<?xml version="1.0" encoding="utf-8"?>
<posts>
  <row Id="1" PostTypeId="1" AcceptedAnswerId="2" CreationDate="2014-02-11T22:24:09.530" Score="49" ViewCount="13292" Body="&lt;p&gt;I'm making a simple Arduino web server and I want to keep it turned on all the time. So it must endure to stay working continuously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Uno with a Ethernet Shield.&#xA;It's powered with a simple outlet power supply 5V @ 1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Will I have any problems leaving the Arduino turned on all the time?&lt;/li&gt;&#xA;&lt;li&gt;Is there some other Arduino board better recommended for this?&lt;/li&gt;&#xA;&lt;li&gt;Are there any precautions that I need to heed regarding this?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3" LastEditorUserId="4" LastEditDate="2014-02-12T15:58:51.040" LastActivityDate="2018-05-08T21:39:18.043" Title="Is an Arduino capable of running 24/7?" Tags="|arduino-uno|web-server|ethernet|" AnswerCount="11" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2" PostTypeId="2" ParentId="1" CreationDate="2014-02-11T22:36:57.700" Score="61" Body="&lt;p&gt;You shouldn't have any issues keeping it on all the time, however, some thing to consider is any counters you may have, like the use of &lt;code&gt;millis()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://arduino.cc/en/Reference/millis&quot;&gt;Arduino docs on millis&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This number will overflow (go back to zero), after approximately 50 days.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So for projects that are on for long periods of time, you may not see an issue immediately but something like this could pop up and cause errors down the road.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-11T22:36:57.700" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3" PostTypeId="2" ParentId="1" CreationDate="2014-02-11T22:40:22.503" Score="34" Body="&lt;p&gt;A couple of things to keep in mind (outside of @Sachleen's mention of &lt;code&gt;millis()&lt;/code&gt;): &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Like any electronics, heat can be disruptive. The micro-controller itself isn't likely going to be a huge issue from the perspective of heat, but other components like the power supply might cause issues. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If your code uses &lt;a href=&quot;http://arduino.cc/en/Reference/EEPROMWrite&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;EEPROM.write()&lt;/code&gt;&lt;/a&gt;, be aware that the EEPROM in your Uno's ATmega328P is only rated for 100,000 writes. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13" LastEditorUserId="26916" LastEditDate="2017-11-04T04:49:35.480" LastActivityDate="2017-11-04T04:49:35.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4" PostTypeId="1" AcceptedAnswerId="11" CreationDate="2014-02-11T22:43:08.173" Score="35" ViewCount="57070" Body="&lt;p&gt;Put plainly: is there a way to get an HTTPS connection on the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been looking in to it, and I have found it is impossible with the standard library and the Ethernet shield, but is there a custom library that can do it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about a coprocessor, i.e. like the WiFi shield has? Anyone know if the Arduino yún has ssl?&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="48" LastEditDate="2014-02-24T17:17:50.090" LastActivityDate="2019-04-27T21:53:57.233" Title="How to get HTTPS on Arduino?" Tags="|ethernet|arduino-yun|web|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5" PostTypeId="2" ParentId="1" CreationDate="2014-02-11T22:47:07.610" Score="12" Body="&lt;p&gt;Running the Arduino 24/7 Shouldn't be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But be sure that you have a case that allows for ventilation and you keep it in a well ventilated area. Just like computers, if you do not keep them in an environment that can keep them cool, they will not stay cool. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Server load also should be a thing to consider, the more load there is on the server the more processing it has to do, and the more heat it will generate.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-11T22:47:07.610" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6" PostTypeId="1" AcceptedAnswerId="31" CreationDate="2014-02-11T22:48:30.837" Score="44" ViewCount="9999" Body="&lt;p&gt;For solar &amp;amp; battery powered projects, decreasing power consumption is a necessity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know a little bit about using a timer and interrupt to put the microcontroller into sleep when it isn't doing anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also read that you can disable some peripherals to further save power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a page explaining these: &lt;a href=&quot;http://arduino720.wikispaces.com/Power+Saving+Techniques&quot;&gt;Power Saving Techniques&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What other techniques are there to save power?&lt;/li&gt;&#xA;&lt;li&gt;Are there any libraries that make using these AVR features easier?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11" LastActivityDate="2015-07-03T12:30:53.297" Title="What are (or how do I use) the power saving options of the Arduino to extend battery life?" Tags="|power|battery|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7" PostTypeId="2" ParentId="1" CreationDate="2014-02-11T22:50:23.247" Score="6" Body="&lt;p&gt;Arduinos can run without issues for a really long time, though depending on local conditions and the intensity of computation you may have to attach heat sinks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, keep it well ventilated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on the program being used, too, if your server is serving a page every now and then, it shouldn't be an issue, but if you expect constant traffic then the Arduino may heat up quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll also want to ensure stability of power supply, when running benchtop experiments with an Arduino this isn't a big issue, bit it can become an issue if transforming power from the mains for a permanent fixture.&lt;/p&gt;&#xA;" OwnerUserId="28" LastActivityDate="2014-02-11T22:50:23.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8" PostTypeId="2" ParentId="4" CreationDate="2014-02-11T22:53:10.947" Score="6" Body="&lt;p&gt;I don't think it is possible due to the size and complexity of the SSL Library, because the Arduino would most likely be under powered. That being said you could make the requests to a regular server and use some sort of PHP script to proxy the request to the HTTPS server. Not sure how well it would work though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be interested into looking at &lt;a href=&quot;http://www.abdulqabiz.com/blog/archives/2007/05/31/php-proxy-script-for-cross-domain-requests/&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-11T22:53:10.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9" PostTypeId="2" ParentId="1" CreationDate="2014-02-11T22:54:56.157" Score="12" Body="&lt;p&gt;Keep in mind that the flash and EEPROM have limited lifetimes (about 10,000 and 100,000 write cycles respectively) so if you're doing a lot of writing to those, they may become corrupted. In a test I did, an external EEPROM took about 3 days to start becoming corrupted.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="33351" LastEditDate="2018-05-08T21:39:18.043" LastActivityDate="2018-05-08T21:39:18.043" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10" PostTypeId="2" ParentId="6" CreationDate="2014-02-11T23:00:13.753" Score="13" Body="&lt;p&gt;You could read through the 200-page datasheet, and then mess with some confusing bit shifts and registers, but I recommend this library: &lt;a href=&quot;http://playground.arduino.cc/Code/Enerlib&quot;&gt;http://playground.arduino.cc/Code/Enerlib&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you're using an Uno or any one with a usb-to-serial chip, you could disable that or remove it.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-11T23:06:51.677" LastActivityDate="2014-02-11T23:06:51.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11" PostTypeId="2" ParentId="4" CreationDate="2014-02-11T23:00:44.073" Score="14" Body="&lt;p&gt;MCUs mounted on Arduinos don't have the horse power to handle https connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yún does handle https &lt;strong&gt;on the linux side&lt;/strong&gt;, with software like curl, wget or python. Your sketch can just delegate the task to the linux side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While curl works fine, despite having python preinstalled, you need to manually install python-openssl, since it's not available out of the box (due to disk space constraints)&lt;/p&gt;&#xA;" OwnerUserId="27" LastEditorUserId="27" LastEditDate="2014-02-11T23:08:21.117" LastActivityDate="2014-02-11T23:08:21.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12" PostTypeId="1" CreationDate="2014-02-11T23:10:53.907" Score="14" ViewCount="801" Body="&lt;p&gt;Is it possible to upgrade the firmware on an Arduino so that it can do more things such as change undervolting/ overvolting in order to provide more processing power. To do this you would have to most likely re flash the chip itself, so how would that be accomplished?&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="220" LastEditDate="2014-02-25T06:34:13.593" LastActivityDate="2014-02-25T06:34:13.593" Title="Installing a different firmware on Arduino" Tags="|arduino-uno|firmware|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13" PostTypeId="1" CreationDate="2014-02-11T23:44:46.803" Score="32" ViewCount="24732" Body="&lt;p&gt;Is it possible to run Linux on Arduino? If yes, what steps and limitations need to be considered? If not, what are the limitations that prevent this?&lt;/p&gt;&#xA;" OwnerUserId="36" LastEditorUserId="4628" LastEditDate="2017-06-02T03:52:41.503" LastActivityDate="2022-02-08T00:48:01.093" Title="What does it take to compile Linux on Arduino, if at all possible?" Tags="|linux|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14" PostTypeId="1" AcceptedAnswerId="1492" CreationDate="2014-02-11T23:57:39.350" Score="16" ViewCount="3016" Body="&lt;p&gt;I have an Arduino Yún, and it only has 16mb flash onboard for the Linux. I was wondering of it is possible to put a bootloader on the flash that uses the sd card as a rootfs? i want to be able to do more projects on it than those that can fit in 16 MB flash.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-10T14:18:33.093" Title="Yún boot from SD card" Tags="|arduino-yun|linux|bootloader|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15" PostTypeId="5" CreationDate="2014-02-12T00:01:07.400" Score="0" Body="&lt;p&gt;The Arduino Uno has become one of the most popular Arduino boards and is now in its third official revision. It is available in DIP and SMD configurations and supports a wide range of shields. There are also many third-party clones that use the same layout and specifications.&lt;/p&gt;&#xA;&lt;p&gt;Use this tag when asking a question about using Uno boards (or exact clones), for example, asking about shield compatibility or pin configuration. Alternatively, use the &lt;a href=&quot;/questions/tagged/arduino-uno-smd&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;arduino-uno-smd&amp;#39;&quot; aria-label=&quot;show questions tagged &amp;#39;arduino-uno-smd&amp;#39;&quot; rel=&quot;tag&quot; aria-labelledby=&quot;tag-arduino-uno-smd-tooltip-container&quot;&gt;arduino-uno-smd&lt;/a&gt; tag when the question is specific to the surface-mount version of the Uno (as opposed to the DIP version).&lt;/p&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;the official Arduino site&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OuoAD.jpg&quot; alt=&quot;Arduino Uno&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Arduino/Genuino Uno is a microcontroller board based on the ATmega328P&#xA;(&lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;). It has 14 digital input/output pins (6 can be&#xA;used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB&#xA;connection, a power jack, an ICSP header, and a reset button. It&#xA;contains everything needed to support the microcontroller;&#xA;Connect it to a computer with a USB cable or power it with an AC-to-DC&#xA;adapter or battery to get started.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Technical specs&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Microcontroller: ATmega328P&lt;/li&gt;&#xA;&lt;li&gt;Operating Voltage: 5V&lt;/li&gt;&#xA;&lt;li&gt;Input Voltage (recommended): 7-12V&lt;/li&gt;&#xA;&lt;li&gt;Input Voltage (limit): 6-20V&lt;/li&gt;&#xA;&lt;li&gt;Digital I/O Pins: 14 (of which 6 provide PWM output)&lt;/li&gt;&#xA;&lt;li&gt;PWM Digital I/O Pins: 6&lt;/li&gt;&#xA;&lt;li&gt;Analog Input Pins: 6&lt;/li&gt;&#xA;&lt;li&gt;DC Current per I/O Pin: 20 mA&lt;/li&gt;&#xA;&lt;li&gt;DC Current for 3.3V Pin: 50 mA&lt;/li&gt;&#xA;&lt;li&gt;Flash Memory: 32 KB (ATmega328P) of which 0.5 KB used by bootloader&lt;/li&gt;&#xA;&lt;li&gt;SRAM: 2 KB (ATmega328P)&lt;/li&gt;&#xA;&lt;li&gt;EEPROM: 1 KB (ATmega328P)&lt;/li&gt;&#xA;&lt;li&gt;Clock Speed: 16 MHz&lt;/li&gt;&#xA;&lt;li&gt;LED_BUILTIN: 13&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3&gt;Notes&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &amp;quot;Input Voltage&amp;quot; above refers to the power input (to the power jack), not the amount of voltage you can put on the input pins (which is a maximum of 5 V).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The six analog input pins can also be used as digital pins, so you actually have 20 pins that can be used for digital input/output.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Resources&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Schematics for revision 3&lt;/a&gt; (PDF)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8" LastEditorUserId="90086" LastEditDate="2023-07-28T08:15:29.637" LastActivityDate="2023-07-28T08:15:29.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16" PostTypeId="4" CreationDate="2014-02-12T00:01:07.400" Score="0" Body="The Arduino Uno is the most common of the Arduino boards. It is based on the ATmega328P microcontroller." OwnerUserId="37" LastEditorUserId="26916" LastEditDate="2017-04-03T18:57:56.740" LastActivityDate="2017-04-03T18:57:56.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17" PostTypeId="1" AcceptedAnswerId="18" CreationDate="2014-02-12T00:08:14.933" Score="181" ViewCount="578096" Body="&lt;p&gt;I made an awesome program the other day, and I wanted to upload it to my Arduino. After clicking the upload button, some mean dude named avr came along and stopped me, saying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;All&lt;/em&gt; I want to do is just upload my program, but avr won't let me. He's even unintelligible, so can someone tell me what the heck he's trying to say and how to get rid of him?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;i.e.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I try to upload a program to my Arduino, I get this error message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What does this mean, and how can I fix it?&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="4143" LastEditDate="2018-03-25T18:31:23.553" LastActivityDate="2021-06-06T17:15:21.123" Title="&quot;avrdude: stk500_getsync(): not in sync: resp=0x00,&quot; aka Some Dude Named Avr Won't Let Me Upload My Program" Tags="|uploading|avrdude|faq|" AnswerCount="21" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18" PostTypeId="2" ParentId="17" CreationDate="2014-02-12T00:08:14.933" Score="114" Body="&lt;p&gt;This is caused by a generic connection error between your computer and the Arduino, and can result from many different specific problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some easy things that can often fix this error:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disconnect and reconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Press the reset button on the board.&lt;/li&gt;&#xA;&lt;li&gt;Restart the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you select the right board in &lt;code&gt;Tools ► Board ►&lt;/code&gt;, e.g. If you are using the Duemilanove 328, select that instead of Duemilanove 128. The board should say what version it is on the microchip.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you selected the right port in &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt;. One way to figure out which port it is on is by following these steps:&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Go to &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt; and see which ports are listed (e.g. COM4 COM5 COM14).&lt;/li&gt;&#xA;&lt;li&gt;Reconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Go back to &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt;, and see which port appeared that wasn't there before.&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make sure digital pins 0 and 1 do not have any parts connected, including any shields.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If none of those work, you will want to try to isolate the issue by replacing things: try a different computer on the same arduino, try a different arduino on the same computer, and try using a different USB cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the issue is with the computer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Double-check all computer-related issues in the &quot;easy fixes&quot; list above.&lt;/li&gt;&#xA;&lt;li&gt;Reinstall the IDE.&lt;/li&gt;&#xA;&lt;li&gt;Reinstall the drivers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the issue is with the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Double-check all board-related issues in the &quot;easy fixes&quot; list above.&lt;/li&gt;&#xA;&lt;li&gt;Make sure the microcontroller is seated correctly.&lt;/li&gt;&#xA;&lt;li&gt;You may need to &lt;a href=&quot;https://arduino.stackexchange.com/a/474/37&quot;&gt;burn the bootloader&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Replace the microcontroller if you have another one handy nearby.&lt;/li&gt;&#xA;&lt;li&gt;You may have bricked your Arduino. Sorry :(&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2018-09-27T21:09:13.663" LastActivityDate="2018-09-27T21:09:13.663" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="19" PostTypeId="2" ParentId="13" CreationDate="2014-02-12T00:11:57.577" Score="22" Body="&lt;p&gt;Linux is a very complex operating system, but it may be able to fit on an Arduino. Things to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is no current AVR port of the source code.&lt;/li&gt;&#xA;&lt;li&gt;You would have no graphics, instead access the terminal over UART.&lt;/li&gt;&#xA;&lt;li&gt;The filesystem driver would have to be rewritten to access internal flash or an external SD card.&lt;/li&gt;&#xA;&lt;li&gt;It would be &lt;em&gt;extremely&lt;/em&gt; slow! The ATmega328 would run at 16 MHz, or about 20 MHz max (overclocked). Most Linux machines run at a minimum of 400 MHz, and more with graphics.&lt;/li&gt;&#xA;&lt;li&gt;You would probably need some extra RAM, probably a good idea to use an ATmega2650 (the one in the Mega), which has 16 times the RAM of the Uno. You could also use a Due (6x as fast as the Uno, more RAM).&lt;/li&gt;&#xA;&lt;li&gt;You may have to write special USB drivers for OTG (on the Due) or MAX3421EE (Mega ADK, USB host shield).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In short, it would take &lt;em&gt;a lot&lt;/em&gt; of time and effort, and probably would be too slow for everyday use. If you really want Arduino Linux, check out the Yún.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="4628" LastEditDate="2017-06-02T03:52:06.327" LastActivityDate="2017-06-02T03:52:06.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20" PostTypeId="2" ParentId="13" CreationDate="2014-02-12T00:12:59.517" Score="18" Body="&lt;p&gt;It just doesn't have enough RAM. You'd also need to teach it to boot from flash memory, which would involve rewriting the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can instead use an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun?from=Main.ArduinoYUN&quot;&gt;Arduino Yun&lt;/a&gt; or a &lt;a href=&quot;http://www.pcduino.com/&quot;&gt;PCDuino&lt;/a&gt;; while not &quot;standard&quot; Arduinos these support Arduino shields and run Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or there's always the &lt;a href=&quot;http://www.raspberrypi.org/&quot;&gt;Raspberry Pi&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="28" LastEditDate="2014-02-12T03:19:32.823" LastActivityDate="2014-02-12T03:19:32.823" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21" PostTypeId="2" ParentId="17" CreationDate="2014-02-12T00:15:36.627" Score="12" Body="&lt;p&gt;If none of the above steps work, try reinstalling Avrdude and the avr-gcc compiler. I had to do this after my Mega started suffering from this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you installed Avrdude and avr-gcc separately, simply uninstall them. if not, you may have to reinstall the Arduino IDE. These steps will depend on your operating system.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-12T00:15:36.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22" PostTypeId="2" ParentId="17" CreationDate="2014-02-12T00:20:15.987" Score="13" Body="&lt;p&gt;Unfortunately, it can also mean that you burned your microcontroller. Were you doing anything dangerous right before you tried to upload a new sketch? Is the microcontroller still working, with its previously loaded sketch?&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-02-12T00:20:15.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23" PostTypeId="5" CreationDate="2014-02-12T00:25:43.427" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoYunFront_2_450px.jpg&quot; &gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. The Atheros processor supports a Linux distribution based on &lt;a href=&quot;http://en.wikipedia.org/wiki/OpenWrt&quot; rel=&quot;nofollow noreferrer&quot;&gt;OpenWrt&lt;/a&gt; named Linino. The board has built-in Ethernet and Wi-Fi support, a USB-A port, micro-SD card slot, 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a 3 reset buttons.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(From &lt;a href=&quot;https://arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arduino.cc/en/Main/ArduinoBoardYun&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main differences between the Yún and other Arduinos is that the Yún contains an onboard Wi-Fi antenna used to program the board wirelessly, connect to the Internet in sketches, or see various information about the board. The Yún also contains a Linux side, which is different because most boards only have one onboard processor. The Yún has two onboard processors; one for the system and one for the Linux part. One can connect to the Linux side of the Yún via &lt;a href=&quot;https://arduino.cc/en/Reference/YunBridgeLibrary#.UwpmrfkiEw8&quot; rel=&quot;nofollow noreferrer&quot;&gt;a Bridge library&lt;/a&gt;. Python 2.7 is also included with the Yún.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider using other related tags such as &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; or &lt;a href=&quot;/questions/tagged/pins&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pins&amp;#39;&quot; rel=&quot;tag&quot;&gt;pins&lt;/a&gt; more specific to your problem.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:35.923" LastActivityDate="2015-09-08T13:14:18.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24" PostTypeId="4" CreationDate="2014-02-12T00:25:43.427" Score="0" Body="The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. Use this tag for questions specifically regarding the Yún, and not just general Arduino usage." OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T23:17:03.917" LastActivityDate="2014-02-23T23:17:03.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25" PostTypeId="1" AcceptedAnswerId="33" CreationDate="2014-02-12T00:49:24.257" Score="5" ViewCount="649" Body="&lt;p&gt;I have an original Arduino UNO R3 that I bought and an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;nofollow&quot;&gt;Arduino Severino (S3V3)&lt;/a&gt; that I've built.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no problems uploading sketches to the UNO, but sometimes, when uploading to the Severino board, I have to hard reset it at a specific time during the upload process, when the IDE says something like this below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : \\.\COM1&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I don't reset it when one of the &lt;code&gt;Send&lt;/code&gt; messages are being displayed, I get the &lt;code&gt;not in sync&lt;/code&gt; message, as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Recv: &#xA;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other times, if I'm lucky, I can upload to the Severino board without having to reset it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why does that happen? Why Severino needs a hard reset during upload?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why is the problem intermitent?&lt;/strong&gt; Why does it happen sometimes and others it doesn't?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;How can I fix that problem?&lt;/strong&gt; Is there a simple change to the Severino design that would fix that?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-02-15T12:53:44.100" LastActivityDate="2014-02-15T12:53:44.100" Title="Why Arduino Severino (S3V3) sometimes needs reseting when uploading a sketch?" Tags="|severino|reset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26" PostTypeId="1" AcceptedAnswerId="561" CreationDate="2014-02-12T01:10:46.997" Score="10" ViewCount="1354" Body="&lt;p&gt;The strangest thing is happening to a standalone Arduino board that I designed and built. The board (whose schematics are below) has the following features:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It has a ATmega328P with a 5V voltage regulator and usual circuitry when set up as a standalone controller. &lt;/li&gt;&#xA;&lt;li&gt;It controls a scoreboard with several 7-display digits linked through the connectors on the right (JP1 through JP12). &lt;/li&gt;&#xA;&lt;li&gt;It has cursor buttons decoded using a voltage ladder through ANALOG_0 (A0).&lt;/li&gt;&#xA;&lt;li&gt;It has a Real Time Clock to keep time when it's turned off.&lt;/li&gt;&#xA;&lt;li&gt;It has an RF receiver module.&lt;/li&gt;&#xA;&lt;li&gt;It has a UART header (JP17) so I can program the board using a serial port.&lt;/li&gt;&#xA;&lt;li&gt;It has a speaker attached to digital pin 3 (D3). &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/21kgT.png&quot; alt=&quot;Controller schematics&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I upload sketches to it using a RS232-to-TTL adapter that I've also built (schematics also below) and a Serial-to-USB cable. When programming it, the board behaves much like a &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;noreferrer&quot;&gt;Severino board&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/h3HJq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's strange is that, when I upload a sketch, the process is paused in the middle and then the speaker starts to beep continually. It pauses with the following avrdude messages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, &lt;a href=&quot;http://www.bdmicro.com/&quot; rel=&quot;noreferrer&quot;&gt;http://www.bdmicro.com/&lt;/a&gt;&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     System wide configuration file is &quot;C:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;     Using Port                    : \\.\COM1&#xA;     Using Programmer              : arduino&#xA;     Overriding Baud Rate          : 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press reset on the board, avrdude continues outputting its messages (such as below), the beep stops, the upload continues and the sketch is uploaded successfully to the board.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;... messages and upload continue and completes successfully.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have the rest of the messages handy here, but I hope you get the idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;What is making the upload process pause?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Why is the buzzer beeping when the process pauses?&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-02-15T12:52:43.017" LastActivityDate="2014-05-03T17:29:19.923" Title="Custom Arduino board beeps and process freezes while I'm uploading a sketch to it. Why?" Tags="|severino|serial|" AnswerCount="3" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="27" PostTypeId="1" AcceptedAnswerId="32" CreationDate="2014-02-12T01:34:28.287" Score="20" ViewCount="9690" Body="&lt;p&gt;I've made a clock using an Arduino, but the time seems to drift.  I am aware of the &lt;a href=&quot;https://arduino.stackexchange.com/questions/1/is-an-arduino-capable-of-running-24-7/2#2&quot;&gt;rollover&lt;/a&gt; issue; the clock seems to drift by about 15 minutes over the course of a week.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a custom PCB with &lt;a href=&quot;http://www.digikey.com/product-search/en/crystals-and-oscillators/resonators/852887?k=x908-nd&quot;&gt;this resonator&lt;/a&gt; from Digi-key.  The code reads the millis() function at the beginning of each loop, and works from that value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:  How can I measure time with an Arduino, accurately enough to make a passable desk clock?&lt;/p&gt;&#xA;" OwnerUserId="59" LastActivityDate="2016-02-29T20:35:37.060" Title="How do I get an accurate time?" Tags="|time|millis|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28" PostTypeId="1" AcceptedAnswerId="35" CreationDate="2014-02-12T01:37:23.670" Score="11" ViewCount="6392" Body="&lt;p&gt;I have been able to connect MATLAB to my Uno with this line of code: &lt;code&gt;a = arduino('COM4');&lt;/code&gt; through this package: &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/32374-matlab-support-package-for-arduino-aka-arduinoio-package&quot; rel=&quot;noreferrer&quot;&gt;Matlab support package for Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, MATLAB is my main script that will synchronize all the components [like the Arduino].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to send pulses to my stepper-motor just by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    digitalWrite(2, HIGH);&#xA;    delay(1);&#xA;    digitalWrite(2, LOW);&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine, and will make the motor move about once every 2 milliseconds. My problem is that I cannot find a way to produce this same delay through MATLAB's interface. I do know that MATLAB has a &lt;code&gt;pause()&lt;/code&gt; function, but when I set up a loop in MATLAB like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = arduino('COM4');&#xA;for m = 1:400&#xA;    a.digitalWrite(2, 1);&#xA;    pause(0.001);&#xA;    a.digitalWrite(2, 0);&#xA;    pause(0.001);&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each step takes WAY longer - about 200 milliseconds each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are other options for creating the pause between digital High / Low being sent to the Arduino? It would be nice if I could control the outcome from Matlab, through Arduino.&lt;/p&gt;&#xA;" OwnerUserId="25" LastEditorUserId="65" LastEditDate="2014-03-09T12:43:25.033" LastActivityDate="2018-06-23T00:06:30.913" Title="How to pause Arduino for 1 millisecond through MATLAB?" Tags="|arduino-uno|matlab|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="29" PostTypeId="2" ParentId="1" CreationDate="2014-02-12T01:48:43.063" Score="4" Body="&lt;p&gt;I've never ran an Arduino for that long, but there shouldn't be a problem. One thing to watch out for is the input voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While an Arduino is capable of handling 7-20v as input anything over 12v can overheat after longer periods of time and cause board damage. As a quick recommendation to avoid any overheating of the Arduino I would keep the voltage as close to 7v as possible.&lt;/p&gt;&#xA;" OwnerUserId="62" LastActivityDate="2014-02-12T01:48:43.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="30" PostTypeId="2" ParentId="12" CreationDate="2014-02-12T01:50:03.943" Score="6" Body="&lt;p&gt;Note the below chart, in regard to your under/over volting the device for different F_CPU, indicates the relationship. As a result you find most Arduino's run at 5V and a clock rate of 16MHz. While there are some 3.3V variants that run at 8MHz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qS5z1.png&quot; alt=&quot;Freq vs Vcc&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the core library provided with the IDE typically has specific #if's for both 8 and 16 MHz F_CPU speeds, not using a formula in most places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence it is possible to do what you ask. However, you will find the core library limitations affecting. Tipping the cost vs benefit ratio, to that of the very intent. And then likely one would leave the Stock IDE and core libraries to a more makefile method.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-12T01:50:03.943" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="31" PostTypeId="2" ParentId="6" CreationDate="2014-02-12T01:53:50.100" Score="35" Body="&lt;p&gt;&lt;em&gt;Note: I wanted to point out that, even though my answer was accepted, the reader (you) should really read Anindo's answer first if you really want to save energy with any Arduino board. Once you address those items in your design, then you should read my answer and worry about how to set the MCU into low power mode.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, there are several techniques to make an Arduino save power. I'll list a few and then point you to a page that explains them all in more detail.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;While the controller isn't doing anything important (between one read of a sensor and the next, for example), you can put the controller into one of the sleep modes below, with the command &lt;code&gt;set_sleep_mode (SLEEP_MODE_PWR_DOWN)&lt;/code&gt;. Next to each mode is the approximate power consumption of each mode. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SLEEP_MODE_IDLE: 15 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_ADC: 6.5 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_PWR_SAVE: 1.62 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_EXT_STANDBY: 1.62 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_STANDBY : 0.84 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_PWR_DOWN : 0.36 mA&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Disable &lt;strong&gt;brown-out detection&lt;/strong&gt; (the circuitry that turns off the controller when low voltage is detected).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn off ADC (analog to digita conversion)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the internal clock&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then, when you put the controller to sleep, you need to use one or more mechanisms below to wake up the controller and do something with it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Wake up with a signal&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wake up with a timer&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is a summary I made from -&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot;&gt;Nick Gammon's article: Power saving techniques for microprocessors&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That article applies mostly to ATmega328P, but the technique applies to other Arduino compatible controllers as well. As TheDoctor said well, you will need to check the datashet to make sure your controller suports any of those techniques and how to do it more precisely.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-07-03T12:30:53.297" LastActivityDate="2015-07-03T12:30:53.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="32" PostTypeId="2" ParentId="27" CreationDate="2014-02-12T02:07:08.230" Score="17" Body="&lt;p&gt;&lt;em&gt;Note: although my answer was accepted and has a higher vote score, make sure you read &lt;a href=&quot;https://arduino.stackexchange.com/a/9039/46&quot;&gt;Edgar Bonet's great answer&lt;/a&gt; on how to make your Arduino keep time without an RTC.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been quite successful in using the DS1307 Real Time Clock. Here's a link to its &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS1307.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are some of its features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;It uses IC interface for communication with Arduino, making it easy to program using the right libraries (available on the Net).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It is connected to Arduino through the SCL and SDA pins (analog A4 and A5 respectively), thus only using 2 pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It requires very little external components to run.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;IT can be connected to a coin cell battery so it will keep time even while the Arduino is turned off. In its low power mode, the coin cell battery lasts for years.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It drifts very little (in my case it only drifts a few seconds per week).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It's not very expensive.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you don't intend to use an RTC, you can replace the crystal that is commonly used to provide clock to arduino for a &lt;strong&gt;crystal oscillator module&lt;/strong&gt; like &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS1307.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one from Farnel&lt;/a&gt; or &lt;a href=&quot;http://www.digikey.com/product-detail/en/ECS-2200BX-200/XC1188-ND/827295&quot; rel=&quot;nofollow noreferrer&quot;&gt;this other one&lt;/a&gt;. They come in 4 pin packages like in the images below. They will generate a much more precise clock for your arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OjaoR.jpg&quot; alt=&quot;Crystal oscillator image&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/aTIAn.jpg&quot; alt=&quot;Crystal oscillator image&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ay7KD.png&quot; alt=&quot;Crystal oscillator image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both modules mentioned have tolerances of 50 ppm and operate at 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, just to be clear, these crystal oscillator modules are not to be confused with regular 2 pin &lt;strong&gt;crystal&lt;/strong&gt; like this below. Those are part of the circuitry of external clocks for MCUs, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/a52VR.png&quot; alt=&quot;Crystal oscillator&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-02-29T20:35:37.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="33" PostTypeId="2" ParentId="25" CreationDate="2014-02-12T02:24:06.803" Score="3" Body="&lt;p&gt;&lt;strong&gt;Why does that happen?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the serial port is opened by either monitor, avrdude or other it toggles the DTR pin of the serial port. Which in turn is AC coupled through C4 100nF. This toggling is converted to a up and down pulse on the ATmega(CPU)'s RESET pin. The subsequent reset starts initially with the boot loader, which typically in turn waits for a avrdude's semiphore (e.i. Send: 0 [30]   [20] ) and if seen then responds in turn and if not seen after a timeout period (typically 5s) it continues on with the application in flash space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You behavior is describing either; not hearing the response. Or the reset is not getting triggered. Since it does work some times I suspect its prior, but the later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why Severino needs a hard reset during upload?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This statement further supports the later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why is the problem intermitent?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the pulse is almost long and strong enough, where the DTR toggle is in code and likely has some significant inconsistency. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I fix that problem?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, change the value of C4 100nF and or R11 10K, to better pass the toggle. I could derive some EE explanation of what value to pick. But I would suggest some trial and error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also have 5V clamping, as the RS232 levels can reach +/-12V (typically +/-9V) where the AC coupling prevents the DC and burn out. but the AC will stress it.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-12T02:24:06.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="34" PostTypeId="2" ParentId="27" CreationDate="2014-02-12T02:37:28.697" Score="6" Body="&lt;p&gt;The resonator you specified has a 0.3% stability, where the crystal or crystal oscillator (as mentioned by Ricardo) is 50ppm. Many times more stable. Not to even mention the temperature drift of resonator is horrible. Heating by sunlight will change it. Hence a resonator should not be used for keeping time over long periods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence using either a crystal or crystal oscillator will get what you want. Either using it on the ATmega and set the fuses respectively or us one connected to an RTC.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-12T02:37:28.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="35" PostTypeId="2" ParentId="28" CreationDate="2014-02-12T02:51:06.470" Score="8" Body="&lt;p&gt;The increased in observed delay is due to the time it takes to send the command from MATLAB to the Arduino have its code execute the requested command. In your case the a.digitalWrite. So actual time between pulses using MATLAB's delay is 0.001 pause plus the time of baud rate times the packet size and decoding then execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend not pursuing this solution of the MATLAB controlling the timing of Step Motors, remotely. As this latent coupling will be a frustrating limitation. Noting that for step motors the timing can not afford such latent execution. Hence all the 3D printers and many CNC with Step Motors use Arduino's which get G-Code (motor move commands with destinations) and the Real-time firmware handles the stepping, within tolerances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using something like grbl firmware with step motor shield and then have the MATLAB send the needed G-code. Where there are others with much more features but tailored to 3d Printing. grbl is simpler and straight to the point of moving motors.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-12T02:51:06.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="36" PostTypeId="1" AcceptedAnswerId="174" CreationDate="2014-02-12T02:59:15.323" Score="15" ViewCount="33115" Body="&lt;p&gt;If you want to submit sensor data such as temperature to a remote server/database somewhere you need to use some kind of call to a web server since it isn't possible to connect directly to a database from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you post data to a JSON web service from an Arduino that's connected to the Internet?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="220" LastEditDate="2014-03-01T13:23:29.430" LastActivityDate="2016-04-26T16:01:24.773" Title="Post Data To a Web Service From Arduino" Tags="|web-service|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="37" PostTypeId="1" AcceptedAnswerId="67" CreationDate="2014-02-12T03:05:17.680" Score="15" ViewCount="316" Body="&lt;p&gt;I would like my compiles to exclude some code depending upon the flash/program space available. To be used in the demo code of a library I support. Whereas my current solution is to use a #ifdef of processor type. But I would like to be more general and not have to specify all the various chips. Rather it would be nice if there was a pre-processor constant that stated the available size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I am not fluent enough in gcc and or avr-gcc I might expect to find some constants similar those that define the beginning and end of the heap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On case example. Is that both the UNO and Leo have 32K of Flash. But the Leo's core library uses 4K for USB support, resulting in only 28K available. My Library's demo is near max'ed out on the UNO and I would like to automatically trim out based on available program space. &lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="37523" LastEditDate="2019-11-16T18:59:30.073" LastActivityDate="2019-11-16T18:59:30.073" Title="Is there a preprocessor constant for memory size" Tags="|compile|sketch-size|avr-gcc|gcc|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="38" PostTypeId="1" CreationDate="2014-02-12T04:08:51.807" Score="2" ViewCount="1636" Body="&lt;p&gt;I am working on a real time application which is recording sensor data continuously. I need to process the data in realtime using R. Is there a way to connect and communicate with the uno board through RStudio via serial port?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-12T13:55:27.613" LastActivityDate="2014-02-12T16:19:51.607" Title="How do I communicate with the Uno using R through RStudio?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ClosedDate="2014-02-15T20:28:58.753" ContentLicense="CC BY-SA 3.0" />
  <row Id="39" PostTypeId="1" AcceptedAnswerId="49" CreationDate="2014-02-12T04:10:06.223" Score="12" ViewCount="832" Body="&lt;p&gt;I bought an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;noreferrer&quot;&gt;Ethernet Shield R3&lt;/a&gt; for my &lt;a href=&quot;http://startingelectronics.com/articles/arduino/uno-r3-r2-differences/&quot; rel=&quot;noreferrer&quot;&gt;Arduino Uno R2&lt;/a&gt;, but since R3 has extra pins it does not fit. Can I use the shield? Should I cut off the extra pins. What do I need to do to make it work?&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="220" LastEditDate="2014-02-25T01:57:21.940" LastActivityDate="2014-02-25T01:57:21.940" Title="Arduino Uno R2 and Ethernet Shield R3 compatibility" Tags="|ethernet|arduino-uno|shields|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="40" PostTypeId="1" AcceptedAnswerId="43" CreationDate="2014-02-12T04:22:30.253" Score="94" ViewCount="18941" Body="&lt;p&gt;The basic Arduino IDE lacks a lot of the sophistication present in other IDEs such as code completion, code collapsing, folder organisation, etc. Are there other IDEs that allow programming in C or C++ and improve on these aspects?&lt;/p&gt;&#xA;" OwnerUserId="76" LastEditorUserId="972" LastEditDate="2018-04-09T13:48:38.137" LastActivityDate="2020-07-14T09:10:38.133" Title="What are the other IDEs for Arduino?" Tags="|programming|arduino-ide|c++|ide|" AnswerCount="22" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="41" PostTypeId="2" ParentId="39" CreationDate="2014-02-12T04:22:58.283" Score="1" Body="&lt;p&gt;The extra pins do not matter. Just leave them. If you really want, cut them off, but this will remove some compatibility with other products.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They should hang off the ends of the headers closest to the power/USB end of the board.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-12T04:43:53.717" LastActivityDate="2014-02-12T04:43:53.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="42" PostTypeId="1" AcceptedAnswerId="65" CreationDate="2014-02-12T04:24:33.670" Score="15" ViewCount="1703" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; What registers do I use to access the IO on the Arduino Uno when I am using assembly for programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;  I was interested in practicing my assembly language skills on the Arduino (I thought it would be easier to turn LEDs on/off than to worry about console IO).  From doing a &lt;a href=&quot;https://electronics.stackexchange.com/q/12750/17375&quot;&gt;preliminary search&lt;/a&gt;, I have found that the AVR toolchain can be used to program the Arduino.  Yet, I don't quite know how to find the corresponding registers for the IO pins.&lt;/p&gt;&#xA;" OwnerUserId="52" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-02-12T06:34:29.143" Title="Assembly on the Arduino: IO registers" Tags="|software|avr-toolchain|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="43" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T04:25:27.440" Score="65" Body="&lt;p&gt;There is an &lt;a href=&quot;http://sloeber.io&quot; rel=&quot;noreferrer&quot;&gt;Arduino Eclipse plugin named sloeber&lt;/a&gt;! And Eclipse is an awesome cross-platform open-source IDE!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Robot-Will/Stino&quot; rel=&quot;noreferrer&quot;&gt;Stino&lt;/a&gt; is good. It requires &lt;a href=&quot;http://www.sublimetext.com/2&quot; rel=&quot;noreferrer&quot;&gt;Sublime Text 2&lt;/a&gt; which has an indefinite free trial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;noreferrer&quot;&gt;Visual Micro&lt;/a&gt; provides a full build system with debugger for Arduino in &lt;a href=&quot;https://www.visualstudio.com/vs/whatsnew/&quot; rel=&quot;noreferrer&quot;&gt;Microsoft Visual Studio&lt;/a&gt;. For advanced users it also allows the underlying Arduino source code to be viewed or modified, enabled projects and/or libraries to be edited from any location and shared in multiple projects alongside true &lt;a href=&quot;http://www.visualmicro.com/post/2017/01/16/Arduino-Cross-Platform-Library-Development.aspx&quot; rel=&quot;noreferrer&quot;&gt;cross-platform intellisense&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more go to &lt;a href=&quot;http://playground.arduino.cc/Main/DevelopmentTools&quot; rel=&quot;noreferrer&quot;&gt;The Official Arduino Site&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For development on Windows, there is a special edition from Arduino official IDE called &lt;a href=&quot;https://code.google.com/p/arduino-erw/&quot; rel=&quot;noreferrer&quot;&gt;arduino-erw&lt;/a&gt;, This edition much better the last one because it fixed a lot of lagging and stability issues!&lt;/p&gt;&#xA;" OwnerUserId="77" LastEditorUserId="18478" LastEditDate="2017-07-19T12:52:40.577" LastActivityDate="2017-07-19T12:52:40.577" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="44" PostTypeId="5" CreationDate="2014-02-12T04:28:52.263" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-12T04:28:52.263" LastActivityDate="2014-02-12T04:28:52.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="45" PostTypeId="4" CreationDate="2014-02-12T04:28:52.263" Score="0" Body="Use this tag for questions relating to computer software used for interaction with the Arduino.  For example, you could use this tag for questions about programming environments, or you could use it for PC/Arduino communication." OwnerUserId="52" LastEditorUserId="52" LastEditDate="2014-02-12T14:43:20.430" LastActivityDate="2014-02-12T14:43:20.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="46" PostTypeId="5" CreationDate="2014-02-12T04:28:53.093" Score="0" Body="&lt;p&gt;The process of programming consists of several stages, including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;editing the source code&lt;/li&gt;&#xA;&lt;li&gt;managing libraries and build events&lt;/li&gt;&#xA;&lt;li&gt;compiling/linking the program (or sketch)&lt;/li&gt;&#xA;&lt;li&gt;debugging the program when it is running&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the case of Arduino, it typically also involves uploading the sketch to a device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each part of this process is often managed by a separate program. These are often command-line based, and can be quite difficult to learn. However, an &lt;b&gt;I&lt;/b&gt;ntegrated &lt;b&gt;D&lt;/b&gt;evelopment &lt;b&gt;E&lt;/b&gt;nvironment (&lt;strong&gt;&lt;em&gt;IDE&lt;/em&gt;&lt;/strong&gt;) combines everything into one application, and often automates several common tasks. This simplifies the programmer's workflow, allowing him/her to focus more on the project at hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The official &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino software&lt;/a&gt; is a very light-weight IDE, based on the &lt;a href=&quot;http://www.processing.org/&quot; rel=&quot;nofollow&quot;&gt;Processing Development Environment&lt;/a&gt;. It includes all of the essential functionality for writing and uploading Arduino sketches, but lacks several features which are found in more sophisticated applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some users prefer more mainstream IDEs, which can have plug-ins or extensions to support Arduino. These include Eclipse, Visual Studio, and XCode. More information about alternative IDEs can be found on &lt;a href=&quot;http://arduino.stackexchange.com/questions/40/what-are-the-other-ides-for-arduino&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the question is about the official Arduino IDE use the &lt;a href=&quot;/questions/tagged/arduino-ide&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;arduino-ide&amp;#39;&quot; rel=&quot;tag&quot;&gt;arduino-ide&lt;/a&gt; tag.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-03-01T19:10:46.180" LastActivityDate="2014-03-01T19:10:46.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="47" PostTypeId="4" CreationDate="2014-02-12T04:28:53.093" Score="0" Body="Integrated Development Environment - software that allows you to write and compile code. Use the arduino-ide tag for questions about the official Arduino software." OwnerUserId="-1" LastEditorUserId="11" LastEditDate="2014-03-01T18:26:35.303" LastActivityDate="2014-03-01T18:26:35.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="48" PostTypeId="2" ParentId="42" CreationDate="2014-02-12T04:31:18.417" Score="1" Body="&lt;p&gt;Check this out: &lt;a href=&quot;http://arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/PortManipulation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also: &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/PinMapping168&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for other ports and pins, check put the datasheet for your controller, they're really useful to people who can understand them! :)&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-12T04:31:18.417" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="49" PostTypeId="2" ParentId="39" CreationDate="2014-02-12T04:35:03.777" Score="4" Body="&lt;p&gt;The only issue that may create an incompatibility seems to be the IOREF pin next the 5V output pin which is extra on Revision 3 but not in Revision 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I just had a look at the board schematics and the shield does not use IOREF.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hOkcc.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;strong&gt;Pin 2 is extending IOREF&lt;/strong&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the shield should work correctly with the Uno Revision 2. As far as the extra pins are concerned, I would recommend not damaging them in any way. If you absolutely &lt;em&gt;need&lt;/em&gt; to, then just try to bend them outwards very carefully.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-12T06:25:23.840" LastActivityDate="2014-02-12T06:25:23.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="50" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T04:43:09.393" Score="11" Body="&lt;p&gt;Majenko created and maintains &lt;a href=&quot;http://uecide.org/&quot;&gt;UECIDE&lt;/a&gt;. His contributions are pretty epic; I've seen first hand his coding prowess as we &lt;a href=&quot;http://www.chipkit.net/forum/viewtopic.php?f=18&amp;amp;t=2530&quot;&gt;worked together&lt;/a&gt; to get the &lt;a href=&quot;http://www.adafruit.com/products/802&quot;&gt;Adafruit 1.8&quot; TFT Joystick shield&lt;/a&gt; working on the chipKIT platform.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-02-12T04:43:09.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="51" PostTypeId="2" ParentId="27" CreationDate="2014-02-12T04:48:40.460" Score="2" Body="&lt;p&gt;I understand a lot of the spirit with Arduino is being frugal and occasionally trudging through a problem. I use Arduino (and now chipKIT, since it's got 10x the RAM and 10x the clock speed) for my workplace and I need &quot;peripheral functions&quot; to be up to speed and working as quickly as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the sparkfun real time clock in one of my projects and am very happy with it. They also have a &lt;a href=&quot;https://www.sparkfun.com/products/10160&quot; rel=&quot;nofollow&quot;&gt;&quot;Dead on&quot; variant&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-02-12T04:48:40.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="52" PostTypeId="1" AcceptedAnswerId="66" CreationDate="2014-02-12T04:54:51.720" Score="14" ViewCount="744" Body="&lt;p&gt;I have a uno that I have been using for 3 years now. I will be using it again in a rather critical project in which failure on the part of the board could be rather expensive and dangerous. So, I would like to be sure that the board is not approaching end of life or going to fail anytime soon. Is there any reliable way to figure out how long the board will function without failing or reduction in performance?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-02-13T14:31:27.243" Title="How do I figure out if my board is approaching end of life?" Tags="|arduino-uno|safety|reliability|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="53" PostTypeId="5" CreationDate="2014-02-12T05:04:26.057" Score="0" Body="&lt;p&gt;Millis is a standard library function. It returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more, see the &lt;a href=&quot;http://arduino.cc/en/Reference/millis&quot; rel=&quot;nofollow&quot;&gt;standard reference&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="48" LastEditDate="2014-02-12T14:39:25.280" LastActivityDate="2014-02-12T14:39:25.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="54" PostTypeId="4" CreationDate="2014-02-12T05:04:26.057" Score="0" Body="Is a standard library function. It returns the number of milliseconds since the Arduino board began running the current program." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-12T14:43:11.600" LastActivityDate="2014-02-12T14:43:11.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="56" PostTypeId="1" CreationDate="2014-02-12T05:16:33.357" Score="18" ViewCount="10206" Body="&lt;p&gt;I want to unit test my Arduino code. Ideally, I want to execute and test my code without uploading it to the board. What tools or libraries can help me with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an &lt;a href=&quot;http://radpartbrainmat.blogspot.in/search/label/arduemu&quot;&gt;Arduino emulator&lt;/a&gt; in development which could be useful, but it doesn't yet seem to be ready for use.&lt;/p&gt;&#xA;" OwnerUserId="77" LastEditorUserId="65" LastEditDate="2014-03-09T12:48:53.587" LastActivityDate="2014-04-01T21:55:20.263" Title="What is the best way to unit test my code without controller?" Tags="|programming|testing|" AnswerCount="3" CommentCount="2" ClosedDate="2016-01-22T22:12:57.617" ContentLicense="CC BY-SA 3.0" />
  <row Id="57" PostTypeId="1" AcceptedAnswerId="84" CreationDate="2014-02-12T05:21:37.753" Score="-4" ViewCount="804" Body="&lt;p&gt;I have not already started to try but I'm a good webmaster and I'm just asking which way is more suitable for sending and keeping data from sensors and I/0 state in a database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some points:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Post versus get&lt;/li&gt;&#xA;&lt;li&gt;MySQL or others types&lt;/li&gt;&#xA;&lt;li&gt;Security layers&lt;/li&gt;&#xA;&lt;li&gt;Graphics render of data's (google API?)&lt;/li&gt;&#xA;&lt;li&gt;PHP, ruby, JavaScript...&lt;/li&gt;&#xA;&lt;li&gt;Able to send data request's to Arduino's&lt;/li&gt;&#xA;&lt;li&gt;Ethernet shield, wifi, I2c ???&lt;/li&gt;&#xA;&lt;li&gt;Access via Android app...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway, the goal here is to know pros and cons of integrate all my Arduino through database.&lt;/p&gt;&#xA;" OwnerUserId="78" LastEditorUserId="220" LastEditDate="2014-03-01T13:22:38.130" LastActivityDate="2014-03-01T13:22:38.130" Title="What's the best way to put in a database sensors data's" Tags="|web-service|" AnswerCount="1" CommentCount="1" ClosedDate="2014-02-12T15:40:23.073" ContentLicense="CC BY-SA 3.0" />
  <row Id="59" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T05:34:04.400" Score="18" Body="&lt;p&gt;One rather good IDE extension is the Arduino Mode for Emacs. It allows using a highly versatile and extensible IDE such as Emacs for writing, compiling and uploading code to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation and instructions can be found &lt;a href=&quot;http://www.emacswiki.org/emacs/ArduinoSupport&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-02-12T05:34:04.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="60" PostTypeId="1" CreationDate="2014-02-12T05:56:49.120" Score="18" ViewCount="1563" Body="&lt;p&gt;What is the best practice to make my Arduino circuit more robust against prototyping mistakes (like shorting pins)? I don't want the controller to release its blue magic smoke while experimenting with it, what precautions can I make while designing a circuit?&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="220" LastEditDate="2014-02-23T15:22:16.377" LastActivityDate="2018-07-12T14:35:34.350" Title="How to prevent breaking my Arduino by mistake?" Tags="|safety|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="61" PostTypeId="1" AcceptedAnswerId="78" CreationDate="2014-02-12T06:15:47.017" Score="243" ViewCount="464697" Body="&lt;p&gt;I would like to start the development of some basic Arduino projects but I don't own an Arduino board yet. Is there a way I can write my code and emulate/test it using a desktop computer so after my board arrives I just have to upload and run my project on it?&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2021-12-23T06:34:02.183" Title="Can I program for Arduino without having a real board?" Tags="|emulation|testing|" AnswerCount="13" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="62" PostTypeId="2" ParentId="27" CreationDate="2014-02-12T06:22:09.293" Score="4" Body="&lt;p&gt;If you don't want to use extra hardware like an Real Time Clock (eg. DSDS1307), you can significantly improve timing accuracy by disabling all unused interrupts. By default Arduino sketches come with various interrupt routines enabled and often they are not used for actually your sketch. Quickest way to find out if you can do without it to try and disable them by issuing &lt;a href=&quot;http://arduino.cc/en/Reference/Interrupts&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;noInterrupts();&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-12T06:22:09.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="63" PostTypeId="2" ParentId="13" CreationDate="2014-02-12T06:24:58.243" Score="6" Body="&lt;p&gt;The short answer is no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you would need LOTS more ram then even the biggest ATmega has natively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;is&lt;/em&gt; theoretically possible to add external hardware, and program the ATmega to emulate a more powerful CPU, and run linux on that. However, on a plain arduino, it is not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be much more realistic to run linux on a Arduino Due, which is basically a AT91SAM3X8E CPU. However, you'd still need to add some additional SRAM and storage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are things like the Arduino Yun, but that is really a entirely separate linux module on the same PCB as a ATmega32U4, so I don't know if you can really count it as an arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Possibly relevant: &lt;a href=&quot;https://stackoverflow.com/questions/1522146/minimum-configuration-to-run-embedded-linux-on-an-arm-processor&quot;&gt;What does it take to run embedded linux?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-02-12T06:24:58.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="64" PostTypeId="2" ParentId="56" CreationDate="2014-02-12T06:29:21.267" Score="4" Body="&lt;p&gt;Have you looked at the AVR simulator that's part of &lt;a href=&quot;http://www.atmel.com/microsite/atmel_studio6/debugging_simulation.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt;? Considering Atmel designed the processor, the simulation may very well be running the HDL that was used to produce the MCU itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect if you're doing something involved enough to be using unit-testing, you should probably stop thinking of your device as an &quot;Arduino&quot;, but rather &quot;An ATmega MCU on a PCB&quot;. There are &lt;strong&gt;much&lt;/strong&gt; more information and tools available about ATmega CPUs in general then Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-02-12T10:05:16.950" LastActivityDate="2014-02-12T10:05:16.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="65" PostTypeId="2" ParentId="42" CreationDate="2014-02-12T06:34:29.143" Score="8" Body="&lt;p&gt;The datasheets for the AVR microcontrollers are reasonably good to read. Just Google for the exact controller on your Arduino (eg. ATmege328) and find the &quot;Complete&quot; datasheet on the &lt;em&gt;atmel.com&lt;/em&gt; website. Don't download the &quot;Summary&quot;, it doesn't include a lot of information. Download the datasheet from atmel.com, that is the only location with the most recent documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three registers used in basic IO (check the chapter called &quot;I/O-Ports&quot;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where &lt;em&gt;n&lt;/em&gt; is a port identifier, a letter ranging from A, B, C, ... depending on the number of IO pins your controller has. Each bit in each register represents a single GPIO pin (yes, you need some basic knowledge on binary to fully understand this).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;DDR&lt;/strong&gt;&lt;em&gt;n&lt;/em&gt;, Data Direction Register: This basically configures a pin for either input (0) or output (1). &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;PORT&lt;/strong&gt;&lt;em&gt;n&lt;/em&gt;, Port n Data Register: When a pin is set as output, the related bit toggles the output pin high (1) or low (0). When configured as input, this enables a weak pull up resistor on the output pin.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;PIN&lt;/strong&gt;&lt;em&gt;n&lt;/em&gt;,  Port n Input Register: Use this register to read the current level on a pin that is configured as input.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-12T06:34:29.143" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="66" PostTypeId="2" ParentId="52" CreationDate="2014-02-12T06:38:39.020" Score="8" Body="&lt;p&gt;Unfortunately, there isn't much way to really determine &quot;wear&quot; in the context of solid-state electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the things that are most likely to fail are the electrolytic capacitors and the connectors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First, if you're using an ATmega CPU for something that could possibly injure someone &lt;strong&gt;CONTACT ATMEL AND TALK ABOUT SAFETY PRECAUTIONS&lt;/strong&gt;. The ATmega CPU used in most of the arduino models is &lt;em&gt;not&lt;/em&gt; rated for use in such situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In EVERY datasheet:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now, realistically, this is probably &lt;em&gt;mostly&lt;/em&gt; lawyer repellent, but you should still take appropriate precautions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, while there isn't anything on a common arduino board that really wears out except the connectors, &lt;em&gt;why are you trying to save $30 at a potential huge cost?&lt;/em&gt; Just buy a new board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also strongly reccomend you chose a board with a SMT ATmega328P, since that removes the IC socket contacts from the list of concerns. If possible, also remove the pin-headers, and solder wires to the board directly. Try to minimize connectors, since they are frequent points of failure.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-02-12T06:38:39.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="67" PostTypeId="2" ParentId="37" CreationDate="2014-02-12T06:43:38.013" Score="11" Body="&lt;p&gt;Find the &lt;code&gt;io__.h&lt;/code&gt; file for your microcontroller, on Linux it is located in &lt;code&gt;/usr/lib/avr/include/avr&lt;/code&gt;, on Windows it will be in a somewhat similar location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scroll down to the part that says &lt;code&gt;/* Constants */&lt;/code&gt;. There are couple interesting macros defined there, &lt;code&gt;FLASHEND&lt;/code&gt; being the one you should be interested in. You can use it for example as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if FLASHEND &amp;gt; 0x8000&#xA;/* Include some extra code when sufficient flash is available. */&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-12T06:43:38.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="68" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T06:44:16.880" Score="21" Body="&lt;p&gt;You can use &lt;a href=&quot;http://www.atmel.com/microsite/atmel_studio6/&quot;&gt;AVR Studio&lt;/a&gt; to write programs for Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a plugin that lets you link against and use the arduino libraries from &lt;a href=&quot;https://arduinotemplateexpress.codeplex.com/&quot;&gt;within Atmel Studio&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've used Microsoft Visual Studio, Atmel Studio is basically a reskin of Visual studio with different compiler backends that target the ATmega series of devices, so you'll feel right at home.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-02-12T06:44:16.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="69" PostTypeId="2" ParentId="12" CreationDate="2014-02-12T07:01:23.777" Score="8" Body="&lt;p&gt;To answer the aspect of your question regarding the &quot;firmware&quot; on the ATmega328p MCU used in most of the Arduino boards:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no firmware on the ATmega at all aside from the bootloader. The programs you write are running &lt;em&gt;directly&lt;/em&gt; on the hardware. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are certain &quot;fuse&quot; settings which are set with a &lt;a href=&quot;http://store.atmel.com/PartDetail.aspx?q=p:10500054&quot; rel=&quot;noreferrer&quot;&gt;ISP programmer&lt;/a&gt;. However, there are only 24 of them (three bytes), and they largely relate to low-level configuration, and are not what I think you're asking:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wEPF9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also the &lt;a href=&quot;http://code.google.com/p/optiboot/&quot; rel=&quot;noreferrer&quot;&gt;Bootloader&lt;/a&gt;, which is a small program that sits in a separate segment of the MCU's program memory and allows it to update itself at startup (which is how all arduinos are programmed). However, it only runs for a short period of time at startup, and is completely removed from memory after the MCU has jumped to the main program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, there are auxiliary MCUs (ATmega16U2/8U2) on most arduino boards that are used as USB-serial interfaces, that &lt;em&gt;can&lt;/em&gt; be updated to behave differently (e.g. emulate a keyboard/mouse), but again, this isn't actually a change to the core processor, so whether it counts as &quot;installing a different firmware&quot; depends on how you define the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, I'd strongly reccomend reading the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega328P datasheet&lt;/a&gt;. This is the documentation for the MCU that basically forms the &quot;Arduino&quot;. It should address what seems to be misconceptions. &lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-02-12T07:01:23.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="70" PostTypeId="2" ParentId="38" CreationDate="2014-02-12T07:08:22.687" Score="1" Body="&lt;p&gt;If RStudio has serial support. Yes, it can talk to a Uno. If it does not. No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is really a question about RStudio (and actually just pure &lt;a href=&quot;http://en.wikipedia.org/wiki/R_%28programming_language%29&quot; rel=&quot;nofollow&quot;&gt;R&lt;/a&gt;), not arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, RStudio is just an IDE. Therefore, no, &lt;em&gt;RStudio&lt;/em&gt; can &lt;em&gt;not&lt;/em&gt; communicate with an arduino, compile a program, or do much of all aside from edit source-code files. RStudio does not run your code at all. It uses an external interpreter to run your source files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;R&lt;/em&gt;, on the other hand probably &lt;em&gt;can&lt;/em&gt; talk to serial interfaces. The fact that you're using RStudio is entirely irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familliar with R, but a little googling leads me to think that R can talk to serial interfaces without &lt;em&gt;too&lt;/em&gt; much trouble, though I have not been able to find any information about doing so on windows. What platform are you using?&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-02-12T07:08:22.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="71" PostTypeId="1" AcceptedAnswerId="76" CreationDate="2014-02-12T07:22:41.363" Score="21" ViewCount="9435" Body="&lt;p&gt;In a project I am using a Seeeduino v3.0 as an Arduino clone. On the seeeduino website it says that &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is based on the Duemilanove schematic, 100% compatible to its existing program, shield and IDEs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In fact I never had any problems with shields or the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is now: Is the seeeduino and other clones really 100% compatible? The seeeduino board was considerable cheaper then an arduino.&lt;/p&gt;&#xA;" OwnerUserId="94" LastActivityDate="2016-01-07T23:27:27.593" Title="Compatibility between Arduino and Arduino clones" Tags="|clones|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="72" PostTypeId="2" ParentId="60" CreationDate="2014-02-12T07:33:14.817" Score="11" Body="&lt;p&gt;I don't know if there's &lt;em&gt;one&lt;/em&gt; best practice, but the following might be helpful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Limit the voltage on input pins to 5.5 V maximum.&lt;/li&gt;&#xA;&lt;li&gt;Do not short IO pins.&lt;/li&gt;&#xA;&lt;li&gt;Use pullup or pulldown resistors when conecting switches or pushbuttons.&lt;/li&gt;&#xA;&lt;li&gt;Respect the current limits (for each pin and in total). Use resistors.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino is just the brain, not the power station. If you have to drive higher loads, use simple transistors, Darlington arrays, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="89" LastEditorUserId="19409" LastEditDate="2018-07-12T14:24:31.090" LastActivityDate="2018-07-12T14:24:31.090" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="74" PostTypeId="1" AcceptedAnswerId="77" CreationDate="2014-02-12T07:36:18.303" Score="20" ViewCount="4265" Body="&lt;p&gt;I was looking at getting an enclosure to house my Arduino Uno R3, but I'm not sure if I should also attach a fan.  Does anyone have experience with this?  It doesn't look like much heat is being generated, but with no ventilation except some slits in the enclosure, there won't be much air circulation without a fan.  My concern with adding a fan was the fact that I'd need to power it.&lt;/p&gt;&#xA;" OwnerUserId="99" LastEditorUserId="220" LastEditDate="2014-02-25T01:44:59.277" LastActivityDate="2014-02-25T01:44:59.277" Title="Does Arduino Uno R3 require cooling in a closure?" Tags="|arduino-uno|enclosure|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="75" PostTypeId="2" ParentId="71" CreationDate="2014-02-12T07:41:33.683" Score="5" Body="&lt;p&gt;If you closely look at the Arduino circuit diagram, You'll notice that it is little more than power supply, a USB-serial interface and the microcontroller itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 'hard' part for compatibility is getting the board layout right (which connector goes where on the circuit board), and to load a compatible bootloader in the chip (which is free/open software, so why bother making your own?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used several el-cheapo Arduino clones and apart from apparent physical construction (one feels a bit flimsy), they all work just like the 'real thing'. I guess the major difference between original and clone is the quality of the board, the used components and quality of assembly.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-12T07:41:33.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="76" PostTypeId="2" ParentId="71" CreationDate="2014-02-12T07:48:19.477" Score="16" Body="&lt;p&gt;Over the years I have used original Arduino boards as well as a multitude of clones of varying provenance, from the excellent &lt;a href=&quot;http://www.simplelabs.co.in/content/induino-r3-low-cost-arduino-r3-usb-clone-board&quot;&gt;InduinoX&lt;/a&gt; that is listed on &lt;a href=&quot;http://playground.arduino.cc/Main/SimilarBoards#goArdComp&quot;&gt;the Arduino site&lt;/a&gt; as an official compatible board, to the very well-made Chinese &lt;a href=&quot;http://youtu.be/DXwezev713s&quot;&gt;Meduino Nano Enhancement&lt;/a&gt; (3.3 / 5 Volt switchable), to dirt-cheap clones from eBay that are sometimes better constructed than the official boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing unique or sophisticated about the Arduino board: It's basically just the microcontroller (atMEGA328, atMEGA1280, SAM3X8E or others) and its minimal support hardware. Not much that can go wrong with that little, really. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two common elements that ensure compatibility across these boards are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Arduino bootloader&lt;/li&gt;&#xA;&lt;li&gt;Support for the board within the official Arduino software distribution&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The bootloader can be replaced with a better or more up-to-date version if one is available for the microcontroller on your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The support files can either be found online, or minor edits to the nearest similar board's files can provide the requisite support for the Arduino environment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short: &lt;em&gt;Yes, clones typically work just as well as the original Arduino, and clones with enhanced features often work far better while retaining compatibility (e.g. InduinoX)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2014-02-12T07:48:19.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="77" PostTypeId="2" ParentId="74" CreationDate="2014-02-12T07:48:32.030" Score="16" Body="&lt;p&gt;The only times I had an AVR run hot was when I applied reverse power to it. You'll be fine without a fan for the Arduino board itself, as long as you don't run power hungry peripherals from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the only thing you really need to check (apart from absolute maximum ratings: 40mA max per IO pin and 200mA max for the whole microcontroller) is the on board voltage regulator (usually three pin device with a heat sink soldered down to the PCB) if you power it from a voltage &gt; 7V or so.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-12T07:48:32.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="78" PostTypeId="2" ParentId="61" CreationDate="2014-02-12T08:04:28.930" Score="140" Body="&lt;p&gt;There are a whole slew of Arduino simulators out there, many free, and some paid products as well.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;http://arduinodev.com/codeblocks/&quot; rel=&quot;noreferrer&quot;&gt;CodeBlocks&lt;/a&gt; Arduino development environment includes a free Arduino simulator, still under development but functional.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sites.google.com/site/adcajo&quot; rel=&quot;noreferrer&quot;&gt;Simuino&lt;/a&gt; simulates the Arduino Uno and Mega pins - not a pretty-looking realistic simulator, but it works.&lt;/li&gt;&#xA;&lt;li&gt;The Python based &lt;a href=&quot;http://sourceforge.net/projects/arduinosim/&quot; rel=&quot;noreferrer&quot;&gt;Arduino Simulator&lt;/a&gt; is another option, that plays well with the official IDE&lt;/li&gt;&#xA;&lt;li&gt;Virtronics &lt;a href=&quot;http://www.virtronics.com.au/Simulator-for-Arduino.html&quot; rel=&quot;noreferrer&quot;&gt;Simulator for Arduino&lt;/a&gt; looks promising, but I don't see why I would pay $14.99 for it, when I could buy one or more actual Arduino clones for that price&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Many other Arduino simulators are out there if you search, and new ones are being announced, even crowdfunded, all the time.&lt;/p&gt;&#xA;" OwnerUserId="70" LastEditorUserId="69580" LastEditDate="2021-02-02T15:59:01.883" LastActivityDate="2021-02-02T15:59:01.883" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="79" PostTypeId="2" ParentId="6" CreationDate="2014-02-12T08:21:43.107" Score="26" Body="&lt;p&gt;Realistically, the biggest power waster on an Arduino board is the linear voltage regulator on it. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;As long as the microcontroller on the board, the LEDs, or any other peripherals, draw current, the linear regulator wastes power equal to &lt;code&gt;difference between supply and board voltage&lt;/code&gt; x &lt;code&gt;current drawn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, a first fix would be to disconnect the power indicator LED on the board, and not use any of the other LEDs as far as possible.&#xA;Second, supply the board with as low a voltage as possible that is just sufficient to power the on-board regulator.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the original designs, the voltage regulators used do not boast low quiescent current. This means even with nothing drawing power within the board, the regulator itself wastes a fair bit of power all the time it is on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy fix is to replace the on-board regulator with an LDO (low drop-out linear regulator) rated for extremely low quiescent current. Parametric searches on various vendor sites will yield likely substitutes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even with the above steps, the Arduino board does not provide a mechanism to set the LDO into low-power mode, if the LDO chosen supports this. Power efficient designs typically use a &quot;sleep mode&quot; pin on voltage regulators to save a fair bit of energy - not an option here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Even with all possible power saving modes and tricks applied at the microcontroller level, the Arduino simply is not designed to be an ultra-low-power device out of the box. Having experimented with several non-trivial applications, I have found that the best that is realistically achievable is some 10% to 30% power saving depending on application, since the voltage regulator and the LEDs are going to consume the rest anyway.&lt;/p&gt;&#xA;" OwnerUserId="70" LastEditorUserId="70" LastEditDate="2014-02-17T08:00:10.263" LastActivityDate="2014-02-17T08:00:10.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="80" PostTypeId="2" ParentId="60" CreationDate="2014-02-12T09:14:23.233" Score="14" Body="&lt;p&gt;Not best practices, but an alternative approach: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the &lt;a href=&quot;http://ruggedcircuits.com/html/ruggeduino.html&quot;&gt;Ruggeduino&lt;/a&gt; instead of a standard Arduino. At a price ($39.95) comparable with the equivalent Arduino, the Ruggeduino offers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Resettable fuse on each GPIO pin, i.e. all GPIO pins are protected from short-circuit to ground or other pins&lt;/li&gt;&#xA;&lt;li&gt;All GPIO pins withstand 24 Volts&lt;/li&gt;&#xA;&lt;li&gt;Reverse voltage protection (-30 V) on V&lt;sub&gt;in&lt;/sub&gt;&lt;/li&gt;&#xA;&lt;li&gt;Microcontroller overcurrent protection&lt;/li&gt;&#xA;&lt;li&gt;3.3V and 5V outputs on the board are over-current and short-circuit protected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Besides the above points specific to the question, the boards are designed to survive harsh environments and various mistakes. Also, the clock is more precise than on the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2014-02-12T09:14:23.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="81" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T09:28:35.477" Score="26" Body="&lt;p&gt;Expanding on &lt;a href=&quot;https://arduino.stackexchange.com/a/43/220&quot;&gt;Fake Name's answer&lt;/a&gt;, there is also &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Micro's Arduino plugin&lt;/a&gt; for Atmel Studio (built off Visual Studio). It shares the tools, sources and libraries with the Arduino IDE but provides all the code completion and other features of Visual Studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Visual Micro plugin also works in all versions of Visual Studio. Provides &#xA;Arduino usb debugging and an Arduino IDE compatible Board Manager.&lt;/p&gt;&#xA;" OwnerUserId="102" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2017-04-04T16:16:06.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="83" PostTypeId="2" ParentId="61" CreationDate="2014-02-12T09:54:54.233" Score="13" Body="&lt;p&gt;Yes, you can, try using &lt;a href=&quot;https://www.labcenter.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Proteus ISIS&lt;/a&gt; for simulating your code...   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For full emulation of Arduino, there is a shareware program called &lt;a href=&quot;http://www.virtualbreadboard.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VBB (Virtual BreadBoard)&lt;/a&gt;, I tried it too and it was nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; You can check my detailed tutorial &lt;a href=&quot;https://arduino.stackexchange.com/questions/56/what-is-the-best-way-to-unit-test-my-code-without-controller/175#175&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; on how to simulate on Proteus ISIS&lt;/p&gt;&#xA;" OwnerUserId="103" LastEditorUserId="103" LastEditDate="2019-02-12T16:14:50.507" LastActivityDate="2019-02-12T16:14:50.507" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="84" PostTypeId="2" ParentId="57" CreationDate="2014-02-12T09:55:52.400" Score="4" Body="&lt;p&gt;It depends on your skills and what you have in your Arduino &quot;box&quot;.&#xA;Let's assume you have an ethernet or WiFi shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would go with a PHP script (I'm a PHP dev, but any language will fit) that accepts POST requests sent by the board and store them in a SQLite db.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why SQLite instead of MySQL?&lt;/strong&gt; Well, it's just a matter of data portability. You copy the SQLite file or send it via email and you're done: there are plenty of clients out there to read your db, in *nix based machines is frequently integrated in the OS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MySQL requires a sort of &quot;infrastructure&quot; to be written/read.&lt;/p&gt;&#xA;" OwnerUserId="82" LastActivityDate="2014-02-12T09:55:52.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="85" PostTypeId="1" AcceptedAnswerId="86" CreationDate="2014-02-12T10:22:23.107" Score="22" ViewCount="9541" Body="&lt;p&gt;I wanted to make a fairly simple circuit which would flash a series of LEDs in sequence, using my Arduino Uno (more specifically, a SainSmart clone). I wrote my sketch and it compiled fine. After that, I connected 8 LEDS+resistors to pins 0 through 7, and then connected the Uno to my computer via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've uploaded sketches successfully in the past, so I'm sure my settings and drivers etc. are correct. However, when I tried to upload my sketch this time, it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried removing everything I'd connected to the Arduino's pins, and suddenly the upload worked again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen? Does it mean I have to disconnect everything from the board every time I upload a sketch?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:45.650" LastActivityDate="2015-11-03T13:28:11.027" Title="Why can't I upload a sketch while other components/devices are connected to my Uno?" Tags="|serial|pins|uploading|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="86" PostTypeId="2" ParentId="85" CreationDate="2014-02-12T10:22:23.107" Score="22" Body="&lt;p&gt;The problem is specifically pins 0 and 1. Although they can be used as regular digital IO pins, they also serve as the RX and TX pins for the Uno's serial port. The USB connection (for uploading sketches etc.) is routed to the same pins internally. Unfortunately that means anything connected on pins 0 and 1 can interfere with the serial connection, preventing communication via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, it's not necessary to disconnect &lt;em&gt;everything&lt;/em&gt; when uploading a sketch. It should only be necessary to disconnect anything from pins 0 and 1. Rather than going through that hassle every time a sketch is uploaded though, it may be best just to avoid using those pins unless necessary (e.g. you run out of other pins, or your project needs a serial connection to another device).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-12T10:22:23.107" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="87" PostTypeId="1" CreationDate="2014-02-12T11:39:41.963" Score="4" ViewCount="18261" Body="&lt;p&gt;I need to simulate my Arduino project with other circuit components before implementing the project. Is there a decent simulator that runs on Mac platform?&lt;/p&gt;&#xA;" OwnerUserId="107" LastActivityDate="2014-02-12T13:12:07.613" Title="Is there an Arduino simulator that runs on Mac OS X?" Tags="|mac-os|simulator|" AnswerCount="1" CommentCount="0" ClosedDate="2014-02-13T17:01:02.770" ContentLicense="CC BY-SA 3.0" />
  <row Id="88" PostTypeId="1" AcceptedAnswerId="89" CreationDate="2014-02-12T11:40:08.950" Score="22" ViewCount="35742" Body="&lt;p&gt;I've been experimenting with an 8x8 LED matrix controlled by an Arduino Uno. As I think is typical, the matrix uses a common anode for each row, and a common cathode for each column. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I've got all the matrix pins connected directly to IO pins on the Uno, and I haven't had any problems lighting the LEDs one-by-one. Going through the whole matrix like this makes updates a little slow though, meaning the LEDs aren't as bright as I'd like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, I can't safely light up an entire row at once, because an individual pin on the Uno isn't capable of sourcing enough current to drive 8 separate LEDs at the same time (requiring at least 10mA each to be bright enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It occurred to me that the reverse might be safer. If I light up an entire column at a time, then each pin only has to source enough current for one LED, which should be no problem. However, it relies on one pin potentially sinking the current from all 8, totalling at least 80mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible, or am I going to fry my board?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-25T06:35:14.613" LastActivityDate="2014-02-25T06:35:14.613" Title="Is there a limit on how much current a pin can sink?" Tags="|pins|arduino-uno|current|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="89" PostTypeId="2" ParentId="88" CreationDate="2014-02-12T12:00:32.087" Score="17" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;am I going to fry my board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Pretty likely outcome. Here's why:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno uses the atMEGA328 microcontroller, which has an absolute maximum rating of 40 mA source or sink per GPIO. Also, the total current through the supply or ground rails (i.e. the total of all current OP wants the GPIO pins to sink, or source) is rated to a maximum of &lt;s&gt;150&lt;/s&gt; 200 mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Realistically, the current graphs in the atMEGA328 datasheet do not even go all the way to 40 mA, hence it is safest to restrict the current to perhaps 20 mA total per GPIO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, whether a GPIO is used as source or sink, the limits remain pretty low, and in practice, should be kept much lower than the absolute maximum ratings. Even below absolute maximum, running a microcontroller to too high a temperature reduces its life expectancy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use either BJTs, MOSFETs, or some driver IC such as the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/uln2003a.pdf&quot;&gt;ULN2003&lt;/a&gt; to actually drive the current through the LEDs.&lt;/p&gt;&#xA;" OwnerUserId="70" LastEditorUserId="70" LastEditDate="2014-02-12T13:39:41.790" LastActivityDate="2014-02-12T13:39:41.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="90" PostTypeId="2" ParentId="71" CreationDate="2014-02-12T12:36:32.577" Score="3" Body="&lt;p&gt;Check twice ! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most clones are exact clones with copies of the flaws that original Arduino board had. Like for example Arduino Nano not having proper RESET and TEST pin connection of FT232RL USB-serial bridge. This flaw may lead to FT232RL not responding to PC and was eventually fixed in later revisions of Arduino Nano board. Some clones were not updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another &quot;not exactly Arduino clones&quot; example are numerous boards with CP2102 USB to serial bridge instead of FT232RL. This may pass unnoticed, but may give frustration when one clone board connects and works with your PC, but another generates system complains on missing drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So again - be prepared !&lt;/p&gt;&#xA;" OwnerUserId="32" LastActivityDate="2014-02-12T12:36:32.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="91" PostTypeId="1" AcceptedAnswerId="92" CreationDate="2014-02-12T12:43:33.707" Score="17" ViewCount="2767" Body="&lt;p&gt;I currently have a Mega2560 with the LCD4884 Shield. The Shield is good for putting out text and simple pixel images. But I am wondering if there is something that has a full range of colours that would work with the Arduino? The screen size would only have to be a few inches in size.&lt;/p&gt;&#xA;" OwnerUserId="114" LastActivityDate="2014-02-23T00:37:25.183" Title="Is there a color LCD display for an arduino?" Tags="|lcd|shields|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="92" PostTypeId="2" ParentId="91" CreationDate="2014-02-12T13:06:14.843" Score="10" Body="&lt;p&gt;There are actually several shields that have color screens on them. Many of the shields are just regular mini TFT displays, however there are also touch screen ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/products/802?gclid=CK3Mk63SxrwCFedlOgodA3IABQ&quot;&gt;Here is one&lt;/a&gt; from Adafruit that includes a MicroSD holder and a Joystick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.radioshack.com/product/index.jsp?productId=12688460&amp;amp;CAWELAID=120125420000001702&amp;amp;catargetid=120125420000031766&amp;amp;cadevice=c&amp;amp;cagpspn=pla&amp;amp;gclid=CMbdyJ_TxrwCFW1nOgodHF4AGg&quot;&gt;Here is one&lt;/a&gt; from Radio Shack that features a 2.8 inch screen with touch capabilities &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as screen size, many of the screens are only about an 1 inch across, however the biggest I have ever been able to find are 2.8 in.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-12T13:06:14.843" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="93" PostTypeId="2" ParentId="87" CreationDate="2014-02-12T13:12:07.613" Score="3" Body="&lt;p&gt;There is a decent program called &lt;a href=&quot;http://virtronics.com.au/Simulator-for-Arduino.html&quot; rel=&quot;nofollow&quot;&gt;Simulator for Arduino&lt;/a&gt; made by Virtronics. Although it is made to run only in windows, you could run it in a &lt;a href=&quot;http://wiki.winehq.org/MacOSX#head-43b0651931c700b0f796ab7d5280a08eb58d51e0&quot; rel=&quot;nofollow&quot;&gt;WINE environment&lt;/a&gt;. WINE allows windows programs to be ran in Mac and Linux OS.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-12T13:12:07.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="95" PostTypeId="2" ParentId="91" CreationDate="2014-02-12T13:27:35.770" Score="5" Body="&lt;p&gt;There's also a &lt;a href=&quot;http://www.adafruit.com/products/1480&quot;&gt;2.2&quot; Adafruit TFT&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nice things about the Adafruit displays are:&#xA;i) library support for both the &lt;a href=&quot;https://github.com/adafruit/Adafruit_ILI9340&quot;&gt;display&lt;/a&gt; and the &lt;a href=&quot;https://github.com/adafruit/Adafruit-GFX-Library&quot;&gt;graphics core library&lt;/a&gt;. So it's easy to get it up and running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The built in frame buffer reduces resource requirements on Arduino.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-02-12T13:27:35.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="96" PostTypeId="1" AcceptedAnswerId="164" CreationDate="2014-02-12T13:41:46.053" Score="15" ViewCount="7599" Body="&lt;p&gt;We have an LED strip connected to output 6 and is powered by the Uno board itself.  Shouldn't be drawing too much current, only have 10 elements on the LED strip.  While this LED strip is connected to the Uno, I noticed that the regulator is getting very hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing we haven't done yet is to power the LED strips from an external source, which will be necessary since there will be many strips.  At the moment, the students are simply trying to debug their program with the small strip.&lt;/p&gt;&#xA;" OwnerUserId="118" LastActivityDate="2014-02-13T14:06:47.320" Title="Why is the regulator very hot?" Tags="|power|heat|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="97" PostTypeId="2" ParentId="61" CreationDate="2014-02-12T13:47:34.540" Score="93" Body="&lt;p&gt;I like to use &lt;a href=&quot;https://www.tinkercad.com/learn/circuits&quot; rel=&quot;noreferrer&quot;&gt;circuits.io aka TinkerCAD&lt;/a&gt; for this.&lt;/p&gt;&#xA;&lt;p&gt;It's cloud based and has some nice features including PCB design and collaboration.&lt;/p&gt;&#xA;&lt;p&gt;IMO the Arduino simulation and capability is impressive and intuitive.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="71881" LastEditDate="2021-01-23T12:14:39.557" LastActivityDate="2021-01-23T12:14:39.557" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="98" PostTypeId="2" ParentId="52" CreationDate="2014-02-12T13:49:35.820" Score="4" Body="&lt;p&gt;One of the sections of the Arduino that is likely to become unreliable over time is its memory. There are &lt;a href=&quot;http://arduino.cc/en/Tutorial/Memory&quot; rel=&quot;nofollow noreferrer&quot;&gt;three pools of memory&lt;/a&gt; in the microcontroller used on avr-based Arduino boards:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flash memory (program space), is where the Arduino sketch is stored.&lt;/li&gt;&#xA;&lt;li&gt;SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs.&lt;/li&gt;&#xA;&lt;li&gt;EEPROM is memory space that programmers can use to store long-term information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The memory is one part of the board that can be checked and verified, and thus evaluated for reliability/health. A very basic way to check memory would be to write a certain 8-bit pattern (byte character) over every address in the memory and then read the value present from every address. If the value that was written matches the value that is read, then that specific 8 bit block in memory is functioning correctly at the present moment.&lt;/p&gt;&#xA;&lt;p&gt;Wear in ROM memory usually occurs in a blockwise pattern i.e. n*8-bit blocks become degraded over time. So, for a 2K byte ROM chip, the health of the chip can be estimated by writing and reading from every byte on the chip, and calculating the percentage of correctly functioning blocks. If the percentage of failed blocks is significant (15%-20%), that means that the memory is likely to fail soon.&lt;/p&gt;&#xA;&lt;p&gt;The test code can be written using separate methods for each of the memory sections.&lt;/p&gt;&#xA;&lt;h3&gt;SRAM&lt;/h3&gt;&#xA;&lt;p&gt;Any variables declared statically or dynamically are allocated on the SRAM. So, we could declare a large character array (~2000) and fill every element with 255 (all bits 1). Then, we could attempt to read each of those elements and see if the value being read is indeed 255.&lt;/p&gt;&#xA;&lt;h3&gt;EEPROM&lt;/h3&gt;&#xA;&lt;p&gt;The EEPROM can be manipulated using the &lt;a href=&quot;http://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow noreferrer&quot;&gt;EEPROM library&lt;/a&gt;. The library provides functions to read and write from specific locations in the EEPROM. So, all memory addresses can be tested by simply looping over the entire memory&#xA;space. &lt;em&gt;This operation will require 500 writes and reads.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Depending on the board usage, EEPROM is most likely to fail first but is not critical to board operation.&lt;/p&gt;&#xA;&lt;h3&gt;Flash&lt;/h3&gt;&#xA;&lt;p&gt;Data can be stored on the flash memory using the &lt;a href=&quot;http://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;PROGMEM&lt;/code&gt;&lt;/a&gt; directive. Similar to SRAM, a large array can be declared and initialized here. Then, values can be read and checked.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-13T14:31:27.243" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="99" PostTypeId="2" ParentId="96" CreationDate="2014-02-12T14:08:24.913" Score="7" Body="&lt;p&gt;A regulator normally get hot when is driven a current near to the maximum that could be driven, and its a normal thing the regulator keep warm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A normal regulator like &lt;a href=&quot;http://www.fairchildsemi.com/ds/LM/LM7805.pdf&quot;&gt;LM7805&lt;/a&gt; could work until 125 C°. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try to drive more current that it can probably it will burn, so, maybe its time to you change your power supply to an external one to keep safe your Arduino board.&lt;/p&gt;&#xA;" OwnerUserId="3" LastActivityDate="2014-02-12T14:08:24.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="100" PostTypeId="2" ParentId="96" CreationDate="2014-02-12T14:16:50.190" Score="11" Body="&lt;p&gt;If you power the Arduino with an external power supply the on board regulator has to &lt;em&gt;dissipate&lt;/em&gt; the voltage difference between input and 5VDC at the total current you draw from the board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Klaus Warzecha wrote in an &lt;a href=&quot;https://arduino.stackexchange.com/questions/60/how-to-prevent-breaking-my-arduino-by-mistake/72#72&quot;&gt;answer&lt;/a&gt; to &lt;a href=&quot;https://arduino.stackexchange.com/questions/60/how-to-prevent-breaking-my-arduino-by-mistake&quot;&gt;another question&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino is just the brain, not the power station.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the output voltage of your power supply is 12V, then the regulator will be dissipating 12-5V = 7 V at the total current drawn. Total dissipated power for eg. 150mA (just an estimate) would be P = V × I = 7 × 0.150 = 1W&#xA;The regulator will be pretty hot from dissipating 1W. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind you that the current is not limited to 150mA, enough LEDs can easily increase current and power. If the regulator is stressed (often) enough, sooner or later it will fail. It is better practice to power any load directly from the external power supply, taking the higher voltage into account.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-02-12T14:28:41.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="101" PostTypeId="2" ParentId="40" CreationDate="2014-02-12T14:57:09.747" Score="23" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Vim_%28text_editor%29&quot;&gt;vim&lt;/a&gt; can be used for Arduino development, but it will take some configuration (as is the way of vim). You'll need the &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2654&quot;&gt;syntax file&lt;/a&gt; and &lt;a href=&quot;https://github.com/tclem/vim-arduino&quot;&gt;this plugin&lt;/a&gt; that enables you to compile and deploy from vim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://twitter.com/grantlucas&quot;&gt;Grant Lucas&lt;/a&gt; produced a great write-up on getting your environment situation squared away:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;&lt;a href=&quot;http://grantlucas.com/posts/2012/09/using-vim-arduino-development&quot;&gt;Using Vim for Arduino development&lt;/a&gt;&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;Here's a quick post on setting up Vim for Arduino development instead&#xA;  of using the Arduino IDE. If you're a heavy Vim user, it can be a bit&#xA;  of a shock to go into a different editor. Thankfully the setup is&#xA;  pretty easy to get this all working with Vim. This post is assuming&#xA;  you are comfortable with how Vim is setup and ideally already have an&#xA;  environment that works for you.&lt;/p&gt;&#xA;  &#xA;  &lt;h3&gt;Install the Arduino IDE&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;Wait. What?!?&lt;/em&gt; I hear you say. I know, I know. We're not actually using the Arduino IDE but we need it for some configuration and the&#xA;  files it installs. The Vim plugin we'll be using ties into what the&#xA;  IDE installs and configures so it's needed. You can download the IDE&#xA;  from the &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot;&gt;Arduino site&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;h3&gt;Install vim-arduino plugin&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;To get the main goodness of compiling, monitoring and deploying to an&#xA;  Arduino, grab the latest version of &lt;a href=&quot;https://github.com/tclem/vim-arduino&quot;&gt;vim-arduino&lt;/a&gt;. Install it in&#xA;  your .vim folder using what ever method you use to manage your Vim&#xA;  plugins. &lt;strong&gt;Hint:&lt;/strong&gt; I'd recommend &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot;&gt;Pathogen&lt;/a&gt; as it makes installing&#xA;  as simple as dropping the plugin folder into a bundle folder.&lt;/p&gt;&#xA;  &#xA;  &lt;h3&gt;Vim syntax file&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;Next up is to get the syntax file so we can have nice colour coding&#xA;  for .pde and .ino files. Download the latest &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=2654&quot;&gt;arduino.vim&lt;/a&gt; and&#xA;  install it in your Vim syntax folder. To get the syntax to apply to&#xA;  the correct file types add the following to your vimrc file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;au BufRead,BufNewFile *.pde set filetype=arduino&#xA;au BufRead,BufNewFile *.ino set filetype=arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;h3&gt;Configuring the Arduino IDE&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;Before trying to compile and deploy with Vim, get it all working with&#xA;  the Arduino IDE first as the Vim plugin just calls from the settings&#xA;  saved by the IDE. If it's working in the IDE, it should work in Vim.&#xA;  Make sure you select the right tty.usbmodem* serial port from Tools &gt;&#xA;  Serial Port in the IDE. &lt;strong&gt;Note:&lt;/strong&gt; This will only show when the Arduino&#xA;  is plugged in.&lt;/p&gt;&#xA;  &#xA;  &lt;h3&gt;Working from Vim&lt;/h3&gt;&#xA;  &#xA;  &lt;p&gt;Once you can communicate with your Arduino from the IDE you should be&#xA;  fully good to go with Vim. You shouldn't have to open the IDE unless&#xA;  you want some example code. Open up your sketch file in Vim and use&#xA;  &lt;code&gt;&amp;lt;Leader&amp;gt;ac&lt;/code&gt; to compile a sketch, &lt;code&gt;&amp;lt;Leader&amp;gt;ad&lt;/code&gt; to compile and then&#xA;  deploy to the connected Arduino and &lt;code&gt;&amp;lt;Leader&amp;gt;as&lt;/code&gt; to open a new window&#xA;  with &lt;code&gt;screen&lt;/code&gt; to monitor the serial output from the Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4" LastActivityDate="2014-02-12T14:57:09.747" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="104" PostTypeId="1" CreationDate="2014-02-12T15:31:08.343" Score="14" ViewCount="9744" Body="&lt;p&gt;Is there any easy way to upload a program/sketch from an iPad or Android tablet without adding extra an shield (Bluetooth or Wi-Fi)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, can it be done using shield? Which shield is preferred?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also what are the IDE options available?&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="4" LastEditDate="2014-02-12T17:00:54.183" LastActivityDate="2015-11-14T07:08:44.313" Title="Is it possible to upload a program from a tablet?" Tags="|uploading|ide|android|" AnswerCount="8" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="105" PostTypeId="1" AcceptedAnswerId="116" CreationDate="2014-02-12T15:31:17.143" Score="41" ViewCount="176982" Body="&lt;p&gt;I am not very skilled with the C Language and I was wondering if there is a way in which python could be used to program an Arduino. This would most likely require a different IDE in order to be able to debug the scripts them self. &lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="65" LastEditDate="2014-02-12T15:59:32.043" LastActivityDate="2020-12-25T19:56:18.700" Title="Programming an Arduino using Python, rather than C/C++" Tags="|programming|python|" AnswerCount="10" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="106" PostTypeId="2" ParentId="104" CreationDate="2014-02-12T15:46:09.823" Score="2" Body="&lt;p&gt;Unfortunately Apple doesn't allow apps that implement programming languages. This being said, it is unclear why they would not allow an app that has to do with the Arduino IDE due to the fact that the code doesn't actually run on the Ipad itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.libertypages.com/clarktech/?p=1690&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for more Info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as an Android IDE, I have heard that there are a few people working on different IDEs that sends the code to the Arduino over the internet, although they have not been released yet, and the details are still a bit unclear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=61305.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=61305.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="24" LastEditDate="2014-02-12T16:11:44.437" LastActivityDate="2014-02-12T16:11:44.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="107" PostTypeId="5" CreationDate="2014-02-12T15:47:38.990" Score="0" Body="&lt;p&gt;The Arduino Uno is the most common and one of the newest Arduino boards. It has 14 digital I/O pins and 6 analog input pins. There are three different versions of the Uno: R1, R2, and R3.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Microcontroller: ATmega328&lt;/li&gt;&#xA;&lt;li&gt;Operating Voltage: 5V&lt;/li&gt;&#xA;&lt;li&gt;Input Voltage (recommended): 7-12V&lt;/li&gt;&#xA;&lt;li&gt;Input Voltage (limits): 6-20V&lt;/li&gt;&#xA;&lt;li&gt;Digital I/O Pins: 14 (of which 6 provide PWM output)&lt;/li&gt;&#xA;&lt;li&gt;Analog Input Pins: 6&lt;/li&gt;&#xA;&lt;li&gt;DC Current per I/O Pin: 40 mA&lt;/li&gt;&#xA;&lt;li&gt;DC Current for 3.3V Pin: 50 mA&lt;/li&gt;&#xA;&lt;li&gt;Flash Memory: 32 KB (ATmega328) of which 0.5 KB used by bootloader&lt;/li&gt;&#xA;&lt;li&gt;SRAM: 2 KB (ATmega328)&lt;/li&gt;&#xA;&lt;li&gt;EEPROM: 1 KB (ATmega328)&lt;/li&gt;&#xA;&lt;li&gt;Clock Speed: 16 MHz&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Official Arduino Uno&lt;/a&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main limitation with the Uno is the Uno's lack of SRAM or flash memory. However, the Uno is the most commonly used Arduino board. It is $30, and is compatible with many shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider using more specific tags to your problem, such as &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; or &lt;a href=&quot;/questions/tagged/serial&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;serial&amp;#39;&quot; rel=&quot;tag&quot;&gt;serial&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="35" LastEditDate="2014-02-25T06:34:09.577" LastActivityDate="2014-02-25T06:34:09.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="108" PostTypeId="4" CreationDate="2014-02-12T15:47:38.990" Score="0" Body="The Arduino Uno is the most common and one of the newest Arduinos, based on the ATmega328 microcontroller. Use this tag when asking a question specific to an Uno, not just a general Arduino question. Also consider using more specific tags to your problem." OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-25T06:32:21.537" LastActivityDate="2014-02-25T06:32:21.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="109" PostTypeId="5" CreationDate="2014-02-12T15:58:37.333" Score="0" Body="&lt;p&gt;Ethernet can be used for communication between an Arduino and a computer. It is defined as &lt;em&gt;a system for connecting a number of computer systems to form a local area network, with protocols to control the passing of information and to avoid simultaneous transmission by two or more systems&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also an &lt;a href=&quot;https://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Ethernet board&lt;/a&gt;, for which you should use the tag &lt;a href=&quot;/questions/tagged/arduino-ethernet&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;arduino-ethernet&amp;#39;&quot; rel=&quot;tag&quot;&gt;arduino-ethernet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, there is an &lt;a href=&quot;https://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Ethernet Shield&lt;/a&gt;. Use this tag for the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoEthernetShield_R3_Front.jpg&quot; &gt; &lt;em&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arduino.cc/en/Main/ArduinoEthernetShield&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.047" LastActivityDate="2014-03-18T22:25:31.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="110" PostTypeId="4" CreationDate="2014-02-12T15:58:37.333" Score="0" Body="Ethernet can be used for cabled communication between an Arduino and a computer, server, or website. For question concerning the Arduino Ethernet board, use the tag &quot;arduino-ethernet&quot; instead." OwnerUserId="37" LastEditorUserId="26717" LastEditDate="2017-06-06T09:17:20.427" LastActivityDate="2017-06-06T09:17:20.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="111" PostTypeId="5" CreationDate="2014-02-12T16:02:26.177" Score="0" Body="&lt;p&gt;Uploading is the process of updating or changing the sketch on the Arduino board. It does not refer to uploading to a server or a website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/ArduinoUnoB.jpg/799px-ArduinoUnoB.jpg&quot; &gt;&#xA;&lt;em&gt;&lt;a href=&quot;http://commons.wikimedia.org/wiki/File:ArduinoUnoB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://commons.wikimedia.org/wiki/File:ArduinoUnoB.jpg&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;Upload process:&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;Sketches are uploaded by avrdude.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The upload process is also controlled by variables in the boards and main preferences files. Those in the boards file include:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&amp;lt;BOARD&gt;.upload.protocol: the protocol that avrdude should use to talk to the board (typically &quot;stk500&quot;).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&amp;lt;BOARD&gt;.upload.speed: the speed (baud rate) avrdude should use when uploading sketches (typically &quot;19200&quot;).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&amp;lt;BOARD&gt;.upload.maximum_size: the maximum size for a sketch on the&#xA;  board (dependent on the chip and the size of the bootloader). &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;And in the main preferences file:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;upload.verbose: whether or not to dump debugging messages while upload a sketch to a board (defaults to &quot;false&quot;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Hacking/BuildProcess&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the code is transferred to the board, then [if the board has auto-reset], the board will reset and the sketch will be run.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.070" LastActivityDate="2014-05-03T12:33:31.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="112" PostTypeId="4" CreationDate="2014-02-12T16:02:26.177" Score="0" Body="Uploading is the process of updating or changing the sketch on the Arduino board. It does not refer to uploading to a server or a website." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:05:52.753" LastActivityDate="2014-02-23T21:05:52.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="113" PostTypeId="1" AcceptedAnswerId="162" CreationDate="2014-02-12T16:04:13.967" Score="15" ViewCount="5439" Body="&lt;p&gt;The function &lt;code&gt;millis&lt;/code&gt; would be running in the span of 100+ microseconds or less. Is there a reliable way to go about measuring the time taken by a single millis call?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach that comes to mind is using &lt;code&gt;micros&lt;/code&gt;, however, a call to &lt;code&gt;micros&lt;/code&gt; will include the time taken by the function call of &lt;code&gt;micros&lt;/code&gt; itself as well, so depending on how long micros takes, the measurement for &lt;code&gt;millis&lt;/code&gt; may be off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to find this as an application I am working on requires accurate time measurements for every step taken in the code, including &lt;code&gt;millis&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2016-04-11T22:08:37.307" Title="Is it possible to find the time taken by millis?" Tags="|time|millis|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="114" PostTypeId="2" ParentId="105" CreationDate="2014-02-12T16:18:01.803" Score="17" Body="&lt;p&gt;Yes, it is (somewhat) possible to program the Arduino using Python. One such project on Github is the &lt;a href=&quot;http://github.com/vascop/Python-Arduino-Proto-API-v2&quot;&gt;Python Arduino Prototyping API v2&lt;/a&gt;. It provides very basic functionality such as digital I/O and analog I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used for very simple projects.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;*This project is a bit of a hack at &quot;programming&quot; the board using the serial connection. It passes the commands over the serial connection to a sketch running on the board which then &quot;executes&quot; the Python command.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-02-12T16:18:01.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="115" PostTypeId="2" ParentId="38" CreationDate="2014-02-12T16:19:51.607" Score="0" Body="&lt;p&gt;I can't seem to figure out directly how to read from a serial port using R; While there does seem to have been at least &lt;a href=&quot;https://biostatmatt.com/archives/112&quot; rel=&quot;nofollow&quot;&gt;one attempt&lt;/a&gt; to provide this, it's not clear that it ever graduated to something supported or easily installable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, R does have &lt;a href=&quot;http://stat.ethz.ch/R-manual/R-patched/library/utils/html/read.socket.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;read.socket&lt;/code&gt; and &lt;code&gt;write.socket&lt;/code&gt;&lt;/a&gt;, which I believe would make it easy enough to use through &lt;a href=&quot;http://ser2net.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ser2net&lt;/code&gt;&lt;/a&gt;, which exposes a serial-port as a socket. &lt;/p&gt;&#xA;" OwnerUserId="13" LastActivityDate="2014-02-12T16:19:51.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="116" PostTypeId="2" ParentId="105" CreationDate="2014-02-12T16:28:12.037" Score="27" Body="&lt;p&gt;It's going to be extremely difficult to get any kind of Python script running directly on the Arduino. The reason is that it's an interpreted language, so you would need the interpreter on-board in addition to the plain text script. There's probably not going to be enough memory for all of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet would probably be finding a way to compile a Python script to native machine code (which is how C/C++ works). I believe there are projects around to do something like that for other platforms, but (as far as I know) none which does it successfully for Arduino yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find some more useful information on this question at Stack Overflow: &lt;a href=&quot;https://stackoverflow.com/questions/8114916/is-there-a-way-to-compile-python-code-onto-an-arduino-uno&quot;&gt;Is there a way to &quot;compile&quot; Python code onto an Arduino (Uno)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-02-12T16:28:12.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="117" PostTypeId="1" AcceptedAnswerId="119" CreationDate="2014-02-12T16:42:31.307" Score="65" ViewCount="81898" Body="&lt;p&gt;Is it possible to have more than 14 output pins on the Arduino, I am working on a project in which I need to light up several LEDs individually. I only have an Arduino Uno, and I don't want to get a Mega. &lt;/p&gt;&#xA;" OwnerUserId="24" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:41.647" LastActivityDate="2018-02-16T14:51:36.183" Title="Is there a way to have more than 14 Output pins on arduino?" Tags="|pins|arduino-uno|" AnswerCount="13" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="118" PostTypeId="2" ParentId="117" CreationDate="2014-02-12T16:42:31.307" Score="32" Body="&lt;p&gt;There are two ways you can get more pins out of an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first way is by using the Analog pins as digital output pins, which is really easy to do. All you need to do is refer to A0-A5 as pins 14,15,16,17,18,19. For example to write high to pin A0 just use digitalWrite(14, HIGH).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other way to get more pins out of the Arduino is by using a Shift Register. To do this I recommend using the &lt;a href=&quot;https://nootropicdesign.com/ez-expander/&quot;&gt;EZ-Expander Shield&lt;/a&gt;, which allows you to use digitalWrite([20-35], HIGH) when you import the EZ-Expander Library. This shield however only allows the pins to be used as outputs only and uses pins 8,12 and 13 to control the shift registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The great thing is, is that you can use both of the two methods above together, without any problems.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-12T16:42:31.307" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="119" PostTypeId="2" ParentId="117" CreationDate="2014-02-12T16:54:59.757" Score="56" Body="&lt;p&gt;A common way to expand the set of available output pins on the Arduino is to use shift registers like the 74HC595 IC (&lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf&quot; rel=&quot;noreferrer&quot;&gt;link to datasheet&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need 3 pins to control these chips: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Clock&lt;/li&gt;&#xA;&lt;li&gt;Latch&lt;/li&gt;&#xA;&lt;li&gt;Data&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In a program, you pass on the data one bit at a time to the shift register using the &lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftOut&quot; rel=&quot;noreferrer&quot;&gt;shiftOut() command&lt;/a&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shiftOut(dataPin, clockPin, data); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that command, you set each of the 8 outputs on the 595 IC with the 8 bits in the &lt;code&gt;data&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With one 595, you gain 5 pins (8 on the IC, but you spend 3 to talk to it). To get more outputs, you can daisy-chain a series of 595 together, by connecting its serial-out pin, to the data pin of the next one. You also must connect together the clock and latch pins of all of the 595 ICs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resulting circuit (using one 595) would look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mUyUl.jpg&quot; alt=&quot;Circuit using 595 shift register&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The figure above was taken from this &lt;a href=&quot;http://codeproject.com&quot; rel=&quot;noreferrer&quot;&gt;codeproject.com&lt;/a&gt; webpage:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/144606/Arduino-Platform-Working-with-Shift-Registers&quot; rel=&quot;noreferrer&quot;&gt;Arduino Platform - Working with Shift Registers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latch pin is used to keep the 595 outputs steady while you are shifting out data into it, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(latchPin, LOW);&#xA;shiftOut(dataPin, clockPin, data); &#xA;digitalWrite(latchPin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2018-02-16T14:51:36.183" LastActivityDate="2018-02-16T14:51:36.183" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="120" PostTypeId="2" ParentId="113" CreationDate="2014-02-12T17:01:24.530" Score="8" Body="&lt;p&gt;Write a sketch that millis 1000 times, not by making a loop, but by copy and paste. Measure that and compare it to the actual expected time. Mind you that that the results may vary with different versions of the IDE (and its compiler in particular).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to toggle an IO pin before and after the millis call, then measure the time for a very small value and a somewhat larger value. Compare the measured timings and calculate the overhead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most accurate way is to take a look at the disassembly listing, the generated code. But that is not for the faint of heart. You'll have to carefully study the datasheet how long each instruction cycle takes.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-13T06:11:15.470" LastActivityDate="2014-02-13T06:11:15.470" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="121" PostTypeId="2" ParentId="74" CreationDate="2014-02-12T17:26:22.720" Score="5" Body="&lt;p&gt;No, You shouldn't need any type of cooling device such as a fan as long as the case has a few holes in order to allow the heat to rise out of the case. I do not recommend using cases that are completely sealed, unless you are using it in an environment that has things that could hard the Arduino such as  ROVs or Nuclear waste facility (although I don't know why you would be at one in the first place).&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-12T17:26:22.720" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="122" PostTypeId="1" AcceptedAnswerId="128" CreationDate="2014-02-12T17:28:00.757" Score="12" ViewCount="1903" Body="&lt;p&gt;I want to use the &lt;a href=&quot;http://learn.adafruit.com/adafruit-cc3000-wifi&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit CC3000&lt;/a&gt; and its &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino libraries&lt;/a&gt; on another platform. In this case it's the Arduino pin compatible &lt;a href=&quot;http://www.cypress.com/?rID=77780&quot; rel=&quot;nofollow noreferrer&quot;&gt;PSOC4 Pioneer Kit&lt;/a&gt;. This is an ARM Cortex M0 based platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: How would I go about porting a library like this? What are the steps, key files etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One obvious issue is that PSOC Creator does not readily support C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One positive might be that the Arduino Due board is based on the Atmel SAM3X8E ARM Cortex-M3 CPU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: If you think this question is off topic; please head over to &lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/22/is-it-ok-to-ask-questions-about-arduino-compatible-micros-not-clones&quot;&gt;this question&lt;/a&gt; on Arduino Meta to voice your opinion on whether questions on Arduino Compatible devices are appropriate for this list.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="-1" LastEditDate="2017-03-16T15:52:43.687" LastActivityDate="2014-02-12T20:32:53.883" Title="What are the steps involved in porting an Arduino library?" Tags="|library|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="123" PostTypeId="1" CreationDate="2014-02-12T17:30:59.020" Score="13" ViewCount="1793" Body="&lt;p&gt;What hardware and software solutions work and what are the tradeoffs for connecting an Arduino Due to the internet?  I gather the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot;&gt;ethernet hardware&lt;/a&gt; is much cheaper than &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot;&gt;WiFi hardware&lt;/a&gt; (€29 versus €69).  In either case (wired or wireless), what software stacks and drivers work under AtmelStudio?&lt;/p&gt;&#xA;" OwnerUserId="44" LastActivityDate="2014-03-03T18:48:47.357" Title="Internet connectivity for the Arduino Due using AtmelStudio?" Tags="|ethernet|arduino-due|atmel-studio|wifi|tcpip|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="124" PostTypeId="1" CreationDate="2014-02-12T19:26:18.917" Score="14" ViewCount="2391" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How does one prepare clothing with embedded electronics for washing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; There are several Arduino boards/clones that are designed for &quot;wearable tech.&quot;  (For example, the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardLilyPad&quot;&gt;Lilypad&lt;/a&gt;.)  Wearable tech with LED light patterns, microphones, GPS, or other circuitry is an interesting concept, but water and electricity tend not to mix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prepare wearable tech for washing, I would assume people make large circuitry removable.  Yet, inevitably, some electronics will be more-or-less permanently affixed to the cloth.  What, if anything, can be done to these electronics (e.g. sewn-in Arduino Lilypad) to make them washing-machine (preferred--hand wash could be done, but it's so much easier to machine wash) safe?&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2014-02-16T18:29:21.220" Title="Washable, Wearable Tech with Arduino" Tags="|safety|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="125" PostTypeId="2" ParentId="124" CreationDate="2014-02-12T19:39:19.070" Score="5" Body="&lt;p&gt;I would use some sort of epoxy and cover up the exposed circuitry. The major concern would be where the wires connect to the board as flex over time can weaken it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some options include:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.3m.com/product/information/Scotchcast-Wet-Niche-Potting-Kit.html&quot; rel=&quot;nofollow&quot;&gt;3M™ Scotchcast™ Wet-Niche Potting Kit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.henkelna.com/product-search-1554.htm?nodeid=8797846732801&quot; rel=&quot;nofollow&quot;&gt;Hysol&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;US1150™—For electronics, telecommunications, and automotive&#xA;  components. Provides environmental hazard protection.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;US1152™—For electronic assemblies. Provides environmental hazard protection.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  Heat might play a factor if you cover up the boards in epoxy but you shouldn't be producing that much heat in a wearable device anyway, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-02-12T19:45:00.310" LastActivityDate="2014-02-12T19:45:00.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="126" PostTypeId="2" ParentId="117" CreationDate="2014-02-12T19:41:02.147" Score="20" Body="&lt;p&gt;If you want to drive LEDs, then you can also use a MAX7219 that can drive 64 LEDs, without extra circuitry (no need for transistor to amplify signal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Driving a &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/1339&quot;&gt;MAX7219&lt;/a&gt; requires only 3 output pins on Arduino.&#xA;Also, you can find a few &lt;a href=&quot;http://playground.arduino.cc/Main/LedControl&quot;&gt;Arduino libraries&lt;/a&gt; for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also chain several of them if you need to power more than 64 LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used it successfully for multiple 7-segment LED displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downside: it is expensive (about $10).&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-02-12T21:03:50.000" LastActivityDate="2014-02-12T21:03:50.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="127" PostTypeId="2" ParentId="124" CreationDate="2014-02-12T19:42:37.623" Score="4" Body="&lt;p&gt;I would make it so the Board has velcro on it so that it can be un attached from the clothing, and then have all the wires have snap terminals that wires from the Arduino connect to. This way you un snap all the wires and remove the arduino. As far as components, I would cover them in an epoxy to protect them.&lt;/p&gt;&#xA;" OwnerUserId="24" LastActivityDate="2014-02-12T19:42:37.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="128" PostTypeId="2" ParentId="122" CreationDate="2014-02-12T20:32:53.883" Score="10" Body="&lt;p&gt;I did essentially the same thing with getting the Adafruit ST7735 library working in chipKIT. &lt;a href=&quot;http://forums.adafruit.com/viewtopic.php?f=47&amp;amp;t=42966&quot;&gt;I started a support thread here which can lead you through my process&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tackled it the same way I do general programming:&lt;br&gt;&#xA;1-» Copy over Libraries, get it so your compiler can actually SEE them.&lt;br&gt;&#xA;2-» Start trying to compile and then triage errors from the &quot;top level&quot; down:&lt;br&gt;&#xA;3-» Look for stlib functions you recognize as should be working and fix those.&lt;br&gt;&#xA;4-» Look for AVR specific code and comment those out. I normally also add my initials and a comment: &lt;code&gt;ckck - bitbanging SPI&lt;/code&gt;, so I can search for these later.&lt;br&gt;&#xA;Repeat 3 and 4 until it works or you quit. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reach out to the forums for your target; they might have been there done that -- or like in my case, you introduce them to something that they want, so they dive in and help.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-02-12T20:32:53.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="129" PostTypeId="1" AcceptedAnswerId="130" CreationDate="2014-02-12T21:54:44.307" Score="6" ViewCount="799" Body="&lt;p&gt;I was communicating between my computer and my Arduino Uno R3 through Bluetooth using &lt;a href=&quot;http://www.mdfly.com/index.php?main_page=product_info&amp;amp;cPath=8_47&amp;amp;products_id=769&amp;amp;zenid=6f2b3946847b73b5ef2185e5e756e498&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Bluetooth module&lt;/a&gt;. The connector I use has a red wire where it connects to GND, and a black wire where it connects to +5V.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/upJ7C.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                ↓        ↓  to Uno ↓       ↓&#xA;               +5V      GND       pin 0  pin 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I forgot this one time when I connected the Bluetooth module to the Uno, so the polarity was reversed. This fried the Bluetooth module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After getting a new module, I discovered that the Uno was apparently fried too. Plugging a USB cable into the Uno made the little green integrated LED turn on, but that was all that happened; none of the pins put out any electricity. When I tried to upload a program, it gave the infamous &lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&lt;/code&gt; error. I could upload programs to my other Uno fine, and I could not upload to the broken Uno on my other computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two of the Arduino experts I know told me that the ATmega328 chip might be the only broken part. Is this likely to be the case? I have an Uno R2 with a working ATmega328. Would temporarily replacing the R3's ATmega with that R2's ATmega have a change of damaging anything?&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-02-25T14:47:02.720" LastActivityDate="2014-02-25T14:47:02.720" Title="Is my ATmega broken, and would replacing it with another break that one, too?" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="130" PostTypeId="2" ParentId="129" CreationDate="2014-02-12T22:08:04.703" Score="7" Body="&lt;p&gt;Besides breaking a pin while removing the IC from its socket, or static electricity during manipulation, I don't see what could fry the ATmega. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is possible that the R2 ATmega has a different bootloader and that may be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was you I would just remove the ATmega from the R3 board and test it on a breadboard (don't need a lot of components to do that); at least that could tell you if it is fried or if it is the R3 board that is fried...&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-12T22:08:04.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="131" PostTypeId="2" ParentId="104" CreationDate="2014-02-12T22:40:52.577" Score="6" Body="&lt;p&gt;I figured out a way to do this without having to port the compiler to iOS. It only works with the arduino Yún, but the Yún can send code to other arduinos with an spi cable.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install an SSH app on your device so you can communicate with the arduino&lt;/li&gt;&#xA;&lt;li&gt;Using that, install &lt;a href=&quot;http://inotool.org&quot;&gt;Ino&lt;/a&gt; on your Yún, a command line arduino compiler&lt;/li&gt;&#xA;&lt;li&gt;Create a file, put your code in it, then save it&lt;/li&gt;&#xA;&lt;li&gt;use &lt;a href=&quot;http://inotool.org&quot;&gt;Ino&lt;/a&gt; to upload your code!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;kind of confusing, but it could work!&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-12T22:40:52.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="132" PostTypeId="1" AcceptedAnswerId="133" CreationDate="2014-02-13T00:17:38.463" Score="34" ViewCount="69650" Body="&lt;p&gt;There are some pins on the Arduino which I haven't been able to find out anything about:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;IOREF&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;AREF&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;An unlabeled one next to &lt;code&gt;IOREF&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What are they?&lt;/p&gt;&#xA;" OwnerUserId="144" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:37.477" LastActivityDate="2016-04-16T23:38:43.477" Title="What are the AREF, IOREF, and the unlabeled pin next to IOREF on the Uno R3?" Tags="|pins|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="133" PostTypeId="2" ParentId="132" CreationDate="2014-02-13T00:21:17.303" Score="32" Body="&lt;p&gt;&lt;strong&gt;AREF:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the voltage reference analog-to-digital converter (ADC). It can be used instead of the standard 5V reference for the top end of the analog spectrum – for example, if you wanted to use the ADC to monitor a signal that had a 0-1.5 volt range you could get the full scale of the ADC by connect AREF to a 1.5V signal. &lt;strong&gt;DO NOT CONNECT A SIGNAL OUTSIDE THE 0V TO 5V RANGE!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in order for this to work, you must run &lt;code&gt;analogReference(EXTERNAL);&lt;/code&gt; before using &lt;code&gt;analogRead()&lt;/code&gt;. Also:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After changing the analog reference, the first few readings from analogRead() may not be accurate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Fore more information, see &lt;a href=&quot;http://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;noreferrer&quot;&gt;AnalogReference&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IOREF:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a voltage corresponding to the i/o of that board, for example an Uno would supply 5v to this pin, but a Due would supply 3.3v. Sending a signal to this pin does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Unlabeled pin:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This pin is unused, but is there to ensure compatibility with future products. It is not connected to anything on any R3 boards I have seen.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="10507" LastEditDate="2016-04-16T23:38:43.477" LastActivityDate="2016-04-16T23:38:43.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="134" PostTypeId="2" ParentId="117" CreationDate="2014-02-13T00:28:13.180" Score="7" Body="&lt;p&gt;As you wrote already already, you can use all pins, including TX and RX as digital output. I did that a while ago for a demonstrator and recorded a video - &lt;a href=&quot;http://www.youtube.com/watch?v=ibhoqUkiSys&quot; rel=&quot;nofollow noreferrer&quot;&gt;20 LEDS on 20 pins&lt;/a&gt; - of this rather nonsensical project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As described by &lt;em&gt;Peter R. Bloomfield&lt;/em&gt; &lt;a href=&quot;https://arduino.stackexchange.com/questions/85/why-cant-i-upload-a-sketch-while-other-components-devices-are-connected-to-my-u&quot;&gt;here&lt;/a&gt;, you a have to disconnect TX and RX for upload. Moreover, you're out of pins to read sensors for possible interactivity and have to make sure that the total current limit isn't reached. Not to forget that you're limited to 5V leds if you drive them directly with your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of shift registers in general and the 595, described by &lt;em&gt;Ricardo&lt;/em&gt; is therefore highly recommended. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;They are cheap!&lt;/li&gt;&#xA;&lt;li&gt;It's rather easy to cascade them.&lt;/li&gt;&#xA;&lt;li&gt;A lot of speed can be gained when you use hardware-SPI.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I used them a while ago when I realized the soldering and programming part of &lt;a href=&quot;http://www.heise.de/hardware-hacks/projekte/Kawaii-me-2073147.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kawaii me&lt;/a&gt; (text of the link is in German) of the upcycling artist &lt;em&gt;Dominik Jais&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, just a bunch of &lt;strong&gt;595&lt;/strong&gt; were used to drive a display of 8x11 leds. Since the leds were cut from a stripe of 12V SMD leds, an additional power supply and some &lt;strong&gt;UDN2803A&lt;/strong&gt; Darlington arrays, hooked to the output pins of the shift registers, were necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other general methods would include the use of PCF8574(A) 8bit port expanders, which are controlled via the I2C bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I'd give the 595 shift registers a try first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to control a couple of RGB leds, however, you might want to look for more specialized solutions. Some RGB leds come with their own &lt;strong&gt;WS2812&lt;/strong&gt;. These fine pieces can be cascaded (1-Wire bus) and are addressed via their position in the chain.&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-02-13T00:42:02.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="135" PostTypeId="2" ParentId="132" CreationDate="2014-02-13T00:33:14.047" Score="14" Body="&lt;p&gt;Concerning the &lt;code&gt;AREF&lt;/code&gt; pin, you have to remember that the Arduino comes with a 10bit ADC (Analog-Digital-Converter), which converts incoming voltages between 0V and 5V to integer values between 0 and 1023. This results in a resolution of roughly 4.8 mV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a sensor only delivers a lower maximum voltage, it is resonable to apply this voltage to the &lt;code&gt;AREF&lt;/code&gt; pin, just in order to obtain a higher resolution.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-02-13T00:33:14.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="136" PostTypeId="1" AcceptedAnswerId="137" CreationDate="2014-02-13T02:04:23.007" Score="15" ViewCount="13772" Body="&lt;p&gt;There are three different revisions of the Arduino Uno. What changed in each revision?&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="33" LastEditDate="2015-01-01T22:58:32.373" LastActivityDate="2019-06-08T13:01:12.357" Title="What is the difference between the revisions of the Arduino Uno board?" Tags="|arduino-uno|revisions|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="137" PostTypeId="2" ParentId="136" CreationDate="2014-02-13T02:10:54.823" Score="11" Body="&lt;p&gt;Here is a summary from &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;noreferrer&quot;&gt;the official site&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Revision 2 of the Uno board has a resistor pulling the 8U2 HWB line to&#xA;ground, making it easier to put into DFU mode.&lt;/p&gt;&#xA;&lt;p&gt;Revision 3 of the board has the following new features:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near to the RESET pin, the IOREF that&#xA;allow the shields to adapt to the voltage provided from the board. In&#xA;future, shields will be compatible with both the board that uses the&#xA;AVR, which operates with 5V and with the Arduino Due that operates&#xA;with 3.3V. The second one is a not connected pin, that is reserved for&#xA;future purposes.&lt;/li&gt;&#xA;&lt;li&gt;Stronger RESET circuit.&lt;/li&gt;&#xA;&lt;li&gt;Atmega 16U2 replace the 8U2.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A more detailed list of changes can be found &lt;a href=&quot;http://startingelectronics.com/articles/arduino/uno-r3-r2-differences/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;R2:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The rotation of the ATMEGA8U2 (the little chip near the USB port) was changed by 45 degrees. &lt;img src=&quot;https://i.stack.imgur.com/piYR2.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Four solder pads (JP2) were added, connecting to pins PB4 to PB7 of the USB ATMEGA.&amp;quot; &lt;img src=&quot;https://i.stack.imgur.com/mudBq.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Instead of R1's solder pads, R2 adds header pins to the USB ATMEGA ICSP. &lt;img src=&quot;https://i.stack.imgur.com/zj258.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An LED connected to pin 13 was added. It turns on when pin 13 is &lt;code&gt;HIGH&lt;/code&gt;, off when &lt;code&gt;LOW&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The main microchip was changed from an ATmega168 to an ATmega328.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A resistor was added between the DTR (HWB) line and the ATMEGA PD7 pin.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/lzBuR.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;R3:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The rotation of the ATMEGA8U2 was changed back by 45 degrees.&lt;/li&gt;&#xA;&lt;li&gt;The ATMEGA8U2 was changed to an ATMEGA16U2.&lt;/li&gt;&#xA;&lt;li&gt;A diode was added, wired from +5vdc to the reset pin, cathode to +5vdc.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/XneB4.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/li&gt;&#xA;&lt;li&gt;The 8 pin connector that contains Arduino pins 8 was changed to 13, GND and AREF for a 10 pin connector. The extra 2 pins are connected to AD4/SDA and AD5/SCL. Also, the 6 pin connector that has the reset pin connected to it changed to an 8 pin connector. One of the new pins on this header is the IOREF pin that allows shields connected to the board to adapt to the voltage of the board. The second pin is not connected and reserved for future use.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ay2Zt.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="37" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-13T02:44:21.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="138" PostTypeId="2" ParentId="136" CreationDate="2014-02-13T02:21:28.900" Score="5" Body="&lt;h3&gt;User Side Changes&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Both revision 2 and 3 boards add four solder pads (JP2) connecting to pins PB4 to PB7 of the USB ATMEGA.&lt;/li&gt;&#xA;&lt;li&gt;Revision 2 and 3 boards are both supplied with header pins in the USB ATMEGA ICSP header rather than just solder pads in the Arduino Uno.&lt;/li&gt;&#xA;&lt;li&gt;The revision 3 board changes the 8 pin connector that contains Arduino pins 8 to 13, GND and AREF for a 10 pin connector. The extra 2 pins are connected to AD4/SDA and AD5/SCL. These are the two analog input pins that can be used for I2C.&lt;/li&gt;&#xA;&lt;li&gt;Revision 3 boards change the 6 pin connector that has the reset pin connected to it to an 8 pin connector. One of the new pins on this header is the IOREF pin that allows shields connected to the board to adapt to the voltage of the board. The second pin is reserved for future use.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Electronics Based Changes&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino Uno and Arduino Uno revision 2 both have an ATMEGA8U2 USB microcontroller on board – this is upgraded to an ATMEGA16U2 on the revision 3 board.&lt;/li&gt;&#xA;&lt;li&gt;Revision 3 adds a diode across the USB ATMEGA reset pin pull-up resistor.&lt;/li&gt;&#xA;&lt;li&gt;Both revision 2 and 3 boards add a 1k pull-down resistor to the DTR (HWB) line coming from the USB ATMEGA microcontroller – from the PD7 pin.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino Uno and Arduino Uno revision 2 both have a LED and resistor connected in series on Arduino pin 13. The revision 3 board buffers this LED/resistor through a unity gain op-amp. This is the spare op-amp that was unused on previous boards.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Sources:&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://startingelectronics.com/articles/arduino/uno-r3-r2-differences/&quot; rel=&quot;noreferrer&quot;&gt;http://startingelectronics.com/articles/arduino/uno-r3-r2-differences/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-13T02:21:28.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="139" PostTypeId="2" ParentId="117" CreationDate="2014-02-13T02:24:28.673" Score="11" Body="&lt;p&gt;In addition to &lt;a href=&quot;https://arduino.stackexchange.com/users/46/ricardo&quot;&gt;Ricardo&lt;/a&gt;'s answer, what Wikipedia states on &lt;a href=&quot;http://en.wikipedia.org/wiki/Shift_register#Uses&quot; rel=&quot;noreferrer&quot;&gt;shift registers&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One of the most common uses of a shift register is to convert between serial and parallel interfaces. [...] SIPO registers are commonly attached to the output of microprocessors when more General Purpose Input/Output pins are required than are available. This allows several binary devices to be controlled using only two or three pins, but slower than parallel I/O.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;http://www.codeproject.com/Articles/144606/Arduino-Platform-Working-with-Shift-Registers&quot; rel=&quot;noreferrer&quot;&gt;article&lt;/a&gt; Ricardo linked you can see the diagram of the shift register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fnNDa.png&quot; alt=&quot;Shift register diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens here is that you put the data of the 8 pins in a sequence and for each clock tick the shift register will shift (move the binary data from each latch to the next one) until it &quot;makes a circle&quot; i.e. the first bit arrives to the last pin. Shift registers also have an input where you can turn on/off the shifting so the status can be kept after the data is shifted to the position. For a simple demonstration see the following animation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JgnIV.gif&quot; alt=&quot;Shift register animation&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the red light is the serial input and the green ones are showing the state of the latches in this simplified &lt;a href=&quot;http://en.wikipedia.org/wiki/Shift_register#Serial-in.2C_parallel-out_.28SIPO.29&quot; rel=&quot;noreferrer&quot;&gt;SIPO shift register&lt;/a&gt;. After the data shifted to place shifting can be turned off and you can read the pins. In this example I shifted out &lt;code&gt;10101011&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From these examples you can realize that serial transfer will be slower than parallel, because you have to wait for the shift register to shift the bits to their place. You will have to wait the same amount of clock tick as many bits you want to load. This is one of the many reasons why you can't chain them indefinitely, because loading would take forever.&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2014-02-13T02:24:28.673" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="140" PostTypeId="1" CreationDate="2014-02-13T02:49:06.950" Score="8" ViewCount="21945" Body="&lt;p&gt;I want to use sensors on an Arduino to control values in a &lt;a href=&quot;http://en.wikipedia.org/wiki/MATLAB&quot; rel=&quot;noreferrer&quot;&gt;MATLAB&lt;/a&gt; program. What are my options for communicating?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used &lt;a href=&quot;http://en.wikipedia.org/wiki/Processing_%28programming_language%29&quot; rel=&quot;noreferrer&quot;&gt;Processing&lt;/a&gt; to receive data sent via the serial cable, and that strategy has worked pretty well. Is there something similar I can do using MATLAB? I'm somewhat new to MATLAB, so gentle guidance would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not really looking for something like the &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/32374-matlab-support-package-for-arduino-aka-arduinoio-package&quot; rel=&quot;noreferrer&quot;&gt;ArduinoIO&lt;/a&gt; package -- I want to have separate computation executing on the Arduino and occasionally informing my MATLAB program (which will occasionally poll the serial line, I suppose).&lt;/p&gt;&#xA;" OwnerUserId="150" LastEditorUserId="510" LastEditDate="2014-04-13T16:58:53.837" LastActivityDate="2015-03-31T06:48:38.067" Title="How can I communicate from Arduino to MATLAB" Tags="|serial|matlab|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="141" PostTypeId="1" AcceptedAnswerId="152" CreationDate="2014-02-13T02:53:07.690" Score="15" ViewCount="7013" Body="&lt;p&gt;Can I program my Arduino using any programming language other than C++? If so, which programming languages? What software would I need for compiling and loading my code onto the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="33" LastEditorUserId="6377" LastEditDate="2018-08-06T18:53:31.837" LastActivityDate="2019-06-13T16:05:45.903" Title="Programming options other than C++" Tags="|programming|software|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="142" PostTypeId="1" AcceptedAnswerId="163" CreationDate="2014-02-13T02:56:18.943" Score="13" ViewCount="43409" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Where do I put code if I want it to execute only once per Arduino startup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt; I tend to use my Arduino to perform tasks that should be executed once per power cycle.  (For example, my robot should only drive forward &lt;em&gt;once&lt;/em&gt; every time I turn it on--more than that, and it might fall off the table.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard Arduino IDE &quot;template&quot; consists of a &lt;code&gt;loop()&lt;/code&gt; and a &lt;code&gt;setup()&lt;/code&gt; function.  The &lt;code&gt;setup&lt;/code&gt; code is run once per power cycle, and the &lt;code&gt;loop&lt;/code&gt; is re-started every time it finishes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see two approaches to code &quot;1 time tasks:&quot;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Method 1: &quot;Loop once&quot;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //do setup stuff&#xA;}&#xA;&#xA;void loop() {&#xA;  //do task&#xA;&#xA;  while(1) ; //Repeat forever, preventing function from re-starting&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Method 2: &quot;Setup only&quot;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //do setup stuff&#xA;&#xA;  //do task&#xA;}&#xA;&#xA;void loop() {&#xA;  //do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More detailed form of question:&lt;/strong&gt;  Is one of these methods &quot;better&quot; from a hardware/software sense?  (e.g. is there anything &quot;special&quot; about the &lt;code&gt;setup&lt;/code&gt; function, like it can only run for so much time?)&lt;br&gt;&#xA;And, if they are the same from a hardware/software perspective, is there a &quot;best practice&quot; or standard way of writing code for these situations in the Arduino community?&lt;/p&gt;&#xA;" OwnerUserId="52" LastActivityDate="2017-12-02T06:41:25.077" Title="Code for one-time execution in Arduino" Tags="|programming|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="143" PostTypeId="1" AcceptedAnswerId="149" CreationDate="2014-02-13T03:14:23.623" Score="11" ViewCount="7775" Body="&lt;p&gt;Before you start to mess with a computer there are basic guidelines to be aware of, such as turn the power off and watch out for static electricity. What guidelines should I be aware of when I work with an Arduino board if I don't want to harm neither myself nor the board. The three kind of activity that requires touching the Arduino and what I'm asking about:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setting up wire, component layout or breadboard.&lt;/li&gt;&#xA;&lt;li&gt;Debugging a running setup.&lt;/li&gt;&#xA;&lt;li&gt;Moving, mounting up the board somewhere.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="87" LastEditorUserId="87" LastEditDate="2014-02-27T21:40:10.170" LastActivityDate="2014-02-27T21:40:10.170" Title="What I should be aware before I touch my Arduino?" Tags="|safety|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="144" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T03:41:07.750" Score="5" Body="&lt;p&gt;I would strongly prefer Method 2. If you ever plan to add code to handle input, output, etc,  it's easy with Method 2 -- just fill in &lt;code&gt;loop()&lt;/code&gt;, but requires reworking/refactoring in Method 1. &lt;/p&gt;&#xA;" OwnerUserId="13" LastActivityDate="2014-02-13T03:41:07.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="145" PostTypeId="2" ParentId="141" CreationDate="2014-02-13T03:56:04.810" Score="9" Body="&lt;p&gt;In theory, any compiler which outputs AVR assembly could be used (modulo limitations on code size, ram usage etc). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVR backends exist for both &lt;a href=&quot;http://sourceforge.net/projects/avr-llvm/&quot;&gt;LLVM&lt;/a&gt; and  &lt;a href=&quot;http://gcc.gnu.org/wiki/avr-gcc&quot;&gt;GCC&lt;/a&gt; -- so in theory, with some effort, most languages which are supported by LLVM and GCC's front-ends could be compiled to AVR. A big question will be library support, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Never the less, here's a couple of odd choices for the spirit of the question, rather than its letter [1]. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://amforth.sourceforge.net/TG/recipes/Arduino-HelloWorld.html&quot;&gt;AMForth&lt;/a&gt;, a forth dialect can be flashed onto an Arduino. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/projects/avr-ada/&quot;&gt;AVR-Ada&lt;/a&gt;: &lt;a href=&quot;http://en.wikipedia.org/wiki/Ada_%28programming_language%29&quot;&gt;Ada&lt;/a&gt; for AVR micro-controllers. &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.mikroe.com/mikrobasic/avr/&quot;&gt;BASIC&lt;/a&gt;: Bring back the Goto!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Oh, and you could write raw &lt;a href=&quot;http://www.atmel.ca/Images/doc0856.pdf&quot;&gt;AVR Assembly&lt;/a&gt;! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1]- I Haven't tried these though! &lt;/p&gt;&#xA;" OwnerUserId="13" LastActivityDate="2014-02-13T03:56:04.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="146" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T04:01:09.127" Score="3" Body="&lt;p&gt;There is no time limit on the setup function. I prefer method 2 because the loop can be filled with whatever you need to later.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-13T04:01:09.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="147" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T04:23:36.643" Score="1" Body="&lt;p&gt;Definitely go with method two. That's what the setup function is there for. It's much easier to read as well. Anything in the &lt;code&gt;loop()&lt;/code&gt; implies it will be run in a loop.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-13T04:23:36.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="148" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T04:40:07.563" Score="6" Body="&lt;p&gt;I usually go with Method 2, but end up doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //do setup stuff&#xA;&#xA;  //do task&#xA;  init(); //Do start-up initialization steps&#xA;}&#xA;&#xA;void init() {&#xA;  // do tasks on startup&#xA;}&#xA;&#xA;void loop() {&#xA;  //do looping code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the above setup it allows my code to be even more organized.&lt;/p&gt;&#xA;" OwnerUserId="62" LastActivityDate="2014-02-13T04:40:07.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="149" PostTypeId="2" ParentId="143" CreationDate="2014-02-13T05:11:43.680" Score="14" Body="&lt;p&gt;Turning the power off and taking proper static precautions also applies to Arduinos.  Anorton's tip about not resting it on a conductive surface is also useful.  Some other things to keep in mind:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Double check the polarities of any connections you make.&lt;/li&gt;&#xA;&lt;li&gt;Keep a consistent wiring color code.  Use red for power and black for ground.&lt;/li&gt;&#xA;&lt;li&gt;Calculate the expected current through all components before you apply power.  Check the datasheet to make sure it's within safe limits.&lt;/li&gt;&#xA;&lt;li&gt;Calculate the heat dissipation for higher power components like power supplies and motor drivers.&lt;/li&gt;&#xA;&lt;li&gt;Connect and test one small part at a time, instead of in one big bang.&lt;/li&gt;&#xA;&lt;li&gt;Make sure the parts you buy expect the same voltage, or perform the appropriate conversion.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For keeping people safe:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Know where the fire extinguisher is.&lt;/li&gt;&#xA;&lt;li&gt;Don't put cords where people can trip on them.&lt;/li&gt;&#xA;&lt;li&gt;Use a proper stand to hold your soldering iron, and keep pets and small children away.&lt;/li&gt;&#xA;&lt;li&gt;If your project has a propeller or something physically dangerous, build failsafes and kill switches into the system.&lt;/li&gt;&#xA;&lt;li&gt;Be careful to charge any batteries properly, and not let them overheat.&lt;/li&gt;&#xA;&lt;li&gt;Be careful what you touch while troubleshooting.  Arduinos usually don't deal with very high voltages, but inductors and capacitors can build up higher charges than you expect, and hold it after power is removed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="40" LastActivityDate="2014-02-13T05:11:43.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="150" PostTypeId="2" ParentId="104" CreationDate="2014-02-13T05:21:46.223" Score="2" Body="&lt;p&gt;You can always upload to the Arduino via Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You must have a bluetooth chip/shield (any should do) and a PC that has bluetooth (or a table that can compile, most likely an Android tablet)&lt;/li&gt;&#xA;&lt;li&gt;You must change the BT baud rate to the same as normal arduino upload, which is 19200 (default BT baud is 9600).&lt;/li&gt;&#xA;&lt;li&gt;Connect the BT to Pin 0 and 1 so act the same as having a USB cord connected&lt;/li&gt;&#xA;&lt;li&gt;Connect a wire to the reset pin to allow remote resetting the arduino to statup the bootloader&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There must be a delay before&#xA;hitting the reset pin as the bootloader must be active when hitting&#xA;the upload button.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enjoy&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For a more detailed description please read: &lt;a href=&quot;http://ame2.asu.edu/staff/kidane/ArdWilessBtProg.pdf&quot; rel=&quot;nofollow&quot;&gt;http://ame2.asu.edu/staff/kidane/ArdWilessBtProg.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="62" LastActivityDate="2014-02-13T05:21:46.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="151" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T06:24:45.360" Score="0" Body="&lt;p&gt;As most other answers, I would go for method 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I would try to avoid the call, by Arduino library, to an an empty &lt;code&gt;loop()&lt;/code&gt; that makes the Atmel consume &quot;a lot&quot; of current for nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As some comments pointed out though, using &lt;code&gt;delay()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt; will change nothing to power consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, if you would like to reduce power consumption once your &lt;code&gt;setup()&lt;/code&gt; has run, you will have to play with Atmel sleep modes.&#xA;You can take a look at &lt;a href=&quot;http://playground.arduino.cc/Learning/arduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; that shows how to deal with sleep modes from your Arduino sketches; it does more than just putting the Atmel to sleep but it is a good (and simple) read if you want to play with sleep modes.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-02-13T18:29:09.117" LastActivityDate="2014-02-13T18:29:09.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="152" PostTypeId="2" ParentId="141" CreationDate="2014-02-13T06:58:14.893" Score="5" Body="&lt;p&gt;Some commonly known ones:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/apps/mediawiki/avr-ada/index.php?title=AVR-Ada&quot; rel=&quot;noreferrer&quot;&gt;Ada&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.mcselec.com/&quot; rel=&quot;noreferrer&quot;&gt;Basic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://claymore.engineer.gvsu.edu/~steriana/Python/pfavr/rationale.html&quot; rel=&quot;noreferrer&quot;&gt;Forth&lt;/a&gt;, &lt;a href=&quot;http://www.forth.com/embedded/index.html&quot; rel=&quot;noreferrer&quot;&gt;alt&lt;/a&gt;, &lt;a href=&quot;http://www.forth.com/embedded/index.html&quot; rel=&quot;noreferrer&quot;&gt;alt&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.harbaum.org/till/nanovm/index.shtml&quot; rel=&quot;noreferrer&quot;&gt;Java&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.e-lab.de/AVRco/index_en.html&quot; rel=&quot;noreferrer&quot;&gt;Pascal&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wiki.python.org/moin/PyMite&quot; rel=&quot;noreferrer&quot;&gt;Python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ladyada.net/learn/avr/setup-mac.html&quot; rel=&quot;noreferrer&quot;&gt;C&lt;/a&gt; (mac) and &lt;a href=&quot;http://winavr.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;C&lt;/a&gt; (Windows)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In theory you should be able to extend avr-gcc to support other languages, though this is no small undertaking. I should also caveat that support for languages other than C typically comes with some fairly weighty restrictions on language components -- for instance, even with C++ it's discouraged to be instantiating new objects as &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; are extremely expensive in both memory space and cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides using Google, the following references are applicable &lt;a href=&quot;http://www.piclist.com/techref/atmel/avr/languages.htm&quot; rel=&quot;noreferrer&quot;&gt;Click Here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="77" LastActivityDate="2014-02-13T06:58:14.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="153" PostTypeId="1" CreationDate="2014-02-13T07:05:23.627" Score="22" ViewCount="182916" Body="&lt;p&gt;When you have a board in your hand but you don't know is it working or not, how to verify if it's working or dead?&lt;/p&gt;&#xA;" OwnerUserId="77" LastEditorUserId="4143" LastEditDate="2015-06-06T23:41:14.560" LastActivityDate="2015-11-29T17:59:58.283" Title="How to check my Arduino board is working or dead?" Tags="|arduino-uno|testing|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="154" PostTypeId="2" ParentId="153" CreationDate="2014-02-13T07:05:23.627" Score="16" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; After the @Ricardo's comment on my last post, I am posting this !&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Plug the board into a USB port on your computer and check that the green LED power indicator on the board illuminates. Standard Arduino boards (Uno, Duemilanove, and Mega) have a green LED power indicator located near the reset switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An orange LED near the center of the board (labeled “Pin 13 LED” in the image below) should flash on and off when the board is powered up (boards come from the factory preloaded with software to flash the LED as a simple check that the board is working).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gDEH4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the power LED does not illuminate when the board is connected to your computer, the board is probably not receiving power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flashing LED (connected to digital output pin 13) is being controlled by code running on the board (new boards are preloaded with the Blink example sketch). If the pin 13 LED is flashing, the sketch is running correctly, which means the chip on the board is working. If the green power LED is on but the pin 13 LED is not flashing, it could be that the factory code is not on the chip. If you are not using a standard board, it may not have a built-in LED on pin 13, so check the documentation for details of your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Online guides for getting started with Arduino are available at for &lt;a href=&quot;http://arduino.cc/en/Guide/Windows&quot;&gt;Windows&lt;/a&gt;,  for &lt;a href=&quot;http://arduino.cc/en/Guide/MacOSX&quot;&gt;Mac OS X&lt;/a&gt;, and for &lt;a href=&quot;http://www.arduino.cc/Learning/Linux&quot;&gt;Linux&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="77" LastActivityDate="2014-02-13T07:05:23.627" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="155" PostTypeId="2" ParentId="153" CreationDate="2014-02-13T07:37:20.493" Score="5" Body="&lt;p&gt;Supposed one owns a USB programmer, there's another way to inspect the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the programmer to the ICSP pins of the Arduino and call &lt;code&gt;avrdude&lt;/code&gt; with the right parameters to read the fuses of your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c programmer-id -p partno -P port&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For an Arduino Uno, &lt;code&gt;partno&lt;/code&gt; is &lt;code&gt;m328p&lt;/code&gt;. &lt;code&gt;Programmer-id&lt;/code&gt; depends on the device used. In my case (mySmartUSB light) &lt;code&gt;stk500v2&lt;/code&gt; is a supported and &lt;code&gt;port&lt;/code&gt; is &lt;code&gt;/dev/ttyUSB0&lt;/code&gt;. Here&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c stk500v2 -p m328p -P /dev/ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives the following output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: AVR device initialized and ready to accept instructions&#xA;Reading | ################################################## | 100% 0.01s&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: safemode: Fuses OK&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The UNO board responds with the correct signature and is ready for some action :)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;How to connect?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;My USB programmer came with a 6-wire ribbon cable with 2x3 female connectors on both sides. As usual, the wire for &lt;strong&gt;pin 1&lt;/strong&gt; is marked red. Due to a notch in at the 2x3 male connector of the programmer, the cable only fits here in one direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the Arduino UNO, the ICSP header is to the right of the reset button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pinout is as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;MISO  1    2 VCC&#xA;SCK   3    4 MOSI&#xA;RESET 5    6 GND&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; Pin 1 is the top left one, marked with a white dot!&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="6936" LastEditDate="2015-04-29T17:39:07.660" LastActivityDate="2015-04-29T17:39:07.660" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="156" PostTypeId="1" AcceptedAnswerId="157" CreationDate="2014-02-13T08:19:39.940" Score="6" ViewCount="1170" Body="&lt;p&gt;I'm using a &lt;a href=&quot;http://digistump.com/wiki/digix&quot; rel=&quot;nofollow noreferrer&quot;&gt;DigiX&lt;/a&gt; (Arduino Due based 3.3V) board to connect to a GPRS/GSM SIM908 breakout board. The SIM908 EVB board has the following pins on its RS232:&lt;img src=&quot;https://i.stack.imgur.com/zNZ90.png&quot; alt=&quot;RS232 pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got all three UART TX lines hooked up to the RX Lines (and RX to TX) on my Arduino but the board keeps resetting, which I would guess is some sort of voltage issue (I turned the board off immediately). However there are three MAX3232s on the underside of the board, which I thought would have made it so I could just connect the lines directly to the Arduino. Does anyone know why this might be happening or how to properly connect these two devices?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional info:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://digistump.com/wiki/digix/tutorials/pinout&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pinout of the DigiX&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://digispark.s3.amazonaws.com/DigiX-V1-Final-Production.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Schematic of the DigiX&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The below links are in Chinese):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is &lt;a href=&quot;http://pan.baidu.com/share/link?shareid=1471365276&amp;amp;uk=4130796101&amp;amp;third=15&quot; rel=&quot;nofollow noreferrer&quot;&gt;a SIM908 Hardware guide&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pan.baidu.com/share/link?shareid=1470501867&amp;amp;uk=4130796101&amp;amp;third=15&quot; rel=&quot;nofollow noreferrer&quot;&gt;The full schematic of the breakout board&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="157" LastEditorUserId="35" LastEditDate="2014-02-23T17:23:39.830" LastActivityDate="2014-02-23T17:23:39.830" Title="Connecting breakout board to Arduino with UART" Tags="|serial|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="157" PostTypeId="2" ParentId="156" CreationDate="2014-02-13T09:27:34.227" Score="5" Body="&lt;p&gt;Both the DigiX and the SIM908 are natively 3.3V boards. They should be able to connect to each other directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, the SIM908 breakout seems to only offer RS232 level serial outputs for the GPRS and GPS. On U3 (the SIM908 module itself) Pins 68/71 offer 3.3V levels for the GPRS (GPRS-TXD and GPRS-RXD) and 15/16 offer 3.3V levels for the GPS (GPS-TXD and GPS-RXD).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are converted to RS232 levels by the MAX3232 and presented on J3 and J13. I can't see any point where the 3.3V signals are presented on a connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Breakout the 3.3V signals onto connectors by modifying the SIM908&#xA;breakout board. &lt;/li&gt;&#xA;&lt;li&gt;Build a level converter to take the 3.3V signals from&#xA;the DigiX to RS232 and then connect them as before.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may have damaged the DigiX board connecting RS232 levels directly to it however. The ARM based Arduinos are far less tolerant of voltage abuse than the ATmega based Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-02-13T09:27:34.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="158" PostTypeId="1" AcceptedAnswerId="160" CreationDate="2014-02-13T10:08:53.917" Score="12" ViewCount="29111" Body="&lt;p&gt;I have a few useful I2C components, such as a 16-bit port expander (MCP23017), which I'd like to use in various projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to do to make these work with Arduino? Will it work with any Arduino, or do I need a specific board or shield?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-23T17:01:20.390" LastActivityDate="2017-03-27T21:47:48.837" Title="How do I use I2C devices with Arduino?" Tags="|i2c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="159" PostTypeId="2" ParentId="158" CreationDate="2014-02-13T10:14:06.827" Score="3" Body="&lt;p&gt;Additional shields are not needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only need the Wire library and a couple of wires to connect the device to &lt;strong&gt;SDA&lt;/strong&gt; and &lt;strong&gt;SCL&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The position of these pins is different on the various Arduinos, please have a look &lt;a href=&quot;http://arduino.cc/de/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-02-13T10:14:06.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="160" PostTypeId="2" ParentId="158" CreationDate="2014-02-13T10:23:06.987" Score="9" Body="&lt;p&gt;Arduino have the &lt;a href=&quot;http://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wire Library&lt;/a&gt; that communicate with I2C.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This library allows you to communicate with I2C / TWI devices. On the&#xA;  Arduino boards with the R3 layout (1.0 pinout), the SDA (data line)&#xA;  and SCL (clock line) are on the pin headers close to the AREF pin. The&#xA;  Arduino Due has two I2C / TWI interfaces SDA1 and SCL1 are near to the&#xA;  AREF pin and the additional one is on pins 20 and 21. As a reference&#xA;  the table below shows where TWI pins are located on various Arduino&#xA;  boards.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Board   I2C / TWI pins&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uno, Ethernet    A4 (SDA), A5 (SCL)&lt;/li&gt;&#xA;&lt;li&gt;Mega2560 20 (SDA), 21 (SCL)&lt;/li&gt;&#xA;&lt;li&gt;Leonardo 2 (SDA), 3 (SCL)&lt;/li&gt;&#xA;&lt;li&gt;Due  20 (SDA), 21 (SCL), SDA1, SCL1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can take a look at , &lt;a href=&quot;http://www.instructables.com/id/I2C-between-Arduinos/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like @TheDoctor said:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The I2C data lines both need resistors to 3.3V. This keeps them from&#xA;  drifting if they are disabled. Andy resistor value should work, but it&#xA;  is recommended to use one between 10k ohm and 47k ohm.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3" LastEditorUserId="-1" LastEditDate="2017-03-27T21:47:48.837" LastActivityDate="2017-03-27T21:47:48.837" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="161" PostTypeId="2" ParentId="113" CreationDate="2014-02-13T10:41:34.937" Score="3" Body="&lt;p&gt;I second calling millis repeatedly and then comparing actual vs. expected.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There will be some minimal overhead, but it will diminish in significance the more times you call millis(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Arduino\Arduino ERW 1.0.5\hardware\arduino\cores\arduino\wiring.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that millis() is very tiny at only 4 instructions &lt;code&gt;(cli is simply # define cli()  \__asm__ \__volatile__ (&quot;cli&quot; ::))&lt;/code&gt; and a return. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd call it about 10 million times using a FOR loop which has a volatile as the conditional. The volatile keyword will prevent the compiler from attempting any optimization on the loop itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't guarantee the following to be syntactically perfect..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int temp1,temp2;&#xA;temp1=millis();&#xA;for (volatile unsigned int j=0;j&amp;lt;1000000;++j){&#xA;temp2=millis();}&#xA;Serial.print(&quot;Execution time = &quot;);&#xA;Serial.print((temp2-temp1,DEC);&#xA;Serial.print(&quot;ms&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my guess is that takes ~900ms or about 56us per call to millis. ( I don't have an aruduino handy ATM.&lt;/p&gt;&#xA;" OwnerUserId="160" LastEditorUserId="11" LastEditDate="2014-02-14T00:05:50.570" LastActivityDate="2014-02-14T00:05:50.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="162" PostTypeId="2" ParentId="113" CreationDate="2014-02-13T12:26:29.550" Score="22" Body="&lt;p&gt;If you want to know &lt;em&gt;exactly&lt;/em&gt; how long something will take, there is only one solution: Look at the disassembly!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with the minimal code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){};&#xA;&#xA;volatile uint16_t x;&#xA;void loop()&#xA;{&#xA;  x = millis();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code compiled and then fed into &lt;code&gt;avr-objdump -S&lt;/code&gt; produces a documented disassembly. Here are the interesting excerpts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void loop()&lt;/code&gt; produces:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000000a8 &amp;lt;loop&amp;gt;:&#xA;  a8:   0e 94 a7 00     call    0x14e   ; 0x14e &amp;lt;millis&amp;gt;&#xA;  ac:   60 93 00 01     sts 0x0100, r22&#xA;  b0:   70 93 01 01     sts 0x0101, r23&#xA;  b4:   80 93 02 01     sts 0x0102, r24&#xA;  b8:   90 93 03 01     sts 0x0103, r25&#xA;  bc:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is a function call (&lt;code&gt;call&lt;/code&gt;), four copies (which copy each of the bytes in the &lt;code&gt;uint32_t&lt;/code&gt; return value of &lt;code&gt;millis()&lt;/code&gt; (note that the arduino docs call this a &lt;code&gt;long&lt;/code&gt;, but they are incorrect to not be explicitly specifying the variable sizes)), and finally the function return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;call&lt;/code&gt; requires 4 clock cycles, and each &lt;code&gt;sts&lt;/code&gt; requires 2 clock cycles, so we have a minimum of 12 clock cycles just for function call overhead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, lets look at the disassembly of the &lt;code&gt;&amp;lt;millis&amp;gt;&lt;/code&gt; function, which is located at &lt;code&gt;0x14e&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long millis()&#xA;{&#xA;    unsigned long m;&#xA;    uint8_t oldSREG = SREG;&#xA; 14e:   8f b7           in  r24, 0x3f   ; 63&#xA;&#xA;    // disable interrupts while we read timer0_millis or we might get an&#xA;    // inconsistent value (e.g. in the middle of a write to timer0_millis)&#xA;    cli();&#xA; 150:   f8 94           cli&#xA;    m = timer0_millis;&#xA; 152:   20 91 08 01     lds r18, 0x0108&#xA; 156:   30 91 09 01     lds r19, 0x0109&#xA; 15a:   40 91 0a 01     lds r20, 0x010A&#xA; 15e:   50 91 0b 01     lds r21, 0x010B&#xA;    SREG = oldSREG;&#xA; 162:   8f bf           out 0x3f, r24   ; 63&#xA;&#xA;    return m;&#xA;}&#xA; 164:   b9 01           movw    r22, r18&#xA; 166:   ca 01           movw    r24, r20&#xA; 168:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the &lt;code&gt;millis()&lt;/code&gt; function is fairly simple:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;in&lt;/code&gt; saves the interrupt register settings (1 cycle)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cli&lt;/code&gt; turns off the interrupts (1 cycle)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lds&lt;/code&gt; copy one of the 4 bytes of the current value of the milli counter into a temporary register (2 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lds&lt;/code&gt; Byte 2 (2 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lds&lt;/code&gt; Byte 3 (2 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lds&lt;/code&gt; Byte 4 (2 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;out&lt;/code&gt; restore interrupt settings (1 clock cycle)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;movw&lt;/code&gt; shuffle registers around (1 clock cycle)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;movw&lt;/code&gt; and again (1 clock cycle)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ret&lt;/code&gt; return from subroutine  (4 cycles)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, if we add them all up, we have a total of 17 clock cycles in the &lt;code&gt;millis()&lt;/code&gt; function itself, plus a call overhead of 12, for a total of 29 clock cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming a 16 Mhz clock rate (most arduinos), each clock cycle is &lt;code&gt;1 / 16e6&lt;/code&gt; seconds, or 0.0000000625 seconds, which is 62.5 nanoseconds. 62.5 ns * 29 = 1.812 microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the total execution time for a single &lt;code&gt;millis()&lt;/code&gt; call on &lt;em&gt;most&lt;/em&gt; Arduinos will be &lt;strong&gt;1.812 microseconds&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/doc0856.pdf&quot; rel=&quot;noreferrer&quot;&gt;AVR Assembly reference&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;As a side-note, there is space for optimization here! If you update the &lt;code&gt;unsigned long millis(){}&lt;/code&gt; function definition to be &lt;code&gt;inline unsigned long millis(){}&lt;/code&gt;, you would remove the call overhead (at the cost of &lt;em&gt;slightly&lt;/em&gt; larger code size). Furthermore, it looks like the compiler is doing two unnecessary moves (the two &lt;code&gt;movw&lt;/code&gt; calls, but I haven't looked at it that closely).&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Really, considering the function call overhead is 5 instructions, and the actual &lt;em&gt;contents&lt;/em&gt; of the &lt;code&gt;millis()&lt;/code&gt; function is only 6 instructions, I think the &lt;code&gt;millis()&lt;/code&gt; function should really be &lt;code&gt;inline&lt;/code&gt; by default, but the Arduino codebase is rather poorly optimized.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is the full disassemby for anyone interested:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_feb13a.cpp.elf:     file format elf32-avr&#xA;&#xA;&#xA;Disassembly of section .text:&#xA;&#xA;00000000 &amp;lt;__vectors&amp;gt;:&#xA;    SREG = oldSREG;&#xA;&#xA;    return m;&#xA;}&#xA;&#xA;unsigned long micros() {&#xA;   0:   0c 94 34 00     jmp 0x68    ; 0x68 &amp;lt;__ctors_end&amp;gt;&#xA;   4:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;   8:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;   c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  10:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  14:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  18:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  1c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  20:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  24:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  28:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  2c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  30:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  34:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  38:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  3c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  40:   0c 94 5f 00     jmp 0xbe    ; 0xbe &amp;lt;__vector_16&amp;gt;&#xA;  44:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  48:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  4c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  50:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  54:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  58:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  5c:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  60:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;  64:   0c 94 51 00     jmp 0xa2    ; 0xa2 &amp;lt;__bad_interrupt&amp;gt;&#xA;&#xA;00000068 &amp;lt;__ctors_end&amp;gt;:&#xA;  68:   11 24           eor r1, r1&#xA;  6a:   1f be           out 0x3f, r1    ; 63&#xA;  6c:   cf ef           ldi r28, 0xFF   ; 255&#xA;  6e:   d8 e0           ldi r29, 0x08   ; 8&#xA;  70:   de bf           out 0x3e, r29   ; 62&#xA;  72:   cd bf           out 0x3d, r28   ; 61&#xA;&#xA;00000074 &amp;lt;__do_copy_data&amp;gt;:&#xA;  74:   11 e0           ldi r17, 0x01   ; 1&#xA;  76:   a0 e0           ldi r26, 0x00   ; 0&#xA;  78:   b1 e0           ldi r27, 0x01   ; 1&#xA;  7a:   e2 e0           ldi r30, 0x02   ; 2&#xA;  7c:   f2 e0           ldi r31, 0x02   ; 2&#xA;  7e:   02 c0           rjmp    .+4         ; 0x84 &amp;lt;.do_copy_data_start&amp;gt;&#xA;&#xA;00000080 &amp;lt;.do_copy_data_loop&amp;gt;:&#xA;  80:   05 90           lpm r0, Z+&#xA;  82:   0d 92           st  X+, r0&#xA;&#xA;00000084 &amp;lt;.do_copy_data_start&amp;gt;:&#xA;  84:   a0 30           cpi r26, 0x00   ; 0&#xA;  86:   b1 07           cpc r27, r17&#xA;  88:   d9 f7           brne    .-10        ; 0x80 &amp;lt;.do_copy_data_loop&amp;gt;&#xA;&#xA;0000008a &amp;lt;__do_clear_bss&amp;gt;:&#xA;  8a:   11 e0           ldi r17, 0x01   ; 1&#xA;  8c:   a0 e0           ldi r26, 0x00   ; 0&#xA;  8e:   b1 e0           ldi r27, 0x01   ; 1&#xA;  90:   01 c0           rjmp    .+2         ; 0x94 &amp;lt;.do_clear_bss_start&amp;gt;&#xA;&#xA;00000092 &amp;lt;.do_clear_bss_loop&amp;gt;:&#xA;  92:   1d 92           st  X+, r1&#xA;&#xA;00000094 &amp;lt;.do_clear_bss_start&amp;gt;:&#xA;  94:   ad 30           cpi r26, 0x0D   ; 13&#xA;  96:   b1 07           cpc r27, r17&#xA;  98:   e1 f7           brne    .-8         ; 0x92 &amp;lt;.do_clear_bss_loop&amp;gt;&#xA;  9a:   0e 94 f0 00     call    0x1e0   ; 0x1e0 &amp;lt;main&amp;gt;&#xA;  9e:   0c 94 ff 00     jmp 0x1fe   ; 0x1fe &amp;lt;_exit&amp;gt;&#xA;&#xA;000000a2 &amp;lt;__bad_interrupt&amp;gt;:&#xA;  a2:   0c 94 00 00     jmp 0   ; 0x0 &amp;lt;__vectors&amp;gt;&#xA;&#xA;000000a6 &amp;lt;setup&amp;gt;:&#xA;  a6:   08 95           ret&#xA;&#xA;000000a8 &amp;lt;loop&amp;gt;:&#xA;  a8:   0e 94 a7 00     call    0x14e   ; 0x14e &amp;lt;millis&amp;gt;&#xA;  ac:   60 93 00 01     sts 0x0100, r22&#xA;  b0:   70 93 01 01     sts 0x0101, r23&#xA;  b4:   80 93 02 01     sts 0x0102, r24&#xA;  b8:   90 93 03 01     sts 0x0103, r25&#xA;  bc:   08 95           ret&#xA;&#xA;000000be &amp;lt;__vector_16&amp;gt;:&#xA;#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)&#xA;ISR(TIM0_OVF_vect)&#xA;#else&#xA;ISR(TIMER0_OVF_vect)&#xA;#endif&#xA;{&#xA;  be:   1f 92           push    r1&#xA;  c0:   0f 92           push    r0&#xA;  c2:   0f b6           in  r0, 0x3f    ; 63&#xA;  c4:   0f 92           push    r0&#xA;  c6:   11 24           eor r1, r1&#xA;  c8:   2f 93           push    r18&#xA;  ca:   3f 93           push    r19&#xA;  cc:   8f 93           push    r24&#xA;  ce:   9f 93           push    r25&#xA;  d0:   af 93           push    r26&#xA;  d2:   bf 93           push    r27&#xA;    // copy these to local variables so they can be stored in registers&#xA;    // (volatile variables must be read from memory on every access)&#xA;    unsigned long m = timer0_millis;&#xA;  d4:   80 91 08 01     lds r24, 0x0108&#xA;  d8:   90 91 09 01     lds r25, 0x0109&#xA;  dc:   a0 91 0a 01     lds r26, 0x010A&#xA;  e0:   b0 91 0b 01     lds r27, 0x010B&#xA;    unsigned char f = timer0_fract;&#xA;  e4:   30 91 0c 01     lds r19, 0x010C&#xA;&#xA;    m += MILLIS_INC;&#xA;  e8:   01 96           adiw    r24, 0x01   ; 1&#xA;  ea:   a1 1d           adc r26, r1&#xA;  ec:   b1 1d           adc r27, r1&#xA;    f += FRACT_INC;&#xA;  ee:   23 2f           mov r18, r19&#xA;  f0:   2d 5f           subi    r18, 0xFD   ; 253&#xA;    if (f &amp;gt;= FRACT_MAX) {&#xA;  f2:   2d 37           cpi r18, 0x7D   ; 125&#xA;  f4:   20 f0           brcs    .+8         ; 0xfe &amp;lt;__vector_16+0x40&amp;gt;&#xA;        f -= FRACT_MAX;&#xA;  f6:   2d 57           subi    r18, 0x7D   ; 125&#xA;        m += 1;&#xA;  f8:   01 96           adiw    r24, 0x01   ; 1&#xA;  fa:   a1 1d           adc r26, r1&#xA;  fc:   b1 1d           adc r27, r1&#xA;    }&#xA;&#xA;    timer0_fract = f;&#xA;  fe:   20 93 0c 01     sts 0x010C, r18&#xA;    timer0_millis = m;&#xA; 102:   80 93 08 01     sts 0x0108, r24&#xA; 106:   90 93 09 01     sts 0x0109, r25&#xA; 10a:   a0 93 0a 01     sts 0x010A, r26&#xA; 10e:   b0 93 0b 01     sts 0x010B, r27&#xA;    timer0_overflow_count++;&#xA; 112:   80 91 04 01     lds r24, 0x0104&#xA; 116:   90 91 05 01     lds r25, 0x0105&#xA; 11a:   a0 91 06 01     lds r26, 0x0106&#xA; 11e:   b0 91 07 01     lds r27, 0x0107&#xA; 122:   01 96           adiw    r24, 0x01   ; 1&#xA; 124:   a1 1d           adc r26, r1&#xA; 126:   b1 1d           adc r27, r1&#xA; 128:   80 93 04 01     sts 0x0104, r24&#xA; 12c:   90 93 05 01     sts 0x0105, r25&#xA; 130:   a0 93 06 01     sts 0x0106, r26&#xA; 134:   b0 93 07 01     sts 0x0107, r27&#xA;}&#xA; 138:   bf 91           pop r27&#xA; 13a:   af 91           pop r26&#xA; 13c:   9f 91           pop r25&#xA; 13e:   8f 91           pop r24&#xA; 140:   3f 91           pop r19&#xA; 142:   2f 91           pop r18&#xA; 144:   0f 90           pop r0&#xA; 146:   0f be           out 0x3f, r0    ; 63&#xA; 148:   0f 90           pop r0&#xA; 14a:   1f 90           pop r1&#xA; 14c:   18 95           reti&#xA;&#xA;0000014e &amp;lt;millis&amp;gt;:&#xA;&#xA;unsigned long millis()&#xA;{&#xA;    unsigned long m;&#xA;    uint8_t oldSREG = SREG;&#xA; 14e:   8f b7           in  r24, 0x3f   ; 63&#xA;&#xA;    // disable interrupts while we read timer0_millis or we might get an&#xA;    // inconsistent value (e.g. in the middle of a write to timer0_millis)&#xA;    cli();&#xA; 150:   f8 94           cli&#xA;    m = timer0_millis;&#xA; 152:   20 91 08 01     lds r18, 0x0108&#xA; 156:   30 91 09 01     lds r19, 0x0109&#xA; 15a:   40 91 0a 01     lds r20, 0x010A&#xA; 15e:   50 91 0b 01     lds r21, 0x010B&#xA;    SREG = oldSREG;&#xA; 162:   8f bf           out 0x3f, r24   ; 63&#xA;&#xA;    return m;&#xA;}&#xA; 164:   b9 01           movw    r22, r18&#xA; 166:   ca 01           movw    r24, r20&#xA; 168:   08 95           ret&#xA;&#xA;0000016a &amp;lt;init&amp;gt;:&#xA;&#xA;void init()&#xA;{&#xA;    // this needs to be called before setup() or some functions won't&#xA;    // work there&#xA;    sei();&#xA; 16a:   78 94           sei&#xA;&#xA;    // on the ATmega168, timer 0 is also used for fast hardware pwm&#xA;    // (using phase-correct PWM would mean that timer 0 overflowed half as often&#xA;    // resulting in different millis() behavior on the ATmega8 and ATmega168)&#xA;#if defined(TCCR0A) &amp;amp;&amp;amp; defined(WGM01)&#xA;    sbi(TCCR0A, WGM01);&#xA; 16c:   84 b5           in  r24, 0x24   ; 36&#xA; 16e:   82 60           ori r24, 0x02   ; 2&#xA; 170:   84 bd           out 0x24, r24   ; 36&#xA;    sbi(TCCR0A, WGM00);&#xA; 172:   84 b5           in  r24, 0x24   ; 36&#xA; 174:   81 60           ori r24, 0x01   ; 1&#xA; 176:   84 bd           out 0x24, r24   ; 36&#xA;    // this combination is for the standard atmega8&#xA;    sbi(TCCR0, CS01);&#xA;    sbi(TCCR0, CS00);&#xA;#elif defined(TCCR0B) &amp;amp;&amp;amp; defined(CS01) &amp;amp;&amp;amp; defined(CS00)&#xA;    // this combination is for the standard 168/328/1280/2560&#xA;    sbi(TCCR0B, CS01);&#xA; 178:   85 b5           in  r24, 0x25   ; 37&#xA; 17a:   82 60           ori r24, 0x02   ; 2&#xA; 17c:   85 bd           out 0x25, r24   ; 37&#xA;    sbi(TCCR0B, CS00);&#xA; 17e:   85 b5           in  r24, 0x25   ; 37&#xA; 180:   81 60           ori r24, 0x01   ; 1&#xA; 182:   85 bd           out 0x25, r24   ; 37&#xA;&#xA;    // enable timer 0 overflow interrupt&#xA;#if defined(TIMSK) &amp;amp;&amp;amp; defined(TOIE0)&#xA;    sbi(TIMSK, TOIE0);&#xA;#elif defined(TIMSK0) &amp;amp;&amp;amp; defined(TOIE0)&#xA;    sbi(TIMSK0, TOIE0);&#xA; 184:   ee e6           ldi r30, 0x6E   ; 110&#xA; 186:   f0 e0           ldi r31, 0x00   ; 0&#xA; 188:   80 81           ld  r24, Z&#xA; 18a:   81 60           ori r24, 0x01   ; 1&#xA; 18c:   80 83           st  Z, r24&#xA;    // this is better for motors as it ensures an even waveform&#xA;    // note, however, that fast pwm mode can achieve a frequency of up&#xA;    // 8 MHz (with a 16 MHz clock) at 50% duty cycle&#xA;&#xA;#if defined(TCCR1B) &amp;amp;&amp;amp; defined(CS11) &amp;amp;&amp;amp; defined(CS10)&#xA;    TCCR1B = 0;&#xA; 18e:   e1 e8           ldi r30, 0x81   ; 129&#xA; 190:   f0 e0           ldi r31, 0x00   ; 0&#xA; 192:   10 82           st  Z, r1&#xA;&#xA;    // set timer 1 prescale factor to 64&#xA;    sbi(TCCR1B, CS11);&#xA; 194:   80 81           ld  r24, Z&#xA; 196:   82 60           ori r24, 0x02   ; 2&#xA; 198:   80 83           st  Z, r24&#xA;#if F_CPU &amp;gt;= 8000000L&#xA;    sbi(TCCR1B, CS10);&#xA; 19a:   80 81           ld  r24, Z&#xA; 19c:   81 60           ori r24, 0x01   ; 1&#xA; 19e:   80 83           st  Z, r24&#xA;    sbi(TCCR1, CS10);&#xA;#endif&#xA;#endif&#xA;    // put timer 1 in 8-bit phase correct pwm mode&#xA;#if defined(TCCR1A) &amp;amp;&amp;amp; defined(WGM10)&#xA;    sbi(TCCR1A, WGM10);&#xA; 1a0:   e0 e8           ldi r30, 0x80   ; 128&#xA; 1a2:   f0 e0           ldi r31, 0x00   ; 0&#xA; 1a4:   80 81           ld  r24, Z&#xA; 1a6:   81 60           ori r24, 0x01   ; 1&#xA; 1a8:   80 83           st  Z, r24&#xA;&#xA;    // set timer 2 prescale factor to 64&#xA;#if defined(TCCR2) &amp;amp;&amp;amp; defined(CS22)&#xA;    sbi(TCCR2, CS22);&#xA;#elif defined(TCCR2B) &amp;amp;&amp;amp; defined(CS22)&#xA;    sbi(TCCR2B, CS22);&#xA; 1aa:   e1 eb           ldi r30, 0xB1   ; 177&#xA; 1ac:   f0 e0           ldi r31, 0x00   ; 0&#xA; 1ae:   80 81           ld  r24, Z&#xA; 1b0:   84 60           ori r24, 0x04   ; 4&#xA; 1b2:   80 83           st  Z, r24&#xA;&#xA;    // configure timer 2 for phase correct pwm (8-bit)&#xA;#if defined(TCCR2) &amp;amp;&amp;amp; defined(WGM20)&#xA;    sbi(TCCR2, WGM20);&#xA;#elif defined(TCCR2A) &amp;amp;&amp;amp; defined(WGM20)&#xA;    sbi(TCCR2A, WGM20);&#xA; 1b4:   e0 eb           ldi r30, 0xB0   ; 176&#xA; 1b6:   f0 e0           ldi r31, 0x00   ; 0&#xA; 1b8:   80 81           ld  r24, Z&#xA; 1ba:   81 60           ori r24, 0x01   ; 1&#xA; 1bc:   80 83           st  Z, r24&#xA;#if defined(ADCSRA)&#xA;    // set a2d prescale factor to 128&#xA;    // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.&#xA;    // XXX: this will not work properly for other clock speeds, and&#xA;    // this code should use F_CPU to determine the prescale factor.&#xA;    sbi(ADCSRA, ADPS2);&#xA; 1be:   ea e7           ldi r30, 0x7A   ; 122&#xA; 1c0:   f0 e0           ldi r31, 0x00   ; 0&#xA; 1c2:   80 81           ld  r24, Z&#xA; 1c4:   84 60           ori r24, 0x04   ; 4&#xA; 1c6:   80 83           st  Z, r24&#xA;    sbi(ADCSRA, ADPS1);&#xA; 1c8:   80 81           ld  r24, Z&#xA; 1ca:   82 60           ori r24, 0x02   ; 2&#xA; 1cc:   80 83           st  Z, r24&#xA;    sbi(ADCSRA, ADPS0);&#xA; 1ce:   80 81           ld  r24, Z&#xA; 1d0:   81 60           ori r24, 0x01   ; 1&#xA; 1d2:   80 83           st  Z, r24&#xA;&#xA;    // enable a2d conversions&#xA;    sbi(ADCSRA, ADEN);&#xA; 1d4:   80 81           ld  r24, Z&#xA; 1d6:   80 68           ori r24, 0x80   ; 128&#xA; 1d8:   80 83           st  Z, r24&#xA;    // here so they can be used as normal digital i/o; they will be&#xA;    // reconnected in Serial.begin()&#xA;#if defined(UCSRB)&#xA;    UCSRB = 0;&#xA;#elif defined(UCSR0B)&#xA;    UCSR0B = 0;&#xA; 1da:   10 92 c1 00     sts 0x00C1, r1&#xA;#endif&#xA;}&#xA; 1de:   08 95           ret&#xA;&#xA;000001e0 &amp;lt;main&amp;gt;:&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main(void)&#xA; 1e0:   cf 93           push    r28&#xA; 1e2:   df 93           push    r29&#xA;{&#xA;    init();&#xA; 1e4:   0e 94 b5 00     call    0x16a   ; 0x16a &amp;lt;init&amp;gt;&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA; 1e8:   0e 94 53 00     call    0xa6    ; 0xa6 &amp;lt;setup&amp;gt;&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA; 1ec:   c0 e0           ldi r28, 0x00   ; 0&#xA; 1ee:   d0 e0           ldi r29, 0x00   ; 0&#xA;#endif&#xA;&#xA;    setup();&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA; 1f0:   0e 94 54 00     call    0xa8    ; 0xa8 &amp;lt;loop&amp;gt;&#xA;        if (serialEventRun) serialEventRun();&#xA; 1f4:   20 97           sbiw    r28, 0x00   ; 0&#xA; 1f6:   e1 f3           breq    .-8         ; 0x1f0 &amp;lt;main+0x10&amp;gt;&#xA; 1f8:   0e 94 00 00     call    0   ; 0x0 &amp;lt;__vectors&amp;gt;&#xA; 1fc:   f9 cf           rjmp    .-14        ; 0x1f0 &amp;lt;main+0x10&amp;gt;&#xA;&#xA;000001fe &amp;lt;_exit&amp;gt;:&#xA; 1fe:   f8 94           cli&#xA;&#xA;00000200 &amp;lt;__stop_program&amp;gt;:&#xA; 200:   ff cf           rjmp    .-2         ; 0x200 &amp;lt;__stop_program&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="86" LastEditorUserId="10794" LastEditDate="2016-04-11T22:08:37.307" LastActivityDate="2016-04-11T22:08:37.307" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="163" PostTypeId="2" ParentId="142" CreationDate="2014-02-13T12:43:07.087" Score="14" Body="&lt;p&gt;I'm kind of confused by your question. You ask where you want to put once-per-startup setup functions, and then discuss the setup function. &lt;em&gt;That's what the setup function is for.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, one-time setup functionality goes in the setup function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW, if you look in the file that &lt;em&gt;calls&lt;/em&gt; the &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;loop&lt;/code&gt; functions:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    init();&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For all intents and purposes, the two options are completely identical. Either way, you get a empty busy-wait loop. Frankly, I'd expect the two different options to probably emit the same machine code anyways, so the whole thing is a non-issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;br&gt;&#xA;&lt;code&gt;if (serialEventRun) serialEventRun();&lt;/code&gt; appears to be a facility to allow you to attach a function that is called upon reception of serial data, but if you do not define a function &lt;code&gt;void serialEvent(){}&lt;/code&gt; in your code, it will compile out completely and not be present in the produced machine code.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-02-13T12:48:32.503" LastActivityDate="2014-02-13T12:48:32.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="164" PostTypeId="2" ParentId="96" CreationDate="2014-02-13T14:01:38.190" Score="5" Body="&lt;p&gt;When a circuit is hot, it's very likely that it is drawing too much current. It may be a component that's getting more current than it's designed for, or a PCB track, or a wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, before you do anything else, I strongly suggest that you get a DMM and measure the current drawn by the board when powering the led strip. Google for ways to measure current with a DMM, as it can be tricky if you never done it before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, compare the value to those specified by the voltage regulator datasheet. The current should be within those values shown in the &quot;Electrical Characteristics&quot;, and well below those from &quot;Absolute Maximum Ratings&quot;. &lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-02-13T14:06:47.320" LastActivityDate="2014-02-13T14:06:47.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="165" PostTypeId="2" ParentId="140" CreationDate="2014-02-13T14:02:25.557" Score="3" Body="&lt;p&gt;I don't know a whole lot about MATLAB, but I found some tutorials about reading and writing from the serial port:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s = serial('COM1');&#xA;fopen(s)&#xA;fprintf(s, 'Your serial data goes here')&#xA;out = fscanf(s)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;out&lt;/code&gt; is now your received data, and you can do whatever you want with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fclose(s)&#xA;delete(s)&#xA;clear s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is from &lt;em&gt;&lt;a href=&quot;http://www.mathworks.com/help/matlab/matlab_external/writing-and-reading-data.html&quot; rel=&quot;nofollow&quot;&gt;Writing and Reading Data&lt;/a&gt;&lt;/em&gt; (&lt;em&gt;MATLAB&lt;/em&gt;/ &lt;em&gt;Data and File Management&lt;/em&gt;/ &lt;em&gt;Serial Port Devices&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your question I assume you know about the Arduino side of things (using &lt;code&gt;Serial&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="510" LastEditDate="2014-04-13T16:59:14.473" LastActivityDate="2014-04-13T16:59:14.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="166" PostTypeId="2" ParentId="104" CreationDate="2014-02-13T14:13:04.587" Score="0" Body="&lt;p&gt;Since your question is only about uploading, this will work with a Yun&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;compile your sketches with the IDE on your pc&lt;/li&gt;&#xA;&lt;li&gt;for each hex file, copy it to the yun and run &lt;code&gt;merge-sketch-with-bootloader.lua PATH_TO_HEX_FILE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;manage to connect to the Yun from your tablet via SSH&lt;/li&gt;&#xA;&lt;li&gt;once logged in, run &lt;code&gt;run-avrdude PATH_TO_HEX_FILE&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-02-13T14:13:04.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="167" PostTypeId="2" ParentId="105" CreationDate="2014-02-13T14:48:24.573" Score="9" Body="&lt;p&gt;There is a project which brings a &lt;a href=&quot;https://code.google.com/p/python-on-a-chip/&quot;&gt;Python virtual machine&lt;/a&gt; to micro-controllers, including the &lt;a href=&quot;https://code.google.com/p/python-on-a-chip/source/browse/#hg%2Fsrc%2Fplatform%2Farduino_mega&quot;&gt;Arduino Mega&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a quote from the Ardunio Mega &lt;a href=&quot;https://code.google.com/p/python-on-a-chip/source/browse/src/platform/arduino_mega/README&quot;&gt;README&lt;/a&gt;, which gives a feel for what this could be like (though, I've not tested this!): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The following is an example session using ipm::&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ipm&amp;gt; import avr, sys&#xA;ipm&amp;gt; avr.ddrA(0xff)&#xA;ipm&amp;gt; avr.portA(0)       # Pins 22-29 all at 0 V&#xA;ipm&amp;gt; avr.portA(0xa5)&#xA;ipm&amp;gt; sys.heap()&#xA;(2622, 7424)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13" LastActivityDate="2014-02-13T14:48:24.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="168" PostTypeId="1" AcceptedAnswerId="170" CreationDate="2014-02-13T15:03:20.657" Score="22" ViewCount="18370" Body="&lt;p&gt;I wanted to move some of my code out into a second tab in the Arduino IDE, to keep things better organised. At first, I only tried moving a function, and it seemed to work fine. I could call the function from the &lt;code&gt;setup()&lt;/code&gt; function in my main tab, and there were no problems compiling or uploading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I tried putting a whole class into the second tab, and suddenly it didn't work any more. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Tab 1:&lt;/strong&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TestClass obj;&#xA;&#xA;void setup()&#xA;{&#xA;    obj.init();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    //...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Tab 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TestClass&#xA;{&#xA;public:&#xA;    void init()&#xA;    {&#xA;        //...&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I tried to compile this, it gave me the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tab1:1: error: 'TestClass' does not name a type&#xA;tab1.ino: In function 'void setup()':&#xA;tab1:5: error: 'obj' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does it recognise a function in another tab, but not a class? Is there a way to make it work in the Arduino IDE, or do I need to use an alternative like Eclipse?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="65" LastEditDate="2014-03-09T12:56:54.733" LastActivityDate="2014-03-09T12:56:54.733" Title="Why can't I declare a class in another tab in Arduino IDE?" Tags="|programming|arduino-ide|compile|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="169" PostTypeId="1" AcceptedAnswerId="172" CreationDate="2014-02-13T15:25:07.000" Score="8" ViewCount="3466" Body="&lt;p&gt;At least for prototyping, is there a semi-permanent way to attach wires to the Nano posts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0n9s9.jpg&quot; alt=&quot;Arduino nano&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, usually the Nano is hanging in free space by its wires (yes I know, quick and dirty, should be using something cleaner, even for prototypes).  So I'm hoping for the best of both worlds, sturdy &quot;enough&quot; to stay attached, yet possible to remove and switch around.  Having no luck finding such advice on the internet, perhaps searching for the wrong terms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;  I neglected one important point, each wire is attached individually just like the SparkFun wires with the female header as mentioned in @TheDoctor's answer below.  &lt;/p&gt;&#xA;" OwnerUserId="118" LastEditorUserId="368" LastEditDate="2014-05-22T23:41:54.727" LastActivityDate="2016-03-11T08:58:44.787" Title="Is there a semi-permanent way to attach wires to the Nano?" Tags="|arduino-nano|prototype|wires|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="170" PostTypeId="2" ParentId="168" CreationDate="2014-02-13T16:21:09.890" Score="17" Body="&lt;p&gt;It is not possible to declare and use classes declared in one &lt;code&gt;.pde&lt;/code&gt; file in another &lt;code&gt;.pde&lt;/code&gt; file from within the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One workaround is to make the second file into a C++ source file (&lt;code&gt;.cpp&lt;/code&gt;) and then add a &lt;code&gt;#include &quot;&amp;lt;filename&amp;gt;&quot;&lt;/code&gt; directive in the beginning of the first file.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This code compiles correctly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tab 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;test.cpp&quot;&#xA;&#xA;TestClass obj;&#xA;&#xA;void setup()&#xA;{&#xA;    obj.init();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    //...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;test.cpp :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TestClass&#xA;{&#xA;public:&#xA;    void init()&#xA;    {&#xA;        //...&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-13T16:29:45.463" LastActivityDate="2014-02-13T16:29:45.463" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="171" PostTypeId="2" ParentId="168" CreationDate="2014-02-13T16:21:34.743" Score="6" Body="&lt;p&gt;The way the Arduino IDE works is that it compiles your code (the code you write in the IDE) as the &amp;quot;main&amp;quot; code. Then it pulls code from all of the libraries you have imported and compiles that along with the main code. To do what you are suggesting would require you to create a library for Arduino.&lt;/p&gt;&#xA;&lt;h3&gt;Here is some more information on Arduino libraries:&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/Libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Guide/Libraries&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;And here is some on how to create a library:&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt; //this one is the easiest to understand imo&lt;br /&gt;&#xA;&lt;a href=&quot;http://playground.arduino.cc/Code/Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Code/Library&lt;/a&gt; &lt;br /&gt;&#xA;&lt;a href=&quot;http://www.divilabs.com/2013/03/write-your-own-arduino-library.html#&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.divilabs.com/2013/03/write-your-own-arduino-library.html#&lt;/a&gt; &lt;br /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is an example library I wrote &lt;a href=&quot;https://github.com/jamolnng/Arduino/tree/master/libraries/ShiftRegister&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jamolnng/Arduino/tree/master/libraries/ShiftRegister&lt;/a&gt; as you can see there is no problem with calling Arduino functions from the .cpp file (I know, I've tested the library)&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-13T16:37:29.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="172" PostTypeId="2" ParentId="169" CreationDate="2014-02-13T16:39:08.530" Score="6" Body="&lt;p&gt;There are jumper wires that have a female header on one end and a male header on the other. Example: &lt;a href=&quot;https://www.sparkfun.com/products/9140&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/9140&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lyllM.png&quot; alt=&quot;jumper wires&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also attatch several wired to a strip of breakaway female headers, such as &lt;a href=&quot;https://www.sparkfun.com/products/115&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/115&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cdMeO.png&quot; alt=&quot;headers&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-14T22:24:08.177" LastActivityDate="2014-02-14T22:24:08.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="173" PostTypeId="2" ParentId="143" CreationDate="2014-02-13T17:05:49.667" Score="4" Body="&lt;p&gt;One of the most common bad things I have seen is connecting LEDs directly to addition pins without a current limiting resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, in electronics there are a few main sources of problems. Too much current, too much voltage, overheating, and physical damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Too much current usually comes from shorting things, too much voltage(or reversed polarity) usually comes from not paying attention to what is being connected, overheating comes from too much current or not using a heatsink when you should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, just think before you connect things and you'll be fine. Learn some basic circuit theory if you haven't already, get in the habit of knowing the ratings of the parts you want to use, and double check stuff before turning it on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like this list here of things not to do: &lt;a href=&quot;http://ruggedcircuits.com/html/ancp01.html&quot; rel=&quot;nofollow&quot;&gt;http://ruggedcircuits.com/html/ancp01.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-02-13T17:05:49.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="174" PostTypeId="2" ParentId="36" CreationDate="2014-02-13T19:15:23.713" Score="4" Body="&lt;p&gt;There is the &lt;a href=&quot;https://github.com/interactive-matter/aJson&quot; rel=&quot;nofollow&quot;&gt;aJson&lt;/a&gt; library that allows you to work with JSON objects in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, depending on the complexity of your program, I would just do it manually to save memory. You may be able to just copy the functions you want out of the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then check out the &lt;a href=&quot;http://playground.arduino.cc/Code/WebClient&quot; rel=&quot;nofollow&quot;&gt;WebClient&lt;/a&gt; library which has an example for making a POST request at the bottom.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-13T19:15:23.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="175" PostTypeId="2" ParentId="56" CreationDate="2014-02-13T19:16:04.687" Score="10" Body="&lt;p&gt;You can easily simulate your Arduino code using the famous Proteus ISIS.&lt;br&gt;&#xA;You just will have to search for the specific Arduino simulation library for Proteus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Here you a small &lt;strong&gt;tutorial&lt;/strong&gt; of how to make this thing done:&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;, identify the path the Arduino IDE generates the hex file to?&lt;br&gt;&#xA;for example if you are using the official IDE you will find the hex file location in the &quot;arduino IDE path/lib/preferences.txt&quot;&lt;br&gt;&#xA;Or if you are using Arduino ERW which I recommended the most on windows! So you can simply open the output folder by &quot;Sketch &gt; Copy HEX file as path&quot;.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;, download the Arduino library from &lt;a href=&quot;https://www.mediafire.com/?q2g7la3dfftfk2r&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt;. Then copy &lt;code&gt;ARDUINO.LIB&lt;/code&gt; and &lt;code&gt;ARDUINO.IDX&lt;/code&gt; to folder &quot;library&quot; in the install directory Proteus.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Third&lt;/strong&gt;, open ISIS and you should be able to find the component.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please find this image of the worksheet after finishing the above steps, and simulation works just fine!&#xA;&lt;img src=&quot;https://i.stack.imgur.com/moWEA.png&quot; alt=&quot;Simulating Arduino Uno on Proteus ISIS&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as a head start for you, please find this small memo I prepared for the &lt;strong&gt;Arduino Uno Pins Layout&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0-14: I/O&#xA;A0-A5: Analog&#xA;&#xA;We can use analog as digital:&#xA;=============================&#xA;Pinout:&#xA;00: Rx      | Can't be used as I/O if I wrote in the code Serial.begin&#xA;01: TX      |&#xA;02: Interrupt&#xA;03: Interrupt &amp;amp; PWM&#xA;04: &#xA;05: PWM&#xA;06: PWM&#xA;07: &#xA;08:&#xA;09: PWM&#xA;10: PWM &amp;amp; SPI&#xA;11: PWM &amp;amp; SPI&#xA;12: SPI&#xA;13: SPI&#xA;A0: &#xA;A1:&#xA;A2:&#xA;A3:&#xA;A4: TWI&#xA;A5: TWI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="103" LastActivityDate="2014-02-13T19:16:04.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="176" PostTypeId="1" AcceptedAnswerId="201" CreationDate="2014-02-13T19:22:59.960" Score="55" ViewCount="271770" Body="&lt;p&gt;Say I have some variables that I want to print out to the terminal, what's the easiest way to print them in a string?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Var 1:&quot;);Serial.println(var1);&#xA;Serial.print(&quot; Var 2:&quot;);Serial.println(var2);&#xA;Serial.print(&quot; Var 3:&quot;);Serial.println(var3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2024-03-12T00:25:38.797" Title="How do I print multiple variables in a string?" Tags="|serial|string|terminal|" AnswerCount="12" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="177" PostTypeId="2" ParentId="176" CreationDate="2014-02-13T20:41:19.023" Score="5" Body="&lt;p&gt;&#xA;This is probably not better, just different.&#xA;You can use the &lt;strong&gt;String&lt;/strong&gt; object for output. These objects allow concatenation and support automatic typecasting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;String label = &quot;Var&quot;;&#xA;const byte nValues = 3;&#xA;int var[nValues] = {36, 72, 49};&#xA;&#xA;for (int i = 0; i &amp;lt; nValues; i++) {&#xA;    String stuff = label + i + &quot;: &quot;;&#xA;    Serial.println(stuff + var[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-02-13T20:41:19.023" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="178" PostTypeId="2" ParentId="140" CreationDate="2014-02-13T20:45:47.473" Score="5" Body="&lt;p&gt;&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/32374-matlab-support-package-for-arduino-aka-arduinoio-package&quot;&gt;MATLAB Support Package for Arduino (aka ArduinoIO Package)&lt;/a&gt; allows you to do it fairly easily.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sample usage:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;%-- connect to the board &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a = arduino('COM9')&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;%-- specify pin mode &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.pinMode(4,'input');&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.pinMode(13,'output');&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;%-- digital i/o &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.digitalRead(4) % read pin 4&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.digitalWrite(13,0) % write 0 to pin 13&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;%-- analog i/o &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.analogRead(5) % read analog pin 5&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;a.analogWrite(9, 155) % write 155 to analog pin 9&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-13T20:45:47.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="179" PostTypeId="1" AcceptedAnswerId="180" CreationDate="2014-02-13T21:23:36.390" Score="61" ViewCount="217623" Body="&lt;p&gt;I made a sketch, but then I lost it. However, I uploaded it to the Arduino before losing it. Is there any way I can get it back?&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-03-04T12:31:52.697" LastActivityDate="2021-11-26T16:36:13.657" Title="Is there any way to download a sketch from an Arduino?" Tags="|sketch|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="180" PostTypeId="2" ParentId="179" CreationDate="2014-02-13T21:25:48.473" Score="43" Body="&lt;p&gt;It should be possible as long as the security bit isn't set. This question was asked on EE a while back. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/61079/is-it-possible-to-extract-code-from-an-arduino-board&quot;&gt;Is it possible to extract code from an arduino board?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you won't get the Arduino code you wrote back. The code is compiled into assembly and you'll have to convert that back to C yourself.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-04-29T13:56:28.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="181" PostTypeId="2" ParentId="179" CreationDate="2014-02-13T21:34:32.477" Score="6" Body="&lt;p&gt;You can download the hex dump of the file, but there is no easy way to get all the C++ code and comments. If you can understand assembly, you could recreate the program, but that would take a while. There are dissasemblers available for some devices, i don't know about arduino.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-13T21:34:32.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="182" PostTypeId="1" CreationDate="2014-02-13T22:32:43.623" Score="14" ViewCount="5181" Body="&lt;p&gt;I'm planning an Arduino system that consists of several Arduino boards. The maximum distance between the boards is about 50 meters. I want to send basic data between these, like short strings or integers. I know I could send data through ethernet cables but that requires an ethernet shield or the Arduino Ethernet board that doubles the costs. Is there a low budget way I could connect the boards using only the most basic boards (like Uno) and some other components but not a full shield?&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2015-04-29T11:52:23.243" Title="How to connect two Arduino without shields?" Tags="|arduino-uno|networking|system-design|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="183" PostTypeId="2" ParentId="182" CreationDate="2014-02-13T22:42:53.227" Score="7" Body="&lt;p&gt;There are two categories i can think of to classify comminucation features of the Arduino boards:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Between 2 devices:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Serial: Easy to use and only requires 2 data lines.&lt;/li&gt;&#xA;&lt;li&gt;OneWire: Harder to use and slow, but uses only one data line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Between more than 2 devices&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I2C: You can have up to 128 devices on a network, individually addressable, but requires a master device, uses 2 data lines. this is know also as Wire.&lt;/li&gt;&#xA;&lt;li&gt;SPI: difficult to use, but very fast and easy device selection. uses a lot of data lines (3 + num of devices)&lt;/li&gt;&#xA;&lt;li&gt;OneWire: using addressed oneWire is even slower than regular oneWire, still only one data line&lt;/li&gt;&#xA;&lt;li&gt;SoftwareSerial: You can have several devices connected by different Serial lines, but it is slower.&lt;/li&gt;&#xA;&lt;li&gt;CAN: only available on the Due, and addressable&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are other methods available, but these listed only require a minimum of external hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For distance ratings, see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=82937.0&quot;&gt;http://forum.arduino.cc/index.php?topic=82937.0&lt;/a&gt; and &lt;a href=&quot;http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO/serial-distance.html&quot;&gt;http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO/serial-distance.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These data rates are directly controlled in Serial and can be tweaked in many others.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-13T23:09:49.190" LastActivityDate="2014-02-13T23:09:49.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="184" PostTypeId="2" ParentId="182" CreationDate="2014-02-13T22:59:03.273" Score="10" Body="&lt;p&gt;For long distance wired communication, look at &lt;a href=&quot;http://en.wikipedia.org/wiki/RS-485&quot;&gt;RS-485&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Since it uses a differential balanced line over twisted pair (like&#xA;  RS-422), it can span relatively large distances (up to 4,000 feet&#xA;  (1,200 m)). A rule of thumb is that the speed in bit/s multiplied by&#xA;  the length in meters should not exceed 108. Thus a 50 meter cable&#xA;  should not signal faster than 2 Mbit/s&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use the MAX485 chip. It's pretty easy to work with but there's a good library as well:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Protoneer/RS485-Arduino-Library&quot;&gt;https://github.com/Protoneer/RS485-Arduino-Library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-13T22:59:03.273" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="185" PostTypeId="2" ParentId="182" CreationDate="2014-02-13T23:01:48.250" Score="5" Body="&lt;p&gt;Freakduino makes some Arduino boards with built in wireless. Their long range wireless is 900 MHz and their shorter range is 2.4GHz. I think they are actually XBee radios and for programming you would use a library called chibiArduino, which is available (and documented) on the Freakduino website. When communicating wirelessly with another radio you can use Broadcast or specify a radio by it's ID which is a value you need to set in the EEPROM of the Freakduino.&lt;/p&gt;&#xA;&lt;p&gt;Taken directly from the Freakduino site:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The addition of an integrated wireless radio based on the IEEE 802.15.4 protocol (same radio protocol as the XBee) allows for wireless control of devices or wireless sensor data collection. Optional battery circuitry was added so that it could function as a true wireless node without any external power cables. The board is also designed to fit a ruggedized enclosure so that the design can be transported safely or deployed in an actual usage scenario without worrying about damaging the circuitry.&lt;/p&gt;&#xA;&lt;p&gt;This 900 MHz radio is a personal favorite of mine. I use it all the time because 900 MHz offers much better range compared to 2.4 GHz. The radio can output up to 10 mW of transmit power which can get a surprising amount of range. With direct line of sight, a few hundred meters would not be surprising. If additional range is needed, the modulation mode can also be changed from OQPSK to BPSK. This results in additional range at the expense of data rate, with the max going from 250 kbps to 40 kbps in standard mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="69" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-13T23:12:28.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="186" PostTypeId="1" CreationDate="2014-02-14T01:01:04.640" Score="15" ViewCount="8501" Body="&lt;p&gt;I have a push button wired to my Arduino but it seems to be triggering randomly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have one pin of the button connected to pin 2 on the arduino and the other connected to ground.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;    pinMode(2, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(digitalRead(2));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect it to print 1 continuously and go to 0 when I press the button down but sometimes it shows 0 even when I don't touch it.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2023-12-29T17:30:14.987" Title="Button state changing randomly" Tags="|button|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="187" PostTypeId="2" ParentId="186" CreationDate="2014-02-14T01:01:04.640" Score="19" Body="&lt;p&gt;When a button is connected in that configuration, the input is what's called &lt;em&gt;floating&lt;/em&gt;, meaning it's not a 0 or a 1. When the button is pressed, it is connected to ground, so that's definitely a 0, but when it's not pressed down, we don't know the value of the pin.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Pull Up Resistor&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We need to include what's called a &quot;pull-up&quot; resistor to pull the signal up to a logic 1 when the button is not pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/h9oX1.jpg&quot; alt=&quot;pull up resistor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/pull-up-resistors/what-is-a-pull-up-resistor&quot; rel=&quot;noreferrer&quot;&gt;Image from Sparkfun&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What this means is when the button is not pressed, the Arduino reads a logic 1. When the button is pressed, the current flows through the resistor to ground and the Arduino reads a logic 0.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Internal Pull Up Resistor&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Arduino also has internal pull up resistors so you don't necessarily have to add an extra component to your circuit. There are a couple of ways to use this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You used to have to do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT);           // set pin to input&#xA;digitalWrite(pin, HIGH);       // turn on pullup resistors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we can do it simply in one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This enables the 20k pull up resistor on that pin. The input will no longer be floating when the button is not pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This only works when the other end is connected to ground.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-14T01:01:04.640" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="188" PostTypeId="1" AcceptedAnswerId="200" CreationDate="2014-02-14T01:28:32.887" Score="18" ViewCount="26575" Body="&lt;p&gt;In either of &lt;code&gt;setup&lt;/code&gt; or &lt;code&gt;loop&lt;/code&gt;, if I were to add an &lt;code&gt;exit(0)&lt;/code&gt; call, where would control be passed to? What would the next state of the microcontroller be? Would it stop execution and power down?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a revision 2 Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="220" LastEditDate="2014-02-25T06:34:23.437" LastActivityDate="2016-06-30T12:15:32.943" Title="What happens when I call exit() from my program?" Tags="|programming|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="189" PostTypeId="1" AcceptedAnswerId="215" CreationDate="2014-02-14T01:33:03.127" Score="17" ViewCount="14122" Body="&lt;p&gt;What happens if there is a runtime error in a program? Will execution of the program just stop? Is there some way I can get the Arduino to tell me what the error is?&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2020-05-30T19:02:27.637" LastActivityDate="2024-02-16T08:24:12.577" Title="What happens if there is a runtime error?" Tags="|sketch|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="190" PostTypeId="2" ParentId="188" CreationDate="2014-02-14T01:42:56.427" Score="11" Body="&lt;p&gt;Well I just tested it with my Arduino Uno and it just completely stopped the code and left all the outputs as they were when the code stopped running (so it left an LED I had on on). There seems to not be a IO cleanup when you call exit. This was what I expected because the Arduino IDE provides the setup and loop functions, if you program the ATMEGA*28 with with any other AVR IDE you start with the main function like all C/C++ programs. The setup and loop functions are not standard on AVR MCU's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The press of the reset button restarts the code, if you were wondering.&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="10" LastEditDate="2014-02-14T01:48:26.633" LastActivityDate="2014-02-14T01:48:26.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="191" PostTypeId="2" ParentId="189" CreationDate="2014-02-14T01:47:13.680" Score="5" Body="&lt;p&gt;You'd need a hardware debugger for something like this. But usually you'll see the program not behaving as you expect it to and will have to look at that section of the code to identify the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common/quick/easy way to do this is to add print statements to print out the values of variables or just anything so you know the program gets to that point in the code without a problem. This will help you isolate the problem further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe &lt;a href=&quot;http://www.visualmicro.com/&quot;&gt;VisualMicro&lt;/a&gt; has some debugging functionality built in.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-14T01:47:13.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="192" PostTypeId="2" ParentId="189" CreationDate="2014-02-14T01:50:31.773" Score="3" Body="&lt;p&gt;I would assume the AVR CPU doesn't have any error detection or recovery tools. It may just stop, or keep going ignoring the error and the consequences. Like sachleen said, you should add some debug statements in your program that print out data in the middle of an operation, to test if it's working. If you use an emulaor and set breakpoints, you could easily find a problem.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-14T01:50:31.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="193" PostTypeId="1" CreationDate="2014-02-14T01:59:18.783" Score="10" ViewCount="8531" Body="&lt;p&gt;I want to make a sketch that is as small as possible, for test purposes. The problem is, when i compile the BareMinimum sketch (with an empty setup and loop), i get 466 bytes for the Uno and a whopping 4,242 for the Leonardo. Is there any way to write your own code that has no extra functions (namely Timer0 for &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;). I would also like to be able to disable the keyboard/mouse functions for the Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="220" LastEditDate="2014-03-18T23:35:56.863" LastActivityDate="2015-06-15T14:00:52.420" Title="How to really shrink a sketch" Tags="|programming|sketch|arduino-leonardo|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="194" PostTypeId="5" CreationDate="2014-02-14T02:24:35.130" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-14T02:24:35.130" LastActivityDate="2014-02-14T02:24:35.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="195" PostTypeId="4" CreationDate="2014-02-14T02:24:35.130" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-14T02:24:35.130" LastActivityDate="2014-02-14T02:24:35.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="196" PostTypeId="1" CreationDate="2014-02-14T03:01:47.440" Score="0" ViewCount="6554" Body="&lt;p&gt;There are several different types in the Arduino programming language. They each have different applications that can use up the limited RAM in the Arduino. When should i use each?&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-14T14:21:28.193" LastActivityDate="2014-02-14T14:21:28.193" Title="When to use different variable types?" Tags="|programming|variables|" AnswerCount="2" CommentCount="9" ClosedDate="2014-02-14T12:30:47.000" ContentLicense="CC BY-SA 3.0" />
  <row Id="197" PostTypeId="2" ParentId="196" CreationDate="2014-02-14T03:01:47.440" Score="3" Body="&lt;p&gt;An overview of the most commonly used variables:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;byte&lt;/strong&gt;: uses one byte (8 bits), holds numbers from 0 to 255&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;char&lt;/strong&gt;: a signed byte&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;boolean&lt;/strong&gt;: uses 1 byte, but only holds a value of &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;int&lt;/strong&gt;: uses 2 bytes, holds numbers from -32768 to 32767, mostly used in general programming. an &lt;code&gt;int&lt;/code&gt; is what is known as a signed variable, where the last bit controls if it is negative or positive&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;long&lt;/strong&gt;: uses 4 bytes, holds numbers from -2147483647 to 217283648, it is also signed&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;long long&lt;/strong&gt;: uses 8 bytes, can hold -9223372036854775808 to 9223372036854775807, signed&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;float&lt;/strong&gt;: uses 4 bytes, holds decimals from -3.4028235E+38 to 3.4028235E+38.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;double&lt;/strong&gt;: almost identical to &lt;code&gt;float&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;string&lt;/strong&gt;: an array of chars that represent text&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;String&lt;/strong&gt;: not to be confused with &lt;code&gt;string&lt;/code&gt;, this is a class that holds text data with extra &lt;a href=&quot;http://arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;functions&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most variable declarations can be prefixed with &lt;code&gt;signed&lt;/code&gt; or &lt;code&gt;unsigned&lt;/code&gt; to change the function of the sigh bit. For example, &lt;code&gt;unsigned int x = 0;&lt;/code&gt; would create a variable that holds numbers from 0 to 65535 because the sign bit is used as an extra data bit.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-14T03:01:47.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="198" PostTypeId="2" ParentId="193" CreationDate="2014-02-14T03:27:43.943" Score="3" Body="&lt;p&gt;You should be able to create your own board definition with a custom boards.txt file as per &lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&lt;/a&gt;. As I see there are several usb features in the leonardo's definition. I would hope that the compiles inclusion of the 4K is based off of these flags and not the processor type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the boards.txt would use the upload, bootloader sections from the Leonardo and the build from the uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is all assuming the core library build does not use processor specific flags to include USB functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If you get such working. post back, I am sure others would be interested in such.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I recently ran into this 4K used limitation on a library demo that actually maxed out the UNO and had to put in a&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if !defined(__AVR_ATmega32U4__)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;around a large chunk of extra features in the sketch to fit on the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had assume (wrong) that this 4K was because I still included Serial.print which when over the USB's CDC on the Leo. But I see after a memory dump of an empty sketch they are still there.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\mflaga\AppData\Local\Temp\build8958339595868119500.tmp&amp;gt;avr-objdump -d sketch_feb13a.cpp.elf &amp;gt; sketch_feb13a.cpp.elf.lst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which makes sense. As the Leonardo still requires the USB-CDC client (the 4K) as to detect the 1200 Baud connect from AVR-DUDE as to stroke the remote reboot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hence making a custom boards.txt without USB in the build, also needs to have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leonardo.upload.use_1200bps_touch=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once loaded on the target, this would require the upload to be synchronized with a manual reset of the target. As the ability to remote reboot is lost.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-02-14T14:51:46.077" LastActivityDate="2014-02-14T14:51:46.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="199" PostTypeId="2" ParentId="196" CreationDate="2014-02-14T03:47:50.560" Score="5" Body="&lt;p&gt;One should appreciate that the Arduino is an Embedded Processor. &lt;em&gt;Specifically that it has limited resources of RAM and ROM(aka Flash/program space).&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often is the case I see coding use the &quot;int&quot; defaultly. Almost sloppily. If that works great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT!!!!&#xA;You can run out of room REAL FAST with only 2K of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend that you size down your type to the minimum of what it needs to be describing it. One also gets a better understanding of what it really is and its limitations. There is no need for an array of int(16bits) from bytes that were recieved from the SPI, UART or I2C. Or a matrix of RGB's that consume 3 bytes each, being int's. You cut your capacity in half.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pro/con: PRO: using default int everywhere makes it more inter changeable. The CON is that such interchangeability can lead to unintentional casting errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also recommend using C99 type def's which can be found at &quot;avr_stdint.html&quot;&gt;http://www.nongnu.org/avr-libc/user-manual/group_&lt;em&gt;avr&lt;/em&gt;_stdint.html&quot; and elsewhere. It makes things vivid, regards to this aspect. Hence a &quot;int&quot; would be a &quot;int16_t&quot;, &quot;unsigned long&quot; be &quot;uint32_t&quot; etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is worth knowing that in some cases a byte or char can not be replaced with int8_t, as such when used with string array functions. But they are still just as vivid.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-14T03:47:50.560" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="200" PostTypeId="2" ParentId="188" CreationDate="2014-02-14T04:00:10.480" Score="12" Body="&lt;p&gt;My initial guess is wrong. I would have thought it would simply return from loop and the core library would just call loop() again. However, I see the following code was created. Noticing that __stop_program is a hard loop...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An extract of Blink.ino's listing, with exit(0) added:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;  exit(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The disassembly of the above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA; 100:   80 91 00 01     lds r24, 0x0100&#xA; 104:   61 e0           ldi r22, 0x01   ; 1&#xA; 106:   0e 94 ca 01     call    0x394   ; 0x394 &amp;lt;digitalWrite&amp;gt;&#xA;  delay(1000);               // wait for a second&#xA; 10a:   68 ee           ldi r22, 0xE8   ; 232&#xA; 10c:   73 e0           ldi r23, 0x03   ; 3&#xA; 10e:   80 e0           ldi r24, 0x00   ; 0&#xA; 110:   90 e0           ldi r25, 0x00   ; 0&#xA; 112:   0e 94 f7 00     call    0x1ee   ; 0x1ee &amp;lt;delay&amp;gt;&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA; 116:   80 91 00 01     lds r24, 0x0100&#xA; 11a:   60 e0           ldi r22, 0x00   ; 0&#xA; 11c:   0e 94 ca 01     call    0x394   ; 0x394 &amp;lt;digitalWrite&amp;gt;&#xA;  delay(1000);               // wait for a second&#xA; 120:   68 ee           ldi r22, 0xE8   ; 232&#xA; 122:   73 e0           ldi r23, 0x03   ; 3&#xA; 124:   80 e0           ldi r24, 0x00   ; 0&#xA; 126:   90 e0           ldi r25, 0x00   ; 0&#xA; 128:   0e 94 f7 00     call    0x1ee   ; 0x1ee &amp;lt;delay&amp;gt;&#xA;  exit(0);&#xA; 12c:   80 e0           ldi r24, 0x00   ; 0&#xA; 12e:   90 e0           ldi r25, 0x00   ; 0&#xA; 130:   0e 94 1e 02     call    0x43c   ; 0x43c &amp;lt;_exit&amp;gt;&#xA;&#xA;...&#xA;&#xA;0000043c &amp;lt;_exit&amp;gt;:&#xA; 43c:   f8 94           cli&#xA;&#xA;0000043e &amp;lt;__stop_program&amp;gt;:&#xA; 43e:   ff cf           rjmp    .-2         ; 0x43e &amp;lt;__stop_program&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that if _exit had not called cli, interrupts would be able to do stuff. But that is not the case.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="86" LastEditDate="2014-02-17T04:26:53.973" LastActivityDate="2014-02-17T04:26:53.973" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="201" PostTypeId="2" ParentId="176" CreationDate="2014-02-14T04:16:45.377" Score="39" Body="&lt;p&gt;&lt;code&gt;ardprintf&lt;/code&gt; is a function that I hacked together which simulates &lt;code&gt;printf&lt;/code&gt; over the serial connection. This function (given at the bottom) can be pasted in the beginning of the files where the function is needed. It should not create any conflicts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be called similar to &lt;code&gt;printf&lt;/code&gt;. See it in action in this example:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int l=2;&#xA;  char *j = &quot;test&quot;;&#xA;  long k = 123456789;&#xA;  char s = 'g';&#xA;  float f = 2.3;&#xA;&#xA;  ardprintf(&quot;test %d %l %c %s %f&quot;, l, k, s, j, f);&#xA;&#xA;  delay(5000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output as expected is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;test 2 123456789 g test 2.30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The function prototype is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int ardprintf(char *, ...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns the number of arguments detected in the function call. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the function definition:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#ifndef ARDPRINTF&#xA;#define ARDPRINTF&#xA;#define ARDBUFFER 16&#xA;#include &amp;lt;stdarg.h&amp;gt;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int ardprintf(char *str, ...)&#xA;{&#xA;  int i, count=0, j=0, flag=0;&#xA;  char temp[ARDBUFFER+1];&#xA;  for(i=0; str[i]!='\0';i++)  if(str[i]=='%')  count++;&#xA;&#xA;  va_list argv;&#xA;  va_start(argv, count);&#xA;  for(i=0,j=0; str[i]!='\0';i++)&#xA;  {&#xA;    if(str[i]=='%')&#xA;    {&#xA;      temp[j] = '\0';&#xA;      Serial.print(temp);&#xA;      j=0;&#xA;      temp[0] = '\0';&#xA;&#xA;      switch(str[++i])&#xA;      {&#xA;        case 'd': Serial.print(va_arg(argv, int));&#xA;                  break;&#xA;        case 'l': Serial.print(va_arg(argv, long));&#xA;                  break;&#xA;        case 'f': Serial.print(va_arg(argv, double));&#xA;                  break;&#xA;        case 'c': Serial.print((char)va_arg(argv, int));&#xA;                  break;&#xA;        case 's': Serial.print(va_arg(argv, char *));&#xA;                  break;&#xA;        default:  ;&#xA;      };&#xA;    }&#xA;    else &#xA;    {&#xA;      temp[j] = str[i];&#xA;      j = (j+1)%ARDBUFFER;&#xA;      if(j==0) &#xA;      {&#xA;        temp[ARDBUFFER] = '\0';&#xA;        Serial.print(temp);&#xA;        temp[0]='\0';&#xA;      }&#xA;    }&#xA;  };&#xA;  Serial.println();&#xA;  return count + 1;&#xA;}&#xA;#undef ARDBUFFER&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;**To print the &lt;code&gt;%&lt;/code&gt; character, use &lt;code&gt;%%&lt;/code&gt;.*&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, available on &lt;a href=&quot;https://gist.github.com/asheeshr/9004783&quot;&gt;Github gists&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-09-30T01:47:15.067" LastActivityDate="2014-09-30T01:47:15.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="202" PostTypeId="2" ParentId="176" CreationDate="2014-02-14T07:19:56.173" Score="4" Body="&lt;p&gt;I usually used Tabs to make things line up better in the Serial. Having things line up like I do allow the arduino to fire as fast as possible while being able to notice certain changes in the variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Var 1:\tVar 2tVar 3:&quot;);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(var1);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(var2);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(var3);&#xA;Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Var 1:&quot;);Serial.println(var1);&#xA;Serial.print(&quot;\tVar 2:&quot;);Serial.println(var2);&#xA;Serial.print(&quot;\tVar 3:&quot;);Serial.println(var3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="62" LastActivityDate="2014-02-14T07:19:56.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="203" PostTypeId="1" AcceptedAnswerId="204" CreationDate="2014-02-14T07:58:54.977" Score="14" ViewCount="17312" Body="&lt;p&gt;So in the fields of robotics sometimes you need multiple boards and or computers linked together to share information or save statistical data. Currently I need to send a few different variables over a serial connection and was wondering what was the best way to go about doing such?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've determined that sending structures would probably be the easier way to send data. Does anyone know of any other way that might be more efficient?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please keep in mind that I will essentially be having to send the data for 4 motors, compressor, different temperatures, random things, and the 3 sections of the arm.&lt;/p&gt;&#xA;" OwnerUserId="62" LastEditorUserId="220" LastEditDate="2014-03-01T13:23:17.863" LastActivityDate="2017-05-24T16:03:57.860" Title="Sending Large Amounts of Serial Data" Tags="|serial|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="204" PostTypeId="2" ParentId="203" CreationDate="2014-02-14T07:58:54.977" Score="9" Body="&lt;p&gt;With my personal thoughts on Structs being the most efficient way to send many different variables I've constructed a library to help make it easier to send structs and variables over serial.  &lt;a href=&quot;http://paste.strictfp.com/39940&quot; rel=&quot;noreferrer&quot;&gt;Source Code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this library it makes sending through serial easily. I've used with with hardware and software serial. Usually this is used in conjunct with xbee's so I can wirelessly send the data to and from the robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When sending data it make it simple as it allows you to either send a variable or a struct (it doesn't care).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is an example of sending a simple char over the serial:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Send the variable charVariable over the serial.&#xA;// To send the variable you need to pass an instance of the Serial to use,&#xA;// a reference to the variable to send, and the size of the variable being sent.&#xA;// If you would like you can specify 2 extra arguments at the end which change the&#xA;// default prefix and suffix character used when attempting to reconstruct the variable&#xA;// on the receiving end. If prefix and suffix character are specified they'll need to &#xA;// match on the receiving end otherwise data won't properly be sent across&#xA;&#xA;char charVariable = 'c'; // Define the variable to be sent over the serial&#xA;StreamSend::sendObject(Serial, &amp;amp;charVariable, sizeof(charVariable));&#xA;&#xA;// Specify a prefix and suffix character&#xA;StreamSend::sendObject(Serial, &amp;amp;charVariable, sizeof(charVariable), 'a', 'z');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example of sending a simple int over the serial:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int intVariable = 13496; // Define the int to be sent over the serial&#xA;StreamSend::sendObject(xbeeSerial, &amp;amp;intVariable, sizeof(intVariable));&#xA;&#xA;// Specify a prefix and suffix character&#xA;StreamSend::sendObject(xbeeSerial, &amp;amp;intVariable, sizeof(intVariable), 'j', 'p');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example of sending a struct over serial:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Define the struct to be sent over the serial&#xA;struct SIMPLE_STRUCT {&#xA;  char charVariable;&#xA;  int intVariable[7];&#xA;  boolean boolVariable;&#xA;};&#xA;SIMPLE_STRUCT simpleStruct;&#xA;simpleStruct.charVariable = 'z'; // Set the charVariable in the struct to z&#xA;&#xA;// Fill the intVariable array in the struct with numbers 0 through 6&#xA;for(int i=0; i&amp;lt;7; i++) {&#xA;  simpleStruct.intVariable[i] = i;&#xA;}&#xA;&#xA;// Send the struct to the object xbeeSerial which is a software serial that was&#xA;// defined. Instead of using xbeeSerial you can use Serial which will imply the&#xA;// hardware serial, and on a Mega you can specify Serial, Serial1, Serial2, Serial3.&#xA;StreamSend::sendObject(xbeeSerial, &amp;amp;simpleStruct, sizeof(simpleStruct));&#xA;&#xA;// Send the same as above with a different prefix and suffix from the default values&#xA;// defined in StreamSend. When specifying when prefix and suffix character to send&#xA;// you need to make sure that on the receiving end they match otherwise the data&#xA;// won't be able to be read on the other end.&#xA;StreamSend::sendObject(xbeeSerial, &amp;amp;simpleStruct, sizeof(simpleStruct), '3', 'u');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiving Examples:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiving a char that was send via Streamsend:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char charVariable; // Define the variable on where the data will be put&#xA;&#xA;// Read the data from the Serial object an save it into charVariable once&#xA;// the data has been received&#xA;byte packetResults = StreamSend::receiveObject(Serial, &amp;amp;charVariable, sizeof(charVariable));&#xA;&#xA;// Reconstruct the char coming from the Serial into charVariable that has a custom&#xA;// suffix of a and a prefix of z&#xA;byte packetResults = StreamSend::receiveObject(Serial, &amp;amp;charVariable, sizeof(charVariable), 'a', 'z');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiving an int that was sent via StreamSend:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int intVariable; // Define the variable on where the data will be put&#xA;&#xA;// Reconstruct the int from xbeeSerial into the variable intVariable&#xA;byte packetResults = StreamSend::receiveObject(xbeeSerial, &amp;amp;intVariable, sizeof(intVariable));&#xA;&#xA;// Reconstruct the data into intVariable that was send with a custom prefix&#xA;// of j and a suffix of p&#xA;byte packetResults = StreamSend::receiveObject(xbeeSerial, &amp;amp;intVariable, sizeof(intVariable), 'j', 'p');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiving a Struct that was sent via StreamSend:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Define the struct that the data will be put&#xA;struct SIMPLE_STRUCT {&#xA;  char charVariable;&#xA;  int intVariable[7];&#xA;  boolean boolVariable;&#xA;};&#xA;SIMPLE_STRUCT simpleStruct; // Create a struct to store the data in&#xA;&#xA;// Reconstruct the data from xbeeSerial into the object simpleStruct&#xA;byte packetResults = StreamSend::receiveObject(xbeeSerial, &amp;amp;simpleStruct, sizeof(simpleStruct));&#xA;&#xA;// Reconstruct the data from xbeeSerial into the object simplestruct that has&#xA;// a prefix of 3 and a suffix of p&#xA;byte packetResults = StreamSend::receiveObject(xbeeSerial, &amp;amp;simpleStruct, sizeof(simpleStruct), '3', 'p');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you read the data using &lt;code&gt;StreamSend::receiveObject()&lt;/code&gt; you need to know if the data was GOOD, Not Found, or BAD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt; = Successful&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not Found&lt;/strong&gt; = No prefix character was found in the specified ostream&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt; = Somehow there was a prefix character found, but the data isn't intact. Usually it means there was no suffix character found or the data wasn't the correct size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing Validity of Data:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Once you call StreamSend::receiveObject() it returns a byte of the status of&#xA;// how things went. If you run that though some of the testing functions it'll&#xA;// let you know how the transaction went&#xA;if(StreamSend::isPacketGood(packetResults)) {&#xA;  //The Packet was Good&#xA;} else {&#xA;  //The Packet was Bad&#xA;}&#xA;&#xA;if(StreamSend::isPacketCorrupt(packetResults)) {&#xA;  //The Packet was Corrupt&#xA;} else {&#xA;  //The Packet wasn't found or it was Good&#xA;}&#xA;&#xA;if(StreamSend::isPacketNotFound(packetResults)) {&#xA;  //The Packet was not found after Max # of Tries&#xA;} else {&#xA;  //The Packet was Found, but can be corrupt&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SteamSend Class:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;#ifndef STREAMSEND_H&#xA;#define STREAMSEND_H&#xA;&#xA;&#xA;#define PACKET_NOT_FOUND 0&#xA;#define BAD_PACKET 1&#xA;#define GOOD_PACKET 2&#xA;&#xA;// Set the Max size of the Serial Buffer or the amount of data you want to send+2&#xA;// You need to add 2 to allow the prefix and suffix character space to send.&#xA;#define MAX_SIZE 64&#xA;&#xA;&#xA;class StreamSend {&#xA;  private:&#xA;    static int getWrapperSize() { return sizeof(char)*2; }&#xA;    static byte receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, unsigned int loopSize);&#xA;    static byte receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, unsigned int loopSize, char prefixChar, char suffixChar);&#xA;    static char _prefixChar; // Default value is s&#xA;    static char _suffixChar; // Default value is e&#xA;    static int _maxLoopsToWait;&#xA;&#xA;  public:&#xA;    static void sendObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize);&#xA;    static void sendObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, char prefixChar, char suffixChar);&#xA;    static byte receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize);&#xA;    static byte receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, char prefixChar, char suffixChar);&#xA;    static boolean isPacketNotFound(const byte packetStatus);&#xA;    static boolean isPacketCorrupt(const byte packetStatus);&#xA;    static boolean isPacketGood(const byte packetStatus);&#xA;&#xA;    static void setPrefixChar(const char value) { _prefixChar = value; }&#xA;    static void setSuffixChar(const char value) { _suffixChar = value; }&#xA;    static void setMaxLoopsToWait(const int value) { _maxLoopsToWait = value; }&#xA;    static const char getPrefixChar() { return _prefixChar; }&#xA;    static const char getSuffixChar() { return _suffixChar; }&#xA;    static const int getMaxLoopsToWait() { return _maxLoopsToWait; }&#xA;&#xA;};&#xA;&#xA;//Preset Some Default Variables&#xA;//Can be modified when seen fit&#xA;char StreamSend::_prefixChar = 's';   // Starting Character before sending any data across the Serial&#xA;char StreamSend::_suffixChar = 'e';   // Ending character after all the data is sent&#xA;int StreamSend::_maxLoopsToWait = -1; //Set to -1 for size of current Object and wrapper&#xA;&#xA;&#xA;&#xA;/**&#xA;  * sendObject&#xA;  *&#xA;  * Converts the Object to bytes and sends it to the stream&#xA;  *&#xA;  * @param Stream to send data to&#xA;  * @param ptr to struct to fill&#xA;  * @param size of struct&#xA;  * @param character to send before the data stream (optional)&#xA;  * @param character to send after the data stream (optional)&#xA;  */&#xA;void StreamSend::sendObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize) {&#xA;  sendObject(ostream, ptr, objSize, _prefixChar, _suffixChar);&#xA;}&#xA;&#xA;void StreamSend::sendObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, char prefixChar, char suffixChar) {&#xA;  if(MAX_SIZE &amp;gt;= objSize+getWrapperSize()) { //make sure the object isn't too large&#xA;    byte * b = (byte *) ptr; // Create a ptr array of the bytes to send&#xA;    ostream.write((byte)prefixChar); // Write the suffix character to signify the start of a stream&#xA;&#xA;    // Loop through all the bytes being send and write them to the stream&#xA;    for(unsigned int i = 0; i&amp;lt;objSize; i++) {&#xA;      ostream.write(b[i]); // Write each byte to the stream&#xA;    }&#xA;    ostream.write((byte)suffixChar); // Write the prefix character to signify the end of a stream&#xA;  }&#xA;}&#xA;&#xA;/**&#xA;  * receiveObject&#xA;  *&#xA;  * Gets the data from the stream and stores to supplied object&#xA;  *&#xA;  * @param Stream to read data from&#xA;  * @param ptr to struct to fill&#xA;  * @param size of struct&#xA;  * @param character to send before the data stream (optional)&#xA;  * @param character to send after the data stream (optional)&#xA;  */&#xA;byte StreamSend::receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize) {&#xA;    return receiveObject(ostream, ptr, objSize, _prefixChar, _suffixChar);&#xA;}&#xA;byte StreamSend::receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, char prefixChar, char suffixChar) {&#xA;  return receiveObject(ostream, ptr, objSize, 0, prefixChar, suffixChar);&#xA;}&#xA;&#xA;byte StreamSend::receiveObject(Stream &amp;amp;ostream, void* ptr, unsigned int objSize, unsigned int loopSize, char prefixChar, char suffixChar) {&#xA;  int maxLoops = (_maxLoopsToWait == -1) ? (objSize+getWrapperSize()) : _maxLoopsToWait;&#xA;  if(loopSize &amp;gt;= maxLoops) {&#xA;      return PACKET_NOT_FOUND;&#xA;  }&#xA;  if(ostream.available() &amp;gt;= (objSize+getWrapperSize())) { // Packet meets minimum size requirement&#xA;    if(ostream.read() != (byte)prefixChar) {&#xA;      // Prefix character is not found&#xA;      // Loop through the code again reading the next char&#xA;      return receiveObject(ostream, ptr, objSize, loopSize+1, prefixChar, suffixChar);&#xA;    }&#xA;&#xA;    char data[objSize]; //Create a tmp char array of the data from Stream&#xA;    ostream.readBytes(data, objSize); //Read the # of bytes&#xA;    memcpy(ptr, data, objSize); //Copy the bytes into the struct&#xA;&#xA;    if(ostream.read() != (byte)suffixChar) {&#xA;      //Suffix character is not found&#xA;      return BAD_PACKET;&#xA;    }&#xA;      return GOOD_PACKET;&#xA;  }&#xA;  return PACKET_NOT_FOUND; //Prefix character wasn't found so no packet detected&#xA;}&#xA;&#xA;&#xA;boolean StreamSend::isPacketNotFound(const byte packetStatus) {&#xA;    return (packetStatus == PACKET_NOT_FOUND);&#xA;}&#xA;&#xA;boolean StreamSend::isPacketCorrupt(const byte packetStatus) {&#xA;    return (packetStatus == BAD_PACKET);&#xA;}&#xA;&#xA;boolean StreamSend::isPacketGood(const byte packetStatus) {&#xA;    return (packetStatus == GOOD_PACKET);&#xA;}&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="62" LastEditorUserId="62" LastEditDate="2014-02-15T04:50:45.477" LastActivityDate="2014-02-15T04:50:45.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="205" PostTypeId="2" ParentId="117" CreationDate="2014-02-14T11:36:15.367" Score="13" Body="&lt;p&gt;Shift registers have been mentioned in other answers, and they are definitely an excellent choice for many projects. They are cheap, simple, moderately fast, and can typically be chained together to add more outputs. However, they have the downside that they usually need exclusive use of several pins (between 2 and 4, depending on how you set them up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to use more advanced port expanders, such as the &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;16-bit MCP23017 and MCP23S17&lt;/a&gt;. These support I2C and SPI respectively, which means you can place them on a bus with several other devices (potentially of different types). Each device on the bus can be individually addressed, meaning you only need 2 or 3 pins to talk to all of them. The update speeds are typically extremely fast, so you're unlikely to experience significant latency (i.e. transmission delays) in an Arduino project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a low level, using I2C or SPI is substantially more complicated than a simple shift register. However, there is library code for Arduino to take care of that for you. See this question, for example: &lt;a href=&quot;https://arduino.stackexchange.com/questions/158/how-do-i-use-i2c-devices-with-arduino&quot;&gt;How do I use I2C devices with Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-02-14T11:41:42.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="206" PostTypeId="1" AcceptedAnswerId="207" CreationDate="2014-02-14T12:06:10.727" Score="26" ViewCount="5876" Body="&lt;p&gt;Making a blinking light seems to be one of the most common beginner projects with Arduino. A typical approach is to connect an LED + resistor (in series) to an IO pin, and connect the other end to ground. In code, you make the pin an output, and bring it &lt;code&gt;HIGH&lt;/code&gt; and &lt;code&gt;LOW&lt;/code&gt; repeatedly to flash the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens if you leave that resistor out? Obviously you're going to wreck the LED, but will it also damage the Arduino in some way?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="37" LastEditDate="2014-02-23T18:56:36.650" LastActivityDate="2019-04-17T18:17:57.613" Title="What happens to the Arduino if you don't use a resistor with an LED?" Tags="|safety|pins|led|resistor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="207" PostTypeId="2" ParentId="206" CreationDate="2014-02-14T13:02:11.400" Score="19" Body="&lt;p&gt;From page 411 of the &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega328P data sheet&lt;/a&gt;, we have a graph of the output current vs voltage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w5V5U.png&quot; alt=&quot;Output current graph&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can see over the the 20mA range of output currents, we drop ~0.5V, giving an approximate internal resistance of 25Ω.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical LED has a forward voltage of about 2V. Therefore, we end up in the situation where we will drop 3V over the 25Ω internal resistance of the ATmega328P, giving an output current of 120mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I = (5-2)V / 25Ω = 120mA &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a simplification, but this 120mA is far larger than the recommended maximum current per pin of 40mA of the microcontroller, and far in excess of what a normal LED should take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, most LEDs and the ATmega328P seem to survive this kind of abuse, especially for short periods. In general, if the pin continues to work after this is done, it should be fine.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-02-14T13:02:11.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="208" PostTypeId="2" ParentId="206" CreationDate="2014-02-14T13:30:43.520" Score="15" Body="&lt;p&gt;Leaving series resistors out will definitely greatly (exponentially) shorten lifetime of both the controller and the LED. Absolute maximum ratings for most AVRs are (a.o.):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;max. 40mA per GPIO pin&lt;/li&gt;&#xA;&lt;li&gt;max. 200mA per package.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A new Arduino sets you back $20 or more, a fist full 220 ohm resistors sets you back 1$. When treated within spec, an Arduino (and LEDs for that matter) can survive a lifetime.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-14T13:30:43.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="209" PostTypeId="2" ParentId="203" CreationDate="2014-02-14T14:20:14.733" Score="1" Body="&lt;p&gt;If you really wanted to send it &lt;em&gt;fast&lt;/em&gt;, i recommend Full Duplex Serial (FDX). It's the same protocol that USB and ethernet use, and it's a lot faster than UART. The downside is that it usually requires external hardware to facilitate the high data rates. I've heard that the new &lt;a href=&quot;http://arduiniana.org/libraries/NewSoftSerial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;softwareSreial&lt;/a&gt; supports FDX, but this may be slower even than hardware UART. For more on communication protocols, see &lt;a href=&quot;https://arduino.stackexchange.com/questions/182/how-to-connect-two-arduino-without-shields&quot;&gt;How to connect two Arduino without shields?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-02-14T14:20:14.733" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="210" PostTypeId="1" AcceptedAnswerId="212" CreationDate="2014-02-14T15:08:09.547" Score="22" ViewCount="27413" Body="&lt;p&gt;According to the &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogWrite&quot;&gt;Arduino reference for &lt;code&gt;analogWrite()&lt;/code&gt;&lt;/a&gt;, the PWM frequency on most pins is ~490 Hz. However, it's ~980 Hz for pins 5 and 6 on the Uno, and for pins 3 and 11 on the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are these different? Is it a deliberate design feature, or is it somehow dictated by the hardware?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:49.447" LastActivityDate="2014-02-27T15:51:01.533" Title="Why do some pins have a different PWM frequency?" Tags="|arduino-uno|pwm|arduino-leonardo|analogwrite|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="211" PostTypeId="2" ParentId="210" CreationDate="2014-02-14T15:57:57.027" Score="8" Body="&lt;p&gt;I am not aware of the design considerations, but if you check the datasheet for the microcontroller on your Arduino, you will notice that PWM pins are grouped together and per group connected to a timer. The speed at which this timer is increased varies by the configured prescaler. If you change the prescaler for a certain timer, you change the PWM frequency for the related PWM pins. I believe some timers double for other purposes like the &lt;code&gt;millis();&lt;/code&gt; function. If you change the prescaler for that timer, values returned by &lt;code&gt;millis()&lt;/code&gt; will be off by the same factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can calculate the setting for the prescaler as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;$$\text{prescaler} = \dfrac{f_{CPU}}{PWMresolution × f_{PWM}} = \dfrac{16\text{MHz}}{256×490} \approx 128$$&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;prescaler = f[CPU]/(PWMresolution×f[PWM]) = 16000000/(256×490) = approx 128. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Check the datasheet and you'll find that 128 is indeed one of the prescaler values you can select.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-14T16:09:15.693" LastActivityDate="2014-02-14T16:09:15.693" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="212" PostTypeId="2" ParentId="210" CreationDate="2014-02-14T16:00:19.090" Score="24" Body="&lt;p&gt;Those aren't the only frequencies available for the PWM signals. However, they are the frequencies as determined by the applied prescaler (which you can readily change as detailed below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of the 3 pairs of PWM pins is tied to one timer, each of which has its own base frequency, as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pins 5 and 6 are paired on timer0, with base frequency of 62500Hz&lt;/li&gt;&#xA;&lt;li&gt;Pins 9 and 10 are paired on timer1, with base frequency of 31250Hz&lt;/li&gt;&#xA;&lt;li&gt;Pins 3 and 11 are paired on timer2, with base frequency of 31250Hz&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then each set of pins have a number of prescaler values that can be chosen, that will divide the base frequency of that pair of pins. The prescaler values available are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pins 5 and 6 have prescaler values of 1, 8, 64, 256, and 1024&lt;/li&gt;&#xA;&lt;li&gt;Pins 9 and 10 have prescaler values of 1, 8, 64, 256, and 1024&lt;/li&gt;&#xA;&lt;li&gt;Pins 3 and 11 have prescaler values of 1, 8, 32, 64, 128, 256, and 1024&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The different combinations yield different frequencies in a given PWM pin. Notice that timer 2 (tied to pins 3 and 11) have more prescaler values available, resulting in more frequencies available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, why timer 2 is different, that's a separate question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here's a list of possible PWM frequencies per pin (from &lt;a href=&quot;http://arduino-info.wikispaces.com/Arduino-PWM-Frequency&quot;&gt;this article&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For pins 6 and 5 (OC0A and OC0B):&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;If TCCR0B = xxxxx001, frequency is 64kHz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCR0B = xxxxx010, frequency is 8 kHz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCR0B = xxxxx011, frequency is 1kHz (this is the default from the Diecimila bootloader)&lt;/li&gt;&#xA;  &lt;li&gt;If TCCR0B = xxxxx100, frequency is 250Hz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCR0B = xxxxx101, frequency is 62.5 Hz&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;For pins 9, 10, 11 and 3 (OC1A, OC1B, OC2A, OC2B):&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;If TCCRnB = xxxxx001, frequency is 32kHz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCRnB = xxxxx010, frequency is 4 kHz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCRnB = xxxxx011, frequency is 500Hz (this is the default from the Diecimila bootloader)&lt;/li&gt;&#xA;  &lt;li&gt;If TCCRnB = xxxxx100, frequency is 125Hz&lt;/li&gt;&#xA;  &lt;li&gt;If TCCRnB = xxxxx101, frequency is 31.25 Hz &lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCCRnB&lt;/code&gt; is where you set the prescaler bits for timer &lt;code&gt;n&lt;/code&gt;, replacing &lt;code&gt;n&lt;/code&gt; by 0, 1 or 2, depending on the timer you want to set. If you are still unsure about bitwise operations, read this &lt;a href=&quot;http://playground.arduino.cc/Code/BitMath&quot;&gt;bit math tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/PwmFrequency&quot;&gt;http://playground.arduino.cc/Code/PwmFrequency&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot;&gt;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM&quot;&gt;http://arduino.cc/en/Tutorial/PWM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino-info.wikispaces.com/Arduino-PWM-Frequency&quot;&gt;http://arduino-info.wikispaces.com/Arduino-PWM-Frequency&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that there seems to be divergence in those sources about whether pins 9 and 10 have the same behavior as 5 and 6 or 3 and 11, but you get the idea anyway. I'm reading the datashet to try and figure out which is correct, or whether this is a difference between boards.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="304" LastEditDate="2014-02-27T15:51:01.533" LastActivityDate="2014-02-27T15:51:01.533" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="213" PostTypeId="5" CreationDate="2014-02-14T19:15:02.077" Score="0" Body="&lt;p&gt;Inter-Integrated Circuit (I²C) is a bus for low speed peripherals. It was invented by Philips, but many companies have created devices using the I²C protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag for questions regarding how to use I²C with an Arduino, or for problems with I²C and your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow&quot;&gt;Wikipedia article for more info&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="118" LastEditorUserId="35" LastEditDate="2014-02-26T22:04:32.127" LastActivityDate="2014-02-26T22:04:32.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="214" PostTypeId="4" CreationDate="2014-02-14T19:15:02.077" Score="0" Body="Inter-Integrated Circuit (I²C) is a bus for low speed peripherals. Use this tag for questions regarding how to use I²C with an Arduino, or for problems with I²C and your Arduino." OwnerUserId="118" LastEditorUserId="35" LastEditDate="2014-02-26T22:04:25.550" LastActivityDate="2014-02-26T22:04:25.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="215" PostTypeId="2" ParentId="189" CreationDate="2014-02-14T21:24:19.817" Score="21" Body="&lt;p&gt;First, let's see a few examples of what can go wrong.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Uninitialized local variables&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  int status;&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, status);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As pointed out by &lt;a href=&quot;https://arduino.stackexchange.com/users/7508/edgar-bonet&quot;&gt;Edgar Bonet&lt;/a&gt; in the comments, local variables like &lt;code&gt;status&lt;/code&gt; in the code above are not implicitly initialized by the C++ compiler. So, the outcome of the code above is indeterminate. To avoid that, make sure you always assign values to your local variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things are a bit different with global and static variables:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Global and static variables are guaranteed to be initialized to 0 by the C standard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &#xA;&lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_varinit.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR Libc Reference Manual - Frequently Asked Questions - Shouldn't I initialize all my variables?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means you shouldn't worry about initializing them to 0 in your code. In fact, you should really avoid it, as the initialization may waste memory. Only initialize them to values other than 0.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Memory overflow&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int array[10];&#xA;int v = array[100];&#xA;array[-100] = 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first problem here is that you don't know what will be assigned to v, but worse is that you don't know what you messed up with the assignment to position -100 of &lt;code&gt;array&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Jump to an illegal instruction&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void doSomething( void ) { &#xA;    for (int i = 0; i &amp;lt; 1000; i++); &#xA;}&#xA;&#xA;void setup () &#xA;{&#xA;    void (*funcPtr)( void );&#xA;&#xA;    funcPtr = &amp;amp;doSomething;&#xA;    funcPtr(); // calls doSomething();&#xA;&#xA;    funcPtr = NULL;&#xA;    funcPtr(); // undefined behavior&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first call to &lt;code&gt;funcPtr()&lt;/code&gt; will actually be a call to &lt;code&gt;doSomething()&lt;/code&gt;. Calls like the second one may lead to undefined behavior.  &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Other bad things that may happen&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Well, you can run out of RAM, for example. What else. In any case, I think your program will keep running, probably not the way you intended it to.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Kinds of Protection&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In computer systems, problems like these are usually dealt with at various levels:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;By the compiler&lt;/li&gt;&#xA;&lt;li&gt;By the programming language runtime (as in Java for example). &lt;/li&gt;&#xA;&lt;li&gt;By the operating system or the processor (if your memory access a position outside the boundaries of the address space reserved to your program, the OS or the processor may have safety mechanisms to prevent that)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Arduinos only have limited protection of the compiler, and probably nothing else. The good news is that they aren't multi-tasked, so the only program being affected is yours. In any case, any of those bugs will lead to erratic behavior.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The Answers&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The assumptions are the all of the problems I stated above are runtime problems.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What happens if there is a runtime error in a program? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The program will continue and what happens will depend on the side-effects of the runtime error. A call to the null function pointer will probably make the program jump to an unknown location.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Will execution of the program just stop?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it will keep going as if nothing extraordinary happened, probably doing what you didn't intend it to do. It may reset or act erratically. It may turn some inputs into outputs and burn a sensor or two (but that's &lt;em&gt;highly unlikely&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there some way I get the Arduino to tell me what the error is?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't think so. As I said earlier, the protection mechanisms aren't there. There's no runtime support from the language, no OS, no hardware checks for out-of-bounds memory access (the bootloader doesn't count as either). You just have to be careful with your program and probably set your own safety nets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for the lack of protection is probably because Arduino controllers are too cheap, have too little memory, and should not run anything too important (yes, there seems to be a disclaimer by AVR somewhere for you not to use the MCUs normally used by Arduino in life support systems).&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-12-03T15:46:07.280" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="216" PostTypeId="5" CreationDate="2014-02-14T21:32:13.740" Score="0" Body="&lt;p&gt;A Pulse Width Modulation (PWM) signal is a series of digital pulses. Each pulse makes the signal go high (on) for a short period, and it then drops back to low (off) for a short period before the next pulse. The result can be referred to as a square or rectangular wave, because of its appearance if it is graphed as voltage over time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two important attributes which describe a PWM signal. Firstly, the frequency determines how often the pulses happen. Frequency is expressed in Hertz (Hz), which is the number of pulses per second. PWM signals generated by the Arduino usually have a frequency of 490 Hz (or 980 Hz in some cases).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second attribute of a PWM signal is the duty cycle. For human-readable purposes, it is often expressed as a percentage. This determines how long a pulse lasts compared to the space between pulses. For example, a pulse could last 5 milliseconds, and be followed by a 15 millisecond gap before the next pulse. This is a 25% duty cycle, because the pulse is high for a quarter of the total time. A 10ms pulse followed by a 10ms gap would be a 50% duty cycle, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PWM is very useful for controlling the speed of a DC motor. Raising or lowing the duty cycle will cause the motor to speed up or slow down. A conventional analog approach to motor control would raise or lower the voltage instead, which can result in poorer performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, a PWM signal can effectively control the brightness of an LED. Raising and lowering the duty cycle will increase and decrease the apparent brightness of the light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most common way to produce a PWM signal on the Arduino is using the &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;analogWrite()&lt;/code&gt;&lt;/a&gt; function. The frequency is fixed, but it allows specification of the duty cycle in the range 0 to 255 (where 255 represents 100%).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;tone()&lt;/code&gt;&lt;/a&gt; function also allows a PWM output to be generated. It has a fixed 50% duty cycle, but allows specification of the frequency in Hz. It is primarily intended for generating simple sounds on a speaker, but could be used for other purposes as well.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-02-15T20:36:01.767" LastActivityDate="2014-02-15T20:36:01.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="217" PostTypeId="4" CreationDate="2014-02-14T21:32:13.740" Score="0" Body="PWM is a form of signal modulation that allows digital output to approximate an analog signal. Use this for questions about using the PWM pins (marked with ~). " OwnerUserId="42" LastEditorUserId="65" LastEditDate="2014-03-01T06:15:05.257" LastActivityDate="2014-03-01T06:15:05.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="218" PostTypeId="1" CreationDate="2014-02-14T22:44:35.220" Score="13" ViewCount="6845" Body="&lt;p&gt;Sometime in the past, I was burning bootloaders on a fresh batch of four &lt;strong&gt;ATmega328-PU&lt;/strong&gt; using the Arduino IDE (notice there's no &lt;strong&gt;P&lt;/strong&gt; after 328 - it's the slightly cheaper non-picopower version of the MCU, not to be confused with the &lt;strong&gt;ATmega328P-PU&lt;/strong&gt; with a &lt;strong&gt;P&lt;/strong&gt;), and was surprised with the following message from avrdude:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Device signature = 0x1e950F &#xA;avrdude: Expected signature for ATMEGA328 is 1E 95 14 &#xA;Double check chip, or use -F to override this check. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means avrdude thought the chip was not what its label said. Then I changed the chip type on my Arduino IDE to &lt;strong&gt;ATmega328P-PU&lt;/strong&gt; and avrdude burned the bootloader without complaints. What that means is that the chip was labelled as one MCU and internally it responded as another, slightly different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to know is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;s&gt;How rare is this event? Has anyone had a similar experience?&lt;/s&gt; (&lt;em&gt;Original question, off-topic&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to fix this? How can I fix the signature so that avrdude recognize the chip correctly?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;This is a &lt;a href=&quot;https://electronics.stackexchange.com/questions/90692/mislabelled-atmega328-pu&quot;&gt;cross-post from EE.SE&lt;/a&gt;. I posted this question there but didn't attract much attention, so I wanted to see if anyone from our community had a similar experience.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2023-02-11T21:30:06.237" Title="I got a missignatured ATmega328-PU. How can I fix that?" Tags="|atmega328|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="219" PostTypeId="2" ParentId="189" CreationDate="2014-02-14T23:26:18.400" Score="9" Body="&lt;p&gt;There are no runtime exceptions. There is only undefined behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, there are no exceptions &lt;em&gt;at all&lt;/em&gt;. If you try to perform an invalid operation, it's results will be unknown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no runtime checking at all, except what &lt;strong&gt;you&lt;/strong&gt; implement. Your program is running on bare-metal hardware. It's the Desktop equivalent of running in &lt;a href=&quot;http://en.wikipedia.org/wiki/Ring_%28computer_security%29&quot; rel=&quot;nofollow&quot;&gt;ring-0&lt;/a&gt; all the time, because the ATmega &lt;em&gt;doesn't have rings&lt;/em&gt;. &lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-03-27T03:13:05.270" LastActivityDate="2014-03-27T03:13:05.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="220" PostTypeId="2" ParentId="218" CreationDate="2014-02-14T23:31:13.463" Score="4" Body="&lt;p&gt;While browsing sparkfun, i have found several news posts that show their struggle with mislabeled chips. Here are a few:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/news/350&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/news/350&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/news/384&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/news/384&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/news/364&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/news/364&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sparkfun had received a questionable shipment if ICs from a new seller in china. They decided to test them before sending them into production, and none of their test boards worked. Using nitric acid, they were able to remove the case of the ICs and fould a hunk of metal that looked like copper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In another article, they dissected some suspicious ICs from Atmel, and found an ON semiconductor silicon wafer inside. The chips were not functional ATmegas, but they did have silicon, unlike the other ones.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-15T04:52:08.083" LastActivityDate="2014-02-15T04:52:08.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="221" PostTypeId="1" AcceptedAnswerId="222" CreationDate="2014-02-15T01:09:33.157" Score="30" ViewCount="80942" Body="&lt;p&gt;According to the Arduino documentation, the ATmega328 has 32KB of Flash memory for the bootloader + uploaded sketch, and only 2KB SRAM for runtime data. The ATmega2560 has quite a bit more, totalling 256KB and 8KB respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case, those limits seem rather small, especially when compared to similarly sized consumer devices, such as smartphones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can you do if you run out? E.g. if your sketch is too big, or you need to process a lot of data (such as strings) at runtime? Is there any way to expand the Flash or SRAM?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-23T18:56:46.587" LastActivityDate="2014-03-15T17:30:24.420" Title="What can I do if I run out of Flash memory or SRAM?" Tags="|flash|sketch-size|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="222" PostTypeId="2" ParentId="221" CreationDate="2014-02-15T01:09:33.157" Score="32" Body="&lt;p&gt;&lt;strong&gt;Optimisation&lt;/strong&gt;&lt;br&gt;&#xA;Low-level programming for embedded systems is quite different from programming for general purpose devices, such as computers and cell phones. Efficiency (in terms of speed and space) is far more important because resources are at a premium. That means the very first thing to do if you run out of space is to look at what parts of your code you can optimise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of reducing program space (Flash) usage, the code size can be quite difficult to optimise if you're inexperienced, or if you're more used to programming for desktop computers which don't tend to need that skill. Unfortunately, there's no 'magic bullet' approach which will work for all situations, although it helps if you consider seriously what your sketch really &lt;em&gt;needs&lt;/em&gt; to have. If a feature isn't needed, take it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes it's also helpful to identify where multiple parts of your code are the same (or very similar). You may be able to condense them into reusable functions which can be called from multiple places. However, be aware that sometimes trying to make code &lt;em&gt;too&lt;/em&gt; reusable actually ends up making it more verbose. It's a tricky balance to strike that tends to come with practice. Spending some time looking at how code changes affect the compiler output can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Runtime data (SRAM) optimisation tends to be a bit easier when you're used to it. A very common pitfall for beginner programmers is using too much global data. Anything declared at global scope will exist for the entire lifetime of the sketch, and that isn't always necessary. If a variable is only used inside one function, and it doesn't need to persist between calls, then make it a local variable. If a value needs to be shared between functions, consider if you can pass it as a parameter instead of making it global. That way you'll only use SRAM for those variables when you actually need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another killer for SRAM usage is text processing (e.g. using the &lt;code&gt;String&lt;/code&gt; class). Generally speaking, you should avoid doing String operations if possible. They are massive memory hogs. For example, if you're outputting lots of text to serial, use multiple calls to &lt;code&gt;Serial.print()&lt;/code&gt; instead of using string concatenation. Also try to reduce the number of string literals in your code if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Avoid recursion if possible as well. Each time a recursive call is made, it takes the stack a level deeper. Refactor your recursive functions to be iterative instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Use EEPROM&lt;/strong&gt;&lt;br&gt;&#xA;EEPROM is used for long-term storage of things that only change occasionally. If you need to use large lists or look-up tables of fixed data, then consider storing it in EEPROM in advance, and only pulling out what you need when necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously EEPROM is quite limited in size and speed though, and has a limited number of write cycles. It's not a great solution to data limitations, but it might be enough to ease the burden on Flash or SRAM. It's also quite possible to interface with similar external storage, such as an SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Expansion&lt;/strong&gt;&lt;br&gt;&#xA;If you've exhausted all other options, then expansion may be a possibility. Unfortunately, expanding Flash memory to increase program space isn't possible. However, it &lt;em&gt;is&lt;/em&gt; possible to expand SRAM. This means you may be able to refactor your sketch to reduce code size at the expense of increasing data size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting more SRAM is actually fairly straightforward. One option is to use one or more &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf&quot;&gt;&lt;strong&gt;23K256&lt;/strong&gt;&lt;/a&gt; chips. They are accessed via SPI, and there is the &lt;a href=&quot;http://playground.arduino.cc/Main/SpiRAM&quot;&gt;&lt;strong&gt;SpiRAM library&lt;/strong&gt;&lt;/a&gt; to help you use them. Just beware that they operate at 3.3V &lt;strong&gt;not&lt;/strong&gt; 5V!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using the Mega, you could alternatively get SRAM expansion shields from &lt;a href=&quot;http://lagrangianpoint.net/store/arduino-mega-sram-expansion-shield-kit&quot;&gt;&lt;strong&gt;Lagrangian Point&lt;/strong&gt;&lt;/a&gt; or &lt;a href=&quot;http://www.ruggedcircuits.com/html/quadram.html&quot;&gt;&lt;strong&gt;Rugged Circuits&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-15T01:09:33.157" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="223" PostTypeId="2" ParentId="221" CreationDate="2014-02-15T03:24:15.173" Score="25" Body="&lt;p&gt;When you upload your code to your Arduino, say an Uno for example, it'll tell you how many bytes it uses up out of the 32K available. That's how much flash memory you have (think computer hard disk). While your program is running, it's using whats called SRAM, and there is much less of that available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes you'll notice your program behaving oddly at a point that you haven't even touched in a while. It could be that your most recent changes cause it to run out of memory (SRAM). Here are a few tips on how to free up some SRAM.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Storing strings in Flash instead of SRAM.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;One of the most common things I've seen is the chip running out of memory because there are too many long strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;code&gt;F()&lt;/code&gt; function when using strings so they are stored in Flash instead of SRAM, since you have much more of that available.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;This string will be stored in flash memory&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Use the right data types&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can save a byte by switching from an &lt;code&gt;int&lt;/code&gt; (2 bytes) to a &lt;code&gt;byte&lt;/code&gt; (1 byte). An unsigned byte will give you 0-255 so if you have numbers that don't go higher than 255, save a byte!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How do I know I'm running out of memory?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Usually you'll observe your program behaving strangely and wonder what went wrong... You didn't change anything in the code near the point where it's messing up, so what gives? It's running out of memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of functions to tell you how much available memory you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/AvailableMemory&quot;&gt;Available Memory&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-15T03:24:15.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="224" PostTypeId="1" AcceptedAnswerId="225" CreationDate="2014-02-15T03:50:16.547" Score="9" ViewCount="5915" Body="&lt;p&gt;I've recently received an Arduino Pro Mini as a gift, and I don't have an external USB programmer to program the Pro Mini. However, I do own an Arduino Uno R3, and I think it would be possible because they both have the same clock speed and micro-controller (16Mhz with an atmega328).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to program an Arduino Pro Mini using an Arduino Uno?&#xA;If yes, how does one do so?&lt;/p&gt;&#xA;" OwnerUserId="188" LastEditorUserId="220" LastEditDate="2014-02-25T06:34:36.940" LastActivityDate="2018-05-28T21:27:37.420" Title="Is it possible to program an Arduino Pro Mini using an Arduino Uno R3?" Tags="|uploading|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="225" PostTypeId="2" ParentId="224" CreationDate="2014-02-15T03:55:38.020" Score="7" Body="&lt;p&gt;Just hook up the pins (RX, TX, reset, Power, and Ground) to the corresponding pins on your Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have to take the ATMega328 out of your Uno for this to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that you need to hook it up to the correct power pin! If your pro mini is running at 3.3v then you must hook it up to the 3.3 pin on your Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out the &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot;&gt;ArduinoToBreadboard&lt;/a&gt; page for a bit more info. Scroll down to &quot;Uploading Using an Arduino Board&quot;. Although it shows you how to program an Arduino on a breadboard, the wiring is the same.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-02-15T04:03:42.247" LastActivityDate="2014-02-15T04:03:42.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="226" PostTypeId="1" AcceptedAnswerId="230" CreationDate="2014-02-15T04:09:14.367" Score="25" ViewCount="42473" Body="&lt;p&gt;ATMEL says the cell lifetime of an EEPROM cell is about 100,000 write cycle/ cell.&#xA;Is this actually how the EEPROM performs in the wild?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do not change the value of a cell, does this stress the lifetime? For example, if I write the value &lt;code&gt;0xFF&lt;/code&gt; to the same cell again and again, is this any different to writing &lt;code&gt;0x00&lt;/code&gt;, &lt;code&gt;0xFF&lt;/code&gt;, &lt;code&gt;0x00&lt;/code&gt; etc.&lt;/p&gt;&#xA;" OwnerUserId="190" LastEditorUserId="65" LastEditDate="2014-02-18T16:42:02.160" LastActivityDate="2020-01-02T19:49:34.070" Title="What is the real lifetime of EEPROM?" Tags="|eeprom|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="227" PostTypeId="2" ParentId="203" CreationDate="2014-02-15T04:23:43.253" Score="0" Body="&lt;p&gt;I have no official credentials here, but in my experience things have gone pretty efficiently when I pick a certain character position(s) to contain the state of a variable, so that you might designate the first three characters as the temperature, and the next three as the angle of a servo, and so on. On the sending end I would save the variables individually and then combine them in a string to send serially. On the receiving end I would have the string picked apart, getting the first three characters and turning them into whatever variable type i need, then doing so again to get the next variable value.&#xA;This system works best when you know for certain the amount of characters each variable will take up, and you always look for the same variables (which I hope is a given) each time the serial data loops through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pick one variable to put last of indeterminate length and then get that variable from it's first character to the end of the string. Granted, the serial data string could get really long depending on the variable types and the sheer amount of them, but this is the system I use and so far the only setback I've hit is the serial length, so that's the only disadvantage I know of.&lt;/p&gt;&#xA;" OwnerUserId="71" LastActivityDate="2014-02-15T04:23:43.253" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="228" PostTypeId="2" ParentId="226" CreationDate="2014-02-15T04:47:54.653" Score="10" Body="&lt;p&gt;I once ran an experiment on an external EEPROM with 1 million max rated cycles. It took about 6 million cycles to become majorly corrupted, and before that it had progressed having sporadic amounts of corruption. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you say you do not change the value, i am assuming you are writing the same data to an address multiple times. This almost certainly would stress the life, although it would probably not stress the surrounding cells.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-15T04:47:54.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="229" PostTypeId="2" ParentId="203" CreationDate="2014-02-15T05:09:45.997" Score="1" Body="&lt;p&gt;Sending a structure is fairly simple.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can declare the structure as you normally would, and then use memcpy(@myStruct,@myArray) to copy the data to a new location, and then use something similar to the below code to write the data as a datastream.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char myArraySender[##];   //make ## large enough to fit struct&#xA;memcpy(&amp;amp;myStruct,&amp;amp;myArraySender);  //copy raw data from struct to the temp array&#xA;digitalWrite(frameStartPin,High);  //indicate to receiver that data is coming&#xA;serial.write(sizeof myStruct);     //tell receiver how many bytes to rx&#xA;Serial.write(&amp;amp;myArraySender,sizeof myStruct);   //write bytes&#xA;digitalWrite)frameStartPin,Low);   //done indicating transmission &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can attach an interrupt routine to the pin on the other device that does the following:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned char len, tempBuff[##];   &#xA;//volatile because the interrupt will not happen at predictable intervals.&#xA;&#xA;attachInterrupt(0,readSerial,Rising);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//tell the mcu to call fxn when pinhigh. This will happen during virtually any moment. if that is not desired, remove the interrupt and simply watch for new characters in your main executive loop (aka, UART polling).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readSerial(unsigned char *myArrayReceiver){&#xA;    unsigned char tempbuff[sizeof myArrayReceiver];&#xA;    while (i&amp;lt;(sizeof myArrayReceiver)) tempBuff[i]=Serial.read();&#xA;    memcpy(&amp;amp;tempbuff,&amp;amp;myArrayReceiver);&#xA;    Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Syntax and use of pointers will need some review. I pulled an all-nighter so I'm sure the above code won't even compile, but the idea is there. Fill your structure, copy it, use out-of-band signalling to avoid framing errors, write the data. On the other end, receive the data, copy it to a struct, and then the data becomes accessible via normal member access methods.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of bitfields will also work, just be aware that the nibbles will appear to be backwards. For instance, attempting to write 0011 1101, may result in 1101 0011 appearing at the other end if the machines differ in byte order. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If data integrity is important, you can also add a checksum to make sure you aren't copying misaligned garbage data. This is quick and effective check that I recommend. &lt;/p&gt;&#xA;" OwnerUserId="160" LastActivityDate="2014-02-15T05:09:45.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="230" PostTypeId="2" ParentId="226" CreationDate="2014-02-15T07:33:52.483" Score="23" Body="&lt;p&gt;As you state, the internal EEPROM has a lifetime of 100,000 write cycles. This isn't a guess - a very significant proportion of ATmega328 will reach this number with no issues. I have tested three processors before, and all reached 150,000 cycles with no issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important to note the failure mode of EEPROM. Most &quot;EEPROM destroyer&quot; projects repeatedly read/write until the data is not written at all. Before this point, the EEPROM will still be damaged. This would be manifested by data not being retained for a reasonable period. It is unwise to rely on anything more than 100,000 write cycles for this reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EEPROM is different to the RAM on an ATmega. Writing to it is not simple or quick, but it is wrapped up in a &lt;a href=&quot;http://arduino.cc/en/Reference/EEPROM#.Uv8RdHnG&quot;&gt;friendly Arduino library&lt;/a&gt;, hiding this complexity from the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first level of indirection is the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/598ab1d5c003e02b6bb193640fac8526ad8ab912/libraries/EEPROM/EEPROM.cpp&quot;&gt;EEPROM library&lt;/a&gt;, which is trivially simple], just calling two other functions for read and write. This calls eeprom_write_byte, found &lt;a href=&quot;https://github.com/arduino/Arduino/blob/598ab1d5c003e02b6bb193640fac8526ad8ab912/build/windows/eeprom.h&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function uses inline assembly, so might not be easily understood. There is a comment that is easily understood though:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Set programming mode: erase and write&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This hints to one of the complexities of dealing with EEPROM - to write to&#xA;it, you first need to erase it. This means that if you call EEPROM.write(), it will perform a write cycle regardless of the value you are writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that repeatedly writing 0xFF will likely have the same effect as writing 0xFF,0x00,0xFF,0x00 etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are ways to work around this - you can try calling EEPROM.read() before EEPROM.write() to see if the value is already the same, but this takes additional time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other techniques to avoid excessive EEPROM wear, but their use depends on your application.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-15T10:32:02.853" LastActivityDate="2014-02-15T10:32:02.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="231" PostTypeId="2" ParentId="218" CreationDate="2014-02-15T07:35:23.420" Score="3" Body="&lt;p&gt;Not the preferred way to fix things and certainly not the first solution to consider, but you can consider programming the signature bytes. Before attempting this be absolutely sure you really want to do this and you have investigated what is involved to undo this. This may involve changing configuration files on your computer ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways the way to set the controller's signature bytes is as follows (untested, I don't have a spare AVR lying around):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -p atmega328 -c arduino -P /dev/ttyUSB003 -b 19200 -v -U signature:w:0x1E,0x95,0x14:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-15T07:35:23.420" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="232" PostTypeId="2" ParentId="226" CreationDate="2014-02-15T08:47:31.550" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://hackaday.com/2011/05/16/destroying-an-arduinos-eeprom/&quot; rel=&quot;nofollow&quot;&gt;http://hackaday.com/2011/05/16/destroying-an-arduinos-eeprom/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino was plugged into a wall wart and sat, “behind a couch for a couple of months.” The EEPROM saw it’s first write error after 47 days and 1,230,163 cycles. This is an order of magnitude better than the spec on the atmel datasheet, but similar to the results of similar experiments.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="160" LastActivityDate="2014-02-15T08:47:31.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="233" PostTypeId="1" AcceptedAnswerId="437" CreationDate="2014-02-15T10:49:28.927" Score="2" ViewCount="2612" Body="&lt;p&gt;The &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/4382&quot; rel=&quot;nofollow&quot;&gt;DS2482-100&lt;/a&gt; and &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/4338&quot; rel=&quot;nofollow&quot;&gt;DS2482-800&lt;/a&gt; are I2C to 1-Wire bridges which are useful for driving complex 1-Wire networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are natively supported by a number of packages in Linux so you can interface easily with them on a Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was surprised to find there is not an obvious library for accessing them on an Arduino however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An &lt;a href=&quot;https://github.com/paeaetech/paeae&quot; rel=&quot;nofollow&quot;&gt;Arduino library&lt;/a&gt; - has some quirks and not-maintained.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/dreamiurg/avr-liberty/blob/e08e41d073be523a8a8e4202afb5b3c1e061d300/src/rsl/ds2482.c&quot; rel=&quot;nofollow&quot;&gt;Part&lt;/a&gt; of AVR-Liberty - less quirks, not sure if maintained, not &quot;Arduino&quot; as&#xA;such, more AVR.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is helpful to be able to rely on maintained libraries to deal with any changes to the Arduino environment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino libraries are often easier to use than ones designed for AVR in general, which means more people are able to use the software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better library available?&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2020-02-03T23:19:14.367" Title="Are there any good and maintained libraries for using DS2482 I2C to 1-Wire bridge?" Tags="|library|i2c|1-wire|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="234" PostTypeId="2" ParentId="189" CreationDate="2014-02-15T11:44:12.093" Score="6" Body="&lt;p&gt;There is one mechanism that can get MCU from erratic state and it's the &lt;strong&gt;watchdog timer&lt;/strong&gt;. If you're implementing some code that will repeatedly run in a loop, that will not run anytime longer than some fixed time, you can set this time as watchdog period and enable the timer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you have to repeatedly reset the timer in the loop. If your code freezes at some condition loop that will never end, then the watchdog will count to zero and eventually reset the MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you are losing data, but if you run the AVR WDT in interrupt mode, you can store some data before resetting the MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the watchdog timer can guard your code from occasional unintended endless loops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation: &lt;a href=&quot;http://www.atmel.com/Images/doc2551.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR132: Using the Enhanced Watchdog Timer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="194" LastEditorUserId="194" LastEditDate="2019-02-23T10:23:12.317" LastActivityDate="2019-02-23T10:23:12.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="235" PostTypeId="1" CreationDate="2014-02-15T13:51:05.673" Score="6" ViewCount="333" Body="&lt;p&gt;I am looking for a simple, low cost solution to control on/off of mains supply to certain equipment. The control will be done using one of the output pin of Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input trigger and how to control it is application dependent.  e.g. controlling an equipment or controlling supply to section of home but in principle mains control module implementation remains same. So looking for solution which is safe while doing connections as well as while in use in  indoor conditions for years.&lt;/p&gt;&#xA;" OwnerUserId="123" LastEditorUserId="26916" LastEditDate="2017-09-09T15:10:36.097" LastActivityDate="2017-09-09T15:10:36.097" Title="Controlling mains (230 V) supply up to 5/10 amps using Arduino" Tags="|power|relay|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="236" PostTypeId="2" ParentId="235" CreationDate="2014-02-15T14:43:03.843" Score="6" Body="&lt;p&gt;The &lt;a href=&quot;https://www.sparkfun.com/products/10747&quot; rel=&quot;nofollow noreferrer&quot;&gt;PowerSwitch Tail 2&lt;/a&gt; is a great way for experimenters to control mains voltages. It is insulated and internally decoupled, so you only have to hook up 5v, gnd, and a signal line to control it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This model supports only 120V, but there are also &lt;a href=&quot;http://www.powerswitchtail.com/Pages/PSTKKit.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;kits&lt;/a&gt; for 230V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kHPjV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;image from sparkfun&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="84" LastEditDate="2014-02-16T14:51:00.807" LastActivityDate="2014-02-16T14:51:00.807" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="237" PostTypeId="1" CreationDate="2014-02-15T16:15:17.440" Score="1" ViewCount="1608" Body="&lt;p&gt;For a robotic project, I need to keep an Arduino powered up for a long time in an outdoor environment. What can I use to power the board?&#xA;If battery is the only solution, can the device tell me remotely that battery is getting low?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs to be powered for at least few days ( at least). The unit monitors an outdoor sensor that is shaded from sun but still exposed to wind and moisture. The unit does not move.&lt;/p&gt;&#xA;" OwnerUserId="197" LastEditorUserId="197" LastEditDate="2014-02-17T08:59:44.660" LastActivityDate="2014-02-17T08:59:44.660" Title="How to power Arduino externally for long term?" Tags="|power|" AnswerCount="1" CommentCount="4" ClosedDate="2014-02-17T19:11:56.487" ContentLicense="CC BY-SA 3.0" />
  <row Id="238" PostTypeId="2" ParentId="237" CreationDate="2014-02-15T16:29:38.010" Score="4" Body="&lt;p&gt;There are several options for Arduino power in an external environment.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/298&quot; rel=&quot;noreferrer&quot;&gt;Wall wart&lt;/a&gt;: Connects to a wall socket, provides a great long-term source of power&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/8483&quot; rel=&quot;noreferrer&quot;&gt;Rechargeable battery&lt;/a&gt;: Doesn't last long, but they can be recharged and monitored with a &lt;a href=&quot;https://www.sparkfun.com/products/10217&quot; rel=&quot;noreferrer&quot;&gt;low cost board&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10218&quot; rel=&quot;noreferrer&quot;&gt;Alkaline Battery&lt;/a&gt;: Last longer, there are some monitoring systems available.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/7840&quot; rel=&quot;noreferrer&quot;&gt;Solar&lt;/a&gt;: Only works when the sun is out, unless you combine it with a rechargable battery (&lt;a href=&quot;https://www.sparkfun.com/products/11496&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Nuclear power: NOT RECOMMENDED!!!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-15T16:29:38.010" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="239" PostTypeId="2" ParentId="221" CreationDate="2014-02-15T17:28:24.073" Score="17" Body="&lt;p&gt;In addition to what others have said (on which I fully agree), I would advise to read &lt;a href=&quot;http://learn.adafruit.com/memories-of-an-arduino/you-know-you-have-a-memory-problem-when-dot-dot-dot&quot;&gt;this adafruit article&lt;/a&gt; about memory; it's well written, explains a lot of things about memory and provide hints on how to optimize it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the read, I think you would get a quite complete answer to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum it up, you have 2 possible optimization targets (depending on where you memory problems are located):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Flash&lt;/strong&gt; (ie Program Memory); for this, you can:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;remove dead code (e.g. any code that is included but not used) and unused variables (that one also helps with SRAM)&lt;/li&gt;&#xA;&lt;li&gt;factor out duplicated code&lt;/li&gt;&#xA;&lt;li&gt;remove the bootloader altogether (you can gain between 0.5K for a UNO and 2 or 4K for other Arduino models); this has some downsides though&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;SRAM&lt;/strong&gt; (ie stack, heap and static data); for this you can:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;remove unused variables&lt;/li&gt;&#xA;&lt;li&gt;optimize the size of each variable (eg don't use long -4 bytes- if you need only int -2 bytes)&lt;/li&gt;&#xA;&lt;li&gt;use the right scope for your variables (and prefer stack to static data when possible)&lt;/li&gt;&#xA;&lt;li&gt;reduce buffers size to the strict minimum&lt;/li&gt;&#xA;&lt;li&gt;move constant data to PROGMEM (ie your static data will stay in Flash memory and won't get copied to SRAM at program start); that also applies to constant strings for which you can use &lt;code&gt;F()&lt;/code&gt; macro)&lt;/li&gt;&#xA;&lt;li&gt;avoid dynamic allocation if it is not absolutely necessary; you will avoid a &lt;em&gt;fragmented heap&lt;/em&gt; that may not shrink even after freeing memory&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An additional approach to reduce SRAM usage is also described (but seldom used, because it is a bit heavy when coding and not very efficient), it consists in using EEPROM to store data built by your program, but not used until later when some conditions occur, when data can be loaded back from EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-15T17:30:24.420" LastActivityDate="2014-03-15T17:30:24.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="241" PostTypeId="2" ParentId="221" CreationDate="2014-02-15T21:21:34.910" Score="10" Body="&lt;p&gt;There are two things to do if you run out of storage:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Somehow &quot;optimize&quot; your code so it needs less storage; or at least uses less of the particular kind of storage that you ran out of (and uses more of the kind of storage that you still have plenty of). Or,&lt;/li&gt;&#xA;&lt;li&gt;Add more storage.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are lots of tips online on how to do the first (and for the vast majority of things people do with the Arduino, the build-in storage is more than enough after &quot;optimizing&quot;).&#xA;So I'll focus on the second:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 3 things that use up flash or SRAM; each one needs a slightly different approach to adding storage:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;variable storage: it is possible to expand SRAM, as sachleen has already pointed out.&#xA;&lt;strong&gt;SRAM, FRAM, and NVSRAM&lt;/strong&gt; are all appropriate for rapidly-changing variables.&#xA;(While in principle you could use flash to store variables, then you have to worry about flash wear-out).&#xA;SPI (a serial protocol) is the easiest to connect to the Arduino.&#xA;The &lt;a href=&quot;http://playground.arduino.cc/Main/SpiRAM&quot;&gt;SpiRAM library&lt;/a&gt; works with the Microchip &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf&quot;&gt;23K256&lt;/a&gt; serial SRAM chip.&#xA;The Ramtron &lt;a href=&quot;http://www.cypress.com/?docID=44787&quot;&gt;FM25W256 serial FRAM&lt;/a&gt; chip (now owned by Cypress) also uses SPI.&#xA;The Cypress &lt;a href=&quot;http://www.cypress.com/?rID=45568&quot;&gt;CY14B101 NVSRAM&lt;/a&gt; also uses SPI.&#xA;Etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;constant data that needs to still be there the next time the power comes on: this is almost as simple as expanding SRAM. There are many external &lt;strong&gt;EEPROM, FRAM, NVSRAM, and FLASH&lt;/strong&gt; storage devices available.&#xA;Currently the lowest cost per MB are &lt;strong&gt;SD flash cards&lt;/strong&gt; (which can accessed via SPI).&#xA;The Ramtron FM25W256 (see above), the Cypress CY14B101 (see above), etc. can also store constant data.&#xA;Many expansion shields include a SD card slot,&#xA;and several &lt;a href=&quot;http://arduino.cc/en/Reference/SDCardNotes&quot;&gt;libraries&lt;/a&gt; and &lt;a href=&quot;http://learn.adafruit.com/adafruit-micro-sd-breakout-board-card-tutorial/look-out&quot;&gt;tutorials&lt;/a&gt; support reading and writing to (flash) SD cards.&#xA;(We can't use SRAM for this, because SRAM forgets everything when the power goes out).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;executable code: Unfortunately, expanding an Arduino's Flash memory to increase program space isn't possible. However, a programmer can always refactor a sketch to reduce code size at the expense of increasing data size and making it run slightly slower. (In theory, you could go so far as translate your entire sketch into some interpreted language, store that version of your sketch on a SD card, and then write a interpreter for that language that runs on the Arduino to fetch and execute instructions from the SD card -- &lt;a href=&quot;http://playground.arduino.cc//CommonTopics/ForthOnArduino&quot;&gt;Forth on Arduino&lt;/a&gt;, a BASIC interpreter, a Tom Napier Picaro interpreter, some application-specific language, etc.).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-02-15T21:21:34.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="242" PostTypeId="1" AcceptedAnswerId="243" CreationDate="2014-02-15T23:54:05.670" Score="12" ViewCount="21306" Body="&lt;p&gt;I'm currently trying to create an Arduino time clock by using the PJRC Time library (&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_Time.html&quot;&gt;http://www.pjrc.com/teensy/td_libs_Time.html&lt;/a&gt;). I know that since most of the Arduino boards are running with a 16MHz clock and a single resonator, the time can become &quot;out-of-sync&quot; after a certain period of time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I was wondering if anyone has an idea about the accuracy of the Time library when used on the Arduino DUE with a 84MHz clock. I've been testing it out and so far, the clock has been kept in sync for a few hours. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="202" LastActivityDate="2019-03-12T18:04:29.223" Title="Arduino Time Clock Accuracy" Tags="|time|arduino-due|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="243" PostTypeId="2" ParentId="242" CreationDate="2014-02-16T00:30:46.663" Score="12" Body="&lt;p&gt;The limitations of accuracy of the library depend on accuracy of the crystal. When they make, or cook, the crystal they can only make it to a certain degree accurate, also the environment of the crystal (temperature, humidity, etc.) play a role in the accuracy of it. Let's say you have a crystal that is off by .5 second every hour, great for short term, but if you expand that over a year it is over 1 hour off by that time. If you want something to keep an accurate time over a long period I suggest a real time clock (they still have inaccuracies), a GPS module, or an internet connect to sync with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further information look at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Quartz_clock&quot;&gt;wikipedia article on quartz crystals&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of a 84MHz crystal versus a 16MHz crystal will not necessarily improve the accuracy of the Arduino clock since the frequency of the crystal is more an indicator of processor speed than accuracy. The accuracy of the Arduino clock is primarily dependent on the accuracy of the crystal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I am no expert on crystal oscillators so if you see anything wrong here please let me know&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="10" LastEditDate="2014-02-16T16:41:13.303" LastActivityDate="2014-02-16T16:41:13.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="244" PostTypeId="2" ParentId="242" CreationDate="2014-02-16T07:50:26.030" Score="2" Body="&lt;p&gt;Your average system clock crystal will be off by several tens ppm (parts per million. They are great for stable and accurate timing of signals, but dramatic for keeping accurate time. Without special provisions the system crystal may be off by several seconds per day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to use a proper Real Time Clock, driven by what is commonly known as a 32768Hz watch crystal. These crystals are easily a factor 10 better in accuracy. You can either set up your own oscillator that interrupts the main processor and keep count in your Arduino sketch or you find a RTC breakout board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two random examples that pop up in Google with search terms &quot;RTC breakout&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cutedigi.com/breakout-board/ds1302-rtc-breakout.html&quot; rel=&quot;nofollow&quot;&gt;http://www.cutedigi.com/breakout-board/ds1302-rtc-breakout.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10160&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10160&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-16T07:50:26.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="245" PostTypeId="2" ParentId="242" CreationDate="2014-02-16T08:20:35.773" Score="3" Body="&lt;p&gt;The best way to know the accuracy of the resonator of your board is to measure it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do so, you can use the Arduino &lt;code&gt;millis()&lt;/code&gt; function of your board and write a small sketch that will:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;enable you to set the beginning time for measuring time drift (eg with a simple push button); you will trigger the button based on an &lt;strong&gt;accurate&lt;/strong&gt; time base.&lt;/li&gt;&#xA;&lt;li&gt;then repeatedly call millis() until at least 120h (&quot;arduino hours&quot;, that would be around 5 days) have elapsed&lt;/li&gt;&#xA;&lt;li&gt;display a signal when those 120h have elapsed (your sketch should probably &quot;warn&quot; you before the exact time has been reached so you get ready for measure)&lt;/li&gt;&#xA;&lt;li&gt;when the 120h have elapsed, check your reference time based (used in step 1.) and check how much time have elapsed (should be 120h +/- epsilon)&lt;/li&gt;&#xA;&lt;li&gt;once you know the drift of your clock, and provided your board will run in the same environental conditions (temperature mainly) of your measure, you can use it in your sketches to adjust the &lt;code&gt;millis()&lt;/code&gt; value every hour or so.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of course, this approach is &lt;strong&gt;far from perfect&lt;/strong&gt; as it requires &lt;strong&gt;human intervention&lt;/strong&gt; and thus will create additional time drifts during measurements, that's why you need to measure your clock time drifts over a long period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An improved approach would be to connect a high accuracy RTC clock (the accuracy must be chosen based on the accuracy you need for your application) to your board and adapt the sketch so that it automatically calculates the drift. Once you got the time drift you can do the same as step 5 above in your sketches, and disconnect the RTC clock from your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important points&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;measure the time drift on the board that will need clock adjustment later on (if you have several boards, you must measure one drift per board)&lt;/li&gt;&#xA;&lt;li&gt;ensure the stability of the environment in which your board will be used&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, if you really need high accuracy, then definitely connect an external clock source (e.g. RTC clock, GPS, NTP) to your board and use it as a SyncProvider for the PJRC library.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-16T08:20:35.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="246" PostTypeId="1" AcceptedAnswerId="659" CreationDate="2014-02-16T13:57:37.557" Score="20" ViewCount="26013" Body="&lt;p&gt;I am working on a mobile robot controlled via a wireless 2.4 GHz link.The receiver is connected to the Arduino Uno which serves onboard as the main controller. The most critical (and main) input channel coming from the receiver produces a very noisy signal, which leads to lots of minor changes in the output of the actuators, even though these are not needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;pre&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Z1yB0.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;                    Plot of the input of the Arduino in a 30 second interval.&lt;/pre&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for libraries that can perform efficient smoothing. Are there any signal smoothing libraries available for the Arduino (Uno)?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-08T11:54:29.480" LastActivityDate="2023-06-18T15:21:43.160" Title="Are there any signal smoothing libraries for Arduino?" Tags="|library|signal-processing|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="247" PostTypeId="2" ParentId="246" CreationDate="2014-02-16T14:45:56.470" Score="4" Body="&lt;p&gt;Have you tried a low pass filter? I found an example &lt;a href=&quot;http://arduino.cc/en/Tutorial/Smoothing&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; an another one &lt;a href=&quot;http://playground.arduino.cc/main/smooth&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these libraries have a list of data being read from the analog sensor of your choice which is averaged. Every new sensor value is added to the list, and the last one is thrown out, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;List: 3 4 3 3 4 3 5 3 2 3 4 3 &#xA;new reading added. old one thrown out&#xA;      /--                     /--&#xA;List: 5 3 4 3 3 4 3 5 3 2 3 4&#xA;list averaged&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-16T14:45:56.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="248" PostTypeId="2" ParentId="246" CreationDate="2014-02-16T16:34:31.177" Score="2" Body="&lt;p&gt;You could filter this digitally using a low pass filter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int valueFilt = (1-0.99)*value + 0.99*valueFilt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change the 0.99 to change the cut off frequency (closer to 1.0 is lower frequency). The actual expression for that value is exp(-2*pi*f/fs) where f is the cutoff frequency you want and fs is the frequency the data is sampled at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another type of &quot;digital filter&quot; is an event filter. It works well on data that has outliers; e.g. 9,9,8,10,9,25,9 . An event filter returns the most frequent value. Statistically this is the mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Statistical averages such as Mean, Mode etc.. can be calculated using the &lt;a href=&quot;http://playground.arduino.cc/Main/Average&quot; rel=&quot;nofollow&quot;&gt;Arduino Average Library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example taken from the Arduino Library page referred to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Average.h&amp;gt;&#xA;#define CNT 600&#xA;int d[CNT];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int i;&#xA;&#xA;  for(i=0; i&amp;lt;CNT; i++)&#xA;  {&#xA;    d[i] = random(500);&#xA;  }  &#xA;&#xA;  Serial.print(&quot;Mean: &quot;);&#xA;  Serial.print(mean(d,CNT),DEC);&#xA;  Serial.print(&quot; Mode: &quot;);&#xA;  Serial.print(mode(d,CNT),DEC);&#xA;  Serial.print(&quot; Max: &quot;);&#xA;  Serial.print(maximum(d,CNT),DEC);&#xA;  Serial.print(&quot; Min: &quot;);&#xA;  Serial.print(minimum(d,CNT),DEC);&#xA;  Serial.print(&quot; Standard deviation: &quot;);&#xA;  Serial.print(stddev(d,CNT),4);&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-02-16T16:34:31.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="249" PostTypeId="1" AcceptedAnswerId="252" CreationDate="2014-02-16T17:35:27.827" Score="6" ViewCount="1086" Body="&lt;p&gt;On the hardware side of things, what is involved in making the Arduino receive signals from a TV Remote? What kind of infrared receiver is needed? Do TV remotes use some kind of channels, encoding, or encryption requiring special receivers or else additional programming work to decrypt the signals?&lt;/p&gt;&#xA;" OwnerUserId="69" LastEditorUserId="220" LastEditDate="2014-02-23T23:16:58.043" LastActivityDate="2015-04-11T12:48:32.507" Title="Infrared TV Remote to Arduino" Tags="|remote-control|ir|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="250" PostTypeId="2" ParentId="249" CreationDate="2014-02-16T17:58:22.867" Score="1" Body="&lt;p&gt;A simple IR diode like &lt;a href=&quot;https://www.sparkfun.com/products/10266&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; can receive raw IR data. There are several chips which are designed to decode these signals, such as &lt;a href=&quot;https://www.sparkfun.com/products/8753&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yuUSq.png&quot; alt=&quot;Ir diode&quot;&gt;  ----------------  &lt;img src=&quot;https://i.stack.imgur.com/Pj4C0.png&quot; alt=&quot;Ir decoder chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ir Diode ------------------------------- Ir Decoder&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-16T17:58:22.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="251" PostTypeId="2" ParentId="124" CreationDate="2014-02-16T18:29:21.220" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How does one prepare clothing with embedded electronics for washing?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remove the battery(ies) and other power supplies, and set them far away from the water. Buzzers and speakers also.&lt;/li&gt;&#xA;&lt;li&gt;Gently wash clothing (including the Lilypad, LEDs, resistors, capacitors, integrated circuits, accelerometers, magnetometers, Bluetooth modules, GPS modules, etc.) by hand with a mild detergent.&lt;/li&gt;&#xA;&lt;li&gt;Drip dry, or manually dry with a hair-dryer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9266&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;LilyPad ... They're even washable!&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://web.media.mit.edu/~leah/LilyPad/build/accelero_shirt.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;accelerometer shirt ... is washable.&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,10382.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Are LEDs and Resistors Washable?&quot;&lt;/a&gt; (Yes!)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/98556/remove-after-washing-on-piezo-buzzer&quot;&gt;&quot;Remove After Washing&quot; on Piezo Buzzer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-02-16T18:29:21.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="252" PostTypeId="2" ParentId="249" CreationDate="2014-02-16T18:42:52.777" Score="3" Body="&lt;p&gt;The most common (not sure what others are used) carrier frequency is 38khz. You need an IR receiver tuned to that frequency to get the signal from the remove. See &lt;a href=&quot;http://learn.adafruit.com/ir-sensor/ir-remote-signals&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; for way more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no encryption or special receivers needed as long as the carrier frequencies match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's really all the hardware you need. On the software side of things, you read this signal and decode it. There's a neat little library for doing exactly that. It's called &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;Arduino IRemote&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It even has an example sketch which tells you just what the decoded value is of whatever button you pressed so you can use that in your other programs.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-16T18:42:52.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="253" PostTypeId="1" CreationDate="2014-02-16T18:48:57.677" Score="10" ViewCount="1133" Body="&lt;p&gt;How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="11" LastEditDate="2014-02-16T21:06:17.663" LastActivityDate="2015-03-31T17:14:23.483" Title="How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?" Tags="|android|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="254" PostTypeId="2" ParentId="253" CreationDate="2014-02-16T20:27:00.780" Score="6" Body="&lt;p&gt;Android devices usually don't have a USB host: they expect to be connected to some smarter device like your computer. Same goes with Arduino.&#xA;For this reason Arduino made the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardADK&quot;&gt;Mega ADK&lt;/a&gt; (that means &lt;a href=&quot;https://developer.android.com/tools/adk/index.html&quot;&gt;Accessory Development Kit&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mega ADK and Due act as USB hosts and can be connected directly to your Android phone. If you already have a board, another option is to get a USB host shield to add USB host capababilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your sketch will tell the phone what kind of accessory application it is and your phone will download the appropriate application from the store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a book about connecting &lt;a href=&quot;http://www.wrox.com/WileyCDA/WroxTitle/Professional-Android-Open-Accessory-Programming-with-Arduino.productCd-1118454766,descCd-DOWNLOAD.html&quot;&gt;Arduino to Android&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-02-16T20:27:00.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="255" PostTypeId="2" ParentId="40" CreationDate="2014-02-16T22:58:05.850" Score="8" Body="&lt;p&gt;In addition to the mentioned IDEs you can use Xcode with &lt;a href=&quot;http://embedxcode.weebly.com/&quot;&gt;embedXcode&lt;/a&gt; if you use a mac. The IDE has a great file structure and support for a lot of boards. For big and complex projects it is really good. I like to use vim or the arduino IDE for simpler and less complex sketches/projects. &lt;/p&gt;&#xA;" OwnerUserId="201" LastActivityDate="2014-02-16T22:58:05.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="256" PostTypeId="2" ParentId="141" CreationDate="2014-02-16T23:04:50.190" Score="1" Body="&lt;p&gt;Because avr-g++ should support all standard C / C++ constructs it is possible to code inline assembly. More info on &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,40916.0.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; arduino.cc forum thread&lt;/p&gt;&#xA;" OwnerUserId="201" LastActivityDate="2014-02-16T23:04:50.190" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="257" PostTypeId="5" CreationDate="2014-02-16T23:28:38.343" Score="0" Body="&lt;p&gt;The arduino DUE is different than most Arduino boards on the market since it runs at 3.3V. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), a 84 MHz clock, an USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button and an erase button.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Providing higher voltages, like 5V to an I/O pin could damage the board.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The board contains everything needed to support the microcontroller; simply connect it to a computer with a micro-USB cable or power it with a AC-to-DC adapter or battery to get started. The Due is compatible with all Arduino shields that work at 3.3V and are compliant with the 1.0 Arduino pinout.&#xA;  The Due follows the 1.0 pinout:&#xA;  TWI: SDA and SCL pins that are near to the AREF pin.&#xA;  The IOREF pin which allows an attached shield with the proper configuration to adapt to the voltage provided by the board. This enables shield compatibility with a 3.3V board like the Due and AVR-based boards which operate at 5V.&#xA;  An unconnected pin, reserved for future use.&#xA;  &lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoDue_Front_450px.jpg&quot; &gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow noreferrer&quot;&gt;Full specs and information&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other features:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;32 bit microcontroller: 4 byte wide instructions during one CPU cycle.&lt;/li&gt;&#xA;&lt;li&gt;84 MHz MCU clock (Uno is 16 MHz on a less efficient architecture.)&lt;/li&gt;&#xA;&lt;li&gt;96KB SRAM&lt;/li&gt;&#xA;&lt;li&gt;512KB Flash&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This gives it much more power than a standard ATmega chip.&lt;/p&gt;&#xA;" OwnerUserId="201" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.083" LastActivityDate="2014-05-03T09:19:36.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="258" PostTypeId="4" CreationDate="2014-02-16T23:28:38.343" Score="0" Body="Arduino DUE is an microcontroller card based on the Atmel SAM3X8E ARM Cortex-M3 CPU. This is a 32bit ARM core MCU." OwnerUserId="201" LastEditorUserId="201" LastEditDate="2014-02-16T23:53:44.720" LastActivityDate="2014-02-16T23:53:44.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="259" PostTypeId="5" CreationDate="2014-02-16T23:58:24.540" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-16T23:58:24.540" LastActivityDate="2014-02-16T23:58:24.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="260" PostTypeId="4" CreationDate="2014-02-16T23:58:24.540" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-16T23:58:24.540" LastActivityDate="2014-02-16T23:58:24.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="261" PostTypeId="1" CreationDate="2014-02-17T02:24:00.157" Score="14" ViewCount="13260" Body="&lt;p&gt;I have a simple sketch that prints out &quot;Hello World&quot; to the serial, but I'm getting a bunch of gibberish instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;Hello World&quot;);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why isn't it printing &quot;Hello World&quot; like the code says?&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="368" LastEditDate="2014-10-29T22:33:01.173" LastActivityDate="2019-11-16T10:34:36.403" Title="Serial data showing up weird" Tags="|serial|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="262" PostTypeId="2" ParentId="261" CreationDate="2014-02-17T02:24:00.157" Score="10" Body="&lt;p&gt;The board and terminal are probably not using the same baud rate. Check the bottom right corner of the Arduino Serial Terminal and make sure it is set to 9600.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Serial Data&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Serial communication works by sending the entire data stream one bit at a time. This is in contrast to the standard parallel port which sends one byte at a time. Both devices need to know at what speed the data is being sent. Furthermore, both devices need to be operating at the same speed. This is called the baud rate.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Baud Rate&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Baud really just means pulses per second. In the context of serial communication, it means how many bits are transmitted per second. One of the most common values is 9600, but there are other common ones which are factors or multiples of 9600. It doesn't really matter, though, as long as both devices operate at the same speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm sending you messages faster than you are getting them, you lose data. If I am sending you messages slower than you are receiving them, you get nonsense mixed in with what I sent you.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Data, Parity, Stop bits&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;If you look at the documentation for &lt;a href=&quot;http://arduino.cc/en/Serial/begin&quot;&gt;&lt;code&gt;begin()&lt;/code&gt;&lt;/a&gt;, you'll see it can take two parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(speed)&#xA;Serial.begin(speed, config)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully you understand speed now, it is the bits per second at which the Arduino will communicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second parameter, &lt;code&gt;config&lt;/code&gt;, lets you configure some other things about the serial data transmission. These are the Data, &lt;a href=&quot;http://en.wikipedia.org/wiki/Parity_bit&quot;&gt;Parity&lt;/a&gt;, and Stop bits. You'll see on the page it has values like &lt;code&gt;5N1&lt;/code&gt;, &lt;code&gt;6N1&lt;/code&gt; and &lt;code&gt;SERIAL_8N1 (the default)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first number represents how many data bits. The second character tells you what kind of parity bit there is. &lt;code&gt;E&lt;/code&gt; for even parity, &lt;code&gt;O&lt;/code&gt; for odd parity, or &lt;code&gt;N&lt;/code&gt; for no parity. The third number tells you how many stop bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really, with 8N1, we have 10 bits being sent for each 8 bits of &quot;your&quot; data. 1 start bit, 8 data bits, and 1 stop bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, both sides need to agree on this information as well as the speed. The Arduino Serial Terminal doesn't give you the option of changing these settings, but others do, so you'll need to be sure all of these configuration settings are the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info on wiki: &lt;a href=&quot;http://en.wikipedia.org/wiki/Asynchronous_serial_communication&quot;&gt;Asynchronous serial communication&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-17T02:24:00.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="264" PostTypeId="2" ParentId="253" CreationDate="2014-02-17T03:36:28.923" Score="2" Body="&lt;p&gt;The USB protocol requires one end to be a &quot;host&quot; and the other end to be a &quot;peripheral&quot;, and it doesn't work if the devices at both ends of the cable are &quot;peripherals&quot;.&#xA;Alas, most Arduinos and many early Android devices are &quot;peripherals&quot;, so connecting such devices with a standard USB cable doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some modern Android devices support &quot;OTG&quot;, so in theory one could make the Android end of the cable the &quot;host&quot;. Has anyone gotten this to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to somehow make the Arduino end of the cable the &quot;host&quot;, and the Android end of the cable the &quot;peripheral&quot;.&#xA;That's the approach taken by&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Microbridge &lt;a href=&quot;https://en.wikipedia.org/wiki/Microbridge&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;https://code.google.com/p/microbridge/&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The IOIO board &lt;a href=&quot;https://www.sparkfun.com/tutorials/280&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;https://github.com/ytai/ioio/wiki&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The Android Accessory Development Kit (ADK) &lt;a href=&quot;http://makezine.com/2011/05/12/why-google-choosing-arduino-matters-and-the-end-of-made-for-ipod-tm/&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;http://developer.android.com/tools/adk/&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt; (c)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(The Amarino &lt;a href=&quot;http://www.amarino-toolkit.net/&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; and Cellbots &lt;a href=&quot;http://www.cellbots.com/&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;https://code.google.com/p/cellbots/&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt; take yet another completely different approach).&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-02-17T03:36:28.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="266" PostTypeId="2" ParentId="104" CreationDate="2014-02-17T03:48:20.310" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any easy way to upload a program/sketch from an iPad or&#xA;  Android tablet without a shield (Bluetooth or Wi-Fi)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you don't mind re-writing your program in an interpreted language,&#xA;one option is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install an &lt;a href=&quot;http://playground.arduino.cc/CommonTopics/InterpretedLanguages&quot; rel=&quot;nofollow noreferrer&quot;&gt;interpreter on the Arduino&lt;/a&gt;, perhaps using the standard Arduino IDE running on a standard desktop PC -- like the bootloader, this only needs to be done once.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use your favorite terminal emulator on the tablet&lt;/li&gt;&#xA;&lt;li&gt;Somehow link the Arduino and the Android together, and tell the terminal emulator to talk over that link.(*)&lt;/li&gt;&#xA;&lt;li&gt;Tell the terminal emulator to send the (more-or-less human-readable plain text) program to the interpreter over the link. (No compiler necessary on the tablet).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(*) There are several different ways to make this link; some of them are mentioned at &lt;a href=&quot;https://arduino.stackexchange.com/questions/253/how-do-i-write-an-arduino-sketch-and-an-android-application-to-talk-to-each-othe&quot;&gt;How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-02-17T03:48:20.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="269" PostTypeId="1" AcceptedAnswerId="270" CreationDate="2014-02-17T04:28:35.933" Score="3" ViewCount="2197" Body="&lt;p&gt;Spanish company Libelium makes this pretty impressive sensor board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.libelium.com/products/waspmote/sensors/&quot; rel=&quot;nofollow&quot;&gt;http://www.libelium.com/products/waspmote/sensors/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for their Waspmote series of boards.  These are not meant for Arduino compatibility, but they are not only interesting for combining so many sensors, the availability of calibrated sensor sets makes it even more unique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here is the challenge: can we reasonably leverage these from an Uno or a Mega?&lt;/p&gt;&#xA;" OwnerUserId="213" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:52.103" LastActivityDate="2014-02-25T06:32:52.103" Title="Using the Waspmote Sensor Board" Tags="|arduino-uno|sensors|arduino-mega|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="270" PostTypeId="2" ParentId="269" CreationDate="2014-02-17T04:48:01.030" Score="3" Body="&lt;p&gt;Too long for a comment...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at some of their docs for &lt;a href=&quot;http://www.libelium.com/development/waspmote/examples/ga-11-co-sensor-on-socket4-reading/&quot; rel=&quot;nofollow&quot;&gt;examples&lt;/a&gt;. seems like they have a very similar platform to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Their forums suggest making the connection is not trivial, but may be&#xA;  possible: &lt;a href=&quot;http://www.libelium.com/forum/viewtopic.php?f=15&amp;amp;t=8811&quot; rel=&quot;nofollow&quot;&gt;http://www.libelium.com/forum/viewtopic.php?f=15&amp;amp;t=8811&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All that's saying is you can't simply plug in a sensor into your Arduino like a shield, because it's not a shield. You'd have to hook up the connections to the right pins and then use their libraries and code to communicate with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That involves reading their documentation and code to figure out what pins it uses to communicate with what. You may have to modify the code slightly to work with Arduino (mainly changing pin numbers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all, I wouldn't invest my time or effort into it. Don't lock yourself into a product that isn't intended to be used the way you're using it. You'll get no support from the company and there's no guarantee future versions of their product will work. Or things like this (from the &lt;a href=&quot;http://www.libelium.com/forum/viewtopic.php?f=15&amp;amp;t=8811&quot; rel=&quot;nofollow&quot;&gt;forum link&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Anyway, I'm afraid the Libelium's sales policy implies a minimum first&#xA;  order including five Waspmotes, five batteries and one Gateway.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simply not worth the effort. You'd be much better off making your own sensor board to fit your requirements.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-17T04:48:01.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="271" PostTypeId="2" ParentId="253" CreationDate="2014-02-17T09:54:06.537" Score="2" Body="&lt;p&gt;Processing is a great place to get started with device to device communication.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interface and language are very similar to Arduino and there are many examples to get you started. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Processing&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Interfacing/Processing&lt;/a&gt;   &lt;/p&gt;&#xA;" OwnerUserId="160" LastActivityDate="2014-02-17T09:54:06.537" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="272" PostTypeId="2" ParentId="253" CreationDate="2014-02-17T14:00:41.933" Score="3" Body="&lt;h2&gt;You never mentioned your tablet model... or Arduino model&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are some tablets designed to work with USB flash drives and printers. This is called OTG (on the go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You need:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A tablet supporting OTG&lt;/li&gt;&#xA;&lt;li&gt;An OTG adapter that fits into your tablets USB slot and is compatible&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.primavera.arduino.listener&quot; rel=&quot;nofollow&quot;&gt;The Arduino Uno Communicator App&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno (or clone) [Note: It says that it works with Atmega16U2 or Atmega8U2 programmed as a USB-to-serial converter so I would assume that that would cover a few boards more than the Uno.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Another alternitive is to look into &lt;a href=&quot;https://www.google.com/search?q=arduino+bluetooth&amp;amp;qscrl=1&amp;amp;tbm=isch&amp;amp;imgil=WyPC4O05Xn4rhM%253A%253Bhttps%253A%252F%252Fencrypted-tbn2.gstatic.com%252Fimages%253Fq%253Dtbn%253AANd9GcSfTtWqIuN9YYdd90OO_tlxsvLUYhV_pl7NfaMhHDzSRq9N6W9rNA%253B1200%253B1200%253B1soQc4CzMzh0MM%253Bhttp%25253A%25252F%25252Fm.dhgate.com%25252Fproduct%25252Fjy-mcu-arduino-bluetooth-wireless-serial%25252F151048482.html&amp;amp;source=iu&amp;amp;usg=__KyMLS4aeubxJnDaMvprgRgADxAs%3D&amp;amp;sa=X&amp;amp;ei=1BUCU635IYmEygGO1oHwCQ&amp;amp;ved=0CGkQ9QEwBg&amp;amp;biw=1280&amp;amp;bih=899&quot; rel=&quot;nofollow&quot;&gt;Bluetooth&lt;/a&gt; (Note: I just picked a random link but there are hundreds of similar BT adapters)&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-02-17T14:00:41.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="273" PostTypeId="1" AcceptedAnswerId="275" CreationDate="2014-02-17T15:18:42.393" Score="19" ViewCount="35707" Body="&lt;p&gt;I am used to relays some, and they are useful, especially for large loads like a incandescent light bulb or other 120V AC device. However, it seems like overkill to use a relay for a bunch of LEDs linked together (parallel) that use 60 mA (too much for the Arduino). Also, it wouldn't work if you wanted to turn it on/off frequently or do PWM. &lt;strong&gt;I've heard some about transistors and MOSFETS and know a little about them. When should I use each one and how do I know what type to get?&lt;/strong&gt; Also, it seems like relays can be more expensive than transistors/MOSFETS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; How can I use these with my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-17T15:47:18.013" LastActivityDate="2021-08-02T13:58:50.607" Title="When should I use a transistor, mosfet, and when should I use a relay?" Tags="|relay|mosfet|transistor|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="274" PostTypeId="1" AcceptedAnswerId="277" CreationDate="2014-02-17T15:26:30.470" Score="9" ViewCount="1765" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Related to:&#xA;  &lt;a href=&quot;https://arduino.stackexchange.com/questions/189/what-happens-if-there-is-a-runtime-error&quot;&gt;What happens if there is a runtime error?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This question is similar to the one above, however this is an alternate situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 999;&#xA;pinMode(pin, OUTPUT);&#xA;digitalWrite(pin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would happen in this instance? The compiler might catch it but if you used a random number would the IDE catch it?&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-02-17T18:11:35.250" Title="What will happen when I use an invalid pin number?" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="275" PostTypeId="2" ParentId="273" CreationDate="2014-02-17T15:32:47.543" Score="11" Body="&lt;p&gt;Transistors (such as Bipolar Junction Transistors (BJT)) are solid state switchers, that is, they don't have any moving parts. &lt;a href=&quot;https://en.wikipedia.org/wiki/MOSFET&quot; rel=&quot;nofollow noreferrer&quot;&gt;Metal-Oxide-Semiconductor Field-Effect Transistors&lt;/a&gt; (MOSFET) are also transistors, but are voltage controlled, whereas classical BJTs are current-controlled. Relays are more expensive, but they have moving parts.&lt;/p&gt;&#xA;&lt;p&gt;BJTs and MOSFETs produce a lot of heat (with high currents). They both have three pins (usually) called the base, collector and emitter (in the case of BJT) or gate, source, drain (in the case of MOSFET). &lt;a href=&quot;http://www.technologystudent.com/elec1/transis1.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;More info here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Relays use a magnet to control the position of a metal switch. They generally take more power than an Arduino pin can deliver, and therefore they are often controlled by a transistor. Relays can usually switch more current than either a transistor or a MOSFET.&lt;/p&gt;&#xA;&lt;p&gt;There are also Solid State Relays (SSR), which have a triac (a device similar to a transistor) in them. These can't switch as much as a normal relay, but they generally have better ratings than MOSFETs and BJT. &lt;a href=&quot;https://www.sparkfun.com/products/10636&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/71AlP.png&quot; alt=&quot;from Sparkfun&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="6936" LastEditDate="2021-01-01T06:07:46.667" LastActivityDate="2021-01-01T06:07:46.667" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="276" PostTypeId="2" ParentId="274" CreationDate="2014-02-17T15:50:12.013" Score="4" Body="&lt;p&gt;In the standard libraries, there are macros designed for converting pins to ports, which are used in assembly. Here they are for the Uno from Arduino 1.0.5:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define digitalPinToPCICR(p)    (((p) &amp;gt;= 0 &amp;amp;&amp;amp; (p) &amp;lt;= 21) ? (&amp;amp;PCICR) : ((uint8_t *)0))&#xA;#define digitalPinToPCICRbit(p) (((p) &amp;lt;= 7) ? 2 : (((p) &amp;lt;= 13) ? 0 : 1))&#xA;#define digitalPinToPCMSK(p)    (((p) &amp;lt;= 7) ? (&amp;amp;PCMSK2) : (((p) &amp;lt;= 13) ? (&amp;amp;PCMSK0) : (((p) &amp;lt;= 21) ? (&amp;amp;PCMSK1) : ((uint8_t *)0))))&#xA;#define digitalPinToPCMSKbit(p) (((p) &amp;lt;= 7) ? (p) : (((p) &amp;lt;= 13) ? ((p) - 8) : ((p) - 14)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are more, but I won't show them here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe your program would subtract 14 from 999, which would still be too big for the brogram. It would then try to point to the 985th element of the &lt;code&gt;digital_pn_to_bit_mask_PGM&lt;/code&gt; array, which only contains 20 elements. This would most likely end up screwing the Arduino by pointing to a random spot in progmem.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-17T15:50:12.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="277" PostTypeId="2" ParentId="274" CreationDate="2014-02-17T16:48:05.083" Score="10" Body="&lt;p&gt;The compiler will not detect any error and the code will compile and execute. Hence, to see what happens we need to explore the behind-the-scenes magic. &lt;em&gt;For a summary, skip to end.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The second line in your code is where the magic will happen and thats where we need to focus. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The portion of &lt;code&gt;pinMode&lt;/code&gt; relevant to this discussion is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void pinMode(uint8_t pin, uint8_t mode) &#xA;{&#xA;&#xA;    uint8_t bit = digitalPinToBitMask(pin); //The first instance where pin is used&#xA;    uint8_t port = digitalPinToPort(pin);&#xA;&#xA;    if (port == NOT_A_PIN) return;&#xA;&#xA;//Do something&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The complete implementation can be found in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/wiring_digital.c&quot;&gt;wiring_digital.c&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, here, &lt;code&gt;digitalPinToBitMask&lt;/code&gt; seems to be using &lt;code&gt;pin&lt;/code&gt; to compute an intermediate bit. Exploring further, &lt;code&gt;digitalPinToBitMask&lt;/code&gt; is a macro defined in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/cc6d7cdbd1f97aa90ffcb759b5fc4c5ba553304e/hardware/arduino/cores/arduino/Arduino.h&quot;&gt;&lt;code&gt;Arduino.h&lt;/code&gt;&lt;/a&gt; whose definition is this one-liner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This weird looking one liner does a very simple task. It indexes the P&lt;sup&gt;th&lt;/sup&gt; element in the array &lt;code&gt;digital_pin_to_bit_mask_PGM&lt;/code&gt; and returns it. This array &lt;code&gt;digital_pin_to_bit_mask_PGM&lt;/code&gt; is defined in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/2a8c06381fbc6fdb7e6363d0cb5d1c16019ccab0/hardware/arduino/variants/standard/pins_arduino.h&quot;&gt;&lt;code&gt;pins_arduino.h&lt;/code&gt;&lt;/a&gt; or the pin map for the specific board being used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {&#xA;    _BV(0), /* 0, port D */&#xA;    _BV(1),&#xA;    _BV(2),&#xA;    _BV(3),&#xA;    _BV(4),&#xA;    _BV(5),&#xA;    _BV(6),&#xA;    _BV(7),&#xA;...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This array has 20 elements in total, so we are out of luck. 999 will index a memory location in the flash memory outside of this array, thereby leading to unpredictable behavior. &lt;em&gt;Or will it?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We still have another line of defense against runtime anarchy. Its the next line of the function &lt;code&gt;pinMode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t port = digitalPinToPort(pin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;digitalPinToPort&lt;/code&gt; takes us along a similar path. It is defined as a macro along with &lt;code&gt;digitalPinToBitMask&lt;/code&gt;. Its definition is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, we index the P&lt;sup&gt;th&lt;/sup&gt; element of &lt;code&gt;digital_pin_to_port_PGM&lt;/code&gt; which is an array defined in the pin map:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t PROGMEM digital_pin_to_port_PGM[] = {&#xA;    PD, /* 0 */&#xA;    PD,&#xA;    ....&#xA;    PC,&#xA;    PC,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This array contains 20 elements, so 999 is again out of range. Again, this command reads and returns a value from flash memory of whose value we cannot be certain. This will again lead to unpredictable behavior from here on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is still one last line of defense. That is the &lt;code&gt;if&lt;/code&gt; check in &lt;code&gt;pinMode&lt;/code&gt; on the return value of &lt;code&gt;digitalPinToPort&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (port == NOT_A_PIN) return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;NOT_A_PIN&lt;/code&gt; is defined as 0 in &lt;code&gt;Arduino.h&lt;/code&gt;. So, if the returned byte from &lt;code&gt;digitalPinToPort&lt;/code&gt; happens to be zero, then &lt;code&gt;pinMode&lt;/code&gt; will silently fail and return. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, &lt;code&gt;pinMode&lt;/code&gt; cannot save us from anarchy. 999 is destined to result in doom.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR, the code will execute and the result of this will be unpredictable.&lt;/strong&gt; Most likely, no pin will be set to &lt;code&gt;OUTPUT&lt;/code&gt;, and &lt;code&gt;digitalWrite&lt;/code&gt; will fail. If you happen to have exceptionally bad luck, then a random pin may get set to &lt;code&gt;OUTPUT&lt;/code&gt;, and &lt;code&gt;digitalWrite&lt;/code&gt; may set it to &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-17T16:54:20.897" LastActivityDate="2014-02-17T16:54:20.897" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="278" PostTypeId="2" ParentId="273" CreationDate="2014-02-17T18:10:17.507" Score="7" Body="&lt;p&gt;Big differences between relays and transistors are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;relays are all-or-nothing (like switches) whereas transistors can transmit more or less current through the &lt;strong&gt;collector&lt;/strong&gt; based on the current present on their &lt;strong&gt;base&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;relays provide isolation between the command circuit (the one with the electromagnet) and the controlled circuit (the one on the switch side of the relay)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to play with arduino, you definitely need to know about transistors; using relays is more akin to special applications.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-17T18:10:17.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="279" PostTypeId="1" CreationDate="2014-02-17T22:27:42.840" Score="29" ViewCount="37726" Body="&lt;p&gt;Once you have uploaded a sketch to one of your Arduino boards, it is hard to know exactly what source code led to that sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, you may change the source code of your sketch on your PC without updating it (in binary format) to your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had the idea of setting up a kind of &quot;&lt;em&gt;sketch repository&lt;/em&gt;&quot; that would be populated as soon as I upload a sketch to one of my boards. Then I could retrieve, later on, the source code for a sketch running on any of my boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For such a repository, I would first need to have an &quot;&lt;em&gt;index&lt;/em&gt;&quot; that would enable me to know &lt;strong&gt;which board&lt;/strong&gt; the sketch source code is linked to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, such an index should be unique for every single arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence my question: how can I get a unique ID for an Arduino board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my current list of boards (the miniumum list to be supported by a single unique ID approach):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UNO R3&lt;/li&gt;&#xA;&lt;li&gt;Mega 2560&lt;/li&gt;&#xA;&lt;li&gt;Yun&lt;/li&gt;&#xA;&lt;li&gt;Arduino Robot (that must be 2 Leonardo equivalent boards)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the future, I may also build my own boards (Uno equivalent but barebones, without FTDI), hence if an approach also supports these that would be better.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="10794" LastEditDate="2015-09-12T00:54:21.913" LastActivityDate="2023-04-04T14:36:23.050" Title="How can I get a unique ID for all my Arduino boards?" Tags="|arduino-uno|arduino-mega|arduino-yun|system-design|" AnswerCount="8" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="280" PostTypeId="2" ParentId="279" CreationDate="2014-02-17T23:37:06.103" Score="13" Body="&lt;p&gt;The chip doesn't have any sort of unique ID as far as I know.... but you could program one into the EEPROM of your boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/EEPROM&quot;&gt;EEPROM documetnation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would write to a specific address and then future sketches can read the ID and do whatever with it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You may also be able to see a unqiue ID or address on the host side. I don't know enough about USB devices to tell you more, but the chip handling USB communication might have a unique ID you could use. Your Arduino code would not be able to use this, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, just use a label maker and put a label on each board.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-02-17T23:42:41.960" LastActivityDate="2014-02-17T23:42:41.960" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="281" PostTypeId="2" ParentId="279" CreationDate="2014-02-17T23:45:14.113" Score="8" Body="&lt;p&gt;Some boards, when connected to a computer, publish their serial number. My Arduino Uno R3 says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[16818.451423] usb 3-2: SerialNumber: 85235353137351E02242&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though I'm not sure how unique it is.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-02-17T23:45:14.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="282" PostTypeId="2" ParentId="279" CreationDate="2014-02-18T05:19:19.273" Score="4" Body="&lt;p&gt;To the best of my knowledge the USB chips all come with a unique serial number, at least for the FTDI chips. On Linux you can easily assign unique device names from that, check &lt;a href=&quot;http://wirespeed.xs4all.nl/mediawiki/index.php/Udev_rules_file_for_Arduino_boards&quot; rel=&quot;nofollow&quot;&gt;my website&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, what you are describing is pretty much a simple form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Revision_control&quot; rel=&quot;nofollow&quot;&gt;version control&lt;/a&gt;. Make sure your source files have version numbers. To identify your Arduino, you can make it &lt;code&gt;Serial.Print();&lt;/code&gt; name and version of the code during &lt;code&gt;setup();&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-18T05:36:36.733" LastActivityDate="2014-02-18T05:36:36.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="283" PostTypeId="2" ParentId="279" CreationDate="2014-02-18T08:27:19.557" Score="16" Body="&lt;p&gt;There are a number of techniques you could use here to get a unique ID.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;FTDI chips have a unique serial number programmed onto them. This can only be accessed from the PC side of the connection as far as I am aware.&lt;/li&gt;&#xA;&lt;li&gt;Some of the chips with built in USB (e.g. ATmega8U2/16U2/32U2) have a unique ID in the signature data, normally used for USB. Can easily be accessed from both sides of the connection. This includes the ATmega16U2 that is used as the USB-&gt;Serial bridge Arduino Uno R3.&lt;/li&gt;&#xA;&lt;li&gt;Some of the chips with built in USB but no unique ID in the signature will still have a unique ID programmed into the USB stack (e.g. LUFA) used for the bootloader or DFU (Device Firmware Upgrade).&lt;/li&gt;&#xA;&lt;li&gt;There are many chips with globally unique serial IDs in them e.g. the Microchip &lt;a href=&quot;http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en538621&quot;&gt;11AA02E48&lt;/a&gt;, all of the Dallas 1-Wire sensors (including the common DS18B20 temperature sensor), and other serial EEPROMS. I've used these in production hardware that must have a unique MAC address.&lt;/li&gt;&#xA;&lt;li&gt;You could modify the standard Optiboot bootloader (or whichever boat loader you use) so that it can hold and respond with a unique ID. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The problem with these is that there is no option except 5 that will work across all boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your solution is going to be a generic one, I would suggest that using a USB ID is not the way forwards. I have ~30 Arduino-based boards, and only 5 of them have built in USB hardware. All the rest of them need an external FTDI cable to be programmed. This means they would all have the same ID. &lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-02-18T08:27:19.557" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="284" PostTypeId="5" CreationDate="2014-02-18T12:10:10.547" Score="0" Body="&lt;p&gt;This tag is for questions regarding powering and/or power consumption of Arduino systems.  &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The most common ways to power an Arduino:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Wall_wart&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wall-wart&lt;/a&gt;&lt;/strong&gt;&#xA;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/7/7f/Wall-Wart-AC-Adapter.jpg&quot; &gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Battery&lt;/strong&gt; (with some sort of external circuitry for making sure the voltage is correct.) This is also used sometimes in conjunction with solar panels to act as a &quot;buffer.&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;USB&lt;/strong&gt; is often used for small projects that are on the breadboard and don't require much power (no motors, etc.).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Power consumption&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Atmega processors in particular are designed to have low power consumption for battery-driven applications. Under the right circumstances you can get power consumption down to 100 nA (0.1 µA). See this chart:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WP7v0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WP7v0.png&quot; alt=&quot;Power consumption chart&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circled area shows 100 nA consumption when running from 3 volts at 25 °C with the watchdog timer (and various other things) disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;General techniques you can use to save power are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Run the processor at a lower frequency&lt;/li&gt;&#xA;&lt;li&gt;Run the processor at a lower voltage&lt;/li&gt;&#xA;&lt;li&gt;Turn off unneeded internal modules in software (eg. SPI, I2C, Serial, ADC)&lt;/li&gt;&#xA;&lt;li&gt;Turn off brownout detection&lt;/li&gt;&#xA;&lt;li&gt;Turn off the Analog-to-Digital converter (ADC)&lt;/li&gt;&#xA;&lt;li&gt;Turn off the watchdog timer&lt;/li&gt;&#xA;&lt;li&gt;Put the processor to sleep&lt;/li&gt;&#xA;&lt;li&gt;Don't use inefficient voltage regulators - if possible run directly from batteries&lt;/li&gt;&#xA;&lt;li&gt;Don't use power-hungry displays (eg. indicator LEDs, backlit LCDs)&lt;/li&gt;&#xA;&lt;li&gt;Arrange to wake the processor from sleep only when needed&lt;/li&gt;&#xA;&lt;li&gt;Turn off (with a MOSFET) external devices (eg. SD cards, temperature sensors) until needed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://jeelabs.org/tag/lowpower/&quot; rel=&quot;nofollow noreferrer&quot;&gt;JeeLabs: Posts Tagged &quot;LowPower&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Low Power - How To Run ATmega328P For a Year On Coin Cell Battery&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.openhomeautomation.net/arduino-battery/&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to Run an Arduino for Years on a Battery&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.100" LastActivityDate="2015-09-04T03:17:51.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="285" PostTypeId="4" CreationDate="2014-02-18T12:10:10.547" Score="0" Body="This tag is for questions regarding powering and/or power consumption of Arduino systems.  " OwnerUserId="201" LastEditorUserId="220" LastEditDate="2014-03-18T21:29:27.993" LastActivityDate="2014-03-18T21:29:27.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="286" PostTypeId="1" AcceptedAnswerId="288" CreationDate="2014-02-18T15:11:41.877" Score="81" ViewCount="182059" Body="&lt;p&gt;Is there a way I can have multiple parts of the program running together without doing multiple things in the same code block?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thread waiting for an external device while also blinking a LED in another thread.&lt;/p&gt;&#xA;" OwnerUserId="193" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:54.930" LastActivityDate="2024-02-17T23:39:23.453" Title="How can I create multiple running threads?" Tags="|arduino-uno|threads|" AnswerCount="9" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="287" PostTypeId="2" ParentId="286" CreationDate="2014-02-18T15:36:32.877" Score="19" Body="&lt;p&gt;It is possible to do software side multi-threading on the Uno. Hardware level threading is not supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve multithreading, it will require the implementation of a basic scheduler and maintaining a process or task list to track the different tasks that need to be run. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The structure of a very simple non-preemptive scheduler would be like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Pseudocode&#xA;void loop()&#xA;{&#xA;&#xA;for(i=o; i&amp;lt;n; i++) &#xA;run(tasklist[i] for timelimit):&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;tasklist&lt;/code&gt; can be an array of function pointers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tasklist [] = {function1, function2, function3, ...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With each function of the form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int function1(long time_available)&#xA;{&#xA;   top:&#xA;   //Do short task&#xA;   if (run_time&amp;lt;time_available)&#xA;   goto top;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each function can perform a separate task such as &lt;code&gt;function1&lt;/code&gt; performing LED manipulations, and &lt;code&gt;function2&lt;/code&gt; doing float calculations. It will be the responsibility of each task(function) to adhere to the time allocated to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully, this should be enough to get you started. &lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-18T15:46:38.783" LastActivityDate="2014-02-18T15:46:38.783" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="288" PostTypeId="2" ParentId="286" CreationDate="2014-02-18T17:23:17.690" Score="62" Body="&lt;p&gt;There is no multi-process, nor multi-threading, support on the Arduino. You can do something close to multiple threads with some software though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to look at &lt;a href=&quot;http://dunkels.com/adam/pt/&quot; rel=&quot;noreferrer&quot;&gt;Protothreads&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Protothreads are extremely lightweight stackless threads designed for&#xA;  severely memory constrained systems, such as small embedded systems or&#xA;  wireless sensor network nodes. Protothreads provide linear code&#xA;  execution for event-driven systems implemented in C. Protothreads can&#xA;  be used with or without an underlying operating system to provide&#xA;  blocking event-handlers. Protothreads provide sequential flow of&#xA;  control without complex state machines or full multi-threading.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course, there is an Arduino example &lt;a href=&quot;http://harteware.blogspot.com/2010/11/protothread-powerfull-library.html&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; with &lt;a href=&quot;http://harteware.blogspot.com/2010/11/protothread-and-arduino-first-easy.html&quot; rel=&quot;noreferrer&quot;&gt;example code&lt;/a&gt;. This &lt;a href=&quot;https://stackoverflow.com/questions/6230878/some-problems-with-arduino-protothreads&quot;&gt;SO question&lt;/a&gt; might be useful, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ivanseidel/ArduinoThread&quot; rel=&quot;noreferrer&quot;&gt;ArduinoThread&lt;/a&gt; is a good one too.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-14T16:12:58.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="289" PostTypeId="2" ParentId="286" CreationDate="2014-02-18T18:14:37.177" Score="21" Body="&lt;p&gt;AVR based Arduino's do not support (hardware) threading, I am unfamiliar with the ARM based Arduino's. One way around this limitation is the use of interrupts, especially timed interrupts. You can program a timer to interrupt the main routine every so many microseconds, to run a specific other routine.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/reference/en/language/functions/interrupts/interrupts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/reference/en/language/functions/interrupts/interrupts/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="-1" LastEditDate="2023-04-26T03:33:06.680" LastActivityDate="2023-04-26T03:33:06.680" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="290" PostTypeId="2" ParentId="286" CreationDate="2014-02-18T20:58:55.920" Score="9" Body="&lt;p&gt;As per the description of your requirements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one thread waiting for an external device&lt;/li&gt;&#xA;&lt;li&gt;one thread blinking a LED&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It seems you could use one Arduino interrupt for the first &quot;thread&quot; (I would rather call it &quot;task&quot; in fact).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino interrupts can call one function (your code) based on an external event (voltage level or level change on a digital input pin), that will trigger your function immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, one important point to keep in mind with interrupts is that the called function should be as fast as possible (typically, there should be no &lt;code&gt;delay()&lt;/code&gt; call or any other API that would depend on &lt;code&gt;delay()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a long task to activate upon external event trigger, then you could potentially use a cooperative scheduler and add a new task to it from your interrupt function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second important point about interrupts is that their number is limited (e.g. only 2 on UNO). So if you start tohave more external events, you would need to implement some kind of multiplexing all inputs into one, and have your interrupt function determine what multiplexed inut was the actual trigger.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-02-18T21:07:29.017" LastActivityDate="2014-02-18T21:07:29.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="291" PostTypeId="2" ParentId="141" CreationDate="2014-02-18T22:21:17.023" Score="2" Body="&lt;p&gt;There are also some people working on &lt;strong&gt;Javascript&lt;/strong&gt; node.js based systems. One that is already publicly available is &lt;a href=&quot;https://github.com/espruino/Espruino&quot; rel=&quot;nofollow&quot;&gt;Espruino&lt;/a&gt; and another is &lt;a href=&quot;https://github.com/technicalmachine&quot; rel=&quot;nofollow&quot;&gt;Tessel&lt;/a&gt; which launches in spring 2014.&lt;/p&gt;&#xA;" OwnerUserId="236" LastActivityDate="2014-02-18T22:21:17.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="292" PostTypeId="1" AcceptedAnswerId="302" CreationDate="2014-02-18T22:56:12.727" Score="6" ViewCount="2066" Body="&lt;p&gt;I am involved in a project that is going to measure PH and chlorine in a swimming pool.  The plan is to use a Arduino Yun. The sensors we are going to use are connected using serial.  Since we may be using multiple sensors, is there any difference in reliability, latency, known issues (bugs) of using software serial versus pin0 and pin1? Is it any way to avoid software serial pitfalls (if there are any)?&lt;/p&gt;&#xA;" OwnerUserId="201" LastEditorUserId="201" LastEditDate="2014-02-19T08:15:29.850" LastActivityDate="2014-02-19T08:15:29.850" Title="Serial sensors and the Yun" Tags="|serial|arduino-yun|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="293" PostTypeId="2" ParentId="292" CreationDate="2014-02-19T00:40:29.107" Score="2" Body="&lt;p&gt;I don't have any experience with the Yun so I can't comment on that specifically, but the only problem you'll encounter with using &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; is that you can only communicate with one device at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means you'll have to make a call to &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerialListen&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;listen()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sensor1.listen()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before communicating with &lt;code&gt;sensor1&lt;/code&gt;. Then when you want to communicate with another sensor, you have to do the same.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-19T00:40:29.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="294" PostTypeId="1" AcceptedAnswerId="295" CreationDate="2014-02-19T00:48:23.407" Score="22" ViewCount="8366" Body="&lt;p&gt;I've been hearing a lot about clones and counterfeits. &lt;strong&gt;What are the differences between the two?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="42" LastEditDate="2014-02-19T22:18:21.060" LastActivityDate="2014-02-19T22:18:21.060" Title="What's the difference between a clone and a counterfeit Arduino?" Tags="|clones|counterfeit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="295" PostTypeId="2" ParentId="294" CreationDate="2014-02-19T00:48:23.407" Score="21" Body="&lt;p&gt;The difference is simple: &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Clones don't say &quot;Arduino,&quot; where counterfeits do&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If I were to create 200 boards all labeled &quot;Arduino UNO R3,&quot; it would be a counterfeit. If I were to call them &quot;Happyduino,&quot; it would be a &lt;em&gt;clone&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can still write &lt;em&gt;Happyduino (Arduino Compatible)&lt;/em&gt; on your product. Here's a quote from the &lt;a href=&quot;http://arduino.cc/en/Main/FAQ&quot;&gt;Arduino FAQ section&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not okay:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Arduino Xxxxxx&lt;/li&gt;&#xA;  &lt;li&gt;Xxxxxx Arduino&lt;/li&gt;&#xA;  &lt;li&gt;Arduino Compatible Xxxxxx - use &quot;Xxxxxx (Arduino-Compatible)&quot; instead&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Okay:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Xxxxxx for Arduino - products that work with official Arduino boards    (e.g. shields or kits)&lt;/li&gt;&#xA;  &lt;li&gt;Xxxxxx (Arduino-Compatible) - variations and clones which are    software and hardware compatible&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Note that while we don't attempt to restrict uses of the &quot;duino&quot;&#xA;  suffix, its use causes the Italians on the team to cringe (apparently&#xA;  it sounds terrible); you might want to avoid it. (It's also&#xA;  trademarked by a Hungarian company.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-02-19T00:48:23.407" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="296" PostTypeId="1" AcceptedAnswerId="299" CreationDate="2014-02-19T03:16:57.470" Score="57" ViewCount="102638" Body="&lt;p&gt;The standard is 9600 baud. That's just the &lt;em&gt;standard&lt;/em&gt;. Using a Arduino Uno SMD R2, what is the highest practical baud rate I can achieve?&lt;/p&gt;&#xA;&lt;p&gt;Bonus points for the audacious: how would you go about creating an error checking mechanism and then increasing the baud rate ridiculous high to get high transfer rates?&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="45493" LastEditDate="2023-11-05T01:07:43.003" LastActivityDate="2023-11-05T01:07:43.003" Title="How high of a baud rate can I go (without errors)?" Tags="|arduino-uno-smd|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="298" PostTypeId="2" ParentId="296" CreationDate="2014-02-19T05:27:35.870" Score="9" Body="&lt;p&gt;The Arduino Serial Monitor window limits you to 115200, but that's not the highest baud rate capable. You can read the Atmel and the FT232 (or whatever you're using) datasheets to find out the maximum but I am able to successfully use 230400 (twice as fast as the largest the Arduino Serial Monitor supports) with no issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to see the results in your computer, you will need another serial monitor that supports other baud rate options. I like &lt;a href=&quot;http://freeware.the-meiers.org/&quot;&gt;CoolTerm&lt;/a&gt; and &lt;a href=&quot;http://www.compuphase.com/software_termite.htm&quot;&gt;Termite&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do note that this heavily depends on your clock speed as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;a href=&quot;http://www.wormfood.net/avrbaudcalc.php&quot;&gt;calculator&lt;/a&gt; to help you with calculating what's possible.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-19T05:27:35.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="299" PostTypeId="2" ParentId="296" CreationDate="2014-02-19T06:24:54.967" Score="80" Body="&lt;p&gt;There are several factors here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How high of a baud-rate can the ATmega328P MCU achieve?&lt;/li&gt;&#xA;&lt;li&gt;How high of a baud-rate can the USB-Serial interface achieve?&lt;/li&gt;&#xA;&lt;li&gt;What is the oscillator frequency on the ATmega328P?&lt;/li&gt;&#xA;&lt;li&gt;What is the oscillator frequency on the USB-serial interface (if it has one)?&lt;/li&gt;&#xA;&lt;li&gt;How tolerant is the USB-serial interface of baud-rate mismatch?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of these factors are relevant to determining the maximum achieveable baud rate. The ATmega328P uses a hardware divisor from it's clock-rate to generate the base-clock for the serial interface. If there is no integer ratio from the main clock to the bit-time of the desired baud rate, the MCU will not be able to &lt;em&gt;exactly&lt;/em&gt; produce the desired rate. This can lead to potential issues, as some devices are much more sensitive to baud-rate mismatch then others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FTDI-based interfaces are quite tolerant of baud-rate mismatch, up to several percent error. However, I have worked with specialized embedded GPS modules that were unable to handle even a 0.5% baud rate error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;General serial interfaces are tolerant of ~5% baud-rate error. However, since each end can be off, a more common spec is +-2.5%. This way, if one end is 2.5% fast, and the other is 2.5% slow, your &lt;em&gt;overall&lt;/em&gt; error is still only 5%.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Anyways. The Uno uses a ATmega328P as the primary MCU, and a ATmega16U2 as the USB-serial interface. We're also fortunate here in that both these MCUs use similar harware USARTs, as well as 16 Mhz clocks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since both MCUs have the same harware and clock-rate, they'll both have the same baud-rate error in the same direction, so we can functionally ignore the baud error issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, the &quot;proper&quot; answer to this question would involve digging up the source for the ATmega16U2, and working out the possible baud-rates from there, but since I'm lazy, I figure simple, empirical testing will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick glance at the ATmega328P datasheet produces the following table:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/P8kN2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So given the max stated baud-rate of 2 Mbps, I wrote a quick test program:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){};&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  delay(1000);&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;\r\rBaud-rate = 57600&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(76800);&#xA;  Serial.println(&quot;\r\rBaud-rate = 76800&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;\r\rBaud-rate = 115200&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(230400);&#xA;  Serial.println(&quot;\r\rBaud-rate = 230400&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(250000);&#xA;  Serial.println(&quot;\r\rBaud-rate = 250000&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(500000);&#xA;  Serial.println(&quot;\r\rBaud-rate = 500000&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(1000000);&#xA;  Serial.println(&quot;\r\rBaud-rate = 1000000&quot;);&#xA;  delay(1000);&#xA;  Serial.begin(2000000);&#xA;  Serial.println(&quot;\r\rBaud-rate = 2000000&quot;);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then looking at the relevant serial port with a serial terminal:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/US17S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it appears the hardware can run at 2,000,000 baud without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this baud rate only gives the MCU &lt;strike&gt;64&lt;/strike&gt; 80 clock-cycles per byte, so it would be very challenging to keep the serial interface busy. While the individual bytes may be transferred very rapidly, there is likely to be lots of time when the interface is simply idle.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit: Actual Testing!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2 Mbps is real:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/APzfe.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;each bit-time is 500 ns, which matches exactly with what is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Performance issues! Overall packet length:&lt;br&gt;&#xA;500 Kbaud:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/rlBti.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 Mbaud:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/9ACpH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 Mbaud:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/vUDoN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;&lt;sub&gt;Note: The noticeable overshoot is due to poor scope probe grounding practices, and is &lt;em&gt;probably&lt;/em&gt; not real. I'm using the ground-clip-lead that's part of my scope probe, and the lead-inductance is likely the cause of the majority of the overshoot.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the overall transmission length is the same for 0.5, 1 and 2 Mbaud. This is because the code that is placing the bytes in the serial buffer is poorly optimized. As such, you will never achieve anything better then an &lt;em&gt;effective&lt;/em&gt; 500 Kbaud, unless you write your own serial libraries. The Arduino libraries are very poorly optimized, so it probably wouldn't be &lt;em&gt;too&lt;/em&gt; hard to get a proper 2 Mbaud, at least for burst transmissions, if you spent a bit of time on it.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2015-05-29T16:26:06.087" LastActivityDate="2015-05-29T16:26:06.087" CommentCount="31" ContentLicense="CC BY-SA 3.0" />
  <row Id="300" PostTypeId="2" ParentId="296" CreationDate="2014-02-19T06:39:32.413" Score="3" Body="&lt;p&gt;This is probably one of the few aspects where el-Cheapo boards differ from original boards. The maximum serial transfer rate is pretty much only limited by the quality of the board and its layout. Once the serial data enters either AVR or USB interface chip, the data will be processed differently from the serial UART protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind though that the microcontroller has some basic hardware to shift in/out serial data to/from the IO pins, but the absolute maximum rate is limited to the 16MHz clock (for AVRs). Once a byte is moved to the serial buffer, the UART hardware will take over and push out / pull in the bits on its own. An AVR at best reaches 16M instructions per second and the interrupts used to fill the serial buffer have some overhead (at least 8 clock ticks for the interrupt handling + instructions to save current state + several instructions for actually filling the buffer). At a given bitrate, the protocol will run at a whopping n bits per second, but your controller needs more time to fill the serial buffer than it needs to actually output the data, resulting in a lower average throughput than you expect and the UART idling for a relatively long time. Disadvantage is the increased probability for bit errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another effect to remember is that all the overhead required to push data out onto UART (or pull it in) cannot be spent in your actual program, again affecting the average practical throughput. You can only use every instruction cycle once, either for filling the buffer or for computing the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The maximum throughput is therefore dependent on the application you use (how fast is data generated/computed/ready to move to/from the serial buffer) and the actual 'physical' bitrate is only a small part of the design decision.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-19T06:39:32.413" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="301" PostTypeId="2" ParentId="292" CreationDate="2014-02-19T06:57:15.270" Score="0" Body="&lt;p&gt;I didn't check the circuit diagrams, but on most AVR based Arduino's pins 0 and 1 are used to program the device. By reusing the pins, you may run into problems when trying to program the Arduino from IDE. It is easily solved by detaching the hardware from those pins, but you have to reattach them to test the sketch. I personally try to avoid using those to pins, just for ease of development.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-19T06:57:15.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="302" PostTypeId="2" ParentId="292" CreationDate="2014-02-19T08:00:46.920" Score="3" Body="&lt;p&gt;The Yun is a bit different to other Arduinos. The main microcontroller is a ATmega32U4 with a build in USB interface. This is used for the connection to the PC so the single USART is not used for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the single USART is used for connecting to the built in wireless processor. This means that you can't use the wireless and hardware serial at the same time. I presume you are using the Yun for wireless, so disabling this is not desirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial is relatively good, but does consume a lot of cycles. You can only listen on a single port at a time. It is possible to use pin change interrupts to listen for activity on multiple ports and switch to the one required, but this requires that the other end can wait for a response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_NewSoftSerial.html#cpu&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; will tie up the microcontroller whilst sending, which can lead to problems when supporting &lt;em&gt;low&lt;/em&gt; baud rates. Conversely, because it is CPU heavy, it can also have problems with &lt;em&gt;high&lt;/em&gt; baud rates. There is a window, between 9600 and 38400 baud, where it seems to work best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another software serial version called &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt;. This works faster than SoftwareSerial and can transmit and receive at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the USART, SoftwareSerial and AltSoftSerial all at the same time. Be warned that because all three of these use interrupts and some use timers, you are highly likely to end up with complex, hard to debug interactions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note than in older versions of Arduino (pre v1), SoftwareSerial was very, very poor. It was replaced entirely with &quot;NewSoftSerial&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensors are often have very basic USART hardware with limited buffer sizes, and drop data when they aren't serviced in a timely manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not a massive fan of the Yun. It isn't popular, the wireless is still relatively hard to use (compared to the TI CC3000), and the wireless interface uses valuable pins. Personally, if I was to work on a project that required multiple serial interfaces, I would either&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use a board with multiple USART, such as a ATmega1280 (2 USARTs) or ATmega2560 (4 USARTs) and a CC3000 (SPI connected) wireless board.&lt;/li&gt;&#xA;&lt;li&gt;Use SPI/I2C-&gt;USART bridges. This allows a single SPI/I2C port to control multiple USARTs. Sparkfun &lt;a href=&quot;https://www.sparkfun.com/products/9981&quot; rel=&quot;nofollow&quot;&gt;sell one&lt;/a&gt;, there are many others available.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Be cautious of falling into the trap of using hardware because it is what you have available. &lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-19T08:10:49.197" LastActivityDate="2014-02-19T08:10:49.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="303" PostTypeId="2" ParentId="294" CreationDate="2014-02-19T10:48:33.700" Score="8" Body="&lt;p&gt;A &lt;strong&gt;clone&lt;/strong&gt; is an exact or almost exact replica of an original Arduino board, with a different branding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;derivative&lt;/strong&gt; is a board based or inspired by Arduino boards, with some specific addition or modification (different layouts, built-in sensors...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;counterfeit&lt;/strong&gt; is a clone of an Arduino board, with the same branding of an Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info on an &lt;a href=&quot;http://blog.arduino.cc/2013/07/10/send-in-the-clones&quot; rel=&quot;noreferrer&quot;&gt;article&lt;/a&gt; on the Arduino blog.&lt;/p&gt;&#xA;" OwnerUserId="27" LastEditorUserId="27" LastEditDate="2014-02-19T20:20:14.867" LastActivityDate="2014-02-19T20:20:14.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="304" PostTypeId="1" AcceptedAnswerId="305" CreationDate="2014-02-19T14:30:38.310" Score="9" ViewCount="6716" Body="&lt;p&gt;I bought a SainSmart clone board which is compatible with the Arduino Uno R3. Alongside each of the standard IO pins, there is a row of 3 additional pins (male). They are arranged in columns, marked S, V, and G.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can be seen on this image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rwQpm.jpg&quot; alt=&quot;Photo of SainSmart Uno R3 clone board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of them are immediately above the SainSmart and UNO logos. The SVG pins corresponding to the analog pins can be seen immediately below the microprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are these pins for? Is this a standard format for some applications, or is it something unique to the SainSmart?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-25T06:34:32.143" LastActivityDate="2017-07-16T14:40:03.193" Title="What are the SVG pins for on the SainSmart Uno clone?" Tags="|pins|arduino-uno|clones|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="305" PostTypeId="2" ParentId="304" CreationDate="2014-02-19T14:30:38.310" Score="10" Body="&lt;p&gt;SVG = Signal, Voltage, Ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Signal pin will carry the actual output, which may be high or low at any given time. It's basically just a male version of the corresponding standard GPIO pin. The Voltage pin will always be high (which can be 5v or 3.3v on this board, depending on the output level switch). The Ground pin is exactly what the name suggests -- it's connected to the board's ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This obviously means there is a lot of duplication. Why have two signal pins? And why bother having so many Voltage and Ground pins if they're all the same anyway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is simply convenience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a standalone external component (such as a motor), you would normally have to run 3 separate wires to it. With the regularly-spaced SVG pins on the board, you can instead use a 3-way cable with a suitable female header block. You can run that to an equivalent set of 3 pins on the external component. That means you are able to attach/detach the component by plugging/unplugging (effectively) a single cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think the SVG idea is a 'standard' as such, largely because (in this form) it's only really of benefit to people who are experimenting or prototyping (as opposed to designing a more permanent system). It seems to be fairly popular among hobbyists and enthusiasts though. You just need to watch out for components which may put their equivalent SVG pins in a different order.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-19T14:30:38.310" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="306" PostTypeId="2" ParentId="296" CreationDate="2014-02-19T15:31:57.060" Score="3" Body="&lt;p&gt;Error checking is actually very easy and there is an AVR lib that does this in a one liner.     &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read up on  &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;util/crc16.h&lt;/code&gt;&lt;/a&gt; and you should be good to go in no time with the included examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CRC is quite robust and fast for simple applications.&lt;/p&gt;&#xA;" OwnerUserId="160" LastEditorUserId="11" LastEditDate="2014-02-24T06:06:24.673" LastActivityDate="2014-02-24T06:06:24.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="307" PostTypeId="1" AcceptedAnswerId="309" CreationDate="2014-02-19T22:11:19.283" Score="3" ViewCount="372" Body="&lt;p&gt;I know there are different revisions of the Arduino Uno itself, but are there any revisions of the SMD? If they are is SMD R2 identical to through-hole R2? I have a board marked R2 SMD and I am wondering if that is the only version that they produced in SMD format and just are signifying that it is compatible with the standard R2.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-02-19T23:18:46.483" Title="Are there different revisions of Arduino Uno SMD?" Tags="|arduino-uno-smd|revisions|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="308" PostTypeId="2" ParentId="249" CreationDate="2014-02-19T22:15:45.733" Score="3" Body="&lt;p&gt;Responding to TV remotes is surprisingly simple, because they typically all work on exactly the same principle, with no concept of channels or encryption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need is an IR receiver module, which you can buy fairly cheaply from many electronics suppliers. Anything intended to work with remote controls should be suitable. The important part is that it will work with ~38 kHz signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will typically be a 3 pin component. Many are able to operate at 5 volts, which means you can usually connect the IR module's voltage and ground pins directly to the Arduino's power supply. The data (or signal) pin can typically be connected straight to any GPIO pin. Always check the component's data sheet though. It will often recommend using some additional components (e.g. resistor and capacitor) to smooth out power fluctuations. That shouldn't be necessary for a small project though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When an IR signal is detected, the module will usually output a series of pulses on the data pin. These will be digital pulses, so there's no need to use an analog-to-digital converter. What matters is typically either the length of each pulse (Pulse Width Modulation), or the length of the gap between consecutive pulses (Pulse Distance Modulation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timings of the pulses/gaps will be very fast; usually in the region of 400 to 2000 microseconds. That means it's probably too fast to try to detect them using repeated calls to &lt;code&gt;digitalRead()&lt;/code&gt;. Instead, there is a core Arduino function called &lt;a href=&quot;http://arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pulseIn()&lt;/code&gt;&lt;/a&gt;. When it's called, it will wait for a pulse to arrive on the specified GPIO pin. It will then return the approximate length of the pulse. You can detect high pulses for PWM, or low pulses for PDM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Precise timing values will vary considerably, so you can ignore small variations. The key is to categorise each pulse as short or long, corresponding to a binary 0 or 1. A good starting point is to consider anything below 1000 usec as short, and everything else as long. Check what timings you actually receive though, and adjust that value accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call &lt;code&gt;pulseIn()&lt;/code&gt; repeatedly, storing each result. Keep going until no more pulses arrive (you will need to give it a timeout after which it gives up waiting, e.g. 10,000 usec or more).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your TV remote will output a unique sequence of short/long pulses for each button, typically 32 bits or less (possibly with extra pulses at the beginning/end). All you need to do is figure out which sequence corresponds to each button. You could store that information in a lookup table, and respond accordingly when a sequence is recognised.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-19T22:15:45.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="309" PostTypeId="2" ParentId="307" CreationDate="2014-02-19T22:32:09.893" Score="4" Body="&lt;p&gt;The only difference with the SMD Uno is the fact you can't remove the chip. There are also 2 extra analog comparators not connected to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SMD boards are compatible with the thru-hole boards, but they have SMD components, which apparently make them easier to make and cheaper. As I said before, the two extra analog inputs (A7 and A6) are left unconnected on the official boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my Uno R3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5miJQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-02-19T23:18:46.483" LastActivityDate="2014-02-19T23:18:46.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="311" PostTypeId="5" CreationDate="2014-02-19T23:25:15.357" Score="0" Body="&lt;p&gt;MATLAB is a programming language used primarily for numerical computations. It can also be used to connect to other programming languages, plot data, or implement algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag for questions regarding communicating or using MATLAB with Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider using other programming related tags such as &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; or &lt;a href=&quot;/questions/tagged/library&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;library&amp;#39;&quot; rel=&quot;tag&quot;&gt;library&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-20T00:49:39.970" LastActivityDate="2014-02-20T00:49:39.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="312" PostTypeId="4" CreationDate="2014-02-19T23:25:15.357" Score="0" Body="MATLAB is a programming language used primarily for numerical computations. Use this tag for questions regarding communicating or using MATLAB with Arduino. Also consider using other tags such as [programming]." OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-20T00:49:57.393" LastActivityDate="2014-02-20T00:49:57.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="314" PostTypeId="5" CreationDate="2014-02-19T23:38:22.120" Score="0" Body="&lt;p&gt;Use this tag for questions regarding programming (writing code) for Arduino. This can include problems with code you've written for Arduino or questions about how/why Arduino code acts in specific ways.&lt;/p&gt;&#xA;&lt;p&gt;Where a question relates to a particular language, you can also use language-specific tags, such as &lt;a href=&quot;/questions/tagged/c%2b%2b&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;c++&amp;#39;&quot; aria-label=&quot;show questions tagged &amp;#39;c++&amp;#39;&quot; rel=&quot;tag&quot; aria-labelledby=&quot;tag-c++-tooltip-container&quot;&gt;c++&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Programming questions that are not specific to Arduino (e.g. general questions about a programming language) should be asked on &lt;a href=&quot;http://www.stackoverflow.com&quot;&gt;&lt;strong&gt;Stack Overflow&lt;/strong&gt;&lt;/a&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;Please use the &lt;a href=&quot;/questions/tagged/uploading&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;uploading&amp;#39;&quot; aria-label=&quot;show questions tagged &amp;#39;uploading&amp;#39;&quot; rel=&quot;tag&quot; aria-labelledby=&quot;tag-uploading-tooltip-container&quot;&gt;uploading&lt;/a&gt; tag for questions regarding uploading sketches to Arduino devices.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; With this tag, &lt;a href=&quot;http://en.wikipedia.org/wiki/Syntax_highlighting&quot; rel=&quot;nofollow noreferrer&quot;&gt;syntax highlighting&lt;/a&gt; will be enabled. For more information, see &lt;strong&gt;&lt;a href=&quot;http://arduino.stackexchange.com/editing-help#syntax-highlighting&quot;&gt;the syntax highlighting help section&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="90086" LastEditDate="2023-07-28T08:14:13.470" LastActivityDate="2023-07-28T08:14:13.470" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="315" PostTypeId="4" CreationDate="2014-02-19T23:38:22.120" Score="0" Body="The process of designing and writing source code as part of a program (or sketch) for Arduino. For questions about uploading code to an Arduino board, use the [uploading] tag instead." OwnerUserId="35" LastEditorUserId="27346" LastEditDate="2019-02-06T12:02:58.473" LastActivityDate="2019-02-06T12:02:58.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="316" PostTypeId="1" AcceptedAnswerId="317" CreationDate="2014-02-20T00:42:53.183" Score="22" ViewCount="5990" Body="&lt;p&gt;Currently, my sketch is checking an input pin every time round the main loop. If it detects a change, it calls a custom function to respond to it. Here's the code (trimmed down to the essentials):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pinValue = LOW;&#xA;&#xA;void pinChanged()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(2, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Read current input&#xA;    int newValue = digitalRead(2);&#xA;&#xA;    // Has the input changed?&#xA;    if (newValue != pinValue) {&#xA;        pinValue = newValue;&#xA;        pinChanged();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this doesn't always work properly for very short changes on the input (e.g. brief pulses), especially if &lt;code&gt;loop()&lt;/code&gt; is running a bit slowly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make the Arduino detect the input change and call my function automatically?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="48" LastEditDate="2014-02-25T18:47:15.817" LastActivityDate="2015-07-01T21:10:22.833" Title="Can a function be called automatically when an input changes?" Tags="|pins|interrupt|isr|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="317" PostTypeId="2" ParentId="316" CreationDate="2014-02-20T00:42:53.183" Score="27" Body="&lt;p&gt;You can do this using external interrupts. Most Arduinos only support this on a limited number of pins though. For full details, see the documentation on &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot;&gt;&lt;code&gt;attachInterrupt()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you're using an Uno, you could do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void pinChanged()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(2, INPUT);&#xA;    attachInterrupt(0, pinChanged, CHANGE);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call &lt;code&gt;pinChanged()&lt;/code&gt; whenever a change is detected on external interrupt 0. On the Uno, that corresponds to GPIO pin 2. The external interrupt numbering is different on other boards, so it's important to check the relevant documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are limitations to this approach though. The custom &lt;code&gt;pinChanged()&lt;/code&gt; function is being used as an Interrupt Service Routine (ISR). That means the rest of the code (everything in &lt;code&gt;loop()&lt;/code&gt;) is temporarily stopped while the call is executing. In order to prevent disrupting any important timing, you should aim to make ISRs as fast as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also important to note that no other interrupts will run during your ISR. That means anything relying on interrupts (such as the core &lt;code&gt;delay()&lt;/code&gt; and &lt;code&gt;millis()&lt;/code&gt; functions) may not work properly inside it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, if your ISR needs to change any global variables in the sketch, they should usually be declared as &lt;code&gt;volatile&lt;/code&gt;, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int someNumber;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's important because it tells the compiler that the value could change unexpectedly, so it should be careful not to use any out-of-date copies/caches of it.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-20T00:42:53.183" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="318" PostTypeId="1" AcceptedAnswerId="330" CreationDate="2014-02-20T11:03:18.267" Score="8" ViewCount="11296" Body="&lt;p&gt;I've been using the &lt;code&gt;pulseIn()&lt;/code&gt; function for processing PWM-based binary data encoding. It works well for distinguishing pulses which are significantly different lengths, e.g. 500us vs. 1500us. That makes it more than sufficient for handling typical IR remotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I want to make my own IR system which can use more than 2 pulse lengths, so that data transfer can occur faster. Ideally, I'd like to use 8 different pulse lengths for octal encoding (e.g. 200us, 400us, 600us, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed quite significant variations in the values returned by &lt;code&gt;pulseIn()&lt;/code&gt; though (+/- 10%). I expect at least some of it is introduced by the IR transmitter and receiver modules, but I don't have good enough equipment to verify that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming I can mitigate that external error, is &lt;code&gt;pulseIn()&lt;/code&gt; likely to be precise enough to distinguish such similar pulses?&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-21T03:38:54.990" Title="How precise is the timing of pulseIn()?" Tags="|pwm|pulsein|timing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="319" PostTypeId="1" AcceptedAnswerId="321" CreationDate="2014-02-20T11:37:03.207" Score="10" ViewCount="3596" Body="&lt;p&gt;When using C/C++ on other platforms, the &lt;code&gt;int&lt;/code&gt; type is typically 4 bytes (or potentially more). However, on Arduino, it's only 2 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is it different? Does it affect performance if I always use the 4 byte &lt;code&gt;long&lt;/code&gt; instead?&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-22T13:53:10.110" Title="Why is int only 2 bytes?" Tags="|programming|c++|data-type|performance|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="321" PostTypeId="2" ParentId="319" CreationDate="2014-02-20T13:55:44.603" Score="10" Body="&lt;p&gt;The ATmega328 used in a lot of Arduinos is a 8-bit microcontroller. This means that registers are 8-bits, the data bus is 8-bits, the ports are 8-bits. There are some minimal 16-bit aspects to the system (e.g. one of the timers), but nearly everything is 8-bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, most operations handle 8-bits at a time. Working on anything except 8-bits (i.e. 16-bit or 32-bit integers and floating point numbers) requires what could essentially be described as software emulation, where the compiler uses multiple instructions to work on these larger variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8-bits is obviously adequate to address a 8-bit port. It's also enough to deal with many loop counters, return values, and ASCII characters. It isn't really enough though when dealing with numbers. A signed 8-bit int (int8_t) can only represent -128 -&gt; +127. Unsigned (uint8_t) can only represent 0 -&gt; 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8-bit integers are quite limiting. C/C++ int must represent at least -32,678 -&gt; +32,767 so maps to int16_t - the smallest size that will do so. This gives a good balance of range and efficiency. This is especially important when beginners are learning - overflow is not really something that non-programmers understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a performance impact of doing this however, because most 16-bit operations take at least twice as long as an 8-bit operation, and use twice as many registers. This may or may not make a difference to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many of us switch to the native types such as int8_t and uint8_t as it gives you far more control.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-20T15:34:20.750" LastActivityDate="2014-02-20T15:34:20.750" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="322" PostTypeId="1" AcceptedAnswerId="328" CreationDate="2014-02-20T14:06:18.787" Score="6" ViewCount="1872" Body="&lt;p&gt;I have a simple library which uses another library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __DERIVEDCLASS_H__&#xA;#define __DERIVEDCLASS_H__&#xA;&#xA;#include &amp;lt;HardwareSerial.h&amp;gt;&#xA;&#xA;class DerivedClass&#xA;{&#xA;private:&#xA;    HardwareSerial* serial;&#xA;&#xA;public:&#xA;    DerivedClass();&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the CPP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DerivedClass.h&quot;&#xA;&#xA;DerivedClass::DerivedClass()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DerivedClass.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I change the library header to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __DERIVEDCLASS_H__&#xA;#define __DERIVEDCLASS_H__&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;class DerivedClass&#xA;{&#xA;private:&#xA;    SoftwareSerial* serial;&#xA;&#xA;public:&#xA;    DerivedClass();&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch fails to compile:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:&#xA;  error: ISO C++ forbids declaration of 'SoftwareSerial' with no type&#xA;  /Users/andrew/Documents/Arduino/libraries/DerivedClass/DerivedClass.h:9:&#xA;  error: expected ';' before '*' token&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I change the sketch to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DerivedClass.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. including the SoftwareSerial library in the top level sketch, it compiles fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I expand the library out so it actually performs actions, then if it compiles, it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this? HardwareSerial is a built-in part of the Arduino, located in &lt;em&gt;hardware/arduino/cores/arduino&lt;/em&gt; and SoftwareSerial is in &lt;em&gt;libraries&lt;/em&gt;, but why would the build process differentiate between the two.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-20T14:33:24.790" LastActivityDate="2014-02-20T18:41:12.700" Title="Why do I need to include libraries used in other libraries?" Tags="|library|c++|build|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="323" PostTypeId="1" AcceptedAnswerId="329" CreationDate="2014-02-20T14:15:29.497" Score="6" ViewCount="1256" Body="&lt;p&gt;A commonly used library is the &lt;a href=&quot;http://milesburton.com/Dallas_Temperature_Control_Library&quot; rel=&quot;noreferrer&quot;&gt;DallasTemperature&lt;/a&gt; library, used to access DS18B20 sensors on a 1-Wire bus. When creating a DallasTemperature object you pass a reference to a &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_OneWire.html&quot; rel=&quot;noreferrer&quot;&gt;OneWire&lt;/a&gt; object. OneWire can create a 1-Wire bus on pretty much any port of an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of this is like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;&#xA;// Pass our oneWire reference to Dallas Temperature.&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there are some issues with using OneWire to drive a 1-Wire bus, mainly around driving longer bus lengths, dealing with shorts, and other errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a commonly available chip called the DS2482-100 that can drive longer busses (hundreds of feet), deals with shorts and other errors. It is also less CPU heavy and it deals with a number of the slower aspects of 1-Wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this reason, I would like to be able to pass a reference to a library that I have created instead. Currently, I am doing this by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Calling the library OneWire&lt;/li&gt;&#xA;&lt;li&gt;Replicating all the methods called by the DallasTemperature library&lt;/li&gt;&#xA;&lt;li&gt;Swapping out the OneWire library for mine&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is relatively messy. I would ideally like to be able to pass either a reference to my library or a 1-Wire library, so that people can chose which interface to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about doing this?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-20T19:18:39.017" LastActivityDate="2015-12-04T07:26:32.023" Title="How can I adapt the DallasTemperature library to accept another 1-Wire class?" Tags="|library|build|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="324" PostTypeId="2" ParentId="318" CreationDate="2014-02-20T14:22:35.903" Score="2" Body="&lt;p&gt;Here is some test data of a &lt;code&gt;pulseIn&lt;/code&gt; test. One Arduino sent what were supposed to be 14us pulses, and the other spat out this data:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;18,18,18,12,18,18,18,18,18,18,18,18,18,18,18,18,18,24,19,18,18,18,18,18,24,18,18,18,19,18,18,12,18,18,19,18,18,18,18,18,18,18,18,18,18,18,19,18,19,24,18,18,18,18,18,18,18,24,18,18,18,18,18,18,18,18,18,18,18,18,18,19,18,18,18,18,18,18,18,18,18,18,19,18,18,18,11,18&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you can see, the pulses are by no means accurate. The time would be more accurate if the sending and recieving ends were written in assembly, or even offloaded to their own processors.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-20T14:22:35.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="326" PostTypeId="1" CreationDate="2014-02-20T14:30:16.777" Score="0" ViewCount="485" Body="&lt;p&gt;I have been using the &lt;a href=&quot;http://jeelabs.net/pub/docs/jeelib/classSleepy.html&quot; rel=&quot;nofollow&quot;&gt;Jeelib Sleepy&lt;/a&gt; functionality for several years now to achieve low power states on the Arduino ATmega328/1280/2560 boards, specifically the LoseSomeTime functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get my Teensy 2 to go into a similar low power state, so I tried a very simple sketch that simply put the device to sleep, flashed an LED, and posted some Serial messages. I did need to comment out a few lines in Jeelib:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// adjust the milli ticks, since we will have missed several&#xA;#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) || defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny45__)&#xA;    extern volatile unsigned long millis_timer_millis;&#xA;    millis_timer_millis += msecs - msleft;&#xA;#else&#xA;    extern volatile unsigned long timer0_millis;&#xA;    timer0_millis += msecs - msleft;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This had to be done as the delay() and millis() functions on the Teensy use different variable names for the adjustment, and it was the quickest way of solving the problem. LoseSomeTime works on the ATmega328 hardware with this change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that although the LoseSomeTime function did sleep for a period, the Serial functionality stopped working entirely - no messages were being printed at all. I have encountered this before on ATmega328 hardware because the microcontroller has gone to sleep before the serial buffer was flushed. I added a number of delay()s after the Serial.writes and also tried using Serial.flush() to make sure the buffer was empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LoseSomeTime requires setting an interrupt on the watchdog timer, but I can't see how this would impact Serial operation.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="19409" LastEditDate="2021-06-07T14:25:34.403" LastActivityDate="2022-10-30T18:01:50.200" Title="Why can't I use Jeelib Sleepy on the Teensy 2 along with Serial" Tags="|serial|power|library|teensy|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="327" PostTypeId="2" ParentId="319" CreationDate="2014-02-20T18:36:59.780" Score="3" Body="&lt;p&gt;One important fact about C and C++ languages is that their respective standards do not define the size (in bytes) of integral and floating point number types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They just define minimal ranges and relation between these ranges, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;range(short) &amp;lt;= range(int) &amp;lt; range(long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the size of e.g. an &lt;code&gt;int&lt;/code&gt; will typically depend on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the target platform (processor)&lt;/li&gt;&#xA;&lt;li&gt;the compiler itself&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastEditorUserId="65" LastEditDate="2014-02-22T13:53:10.110" LastActivityDate="2014-02-22T13:53:10.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="328" PostTypeId="2" ParentId="322" CreationDate="2014-02-20T18:41:12.700" Score="3" Body="&lt;p&gt;If I remember correctly this is in fact a limitation of the &lt;strong&gt;Arduino IDE&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a better IDE (personally I use Eclipse with the Arduino plugin) it works as it should, i.e. if you include a library A that includes another library B, then in the end you won't get compile-time errors and both B and A will be included in the final binary.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-20T18:41:12.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="329" PostTypeId="2" ParentId="323" CreationDate="2014-02-20T20:51:31.323" Score="4" Body="&lt;p&gt;The typical way to achieve what you want would normally be to create your own &lt;strong&gt;subclass&lt;/strong&gt; of &lt;code&gt;OneWire&lt;/code&gt; class and &lt;strong&gt;override&lt;/strong&gt; the methods you need to change, then pass a pointer to an instance of your class to the &lt;code&gt;DallasTemperature&lt;/code&gt; constructor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for this to work, the &lt;code&gt;OneWire&lt;/code&gt; class must have been developed with extensibility (subclassing) in mind, i.e. use &lt;strong&gt;virtual&lt;/strong&gt; methods that you can override.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, a quick look at &lt;code&gt;OneWire.h&lt;/code&gt; shows that no method is virtual in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that means in the end you will have to perform some hacks, just as you do now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could potentially do (that's still a hack, but maybe a bit less dirty) is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replace &lt;code&gt;OneWire.h&lt;/code&gt; to make all methods virtual (at least those you need to override)&lt;/li&gt;&#xA;&lt;li&gt;keep the original &lt;code&gt;OneWire.cpp&lt;/code&gt; that should still compile with the newly adapted header file&lt;/li&gt;&#xA;&lt;li&gt;create a new &lt;code&gt;MyOneWire.h&lt;/code&gt; / &lt;code&gt;MyOneWire.cpp&lt;/code&gt; to define your own &lt;code&gt;OneWire&lt;/code&gt; subclass that overrides all necessary methods as you want&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you can pass either a &lt;code&gt;OneWire&lt;/code&gt; or a &lt;code&gt;MyOneWire&lt;/code&gt; instance to &lt;code&gt;DallasTemperature&lt;/code&gt; constructor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: when I see my answer, this makes me think your question is more a general C++ question than an Arduino-related one.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-20T20:51:31.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="330" PostTypeId="2" ParentId="318" CreationDate="2014-02-21T03:38:54.990" Score="11" Body="&lt;p&gt;The pulsein() function is very lossy, in that it is a hard loop and returns a number * the assumed clock cycles it takes for per loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;// wait for the pulse to stop&#xA;while ((*portInputRegister(port) &amp;amp; bit) == stateMask) {&#xA;  if (numloops++ == maxloops)&#xA;    return 0;&#xA;  width++;&#xA;}&#xA;&#xA;// convert the reading to microseconds. The loop has been determined&#xA;// to be 20 clock cycles long and have about 16 clocks between the edge&#xA;// and the start of the loop. There will be some error introduced by&#xA;// the interrupt handlers.&#xA;return clockCyclesToMicroseconds(width * 21 + 16); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The most accurate method for capturing the timing of a PIN is use the INPUT CAPTURE FEATURE. Look at the &lt;a href=&quot;https://gist.github.com/mpflaga/4404996&quot;&gt;this example &lt;/a&gt;. It enables the input capture at 1x of CPU for max resolution and each edge of the input pin captures the timer's clock value for reading from the generated Interrupt service. It also enables the timer overflow interrupt to as to maintain large absolute time, to be capture. Since the 1x will roll rather quickly. The captures store the time into an array for reading by the main loop.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Where for signals over IR the typical library to use is &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot;&gt;shirriff/Arduino-IRremote&lt;/a&gt; library. Where it has several demo's that will read and send the IR from a demodulated signal. To allow one to build a sketch of their own design. This code originally creates a timer interrupt that polls the input pin at a rate determine by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define USECPERTICK 50  // microseconds per clock interrupt tick&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the IRremote.h file. For my purposes I have change it to 25 us. Where I find this still can be intermittently missing pulse streams. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the demodulation is best accomplished within the IR receiver, which in turn outputs this signal of interest. Where to add some background. Using the typical 38KHz modulation, equates to a minimum resolution of 26.3uS per pulse's cycle. sherriff's library shows typically most bauds or bits are in the order of 10+ pulses. Which appear to meet your desired timings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/microtherion/Arduino-IRremote&quot;&gt;microtherion/Arduino-IRremote&lt;/a&gt; fork of shirriff's work improves the reception by replacing the timer interrupt polling of the pin with the use of PinChangeInterrupts. Which I have merged into my own &lt;a href=&quot;https://github.com/mpflaga/Arduino-IRremote&quot;&gt;mpflaga/Arduino-IRremote&lt;/a&gt; fork, that adds several other features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could use any of the above libraries. Or create your own app that uses either of the below to capture edges.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;polls on a Timer event (e.g. 50uS)&lt;/li&gt;&#xA;&lt;li&gt;captures the micros() on a PinChangeInterrupt&lt;/li&gt;&#xA;&lt;li&gt;uses Input Capture Interrupts to grab the exact time &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-21T03:38:54.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="331" PostTypeId="1" AcceptedAnswerId="350" CreationDate="2014-02-21T10:14:47.667" Score="5" ViewCount="407" Body="&lt;p&gt;I'm trying to use an unusual 16x2 LCD display with my Uno. As far as I know, it's an EA-X16027AR. It doesn't seem to be compatible with the HD44780 driver, which is typically used for Arduino LCD's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the datasheet, the display's ENB (Enable) pin requires a clock input, described as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Basical Clock to perform Instructions in Controller LSI. The Clock at the same timing as MPU are usually input.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The timing graphs elsewhere in the datasheet show it wants a speed of around 2 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get the internal clock signal from the Uno, scale it down to 2 MHz, and output it to a GPIO pin or similar? Alternatively, is it possible to emulate a clock signal at that speed on-board, without adding additional timing components?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="220" LastEditDate="2014-02-25T06:32:32.693" LastActivityDate="2014-02-25T06:32:32.693" Title="Can I link another device to the Uno's clock?" Tags="|arduino-uno|lcd|oscillator-clock|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="332" PostTypeId="1" AcceptedAnswerId="334" CreationDate="2014-02-21T12:21:09.433" Score="6" ViewCount="2126" Body="&lt;p&gt;I'm planning to build a simple XY plotter, and have been looking at the possibility of using a pair of small 5V 4-phase steppers to provide the movement. In my research, I've often seen stepper driver boards advertised, ranging from very big and expensive, through to quite small and cheap. Some of them actually look like little more than a darlington array on a PCB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I really need one of those external driver boards, or can I control the steppers directly from my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="11" LastEditDate="2014-03-01T18:27:30.450" LastActivityDate="2014-03-01T18:27:30.450" Title="Can a stepper motor be controlled directly from an Arduino?" Tags="|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="333" PostTypeId="1" CreationDate="2014-02-21T12:31:40.307" Score="10" ViewCount="3690" Body="&lt;p&gt;I have following setup:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Duemilanove&lt;/li&gt;&#xA;&lt;li&gt;Small water heater connected with optical relay (PWM is ok)&lt;/li&gt;&#xA;&lt;li&gt;Waterproof DS18B20 temperature sensor&lt;/li&gt;&#xA;&lt;li&gt;Unknown amount of water (but temperature sensor and heater are always underwater).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I accurately control water temperature, based on temperature sensor readings? By accurately, I mean up to accuracy of temperature sensor (in this case, ±0.5°C). Everything should run on Arduino, so no additional data storage or processing power is available. For debugging, I can obviously use computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried running PID, but it seems really hard to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Avoid overshooting - going over target temperature either initially, or when (cold) water is added&lt;/li&gt;&#xA;&lt;li&gt;Stabilize properly after adding cold water.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="261" LastEditorUserId="6452" LastEditDate="2015-04-10T15:26:18.960" LastActivityDate="2015-04-10T15:26:18.960" Title="Controlling water temperature accurately" Tags="|pwm|pid|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="334" PostTypeId="2" ParentId="332" CreationDate="2014-02-21T13:48:27.017" Score="11" Body="&lt;p&gt;Generally, stepper motors cannot be controlled by an Arduino pin. They have a current draw of over the 20mA any single pin can supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kickback is also a problem. Because the motors have moving magnetic parts inside, they will continue to generate electricity after power has been cut. this will almost certainly cause enough negative voltage that is enough to fry your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution is to use a motor driver chip or shield. &lt;a href=&quot;https://www.sparkfun.com/products/9815&quot;&gt;This one&lt;/a&gt; is a good example. These have transistor based chips that can drive enough current to power a motor, and diodes to mitigate the kickback from the motors.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="42" LastEditDate="2014-02-21T15:22:08.023" LastActivityDate="2014-02-21T15:22:08.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="337" PostTypeId="1" AcceptedAnswerId="339" CreationDate="2014-02-21T15:36:19.237" Score="21" ViewCount="12396" Body="&lt;p&gt;When you're writing a typical sketch, you usually rely on &lt;code&gt;loop()&lt;/code&gt; being called repeatedly for as long as the Arduino is running. Moving in and out of the &lt;code&gt;loop()&lt;/code&gt; function must introduce a small overhead though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid that, you could presumably create your own infinite loop, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    while (true)&#xA;    {&#xA;        // do stuff...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that a viable way to improve performance? Will it cause other problems if &lt;code&gt;loop()&lt;/code&gt; never returns?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="37523" LastEditDate="2019-12-05T15:40:06.313" LastActivityDate="2019-12-05T15:40:06.313" Title="Would an infinite loop inside loop() perform faster?" Tags="|programming|avr-gcc|performance|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="339" PostTypeId="2" ParentId="337" CreationDate="2014-02-21T16:43:46.067" Score="18" Body="&lt;p&gt;The part of the code on an ATmega core that does setup() and loop() is at follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;        init();&#xA;&#xA;#if defined(USBCON)&#xA;        USBDevice.attach();&#xA;#endif&#xA;&#xA;        setup();&#xA;&#xA;        for (;;) {&#xA;                loop();&#xA;                if (serialEventRun) serialEventRun();&#xA;        }&#xA;&#xA;        return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pretty simple, but there is the overhead of the serialEventRun(); in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's compare two simple sketches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;&#xA;}&#xA;&#xA;volatile uint8_t x;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;    x = 1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;&#xA;}&#xA;&#xA;volatile uint8_t x;&#xA;&#xA;void loop()&#xA;{&#xA;    while(true)&#xA;    {&#xA;        x = 1;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The x and volatile is just to ensure it isn't optimised out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the ASM produced, you get different results:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/CkIST.png&quot; alt=&quot;Comparison of two&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the while(true) just performs a rjmp (relative jump) back a few instructions, whereas loop() performs a subtraction, comparison and call. This is 4 instructions vs 1 instruction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To generate ASM as above, you need to use a tool called avr-objdump. This is included with avr-gcc. Location varies depending on OS so it is easiest to search for it by name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr-objdump can operate on .hex files, but these are missing the original source and comments. If you have just built code, you will have a .elf file that does contain this data. Again, the location of these files varies by OS - the easiest way to locate them is to turn on verbose compilation in preferences and see where the output files are being stored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the command as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avr-objdump -S output.elf &gt; asm.txt&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And examine the output in a text editor.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-21T21:20:58.340" LastActivityDate="2014-02-21T21:20:58.340" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="340" PostTypeId="1" CreationDate="2014-02-21T17:48:05.103" Score="4" ViewCount="5607" Body="&lt;p&gt;I've managed to adapt some code from the Arduino forums to display timecode on an LCD display.&lt;/p&gt;&#xA;&lt;p&gt;What I would like some extra help with is first is there a way of defining the &lt;code&gt;one_time_max&lt;/code&gt; etc differently depending on the high low state of a pin? This way I could use a switch to change the times so it could switch between NTSC and PAL.&lt;/p&gt;&#xA;&lt;p&gt;Secondly would anyone be kind enough to explain what is happening in the middle part of this code? I've made some notes but any help would be really appreciated.&lt;/p&gt;&#xA;&lt;p&gt;Here is a picture of how it's going so far. I'll keep you guys up to date as the project continues :)&lt;/p&gt;&#xA;&lt;p&gt;[![enter image description here][1]][1]&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    // Code from forum post Dec 12, 2007&#xA;    &#xA;    // include the library code:&#xA;    #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;    &#xA;    // initialize the library with the numbers of the interface pins&#xA;    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;    #define one_time_max 600 // these values are setup for PA video&#xA;    #define one_time_min 400&#xA;    // It's the durstion of a one and zero with a little bit of room for error.&#xA;    #define zero_time_max 1050 //&#xA;    #define zero_time_min 950 //&#xA;    &#xA;    &#xA;    #define icpPin 8 // ICP input pin on arduino&#xA;    //#define one_time_max 475 // these values are setup for NTSC video&#xA;    //#define one_time_min 300 // PAL would be around 1000 for 0 and 500 for 1&#xA;    //#define zero_time_max 875 // 80bits times 29.97 frames per sec&#xA;    //#define zero_time_min 700 // equals 833 (divide by 8 clock pulses)&#xA;    &#xA;    #define end_data_position 63&#xA;    #define end_sync_position 77&#xA;    #define end_smpte_position 80&#xA;    &#xA;    volatile unsigned int pin = 13;&#xA;    volatile unsigned int bit_time;&#xA;    // volatile instructs the variable to be stored in RAM&#xA;    volatile boolean valid_tc_word;&#xA;    // boolean can be either of two values true or false but default to false&#xA;    volatile boolean ones_bit_count;&#xA;    // boolean can be either of two values true or false but default to false&#xA;    volatile boolean tc_sync;&#xA;    // boolean can be either of two values true or false but default to false&#xA;    volatile boolean write_tc_out;&#xA;    // boolean can be either of two values true or false but default to false&#xA;    volatile boolean drop_frame_flag;&#xA;    // boolean can be either of two values true or false but default to false&#xA;    volatile byte total_bits; //this stores a an 8-bit unsigned number&#xA;    volatile byte current_bit; //this stores a an 8-bit unsigned number&#xA;    volatile byte sync_count; //this stores a an 8-bit unsigned number&#xA;    &#xA;    volatile byte tc[8]; //this stores a an 8-bit unsigned number&#xA;    volatile char timeCode[11]; //this stores a an 8-bit unsigned number&#xA;    &#xA;    /* ICR interrupt vector */&#xA;    ISR(TIMER1_CAPT_vect) {&#xA;      //ISR=Interrupt Service Routine, and timer1 capture event&#xA;      //toggleCaptureEdge&#xA;      TCCR1B ^= _BV(ICES1);&#xA;      //toggles the edge that triggers the handler so that the duration of both high and low pulses is measured.&#xA;      bit_time = ICR1; //this is the value the timer generates&#xA;      //resetTimer1&#xA;      TCNT1 = 0;&#xA;      // Ignore phase changes &amp;lt; time for 1 bit or &amp;gt; time for zero bit (zero bit phase change time is double that of 1 bit)&#xA;      if ((bit_time &amp;lt; one_time_min) || (bit_time &amp;gt; zero_time_max)) {&#xA;        // this gets rid of anything that's not what we're looking for&#xA;        total_bits = 0;&#xA;      } else {&#xA;        // If the bit we are reading is a 1 then ignore the first phase change&#xA;        if (ones_bit_count == true)&#xA;          // only count the second ones pulse&#xA;          ones_bit_count = false;&#xA;        else {&#xA;          // We have already checked the outer times for 1 and zero bits so no see if the inner time is &amp;gt; zero min&#xA;          if (bit_time &amp;gt; zero_time_min) {&#xA;            // We have a zero bit&#xA;            current_bit = 0;&#xA;            sync_count = 0; // Not a 1 bit so cannot be part of the 12 bit sync&#xA;          } else {&#xA;            // It must be a 1 bit then&#xA;            ones_bit_count = true; // Flag so we don't read the next edge of a 1 bit&#xA;            current_bit = 1;&#xA;            sync_count++; // Increment sync bit count&#xA;            if (sync_count == 12) {&#xA;              // part of the last two bytes of a timecode word&#xA;              // We have 12 1's in a row that can only be part of the sync&#xA;              sync_count = 0;&#xA;              tc_sync = true;&#xA;              total_bits = end_sync_position;&#xA;            }&#xA;          }&#xA;    &#xA;          if (total_bits &amp;lt;= end_data_position) {&#xA;            // timecode runs least to most so we need&#xA;            // to shift things around&#xA;            tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;            for(int n=1;n&amp;lt;8;n++) {&#xA;              //creates tc[1-8]&#xA;              if(tc[n] &amp;amp; 1) tc[n-1] |= 0x80;&#xA;              tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;            }&#xA;            if(current_bit == 1) tc[7] |= 0x80;&#xA;          }&#xA;          total_bits++;&#xA;        }&#xA;        if (total_bits == end_smpte_position) {&#xA;          // we have the 80th bit&#xA;          total_bits = 0;&#xA;          if (tc_sync) {&#xA;            tc_sync = false;&#xA;            valid_tc_word = true;&#xA;          }&#xA;        }&#xA;        if (total_bits &amp;lt;= end_data_position) {&#xA;          // timecode runs least to most so we need&#xA;          // to shift things around&#xA;          tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;          for(int n=1;n&amp;lt;8;n++) {&#xA;            //creates tc[1-8]&#xA;            if(tc[n] &amp;amp; 1) tc[n-1] |= 0x80;&#xA;            tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;          }&#xA;          if(current_bit == 1) tc[7] |= 0x80;&#xA;        }&#xA;        total_bits++;&#xA;      }&#xA;    &#xA;      if (total_bits == end_smpte_position) {&#xA;        // we have the 80th bit&#xA;        total_bits = 0;&#xA;        if (tc_sync) {&#xA;          tc_sync = false;&#xA;          valid_tc_word = true;&#xA;        }&#xA;      }&#xA;    &#xA;      if (valid_tc_word) {&#xA;        valid_tc_word = false;&#xA;        timeCode[10] = (tc[0]&amp;amp;0x0F)+0x30;&#xA;        // frames  this converst from binary to decimal giving us the last digit&#xA;        timeCode[9] = (tc[1]&amp;amp;0x03)+0x30;&#xA;        // 10's of frames this converst from binary to decimal giving us the first digit&#xA;        timeCode[8] =  ':';&#xA;        timeCode[7] = (tc[2]&amp;amp;0x0F)+0x30; // seconds&#xA;        timeCode[6] = (tc[3]&amp;amp;0x07)+0x30; // 10's of seconds&#xA;        timeCode[5] =  ':';&#xA;        timeCode[4] = (tc[4]&amp;amp;0x0F)+0x30; // minutes&#xA;        timeCode[3] = (tc[5]&amp;amp;0x07)+0x30; // 10's of minutes&#xA;        timeCode[2] = ':';&#xA;        timeCode[1] = (tc[6]&amp;amp;0x0F)+0x30; // hours&#xA;        timeCode[0] = (tc[7]&amp;amp;0x03)+0x30; // 10's of hours&#xA;        drop_frame_flag = bit_is_set(tc[1], 2);&#xA;        //detects whether theree is the drop frame bit.&#xA;        write_tc_out = true;&#xA;      }&#xA;    }&#xA;    &#xA;    void setup() {&#xA;      lcd.begin (16, 2);&#xA;      pinMode(icpPin, INPUT); // ICP pin (digital pin 8 on arduino) as input&#xA;      bit_time = 0;&#xA;      valid_tc_word = false;&#xA;      ones_bit_count = false;&#xA;      tc_sync = false;&#xA;      write_tc_out = false;&#xA;      drop_frame_flag = false;&#xA;      total_bits =  0;&#xA;      current_bit =  0;&#xA;      sync_count =  0;&#xA;      lcd.print(&amp;quot;FINISHED SETUP&amp;quot;);&#xA;      delay (1000);&#xA;      TCCR1A = B00000000; // clear all&#xA;      TCCR1B = B11000010; // ICNC1 noise reduction + ICES1 start on rising edge + CS11 divide by 8&#xA;      TCCR1C = B00000000; // clear all&#xA;      TIMSK1 = B00100000; // ICIE1 enable the icp&#xA;      TCNT1 = 0; // clear timer1&#xA;    }&#xA;    &#xA;    void loop() {&#xA;      if (write_tc_out) {&#xA;        write_tc_out = false;&#xA;        if (drop_frame_flag)&#xA;          lcd.print(&amp;quot;TC-[df] &amp;quot;);&#xA;        else&#xA;          lcd.print(&amp;quot;TC-NO DROP FRAME&amp;quot;);&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print((char*)timeCode);&#xA;        lcd.print(&amp;quot;\r&amp;quot;);&#xA;        lcd.setCursor(11, 1);&#xA;        lcd.print(&amp;quot;......&amp;quot;);&#xA;        delay (30);&#xA;        lcd.clear();&#xA;      }&#xA;    }&#xA;111&#xA;&#xA;  [1]: https://i.stack.imgur.com/V6CxE.jpg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="262" LastEditorUserId="90731" LastEditDate="2023-08-24T14:21:45.370" LastActivityDate="2023-08-24T14:21:45.370" Title="SMPTE Timecode Reader with LCD display coding question" Tags="|arduino-uno|lcd|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="341" PostTypeId="2" ParentId="340" CreationDate="2014-02-21T18:10:45.933" Score="1" Body="&lt;p&gt;The one_time_max, one_time_min, zero_time_max and zero_time_min are all defines at the top of the file. This will insert them as constant values at compile time. This makes changing the code to deal with them slightly awkward, but not impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oddly, the one_time_max value isn't used, but the others are. To allow you to switch between PAL and NTSC, I would do the following (this is marginally lazy, but quick):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;change one_time_max to ONE_TIME_MAX_NTSC and ONE_TIME_MAX_PAL so that you have two defined constants for each part. Caps is convention for defines.&lt;/li&gt;&#xA;&lt;li&gt;create a new global variable, a boolean, that is a flag to decide if PAL or NTSC is to be decoded.&lt;/li&gt;&#xA;&lt;li&gt;every time that one of the constant is used, use a conditional statement based on the global variable to decided which constants are used.&lt;/li&gt;&#xA;&lt;li&gt;use the input from a button to decided the value of the global variable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-21T18:23:59.083" LastActivityDate="2014-02-21T18:23:59.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="342" PostTypeId="1" AcceptedAnswerId="344" CreationDate="2014-02-21T19:30:53.623" Score="6" ViewCount="625" Body="&lt;p&gt;I have Arduino Uno with SD card shield. I'm planning to log a huge amount of data from various sensors - including accelerometers and 3D compass - to the SD card. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have understood that Arduino, 64GB SD, FAT and large amount of data are not working too well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Arduino work well with this amount of data on FAT? There's no need to read any data from SD on Arduino. If not, is there a better approach? Writing directly to SD without FAT? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This data logger will be on the environment where no computer or network connection is available. Performance is not an issue - around 8kB/s (over three months) is already enough.&lt;/p&gt;&#xA;" OwnerUserId="261" LastEditorUserId="220" LastEditDate="2014-02-23T14:56:34.517" LastActivityDate="2014-02-23T14:56:34.517" Title="Logging multiple gigabytes of data with Arduino" Tags="|fat|sd-card|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="343" PostTypeId="1" AcceptedAnswerId="347" CreationDate="2014-02-21T21:29:25.117" Score="14" ViewCount="16476" Body="&lt;p&gt;When I compile this sketch for the Yún:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 7;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sketch uses 5,098 bytes (17%) of program storage space. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Maximum is&#xA;  28,672 bytes. Global variables use 153 bytes (5%) of dynamic memory,&#xA;  leaving 2,407 bytes for local variables. Maximum is 2,560 bytes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Even when I compile the BareMinimum sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {                &#xA;  // setup    &#xA;}&#xA;&#xA;void loop() {&#xA;  // loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sketch uses 4,548 bytes (15%) of program storage space.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Maximum is&#xA;  28,672 bytes. Global variables use 151 bytes (5%) of dynamic memory,&#xA;  leaving 2,409 bytes for local variables. Maximum is 2,560 bytes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why does a bare minimum sketch take up 15% of the program storage space allocated? And why does a very simple sketch take up 17% of the program storage space? According to &lt;a href=&quot;http://arduino.cc/en/Tutorial/Memory#.UwfEavkiEw8&quot;&gt;the Arduino website&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's easy to use it all up by having lots of strings in your program.&#xA;  For example, a declaration like: &lt;code&gt;char message[] = &quot;I support the Cape&#xA;  Wind project.&quot;;&lt;/code&gt; puts 33 bytes into SRAM (each character takes a byte,&#xA;  plus the '\0' terminator).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, there aren't any strings declared in either of these sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems as if they might import or use other libraries/classes that I don't specify. Maybe it imports a system default library? Or is it something else?&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-21T21:38:07.423" LastActivityDate="2015-07-07T08:12:16.963" Title="Why do sketches take up so much space and memory?" Tags="|programming|compile|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="344" PostTypeId="2" ParentId="342" CreationDate="2014-02-21T21:33:58.613" Score="1" Body="&lt;p&gt;I'm not sure where you have the impression it won't work. I haven't used 64GB cards, but have used 32GB cards and they work fine in terms of FAT32 and writing files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you have already worked out, reading or searching the file system can get very slow as size increases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I have found that larger capacity cards are more likely to have problems with the SPI interface being poor quality. Consumer devices do not use the SPI interface, and it seems that some manufacturers are willing to skimp on this side of it. The SPI interface can be buggy or unstable as a result. Genuine name-brand cards should work fine though.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-02-21T21:33:58.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="345" PostTypeId="2" ParentId="343" CreationDate="2014-02-21T21:36:27.060" Score="7" Body="&lt;p&gt;Arduino compiles in a lot of standard libraries, interrupts, ... etc. For example the pinMode and digitalWrite functions use a lookup table to figure out at run time which GPIO registers to write data to. Another example is that Arduino keeps track of time, it defines some interrupts by default and all this functionality requires some space. You'll notice that if you extend the program, the foot print will only change slightly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally like to program controllers with bare minimum, without &quot;bloat&quot;, but you'll quickly enter the world of EE.SE and SO because several easy to use functions will no longer work out of the box. There are some alternative libraries for pinMode and digitalWrite that compile into a smaller footprint, but come with other disadvantages like for example static compiled pins (where &lt;code&gt;led&lt;/code&gt; cannot be a variable, but is a constant).&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-21T21:43:59.177" LastActivityDate="2014-02-21T21:43:59.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="346" PostTypeId="2" ParentId="342" CreationDate="2014-02-22T05:33:04.717" Score="1" Body="&lt;p&gt;You should consider using &lt;a href=&quot;http://code.google.com/p/sdfatlib/&quot; rel=&quot;nofollow&quot;&gt;sdfatlib&lt;/a&gt;. This is currently supported version. Where an early version of this was the predecessor the IDE's stock SD library. SdFat better supports newer and larger SdCards, along with more features.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-22T05:33:04.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="347" PostTypeId="2" ParentId="343" CreationDate="2014-02-22T05:58:42.613" Score="7" Body="&lt;p&gt;The YUN is a combo. Part Arduino and Part OpenWRT(Linux). Your question is in reference to the Arduino. Where this is actually a ATmega32u4 similar to a Leonardo and not an UNO(ATmega328p). The 32u4(Leo) communicates via Virtual Serial Ports over the USB &lt;em&gt;(short answer: this needs to be supported)&lt;/em&gt; , where the UNO has a real Serial Port (aka UART). Below are builds statistics of the different boards types for the AVR processors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note on the UNO there is an external chip that converts USB to the Serial port's DTR pin which toggles the ATmega328's reset pin when connected causing a reboot to the bootloader. In contrast the Leo/Yun's USB to Serial is in implemented in the firmware of the 32u4. Hence in order to remotely reboot the Leo or YUN's 32u4 chip the firmware loaded must always support the USB client side driver. Which consumes approximately 4K. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the USB was NOT needed and no other library resources were called as in the case of BareMinimum.ino on an UNO, only approximately 466 bytes are needed for the core Arduino Library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;compile stats of BareMinimum.ino on a UNO(ATmega328p)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 466 bytes (1%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;compile stats of BareMinimum.ino on a Leonardo(ATmega32u4)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 4,554 bytes (15%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 151 bytes (5%) of dynamic memory, leaving 2,409 bytes for local variables. Maximum is 2,560 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;compile stats of BareMinimum.ino on a Yun(ATmega32u4)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 4,548 bytes (15%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 151 bytes (5%) of dynamic memory, leaving 2,409 bytes for local variables. Maximum is 2,560 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-22T05:58:42.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="348" PostTypeId="1" AcceptedAnswerId="998" CreationDate="2014-02-22T07:31:10.457" Score="92" ViewCount="55392" Body="&lt;p&gt;It's been a long time I've been looking for a good answer to this question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, any Arduino project but the simplest one will include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The main source code file &lt;code&gt;MyProject.ino&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Libraries specific to the project (&lt;code&gt;MyProjectLibrary1.h&lt;/code&gt;, &lt;code&gt;MyProjectLibrary1.cpp&lt;/code&gt;...)&lt;/li&gt;&#xA;&lt;li&gt;Third-party libraries (generally free open source, added manually to Arduino libraries directory)&lt;/li&gt;&#xA;&lt;li&gt;Schematics, PCB diagrams&lt;/li&gt;&#xA;&lt;li&gt;Documentation&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All this makes it hard to keep the whole code and doc of one project under Source Code Management (e.g. on Subversion, Git or GitHub).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Managing source control of your project means managing the version of all files used by the project including 3rd-party libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for a single project, I need to define a directory structure that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Includes all project files as described above&lt;/li&gt;&#xA;&lt;li&gt;I can entirely commit to a Source Code Management tool (including 3rd-party dependencies)&lt;/li&gt;&#xA;&lt;li&gt;I can checkout anywhere on my hard drive and build the project from there (does it have to be a single location as imposed by Arduino IDE)&lt;/li&gt;&#xA;&lt;li&gt;I can zip into a self-contained archive that I can send to a friend for him to build as easily as possible (no extra manual download)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I find particularly tricky with Arduino projects is the management of external libraries dependencies. Java projects developers have &lt;a href=&quot;http://maven.apache.org&quot;&gt;maven&lt;/a&gt; repositories for that and that helps a lot in managing all external deps. But we don't have an equivalent system for Arduino libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be interested to know how other Arduino project makers deal with these aspects in their own projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that I am open to changing my development process, including my IDE (currently I use Eclipse with the Arduino plugin most of the time, and then I ensure my projects can also work directly with the Arduino IDE).&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-02-22T17:26:58.043" LastActivityDate="2021-12-02T16:01:54.027" Title="How to organize my Arduino projects' structure for easy source control?" Tags="|project|version-control|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="349" PostTypeId="2" ParentId="337" CreationDate="2014-02-22T08:11:33.753" Score="6" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/337/would-an-infinite-loop-inside-loop-perform-faster#339&quot;&gt;Cybergibbons's answer&lt;/a&gt; describes quite nicely the assembly code generation and the differences amongst the two techniques. This is intended to be a complementary answer looking at the issue in terms of &lt;em&gt;practical&lt;/em&gt; differences, i.e. how much of a difference either approach will make in terms of &lt;em&gt;execution time&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code Variations&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I did an &lt;a href=&quot;http://github.com/AsheeshR/Arduino-Loop-Analysis&quot; rel=&quot;nofollow noreferrer&quot;&gt;analysis&lt;/a&gt; involving the following variations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Basic &lt;code&gt;void loop()&lt;/code&gt; (which gets inlined on compilation)&lt;/li&gt;&#xA;&lt;li&gt;Un-inlined &lt;code&gt;void loop()&lt;/code&gt; (using &lt;code&gt;__attribute__ ((noinline))&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Loop with &lt;code&gt;while(1)&lt;/code&gt; (which gets optimized)&lt;/li&gt;&#xA;&lt;li&gt;Loop with un-optimized &lt;code&gt;while(1)&lt;/code&gt; (by adding &lt;code&gt;__asm__ __volatile__(&quot;&quot;);&lt;/code&gt;. This is a &lt;code&gt;nop&lt;/code&gt; instruction that prevents optimization of the loop without resulting in additional overheads of a &lt;code&gt;volatile&lt;/code&gt; variable)&lt;/li&gt;&#xA;&lt;li&gt;An un-inlined &lt;code&gt;void loop()&lt;/code&gt; with optimized &lt;code&gt;while(1)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;An un-inlined &lt;code&gt;void loop()&lt;/code&gt; with un-optimized &lt;code&gt;while(1)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The sketches can be found &lt;a href=&quot;http://github.com/AsheeshR/Arduino-Loop-Analysis/tree/master/Code/Sketches&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Experiment&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I ran each of these sketches for 30 seconds, thereby accumulating &lt;a href=&quot;http://github.com/AsheeshR/Arduino-Loop-Analysis/tree/master/Data&quot; rel=&quot;nofollow noreferrer&quot;&gt;300 data points each&lt;/a&gt;. There was a 100 millisecond &lt;code&gt;delay&lt;/code&gt; call in each loop (without which &lt;a href=&quot;https://electronics.stackexchange.com/q/12300/18583&quot;&gt;bad things happen&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Results&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I then calculated the mean execution times of each loop, subtracted 100 milliseconds from each and then plotted the results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://github.com/AsheeshR/Arduino-Loop-Analysis/blob/master/Data/Munged/runtime.csv&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://raw2.github.com/AsheeshR/Arduino-Loop-Analysis/master/Figures/timeplot.png&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An un-optimised &lt;code&gt;while(1)&lt;/code&gt; loop within &lt;code&gt;void loop&lt;/code&gt; is faster than a compiler optimised  &lt;code&gt;void loop&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;The time difference between the un-optimized code and default Arduino  optimized code is insignificant &lt;em&gt;practically&lt;/em&gt;. You will be better off compiling manually using &lt;code&gt;avr-gcc&lt;/code&gt; and using your own optimisation flags rather than depending on the Arduino IDE to help you with it (if you need microsecond optimisations). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;&lt;strong&gt;NOTE:&lt;/strong&gt; The actual time values are not of significance here, the difference between them is. The ~90 microseconds of execution time includes a call to &lt;code&gt;Serial.println&lt;/code&gt;, &lt;code&gt;micros&lt;/code&gt; and &lt;code&gt;delay&lt;/code&gt;.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;&lt;strong&gt;NOTE2:&lt;/strong&gt; This was done using the Arduino IDE and the default compiler flags that it supplies.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&#xA;&lt;strong&gt;NOTE3:&lt;/strong&gt; Analysis (plot and calculations) was done using R.&#xA;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-02-28T17:02:48.370" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="350" PostTypeId="2" ParentId="331" CreationDate="2014-02-22T12:51:58.380" Score="1" Body="&lt;p&gt;Rather than using microprocessor-specific low-level programming, I was able to get a suitable signal using the core &lt;code&gt;tone()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tone(11, 2000000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It can be used to generate a 50% duty cycle square wave of a custom frequency on any individual GPIO pin (I'm using 11 in this case). Given the name, it's obviously designed for producing simple audio output, and 2 MHz is way above the range of human hearing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation doesn't list any upper limit on the frequency though, and the code it's based on doesn't appear to introduce any limitations. With that said, it clearly can't run faster than the internal timer it's based on (which I think will typically be 8 or 16 MHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems reasonable to assume that it will be in-sync with the microprocessor's internal clock, although I haven't been able to confirm that empirically as I don't have suitable equipment at home. Similarly, I haven't been able to confirm that it's &lt;em&gt;actually&lt;/em&gt; producing a 2 MHz signal, but the LCD display is working properly so it's likely to be in the right vicinity. I had previously tried running it from regular PWM, but that didn't work, so frequency is obviously important here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The signal can be stopped by calling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noTone(11);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are a couple of caveats to be aware of when using &lt;code&gt;tone()&lt;/code&gt;. First of all, it can only work on a single pin at a time, so you can't generate multiple signals with it. And secondly, it will prevent some PWM output from working properly (on pins 3 and 11, according to the documentation). This is because it has to reconfigure one of the internal timers which is normally used for PWM.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-22T12:51:58.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="351" PostTypeId="2" ParentId="348" CreationDate="2014-02-22T18:38:39.317" Score="25" Body="&lt;p&gt;The simplest way to do this is to copy the header and code files of the library into your source directory and include them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myproject/&#xA;    myproject.ino&#xA;    somelib.h&#xA;    somelib.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your code, you can do &lt;code&gt;include &quot;somelib.h&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The down side to this is that the libraries must be in the same folder, not sub folders, so it makes your directory look messy.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding the directory structure of my entire project, including schematics and documentation, mine usually looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myproject/&#xA;  schematics/ - eagle files or whatever you may have&#xA;  docs/       - include relevant datasheets here&#xA;  test/       - any test cases or other code to test parts of the system.&#xA;  myproject/  - since Arduino code must be in a directory of the same name&#xA;    myproject.ino&#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-02-22T19:59:51.550" LastActivityDate="2014-02-22T19:59:51.550" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="352" PostTypeId="2" ParentId="4" CreationDate="2014-02-22T22:25:54.133" Score="1" Body="&lt;p&gt;As Federico Fissore says above, the Yún can only handle HTTPS (or SSL, whatever you want to call it) on the Linux side of the Yún.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first way to do it is using Python with Python OpenSSL. The way you do this is by issuing the following commands via SSH or YunSerialTerminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opkg update&#xA;opkg install python-openssl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;opkg update&lt;/code&gt; will make sure the package list is up-to-date, and then &lt;code&gt;opkg install&lt;/code&gt; installs Python OpenSSL. And then you can talk to the Arduino using Python. &lt;a href=&quot;http://playground.arduino.cc/interfacing/python#.Uwki4_kiEw8&quot; rel=&quot;nofollow&quot;&gt;This page on the Arduino website&lt;/a&gt; should help you in using Python with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use &lt;code&gt;curl&lt;/code&gt; with the &lt;code&gt;-k&lt;/code&gt; option in your sketch. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Process process;&#xA;process.runShellCommand(&quot;curl -k http://example.net&quot;);&#xA;while(p.running()); // this waits for the command to be done before continuing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, if you want to download a file, you could use &lt;code&gt;wget&lt;/code&gt;. This would require you to upgrade &lt;code&gt;wget&lt;/code&gt; by again issuing these commands via SSH or YunSerialTerminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opkg update&#xA;opkg upgrade wget&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you can just do this in your sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Process process;&#xA;process.runShellCommand(&quot;wget http://example.net&quot;);&#xA;while(p.running()); // this waits for the command to be done before continuing&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="35" LastActivityDate="2014-02-22T22:25:54.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="353" PostTypeId="1" AcceptedAnswerId="358" CreationDate="2014-02-23T00:31:46.827" Score="3" ViewCount="6002" Body="&lt;p&gt;I have a clone of a Mega 2560, and the Chinese manufacture apparently had a broken shift key. To my annoyance, whenever I connect it to my computer it reads, &lt;code&gt;arduino compatible mega 2560&lt;/code&gt;. With my extreme &lt;em&gt;annoyance&lt;/em&gt; with &lt;em&gt;slightly&lt;/em&gt; misspelled or incorrectly capitalised English, it has been very distracting to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the reason that I'm asking this question is for more than how to rename it to be capitalised. Think of how many projects could be simplified by this! Or for many Arduinos, you can label they physically and then rename them &lt;code&gt;Arduino #1&lt;/code&gt;, etc. so you can tell which port it is on using device manager. If you designed a product with Arduino, then you can even rename it to your product name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I would imagine that there would be an easy way to do this by reburning the firmware to the [Insert USB chip model #### here].&lt;/strong&gt; I've seen it done for keyboards on the Uno, so I would imagine that you could modify it somehow.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-04-16T17:59:17.803" Title="How can I rename how my Arduino shows up on the computer?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="354" PostTypeId="2" ParentId="91" CreationDate="2014-02-23T00:37:25.183" Score="2" Body="&lt;p&gt;Another very cool screen is the official &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=product_info&amp;amp;products_id=288#.UwlAY_kiEw8&quot; rel=&quot;nofollow&quot;&gt;Arduino TFT LCD Screen&lt;/a&gt;. (&lt;a href=&quot;http://arduino.cc/documents/datasheets/A000096_Datasheet_HTF0177SN-01-SPEC.pdf&quot; rel=&quot;nofollow&quot;&gt;Datasheet&lt;/a&gt; if you're curious.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a 1.77&quot; screen, with a resolution of 160x128. It has a micro-SD slot in it, which is easily accessible. It is a color screen, with up to 18 bit per pixel. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The extremely nice thing with this screen is that since it's officially supported, you don't need to do anything extra to support it. The &lt;a href=&quot;http://arduino.cc/en/Reference/TFTLibrary#.UwlB__kiEw8&quot; rel=&quot;nofollow&quot;&gt;official Arduino TFT library&lt;/a&gt; works perfectly with it. However, according to &lt;a href=&quot;http://www.jameco.com/1/1/52373-a000096-tft-lcd-screen-runs-5vdc-shields.html&quot; rel=&quot;nofollow&quot;&gt;Jameco&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Library Update: There is a known issue with the TFT library supplied&#xA;  in IDE versions 1.0.5 and 1.5.4 Beta. You will need to replace the&#xA;  library. We have zipped up the updated TFT library for both versions&#xA;  available here. Just delete the existing library and copy in the&#xA;  replacement for the appropriate IDE version and restart the IDE. (IDE&#xA;  v1.0.5 or v1.5.4)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So beside that minor fix, everything should be easy and quick to work with. &lt;a href=&quot;http://arduino.cc/en/Reference/TFTLibrary#.UwlB__kiEw8&quot; rel=&quot;nofollow&quot;&gt;This page&lt;/a&gt; has some code samples which should make it easy to work with.&lt;/p&gt;&#xA;" OwnerUserId="35" LastActivityDate="2014-02-23T00:37:25.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="355" PostTypeId="1" AcceptedAnswerId="361" CreationDate="2014-02-23T02:40:20.173" Score="22" ViewCount="7673" Body="&lt;p&gt;The Arduino Uno board has limited RAM which means it has a limited call stack available. Sometimes, recursion is the only quick option to implement a certain algorithm. So, given that the call stack is severely limited, what would be a way to find out that given a certain program running on the board, exactly how many recursive calls can you afford before there is a stack overflow (and bad things happen)?&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-23T02:45:37.733" LastActivityDate="2018-03-24T07:47:25.893" Title="How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW" Tags="|programming|sram|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="356" PostTypeId="1" AcceptedAnswerId="357" CreationDate="2014-02-23T05:06:01.823" Score="3" ViewCount="947" Body="&lt;p&gt;I'd like to be able to use Python from a sketch. According to &lt;a href=&quot;http://playground.arduino.cc/interfacing/python#.Uwl-r6go6aw&quot; rel=&quot;nofollow&quot;&gt;the Arduino playground&lt;/a&gt;, one can use PySerial from a computer to talk with an Arduino via Python. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like from that page you can also use various API's to use Python with an Arduino from a computer. However, I'd like to know if you can execute Python directly from a sketch. It would be nice because then you could execute Python directly from a sketch, and not all of it would have to be written in Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not possible, is there an easy way to execute Python on an Arduino? Looking at the various API's it was hard to determine exactly what they did, and if you could execute a &lt;code&gt;.py&lt;/code&gt; script from a computer or from anything on the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T22:14:56.190" LastActivityDate="2014-02-23T22:14:56.190" Title="How can I use Python from a sketch?" Tags="|programming|python|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="357" PostTypeId="2" ParentId="356" CreationDate="2014-02-23T05:44:37.530" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It looks like from that page you can also use various API's to execute&#xA;  Python directly on the Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't see that, at all. All those links show you how to communicate with the Arduino over serial using Python on the host side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd need a python interpreter to be able to run python on the Arduino. There is the &lt;a href=&quot;https://code.google.com/p/python-on-a-chip/&quot;&gt;Python On A Chip&lt;/a&gt; project and it seems like they have support for the Mega.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2010/09/01 (1bdb8d31f27b) New platform: Arduino Mega.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some more info from the &lt;a href=&quot;https://wiki.python.org/moin/PyMite&quot;&gt;PyMite page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;any device in the AtMega family which meets these requirements: 20KiB&#xA;  Flash and 4K RAM, will run today&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I doubt you'll find anything that'll let you mix Arduino and Python code in the same sketch.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-23T05:44:37.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="358" PostTypeId="2" ParentId="353" CreationDate="2014-02-23T06:05:49.080" Score="5" Body="&lt;p&gt;This string is contained in the FT232 USB to UART interface chip and the manufacturer has released &lt;a href=&quot;http://www.ftdichip.com/Support/Utilities.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;the FT_PROG tool&lt;/a&gt; to reprogram it. But do take note of the warning on their website: &quot;&lt;strong&gt;PLEASE NOTE - The use of some of these utilities by an end user may result in a device being rendered useless&lt;/strong&gt;&quot;. Another word of warning is to &lt;strong&gt;ensure there is only one device connected with an FTDI-chip&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of the MProg tool:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8outD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="7699" LastEditDate="2015-04-16T17:59:17.803" LastActivityDate="2015-04-16T17:59:17.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="359" PostTypeId="2" ParentId="355" CreationDate="2014-02-23T06:30:01.247" Score="9" Body="&lt;p&gt;Recursion is bad practice on a microcontroller as you already stated yourself and you probably want to avoid it whenever possible. On &lt;a href=&quot;http://playground.arduino.cc/Code/AvailableMemory&quot;&gt;the Arduino site there are some examples and libraries available for checking free RAM size&lt;/a&gt;. You can for example use this to figure out when to break recursion or a bit trickier/riskier to profile your sketch and hard code the limit in it. This profile would be required for every change in your program and for every change in Arduino tool chain.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-23T06:30:01.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="360" PostTypeId="2" ParentId="355" CreationDate="2014-02-23T10:07:26.880" Score="6" Body="&lt;p&gt;It depends on the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time a function is called, a new frame is pushed onto the stack. It will usually contain various critical items, potentially including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Return address (the point in the code from which the function was called).&lt;/li&gt;&#xA;&lt;li&gt;The local instance pointer (&lt;code&gt;this&lt;/code&gt;) if calling a member function.&lt;/li&gt;&#xA;&lt;li&gt;Parameters passed into the function.&lt;/li&gt;&#xA;&lt;li&gt;Register values which need to be restored when the function ends.&lt;/li&gt;&#xA;&lt;li&gt;Space for local variables inside the called function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see, the stack space required for a given call depends on the function. For example, if you write a recursive function which only takes an &lt;code&gt;int&lt;/code&gt; parameter and uses no local variables, it won't need much more than a few bytes on the stack. That means you can recursively call it far more than a function which takes several parameters and uses a lot of local variables (which will eat up the stack much quicker).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously the state of the stack depends on what else is going on in the code. If you start a recursion directly within the standard &lt;code&gt;loop()&lt;/code&gt; function, then there probably won't be a lot on the stack already. However, if you start it nested several levels deep in other functions, then there won't be as much room. That will affect how many times you can recurse without exhausting the stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth noting that tail recursion optimisation exists on some compilers (although I'm not sure if avr-gcc supports it). If the recursive call is the very last thing in a function, it means it is sometimes possible to avoid altering the stack frame at all. The compiler can just re-use the existing frame, since the 'parent' call (so to speak) is finished using it. That will mean you can theoretically keep recursing as much as you like, so long as your function doesn't call anything else.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-23T10:07:26.880" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="361" PostTypeId="2" ParentId="355" CreationDate="2014-02-23T10:17:40.737" Score="15" Body="&lt;p&gt;If you really want to recurse (and as @jippie said it is a bad idea; subliminal message:  &lt;strong&gt;don't do it&lt;/strong&gt;) and want to know how much you can recurse, then you will have to perform some calculation and experiments; also you generally will have only an approximation of it as it depends a lot on the memory state at the time your recursive function will be called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, you should first know how SRAM is organized inside AVR-based Arduino (it won't apply to e.g. the Arduino Galileo by Intel). The following diagram &lt;a href=&quot;https://learn.adafruit.com/memories-of-an-arduino?view=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;from Adafruit&lt;/a&gt; shows it clearly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kosMi.gif&quot; alt=&quot;SRAM organization&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to know the total size of your SRAM (depends on Atmel MCU, hence what kind of Arduino board you have).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On this diagram, it is easy to find out ths size of &lt;strong&gt;Static Data&lt;/strong&gt; block as it is known at compile-time and won't change later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;Heap&lt;/strong&gt; size can be more difficult to know as it can vary at runtime, depending on dynamic memory allocations (&lt;code&gt;malloc&lt;/code&gt; or &lt;code&gt;new&lt;/code&gt;) performed by your sketch or the libraries it uses. Using dynamic memory is quite rare on Arduino, but some standard functions do it (type &lt;code&gt;String&lt;/code&gt; uses it, I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &lt;strong&gt;Stack&lt;/strong&gt; size, it will also vary during runtime, based on the current depth of function calls (each function call takes 2 bytes on the Stack to store the address of the caller) and the number and size of local variables including passed arguments (that are also stored on the &lt;strong&gt;Stack&lt;/strong&gt;) for all the functions called until now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So let's suppose your &lt;code&gt;recurse()&lt;/code&gt; function uses 12 bytes for its local variables and arguments, then each call to this function (the first one from an external caller and the recursive ones) will use &lt;code&gt;12+2&lt;/code&gt; bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we suppose that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you are on Arduino UNO (SRAM = 2K)&lt;/li&gt;&#xA;&lt;li&gt;your sketch does not use dynamic memory allocation (no &lt;strong&gt;Heap&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you know the size of your &lt;strong&gt;Static Data&lt;/strong&gt; (let's say 132 bytes)&lt;/li&gt;&#xA;&lt;li&gt;when your &lt;code&gt;recurse()&lt;/code&gt; function is called from your sketch, the current &lt;strong&gt;Stack&lt;/strong&gt; is 128 bytes long&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you are left with &lt;code&gt;2048 - 132 - 128 = 1788&lt;/code&gt; available bytes on the &lt;strong&gt;Stack&lt;/strong&gt;. The number of recursive calls to your function is thus &lt;code&gt;1788 / 14 = 127&lt;/code&gt;, including the initial call (which is not a recursive one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, this is very difficult, but not impossible to find what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simpler way to get the stack size available before &lt;code&gt;recurse()&lt;/code&gt; is called would be to use the following function (found on Adafruit learning center; I have not tested it myself):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freeRam () &#xA;{&#xA;  extern int __heap_start, *__brkval; &#xA;  int v; &#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I strongly encourage you to read &lt;a href=&quot;http://learn.adafruit.com/memories-of-an-arduino/you-know-you-have-a-memory-problem-when-dot-dot-dot&quot; rel=&quot;nofollow noreferrer&quot;&gt;this article&lt;/a&gt; at Adafruit learning center.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="7727" LastEditDate="2018-03-24T07:47:25.893" LastActivityDate="2018-03-24T07:47:25.893" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="362" PostTypeId="1" CreationDate="2014-02-23T11:23:48.887" Score="13" ViewCount="5305" Body="&lt;p&gt;Currently; when I start a new Arduino project with some new hardware, the first thing I do is to look for 3rd-party libraries that bring Arduino support for this hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first places I look are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/&quot;&gt;The Arduino Playground&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Generally I find either no support library or several different libraries (it's quite rare to find only one) in different locations with different levels of documentation, different levels of testing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I have found the library I need (sometimes I need to try several), I download it to my Arduino libraries folder, I use it and I forget it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find this process cumbersome:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;manual search with different possible options, not always well documented&lt;/li&gt;&#xA;&lt;li&gt;manual download and install to Arduino libraries&lt;/li&gt;&#xA;&lt;li&gt;no version control in the process (all versions of a library have the same name and thus cannot coexist in the Arduino library folder).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I wish there was a central repository with all available libraries for arduino, with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;description (supported hardware, supported boards)&lt;/li&gt;&#xA;&lt;li&gt;source code&lt;/li&gt;&#xA;&lt;li&gt;documentation&lt;/li&gt;&#xA;&lt;li&gt;versions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And a tool (Arduino IDE or external) to access this repository at project build time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A kind of &lt;a href=&quot;http://maven.apache.org&quot;&gt;maven&lt;/a&gt; for Arduino in fact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen several discussions once took place on Arduino forum, but it seems they led nowhere:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=73531.0&quot;&gt;Arduino Libraries Census and Repository&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,1460.0.html&quot;&gt;Arduino Library downloader&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,63215.0.html&quot;&gt;Arduino Library downloader (2)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there other options, that are made it to something usable (from the community or individuals, why not)?&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="65" LastEditDate="2014-02-23T13:11:33.853" LastActivityDate="2018-09-06T11:19:22.723" Title="Where can I find a central repository of all available Arduino libraries?" Tags="|library|" AnswerCount="7" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="363" PostTypeId="2" ParentId="362" CreationDate="2014-02-23T14:50:01.847" Score="2" Body="&lt;p&gt;There is none. Unfortunately, you will have to manually search for each library you are interested in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested in creating such a central repository, while it would be awesome, this is not the correct forum in which to do it.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-02-23T14:50:01.847" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="364" PostTypeId="2" ParentId="88" CreationDate="2014-02-23T14:54:03.270" Score="13" Body="&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins/67094#67094&quot;&gt;I'm going to steal my answer from when I answered this question on the last arduino SE attempt.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is a bit complex. Basically, there are a number of limiting factors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IO lines from the microcontroller (i.e. the analog and digital pins) have both an aggregate (e.g. total) current limit, and an per-pin limit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nLAlB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;&lt;sup&gt;&lt;sub&gt;From the &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega328P datasheet&lt;/a&gt;.&lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, depending on how you define the Arduino &quot;Pins&quot;, this is not the entire story. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 5V pin of the arduino is &lt;em&gt;not connected through the microcontroller&lt;/em&gt;. As such, it can source significantly more power. When you are powering your arduino from USB, the USB interface limits your total power consumption to 500 mA. This is shared with the devices on the arduino board, so the available power will be somewhat less.&lt;br&gt;&#xA;When you are using an external power supply, through the barrel power connector, you are limited by the local 5V regulator, which is rated for a maximum of &lt;strong&gt;1 Amp&lt;/strong&gt;. However, this it also &lt;em&gt;thermally limited&lt;/em&gt;, meaning that as you draw power, the regulator will heat up. When it overheats, it will shut down temporarily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 3.3V regulated output is able to supply 150 mA max, which is the limit of the 3.3V regulator.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;In Summary&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;em&gt;absolute maximum&lt;/em&gt; for any single IO pin is &lt;strong&gt;40 mA&lt;/strong&gt; (&lt;sub&gt;&lt;sup&gt;this is the &lt;em&gt;maximum&lt;/em&gt;. You should never actually pull a full 40 mA from a pin. Basically, it's the threshold at which Atmel can no longer guarantee the chip won't be damaged. You should always ensure you're safely &lt;em&gt;below&lt;/em&gt; this current limit.&lt;/sub&gt;&lt;/sup&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The total current from all the IO pins together is &lt;strong&gt;200 mA max&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;The 5V output pin is good for &lt;strong&gt;~400 mA on USB, ~900 mA when using an external power adapter&lt;/strong&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The 900 mA is for an adapter that provides ~7V. As the adapter voltage increases, the amount of heat the regulator has to deal with also increases, so the maximum current will drop as the voltage increases. &lt;sub&gt;&lt;sup&gt;This is called &lt;em&gt;thermal limiting&lt;/em&gt;&lt;/sup&gt;&lt;/sub&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;The 3.3V output is capable of supplying &lt;strong&gt;150 mA&lt;/strong&gt;. &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note - Any power drawn from the 3.3V rail &lt;em&gt;has to go through the 5V rail&lt;/em&gt;. Therefore, if you have a 100 mA device on the 3.3V output, you need to &lt;em&gt;also&lt;/em&gt; count it against the 5V total current.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;sub&gt;Note: This does not apply to the Arduino Due, and there are likely some differences for the Arduino Mega. It is likely generally true for any Arduino based off the ATmega328 microcontroller.&lt;/sub&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-02-23T14:54:03.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="365" PostTypeId="2" ParentId="355" CreationDate="2014-02-23T15:32:18.337" Score="1" Body="&lt;p&gt;I wrote this simple test program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(115200);&#xA;  recurse(1);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly: &#xA;&#xA;}&#xA;&#xA;void recurse(long i) {&#xA;  Serial.println(i);&#xA;  recurse(i+1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I compiled it for the Uno, and as i write it has recursed over 1 million times! I don't know, but the compiler may have optimized this program&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-02-23T15:32:18.337" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="366" PostTypeId="2" ParentId="362" CreationDate="2014-02-23T16:20:24.350" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Main/LibraryList&quot; rel=&quot;nofollow&quot;&gt;Arduino Playground LibraryList&lt;/a&gt; and the &lt;a href=&quot;http://arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;standard library list&lt;/a&gt; appear to be the official pages for that.&lt;/p&gt;&#xA;" OwnerUserId="37" LastActivityDate="2014-02-23T16:20:24.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="367" PostTypeId="5" CreationDate="2014-02-23T17:04:46.790" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-23T17:04:46.790" LastActivityDate="2014-02-23T17:04:46.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="368" PostTypeId="4" CreationDate="2014-02-23T17:04:46.790" Score="0" Body="a filesystem that allows files to be stored on a SD card or similar device on an Arduino." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T19:08:15.413" LastActivityDate="2014-02-23T19:08:15.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="369" PostTypeId="5" CreationDate="2014-02-23T17:06:23.627" Score="0" Body="&lt;p&gt;Item made in exact imitation of something valuable or important with the intention to deceive or defraud.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="37523" LastEditDate="2019-11-16T18:20:27.717" LastActivityDate="2019-11-16T18:20:27.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="370" PostTypeId="4" CreationDate="2014-02-23T17:06:23.627" Score="0" Body="Item made in exact imitation of something valuable or important with the intention to deceive or defraud." OwnerUserId="-1" LastEditorUserId="37523" LastEditDate="2019-11-16T18:20:27.717" LastActivityDate="2019-11-16T18:20:27.717" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="371" PostTypeId="5" CreationDate="2014-02-23T17:08:06.260" Score="0" Body="&lt;p&gt;An LED (Light Emitting Diode) is a semiconductor component which emits light (via electro-luminescence) when its forward voltage is sufficiently high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Arduino projects, small LEDs are commonly used as indicators. For example, it could be illuminated to show that a system is active/powered-on. LEDs typically operate at around 2-3 volts, requiring a current of 10-20 mA, meaning they can by powered directly from the digital output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For safety, an LED should normally be used with a current-limiting resistor in series.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDs can also be used for other purposes, including general illumination, and in opto-isolators.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="42" LastEditDate="2014-05-26T00:27:22.597" LastActivityDate="2014-05-26T00:27:22.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="372" PostTypeId="4" CreationDate="2014-02-23T17:08:06.260" Score="0" Body="An LED is a type of light source which is typically fairly small and has low power requirements." OwnerUserId="-1" LastEditorUserId="42" LastEditDate="2014-05-26T00:27:22.597" LastActivityDate="2014-05-26T00:27:22.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="373" PostTypeId="5" CreationDate="2014-02-23T17:10:15.540" Score="0" Body="&lt;p&gt;Serial communication is the standard USB connection between the Arduino and a computer with a standard USB A to B cable or through the TX/RX pins using a USB to serial converter. It can also refer to the serial library.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[Serial is] used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output.&#xA;  You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin().&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Excerpt from the &lt;a href=&quot;http://arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;Arduino Page about Serial&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Most boards have only one serial port.&lt;/strong&gt; Exceptions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Leonardo has two: one connected to USB and the other connected to pins 0 and 1 for connection to UART items.&lt;/li&gt;&#xA;&lt;li&gt;The Mega/Mega2560 has 4 serial ports, one connected to a UART to USB converter.&lt;/li&gt;&#xA;&lt;li&gt;The DUE also has 4 serial ports, one connected to a UART to USB converter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The serial is outputted through &lt;em&gt;UART&lt;/em&gt;. Then, for the primary serial connection on pins 0 and 1*, the data goes to a UART to serial chip** and then transferred to/from the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*On some boards, such as the Leonardo, it doesn't use the pins 0 and 1.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;**On some boards, such as the Leonardo, there is no USB chip because it is built into the chip itself, or it has no USB connection.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The serial library:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino includes &lt;a href=&quot;http://arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;a library for inferencing with the serial ports&lt;/a&gt;. Here is some example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // open the serial port at 9600 bps:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Hello World!&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-03-18T21:07:05.250" LastActivityDate="2014-03-18T21:07:05.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="374" PostTypeId="4" CreationDate="2014-02-23T17:10:15.540" Score="0" Body="Serial communication is the standard USB connection between the Arduino and a computer with a standard USB A to B cable or through the TX/RX pins using a USB to serial converter. It can also refer to the serial library." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T21:07:05.250" LastActivityDate="2014-03-18T21:07:05.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="375" PostTypeId="5" CreationDate="2014-02-23T17:12:34.490" Score="0" Body="&lt;p&gt;A clone is a legal, Arduino-like board developed by a third party using the original schematics for the board (with a few minor adjustments). If significant changes are made, it is called a derivative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/qgJGS5w.png&quot; &gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;All Arduino clones follow the &lt;a href=&quot;http://arduino.cc/en/Main/FAQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;naming guidelines&lt;/a&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;While unofficial products should not have &quot;Arduino&quot; in their name, it's okay to describe your product in relation to the Arduino project and platform. Here are a few guidelines that explain which uses we consider reasonable. Not okay:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Arduino Xxxxxx&lt;/li&gt;&#xA;  &lt;li&gt;Xxxxxx Arduino&lt;/li&gt;&#xA;  &lt;li&gt;Arduino Compatible Xxxxxx - use &quot;Xxxxxx (Arduino-Compatible)&quot; instead&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Okay:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Xxxxxx for Arduino - products that work with official Arduino boards (e.g. shields or kits)&lt;/li&gt;&#xA;  &lt;li&gt;Xxxxxx (Arduino-Compatible) - variations and clones which are software and hardware compatible Note that while we don't attempt to&#xA;  restrict uses of the &quot;duino&quot; suffix, its use causes the Italians on&#xA;  the team to cringe (apparently it sounds terrible); you might want to&#xA;  avoid it. (It's also trademarked by a Hungarian company.)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-03-18T22:15:31.890" LastActivityDate="2014-03-18T22:15:31.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="376" PostTypeId="4" CreationDate="2014-02-23T17:12:34.490" Score="0" Body="A clone is a legal, Arduino-like board developed by a third party using the original schematics for the board (with a few minor adjustments). If significant changes are made, it is called a derivative." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T22:15:31.890" LastActivityDate="2014-03-18T22:15:31.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="377" PostTypeId="5" CreationDate="2014-02-23T17:44:57.963" Score="0" Body="&lt;p&gt;Python is a programming language. It is often used as a scripting language, but has many other uses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag for questions regarding how to use Python with your Arduino, or on using of pySerial and other software that lets you use Python on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider using &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; and other tags more specific to your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/interfacing/python#.Uwl-r6go6aw&quot; rel=&quot;nofollow&quot;&gt;This page on the Arduino website&lt;/a&gt; should help you to get up and running using Python with an Arduino. The main way to use Python with an Arduino is by using &lt;a href=&quot;http://pyserial.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;pySerial&lt;/a&gt;. pySerial is a desktop program compatible with Windows, Linux and other OS's. It is used to execute Python commands on an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T19:08:17.867" LastActivityDate="2014-02-23T19:08:17.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="378" PostTypeId="4" CreationDate="2014-02-23T17:44:57.963" Score="0" Body="Python is a programming language. Use this tag for questions regarding how to use Python with your Arduino, or on using of pySerial or such software. Also consider using [programming] and other specific tags." OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T19:07:52.193" LastActivityDate="2014-02-23T19:07:52.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="379" PostTypeId="5" CreationDate="2014-02-23T19:34:47.960" Score="0" Body="&lt;p&gt;The Arduino Uno SMD is a &quot;branch&quot; of the Arduino Uno board that has a SMD (surface mount chip) that is smaller and cheaper, but not replaceable. It was developed when there was a shortage of ATMega328-PUs. It acts the same way as a &quot;standard&quot; Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From the &lt;strong&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoBoardUnoSMD&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno SMD page&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;:&#xA;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoUnoSmd.jpg&quot; &gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Uno SMD is a version of the Arduino Uno, but uses an&#xA;  surface mount version of the Atmega328P instead of the through-hole&#xA;  version. This version was made in response to a shortage in supply of&#xA;  the through-hole Atmega328P. The board is based on the ATmega328&#xA;  (datasheet). It has 14 digital input/output pins (of which 6 can be&#xA;  used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a&#xA;  USB connection, a power jack, an ICSP header, and a reset button. It&#xA;  contains everything needed to support the microcontroller; simply&#xA;  connect it to a computer with a USB cable or power it with a AC-to-DC&#xA;  adapter or battery to get started.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.117" LastActivityDate="2014-03-18T22:19:11.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="380" PostTypeId="4" CreationDate="2014-02-23T19:34:47.960" Score="0" Body="The Arduino Uno SMD is a &quot;branch&quot; of the Arduino Uno board that has a SMD (surface mount chip) that is smaller and cheaper, but not replaceable. It was developed when there was a shortage of ATMega328-PUs. It acts the same way as a &quot;standard&quot; Arduino Uno." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T22:19:11.420" LastActivityDate="2014-03-18T22:19:11.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="381" PostTypeId="5" CreationDate="2014-02-23T19:36:50.533" Score="0" Body="&lt;p&gt;&quot;Pins&quot; are like gateways between the Arduino code running on the chip and the components attached to Arduino. It can refer either to the physical connectors on the board, or it can refer to the pins defined in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three main types of pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &lt;strong&gt;digital pin&lt;/strong&gt; is one that can detect and output a digital signal (i.e. either HIGH or LOW)&lt;/li&gt;&#xA;&lt;li&gt;An &lt;strong&gt;analog pin&lt;/strong&gt; works mostly like a digital pin, except that each one of them also includes an ADC (analogue to digital converter) which can give the Arduino values of 0 to 1024 that is proportional to the input voltage (i.e. 2.5V on a 5V board is 512).&lt;/li&gt;&#xA;&lt;li&gt;A &lt;strong&gt;PWM pin&lt;/strong&gt; (pulse width modulation) is a digital pin that can create a signals that goes on and off very fast. This can be used to create a dimming effect. For more questions related to PWM, see &lt;a href=&quot;/questions/tagged/pwm&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pwm&amp;#39;&quot; rel=&quot;tag&quot;&gt;pwm&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A pin can also refer to the physical &lt;em&gt;pin header&lt;/em&gt; that you connect wires to. &lt;em&gt;Connect the wire to the GND pin&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9bbhn.jpg&quot; alt=&quot;Arduino Uno&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardUno&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the photo above, there are 14 digital pins (six of those are PWM), 6 analog pins, and 12 other pins (GND, 5V, 3.3V, etc.).&lt;/p&gt;&#xA;" OwnerUserId="27346" LastEditorUserId="27346" LastEditDate="2018-10-14T19:13:36.180" LastActivityDate="2018-10-14T19:13:36.180" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="382" PostTypeId="4" CreationDate="2014-02-23T19:36:50.533" Score="0" Body="&quot;Pins&quot; are like gateways between the Arduino code running on the chip and the components attached to Arduino. It can refer either to the physical connectors on the board, or it can refer to the pins defined in the code." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T20:54:27.457" LastActivityDate="2014-03-18T20:54:27.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="383" PostTypeId="5" CreationDate="2014-02-23T19:40:38.510" Score="0" Body="&lt;p&gt;A library is a file that can be included into the code to add new instructions by combining many existing instructions and creating one easy to use instruction to call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is the list of libraries:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/Libraries&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;Standard Libraries:&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;EEPROM - reading and writing to &quot;permanent&quot; storage&lt;/li&gt;&#xA;  &lt;li&gt;Ethernet - for connecting to the internet using the Arduino Ethernet    Shield&lt;/li&gt;&#xA;  &lt;li&gt;Firmata - for communicating with applications on the computer using a    standard serial protocol.&lt;/li&gt;&#xA;  &lt;li&gt;GSM - for connecting to a GSM/GRPS network with the GSM shield.&lt;/li&gt;&#xA;  &lt;li&gt;LiquidCrystal - for controlling liquid crystal displays (LCDs)&lt;/li&gt;&#xA;  &lt;li&gt;SD - for reading and writing SD cards&lt;/li&gt;&#xA;  &lt;li&gt;Servo - for controlling servo motors&lt;/li&gt;&#xA;  &lt;li&gt;SPI - for communicating with devices using the Serial Peripheral    Interface (SPI) Bus&lt;/li&gt;&#xA;  &lt;li&gt;SoftwareSerial - for serial communication on any digital pins.    Version 1.0 and later of Arduino incorporate Mikal Hart's&lt;br&gt;&#xA;  NewSoftSerial library as SoftwareSerial.&lt;/li&gt;&#xA;  &lt;li&gt;Stepper - for controlling stepper motors&lt;/li&gt;&#xA;  &lt;li&gt;TFT - for drawing text , images, and shapes on the Arduino TFT screen&lt;/li&gt;&#xA;  &lt;li&gt;WiFi - for connecting to the internet using the Arduino WiFi shield&lt;/li&gt;&#xA;  &lt;li&gt;Wire - Two Wire Interface (TWI/I2C) for sending and receiving data    over a net of devices or sensors.&lt;/li&gt;&#xA;  &lt;li&gt;The Matrix and Sprite libraries are no longer part of the core    distribution.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;Due Only Libraries:&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Audio - Play audio files from a SD card.&lt;/li&gt;&#xA;  &lt;li&gt;Scheduler - Manage multiple non-blocking tasks.&lt;/li&gt;&#xA;  &lt;li&gt;USBHost - Communicate with USB peripherals like mice and keyboards.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;Esplora Only Libraries:&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Esplora - this library enable you to easily access to various sensors    and actuators mounted on the Esplora board.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;Arduino Robot Library:&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Robot - this library enables easy access to the functions of the    Arduino Robot&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;Arduino Yún Bridge Library:&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Bridge Library - Enables communication between the Linux processor    and the Arduino on the Yún.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;USB Libraries (Leonardo, Micro, Due, and Esplora)&lt;/h2&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Keyboard - Send keystrokes to an attached computer.&lt;/li&gt;&#xA;  &lt;li&gt;Mouse - Control cursor movement on a connected computer.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h2&gt;Contributed Libraries&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;If you're using one of these libraries, you need to install it first.&#xA;  See these instructions for details on installation. There's also a&#xA;  tutorial on writing your own libraries.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Communication (networking and protocols):&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Messenger - for processing text-based messages from the computer&lt;/li&gt;&#xA;  &lt;li&gt;NewSoftSerial - an improved version of the SoftwareSerial library&lt;/li&gt;&#xA;  &lt;li&gt;OneWire - control devices (from Dallas Semiconductor) that use the    One Wire protocol.&lt;/li&gt;&#xA;  &lt;li&gt;PS2Keyboard - read characters from a PS2 keyboard.&lt;/li&gt;&#xA;  &lt;li&gt;Simple Message System - send messages between Arduino and the    computer&lt;/li&gt;&#xA;  &lt;li&gt;SSerial2Mobile - send text messages or emails using a cell phone (via    AT commands over software serial)&lt;/li&gt;&#xA;  &lt;li&gt;Webduino - extensible web server library (for use with the Arduino    Ethernet Shield)&lt;/li&gt;&#xA;  &lt;li&gt;X10 - Sending X10 signals over AC power lines&lt;/li&gt;&#xA;  &lt;li&gt;XBee - for communicating with XBees in API mode&lt;/li&gt;&#xA;  &lt;li&gt;SerialControl - Remote control other Arduinos over a serial    connection&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Sensing:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Capacitive Sensing - turn two or more pins into capacitive sensors&lt;/li&gt;&#xA;  &lt;li&gt;Debounce - for reading noisy digital inputs (e.g. from buttons)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Displays and LEDs:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;GFX - base class with standard graphics routines (by Adafruit    Industries)&lt;/li&gt;&#xA;  &lt;li&gt;GLCD - graphics routines for LCD based on the KS0108 or equivalent    chipset.&lt;/li&gt;&#xA;  &lt;li&gt;Improved LCD library fixes LCD initialization bugs in official    Arduino LCD library&lt;/li&gt;&#xA;  &lt;li&gt;LedControl - for controlling LED matrices or seven-segment displays    with a MAX7221 or MAX7219.&lt;/li&gt;&#xA;  &lt;li&gt;LedControl - an alternative to the Matrix library for driving    multiple LEDs with Maxim chips.&lt;/li&gt;&#xA;  &lt;li&gt;LedDisplay - control of a HCMS-29xx scrolling LED display.&lt;/li&gt;&#xA;  &lt;li&gt;Matrix - Basic LED Matrix display manipulation library&lt;/li&gt;&#xA;  &lt;li&gt;PCD8544 - for the LCD controller on Nokia 55100-like displays (by    Adafruit Industries)&lt;/li&gt;&#xA;  &lt;li&gt;Sprite - Basic image sprite manipulation library for use in    animations with an LED matrix&lt;/li&gt;&#xA;  &lt;li&gt;ST7735 - for the LCD controller on a 1.8&quot;, 128x160 TFT screen (by    Adafruit Industries)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Audio and Waveforms:&lt;/strong&gt; FFT - frequency analysis of audio or other analog signals Tone - generate audio frequency square waves in the&#xA;  background on any microcontroller pin Motors and PWM: TLC5940 - 16&#xA;  channel 12 bit PWM controller.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Timing:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;DateTime - a library for keeping track of the current date and time    in software.&lt;/li&gt;&#xA;  &lt;li&gt;Metro - help you time actions at regular intervals&lt;/li&gt;&#xA;  &lt;li&gt;MsTimer2 - uses the timer 2 interrupt to trigger an action every N    milliseconds.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Utilities:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;PString - a lightweight class for printing to buffers&lt;/li&gt;&#xA;  &lt;li&gt;Streaming - a method to simplify print statements&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-03-18T21:36:49.553" LastActivityDate="2014-03-18T21:36:49.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="384" PostTypeId="4" CreationDate="2014-02-23T19:40:38.510" Score="0" Body="A library is a file that can be included into the code to add new instructions by combining many existing instructions and creating one easy to use instruction to call." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T23:16:34.540" LastActivityDate="2014-02-23T23:16:34.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="385" PostTypeId="5" CreationDate="2014-02-23T19:45:04.910" Score="0" Body="&lt;p&gt;The safety tag is for the well-being of the people and objects around you, and yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some general precautions for your Arduino:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't under/over power your Arduino&lt;/li&gt;&#xA;&lt;li&gt;Don't pull more than 40 mA on most boards from one digital pin&lt;/li&gt;&#xA;&lt;li&gt;Don't apply more than 5V to any pin (except VIN)&lt;/li&gt;&#xA;&lt;li&gt;Don't change a circuit while the Arduino is powered&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some general precautions for you/the people around you:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't apply mains to your Arduino.&lt;/li&gt;&#xA;&lt;li&gt;When powering high voltages with a relay, make sure to cover and seal any wires that might be connected to the high voltages.&lt;/li&gt;&#xA;&lt;li&gt;Arduino not to be used as a flotation device. Really, don't get your Arduino or any other part of your setup wet.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-03-18T21:25:09.593" LastActivityDate="2014-03-18T21:25:09.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="386" PostTypeId="4" CreationDate="2014-02-23T19:45:04.910" Score="0" Body="The safety tag is for the well-being of the people and objects around you, and yourself." OwnerUserId="220" LastEditorUserId="65" LastEditDate="2014-02-28T19:20:22.983" LastActivityDate="2014-02-28T19:20:22.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="387" PostTypeId="5" CreationDate="2014-02-23T19:46:16.137" Score="0" Body="&#xA;&#xA;&lt;p&gt;This tag should be used when writing code for the Arduino specifically using the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sketch has the following structure:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    ...&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;setup&lt;/code&gt; function is called once when the sketch starts. The &lt;code&gt;loop&lt;/code&gt; function then is called repeatedly until the board is either shut down or restarted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sketch is saved with the &lt;code&gt;.ino&lt;/code&gt; extension.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you are used to more traditional C programming, effectively what is done by the above is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  init ();  // set up hardware, particularly timers used by delay()&#xA;  setup (); // your own code, to be run once only&#xA;  while (true)&#xA;    loop ();  // do this repeatedly&#xA;  return 0;   // this is never executed&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a bit more complex than that, but that is the basic idea. Also the IDE lets you take control by writing your own &lt;code&gt;main()&lt;/code&gt; function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  ...  // do whatever you want here&#xA;  return 0;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do that, the &quot;normal&quot; main is ignored.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="10794" LastEditDate="2016-01-23T04:13:23.840" LastActivityDate="2016-01-23T04:13:23.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="388" PostTypeId="4" CreationDate="2014-02-23T19:46:16.137" Score="0" Body="A sketch is compiled code that is uploaded to an Arduino board." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:00:57.257" LastActivityDate="2014-02-23T21:00:57.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="389" PostTypeId="5" CreationDate="2014-02-23T19:48:51.823" Score="0" Body="&lt;p&gt;Shields are attachments that &quot;snap&quot; onto the Arduino board adding functionality. They are usually the same shape as an Uno/Leonardo/Duemilanove. Some examples are: the Ethernet (includes SD port) shield, motor shields, and sensor shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some of the official shields:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;GSM&lt;/a&gt;&lt;/strong&gt; (cell connectivity)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ethernet&lt;/a&gt;&lt;/strong&gt;&#xA;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoEthernetShield_R3_Front.jpg&quot; &gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://arduino.cc/en/Main/ArduinoMotorShieldR3&quot; rel=&quot;nofollow noreferrer&quot;&gt;Motor Shield&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.047" LastActivityDate="2014-03-18T21:54:48.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="390" PostTypeId="4" CreationDate="2014-02-23T19:48:51.823" Score="0" Body="Shields are attachments that &quot;snap&quot; onto the Arduino board adding functionality. They are usually the same shape as an Uno/Leonardo/Duemilanove. Some examples are: the Ethernet (includes SD port) shield, motor shields, and sensor shields." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:05:01.360" LastActivityDate="2014-02-23T21:05:01.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="391" PostTypeId="5" CreationDate="2014-02-23T19:49:59.797" Score="0" Body="&lt;p&gt;C++ is the standard language used to program the Arduino IDE. Most Arduino code online is written in this language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C++ is one of the most popular coding languages available, being highly cross-platform. However, transferring Arduino code to PC code (and vice versa) is very hard, even when ignoring the fact that your computer can't run a motor. For example, in C++ code, the first thing to be called is &lt;code&gt;main&lt;/code&gt;. In Arduino C++, &lt;code&gt;main&lt;/code&gt; is still called, however, &lt;strong&gt;the Arduino libraries are called, not your sketch.&lt;/strong&gt; Those libraries &lt;em&gt;then&lt;/em&gt; call &lt;code&gt;setup&lt;/code&gt; and then &lt;code&gt;loop&lt;/code&gt; repeatedly after finishing all the initialization tasks they must perform before the Arduino can run the code of your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is pronounced &quot;C plus plus.&quot;&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-05-03T09:18:55.797" LastActivityDate="2014-05-03T09:18:55.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="392" PostTypeId="4" CreationDate="2014-02-23T19:49:59.797" Score="0" Body="C++ is the standard language used to program the Arduino IDE. However, the Arduino IDE does have lots of libraries built in, so functions such as &quot;main&quot; are not called directly in the sketch code. Most Arduino code online is written in this language." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T22:53:53.367" LastActivityDate="2014-03-18T22:53:53.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="393" PostTypeId="5" CreationDate="2014-02-23T19:51:18.210" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-23T19:51:18.210" LastActivityDate="2014-02-23T19:51:18.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="394" PostTypeId="4" CreationDate="2014-02-23T19:51:18.210" Score="0" Body="To compile is to convert the code for a sketch into machine readable files that are uploaded to the Arduino. This tag is mostly used for the space and footprint of the files uploaded to the Arduino." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T20:37:47.310" LastActivityDate="2014-02-23T20:37:47.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="395" PostTypeId="5" CreationDate="2014-02-23T19:56:31.007" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-23T19:56:31.007" LastActivityDate="2014-02-23T19:56:31.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="396" PostTypeId="4" CreationDate="2014-02-23T19:56:31.007" Score="0" Body="A relay is a part that acts like a switch that can be controlled by an Arduino. They usually are powered by sending current through a coil, which moves a piece of metal to touch a contact within it. (Note there are also solid state relays which act more like a transistor.) The moving parts is why some devices make a &quot;clicking&quot; noise when they turn on/off a light or another device attached to it." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:02:23.780" LastActivityDate="2014-02-23T21:02:23.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="397" PostTypeId="5" CreationDate="2014-02-23T19:58:44.503" Score="0" Body="&lt;p&gt;LCD stands for &quot;Liquid Crystal Display&quot; and is commonly known as a screen. The tag should be used for questions related to LCD display as opposed to LED displays.  LCD displays have to have a backlight in order to be visible.   Their size can range from small 16x2 modules all the way up to full-size televisions.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="26717" LastEditDate="2017-06-06T09:16:57.650" LastActivityDate="2017-06-06T09:16:57.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="398" PostTypeId="4" CreationDate="2014-02-23T19:58:44.503" Score="0" Body="LCD stands for &quot;Liquid Crystal Display&quot; and is commonly known as a screen. The tag should be used for questions related to LCD display." OwnerUserId="220" LastEditorUserId="19515" LastEditDate="2016-10-10T18:02:27.200" LastActivityDate="2016-10-10T18:02:27.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="399" PostTypeId="5" CreationDate="2014-02-23T20:16:54.033" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-23T20:16:54.033" LastActivityDate="2014-02-23T20:16:54.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="400" PostTypeId="4" CreationDate="2014-02-23T20:16:54.033" Score="0" Body="The ATMega328 is the chip that is the heart of the Arduino Uno. It is popular also as a chip to use to create your own board. Since it is available in the through hole version, it can be placed on a breadboard easily for circuits." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:02:34.953" LastActivityDate="2014-02-23T21:02:34.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="401" PostTypeId="5" CreationDate="2014-02-23T20:19:34.737" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-23T20:19:34.737" LastActivityDate="2014-02-23T20:19:34.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="402" PostTypeId="4" CreationDate="2014-02-23T20:19:34.737" Score="0" Body="Emulation is the process of using software to &quot;fake&quot; how a piece of hardware will act in certain circuits with different firmware on the chips." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-23T21:01:16.977" LastActivityDate="2014-02-23T21:01:16.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="403" PostTypeId="1" AcceptedAnswerId="407" CreationDate="2014-02-23T20:42:26.537" Score="21" ViewCount="8112" Body="&lt;p&gt;I'm looking for a broadly applicable solution, one that can be adapted to a variety of projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently working on several projects that each require controlling devices ranging from 800mA to 2A from an Arduino Uno. One controls stepper motors, one controls 12vdc solenoid actuators, and one controls 12vdc pneumatic valves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino monitors a button, and each time the button is pressed it triggers the solenoid actuator. Because the Arduino is unable to source the current required by the solenoid, a seperate power supply is required with the Arduino controlling a switch (relay, transistor, etc.) that allows the higher current to pass. For the stepper motor, the layout is more complex as there would need to be four pins controlling four separate switches (to maintain interoperability of the circuit). The relay controls an air valve and requires 12vdc as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out how to use a single circuit that can be used in each of these applications (and any future projects) that involve controlling higher current devices than the Arduino pins can handle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prototyping speed, standardized components, and low cost are the driving factors. Switching speed, useful life, and noise are also important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a breakout board, circuit, or component that can be connected to an Arduino pin and used to control a high current device? Ideally with a software controlled potentiometer so that the resistance for different projects could be set in the sketch itself.&lt;/p&gt;&#xA;" OwnerUserId="225" LastEditorUserId="220" LastEditDate="2014-03-20T15:21:28.933" LastActivityDate="2019-10-29T05:32:36.310" Title="How can higher current devices (motors, solenoids, lights, etc.) be controlled by an Arduino?" Tags="|pins|voltage-level|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="405" PostTypeId="5" CreationDate="2014-02-23T21:11:35.700" Score="0" Body="&lt;p&gt;Use this tag for questions regarding how to get the time on an Arduino, how to create or use clocks with an Arduino, or anything that time would be a substantial part of the problem/question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider using &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; or other tags specific to your problem.&lt;/p&gt;&#xA;" OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T23:16:28.133" LastActivityDate="2014-02-23T23:16:28.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="406" PostTypeId="4" CreationDate="2014-02-23T21:11:35.700" Score="0" Body="Use this tag for questions regarding how to get the time on an Arduino, how to create or use clocks with an Arduino, or anything that has time as a substantial factor in it. Also consider using [programming] or other more specific tags." OwnerUserId="35" LastEditorUserId="35" LastEditDate="2014-02-23T23:16:41.197" LastActivityDate="2014-02-23T23:16:41.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="407" PostTypeId="2" ParentId="403" CreationDate="2014-02-23T21:36:40.887" Score="13" Body="&lt;p&gt;To drive such high currents, you may have to cascade several transistors (you can also use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Darlington_transistor&quot;&gt;Darlington transistor&lt;/a&gt;). There are arrays of Darlingtons mounted in a chip (e.g. the ULN2803A has 8 darlington transistors, but is limited to 500mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably will have to deal with higher power transistors; as an example I have found STMicroelectronics &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000909.pdf&quot;&gt;TIP110&lt;/a&gt; which can support switching a 2A current (4A peak), but it would probably need a heatsink to dissipate heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I wonder if your steppers really need 2A current (are they that big?). For steppers, you can generally find IC that can drive them easily, e.g. the L293D but this one can drive &quot;only&quot; 600mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a conclusion, I am afraid you will not find a &quot;one size fits all&quot; solution, as all your devices are different and should be driven by the appropriate circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since oversizing is not an issue in your prototyping case, then you could go with a &lt;strong&gt;MOSFET&lt;/strong&gt; instead of usual bipolar transistors. A MOSFET will be able to drive higher currents and voltages than standard transistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside is you can use it as a switch only (like e.g. a relay) and thus can't really &lt;strong&gt;drive&lt;/strong&gt; the exact power for your devices. I guess that does not matter for a Stepper motor, or a Solenoid, but that may be important for driving lights for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the good point is that you can still use PWM for that as the MOSFET switching speed is good enough for such purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding price, there are many diferent kinds of MOSFET out there, but I guess you can find one that fits yours needs (12V, 2A) for less than $1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I advise you to take a look at &lt;a href=&quot;http://bildr.org/2012/03/rfp30n06le-arduino/&quot;&gt;this great article&lt;/a&gt; about this topic.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-02-25T06:59:25.793" LastActivityDate="2014-02-25T06:59:25.793" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="408" PostTypeId="1" AcceptedAnswerId="411" CreationDate="2014-02-23T21:43:22.787" Score="5" ViewCount="2997" Body="&lt;p&gt;I've been using a button to interact with a sketch (on my Uno), and it's mostly working fine. However, sometimes it seems to be detecting multiple presses when it's only pressed once.&lt;/p&gt;&#xA;&lt;p&gt;It's a small circuit-mounted momentary button, which is normally open. It's connected from +5V directly to an input pin. I've also added a 10K pull-down resistor on the pin to make sure the input isn't left floating.&lt;/p&gt;&#xA;&lt;p&gt;Here's a test sketch I've been using, which reports the number of presses to the serial monitor:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    int oldState = LOW;&#xA;    int numPresses = 0;&#xA;&#xA;    void setup()&#xA;    {&#xA;        pinMode(5, INPUT);&#xA;        Serial.begin(9600);&#xA;    }&#xA;&#xA;    void loop()&#xA;    {&#xA;        const int newState = digitalRead(5);&#xA;&#xA;        if (newState != oldState) {&#xA;            if (newState == HIGH) Serial.println(++numPresses);&#xA;            oldState = newState;&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Sometimes when I press the button once, the serial monitor shows two presses in a row. It sometimes even reports a press when I &lt;em&gt;release&lt;/em&gt; the button.&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to fix this? Or do I just have a faulty button or pin or something?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="90731" LastEditDate="2023-09-06T13:36:57.757" LastActivityDate="2023-09-06T13:36:57.757" Title="Why does my sketch report too many button presses?" Tags="|pins|button|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="409" PostTypeId="2" ParentId="408" CreationDate="2014-02-23T22:05:29.407" Score="4" Body="&lt;p&gt;The button contacts themselves are probably bouncing in and out of contact, which is causing the circuit to open and close multiple times, even though the button position isn't changing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a common problem with buttons and would be the first thing I would check. In order to fix this, you need to de-bounce the button. There are various ways in which to accomplish this, some of which can be done in the sketch itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good solution is code that measures the duration of each button state and only registers a change in state if the current duration is greater than the desired duration. That option should be used for more complex projects. The code for it will be project specific and likely use sketch defined variables, but an example of what needs to be done can be found &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the sketch is very basic or you just want to make sure that bounce is the problem, you can add a short delay after the button state changes. For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    const int newState = digitalRead(5);&#xA;&#xA;    if (newState != oldState) {&#xA;        if (newState == HIGH) Serial.println(++numPresses);&#xA;        oldState = newState;&#xA;        delay(10) //Adjust the delay length to be as short as possible without triggering errors&#xA;    }&#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="225" LastActivityDate="2014-02-23T22:05:29.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="410" PostTypeId="2" ParentId="408" CreationDate="2014-02-23T22:11:03.883" Score="3" Body="&lt;p&gt;This is your button &lt;strong&gt;bouncing&lt;/strong&gt; which is quite usual behavior; it has nothing to do with button quality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 2 ways to &quot;debounce&quot; a button: by hardware or by software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I prefer by hardware; just google for &lt;code&gt;button debouncing circuit&lt;/code&gt; and you should find many examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have the necessary components available, you can use software debouncing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By software, you have an example &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; on Arduino web site.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-02-23T22:11:03.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="411" PostTypeId="2" ParentId="408" CreationDate="2014-02-23T22:35:02.897" Score="11" Body="&lt;h1&gt;Contact Bounce&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is known as contact bounce and happens when the metal contacts in the button or switch bounce against each other when you push it. The microcontroller is fast enough to pick up these bounces and, as far as it's concerned, you're toggling the switch many times in as much as 10 milliseconds of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different switches and buttons will have a different amount of contact bounce, and even one switch will behave differently between two presses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a button press captured on a scope (image from &lt;a href=&quot;http://www.maximintegrated.com/app-notes/index.mvp/id/159&quot; rel=&quot;noreferrer&quot;&gt;Maxim&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZrNMs.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 2ms/div we don't see a stable signal until 6ms after initial contact!&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Solutions&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;Add a delay&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The absolute simplest solution is to introduce a short delay after you read the button input. This will prevent the code from picking up any bounces and when it resumes, the signal should be stable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(A3) == 0) {&#xA;    // do something here&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the example above, I delay 500ms after reading the state of the pin. The button is normally high so when I press it down, the state of the pin goes to logic 0. I pick that up in the code and do something and then wait at least 500ms before continuing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, this code will just halt for half a second every time you push a button, which may or may not be acceptable in your application. You can decrease the amount of delay depending on the contact bounce time of your switch, too, but I play it safe here.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Ignore button presses too close to each other&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Similar to the solution above but instead of adding a hard delay, you use the &lt;code&gt;millis()&lt;/code&gt; function to keep track of when the last time the switch was triggered. Every time you see a switch trigger, you compare against the time and, if not enough time has elapsed (say like 500ms in my previous example), you ignore it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solves the problem of having to use &lt;code&gt;delay()&lt;/code&gt; in your code.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Switch debouncer IC&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are things like the &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/1896&quot; rel=&quot;noreferrer&quot;&gt;MAX6816&lt;/a&gt; which is an IC that you put in between your switch and microcontroller input. It will denounce the signal for you. At a price of $1.62 @1k you'll probably never use this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Other&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are many solutions to this problem... I always do it in software, but some others include using a &lt;a href=&quot;http://tech.thetonegod.com/debounce/debounce.html&quot; rel=&quot;noreferrer&quot;&gt;latch or capacitor&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://hackaday.com/2010/11/09/debounce-code-one-post-to-rule-them-all/&quot; rel=&quot;noreferrer&quot;&gt;Debounce Code – one post to rule them all&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-23T22:35:02.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="412" PostTypeId="1" AcceptedAnswerId="422" CreationDate="2014-02-24T00:55:35.033" Score="9" ViewCount="12463" Body="&lt;p&gt;I'm working on a free space optics project to send data wirelessly between two points. To accomplish this I'm using an IR LED connected to an Arduino Uno that pulses with a 56&amp;nbsp;kHz carrier frequency for the transmitter and a second Arduino with a 56&amp;nbsp;kHz IR detector module for the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using delayMicroseconds() between pin high and pin low commands in order to create the carrier frequency. This kind of works, but the frequency isn't always the same and any additional delays for pulsing the signal (i.e. the time required to call the function and decrementing) can change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the datasheet for the ATmega328 it appears that there is a way to set a more accurate pulse using the chip's timers. Is that possible, and if so, how do you create a 56&amp;nbsp;kHz pulse using the timers?&lt;/p&gt;&#xA;" OwnerUserId="225" LastEditorUserId="510" LastEditDate="2018-03-07T14:34:07.420" LastActivityDate="2018-03-07T14:40:28.623" Title="How can an Arduino output a specific (i.e. 56 kHz) carrier frequency?" Tags="|arduino-uno|ir|timers|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="414" PostTypeId="1" AcceptedAnswerId="416" CreationDate="2014-02-24T02:06:06.347" Score="11" ViewCount="4072" Body="&lt;p&gt;While looking at sketches other people have written, I occasionally come across code that looks somewhat like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1A = 0;&#xA;TCCR1B = 0;&#xA;&#xA;TCNT1 = 34286;&#xA;TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;TIMSK1 |= (1 &amp;lt;&amp;lt; TOIE1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All I know is that is has something to with timing/timers (I think). How can I decipher—and create—code like this? What are &lt;code&gt;TCCR1A&lt;/code&gt;, &lt;code&gt;TCCR1B&lt;/code&gt;, &lt;code&gt;TCNT1&lt;/code&gt;, &lt;code&gt;CS12&lt;/code&gt;, &lt;code&gt;TIMSK1&lt;/code&gt;, and &lt;code&gt;TOIE1&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="84" LastEditDate="2014-02-24T09:38:06.547" LastActivityDate="2020-01-18T16:44:34.523" Title="Could someone explain this weird looking code, used to setup timers?" Tags="|timers|programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="415" PostTypeId="2" ParentId="414" CreationDate="2014-02-24T03:07:29.873" Score="3" Body="&lt;p&gt;&lt;code&gt;TCCR1A&lt;/code&gt; is timer/counter 1 control register A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCCR1B&lt;/code&gt; is timer/counter 1 control register B&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCNT1&lt;/code&gt; is timer/counter 1's counter value&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;CS12&lt;/code&gt; is the 3rd clock select bit for timer/counter 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TIMSK1&lt;/code&gt; is timer/counter 1's interrupt mask register&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TOIE1&lt;/code&gt; is the timer/counter 1 overflow interrupt enable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the code enables timer/counter 1 at 62.5 kHz and sets the value to 34286. Then it enable the overflow interrupt so when it reaches 65535, it will trigger the interrupt function, most likely labelled as &lt;code&gt;ISR(timer0_overflow_vect)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="11" LastEditDate="2014-02-24T03:37:58.120" LastActivityDate="2014-02-24T03:37:58.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="416" PostTypeId="2" ParentId="414" CreationDate="2014-02-24T03:54:06.270" Score="15" Body="&lt;p&gt;This isn't weird looking. It's what normal MCU code actually looks like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you have here is an example of the concept of &lt;em&gt;memory-mapped peripherals&lt;/em&gt;. Basically, the MCU hardware has special locations in the SRAM address space of the MCU assigned to it. If you write to these addresses, the bits of the byte written to address &lt;em&gt;n&lt;/em&gt; control the behaviour of peripheral &lt;em&gt;m&lt;/em&gt;.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, certain banks of memory literally have little wires running from the SRAM cell to the hardware. If you write a &quot;1&quot; to this bit in that byte, it sets this SRAM cell to a logical high, which then turns on some portion of the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look into the headers for the MCU, there are great big tables of keyword&amp;lt;-&gt;address mappings. This is how things like &lt;code&gt;TCCR1B&lt;/code&gt; etc... are resolved at compile time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This memory-mapping mechanism is extremely broadly used in MCUs. The ATmega MCU in the arduino use it, as do PIC, ARM, MSP430, STM32 and STM8 MCU series, as well as lots of MCUs I'm not immediately familiar with. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Arduino&lt;/em&gt; code is the weird stuff, with functions that access the MCU control registers indirectly. While this is somewhat &quot;nicer&quot; looking, it's also much slower, and uses a lot more program space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mysterious constants are all described in great detail in the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega328P datasheet&lt;/a&gt;, which you really should read if you're interested in doing anything more then occationally toggling pins on an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Select excerpts from the datasheet linked above:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/przAI.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/P3Yu2.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/faCfk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, &lt;code&gt;TIMSK1 |= (1 &amp;lt;&amp;lt; TOIE1);&lt;/code&gt; sets the bit &lt;code&gt;TOIE1&lt;/code&gt; in &lt;code&gt;TIMSK1&lt;/code&gt;. This is achieved by shifting binary 1 (&lt;code&gt;0b00000001&lt;/code&gt;) to the left by &lt;code&gt;TOIE1&lt;/code&gt; bits, with &lt;code&gt;TOIE1&lt;/code&gt; being defined in a header file as 0. This is then bitwise ORed into the current value of &lt;code&gt;TIMSK1&lt;/code&gt;, which effectively set this one bit high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the documentation for bit 0 of &lt;code&gt;TIMSK1&lt;/code&gt;, we can see it is described as  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When this bit is written to one, and the I-flag in the Status Register&#xA;  is set (interrupts globally enabled), the Timer/Counter1 Overflow&#xA;  interrupt is enabled. The corresponding Interrupt Vector (See&#xA;  ”Interrupts” on page 57) is executed when the TOV1 Flag, located in&#xA;  TIFR1, is set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All the other lines should be interpreted in the same manner.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some notes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also see things like &lt;code&gt;TIMSK1 |= _BV(TOIE1);&lt;/code&gt;. &lt;code&gt;_BV()&lt;/code&gt; is a &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_use_bv&quot; rel=&quot;noreferrer&quot;&gt;commonly used macro&lt;/a&gt; originally from the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/index.html&quot; rel=&quot;noreferrer&quot;&gt;AVR libc implementation&lt;/a&gt;. &lt;code&gt;_BV(TOIE1)&lt;/code&gt; is functionally identical to &lt;code&gt;(1 &amp;lt;&amp;lt; TOIE1)&lt;/code&gt;, with the benefit of better readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you may also see lines such as: &lt;code&gt;TIMSK1 &amp;amp;= ~(1 &amp;lt;&amp;lt; TOIE1);&lt;/code&gt; or &lt;code&gt;TIMSK1 &amp;amp;= ~_BV(TOIE1);&lt;/code&gt;. This has the opposite function of &lt;code&gt;TIMSK1 |= _BV(TOIE1);&lt;/code&gt;, in that it &lt;em&gt;unsets&lt;/em&gt; the bit &lt;code&gt;TOIE1&lt;/code&gt; in &lt;code&gt;TIMSK1&lt;/code&gt;. This is achieved by taking the bit-mask produced by &lt;code&gt;_BV(TOIE1)&lt;/code&gt;, performing a bitwise NOT operation on it (&lt;code&gt;~&lt;/code&gt;), and then ANDing &lt;code&gt;TIMSK1&lt;/code&gt; by this NOTed value (which is 0b11111110).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in all these cases, the value of things like &lt;code&gt;(1 &amp;lt;&amp;lt; TOIE1)&lt;/code&gt; or &lt;code&gt;_BV(TOIE1)&lt;/code&gt; are fully resolved at &lt;em&gt;compile time&lt;/em&gt;, so they functionally reduce to a simple constant, and therefore take no execution time to compute at runtime.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Properly written code will &lt;em&gt;generally&lt;/em&gt; have comments inline with the code that detail what the registers being assigned to do. Here is a fairly simple soft-SPI routine I wrote recently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t transactByteADC(uint8_t outByte)&#xA;{&#xA;    // Transfers one byte to the ADC, and receives one byte at the same time&#xA;    // does nothing with the chip-select&#xA;    // MSB first, data clocked on the rising edge&#xA;&#xA;    uint8_t loopCnt;&#xA;    uint8_t retDat = 0;&#xA;&#xA;    for (loopCnt = 0; loopCnt &amp;lt; 8; loopCnt++)&#xA;    {&#xA;        if (outByte &amp;amp; 0x80)         // if current bit is high&#xA;            PORTC |= _BV(ADC_MOSI);     // set data line&#xA;        else&#xA;            PORTC &amp;amp;= ~(_BV(ADC_MOSI));  // else unset it&#xA;&#xA;        outByte &amp;lt;&amp;lt;= 1;              // and shift the output data over for the next iteration&#xA;        retDat &amp;lt;&amp;lt;= 1;               // shift over the data read back&#xA;&#xA;        PORTC |= _BV(ADC_SCK);          // Set the clock high&#xA;&#xA;        if (PINC &amp;amp; _BV(ADC_MISO))       // sample the input line&#xA;            retDat |= 0x01;         // and set the bit in the retval if the input is high&#xA;&#xA;        PORTC &amp;amp;= ~(_BV(ADC_SCK));       // set clock low&#xA;    }&#xA;    return retDat;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;PORTC&lt;/code&gt; is the register that controls the value of output pins within &lt;code&gt;PORTC&lt;/code&gt; of the ATmega328P. &lt;code&gt;PINC&lt;/code&gt; is the register where the &lt;em&gt;input&lt;/em&gt; values of &lt;code&gt;PORTC&lt;/code&gt; are available. Fundamentally, things like this are what happen internally when you use the &lt;code&gt;digitalWrite&lt;/code&gt; or &lt;code&gt;digitalRead&lt;/code&gt; functions. However, there is a look-up operation that converts the arduino &quot;pin numbers&quot; into actual hardware pin numbers, which takes somewhere in the realm of 50 clock cycles. As you can probably guess, if you're trying to go fast, wasting 50 clock cycles on an operation that should only require 1 is a bit ridiculous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above function probably takes somewhere in the realm of 100-200 clock cycles to transfer 8 bits. This entails 24 pin-writes, and 8 reads. This is many, many times faster then using the &lt;code&gt;digital{stuff}&lt;/code&gt; functions.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-02-24T05:03:54.433" LastActivityDate="2014-02-24T05:03:54.433" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="417" PostTypeId="2" ParentId="412" CreationDate="2014-02-24T12:02:04.777" Score="2" Body="&lt;p&gt;I've found &lt;a href=&quot;http://arduino.cc/en/Reference/Tone#.UwsyD2J_t8E&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;tone()&lt;/code&gt;&lt;/a&gt; useful for generating high frequency pulses on any pin. It should be able to handle 56 KHz. &lt;em&gt;(Edit: As noted by jfpoilpret, the closest you could actually get on a 16 MHz Arduino is about 55.944 KHz)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty will obviously be combining it with your data signal. I don't think you could do that in software without resorting to low level code. It should be pretty easy in hardware though, since it's digital.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you'd need to do is output your data signal on a different pin, and then combine it with the carrier using an AND gate. The combined signal can go straight to your IR transmitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have an AND gate handy then it's quite simple to make your own using a pair of transistors. Just search online for &quot;transistor and gate&quot;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-02-24T21:23:34.093" LastActivityDate="2014-02-24T21:23:34.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="418" PostTypeId="1" AcceptedAnswerId="419" CreationDate="2014-02-24T12:23:42.077" Score="9" ViewCount="3108" Body="&lt;p&gt;I currently have an Uno (which operates at 5v), and I'm looking at buying a Due (which only operates at 3.3v). I'd like to make them communicate via Serial or SPI or similar, but presumably connecting them directly isn't an option (I guess the Due's pins would get damaged).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make the connection safe? Or is there an alternative form of communication I could safely use between them instead?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="84" LastEditDate="2014-02-25T07:47:25.397" LastActivityDate="2014-02-25T07:47:25.397" Title="How can a 5v Uno talk to a 3.3v Due?" Tags="|arduino-uno|serial|pins|arduino-due|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="419" PostTypeId="2" ParentId="418" CreationDate="2014-02-24T13:36:42.870" Score="8" Body="&lt;ul&gt;&#xA;&lt;li&gt;For a 5V logic output to a 3V3 logic input, you can use a resistive divider to lower the voltage.&lt;/li&gt;&#xA;&lt;li&gt;When unloaded, a 3V3 logic output is just enough to drive a 5V logic input. Check the AVR datasheet for the exact voltages (0.6 × Vcc = 3V, found under DC Characteristics in the datasheet).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In other words, with a little bit of special care it may just work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To construct a more reliable and bidirectional solution, use a level shifter. There are several listed on &lt;a href=&quot;http://www.nxp.com/products/logic/level_shifters_translators/#products&quot;&gt;this page&lt;/a&gt; but other manufacturers make similar devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nxp.com/documents/application_note/AN10441.pdf&quot;&gt;This document&lt;/a&gt; describes how a MOSFET can be used to bidirectionally convert logic levels between different supply voltages.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-24T14:34:57.913" LastActivityDate="2014-02-24T14:34:57.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="420" PostTypeId="2" ParentId="316" CreationDate="2014-02-24T14:36:05.793" Score="5" Body="&lt;p&gt;Any state of change on any pin configured as digital input can create an interrupt. Unlike the unique vectors for the interrupts causes by INT1 or INT2 the PinChangeInt feature uses a common vector and then Interrupt Service Routine (aka ISR) for this vector needs to then determine which pin changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot;&gt;PinChangeInt Library&lt;/a&gt; makes this easy.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PCintPort::attachInterrupt(PIN, burpcount,RISING); // attach a PinChange Interrupt to our pin on the rising edge&#xA;// (RISING, FALLING and CHANGE all work with this library)&#xA;// and execute the function burpcount when that pin changes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-02-24T14:36:05.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="421" PostTypeId="1" CreationDate="2014-02-24T16:53:23.563" Score="1" ViewCount="14447" Body="&lt;p&gt;I'm currently working with the &lt;code&gt;Talon SR Speed Controller&lt;/code&gt; and it requires a specific Input PWM Signal of &lt;code&gt;1-2 ms @ 333 Hz&lt;/code&gt; and an input resolution of &lt;code&gt;10-bit (1024 steps)&lt;/code&gt;. Currently I use the &lt;code&gt;Servo&lt;/code&gt; library to handle these requirements, but was having some issues of the motors jumping their dead-band from forwards to backwards really fast causing the motors to rock back and forwards a few millimeters. If the &lt;code&gt;servo1.write(pwmValue);&lt;/code&gt; isn't my issues please let me know?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a way to specifically achieve the 333Hz PWM signal for 4 motors of the same Uno or Due (most likely will transfer to a Due in a few days) I would like to implement that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my understand I can modify the timers registers for the arduino specifically, but don't know exactly how to do that or to achieve 333Hz. If someone could please help me understand this I would greatly appreciate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Speed SR  Speed Controller Information:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Input voltage 6-28 VDC&#xA;Continuous current 60 A&#xA;Peak current 100 A&#xA;Input PWM signal 1-2 ms @ 333 Hz&#xA;Input resolution 10-bit (1024 steps)&#xA;Output resolution 10-bit (1024 steps)&#xA;Output switching frequency 15 kHz&#xA;4% neutral dead band&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="62" LastActivityDate="2017-01-05T11:09:08.320" Title="Generating PWM signal 1-2 ms @ 333 Hz" Tags="|arduino-uno|arduino-due|pwm|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="422" PostTypeId="2" ParentId="412" CreationDate="2014-02-24T20:45:44.093" Score="10" Body="&lt;p&gt;It is indeed possible to generate a 56 kHz signal with an Arduino &lt;strong&gt;timer&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A timer actually can be seen as a special register, in the MCU, that holds a value (starting at 0) that gets incremented at a frequency that is the MCU clock frequency (16&amp;nbsp;MHz on Arduino Uno), possibility divided by a factor called &lt;em&gt;prescaler&lt;/em&gt;. When that value reaches a limit, called &lt;strong&gt;Compare Match&lt;/strong&gt;, that you specify, then two things happen:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The timer register value is reset to 0.&lt;/li&gt;&#xA;&lt;li&gt;One &lt;strong&gt;ISR&lt;/strong&gt; (interrupt service routine) callback function gets called (you can define it to point to your own code).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The idea is to use that ISR to change the output of a logical pin every time it is called (&lt;code&gt;HIGH&lt;/code&gt;, then &lt;code&gt;LOW&lt;/code&gt;, then &lt;code&gt;HIGH&lt;/code&gt;...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, in order to generate a 56&amp;nbsp;kHz square wave, you'll need your ISR to be called &lt;code&gt;56000 * 2&lt;/code&gt; times per second (&lt;code&gt;* 2&lt;/code&gt; because you need to change the output value twice per period).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can choose the prescaler value you want for a timer among the following list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 (clock frequency is not divided, hence 16 MHz)&lt;/li&gt;&#xA;&lt;li&gt;8 (clock frequency is divided by 8, hence 2 MHz)&lt;/li&gt;&#xA;&lt;li&gt;64&lt;/li&gt;&#xA;&lt;li&gt;256&lt;/li&gt;&#xA;&lt;li&gt;1024&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are two sizes of timers/counters on Arduino Uno (they are called &lt;em&gt;timer/counter&lt;/em&gt; actually): 8 bits and 16 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino Uno (ATmega328P), you have three timers overall, but some may be used by the Arduino core library or other libraries used in your sketches (you'll have to check that by yourself):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;timer0 (8-bit)&lt;/li&gt;&#xA;&lt;li&gt;timer1 (16-bit)&lt;/li&gt;&#xA;&lt;li&gt;timer2 (8-bit): this one has more prescaling options (1, 8, 32, 64, 128, 256, and 1024)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now you need to generate a 56&amp;nbsp;kHz wave from 16&amp;nbsp;MHz, hence, without prescaling, you would need to count to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;16000000 / (56000 * 2) - 1 = 141.857&lt;/code&gt; (&lt;code&gt;- 1&lt;/code&gt; because a timer counts from 0 to this value and resets only &lt;strong&gt;after&lt;/strong&gt; it has been reached)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this calculation, we can draw two observations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;141.857&lt;/code&gt; is not an integer and thus you won't be able to generate a wave of exactly 56&amp;nbsp;kHz.&lt;/li&gt;&#xA;&lt;li&gt;Without prescaling, you need a 16-bit timer as 285 is not representable as an 8-bit unsigned integer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;From now you have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use a 16-bit timer (&lt;strong&gt;timer1&lt;/strong&gt;), use prescaler = 1, and select &lt;code&gt;142&lt;/code&gt; as the Compare Match; that will give you the following frequency: &lt;code&gt;16000000 / (2 * (142 + 1)) = 55944 Hz&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use an 8-bit timer (&lt;strong&gt;timer0&lt;/strong&gt;), use prescaler = 8, and select &lt;code&gt;17&lt;/code&gt; as the Compare Match; that will give less precision with the following frequency: &lt;code&gt;16000000 / (8 * 2 * (17 + 1)) = 55555 Hz&lt;/code&gt; which is still within the required range.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, regarding how to write your sketch for that, I advise you to check out &lt;a href=&quot;http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;this instructable&lt;/a&gt; which is very complete and very interesting to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the &lt;a href=&quot;http://www.atmel.ch/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328P complete datasheet&lt;/a&gt; is also important if you want to understand, in the slightest details, what you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some important notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An ISR is executed with disabled interrupts and must thus be as short as possible. In particular, there are several functions from the Arduino library that shall not be called from an ISR.&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno clock is not very accurate (it uses a ceramic resonator instead of a quartz, which would have been much more accurate), so this means the output frequency will shift further.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastEditorUserId="510" LastEditDate="2018-03-07T14:14:54.800" LastActivityDate="2018-03-07T14:14:54.800" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="423" PostTypeId="5" CreationDate="2014-02-25T01:01:42.260" Score="0" Body="&lt;p&gt;Use this tag for any question which involves infrared in an Arduino project. This can cover a broad range of topics, so please try to use other tags as well, where appropriate.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="42" LastEditDate="2014-03-02T00:50:01.370" LastActivityDate="2014-03-02T00:50:01.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="424" PostTypeId="4" CreationDate="2014-02-25T01:01:42.260" Score="0" Body="Infrared (IR) is a form of light which is not visible to the human eye. It can be used in a variety of applications, including remote controls, data transfer, reflectance sensing, and proximity/motion detection." OwnerUserId="220" LastEditorUserId="42" LastEditDate="2014-03-02T00:50:01.370" LastActivityDate="2014-03-02T00:50:01.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="425" PostTypeId="5" CreationDate="2014-02-25T01:03:54.677" Score="0" Body="&lt;p&gt;Linux is an open source operating system (OS) that is lightweight and runs on many systems. It also runs on the Arduino Yún. There are different &quot;flavors&quot; or &quot;distros&quot; (distributions and changes made by different groups) of Linux such as Ubuntu, Debian, and Fedora. All versions of Linux use the Linux &lt;em&gt;Kernel&lt;/em&gt; as the base of the OS. The kernel was released in late 1991.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Ubuntu_13.10_release.png/800px-Ubuntu_13.10_release.png&quot; &gt;&#xA;&lt;em&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/File:Ubuntu_13.10_release.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Screenshot of Ubuntu, a popular distro&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Y&amp;uacute;n runs a port of Linux called &lt;em&gt;Open WRT&lt;/em&gt; that is designed for routers and other networking appliances.&lt;/p&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.133" LastActivityDate="2014-03-18T22:09:09.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="426" PostTypeId="4" CreationDate="2014-02-25T01:03:54.677" Score="0" Body="Linux is an open source operating system (OS) that is lightweight and runs on many systems. It also runs on the Arduino Yún. There are different &quot;flavors&quot; or &quot;distros&quot; (distributions and changes made by different groups) of Linux such as Ubuntu, Debian, and Fedora." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-25T06:35:09.707" LastActivityDate="2014-02-25T06:35:09.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="429" PostTypeId="1" CreationDate="2014-02-25T02:53:22.187" Score="5" ViewCount="493" Body="&lt;p&gt;I'm building a weather station with two UNOs, using NRF24l01+ radios. Communications are fine. I'm sending a struct from one to the other. The struct has three elements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    struct weather {&#xA;      float tempData;&#xA;      float humData;&#xA;      float pressData;&#xA;    };&#xA;    weather wData = {0, 0, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then populate the struct with values from my DHT22 Temperature Sensor and my BMP085 pressure sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    float c = dht.readTemperature();&#xA;    wData.tempData = (c * 9/5) + 32;&#xA;    wData.humData = dht.readHumidity();&#xA;&#xA;    sensors_event_t event;&#xA;    bmp.getEvent(&amp;amp;event);&#xA;    wData.pressData = (0.0295 * event.pressure);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I send it via the NRF24L01+.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    radio.write(&amp;amp;wData, sizeof(wData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the receiving Uno I have this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    struct weather {&#xA;      float tempData;&#xA;      float humData;&#xA;      float pressData;&#xA;    };&#xA;&#xA;    weather wData = {0, 0, 0};&#xA;&#xA;    radio.read( &amp;amp;wData, sizeof(wData) );&#xA;    Serial.println(wData.tempData);&#xA;    Serial.println(wData.humData);&#xA;    Serial.println(wData.pressData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get results similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Temp = 75.43&#xA;    Hum = 35.76&#xA;    Press = 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first two are correct. The final one is not. I can change the order and the first two will always be correct, but the last element is always 0.00. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Hum = 35.76&#xA;   Press = 30.14&#xA;   Temp = 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I'm missing something here with my code but I can't find it. Anyone have some suggestions?&lt;/p&gt;&#xA;" OwnerUserId="131" LastEditorUserId="365" LastEditDate="2014-02-28T19:23:38.500" LastActivityDate="2014-02-28T19:55:17.760" Title="Last element of a struct disappearing on write/read" Tags="|c++|struct|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="430" PostTypeId="1" AcceptedAnswerId="433" CreationDate="2014-02-25T05:44:28.927" Score="0" ViewCount="2994" Body="&lt;p&gt;Will it still run on less than 5 volts? Will it break?&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-03-01T16:27:36.687" Title="What will happen if I give my Arduino Uno more or less than 5 volts?" Tags="|arduino-uno|power|safety|" AnswerCount="1" CommentCount="1" ClosedDate="2014-02-26T02:44:41.467" ContentLicense="CC BY-SA 3.0" />
  <row Id="432" PostTypeId="1" AcceptedAnswerId="436" CreationDate="2014-02-25T06:50:47.410" Score="35" ViewCount="164415" Body="&lt;p&gt;I'm working on building a solar powered, Arduino based weather station. The weather station consists of a temperature sensor and a photoresistor, and I plan to add an anemometer in the future. I would like to connect the weather station to my wireless network so that I can retrieve the sensor data from my computer without having to run wires (I live in a rental).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the different options for connecting the Arduino to WiFi? I've looked at ethernet shields, WiFi shields, and something called Xbee, but I don't understand what each of them are for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a wireless home router that I could use. Is it possible to connect my Arduino Uno to the router via the routers ethernet or USB port and then receive data from and send commands to the Arduino wirelessly over my home network? If so, how would this be accomplished? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have a bare Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="225" LastEditorUserId="304" LastEditDate="2014-03-20T11:47:16.523" LastActivityDate="2019-10-15T13:06:05.743" Title="How can I connect to an Arduino using WiFi?" Tags="|arduino-uno|wifi|xbee|" AnswerCount="12" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="433" PostTypeId="2" ParentId="430" CreationDate="2014-02-25T07:03:02.160" Score="6" Body="&lt;h1&gt;Will it break at &amp;lt; 5V? Not likely.&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check the datasheet for the IC's on the board and find the minimum power supply voltage the device works at.&lt;/li&gt;&#xA;&lt;li&gt;At typical ATmega328 Safe Operating Area (under &quot;Speed grades&quot; in the datasheet) specifies approximately 4.1V for 16MHz.&lt;/li&gt;&#xA;&lt;li&gt;If you require to use the USB interface, you'll have to check the datasheet for that chip too.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Will it run at &amp;lt; 5V? Maybe.&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the supply voltage gets below the minimum operational voltage, the controller may behave erratically. That means it can do anything (un)expected. This value is in the datasheet and probably somewhere around 2.7V.&lt;/li&gt;&#xA;&lt;li&gt;If the Brown Out circuit is configured (in fuses), then the controller will switch itself off when supply voltage gets too low to prevent undefined situations. Once the supply voltage returns, it restarts.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Will it break at &gt; 5V? Depends on where you apply it.&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;V(IN) should work fine for 7-20VDC as it is fed through an on board regulator. Notice though that the regulator has to dissipate the excess voltage and can get pretty hot when you draw a fair bit of current. The regulator will fail if the voltage goes over 20V or gets too hot too often;&lt;/li&gt;&#xA;&lt;li&gt;+5V should work fine up to 5V, and I personally wouldn't worry if an external supply delivers up to 5.5V unloaded. Above that 5.5V you will probably release the magic blue smoke.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-01T16:27:36.687" LastActivityDate="2014-03-01T16:27:36.687" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="434" PostTypeId="1" CreationDate="2014-02-25T13:38:13.100" Score="1" ViewCount="2244" Body="&lt;p&gt;I am new to the world of Arduinos but have a new project going with a MultiWii Flight controller. With the MultiWii comes a software for showing all data that is measured from the sensors (acceleration, velocity, roll, pitch, etc) which is nice but I would like to have/extract this data (call raw data or something) from all sensors (i.e. the data plotting everything, in numbers). Maybe it is the simplest thing to do, and I guess I have to set up some serial connection between the controller and tell it to send this data somehow but I do not know where to start so any guidance and help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="232" LastEditorUserId="65" LastEditDate="2014-02-27T15:25:14.483" LastActivityDate="2014-12-11T14:32:22.700" Title="Extracting data from Arduino MultiWii Flight Controller" Tags="|serial|sensors|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="435" PostTypeId="2" ParentId="429" CreationDate="2014-02-25T16:08:19.570" Score="2" Body="&lt;p&gt;Modified my &lt;code&gt;struct&lt;/code&gt; by changing the first two elements from &lt;code&gt;float&lt;/code&gt; to &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct weather {&#xA;  int tempData;&#xA;  int humData;&#xA;  float pressData;&#xA;}&#xA;weather wData;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Everything transmits fine now.&lt;/strong&gt; I don't really need the precision of a &lt;code&gt;float&lt;/code&gt; for temperature and humidity. However, I would still like to find the problem. Could there be some problem with the size of three &lt;code&gt;floats&lt;/code&gt; versus two &lt;code&gt;ints&lt;/code&gt; and a &lt;code&gt;float&lt;/code&gt;? &lt;code&gt;Serial.print(sizeof(wData))&lt;/code&gt; is &lt;code&gt;12&lt;/code&gt; when all elements are &lt;code&gt;floats&lt;/code&gt; and &lt;code&gt;8&lt;/code&gt; when using two &lt;code&gt;int&lt;/code&gt; and a &lt;code&gt;float&lt;/code&gt;. My understanding is the NRF24L01+ has a transmit and receive buffer of 32 bytes.&lt;/p&gt;&#xA;" OwnerUserId="131" LastActivityDate="2014-02-25T16:08:19.570" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="436" PostTypeId="2" ParentId="432" CreationDate="2014-02-25T18:05:46.643" Score="30" Body="&lt;p&gt;You have a few options for connecting your Arduino to the network/Internet.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Ethernet&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Something like the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;noreferrer&quot;&gt;Arduino Ethernet Shield&lt;/a&gt; allows you to plug in an Ethernet cable from the wall or router into your Arduino. Obviously, the main limitation is that your device is now tethered by the cable. For outdoor use, I wouldn't do this.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;WiFi&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;noreferrer&quot;&gt;Arduino WiFi Shield&lt;/a&gt; allows you to connect to your home WiFi network. This is just like the Ethernet except its now wireless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.sparkfun.com/products/13678&quot; rel=&quot;noreferrer&quot;&gt;ESP8266&lt;/a&gt; is a cheaper alternative that, with the default firmware, has the same functionality as the WiFi Shield. Be careful that you power it with 3.3V and not 5V as the rest of the Arduino. It also uses 3.3V logic levels so don't connect the Arduino's TX pin directly to the ESP's RX pin; use a voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;RF&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you have a lot of sensors or other devices that need to communicate with each other, the best option is usually an RF module. You have many options here, XBee being one of them. Check out the &lt;a href=&quot;https://www.sparkfun.com/pages/xbee_guide&quot; rel=&quot;noreferrer&quot;&gt;Sparkfun XBee Buying Guide&lt;/a&gt; to look at all the options available. And that's just XBee. There are many other wireless options available, at all sorts of prices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing with RF is that none of these will connect to the Internet. You will have all your devices communicate with each other or a base station, which will then be connected to the network by either a WiFi or Ethernet module.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Wireless Router Serial&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Depending on what kind of wireless router you use, you can have the Arduino communicate directly with it and use that as your connection to a network.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.thebmwz3.co.uk/article.php?story=20120611144749730&quot; rel=&quot;noreferrer&quot;&gt;Arduino - Cheap wifi connectivity&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hackanerd.wordpress.com/2013/07/06/how-to-make-a-simple-arduino-wireless-shield/&quot; rel=&quot;noreferrer&quot;&gt;Converting your Ethernet Shield to a wireless shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11763" LastEditDate="2016-05-22T01:51:38.860" LastActivityDate="2016-05-22T01:51:38.860" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="437" PostTypeId="2" ParentId="233" CreationDate="2014-02-25T21:24:20.040" Score="0" Body="&lt;p&gt;I have implemented &lt;a href=&quot;https://github.com/cybergibbons/DS2482_OneWire&quot; rel=&quot;nofollow&quot;&gt;a library&lt;/a&gt;, based on the Paeaetech one linked to above, but tidying up defines, fixing the listed issue, adding lookup table based CRC and support for passively powered sensors.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-02-25T21:24:20.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="438" PostTypeId="1" AcceptedAnswerId="450" CreationDate="2014-02-25T22:48:32.067" Score="10" ViewCount="18929" Body="&lt;p&gt;I am working with some code for remote temperature sensor nodes. They turn the debug interface on and off depending on if anything is conneced to the serial port or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is on Github &lt;a href=&quot;https://github.com/openenergymonitor/emonTH/blob/master/emonTH_DHT22_DS18B20/emonTH_DHT22_DS18B20.ino&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;. Line &lt;a href=&quot;https://github.com/openenergymonitor/emonTH/blob/40b8d4d42ad301b7877c1f5f18d492cc0e4317a9/emonTH_DHT22_DS18B20/emonTH_DHT22_DS18B20.ino#L111&quot; rel=&quot;noreferrer&quot;&gt;111&lt;/a&gt; is the line of interest:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial) debug = 1; else debug=0; //if serial UART to USB is connected show debug O/P.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, a simple question: On a hardware and software level, how does this work? I can't see anything in HardwareSerial or Stream that would return true/false if anything was connected or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I am not confident that it actually works. This simple test indicates it doesn't work as the LED flashes regardless of the presence of a serial adapter or connection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean debug;&#xA;&#xA;const int toggle = 6;&#xA;&#xA;void setup()&#xA;{&#xA;  if (Serial) debug = 1; else debug = 0;&#xA;&#xA;  pinMode(toggle, OUTPUT);&#xA;  digitalWrite(toggle, LOW);&#xA;&#xA;  if (debug)&#xA;  {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Setup&quot;);&#xA;    digitalWrite(toggle, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(toggle, LOW);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (debug)&#xA;  {&#xA;    Serial.println(&quot;Loop&quot;);&#xA;    digitalWrite(toggle, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(toggle, LOW);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="136" LastEditorUserId="275" LastEditDate="2014-02-26T16:15:30.337" LastActivityDate="2021-08-24T14:50:57.590" Title="How does this code line detect if a serial interface is connected?" Tags="|serial|library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="439" PostTypeId="1" AcceptedAnswerId="440" CreationDate="2014-02-25T22:51:03.030" Score="44" ViewCount="49610" Body="&lt;p&gt;If I upload any sketch that sends serial data, I immediately see the TX/RX LEDs flash once the sketch is uploaded. If I then start the serial monitor, the sketch appears to restart.&lt;/p&gt;&#xA;&lt;p&gt;A bare minimum sketch that shows this behaviour:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    void setup()&#xA;    {&#xA;        Serial.begin(9600);&#xA;        Serial.println(&amp;quot;Setup&amp;quot;);&#xA;    }&#xA;    &#xA;    void loop()&#xA;    {&#xA;      Serial.println(&amp;quot;Loop&amp;quot;);&#xA;      delay(1000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Tested with several boards and Mac and Windows versions of the IDE.&lt;/p&gt;&#xA;&lt;p&gt;Example output - it goes back to &amp;quot;Setup&amp;quot; when I open the serial monitor:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mokWb.png&quot; alt=&quot;Restart&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why is this?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="90731" LastEditDate="2023-11-30T16:01:08.890" LastActivityDate="2023-11-30T16:01:08.890" Title="Why does starting the serial monitor restart the sketch?" Tags="|serial|arduino-ide|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="440" PostTypeId="2" ParentId="439" CreationDate="2014-02-26T00:02:20.497" Score="42" Body="&lt;p&gt;The Arduino uses the &lt;a href=&quot;http://en.wikipedia.org/wiki/RS-232_RTS/CTS#RTS.2FCTS_handshaking&quot;&gt;RTS (Request To Send)&lt;/a&gt; (and I think &lt;a href=&quot;http://en.wikipedia.org/wiki/Data_Terminal_Ready&quot;&gt;DTR (Data Terminal Ready)&lt;/a&gt;) signals to auto-reset. If you get a serial terminal that allows you to change the flow control settings you can change this functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino terminal doesn't give you a lot of options and that's the default. Others will allow you to configure a lot more. Setting the flow control to none will allow you to connect/disconnect from the serial without resetting your board. it's quite useful for debugging when you want to be able to just plug in the connector and see the output without having to start the sketch over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to disable the auto reset is to put a pull up resistor on the reset pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection&quot;&gt;Disabling Auto Reset On Serial Connection&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-02-26T00:02:20.497" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="441" PostTypeId="2" ParentId="403" CreationDate="2014-02-26T01:00:08.327" Score="7" Body="&lt;p&gt;There are lots of ways to switch higher loads, and jfpoilpret has described some good options. I'll summarise a couple of relay-based solutions, which are mainly appropriate for comparatively slow switching speeds (i.e. not usually suitable for PWM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solid State Relays&lt;/strong&gt;&lt;br&gt;&#xA;Solid State Relays (SSRs) are effectively semiconductor-based switches. They come in a wide variety of configurations, depending on your requirements, but the key factor is that they have no moving parts. This means they can be very reliable in the long run if used properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally, they are usually comprised of MOSFETs and thyristors or similar. This can let them achieve fairly high switching speeds in theory. In practice though, the more power it's designed for, the harder it is to switch quickly. That means high speed + high power can get quite expensive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A critical factor to bear in mind is that you'll usually need a different type of SSR if you intended to switch AC instead of DC. It's also good to note that some will come with a built-in opto-isolator or similar to keep your power supplies separate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Electro Mechanical Relays&lt;/strong&gt;&lt;br&gt;&#xA;This is the more 'traditional' approach. An Electro Mechanical Relay (EMR) is a fairly simple component, containing a mechanical switch, controlled by a electromagnetic coil. If the switch is normally open, the coil pulls it closed when a control current is applied. In contrast, a normally-closed switch would be pulled open when a control current is applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of advantages of EMRs over things like SSRs. The most obvious is cost -- their simplicity makes them quite cheap, and the cost doesn't rise so sharply for higher-power versions. Additionally, the control and load are inherently isolated, and they don't care whether you're switching AC or DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several disadvantages though. The mechanical aspect means that EMRs are usually much slower than non-mechanical switching solutions, and can suffer from contact bounce. Additionally, they can physically wear out, and they can be affected by things like shocks, vibrations, and (potentially) other magnetic fields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When designing a circuit to use an EMR, it's essential to be aware of back-EMF (electromotive force). When a control current is applied, the coil acts as an inductor, storing charge electromagnetically. When the control current is stopped, the stored charge can surge back through the control circuit, creating a large negative voltage spike (potentially much larger than what was originally applied).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This spike can unfortunately damage/destroy any attached components or microcontroller pins. It is typically prevented/mitigated by putting a diode &lt;em&gt;in reverse&lt;/em&gt; across the relay's control contacts. In this context, it's sometimes known as a flyback diode, and it allows the EMF to dissipate safely.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-02-26T01:00:08.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="442" PostTypeId="5" CreationDate="2014-02-26T01:02:07.103" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-26T01:02:07.103" LastActivityDate="2014-02-26T01:02:07.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="443" PostTypeId="4" CreationDate="2014-02-26T01:02:07.103" Score="0" Body="Heat is referring to overheating a chip with too much voltage or current, thus producing heat. It often makes a blueish smoke when the chip exploded from pressure. Use this tag for how to cool the chips and/or how far you can push a certain chip before it will have a reduced lifespan." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-26T06:46:14.593" LastActivityDate="2014-02-26T06:46:14.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="444" PostTypeId="5" CreationDate="2014-02-26T01:04:26.900" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-26T01:04:26.900" LastActivityDate="2014-02-26T01:04:26.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="445" PostTypeId="4" CreationDate="2014-02-26T01:04:26.900" Score="0" Body="SD cards are often used with the Arduino Ethernet Shield. They stand for &quot;secure digital cards&quot; and fit into one's palm. They range from 256MB to 128GB, although most Arduinos only use 4GB. There are also SD micro cards, a smaller version of the cards." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-26T06:45:46.357" LastActivityDate="2014-02-26T06:45:46.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="446" PostTypeId="5" CreationDate="2014-02-26T01:05:36.360" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-26T01:05:36.360" LastActivityDate="2014-02-26T01:05:36.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="447" PostTypeId="4" CreationDate="2014-02-26T01:05:36.360" Score="0" Body="Threads are different processes that a device runs at once. Unless it has multiple cores, it has to switch between the threads to ensure that all the threads get ran." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-26T14:53:12.503" LastActivityDate="2014-02-26T14:53:12.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="448" PostTypeId="5" CreationDate="2014-02-26T01:06:49.990" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-26T01:06:49.990" LastActivityDate="2014-02-26T01:06:49.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="449" PostTypeId="4" CreationDate="2014-02-26T01:06:49.990" Score="0" Body="Use this tag to refer to the volume of electricity traveling through any given wire at any given time. It is measured in amps." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-02-26T06:46:00.200" LastActivityDate="2014-02-26T06:46:00.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="450" PostTypeId="2" ParentId="438" CreationDate="2014-02-26T01:19:04.780" Score="13" Body="&lt;p&gt;You're right -- it doesn't work in most cases, and will almost always return true. The one board where it's actually functional is the Leonardo. According to the &lt;a href=&quot;https://www.arduino.cc/reference/en/language/functions/communication/serial/ifserial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;official documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;On the Leonardo, &lt;strong&gt;if (Serial)&lt;/strong&gt; indicates wether or not the USB CDC serial connection is open. For all other instances, including &lt;strong&gt;if (Serial1)&lt;/strong&gt; on the Leonardo, this will always returns true.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Basic serial connections (used by most Arduinos) usually don't care if anything is actually listening. It's not uncommon for embedded devices to send debug info by serial even when nothing is receiving it. This has the advantage that the code's timing and behaviour won't change when debugging, which could cause all sorts of problems if you're trying to diagnose a problem reported in the field.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="79963" LastEditDate="2021-08-24T14:50:57.590" LastActivityDate="2021-08-24T14:50:57.590" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="451" PostTypeId="2" ParentId="193" CreationDate="2014-02-26T07:16:15.087" Score="3" Body="&lt;p&gt;I recently wanted to do exactly this. Since there is no nice way to do so, I wound up &lt;a href=&quot;https://github.com/Robot-Will/Stino/pull/123&quot; rel=&quot;nofollow noreferrer&quot;&gt;writing a patch&lt;/a&gt; for the &lt;a href=&quot;https://github.com/Robot-Will/Stino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stino&lt;/a&gt; sublime-text arduino plugin to do exactly this. It's subsequently been accepted, so it should be in any up-to-date Stino installs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This adds a new option to Stino:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9p7tO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this mode produces compilation results like the following:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a Uno:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Binary sketch size: 172 bytes (of a 32256 byte maximum, 0.53 percent).&lt;br&gt;&#xA;  Estimated memory use: 0 bytes (of a 1024 byte maximum, 0.00 percent).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a leonardo&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Binary sketch size: 240 bytes (of a 28672 byte maximum, 0.84 percent).&lt;br&gt;&#xA;  Estimated memory use: 0 bytes (of a 2560 byte maximum, 0.00 percent).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Actually &lt;em&gt;programming&lt;/em&gt; the leonardo with the above compiled output is &lt;em&gt;probably&lt;/em&gt; a bad idea, as it &lt;em&gt;might&lt;/em&gt; break the auto-reset functionality, but you &lt;em&gt;could&lt;/em&gt;, if you wanted. Hat-tip to mpflaga for noting this in his answer.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the memory reports are actually incorrect, but that's a &lt;a href=&quot;https://github.com/Robot-Will/Stino/pull/127&quot; rel=&quot;nofollow noreferrer&quot;&gt;separate issue&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code used for the above is:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main()&#xA;{&#xA;    while (1)&#xA;    {&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You ain't writing a &quot;Sketch&quot; anymore, not that you ever actually &lt;em&gt;do&lt;/em&gt; write a sketch. You write &lt;strong&gt;programs&lt;/strong&gt;. Period. I don't care what the Arduino wackos want to say, they don't get to redefine terms.&lt;/li&gt;&#xA;&lt;li&gt;All interrupt management is manual. This means no &lt;code&gt;milis()&lt;/code&gt; or similar.&lt;/li&gt;&#xA;&lt;li&gt;You &lt;em&gt;can&lt;/em&gt; still use the arduino serial libraries and so forth, if you want. You do have to &lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You define &lt;code&gt;main&lt;/code&gt;. You don't ever return from &lt;code&gt;main&lt;/code&gt;. If you want setup stuff, it goes before the &lt;code&gt;while (1)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="86" LastEditorUserId="42" LastEditDate="2014-02-28T23:47:38.417" LastActivityDate="2014-02-28T23:47:38.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="452" PostTypeId="1" CreationDate="2014-02-26T08:45:43.817" Score="1" ViewCount="3814" Body="&lt;p&gt;I've traditionally used a text editor with avr-gcc and makefiles for working with Arduino boards. I'm now trying to develop projects for the wider Arduino user-base, so I am trying to use the Arduino libraries and common IDEs for ease of use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started using Stino, but then found out that the Arduino IDE has some toolchain &quot;quirks&quot; that mean I will need to test everything in Arduino IDE expressly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since starting to use it more, I have found it frequently hangs or crashes. The triggers for this are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Creating a new sketch takes about 15s, and shows me the OS X beach&#xA;ball. &lt;/li&gt;&#xA;&lt;li&gt;Saving a sketch takes about 15s. &lt;/li&gt;&#xA;&lt;li&gt;Going to File-&gt;Examples frequently crashes the IDE - I need to force quit.&lt;/li&gt;&#xA;&lt;li&gt;Going to&#xA;File-&gt;Sketchbook always crashes the IDE. &lt;/li&gt;&#xA;&lt;li&gt;It sometimes randomly hangs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't have any other stability issues and other Java based IDEs like Pycharm work flawlessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed numerous libraries, including the entire Teensyduino suite (which is a lot of libraries!). Outside of that, no changes have been made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a common issue? Is there any logging or anyway I can try and work out what is causing this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is happening with:&#xA; - Arduino 1.05&#xA; - Arduino 1.55&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried uninstalling and reinstalling.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="37523" LastEditDate="2019-12-05T17:15:51.400" LastActivityDate="2019-12-05T17:15:51.400" Title="Why does my Arduino IDE hang/crash so often?" Tags="|arduino-ide|avr-gcc|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="453" PostTypeId="2" ParentId="40" CreationDate="2014-02-26T11:40:33.883" Score="8" Body="&lt;p&gt;There is one from Brazil called &lt;strong&gt;MariaMole&lt;/strong&gt;: &lt;a href=&quot;http://dalpix.com/mariamole&quot;&gt;http://dalpix.com/mariamole&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the author, like the original Arduino environment, the MariaMole facilitates the creation of software for the Arduino. However, while the original Arduino IDE has limitations to make life easier for beginners, MariaMole brings features that more advanced users are accustomed to find in professional IDEs, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Runs over Arduino install&lt;/li&gt;&#xA;&lt;li&gt;Workspace support multiple projects at the same time&lt;/li&gt;&#xA;&lt;li&gt;Multiple serial port consoles at the same time&lt;/li&gt;&#xA;&lt;li&gt;Files use open-formats&lt;/li&gt;&#xA;&lt;li&gt;Building process configurable&lt;/li&gt;&#xA;&lt;li&gt;Imports Arduino examples and sketches&lt;/li&gt;&#xA;&lt;li&gt;Easily import Arduino libraries&lt;/li&gt;&#xA;&lt;li&gt;Color-themes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="296" LastEditorUserId="296" LastEditDate="2014-02-26T16:22:09.850" LastActivityDate="2014-02-26T16:22:09.850" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="454" PostTypeId="2" ParentId="117" CreationDate="2014-02-26T12:14:39.230" Score="19" Body="&lt;p&gt;You can use &lt;a href=&quot;http://en.wikipedia.org/wiki/Charlieplexing&quot; rel=&quot;noreferrer&quot;&gt;Charlieplexing&lt;/a&gt;. With this technique you can directly drive &lt;code&gt;n*(n-1)&lt;/code&gt; LED's from n pins. So with 3 pins you can drive 6 LED's, 4 pins - 12 LED's, 5 pins - 20 LED's and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Exemple: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Six LED's on 3 Pins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PINS        LEDS&#xA;0 1 2   1 2 3 4 5 6&#xA;0 0 0   0 0 0 0 0 0&#xA;0 1 Z   1 0 0 0 0 0&#xA;1 0 Z   0 1 0 0 0 0&#xA;Z 0 1   0 0 1 0 0 0&#xA;Z 1 0   0 0 0 1 0 0&#xA;0 Z 1   0 0 0 0 1 0&#xA;1 Z 0   0 0 0 0 0 1&#xA;0 0 1   0 0 1 0 1 0&#xA;0 1 0   1 0 0 1 0 0&#xA;0 1 1   1 0 0 0 1 0&#xA;1 0 0   0 1 0 0 0 1&#xA;1 0 1   0 1 1 0 0 0&#xA;1 1 0   0 0 0 1 0 1&#xA;1 1 1   0 0 0 0 0 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bq6H5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see a better tutorial &lt;a href=&quot;http://www.pcbheaven.com/wikipages/Charlieplexing/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="296" LastActivityDate="2014-02-26T12:14:39.230" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="455" PostTypeId="1" AcceptedAnswerId="456" CreationDate="2014-02-26T14:20:39.883" Score="4" ViewCount="3042" Body="&lt;p&gt;Every time I open the &lt;code&gt;Tools&lt;/code&gt; menu, the IDE freezes for a few seconds. Why is that? It happens on both of my computers, and nothing I do makes a difference in how long it takes. I've tried restarting the IDE, unplugging my Uno, and many other things, but nothing helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on windows, running IDE version 1.0.2.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-02-26T14:29:32.220" LastActivityDate="2015-03-25T12:07:36.683" Title="Why does opening the Tools menu take so long?" Tags="|arduino-ide|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="456" PostTypeId="2" ParentId="455" CreationDate="2014-02-26T15:01:23.067" Score="7" Body="&lt;p&gt;It's an RXTX issue. RXTX is the native serial library used to make the IDE talk to the boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On some Windows installation, with some Bluetooth things (both dongles or integrated), when enumerating serial devices, these dongles scan the air for remote serial devices. Hence, the IDE stays stuck, waiting for RXTX serial device enumeration to end. This issue has been acknowledged a lot of times, see for example &lt;a href=&quot;https://github.com/arduino/Arduino/issues/1375&quot;&gt;#1375&lt;/a&gt;, &lt;a href=&quot;https://github.com/arduino/Arduino/issues/532&quot;&gt;#532&lt;/a&gt;, &lt;a href=&quot;https://github.com/arduino/Arduino/issues/200&quot;&gt;#200&lt;/a&gt; and &lt;a href=&quot;https://github.com/arduino/Arduino/issues/143&quot;&gt;#143&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand, this issue does not affect linux or mac because of the different way the scan occurs. On linux it's a plain filtered file listing of &lt;code&gt;/dev&lt;/code&gt;. Similarly it's on mac. On windows, it uses native API calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some fixes are available in the 1.5 series but I suggest switching to the latest &lt;a href=&quot;http://arduino.cc/en/Main/Software#toc3&quot;&gt;1.5.6 release&lt;/a&gt; as RXTX was replaced by &lt;a href=&quot;https://code.google.com/p/java-simple-serial-connector/&quot;&gt;JSSC&lt;/a&gt;, a more modern and simpler library.&lt;/p&gt;&#xA;" OwnerUserId="27" LastEditorUserId="27" LastEditDate="2014-02-26T15:47:41.693" LastActivityDate="2014-02-26T15:47:41.693" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="457" PostTypeId="2" ParentId="438" CreationDate="2014-02-26T15:08:50.183" Score="6" Body="&lt;p&gt;While it may not be possible to detect whether a device is connected to the Arduino serial connection or not, it is possible to &lt;em&gt;enable the debug messages over the serial connection&lt;/em&gt; based on the presence of a device on the serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering that you will be using the debug interface of your sketch only when connected to a computer capable of serial communication, it is possible to incorporate a simple test into the sketch based on which debug mode is enabled or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the sketch starts, you can check to see if any data is available on the Serial connection or not. If there is, then a device is present and debugging can be enabled. On the computer side, everytime you want to start the debugging mode on the Arduino, simply send a byte over the serial connection during the &lt;code&gt;setup&lt;/code&gt; phase and sit back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a sample sketch showing the same:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int debug = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.begin(9600);&#xA;&#xA;  //Wait for four seconds or till data is available on serial, &#xA;  //whichever occurs first.&#xA;  while(Serial.available()==0 &amp;amp;&amp;amp; millis()&amp;lt;4000);&#xA;&#xA;  //On timeout or availability of data, we come here.&#xA;  if(Serial.available()&amp;gt;0)&#xA;  {&#xA;    //If data is available, we enter here.&#xA;    int test = Serial.read(); //We then clear the input buffer&#xA;&#xA;    Serial.println(&quot;DEBUG&quot;); //Give feedback indicating mode&#xA;&#xA;    debug = 1; //Enable debug&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(debug==1) Serial.println(&quot;ON&quot;);&#xA;  digitalWrite(13,HIGH);&#xA;  delay(1000);&#xA;  if(debug==0) Serial.println(&quot;OFF&quot;);&#xA;  //Turn off if serial is not available&#xA;  digitalWrite(13,LOW);&#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2017-06-30T03:26:35.553" LastActivityDate="2017-06-30T03:26:35.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="458" PostTypeId="2" ParentId="455" CreationDate="2014-02-26T15:38:12.647" Score="7" Body="&lt;p&gt;Frederico Fissore already pointed out that this delay is due to the serial libraries. From a functional perspective: The Arduino IDE tries to enumerate all available COM ports which simply takes some time.&lt;/p&gt;&#xA;&lt;p&gt;Quote from the official &lt;a href=&quot;http://arduino.cc/de/Guide/Troubleshooting#toc14&quot; rel=&quot;noreferrer&quot;&gt;troubleshooting guide&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Why does do the Arduino software and the Tools menu take a long time to open (on Windows)?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If the Arduino software takes a long time to start up and appears to freeze when you try to open the Tools menu, there by a conflict with another device on your system. The Arduino software, on startup and when you open the Tools menu, tries to get a list of all the COM ports on your computer. It's possible that a COM port created by one of the devices on your computer slows down this process. Take a look in the Device Manager. Try disabling the devices that provide COM ports (e.g. Bluetooth devices).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="275" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-26T15:38:12.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="459" PostTypeId="2" ParentId="432" CreationDate="2014-02-26T18:24:45.643" Score="3" Body="&lt;p&gt;I've been working with xbee on the arduino and raspberry pi for a few months now. Whilst it does have it's issues and quirks, it is a great tool in the communication chain. It's not perfect but given the mesh side of it, for me it reaches further than my wifi and can even be more reliable (my raspberry pi with wifi occasionally drops out, however the connected xbee continues to function in the background. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically in my case it allows for a serial connection between my devices (being several arduinos, a raspberry pi (coordinator) and my mac (used primarily for monitoring but also occasionally injecting serial data)). In this case it's perfect. It doesn't allow internet access or access beyond the xbee framework, but that suits me perfectly since implementation is as simple as Serial.print and Serial.read with no Ethernet overhead. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-02-26T18:24:45.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="460" PostTypeId="1" CreationDate="2014-02-26T18:32:42.870" Score="15" ViewCount="70146" Body="&lt;p&gt;I'm just a tinkerer learning Arduino with my son and I was surprised that when I plugged the USB cord back in to the Arduino the program was still running and I thought to myself, &quot;it's a good thing I didn't just blow anything up.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what's the normal way people call it a day with these things?  Do you usually load up the bare-bones do nothing sketch or just unplug everything?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="65" LastEditDate="2014-03-16T15:19:10.200" LastActivityDate="2017-07-29T09:05:46.357" Title="How do I erase the memory of the Arduino Uno?" Tags="|arduino-uno|safety|flash|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="461" PostTypeId="2" ParentId="460" CreationDate="2014-02-26T18:37:12.460" Score="15" Body="&lt;p&gt;When booted, the Arduino will run whatever program was put on it last. Solution: Don't turn it on if you don't want it to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When out of the box, the Arduino usually runs the Blink program. So you can just load that and call it a day if you want to &quot;reset&quot; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or have a loop program with a sleep command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've been messing with the USB bootloader via the icsp pins, this isn't enough though, you'll need to reinstall the bootloader. But if you've been uploading programs via usb or directly using a programmer, there is no issue with uploading Blink or some other dummy program to reset it. &lt;/p&gt;&#xA;" OwnerUserId="28" LastActivityDate="2014-02-26T18:37:12.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="463" PostTypeId="2" ParentId="434" CreationDate="2014-02-26T19:30:38.163" Score="2" Body="&lt;p&gt;Since you're new to Arduino, I'd suggest beginning with a basic interfacing arduino activity. Once you understand reading and writing digital and analog signals it's pretty much plain sailing from there. You may want to invest some time and a bit of cash in a beginners course on Udemy (try PEter Dalmaris' course &lt;a href=&quot;https://www.udemy.com/arduino-sbs/&quot; rel=&quot;nofollow&quot;&gt;https://www.udemy.com/arduino-sbs/&lt;/a&gt;) it's a good start. From there, talking to the MultiWii should be a piece of cake. Also, check out &lt;a href=&quot;http://www.multiwii.com/connecting-elements&quot; rel=&quot;nofollow&quot;&gt;http://www.multiwii.com/connecting-elements&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="310" LastActivityDate="2014-02-26T19:30:38.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="464" PostTypeId="1" CreationDate="2014-02-26T20:50:09.260" Score="6" ViewCount="1166" Body="&lt;p&gt;I only get to work on my arduino every few weeks, so sometimes and get interrupted a lot by small children, so if I completely forget what is on the firmware, then I unplug the pins (because I haven't got anything soldered on there) should I be 100% certain I'm not going to fry my board?&lt;/p&gt;&#xA;" OwnerUserId="307" LastEditorUserId="307" LastEditDate="2014-02-26T21:09:18.667" LastActivityDate="2014-07-25T12:40:26.127" Title="Can you fry an arduino with nothing plugged in to it?" Tags="|safety|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="465" PostTypeId="2" ParentId="464" CreationDate="2014-02-26T20:54:24.323" Score="5" Body="&lt;p&gt;Arduinos are far from bulletproof but with nothing connected (apart from a power source of course) I doubt it will come to harm. If in doubt, upload Blink to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are rugged Arduino-compatibles. One of them has a rather &lt;a href=&quot;http://ruggedcircuits.com/html/ruggeduino.html&quot; rel=&quot;nofollow&quot;&gt;obvious name&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="316" LastEditorUserId="316" LastEditDate="2014-02-26T23:08:36.880" LastActivityDate="2014-02-26T23:08:36.880" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="468" PostTypeId="2" ParentId="40" CreationDate="2014-02-26T21:24:59.653" Score="13" Body="&lt;p&gt;UPDATE-&gt;  &lt;a href=&quot;https://codebender.cc/next-chapter&quot; rel=&quot;nofollow&quot;&gt;Codebender is being shut down.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a brilliant open source, web based IDE called &lt;a href=&quot;http://codebender.cc&quot; rel=&quot;nofollow&quot;&gt;Codebender&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is like Github for Arduino and has a great community working from it with thousands of examples and the dev team are exceptional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With codebender, you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;program an existing sketch to your device &lt;/li&gt;&#xA;&lt;li&gt;clone an existing sketch&lt;/li&gt;&#xA;&lt;li&gt;modfy it to your needs &lt;/li&gt;&#xA;&lt;li&gt;share your work with the world &lt;/li&gt;&#xA;&lt;li&gt;embed code in your website, blog, or tutorials&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Cross-platform&#xA;Works on Windows, Mac &amp;amp; Linux, Firefox &amp;amp; Chrome&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Codebender supports Windows (from Windows XP up to Windows 8.1, yes, even Vista :P), Mac OS X 10.6-10.9, and Linux and works within all major browsers&lt;/p&gt;&#xA;" OwnerUserId="310" LastEditorUserId="20022" LastEditDate="2016-10-28T19:35:28.000" LastActivityDate="2016-10-28T19:35:28.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="469" PostTypeId="2" ParentId="464" CreationDate="2014-02-26T21:33:30.393" Score="3" Body="&lt;p&gt;It's generally a good idea not to try to take input from a pin configured as &lt;code&gt;pinMode(OUTPUT)&lt;/code&gt; and vice versa. In addition, I prefer not to take input from tristated pins. Both of these cases are harmless, but it's good practice not to do so, especially since they &lt;em&gt;can&lt;/em&gt; cause issues when coupled with some hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, Arduinos are protected from software issues. You can't burnout an Arduino with just faulty software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are, however, &lt;a href=&quot;https://electronics.stackexchange.com/a/67151/8144&quot;&gt;many ways to fry an Arduino via hardware.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="28" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-02-26T22:02:41.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="470" PostTypeId="1" CreationDate="2014-02-26T21:37:38.717" Score="5" ViewCount="3705" Body="&lt;p&gt;I am working on a design project for school (non-capstone non-electrical engineering project) where we are building a system to remotely control a winch on a boat that will lower an &lt;a href=&quot;http://www.hydroscientificwest.com/cms/upload_pic/resize_1348258228.jpg&quot; rel=&quot;nofollow&quot;&gt;independently operating meter&lt;/a&gt; to specified depths using a pressure transducer (controlled from the shore).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current idea is to have an arduino collecting data from the pressure transducer while being connected to the winch (adjusting it up/down as needed, based on the desired inputted depth). The arduino would then be connected to the a Raspberry Pi B via USB. The Raspberry Pi would then communicate via wifi USB adapter to a router @ 2.5 GHz 802.11n on the shore, which would then communicate with the laptop on the shore. The important thing is that the laptop on the shore will be recording data as well as changing the input depth for the arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino &amp;lt;==&gt; Raspberry Pi &amp;lt;==&gt; Router &amp;lt;==&gt; Laptop on shore&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw [this information][2] talking about connecting to an arduino via wifi, but I was unable to determine the potential range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;http://abersailbot.co.uk/about-the-boat/&quot; rel=&quot;nofollow&quot;&gt;related project&lt;/a&gt; using a boat that uses the Xbee shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once concern is that we will not be able to specifically point any antenna on the boat back to shore, so we are looking for a non-direction-oriented solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering what potential ways I could communicate back to the shore to control the winch depth (output display on shore showing depth, then being able to change the depth from shore). Furthermore, I was wondering if my setup would be feasible and what your suggestions might be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="317" LastEditorUserId="84" LastEditDate="2014-02-27T01:09:18.677" LastActivityDate="2014-02-27T09:19:28.577" Title="How can I transmit data to/from arduino from up to ~750 ft away?" Tags="|wifi|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="471" PostTypeId="2" ParentId="464" CreationDate="2014-02-26T21:50:32.867" Score="2" Body="&lt;p&gt;&lt;strong&gt;100% certain? No. 99.9999[Repeating]%? Yes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a couple problems you could run into:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using pins &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; when connected to USB (wouldn't damage it, the USB chip if on a board with a separate USB chip would probably ignore the &quot;corrupted&quot; data.)&lt;/li&gt;&#xA;&lt;li&gt;You never mentioned your board. If it's a Uno and you modified your USB firmware, there might be some issues reflashing your board if you forget that you flashed it with a keyboard firmware. &lt;strong&gt;It won't damage it, but you may think it's bricked if you forget to reflash it.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you only disconnect a couple pins and leave others in, it may give wierd results and fry the Arduino or whatever is partially attached&lt;/li&gt;&#xA;&lt;li&gt;If you make any physical modifications to the board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The second to last one is the one you really have to worry about. I have seen previous discussions about destroying a board with a sketch, but nothing has been suggested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, there a chance you can damage it with setting the fuses on the chip(s) on the board.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-07-25T12:40:26.127" LastActivityDate="2014-07-25T12:40:26.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="472" PostTypeId="2" ParentId="464" CreationDate="2014-02-26T21:57:15.830" Score="7" Body="&lt;p&gt;Although the controllers on an Arduino are pretty well protected, they can still be damaged by ESD (Electro Static Discharge). The same effect that makes a crispy sound when you pull off your woolen sweater in the winter, or after walking with rubber shoes on a carpet and you touch someone else or a metal and grounded object and you feel a pick. Static electricity can damage the controller. It may get completely broken, or it may function 'most of the time' or lifetime may be shortened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino is also easily killed with an piezo gas lighter, just make the spark near the copper traces that feed directly in the controller. This is largely the same effect as above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, the controllers themselves are pretty well protected, don't worry too much about them. But with kids running around (on their rubber shoes) better make sure they don't accidentally draw a spark from their little finger to your Arduino. The protective metallic bag is best, but putting it away in a cupboard or box should do the trick equally well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general rule of thumb, the faster the electronics, the more sensitive it is for ESD. A Due is probably more sensitive than a UNO or a MEGA. But with normal, avoiding static electricity, use you should be OK.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-02-26T22:02:59.813" LastActivityDate="2014-02-26T22:02:59.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="473" PostTypeId="1" AcceptedAnswerId="474" CreationDate="2014-02-26T22:09:57.103" Score="22" ViewCount="77786" Body="&lt;p&gt;I was instructed to &quot;burn the bootloader&quot; to my Arduino to fix an error I was getting. How can I do this? (And what exactly is the bootloader?)&lt;/p&gt;&#xA;" OwnerUserId="37" LastActivityDate="2023-12-22T12:28:19.157" Title="How do I burn the bootloader?" Tags="|bootloader|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="474" PostTypeId="2" ParentId="473" CreationDate="2014-02-26T22:09:57.103" Score="23" Body="&lt;p&gt;The bootloader is a small program that is (almost) always on an Arduino. It manages uploading and starting the sketches you make, and blinks the pin 13 LED whenever the board resets.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To burn the bootloader:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Obtain an AVR ISP, &lt;a href=&quot;http://learn.adafruit.com/usbtinyisp&quot; rel=&quot;noreferrer&quot;&gt;USBtinyISP&lt;/a&gt;, &lt;a href=&quot;http://arduino.cc/en/Hacking/ParallelProgrammer&quot; rel=&quot;noreferrer&quot;&gt;ParallelProgrammer&lt;/a&gt;, or similar; or use &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;noreferrer&quot;&gt;another Arduino board&lt;/a&gt;. This will be your ISP.&lt;/li&gt;&#xA;&lt;li&gt;Unless otherwise instructed, connect the ISP to the ICSP pins on your board.&lt;/li&gt;&#xA;&lt;li&gt;Power your board with either a USB cable or an external power supply.&lt;/li&gt;&#xA;&lt;li&gt;Open up the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you selected the correct board that you are burning to at &lt;code&gt;Tools ► Board ►&lt;/code&gt; in the IDE. Double-check this even if you could upload programs correctly; uploading doesn't always require the right board.&lt;/li&gt;&#xA;&lt;li&gt;Select the appropriate programmer at &lt;code&gt;Tools ► Programmer ►&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Click &lt;code&gt;Tools ► Burn Bootloader&lt;/code&gt;, and wait. It shouldn't take more than a minute, and often takes only a few seconds.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Sources:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/Hacking/Bootloader&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/Environment&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/Guide/Environment&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2020-12-20T10:37:16.433" LastActivityDate="2020-12-20T10:37:16.433" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="477" PostTypeId="2" ParentId="432" CreationDate="2014-02-26T23:21:30.520" Score="2" Body="&lt;p&gt;I use &lt;a href=&quot;https://www.spark.io&quot; rel=&quot;nofollow&quot;&gt;Spark Core&lt;/a&gt; which is a very easy to use Arduino programming platform. This platform was built on the primus that WiFi should be easy to use and cheap. Can even program the Spark Core from anywhere, any time.&lt;/p&gt;&#xA;" OwnerUserId="320" LastActivityDate="2014-02-26T23:21:30.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="479" PostTypeId="2" ParentId="176" CreationDate="2014-02-27T04:19:35.337" Score="2" Body="&lt;p&gt;I usually (painfully) stick with multiple lines of &lt;code&gt;Serial.print&lt;/code&gt; but when it becomes convoluted I go back to &lt;code&gt;sprintf&lt;/code&gt;. It's annoying in that you have to have an available buffer for it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage is as simple (??) as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[35]; // you have to be aware of how long your data can be&#xA;                 // not forgetting unprintable and null term chars&#xA;sprintf(buffer,&quot;var1:%i\tvar2:%i\tvar3:%i&quot;,var1,var2,var3);&#xA;Serial.println(buffer);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A word of warning though, it doesn't (by default) support floating types. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-02-27T04:19:35.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="480" PostTypeId="2" ParentId="176" CreationDate="2014-02-27T04:22:01.400" Score="16" Body="&lt;p&gt;I wouldn't normally put two answers to a question, but I only just found &lt;a href=&quot;https://web.archive.org/web/20190419093813/http://forum.arduino.cc/index.php/topic,120440.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; today, where you can use printf without any buffer.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Function that printf and related will use to print&#xA;int serial_putchar(char c, FILE* f) {&#xA;    if (c == '\n') serial_putchar('\r', f);&#xA;    return Serial.write(c) == 1? 0 : 1;&#xA;}&#xA;&#xA;FILE serial_stdout;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;&#xA;    // Set up stdout&#xA;    fdev_setup_stream(&amp;amp;serial_stdout, serial_putchar, NULL, _FDEV_SETUP_WRITE);&#xA;    stdout = &amp;amp;serial_stdout;&#xA;    &#xA;    printf(&amp;quot;My favorite number is %6d!\n&amp;quot;, 12);&#xA;}&#xA;&#xA;void loop() {&#xA;  static long counter = 0;&#xA;  if (millis()%300==0){&#xA;    printf(&amp;quot;millis(): %ld\tcounter: %ld (%02X)\n&amp;quot;, millis(), counter, counter++);&#xA;    delay(1);    &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This still has the floating point limitation.&lt;/p&gt;&#xA;&lt;p&gt;I thought I would do a little testing on this, and it works quite well. I added a better test to the loop with formatted output.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="6936" LastEditDate="2024-03-12T00:25:38.797" LastActivityDate="2024-03-12T00:25:38.797" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="481" PostTypeId="2" ParentId="470" CreationDate="2014-02-27T08:50:03.343" Score="8" Body="&lt;p&gt;There are a number of considerations that need to be made when considering any wireless communication solution over long distances and over water.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFi is capable of working over long distances especially with higher power cards (&lt;a href=&quot;https://www.google.co.uk/search?client=safari&amp;amp;rls=en&amp;amp;q=Alfa%20AWUS036H%201000mW&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;gws_rd=cr&amp;amp;ei=lf0OU_ubJsGM0AW_1oGACw&quot;&gt;1W ones are now readily available&lt;/a&gt;) and directional antenna (anything from &lt;a href=&quot;http://uk.tp-link.com/products/details/?categoryid=2473&amp;amp;model=TL-ANT2403N&quot;&gt;3dBi&lt;/a&gt; to &lt;a href=&quot;http://uk.tp-link.com/products/details/?categoryid=2474&amp;amp;model=TL-ANT5830B&quot;&gt;30dBi&lt;/a&gt; of gain). There are advantages and disadvantages to using WiFi like this for your purposes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;WiFi uses 2.4GHz which is attenuated by the presence of water and water vapour. If you are close to the surface of the water surface, this can cause variable range with weather conditions increasing humidity and spray - even slight choppiness can massively increase the humidity close to the surface.&lt;/li&gt;&#xA;&lt;li&gt;WiFi is a fairly heavyweight protocol that has several layers that need setting up each time a connection is made. This takes time and means marginal connections will have zero throughput as they will never get setup.&lt;/li&gt;&#xA;&lt;li&gt;WiFi is intended to have high throughput (&gt;1MBps) and doesn't degrade gracefully below this point. There isn't often a need to shift data this fast on an Arduino project. Speed and range are a trade-off.&lt;/li&gt;&#xA;&lt;li&gt;Directional antenna on boats can be hard work. The more gain an antenna has, the more directional it is, which in turn means you need to aim it better. Even mild rocking can make this difficult to impossible. It depends if you are on a smooth pond or the sea really.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you do want to go with WiFi, Ubiquiti make some neat products like the &lt;a href=&quot;http://www.ubnt.com/nanostation&quot;&gt;Nanostation&lt;/a&gt; that allow long range connections to be set-up over long ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would stay away from 2.4GHz near water, and go with one of the other ISM bands. Depending on your location, this could mean 315MHz 433MHz, 868MHz, or 915MHz. It depends which region of the world you are in which ones you are allowed to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These lower frequencies are suited to longer ranges and penetrating object and water. There are a lot of different solutions in this space, all of which have ups and downs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.sparkfun.com/products/9582&quot;&gt;Hope RFM12B&lt;/a&gt; is a very popular small RF board that has several easy to use libraries available - I use &lt;a href=&quot;https://github.com/jcw/jeelib&quot;&gt;Jeelib&lt;/a&gt; personally. These are just capable of the 750ft range you require. They are available in all most ISM bands, and personally I have found the 868MHz best outdoors, whilst the 434MHz is better indoors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The newer &lt;a href=&quot;http://www.hoperf.com/rf/fsk_module/RFM69W.htm&quot;&gt;Hope RFM69W&lt;/a&gt; is a similar board but with more functionality and more power. It has 13dBm (20mW) of power vs 0dBm (1mW) of power on the RFM12B. I have been seeing an increase in range of ~50-100% with these boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.hoperf.com/rf/fsk_module/RFM69HW.htm&quot;&gt;RFM69HW&lt;/a&gt; is a high power version has 20dBm (100mW) of power. I haven't range tested this, but would expect up to 3-4 times the range of an RFM12B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ciseco, a UK company, also make a series of boards that use CC1110 chips as transceivers. These are in an XBee like form. One of their boards, &lt;a href=&quot;http://shop.ciseco.co.uk/arf-high-power-radio-transceiver/&quot;&gt;the ARF&lt;/a&gt;, has a power amplifier. These have 26dBm output power (400mW) and in a brief test in a built up area, I have seen a range of about 2km.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's important to note that these are transceivers so that they can send and receive, which means you can acknowledge if packets have been received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are boards like the &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf2401&quot;&gt;nRF2401L&lt;/a&gt; which use 2.4GHz, but use a much lighter weight protocol than WiFi so work better on marginal ranges. They are dirt cheap (~£2). They have the same disadvantage of water impacting range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't like Xbee at all. The boards are overpriced and I find the range isn't great even with the higher powered modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also &quot;roll your own&quot; and use simple 434/868/915MHz on-off-keyed (OOK) &lt;a href=&quot;http://www.coolcomponents.co.uk/rf-link-transmitter-434mhz-781.html&quot;&gt;transmitter&lt;/a&gt;/&lt;a href=&quot;http://www.coolcomponents.co.uk/rf-link-receiver-4800bps-434mhz.html&quot;&gt;receivers&lt;/a&gt;. Protocol design isn't easy though, and you lose a lot of hidden functionality that the more advanced boards have.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-27T09:19:28.577" LastActivityDate="2014-02-27T09:19:28.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="482" PostTypeId="1" AcceptedAnswerId="497" CreationDate="2014-02-27T11:46:28.300" Score="5" ViewCount="6413" Body="&lt;p&gt;Though an emulator is quite useful for debugging code that has no side effects, most real-world applications include some circuitry besides the Arduino. If a microcontroller on an Arduino had a JTAG interface, it would be pretty straight-forward, but what if it's e.g. an Arduino Uno?&lt;/p&gt;&#xA;" OwnerUserId="206" LastEditorUserId="206" LastEditDate="2014-02-27T15:15:23.190" LastActivityDate="2018-08-22T12:07:40.903" Title="How do I debug on-chip with Arduino?" Tags="|ide|emulation|debugging|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="483" PostTypeId="2" ParentId="421" CreationDate="2014-02-27T12:55:32.013" Score="4" Body="&lt;p&gt;I am playing on a Arduino UNO, you would have to compare the datasheets to determine differences.&lt;/p&gt;&#xA;&lt;p&gt;For my research on this answer I am looking at:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/PwmFrequency#.Uw7UNfSSxfg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Code/PwmFrequency (for a quick rundown)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM#.Uw7P6fSSxfh&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tutorial/PWM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/TimerPWMCheatsheet#.Uw8UafSSxfg&quot; rel=&quot;nofollow noreferrer&quot;&gt;TimerPWMCheatsheet (explains the prescaller and resulting frequencies)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,16612.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;varying the pwm frequency of timer0 and timer2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,46949.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;feature request: adjustable pwm frequencies&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=117425.30&quot; rel=&quot;nofollow noreferrer&quot;&gt;pwm frequency library (this is the one you REALLY want)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and the datasheet for the &lt;a href=&quot;http://www.atmel.com/ru/ru/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATMega328&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Also:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;we know PWM pins are D3, D5, D6, D9, D10, D11&lt;/li&gt;&#xA;&lt;li&gt;I am using D11 for this since I can attach my oscilloscope to the MOSI pin of the ISCP&lt;/li&gt;&#xA;&lt;li&gt;D11 maps to PB3 (MOSI/OC2A/PCINT3) (see datasheet or &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168#.Uw7gxfSSxfg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this cool gfx&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Normal usage&lt;/h2&gt;&#xA;&lt;p&gt;First, let's see what happens when we set an arbitrary PWM on pin 11&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int DUTY = 25;&#xA;analogWrite(11, DUTY * 256 / 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;results in:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Freq: ~487Hz&lt;/li&gt;&#xA;&lt;li&gt;Duty: ~25%&lt;/li&gt;&#xA;&lt;li&gt;Time: ~2.05ms&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This first point I will make is that with the given 490Hz the PWM duration is actually 2ms which seems to be close to what you want (you said between 1-2ms), maybe my misunderstanding there.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Playing with pre-scalers&lt;/h2&gt;&#xA;&lt;p&gt;From several of the links posted above, you will see that you have different pre-scalers available depending on which timer you are using: eg.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pins 5 and 6: controlled by Timer 0 in fast PWM mode (cycle length = 256)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Setting     Divisor     Frequency&#xA;0x01        1           62500&#xA;0x02        8           7812.5&#xA;0x03        64          976.5625&#xA;0x04        256         244.140625&#xA;0x05        1024        61.03515625&#xA;&#xA;TCCR0B = TCCR0B &amp;amp; 0b11111000 | &amp;lt;setting&amp;gt;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pins 9 and 10: controlled by timer 1 in phase-correct PWM mode (cycle length = 510)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Setting     Divisor     Frequency&#xA;0x01        1           31372.55&#xA;0x02        8           3921.16&#xA;0x03        64          490.20&#xA;0x04        256         122.55&#xA;0x05        1024        30.64&#xA;&#xA;TCCR1B = TCCR1B &amp;amp; 0b11111000 | &amp;lt;setting&amp;gt;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Pins 11 and 3: controlled by timer 2 in phase-correct PWM mode (cycle length = 510)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Setting     Divisor     Frequency&#xA;0x01        1           31372.55&#xA;0x02        8           3921.16&#xA;0x03        32          980.39&#xA;0x04        64          490.20&#xA;0x05        128         245.10&#xA;0x06        256         122.55&#xA;0x07        1024        30.64&#xA;&#xA;TCCR2B = TCCR2B &amp;amp; 0b11111000 | &amp;lt;setting&amp;gt;;&#xA; &#xA;(All frequencies are in Hz and assume a 16000000 Hz system clock.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;These are relatively simple to setup and use (the setting is at the bottom of each of the above code blocks), but you have to be mindful of playing with the pre-scaler of timer0 (which controls &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;). So if you have a choice, steer clear of timer0, or pwm pins 5 and 6.&lt;/p&gt;&#xA;&lt;p&gt;Example of using just the inbuilt pre-scalers without any additional libraries:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define PIN 11&#xA;void setup(){&#xA;    pinMode(PIN,OUTPUT);  // not absolutely required&#xA;    int DUTY = 20;&#xA;    TCCR2B = TCCR2B &amp;amp; 0b11111000 | 6;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  static long counter = 0;&#xA;  if(millis()%10==0){&#xA;      counter++;&#xA;      analogWrite(PIN, counter%255);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I know you can manipulate the frequency better than that, and I have been playing with this for hours and then I finally stumbled upon the final link (which believe it or not, I found via YouTube!).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Using an External Library&lt;/h2&gt;&#xA;&lt;p&gt;To use the PWM library you will need to download it from &lt;a href=&quot;http://code.google.com/p/arduino-pwm-frequency-library/downloads/list&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Code&lt;/a&gt;, save/import/get it into your library folder, and restart the IDE. Once you do that, you can explicitly set the frequency (within limits, 333Hz is within those limits), and you should be set.&lt;/p&gt;&#xA;&lt;p&gt;Code example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PWM.h&amp;gt;&#xA;int32_t frequency = 333;&#xA;&#xA;#define PIN 10&#xA;&#xA;void setup(){&#xA;    pinMode(PIN,OUTPUT);&#xA;    int DUTY = 20;&#xA;    InitTimersSafe();                    // won't touch timer0&#xA;    SetPinFrequencySafe(PIN,frequency);  // again, not timer0&#xA;    pwmWrite(PIN, DUTY * 256 / 100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is even a &lt;code&gt;pwmWriteHR&lt;/code&gt; which allows for higher resolution, but that does not work with timer2 (which is only an 8-bit timer).&lt;/p&gt;&#xA;&lt;p&gt;The matching, non-safe (ie initialises and uses timer0 as well) functions are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;InitTimer();  // and&#xA;SetPinFrequency(PIN,frequency);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The only limitation I have found so far is that it doesn't work with PWM pin D11. I have tested D3, D9 and D10 (they all worked fine), but I did not get around to testing D5 or D6.&lt;/p&gt;&#xA;&lt;p&gt;Good luck, I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-02-27T15:26:49.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="484" PostTypeId="1" AcceptedAnswerId="541" CreationDate="2014-02-27T14:37:49.173" Score="30" ViewCount="66671" Body="&lt;p&gt;Is it possible to build a HID device (like a keyboard) using an Arduino uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the time being, I have button inputs on the Arduino giving outputs on the serial line. So, how can I transform my current firmware into something that can behave like a HID keyboard?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shall I write a new window device driver?&lt;/li&gt;&#xA;&lt;li&gt;Shall I create a software layer that could take my serial data and have windows read it as HID input?&lt;/li&gt;&#xA;&lt;li&gt;Is there any better way to achieve this, if it is possible at all?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="335" LastEditorUserId="379" LastEditDate="2014-03-01T14:54:43.380" LastActivityDate="2021-06-20T13:39:27.700" Title="Arduino as USB HID" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="485" PostTypeId="1" AcceptedAnswerId="486" CreationDate="2014-02-27T16:51:23.440" Score="5" ViewCount="4196" Body="&lt;p&gt;I'm creating a weather station / environmental datalogger and am saving my data to a SD card Breakout. The SD card works fine but I would like to name the files I am saving on it after the date when the readings were taken.I've tryed multiple things but I can't work out how to combine the date from my RTC and put them in a file name. I've tryed this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dataFile = SD.open(String(now.day()) + &quot;-&quot; + String(now.month()) + &quot;-&quot; + String(now.year()) + &quot;.csv&quot;,FILE_WRITE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gives me an error -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char dateName[13] = {String(now.day()) + &quot;-&quot; + String(now.month()) + &quot;-&quot; + String(now.year()) + &quot;.csv&quot;};&#xA;dataFile = SD.open(dateName,FILE_WRITE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this gives me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; cannot convert 'StringSumHelper' to 'char' in initialization&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Help! How do I do this? &lt;/p&gt;&#xA;" OwnerUserId="336" LastEditorUserId="11" LastEditDate="2014-03-01T18:25:01.717" LastActivityDate="2018-02-10T20:57:03.397" Title="Combining Strings into a datestamp" Tags="|sd-card|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="486" PostTypeId="2" ParentId="485" CreationDate="2014-02-27T17:09:34.817" Score="5" Body="&lt;p&gt;&lt;em&gt;EDIT: As noted by Klaus Warzecha, the SD library may only support 8.3 format filenames (i.e. 8 characters for the name, 3 characters for the extension). The solution may in fact be to ensure that the years is only 2 digits, resulting in names like: &lt;code&gt;20-12-14.csv&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From what I can see in the SD library code, the &lt;code&gt;open()&lt;/code&gt; method isn't designed to accept a &lt;code&gt;String&lt;/code&gt; object as a parameter. It only wants a plain old &lt;a href=&quot;http://arduino.cc/en/Reference/String&quot; rel=&quot;nofollow&quot;&gt;C-style string&lt;/a&gt; (which means a &lt;code&gt;char&lt;/code&gt; array). That explains why your first example doesn't work -- it's trying to pass a &lt;code&gt;String&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second example unfortunately is invalid C++. You simply can't initialise an array like that. What you want to do instead is to build the &lt;code&gt;String&lt;/code&gt; object, then extract the characters out using &lt;code&gt;String::toCharArray()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String filename = String(now.day()) + &quot;-&quot; + String(now.month()) + &quot;-&quot; + String(now.year()) + &quot;.csv&quot;;&#xA;char str[16] = {0};&#xA;filename.toCharArray(str, 16);&#xA;dataFile = SD.open(str, FILE_WRITE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what your &lt;code&gt;now.year()&lt;/code&gt; returns; i.e. if that's a 2 digit or 4 digit year. I've assumed 4 digits, so I've made the &lt;code&gt;char&lt;/code&gt; array big enough for 15 characters in total, plus an extra null terminator (which is essential for C-style strings).&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-02-28T08:24:03.203" LastActivityDate="2014-02-28T08:24:03.203" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="487" PostTypeId="2" ParentId="485" CreationDate="2014-02-27T17:09:36.373" Score="1" Body="&lt;p&gt;In your second case, you need to break the initialization into two lines and use &lt;a href=&quot;http://arduino.cc/en/Reference/StringToCharArray&quot; rel=&quot;nofollow&quot;&gt;toCharArray()&lt;/a&gt; as shown:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;char dateName[13];&#xA;String(String(now.day()) + &quot;-&quot; + String(now.month()) + &quot;-&quot; + String(now.year()) + &quot;.csv&quot;).toCharArray(dateName, 13);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you can move ahead with opening the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you are seeing is quite literally what the error message says. An initialization of a character array requires a character array. It cannot be initialised with a string object.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-27T17:15:05.140" LastActivityDate="2014-02-27T17:15:05.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="488" PostTypeId="1" AcceptedAnswerId="492" CreationDate="2014-02-27T17:27:04.717" Score="9" ViewCount="7433" Body="&lt;p&gt;I have an espresso machine that gets its water from one of those 5 gallon blue water bottles (I would plumb it, but our water here is WAAAAY too hard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I ever accidentally let the bottle run out of water, the rotary pump in the espresso machine will be ruined, which would be a costly mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can install some sort of magnetic float sensor inside the water bottle, but since I have to change it out once every few weeks, having another thing inside the bottle would make changing it out harder, and microbial contamination more likely.  The pump that pumps water out of the bottle forms a tight seal at the lid, and anything running under it or through it would compromise that seal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I could use to detect if the water level is low from the outside of the bottle?  Like a laser sensor?&lt;/p&gt;&#xA;" OwnerUserId="323" LastEditorUserId="65" LastEditDate="2014-03-08T07:25:51.390" LastActivityDate="2020-11-09T04:12:34.163" Title="Best way to determine if a 5 gallon water jug is getting empty" Tags="|sensors|system-design|" AnswerCount="9" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="489" PostTypeId="1" CreationDate="2014-02-27T19:39:43.403" Score="8" ViewCount="7974" Body="&lt;p&gt;I am making an interface project that, when plugged into a computer, shows up as both usb flash storage and can type like a keyboard when some physical buttons on the board are pressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen projects that do one or the other, but not both at the same time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have gotten it to work using a usb hub and two chips that are sharing the same storage (since I want the hot-key buttons to type out information stored in the flash drive side as well), with one acting like a HID and one acting as usb storage, but this has a few problems. First, it feels redundant. Second it's difficult to program since every time I plug the mess in it randomly assigns a name to each chip with no easy way of telling which to send the HID code to and with to send the USB Drive code to. I have to plug them in one at a time which wont work once this project is all on the same board. The last problem is the buttons work inconsistently since, im assuming, the two chips are not doing a nice job of sharing access to the text file it's trying to read for the text to 'type out' on the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a nicer way of doing this that uses one arduino acting in both roles accessing the one flash storage? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="343" LastActivityDate="2020-07-01T17:45:22.837" Title="Make an Arduino board act as both a usb storage device and a keyboard?" Tags="|serial|programming|" AnswerCount="3" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="490" PostTypeId="2" ParentId="488" CreationDate="2014-02-27T19:51:07.663" Score="4" Body="&lt;p&gt;I think you want a &lt;a href=&quot;http://www.mouser.com/ProductDetail/Hamlin/59630-1-T-02-A/?qs=sGAEpiMZZMun2xR%252b%252bFUzeBXr8YNXGDFf8m4HoboDx0M=&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;liquid level switch&quot;&lt;/a&gt;, possibly also known as a &quot;fluid switch&quot; ... I realize this may not satisfy your requirements, but this is one way to solve the problem for &gt;$10. I would probably hack something together that would put this sensor inline to the bottle. it's probably too hacky, but you could have a disc of plywood the same diameter as the water bottle, with a pipe fitting in the middle where you could mount the switch, so that the water bottle routes water through it so that when it runs low, it would trigger the switch before it runs to the pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y2s79.png&quot; alt=&quot;inline liquid level switch&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="146" LastEditorUserId="146" LastEditDate="2014-02-27T20:05:07.483" LastActivityDate="2014-02-27T20:05:07.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="491" PostTypeId="2" ParentId="488" CreationDate="2014-02-27T20:08:46.467" Score="3" Body="&lt;p&gt;It seems to me that if you have pumped out 4.9 gallons you know the jug is close to empty. If an inline flow meter between the pump and the espessso maker is out due to water contact, then maybe you know that an espresso shot takes x amount of water, and once one has called for y shots (and calculated x times y) one is in the danger zone of running out of water? &lt;/p&gt;&#xA;" OwnerUserId="6" LastActivityDate="2014-02-27T20:08:46.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="492" PostTypeId="2" ParentId="488" CreationDate="2014-02-27T20:54:39.333" Score="10" Body="&lt;p&gt;&lt;strong&gt;Using a Force Sensor to Measure a Quantity of Water&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To satisfy your requirement of having the sensor on the exterior of the water container, I would recommend using a force sensor to weigh the bottle at set intervals. A force sensor, such as the FlexiForce A401, is a type of resistor that changes resistance in response to the amount of force applied. While not as accurate as a scale, it should provide enough accuracy (+-3% according to the &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Pressure/A401-force-sensor.pdf&quot;&gt;datasheet&lt;/a&gt;) for the application described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic procedure would be to hook up the force sensor to the Arduino and first measure the resistance with an empty bottle, then measure again with a full bottle. This will give you an idea of the force that your specific platform is actually applying to the sensor, and you can then fine tune the voltage (as per the datasheet) for your installation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A basic tutorial using a similar force sensor with an Arduino can be found &lt;a href=&quot;http://bildr.org/2012/11/flexiforce-arduino/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other Possibilities&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.fluidswitch.com/pages/Optical-Liquid-Level-Sensors.htm&quot;&gt;Optical Liquid Level Sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cigrjournal.org/index.php/Ejounral/article/viewFile/2343/1823&quot;&gt;Ultrasonic Level Monitoring&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Thermistors and Heating Coils at various levels to Measure the Thermal Mass (i.e. water) near the Sensor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="225" LastActivityDate="2014-02-27T20:54:39.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="493" PostTypeId="1" AcceptedAnswerId="511" CreationDate="2014-02-27T23:29:52.217" Score="4" ViewCount="30638" Body="&lt;p&gt;I'm trying to parse many variables into a URL so that I can update a website through a simple HTTP API with sensor data. After talking to a buddy of mine, he suggested going with the code below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put this in, the Arduino Yun boots up. I see the L13 red LED turn on, but then it hoses. When I comment out the &lt;code&gt;sprintf();&lt;/code&gt; line, everything works fine — except no URL is parsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to debug to the best of my ability and am looking for thoughts on what may be happening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how much code to post without posting the whole 130 line sketch, so I'm just dumping the parts from the &lt;code&gt;loop&lt;/code&gt; that is trying to piece together the URL.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // Get update time&#xA;  Process date;&#xA;  date.runShellCommand(&quot;date --utc \&quot;+%Y-%m-%d%%20%H:%M:%S\&quot;&quot;);&#xA;  String utcDateString = &quot;&quot;;&#xA;  while (date.available()) {&#xA;    char d = date.read();&#xA;    utcDateString += d;&#xA;  }&#xA;&#xA;      char url[512];&#xA;      url[0]='\0';&#xA;      float humid, baro, windspeed, raingauge;&#xA;      int winddir;&#xA;      Serial.print(&quot;humid: &quot;);&#xA;      Serial.println(humid);&#xA;        Serial.print(&quot;baro: &quot;);&#xA;      Serial.println(baro);&#xA;        Serial.print(&quot;windspeed: &quot;);&#xA;      Serial.println(windspeed);&#xA;        Serial.print(&quot;raingauge: &quot;);&#xA;      Serial.println(raingauge);&#xA;        Serial.print(&quot;winddir: &quot;);&#xA;      Serial.println(winddir);&#xA; //sprintf(url,&quot;http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=123456&amp;amp;PASSWORD=xxxxxx&amp;amp;dateutc=%s&amp;amp;temp=%2.2f&amp;amp;humidity=%2.2f&amp;amp;baromin=%f&amp;amp;winddir=%d&amp;amp;windspeedmph=%3.2f&amp;amp;rainin=%3.2f&amp;amp;softwaretype=Custom%%20Arduino&amp;amp;action=updateraw&quot;,&#xA;//         utcDateString,Thermistor(analogRead(0)),humid,baro,winddir,windspeed,raingauge);&#xA;        Serial.print(&quot;url: &quot;);&#xA;      Serial.println(url);&#xA;&#xA;double Thermistor(int RawADC) {&#xA;  double Temp;&#xA;  Temp = log(11100.0/((1024.0/RawADC-1)));  // Was 10000... Manually dialed down to increase accuracy. 9400 is a good value. Changing again to match wunderground&#xA;  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );&#xA;  Temp = Temp - 273.15;            // Convert Kelvin to Celcius&#xA;  Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit&#xA;  return Temp;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the output from those &lt;code&gt;Serial.print()&lt;/code&gt; calls:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;humid: 0.00&#xA;baro: 0.00&#xA;windspeed: 0.00&#xA;raingauge: 0.00&#xA;winddir: 0&#xA;url:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how else to debug this because when I uncomment &lt;code&gt;sprintf();&lt;/code&gt; the Yun locks up and I have to press the &lt;code&gt;32U4 Reset&lt;/code&gt; button and power cycle the Arduino to get it to work again.&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="365" LastEditDate="2014-02-28T19:20:47.733" LastActivityDate="2016-07-26T00:19:47.350" Title="sprintf() to assemble String and float pieces locks up" Tags="|sketch|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="494" PostTypeId="2" ParentId="488" CreationDate="2014-02-27T23:55:27.287" Score="5" Body="&lt;p&gt;Another option is to measure the current going into the pump; when it runs dry, the current goes up, which generates the heat that fries the pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or measure the temperature on the pump, but measuring the current will detect the beginning of the pump's meltdown, while the temperature may only detect the middle or end of the meltdown.  :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or install a current limiter or breaker inline with the pump, just in case everything else fails.  :-)&lt;/p&gt;&#xA;" OwnerUserId="347" LastActivityDate="2014-02-27T23:55:27.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="495" PostTypeId="2" ParentId="493" CreationDate="2014-02-28T00:54:04.997" Score="3" Body="&lt;p&gt;Looks like &lt;code&gt;%f&lt;/code&gt; isn't wired up for performance reasons.  You can convert floats to strings first using &lt;code&gt;dtostrf()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="348" LastEditorUserId="11" LastEditDate="2014-02-28T01:02:31.777" LastActivityDate="2014-02-28T01:02:31.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="496" PostTypeId="2" ParentId="488" CreationDate="2014-02-28T01:38:09.093" Score="3" Body="&lt;p&gt;Honestly - you're overthinking this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A dipstick or a float would be all you need.  Once the water level drops below your minimum, the float moves down with the water level and pulls a switch or allows a LDR to see through a hole.  Then do something like turn on a light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Less is more.&lt;/p&gt;&#xA;" OwnerUserId="350" LastActivityDate="2014-02-28T01:38:09.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="497" PostTypeId="2" ParentId="482" CreationDate="2014-02-28T01:44:54.170" Score="6" Body="&lt;p&gt;The Arduino Uno uses the Atmel Atmega328p microcontroller, which only has one debug option, DebugWire.  There are a few tools that can work with it, but the least expensive and most commonly available is the &lt;a href=&quot;http://www.atmel.com/tools/AVRDRAGON.aspx&quot;&gt;AVR Dragon&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use AVR Studio 6 for this.  You can use the &lt;code&gt;.elf&lt;/code&gt; file file produced during the Arduino build process directly, but setting up the debugger is a little easier if you port the Arduino program to the AVR Studio.  It's not difficult, but there are a lot of little pieces to deal with.  There are guides online to help you through this.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2014-02-28T01:44:54.170" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="498" PostTypeId="2" ParentId="489" CreationDate="2014-02-28T01:59:43.327" Score="1" Body="&lt;p&gt;You're looking to create a USB composite device.  I don't see any examples within the arduino community, but I don't see a reason why you couldn't &lt;a href=&quot;https://www.google.com/search?q=atmega%2016u2%20composite%20device&quot; rel=&quot;nofollow&quot;&gt;use the 16u2 as a composite device&lt;/a&gt;, it'll just require more effort than you'd normally put into an arduino project.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2014-02-28T01:59:43.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="500" PostTypeId="2" ParentId="488" CreationDate="2014-02-28T05:00:18.687" Score="4" Body="&lt;p&gt;Whenever light follows a path that takes it from one material to the next, it makes a sharp turn. However, the angle of deviation is different based on the characteristics of the materials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this principle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set a LED on the level that you want to be your lowest. When the water is full, its light will follow a certain path across the container and reach its light sensor. When the water gets bellow the level, it will miss it (or you could set up a second sensor if you really wanted to).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on this info, you can know when the water gets too low. Just take appropriate action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Watch out on the recommendation to measure the water used. This could be dangerous. You may have a leakage (either now or later) or somebody might tip the machine and spill some water. In either case your water level would be lower than the level you calculate, which would certainly result in your espresso machine be ruined.&lt;/p&gt;&#xA;" OwnerUserId="356" LastEditorUserId="356" LastEditDate="2014-02-28T05:09:10.593" LastActivityDate="2014-02-28T05:09:10.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="501" PostTypeId="1" AcceptedAnswerId="504" CreationDate="2014-02-28T05:28:50.783" Score="14" ViewCount="17857" Body="&lt;p&gt;In a similar way to the question  &quot;&lt;a href=&quot;https://arduino.stackexchange.com/questions/488/best-way-to-determine-if-a-5-gallon-water-jug-is-getting-empty&quot;&gt;&lt;strong&gt;best way to determine if a 5 gallon water jug is getting empty&lt;/strong&gt;&lt;/a&gt;&quot;, I'm looking for a way to measure water in a container. This is so it can be connected to an Arduino for logging and reporting.  But it's a very different container.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a home with the household water supplied from an underground concrete tank (around 3000 US gallons, 11000 litres).  Although there is a float switch cutout when it gets empty (to protect the pump), I'd like to know it's gettting low long before that (as it takes a while before a tanker delivers a fresh load).  Ideally something that measures exactly or in steps (at least in eights of a load), so software can predict when it'll run out based on average usage, and it can be monitored online when away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tank has a heavy concrete hatch, and a small hole that has an existing primitive dipstick, so access is limited.  It's in a harsh desert environment, but the pump room and power are only a few feet away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some ideas I had:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;suspend an array of float switches with strings of different lengths from a bar inside the tank, and wire them all back to a controller.  Hard to install, ugly, low tech. Or something similar on a vertical pole.&lt;/li&gt;&#xA;&lt;li&gt;contacts (like a US 2 pin plug) on a vertical pole that again are connected back to a controller (probably using a ribbon cable).  Corrosion/anodes might be a problem, although power could just be a short pulse at times.  Condensation, spiders webs and dead bugs may give false readings.&lt;/li&gt;&#xA;&lt;li&gt;run a fully insulated cable vertically down it, and use as an antenna to send a pulse through, and use the difference between how it works as an antenna in air, and in water, (like an SWR meter) to calculate how far down the water is.&lt;/li&gt;&#xA;&lt;li&gt;ultrasonic (or light?) distance finder mounted under the hatch.  Range needs to be up to 2 metres (6 feet).&lt;/li&gt;&#xA;&lt;li&gt;depth finder (sonar) on a float.  Biggest challenge here is getting the signal out (long cable might get tangled when the tank fills).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The last two would be even better if they were wireless (to save running a cable that might get damaged) but I don't think I'd get the battery life I'd like (1 year or more).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other ideas?  Has anybody ever done this?&lt;/p&gt;&#xA;" OwnerUserId="357" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-08-02T18:33:53.783" Title="Sensor for underground water tank level" Tags="|sensors|" AnswerCount="10" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="502" PostTypeId="2" ParentId="488" CreationDate="2014-02-28T06:05:14.713" Score="3" Body="&lt;p&gt;&lt;strong&gt;Lasers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your blue water bottles are like mine, they are transparent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I would try first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would get a cheap laser, and shine the light horizontally through the bottle.&#xA;I would aim the laser through a short &lt;a href=&quot;http://en.wikipedia.org/wiki/chord_%28geometry%29&quot; rel=&quot;nofollow&quot;&gt;chord&lt;/a&gt; -- not pointed directly through the middle of the bottle; perhaps 1/8 turn to the left of center.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    -------&#xA;L../.......\..........S1&#xA;  /         \&#xA; |     o     |        S2&#xA;  \         /&#xA;   \       /&#xA;    -------&#xA;top-down view&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the bottle is empty, the laser beam will shoot pretty much straight through the bottle -- I would put one photo-sensor S1 there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the bottle is not quite empty, the laser beam will bend (&lt;a href=&quot;http://en.wikipedia.org/wiki/refraction&quot; rel=&quot;nofollow&quot;&gt;refract&lt;/a&gt;) -- for redundancy, I would put another photo-sensor S2 there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as the Arduino sees the laser hitting S2 alone, there's still some water in the bottle, at least up to the level of the laser -- turn on the green light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything else -- light detecting only at S1, or nothing detected at either sensor, or light detected at both sensors (yes, it can happen) -- something doesn't seem right, better have the Arduino turn off the green light and turn on the red light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would start with &lt;a href=&quot;http://www.artima.com/intv/simplestP.html&quot; rel=&quot;nofollow&quot;&gt;the simplest thing that could possibly work&lt;/a&gt;.&#xA;If I'm lucky, it might work.&#xA;If not, there's lots of little tricks involved in getting the light where you want it to go.&#xA;There's also lots of tricks for blocking sunlight, etc. from going where you don't want it to go.&#xA;Little black tubes, red plastic filters,&#xA;pulsing the laser at a few kHz,&#xA;collimating lenses,&#xA;lock-in amplifiers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seem to be lots of tutorials that describe how to detect a laser using Arduino -- see&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.radioshack.com/graphics/uc/rsk/Support/ProductManuals/Laser_Harp_Online_Instructions.pdf&quot; rel=&quot;nofollow&quot;&gt;&quot;Laser Harp&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.manylabs.org/project/laserGate/&quot; rel=&quot;nofollow&quot;&gt;&quot;Laser Timing Gate&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Laser-Tripwire/&quot; rel=&quot;nofollow&quot;&gt;&quot;Arduino Laser Tripwire&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,13046.0.html&quot; rel=&quot;nofollow&quot;&gt;&quot;Arduino Forum: laser detection&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hackaday.com/2010/01/03/arduino-security-with-frickin-laser/&quot; rel=&quot;nofollow&quot;&gt;&quot;Arduino security with frickin’ laser&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://keithkay.com/2013/03/03/arduino-self-calibrating-laser-trip-wire/&quot; rel=&quot;nofollow&quot;&gt;&quot;Arduino self-calibrating laser trip wire&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://makezine.com/projects/the-arduino-controlled-laser-security-system/&quot; rel=&quot;nofollow&quot;&gt;&quot;The Arduino Controlled Laser Security System&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://pyevolve.sourceforge.net/wordpress/?p=2383&quot; rel=&quot;nofollow&quot;&gt;&quot;Raspberry Pi &amp;amp; Arduino: laser pointer communication&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(This would probably work just as well with a medium-power LED or &quot;infrared LED&quot; and some careful optical focusing and alignment. But -- lasers!)&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-02-28T06:05:14.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="503" PostTypeId="2" ParentId="485" CreationDate="2014-02-28T07:25:02.660" Score="2" Body="&lt;p&gt;Is this based on the &lt;a href=&quot;http://code.google.com/p/sdfatlib/&quot; rel=&quot;nofollow&quot;&gt;SDFat&lt;/a&gt; library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have to live with short 8.3 filenames for the moment.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-02-28T07:25:02.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="504" PostTypeId="2" ParentId="501" CreationDate="2014-02-28T08:29:06.940" Score="12" Body="&lt;p&gt;I have a background working on ships where robust and workable tank level gauges are  a huge part of instrumentation available to you. Water is the most forgiving and easiest liquid to measure - it's cool, not too viscous, not corrosive in itself, and easy to clean off. There are a lot of options available to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would avoid any system which involves immersing anything in liquid if at all possible. Waterproofing isn't easy. I would also try to stay with a tried and tested system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to run through your solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Multiple float switches - has poor resolution. Would be reliable. You can buy assemblies with LowLow, LowHigh, HighLow, HighHigh float limit switches already on them for maintaining tanks levels, but these are industrial quality with industrial prices.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This would work, but corrosion is going to be an issue. Resolution limited by how many contacts you have.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Interesting idea, but would likely require a lot of DSP work. Not a tried and tested method.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An ultrasonic sensor would be my preferred method. Non-contact, high resolution, range of 2m is easy. Tried and tested system.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Interesting idea, would require a lot of work. Easier to measure depth of air as per 4 and do the simple maths.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A few other methods come to mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A pressure sensor at the bottom of the tank. This is often used on ships, works well but needs immersion which can be avoided.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Inflow/outflow monitoring. A flow meter on the output can tell you how much you have used. Inferring level like this is prone to errors though.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are a million other methods, but they get more and more complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ultrasound would be a great way to do this. The commonly available &lt;a href=&quot;http://www.parallax.com/product/28015&quot;&gt;Parallax Ping&lt;/a&gt; sensor would do the job. Realistically, you would only need to make measurements at most once every hour, so you could achieve great battery life. The concrete is likely to present a wireless range challenge. Most RF transceivers will get through concrete though, so place the receiver nearby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want ideas on how it is done, google for ultrasonic &lt;em&gt;oil&lt;/em&gt; level monitoring - there are loads of wireless commercial solutions.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-02-28T08:34:48.887" LastActivityDate="2014-02-28T08:34:48.887" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="505" PostTypeId="2" ParentId="488" CreationDate="2014-02-28T09:13:41.540" Score="3" Body="&lt;p&gt;you can use a metal detector like setup using the fact that electronic &lt;a href=&quot;http://en.wikipedia.org/wiki/Permitivity&quot; rel=&quot;nofollow&quot;&gt;permittivity&lt;/a&gt; of water is different than that of air&lt;/p&gt;&#xA;&#xA;&lt;p&gt;have a coil with AC next to the bottle and an unpowered coil inside it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then by measuring the current and/or voltage generated by the second coil you can sense the difference between with water next to it and without&lt;/p&gt;&#xA;" OwnerUserId="359" LastEditorUserId="359" LastEditDate="2014-02-28T13:31:27.123" LastActivityDate="2014-02-28T13:31:27.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="506" PostTypeId="1" AcceptedAnswerId="510" CreationDate="2014-02-28T09:46:51.437" Score="32" ViewCount="58239" Body="&lt;p&gt;Arduino is an odd hybrid, where some C++ functionality is used in the embedded world—traditionally a C environment. Indeed, a lot of Arduino code is very C like though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C has traditionally used &lt;code&gt;#define&lt;/code&gt;s for constants. There are a number of reasons for this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can't set array sizes using &lt;code&gt;const int&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You can't use &lt;code&gt;const int&lt;/code&gt; as case statement labels (though this does work in some compilers)&lt;/li&gt;&#xA;&lt;li&gt;You can't initialize a &lt;code&gt;const&lt;/code&gt; with another &lt;code&gt;const&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can check &lt;a href=&quot;https://stackoverflow.com/questions/1674032/static-const-vs-define-in-c&quot;&gt;this question&lt;/a&gt; on StackOverflow for more reasoning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what should we use for Arduino? I tend towards &lt;code&gt;#define&lt;/code&gt;, but I see some code using &lt;code&gt;const&lt;/code&gt; and some using a blend.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2021-10-06T14:22:39.913" Title="Is it better to use #define or const int for constants?" Tags="|programming|c++|coding-standards|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="507" PostTypeId="2" ParentId="506" CreationDate="2014-02-28T10:40:05.943" Score="7" Body="&lt;p&gt;&lt;em&gt;EDIT: microtherion gives an excellent answer which corrects some of my points here, particularly about memory usage.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As you've identified, there are certain situations where you're forced to use a &lt;code&gt;#define&lt;/code&gt;, because the compiler won't allow a &lt;code&gt;const&lt;/code&gt; variable. Similarly, in some situations you're forced to use variables, such as when you need an array of values (i.e. you can't have an array of &lt;code&gt;#define&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are many other situations where there isn't necessarily a single 'correct' answer. Here are some guidelines which I would follow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Type safety&lt;/strong&gt;&lt;br&gt;&#xA;From a general programming point-of-view, &lt;code&gt;const&lt;/code&gt; variables are usually preferable (where possible). The main reason for that is type-safety.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;#define&lt;/code&gt; (preprocessor macro) directly copies the literal value into each location in code, making every usage independent. This can hypothetically result in ambiguities, because the type may end up being resolved differently depending on how/where it's used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;const&lt;/code&gt; variable is only ever one type, which is determined by its declaration, and resolved during initialisation. It will often require an explicit cast before it will behave differently (although there are various situations where it can safely be implicitly type-promoted). At the very least, the compiler can (if configured correctly) emit a more reliable warning when a type issue occurs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible workaround for this is to include an explicit cast or a type-suffix within a &lt;code&gt;#define&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define THE_ANSWER (int8_t)42&#xA;#define NOT_QUITE_PI 3.14f&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That approach can potentially cause syntax problems in some cases though, depending on how it's used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Memory usage&lt;/strong&gt;&lt;br&gt;&#xA;Unlike general purpose computing, memory is obviously at a premium when dealing with something like an Arduino. Using a &lt;code&gt;const&lt;/code&gt; variable vs. a &lt;code&gt;#define&lt;/code&gt; can affect where the data is stored in memory, which may force you to use one or the other.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;const&lt;/code&gt; variables will (usually) be stored in SRAM, along with all other variables.&lt;/li&gt;&#xA;&lt;li&gt;Literal values used in &lt;code&gt;#define&lt;/code&gt; will often be stored in program space (Flash memory), alongside the sketch itself.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that there are various things which can affect exactly how and where something is stored, such as compiler configuration and optimisation.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SRAM and Flash have different limitations (e.g. 2 KB and 32 KB respectively for the Uno). For some applications, it's quite easy to run out of SRAM, so it can be helpful to shift some things into Flash. The reverse is also possible, although probably less common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PROGMEM&lt;/strong&gt;&lt;br&gt;&#xA;It's possible to get the benefits of type-safety while also storing the data in program space (Flash). This is done using the &lt;code&gt;PROGMEM&lt;/code&gt; keyword. It doesn't work for all types, but it's commonly used for arrays of integers or strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general form given in the &lt;a href=&quot;http://arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;documentation&lt;/strong&gt;&lt;/a&gt; is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dataType variableName[] PROGMEM = {dataInt0, dataInt1, dataInt3...}; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;String tables are a bit more complicated, but the documentation has full details.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-02-28T15:50:16.123" LastActivityDate="2014-02-28T15:50:16.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="508" PostTypeId="1" AcceptedAnswerId="509" CreationDate="2014-02-28T11:05:39.467" Score="4" ViewCount="6148" Body="&lt;p&gt;I have an object with a series of led and I want to turn on and off these leds from my Arduino. The input of the LED circuit is 24v DC 100mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've done is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I've cut a wire of this object and I connected one end to the collector and the other end to the emitter of a NPN transistor&lt;/li&gt;&#xA;&lt;li&gt;I connected the base of the transistor to a digital output (through a 1k resistance)&lt;/li&gt;&#xA;&lt;li&gt;I connected the power to the led series while the digital pin was LOW (actually completely disconnected)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But with no current on the base of the transistor, the LED has turned on to my surprise.&lt;/strong&gt; I may have completely misused the transistor and other items. How do I fix this circuit?&lt;/p&gt;&#xA;" OwnerUserId="360" LastEditorUserId="220" LastEditDate="2014-03-01T13:17:26.133" LastActivityDate="2014-03-01T13:17:26.133" Title="How to switch an external circuit with Arduino?" Tags="|power|transistor|voltage-level|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="509" PostTypeId="2" ParentId="508" CreationDate="2014-02-28T12:44:57.123" Score="6" Body="&lt;p&gt;If I understand your writeup correctly, this is what you have built:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8zae1.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f8zae1.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you didn't mention in your question is that you made a connection from Arduino ground to the base of the transistor and the seconds circuit's ground connection. I drew the extra lead 'loose' for illustration only, but you see where it should connect. Current needs a return path, it is not sufficient to only have the forward path (from Arduino through R1 and base-Q1). The return path is emitter-Q1 to Arduino-GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do notice though that the two batteries / power supplies must be floating with respect to each other otherwise you're going to short them out.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-02-28T12:44:57.123" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="510" PostTypeId="2" ParentId="506" CreationDate="2014-02-28T15:05:36.517" Score="25" Body="&lt;p&gt;It's important to note that &lt;code&gt;const int&lt;/code&gt; does &lt;strong&gt;not&lt;/strong&gt; behave identically in C and in C++, so in fact several of the objections against it that have been alluded to in the original question and in Peter Bloomfields's extensive answer are not valid:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In C++, &lt;code&gt;const int&lt;/code&gt; constants are compile time values and &lt;strong&gt;can&lt;/strong&gt; be used to set array limits, as case labels, etc.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;const int&lt;/code&gt; constants do not necessarily occupy any storage. Unless you take their address or declare them extern, they will generally just have a compile time existence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, for integer constants, it might often be preferable to use a (named or anonymous) &lt;code&gt;enum&lt;/code&gt;. I often like this because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's backward compatible with C.&lt;/li&gt;&#xA;&lt;li&gt;It's nearly as type safe as &lt;code&gt;const int&lt;/code&gt; (every bit as type safe in C++11).&lt;/li&gt;&#xA;&lt;li&gt;It provides a natural way of grouping related constants.&lt;/li&gt;&#xA;&lt;li&gt;You can even use them for some amount of namespace control.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So in an idiomatic C++ program, there is no reason whatsoever to use &lt;code&gt;#define&lt;/code&gt; to define an integer constant. Even if you want to remain C compatible (because of technical requirements, because you're kickin' it old school, or because people you work with prefer it that way), you can still use &lt;code&gt;enum&lt;/code&gt; and should do so, rather than use &lt;code&gt;#define&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-02-28T15:05:36.517" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="511" PostTypeId="2" ParentId="493" CreationDate="2014-02-28T16:14:50.733" Score="7" Body="&lt;p&gt;This variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String utcDateString = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is a C++ String, not a character array like sprintf() is expecting.  To convert this string to a character array such that sprintf is expecting, you must use .c_str() in your sprintf, i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(foo,&quot;This is a format for %s&quot;, utcDateString.c_str());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing this should prevent the sprintf line from causing a memory fault.&lt;/p&gt;&#xA;" OwnerUserId="364" LastActivityDate="2014-02-28T16:14:50.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="512" PostTypeId="5" CreationDate="2014-02-28T16:46:24.083" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-02-28T16:46:24.083" LastActivityDate="2014-02-28T16:46:24.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="513" PostTypeId="4" CreationDate="2014-02-28T16:46:24.083" Score="0" Body="This refers to techniques and practices to to be followed to ensure the correct functioning of the board and its well-being over time." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-02-28T19:20:40.720" LastActivityDate="2014-02-28T19:20:40.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="514" PostTypeId="5" CreationDate="2014-02-28T16:47:38.107" Score="0" Body="&lt;p&gt;A sensor is a converter that measures a physical quantity and converts it into an analog or digital signal which can be read by an Arduino. Use this tag for questions about selecting, connecting, using, and debugging sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some of the most common types of sensors:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://learn.adafruit.com/tmp36-temperature-sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;Temperature sensor&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://arduino.cc/en/tutorial/button&quot; rel=&quot;nofollow noreferrer&quot;&gt;Button&lt;/a&gt;&lt;/strong&gt;&#xA;&lt;img src=&quot;https://arduino.cc/en/uploads/Tutorial/button.png&quot; &gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Light sensor&lt;/strong&gt; (Used in &lt;em&gt;&lt;a href=&quot;https://arduino.cc/en/Tutorial/Calibration&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;&lt;/em&gt;.)&#xA;&lt;img src=&quot;https://arduino.cc/en/uploads/Tutorial/calibration.png&quot; &gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Potentiometer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Potentiometer&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Tutorial/potentiometer.jpg&quot; &gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="213" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.147" LastActivityDate="2014-03-18T21:20:48.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="515" PostTypeId="4" CreationDate="2014-02-28T16:47:38.107" Score="0" Body="Use this tag for questions about selecting, connecting, using, and debugging sensors." OwnerUserId="65" LastEditorUserId="213" LastEditDate="2014-03-15T21:06:46.580" LastActivityDate="2014-03-15T21:06:46.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="516" PostTypeId="5" CreationDate="2014-02-28T16:51:38.830" Score="0" Body="&lt;p&gt;This tag is for questions about the official &lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/main/software&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino IDE&lt;/a&gt;&lt;/strong&gt;. This open-source IDE makes it easy to write code/sketches and upload it/them to any Arduino board. The IDE runs on Windows, macOS and Linux.&lt;/p&gt;&#xA;&lt;p&gt;Virtually all beginner tutorials use the Arduino IDE. You can write the code, select the correct COM port, and then click &amp;quot;upload.&amp;quot; Other IDEs may require more configuration and not be as user friendly. It is available as a standalone application or installer on Windows.&lt;/p&gt;&#xA;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/en/d/d9/Arduino_1.0_IDE%2C_Ubuntu_11.10.png&quot; &gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/File:Arduino_1.0_IDE,_Ubuntu_11.10.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino IDE running on Ubuntu Linux&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;For more information about &lt;b&gt;I&lt;/b&gt;ntegrated &lt;b&gt;D&lt;/b&gt;evelopment &lt;b&gt;E&lt;/b&gt;nvironments in general, see the &lt;a href=&quot;/questions/tagged/ide&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ide&amp;#39;&quot; rel=&quot;tag&quot;&gt;ide&lt;/a&gt; tag.&lt;/p&gt;&#xA;" OwnerUserId="275" LastEditorUserId="27346" LastEditDate="2020-12-13T11:03:23.397" LastActivityDate="2020-12-13T11:03:23.397" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="517" PostTypeId="4" CreationDate="2014-02-28T16:51:38.830" Score="0" Body="This is for questions about the official IDE. The open-source IDE makes it easy to write code and upload it to any Arduino board. It runs on Windows, macOS and Linux." OwnerUserId="65" LastEditorUserId="27346" LastEditDate="2020-12-13T11:03:25.757" LastActivityDate="2020-12-13T11:03:25.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="518" PostTypeId="1" CreationDate="2014-02-28T17:03:44.967" Score="8" ViewCount="6712" Body="&lt;p&gt;When reading/trying a &lt;a href=&quot;https://arduino.stackexchange.com/a/511/42&quot;&gt;recent answer&lt;/a&gt;, I was surprised to see that Arduino's &lt;code&gt;String&lt;/code&gt; class supports the &lt;code&gt;c_str()&lt;/code&gt; method, just like the C++ &lt;code&gt;std::string&lt;/code&gt; class. As expected, it appears to get a pointer to the string's contents as a null-terminated &lt;code&gt;char&lt;/code&gt; array (i.e. C-style string).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, (as far as I can see) that method is not mentioned in the official Arduino documentation. Additionally, in all example code I've seen using &lt;code&gt;String&lt;/code&gt;, a different approach seems to be used. A secondary &lt;code&gt;char&lt;/code&gt; buffer is setup, and then the contents of the string are copied to it using &lt;a href=&quot;http://arduino.cc/en/Reference/StringToCharArray&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;String::toCharArray()&lt;/code&gt;&lt;/a&gt;. This obviously requires double the memory, plus an O(n) copy operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like &lt;code&gt;c_str()&lt;/code&gt; should be the preferred approach. Is there some reason why &lt;code&gt;toCharArray()&lt;/code&gt; is more commonly used?&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-03-01T13:55:11.313" Title="Is it better to use c_str or toCharArray?" Tags="|programming|c++|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="520" PostTypeId="5" CreationDate="2014-03-01T00:43:38.637" Score="0" Body="&lt;p&gt;Use this tag for any questions which relate directly to using text strings in Arduino programming, whether for input, output, storage, or transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag can cover any representation of a string which Arduino will support, including &lt;code&gt;char&lt;/code&gt; arrays (null-terminated or otherwise), the Arduino &lt;code&gt;String&lt;/code&gt; class, and the C++ &lt;code&gt;std::string&lt;/code&gt; class.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-01T00:43:38.637" LastActivityDate="2014-03-01T00:43:38.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="521" PostTypeId="4" CreationDate="2014-03-01T00:43:38.637" Score="0" Body="A sequence of characters -- including letters, numbers and symbols -- often used for representing information in a human-readable format." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-01T00:43:38.637" LastActivityDate="2014-03-01T00:43:38.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="522" PostTypeId="2" ParentId="489" CreationDate="2014-03-01T00:52:47.303" Score="2" Body="&lt;p&gt;The Leonardo can easily be used as a keyboard. There are also special codes to turn the USB-to-Serial chip on newe Unos into a keyboard (see &lt;a href=&quot;http://www.fourwalledcubicle.com/LUFA.php&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB mass storage is another game all together. The &lt;a href=&quot;https://www.sparkfun.com/products/10155&quot; rel=&quot;nofollow&quot;&gt;Brondani EasyUSB&lt;/a&gt; is a simple chip that exposes 2MB of storage space on both the USB and microcontroller. They say they will be releasing larger capacities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easyUSB also has a serial link built into it from uC to computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want, you can make your own USB stack to handle this on you own, but the pitifully small amount of ram on these chips would prohibit it.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-01T00:52:47.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="523" PostTypeId="5" CreationDate="2014-03-01T02:09:12.767" Score="0" Body="&lt;p&gt;The Arduino Mega is a board based on the ATmega2560 or 1280 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag for questions specifically regarding the Mega, and not just general Arduino usage. This applies to both versions of this board.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;&lt;a href=&quot;https://arduino.cc/en/Main/arduinoBoardMega2560&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mega 2560&lt;/a&gt;:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From official Arduino page:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoMega2560_R3_Front_450px.jpg&quot; &gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Microcontroller   ATmega2560&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Operating Voltage 5V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (recommended)   7-12V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (limits)    6-20V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Digital I/O Pins  54 (of which 15 provide PWM output)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Analog Input Pins 16&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;DC Current per I/O Pin    40 mA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;DC Current for 3.3V Pin   50 mA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Flash Memory  256 KB of which 8 KB used by bootloader&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SRAM  8 KB&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;EEPROM    4 KB&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Clock Speed   16 MHz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;&lt;a href=&quot;https://arduino.cc/en/Main/arduinoBoardMega&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mega 1280&lt;/a&gt;:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From official Arduino page:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Microcontroller   ATmega1280&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Operating Voltage 5V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (recommended)   7-12V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (limits)    6-20V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Digital I/O Pins  54 (of which 15 provide PWM output)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Analog Input Pins 16&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;DC Current per I/O Pin    40 mA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;DC Current for 3.3V Pin   50 mA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Flash Memory  128 KB of which 4 KB used by bootloader&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SRAM  8 KB&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;EEPROM    4 KB&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Clock Speed   16 MHz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.190" LastActivityDate="2014-03-18T22:39:17.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="524" PostTypeId="4" CreationDate="2014-03-01T02:09:12.767" Score="0" Body="A microcontroller board based on the ATmega2560 or 1280 chip. Use this tag for questions specifically regarding the Mega, and not just general Arduino usage." OwnerUserId="11" LastEditorUserId="220" LastEditDate="2014-03-18T22:39:17.040" LastActivityDate="2014-03-18T22:39:17.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="525" PostTypeId="1" CreationDate="2014-03-01T02:53:30.003" Score="4" ViewCount="6241" Body="&lt;p&gt;Can someone help me understand how the external antenna IPX connector actually stays connected to the Yun? Do I have to &quot;force&quot; it in so it snaps in? I've been somewhat gentle with it in fear I'll break something. However when I get close to getting it in, it just pops back out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've never worked with an IPX connector before, and I'm trying to not break anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I may have figured this out. Looks like the socket on the Yun is an IPEX socket, which is female. The cable I have is an IPX/uFL/u.FL connector, which also appears to be female. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like I need to use an MCX cable adapter as found here: &lt;a href=&quot;http://www.adafruit.com/products/1532&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.adafruit.com/products/1532&lt;/a&gt; If someone could confirm this for me, that'd be great. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a picture of the cable I purchased and my Yun. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/nadBC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="306" LastEditorUserId="306" LastEditDate="2014-03-01T03:06:52.800" LastActivityDate="2017-11-29T03:15:15.467" Title="Arduino Yun external antenna" Tags="|arduino-yun|wifi|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="526" PostTypeId="2" ParentId="525" CreationDate="2014-03-01T03:21:43.237" Score="4" Body="&lt;p&gt;There's a discussion on the Arduino Forum about this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=188976.0&quot; rel=&quot;nofollow&quot;&gt;Mystery component on Yun board?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I read it's only for testing purposes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the connector is a MM8430-2610 (&lt;a href=&quot;http://www.murata.com/products/catalog/pdf/o33e.pdf&quot; rel=&quot;nofollow&quot;&gt;see this&lt;/a&gt;). You can plug in a&#xA;  MXGS83RK3000/MM126036: once plugged in, the switch connector will turn&#xA;  the internal antenna off and use the probe as an external antenna&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-01T03:21:43.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="527" PostTypeId="2" ParentId="525" CreationDate="2014-03-01T04:35:24.260" Score="1" Body="&lt;p&gt;Testing with my Yún, it took quite a bit of force to install the connector. I had to use pliers to get extra leverage, but it eventually snapped in place.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-01T04:35:24.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="528" PostTypeId="5" CreationDate="2014-03-01T06:04:16.750" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-01T06:04:16.750" LastActivityDate="2014-03-01T06:04:16.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="529" PostTypeId="4" CreationDate="2014-03-01T06:04:16.750" Score="0" Body="Electronically Erasable ROM is a type of memory available on most boards. It is used for storing persistent data. Use the tag for questions about the EEPROM library or the hardware." OwnerUserId="65" LastEditorUserId="11" LastEditDate="2014-03-01T06:15:32.667" LastActivityDate="2014-03-01T06:15:32.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="530" PostTypeId="5" CreationDate="2014-03-01T07:41:53.223" Score="0" Body="&lt;p&gt;Use this tag for questions relating to connecting your Arduino to a WiFi network.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="19515" LastEditDate="2016-09-08T19:41:32.800" LastActivityDate="2016-09-08T19:41:32.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="531" PostTypeId="4" CreationDate="2014-03-01T07:41:53.223" Score="0" Body="Wi-Fi is a trademark of the Wi-Fi Alliance. A Wi-Fi enabled device such as a personal computer, video game console, smartphone, or digital audio player can connect to the Internet when within range of a wireless network connected to the Internet. " OwnerUserId="11" LastEditorUserId="19515" LastEditDate="2016-09-24T02:10:29.487" LastActivityDate="2016-09-24T02:10:29.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="532" PostTypeId="1" AcceptedAnswerId="537" CreationDate="2014-03-01T09:46:43.670" Score="7" ViewCount="1224" Body="&lt;p&gt;I've used enough products with embedded microcontrollers and unresponsive UIs to know that it can make or break a product. Even a slight delay or lag between the button presses and the display updating, or button presses being ignored or double counted, can be extremely frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What design patterns can be used to deal with user input (from buttons) and updating displays without causing these issues?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently use the following kind of pattern (this is simplified down to the bare minimum):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bounce.h&amp;gt;&#xA;&#xA;#define GREEN_LED       6 // Pin for green LED&#xA;&#xA;#define BUTTON_PIN      15 // Pin for button - uses external pull down so active high&#xA;&#xA;#define DISPLAY_REFRESH_INT 100 // How many MS between display updates&#xA;&#xA;Bounce button = Bounce(BUTTON_PIN, 5);&#xA;&#xA;// To signal between the button read and the display update&#xA;bool ledState = false;&#xA;&#xA;// Used to keep track of last display update&#xA;long displayUpdate = 0;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(GREEN_LED, OUTPUT);&#xA;    pinMode(BUTTON_PIN, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Read the button status&#xA;    if (button.update())&#xA;    {&#xA;        if (button.risingEdge())&#xA;        {&#xA;            ledState = !ledState;&#xA;        }&#xA;    }&#xA;&#xA;    // Update the display periodically&#xA;    if (millis() - displayUpdate &amp;gt; DISPLAY_REFRESH_INT)&#xA;    {&#xA;        displayUpdate = millis();&#xA;&#xA;        digitalWrite(GREEN_LED, ledState);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What other options are there? Is it ever worth using pin change interrupts to read buttons (if we are not considering battery life!).&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2017-03-03T19:56:11.353" Title="What design patterns can I use to handle user input and display updating?" Tags="|button|ui|display|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="533" PostTypeId="1" AcceptedAnswerId="535" CreationDate="2014-03-01T10:00:28.807" Score="10" ViewCount="23462" Body="&lt;p&gt;These are two ways I can hold a variable outside of loop (or any function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I can declare it with global scope outside of loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;int count = 0;&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(count);&#xA;    count++;&#xA;&#xA;    delay(250);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also declare it static inside the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    static int count = 0;&#xA;&#xA;    Serial.println(count);&#xA;    count++;&#xA;&#xA;    delay(250);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What difference, if any, will this make?&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2023-01-14T12:49:43.610" Title="What is the difference between declaring a variable outside of loop and declaring static inside loop?" Tags="|programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="535" PostTypeId="2" ParentId="533" CreationDate="2014-03-01T10:45:19.803" Score="10" Body="&lt;p&gt;The most basic difference is of scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first case, you are declaring a global variable. It is a variable that is accessible in every scope after its definition.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void inc();&#xA;int count = 0;&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(count);&#xA;    count++;&#xA;&#xA;    inc();&#xA;&#xA;    delay(500);&#xA;}&#xA;&#xA;void inc() //Can edit the value of count&#xA;{&#xA;  count=count+1;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the second case, you are declaring a static variable with local scope. The variable will persist for the entire program run similar to global variables, but will be accessible only in the code block it is declared in. This is the same example, with only one change. &lt;code&gt;count&lt;/code&gt; is now declared as a static variable inside &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void inc();&#xA;&#xA;void loop()&#xA;{&#xA;    static int count = 0;&#xA;    Serial.println(count);&#xA;    count++;&#xA;&#xA;    inc();&#xA;&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will not compile as the function &lt;code&gt;inc()&lt;/code&gt; does not have access to &lt;code&gt;count&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Global variables, however seemingly useful, come with some pitfalls. These can even cause damage when it comes to writing programs that can interact with the physical surroundings. This a very basic example of something that is quite likely to happen, as soon as programs start getting larger. A function may inadvertently change the state of a global variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;void another_function();&#xA;int state=0;&#xA;&#xA;void loop()&#xA;{&#xA;    //Keep toggling the state&#xA;    Serial.println(state);&#xA;    delay(250);&#xA;    state=state?0:1;&#xA;&#xA;    //Some unrelated function call&#xA;    another_function();&#xA;}&#xA;&#xA;void another_function()&#xA;{&#xA;  //Inadvertently changes state&#xA;  state=1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Such cases are very hard to debug. &lt;em&gt;This&lt;/em&gt; type of problem however, can easily be detected, by simply using a static variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;void another_function();&#xA;&#xA;void loop()&#xA;{&#xA;    static int state=0;&#xA;&#xA;    //Keep toggling the state&#xA;    Serial.println(state);&#xA;    delay(250);&#xA;    state=state?0:1;&#xA;&#xA;    //Some unrelated function call&#xA;    another_function();&#xA;}&#xA;&#xA;void another_function()&#xA;{&#xA;  //Results in a compile time error. Saves time.&#xA;  state=1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-01T11:09:53.580" LastActivityDate="2014-03-01T11:09:53.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="536" PostTypeId="2" ParentId="533" CreationDate="2014-03-01T10:49:55.183" Score="5" Body="&lt;p&gt;From a functional perspective, both versions generate the same result, since in both cases the value of &lt;code&gt;count&lt;/code&gt; is stored between the executions of the &lt;code&gt;loop()&lt;/code&gt; (either because it is a global variable or because it is marked as &lt;code&gt;static&lt;/code&gt; and therefore keeps its value).&lt;/p&gt;&#xA;&lt;p&gt;So the decision which to choose come down to following arguments:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Generally, in computer science, it is encouraged to keep your variables as local as possible in terms of &lt;strong&gt;scope&lt;/strong&gt;. This usually results in much clearer code with less side-effects and reduces chances of someone else using that global variable screwing up your logic. E.g. in your first example, other logic areas might change the &lt;code&gt;count&lt;/code&gt; value, whereas in the second, only that particular function &lt;code&gt;loop()&lt;/code&gt; can do so.&lt;/li&gt;&#xA;&lt;li&gt;Global and static variables always occupy &lt;strong&gt;memory&lt;/strong&gt;, where as locals only do when they are in scope. In your above examples that makes no difference (since in one you use a global, in the other a static variable), but in bigger and more complex programs it might and you could save memory using non-static locals.&#xA;&lt;em&gt;However&lt;/em&gt;: If you have a variable in a logic area that is executed very often, consider making it either static or global, since&#xA;otherwise you loose a tiny bit of performance each time that logic&#xA;area is entered, since it takes a bit of time to allocate the memory&#xA;for that new variable instance. You need to find a balance between memory load and performance.&lt;/li&gt;&#xA;&lt;li&gt;Other points such as better layout for &lt;strong&gt;static analysis&lt;/strong&gt; or &lt;strong&gt;optimization&lt;/strong&gt; by the compiler might also come into play.&lt;/li&gt;&#xA;&lt;li&gt;In some special scenarios, there might be issues with the unpredictable initialization order of static elements (not sure about that point, compare this &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=nt8h6685309s1vv0voea1rbkd5&amp;amp;topic=74180.msg559158#msg559158&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; though).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=i4sdu9bn0f8u2jekn5tl5pbeo1&amp;amp;topic=74180.msg559208#msg559208&quot; rel=&quot;nofollow noreferrer&quot;&gt;Similar thread&lt;/a&gt; on arduino.cc&lt;/p&gt;&#xA;" OwnerUserId="275" LastEditorUserId="275" LastEditDate="2023-01-14T12:49:43.610" LastActivityDate="2023-01-14T12:49:43.610" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="537" PostTypeId="2" ParentId="532" CreationDate="2014-03-01T11:50:10.063" Score="6" Body="&lt;p&gt;The answer depends on exactly how the sketch is meant to respond to the user interaction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;External interrupts&lt;/strong&gt;&lt;br&gt;&#xA;If the interaction depends on responding very accurately to the rising or falling edge of an input event (as in your example), then an &lt;a href=&quot;https://arduino.stackexchange.com/questions/316/can-a-function-be-called-automatically-when-an-input-changes/317#317&quot;&gt;external interrupt&lt;/a&gt; may be the way to go, if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is particularly important if the input event might be shorter that the duration of a call to &lt;code&gt;loop()&lt;/code&gt;. If that happens, consecutive attempts to poll the input could completely miss the state change. It's quite rare for a user input event to be that short though, unless &lt;code&gt;loop()&lt;/code&gt; is quite slow to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;External hardware to get help that though, e.g. by having an input which latches until it is read and reset by the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Improving polling frequency&lt;/strong&gt;&lt;br&gt;&#xA;External interrupts often aren't possible (e.g. because the chip only supports a limited number), or they are simply overkill/unnecessary for a given application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In those cases, it may still be possible to improve the timing precision when using polling. One option is to split up all the different parts of the main loop into separate functions. On each successive iteration of &lt;code&gt;loop()&lt;/code&gt;, it will call the next function, and then wrap round to the first. In between each of those functions, it can poll the button. Here's a simple example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int g_section = 0;&#xA;&#xA;void setup() { }&#xA;&#xA;void pollButton()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void runSection0()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void runSection1()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void runSection2()&#xA;{&#xA;    //...&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Poll the button on every pass:&#xA;    pollButton();&#xA;&#xA;    // Execute the next section of the main code:&#xA;    switch (g_section)&#xA;    {&#xA;    case 0: runSection0(); break;&#xA;    case 1: runSection1(); break;&#xA;    case 2: runSection2(); break;&#xA;    }&#xA;&#xA;    // On the next iteration, run the next section:&#xA;    if (++g_section &amp;gt; 2) g_section = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One important issue with this approach is that it's very difficult to make each of those &lt;code&gt;runSectionX()&lt;/code&gt; functions take the same execution time. That can result in the button being polled inconsistently from one iteration to the next. If it's fast enough though, then it shouldn't be too big of a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Display update&lt;/strong&gt;&lt;br&gt;&#xA;Updating a display is unfortunately often quite slow, compared to many other operations. That means you need to be quite careful where you do it. Inside an Interrupt Service Routine often wouldn't be appropriate, as that could introduce other timing issues in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Realistically, you'd have to do it in the main loop. If you absolutely have to run it quickly though, then it can be included in the faster polling example I've given above -- i.e. update the display on every iteration, the same as polling. You have to be careful to avoid partial updates though.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-03-01T11:50:10.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="538" PostTypeId="2" ParentId="518" CreationDate="2014-03-01T13:55:11.313" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems like &lt;code&gt;c_str()&lt;/code&gt; should be the preferred approach. Is there some reason why &lt;code&gt;toCharArray()&lt;/code&gt; is more commonly used?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;basically, I'd say it's a lack of knowledge from the people doing the codes you've seen. Definitely &lt;code&gt;c_str()&lt;/code&gt; is better. Though, what I see even more often is the use of character arrays &lt;code&gt;char*&lt;/code&gt; strings instead of &lt;code&gt;String&lt;/code&gt; (and I plead guilty of that as well in my own codes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's because the Arduino library has been built upon a messy set of C and C++ libraries and coding style. Trying to make things easier actually messed them up and complicated them more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's actually why we have new projects like &lt;a href=&quot;http://xpcc.kreatives-chaos.com&quot; rel=&quot;nofollow&quot;&gt;xpcc&lt;/a&gt; trying to make a real and smart use of the C++ abilities in the embedded world.&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-01T13:55:11.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="539" PostTypeId="1" AcceptedAnswerId="540" CreationDate="2014-03-01T15:13:27.810" Score="5" ViewCount="3365" Body="&lt;p&gt;I have 2 Lowpowerlab WaterMote's talking to each other using the 'out of the box' pre-installed &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Sketch&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; that just confirm they're talking to each other. I verified this by opening a COM connection and saw traffic of 'receiving packets...' That was just to show that they are functioning and talking to each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, using Arduino IDE on Mac&amp;nbsp;OS&amp;nbsp;X 1.9.x (Lion?) I have loaded the WaterMote sketch (found on &lt;a href=&quot;http://en.wikipedia.org/wiki/GitHub&quot; rel=&quot;nofollow&quot;&gt;Github&lt;/a&gt;) on the Moteino with the sensor (not the gateway) as it should be. The traffic looks like it's working, except the text being transmitted (number of Gallons) stays the same at 0.02 Gallons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... I want to debug the WaterMote sketch, &lt;em&gt;but&lt;/em&gt; I do not see an option in my Arduino IDE on Mac&amp;nbsp;OS&amp;nbsp;X. Is there a way to debug sketches using Macs? Searching online shows various and preferred options, but mostly on Windows (of which I don't have any at home).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current setup&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Moteino Gateway (as out of the box) connected to a &lt;a href=&quot;http://en.wikipedia.org/wiki/Raspberry_Pi&quot; rel=&quot;nofollow&quot;&gt;Raspberry Pi&lt;/a&gt; (with ssh enabled)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connected via USB to the RasPi&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Moteino with WaterMote sketch loaded&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connected via USB to the MacBook Pro&lt;/li&gt;&#xA;&lt;li&gt;Arduino IDE running, but I see strange &quot;[][][]&quot; square output in the Serial connection.&lt;/li&gt;&#xA;&lt;li&gt;I do not know what to make of this since that text is not in the WaterMote sketch.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is there a way to debug sketches loaded on Arduino clones using Arduino IDE on Macs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a debugging article:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Debugging-Breakpoints-Tracepoints-and-E/&quot; rel=&quot;nofollow&quot;&gt;Visual Micro&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="381" LastEditorUserId="510" LastEditDate="2014-03-16T09:14:55.600" LastActivityDate="2014-03-23T16:12:32.387" Title="How to debug an Arduino sketch on a Mac?" Tags="|ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="540" PostTypeId="2" ParentId="539" CreationDate="2014-03-01T15:48:15.247" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So... I want to debug the WaterMote sketch, but I do not see an option in my Arduino IDE on Mac OS X. Is there a way to debug sketches using Macs? Searching online shows various and preferred options, but mostly on Windows (of which I don't have any at home).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's definitely possible to debug a sketch with OS&amp;nbsp;X. But it's definitely an advanced AVR topic, and if you're not experienced enough with embedded programming you should first try to avoid it, except if it is really necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debugging a sketch for an &lt;a href=&quot;http://www.atmel.com/devices/atmega328.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega328&lt;/a&gt; implies:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Running a flasher such as the AVR Dragon, the JTAG ICE 3, the STK500 or the AVR ONE; no cheap flasher implements the &lt;code&gt;DebugWire&lt;/code&gt; protocol;&lt;/li&gt;&#xA;&lt;li&gt;Setting up the debug fuse, which is an operation that can brick your &lt;a href=&quot;http://en.wikipedia.org/wiki/Microcontroller&quot; rel=&quot;nofollow&quot;&gt;MCU&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you're using an &lt;a href=&quot;http://www.atmel.com/devices/atmega32u4.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega32U4&lt;/a&gt; (or alike), you won't be able to do it out of the box, as the 32U4 needs a &lt;a href=&quot;http://en.wikipedia.org/wiki/Joint_Test_Action_Group&quot; rel=&quot;nofollow&quot;&gt;JTAG&lt;/a&gt; connection for on-chip debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, once you got through that, you can bind a &lt;code&gt;gdb&lt;/code&gt; to the AVR using &lt;a href=&quot;http://avarice.sf.net&quot; rel=&quot;nofollow&quot;&gt;AVaRICE&lt;/a&gt;. I'm not getting you through all that, because I really, really, strongly advise you not to do it until you're experienced enough to know what you're doing.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Moteino with WaterMote sketch loaded&#xA;         connected via USB to the MacBook Pro&#xA;         Arduino IDE running, but I see strange &quot;[][][]&quot; square output in the Serial connection.&#xA;         I do not know what to make of this since that text is not in the WaterMote sketch.&#xA;  Is there a way to debug sketches loaded on Arduino clones using Arduino IDE on Macs?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is very likely you did not setup the correct baudrate for the serial outputs. Arduino IDE defaults to 9600&amp;nbsp;bits/s connections, whereas the &lt;a href=&quot;https://github.com/LowPowerLab/WaterMote/blob/master/WaterMote.ino#L31&quot; rel=&quot;nofollow&quot;&gt;WaterMote source code&lt;/a&gt; defines a 115,200&amp;nbsp;bits/s connection. When you open the &lt;code&gt;Serial Monitor&lt;/code&gt; change the setting at the right of the status bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, be sure to uncomment the &lt;a href=&quot;https://github.com/LowPowerLab/WaterMote/blob/master/WaterMote.ino#L30&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;#define SERIAL_EN&lt;/code&gt; line&lt;/a&gt; to enable the serial communication and debug outputs.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="510" LastEditDate="2014-03-23T16:12:32.387" LastActivityDate="2014-03-23T16:12:32.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="541" PostTypeId="2" ParentId="484" CreationDate="2014-03-01T16:15:11.903" Score="16" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Is it possible to build a HID device (like a keyboard) using an Arduino uno?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;yes it is! And there's a great tutorial on how to do that over &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;At the time being, I have button inputs on the Arduino giving outputs on the&#xA;serial line. So, how can I transform my current firmware into something that&#xA;can behave like a HID keyboard?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As the tutorial shows you, you need to transform your firmware code so instead of&#xA;printing the events, you actually trigger events. What you need to do, is add to your&#xA;code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void triggerKey(uint8_t mod, uint8_t chr) {&#xA;    uint8_t buf[8] = {mod, chr, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};&#xA;    // press key&#xA;    Serial.write(buf, 8);&#xA;    // emulate key press delay&#xA;    delay(10);&#xA;    buf[1] = 0x00;&#xA;    // release key&#xA;    Serial.write(buf, 8);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;What you're doing here, is send from your main Arduino microcontroller events over&#xA;the serial line to the smaller microcontroller that handles USB communication. That&#xA;microcontroller will take those key &amp;quot;buffers&amp;quot; and transfer them as USB HID Keyboard&#xA;key presses over USB.&lt;/p&gt;&#xA;&lt;p&gt;Beware that the key character (&lt;code&gt;chr&lt;/code&gt; in the code here), is actually a keycode sent&#xA;over USB that gets interpreted by your USB HID driver, which then translates it into&#xA;a real character using the current layout you've setup for your keyboard.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;mod&lt;/code&gt; character is one of the modifier keys you have on the keyboard (&lt;kbd&gt;shift&lt;/kbd&gt;,&#xA;&lt;kbd&gt;control&lt;/kbd&gt;, &lt;kbd&gt;alt&lt;/kbd&gt;...), &lt;code&gt;0x00&lt;/code&gt; being no modifier.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shall I write a new window device driver?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;No, you don't need! With the DFU upgrade, your arduino will be seen as a USB keyboard&#xA;by windows.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shall I create a software layer that could take my serial data and have windows read it as HID input?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You neither need to do that, and it's actually a very bad idea for many reasons:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;your solution would not be portable, and thus you'd need to hack something for every platform you may use,&lt;/li&gt;&#xA;&lt;li&gt;your solution would imply a lot of new code ; the more code one write, the more bugs is likely to be in your system,&lt;/li&gt;&#xA;&lt;li&gt;your solution would be really hackish, as it would behave as a device driver (i.e. &lt;em&gt;kernel land&lt;/em&gt;) taking input from&#xA;a user program (i.e. &lt;em&gt;user land&lt;/em&gt;) and is likely to not work, be a hell to debug, and prone for security issues...&#xA;If that's even possible to do!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I'm using an Uno, but I'll look at what you posted because last time we considered the DFU update but we're kinda scared of bricking stuff&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Finally you're having concerns, in a comment, about bricking your arduino. Please&#xA;believe me and the author of the &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt; that you &lt;strong&gt;cannot&lt;/strong&gt; brick your arduino&#xA;doing a firmware flash:&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;NOTE: There is no chance of ‘bricking’ the device using this method. The Arduino bootloader firmware can always be updated using the DFU protocol!&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In case something gets really badly wrong, and you get a bootloader corruption in the&#xA;little AVR (atmega8u2), you still can reflash it &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;using another arduino&lt;/a&gt; or an&#xA;&lt;a href=&quot;http://www.atmel.com/tools/avrispmkii.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;atmel programmer&lt;/a&gt; using the 6 pins next to the USB plug.&lt;/p&gt;&#xA;&lt;p&gt;In the end, know that the &lt;strong&gt;only&lt;/strong&gt; way to brick an AVR, thus an Arduino as well, is&#xA;to play with the fuses and reset the programming fuses. And even then, you may use&#xA;&lt;a href=&quot;http://microtherion.github.io/ScratchMonkey/HVSP.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;HVSP&lt;/a&gt; to save your device, though it's often less trouble to just take a new chip.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="27346" LastEditDate="2021-06-20T13:39:27.700" LastActivityDate="2021-06-20T13:39:27.700" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="542" PostTypeId="2" ParentId="501" CreationDate="2014-03-01T20:46:42.273" Score="1" Body="&lt;p&gt;Id go with an ultrasonic detector as Cybergibbons suggests together with a usage/flow monitor (&lt;a href=&quot;http://www.ebay.com/bhp/water-flow-sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/bhp/water-flow-sensor&lt;/a&gt;) so as to understand if there are any losses through leaks etc. I'd use a YUN or Ethernet or shield to call or email you a monthly report / fill a datbase as well as place the order directly to the water supplier as well as cc'ing you.&lt;/p&gt;&#xA;" OwnerUserId="310" LastActivityDate="2014-03-01T20:46:42.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="543" PostTypeId="2" ParentId="439" CreationDate="2014-03-01T22:24:12.817" Score="13" Body="&lt;p&gt;The truth is always in the datasheets, the schematics and the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino UNO actually uses the &lt;code&gt;/DTR&lt;/code&gt; line to trigger a reset, as you can see on the following datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zWoHK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zWoHK.png&quot; alt=&quot;reset schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="379" LastEditDate="2017-06-25T12:18:19.810" LastActivityDate="2017-06-25T12:18:19.810" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="544" PostTypeId="5" CreationDate="2014-03-02T00:35:52.860" Score="0" Body="&lt;p&gt;There are several different official Arduino boards. In some cases, the board design has been revised, and a new specification/product has been released. They are distinguished by revision number, such as the Uno R2 and the Uno R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag can be used for questions about changes between revisions, or the process of revising official board design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag should &lt;em&gt;not&lt;/em&gt; be used for questions which relate to one particular revision of a board. Use the relevant revision-specific tag instead, such as &lt;a href=&quot;/questions/tagged/arduino-uno-r3&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;arduino-uno-r3&amp;#39;&quot; rel=&quot;tag&quot;&gt;arduino-uno-r3&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-02T00:35:52.860" LastActivityDate="2014-03-02T00:35:52.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="545" PostTypeId="4" CreationDate="2014-03-02T00:35:52.860" Score="0" Body="Revisions are different versions of a given Arduino board, such as the Uno R2 and Uno R3." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-02T00:35:52.860" LastActivityDate="2014-03-02T00:35:52.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="546" PostTypeId="2" ParentId="460" CreationDate="2014-03-02T02:38:25.427" Score="9" Body="&lt;p&gt;If safety is a major concern, then you should almost always load a stop* sketch onto the board before calling it a day. This would be a good idea, for example, when your board is semi-permanently a part of a larger system. You could do so by: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Upload the Bare Minimum sketch found in &lt;kbd&gt;File&lt;/kbd&gt; -&gt;  &lt;kbd&gt;Examples&lt;/kbd&gt; -&gt; &lt;kbd&gt;Basic&lt;/kbd&gt; in the &lt;a href=&quot;/questions/tagged/arduino-ide&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;arduino-ide&amp;#39;&quot; rel=&quot;tag&quot;&gt;arduino-ide&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Upload a sketch with a large delay in loop.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;limits.h&amp;gt;&#xA;&#xA;void setup()&#xA;{}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(ULONG_MAX);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Upload a sketch with a &lt;a href=&quot;https://arduino.stackexchange.com/q/188/65&quot;&gt;call to &lt;code&gt;exit()&lt;/code&gt; from &lt;code&gt;setup()&lt;/code&gt;&lt;/a&gt; (&lt;em&gt;Thanks @Peter!&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;   exit(0);&#xA;}&#xA;&#xA;void loop()&#xA;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*Stop is simply figurative. The board doesnt really stop running.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-03-02T15:57:15.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="548" PostTypeId="1" AcceptedAnswerId="549" CreationDate="2014-03-02T03:13:06.193" Score="1" ViewCount="162" Body="&lt;p&gt;I have been through &lt;a href=&quot;http://arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt; but I can't do it. Whenever I create a new sketch and try to save it as &lt;code&gt;.cpp&lt;/code&gt; or &lt;code&gt;.h&lt;/code&gt; from the &lt;kbd&gt;Save As&lt;/kbd&gt; button in the Arduino IDE, it gets saved as &lt;code&gt;_cpp&lt;/code&gt; and &lt;code&gt;_h&lt;/code&gt;. I am not able to create a library this way. How do I create a new library? What am I missing here?&lt;/p&gt;&#xA;" OwnerUserId="390" LastEditorUserId="65" LastEditDate="2014-03-02T13:57:29.260" LastActivityDate="2014-03-02T13:57:29.260" Title="Why are the files not being created correctly?" Tags="|library|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="549" PostTypeId="2" ParentId="548" CreationDate="2014-03-02T04:20:02.597" Score="1" Body="&lt;p&gt;When you save a file using the &lt;kbd&gt;Save As&lt;/kbd&gt; button from the Arduino IDE, it saves the current file as a sketch i.e. as an &lt;code&gt;.ino&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create a &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files for working on a new library, you need to create the files alongside a sketch. For this, you can use the &lt;kbd&gt;Tab&lt;/kbd&gt; button on the top right (circled in red).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lya7P.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Click on it, and select &lt;kbd&gt;New Tab&lt;/kbd&gt;. You will get a bar at the bottom of the screen asking for a file name. Enter the name with extension (&lt;code&gt;test.cpp&lt;/code&gt;) and press &lt;kbd&gt;Enter&lt;/kbd&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5cIWe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your file has now been added to the current directory.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Cp0V.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Similarly, follow the same steps for creating the &lt;code&gt;.h&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once your library is complete and ready to ship, you can move the &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files to a separate directory and then add it under libraries.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-02T04:20:02.597" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="551" PostTypeId="5" CreationDate="2014-03-02T11:52:16.930" Score="0" Body="&lt;p&gt;The &lt;strong&gt;bootloader&lt;/strong&gt; is a small piece of code loaded into the high part of program memory (flash memory). It is optionally invoked by the processor after a reset (depending on &lt;code&gt;BOOTRST&lt;/code&gt; fuse setting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its purpose is to allow self-programming of the flash, generally by checking the serial port for specific &quot;programming&quot; sequences within the first second or so after a reset. If such a sequence is found the bootloader responds to the programmer (usually &lt;code&gt;avrdude&lt;/code&gt; running on the host computer), and in conjunction with the programmer accepts and acts upon instructions to erase and reprogram memory, change the EEPROM if desired, and change the fuses if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of the bootloader avoids the need for special hardware to upload new code. However to change the bootloader itself (something not normally necessary) a special programmer is needed which plugs into the ICSP (In Circuit Serial Programming) header of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Once the bootloader has finished uploading new code (if required) it jumps to address 0x0000 which is the start of the actual code, so that the newly-uploaded sketch can now start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no programming instructions are detected by the bootloader after a short delay, it jumps to address 0x0000 to execute the previously-loaded code.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-27T22:30:04.380" LastActivityDate="2015-08-27T22:30:04.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="552" PostTypeId="4" CreationDate="2014-03-02T11:52:16.930" Score="0" Body="Refers to the code burned on the Arduino flash memory that runs every time the board is powered up. It starts the execution of user-loaded programs and allows uploading sketches from a PC through the USB connection. This tag should be used for questions about modifying, changing, uploading the default bootloader." OwnerUserId="65" LastEditorUserId="84" LastEditDate="2014-05-03T09:19:09.813" LastActivityDate="2014-05-03T09:19:09.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="553" PostTypeId="5" CreationDate="2014-03-02T11:53:49.047" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-02T11:53:49.047" LastActivityDate="2014-03-02T11:53:49.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="554" PostTypeId="4" CreationDate="2014-03-02T11:53:49.047" Score="0" Body="Refers to the sum total of software, circuit diagrams, documentation, libraries, and hardware that make up an Arduino based application." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-02T14:07:29.140" LastActivityDate="2014-03-02T14:07:29.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="555" PostTypeId="5" CreationDate="2014-03-02T11:56:17.977" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-02T11:56:17.977" LastActivityDate="2014-03-02T11:56:17.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="556" PostTypeId="4" CreationDate="2014-03-02T11:56:17.977" Score="0" Body="Flash memory is a type of memory available on the Arduino boards. It can be accessed from a program using PROGMEM directive to store data. For questions about using and accessing flash memory, use this tag." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-02T14:10:02.670" LastActivityDate="2014-03-02T14:10:02.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="557" PostTypeId="5" CreationDate="2014-03-02T11:57:28.750" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-02T11:57:28.750" LastActivityDate="2014-03-02T11:57:28.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="558" PostTypeId="4" CreationDate="2014-03-02T11:57:28.750" Score="0" Body="Use this tag for questions about connecting, controlling, and safely operating motors using an Arduino board." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-02T14:08:52.220" LastActivityDate="2014-03-02T14:08:52.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="559" PostTypeId="5" CreationDate="2014-03-02T11:59:13.443" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-02T11:59:13.443" LastActivityDate="2014-03-02T11:59:13.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="560" PostTypeId="4" CreationDate="2014-03-02T11:59:13.443" Score="0" Body="Version control refers to the management of changes made over time to a code base. Use this tag for questions about managing software and libraries." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-02T14:08:39.703" LastActivityDate="2014-03-02T14:08:39.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="561" PostTypeId="2" ParentId="26" CreationDate="2014-03-02T13:05:58.760" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is making the upload process pause?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, given all the comments made under your question, this is definitely a tricky one. You might want to try to add a decoupling capacitor as suggested by @jfpoilpret, though your schematics look alright to me… (maybe ask a review of it on &lt;a href=&quot;http://electronics.stackexchange.com&quot;&gt;EE SE&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also advice you to copy the &lt;code&gt;avrdude&lt;/code&gt; command from Arduino IDE output (you'll find it at the top), and run it in the command shell with lower bitrate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -v -v -v -v -C &quot;C:\arduino-1.0.3\hardware/tools/avr/etc/avrdude.conf&quot; -P COM1 -patmega328 -U… -B3 -b115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the higher the &lt;code&gt;-B&lt;/code&gt; value is the lower your bitrate is. and &lt;code&gt;-b&lt;/code&gt; to the correct baudrate for your bootloader (are you &lt;em&gt;sure&lt;/em&gt; this is 115200? it's more common to see 57600).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you also set fuses correctly? You might as well want to check the values of the fuses to see if the clocks are correctly set up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -U lfuse:r:-:i -U hfuse:r:-:i -U efuse:r:-:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will output the values of the fuses. Then to make the values readable, put the values at the bottom of the form on the &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;fuse calculator site&lt;/a&gt;, after choosing the &lt;code&gt;Atmega328P&lt;/code&gt; MCU from the dropdown list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Double check that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have enough size for the bootloader (usually the more you give it the better it is) ;&lt;/li&gt;&#xA;&lt;li&gt;you have correctly set up the cristals configuration for your design (which may not be compatible with default Uno settings as setup by the Arduino IDE), checking if you correctly set up the external crystal at 16MHz…&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why is the buzzer beeping when the process pauses?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's because when the processor does not have the output set up, the values within the registers are in an undefined and unpredictable state. Which means that usually it keeps the last value it had before a reset, or changed state because of some electrostatic weirdness, or is giving some weird PWM output because of the influence of a clock nearby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, there's something wrong happening when you're uploading your code and that wrong thing has an indirect effect on the audio. I wouldn't worry much about that stuff, but more about the cause of the pausing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly, I don't have a direct answer for you, but at best a few paths you should investigate more. HTH&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-02T13:05:58.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="562" PostTypeId="1" CreationDate="2014-03-02T13:26:25.627" Score="3" ViewCount="2880" Body="&lt;p&gt;The Arduino IDE by default is oriented towards C++. The linker for example requires &lt;code&gt;.cpp&lt;/code&gt; files and not &lt;code&gt;.c&lt;/code&gt; files, otherwise it leads to errors during the linking process. See &lt;a href=&quot;http://en.wikipedia.org/wiki/Name_mangling&quot; rel=&quot;nofollow&quot;&gt;name mangling&lt;/a&gt; if you want to know more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what are the tools that I need to setup a C environment? Can this be done from the Arduino IDE itself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work on a Linux system (Ubuntu 12.04).&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-02T15:00:23.053" LastActivityDate="2015-06-29T11:51:02.323" Title="What are the tools that I need to program the Arduino in C?" Tags="|programming|c|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="563" PostTypeId="1" CreationDate="2014-03-02T16:27:27.340" Score="1" ViewCount="228" Body="&lt;p&gt;I am working on a UAV and we are currently exploring inertial measurement units or IMUs. The two options that we have come across are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using an Arduino Uno and a 9 DOF IMU like &lt;a href=&quot;https://www.sparkfun.com/products/10724&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using an ArduIMU chip like &lt;a href=&quot;https://www.sparkfun.com/products/11055&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ignoring the cost aspect and assuming the same microprocessor on board, what would be the pros and cons of either of these approaches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that performance is very important for a UAV controller as ESCs require 60 Hz or higher refresh rates for stable flight.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-03T13:43:59.567" LastActivityDate="2014-03-03T15:42:39.937" Title="Arduino + IMU vs ArduIMU" Tags="|arduino-uno|sensors|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="564" PostTypeId="1" CreationDate="2014-03-02T20:18:51.180" Score="48" ViewCount="14236" Body="&lt;p&gt;Anyone with kids knows they never help with the toilet paper. Anyone know how to track when it's low or out and sound an audible alarm? I just don't know what sensor to use that may help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some that came to mind are: by weight, by reflection (the color of the paper) or some laser tripwire - all right on the spool. I don't mind building it, it's just I don't know which sensor. Anyone know which to use?&lt;/p&gt;&#xA;" OwnerUserId="381" LastEditorUserId="65" LastEditDate="2014-03-03T15:15:13.953" LastActivityDate="2016-06-27T20:24:47.090" Title="How to trigger an alarm when toilet paper is low?" Tags="|sensors|system-design|" AnswerCount="17" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="565" PostTypeId="2" ParentId="564" CreationDate="2014-03-02T20:40:39.523" Score="2" Body="&lt;p&gt;One idea that comes to mind would be something like that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;stick a small magnet inside the paper roll, i.e. inside the cardboard part (this has to be done every time you change it; though)&lt;/li&gt;&#xA;&lt;li&gt;use a reed contact (electro-magnetic switch) at the tip of a stick mounted with a spring to be always in contact with the paper roll&lt;/li&gt;&#xA;&lt;li&gt;one pin of the reed contact can be directly connected to an input logical pin (set it up as a pullup resistor input)&lt;/li&gt;&#xA;&lt;li&gt;the other pin of the reed contact is to be connected to the ground&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus, as soon as the distance between the magnet and the reed contact is under some limit, the switch will close the circuit. That distance will decrease while the paper roll gets drawn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, instead of a reed contact, you may also use a Hall Effect sensor, the principles remain the same, only technology and characteristics change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty here will be to find the right sensitivity of the reed contact (or the force of the magnet) so that the reed contact gets closed when the distance between it and the magnet is small enough to avoid an alarm that would be activated too soon).&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-02T21:17:19.300" LastActivityDate="2014-03-02T21:17:19.300" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="566" PostTypeId="2" ParentId="564" CreationDate="2014-03-02T20:43:43.507" Score="1" Body="&lt;h2&gt;You have a few options:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Note: The links given are just the first ones that come up. Most of them are pricey compared to other sites. eBay buy it nows can be fairly cheap for most of these items. Check other places, too, including &lt;a href=&quot;http://www.sparkfun.com&quot; rel=&quot;nofollow&quot;&gt;Sparkfun&lt;/a&gt;.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.robotmesh.com/parallax-ping-ultrasound-sensor?gclid=CJvLqNvY9LwCFewRMwod0SQAzw&quot; rel=&quot;nofollow&quot;&gt;Ultrasonic Ping Sensor&lt;/a&gt;. This isn't ideal by any means, but they're easy to use. Just add one with an enclosure. It isn't ideal because it won't be accurate enough to tell when exactly it's empty. It might be a little over/under sensitive. Weight would be harder, though if it shifts at all.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10904&quot; rel=&quot;nofollow&quot;&gt;Color sensor  (preferable, but costs more)&lt;/a&gt;. You mentioned this and this is probably the best idea. It'll give you analogue values (to read with Arduino) for red, green, and blue. [Assuming that the higher the content of that color, the higher the voltage,] white should be pretty much all of those at 100% and brown I would image that most of them would be about 30-40%. (More later, if you don't understand this, skip this part)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I'm going to go into more detail on the color sensor:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colors are read with three values here: red, green, and blue. There are three sensors on the board. One filters out everything except red, another blue, and the other green. The sensors on the board detect the amount of incoming light and then convert that to a voltage: between 5V (&quot;100% red/green/blue&quot;) or 0V (&quot;0% red/green/blue&quot;). This then can be converted into a number by the Arduino (0-1024 on an analogue pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A problem with lighting:&lt;/strong&gt;&#xA;This sensor, from what I can tell, has a LED that's always on. You'll want to either desolder that or cover it up, unless you want an illuminated toilet paper holder. Now wait... your sensor will think that when it's dark, it's brown. No problem... here's something for you mind to think about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.w3schools.com/tags/ref_colorpicker.asp&quot; rel=&quot;nofollow&quot;&gt;Use a color picker like I'm using and select a brown&lt;/a&gt;. On the left of this one, you can control the &quot;simulated brightness.&quot; Besides that is the hexadecimal form of RGB. You'll want to convert that to standard &lt;a href=&quot;http://www.javascripter.net/faq/hextorgb.htm&quot; rel=&quot;nofollow&quot;&gt;values with this calcuator&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In brown, the color blue is almost nonexistent. We should ignore that color, unless you want a way to double check that it's brown. I'd say it should always be under 40% for pretty much any shade of brown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I can tell with a sample shade of brown, the red is pretty much 2x the green. That ratio may vary, but you should verify that it is &lt;em&gt;somewhat&lt;/em&gt; existent. For white/grey/black, all the colors are proportional 1:1:1. You can use this to detect if it's dark, or if it's brown.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rPin = A0;      //Red Pin&#xA;int gPin = A1;      //Green Pin&#xA;int bPin = A2;      //Blue Pin&#xA;int ledPin = 13;    //I made this code with a LED, not a speaker&#xA;boolean testTwice = false;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;  int rValue = analogRead(rPin);&#xA;  int gValue = analogRead(gPin);&#xA;  int bValue = analogRead(bPin);&#xA;&#xA;  if (bPin &amp;lt; 256) { //If this is false, either something is in the way or it's white. Going to verify that something's not in the way...&#xA;    int minRed = rPin * 0.4; //A little under a half for padding... this values may need to be adjusted. Adjust this one and the one below farther apart for less sensitive.&#xA;    int maxRed = rPin * 0.6; //A little over a half for padding... this values may need to be adjusted.&#xA;    if (gPin &amp;lt; maxRed &amp;amp;&amp;amp; gPin &amp;gt; minRed) { //Verifys that red between minRed and maxRed&#xA;      digitalWrite(ledPin, HIGH);&#xA;      delay(5000);&#xA;      digitalWrite(ledPin, LOW);&#xA;    }&#xA;  }&#xA;  delay(5000); // No need to waste power... you might want to add an actutal sleep function if on battery power&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, it verifies that the blue is less than 25%. Then, it verifies that the red and green are equal... give or take 20%. (i.e. red = 100 green = 80, red = 110 green = 90, etc.). If that is true, you can pretty much establish that it's brown. Then, a LED turn on for five seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can modify the LED to be a buzzer if you want. You might have to adjust the if statement with verifying that the blue is less than 256/1024 (1024 = resolution of analog pin) if it isn't working in a lot of light or is working in dark light. Since the code later verifies that the red is about 2x the green, any shade of white shouldn't pass that if statement. You may also have to adjust the &lt;code&gt;minRed&lt;/code&gt; and &lt;code&gt;maxRed&lt;/code&gt; to be farther (if not detecting brown) or closer (if detecting brown when it's white). I can't really test this code with no color sensor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: these can be a little fidgety. &lt;strong&gt;I would recommend a LED instead&lt;/strong&gt; so the whole house isn't woken up in the middle of the night just because of low toilet paper. Also, if you obstruct the sensor at all... If it wasn't in the bathroom, I would recommend a camera and have it take a shot every time it gets very low with a reed switch like @jfpolipret's answer... but... (no pun intended) :)&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-02T21:54:27.677" LastActivityDate="2014-03-02T21:54:27.677" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="567" PostTypeId="2" ParentId="564" CreationDate="2014-03-02T20:49:38.497" Score="2" Body="&lt;p&gt;An short-range ultrasound distance sensor might be an effective (and fairly cheap) option. You can get an emitter+sensor combination mounted on a chip. Different sensors may work in different ways (always check the datasheet). A common output though uses the length of a pulse to indicate the distance sensed. You could process that in Arduino using the &lt;a href=&quot;http://arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pulseIn()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of installation, you'd probably fit it directly behind the toilet paper, pointing at the centre of the spool. The readings are often quite erratic, so you want to take several measurements and average them (or use a simple moving average). With a bit of calibration, you could determine what distance represents an empty spool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you detect that distance repeatedly for a significant period (e.g. a minute or more), you'd sound the alarm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A reflectance-based sensor might be another possibility, although I wonder if you might struggle to find one which will work properly on toilet paper (depending on how soft your preferred brand is!).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-02T20:49:38.497" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="568" PostTypeId="2" ParentId="564" CreationDate="2014-03-02T21:11:46.487" Score="47" Body="&lt;p&gt;Bring up several rolls at a time and hang one for use. Put the other two on a short vertical pole within reach of the sitter. Sitter can take another roll when needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mechanically sense lack of weight on the shelf at the bottom of the pole. Alarm triggers when the last roll is removed. No one has to get caught short.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sense the weight use a force sensitive resistor such as the &lt;a href=&quot;https://www.sparkfun.com/products/9673&quot;&gt;FSR 400&lt;/a&gt; (see &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ForceFlex/2010-10-26-DataSheet-FSR400-Layout2.pdf&quot;&gt;datasheet&lt;/a&gt;). Alternatively, you could use a lightweight coil spring to rest the toilet paper on with a micro switch that is released when both rolls are removed. Another option would be an IR beam break detector where the circuit is completed when the last roll is removed.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="225" LastEditDate="2014-03-03T18:39:09.873" LastActivityDate="2014-03-03T18:39:09.873" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="569" PostTypeId="2" ParentId="533" CreationDate="2014-03-02T22:11:52.803" Score="2" Body="&lt;p&gt;Both variables are static - they persist for the entire execution session. The global is visible to any function if it declares - not defines - the global, or if the function follows the definition in the same compilation unit (file + includes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving the definition of &lt;code&gt;count&lt;/code&gt; to inside of a function both limits its scope of visibility to the nearest enclosing set of &lt;code&gt;{}&lt;/code&gt;es, and gives it function invocation lifetime (it is created and destroyed as the function is entered and exited). Declaring it &lt;code&gt;static&lt;/code&gt; as well gives it execution session lifetime it exists from the start to the end of the execution session, persisting across function invocations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: be cautious about using initialized statics within a function, as I have seen some versions of the gnu compiler get this wrong. An automatic variable with an initializer should be created and initialized on every function entry. A static with an initializer should only be initialized once, during the execution setup, before main() is given control (just as a global would be). I have had local statics get reinitialized on each function entry as though they were automatics, which is incorrect. Test your own compiler to be sure.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-03-02T22:16:53.880" LastActivityDate="2014-03-02T22:16:53.880" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="570" PostTypeId="2" ParentId="564" CreationDate="2014-03-02T22:16:08.053" Score="2" Body="&lt;p&gt;Sounds like a cool project, here are my 2 ct:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point a camera to take photos of the roll from sideways, that is probably the only way to really find out how much paper is left. (edit: You could use a raspberry pi with the csi camera and create an output signal corresponding to the number of sheets and feed that signal to the arduino?!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an estimate it might also be enough to count rotations of the roll, but you need to fiix the roll better so it doesn't slip. Or you can use magnets like you do on bicycles, but they need to be attached to the roll directly then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(edit: one more idea, mesure the thickness of the roll by measuring the angle of the lid)&lt;/p&gt;&#xA;" OwnerUserId="397" LastEditorUserId="397" LastEditDate="2014-03-02T23:00:40.160" LastActivityDate="2014-03-02T23:00:40.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="571" PostTypeId="2" ParentId="203" CreationDate="2014-03-02T22:57:16.733" Score="1" Body="&lt;p&gt;If you can tolerate the data volume, debugging communicatons is &lt;strong&gt;so&lt;/strong&gt; much easier when sending strings than when sending binary; sprintf()/sscanf() and their variants are your friends here. Enclose the communication in dedicated functions in their own module (.cpp file); if you need to optimize the channel later - &lt;strong&gt;after&lt;/strong&gt; you have a working system - you can replace the string-based module with one coded for smaller messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll make your life lots easier if you hold tight to protocol specs on transmission and interpret them more loosely on reception, regard to field widths, delimiters, line endings, insignificant zeros, presence of &lt;code&gt;+&lt;/code&gt; signs, etc. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-03-02T22:57:16.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="572" PostTypeId="2" ParentId="532" CreationDate="2014-03-02T23:19:02.123" Score="1" Body="&lt;p&gt;You could interrupt instead of polling if you can de-bounce the buttons in hardware. Otherwise you'll be take many more interrupts than there were button presses and still have to de-bounce them in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to the primary question, a collection of state machines can be very useful, at least for the ui, and give you most of the benefits of multi-tasking without needed a m/t kernel.  can be  in RAM limited devices, unfortunately, because &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The technique could be especially useful on these small devices but for the severe limits on RAM, making it something of a challenge to divide your state-machine data between flash and RAM, to fit.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-03-02T23:19:02.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="573" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T02:45:31.253" Score="9" Body="&lt;p&gt;Use a radiation detector to detect the amount of paper left on the roll. Place some amount of radioactive material in the middle of the spool rod, and place the radiation detector somewhere else (you could mount it on the other side of the surface the roll holder is mounted to, if you want; radiation sensors are extremely flexible), and measure the radiation amounts to determine how much paper is left on the roll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, you could have an electronically controlled toilet paper dispenser (push button to dispense a preprogrammed length of toilet paper) and have the arduino just keep track of how much has been dispensed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, attach a rotary encoder to the side of the spool rod (make sure it fits without slipping inside the roll), and count the rotations of the roll to determine how much has been used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, with any of these methods, you will have to do tests and collect data  depending on the exact type/brand/material/etc of toilet paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Especially for the second and third ideas, I would recommend taking data from the system regularly, to keep track of the typical length of a roll so you can adjust the program for any significant variation. Even within one type of toilet paper, I would imagine that there would be some variation in roll length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For even more fun, you could instrument the detector to collect time series data, so later you can upload it to a computer and make a &quot;toilet paper usage over time&quot; graph or something.&lt;/p&gt;&#xA;" OwnerUserId="401" LastEditorUserId="401" LastEditDate="2014-03-05T17:00:52.267" LastActivityDate="2014-03-05T17:00:52.267" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="574" PostTypeId="1" AcceptedAnswerId="575" CreationDate="2014-03-03T05:07:38.563" Score="18" ViewCount="5868" Body="&lt;p&gt;I am using the A0 port on my Arduino Uno to read the voltage output from an LM35 temperature sensor.  I observed that the reading fluctuates a lot if I leave the remaining analog input ports A1 to A5 floating. Would floating analog inputs affect the accuracy of readings on input ports connected to some signals.&lt;/p&gt;&#xA;" OwnerUserId="405" LastActivityDate="2017-01-29T12:00:30.407" Title="Should all unused analog input ports be tied to ground for accurate A2D measurements?" Tags="|arduino-uno|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="575" PostTypeId="2" ParentId="574" CreationDate="2014-03-03T05:37:08.900" Score="13" Body="&lt;p&gt;Any floating pin will act as an antenna, and may interfere with values around it, this is one of the major disadvantages of using analog.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the most accurate readings with minimal amount of interference, you can pull all unused inputs to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accuracy will not change, as the accuracy is determined by the sensor itself. However it will reduce the amount of noise / interference, which will give you more accurate readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These pull to grounds can be accomplished by configuring the unused analog pins as digital outputs, and setting them low.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(A1, OUTPUT);&#xA;digitalWrite(A1, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="407" LastEditorUserId="407" LastEditDate="2014-03-03T05:42:31.690" LastActivityDate="2014-03-03T05:42:31.690" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="576" PostTypeId="1" CreationDate="2014-03-03T08:45:26.233" Score="2" ViewCount="693" Body="&lt;p&gt;I am currently using a ST7565 graphic LCD for display in a heat pump system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This LCD has the following characteristics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;128x64 pixels&lt;/li&gt;&#xA;&lt;li&gt;2.5&quot;x1.5&quot;&lt;/li&gt;&#xA;&lt;li&gt;monochrome, no greyscale&lt;/li&gt;&#xA;&lt;li&gt;backlit&lt;/li&gt;&#xA;&lt;li&gt;good viewing angles&lt;/li&gt;&#xA;&lt;li&gt;serially connected (i.e. only uses a small number of pins)&lt;/li&gt;&#xA;&lt;li&gt;high enough refresh rate to show animated icons&lt;/li&gt;&#xA;&lt;li&gt;low cost (£20)&lt;/li&gt;&#xA;&lt;li&gt;has a high-quality, maintained library&lt;/li&gt;&#xA;&lt;li&gt;available from multiple sources for several years&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am finding the resolution of the screen limiting for my application. Ideally I would like a display that is exactly the same but with a higher resolution. Something between&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not want:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;colour (largely as the display is less visible, but also increased cost and code complexity), but red/green/blue on black would be OK.&lt;/li&gt;&#xA;&lt;li&gt;a physically smaller display (all of the OLED displays are small - 2&quot; and below) as it needs to be visible from a distance&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there any displays that meet these requirements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that the specific requirements here mean that this is not a simple &quot;&lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/16/when-should-questions-be-considered-shopping-recommendations&quot;&gt;shopping question&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="-1" LastEditDate="2017-03-16T15:52:43.687" LastActivityDate="2014-03-03T10:54:41.610" Title="Are there any commonly available and supported backlit, monochrome graphic LCDs with more than 128x64 pixels?" Tags="|display|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="577" PostTypeId="2" ParentId="576" CreationDate="2014-03-03T10:47:43.347" Score="2" Body="&lt;p&gt;Here you can find a bunch of displays at &lt;a href=&quot;http://www.newhavendisplay.com/oled-graphic-oled-c-119_577.html?zenid=jpvgfaffukfrnbam6l9mnkbqg1&quot; rel=&quot;nofollow&quot;&gt;new haven display&lt;/a&gt;, which are big and OLED and not too expensive:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.newhavendisplay.com/images/NHD-2.7-12864UCY3-front-NOBL.jpg&quot; rel=&quot;nofollow&quot;&gt;2.7&quot; 128x64 OLED&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.newhavendisplay.com/nhd31225664umy3-p-6092.html&quot; rel=&quot;nofollow&quot;&gt;3.12&quot; 256x64 OLED&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Those OLED Displays have a really excellent viewing angle and can be read from far (given you accept those sizes, which are &gt;2&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the biggest I know about are &lt;a href=&quot;http://www.newhavendisplay.com/lcd-graphic-c-21.html&quot; rel=&quot;nofollow&quot;&gt;LCD ones from NHD&lt;/a&gt; over there:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.newhavendisplay.com/lcd-graphic-320-x-240-c-21_107.html&quot; rel=&quot;nofollow&quot;&gt;320x240 LCD with backlight&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What's good with them, it's that they can cope with production in case this is needed, their prices are decent and their product just work(cTMr). You can find the &lt;a href=&quot;https://code.google.com/p/u8glib/&quot; rel=&quot;nofollow&quot;&gt;u8g library&lt;/a&gt; to run them.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="379" LastEditDate="2014-03-03T10:54:41.610" LastActivityDate="2014-03-03T10:54:41.610" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="579" PostTypeId="2" ParentId="348" CreationDate="2014-03-03T11:57:39.827" Score="36" Body="&lt;p&gt;My way of organizing an arduino project is quite simple, all my project are git repositories so that there is at least the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;project/&#xA;&lt;ul&gt;&#xA;&lt;li&gt;project.ino&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/guyzmo/Arduino-Tools/blob/master/Makefile&quot; rel=&quot;noreferrer&quot;&gt;Makefile&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have a preference using my &lt;a href=&quot;http://vim.org&quot; rel=&quot;noreferrer&quot;&gt;favorite editor&lt;/a&gt; and a &lt;a href=&quot;https://github.com/guyzmo/Arduino-Tools/blob/master/Makefile&quot; rel=&quot;noreferrer&quot;&gt;Makefile&lt;/a&gt; which I have crafted to work against most use cases (and I even improved on that one that I'm going to share soon).&lt;/p&gt;&#xA;&lt;p&gt;For the libraries, I prefer to keep them as their own repositories and use git submodule to include them to the project. As many libraries written by the community are shared as git repositories, that's a good generic solution. Then, within the Makefile, I just have to add the libraries path I want to include in the &lt;a href=&quot;https://github.com/guyzmo/Arduino-Tools/blob/master/Makefile#L63&quot; rel=&quot;noreferrer&quot;&gt;LOCALLIBS&lt;/a&gt; variable.&lt;/p&gt;&#xA;&lt;p&gt;Though, for some projects, it makes sense to encapsulate the libraries into a hardware abstraction layer library crafted for the project, then I prefer to use a path such as:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;project&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;project.ino&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Makefile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;project_hal_lib&lt;/code&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;library1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;library2&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;library3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;…&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Though, with arduino 1.5.x a new &lt;a href=&quot;https://arduino.github.io/arduino-cli/library-specification/&quot; rel=&quot;noreferrer&quot;&gt;way to specify libraries&lt;/a&gt; is offered, that will offer a way to create and build arduino projects the same way we already do with pipy and virtualenv in python, i.e. you define the set of libraries you need and they get downloaded.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="67489" LastEditDate="2020-07-14T20:37:58.227" LastActivityDate="2020-07-14T20:37:58.227" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="580" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T12:13:37.963" Score="2" Body="&lt;p&gt;The simplest, yet best solution afaict, would be to use an optocoupler made of one IR LED and an opto-transistor. You make the LED lighten towards the roll, the LED being within the roll tied to the &quot;handle&quot;. Once you remove the cardboard roll, the opto-transistor gets the IR light from the LED and triggers a pin change interruption on the Arduino, which can then alert you through many ways (light, SMS, twitter, alarm…).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That design is really cheap, easy and fast to build. Though there's still one thing you need to do: when there's no more toilet paper, you need to actually have the cardboard roll &lt;em&gt;removed&lt;/em&gt; ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the same kind of solution for the spare rolls is even a better idea :-)&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-03T12:13:37.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="581" PostTypeId="2" ParentId="563" CreationDate="2014-03-03T15:07:17.307" Score="2" Body="&lt;p&gt;&lt;strong&gt;Weight:&lt;/strong&gt; marginal as the difference between one board (with everything on it) and two boards (Uno plus DOF) may be - for model airplanes every bit counts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Size:&lt;/strong&gt; the traditional &quot;Uno&quot; is much larger than the ArduIMU integrated boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Power:&lt;/strong&gt; the integrated board PROBABLY will use less and thus get away with a smaller (lighter) battery.&lt;/p&gt;&#xA;" OwnerUserId="58" LastEditorUserId="8" LastEditDate="2014-03-03T15:42:39.937" LastActivityDate="2014-03-03T15:42:39.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="582" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T15:13:39.260" Score="14" Body="&lt;p&gt;I think I saw this in series 1 episode 2 of James May's Manlab. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar to jfpoilpret, use a wide piece of material on a spring that makes contact with the roll at all times. I say 'wide' so that when the roll is empty the reed touches with a contact on one of the roll holders on the side. When it touches it completes a circuit to your alarm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a crude image describing what I mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Arluin's response it was mentioned that this method would not show that the the roll was empty. Thats pretty much true. If the top contact is as thick as the TP cardboard roll and the bottom contact is positioned inside the inner part of the cardboard roll it should get close enough for practical purposes. One foot of TP roll is not enough after taco night. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uSWHr.jpg&quot; alt=&quot;Behold the image of my imagination&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="425" LastEditorUserId="425" LastEditDate="2014-03-05T18:09:22.900" LastActivityDate="2014-03-05T18:09:22.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="583" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T16:28:28.857" Score="1" Body="&lt;p&gt;Your best option is attaching a rotary encoder to the side of the roll, and count the rotations of the roll to determine how much has been used. Once you know the number of rotations per roll,you can set where you want your notification to fire. Attach it to a logging system of sorts and you'll have historical data of paper use as well as toilet use.&lt;/p&gt;&#xA;" OwnerUserId="310" LastActivityDate="2014-03-03T16:28:28.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="584" PostTypeId="2" ParentId="562" CreationDate="2014-03-03T16:43:42.907" Score="3" Body="&lt;p&gt;Well, if you want to do more advanced stuff with your AVRs, you should definitely leave the Arduino environment, and integrate your AVR development in your &quot;usual&quot; favorite development environment, whatever it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you've got two choices, either do 100% pure C with AVR libraries, for which you only need a simple makefile that calls avr-gcc with avr-libc libraries as include path. You can also use Atmel Studio that helps you a lot on that stuff. But if you do so, you're loosing the advantages of the libraries built for/by the arduino community – which, sadly, is not a huge loss for a strong majority of those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can work your code out as a 100% C external library, used from within the sketch, and included at linking time. Then you'll have all the advantages of working with any C++ library you'd like to have, but still doing the important code in pure C. Having only the &lt;code&gt;.ino&lt;/code&gt; used to generate the main &lt;code&gt;.cpp&lt;/code&gt; and any &lt;code&gt;.cpp&lt;/code&gt; library you'd need. Though, for many basic features like writing on the serial port, you'll have to do it [the good old way][2] or by doing some weird encapsulation of &lt;code&gt;Serial.println()&lt;/code&gt; call sent as a functor to the pure C parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;https://github.com/guyzmo/Arduino-Tools/blob/master/Makefile&quot; rel=&quot;nofollow&quot;&gt;makefile&lt;/a&gt; I've written (debian offers another one with the non-gui install of arduino), every &lt;code&gt;.c&lt;/code&gt; file from declared libraries are detected and compiled with avr-gcc, every &lt;code&gt;.cpp&lt;/code&gt; file is compiled with &lt;code&gt;avr-g++&lt;/code&gt; and both gets linked when doing the &lt;code&gt;.elf&lt;/code&gt;/&lt;code&gt;.hex&lt;/code&gt; file.&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-03T16:43:42.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="585" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T17:32:34.200" Score="22" Body="&lt;p&gt;I believe the reed sensor concept put forth by jfpoilpret and jmathew is the easiest to accomplish. I have drawn a diagram of how I think it would look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could adjust sensitivity by adjusting the height of the lower contact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This really only gets you to a &quot;low&quot; condition and not necessarily out. Unless you want to change rolls while there are still a few sheets left this doesn't seem to me to be a satisfactory solution. I'd rather have an &quot;out&quot; indicator and have an audible buzzer to prompt/shame the user into replacing the roll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This design could be accomplished using standalone electronics (no arduino needed). However it you wanted to gamify the changing of the roll you could use an arduino for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also for color based optics sensors, while the vast majority of cardboard tubes used for this purpose are brown, I have seen white ones in use as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CY76e.png&quot; alt=&quot;Reed Sensor Diagram&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="427" LastActivityDate="2014-03-03T17:32:34.200" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="586" PostTypeId="2" ParentId="123" CreationDate="2014-03-03T18:48:47.357" Score="2" Body="&lt;p&gt;Well, your best bet is to import the arduino libraries in your &lt;a href=&quot;http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio project&lt;/a&gt;. Then you'll be able to use existing code to connect to the &quot;traditional&quot; Ethernet Shield using SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though, the Sam 3X features an hardware ethernet &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=197083.0&quot; rel=&quot;nofollow&quot;&gt;that is not wired&lt;/a&gt;, unlike the &lt;a href=&quot;http://mbed.org/platforms/mbed-LPC1768/&quot; rel=&quot;nofollow&quot;&gt;MBed LPC1768&lt;/a&gt;… Sadly that's the &lt;a href=&quot;http://asf.atmel.com/docs/3.11.0/sam3x/html/group__dm9161a__ethernet__phy__group.html&quot; rel=&quot;nofollow&quot;&gt;ethernet PHY component&lt;/a&gt; you saw, but won't be able to actually use…&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-03T18:48:47.357" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="587" PostTypeId="2" ParentId="564" CreationDate="2014-03-03T21:15:47.080" Score="3" Body="&lt;p&gt;I built a reflectance tachometer for an Arduino that'd probably solve your problem.&#xA;The basic circuit is quite simple: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/IOohy.png&quot; alt=&quot;tachometer circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a photoransistor laying around that responded well to red light, and &lt;a href=&quot;http://www.radioshack.com/product/index.jsp?productId=2049724&quot; rel=&quot;nofollow noreferrer&quot;&gt;another from Radio Shack&lt;/a&gt; that was quite sensitive to the IR output of old TV remote LED's.&#xA;For your purposes, green wire would be hooked up to Analog Pin 0 of Arduino, and you just have to sample periodically, not set up an interupt driven sketch.&#xA;The trick to getting a reflected signal difference between white paper and grey roll is knowing that light sensitivity of a photransistor increases w increasing resistance to GND, but the dark voltage also goes up. I came by the 5 and 3 megohm values empically, by checking the AtoD values off dark and light objects at a distance of a few inches from the detector. Same procedure should work for your detection of grey vs white. Although some things that look quite different visibly have the same reflectance in IR. Here's a pic of the finished red light tachometer: &#xA;&lt;img src=&quot;https://i.stack.imgur.com/TlJjj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be simple to make the sensor board small enough to fit into the back of your paper dispenser. IR version is even smaller, but buried too deeply in a home-built centrifuge to get a pic of it today.&lt;/p&gt;&#xA;" OwnerUserId="382" LastActivityDate="2014-03-03T21:15:47.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="588" PostTypeId="1" AcceptedAnswerId="590" CreationDate="2014-03-03T23:17:03.163" Score="16" ViewCount="10155" Body="&lt;h2&gt;Ignore the stalker-like title.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am thinking about creating a project with Arduino that can sense you sleep habits, when you're asleep, and how much you sleep. It would be convenient to not have to turn it on/off at night; it should know how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some ideas that I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Motion sensor&lt;/li&gt;&#xA;&lt;li&gt;Breathing patterns (if an Arduino microphone could even pick that out... I would be surprised if it could)&lt;/li&gt;&#xA;&lt;li&gt;A RTC clock could assist in deciding &lt;em&gt;It's midnight. Usual, Steve isn't asleep at this time on Fridays. He's probably not sleeping now.&lt;/em&gt; It won't always be there to help you, but you might be able to try to get more accurate results this way&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I accomplish this?&lt;/strong&gt; (Extra points for some sort of algorithm that can tell dozing off from a deep sleep.)&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2023-09-16T11:26:53.443" Title="How can I sense when someone is sleeping with my Arduino?" Tags="|sensors|arduino-uno-smd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="590" PostTypeId="2" ParentId="588" CreationDate="2014-03-03T23:50:11.703" Score="13" Body="&lt;p&gt;I actually did something like this, using a &lt;a href=&quot;https://www.sparkfun.com/products/8630&quot;&gt;PIR Motion sensor&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motion sensor is good enough to detect a person turning in their sleep, and my simple algorithm just counts movements per minute and when its over a threshold (found by trial and error), it sounds the alarm to wake you up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pYBe3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The image above represents my body movements during a night. The spikes represent a high movements/minute.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Here we see after about 30 minutes body motion was minimal. This suggests I was in a deeper stage of sleep during that time.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The spike at 250 minutes (around 4:30AM) is when I woke up only to&#xA;  realize I could sleep for couple of hours longer. I recall the time&#xA;  being 4:38 when I looked at my clock and I was already facing it. This&#xA;  means I turned around to face the clock but actually &quot;woke up&quot; 8&#xA;  minutes later to see the time, and then turned back around (indicated&#xA;  by the shorter spike at 265).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The data suggests I was not able to sleep very well (compared to the&#xA;  time period between 30 and 240 minutes) after waking up once and&#xA;  finally got up at 400 minutes (7:00AM), when I shut everything down.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here are a couple of posts from my blog that have a lot more information.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://blog.sachleen.com/posts/1353217318/body-movement-during-sleep/&quot;&gt;Body Movement During Sleep&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://blog.sachleen.com/posts/1353217790/alarm-clock-hardware/&quot;&gt;Intelligent Alarm Clock Hardware&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-03T23:50:11.703" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="591" PostTypeId="2" ParentId="564" CreationDate="2014-03-04T00:59:03.920" Score="3" Body="&lt;p&gt;I think another decent and cheap option to use is a proximity sensor like the ones on the phone or a fixed field infrared sensor. These sensor are pretty accurate and can easily be used to &quot;look&quot; at the back of the toilet roll by mounting the sensor to the holder or the wall where the toilet roll is placed.&#xA;All the other ideas I saw on the post were either fairly inaccurate or felt intrusive towards the toilet roll which in the long run I feel may provide contamination.&#xA;A proximity sensor is not only fairly cheap and easy to use, if calibrated well, they can allow a very good amount of accuracy and reliability. This model is already in wide usage in men urinals to auto-flush.&#xA;For example on your phone: Your phone will accurately provide a distance of 2.0 inches or infinity when your hand or your face is near the screen.&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2014-03-04T00:59:03.920" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="592" PostTypeId="1" AcceptedAnswerId="595" CreationDate="2014-03-04T01:11:20.083" Score="5" ViewCount="977" Body="&lt;p&gt;I wish to build a remote for my Camera i.e Sony NEX 5R. It has a built in IR receiver and has several Sony as well as aftermarket remotes provided for it. Due to my interest in Micro controller design I wish to build one myself rather than use an aftermarket one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A friend who did the same for his NEX 5 series camera posted a video of the same on Facebook, which inspired me to build my own. I plan to use an Arduino Uno R3 with the following additional components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;IR LED&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;NPN Transistor(for amplification)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Schmidt Triggers(for rectification)&lt;/li&gt;&#xA;&lt;li&gt;9 Volt Battery&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ultimately I would like to swap out the Arduino for a standalone ATmega328 or ATtiny2313 but currently I have some issues as of now:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I currently do not have a schematic or a sample code which I can use. I have been trying to search the internet for the same but to no avail.&lt;/li&gt;&#xA;&lt;li&gt;I am unsure of the protocol used by my camera. I have found it difficult to find documentation on the same.&lt;/li&gt;&#xA;&lt;li&gt;How can I replace the 9-Volt battery for something smaller?&lt;/li&gt;&#xA;&lt;li&gt;I would like to use a smaller micro controller but what differences will I encounter when trying to change my code for the smaller micro controller?&lt;/li&gt;&#xA;&lt;li&gt;For such a project, will I need additional hardware?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="358" LastEditorUserId="358" LastEditDate="2014-03-04T05:38:36.570" LastActivityDate="2017-04-10T18:56:28.217" Title="Build Infrared Camera Remote" Tags="|arduino-uno|programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="593" PostTypeId="5" CreationDate="2014-03-04T01:43:31.853" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-04T01:43:31.853" LastActivityDate="2014-03-04T01:43:31.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="594" PostTypeId="4" CreationDate="2014-03-04T01:43:31.853" Score="0" Body="This tag should be used for questions regarding the selection of components, deciding functionality, and other issues that may come up during the early stages of a project." OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-04T01:50:14.033" LastActivityDate="2014-03-04T01:50:14.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="595" PostTypeId="2" ParentId="592" CreationDate="2014-03-04T01:57:56.513" Score="5" Body="&lt;ol&gt;&#xA;&lt;li&gt;Using the Arduino shouldn't be any different than any other microcontroller.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot;&gt;IRremote library&lt;/a&gt; is my go-to library for any IR related stuff.&lt;/li&gt;&#xA;&lt;li&gt;Power shouldn't be an issue, look at the &lt;a href=&quot;http://lowpowerlab.com/moteino/&quot;&gt;Moteino from LowPowerLab&lt;/a&gt; and check out his &lt;a href=&quot;http://lowpowerlab.com/blog/2012/12/24/moteino-coin-cell-battery-tests/&quot;&gt;coin cell battery tests&lt;/a&gt;. It's definitely possible. Not with a full blown Uno, but with a bare chip, yes.&lt;/li&gt;&#xA;&lt;li&gt;You want to burn the bootloader on the IC first, before you can start writing Arduino code. Check out this tutorial: &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot;&gt;From Arduino to a Microcontroller on a Breadboard&lt;/a&gt;. It's the same process for an ATTiny, you just have to look at the datasheet to see where to plug things into. Specifically, MOSI, MISO, SCK, and Reset pins. The &lt;a href=&quot;https://www.sparkfun.com/products/11801&quot;&gt;Tiny AVR Programmer&lt;/a&gt; is also a good choice. It's meant for the 8 pin micros but it has an ISP header so you can use it for almost any chip.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This may be useful for more information about decoding IR signals:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=vOzaDQmAW0g&quot;&gt;EEVblog #505 - IR Learning Remote Control Hack&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=BUvFGTxZBG8&amp;amp;feature=youtu.be&quot;&gt;EEVblog #506 - IR Remote Control Arduino Protocol Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-04T01:57:56.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="596" PostTypeId="2" ParentId="592" CreationDate="2014-03-04T02:18:58.167" Score="1" Body="&lt;p&gt;1.) I'm not exactly sure what you mean by this. What I'd recommend is a &lt;a href=&quot;https://www.sparkfun.com/products/9061&quot; rel=&quot;nofollow&quot;&gt;ATMega328&lt;/a&gt; for the heart of the chip. It's what is in the Uno, so with a exception of uploading code, for this project this will cut down on the size of your project. However, an Uno will work pretty much identical. If you do want to use a chip like this, &lt;a href=&quot;http://fritzing.org/projects/barebones-arduino&quot; rel=&quot;nofollow&quot;&gt;this design&lt;/a&gt; looks pretty complete. You'll probably want to move to a PCB for your final product, but since you have a little electronic experience, I assume you can solder and know about this. &lt;a href=&quot;http://playground.arduino.cc/Learning/AtmegaStandalone&quot; rel=&quot;nofollow&quot;&gt;Here is another tutorial for barebones&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.) Again, what do you mean by &quot;standard?&quot; Like protocol? If so, there's no real protocol to use. &lt;a href=&quot;http://www.robotmesh.com/ir-kit-for-arduino?gclid=CM650djc97wCFexcMgodK0kAjQ&quot; rel=&quot;nofollow&quot;&gt;This may be easy for a begginer&lt;/a&gt;. It's the remote and the receiver. If you want to go all geek you can also &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow&quot;&gt;hack an existing TV remote to do the same task&lt;/a&gt;. That library should take care of everything you need (see code later).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A bit of code/wiring:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit will depend on what receiver you choose. Most IR receivers have one pin for 5v, one for GND, and the last one is connected to a digital pin. Again, look at the information on the specific receiver you choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some sample code with the library I listed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;        //Using pin 11 for the signal pin&#xA;IRrecv irrecv(RECV_PIN);  //Creates a variable that will be used later to inference between library and code&#xA;decode_results results;   //Use it to store the value of the keycode&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    Serial.println(results.value, HEX);&#xA;    irrecv.resume(); // Receive the next value&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll have to run this sketch to determine the value of the button you'll use on the remote. It should print on the serial window some sort of hexadecimal value IIRC that you'll have to convert into decimal if you want to use it inside the code to compare that to the button you want to use on the remote. The post I mentioned is a great resource: go and look at it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;3.) I don't recommend building a remote. Like I said, you can use existing TV remotes or buy one for this purpose. Start small, figure out how IR remotes work, and then build one later if you desire. A v2 is often required on Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4.) Don't bother for the receiver. It &lt;em&gt;can&lt;/em&gt; be bigger. If you don't know how to to program it, &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow&quot;&gt;this guide is a good reference&lt;/a&gt;. It has some files that you download to add it in the IDE to trick the IDE to think the chip is a board. Note: You'll have to program it with an Uno or similar to upload and to burn the firmware. (I would explain it more in case the site goes down, but you need the files there so it'll be pointless anyway.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a quick tip: don't be afraid to ask your friend for some help. You don't need to rely on him, but if you get stuck ask him.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to connect the Arduino to the camera, but you seem to know how to do that.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="46" LastEditDate="2014-06-02T17:08:32.080" LastActivityDate="2014-06-02T17:08:32.080" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="597" PostTypeId="2" ParentId="452" CreationDate="2014-03-04T02:38:20.473" Score="1" Body="&lt;h2&gt;Just &lt;a href=&quot;https://github.com/arduino/Arduino/issues&quot; rel=&quot;nofollow noreferrer&quot;&gt;report it to Arduino&lt;/a&gt;.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You don't really have any other option. I've been waiting to answer this question until I was sure that no one here knew the answer. You don't really have any other option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems like a bug. &lt;strong&gt;We're not Arduino developers or a bug tracking site.&lt;/strong&gt; We can only do so much here. Even if it was confirmed a bug and we fixed it, there's only so much that can be done without submitting a report.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BEFORE YOU SUBMIT A REPORT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'd try copying out the libraries from Arduino. So many libraries&#xA;might make Arduino IDE somewhat heavier. I don't know if it'll really&#xA;affect the sluggishness but it's worth a shot.&lt;/li&gt;&#xA;&lt;li&gt;The only other thing that I can think of, besides RAM (which you&#xA;already said wasn't an issue) and the libraries, is some sort of&#xA;cache/temporary file. Try reinstalling Arduino, even if you haven't,&#xA;and also I'd try using the &lt;a href=&quot;http://arduino.cc/en/main/software&quot; rel=&quot;nofollow noreferrer&quot;&gt;beta 1.5.6-r2&#xA;version&lt;/a&gt;. It has to be pretty&#xA;stable for it to be the only version that supports the YUN and DUE.&#xA;Both have been out for a considerable amount of time with this&#xA;software, so I'd imagine that it's pretty stable minus a few issues.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Many things are said to have been improved compared to the previous 1.0.5-r2 version.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It'd be stupid not to try the newer version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/G7N4P.png&quot; alt=&quot;GitHub Screenshot&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-04T02:38:20.473" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="598" PostTypeId="1" AcceptedAnswerId="599" CreationDate="2014-03-04T02:50:55.353" Score="16" ViewCount="14229" Body="&lt;p&gt;Stepper motors are often pricey for a large motor. However, with a powerful, standard DC motor and a rotary encoder, you can &quot;simulate&quot; a stepper motor. &lt;strong&gt;How accurate are rotary encoders with Arduino just with a basic loop and not much other code?&lt;/strong&gt; Is it going to &quot;miss a pulse&quot; and not record enough rotation often? How can I handle this with much more code? Is there a better way to do this? Would interrupts help? Is there some sort of circuit that would help with this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: It will probably not exceed 4 rotations a second... &lt;em&gt;(That may be a lot but if you're doing a lead screw type mechanism that would only be 24 inches a minute if there is 10 rotations per inch of linear motion.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-04-09T03:22:53.033" Title="How precise can I get Arduino using rotary encoders?" Tags="|interrupt|rotary-encoder|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="599" PostTypeId="2" ParentId="598" CreationDate="2014-03-04T03:26:23.890" Score="11" Body="&lt;p&gt;Interrupts are what you would use in this situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rates that you have mentioned are slow enough where you &lt;em&gt;probably&lt;/em&gt; would be able to count it inside of a loop, however this is not recommended, as a typical loop will take many clock cycles to complete, and depending on the number of instuctiuons per loop, you may miss some counts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are made for this purpose, as they can be triggered at any time, regardless of the state of the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a function named &lt;code&gt;attachInterrupt()&lt;/code&gt; which will take three arguments.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Interrupt Pin&lt;/li&gt;&#xA;&lt;li&gt;Interrupt Service Routine&lt;/li&gt;&#xA;&lt;li&gt;Mode&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Below is an example for counting an interrupt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int myCounter = 0;&#xA;&#xA;void setup(){&#xA;    attachInterrupt(0, count, RISING);&#xA;}&#xA;&#xA;void count(){&#xA;    myCounter++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Modes are as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;LOW, CHANGE, RISING, FALLING&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;More information about using interrupts can be found &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt#.UxVGrvldXvM&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the encoder you use, you will need to tailor the code your needs, and do some more calculations to determine your position, but this should be a good starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;&lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders#.UxVIwvldU4J&quot;&gt;Here&lt;/a&gt; is some example code from Arduino Sandbox for using a rotary encoder.&lt;/p&gt;&#xA;" OwnerUserId="407" LastActivityDate="2014-03-04T03:26:23.890" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="600" PostTypeId="2" ParentId="592" CreationDate="2014-03-04T10:26:29.627" Score="1" Body="&lt;p&gt;Well, for your project you can simply buy/rebuild a TV-B-Gone &lt;a href=&quot;https://cornfieldelectronics.com/tvbgone/buy.tvbgkit.php?PHPSESSID=3phhip32unp1ku0di8qe9e6od0&quot; rel=&quot;nofollow noreferrer&quot;&gt;made by Mitch&lt;/a&gt;, which he uses as a basic project to teach soldering all over the world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &quot;hack&quot; the TV-B-Gone by adding a &lt;a href=&quot;http://www.vishay.com/docs/82459/tsop48.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSOP4838&lt;/a&gt; that can work as an IR receiver (or use another device as a code recorder).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LezO4.png&quot; alt=&quot;TV-B-Gone&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as you can see here the TV B Gone features an ATTiny85. A really small and nice beast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you'll find the &lt;a href=&quot;https://github.com/adafruit/TV-B-Gone-kit/tree/master/firmware&quot; rel=&quot;nofollow noreferrer&quot;&gt;source code&lt;/a&gt; for the TV B Gone. I'm not sure what format they use for their code database though.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="11529" LastEditDate="2017-04-10T18:56:28.217" LastActivityDate="2017-04-10T18:56:28.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="601" PostTypeId="1" AcceptedAnswerId="618" CreationDate="2014-03-04T12:59:01.943" Score="9" ViewCount="14993" Body="&lt;p&gt;There exists a large variety of sensors in the &lt;a href=&quot;http://www.seeedstudio.com/wiki/GROVE_System&quot;&gt;Grove System&lt;/a&gt;. Usually these are accessed via a special shield (Grove base shield). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I access these sensor directly without a shield. In particular I am interested in using them with an Arduino Pro Mini. My guess is that one definitely needs the 5V version of the Mini, but other than this? How fiddly is it to use these sensors directly? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am interested in using the &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor&quot;&gt;Grove dust sensor&lt;/a&gt;, but I am also would like to operate a &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_4-Digit_Display&quot;&gt;Grove 4 digit display&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="94" LastEditorUserId="94" LastEditDate="2014-03-04T13:42:51.337" LastActivityDate="2015-10-20T22:12:23.083" Title="Grove sensors without a Grove shield" Tags="|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="602" PostTypeId="1" AcceptedAnswerId="605" CreationDate="2014-03-04T13:26:36.847" Score="16" ViewCount="14020" Body="&lt;p&gt;I have a problem with my Arduino. I can't upload any sketches to it (it gives me the error &lt;code&gt;avrdude: verification error; content mismatch&lt;/code&gt;), but the LEDs are still blinking. Do you think that the whole Arduino is dead or is it just the chip ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : I tried an other USB cable but it changed nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : Here is the output of verbose mode while uploading :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Taille binaire du croquis : 1 084 octets (d'un max de 32 256 octets)&#xA;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/cu.usbmodem641 -b115200 -D -Uflash:w:/var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:i &#xA;&#xA;avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/trevorannedenise/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/cu.usbmodem641&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;         AVR Part                      : ATMEGA328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;avrdude: Send: A [41] . [80]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [98]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;         Hardware Version: 3&#xA;         Firmware Version: 4.4&#xA;avrdude: Send: A [41] . [84]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [85]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [86]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [87]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [89]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;         Vtarget         : 0.3 V&#xA;         Varef           : 0.3 V&#xA;         Oscillator      : 28.800 kHz&#xA;         SCK period      : 3.3 us&#xA;&#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: P [50]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | avrdude: Send: u [75]   [20] &#xA;avrdude: Recv: . [14] . [1e] . [95] . [0f] . [10] &#xA;################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: Send: V [56] . [a0] . [03] . [fc] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [fd] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [fe] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [ff] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: reading input file &quot;/var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex&quot;&#xA;avrdude: writing flash (1084 bytes):&#xA;&#xA;Writing | avrdude: Send: U [55] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [0c] . [94] a [61] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] . [9d] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [00] . [00] . [00] . [00] $ [24] . [00] ' [27] . [00] * [2a] . [00] . [00] . [00] . [00] . [00] % [25] . [00] ( [28] . [00] + [2b] . [00] . [00] . [00] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;#####avrdude: Send: U [55] @ [40] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] # [23] . [00] &amp;amp; [26] . [00] ) [29] . [00] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [02] . [02] . [02] . [02] . [02] . [02] . [03] . [03] . [03] . [03] . [03] . [03] . [01] . [02] . [04] . [08] . [10]   [20] @ [40] . [80] . [01] . [02] . [04] . [08] . [10]   [20] . [01] . [02] . [04] . [08] . [10]   [20] . [00] . [00] . [00] . [07] . [00] . [02] . [01] . [00] . [00] . [03] . [04] . [06] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [11] $ [24] . [1f] . [be] . [cf] . [ef] . [d8] . [e0] . [de] . [bf] . [cd] . [bf] . [11] . [e0] . [a0] . [e0] . [b1] . [e0] . [ea] . [e3] . [f4] . [e0] . [02] . [c0] . [05] . [90] . [0d] . [92] . [a2] 0 [30] . [b1] . [07] . [d9] . [f7] . [11] . [e0] . [a2] . [e0] . [b1] . [e0] . [01] . [c0] . [1d] . [92] . [ab] 0 [30] . [b1] . [07] . [e1] . [f7] . [0e] . [94] . [0c] . [02] . [0c] . [94] . [1b] . [02] . [0c] . [94] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [80] . [91] . [00] . [01] ` [60] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [08] . [95] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] y [79] . [01] . [08] . [95] . [1f] . [92] . [0f] . [92] . [0f] . [b6] . [0f] . [92] . [11] $ [24] / [2f] . [93] ? [3f] . [93] . [8f] . [93] . [9f] . [93] . [af] . [93] . [bf] . [93] . [80] . [91] . [06] . [01] . [90] . [91] . [07] . [01] . [a0] . [91] . [08] . [01] . [b0] . [91] . [09] . [01] 0 [30] . [91] . [0a] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] # [23] / [2f] - [2d] _ [5f] - [2d] 7 [37]   [20] . [f0] - [2d] W [57] . [01] . [96] . [a1] . [1d] . [b1] . [1d]   [20] . [93] . [0a] . [01] . [80] . [93]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [06] . [01] . [90] . [93] . [07] . [01] . [a0] . [93] . [08] . [01] . [b0] . [93] . [09] . [01] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [80] . [93] . [02] . [01] . [90] . [93] . [03] . [01] . [a0] . [93] . [04] . [01] . [b0] . [93] . [05] . [01] . [bf] . [91] . [af] . [91] . [9f] . [91] . [8f] . [91] ? [3f] . [91] / [2f] . [91] . [0f] . [90] . [0f] . [be] . [0f] . [90] . [1f] . [90] . [18] . [95] . [9b] . [01] . [ac] . [01] . [7f] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] f [66] . [b5] . [a8] . [9b] . [05] . [c0] o [6f] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [7f] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [86] . [0f] . [91] . [1d]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [a1] . [1d] . [b1] . [1d] b [62] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] j [6a] . [95] . [d1] . [f7] . [bc] . [01] - [2d] . [c0] . [ff] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [e6] . [b5] . [a8] . [9b] . [05] . [c0] . [ef] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [ff] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [8e] . [0f] . [91] . [1d] . [a1] . [1d] . [b1] . [1d] . [e2] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] . [ea] . [95] . [d1] . [f7] . [86] . [1b] . [97] . [0b] . [88] ^ [5e] . [93] @ [40] . [c8] . [f2] ! [21] P [50] 0 [30] @ [40] @ [40] @ [40] P [50] @ [40] h [68] Q [51] | [7c] O [4f] ! [21] . [15] 1 [31] . [05] A [41] . [05] Q [51] . [05] q [71] . [f6] . [08] . [95] x [78] . [94] . [84] . [b5]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] @ [40] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [82] ` [60] . [84] . [bd] . [84] . [b5] . [81] ` [60] . [84] . [bd] . [85] . [b5] . [82] ` [60] . [85] . [bd] . [85] . [b5] . [81] ` [60] . [85] . [bd] . [ee] . [e6] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [e8] . [f0] . [e0] . [10] . [82] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [e0] . [e8] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [eb] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [e0] . [eb] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [ea] . [e7] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [80] . [81] . [80] h [68] . [80] . [83] . [10] . [92] . [c1] . [00] . [08] . [95] . [cf] . [93] . [df] . [93] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [86] V [56] . [9f] O [4f]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [fc] . [01] 4 [34] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] . [84] . [91] . [88] # [23] i [69] . [f1] . [90] . [e0] . [88] . [0f] . [99] . [1f] . [fc] . [01] . [e8] Y [59] . [ff] O [4f] . [a5] . [91] . [b4] . [91] . [fc] . [01] . [ee] X [58] . [ff] O [4f] . [c5] . [91] . [d4] . [91] f [66] # [23] Q [51] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [89] # [23] . [0b] . [c0] b [62] 0 [30] a [61] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [83] + [2b] . [88] . [83] / [2f] . [bf] . [06] . [c0] . [9f] . [b7] . [f8] . [94] . [8c] . [91] . [83] + [2b] . [8c] . [93] . [9f] . [bf] . [df] . [91] . [cf] . [91] . [08] . [95] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [82] U [55] . [9f] O [4f] . [fc] . [01] $ [24] . [91] . [ca] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [86] V [56] . [9f] O [4f] . [fc] . [01] . [94] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] 4 [34] . [91] 3 [33] # [23] . [09] . [f4] @ [40] . [c0] &quot; [22] # [23] Q [51] . [f1] # [23] 0 [30] q [71] . [f0] $ [24] 0 [30] ( [28] . [f4] ! [21] 0 [30] . [a1] . [f0] &quot; [22] 0 [30] . [11] . [f5] . [14] . [c0] &amp;amp; [26] 0 [30] . [b1] . [f0] ' [27] 0 [30] . [c1] . [f0] $ [24] 0 [30] . [d9] . [f4] . [04] . [c0] . [80] . [91] . [80] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [80] . [00] . [8f] } [7d] . [80] . [93] . [80] . [00] . [10] . [c0] . [84] . [b5] . [8f] w [77] . [02] . [c0] . [84] . [b5] . [8f] } [7d] . [84] . [bd] . [09] . [c0] . [80] . [91] . [b0] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [b0] . [00] . [8f] } [7d] . [80] . [93] . [b0] . [00] . [e3] / [2f] . [f0] . [e0] . [ee] . [0f] . [ff] . [1f] . [ee] X [58] . [ff] O [4f] . [a5] . [91] . [b4] . [91] / [2f] . [b7]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [02]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] &amp;lt; [3c] F [46] . [f8] . [94] f [66] # [23] ! [21] . [f4] . [8c] . [91] . [90] . [95] . [89] # [23] . [02] . [c0] . [8c] . [91] . [89] + [2b] . [8c] . [93] / [2f] . [bf] . [08] . [95] . [cf] . [93] . [df] . [93] . [0e] . [94] &amp;gt; [3e] . [01] . [0e] . [94] . [97] . [00] . [c0] . [e0] . [d0] . [e0] . [0e] . [94] . [80] . [00]   [20] . [97] . [e1] . [f3] . [0e] . [94] . [00] . [00] . [f9] . [cf] . [f8] . [94] . [ff] . [cf] . [0d] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;### | 100% 0.21s&#xA;&#xA;avrdude: 1084 bytes of flash written&#xA;avrdude: verifying flash memory against /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:&#xA;avrdude: load data flash data from input file /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:&#xA;avrdude: input file /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex contains 1084 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | avrdude: Send: U [55] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;#####avrdude: Send: U [55] @ [40] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] @ [40] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [02]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] &amp;lt; [3c] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] &#xA;avrdude: Recv: . [10] &#xA;### | 100% 0.16s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x0000&#xA;         0x0c != 0xff&#xA;avrdude: verification error; content mismatch&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="453" LastEditorUserId="6936" LastEditDate="2015-08-06T17:49:24.503" LastActivityDate="2015-08-11T08:55:56.333" Title="Is my Arduino dead or is it just its processor?" Tags="|arduino-uno|uploading|atmega328|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="604" PostTypeId="1" AcceptedAnswerId="608" CreationDate="2014-03-04T14:05:45.620" Score="10" ViewCount="10961" Body="&lt;p&gt;I have an Arduino motor shield like this one plugged into my Mega board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cKBqi.jpg&quot; alt=&quot;Arduino motor shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know some more information about the orange and white pin blocks on the board. The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoMotorShieldR3#.UxXT9vl_skI&quot; rel=&quot;noreferrer&quot;&gt;Arduino website&lt;/a&gt; has the following information, but it doesn't give any explanation of what is best to use them for or which pins are mapped to the data pins etc.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TinkerKit connectors for two Analog Inputs (in white), connected to A2 and A3.  &lt;/li&gt;&#xA;&lt;li&gt;TinkerKit connectors for two Aanlog Outputs (in orange in the middle), connected to PWM outputs on pins D5 and D6.  &lt;/li&gt;&#xA;&lt;li&gt;TinkerKit connectors for the TWI interface (in white with 4 pins), one for input and the other one for output.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I want to do is connect a servo up to the board and was hoping I could use one of the orange &lt;code&gt;OUT&lt;/code&gt; blocks. I haven't been successful in finding any examples of this which leaves me in doubt as to whether it is possible or not. I would just plug it in, but I'm afraid of frying the shield/mega/servo. Probably an irrational fear, but I can't afford another one of any at the moment!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know which pins in the block are assigned to the data, vcc and out, so if anyone know I would be grateful for the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, just because it is annoying not to understand, what are the &lt;code&gt;TWI&lt;/code&gt; connectors for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this isn't too general a question as I could really use some answers!&lt;/p&gt;&#xA;" OwnerUserId="454" LastActivityDate="2019-02-24T15:03:40.397" Title="Arduino motor shield orange/white pin usage" Tags="|pins|shields|motor|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="605" PostTypeId="2" ParentId="602" CreationDate="2014-03-04T14:31:35.913" Score="11" Body="&lt;p&gt;It's possible you have a non-fatal problem&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;check power&lt;/li&gt;&#xA;&lt;li&gt;check connections&lt;/li&gt;&#xA;&lt;li&gt;reflash the Arduino bootloader&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If your Arduino has a socketed microcontroller you can try swapping it out with one that has the bootloader preloaded.&lt;/p&gt;&#xA;" OwnerUserId="316" LastActivityDate="2014-03-04T14:31:35.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="606" PostTypeId="2" ParentId="601" CreationDate="2014-03-04T15:15:51.453" Score="3" Body="&lt;p&gt;Grove sensors use a special socket, a 4 pin JST with two power lines and two data. you would have to make your own board/terminal to get them to connect to a mini. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do is use a &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_Protoshield&quot; rel=&quot;nofollow&quot;&gt;Grove proto board&lt;/a&gt;, which converts the JST terminals onto .1&quot; pins suitable for connecting to the Mini. There is also a litle proto area if you want it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use an &lt;a href=&quot;http://www.seeedstudio.com/depot/grove-to-4-pin-254-female-jumper-wire5-pcs-pack-p-1020.html?cPath=178_179&quot; rel=&quot;nofollow&quot;&gt;adapter cable&lt;/a&gt;, which would not have a bulky protoboard along with it. The terminals could be soldered directly to the Mini.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-04T15:15:51.453" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="607" PostTypeId="2" ParentId="348" CreationDate="2014-03-04T15:54:17.963" Score="21" Body="&lt;p&gt;&lt;a href=&quot;http://git-scm.com/book/en/Git-Tools-Submodules&quot; rel=&quot;noreferrer&quot;&gt;Git submodules&lt;/a&gt; are extremely powerful when it comes to organizing multiple nested repositories. Handling multiple libraries from different sources, and even handling parts of your own project which may be stored at different sources becomes easy with git submodules.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Directory Structure&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A way to organize your projects would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;projectA&lt;/strong&gt; - Parent Directory&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;projectA&lt;/strong&gt; - Source code directory containing Arduino code&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;projectA.ino&lt;/li&gt;&#xA;&lt;li&gt;header.h&lt;/li&gt;&#xA;&lt;li&gt;implementation.cpp&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;docs&lt;/strong&gt; - Your main documentation directory&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;schematics&lt;/strong&gt; - these may be maintained separately on a separate Git repo or part of the same repo&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;libs&lt;/strong&gt; - This will contain your third party libraries.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;libA - These may be maintained as third party repositories&lt;/li&gt;&#xA;&lt;li&gt;libC - ...&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;license&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;README&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Makefile&lt;/strong&gt; - Necessary to handle dependencies across directories&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Workflow&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You would follow your normal cycle of make changes, add and commit as far as the main repository is concerned. Things get interesting with the sub-repositories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have the option of adding a repository into the parent directory of your main repository. This means that any part of you directory structure, i.e. docs, schematics, etc. can be maintained as a separate repository and continuously updated from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this using the &lt;code&gt;git submodule add &amp;lt;repo.git&amp;gt;&lt;/code&gt; command. To keep it up to date, you can use &lt;code&gt;git submodule update &amp;lt;path&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it comes to maintaining multiple third party libraries within your repository such that each can be version controlled in itself or each can be kept up to date if need be, git submodule again saves your day!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add a third party repo to &lt;strong&gt;libs&lt;/strong&gt;, use the command &lt;code&gt;git submodule add &amp;lt;lib1.git&amp;gt; libs/lib1&lt;/code&gt;. Then, to maintain the library at a fixed point in the release cycle, checkout the library and make a commit. To keep the library up to date, use the command &lt;code&gt;git submodule update &amp;lt;path&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you can maintain multiple repositories within a main repository as well as multiple third party libraries in their independent stages of release. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Versus Single Directory Approach&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;While the &lt;a href=&quot;https://arduino.stackexchange.com/a/351/65&quot;&gt;single directory approach&lt;/a&gt; is the simplest, it is not possible to version control parts of a directory without a lot of pain. Hence, the simple approach fails to accomodate different repositories with varying states in the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach allows maintaining multiple repositories but brings in the need for a Makefile to handle the compilation and linking process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the complexity of your project, the optimal approach can be selected. &lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-03-04T15:54:17.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="608" PostTypeId="2" ParentId="604" CreationDate="2014-03-04T18:49:29.397" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know which pins in the block are assigned to the data, vcc and&#xA;  out, so if anyone know I would be grateful for the answer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Following the example on &lt;a href=&quot;http://www.tinkerkit.com/custom-distance-sensor/&quot; rel=&quot;nofollow&quot;&gt;TinkerKit's Custom Distance Sensor&lt;/a&gt; page, we see that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you look on the edge of the sensor, you can see the three pins,&#xA;  that are power (5V), ground and signal. The same as your TinkerKit!&#xA;  modules, just in a different order.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The only difference is that the signal and ground cable are inverted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the order in the connector is Vcc Signal Ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way, and what I would do to be 100% sure, is measure resistance with a multimeter. If your meter has a continuity test feature, that's even better because it'll beep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, put one end of the probe on pin 1 of the connector and the other end on GND and see if the resistance is very close to 0 ohms. If it's reading OL (Over-Limit) then that pin is not GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the probe on Vcc instead and it should show 0 ohm or beep. So now you know that pin is Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the same for the other pins and find out which one is ground. The third pin is your PWM output. It's connected to D5 or D6, check the continuity on those pins to see which one.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-04T18:49:29.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="609" PostTypeId="2" ParentId="602" CreationDate="2014-03-04T21:03:13.783" Score="2" Body="&lt;p&gt;I've faced this problem several times!&#xA;If you are using arduino UNO, make sure to remove any serial connected device on the (Tx,RX) pins. Upload your sketch, then connect them back again.&#xA;It's because the arduino UNO has on serial pins which is used for uploading the code, there will be a conflict if there was a device that is connected to the serial the same time you upload the code.&lt;/p&gt;&#xA;" OwnerUserId="467" LastActivityDate="2014-03-04T21:03:13.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="610" PostTypeId="2" ParentId="604" CreationDate="2014-03-04T22:26:04.753" Score="7" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;...which pins are mapped to the data pins etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The shield page provides a &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino_MotorShield_Rev3-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;schematic&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I would like to know some more information about the orange and white pin blocks on the board&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;These have the reference printed on the board&#xA;&lt;img src=&quot;https://i.stack.imgur.com/H7mnt.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;TWI IN and TWI OUT&lt;/h1&gt;&#xA;&lt;p&gt;They are the same and are both connected to the same I2C pins of Arduino (SCL, SDA). They are intended to help in case you want to connect more than one device.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/bAIkc.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;OUT 5, OUT 6&lt;/h1&gt;&#xA;&lt;p&gt;Connected to Arduino pins 5 and 6 (PWM outputs)&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5YY7w.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;IN 2, IN 3&lt;/h1&gt;&#xA;&lt;p&gt;Connected to Analog in A2 and A3&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AK2nq.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;The power outputs of &lt;a href=&quot;http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00000240.pdf&quot; rel=&quot;noreferrer&quot;&gt;L298&lt;/a&gt; intended to drive the motor are the blue screw connectors.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9zRaY.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-04T22:26:04.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="611" PostTypeId="1" AcceptedAnswerId="612" CreationDate="2014-03-04T22:35:36.890" Score="5" ViewCount="1085" Body="&lt;p&gt;In this &lt;a href=&quot;https://code.google.com/p/heating-monitor/source/browse/HeatingMonitor/consts.h&quot; rel=&quot;nofollow&quot;&gt;code&lt;/a&gt; for heating monitor, there appears to be macros called &lt;code&gt;FLASH_ARRAY&lt;/code&gt; and &lt;code&gt;FLASH_TABLE&lt;/code&gt;. I can't find any reference to them either in this code, Arduino, or on the Internet. What do they do?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FLASH_ARRAY(byte, VARIABLE_DEVICE_TABLE,&#xA;    DEVICE_LADDNING_RETUR,&#xA;    DEVICE_LADDNING_UT,&#xA;    DEVICE_TANK1,&#xA;    DEVICE_TANK2,&#xA;    ...&#xA;    VARIABLE_ID_LOAD,&#xA;    VARIABLE_ID_TIME_EMPTY);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FLASH_TABLE(byte, NUMBER_TEMP_TABLE, 7,&#xA;  {DEVICE_LADDNING_RETUR, 99,  5, 10,  7, MAIN_TYPE_TEXT_CELCIUS, 2},&#xA;  {DEVICE_LADDNING_UT,    99, 43, 10,  7, MAIN_TYPE_TEXT_CELCIUS, 2},&#xA;  ...&#xA;  {DEVICE_UTE,             0, 55, 15,  7, MAIN_TYPE_TEXT_CELCIUS_WITH_NEGATIVE, 103},&#xA;  {VARIABLE_ID_EFFECT,   114, 29, 10,  7, MAIN_TYPE_TEXT_VARIABLE, 2});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="136" LastEditorUserId="6452" LastEditDate="2015-01-22T14:11:00.170" LastActivityDate="2017-09-09T08:30:07.683" Title="What are the FLASH_ARRAY/FLASH_TABLE macros in this code?" Tags="|library|flash|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="612" PostTypeId="2" ParentId="611" CreationDate="2014-03-04T22:42:39.183" Score="5" Body="&lt;p&gt;After further digging, this appears to be from Mikal Hart's &lt;a href=&quot;http://arduiniana.org/libraries/flash/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flash library&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The reason this library was developed is:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Storing static program data in flash/PROGMEM is a tricky part of&#xA;Arduino programming. To save precious RAM, a novice user already at&#xA;odds with unfamiliar C++ syntax must digest such daunting concepts as&#xA;prog_char, PSTR(), PROGMEM, pgm_read_word(), etc. Even seasoned users&#xA;get tripped up by the indirection and typecasting that are required to&#xA;retrieve valid PROGMEM data. Add to that a couple of apparent bugs in&#xA;the implementation, and it’s clear that PROGMEM is a complicated mess.&lt;/p&gt;&#xA;&lt;p&gt;I have written a new library, Flash, which abstracts away most of this&#xA;complexity. It provides new String, Array, Table, and String Array&#xA;types that make ROM-based data collections as easy to use as “normal”&#xA;types. Each overrides the C++ [] operator, so to extract individual&#xA;elements one uses familiar array access syntax:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Specifically, these are macros and a simple helper class to make it easier to create arrays and tables of values in program memory.&lt;/p&gt;&#xA;&lt;p&gt;The two macros are declared as so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Example: FLASH_ARRAY(float, temperatures, 98.1, 98.5, 99.1, 102.1);&#xA;#define FLASH_ARRAY(type, name, values...) \&#xA;  static const type name##_flash[] PROGMEM = { values }; \&#xA;  _FLASH_ARRAY&amp;lt;type&amp;gt; name(name##_flash, sizeof(name##_flash) / sizeof(type));&#xA;&#xA;// Example: FLASH_TABLE(uint8_t, fonts, 7, {ON, OFF, ON, ON, OFF, ON, OFF}, {OFF, ON, OFF, ON, OFF, ON, OFF});&#xA;#define FLASH_TABLE(type, name, cols, values...) \&#xA;  static const type name##_flash[][cols] PROGMEM = { values }; \&#xA;  _FLASH_TABLE&amp;lt;type&amp;gt; name((const PROGMEM type *)name##_flash, sizeof(name##_flash) / sizeof(name##_flash[0]), cols);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The helper functions include size and override the operator [] so that they can easily be accessed like so&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;FLASH_ARRAY[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I disagree with zmo - this is more than boilerplate. The area of PROGMEM causes a lot of questions from Arduino users, and it is very easy to do things wrong when creating arrays in PROGMEM.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-05T09:03:48.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="614" PostTypeId="2" ParentId="611" CreationDate="2014-03-05T01:43:32.587" Score="4" Body="&lt;p&gt;The flash array is from Mikal Hart's &lt;a href=&quot;https://github.com/mikalhart/Flash/blob/master/Flash.h#L39&quot; rel=&quot;nofollow noreferrer&quot;&gt;flash library&lt;/a&gt; as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define FLASH_ARRAY(type, name, values...) \&#xA;static const type name##_flash[] PROGMEM = { values }; \&#xA;_FLASH_ARRAY&amp;lt;type&amp;gt; name(name##_flash, sizeof(name##_flash) / sizeof(type));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is an instance of the &lt;code&gt;_FLASH_ARRAY&lt;/code&gt; class defined in that same file, which is a facility to access PROGMEM/Flash memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, it's a lot of boilerplate for what already does the &lt;code&gt;PSTR()&lt;/code&gt; macro amongst other from &lt;code&gt;pgmspace.h&lt;/code&gt;. I personally would avoid using that and prefer to use the original macros along with my own index and pointers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, except for some Arduono IDE magic, I don't think that can compile, as the &lt;code&gt;Flash.h&lt;/code&gt; is not included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make another point against the &lt;code&gt;FLASH_TABLE&lt;/code&gt;/&lt;code&gt;FLASH_ARRAY&lt;/code&gt; boilerplate/overhead, since avc-gcc 4.8 has been introduced the &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;__flash&lt;/code&gt; qualifier&lt;/a&gt; which is a replacement for the &lt;code&gt;PROGMEM&lt;/code&gt; macro, simplifying the whole stuff:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// to use string literals without having to cast&#xA;#define FSTR(X) ((const __flash char[]) { X })&#xA;&#xA;// create string pstr in the .progmem.data address space&#xA;const __flash char* pstr = FSTR (&quot;foo&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and no more use of the &lt;code&gt;pgm_read_*()&lt;/code&gt; functions, you can now access the content of the flash memory using &lt;code&gt;*pstr&lt;/code&gt;, as shown is &lt;a href=&quot;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;p=1129848&quot; rel=&quot;nofollow noreferrer&quot;&gt;this thread&lt;/a&gt;. In case you want to keep a code compatible with older version of avr-gcc, &lt;a href=&quot;https://codereview.stackexchange.com/questions/33883/embedded-conditional-code-compaction&quot;&gt;here's a post&lt;/a&gt; that offers macros to deal with both systems.&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="26916" LastEditDate="2017-09-09T08:30:07.683" LastActivityDate="2017-09-09T08:30:07.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="615" PostTypeId="1" AcceptedAnswerId="617" CreationDate="2014-03-05T02:04:47.267" Score="9" ViewCount="18233" Body="&lt;p&gt;I've seen many temperature sensors, but the highest temperature they go up to is 125 degrees C (257 degrees F). I want to reach &lt;em&gt;higher&lt;/em&gt; temperatures than that. I'm thinking about rigging up a closed loop sensor for my soldering iron (for a convenient LCD display), but I can't find out how to sense the temperature of the tip due to the higher operating temperature than most sensors.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="225" LastEditDate="2014-03-07T01:12:39.413" LastActivityDate="2016-12-07T18:35:33.663" Title="How can I sense very high temperatures with Arduino?" Tags="|sensors|temperature-sensor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="616" PostTypeId="2" ParentId="615" CreationDate="2014-03-05T02:13:41.933" Score="6" Body="&lt;p&gt;One of the options to measure high temperatures would be to use &lt;a href=&quot;http://en.wikipedia.org/wiki/Thermocouple&quot; rel=&quot;noreferrer&quot;&gt;thermocouples&lt;/a&gt;. This table provides a basic description of &lt;a href=&quot;http://en.wikipedia.org/wiki/Thermocouple#Thermocouple_comparison&quot; rel=&quot;noreferrer&quot;&gt;the types&lt;/a&gt; and the corresponding temperatures that they can sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple search led me to these components.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/270&quot; rel=&quot;noreferrer&quot;&gt;Thermocouple Type-K Glass Braid Insulated&lt;/a&gt; - A mid range thermocouple&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/269&quot; rel=&quot;noreferrer&quot;&gt;Thermocouple Amplifier MAX31855 breakout board&lt;/a&gt; - Board to interface the thermocouple with the Arduino. This is needed as the voltage changes in the thermocouple are extremely small, and the rise is non-linear. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is how the board is connected to the thermocouple.&#xA;  &lt;img src=&quot;https://i.stack.imgur.com/oV37Y.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is also a &lt;a href=&quot;http://learn.adafruit.com/thermocouple/&quot; rel=&quot;noreferrer&quot;&gt;tutorial on Adafruit&lt;/a&gt; that deals with using and interfacing thermocouples. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is an image of the thermocouple interfaced with the Arduino.&#xA;  &lt;img src=&quot;https://i.stack.imgur.com/tvzG0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-05T02:53:47.743" LastActivityDate="2014-03-05T02:53:47.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="617" PostTypeId="2" ParentId="615" CreationDate="2014-03-05T02:13:53.903" Score="7" Body="&lt;p&gt;You probably want to use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Thermocouple&quot; rel=&quot;noreferrer&quot;&gt;thermocouple&lt;/a&gt;. It'll give you the ability to measure much higher temps than regular temperature sensor. You'll also need a IC like the &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/3149&quot; rel=&quot;noreferrer&quot;&gt;MAX6675&lt;/a&gt; to interface with it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The MAX6675 performs cold-junction compensation and digitizes the&#xA;  signal from a type-K thermocouple. The data is output in a 12-bit&#xA;  resolution, SPI™-compatible, read-only format.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This converter resolves temperatures to 0.25°C, allows readings as&#xA;  high as +1024°C, and exhibits thermocouple accuracy of 8 LSBs for&#xA;  temperatures ranging from 0°C to +700°C.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pyNbk.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/MAX6675.pdf&quot; rel=&quot;noreferrer&quot;&gt;Page 6 of the datasheet&lt;/a&gt; has the serial interface protocol information and. You can really just set the Chip Select line and it'll give you 16 bits of information, 12 of which will be the temperature.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-05T02:13:53.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="618" PostTypeId="2" ParentId="601" CreationDate="2014-03-05T02:43:12.093" Score="5" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vxc2g.jpg&quot; alt=&quot;Groove Schematic&quot; /&gt;&#xA;&lt;em&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/File:Stem-diagram-sign.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;From the wiki&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Above is a schematic of a Groove shield. You can see that each of the connectors has two digital pins connected to it and then V (5V) and G (GND). The last two you can connect normally to an Arduino. The first two you connect to the pins that are used in your sketch.&lt;/p&gt;&#xA;&lt;p&gt;Say it says to connect the connector to the top left DIGITAL pin on the board (D6/D7). You'll 7want to connect the pins as followed: Black → GND, Red → 5V, White → D7, and Yellow → D6.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The shield overlaps the pins (i.e. 3-4, 4-5), so that might make things confusing. I think that is a design flaw. If it needs two pins, &lt;em&gt;it should have two connectors&lt;/em&gt;. In the current state, you can connect two things together. &lt;strong&gt;I don't really know how to figure out if it uses all of the ports attached or not. If you don't have to, I would try not to overlap any two grooves.&lt;/strong&gt; You would do this by using two digital ports for every groove &amp;quot;module.&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;You'll also need to have a &lt;a href=&quot;http://www.seeedstudio.com/depot/grove-to-4-pin-254-female-jumper-wire5-pcs-pack-p-1020.html?cPath=178_179&quot; rel=&quot;nofollow noreferrer&quot;&gt;adapter cable&lt;/a&gt; (Link from &lt;em&gt;TheDoctor's&lt;/em&gt; Answer.)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;For analog connections, it applies the same way as digital. G is ground, V is 5v, and A# is an analog pin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Inferencing it:&lt;/h2&gt;&#xA;&lt;p&gt;There's no real cookie cutter way to connect to them. However, the &lt;a href=&quot;http://www.seeedstudio.com/wiki/GROVE_System&quot; rel=&quot;nofollow noreferrer&quot;&gt;wiki&lt;/a&gt; seems to be a decent resource once you figure out how to navigate it. The &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;dust sensor you mentioned&lt;/a&gt; seems to ONLY use digital pin 8. It was connected to the D7/D8 connector on the Groove shield, so the yellow wire could be ignored since it was never used in the sketch.&lt;/p&gt;&#xA;&lt;p&gt;It's hard to do much with this system: it's poorly documented and not uniform at all. Plus, some boards could cause problems that could even lead to damaging components. I would say look at something else.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9689&quot; rel=&quot;nofollow noreferrer&quot;&gt;This dust sensor&lt;/a&gt; seems pretty good, minus the documentation. On &lt;a href=&quot;https://www.sparkfun.com/products/9689&quot; rel=&quot;nofollow noreferrer&quot;&gt;this blog&lt;/a&gt;, they say to do this:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Sharp pin 1 (V-LED)   =&amp;gt; 5V (connected to 150ohm resister) Sharp pin 2&lt;/p&gt;&#xA;&lt;p&gt;(LED-GND) =&amp;gt; Arduino GND pin Sharp pin 3 (LED)     =&amp;gt; Arduino pin 2&lt;/p&gt;&#xA;&lt;p&gt;Sharp pin 4 (S-GND)   =&amp;gt; Arduino GND pin Sharp pin 5 (Vo)      =&amp;gt;&lt;/p&gt;&#xA;&lt;p&gt;Arduino A0 pin Sharp pin 6 (Vcc)     =&amp;gt; 5V&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I can't seem to find the cord for it, but I'm sure there are many others like this online. (It lists the cable needed: a 6-pin, 1.5mm pitch connector. That doesn't seem too hard to find).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Here is a &lt;a href=&quot;https://www.sparkfun.com/products/9483&quot; rel=&quot;nofollow noreferrer&quot;&gt;4x7 segment display&lt;/a&gt; for much cheaper. It does use a lot of pins and need resistors, but multiplexing and resistors aren't that hard to figure out. That's outside of the scope of this question. There might be some other board with a built in IC for controlling a display like that, but I can't seem to find one now.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-05T02:43:12.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="619" PostTypeId="1" AcceptedAnswerId="621" CreationDate="2014-03-05T07:03:24.243" Score="3" ViewCount="2333" Body="&lt;p&gt;I am integrating the MPU-6050 Accelerometer + Gyro sensor into a large project that contains 12 Arduino boards and 6 Raspberry Pis. At some point, I will have to load the output of my MPU-6050 sensor into another application through command line. The process is to be all done with Python and Bash (on the Raspberry Pi side), and so what I need is a way to store the output of my Arduino boards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am currently looking at is the python program &lt;code&gt;ino&lt;/code&gt;. I have used the product for about a year now, and as far as I am aware of, the only way to exit out of serial mode in &lt;code&gt;ino&lt;/code&gt; is by closing the command-line window! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can achieve what I've discussed above? Essentially, all I want is a way to hold the output of my Arduino serial output so I can use it later in other parts of my project.&lt;/p&gt;&#xA;" OwnerUserId="480" LastEditorUserId="65" LastEditDate="2014-03-05T07:31:19.943" LastActivityDate="2014-03-05T14:48:50.470" Title="Redirecting Arduino Serial Output to a File" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="620" PostTypeId="1" AcceptedAnswerId="622" CreationDate="2014-03-05T10:05:42.047" Score="10" ViewCount="30025" Body="&lt;p&gt;I want an I/O pin to return current in a circuit, similarly to the function of ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which of these will achieve what I require?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pinnumber, OUTPUT)&#xA;digitalWrite(pinnumber, LOW)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pinnumber, input)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="481" LastEditorUserId="481" LastEditDate="2014-03-07T06:59:42.000" LastActivityDate="2014-03-07T06:59:42.000" Title="A digital I/O pin as ground" Tags="|pins|arduino-due|current|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="621" PostTypeId="2" ParentId="619" CreationDate="2014-03-05T10:21:00.027" Score="3" Body="&lt;p&gt;Well, I don't know about your &lt;code&gt;ino&lt;/code&gt; program, but here's how I'd do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;get_serial.py&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial, sys&#xA;&#xA;with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:&#xA;    while ser.isOpen():&#xA;        print(ser.readline())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea, here, is to print on &lt;code&gt;stdout&lt;/code&gt; the data coming on the serial line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python get_serial.py /dev/ttyACM0 115200 &amp;gt; output.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or you can do it this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;get_serial.py&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial, sys&#xA;&#xA;with open(sys.argv[3]) as f:&#xA;    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:&#xA;        while ser.isOpen():&#xA;            f.write(ser.readline())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is ran:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python get_serial.py /dev/ttyACM0 115200 output.log&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="65" LastEditDate="2014-03-05T14:48:50.470" LastActivityDate="2014-03-05T14:48:50.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="622" PostTypeId="2" ParentId="620" CreationDate="2014-03-05T10:26:07.987" Score="9" Body="&lt;p&gt;Your first snippet is the correct solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pinnumber,OUTPUT)&#xA;digitalWrite(pinnumber,LOW)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be careful though, you can only sink up to 6mA or 9mA per pin (as per the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardDue&quot;&gt;documentation&lt;/a&gt; [&quot;Input and Output&quot; section], I never tried more). If you need more current, use a transistor (&lt;a href=&quot;http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/transistors&quot;&gt;this&lt;/a&gt; looks like a good example, you just need to invert the output pin to &lt;code&gt;HIGH&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the pin is configured as input it is supposed to be high impedance, not what you want.&lt;/p&gt;&#xA;" OwnerUserId="291" LastEditorUserId="291" LastEditDate="2014-03-05T11:12:10.207" LastActivityDate="2014-03-05T11:12:10.207" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="623" PostTypeId="1" AcceptedAnswerId="625" CreationDate="2014-03-05T11:52:44.643" Score="12" ViewCount="8907" Body="&lt;p&gt;I'm currently changing some libraries to use flash instead of RAM for string storage so that I do not run out of SRAM on a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some strings in the library are declared in this manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *testStringA = &quot;ABC&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is different to how I normally see this done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char testStringB[] = &quot;DEF&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I think that these two are equivalent when declared const and initialised in the declaration. Both work fine in code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I attempted to move these to flash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char *testStringC PROGMEM = &quot;GHI&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then found that this didn't work. It was producing gobbledegook when printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, following the more usual pattern of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char testStringD[] PROGMEM = &quot;JKL&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see in the disassembly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000068 &amp;lt;testStringC&amp;gt;:&#xA;  68:   04 01                                               ..&#xA;&#xA;0000006a &amp;lt;_ZL11testStringD&amp;gt;:&#xA;  6a:   4a 4b 4c 00                                         JKL.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it is clear the pointer and PROGMEM results in the string/array not being initialised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;const int BUFFER_LEN = 20;&#xA;&#xA;const char *testStringA = &quot;ABC&quot;;&#xA;const char testStringB[] = &quot;DEF&quot;;&#xA;const prog_char *testStringC PROGMEM = &quot;GHI&quot;;&#xA;const prog_char testStringD[] PROGMEM = &quot;JKL&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    char buffer[BUFFER_LEN];&#xA;&#xA;    Serial.println(testStringA);&#xA;    Serial.println(testStringB);&#xA;&#xA;    strncpy_P(buffer, testStringC, BUFFER_LEN);&#xA;    Serial.println(buffer);&#xA;&#xA;    strncpy_P(buffer, testStringD, BUFFER_LEN);&#xA;    Serial.println(buffer);&#xA;&#xA;    delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-25T04:12:28.770" Title="Why can I not use pointers instead of array with PROGMEM?" Tags="|progmem|pointer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="624" PostTypeId="2" ParentId="623" CreationDate="2014-03-05T13:07:26.727" Score="3" Body="&lt;p&gt;What this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char *testStringC PROGMEM = &quot;GHI&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does is to write prologue code to copy the characters in the string to SRAM, and then initializes the &lt;em&gt;pointer&lt;/em&gt; stored in flash to this SRAM location. You must load the pointer via normal means, and then dereference the pointer as usual.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *str = pgm_read_word(&amp;amp;testStringC);&#xA;Serial.println(str);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char testStringD[] PROGMEM = &quot;JKL&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;creates the &lt;em&gt;array of characters&lt;/em&gt; in flash, allowing you to access it as expected.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="42" LastEditDate="2014-03-05T16:32:40.537" LastActivityDate="2014-03-05T16:32:40.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="625" PostTypeId="2" ParentId="623" CreationDate="2014-03-05T13:10:11.627" Score="7" Body="&lt;p&gt;Well, this question has been wisely answered in &lt;a href=&quot;https://stackoverflow.com/a/1335836/1290438&quot;&gt;an answer to Stack&amp;nbsp;Overflow question &lt;em&gt;C: differences between char pointer and array&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, what you're declaring as PROGMEM with,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char testStringD[] PROGMEM = &quot;JKL&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is both the array and the memory it points to, that is, the elements of the array, both in current's scope stack. Whereas with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char* testStringC PROGMEM = &quot;GHI&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you declare a PROGMEM pointer to a constant string that may stay elsewhere in memory, but not declared as a PROGMEM string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I did &lt;em&gt;not&lt;/em&gt; test that, but you should try to declare:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const prog_char* testStringC PROGMEM = F(&quot;GHI&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to actually allocate the pointed string within the PROGMEM space. I &lt;em&gt;guess&lt;/em&gt; it should be working, using Arduino's &lt;a href=&quot;http://andybrown.me.uk/wk/wp-content/images//avr-gcc-4.7.0/WString.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;F()&lt;/code&gt; macro&lt;/a&gt;, which adds a lot of boilerplate code to actually have the same result as the array declaration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said in comments, if not in a global context, the &lt;code&gt;PSTR()&lt;/code&gt; macro could be used instead of the &lt;code&gt;F()&lt;/code&gt; macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simpler is better: use the array declaration, not the pointer one!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cf &lt;a href=&quot;https://arduino.stackexchange.com/a/614/379&quot;&gt;that other answer&lt;/a&gt;, the &lt;code&gt;__flash&lt;/code&gt; qualifier is a third solution ;-)&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-03-25T04:12:28.770" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="626" PostTypeId="1" AcceptedAnswerId="629" CreationDate="2014-03-05T13:48:35.653" Score="6" ViewCount="572" Body="&lt;p&gt;How can I run a webserver in a Arduino Uno? I want to use my Arduino to monitor things in my home such as temperature. I want to be able to access this data through the internet.&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-03-05T19:41:55.710" Title="Webserver on Arduino" Tags="|arduino-uno|ethernet|networking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="628" PostTypeId="2" ParentId="564" CreationDate="2014-03-05T13:55:57.310" Score="2" Body="&lt;p&gt;A lot of the options here seem overcomplicated and intrusive.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Color Sensor&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Another option, slightly complicated (but fun) to implement, but unintrusive and easy-to-install, is to build a cheap &lt;a href=&quot;http://www.instructables.com/id/Introduction-29/&quot; rel=&quot;nofollow&quot;&gt;color sensor&lt;/a&gt; and mount it on the wall behind the roll. When you detect the color of the roll (or the absence of the color of TP), it's low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also just &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=540#.UxctDPldWSo&quot; rel=&quot;nofollow&quot;&gt;buy one for $8&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can adjust the threshold by taking advantage of the thinness of TP and the fact that it starts to look a little darker when there's only a few sheets left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If necessary, calibration can be done by pressing a button after a new roll is installed with the bathroom lights on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to make a few adjustments depending on the specifics of your bathroom. If you added some extra complexity and powered it off an AC outlet that was tied to the bathroom light switch, you could only have it powered on when the bathroom lights were on, which would filter out a lot of unreliable data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is very easy to install and doesn't involve modification to the roll itself. You could stick the sensor to the wall with double-sided tape, or put it on a tiny shelf under the roll facing up (or on top facing down).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;IR beam break&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Mount a small IR LED on one side of the dispenser, just above the spool. Mount an IR photo sensor on the other side of the dispenser. When the sensor sees the LED, the roll is low. Could be done with a cheap laser too (e.g. an off the shelf laser pointer on one side and a photosensor on the other; but don't hurt your eyes!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also easy to install (e.g. hot glue to dispenser) and doesn't involve modification to the roll, although the location of the sensors might make them easy to damage when you're replacing rolls.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I also really like the reed sensor and range sensor (BTW: &lt;a href=&quot;http://www.adafruit.com/products/466&quot; rel=&quot;nofollow&quot;&gt;$10 gets you a great short range distance sensor&lt;/a&gt;) options here.&lt;/p&gt;&#xA;" OwnerUserId="486" LastEditorUserId="486" LastEditDate="2014-03-05T14:10:51.983" LastActivityDate="2014-03-05T14:10:51.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="629" PostTypeId="2" ParentId="626" CreationDate="2014-03-05T14:07:53.120" Score="2" Body="&lt;p&gt;You'll need something like the Ethernet Shield to connect your Arduino Uno to a LAN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for webserver functionality, the &lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Webserver Example&lt;/a&gt; sketch does the bulk of what you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ju3X6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &quot;access this data through the internet&quot; part, assuming you want access beyond your LAN; you'll need to perform Port Forwarding on your local router (i.e. allow the &quot;Internet&quot; to see your Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need wifi, then personally I prefer the &lt;a href=&quot;https://www.adafruit.com/products/1469&quot; rel=&quot;nofollow noreferrer&quot;&gt;CC3300&lt;/a&gt; to the Arduino Wifi shield.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="42" LastEditDate="2014-03-05T14:17:11.973" LastActivityDate="2014-03-05T14:17:11.973" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="630" PostTypeId="1" AcceptedAnswerId="645" CreationDate="2014-03-05T16:23:32.863" Score="1" ViewCount="171" Body="&lt;p&gt;I just finished testing a haptic device at university, and when I took it home I got the joy of finding the device not working. Here's what I can trace the problem to: when multiple pins are set to output (pin 2~11), pin 3 writes constantly to high and there is nothing I can do to make it stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a blinker program one pin at a time produces no problems, however when I run a blinker program that cycles through all pins, pin 3 is set to constant high. My actual code is similar in function but more complex. This program below though gets the same error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  for (int c =2; c&amp;lt;12; c++){&#xA;    pinMode(c, OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;  for (int c =2; c&amp;lt;12 ; c++){&#xA;     digitalWrite(c, HIGH);&#xA;     delay(100);&#xA;     digitalWrite(c, LOW);&#xA;     delay(100);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a sign my arduino died? My device had been working for weeks on my prior code with no problem (and no updates). &lt;/p&gt;&#xA;" OwnerUserId="492" LastActivityDate="2014-06-05T00:01:19.817" Title="All voltage directed to pin 3 when multiple pins are set to out put" Tags="|pins|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="631" PostTypeId="2" ParentId="564" CreationDate="2014-03-05T16:32:43.510" Score="0" Body="&lt;p&gt;Another way to do it, in case you just want to for the fun of it would be to put a metal rod inside the roll, and a metal plate on the outside, and measure the capacitance which should change with the TP remaining due to the dielectric constant of the paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that would be taking the &quot;scenic route&quot; for sure. Still, the Arduino can measure capacitance pretty easily and it might even be sensitive enough, and it would stay out of the way because it would just be a metal plate behind the roll and a metal rod in the roll. You might even be able to retrofit an existing holder without it being noticed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easier way would be a stick attached to the shaft of a potentiometer held up by the top of the roll. Less TP, shaft goes lower and turns the pot. Might need a long shaft for leverage because you can't press too hard without impeding the function of pulling toilet paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As AJMansfield suggested, Radioactivity actually is used to measure the thickness of things in industrial settings. If you really wanted to go crazy maybe you could use an extremely low energy radioactive source like a can of that weird tasting salt substitute which is a tiny bit above background levels and average over extremely long times(toilet paper shouldn't change much from hour to hour), so this could actually be a reasonable if expensive way to do things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Infrared beam break sensors are also good, and if you position it right you could get it to block more light the fuller the roll was instead of just giving you and on or off signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Working Proof of concept of the capacitative approach. Only needs an arduino and 2 stiff wires. Precise to about an 8th of an inch, with a lot of noise. Pretty sure you could reliably get at least 1inch accuracy. Measurement time is about a minute. It's really sensitive to it's surroundings. You'd have to make sure anything metal within a foot stayed where it was or use shielding.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float difference;&#xA;unsigned long i;&#xA;unsigned long j;&#xA;unsigned int temp;&#xA;volatile unsigned char blah;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(5,OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; difference =0;&#xA; Serial.print(&quot;Measuring: &quot;);&#xA;&#xA; for(i=0;i&amp;lt;100;i++)&#xA;   {&#xA;     for(j=0;j&amp;lt;5000;j++)&#xA;     {&#xA;       digitalWrite(5,LOW);&#xA;&#xA;       temp=analogRead(A0);&#xA;&#xA;       digitalWrite(5,HIGH);&#xA;&#xA;       temp = analogRead(A0)-temp;&#xA;       if(temp&amp;lt;1024)&#xA;       {&#xA;         difference += temp;&#xA;       }&#xA;&#xA;     }&#xA;     //Random delay every 5000 samples helps avoid problems with interference by staggering the samples to cancel aliasing.&#xA;     delay(random(1,50));&#xA;     Serial.print(&quot;|&quot;);&#xA;&#xA;   }&#xA;   Serial.print(&quot;\n&quot;);&#xA;   Serial.print(&quot;Value: &quot;);&#xA;   Serial.print(difference/500000);&#xA;   Serial.print(&quot;\nMeasurement Complete. Press Enter to begin another test.\n&quot;);&#xA;&#xA;   while(!Serial.available())&#xA;   {&#xA;     blah = 20;&#xA;   }&#xA;   Serial.read();&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/2W5y81AB&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/2W5y81AB&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="168" LastEditorUserId="11" LastEditDate="2014-03-11T19:35:55.160" LastActivityDate="2014-03-11T19:35:55.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="632" PostTypeId="2" ParentId="626" CreationDate="2014-03-05T19:41:55.710" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;Arduino Yún&lt;/a&gt; has been made with this use case in mind. The &lt;a href=&quot;http://arduino.cc/en/Reference/YunBridgeLibrary&quot; rel=&quot;nofollow&quot;&gt;Bridge library&lt;/a&gt; allows your sketch to publish data such as sensor readings: this data is available through a REST api.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you want to publish the temperature of your living room: you'll write something like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Bridge.put(&quot;living_room&quot;, String(19)); //celsius&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then access the data via web with a URL like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;http://arduino.local/data/get/living_room&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get all sensor readings without specifying the key name, with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;http://arduino.local/data/get&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-03-05T19:41:55.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="633" PostTypeId="1" AcceptedAnswerId="634" CreationDate="2014-03-06T00:46:02.330" Score="16" ViewCount="23147" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardUno&quot;&gt;The Arduino Uno Page&lt;/a&gt; doesn't say the temperatures that it can operate in. I'm thinking about placing it outdoors. How can I make sure my Arduino Uno is safe in weather that can reach -20 to 105 degrees Fahrenheit? (-26 to 40 degrees Celsius).&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="510" LastEditDate="2014-03-21T19:29:56.110" LastActivityDate="2018-11-05T09:38:51.233" Title="How cold or hot can my Arduino Uno get?" Tags="|safety|arduino-uno-smd|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="634" PostTypeId="2" ParentId="633" CreationDate="2014-03-06T00:46:02.330" Score="15" Body="&lt;p&gt;&lt;strong&gt;It's not that big of deal.&lt;/strong&gt; &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet.pdf&quot;&gt;The ATmega 328p datasheet&lt;/a&gt; states this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Temperature range: -40 to 85 degrees celsius.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The same goes for the &lt;a href=&quot;http://www.atmel.com/Images/7799S.pdf&quot;&gt;USB chip on the Uno (ATmega 16u2 for UNO R3)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's inside your limits. It probably could go a bit colder than mentioned, but it'll shorten the length of the board a little bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are some things that may go wrong:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;EEPROM might not be stored as long in extreme temperatures. Keep this in mind if you're storing critical data.&lt;/li&gt;&#xA;&lt;li&gt;The voltage regulator may not perform as well in hot conditions&lt;/li&gt;&#xA;&lt;li&gt;The crystal oscillator may not produce exact values. &lt;strike&gt;However, I would imagine that a few hertz more or less wouldn't affect a 16 MHz processor.&lt;/strike&gt; The tolerance is actually a little less than 1%. You may have some issues with serial (baud rate not correct). I would look into any communications like I2C also. (I don't know exactly how the clock line works... it might be fine for I2C.)&lt;/li&gt;&#xA;&lt;li&gt;Resistors/capacitors may not produce the &lt;em&gt;exact&lt;/em&gt; values. I'd imagine that the tolerance won't be more than 8% on resistors: most resistors are rated at 5% for normal temperatures. It does depend on the manufacturer. Capacitors do have a bigger tolerance, but their main purpose is to &quot;smooth&quot; a signal.&lt;/li&gt;&#xA;&lt;li&gt;Extreme cooling/warming may cause minor expansion problems. (Note: it's fine once in a while, but not on an hourly basis of dropping 30 degrees.)&lt;/li&gt;&#xA;&lt;li&gt;Other components (LCDs, etc.) should be kept in mind also when looking at the viability of keeping it outdoors.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So as long as all the other components not on the board will happily run in the temperatures that you need, you should be fine. Also, as with all engineering, values often have added &quot;padding&quot; built in. (i.e. 5% tolerance is often 3-4%, maximum 12V it can run on 12.5V, etc.)*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*&lt;sub&gt;What I mean by that is your Arduino won't explode when it's -41 degrees C. It's not great for it, but most likely you should be fine as long is it isn't a regular occurrence.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-11T20:41:27.550" LastActivityDate="2014-03-11T20:41:27.550" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="635" PostTypeId="2" ParentId="532" CreationDate="2014-03-06T01:17:51.240" Score="2" Body="&lt;p&gt;For program control, I made something of a menu handling framework for one of my projects and &lt;a href=&quot;https://github.com/cacycleworks/chipKIT_ST7735/blob/master/Libraries/ST7735/examples/simpleMenu/simpleMenu.ino&quot; rel=&quot;nofollow&quot;&gt;shared the source on Github&lt;/a&gt;. &lt;em&gt;Note that this is for chipKIT but the menu handling code is generic.&lt;/em&gt; After building my 3rd or 4th huge if-else-if and switch structure, I decided there had to be a better way. &lt;em&gt;&lt;a href=&quot;https://github.com/cacycleworks/chipKIT_ST7735/blob/master/Libraries/ST7735/examples/simpleMenu/menu_credit.txt&quot; rel=&quot;nofollow&quot;&gt;Credit for the source of the static menu structures.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just use the main loop to check the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wanting to say the first step is to get a TFT. If you try it, you'll never go back... I particularly love the Adafruit 1.8&quot; TFT with joystick. Arduinos are slow enough that I cannot recall caring to debounce user input. &lt;/p&gt;&#xA;" OwnerUserId="79" LastEditorUserId="79" LastEditDate="2014-03-06T09:48:45.723" LastActivityDate="2014-03-06T09:48:45.723" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="636" PostTypeId="2" ParentId="333" CreationDate="2014-03-06T01:41:25.377" Score="3" Body="&lt;p&gt;You need to know the response time of your system and the repeatability of your measurements to characterize your data (establish confidence). I suggest taking samples and average them before turning the heater back on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imho, water will not happily stay within 0.5°C. Can you allow for coarse and fine modes? Use a higher PWM for great differences and then lower PWM for when close to target. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once homed in on your target, there are a few means you can try to improve temperature stability. While pre-built things like PID work for many, I normally implement functionality like this manually.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-03-06T01:41:25.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="637" PostTypeId="2" ParentId="633" CreationDate="2014-03-06T05:50:50.773" Score="1" Body="&lt;p&gt;For hot temperature, just follow the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For low temperature, I remember someone last year trying to &lt;a href=&quot;http://blog.arduino.cc/2013/08/29/overclocking-arduino-with-liquid-nitrogen/&quot; rel=&quot;nofollow&quot;&gt;overclock a UNO with liquid nitrogen&lt;/a&gt; so I guess you won't ever meet any problems with low temps :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;http://3.14.by/en/read/arduino-liquid-nitrogen-overclocking&quot; rel=&quot;nofollow&quot;&gt;his blog&lt;/a&gt;, that person shows that he could run his UNO at 65 MHz by reducing temperature to -196°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the process was more complex than just reducing the temperature and checking what happens: a lot of improvements were performed on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blog explains very well how various components can react to cryogenic temperatures; the major issues seemed to be capacitors which capacitance &lt;strong&gt;dramatically&lt;/strong&gt; reduces under low temperatures.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-16T09:35:43.830" LastActivityDate="2014-03-16T09:35:43.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="638" PostTypeId="1" AcceptedAnswerId="643" CreationDate="2014-03-06T08:57:06.017" Score="20" ViewCount="19112" Body="&lt;p&gt;Presumably, one powers an Arduino board with car batteries for long-term operation away from the power grid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be done, and what are the most (1) economic, and (2) reliable ways to do this? Specifically, do any additional risks to short the board with an extraneous discharge exist?&lt;/p&gt;&#xA;" OwnerUserId="213" LastEditorUserId="510" LastEditDate="2014-03-06T20:59:52.643" LastActivityDate="2015-04-25T23:20:52.220" Title="Powering Arduino with car batteries" Tags="|power|battery|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="639" PostTypeId="2" ParentId="638" CreationDate="2014-03-06T09:34:56.323" Score="3" Body="&lt;p&gt;I'm a big fan of USB car chargers for things like this, or USB buck converter boards that you get from ebay.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-03-06T09:34:56.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="640" PostTypeId="1" AcceptedAnswerId="642" CreationDate="2014-03-06T11:16:52.390" Score="5" ViewCount="7827" Body="&lt;p&gt;So am I using an Arduino with a shield to gain some voltage values for an ECG. I am then plotting that data in Python. However whenever I &quot;observe&quot; the serial port, be that through the Arduino serial monitor or in attempting to plot the values of time (using millis()) against ECG (voltage) the values reset, so millis() resets the zero, which is fine, except that some of the older values still show up. Now this is especially a problem in Python because it means the plot is malfunctioning at the start of the script, because it is plotting some of the older values and then after a couple of seconds it resets and the plot looks normal again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To demonstrate this I have recorded it on video and put it on YouTube, here it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=dNpUakcRPec&quot;&gt;https://www.youtube.com/watch?v=dNpUakcRPec&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now initially I thought the problem was with Python or the Pyserial module so I labelled the video as such, but since it occurs in the serial monitor I realised the solution would be in the Arduino sketch. I have tried flushing, didn't work, I have tried even to not start the data till I send a start byte, but this didn't work on Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I could start the Python plotting script and it would skip, or ignore those initial values from the serial port before beginning again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Arduino sketch I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;eHealth.h&amp;gt;&#xA;&#xA;&#xA;unsigned long time;&#xA;// The setup routine runs once when you press reset:&#xA;void setup() {&#xA;  Serial.begin(9600); &#xA;&#xA;}&#xA;&#xA;// The loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  float ECG = eHealth.getECG();&#xA;  time = millis();&#xA;  Serial.print(time);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(ECG, 3); &#xA;  Serial.println(&quot;&quot;); &#xA;&#xA;&#xA;  delay(50);    // wait for 50 millisecond&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="501" LastActivityDate="2021-07-01T14:21:00.663" Title="Arduino serial port reset in Serial monitor &amp; Python" Tags="|arduino-uno|serial|python|reset|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="641" PostTypeId="2" ParentId="640" CreationDate="2014-03-06T12:20:35.623" Score="1" Body="&lt;p&gt;Take a look at &lt;a href=&quot;http://arduino.cc/en/Serial/IfSerial#.Uxhl8xARfxw&quot; rel=&quot;nofollow&quot;&gt;if(Serial)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That makes the Sketch wait for the serial port before continuing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;//Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;; // wait for serial port to connect.&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a sneaking suspicion that may only work on the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so you could try an alternative:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Have Python send something to Arduino after it connects.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wait until this is received in setup(): if (Serial.available() &gt; 0) {...}&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Execute the loop() normally&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// send data only when you receive data:&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;            // read the incoming byte:&#xA;            incomingByte = Serial.read();&#xA;&#xA;            // say what you got:&#xA;            Serial.print(&quot;I received: &quot;);&#xA;            Serial.println(incomingByte, DEC);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-03-06T12:20:35.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="642" PostTypeId="2" ParentId="640" CreationDate="2014-03-06T14:05:10.967" Score="2" Body="&lt;p&gt;The Arduino is designed to reset when a Serial monitor or script connects to it. The best way to mitigate this would be to send the Arduino some kind of &quot;start sending&quot; signal when you connect to the serial port. It would then send the data when your script was ready.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-06T14:05:10.967" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="643" PostTypeId="2" ParentId="638" CreationDate="2014-03-06T17:18:02.817" Score="18" Body="&lt;p&gt;Use a switching regulator such as the &lt;a href=&quot;http://www.ti.com/product/lm2596&quot; rel=&quot;noreferrer&quot;&gt;LM2596&lt;/a&gt;. You can get a ready board from &lt;a href=&quot;http://en.wikipedia.org/wiki/EBay&quot; rel=&quot;noreferrer&quot;&gt;eBay&lt;/a&gt; for about US$1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HyLG8.jpg&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just set the output voltage to 5&amp;nbsp;V and feed the V&lt;sub&gt;cc&lt;/sub&gt; input of Arduino; this bypasses the onboard regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The benefit is that unlike the linear onboard regulator, a switching regulator is very efficient which means less consumption and less generated heat on the regulator. An additional benefit is that it can withstand a higher input voltage (about 35&amp;nbsp;V for the specified regulator), just in case the circuit is used in a vehicle that has 24&amp;nbsp;V batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regulator has already several protections like for &lt;a href=&quot;https://en.wikipedia.org/wiki/Short_circuit&quot; rel=&quot;noreferrer&quot;&gt;short circuiting&lt;/a&gt;, overheating, etc.&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="510" LastEditDate="2014-03-06T21:00:09.533" LastActivityDate="2014-03-06T21:00:09.533" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="645" PostTypeId="2" ParentId="630" CreationDate="2014-03-06T17:48:01.883" Score="1" Body="&lt;p&gt;It is probably a dead chip. Try getting a new ATmega chip for the Arduino (easily found online for ~$5) and see if that fixes it.&lt;/p&gt;&#xA;" OwnerUserId="196" LastEditorUserId="220" LastEditDate="2014-03-06T22:24:09.370" LastActivityDate="2014-03-06T22:24:09.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="646" PostTypeId="1" CreationDate="2014-03-06T19:25:23.807" Score="6" ViewCount="7819" Body="&lt;p&gt;This problem doesn't seen to be very common around the Arduino community.&lt;/p&gt;&#xA;&lt;p&gt;Basically, what's happening is that as soon as I click the upload button, the Arduino IDE tells me that my Arduino board is not connected. What's strange though is that the python application ino is able to upload my code just fine, so my only guess is that there is something wrong with the IDE itself.&lt;/p&gt;&#xA;&lt;p&gt;Here's a copy of the error message I am getting at the time of uploading the sketch:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Binary sketch size: 444 bytes (of a 32,256 byte&#xA;maximum)processing.app.SerialException: Error opening serial port&#xA;'/dev/ttyACM1'.at processing.app.Serial.&amp;lt;init&amp;gt;(Serial.java:178)at&#xA;processing.app.Serial.&amp;lt;init&amp;gt;(Serial.java:77)at&#xA;processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)at&#xA;processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:174)at&#xA;processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)at&#xA;processing.app.Sketch.upload(Sketch.java:1671)at&#xA;processing.app.Sketch.exportApplet(Sketch.java:1627)at&#xA;processing.app.Sketch.exportApplet(Sketch.java:1599)at&#xA;processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)at&#xA;java.lang.Thread.run(Thread.java:744)Caused by:&#xA;gnu.io.UnsupportedCommOperationException: Invalid Parameterat&#xA;gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:213)at&#xA;processing.app.Serial.&amp;lt;init&amp;gt;(Serial.java:163)... 9&#xA;moreprocessing.app.debug.RunnerException: Error opening serial port&#xA;'/dev/ttyACM1'.at&#xA;processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:101)at&#xA;processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:174)at&#xA;processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)at&#xA;processing.app.Sketch.upload(Sketch.java:1671)at&#xA;processing.app.Sketch.exportApplet(Sketch.java:1627)at&#xA;processing.app.Sketch.exportApplet(Sketch.java:1599)at&#xA;processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)at&#xA;java.lang.Thread.run(Thread.java:744)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am expecting to hear a few questions regarding this issue, so I'll go ahead and answer all the questions I can think of.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Is this the first time you trying to connect to the Arduino from this computer?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;No. In fact, I was able to upload the same source code just fine less than two hours ago.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Did you try a different USB cord?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes, I did.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Can you upload the source code from a different computer?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes, I can.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Have you tried removing and reinstalling the IDE?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes, I have.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;Have you tried a different USB port?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes, I have.&lt;/p&gt;&#xA;&lt;p&gt;What seems to be the problem here?&lt;/p&gt;&#xA;" OwnerUserId="480" LastEditorUserId="4854" LastEditDate="2022-05-27T09:25:09.033" LastActivityDate="2022-05-27T09:25:09.033" Title="Arduino disconnecting at upload" Tags="|arduino-uno|serial|uploading|linux|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="647" PostTypeId="2" ParentId="646" CreationDate="2014-03-06T19:36:45.963" Score="4" Body="&lt;p&gt;First of all, you must test if the device that you are trying to access, actually exists. The device file may change when you replug the Arduino. The easiest way to accomplish that is to find the device name in the error message, in this case &lt;code&gt;/dev/ttyACM1&lt;/code&gt;. Then check two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the device file exist in  the &lt;code&gt;/dev&lt;/code&gt; tree? &lt;code&gt;ls -l /dev/ttyACM*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is the Arduino IDE configured to use the correct device? Check under &lt;code&gt;Tools&lt;/code&gt; =&gt; &lt;code&gt;Serial Port&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Maybe another application is using the device. When working on Linux, you can verify this with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsof /dev/ttyUSB0&#xA;COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME&#xA;avrdude 7356   jippie    3u   CHR  188,0      0t0 266450197 /dev/ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;€ fuser /dev/ttyUSB0&#xA;/dev/ttyUSB0:         7356&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where of course you have to replace &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; with the device file as mentioned in the error message. In case of this question &lt;code&gt;/dev/ttyACM1&lt;/code&gt;, but do notice that the number can change when you unplug the board for a moment and then replug it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both results, the &lt;code&gt;7356&lt;/code&gt; is the PID of the process that is locking the device. In my example I was reading flash from the command line, so the output for your specific situation will be different. To identify the process, you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps -fp 7356&#xA;UID      PID  PPID  C STIME TTY          TIME CMD&#xA;jippie  7698 28116  1 20:34 pts/8    00:00:00 avrdude -patmega1280 -carduino -P/dev/ttyUSB002 -b57600 -D -Uflash:r:/tmp/flash:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or a more portable command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ps -ef | grep 7356&#xA;jippie  7698 28116  1 20:34 pts/8    00:00:00 avrdude -patmega1280 -carduino -P/dev/ttyUSB002 -b57600 -D -Uflash:r:/tmp/flash:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-06T20:14:06.070" LastActivityDate="2014-03-06T20:14:06.070" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="649" PostTypeId="1" AcceptedAnswerId="677" CreationDate="2014-03-07T01:35:18.833" Score="0" ViewCount="1338" Body="&lt;p&gt;I'm trying to replicate a waveform exactly using external and timing interrupts. I've got an external that's setup as a 0ms reference, TIMER1 which is used to determine on time, and TIMER2, which sets the low period. Unfortunately, I can't get the pin low for 2ms. TIMER2 must have something wrong with it, but I can't find it. Instead of banging my head against the wall, I thought I'd ask you guys. Anyone know the answer?  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//3 is interrupt for Timing&#xA;//4 through 11 are Time dependent receivers&#xA;//3-11 Pins 12-19&#xA;&#xA;//Current Serial Byte(Letter or Number)&#xA;char incomingByte = 0;&#xA;//Previous Byte in the Serial Chain&#xA;char previousByte = 0;&#xA;&#xA;//Iterator for Interrupt Values&#xA;volatile unsigned int maincount = 0;&#xA;&#xA;//Time of High Period or Timer Duration&#xA;volatile unsigned int timerhigh;&#xA;&#xA;//Output Pin for Timer Waveform&#xA;volatile unsigned int waveout;&#xA;&#xA;//Time for Timer Delay in milliseconds, default tim&#xA;volatile unsigned int groundtime = 0;&#xA;&#xA;//Receiver Pins in an Array, except for 3, which serves as 0 source reference&#xA;int pins[9] =&#xA;{&#xA;  3,4,5,6,7,8,9,10,11&#xA;};&#xA;&#xA;void rising()&#xA;{   &#xA;  // set up Timer 1&#xA;  TCCR1A = 0;  // normal mode&#xA;  TCCR1B = bit(WGM12) | bit(CS11);  // CTC, scale to clock / 8&#xA;  OCR1A = timerhigh;          // time before timer fires&#xA;  TIMSK1 = bit (OCIE1A);            // interrupt on Compare A Match&#xA;}&#xA;&#xA;&#xA;//Sets Pin Low, then sets up another timer interrupt for the jump back to high&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA; //Brings Pin Low for Keypress&#xA; //Serial.println(&quot;We're in Timer 1&quot;);&#xA; pinMode(waveout,OUTPUT);&#xA; digitalWrite(waveout, LOW);&#xA;&#xA; //Stop Timer 1&#xA; TCCR1B = 0;                      // stop timer&#xA; TIMSK1 = 0;                      // cancel timer interrupt&#xA;&#xA; //Disables Interrupts Before Messing&#xA; cli();&#xA; // set up Timer 2&#xA; TCCR2A = 0;  // normal mode&#xA; TCCR2B = 0;&#xA; //  TCCR2A = bit(WGM21) | bit(CS21);  // CTC, scale to clock / 8&#xA; TCCR2A = (1 &amp;lt;&amp;lt; WGM21); //Enables CTC for timer &#xA; TCCR2B = (1 &amp;lt;&amp;lt; CS21); //Sets 8 bit prescaler&#xA; OCR2A = groundtime;          // time before timer fires&#xA; TIMSK2 = (1 &amp;lt;&amp;lt; OCIE2A);&#xA;&#xA; //Cancel Rising Interrupt on D3&#xA; EIFR = bit (INTF1); &#xA; //Reenables interrupts&#xA; sei();&#xA;}&#xA;&#xA;//Timer Interrupt for Low Period&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;//Serial.println(&quot;WE'RE IN TIMER2&quot;);&#xA;//Brings Output pin high&#xA;digitalWrite(waveout, HIGH);&#xA;&#xA;//Stop Timer 2&#xA;TCCR2B = 0;                      // stop timer&#xA;TIMSK2 = 0;                      // cancel timer interrupt  &#xA;&#xA;//Cancel Rising Interrupt on D3&#xA; EIFR = bit (INTF1);   &#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;//Sets all the pins for output use&#xA;for(int i=0;i&amp;lt;8;i++)&#xA;{&#xA;  pinMode(pins[i], INPUT);&#xA;}&#xA;&#xA;//Sets Reference Pin as Input&#xA;pinMode(3,INPUT);&#xA;&#xA;&#xA;//Begins Serial&#xA;Serial.begin(115200);&#xA;&#xA;//Cancels Timer 1&#xA;TCCR1A = 0;  // normal mode&#xA;TCCR1B = 0;  // stop timer&#xA;TIMSK1 = 0;   // cancel timer interrupt&#xA;&#xA;//Cancels Timer 2&#xA; TCCR2A = 0;&#xA; TCCR2B = 0;                      // stop timer&#xA; TIMSK2 = 0;                      // cancel timer interrupt  &#xA;detachInterrupt(1);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  //Time of Ground Drop(2 mS), Universal for all letters and offsets&#xA;  groundtime = 40000;     // spark time (4000 * 500 nS) = 2 mS&#xA;&#xA;  // because of prescaler of 8, each unit is 500 nS (0.5 µS)&#xA;&#xA;     if(Serial.available()&amp;gt; 0);&#xA;    {&#xA;   //Reads Serial Value and assigns to incomingByte&#xA;   incomingByte = Serial.read();&#xA;   attachInterrupt(1,rising,RISING);&#xA;    }&#xA;  //  noInterrupts ();  // atomic change of the time amount&#xA;&#xA;   //In this area, we'll set the output pin to be used by the timing interrupt, &#xA;   //and the time delay off the default waveform present on pin 4&#xA;&#xA;   //We can use switch case arrangement, don't know if that's the optimal setup though    &#xA; switch(incomingByte)&#xA; {&#xA;   default:&#xA;   //Do Nothing&#xA;   break;&#xA;&#xA;   //Cases FOR ALL THE LETTERS&#xA;   case 'a':&#xA;   break;&#xA;   case 'b':&#xA;   break;&#xA;   case 'c':&#xA;   break;&#xA;   case 'd':&#xA;   break;&#xA;   case 'e':&#xA;   break;&#xA;   case 'f':&#xA;   break;&#xA;   case 'g':&#xA;   break;&#xA;   case 'h':&#xA;   break;&#xA;   case 'i':&#xA;   break;&#xA;   case 'j':&#xA;   break;&#xA;   case 'k':&#xA;   break;&#xA;   case 'l':&#xA;   break;&#xA;   case 'm':&#xA;   break;&#xA;   case 'n':&#xA;   break;&#xA;   case 'o':&#xA;   break;&#xA;   case 'p':&#xA;   break;&#xA;   case 'q':&#xA;   break;&#xA;   case 'r':&#xA;   //Output pin 17 Frequency Pin 10&#xA;   //microseconds&#xA;   timerhigh=8000;&#xA;   waveout=9;&#xA;   break;&#xA;   case 's':&#xA;   break;&#xA;   case 't':&#xA;   break;&#xA;   case 'u':&#xA;   break;&#xA;   case 'v':&#xA;   break;&#xA;   case 'w':&#xA;   break;&#xA;   case 'x':&#xA;   break;&#xA;   case 'y':&#xA;   break;&#xA;   case 'z':&#xA;   break;&#xA;&#xA;   //Cases FOR ALL THE NUMBERS&#xA;   case '0':&#xA;   break;&#xA;   case '1':&#xA;   break;&#xA;   case '2':&#xA;   break;&#xA;   case '3':&#xA;   break;&#xA;   case '4':&#xA;   break;&#xA;   case '5':&#xA;   break;&#xA;   case '6':&#xA;   break;&#xA;   case '7':&#xA;   break;&#xA;   case '8':&#xA;   break;&#xA;   case '9':&#xA;   break;&#xA;&#xA;   //Cases FOR ALL THE PUNCTUATION&#xA;   case '.':&#xA;   break;&#xA;   case ',':&#xA;   break;&#xA;   case '!':&#xA;   break;&#xA;   case '&quot;':&#xA;   break;&#xA;   case '#':&#xA;   break;&#xA;   case '$':&#xA;   break;&#xA;   case '%':&#xA;   break;      &#xA; }&#xA;&#xA;//Enables Rising Interrupt for 0ms detection&#xA;//attachInterrupt(1,rising,RISING);&#xA;&#xA;//Reenables interrupts after offset time change&#xA;//interrupts ();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="514" LastEditorUserId="261" LastEditDate="2014-03-14T21:36:17.583" LastActivityDate="2014-03-14T21:36:17.583" Title="Two Timer Interrupts, One Incorrect?" Tags="|interrupt|timers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="650" PostTypeId="1" AcceptedAnswerId="660" CreationDate="2014-03-07T06:34:12.020" Score="4" ViewCount="135" Body="&lt;p&gt;I'm playing around with a SparkFun Redboard (essentially, an Arduino UNO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a simple 5V sensor that I'd been trying to get to work with A2 and analogRead(). Nothing seemed to work. It's supposed to be cycling from 0 to 5V, which should give me values from 0 to 1023, and instead I get constant values of around 260.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In desperation, I tried using other ports. On A0, A1, and A3 I get the signals I expect. On A2, still nada.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the question. Is there something I could have done in configuring things that would have made A2 and only A2 stop reading correctly? If so, how can I reset it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there some other function that I might be using that could interfere with A2? Currently, I'm only using Serial over USB - could that interfere with A2?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or could I simply have fried the port?&lt;/p&gt;&#xA;" OwnerUserId="517" LastEditorUserId="65" LastEditDate="2014-03-07T06:53:49.837" LastActivityDate="2014-03-07T14:16:18.497" Title="Have I fried my A2 port?" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="651" PostTypeId="1" CreationDate="2014-03-07T07:26:43.180" Score="4" ViewCount="5290" Body="&lt;p&gt;When running the board at room temperature (20 C) without any extra cooling mechanisms added, how much can the Arduino Uno be overclocked?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what would I need to change/update to overclock the board?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-07T08:43:35.867" Title="How much can an Uno be overclocked?" Tags="|arduino-uno|performance|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="652" PostTypeId="1" CreationDate="2014-03-07T07:46:39.640" Score="1" ViewCount="568" Body="&lt;p&gt;I have sourced an LPG consumption meter from China with pulse output. I am looking to hook the output up to an arduino to get the consumption metrics. Unfortunately there is not too much documentation available on the unit that I can find. The suppliers inform me that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Black wire(signal 1)&lt;/li&gt;&#xA;&lt;li&gt;Black wire(signal 2)&lt;/li&gt;&#xA;&lt;li&gt;Red wire(earth wire)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So that's a start, I know the unit pulses a signal for every cubic meter of gas consumed. &#xA;What I'm wanting to know is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What are the input [likely] voltages for the unit (or how could I establish this)?&lt;/li&gt;&#xA;&lt;li&gt;How do I wire the unit to an arduino?&lt;/li&gt;&#xA;&lt;li&gt;I can cook up a sketch to do the reading but what is the signal I am looking for?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The mechanical meter itself has a metallic strip on the 0 digit of the wheel (how it achieves the pulsing itself no doubt) so another approach would be something like this &lt;a href=&quot;http://phk.freebsd.dk/Gasdims/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://phk.freebsd.dk/Gasdims/&lt;/a&gt; which is a more accurate option. For this option any suggestions on what photoreflectors are available for the Arduino which could do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sHmUd.jpg&quot; alt=&quot;meter&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/WTD8F.jpg&quot; alt=&quot;output wiring - one red two black&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="518" LastActivityDate="2014-10-12T15:22:58.970" Title="How to interface to LPG consumption meter" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="653" PostTypeId="1" CreationDate="2014-03-07T08:32:43.647" Score="10" ViewCount="5926" Body="&lt;p&gt;Currently I am developing a graphic LCD system to display temperatures, flows, voltages, power and energy in a heat pump system. The use of a graphic LCD means that half of my SRAM and ~75% of my flash have been used up by a screen buffer and strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently displaying min/max/average figures for energy At midnight when the daily figure resets, the system checks if the consumption for the day is above or below the previous minimum or maximum, and stores the value. The average is calculated by dividing the cumulative energy consumption by the number of days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to display the daily average over the last week and month (4 weeks for simplicity) i.e. a rolling average. Currently this involves maintaining an array of values for the last 28 days and calculating an average over the whole array for monthly and last 7 days for weekly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I was doing this using an array of floats (as the energy is in the form &quot;12.12kWh&quot;), but this was using 28 * 4 bytes = 112 bytes (5.4% of SRAM). I don't mind having only a single decimal point of resolution, so I changed to using uint16_t and multiplying the figure by 100. This means that 12.12 is represented as 1212, and I divide by 100 for display purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The size of the array is now down to 56 bytes (much better!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no trivial way to reduce the figure down to a uint8_t that I can see. I could tolerate the loss of a decimal place (&quot;12.1kWh&quot; instead of &quot;12.12kWh&quot;), but consumption is frequently higher than 25.5kWh (255 being the highest value represented by a 8-bit unsigned integer). Consumption has never been below 10.0kWh or above 35.0kWh, so conceivably I could subtract 10 from the stored figures, but I know that one day we will exceed these limits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then tested code to pack 9-bit values into an array. This gives a range of 0-51.2kWh and uses 32 bytes in total. However, accessing an array like this is pretty slow, especially when you have to iterate over all values to calculate an average.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is - is there a more efficient way of calculating a moving average with three windows - lifetime, 28 days and 7 days? Efficiency means smaller in terms of SRAM usage, but without the penalty of huge code. Can I avoid storing all values?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-08T06:41:13.103" LastActivityDate="2014-11-23T05:57:42.630" Title="Efficient algorithm/data structure to calculate moving averages" Tags="|memory-usage|algorithm|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="654" PostTypeId="2" ParentId="651" CreationDate="2014-03-07T08:43:35.867" Score="7" Body="&lt;p&gt;With no active cooling, most ATmega328P will run at 30MHz but you will need to up the supply voltage to ~6V. I have never done this on an Arduino board, just an ATmega328P.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I provided an external clock from a signal generator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to achieve a speed faster than 16MHz is to change the crystal/oscillator/clock input for one faster than 16MHz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this was just an experiment, I didn't alter f_cpu in boards.txt, so all timers etc. would be incorrect. Baud rates would also be incorrect - the only way to upload code was to change back to 16MHz.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-07T08:43:35.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="655" PostTypeId="2" ParentId="653" CreationDate="2014-03-07T09:15:21.353" Score="2" Body="&lt;p&gt;you can use a different method, you keep the current average and then do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;average = (weight1*average+weight2*new_value)/(weight1+weight2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it's not a true rolling average and has different semantics, but it may fit your needs nonetheless &lt;/p&gt;&#xA;&#xA;&lt;p&gt;for a more efficient calculation method for your 9 bits per value solution you could keep the 8 highest bits of the values in an array and separate out the least significant bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t[28] highbits;&#xA;uint32_t lowbits;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to set a value you need to split it out&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void getvalue(uint8_t index, uint16_t value){&#xA;    highbits[index] = value&amp;gt;&amp;gt;1;&#xA;    uint32_t flag = (value &amp;amp; 1)&amp;lt;&amp;lt;index;&#xA;    highbits|=flag;&#xA;    highbits&amp;amp;=~flag;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;resulting in 2 shifts an AND and an OR and a not&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to calculate the average you can use various bit tricks to speed it up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t getAverage(){&#xA;    uint16_t sum=0;&#xA;    for(uint8_t i=0;i&amp;lt;28;i++){&#xA;        sum+=highbits[i];&#xA;    }&#xA;    sum&amp;lt;&amp;lt;=1;//multiply by 2 after the loop&#xA;    sum+=bitcount(lowbits);&#xA;    return sum/28;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can use an &lt;a href=&quot;https://stackoverflow.com/questions/3815165/how-to-implement-bitcount-using-only-bitwise-operators&quot;&gt;efficient parallel bitcount&lt;/a&gt; for the &lt;code&gt;bitcount()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="359" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-03-07T09:55:04.760" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="656" PostTypeId="2" ParentId="653" CreationDate="2014-03-07T09:37:34.870" Score="3" Body="&lt;p&gt;If your data has low standard deviation, then one method would be to sum values over the window, and then keep subtracting the mean from the sum, while adding the new value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would work well if there are &lt;em&gt;no outliers&lt;/em&gt;, thereby leading to the aggregate error tending to zero over time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Pseudocode&#xA;&#xA;count=0&#xA;while new_reading and count&amp;lt;7:&#xA;    sum += new_reading        //Calculate the sum of first 7 values&#xA;    count++&#xA;&#xA;while new_reading:            //Loop till new readings available&#xA;    avg = sum / 7             //Calculate average&#xA;    sum -= avg                //Subtract average from sum&#xA;    sum += new_reading        //Add next reading to sum&#xA;    print avg&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-07T09:37:34.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="658" PostTypeId="1" AcceptedAnswerId="662" CreationDate="2014-03-07T12:29:32.300" Score="22" ViewCount="78691" Body="&lt;p&gt;C on embedded systems has traditionally use structs to hold structured data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino brings C++ to the table, so we can use classes instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say we have two different data structures which could be considered very similar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct &#xA;{&#xA;    int valueOne;&#xA;    int valueTwo;&#xA;    int valueThree;&#xA;} value_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Value&#xA;{&#xA;    public:&#xA;        int valueOne;&#xA;        int valueTwo;&#xA;        int valueThree;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In terms of memory, what difference will this make? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still see the struct technique being used heavily - why is this?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-19T21:52:48.000" LastActivityDate="2020-04-09T13:39:38.837" Title="What overheads and other considerations are there when using a struct vs a class?" Tags="|programming|c++|struct|class|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="659" PostTypeId="2" ParentId="246" CreationDate="2014-03-07T14:14:23.803" Score="13" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/AsheeshR/Microsmooth&quot;&gt;Microsmooth&lt;/a&gt; is a lighweight signal smoothing library currently being developed by me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is still being worked on and the aim is to make it lightweight in terms of memory and fast. The library provides multiple filters for smoothing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple Moving Average&lt;/li&gt;&#xA;&lt;li&gt;Exponential Moving Average&lt;/li&gt;&#xA;&lt;li&gt;Cumulative Moving Average&lt;/li&gt;&#xA;&lt;li&gt;Savitzky Golay Filter&lt;/li&gt;&#xA;&lt;li&gt;Ramer Douglas Pecker Algorithm&lt;/li&gt;&#xA;&lt;li&gt;Kalmogorov Zurbenko Filter&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To use the library, download and add it to the source directory. Also, add the following line to your source file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;microsmooth.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-07T14:14:23.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="660" PostTypeId="2" ParentId="650" CreationDate="2014-03-07T14:16:18.497" Score="2" Body="&lt;p&gt;I wrote a simple program that used all six analog pins as digital outputs, and wired up an LED. All of the pins except A2 would blink the LED. So yes, it is fried.  Thanks.&lt;/p&gt;&#xA;" OwnerUserId="517" LastActivityDate="2014-03-07T14:16:18.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="661" PostTypeId="2" ParentId="638" CreationDate="2014-03-07T14:21:28.740" Score="2" Body="&lt;p&gt;There is also the higher-end Akafugu breadboard power supply - takes input from 7V all the way to 35V, but costs 11$ apiece in the bargain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/IB0rt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://store.akafugu.jp/products/30&quot; rel=&quot;nofollow noreferrer&quot;&gt;Akafugu&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="213" LastEditorUserId="213" LastEditDate="2014-03-07T16:05:30.093" LastActivityDate="2014-03-07T16:05:30.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="662" PostTypeId="2" ParentId="658" CreationDate="2014-03-07T14:41:46.277" Score="18" Body="&lt;p&gt;As taken from the accepted answer from &lt;a href=&quot;https://stackoverflow.com/a/54596/731620&quot;&gt;When should you use a class vs a struct in C++?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The only difference between a class and a struct in C++ is that&#xA;  structs have default public members and bases and classes have default&#xA;  private members and bases. Both classes and structs can have a mixture&#xA;  of public and private members, can use inheritance, and can have&#xA;  member functions.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I would recommend using structs as plain-old-data structures without&#xA;  any class-like features, and using classes as aggregate data&#xA;  structures with private data and member functions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Memory wise the access modifier makes no difference and given the memory constraints of the Arduino, people are less likely to use classes with complex hierarchies, but prefer the POD structs anyway.&lt;/p&gt;&#xA;" OwnerUserId="359" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-03-11T19:56:14.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="663" PostTypeId="2" ParentId="658" CreationDate="2014-03-07T14:53:45.960" Score="10" Body="&lt;p&gt;Unlike C, an instance of a &lt;code&gt;struct&lt;/code&gt; in C++ is an object in exactly the same way as an instance of a &lt;code&gt;class&lt;/code&gt;. From the point-of-view of the compiled code, they are identical. Memory usage, alignment, access times etc. are exactly the same (i.e. there are no overheads).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the programmer's point-of-view, there is a very minor difference. Members of a &lt;code&gt;struct&lt;/code&gt; have public visibility by default, whereas members of a &lt;code&gt;class&lt;/code&gt; have private visibility by default. Otherwise, all language features work the same on both, such as constructors/destructors, inheritance, polymorphism, templates, and operator overloading. You can even derive a &lt;code&gt;struct&lt;/code&gt; from a &lt;code&gt;class&lt;/code&gt;, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite the similarity, it's quite common to see people deliberately using a &lt;code&gt;struct&lt;/code&gt; in C++ for very simple structures, e.g. where it only consists of a few data members, but no functions. A &lt;code&gt;class&lt;/code&gt; would be used for anything more complex. This is purely a matter of convention or personal preference though, and can be used as a subtle indication of the structure's intended complexity.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-07T15:26:19.540" LastActivityDate="2014-03-07T15:26:19.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="664" PostTypeId="2" ParentId="658" CreationDate="2014-03-07T15:29:42.223" Score="4" Body="&lt;p&gt;As other answers have pointed out, your particular &lt;code&gt;struct&lt;/code&gt; and &lt;code&gt;class&lt;/code&gt; are indistinguishable performance wise (There are slight differences in the scopes of the type names, due to the way you defined your struct). The delineation in C++ is not between &lt;code&gt;struct&lt;/code&gt; and &lt;code&gt;class&lt;/code&gt;, but between types that are &lt;em&gt;POD (plain old data)&lt;/em&gt; and types that are not, as explained in &lt;a href=&quot;https://stackoverflow.com/questions/146452/what-are-pod-types-in-c&quot;&gt;this discussion&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="353" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-03-07T15:29:42.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="665" PostTypeId="1" AcceptedAnswerId="667" CreationDate="2014-03-07T16:13:28.637" Score="15" ViewCount="10378" Body="&lt;p&gt;Clearly, an Arduino can be powered with solar panels. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the most optimal configuration? &lt;/li&gt;&#xA;&lt;li&gt;Can you recharge and discharge at the same time?&lt;/li&gt;&#xA;&lt;li&gt;Is LiPO the best battery cache technology, or is there something more durable out there, for fielded deployment?&lt;/li&gt;&#xA;&lt;li&gt;What are the most economic, and reliable ways to do this? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="213" LastEditorUserId="213" LastEditDate="2014-03-15T20:42:22.140" LastActivityDate="2015-06-07T18:47:28.387" Title="Powering Arduino with Solar Panels" Tags="|power|solar|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="666" PostTypeId="2" ParentId="653" CreationDate="2014-03-07T18:00:57.130" Score="1" Body="&lt;p&gt;How about only storing the difference from the previous value? In electronics there is a similar concept called Delta Sigma converter, which is used for DA/AD converters. It relies on the fact that the previous measurement is reasonably near the current one.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-03-07T18:00:57.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="667" PostTypeId="2" ParentId="665" CreationDate="2014-03-07T22:13:32.720" Score="8" Body="&lt;p&gt;&lt;strong&gt;First of all you want to buy some solar panels or cells.&lt;/strong&gt; Although they can be found on eBay for very cheap, but they not be as efficient as they say. I would say try to buy from a reputable dealer to see reviews on the product or trust that they work efficiently. Sparkfun datasheets are generally accurate and can be trusted.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Most optimal configuration: &lt;strong&gt;Do not use a regulator and some sort of step-up booster.&lt;/strong&gt; Try the TPS61200 or TPS61202 chips. They will not &lt;em&gt;regulate&lt;/em&gt; the voltage, they &lt;em&gt;boost&lt;/em&gt; the voltage dynamically. This is much more efficient and therefore generates less heat. They work like a reverse voltage regulator, taking .3V to 5.5V and turning it into anywhere from 1.8V to 5V (xxx0) or 5V exactly (xxx2). Hack a USB B end and just connect the power lines to the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Discharge/charge simultaneously: Yes, however I'm not sure how to. I believe that if you hook up a charger IC and a load, the voltage won't go through the battery, it will go through the path of least resistance. However, your battery wouldn't get charged then. This is outside the scope of the question, so I would recommend EE on how exactly to do this.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is LiPO the best: &lt;strong&gt;Try a Lithium-Ion Battery.&lt;/strong&gt; (A.K.A. Li-ion) According to &lt;a href=&quot;http://www.androidauthority.com/lithium-ion-vs-lithium-polymer-whats-the-difference-27608/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this site&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Although the lithium-polymer battery is sleeker and thinner, lithium-ion batteries have a higher energy density and cost less to manufacture.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Therefore, it seems like Li-ion is the best choice for you. &lt;strong&gt;Note: Since you are dealing with very dense batteries that &lt;a href=&quot;https://www.youtube.com/watch?v=SMy2_qNO2Y0&amp;amp;feature=youtu.be&amp;amp;t=2m&quot; rel=&quot;nofollow noreferrer&quot;&gt;if overvolted can go up into flames [Note: please mute your speakers!]&lt;/a&gt;, make &lt;em&gt;sure&lt;/em&gt; to go with Sparkfun/Adafruit/etc...&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Economic way: If you don't mind a big &quot;homemade&quot; solar panel, go this way. Buy through eBay or a similar site solar &lt;em&gt;cells&lt;/em&gt;. They are small plates that are connected to create a solar panel. Try looking for &quot;grade B&quot; or similar solar cells that work fine, they just may have minor imperfections. It won't be as pretty, but you'll save some cash.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://electronics.stackexchange.com/questions/85757/how-do-i-go-about-building-a-charger-circuit&quot;&gt;this EE.SE post for more information&lt;/a&gt;. One cool thing that I saw was:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is really cool. You can connect the Li-Ion voltage through an op-amp to generate a pulse wave, which can be picked up by your MPU to tell your bot to go charge –  Raaj Oct 18 '13 at 18:44&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not exactly sure how to do this, but it might be useful. I couldn't find anything online about it.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-03-07T22:13:32.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="668" PostTypeId="1" CreationDate="2014-03-08T01:31:24.920" Score="2" ViewCount="148" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5TXBA.png&quot; alt=&quot;Arduino Robotics : Circuit Example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to Arduino and consequently, to circuits. I've been reading Arduino Robotics by Warren and this was a circuit present in the book.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what Warren has said, electricity in the circuit travels from the negative pole to the positive, BUT to imagine it as going the other way for simplicity. So, looking at this circuit... it seems useless to have the resistor placed after the LED, based on the + --&gt; - model. Wouldn't the LED turn on before going through the resistor, rendering the resistor useless?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if this seems like a basic concept, I'm entirely new to this.&lt;/p&gt;&#xA;" OwnerUserId="530" LastEditorUserId="84" LastEditDate="2014-03-08T08:57:08.193" LastActivityDate="2014-03-08T08:57:08.193" Title="Circuit diagram interpretation and electrical flow" Tags="|electricity|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="669" PostTypeId="2" ParentId="653" CreationDate="2014-03-08T01:33:29.813" Score="0" Body="&lt;p&gt;Why couldn't you just add the values together as soon as you obtain them. So what I mean is you get the value for day 1, you divide it by 1 and store it and the 1 somewhere. Then you multiply the 1 by the value and add it to the next value and divide them both by 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing this method would create a rolling average with two or three variable as I can think of. I would write some code but I am new to stackexchange so please bear with me.&lt;/p&gt;&#xA;" OwnerUserId="358" LastActivityDate="2014-03-08T01:33:29.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="670" PostTypeId="2" ParentId="668" CreationDate="2014-03-08T01:54:18.197" Score="6" Body="&lt;p&gt;&lt;strong&gt;Should the Resistor be Placed Before or After the LED?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important thing to remember is that the direct current electricity must flow &lt;em&gt;through&lt;/em&gt; the circuit to be useful. Since the resistor is part of the circuit (meaning that there isn't another path for the current to take) it resists the overall flow, thereby helping to protect the LED. Whether before or after the LED, it would still be in the circuit, and would therefore still reduce current flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Visualizing the Flow of Water&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think of it like a water hose, where the LED is a flow meter and the resistor is your foot. If you step on the hose before the flow meter it will cause the overall flow to slow down. Stepping on the hose after the flow meter but before the nozzle will have the same result, as the water must pass through the entire length of the hose before being released.&lt;/p&gt;&#xA;" OwnerUserId="225" LastActivityDate="2014-03-08T01:54:18.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="672" PostTypeId="1" AcceptedAnswerId="675" CreationDate="2014-03-08T04:04:14.447" Score="3" ViewCount="4001" Body="&lt;p&gt;Duplicate of &lt;a href=&quot;https://electronics.stackexchange.com/q/102224/38392&quot;&gt;this question&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to drive an 8x8 LED matrix with an arduino nano, but I can't get the LEDs to display what I tell it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;http://www.aliexpress.com/store/product/Free-shipping-10-pcs-8-8-3-75MM-Red-16P-dot-matrix-module-Dimensions-38-38/605870_879542981.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; LED Matrix&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int row1 = 2;&#xA;int row2 = 3;&#xA;int row3 = 4;&#xA;int row4 = 5;&#xA;int row5 = 6;&#xA;int row6 = 7;&#xA;int row7 = 8;&#xA;int row8 = 9;&#xA;&#xA;int col1 = 10;&#xA;int col2 = 11;&#xA;int col3 = 12;&#xA;int col4 = 18;&#xA;int col5 = 14;&#xA;int col6 = 15;&#xA;int col7 = 16;&#xA;int col8 = 17;&#xA;&#xA;void setup() {&#xA;  int i;&#xA;  for(i = 2; i &amp;lt;= 18; i++) {&#xA;    pinMode(i,OUTPUT);&#xA;  }&#xA;  for(i = 2; i &amp;lt;= 9; i++) {&#xA;    digitalWrite(i, HIGH);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int display [8][8] = {&#xA;  {1,0,0,0,0,0,0,0},&#xA;  {0,1,0,0,0,0,0,0},&#xA;  {0,0,1,0,0,0,0,0},&#xA;  {0,0,0,1,0,0,0,0},&#xA;  {0,0,0,0,1,0,0,0},&#xA;  {0,0,0,0,0,1,0,0},&#xA;  {0,0,0,0,0,0,1,0},&#xA;  {0,0,0,0,0,0,0,1}&#xA;  };&#xA;&#xA;  updateScreen(display);&#xA;}&#xA;&#xA;void updateScreen(int screen[8][8]) {&#xA;&#xA;  Serial.begin(9600);&#xA;  int i;&#xA;  for (i = row1; i &amp;lt;= row8; i++) {&#xA;    Serial.println(i-1); &#xA;    digitalWrite(i, LOW);&#xA;      digitalWrite(col8, screen[i-2][0]);&#xA;      Serial.print(screen[i-2][0]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col7, screen[i-2][1]);&#xA;      Serial.print(screen[i-2][1]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col6, screen[i-2][2]);&#xA;      Serial.print(screen[i-2][2]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col5, screen[i-2][3]);&#xA;      Serial.print(screen[i-2][3]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col4, screen[i-2][4]);&#xA;      Serial.print(screen[i-2][4]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col3, screen[i-2][5]);&#xA;      Serial.print(screen[i-2][5]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col2, screen[i-2][6]);&#xA;      Serial.print(screen[i-2][6]); Serial.print(&quot;|&quot;); &#xA;      digitalWrite(col1, screen[i-2][7]);&#xA;      Serial.println(screen[i-2][7]);&#xA;      delay(1);&#xA;      blank();&#xA;    digitalWrite(i, HIGH);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void blank() {&#xA;  digitalWrite(col1, LOW);&#xA;  digitalWrite(col2, LOW);&#xA;  digitalWrite(col3, LOW);&#xA;  digitalWrite(col4, LOW);&#xA;  digitalWrite(col5, LOW);&#xA;  digitalWrite(col6, LOW);&#xA;  digitalWrite(col7, LOW);&#xA;  digitalWrite(col8, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;1 &#xA;1|0|0|0|0|0|0|0 &#xA;2 &#xA;0|1|0|0|0|0|0|0 &#xA;3 &#xA;0|0|1|0|0|0|0|0 &#xA;4 &#xA;0|0|0|1|0|0|0|0 &#xA;5 &#xA;0|0|0|0|1|0|0¾j &#xA;6 &#xA;0|0|0|0|0|1|0|0 &#xA;7 &#xA;0|0|0|0|0|0|1|0 &#xA;8 &#xA;0|0|0|0|0|0|0|1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I can tell that the error (probably) isn't my wiring, because those array values are clearly wrong, I have no idea where the &lt;code&gt;¾j&lt;/code&gt; is coming from.&lt;/p&gt;&#xA;" OwnerUserId="533" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-03-08T15:02:20.803" Title="Arduino LED matrix and 2D array, data seems to be corrupting" Tags="|programming|led|arduino-nano|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="673" PostTypeId="2" ParentId="672" CreationDate="2014-03-08T04:39:56.710" Score="2" Body="&lt;p&gt;Your initial problem can be sorted out by using a longer &lt;code&gt;delay&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void updateScreen(int screen[8][8]) {&#xA;&#xA;  Serial.begin(9600);&#xA;  int i;&#xA;  ........&#xA;      delay(100); //Longer time duration&#xA;      blank();&#xA;    digitalWrite(i, HIGH);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as the chess pattern is concerned, it displays correctly for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;  int display [8][8] = {&#xA;  {1,0,1,0,1,0,1,0},&#xA;  {0,1,0,1,0,1,0,1},&#xA;  {1,0,1,0,1,0,1,0},&#xA;  {0,1,0,1,0,1,0,1},&#xA;  {1,0,1,0,1,0,1,0},&#xA;  {0,1,0,1,0,1,0,1},&#xA;  {1,0,1,0,1,0,1,0},&#xA;  {0,1,0,1,0,1,0,1}&#xA;  };&#xA;&#xA;  updateScreen(display);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check your array declarations for errors.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-08T04:39:56.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="674" PostTypeId="1" CreationDate="2014-03-08T13:16:43.187" Score="4" ViewCount="467" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://ied.rca.ac.uk/de-computation/space-replay&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Space Replay&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;A hovering object that explores and manipulates transitional public&#xA;spaces with particular acoustic properties. By constantly recording&#xA;and replaying these ambient sounds, the levitating sphere produces a&#xA;delayed echo of human activity.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://blog.arduino.cc/wp-content/uploads/2014/03/replay.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In this project, the Arduino board and an &lt;a href=&quot;https://www.adafruit.com/products/94&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit Wave Shield&lt;/a&gt; is used. The Wave shield is not designed to record audio however, they say that they use the board for both &lt;em&gt;recording&lt;/em&gt; and playback.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The sphere responds sonically to people and its surroundings by means of a battery-powered Arduino, an Adafruit Wave Shield hacked to record and playback audio on-the-fly and a small speaker.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This generates a few questions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How would this be done?&lt;/li&gt;&#xA;&lt;li&gt;Where would the microphone be placed inside the balloon for decent audio capture?&lt;/li&gt;&#xA;&lt;li&gt;Would there be a better way to design this?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-07-04T18:02:04.847" Title="How does the Space Replay record audio?" Tags="|sensors|shields|project-critique|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="675" PostTypeId="2" ParentId="672" CreationDate="2014-03-08T15:02:20.803" Score="2" Body="&lt;p&gt;Because of my psychic abilities*, I am able to tell that you actually used &lt;code&gt;.&lt;/code&gt; in a few places you should have used &lt;code&gt;,&lt;/code&gt; in your array initialization. Replacing the &lt;code&gt;,&lt;/code&gt;s with &lt;code&gt;.&lt;/code&gt;s should fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sup&gt;*&lt;a href=&quot;https://arduino.stackexchange.com/questions/672/arduino-led-matrix-and-2d-array-data-seems-to-be-corrupting#comment1193_672&quot;&gt;Okay, okay, not really.&lt;/a&gt;&lt;/sup&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-03-08T15:02:20.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="676" PostTypeId="2" ParentId="674" CreationDate="2014-03-08T15:36:21.713" Score="0" Body="&lt;p&gt;As jippie said, you can use the Arduinos ADC to record audio, and presumably save that to the Arduino's RAM (the SD card is probably too slow for directly saving it). Then it writes the buffer to the SD card.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-08T15:36:21.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="677" PostTypeId="2" ParentId="649" CreationDate="2014-03-08T17:59:14.100" Score="5" Body="&lt;p&gt;Turns out the problem was that timer 0 and 2 on the arduino uno are 8 bit. Set a different prescaler and I'm golden&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// set up Timer 2&#xA;    TCCR2A = 0;  // normal mode&#xA;    TCCR2B = 0;&#xA;    //  TCCR2A = bit(WGM21) | bit(CS21);  // CTC, scale to clock / 8&#xA;    TCCR2A = (1 &amp;lt;&amp;lt; WGM21); //Enables CTC for timer &#xA;&#xA;    TCCR2B |= (1 &amp;lt;&amp;lt; CS21); &#xA;    TCCR2B |= (1 &amp;lt;&amp;lt; CS22); //Sets 256 bit prescaler&#xA;    TCCR2B |= (0 &amp;lt;&amp;lt; CS20); &#xA;    OCR2A = groundtime;    // time before rising edge&#xA;    TIMSK2 = (1 &amp;lt;&amp;lt; OCIE2A);&#xA;    //Cancel Rising Interrupt on D3&#xA;    EIFR = bit (INTF1); &#xA;    //Reinables interrupts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="514" LastActivityDate="2014-03-08T17:59:14.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="678" PostTypeId="1" AcceptedAnswerId="679" CreationDate="2014-03-02T13:13:16.097" Score="0" ViewCount="272" Body="&lt;p&gt;So I am turning a relay on and off with my Arduino. I am using python to control it but wrote the simple basic code in the Arduino IDE. I am able to send 5 or 0 volts to the pin. My question is, how can I turn something on and off that requires more than 5 volts to turn on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you. &lt;/p&gt;&#xA;" OwnerUserId="539" OwnerDisplayName="user3343579" LastEditorUserId="11" LastEditDate="2014-03-09T05:30:15.857" LastActivityDate="2014-03-09T05:30:15.857" Title="Connecting Something Big to an Arduino - Sending more than 5V" Tags="|relay|transistor|" AnswerCount="1" CommentCount="2" ClosedDate="2014-03-09T05:28:26.683" ContentLicense="CC BY-SA 3.0" />
  <row Id="679" PostTypeId="2" ParentId="678" CreationDate="2014-03-02T15:21:59.200" Score="1" Body="&lt;p&gt;Use a transistor, amplifier, opto-isolator or if you can drive a 5V relay use that relay to drive a higher voltage/current item item.&lt;/p&gt;&#xA;" OwnerDisplayName="Steve Barnes" LastActivityDate="2014-03-02T15:21:59.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="681" PostTypeId="2" ParentId="674" CreationDate="2014-03-09T05:38:12.913" Score="4" Body="&lt;p&gt;It seems to be possible to record with the shield using a library called &lt;a href=&quot;https://code.google.com/p/waverp/&quot; rel=&quot;nofollow&quot;&gt;waverp&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WaveRP is an Arduino library for recording and playing Wave files with&#xA;  the Adafruit Wave Shield. It records 8-bit mono files at 4,000 to&#xA;  44,100 samples per second.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some details &lt;a href=&quot;https://www.adafruit.com/products/94&quot; rel=&quot;nofollow&quot;&gt;adafruit blog&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It records 8-bit mono files at 4,000 to 44,100 samples per second.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-09T05:38:12.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="682" PostTypeId="1" CreationDate="2014-03-09T09:00:25.003" Score="62" ViewCount="107902" Body="&lt;p&gt;The use of &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt; seems pretty rare in the Arduino world. It is used in pure AVR C much more often, but still with caution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a really bad idea to use &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt; with Arduino?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorDisplayName="user24204" LastEditDate="2016-08-24T19:46:14.690" LastActivityDate="2023-12-12T16:03:33.617" Title="Is using malloc() and free() a really bad idea on Arduino?" Tags="|programming|sram|eeprom|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="683" PostTypeId="2" ParentId="652" CreationDate="2014-03-09T12:42:12.190" Score="2" Body="&lt;p&gt;Start with earthing the red (!?) wire to the ground of the arduino.&#xA;Apply 5 volts via a 10k resistor to one of the black wires and also connect the black wire to the arduino as well.&#xA;Basically :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5V ----(10K resistor)---+---Black wire----( Gas Meter)-----ground&#xA;                        |                              &#xA;                        |                             &#xA;                        +--- arduino digital input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should either get a high or a low signal. Try the other black wire, it might be inverted (as in high and then pulse low, vs low and then pulse high).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that, pop the top off that cover and have a poke around. Might give you a clue as to what's what.&lt;/p&gt;&#xA;" OwnerUserId="546" LastActivityDate="2014-03-09T12:42:12.190" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="684" PostTypeId="5" CreationDate="2014-03-09T13:20:04.687" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-03-09T13:20:04.687" LastActivityDate="2014-03-09T13:20:04.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="685" PostTypeId="4" CreationDate="2014-03-09T13:20:04.687" Score="0" Body="Use this tag when you are looking for feedback, suggestions, improvements or alternatives to a specific aspect of your working project. This tag should not be used for early design questions; also see the tag [system-design]." OwnerUserId="65" LastEditorUserId="27346" LastEditDate="2019-12-29T17:28:24.917" LastActivityDate="2019-12-29T17:28:24.917" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="686" PostTypeId="1" CreationDate="2014-03-09T16:02:25.323" Score="6" ViewCount="343" Body="&lt;p&gt;What do I need to build a shield capable of receiving 1080p video from USB camera, timestamp each frame and send the frame to memory card?&lt;/p&gt;&#xA;" OwnerUserId="550" LastEditorUserId="65" LastEditDate="2014-03-09T16:22:56.430" LastActivityDate="2014-03-11T11:49:52.457" Title="Is it possible to build a 1080p OSD webcam shield?" Tags="|shields|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="687" PostTypeId="2" ParentId="682" CreationDate="2014-03-09T17:07:19.480" Score="19" Body="&lt;p&gt;Typically, when writing Arduino sketches, you will avoid dynamic allocation (be it with &lt;code&gt;malloc&lt;/code&gt; or &lt;code&gt;new&lt;/code&gt; for C++ instances), people rather use global -or &lt;code&gt;static&lt;/code&gt;- variables, or local (stack) variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using dynamic allocation can lead to several problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;memory leaks (if you lose a pointer to a memory you previously allocated, or more likely if you forget to free the allocated memory when you don't need it anymore)&lt;/li&gt;&#xA;&lt;li&gt;heap fragmentation (after several &lt;code&gt;malloc&lt;/code&gt;/&lt;code&gt;free&lt;/code&gt; calls) where the heap grows bigger thant the actual amount of memory allocated currently&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In most situations I have faced, dynamic allocation was either not necessary, or could be avoided with macros as in the following code sample:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MySketch.ino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUFFER_SIZE 32&#xA;#include &quot;Dummy.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Dummy.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Dummy&#xA;{&#xA;    byte buffer[BUFFER_SIZE];&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without &lt;code&gt;#define BUFFER_SIZE&lt;/code&gt;, if we wanted &lt;code&gt;Dummy&lt;/code&gt; class to have a non-fixed &lt;code&gt;buffer&lt;/code&gt; size, we would have to use dynamic allocation as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Dummy&#xA;{&#xA;    const byte* buffer;&#xA;&#xA;    public:&#xA;    Dummy(int size):buffer(new byte[size])&#xA;    {&#xA;    }&#xA;&#xA;    ~Dummy()&#xA;    {&#xA;        delete [] bufer;&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, we have more options than in the first sample (e.g. use different &lt;code&gt;Dummy&lt;/code&gt; objects with different &lt;code&gt;buffer&lt;/code&gt; size for each), but we may have heap fragmentation issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the use of a destructor to ensure dynamically allocated memory for &lt;code&gt;buffer&lt;/code&gt; will be freed when a &lt;code&gt;Dummy&lt;/code&gt; instance is deleted.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-09T18:53:37.703" LastActivityDate="2014-03-09T18:53:37.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="688" PostTypeId="2" ParentId="682" CreationDate="2014-03-09T18:32:03.697" Score="9" Body="&lt;p&gt;Using dynamic allocation (via &lt;code&gt;malloc&lt;/code&gt;/&lt;code&gt;free&lt;/code&gt; or &lt;code&gt;new&lt;/code&gt;/&lt;code&gt;delete&lt;/code&gt;) isn't inherently bad as such. In fact, for something like string processing (e.g. via the &lt;code&gt;String&lt;/code&gt; object), it's often quite helpful. That's because many sketches use several small fragments of strings, which eventually get combined into a larger one. Using dynamic allocation lets you use only as much memory as you need for each one. In contrast, using a fixed-size static buffer for each one could end up wasting a lot of space (causing it to run out of memory much faster), although it depends entirely on the context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all of that being said, it's very important to make sure memory usage is predictable. Allowing the sketch to use arbitrary amounts of memory depending on run-time circumstances (e.g. input) can easily cause a problem sooner or later. In some cases, it might be perfectly safe, e.g. if you &lt;em&gt;know&lt;/em&gt; the usage will never add up to much. Sketches can change during the programming process though. An assumption made early-on could be forgotten when something is changed later, resulting in an unforeseen problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For robustness, it's usually better to work with fixed-size buffers where possible, and design the sketch to work explicitly with those limits from the outset. That means any future changes to the sketch, or any unexpected run-time circumstances, should hopefully not cause any memory problems.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-09T18:32:03.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="689" PostTypeId="1" CreationDate="2014-03-09T18:53:20.203" Score="5" ViewCount="13267" Body="&lt;p&gt;I am using the Arduino IDE to program the attiny85. I want to take an incoming analog reading, then based on that reading, output a specific PWM value. Here's my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/q83mB.jpg&quot; alt=&quot;my circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// to run on attiny85&#xA;&#xA;const byte pwmPin = 0;&#xA;const byte analogInPin = A2;&#xA;&#xA;void setup() {&#xA;  pinMode(pwmPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  int analogIn = analogRead(analogInPin);&#xA;  analogWrite(pwmPin, analogIn);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be very simple- I have no problems uploading code to the attiny85, and no problems with simple tests like outputting a specific PWM value (not based on the analog read). but when I try to combine the two- read, then write that value, I can't seem to get things to work. In this circuit for example- I get a reading of 1023 (5v) on the arduino micro- instead of a reading of ~ 790 (3.85v) which is what I should expect. I've used a multimeter to verify the voltages in this circuit- so I think I must either be doing something wrong with my expectations of how to wire up or program the attiny85.&lt;/p&gt;&#xA;" OwnerUserId="555" LastEditorUserId="42" LastEditDate="2015-03-06T22:58:09.990" LastActivityDate="2018-12-14T14:42:53.720" Title="attiny85 and arduino - analogRead + pwmOut" Tags="|programming|pwm|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="691" PostTypeId="2" ParentId="564" CreationDate="2014-03-09T22:35:33.980" Score="7" Body="&lt;p&gt;I think 'Arluin' and 'jmathew' have the right idea.&#xA;Use a lever resting on the top of the roll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would do it slightly different however.&#xA;Rather than rely on contacts shutting you can use a potentiometer.&#xA;With this system you can measure the amount left instead of simply being notified when it gets low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a contact such as those suggested already, you might get paper stuck in the contact as it closes and then low paper would not be detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You may need a weight, shown in blue on the diagram, to push the lever down as the roll is used)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to try and get the pot as close to the roll as possible for maximum swing of the pot and therefore maximum resolution of amount remaining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing you might want is some kind of roller on the end of the lever so that the paper roll can move easily with little drag where the lever contacts the paper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3RoTx.png&quot; alt=&quot;Proposed setup&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="558" LastActivityDate="2014-03-09T22:35:33.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="692" PostTypeId="1" CreationDate="2014-03-09T23:28:49.490" Score="10" ViewCount="28926" Body="&lt;p&gt;I have been using the Arduino to record some data. In my Arduino sketch I also used the &lt;code&gt;millis()&lt;/code&gt; function so I can keep track of the time at which each value I am measuring is taken. However, I noticed that the timing isn't correct. For example 30 seconds in real life only comes out as 10 seconds (made up example). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct in saying that the Arduino delay function affects the time keeping using &lt;code&gt;millis()&lt;/code&gt;? In other words suppose I have a delay of 50ms, does that mean the &lt;code&gt;millis()&lt;/code&gt; function stops for that duration as well and then continues and so on for the duration of the connection? I noticed this when I tried plotting some data and finding that the frequency of the peaks in my data was too frequent given the time which had passed by. So I want to know if that is the reasoning for this mismatch of timing and if so, how do I fix this so that I can keep the time each sample occurs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give some context here is my sketch: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;eHealth.h&amp;gt;    &#xA;&#xA;unsigned long time;&#xA;// The setup routine runs once when you press reset:&#xA;void setup() {&#xA;  Serial.begin(9600);  &#xA;}&#xA;&#xA;// The loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  float ECG = eHealth.getECG();&#xA;  time = millis();&#xA;  Serial.print(time);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(ECG, 5); &#xA;  Serial.println(&quot;&quot;);    &#xA;&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="501" LastEditorUserId="275" LastEditDate="2014-03-10T09:13:51.480" LastActivityDate="2016-11-16T10:59:07.720" Title="Arduino time keeping using millis() is not accurate or correct?" Tags="|arduino-uno|programming|time|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="693" PostTypeId="2" ParentId="689" CreationDate="2014-03-10T08:18:00.113" Score="8" Body="&lt;p&gt;Analog read is 10-bits (2^10 = 0-1023 range), analog write is 8-bits (2^8 = 0-255 range). Ditch the lower two bits of the result either by doing: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogIn = analogIn &amp;gt;&amp;gt; 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can be shortened to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogIn &amp;gt;&amp;gt;= 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can use the rather complex map function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogIn = map( analogIn(0, 1023, 0, 255) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="136" LastEditorUserId="46" LastEditDate="2014-03-11T11:48:43.817" LastActivityDate="2014-03-11T11:48:43.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="694" PostTypeId="2" ParentId="692" CreationDate="2014-03-10T09:15:13.077" Score="10" Body="&lt;p&gt;&lt;code&gt;millis()&lt;/code&gt; is interrupt driven so &lt;code&gt;delay()&lt;/code&gt; won't impact it, at least not on an ATmega based board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That isn't to say that &lt;code&gt;millis()&lt;/code&gt; is totally accurate either. Each tick of the timer is not exactly 1ms, but is 1.024ms. This error gradually accumulates until a correction is made. This can be seen in the implementation of the TIMER0_OVF (timer 0 overflow) interrupt handler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another source of inaccuracy is the oscillator/crystal itself, which is not exactly 16MHz. It is pretty close though, and as long as temperature doesn't change too much, is relatively stable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above means that you might be about 1ms out when using &lt;code&gt;millis()&lt;/code&gt;. This doesn't sound like your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another potential issue would be what &lt;code&gt;getECG()&lt;/code&gt; is doing - it might be very slow.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float eHealthClass::getECG(void)&#xA;    {&#xA;        float analog0;&#xA;        // Read from analogic in. &#xA;        analog0=analogRead(0);&#xA;        // binary to voltage conversion&#xA;        return analog0 = (float)analog0 * 5 / 1023.0;   &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;analogRead()&lt;/code&gt; is slow, but not so slow as to impact a loop like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem I have seen people have is when they change the clock speed but don't correctly change boards.txt. This means that the constants used in the &lt;code&gt;millis()&lt;/code&gt; implementation are wrong and the times are wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you actually want to read values every 50ms, a much better way of implementing this is to do the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static long lastUpdate;&#xA;&#xA;if (millis() - lastUpdate &amp;gt; 50)&#xA;{&#xA;    lastUpdate = millis();&#xA;    //Do stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We'd really need to see the timestamps you are getting. If you actually seeing 30s showing as 10s, then there is something else at work.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-10T09:28:59.460" LastActivityDate="2014-03-10T09:28:59.460" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="695" PostTypeId="2" ParentId="638" CreationDate="2014-03-10T10:42:31.183" Score="2" Body="&lt;p&gt;&quot;Practical Arduino book&quot; has a very interesting circuit for this purpose: &lt;a href=&quot;http://www.practicalarduino.com/projects/vehicle-telemetry-platform&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.practicalarduino.com/projects/vehicle-telemetry-platform&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I've recreated it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.bougakov.com/post/44802340184/ok-enough-with-preparations-lets-make-some-real&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://25.media.tumblr.com/8c2d23c56eb465d055e4d8c8406017c8/tumblr_mjb5327Gzh1s6jcaao1_1280.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses LM2940CT and huge electrolytic cap - even if supply voltage drops, you'll have about a second to shut down your Arduino gracefully (close files on SD properly, and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Arduino Cookbook&quot; (2nd ed.) has a chapter with examples on how to reduce Arduino's power consumption to absolute minimum - have a look at it, too.&lt;/p&gt;&#xA;" OwnerUserId="562" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.220" LastActivityDate="2014-03-10T10:42:31.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="696" PostTypeId="2" ParentId="686" CreationDate="2014-03-10T11:09:56.837" Score="5" Body="&lt;p&gt;None of the ATmega based boards have the hardware (in terms of acting as a USB host) or power (in terms of handling probably compressed 1080p video).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Potentially one of the ARM boards could do this. The Arduino Due can act as a host, but it sounds fairly experimental, and none of them will have drivers to connect to the camera.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a shield was developed to do this, it would have so much more power than the Arduino that the Arduino would probably better be viewed as a slave to the other device.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-11T11:49:52.457" LastActivityDate="2014-03-11T11:49:52.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="698" PostTypeId="2" ParentId="564" CreationDate="2014-03-10T17:45:36.740" Score="5" Body="&lt;p&gt;You could just crack open one of those playing birthday cards and adapt the switch to the holder arm. Once you hear 'Happy Birthday&quot; chiming from the toilet you know you're in trouble! (and because they are very low-power these things chime on forever ;-) ) I've shown a LED setup here but you get the idea...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oQBrx.jpg&quot; alt=&quot;happy birthday&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="569" LastActivityDate="2014-03-10T17:45:36.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="699" PostTypeId="1" CreationDate="2014-03-10T21:30:33.983" Score="17" ViewCount="131449" Body="&lt;p&gt;I am beginning to get a bit confused about sampling rates and baudrates etc. I have this Arduino code: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;eHealth.h&amp;gt;&#xA;&#xA;extern volatile unsigned long timer0_overflow_count;&#xA;float fanalog0;&#xA;int analog0;&#xA;unsigned long time;&#xA;&#xA;&#xA;byte serialByte;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() { &#xA;  while (Serial.available()&amp;gt;0){  &#xA;    serialByte=Serial.read();&#xA;    if (serialByte=='S'){        &#xA;      while(1){&#xA;        fanalog0=eHealth.getECG();  &#xA;        // Use the timer0 =&amp;gt; 1 tick every 4 us&#xA;        time=(timer0_overflow_count &amp;lt;&amp;lt; 8) + TCNT0;        &#xA;        // Microseconds conversion.&#xA;        time=(time*4);   &#xA;        //Print in a file for simulation&#xA;        //Serial.print(time);&#xA;        //Serial.print(&quot; &quot;);&#xA;        Serial.print(fanalog0,5);&#xA;        Serial.print(&quot;\n&quot;);&#xA;&#xA;        if (Serial.available()&amp;gt;0){&#xA;          serialByte=Serial.read();&#xA;          if (serialByte=='F')  break;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since there is no delay interrupt, what is the sampling rate/frequency? Is it based on the Arduino ADC speed? When I increase the baudrate am I increasing the sampling frequency or just the rate at which I send data over the serial port?&lt;/p&gt;&#xA;" OwnerUserId="501" LastEditorUserId="185" LastEditDate="2014-03-10T21:40:33.167" LastActivityDate="2020-08-19T19:34:05.777" Title="How do I know the sampling frequency?" Tags="|arduino-uno|serial|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="700" PostTypeId="2" ParentId="699" CreationDate="2014-03-10T22:14:32.777" Score="3" Body="&lt;p&gt;Each loop you are printing 8 characters over a 9600bps serial link. Each character takes 10 bits (1 start, 8 bits for the character, 1 stop). That means you can only go through this loop ~120 times/sec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;analogRead()&lt;/code&gt; function can sample at about 9600 times/sec in theory, realistically it is about 8600 times/sec. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are being bounded by the serial communication.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-10T22:14:32.777" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="701" PostTypeId="2" ParentId="699" CreationDate="2014-03-10T22:23:02.007" Score="24" Body="&lt;p&gt;The Arduino ADC clock speed is set in ..arduino-1.5.5\hardware\arduino\avr\cores\arduino\wiring.c&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relevant part&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(ADCSRA)&#xA;    // Set A/D prescale factor to 128&#xA;    // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.&#xA;    // XXX: this will not work properly for other clock speeds, and&#xA;    // this code should use F_CPU to determine the prescale factor.&#xA;    sbi(ADCSRA, ADPS2);&#xA;    sbi(ADCSRA, ADPS1);&#xA;    sbi(ADCSRA, ADPS0);&#xA;&#xA;    // Enable A/D conversions&#xA;    sbi(ADCSRA, ADEN);&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a 16&amp;nbsp;MHz Arduino the ADC clock is set to 16&amp;nbsp;MHz/128 = 125&amp;nbsp;KHz. Each conversion in AVR takes 13 ADC clocks so 125&amp;nbsp;KHz /13 = 9615&amp;nbsp;Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is the maximum possible sampling rate, but the actual sampling rate in your application depends on the interval between successive conversions calls.&lt;br&gt;&#xA;Since you read the result and send it through the serial port, you are getting a delay that increases as the baud rate decreases. The lower the baud rate the longer it will take to send the same length of data and the longer it will take to call the next ADC conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual sampling rate in your application can be determined with the use of a debugger or a simulator, but an easier solution is to toggle a digital pin every time you execute a conversion and measure the frequency that the digital pin toggles at.&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="510" LastEditDate="2014-04-08T18:45:05.207" LastActivityDate="2014-04-08T18:45:05.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="702" PostTypeId="1" AcceptedAnswerId="705" CreationDate="2014-03-10T23:01:37.753" Score="2" ViewCount="1728" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.pololu.com/product/1300&quot; rel=&quot;nofollow&quot;&gt;Pololu 5v AVR ISP&lt;/a&gt; which I have successfully used to program several Arduinos (a Mega, an Uno and a Pro Mini 5v). I now have a new Arduino compatible clone which is basically a clone of the pro mini 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if anyone else has used this programmer to program a 3.3V board without issues. I've seen a forum post on &lt;a href=&quot;http://forum.pololu.com/viewtopic.php?f=3&amp;amp;t=7368&quot; rel=&quot;nofollow&quot;&gt;pololu's forum&lt;/a&gt; which discusses modifications required - but I don't really understand what is necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also found the software tool mentioned in the above forum post &lt;a href=&quot;http://www.pololu.com/docs/0J41&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and I have downloaded it and built it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the aforementioned tool I get these options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PgmCmd: Configuration and status utility for the Pololu USB AVR Programmer.&#xA;Version: 1.0.1.0&#xA;Options:&#xA; -l, --list             list available devices&#xA; -d, --device SERIALNUM (optional) select device with given serial number&#xA; -s, --status           display complete device status&#xA;     --freq NUM         sets the ISP frequency (in units of kHz)&#xA;     --linea ID&#xA;       or --lineb ID    set serial control signal associated with line A or B.&#xA;                        Valid IDs are: none, cd, dsr, ri, dtr, rts.&#xA;                        Warning: dtr and rts are outputs: -f option is required&#xA;     --swminor HEXNUM   AVR ISP software version minor (in hex, e.g. A)&#xA;     --swmajor HEXNUM   AVR ISP software version major (in hex)&#xA;     --hw HEXNUM        AVR ISP software hardware version (in hex)&#xA;     --vddmin NUM       set minimum allowed target vdd (units of mV)&#xA;     --vddmaxrange NUM  set maximum allowed target vdd range (units of mV)&#xA;     --restoredefaults  restore factory settings&#xA;     --bootloader       put device in to bootloader (firmware upgrade) mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then ran the --status option with the serial number of my programmer and got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial number:                  00048632&#xA;Firmware version:               1.07&#xA;Settings:&#xA;  ISP Frequency:                200 kHz&#xA;  Line A Identity:              None&#xA;  Line B Identity:              None&#xA;  AVR ISP hardware version:     F&#xA;  AVR ISP software version:     2.A&#xA;  Target VDD allowed minimum:   4384 mV&#xA;  Target VDD allowed max range: 512 mV&#xA;Last programming:&#xA;  Error: None&#xA;  Measured Target VDD Minimum:  N/A&#xA;  Measured Target VDD Range:    N/A&#xA;SLO-scope:&#xA;  State:                        Off&#xA;  Line A output:                Off&#xA;  Line B output:                Off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this I deduced that my programmer is currently set at between about 4.38V and 4.89V which I presume corresponds to the 5V approximate voltage of the normal Arduino chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the utility program allows me to set both the target minimum V&lt;sub&gt;dd&lt;/sub&gt; and the target V&lt;sub&gt;dd&lt;/sub&gt; max range should I therefore set it to something like a minimum of 2704 with a max range of 512 which should put the signal voltages at up to ~3.2V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that all I have to do to get this to work?&lt;/p&gt;&#xA;" OwnerUserId="575" LastEditorUserId="65" LastEditDate="2014-03-11T14:40:15.440" LastActivityDate="2014-03-11T14:40:15.440" Title="How to use a Pololu 5v AVR ISP Programmer to program an AVR at 3.3v" Tags="|uploading|voltage-level|isp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="703" PostTypeId="5" CreationDate="2014-03-11T00:42:38.050" Score="0" Body="&lt;p&gt;In-system programming (ISP) refers to the ability of chips to be programmed while installed in the system. This is usually accomplished by connecting to a 6 or 8 pin header on the board and a hardware programmer connected to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info on &lt;a href=&quot;http://en.wikipedia.org/wiki/In-system_programming&quot; rel=&quot;nofollow&quot;&gt;Wiki&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-03-11T00:42:38.050" LastActivityDate="2014-03-11T00:42:38.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="704" PostTypeId="4" CreationDate="2014-03-11T00:42:38.050" Score="0" Body="In-system programming (ISP) refers to the ability of chips to be programmed while installed in the system." OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-03-11T00:42:38.050" LastActivityDate="2014-03-11T00:42:38.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="705" PostTypeId="2" ParentId="702" CreationDate="2014-03-11T02:18:07.097" Score="3" Body="&lt;p&gt;Since AVR ISP is simply a modified form of SPI, the most universal way to handle this is to use a 3/1 level translator such as the &lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/3253&quot; rel=&quot;nofollow&quot;&gt;MAX3392E&lt;/a&gt;. Once you provide it with 5V on V&lt;sub&gt;CC&lt;/sub&gt; and 3V3 on V&lt;sub&gt;L&lt;/sub&gt; it will translate the MOSI, SCK, and nRESET signals to 3V3 and the MISO signal to 5V.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-11T02:18:07.097" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="706" PostTypeId="2" ParentId="403" CreationDate="2014-03-11T03:41:35.897" Score="3" Body="&lt;p&gt;As jfpoilpret already said, a power MOSFET is great for turning ON and OFF the 12 VDC power to devices that pull up to 44 A. There are dozens of such power MOSFETs for under $1 each. More expensive MOSFETs are available that can handle much higher current and voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In principle it is possible to drive a stepper motor with a microcontroller and a handful of transistors and a few other little parts.&#xA;However, many people prefer to use a &quot;stepper driver chip&quot;, so it is impossible for a software bug to accidentally turn on transistors in such a way as to short the power supply to ground (typically destroying at least 2 transistors).&#xA;Many recent stepper driver chips also handle microstepping, current limiting, thermal overload protection, and other nice features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the stepper driver chips that I've ever heard of, and a few off-the-shelf breakout boards using those chips, are listed at&#xA;&lt;a href=&quot;http://reprap.org/wiki/stepper_motor_driver&quot; rel=&quot;nofollow&quot;&gt;http://reprap.org/wiki/stepper_motor_driver&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, many of the RepRap 3D printers I've seen connect an Arduino to four &lt;a href=&quot;http://www.pololu.com/category/120/stepper-motor-drivers&quot; rel=&quot;nofollow&quot;&gt;Pololu stepper drivers&lt;/a&gt; (under $15 each) to drive five stepper motors.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-03-11T03:41:35.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="707" PostTypeId="1" CreationDate="2014-03-11T09:13:08.583" Score="12" ViewCount="6134" Body="&lt;p&gt;I am using an Arduino Uno to send time and voltage information over the serial port to Python to plot. However the interval timings between successive time stamps appears to be increasing over time, affecting my plotting. This is especially true when the baud rate is set to 9600, where my initial time differences maybe 1320 and increases to 16400 after a relatively short period of time. When this rate is put to maximum of 115200 bps the change is slower and less noticeable, from around 1340 to 1500 even after a relatively long run of sending. All times are given in microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if I can reduce or eliminate this effect, and if not understand why it exists. I have read things about interrupts and delays causing this, but I do not fully appreciate the complexity of the electronics at hand and would like to know: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I get greater precision in the timing?&lt;/li&gt;&#xA;&lt;li&gt;What causes this change in timing?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is what I currently have: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;eHealth.h&amp;gt;&#xA;&#xA;extern volatile unsigned long timer0_overflow_count;&#xA;float fanalog0;&#xA;int analog0;&#xA;unsigned long time;    &#xA;&#xA;byte serialByte;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() { &#xA;  while (Serial.available()&amp;gt;0){  &#xA;    serialByte=Serial.read();&#xA;    if (serialByte=='S'){        &#xA;      while(1){&#xA;        fanalog0=eHealth.getECG();  &#xA;        // Use the timer0 =&amp;gt; 1 tick every 4 us&#xA;        time=(timer0_overflow_count &amp;lt;&amp;lt; 8) + TCNT0;        &#xA;        // Microseconds conversion.&#xA;        time=(time*4);   &#xA;        //Print in a file for simulation&#xA;        //Serial.print(time);&#xA;        //Serial.print(&quot; &quot;);&#xA;        Serial.print(fanalog0,5);&#xA;        Serial.print(&quot;\n&quot;);&#xA;&#xA;        if (Serial.available()&amp;gt;0){&#xA;          serialByte=Serial.read();&#xA;          if (serialByte=='F')  break;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="501" LastEditorUserId="65" LastEditDate="2014-03-11T14:37:37.987" LastActivityDate="2014-04-28T08:52:37.410" Title="High precision timing on Arduino for serial communication" Tags="|arduino-uno|serial|time|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="708" PostTypeId="1" CreationDate="2014-03-11T10:25:06.483" Score="3" ViewCount="676" Body="&lt;p&gt;I need to communicate between two Arduinos using XBee. I am new to XBee and hardware. The two Arduino Unos need to send a message (number) to each other and light an LED or play a sound, when they come close within a 10 meter distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my doubt is which XBee shield and XBee module I need to purchase. I read about XBee series 2, XB24 etc.&lt;/p&gt;&#xA;" OwnerUserId="578" LastEditorUserId="304" LastEditDate="2014-03-20T11:48:09.027" LastActivityDate="2014-03-20T12:39:19.997" Title="XBee shield communication" Tags="|arduino-uno|sensors|shields|proximity|xbee|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="709" PostTypeId="2" ParentId="708" CreationDate="2014-03-11T13:09:06.670" Score="2" Body="&lt;p&gt;The &quot;XBee&quot; brand has two major types. Series 1 are the original ones, and are often NOT referred to by their series number. Series 2 are the newer mesh network brethren.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most XBee's and their clones are pin compatible (there is even a Bluetooth replacement 'Bee), thus any XBee shield or adapter can be used for either series.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference is largely in their communication protocols. The Series 2 allow more robust mesh networking options. But for a beginner - the original (S1) provide simpler out-of-the-box networking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are retail packages available that include a pair of S1 XBees, an Arduino compatible breakout board, and a USB adapter to program them. This allows you to get &quot;on the air&quot; and setup the XBees quickly. For communication between two arduinos, a pair of shields will make physical connectivity much easier.&lt;/p&gt;&#xA;" OwnerUserId="58" LastActivityDate="2014-03-11T13:09:06.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="710" PostTypeId="2" ParentId="707" CreationDate="2014-03-11T15:28:40.127" Score="3" Body="&lt;p&gt;I can think of a few things that can impact the &quot;consistency&quot; of the serial write timings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;size of the data to be printout&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;this may be the most obvious thing to think of, but indeed the more you print, the more it'll take to handle it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: print format the string into a string of known length.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;using buffered serial&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;on unix you can access the serial port using a buffered or an unbuffered way. Using the buffered way for a long time may make it a bit slower as the buffer fills, usually it happens when data is incoming faster than you're reading it…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: use the unbuffered serial line (&lt;em&gt;e.g.&lt;/em&gt;: on Darwin/OSX it's &lt;code&gt;/dev/cu.usbmodemXXX&lt;/code&gt; instead of &lt;code&gt;/dev/tty.usbmodemXXX&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;priority of the timers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;it looks like your using a TC interrupt, and AVRs have priorities in the way interrupts are handled, I don't know the order of priority for the Atmega328, and it's not one of the most documented feature around, so I don't know how safe is TC0 versus the UART interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: look up further in the documentation/datasheet about interrupt priorities and change the timer if needed ; and/or do a test without having the other timer running.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the data you're reading from takes more time to read from over time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;some drivers need to average or do some operations over the previous values, so the more values you measure, the longer the buffer is, and the longer it takes to calculate the value, until you've reached the maximum size of the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: look at the source code of the library you're using, and either optimize it, remove the calcul if there's one or take that increasing processing time into account.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;avoiding the arduino framework overhead&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;but if you &lt;em&gt;really&lt;/em&gt; want to optimize serial output from the arduino, you should avoid using the arduino overhead… But it's way less elegant and comfortable to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure there are other points I'm missing, but that's the first things that I'd check before digging further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-11T15:28:40.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="711" PostTypeId="2" ParentId="692" CreationDate="2014-03-11T16:07:59.987" Score="2" Body="&lt;p&gt;If interrupts are turned off for any significant fraction &lt;code&gt;eHealth.getECG()&lt;/code&gt; call duration, &lt;code&gt;millis()&lt;/code&gt;'s count could fall behind. Otherwise, &lt;code&gt;millis()&lt;/code&gt; should return much more accurate time than the 3x errors you described. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You said your sampled signal appears higher in frequency than what you expected, which could happen if your sample rate is lower than you intended. Are you a assuming a 20Hz sample rate? Your loop could be taking a fair bit longer than 50ms, which you would see in the printed times, but those should still track the clock time. If you didn't account for that but assumed 50ms/sample, you'd see an apparent speed up of of the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not the issue, then the next step would be to toggle an output while you're in &lt;code&gt;loop()&lt;/code&gt;, and measure the frequency of the resulting square wave with a frequency meter (some inexpensive DVMs can do this) or a 'scope. Do the same thing with an empty &lt;code&gt;loop()&lt;/code&gt;. The first experiment will your real sampling rate or interval; the second will tell you whether &lt;code&gt;millis()&lt;/code&gt; (ie., the timer0 frequency) is what you expected.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-03-11T16:07:59.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="712" PostTypeId="2" ParentId="682" CreationDate="2014-03-11T16:36:25.093" Score="51" Body="&lt;p&gt;My general rule for embedded systems is to only &lt;code&gt;malloc()&lt;/code&gt; large buffers and only once, at the start of the program, e.g., in &lt;code&gt;setup()&lt;/code&gt;. The trouble comes when you allocate and de-allocate memory. Over a long run session, memory becomes fragmented and eventually an allocation fails due to lack of a sufficiently large free area, even though the total free memory is more than adequate for the request.&lt;/p&gt;&#xA;&lt;p&gt;(Historical perspective, skip if not interested): Depending on the loader implementation, the only advantage of run-time allocation vs. compile-time allocation (intialized globals) is the size of the hex file. When embedded systems were built with off the shelf computers having all volatile memory, the program was often uploaded to the embedded system from a network or an instrumentation computer and the upload time was sometimes an issue. Leaving out buffers full of zeros from the image could shorten the time considerably.)&lt;/p&gt;&#xA;&lt;p&gt;If I need dynamic memory allocation in an embedded system, I generally &lt;code&gt;malloc()&lt;/code&gt;, or preferably, statically allocate, a large pool and divide it into fixed-size buffers (or one pool each of small and large buffers, respectively) and do my own allocation/de-allocation from that pool. Then every request for any amount of memory up to the fixed buffer size is honored with one of those buffers. The calling function doesn't need to know whether it's larger than requested, and by avoiding splitting and re-combining blocks we solve fragmentation. Of course memory leaks can still occur if the program has allocate/de-allocate bugs.&lt;/p&gt;&#xA;&lt;p&gt;Update 02/16/23:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I'm curious why the Arduino library's malloc implementation doesn't&#xA;implement some coalescing of the free blocks like a full OS would.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That's interesting to think about, but let's first be clear that in C/C++, malloc() and free() are implemented as library functions at the application-level not the OS level, even in major OSes. And they are based on fragmenting the heap, just as the Arduinos' malloc() functions do.&lt;/p&gt;&#xA;&lt;p&gt;Embedded systems, are relatively new, at least as an influential force in the design of OSes, languages, and libraries' design. Which is to say, programs that had to run &amp;quot;forever&amp;quot; without failing (other than, perhaps the OS itself) were outliers. Most programs we run on our desktops or (once upon a time) ran on mainframes, were started, processed a batch of data, and exited.&lt;/p&gt;&#xA;&lt;p&gt;Secondly, the malloc()/free() method of memory allocation/deallocation was simple, where anticipating the sizes of memory requests was not; and some allocations are used briefly and returned, where some are kept for the duration of the run. How is a library designer to provide for coalescing currently free and newly deallocated memory with no knowledge of the allocate/deallocate usage and sizes of requests? The fixed-size buffer scheme I described above doesn't suffer the fragmentation problem that &amp;quot;malloc() an arbitrary number of bytes&amp;quot; scheme does. It is still limited to available memory but within that limitation, could meet the &amp;quot;run forever&amp;quot; requirement. There may be algorithms that split and coalesce memory, but probably only for a few - statistically predictable - patterns of allocation and deallocation.&lt;/p&gt;&#xA;&lt;p&gt;Update 02/18/23:&lt;/p&gt;&#xA;&lt;p&gt;@edgarbonet points out that Arduino's &lt;code&gt;free()&lt;/code&gt; does try to coalesce free blocks. This is a good example of an algorithm that works for certain cases: Properly done, it would work for &amp;quot;last-out / first-in&amp;quot; cases, and to some extent for some other cases.&lt;/p&gt;&#xA;&lt;p&gt;The trouble is, most of our use patterns are not very regular, if they're regular at all. An alogrithm that does no splitting, but merely allocates &amp;amp; deallocates fixed-size pieces (rather like loaning library books) can still run out of memory but won't end up with fragmented resources. In fact, because it doesn't split, it &lt;em&gt;will&lt;/em&gt; need more memory to meet the same random-sized requests than even a coalescing &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2023-02-18T15:07:23.367" LastActivityDate="2023-02-18T15:07:23.367" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="713" PostTypeId="2" ParentId="707" CreationDate="2014-03-11T17:16:42.697" Score="4" Body="&lt;p&gt;Use a timer and ISR (interrupt service routine) to make timing more accurate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at my &lt;a href=&quot;http://blog.linformatronics.nl/213/electronics/timed-1-millisecond-interrupt-routine-for-arduino&quot; rel=&quot;nofollow&quot;&gt;1ms timed interrupt Proof of Concept&lt;/a&gt;. The idea is to have a reasonably accurate 1ms 'heartbeat' in the system that can be used to trigger other events. In the PoC it is used to blink an LED at ½Hz, but having access to the new variables &lt;code&gt;millisecondCounter&lt;/code&gt; and &lt;code&gt;secondCounter&lt;/code&gt; enables you to trigger events in the main loop at arbitrary (but accurately timed) moments.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-03-11T17:16:42.697" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="714" PostTypeId="2" ParentId="689" CreationDate="2014-03-11T17:54:18.690" Score="4" Body="&lt;p&gt;i needed to re-range the 10bit input to 8 bit for the pwm out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// to run on attiny85&#xA;&#xA;const byte pwmPin = 0;&#xA;const byte analogInPin = A2;&#xA;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;  pinMode(pwmPin, OUTPUT);&#xA;  int analogIn = analogRead(analogInPin);&#xA; analogIn = map(analogIn, 0, 1023, 0, 255);&#xA; analogWrite(pwmPin, analogIn);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="555" LastActivityDate="2014-03-11T17:54:18.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="716" PostTypeId="1" CreationDate="2014-03-11T00:36:49.290" Score="8" ViewCount="1615" Body="&lt;p&gt;I have done various applications with the Ultrasonic &lt;a href=&quot;https://github.com/alexmac131/NodeXbeeTank&quot; rel=&quot;noreferrer&quot;&gt;example project&lt;/a&gt; but it is always using one pinger. I'd like to make a scanner resting on a servo sweep but to reduce sweep time use more than one censor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the documentation is rather basic &lt;a href=&quot;http://www.parallax.com/sites/default/files/downloads/28015-PING-Sensor-Product-Guide-v2.0.pdf&quot; rel=&quot;noreferrer&quot;&gt;ping sonic&lt;/a&gt; that states the signal 40khz is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Down to the question now. Is there a means to tell one pinger to use 40Khz and another say  45Khz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would allow me to scan two areas (different directions) per cycle, reducing the time frame to complete area scan by half.&lt;/p&gt;&#xA;" OwnerDisplayName="alexmac" LastEditorUserId="11" LastEditDate="2014-03-12T14:56:02.643" LastActivityDate="2014-06-30T10:30:36.347" Title="Using more than one Ping Ultrasonic Range Finder" Tags="|sensors|robotics|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="717" PostTypeId="2" ParentId="638" CreationDate="2014-03-12T05:26:14.837" Score="2" Body="&lt;p&gt;Two more options - battery pack with convenient pre-made screw holes for Arduino, Raspberry.PI, and Beagle Board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T0aHD.jpg&quot; alt=&quot;Smart Power Base&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.makershed.com/product_p/mkmts01.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Smart Power Base&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kicking it up a notch - using a cordless drill's 18V battery.  The project is meant for R.PI, but it would work just as well on Arduino, as the power supply is USB&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I9ct9.jpg&quot; alt=&quot;Portable PI Power&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://makezine.com/projects/portable-pi-power-raspbery-pi-to-go/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Portable PI Power&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="213" LastActivityDate="2014-03-12T05:26:14.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="718" PostTypeId="2" ParentId="716" CreationDate="2014-03-12T12:51:56.400" Score="0" Body="&lt;p&gt;I don't think it would be very easy to change the frequency unless Parallax decides to release the firmware for the Ping. It is possible to use two, as long as you use a different data pin for each, but the ultrasonic signals may interfere.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-12T12:51:56.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="719" PostTypeId="2" ParentId="708" CreationDate="2014-03-12T13:04:22.340" Score="0" Body="&lt;p&gt;Adding to Ron's answer, the Series 1 is a lot easier to use, because you have to flash firmware onto Series 2s and do all kinds of setup. The S1s work out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing to keep in mind is that Xbees use 3.3v I/O pins, while the Arduino uses 5v. Most Xbee shields have a Logic Level Converter to handle this, but there are some that don't, and those could damage your Xbee.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="304" LastEditDate="2014-03-20T12:39:19.997" LastActivityDate="2014-03-20T12:39:19.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="720" PostTypeId="2" ParentId="716" CreationDate="2014-03-12T13:35:37.633" Score="4" Body="&lt;p&gt;There is no way to change the frequency, however there are other ways of doing what you want to accomplish. I think the best thing to do is stagger the timing of the pings so they don't happen at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code, modified by me:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;Servo servo; // create servo object to control a servo&#xA;&#xA;int pingPins[] = {7,8}; //The pins for the two sensors&#xA;char *pingString[] = {&quot;Ping1&quot;, &quot;Ping2&quot;};&#xA;&#xA;void setup()&#xA;{&#xA;  servo.attach(10); // attaches a servo to pin 10&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned long ultrasoundValue;&#xA;  for(int i = 0; i &amp;lt; ultraSoundSignalPins.length; i++)&#xA;  {&#xA;    ultrasoundValue = ping(i);&#xA;    Serial.print(pingString[i]);&#xA;    Serial.print(&quot;: &quot;);&#xA;    Serial.print(ultrasoundValue);&#xA;    Serial.print(&quot;in, &quot;);    &#xA;    delay(50);&#xA;  }&#xA;  Serial.println();&#xA;  delay(50);&#xA; } &#xA;&#xA;//Ping function&#xA;unsigned long ping(int i)&#xA;{&#xA;  unsigned long echo;&#xA;&#xA;  pinMode(pingPins[i], OUTPUT);         // Switch signalpin to output&#xA;  digitalWrite(pingPins[i], LOW);       // Send low pulse&#xA;  delayMicroseconds(2);                 // Wait for 2 microseconds&#xA;  digitalWrite(pingPins[i], HIGH);      // Send high pulse&#xA;  delayMicroseconds(5);                 // Wait for 5 microseconds&#xA;  digitalWrite(pingPins[i], LOW);       // Holdoff&#xA;  pinMode(pingPins[i], INPUT);          // Switch signalpin to input&#xA;  digitalWrite(pingPins[i], HIGH);      // Turn on pullup resistor&#xA;  echo = pulseIn(pingPins[i], HIGH);    //Listen for echo&#xA;  return (echo / 58.138) * .39;         //convert to CM then to inches&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&#xA;Sources:&#xA;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;sup&gt;&lt;a href=&quot;https://stackoverflow.com/questions/20273971/arduino-multiple-ultrasonic-sensors-interference&quot;&gt;https://stackoverflow.com/questions/20273971/arduino-multiple-ultrasonic-sensors-interference&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;sup&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=17898.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=17898.0&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="37" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-03-12T13:35:37.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="721" PostTypeId="1" CreationDate="2014-03-12T15:13:33.620" Score="5" ViewCount="350" Body="&lt;p&gt;I am trying to build a device that will allow me to control at least a couple hundred raising platforms. The goal of this is to create a real time editor for board games (&lt;em&gt;Dungeons and Dragons&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All the platforms would move simultaneously &lt;/li&gt;&#xA;&lt;li&gt;The platforms would be transparent to allow us to place LEDs inside them to color the platform so we can make colors like blue for water and brown for dirt.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In our current setup, we use some acrylic prisms that are 1 inch x 1 inch x 6 inch (width, length, height). We wanted to use a CNC motor like system to move something around and move a platform. Obviously, this can only raise/lower one item at a time. We calculated (on paper) quite a long update time (calculated approximately 1 sec per platform) to raise/lower a platform. A CNC linear drive type system is the only solution we found that had a reasonable cost/quality (a CNC motor for every platform also raised the power consumption very high). After a few weeks of looking around, planning and throwing stupid ideas away, we found &lt;a href=&quot;http://www.youtube.com/watch?v=lvtfD_rJ2hE&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, it's way better then our idea but I have no idea how they did this. They have 900 platforms and they all work simultaneously. We also don't need real time interaction. Loading from computer and staying static until we change it is good (though water movement would be really nice).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would you guys recommend to raise simultaneously a thousand small platforms?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After looking at this &lt;a href=&quot;http://tmg-trackr.media.mit.edu:8020/SuperContainer/RawData/Papers/527-inFORM%20Dynamic%20Physical%20Affordances/Published/PDF&quot; rel=&quot;nofollow&quot;&gt;document&lt;/a&gt; that the devs made, and doing a bit more research I found that the device they used to move the platforms cost approxomently $30; I don't think I need to say this, but I don't have $27,000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Key difference between their implementation and our goal:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No real-time interaction with the table. Controlled by an Arduino is fine.&lt;/li&gt;&#xA;&lt;li&gt;Size of the platforms will be closer to 1 inch^2&lt;/li&gt;&#xA;&lt;li&gt;All sides of the platform should be light up, but I believe this is mostly a question of choosing the right material&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="user591" LastEditorUserId="220" LastEditDate="2014-03-18T19:13:45.990" LastActivityDate="2014-07-25T21:15:44.063" Title="How do I manipulate a large number of moving platforms?" Tags="|system-design|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="723" PostTypeId="2" ParentId="708" CreationDate="2014-03-12T16:47:08.177" Score="3" Body="&lt;p&gt;The only way I can think of accomplishing this without some sort of proximity sensor is to measure the signal strength of the XBees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;page 41 of the datasheet&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;DB (Received Signal Strength) Command&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;AT Command:&lt;/strong&gt; ATDB&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Parameter Range [read-only]:&lt;/strong&gt;  0x17-0x5C (XBee), 0x24-0x64 (XBee-PRO)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt; DB parameter is used to read the received signal&#xA;  strength (in dBm) of the last RF packet received. Reported values are&#xA;  accurate between -40 dBm and the RF module's receiver sensitivity.&#xA;  Absolute values are reported. For example: 0x58 = -88 dBm (decimal).&#xA;  If no packets have been received (since last reset, power cycle or&#xA;  sleep event), “0” will be reported.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use this as a &lt;strong&gt;rough&lt;/strong&gt; estimate of the distance between two sensors. You will have to correlate signal strength to actual distance and obstructions and other factors will cause the reported value to be off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=151145.0&quot; rel=&quot;nofollow&quot;&gt;How to measure XBee signal strength?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page has an example using Processing (on the computer): &lt;a href=&quot;http://www.makingthingstalk.com/chapter8/22/&quot; rel=&quot;nofollow&quot;&gt;XBee Signal Strength&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-12T16:47:08.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="724" PostTypeId="1" AcceptedAnswerId="732" CreationDate="2014-03-13T01:36:25.043" Score="2" ViewCount="486" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.radioshack.com/product/index.jsp?productId=12345958&quot; rel=&quot;nofollow&quot;&gt;Parallax 27800 2-Axis Joystick&lt;/a&gt; wired up to a &lt;a href=&quot;https://www.sparkfun.com/products/11232&quot; rel=&quot;nofollow&quot;&gt;AVR 14 Pin 20MHz 8K 12A/D - ATtiny84&lt;/a&gt;. The joy stick sends out a x y analog signal. I have programmed the Attiny84 to read the signals and set one of the attiny84 pins (high or low) depending on the direction of the joystick. In this example, each pin is wired up to a LED. The problem I am having is there is about a 1 second delay for the LED to light. The Attiny84 has a built in 8MHz clock. Would connecting an external 20MHz crystal fix this issue?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int UD = 0;&#xA;int LR = 0;&#xA;&#xA;int DWN = 0;&#xA;int UP = 1;&#xA;int LEFT = 4;&#xA;int RT = 5;&#xA;&#xA;int LRMID = 0;&#xA;int UPMID = 0;&#xA;void setup(){&#xA;&#xA;  pinMode(DWN, OUTPUT);&#xA;  pinMode(UP, OUTPUT);  &#xA;  pinMode(LEFT, OUTPUT); &#xA;  pinMode(RT, OUTPUT);&#xA;&#xA;  digitalWrite(DWN, LOW);&#xA;  digitalWrite(UP, LOW);&#xA;  digitalWrite(LEFT, LOW);&#xA;  digitalWrite(RT, LOW);&#xA;&#xA;  //calabrate center&#xA;  LRMID = analogRead(3);&#xA;  UPMID = analogRead(2);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  UD = analogRead(2);&#xA;  LR = analogRead(3);&#xA;  // UP-DOWN&#xA;  if(UD &amp;lt; UPMID - 5){&#xA;   digitalWrite(DWN, HIGH);&#xA;  }else{&#xA;   digitalWrite(DWN, LOW);&#xA;  }&#xA;&#xA;  if(UD &amp;gt; UPMID + 5){&#xA;   digitalWrite(UP, HIGH);&#xA;  }else{&#xA;   digitalWrite(UP, LOW);&#xA;  }&#xA;  // LEFT-RIGHT&#xA;  if(LR &amp;lt; LRMID-5){&#xA;   digitalWrite(LEFT, HIGH);&#xA;  }else{&#xA;   digitalWrite(LEFT, LOW);&#xA;  }&#xA;&#xA;  if(LR &amp;gt; LRMID +5){&#xA;   digitalWrite(RT, HIGH);&#xA;  }else{&#xA;   digitalWrite(RT, LOW);&#xA;  }&#xA;&#xA;  delay(100);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-03-13T18:33:24.297" Title="Attiny84 and 2-Axis Joystick" Tags="|programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="725" PostTypeId="1" AcceptedAnswerId="852" CreationDate="2014-03-13T02:17:11.663" Score="9" ViewCount="243" Body="&lt;p&gt;I have a custom Arduino ATMega328 board that generally runs at 5V @ 8MHz (using the Arduino Pro 3.3V 8MHz profile and bootloader). The main reason I'm using this setup is so that I can put the board to sleep when main power is disconnected and it starts being run off of battery power (3V from a coin cell). The 5V and 3V sources are diode OR'ed together and the 5V input is tied to INT0. In code, when it detects that INT0 has fallen low, it initializes sleep mode and everything powers down with the exception of the watchdog timer that keeps a 1Hz cycle to keep an internal count and check it the chip should be woken back up. This works &lt;em&gt;beautifully&lt;/em&gt; when 5V power is applied first, then the battery is inserted, &lt;em&gt;then&lt;/em&gt; 5V is disconnected. It goes to sleep and when 5V is brought back it wakes up and I can see it hasn't lost count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the problem comes when 3V is applied &lt;em&gt;first&lt;/em&gt;. I'm honestly not sure if it's even booting. But what it is supposed to do is boot, check if INT0 (Digital 2) is low and, if so, go right to sleep. By watching the current draw I see that it powers up to a few mA for a couple seconds, then drops to about 0.3mA (still higher than it should be in sleep mode). But when I re-apply 5V, &lt;em&gt;nothing&lt;/em&gt;. The power draw goes back up but it is unresponsive (over FTDI serial).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there maybe something I'm missing that it can't be booted on 3V... in theory it should run just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I dropped an LED onto D13 and tried the blink sketch. Works fine when starting from 3V or 5V. However, when I run my firmware and start it from 3V, the LED just starts flashing wildly. I have no idea what's causing it since I never even setup D13 as anything in my code. But it makes me thing it's something to do with the bootloader...&lt;/p&gt;&#xA;" OwnerUserId="600" LastEditorUserId="600" LastEditDate="2014-03-13T03:08:07.803" LastActivityDate="2014-03-21T16:33:37.700" Title="Bootup on lower power not functioning" Tags="|battery|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="726" PostTypeId="2" ParentId="724" CreationDate="2014-03-13T07:52:23.227" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;Are you absolutely sure your AVR is running at 8MHz, because default I believe it is scaling the 8MHz internal RC-oscillator down to 1MHz system clock. Change your F_CPU macro to 1MHz to see what happens.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-13T10:36:23.797" LastActivityDate="2014-03-13T10:36:23.797" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="728" PostTypeId="2" ParentId="724" CreationDate="2014-03-13T14:07:10.490" Score="1" Body="&lt;p&gt;Several AVR devices including ATtiny 84, have a clock prescaler that can be used to lower the core frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The divider can be controlled two ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first way is the &lt;strong&gt;CKDIV8&lt;/strong&gt; fuse that controls the default loaded value to CLKPR (Clock prescale register) to either&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;fuse disabled:&lt;/strong&gt;  Clock Division Factor 1 (clk/1)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;fuse enabled:&lt;/strong&gt; Clock Division Factor 8 (clk/8)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The fuse is enabled by default and applies the clk/8 setting, it can be changed with a programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second way is by changing the prescaler value during runtime. All you need to do is to include the following header&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call one of following functions with the appropriate value you want to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   clock_prescale_set(clock_div_1);    // Clock Division Factor 1&#xA;   clock_prescale_set(clock_div_2);    // Clock Division Factor 2&#xA;   clock_prescale_set(clock_div_4);    // Clock Division Factor 4&#xA;   clock_prescale_set(clock_div_8);    // Clock Division Factor 8&#xA;   clock_prescale_set(clock_div_16);   // Clock Division Factor 16&#xA;   clock_prescale_set(clock_div_32);   // Clock Division Factor 32&#xA;   clock_prescale_set(clock_div_64);   // Clock Division Factor 64&#xA;   clock_prescale_set(lock_div_128);   // Clock Division Factor 128&#xA;   clock_prescale_set(clock_div_256);  // Clock Division Factor 256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html&quot; rel=&quot;nofollow&quot;&gt;power.h manual&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the above functions can be applied at any part of the program, for example you can lower the cpu frequency to reserve battery and then set it higher again for intensive tasks. Just be aware that all peripheral will work with the divided clock too so PWM, timers, SPI, UART etc will all be affected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem you are facing is caused by the clock divider being in the /8 setting then you can change it at runtime.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add the header at the start of the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then set the prescaler value to 1 at the start of setup()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;               clock_prescale_set(clock_div_1);  // set the clock prescaler to /1&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="470" LastActivityDate="2014-03-13T14:07:10.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="729" PostTypeId="1" CreationDate="2014-03-13T16:34:14.170" Score="3" ViewCount="1028" Body="&lt;p&gt;My hardware is 4 potentiometers connected to Arduino Analog 0-3, the output is an RGB led driver connected to Digital outputs 9,10,11. The output channels provide access to PWM control of those pins. So idea is the color and intensity can be controlled by the Arduino. I wrote a simple Sketch that reads the potentiometers and then outputs PWM to the RGB driver circuitry. This works great! So the hardware is working! Now comes the last potentiometer...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make the last potentiometer a &quot;mode select&quot; control. It would function like this: If the last potentiometer (Pot4) is turned down all the way, then all lights are off. If the level is turned up a little, the Arduino then controls the RGB channels via Pots 1, 2 &amp;amp; 3. If Pot4 is turned up to just past halfway, the sketch enters a &quot;strobe flash pattern&quot; pulsing all channels on and off. And if the mode control Pot4 is turned up all the way, Arduino turns on all RGB channels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I implement? Mode selection via a potentiometer? &lt;/p&gt;&#xA;" OwnerUserId="608" LastEditorUserId="275" LastEditDate="2014-03-13T18:15:19.450" LastActivityDate="2014-03-13T18:15:19.450" Title="How to implement multiple LED modes in a sketch with potentiometers?" Tags="|sketch|analogwrite|potentiometer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="730" PostTypeId="2" ParentId="729" CreationDate="2014-03-13T16:41:37.180" Score="1" Body="&lt;p&gt;It would be relatively simple to do a threshold test on analogRead() to switch modes &lt;em&gt;(e.g. if the value is above 512 (analogRead() gives values between 0-1023)&lt;/em&gt; then you switch modes (probably with a boolean variable that you can then use to decide whether to strobe the LEDs).&lt;/p&gt;&#xA;" OwnerUserId="554" LastActivityDate="2014-03-13T16:41:37.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="731" PostTypeId="2" ParentId="729" CreationDate="2014-03-13T17:36:35.967" Score="6" Body="&lt;p&gt;Since you already know how to hook up a pot and read it's value, it's quite simple. You already have it hooked up in a voltage divider configuration and are getting a 10 bit (0-1023) value using &lt;a href=&quot;http://arduino.cc/en/Reference/analogRead&quot;&gt;&lt;code&gt;analogRead()&lt;/code&gt;&lt;/a&gt;, you just need to decide what to do with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume &lt;code&gt;potVal&lt;/code&gt; has the value of the pot.;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (potVal &amp;lt; 256) {&#xA;    // Pot is one quarter turn or less&#xA;} else if (potVal &amp;lt; 512) {&#xA;    // Pot is between 256 and 512, so its more than quarter but less than half&#xA;} else if (potVal &amp;lt; 768) {&#xA;    // Pot is between half and 3/4ths of the way there&#xA;} else {&#xA;    // Pot is greater than 3/4 of it's full range&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have broken it down into four quadrants for you, but you can do it however you like.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-03-13T17:36:35.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="732" PostTypeId="2" ParentId="724" CreationDate="2014-03-13T18:33:24.297" Score="3" Body="&lt;p&gt;While @alexan_e’s suggestion fixed your practical problem, I would argue that it did not address your root cause, which is that whatever board setting you’re working from in boards.txt assumes a clock rate of 8MHz, while in reality your fuses are set to boot the microcontroller at 1MHz. This caused your delay(100) to take 800ms, and was the entire reason for the slowdown. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of fixing this at runtime, as aleman_e suggested, it seems more natural to me to bring your fuse settings into alignment with your compiler settings, using the “burn boot loader” Arduino command (which on Attinys generally does NOT burn a boot loader, but only sets the fuses to be in sync with the compiler settings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your application is not going to become much more complex, running at 1MHz might be a more efficient choice than running at 8MHz. &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-13T18:33:24.297" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="733" PostTypeId="5" CreationDate="2014-03-13T18:41:20.237" Score="0" Body="&lt;p&gt;&lt;strong&gt;Potentiometer&lt;/strong&gt; - short form &lt;strong&gt;&lt;em&gt;pot&lt;/em&gt;&lt;/strong&gt;. Electronic component forming a three-terminal resistor with a sliding contact that acts as a variable resistor / voltage divider and lets a variable current flow through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Potentiometers are commonly used to control electrical devices such as volume controls on audio equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Wikipedia:&lt;/em&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Potentiometer&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Potentiometer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Potentiometer Explanation:&lt;/em&gt; &lt;a href=&quot;http://www.electronics-tutorials.ws/io/io_2.html&quot; rel=&quot;nofollow&quot;&gt;http://www.electronics-tutorials.ws/io/io_2.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Voltage Divider Tutorial:&lt;/em&gt; &lt;a href=&quot;https://learn.sparkfun.com/tutorials/voltage-dividers&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/voltage-dividers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="275" LastEditorUserId="275" LastEditDate="2014-03-13T19:28:37.273" LastActivityDate="2014-03-13T19:28:37.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="734" PostTypeId="4" CreationDate="2014-03-13T18:41:20.237" Score="0" Body="Electronic component forming a three-terminal resistor with a sliding contact. Acts as a variable resistor / voltage divider, manipulating the amount of current flowing through it." OwnerUserId="275" LastEditorUserId="42" LastEditDate="2015-03-08T19:40:25.957" LastActivityDate="2015-03-08T19:40:25.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="735" PostTypeId="1" CreationDate="2014-03-14T07:43:18.967" Score="1" ViewCount="220" Body="&lt;p&gt;I remember seeing &lt;a href=&quot;http://techcrunch.com/2013/11/24/primo/&quot; rel=&quot;nofollow&quot;&gt;Primo&lt;/a&gt;, this robot that is based on Arduino and serves to teach kids to program. My interest in the platform comes from there, but it is always nice to learn about other cool applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What other applications are there that utilise Arduino for K-12 education?&lt;/p&gt;&#xA;" OwnerUserId="20" LastEditorUserId="65" LastEditDate="2014-03-14T16:36:08.273" LastActivityDate="2016-01-08T23:55:38.160" Title="How has Arduino been used in the classroom?" Tags="|project|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="736" PostTypeId="1" AcceptedAnswerId="737" CreationDate="2014-03-14T10:41:10.037" Score="8" ViewCount="3126" Body="&lt;p&gt;I've been trying to get colours fade into each other for a project I'm working on.&#xA;I have achieved this with the rainbow effect that some from Adafruit's example code, however I want to be able to choose the colours (eg. dark blue into light blue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got the colours changing and fading, however the fade turns off all the LEDs and starts to increase the brightness of the new colour. I need the colours to blend rather than fade out and increase in brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is anyone able to point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;LPD8806.h&quot;&#xA;#include &quot;SPI.h&quot;&#xA;#define stripSize 64&#xA;&#xA;int nLEDs = 160;&#xA;&#xA;int dataPin  = 2;&#xA;int clockPin = 3;&#xA;&#xA;// First parameter is the number of LEDs in the strand.  The LED strips&#xA;// are 32 LEDs per meter but you can extend or cut the strip.  Next two&#xA;// parameters are SPI data and clock pins:&#xA;LPD8806 strip = LPD8806(64, dataPin, clockPin);&#xA;&#xA;// You can optionally use hardware SPI for faster writes, just leave out&#xA;// the data and clock pin parameters.  But this does limit use to very&#xA;// specific pins on the Arduino.  For &quot;classic&quot; Arduinos (Uno, Duemilanove,&#xA;// etc.), data = pin 11, clock = pin 13.  For Arduino Mega, data = pin 51,&#xA;// clock = pin 52.  For 32u4 Breakout Board+ and Teensy, data = pin B2,&#xA;// clock = pin B1.  For Leonardo, this can ONLY be done on the ICSP pins.&#xA;//LPD8806 strip = LPD8806(nLEDs);&#xA;&#xA;void setup() {&#xA;  // Start up the LED strip&#xA;  strip.begin();&#xA;&#xA;  // Update the strip, to start they are all 'off'&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop() {&#xA;  //turnAllOn(strip.Color(30,30,30),4000);&#xA;  fade(0, 127, 0, 100); //red, green, blue, delay - fade up all pixels one color&#xA;  //turnAllOn(strip.Color(30,100,30),4000);&#xA;  fade(50, 127, 02,100); //red, green, blue, delay - fade up all pixels one color&#xA;  //turnAllOn(strip.Color(100,30,100),4000);&#xA;  fade(50, 127, 50, 100); //red, green, blue, delay - fade up all pixels one color&#xA;}&#xA;&#xA;void fade(uint32_t r, uint32_t g, uint32_t b, uint32_t wait) {&#xA;  int i, j;&#xA;  for (j=0; j &amp;lt; 384; j++) {&#xA;    for (i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, strip.Color((r*j)/1000,(g*j)/1000,(b*j)/1000));&#xA;    }&#xA;  strip.show();&#xA;  }&#xA;  delay(wait);&#xA;}&#xA;&#xA;void turnAllOn(uint32_t c, uint32_t wait) {&#xA;  int i;  &#xA;  for (i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;    strip.setPixelColor(i, c);  // turn all pixels on&#xA;  }&#xA;  strip.show();   // write all the pixels out&#xA;  delay(wait); &#xA;}&#xA;&#xA;uint32_t Wheel(uint16_t WheelPos)&#xA;{&#xA;  byte r, g, b;&#xA;  switch(WheelPos / 128)&#xA;  {&#xA;    case 0:&#xA;      r = 127 - WheelPos % 128;   //Red down&#xA;      g = WheelPos % 128;      // Green up&#xA;      b = 0;                  //blue off&#xA;      break; &#xA;    case 1:&#xA;      g = 127 - WheelPos % 128;  //green down&#xA;      b = WheelPos % 128;      //blue up&#xA;      r = 0;                  //red off&#xA;      break; &#xA;    case 2:&#xA;      b = 127 - WheelPos % 128;  //blue down &#xA;      r = WheelPos % 128;      //red up&#xA;      g = 0;                  //green off&#xA;      break; &#xA;  }&#xA;  return(strip.Color(r,g,b));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="617" LastEditorUserId="42" LastEditDate="2014-03-14T10:53:22.070" LastActivityDate="2014-03-14T11:36:47.860" Title="Digital RGB LED animation" Tags="|programming|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="737" PostTypeId="2" ParentId="736" CreationDate="2014-03-14T11:36:47.860" Score="6" Body="&lt;p&gt;Currently, your fade function is starting at 0 and effectively interpolating up to the desired colour. To fade between colours, you would need the sketch to remember the previous colour it used, and start fading from that instead of from 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The approach I'd use is to start by calculating how much each component needs to change by on each step. For example, if you want to fade from 100 to 200 across 50 steps, then it needs to change by +2 on every step. If you wanted to do the same in reverse (200 to 100) then it would have to change by -2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the problems is that each component will probably be changing by a different amount (red might go from 0 to 200, but blue might only go from 50 to 70). If you're using integers all the time then it could result in some uneven transitions, so I'd recommend using floating point instead. It's technically slower (less efficient), but probably not enough to worry about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I'd probably write it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void fade(uint8_t oldR, uint8_t oldG, uint8_t oldB, uint8_t newR, uint8_t newG, uint8_t newB, uint32_t numSteps, uint32_t waitPerStep)&#xA;{&#xA;    // Guard against division by zero&#xA;    if (numSteps == 0) numSteps = 1;&#xA;&#xA;    // Calculate how how much each colour needs to change on each step&#xA;    const float&#xA;        stepR = (newR - oldR) / (float)numSteps,&#xA;        stepG = (newG - oldG) / (float)numSteps,&#xA;        stepB = (newB - oldB) / (float)numSteps;&#xA;&#xA;    // These values will store our colours on the way along&#xA;    float r = oldR, g = oldG, b = oldB;&#xA;    uint8_t byteR = oldR, byteG = oldG, byteB = oldB;&#xA;&#xA;    // Go through each fade step&#xA;    const uint16_t numPixels = strip.numPixels();&#xA;    for (uint32_t step = 0; step &amp;lt; numSteps; ++step) {&#xA;        // Move one step towards the target colour&#xA;        r += stepR;&#xA;        g += stepG;&#xA;        b += stepB;&#xA;&#xA;        // Round the colours to integers here so we don't have to do it repeatedly in the loop below&#xA;        byteR = (uint8_t)(r + 0.5f);&#xA;        byteG = (uint8_t)(g + 0.5f);&#xA;        byteB = (uint8_t)(b + 0.5f);&#xA;&#xA;        // Apply the colour to each pixel&#xA;        for (uint16_t pixel = 0; pixel &amp;lt; numPixels; ++pixel) {&#xA;            strip.setPixelColor(pixel, byteR, byteG, byteB);&#xA;        }&#xA;&#xA;        strip.show();&#xA;        delay(waitPerStep);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, you pass it the old colour (which you're fading &lt;em&gt;from&lt;/em&gt;) and the new colour (which you're fading &lt;em&gt;to&lt;/em&gt;). As I mentioned above, this means your sketch has to remember which colour it previously used, as I don't think the library provides a way to read the current colour back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included some optimisations in there to make it run faster. There's more you could do to optimise it even further, if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use this, you'd do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Fade from black to red and pause briefly&#xA;fade(0, 0, 0,  255, 0, 0,  100, 10);&#xA;delay(500);&#xA;&#xA;// Fade from red to purple and pause briefly&#xA;fade(255, 0, 0,   255, 0, 255,  100, 10);&#xA;delay(500);&#xA;&#xA;// Fade from purple to green and pause briefly&#xA;fade(255, 0, 255,  0, 255, 0,  100, 10);&#xA;delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've made a couple of other changes compared to your own fade function function. First of all, I've made it so that you can set the number of steps to fade over. This can be quite useful because bigger colour changes will need more steps to look smooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also modified the &lt;code&gt;wait&lt;/code&gt; parameter. In your code, you put the delay after the entire fade was complete, which seems like an odd approach. It makes more sense to allow a small delay between each step of the fade, so you can control how fast it goes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my example above, you can see the &lt;code&gt;100, 10&lt;/code&gt; parameters at the end of each call to &lt;code&gt;fade()&lt;/code&gt;. That means it will divide the colour change into 100 steps, with a delay of 10ms between each step. The result is that each fade will take roughly 1 second (not counting the time taken to actually update the LED strip).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-14T11:36:47.860" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="738" PostTypeId="2" ParentId="735" CreationDate="2014-03-14T14:55:14.040" Score="2" Body="&lt;p&gt;I've used &lt;a href=&quot;http://arcbotics.com/products/sparki/start&quot; rel=&quot;nofollow&quot;&gt;Sparki&lt;/a&gt; from Arcbotics as a robotics platform. It's uses Arduino Sketch to program and a modified Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensors for line following , edge detection, distance and light level sensing are built in. Also the creators are focused on education so the material and projects are teaching oriented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Community seems pretty active and engaged too so the material should build over time.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-03-14T14:55:14.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="739" PostTypeId="1" CreationDate="2014-03-14T16:47:37.697" Score="20" ViewCount="24796" Body="&lt;p&gt;Uploading simple sketches seems to work when I run the Arduino program as root (&lt;code&gt;sudo&lt;/code&gt;). I would like to run it as a regular user. Has anyone faced the same problem before and fixed it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I obtained from &lt;code&gt;lsusb&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb&#xA;Bus 002 Device 022: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the Arduino program identifies it as &lt;code&gt;/dev/ttyACM0&lt;/code&gt;. Here are its permissions: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -l /dev/ttyACM0 &#xA;crw-rw---T 1 root dialout 166, 0 Mar 14 22:03 /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the output from &lt;code&gt;id&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;groups=1000(abhiram),20(dialout),24(cdrom),25(floppy),29(audio),&#xA;30(dip),44(video),46(plugdev),105(scanner),110(bluetooth),112(netdev)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I upload an sketch from the examples, as a regular user, I encounter this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude:stk500_recv(): programmer not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions are welcome.&lt;/p&gt;&#xA;" OwnerUserId="618" LastEditorUserId="618" LastEditDate="2014-03-15T06:41:26.590" LastActivityDate="2018-05-22T13:07:17.360" Title="Arduino program only works when run as root" Tags="|arduino-uno|arduino-ide|linux|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="741" PostTypeId="2" ParentId="665" CreationDate="2014-03-14T17:32:03.900" Score="4" Body="&lt;p&gt;I would actually suggest LiFePo4 for anything DIY. Not only is it safer so one false move won't cause an inferno, but it will last two to four times as long at the CONST of a little extra size and weight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are just running an arduino, I would use only 1 single cell, and avoid cell balance woes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would use a boost regulator to step up the voltage from the cell to the required 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To actually charge the cell, I would probably use a cheap ebay CC-CV charger board, and set the voltage for about 0.15V below the max for your lifepo(you only lose 10% of the energy but You make the battery last much longer), and set the current as appropriate for your panel and battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your circuit is drawing power while the charger is charging, your circuit will take what it needs and any extra the charger puts out will go into the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might need a diode, to make the battery not discharge back through the charger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a protection pcb like you can get from batteryspace, or better yet a protected lifepo with the pcb built it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember to size your solar panel so that there is enough energy to keep the circuit running. Even with the protected cells overdischarge kills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd really like to do is design a lifepo4 charge control board that had all this in one unit since everyone seems to want it...&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-03-14T17:32:03.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="742" PostTypeId="2" ParentId="739" CreationDate="2014-03-14T17:48:43.850" Score="13" Body="&lt;p&gt;The easiest solution is to add yourself to the &lt;code&gt;dialout&lt;/code&gt; group.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First make a note of the output from &lt;code&gt;id&lt;/code&gt;. Save it in file (not in &lt;code&gt;/tmp&lt;/code&gt; as that gets cleaned out on a reboot). If you look at the output, you'll notice that your user is signed up for several groups and those groups represent extra privileges on the system. By default your Arduino is assigned to the group &lt;code&gt;dialout&lt;/code&gt; because it registers as a serial interface and in the old days these were often used to ... dial out, using a modem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add yourself to the &lt;code&gt;dialout&lt;/code&gt; group, issue the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo usermod -a -G dialout $USER&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't forget the &lt;code&gt;-a&lt;/code&gt; flag (for appending groups rather than replacing) or you will have entirely different problems. This is the reason for making a copy of the &lt;code&gt;id&lt;/code&gt; output to a file, so in case you do mess up at least you know what your user was configured like before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then log out and log in and it should work from that point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optionally you can double check the output for &lt;code&gt;id&lt;/code&gt; against the output you saved before.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="4527" LastEditDate="2018-05-22T13:07:17.360" LastActivityDate="2018-05-22T13:07:17.360" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="743" PostTypeId="2" ParentId="348" CreationDate="2014-03-15T10:22:25.003" Score="4" Body="&lt;p&gt;You could use the makefile &#xA;&lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sudar/Arduino-Makefile&lt;/a&gt;&#xA;for compiling Arduino codes. You don't necessarily need the IDE.&lt;/p&gt;&#xA;" OwnerUserId="624" LastActivityDate="2014-03-15T10:22:25.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="744" PostTypeId="1" AcceptedAnswerId="753" CreationDate="2014-03-15T19:33:42.287" Score="1" ViewCount="2444" Body="&lt;p&gt;I downloaded Arduino code from this: &lt;a href=&quot;https://github.com/BabyWrassler/MissionControl/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/BabyWrassler/MissionControl/&lt;/a&gt; Github, and got the  error message below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is designed to work with a Raspberry Pi, and I installed the two Adafruit libraries.  I also have not hooked it up to either the Pi, or the two Adafruit devices, but that is partly because I cannot get it to run without the error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Here is what was highlighted: &#xA;&lt;code&gt;Adafruit_LEDBackpack matrixA = Adafruit_LEDBackpack();&lt;/code&gt;&#xA;The orange bar says:&#xA;    Variable or field ‘matrixOff‘ declared void&#xA;I cannot tell what of the following was from before, but here is the entire console log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    mcDesk.ino:2:53: error: Adafruit_LEDBackpack.h: No such file or directory&#xA;    mcDesk.ino:3:45: error: Adafruit_GFX.h: No such file or directory&#xA;    mcDesk:11: error: variable or field 'matrixOff' declared void&#xA;    mcDesk:11: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:11: error: expected primary-expression before 'buffer'&#xA;    mcDesk:12: error: variable or field 'ledOn' declared void&#xA;    mcDesk:12: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:12: error: expected primary-expression before 'buffer'&#xA;    mcDesk:12: error: expected primary-expression before 'cat'&#xA;    mcDesk:12: error: expected primary-expression before 'an'&#xA;    mcDesk:13: error: variable or field 'ledOff' declared void&#xA;    mcDesk:13: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:13: error: expected primary-expression before 'buffer'&#xA;    mcDesk:13: error: expected primary-expression before 'cat'&#xA;    mcDesk:13: error: expected primary-expression before 'an'&#xA;    mcDesk:14: error: variable or field 'dispMat' declared void&#xA;    mcDesk:14: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:14: error: expected primary-expression before 'buffer'&#xA;    mcDesk:17: error: variable or field 'threeDigitDisp' declared void&#xA;    mcDesk:17: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:17: error: expected primary-expression before 'buffer'&#xA;    mcDesk:17: error: expected primary-expression before 'cats'&#xA;    mcDesk:17: error: expected primary-expression before 'ans'&#xA;    mcDesk:17: error: expected primary-expression before 'number'&#xA;    mcDesk:18: error: variable or field 'digitDisp' declared void&#xA;    mcDesk:18: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:18: error: expected primary-expression before 'buffer'&#xA;    mcDesk:18: error: expected primary-expression before 'pos'&#xA;    mcDesk:18: error: expected primary-expression before 'cat'&#xA;    mcDesk:18: error: expected primary-expression before 'an'&#xA;    mcDesk:18: error: expected primary-expression before 'num'&#xA;    mcDesk:23: error: variable or field 'switchBars' declared void&#xA;    mcDesk:23: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:23: error: expected primary-expression before 'buffer'&#xA;    mcDesk:23: error: expected primary-expression before 'grphCats'&#xA;    mcDesk:23: error: expected primary-expression before 'grphAns'&#xA;    mcDesk:23: error: expected primary-expression before 'cmnd'&#xA;    mcDesk:23: error: expected primary-expression before 'offset'&#xA;    mcDesk:24: error: variable or field 'barDisp' declared void&#xA;    mcDesk:24: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:24: error: expected primary-expression before 'buffer'&#xA;    mcDesk:24: error: expected primary-expression before 'grphCats'&#xA;    mcDesk:24: error: expected primary-expression before 'grphAns'&#xA;    mcDesk:24: error: expected primary-expression before 'pos'&#xA;    mcDesk:24: error: expected primary-expression before 'offset'&#xA;    mcDesk:25: error: variable or field 'cBarDisp' declared void&#xA;    mcDesk:25: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:25: error: expected primary-expression before 'buffer'&#xA;    mcDesk:25: error: expected primary-expression before 'grphCats'&#xA;    mcDesk:25: error: expected primary-expression before 'grphAns'&#xA;    mcDesk:25: error: expected primary-expression before 'pos'&#xA;    mcDesk:25: error: expected primary-expression before 'offset'&#xA;    mcDesk:11: error: 'Adafruit_LEDBackpack' does not name a type&#xA;    mcDesk:12: error: 'Adafruit_LEDBackpack' does not name a type&#xA;    mcDesk:13: error: 'Adafruit_LEDBackpack' does not name a type&#xA;    mcDesk:14: error: 'Adafruit_LEDBackpack' does not name a type&#xA;    mcDesk:15: error: 'Adafruit_LEDBackpack' does not name a type&#xA;    mcDesk.ino: In function 'void decodeCommand()':&#xA;    mcDesk:193: error: 'matrixE' was not declared in this scope&#xA;    mcDesk:193: error: 'ledOn' was not declared in this scope&#xA;    mcDesk:199: error: 'matrixE' was not declared in this scope&#xA;    mcDesk:199: error: 'ledOff' was not declared in this scope&#xA;    mcDesk:204: error: 'matrixC' was not declared in this scope&#xA;    mcDesk:204: error: 'cBarDisp' was not declared in this scope&#xA;    mcDesk.ino: In function 'void allMatrixOff()':&#xA;    mcDesk:213: error: 'matrixA' was not declared in this scope&#xA;    mcDesk:213: error: 'matrixOff' was not declared in this scope&#xA;    mcDesk:214: error: 'matrixB' was not declared in this scope&#xA;    mcDesk:215: error: 'matrixC' was not declared in this scope&#xA;    mcDesk:216: error: 'matrixD' was not declared in this scope&#xA;    mcDesk:217: error: 'matrixE' was not declared in this scope&#xA;    mcDesk.ino: At global scope:&#xA;    mcDesk:220: error: variable or field 'matrixOff' declared void&#xA;    mcDesk:220: error: 'Adafruit_LEDBackpack' was not declared in this scope&#xA;    mcDesk:220: error: expected primary-expression before 'buffer'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="196" LastEditorUserId="196" LastEditDate="2014-03-16T22:30:03.590" LastActivityDate="2014-03-16T22:30:03.590" Title="Arduino error message that I don't understand" Tags="|library|sketch|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="745" PostTypeId="5" CreationDate="2014-03-15T20:45:08.277" Score="0" Body="&lt;p&gt;Solar power approaches to powering an Arduino project.  This may include power generation, buffering with batteries or smoothing capacitors, and interfacing with the board itself.&lt;/p&gt;&#xA;" OwnerUserId="213" LastEditorUserId="213" LastEditDate="2014-03-15T21:05:10.760" LastActivityDate="2014-03-15T21:05:10.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="746" PostTypeId="4" CreationDate="2014-03-15T20:45:08.277" Score="0" Body="Solar powered projects." OwnerUserId="213" LastEditorUserId="213" LastEditDate="2014-03-15T21:05:03.387" LastActivityDate="2014-03-15T21:05:03.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="747" PostTypeId="1" CreationDate="2014-03-15T22:38:07.423" Score="1" ViewCount="6048" Body="&lt;p&gt;I have Arduino Leonardo board operating lots of AC relays in quite noisy environment. USB works unstable, which sometimes causes the board to hang, so I decided to use secondary serial connection as &quot;debug console&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial1.begin(115200); &#xA;  .....&#xA;  .....&#xA;  if (Serial1.available()) {&#xA;    char ch = Serial1.read();&#xA;    if ( isalnum(ch) ) {&#xA;      switch (ch) {&#xA;        case 'M': {&#xA;          turnOn_pin_Motor();&#xA;          break;&#xA;        }&#xA;        case 'm': {&#xA;          turnOff_pin_Motor();&#xA;          break;&#xA;        }&#xA;        .......&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that noise affects Serial1 the same way it messes USB (but at least it doesn't cause it to freeze). I'd like to use some sort of error checking to prevent Leonardo from acting on &quot;phantom&quot; commands. I could, for example, prefix each keyboard command my Arduino should receive with special symbol, maybe &quot;!&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I must be reading one char, checking if it is &quot;!&quot; and reading second character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I can't modify my code so it would use 2-character buffer and shift its contents as characters arrive, without locking the main loop while waiting for the next char. Any hints on what should I do in this case?&lt;/p&gt;&#xA;" OwnerUserId="562" LastActivityDate="2014-04-23T08:46:56.323" Title="Reading multiple bytes from *software* serial" Tags="|serial|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="748" PostTypeId="1" CreationDate="2014-03-13T18:06:28.733" Score="2" ViewCount="253" Body="&lt;p&gt;I made a working model of Bluetooth light control with arduino and Bluetooth. Everything worked fine and then after some time I connected the circuit again it didn't work and the pins 7,10,11,12 aren't working . I was using a Bluetooth shield but I tried the simple LED flash program and even that's not working .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest any good way of making it working again or at least explain what happened with it.&lt;/p&gt;&#xA;" OwnerDisplayName="Kam" LastEditorUserId="11" LastEditDate="2014-03-16T00:20:57.963" LastActivityDate="2014-03-16T00:20:57.963" Title="Is my Arduino destroyed or are the pins destroyed?" Tags="|pins|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="749" PostTypeId="2" ParentId="748" CreationDate="2014-03-13T20:19:28.100" Score="6" Body="&lt;p&gt;Try running the blink LED, on a different terminals.&#xA;If the LED is working properly, then most likely the pins are destroyed.&#xA;Why are they destroyed?&#xA;Most likely, you've withdrawn more current than the pins can actually provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the datasheet of the Arduino uno, the IO pins can handle up to 40mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eapOV.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible way to solve this problem is to change the IC (Atmega328) by another one. It's not guranteed that it will work, but the microcontroller is reletively cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The definite answer can not be determined unless you showed us a schematic of your connection.&lt;/p&gt;&#xA;" OwnerUserId="467" OwnerDisplayName="Adel Bibi" LastActivityDate="2014-03-13T20:19:28.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="750" PostTypeId="1" AcceptedAnswerId="755" CreationDate="2014-03-16T01:33:14.700" Score="21" ViewCount="15741" Body="&lt;p&gt;I have a few Arduino Pro Mini clones (cheap Chinese stuff) and would like to power them with 12V power supply (same as fan voltage). According to the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardProMini#.UyT9APl_sz0&quot;&gt;Arduino Pro Mini spec&lt;/a&gt; the RAW pin can take 3.35-12V (3.3V model). In practice this means a 12V PSU cannot be used as they are almost always over 12V with low load. I read that the voltage regulator in this board is capable up to 16V input. I tried plugging in a cheap 12V power adapter that read 15.1V with no load but a component on the arduino clone board actually exploded instantly. The board seems to work still when powered from usb programmer. Component that burned out is just above VCC, RST and GND pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why did this happen? What did I just damage and most importantly what is a safe voltage level to use? I already have a few 12V switching power supplies it would be a shame if I could not use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end it seems to have been a faulty arduino clone, faulty or poor quality power adapter or the fact that I powered the power supply before plugging it to the board's RAW input pin. The cheap 12V switching power supplies work just fine even though my multimeter registers a voltage spike as high as 30V during power up.&lt;/p&gt;&#xA;" OwnerUserId="633" LastEditorUserId="612" LastEditDate="2014-09-24T15:23:31.833" LastActivityDate="2021-03-09T03:01:47.990" Title="Arduino Pro Mini (3.3V version) input voltage range / tolerance" Tags="|clones|voltage-level|arduino-pro-mini|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="752" PostTypeId="2" ParentId="750" CreationDate="2014-03-16T08:16:06.193" Score="3" Body="&lt;p&gt;The component that exploded during your test is a capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the position on the board you mentioned, it is one of the 2 electrolytic capacitors used on both sides of the 3.3V regulator (I would say that's probably the upstream capcitor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;a href=&quot;http://en.wikipedia.org/wiki/Capacitor#Hazards_and_safety&quot; rel=&quot;nofollow&quot;&gt;a few reasons why a capacitor may explode&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;apply an inverted voltage to it (polarized capacitors only)&lt;/li&gt;&#xA;&lt;li&gt;apply a voltage above its rating&lt;/li&gt;&#xA;&lt;li&gt;apply a current above its rating&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your situation is probably the 2nd one: too high voltage applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to Sparkfun original schematics, this capacitor must be polarized with 10uF capacity. Unfortunately the schematics do not mention the maximum voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow&quot;&gt;specification for the original board&lt;/a&gt;, the maximum voltage for this cap should be at least 12V, but there is no guarantee that it is anthing above than 12V. Hence, you have to consider &lt;strong&gt;12V is the maximum voltage applicable&lt;/strong&gt; to your board (on the RAW pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, you have mentioned you are using a cheap chinese clone, it is perfectly possible (although not expected, as it would make the board operate differently than the original specs) that this one uses a lower voltage cap (eg 10V) which would be a bit cheaper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to reuse your 12V PSU, you will have to ensure that its output voltage never exceeds 12V, for this you are left with a few options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;voltage divider&lt;/a&gt; made of 2 resistors: you must first know the max voltage output of your PSU and then calculate resistance values to get 12V based on that max voltage. That's easy but it can waste a lot of energy&lt;/li&gt;&#xA;&lt;li&gt;use a 12V &lt;a href=&quot;http://en.wikipedia.org/wiki/Zener_diode&quot; rel=&quot;nofollow&quot;&gt;Zener diode&lt;/a&gt; outside your PSU&lt;/li&gt;&#xA;&lt;li&gt;use a 12V &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_regulator&quot; rel=&quot;nofollow&quot;&gt;voltage regulator&lt;/a&gt; circuit after your PSU: that one is the safest, but also the most expensive solution&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you have already done it and are equipped for it, you can find replacements for the capacitor that has exploded and buy a higher-voltage one, then replace it on your boards; that will reauire good soldering/desoldering equipement usable for surface-mounted components.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-16T08:34:00.160" LastActivityDate="2014-03-16T08:34:00.160" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="753" PostTypeId="2" ParentId="744" CreationDate="2014-03-16T08:28:34.017" Score="4" Body="&lt;p&gt;It seems to me that those Adafruit libraries were not correctly installed on your PC or your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to downloading and installing the library onto the Arduino library directory (on Windows, that's normally &lt;code&gt;C:\Users\UserName\Documents\Arduino\libraries&lt;/code&gt;), when you want to use that library with Arduino IDE, you must add the library for your sketch with the menu command &quot;&lt;strong&gt;Sketch -&gt; Import Library...&lt;/strong&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;: it seems just adding &lt;code&gt;#include &quot;library.h&quot;&lt;/code&gt; does not work with Arduino IDE, you absolutely need to use the menu.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-16T08:28:34.017" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="754" PostTypeId="2" ParentId="179" CreationDate="2014-03-16T09:43:55.223" Score="26" Body="&lt;p&gt;This answer doesn't directly answer the question, but still will result in the same end result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE uses temporary directories to store build files, including the original sketch as well as the HEX and intermediate files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a Mac, these are in /var/folders by default, and on a Windows machine they are in …\Local Settings\Temp\ (which depending on the version of Windows could be in several places).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found that especially in Windows, these build files don't get deleted when you close the sketch or IDE, so they may exist on your machine for far longer than you would think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, by default, Crashplan, Backblaze and Time Machine back-up these locations, so even if they have been deleted, they may still be in a backup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage here is that you will recover C code rather than ASM.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="10907" LastEditDate="2016-01-12T05:32:46.657" LastActivityDate="2016-01-12T05:32:46.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="755" PostTypeId="2" ParentId="750" CreationDate="2014-03-16T10:25:12.787" Score="19" Body="&lt;p&gt;The genuine Pro Mini's use a &lt;a href=&quot;http://www.micrel.com/_PDF/mic5205.pdf&quot; rel=&quot;noreferrer&quot;&gt;MIC5205 regulator&lt;/a&gt; which should accept up to 16V at it's input normally, with an absolute maximum of 20V. It's unlikely that the regulator would be damaged by 15.1V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the component you have indicated that has blown is a capacitor. SMD capacitors are available in different voltage ratings, typically 4V, 6.3V, 10V, 16V, 25V, 35V and 50V (and above, but let's ignore them for this). It's rare to see any intermediate values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SMD capacitors are very intolerant of being used at a higher voltage than specified. This is especially true of electrolytic and tantalum capacitors. The blown capacitor on the genuine Pro Mini's is polarised (the grey band not he package and the schematic indicates this), so we can infer it is either electrolytic or tantalum. A 10µF SMD electrolytic is unlikely to be in this package, so it is almost certainly a tantalum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sparkfun sell &lt;a href=&quot;https://www.sparkfun.com/products/11244&quot; rel=&quot;noreferrer&quot;&gt;10µF tantalums&lt;/a&gt;, and they are rated at 16V. It's quite likely these are the same ones used on the Pro Mini. 15.1V is very close to 16V - in fact, if this is a poorly smoothed power supply, the meter might show 15.1V but the peaks could well be 16V or even 20V. It is recommended that you de-rate the voltage ratings on tantalums by 50% at least.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really important to realise that most low-cost DC power supplies are not regulated and produce a very bumpy output voltage with no regulation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ihvi5.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tantalums also have no tolerance for reverse voltage, so if you did apply reverse voltage, it would pop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is quite likely that you over-volted the cap and blew it. You could replace them with higher rated capacitors - I would go for 35V ones if you want to supply 15.1V. Desoldering and desoldering a single capacitor is relatively easy as long as the pads haven't been damaged. Realistically, you could use a normal leaded 10uF electrolytic between RAW and GND instead of the SMD one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; However, looking at the data sheet for the regulator, it shouldn't really matter if that 10uF is there or not:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A 1μF capacitor should be placed from IN to GND if there is more than&#xA;  10 inches of wire between the input and the ac filter capacitor or if&#xA;  a battery is used as the input.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some regulators absolutely require an input capacitor, with others it is just advisable. This looks like it is just advisable. So if it isn't working on external power now, you may have blown the regulator as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if the clone board uses a different SMD regulator, their characteristics are all very similar. As stated, some do need a capacitor on the input to work, so replacing it might fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a further consideration that dropping from 15.1V to 3.3V on a SMD regulator is not a great idea. You will need to burn off a lot of power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MC5205 can dissipate 455mW with a minimal PCB footprint (which the Pro Mini has) with a 25°C ambient:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lBlQZ.png&quot; alt=&quot;Thermal calc&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we know the maximum power we can dissipate, and we know the voltage drop - we can then calculate the current:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P = (Vin - Vout) * I&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0.455 / (15.1 - 3.3) = I&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I = 38.5mA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't very much at all. You might want to consider regulating off the board, and probably with a switching regulator rather than linear regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also note your PS:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the ground of the 12V PSU is shared with Arduino ground pin, not sure&#xA;  if this might be the cause.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If they weren't shared, there would be no way that this could work. They need to be shared otherwise the Vcc from the power supply is not referenced to anything and may as well not be there.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-16T10:46:31.733" LastActivityDate="2014-03-16T10:46:31.733" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="756" PostTypeId="1" CreationDate="2014-03-16T10:52:39.307" Score="8" ViewCount="293" Body="&lt;p&gt;I've noticed some irritating differences between the Arduino IDE and Stino (mainly around including certain header files). These are likely bugs that need following up with one or both of the parties, but in the meantime, I would like my code to compile with both of them without editing. This is because I do not want to lock any users out of using my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any macros or similar that are readily available (as in, require no modification of the toolchain or IDE) that would allow me to detect which is in use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in many libraries, there is this snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if ARDUINO &amp;gt;= 100&#xA;  #include &quot;Arduino.h&quot;&#xA;#else&#xA;  #include &quot;WProgram.h&quot;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However both Stino and Arduino define this.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2015-04-27T23:50:57.110" Title="Is there a way to detect if Arduino, Stino or another IDE/toolchain is in use?" Tags="|ide|build|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="757" PostTypeId="1" CreationDate="2014-03-16T11:31:29.970" Score="13" ViewCount="12855" Body="&lt;p&gt;Nearly all modern Arduino boards use the &lt;a href=&quot;https://code.google.com/p/optiboot/&quot;&gt;Optiboot bootloader&lt;/a&gt;. Compared to the ATmegaboot used before, this is smaller in flash terms (by about 1.5KB) and faster in upload speed (115.2k vs 57.6k) and starts your sketch quicker (the delay whilst waiting after reset is shorter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any alternatives to the Optiboot bootloader? Specifically, are there any smaller (in flash terms) boot loaders? What differences do they have?&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2015-12-11T18:43:38.250" Title="What alternatives are there to the Optiboot bootloader?" Tags="|bootloader|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="758" PostTypeId="2" ParentId="747" CreationDate="2014-03-16T11:45:16.947" Score="3" Body="&lt;p&gt;Serial1 on the Arduino Leonardo is hardware serial, not software. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to read in multiple bytes from Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of detecting &lt;code&gt;Serial.available()&lt;/code&gt; (i.e. non-zero), change it to &lt;code&gt;Serial.available() &amp;gt;= 2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available() &amp;gt;= 2) {&#xA;  for (int i=0; i&amp;lt;2; i++) {&#xA;    buffer[i] = Serial.read();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can leave it as it is, and read into the buffer one at a time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static int bufferIndex;&#xA;&#xA;if (Serial.available())&#xA;{&#xA;    buffer[bufferIndex++] = Serial.read()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll need to detect the contents of the buffer in another &lt;code&gt;if&lt;/code&gt; statement, and also deal with the bounds of the index.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Honestly though, noise is your issue here - this is an example of an &lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem&quot;&gt;XY problem&lt;/a&gt;. There's nothing inherent in using a microcontroller with relays that should mean that serial won't work.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="-1" LastEditDate="2017-03-20T10:32:30.027" LastActivityDate="2014-03-16T11:45:16.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="759" PostTypeId="1" AcceptedAnswerId="773" CreationDate="2014-03-16T13:54:12.883" Score="7" ViewCount="244" Body="&lt;p&gt;I would like to constantly save data coming from sensors (for an activity tracker) while consuming as less battery as possible (I'd like to have a 4/5 days autonomy on a 3000 mAh battery) but I can't find the best way to save about 2 kBytes/s on a memory large enough to contain several days of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensors would be read at a rate of 20 times per second and produce about 100 bytes each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What options do I have in order to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;store such an amount of data (hardware)?&lt;/li&gt;&#xA;&lt;li&gt;ensure the system can work properly with required autonomy?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="453" LastEditorUserId="84" LastEditDate="2014-03-16T19:43:08.150" LastActivityDate="2014-03-16T20:03:56.367" Title="Most power efficient way to constantly save 2 kilobytes of data per second" Tags="|battery|system-design|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="760" PostTypeId="1" CreationDate="2014-03-16T13:59:26.437" Score="11" ViewCount="22076" Body="&lt;p&gt;On my Arduino Uno R3 and Arduino Mega R3, there are 5V and 3.3V pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However on this page &lt;a href=&quot;http://arduino.cc/en/reference/board&quot; rel=&quot;noreferrer&quot;&gt;Introduction to the Arduino Board&lt;/a&gt;, there is a 5V and 9V pin but no 3.3V pin. The page at &lt;a href=&quot;http://playground.arduino.cc/Learning/WhatAdapter&quot; rel=&quot;noreferrer&quot;&gt;Arduino: What Adapter?&lt;/a&gt; also mentions a 9V pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is there a discrepency?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YBmuc.png&quot; alt=&quot;Arduino UNO Board Layout&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="6936" LastEditDate="2015-07-20T11:53:59.103" LastActivityDate="2015-07-20T11:53:59.103" Title="3.3V, 5V and 9V pins on Arduino" Tags="|arduino-uno|pins|power|arduino-mega|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="761" PostTypeId="2" ParentId="760" CreationDate="2014-03-16T14:34:59.450" Score="8" Body="&lt;p&gt;There are three power supply pins on the Arduino Uno and on the Mega:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5V - Labelled as 5V. Can be used to power other 5V devices.&lt;/li&gt;&#xA;&lt;li&gt;3.3V - Labelled as 3.3V. Can be used to power other 3.3V devices.&lt;/li&gt;&#xA;&lt;li&gt;Vin - This also referred to as the 9V pin that is shown in the schematic. This is used to power the Arduino board itself, usually using a 9V battery.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cpfrj.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-16T14:42:43.467" LastActivityDate="2014-03-16T14:42:43.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="762" PostTypeId="2" ParentId="760" CreationDate="2014-03-16T14:36:30.767" Score="9" Body="&lt;p&gt;The link you provide looks rather old and I don't think it applies to UNO Revision 3 as it has more pins than on the diagram you show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you rather take a look at this &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot;&gt;Arduino UNO link&lt;/a&gt; which contains uptodate information about the UNO; in there you will see that for R3, the &quot;power rail&quot; has been extended and has the following pins, left to right:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 unlabeled pin (can't remember what it is)&lt;/li&gt;&#xA;&lt;li&gt;1 &lt;strong&gt;IOREF&lt;/strong&gt; pin (used by shields to know if they should operate as 3.3V or 5V devices)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;3.3V&lt;/strong&gt; regulated output&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;5V&lt;/strong&gt; regulated output&lt;/li&gt;&#xA;&lt;li&gt;2 &lt;strong&gt;GND&lt;/strong&gt; pins&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Vin&lt;/strong&gt; pin: this pin can be used in 2 different ways:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either as a voltage supply input (instead of using the power plug or the USB); the input voltage should be in 7-12V range and will be regulated internally (by the board circuits) to 5V&lt;/li&gt;&#xA;&lt;li&gt;or an output supply voltage (if you plugged voltage supply through the power plug or the USB plug) that is a &quot;copy&quot; of the voltage input through the power plug or USB plug (not regulated yet)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-16T14:36:30.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="763" PostTypeId="1" AcceptedAnswerId="777" CreationDate="2014-03-16T15:00:54.307" Score="20" ViewCount="9465" Body="&lt;p&gt;I would like to know how much RAM I am using in my project, as far as I can tell, there's no way to actually work that out (other than going through and calculating it myself). I have got to a stage in a rather large project where I have determined that I am running out of RAM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have determined this because I can add a section and then all hell breaks loose &lt;strong&gt;somewhere else in my code&lt;/strong&gt; for no apparent reason. If I &lt;code&gt;#ifndef&lt;/code&gt; something else out, it works again. There is nothing programatically wrong with the new code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspected for a while that I was getting to the end of available RAM. I don't think I'm using too much stack (although it's possible), what is the best way to determine how much RAM I am actually using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going through and trying to work it out, I have problems when I get to enums and structs; how much memory do they cost? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;first&lt;/em&gt; edit: ALSO, I have edited my sketch so much since starting, these are not the actual results I initially got, but they are what I am getting now. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  text     data     bss     dec     hex filename&#xA; 17554      844     449   18847    499f HA15_20140317w.cpp.elf&#xA; 16316      694     409   17419    440b HA15_20140317w.cpp.elf&#xA; 17346      790     426   18562    4882 HA15_20140317w.cpp.elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line (with text 17554) was not working, after much editing, the second line (with text 16316) is working as it should. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;edit: the third line has everything working, serial reading, my new functions, etc. I essentially removed some global variables and duplicate code. I mention this because (as suspected) it's not about this code per sae, it has to be about the RAM usage. Which brings me back to the original question, &quot;how to best measure it&quot; I'm still checking out some answers, thanks.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I actually interpret the above information? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far my understanding is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;`TEXT` is program instruction memory&#xA;`DATA` is variables (unitialised?) in program memory&#xA;`BSS`  is variables occupying RAM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;since BSS is considerably less than 1024 bytes, why does the second work, but the first doesn't? If it's &lt;code&gt;DATA+BSS&lt;/code&gt; then both occupy more than 1024. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;re-edit:&lt;/em&gt; I edited the question to include the code, but now I've removed it because it really had nothing to do with the problem (other than maybe poor coding practices, variable declarations and the like). You can review the code by looking back through the edits if you &lt;em&gt;really&lt;/em&gt; want to see it. I wanted to get back to the question at hand, which was more based around: How to measure RAM usage.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-03-17T15:15:47.650" LastActivityDate="2018-06-14T13:40:13.447" Title="I'm using too much RAM. How can this be measured?" Tags="|sram|" AnswerCount="5" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="764" PostTypeId="2" ParentId="763" CreationDate="2014-03-16T15:15:03.480" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I suspected for a while that I was getting to the end of available RAM. I don't think I'm using too much stack (although it's possible), what is the best way to determine how much RAM I am actually using?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It would be best to use a combination of manual estimation and by using the &lt;code&gt;sizeof&lt;/code&gt; operator. If all your declarations are static, then this should give you an accurate picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using dynamic allocations, then you may run into a problem once you start deallocating the memory. This is due to memory fragmentation on the heap. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Going through and trying to work it out, I have problems when I get to enums and structs; how much memory do they cost?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An enum takes as much space as an &lt;code&gt;int&lt;/code&gt;. So, if you have a set of 10 elements in a &lt;code&gt;enum&lt;/code&gt; declaration, that would be &lt;code&gt;10*sizeof(int)&lt;/code&gt;. Also, every variable that uses an enumeration is simply an &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For structures, it would be easiest to use &lt;code&gt;sizeof&lt;/code&gt; to find out. Structures occupy a (minimum) space equal to sum of its members. If the compiler does structure alignment, then it may be more, however this is unlikely in the case of &lt;code&gt;avr-gcc&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-16T15:15:03.480" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="765" PostTypeId="2" ParentId="725" CreationDate="2014-03-16T15:18:53.663" Score="2" Body="&lt;p&gt;I think the problem is with your bootloader, but not in the way you think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When an Arduino starts up, a bootloader profiting several tasks, such as looking for a serial host or loading program data from flash is going to take a lot more energy than a sleeping Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the reason why your Arduino will not start is because the bootloader requires an accurate clock source, but applying 3v to it will mess up that clock and it will perhaps crash or wait for 3.3v to be applied for a stable source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NZAHA.jpg&quot; alt=&quot;copyright ATMEL&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We see that current draw while waking up (running the bootloader) is probably going to be around 2mA, while sleeping current is about &lt;em&gt;0.8 microamps&lt;/em&gt;. This could certainly lead to a blackout on startup without the proper current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps you should only turn it on with 5v power, or maybe you need a higher current, higher voltage battery.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-16T15:18:53.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="766" PostTypeId="1" CreationDate="2014-03-16T16:40:08.613" Score="0" ViewCount="140" Body="&lt;p&gt;I got an Arduino Uno to play around with, and started to actually dive in. During a program that I am writing for a friend, it suddenly stopped outputting to the serial monitor. When I comment out the part I added (the for loop for changing the names), it still doesn't respond. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#define numPokemon 151&#xA;String nameArray[] = {&quot;MISSINGNO&quot;,&quot;Bulbasaur&quot;,&quot;Ivysaur&quot;,&quot;Venusaur&quot;,&quot;Charmander&quot;,&quot;Charmeleon&quot;,&quot;Charizard&quot;,&quot;Squirtle&quot;,&#xA;&quot;Wartortle&quot;,&quot;Blastoise&quot;,&quot;Caterpie&quot;,&quot;Metapod&quot;,&quot;Butterfree&quot;,&quot;Weedle&quot;,&quot;Kakuna&quot;,&quot;Beedrill&quot;,&quot;Pidgey&quot;,&quot;Pidgeotto&quot;,&#xA;&quot;Pidgeot&quot;,&quot;Rattata&quot;,&quot;Raticate&quot;,&quot;Spearow&quot;,&quot;Fearow&quot;,&quot;Ekans&quot;,&quot;Arbok&quot;,&quot;Pikachu&quot;,&quot;Raichu&quot;,&quot;Sandshrew&quot;,&quot;Sandslash&quot;,&#xA;&quot;Nidoran♀&quot;,&quot;Nidorina&quot;,&quot;Nidoqueen&quot;,&quot;Nidoran♂&quot;,&quot;Nidorino&quot;,&quot;Nidoking&quot;,&quot;Clefairy&quot;,&quot;Clefable&quot;,&quot;Vulpix&quot;,&quot;Ninetales&quot;,&quot;Jigglypuff&quot;,&#xA;&quot;Wigglytuff&quot;,&quot;Zubat&quot;,&quot;Golbat&quot;,&quot;Oddish&quot;,&quot;Gloom&quot;,&quot;Vileplume&quot;,&quot;Paras&quot;,&quot;Parasect&quot;,&quot;Venonat&quot;,&quot;Venomoth&quot;,&quot;Diglett&quot;,&quot;Dugtrio&quot;,&quot;Meowth&quot;,&#xA;&quot;Persian&quot;,&quot;Psyduck&quot;,&quot;Golduck&quot;,&quot;Mankey&quot;,&quot;Primeape&quot;,&quot;Growlithe&quot;,&quot;Arcanine&quot;,&quot;Poliwag&quot;,&quot;Poliwhirl&quot;,&quot;Poliwrath&quot;,&quot;Abra&quot;,&quot;Kadabra&quot;,&quot;Alakazam&quot;,&#xA;&quot;Machop&quot;,&quot;Machoke&quot;,&quot;Machamp&quot;,&quot;Bellsprout&quot;,&quot;Weepinbell&quot;,&quot;Victreebel&quot;,&quot;Tentacool&quot;,&quot;Tentacruel&quot;,&quot;Geodude&quot;,&quot;Graveler&quot;,&quot;Golem&quot;,&quot;Ponyta&quot;,&quot;Rapidash&quot;,&#xA;&quot;Slowpoke&quot;,&quot;Slowbro&quot;,&quot;Magnemite&quot;,&quot;Magneton&quot;,&quot;Farfetch`d&quot;,&quot;Doduo&quot;,&quot;Dodrio&quot;,&quot;Seel&quot;,&quot;Dewgong&quot;,&quot;Grimer&quot;,&quot;Muk&quot;,&quot;Shellder&quot;,&quot;Cloyster&quot;,&quot;Gastly&quot;,&quot;Haunter&quot;,&#xA;&quot;Gengar&quot;,&quot;Onix&quot;,&quot;Drowzee&quot;,&quot;Hypno&quot;,&quot;Krabby&quot;,&quot;Kingler&quot;,&quot;Voltorb&quot;,&quot;Electrode&quot;,&quot;Exeggcute&quot;,&quot;Exeggutor&quot;,&quot;Cubone&quot;,&quot;Marowak&quot;,&quot;Hitmonlee&quot;,&quot;Hitmonchan&quot;,&quot;Lickitung&quot;,&#xA;&quot;Koffing&quot;,&quot;Weezing&quot;,&quot;Rhyhorn&quot;,&quot;Rhydon&quot;,&quot;Chansey&quot;,&quot;Tangela&quot;,&quot;Kangaskhan&quot;,&quot;Horsea&quot;,&quot;Seadra&quot;,&quot;Goldeen&quot;,&quot;Seaking&quot;,&quot;Staryu&quot;,&quot;Starmie&quot;,&quot;Mr. Mime&quot;,&quot;Scyther&quot;,&quot;Jynx&quot;,&#xA;&quot;Electabuzz&quot;,&quot;Magmar&quot;,&quot;Pinsir&quot;,&quot;Tauros&quot;,&quot;Magikarp&quot;,&quot;Gyarados&quot;,&quot;Lapras&quot;,&quot;Ditto&quot;,&quot;Eevee&quot;,&quot;Vaporeon&quot;,&quot;Jolteon&quot;,&quot;Flareon&quot;,&quot;Porygon&quot;,&quot;Omanyte&quot;,&quot;Omastar&quot;,&quot;Kabuto&quot;,&quot;Kabutops&quot;,&#xA;&quot;Aerodactyl&quot;,&quot;Snorlax&quot;,&quot;Articuno&quot;,&quot;Zapdos&quot;,&quot;Moltres&quot;,&quot;Dratini&quot;,&quot;Dragonair&quot;,&quot;Dragonite&quot;,&quot;Mewtwo&quot;,&quot;Mew&quot;,&#xA;};&#xA;int a = 0;&#xA;int b = 0;&#xA;int value;&#xA;String pokemonName;&#xA;int currentID = TrueRandom.random(1,numPokemon+1);&#xA;// a = CurrentID&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  if (EEPROM.read(a)!=0){&#xA;    currentID = EEPROM.read(a);&#xA;    Serial.print(&quot;The Stored ID is &quot;);&#xA;    Serial.println(EEPROM.read(a));&#xA;    Serial.println(&quot;Stored = true&quot;);&#xA;  }else{&#xA;    value = EEPROM.read(a);&#xA;    Serial.println(value);&#xA;    EEPROM.write(a,currentID);&#xA;    value = EEPROM.read(a);&#xA;    Serial.println(value);&#xA;    Serial.println(&quot;Stored = false&quot;);&#xA;  }&#xA;  for (int i = 0 ; i &amp;lt; 152 ; i++){&#xA;      if (currentID = i){&#xA;        pokemonName = nameArray[i];&#xA;        Serial.print(pokemonName);&#xA;        break;&#xA;      }&#xA;   }&#xA;  //nameChange(currentID);&#xA;  //Serial.println(pokemonName);&#xA;}&#xA;void loop(){&#xA;&#xA;}&#xA;void nameChange(int currentID){&#xA;   for (int i = 0 ; i &amp;lt; 152 ; i++){&#xA;      if (currentID = i){&#xA;        pokemonName = nameArray[i];&#xA;        break;&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the problem with this code?&lt;/p&gt;&#xA;" OwnerDisplayName="user641" LastEditorUserId="220" LastEditDate="2014-03-22T01:25:40.820" LastActivityDate="2014-03-22T01:25:40.820" Title="Arduino Not Responding During Program" Tags="|arduino-uno|programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="767" PostTypeId="2" ParentId="766" CreationDate="2014-03-16T16:59:39.360" Score="0" Body="&lt;p&gt;the string array is too big for ram, place it in flash with the fucntion F()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;This string will be stored in flash memory&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also a detailed example with array with explanation cn be found &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,145756.0.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-03-16T16:59:39.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="768" PostTypeId="2" ParentId="766" CreationDate="2014-03-16T17:00:01.457" Score="1" Body="&lt;p&gt;You have mixed up your comparison and assignment operators in two instances:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First is towards the end of &lt;code&gt;setup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for (int i = 0 ; i &amp;lt; 152 ; i++){&#xA;      //if (currentID = i){ //This is assignment, not comparison&#xA;      //This is a comparison operation&#xA;        if (currentID == i){&#xA;        pokemonName = nameArray[i];&#xA;        Serial.print(pokemonName);&#xA;        break;&#xA;      }&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, is in the function definition of &lt;code&gt;nameChange&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void nameChange(int currentID){&#xA;   for (int i = 0 ; i &amp;lt; 152 ; i++){&#xA;      //if (currentID = i){ //This is an assignment operation, not comparison.&#xA;      //This is a comparison operation&#xA;        if (currentID == i){&#xA;        pokemonName = nameArray[i];&#xA;        break;&#xA;      }&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you have defined a constant &lt;code&gt;numPokemon&lt;/code&gt; but are not using it at any point.&lt;/p&gt;&#xA;" OwnerUserId="65" LastEditorUserId="65" LastEditDate="2014-03-16T17:07:52.287" LastActivityDate="2014-03-16T17:07:52.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="769" PostTypeId="2" ParentId="766" CreationDate="2014-03-16T17:10:07.630" Score="2" Body="&lt;p&gt;The primary reason that this isn't working is that you are using more RAM than the ATmega328 has (2Kbytes). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array nameArray is huge. Each one of those characters is 1 byte, it's ~1.1k in itself. Add in Serial, TrueRandom and String, and you are over the limit. It could be you are right on the bounds and calling a single function pushes the stack over it's limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save size, you can place the strings in flash. There is functionality to do this in Arduino, namely &lt;a href=&quot;http://arduino.cc/en/Reference/PROGMEM#.UyXZldzGnHg&quot; rel=&quot;nofollow&quot;&gt;PROGMEM directive&lt;/a&gt; from underlying AVR-GCC and F() from Arduino. Making arrays of string is quite painful though, and using the &lt;a href=&quot;http://arduiniana.org/libraries/flash/&quot; rel=&quot;nofollow&quot;&gt;Flash library&lt;/a&gt; helps here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would avoid String for anything like this. The insides of String use dynamic memory allocation and when you are near the limits of RAM, it really isn't helpful. You lose a lot of ease of use by moving to arrays of char though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are also using assignment instead of comparison in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentID = i){&#xA;   pokemonName = nameArray[i];&#xA;   Serial.print(pokemonName);&#xA;   break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This needs to be &lt;code&gt;currentID == i&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not confident what you are doing here though. If you want to get the &lt;em&gt;i&lt;/em&gt; th element from the array, then just do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pokemonName = nameArray[currentID]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also have an odd conditional at the beginning where you check for an EEPROM value being non zero, and then the else reads out the EEPROM value which by definition must be zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you have a define for &lt;code&gt;numPokemon&lt;/code&gt; but you aren't using it for the bounds on your for loops.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-16T17:10:07.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="770" PostTypeId="2" ParentId="759" CreationDate="2014-03-16T17:23:31.177" Score="1" Body="&lt;p&gt;This would be possible with a standard SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Capacity&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using some simple calculations, I was able to find that writing at 2kB/s for 5 days would only consume 0.8GB. You could probably get by with a 1 or 2 GB card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Speed&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,109862.0.html&quot; rel=&quot;nofollow&quot;&gt;this benchmark&lt;/a&gt;, which says it is possible to write SD card data from an Arduino at 192 kB/s, which should be more than enough for your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a lot of great tutorials and examples out there for using an SD card with an Arduino. The &lt;a href=&quot;http://arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;official documentation&lt;/a&gt; is always a good place to start.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-16T17:23:31.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="771" PostTypeId="1" AcceptedAnswerId="772" CreationDate="2014-03-16T18:30:53.387" Score="0" ViewCount="140" Body="&lt;p&gt;I'm using a PROGMEM char* to store a massive array. When I try to print a certain part of the array, the message comes out mangled. How do I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output should be &quot;Poliwag&quot;, but it comes out as &quot;arow&quot;.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#define numPokemon 151&#xA;PROGMEM char* nameArray[] = {&quot;MISSINGNO&quot;,&quot;Bulbasaur&quot;,&quot;Ivysaur&quot;,&quot;Venusaur&quot;,&quot;Charmander&quot;,&quot;Charmeleon&quot;,&quot;Charizard&quot;,&quot;Squirtle&quot;,&#xA;&quot;Wartortle&quot;,&quot;Blastoise&quot;,&quot;Caterpie&quot;,&quot;Metapod&quot;,&quot;Butterfree&quot;,&quot;Weedle&quot;,&quot;Kakuna&quot;,&quot;Beedrill&quot;,&quot;Pidgey&quot;,&quot;Pidgeotto&quot;,&#xA;&quot;Pidgeot&quot;,&quot;Rattata&quot;,&quot;Raticate&quot;,&quot;Spearow&quot;,&quot;Fearow&quot;,&quot;Ekans&quot;,&quot;Arbok&quot;,&quot;Pikachu&quot;,&quot;Raichu&quot;,&quot;Sandshrew&quot;,&quot;Sandslash&quot;,&#xA;&quot;Nidoran♀&quot;,&quot;Nidorina&quot;,&quot;Nidoqueen&quot;,&quot;Nidoran♂&quot;,&quot;Nidorino&quot;,&quot;Nidoking&quot;,&quot;Clefairy&quot;,&quot;Clefable&quot;,&quot;Vulpix&quot;,&quot;Ninetales&quot;,&quot;Jigglypuff&quot;,&#xA;&quot;Wigglytuff&quot;,&quot;Zubat&quot;,&quot;Golbat&quot;,&quot;Oddish&quot;,&quot;Gloom&quot;,&quot;Vileplume&quot;,&quot;Paras&quot;,&quot;Parasect&quot;,&quot;Venonat&quot;,&quot;Venomoth&quot;,&quot;Diglett&quot;,&quot;Dugtrio&quot;,&quot;Meowth&quot;,&#xA;&quot;Persian&quot;,&quot;Psyduck&quot;,&quot;Golduck&quot;,&quot;Mankey&quot;,&quot;Primeape&quot;,&quot;Growlithe&quot;,&quot;Arcanine&quot;,&quot;Poliwag&quot;,&quot;Poliwhirl&quot;,&quot;Poliwrath&quot;,&quot;Abra&quot;,&quot;Kadabra&quot;,&quot;Alakazam&quot;,&#xA;&quot;Machop&quot;,&quot;Machoke&quot;,&quot;Machamp&quot;,&quot;Bellsprout&quot;,&quot;Weepinbell&quot;,&quot;Victreebel&quot;,&quot;Tentacool&quot;,&quot;Tentacruel&quot;,&quot;Geodude&quot;,&quot;Graveler&quot;,&quot;Golem&quot;,&quot;Ponyta&quot;,&quot;Rapidash&quot;,&#xA;&quot;Slowpoke&quot;,&quot;Slowbro&quot;,&quot;Magnemite&quot;,&quot;Magneton&quot;,&quot;Farfetch`d&quot;,&quot;Doduo&quot;,&quot;Dodrio&quot;,&quot;Seel&quot;,&quot;Dewgong&quot;,&quot;Grimer&quot;,&quot;Muk&quot;,&quot;Shellder&quot;,&quot;Cloyster&quot;,&quot;Gastly&quot;,&quot;Haunter&quot;,&#xA;&quot;Gengar&quot;,&quot;Onix&quot;,&quot;Drowzee&quot;,&quot;Hypno&quot;,&quot;Krabby&quot;,&quot;Kingler&quot;,&quot;Voltorb&quot;,&quot;Electrode&quot;,&quot;Exeggcute&quot;,&quot;Exeggutor&quot;,&quot;Cubone&quot;,&quot;Marowak&quot;,&quot;Hitmonlee&quot;,&quot;Hitmonchan&quot;,&quot;Lickitung&quot;,&#xA;&quot;Koffing&quot;,&quot;Weezing&quot;,&quot;Rhyhorn&quot;,&quot;Rhydon&quot;,&quot;Chansey&quot;,&quot;Tangela&quot;,&quot;Kangaskhan&quot;,&quot;Horsea&quot;,&quot;Seadra&quot;,&quot;Goldeen&quot;,&quot;Seaking&quot;,&quot;Staryu&quot;,&quot;Starmie&quot;,&quot;Mr. Mime&quot;,&quot;Scyther&quot;,&quot;Jynx&quot;,&#xA;&quot;Electabuzz&quot;,&quot;Magmar&quot;,&quot;Pinsir&quot;,&quot;Tauros&quot;,&quot;Magikarp&quot;,&quot;Gyarados&quot;,&quot;Lapras&quot;,&quot;Ditto&quot;,&quot;Eevee&quot;,&quot;Vaporeon&quot;,&quot;Jolteon&quot;,&quot;Flareon&quot;,&quot;Porygon&quot;,&quot;Omanyte&quot;,&quot;Omastar&quot;,&quot;Kabuto&quot;,&quot;Kabutops&quot;,&#xA;&quot;Aerodactyl&quot;,&quot;Snorlax&quot;,&quot;Articuno&quot;,&quot;Zapdos&quot;,&quot;Moltres&quot;,&quot;Dratini&quot;,&quot;Dragonair&quot;,&quot;Dragonite&quot;,&quot;Mewtwo&quot;,&quot;Mew&quot;&#xA;};&#xA;int a = 0;&#xA;int b = 0;&#xA;int value;&#xA;String pokemonName = &quot;Missingno&quot;;&#xA;int currentID = TrueRandom.random(1,numPokemon+1);&#xA;// a = CurrentID&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  if (EEPROM.read(a)!=0){&#xA;    currentID = EEPROM.read(a);&#xA;    Serial.print(&quot;The Stored ID is &quot;);&#xA;    Serial.println(EEPROM.read(a));&#xA;    Serial.println(&quot;Stored = true&quot;);&#xA;  }else{&#xA;    value = EEPROM.read(a);&#xA;    Serial.println(value);&#xA;    EEPROM.write(a,currentID);&#xA;    value = EEPROM.read(a);&#xA;    Serial.println(value);&#xA;    Serial.println(&quot;Stored = false&quot;);&#xA;  }&#xA;  pokemonName = nameArray[currentID];&#xA;  Serial.println(pokemonName);&#xA;}&#xA;void loop(){&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="642" LastEditorUserId="84" LastEditDate="2014-04-20T09:45:32.687" LastActivityDate="2014-04-20T09:45:32.687" Title="Unrecognizable Message From PROGMEM char*" Tags="|arduino-uno|progmem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="772" PostTypeId="2" ParentId="771" CreationDate="2014-03-16T18:36:13.757" Score="5" Body="&lt;p&gt;The way you've written in, the &lt;em&gt;pointer&lt;/em&gt; is stored in flash, but the strings are stored in &lt;em&gt;SRAM&lt;/em&gt;. Read &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/pgmspace.html&quot;&gt;the appropriate documentation&lt;/a&gt; (also found in the &lt;a href=&quot;http://arduino.cc/en/Reference/PROGMEM&quot;&gt;Arduino reference&lt;/a&gt;) more closely, and do as it says.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char nmPokemon0[] PROGMEM = &quot;MISSINGNO&quot;;&#xA;char nmPokemon1[] PROGMEM = &quot;Bulbasaur&quot;;&#xA; ...&#xA;&#xA;PGM_P nameArray[] PROGMEM =&#xA;{&#xA;  nmPokemon0, nmPokemon1, ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And don't forget to copy the string to SRAM as shown further down before outputting it, since &lt;code&gt;Serial.println()&lt;/code&gt; can't work directly with flash.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-03-16T18:44:57.103" LastActivityDate="2014-03-16T18:44:57.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="773" PostTypeId="2" ParentId="759" CreationDate="2014-03-16T20:03:56.367" Score="4" Body="&lt;p&gt;There are two constraints here, and I think it might back you into a corner. Size and then power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2Kbyte/s is 2*60*60*24/1024 = 168.75Mbyte/day. This is a lot. The only readily available technology that can be used with a small microprocessor that can store this volume of data is an SD card. There are no serial EEPROM or flash chips this large, and the Arduino, as far as I know, can't deal with the NAND flash used in USB sticks and SD cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, SD cards can be relatively power hungry. They draw between 5mA and 100mA when writing, typically around 30-50mA. The SD spec says the maximum is 200mA. Writing is also quite lengthy as they operate on blocks of data rather than individual cells. I've never done a full analysis of how much power they use, but it is not insignificant and much, much more than serial EEPROM or flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your only choice, if you have to store that much, is to go with SD cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would investigate compressing the data. Even very basic schemes can make a huge difference.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-16T20:03:56.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="774" PostTypeId="2" ParentId="763" CreationDate="2014-03-16T20:31:20.670" Score="7" Body="&lt;p&gt;When you figure out how to locate the generated .elf file in your temporary directory, you can execute the command below to dump a SRAM usage, where &lt;code&gt;project.elf&lt;/code&gt; is to be replaced with the generated &lt;code&gt;.elf&lt;/code&gt; file. The advantage of this output is the ability to inspect &lt;em&gt;how&lt;/em&gt; your SRAM is used. Do all the variables need to be global, are they really all required?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -S -j .bss project.elf&#xA;&#xA;project.elf:     file format elf32-avr&#xA;&#xA;&#xA;Disassembly of section .bss:&#xA;&#xA;00800060 &amp;lt;__bss_start&amp;gt;:&#xA;        ...&#xA;&#xA;00800070 &amp;lt;measurementReady&amp;gt;:&#xA;        ...&#xA;&#xA;00800071 &amp;lt;cycles&amp;gt;:&#xA;        ...&#xA;&#xA;00800073 &amp;lt;measurement&amp;gt;:&#xA;  800073:       00 00 00 00                                         ....&#xA;&#xA;00800077 &amp;lt;measurementStart&amp;gt;:&#xA;  800077:       00 00 00 00                                         ....&#xA;&#xA;0080007b &amp;lt;timerOverflows&amp;gt;:&#xA;  80007b:       00 00 00 00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that this doesn't show stack or dynamic memory use as Ignacio Vazquez-Abrams noted in the comments below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally a &lt;code&gt;avr-objdump -S -j .data project.elf&lt;/code&gt; can be checked, but none of my programs output anything with that so I can't tell for sure if it is useful. It &lt;a href=&quot;http://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/&quot;&gt;supposed to list&lt;/a&gt; 'initialized (non-zero) data'.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-17T06:57:04.527" LastActivityDate="2014-03-17T06:57:04.527" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="775" PostTypeId="1" AcceptedAnswerId="776" CreationDate="2014-03-16T22:30:21.940" Score="2" ViewCount="206" Body="&lt;p&gt;I wrote a program using PROGMEM for massive string arrays. One of the arrays worked, but when I added the second one, the serial output only puts out &quot;th&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pastebin Code: &lt;a href=&quot;http://pastebin.com/9U7QZQKn&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/9U7QZQKn&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="642" LastActivityDate="2014-03-17T06:26:37.890" Title="PROGMEM char* mangled text" Tags="|arduino-uno|progmem|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="776" PostTypeId="2" ParentId="775" CreationDate="2014-03-16T22:56:22.960" Score="4" Body="&lt;p&gt;Your declaration of char buffers is done like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* move1 = &quot;N/A&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will only allocate 3 characters with an additional one for null termination i.e. not long enough to hold the name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[16];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the length is long enough to hold your string.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-17T06:26:37.890" LastActivityDate="2014-03-17T06:26:37.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="777" PostTypeId="2" ParentId="763" CreationDate="2014-03-16T23:29:39.897" Score="15" Body="&lt;p&gt;You can use the functions provided &lt;a href=&quot;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=52249&quot;&gt;AVRGCC: Monitoring Stack Usage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function was intended to check the stack usage but what it reports is the actual RAM that has never been used (during execution). It does so by &quot;painting&quot; (filling) the RAM with a known value (0xC5), and then checking the RAM area counting how many bytes have still the same initial value.&lt;br&gt;&#xA;The report will show the RAM that has not been used (minimum free RAM) and therefor you can calculate the max RAM that has been used (Total RAM - reported RAM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two functions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;StackPaint&lt;/strong&gt; is executed automatically during initialization and &quot;paints&quot; the RAM with the value 0xC5 (can be changed if needed).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;StackCount&lt;/strong&gt; can be called at any point to count the RAM that hasn't been used.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is an example of usage. Doesn't do much but is intended to show how to use the functions.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// -----------------------------------------------------------------------------&#xA;extern uint8_t _end;&#xA;extern uint8_t __stack;&#xA;&#xA;void StackPaint(void) __attribute__ ((naked)) __attribute__ ((section (&quot;.init1&quot;)));&#xA;&#xA;void StackPaint(void)&#xA;{&#xA;#if 0&#xA;    uint8_t *p = &amp;amp;_end;&#xA;&#xA;    while(p &amp;lt;= &amp;amp;__stack)&#xA;    {&#xA;        *p = 0xc5;&#xA;        p++;&#xA;    }&#xA;#else&#xA;    __asm volatile (&quot;    ldi r30,lo8(_end)\n&quot;&#xA;                    &quot;    ldi r31,hi8(_end)\n&quot;&#xA;                    &quot;    ldi r24,lo8(0xc5)\n&quot; /* STACK_CANARY = 0xc5 */&#xA;                    &quot;    ldi r25,hi8(__stack)\n&quot;&#xA;                    &quot;    rjmp .cmp\n&quot;&#xA;                    &quot;.loop:\n&quot;&#xA;                    &quot;    st Z+,r24\n&quot;&#xA;                    &quot;.cmp:\n&quot;&#xA;                    &quot;    cpi r30,lo8(__stack)\n&quot;&#xA;                    &quot;    cpc r31,r25\n&quot;&#xA;                    &quot;    brlo .loop\n&quot;&#xA;                    &quot;    breq .loop&quot;::);&#xA;#endif&#xA;} &#xA;&#xA;&#xA;uint16_t StackCount(void)&#xA;{&#xA;    const uint8_t *p = &amp;amp;_end;&#xA;    uint16_t       c = 0;&#xA;&#xA;    while(*p == 0xc5 &amp;amp;&amp;amp; p &amp;lt;= &amp;amp;__stack)&#xA;    {&#xA;        p++;&#xA;        c++;&#xA;    }&#xA;&#xA;    return c;&#xA;} &#xA;&#xA;// -----------------------------------------------------------------------------&#xA;&#xA;void setup() {&#xA;&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;Serial.println(StackCount(), DEC);  // calls StackCount() to report the unused RAM&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="470" LastEditorUserId="470" LastEditDate="2014-03-17T00:22:43.143" LastActivityDate="2014-03-17T00:22:43.143" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="778" PostTypeId="2" ParentId="775" CreationDate="2014-03-17T05:40:33.517" Score="3" Body="&lt;p&gt;I see one major flaw in your code, related to index usage on arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arrays in C and C++ are using a &lt;strong&gt;0-based index&lt;/strong&gt;, meaning that, for an array containing &lt;code&gt;N&lt;/code&gt; elements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the first element is accessible with index &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the last element is accessible with index &lt;code&gt;(N-1)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, your code uses &lt;code&gt;TrueRandom.random(1,numPokemon+1);&lt;/code&gt; which means you'll get an index between &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;numPokemon&lt;/code&gt; (included), if you get the &lt;code&gt;numPokemon&lt;/code&gt; value for your index, then you'll get garbage as it will try access some other part of memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe that is not the only problem in your code, but this one is a major bug.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-17T05:40:33.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="779" PostTypeId="1" AcceptedAnswerId="780" CreationDate="2014-03-17T11:16:07.667" Score="8" ViewCount="809" Body="&lt;p&gt;I bought a Gertboard a while ago, and one of the features it has on-board is an ATMega328 (DIP). However, since the Gertboard is designed for use with the Raspberry Pi, it only operates at 3.3v, so the clock speed is limited to ~12MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming it via the Raspberry Pi is quite cumbersome though. Instead, I'd like to transfer the chip to an Arduino Uno board so I can upload sketches from my desktop PC. I would then transfer it back to the Gertboard for normal operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that my Uno operates at the more typical 5v / 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it safe to attempt this? Do I need to make any configuration changes in the IDE to tell it to account for a different clock speed?&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-17T11:27:13.300" Title="Can I program a 3.3v chip on a 5v board?" Tags="|arduino-uno|safety|uploading|atmega328|oscillator-clock|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="780" PostTypeId="2" ParentId="779" CreationDate="2014-03-17T11:27:13.300" Score="10" Body="&lt;p&gt;The clock speed selected will affect both &lt;code&gt;delay*()&lt;/code&gt; and &lt;code&gt;millis()&lt;/code&gt;/&lt;code&gt;micros()&lt;/code&gt; as well as the functions in &lt;code&gt;&amp;lt;util/delay.h&amp;gt;&lt;/code&gt;, therefore you &lt;em&gt;must&lt;/em&gt; use the target system's correct clock speed if you are using any of these functions. This can be easily done by editing &lt;code&gt;boards.txt&lt;/code&gt; and copying an existing entry for the Uno and changing the value of the &lt;code&gt;f_cpu&lt;/code&gt; parameter to match the target system (in this case, &lt;code&gt;12000000&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference in voltage does not matter, since the chip can run at either voltage and no connection is being made between the 5V system and the 3.3V system.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-17T11:27:13.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="781" PostTypeId="1" CreationDate="2014-03-17T17:55:17.447" Score="27" ViewCount="10206" Body="&lt;p&gt;Why is the Arduino able to accept ~5V from the USB, but requires a min of 7V when using an external power supply?&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2014-10-04T20:36:14.403" Title="Arduino USB Power vs External Power Supply" Tags="|arduino-uno|power|safety|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="782" PostTypeId="1" CreationDate="2014-03-17T13:04:08.333" Score="6" ViewCount="1545" Body="&lt;p&gt;I have an Arduino Mega 2560 with a &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoXbeeShield#.UybqgHVSm4I&quot; rel=&quot;nofollow noreferrer&quot;&gt;libelium XBee Shield&lt;/a&gt;. If I have an XBee S2 mounted on it and set the two jumpers to the USB setting or remove them, I am able to flash a program onto my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I'm mounting one of my XBee PRO S2B (I have three of them available and all behave the same) on the Arduino, no matter how I set the jumpers, it is not possible to flash anything on it. I always see &lt;code&gt;avrdude: stk500v2_getsync(): timeout communicating with programmer&lt;/code&gt; in the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the XBee PRO S2B incompatible with the Arduino or what might be the issue? I also tried to add an external power source additionally to the USB, but it didn't help either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some more experimenting, I found out new details. I tried to disconnect each pin of the shield individually. While doing it, I discovered that disconnecting the &lt;code&gt;reset&lt;/code&gt; pin from the arduino makes it possible to flash it - take a look at the &lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/XbeeShieldSchematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;XBee shield schematic&lt;/a&gt;, it's pin 5 from the ICSP connector; Photo: &lt;img src=&quot;https://i.stack.imgur.com/wgXvG.jpg&quot; alt=&quot;photo of it&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a multimeter and discovered that the XBee PRO S2B CTS / DIO7 port is high, while the one from the XBee S2 is low, and so constantly resetting the arduino. I mounted the XBee PRO S2B onto the &lt;a href=&quot;https://www.sparkfun.com/products/8687&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun XBee Explorer USB&lt;/a&gt; and opened a serial port with PuTTY.&#xA;In contrast to the S2, the PRO S2B provides a menu with several options:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;B-Bypass Mode&#xA;F-Update App&#xA;T-Timeout&#xA;V-BL Version&#xA;A-App Version&#xA;R-Reset&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ju3TV.jpg&quot; alt=&quot;Sparkfun XBee Explorer USB, CTS port&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I type B, the CTS port goes low, and would prevent the arduino from resetting. Also this mode is needed to detect the module via XCTU. However, with an unmodified arduino, I wouldn't have a chance to send this letter, since the XBee is constantly resetting it. What is this menu, can it be disabled somehow?&lt;/p&gt;&#xA;" OwnerUserId="665" OwnerDisplayName="swege" LastEditorUserId="665" LastEditDate="2014-03-20T11:56:44.990" LastActivityDate="2014-03-20T11:56:44.990" Title="Arduino Mega not flashable with XBee PRO S2B" Tags="|programming|serial|xbee|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="783" PostTypeId="2" ParentId="781" CreationDate="2014-03-17T18:09:00.250" Score="33" Body="&lt;p&gt;The design assumes USB provides a regulated 5v so no further regulation is necessary. The power connecter is meant to accept a wider range of voltage and regulate it to 5v, and the kind of regulators used on the Arduino board need that much higher voltage to provide regulation. If you already have a regulated +5v source you can supply it to the 5v pin. You'll bypass the on-board regulator this way, so just know that it will then be up to you to provide clean power.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-03-17T21:35:50.473" LastActivityDate="2014-03-17T21:35:50.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="784" PostTypeId="1" AcceptedAnswerId="786" CreationDate="2014-03-17T18:45:41.993" Score="1" ViewCount="8455" Body="&lt;p&gt;I am getting the error &quot;error: expected unqualified-id before 'do'&quot; multiple times for every do{&#xA;}while(); loop I have... Any help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pastebin:&lt;a href=&quot;http://pastebin.com/DubuAEUs&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/DubuAEUs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="642" LastEditorUserId="65" LastEditDate="2014-03-18T15:44:24.163" LastActivityDate="2014-03-18T15:44:24.163" Title="Expected Unqualified-ID Before 'do'(and 'while')" Tags="|programming|" AnswerCount="1" CommentCount="6" ClosedDate="2014-03-18T16:13:41.433" ContentLicense="CC BY-SA 3.0" />
  <row Id="786" PostTypeId="2" ParentId="784" CreationDate="2014-03-17T20:15:13.410" Score="3" Body="&lt;p&gt;The do whiles are outside of the setup() or loop(), so they won't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest doing a simple C/C++ tutorial like &lt;a href=&quot;http://www.learn-c.org&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; to get up to speed with how things work.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-17T20:15:13.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="787" PostTypeId="2" ParentId="763" CreationDate="2014-03-17T20:38:38.843" Score="10" Body="&lt;p&gt;The main issues you can have with memory usage at runtime are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no available memory in the &lt;strong&gt;heap&lt;/strong&gt; for dynamic allocations (&lt;code&gt;malloc&lt;/code&gt; or &lt;code&gt;new&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;no room left on the &lt;strong&gt;stack&lt;/strong&gt; when calling a function&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both are actually the same as the AVR &lt;strong&gt;SRAM&lt;/strong&gt; (2K on Arduino) is used for both (in addition to &lt;strong&gt;static data&lt;/strong&gt; which size never changes during program execution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, dynamic memory allocation is seldom used on MCUs, only a few libraries typically use it (one of them is &lt;code&gt;String&lt;/code&gt; class, which you mentioned you don't use, and that's a good point).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The stack and the heap can be seen in the picture below (courtesy of &lt;a href=&quot;http://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory&quot; rel=&quot;noreferrer&quot;&gt;Adafruit&lt;/a&gt;):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/waoHN.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, the most expected issue comes from stack overflow (i.e. when the stack grows towards the heap and overflows on it, and then -if the heap was not used at all- overflows on the static data zone of the SRAM. At that time, you have a high risk of either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;data corruption (i.e. the stack ovewrites heap or static data), giving you ununderstandable behavior&lt;/li&gt;&#xA;&lt;li&gt;stack corruption (i.e. the heap or static data overwrites stack content), generally leading to a crash&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In order to know the amount of memory that's left between the top of the heap and the top of the stack (actually, we might call it the bottom if we represent both the heap and the stack on the same image as depicted below), you can use the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freeRam () {&#xA;  extern int __heap_start, *__brkval; &#xA;  int v; &#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the code above, &lt;code&gt;__brkval&lt;/code&gt; points to the top of the heap but is &lt;code&gt;0&lt;/code&gt; when the heap has not been used, in which case we use &lt;code&gt;&amp;amp;__heap_start&lt;/code&gt; which points to &lt;code&gt;__heap_start&lt;/code&gt;, the first variable that marks the bottom of the heap; &lt;code&gt;&amp;amp;v&lt;/code&gt; points of course to the top of the stack (this is the last variable pushed on the stack), hence the formula above returns the amount of memory available for the stack (or the heap if you use it) to grow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this function in various locations of your code to try and find out where this size is getting dramatically reduced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if ever you see this function return a negative number then it is too late: you have already overflown the stack!&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-17T21:12:59.113" LastActivityDate="2014-03-17T21:12:59.113" CommentCount="7" CommunityOwnedDate="2014-03-17T20:38:38.843" ContentLicense="CC BY-SA 3.0" />
  <row Id="789" PostTypeId="1" AcceptedAnswerId="792" CreationDate="2014-03-18T00:21:02.903" Score="13" ViewCount="29201" Body="&lt;p&gt;I am working on a heating control system for my home, but having problems with the temperature sensor reading higher than I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a 5V Arduino Mini Pro clone hooked up to a relay module, an HD47780 display and a Tiny RTC module, with a DS18B20 attached to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DS18B20 is powered from the 5v Vcc applied to the Tiny RTC module rather than using parasitic power on the DQ line (as I wasn't sure if the Onewire libraries supported this mode of operation) and the &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf&quot; rel=&quot;noreferrer&quot;&gt;DS18B20 datasheet&lt;/a&gt; says that Vcc may be between 3.0v and 5.5v. I measured the regulated power from the Mini Pro's  being at 5.2v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am comparing the temperature from the DS with the existing room thermostat (bi-metallic), an RS desktop temperature monitor with two sensors, a small &lt;a href=&quot;http://i01.i.aliimg.com/photo/v4/376190273/In_out_Thermo_Hygrometer_HC520.jpg&quot; rel=&quot;noreferrer&quot;&gt;'thermo-hygrometer'&lt;/a&gt; and a &lt;a href=&quot;http://ecx.images-amazon.com/images/I/71sVnFU5AQL._SL1436_.jpg&quot; rel=&quot;noreferrer&quot;&gt;bi-metallic fridge thermometer&lt;/a&gt; (in the upper quarter of its temperature range)&lt;sup&gt;&amp;dagger;&lt;/sup&gt;. The readout from the DS is always around 1-2 degrees higher than the readout from the other sensors, which are within a degree of each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&amp;dagger; Not the actual one, but something similar.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading various forums I have heard that these sensors are quite accurate but can suffer from localised heating from components near them, so I moved the sensor onto a 20cm cable and positioned it well away from the rest of the electronics. This made no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then read that the DS can become self heating if it is supplied with too high a Vcc voltage, so I added a Red LED with 1.7v drop and measured the new voltage over the DS as 3.5v, but again, after waiting for the temperatures to stabilise once more, this made no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest why the DS may be reading high and what I can can do to prevent this?&lt;/p&gt;&#xA;" OwnerUserId="173" LastEditorUserId="4628" LastEditDate="2017-05-27T15:16:32.970" LastActivityDate="2019-09-30T19:09:32.223" Title="My DS18B20 is reading high. How can I get it to return the correct temperature?" Tags="|sensors|temperature-sensor|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="790" PostTypeId="1" AcceptedAnswerId="805" CreationDate="2014-03-18T00:38:24.110" Score="5" ViewCount="7857" Body="&lt;p&gt;I have arduino Pro Mini 3.3V version with hc-05 module connected to 3.3V/GND and RXI/TX0 pins. I am then using my android phone to connect to the module. It shows up and pairs fine. Then I use BlueTerm app to view the output. I am seeing output that is occasionally as expected but mostly partially corrupted (characters replaced with random characters). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using 9600 baud rate and trasmitting the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialTransmit(int data){&#xA;  // send to raspberry pi or other device(s).&#xA;  Serial.print(&quot;Serial Transmit: &quot;);&#xA;  Serial.println(data); // this is hard coded as &quot;12&quot; for testing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried switching rx/tx pins around but got same corrupt output. Tried changing baud rate but then it wouldn't transmit anything at all and default rate is 9600 so that was expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the cause?&lt;/p&gt;&#xA;" OwnerUserId="633" LastEditorUserId="220" LastEditDate="2014-03-18T22:27:46.933" LastActivityDate="2015-09-15T21:25:30.413" Title="Corrupted output from HC-05 Bluetooth module" Tags="|arduino-pro-mini|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="791" PostTypeId="1" CreationDate="2014-03-18T00:42:09.173" Score="6" ViewCount="18070" Body="&lt;p&gt;I'm trying to make an RF remote control using ATtiny85 running at 8MHz on internal oscillator, &lt;a href=&quot;http://www.wenshing.com.tw/Products/RF_Module/ASK_RF_Transmitter_Module/TWS-DS-3_433.92MHz_Miniaturization_Wireless_Transmitter_Module/&quot; rel=&quot;noreferrer&quot;&gt;this cheap RF 434MHz transmitter module&lt;/a&gt; (like the one below), and VirtualWire lib, &lt;strong&gt;but had no success so far&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LHs0b.gif&quot; alt=&quot;RF transmitter&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, before I go any further, &lt;strong&gt;is it possible to use VirtualWire with ATtiny85 running at 3.6V and 8MHz with its internal oscillator? If so, how?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a few scattered sources of information on the Net about it, but couldn't make much sense of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have build ATMega328 versions of the receiver and transmitter using VirtualWire without any major problems. Both modules talk to each other will very little data drop out. Now, when I tried to replace the ATMega328 transmitter with a smaller version using the ATtiny85, I'm having problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the symptoms: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The major one seem to be that when I add the VirtualWire include, &lt;strong&gt;my sketch seems to slow down a lot&lt;/strong&gt;. So I figure it's a timing issue. But I'm not sure what the problem is.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I put a scope on ATtiny85 pin 6 (PB1) but &lt;strong&gt;I don't see anything being transmitted&lt;/strong&gt;. I think I've messed up with the pin names. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can make the LED blink and also can read the buttons without problems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here are the schematics and the board design for the remote controller:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/skxbK.png&quot; alt=&quot;RC schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is currently powered by 2 AA NiMH batteries that are currently at 2.6V. I can make the ATtiny85 blink with that voltage. I plan to power the RC with a 3.6V CR2 lithum battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are more details of my development enviroment:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino IDE 1.05&lt;/li&gt;&#xA;&lt;li&gt;I'm using ATtiny cores &lt;a href=&quot;https://docs.google.com/file/d/0B4cPTBXMMjz9Q0NWN3Q1cWhuV0U/edit?pli=1&quot; rel=&quot;noreferrer&quot;&gt;from here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;I'm programming the ATtiny85 using an Arduino UNO R3 as ISP, without problems (it's working as I can make the ATtiny85 blink an LED).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;#define VCC_PIN  A1&#xA;#define BTN_PIN  A2&#xA;#define LED_PIN  A3&#xA;#define TXD_PIN  PB1&#xA;&#xA;#define BLINK_UP_TIME  25&#xA;&#xA;#define BUTTON_NONE  0&#xA;#define BUTTON_1     1&#xA;#define BUTTON_2     2&#xA;#define BUTTON_3     3&#xA;#define BUTTON_4     4&#xA;#define BUTTON_5     5&#xA;#define BUTTON_6     6&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(BTN_PIN, INPUT);&#xA;  pinMode(TXD_PIN, OUTPUT);     &#xA;  pinMode(VCC_PIN, OUTPUT);     &#xA;  pinMode(LED_PIN, OUTPUT);     &#xA;&#xA;  // leave RF transmitter off for now&#xA;  digitalWrite(VCC_PIN, LOW);&#xA;&#xA;  // Initialise the IO and ISR&#xA;  vw_set_tx_pin(TXD_PIN);&#xA;  vw_setup(2000);    // Bits per sec&#xA;&#xA;  // let the user know we are alive: heartbeat&#xA;  blink(3, 50);&#xA;  delay(1000);&#xA;}&#xA;&#xA;uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;&#xA;void loop()&#xA;{&#xA;  byte button = ReadButtons();&#xA;  if (button != BUTTON_NONE) {&#xA;    // transmit button pressed&#xA;    digitalWrite(LED_PIN, HIGH); // Flash a light to show transmitting&#xA;    digitalWrite(VCC_PIN, HIGH); // turn tranmitter on&#xA;    delay(10);&#xA;    buf[0] = button;&#xA;    vw_send(buf, 1);&#xA;    vw_wait_tx(); // Wait until the whole message is gone&#xA;    digitalWrite(LED_PIN, LOW); // turn off LED&#xA;    digitalWrite(VCC_PIN, LOW); // turn tranmitter off&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&#xA;byte ReadButtons()&#xA;{&#xA;  unsigned int buttonVoltage = analogRead(BTN_PIN);&#xA;  byte button = BUTTON_NONE;   // return no button pressed if the below checks don't write to btn&#xA;  if      (buttonVoltage &amp;lt; 10)   {    button = BUTTON_1; } &#xA;  else if (buttonVoltage &amp;lt; 200)  {    button = BUTTON_2; } &#xA;  else if (buttonVoltage &amp;lt; 400)  {    button = BUTTON_3; } &#xA;  else if (buttonVoltage &amp;lt; 550)  {    button = BUTTON_4; } &#xA;  else if (buttonVoltage &amp;lt; 720)  {    button = BUTTON_5; } &#xA;  else if (buttonVoltage &amp;lt; 900)  {    button = BUTTON_6; }&#xA;  else if (buttonVoltage &amp;gt; 1000) {    button = BUTTON_NONE; }&#xA;  return( button );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, &lt;strong&gt;What's wrong with my setup?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2020-07-03T09:35:21.617" Title="RF remote control using VirtualWire on ATtiny85 running at 8MHz on internal oscillator" Tags="|remote-control|attiny|virtualwire|rf|" AnswerCount="4" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="792" PostTypeId="2" ParentId="789" CreationDate="2014-03-18T08:48:53.803" Score="12" Body="&lt;p&gt;I've put a lot of DS18B20 sensors in place now on various sensor nodes - maybe 50 or so. I've learnt a bit about the readings returned from them. I know you have isolated some of these as not being the cause, but it is good to confirm that they are issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if you are using Celsius or Fahrenheit, so the degree of the problem isn't clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Localised heating&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think of Arduino as a &quot;hot&quot; chip, but putting a DS18B20 in an enclosure with an Arduino and LCD caused me to see readings 2-3°C higher than expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving it outside the enclosure fixed this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Heating from high Vcc/frequent conversions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you supply the chip with a high Vcc and perform frequent conversions (i.e. as frequently as you can), the chip does warm up. I have seen this increase readings by 1-2°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't seen the problem with high Vcc alone, but I operate most DS18B20 in parasitic mode and convert at most once every 10s. The ones operated in active mode generally have the powered turned off when not being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OneWire and DallasTemperature do support parasitic mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not all temperature sensors are created equal&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a number of temperature sensors before I started playing around with DS18B20. Almost without exception, these under-read. Most of them are based on thermistors and calibration is poor. I thought the DS18B20 were over reading, but when I used a good thermocouple and meter, I could validate that they were correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was about learning to trust the DS18B20.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Heat conducted along wire&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the sensors on a wire, the wire conducts a surprising amount of heat. This can be an issue when running wiring along pipes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Fake DS18B20&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These sensors are very popular, and this seems to have caused fakes to appear. I have a batch of stainless steel waterproof sensors that over-read and the timings were out. They worked with the OneWire library, but not a DS2482 OneWire master. I have heard of the normal TO-92 cased ones being fake as well.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-18T08:48:53.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="793" PostTypeId="2" ParentId="781" CreationDate="2014-03-18T11:20:44.303" Score="4" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DIp8P.jpg&quot; alt=&quot;AA Battery&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Above is an AA Battery voltage curve. Many people assume that 5* 1.5V AA batterys would be enough to power the Arduino. As you can see the 1.5 is the maximum voltage and it quickly drops. Different brands have different values and sometimes this can drop below the value of the voltage regulator input. I usually tend to aim between 7 and 9 Volts for  running from batteries, ie the nominal voltage of the batteries, eg 6 x 1.5V = 9V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For wall socket charges, Buy a cheap one and hook it up to a volt meter, Many that say 5V actually have a range of values. Raspberry Pi users often have problems with power caused by manufacturers saying its 5v and it actually delivering something like 4.85 and fluctuating beacuse of the power demand of the pi &lt;/p&gt;&#xA;" OwnerUserId="685" LastEditorUserId="3267" LastEditDate="2014-10-04T20:36:14.403" LastActivityDate="2014-10-04T20:36:14.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="795" PostTypeId="1" AcceptedAnswerId="798" CreationDate="2014-03-18T16:09:01.827" Score="5" ViewCount="18353" Body="&lt;p&gt;I'm completely new with Arduino and microcontrollers in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several 5V sensors, and need 3.3V because that's the max for the Due. Is it possible to use a resistor to connect it to the Arduino? Do I have to measure the current from the sensor and calculate the needed resistor like this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$$\frac{5.0 - 3.3}{\text{Measured current}}$$&#xA;(5.0 - 3.3)/(Measured current)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="693" LastActivityDate="2014-03-18T18:19:29.483" Title="How to connect 5V sensors to 3.3V digital input (Due)?" Tags="|sensors|arduino-due|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="796" PostTypeId="1" AcceptedAnswerId="797" CreationDate="2014-03-17T13:43:20.593" Score="3" ViewCount="702" Body="&lt;p&gt;When communicating over SPI, one byte is sent at a time. Is there a library (C or C++) that allows for sending strings? Essentially it would be a protocol library handling the start and the end of a message, as well as integrity checking. (I'm using an Arduino.)&lt;/p&gt;&#xA;" OwnerUserId="693" OwnerDisplayName="Friend of Kim" LastEditorUserId="220" LastEditDate="2014-03-18T16:27:53.283" LastActivityDate="2014-03-18T16:27:53.283" Title="Is there a transmission protocol library for SPI?" Tags="|spi|uart|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="797" PostTypeId="2" ParentId="796" CreationDate="2014-03-17T20:50:14.800" Score="6" Body="&lt;p&gt;Each spi peripheral has its own protocol in the sense of commands and addresses if any and data.  Spi simply makes a common ground for chip select vs clocks and clocks vs data and separate miso and mosi data lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a general purpose library doesnt make sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also spi certainly is not limited to a byte, many peripherals and many spi controllers allow for long sequences of data, you are also not strictly limited to multiples of 8 bits either although that is the norm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your arduino spi master may have its limitations but that has nothing to do with spi in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Integrity testing is not part of the spi protocol, you get what you get.  Ideally all of the parts are soldered down on the same board or through known connectors and the margins have been designed in.  You would need to do something outside the spi protocol, for example if it is a spi flash then after you read a chunk of data you can do a checksum and compare it with a checksum you have embedded in the data (or crc).  If it is a spi ethernet part you may choose to leave the frame checksums in the frames and re-validate each frame yourself.  If you create your own peripheral (hardware design or cpld or fpga) then certainly you can add a crc or checksum to every transfer if you wish.&lt;/p&gt;&#xA;" OwnerUserId="875" OwnerDisplayName="dwelch" LastActivityDate="2014-03-17T20:50:14.800" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="798" PostTypeId="2" ParentId="795" CreationDate="2014-03-18T18:19:29.483" Score="2" Body="&lt;p&gt;Well if you're not sure of what you're doing, you can always go with &lt;strong&gt;level-converters&lt;/strong&gt; for your sensors (that does not apply to shields though)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Level-converters (sometimes called &lt;strong&gt;level-shifters&lt;/strong&gt;) come in different flavors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;breakout board (the easiest to work with)&lt;/li&gt;&#xA;&lt;li&gt;IC&lt;/li&gt;&#xA;&lt;li&gt;DIY circuits with a few components&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some are &quot;one-way&quot;: they have pin-pairs with converters 3.3V -&gt; 5V, and other pin-pairs with 5V -&gt; 3.3V conversion; others are bi-directional, i.e. you can use the same pair of pins in 2 directions 3.3V &amp;lt;-&gt; 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plenty of these converters, and they are rather cheap; here are just a few examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11978&quot; rel=&quot;nofollow&quot;&gt;one-way breakout&lt;/a&gt; usable with 4 pairs of pins&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow&quot;&gt;bi-directional breakout&lt;/a&gt; usable with 4 pairs of pins&lt;/li&gt;&#xA;&lt;li&gt;74HC4050 IC discussed &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=109493.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-18T18:19:29.483" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="799" PostTypeId="2" ParentId="757" CreationDate="2014-03-18T19:01:17.937" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there any alternatives to the Optiboot bootloader?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Err... not really. There's actually &lt;strong&gt;a [unofficial] &lt;a href=&quot;http://zygomorphic.com/arduino-tiny/?attachment_id=257&quot; rel=&quot;nofollow noreferrer&quot;&gt;modification to Optiboot to make it faster when uploading&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To install the high baud rate variations…&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Ensure the Arduino IDE is not running&lt;/li&gt;&#xA;  &lt;li&gt;Download the 7-Zip archive using the link above&lt;/li&gt;&#xA;  &lt;li&gt;Extract the three files to the following directory: &lt;code&gt;{Arduino Installation Root}\hardware\arduino\bootloaders\optiboot\&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;Open the boards.txt file located in the following directory: &lt;code&gt;{Arduino Installation Root}\hardware\arduino\&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Find This section inside it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.name=Arduino Uno&#xA;uno.upload.protocol=arduino&#xA;uno.upload.maximum_size=32256&#xA;uno.upload.speed=115200&#xA;uno.bootloader.low_fuses=0xff&#xA;uno.bootloader.high_fuses=0xde&#xA;uno.bootloader.extended_fuses=0x05&#xA;uno.bootloader.path=optiboot&#xA;uno.bootloader.file=optiboot_atmega328.hex&#xA;uno.bootloader.unlock_bits=0x3F&#xA;uno.bootloader.lock_bits=0x0F&#xA;uno.build.mcu=atmega328p&#xA;uno.build.f_cpu=16000000L&#xA;uno.build.core=arduino&#xA;uno.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;Add the following section…&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno_uf.name=Arduino Uno / Upload Fast&#xA;uno_uf.upload.protocol=arduino&#xA;uno_uf.upload.maximum_size=32256&#xA;uno_uf.upload.speed=250000&#xA;uno_uf.bootloader.low_fuses=0xff&#xA;uno_uf.bootloader.high_fuses=0xde&#xA;uno_uf.bootloader.extended_fuses=0x05&#xA;uno_uf.bootloader.path=optiboot&#xA;uno_uf.bootloader.file=optiboot_atmega328_250000.hex&#xA;uno_uf.bootloader.unlock_bits=0x3F&#xA;uno_uf.bootloader.lock_bits=0x0F&#xA;uno_uf.build.mcu=atmega328p&#xA;uno_uf.build.f_cpu=16000000L&#xA;uno_uf.build.core=arduino&#xA;uno_uf.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Change the two highlighted values to the baud rate you plan to use:    250000, 500000, or 1000000 Save and close the boards.txt file&lt;/li&gt;&#xA;  &lt;li&gt;Using your favourite ISP programmer, install the new bootloader. &lt;em&gt;Don’t forget to: Ensure the Arduino Uno / Upload Fast board is selected (Tools / Board)&lt;/em&gt;, &lt;em&gt;If appropriate, ensure the Serial Port of&#xA;  your programmer is selected (Tools / Serial Port)&lt;/em&gt;, &lt;em&gt;Ensure the&#xA;  programmer is selected (Tools / Programmer)&lt;/em&gt;, &lt;em&gt;After installing the&#xA;  bootloader, change the Serial Port to the serial port of your Arduino&#xA;  Uno&lt;/em&gt;.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Above text slightly modified for compatibility with site. &lt;em&gt;&lt;a href=&quot;http://zygomorphic.com/arduino-tiny/?page_id=249&quot; rel=&quot;nofollow noreferrer&quot;&gt;Original post&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Besides that, and the ATmegaboot bootloader, you can't really find any alternative. I would imagine that if Arduino loads it on all the Unos ever produced, it's pretty optimized. The above hack speeds up upload time, but it doesn't reduce the size of the bootloader. You can also &lt;a href=&quot;http://learn.adafruit.com/arduino-tips-tricks-and-techniques/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;remove the wait time on the bootloader&lt;/a&gt; so it has a faster startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're that concerned about maximising flash see: &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/193/how-to-really-shrink-a-sketch&quot;&gt;How to really shrink a sketch&lt;/a&gt;&lt;/em&gt; and &lt;a href=&quot;https://arduino.stackexchange.com/a/222/220&quot;&gt;this answer&lt;/a&gt; [on on &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/221/what-can-i-do-if-i-run-out-of-flash-memory-or-sram&quot;&gt;What can I do if I run out of Flash memory or SRAM?&lt;/a&gt;&lt;/em&gt;].&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-03-18T19:01:17.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="800" PostTypeId="5" CreationDate="2014-03-18T19:53:03.877" Score="0" Body="" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T19:53:03.877" LastActivityDate="2014-03-18T19:53:03.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="801" PostTypeId="4" CreationDate="2014-03-18T19:53:03.877" Score="0" Body="Voltage level should be used for questions that are referring to using hardware together that operates on different voltages (the &quot;concentration&quot; of electricity)." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T19:53:03.877" LastActivityDate="2014-03-18T19:53:03.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="802" PostTypeId="5" CreationDate="2014-03-18T19:57:44.630" Score="0" Body="&lt;h2&gt;Memory types on an Arduino&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;RAM is precious on a microcontroller, PROGMEM (program memory) not quite as much so. On the Arduino Uno (using an Atmega328P) you have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 KB of EEPROM&lt;/li&gt;&#xA;&lt;li&gt;2 KB of RAM&lt;/li&gt;&#xA;&lt;li&gt;32 KB of PROGMEM (Flash Memory - where your program goes)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Clearly, there is a lot more &lt;em&gt;program memory&lt;/em&gt; than RAM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Constants are normally copied from PROGMEM into RAM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Constants in your program are initially stored in PROGMEM (where else could they be stored when the power is off?) but &lt;em&gt;copied into RAM&lt;/em&gt; by compiler-generated initialization code at the very start of executing your sketch (program).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (&quot;Hello, world!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The constant string &quot;Hello, world!&quot; is initially in PROGMEM, but copied into RAM at startup. This means that room for it has to be allowed for in RAM &lt;em&gt;as well as&lt;/em&gt; in the Flash memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This uses up valuable RAM for what is really just a copy of something that will never change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int NUMBER_OF_ELEMENTS = 10;&#xA;const float table[NUMBER_OF_ELEMENTS] = &#xA;      { 1.0, 34.234, 324.234, 23.1, 52.0, 3.6, 5.6, 42.42, 1908, 23.456 } ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although this table of floating-point values won't change, it is also copied into RAM. If you have a large table, you will soon run out of RAM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;The PROGMEM attribute&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can prevent this copying into RAM by adding &lt;code&gt;PROGMEM&lt;/code&gt; to a data declaration, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int NUMBER_OF_ELEMENTS = 10;&#xA;const float table[NUMBER_OF_ELEMENTS] PROGMEM = &#xA;      { 1.0, 34.234, 324.234, 23.1, 52.0, 3.6, 5.6, 42.42, 1908, 23.456 } ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Accessing PROGMEM constants&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the compiler (on the AVR Arduinos anyway) expects all data to be in RAM and does not allow for accessing data directly from PROGMEM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make a small library &lt;code&gt;PROGMEM_readAnything.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;  // for type definitions&#xA;&#xA;template &amp;lt;typename T&amp;gt; void PROGMEM_readAnything (const T * sce, T&amp;amp; dest)&#xA;  {&#xA;  memcpy_P (&amp;amp;dest, sce, sizeof (T));&#xA;  }&#xA;&#xA;template &amp;lt;typename T&amp;gt; T PROGMEM_getAnything (const T * sce)&#xA;  {&#xA;  static T temp;&#xA;  memcpy_P (&amp;amp;temp, sce, sizeof (T));&#xA;  return temp;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Copy the above into a text file, save it as &lt;code&gt;PROGMEM_readAnything.h&lt;/code&gt;, and place that into a folder called &lt;code&gt;PROGMEM_readAnything&lt;/code&gt;, and put that folder inside your Arduino &lt;code&gt;libraries&lt;/code&gt; folder which itself is inside your sketchbook folder. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(sketchbook location)/libraries/PROGMEM_readAnything/PROGMEM_readAnything.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can access a PROGMEM constant like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float thisOne;&#xA;PROGMEM_readAnything (&amp;amp;table[3], thisOne);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float thisOne = PROGMEM_getAnything (&amp;amp;table[3]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;The F() macro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For simple string constants, you can use the &lt;code&gt;F()&lt;/code&gt; macro to easily keep strings in PROGMEM, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (F(&quot;Hello, world!&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:45.937" LastActivityDate="2015-08-30T23:57:45.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="803" PostTypeId="4" CreationDate="2014-03-18T19:57:44.630" Score="0" Body="PROGMEM is a keyword used when declaring a variable that keeps the data in flash instead of copying it into SRAM. It is part of the `pgmspace.h` library. Use this tag for discussions about using this attribute." OwnerUserId="220" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:37.700" LastActivityDate="2015-08-30T23:57:37.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="804" PostTypeId="1" AcceptedAnswerId="806" CreationDate="2014-03-18T21:01:57.920" Score="40" ViewCount="147752" Body="&lt;p&gt;I have a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00761NDHI&quot;&gt;Arduino Nano (Sainsmart)&lt;/a&gt; that I'm trying to upload a sketch to. Under the Arduino IDE, the device selected was &lt;code&gt;Arduino Nano w/ ATmega328&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However uploading the sketch gives me the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried both USB ports (&lt;code&gt;/dev/tty.usbserial&lt;/code&gt; &amp;amp; &lt;code&gt;/dev/cu.usbserial&lt;/code&gt;) but the same error persist. The Arduino is connected to a Macbook Air via the USB cable, and the &lt;code&gt;PWR&lt;/code&gt; LED indicator light on the Arduino is turned on and the &lt;code&gt;L&lt;/code&gt; indicator LED blinks. There was no problem uploading to a Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Retried after installing the latest FTDI drivers (MAC OSX, x64, v2.2.18, FTDIUSBSerialDriver_10_4_10_5_10_6_10_7.mpkg) from &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot;&gt;http://www.ftdichip.com/Drivers/VCP.htm&lt;/a&gt;. However that did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could have gone wrong?&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="639" LastEditDate="2014-03-18T21:33:24.327" LastActivityDate="2022-07-25T01:26:49.053" Title="Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding" Tags="|programming|serial|uploading|sketch|arduino-nano|" AnswerCount="12" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="805" PostTypeId="2" ParentId="790" CreationDate="2014-03-18T21:44:41.960" Score="2" Body="&lt;p&gt;First thing to try: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect a 2.2k - 10k resistor from the arduino RX pin (the hc-05 tx pin) to ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that didn't work, I recommend getting everything into a known state and eliminating some complexity. So, first let's remove the Android software from the equation.  And second, let's put the module into a known baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this wire up the arduino and module like this:&lt;img src=&quot;https://i.stack.imgur.com/4zcck.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the Key pin is connected to 3.3v.  That will ensure the module is at 38400 baud on power up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the arduino to your computer with the FTDI cable.  Upload the following sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Serial Loop */&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define rxPin 8&#xA;#define txPin 9&#xA;&#xA;SoftwareSerial mySerial(rxPin, txPin); // RX, TX&#xA;char myChar ;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);   &#xA;  Serial.println(&quot;AT&quot;);&#xA;&#xA;  mySerial.begin(38400);&#xA;  mySerial.println(&quot;AT&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (mySerial.available()) {&#xA;    myChar = mySerial.read();&#xA;    Serial.print(myChar);&#xA;  }&#xA;&#xA;  while (Serial.available()) {&#xA;    myChar = Serial.read();&#xA;    Serial.print(myChar); //echo&#xA;    mySerial.print(myChar);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the sketch now uploaded and running, open the Arduino serial console and enter these AT commands. The serial console baud rate should be set to 9600 and line endings should be &quot;Both NL &amp;amp; CR&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ORGL //back to factory settings&#xA;AT+ROLE=0 //slave role - transparent serial bridge&#xA;AT+UART=9600,0,0 //default baud rate&#xA;AT+INIT //init module&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should get &quot;OK&quot; back from the module after each command. If you've gotten this far, we know the module is working fine and we know what baud rate it will default to now.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hook the module back up the way you had it before.  Make sure 3.3v is disconnected from key pin and make sure you have added the pulldown resistor on the RX line. Cycle the power to the module. The module should start up running 9600 baud, slave mode. Delete the module from the Android pairing list and re-pair it.  The name probably will have changed.  Hopefully it works correctly now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-03-18T21:44:41.960" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="806" PostTypeId="2" ParentId="804" CreationDate="2014-03-18T22:05:09.317" Score="6" Body="&lt;p&gt;This error message basically shows up for any communication problem, so by itself, it is not all that instructive. The Arduino Nano is supposed to have auto-reset, but maybe your clone does not? In that case, you'd have to press the reset key on the board just before starting an upload.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-18T22:05:09.317" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="807" PostTypeId="5" CreationDate="2014-03-18T22:47:05.140" Score="0" Body="&lt;p&gt;The Arduino Nano is a small board based on the ATmega328 or 168. It has male headers, so it can be plugged directly into a breadboard. It is small and compact, and features a USB chip.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoNanoFront_3_lg.jpg&quot; &gt;&#xA;  The Arduino Nano is a small, complete, and breadboard-friendly board&#xA;  based on the ATmega328 (Arduino Nano 3.x) or ATmega168 (Arduino Nano&#xA;  2.x). It has more or less the same functionality of the Arduino Duemilanove, but in a different package. It lacks only a DC power&#xA;  jack, and works with a Mini-B USB cable instead of a standard one. The&#xA;  Nano was designed and is being produced by Gravitech.&lt;/p&gt;&#xA;  &#xA;  &lt;hr&gt;&#xA;  &#xA;  &lt;p&gt;Microcontroller   Atmel ATmega168 or ATmega328&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Operating Voltage (logic level)   5 V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (recommended)   7-12 V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Input Voltage (limits)    6-20 V&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Digital I/O Pins  14 (of which 6 provide PWM output)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Analog Input Pins 8&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;DC Current per I/O Pin    40 mA&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Flash Memory  16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used&#xA;  by bootloader&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SRAM  1 KB (ATmega168) or 2 KB (ATmega328)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;EEPROM    512 bytes (ATmega168) or 1 KB (ATmega328)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Clock Speed   16 MHz&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Dimensions    0.73&quot; x 1.70&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(From the &lt;a href=&quot;https://arduino.cc/en/Main/arduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Nano Page&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.237" LastActivityDate="2014-03-18T22:47:05.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="808" PostTypeId="4" CreationDate="2014-03-18T22:47:05.140" Score="0" Body="The Arduino Nano is a small board based on the ATmega328 or 168. It has male headers, so it can be plugged directly into a breadboard. It is small and compact, and features a USB chip." OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-18T22:47:05.140" LastActivityDate="2014-03-18T22:47:05.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="809" PostTypeId="2" ParentId="193" CreationDate="2014-03-18T23:43:09.380" Score="2" Body="&lt;p&gt;Although it depends on your sketch, you can somewhat decrease the size by &lt;strong&gt;reusing code with methods.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  val = digitalRead(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1,322 bytes on Arduino Uno. Now let's shrink it a bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  for(uint8_t i = 0; i &amp;lt; 8; i++) {&#xA;    blink(HIGH);&#xA;    blink(LOW);&#xA;  }    &#xA;  val = digitalRead(10);&#xA;}&#xA;&#xA;void blink(uint8_t state) {&#xA;  digitalWrite(led, state);   // turn the LED to the right state&#xA;  delay(1000);                // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1,194 bytes. That's about a 10% decrease!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, although it doesn't &lt;em&gt;greatly&lt;/em&gt; shrink a sketch, it sometimes can be the easiest route when you are two bytes over the limit, or just want to make a more compact sketch to begin with without loosing any functionality. It's not for every situation, but I find it useful sometimes.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-06-15T14:00:52.420" LastActivityDate="2015-06-15T14:00:52.420" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="810" PostTypeId="1" AcceptedAnswerId="811" CreationDate="2014-03-19T00:15:29.617" Score="5" ViewCount="725" Body="&lt;p&gt;There has been a lot of talk about shrinking sketches recently, but if you don't need the room, should it be done? Will it speed up my program?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;&#xA;  val = digitalRead(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1,396 bytes on Arduino Uno. Now let's shrink it a bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  blink();&#xA;  val = digitalRead(10);&#xA;}&#xA;&#xA;void blink() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1,270 bytes. A 10% decrease! It could be shrunk even more. &lt;strong&gt;I have the space... is it more efficient (as far as speed) to make it the most compact I can or leave it &quot;uncompressed?&quot;&lt;/strong&gt; I would imagine that it would be a little more work (not much) calling &lt;code&gt;blink();&lt;/code&gt;, therefore slowing down my code. Is this true? Are there other advantages/disadvantages of making it as small as possible (besides storage/distribution of C++ files)?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-01-20T02:34:28.627" Title="Should I try to make my sketches as small as possible, even when I have enough room?" Tags="|programming|sketch|sketch-size|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="811" PostTypeId="2" ParentId="810" CreationDate="2014-03-19T02:02:13.733" Score="8" Body="&lt;p&gt;Generally speaking, smaller is better. However, there is a point where too small actually makes the program run slower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is if you are working on a sketch and it is blatantly obvious that you are repeating code over and over again, I would rip that out and put it into a function, not only does it make the program smaller, it makes it easier to read. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also some optimization going on behind the scenes as well during compilation, so even though the C/C++ code looks to be large, chances are the compiler/linker are determining that something are repeats and consolidating them... Or at least the AVR compiler I used previously did, cannot remember if Arduino does this.&lt;/p&gt;&#xA;" OwnerUserId="701" LastActivityDate="2014-03-19T02:02:13.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="812" PostTypeId="1" AcceptedAnswerId="813" CreationDate="2014-03-19T04:22:10.897" Score="4" ViewCount="1548" Body="&lt;p&gt;I have the below portable electric heater, but I would love to control it's start AND stop time using an Arduino. As-is, it does not come with a stop feature. SO, I have a burning question. How can I get an Arduino to start and stop this heater at specific times of the day?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, it does have a start time, but it does not have a stop time.&#xA;The power button is a simple push button. I suspect I would need to 'interject' into that and the board by using a switch? Apologies if the terminology is off, but I'm very green.&#xA;Where would a noob begin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-EDIT-&#xA;The unit is always off when it's plugged back in. That likely means I cannot put a timer on the power cord. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ybUjr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="381" LastEditorUserId="381" LastEditDate="2014-03-19T11:05:37.593" LastActivityDate="2015-02-21T05:12:46.163" Title="What are some steps to attach an Arduino to an electric heater?" Tags="|arduino-uno|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="813" PostTypeId="2" ParentId="812" CreationDate="2014-03-19T06:19:04.083" Score="2" Body="&lt;p&gt;Would or should begin? Don't fiddle with the internals of the heater. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set its switch to the always on position and control switching on and off with an external relay. Make a box that has plenty of room (you can reduce size at a later moment), a power cord, a mains adapter for your Arduino and a mains outlet in which you can plug your heater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;an &lt;a href=&quot;http://www.amazon.co.uk/s/?tag=duc08-21&amp;amp;url=search-alias%3Daps&amp;amp;field-keywords=rtc%20breakout&quot; rel=&quot;nofollow&quot;&gt;RTC (real time clock) breakout&lt;/a&gt; to keep accurate time&lt;/li&gt;&#xA;&lt;li&gt;optionally a &lt;a href=&quot;http://www.amazon.co.uk/MAX7219-8-Digit-Display-Segment-Digital/dp/B00IHSE6V6/ref=sr_1_6?ie=UTF8&amp;amp;qid=1395212225&amp;amp;sr=8-6&amp;amp;keywords=7+segment+display&quot; rel=&quot;nofollow&quot;&gt;7 segment display&lt;/a&gt; to display date/time. Just make sure it has a driver chip on it so you don't need your Arduino to multiplex the individual LEDs&lt;/li&gt;&#xA;&lt;li&gt;couple push buttons to configure the device&lt;/li&gt;&#xA;&lt;li&gt;a &lt;a href=&quot;http://www.amazon.co.uk/s/ref=nb_sb_noss_1?url=search-alias%3Daps&amp;amp;field-keywords=relay+5V&amp;amp;rh=i%3Aaps%2Ck%3Arelay+5V&quot; rel=&quot;nofollow&quot;&gt;relay&lt;/a&gt; rated for the maximum power of the heater to turn it on/off, that can be driven from 5V. Possibly needs a transistor and flyback diode to be controlled from an Arduino GPIO line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And be &lt;strong&gt;very&lt;/strong&gt; careful when experimenting with mains power, it can be leathal.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-19T06:58:06.987" LastActivityDate="2014-03-19T06:58:06.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="814" PostTypeId="2" ParentId="810" CreationDate="2014-03-19T08:30:20.267" Score="12" Body="&lt;p&gt;You second code may be smaller in size but due to the function call overhead the max execution speed is reduced.&lt;br&gt;&#xA;Does this matter in your case? No, because you have huge delays anyway, but if the code was an actual series of repeated calculations that should be executed as fast as possible then it would make a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general rule, smaller code is not necessarily faster too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For code optimization (either size or speed) you can refer to this application note from Atmel &lt;a href=&quot;http://www.atmel.com/images/doc8453.pdf&quot;&gt;AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could repeat everything it says here but I don't think there is a point, you can read the original article directly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding the compiler optimization level. Arduino IDE uses the avr-gcc compiler with a setting for &lt;strong&gt;Os&lt;/strong&gt; optimization.&lt;br&gt;&#xA;The avr-gcc available optimization levels are (&lt;a href=&quot;http://www.network-theory.co.uk/docs/gccintro/gccintro_49.html&quot;&gt;source1&lt;/a&gt; &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Optimize-Options.html#Optimize-Options&quot;&gt;source2&lt;/a&gt;)  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;O0 or no -O option&lt;/strong&gt;&lt;br&gt;&#xA;At this optimization level GCC does not perform any optimization and compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the best option to use when debugging a program and is the default if no optimization level option is specified.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;O1 or -O&lt;/strong&gt;&lt;br&gt;&#xA;This level turns on the most common forms of optimization that do not require any speed-space tradeoffs. With this option the resulting executables should be smaller and faster than with -O0. The more expensive optimizations, such as instruction scheduling, are not used at this level. Compiling with the option -O1 can often take less time than compiling with -O0, due to the reduced amounts of data that need to be processed after simple optimizations. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;O2&lt;/strong&gt;&lt;br&gt;&#xA;This option turns on further optimizations, in addition to those used by -O1. These additional optimizations include instruction scheduling. Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;O3&lt;/strong&gt;&lt;br&gt;&#xA;This option turns on more expensive optimizations, such as function inlining, in addition to all the optimizations of the lower levels -O2 and -O1. The -O3 optimization level may increase the speed of the resulting executable, but can also increase its size. Under some circumstances where these optimizations are not favorable, this option might actually make a program slower. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Os&lt;/strong&gt;&lt;br&gt;&#xA;This option selects optimizations which reduce the size of an executable. The aim of this option is to produce the smallest possible executable, for systems constrained by memory or disk space. In some cases a smaller executable will also run faster, due to better cache usage.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="470" LastEditorUserId="470" LastEditDate="2014-03-19T09:43:12.373" LastActivityDate="2014-03-19T09:43:12.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="815" PostTypeId="1" AcceptedAnswerId="822" CreationDate="2014-03-19T14:26:44.540" Score="33" ViewCount="57450" Body="&lt;p&gt;There are a lot of methods to power an Arduino from a large range of voltages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB cable from PC or from a phone charger or an USB hub&lt;/li&gt;&#xA;&lt;li&gt;step down converters&lt;/li&gt;&#xA;&lt;li&gt;step up converters&lt;/li&gt;&#xA;&lt;li&gt;switching power supply&lt;/li&gt;&#xA;&lt;li&gt;batteries (connected to the power jack or USB or to Vin)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I can't seem to find is a small 220V-5V converter. I'd like to put an Arduino in the wall, under a light switch, so size matters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last resort option is to open a 5V phone charger and replace the metal prongs that go in a socket with two wires, and replace the USB socket with another pair of wires that go the Arduino board, but still, an Arduino Pro Mini or an Arduino Nano is smaller than the phone charger. &lt;/p&gt;&#xA;" OwnerUserId="709" LastEditorUserId="46" LastEditDate="2015-08-27T00:12:47.457" LastActivityDate="2018-07-02T00:56:52.167" Title="Most compact method of powering Arduino from wall socket" Tags="|arduino-uno|power|arduino-nano|arduino-pro-mini|electricity|" AnswerCount="14" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="816" PostTypeId="1" AcceptedAnswerId="817" CreationDate="2014-03-19T14:34:30.793" Score="103" ViewCount="262193" Body="&lt;p&gt;What are the advantages of each language when using the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking this is a good general question, but I'll add a bit about why I'm asking if anyone wants to give me a tip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic. In other words I know programming techniques and both classical and prototypal object orientation, but nothing about communicating directly with hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm making an octocopter, and am thinking that an object oriented approach will be the easiest. (The software will have very many features...) However I have never written in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is a Q&amp;amp;A site that's supposed to help others, only the general question presented at the beginning is of much importance, but I'd appreciate any comments on my situation.&lt;/p&gt;&#xA;" OwnerUserId="693" LastActivityDate="2023-08-08T17:42:18.230" Title="C++ vs. The Arduino Language?" Tags="|c++|arduino-ide|" AnswerCount="9" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="817" PostTypeId="2" ParentId="816" CreationDate="2014-03-19T14:51:57.067" Score="66" Body="&lt;p&gt;My personal experience as professor (programming, mechatronics) is that if you have previous programming experience and you are aware of concepts as OOP, it is better to go for C/C++. The arduino language is really great for beginners, but have some limitations (e.g. you must have all your files in the same folder). And it is basically a simplification of C/C++ (you can practically copy&amp;amp;paste arduino code to a C/C++ file, and it will work). Also it makes sense that you can go and use a full well known IDE as eclipse:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/Eclipse&quot;&gt;http://playground.arduino.cc/Code/Eclipse&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially it is required a bit more of setup and configuration of your dev environment, but IMHO it is worth it for programmers with experience in any other language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, it won't harm you to start using the arduino language and the arduino IDE for a few days to get familiar with the arduino hardware and then move to C/C++ with Eclipse for really developing your project.&lt;/p&gt;&#xA;" OwnerUserId="666" LastEditorUserId="666" LastEditDate="2014-03-19T14:57:18.857" LastActivityDate="2014-03-19T14:57:18.857" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="818" PostTypeId="2" ParentId="816" CreationDate="2014-03-19T14:52:47.250" Score="15" Body="&lt;p&gt;The Arduino language &lt;em&gt;is&lt;/em&gt; C++, but it is very different from most C++ varieties. The Arduino language has a lot of abstraction built in, especially in the hardware interfaces, which makes it very simple to use. If you have a background in Java, C and C++ should be very similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main differences between Arduino and C++ are in the memory storage. Usually a modern computer has more than 2GB of RAM, while the Arduino Uno has 2kB (1 million times less). The Arduino also uses 8-bit instructions in stead of the 32 bit ones a computer uses. This will mainly affect the amount of information you can store in a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are very new to the Arduino world, you should look up a tutorial, as there are many good ones out there.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-19T14:52:47.250" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="819" PostTypeId="2" ParentId="816" CreationDate="2014-03-19T14:59:26.963" Score="53" Body="&lt;p&gt;&lt;strong&gt;In theory...&lt;/strong&gt;&lt;br /&gt;&#xA;There isn't really an Arduino language as such. It's really just C++ with some domain-specific libraries. These add on various features, such as functions you can call to control the hardware. If you didn't have those functions, you'd need to fiddle directly with special registers to control everything. That's how embedded programming is usually done. It's fast, but it can be quite hard to learn and understand.&lt;/p&gt;&#xA;&lt;p&gt;In addition to the functions, the libraries add alternative names for some types. For example, &lt;code&gt;boolean&lt;/code&gt; and &lt;code&gt;byte&lt;/code&gt; are not in the C++ standard. However, they are directly equivalent to &lt;code&gt;bool&lt;/code&gt; and &lt;code&gt;unsigned char&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;All of these things mean you can probably port general C++ code directly to Arduino without difficulty. However, going back the other way may require some minor editing.&lt;/p&gt;&#xA;&lt;p&gt;But note that not all features of modern C++ versions are available on all Arduino platforms. In some cases, they aren't realistically possible, such as &lt;code&gt;std::thread&lt;/code&gt; on an 8-bit microcontroller. Others simply haven't been made available, such as &lt;code&gt;std::array&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;In practice...&lt;/strong&gt;&lt;br /&gt;&#xA;Having said all of that, programming for Arduino isn't exactly the same as general C++ programming. A lot of the differences are common to all embedded programming though (such as limited memory and processing power).&lt;/p&gt;&#xA;&lt;p&gt;It's also worth noting that if you're using the official Arduino IDE then there are all sorts of annoying quirks and limitations on how you setup your code. There are workarounds in all cases (as far as I'm aware), but they are sometimes quite frustrating.&lt;/p&gt;&#xA;&lt;p&gt;For full flexibility, use a third-party IDE (such as Eclipse) with a plug-in to support Arduino. That should give you all the advantages of C++, along with the Arduino libraries.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2023-03-31T14:44:42.297" LastActivityDate="2023-03-31T14:44:42.297" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="820" PostTypeId="2" ParentId="815" CreationDate="2014-03-19T15:16:04.090" Score="2" Body="&lt;p&gt;What if you replace the nearest outlet with some kind of &lt;a href=&quot;http://www.alibaba.com/product-detail/Nice-Dual-USB-Wall-socket-For_1518461365.html&quot; rel=&quot;nofollow&quot;&gt;USB Wall Socket&lt;/a&gt; and attach to that (either through a standard USB plug, or inside the wall) ?&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-19T15:16:04.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="821" PostTypeId="1" AcceptedAnswerId="836" CreationDate="2014-03-19T15:27:47.403" Score="2" ViewCount="3838" Body="&lt;p&gt;An XBee Series 2 is set to &lt;code&gt;Router AT&lt;/code&gt; whose &lt;code&gt;TX&lt;/code&gt; and &lt;code&gt;RX&lt;/code&gt; pins are connected to an Arduino Nano's &lt;code&gt;Rx&lt;/code&gt; and &lt;code&gt;Tx&lt;/code&gt; pins respectively. The Arduino is connected to a Mac OSX via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second XBee Series 2 is connected to a Windows system via USB. It is set to &lt;code&gt;Coordinator API&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the sketch below on the Arduino, a packet is sent from the &lt;code&gt;Router AT&lt;/code&gt; XBee to the &lt;code&gt;Coordinator API&lt;/code&gt; XBee, which is seen by &lt;code&gt;XCTU&lt;/code&gt; as a Explicit RX frame. However the Arduino LED should blink once if it received a reply packet (should it?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On another test, I wrote a script to send a frame for the &lt;code&gt;Coordinator API&lt;/code&gt; XBee to send to the &lt;code&gt;Router AT&lt;/code&gt; XBee. Once again the Arduino LED does not blink, and nothing is seen using Arduino's Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing the &lt;code&gt;Coordinator API&lt;/code&gt; XBee&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the same script to send a packet from &lt;code&gt;Coordinator API&lt;/code&gt; XBee to itself, the packet was received as well as a delivery confirmation packet. This shows that both the &lt;code&gt;Coordinator API&lt;/code&gt; XBee and the script are working.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;// Delivery confirmation &#xA;received:  { type: 144,&#xA;  remote64: '0013a20040a74613',&#xA;  remote16: '0000',&#xA;  receiveOptions: 1,&#xA;  data: [ 116 ] }&#xA;&#xA;// Received the packet sent to itself     &#xA;received:  { type: 139,&#xA;  id: 1,&#xA;  remote16: '0000',&#xA;  transmitRetryCount: 0,&#xA;  deliveryStatus: 0,&#xA;  discoveryStatus: 0 }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing the Arduino Sketch Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the same Arduino sketch which continuously sends API frames to the &lt;code&gt;Coordinator&lt;/code&gt;, I connected the &lt;code&gt;Router AT&lt;/code&gt; XBee's &lt;code&gt;RX&lt;/code&gt; pin to Arduino's &lt;code&gt;RX&lt;/code&gt; pin, so the frames the Arduino are sending out are going back into its &lt;code&gt;RX&lt;/code&gt; pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This causes the Arduino's LED to light up! So there is nothing wrong with the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Does this mean the &lt;code&gt;Router AT&lt;/code&gt; XBee is not configured properly? I do not think its &lt;code&gt;TX&lt;/code&gt; pin is damaged because &lt;code&gt;XCTU&lt;/code&gt; can still read the settings off this XBee. Any ideas on how we can troubleshoot this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Sketch (Connected to Router Xbee)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;&#xA;XBee xbee = XBee();&#xA;uint8_t payload[] = { 0, 0 };&#xA;&#xA;// SH + SL Address of receiving XBee&#xA;XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40a74613);&#xA;ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));&#xA;ZBTxStatusResponse txStatus = ZBTxStatusResponse();&#xA;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;&#xA;    Serial.begin(9600);&#xA;    xbee.setSerial(Serial);&#xA;}&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;    xbee.send(zbTx);&#xA;    delay(1000);&#xA;&#xA;    xbee.readPacket();&#xA;    if (xbee.getResponse().isAvailable()) {&#xA;        // Response received, blink LED once&#xA;        Serial.println('resposne!');&#xA;        digitalWrite(13, HIGH);&#xA;        delay(1000);&#xA;        digitalWrite(13, LOW);&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="639" LastEditorUserId="26916" LastEditDate="2017-11-04T17:26:10.020" LastActivityDate="2017-11-11T07:23:25.503" Title="Arduino unable to read from XBee Series 2" Tags="|programming|serial|sketch|arduino-nano|xbee|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="822" PostTypeId="2" ParentId="815" CreationDate="2014-03-19T15:55:13.463" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The last resort option is to open a 5v phone charger and replace the metal prongs that go in a socket with two wires, and replace the usb socket with another pair of wires that go the arduino board, but still, an Arduino Pro Mini or an Arduino Nano is smaller than the phone charger.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will probably have to do something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Wall_wart_opened.JPG/800px-Wall_wart_opened.JPG&quot; &gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the nature of conversion between AC and DC, there has to be some large parts.* I'm not going to go into the specifics here. There is usually a diode bridge (because AC waveforms reverse the current ~60 times a second) and a transformer (to lower the voltage for the diode bridge). They almost always include a regulator and a capacitor to make sure voltage is exact and it outputs a &quot;clean&quot; power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*&lt;a href=&quot;http://en.wikipedia.org/wiki/Switching_power_supply&quot; rel=&quot;nofollow noreferrer&quot;&gt;Switching power supplies&lt;/a&gt;, although considerably more expensive, are a lot smaller and more power efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.amazon.co.uk/Xcessor-Compact-European-Wall-Charger/dp/B00DVLHZOE/ref=sr_1_1?s=electronics&amp;amp;ie=UTF8&amp;amp;qid=1395244016&amp;amp;sr=1-1&amp;amp;keywords=220v+usb+adapter&quot; rel=&quot;nofollow noreferrer&quot;&gt;This adapter&lt;/a&gt; seems to be the most compact adapter I can find for 220V. You'll never get something near the size you are desiring, even with a switching power supply. I don't know the size of the Amazon adapter I gave a link for, but in the US (120V), iPhone chargers are very small and they should fit in a standard depth outlet box (with a little room left over for relays and such). If you &lt;em&gt;really&lt;/em&gt; need to get everything smaller, I recommend using a ATtiny chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How I recommend connecting this:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would avoid ripping this apart at all costs from a safety perspective. It would be really easy to send 220V to your Arduino if you're not careful. If you &lt;em&gt;absolutely have to&lt;/em&gt;, you might want to coat it with some non-conductive epoxy or other coding. Note: this may act as a thermal insulator, therefore reducing the lifespan of the part. You should just coil some wire around the prongs, and then melt a little solder onto each of the terminals. Then, cover that with electrical tape and pigtail (with a wire nut) into a source power line. Note: you probably are doing wiring that could be illegal in your area. Check your local building codes before attempting this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, attach a USB cord to the socket and to the Arduino or the ATtiny/ATmega328 chip 5V/GND input (of coarse, after cutting and stripping one end of the USB cord). I would also, after finalizing all the code and circuitry, seal that with some epoxy or somehow add it to an enclosure to make sure you don't fry your Arduino if a loose wire touches the Arduino circuitry.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;If you don't feel safe doing any of the above, &lt;em&gt;don't do it&lt;/em&gt;. You can live without a Arduino light switch.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;That being said, happy hacking! :P&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.253" LastActivityDate="2014-08-05T18:22:53.807" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="824" PostTypeId="2" ParentId="816" CreationDate="2014-03-19T17:09:02.170" Score="17" Body="&lt;p&gt;--- Update 170412&lt;br&gt;&#xA;I wrote my original answer three years ago from the perspective of there existing a distinct &quot;Arduino C++&quot;. The language used in the IDE &lt;em&gt;is&lt;/em&gt; standard C++, because it is implemented by the GNU C++ compiler. &quot;Apparent&quot; differences creep in because the IDE will do some pre-processing to help newcomers to the language avoid a couple of 'gotcha's, by filling in some #includes, f/ex. But you can - and I do - write correct C++ to it and get just what you expect to get.&lt;br&gt;&#xA;--- end update &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do limit your use of C++ language features to those whose implementation you fully understand. There are some features that compile to more resource-intensive code than is obvious from reading the source code. The optionally generated .lss (merged source and assembly) listing can give you some good insight into what the C++ compiler did when you weren't looking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To your question about memory: C++ does not garbage-collect. Stack-based languages like C and C++ do allocate temporary storage on the stack for automatic variables at function entry, which then gets released when the function returns, but this is not true garbage-collection. Objects created in heap- or global memory live until you explicitly delete them. Make sure you know where, when, and for how long different kinds of objects will be created. You really don't want your code &lt;code&gt;new&lt;/code&gt;-ing and &lt;code&gt;delete&lt;/code&gt;-ing objects willy-nilly. They will be built in heap memory, fragmenting it and causing it to grow up into the stack. That's when your code - and your nice 'copter - will crash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C does less for you so it can do less &lt;strong&gt;to&lt;/strong&gt; you. It's not a bad choice. C with a few of C++'s features can be an even better choice, given you choose the extra features judiciously.C++, if those are your two choices:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Original answer]&#xA; - C++ is a standardized language. It is widely deployed in many environments including embedded systems and therefore is more thoroughly tested than the very-like-C++ language that is &quot;Arduino&quot;. This is especially important for mission-critical / safety-critical applications such as you are planning. Crashed code means a crashed 'copter and even if it doesn't hurt someone, it &lt;strong&gt;will&lt;/strong&gt; break your expensive machine.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Being standard, C++ is portable. Need to upgrade your processor? Everything but silicon-specific code will port to the new one. Need to change your toolset, development system, host OS? C++ will be supported everywhere. Though Arduino IDE will run anywhere Java is supported, it is the only tool that uses Arduino C++ and it is a very limited tool. If you want to use Eclipse, the AVR tools, go barefoot on the command-line, develop within Emacs, or whatever other environment you prefer, standard C++ will be supported.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Arduino IDE does things behind your back - specifically, it #includes .h files when it thinks you need them. Even if it is correct, you really want to write, or at least see and understand, everything the compiler is going to see. Programming languages aren't made for computers (computers eat bits for breakfast); they're made for people, specifically the people who follow you on the project, the most important of whom may be ... you!, when 6 months after you wrote a module, you have to come back to enhance it, or more likely, fix it. You really want to be able to see everything the compiler sees.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2019-08-26T12:14:02.397" LastActivityDate="2019-08-26T12:14:02.397" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="825" PostTypeId="1" AcceptedAnswerId="850" CreationDate="2014-03-19T17:10:02.733" Score="12" ViewCount="3220" Body="&lt;p&gt;Has anyone seen or know of a method of preloading (using a computer or whatever) a firmware as data onto one arduino set up to operate as an isp and then using that arduino plug the isp interface into another and upload the firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear - i'm looking for a way to make uploading arduino sketches possible without a direct connection to a full blown computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally the steps involved would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Write new sketch/firmware&lt;/li&gt;&#xA;&lt;li&gt;Compile firmware&lt;/li&gt;&#xA;&lt;li&gt;Write a copy firmware onto Arduino A as data (Arduino A is set up to work as ISP)&lt;/li&gt;&#xA;&lt;li&gt;Detach Arduino A from the computer&lt;/li&gt;&#xA;&lt;li&gt;In a seperate location attach Arduino A to Arduino B using ISP headers&lt;/li&gt;&#xA;&lt;li&gt;Using some method (maybe a pushbutton) trigger Arduino A to upload the preloaded firmware onto Arduino B.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm assuming that theoretically it could work because uploading firmware is just an exchange of bytes across the SPI interface but i'm not sure about the reality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scenario for which I'm considering is if I were to install an arduino (permanently) in a location that is remote from my computer (I don't have a laptop nor do I want to get one) it would be troublesome to reprogram it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other method I have considered is using the DIL packaged ATMEGA which I can then remove from the board and program at the computer and return to the board - however I would much prefer not to risk bending of pins and the hassle of having to remove the chip each time I want to reprogram.&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2014-03-20T17:39:06.713" Title="Arduino as ISP without a computer" Tags="|programming|uploading|isp|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="826" PostTypeId="2" ParentId="815" CreationDate="2014-03-19T17:15:06.997" Score="4" Body="&lt;p&gt;The smallest is probably a plug-in USB charger such as Apple's tiny cube. The cheapest is bound to be a ~9v (output) wall-wart scrounged from the lost and found in a tourist's/traveller's hotel.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-03-19T17:15:06.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="827" PostTypeId="2" ParentId="816" CreationDate="2014-03-19T17:27:00.953" Score="28" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What are the advantages of C++ vs the Arduino language when using Arduino? I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, the Arduino compiler/IDE accepts C and C++ as-is.  In fact many of the libraries are written in C++.  Much of the underlying system is not object oriented, but it could be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, &quot;The arduino language&quot; is C++ or C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C++ is not garbage collected.  It does manage variables in scope - if you write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;&#xA;void blinkTimes(int value)&#xA;{&#xA;   int i;&#xA;&#xA;   for(i=0;i&amp;lt;value;i++)&#xA;   {&#xA;      digitalWrite(led, HIGH);&#xA;      delay(1000);&#xA;      digitalWrite(led, LOW);&#xA;      delay(1000);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you'll find that &lt;code&gt;led&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; don't grow or leak, no matter how many times you call &lt;code&gt;blinkTimes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;i&lt;/code&gt; were a class, it would similarly be disposed of once the function ended.  So as long as you aren't using &lt;code&gt;new&lt;/code&gt; or similar memory allocation functions to create new objects, then you won't have to worry about leaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may still run out of memory, if you create huge classes and use a lot of them in deeply nested functions, but in general you aren't going to run into trouble until you start dealing with &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using &lt;code&gt;new&lt;/code&gt;, then you'll have to call &lt;code&gt;delete&lt;/code&gt; at appropriate times.  C++, and by extension Arduino, has no automatic garbage collection, you have to explicitly manage your own memory.&lt;/p&gt;&#xA;" OwnerUserId="349" LastEditorUserId="84" LastEditDate="2014-03-19T21:51:26.480" LastActivityDate="2014-03-19T21:51:26.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="828" PostTypeId="2" ParentId="815" CreationDate="2014-03-19T17:52:23.080" Score="13" Body="&lt;p&gt;I can suggest you to try this : &lt;a href=&quot;http://www.aliexpress.com/item/220V-to-5V-AC-DC-Step-Down-Converter-5V-800mA-Switching-Power-Supply-Module-AC-85/1488428284.html&quot;&gt;AC DC Step Down Converter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is as small as the Apple's tiny cube, and it can be placed inside of a wall easily. (I'm personally using this with an arduino micro)&lt;/p&gt;&#xA;" OwnerUserId="717" LastActivityDate="2014-03-19T17:52:23.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="829" PostTypeId="2" ParentId="825" CreationDate="2014-03-19T18:16:06.883" Score="4" Body="&lt;p&gt;I have no direct solution for what you want, but yes it is possible to do it. You can hack a bootloader firmware so that it reads the firmware flash code and upload it over ISP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though you obviously can't upload 32k of firmware on the target AVR if both arduinos have only 32k of total flash in their MCUs, you'll need to have the flasher have more flash than the target if you want to do so (a 1284p or 2560 Mega will be far enough, or a 328/32u4 will be cood to flash a 168 or an attiny).&#xA;The only exception would be to have the firmware to be flashed way smaller than the total memory (like for a blink sketch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, that won't be easy, it's 100% pure AVR code, but you can do it. Have a look at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://blog.schicks.net/wp-content/uploads/2009/09/bootloader_faq.pdf&quot; rel=&quot;nofollow&quot;&gt;The bootloader FAQ&lt;/a&gt; ;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://code.google.com/p/optiboot/&quot; rel=&quot;nofollow&quot;&gt;The Optiboot Project&lt;/a&gt; which goal is to make the smallest bootloader possible and&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://code.google.com/p/micropendous/wiki/AVRISP&quot; rel=&quot;nofollow&quot;&gt;AVRISP&lt;/a&gt; source code&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The way I'd implement that would be to either make everything fit in the bootloader of the flasher device, so it reads the firmware (everything from 0x00 to the bootloader start address) and flashes it through ISP by merging AVRISP with Optiboot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, that's an interesting project for a workshop about bootloaders and AVRs I may suggest at my local hackerspace! ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-03-19T18:16:06.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="830" PostTypeId="1" AcceptedAnswerId="845" CreationDate="2014-03-19T20:33:20.310" Score="5" ViewCount="10034" Body="&lt;p&gt;I am currently playing with Arduino timers (on UNO currently) and I am building a library that  has a function that must be called every millisecond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is plenty of code samples on Internet so I went with something that seemed perfect for my needs. I have then updated it to make it a reusable C++ class. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code (simplified to just isolate the issue):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BIT(x) (0x01 &amp;lt;&amp;lt; (x))&#xA;&#xA;static volatile uint32_t milliseconds = 0;&#xA;&#xA;class Timer&#xA;{&#xA;    public:&#xA;    Timer()&#xA;    {&#xA;        // Disable interrupts&#xA;        uint8_t savedStatus = SREG;&#xA;        cli();&#xA;        // Use Timer2 with 1 ms interrupts&#xA;        // OC2A &amp;amp; OC2B disconnected, mode 2 (CTC, Clear Timer on Compare match)&#xA;        TCCR2A = BIT(WGM21);&#xA;        // Don't force output compare (FOCA &amp;amp; FOCB), mode 2, Clock Select clk/128 (CS = 5)&#xA;        TCCR2B = BIT(CS22) | BIT(CS20);&#xA;        // Set timer counter compare match (when value reached, 1ms has elapsed)&#xA;        OCR2A = 125 - 1;&#xA;        // Reset Timer2 counter&#xA;        TCNT2 = 0;&#xA;        // Set Timer2 interrupt mode (Set interrupt on OCR2A compare match)&#xA;        TIMSK2 = BIT(OCIE2A);&#xA;&#xA;        // Restore interrupt enabling state&#xA;        SREG = savedStatus;&#xA;    }&#xA;};&#xA;&#xA;static void callEveryMillisecond(uint32_t ms)&#xA;{&#xA;    // Do something here&#xA;}&#xA;&#xA;// Attach interrupt routine to the Timer Compare Interrupt&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;    milliseconds++;&#xA;    callEveryMillisecond(milliseconds);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After checking &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega328 datasheet&lt;/a&gt; (section 17) several times, I came to the conclusion that what I do in &lt;code&gt;Timer&lt;/code&gt; class constructor above is correct, and for Arduino UNO, the values used must lead to one call of the ISR every ms:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CPU frequency = &lt;strong&gt;16MHz&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Prescaler = &lt;strong&gt;128&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;-&gt; timer frequency = &lt;strong&gt;16MHz/128 = 125KHz&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;-&gt; max counter value = &lt;strong&gt;125&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I decided to use the &lt;strong&gt;CTC&lt;/strong&gt; (Clear Timer on Compare match) mode, which means that when the timer &lt;code&gt;TCNT2&lt;/code&gt; (which is incremented at 125KHz frequency), reaches &lt;code&gt;OCR2A&lt;/code&gt; value, then it will trigger the ISR, and then will be reset on next tick; the additional tick to reset the counter explains why we use &lt;code&gt;125 - 1&lt;/code&gt; for &lt;code&gt;OCR2A&lt;/code&gt; and not just &lt;code&gt;125&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now comes the weird stuff. In order to check that my code worked, I decided to blink the LED on pin 13 every 10 seconds, hence I have added the following code to my program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static void callEveryMillisecond(uint32_t ms)&#xA;{&#xA;    if (ms % 10000 == 0)&#xA;        digitalWrite(13, digitalRead(13) ^ 1);&#xA;}&#xA;&#xA;static Timer timer;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I measured the time during which pin 13 LED is lit on (or off, both measures are the same). Measures are not very accurate (I just used my wristwatch) but good enough for my check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was surprised to see the measured time to be about &lt;strong&gt;20 seconds instead of 10s&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I thought about a mismatch in CPU frequency, but after performing a lot of small changes, here is what I found which worked perfectly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//static Timer timer;&#xA;&#xA;void setup()&#xA;{&#xA;    static Timer timer;&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just moving the &lt;code&gt;Timer&lt;/code&gt; instance into &lt;code&gt;setup()&lt;/code&gt; did the trick: my measures rightly indicated &lt;strong&gt;10 seconds&lt;/strong&gt; between 2 states of the pin 13 LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now my questions are:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why the second code sample works perfectly, whereas the first does not?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there, in standard Arduino included code, some code that would overwrite some of the settings I perform for Timer2 in &lt;code&gt;Timer::Timer()&lt;/code&gt;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a way to make the first code sample work? Note that I don't like the second sample because it does not seem natural coding, also, I will need access to &lt;code&gt;Timer&lt;/code&gt; &lt;code&gt;timer&lt;/code&gt; instance in several locations of my future program, hence it can't be possible if it is declared in the scope of &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-20T06:15:27.507" LastActivityDate="2015-04-25T14:57:17.290" Title="Timer2 does not work as it should" Tags="|arduino-uno|c++|timers|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="831" PostTypeId="2" ParentId="815" CreationDate="2014-03-19T21:04:16.180" Score="10" Body="&lt;p&gt;Nowadays, most smartphones come with a charger that is linked to the USB plug of the phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The charger for my HTC says: &lt;strong&gt;5V&lt;/strong&gt;, &lt;strong&gt;1A&lt;/strong&gt;, I guess this voltage must be regulated (but I haven't checked it has the charger is sealed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NYLJn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The charger itself has a female USB socket on which you can plug any USB cord to link to your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IMPORTANT!&lt;/strong&gt; I have never tried it myself! I would not bet my life on it! It would be wise to check the output voltage is well regulated.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-19T21:04:16.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="832" PostTypeId="2" ParentId="658" CreationDate="2014-03-19T21:20:24.353" Score="2" Body="&lt;p&gt;Note that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct { ... } Foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is obsolete in C++ and you should just use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct Foo { ... };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not very clear in the answers but the other effect of structs is public inheritance by default vs private inheritance by default with classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned by others, using struct is generally a convention for POD types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also technically 'struct vs object' should be 'struct vs class' (as instantiating a struct or a class still gives an object).&lt;/p&gt;&#xA;" OwnerUserId="722" LastActivityDate="2014-03-19T21:20:24.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="833" PostTypeId="2" ParentId="658" CreationDate="2014-03-19T21:35:17.490" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;In terms of memory, what difference will this make?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;None. Structs and classes are the same thing, differing only in protection levels, and instantiating either creates an 'object'.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;still see the struct technique being used heavily - why is this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Less typing if you're not trying to hide data members.&lt;/p&gt;&#xA;" OwnerUserId="723" LastActivityDate="2014-03-19T21:35:17.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="834" PostTypeId="2" ParentId="810" CreationDate="2014-03-19T21:38:42.387" Score="2" Body="&lt;p&gt;Your refactor should be done simply because it's better code, not because it's smaller. The advantage is that it's easier to modify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If making the code size smaller results in a loss of clarity (not so in your case), then you should probably view it as a &lt;a href=&quot;http://c2.com/cgi/wiki?PrematureOptimization&quot; rel=&quot;nofollow&quot;&gt;premature optimization&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="723" LastEditorUserId="723" LastEditDate="2014-04-06T17:06:12.347" LastActivityDate="2014-04-06T17:06:12.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="835" PostTypeId="2" ParentId="812" CreationDate="2014-03-19T22:41:58.290" Score="1" Body="&lt;p&gt;&lt;strong&gt;I don't know if that heater will work for sure with this approach because the buttons are weird.&lt;/strong&gt; However, I am 99% sure this will work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qx3F5.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(From &lt;a href=&quot;http://keshavsaharia.com/2012/12/01/coffeeduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://keshavsaharia.com/2012/12/01/coffeeduino/&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically here's what you do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disassemble the control panel to find the PCB where the buttons are mounted. Find which button you want to simulate a press of.&lt;/li&gt;&#xA;&lt;li&gt;Find the solder joint where the button meets the PCB.&lt;/li&gt;&#xA;&lt;li&gt;Solder a wire to the two terminals that are connected. Some buttons have three or four terminals: look at the traces on the PCB to see which buttons are connected.&lt;/li&gt;&#xA;&lt;li&gt;Wire the relay with the two wires connected so the relay acts as a switch.&lt;/li&gt;&#xA;&lt;li&gt;Make the proper connections to the Arduino board to control the relay.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In code, you can just turn the relay on for a quarter of a second or so. Then, the IC on the heater will react like you pushed the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to seal all of this up and make sure you don't accidentally short out any of the wires. I would say to also isolate the Arduino and relay to make sure that you don't electrocute yourself at all if something goes wrong.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-19T22:41:58.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="836" PostTypeId="2" ParentId="821" CreationDate="2014-03-19T23:04:27.167" Score="1" Body="&lt;p&gt;As I mentioned in my comments to your question, if you are using &lt;a href=&quot;https://code.google.com/p/xbee-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; library&#xA;then it doesn't actually support AT mode. In fact, AT mode (otherwise known as Transparent Mode) is simply attached to the &lt;code&gt;Serial&lt;/code&gt; port and accessed directly through the &lt;code&gt;Serial&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: put this into your Arduino attached to the AT Router.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED 13&#xA;&#xA;void setup() {&#xA;    pinMode(LED, OUTPUT);&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;\nXBee AT communications test&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  static unsigned long previous = millis()/1000;&#xA;  if(previous != millis()/1000){&#xA;    previous = millis()/1000;&#xA;    char buffer[5];    &#xA;    sprintf(buffer,&quot;%04i&quot;,previous);&#xA;    Serial.println(buffer);&#xA;   digitalWrite(LED, !digitalRead(LED)); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then open the console on the XCTU software on the API Coordinator watch the packets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dEu73.png&quot; alt=&quot;look at packet 0102&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will see above the received packets from the router. Because the coordinator is in &lt;code&gt;API&lt;/code&gt; mode, you see it like this. (In &lt;code&gt;AT&lt;/code&gt; mode, you will see the raw packets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ichose numbers to send because they are easy to read in this form. Packet &lt;code&gt;0102&lt;/code&gt; appears in the packets data as &lt;code&gt;30 31 30 32 0D 0A&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;AT&lt;/code&gt; mode there is no packet confirmation, validations, status or anything. They are all handled &quot;transparently&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, I've seen many references that both XBees need to be in the same mode. That is, in fact, incorrect. If we modify our source to include &lt;code&gt;Serial.read&lt;/code&gt; you would see data the other way as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; I thought I would add communications between &lt;code&gt;AT Router&lt;/code&gt; and &lt;code&gt;API Coordinator&lt;/code&gt;. I have modified the code in the &lt;code&gt;Router&lt;/code&gt; to receive a constructed packet from the &lt;code&gt;Coordinator&lt;/code&gt; via the XCTU software. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED 13&#xA;&#xA;boolean serialComplete = false;&#xA;char bufferIn[64];&#xA;char bufferOut[5];&#xA;int count=0;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;\nXBee AT communications test&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  static unsigned long previous = millis()/1000;&#xA;  if(serialComplete) {&#xA;    Serial.println(bufferIn);&#xA;    serialComplete=false;&#xA;    count = 0;&#xA;    memset(bufferIn,0,sizeof(bufferIn));&#xA;    digitalWrite(LED,!digitalRead(LED)); &#xA;  }&#xA;  if(previous != millis()/1000){&#xA;    previous = millis()/1000;&#xA;    sprintf(bufferOut,&quot;%04u&quot;,(uint16_t)previous);&#xA;    Serial.println(bufferOut);&#xA;  }&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available()) {&#xA;    char inChar = (char)Serial.read(); &#xA;    if (inChar == '\n' || inChar == '\0') {&#xA;      bufferIn[count++]=0;&#xA;      serialComplete = true;&#xA;    } else {&#xA;      bufferIn[count++] = inChar;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in XCTU construct a packet for the &lt;code&gt;Coordinator&lt;/code&gt;. I'm using version 6.1.0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/C2tmh.png&quot; alt=&quot;add API frame&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and click &quot;the create frame using form generator tool&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QtGD0.png&quot; alt=&quot;form generator tool&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the packet being received by the router. I am only sending &lt;code&gt;9999&lt;/code&gt; &lt;code&gt;nul&lt;/code&gt; terminated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/db0eF.png&quot; alt=&quot;result&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then once the pair are running, you can send the constructed packet from the XCTU software and it will be received by the router.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-03-20T01:21:13.243" LastActivityDate="2014-03-20T01:21:13.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="838" PostTypeId="2" ParentId="830" CreationDate="2014-03-19T23:51:35.850" Score="0" Body="&lt;p&gt;In your setup function, you need to instantiate your timer, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static Timer timer;&#xA;&#xA;void setup()&#xA;{&#xA;    timer = new Timer();                       &amp;lt;&amp;lt;&amp;lt;--- here&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-03-19T23:59:32.450" LastActivityDate="2014-03-19T23:59:32.450" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="839" PostTypeId="1" CreationDate="2014-03-19T23:54:27.277" Score="5" ViewCount="4753" Body="&lt;p&gt;I have a list of set-ups and I only have 2 rows in the lcd , I'm trying to scroll down for the moment and I'm doing this by changing the row in the setcursor function to either 0 or 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However since that I'll be having about 10 set-ups I used an equation that will change the rows to 0 and one for the ones I want to display and a negative number for those that I don't want to appear.&#xA;The problem is when setting the cursor's row to -1 or 2, it will ignore the one with row one (which is the 2nd row).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I can overcome this problem ? by setting it to a row that will not appear on my LCD?&#xA;I'm using &lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;/code&gt;&#xA;and I already set &lt;code&gt;lcd.begin(16, 2);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int  colom[5] = {&#xA;    0-goDown,1-goDown,2-goDown,3-goDown,4-goDown  };&#xA;for (int i = 0; i &amp;lt; 4; i++) {&#xA;    if (colom[i] &amp;gt; 1) colom[i] = -1;&#xA;}&#xA;&#xA;  lcd.setCursor(0, colom[0]);&#xA;  lcd.print(&quot;choise 1 &quot;);&#xA;  lcd.setCursor(0, colom[1]);&#xA;  lcd.print(&quot;choise 2 &quot;);&#xA;  lcd.setCursor(0, colom[2]);&#xA;  lcd.print(&quot;choise 3 &quot;);&#xA;  lcd.setCursor(0, colom[3]);&#xA;  lcd.print(&quot;choise 4 &quot;);&#xA;  lcd.setCursor(0, colom[4]);&#xA;  lcd.print(&quot;choise 5 &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So here goDown is 0 so choice 1 and 2 should appear, but I'm only getting choice 1 and in the second row it's changing quickly between 2 and 5, it's not constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought about doing an if condition for each choice but that will be a lot of code to write and it won't be efficient for my application.&lt;/p&gt;&#xA;" OwnerUserId="730" LastEditorUserId="27346" LastEditDate="2017-11-23T23:30:01.880" LastActivityDate="2017-11-23T23:30:01.880" Title="LCD scrolling down problem" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="840" PostTypeId="2" ParentId="839" CreationDate="2014-03-20T00:36:16.610" Score="4" Body="&lt;p&gt;This is a bad strategy in general. You should not be issuing print calls for things you &lt;em&gt;don't&lt;/em&gt; want to print and relying on the lcd library to filter for you because they're out of bounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call print for only the choices you want to display.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* menu[] = {&#xA;    &quot;choice 1&quot;,&#xA;    &quot;choice 2&quot;,&#xA;    &quot;choice 3&quot;,&#xA;    &quot;choice 4&quot;,&#xA;    &quot;choice 5&quot;,&#xA;};&#xA;const int numMenuItems = sizeof menu / sizeof *menu;&#xA;const int numLcdRows = 2;&#xA;&#xA;&#xA;// start out at the top of the menu&#xA;int scrollPos = 0;&#xA;&#xA;void drawMenu() {&#xA;    for (int i=0; i &amp;lt; numLcdRows; ++i) {&#xA;        lcd.setCursor(0, i); &#xA;        lcd.print(menu[i + scrollPos]);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To scroll up or down, just adjust the scroll offset:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inline void scrollUp() {&#xA;    if (scrollPos &amp;gt; 0)&#xA;        scrollPos--;&#xA;}&#xA;&#xA;inline void scrollDown() {&#xA;    if (scrollPos &amp;lt; numMenuItems - numLcdRows)&#xA;        scrollPos++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note this is untested code written for a library I've never seen (just inferring how it works from your post); it's for illustration purposes only.&lt;/p&gt;&#xA;" OwnerUserId="723" LastEditorUserId="723" LastEditDate="2014-03-20T00:56:46.543" LastActivityDate="2014-03-20T00:56:46.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="841" PostTypeId="2" ParentId="839" CreationDate="2014-03-20T01:30:18.720" Score="1" Body="&lt;p&gt;I have written some abstraction code for handling LCD menus, located here: &lt;a href=&quot;https://github.com/red-green/Arduino_Mobile_OS&quot; rel=&quot;nofollow&quot;&gt;https://github.com/red-green/Arduino_Mobile_OS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the main snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte menu(String title,const String* strings,byte length) {&#xA;  boolean select, esc; static byte item, selection;&#xA;  select = false;&#xA;  esc = false;&#xA;  item = 1;&#xA;  lcd.clear();&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(title);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.print(item);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(strings[item]);&#xA;    delay(100);&#xA;&#xA;  while (!select) {&#xA;    uint8_t buttons = lcd.readButtons();&#xA;    if (buttons) {&#xA;    if (buttons &amp;amp; BUTTON_UP) {&#xA;      item--; &#xA;    }&#xA;    if (buttons &amp;amp; BUTTON_DOWN) {&#xA;      item++;&#xA;    }&#xA;    if (buttons &amp;amp; BUTTON_LEFT) {&#xA;      esc = true;&#xA;    }  &#xA;    if (buttons &amp;amp; BUTTON_SELECT) {&#xA;      selection = item;&#xA;      select = true;&#xA;    }&#xA;&#xA;    item = constrain(item,1,length - 1);&#xA;    lcd.clear();&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(title);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.print(item);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(strings[item]);&#xA;    if (esc) {&#xA;      select = true;&#xA;      selection = 0;&#xA;    }&#xA;    delay(100);&#xA;&#xA;  }&#xA;  } &#xA;  return(selection);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may need to change the button handling to work with your setup. To call, have an array of items before setup, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const String utilmenuitems[6] = {&quot;back&quot;,&quot;Random Numbers&quot;,&quot;Uptime&quot;,&quot;Device Info&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then call it like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte return = menu(&quot;Utilities&quot;,utilmenuitems,4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-20T01:30:18.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="842" PostTypeId="2" ParentId="782" CreationDate="2014-03-20T01:42:15.390" Score="2" Body="&lt;p&gt;I don't have a PRO to play with, but I just looked at the &lt;a href=&quot;ftp://ftp1.digi.com/support/documentation/90000976_F.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; and it appears that it SHOULD timeout after 60 seconds &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If no serial transaction is initiated within a 60 second timeout period, the bootloader times out and returns to &#xA;  the menu. If the upload is interrupted with a power cycle or reset event, the EM250 will detect an invalid &#xA;  application image and enter bootloader mode.  (page 139)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also, it seems that it takes a particular set of conditions to get to the bootloader, obviously these conditions are being met:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;XBee modules use a modified version of Ember’s bootloader. This bootloader version supports a custom entry &#xA;  mechanism that uses module pins DIN (pin 3), DTR / SLEEP_RQ (pin 9), and RTS (pin 16). To invoke the bootloader, &#xA;  do the following:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Set DTR / SLEEP_RQ low (TTL 0V) and RTS high.&lt;/li&gt;&#xA;  &lt;li&gt;Send a serial break to the DIN pin and power cycle or reset the module.&lt;/li&gt;&#xA;  &lt;li&gt;When the module powers up, DTR / SLEEP_RQ and DIN should be low (TTL 0V) and RTS should be high.&lt;/li&gt;&#xA;  &lt;li&gt;Terminate the serial break and send a carriage return at 115200bps to the module.&lt;/li&gt;&#xA;  &lt;li&gt;If successful, the module will send the Ember bootloader menu out the DOUT pin at 115200bps.&lt;/li&gt;&#xA;  &lt;li&gt;Commands can be sent to the bootloader at 115200bps.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Hardware flow control should be disabled when entering and communicating with the EM250 bootloader.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Perhaps check pins 3, 9 and 16 on boot and see if you can modify their behaviour.&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-03-20T01:42:15.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="843" PostTypeId="1" CreationDate="2014-03-20T04:36:24.680" Score="4" ViewCount="3502" Body="&lt;p&gt;I tried testing the system and I’m not sure if the problem is with the XBee’s, the transmitting code, or the receiving code. Before I post my code, I will explain what we are doing with the signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have three analog signals that will be sent serially through one XBee using an Arduino and XBee shield.  We want to send these signals to the receiving xbee where the Arduino will output these signals to be connected to a third Arduino through wires to be used in a Simulink program.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are using an Arduino mega for the transmitting side and an Arduino uno for the receiving side. I was told I need to do serial streaming but I’m not sure how that’s done. I understand the XBee and Arduinos both digitize signals but we are hoping to get a signal very similar to the analog signals we are transmitting. Any amount of help is greatly appreciated!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I have my XBees configured (series 1) both in AT mode:  &lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Transmitting XBee&lt;/strong&gt;:&lt;br&gt;&#xA;      Channel:10&lt;br&gt;&#xA;      Pan id: 1234&lt;br&gt;&#xA;      MY: 10&lt;br&gt;&#xA;      DL: 11  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Receiving XBee&lt;/strong&gt;:&lt;br&gt;&#xA;      Channel:10&lt;br&gt;&#xA;      Pan ID: 1234 &#xA;      MY: 11&lt;br&gt;&#xA;      DL: 10  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Transmitting Arduino code:                   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {  &#xA;  Serial.begin(9600);  &#xA;}  &#xA;void loop() {  &#xA;  // read the input on analog pins &#xA;  int sensorValue1 = analogRead(A0);  &#xA;  int sensorValue2 = analogRead(A1);  &#xA;  int sensorValue3 = analogRead(A2);  &#xA;  // print out the value you read: &#xA;  Serial.println(sensorValue1);  &#xA;  Serial.println(sensorValue2);  &#xA;  Serial.println(sensorValue3);  &#xA;  delay(1);   &#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiving Arduino code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int received1=8;  &#xA;int received2=9;  &#xA;int received3=10;  &#xA;void setup(){  &#xA;  pinMode(received1, OUTPUT);  &#xA;  pinMode(received2, OUTPUT);  &#xA;  pinMode(received3, OUTPUT);  &#xA;  Serial.begin(9600);  &#xA;}  &#xA;void loop(){  &#xA;  if(Serial.available() )  &#xA;  {  &#xA;    byte output1 = Serial.read();  &#xA;    byte output2 = Serial.read();  &#xA;    byte output3 = Serial.read();  &#xA;    digitalWrite(received1, HIGH);  &#xA;    digitalWrite(received2, HIGH);  &#xA;    digitalWrite(received3, HIGH);  &#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="734" LastEditorUserId="84" LastEditDate="2014-03-20T06:11:24.180" LastActivityDate="2014-03-20T11:27:03.943" Title="XBee+Arduino communication problem" Tags="|programming|serial|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="844" PostTypeId="2" ParentId="843" CreationDate="2014-03-20T05:54:42.600" Score="3" Body="&lt;p&gt;There are several things here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Increase your delay, you don't want to be sending the data that often, even if you only increase it to 100-200ms, although I'd recommend making it in the order of 1-30 seconds.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're reading in analog inputs which will be in the range of &lt;code&gt;0-1023&lt;/code&gt; but your serial reads are in byte format (which will actually be reading the first three bytes (or the first three DIGITS of the first reading). More about this below.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're reading in three arbitrary bytes, you're not identifying them at all, you have no idea what you're reading (other than by testing for a 1ms delay--which over XBee is not practical).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You have two options, transmit the data as ASCII (not a good idea IMHO), pre-pending some identifier such that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1:259&#xA;2:0&#xA;3:1019&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or even some other delimiter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;259:0:1019&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I would probably lean towards byte encoding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte0 :0xEA    // just some custom header for yourself&#xA;byte1H:0x01&#xA;byte1L:0x03&#xA;byte2H:0x00&#xA;byte2L:0x00&#xA;byte3H:0x03&#xA;byte3L:0xFB&#xA;byte4 :0xXX    // checksum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could &lt;code&gt;map&lt;/code&gt; the inputs down to a range of &lt;code&gt;0-255&lt;/code&gt; for single byte transmission. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you'll need to work on receiving the data, how you do that is going to depend on how you encode the stream. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;edit:&lt;/strong&gt; I've removed the code sample that was here and replaced it with two working sketches below.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have two XBees, running in AT mode, mine are Series 2, but programatically &lt;em&gt;I THINK&lt;/em&gt; they are the same. If not, you'll have to tweak these, but I'm pretty sure you'll be right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we have are two apps, the first is the &quot;SENDING&quot; app, it takes three arbitrary values, they are: minutes (0-60) the micro has been running, seconds (0-60) the micro has been running, and 100 (it was random, and you can put that back if you want). Also, if you comment out the &lt;code&gt;#define TESTAPP&lt;/code&gt; instead of using these values, it can pull three analog values from &lt;code&gt;A0&lt;/code&gt;-&lt;code&gt;A2&lt;/code&gt; instead. (If you change it in the receiving app, you could have three LEDS on Pulse Width channels and vary the brightness). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* * * * * * * */&#xA;&#xA;XBEE SENDER (131) &#xA;&#xA;#define TESTAPP        // Just serial data based on time&#xA;&#xA;#define PACKETLENGTH   7&#xA;#define LED            13&#xA;&#xA;/* * * * * * * */&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);  &#xA;    Serial.println(&quot;\nSender&quot;);&#xA;    randomSeed(analogRead(0));   &#xA;    pinMode(LED,OUTPUT);&#xA;}&#xA;&#xA;unsigned long m1 = 0;&#xA;unsigned long m2 = 0;&#xA;&#xA;void loop(){&#xA;    m1 = millis()/1000;&#xA;    if(m2 != m1){&#xA;        m2 = m1;&#xA;&#xA;#ifdef TESTAPP        &#xA;        uint8_t  s = m1 % 60;           // how many seconds on millis()&#xA;        m1 /= 60;                       // now we're working with minutes&#xA;        uint8_t  m = m1 % 60;           // how manu minutes on millis()&#xA;        uint8_t  r = 100; //random(256);&#xA;        Serial.print(&quot;x.x&quot;);            // this is just pre-pended data for testing&#xA;        Serial.print('&amp;lt;');  &#xA;        Serial.write(m);  &#xA;        Serial.print('-');  &#xA;        Serial.write(s);  &#xA;        Serial.print('-');  &#xA;        Serial.write(r);  &#xA;        Serial.print(&quot;&amp;gt;  x-x&quot;);        // we want to ignore these chars&#xA;#else&#xA;        Serial.print('&amp;lt;');  &#xA;        Serial.write(map(analogRead(A0),0,1023,0,255));  &#xA;        Serial.print('-');  &#xA;        Serial.write(map(analogRead(A1),0,1023,0,255));  &#xA;        Serial.print('-');  &#xA;        Serial.write(map(analogRead(A2),0,1023,0,255));  &#xA;        Serial.print('&amp;gt;');        &#xA;#endif&#xA;        digitalWrite(LED,!digitalRead(LED));  // toggle the LED everytime we're here&#xA;    }&#xA;    // do other stuff here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll notice garbage characters around the data we are transporting, this is to demonstrate cycling through all serial communications to arrive at the 7 particular characters we need. That's done in the next app, the receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* * * * * * * * */&#xA;&#xA;XBEE RECEIVER (121) &#xA;&#xA;#define TESTAPP  // if you attach 3 LEDS to 9, 10 and 11, the remove this line.&#xA;&#xA;//#define DEBUG  // uncomment this line to see all the data stream coming in&#xA;&#xA;#define PACKETLENGTH  7&#xA;&#xA;/* * * * * * * * */&#xA;&#xA;int LED[3]={9, 10, 11};&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);  &#xA;  Serial.println(&quot;\nReceiver&quot;);&#xA;}&#xA;&#xA;byte  buffer[PACKETLENGTH]; // what holds our serial data&#xA;byte  idx         = 0;      // the index for the buffer character being written&#xA;byte  validBuffer = 0;      // flag to tell us if we're ready to go&#xA;&#xA;void loop(){&#xA;  if(validBuffer){&#xA;      #ifdef TESTAPP&#xA;          // we're just going to print it out in a different format&#xA;          validBuffer=0;&#xA;          #ifdef DEBUG&#xA;              Serial.print('\n');&#xA;          #endif&#xA;          Serial.print(&quot;Data: (&quot;);&#xA;          if (buffer[1]&amp;lt;10) Serial.print(&quot;0&quot;);&#xA;          Serial.print(buffer[1]);&#xA;          Serial.print(&quot;:&quot;);&#xA;          if (buffer[3]&amp;lt;10) Serial.print(&quot;0&quot;);&#xA;          Serial.print(buffer[3]);&#xA;          Serial.print(&quot;) (&quot;);&#xA;          Serial.print(buffer[5]);&#xA;          Serial.println(&quot;)&quot;);&#xA;      #else&#xA;          // this is the more practical side of things&#xA;          // instead of serial.printing, change the brightness &#xA;          // on three attached LEDs via PWM Pins (9, 10, 11)&#xA;          analogWrite(LED[0],buffer[1]); &#xA;          analogWrite(LED[1],buffer[3]);&#xA;          analogWrite(LED[2],buffer[5]);&#xA;      #endif&#xA;      memset(buffer, 0, PACKETLENGTH);  // we've used the data, clear it out&#xA;      idx = 0;                          // and reset the index marker&#xA;  }  &#xA;}&#xA;&#xA;// This is where the real magic is done. We have a buffer of&#xA;// PACKETLENGTH that takes in all Serial data and waits until&#xA;// it finds PACKETLENGTH characters in the format we're after&#xA;// Probably not the best method, but it would be unlikely to&#xA;// stumble across this pattern, although not impossible :) &#xA;// use at your own risk &#xA;&#xA;void serialEvent(){&#xA;    if(validBuffer) return; //we don't want to process new Serial&#xA;                            //until we've processed the buffer&#xA;    buffer[idx] = Serial.read();&#xA;        #ifdef DEBUG&#xA;        Serial.write(buffer[idx]);&#xA;        #endif&#xA;&#xA;    if (++idx==PACKETLENGTH){&#xA;        // we have enough bytes for testing, this next part could be handled better&#xA;        if(  buffer[0]=='&amp;lt;' &amp;amp;&amp;amp; &#xA;             buffer[2]=='-' &amp;amp;&amp;amp;     &#xA;             buffer[4]=='-' &amp;amp;&amp;amp;     &#xA;             buffer[6]=='&amp;gt;' ) { // we have a valid data packet     &#xA;               validBuffer=1;&#xA;        } else {    // we don't have valid data yet, but keep&#xA;                    // what we have, shift it all over one byte and&#xA;                    // we'll check again once the next byte is received&#xA;            memmove(buffer, buffer + 1, PACKETLENGTH-1);&#xA;        }  &#xA;        idx--;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-03-20T11:27:03.943" LastActivityDate="2014-03-20T11:27:03.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="845" PostTypeId="2" ParentId="830" CreationDate="2014-03-20T09:33:58.700" Score="4" Body="&lt;p&gt;I have located the source of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In file wiring.c (arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino) which gets called before setup(), there is the following part that tries to changes the timer 2 prescaller to 64 by setting the &lt;code&gt;CS22&lt;/code&gt; bit.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// set timer 2 prescale factor to 64&#xA;#if defined(TCCR2) &amp;amp;&amp;amp; defined(CS22)&#xA;    sbi(TCCR2, CS22);&#xA;#elif defined(TCCR2B) &amp;amp;&amp;amp; defined(CS22)&#xA;    sbi(TCCR2B, CS22);&#xA;#else&#xA;    #warning Timer 2 not finished (may not be present on this CPU)&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You already set &lt;code&gt;CS20&lt;/code&gt; and  &lt;code&gt;CS22&lt;/code&gt; so this doesn't affect you. What does affect you is the following part which sets bit &lt;code&gt;WGM20&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // configure timer 2 for phase correct pwm (8-bit)&#xA;#if defined(TCCR2) &amp;amp;&amp;amp; defined(WGM20)&#xA;    sbi(TCCR2, WGM20);&#xA;#elif defined(TCCR2A) &amp;amp;&amp;amp; defined(WGM20)&#xA;    sbi(TCCR2A, WGM20);&#xA;#else&#xA;    #warning Timer 2 not finished (may not be present on this CPU)&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you have already set &lt;code&gt;WGM21&lt;/code&gt; so &lt;code&gt;WGM21&lt;/code&gt; and &lt;code&gt;WGM20&lt;/code&gt; set changes the timer mode to fast PWM , top=0xFF which gives almost double delay that the mode you were trying to use (CTC top=124).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to workaround this issue?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer2 is used when its associated PWM pins are used with an &lt;code&gt;analogWrite()&lt;/code&gt; call, so the Arduino setup code sets all prescalers to well-defined values just in case the timers might get used later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would not try to fight that code; instead, I would just make sure that my setup code runs later, e.g. by moving it to a separate &lt;code&gt;setup()&lt;/code&gt; method in your &lt;code&gt;Timer&lt;/code&gt; class and calling that from the global &lt;code&gt;setup()&lt;/code&gt; routine.&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="84" LastEditDate="2014-03-20T19:25:03.440" LastActivityDate="2014-03-20T19:25:03.440" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="847" PostTypeId="1" CreationDate="2014-03-20T11:14:42.673" Score="4" ViewCount="5922" Body="&lt;p&gt;I am a new user of Arduino (I have a Arduino Due) and also I am a new user of BLE112 (Bluegiga module 112)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My teacher told me to make the BLE112 advertisable and furthermore he told me to look for information about UART@115K. (The Ble112 he gave me came with wires already soldered to the selected pins: I'm assuming I only need to use those.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PIN NUMBER [PIN NAME] for BLE112&#xA;&#xA;    2         AVDD                    (Supply voltage 2-3.6V)&#xA;    3         AVDD                    (Supply voltage 2-3.6V)&#xA;    4        [P2_2]  DC- Debug clock  (DIGITAL I/O)&#xA;    5        [P2_1]  DD- Debug data   (DIGITAL I/O)&#xA;    9        VDD_USB                  (Supply voltage 2-3.6V)&#xA;    20        DVDD                    (Supply voltage 2-3.6V)&#xA;    23       [P0_5]  RXD(Rx)          (DIGITAL I/O)&#xA;    24       [P0_4]  TXD(TX)          (DIGITAL I/O)&#xA;    25       [P0_3]  RTS              (DIGITAL I/O)&#xA;    26       [P0_2]  CTS              (DIGITAL I/O)&#xA;    29        RESET&#xA;    30         GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BLE pins [2,3,9,20]    to     3.3v pin of Arduino &#xA;BLE pin  [30]          to     GND pin of Arduino &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I found a picture (attached at the bottom of this post) that describes that I should put CTS of BLE on RTS of Arduino and vice versa. Where is the CTS on an Arduino board? I think I have to program one of the Digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried some other connections. I put:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BLE pin 26(CTS)   to    Arduino random digital pin 32, and &#xA;BLE pin 25(RTS)         Arduino random digital pin 34.&#xA;&#xA;BLE pin 24(TX)          Arduino RX pin 0&#xA;BLE pin 23(RX)          Arduino TX pin 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't connect &lt;code&gt;DC(Debug clock)&lt;/code&gt;, &lt;code&gt;DD(Debug data)&lt;/code&gt; and &lt;code&gt;Reset&lt;/code&gt; on the BLE112.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I found some more info on the web that if I use USART than I should use a wake up pin which is by the default &lt;code&gt;P0_0&lt;/code&gt;(??) more about that in &lt;a href=&quot;https://dl.dropboxusercontent.com/u/65932667/Bluetooth_Smart_Configuration_Guide_v33.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this PDF&lt;/a&gt;. (Search &lt;code&gt;wake_up&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I should mention sleep mode Ble112 (there are three kinds of it) and I believe that the one I am after is MODE 3 (that means that it consumes the minimum (power) of them all) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some example named UART@115K&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UART@115k &#xA;  This example configures the BLE112 or BLE113 Bluetooth Smart module to expose the BGAPI protocol over UART interface with the following settings: 115200 bps, 8n1 and hardware flow control enabled. The power mode 3 is enabled in this example and the wake-up pin is configured to P0_0 pin (P0_0 button on DKBLE112 &#xA;  and DKBLE113). When the power mode 3 is enabled the device will not be able to receive commands or data over UART unless the wake-up pin is asserted.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The example uses UART in the pin configuration channel 1 and alternate 1, which is the configuration used in the DKBLE112 and DKBLE113 development kits. &#xA;  If you try this example with DKBLE112 or DKBLE113 make sure the UART interface is enabled and the device is NOT powered with a CR2032 battery as it’s not able to power up the level shifter or UART to USB converter. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This is also the factory default configuration for BLE112 and BLE113 Bluetooth Smart Modules.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OwjIi.jpg&quot; alt=&quot;Connection shown&quot;&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Source: &lt;a href=&quot;https://bluegiga.zendesk.com/entries/22412436&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bluegiga.zendesk.com/entries/22412436&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="744" LastEditorUserId="220" LastEditDate="2014-03-25T20:27:20.310" LastActivityDate="2015-08-09T09:33:43.243" Title="How do I connect Arduino to a Bluegiga112?" Tags="|pins|arduino-due|bluetooth|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="850" PostTypeId="2" ParentId="825" CreationDate="2014-03-20T17:39:06.713" Score="5" Body="&lt;p&gt;I think &lt;a href=&quot;http://mdiy.pl/uprog-maly-szybki-przenosny-programator-avr-z-sd/?lang=en&quot; rel=&quot;noreferrer&quot;&gt;µProg – tiny, fast, portable AVR programmer with SD&lt;/a&gt; does what you want. You can store multiple files in the SD card (hex, eep etc) and select from the device menu which one to write to the target MCU without any need for a PC.&lt;br /&gt;&#xA;The best part is that it's available for free (PCB, schematic, firmware etc).&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;One of a kind, portable AVR programmer! Helps wherever you need to&#xA;update the device firmware, where target device is in a hard-to-reach&#xA;location and you can’t (or don’t want to) bring your laptop with a&#xA;bunch of wires with you. Trivially easy to use, super cheap to make,&#xA;super small, super fast, uses SD cards…&lt;/p&gt;&#xA;&lt;p&gt;Features:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;super small – dimensions 44 x 39 x 5,5 mm&lt;/li&gt;&#xA;&lt;li&gt;super fast – write up to 12,5kB/s, read up to 14,5kB/s&lt;/li&gt;&#xA;&lt;li&gt;uses cheap storage medium – small MICRO SD cards&lt;/li&gt;&#xA;&lt;li&gt;supports FAT16 and FAT32 file systems&lt;/li&gt;&#xA;&lt;li&gt;can read, write, verify flash and eeprom memory&lt;/li&gt;&#xA;&lt;li&gt;can read, write, verify fusebits and lockbits&lt;/li&gt;&#xA;&lt;li&gt;write and read to BIN, HEX, and TXT files&lt;/li&gt;&#xA;&lt;li&gt;can set default values of fusebits, erase memories&lt;/li&gt;&#xA;&lt;li&gt;cheap, easy to obtain, LPH7779 graphic display&lt;/li&gt;&#xA;&lt;li&gt;shows funny animations after every operation&lt;/li&gt;&#xA;&lt;li&gt;standard programming header – Atmel 6-PIN ISP&lt;/li&gt;&#xA;&lt;li&gt;has a function of auto-update its own firmware (from SD)&lt;/li&gt;&#xA;&lt;li&gt;very simple to use, 4 buttons navigation&lt;/li&gt;&#xA;&lt;li&gt;user-setting menu&lt;/li&gt;&#xA;&lt;li&gt;programming speed auto-selection (up to 4MHz)&lt;/li&gt;&#xA;&lt;li&gt;Operates at 3V, programs chips supplied from 3V to 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Supported chip list&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XZRUr.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-20T17:39:06.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="851" PostTypeId="2" ParentId="725" CreationDate="2014-03-20T18:03:24.497" Score="4" Body="&lt;p&gt;Exactly what is happening and why cannot be determined based on the amount of info provided. However, I see at least one potential problem which would at least partially explain the symptoms described. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You said that you are using diodes to select the voltage supply, and one supply is a 3V battery. If you are using standard diodes that drop ~0.6V then the supply voltage to the MCU is only ~2.4V. If you are using Schottky diodes with a voltage drop between 0.15-0.45, the supply voltage is potentially as low as 2.5V. You have the BOD voltage set to 2.7 volts, so in theory the MCU will never boot with the battery. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why you can start it at 5v, drop to 3v, and bring it back up again- I'm not sure. You could be disabling the BOD in code...maybe… Not sure why it works, but it's likely not guaranteed to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I setup a diode switch circuit with 5v and 3.3v to see what it looks like on my oscilloscope when the voltages switch. When at 3.3v switching up to 5v, the voltage oscillates quite a bit initially. This may potentially cause some problems when the MCU tries to come out of sleep. Putting a cap between VCC and GND smoothed the signal very nicely. When switching from 5v to 3.3v, there really wasn't any oscillating, just a clean drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this information, it seems that you should lower the BOD threshold or turn off the BOD, and put a decoupling cap between VCC and GND. You probably also should make sure you have a pull-down resistor on INT0, and read the MCU datasheet sections explaining the various sleep modes all the considerations for sleeping and waking – it’s pretty involved. Cheers&lt;/p&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2014-03-20T19:20:50.480" LastActivityDate="2014-03-20T19:20:50.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="852" PostTypeId="2" ParentId="725" CreationDate="2014-03-20T18:57:59.170" Score="6" Body="&lt;p&gt;So... turned out what was happening was all in code. Turns out that I was initializing an interrupt on INT0, when it was low, at the very beginning of my code. Problem was that when it started up on 3V backup power, INT0 was always low because INT0 is tied to the 5V line (it's how it knows to go to sleep). Because INT0 was low and the interrupt was triggering on low it was causing a constant interrupt to occur, never giving the rest of the program any time to run. Switched to enabling that interrupt only once I've entered full waking mode and it works fine now.&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-03-20T18:57:59.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="853" PostTypeId="2" ParentId="830" CreationDate="2014-03-20T19:34:40.437" Score="1" Body="&lt;p&gt;As a follow-up up to @alexan_e answer, here is what I finally did to ensure that my Timer2 settings are not overwritten by the &lt;code&gt;init()&lt;/code&gt; method in Arduino &lt;code&gt;wiring.c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BIT(x) (0x01 &amp;lt;&amp;lt; (x))&#xA;&#xA;static volatile uint32_t milliseconds = 0;&#xA;&#xA;class Timer&#xA;{&#xA;    public:&#xA;    // Don't use the constructor anymore&#xA;    void init()&#xA;    {&#xA;        // Disable interrupts&#xA;        uint8_t savedStatus = SREG;&#xA;        cli();&#xA;        // Use Timer2 with 1 ms interrupts&#xA;        // OC2A &amp;amp; OC2B disconnected, mode 2 (CTC, Clear Timer on Compare match)&#xA;        TCCR2A = BIT(WGM21);&#xA;        // Don't force output compare (FOCA &amp;amp; FOCB), mode 2, Clock Select clk/128 (CS = 5)&#xA;        TCCR2B = BIT(CS22) | BIT(CS20);&#xA;        // Set timer counter compare match (when value reached, 1ms has elapsed)&#xA;        OCR2A = 125 - 1;&#xA;        // Reset Timer2 counter&#xA;        TCNT2 = 0;&#xA;        // Set Timer2 interrupt mode (Set interrupt on OCR2A compare match)&#xA;        TIMSK2 = BIT(OCIE2A);&#xA;&#xA;        // Restore interrupt enabling state&#xA;        SREG = savedStatus;&#xA;    }&#xA;};&#xA;&#xA;static void callEveryMillisecond(uint32_t ms)&#xA;{&#xA;    if (ms % 10000 == 0)&#xA;        digitalWrite(13, digitalRead(13) ^ 1);&#xA;}&#xA;&#xA;// Attach interrupt routine to the Timer Compare Interrupt&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;    milliseconds++;&#xA;    callEveryMillisecond(milliseconds);&#xA;}&#xA;&#xA;static Timer timer;&#xA;&#xA;void setup()&#xA;{&#xA;    // Explicit call to Timer initialization; this occurs AFTER &#xA;    // Arduino wiring.c init() has been called&#xA;    timer.init();&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-20T19:34:40.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="854" PostTypeId="1" AcceptedAnswerId="855" CreationDate="2014-03-20T20:17:25.960" Score="7" ViewCount="4671" Body="&lt;p&gt;I would like to be able to use a USB port at the same time as an RS-232 port with my Arduino Uno board. I unwittingly bought a shield that (I think?) overrides the USB port when it is mounted to the Arduino board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/RS232_Shield&quot;&gt;http://www.dfrobot.com/wiki/index.php/RS232_Shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would anyone be able to give me any advice on how to connect the hardware so that I can have two serial ports accessible from my Arduino Uno? The format I was thinking was (Arduino =&gt; RS-232 Sheild):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND =&gt; GND&#xA;5V =&gt; 5V&#xA;Digital Pin 2 =&gt; 232RXD&#xA;Digital Pin 3 =&gt; 232TXD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accompanying code for initializing the serial port which I've written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int rxpin = 2; // pin used to receive&#xA;const int txpin = 3; // pin used to send&#xA;SoftwareSerial Serial_rs232(rxpin, txpin); // new serial port&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas as to why this may or may not be a good method of using the hardware I have available for the purpose I had in mind?&lt;/p&gt;&#xA;" OwnerUserId="755" LastActivityDate="2014-03-20T20:45:08.857" Title="How to use RS-232 sheild as software serial port?" Tags="|arduino-uno|serial|software|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="855" PostTypeId="2" ParentId="854" CreationDate="2014-03-20T20:45:08.857" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;GND =&gt; GND 5V =&gt; 5V Digital Pin 2 =&gt; 232RXD Digital Pin 3 =&gt; 232TXD&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A better choice of board would be the Leonardo, since you could connect such a shield &lt;em&gt;and&lt;/em&gt; use the USB port right out of the box. However, since you have the Uno, there is a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;noreferrer&quot;&gt;Arduino&lt;/a&gt;:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name &quot;SoftwareSerial&quot;). It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It then goes on to reccomend the library &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;noreferrer&quot;&gt;AltSoftSerial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some example code from the link above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;&#xA;AltSoftSerial altSerial;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;AltSoftSerial Test Begin&quot;);&#xA;  altSerial.begin(9600);&#xA;  altSerial.println(&quot;Hello World&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  char c;&#xA;&#xA;  if (Serial.available()) {&#xA;    c = Serial.read();&#xA;    altSerial.print(c);&#xA;  }&#xA;  if (altSerial.available()) {&#xA;    c = altSerial.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It acts like a standard serial port, only you declare the connection as a variable first. This code is written for a board with an additional serial port, like you have.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;All is good, except for one problem:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The problem is the shield is wired to connect to pins 0 and 1: the ones used by the USB adapter. The AltSoftSerial library uses pins 8 for TX and 9 for RX. (Note: You cannot use PWM on pin 10 on the Uno... it should still work as a digital pin.) In that case you would &lt;strong&gt;not attach the shield by plugging it into the Arduino&lt;/strong&gt;, and you would wire it like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;GND =&gt; GND | 5V =&gt; 5V | Digital Pin 8 =&gt; 232RXD pin 0 on the shield headers | Digital Pin 9 =&gt; 232TXD 1 on the shield headers&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So then, you would be manually wiring the shield to the Arduino with jumpers. As long as it doesn't connect to any other Arduino pins I'm not aware of (it shouldn't besides maybe 13 for a LED or something like that), it should function like it would stacked and using pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: (Obviously) You cannot connect anything to the headers on the shield (You cannot connect to pin 5 and get a signal).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-20T20:45:08.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="856" PostTypeId="2" ParentId="791" CreationDate="2014-03-20T21:55:14.047" Score="3" Body="&lt;p&gt;I tried those Tiny cores you are using and had a lot of problems. I switched to &lt;a href=&quot;http://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/arduino-tiny/&lt;/a&gt; and it seems much better. Create a second Arduino installation folder and add the arduino-tiny cores.  The pin name constants are like PIN_A0, PIN_A1,...,PIN_B1, etc. So, try that out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked briefly at the VirtualWire code and there are ifdefs specifically for the Attiny85, so it should work.  Here is a derivative project with working ATTINY85 examples: &lt;a href=&quot;http://cosa-arduino.blogspot.de/2013/03/news-virtual-wire-interface.html&quot; rel=&quot;nofollow&quot;&gt;http://cosa-arduino.blogspot.de/2013/03/news-virtual-wire-interface.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-03-20T21:55:14.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="857" PostTypeId="1" AcceptedAnswerId="858" CreationDate="2014-03-20T22:39:51.870" Score="7" ViewCount="14632" Body="&lt;p&gt;new to arduino I'm struggling with what sounds like fairly n00b problem...&#xA;I've wired up a adafruit GPS-board to my Arduino and it is working as it spits out GPS data to the serial port with &lt;code&gt;Serial.print(GPS.latitude, DEC)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I Now want to concat a string which I can process (read: I want to sent it via an ethernet client.)&#xA;This is what I got already:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;......&#xA;String vnnt = &quot;$VNNT,&quot;;&#xA;&#xA;if (GPS.fix) {&#xA;   vnnt += &quot;GPS,&quot;;&#xA;&#xA;   //this works:&#xA;   vnnt.concat(GPS.fix);&#xA;&#xA;   //but this not:&#xA;   vnnt.concat(GPS.latitude);&#xA;&#xA;}else{&#xA;   vnnt += &quot;INFO,Acquiring Sats&quot;;&#xA;}&#xA;&#xA;Serial.println(vnnt);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error message is: &lt;code&gt;Call of overloaded 'concat(float&amp;amp;)' is ambiguous&lt;/code&gt;&#xA;When I &lt;code&gt;Serial.print(GPS.latitude, DEC)&lt;/code&gt; it results in: &lt;code&gt;4418.5937996050&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is probably to big or something... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I concat the vars and create the long string?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="756" LastEditorUserId="756" LastEditDate="2014-03-20T22:45:58.590" LastActivityDate="2014-03-20T22:59:11.010" Title="How to build (concat) a string with big numbers" Tags="|arduino-uno|programming|software|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="858" PostTypeId="2" ParentId="857" CreationDate="2014-03-20T22:52:25.423" Score="7" Body="&lt;p&gt;The concat function does not implement a float version, but some of char, int, unsigneds...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char String::concat(long unsigned int)&#xA;unsigned char String::concat(unsigned int)&#xA;unsigned char String::concat(int)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so the compiler does not know how to cast (truncating probably the float) to integer, as there are several options. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to convert first your float to string, use dtostrf() or sprintf() then concat to your string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char outstr[25];&#xA;sprintf(outstr, &quot;%f&quot;, GPS.latitude);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dtostrf(GPS.latitude, 6, 2, outstr);  //check docs for 6, 2 values, and set them for your needs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vnnt.concat(outstr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note that sprintf is very handy for compact creation of a (char) string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char msg[80];&#xA;sprintf(msg, &quot;$VNNT,GPS, %s %f&quot;, GPS.fix, GPS.latitude);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="666" LastEditorUserId="666" LastEditDate="2014-03-20T22:59:11.010" LastActivityDate="2014-03-20T22:59:11.010" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="860" PostTypeId="1" AcceptedAnswerId="861" CreationDate="2014-03-21T17:48:44.647" Score="16" ViewCount="60611" Body="&lt;p&gt;I've been looking for a while inside Arduino's files to find the core library. However, I haven't found them yet. &lt;strong&gt;Where on my hard drive can I obtain the core library files (.cpp and .h) necessary for all Arduino code?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking around on Google, I couldn't find a way to find the above files. I did see something about getting an .a file while Arduino is compiling, however, that isn't what I want. I want to browse the code and look at functions such as delay to see how they would react when given the values not expected. (i.e. Will my code stall if I use &lt;code&gt;delay(-200);&lt;/code&gt; by not being to exit the loop, or will it create a black hole and disrupt the space-time continuum?)&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2021-08-28T02:48:13.777" Title="How can I get the source files for Arduino libraries?" Tags="|library|core-libraries|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="861" PostTypeId="2" ParentId="860" CreationDate="2014-03-21T18:00:33.390" Score="10" Body="&lt;p&gt;The base Arduino source files are in the Arduino installation, under &lt;a href=&quot;https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;cores/arduino/&lt;/code&gt;&lt;/a&gt;. Source for additional libraries included are in &lt;a href=&quot;https://github.com/arduino/ArduinoCore-avr/tree/master/libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;libraries/&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="66625" LastEditDate="2020-06-10T16:37:52.737" LastActivityDate="2020-06-10T16:37:52.737" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="862" PostTypeId="2" ParentId="860" CreationDate="2014-03-21T18:53:33.323" Score="9" Body="&lt;p&gt;On a Mac, the path to the source code folder is:&lt;br&gt;&#xA;&lt;code&gt;Arduino.app/Contents/Resources/Java/Hardware/Arduino/Cores/Arduino&lt;/code&gt;. I'd expect it would be the same from &lt;code&gt;/Java/&lt;/code&gt; on down in other OSes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pY7yE.png&quot; alt=&quot;Path to library sources (Arduino-Mac)&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-03-21T18:53:33.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="863" PostTypeId="1" CreationDate="2014-03-21T19:46:40.930" Score="2" ViewCount="961" Body="&lt;p&gt;I am using the arduinconnector ANE to connect to an arduino baord in an AIR application. &lt;a href=&quot;https://code.google.com/p/as3-arduino-connector/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/as3-arduino-connector/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me if its possible to connect to more than 1 board, simply by instantiating additional instances of the ANE and passing in unique port #'s?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there some reason why this isn't possible and a unique AIR application is required for every arduino you connect to?&lt;/p&gt;&#xA;" OwnerUserId="765" LastEditorUserId="11" LastEditDate="2014-04-21T03:58:10.537" LastActivityDate="2014-05-21T05:00:31.620" Title="Connect to more than one Arduino with Adobe AIR" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="864" PostTypeId="1" CreationDate="2014-03-21T20:46:13.690" Score="13" ViewCount="26708" Body="&lt;p&gt;I have an Arduino Mega 2560 and it was working fine until about lunch time when I started getting this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know it isn't the code I'm running as I tried to load it onto an Uno and it seemed to load without issue. I need to use the Mega as it has more ports, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I have read this is potentially an issue with the bootloader and is possibly related to the current version of Arduino. I know virtually nothing about the bootloader; all I know is that it is used to upload code to the Arduino (I think...), therefore I have a fear of just messing around with related files unknowingly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These pages are the ones I've been looking at, but like I said, I don't really know enough to feel comfortable with just messing around with the files.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=135451.0&quot; rel=&quot;noreferrer&quot;&gt;Mega2560: timeout communicating with programmer....&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,83079.msg659993.html#msg659993&quot; rel=&quot;noreferrer&quot;&gt;Upload Timeout Error on Mega 2560 - Not Sure What Changed&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I tried uninstalling my Mega totally, then reinstalling it. I also downloaded an older version of Arduino (0022) and neither option seemed to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what to do, or how to change the 'AVR' files if necessary.&lt;/p&gt;&#xA;" OwnerUserId="454" LastEditorUserId="6936" LastEditDate="2016-02-18T12:17:01.327" LastActivityDate="2019-11-10T06:02:44.347" Title="Arduino Mega timeout communication with programmer error" Tags="|bootloader|arduino-mega|avrdude|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="865" PostTypeId="1" AcceptedAnswerId="868" CreationDate="2014-03-22T01:32:16.627" Score="5" ViewCount="2335" Body="&lt;p&gt;When messing around with code and uploading a sketch to my Arduino board, I almost accidentally pulled out the USB cord. Everything is fine, but then I started thinking what would've happened if I had pulled it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How safe is avrdude? Could it damage or brick the board? I'd imagine that you would just have to upload code to it again... but what would happen before you upload the new code? I've seen something about how you can always upload new code if the bootloader is intact, but I would imagine that there would be some problems. If this were to happen, should I unplug everything connected in case Arduino writes a HIGH to an input (or similar) that would damage the component?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2022-04-24T03:27:44.673" Title="Can I corrupt my Arduino if it's unplugged during an upload?" Tags="|uploading|safety|avrdude|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="866" PostTypeId="2" ParentId="863" CreationDate="2014-03-22T01:48:10.177" Score="2" Body="&lt;p&gt;This seems to be possible with &lt;code&gt;as3Glue&lt;/code&gt; as per the &lt;a href=&quot;https://code.google.com/p/as3glue/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;as3Glue is an ActionScript 3 library that enables communication between Flash/Flex/AIR applications and Arduino boards. &lt;strong&gt;It can together with one or several Arduino boards&lt;/strong&gt; be used to monitor sensors (such as rotary encoders and motion detectors), control actuators (such as LEDs and motors) and interface other electronics (such as RFID readers) from Flash, Flex and AIR applications.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;as3Glue&lt;/code&gt; can be used with &lt;code&gt;as3-arduino-connector&lt;/code&gt; as mentioned in the &lt;a href=&quot;https://code.google.com/p/as3-arduino-connector/&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Using with as3Glue&lt;/p&gt;&#xA;&lt;p&gt;Download either the SWC or Source Code from the Downloads section of this project for a patched version of as3Glue. This patched version has the exact same interfaces as v20, with a notable exception of the constructor. When you instantiate a new &amp;quot;Arduino&amp;quot; object, replace the IP address and port with the COM port and baud rate. For example :&lt;/p&gt;&#xA;&lt;p&gt;public var myArduino:Arduino = new Arduino(&amp;quot;COM10&amp;quot;, 57600);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="65" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-22T01:48:10.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="867" PostTypeId="2" ParentId="865" CreationDate="2014-03-22T03:22:07.477" Score="1" Body="&lt;p&gt;It should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most boards don't require you to reupload the bootloader every time you upload a sketch, so your program will be corrupted but your bootloader won't. I assume the bootloader is similar to the bootloader on other chips I have seen&lt;sup&gt;*&lt;/sup&gt;, it will stop execution if the code doesn't work properly. I would also think that the micro would not accept a transmission if it's checksum is missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't try it if I were you, but you can be a little less cautious about this sort of thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt;: the Propellor chip, among others&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-22T03:22:07.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="868" PostTypeId="2" ParentId="865" CreationDate="2014-03-22T03:28:17.777" Score="7" Body="&lt;p&gt;AVRDUDE does not actually &lt;em&gt;perform&lt;/em&gt; the write, it merely &lt;em&gt;directs&lt;/em&gt; it. The actual writes are performed either by the bootloader or by the ISP firmware/hardware within the MCU itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the bootloader it depends on how itself is coded, but at worst it would finish off the flash byte or page or EEPROM page zero- or one-filled and then fail to communicate further with AVRDUDE, aborting programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With ISP, the page write command would never be received and the programming would be aborted at the last full page. Fuse bytes are done singly and so programming a single fuse can be viewed as an atomic operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case, a chip erase operation should reset the MCU to a known working state, fuse changes excepted.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-22T03:28:17.777" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="869" PostTypeId="2" ParentId="860" CreationDate="2014-03-22T07:19:33.490" Score="13" Body="&lt;p&gt;The code is also available online for those times you don't have the IDE installed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arduino/Arduino&quot;&gt;https://github.com/arduino/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-22T07:19:33.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="870" PostTypeId="1" CreationDate="2014-03-22T10:59:45.887" Score="4" ViewCount="361" Body="&lt;p&gt;I've been browsing Aliexpress and eBay for decent Arduino enclusures, but I've found out they are even pricier then boards themselves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I've realized that there are multiple firms that offer cheap laser cutting - I can buy 1 sq.m acrylic sheet and order cutting multiple parts of boxes at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously I am not the first one who came up with this idea. Has anyone seen downloadable vector layouts I can use as something to start from? Thanks. &lt;/p&gt;&#xA;" OwnerUserId="562" LastEditorUserId="562" LastEditDate="2014-03-22T14:23:42.953" LastActivityDate="2014-04-01T09:03:23.940" Title="Acrylic enclosure for Arduino" Tags="|enclosure|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="871" PostTypeId="1" CreationDate="2014-03-22T15:59:45.930" Score="6" ViewCount="2117" Body="&lt;p&gt;The Arduino boards provide an analog input range of 0V to 5V which translates to 0 to 1023 integer values. The range is determined by the on-board ADC, which in the case of the Uno is a 10 bit ADC (2^10 = 1024). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do any of the official boards have a larger (&gt;10 bits) ADC? Do any boards provide a wider range of analog input values?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2015-08-09T03:31:08.703" Title="Does any board provide more than 1024 analog input values?" Tags="|analogread|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="872" PostTypeId="2" ParentId="871" CreationDate="2014-03-22T16:05:20.307" Score="7" Body="&lt;p&gt;AVR-based Arduinos only have 10-bit ADCs, but the ATSAM3X in the Due has &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogReadResolution&quot;&gt;12-bit ADCs&lt;/a&gt;. Additionally, it is possible to interface to higher-resolution external ADCs via I&lt;sup&gt;2&lt;/sup&gt;C or SPI.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-22T16:05:20.307" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="873" PostTypeId="1" CreationDate="2014-03-22T17:53:52.213" Score="9" ViewCount="7709" Body="&lt;p&gt;Using an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;noreferrer&quot;&gt;Arduino Nano&lt;/a&gt; and a &lt;a href=&quot;http://www.seeedstudio.com/depot/Noninvasive-AC-Current-Sensor-30A-max-p-519.html&quot; rel=&quot;noreferrer&quot;&gt;current transformer &lt;/a&gt; (CT), I'm trying to sense the current flowing through a 120&amp;nbsp;V 60&amp;nbsp;Hz line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Circuit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CT outputs &lt;code&gt;0-1&amp;amp;nbsp;V&lt;/code&gt; according to its specifications. This output is biased &lt;code&gt;AREF/2&lt;/code&gt; = 2.5&amp;nbsp;V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tgpsQ.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;analogRead&lt;/code&gt; Values&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The x-axis represents the index number of the ADC sample, while the y-axis represent the ADC value (0-1024). Sampling rate is about 9&amp;nbsp;kHz. Peak-to-peak difference is about 1026 samples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Gdcc.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this waveform what you would expect from the CT? Why are there regions where the values are flat, rather than varying continuously?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, if we look at the curve part of the plot, why is Arduino reading values both above &lt;code&gt;512&lt;/code&gt; and below &lt;code&gt;512&lt;/code&gt; alternately? It reads a value above &lt;code&gt;512&lt;/code&gt;, then a value below &lt;code&gt;512&lt;/code&gt;, then a value above &lt;code&gt;512&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Time taken for an &lt;code&gt;analogRead&lt;/code&gt; was measured to be 110 microseconds for my setup and there are 1026 samples between the waveform peaks. That means there will be about 9 peaks in 1 second, although I would expect 60 peaks since we are sensing a 60&amp;nbsp;Hz line. What do you make out of this? There's a capacitor, &lt;code&gt;C1&lt;/code&gt;, in the circuit, would it have anything to do with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are these analogRead values suitable to be used to calculate the RMS voltage, and hence the RMS current passing through the wire being sensed? The final goal of this is to calculate the power usage after determining the RMS current flowing through the wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Sketch&quot; rel=&quot;noreferrer&quot;&gt;Sketch&lt;/a&gt; used to get values for plot&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;   double sensorValue = analogRead(1);&#xA;   Serial.println(sensorValue)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Actual &lt;code&gt;analogRead&lt;/code&gt; data points in the bump regions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;487&#xA;534&#xA;487&#xA;535&#xA;488&#xA;537&#xA;484&#xA;536&#xA;487&#xA;538&#xA;486&#xA;536&#xA;484&#xA;540&#xA;484&#xA;539&#xA;485&#xA;540&#xA;483&#xA;540&#xA;484&#xA;541&#xA;481&#xA;539&#xA;481&#xA;540&#xA;484&#xA;540&#xA;480&#xA;543&#xA;484&#xA;539&#xA;481&#xA;540&#xA;484&#xA;541&#xA;486&#xA;542&#xA;485&#xA;538&#xA;485&#xA;538&#xA;488&#xA;535&#xA;489&#xA;534&#xA;491&#xA;530&#xA;491&#xA;529&#xA;493&#xA;531&#xA;492&#xA;526&#xA;498&#xA;526&#xA;499&#xA;524&#xA;499&#xA;520&#xA;503&#xA;518&#xA;502&#xA;518&#xA;507&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Plot of analogRead values&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analogRead values are now stored in a buffer before being transmitted over Serial. There are now 55 ADC datapoints making up 1 period. Considering the analogRead time is 110&amp;nbsp;µs, each cycle takes 6.05&amp;nbsp;ms, giving us a frequency of 165&amp;nbsp;Hz! What may have gone wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wjw7T.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    double sensorValue = analogRead(1);&#xA;    char buf[32];&#xA;&#xA;    dtostrf(sensorValue, 8, 2, buf);&#xA;    value = buf;&#xA;&#xA;    if (stop == 0) {&#xA;        if (i &amp;lt; 10000) {&#xA;            message += ',';&#xA;            message += value;&#xA;            i++;&#xA;        }&#xA;        else {&#xA;            stop = 1;&#xA;            Serial.println(message);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="639" LastEditorUserId="510" LastEditDate="2014-04-14T12:58:18.287" LastActivityDate="2017-12-20T21:57:36.287" Title="Reading a varying voltage into Arduino" Tags="|programming|sensors|power|voltage-level|arduino-nano|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="874" PostTypeId="1" CreationDate="2014-03-22T19:50:02.973" Score="7" ViewCount="7153" Body="&lt;p&gt;I have a relatively cheap 0-15psi pressure transducer. It has 3 pins - ground 5V and signal. The signal outputs a voltage of 0.5V to 4.5V based on pressure from 0psi to 15psi. I can verify it does respond to significant pressure increases so it works at least to a point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that the reading from arduino can differ by over 50% when at ambient atmospheric pressure (resting on a table). It should be significantly more accurate if the sensor data are to be trusted. The code is basic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void measurePressure(){&#xA;  int rawReading = analogRead(A0);   // Range : 0..1024&#xA;  //float rawVoltage = (rawReading * (4.5 / 1023.0)) + 0.5;&#xA;&#xA;  Serial.print(&quot;Raw reading: &quot;);&#xA;  Serial.println(rawReading);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  measurePressure();&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output variations are not entirely random, it seems that the reading goes down and up in intervals of roughly 5-15 seconds. Below is a sample output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Raw reading: 61&#xA;Raw reading: 67&#xA;Raw reading: 70&#xA;Raw reading: 73&#xA;Raw reading: 74&#xA;Raw reading: 78&#xA;Raw reading: 75&#xA;Raw reading: 82&#xA;Raw reading: 85&#xA;Raw reading: 90&#xA;Raw reading: 89&#xA;Raw reading: 97&#xA;Raw reading: 103&#xA;Raw reading: 119&#xA;Raw reading: 146&#xA;Raw reading: 165&#xA;Raw reading: 171&#xA;Raw reading: 168&#xA;Raw reading: 163&#xA;Raw reading: 150&#xA;Raw reading: 143&#xA;Raw reading: 118&#xA;Raw reading: 88&#xA;Raw reading: 70&#xA;Raw reading: 62&#xA;Raw reading: 64&#xA;Raw reading: 72&#xA;Raw reading: 78&#xA;Raw reading: 80&#xA;Raw reading: 82&#xA;Raw reading: 88&#xA;Raw reading: 92&#xA;Raw reading: 102&#xA;Raw reading: 134&#xA;Raw reading: 160&#xA;Raw reading: 170&#xA;Raw reading: 172&#xA;Raw reading: 166&#xA;Raw reading: 158&#xA;Raw reading: 149&#xA;Raw reading: 132&#xA;Raw reading: 100&#xA;Raw reading: 73&#xA;Raw reading: 63&#xA;Raw reading: 61&#xA;Raw reading: 71&#xA;Raw reading: 77&#xA;Raw reading: 79&#xA;Raw reading: 84&#xA;Raw reading: 90&#xA;Raw reading: 90&#xA;Raw reading: 99&#xA;Raw reading: 134&#xA;Raw reading: 161&#xA;Raw reading: 170&#xA;Raw reading: 166&#xA;Raw reading: 161&#xA;Raw reading: 151&#xA;Raw reading: 133&#xA;Raw reading: 103&#xA;Raw reading: 81&#xA;Raw reading: 68&#xA;Raw reading: 63&#xA;Raw reading: 63&#xA;Raw reading: 71&#xA;Raw reading: 73&#xA;Raw reading: 81&#xA;Raw reading: 83&#xA;Raw reading: 85&#xA;Raw reading: 89&#xA;Raw reading: 98&#xA;Raw reading: 128&#xA;Raw reading: 161&#xA;Raw reading: 171&#xA;Raw reading: 166&#xA;Raw reading: 159&#xA;Raw reading: 145&#xA;Raw reading: 120&#xA;Raw reading: 85&#xA;Raw reading: 67&#xA;Raw reading: 57&#xA;Raw reading: 63&#xA;Raw reading: 72&#xA;Raw reading: 75&#xA;Raw reading: 83&#xA;Raw reading: 85&#xA;Raw reading: 89&#xA;Raw reading: 97&#xA;Raw reading: 130&#xA;Raw reading: 164&#xA;Raw reading: 172&#xA;Raw reading: 163&#xA;Raw reading: 155&#xA;Raw reading: 135&#xA;Raw reading: 101&#xA;Raw reading: 69&#xA;Raw reading: 60&#xA;Raw reading: 62&#xA;Raw reading: 72&#xA;Raw reading: 78&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried adding 4.7k pull down resistor with no change but that was just a blind try. I have a multimeter connected as well and the reading seems to be more stable ranging from about 0.495V to 0.535V (variations do not seem to match arduino output).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing the issue?&lt;/p&gt;&#xA;" OwnerUserId="633" LastEditorUserId="65" LastEditDate="2014-03-23T12:43:29.950" LastActivityDate="2014-04-09T01:16:33.127" Title="Pressure transducer / sensor (0.5 - 4.5V) innacurate analog pin readings" Tags="|sensors|arduino-pro-micro|" AnswerCount="1" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="875" PostTypeId="2" ParentId="865" CreationDate="2014-03-22T23:10:32.617" Score="2" Body="&lt;p&gt;One safety feature that hasn't been mentioned so far is that the ATmega328 has a set of lock bits that prevent read/write access to certain areas. To the best of my knowledge, the way Arduinos are set up, those bits are always set to prevent writing to the boot loader area unless the &quot;Burn Bootloader&quot; command is currently active, and since you can only use that command with an external programmer, you can always write a new bootloader if something goes wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the only way of bricking the board (in the sense of leaving the MCU in a state that is functional, yet almost irrepairably unresponsive) is writing bad fuse settings. &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-22T23:10:32.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="876" PostTypeId="1" CreationDate="2014-03-23T03:14:19.210" Score="25" ViewCount="5816" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hYRnU.png&quot; width=&quot;450&quot; height=&quot;200&quot; &gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;sub&gt;The logo is a derivative of the &lt;a href=&quot;http://arduino.cc/en/Trademark/HomePage?from=Main.Trademark&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Community Logo&lt;/a&gt; licensed under &lt;a href=&quot;http://creativecommons.org/licenses/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Creative Commons license CC-SA-BY-NC 3.0&lt;/a&gt;&lt;/sub&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;Update: Winners Announced&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The winners of the contest have been announced. Please see the &lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/184/project-showcase-14-winners&quot;&gt;Meta post for details&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To celebrate &lt;a href=&quot;http://day.arduino.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;10 years of Arduino&lt;/a&gt;, we are proud to announce the &lt;em&gt;first event ever&lt;/em&gt; on Arduino Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Get your boards and soldering equipment out, dig out the ICs and&#xA;  resistors. The first Arduino Stack Exchange contest is just round the&#xA;  corner. We will be looking for interesting projects that are built&#xA;  using Arduinos. The contest is aimed towards sharing, discussing and&#xA;  providing feedback on projects that you and other members are working&#xA;  on. &lt;sub&gt;&lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/153/project-showcase-14-is-coming-to-arduino-stack-exchange-updated-3-19-14&quot;&gt;See announcement post&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;Details:&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The prize is an official &lt;strong&gt;Stack Exchange t-shirt&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Limit two entries per person. If more than two are provided, only the first two will be considered. &lt;/li&gt;&#xA;&lt;li&gt;Clones &lt;em&gt;are&lt;/em&gt; allowed.&lt;/li&gt;&#xA;&lt;li&gt;Projects for consideration will be accepted through &lt;strong&gt;March 29th, 2014 at 4:00 UTC.&lt;/strong&gt; The question will still remain open in case someone wants to show off their project they made on Arduino Day 2014.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Visit the &lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/171/project-showcase-14-detailed-information&quot;&gt;Meta post&lt;/a&gt; for discussion about this event and further information.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Answer Format&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You may post up to two projects (as two separate answers) as entries for the contest. All extra entries will be deleted. Consider following the following template for entries:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h1&gt;Project Title&lt;/h1&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Very Brief Description&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;h1&gt;Description&lt;/h1&gt;&#xA;  &#xA;  &lt;p&gt;What is your project? What does it do? What problem does it solve?&lt;/p&gt;&#xA;  &#xA;  &lt;h1&gt;Design&lt;/h1&gt;&#xA;  &#xA;  &lt;p&gt;Things to include in this section:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Schematics and other design documentation. &lt;a href=&quot;http://fritzing.org/home/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fritzing&lt;/a&gt; is a good tool for drawing breadboard schematics like the one shown in the&#xA;  project logo above.&lt;/li&gt;&#xA;  &lt;li&gt;Components used to build the project&lt;/li&gt;&#xA;  &lt;li&gt;Pictures or video&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;  &#xA;  &lt;p&gt;Final thoughts. What did you learn from doing this project? What would&#xA;  you do differently if you had to start over?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can copy/paste the following text if you want to use this template.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Project Title&#xA;**Very Brief Description**&#xA;&#xA;# Description&#xA;What is your project? What does it do? What problem does it solve?&#xA;&#xA;# Design&#xA;Things to include in this section:&#xA;&#xA;- Schematics and other design documentation. [Fritzing][8] is a good tool for drawing breadboard schematics like the one shown in the project logo above.&#xA;- Components used to build the project&#xA;- Pictures or video&#xA;&#xA;# Conclusion&#xA;Final thoughts. What did you learn from doing this project? What would you do differently if you had to start over?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Prizes&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;There are two prizes! The winner will be the submission getting the maximum number of upvotes (downvotes do not count) and will get a Stack Exchange T-shirt*! There will be something for the runner-up as well. The runner-up will be decided at the discretion of the event organizers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*Certain restrictions may apply. International shipping may take a few weeks. &lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Where do I submit my projects?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Post your projects as answers to this post.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="-1" LastEditDate="2017-03-16T15:52:43.687" LastActivityDate="2014-11-28T19:13:18.967" Title="Project Showcase '14" Tags="|events|" AnswerCount="14" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="877" PostTypeId="1" AcceptedAnswerId="878" CreationDate="2014-03-23T03:19:02.423" Score="2" ViewCount="895" Body="&lt;p&gt;I'm doing my first electronics project where a signal that varies between -1 to 1 V is going into an analog pin on the Arduino. The amplified signal has to be read as fast as possible by Arduino. The source signal is at 60 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will &lt;a href=&quot;http://www.digikey.com/product-detail/en/LM324N/296-1391-5-ND/277627&quot; rel=&quot;nofollow&quot;&gt;this LM324&lt;/a&gt; be a suitable 4-channel opamp for my needs? How concerned should I be about the 2 mV input offset and 20 nA input current bias?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make full use of the 10bit ADC, would you recommend using an opamp with gain of 2 and biasing the signal by +2.5V? If so, will it be better to create the bias using a potential divider across +5V and GND, or using a 2.5V voltage regulator?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or would it be better to set AREF to 2V and bias the signal by +1V? In this case, will it be better to use a 2V voltage regulator, or a voltage divider across Arduino's 3V3 and GND using 20M and 33M resistors? &lt;/p&gt;&#xA;" OwnerUserId="774" LastEditorUserId="774" LastEditDate="2014-03-23T16:38:03.013" LastActivityDate="2014-03-24T03:57:52.537" Title="Opamp for amplifying 1V signal voltage to 2V" Tags="|pins|sensors|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="878" PostTypeId="2" ParentId="877" CreationDate="2014-03-23T03:26:38.100" Score="2" Body="&lt;p&gt;A 2mV offset voltage will become a 4mV error after amplification. You haven't shown the schematic for your amplification, but the current bias will also become error after amplification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;That&lt;/em&gt; LM324 variant is surface mount, but there are other LM324 variants in a DIP package, which will work fine in a breadboard.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-23T03:26:38.100" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="879" PostTypeId="2" ParentId="876" CreationDate="2014-03-23T05:04:51.437" Score="5" Body="&lt;h1&gt;ShiftLCD&lt;/h1&gt;&#xA;&lt;p&gt;&lt;strong&gt;AVR based, Arduino compatible, board that mounts to the back of an 8x1 up to 20x4 Character LCD Screen.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&lt;p&gt;I just designed this board and the custom library to make it easier to use and LCD. Though they are pretty easy to use at the moment. It cuts down the number of output pins used from 6 to 3. It also has the option to expand the I/O by adding more shift registers on to the one that drives the display. The processor used is an ATTiny45 or ATTiny85 which has, after using the shift register, digital pins 1 (PWM) and 4 available and analog pin 2 (same pin as digital pin 4) available.&lt;/p&gt;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://oshpark.com/shared_projects/LKBJyhOP&quot; rel=&quot;nofollow noreferrer&quot;&gt;OSH Park permalink which has parts listed&lt;/a&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/jamolnng/Arduino/tree/master/libraries/ShiftLCD&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3nETo.png&quot; alt=&quot;Schematic&quot; /&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/aXSfc.png&quot; alt=&quot;OSH Park render&quot; /&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/DqIuw.jpg&quot; alt=&quot;Unsoldered Board&quot; /&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Challenges&lt;/h1&gt;&#xA;&lt;p&gt;One unforeseen challenge I faced was when I started I was using digital pins 0-2 to run the shift register, these also happened to be the programming pins (MISO, MOSI, SCK). So every time I reprogrammed the device the LCD would get sent a whole bunch of gibberish messages where the power would have to be turned off in order to reset the display. I solved this problem by moving the shift registers latch pin to digital pin 3 which is not a programming pin. Solving this also solved another problem for me because when I moved the latch pin it opened up digital pin 1 which had PWM usage, allowing for more things to be done with the board.&lt;/p&gt;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&lt;p&gt;Granted this may not be the coolest product or idea, it still has its uses. The answer the question directly, &amp;quot;What did you learn from doing this project&amp;quot; I learned how to design from start to finish a PCB board. If I could do anything differently it would have been to use surface mount parts instead of through hole, then again it is just a prototype, one-off board.&lt;/p&gt;&#xA;" OwnerUserId="10" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-23T16:19:55.237" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="880" PostTypeId="2" ParentId="876" CreationDate="2014-03-23T07:41:06.620" Score="11" Body="&lt;h1&gt;Energy saver for the absent-minded PC user&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This device switches on/off my desk lights when it is dark(ish) and in sync with my PC screensaver.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The project is little more than an combination of a light sensitive sensor, a relay and some smart code that monitors the screensaver on my PC. When it is dusk and when screen saver is not active, it switches on the lights over my desk. When I subsequently leave my desk the screensaver will activate, which will in turn trigger the desk light to be turned off. When there is enough light during day time, the lights are not switched on at all. The problem solved is to reduce the waste of energy due to the lighting in my office being switched on when I have left the room.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Because the power of microcontrollers / Arduino only a little extra hardware is required to create a useful project. The same goes for this project where the hardware is little more than:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An Arduino&lt;/li&gt;&#xA;&lt;li&gt;A couple of screw shields to connect the external components&lt;/li&gt;&#xA;&lt;li&gt;An &lt;a href=&quot;https://en.wikipedia.org/wiki/Photoresistor&quot; rel=&quot;nofollow noreferrer&quot;&gt;LDR&lt;/a&gt; in series with a resistor to measure ambient light&lt;/li&gt;&#xA;&lt;li&gt;A relay card to switch on and off the mains powered lights&lt;/li&gt;&#xA;&lt;li&gt;A 10&amp;nbsp;μF capacitor from GND to RST to prevent the board from being reset and accidentally being programmed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cQlSi.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fcQlSi.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I learned how to interface the PC over the USB serial link with Arduino and how to read current state of the screensaver on my PC. If I would start over, I'd use a much smaller controller as I really only need a single digital output and a single analog input. Probably base the project on &lt;a href=&quot;http://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;V-USB&lt;/a&gt;. Arduino however is excellent for the quick and easy proof of concept (PoC). (The PoC has been on my desk for at least two years already).&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="510" LastEditDate="2014-04-08T18:45:31.453" LastActivityDate="2014-04-08T18:45:31.453" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="881" PostTypeId="2" ParentId="877" CreationDate="2014-03-23T10:52:46.530" Score="1" Body="&lt;p&gt;Just an alternate idea I saw: If you dont need high accuracy, you can use a voltage divider to bias -1 to +1 into 0 to 1, and set the analog reference to 1.2, and get almost the same result but skip the op amp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A voltage divider with 2 equal resistors will give you the voltage halfway between its two inputs. If the bottom of the voltage divider is at 1v, and the top input is at -1, you get 0 out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the bottom is at +1, you get 1 out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw a really clever design using 2 1 megaohm resistors, and actually using the aref pin as an output to provide the bias for the divider, setting the reference to the 1.2v setting, putting the signal in the top of the divider and ground and connecting the adc to the output of the divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aref wasnt meant as a current source, but they use 1meg resistors so the current draw will be at most a few microamps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A filter cap on aref probably draws more than that if vcc is noisy(if there wasnt current to filter we wouldnt need the cap!) So a few uA should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They put a 1nf capacitor betcan the input and ground to fix the issues with the ADC input current causing voltage drop. It worked up to 100hz. They never tested accuracy because it wasnt needed though. I'd guess that the adc internal reference was the major error source, probably a few percent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also actually bias with a voltage divider to the 5V supply, and get a 0 to ~1.6V output, it's just a little harder to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This simulation explains the concept(5v version)&#xA;&lt;a href=&quot;http://www.falstad.com/circuit/#%24+1+5.0E-6+81.92041607667615+50+5.0+50%0Ar+304+160+304+224+0+1000.0%0Ar+304+224+304+304+0+5000.0%0AR+304+304+256+304+0+0+40.0+5.0+0.0+0.0+0.5%0AR+304+160+208+160+0+1+40.0+1.0+0.0+0.0+0.5%0Aw+304+224+400+224+0%0Ax+368+208+456+214+0+24+To+ADC%0Ao+3+64+0+35+2.5+0.00625+0+-1%0Ao+4+64+0+35+2.5+9.765625E-5+1+-1%0A&quot; rel=&quot;nofollow&quot;&gt;http://www.falstad.com/circuit/#%24+1+5.0E-6+81.92041607667615+50+5.0+50%0Ar+304+160+304+224+0+1000.0%0Ar+304+224+304+304+0+5000.0%0AR+304+304+256+304+0+0+40.0+5.0+0.0+0.0+0.5%0AR+304+160+208+160+0+1+40.0+1.0+0.0+0.0+0.5%0Aw+304+224+400+224+0%0Ax+368+208+456+214+0+24+To+ADC%0Ao+3+64+0+35+2.5+0.00625+0+-1%0Ao+4+64+0+35+2.5+9.765625E-5+1+-1%0A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Left click the output, use view in scope.&lt;/p&gt;&#xA;" OwnerUserId="168" LastEditorUserId="168" LastEditDate="2014-03-24T03:57:52.537" LastActivityDate="2014-03-24T03:57:52.537" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="882" PostTypeId="2" ParentId="873" CreationDate="2014-03-23T12:11:25.067" Score="5" Body="&lt;p&gt;Regarding your measurements, I would completely disregard the first set with Serial.println() in the loop. I would exepect the timing of this to be unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second set of data that you captured in a buffer looks correct, but your Frequency Estimation / timing may be wrong. I would invert a Digital Output at each loop iteration. You can measure the frequency of that with a Multimeter and your ADC sample rate would be twice that value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a PC or laptop power supply that's quite a common current waveform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without effective Power Factor Correction the current signal shown below would be quite typical (source: &lt;a href=&quot;http://www.nlvocables.com/blog/?p=300&quot; rel=&quot;noreferrer&quot;&gt;http://www.nlvocables.com/blog/?p=300&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oAAF2.gif&quot; alt=&quot;http://www.nlvocables.com/blog/?p=300&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to calculate RMS values and it would be wise to filter the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Yun-based-Electricity-Monitor-with-Cloud-Support-T/&quot; rel=&quot;noreferrer&quot;&gt;Here's an instructable&lt;/a&gt; I wrote on how to build and code an Arduino Yun based Electricity Monitor with Cloud Support / Temboo and Google Drive. It should be of some help to you.&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-03-23T12:11:25.067" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="883" PostTypeId="1" AcceptedAnswerId="884" CreationDate="2014-03-23T15:41:51.263" Score="5" ViewCount="2123" Body="&lt;p&gt;I am using an HC-SRO4 ultrasonic sensor for a wall-avoidance, maze-solving robot. However, I have recently run into an issue where I am getting a whirring noise from the sensor because it is taking measurements way too often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code I have right now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int serialPeriod = 250;       // only print to the serial console every 1/4 second&#xA;unsigned long timeSerialDelay = 0;&#xA;&#xA;const int loopPeriod = 20;          // a period of 20ms = a frequency of 50Hz&#xA;unsigned long timeLoopDelay   = 0;&#xA;&#xA;// specify the trig &amp;amp; echo pins used for the ultrasonic sensors&#xA;const int ultrasonic2TrigPin = 8;&#xA;const int ultrasonic2EchoPin = 9;&#xA;&#xA;int ultrasonic2Distance;&#xA;int ultrasonic2Duration;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;&#xA;    // ultrasonic sensor pin configurations&#xA;    pinMode(ultrasonic2TrigPin, OUTPUT);&#xA;    pinMode(ultrasonic2EchoPin, INPUT);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    debugOutput(); // prints debugging messages to the serial console&#xA;&#xA;    if(millis() - timeLoopDelay &amp;gt;= loopPeriod)&#xA;    {&#xA;        readUltrasonicSensors(); // read and store the measured distances&#xA;&#xA;        timeLoopDelay = millis();&#xA;    }&#xA;}&#xA;&#xA;&#xA;void readUltrasonicSensors()&#xA;{&#xA;    // ultrasonic 2&#xA;    digitalWrite(ultrasonic2TrigPin, HIGH);&#xA;    delayMicroseconds(10);                  // must keep the trig pin high for at least 10us&#xA;    digitalWrite(ultrasonic2TrigPin, LOW);&#xA;&#xA;    ultrasonic2Duration = pulseIn(ultrasonic2EchoPin, HIGH);&#xA;    ultrasonic2Distance = (ultrasonic2Duration/2)/29;&#xA;}&#xA;&#xA;&#xA;&#xA;void debugOutput()&#xA;{&#xA;    Serial.print(&quot;timeSerialDelay: &quot;);&#xA;    Serial.print(timeSerialDelay);&#xA;    Serial.println();&#xA;&#xA;    if((millis() - timeSerialDelay) &amp;gt; serialPeriod)&#xA;    {&#xA;        Serial.print(&quot;ultrasonic2Distance: &quot;);&#xA;        Serial.print(ultrasonic2Distance);&#xA;        Serial.print(&quot;cm: &quot;);&#xA;        Serial.println();&#xA;&#xA;        timeSerialDelay = millis();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my wiring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yzG9F.jpg&quot; alt=&quot;breadboard wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.foxytronics.com/products/181-4-pin-female-to-female-cable&quot; rel=&quot;noreferrer&quot;&gt;Link to product&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why the scanning is happening constantly? It should only be happening every 1/4 of a second, not constantly. The weird thing is that this wasn't happening earlier before I started using the cable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe it has something to do with the 8.5&quot; extension cable I have (needed because I can't mount three sensors, one facing to each side and one in front, on a single breadboard). This is because when I mounted the sensor directly onto the breadboard, the delay was correct and the whirring was not present. However, as I just mentioned, I &lt;em&gt;need&lt;/em&gt; the extension cable to be able to have the three sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have a solution for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="333" LastActivityDate="2014-03-23T15:55:02.290" Title="Ultrasonic Sensor scanning too often resulting in a whirring noise" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="884" PostTypeId="2" ParentId="883" CreationDate="2014-03-23T15:55:02.290" Score="3" Body="&lt;p&gt;If you want to sample at 4Hz (4 times per second), you need to change your headers accordingly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int serialPeriod = 250;       // only print to the serial console every 1/4 second&#xA;unsigned long timeSerialDelay = 0;&#xA;&#xA;const int loopPeriod = 250;          // a period of 250ms = a frequency of 4Hz&#xA;unsigned long timeLoopDelay   = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-23T15:55:02.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="885" PostTypeId="1" CreationDate="2014-03-24T00:18:30.070" Score="8" ViewCount="471" Body="&lt;p&gt;I currently do most of my AVR work on breadboards, but the large variety of Arduino shields and code out there makes me wonder if I'm not beating my head against the wall sometimes, and looking up port to pin mappings both wastes time and slows me down. Is there any convenient way to adapt AVRs (&lt;em&gt;other&lt;/em&gt; than those pin-compatible with current Arduinos) to Arduino shields?&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorDisplayName="user278" LastEditDate="2014-03-24T16:42:25.623" LastActivityDate="2014-03-24T16:42:25.623" Title="Is there a way to make wiring a bare microprocessor to a shield easier?" Tags="|shields|avr|hardware|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="886" PostTypeId="1" CreationDate="2014-03-24T01:27:06.783" Score="5" ViewCount="2253" Body="&lt;p&gt;I am sending three signals from one Arduino mega to another using xbees. On the receiving end I am using these signals in a Simulink code to control servo motors. Currently it is set up to read from analog pins without the wireless set up. With the wireless technology the signals are all being sent and received through one serial port. I believe I would need to change the inputs in Simulink to a serial receive block instead of an analog pin block. The problem is the documentation for the serial receive block says you can not assign more than one serial receive block to the same serial port. If anyone has a solution to this it would be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;receiving code&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int received1; &#xA;int received2;  &#xA;int received3;  &#xA;void setup() {  &#xA;  Serial.begin(9600);  &#xA;}  &#xA;void loop() {  &#xA;  if(Serial.available() )  &#xA;  {  &#xA;    received1, received2, received3 = Serial.read();  &#xA;  }  &#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;transmitting code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorValue1 = analogRead(A0);&#xA;  int sensorValue2 = analogRead(A1);&#xA;  int sensorValue3 = analogRead(A2);&#xA;  Serial.write(sensorValue1, sensorValue2, sensorValue3);&#xA;  delay(1);       &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="734" LastEditorUserId="19409" LastEditDate="2021-06-07T14:52:33.263" LastActivityDate="2023-06-27T20:03:20.440" Title="Reading three signals sent serially on Simulink from Arduino" Tags="|serial|arduino-mega|xbee|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="887" PostTypeId="2" ParentId="876" CreationDate="2014-03-24T03:17:43.857" Score="7" Body="&lt;h1&gt;(fake) Linux on Arduino&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I recently acquired a small composite LCD screen, which I quickly began playing with using the Arduino TVout library. What came next? Linux!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Description&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While playing around with my TV screen and the TVout library, I discovered there is a premade terminal handler for the TV. I soon began to experiment with using it as a TV terminal hooked up to a PS/2 keyboard. There were some problems with the PS/2 library I used, so I transitioned it to use the USB library on my Mega ADK along with a USB keyboard. That worked much better. Now for storage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My SD card shield isn't compatible with my Mega, so I wired it up somewhat haphazardly to the SPI at the end of the board. I wrote command handling to preform a few tasks like listing files and finding disk size, free space, etc.. The entire assembly isn't by any means finished, but I am happy with the progress I have made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code will be relocated to Github eventually, watch the comments.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Design&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cgzPU.jpg&quot; alt=&quot;zoomed out pic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L9PmB.jpg&quot; alt=&quot;clse up screen&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Challenges&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I had a lot of trouble concatenating the inputted charactars to the string storing the current command because I wasn't casting right. Once I got that figured out, I also needed to fix the problem where some keys printed random garbage to the screen. This was caused by reading memory before the letter definitions, so a few &lt;code&gt;if&lt;/code&gt;s cleared that up.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am very satisfied with the code. Once I add a few more utilities to it, I will put it on Github, so watch the comments. Overall, it was a very fun project. I learned how to use Stino in the process.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-03-24T23:17:09.403" LastActivityDate="2014-03-24T23:17:09.403" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="888" PostTypeId="2" ParentId="871" CreationDate="2014-03-24T04:19:36.053" Score="5" Body="&lt;p&gt;How much accuracy do you really need? If it's just 1 or 2 extra bits of resolution you are after, you might be able to achieve that with a bit of oversampling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you take a ton of readings and average them. It only works if there is at least a few mV of random noise in your signal or in your ADC, and if your input signal bandwidth is low enough to be averaging samples together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, go with a dedicated ADC chip.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-03-24T04:19:36.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="889" PostTypeId="2" ParentId="885" CreationDate="2014-03-24T06:29:52.423" Score="2" Body="&lt;p&gt;The Arduino-way of doing that is making a lookup table that translates pin number to PORTn / DDRn / PINn SFR and the related bit. You can use the same trick and make GPIO pins count in a convenient way as they are in the package. Only special peripherals (like SPI / PWM) cannot be accounted for in this way because they are hard wired to a pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good start is the below &lt;code&gt;Arduino.h&lt;/code&gt; library sniplet if you want to re-use that concept.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Get the bit location within the hardware port of the given virtual pin.&#xA;// This comes from the pins_*.c file for the active board configuration.&#xA;&#xA;#define analogInPinToBit(P) (P)&#xA;&#xA;// On the ATmega1280, the addresses of some of the port registers are&#xA;// greater than 255, so we can't store them in uint8_t's.&#xA;extern const uint16_t PROGMEM port_to_mode_PGM[];&#xA;extern const uint16_t PROGMEM port_to_input_PGM[];&#xA;extern const uint16_t PROGMEM port_to_output_PGM[];&#xA;&#xA;extern const uint8_t PROGMEM digital_pin_to_port_PGM[];&#xA;// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];&#xA;extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];&#xA;extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];&#xA;&#xA;// Get the bit location within the hardware port of the given virtual pin.&#xA;// This comes from the pins_*.c file for the active board configuration.&#xA;// &#xA;// These perform slightly better as macros compared to inline functions&#xA;//&#xA;#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )&#xA;#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )&#xA;#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )&#xA;#define analogInPinToBit(P) (P)&#xA;#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )&#xA;#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )&#xA;#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;pinMode&lt;/code&gt;, &lt;code&gt;digitalWrite&lt;/code&gt; and &lt;code&gt;digitalRead&lt;/code&gt; functions are defined in &lt;code&gt;/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c&lt;/code&gt; which can be used for further inspiration.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-03-24T06:39:06.630" LastActivityDate="2014-03-24T06:39:06.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="890" PostTypeId="1" CreationDate="2014-03-24T06:46:25.323" Score="2" ViewCount="1000" Body="&lt;p&gt;I have a servo motor with following specs&#xA;Torque - 1.08Nm&#xA;Max rpm - 3000&#xA;Current rating - 7.8 amp&#xA;Max voltage - 56V DC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell me how to calculate whether an arduino board - uno rev 3 can control the servo motor? If not, how to find out how many such boards are required?&lt;/p&gt;&#xA;" OwnerUserId="785" LastActivityDate="2014-03-24T20:34:22.283" Title="How to find out whether an arduino can control a servo motor" Tags="|arduino-uno|motor|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="892" PostTypeId="2" ParentId="876" CreationDate="2014-03-24T09:37:35.727" Score="7" Body="&lt;h1&gt;Sonic Ray Gun&lt;/h1&gt;&#xA;&lt;p&gt;&lt;strong&gt;Two projects by kids&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm working with a couple of home educated kids and we are having a lot of fun with an arduino. Their first project was a fake-bomb, like you see in the movies, with a LCD countdown timer and a classic &amp;quot;do you cut the red or blue wire?&amp;quot; type problem.&lt;/p&gt;&#xA;&lt;p&gt;Project two started with showing them the toneMelody example and a small speaker. The quickly found out that if you turn the frequency up to 15kHz it was rather annoying to teenagers. An hour later they had improved the design with a cup, toilet roll and a switch made from a paperclip making a directional sonic ray gun.&lt;/p&gt;&#xA;&lt;p&gt;Sadly no pictures.&lt;/p&gt;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&lt;p&gt;Don't leave kids unattended with an arduino.&lt;/p&gt;&#xA;" OwnerUserId="679" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-24T09:37:35.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="893" PostTypeId="1" AcceptedAnswerId="894" CreationDate="2014-03-24T10:22:29.783" Score="52" ViewCount="68083" Body="&lt;p&gt;I am a new Arduino user. I am not sure whether I can connect both USB and external supply through power adaptor to Arduino simultaneously. Would this burn the controller?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to automatically shut down the computer after saving all open documents before my UPS battery goes out whenever I am not there to manually shut it down. I am trying to notify the computer about the power failures of main supply - AC 220V 50 Hz (notification/signal sent when power goes out) via USB using Arduino. I am thinking that this can be done by using the external voltage power supply pin. Whenever power goes out in the mains, the external voltage power supply pin will drop to 0 V from 7 V. The value of the voltage can be read using software ( I am unclear about this: Can it be done? If yes, how?). The Arduino will still be powered up as it is connected to USB of computer and thereby communicates to the computer about the power failure.&lt;/p&gt;&#xA;" OwnerUserId="785" LastEditorUserId="4628" LastEditDate="2017-11-28T12:30:23.407" LastActivityDate="2017-11-28T12:30:23.407" Title="What happens if I power the Arduino with both the USB and external power voltage simultaneously?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="894" PostTypeId="2" ParentId="893" CreationDate="2014-03-24T10:37:08.933" Score="12" Body="&lt;p&gt;From &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;noreferrer&quot;&gt;arduinoBoardUno&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;h1&gt;Power&lt;/h1&gt;&#xA;&lt;p&gt;The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Put the external power through a voltage divider or transistor-based inverter and into an analog (divider) or digital (inverter) pin and check the appropriate value from the pin. Note that this does not require powering the Uno from external power, only connecting the grounds.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-24T11:07:08.490" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="895" PostTypeId="2" ParentId="885" CreationDate="2014-03-24T12:11:19.597" Score="4" Body="&lt;p&gt;You can make adapter boards (one for each mcu model).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bottom side (male headers) would plug to the breadboard and the upper side would have female headers with the same pinout as an Arduino board (female hearers placed in the appropriate positions to match Arduino shields).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such a board shouldn't be difficult to design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an image that resembles what I describe&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LdseD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would adapt the pinout of a bare AVR to the pinout of a typical Arduino so that shields can by directly plugged on top of it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also a pinout diagram may come handy to speedup things when you use a bare chip with Arduino code.&lt;br&gt;&#xA;(&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,146315.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;image source&lt;/a&gt;)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/gNAJG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another similar solution is a small printed sticker placed on top of the AVR&lt;br&gt;&#xA;(&lt;a href=&quot;http://makezine.com/2011/01/12/free-print-and-stick-pinout-label-f/&quot; rel=&quot;nofollow noreferrer&quot;&gt;image source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AMuWs.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="470" LastEditDate="2014-03-24T13:41:10.970" LastActivityDate="2014-03-24T13:41:10.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="896" PostTypeId="2" ParentId="893" CreationDate="2014-03-24T15:16:44.610" Score="65" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am a novice user of Arduino. I am not sure whether I can connect both USB and external supply through power adaptor to Arduino simultaneously. Would this burn the controller?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Lets study the schematic of &lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;Arduino UNO R3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input from the power supply plug (PWRIN, the power jack) goes through a diode D1 (to prevent reverse polarity), and feeds a &lt;a href=&quot;http://www.onsemi.com/pub/Collateral/NCP1117-D.PDF&quot; rel=&quot;noreferrer&quot;&gt;NCP1117&lt;/a&gt; regulator that down converts it to the 5v supply that feeds the 5v parts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bNsoC.jpg&quot; alt=&quot;Power input&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative supply comes from the USB plug (USBVCC). The relevant circuit is shown below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/r9NgC.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB power lines goes through a P-mosfet (T1) that operates as a switch and then goes to the +5V node (that is the +5v regulator output as shown in the first schematic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mosfet is controlled by an &lt;a href=&quot;http://www.onsemi.com/pub/Collateral/LMV321-LMV358-LMV324-D.PDF&quot; rel=&quot;noreferrer&quot;&gt;LMV358&lt;/a&gt; operational amplifier (OPAMP) that operates as a comparator.&lt;br&gt;&#xA;The negative input of the opamp is tied to 3.3V and the positive one fed through a voltage divider with half the Vin supply level.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When Vin &gt;6.6V then the + input of the opamp become higher than the - input and the opamp turns the mosfet off.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When Vin &amp;lt;6.6V then the + input of the opamp become lower than the - input and the opamp turns the mosfet on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that Vin is after the input diode so it's about 0.6V lower than the external connected power supply level. So when there is power supply connected to the power input that is higher than 6.6V+0.6V (where 0.6V is the diode D1 voltage drop), then the USB supply line is cutoff (because the mosfet turns off) and the power is provided from the power plug. Connecting or disconnecting the USB supply in this case will not make a difference, so you can have both power supplies connected simultaneously, only when the power input drops below the specified level (about 6.6V+0.6V=7.2V), the USB will start powering the board.&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="-1" LastEditDate="2015-04-15T18:27:32.863" LastActivityDate="2015-04-15T18:27:32.863" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="897" PostTypeId="2" ParentId="876" CreationDate="2014-03-24T15:24:18.203" Score="5" Body="&lt;h1&gt;Button-pushing robot.&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A four-wheeled eight-pound remote-control laser-shooting robot that pushes buttons.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I made this project over the course of last school year. I was in robotics class, and we decided to have a competition. Each team would make a robot that has a large button and a way to push other buttons. At the end of the year, we would have the final contest, where the three robots would try to push each other's buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the end of the year, my robot only partially worked. Every part of the robot had at some point been working, but between a fried Arduino, fried motor drivers, terrible code organization, and me being the only person on my team to work on the robot for a total of more than five hours, I couldn't get it completely working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't touched my robot in almost a year, so I know that if I wanted to get it working again I would have to rewire the bot and rewrite the code. I may decide to do that some day, but for now I'm going to work on less ambitious projects.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;h3&gt;Overall Design&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w7Gs6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Information/electricity flow&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--------------------------+   +-------------------------------------------------+&#xA;|         Computer         |   |      Robot                                      |&#xA;|--------------------------|   |-------------------------------------------------|&#xA;|                          |   |                                                 |&#xA;| Keyboard +--&amp;gt; Processing |   |  Button +-------------+        Motor    Motor   |&#xA;|                          |   |                       |          ^       ^      |&#xA;|                    +     |   |                       |          |       |      |&#xA;|                    |     |   |  Batteries +-----+    |          +       +      |&#xA;|                    v     |   |                  |    |   +----&amp;gt; Motor Driver   |&#xA;|                          |   |                  v    v   +                     |&#xA;|               Bluetooth +-----&amp;gt; Bluetooth +--&amp;gt; Arduino Uno +--&amp;gt; Motor driver   |&#xA;|                          |   |                  +    +  +       +       +      |&#xA;+--------------------------+   |                  |    |  |       |       |      |&#xA;                               |                  |    |  |       v       v      |&#xA;                               |                  |    |  |    Motor     Motor   |&#xA;                               |                  |    |  |                      |&#xA;                               |                  |    |  |                      |&#xA;                               |                  |    |  +-----&amp;gt; Laser          |&#xA;                               |  +---------------|----|----+                    |&#xA;                               |  |       Arm     |    |    |                    |&#xA;                               |  |---------------|----|----|                    |&#xA;                               |  |     +---------+    v    |                    |&#xA;                               |  |     |      Motor Driver |                    |&#xA;                               |  |     v              +    |                    |&#xA;                               |  |  Servo             |    |                    |&#xA;                               |  |                    v    |                    |&#xA;                               |  |                  Motor  |                    |&#xA;                               |  +-------------------------+                    |&#xA;                               +-------------------------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Components&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno, (fried)&lt;/li&gt;&#xA;&lt;li&gt;Transportation:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.pololu.com/product/2136/&quot; rel=&quot;nofollow noreferrer&quot;&gt;2 motor drivers&lt;/a&gt;, (one fried)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.allelectronics.com/make-a-store/item/dcm-395/3-24vdc-gear-motor-used/1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;4 wheel motors&lt;/a&gt;, (24v, 360mA with no load)&lt;/li&gt;&#xA;&lt;li&gt;4 wheels, (plastic jar lids)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.staples.com/Easy-Button/cat_CL163314&quot; rel=&quot;nofollow noreferrer&quot;&gt;Easy Button&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arm:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.parallax.com/product/900-00008&quot; rel=&quot;nofollow noreferrer&quot;&gt;Servo&lt;/a&gt;, (continuous rotation)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.pololu.com/product/2136/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Motor driver&lt;/a&gt;, (fried)&lt;/li&gt;&#xA;&lt;li&gt;Motor, (12v, found in teacher's junk pile)&lt;/li&gt;&#xA;&lt;li&gt;Eraser&lt;/li&gt;&#xA;&lt;li&gt;Counterweight, (homemade paper bag filled with pennies)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://compare.ebay.com/like/140474546940?var=lv&amp;amp;ltyp=AllFixedPriceItemTypes&amp;amp;var=sbar&quot; rel=&quot;nofollow noreferrer&quot;&gt;2 battery packs&lt;/a&gt;, (12V, 1300mAh, Ni-MH rechargeable)&lt;/li&gt;&#xA;&lt;li&gt;2 solderless breadboards&lt;/li&gt;&#xA;&lt;li&gt;Laser, (5mW)&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.mdfly.com/index.php?main_page=product_info&amp;amp;cPath=&amp;amp;products_id=769&amp;amp;zenid=2qgknl98q9kppt6q14hk70rlr3&quot; rel=&quot;nofollow noreferrer&quot;&gt;mdfly Bluetooth module&lt;/a&gt;, (5v, 30ft)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.aziocorp.com/en/connectivity/16-usb-micro-bluetooth-adapter-v21-edr.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bluetooth adapter&lt;/a&gt;, (USB, 300+ ft)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Lots of wires&lt;/li&gt;&#xA;&lt;li&gt;Lots of scrap metal and plexiglass, (found in teacher's machine shop)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Code&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I didn't organize my code very well, so I hope this is the right code.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino: &lt;a href=&quot;https://github.com/TheGuywithTheHat/robotics-2013/tree/master/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/TheGuywithTheHat/robotics-2013/tree/master/Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Processing: &lt;a href=&quot;https://github.com/TheGuywithTheHat/robotics-2013/tree/master/Processing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/TheGuywithTheHat/robotics-2013/tree/master/Processing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;More pictures&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XoTWl.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/pWIw8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Terrible video of a slow, armless, buttonless, laserless, and bluetoothless early version of the robot.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Q7MvE7-Xb0E&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=Q7MvE7-Xb0E&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm really good at frying electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was my first experience in an actual machine shop. I got to use a CNC milling machine, manual milling machine, lathe, and bandsaw. If I started a project like this again, I would make much better documentation, so I could figure out what the heck I was doing a year later.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-03-25T14:22:57.180" LastActivityDate="2014-03-25T14:22:57.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="898" PostTypeId="2" ParentId="890" CreationDate="2014-03-24T16:01:56.993" Score="4" Body="&lt;p&gt;An Uno most definitely cannot directly control that motor. According to the specs &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So your motor has needs about ten times the voltage and &lt;em&gt;200&lt;/em&gt; times the amps that the Uno can supply. Of course, you can always get a driver of some sort for the servo.&lt;/p&gt;&#xA;" OwnerUserId="37" LastActivityDate="2014-03-24T16:01:56.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="899" PostTypeId="1" AcceptedAnswerId="904" CreationDate="2014-03-24T20:25:52.473" Score="3" ViewCount="4229" Body="&lt;p&gt;Does the Arduino Yun does it have a RTC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if so is it connected to the Atheros AR9331 or the ATmega32u4?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there there is no RTC, can I connect a DS1307 to the Atheros AR9331?&lt;/p&gt;&#xA;" OwnerUserId="790" LastActivityDate="2015-05-22T16:55:42.797" Title="Arduino Yun does it have a RTC?" Tags="|time|arduino-yun|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="900" PostTypeId="1" AcceptedAnswerId="905" CreationDate="2014-03-24T20:31:15.207" Score="6" ViewCount="1552" Body="&lt;p&gt;Can I compile c/c++ code on the linux part of the Arduino Yun?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How complete is the linux part of the Arduino Yun?&#xA;Can I scp some c/c++ code onto the Atheros AR9331 chip compile it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or must I first crosscompile all software and then put them onto the Atheros?&lt;/p&gt;&#xA;" OwnerUserId="790" LastActivityDate="2014-03-24T22:05:10.790" Title="Can I compile c/c++ code on the linux part of the Arduino Yun?" Tags="|arduino-yun|linux|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="901" PostTypeId="2" ParentId="890" CreationDate="2014-03-24T20:34:22.283" Score="2" Body="&lt;p&gt;The optical encoder you link to has 500 pulses per revolution. This means at 3000rpm , you will be generating pulses 25,000 times a second. You will also need to deal with overshoot (as there is nothing worse than a motor going overspeed and the feedback loop being unable to detect it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dealing with an optical encoder generating pulses this quickly is actually quite a challenge, especially with Arduino (which has rather slow native I/O using digitalRead and digitalWrite), and the ATmega328 (which doesn't have any dedicated hardware to deal with high speed optical encoders).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Driving a 56VDC, 7.8A motor isn't an easy challenge either - a motor driver for this isn't going to be easy to design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd probably look for a dedicated servo or CNC motor controller to deal with something like this.&lt;/p&gt;&#xA;" OwnerUserId="136" LastActivityDate="2014-03-24T20:34:22.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="902" PostTypeId="2" ParentId="432" CreationDate="2014-03-24T20:45:52.467" Score="2" Body="&lt;p&gt;You could try a Arduino Yun, it is like a Uno but it has a WiFi directly on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a part in the &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoYun#toc13&quot; rel=&quot;nofollow&quot;&gt;&quot;Guide to the Arduino Yún&quot; called &quot;Configuring the onboard WiFi&quot;&lt;/a&gt;, that describes how to configure the WiFi.&lt;/p&gt;&#xA;" OwnerUserId="790" LastEditorUserId="790" LastEditDate="2014-03-25T14:46:07.343" LastActivityDate="2014-03-25T14:46:07.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="903" PostTypeId="2" ParentId="40" CreationDate="2014-03-24T20:57:47.627" Score="20" Body="&lt;p&gt;There is a half way solution as well since the Arduino IDE has support for external a editor, then the Arduio IDE just compiles and uploads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tu78x.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can use whatever IDE/editor you like to edit the code, &#xA;and then you switch back to the Arduino IDE to press the compile and upload button when you are done.&lt;/p&gt;&#xA;" OwnerUserId="790" LastActivityDate="2014-03-24T20:57:47.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="904" PostTypeId="2" ParentId="899" CreationDate="2014-03-24T22:03:38.863" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the Yún doesn’t have a real time clock IC on board, so it can’t keep time when is powered off. Instead, it synchronizes with time servers automatically when it powers up and connects to a network using NTP.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(&lt;a href=&quot;http://blog.arduino.cc/2013/09/02/arduino-yun-hardware-review/&quot; rel=&quot;noreferrer&quot;&gt;Arduino Blog&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, the &lt;strong&gt;Yun does &lt;em&gt;not&lt;/em&gt; have a onboard RTC.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If there there is no RTC, can I connect a DS1307 to the Atheros AR9331?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably not. It comes in a &lt;a href=&quot;https://www.google.com/search?q=LPCC+package&amp;amp;espv=210&amp;amp;es_sm=122&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ei=n6kwU5ncHaSHygGduoGYDQ&amp;amp;ved=0CAoQ_AUoAg&amp;amp;biw=1280&amp;amp;bih=899&quot; rel=&quot;noreferrer&quot;&gt;LPCC package&lt;/a&gt;, which has the solder joints on the bottom. This needs to be soldered by reflow. The Yun does not have any pins connected directly to that chip. You're probably thinking of the ATmega32u4, the actual Arduino chip. The other one is for a router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To get the time, you have two options:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/TimeCheck&quot; rel=&quot;noreferrer&quot;&gt;Use the time from the time server&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few notes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Yún must be connected to a network to get the correct time. If you used the web-based WiFi interface to configure the Yún for the network, make sure you've selected the proper time zone.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Connect it to a DS1307&lt;/strong&gt; (I find &lt;a href=&quot;http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit&quot; rel=&quot;noreferrer&quot;&gt;this Adafruit tutorial helpful&lt;/a&gt;) You'll need only two pins to use this board. One note: there is a way to connect up to 121 I2C devices using these two pins. However, that gets a little more complicated.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-24T22:03:38.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="905" PostTypeId="2" ParentId="900" CreationDate="2014-03-24T22:05:10.790" Score="5" Body="&lt;p&gt;The Yun's OS (Linino) is based on OpenWRT, and the official toolchain from OpenWRT does not appear to have changed much. It could probably be done, the question is if you'd really want to though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The limited resources (storage, RAM, CPU) means you would most likely not fit all the parts of the toolchain for C/C++ compilation (perhaps with the exception of very basic programs without many dependencies). The YUN's package manager (opkg) should contain pre-built packackes if they exist, but given that even the list of packages is only kept in RAM to conserve space, I doubt the entire toolchain with libraries needed to compile useful stuff would fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The official way to build things for OpenWRT appears to be cross-compilation on a much beefier machine, if only because it takes a fraction of the time needed by a native compiler. All in all, you're also very likely to save time and resources by cross-compiling and have more resources left on the YUN itself.&lt;/p&gt;&#xA;" OwnerUserId="703" LastActivityDate="2014-03-24T22:05:10.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="906" PostTypeId="1" AcceptedAnswerId="909" CreationDate="2014-03-24T22:14:27.140" Score="2" ViewCount="247" Body="&lt;p&gt;I have made a simple program using the &lt;code&gt;int main() {}&lt;/code&gt; function. It has a delay in it. It is evident the code before the delay is running, but the delay never seems to time out and let the next instructions through. Is this by design?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I rename the method and call it exactly once from the &lt;code&gt;loop() {}&lt;/code&gt; function though, it does work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code borrowed the 'main()' function and I suppose redefined it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main() { &#xA;    Forward();&#xA;    delay(3000);&#xA;    Reverse();&#xA;}&#xA;&#xA;void Forward() {&#xA;    //...&#xA;}&#xA;&#xA;void Reverse() {&#xA;    //... &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see this redefinition of &lt;code&gt;main()&lt;/code&gt; could cause some serious issues based on the answer below.&lt;/p&gt;&#xA;" OwnerUserId="690" LastEditorUserId="690" LastEditDate="2014-03-25T09:56:17.003" LastActivityDate="2014-03-25T09:56:17.003" Title="Should a delay be expected to cause deadlock?" Tags="|arduino-mega|timers|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="907" PostTypeId="1" CreationDate="2014-03-24T22:46:53.803" Score="2" ViewCount="3726" Body="&lt;p&gt;On Mac OSX Mavericks, why does Arduino Uno uses serial port named &lt;code&gt;/dev/cu.usbmodemfa131&lt;/code&gt; while Arduino Nano uses &lt;code&gt;/dev/cu.usbserial-A702NY8S&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are they using different FTDI drivers?&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2014-06-12T00:04:03.783" Title="Serial port /dev/cu.usbmodemfa131 vs /dev/cu.usbserial-A702NY8S" Tags="|arduino-uno|serial|arduino-nano|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="908" PostTypeId="2" ParentId="907" CreationDate="2014-03-24T23:55:46.713" Score="2" Body="&lt;p&gt;Drivers are different. On older boards, such as Duemilanove you may need to actually &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;download serial drivers&lt;/a&gt; to &lt;a href=&quot;https://pixhawk.ethz.ch/tutorials/serial_terminal&quot; rel=&quot;nofollow&quot;&gt;talk to them&lt;/a&gt; at all in Lion, Mountain Lion, Mavericks.&#xA;There's some discussion of that problem &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=114652.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="382" LastActivityDate="2014-03-24T23:55:46.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="909" PostTypeId="2" ParentId="906" CreationDate="2014-03-25T05:49:46.733" Score="7" Body="&lt;p&gt;You don't seem to use standard Arduino stuff since you defined your own &lt;code&gt;main()&lt;/code&gt; which is normally avoided when programming Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take a look at Arduino provided &lt;code&gt;main()&lt;/code&gt; (in &lt;strong&gt;hardware/cores/arduino/main.cpp&lt;/strong&gt;), you'll see how it is defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    init();&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you notice the &lt;code&gt;init()&lt;/code&gt; function call at the beginning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its code is defined in &lt;strong&gt;hardware/cores/arduino/wiring.c&lt;/strong&gt;; what it does is setup all timers used by Arduino functions, in particular a timer that is needed by &lt;code&gt;delay()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the same &lt;strong&gt;wiring.c&lt;/strong&gt; file, you can also find the definition of &lt;code&gt;delay()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void delay(unsigned long ms)&#xA;{&#xA;    uint16_t start = (uint16_t)micros();&#xA;&#xA;    while (ms &amp;gt; 0) {&#xA;        if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will turn into an infinite loop if &lt;code&gt;micros()&lt;/code&gt; always return the same value, and it does so if &lt;code&gt;init()&lt;/code&gt; has never been called before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what happens with your code.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-25T05:49:46.733" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="910" PostTypeId="1" AcceptedAnswerId="1331" CreationDate="2014-03-25T09:26:50.040" Score="2" ViewCount="1645" Body="&lt;p&gt;I'm using the &lt;code&gt;Serial1&lt;/code&gt; of the Arduino Leonardo to send and receive data with another MCU. The following code will always retrieve garbled data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte streamReadResponse;&#xA;Serial1.begin(115200);&#xA;Serial1.setTimeout(9000);&#xA;Serial1.print(cmd);&#xA;Serial1.print('\r');&#xA;Serial1.flush();  //wait for all the data to be sent to the serial&#xA;streamReadResponse = Serial1.readBytesUntil('&amp;gt;', data, dataLength);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, if I add a &lt;code&gt;delay(50)&lt;/code&gt; before the Serial1 read, I would get the expected output. The value 50 was found by trial and error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing? Why is the &lt;code&gt;flush()&lt;/code&gt; command not working as expected?&lt;/p&gt;&#xA;" OwnerUserId="794" LastEditorUserId="754" LastEditDate="2014-03-25T14:17:37.293" LastActivityDate="2014-04-29T09:32:03.897" Title="Serial.read has garbled data after a Serial.write" Tags="|serial|arduino-leonardo|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="911" PostTypeId="1" AcceptedAnswerId="921" CreationDate="2014-03-25T12:24:10.450" Score="7" ViewCount="3846" Body="&lt;p&gt;I'm trying to build an Arduino example without using its IDE. My OS is &lt;strong&gt;Windows 8.1&lt;/strong&gt; and I'm using the last version of &lt;strong&gt;CMake (2.8.12.2)&lt;/strong&gt; and &lt;strong&gt;MinGW (GNU Make 3.82.90)&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded &lt;a href=&quot;https://github.com/queezythegreat/arduino-cmake&quot;&gt;the Arduino CMakeLists&lt;/a&gt; and I learned all about &lt;code&gt;make/upload&lt;/code&gt; any firmware in my Arduino. I'm using &lt;strong&gt;Arduino UNO&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, if I modify the CMakeLists saved in &lt;code&gt;~/arduino-cmake-master/example/CMakeLists.txt&lt;/code&gt; (&lt;strong&gt;&lt;em&gt;arduino-cmake-master&lt;/em&gt;&lt;/strong&gt; is the repository folder) to build the WiFi example &lt;strong&gt;&lt;em&gt;WiFiWebClient&lt;/em&gt;&lt;/strong&gt; too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&#xA;#Add the WiFi example -&amp;gt; WiFiWebClient&#xA;generate_arduino_example(wifi_example&#xA;                     LIBRARY WiFi&#xA;                     EXAMPLE WiFiWebClient)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  $ cmake -G &quot;MinGW Makefiles&quot;&#xA;&#xA;  ...&#xA;&#xA;  CMake Warning (dev) in example/CMakeLists.txt:&#xA;  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link&#xA;  interface.  Run &quot;cmake --help-policy CMP0022&quot; for policy details.  Use the&#xA;  cmake_policy command to set the policy and suppress this warning.&#xA;&#xA;  Target &quot;uno_example&quot; has an INTERFACE_LINK_LIBRARIES property.  This should&#xA;  be preferred as the source of the link interface for this library but&#xA;  because CMP0022 is not set CMake is ignoring the property and using the&#xA;  link implementation as the link interface instead.&#xA;&#xA;  INTERFACE_LINK_LIBRARIES:&#xA;&#xA;    uno_CORE;uno_example;uno_Wire&#xA;&#xA;  Link implementation:&#xA;&#xA;    uno_CORE;uno_Wire&#xA;&#xA;This warning is for project developers.  Use -Wno-dev to suppress it.&#xA;&#xA;CMake Warning (dev) in example/CMakeLists.txt:&#xA;  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link&#xA;  interface.  Run &quot;cmake --help-policy CMP0022&quot; for policy details.  Use the&#xA;  cmake_policy command to set the policy and suppress this warning.&#xA;&#xA;  Target &quot;uno_Wire&quot; has an INTERFACE_LINK_LIBRARIES property.  This should be&#xA;  preferred as the source of the link interface for this library but because&#xA;  CMP0022 is not set CMake is ignoring the property and using the link&#xA;  implementation as the link interface instead.&#xA;&#xA;  INTERFACE_LINK_LIBRARIES:&#xA;&#xA;    uno_CORE;uno_Wire&#xA;&#xA;  Link implementation:&#xA;&#xA;    uno_CORE&#xA;&#xA;This warning is for project developers.  Use -Wno-dev to suppress it.&#xA;&#xA;CMake Warning (dev) in example/CMakeLists.txt:&#xA;  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link&#xA;  interface.  Run &quot;cmake --help-policy CMP0022&quot; for policy details.  Use the&#xA;  cmake_policy command to set the policy and suppress this warning.&#xA;&#xA;  Target &quot;uno_SPI&quot; has an INTERFACE_LINK_LIBRARIES property.  This should be&#xA;  preferred as the source of the link interface for this library but because&#xA;  CMP0022 is not set CMake is ignoring the property and using the link&#xA;  implementation as the link interface instead.&#xA;&#xA;  INTERFACE_LINK_LIBRARIES:&#xA;&#xA;    uno_CORE;uno_SPI&#xA;&#xA;  Link implementation:&#xA;&#xA;    uno_CORE&#xA;&#xA;This warning is for project developers.  Use -Wno-dev to suppress it.&#xA;&#xA;CMake Warning (dev) in example/CMakeLists.txt:&#xA;  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link&#xA;  interface.  Run &quot;cmake --help-policy CMP0022&quot; for policy details.  Use the&#xA;  cmake_policy command to set the policy and suppress this warning.&#xA;&#xA;  Target &quot;uno_WiFi&quot; has an INTERFACE_LINK_LIBRARIES property.  This should be&#xA;  preferred as the source of the link interface for this library but because&#xA;  CMP0022 is not set CMake is ignoring the property and using the link&#xA;  implementation as the link interface instead.&#xA;&#xA;  INTERFACE_LINK_LIBRARIES:&#xA;&#xA;    uno_CORE;uno_WiFi&#xA;&#xA;  Link implementation:&#xA;&#xA;    uno_CORE&#xA;&#xA;This warning is for project developers.  Use -Wno-dev to suppress it.&#xA;&#xA;-- Generating done&#xA;-- Build files have been written to: ~/arduino-cmake-master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Later I execute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ mingw32-make&#xA;&#xA;...&#xA;&#xA;&#xA;Linking CXX static library libuno_WiFi.a&#xA;[ 89%] Built target uno_WiFi&#xA;Scanning dependencies of target wifi_example&#xA;[ 92%] Building CXX object example/CMakeFiles/wifi_example.dir/wifi_example_WiFiWebClient.cpp.obj&#xA;Linking CXX executable wifi_example.elf&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::status()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:160: undefined reference to `ServerDrv::getClientState(unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::stop()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:131: undefined reference to `ServerDrv::stopClient(unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::peek()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:117: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:101: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read(unsigned char*, unsigned int)':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:107: undefined reference to `ServerDrv::getDataBuf(unsigned char, unsigned char*, unsigned int*)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::available()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:90: undefined reference to `ServerDrv::availData(unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::write(unsigned char const*, unsigned int)':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:73: undefined reference to `ServerDrv::sendData(unsigned char, unsigned char const*, unsigned int)'&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:78: undefined reference to `ServerDrv::checkDataSent(unsigned char)'&#xA;libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::connect(IPAddress, unsigned int)':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:36: undefined reference to `ServerDrv::startClient(unsigned long, unsigned int, unsigned char, unsigned char)'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::hostByName(char const*, IPAddress&amp;amp;)':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:228: undefined reference to `WiFiDrv::getHostByName(char const*, IPAddress&amp;amp;)'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::status()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:223: undefined reference to `WiFiDrv::getConnectionStatus()'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::RSSI()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:181: undefined reference to `WiFiDrv::getCurrentRSSI()'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::SSID()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:169: undefined reference to `WiFiDrv::getCurrentSSID()'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::localIP()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:149: undefined reference to `WiFiDrv::getIpAddress(IPAddress&amp;amp;)'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::begin(char*, char const*)':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:87: undefined reference to `WiFiDrv::wifiSetPassphrase(char*, unsigned char, char const*, unsigned char)'&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:92: undefined reference to `WiFiDrv::getConnectionStatus()'&#xA;libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::init()':&#xA;C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:22: undefined reference to `WiFiDrv::wifiDriverInit()'&#xA;example\CMakeFiles\wifi_example.dir\build.make:95: recipe for target 'example/wifi_example.elf' failed&#xA;mingw32-make[2]: *** [example/wifi_example.elf] Error 1&#xA;CMakeFiles\Makefile2:748: recipe for target 'example/CMakeFiles/wifi_example.dir/all' failed&#xA;mingw32-make[1]: *** [example/CMakeFiles/wifi_example.dir/all] Error 2&#xA;Makefile:74: recipe for target 'all' failed&#xA;mingw32-make: *** [all] Error 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is the Arduino.cmake because it's not linking correctly with the library WiFi, but it links with the Wire library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows why that warning appears and why Wire links ok but WiFi doesn't?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I'm using original code which is in the repository example, I've not modified this one.&lt;/p&gt;&#xA;" OwnerUserId="656" LastEditorUserId="754" LastEditDate="2014-03-25T13:41:28.383" LastActivityDate="2014-03-26T06:31:05.097" Title="Warning Arduino CMakeLists &quot;Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES&quot;" Tags="|arduino-uno|compile|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="912" PostTypeId="2" ParentId="847" CreationDate="2014-03-25T16:44:45.167" Score="0" Body="&lt;p&gt;To communicate with the Arduino, it is only necessary to connect the RX and TX pins between the module and the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://www.mkroll.mobi/?page_id=386&quot; rel=&quot;nofollow&quot;&gt;http://www.mkroll.mobi/?page_id=386&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-03-25T16:44:45.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="913" PostTypeId="2" ParentId="432" CreationDate="2014-03-25T20:06:27.923" Score="5" Body="&lt;h1&gt;Marry OpenWrt and your Arduino&lt;/h1&gt;&#xA;&lt;p&gt;Get a small OpenWrt-capable router like &amp;quot;TP-Link TL-WR703N&amp;quot;, flash it with the current stable version of OpenWrt and connect your Arduino to the router's USB port.&lt;/p&gt;&#xA;&lt;p&gt;This solution ist half or less of the cost of WiFi-shields and has far more power.&lt;/p&gt;&#xA;&lt;p&gt;...and cheaper as a YÙN.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/How-to-set-up-OpenWRT-on-a-pocket-router-WR703N/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Smart home automation webserver on OpenWRT router WR703N interfaced to Arduino, compared to Raspberry Pi and Ubuntu&lt;/a&gt; may be a starting point to read about this and your favorite search engine will find many more links about marrying WR703N and Arduinos...&lt;/p&gt;&#xA;&lt;p&gt;(!) Please see &lt;a href=&quot;https://arduino.stackexchange.com/a/1754/653&quot;&gt;https://arduino.stackexchange.com/a/1754/653&lt;/a&gt; too....&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-01-01T07:19:36.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="914" PostTypeId="2" ParentId="876" CreationDate="2014-03-25T21:21:44.917" Score="5" Body="&lt;h1&gt;The Knock-knock lamp&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A lamp that toggles on/off when the desk is knocked on.&lt;/strong&gt; Currently in alpha phase, still prototyping, but I think it's the most useful Arduino project in existence. &lt;em&gt;Included corny joke generator... from previously recorded knock-knock jokes.&lt;/em&gt; Note: I know I can't win in the rules, but there's no rule about entering... I can show off my project, too.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;So far I've pretty much explained most of it. You knock, and the light turns on and off. I'm currently on breadboard. I'm using a &lt;a href=&quot;http://antoinettejcitizen.files.wordpress.com/2011/03/piezo.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;piezo element&lt;/a&gt; to detect the knocks with vibrations. In parallel, I have a 1 megaohm resistor to protect my Arduino Uno SMD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought of this design after nearly knocking (haha punny) my lamp off of my desk while searching for the little toggle switch. I'm not exactly... well &lt;em&gt;adroit&lt;/em&gt;. It's nice just to knock on the desk and then have light. I'm also using a Power Switch Tail SSR (solid state relay: no noise) to control it with two of my Arduino's pins.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KxflQ.png&quot; alt=&quot;Photo&quot;&gt;&#xA;&lt;em&gt;Image taken with webcam hanging over monitor... eek!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yScgU.png&quot; alt=&quot;Fritzing Diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Components used to build the project:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Piezo element ($3.00 USD)&lt;/li&gt;&#xA;&lt;li&gt;Megaohm resistor ($0.30 USD each in 5pk)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno SMD (on hand)&lt;/li&gt;&#xA;&lt;li&gt;Power Switch Tail SSR (~$25.00 USD with ship, but had on hand so no cost)&lt;/li&gt;&#xA;&lt;li&gt;Breadboard and jumpers/extra wire (~$5.00 USD, but had on hand so no cost)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cost to me: $3.30 USD + $0.02 USD (tax) == Only $3.32!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Overall, it is a simple project but it's actually useful. That's a struggle with my Arduino projects: can I build something that I would actually &lt;em&gt;use&lt;/em&gt;? Blinking an LED isn't exactly going to help you in life. It's fun, but that's about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest issue I faced (and kinda still do) is not getting a strong enough signal. I learned a lot about electrical signals: I figured out how to find the &quot;peak&quot; of a pulse and not just read the pin at a random interval and miss the higher voltage. I would try getting  more sensitive piezo element. A larger one would help. I'm trying to modify my circuit to not limit the voltage as much, but protect the Arduino. Some sort of fuse would help in this situation. I'm also playing around with resistor values. It'd help a lot to have a scope for this, but I guess not... :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I perfect the circuit, I'm going to work on getting it on a PCB with an ATtiny... and maybe even develop some kits. I'll try to publish my findings on how to make the element more sensitive without risking my board in the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Status update:&lt;/strong&gt; I've been really busy recently. I'm going to order a zener diode (4.3V) here in a week or two to remove the megaohm resistor to prevent diluting the signal while protection the chip. I may build a simple voltage amp here if needed (alongside the zener) to try to make the sensor more sensitive.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-11-28T19:13:18.967" LastActivityDate="2014-11-28T19:13:18.967" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="915" PostTypeId="2" ParentId="876" CreationDate="2014-03-25T21:49:33.790" Score="14" Body="&lt;h1&gt;Stateful questbox&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A &lt;a href=&quot;http://en.wikipedia.org/wiki/Global_Positioning_System&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPS&lt;/a&gt; powered box that makes you visit a few spots before opening&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It is similar to &lt;a href=&quot;https://www.sundial.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;questbox&lt;/a&gt;, but it stores a small amount state of information in &lt;a href=&quot;http://en.wikipedia.org/wiki/EEPROM&quot; rel=&quot;nofollow noreferrer&quot;&gt;EEPROM&lt;/a&gt;, so you have to visit two or three different places before it opens.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Needed hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reverse Geocache Version 2 (or a protoshield)&lt;/li&gt;&#xA;&lt;li&gt;GlobalSat EM-406A GPS module&lt;/li&gt;&#xA;&lt;li&gt;2×8 blue LCD with connector header and cable&lt;/li&gt;&#xA;&lt;li&gt;Hitec HS-55 servo motor&lt;/li&gt;&#xA;&lt;li&gt;4-40 push rod and clevis for latch (some versions provide a Z-bend rod instead)&lt;/li&gt;&#xA;&lt;li&gt;2 AA battery holder&lt;/li&gt;&#xA;&lt;li&gt;Metallic push button with embedded blue LED and 4-pin cable&lt;/li&gt;&#xA;&lt;li&gt;Pololu low voltage switch&lt;/li&gt;&#xA;&lt;li&gt;Pololu 5&amp;nbsp;V boost regulator&lt;/li&gt;&#xA;&lt;li&gt;JST connector for EM-406A GPS module&lt;/li&gt;&#xA;&lt;li&gt;Straight and right-angle header pins for the display, servo, and pushbutton connectors&lt;/li&gt;&#xA;&lt;li&gt;Two resistors for current limiting and display contrast adjustment&lt;/li&gt;&#xA;&lt;li&gt;Two small capacitors for power smoothing&lt;/li&gt;&#xA;&lt;li&gt;larger capacitor for display contrast circuit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Total hardware cost: &lt;strong&gt;137$ + shipping&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aditional materials:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A nice box&lt;/li&gt;&#xA;&lt;li&gt;Epoxy glue, wood to cover pieces, tools&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find assembling instructions in &lt;a href=&quot;https://www.sundial.com/quest-box/notes-for-builders/&quot; rel=&quot;nofollow noreferrer&quot;&gt;sundial page&lt;/a&gt; (you can buy most materials from them)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will upload stateful code and post a link here, unfortunately I wont get all need hardware on time, so this is just an idea :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code written so far&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.biicode.com/hithwen/blocks/hithwen/statemachine/branches/master#.UzSTlmR5NUk&quot; rel=&quot;nofollow noreferrer&quot;&gt;Persistent state machine library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Inspiration:&lt;img src=&quot;https://i.stack.imgur.com/864pF.jpg&quot; alt=&quot;Original questbox&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Learned how to integrate many components and libraries all toghether, I'll have to travel a bit to test it :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Budget can be cut quite a bit changing the concept a bit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Change GPS with a numerical keypad: the 'player' has to guess/obtain a code instead of traveling to a location&lt;/li&gt;&#xA;&lt;li&gt;Polulu switch and regulator can be exchanged for a &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,64596.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;latching relay with capacitance coupling&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="754" LastEditorUserId="510" LastEditDate="2014-04-08T18:45:43.877" LastActivityDate="2014-04-08T18:45:43.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="916" PostTypeId="2" ParentId="907" CreationDate="2014-03-25T22:32:09.513" Score="0" Body="&lt;p&gt;The Uno is not using FTDI drivers &lt;strong&gt;at all&lt;/strong&gt;, since it does USB through an ATmega16u2, not an FTDI chip.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-25T22:32:09.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="917" PostTypeId="1" CreationDate="2014-03-25T23:33:33.123" Score="7" ViewCount="3256" Body="&lt;p&gt;I recently noticed how the map() function in Arduino was bulky in both terms of flash space used and time taken to execute, largely because it deals with &lt;code&gt;long&lt;/code&gt; and involves a division and multiplication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many times you can replace maps with more basic functions i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = map(input,0,1023,0,255); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = input &amp;gt;&amp;gt; 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = map(input,0,1023,1023,0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = 1023 - input;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have one line in some code that says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;backlight = map(LDRreading,0,1023,50,250);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How could this be simplified so that it is both space and time efficient?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll allow slight differences in output values if it results in a much better solution.&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="220" LastEditDate="2014-04-17T21:43:11.353" LastActivityDate="2014-04-17T21:43:11.353" Title="What's the most efficient implementation of map(x,0,1023,50,250)?" Tags="|map|code-optimization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="918" PostTypeId="2" ParentId="917" CreationDate="2014-03-25T23:58:22.970" Score="2" Body="&lt;p&gt;You could approximate it quite closely using only two integer operations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;backlight = (LDRreading / 5) + 46;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That effectively maps input range 0 - 1023 onto output range 46 - 250, so it's fairly accurate. If &lt;code&gt;LDRreading&lt;/code&gt; is a 2 byte integer type then it should be significantly more efficient (comparatively speaking) than anything which uses &lt;code&gt;long&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-25T23:58:22.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="919" PostTypeId="2" ParentId="917" CreationDate="2014-03-26T00:10:14.167" Score="9" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SJsei.png&quot; alt=&quot;Scaling calculation&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The screenshot shows a base-2 (i.e. binary) result of calculating the constant part of a mapping. You can approximate this multiplication by a constant by a number of shifts added together. You need to break down each multiplication in the result first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x * 0.001&lt;sub&gt;2&lt;/sub&gt; = x &gt;&gt; 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x * 0.0001&lt;sub&gt;2&lt;/sub&gt; = x &gt;&gt; 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x * 0.0000001&lt;sub&gt;2&lt;/sub&gt; = x &gt;&gt; 7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then add these together. You are essentially breaking it down into convenient base-2 multiplies (which can always be represented by shifts) and adds - nearly always more efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't get you right to 250, but pretty close:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; for i in range(0, 1024, 34):&#xA;...   print (i &amp;gt;&amp;gt; 3) + (i &amp;gt;&amp;gt; 4) + (i &amp;gt;&amp;gt; 7) + 50&#xA;... &#xA;50&#xA;56&#xA;62&#xA;   [snip]&#xA;235&#xA;241&#xA;247&#xA;&amp;gt;&amp;gt;&amp;gt; print (1023 &amp;gt;&amp;gt; 3) + (1023 &amp;gt;&amp;gt; 4) + (1023 &amp;gt;&amp;gt; 7) + 50&#xA;247&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do all your processing with a left-justified &lt;code&gt;int&lt;/code&gt; (&lt;code&gt;ADLAR&lt;/code&gt;=1) though, to minimize errors. The ADC returns a 10bit result, and ADLAR choses if this is aligned to the left or right of the two result registers.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-03-27T03:51:01.603" LastActivityDate="2014-03-27T03:51:01.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="920" PostTypeId="1" CreationDate="2014-03-08T18:29:48.480" Score="2" ViewCount="3222" Body="&lt;p&gt;I'm trying to simply access my HC_05 bluetooth module and conduct some AT commands through the Serial Monitor. For some reason though, &lt;strong&gt;it only seems to be returning Null characters,&lt;/strong&gt; though it does some to be actually responding to the command in some way (given by the length of Null characters it returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NnELQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can clearly see that the command &lt;code&gt;AT&lt;/code&gt; and &lt;code&gt;AT+NAMEdevice&lt;/code&gt; return different data, but they are both all &lt;code&gt;NUL&lt;/code&gt; blocks. I am viewing the monitor in text. Changing the view to Hex or ASCII does not change results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code for this simple program is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BTSerial(10, 11); // RX | TX&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode&#xA;  digitalWrite(9, HIGH);&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Enter AT commands:&quot;);&#xA;  BTSerial.begin(38400);  // HC-05 default speed in AT command more&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  // Keep reading from HC-05 and send to Arduino Serial Monitor&#xA;  if (BTSerial.available())&#xA;    Serial.write(BTSerial.read());&#xA;&#xA;  // Keep reading from Arduino Serial Monitor and send to HC-05&#xA;  if (Serial.available())&#xA;    BTSerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wire Diagram is as &lt;a href=&quot;http://www.instructables.com/file/FM8W4A2HKZAVRT9&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&#xA;&lt;em&gt;NOTE&lt;/em&gt; I have used both a direct connection to the &lt;code&gt;5V&lt;/code&gt; and also used a Voltage Divider. Neither changes the &lt;code&gt;NUL&lt;/code&gt; return.&lt;/p&gt;&#xA;" OwnerUserId="6601" OwnerDisplayName="JcKelley" LastEditorUserId="11" LastEditDate="2014-03-26T06:11:11.613" LastActivityDate="2014-05-30T17:52:31.907" Title="Arduino Serial Monitor only returning Null Characters" Tags="|serial|bluetooth|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="921" PostTypeId="2" ParentId="911" CreationDate="2014-03-26T06:31:05.097" Score="4" Body="&lt;p&gt;Your question actually has 2 distinct parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why does arduino-cmake generate the warning &quot;Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES...&quot;?&lt;/li&gt;&#xA;&lt;li&gt;Why does &lt;code&gt;make&lt;/code&gt;, using the generated MakeFile, fail when building WiFi example?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First off&lt;/strong&gt;, the arduino-cmake &quot;&lt;strong&gt;Policy CMP0022&lt;/strong&gt;&quot; is just a warning, not an error. As per &lt;a href=&quot;https://github.com/Kitware/CMake/blob/master/Help/policy/CMP0022.rst&quot; rel=&quot;nofollow noreferrer&quot;&gt;this cmake article&lt;/a&gt;, that CMP policy has been only recently introduced in &lt;strong&gt;CMake 2.8.12&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get this warning simply because arduino-cmake has been created based on an older version of cmake and thus does not specifically support this new policy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to get rid of this warning, the documentation mentions you should add the &lt;code&gt;cmake_policy(SET CMP0022 OLD)&lt;/code&gt; command to your cmake configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I tried it in the example &lt;code&gt;CMakeLists.txt&lt;/code&gt; to no avail; maybe it has to be set directly in arduino-cmake files (which I have not tested).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, if you want to get rid of this boring warning, it seems the only solution you are left with is to disable all warnings when launching cmake:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;cmake -G &quot;MinGW Makefiles&quot; -Wno-dev&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This works fine and has removed all warnings..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Your second problem&lt;/strong&gt; (the real one I would say) is due to to the structure of WiFi library:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/JUqed.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, as you can see above, it has a &lt;code&gt;utility&lt;/code&gt; subdirectory that contains additional source code that &lt;strong&gt;cannot be found by arduino-cmake&lt;/strong&gt;, as by default it searches for source code files only at first level directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to solve it? Just tell arduino-cmake to do a &lt;strong&gt;recursive search for the WiFi library&lt;/strong&gt;; in your &lt;code&gt;CMakeLists.txt&lt;/code&gt;, ensure you add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set(WiFi_RECURSE True)&#xA;generate_arduino_example(wifi_example&#xA;                     LIBRARY WiFi&#xA;                     EXAMPLE WiFiWebClient)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The added &lt;code&gt;set(WiFi_RECURSE True)&lt;/code&gt; line just tells arduino-cmake that, for WiFi library, it should recurse through subdirectories when looking for source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked it with &quot;Unix Makefiles&quot; (not &quot;MinGW Makefiles&quot; but I guess that won't make any difference) and it worked fine.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-26T06:31:05.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="924" PostTypeId="2" ParentId="864" CreationDate="2014-03-26T09:32:03.957" Score="3" Body="&lt;p&gt;The bootloader on an arduino is just a piece of software written to enable you to update your sketches using the usb connection. Without the bootloader you can't upload sketches using just the arduino ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information about the bootloader can be found here: &lt;a href=&quot;http://arduino.cc/en/Guide/Environment?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/Environment?from=Tutorial.Bootloader&lt;/a&gt;&#xA;Look under the heading entitled uploading which explains the part the bootloader plays in uploading sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use the &quot;Burn Bootloader&quot; button in the arduino ide it will attempt to write a new copy of the bootloader onto the attached Arduino board. To do this the board must be attached in a specific manner - that is - using the icsp/isp header rather than the usb cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to program the avr chip directly you have to use an external (hardware) programmer. Fortunately you don't have to buy one if you have a second arduino because the second arduino can be used as a programmer. Instructions for doing so can be found here: &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even more info about the bootloader: &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2014-03-26T09:32:03.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="925" PostTypeId="2" ParentId="917" CreationDate="2014-03-26T12:10:17.060" Score="4" Body="&lt;p&gt;How about this, mapping to 50..249?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = ((input * 25) &amp;gt;&amp;gt; 7)+50;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your input range was 1024 (0..1023). Output range is 200 (In the original specification, it would have been 201, which does not divide as neatly). These have a gcd of 8, so &lt;code&gt;output = (input * (200/8)) / (1024/8) + 50&lt;/code&gt; will do, and the division by a power of 2 can be expressed with a shift. The nice thing is that &lt;code&gt;1024*25&lt;/code&gt; still fits into a 16 bit integer, so no longs are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want full range, you can try throwing in rounding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = ((input*25+64) &amp;gt;&amp;gt; 7)+50;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="353" LastEditorUserId="353" LastEditDate="2014-03-26T18:39:08.740" LastActivityDate="2014-03-26T18:39:08.740" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="926" PostTypeId="1" CreationDate="2014-03-26T14:56:05.410" Score="20" ViewCount="106053" Body="&lt;p&gt;What is the maximum power consumption (in mW) of the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardNano&quot; rel=&quot;noreferrer&quot;&gt;Arduino Nano 3.0&lt;/a&gt;, when it is running in its default state (at 16MHz, no LEDs removed) and powered by an external regulated 5V supply so it bypasses the built in voltage regulator?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will give us an upper bound on the power consumption of the Arduino Nano that can be used during estimates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ugt9m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="4628" LastEditDate="2017-12-18T16:01:30.963" LastActivityDate="2020-01-29T15:23:21.640" Title="What is the maximum power consumption of the Arduino Nano 3.0?" Tags="|power|arduino-nano|voltage-level|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="927" PostTypeId="2" ParentId="917" CreationDate="2014-03-26T15:15:42.813" Score="2" Body="&lt;p&gt;If the input range is limited in size and you have the memory for it nothing beats a simple lookup-table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;like&lt;br&gt;&#xA;unsigned char map[1024] = { 50, 50, &amp;lt;&amp;lt; more entries here  &gt;&gt;, 250 } ;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pre-compute the content in a part of the program that isn't time-critical or just compute the entire table-content beforehand and put it verbatim in the source-code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing a map is just a read of map[] with the original value as index.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you input range starts with a non-zero number just decrement all inputs by the lower-bound value so you have a 0-base index for the map array. (That works for negative lower-bounds too !)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At most 1 substract (to adjust for a non-zero lower-bound) and 1 addition to calculate the array-base + index.&lt;br&gt;&#xA;And a good compiler will be able to optimize it further.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't get more efficient than that, but you do need the space to store the table somewhere.&lt;/p&gt;&#xA;" OwnerUserId="810" LastActivityDate="2014-03-26T15:15:42.813" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="928" PostTypeId="2" ParentId="876" CreationDate="2014-03-26T15:56:52.820" Score="5" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UKSL4.png&quot; alt=&quot;MySensors&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;- Learn how to create your own low cost wireless sensors and connect them to the world.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mysensors.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.mysensors.org&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We call it &lt;strong&gt;&quot;Internet of Your Things&quot;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;We've combined the Arduino platform with a small radio transceiver into a fun, flexible world of low cost wireless sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the nitty-gritty details about the sensor communication has been packaged into a convenient software library so you don't have to worry about them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is as easy as 1, 2, 3.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/VfWYX.png&quot; alt=&quot;Arduino + NRF24L01+&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect the parts. 2. Download the provided examples. 3. Start measuring and controlling the world!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Read more about how the sensor network is automatically being formed using our Arduino Library on the site. It basically forms a star network and can reach hundred of meters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ETVDA.png&quot; alt=&quot;The sensor network&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the middle you place an Arduion or Raspberry gateway that collects the information from your sensors.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/s8GkQ.jpg&quot; alt=&quot;Raspberry Controller&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/35AcP.jpg&quot; alt=&quot;Arduino Gateway&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design and schematics&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Here is one of the prototype motion sensors I created to control the garden light outside of my house. The motions status is sent to my HA controller which turns on the light (via z-wave) when motion has been detected. A light sensor (not in the image) makes sure only to turn on the lights at night.&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/DE5oE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will find all the build instructions here:&#xA;&lt;a href=&quot;http://www.mysensors.org/build/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.mysensors.org/build/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Othe site there is also easy-to-follow build instructions for a bunch of other wireless sensors and actuators. Here are some examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Distance Sensor, Motion sensor, Relay actuator, Humidity, Light, Pressure, Rain, Temperature, ... &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The project is still in the starting blocks and we hope to provide plugins for a growing list of Home Automation controllers. The first thing on our list right now is to provide a DIY controller that provides a free cloud storage for your sensor data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VYgX4.png&quot; alt=&quot;Hello&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See you @ mysensors.org&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/Henrik Ekblad (the creator of the Open Source Arduino Library used for the communication between the sensors) &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UPDATE 27/3. Made the example more concrete and added my affiliation with the open source project. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="809" LastEditorUserId="809" LastEditDate="2014-03-27T09:24:49.833" LastActivityDate="2014-03-27T09:24:49.833" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="929" PostTypeId="1" CreationDate="2014-03-26T17:18:26.827" Score="9" ViewCount="714" Body="&lt;p&gt;Whilst it is possible, and sometimes desirable, to use pin change interrupts to read the state of buttons, it is simpler to poll the state of buttons in &lt;code&gt;loop()&lt;/code&gt;. This is a commonly used technique.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;loop()&lt;/code&gt; executes quickly enough, then button presses are always going to be caught and the user will not be able to perceive any delay or lag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that your loop would take so long as to cause a delay or lag to be perceived.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, how long would it be, in general, before a user would see this?&lt;/p&gt;&#xA;" OwnerUserId="136" LastEditorUserId="136" LastEditDate="2014-03-26T21:40:57.043" LastActivityDate="2014-03-27T03:50:41.280" Title="How frequently do you need to poll UI buttons before they are perceived as laggy?" Tags="|button|ui|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="930" PostTypeId="2" ParentId="246" CreationDate="2014-03-26T17:37:55.967" Score="7" Body="&lt;p&gt;I think I see a lot of single-sample noise spikes in your noisy signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The median filter does better at getting rid of single-sample noise spikes than any linear filter.&#xA;(It is better than any low pass filter, moving average, weighted moving average, etc. in terms of its response time and its ability to ignore such single-sample noise spike outliers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are, in fact, many signal-smoothing libraries for the Arduino, many of which include a median filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;signal-smoothing libraries at arduino.cc:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/Smooth&quot;&gt;Paul Badger: smooth digital low-pass filter&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DigitalSmooth&quot;&gt;Paul Badger: digitalSmooth digital low-pass filter with outlier rejection&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/Smoothing&quot;&gt;David A. Mellis and Tom Igoe: Smoothing tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/Average&quot;&gt;Majenki: Average Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;signal-smoothing libraries at github:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/AsheeshR/Microsmooth&quot;&gt;AsheeshR / Microsmooth&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/jeroendoggen/Arduino-signal-filtering-library&quot;&gt;jeroendoggen: Arduino-signal-filtering-library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/karlward/Filter&quot;&gt;karlward: Arduino data filtering library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/sebnil/FIR-filter-Arduino-Library&quot;&gt;sebnil: FIR-filter-Arduino-Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/daPhoosa/MedianFilter&quot;&gt;daPhoosa: MedianFilter&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/arc12/LibSimpleFilters&quot;&gt;arc12: A Collection of Digital Signal Filters (intended for use with Arduino)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/sebnil/Selfbalancing-robot&quot;&gt;sebnil: Selfbalancing robot in Arduino. Implemented with PID controllers, FIR filters, complementary filter.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Would something like this work in your robot?&#xA;(The median-of-3 requires very little CPU power, and hence fast):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;median_filter.ino&#xA;2014-03-25: started by David Cary&#xA;*/&#xA;&#xA;int median_of_3( int a, int b, int c ){&#xA;    int the_max = max( max( a, b ), c );&#xA;    int the_min = min( min( a, b ), c );&#xA;    // unnecessarily clever code&#xA;    int the_median = the_max ^ the_min ^ a ^ b ^ c;&#xA;    return( the_median );&#xA;}&#xA;&#xA;int newest = 0;&#xA;int recent = 0;&#xA;int oldest = 0;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    // read first value, initialize with it.&#xA;    oldest = random(200);&#xA;    recent = oldest;&#xA;    newest = recent;&#xA;    Serial.println(&quot;median filter example: &quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // drop oldest value and shift in latest value&#xA;    oldest = recent;&#xA;    recent = newest;&#xA;    newest = random(200);&#xA;&#xA;    Serial.print(&quot;new value: &quot;);&#xA;    Serial.print(newest, DEC);&#xA;&#xA;    int median = median_of_3( oldest, recent, newest );&#xA;&#xA;    Serial.print(&quot;smoothed value: &quot;);&#xA;    Serial.print(median, DEC);&#xA;    Serial.println(&quot;&quot;);&#xA;&#xA;    delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-03-26T17:37:55.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="931" PostTypeId="2" ParentId="929" CreationDate="2014-03-26T17:39:33.920" Score="14" Body="&lt;p&gt;The short answer is that you have &lt;strong&gt;100 miliseconds&lt;/strong&gt; to respond to the user if you want them to feel the action occurred instantaneously.&lt;/p&gt;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://www.nngroup.com/articles/author/jakob-nielsen/&quot; rel=&quot;noreferrer&quot;&gt;Jacob Nielsen&lt;/a&gt; in his book &lt;a href=&quot;http://www.nngroup.com/books/usability-engineering/&quot; rel=&quot;noreferrer&quot;&gt;Usability Engineering&lt;/a&gt;, from 1993, which is considered an important reference in Systems Usability and User Experience:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;0.1 second&lt;/strong&gt; is about the limit for having the user feel that the system is reacting instantaneously, meaning that no special feedback is necessary except to display the result.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;He also mentions that this basic advice regarding response times has been about the same for many decades [Miller 1968; Card et al. 1991].&lt;/p&gt;&#xA;&lt;p&gt;I've taken this citation from this article: &lt;a href=&quot;http://www.nngroup.com/articles/response-times-3-important-limits/&quot; rel=&quot;noreferrer&quot;&gt;Response Times: The 3 Important Limits&lt;/a&gt;, also writen by Jacob Nielsen.&lt;/p&gt;&#xA;&lt;p&gt;Note that in this time you must include all time taken to read the button press and give feedback to the user.&lt;/p&gt;&#xA;&lt;p&gt;Other response time thresholds that are important for user experience, from the same source, but that were not mentioned directly by the OP are:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;1.0 second is about the limit for the user's flow of thought to stay uninterrupted, even though the user will notice the delay. Normally, no special feedback is necessary during delays of more than 0.1 but less than 1.0 second, but the user does lose the feeling of operating directly on the data.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10 seconds is about the limit for keeping the user's attention focused on the dialogue. For longer delays, users will want to perform other tasks while waiting for the computer to finish, so they should be given feedback indicating when the computer expects to be done. Feedback during the delay is especially important if the response time is likely to be highly variable, since users will then not know what to expect.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-27T03:50:41.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="932" PostTypeId="2" ParentId="926" CreationDate="2014-03-26T17:55:03.483" Score="15" Body="&lt;p&gt;Well, it depends on what you have attached to the Arduino. If you are using the pins to do things you will definitely require more current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;strong&gt;ONLY want to power the Arduino&lt;/strong&gt;, then I calculated what I think it should be below. (You should also check with someone who owns this device for an experimental value, and not just a calculated value. )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the datasheet (fig 30-8, p 319), I would say the the processor will draw around 2.4 mA at 5 volts.&lt;br&gt;&#xA;&lt;a href=&quot;http://www.atmel.com/images/doc2545.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.atmel.com/images/doc2545.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB chip draws around 15 mA depending on several things (p 18)&#xA;&lt;a href=&quot;http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have 2 LEDs with 680 ohm resistors. (Assuming 2 volt drop for each led)&#xA;(5-2)/680  = around 4 mA per led.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So depending on how much you use the serial port, and the LEDs I would guess around (2.4 + 15 + 4*4) = 33.4 mA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;33.4 mA * 5V  = 0.167 Watts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect you want to know to the &lt;strong&gt;total amount of power the Arduino can source&lt;/strong&gt;, which is a bit harder to calculate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins can provide up to 200 mA. (p 303 &lt;a href=&quot;http://www.atmel.com/images/doc2545.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.atmel.com/images/doc2545.pdf&lt;/a&gt;)&#xA;So 33.4 + 200 = 233.4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also add a 20% safety margin (around 50 mA)&lt;br&gt;&#xA;So I would want a 280 mA supply, if I was going to attach the Arduino to different things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;280 mA * 5 = 1.4 Watts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if my numbers are way off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: Be careful making your own supply. It is critical that the voltage be very stable. An unstable supply can/will destroy an Ardiuno. I suggest using a &lt;a href=&quot;http://en.wikipedia.org/wiki/Linear_regulator&quot; rel=&quot;nofollow noreferrer&quot;&gt;linear regulator&lt;/a&gt;, like the &lt;a href=&quot;http://www.fairchildsemi.com/ds/LM/LM7805.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;LM7805&lt;/a&gt;. or maybe the &lt;a href=&quot;http://www.fairchildsemi.com/ds/LM/LM317.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;LM317&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="815" LastEditorUserId="-1" LastEditDate="2020-01-29T15:23:21.640" LastActivityDate="2020-01-29T15:23:21.640" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="933" PostTypeId="2" ParentId="920" CreationDate="2014-03-26T19:24:50.607" Score="0" Body="&lt;p&gt;This sounds like baud-rate mismatch. These dongles don't have a reset ability; they remember their most recent settings. &lt;a href=&quot;https://electronics.stackexchange.com/a/103868/3361&quot;&gt;See my answer&lt;/a&gt; to another user having trouble communicating with one these.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-03-26T19:24:50.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="934" PostTypeId="2" ParentId="876" CreationDate="2014-03-26T20:20:31.750" Score="4" Body="&lt;p&gt;&lt;strong&gt;Heating Controller&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You know how it is - you set the heating to come on at a certain time and how many days do you work late and it's been on full bore for hours, or you go away for a few days and forget to turn it off? Or the rare occasion that you get home early and the house is cold? I decided that the simple way to get around this was to build a device that would allow me to turn my heating on or off by text message / sms. It would be in addition to the existing control system so as not to lose the flexibility which that can provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The project consists of a few major parts: an Arduino Uno clone, a Seeedstudio GSM shield, a DHT22 temperature sensor and a 25 amp SSR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The existing heating controls are set to 'Off' and the new controller is wired up to override them. The Uno is programmed to respond to three different messages - On, Off and Query. In the case of the latter the unit will read the DHT22 and reply to the sender with the current temperature and the status of the unit (on or off). If the command is either On or Off then it will respond with a confirmation of the action carried out. Once messages have been acted upon they are deleted; any messages that do not conform to the specific message structure are left in the SIM card memory and can be examined later if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power to the unit is supplied by a five volt three amp switch mode power supply. As the power pins on the Arduino are simply exposing the board's internal 5v bus I decided to power the ensemble through these and configure the shield to draw  power from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The unit has three status LEDs. One green one to indicate that there is power, a blue one to indicate that the GSM board is 'live' and a red one to indicate the status of the heating. These are in addition to the status LEDs provided on the Arduino and shield. There is also a push button switch that allows manual control of the heating, with a 100nF capacitor to handle the debounce. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Next:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much of the code relies upon good old delay() to give the shield enough time to perform its actions. I plan to improve the code so that it waits for confirmation from the shield rather than assuming that it has done what it was told to within the time allocated! I will also add a 'still alive' feature - at fixed intervals turn off the blue LED, send the AT command to the shield and on an acknowledgement turn the LED on again. The shield is under software control so if it fails to respond then turn it off and back on again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole ensemble is to be mounted in a suitable enclosure and mounted adjacent to the existing controller. I have an internally illuminated push button switch that I will use instead of separate switch and red LED to handle the override.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer term I'm planning to add an RTC, a 20 x 4 LCD and additional push buttons to allow the unit to be programmed and act as a time switch as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prototyping has already started!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is something slightly decadent about waking up on a cold winter's rest day, sending a text message / sms to turn the heating on, and rolling over and going back to sleep for an hour! And when you realise that you haven't turned it off on a night you can do so from the comfort of your bed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yYGiv.jpg&quot; alt=&quot;Controller Image 1&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/raCwl.jpg&quot; alt=&quot;Controller Image 2&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="781" LastActivityDate="2014-03-26T20:20:31.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="935" PostTypeId="1" AcceptedAnswerId="936" CreationDate="2014-03-26T20:44:02.157" Score="10" ViewCount="6398" Body="&lt;p&gt;I have done quite a few projects with Arduino, but have never done more than a &quot;Hello World&quot; in C. I am writing my first library, and a lot of the object oriented stuff is going over my head. Anyway, my library is working as it is supposed to, I pass a float to my function and it formats it properly and sends it out over serial. However, I implemented it in a clunky way. The &lt;a href=&quot;http://arduino.cc/en/Reference/APIStyleGuide&quot;&gt;Arduino API Style Guide&lt;/a&gt; mentions a way that seems much better:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When using serial communication, allow the user to specify any Stream object, rather than hard-coding &quot;Serial&quot;. This will make your library compatible all serial ports on Mega and the Due, and can also use alternate interfaces like SoftwareSerial. The Stream object can be passed to your library's constructor or to a begin() function (as a reference, not a pointer). See Firmata 2.3 or XBee 0.4 for examples of each approach.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can anybody elaborate on how to do this, or show me some code?&lt;/p&gt;&#xA;" OwnerUserId="819" LastEditorUserId="819" LastEditDate="2014-03-26T20:49:48.390" LastActivityDate="2014-03-27T08:35:04.267" Title="Writing First Library - Serial Stream Object" Tags="|serial|c++|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="936" PostTypeId="2" ParentId="935" CreationDate="2014-03-26T23:18:58.250" Score="10" Body="&lt;p&gt;Here is a simple example (built and tested with a mega2560), with a class that can be passed a Stream object, and sends a Hello over this generic stream object. When constructing the object, you can pass the Stream object you want to actually communicate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;class MyProtocol&#xA;{&#xA;public:&#xA;    MyProtocol(Stream&amp;amp; s):serial(s){}&#xA;    void send(){&#xA;        serial.println(&quot;Hello&quot;);&#xA;    }&#xA;private:&#xA;    Stream&amp;amp; serial;&#xA;};&#xA;&#xA;MyProtocol p(Serial);&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(1000);&#xA;    p.send();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: The serial.println() is not the Serial global object, note the lower case, it is the internal Stream class variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are confused with the OO and classes, take into account (while you gain more knowledge about it) that this approach can be also used with a simple function, you can pass the serial parameter. Furthermore, it is not necessary to hardwire the Serial interface for ever, you can in fact switch in run time and use a different channel depending on some condition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;void send(Stream&amp;amp; serial){&#xA;    serial.println(&quot;Hello&quot;);&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(1000);&#xA;    if(someCondition)&#xA;        send(Serial);&#xA;    else&#xA;        send(Serial1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="666" LastEditorUserId="666" LastEditDate="2014-03-27T08:35:04.267" LastActivityDate="2014-03-27T08:35:04.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="937" PostTypeId="2" ParentId="876" CreationDate="2014-03-27T00:16:39.127" Score="7" Body="&lt;p&gt;I think this kind of barely fits within the rules, but it's interesting enough that I figure I'd post it anyways.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;High-Precision, GPS-Synchronized timestamp generator for data-acquisition purposes.&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is a rather interesting project that is intended to be used for providing a easy way of synchronizing multiple independent data-acquisition systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I work in a research lab, and we often have instruments that have multiple independent data-acquisition systems, which can be physically separated by as much as 50 feet. We need to be able to correlate the time at which samples from each system were taken, which can be difficult if you want to resolve sampling-times to a great degree of precision. Using something like a USB data-acquisition system, just the USB latency can introduce several hundred milliseconds of unknown latency, that can vary from acquisition to acquisition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The previous solution was a 24-bit parallel counter that was simply bussed everywhere, requiring an enormous wiring harness, and was kind of a pain in the butt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This system uses a &lt;a href=&quot;https://www.u-blox.com/de/lea-6t.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;specialized timing GPS module&lt;/a&gt; that can synthesize arbitrary frequency clocks, that are phase and frequency locked to the atomic clocks in the GPS satellites. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MCU is responsible for tying together the GPS data messages (I had to heavily extend and optimize a existing protocol parser for the GPS data). The GPS is configured to use a proprietary binary protocol, and it's all parsed by the parser I wrote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The project has gone through a number of revisions (pictured below).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Revisions!&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Zt8N8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Rev 1: Never worked, due to the fact that I was initially hoping to use a software dPLL off a much less expensive GPS, to synthesize a higher-frequency clock from only the 1 PPS output. It's probably possible to make it work, but the time-investment just made it not worthwhile. (and I'm too crappy a coder)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Used a parallax propeller MCU. The lack of decent compiled languages was a major issue as well.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/m40P9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Rev 2: Shifted to a ATmega2560. Worked, had lots of funky design aspects inherited from the first rev. Primarily, the continued use of shift-registers for the 32-bit output, despite the more then sufficient number of IO on the ATmega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First board that ran Optiboot, and was actually programmed entirely using the standard Arduino toolchain, before I got irritated with it and started modifying the toolchain to better suit my purposes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PjfGb.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Rev 3: Also worked. The bodged wiring is because this board incorporated a built-in USB hub to reduce the number of required USB ports (the FTDI interface requires 1 USB, and the GPS has a USB interface as well). Unfortunately, the GPS wouldn't properly enumerate, though the FTDI device worked fine, and I've used this hub elsewhere without issue. Weird.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a proper USB debugger, so I just dropped the USB hub entirely, rather then trying to fix the issue. The GPS usb isn't &lt;em&gt;really&lt;/em&gt; used much outside of set-up anyways.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/18PyD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Rev 4: Semi-final ATmega2560 version. Added a LCD for GPS status, fiddled with LEDs and so forth. Also, better footprints for the possible super-capacitors for maintaining the GPS status when not powered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the last Optiboot version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;MStime&lt;/code&gt; is the &lt;code&gt;MSTOW&lt;/code&gt;, or Millisecond-Time-Of-Week, which is the name of the GPS data value that is output on the timestamp out. It's a 32-bit variable that increments once per milliseond, and rolls over each week. It's a more obscure part of the GPS standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ITOW&lt;/code&gt; is another GPS-related value, being a value that corresponds to the 1PPS signal. The correlation between the two isn't properly reflected on the LCD, since I do not have the CPU time to update the LCD at the rate I'd like. This was actually one of the major things that improved in the upgrade to the Xmega devices.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qLfpS.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Rev 5: Complete architecture switch. Now uses a ATxmega128A1U processor. Not really &quot;Arduino&quot; at all anymore, but the ability to have multiple interrupt levels on the xmega processor series allowed me to considerably improve the code structure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two bodge-wires are from me doing some experimentation, the board worked fine without them as well.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Looking forward:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Rev 6!&#xA;&lt;img src=&quot;https://i.stack.imgur.com/zdher.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;Add the ability to use different LCD sizes, more ESD protection on GPS antenna connection (that was an issue), ability to use a CR2032 battery for maintaining the GPS clock instead of super-capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, much better labeling of debug and status LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fdMJZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;And bonus Nyan-Cat!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lJSUA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(These boards are out for fabrication right now. When I get them, I'll add pictures of the real board.)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I did some long-duration testing between two of the ATmega2560 boards, and over 72 hours, the RMS time-error between the two units was ~20 uS. This was with two completely independent antennas too. My design goal was &amp;lt; 1 ms, so I'm pretty damn happy with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the whole, I think this does a good job illustrating how Arduino can be a useful tool for &#xA;early prototyping for &quot;real&quot; products/systems. I use it for getting an initial test-version running with minimal effort, and when I'm confident the &lt;em&gt;idea&lt;/em&gt; will work, I actually put the work in to migrate away to a completely custom, purpose-specific implementation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Design files:&lt;br&gt;&#xA;&lt;a href=&quot;https://fake-server.no-ip.org/svn/FPGAStuff/DAQ%20systems/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fake-server.no-ip.org/svn/FPGAStuff/DAQ%20systems/&lt;/a&gt;&lt;br&gt;&#xA;(In the &quot;GPS Timestamp&quot; series of directories).&lt;br&gt;&#xA;(Note: Files are from Altium Designer. The are &lt;strong&gt;not&lt;/strong&gt; eagle files). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source code:&lt;br&gt;&#xA;&lt;a href=&quot;https://fake-server.no-ip.org/svn/Programming/Code/AVR/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://fake-server.no-ip.org/svn/Programming/Code/AVR/&lt;/a&gt;&lt;br&gt;&#xA;Again, in the &quot;gpsTimeStamp&quot; series of directories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the crappy cell-phone pictures.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-03-28T02:34:55.230" LastActivityDate="2014-03-28T02:34:55.230" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="938" PostTypeId="2" ParentId="929" CreationDate="2014-03-27T00:49:59.517" Score="3" Body="&lt;p&gt;It's commonly known that people are unable to perceive changes when they happen underneath 10ms after their action. This responsiveness will result in an experience that has recently mostly been described as &quot;snappy&quot;. It's noticeable but for users it's hard to put a name on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want perfection, take about 15ms of delay. If you want really good, take 100 ms of delay. 100ms is 50ms on average, and will certainly pass for people.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The application and the expected response time is vital too. A sliding door or elevator is given very large tolerance (as the physical object will always take a lot more time) whereas ticket vending machine interfaces are not given any time at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upper limit for polling would be around 1500ms. Around there people will always notice it is slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This data is purely personal experience as a gamer and programmer. YMMV and remember that just trying it yourself is the best way to find out how it feels. The only &quot;scientific&quot; answer is the &amp;lt;10 milliseconds, beyond that it's about the ability to perceive the delay (which varies per person and moment) and the tolerance of the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, you can try fluctuating the delays in order to conserve battery or CPU time when the interface is not being used. The user-action, the faster the polling. When the application is doing it's thing, poll very slowly. Better to poll when it matters!&lt;/p&gt;&#xA;" OwnerUserId="627" LastActivityDate="2014-03-27T00:49:59.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="939" PostTypeId="1" AcceptedAnswerId="1037" CreationDate="2014-03-27T02:22:22.547" Score="2" ViewCount="2808" Body="&lt;p&gt;I hope this question is specific enough. Basically I want to know if it matters a great deal what kind of Motor Driver IC(s) or pre-assembled kits you use to drive a Unipolar Stepper Motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: Can the following Driver be used to control this Stepper Motor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Driver: &lt;a href=&quot;https://www.sparkfun.com/products/9670&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9670&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motor: &lt;a href=&quot;http://www.jaycar.com.au/productView.asp?ID=YM2754&quot; rel=&quot;nofollow&quot;&gt;http://www.jaycar.com.au/productView.asp?ID=YM2754&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="826" LastActivityDate="2014-04-01T05:27:44.073" Title="Which type of Motor Drivers to drive Unipolar Stepper Motors?" Tags="|motor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="940" PostTypeId="1" CreationDate="2014-03-27T02:25:16.213" Score="13" ViewCount="7619" Body="&lt;p&gt;I am finishing up a project- an LED game alarm clock. Seeing as this is a clock, I need to have a way to conserve power, which right now my Uno R3+ is eating up like a politician. My question is, how do I turn the screen off, or turn the back-light off using software only on a Hitachi HD44780 16x2 LCD screen? Or how do I set a sleep mode on one component? The way I plan on turning it off is with an ultrasonic range finder, if I get close it turns on the screen. If anything I say doesn't make sense, ask me to clarify, I'm in a bit of a rush.&lt;/p&gt;&#xA;" OwnerUserId="825" LastActivityDate="2014-03-27T03:22:47.667" Title="Changing the brightness on a Hitachi HD44780 LCD screen" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="941" PostTypeId="2" ParentId="940" CreationDate="2014-03-27T03:20:14.087" Score="5" Body="&lt;p&gt;Instead of tying the backlight directly to V+ and GND, connect it to a PWM pin (you may need to use a separate driver if the pin cannot source/sink enough current). This will allow you to control the brightness via &lt;code&gt;analogWrite()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn the LCD display off (&lt;code&gt;LiquidCrystal::noDisplay()&lt;/code&gt;) when not actively in use. The contents will remain in memory but the LCD segments will not be driven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set the various bits in the &lt;code&gt;PRR&lt;/code&gt; register to disable any peripherals not it use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &lt;em&gt;don't forget to sleep the CPU when it doesn't need to run&lt;/em&gt;. See the &quot;Power Management and Sleep Modes&quot; section of the datasheet for more information about this and the &lt;code&gt;PRR&lt;/code&gt; register, as well as the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html&quot;&gt;&lt;code&gt;&amp;lt;avr/sleep.h&amp;gt;&lt;/code&gt; documentation&lt;/a&gt; for AVR Libc.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-27T03:20:14.087" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="942" PostTypeId="2" ParentId="940" CreationDate="2014-03-27T03:22:47.667" Score="8" Body="&lt;p&gt;Place a transistor in series with a 33R resistor between the LCD pin 16 (backlight ground) and GND and switch the transistor on and off with a digital pin. That way you'll be able to turn the backlight on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have a finer control over brightness if you put a PWM pulse on said pin. Just call &lt;code&gt;analogWrite(D3, value)&lt;/code&gt; where &lt;code&gt;value&lt;/code&gt; is the desired brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schematics is below. It's from &lt;a href=&quot;http://freetronics.com/16x2lcd&quot; rel=&quot;noreferrer&quot;&gt;Freetronics 16x2 LCD SHield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/g0D2T.png&quot; alt=&quot;LCD Brightness control&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-03-27T03:22:47.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="943" PostTypeId="1" CreationDate="2014-03-27T05:13:29.857" Score="9" ViewCount="3327" Body="&lt;p&gt;I have a project that I'm currently working on. We have built a green wall, wich consists of plants on a wall&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iIhSW.jpg&quot; alt=&quot;Green wall&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, we have a pump situated at the bottom that waters all the plants. There is an arduino board that decides when to put the pump on. Powering it is a solar panel and wind turbine. We want to know how much energy we have saved by using the solar panel and turbine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I measure the amount of energy, in Wh, used from 00h00 that day? Is there a library? Or is this not possible with Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To clear up some things&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, the pump is not fueled directly by the Arduino pin. We are using a motor shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, there is an accumulator in the circuit. The solar and wind power recharge a battery which in turn powers the components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know the entire energy consumed, not just the pump.&lt;/p&gt;&#xA;" OwnerUserId="76" LastEditorUserId="-1" LastEditDate="2014-04-03T03:57:22.923" LastActivityDate="2014-04-03T03:57:22.923" Title="How to measure total energy usage of an arduino board" Tags="|programming|sensors|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="944" PostTypeId="2" ParentId="943" CreationDate="2014-03-27T06:17:07.867" Score="3" Body="&lt;p&gt;In order to calculate the amount of energy you have to calculate the power first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relation is &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Energy = (Power * Time of usage)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to calculate the power?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage for each device in the system is constant. What changes is the current withdrawal in each component in the project.&#xA;The main thing you have here is the pump and how much does it consume current.&#xA;Usually, you will have on the &quot;plate&quot; of the pump the current withdrawal of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say it consumes 2 Amps.&#xA;If that is not available there, use a DMM &quot;Digital Multimeter&quot; and connect in series with the pump and measure the amount of current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are any other major/important components in your project just calculate the current withdrawal from them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now add up all the currents and say you ended up with 2 Amps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all the components are operating at the same voltage, just multiply the total amount of current withdrawal by the voltage.&#xA;WHY?&#xA;Because:&#xA;P(power) = V(voltage)   * I(current)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, just find the power of each component.&#xA;Add up all the powers of all you components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you will only have to calculate the energy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E(Energy) = Power * time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Time here refers to how long is your system working?&#xA;Is it a full day, couple of hours. IT doesn't matter. Usually to make things easier use time (in terms of hours).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say your power ended up with 3kW &lt;em&gt;kilo Watt&lt;/em&gt;&#xA;You've run the system for 2 hours every day&#xA;Energy = 3 * 2 = 6 kWh&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've kept this for a full month.&#xA;Energy save in a month = 180kWh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just find out how much do the ministry cost for each kWh, and you'll know how much money you've saved!&lt;/p&gt;&#xA;" OwnerUserId="467" LastEditorUserId="83" LastEditDate="2014-03-27T07:04:44.743" LastActivityDate="2014-03-27T07:04:44.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="945" PostTypeId="2" ParentId="910" CreationDate="2014-03-27T08:42:19.510" Score="0" Body="&lt;p&gt;Usually, this kind of issue is the result of the several times by time unity of loop statements execution, with the baudrate defined for your serial i/o it's very possible that the flush are override by the new information input and the result are the &quot;garbage&quot; on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my sketches, ever I put &quot;idle function calls&quot;  in some points of the code to avoid this and works succesfully.&lt;/p&gt;&#xA;" OwnerUserId="797" LastActivityDate="2014-03-27T08:42:19.510" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="946" PostTypeId="1" AcceptedAnswerId="949" CreationDate="2014-03-27T12:00:56.460" Score="11" ViewCount="18161" Body="&lt;p&gt;I would like to know if there is a way to call functions that are contained within C files using an Arduino sketch? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My C file declares and defines a function. To save putting the messy function definition into my Arduino sketch, I'd like to call the function straight from the sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a standard way to do this using Arduino and C?&#xA;Here is the sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;crc16.h&quot;;&#xA;&#xA;void setup(){&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  CalculateCRC16(&quot;&amp;lt;09M&quot;, 4);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is the trimmed down C file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;&#xA;uint16_t crctable[256] =&#xA;{&#xA;    0x0000, 0x1189,.....&#xA;&#xA;&#xA;&#xA;uint16_t // Returns Calculated CRC value&#xA;CalculateCRC16( // Call example CalculateCRC16(&quot;&amp;lt;09M&quot;, 4);&#xA;    const void *c_ptr, // Pointer to byte array to perform CRC on&#xA;    size_t len)        // Number of bytes to CRC&#xA;{&#xA;&#xA;    uint16_t crc = 0xFFFF // Seed for CRC calculation&#xA;    const uint8_t *c = c_ptr;&#xA;&#xA;    while (len--)&#xA;        crc = (crc &amp;lt;&amp;lt; 8) ^ crctable[((crc &amp;gt;&amp;gt; 8) ^ *c++)];&#xA;&#xA;    return crc;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="755" LastEditorUserId="755" LastEditDate="2014-03-27T14:14:13.763" LastActivityDate="2021-02-21T21:02:28.653" Title="How to call C functions from Arduino sketch?" Tags="|arduino-uno|software|c|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="947" PostTypeId="2" ParentId="946" CreationDate="2014-03-27T13:30:18.870" Score="1" Body="&lt;p&gt;Yes, just copy its declaration line in your sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot; {&#xA;    void myfunction(int arg);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-27T13:30:18.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="948" PostTypeId="2" ParentId="946" CreationDate="2014-03-27T14:31:45.590" Score="4" Body="&lt;p&gt;Your CRC function can easily be converted to C++ so that it can go into a *.cpp file. All you need to do is use an explicit cast when you initialise your &lt;code&gt;c&lt;/code&gt; pointer. Here's the 'proper' C++ way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t *c = static_cast&amp;lt;const uint8_t*&amp;gt;(c_ptr);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, an old C-style cast would also work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t *c = (const uint8_t*)c_ptr;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is basically that C can be a little more permissive about letting you convert pointers implicitly between types. To do it in C++, you need to tell the compiler explicitly that the conversion is intentional.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-27T14:31:45.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="949" PostTypeId="2" ParentId="946" CreationDate="2014-03-27T14:33:40.687" Score="11" Body="&lt;p&gt;You can extern &quot;C&quot; #include like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot;{&#xA;#include &quot;crc16.h&quot;&#xA;};&#xA;&#xA;void setup(){&#xA;}&#xA;&#xA;void loop(){&#xA;  CalculateCRC16(&quot;&amp;lt;09M&quot;, 4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the crc16.h file could be (some minor fixes, the #pragma once, a cast):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#pragma once&#xA;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;&#xA;uint16_t crctable[2] ={ 0x0000, 0x1189};&#xA;&#xA;uint16_t CalculateCRC16( // Call example CalculateCRC16(&quot;&amp;lt;09M&quot;, 4);&#xA;    const void *c_ptr, // Pointer to byte array to perform CRC on&#xA;    size_t len)        // Number of bytes to CRC&#xA;{&#xA;    uint16_t crc = 0xFFFF; // Seed for CRC calculation&#xA;    const uint8_t *c = (const uint8_t *)c_ptr;&#xA;&#xA;    while (len--)&#xA;        crc = (crc &amp;lt;&amp;lt; 8) ^ crctable[((crc &amp;gt;&amp;gt; 8) ^ *c++)];&#xA;&#xA;    return crc;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="666" LastActivityDate="2014-03-27T14:33:40.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="950" PostTypeId="1" AcceptedAnswerId="953" CreationDate="2014-03-27T16:17:04.193" Score="2" ViewCount="3431" Body="&lt;p&gt;I have made this small program to lighten up in sequence 8 LEDs, it starts fine, but it stops working after a minute or so and the first 2 LEDs stay permanently ON, its like the chip stoped, here is the code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Initialize an array with all 8 leds&#xA;// and give them the corresponding&#xA;// digital number.&#xA;const byte led[8] = {0,1,2,3,4,5,6,7};&#xA;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;&#xA;  // initialize all 8 digital I/O pins as outputs.&#xA;  for (byte i = 0; i&amp;lt;9; i++) {&#xA;    pinMode(led[i], OUTPUT);&#xA;  }&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void left (void);&#xA;void right (void);&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  right();&#xA;  left();&#xA;&#xA;}&#xA;&#xA;&#xA;void left (void) {&#xA;  for (byte i = 0; i&amp;lt;9; i++) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(50);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&#xA;void right (void) {&#xA;  for (byte i = 8; i&amp;gt;0; i--) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(50);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a very old arduino duemilanove.&lt;/p&gt;&#xA;" OwnerUserId="832" LastEditorUserId="832" LastEditDate="2014-03-27T16:30:41.317" LastActivityDate="2014-03-28T12:12:12.363" Title="Program stops working after a minute" Tags="|led|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="951" PostTypeId="2" ParentId="950" CreationDate="2014-03-27T16:45:06.363" Score="3" Body="&lt;p&gt;Your loop conditions aren't quite right, which could be resulting in undefined behaviour. I highly doubt it would cause it to stop working spontaneously, but it's possible in theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In each loop that counts upwards, you basically need to stop &lt;em&gt;before&lt;/em&gt; the counter reaches 8. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (byte i = 0; i&amp;lt;8; i++) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it's &lt;code&gt;i&amp;lt;8&lt;/code&gt; instead of &lt;code&gt;i&amp;lt;9&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is that the array is only 8 elements long, so the indices run from 0 to 7 (inclusive). Currently, your loops are going all the way up to and including 8, which means it's trying to read past the end of your array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to fix that in &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;left()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The loop that goes downwards in &lt;code&gt;right()&lt;/code&gt; is a little more difficult. At the moment, it runs through indices 8 to 1, meaning it has the same problem of reading past the array. However, it also never actually reaches index 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's harder to fix because &lt;code&gt;byte&lt;/code&gt; is an unsigned type, so you can't use &lt;code&gt;i&amp;gt;=0&lt;/code&gt; as your condition (as it will never terminate). Personally, I would rewrite the loop to count upwards, but then reverse the index order inside the loop, so that 0 becomes 7, and so on. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (byte i = 0; i&amp;lt;8; i++) {&#xA;    digitalWrite(led[7-i], HIGH);&#xA;    delay(50);&#xA;    digitalWrite(led[7-i], LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like I said, I doubt this will actually solve your problem. It's worth trying though.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-27T16:45:06.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="953" PostTypeId="2" ParentId="950" CreationDate="2014-03-27T18:42:08.517" Score="3" Body="&lt;p&gt;You had several problems with your loop conditions.  Arrays are 0 indexed. If we declare &lt;code&gt;const byte led[8]&lt;/code&gt;, &lt;code&gt;led[0]&lt;/code&gt; is the first element and &lt;code&gt;led[7]&lt;/code&gt; is the 8th and last element.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in &lt;code&gt;void right()&lt;/code&gt;, you declared &lt;code&gt;i&lt;/code&gt; as a &lt;code&gt;byte&lt;/code&gt; which is an 8-bit, unsigned number from 0 to 255. While you wrote the conditional to be &lt;code&gt;i&amp;gt;0&lt;/code&gt;, it needs to be &lt;code&gt;i&amp;gt;-1&lt;/code&gt; or &lt;code&gt;i&amp;gt;=0&lt;/code&gt;. So, if we change the coditional and keep &lt;code&gt;i&lt;/code&gt; as a &lt;code&gt;byte&lt;/code&gt; the loop would decrement &lt;code&gt;i&lt;/code&gt; like 8,7,6,5,4,3,2,1,0,255,254... forever.  So instead, &lt;code&gt;i&lt;/code&gt; should be declared as a &lt;code&gt;char&lt;/code&gt; which is an 8-bit, signed number from -128 to 127.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Initialize an array with all 8 leds&#xA;// and give them the corresponding&#xA;// digital number.&#xA;const byte led[8] = {0,1,2,3,4,5,6,7};&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  // initialize all 8 digital I/O pins as outputs.&#xA;  for (byte i = 0; i&amp;lt;8; i++) {&#xA;    pinMode(led[i], OUTPUT);&#xA;  }&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void left (void);&#xA;void right (void);&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  right();&#xA;  left();&#xA;}&#xA;&#xA;void left (void) {&#xA;  for (byte i = 0; i&amp;lt;8; i++) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(50);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&#xA;void right (void) {&#xA;  for (char i = 7; i&amp;gt;=0; i--) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(50);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-03-27T18:42:08.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="954" PostTypeId="1" AcceptedAnswerId="970" CreationDate="2014-03-27T19:55:06.863" Score="7" ViewCount="13962" Body="&lt;p&gt;I just got my Arduino UNO and I'm trying to upload the blink example but the upload fails with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ioctl(&quot;TIOCMSET&quot;): Broken pipe&#xA;ioctl(&quot;TIOCMSET&quot;): Broken pipe&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;ioctl(&quot;TIOCMSET&quot;): Broken pipe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried both Arduino IDE 1.0.1 (which I installed via my package manager) as well as version 1.0.5 which I downloaded from the arduino.cc website. I'm running Ubuntu Linux 12.10 if that makes a difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any and all help in getting my arduino up and running!&lt;/p&gt;&#xA;" OwnerUserId="836" LastActivityDate="2014-04-04T20:57:31.690" Title="&quot;Broken Pipe&quot; when uploading to Arduino UNO" Tags="|arduino-uno|uploading|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="955" PostTypeId="1" CreationDate="2014-03-27T21:24:40.537" Score="2" ViewCount="209" Body="&lt;p&gt;I've seen that there are many resources on programming basis for arduino for people that have some electronics basis or background. Are there similar resources on the opposite? Basics electronics for programmers? Things that cover:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How to read schematics (different elements that appear there)&lt;/li&gt;&#xA;&lt;li&gt;What different pins are used for (yeah, even on a more basic level than &lt;a href=&quot;http://arduino.cc/en/Reference/Board#.UzSV3WR5NUk&quot; rel=&quot;nofollow&quot;&gt;arduino documentation&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;General idea of how a protoboard/protoshield works and how to connect components&lt;/li&gt;&#xA;&lt;li&gt;General common components (resitors, capacitors...) and when and how to use them...&lt;/li&gt;&#xA;&lt;li&gt;Safety rules, what happens when you do something wrong&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="754" LastActivityDate="2014-03-29T07:55:21.433" Title="'Basic electronics' resources" Tags="|hardware|" AnswerCount="2" CommentCount="3" ClosedDate="2014-03-28T17:40:30.537" ContentLicense="CC BY-SA 3.0" />
  <row Id="958" PostTypeId="2" ParentId="876" CreationDate="2014-03-28T01:20:44.180" Score="4" Body="&lt;h1&gt;Serial Box&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A portable serial monitor in a box&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Sometimes it's useful for a device (Arduino or otherwise) to output some debug information via serial. That's great if you've got a computer on hand with an appropriate serial input. However, that's not always the case for a variety of reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This project is my attempt to address that problem by creating a portable Arduino-powered serial monitor, which I can hook-up to other devices in the field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default, it will simply display text in a scrollback format; i.e. text appears on the bottom line, and everything scrolls up to make room when more arrives. This means it should work very neatly with all sorts of generic devices. However, it will also be possible to use escape sequences to control the display more precisely, so that devices can also be programmed specifically to take advantage of its capabilities.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The design consists of a set of 4 alphanumeric LCD displays (16x2 characters each), aligned in a box something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/m8Les.jpg&quot; alt=&quot;3d mockup of the Serial Box design&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The displays are Epson EAX16027AR's, which unfortunately are not compatible with the standard Hitachi HD44780 driver. As such, I had to write &lt;a href=&quot;https://github.com/avid-insight/LiquidCrystalEAX&quot; rel=&quot;nofollow noreferrer&quot;&gt;my own library&lt;/a&gt; for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I chose to use these displays (rather than e.g. one large display) mainly because I just had them lying around, and wanted to do something interesting with them. I also thought it would be quite handy to be able to control each display independently for some applications (e.g. displaying different information on each one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of circuit design, the displays are connected in parallel, with chip select pins being used to direct data/commands to each one as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ATMega328 will be the brains of the final unit, with serial data coming from a TTL-level line (for connecting directly to the TX of a similar MCU), or optionally from an RS232 9-pin D-sub socket (for connecting to various other systems). The unit will also have a contrast dial, a button for clearing the display, and a button for initiating a self-test mode. In future, I'd like to add buttons which let the user move through a scrollback history too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a very preliminary circuit layout (I had a lot of trouble getting Fritzing to play nicely for some reason!). It includes an 8-bit SIPO shift register for driving the LCDs' data lines, which are shown in green. You can also see the chip select lines in orange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/plAfe.png&quot; alt=&quot;Preliminary circuit layout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, the project is still at the working prototype stage, driven from an Uno (clone) board. Below, you can see a photo of it in action, displaying text which was passed via serial from my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9xlB6.jpg&quot; alt=&quot;The prototype in action&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Source code&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm making my LCD library available on GitHub at the link below. Please note that it's at an early stage in development. In the near future, I intend to make it much more similar to the core LiquidCrystal library so that it's easier to transition between the two.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/avid-insight/LiquidCrystalEAX&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/avid-insight/LiquidCrystalEAX&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can find some basic code for my Serial Box prototype in the &quot;examples&quot; folder.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I think the project is coming along very nicely, and I was extremely pleased to get the prototype working. My main challenge is going to be mounting the whole thing in a box. I've already made a start on cutting out suitable holes for the displays, but I'm not very experienced at that sort of thing, and am finding it quite tricky to line everything up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll get there in the end though. It just may not look very pretty by the time I'm finished! :)&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-03-28T02:03:07.957" LastActivityDate="2014-03-28T02:03:07.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="959" PostTypeId="2" ParentId="757" CreationDate="2014-03-28T05:41:17.387" Score="10" Body="&lt;p&gt;Optiboot is about the smallest bootloader available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, there is a much more powerful (with inbuilt console for hardware testing, RAM and Flash contents checking, etc) bootloader with a more developed and robust stk500v2 communications protocol between avrdude and the AVR bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used it on the ATmega2560 and on the ATmega1284p. It works for both 3 byte and 2 byte program counter MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;https://sourceforge.net/projects/avrfreertos/files/AVRstk500v2_bootloader/&quot; rel=&quot;noreferrer&quot; title=&quot;STK500v2 Bootloader&quot;&gt;STK500v2 Bootloader&lt;/a&gt; version on &lt;a href=&quot;https://sourceforge.net/projects/avrfreertos/&quot; rel=&quot;noreferrer&quot; title=&quot;AVRfreeRTOS&quot;&gt;Sourceforge&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This bootloader is based the Peter Fleury STK500v2 bootloader, updated by Mark Sproul. I've made edits to have it supporting with the Goldilocks (an ATmega1284p) board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key feature is to use the &lt;strong&gt;STK500v2&lt;/strong&gt; protocol for uploading the Flash image to the Arduino. This protocol is more robust and gives better error capabilities than the &lt;strong&gt;avr109&lt;/strong&gt; protocol. As an aside the avr109 protocol is called &quot;Arduino&quot; in the Arduino world, because it toggles DTR (to reset the board and automatically enter the bootloader), and the STK500v2 protocol is called &quot;Wiring&quot; in the Arduino world, because of the same reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Fleury/Sproul STK500v2 bootloader is designed to work with the ATmega2560 which has a 3 byte program register, because of the larger Flash size. But, it also supports normal 2 byte boards (everything else really).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For boards with plenty of Flash (like Goldilocks 1284p), there is a &lt;strong&gt;hardware monitor&lt;/strong&gt; that can be used to query Flash, SRAM and hardware; you can check connections without additional code, and check the actual contents of Flash and EEPROM. Because the 1284p supports 2 USART, I added the ability to have debugging on &lt;strong&gt;USART1&lt;/strong&gt;, so that the upload process via &lt;strong&gt;USART0&lt;/strong&gt; isn't disturbed.&lt;/p&gt;&#xA;" OwnerUserId="844" LastEditorUserId="84" LastEditDate="2014-03-29T17:21:50.237" LastActivityDate="2014-03-29T17:21:50.237" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="960" PostTypeId="2" ParentId="955" CreationDate="2014-03-28T07:10:41.087" Score="1" Body="&lt;p&gt;This is an extract of an &lt;a href=&quot;http://m.dummies.com/DummiesArticle/Arduino-Projects-For-Dummies-Cheat-Sheet.id-379124.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;introductory book&lt;/a&gt; that shows basic schematic  components: &#xA;&lt;img src=&quot;https://media.wiley.com/Lux/21/379121.image0.jpg&quot; alt=&quot;Basic schematic components&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="754" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.267" LastActivityDate="2014-03-29T07:55:21.433" CommentCount="2" CommunityOwnedDate="2014-03-29T07:50:17.113" ContentLicense="CC BY-SA 3.0" />
  <row Id="961" PostTypeId="2" ParentId="955" CreationDate="2014-03-28T07:24:16.323" Score="2" Body="&lt;h1&gt;From zero to Arduino (maybe a HOWTO someday?)&lt;/h1&gt;&#xA;&lt;p&gt;Rule zero:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't overestimate the other Arduino users! They all were not born with this knowledge too.&lt;/li&gt;&#xA;&lt;li&gt;Never be too shy to ask!&lt;/li&gt;&#xA;&lt;li&gt;Making mistakes is ok as long as they trigger learning.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(-: short break :-)&lt;/p&gt;&#xA;&lt;p&gt;You'll find lots of HOWTOs and other tutorials in the wild wild web.&lt;/p&gt;&#xA;&lt;p&gt;I assume, the confusing thing is to read them in the wrong order.&lt;/p&gt;&#xA;&lt;p&gt;Forget your Arduino(s) for a while and start with reading about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;General common components (resitors, capacitors...) and when and how to use them...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This will at least partially answer:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Safety rules, what happens when you do something wrong&lt;/li&gt;&#xA;&lt;li&gt;How to read schematics (different elements that appear there)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If not already done:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Read about ANDs, ORs, NANDs, NORs, FLIPFLOPs...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This will show how their schematic symbols look like.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;...compare them to creating the same behaviour by programming (if,&#xA;and (&amp;amp;&amp;amp;), or (||), ...)&lt;/li&gt;&#xA;&lt;li&gt;Have a look at bit operations (&amp;amp;, |, ... on whole number variables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The programming up to this point can be done on your PC.&lt;/p&gt;&#xA;&lt;p&gt;After this, dedust your Arduino again and jump into:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What different pins are used for (yeah, even on a more basic level&#xA;than arduino documentation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(Happy end. At least for now.)&lt;/p&gt;&#xA;&lt;p&gt;(I make this a community wiki answer to invite others to expand this text.)&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-28T07:24:16.323" CommentCount="5" CommunityOwnedDate="2014-03-28T07:24:16.323" ContentLicense="CC BY-SA 3.0" />
  <row Id="962" PostTypeId="1" CreationDate="2014-03-28T07:31:56.483" Score="0" ViewCount="1165" Body="&lt;p&gt;I have programmed an IR remote control along with an LED and an 8bit 7segment on an Arduino Uno.&#xA;the segment displays the number I press via the remote, and the LED turns on and off&#xA;here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case 16738455:&#xA;  Serial.println(0);&#xA;  if (oldvalue == results.value){&#xA;    on(num0);&#xA;    delay(1000);&#xA;    on(num00);&#xA;    delay(1000);&#xA;    oldvalue = results.value;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;oldvalue stores the last value pressed, which is the DEC value of the buttons, num0 displays the number zero, and num00 turns all the segments off.&#xA;I want the 7segment to blink again when I press the same button again.&#xA;Can anyone help me with this? &#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="845" LastEditorUserId="42" LastEditDate="2014-03-28T07:55:19.817" LastActivityDate="2014-03-28T12:10:04.683" Title="7segment blink when the button is pressed" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="963" PostTypeId="2" ParentId="962" CreationDate="2014-03-28T11:39:54.723" Score="2" Body="&lt;p&gt;A simple solution would be to not worry about blinking as a piece of code, ie. remove those delays (I hate blocking code) and instead, if you are currently receiving a signal from the remote, do not display any number (or display your &lt;code&gt;num00&lt;/code&gt;). Once the value is received and processed, then display that number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way, whilst ever the remote button is down, the display will blank out, and the number will appear as soon as the number is released. If it's the same number, then you will see the number, see a blank display, and then see the same number again. Obviously, if it's a different number, the new number would be displayed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since most people would only press the remote button for 100-1500ms, it should give you a nice delay anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you may encounter some flashing if you process the data so quickly and the remote auto repeats. This could be handy if that number is processed multiple times by the receiving unit. The flashing would indicate that that is the case. If that is undesired, implement a simple state machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; your pastebin code came up whilst I was writing this answer. Having a quick look at your code, I would suggest that in the section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (irrecv.decode(&amp;amp;results)) {&#xA;  //receiving data? display nothing&#xA;  on(num00);&#xA;  digitalWrite(ledPin, HIGH);&#xA;  Serial.println(results.value, DEC);&#xA;  irrecv.resume();&#xA;  delay(100);&#xA;  int oldvalue = results.value;&#xA;  switch(results.value){&#xA;    case 16738455:&#xA;      Serial.println(0);&#xA;      num2display=0;      // make sure to declare this var somewhere&#xA;      //if (oldvalue == results.value){&#xA;      //  on(num0);&#xA;      //  delay(1000); &#xA;      //  on(num00);&#xA;      //  delay(1000); &#xA;      //} else {   // I think you missed an else here&#xA;      //  oldvalue = results.value;  &#xA;      //}&#xA;      //on(num0); &#xA;      //delay(1000); // you don't want such large blocking delays&#xA;      irrecv.resume();&#xA;      break;&#xA;    case 16724175:&#xA;      Serial.println(1);&#xA;      num2display=1;       // add this for each section&#xA;      irrecv.resume();&#xA;      break;&#xA;      . . .&#xA;  }&#xA;}&#xA;else{&#xA;  digitalWrite(ledPin, LOW);&#xA;  on(num2display);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you only set the variable to be displayed, but display &lt;code&gt;num00&lt;/code&gt;. Then in the else, you can display that number&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-03-28T12:10:04.683" LastActivityDate="2014-03-28T12:10:04.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="964" PostTypeId="1" CreationDate="2014-03-28T11:55:33.653" Score="7" ViewCount="3811" Body="&lt;p&gt;Is it possible to connect an Arduino to an Android Phone and use it for input/output?&#xA;Are connections possible over USB? Or do I need to have a wifi or Bluetooth shield?&lt;/p&gt;&#xA;" OwnerUserId="848" LastEditorUserId="42" LastEditDate="2014-03-28T16:15:04.400" LastActivityDate="2015-03-31T17:18:28.900" Title="How to connect Android phone to Arduino?" Tags="|serial|android|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="966" PostTypeId="2" ParentId="950" CreationDate="2014-03-28T12:12:12.363" Score="1" Body="&lt;p&gt;Thank you guys, its fixed now, i just dont understand why i cant use byte if i do, i&gt;=0, this way i never goes to 255 anyway and if does, it doesn matter, unless im missing something.&#xA;Here goes the final working code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Blink&#xA;  Turns on all 8 leds in sequence back and forth.&#xA;&#xA; */&#xA;&#xA;&#xA;// Initialize an array with all 8 leds&#xA;// and give them the corresponding&#xA;// digital number.&#xA;const char led[8] = {0,1,2,3,4,5,6,7};&#xA;#define speed 40&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;&#xA;  // initialize all 8 digital I/O pins as outputs.&#xA;  for (int i = 0; i&amp;lt;8; i++) {&#xA;    pinMode(led[i], OUTPUT);&#xA;  }&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void left (void);&#xA;void right (void);&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  // Turn off the buzzer on pin 13&#xA;  digitalWrite(13, LOW);&#xA;&#xA;  while(1) {&#xA;  right();&#xA;  left();&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;void left (void) {&#xA;  for (int i = 0; i&amp;lt;8; i++) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(speed);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&#xA;void right (void) {&#xA;  for (int i = 7; i&amp;gt;=0; i--) {&#xA;    digitalWrite(led[i], HIGH);&#xA;    delay(speed);&#xA;    digitalWrite(led[i], LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="832" LastActivityDate="2014-03-28T12:12:12.363" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="967" PostTypeId="2" ParentId="964" CreationDate="2014-03-28T13:14:08.820" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardADK&quot; rel=&quot;nofollow&quot;&gt;Arduino ADK&lt;/a&gt; is meant for that. It combines an Arduino Mega with a USB host chip and port. If you don't want to buy a full Arduino, you can buy a &lt;a href=&quot;https://www.sparkfun.com/products/9947&quot; rel=&quot;nofollow&quot;&gt;USB host shield&lt;/a&gt;. Excellent tutorial for it &lt;a href=&quot;http://labs.arduino.cc/ADK/Index&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What those do is convert high speed USB signals to SPI, which is readable by a microcontroller. Android has libraries known as the Accessory Development Protocol, which can bridge communication from a phone to the USB and then to a microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-03-28T13:14:08.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="968" PostTypeId="2" ParentId="964" CreationDate="2014-03-28T15:24:26.237" Score="3" Body="&lt;p&gt;You bet it's possible. I used a pretty cheap bluetooth module that I got from &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0093XAV4U&quot; rel=&quot;nofollow&quot;&gt;Amazon&lt;/a&gt;, and wrote an app using the information on the official &lt;a href=&quot;http://developer.android.com/guide/topics/connectivity/bluetooth.html&quot; rel=&quot;nofollow&quot;&gt;Android Developers page&lt;/a&gt; to connect to the Arduino. There are many guides online telling you how to hook up a module to the pins of the duino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably get a cheaper module if you look on eBay and don't care how long it takes to arrive, and I think there's at least one app on the Play store for controlling an Arduino if you can make it work for your purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB connections are probably possible, though I haven't done any of that.&lt;/p&gt;&#xA;" OwnerUserId="813" LastEditorUserId="42" LastEditDate="2014-03-30T17:38:49.780" LastActivityDate="2014-03-30T17:38:49.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="969" PostTypeId="2" ParentId="876" CreationDate="2014-03-28T18:06:11.050" Score="5" Body="&lt;h1&gt;4-Digits LED display for Arduino&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Small board with 4 7-segments LED digits, managed through 3 pins.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;When I started working with Arduino, I wanted a way to display values collected by various sensors I experimented, but I did not want to output these values through &lt;code&gt;Serial&lt;/code&gt; to a PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted a small board that I could easily reuse from one project to another and I wanted to spare a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This board, along with its small library, currently allows 4-digits numbers display and does not source any Arduino current during display (current is sourced only when communicating to the board the new value to display from now on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XAvXo.png&quot; alt=&quot;display board with counter&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The design is rather simple as I decided to reuse a &lt;strong&gt;MAX-7219&lt;/strong&gt; chip to drive my LED display (I had a few of them on hand).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to this chip, the schematic was much simple, but it was important to correctly understand how to use it; fortunately, its &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; was pretty clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original design was done on a breadboard and used &lt;strong&gt;4 single LED 7-segment digits&lt;/strong&gt;; but it required too much wiring for my taste (need to connect segments by groups of 4). Also, during my very first experiment with 7-segment LED digits, I have fried one: it had 2 Ground pins, but I connected only one to GND instead of both :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I decided to go for a &lt;strong&gt;4x7-segment display, common cathode&lt;/strong&gt;, with segment anodes already connected for 4 digits: that's only 4+8 pins!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PnB3n.jpg&quot; alt=&quot;Board Schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During my tests, I have found a useful &lt;a href=&quot;http://playground.arduino.cc/uploads/Main/LedControl.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino library for working with MAX-7219&lt;/a&gt; which I decided to reuse. I have built my &lt;a href=&quot;https://github.com/jfpoilpret/arduino-libraries/tree/master/DisplayDriver&quot; rel=&quot;nofollow noreferrer&quot;&gt;own library&lt;/a&gt; upon it, with a very simple API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After breadboarding, it was time to make the design more permanent; since I had a bunch of stripboards on hand, I decided to go for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched and found &lt;a href=&quot;http://www.abacom-online.de/uk/html/lochmaster.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;an easy Stripboard designer&lt;/a&gt; for PC that I have used for designing my board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first stripboard design was not optimized in terms of space and I decided not to implement it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iE37V.png&quot; alt=&quot;STRIPBOARD DESIGN #1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have reviewed the design to optimize the cost and size (just one small 50x75mm stripboard); that was easy with the stripboard designer I found before:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3dTgz.png&quot; alt=&quot;STRIPBOARD DESIGN #2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the board was ready, I decided to check it with an Arduino UNO and an Ultrasonic Sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MiLnL.jpg&quot; alt=&quot;PICTURE&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seemed to work except I often had strange, inconsistent displayed values; after investigation, I found it was due to &lt;strong&gt;noise triggered by the display board&lt;/strong&gt;, noise that interfered with the sensor. I just needed to &lt;strong&gt;add a decoupling cap&lt;/strong&gt; as near the current supply pins of the sensor as possible and that worked perfectly (note that the display board already had decoupling caps for the MAX-7219 chip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parts list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 x LN5461AS:    common cathode 7-segments block of 4 digits&lt;/li&gt;&#xA;&lt;li&gt;1 x MAX7219:     multiplexed LED driver chip&lt;/li&gt;&#xA;&lt;li&gt;1 x IC support (24 pins)&lt;/li&gt;&#xA;&lt;li&gt;1 x 22K resistor&lt;/li&gt;&#xA;&lt;li&gt;1 x 10uF electrolytic cap&lt;/li&gt;&#xA;&lt;li&gt;1 x 100nF cap&lt;/li&gt;&#xA;&lt;li&gt;1 x male pin header (5 pins)&lt;/li&gt;&#xA;&lt;li&gt;1 x 90x50mm stripboard&lt;/li&gt;&#xA;&lt;li&gt;wires, solder...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;30 years after my last electronics experiments, I could get the virus again with Arduino and with this very first project which, although rather simple, taught me several things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;interpret datasheets for the components used (MAX7219 and LED display)&lt;/li&gt;&#xA;&lt;li&gt;learn how to use and be effective with stripboard design&lt;/li&gt;&#xA;&lt;li&gt;all pins marked GND or V+ should be connected: you don't choose the one you feel like connecting!&lt;/li&gt;&#xA;&lt;li&gt;if there's something that appears strange when you test your circuit and you don't understand why: don't search, it must be noise, try to add a decoupling cap and that should do it! &lt;/li&gt;&#xA;&lt;li&gt;learn how to create an Arduino library (not just a sketch)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I was to start this project again today, I would:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;try to optimize further the stripboard design (probably I could reduce the size a bit further)&lt;/li&gt;&#xA;&lt;li&gt;replace the straight pin headers on the board with right-angled headers so that wires connecting to Arduino are more protruding in front of the board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-28T18:06:11.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="970" PostTypeId="2" ParentId="954" CreationDate="2014-03-28T18:40:04.683" Score="3" Body="&lt;p&gt;As with any communication error, try these:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disconnect and reconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Use a different USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Press the reset button on the board.&lt;/li&gt;&#xA;&lt;li&gt;Restart the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you select the right board in &lt;code&gt;Tools ► Board ►&lt;/code&gt;, e.g. If you are using the Duemilanove 328, select that instead of Duemilanove 128. The board should say what version it is on the microchip.&lt;/li&gt;&#xA;&lt;li&gt;Make sure you selected the right port in &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt;. One way to figure out which port it is on is by following these steps:&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Disconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Go to &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt; and see which ports are listed (e.g. COM4 COM5 COM14).&lt;/li&gt;&#xA;&lt;li&gt;Reconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Go back to &lt;code&gt;Tools ► Serial Port ►&lt;/code&gt;, and see which port appeared that wasn't there before.&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;li&gt;In extreme cases, you may need to &lt;a href=&quot;https://arduino.stackexchange.com/a/474/37&quot;&gt;burn the bootloader&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;sub&gt;Answer adapted from &lt;a href=&quot;https://arduino.stackexchange.com/a/18/37&quot;&gt;here&lt;/a&gt;.&lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-04-04T20:57:31.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="971" PostTypeId="2" ParentId="633" CreationDate="2014-03-28T18:56:14.830" Score="4" Body="&lt;p&gt;Like everyone mentions, as long as you're in the shade, hot temperature probably doesn't matter too much as it's within the limits of the components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm more worried about condensation in the mornings.  Water vapors will condense on electronics just like it does on grass.  You could try electrical epoxy to cover the circuit.  The Arduino doesn't run very hot, so the epoxy doesn't do much in terms of preventing it from cooling down.  But epoxy does keep water vapor condensation from being a problem.&lt;/p&gt;&#xA;" OwnerUserId="851" LastActivityDate="2014-03-28T18:56:14.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="972" PostTypeId="2" ParentId="432" CreationDate="2014-03-28T19:19:41.000" Score="1" Body="&lt;p&gt;What you want is pretty easy to do, and the code exists already.  But the way I invision it, you won't connect the sensor Arduino to your wifi.  Instead, you'll use another Arduino as your gateway like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor Arduino:  Located outside, connected to temperature sensor, wind speed, rain gauge?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gateway Arduino: Located inside, w/ Wiznet 5001 ethernet shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sensor Arduino and Gateway Arduino talks to each other using a VERY easy to use wireless transceiver, nRF24L01+.  The wireless modules are $3 each, and the library for use is very mature.  All the sensor data is easily communicated to the Gateway using this library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Gateway Arduino w/ the ethernet acts as a webserver, enabling any computer in your local network to open up a page and view current conditions.  Look at this page for the Arduino code:&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WebServer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to also save historical temperature/wind speed information right?  This is the best part! The Gateway Arduino can push data to a service like Xively, a free web-based data collection service that also gives you a nifty way to visualize/graph your data.  There is a little hiccup with using the Wiznet along with the nRF24L01 module.  The wireless module and ethernet shield both use the same bus to communicate, so take a look at this blog to see how you can use both at the same time:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.heald.ca/content/arduino-ethernet-nrf24l01-and-pachubecosmxively&quot; rel=&quot;nofollow&quot;&gt;http://www.heald.ca/content/arduino-ethernet-nrf24l01-and-pachubecosmxively&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Xively also lets you make that data public or private, so you can chose to contribute your weather station data to the community.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some other notes:&#xA;I like nRF24L01+ modules because they're dirt cheap.  Xbee modules cost more than the Arduinos themselves.  You can keep adding nRF24L01+ modules around the house once you establish a gateway.  The same cost problem exists with wifi shield - expensive.&lt;/p&gt;&#xA;" OwnerUserId="851" LastActivityDate="2014-03-28T19:19:41.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="973" PostTypeId="1" CreationDate="2014-03-28T22:36:59.827" Score="1" ViewCount="466" Body="&lt;p&gt;I'm new to arduino. I have nexus duino robot as described in &lt;a href=&quot;http://www.aliexpress.com/item/3WD-48mm-Omni-Wheel-Mobile-Arduino-Robot-Kit-10019/688287804.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/3WD-48mm-Omni-Wheel-Mobile-Arduino-Robot-Kit-10019/688287804.html&lt;/a&gt;, the shield connected with motors and support xbee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With simple serial comm sketch, I'm able to communicate between arduino and PC if the shield not inserted, but not if I insert the shield as it seem arduino can't receive serial data (still can send data to PC tough). Someone says that the shield might be use RX TX so it interfere with serial comm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Questions are, is there a way to check whether the shield use RX TX? If yes, can we make it not interfere with serial comm? Could be other problem causing this serial comm problem?&#xA;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="854" LastEditorUserId="304" LastEditDate="2014-03-29T04:04:41.817" LastActivityDate="2014-03-29T04:04:41.817" Title="Shield interfere with Serial Communication" Tags="|serial|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="975" PostTypeId="2" ParentId="876" CreationDate="2014-03-28T23:10:21.200" Score="5" Body="&lt;h1&gt;Digital Wall Clock with Radio Frequency (RF) Remote Control&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A large (40x30cm / 16x12&quot;) 7-segment display wall clock with R/F remote control.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T0XE7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This project features a large (40x30cm / 16x12&quot;) 7-segment display &lt;strong&gt;digital wall clock&lt;/strong&gt; with R/F remote control. It has the following features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It shows the current time and date (hours, minutes, seconds, day, month, year) in two formats (hours or date in the large digits).&lt;/li&gt;&#xA;&lt;li&gt;It shows the current temperature in °C.&lt;/li&gt;&#xA;&lt;li&gt;Has a user defined countdown which will sound an (annoying) alarm when it reaches zero.&lt;/li&gt;&#xA;&lt;li&gt;All functions controlled remotely by an RF remote control.&lt;/li&gt;&#xA;&lt;li&gt;Has a small cursor keypad for controlling its functions (when the remote control isn't available).&lt;/li&gt;&#xA;&lt;li&gt;Brightness control independent for each display line.&lt;/li&gt;&#xA;&lt;li&gt;It continues to keep the current time accurately even when off, thanks to a real time clock IC powered by a coin cell battery.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Design&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The key aspects of this project were the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It's completely based on Arduino and AVR ATmega328 microcontroller.&lt;/li&gt;&#xA;&lt;li&gt;It keeps current time even when off, thanks to DR1307 RTC powered by a coin cell battery.&lt;/li&gt;&#xA;&lt;li&gt;The digits are never multiplexed. Instead, each digit has a dedicated 8-bit serial shift register IC (74HC595) that keeps selected segments on independently of what's being displayed on the other digits and what the MCU is doing.&lt;/li&gt;&#xA;&lt;li&gt;Segments are powered by Darlington arrays due to current consumption that exceeds that of the MCU or the shift registers.&lt;/li&gt;&#xA;&lt;li&gt;The clock is controlled by a keypad on the controller board and also by an RF remote control. Radio communication is performed by a pair of inexpensive 434MHz radio receiver and transmitter.&lt;/li&gt;&#xA;&lt;li&gt;The project has a modular design in which a single controller can manage up 12 single digits. Controller also accepts expandable modules for unlimited number of digits (maximum number of digits is limited by timing delay due to daisy chaining of shift registers and the attenuation of their clock signal).&lt;/li&gt;&#xA;&lt;li&gt;The design supports a number of ready-made 7-segment display digits or custom digits made with LEDs. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Below are the schematics for the controller and one of the 7-segments boards:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TAqPM.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yIV4x.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some pictures of the boards that I designed, etched, and assembled, and the remote control:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tnZ5K.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7AtQ4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/r6aQR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, here's a picture of another version of the clock. In this one, I'm making the 7-segment displays myself using rectangular LEDs and discrete components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iicCN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This project took me a lot of time, effort and learning to get to this stage (it's never finished, as I've learned), but it was lots of fun. A few things I've learned:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Study &lt;strong&gt;all the libs&lt;/strong&gt; you're going to use in your project &lt;strong&gt;before you assign GPIO pins in your controller&lt;/strong&gt; so you avoid potential conflicts. I've been unlucky to use the same PWM pin for brightness control that is associated with VirtualWire timer, so I had to patch the board to get brightness and RF working at the same time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Crimping KK molex and modu connectors takes A LOT OF TIME!!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Laser cut acrylic pieces are the future. They add a lot of quality to the device even if you are clumsy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-03-28T23:10:21.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="976" PostTypeId="1" AcceptedAnswerId="979" CreationDate="2014-03-28T23:29:06.877" Score="6" ViewCount="167" Body="&lt;p&gt;I have recently designed a shield to my Arduino Duemilanove, which has 8 LEDs, on the digital GPIO, from 0 to 7, but it won't program with the shield on because the voltage drop is too much on the RX and TX lines. My question is: can I have a LED on the TX/RX line with a minimum resistor value that allows me to program the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="832" LastEditorUserId="27346" LastEditDate="2017-11-22T22:24:27.230" LastActivityDate="2017-11-22T22:24:27.230" Title="LEDs on TX/RX lines interfering with the programmig of the device" Tags="|led|shields|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="977" PostTypeId="2" ParentId="876" CreationDate="2014-03-29T00:49:00.660" Score="6" Body="&lt;h1&gt;TV Antenna Rotator&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IR remote controlled antenna rotation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't get off the couch to adjust the direction of the TV antenna?  And even if you do, sometimes your proximity to the antenna changes the reception.  It would be nice to be able to adjust the antenna from the couch.  Using the TV remote.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Components&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno, &#xA;IR receiver,&#xA;Stepper motor w/ driver board, &#xA;1&quot; ID bearing, &#xA;Swiffer mop handle, &#xA;Plastic box, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KyUOA.jpg&quot; alt=&quot;behind TV&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/4q8mv.jpg&quot; alt=&quot;Arduino w/ IR receiver up front&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/t4len.jpg&quot; alt=&quot;Close up of box and bearing&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/n80OR.jpg&quot; alt=&quot;Swiffer handle&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/hAevo.jpg&quot; alt=&quot;These two buttons don&amp;#39;t do anything on the TV anyways&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Description&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Use an old Swiffer mop handle as the antenna post. Got a 1&quot; ID bearing from  my favorite online store, which the mop handle just squeezes into and stops.  I drilled a hole into the plastic box big enough for the mop handle to fit through, but not for the bearing.  I drilled a rectangular hole into the mop handle end to fit the shaft of a 28BYJ-48 stepper motor, and stuck the contraption into the box as shown.  The mop handle actually rests on the bearing, and the bearing is super glued to the top of the plastic box. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Used the stepper.h library to rotate the motor from an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took apart an unused DVD player and salvaged the IR receiver from it.  You can take apart any consumer appliance that has a remote and use the IR receiver from it, it'll work.  The IR receiver uses the IRremote.h library.  Using the serial monitor, I printed out the hex code that corresponded to the two buttons on the TV remote that I want to use to operate the antenna motor.  One for rotating left, one for right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save energy, use the small_stepper.motorOff() function to turn off the coils after each movement.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Conclusion&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This was a fun project that was also useful for my wife.  I didn't implement any acceleration/deceleration in the movement, which might be nice, especially if the antenna had more rotational inertia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  sorry about the picture being sideways!  It's right side up on my computer, I have no idea why it's sideways online.&lt;/p&gt;&#xA;" OwnerUserId="851" LastEditorUserId="851" LastEditDate="2014-03-29T03:06:07.153" LastActivityDate="2014-03-29T03:06:07.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="978" PostTypeId="2" ParentId="954" CreationDate="2014-03-29T00:52:33.750" Score="1" Body="&lt;h2&gt;It sounds like you have incorrect drivers or the wrong COM port (USB) selected in the IDE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Both are easy to fix. I'd imagine that it would be the COM port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/esLpV.png&quot; alt=&quot;IDE&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools → Serial Port → [COM port... try a few different ones. Also you can use device manager to see which one disappears when you unplug your Arduino]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Few notes on photo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;#1. The selector for the COM port. Choose which one your board is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;#2. That shows the COM port selected and board. I don't have my UNO connected: ignore that the COM port isn't showing up on the menu.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-29T00:52:33.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="979" PostTypeId="2" ParentId="976" CreationDate="2014-03-29T02:56:47.783" Score="1" Body="&lt;p&gt;I just found this reference (&lt;a href=&quot;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=printview&amp;amp;t=70515&amp;amp;start=0&quot; rel=&quot;nofollow&quot;&gt;using ICSP for output as well as programming&lt;/a&gt; -- essentially the same thing), and it suggests a 4.7kOhm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't have a 4.7k handy, and used a 15k instead and it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my scenario, I have run a sketch with a polarized buzzer connected between RX (digital 0) and &lt;code&gt;GND&lt;/code&gt;. When connected directly (with no resistor) the sketch fails to load (but the buzzer works as expected). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I put the resistor in series with it, the sketch uploads without fail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also probably realise, but mentioning for clarity/completeness, you will lose all serial port functionality for debugging purposes and won't be able to use &lt;code&gt;Serial.[anything]&lt;/code&gt;. Make sure to not even initialise the port. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-03-29T02:56:47.783" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="980" PostTypeId="2" ParentId="973" CreationDate="2014-03-29T03:05:08.680" Score="2" Body="&lt;p&gt;You really do need to provide information on the shield, there are many versions out there (and I own half of them ). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In essence, unless you are using an alternate serial port (&lt;code&gt;SerialN&lt;/code&gt;) or software serial, then YES, your XBee will be using the same lines as your Arduino. If you are using &lt;code&gt;Serial.print&lt;/code&gt; or &lt;code&gt;Serial.write&lt;/code&gt; to talk to the XBee, then that is a giveaway too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for this is the XBee talks to your Arduino through the serial port, but the Arduino IDE also talks to your Arduino (for programming and &lt;code&gt;Serial.print&lt;/code&gt;) as well. You can only do one successfully. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In answer to your second question, most likely not. It will be the XBee shield causing you your problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I thought I would add, I actually have ONE shield that uses RX and TX but also allows for programming at the same time. This is achieved through a series resistor and (in the case of the shield) an amplifier as well.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-03-29T03:10:15.273" LastActivityDate="2014-03-29T03:10:15.273" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="981" PostTypeId="1" AcceptedAnswerId="982" CreationDate="2014-03-29T12:02:09.650" Score="7" ViewCount="3149" Body="&lt;p&gt;Have you heard about support for IPv6 protocol for any Ethernet shield?&#xA;As far as I know only IPv4 is supported.&#xA;Maybe some one would like to write library?&lt;/p&gt;&#xA;" OwnerUserId="859" LastActivityDate="2017-01-11T10:16:21.683" Title="Ethernet shield and IPv6 support" Tags="|tcpip|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="982" PostTypeId="2" ParentId="981" CreationDate="2014-03-29T12:51:59.663" Score="2" Body="&lt;p&gt;&lt;strong&gt;There is no library, and there physically cannot be one.&lt;/strong&gt; IPv4 is built into the Ethernet shield itself. (It has a &lt;em&gt;Wiznet 510&lt;/em&gt; chip.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Shields based on the MicroChip ENC28J60 chip (such as those sold by Ekitszone and Nuelectronics) are suitable for the implementation of an IPv6 or dual IPv4/IPv6 stack. This approach requires the TCP state machine to be implemented in software and results in more complex arduino code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Source: &lt;a href=&quot;https://www.adafruit.com/blog/2012/09/17/ask-an-educator-how-can-i-get-my-arduino-to-use-ipv6/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;. (You may find it useful, I'd recommenced reading it.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is &lt;a href=&quot;https://sites.google.com/site/ghoelzl/ipv6ethershield&quot; rel=&quot;nofollow&quot;&gt;this library for IPv6 on &lt;em&gt;other hardware&lt;/em&gt;, not for the official Ethernet shield&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-03-29T12:51:59.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="983" PostTypeId="1" CreationDate="2014-03-29T12:54:38.267" Score="5" ViewCount="268" Body="&lt;p&gt;I tested an &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050#.Uzl8TvldU-0&quot; rel=&quot;nofollow&quot;&gt;MPU-6050 (GY-521)&lt;/a&gt; using an Arduino Nano. I used the I2CDevLib and opened the &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050/Examples/MPU6050_DMP6&quot; rel=&quot;nofollow&quot;&gt;MPU6050_DMP6.ino&lt;/a&gt; with the Arduino IDE. I opened the &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050/Examples/MPU6050_DMP6/Processing&quot; rel=&quot;nofollow&quot;&gt;MPUTeapot.pde&lt;/a&gt; Processing-file with Processing. A few changes was necessary to make it work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MPU6050 mpu;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;was changed into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MPU6050 mpu(0x68);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally I commented out this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define OUTPUT_READABLE_YAWPITCHROLL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and uncommented this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define OUTPUT_TEAPOT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When turning everything on, the arrow (Processing) would turn with 5 degrees/s clockwise around the z-axis (plus a very small amount around the other two axes). After about 20 seconds, it would stop, and turn around the x-axis pretty fast for 3 seconds. Then it would stop. Now, the gyroscope+accelerometer would work perfectly. This happens every time I test it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens only when the gyroscope is perfectly still on the ground. It does not stabilize if I move it around. Only after it is left completely still, it'll stabilize after 23 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this how it should work, or is it a problem with the gyroscope? Could it even be caused by the I2CDevLib? Can anybody else confirm this?&lt;/p&gt;&#xA;" OwnerUserId="693" LastEditorUserId="186" LastEditDate="2014-03-31T15:18:40.347" LastActivityDate="2014-04-01T16:15:50.920" Title="Do gyroscopes purposefully show erroneous data?" Tags="|gyroscope|accelerometer|mpu6050|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="984" PostTypeId="5" CreationDate="2014-03-29T13:05:54.493" Score="0" Body="&lt;p&gt;Use this tag for designing a user experience of your project. This tag is often used with LCDs or with responsiveness, although it can have other uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UIs often determine the usefulness and simplicity of your sketch. For example, a &quot;lagging UI&quot; is like a slow computer: when you click something there is a short (or long) delay.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-03-29T13:05:54.493" LastActivityDate="2014-03-29T13:05:54.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="985" PostTypeId="4" CreationDate="2014-03-29T13:05:54.493" Score="0" Body="User Interface. Use this tag for designing a user experience of your project. This tag is often used with LCDs or with responsiveness, although it can have other uses." OwnerUserId="220" LastEditorUserId="42" LastEditDate="2015-03-15T02:43:04.077" LastActivityDate="2015-03-15T02:43:04.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="986" PostTypeId="1" AcceptedAnswerId="987" CreationDate="2014-03-29T18:33:39.723" Score="19" ViewCount="11363" Body="&lt;p&gt;Looking at my Arduino Uno R3 board and its &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;reference design schematic&lt;/a&gt; I noticed that there's a second ICSP 6-pin header. In the schematic, the connector I'm referring to is named ICSP1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What's that for?&lt;/strong&gt; &#xA;What useful things can an average Arduino user like me do with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant part of the schematic is below (marked in red).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2QP5f.png&quot; alt=&quot;Arduino Uno R3&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="10907" LastEditDate="2016-01-13T04:59:04.510" LastActivityDate="2020-01-01T23:59:43.603" Title="What's the 2nd ICSP header for in Arduino Uno R3?" Tags="|arduino-uno|icsp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="987" PostTypeId="2" ParentId="986" CreationDate="2014-03-29T19:12:38.940" Score="15" Body="&lt;p&gt;It's for the other MCU on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main MCU on the Uno is labelled &quot;ZIC1&quot;. This is the one that is programmed when you press &quot;Upload&quot; in the IDE. But unlike other Arduinos that use a FTDI chip to connect to the serial port on the main MCU, the Uno uses another MCU instead, labelled &quot;U3&quot; on the left. This MCU runs a small bit of code that acts as a serial port via USB and passes through the bytes to its USART1. This then connects to the USART on the main MCU, where the bootloader on that chip accepts the bytes coming through and writes to flash and EEPROM on the main MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this additional MCU as you would any other, but the only I/O it has available are the USB connection, the SPI connection via its ICSP header, the UART1 connection to both the main MCU and pins 0 and 1, and two LEDs on PD4 and PD5.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-29T19:12:38.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="988" PostTypeId="2" ParentId="525" CreationDate="2014-03-29T20:27:49.563" Score="1" Body="&lt;p&gt;I went through this last night.  I got the adapter cable [ .../852] and antenna from Adafruit.&#xA;It appeared to be hard to snap into place, but it did go.&lt;br&gt;&#xA;&lt;strong&gt;It did not improve performance&lt;/strong&gt; though when testing signal strength with the Example&gt;Bridge&gt;WiFiStatus &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which leads me to believe that the connector didn't mate -or- I damaged it -or- it isn't the proper connector.&#xA;I am thinking the latter is the case.&#xA;Still looking for the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jim&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought:&#xA;1 ea.     RP-SMA to uFL/u.FL/IPX/IPEX RF Adapter Cable     $3.95&#xA;&lt;a href=&quot;http://www.adafruit.com/products/852&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/852&lt;/a&gt;&#xA;1 ea.     2.4GHz Dipole Swivel Antenna with RP-SMA - 5dBi     $8.95&#xA;&lt;a href=&quot;http://www.adafruit.com/products/945&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/945&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="861" LastActivityDate="2014-03-29T20:27:49.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="989" PostTypeId="1" CreationDate="2014-03-29T21:34:55.593" Score="1" ViewCount="718" Body="&lt;p&gt;I am using a mcp23017 to read button presses for my joystick project and am using the internal pullup to minimize complications. Is there a way to invert all the bits in the uint16_t so i can send the values as normally off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library&quot; rel=&quot;nofollow&quot;&gt;this Adafruit library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the reading code: &lt;code&gt;uint16_t buttons = mcp.readGPIOAB();&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="862" LastEditorUserId="84" LastEditDate="2014-03-29T22:42:56.457" LastActivityDate="2014-03-29T22:42:56.457" Title="How do I use a i2c port expander to read buttons with pull ups and inverting the resulting uint16_t?" Tags="|programming|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="990" PostTypeId="2" ParentId="989" CreationDate="2014-03-29T21:37:40.513" Score="3" Body="&lt;p&gt;The inversion operator in C++ is &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(buttons, BIN);&#xA;Serial.print(~buttons, BIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-29T21:37:40.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="991" PostTypeId="1" AcceptedAnswerId="992" CreationDate="2014-03-29T21:53:49.723" Score="9" ViewCount="2711" Body="&lt;p&gt;Following on from &lt;a href=&quot;https://arduino.stackexchange.com/questions/986/whats-the-2nd-icsp-header-for-in-arduino-uno-r3&quot;&gt;What&amp;#39;s the 2nd ICSP header for in Arduino Uno R3?&lt;/a&gt; I was wondering how this could be hacked to our advantage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, could that firmware be rewritten to have the UNO recognised as a mouse/keyboard input? Could this be done after the boot loader process and leave the uploading process in tact?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the limited IO, it seems it's functions might be limited. Plus I have no idea how much code is space is available. &lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-03-29T22:15:58.580" Title="Can the 2nd MCU on the UNO R3 be used for keyboard emulation?" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="992" PostTypeId="2" ParentId="991" CreationDate="2014-03-29T21:59:06.220" Score="7" Body="&lt;p&gt;Yes, it is possible. using LUFA, you can burn new firmware to the Serial converter. The only problem is that you need to re-burn the USB-Serial converter to upload another program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Info: &lt;a href=&quot;http://www.fourwalledcubicle.com/LUFA.php&quot;&gt;http://www.fourwalledcubicle.com/LUFA.php&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specific page: &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard/&quot;&gt;http://mitchtech.net/arduino-usb-hid-keyboard/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2014-03-29T22:15:58.580" LastActivityDate="2014-03-29T22:15:58.580" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="993" PostTypeId="2" ParentId="991" CreationDate="2014-03-29T22:04:24.807" Score="3" Body="&lt;p&gt;The second MCU is similar to that used in the Leonardo, but is smaller and less capable (&lt;a href=&quot;http://www.atmel.com/devices/atmega16u2.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega16U2&lt;/a&gt; vs. &lt;a href=&quot;http://www.atmel.com/devices/atmega32u4.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega32U4&lt;/a&gt;). It is certainly possible to reprogram it to do what you like, but its limits means that you can have fewer USB &quot;devices&quot; at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not looked at the existing firmware, but it should certainly be possible to add your own custom code into it such that both the normal serial connection to the main MCU as well as your additional code can coexist.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-03-29T22:04:24.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="994" PostTypeId="1" CreationDate="2014-03-29T22:24:57.340" Score="6" ViewCount="14138" Body="&lt;p&gt;I'm working on a project with a joystick and I'm trying to keep everything a simple and low latency as possible. I am reading the pots with the onboard 10bit ADC on the ATmega 32u4 but may be upgrading to either a 16bit ADC or 24 bit ADC. &lt;strong&gt;How can I filter noise out of the signals?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="862" LastEditorUserId="220" LastEditDate="2014-03-29T22:43:52.237" LastActivityDate="2015-03-04T08:19:10.287" Title="How can I filter out noise from ADC lines without delay or signal change?" Tags="|pins|arduino-leonardo|signal-processing|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="995" PostTypeId="1" CreationDate="2014-03-30T00:05:17.010" Score="-1" ViewCount="1824" Body="&lt;p&gt;I am sending three analog signals through the xbees to be written to analog pins on the receiving side so they can be read in Simulink. I connected both of the arduino megas to my laptop and uploaded the sketches. I have a shield and a series one xbee connected to each arduino. I pulled up the serial monitor for each sketch. I connected a 1 volt DC power supply to all three analog pins. On the transmitting serial monitor I got numbers close to 200 which I believe is correct but on the receiving side I was not getting anything. I believe the problem is with the arduino. After I uploaded the code on the transmitting side the TX led was green but the RX led on the receiving side was not lit up at all. The power LED on the transmitting arduino is red but it is green on the receiving side. The 'L' led on the transmitting side is red on the transmitting side is read and yellow on the receiving side. On both of the xbee shield the power led's are red and the DIO5 led blinks green. On the receiving xbee shield the DOUT LED is red and the DI LED is green. If more information is needed let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my configuration for the xbees: (series 1. firmware version: 10ed) &lt;br/&gt;&#xA;Transmitting Xbee: &lt;br/&gt;&#xA;PAN ID: 1234 &lt;br/&gt;&#xA;MY:10 &lt;br/&gt;&#xA;DL:11 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Receiving Xbee: &lt;br/&gt;&#xA;PAN ID: 1234 &lt;br/&gt;&#xA;MY: 11 &lt;br/&gt;&#xA;DL: 10 &lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transmitting arduino program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val1 = 0;&#xA;int val2 = 0;&#xA;int val3 = 0;&#xA;int analogPin1 = 0; //these are you analog in pins&#xA;int analogPin2 = 1;&#xA;int analogPin3 = 2;&#xA;void setup()  {&#xA;  Serial.begin(9600);  //start serial&#xA;}&#xA;void loop()                               // run over and over again&#xA;{&#xA;        Serial.print(&quot;&amp;lt;&quot;);                // This character signifies the begining of our data cycle&#xA;            val1 = analogRead(analogPin1);    // read the input pin&#xA;        Serial.println(val1);             // output the signal&#xA;        Serial.print(&quot;\t&quot;);               // Signifies end of 1st piece of data&#xA;            val2 = analogRead(analogPin2);    // read the input pin&#xA;        Serial.println(val2);             // output the signal&#xA;        Serial.print(&quot;\t&quot;);               // Signifies end of 2nd piece of data        &#xA;            val3 = analogRead(analogPin3);    // read the input pin&#xA;        Serial.println(val3);             // output the signal&#xA;        Serial.print(&quot;&amp;gt;&quot;);                // This character signifies the end of our data cycle&#xA;        delay(100); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiving Arduino program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// software serial #1: TX = digital pin 0, RX = digital pin 1&#xA;SoftwareSerial portOne(0,1);&#xA;int Apin1 = 0; // These variables hold the current incoming value&#xA;int Apin2 = 0;&#xA;int Apin3 = 0;&#xA;int AnalogOut1 = 0;  //Set our analog pins&#xA;int AnalogOut2 = 1;&#xA;int AnalogOut3 = 2;&#xA;int Digits = 0; // Helps watch for comma&#xA;int Mode = 0; // This designates which section of reading we are doing - begin = 0, Apin1 = 1, Apin2 = 2, APin3 = 3, end = 4&#xA;void setup()&#xA;{&#xA; // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  // Start each software serial port&#xA;  portOne.begin(9600);&#xA;}&#xA;void loop()&#xA;{&#xA;  portOne.listen();&#xA;  while (portOne.available() &amp;gt; 0) {&#xA;  // read the incoming byte:&#xA;    char inByte = portOne.read();&#xA;&#xA;    if (isdigit(inByte) &amp;amp;&amp;amp; Mode == 1) {&#xA;    int temp = inByte - '0';&#xA;    Apin1 = (Apin1 * 10) + temp;&#xA;    Serial.print('\n'); // This is just some debugging stuff, if you plug in your programmer this will output the data to a serial monitor&#xA;    Serial.print(temp);&#xA;    Serial.print('\n');&#xA;    Serial.print(Apin1);&#xA;    Serial.print('\n');&#xA;    }&#xA;   if (isdigit(inByte) &amp;amp;&amp;amp; Mode == 2) {&#xA;    int temp = inByte - '0';&#xA;    Apin2 = (Apin2 * 10) + temp;&#xA;    Serial.print(temp); // This is just some debugging stuff, if you plug in your programmer this will output the data to a serial monitor&#xA;    Serial.print('\n');&#xA;    Serial.print(Apin2);&#xA;    Serial.print('\n');&#xA;    }&#xA;  if (isdigit(inByte) &amp;amp;&amp;amp; Mode == 3) {&#xA;    int temp = inByte - '0';&#xA;    Apin3 = (Apin3 * 10) + temp;&#xA;    Serial.print(temp); // This is just some debugging stuff, if you plug in your programmer this will output the data to a serial monitor&#xA;    Serial.print('\n');&#xA;    Serial.print(Apin3);&#xA;    Serial.print('\n');&#xA;    }&#xA;    if (inByte == ',') {&#xA;    Mode++;&#xA;    }&#xA;    if (inByte == '&amp;lt;') {&#xA;    Mode = 1;&#xA;    }&#xA;    if (inByte == '&amp;gt;') {&#xA;    Mode = 4;&#xA;    if (Apin1 &amp;gt; 0 &amp;amp;&amp;amp; Apin2 &amp;gt; 0 &amp;amp;&amp;amp; Apin3 &amp;gt; 0) {&#xA;    analogWrite(AnalogOut1, Apin1);&#xA;    analogWrite(AnalogOut2, Apin2);&#xA;    analogWrite(AnalogOut3, Apin3);&#xA;    }&#xA;    Serial.print('\n'); // This is just some debugging stuff, if you plug in your programmer this will output the data to a serial monitor&#xA;    Serial.print(Apin1);&#xA;    Serial.print('\n');&#xA;    Serial.print(Apin2);&#xA;    Serial.print('\n');&#xA;    Serial.print(Apin3);&#xA;    Serial.print('\n');&#xA;    Apin1 = 0; // These variables hold the current incoming value&#xA;    Apin2 = 0;&#xA;    Apin3 = 0;&#xA;          }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="835" LastActivityDate="2014-03-30T03:41:21.567" Title="Problem with Xbee or Arduino?" Tags="|arduino-mega|xbee|" AnswerCount="1" CommentCount="1" ClosedDate="2014-03-30T06:00:01.240" ContentLicense="CC BY-SA 3.0" />
  <row Id="996" PostTypeId="2" ParentId="995" CreationDate="2014-03-30T00:48:25.140" Score="1" Body="&lt;p&gt;The problem is the same as last time (&lt;a href=&quot;https://arduino.stackexchange.com/questions/843/xbeearduino-communication-problem?rq=1&quot;&gt;XBee+Arduino communication problem&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are sending the data via: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(val1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which outputs an &lt;code&gt;ASCII&lt;/code&gt; representation of the number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in your reading, you are reading in a &lt;code&gt;byte&lt;/code&gt; value. Actually, I just realised you are reading in a &lt;code&gt;char&lt;/code&gt; which is a signed (-128 to 127) value: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char inByte = portOne.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;first, change that to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte inByte = portOne.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you have three options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If (as you say) the numbers you expect are around &lt;code&gt;200&lt;/code&gt; and will &lt;strong&gt;always&lt;/strong&gt; be below &lt;code&gt;256&lt;/code&gt; (and positive) then you could send a byte value instead. That way, when you read the byte in, you get the same value. You would do this using &lt;code&gt;Serial.write(val1);&lt;/code&gt; instead of &lt;code&gt;print&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you need to send larger than a byte value, eg &lt;code&gt;int&lt;/code&gt;, then send as two bytes, HIGH and LOW. Then on the receiving end, take in two bytes when reading that data.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Send as plain text but read in as plain text. Since you have delimiters, keep reading in the serial until you have all the data you need and then break it down. (You could adapt the code I posted in the answer above to do that).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; a couple of other points with your code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You're doing an &lt;code&gt;analogWrite&lt;/code&gt; to digital pins &lt;code&gt;0, 1,&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt;. Was that your intention? &lt;code&gt;analogWrite&lt;/code&gt; is reserved for sending out PWM signals on only those pins that are capable (see: &lt;a href=&quot;http://arduino.cc/en/Reference/analogWrite&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Reference/analogWrite&lt;/a&gt; )&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;analogRead&lt;/code&gt; will read a value of &lt;code&gt;0-1023&lt;/code&gt; and if your intention is to just use PWM at the other end, then step it down to a value of &lt;code&gt;0-255&lt;/code&gt;. In that case you can get away with writing byte values to &lt;code&gt;Serial.write&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're never setting the &lt;code&gt;pinMode&lt;/code&gt; of the outputs in the receiver. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're sending &lt;code&gt;val1&lt;/code&gt;, &lt;code&gt;val2&lt;/code&gt;, and &lt;code&gt;val3&lt;/code&gt; out via &lt;code&gt;Serial.println&lt;/code&gt; which will send your value out (as &lt;code&gt;ASCII&lt;/code&gt;), followed by a newline, so the bytes sent from that one line will be &lt;code&gt;32 30 30 0D 0A&lt;/code&gt;. You have to interpret that at the other end. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're also using software serial on the hardware serial port (you're assigning digital pins 0 and 1. These are the hardware serial pins). &lt;strong&gt;BUT&lt;/strong&gt; you're also initialising it via hardware serial. I'm guessing that it really wouldn't matter (if the pins are aligned), but you can't expect to receive data via software serial and send data via hardware serial if they're all using the same pins. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="304" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-03-30T03:41:21.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="997" PostTypeId="2" ParentId="964" CreationDate="2014-03-30T03:02:36.897" Score="1" Body="&lt;p&gt;I already had this answer typed up on another question so I thought I'd post it here to help you. I've replaced &quot;tablet&quot; with &quot;phone&quot; for easy reading.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;You never mentioned your phone model... or Arduino model&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;There are some phones designed to work with USB flash drives and&#xA;  printers. This is called OTG (on the go.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;You need:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;A phone supporting OTG&lt;/li&gt;&#xA;  &lt;li&gt;An OTG adapter that fits into your phone's USB slot and is compatible&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.primavera.arduino.listener&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Arduino Uno Communicator App&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;Arduino Uno (or clone) [Note: It says that it works with Atmega16U2 or Atmega8U2 programmed as a USB-to-serial converter so I would assume&#xA;  that that would cover a few boards more than the Uno.)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Another alternitive is to look into&#xA;  &lt;a href=&quot;https://www.google.com/search?q=arduino+bluetooth&amp;amp;qscrl=1&amp;amp;tbm=isch&amp;amp;imgil=WyPC4O05Xn4rhM%253A%253Bhttps%253A%252F%252Fencrypted-tbn2.gstatic.com%252Fimages%253Fq%253Dtbn%253AANd9GcSfTtWqIuN9YYdd90OO_tlxsvLUYhV_pl7NfaMhHDzSRq9N6W9rNA%253B1200%253B1200%253B1soQc4CzMzh0MM%253Bhttp%25253A%25252F%25252Fm.dhgate.com%25252Fproduct%25252Fjy-mcu-arduino-bluetooth-wireless-serial%25252F151048482.html&amp;amp;source=iu&amp;amp;usg=__KyMLS4aeubxJnDaMvprgRgADxAs%3D&amp;amp;sa=X&amp;amp;ei=1BUCU635IYmEygGO1oHwCQ&amp;amp;ved=0CGkQ9QEwBg&amp;amp;biw=1280&amp;amp;bih=899&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bluetooth&lt;/a&gt;&#xA;  (Note: I just picked a random link but there are hundreds of similar&#xA;  BT adapters)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/a/272/220&quot;&gt;From my answer on a similar question&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-03-30T03:02:36.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="998" PostTypeId="2" ParentId="348" CreationDate="2014-03-30T10:23:09.567" Score="20" Body="&lt;p&gt;Here is the way I finally decided to follow for my projects.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Arduino-CMake&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The first important decision I made was the choice of a build tool that could work for my environment (Windows) but was not limited to it (I want my projects easily reusable by other people).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested various open source Arduino make tools:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/guyzmo/Arduino-Tools&quot; rel=&quot;noreferrer&quot;&gt;Guyzmo Makefile&lt;/a&gt;&lt;/strong&gt; (suggested by @zmo answer): this is just a standard Makefile handcrafted for Arduino builds; this is a Unix Makefile but there  is a &lt;a href=&quot;http://gnuwin32.sourceforge.net/packages/make.htm&quot; rel=&quot;noreferrer&quot;&gt;good port&lt;/a&gt; of &lt;strong&gt;Unix make for Windows&lt;/strong&gt;; still, unfortunately this Makefile works only for Unix, of course it could be adapted for Windows, but I wanted a tool that works &quot;out of the box&quot;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;noreferrer&quot;&gt;Arduino-Makefile&lt;/a&gt;&lt;/strong&gt; (suggested by @adnues answer): this a more advanced project, based on Unix Makefile, that aims to be easily reusable by all Arduino projects; it is documented as working on Mac, Linux and Windows, but Windows support proved wrong in my first experiments (many dependencies on Unix shell).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://bitbucket.org/magnomp/graduino/&quot; rel=&quot;noreferrer&quot;&gt;Graduino&lt;/a&gt;&lt;/strong&gt; (not suggested by any answer): this build tool is based on well-known &lt;a href=&quot;http://www.gradle.org/&quot; rel=&quot;noreferrer&quot;&gt;gradle&lt;/a&gt; build tool from the &lt;a href=&quot;http://groovy.codehaus.org/&quot; rel=&quot;noreferrer&quot;&gt;groovy&lt;/a&gt; world; the tool seems quite well done but requires some (little) groovy/gradle knowlegde, and has only little documentation; I decided not to go with it due to the burden of installing groovy and gradle just for it (I'd like to avoid too many pre-requisites to people who want to build my projects on their environments).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/queezythegreat/arduino-cmake&quot; rel=&quot;noreferrer&quot;&gt;Arduino-CMake&lt;/a&gt;&lt;/strong&gt; (not suggested by any answer): this seems the best of all, it has a long history, has many supporters and maintainers, is very well documented, comes with simple examples and also has a few good tutorial blog posts on the Web, e.g. &lt;a href=&quot;http://www.pascalspoerri.ch/posts/2013/12/29/using-arduino-with-cmake/&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://duinoworks.bakketti.com/?p=11&quot; rel=&quot;noreferrer&quot;&gt;there&lt;/a&gt;. It is based on &lt;a href=&quot;http://www.cmake.org/&quot; rel=&quot;noreferrer&quot;&gt;CMake&lt;/a&gt;, a &quot;Cross-Platform Make&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have also found &lt;strong&gt;&lt;a href=&quot;https://github.com/arons/ArduinoDevel&quot; rel=&quot;noreferrer&quot;&gt;ArduinoDevel&lt;/a&gt;&lt;/strong&gt;, another Arduino build tool -which I have not experimented- that can generate &lt;strong&gt;Unix Makefiles&lt;/strong&gt; or &lt;a href=&quot;http://ant.apache.org/&quot; rel=&quot;noreferrer&quot;&gt;ant&lt;/a&gt; &lt;code&gt;build.xml&lt;/code&gt; files; that one seemed interesting but a bit limited in terms of functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I decided to go with &lt;strong&gt;Arduino-CMake&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it was easy to setup: just install &lt;strong&gt;CMake&lt;/strong&gt; on your machine and copy Arduino-CMake in some directory that is easily accessible (through relative paths) from your projects directories.&lt;/li&gt;&#xA;&lt;li&gt;the examples worked out of the box for me (just followed the comments in &lt;code&gt;CMakeLists.txt&lt;/code&gt; configuration file to adapt properties that needed to for my environment, e.g. Arduino type, serial port)&lt;/li&gt;&#xA;&lt;li&gt;you can organize your projects any way you want&lt;/li&gt;&#xA;&lt;li&gt;it can generate configuration files for various build tools out there (I have only tested &lt;strong&gt;Unix Makefiles&lt;/strong&gt; though), including &lt;a href=&quot;https://www.eclipse.org/&quot; rel=&quot;noreferrer&quot;&gt;Eclipse&lt;/a&gt; projects.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;in the generated make, several targets get created to support:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;libraries build&lt;/li&gt;&#xA;&lt;li&gt;programs build&lt;/li&gt;&#xA;&lt;li&gt;program upload to boards&lt;/li&gt;&#xA;&lt;li&gt;serial monitor launch&lt;/li&gt;&#xA;&lt;li&gt;and a few others I have not tested yet&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Project Structure&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Since Arduono-CMake does not impose any directory structure for your project, you can choose the one that fits you best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I've done personnaly (that still requires further refinement, but I'm happy with it now):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gV76h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have decided to put all my projects under a common &lt;code&gt;arduino-stuff&lt;/code&gt; directory (which I commit to github as a whole, I know I could use &lt;strong&gt;&lt;em&gt;git submodules&lt;/em&gt;&lt;/strong&gt; for a better organisation on github, but had no time to check that yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;arduino-stuff&lt;/code&gt; has the following content:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;build&lt;/code&gt;: that's a directory where cmake and make will generate all their stuff (makefiles, cache, object files...); this one does ot get committed to github&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cmake&lt;/code&gt;: that one is just a copy (unmodified) of &lt;a href=&quot;https://github.com/queezythegreat/arduino-cmake/tree/master/cmake&quot; rel=&quot;noreferrer&quot;&gt;Arduino-CMake cmake&lt;/a&gt; directory. This one gets on github so that it's easier for someone who wants to build my projects&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CMakeLists.txt&lt;/code&gt;: that's the &quot;global&quot; CMake configuration that declares all defaults for my environment (board, serial port) and the list of build target subdirectories&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;TaskManager&lt;/code&gt;: this is my first project based on Arduino-CMake, this one is a library with examples; this idrectory also contains a &lt;code&gt;CMakeLists.txt&lt;/code&gt; that states the targets for the project&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Points to improve&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The current solution is not perfect though.&#xA;Among improvements I see (that's rather for Arduino-CMake project to include these improvements if they see fit):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Feature to copy a library directory from the current project to the Arduino libraries directory&lt;/li&gt;&#xA;&lt;li&gt;Feature to upload a library to github&lt;/li&gt;&#xA;&lt;li&gt;Feature to download a library from github&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-30T10:23:09.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="999" PostTypeId="1" AcceptedAnswerId="1001" CreationDate="2014-03-30T11:01:29.997" Score="13" ViewCount="9113" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Reference/LiquidCrystalConstructor&quot;&gt;Arduino LiquidCrystal library&lt;/a&gt; has 4 constructors with different arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal(rs, enable, d4, d5, d6, d7) &#xA;LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) &#xA;LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7) &#xA;LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following comments are stated for the constructor arguments:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...] d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What is the point of &lt;code&gt;d0-d3&lt;/code&gt; if they are not needed? Will they decrease the response time?&lt;/p&gt;&#xA;" OwnerUserId="693" LastEditorUserId="42" LastEditDate="2014-03-30T11:43:39.910" LastActivityDate="2018-10-11T06:20:07.987" Title="What is the point of D0-D3 on LCD?" Tags="|lcd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1000" PostTypeId="2" ParentId="999" CreationDate="2014-03-30T11:21:43.323" Score="3" Body="&lt;p&gt;The answer is on the same page as the quote you mentioned (I have highlighted the important statement):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Creates a variable of type LiquidCrystal. &lt;strong&gt;The display can be controlled using 4 or 8 data lines&lt;/strong&gt;. If the former, omit the pin numbers for d0 to d3 and leave those lines unconnected. The RW pin can be tied to ground instead of connected to a pin on the Arduino; if so, omit it from this function's parameters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It turns out that the Hitachi HD44780 LCD display can work in 4-bit or 8-bit modes.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-03-30T11:21:43.323" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1001" PostTypeId="2" ParentId="999" CreationDate="2014-03-30T11:42:17.693" Score="14" Body="&lt;p&gt;That type of LCD has two main modes of operation: 4-bit mode which uses 4 data pins (d4-d7), and 8-bit mode which uses all 8 data pins (d0-d7).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4-bit mode has the advantage of requiring fewer output pins on your Arduino. However, it means your sketch needs to send each command/character as two separate batches of 4-bits (one after the other). This is handled for you automatically by the LiquidCrystal library, so you won't need any extra complexity in your code. However, it does mean that your sketch requires roughly double the number of processor cycles to send anything to the LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast, 8-bit mode sends each command/character as a single batch of 8-bits. That simply means it technically runs a little faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, a person looking at the display probably won't see a significant speed difference most of the time, as it still goes very quickly. The main impact will be on the microcontroller (the Arduino in this case). If it can use the faster 8-bit mode then it can devote a little more processing time to other things. That can be particularly helpful for timing-critical applications.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-04-01T22:03:14.057" LastActivityDate="2014-04-01T22:03:14.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1002" PostTypeId="1" AcceptedAnswerId="1004" CreationDate="2014-03-30T13:05:38.427" Score="1" ViewCount="8710" Body="&lt;p&gt;I'm &lt;a href=&quot;https://electronics.stackexchange.com/q/104466/29792&quot;&gt;debugging a couple of RS232-to-TTL converter boards&lt;/a&gt; that I'm trying to use to program my Arduinos and one thing I would like to try would be to reduce the upload serial speed from 115200 to 19200. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I do that?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine that there's a setting that can be easily changed on the Arduino IDE preferences. But where is it? But then the bootloader speed would have to match that? &lt;strong&gt;How do I change the serial upload speed on optiboot, too?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-11T09:38:51.813" Title="How to reduce serial speed on Arduino bootloader (optiboot) and on the IDE?" Tags="|arduino-uno|serial|arduino-ide|bootloader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1003" PostTypeId="1" AcceptedAnswerId="1011" CreationDate="2014-03-30T13:21:02.950" Score="6" ViewCount="2961" Body="&lt;p&gt;The Arduino Uno has an ICSP header that I imagine is for programming the board using a separate ICSP programmer. That is, its ICSP header turn the board into a target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can one use that same ICSP to program other boards, turning the Arduino Uno effectively into a ICSP AVR programmer? How?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming that the target boards would also be Arduinos and wanted the Uno to program them using the Arduino IDE. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the &lt;a href=&quot;http://www.atmel.in/Images/doc0943.pdf&quot;&gt;AVR In-System Programming Application Note&lt;/a&gt; it looks to me that the only issue would be to make the programmer (the Arduino Uno) control the target board reset line. I've seen something like that in ArduinoISP sketch, but in that sketch, the target reset is controlled by port D10. But one could program the reset line to be an output, right? So could we change the ArduinoISP sketch to use its own reset line as output to control the target board reset line? If not, &lt;strong&gt;why not?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-03-31T11:50:23.240" Title="Can the Arduino Uno become an AVR programmer and use the ICSP header to program the target board" Tags="|arduino-uno|icsp|arduinoisp|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1004" PostTypeId="2" ParentId="1002" CreationDate="2014-03-30T13:44:16.507" Score="2" Body="&lt;p&gt;On Arduino IDE side, the upload speed is coded in &lt;code&gt;hardware/arduino/boards.txt&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.upload.speed=115200&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for every kind of board; you cannot change it directly from the IDE (that would be too dangerous as that value must match the &lt;strong&gt;expected speed for the actual bootloader&lt;/strong&gt; of every board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as per the optiboot loader side, the upload speed is defined in &lt;code&gt;BAUD_RATE&lt;/code&gt; macro, in &lt;code&gt;optiboot.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* set the UART baud rate defaults */&#xA;#ifndef BAUD_RATE&#xA;#if F_CPU &amp;gt;= 8000000L&#xA;#define BAUD_RATE   115200L // Highest rate Avrdude win32 will support&#xA;#elsif F_CPU &amp;gt;= 1000000L&#xA;#define BAUD_RATE   9600L   // 19200 also supported, but with significant error&#xA;#elsif F_CPU &amp;gt;= 128000L&#xA;#define BAUD_RATE   4800L   // Good for 128kHz internal RC&#xA;#else&#xA;#define BAUD_RATE 1200L     // Good even at 32768Hz&#xA;#endif&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I guess you can:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;#define BAUD_RATE 19200&lt;/code&gt; before that block of code&lt;/li&gt;&#xA;&lt;li&gt;recompile the optiboot loader&lt;/li&gt;&#xA;&lt;li&gt;upload your own new bootloader version&lt;/li&gt;&#xA;&lt;li&gt;update &lt;code&gt;uno.upload.speed&lt;/code&gt; accordingly in &lt;code&gt;boards.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;check it on the usual blink sketch and cross your fingers :-)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please note that this kind of task is not for beginners, you need to know what you're doing.&#xA;Also note that I disclaim any responsibility if you get unable to upload programs to your Arduino afterwards!&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-03-31T16:27:17.983" LastActivityDate="2014-03-31T16:27:17.983" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1005" PostTypeId="2" ParentId="1003" CreationDate="2014-03-30T13:50:53.060" Score="3" Body="&lt;p&gt;Yes you can program the Arduino's reset input pin as an output and use that to program another AVR, but you can no longer program your Arduino as that relies on the controller being reset through its own reset pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coming to think about it, I am not sure how the other devices (like the USB controller) responds to being reset by Arduino's controller itself. It resets the USB controller which may or may not reset the connection to the computer, possibly loosing data. With the USB controller being reset, GPIO-pins D0 and D1 (the serial interface between PC and Arduino's AVR) may corrupt the datastream. &lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-03-30T13:50:53.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1007" PostTypeId="1" AcceptedAnswerId="1109" CreationDate="2014-03-30T23:14:46.567" Score="3" ViewCount="1783" Body="&lt;p&gt;I have a CC3000 wifi module from adafruit that is working OK. Now, I am trying to use it together with an external service, which code requires me to pass a Client (from Arduino SDK) reference, but the Adafruit_CC3000_Client does not inherit from Client nor WifiClient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for an appropiate wrapper, but unable to find one. Does anyone know about such wrapper?&lt;/p&gt;&#xA;" OwnerUserId="666" LastActivityDate="2014-07-15T20:44:42.060" Title="Client or WiFiClient wrapper for adafruit CC3000 wifi" Tags="|wifi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1008" PostTypeId="1" AcceptedAnswerId="1009" CreationDate="2014-03-31T00:55:16.420" Score="1" ViewCount="2926" Body="&lt;p&gt;I'm using &lt;code&gt;sprintf&lt;/code&gt; to use a format specifier &lt;code&gt;myTemplate&lt;/code&gt; with some strings. The result will then be written to Serial. Although the sketch compiles fine, it does not write any thing to the serial, nothing is seen in the Serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is &lt;code&gt;sprintf&lt;/code&gt; being used wrongly here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* result;&#xA;char* myTemplate;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    myTemplate = &quot;Welcome %s. You have slept %s times&quot;;&#xA;    sprintf(result, myTemplate, &quot;Jane&quot;, &quot;many&quot;);&#xA;    Serial.println(result);&#xA;    Serial.println(&quot;hello&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When I try the follwing sketch and write something to the Serial monitor, I receive gibberish echoed back to me!  Why is this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sketch&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char received;&#xA;char* message = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // Echos back&#xA;    if(Serial.available() &amp;gt; 0) {&#xA;        received = Serial.read();&#xA;        Serial.println(message);&#xA;&#xA;&#xA;        if(received == '\n') {&#xA;            message = &quot;&quot;;&#xA;        }  else {&#xA;            message += received;&#xA;        }&#xA;&#xA;&#xA;    }&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="639" LastEditorUserId="639" LastEditDate="2014-03-31T03:07:08.517" LastActivityDate="2014-03-31T03:07:08.517" Title="Nothng Written to Serial when using sprintf" Tags="|arduino-uno|programming|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1009" PostTypeId="2" ParentId="1008" CreationDate="2014-03-31T01:10:23.553" Score="3" Body="&lt;p&gt;When you use &lt;code&gt;sprintf()&lt;/code&gt;, you need to have some space allocated for it to write the result to. At the moment, you're just passing an uninitialised pointer (&lt;code&gt;result&lt;/code&gt;), meaning the behaviour of &lt;code&gt;sprintf()&lt;/code&gt; is undefined. It might appear to work under some circumstances, but not others (and even if it did seem to work, it could have some nasty side effects on other parts of your code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest approach is to allocate a static &lt;code&gt;char&lt;/code&gt; buffer. You need to be sure it's big enough to contain all of the text you want it to store though (plus an extra null character at the end).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* myTemplate = &quot;&quot;;&#xA;char result[64] = {0};&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    myTemplate = &quot;Welcome %s. You have slept %s times&quot;;&#xA;&#xA;    sprintf(result, myTemplate, &quot;Jane&quot;, &quot;many&quot;);&#xA;    Serial.println(result);&#xA;    Serial.println(&quot;hello&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, it's usually a good idea to initialise your variables. This is especially true for pointers.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-31T01:10:23.553" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1010" PostTypeId="1" CreationDate="2014-03-31T01:18:42.903" Score="3" ViewCount="1708" Body="&lt;p&gt;I have an Arduino Uno R3. I have a paddlewheel waterspeed sensor that I use on an ISR on pin 2. The power supply is approximately 8v stepped down to 4.92v with a circuit yanked from the phone charger. I have also tried this with the arduino 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin returns the correct values with digitalRead(), so it's cycling between 1 and 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ISR works fine on pin3. Why does it work on pin 3 and not pin 2 ISR?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void itest() {&#xA;    Serial.println( &quot;test&quot; );&#xA;}&#xA;&#xA;void setup() {&#xA;    attachInterrupt(0, itest, FALLING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="874" LastEditorUserId="874" LastEditDate="2014-03-31T07:32:59.000" LastActivityDate="2014-03-31T12:04:11.680" Title="Arduino Uno R3 ISR does not work on pin 2?" Tags="|arduino-uno|interrupt|isr|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1011" PostTypeId="2" ParentId="1003" CreationDate="2014-03-31T02:46:58.210" Score="5" Body="&lt;p&gt;First of all, as configured, the RESET pin can &lt;strong&gt;not&lt;/strong&gt; be used as an output pin. In order to use it as an I/O pin, you would have to program the RSTDISBL fuse. But once you do that, as jippie said, it becomes near-impossible to reprogram your Arduino (if you have the socketed through hole variety of the MCU, you could pull it out and put it into a high voltage programmer; in all other cases, it's effectively impossible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in theory, you can use the ICSP header the way you suggest. In practice, it's under almost any conceivable circumstance a terrible idea.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-03-31T02:46:58.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1012" PostTypeId="2" ParentId="994" CreationDate="2014-03-31T03:29:01.343" Score="2" Body="&lt;p&gt;One possible approach is to go for a completely software side solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/AsheeshR/Microsmooth&quot; rel=&quot;nofollow&quot;&gt;Microsmooth&lt;/a&gt; is a signal processing library that I am working on that is specifically intended for low latency, low memory signal smoothing. It is still in development, but even now, most of the filters work in less than 100 microseconds per call while giving fairly good accuracy and smoothing. Also, the header file allows for simple configuration for certain filter parameters.&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-03-31T03:29:01.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1013" PostTypeId="1" AcceptedAnswerId="1033" CreationDate="2014-03-31T06:35:44.493" Score="71" ViewCount="445312" Body="&lt;p&gt;I am sending a list of servo positions via the serial connection to the arduino in the following format&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1:90&amp;amp;2:80&amp;amp;3:180&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would be parsed as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;servoId : Position &amp;amp; servoId : Position &amp;amp; servoId : Position&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I split these values up, and convert them to an integer?&lt;/p&gt;&#xA;" OwnerUserId="878" LastEditorUserId="220" LastEditDate="2015-03-09T23:54:16.560" LastActivityDate="2024-02-10T20:57:56.803" Title="How do I split an incoming string?" Tags="|serial|arduino-mega|string|" AnswerCount="12" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1014" PostTypeId="2" ParentId="1013" CreationDate="2014-03-31T07:36:29.347" Score="9" Body="&lt;p&gt;You can use &lt;a href=&quot;http://arduino.cc/en/Reference/StreamReadStringUntil&quot;&gt;&lt;code&gt;Stream.readStringUntil(terminator)&lt;/code&gt;&lt;/a&gt; passing a different terminator for each part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On each part you then call &lt;a href=&quot;http://arduino.cc/en/Reference/StringToInt&quot;&gt;&lt;code&gt;String.toInt&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-03-31T07:36:29.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1015" PostTypeId="2" ParentId="1013" CreationDate="2014-03-31T07:51:40.857" Score="13" Body="&lt;p&gt;You could do something like the following, but please take into account several things:&lt;/p&gt;&#xA;&lt;p&gt;If you use &lt;code&gt;readStringUntil()&lt;/code&gt;, it will wait until it receives the character or timeouts. Thus, with your current string, the last position will last a little longer, as it has to wait. You can add a trailing &lt;code&gt;&amp;amp;&lt;/code&gt; to avoid this timout. You can easily check this behavior in your monitor, try to send the string with and without the extra &lt;code&gt;&amp;amp;&lt;/code&gt; and you will see such timeout delay.&lt;/p&gt;&#xA;&lt;p&gt;You actually do not need the servo index, you can just send your string of positions, and get the servo index by the value position in the string, something like: &lt;code&gt;90&amp;amp;80&amp;amp;180&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you use the servo index, maybe you want to check it (convert to &lt;code&gt;int&lt;/code&gt;, and then match the loop index i) to ensure that nothing went wrong with your message.&lt;/p&gt;&#xA;&lt;p&gt;You have to check that the returning string from &lt;code&gt;readStringUntil&lt;/code&gt; is not empty. If the function timeouts, you didn't receive enough data, and thus any attempt to extract your &lt;code&gt;int&lt;/code&gt; values will produce strange results.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int i=1; i&amp;lt;=3; i++) {&#xA;    String servo = Serial.readStringUntil(':');&#xA;    if (servo != &amp;quot;&amp;quot;) {&#xA;      // here you could check the servo number&#xA;      String pos = Serial.readStringUntil('&amp;amp;');&#xA;      int int_pos=pos.toInt();&#xA;&#xA;      Serial.println(&amp;quot;Pos&amp;quot;);&#xA;      Serial.println(int_pos);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="666" LastEditorUserId="61722" LastEditDate="2024-02-10T20:57:56.803" LastActivityDate="2024-02-10T20:57:56.803" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1016" PostTypeId="2" ParentId="1003" CreationDate="2014-03-31T08:07:11.147" Score="5" Body="&lt;p&gt;I recommend going out and buying an AVR Dragon - costs aroud $US50. That gives you ISCP programming plus debugwire debugging (using the Atmel Studio IDE).&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-03-31T08:07:11.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1017" PostTypeId="2" ParentId="40" CreationDate="2014-03-31T08:31:55.013" Score="4" Body="&lt;p&gt;I have always wanted to use Eclipse, since that is our standard (for Java) at work. But I never managed to get the debugger working with my AVR Dragon board - just too many layers between the source code and the chip.&#xA;So I am back to using Atmel Studio. You can set the keyboard mapping to emulate various other IDEs (including Eclipse and Netbeans). I can accept the Microsft quirkiness in return for a stable debugging environment, multi-file support and professional source control features.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-03-31T08:31:55.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1018" PostTypeId="2" ParentId="870" CreationDate="2014-03-31T08:47:31.953" Score="1" Body="&lt;p&gt;Making your own is quite possible, especially if you own a router (or even better a router table). You need a V shaped 90 degree router bit, a tube of proper perspex glue and some acrylic sheet. The glue is hard to find, but plastic sign manufacturers generally will sell it. Unless you are a DIY expert, I suggest the gap filling type of glue rather than the watery product that only fills perfectly matched surfaces. Try searching Youtube on &quot;acrylic box making&quot;. There are several videos. My first two efforts were pretty bad, but the last couple are fine, and are of course exactly the right size.&lt;/p&gt;&#xA;" OwnerUserId="881" LastEditorUserId="881" LastEditDate="2014-04-01T09:03:23.940" LastActivityDate="2014-04-01T09:03:23.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1019" PostTypeId="2" ParentId="830" CreationDate="2014-03-31T09:02:50.587" Score="0" Body="&lt;p&gt;The way most of the libraries do this is to put an instance of (in your case) Timer in the Timer.cpp file, and reference it with an extern definition when needed - typically in your main cpp file.&#xA;Also you are calling digitalWrite() and digitalRead() during an ISR. This can be bad since those functions are slow, and may not be guaranteed to behave when interrupts are disabled (as they are during an ISR). A safer approach is for your ISR to set a flag in your Timer class that can be read by an Timer.isExpired() or similar method in your loop() code.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-03-31T09:02:50.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1020" PostTypeId="2" ParentId="816" CreationDate="2014-03-31T09:25:32.280" Score="12" Body="&lt;p&gt;In my experience, it is best to avoid &lt;b&gt;new&lt;/b&gt; and &lt;b&gt;delete&lt;/b&gt; when running on machines with limited memory. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;  &lt;li&gt;The memory management itself uses valuable program and RAM space&lt;/li&gt;&#xA;  &lt;li&gt;ISR vectors are set at compile tme. It is difficult (impossible?) for a class instance to claim an ISR at run time&lt;/li&gt;&#xA;  &lt;li&gt;Generally you will know at compile time what class instances you need - e.g. 3 button debouncers, a display driver and a 2-line display driver&lt;/li&gt;&#xA;  &lt;li&gt;Memory management introduces unknown delays when you use new or delete.&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There may be cases where it is justified to use dynamic instance construction and destruction, but I suspect they are rare. &lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-03-31T09:25:32.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1021" PostTypeId="2" ParentId="412" CreationDate="2014-03-31T09:51:33.417" Score="1" Body="&lt;p&gt;You can turn the carrier on and off simply by toggling the carrier pin mode between output and input. I have used this to control a heat pump through the 37KHz infrared (remote control) port.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-03-31T09:51:33.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1022" PostTypeId="2" ParentId="1003" CreationDate="2014-03-31T11:50:23.240" Score="4" Body="&lt;p&gt;To answer my own question, just to report that I found something close to what I was looking for, which I link and describe briefly below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gammon Software Solutions forum - Atmega Bootloader Programmer - Programming Cable&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On that page, the author suggest that we cut pin 5 from the 6-pin ICSP programming cable, solder a pin to it, and wire it to pin D10. Like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tMAP4.jpg&quot; alt=&quot;Modified ICSP programming cable&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you can load the Arduino Uno with the ArduinoISP sketch and program the target board as usual.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-03-31T11:50:23.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1023" PostTypeId="2" ParentId="1010" CreationDate="2014-03-31T12:04:11.680" Score="3" Body="&lt;p&gt;never use Serial inside an interrupt handler, increment a (volatile) variable and print it in the loop().&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-03-31T12:04:11.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1024" PostTypeId="1" AcceptedAnswerId="1025" CreationDate="2014-03-31T12:56:56.303" Score="6" ViewCount="3647" Body="&lt;p&gt;I built a simple clock using a 4 digits 7 segments LCD display. I display one digit at a time, switching on and off very quicky and cycling through digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is ok, but I used 8 + 4 = 12 arduino pins. I need 2 more pins for other features and I don't want to use 0 and 1 as I need onboard programming features of Arduino Mini.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used I2C for RTC clock, I could add some interface here (like a PCF8574) and get some pins from here. But I'd like a different (and more educational, for me) approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an IC that sends an HIGH output on one of four output pins driven by 2 input pins? I need this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IN     OUT&#xA;P0 P1  D0 D1 D2 D3&#xA;0  0   1  0  0  0&#xA;0  1   0  1  0  0&#xA;1  0   0  0  1  0&#xA;1  1   0  0  0  1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way I can connect OUT to digit selection and spare 2 pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your hints.&lt;/p&gt;&#xA;" OwnerUserId="883" LastActivityDate="2014-04-04T05:55:38.513" Title="Save some arduino pins when driving a 4 digits 7 segments display" Tags="|lcd|display|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1025" PostTypeId="2" ParentId="1024" CreationDate="2014-03-31T13:07:35.223" Score="2" Body="&lt;p&gt;A 2-to-4 line decoder should do what you need. I've used a &lt;a href=&quot;http://www.fairchildsemi.com/ds/74/74VHC139.pdf&quot; rel=&quot;nofollow&quot;&gt;74HC139&lt;/a&gt; with Arduino before, which contains two decoders in a 16-pin DIP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are lots of other options though. In the past, I've used an 8 bit serial-to-parallel shift register (&lt;a href=&quot;https://www.sparkfun.com/datasheets/IC/SN74HC595.pdf&quot; rel=&quot;nofollow&quot;&gt;74HC595&lt;/a&gt;) to control a 7 segment display. It effectively lets you control 8 (or more) outputs using only 3 pins on your microcontroller. You have to be careful of power requirements though. Most shift registers aren't able to drive such a display directly, but I was able to incorporate transistors quite easily to get around that.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-03-31T13:07:35.223" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1026" PostTypeId="2" ParentId="1024" CreationDate="2014-03-31T13:37:49.573" Score="2" Body="&lt;p&gt;An &lt;a href=&quot;http://www.digikey.com/product-detail/en/MCP23017-E/SP/MCP23017-E/SP-ND/894272&quot; rel=&quot;nofollow&quot; title=&quot;I2C&quot;&gt;I2C IO expander&lt;/a&gt; might be your best bet.  If your existing I2C device uses a different address, you may be able to put both devices on the same I2C bus.  You would then use 0 additional pins compared to your current design.&lt;/p&gt;&#xA;" OwnerUserId="59" LastActivityDate="2014-03-31T13:37:49.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1027" PostTypeId="2" ParentId="1024" CreationDate="2014-03-31T13:41:23.967" Score="3" Body="&lt;p&gt;I know it's not what you asked, but you're using a lot of pins, why not try streamlining them and go to an I2C backpack? &lt;a href=&quot;http://www.adafruit.com/products/879&quot; rel=&quot;nofollow&quot;&gt;This one from adafruit&lt;/a&gt; includes a single 4x7 segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;given your comment, another option would be an &lt;a href=&quot;http://uk.farnell.com/nxp/saa1064-n2/ic-led-driver-4dgt-i2c-24dip/dp/1627002&quot; rel=&quot;nofollow&quot;&gt;I2C/SPI 7 Segment driver&lt;/a&gt;. (&lt;a href=&quot;http://www.fortito.mx/wp-content/uploads/technical/SAA1064.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;new edit: Actually, when I posted the above 7 segment driver, this is the one I was thinking of. I don't know why I didn't find this the first time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.maximintegrated.com/datasheet/index.mvp/id/1339&quot; rel=&quot;nofollow&quot;&gt;max7219/7221 datasheet&lt;/a&gt; and &lt;a href=&quot;http://www.digikey.com.au/product-search/en?vendor=0&amp;amp;keywords=max7219+%7C+max7221&quot; rel=&quot;nofollow&quot;&gt;digikey source&lt;/a&gt;:&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2014-04-04T05:55:38.513" LastActivityDate="2014-04-04T05:55:38.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1029" PostTypeId="2" ParentId="920" CreationDate="2014-03-31T15:50:26.920" Score="1" Body="&lt;p&gt;First, change all &lt;code&gt;Serial.write&lt;/code&gt; to &lt;code&gt;Serial.print&lt;/code&gt; I think that might be half your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode&#xA;  digitalWrite(9, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way you are doing this will probably put the HC-05 into 9600 baud mode. You can fix this one of two ways: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;BTSerial.begin(38400);&lt;/code&gt; to &lt;code&gt;BTSerial.begin(9600);&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, as jfpoilpret suggested, tie the Key pin directly to VCC.  The reason is that in order to go into 38400 baud mode, there must be voltage on Key at the time the module is powered up.  By the time the digital write in your code happens, it's too late.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If for some reason you'd like to have digital control over the Key pin rather than directly wiring it to VCC, yet you'd like the module to operate at 38400 baud, you can simply change the default baud rate by issuing the appropriate AT command - I believe it's &lt;code&gt;AT+UART=&lt;/code&gt; off the top of my head.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm not sure, but jfpoilpret might be right as well about how your serial read/write handling is done within loop() but here is code that I know works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BTSerial(10, 11); // RX | TX&#xA;char myChar;&#xA;&#xA;void setup()&#xA;{&#xA;  ...&#xA;}&#xA;&#xA;void loop() {&#xA;  while (BTSerial.available()) {&#xA;    myChar = BTSerial.read();&#xA;    Serial.print(myChar);&#xA;  }&#xA;&#xA;  while (Serial.available()) {&#xA;    myChar = Serial.read();&#xA;    Serial.print(myChar); //echo&#xA;    BTSerial.print(myChar);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2014-03-31T16:03:03.513" LastActivityDate="2014-03-31T16:03:03.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1030" PostTypeId="1" AcceptedAnswerId="1031" CreationDate="2014-03-31T16:09:26.943" Score="2" ViewCount="4946" Body="&lt;p&gt;Following &lt;a href=&quot;http://playground.arduino.cc/Code/Eclipse#.UzgDN_nEKG4&quot; rel=&quot;nofollow&quot;&gt;this guide&lt;/a&gt;, it says to include a library in the C++ Linker called &lt;code&gt;m&lt;/code&gt;. What is this for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, &lt;a href=&quot;http://playground.arduino.cc/Code/Eclipse#YourSecondArduinoProject&quot; rel=&quot;nofollow&quot;&gt;Your second Arduino project&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) &lt;strong&gt;Configure project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5th dot point:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AVR C++ Linker -&gt; Libraries: Under libraries, add arduino_core and m (in that order). Under path, add the path to the correct core library, e.g. &quot;&lt;code&gt;${workspace_loc:/arduino_core/328P_16MHz}&lt;/code&gt;&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="693" LastEditorUserId="304" LastEditDate="2014-03-31T16:25:27.933" LastActivityDate="2014-03-31T16:25:27.933" Title="What is the library m in C++ linker?" Tags="|c++|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1031" PostTypeId="2" ParentId="1030" CreationDate="2014-03-31T16:15:42.750" Score="4" Body="&lt;p&gt;The m library is the &quot;math&quot; library. You have to link with it in most flavours of gnu compilers (it is typically not required in other, as it is included in the standard lib) when using functions and stuff from the header file &quot;math.h&quot;.&lt;/p&gt;&#xA;" OwnerUserId="666" LastActivityDate="2014-03-31T16:15:42.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1032" PostTypeId="2" ParentId="1024" CreationDate="2014-03-31T17:01:17.500" Score="3" Body="&lt;p&gt;Are you using your analog pins?  Did you know &lt;a href=&quot;http://arduino.cc/en/Tutorial/AnalogInputPins&quot; rel=&quot;nofollow noreferrer&quot;&gt;they can be used as digital pins&lt;/a&gt;?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The analog pins can be used identically to the digital pins, using the aliases A0 (for analog input 0), A1, etc. For example, the code would look like this to set analog pin 0 to an output, and to set it HIGH:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(A0, OUTPUT);&#xA;digitalWrite(A0, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is your best bet if you aren't using all your analog pins.&lt;/p&gt;&#xA;" OwnerUserId="349" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-03-31T17:01:17.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1033" PostTypeId="2" ParentId="1013" CreationDate="2014-03-31T18:12:50.343" Score="98" Body="&lt;p&gt;Contrarily to other answers, I'd rather stay away from &lt;code&gt;String&lt;/code&gt; for the following reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;dynamic memory usage (that may quickly lead to &lt;strong&gt;heap fragmentation&lt;/strong&gt; and &lt;strong&gt;memory exhaustion&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;quite slow&lt;/strong&gt; due to construction/destruction/assignment operators&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In an embedded environment like Arduino (even for a Mega that has more SRAM), I'd rather use &lt;strong&gt;standard C functions&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strchr/&quot;&gt;&lt;code&gt;strchr()&lt;/code&gt;&lt;/a&gt;: search for a character in a C string (i.e. &lt;code&gt;char *&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strtok/&quot;&gt;&lt;code&gt;strtok()&lt;/code&gt;&lt;/a&gt;: splits a C string into substrings, based on a separator character &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstdlib/atoi/&quot;&gt;&lt;code&gt;atoi()&lt;/code&gt;&lt;/a&gt;: converts a C string to an &lt;code&gt;int&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That would lead to the following code sample:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Calculate based on max input size expected for one command&#xA;#define INPUT_SIZE 30&#xA;...&#xA;&#xA;// Get next command from Serial (add 1 for final 0)&#xA;char input[INPUT_SIZE + 1];&#xA;byte size = Serial.readBytes(input, INPUT_SIZE);&#xA;// Add the final 0 to end the C string&#xA;input[size] = 0;&#xA;&#xA;// Read each command pair &#xA;char* command = strtok(input, &quot;&amp;amp;&quot;);&#xA;while (command != 0)&#xA;{&#xA;    // Split the command in two values&#xA;    char* separator = strchr(command, ':');&#xA;    if (separator != 0)&#xA;    {&#xA;        // Actually split the string in 2: replace ':' with 0&#xA;        *separator = 0;&#xA;        int servoId = atoi(command);&#xA;        ++separator;&#xA;        int position = atoi(separator);&#xA;&#xA;        // Do something with servoId and position&#xA;    }&#xA;    // Find the next command in input string&#xA;    command = strtok(0, &quot;&amp;amp;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The advantage here is that no dynamic memory allocation takes place; you can even declare &lt;code&gt;input&lt;/code&gt; as a local variable inside a function that would read the commands and execute them; once the function is returned the size occupied by &lt;code&gt;input&lt;/code&gt; (in the stack) is recovered.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="18420" LastEditDate="2016-02-17T06:26:05.207" LastActivityDate="2016-02-17T06:26:05.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1034" PostTypeId="1" AcceptedAnswerId="1035" CreationDate="2014-04-01T00:08:17.063" Score="3" ViewCount="1009" Body="&lt;p&gt;I'm trying to upgrade firmware on my wifi shield by following the &lt;a href=&quot;http://arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading&quot; rel=&quot;nofollow&quot;&gt;upgrade instructions for Mac&lt;/a&gt;. I was wondering what this means?:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Connect a jumper on the J3 connector, that put the shield in the programming mode. Then connect the USB cable to the shield USB mini socket&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I do this?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="888" LastEditorUserId="220" LastEditDate="2014-04-01T00:59:31.933" LastActivityDate="2015-01-18T00:53:52.213" Title="updating firmware on arduino wifi shield" Tags="|arduino-uno|wifi|firmware|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1035" PostTypeId="2" ParentId="1034" CreationDate="2014-04-01T00:21:15.250" Score="3" Body="&lt;p&gt;A &quot;jumper&quot; is a little piece of metal (or a 0-ohm resistor) that connects two pads or pins together. So, create an electrical connection across J3 (&quot;DFU programming jumper&quot; in all the pictures). You will then be able to program the shield via USB.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-01T00:21:15.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1036" PostTypeId="2" ParentId="739" CreationDate="2014-04-01T01:22:05.590" Score="9" Body="&lt;p&gt;The oft-repeated advice to &quot;just do &lt;code&gt;sudo usermod -aG dialout &amp;lt;username&amp;gt;&lt;/code&gt; never worked for me, and I finally figured out why. On my machine, &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; is of the group &lt;code&gt;serial&lt;/code&gt; and not &lt;code&gt;dialout&lt;/code&gt;, so adding my username to &lt;code&gt;dialout&lt;/code&gt; did nothing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ls -l&#xA;# crw-rw---- 1 root serial 188, 0 Mar 31 20:52 /dev/ttyUSB0&#xA;                    ^^^^^^ (group-name)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally: &lt;code&gt;sudo usermod -aG &amp;lt;group-name&amp;gt; &amp;lt;username&amp;gt;&lt;/code&gt; fixed it for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Embarrassingly, this is also explicitly mentioned &lt;a href=&quot;http://playground.arduino.cc/Linux/All#.UzoSq1VX-uZ&quot;&gt;here&lt;/a&gt; under &quot;SET THE PERMISSION&quot;. Sigh.&lt;/p&gt;&#xA;" OwnerUserId="889" LastActivityDate="2014-04-01T01:22:05.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1037" PostTypeId="2" ParentId="939" CreationDate="2014-04-01T01:55:41.950" Score="2" Body="&lt;p&gt;It does matter.  There are pros and cons to each different driver setup. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wire the motor as a bipolar, which I'm not sure that you can, you can use the driver that you linked, but it is not very good for driving stepper motors.  &lt;a href=&quot;https://www.sparkfun.com/products/11876&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11876&lt;/a&gt; is a better driver for steppers for half the price.  (still have to wire it bipolar)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to stick with unipolar wiring, &lt;a href=&quot;http://www.pcbheaven.com/circuitpages/Simple_Unipolar_Stepper_Motor_Full_Step_Controller/&quot; rel=&quot;nofollow&quot;&gt;PCBheaven.com&lt;/a&gt; shows an example using a CD4017, MOSFETs, and diodes to run a unipolar motor.  It will only turn one direction.  Instead you could use a micro-controller, such as an Arduino, in place of the CD4017 along with logic-level MOSFETs to go both directions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A tutorial on the Arduino site uses a ULN2003A, which is not powerful enough to drive your motor to its full potential (does it need to turn, or turn well?) and doesn't have the diodes (important to protect your IC!), but the Arduino sketches would still work using the schematic from PCBheaven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of complete driver boards:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.electronickits.com/kit/complete/motor/ck1405.htm&quot; rel=&quot;nofollow&quot;&gt;UNIPOLAR STEPPER MOTOR DRIVER&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.stepperboard.com/SS1010.htm&quot; rel=&quot;nofollow&quot;&gt;FANCY UNIPOLAR STEPPER MOTOR DRIVER&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="887" LastEditorUserId="887" LastEditDate="2014-04-01T05:27:44.073" LastActivityDate="2014-04-01T05:27:44.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1038" PostTypeId="1" CreationDate="2014-04-01T03:00:35.130" Score="3" ViewCount="601" Body="&lt;p&gt;At this stage, my finalized design includes Arduino Nano 3.0, a breakout board and a few electrical components on a breadboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will there be an appreciable cost savings from not buying a ready-made Arduino? The Arduino Nano clone being used costs $17.20. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And is it a good idea if everything is soldered on to a custom fabricated PCB board, including the components of Arduino Nano 3.0? The PCB board will cost around $10 at the quantities I'm starting with.&lt;/p&gt;&#xA;" OwnerUserId="774" LastActivityDate="2014-04-01T03:39:04.360" Title="Building Arduino Nano from components" Tags="|arduino-nano|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1039" PostTypeId="2" ParentId="1038" CreationDate="2014-04-01T03:39:04.360" Score="3" Body="&lt;p&gt;You can probably do a lot better than $17 but not much better than $8:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/Mini-USB-Nano-V3-0-ATmega328P-5V-Micro-controller-Board-For-Arduino-compatible-/130977189883?pt=LH_DefaultDomain_0&amp;amp;hash=item1e7ed94ffb&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/Mini-USB-Nano-V3-0-ATmega328P-5V-Micro-controller-Board-For-Arduino-compatible-/130977189883?pt=LH_DefaultDomain_0&amp;amp;hash=item1e7ed94ffb&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't need USB, you can use a Pro Mini and they go for about $4 and that's really hard to beat.&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-04-01T03:39:04.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1040" PostTypeId="2" ParentId="412" CreationDate="2014-04-01T04:10:46.677" Score="2" Body="&lt;p&gt;The accepted answer of jfpoilpret is very well written, perfectly valid and in 99% of the cases I will do exactly what he explains. His solutions are well within your defined parameters, so they should work very well. But what is better than &quot;&lt;em&gt;very well&lt;/em&gt;&quot;? &lt;strong&gt;Perfection!&lt;/strong&gt; After all, the question is about generating a exact value. As said close enough is good in most cases (arguably all), and even when dealing with something as a clocks when 1 second need to be 1 second, you still have to suffer inherited parts imperfections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I will suggest is not always possible. In some cases, it's possible, but with much more hassle and effort than this case. Is it worthy depend on a case-by-case basis. My goal is mostly to show a alternative for future references that is better in somewhat fringe cases. This is written with novice Arduino users in mind that don't have extensive experience in electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more advanced people this probably will look too verbose and dumbed down. But I believe that, those same people probably already know it and don't need this answer. This is also applicable to every microcontroller and every manufacturer and architecture. But for other microcontrollers you will need to consult the correct datasheet to find out proper registers and prescale names and values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you need a specific frequency and the nice thing about it, is that exactly 56&amp;nbsp;kHz actually can be achieved very easy (not counting practical imperfections of the parts). So this is also a perfect example case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generating a signal depends on the timers and clock source of the microcontroller, as explained well by jfpoilpret. His answer deals with the problem of one point of view only and that is fiddling with timers. But you can fiddle with the clock source too, or even better with both for synergy and awesome results. By changing the parameters of the environment, in this case hacking the system and replacing the clock source, we can deal with a specific problem with much, much more ease and simplicity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First to remind, because of toggling the pin state, you need to execute the ISR two times more than the signal frequency. This is 112,000 times per second. 56,000 and 16,000,000 don't add up very nicely as pointed out already. We need to change either the signal frequency or tact frequency. Let's deal for now with an immutable signal frequency and find a better clock speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be most straightforward to choose a clock with some order of magnitude bigger than 56&amp;nbsp;kHz (or 112&amp;nbsp;kHz, but it is practically the same), as you only add zeros and this kind of math is simplest for most people. Unfortunately everything in this world is some kind of compromise with something. Not every value will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first example is with a too low tact generator speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose a 56,000 Hz clock you won't be able to do anything as you will need to call the ISR every cycle and can't do anything else. It is utterly useless. If you choose 10 times faster speed (560&amp;nbsp;kHz), you will have 9 (10 cycles for the timer to reach its max value - one cycle to call ISR function) microcontroller cycles to do your work and this quite possible can be not enough. You simply often need more computational power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose a value far too great at other hand, as 56&amp;nbsp;MHz the microcontroller simply can't work with it. It is way too fast. So, simply choosing the biggest value in the shop won't cut it either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original Arduino Uno R3 have a stock clock at 16 MHz, so anything slower that that is guaranteed to work. The next value that is an order of magnitude bigger than 56 and lower than 16&amp;nbsp;MHz is 5.6&amp;nbsp;MHz. This will lead to be able to call the ISR every 50 cycles and will create the perfect 112,000 Hz timer frequency. And your signal will be exactly 56&amp;nbsp;kHz. You will have 49 MCU cycles to execute your program between ISR calls, but it is still around 1/3 of the speed of the original clock. One can use 112 as base and use a 11.2&amp;nbsp;MHz clock and this will give a about 2/3 of the stock 16&amp;nbsp;MHz resonator. The ISR function will be called every 100 cycles and still generating a perfect 56&amp;nbsp;kHz signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However two major problems exist with these values.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The first problem severely depends on your needs: You sacrifice about 1/3 (with 11.2&amp;nbsp;MHz) of your maximum computational power to get the exact signal frequency that use an easy-to-find register value (OCR &lt;em&gt;iirc&lt;/em&gt;). You may be fine with it or you may not.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second problem is a &lt;strong&gt;hard showstopper&lt;/strong&gt;: It is very easy to find values, but very often they simply do not exist as a manufactured clock source. This is &lt;a href=&quot;http://bg.farnell.com/crystals&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Farnell's resonator web page&lt;/strong&gt;&lt;/a&gt; that simply lack both 5.6&amp;nbsp;MHz and 11.2&amp;nbsp;MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To circumvent this we can look at available resonator values and find out something else that can be used to generate exactly desired values. If we divide 56 by 4 we get 14 and luckily there is a 14 MHz resonator. This provides us with much higher speed and more power and with equally easy to find register value. To call the ISR 112,000 times per second we need to put value of decimal 124 or hexadecimal 0x7C in the OCR register, so with counting 124 cycles + 1 for calling the ISR, we get our desired perfect value.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;N.B.&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;ISR - interrupt service routine (this is the code that is executed only on generated interrupts)&lt;/li&gt;&#xA;&lt;li&gt;How big your program can be depends on the memory size! It has nothing to do with the clock speed and has nothing to do with how often you call the ISR.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When the microcontroller starts with program command a counter is incremented. If an interrupt is generated, the ISR is called and this value is stored in a special register. When the ISR code completes, the value of the program counter is restored from this special register and the program continues from where it was interrupted as if it had never happened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will give an extremely dumbed-down example. If you are a purist, I warn you: Nose and eye bleeding can occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you have to walk from somewhere to somewhere. The step-by-step route instructions are your main program and its commands. How fast you walk or run, depends on your &quot;clock speed&quot;, but not on the route instructions (30 steps forward, 1 turn 90 grad. left, 10 steps forward, 45 grad. right, etc.) They are always the same. Now imagine a little kid or a greedy corrupt local politician untie your shoes now and then. This is the event that generates an interrupt. Then you halt after your last step, kneel and tie your shoe again. This is your ISR program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you continue from the place you have stopped; you do not start from beginning. When you walk without a care in the world and with all the time, you don't care even if you have to tie your shoe every other step. If you however do it with time constrains, like running in 100 meters on the Olympics (or running from a hungry flesh-eating predator), stopping and tieing your shoes can have dire consequences. The same is with microcontrollers. Even if you execute only one line of code your program will continue, albeit slow. If you don't care about speed at all, it won't be a problem. If you have to do some time related, like using other timer dependent actions, interference can be very unwanted and problematic.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Less is more! A faster clock is not always better. Slower clocked devices use considerably less power. This can be a crucial point in a battery-operated device.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The needed cycles are derived from this formulae: &lt;br/&gt;&#xA;(clock speed / (prescaler value * needed ISR calling frequency)) - 1 &lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="204" LastEditorUserId="510" LastEditDate="2018-03-07T14:40:28.623" LastActivityDate="2018-03-07T14:40:28.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1041" PostTypeId="1" CreationDate="2014-04-01T07:13:23.783" Score="3" ViewCount="2594" Body="&lt;p&gt;Are there any i2c LCD screens that are larger than 2004 characters and larger than 4.8 x 2.7 x 1.2 inches in dimensions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the &lt;a href=&quot;https://www.sainsmart.com/products/20x4-iic-i2c-twi-lcd-module&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sainsmart 2004 LCD&lt;/a&gt; but it can't display all the information that I need. Maybe a 20x8 character screen? Because the screen will be viewed from a distance of about 50cm, the screen size should be at least 5&quot; in diagonal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/X6vHl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="19409" LastEditDate="2018-08-22T04:43:17.523" LastActivityDate="2018-08-22T06:41:08.873" Title="LCDs larger than 20x04 and 5&quot; diagonal" Tags="|lcd|i2c|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1042" PostTypeId="2" ParentId="1041" CreationDate="2014-04-01T07:42:21.237" Score="1" Body="&lt;p&gt;Naked displays... search e.g. Ebay for &quot;40x4 lcd&quot; (maybe enable &quot;worldwide&quot; search)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...naked... so not i2c ... but Arduino libs for these displays exist (e.g.: &lt;a href=&quot;https://code.google.com/p/liquidcrystal440/&quot; rel=&quot;nofollow&quot;&gt;liquidcrystal440&lt;/a&gt;), so add an Arduino-Pro or such and you can have i2c... basically they are two 40x2 displays on the same spi bus selected by different chip select lines...&lt;/p&gt;&#xA;" OwnerUserId="653" LastActivityDate="2014-04-01T07:42:21.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1043" PostTypeId="2" ParentId="412" CreationDate="2014-04-01T08:12:01.450" Score="0" Body="&lt;p&gt;There is no need to use an ISR to create the carrier. Just set up a timer to produce a 50% PWM output at the required carrier frequency. The ISR is then just in charge of modulating the carrier - typically at 0.5 or 1ms intervals - a far more comfortable rate. In my experience a 5% error in carrier frequency is tolerated by most IR receivers. I used a Freetronics EtherMega 2560 (which has plenty of timers) but I'm sure other CPUs will do just as well.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-04-01T08:12:01.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1044" PostTypeId="2" ParentId="26" CreationDate="2014-04-01T12:24:58.600" Score="1" Body="&lt;p&gt;I'm not sure but the problem may also be related to the auto-reset feature of the converter board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I copied the converter board design from the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;nofollow&quot;&gt;Arduino Severino&lt;/a&gt; and according to &lt;a href=&quot;http://arduino.cc/en/uploads/Main/ArduinoSeverinoManual2.pdf&quot; rel=&quot;nofollow&quot;&gt;its manual&lt;/a&gt;, the serial communication must be set to 19,200 bps for the auto-reset feature to work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Be sure that computer COM Port speed is set to 19200bps otherwise&#xA;  auto reset will not work properly.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, I'm using 115,200, so that must be a problem.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-04-01T12:24:58.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1045" PostTypeId="1" AcceptedAnswerId="1052" CreationDate="2014-04-01T14:01:43.577" Score="3" ViewCount="10778" Body="&lt;p&gt;I am connecting my Arduino to my Cubieboard that is running Android.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this originally with my android tablet and USB cable. This worked successfully for the most part using the firmata kit but I don't want to use firmata.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a basic function library written in Java for use with Unity (eg &lt;a href=&quot;https://www.dropbox.com/s/i1mera8850cp6u8/Creating%20a%20Simple%20Unity%20plugin%20to%20Android.mp4&quot; rel=&quot;nofollow&quot;&gt;Library Tutorial Video&lt;/a&gt;) to connect to the Arduino via the USB serial port connection much like a connection with my Windows computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I'd like basic command functions like:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connect / Open&lt;/li&gt;&#xA;&lt;li&gt;Write&lt;/li&gt;&#xA;&lt;li&gt;Read&lt;/li&gt;&#xA;&lt;li&gt;Flush&lt;/li&gt;&#xA;&lt;li&gt;Close&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I was thinking maybe of using this library &lt;a href=&quot;https://github.com/mik3y/usb-serial-for-android&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; but I am unsure how to go about this. I know similar discussion have already taken place on the forum claiming it may not be possible, but it is very clear that it is. It has been done many times. All I need to do is send strings with serial after finding the Arduino's COM port and reading from the serial.&lt;/p&gt;&#xA;" OwnerUserId="878" LastEditorUserId="220" LastEditDate="2014-04-01T22:24:51.150" LastActivityDate="2015-05-12T00:09:57.370" Title="How to create a serial communication connection between Cubieboard running Android and Arduino" Tags="|serial|android|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1046" PostTypeId="1" AcceptedAnswerId="1084" CreationDate="2014-04-01T14:10:24.757" Score="2" ViewCount="2361" Body="&lt;p&gt;This is a follow on question from &lt;a href=&quot;https://arduino.stackexchange.com/questions/1002/how-to-reduce-serial-speed-on-arduino-bootloader-optiboot-and-on-the-ide&quot;&gt;How to reduce serial speed on Arduino bootloader (optiboot) and on the IDE?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did manage recompile optiboot bootloader to work at 57600 bps and uploaded it to a couple of ATmega328-PUs. I just changed the &lt;code&gt;BAUD_RATE&lt;/code&gt; to &lt;code&gt;57600L&lt;/code&gt; in Makefile and recompiled it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They worked just fine with my &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Single Sided Serial (Severino)&lt;/a&gt; and a couple of custom standalone Arduino boards with FTDI-like header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I couldn't program the same MCUs using my Arduino Uno R3. When I try to upload a sketch, avrdude just sits there waiting for a response that doesn't come. The output I got is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Users\Ricardo\arduino-1.0.5\hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : \\.\COM3&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Recv: &#xA;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would that have anything to do with the 2nd MCU that acts as the USB driver on the Uno - the &lt;a href=&quot;http://www.atmel.com/devices/atmega16u2.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega16U2&lt;/a&gt;? Do I have to patch it, too?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Why my recompiled optiboot didn't work with my Arduino Uno R3?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. What can I do to check what's wrong with the upload process using my new bootloader?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-04-06T01:25:44.340" Title="Why my Arduino Uno R3 doesn't work with a recompiled optiboot with BAUD_RATE=57600" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="1048" PostTypeId="1" CreationDate="2014-03-29T04:21:26.530" Score="15" ViewCount="22541" Body="&lt;p&gt;I'd always thought Arduino was a microcontroller platform but the actual microcontroller is an AVR chip made by Atmel, or something like that made by someone else, based on a RISC ISA, and Arduino is usually used to refer to the whole circuit board powered by this AVR chip. Is my understanding correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the difference/relationship between Arduino and AVR?&lt;/p&gt;&#xA;" OwnerDisplayName="user3383182" LastActivityDate="2023-08-27T13:50:11.763" Title="What's the difference/relationship between Arduino and AVR?" Tags="|avr|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1049" PostTypeId="2" ParentId="1048" CreationDate="2014-03-29T04:35:46.177" Score="2" Body="&lt;p&gt;The Arduino is an AVR processor running special code that lets you use the Arduino environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVR's can be used by themselves with some additional supporting components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is a combination of both AVR(chip) and breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVR is a single chip, and would require a breadboard.&lt;/p&gt;&#xA;" OwnerDisplayName="JayG" LastActivityDate="2014-03-29T04:35:46.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1050" PostTypeId="2" ParentId="983" CreationDate="2014-04-01T16:02:02.227" Score="1" Body="&lt;p&gt;MPU6050 is a chip that has an intenal (closed and unknown) algorith to calculate orientation. Because you ar reading ANGLE, that means you are using that algoritm, and that &quot;time&quot; may be the time needed for the calibration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what do you have as output on the serial?&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="643" LastEditDate="2014-04-01T16:15:50.920" LastActivityDate="2014-04-01T16:15:50.920" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1051" PostTypeId="2" ParentId="943" CreationDate="2014-04-01T17:03:15.273" Score="2" Body="&lt;p&gt;There are some chip that measure current flow (like ACS714). Just be sure to buy a chip that will not fry under your load, and mount it in serie with the pump. That chip will bring an analog (but there a re &quot;smarter&quot; chip witch use i2c or spi) signal to arduino, using the formula on the datasheet you can find out real (well, as always there are small error) current flow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should already know the voltage of the pump, but you can easily read it with a similar chip or even a &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;voltage divider&lt;/a&gt;, just pay attention if you are using PWM as if it will fake your reading)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, as already pointed out by Adel Bibi, you can multiply the voltage of the pump with the current value readed (find power), multiply with the time elapsed from the last measure and sum up with precedent measure (integral of the power by time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can do the same on the wind/solar panel, just invert the sign of the current (as you are Producing and not Consuming power) and voilà!&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-01T17:03:15.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1052" PostTypeId="2" ParentId="1045" CreationDate="2014-04-01T17:38:07.207" Score="2" Body="&lt;p&gt;Using the library you linked should be a simple case of downloading the library's jar file from &lt;a href=&quot;https://github.com/mik3y/usb-serial-for-android/releases&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mik3y/usb-serial-for-android/releases&lt;/a&gt; and adding it as a reference/library/dependency (I forget what eclipse calls them) in your eclipse project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then of course providing you connect with the right baud rates and so on it should work.&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2014-04-01T17:38:07.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1054" PostTypeId="2" ParentId="56" CreationDate="2014-04-01T21:55:20.263" Score="10" Body="&lt;p&gt;I always try to isolate the hardware logic from the rest of the domain logic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Classes (or whatever) from domain logic can be programmed in c++ (with the known arduino restrictions like exceptions or std lib) and can be tested with gtest. &#xA;When these classes are tested, simply instance from arduino program excluding the main with tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your project is pure hardware this solution will not help you very much, but if you have your own algorithms, protocols...etc, test them with Google test will save you hours of on board testing and memory problems with unexpected results and your software will gain in quality.&lt;/p&gt;&#xA;" OwnerUserId="655" LastActivityDate="2014-04-01T21:55:20.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1055" PostTypeId="2" ParentId="1048" CreationDate="2014-04-01T22:32:49.503" Score="7" Body="&lt;p&gt;Arduino is a prototyping board, and the term &amp;quot;Arduino&amp;quot; is also used to refer to the IDE and library on the PC side, and the whole ecosystem.&#xA;AVR is the architecture (developed by Atmel) of the microcontroller chip used in all official 8-bit boards, and almost all clones.&#xA;Arduino UNO and 2009, the most used boards, use the AtMega328P chip.&lt;/p&gt;&#xA;&lt;p&gt;Many times, Arduino is used to quickly test some idea, sensor, and circuitry, then a stand-alone board is built around the AtMega chip, as it cost 1/10 of the Arduino board, soldered circuit on a stripboard or on a custom PCB are more reitable, and can be optimized on some aspect, like power usage, space occupied, high current/voltage, and so on.&lt;/p&gt;&#xA;&lt;p&gt;Newest and advanced Arduino board use a different chip with a very different architecture; the Arduino Yun uses a SAM plus a classic AVR, the Due uses an ARM (same architecture used by many smartphones), the Galileo use an x86 (like a classic single-core cpu).&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="-1" LastEditDate="2023-08-26T08:04:42.707" LastActivityDate="2023-08-26T08:04:42.707" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1056" PostTypeId="1" CreationDate="2014-04-02T04:43:15.870" Score="1" ViewCount="1209" Body="&lt;p&gt;I have Code for Mod bus Library as below. I have Gone through lots of forum. How to assign device ID, slave address, length using below library function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleModbusSlave.h&amp;gt;&#xA;#define  LED 9  &#xA;enum &#xA;{     &#xA;&#xA;  ADC_VAL,     &#xA;  PWM_VAL,        &#xA;  HOLDING_REGS_SIZE // leave this one&#xA;};&#xA;&#xA;unsigned int holdingRegs[HOLDING_REGS_SIZE]; &#xA;void setup()&#xA;{&#xA;  modbus_configure(&amp;amp;Serial, 9600, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs);    &#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  modbus_update();&#xA;  holdingRegs[ADC_VAL] = analogRead(A0); // update data to be read by the master to adjust the PWM&#xA;  analogWrite(LED, holdingRegs[PWM_VAL]&amp;gt;&amp;gt;2); // constrain adc value from the arduino master to 255&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am getting Error has.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SimpleModbusSlaveArduino.cpp: In function 'void setup()':&#xA;SimpleModbusSlaveArduino:79: error: 'SERIAL_8N2' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rzaUD.jpg&quot; alt=&quot;Error message for IDE&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have  made changes in the lib as in forum. but I found no value read by my software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master sending below request on read mode. But not receiving anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12:31:02.953: Com8, Baud Rate: 9600, Data Bits: 8 Bits, Parity: None, Stop Bits: 1 Stop Bit&#xA;12:31:02.953: Echoback: On, RTS Control: On, Transmit Delay: 5 ms, Response Delay: 1000 ms&#xA;12:31:02.953: Read Holding Register(s), Repeat Loop&#xA;12:31:02.953: Device Address: 01h, Register: 0000h&#xA;12:31:02.953: |-&amp;gt; Read Register: 0000h&#xA;12:31:02.968: -&amp;gt; [01h] [0Dh] [00h] [00h] [00h] [01h] [CBh] [EDh]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rJSz8.jpg&quot; alt=&quot;my softawre&quot;&gt;&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=176142.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;CHANGES MADE IN AS IN FORUM MENTIONED&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="220" LastEditDate="2014-04-19T13:21:26.243" LastActivityDate="2015-07-08T09:14:49.123" Title="Modbus Protocol Compile Error" Tags="|arduino-uno|programming|arduino-mega|networking|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1058" PostTypeId="2" ParentId="1056" CreationDate="2014-04-02T05:20:16.370" Score="4" Body="&lt;p&gt;Not sure where you got the library from, but if it's from this &lt;a href=&quot;https://github.com/thibs0/EWC2013-Greenhouse-demo/tree/master/Arduino/libraries/SimpleModbusSlave&quot; rel=&quot;nofollow&quot;&gt;github repo&lt;/a&gt;, you're using it wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function prototype for &lt;code&gt;modbus_configure&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void modbus_configure(long baud, byte _slaveID, byte _TxEnablePin, unsigned int _holdingRegsSize, unsigned char _lowLatency);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/thibs0/EWC2013-Greenhouse-demo/blob/master/Arduino/libraries/SimpleModbusSlave/examples/SimpleModbusSlaveExample/SimpleModbusSlaveExample.ino&quot; rel=&quot;nofollow&quot;&gt;example file&lt;/a&gt; shows how to use it correctly&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;modbus_configure(115200, 1, 2, TOTAL_REGS_SIZE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-04-02T05:20:16.370" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1059" PostTypeId="2" ParentId="1056" CreationDate="2014-04-02T09:03:53.263" Score="1" Body="&lt;p&gt;In your first example the error is that SERIAL_8N2 is not declared. maybe you are using an old Arduino IDE? try latest 1.0.x or 1.5.x&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the second case TOTAL_REGS_SIZE is a pointer to int, while the function expect a char. Without code is hard to tell what is wrong and how, but in your first code it should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;modbus_configure(115200, 1, 2, HOLDING_REGS_SIZE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also because you are not passing a reference to the array, you have to pass a pointer pointing the current element in the update function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;modbus_update(holdingRegs[i]);&#xA;i++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-02T09:03:53.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1060" PostTypeId="2" ParentId="943" CreationDate="2014-04-02T10:29:48.043" Score="0" Body="&lt;p&gt;With the accumulator in the system, current draw will increase as that is topped off. The accumulator provides sufficient pressure to drive the system. As system pressure draws down, the pump turns on to bring up the accumulator, with maximum draw nearing cut-off pressure. Taking the total run time of the pump in question (@DLJ) you may chop this up into discrete chunks and measure the draw over those periods, plot that out. I like that greenwall, and I want one. -- Aloha nui loa, MKK&#xA;edit -- As an aside, even a 12V pump driving the smallest 1 liter accumulator to 250 kPa, will draw up to 3A for a few moments, given the size of your system. What motor shield are you using?&lt;/p&gt;&#xA;" OwnerUserId="906" LastEditorUserId="906" LastEditDate="2014-04-02T10:48:40.010" LastActivityDate="2014-04-02T10:48:40.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1061" PostTypeId="2" ParentId="1048" CreationDate="2014-04-02T14:16:34.047" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Arduino#History&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino is a set of open-sourced hardware- and software specifications, originally conceived as a students' platform.&lt;/a&gt; I would add that the specifications, though openly available, are distributed under various public licenses.&lt;/p&gt;&#xA;&lt;p&gt;There are &amp;quot;official&amp;quot; Arduino boards made by an Italian company of the same name, but as the board designs are open-sourced, there are lots of good (and a few &amp;quot;less good&amp;quot;) variants from other sources.&lt;/p&gt;&#xA;&lt;p&gt;AVR refers to the line of MCUs manufactured by Atmel and used in the original designs. Atmel was acquired in 2016 by Microchip Technology, who continue to manufacture the AVR devices.&lt;/p&gt;&#xA;&lt;p&gt;Some of the more recent Arduino designs use more capable processors from other chip manufacturers, but many still use the Atmel/Microchip AVR processors. The smaller AVRs' relative simplicity (ATtiny &amp;amp; ATmega, f/ex) make them ideal for quickly designing/building boards and software for less demanding applications and for learning about programming and digital controls.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2023-08-27T13:50:11.763" LastActivityDate="2023-08-27T13:50:11.763" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1062" PostTypeId="1" CreationDate="2014-04-02T15:20:44.623" Score="2" ViewCount="9134" Body="&lt;p&gt;Is there a way to get a DateTime object from a unix timestamp and hour offset? I want to be able to print a formatted string, for example &lt;code&gt;Wed Apr 02 17:15:06 2014&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A unix timestamp: &lt;code&gt;1396451852&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;An offset from my hour zone, &lt;code&gt;+1&lt;/code&gt; hour.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: I get the timestamp from an internet service and want to make the conversion in the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="655" LastEditorUserId="37" LastEditDate="2014-04-02T17:08:23.607" LastActivityDate="2014-04-04T16:37:32.610" Title="Can I get a Datetime object from a unix timestamp?" Tags="|programming|time|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1063" PostTypeId="2" ParentId="1062" CreationDate="2014-04-02T15:44:39.493" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Code/Time&quot; rel=&quot;nofollow&quot;&gt;Arduino Time Library&lt;/a&gt; looks like it can do it. Or have a look at the strftime() function from unix and unix-oid environments. There is &lt;a href=&quot;http://www.jbox.dk/sanos/source/lib/strftime.c.html&quot; rel=&quot;nofollow&quot;&gt;source to strftime() here&lt;/a&gt;. It's pretty large but you can probably cut it down considerably to just the format parts you need. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-04-02T15:44:39.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1064" PostTypeId="1" CreationDate="2014-04-03T03:46:02.530" Score="3" ViewCount="14394" Body="&lt;p&gt;I'm trying to understand how to fully use the COMPB vector ISR of Timer0 on the ATMega328 (standard Arduino core). I realize it will make delay() and millis() not work but that's ok by me. I've setup some test code that &lt;em&gt;should&lt;/em&gt; output a 244Hz signal on D4 and 488Hz on D5 (note, this is running at 8MHz). But D5 (COMPB) is always what D4 (COMPA) is. Any thoughts? Code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;volatile bool stateA = false;&#xA;ISR(TIMER0_COMPA_vect)&#xA;{&#xA;    if (stateA)&#xA;        PORTD |= _BV(PIND4);&#xA;    else&#xA;        PORTD &amp;amp;= ~(_BV(PIND4));&#xA;&#xA;    stateA = !stateA;&#xA;}&#xA;&#xA;volatile bool stateB = false;&#xA;ISR(TIMER0_COMPB_vect)&#xA;{&#xA;    if (stateB)&#xA;        PORTD |= _BV(PIND5);&#xA;    else&#xA;        PORTD &amp;amp;= ~(_BV(PIND5));&#xA;&#xA;    stateB = !stateB;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    DDRD |= _BV(PIND4) | _BV(PIND5); &#xA;&#xA;    //set timer0 interrupt at 2kHz&#xA;    TCCR0A = 0;// set entire TCCR2A register to 0&#xA;    TCCR0B = 0;// same for TCCR2B&#xA;    TCNT0 = 0;//initialize counter value to 0&#xA;    // set compare match register for 2khz increments&#xA;    OCR0A = 255;//244Hz&#xA;    OCR0B = 127;//488Hz&#xA;    // turn on CTC mode&#xA;    TCCR0A |= (1 &amp;lt;&amp;lt; WGM01);&#xA;    // Set CS01 and CS00 bits for 64 prescaler&#xA;    TCCR0B |= (1 &amp;lt;&amp;lt; CS01) | (1 &amp;lt;&amp;lt; CS00);&#xA;    // enable timer compare interrupt&#xA;    TIMSK0 |= (1 &amp;lt;&amp;lt; OCIE0B) | (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&#xA;    interrupts();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; After thinking about it, I'm realizing that it's not that I need two separate frequencies (though I just kinda wanted to know how, so this is good stuff) but I just need two separate interrupts, only using Timer0 (1 &amp;amp; 2 are already in use elsewhere). They can be the same frequency, most likely. I probably &lt;em&gt;could&lt;/em&gt; put all the functionality I need in the same TIMER0_COMPA_vect, however I was trying to use that in a library I was writing and was trying to keep the functionality separate... this may not be possible.&lt;/p&gt;&#xA;" OwnerUserId="600" LastEditorUserId="600" LastEditDate="2014-04-03T13:46:39.803" LastActivityDate="2020-10-04T20:19:38.967" Title="Using TIMER0_COMPB_vect" Tags="|timers|interrupt|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1065" PostTypeId="2" ParentId="1064" CreationDate="2014-04-03T04:08:58.643" Score="1" Body="&lt;p&gt;Your code doesn't do what you think it does. The timer always runs at 244Hz, and OCR0B only matches twice per period, causing it to have the same frequency but a different phase. What you need to do is set OC0B on compare match and clear it in the overflow ISR. OCR0A you can simply set to toggle on match.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0A = _BV(COM0A0) | _BV(COM0B1) | _BV(COM0B0) | _BV(WGM01);&#xA;TIMSK0 |= _BV(OCIE0A);&#xA;&#xA; ...&#xA;&#xA;ISR(TIMER0_COMPA_vect)&#xA;{&#xA;  PORTB &amp;amp;= ~_BV(PD5);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, OC0A is D6, not D4.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-04-03T04:39:17.847" LastActivityDate="2014-04-03T04:39:17.847" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1066" PostTypeId="2" ParentId="1064" CreationDate="2014-04-03T04:10:31.113" Score="1" Body="&lt;p&gt;I think your code did not set &lt;code&gt;TIMSK0&lt;/code&gt; properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TIMSK0 |= (1 &amp;lt;&amp;lt; OCIE0B) | (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TIMSK0 = (1 &amp;lt;&amp;lt; OCIE0B) | (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? Because &lt;code&gt;TIMSK0&lt;/code&gt; is already initialized by Arduino libraries before your &lt;code&gt;setup()&lt;/code&gt; is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take a look at &lt;code&gt;hardware/arduino/cores/arduino/wiring.c&lt;/code&gt; and search for the &lt;code&gt;init()&lt;/code&gt; function, you will see that it contains the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // enable timer 0 overflow interrupt&#xA;#if defined(TIMSK) &amp;amp;&amp;amp; defined(TOIE0)&#xA;    sbi(TIMSK, TOIE0);&#xA;#elif defined(TIMSK0) &amp;amp;&amp;amp; defined(TOIE0)&#xA;    sbi(TIMSK0, TOIE0);&#xA;#else&#xA;    #error  Timer 0 overflow interrupt not set correctly&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With these lines, the &lt;code&gt;TOIE0&lt;/code&gt; bit of &lt;code&gt;TIMSK0&lt;/code&gt; is set, but your &lt;code&gt;setup()&lt;/code&gt; does not clear it.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-04-03T04:10:31.113" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1067" PostTypeId="1" CreationDate="2014-04-03T04:19:30.183" Score="2" ViewCount="1624" Body="&lt;p&gt;I just bought a WiFi shield and I cannot connect to my wireless network (WPA2). &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I used the &lt;a href=&quot;http://arduino.cc/en/Tutorial/ConnectWithWPA&quot; rel=&quot;nofollow&quot;&gt;sketch from the Arduino site&lt;/a&gt; for connecting to WPA network and put my SSID and password on but it doesn't connect (I know the credentials are correct as I used my phone to connect with these WiFi credentials). &lt;/li&gt;&#xA;&lt;li&gt;When I read the serial monitor it just keeps trying to connect. The WiFi-shield board error light is red&lt;/li&gt;&#xA;&lt;li&gt;I checked my network settings and my block level is at is lowest (NAT only).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why can't I connect?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="888" LastEditorUserId="220" LastEditDate="2014-04-03T22:14:11.090" LastActivityDate="2018-09-23T05:14:28.317" Title="Connecting to network with wifi shield" Tags="|arduino-uno|shields|wifi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1068" PostTypeId="2" ParentId="1064" CreationDate="2014-04-03T04:36:41.190" Score="1" Body="&lt;p&gt;Actually, after reading the ATmega328P datasheet again, I am not sure that you can use both &lt;code&gt;OCR0A&lt;/code&gt; and &lt;code&gt;OCR0B&lt;/code&gt; in normal timer mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, since you use CTC mode, I think that &lt;code&gt;TCNT0&lt;/code&gt; will be cleared every time its value reaches &lt;code&gt;OCR0A&lt;/code&gt; i.e. 127.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you need 244Hz and 488Hz (exactly twice 244Hz), I think you can operate with only one of &lt;code&gt;OCR0A&lt;/code&gt; or &lt;code&gt;OCRB0&lt;/code&gt; and do the work in one ISR only:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;volatile bool setBothPins = false;&#xA;ISR(TIMER0_COMPA_vect)&#xA;{&#xA;    if (setBothPins)&#xA;        // D4 is changed only once (244Hz)for every 2 changes of D5 (488Hz)&#xA;        PORTD ^= _BV(PIND4);&#xA;    PORTD ^= _BV(PIND5);&#xA;&#xA;    setBothPins = !setBothPins;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    DDRD |= _BV(PIND4) | _BV(PIND5); &#xA;&#xA;    //set timer0 interrupt at 2kHz&#xA;    TCCR0A = 0;// set entire TCCR2A register to 0&#xA;    TCCR0B = 0;// same for TCCR2B&#xA;    TCNT0 = 0;//initialize counter value to 0&#xA;    // set compare match register for 2khz increments&#xA;    OCR0A = 127;//488Hz&#xA;    // turn on CTC mode&#xA;    TCCR0A |= (1 &amp;lt;&amp;lt; WGM01);&#xA;    // Set CS01 and CS00 bits for 64 prescaler&#xA;    TCCR0B |= (1 &amp;lt;&amp;lt; CS01) | (1 &amp;lt;&amp;lt; CS00);&#xA;    // enable timer compare interrupt&#xA;    TIMSK0 = (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&#xA;    interrupts();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-04-03T04:56:34.597" LastActivityDate="2014-04-03T04:56:34.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1069" PostTypeId="1" CreationDate="2014-04-03T06:14:35.190" Score="2" ViewCount="1140" Body="&lt;p&gt;I am not able to receive data. I am able to send data from master but am not getting any response. This program uploaded successfully. I have below setup to monitor data from Modbus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have included code for Modbus protocol below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, can someone suggest me the link to download modbus slave config library without any error along with wiring diagram&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11:42:17.000: Device Address: 01h, Register: 000Dh&#xA;11:42:17.000: |-&amp;gt; Read Register: 000Dh&#xA;11:42:17.015: -&amp;gt; [01h] [0Dh] [00h] [0Dh] [00h] [01h] [08h] [7Ch] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/h72Bw.png&quot; alt=&quot;MYsetup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;modbus.h&amp;gt;&#xA;#include &amp;lt;modbusDevice.h&amp;gt;&#xA;#include &amp;lt;modbusRegBank.h&amp;gt;&#xA;#include &amp;lt;modbusSlave.h&amp;gt;&#xA;&#xA;/*&#xA;This example code shows a quick and dirty way to get an&#xA;arduino to talk to a modbus master device with a&#xA;device ID of 1 at 9600 baud.&#xA;*/&#xA;&#xA;//Setup the brewtrollers register bank&#xA;//All of the data accumulated will be stored here&#xA;modbusDevice regBank;&#xA;//Create the modbus slave protocol handler&#xA;modbusSlave slave;&#xA;&#xA;void setup()&#xA;{   &#xA;&#xA;//Assign the modbus device ID.  &#xA;  regBank.setId(1);&#xA;&#xA;/*&#xA;modbus registers follow the following format&#xA;00001-09999  Digital Outputs, A master device can read and write to these registers&#xA;10001-19999  Digital Inputs, A master device can only read the values from these registers&#xA;30001-39999  Analog Inputs, A master device can only read the values from these registers&#xA;40001-49999  Analog Outputs, A master device can read and write to these registers &#xA;&#xA;Analog values are 16 bit unsigned words stored with a range of 0-32767&#xA;Digital values are stored as bytes, a zero value is OFF and any nonzer value is ON&#xA;&#xA;It is best to configure registers of like type into contiguous blocks.  this&#xA;allows for more efficient register lookup and and reduces the number of messages&#xA;required by the master to retrieve the data&#xA;*/&#xA;&#xA;//Add Digital Output registers 00001-00016 to the register bank&#xA;  regBank.add(1);&#xA;  regBank.add(2);&#xA;  regBank.add(3);&#xA;  regBank.add(4);&#xA;  regBank.add(5);&#xA;  regBank.add(6);&#xA;  regBank.add(7);&#xA;  regBank.add(8);&#xA;  regBank.add(9);&#xA;  regBank.add(10);&#xA;  regBank.add(11);&#xA;  regBank.add(12);&#xA;  regBank.add(13);&#xA;  regBank.add(14);&#xA;  regBank.add(15);&#xA;  regBank.add(16);&#xA;&#xA;//Add Digital Input registers 10001-10008 to the register bank&#xA;  regBank.add(10001);  &#xA;  regBank.add(10002);  &#xA;  regBank.add(10003);  &#xA;  regBank.add(10004);  &#xA;  regBank.add(10005);  &#xA;  regBank.add(10006);  &#xA;  regBank.add(10007);  &#xA;  regBank.add(10008);  &#xA;&#xA;//Add Analog Input registers 30001-10010 to the register bank&#xA;  regBank.add(30001);  &#xA;  regBank.add(30002);  &#xA;  regBank.add(30003);  &#xA;  regBank.add(30004);  &#xA;  regBank.add(30005);  &#xA;  regBank.add(30006);  &#xA;  regBank.add(30007);  &#xA;  regBank.add(30008);  &#xA;  regBank.add(30009);  &#xA;  regBank.add(30010);  &#xA;&#xA;//Add Analog Output registers 40001-40020 to the register bank&#xA;  regBank.add(40001);  &#xA;  regBank.add(40002);  &#xA;  regBank.add(40003);  &#xA;  regBank.add(40004);  &#xA;  regBank.add(40005);  &#xA;  regBank.add(40006);  &#xA;  regBank.add(40007);  &#xA;  regBank.add(40008);  &#xA;  regBank.add(40009);  &#xA;  regBank.add(40010);  &#xA;  regBank.add(40011);  &#xA;  regBank.add(40012);  &#xA;  regBank.add(40013);  &#xA;  regBank.add(40014);  &#xA;  regBank.add(40015);  &#xA;  regBank.add(40016);  &#xA;  regBank.add(40017);  &#xA;  regBank.add(40018);  &#xA;  regBank.add(40019);  &#xA;  regBank.add(40020);  &#xA;&#xA;/*&#xA;Assign the modbus device object to the protocol handler&#xA;This is where the protocol handler will look to read and write&#xA;register data.  Currently, a modbus slave protocol handler may&#xA;only have one device assigned to it.&#xA;*/&#xA;  slave._device = &amp;amp;regBank;  &#xA;&#xA;// Initialize the serial port for coms at 9600 baud  &#xA;  slave.setBaud(9600);   &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;//put some data into the registers&#xA;  regBank.set(1, 1);  &#xA;  regBank.set(2, 1);  &#xA;  regBank.set(3, 0);  &#xA;  regBank.set(4, 1);  &#xA;  regBank.set(5, 1);  &#xA;  regBank.set(6, 0);  &#xA;  regBank.set(7, 1);  &#xA;  regBank.set(8, 0);  &#xA;&#xA;  regBank.set(10001, 1);&#xA;  regBank.set(10002, 1);  &#xA;  regBank.set(10003, 1);  &#xA;  regBank.set(10004, 1);  &#xA;  regBank.set(10005, 0);  &#xA;  regBank.set(10006, 0);  &#xA;  regBank.set(10007, 0);  &#xA;  regBank.set(10008, 0);  &#xA;&#xA;&#xA;  regBank.set(30001,1);&#xA;  regBank.set(30002,2);&#xA;  regBank.set(30003,3);&#xA;  regBank.set(30004,4);&#xA;  regBank.set(30005,5);&#xA;  regBank.set(30006,6);&#xA;  regBank.set(30007,7);&#xA;  regBank.set(30008,8);&#xA;  regBank.set(30009,9);&#xA;  regBank.set(30010,10);&#xA;&#xA;  regBank.set(40001,1);&#xA;  regBank.set(40002,2);&#xA;  regBank.set(40003,2);&#xA;  regBank.set(40004,4);&#xA;  regBank.set(40005,5);&#xA;  regBank.set(40006,6);&#xA;  regBank.set(40007,7);&#xA;  regBank.set(40008,8);&#xA;  regBank.set(40009,9);&#xA;  regBank.set(40010,10);&#xA;&#xA; while(1)&#xA;  {&#xA;    //put a random number into registers 1, 10001, 30001 and 40001&#xA;    regBank.set(1, (byte) random(0, 2));&#xA;    regBank.set(10001, (byte) random(0, 2));&#xA;    regBank.set(30001, (word) random(0, 32767));&#xA;    regBank.set(40001, (word) random(0, 32767));&#xA;&#xA;     slave.run();  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="220" LastEditDate="2014-04-04T21:50:30.397" LastActivityDate="2014-04-04T21:50:30.397" Title="MODbus response for configure data" Tags="|programming|modbus|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1072" PostTypeId="1" CreationDate="2014-04-03T13:43:27.917" Score="3" ViewCount="1169" Body="&lt;p&gt;Using an Uno configured with an Adafruit RFID-NFC shield to send the UID values to a desktop game I am building.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works fine. However, in addition to just the UID, I need to send 1 additional value, lets call it 'game choice'. This can be one of 3 values. This is just the relevant code. Can any experts suggest how I might modify the following to send this additional value?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**************************************************************************/&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_NFCShield_I2C.h&amp;gt;&#xA;&#xA;#define IRQ   (2)&#xA;#define RESET (3)  // Not connected by default on the NFC Shield&#xA;&#xA;Adafruit_NFCShield_I2C nfc(IRQ, RESET);&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Hello!&quot;);&#xA;&#xA;  nfc.begin();&#xA;&#xA;  uint32_t versiondata = nfc.getFirmwareVersion();&#xA;  if (! versiondata) {&#xA;    Serial.print(&quot;Didn't find PN53x board&quot;);&#xA;    while (1); // halt&#xA;  }&#xA;  // Got ok data, print it out!&#xA;  Serial.print(&quot;Found chip PN5&quot;); Serial.println((versiondata&amp;gt;&amp;gt;24) &amp;amp; 0xFF, HEX); &#xA;  Serial.print(&quot;Firmware ver. &quot;); Serial.print((versiondata&amp;gt;&amp;gt;16) &amp;amp; 0xFF, DEC); &#xA;  Serial.print('.'); Serial.println((versiondata&amp;gt;&amp;gt;8) &amp;amp; 0xFF, DEC);&#xA;&#xA;  // configure board to read RFID tags&#xA;  nfc.SAMConfig();&#xA;&#xA;  Serial.println(&quot;init&quot;);&#xA;}&#xA;void loop(void) {&#xA;  uint8_t success;&#xA;  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID&#xA;  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)&#xA;  int nfcDEC;  &#xA;  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;&#xA;  if (success) {&#xA;&#xA;&#xA;   nfc.PrintHex(uid, uidLength );&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="765" LastActivityDate="2014-06-03T19:53:57.117" Title="Modifying serial message for Adafruit NFC/RFID card" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1073" PostTypeId="1" CreationDate="2014-04-03T16:11:46.917" Score="0" ViewCount="5846" Body="&lt;p&gt;I am working on code where I am able to manually enter the value in the URL to let the PHP code save it in the database, but I'm unsure how to do it with a variable in a loop running. This is the URL:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;student.cs.hioa.no/~s180343/updatedb.php?verdi=25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Initialize Bridge&#xA;  Bridge.begin();&#xA;&#xA;  // Initialize Serial&#xA;  Serial.begin(9600);&#xA;&#xA;  // Wait until a Serial Monitor is connected.&#xA;  while (!Serial);&#xA;  Serial.println(&quot;Ready&quot;);&#xA;&#xA;  // run various example processes&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;   runCurl();&#xA;   delay(10000);&#xA;}&#xA;&#xA;void runCurl() {&#xA;  // Launch &quot;curl&quot; command and get Arduino ascii art logo from the network&#xA;  // curl is command line program for transferring data using different internet protocols&#xA;  Process p;        // Create a process and call it &quot;p&quot;&#xA;  p.begin(&quot;curl&quot;);  // Process that launch the &quot;curl&quot; command&#xA;  p.addParameter(&quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=25&quot;); // Add the URL parameter to &quot;curl&quot;&#xA;  p.run();      // Run the process and wait for its termination&#xA;&#xA;  // A process output can be read with the stream methods&#xA;  while (p.available()&amp;gt;0) {&#xA;    char c = p.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  // Ensure the last bit of data is sent.&#xA;  Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="884" LastEditorUserId="6936" LastEditDate="2015-08-07T12:16:37.240" LastActivityDate="2015-08-07T12:16:37.240" Title="Pass variable in a URL" Tags="|programming|arduino-yun|variables|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1074" PostTypeId="2" ParentId="1073" CreationDate="2014-04-03T18:51:49.743" Score="2" Body="&lt;p&gt;You can pass in a variable into a function. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void runCurl(int verdi) {&#xA;    ...&#xA;    String myUrl = &quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=&quot;;&#xA;    myUrl += verdi;&#xA;    p.addParameter(myUrl);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You call the function like this, now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;runCurl(1);&#xA;runCurl(2);&#xA;runCurl(someVar);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on. Since it's already in your main &lt;code&gt;loop()&lt;/code&gt; function, you just need to set pass in a different number based on whatever it is you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-04-04T17:47:14.937" LastActivityDate="2014-04-04T17:47:14.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1075" PostTypeId="1" AcceptedAnswerId="1076" CreationDate="2014-04-03T19:03:39.057" Score="6" ViewCount="9060" Body="&lt;p&gt;I want to program an ATtiny through the Arduino IDE. I have a somehow strange programmer. But I can upload via avrdude by &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude -p attiny13 -P /dev/cu.usbmodemfa131     -c stk500v2    -F -B20 -U flash:w:programm.hex &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It took a while to figure out that I had to slow the baud rate via the -B20 switch. If I try to upload via the arduino 1.0.5 IDE avrdude is executed as follows.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny13 -cstk500v1 -P/dev/tty.usbmodemfa131 -Uflash:w:/var/folders/9t/5jldfq752fs1x74_rhn2plz80000gn/T/build7680201613426497544.tmp/attinytest.cpp.hex:i &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My question is, how can I change the preferences such that I have control over the avrdude parameters? Say I want to add a -B20 switch and change stk500v1 to stk500v2. &lt;/p&gt;&#xA;" OwnerUserId="94" LastActivityDate="2014-04-03T20:24:31.653" Title="Change Options for the AVR Programmer via Arduino IDE" Tags="|avrdude|avr|programmer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1076" PostTypeId="2" ParentId="1075" CreationDate="2014-04-03T19:59:19.507" Score="3" Body="&lt;p&gt;&lt;strong&gt;Short answer&lt;/strong&gt;: I'm afraid you can't do it with Arduino IDE 1.0.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long answer&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, be aware that &lt;code&gt;-B20&lt;/code&gt; does not specify the baud rate but the bitclock period (in us); this is specific to &lt;code&gt;stk500v2&lt;/code&gt; programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, enabling your programmer should only be a matter of adding it to the list of programmers known by Arduino IDE; that list can be found in &lt;code&gt;hardware/arduino/programmers.txt&lt;/code&gt;. You would then append the following lines at the end of this file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strangeprogrammer.name=Somehow Strange Programmer&#xA;strangeprogrammer.communication=serial&#xA;strangeprogrammer.protocol=stk500v2&#xA;strangeprogrammer.force=true&#xA;strangeprogrammer.speed=?????&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the problem here is that Arduino IDE does not seem to be able to use flag &lt;code&gt;-B&lt;/code&gt; (bitclock period) but only flag &lt;code&gt;-b&lt;/code&gt; (baud rate) which value is set to whatever you will put to &lt;code&gt;strangeprogrammer.speed&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least that's what I could find out by inspecting Arduino IDE source code: &lt;code&gt;AvrdudeUploader.java&lt;/code&gt; never adds that flag to the &lt;code&gt;avrdude&lt;/code&gt; command-line :-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Rebuild the Arduino IDE 1.0 on your own after modifying &lt;code&gt;AvrdudeUploader.java&lt;/code&gt; to support &lt;code&gt;-B&lt;/code&gt; flag; code should be quite easy (about 2 more lines of Java code).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch to Arduino IDE 1.5 and follow &lt;a href=&quot;https://arduino.stackexchange.com/questions/1075/change-options-for-the-avr-programmer-via-arduino-ide/1077#1077&quot;&gt;Federico's answer&lt;/a&gt; :-)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use another IDE, something that deserves the &lt;strong&gt;IDE&lt;/strong&gt; name. I use Eclipse with this &lt;a href=&quot;http://eclipse.baeyens.it/UsethePlugin.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino plugin&lt;/a&gt; and it works fine for me. As a bonus, avrdude support seems better as you can see on the screenshot below:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gUqsS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-04-03T20:24:31.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1079" PostTypeId="1" CreationDate="2014-04-04T05:46:42.140" Score="4" ViewCount="359" Body="&lt;p&gt;I'm currently developing a Lego Robot, the mindstorm series to be specific. I want to replace the lego NXT brick with an arduino, maybe an intel galileo in the future. How do I establish connections from the arduino with the lego sensors? Also, I would like some input on any cool features that I can add to this robot. This robot is to be seen as a human companion. Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of a sensor i would like to use is here : &lt;a href=&quot;http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&amp;amp;key=NIS1070&quot; rel=&quot;nofollow&quot;&gt;http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&amp;amp;key=NIS1070&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I interface this with an arduino?&lt;/p&gt;&#xA;" OwnerUserId="931" LastEditorUserId="931" LastEditDate="2014-04-04T06:00:41.020" LastActivityDate="2014-04-04T06:50:34.037" Title="Arduino Lego Robot" Tags="|arduino-uno|robotics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1080" PostTypeId="2" ParentId="1067" CreationDate="2014-04-04T06:31:39.580" Score="1" Body="&lt;p&gt;In the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// attempt to connect to Wifi network:&#xA;  while ( status != WL_CONNECTED) { &#xA;    Serial.print(&quot;Attempting to connect to WPA SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network:    &#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;    delay(10000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you add &lt;code&gt;Serial.print(status);&lt;/code&gt; before the delay so you can see if any of these arise:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;WL_IDLE_STATUS = 0&lt;/li&gt;&#xA;&lt;li&gt;WL_NO_SSID_AVAIL &lt;/li&gt;&#xA;&lt;li&gt;WL_CONNECT_FAILED &lt;/li&gt;&#xA;&lt;li&gt;WL_CONNECTION_LOST&lt;/li&gt;&#xA;&lt;li&gt;WL_DISCONNECTED&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They are defined in &lt;code&gt;wl_definitions.h&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="754" LastActivityDate="2014-04-04T06:31:39.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1081" PostTypeId="2" ParentId="1079" CreationDate="2014-04-04T06:50:34.037" Score="2" Body="&lt;p&gt;Doing a quick search on google you can find a couple of shields designed for that purpose:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.robotshop.com/en/arduino-lego-mindstorms-shield-nxshield-d.html&quot; rel=&quot;nofollow&quot;&gt;NXShield-Dx&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://store.wayneandlayne.com/products/bricktronics-shield-kit.html&quot; rel=&quot;nofollow&quot;&gt;Bricktronics shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Second one is allows less motor connections but it's cheaper and has a &lt;a href=&quot;http://shop.oreilly.com/product/0636920024316.do&quot; rel=&quot;nofollow&quot;&gt;book&lt;/a&gt; written by the designers&lt;/p&gt;&#xA;" OwnerUserId="754" LastActivityDate="2014-04-04T06:50:34.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1082" PostTypeId="2" ParentId="1" CreationDate="2014-04-04T07:08:21.227" Score="4" Body="&lt;p&gt;I'd like to mention an issue that doesn't come up very often but can cause long term issues. Memory Leaks and Heap Fragmentation. Almost nobody mallocs in embedded stuff, but if you do, do it right.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-04-04T07:08:21.227" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1083" PostTypeId="1" CreationDate="2014-04-04T09:21:24.980" Score="3" ViewCount="2414" Body="&lt;p&gt;I have the below code. This code is successfully compiling and uploading, but I am not getting any response from Slave. What do I need to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eglU2.jpg&quot; alt=&quot;Error message&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bphiY.png&quot; alt=&quot;Connection diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some time data being received from Slave (I get this error):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wwfhW.jpg&quot; alt=&quot;error2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ID  1&#xA;/*static float ARDUINO_ANALOG_SCALING = 0.00488758;&#xA;static float Ydegree;&#xA;static int Sensor_Value;&#xA;float Yvoltage;&#xA;&#xA;*/&#xA;&#xA;Modbus slave(ID, 0, 0);&#xA;boolean led;&#xA;int8_t state = 0;&#xA;unsigned long tempus;&#xA;// data array for modbus network sharing&#xA;uint16_t au16data[9];&#xA;float latitude=13.08;&#xA;&#xA;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;  slave.begin( 19200 );&#xA;  tempus = millis() + 100;&#xA;  digitalWrite(13, HIGH );&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  state = slave.poll( au16data, 9 );&#xA;  if (state &amp;gt; 4) {&#xA;    tempus = millis() + 50;&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;  if (millis() &amp;gt; tempus) digitalWrite(13, LOW );&#xA;&#xA;&#xA;  au16data[4] = analogRead(0);&#xA;  au16data[5] = analogRead(1);&#xA;&#xA;&#xA;&#xA;  au16data[6] = slave.getInCnt();&#xA;  au16data[7] = slave.getOutCnt();&#xA;  au16data[8] = slave.getErrCnt();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modbus code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define  MAX_BUFFER  64 &#xA;typedef struct {&#xA;  uint8_t u8id;          /*!&amp;lt; slave address between 1 and 247. 0 means broadcast */&#xA;  uint8_t u8fct;         /*!&amp;lt; function code: 1, 2, 3, 4, 5, 6, 15 or 16 */&#xA;  uint16_t u16RegAdd;    /*!&amp;lt; address of the first register to access at slave/s */&#xA;  uint16_t u16CoilsNo;   /*!&amp;lt; number of coils or registers to access */&#xA;  uint16_t *au16reg;     /*!&amp;lt; pointer to memory image in master */&#xA;}&#xA;modbus_t;&#xA;&#xA;enum {&#xA;  RESPONSE_SIZE = 6,&#xA;  EXCEPTION_SIZE = 3,&#xA;  CHECKSUM_SIZE = 2&#xA;};&#xA;&#xA;enum MESSAGE {&#xA;  ID = 0,&#xA;  FUNC,&#xA;  ADD_HI,&#xA;  ADD_LO,&#xA;  NB_HI,&#xA;  NB_LO,&#xA;  BYTE_CNT&#xA;};&#xA;&#xA;enum MB_FC {&#xA;  MB_FC_NONE                     = 0,   /*!&amp;lt; null operator */&#xA;  MB_FC_READ_COILS               = 1,   /*!&amp;lt; FCT=1 -&amp;gt; read coils or digital outputs */&#xA;  MB_FC_READ_DISCRETE_INPUT      = 2,   /*!&amp;lt; FCT=2 -&amp;gt; read digital inputs */&#xA;  MB_FC_READ_REGISTERS           = 3,   /*!&amp;lt; FCT=3 -&amp;gt; read registers or analog outputs */&#xA;  MB_FC_READ_INPUT_REGISTER      = 4,   /*!&amp;lt; FCT=4 -&amp;gt; read analog inputs */&#xA;  MB_FC_WRITE_COIL               = 5,   /*!&amp;lt; FCT=5 -&amp;gt; write single coil or output */&#xA;  MB_FC_WRITE_REGISTER           = 6,   /*!&amp;lt; FCT=6 -&amp;gt; write single register */&#xA;  MB_FC_WRITE_MULTIPLE_COILS     = 15,  /*!&amp;lt; FCT=15 -&amp;gt; write multiple coils or outputs */&#xA;  MB_FC_WRITE_MULTIPLE_REGISTERS = 16   /*!&amp;lt; FCT=16 -&amp;gt; write multiple registers */&#xA;};&#xA;&#xA;enum COM_STATES {&#xA;  COM_IDLE                     = 0,&#xA;  COM_WAITING                  = 1&#xA;&#xA;};&#xA;&#xA;enum ERR_LIST {&#xA;  ERR_NOT_MASTER                = -1,&#xA;  ERR_POLLING                   = -2,&#xA;  ERR_BUFF_OVERFLOW             = -3,&#xA;  ERR_BAD_CRC                   = -4,&#xA;  ERR_EXCEPTION                 = -5&#xA;};&#xA;&#xA;&#xA;enum {&#xA;  NO_REPLY = 255,           /*!&amp;lt; */&#xA;  EXC_FUNC_CODE = 1,        /*!&amp;lt; Function code not available */&#xA;  EXC_ADDR_RANGE = 2,       /*!&amp;lt; Address beyond available space for Modbus registers */&#xA;  EXC_REGS_QUANT = 3,       /*!&amp;lt; Coils or registers number beyond the available space */&#xA;  EXC_EXECUTE = 4           /*!&amp;lt; */&#xA;};&#xA;&#xA;&#xA;const unsigned char fctsupported[] = {&#xA;  MB_FC_READ_COILS,&#xA;  MB_FC_READ_DISCRETE_INPUT,&#xA;  MB_FC_READ_REGISTERS,&#xA;  MB_FC_READ_INPUT_REGISTER,&#xA;  MB_FC_WRITE_COIL,&#xA;  MB_FC_WRITE_REGISTER,&#xA;  MB_FC_WRITE_MULTIPLE_COILS,&#xA;  MB_FC_WRITE_MULTIPLE_REGISTERS&#xA;};&#xA;&#xA;#define T35  5&#xA;&#xA;class Modbus {&#xA;private:&#xA;  HardwareSerial *port; //!&amp;lt; Pointer to Serial class object&#xA;  uint8_t u8id; //!&amp;lt;0=master, 1..247=slave number&#xA;  uint8_t u8serno; //!&amp;lt;serial port: 0-Serial, 1..3-Serial1..Serial3&#xA;  uint8_t u8txenpin; //!&amp;lt;flow control pin: 0=USB or RS-232 mode, &amp;gt;0=RS-485 mode&#xA;  uint8_t u8state;&#xA;  uint8_t au8Buffer[MAX_BUFFER];&#xA;  uint8_t u8BufferSize;&#xA;  uint8_t u8lastRec;&#xA;  uint16_t *au16regs;&#xA;  uint16_t u16InCnt, u16OutCnt, u16errCnt;&#xA;  uint16_t u16timeOut;&#xA;  uint32_t u32time, u32timeOut;&#xA;  uint8_t u8regsize;&#xA;&#xA;  void init(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin);&#xA;  void sendTxBuffer(); // transmit buffer to serial port&#xA;  int8_t getRxBuffer(); // get serial buffer contents&#xA;  uint16_t calcCRC(uint8_t u8length); // get CRC from au8Buffer until u8length&#xA;  uint8_t validateAnswer();&#xA;  uint8_t validateRequest(); // validate master request&#xA;  void get_FC1(); // *** only master ***&#xA;  void get_FC3(); // *** only master ***&#xA;  int8_t process_FC1( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  int8_t process_FC3( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  int8_t process_FC5( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  int8_t process_FC6( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  int8_t process_FC15( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  int8_t process_FC16( uint16_t *regs, uint8_t u8size ); //!&amp;lt; *** only slave ***&#xA;  void buildException( uint8_t u8exception ); // build exception message&#xA;&#xA;public:&#xA;  Modbus(); // !&amp;lt; Default Constructor&#xA;  Modbus(uint8_t u8id, uint8_t u8serno); // !&amp;lt; Constructor&#xA;  Modbus(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin); // !&amp;lt; Full Constructor&#xA;  void begin(long u32speed);&#xA;  void begin();&#xA;  void setTimeOut( uint16_t u16timeout); //!&amp;lt; write communication watch-dog timer&#xA;  uint16_t getTimeOut(); //!&amp;lt; get communication watch-dog timer value&#xA;  boolean getTimeOutState(); //!&amp;lt; get communication watch-dog timer state&#xA;  int8_t query( modbus_t telegram ); //!&amp;lt; only for master&#xA;  int8_t poll(); //!&amp;lt; cyclic poll for master&#xA;  int8_t poll( uint16_t *regs, uint8_t u8size ); //!&amp;lt; cyclic poll for slave&#xA;  uint16_t getInCnt(); //!&amp;lt; number of incoming messages&#xA;  uint16_t getOutCnt(); //!&amp;lt; number of outcoming messages&#xA;  uint16_t getErrCnt(); //!&amp;lt; error counter&#xA;  uint8_t getID(); //!&amp;lt; get slave ID between 1 and 247&#xA;  uint8_t getState();&#xA;  uint8_t getLastError(); //!&amp;lt; get last error message&#xA;  void setID( uint8_t u8id ); //!&amp;lt; write new ID for the slave&#xA;  void end(); //!&amp;lt; finish any communication and release serial communication port&#xA;};&#xA;&#xA;&#xA;Modbus::Modbus() {&#xA;  init(0, 0, 0);&#xA;}&#xA;&#xA;&#xA;Modbus::Modbus(uint8_t u8id, uint8_t u8serno) {&#xA;  init(u8id, u8serno, 0);&#xA;}&#xA;&#xA;Modbus::Modbus(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) {&#xA;  init(u8id, u8serno, u8txenpin);&#xA;}&#xA;&#xA;&#xA;void Modbus::begin(long u32speed) {&#xA;&#xA;  switch ( u8serno ) {&#xA;#if defined(UBRR1H)&#xA;  case 1:&#xA;    port = &amp;amp;Serial1;&#xA;    break;&#xA;#endif&#xA;&#xA;#if defined(UBRR2H)&#xA;  case 2:&#xA;    port = &amp;amp;Serial2;&#xA;    break;&#xA;#endif&#xA;&#xA;#if defined(UBRR3H)&#xA;  case 3:&#xA;    port = &amp;amp;Serial3;&#xA;    break;&#xA;#endif&#xA;  case 0:&#xA;  default:&#xA;    port = &amp;amp;Serial;&#xA;    break;&#xA;  }&#xA;&#xA;  // port-&amp;gt;begin(u32speed, u8config);&#xA;  port-&amp;gt;begin(u32speed);&#xA;  if (u8txenpin &amp;gt; 1) { // pin 0 &amp;amp; pin 1 are reserved for RX/TX&#xA;    // return RS485 transceiver to transmit mode&#xA;    pinMode(u8txenpin, OUTPUT);&#xA;    digitalWrite(u8txenpin, LOW);&#xA;  }&#xA;&#xA;  port-&amp;gt;flush();&#xA;  u8lastRec = u8BufferSize = 0;&#xA;  u16InCnt = u16OutCnt = u16errCnt = 0;&#xA;}&#xA;&#xA;&#xA;void Modbus::begin() {&#xA;  begin(19200);&#xA;}&#xA;&#xA;void Modbus::setID( uint8_t u8id) {&#xA;  if (( u8id != 0) &amp;amp;&amp;amp; (u8id &amp;lt;= 247)) {&#xA;    this-&amp;gt;u8id = u8id;&#xA;  }&#xA;}&#xA;&#xA;&#xA;uint8_t Modbus::getID() {&#xA;  return this-&amp;gt;u8id;&#xA;}&#xA;&#xA;&#xA;void Modbus::setTimeOut( uint16_t u16timeOut) {&#xA;  this-&amp;gt;u16timeOut = u16timeOut;&#xA;}&#xA;&#xA;&#xA;boolean Modbus::getTimeOutState() {&#xA;  return (millis() &amp;gt; u32timeOut);&#xA;}&#xA;&#xA;&#xA;uint16_t Modbus::getInCnt() {&#xA;  return u16InCnt;&#xA;}&#xA;&#xA;&#xA;uint16_t Modbus::getOutCnt() {&#xA;  return u16OutCnt;&#xA;}&#xA;&#xA;uint16_t Modbus::getErrCnt() {&#xA;  return u16errCnt;&#xA;}&#xA;&#xA;&#xA;uint8_t Modbus::getState() {&#xA;  return u8state;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::query( modbus_t telegram ) {&#xA;  uint8_t u8regsno, u8bytesno;&#xA;  if (u8id != 0) return -2;&#xA;  if (u8state != COM_IDLE) return -1;&#xA;&#xA;  if ((telegram.u8id == 0) || (telegram.u8id &amp;gt; 247)) return -3;&#xA;&#xA;  au16regs = telegram.au16reg;&#xA;&#xA;  // telegram header&#xA;  au8Buffer[ ID ]         = telegram.u8id;&#xA;  au8Buffer[ FUNC ]       = telegram.u8fct;&#xA;  au8Buffer[ ADD_HI ]     = highByte(telegram.u16RegAdd );&#xA;  au8Buffer[ ADD_LO ]     = lowByte( telegram.u16RegAdd );&#xA;&#xA;  switch ( telegram.u8fct ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;  case MB_FC_READ_REGISTERS:&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    au8Buffer[ NB_HI ]      = ((au16regs[0] &amp;gt; 0) ? 0xff : 0);&#xA;    au8Buffer[ NB_LO ]      = 0;&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER:&#xA;    au8Buffer[ NB_HI ]      = highByte(au16regs[0]);&#xA;    au8Buffer[ NB_LO ]      = lowByte(au16regs[0]);&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    u8regsno = telegram.u16CoilsNo / 16;&#xA;    u8bytesno = u8regsno * 2;&#xA;    if ((telegram.u16CoilsNo % 16) != 0) {&#xA;      u8bytesno++;&#xA;      u8regsno++;&#xA;    }&#xA;&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO + 1 ]    = u8bytesno;&#xA;    u8BufferSize = 7;&#xA;&#xA;    u8regsno = u8bytesno = 0; // now auxiliary registers&#xA;    for (uint16_t i = 0; i &amp;lt; telegram.u16CoilsNo; i++) {&#xA;&#xA;&#xA;    }&#xA;    break;&#xA;&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS:&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO + 1 ]    = (uint8_t) ( telegram.u16CoilsNo * 2 );&#xA;    u8BufferSize = 7;&#xA;&#xA;    for (uint16_t i = 0; i &amp;lt; telegram.u16CoilsNo; i++) {&#xA;      au8Buffer[ u8BufferSize ] = highByte( au16regs[ i ] );&#xA;      u8BufferSize++;&#xA;      au8Buffer[ u8BufferSize ] = lowByte( au16regs[ i ] );&#xA;      u8BufferSize++;&#xA;    }&#xA;    break;&#xA;  }&#xA;&#xA;  sendTxBuffer();&#xA;  u8state = COM_WAITING;&#xA;  return 0;&#xA;}&#xA;&#xA;int8_t Modbus::poll() {&#xA;  // check if there is any incoming frame&#xA;  uint8_t u8current = port-&amp;gt;available();&#xA;&#xA;  if (millis() &amp;gt; u32timeOut) {&#xA;    u8state = COM_IDLE;&#xA;    u16errCnt++;&#xA;    return 0;&#xA;  }&#xA;&#xA;  if (u8current == 0) return 0;&#xA;&#xA;  // check T35 after frame end or still no frame end&#xA;  if (u8current != u8lastRec) {&#xA;    u8lastRec = u8current;&#xA;    u32time = millis() + T35;&#xA;    return 0;&#xA;  }&#xA;  if (millis() &amp;lt; u32time) return 0;&#xA;&#xA;  // transfer Serial buffer frame to auBuffer&#xA;  u8lastRec = 0;&#xA;  int8_t i8state = getRxBuffer();&#xA;  if (i8state &amp;lt; 7) {&#xA;    u8state = COM_IDLE;&#xA;    u16errCnt++;&#xA;    return i8state;&#xA;  }&#xA;&#xA;  // validate message: id, CRC, FCT, exception&#xA;  uint8_t u8exception = validateAnswer();&#xA;  if (u8exception != 0) {&#xA;    u8state = COM_IDLE;&#xA;    return u8exception;&#xA;  }&#xA;&#xA;  // process answer&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;    // call get_FC1 to transfer the incoming message to au16regs buffer&#xA;    get_FC1( );&#xA;    break;&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;  case MB_FC_READ_REGISTERS :&#xA;    // call get_FC3 to transfer the incoming message to au16regs buffer&#xA;    get_FC3( );&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;  case MB_FC_WRITE_REGISTER :&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    // nothing to do&#xA;    break;&#xA;  default:&#xA;    break;&#xA;  }&#xA;  u8state = COM_IDLE;&#xA;  return u8BufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::poll( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  au16regs = regs;&#xA;  u8regsize = u8size;&#xA;&#xA;  // check if there is any incoming frame&#xA;  uint8_t u8current = port-&amp;gt;available();&#xA;  if (u8current == 0) return 0;&#xA;&#xA;  // check T35 after frame end or still no frame end&#xA;  if (u8current != u8lastRec) {&#xA;    u8lastRec = u8current;&#xA;    u32time = millis() + T35;&#xA;    return 0;&#xA;  }&#xA;  if (millis() &amp;lt; u32time) return 0;&#xA;&#xA;  u8lastRec = 0;&#xA;  int8_t i8state = getRxBuffer();&#xA;  if (i8state &amp;lt; 7) return i8state;&#xA;&#xA;  // check slave id&#xA;  if (au8Buffer[ ID ] != u8id) return 0;&#xA;&#xA;  // validate message: CRC, FCT, address and size&#xA;  uint8_t u8exception = validateRequest();&#xA;  if (u8exception &amp;gt; 0) {&#xA;    if (u8exception != NO_REPLY) {&#xA;      buildException( u8exception );&#xA;      sendTxBuffer();&#xA;    }&#xA;    return u8exception;&#xA;  }&#xA;&#xA;  u32timeOut = millis() + long(u16timeOut);&#xA;&#xA;  // process message&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;    return process_FC1( regs, u8size );&#xA;    break;&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;  case MB_FC_READ_REGISTERS :&#xA;    return process_FC3( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    return process_FC5( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER :&#xA;    return process_FC6( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    return process_FC15( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    return process_FC16( regs, u8size );&#xA;    break;&#xA;  default:&#xA;    break;&#xA;  }&#xA;}&#xA;&#xA;/* _____PRIVATE FUNCTIONS_____________________________________________________ */&#xA;&#xA;void Modbus::init(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) {&#xA;  this-&amp;gt;u8id = u8id;&#xA;  this-&amp;gt;u8serno = (u8serno &amp;gt; 3) ? 0 : u8serno;&#xA;  this-&amp;gt;u8txenpin = u8txenpin;&#xA;  this-&amp;gt;u16timeOut = 1000;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::getRxBuffer() {&#xA;  boolean bBuffOverflow = false;&#xA;&#xA;  if (u8txenpin &amp;gt; 1) digitalWrite( u8txenpin, LOW );&#xA;&#xA;  u8BufferSize = 0;&#xA;  while ( port-&amp;gt;available() ) {&#xA;    au8Buffer[ u8BufferSize ] = port-&amp;gt;read();&#xA;    u8BufferSize ++;&#xA;&#xA;    if (u8BufferSize &amp;gt;= MAX_BUFFER) bBuffOverflow = true;&#xA;  }&#xA;  u16InCnt++;&#xA;&#xA;  if (bBuffOverflow) {&#xA;    u16errCnt++;&#xA;    return ERR_BUFF_OVERFLOW;&#xA;  }&#xA;  return u8BufferSize;&#xA;}&#xA;&#xA;&#xA;void Modbus::sendTxBuffer() {&#xA;  uint8_t i = 0;&#xA;&#xA;  // append CRC to message&#xA;  uint16_t u16crc = calcCRC( u8BufferSize );&#xA;  au8Buffer[ u8BufferSize ] = u16crc &amp;gt;&amp;gt; 8;&#xA;  u8BufferSize++;&#xA;  au8Buffer[ u8BufferSize ] = u16crc &amp;amp; 0x00ff;&#xA;  u8BufferSize++;&#xA;&#xA;  // set RS485 transceiver to transmit mode&#xA;  if (u8txenpin &amp;gt; 1) {&#xA;    switch ( u8serno ) {&#xA;#if defined(UBRR1H)&#xA;    case 1:&#xA;      UCSR1A = UCSR1A | (1 &amp;lt;&amp;lt; TXC1);&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR2H)&#xA;    case 2:&#xA;      UCSR2A = UCSR2A | (1 &amp;lt;&amp;lt; TXC2);&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR3H)&#xA;    case 3:&#xA;      UCSR3A = UCSR3A | (1 &amp;lt;&amp;lt; TXC3);&#xA;      break;&#xA;#endif&#xA;    case 0:&#xA;    default:&#xA;      UCSR0A = UCSR0A | (1 &amp;lt;&amp;lt; TXC0);&#xA;      break;&#xA;    }&#xA;    digitalWrite( u8txenpin, HIGH );&#xA;  }&#xA;&#xA;  // transfer buffer to serial line&#xA;  port-&amp;gt;write( au8Buffer, u8BufferSize );&#xA;&#xA;  // keep RS485 transceiver in transmit mode as long as sending&#xA;  if (u8txenpin &amp;gt; 1) {&#xA;    switch ( u8serno ) {&#xA;#if defined(UBRR1H)&#xA;    case 1:&#xA;      while (!(UCSR1A &amp;amp; (1 &amp;lt;&amp;lt; TXC1)));&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR2H)&#xA;    case 2:&#xA;      while (!(UCSR2A &amp;amp; (1 &amp;lt;&amp;lt; TXC2)));&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR3H)&#xA;    case 3:&#xA;      while (!(UCSR3A &amp;amp; (1 &amp;lt;&amp;lt; TXC3)));&#xA;      break;&#xA;#endif&#xA;    case 0:&#xA;    default:&#xA;      while (!(UCSR0A &amp;amp; (1 &amp;lt;&amp;lt; TXC0)));&#xA;      break;&#xA;    }&#xA;&#xA;    // return RS485 transceiver to receive mode&#xA;    digitalWrite( u8txenpin, LOW );&#xA;  }&#xA;  port-&amp;gt;flush();&#xA;  u8BufferSize = 0;&#xA;&#xA;  // set time-out for master&#xA;  u32timeOut = millis() + (unsigned long) u16timeOut;&#xA;&#xA;  // increase message counter&#xA;  u16OutCnt++;&#xA;}&#xA;&#xA;/**&#xA; * @brief&#xA; * This method calculates CRC&#xA; *&#xA; * @return uint16_t calculated CRC value for the message&#xA; * @ingroup buffer&#xA; */&#xA;uint16_t Modbus::calcCRC(uint8_t u8length) {&#xA;  unsigned int temp, temp2, flag;&#xA;  temp = 0xFFFF;&#xA;  for (unsigned char i = 0; i &amp;lt; u8length; i++) {&#xA;    temp = temp ^ au8Buffer[i];&#xA;    for (unsigned char j = 1; j &amp;lt;= 8; j++) {&#xA;      flag = temp &amp;amp; 0x0001;&#xA;      temp &amp;gt;&amp;gt;= 1;&#xA;      if (flag)&#xA;        temp ^= 0xA001;&#xA;    }&#xA;  }&#xA;  // Reverse byte order.&#xA;  temp2 = temp &amp;gt;&amp;gt; 8;&#xA;  temp = (temp &amp;lt;&amp;lt; 8) | temp2;&#xA;  temp &amp;amp;= 0xFFFF;&#xA;  // the returned value is already swapped&#xA;  // crcLo byte is first &amp;amp; crcHi byte is last&#xA;  return temp;&#xA;}&#xA;&#xA;uint8_t Modbus::validateRequest() {&#xA;  // check message crc vs calculated crc&#xA;  uint16_t u16MsgCRC =&#xA;    ((au8Buffer[u8BufferSize - 2] &amp;lt;&amp;lt; 8)&#xA;    | au8Buffer[u8BufferSize - 1]); // combine the crc Low &amp;amp; High bytes&#xA;  if ( calcCRC( u8BufferSize - 2 ) != u16MsgCRC ) {&#xA;    u16errCnt ++;&#xA;    return NO_REPLY;&#xA;  }&#xA;&#xA;  // check fct code&#xA;  boolean isSupported = false;&#xA;  for (uint8_t i = 0; i &amp;lt; sizeof( fctsupported ); i++) {&#xA;    if (fctsupported[i] == au8Buffer[FUNC]) {&#xA;      isSupported = 1;&#xA;      break;&#xA;    }&#xA;  }&#xA;  if (!isSupported) {&#xA;    u16errCnt ++;&#xA;    return EXC_FUNC_CODE;&#xA;  }&#xA;&#xA;  // check start address &amp;amp; nb range&#xA;  uint16_t u16regs = 0;&#xA;  uint8_t u8regs;&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;&#xA;    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]) / 16;&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER :&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_READ_REGISTERS :&#xA;  case MB_FC_READ_INPUT_REGISTER :&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);&#xA;    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]);&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  }&#xA;  return 0; // OK, no exception code thrown&#xA;}&#xA;&#xA;&#xA;uint8_t Modbus::validateAnswer() {&#xA;  // check message crc vs calculated crc&#xA;  uint16_t u16MsgCRC =&#xA;    ((au8Buffer[u8BufferSize - 2] &amp;lt;&amp;lt; 8)&#xA;    | au8Buffer[u8BufferSize - 1]); // combine the crc Low &amp;amp; High bytes&#xA;  if ( calcCRC( u8BufferSize - 2 ) != u16MsgCRC ) {&#xA;    u16errCnt ++;&#xA;    return NO_REPLY;&#xA;  }&#xA;&#xA;  // check exception&#xA;  if ((au8Buffer[ FUNC ] &amp;amp; 0x80) != 0) {&#xA;    u16errCnt ++;&#xA;    return ERR_EXCEPTION;&#xA;  }&#xA;&#xA;  // check fct code&#xA;  boolean isSupported = false;&#xA;  for (uint8_t i = 0; i &amp;lt; sizeof( fctsupported ); i++) {&#xA;    if (fctsupported[i] == au8Buffer[FUNC]) {&#xA;      isSupported = 1;&#xA;      break;&#xA;    }&#xA;  }&#xA;  if (!isSupported) {&#xA;    u16errCnt ++;&#xA;    return EXC_FUNC_CODE;&#xA;  }&#xA;&#xA;  return 0; // OK, no exception code thrown&#xA;}&#xA;&#xA;&#xA;void Modbus::buildException( uint8_t u8exception ) {&#xA;  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code&#xA;&#xA;  au8Buffer[ ID ]      = u8id;&#xA;  au8Buffer[ FUNC ]    = u8func + 0x80;&#xA;  au8Buffer[ 2 ]       = u8exception;&#xA;  u8BufferSize         = EXCEPTION_SIZE;&#xA;}&#xA;&#xA;&#xA;void Modbus::get_FC1() {&#xA;  uint8_t u8byte, i;&#xA;  u8byte = 0;&#xA;&#xA;  // check the answer length&#xA;  boolean bEvenOdd =&#xA;    ( au8Buffer[ ADD_HI ] % 2 == 0) ?&#xA;  false :&#xA;  true;&#xA;&#xA;  uint8_t u8WordsNo =&#xA;    ( !bEvenOdd ) ?&#xA;  au8Buffer[ ADD_HI ] / 2 :&#xA;  au8Buffer[ ADD_HI ] / 2 + 1;&#xA;&#xA;  for (i = 0; i &amp;lt; u8WordsNo; i++) {&#xA;    au16regs[ i ] = word(&#xA;    au8Buffer[ u8byte ],&#xA;    au8Buffer[ u8byte + 1 ]);&#xA;    u8byte += 2;&#xA;  }&#xA;&#xA;  // cut last byte&#xA;  if (bEvenOdd) {&#xA;    au16regs[ u8WordsNo - 1 ] &amp;amp;= 0xff00;&#xA;  }&#xA;}&#xA;&#xA;void Modbus::get_FC3() {&#xA;  uint8_t u8byte, i;&#xA;  u8byte = 3;&#xA;&#xA;  for (i = 0; i &amp;lt; au8Buffer[ 2 ] / 2; i++) {&#xA;    au16regs[ i ] = word(&#xA;    au8Buffer[ u8byte ],&#xA;    au8Buffer[ u8byte + 1 ]);&#xA;    u8byte += 2;&#xA;  }&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC1( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit, u8bytesno, u8bitsno;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16currentCoil, u16coil;&#xA;&#xA;  // get the first and last coil from the message&#xA;  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;  // put the number of bytes in the outcoming message&#xA;  u8bytesno = (uint8_t) (u16Coilno / 8);&#xA;  if (u16Coilno % 8 != 0) u8bytesno ++;&#xA;  au8Buffer[ ADD_HI ]  = u8bytesno;&#xA;  u8BufferSize         = ADD_LO;&#xA;&#xA;  // read each coil from the register map and put its value inside the outcoming message&#xA;  u8bitsno = 0;&#xA;&#xA;  for (u16currentCoil = 0; u16currentCoil &amp;lt; u16Coilno; u16currentCoil++) {&#xA;    u16coil = u16StartCoil + u16currentCoil;&#xA;    u8currentRegister = (uint8_t) (u16coil / 16);&#xA;    u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;    bitWrite(&#xA;    au8Buffer[ u8BufferSize ],&#xA;    u8bitsno,&#xA;    bitRead( regs[ u8currentRegister ], u8currentBit ) );&#xA;    u8bitsno ++;&#xA;&#xA;    if (u8bitsno &amp;gt; 7) {&#xA;      u8bitsno = 0;&#xA;      u8BufferSize++;&#xA;    }&#xA;  }&#xA;&#xA;  // send outcoming message&#xA;  if (u16Coilno % 8 != 0) u8BufferSize ++;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;int8_t Modbus::process_FC3( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  uint8_t u8StartAdd = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint8_t u8regsno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint8_t i;&#xA;&#xA;  au8Buffer[ 2 ]       = u8regsno * 2;&#xA;  u8BufferSize         = 3;&#xA;&#xA;  for (i = u8StartAdd; i &amp;lt; u8StartAdd + u8regsno; i++) {&#xA;    au8Buffer[ u8BufferSize ] = highByte(regs[i]);&#xA;    u8BufferSize++;&#xA;    au8Buffer[ u8BufferSize ] = lowByte(regs[i]);&#xA;    u8BufferSize++;&#xA;  }&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC5( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16coil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;&#xA;  // point to the register and its bit&#xA;  u8currentRegister = (uint8_t) (u16coil / 16);&#xA;  u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;  // write to coil&#xA;  bitWrite(&#xA;  regs[ u8currentRegister ],&#xA;  u8currentBit,&#xA;  au8Buffer[ NB_HI ] == 0xff );&#xA;&#xA;&#xA;  // send answer to master&#xA;  u8BufferSize = 6;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC6( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  uint8_t u8add = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16val = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;  regs[ u8add ] = u16val;&#xA;&#xA;  // keep the same header&#xA;  u8BufferSize         = RESPONSE_SIZE;&#xA;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC15( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit, u8frameByte, u8bitsno;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16currentCoil, u16coil;&#xA;  boolean bTemp;&#xA;&#xA;  // get the first and last coil from the message&#xA;  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;&#xA;  // read each coil from the register map and put its value inside the outcoming message&#xA;  u8bitsno = 0;&#xA;  u8frameByte = 7;&#xA;  for (u16currentCoil = 0; u16currentCoil &amp;lt; u16Coilno; u16currentCoil++) {&#xA;&#xA;    u16coil = u16StartCoil + u16currentCoil;&#xA;    u8currentRegister = (uint8_t) (u16coil / 16);&#xA;    u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;    bTemp = bitRead(&#xA;    au8Buffer[ u8frameByte ],&#xA;    u8bitsno );&#xA;&#xA;    bitWrite(&#xA;    regs[ u8currentRegister ],&#xA;    u8currentBit,&#xA;    bTemp );&#xA;&#xA;    u8bitsno ++;&#xA;&#xA;    if (u8bitsno &amp;gt; 7) {&#xA;      u8bitsno = 0;&#xA;      u8frameByte++;&#xA;    }&#xA;  }&#xA;&#xA;  // send outcoming message&#xA;  // it's just a copy of the incomping frame until 6th byte&#xA;  u8BufferSize         = 6;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC16( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code&#xA;  uint8_t u8StartAdd = au8Buffer[ ADD_HI ] &amp;lt;&amp;lt; 8 | au8Buffer[ ADD_LO ];&#xA;  uint8_t u8regsno = au8Buffer[ NB_HI ] &amp;lt;&amp;lt; 8 | au8Buffer[ NB_LO ];&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint8_t i;&#xA;  uint16_t temp;&#xA;&#xA;  // build header&#xA;  au8Buffer[ NB_HI ]   = 0;&#xA;  au8Buffer[ NB_LO ]   = u8regsno;&#xA;  u8BufferSize         = RESPONSE_SIZE;&#xA;&#xA;  // write registers&#xA;  for (i = 0; i &amp;lt; u8regsno; i++) {&#xA;    temp = word(&#xA;    au8Buffer[ (BYTE_CNT + 1) + i * 2 ],&#xA;    au8Buffer[ (BYTE_CNT + 2) + i * 2 ]);&#xA;&#xA;    regs[ u8StartAdd + i ] = temp;&#xA;  }&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="220" LastEditDate="2014-04-04T21:54:21.263" LastActivityDate="2016-04-01T09:06:22.950" Title="Response of Modbus Protocol" Tags="|arduino-uno|programming|modbus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1084" PostTypeId="2" ParentId="1046" CreationDate="2014-04-04T12:53:19.513" Score="1" Body="&lt;p&gt;Chris Stratton's comments helped me find a workaround for my problem. It looks like the version of optiboot I was working with (see &lt;a href=&quot;http://pastebin.com/d8NUirfZ&quot; rel=&quot;nofollow&quot;&gt;source-code here&lt;/a&gt;) doesn't work properly at 57600 BAUD with Arduino Uno without modifications (that I don't know how to make). So I compiled the bootloader with 76800 BAUD, configured the IDE accordingly, and all my boards started to work fine with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is still unclear to me the reason I one can't use 57600 BAUD, but I'm too pragmatic and too little knowledgeable to go after the true answer. So, I'll take Chris' word for it. He said this: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Basically, 57600 does not divide in 16 MHz nicely when the 8x or 16x oversampling of the hardware UART is taken into account. My gut feeling is that different implementation are using different approximations. If they used the same approximation then even if &quot;wrong&quot; things would be basically fine (especially as the hardware design is similar), but if they are are off in opposite directions it could be unreliable. If you post the exact bootloader source you used we can see for sure - some optiboot source I just looked at seems to actually be using a software UART for 57600.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's the end of it for me.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-04-06T01:25:44.340" LastActivityDate="2014-04-06T01:25:44.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1085" PostTypeId="2" ParentId="1062" CreationDate="2014-04-04T16:24:38.833" Score="2" Body="&lt;p&gt;The seconds since (UNIX) epoch relies on a &lt;a href=&quot;https://en.wikipedia.org/wiki/Tz_database&quot; rel=&quot;nofollow&quot;&gt;database&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;New editions of the database and code are published as changes warrant, usually several times per year.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your options can: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reduce the timezone database to the timezone you are actually interested in;&lt;/li&gt;&#xA;&lt;li&gt;Don't forget about daylight savings time for you specific timezone;&lt;/li&gt;&#xA;&lt;li&gt;The leap years are well known too and reasonably easy to program; &lt;/li&gt;&#xA;&lt;li&gt;The leap seconds are decided upon usually only couple months before they are introduced and therefore cannot be accounted for in an algorithm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;So can you convert epoch to a time/date format? Yes. &lt;/li&gt;&#xA;&lt;li&gt;Will it be accurate? It'll drift away over time (months or years)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Advise&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you retrieve epoch from an Internet service, why not use (another?) webserver that has the full timezone database available to convert it to accurate date/time, or 'synchronize' against every once in a while?&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-04-04T16:37:32.610" LastActivityDate="2014-04-04T16:37:32.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1086" PostTypeId="2" ParentId="1072" CreationDate="2014-04-04T19:37:38.583" Score="1" Body="&lt;p&gt;had to simply modify PrintHex in&#xA;Adafruit_NFCShield_I2C.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to accept an additional argument&lt;/p&gt;&#xA;" OwnerUserId="765" LastActivityDate="2014-04-04T19:37:38.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1087" PostTypeId="1" AcceptedAnswerId="1089" CreationDate="2014-04-05T00:04:48.990" Score="9" ViewCount="9894" Body="&lt;p&gt;I am new to Arduino, however I have experience in web development, lately I have been using, meteor js and the mean stack for different projects. However, I am open to trying any language for development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do is build a simple application to control the LED on the Arduino over the web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working with another person, and the Arduino will be behind a firewall so I am not sure how to access it via the internet. I do have access to an Arduino Uun that I can use for testing at home which does have linio connected via bridge, which I don't quite understand what that does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also heard of &lt;a href=&quot;https://www.yaler.net/&quot;&gt;this&lt;/a&gt;, but would like to stay away from third party builds as much as possible if I can do it myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whats the common way to do this with an Arduino behind a firewall? How do I do this with a Arduino Yun? Is it easier with a Yun?&lt;/p&gt;&#xA;" OwnerUserId="938" LastEditorUserId="220" LastEditDate="2014-04-05T00:36:32.660" LastActivityDate="2014-06-04T10:01:37.507" Title="How do I use Arduino and node.js?" Tags="|arduino-yun|web-server|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1088" PostTypeId="2" ParentId="1087" CreationDate="2014-04-05T01:35:48.523" Score="1" Body="&lt;p&gt;first of all you need to have clear what you need to do.&#xA;Arduino UNO is just a microcontroller with a serial (over USB) connection.&#xA;To make your arduino accessible from the internet, it need to be connected with the internet, or to have something that act like a bridge.&#xA;You can use an ethernet shield, a wifi shiled, or a YUN witch is an arduino UNO + a micro linux with has ethernet and wifi (programmable in phyton, or the chip can command the linux sending command to bash shell using the special bridge library)&#xA;You can even connect arduin on the pc by usb and create a bridge program, or, if your firewall/router is a unlocked linux/similar, you can use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many option, and we event startint to decide how o talk with it. As you want to use node.sj, you can use socket or get/post.&#xA;Using socket is faster, lighter, and can create a pull connection, and js wil be a requisite. With get/post you don't even need js, pure html form will do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then, after you decided witch sistem you like (arduino as http server or plain socket) you can open the corresponding port on the firewall/nat. but is just the last part&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-05T01:35:48.523" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1089" PostTypeId="2" ParentId="1087" CreationDate="2014-04-05T10:20:51.800" Score="9" Body="&lt;p&gt;I am working on similar project that uses internet to communicate with external device (mobile). I am reading data from sensors and passing them over the web with web sockets. I am using Arduino Yun for this project and Spacebrew (for web sockets communication). It's very interesting approach but quite a challenge in some cases. You will probably run into asynchronous/synchronous problem, which in my case lead me to running some Python scripts on Yun triggered from Processing code. I am currently running Spacebrew server on my VPN, so I can connect my Yun left at home and use my iphone from everywhere to get the readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also worth mentioning Yun comes with pre-installed Temboo library, which is great starting point for web communication. The configuration is really easy and quick. You will also find official documentation very handy and easy to understand. It's really great starting point for experimenting with web-like applications integrated with Arduino Yun.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Spacebrew&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://docs.spacebrew.cc/&quot; rel=&quot;nofollow&quot;&gt;http://docs.spacebrew.cc/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spacebrew is an open, dynamically re-routable software toolkit for choreographing interactive spaces. Or, in other words, a simple way to connect interactive things to one another. Every element you hook up to the system can subscribe to, and publish data feeds.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://github.com/Spacebrew/pySpacebrew&quot; rel=&quot;nofollow&quot;&gt;http://github.com/Spacebrew/pySpacebrew&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This repo contains the Spacebrew Library for Python along with documentation and example apps.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://github.com/julioterra/yunSpacebrew&quot; rel=&quot;nofollow&quot;&gt;http://github.com/julioterra/yunSpacebrew&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Spacebrew Yun library features two main components - a set of python scripts that run on the linino, and a library that runs on the atmel chip. You find there information how to install both of these components so that you can connect to Spacebrew from an Arduino sketch.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Temboo&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Yun has also build in Temboo library, it's a great way to start experimenting, once you prove the concept you can start narrowing your environment and moving away if you don't want to use 3rd parties software.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.temboo.com/arduino&quot; rel=&quot;nofollow&quot;&gt;http://www.temboo.com/arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Temboo Library makes it easy to connect to over 100 web-based resources and services with Processing. Currently you can find libraries for Android, Arduino, iOS, Java, Node.js, PHP, Processing, Python, REST API, Ruby, Twyla&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Node.js&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can also run node.js on the Yun itself, here's good article and some packages ready to install:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://giorgiocefaro.com/blog/installing-node-js-on-arduino-yun&quot; rel=&quot;nofollow&quot;&gt;http://giorgiocefaro.com/blog/installing-node-js-on-arduino-yun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/giorrrgio/nodejs-linino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/giorrrgio/nodejs-linino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an openwrt package for node. It probably only works on mips (not mipsel, or arm). It runs an outdated v8 as well.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;What is Bridge library for Arduino Yun?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You also asked about Bridge library. As you know Yun has two processors on board, one is running your Processing code, the other one has Linux on it (Linino). Bridge basically simplifies communication between them so they can &quot;talk&quot; to eachother, more information here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/YunBridgeLibrary&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/YunBridgeLibrary&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Taken from arduino.cc documentation:)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Yún has two processors on board. One is an ATmega32U4 like on the Arduino Leonardo. The other is an Atheros 9331, running Linux and the OpenWRT wireless stack, which enables the board to connect to WiFi and Ethernet networks. It is possible to call programs or custom scripts on the Linux system through the Arduino to connect with various internet services.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Bridge library simplifies communication between the ATmega32U4 and the AR9331. It inherits from Stream, and many of the methods should be familiar from Serial and other derivatives of Stream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bridge commands from the 32U4 are interpreted by Python on the AR9331. Its role is to execute programs on the GNU/Linux side when asked by Arduino, provide a shared storage space for sharing data like sensor readings between the Arduino and the Internet, and receiving commands from the Internet and passing them directly to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bridge allows communication in both directions, acting as an interface to the the Linino command line. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Where to start?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I would start with Temboo if I were you, it's a great learning curve and quite simple step to start. You will also learn and understand how the board works and how you can communicate with &quot;external world&quot;. Once you have proof of concept, start experimenting with different libraries and improving the approach. Perhaps you will find Spacebrew more handy later or even discover different solutions.&lt;/p&gt;&#xA;" OwnerUserId="939" LastEditorUserId="939" LastEditDate="2014-06-04T10:01:37.507" LastActivityDate="2014-06-04T10:01:37.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1090" PostTypeId="2" ParentId="14" CreationDate="2014-04-05T10:31:35.223" Score="4" Body="&lt;p&gt;I am using Yun as well for my projects. I don't boot from SD card, but I store a lot of Python code there and it works for me. I've also seen this article that might be interesting for you. I haven't tried to do it on my Yun but I think it should work... This is example how to install node.js on the Yun (SD card), so in theory you could use the same approach for all additional software you want to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://linino.org/doku.php?id=wiki%3anodejs&quot; rel=&quot;nofollow&quot;&gt;http://linino.org/doku.php?id=wiki:nodejs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="939" LastActivityDate="2014-04-05T10:31:35.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1092" PostTypeId="1" AcceptedAnswerId="1093" CreationDate="2014-04-06T00:41:43.590" Score="20" ViewCount="24142" Body="&lt;p&gt;Hi i'm trying to parse JSON resposne from webserver in my arduino in order to turn on and off a LED light. I'm using the wifi client repeating example to make a get request to my server:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/WiFiWebClientRepeating&quot;&gt;http://arduino.cc/en/Tutorial/WiFiWebClientRepeating&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I get printed back from the serial port&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;connecting...&#xA;HTTP/1.1 200 OK&#xA;Date: Sun, 06 Apr 2014 01:14:37 GMT&#xA;Server: Apache&#xA;X-Powered-By: PHP/5.5.10&#xA;Cache-Control: no-cache&#xA;X-Frame-Options: SAMEORIGIN&#xA;Set-Cookie: expires=Sun, 06-Apr-2014 03:14:37 GMT; Max-Age=7200; path=/; httponly&#xA;Connection: close&#xA;Transfer-Encoding: chunked&#xA;Content-Type: application/json&#xA;&#xA;19&#xA;{&quot;lightstatus&quot;:&quot;on&quot;}&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do i parse the JSON portion of this response only so that I can use it to control my LED?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="888" LastEditorUserId="888" LastEditDate="2014-04-06T01:36:10.597" LastActivityDate="2017-07-06T06:01:14.787" Title="Parse JSON with arduino to turn on LED" Tags="|arduino-uno|shields|wifi|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1093" PostTypeId="2" ParentId="1092" CreationDate="2014-04-06T05:12:47.630" Score="11" Body="&lt;p&gt;I'm aware of a few JSON parsing libraries for Arduino.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/interactive-matter/aJson&quot;&gt;aJSON&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/bblanchon/ArduinoJsonParser&quot;&gt;Arduino JSON Parser&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/not404/json-arduino&quot;&gt;JSON Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've never used any of these but I did do some simple JSON parsing in a project I'm working on so I'll show you how I did that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I'm reading serial data using the software serial library. You'll need to change this code to work for you. This will only work on very simple JSON strings. It's &lt;em&gt;very&lt;/em&gt; limited but if that's all you're parsing then it'll work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of JSON response from server:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;id&quot;:&quot;TEST1&quot;,&quot;lat&quot;:&quot;38.56050207&quot;,&quot;lng&quot;:&quot;-121.42158374&quot;,&quot;total&quot;:&quot;3&quot;,&quot;available&quot;:&quot;2&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, only read data between curly braces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String response = &quot;&quot;;&#xA;bool begin = false;&#xA;while (SIM900.available() || !begin) {&#xA;&#xA;    char in = SIM900.read();&#xA;&#xA;    if (in == '{') {&#xA;        begin = true;&#xA;    }&#xA;&#xA;    if (begin) response += (in);&#xA;&#xA;    if (in == '}') {&#xA;        break;&#xA;    }&#xA;&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code reads data one byte at a time and once it gets an open brace, it starts saving it into &lt;code&gt;response&lt;/code&gt;. When it gets a closing brace, it ends it. So here's a clear limitation, you can only have one set of opening/closing braces in your string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I have the string, I use &lt;code&gt;indexOf&lt;/code&gt; and &lt;code&gt;substring&lt;/code&gt; to extract relevant information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;start = response.indexOf(&quot;id\&quot;:\&quot;&quot;) + 5;&#xA;end = start + 5;&#xA;nodeId = response.substring(start, end);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code sets &lt;code&gt;start&lt;/code&gt; to the beginning of &lt;code&gt;id&quot;:&quot;&lt;/code&gt; + 5 characters in the string. It's +5 because that's how long &lt;code&gt;id&quot;:&quot;&lt;/code&gt; is. So &lt;code&gt;start&lt;/code&gt; points to &lt;code&gt;TEST1&lt;/code&gt; in the JSON string. In my system, the ID is always going to be 5 characters long so end is &lt;code&gt;start + 5&lt;/code&gt;. I then use &lt;code&gt;substring&lt;/code&gt; to extract that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, before anyone starts down voting me for this horrible solution: if you know exactly what you're working with, and understand the limitations of this code, then this is not a bad solution. It's a solution that gets the job done.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-04-06T05:12:47.630" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1094" PostTypeId="2" ParentId="1092" CreationDate="2014-04-06T07:56:37.890" Score="7" Body="&lt;p&gt;I have programmed a class that will receive char by char the JSON document. It only will store in memory a few bytes for known JSON structure using a state machine and the results you need. So you can query the class for the results you want and will process the JSON.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its ideal for your purpose. I have used for connecting to a weather service that returns a json:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const char* queries[] = { &quot;list.0.deg&quot;, &quot;list.0.weather.0.main&quot;};&#xA;StreamJsonReader jsonreader(queries, 2); // 2 queries    &#xA;while(char c  =  read()){&#xA;      jsonreader.process_char(c);&#xA;}&#xA;&#xA;cout &amp;lt;&amp;lt; jsonreader.results[0] &amp;lt;&amp;lt; endl;&#xA;cout &amp;lt;&amp;lt; jsonreader.results[1] &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check this blog post I just wrote: &lt;a href=&quot;http://web.biicode.com/blog/big-json-on-arduino&quot;&gt;http://web.biicode.com/blog/big-json-on-arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source code is &lt;a href=&quot;https://www.biicode.com/lasote/blocks/lasote/stream_json_reader/branches/master&quot;&gt;here&lt;/a&gt; in Biicode.&lt;/p&gt;&#xA;" OwnerUserId="655" LastEditorUserId="666" LastEditDate="2014-04-06T21:29:58.723" LastActivityDate="2014-04-06T21:29:58.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1095" PostTypeId="2" ParentId="1092" CreationDate="2014-04-06T12:52:40.383" Score="2" Body="&lt;p&gt;I wrote a parser for the PIC that has very low ram use because it works directly with char pointers and does not build a tree structure. If you ask to get item N of a list, it gives you an actual pointer into the direct JSON file right at the start of item N of the list. Then you can ask what type of object the pointer represents, etc. It's buggy and doesn't support floats and I think has a few other limitations(twas a long time ago) but it's all on github:&lt;a href=&quot;https://github.com/EternityForest/OpenFortune-fortune-like-text-generator&quot; rel=&quot;nofollow&quot;&gt;https://github.com/EternityForest/OpenFortune-fortune-like-text-generator&lt;/a&gt;&#xA;You'll need to look in libfortune which is part of the C version.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-04-06T12:52:40.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1096" PostTypeId="1" CreationDate="2014-04-06T16:50:03.683" Score="11" ViewCount="607" Body="&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://alanbmitchell.wordpress.com/2011/10/09/design-of-the-extended-battery-life-power-controller-for-the-arduino/&quot;&gt;This article&lt;/a&gt;&lt;/b&gt; describes a method to extend the battery life: use a low-power controller to switch on the Arduino only when needed. The author states that this method uses considerably less power than using Arduino's sleep mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;Are there downsides to this approach? Which variant should I build?&lt;/b&gt;(The &lt;a href=&quot;http://alanbmitchell.wordpress.com/2011/11/07/arduino-power-controller-with-texas-instruments%E2%80%99-tps61240/&quot;&gt;TPS61240 variant&lt;/a&gt; seems to use something from Circuits@Home that's not available anymore.) &lt;strong&gt;I'd appreciate schematics or links to detailed instructions.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: I'm building a sensor device that's in an environment with no mains power supply. The sensor should wake up eg. hourly, read eg. a temperature sensor, possibly send an SMS and then go back to sleep.&lt;/p&gt;&#xA;" OwnerUserId="943" LastEditorUserId="943" LastEditDate="2014-04-06T17:21:12.890" LastActivityDate="2014-04-06T18:08:26.387" Title="Extend battery life with a power-controlling microcontroller?" Tags="|battery|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1097" PostTypeId="2" ParentId="1096" CreationDate="2014-04-06T18:08:26.387" Score="4" Body="&lt;p&gt;Switching off power to the board only makes sense if you're using a full Arduino. Once you strip the Arduino down to the bare MCU and decoupling capacitors (or start with a &lt;a href=&quot;https://www.sparkfun.com/products/11117&quot; rel=&quot;nofollow&quot;&gt;basic breakout board&lt;/a&gt; instead), disabling unused peripherals and sleeping the CPU has &lt;a href=&quot;http://www.atmel.com/Images/doc8349.pdf&quot; rel=&quot;nofollow&quot;&gt;much more of an effect&lt;/a&gt; since you no longer need to supply power to an external monitor chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally this may involve creating your own board for the MCU. Fortunately Atmel &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2521-AVR-Hardware-Design-Considerations_Application-Note_AVR042.pdf&quot; rel=&quot;nofollow&quot;&gt;has the basics of that covered&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-06T18:08:26.387" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1099" PostTypeId="2" ParentId="1" CreationDate="2014-04-06T20:13:31.893" Score="4" Body="&lt;p&gt;I built a simple power monitor with my first Arduino. It is powered via USB from a web-server that in turn is powered via a quite substantial battery backup (which  does not have notification abilities).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also connected to a mobile phone charger plugged into a non-UPS power socket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if the power dies the Arduino sends a message to a little program running on the server. The server program in turn sends me an email notification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was installed in late September 2013, on the 23rd March 2014 - I got my first email!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have not seen a problem (it does not use millis() ) but it does sample the power every 5 seconds.&lt;/p&gt;&#xA;" OwnerUserId="949" LastActivityDate="2014-04-06T20:13:31.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1100" PostTypeId="2" ParentId="810" CreationDate="2014-04-07T00:40:00.430" Score="0" Body="&lt;p&gt;When your time has more worth more than the gains to be had, stop optimizing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you writing for someone for pay? Then this should be their call. But in this case, readability and clarity of your code is paramount; someday, someone else will have to modify your code in your absence. If you deliver working, high performance code that someone else can't read and get a handle on, you will not have fulfilled your obligation (unless this was specifically agreed to).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-04-07T00:40:00.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1101" PostTypeId="1" CreationDate="2014-04-07T00:43:55.483" Score="1" ViewCount="108" Body="&lt;p&gt;How would I measure resistance over a certain length? In this case the resistance is variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have in my head is that you would output a certain amount of current from one pin, and measure how much comes back from the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this would work, or how to implement it in code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,21614.0.html&quot; rel=&quot;nofollow&quot;&gt;this forum post&lt;/a&gt;, but it's not making much sense to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I measure resistance?&lt;/p&gt;&#xA;" OwnerUserId="346" LastEditorUserId="11" LastEditDate="2014-04-07T00:53:08.673" LastActivityDate="2014-04-07T13:14:14.377" Title="Measuring resistance conceptually and in code?" Tags="|current|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1102" PostTypeId="5" CreationDate="2014-04-07T00:45:52.293" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-04-07T00:45:52.293" LastActivityDate="2014-04-07T00:45:52.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1103" PostTypeId="4" CreationDate="2014-04-07T00:45:52.293" Score="0" Body="An Arduino board based on the ATmega32u4 chip with built in USB HID functionality" OwnerUserId="346" LastEditorUserId="346" LastEditDate="2014-04-07T00:47:25.343" LastActivityDate="2014-04-07T00:47:25.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1104" PostTypeId="1" AcceptedAnswerId="1107" CreationDate="2014-04-07T01:57:08.037" Score="4" ViewCount="4626" Body="&lt;p&gt;My high school is entering an ROV competition and for next year's competition we want to try and set it up so that we can control it using a PS4 controller. I have done research and found &lt;a href=&quot;http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; shield for Arduino and &lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; library that allows you to connect it to an Arduino. I plan to then connect the Arduino to a computer via USB and then send each button press to a Processing program via serial. Would it then be possible to send this from Processing to another Arduino out of the laptop? I'm just wondering how feasible this project is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We initially had just a single Arduino at the top with the Ethernet shield and took inputs from standard joystick potentiometers. We want to add in using the PS4 controller this year for easier control. We found the USB Host Shield that gives us that capability, but uses the same pins as the Ethernet shield. So we added another Arduino, connecting the laptop as the bridge also allows to have a GUI. The Ethernet is wired, by the way. We need the laptop, it's not just for a bridge.&lt;/p&gt;&#xA;" OwnerUserId="952" LastEditorUserId="220" LastEditDate="2014-04-09T22:13:16.847" LastActivityDate="2014-04-09T22:33:36.070" Title="How do I connect a PS4 controller connected to an Arduino that's connected to a laptop to another Arduino?" Tags="|library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1105" PostTypeId="1" AcceptedAnswerId="1106" CreationDate="2014-04-07T06:11:31.823" Score="4" ViewCount="3764" Body="&lt;p&gt;I have a LED attached to my Arduino wifi shield that I want to control from my PHP web server.  In terms of communication, should I &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make my Arduino a web server and then communicate with PHP web server via HTTP&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make my Arduino a web client and receive commands from my PHP web service.  I would parse the JSON response&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also my other question is should I communicate with JSON between my PHP web server or is there a better way to send commands to my LED light? &lt;/p&gt;&#xA;" OwnerUserId="888" LastEditorUserId="6936" LastEditDate="2015-07-30T18:44:21.867" LastActivityDate="2015-07-30T18:44:21.867" Title="Controlling LED from web server" Tags="|arduino-uno|shields|wifi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1106" PostTypeId="2" ParentId="1105" CreationDate="2014-04-07T06:20:02.043" Score="4" Body="&lt;p&gt;There's no need for either PHP or JSON. Simply detect when one of two URLs (say, &lt;code&gt;/led/on&lt;/code&gt; and &lt;code&gt;/led/off&lt;/code&gt;) has been accessed on the Arduino's web server, change the LED state, and return a &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success&quot; rel=&quot;nofollow&quot;&gt;204 response&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-07T06:20:02.043" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1107" PostTypeId="2" ParentId="1104" CreationDate="2014-04-07T13:08:56.583" Score="2" Body="&lt;p&gt;this is possible, but the processig bridge can add a lot of delay if not correctly handled, also wifi has a low range, almost 100m by default hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;zigbee module has better range (xbee pro are up to 1km) and are microcontroller friendly, you use the as you are using a serial, they will hide their complexity once you set them up, and this can be done by PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That mens less code, that mena less error and more ram/flash/cpu so you can do a smarter robot :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;zigbee use the serial protocol to communicate, exactly as you do with the pc. Also arduino can use, with the library SoftSerial, any pin as Serial. So you can keep the HardwareSerial to communicate with pc, and any 2 free pin to communicate with the xbee. So you can use the arduino stand alone, only with the controller, and when needed connect the pc. Then arduino can act as a bridge between xbee and pc, so pc can excange data with the rover. But even without pc your project will be fun.&#xA;The same apply for bluetoot or 400/800mhz rxtx module, but not for wifi shield&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="643" LastEditDate="2014-04-09T22:33:36.070" LastActivityDate="2014-04-09T22:33:36.070" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1108" PostTypeId="2" ParentId="1101" CreationDate="2014-04-07T13:14:14.377" Score="3" Body="&lt;p&gt;you cant control current output to a pin BUT you know a pin output 5V (if using a 5V a arduino, 3.3v in other case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then what you need is a know resistence resitor, so you can set up a &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;voltage divider&lt;/a&gt; and then read the resulting voltage with an analogRead. That give you a 10bit precision value that you can easily translate to a voltage, and then use the formula on the linked page to find R1 or R2 (depends on how you wired up your know resistor)&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-07T13:14:14.377" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1109" PostTypeId="2" ParentId="1007" CreationDate="2014-04-07T15:51:16.317" Score="5" Body="&lt;p&gt;As I didn't get any answer, and further search for an existing solution failed, I decided to roll my own. The class header is very straightforward, I decided to go for single inheritance and composition of Adafruit_CC3000_Client:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CC3000Client: public WiFiClient {&#xA;public:&#xA;    CC3000Client(Adafruit_CC3000&amp;amp; cc, Stream&amp;amp; stream=Serial);&#xA;    virtual ~CC3000Client();&#xA;&#xA;    virtual int connect(IPAddress ip, uint16_t port);&#xA;    virtual int connect(const char *host, uint16_t port);&#xA;    virtual uint8_t connected();&#xA;    virtual int available();&#xA;    virtual void stop();&#xA;    virtual void flush();&#xA;    virtual int peek();&#xA;    virtual int read();&#xA;    virtual size_t write(uint8_t v);&#xA;    virtual size_t write(const uint8_t *buf, size_t size);&#xA;    virtual int read(uint8_t *buf, size_t size);&#xA;    virtual operator bool();&#xA;&#xA;private:&#xA;    Adafruit_CC3000&amp;amp; cc3000;&#xA;    Adafruit_CC3000_Client client;&#xA;    bool peeked;&#xA;    int peeked_byte;&#xA;    Stream&amp;amp; stream;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The implementation is a bit tricky (or I didn't manage to find a better way), as the Adafruit client does not have peek() functionality, so this wrapper class have to implement it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CC3000Client::CC3000Client(Adafruit_CC3000&amp;amp; cc, Stream&amp;amp; stre) :&#xA;        cc3000(cc), peeked(false), stream(stre), peeked_byte(0) {&#xA;}&#xA;CC3000Client::~CC3000Client() {&#xA;}&#xA;&#xA;int CC3000Client::connect(IPAddress ip, uint16_t port) {&#xA;    client = cc3000.connectTCP((uint32_t) ip, port);&#xA;    peeked = false;&#xA;    if (client.connected())&#xA;        return 1;&#xA;    return 0;&#xA;}&#xA;int CC3000Client::connect(const char *host, uint16_t port) {&#xA;    uint32_t ip = 0;&#xA;    if (!cc3000.getHostByName((char*) host, &amp;amp;ip)) {&#xA;        stream.println(F(&quot;Couldn't resolve!&quot;));&#xA;        return 0;&#xA;    }&#xA;    client = cc3000.connectTCP(ip, port);&#xA;    peeked = false;&#xA;    if (client.connected()) {&#xA;        return 1;&#xA;    }&#xA;    return 0;&#xA;}&#xA;uint8_t CC3000Client::connected() {&#xA;    return (uint8_t) client.connected();&#xA;}&#xA;int CC3000Client::available() {&#xA;    if(peeked)&#xA;        return 1;&#xA;    return (int) client.available();&#xA;}&#xA;void CC3000Client::stop() {&#xA;    peeked = false;&#xA;    flush();&#xA;    while (client.connected()){&#xA;        client.close();&#xA;        delay(10);&#xA;    }&#xA;}&#xA;void CC3000Client::flush() {&#xA;    peeked = false;&#xA;    while (connected() &amp;amp;&amp;amp; available())&#xA;        read();&#xA;}&#xA;int CC3000Client::peek() {&#xA;    if (!peeked) {&#xA;        if (available()) {&#xA;            peeked_byte = read();&#xA;            peeked = true;&#xA;        } else&#xA;            return -1;&#xA;    }&#xA;    return peeked_byte;&#xA;&#xA;}&#xA;int CC3000Client::read() {&#xA;    if (peeked) {&#xA;        peeked = false;&#xA;        return peeked_byte;&#xA;    }&#xA;    return (int) client.read();&#xA;}&#xA;size_t CC3000Client::write(uint8_t v) {&#xA;    return (size_t) client.write(v);&#xA;}&#xA;size_t CC3000Client::write(const uint8_t *buf, size_t size) {&#xA;    return client.write(buf, size);&#xA;}&#xA;int CC3000Client::read(uint8_t *buf, size_t size) {&#xA;    if(peeked){&#xA;        buf[0]=peeked_byte;&#xA;        peeked=false;&#xA;        return client.read(buf+1, size-1);&#xA;    }&#xA;    return client.read(buf, size);&#xA;}&#xA;CC3000Client::operator bool() {&#xA;    stream.println(&quot;Error, bool() not implemented&quot;);&#xA;    return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both files are available &lt;a href=&quot;https://www.biicode.com/diego/blocks/diego/ardunet/branches/master&quot;&gt;here&lt;/a&gt;, if you are using &lt;a href=&quot;http://www.biicode.com&quot;&gt;biicode&lt;/a&gt; all you have to do in your code is to put an include like the following and run &quot;bii find&quot;, that will also retrieve and install the cc3000 library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;diego/ardunet/cc3000client.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used and tested it with a simple http_get call (also &lt;a href=&quot;https://www.biicode.com/diego/blocks/diego/ardunet/branches/master&quot;&gt;here&lt;/a&gt;) and with the &lt;a href=&quot;http://www.temboo.com&quot;&gt;temboo&lt;/a&gt; service, and it has worked OK for sending emails from a Gmail account from an Arduino Mega2560 connected to the CC3000. This temboo service uses via the SDK Client interface most methods of this wrapper, but the bool() operator and the CC3000Client::write(const uint8_t *buf, size_t size) method. &lt;/p&gt;&#xA;" OwnerUserId="666" LastActivityDate="2014-04-07T15:51:16.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1110" PostTypeId="1" CreationDate="2014-04-03T13:31:46.257" Score="2" ViewCount="18" Body="&lt;p&gt;Working on a arduino code, but its C code. Having the problem that I want a variable with int to increase in a loop to run with the url:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;student.cs.hioa.no/~s180343/updatedb.php?verdi=%d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The updatedb.php files takes the parameter and saves it to the database.    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Process.h&amp;gt;&#xA;char buffer[50];&#xA;int val=1200;&#xA;&#xA;&#xA;void setup() {&#xA;  // Initialize Bridge&#xA;  Bridge.begin();&#xA;&#xA;  // Initialize Serial&#xA;  Serial.begin(9600);&#xA;&#xA;  // Wait until a Serial Monitor is connected.&#xA;  while (!Serial);&#xA;&#xA;  // run various example processes&#xA;  //runCurl(val);&#xA;  //runCpuInfo();&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Starting&quot;);&#xA;  sprintf (buffer, &quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=%d&quot;, val);  &#xA;   val++;&#xA;   Serial.println(buffer);&#xA;   runCurl();&#xA;   delay(5000);&#xA;  // Do nothing here.&#xA;}&#xA;&#xA;void runCurl() {&#xA;&#xA;  // curl is command line program for transferring data using different internet protocols&#xA;  Process p;        // Create a process and call it &quot;p&quot;&#xA;  p.begin(&quot;curl&quot;);  // Process that launch the &quot;curl&quot; command&#xA;  p.addParameter(buffer); // Add the URL parameter to &quot;curl&quot;&#xA;&#xA;  p.run();      // Run the process and wait for its termination&#xA;&#xA;  // A process output can be read with the stream methods&#xA;  while (p.available()&amp;gt;0) {&#xA;    char c = p.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  // Ensure the last bit of data is sent.&#xA;  Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="884" OwnerDisplayName="user3270211" LastActivityDate="2014-04-07T16:14:12.547" Title="Sending variable in url" Tags="|c|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2014-04-07T16:16:53.293" ContentLicense="CC BY-SA 3.0" />
  <row Id="1111" PostTypeId="2" ParentId="1073" CreationDate="2014-04-06T10:09:39.557" Score="0" Body="&lt;p&gt;first of all, you declare your &lt;code&gt;buffer&lt;/code&gt; as a string of 50 characters, but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;student.cs.hioa.no/~s180343/updatedb.php?verdi=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is already 48, and you start your value at 1200 and increments over that, so basically&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf (buffer, &quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=%d&quot;, val)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will create a buffer of 53 characters (52 characters + &lt;code&gt;\0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, it's always a better idea to give the &lt;em&gt;full&lt;/em&gt; URL to a program such as curl, as it might work but may give unexpected results as well if you do not provide the protocol… &lt;code&gt;curl&lt;/code&gt; could legally assume you want &lt;code&gt;ftp&lt;/code&gt; or &lt;code&gt;gopher&lt;/code&gt; to access that address! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://student.cs.hioa.no/~s180343/updatedb.php?verdi=%d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Third, here's how you setup and use your &lt;code&gt;val&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val=1200;&#xA;sprintf (…, &quot;…&quot;, val);  &#xA;val++;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so once you've reached &lt;code&gt;32767&lt;/code&gt; your int is overflowing, getting back to &lt;code&gt;-32,768&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and by the way, it is good practice on a Q&amp;amp;A site such as Stack Overflow to actually &lt;em&gt;ask&lt;/em&gt; a question and say what your problem is. All my hints here are insights based on reading your flawed code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" OwnerDisplayName="zmo" LastActivityDate="2014-04-06T10:09:39.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1112" PostTypeId="1" CreationDate="2014-04-03T13:46:16.157" Score="0" ViewCount="114" Body="&lt;p&gt;Working on a arduino script where I am right now entering manually the value with the URL, but wondering how to do it with a int in a loop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the url and how it works now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;student.cs.hioa.no/~s180343/updatedb.php?verdi=25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Process.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  // Initialize Bridge&#xA;  Bridge.begin();&#xA;&#xA;  // Initialize Serial&#xA;  Serial.begin(9600);&#xA;&#xA;  // Wait until a Serial Monitor is connected.&#xA;  while (!Serial);&#xA;  Serial.println(&quot;Ready&quot;);&#xA;&#xA;  // run various example processes&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;   runCurl();&#xA;   delay(10000);&#xA;}&#xA;&#xA;void runCurl() {&#xA;  // Launch &quot;curl&quot; command and get Arduino ascii art logo from the network&#xA;  // curl is command line program for transferring data using different internet protocols&#xA;  Process p;        // Create a process and call it &quot;p&quot;&#xA;  p.begin(&quot;curl&quot;);  // Process that launch the &quot;curl&quot; command&#xA;  p.addParameter(&quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=25&quot;); // Add the URL parameter to &quot;curl&quot;&#xA;  p.run();      // Run the process and wait for its termination&#xA;&#xA;  // A process output can be read with the stream methods&#xA;  while (p.available()&amp;gt;0) {&#xA;    char c = p.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  // Ensure the last bit of data is sent.&#xA;  Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3185936" LastActivityDate="2014-04-07T16:14:22.260" Title="Passing variable in url" Tags="|c++|variables|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2014-04-07T16:18:41.260" ContentLicense="CC BY-SA 3.0" />
  <row Id="1113" PostTypeId="2" ParentId="1073" CreationDate="2014-04-06T13:48:29.593" Score="0" Body="&lt;p&gt;Alright. I'm assuming you mean that you need the last part of the url varied from, say 1 to 100. Like Java, Processing, and, by extension, Arduino, allow you to add an integer to a String to get a String. I haven't tested this out, but it should work:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Process.h&amp;gt;&#xA;#define MIN 0&#xA;#define MAX 100&#xA;&#xA;int i;&#xA;&#xA;void setup() {&#xA;  i = MIN;&#xA;&#xA;  // Initialize Bridge&#xA;  Bridge.begin();&#xA;&#xA;  // Initialize Serial&#xA;  Serial.begin(9600);&#xA;&#xA;  // Wait until a Serial Monitor is connected.&#xA;  while (!Serial);&#xA;  Serial.println(&quot;Ready&quot;);&#xA;&#xA;  // run various example processes&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;   if (i&amp;lt;=MAX) {&#xA;     runCurl();  &#xA;     i = i+1; &#xA;   }&#xA;   delay(10000);&#xA;}&#xA;&#xA;void runCurl() {&#xA;  // Launch &quot;curl&quot; command and get Arduino ascii art logo from the network&#xA;  // curl is command line program for transferring data using different internet protocols&#xA;  Process p;        // Create a process and call it &quot;p&quot;&#xA;  p.begin(&quot;curl&quot;);  // Process that launch the &quot;curl&quot; command&#xA;  String myUrl = &quot;student.cs.hioa.no/~s180343/updatedb.php?verdi=&quot;;&#xA;  p.addParameter(myUrl+i); // Add the URL parameter to &quot;curl&quot;&#xA;  p.run();      // Run the process and wait for its termination&#xA;&#xA;  // A process output can be read with the stream methods&#xA;  while (p.available()&amp;gt;0) {&#xA;    char c = p.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  // Ensure the last bit of data is sent.&#xA;  Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="aspiring_sarge" LastActivityDate="2014-04-06T13:48:29.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1114" PostTypeId="1" CreationDate="2014-04-06T18:30:18.623" Score="4" ViewCount="21636" Body="&lt;p&gt;I want to make my Arduino connect via WiFi and then send an email. The idea is very simple, but the problem is that I've never worked with those protocols and other things before. I just wanted something that's already premade, so I would just change the information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a library or a function that sends the email?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could help me to understand, so I can make it myself, that would be the best.&lt;/p&gt;&#xA;" OwnerUserId="980" OwnerDisplayName="user3504192" LastEditorUserId="37" LastEditDate="2014-04-11T15:23:18.357" LastActivityDate="2020-12-11T04:09:19.693" Title="How to send an email with Arduino and a WiFi shield?" Tags="|wifi|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1115" PostTypeId="1" CreationDate="2014-04-05T22:03:34.517" Score="11" ViewCount="718" Body="&lt;p&gt;I am starting a personal project of home automation and I have a raspberry pi and an arduino Uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want communicate raspberry pi and my arduino where my raspberry should be able to write and read signals to and from arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The distance between them I think its going to be something around 10 to 15 meters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need for it? what kind of wires or other components I'll need to achieve my goal? I repeat: I do not want to communicate raspberry pi and arduino wirelessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="963" OwnerDisplayName="thiagoh" LastEditorUserId="220" LastEditDate="2014-04-12T13:12:40.673" LastActivityDate="2014-04-12T13:12:40.673" Title="How can I communicate Raspberry Pi and Arduino (in both ways) using a 10-15m distance wires?" Tags="|serial|uart|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1116" PostTypeId="2" ParentId="1115" CreationDate="2014-04-06T11:20:16.370" Score="9" Body="&lt;p&gt;for length such as this, you should be using protocols that are designed for length, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UART,&lt;/li&gt;&#xA;&lt;li&gt;CAN,&lt;/li&gt;&#xA;&lt;li&gt;Ethernet&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;for UART, you can't of course use a direct connection between the two boards, you need to upgrade the connection and wiring to either rs232 or rs485, using a driver between the arduino pins and the cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though, the simplest solution would be to plug the Arduino on the Raspberry Pi using a lengthy USB cable (or more likely 3 five meters cable), which should work fine as long as you only do serial communication. The USB 2.0 limitation of 5 meters are for &quot;hi-speed&quot; connections, which is not our concern for simple serial data communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" OwnerDisplayName="zmo" LastActivityDate="2014-04-06T11:20:16.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1117" PostTypeId="2" ParentId="1114" CreationDate="2014-04-07T22:44:50.037" Score="5" Body="&lt;p&gt;What you're looking for is a &lt;strong&gt;SMTP (Simple Mail Transport Protocol) library&lt;/strong&gt;. A Google search finds 2 for the Arduino:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/gregington/SMTPClient&quot; rel=&quot;noreferrer&quot;&gt;SMTPClient&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This seems to be a minimal-capability SMTP-only library that piggybacks on top of a connection library.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/bibi21000/arduino-fullip&quot; rel=&quot;noreferrer&quot;&gt;FullIP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This seems to be a full IP package for the Arduino that works with select network devices which includes SMTP capability.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-04-07T22:44:50.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1118" PostTypeId="1" AcceptedAnswerId="1120" CreationDate="2014-04-07T23:11:25.913" Score="3" ViewCount="281" Body="&lt;p&gt;I am trying to connect a MPL3115A2 Altitude/Pressure/Temp Sensor Breakout which I bought from Hobbytronics to my Arduino Mega. What I had in mind was (Breakout -&gt; Arduino):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;3.3V -&amp;gt; 3.3 V&lt;/code&gt;&#xA;&lt;code&gt;GND -&amp;gt; GND&lt;/code&gt;&#xA;&lt;code&gt;SDA -&amp;gt; A4&lt;/code&gt;&#xA;&lt;code&gt;SCL -&amp;gt; A5&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The information which I've found so far is very conflicting and I'm not sure whether or not I should be using pull-up or in-line resistors, and if so, what value? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code which the product page links to also differs, with one stating that the Wire library is unsafe to use with a 3.3V rated sensor due to the internal pull-ups, but the other code uses the Wire library? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone could advise me on how best to use this sensor without frying it, it would be much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.hobbytronics.co.uk/mpl3115a2-pressure-temp-sensor&quot; rel=&quot;nofollow&quot;&gt;Product information&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sparkfun/MPL3115A2_Breakout/tree/master/firmware&quot; rel=&quot;nofollow&quot;&gt;Code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="755" LastEditorUserId="368" LastEditDate="2014-04-07T23:14:40.257" LastActivityDate="2014-04-07T23:48:49.630" Title="Can anyone explain how to use MPL sensor with Arduino MEGA?" Tags="|sensors|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1120" PostTypeId="2" ParentId="1118" CreationDate="2014-04-07T23:48:49.630" Score="3" Body="&lt;p&gt;Since the device is 3.3V and the Arduino is 5V, you &lt;em&gt;will&lt;/em&gt; need a I&lt;sup&gt;2&lt;/sup&gt;C level converter such as the &lt;a href=&quot;http://www.ti.com/product/tca9517&quot; rel=&quot;nofollow&quot;&gt;TCA9517&lt;/a&gt;. Simply supply the Mega side with 5V and the device side with 3.3V and attach 4.7kohm pull-ups to 5V on the Mega side, and it will convert both SDA and SCL for you. You won't need pull-ups on the device side since it includes pull-ups on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For I1 and I2 (push-pull outputs) you can use either normal level converters or you can use a &lt;a href=&quot;http://www.ti.com/product/sn74lvc2g07&quot; rel=&quot;nofollow&quot;&gt;SN74LVC2G07&lt;/a&gt; along with the pull-ups found on the Mega inputs.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-07T23:48:49.630" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1121" PostTypeId="2" ParentId="1104" CreationDate="2014-04-08T01:06:07.723" Score="1" Body="&lt;p&gt;&lt;strong&gt;This project is very simple.&lt;/strong&gt; As I understand it, this is your setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+–––––––––––––––––––––––––––––––––––––––––+             &#xA;|                                         |             &#xA;|  Arduino 1-––––––––––-PS4 Controller    |             &#xA;|  |                 (W. Shield attached) |             &#xA;|  |USB                                   |             &#xA;|  |                                      |             &#xA;|  Computer                               |             &#xA;|  |                                      |             &#xA;|  |[Wireless]                            |             &#xA;|  |                                      |             &#xA;|  Arduino 2                              |             &#xA;|                                         |             &#xA;+–––––––––––––––––––––––––––––––––––––––––+             &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://asciiflow.com&quot; rel=&quot;nofollow&quot;&gt;Made with ASCIIFlow&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a very small range (I'd say 10-20 feet max), I recommend using Bluetooth. The &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0093XAV4U&quot; rel=&quot;nofollow&quot;&gt;HC 06 Bluetooth module looks like a good choice&lt;/a&gt;. There's also a less powerful HC05 if I remember correctly. I had one once but accidentally destroyed it before I could connect with a bad soldering job :). The one linked on Amazon luckily comes with a &quot;backplane&quot; already soldered so you just need to attach 5V, GND, and the TX/RX pins to the Arduino, accordingly. Then, you can select the BT module (wherever it appears on your OS; search online for this) and then you can connect to it and add the password 1234. After that, it should function like a normal COM port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would connect this to the HC06 to Arduino 2, and wirelessly the HC06 to the computer. The computer would then be connected to Arduino 1, who would receive the PS4 signals, with the shield. You would use Processing to receive the PS4 signals and to send data to the second Arduino board. I'm not an expert on Processing, but I found &lt;a href=&quot;https://www.processing.org/reference/libraries/serial/Serial.html&quot; rel=&quot;nofollow&quot;&gt;this serial library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;strong&gt;&lt;em&gt;do not&lt;/em&gt;&lt;/strong&gt; recommend using Xbee because one Arduino needs to talk to the computer and the other at the same time. That's not practical with the way it's set up on most boards. The OP would need another UART connection, even so the Xbee and the USB to UART chip use the same pins on all standard boards. &lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-04-08T01:06:07.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1122" PostTypeId="2" ParentId="1105" CreationDate="2014-04-08T11:14:13.833" Score="4" Body="&lt;p&gt;The REST protocol is ideal for this and there's a nice Sketch already written, called RESTduino on Github:&#xA;&lt;a href=&quot;https://github.com/jjg/RESTduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jjg/RESTduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically (and loosely) REST treats a URL as a command.  Quoting from the RESTduino doc's:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;To turn on the LED attached to pin #9 (currently case sensitive!):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://192.168.1.177/9/HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will set the pin to the HIGH state and the LED should light. Next try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; http://192.168.1.177/100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will use PWM to illuminate the LED at around 50% brightness (valid PWM values are 0-255).&quot;&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-04-08T11:14:13.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1123" PostTypeId="2" ParentId="874" CreationDate="2014-04-08T22:34:59.453" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I tried same setup with arduino uno and the problem is gone. It also works on micro as long as gnd and 5v pin is connected to uno. Uno measured voltage is 4.88V and micro 4.60V could a voltage difference this small cause this? What else could this be?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Reinstatement of incorrect edits by Annonomus Person&#xA;(AP: Please do not edit answers in such a way that you entirely change their meaning. In the current discussion &quot;the board&quot; is meaningless. We are trying to distinguish between symptoms seen in two different 'boards', an Arduino Uno, and an Arduino Micro.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks to me like the problem is with the Arduino Micro's 5V supply then. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are powering the Micro from an external supply (not USB), then 4.6V on the Micro's &quot;5V&quot; output would indicate that the 5V regulator is not operating within its expected range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;are&lt;/em&gt; powering from USB, then the regulator is not in play. The 4.6V would indicate a problem with the USB's 5V supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likely possibilities:, either the upstream supply is inadequate, or the micros and whatever is attached to it is drawing too much current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that the transducer output is fluctuating in a way that's too rapid to be seen by your meter, but which is sampled by the Arduino Micro, giving your varying result numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either the &quot;4.6V&quot; is inadequate to run the transducer, causing erratic transducer output, or the 4.6V itself is fluctuating, with similar results at the trans output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you might also check the ground between micro and transducer -- are you sure that's wired correctly?&lt;/p&gt;&#xA;" OwnerUserId="973" LastEditorUserId="973" LastEditDate="2014-04-09T01:16:33.127" LastActivityDate="2014-04-09T01:16:33.127" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1124" PostTypeId="1" CreationDate="2014-04-09T00:19:33.763" Score="5" ViewCount="5516" Body="&lt;p&gt;My project is to control car windows using voice recognition. I have successfully controlled some LEDs using the EasyVR Arduino shield using and Arduino MEGA. Now I want to take control of the windows using the CAN-BUS arduino shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the car that I own doesn't have an OBD-II connector, I am using two Arduinos with two CAN-BUS Arduino shields making one a sender and the other a receiver. How can I program the CAN-BUS Arduino shield to make a simulation of the car's windows?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CAN-BUS shield that I am using: &lt;a href=&quot;https://www.sparkfun.com/products/10039&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10039&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Mega: &lt;a href=&quot;https://www.sparkfun.com/products/11061&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11061&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="977" LastEditorUserId="3514" LastEditDate="2015-07-25T16:51:36.727" LastActivityDate="2015-07-25T16:51:36.727" Title="How to program a CAN-BUS Arduino shield to control car windows?" Tags="|programming|arduino-mega|can-bus|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1125" PostTypeId="2" ParentId="1114" CreationDate="2014-04-09T00:24:57.757" Score="3" Body="&lt;p&gt;You actually present 2 issues here, which can be handled separately:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You are concerned about having a WiFi, not an Ethernet shield. This doesnt affect at all for sending emails or any other network stuff. When you have internet connection, it is almost transparent from the programming side. So I recommend first to try your wifi shield connection and configuration as a separate problem, with a more simple task, as a simple HTTP_GET to a known web page. A function like this might help, assuming that you have an instance of WiFiClient (which is a Client), that has been connected (with connect) to the URL and port 80:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void http_get(Client&amp;amp; www, char website[], char webpage[], int timeout, Stream&amp;amp; stream) {&#xA;    if (www.connected()) {&#xA;        int n = www.print(&quot;GET &quot;);&#xA;        www.print(webpage);&#xA;        www.print(&quot; HTTP/1.1\r\n&quot;);&#xA;        www.print(&quot;Host: &quot;);&#xA;        www.print(website);&#xA;        www.print(&quot;\r\n&quot;);&#xA;        www.print(&quot;\r\n&quot;);&#xA;    } else {&#xA;        stream.println(F(&quot;Connection failed get&quot;));&#xA;        return;&#xA;    }&#xA;&#xA;    /* Read data until either the connection is closed, or the idle timeout is reached. */&#xA;    unsigned long lastRead = millis();&#xA;    while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; timeout)) {&#xA;        while (www.available()) {&#xA;            char c = www.read();&#xA;            stream.print(c);&#xA;            lastRead = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second problem is that you want to send an email. One you have a connection, it doesnt matter if it is wifi or wired. The above recommended libraries (SMTPClient, FullIP) will directly connect to your provider (e.g. gmail) and will request your gmail password, something that is not secure over non secure connections (and those libraries do not seem to provide secure layer), so personally I am not comfortable with that option. I have been using the &lt;a href=&quot;http://www.temboo.com&quot; rel=&quot;nofollow&quot;&gt;temboo&lt;/a&gt; service, that allows to send emails, and I have found it to be quite convenient and simple. Furthermore, they also have many other services. The service stores your gmail or whatever provider credentials, and you access the service via a Secret Key and App Password they provide. While this keys might not be fully secure to be sent via non secure layers, at least it only compromises your app in the cloud application, which you might simply manage, and not your full email account. (Disclaimer: I have no relation with temboo, and there might be other similar services for this task, e.g. &lt;a href=&quot;https://www.carriots.com/documentation/arduino&quot; rel=&quot;nofollow&quot;&gt;Carriots&lt;/a&gt;, I simply say that I have used them with success for this task and feel it is relatively simple). Your code using temboo, could be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TembooChoreo choreo(client); // your WiFiClient object&#xA;&#xA;// Set Temboo account credentials&#xA;choreo.setAccountName(temboo_account);&#xA;choreo.setAppKeyName(temboo_app);&#xA;choreo.setAppKey(temboo_app_key);&#xA;&#xA;// credential is the name of your gmail profile in temboo&#xA;choreo.setCredential(credential);&#xA;choreo.addInput(&quot;MessageBody&quot;, body);&#xA;choreo.addInput(&quot;Subject&quot;, subject);&#xA;choreo.addInput(&quot;ToAddress&quot;, address);&#xA;&#xA;//Identify the Choreo to run&#xA;choreo.setChoreo(&quot;/Library/Google/Gmail/SendEmail&quot;);&#xA;&#xA;choreo.run();&#xA;choreo.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="666" LastActivityDate="2014-04-09T00:24:57.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1126" PostTypeId="1" CreationDate="2014-04-09T00:44:17.830" Score="2" ViewCount="856" Body="&lt;p&gt;I am trying to create a wireless remote control to control a servo motor via Bluetooth. What all do I need to establish this? I did some research and found the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tiny-circuits.com/products/tinyduino/&quot; rel=&quot;nofollow&quot;&gt;Tinyduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tiny-circuits.com/shop/tinyshield-bluetooth-le/&quot; rel=&quot;nofollow&quot;&gt;Bluetooth low energy shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would these be enough (in addition to the servo motor) to establish my needs? Any advice on how I would go about coding this? I can research on the specifics but hints on functions to use would be greatly appreciated. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to be able to control the system wirelessly (may it be Bluetooth or whatever) through a remote control. This remote control could be a push button system or an app on the phone. I do not have this designed yet. I do not know how to make iPhone apps so the best solution for me would be a simple push button on/off switch that can wirelessly tell the servo motor to either turn 90º clockwise or counterclockwise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RFDuino suggestion is very helpful, thank you for that. Can anyone recommend a push-button switch (small) that can wirelessly transmit the signal to the servo motor on the device? I hope this clears things up. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="979" LastEditorUserId="11" LastEditDate="2014-04-16T16:43:59.433" LastActivityDate="2014-04-16T16:43:59.640" Title="Creating a wireless remote" Tags="|bluetooth|remote-control|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1127" PostTypeId="2" ParentId="598" CreationDate="2014-04-09T03:22:53.033" Score="3" Body="&lt;p&gt;Adding some references to already-written libraries and examples, to enable comparison between different approaches, and experiences with speed versus susceptibility to missing steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading rotary encoders:&#xA;&lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/RotaryEncoders&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quadrature Encoder too Fast for Arduino (with Solution): &lt;a href=&quot;http://www.hessmer.org/blog/2011/01/30/quadrature-encoder-too-fast-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.hessmer.org/blog/2011/01/30/quadrature-encoder-too-fast-for-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Teensy Encoder library: &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_Encoder.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_libs_Encoder.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading rotary encoder on Arduino:&#xA;&lt;a href=&quot;http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-04-09T03:22:53.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1128" PostTypeId="1" AcceptedAnswerId="1129" CreationDate="2014-04-09T03:31:11.847" Score="2" ViewCount="680" Body="&lt;p&gt;Is there any good way to calibrate the watchdog timer? I'm trying to use it as a time source, even when asleep, but it's woefully inaccurate. Some simple testing showed it loosing 2 minutes every &lt;em&gt;hour&lt;/em&gt;!&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-04-09T03:58:58.360" Title="Calibrate Watchdog Timer" Tags="|timers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1129" PostTypeId="2" ParentId="1128" CreationDate="2014-04-09T03:42:30.483" Score="4" Body="&lt;p&gt;Not only is it uncalibrateable, but it's actually pretty rubbish (as you've discovered). If you check the datasheet you'll see that it can vary between about 109kHz and 119kHz, even though its nominal frequency is 128kHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the ATmegaXX8(A/P) you can reconfigure the system to run its CPU off the internal RC oscillator and timer 2 from a crystal across TOSC1/TOSC2 (pins 9/10 [DIP] or 7/8 [TQFP]) by setting ASSR[6:5] to 0b01 and changing the CKSEL[3:0] fuse bits to 0b0010. Take careful note of the warning on AS2 in the datasheet though. If you want to use a watch crystal instead of prescaling the existing crystal on an Arduino board then you'll need some soldering skill as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need crystal accuracy for the CPU as well then you'll need to move up to an AVR family that has a separate asynchronous timer that can be supplied with a watch crystal, such as the ATmegaXX4(P) (Sanguino) or ATmegaXXX0 (Mega/Mega 2560).&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-04-09T03:58:58.360" LastActivityDate="2014-04-09T03:58:58.360" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1130" PostTypeId="2" ParentId="1126" CreationDate="2014-04-09T04:32:39.923" Score="1" Body="&lt;p&gt;I would also check out &lt;a href=&quot;http://www.rfduino.com/&quot; rel=&quot;nofollow&quot;&gt;RFDuino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it's a finger-tip sized, Arduino compatible, wireless enabled microcontroller, low cost enough to leave in all of your projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RFduino runs Arduino code and can do everything an Arduino can.&lt;/p&gt;&#xA;" OwnerUserId="983" LastActivityDate="2014-04-09T04:32:39.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1132" PostTypeId="1" CreationDate="2014-04-09T23:31:56.213" Score="3" ViewCount="3501" Body="&lt;p&gt;I really hope somebody can help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help making my code receive updates faster to the parser...I need the received GPS coordinates (Latitude and Longitude) to update 5 or more times a second, currently it locks when stationary. Can somebody help? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;/* This sample code demonstrates the normal use of a TinyGPS object.&#xA;   It requires the use of SoftwareSerial, and assumes that you have a&#xA;   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).&#xA;*/&#xA;&#xA;TinyGPS gps;&#xA;//SoftwareSerial ss(4, 3);&#xA;&#xA;static void smartdelay(unsigned long ms);&#xA;static void print_float(float val, float invalid, int len, int prec);&#xA;static void print_int(unsigned long val, unsigned long invalid, int len);&#xA;static void print_date(TinyGPS &amp;amp;gps);&#xA;static void print_str(const char *str, int len);&#xA;//double getCurrentLatitude();&#xA;//double getCurrentLongitude();&#xA;&#xA;//double cLatitude = 0.0;&#xA;//double cLongitude = 0.0;&#xA;//&#xA;//double getCurrentLatitude(){&#xA;//  return cLatitude;&#xA;//}&#xA;//&#xA;//double getCurrentLongitude(){&#xA;//  return cLongitude;  &#xA;//}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;&#xA;//  Serial.print(&quot;Testing TinyGPS library v. &quot;); Serial.println(TinyGPS::library_version());&#xA;//  Serial.println();&#xA;//  Serial.println(&quot;Sats HDOP Latitude      Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum&quot;);&#xA;//  Serial.println(&quot;          (deg)         (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail&quot;);&#xA;//  Serial.println(&quot;------------------------------------------------------------------------------------------------------------------------------------------&quot;);&#xA;&#xA;  Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  double flat, flon = 0.0000000000000;&#xA;  unsigned long age, date, time, chars = 0;&#xA;  unsigned short sentences = 0, failed = 0;&#xA;  //static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;&#xA;&#xA;//  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);&#xA;//  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);&#xA;  gps.f_get_position(&amp;amp;flat, &amp;amp;flon, &amp;amp;age);&#xA;//  gps.f_get_position(&amp;amp;cLatitude,&amp;amp;cLongitude, &amp;amp;age);&#xA;&#xA;  //print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 13, 8);&#xA;  //print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 13, 8);&#xA;&#xA;  float lati = (float)flat;&#xA;  float longi = (float)flon;&#xA;&#xA;  Serial.print(&quot;     &quot;);&#xA;  Serial.print(lati, 8);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(longi, 8);&#xA;  smartdelay(0);&#xA;  //cLatitude = flat;&#xA;  //cLongitude = flon;&#xA;//  print_float(getCurrentLatitude(), TinyGPS::GPS_INVALID_F_ANGLE, 13, 8);&#xA;//  print_float(getCurrentLongitude(), TinyGPS::GPS_INVALID_F_ANGLE, 13, 8);&#xA;&#xA;&#xA;//  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;//  print_date(gps);&#xA;//  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);&#xA;//  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;//  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);&#xA;//  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(gps.f_course()), 6);&#xA;//  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);&#xA;//  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;//  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);&#xA;//&#xA;//  gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed);&#xA;//  print_int(chars, 0xFFFFFFFF, 6);&#xA;//  print_int(sentences, 0xFFFFFFFF, 10);&#xA;//  print_int(failed, 0xFFFFFFFF, 9);&#xA;&#xA;  Serial.println();&#xA;&#xA;  smartdelay(1000);&#xA;}&#xA;&#xA;static void smartdelay(unsigned long ms)&#xA;{&#xA;  unsigned long start = millis();&#xA;  do &#xA;  {&#xA;    while (Serial1.available())&#xA;      gps.encode(Serial1.read());&#xA;  } while (millis() - start &amp;lt; ms);&#xA;}&#xA;&#xA;static void print_float(float val, float invalid, int len, int prec)&#xA;{&#xA;  if (val == invalid)&#xA;  {&#xA;    while (len-- &amp;gt; 1)&#xA;      Serial.print('*');&#xA;    Serial.print(' ');&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(val, prec);&#xA;    int vi = abs((int)val);&#xA;    int flen = prec + (val &amp;lt; 0.0 ? 2 : 1); // . and -&#xA;    flen += vi &amp;gt;= 1000 ? 4 : vi &amp;gt;= 100 ? 3 : vi &amp;gt;= 10 ? 2 : 1;&#xA;    for (int i=flen; i&amp;lt;len; ++i)&#xA;      Serial.print(' ');&#xA;  }&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;&#xA;/*&#xA;    If data is invalid, print out *******&#xA;    otherwise print out buffer&#xA;*/&#xA;static void print_int(unsigned long val, unsigned long invalid, int len)&#xA;{&#xA;  char sz[32];&#xA;  if (val == invalid)&#xA;    strcpy(sz, &quot;*******&quot;);&#xA;  else&#xA;    sprintf(sz, &quot;%ld&quot;, val);&#xA;  sz[len] = 0;&#xA;  for (int i=strlen(sz); i&amp;lt;len; ++i)&#xA;    sz[i] = ' ';&#xA;  if (len &amp;gt; 0) &#xA;    sz[len-1] = ' ';&#xA;  Serial.print(sz);&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;static void print_date(TinyGPS &amp;amp;gps)&#xA;{&#xA;  int year;&#xA;  byte month, day, hour, minute, second, hundredths;&#xA;  unsigned long age;&#xA;  gps.crack_datetime(&amp;amp;year, &amp;amp;month, &amp;amp;day, &amp;amp;hour, &amp;amp;minute, &amp;amp;second, &amp;amp;hundredths, &amp;amp;age);&#xA;  if (age == TinyGPS::GPS_INVALID_AGE)&#xA;    Serial.print(&quot;********** ******** &quot;);&#xA;  else&#xA;  {&#xA;    char sz[32];&#xA;    sprintf(sz, &quot;%02d/%02d/%02d %02d:%02d:%02d &quot;,&#xA;        month, day, year, hour, minute, second);&#xA;    Serial.print(sz);&#xA;  }&#xA;  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;static void print_str(const char *str, int len)&#xA;{&#xA;  int slen = strlen(str);&#xA;  for (int i=0; i&amp;lt;len; ++i)&#xA;    Serial.print(i&amp;lt;slen ? str[i] : ' ');&#xA;  smartdelay(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="993" LastEditorUserId="84" LastEditDate="2014-04-10T05:17:11.400" LastActivityDate="2014-04-16T09:24:20.727" Title="Faster GPS update rate for parser" Tags="|arduino-due|tinygps|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1133" PostTypeId="1" CreationDate="2014-04-10T03:55:45.807" Score="3" ViewCount="4613" Body="&lt;p&gt;I have a Seeed Studio SD card shield (V3) that I am trying to use on my Arduino Due. I am having trouble using the SD examples that come with the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They worked fine on my Arduino Uno by setting &lt;code&gt;chipSelect&lt;/code&gt; to &lt;code&gt;SS&lt;/code&gt;. Below is the code I used for the Arduino Uno. It is the same as the &lt;code&gt;CardInfo.ino&lt;/code&gt; in the examples section under SD (except for the &lt;code&gt;chipSelect&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CardInfo.ino&#xA;&#xA;    /*&#xA;      SD card test&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; This example shows how use the utility libraries on which the'&#xA; SD library is based in order to get info about your SD card.&#xA; Very useful for testing a card when you're not sure whether its working or not.&#xA;&#xA; The circuit:&#xA;  * SD card attached to SPI bus as follows:&#xA; ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila&#xA; ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila&#xA; ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila&#xA; ** CS - depends on your SD card shield or module.&#xA;        Pin 4 used here for consistency with other Arduino examples&#xA;&#xA;&#xA; created  28 Mar 2011&#xA; by Limor Fried&#xA; modified 9 Apr 2012&#xA; by Tom Igoe&#xA;*/&#xA;&#xA;// include the SD library:&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;// set up variables using the SD utility library functions:&#xA;Sd2Card card;&#xA;SdVolume volume;&#xA;SdFile root;&#xA;&#xA;// change this to match your SD shield or module;&#xA;// Arduino Ethernet shield: pin 4&#xA;// Adafruit SD shields and modules: pin 10&#xA;// Sparkfun SD shield: pin 8&#xA;const int chipSelect = SS; //CHANGE HERE!!!!!!!!&#xA;&#xA;void setup()&#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;&#xA;  Serial.print(&quot;\nInitializing SD card...&quot;);&#xA;  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.&#xA;  // Note that even if it's not used as the CS pin, the hardware SS pin&#xA;  // (10 on most Arduino boards, 53 on the Mega) must be left as an output&#xA;  // or the SD library functions will not work.&#xA;  pinMode(10, OUTPUT);     // change this to 53 on a mega&#xA;&#xA;&#xA;  // we'll use the initialization code from the utility libraries&#xA;  // since we're just testing if the card is working!&#xA;  if (!card.init(SPI_HALF_SPEED, chipSelect)) {&#xA;    Serial.println(&quot;initialization failed. Things to check:&quot;);&#xA;    Serial.println(&quot;* is a card is inserted?&quot;);&#xA;    Serial.println(&quot;* Is your wiring correct?&quot;);&#xA;    Serial.println(&quot;* did you change the chipSelect pin to match your shield or module?&quot;);&#xA;    return;&#xA;  } else {&#xA;    Serial.println(&quot;Wiring is correct and a card is present.&quot;);&#xA;  }&#xA;&#xA;  // print the type of card&#xA;  Serial.print(&quot;\nCard type: &quot;);&#xA;  switch (card.type()) {&#xA;    case SD_CARD_TYPE_SD1:&#xA;      Serial.println(&quot;SD1&quot;);&#xA;      break;&#xA;    case SD_CARD_TYPE_SD2:&#xA;      Serial.println(&quot;SD2&quot;);&#xA;      break;&#xA;    case SD_CARD_TYPE_SDHC:&#xA;      Serial.println(&quot;SDHC&quot;);&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;Unknown&quot;);&#xA;  }&#xA;&#xA;  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32&#xA;  if (!volume.init(card)) {&#xA;    Serial.println(&quot;Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;&#xA;  // print the type and size of the first FAT-type volume&#xA;  uint32_t volumesize;&#xA;  Serial.print(&quot;\nVolume type is FAT&quot;);&#xA;  Serial.println(volume.fatType(), DEC);&#xA;  Serial.println();&#xA;&#xA;  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks&#xA;  volumesize *= volume.clusterCount();       // we'll have a lot of clusters&#xA;  volumesize *= 512;                            // SD card blocks are always 512 bytes&#xA;  Serial.print(&quot;Volume size (bytes): &quot;);&#xA;  Serial.println(volumesize);&#xA;  Serial.print(&quot;Volume size (Kbytes): &quot;);&#xA;  volumesize /= 1024;&#xA;  Serial.println(volumesize);&#xA;  Serial.print(&quot;Volume size (Mbytes): &quot;);&#xA;  volumesize /= 1024;&#xA;  Serial.println(volumesize);&#xA;&#xA;&#xA;  Serial.println(&quot;\nFiles found on the card (name, date and size in bytes): &quot;);&#xA;  root.openRoot(volume);&#xA;&#xA;  // list all files in the card with date and size&#xA;  root.ls(LS_R | LS_DATE | LS_SIZE);&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a picture of my setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nZ6f9.jpg&quot; alt=&quot;Due with SD card shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;tl;dr&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;How do I make this shield work on my Due?&lt;/p&gt;&#xA;" OwnerUserId="996" LastEditorUserId="37523" LastEditDate="2019-05-10T18:44:50.540" LastActivityDate="2020-06-16T14:10:40.243" Title="Using SD card shield on Arduino Due" Tags="|serial|shields|arduino-due|sd-card|spi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="1134" PostTypeId="1" CreationDate="2014-04-10T10:08:02.490" Score="3" ViewCount="999" Body="&lt;p&gt;I have an analog sensor which reads values 0-5v, -75 degrees to 75 degrees. Now I have converted to +75 degrees and -75 degrees format depend on the voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From 2.5v to 5v data is read properly (i.e 0-75 degree), but from 0-2.5v they are negative values -75 degree to 0. In the below image array holding register is reading 65493 and 65491 which are negative value. How do I make it readable format? Since my code is very big, only part of code is pasted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ID   1&#xA;&#xA;int Wind_Speed=30;&#xA;int Wind_Kmph=67;&#xA;signed int tracker_des_angle=-45;&#xA;signed int tracker_actual_pos=-43;&#xA;Modbus slave(ID, 0, 0);&#xA;boolean led;&#xA;int8_t state = 0;&#xA;unsigned long tempus;&#xA;// data array for modbus network sharing&#xA;uint16_t au16data[14];&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  // start communication&#xA;  slave.begin( 9600 );&#xA;  rtcSetup();&#xA;&#xA;  tempus = millis() + 100;&#xA;  digitalWrite(13, HIGH );&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // poll messages&#xA;  // blink led pin on each valid message&#xA;  state = slave.poll( au16data, 14);&#xA;  if (state &amp;gt; 4) {&#xA;    tempus = millis() + 50;&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;  if (millis() &amp;gt; tempus) digitalWrite(13, LOW ); &#xA;  calcTime();&#xA;  convertUTCtoLocal();&#xA;&#xA;  au16data[0]=local_year;&#xA;  au16data[1]=local_month;&#xA;  au16data[2]=local_day;&#xA;  au16data[3]=wkDay;&#xA;  au16data[4]=local_h;&#xA;  au16data[5]=local_m;&#xA;  au16data[6]=local_s;&#xA;  au16data[7]=Wind_Speed;&#xA;  au16data[8]=Wind_Kmph;&#xA;  au16data[9]=tracker_des_angle;&#xA;  au16data[10]=tracker_actual_pos;&#xA;&#xA;  au16data[11] = slave.getInCnt();&#xA;  au16data[12] = slave.getOutCnt();&#xA;  au16data[13] = slave.getErrCnt();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ynsrT.png&quot; alt=&quot;Negtive value read&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="42" LastEditDate="2014-05-21T22:53:11.723" LastActivityDate="2014-05-21T22:53:11.723" Title="Negative value conversion for modbus slave" Tags="|arduino-uno|arduino-mega|modbus|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1135" PostTypeId="1" CreationDate="2014-04-10T18:22:17.600" Score="7" ViewCount="2274" Body="&lt;p&gt;I am trying to make a small project. Firstly, I want to record voice using a small microphone(electret) for the time button is pressed and on releasing the button, the speaker of my laptop should output the recorded voice or a speaker attached to the arduino should output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note: I don't want to use any shield to do so. Simply Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1004" LastActivityDate="2014-04-10T18:29:06.040" Title="Mic input and Speaker output using arduino" Tags="|interrupt|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1136" PostTypeId="2" ParentId="1135" CreationDate="2014-04-10T18:29:06.040" Score="3" Body="&lt;p&gt;Microphone input is easy (ADC). Speaker output is easy (PWM). Both have many, many examples strewn across the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens in between is &lt;em&gt;not&lt;/em&gt;, and will require external components. You will need at the very least somewhere to store the samples between record and playback. Investigate SPI SRAM large enough to store all the required samples at your chosen sample rate (8 kS/s should be high enough for human speech).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-10T18:29:06.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1137" PostTypeId="1" CreationDate="2014-04-10T20:01:56.483" Score="4" ViewCount="20745" Body="&lt;p&gt;I downloaded the Adafruit_GPS library from Adafruit and I'm trying to compile the example code (due_parsing) but I can't seem to get past this silly error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from due_parsing.ino:15:&#xA;&#xA;/Users/haddad/Documents/Arduino/libraries/Adafruit_GPS/Adafruit_GPS.h:24: fatal error: SoftwareSerial.h: No such file or directory&#xA;compilation terminated.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the location in the example Arduino Sketch where &lt;code&gt;SoftwareSerial.h&lt;/code&gt; is mentioned:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __AVR__&#xA;  #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed it's around an &lt;code&gt;ifdef&lt;/code&gt; guard, so shouldn't it not even matter that I don't have this library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went into the .h and .cpp files and commented out the where it called &lt;code&gt;SoftwareSerial.h&lt;/code&gt;, but I'm still getting that above error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how to fix this?&#xA;I am using Arduino IDE v1.5.5&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't put the library in the library direct on my mac but I'm now getting tons of errors, all the errors are with &lt;code&gt;SoftwareSerial.cpp&lt;/code&gt;. Is anybody else having similar issues when you go to compile?&lt;/p&gt;&#xA;" OwnerUserId="993" LastEditorUserId="37" LastEditDate="2014-04-11T15:22:42.703" LastActivityDate="2017-11-02T07:08:52.590" Title="Why am I getting &quot;fatal error: SoftwareSerial.h: No such file or directory&quot;" Tags="|arduino-due|softwareserial|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1138" PostTypeId="1" AcceptedAnswerId="4537" CreationDate="2014-04-10T21:01:52.340" Score="10" ViewCount="32088" Body="&lt;p&gt;Even on ebay's &lt;a href=&quot;http://www.ebay.com/itm/2-4-TFT-LCD-Shield-Touch-Panel-Display-TF-Reader-For-Arduino-UNO-R2-R3-A137-/390631788477&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; it is mentioned that I can't use 2.4&quot; TFT LCD Shield display on attach to Arduino Mega. The problem is that I bought this shield by mistake. I want to put this shield onto Arduino Mega 2560. Is there a way to combine Mega and 2.4&quot; Display Shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note: I tried on my friend's Arduino Uno. Shield is working very good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note: The photo below is determining my question. The display not runs my Arduino's code. It only runs its LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DGkHU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // UTFT_Demo_320x240 (C)2012 Henning Karlsen&#xA;// web: http://www.henningkarlsen.com/electronics&#xA;//&#xA;// This program is a demo of how to use most of the functions&#xA;// of the library with a supported display modules.&#xA;//&#xA;// This demo was made for modules with a screen resolution &#xA;// of 320x240 pixels.&#xA;//&#xA;// This program requires the UTFT library.&#xA;//&#xA;&#xA;#include &amp;lt;UTFT.h&amp;gt;&#xA;#define ILI9320_16 18&#xA;// Declare which fonts we will be using&#xA;extern uint8_t SmallFont[];&#xA;&#xA;// Uncomment the next line for Arduino 2009/Uno&#xA;//UTFT myGLCD(UNO_24,A2,A1,A3,A4);   // Remember to change the model parameter to suit your display module!&#xA;&#xA;// Uncomment the next line for Arduino Mega&#xA;UTFT myGLCD(ILI9320_16,38,39,40,41);   // Remember to change the model parameter to suit your display module!&#xA;&#xA;void setup()&#xA;{&#xA;  randomSeed(analogRead(0));&#xA;&#xA;// Setup the LCD&#xA;  pinMode(A0,OUTPUT);       // for the UNO_SHIELD_1IN1&#xA;  digitalWrite(A0,HIGH);    // the RD pin must be set high&#xA;  myGLCD.InitLCD();&#xA;  myGLCD.setFont(SmallFont);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int buf[318];&#xA;  int x, x2;&#xA;  int y, y2;&#xA;  int r;&#xA;&#xA;// Clear the screen and draw the frame&#xA;  myGLCD.clrScr();&#xA;&#xA;  myGLCD.setColor(255, 0, 0);&#xA;  myGLCD.fillRect(0, 0, 319, 13);&#xA;  myGLCD.setColor(64, 64, 64);&#xA;  myGLCD.fillRect(0, 226, 319, 239);&#xA;  myGLCD.setColor(255, 255, 255);&#xA;  myGLCD.setBackColor(255, 0, 0);&#xA;  myGLCD.print(&quot;* Universal Color TFT Display Library *&quot;, CENTER, 1);&#xA;  myGLCD.setBackColor(64, 64, 64);&#xA;  myGLCD.setColor(255,255,0);&#xA;  myGLCD.print(&quot;&amp;lt;http://electronics.henningkarlsen.com&amp;gt;&quot;, CENTER, 227);&#xA;&#xA;  myGLCD.setColor(0, 0, 255);&#xA;  myGLCD.drawRect(0, 14, 319, 225);&#xA;&#xA;// Draw crosshairs&#xA;  myGLCD.setColor(0, 0, 255);&#xA;  myGLCD.setBackColor(0, 0, 0);&#xA;  myGLCD.drawLine(159, 15, 159, 224);&#xA;  myGLCD.drawLine(1, 119, 318, 119);&#xA;  for (int i=9; i&amp;lt;310; i+=10)&#xA;    myGLCD.drawLine(i, 117, i, 121);&#xA;  for (int i=19; i&amp;lt;220; i+=10)&#xA;    myGLCD.drawLine(157, i, 161, i);&#xA;&#xA;// Draw sin-, cos- and tan-lines  &#xA;  myGLCD.setColor(0,255,255);&#xA;  myGLCD.print(&quot;Sin&quot;, 5, 15);&#xA;  for (int i=1; i&amp;lt;318; i++)&#xA;  {&#xA;    myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));&#xA;  }&#xA;&#xA;  myGLCD.setColor(255,0,0);&#xA;  myGLCD.print(&quot;Cos&quot;, 5, 27);&#xA;  for (int i=1; i&amp;lt;318; i++)&#xA;  {&#xA;    myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));&#xA;  }&#xA;&#xA;  myGLCD.setColor(255,255,0);&#xA;  myGLCD.print(&quot;Tan&quot;, 5, 39);&#xA;  for (int i=1; i&amp;lt;318; i++)&#xA;  {&#xA;    myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;  myGLCD.setColor(0, 0, 255);&#xA;  myGLCD.setBackColor(0, 0, 0);&#xA;  myGLCD.drawLine(159, 15, 159, 224);&#xA;  myGLCD.drawLine(1, 119, 318, 119);&#xA;&#xA;// Draw a moving sinewave&#xA;  x=1;&#xA;  for (int i=1; i&amp;lt;(318*20); i++) &#xA;  {&#xA;    x++;&#xA;    if (x==319)&#xA;      x=1;&#xA;    if (i&amp;gt;319)&#xA;    {&#xA;      if ((x==159)||(buf[x-1]==119))&#xA;        myGLCD.setColor(0,0,255);&#xA;      else&#xA;        myGLCD.setColor(0,0,0);&#xA;      myGLCD.drawPixel(x,buf[x-1]);&#xA;    }&#xA;    myGLCD.setColor(0,255,255);&#xA;    y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));&#xA;    myGLCD.drawPixel(x,y);&#xA;    buf[x-1]=y;&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some filled rectangles&#xA;  for (int i=1; i&amp;lt;6; i++)&#xA;  {&#xA;    switch (i)&#xA;    {&#xA;      case 1:&#xA;        myGLCD.setColor(255,0,255);&#xA;        break;&#xA;      case 2:&#xA;        myGLCD.setColor(255,0,0);&#xA;        break;&#xA;      case 3:&#xA;        myGLCD.setColor(0,255,0);&#xA;        break;&#xA;      case 4:&#xA;        myGLCD.setColor(0,0,255);&#xA;        break;&#xA;      case 5:&#xA;        myGLCD.setColor(255,255,0);&#xA;        break;&#xA;    }&#xA;    myGLCD.fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some filled, rounded rectangles&#xA;  for (int i=1; i&amp;lt;6; i++)&#xA;  {&#xA;    switch (i)&#xA;    {&#xA;      case 1:&#xA;        myGLCD.setColor(255,0,255);&#xA;        break;&#xA;      case 2:&#xA;        myGLCD.setColor(255,0,0);&#xA;        break;&#xA;      case 3:&#xA;        myGLCD.setColor(0,255,0);&#xA;        break;&#xA;      case 4:&#xA;        myGLCD.setColor(0,0,255);&#xA;        break;&#xA;      case 5:&#xA;        myGLCD.setColor(255,255,0);&#xA;        break;&#xA;    }&#xA;    myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some filled circles&#xA;  for (int i=1; i&amp;lt;6; i++)&#xA;  {&#xA;    switch (i)&#xA;    {&#xA;      case 1:&#xA;        myGLCD.setColor(255,0,255);&#xA;        break;&#xA;      case 2:&#xA;        myGLCD.setColor(255,0,0);&#xA;        break;&#xA;      case 3:&#xA;        myGLCD.setColor(0,255,0);&#xA;        break;&#xA;      case 4:&#xA;        myGLCD.setColor(0,0,255);&#xA;        break;&#xA;      case 5:&#xA;        myGLCD.setColor(255,255,0);&#xA;        break;&#xA;    }&#xA;    myGLCD.fillCircle(100+(i*20),60+(i*20), 30);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some lines in a pattern&#xA;  myGLCD.setColor (255,0,0);&#xA;  for (int i=15; i&amp;lt;224; i+=5)&#xA;  {&#xA;    myGLCD.drawLine(1, i, (i*1.44)-10, 224);&#xA;  }&#xA;  myGLCD.setColor (255,0,0);&#xA;  for (int i=224; i&amp;gt;15; i-=5)&#xA;  {&#xA;    myGLCD.drawLine(318, i, (i*1.44)-11, 15);&#xA;  }&#xA;  myGLCD.setColor (0,255,255);&#xA;  for (int i=224; i&amp;gt;15; i-=5)&#xA;  {&#xA;    myGLCD.drawLine(1, i, 331-(i*1.44), 15);&#xA;  }&#xA;  myGLCD.setColor (0,255,255);&#xA;  for (int i=15; i&amp;lt;224; i+=5)&#xA;  {&#xA;    myGLCD.drawLine(318, i, 330-(i*1.44), 224);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some random circles&#xA;  for (int i=0; i&amp;lt;100; i++)&#xA;  {&#xA;    myGLCD.setColor(random(255), random(255), random(255));&#xA;    x=32+random(256);&#xA;    y=45+random(146);&#xA;    r=random(30);&#xA;    myGLCD.drawCircle(x, y, r);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some random rectangles&#xA;  for (int i=0; i&amp;lt;100; i++)&#xA;  {&#xA;    myGLCD.setColor(random(255), random(255), random(255));&#xA;    x=2+random(316);&#xA;    y=16+random(207);&#xA;    x2=2+random(316);&#xA;    y2=16+random(207);&#xA;    myGLCD.drawRect(x, y, x2, y2);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;// Draw some random rounded rectangles&#xA;  for (int i=0; i&amp;lt;100; i++)&#xA;  {&#xA;    myGLCD.setColor(random(255), random(255), random(255));&#xA;    x=2+random(316);&#xA;    y=16+random(207);&#xA;    x2=2+random(316);&#xA;    y2=16+random(207);&#xA;    myGLCD.drawRoundRect(x, y, x2, y2);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;  for (int i=0; i&amp;lt;100; i++)&#xA;  {&#xA;    myGLCD.setColor(random(255), random(255), random(255));&#xA;    x=2+random(316);&#xA;    y=16+random(209);&#xA;    x2=2+random(316);&#xA;    y2=16+random(209);&#xA;    myGLCD.drawLine(x, y, x2, y2);&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.setColor(0,0,0);&#xA;  myGLCD.fillRect(1,15,318,224);&#xA;&#xA;  for (int i=0; i&amp;lt;10000; i++)&#xA;  {&#xA;    myGLCD.setColor(random(255), random(255), random(255));&#xA;    myGLCD.drawPixel(2+random(316), 16+random(209));&#xA;  }&#xA;&#xA;  delay(2000);&#xA;&#xA;  myGLCD.fillScr(0, 0, 255);&#xA;  myGLCD.setColor(255, 0, 0);&#xA;  myGLCD.fillRoundRect(80, 70, 239, 169);&#xA;&#xA;  myGLCD.setColor(255, 255, 255);&#xA;  myGLCD.setBackColor(255, 0, 0);&#xA;  myGLCD.print(&quot;That's it!&quot;, CENTER, 93);&#xA;  myGLCD.print(&quot;Restarting in a&quot;, CENTER, 119);&#xA;  myGLCD.print(&quot;few seconds...&quot;, CENTER, 132);&#xA;&#xA;  myGLCD.setColor(0, 255, 0);&#xA;  myGLCD.setBackColor(0, 0, 255);&#xA;  myGLCD.print(&quot;Runtime: (msecs)&quot;, CENTER, 210);&#xA;  myGLCD.printNumI(millis(), CENTER, 225);&#xA;&#xA;  delay (10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="1006" LastEditDate="2014-04-10T22:00:59.223" LastActivityDate="2015-07-25T16:50:31.483" Title="2.4&quot; TFT LCD Shield isn't working on Arduino Mega" Tags="|arduino-mega|shields|lcd|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1140" PostTypeId="2" ParentId="1137" CreationDate="2014-04-11T04:36:18.463" Score="3" Body="&lt;p&gt;According to your comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;after commenting out those ifdef guards, it worked&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would say that is a bug in the &lt;strong&gt;Adafruit_GPS&lt;/strong&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a matter of fact, the &lt;strong&gt;DUE&lt;/strong&gt; is not using the &lt;strong&gt;AVR&lt;/strong&gt; architecture (it uses &lt;strong&gt;ARM&lt;/strong&gt;), that explains why &lt;code&gt;#ifdef __AVR__&lt;/code&gt; in &lt;code&gt;Adafruit_GPS.h&lt;/code&gt; never passes; but then something else should be done specifically for the DUE (missing &lt;code&gt;#else&lt;/code&gt; or &lt;code&gt;#elif&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After checking on &lt;em&gt;github&lt;/em&gt;, there is an &lt;a href=&quot;https://github.com/adafruit/Adafruit-GPS-Library/issues/14&quot; rel=&quot;nofollow&quot;&gt;issue&lt;/a&gt; open for that; unfortunately, as of April 2014, it has not moved for 10 months.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best guess would be to go there and try to &quot;reactivate&quot; this issue.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-04-11T04:36:18.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1141" PostTypeId="2" ParentId="1114" CreationDate="2014-04-11T05:39:10.613" Score="2" Body="&lt;p&gt;There may be a problem with sending Email from Arduino, but not where you are expecting it. SMTP protocol is super simple, even Arduino can handle it. But you will need SMTP server somewhere that will talk to your Arduino. SSL connections (as on Gmail) are out of consideration (code to handle the encryption would be too much for Arduino) so you'd have to find mail provider that provides plain SMTP - and there aren't many. If you will set up one yourself, say on your home PC with static IP address, it would be an invitation for spammers and a guaranteed way to get your IP blacklisted by Spamhaus. My advice would be to have Python, PHP or Perl script hosted somewhere that will handle HTTP POST requests from your Arduino and do Email sending. It is safer and simpler.&lt;/p&gt;&#xA;" OwnerUserId="562" LastActivityDate="2014-04-11T05:39:10.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1144" PostTypeId="1" AcceptedAnswerId="1145" CreationDate="2014-04-11T18:09:40.020" Score="6" ViewCount="421" Body="&lt;p&gt;I am new to using Arduino Yun and I would like to know if it is possible to run a command from the Arduino sketch in order to make (probably, through the Bridge Library) Linino to execute a HTTP Request to a remote server. Then I would like to know if it is possible to use the returned values in that Arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I would like to delegate the task of retrieving values from the web to the Linux side and the usage of the retrieved data to the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible, how to do that?&lt;/p&gt;&#xA;" OwnerUserId="1015" LastEditorUserId="1015" LastEditDate="2014-04-11T18:15:48.527" LastActivityDate="2014-04-11T19:03:36.213" Title="It is possible to program Linino to send HTTP requests and then use the returned values in sketch?" Tags="|programming|library|sketch|arduino-yun|web|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1145" PostTypeId="2" ParentId="1144" CreationDate="2014-04-11T19:03:36.213" Score="1" Body="&lt;p&gt;Take a look at &lt;a href=&quot;http://arduino.cc/en/Tutorial/Bridge&quot; rel=&quot;nofollow&quot;&gt;Bridge example&lt;/a&gt; or &lt;a href=&quot;http://arduino.cc/en/Tutorial/TemperatureWebPanel&quot; rel=&quot;nofollow&quot;&gt;TemperatureWebPanel example&lt;/a&gt;: you see you can receive kind of &quot;commands&quot; and react &quot;doing things&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then take a look at &lt;a href=&quot;http://arduino.cc/en/Tutorial/HttpClient&quot; rel=&quot;nofollow&quot;&gt;HTTP Client example&lt;/a&gt;, where you delegate an HTTP call to the linux side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now mix the two: you can make HTTP calls after receiving a command from outside your Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A short test can be done by cutting and pasting the examples above.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-04-11T19:03:36.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1146" PostTypeId="1" AcceptedAnswerId="1168" CreationDate="2014-04-11T19:48:47.153" Score="6" ViewCount="2020" Body="&lt;p&gt;I am new to using Arduino Yun and I would like to know if it is possible to run an entire script on the Linux side. In my case the script should execute a HTTP request to a remote server, parse the subsequent HTTP response and return some value that then can be used in the Arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible, what I have to do? For example, how should I write and run script files? what programming language should I use? where I should put those script files on the Linux side?&lt;/p&gt;&#xA;" OwnerUserId="1015" LastActivityDate="2014-04-14T10:37:38.250" Title="It is possible to run an entire script on the Linux side? If so, how, what and where to do that?" Tags="|programming|sketch|arduino-yun|web|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1147" PostTypeId="2" ParentId="1137" CreationDate="2014-04-11T23:22:13.890" Score="0" Body="&lt;p&gt;So I went into the interface file (.h) and removed all references to AVR and then went into (.cpp) and removed all references to AVR there as well. It now seems to be working, although sometimes it says &quot;Not supported Architecture ARM&quot; during compilation...very weird&lt;/p&gt;&#xA;" OwnerUserId="993" LastActivityDate="2014-04-11T23:22:13.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1148" PostTypeId="1" CreationDate="2014-03-08T19:12:32.133" Score="4" ViewCount="1744" Body="&lt;p&gt;I wanted to use either Arduino Mega or Uno as a form of an interface between me and the computer. I want to apply it to the following scenario; if I press a button on a circuit board I want it to trigger an action on my computer, like scroll down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this? How would the code look like and what programs would I need to translate from Arduino to Windows?&lt;/p&gt;&#xA;" OwnerUserId="4066" OwnerDisplayName="Jakub" LastActivityDate="2014-04-12T18:11:16.540" Title="Use an Arduino as a user interface for the computer" Tags="|serial|linux|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1149" PostTypeId="2" ParentId="1148" CreationDate="2014-03-08T20:22:37.537" Score="1" Body="&lt;p&gt;You can do that easily with a few of the Arduino boards that have built-in USB communications support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You find that feature on Leonardo, Micro, Esplora and Due boards. You also find that on some Arduino compatible boards like the Adafruit Flora.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply plug the Arduino USB port to your computer and the Arduino will behave like a keyboard. Then you can program your sketch to perform what you want with your buttons. Check the Arduino  &lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard#.Uxt6yuddVTY&quot; rel=&quot;nofollow&quot;&gt;mouse and keyboard library&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="mlemos" LastActivityDate="2014-03-08T20:22:37.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1150" PostTypeId="2" ParentId="1148" CreationDate="2014-03-08T20:39:11.033" Score="2" Body="&lt;p&gt;Arduino Yun, Leonardo, Esplora and Due have  the ability to appear as a native Mouse and/or Keyboard to a connected computer by use of the &lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard#.Uxt-kIWzBzw&quot; rel=&quot;nofollow&quot;&gt;Mouse and Keyboard libraries&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of how you would use SWITCH3 on the Esplora to active PAGE UP on your keyboard.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!Esplora.readButton(SWITCH_3)) {&#xA;  Keyboard.press(KEY_PAGE_UP)&#xA;  delay(100);&#xA;  Keyboard.releaseAll();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Esplora-Flight-Simulator/&quot; rel=&quot;nofollow&quot;&gt;Here's an example&lt;/a&gt; of using the Esplora to control the Keyboard and Mouse to control the Flight Simulator option of Google Earth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use the Uno it's more difficult but it can be done by sending data from the Uno to a Python program running on the PC. The Python program uses the pywin library to control windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Flight-Simulator-with-Arduino-and-Python/&quot; rel=&quot;nofollow&quot;&gt;Here's a fully worked out Instructable&lt;/a&gt; on how to do it.&lt;/p&gt;&#xA;" OwnerUserId="113" OwnerDisplayName="akellyirl" LastActivityDate="2014-03-08T20:39:11.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1151" PostTypeId="1" AcceptedAnswerId="1152" CreationDate="2014-02-26T17:18:22.927" Score="2" ViewCount="3101" Body="&lt;p&gt;I am trying to access my Arduino Yun from the internet, and it's not quite working. I have correctly port forwarded the port 5555 from the router to the Yun (verified I am able to access my many other NAT'd resources). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can access the Yun from my internal network. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino sketch I have this (among many other things). Mainly taken from example sketches.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;HttpClient.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;YunServer server;&#xA;&#xA;void setup {&#xA;   // Listen for incoming connections on port 5555&#xA;   server.noListenOnLocalhost();&#xA;   server.begin();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is &lt;code&gt;server.noListenOnLocalhost();&lt;/code&gt; the right one to use to access from the outside world?&lt;/p&gt;&#xA;" OwnerUserId="306" OwnerDisplayName="Pat" LastEditorUserId="11" LastEditDate="2014-04-11T23:45:37.760" LastActivityDate="2014-04-11T23:45:37.760" Title="Accessing Arduino Yun from Internet" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1152" PostTypeId="2" ParentId="1151" CreationDate="2014-02-26T17:37:22.027" Score="2" Body="&lt;p&gt;Well, I'm not familiar with the Yun, but the first thing that stands out is the missing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bridge.begin();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line apparently needed to initialize the Bridge library that you use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you do have something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;YunClient client = server.accept();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &quot;more&quot; in the main loop (or a function where applicable) of your code, right ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, &lt;code&gt;noListenOnLocalhost()&lt;/code&gt; is the correct function for serving external clients.&lt;/p&gt;&#xA;" OwnerUserId="291" OwnerDisplayName="FredP" LastActivityDate="2014-02-26T17:37:22.027" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1153" PostTypeId="2" ParentId="1137" CreationDate="2014-04-12T09:53:26.167" Score="0" Body="&lt;p&gt;this is a &quot;bug&quot; in the arduino IDE pre-compilation process.&#xA;If you turn on the compiling verbositi in thge precerences menu, you will see that arduino has copied all file (with a rater &quot;stupid&quot; code that just look for include) into a temp folder (wiring lib are not copied, but the below still aplly). Until here, ugly but still fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, it will -force- compilation of every &quot;included&quot; file, one by one, the facto bypassing the #ifdef.. and this is why you get that problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution is to heavy change the ide so it will force compilation only in the main, and let the compiler include and compile needed libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still have no idea why every file is forced, but a change like this is really heavy and break-old-code prone..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Newest IDE to bypass this problem (and also some other problem, like depeency) use a &quot;config&quot; file that will tell the IDE if use the AVR or ARM or x86 library, probabily this file is missing and the ide see te lib as only AVR by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Double check if it is really usable on DUE&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-12T09:53:26.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1155" PostTypeId="2" ParentId="1124" CreationDate="2014-04-12T11:10:41.193" Score="-1" Body="&lt;p&gt;the central lock system will close the car doors and close the windows, i think you should build your system with the same idea, dealing with windows motors as normal motor without special commands for the window&lt;/p&gt;&#xA;" OwnerUserId="1021" LastActivityDate="2014-04-12T11:10:41.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1156" PostTypeId="2" ParentId="1148" CreationDate="2014-04-12T18:11:16.540" Score="3" Body="&lt;p&gt;For the sake of completeness, on the more traditional boards where the USB interface is not implemented from the main &quot;sketch&quot; processor, there are three other potential possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the (USB) serial data interface, and have software on the host computer which accepts commands over that.  Obviously, the downside is requiring installation of something on the host system - installation which may require admin privileges or even disabling code signing requirements in some cases (especially if it is to inject the data into the host operating system as if it came from a keyaboard)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On boards such as the Uno and comparable-generation Mega which use a secondary ATmega &quot;u&quot; series part as a USB-serial converter, this chip can be reprogrammed to act instead as a keyboard.  That could make loading sketches tricky - though it might be possible to come up with a dual-mode firmware that could switch roles under control of an external hardware or software signal.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The main ATmega &quot;sketch&quot; processor can generally implement a &quot;not quite compliant, but workable&quot; &lt;em&gt;approximation&lt;/em&gt; of a low-speed USB interface &lt;em&gt;in software&lt;/em&gt; on arbitrary I/O pins with some external matching/protection componenets.  A USB keyboard is a common demo application of that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-04-12T18:11:16.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1157" PostTypeId="1" CreationDate="2014-04-13T05:27:47.710" Score="6" ViewCount="2021" Body="&lt;p&gt;I'm working with an Adafruit LSM303DLHC Accelerometer Sensor hooked up to an Arduino.  I've downloaded the appropriate libraries to make it work and uploaded the example sketch &quot;accelsensor.pde&quot;.  I then placed my sensor at rest on a flat surface and obtained the following acceleration vector values on average, in units of meters per second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X: -0.24  Y: -0.71  Z: 10.47&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At rest, each of these three values fluctuate approximately +-0.04 on average.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I see it, the values are off a bit.  At rest, the X and Y components should hover closer to 0m/s^2 while the Z component should be closer to 9.8m/s^2.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to compensate for this biased measurement?  Should I simply add back the average observed bias?  Or is there a more robust method to calibrate the sensor values? &lt;/p&gt;&#xA;" OwnerUserId="667" LastActivityDate="2014-04-14T13:21:26.257" Title="Calibrating Accelerometer Sensor" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1158" PostTypeId="1" AcceptedAnswerId="1159" CreationDate="2014-04-13T08:08:26.073" Score="6" ViewCount="315" Body="&lt;p&gt;I was playing with getting my servos to be on dedicated power, separate form the Arduino entirely, but obviously controlled by the Arduino. I originally had the ground of the Arduino joined with the &lt;code&gt;-&lt;/code&gt; of the battery, but to my surprise my Arduino continued to control the servos when I remove the ground wire entirely from the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was under the impression that all electricity must form a complete circuit, and be a closed loop. But my Arduino can obviously send a signal to a component that has no return path to itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel like I'm missing something fundamental about a electricity. So my question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why does this work?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/n37I0.jpg&quot; alt=&quot;arduino setup&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="942" LastEditorUserId="942" LastEditDate="2014-04-13T08:19:39.947" LastActivityDate="2014-04-13T08:31:35.377" Title="How can Arduino control with a servo with only one wire?" Tags="|electricity|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1159" PostTypeId="2" ParentId="1158" CreationDate="2014-04-13T08:31:35.377" Score="5" Body="&lt;p&gt;The return signal is probably the other wire's servo. This only works when the control pulses to both servos are not in sync. Pull one signal wire off the breadboard and both servos will stop working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to interconnect grounds or you will get strange effects sooner or later.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-13T08:31:35.377" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1160" PostTypeId="1" AcceptedAnswerId="1169" CreationDate="2014-04-13T12:32:51.317" Score="4" ViewCount="7995" Body="&lt;p&gt;Running Ubuntu 12.04.4 LTS (64 bit) I try to upload my code to the Arduino Due through the Native port. I have tried both the &lt;code&gt;bossac&lt;/code&gt; that ships with the Arduino IDE (which is a modified version of BOSSA), and the master BOSSA branch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ./bossac -p /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;No device found on /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it works perfectly inside the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can the problem be?&lt;/p&gt;&#xA;" OwnerUserId="693" LastEditorUserId="693" LastEditDate="2014-04-15T18:53:50.953" LastActivityDate="2019-12-24T00:00:35.830" Title="Why does command line BOSSA not recognize Arduino Due?" Tags="|arduino-due|bossa|ubuntu|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1162" PostTypeId="1" CreationDate="2014-04-13T20:21:35.167" Score="5" ViewCount="18508" Body="&lt;p&gt;I've hooked up two ultrasonic sensors to my breadboard and I also got a 5 V motor installed. I also got the diode installed and the usual set up. I can easily control the motor with one sensor.&lt;/p&gt;&#xA;&lt;p&gt;I want the motor to run at let's say 100 once I start it up:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first sensor should be used to slowly slow down the motor when an object is placed in front of it&lt;/li&gt;&#xA;&lt;li&gt;The second sensor should be used to slowly speed up the motor when an object is placed in front of it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I do not want the speed to return to 100 once the object is removed. It should remain at the same speed according to which sensor was used.&lt;/p&gt;&#xA;&lt;p&gt;Tell me if I have to clarify anything in the comments.&lt;/p&gt;&#xA;&lt;p&gt;Code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int motorPin = 9;&#xA;int trigPin = 13;&#xA;int echoPin = 12;&#xA;int trigPin2 = 5;&#xA;int echoPin2 = 4;&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(trigPin2, OUTPUT);&#xA;  pinMode(echoPin2, INPUT);&#xA;  pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  int duration, distance;&#xA;  digitalWrite (trigPin, HIGH);&#xA;  delayMicroseconds (1000);&#xA;  digitalWrite (trigPin, LOW);&#xA;  duration = pulseIn (echoPin, HIGH);&#xA;  distance = (duration/2) / 29.1;&#xA;  if (distance &amp;lt; 20) {  // Distance from sensor&#xA;    analogWrite (motorPin, 50);&#xA;  } else {&#xA;    int duration, distance;&#xA;    digitalWrite (trigPin2, HIGH);&#xA;    delayMicroseconds (1000);&#xA;    digitalWrite (trigPin2, LOW);&#xA;    duration = pulseIn (echoPin2, HIGH);&#xA;    distance = (duration/2) / 29.1;&#xA;    if (distance &amp;gt; 20) {  // Distance from sensor&#xA;      analogWrite (motorPin, 150);&#xA;    }&#xA;    if  (distance &amp;gt; 20) {  // Distance from sensor&#xA;      Serial.println(&amp;quot;Out of range&amp;quot;);&#xA;    } else {&#xA;      Serial.print(distance);&#xA;     Serial.println(&amp;quot; cm&amp;quot;);&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1032" LastEditorUserId="61722" LastEditDate="2024-02-02T06:31:50.500" LastActivityDate="2024-03-03T07:01:45.203" Title="How do I use two ultrasonic sensors to control a 5 V motor?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="1163" PostTypeId="1" CreationDate="2014-03-06T01:47:30.947" Score="2" ViewCount="220" Body="&lt;p&gt;So I've got a waveform that's high for 16ms and low for 2ms repeating forever. I need to recreate that and offsets of that waveform time exactly on a different pin. Right now, I've got an interrupt on the rising edge for the 16ms low/high transistion, and delayMicroseconds() that determines the offset and duration of the high and low pulses. Trouble is, I'm not sure the code I have is as fast and accurate as it could be. And the replicated waveform seems to shift through the full period of the original one. I need it to be locked in.Any suggestions?&#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; //3 is interrupt for Timing&#xA;//4 through 11 are Time dependent receivers&#xA;//3-11 Pins 12-19&#xA;char incomingByte = 0;&#xA;&#xA;int pins[9] =&#xA;{&#xA;  3,4,5,6,7,8,9,10,11&#xA;};&#xA;&#xA;void timing()&#xA;{&#xA;  //Serial.println(&quot;This is a 0ms Event&quot;);&#xA; // if(Serial.available() &amp;gt; 0)&#xA; // {&#xA;    incomingByte = Serial.read();&#xA;    Serial.print(&quot;I received&quot;);&#xA;    Serial.println(incomingByte);&#xA;&#xA;     pinMode(10, OUTPUT);&#xA;     digitalWrite(10, HIGH);&#xA;     delayMicroseconds(16000);&#xA;      digitalWrite(10, LOW);&#xA;      delayMicroseconds(2000);&#xA;      digitalWrite(10, HIGH);&#xA; }&#xA;//}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;for(int i=0;i&amp;lt;8;i++)&#xA;{&#xA;  pinMode(pins[i], INPUT);&#xA;}&#xA;pinMode(3,INPUT);&#xA;attachInterrupt(1,timing,RISING);&#xA;&#xA;//Begins Serial&#xA;Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the waveform I'm trying to duplicate:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dkxhW.png&quot; alt=&quot;Desired Waveform&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="514" OwnerDisplayName="cii" LastActivityDate="2014-05-14T10:13:14.683" Title="Replicate a Waveform Exactly with An Arduino Uno" Tags="|c++|c|timing|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1164" PostTypeId="2" ParentId="1162" CreationDate="2014-04-13T22:41:21.080" Score="1" Body="&lt;p&gt;This is &lt;em&gt;very&lt;/em&gt; simple using the &lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/reference/map&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;map()&lt;/code&gt; instruction&lt;/a&gt;.&lt;/strong&gt; Here's the code you would use (feel free to modify values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int speed = 112 + map(distance, 0, 20, 0, 112) - map(distance2, 0, 20, 0, 112);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if both sensors gave equal values, they would offset each other. To make it still work if an object is removed, you could just use the last &lt;code&gt;distance&lt;/code&gt;/&lt;code&gt;distance_2&lt;/code&gt; value and update the other.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One issue with this approach is, if the line of transformation of the object is &lt;em&gt;not&lt;/em&gt; perpendicular to the line of the pings, the value will go:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;10 → 11 → 12 → 13 → 14 → 15 → 16 → 17 → 18 → 19 → 20 → [Out of range]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I've added some pretty animations to show you what I mean:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perpendicular:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jmOp6.gif&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Collinear:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tnk9M.gif&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As I understand, this is what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int motorPin = 9;&#xA;int trigPin = 13;&#xA;int echoPin = 12;&#xA;int trigPin2 = 5;&#xA;int echoPin2 = 4;&#xA;int postdist = 112;&#xA;int postdist2 = 112;&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(trigPin2, OUTPUT);&#xA;  pinMode(echoPin2, INPUT);&#xA;  pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  //First Read&#xA;  int duration, distance;&#xA;  digitalWrite (trigPin, HIGH);&#xA;  delayMicroseconds (1000);&#xA;  digitalWrite (trigPin, LOW);&#xA;  duration = pulseIn (echoPin, HIGH);&#xA;  distance = (duration/2) / 29.1;&#xA;  int ltol = postdist - 5;&#xA;  int htol = postdist + 5;&#xA;  if (distance &amp;gt; 20 || !(distance &amp;gt; ltol &amp;amp;&amp;amp; distance &amp;lt; htol)) {  // Distance from sensor&#xA;    Serial.println(&quot;Out of range&quot;);&#xA;    distance = postdist;&#xA;  }&#xA;  //Second Read&#xA;  int duration2, distance2;&#xA;  digitalWrite (trigPin2, HIGH);&#xA;  delayMicroseconds (1000);&#xA;  digitalWrite (trigPin2, LOW);&#xA;  duration2 = pulseIn (echoPin2, HIGH);&#xA;  distance2 = (duration2/2) / 29.1;&#xA;  int ltol2 = postdist2 - 5;&#xA;  int htol2 = postdist2 + 5;&#xA;  if (distance2 &amp;gt; 20 || !(distance2 &amp;gt; ltol2 &amp;amp;&amp;amp; distance2 &amp;lt; htol2)) {  // Distance from sensor&#xA;    Serial.println(&quot;Out of range&quot;);&#xA;    distance2 = postdist2;&#xA;  }&#xA;  //Math:&#xA;  Serial.print(&quot;Distances-1: &quot;);&#xA;  Serial.print(distance);&#xA;  Serial.print(&quot; cm 2: &quot;);&#xA;  Serial.print(&quot;Distances-1: &quot;);&#xA;  Serial.print(distance2);&#xA;  Serial.println(&quot; cm&quot;);&#xA;  postdist = distance;&#xA;  postdist2 = distance2;&#xA;  int speed = 112 + map(distance, 0, 20, 0, 112) - map(distance2, 0, 20, 0, 112); &#xA;  if(speed &amp;lt; 60) {speed = 60;} //Modify 60 to meet your needs for minimum threshold&#xA;  analogWrite (motorPin, speed);&#xA;  Serial.print(&quot;Motor Speed: &quot;);&#xA;  Serial.println(speed);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Changelog:&lt;/strong&gt; forgot to edit &lt;code&gt;postdist&lt;/code&gt;/&lt;code&gt;postdist2&lt;/code&gt; at end of cycle, added minimum threshold, prevent very small changes in voltage to keep voltage stable and prevent noise.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-04-19T15:03:27.270" LastActivityDate="2014-04-19T15:03:27.270" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1165" PostTypeId="2" ParentId="1163" CreationDate="2014-04-14T09:06:20.167" Score="1" Body="&lt;p&gt;If you're looking to speed your code up I would recommend not using &lt;code&gt;digitalWrite&lt;/code&gt; or &lt;code&gt;Serial&lt;/code&gt;. When using digitalWrite it can take quite a few unneeded clock cycles to turn the pin on or off, as a replacement I would suggest looking into using &lt;a href=&quot;http://arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;port manipulation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of turning a pin on or off with a preprocessor macro using port manipulation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DIGITAL_WRITE_10_HIGH() PORTB = PORTB | B00000100     // Town ON only pin 10&#xA;#define DIGITAL_WRITE_10_LOW() PORTB = PORTB &amp;amp; ~B00000100     // Turn OFF only pin 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using port manipulation in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DIGITAL_WRITE_10_HIGH() PORTB = PORTB | B00000100     // Town ON only pin 10&#xA;#define DIGITAL_WRITE_10_LOW() PORTB = PORTB &amp;amp; ~B00000100     // Turn OFF only pin 10&#xA;&#xA;void timing()&#xA;{&#xA;    //incomingByte = Serial.read(); // If needed uncomment, but it's slow&#xA;    //Serial.println(incomingByte); // If needed uncomment, but it's slow&#xA;&#xA;     // Set pinMode in setup()    &#xA;     DIGITAL_WRITE_10_HIGH();&#xA;     delayMicroseconds(16000);&#xA;     DIGITAL_WRITE_10_LOW();&#xA;     delayMicroseconds(2000);&#xA;     DIGITAL_WRITE_10_HIGH();&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="62" LastActivityDate="2014-04-14T09:06:20.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1166" PostTypeId="2" ParentId="1163" CreationDate="2014-04-14T09:08:21.907" Score="0" Body="&lt;p&gt;This code is wrong in many ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first of all, &lt;code&gt;timing()&lt;/code&gt; is execute inside an interrupt, this mean that while it is running, all other interrupt and timer stop (delayMicroseconds works because it does not rely on timer, but on know instruction execution time). That mean you have to keep the interrupt funzion faster as possible, or bad things may and will happen. (microseconds still work because it is based on know instruction duration in loop)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Serial is interrupt driven; this may cause a race condition that will freeze the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as i can understand pin 3 may be a button (in that case you need to apply some antibounce code, just look at the signal create by pressing a button with your oscilloscope to see what happen), so you can just make a digitalRead every loop, if true do your code. So you will keep &lt;code&gt;timing()&lt;/code&gt; out of interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pinMode()&lt;/code&gt; only needs to be set once, in &lt;code&gt;setup()&lt;/code&gt;. Also, &lt;code&gt;digitalRead()&lt;/code&gt; is really slow: operating directly on the register is a lot faster! see &lt;a href=&quot;http://arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;port manipulation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but in your case i would delete all precendent code and do some math to use an ad-hoc PWM, so you will be almost code free and because it will be almost all done by hardware, precision and possible granularity will increase, see &lt;a href=&quot;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow&quot;&gt;secret of arduino PWM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="42" LastEditDate="2014-04-14T09:25:06.237" LastActivityDate="2014-04-14T09:25:06.237" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1167" PostTypeId="1" CreationDate="2014-04-14T09:56:23.033" Score="3" ViewCount="30261" Body="&lt;p&gt;I'm currently trying to build an Arduino robot controlled via a wifi connection. I have an Arduino Mega running as a client and it successfully connects to the server on LAN via the Adafruit cc3000 wifi board. However instead of grabbing the contents of the JSON file and printing it to serial, I'm just getting a 100 continue response. While this means I'm doing something right, I don't know what to do next in order to grab the data I need. Do I need to get the 100 message then respond with the GET request, or is there a way that I can GET the data straight away?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you all in advance. Here is the Arduino code I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ 3  // MUST be an interrupt pin!&#xA;#define ADAFRUIT_CC3000_VBAT 5 // Apparently these can be any two pins&#xA;#define ADAFRUIT_CC3000_CS 10  // But I wouldn't change these...&#xA;// Use hardware SPI for the remaining pins (On a Mega 2560, SCK = 52, MISO = 50, and MOSI = 51)&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);&#xA;&#xA;#define WLAN_SSID &quot;VM540258-2G&quot;&#xA;#define WLAN_PASS &quot;XXXXXXXX&quot;&#xA;#define WLAN_SECURITY WLAN_SEC_WPA2&#xA;&#xA;&#xA;String readString = String(100); //string for fetching data from address&#xA;uint32_t ip = 3232235523; // This translates into the ip address we need&#xA;                          // 323223552X; 192.168.0.X&#xA;&#xA;void setup(){&#xA;  Serial.begin(115200); //Can also work at 9600&#xA;&#xA;  //Initialise CC3000 module&#xA;  Serial.println(F(&quot;\nInitializing CC3000...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;  //Connect to the Wireless Access Point&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP()) { //Obtain IP addeess&#xA;    delay(100);&#xA;  } &#xA;&#xA;  while (! displayConnectionDetails())&#xA;  {&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA;  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);&#xA;&#xA;  if (client.connected()) {&#xA;    client.println(&quot;GET /project-test/state.json HTTP/1.0&quot;); //Make a request for state.json&#xA;    client.println(&quot;&quot;); //Mandatory blank line?&#xA;    if (client.available()){&#xA;      char c = client.read();&#xA;      Serial.print(c);&#xA;      //read char by char HTTP request&#xA;      if (readString.length() &amp;lt; 100) {&#xA;       //store characters to string &#xA;       readString += c;&#xA;      }&#xA;    }&#xA;  }&#xA;  //Once we have obtained the data, disconnect from the server&#xA;  client.close();&#xA;  Serial.println(readString);&#xA;  delay(1000);&#xA;}&#xA;&#xA;bool displayConnectionDetails(void)&#xA;{&#xA;  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;  if(!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv, &amp;amp;dnsserv))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;    return false;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;    Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;    Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;    Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;    Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;    Serial.println();&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The initial JSON file I'm using contains the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;speed_left&quot;:null,&quot;speed_right&quot;:null,&quot;direction_left&quot;:null,&quot;direction_right&quot;:null}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the serial output I get when I run the Sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Initializing CC3000...&#xA;Started AP/SSID scan&#xA;&#xA;Connecting to VM540258-2G...Waiting to connect...Connected!&#xA;Request DHCP&#xA;&#xA;IP Addr: 192.168.0.7&#xA;Netmask: 255.255.255.0&#xA;Gateway: 192.168.0.1&#xA;DHCPsrv: 192.168.0.1&#xA;DNSserv: 192.168.0.1&#xA;&#xA;Connect to 192.168.0.3:80&#xA;100&#xA;&#xA;Connect to 192.168.0.3:80&#xA;100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ad infinitum&lt;/p&gt;&#xA;" OwnerUserId="1039" LastActivityDate="2014-07-16T21:30:41.037" Title="TCP communication between Arduino client and server" Tags="|arduino-mega|tcpip|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1168" PostTypeId="2" ParentId="1146" CreationDate="2014-04-14T10:37:38.250" Score="0" Body="&lt;p&gt;Arduino Yun ships with python pre installed. You can copy python scripts from your pc to the yun with &lt;code&gt;scp&lt;/code&gt; (or WinSCP or &lt;code&gt;putty&lt;/code&gt;, if you're on windows). Once copied, just run it using Process from your sketch. As they are scripts, program name is &lt;code&gt;python&lt;/code&gt; and the path to your script is its first argument (you can do that in a different way, but that would require some linux magic, which I suggest to postpone if you're new to it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other pre installed options include &lt;a href=&quot;http://www.lua.org/&quot; rel=&quot;nofollow&quot;&gt;lua&lt;/a&gt; and bash. Other languages such as ruby, erlang and php are available as optional packages.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-04-14T10:37:38.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1169" PostTypeId="2" ParentId="1160" CreationDate="2014-04-14T12:31:17.287" Score="5" Body="&lt;p&gt;from the IDE's menu you can activate the verbose upload (and compile) mode, that will print all the command executed; Probabibly what you miss is the necessity to open the serial at 1200baud, that will trigger the reboot and consequent bootloader's start ont DUE chip, and bossac need to find the bootloader. see &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoDue#toc4&quot; rel=&quot;nofollow&quot;&gt;autoReset&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: i've now a pc with a physical Serial, so i've tryed to upload in verbose mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 10,380 bytes (1%) of program storage space. Maximum is 524,288 bytes.&#xA;Forcing reset using 1200bps open/close on port /dev/ttyS0&#xA;/home/xxx/arduino-1.5.6-r2/hardware/tools/bossac -i -d --port=ttyS0 -U false -e -w -v -b /tmp/build8035422101690460839.tmp/sketch_apr14a.cpp.bin -R &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as you can see he is resetting the board by opening the serial at 1200, forcing the bootloader to start. You have to do the same on your script befor launching bossac. How this can be done depends on your OS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that the reset is triggered by the 8u2 chip used as USB to serial adapter on the arduino board, so bypassing it by connecting through tx/rx pin (like using your own conversor, like in my example with hardware serial) won't work unless you do a manual reset at the right time&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="643" LastEditDate="2014-11-11T18:44:29.570" LastActivityDate="2014-11-11T18:44:29.570" CommentCount="21" ContentLicense="CC BY-SA 3.0" />
  <row Id="1170" PostTypeId="2" ParentId="1157" CreationDate="2014-04-14T13:05:08.177" Score="1" Body="&lt;p&gt;there are varius calculation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the day, if take a point in every position (under no acceleration), you should end up with a sphere, or matematically speacking, wthe lenght of the vector should be equal to gravity, so &lt;code&gt;sqrt(x*x+y*y+z*z) = G&lt;/code&gt; or, to do less computing &lt;code&gt;x*x+y*y+z*z = G*G&lt;/code&gt; (same apply for magnetometer, but using local magnetic force, or gyroscope, using a know-speed rotation like a LP player)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create that spere you have to take many point, and find a multiplicator (or function) for each axes. That is particualary important when one axes has differnet precision of others, you are &lt;code&gt;linearizing&lt;/code&gt; the axis output, and then &lt;code&gt;normalizig&lt;/code&gt; its value relative to others axes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have corrected the vector lenght to have a spere, you should look at the offset of the sphere; if its &lt;code&gt;center&lt;/code&gt; point is not on the &lt;code&gt;origin&lt;/code&gt; point 0,0,0 then the differece between &lt;code&gt;center&lt;/code&gt; and &lt;code&gt;origin&lt;/code&gt; is the correction you talk about. This is offset correction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also many (well, all) sensor are affected on their temperature; many claim to be &quot;thermocompensated&quot;, that means this difference is less evident due to some some sort of hardware and/or software filtering.&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-14T13:05:08.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1171" PostTypeId="2" ParentId="1167" CreationDate="2014-04-14T13:08:05.297" Score="1" Body="&lt;p&gt;you are missing the &lt;code&gt;HOST&lt;/code&gt; header in the request, so the server tell you to &lt;code&gt;100 CONTINUE&lt;/code&gt; you request.&#xA;Also yes, the final empty row IS mandatory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example, to ask &lt;code&gt;www.example.com/index.html&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET /index.html HTTP/1.1&#xA;Host: www.example.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-14T13:08:05.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1172" PostTypeId="2" ParentId="1157" CreationDate="2014-04-14T13:21:26.257" Score="1" Body="&lt;p&gt;To get rid of the fluctuation, you could always try a moving average. It isn't hard to modify the &lt;code&gt;Smoothing&lt;/code&gt; example (under &lt;code&gt;File-&amp;gt;Examples-&amp;gt;1. Analog-&amp;gt;Smoothing&lt;/code&gt;) to accept accelerometer values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the slight offset in the X &amp;amp; Y values, that is probably because your sensor isn't sitting perfectly flat.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-04-14T13:21:26.257" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1174" PostTypeId="2" ParentId="1167" CreationDate="2014-04-14T21:24:23.377" Score="0" Body="&lt;p&gt;I'm going to guess that it's a problem with your server not expecting an HTTP/1.0 request.  I note the following from RFC 1945 about the response codes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;9.1  Informational 1xx&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This class of status code indicates a provisional response,&#xA;    consisting only of the Status-Line and optional headers, and is&#xA;    terminated by an empty line. HTTP/1.0 does not define any 1xx status&#xA;    codes and they are not a valid response to a HTTP/1.0 request.&#xA;    However, they may be useful for experimental applications which are&#xA;    outside the scope of this specification.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'd recommend changing your request to be HTTP/1.1 compliant (with a Host: header as suggested by @lesto)&lt;/p&gt;&#xA;" OwnerUserId="150" LastActivityDate="2014-04-14T21:24:23.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1175" PostTypeId="2" ParentId="1167" CreationDate="2014-04-14T21:28:08.817" Score="0" Body="&lt;p&gt;Okay, I have a better answer, again done without testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I look at the BNF for an HTTP-message from the RFC, it indicates that the message body is terminated by a blank line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you actually need 2 CRLFs (i.e. 2 blank lines).  The first one separates the headers from the body of the HTTP request.  You don't actually have a message body (which is fine, it is optional).  But, you'll need another CRLF to terminate the (blank) body.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you only sent one blank line, the server is sending you the continue status codes, prompting you to finish sending your message (i.e. the message body).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, try adding another client.println(&quot;&quot;); &lt;/p&gt;&#xA;" OwnerUserId="150" LastActivityDate="2014-04-14T21:28:08.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1176" PostTypeId="1" CreationDate="2014-04-15T05:02:06.587" Score="4" ViewCount="1118" Body="&lt;p&gt;I want to make a simple circuit which returns the time/delay between two, consecutive loud sounds (i.e, a mic reading of ~600) coming from a speaker. I have set up and ADMP 401 microphone for this purpose. How do I measure the time it takes for this application?&lt;/p&gt;&#xA;" OwnerUserId="1051" LastActivityDate="2014-04-25T23:31:38.560" Title="How do I use the timers on an Arduino Uno R3?" Tags="|arduino-uno|timers|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="1177" PostTypeId="1" CreationDate="2014-04-15T02:10:34.543" Score="6" ViewCount="10439" Body="&lt;p&gt;As I don't want to stack the shield over the mega 2560 board, I try to connect only the pins that used for GSM communication. Here are my connection:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 3 on Mega &amp;lt;==&gt; Pin GSM Rx on Shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 10 on Mega &amp;lt;==&gt; Pin GSM Tx on Shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 4 on Mega &amp;lt;==&gt; Pin 4 on Shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 5V on Mega &amp;lt;==&gt; Pin Vin on Shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin GRD on Mega &amp;lt;==&gt; Pin GRD on Shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code I used is from the Examples library, GsmScanNetworks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;// PIN Number&#xA;#define PINNUMBER &quot;8888&quot;&#xA;&#xA;// initialize the library instance&#xA;GSM gsmAccess;     // include a 'true' parameter to enable debugging&#xA;GSMScanner scannerNetworks;&#xA;GSMModem modemTest;&#xA;&#xA;// Save data variables&#xA;String IMEI = &quot;&quot;;&#xA;&#xA;// serial monitor result messages&#xA;String errortext = &quot;ERROR&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;  // initialize serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;GSM networks scanner&quot;);&#xA;  scannerNetworks.begin();&#xA;&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;&#xA;  // Start GSM shield&#xA;  // If your SIM has PIN, pass it as a parameter of begin() in quotes&#xA;  while(notConnected)&#xA;  {&#xA;    if(gsmAccess.begin(PINNUMBER)==GSM_READY)&#xA;      notConnected = false;&#xA;    else&#xA;    {&#xA;      Serial.println(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;&#xA;  // get modem parameters&#xA;  // IMEI, modem unique identifier&#xA;  Serial.print(&quot;Modem IMEI: &quot;);&#xA;  IMEI = modemTest.getIMEI();&#xA;  IMEI.replace(&quot;\n&quot;,&quot;&quot;);&#xA;  if(IMEI != NULL)&#xA;    Serial.println(IMEI);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // scan for existing networks, displays a list of networks&#xA;  Serial.println(&quot;Scanning available networks. May take some seconds.&quot;);&#xA;  Serial.println(scannerNetworks.readNetworks());&#xA;&#xA;    // currently connected carrier&#xA;  Serial.print(&quot;Current carrier: &quot;);&#xA;  Serial.println(scannerNetworks.getCurrentCarrier());&#xA;&#xA;  // returns strength and ber&#xA;  // signal strength in 0-31 scale. 31 means power &amp;gt; 51dBm&#xA;  // BER is the Bit Error Rate. 0-7 scale. 99=not detectable&#xA;  Serial.print(&quot;Signal Strength: &quot;);&#xA;  Serial.print(scannerNetworks.getSignalStrength());&#xA;  Serial.println(&quot; [0-31]&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;After opening the serial port, only a line &quot;GSM network scanner&quot; is read. Seems that the program is stuck on&lt;code&gt;gsmAccess.begin(PINNUMBER)&lt;/code&gt;, how shall I fix that?&lt;/li&gt;&#xA;&lt;li&gt;Is it a must that I shall supply 5V 2A power to the shield seperately in order for the shield to work? (with connection mentioned above, the ON led light on the shield does turns on with an orange light)&lt;/li&gt;&#xA;&lt;li&gt;For the PINNUMBER defined in the program, my SIM has default PIN 8888. I checked with a mobile phone that the SIM card does work. But my phone shows that the SIM card is not locked with PIN. So shall I define the PIN as 8888 for ''?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoGSMShield&quot; rel=&quot;noreferrer&quot;&gt;GSM shield link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/GSMShieldLeonardoMega&quot; rel=&quot;noreferrer&quot;&gt;Note for using GSM shield with Mega&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;*&lt;/em&gt; And yes! The shield did work when stacked! (Orginally I don't want to bend pin 2...but...unnh...stacking and bending out pin 2 did work)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;*&lt;/em&gt; Tried the examples &quot;GSMScanNetwork&quot; and &quot;SendSMS&quot;, works fine. But for &quot;GsmWebServer&quot;, an IP address is shown, but when I enter the IP address on my browser, chrome/ie says they cannot find the IP address.....Any clues?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;*&lt;/em&gt; And does the status LED on the GSM board have anything to do with power? It goes on and off and on and off.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;*&lt;/em&gt; For question 1 &amp;amp; 3, PINNUMBER is set to ''. Worked fine.&lt;/p&gt;&#xA;" OwnerUserId="1049" OwnerDisplayName="user1702061" LastEditorUserId="1049" LastEditDate="2014-04-15T07:46:44.677" LastActivityDate="2018-05-09T12:48:54.973" Title="Connection problem with Arduino Mega 2560 and GSM shield ( official M10)" Tags="|arduino-mega|gsm|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1178" PostTypeId="1" CreationDate="2014-04-15T06:28:43.203" Score="3" ViewCount="787" Body="&lt;p&gt;This is first time programming with Ethernet shield . I want to test the web server application with my Arduino. I have an Arduino Uno, Ethernet shield, and a potentiometer. Below code being uploaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Currently I am using LAN connection to configure. How to configure it? Is internet required for below application?&lt;/li&gt;&#xA;&lt;li&gt;How do I check the output?&lt;/li&gt;&#xA;&lt;li&gt;Is there any software where i can make customized tags?&lt;/li&gt;&#xA;&lt;li&gt;I have values coming from the serial port to be monitored on webserver. Can someone share how to monitor it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/De3WX.jpg&quot; alt=&quot;Manually configured for windows 7&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HDDWk.jpg&quot; alt=&quot;After config&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yDM0O.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ethernet shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;// The IP address will be dependent on your local network:&#xA;byte mac[] = { &#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;IPAddress ip(192,168,1,177);&#xA;&#xA;// Initialize the Ethernet server library&#xA;// with the IP address and port you want to use &#xA;// (port 80 is default for HTTP):&#xA;EthernetServer server(80);&#xA;&#xA;void setup() {&#xA; // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;   while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // listen for incoming clients&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    Serial.println(&quot;new client&quot;);&#xA;    // an http request ends with a blank line&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        Serial.write(c);&#xA;        // if you've gotten to the end of the line (received a newline&#xA;        // character) and the line is blank, the http request has ended,&#xA;        // so you can send a reply&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          // send a standard http response header&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println(&quot;Connection: close&quot;);  // the connection will be closed after completion of the response&#xA;      client.println(&quot;Refresh: 5&quot;);  // refresh the page automatically every 5 sec&#xA;          client.println();&#xA;          client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;          // output the value of each analog input pin&#xA;          for (int analogChannel = 0; analogChannel &amp;lt; 6; analogChannel++) {&#xA;            int sensorReading = analogRead(analogChannel);&#xA;            client.print(&quot;analog input &quot;);&#xA;            client.print(analogChannel);&#xA;            client.print(&quot; is &quot;);&#xA;            client.print(sensorReading);&#xA;            client.println(&quot;&amp;lt;br /&amp;gt;&quot;);       &#xA;          }&#xA;          client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;          break;&#xA;        }&#xA;        if (c == '\n') {&#xA;          // you're starting a new line&#xA;          currentLineIsBlank = true;&#xA;        } &#xA;        else if (c != '\r') {&#xA;          // you've gotten a character on the current line&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    // give the web browser time to receive the data&#xA;    delay(1);&#xA;    // close the connection:&#xA;    client.stop();&#xA;    Serial.println(&quot;client disconnected&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="31105" LastEditDate="2017-05-03T20:19:01.587" LastActivityDate="2017-05-03T20:19:01.587" Title="Ethernet shield programming" Tags="|arduino-uno|ethernet|networking|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1179" PostTypeId="2" ParentId="1178" CreationDate="2014-04-15T08:03:21.857" Score="3" Body="&lt;p&gt;You need to determine what the network address is of the LAN you have connected the arduino to. A router can often give you this information. Alternatively you can connect a computer to the same network and look at the computers network settings (this varies depending on what OS you use). Then you have determine what IP address is available on that network. You will enter this in the ip variable in your example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The internet is not required for your application, however you do need the arduino to be connected to a LAN and another device (probably a standard computer) to invoke the arduinos server behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test that it works, you can open an internet browser on the second device and type in the IP address that you have configured for the arduino into the address bar.&lt;/p&gt;&#xA;" OwnerUserId="1053" LastActivityDate="2014-04-15T08:03:21.857" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1180" PostTypeId="1" CreationDate="2014-04-15T09:08:11.743" Score="48" ViewCount="141371" Body="&lt;p&gt;I need to plot serial data from Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I require support for:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Various data formats (e.g. signed, unsigned, 8 bits, 16 bits);&lt;/li&gt;&#xA;&lt;li&gt;Plots several data on the same axes;&lt;/li&gt;&#xA;&lt;li&gt;Exports / Imports file data.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As plotting serial data from Arduino is a common need, my question is:&#xA;What programs/utilities are available for plotting serial data from Arduino that meet the needs above?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the advantages / disadvantages of the method you have suggested?&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="4628" LastEditDate="2017-01-26T03:55:16.213" LastActivityDate="2023-11-02T03:11:18.737" Title="Serial data plotting programs" Tags="|serial|" AnswerCount="21" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1181" PostTypeId="2" ParentId="1180" CreationDate="2014-04-15T09:16:09.757" Score="6" Body="&lt;p&gt;Responding to my own question here.. I use Bridge Control Panel as mentioned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advantages: Lots of Features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disadvantages: Tricky to setup and very poor syntax/error reporting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use:&#xA;You need to write the Arduino Data over the Serial Port one byte at a time. For an int data type that would look as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// RX8 [h=43] @1Key1 @0Key1&#xA;Serial.print(&quot;C&quot;);&#xA;Serial.write(data&amp;gt;&amp;gt;8);&#xA;Serial.write(data&amp;amp;0xff);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Bridge the command to Read Data is:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RX8 [h=43] @1Key1 @0Key1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX8 is the read command&#xA;[h=43] means the next valid byte is &quot;C&quot; in ASCII&#xA;then the High Byte of Key1&#xA;then the Low Byte of Key1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this in Bridge:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wO2vf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BBQqC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-04-15T09:16:09.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1184" PostTypeId="1" CreationDate="2014-04-15T17:37:20.687" Score="2" ViewCount="1322" Body="&lt;p&gt;I am trying to connect a 2 cell 7.4 volt LiPo battery into my motor shield. I am a beginner at robotics so I am not sure if I just connect the battery, via a connector of some sort, into the motor shield itself or do I use some 22 AWG wire and connect it via that way. Sorry if that sounds confusing. &lt;/p&gt;&#xA;" OwnerUserId="1060" LastActivityDate="2014-04-17T14:00:24.670" Title="How to connect a 2 cell LiPo batter to Arduino Motor Shield?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1185" PostTypeId="2" ParentId="1184" CreationDate="2014-04-15T18:27:22.257" Score="2" Body="&lt;p&gt;From the Motor Shield page,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;External (non-USB) power can come either from an AC-to-DC adapter&#xA;  (wall-wart) or battery. The adapter can be connected by plugging a&#xA;  2.1mm center-positive plug into the Arduino's board power jack on which the motor shield is mounted or by &lt;strong&gt;connecting the wires that lead&#xA;  the power supply to the Vin and GND screw terminals, taking care to&#xA;  respect the polarities.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So they provide the screw terminals for a battery, you should be able to insert two wires from your battery/pack into the terminals. If your battery has a connector on it, you'll need to either cut it off or find an adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Be extra careful:&lt;/strong&gt; if you have exposed leads from your battery and they touch, it'll get extremely hot and possibly catch fire.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-04-15T18:27:22.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1186" PostTypeId="1" AcceptedAnswerId="1188" CreationDate="2014-04-15T20:33:26.320" Score="6" ViewCount="7388" Body="&lt;p&gt;I will be using an Arduino as a bridge between a computer high-level Java client and some low-level hardware computing units (e.g. other Arduinos). I need to find a solution to &lt;strong&gt;periodically&lt;/strong&gt; communicate in &lt;strong&gt;both&lt;/strong&gt; ways. It should be possible to send digital, analog inputs to the PC and receive digital, analog outputs from the PC via serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have very specific requirements for my project to work: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Lowest possible latency in both ways. High latency would cause&#xA;instability of controlled systems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Extremely constant, possibly user-defined update period. Varying&#xA;sample rate would cause inaccuracies in the control.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I need a very fast solution possible for update frequency of 100 Hz and higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have tried to send data via Firmata to my java client using time interrupt.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_COMPA_vect) {&#xA;  Firmata.sendAnalog(analog, analogRead(analog));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The messages however don't come at a very constant rate and are sometimes held up for twice the sample period or more which is unnaceptable. For higher frequencies this happens even more often. I suspect some kind of a buffer. Do you have any idea where should I look for bottlenecks? Would it be benefiting to design my own communication protocol and ditch Firmata?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Look at the attached &lt;a href=&quot;https://i.stack.imgur.com/9K9L8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;diagram &lt;/a&gt;. Blue lines are &quot;inputs&quot;, green lines &quot;outputs&quot;. Right now I am trying to design the &quot;Arduino (Bridge)&quot;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/fAmud.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1063" LastEditorUserId="1063" LastEditDate="2014-04-21T08:03:55.637" LastActivityDate="2014-04-21T08:03:55.637" Title="What's the fastest way to periodically communicate via serial?" Tags="|serial|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1187" PostTypeId="2" ParentId="1176" CreationDate="2014-04-15T21:00:22.073" Score="2" Body="&lt;p&gt;Your question is probably not as simple as it may seem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach I would use if I was to address this same problem would consist in:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;converting the analog output of the mike into a digital value (based on a threshold to determine)&lt;/li&gt;&#xA;&lt;li&gt;connect this digital signal to one Arduino pin that can trigger an interrupt when its level changes&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Let's first start with the easy part: Arduino program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we have a digital signal that raises to 1 as soon as a sound of too high amplitude is captured by the mike; it shall stay 1 as long as the sound does not reduce amplitude enough. We will connect this signal to Arduino pin 3; then we can use &lt;code&gt;attachInterrupt()&lt;/code&gt; to have a function called whenever this pon level raises to 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile static bool started = false;&#xA;volatile static unsigned long timing = 0;&#xA;volatile static bool finished = false;&#xA;&#xA;void loud() {&#xA;    if (started) {&#xA;        timing = micros() - timing;&#xA;        started = false;&#xA;        finished = true;&#xA;    } else {&#xA;        timing = micros();&#xA;        started = true;&#xA;        finished = false;&#xA;    }&#xA;}&#xA;&#xA;void setup() {&#xA;    pinMode(3, INPUT);&#xA;    attachInterrupt(1, loud, RAISE);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (finished) {&#xA;        // Do something with timing&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the hardest part: electronics!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A first issue we have to deal with is related to the fact that the raw mike signal will have same wave shape as the sound it captures, this wave has a frequency that can vary between 10Hz (bass) and 20KHz (treble).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, if we convert the mike analog output to a logical value (&lt;code&gt;1&lt;/code&gt; when the analog value is above a threshold we'll call &lt;code&gt;Vt&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt; when it is under &lt;code&gt;Vt&lt;/code&gt;) fast enough, then, if the environmental sound as an amplitude above &lt;code&gt;Vt&lt;/code&gt;, the logical input connected to your Arduino will oscillate at the same frequency as the sound! This would make our efforts pointless as you would measure the period of the sound wave instead of the elapsed time between two distinct sound bursts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that we should probably first &quot;smoothen&quot; the analog sound signal in order to avoid disturbance of its frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence point 1 will have to deal with these 2 aspects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;smoothen analog input value&lt;/li&gt;&#xA;&lt;li&gt;compare smoothened value with &lt;code&gt;Vt&lt;/code&gt; threshold and provide a logical value from this comparison&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Comparison can rather easily be performed by an &lt;a href=&quot;http://en.wikipedia.org/wiki/Operational_amplifier&quot; rel=&quot;nofollow&quot;&gt;op-amp&lt;/a&gt; used as a comparator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the main difficulty you may have with an op-amp is the need for a symetric voltage supply (e.g. +5V/-5V) although it is possible to use a single supply but that raises further limitations (outside the scope of my answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Smoothening the signal is potentially more complex, although it can be done with a simple capacitor, because smoothening the signal generally means weakening it, thus you would lose the initial amplitude of the sound signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can we deal with that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;http://en.wikipedia.org/wiki/Schmitt_trigger&quot; rel=&quot;nofollow&quot;&gt;Schmitt trigger&lt;/a&gt; is probably a good solution for this problem but further experiment will be needed to confirm that.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-04-15T21:00:22.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1188" PostTypeId="2" ParentId="1186" CreationDate="2014-04-15T23:05:37.447" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Lowest possible latency in both ways. High latency would cause instability of controlled systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;the fact that you are using a not-real-time OS introduce a lot of unpredictable latency, the use of a visrtual machine over that os then add a bit more.&#xA;Fast communication can be obtained increasing the baudrate, that will decrease the latency between the sample and the elaboration. &#xA;Also sending RAW data instead of string will be faster (no convertion AND less byte send), and finally decreasing the overhead caused by the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example Firmata by default use a low baudrate AND will add a lot of overhead to send WHAT kind of operation is doing. Writing your own communication protocol is better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: analogRead use 10bit, so you may send a raw int, 2 byte, 16bit, so 6 bit are lost.. or you can &quot;compress&quot; with a bit of bitwise operation 4 read (40 bit) into 5 byte (40bit, no bit loss) instead of 8(int size * 4)!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AnalogRead is a really slow operation by default on arduino (~200us), but can be faster if you set up a lower prescaler (attention, lower prescaler means less ADC precision. at prescaler 16 guaranteed precision is 8bit, if my memory is good)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Extremely constant, possibly user-defined update period. Varying sample rate would cause inaccuracies in the control.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the PC side, if you need micro/nano second precision you need a &lt;code&gt;real time os&lt;/code&gt;, newest linux kernel add a new special schedule but i think is still hard to find documentation. If less precision is ok, just use a timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the arduino side, using a hardware timer is the best way, see &lt;a href=&quot;http://www.leonardomiliani.com/2012/leos-un-semplice-so-per-arduino/?lang=en&quot; rel=&quot;nofollow&quot;&gt;LeOS&lt;/a&gt; for a nice scheduler on arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note HardwareSerial on the arduino side use interrupt to send data, so using it inside an ISR (like you are doing now or with LeOS) is really usafe and deadlock prone.&#xA;Also ISR will &quot;slow down&quot; each others, as they cannnot be executed parallel; and analogRead is a realtivly slow operation..&#xA;I would use timer to set up a flag, and in the loop if i see the flag, start the analogread, Serial.write and finally Serial.flush (to be sure to not fill Serial buffer, causing a lot of trouble on the arduino reprogrammation reset)&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-15T23:05:37.447" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1189" PostTypeId="1" AcceptedAnswerId="1190" CreationDate="2014-04-16T01:50:05.913" Score="1" ViewCount="4715" Body="&lt;p&gt;I have made a simple Arduino program that uses a potentiometer to dim a LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This program also makes a second LED blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I have added a button that controls a third LED; this part of my program does not work: the 3rd LED is always lit as the button always reads HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//sensePin is wired up to the FSR&#xA;int sensePin = 2;&#xA;&#xA;//this is wired up to an LED&#xA;int ledPin = 9;&#xA;&#xA;//Wired up to a button&#xA;int inputPin = 1;&#xA;&#xA;int val = 0;&#xA;&#xA;//I was broed so added the default Blink&#xA;int ledPinX = 13;&#xA;&#xA;//Wired up to a second LED&#xA;int ledPinY = 7;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(inputPin, INPUT);&#xA;  pinMode(ledPinX, OUTPUT);&#xA;  pinMode(ledPinY, OUTPUT);&#xA;  val = digitalRead(inputPin);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (val == HIGH){&#xA;    //This should ask &quot;If your button is pressed, then do the code below&#xA;    digitalWrite(ledPinY, HIGH);&#xA;    //but for some reason the light is always on. I've tried it with more than one button&#xA;  }&#xA;  else if(val == LOW){&#xA;    digitalWrite(ledPinY, LOW);&#xA;  }&#xA;  int value;&#xA;&#xA;  /*&#xA; The rest of this stuff works. Well, it did before adding in the button. Now the FSR acts as a digital input. Please help.&#xA;   */&#xA;  value = analogRead(sensePin) / 4;&#xA;  analogWrite(ledPin, value);&#xA;  digitalWrite(ledPinX, HIGH);&#xA;  delay(500);&#xA;  digitalWrite(ledPinX, LOW);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong in this code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:: diagram and pic at: instagram.com/p/m3AmHWmp4e&lt;/p&gt;&#xA;" OwnerUserId="1065" LastEditorUserId="1065" LastEditDate="2014-04-16T17:42:19.693" LastActivityDate="2014-04-19T18:50:23.963" Title="Why does my wired button always read HIGH?" Tags="|button|led|debugging|potentiometer|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1190" PostTypeId="2" ParentId="1189" CreationDate="2014-04-16T05:06:36.150" Score="2" Body="&lt;p&gt;You read the button once, in &lt;code&gt;setup()&lt;/code&gt;. The function is not called every time the variable's value is read, only when the line is executed and the variable assigned to. Move the &lt;code&gt;digitalRead()&lt;/code&gt; call and assignment into &lt;code&gt;loop()&lt;/code&gt;, before you check the variable's value.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-16T05:06:36.150" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1191" PostTypeId="2" ParentId="1189" CreationDate="2014-04-16T05:10:12.517" Score="1" Body="&lt;p&gt;The main problem with your code is that you read the button state &lt;strong&gt;only once&lt;/strong&gt; at the beginning of your program in &lt;code&gt;setup()&lt;/code&gt;, so it keeps the initial value forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should modify &lt;code&gt;loop()&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  digitalWrite(ledPinY, digitalRead(inputPin));&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also remove the &lt;code&gt;val&lt;/code&gt; variable, it is totally useless here; then you must also simplify &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(inputPin, INPUT);&#xA;  pinMode(ledPinX, OUTPUT);&#xA;  pinMode(ledPinY, OUTPUT);&#xA;  // val = digitalRead(inputPin);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-04-16T05:10:12.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1192" PostTypeId="2" ParentId="1132" CreationDate="2014-04-16T09:24:20.727" Score="2" Body="&lt;p&gt;I assume you're using TinyGPS which I sourced from &lt;a href=&quot;https://github.com/mikalhart/TinyGPS&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mikalhart/TinyGPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recently done a similar thing - just trying to get the gps to work and give me as much data as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I used to do this is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TinyGPS.h&quot;&#xA;&#xA;#define GPS_BAUD 115200&#xA;#define PC_BAUD 115200&#xA;&#xA;TinyGPS gps;&#xA;&#xA;int led1 = 13;&#xA;&#xA;long lat, lon;&#xA;&#xA;unsigned long fix_age, time, date, speed, course;&#xA;&#xA;unsigned long chars;&#xA;unsigned short sentences, failed_checksum;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(led1, OUTPUT);&#xA;  Serial1.begin(GPS_BAUD);&#xA;  Serial.begin(PC_BAUD);&#xA;  Serial1.println(&quot;&quot;);&#xA;  Serial1.println(&quot;Initializing&quot;);&#xA;  Serial1.println(&quot;&quot;);&#xA;  digitalWrite(led1, HIGH);&#xA;  delay(2000);&#xA;  digitalWrite(led1, LOW);&#xA;  delay(500);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  while(Serial1.available()){&#xA;    if(gps.encode(Serial1.read())){&#xA;      digitalWrite(led1, HIGH);&#xA;      gps.get_position(&amp;amp;lat, &amp;amp;lon, &amp;amp;fix_age);&#xA;      gps.get_datetime(&amp;amp;date, &amp;amp;time);&#xA;      Serial1.println(&quot;&quot;);&#xA;      Serial1.println(&quot;Lat: &quot; + String(lat));&#xA;      Serial1.println(&quot;Lon: &quot; + String(lon));&#xA;      delay(3000);&#xA;      gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed_checksum);&#xA;      Serial1.println(&quot;Chars: &quot; + String(chars));&#xA;      Serial1.println(&quot;Sents: &quot; + String(sentences));&#xA;      delay(1000);&#xA;      Serial1.println(&quot;Fails: &quot; + String(failed_checksum));&#xA;      Serial1.println(&quot;&quot;);&#xA;      delay(1000);&#xA;    }&#xA;    Serial1.print(&quot;.&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was using an Arduino Mega 2560, but I think you have the same Serial ports on your Due. I connected the TX pin of my GPS ( can't remember the model but I think it was a 10Hz version of this: &lt;a href=&quot;https://www.sparkfun.com/products/9891&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9891&lt;/a&gt; ) to Serial1's RX and I used a small serial 2 row LCD display to output which was connected to Serial1's TX, hence I was using serial1 for both transmitting and receiving. If you remove the delays from the code above the data is read and then written back as fast as possible and while I never measured how many fixes I was seeing per second I'm fairly sure there were at least 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code you want is probably something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TinyGPS.h&quot;&#xA;&#xA;#define GPS_BAUD 115200&#xA;#define PC_BAUD 115200&#xA;&#xA;TinyGPS gps;&#xA;&#xA;int led1 = 13;&#xA;&#xA;long lat, lon;&#xA;&#xA;unsigned long fix_age, time, date, speed, course;&#xA;&#xA;unsigned long chars;&#xA;unsigned short sentences, failed_checksum;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(led1, OUTPUT);&#xA;  Serial1.begin(GPS_BAUD);&#xA;  Serial.begin(PC_BAUD);&#xA;  Serial1.println(&quot;&quot;);&#xA;  Serial1.println(&quot;Initializing&quot;);&#xA;  Serial1.println(&quot;&quot;);&#xA;  digitalWrite(led1, HIGH);&#xA;  delay(2000);&#xA;  digitalWrite(led1, LOW);&#xA;  delay(500);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  while(Serial1.available()){&#xA;    if(gps.encode(Serial1.read())){&#xA;      digitalWrite(led1, HIGH);&#xA;      gps.get_position(&amp;amp;lat, &amp;amp;lon, &amp;amp;fix_age);&#xA;      gps.get_datetime(&amp;amp;date, &amp;amp;time);&#xA;      Serial.print(&quot;    &quot;);&#xA;      Serial.print(lat);&#xA;      Serial.print(&quot; &quot;);&#xA;      Serial.print(long);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As commented by @connor-wolf above you will probably need to change the baud-rate of your communications up because otherwise you the limit of the amount of information you can send/receive per second is probably too low. The baud rate must also match the baud rate of your GPS device. Some GPS devices have an adjustable baud rate.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A quick google turned up an average NMEA sentence length of 60 bytes and if I recall correctly you may have 2 or 3 sentences to each fix? (I think the extra sentences contain extra info like satellite counts, and stuff). So assume you need 180 bytes per fix and you want at least 5 fixes per second that would be 900 bytes. In baud that is 900x8 = 7200. So assuming my estimations above are accurate or overestimated then you have enough bandwidth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure however if the Micro transmits/receives over serial while running the other instructions in your code - I would assume not to be safe but it's worth some research. Therefore you have to account for the time the micro spends transmitting and interpreting the data as time in the second that it can't spend receiving the data. Therefore I would suggest that doubling or even tripling the data rate would be a good idea. (as you can see from my example I just set it to as high as the GPS would go.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway. I hope all that helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S please forgive if I've used the wrong terminology for fixes/sentences or whatever&lt;/p&gt;&#xA;" OwnerUserId="575" LastActivityDate="2014-04-16T09:24:20.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1193" PostTypeId="1" CreationDate="2014-04-16T15:50:42.617" Score="2" ViewCount="1344" Body="&lt;p&gt;I've succeeded to get an Arduino to work with a pressure sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;when I put pressure on the sensor, after 5 minutes the led lights on.&lt;/li&gt;&#xA;&lt;li&gt;it starts over again if there's no pressure on the sensor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's the program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// FSR is verbonden met analoog 0 &#xA;int fsrAnalogePin = 0; &#xA;// De LED is verbonden met pin 11 (pmw pin) &#xA;int LEDpin = 11; &#xA;// De analoge waarde van de fsr spanningdeler &#xA;int fsrWaarde; &#xA;// De helderheid van de led tussen 0 en 255 &#xA;int LEDhelderheid; &#xA;&#xA;void setup() { &#xA;    // start de serial monitor &#xA;    Serial.begin(9600); &#xA;    pinMode(LEDpin, OUTPUT); &#xA;} &#xA;&#xA;void loop() { &#xA;    fsrWaarde = analogRead(fsrAnalogePin); &#xA;    // print ‘Analoge waarde’ &#xA;    Serial.print(“Analoge waarde = “); &#xA;    // print de fsrwaarde op de monitor &#xA;    Serial.println(fsrWaarde); &#xA;&#xA;    // maak van getallen tussen 0 en 1023 getallen tussen 0 en 255 &#xA;    LEDhelderheid = map(fsrWaarde, 0, 50, 0, 255); &#xA;    analogWrite(LEDpin, LEDhelderheid); &#xA;    delay(100); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've got this for the pressure sensor... now I need to combine it with 5 minutes and the led lights on when it's reached that 5 min of pressure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i managed to do this but it aint enough...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long currentTime;&#xA;unsigned long startTime;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  currentTime = millis();&#xA;  startTime = currentTime;&#xA;}&#xA;&#xA;    void loop() {&#xA;  currentTime = millis();&#xA;  // put your main code here, to run repeatedly: &#xA;  Serial.println(currentTime);&#xA;  delay(1000); &#xA;&#xA;  if(currentTime-startTime &amp;gt; 6000) {&#xA;Serial.println(&quot;1 minuut voorbij&quot;);&#xA;startTime = currentTime;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1072" LastEditorUserId="1072" LastEditDate="2014-04-24T15:45:29.460" LastActivityDate="2014-06-04T15:01:14.100" Title="Arduino time(milli) and pressure sensor" Tags="|arduino-uno|time|millis|timing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1194" PostTypeId="1" AcceptedAnswerId="1480" CreationDate="2014-04-16T16:15:29.203" Score="10" ViewCount="1046" Body="&lt;p&gt;I&amp;#039;m planning to build a device that would read some sensor data and send it via GPRS, eg. once per day. (Not that original, yeah.) But my problem is choosing a GSM/GPRS shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The official shield has a &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoGSMShield#toc10&quot;&gt;&lt;strong&gt;nice interface for doing an HTTP POST/GET&lt;/strong&gt;&lt;/a&gt;. OTOH, the shield seems to be sold out (and would be quite expensive anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seem to be other shields available, but their code examples tend to look &lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0#A_Simple_Source_Code_Examples&quot;&gt;&lt;strong&gt;quite hacky&lt;/strong&gt;&lt;/a&gt;: the device waits for an arbitrary moment and then hopes that the server is done. That&amp;#039;s IMO both inefficient or unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: which GSM/GPRS shield would you recommend, with these features:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&lt;li&gt;a sane library w/ examples, such as the official one&lt;/li&gt;&lt;li&gt;an external antenna&lt;/li&gt;&lt;li&gt;bonus: a competitive price&lt;/li&gt;&lt;li&gt;another bonus: hopefully a &amp;quot;real&amp;quot; shield, so no soldering required and a few pins still easily usable for the sensors.&lt;/li&gt;&lt;/ul&gt;&#xA;" OwnerUserId="943" LastActivityDate="2018-05-09T10:06:21.960" Title="Which shield to use for GPRS?" Tags="|shields|tcpip|gsm|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1195" PostTypeId="2" ParentId="1194" CreationDate="2014-04-16T16:37:59.233" Score="3" Body="&lt;p&gt;That library should work with pretty much anything that has the M10 module on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only have experience with the SIM900 modules. Found the cheapest one on EBay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While interfacing with these things can be a challenge at first, you really just need to read the manual for all the AT commands and execute them. I've written a couple of functions that may help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: you may safely replace all instances of &lt;code&gt;DEBUG_PRINT&lt;/code&gt; and &lt;code&gt;DEBUG_PRINTLN&lt;/code&gt; with &lt;code&gt;Serial.print&lt;/code&gt; and &lt;code&gt;Serial.println&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial SIM900(7, 8);&#xA;&#xA;/*&#xA;    Sends AT commands to SIM900 module.&#xA;&#xA;    Parameter   Description&#xA;    command     String containing the AT command to send to the module&#xA;    timeout     A timeout, in milliseconds, to wait for the response&#xA;&#xA;    Returns a string containing the response. Returns NULL on timeout.&#xA;&#xA;*/&#xA;String SIMCommunication::sendCommand(String command, int timeout) {&#xA;    SIM900.listen();&#xA;    // Clear read buffer before sending new command&#xA;    while(SIM900.available()) { SIM900.read(); }&#xA;&#xA;    SIM900.println(command);&#xA;&#xA;    if (responseTimedOut(timeout)) {&#xA;        DEBUG_PRINT(F(&quot;sendCommand Timed Out: &quot;));DEBUG_PRINTLN(command);&#xA;        return NULL;&#xA;    }&#xA;&#xA;    String response = &quot;&quot;;&#xA;&#xA;    while(SIM900.available()) {&#xA;        response.concat((char)SIM900.read());&#xA;        delayMicroseconds(500);&#xA;    }&#xA;&#xA;    return response;&#xA;}&#xA;&#xA;/*&#xA;    Waits for a response from SIM900 for &amp;lt;ms&amp;gt; milliseconds&#xA;&#xA;    Returns true if timed out without response. False otherwise.&#xA;*/&#xA;bool SIMCommunication::responseTimedOut(int ms) {&#xA;    SIM900.listen();&#xA;&#xA;    int counter = 0;&#xA;    while(!SIM900.available() &amp;amp;&amp;amp; counter &amp;lt; ms) {&#xA;        counter++;&#xA;        delay(1);&#xA;    }&#xA;&#xA;    // Timed out, return null&#xA;    if (counter &amp;gt;= ms) {&#xA;        return true;&#xA;    }&#xA;    counter = 0;&#xA;    return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-04-16T16:37:59.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1196" PostTypeId="2" ParentId="1193" CreationDate="2014-04-16T16:41:27.620" Score="0" Body="&lt;p&gt;The very simplest way - not necessarily the best way - is something like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Keep re-reading the pressure sensor until it senses pressure;&#xA;Read millis(), add 300000 (# of msec in 5 min) to it's value, and store that;&#xA;Keep re-read millis() until it returns a number &amp;gt;= to that stored value;&#xA;Read the pressure sensor;&#xA;If it senses pressure,&#xA;  turn on the alarm;&#xA;  do nothing, forever;&#xA;Otherwise, start over again;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It isn't the best way, because the Arduino does nothing else for the 5 minutes until the final sensor check. But as you're learning, you probably don't need it to do anything else - for now. When that time comes, there are better ways than dedicating your processor to watching the clock. But this will get you started, and you may figure out some of those ways on your own, by then. Good luck!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I realized my answer does not account for the possibility that pressure is released from the sensor and reapplied some time later, if both occur within the 5 minute wait. How you treat that situation will depend on the needs of your application (which I'm guessing is for you to learn to work with time and physical data). I'll leave that as a further exercise for you.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-04-16T18:36:47.750" LastActivityDate="2014-04-16T18:36:47.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1197" PostTypeId="1" AcceptedAnswerId="1198" CreationDate="2014-04-16T16:41:54.100" Score="7" ViewCount="3114" Body="&lt;p&gt;I'm trying to program a little bit in Arduino, but I'm stuck with probably something trivial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ang[3], lat[9];&#xA;dtostrf(GPS.angle, 3, 0, ang);&#xA;dtostrf(GPS.latitude, 9,5, lat);&#xA;&#xA;Serial.println(lat);             &#xA;Serial.println(ang);&#xA;Serial.println(&quot;-------&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect the following in the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5111.60160&#xA;267&#xA;-------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But instead, I'm getting this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5111.60160&#xA;2675111.60160&#xA;-------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it looks like the &lt;code&gt;ang&lt;/code&gt; holds both the angle and the latitude....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening? And how can I solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to make one big string, comma separated, from the data stored in &lt;code&gt;GPS&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="756" LastActivityDate="2014-04-16T17:44:33.433" Title="strange behaviour of dtostrf()" Tags="|programming|sketch|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1198" PostTypeId="2" ParentId="1197" CreationDate="2014-04-16T17:44:33.433" Score="4" Body="&lt;p&gt;Your arrays are both too short for the strings they're meant to hold. In particular, ang has three digits and only three bytes. The string-terminator, NUL, ends up in the 1st byte of lat. Since you generated the ang string first, lat over-wrote ang's NUL character, effectively getting appended to ang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lat string will need at least (10+1) bytes; ang will need (3+1) bytes, counting only the actual data in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I make it a habit to declare string arrays just as I wrote the sums above, to make it clear that I've counted both the contents and the NUL byte, so:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;char ang[3+1], lat[10+1];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I doubt that you need to specifically add the NUL terminator; it would quite unusual (counter-conventional) for a C/C++ function that generates a string to leave off the terminator (except in a few special cases).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try increasing just your array sizes first; it'll probably work.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-04-16T17:44:33.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1199" PostTypeId="2" ParentId="1138" CreationDate="2014-04-16T21:30:03.107" Score="0" Body="&lt;p&gt;You need to compare the pins' functions between your Mega and your friend's Uno. Then you need to make those electrical connections happen. I talk about this a little in the &quot;pin locations&quot; section of &lt;a href=&quot;https://arduino.stackexchange.com/questions/462/which-are-the-competitors-of-the-arduino-boards/476#476&quot;&gt;my answer here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This requires &quot;hacking&quot;. Something needs to be done to reroute those physical connections. I normally use an intermediate shield to translate pins as needed. There was a shield specifically made for this purpose but I couldn't find it. &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;path=123_124&amp;amp;product_id=990#.U071vPldX_M&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maybe this one would work&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="79" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-04-16T21:30:03.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1200" PostTypeId="1" CreationDate="2014-04-17T03:59:23.890" Score="1" ViewCount="401" Body="&lt;p&gt;I have a &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Mega board&lt;/a&gt; and a &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;GSM shield&lt;/a&gt;. I'm using Arduino's example &quot;TestWebServer&quot;. The serial monitor shows that the GSM is connected, and returns a IP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the IP is always 10.X.X.X. Isn't that a internal network IP address? How should I get the SIM cards IP? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1049" LastActivityDate="2014-04-19T17:48:39.577" Title="GSM library getIPaddress returns local network address 10.X.X.X" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1202" PostTypeId="1" AcceptedAnswerId="1203" CreationDate="2014-04-17T07:33:16.643" Score="1" ViewCount="452" Body="&lt;p&gt;I have been using only Arduino Uno. Now I am about to buy Mega. But a question rises. Are those 4 Serial Ports of Mega controlled still through one usb cable?&lt;/p&gt;&#xA;" OwnerUserId="1052" LastActivityDate="2014-04-17T07:49:37.900" Title="Arduino Mega's 4 Serial Ports?" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1203" PostTypeId="2" ParentId="1202" CreationDate="2014-04-17T07:49:37.900" Score="1" Body="&lt;p&gt;No. If Arduino ATmega microcontroller supports more than a single UART, then only the first one is available through the standard USB connection. Other UARTs use their own pins that you have to connect to on the board. Mind you these pins are TTL logic serial and need a converter for RS232 or similar. It is possible to use a second (third, ...) TTL-serial to USB cable to access the port on your PC.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-17T07:49:37.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1207" PostTypeId="2" ParentId="1184" CreationDate="2014-04-17T14:00:24.670" Score="1" Body="&lt;p&gt;it is up to you.&#xA;Welded cable is better, but you will probably need a connector, so you should take care to use low-ipendance one that can hadle your current need, like &lt;code&gt;bullet connector&lt;/code&gt; used by RC toys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the battery should have a &lt;code&gt;discarge current&lt;/code&gt; higher that the maximum current used by the engine: normaly this can be calculated by the discarge factor (labeled as 'C' on the hobbyst battery) multiplied by the capacity in Ah o the battery. Pay attention to this as this can damage the battery and alco cause lipo-fire, witch cannot pulled off with just water, you need an extinguer. (this is what happen when you short-circuit the + and -)&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-04-17T14:00:24.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1210" PostTypeId="1" AcceptedAnswerId="1219" CreationDate="2014-04-17T15:12:06.210" Score="5" ViewCount="4050" Body="&lt;p&gt;I am using Arduino Yun and I would like to disable it to work as Access Point. That is, I don't want that it is displayed in the list of available networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I would like to set and use it (separately) in the following scenarios:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Arduino Yun connected just over a given Wi-Fi network (Ethernet connection disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Arduino Yun connected just over Ethernet (Wi-Fi connection disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: In my previous attempts I tried to customize and/or disable someway the Wi-Fi connection (through the LuCI panel) in order to reach what I am looking for but in all of these cases &lt;a href=&quot;http://playground.arduino.cc/Hardware/Yun#restoring_a_yun&quot; rel=&quot;noreferrer&quot;&gt;I had to restore my Arduino Yun&lt;/a&gt; from scratch because it did not work anymore.&lt;/p&gt;&#xA;" OwnerUserId="1015" LastActivityDate="2014-04-18T08:07:18.610" Title="How to disable Arduino Yun to work as Access Point and set it to work as needed?" Tags="|arduino-yun|wifi|networking|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1211" PostTypeId="1" AcceptedAnswerId="1215" CreationDate="2014-04-17T19:55:03.580" Score="4" ViewCount="2642" Body="&lt;p&gt;I'm looking to find a suitable board for a robot I'm developing (it'll involve computer vision, else I'd be using my Arduino Micro) and I've come across two possibilities: &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=product_info&amp;amp;products_id=522&quot; rel=&quot;nofollow&quot;&gt;The Intel Galileo&lt;/a&gt; and the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardTre&quot; rel=&quot;nofollow&quot;&gt;Arduino Tre&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as I understand it, the Intel Galileo has a 400MHz Quark processor, whilst the Arduino Tre has 2 processors, an onboard 16MHz standard ATmega32u4 with the Arduino bootloader and then another 1GHz TI processor with Linux installed on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm not sure of the differences between both products, as price estimates appear to place them at approximately the same price (around $70) and the Intel Galileo doesn't appear to have any real advantage over the Arduino Tre (except for a full x86 instruction set).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any information on comparison of the two boards so I can make a better informed decision?&lt;/p&gt;&#xA;" OwnerUserId="632" LastEditorUserId="220" LastEditDate="2014-04-17T21:30:50.243" LastActivityDate="2014-05-19T18:20:01.017" Title="What are the main differences between the Arduino Tre and the Intel Galileo?" Tags="|robotics|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1212" PostTypeId="1" AcceptedAnswerId="1213" CreationDate="2014-04-17T20:33:47.877" Score="6" ViewCount="1527" Body="&lt;p&gt;I have built my own ATTiny programmer, but made a bit of a mistake along the way - I didn't align the headers properly, and now instead of them plugging into pins 10, 11, 12 and 13 as per the ArduinoISP example - they now plug into pins 8, 9, 10 and 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use some jumper cables to wire the pins to match the ArduinoISP example, it all works fine, meaning the wiring on the actual board is OK, however, I want to be able to just plug my board I have made straight in, and thus need to get the bootloader burning and the uploading to work via pins 8, 9, 10 and 11 instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried modifying the example myself by replacing the references to RESET, MOSI, MISO and SCK with my own pin numbers, but this doesn't seem to suffice. When I try to burn the bootloader now, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I try to upload a sketch using my version which has the custom pin numbers, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The wiring of my programmer is the same as can be found here: &lt;a href=&quot;http://highlowtech.org/?p=1706&quot; rel=&quot;noreferrer&quot;&gt;http://highlowtech.org/?p=1706&lt;/a&gt; except I want the programmer sketch to work with different pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerDisplayName="user1092" LastActivityDate="2014-04-17T23:28:18.500" Title="Changing pins used in ArduinoISP example" Tags="|bootloader|isp|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1213" PostTypeId="2" ParentId="1212" CreationDate="2014-04-17T20:48:53.133" Score="7" Body="&lt;p&gt;You can't change the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ArduinoISP uses the SPI interface on pins 10-13 which is provided by the underlying AVR hardware.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-04-17T20:48:53.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1214" PostTypeId="2" ParentId="1212" CreationDate="2014-04-17T23:28:18.500" Score="3" Body="&lt;p&gt;As a practical matter, you're much better off correcting things so you're using the original pins, which correspond to hardware SPI. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it's not terribly hard to implement SPI in software (at a lower performance, of course):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static uint8_t &#xA;SPITransfer(uint8_t out)&#xA;{&#xA;    uint8_t in = 0;&#xA;    for (int i=0; i&amp;lt;8; ++i) {&#xA;        digitalWrite(MOSI, (out &amp;amp; 0x80) != 0);&#xA;        out &amp;lt;&amp;lt;= 1;&#xA;        digitalWrite(SCK, HIGH);&#xA;        in = (in &amp;lt;&amp;lt; 1) | digitalRead(MISO);&#xA;        digitalWrite(SCK, LOW);&#xA;    }&#xA;    return in;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are several SPI modes, but this implements the one used for ISP.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-04-17T23:28:18.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1215" PostTypeId="2" ParentId="1211" CreationDate="2014-04-17T23:49:49.450" Score="4" Body="&lt;h2&gt;Biggest difference IMHO: Tre hasn't been released yet!&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Besides that, there are a few different things that you should compare. Not much is available about the Tre as of now, but I'll update this post when it's released.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;&lt;em&gt;Basic Specs:&lt;/em&gt; [First sub-bullet is TRE, second Galileo; better spec in bold]&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Microcontroller:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Texas Instrument Sitara AM3359AZCZ100 (ARM Cortex-A8) (&lt;strong&gt;1 GHz,&lt;/strong&gt; 32 bit), Atmel ATmega32u4 (16 MHz, Secondary, found on Leonardo)&lt;/li&gt;&#xA;&lt;li&gt;Intel® Quark SoC X1000 (400 MHz, 32 bit)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;RAM:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;512 MB SRAM (2.5 KB ATmega32u4)&lt;/li&gt;&#xA;&lt;li&gt;512 MB SRAM&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Pins&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;14 Digital 5V, 7 of which are PWM, 6 analog 5V (additional 6 multiplexed) (32u4); 12 Digital 3.3V, 4 of those are PWM (Sitara)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;14 5V digital, 6 of those are PWM, 6 analog 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Networking:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ethernet 10/100&lt;/li&gt;&#xA;&lt;li&gt;Ethernet 10/100&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;USB port:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 USB as slave, 4 USB host ports&lt;/li&gt;&#xA;&lt;li&gt;Up to 128 devices as host, 1 USB slave&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Video&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;HDMI (1920x1080), LCD header&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;None that I can find&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Audio&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;HDMI, stereo analog audio input and output&lt;/li&gt;&#xA;&lt;li&gt;None that I can find&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;MicroSD card&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes&lt;/li&gt;&#xA;&lt;li&gt;Yes&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;PCIe Slot&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Yes&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sources (I combined a bunch of data for this): &lt;a href=&quot;https://arduino.cc/en/ArduinoCertified/IntelGalileo&quot; rel=&quot;nofollow noreferrer&quot;&gt;Galileo&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://arduino.cc/en/Main/ArduinoBoardTre&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tre&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; If you need a board before the Tre comes out, which seems to be soon (Spring 2014), Galileo is your only option. Other than that, the Tre seems to be better all around in most aspects, minus the PCIe slot. I can't comment on power, but it seems like the Tre will be able to supply 4x the power per pin than the Galileo. The Galileo is getting older, and it doesn't seem like the Galileo can provide full Linux support like the Tre will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I'd wait for the Tre. The &lt;em&gt;only&lt;/em&gt; thing I can think that the Galileo would be better for would be either a.) lower power usage or b.) the PCIe slot for a WiFi adapter that works decently. The second one could be solved by &lt;a href=&quot;http://www.instructables.com/id/Cheap-and-Easy-Arduino-Wi-Fi-Hack/0&quot; rel=&quot;nofollow noreferrer&quot;&gt;doing a common WiFi router hack&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a lot of processing power without the need of low latency, you should conciser sending data to a computer to process.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Main/ArduinoTre_LandingPage.jpg&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.cc/en/uploads/Main/ArduinoTre_LandingPage.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/ArduinoCertified/IntelGalileo_fabD_Front.jpg&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.cc/en/uploads/ArduinoCertified/IntelGalileo_fabD_Front.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.300" LastActivityDate="2014-04-18T08:42:10.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1216" PostTypeId="1" CreationDate="2014-04-17T23:50:45.257" Score="-2" ViewCount="8191" Body="&lt;p&gt;I'm trying to make my first library for Arduino and want to use a servo object in my library. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="1095" LastEditorUserId="11" LastEditDate="2014-04-18T00:09:24.420" LastActivityDate="2014-04-22T19:07:42.567" Title="How do I initialize a servo object in my own library?" Tags="|library|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1217" PostTypeId="2" ParentId="1216" CreationDate="2014-04-18T00:50:07.537" Score="1" Body="&lt;p&gt;&lt;strong&gt;This is a simple solution.&lt;/strong&gt; All you need to do is declare a &lt;em&gt;global variable&lt;/em&gt; (i.e. make it accessible everywhere in your sketch), and then add some additional code to &quot;share&quot; the servo between the different parts of the code.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Code you need:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Your library:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo servoname;&#xA;void foo() {&#xA;  //Some code here!&#xA;}&#xA;&#xA;void bar() {&#xA;  //More code here!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The methods &lt;code&gt;foo()&lt;/code&gt; and &lt;code&gt;bar()&lt;/code&gt; are irreverent to the code, you just need to declare it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Your library header file (&lt;code&gt;name.h&lt;/code&gt;):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern Servo servoname;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you need to do then is import your new library and use &lt;code&gt;servoname&lt;/code&gt;. You will have to still call &lt;code&gt;servoname.attach([pin]);&lt;/code&gt; before you can use the servo, but then you just need to use the servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1045501/how-do-i-share-variables-between-different-c-files&quot;&gt;Source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-04-18T00:50:07.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1218" PostTypeId="2" ParentId="1180" CreationDate="2014-04-18T01:13:41.930" Score="8" Body="&lt;p&gt;I use &lt;a href=&quot;http://matplotlib.org/&quot;&gt;Matplotlib&lt;/a&gt; for any plotting I need to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not arduino specific in any way, but it is a very excellent &lt;em&gt;Python&lt;/em&gt; plotting toolkit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've built a number of applications that plot data from a variety of microcontrollers in real-time to a graph, but that was really more of a two-step process: 1. Get data from device into computer, 2. plot realtime data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, I think you should break your question into two parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do you get data from an Arduino/Any serial device into a computer easily.&lt;/li&gt;&#xA;&lt;li&gt;What is a good plotting library that is easy to use.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-04-18T01:13:41.930" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1219" PostTypeId="2" ParentId="1210" CreationDate="2014-04-18T08:07:18.610" Score="2" Body="&lt;p&gt;Yun expects wifi to be working and, if it's not, it will reboot itself after 60 seconds and return in access point mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to disable this check, edit file &lt;code&gt;/etc/rc.local&lt;/code&gt; and turn &lt;code&gt;wifi-live-or-reset&lt;/code&gt; into &lt;code&gt;#wifi-live-or-reset&lt;/code&gt; (with a starting &lt;code&gt;#&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once done, use LuCI (the advanced configuration panel) to configure network interfaces.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-04-18T08:07:18.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1220" PostTypeId="2" ParentId="1138" CreationDate="2014-04-18T10:40:37.260" Score="4" Body="&lt;p&gt;A way to proceed is to create a spreadsheet showing the pin positions used by this board, and the Arduino shield signals they plug into. Next to these, you need columns showing the actual signals on the ATMega2560 (for Mega2560) and ATMega328 (for Uno) that these shield pins attach to. You can get this info from the Uno and Mega2560 schematic drawings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a quick look, it seems that the Arduino shield pin names for Uno and Mega are the same: for example, shield pin '0' (digital zero) is in the same location on both boards, and likewise for other pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on the Uno digital-0 attaches to ATMega328 Port D bit 0, while on the Mega2560, it attaches to ATMega2560 Port E bit 0. And things get more obtuse with digital 2..7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when twiddling bits individually using digitalWrite(pin, value), the Arduino library no doubt takes care of translating to the appropriate port/bits that need to be set for the ATMega chip and Arduino board that's in use. However, libraries that use lower-level functions (especially if they need to write entire bytes to ports, as a fast LCD library might) will need to take their own steps to make this translation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... first step is to determine whether there is a separate LCD driver library for Mega2560. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, investigate whether the library you have has initialization code that is supposed to determine what board it's running on (and is your board included?), or requires you to set some flag to tell it what board is in use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that, you &lt;em&gt;could&lt;/em&gt; create a mess of jumpers or some other wiring scheme to jumper the Mega's ATMega2560's signals so that it's wired up like a Uno would be. It's not clear that this is possible, since some of ATMega2560's Port D is not even wired to a header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could look at the source code for the library and see what it's actually doing, and what it would need to do different to operate the ATMega 2560 pins that the shield does connect to.&lt;/p&gt;&#xA;" OwnerUserId="973" LastEditorUserId="973" LastEditDate="2014-04-25T23:11:52.833" LastActivityDate="2014-04-25T23:11:52.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1221" PostTypeId="1" AcceptedAnswerId="1226" CreationDate="2014-04-18T14:14:26.397" Score="4" ViewCount="555" Body="&lt;p&gt;I am planning on making a simple stopwatch with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A display &lt;/li&gt;&#xA;&lt;li&gt;One or two additional buttons to start the stopwatch and stop the stopwatch and&#xA;maybe reset it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem is that it has to be as small as possible.&#xA;With all those different Arduino boards out there, I don't know which one I should buy (mini, micro, nano, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how many pins I need for the LCD since I have read that in fact not all pins are mandatory for the LCD. I have done something earlier with an LCD and I found the pot meter for the LCD contrast level a bit of waste of space. Could I just replace it with a certain resistor or something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many pins in the end would I need and which board would be fitting for this little project?&lt;/p&gt;&#xA;" OwnerUserId="1100" LastEditorUserId="220" LastEditDate="2014-04-18T21:09:06.740" LastActivityDate="2018-12-28T23:16:09.843" Title="Arduino stopwatch, which board to use?" Tags="|arduino-nano|system-design|arduino-pro-mini|arduino-pro-micro|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1222" PostTypeId="1" AcceptedAnswerId="1224" CreationDate="2014-04-18T17:22:11.233" Score="3" ViewCount="4126" Body="&lt;p&gt;I'm using an arduino UNO, and i want to turn a motor a set number of revolutions, i'm trying to read the clicks of the encoder which has a resolution of 360 clicks/ revolution, my logic is that i count the number of clicks until i get to the desired number which represents the the number of revolutions * the resolution of the encoder:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 revolution ==&gt; 360 clicks&lt;br&gt;&#xA;5 revolutions ==&gt; 360*5 (desired number)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i'm a beginner with arduino so here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int counter=0;&#xA;int motor=5;  // motor is connected to pin 5&#xA;&#xA;void setup(){&#xA;  pinMode(motor,OUTPUT);&#xA;  attachInterrupt(0, count,RISING); // attaching encoder on interrupt 0&#xA;}&#xA;&#xA;void loop(){&#xA;  while(counter&amp;lt; 360*5){&#xA;    analogWrite(motor,255);&#xA;  }&#xA;}&#xA;&#xA;void count(){&#xA;  counter++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code is not working at all, how can i fix it?&lt;/p&gt;&#xA;" OwnerUserId="1103" LastEditorUserId="11" LastEditDate="2014-04-18T18:34:56.173" LastActivityDate="2016-08-15T17:39:40.367" Title="Turning a DC motor a set number of Rotations using an encoder" Tags="|arduino-uno|rotary-encoder|" AnswerCount="2" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1224" PostTypeId="2" ParentId="1222" CreationDate="2014-04-18T18:40:27.003" Score="2" Body="&lt;p&gt;You never tell the motor to stop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;   while(counter&amp;lt; 360*5){&#xA;     analogWrite(motor,255);&#xA;   }&#xA;   analogWrite(motor, 0); //add something like this or whatever could stop it&#xA;   //you may want to disable the counter now too&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, even with that change you are likely a long way from having a working, or at least reliable system - see other issues in my comment on the question.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-04-18T18:40:27.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1225" PostTypeId="2" ParentId="1180" CreationDate="2014-04-18T21:15:14.107" Score="10" Body="&lt;p&gt;&lt;a href=&quot;http://www.gnuplot.info/&quot; rel=&quot;noreferrer&quot;&gt;GnuPlot&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advantages: It's very flexible, scriptable, and freely available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disadvantages: A bit complex to learn (but I figured out how to get started in a few minutes, and quite functional in an hour or two), runs in a terminal window (if you consider that a disadvantage). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something I found very useful was to script it to reload my terminal program's logfile periodically so i got a dynamic graph as my experiment progressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/r5x4O.png&quot; alt=&quot;Image of GnuPlot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;br&gt;&#xA;Edit: Here is the GnuPlot script that plots it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/local/bin/gnuplot -rv&#xA;# Note reverse video here ^^^   til I find a way to put it in the script&#xA;&#xA;# gpFanCtl - Plots DiffThermo fan controller data (aloft, alow, Tdiff, fan-state).&#xA;# $Id: gpFanCtl,v 1.8 2014-04-28 09:40:51-04 jrobert Exp jrobert $&#xA;&#xA;set terminal x11 1 noraise&#xA;set xtics 3600&#xA;set mxtics 4&#xA;set xdata time&#xA;&#xA;set ytics 1 nomirror&#xA;set mytics 2&#xA;&#xA;set y2range [0:3]&#xA;set y2tics 1&#xA;set my2tics 4&#xA;&#xA;set grid&#xA;set ylabel 'Temperature, degC'&#xA;set y2label 'Tdiff, degC' textcolor rgb '#00CD63'&#xA;&#xA;cd '/Users/jrobert/Desktop'&#xA;plot &quot;Logfile.txt&quot; using ($0*4):1 title &quot;Aloft&quot; with lines lc rgb &quot;red&quot;,\&#xA;     &quot;Logfile.txt&quot; using ($0*4):2 title &quot;Alow&quot; with lines lc rgb &quot;#3982FF&quot;,\&#xA;     &quot;Logfile.txt&quot; using ($0*4):3 title &quot;Tdiff&quot; with lines lc rgb &quot;#00CD63&quot; axis x1y2,\&#xA;     &quot;Logfile.txt&quot; using ($0*4):4 title &quot;Fan&quot; with lines lc rgb &quot;orange&quot; axis x1y2;&#xA;pause 4&#xA;refresh&#xA;reread&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-09-25T16:20:57.937" LastActivityDate="2014-09-25T16:20:57.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1226" PostTypeId="2" ParentId="1221" CreationDate="2014-04-18T21:37:25.320" Score="1" Body="&lt;p&gt;&lt;strong&gt;By that &lt;a href=&quot;http://arduino.cc/en/uploads/Tutorial/LCD_bb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;photo&lt;/a&gt; you posted, you pretty much answered a decent part of your question.&lt;/strong&gt; You'll need six pins for the LCD, and one or two for the button. That means that you need a &lt;em&gt;total&lt;/em&gt; of 8 pins. That Uno pictured has 20 (analog can act as digital, too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the boards, if you feel comfortable with some extra work, I'd recommend an ATtiny. From what I can find, it seems like you can drive a LCD with a 44 or an 84 (similar, but the 84 is more powerful).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NUYiB.png&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source for image and how to program chip&lt;/a&gt;&lt;/em&gt;. I'm not going to go into the details for this method, as the link has the necessary files...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That's the smallest way to do this*, however, if you want to use a real Arduino board, then I'd recommend the Micro for a few reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, it has the newer ATMEGA32u4 chip, found on the Leonardo. I do &lt;em&gt;not&lt;/em&gt; recommend the Mini because, although it's the smallest of the three, it doesn't feature on board USB. You would have to buy another adapter to program it. If you're already using a breadboard, the extra 2cm (or so) is worth not having to spend &lt;em&gt;more&lt;/em&gt; to buy both of those components. The Nano is the equivalent of the Mini, only with USB. Also, the Nano and the Micro are roughly the same size, one a little bit longer and one a little bit wider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Nano and Micro are roughly the same as far as processing power, so I'd recommend that, if you can get one significantly cheaper, to go with that. It doesn't really matter that much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*If you're building this on a breadboard, it won't be smaller. If you're transferring to a PCB, then you should use an ATtiny.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As far as the pot goes, I'd recommend getting a &lt;em&gt;trimmer&lt;/em&gt; with an equivalent value. Some of them are very small, as I have one that fits on the USB connector part of my thumb drive. They need a screwdriver to adjust, but I would recommend it. I've had issues moving it from a dark room to in the sun and not being able to see it clearly. Spend the two cents and the 2 cm&lt;sup&gt;2&lt;/sup&gt; and have an opportunity to change it if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the battery, I would recommend any rechargeable battery (under ~3.5V) &lt;strong&gt;if and &lt;em&gt;only&lt;/em&gt; if&lt;/strong&gt; you add a proper chip to not waste energy in the conversion. I talked about this in &lt;a href=&quot;https://arduino.stackexchange.com/questions/665/powering-arduino-with-solar-panels/667#667&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="27346" LastEditDate="2018-12-28T23:16:09.843" LastActivityDate="2018-12-28T23:16:09.843" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1228" PostTypeId="1" CreationDate="2014-04-19T08:43:10.460" Score="-1" ViewCount="1034" Body="&lt;p&gt;I have wind speed sensor that can measure max speed upto 30 m/s with analog out put 0-5v. I have simple code calling from the loop. When I put the wind speed average code, the web server is not working and it just hangs. If I comment out web server it's working fine. Let me know What makes my web server hang or not get connected. Is there any way I can change average taking code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Working code should like below:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if wind speed exceed 30 m/s &#xA;   mode =stow&#xA;else &#xA;   mode =track&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My code. And how can write average of windload of day to SDcard&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&quot;wind.h&quot;&#xA;#include&quot;mode.h&quot;&#xA;&#xA;float sampleAverage(void)&#xA;{&#xA;  float accumulator = 0;&#xA;  for (int i = 0; i &amp;lt; SAMPLE_COUNT; i++)&#xA;  {&#xA;    accumulator += sample[i];&#xA;  }&#xA;  return accumulator / SAMPLE_COUNT;&#xA;}&#xA;&#xA;void Wind_calc()&#xA;{&#xA;&#xA;  static unsigned long lastSampleTime = 0;&#xA;  unsigned long currentTime = millis();&#xA;&#xA;  // check if time for new reading&#xA;  if (currentTime - lastSampleTime &amp;gt;= SAMPLE_RATE)&#xA;  {&#xA;    lastSampleTime = currentTime;&#xA;    int sensorValue = analogRead(SENSOR_PIN);&#xA;    float voltage = sensorValue * (5.0 / 1023.0);&#xA;    /* Serial.print(&quot;voltage: &quot;);&#xA;     Serial.println(voltage);*/&#xA;    // add the newest reading at the oldest pointer&#xA;    sample[sampleIndex] = voltage;&#xA;    // advance to next index which is now oldest&#xA;    sampleIndex++;&#xA;    // check for and handle rollover&#xA;    if (sampleIndex == SAMPLE_COUNT)&#xA;    {&#xA;      sampleIndex = 0;&#xA;    }&#xA;    // the sample array now contains the last ten readings&#xA;    // sampleIndex now points to the oldest reading&#xA;    // it will be replaced with the newest next time &#xA;&#xA;    float average = sampleAverage();&#xA;    /*Serial.print(&quot;average:&quot;);&#xA;     Serial.println(average);*/&#xA;    Wind_Speed = (6 * average);&#xA;    Wind_Kmph = 3.6 * Wind_Speed;&#xA;    /*    Serial.print(&quot;Wind_Speed:&quot;);&#xA;     Serial.print(Wind_Speed);&#xA;     Serial.println(&quot;m/s&quot;);&#xA;&#xA;     Serial.print(&quot;Wind_Exceed_count:&quot;);Serial.println(Wind_Exceed_count);Serial.println(&quot;.................&quot;);&#xA;     Serial.print(&quot;Wind_Kmph:&quot;);&#xA;     Serial.print(Wind_Kmph);&#xA;     Serial.println(&quot;KMPH&quot;);&#xA;     */&#xA;    if((Wind_Speed&amp;gt;4.0)&amp;amp;&amp;amp;(Stow_flag==0))&#xA;    {&#xA;      Wind_Exceed_count=Wind_Exceed_count+1;&#xA;&#xA;      //Serial.println(&quot;Wind_Exceed_count&quot;);Serial.print(Wind_Exceed_count);&#xA;      if(Wind_Exceed_count&amp;lt;5)&#xA;      {&#xA;        Stow_flag=0;&#xA;      }&#xA;      else&#xA;      {&#xA;        Stow_flag=1; &#xA;        MODE=STOW;&#xA;      }&#xA;&#xA;    }&#xA;    else&#xA;    {&#xA;      Redo_Wind_calc();&#xA;    }&#xA;&#xA;&#xA;  } &#xA;&#xA;}&#xA;&#xA;&#xA;void Redo_Wind_calc()&#xA;{&#xA;  //  Serial.println(&quot;Wind_Exceed_count&quot;);Serial.print(Wind_Exceed_count);&#xA;  if(Wind_Speed&amp;gt;4.0 &amp;amp;&amp;amp;Stow_flag==1)&#xA;  {&#xA;    Wind_Exceed_count=Wind_Exceed_count+1;&#xA;    if(Wind_Exceed_count&amp;lt;=10)&#xA;    {&#xA;      MODE=STOW;    &#xA;    }&#xA;    else&#xA;    {&#xA;      MODE=TRACK;&#xA;      Wind_Exceed_count=0;&#xA;      Stow_flag=0;&#xA;    }&#xA;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA; Wind_calc();&#xA;webcontrol();&#xA;}&#xA;&#xA;&#xA;void webcontrol()&#xA;{&#xA;&#xA;//Web control function are defined here&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="220" LastEditDate="2014-05-21T21:43:21.650" LastActivityDate="2014-05-21T21:43:21.650" Title="Analog average sample wind speed sensor" Tags="|arduino-uno|web-server|analogwrite|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1229" PostTypeId="2" ParentId="1216" CreationDate="2014-04-19T14:18:30.783" Score="0" Body="&lt;p&gt;If your question is about &lt;strong&gt;including library A inside library B and then including library B in your main program&lt;/strong&gt;, then you need to be aware of a limitation of Arduino IDE (discussed in &lt;a href=&quot;https://arduino.stackexchange.com/questions/322/why-do-i-need-to-include-libraries-used-in-other-libraries/328#328&quot;&gt;this answer&lt;/a&gt; to a similar question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino IDE (at least 1.0.x, I have not checked with 1.5) for an obscure reason will not include libraries included by other libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to work around this issue is to include ALL libraries (direct &lt;strong&gt;and&lt;/strong&gt; indirect) in your main program file (&lt;code&gt;.ino&lt;/code&gt; file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Needed by library &quot;B&quot;&#xA;#include &quot;A.h&quot;&#xA;// Needed by your program&#xA;#include &quot;B.h&quot;&#xA;&#xA;void setup() {&#xA;    // You can use B stuff here&#xA;}&#xA;&#xA;void loop() {&#xA;    // You can use B stuff here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another workaround is to trash Arduino IDE and use a better (I mean a real) IDE: many good options have been discussed in &lt;a href=&quot;https://arduino.stackexchange.com/questions/40/what-are-the-other-ides-for-arduino&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-04-19T14:18:30.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1230" PostTypeId="1" CreationDate="2014-04-19T17:19:18.207" Score="1" ViewCount="2081" Body="&lt;p&gt;I have a complex requirement that uses a number of libraries that depend on timing I.e. OneWire. When using the official GSM shield on a mega, it loads a version of software serial to talk to the GSM. I want to make it use a spare hardware serial port on the MEGA for more timing stability. How should I modify the GSM library to (optionally) auto detect a MEGA and then use a nominated serial port. I am happy to jumper the correct pins from the mega serial hardware port to the bent outwards pins 2 and 3 of the GSM shield ( pin 2 is already bent out if you use a MEGA anyway).&lt;/p&gt;&#xA;" OwnerUserId="1113" LastEditorUserId="1113" LastEditDate="2014-04-19T18:28:45.223" LastActivityDate="2019-12-10T09:01:25.913" Title="Can the official arduino GSM shield library be changed to work with hardware serial on mega" Tags="|serial|arduino-mega|gsm|hardware|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1231" PostTypeId="2" ParentId="1228" CreationDate="2014-04-19T17:34:08.457" Score="3" Body="&lt;p&gt;What arduino board is being used? I find that some webserver code takes up a lot of the SRAM and in an UNO this leaves very little space for other code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save SRAM use the F macro on all the Serial.print statements that have quoted text. i.e:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Some text you want output&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This takes up SRAM when running. 1 byte per letter and space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(F(&quot;Some text you want output&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This takes up no SRAM as it is stored in program space and is makes a big difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search for a &lt;code&gt;freeRam()&lt;/code&gt; and use that in debugging your sketch to see how much free space you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant question: &lt;a href=&quot;https://arduino.stackexchange.com/questions/221/what-can-i-do-if-i-run-out-of-flash-memory-or-sram&quot;&gt;What can I do if I run out of Flash memory or SRAM?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1113" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-04-19T18:52:59.087" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1232" PostTypeId="1" AcceptedAnswerId="3721" CreationDate="2014-04-19T17:37:10.797" Score="2" ViewCount="4307" Body="&lt;p&gt;I have set up Eclipse to compile for the Arduino Due using all the tools shipped with the Arduino IDE 1.5.6-r2. It compiles without errors, but when uploaded, the Arduino does nothing, and isn't recognized on the computer. It then has to be reset manually using the erase and reset buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one static library (ArduinoDueCore) consisting of the Arduino library (&lt;code&gt;core&lt;/code&gt;), and other code (Atmel found in &lt;code&gt;lib&lt;/code&gt;). The other Eclipse project is the TestProject. It contains one file blinking an LED on pin 13. All the files from the Arduino library are there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output from Eclipse compiling the library itself: (excerpt of only one of each type of command)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;18:31:36 **** Build of configuration Release for project ArduinoDueCore ****&#xA;make all&#xA;Building file: ../src/lib/variants/arduino_due_x/variant.cpp&#xA;Invoking: ARM Sourcery Linux GCC C++ Compiler&#xA;arm-none-eabi-g++ -DUSB_PRODUCT=&quot;Arduino Due&quot; -DARDUINO=156 -DUSB_MANUFACTURER=&quot;Unknown&quot; -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE -D__SAM3X8E__ -Dprintf=iprintf -DF_CPU=84000000L -DUSB_VID=0x2341 -DUSB_PID=0x003E -DUSBCON -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/core&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/CMSIS/Include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL/sam3xa/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x&quot; -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns=&quot;src/lib/variants/arduino_due_x/variant.o.lst&quot; -fno-exceptions -fno-rtti -w -c -g -fmessage-length=0 --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF&quot;src/lib/variants/arduino_due_x/variant.d&quot; -MT&quot;src/lib/variants/arduino_due_x/variant.d&quot; -mcpu=cortex-m3 -mthumb -o &quot;src/lib/variants/arduino_due_x/variant.o&quot; &quot;../src/lib/variants/arduino_due_x/variant.cpp&quot;&#xA;Finished building: ../src/lib/variants/arduino_due_x/variant.cpp&#xA;&#xA;Building file: ../src/lib/libsam/source/adc.c&#xA;Invoking: ARM Sourcery Linux GCC C Compiler&#xA;arm-none-eabi-gcc -DARDUINO=156 -DARM_MATH_CM3 -DUSB_MANUFACTURER=&quot;Unknown&quot; -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE -D__SAM3X8E__ -Dprintf=iprintf -DF_CPU=84000000L -DUSB_VID=0x2341 -DUSB_PRODUCT=&quot;Arduino Due&quot; -DUSB_PID=0x003E -DUSBCON -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/core&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/CMSIS/Include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL/sam3xa/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x&quot; -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns=&quot;src/lib/libsam/source/adc.o.lst&quot; -w -c -fmessage-length=0 --param max-inline-insns-single=500 -nostdlib -std=c99 -MMD -MP -MF&quot;src/lib/libsam/source/adc.d&quot; -MT&quot;src/lib/libsam/source/adc.d&quot; -mcpu=cortex-m3 -mthumb -o &quot;src/lib/libsam/source/adc.o&quot; &quot;../src/lib/libsam/source/adc.c&quot;&#xA;Finished building: ../src/lib/libsam/source/adc.c&#xA;&#xA;Building file: ../src/core/USB/HID.cpp&#xA;Invoking: ARM Sourcery Linux GCC C++ Compiler&#xA;arm-none-eabi-g++ -DUSB_PRODUCT=&quot;Arduino Due&quot; -DARDUINO=156 -DUSB_MANUFACTURER=&quot;Unknown&quot; -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE -D__SAM3X8E__ -Dprintf=iprintf -DF_CPU=84000000L -DUSB_VID=0x2341 -DUSB_PID=0x003E -DUSBCON -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/core&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/CMSIS/Include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL/sam3xa/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x&quot; -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns=&quot;src/core/USB/HID.o.lst&quot; -fno-exceptions -fno-rtti -w -c -g -fmessage-length=0 --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF&quot;src/core/USB/HID.d&quot; -MT&quot;src/core/USB/HID.d&quot; -mcpu=cortex-m3 -mthumb -o &quot;src/core/USB/HID.o&quot; &quot;../src/core/USB/HID.cpp&quot;&#xA;Finished building: ../src/core/USB/HID.cpp&#xA;&#xA;Building file: ../src/core/cortex_handlers.c&#xA;Invoking: ARM Sourcery Linux GCC C Compiler&#xA;arm-none-eabi-gcc -DARDUINO=156 -DARM_MATH_CM3 -DUSB_MANUFACTURER=&quot;Unknown&quot; -DARDUINO_ARCH_SAM -DARDUINO_SAM_DUE -D__SAM3X8E__ -Dprintf=iprintf -DF_CPU=84000000L -DUSB_VID=0x2341 -DUSB_PRODUCT=&quot;Arduino Due&quot; -DUSB_PID=0x003E -DUSBCON -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/core&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/CMSIS/Include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL/sam3xa/include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x&quot; -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns=&quot;src/core/cortex_handlers.o.lst&quot; -w -c -fmessage-length=0 --param max-inline-insns-single=500 -nostdlib -std=c99 -MMD -MP -MF&quot;src/core/cortex_handlers.d&quot; -MT&quot;src/core/cortex_handlers.d&quot; -mcpu=cortex-m3 -mthumb -o &quot;src/core/cortex_handlers.o&quot; &quot;../src/core/cortex_handlers.c&quot;&#xA;Finished building: ../src/core/cortex_handlers.c&#xA;&#xA;18:31:39 Build Finished (took 2s.811ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the project itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;18:33:42 **** Build of configuration Release for project TestProject ****&#xA;make all&#xA;Building file: ../src/TestProject.cpp&#xA;Invoking: ARM Sourcery Linux GCC C++ Compiler&#xA;arm-none-eabi-g++ -DARDUINO=156 -DUSB_PRODUCT=&quot;Arduino Due&quot; -DARDUINO_SAM_DUE -D__SAM3X8E__ -DARDUINO_ARCH_SAM -Dprintf=iprintf -DF_CPU=84000000L -DUSB_MANUFACTURER=&quot;Unknown&quot; -DUSB_VID=0x2341 -DUSB_PID=0x003E -DUSBCON -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/core&quot; -I&quot;/home/kim/workspace_juno/TestProject/src&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/libsam&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/CMSIS/Include&quot; -I&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/CMSIS/Device/ATMEL/sam3xa/include&quot; -Os -ffunction-sections -fdata-sections -Wall -fno-exceptions -fno-rtti -c -fmessage-length=0 --param max-inline-insns-single=500 -nostdlib -g -w -MMD -MP -MF&quot;src/TestProject.d&quot; -MT&quot;src/TestProject.d&quot; -mcpu=cortex-m3 -mthumb -o &quot;src/TestProject.o&quot; &quot;../src/TestProject.cpp&quot;&#xA;Finished building: ../src/TestProject.cpp&#xA;&#xA;Building target: TestProject.elf&#xA;Invoking: ARM Sourcery Linux GCC C++ Linker&#xA;arm-none-eabi-g++ -T&quot;/home/kim/workspace_juno/ArduinoDueCore/src/lib/variants/arduino_due_x/linker_scripts/gcc/flash.ld&quot; -L&quot;/home/kim/workspace_juno/ArduinoDueCore/Release&quot; -Wl,-Map,TestProject.map -lm -lgcc  -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--gc-sections -mcpu=cortex-m3 -mthumb -o &quot;TestProject.elf&quot; -Wl,--start-group  ./src/TestProject.o   -lArduinoDueCore -Wl,--end-group&#xA;Finished building target: TestProject.elf&#xA;&#xA;make --no-print-directory post-build&#xA;/home/kim/arduino-1.5.6-r2/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-objcopy -O binary TestProject.elf TestProject.bin&#xA;&#xA;Invoking: ARM Sourcery Linux GNU Create Listing&#xA;arm-none-eabi-objdump -h -S TestProject.elf &amp;gt; &quot;TestProject.lst&quot;&#xA;Finished building: TestProject.lst&#xA;&#xA;Invoking: ARM Sourcery Linux GNU Print Size&#xA;arm-none-eabi-size  --format=berkeley TestProject.elf&#xA;   text    data     bss     dec     hex filename&#xA;  10396      24    1188   11608    2d58 TestProject.elf&#xA;Finished building: TestProject.siz&#xA;&#xA;&#xA;18:33:43 Build Finished (took 308ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the upload command: (removed &lt;code&gt;readWord&lt;/code&gt;, &lt;code&gt;go&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt; and &lt;code&gt;writeWord&lt;/code&gt; lines)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-i -d --port=ttyACM0 -U true -e -w -v -b ${project_loc}/Release/${project_name}.bin -R&#xA;&#xA;Set binary mode&#xA;chipId=0x285e0a60&#xA;Connected at 921600 baud&#xA;Erase flash&#xA;Write 10420 bytes to flash&#xA;&#xA;[                              ] 0% (0/41 pages)&#xA;[=======                       ] 24% (10/41 pages)&#xA;[==============                ] 48% (20/41 pages)&#xA;[=====================         ] 73% (30/41 pages)&#xA;[============================= ] 97% (40/41 pages)&#xA;[==============================] 100% (41/41 pages)&#xA;Verify 10420 bytes of flash&#xA;&#xA;[                              ] 0% (0/41 pages)&#xA;[=======                       ] 24% (10/41 pages)&#xA;[==============                ] 48% (20/41 pages)&#xA;[=====================         ] 73% (30/41 pages)&#xA;[============================= ] 97% (40/41 pages)&#xA;[==============================] 100% (41/41 pages)&#xA;Verify successful&#xA;Set boot flash true&#xA;Device       : ATSAM3X8&#xA;Chip ID      : 285e0a60&#xA;version()=v1.1 Dec 15 2010 19:25:04&#xA;Version      : v1.1 Dec 15 2010 19:25:04&#xA;Address      : 524288&#xA;Pages        : 2048&#xA;Page Size    : 256 bytes&#xA;Total Size   : 512KB&#xA;Planes       : 2&#xA;Lock Regions : 32&#xA;Locked       : none&#xA;Security     : false&#xA;Boot Flash   : true&#xA;CPU reset.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;TestProject.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(13, HIGH);&#xA;    delay(50);&#xA;    digitalWrite(13, LOW);&#xA;    delay(950);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="693" LastEditorUserId="693" LastEditDate="2014-04-20T11:08:05.783" LastActivityDate="2014-08-11T01:13:14.340" Title="How to compile code for the Arduino Due?" Tags="|arduino-due|compile|eclipse|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="1233" PostTypeId="2" ParentId="1200" CreationDate="2014-04-19T17:48:39.577" Score="1" Body="&lt;p&gt;The SIM card does not have an IP address. When the data connection is made to your GSM APN it is assigned an IP in a similar way to DHCP. Often the address is the same after the first connection as the service provider will link that to your SIM for audit purposes. If you setup a private APN then you can arrange to have specific range allocated to your SIM card(s). This is normally only done for security of volume reasons.&lt;/p&gt;&#xA;" OwnerUserId="1113" LastActivityDate="2014-04-19T17:48:39.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1234" PostTypeId="2" ParentId="1189" CreationDate="2014-04-19T17:53:02.027" Score="0" Body="&lt;p&gt;Pin 1 is used for the serial output and can't be used if you enable serial using &lt;code&gt;serial.begin(9600)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change button to pin 2.&lt;/p&gt;&#xA;" OwnerUserId="1113" LastEditorUserId="11" LastEditDate="2014-04-19T18:50:23.963" LastActivityDate="2014-04-19T18:50:23.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1235" PostTypeId="2" ParentId="1186" CreationDate="2014-04-19T18:05:35.040" Score="0" Body="&lt;p&gt;I have had great success removing serial from such an example and setting up a closed network and then Ethernet enabling all the arduino devices. I then have a DCHP and SNTP server in the closed network. The PC etc are all in the closed network. I then setup a MQTT server (see www.mosquitto.org) and use the arduino PubSub library on the arduino. I get extremely short round trips with pretty consistent response times and this has the advantage that multiple sources can publish or subscribe to the data steams created. The SNTP server is used so that all the devices get the same time reference to use and I time stamp all messages and can then work out message sequence etc even if they are physically delayed slightly by an Ethernet collision! although in a closed network this is minimized.&lt;/p&gt;&#xA;" OwnerUserId="1113" LastActivityDate="2014-04-19T18:05:35.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1237" PostTypeId="2" ParentId="1013" CreationDate="2014-04-19T19:08:33.473" Score="45" Body="&lt;p&gt;This function can be used to separate a string into pieces based on what the separating character is.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;String xval = getValue(myString, ':', 0);&#xA;String yval = getValue(myString, ':', 1);&#xA;&#xA;Serial.println(&amp;quot;Y:&amp;quot; + yval);&#xA;Serial.print(&amp;quot;X:&amp;quot; + xval);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Convert String to int&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int xvalue = xval.toInt();&#xA;int yvalue = yval.toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This Chunk of code takes a string and separates it based on a given character and     returns&#xA;The item between the separating character&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;String getValue(String data, char separator, int index)&#xA;{&#xA;    int found = 0;&#xA;    int strIndex[] = { 0, -1 };&#xA;    int maxIndex = data.length() - 1;&#xA;&#xA;    for (int i = 0; i &amp;lt;= maxIndex &amp;amp;&amp;amp; found &amp;lt;= index; i++) {&#xA;        if (data.charAt(i) == separator || i == maxIndex) {&#xA;            found++;&#xA;            strIndex[0] = strIndex[1] + 1;&#xA;            strIndex[1] = (i == maxIndex) ? i+1 : i;&#xA;        }&#xA;    }&#xA;    return found &amp;gt; index ? data.substring(strIndex[0], strIndex[1]) : &amp;quot;&amp;quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1115" LastEditorUserId="95596" LastEditDate="2024-02-06T01:08:15.473" LastActivityDate="2024-02-06T01:08:15.473" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1238" PostTypeId="2" ParentId="1186" CreationDate="2014-04-20T08:45:02.320" Score="1" Body="&lt;p&gt;could you be more specific with your question ?&#xA;From what I understood:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you have a client java program acting as the &amp;quot;brain&amp;quot; of your system&lt;/li&gt;&#xA;&lt;li&gt;your control is time sensitive. You have a PID or other regulation loop running on the pc&lt;/li&gt;&#xA;&lt;li&gt;you have or plan to have multiple arguing boards on your system and you need to communicate with them.&lt;/li&gt;&#xA;&lt;li&gt;you are dealing with analog IOs&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;bridging&lt;/h2&gt;&#xA;&lt;p&gt;If you want to stick to serial port,you have to use RS485 or RS422. Those can work as a bus. Protocol on top of that can be Modbus.&#xA;Note that this has a higher latency and you need at least 2 serial ports on your bridge&lt;/p&gt;&#xA;&lt;p&gt;I2C. Lower latency 2 wires bus. Command oriented,runs at 400 kHz. So you have plenty of time to send/receive data&lt;/p&gt;&#xA;&lt;p&gt;SPI even lower latency as bytes are sent as stream .arduino mega has 5 pins for it. Note that you have to deal with the addressing yourself in this case.&lt;/p&gt;&#xA;&lt;p&gt;Arduino like many micro controllers is bad as doing many tasks at the same time like for the bridging case. I would avoid using an arduino in this case&lt;/p&gt;&#xA;&lt;h2&gt;latency&lt;/h2&gt;&#xA;&lt;p&gt;As already answered, ADC conversion takes time and you cannot nest interrupt.&#xA;Your minimum latency can be computed from the specifications of the arduino.&#xA;The maximum latency is a value you fix yourself.&#xA;Knowing the amount of time to send one byte on the communication port,&#xA;You can decide between options like&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;run the AD conversion in a loop outside interrupt, put the value inside a variable and do the communication a synchronously inside an interrupt&lt;/li&gt;&#xA;&lt;li&gt;run the AD conversion interrupt based and the communication in the main loop of operation&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;conclusions&lt;/h2&gt;&#xA;&lt;p&gt;Don't do hardware in the loop using a PC. The latency and lack of strict timing possibilities worsened by the use of java make it a dead end with your current setup.&lt;/p&gt;&#xA;&lt;p&gt;Use a stronger micro controller like an AVR32 with USB running the brain of your system.&#xA;You can also use a raspberries pi or a beaglebone. Those runs &amp;quot;standard&amp;quot; Linux distributions and so you can use a PC like approach.&lt;/p&gt;&#xA;&lt;p&gt;In any case guidelines are :&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;try to stay as close to the micro controller as possible and avoid abstraction libraries and OSes&lt;/li&gt;&#xA;&lt;li&gt;don't use a pc for hardware in the loop&lt;/li&gt;&#xA;&lt;li&gt;try to make your task run a synchronously as much as possible&lt;/li&gt;&#xA;&lt;li&gt;keep your interrupt routines as small as possible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1117" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-04-20T08:45:02.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1239" PostTypeId="1" CreationDate="2014-04-21T00:32:52.443" Score="6" ViewCount="3444" Body="&lt;p&gt;I want to add CO2 measuring feature to my room weather station. Can someone please recommend a CO2 sensor easy to integrate with Arduino?&lt;/p&gt;&#xA;" OwnerUserId="1109" LastEditorUserId="220" LastEditDate="2014-04-21T01:58:15.213" LastActivityDate="2020-09-15T11:46:14.817" Title="CO2 sensor for arduino" Tags="|sensors|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1240" PostTypeId="1" CreationDate="2014-04-21T09:22:12.893" Score="2" ViewCount="1174" Body="&lt;p&gt;I am building an early prototype, proof of concept, network monitoring tool.  A big part of it uses localization of a Smartphone.  It seems that the best way to do this is using RSSI from multiple points.  I plan to do this using several Arduino Fios with Xbee WiFi (S6B) cards.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current setup has a network running from my smartphone (it is running DHCP) with a laptop monitoring all the traffic on the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I need is for my Fio Xbees to dump the RSSI of the &quot;access point&quot; (Smartphone) onto the network so my laptop can pull the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, to/from is not important as far as the packet is concerned, I just need the data dropped on the &quot;wire&quot; for my laptop to later parse, which is good because Serial.print* sends out a broadcast to 255.255.255.255:fffff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can make my devices broadcast any integer, but when I go into AT mode nothing aside from the initial DHCP handshake gets put on the wire.  Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() { &#xA;  Serial.begin(9600); &#xA;  Serial.flush();&#xA;  delay(1000);//enter AT mode start&#xA;  Serial.print(&quot;+&quot;);//AT&#xA;  Serial.print(&quot;+&quot;);//AT&#xA;  Serial.print(&quot;+&quot;);//AT&#xA;  Serial.flush();&#xA;  delay(1000);//enter AT mode finish &#xA;  while(Serial.available()&amp;gt;0){&#xA;    Serial.write(Serial.read());&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;  Serial.println(&quot;ATDB&quot;);&#xA;&#xA;  while(Serial.available()&amp;gt;0){&#xA;    Serial.write(Serial.read());&#xA;  }&#xA;  delay(750);//3/4 a sec&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, &lt;code&gt;Serial.println(&quot;ATDB&quot;);&lt;/code&gt; should cause the xbee to drop the RSSI on the wire; see&#xA;&lt;a href=&quot;http://examples.digi.com/wp-content/uploads/2012/06/XBee_WiFi_AT_Commands.pdf&quot; rel=&quot;nofollow&quot;&gt;XBee_WiFi_AT_Commands.pdf&lt;/a&gt;&#xA;at digi.com.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The three &quot;+&quot;s at the start are how you move the device into AT mode; see &#xA;&lt;a href=&quot;http://www.mouser.com/pdfdocs/Digi_International_90002124_G.pdf&quot; rel=&quot;nofollow&quot;&gt;Digi_International_90002124_G.pdf&lt;/a&gt; at mouser.com.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once again what I am trying to do is get the collected RSSI information dropped onto a wifi connection from multiple xbee WiFi S6B equipped Fios.&lt;/p&gt;&#xA;" OwnerUserId="1129" LastEditorUserId="3917" LastEditDate="2015-12-14T07:47:33.333" LastActivityDate="2015-12-14T07:47:33.333" Title="XBEE WiFi S6B RSSI for Smartphone localization" Tags="|wifi|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1241" PostTypeId="1" CreationDate="2014-04-21T12:00:09.353" Score="6" ViewCount="9943" Body="&lt;p&gt;So I've tried this a few times and I always get the same issue. When I try to run the sweep example the servo goes round 180 degrees but only in steps. Anyone know a way to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo I'm using is a &lt;strong&gt;Tower Pro Micro Servo 9G SG90&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sweep&#xA;// by BARRAGAN &amp;lt;http://barraganstudio.com&amp;gt; &#xA;// This example code is in the public domain.&#xA;&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;  // create servo object to control a servo &#xA;                // a maximum of eight servo objects can be created &#xA;&#xA;int pos = 0;    // variable to store the servo position &#xA;&#xA;void setup() &#xA;{ &#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;} &#xA;&#xA;&#xA;void loop() &#xA;{ &#xA;  for(pos = 0; pos &amp;lt; 180; pos += 1)  // goes from 0 degrees to 180 degrees &#xA;  {                                  // in steps of 1 degree &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;  for(pos = 180; pos&amp;gt;=1; pos-=1)     // goes from 180 degrees to 0 degrees &#xA;  {                                &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Video: &lt;a href=&quot;http://vidd.me/A40&quot; rel=&quot;noreferrer&quot;&gt;http://vidd.me/A40&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1132" LastEditorUserId="11" LastEditDate="2014-04-21T17:43:57.703" LastActivityDate="2020-05-01T17:17:12.090" Title="My Servo Won't Sweep Smoothly" Tags="|arduino-uno|servo|" AnswerCount="6" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="1244" PostTypeId="1" CreationDate="2014-04-21T16:08:45.997" Score="4" ViewCount="1040" Body="&lt;p&gt;Is it possible to connect these two shields to my Arduino Uno? After a research on the internet, I discovered that they use some of the same pins. Even so, is it still possible for me to connect the LcdKeypad and the ArduinoWifi on my Arduino Uno? (the LCD would be on top)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the pic of the shields, and some information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.robotshop.com/media/catalog/product/cache/1/image/325x325/9df78eab33525d08d6e5fb8d27136e95/a/d/adafruit-rgb-lcd-keypad-shield-kit-arduino-i2c.jpg&quot; rel=&quot;nofollow&quot;&gt;LDC KEYPAD&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ktjjnx9q5vgx99fk.zippykid.netdna-cdn.com/wp-content/uploads/2013/06/arduino-wifi-shield.jpeg&quot; rel=&quot;nofollow&quot;&gt;Arduino WIFI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFi shield info:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino communicates with the processor WiFi shield with the microSD card by SPI &#xA;  (Eurotherm the ICSP bus) that is on pins 11, 12&#xA;  and 13 at Uno. The pin 10 is used to select the HDG104 and pin 4 to&#xA;  the microSD card(i dont need the pin 4 cause i wont use SD). These pins can not be used &#xA;  for input and output. The&#xA;  digital pin 7 is used for initialization of the communication protocol&#xA;  between the shield and Arduino WiFi and should not be used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;LCD info:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This shield we will have to use the following sequence to initialize&#xA;  the library LiquidCrystal: &#xA;  LiquidCrystal lcd (8,9,4,5,6,7);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you guys have noticed, there is the pin 7 on both shields that I need to use. How would it work? Can I do this? If i can't, is there any solution that I can expand my pins that would not result buying a Mega?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still have to connect two INFRA-RED sensors and a motor (using pins 0, 1, and 2). I don't know if i can connect on the pins TX and RX (they seem to work).&lt;/p&gt;&#xA;" OwnerUserId="980" LastEditorUserId="220" LastEditDate="2014-04-21T21:31:04.957" LastActivityDate="2014-04-22T21:21:06.470" Title="ArduinoUno+LcdKeypad+ArduinoWifi=Pins Problems" Tags="|arduino-uno|pins|shields|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1245" PostTypeId="2" ParentId="1244" CreationDate="2014-04-21T22:05:54.970" Score="1" Body="&lt;p&gt;&lt;strong&gt;So here are your needs:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;WiFi, which uses pins 4, 10, 11, 12, 13. I know you said that you don't need pin 4 since no SD, but because that pin switches on/off the SD card, if you use it at all. Note: As Connor Wolf points out, it's not really relevant when there's no SD card. If you're facing problems with the Ethernet shield using the LCD additionally, you might have to reroute pin 4.&lt;/li&gt;&#xA;&lt;li&gt;LCD, which uses pins 4, 5, 6, 7, 8, 9. The standard Arduino LCD library can use any pins, but your shield is hard wired to use those. As mentioned before, you can reroute them if you want to. Below is the method for rerouting pins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Rerouting pin 7 (you need to do this!):&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bend pin 7 on the LCD shield and the WiFi shield outward so it doesn't make contact with the header&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;LiquidCrystal lcd(8,9,3,5,6,2);&lt;/code&gt; if you're rerouting pin 4, or &lt;code&gt;LiquidCrystal lcd (8,9,4,5,6,2);&lt;/code&gt; in your code if you're not rerouting&lt;/li&gt;&#xA;&lt;li&gt;Attach a jumper between the pin 7 on the header of the WiFi shield and the pin 7 on the Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;Attach a jumper between the pin 2 of the WiFi shield (or the Uno, if that's easier) and the pin 7 of the LCD using the free space of the pin bent above it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will isolate pin 7 on the LCD, still send the pin 4 signal to the WiFi shield, and reroute the signal from pin 2 on your Arduino to pin 7 on the LCD shield.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Rerouting pin 4 (optional):&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bend pin 4 on the LCD shield and the WiFi shield outward so it doesn't make contact with the header&lt;/li&gt;&#xA;&lt;li&gt;Use &lt;code&gt;LiquidCrystal lcd(8,9,3,5,6,2);&lt;/code&gt; in your code&lt;/li&gt;&#xA;&lt;li&gt;Attach a jumper between the pin 4 on the header of the WiFi shield and the pin 4 on the Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;Attach a jumper between the pin 3 of the WiFi shield (or the Uno, if that's easier) and the pin 4 of the LCD using the free space of the pin bent above it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will isolate pin 4 on the LCD, still send the pin 4 signal to the WiFi shield, and reroute the signal from pin 3 on your Arduino to pin 4 on the LCD shield.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For number of pins, you should be fine. You can use pins 0 and 1 (TX/RX) &lt;strong&gt;as long as you aren't connecting to the computer or any other UART device&lt;/strong&gt;  (i.e. using the &lt;code&gt;Serial()&lt;/code&gt; library). Don't forget you can use the analog pins as digital pins by referencing them as &lt;code&gt;A0&lt;/code&gt; to &lt;code&gt;A5&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-04-22T21:21:06.470" LastActivityDate="2014-04-22T21:21:06.470" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1247" PostTypeId="1" AcceptedAnswerId="1252" CreationDate="2014-04-22T07:48:37.103" Score="2" ViewCount="312" Body="&lt;p&gt;I have downloaded BOSSA for Linux, and have run &lt;code&gt;bossash-&amp;gt;scan&lt;/code&gt;. I have also tried erasing and resetting the board before scanning. It does not work. According to the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;Arduino website&lt;/a&gt;, the native USB port is connected directly to the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Isn't the master branch BOSSA (Arduino IDE uses it's own modified version of BOSSA) working because of a problem with this specific board, or have Arduino modified something inside the chip which alters the behaviour of the native port?&lt;/p&gt;&#xA;" OwnerUserId="693" LastActivityDate="2014-04-22T16:50:41.413" Title="Why doesn't the master branch BOSSA work on Arduino Due?" Tags="|arduino-due|bootloader|bossa|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1248" PostTypeId="2" ParentId="1241" CreationDate="2014-04-22T09:47:09.093" Score="0" Body="&lt;p&gt;It looks like your sketch runs in slow motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check if you wrote delay(150) or have an additional delay in your loop.&#xA;Check twice and - just to make sure - upload the corrected sketch again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;If possible, test with another servo and even test with another Arduino board.&lt;/p&gt;&#xA;" OwnerUserId="1136" LastEditorUserId="1136" LastEditDate="2014-04-29T09:11:48.617" LastActivityDate="2014-04-29T09:11:48.617" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1249" PostTypeId="2" ParentId="1239" CreationDate="2014-04-22T10:36:36.723" Score="4" Body="&lt;p&gt;You could try the &lt;a href=&quot;http://www.co2meter.com/products/k-30-co2-sensor-module&quot; rel=&quot;nofollow&quot;&gt;K30 CO2 sensor&lt;/a&gt;. There is also a guide using it to make an arduino CO2 detector &lt;a href=&quot;http://www.openhomeautomation.net/wireless-co2-sensor-arduino/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also seen people use the MG-811 module, you can buy them from dfrobot.com . There is also good documentation for how to use the MG-811 with arduino &lt;a href=&quot;http://www.spencerpages.com/wiki/index.php?title=MG811_Carbon_Dioxide_%28CO2%29_Sensor&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9" LastEditorUserId="1532" LastEditDate="2014-06-13T14:02:29.543" LastActivityDate="2014-06-13T14:02:29.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1251" PostTypeId="1" AcceptedAnswerId="1295" CreationDate="2014-04-22T16:44:36.173" Score="3" ViewCount="14608" Body="&lt;p&gt;Does anyone know where I can find a Chlorine Sensor to use with the Arduino? It would need to be water proof. I've googled, but I couldn't find anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;Requirements: relatively inexpensive (under $100us), works with Arduino, waterproof and used to detect chlorine in water.&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2014-04-23T19:59:13.847" LastActivityDate="2019-03-10T13:21:46.923" Title="A waterproof Chlorine Sensor" Tags="|sensors|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1252" PostTypeId="2" ParentId="1247" CreationDate="2014-04-22T16:50:41.413" Score="1" Body="&lt;p&gt;No Arduino did not alter the chip, custom chips are massively expensive. If they are using their own modified version of BOSSA, then there must be a reason for it, probably the support of Arduino's hardware platform. To find out what the difference is, you have to find the code base used for Due and the original version when the code was forked. Often in such cases a project like Arduino can provide a patch to the BOSSA project, and that patch may or may not be applied to the master tree. Only way to find out is to check the BOSSA project repository / bug  reports and documentation.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-22T16:50:41.413" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1253" PostTypeId="2" ParentId="1240" CreationDate="2014-04-22T18:53:38.687" Score="1" Body="&lt;p&gt;Just incase anybody stumbles onto this page googling, I am posting my solution below (I &lt;em&gt;think&lt;/em&gt; it will work for any xbee radio)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically for some reason the RSSI values are getting nulled out before I can read them, both in my API mode tests and AT commands.  I'm not convinced that there is not some way around this in API mode at least, but it is irrelevant for my current purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did was wire pin 6 on the xbee to a digital pin on the Arduino (I used 7) then use a pulse detector to find the period of the wireless signal coming in.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 7;&#xA;unsigned long period;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); &#xA;  pinMode(pin, INPUT);&#xA;  Serial.println(&quot;Getting started&quot;);&#xA;}&#xA;&#xA;void loop(){&#xA;  delay(100);&#xA;  period = pulseIn(pin, HIGH);&#xA;  Serial.println(period);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is not perfect, but for now it works, might help someone else in the future.&lt;/p&gt;&#xA;" OwnerUserId="1129" LastActivityDate="2014-04-22T18:53:38.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1254" PostTypeId="2" ParentId="1216" CreationDate="2014-04-22T19:07:42.567" Score="2" Body="&lt;p&gt;This should give you an idea of how to create a custom library which you can use in your project. I actually compiled it with Arduino IDE 1.0.5 on Mac OsX. &#xA;I did not run it on an Arduino board, but have similar code in a production project, that works just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start a new Arduino sketch, name it as you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to the folder where you saved that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add a new file called MyServoLib.h parallel to your main project file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your main file, include the servo library from Arduino and your custom library like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &quot;MyNewLib.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you close and reopen your project, it the Arduino IDE will automatically load your custom library file as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Copy the following simple stub code into your custom library file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MY_SERVO_LIB_H__&#xA;#define  MY_SERVO_LIB_H__&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class MyServoLib&#xA;{&#xA;public:&#xA;&#xA;  MyServoLib()&#xA;    : _servoPin(9)&#xA;    , _attached(false)&#xA;  {}&#xA;&#xA;  void attach()&#xA;  {&#xA;    if (_attached)&#xA;      return;      &#xA;&#xA;    _attached = true;&#xA;    _servo.attach(_servoPin);&#xA;  }&#xA;&#xA;  void detach()&#xA;  {&#xA;      if (! _attached)&#xA;          return;&#xA;&#xA;      _attached = false;&#xA;      _servo.detach();&#xA;  }    &#xA;&#xA;  void setPin(int pin){&#xA;    _servoPin = pin;&#xA;  }&#xA;&#xA;&#xA;private:&#xA;&#xA;  bool _attached;&#xA;  Servo _servo;&#xA;  int _servoPin;&#xA;&#xA;};&#xA;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your main file should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &quot;MyNewLib.h&quot;&#xA;&#xA;// use your custom lib here&#xA;MyServoLib myServo;&#xA;int MyServoPin = 5;&#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(MyServoPin, OUTPUT);&#xA;  myServo.setPin(MyServoPin);  &#xA;  myServo.attach();&#xA;&#xA;  // your additional setup code here&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  // your main code here&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upload it to an Arduino board and give it a try. The servo won't move, but it should get powered on.&lt;/p&gt;&#xA;" OwnerUserId="1136" LastActivityDate="2014-04-22T19:07:42.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1255" PostTypeId="1" CreationDate="2014-04-21T00:52:39.887" Score="2" ViewCount="1787" Body="&lt;p&gt;My goal is to have my Arduino fire two stepper motors.  They need not be simultaneous. I'm using an Arduino Uno with 2 motor shields - specifically, the &lt;a href=&quot;http://www.seeedstudio.com/depot/Motor-Shield-p-913.html?cPath=73&quot; rel=&quot;nofollow&quot;&gt;Seeed Studio Motor Shield v1.0&lt;/a&gt;. I know this shield uses D8-13.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question is, how can I get the Arduino to use both shields?  Is there a way to make one of the shields take D0-D7?  If I could do that that'd be great. As far as I can tell, there's no way. The motor shields cannot be physically mounted either.&lt;/p&gt;&#xA;" OwnerUserId="1193" OwnerDisplayName="user40632" LastActivityDate="2014-05-25T18:55:43.933" Title="Seeed Studio motor shield" Tags="|motor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1256" PostTypeId="1" CreationDate="2014-04-23T02:17:16.723" Score="2" ViewCount="345" Body="&lt;p&gt;I got some code to receive characters from Bluetooth and code and print it back to the LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, want to detect the &lt;em&gt;&lt;code&gt;Enter&lt;/code&gt;&lt;/em&gt; &lt;em&gt;character&lt;/em&gt; to be the input signal, in other words, not to print nothing to the display until &lt;kbd&gt;Enter&lt;/kbd&gt; is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An strange character is shown at display for &lt;kbd&gt;Enter&lt;/kbd&gt; but I can't &lt;em&gt;catch it&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x20,16,2); &#xA;&#xA;void setup()&#xA;{&#xA;  lcd.init();&#xA;  lcd.backlight();&#xA;  pinMode(13,OUTPUT);&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  while (Serial1.available())&#xA;  { &#xA;    char dato= Serial1.read(); //Comprobamos el dato &#xA;&#xA;     lcd.print(dato);&#xA;&#xA;&#xA;    switch(dato) { &#xA;    case '#':  &#xA;      Serial.println(&quot;GATO...&quot;);&#xA;    break;  &#xA;    case 'e':  digitalWrite(13,LOW); &#xA;&#xA;    Serial1.println(&quot;Led apagado&quot;);&#xA;    break;  &#xA;      case 'r':  &#xA;      digitalWrite(13,HIGH); delay(200); &#xA;      digitalWrite(13,LOW); delay(200);&#xA;&#xA;      Serial1.println(&quot;Led intermitente&quot;);&#xA;      break;&#xA;  } //fin switch&#xA;&#xA;}//serial disponible&#xA;&#xA;&#xA;}//fin programa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1143" LastActivityDate="2014-04-23T05:11:50.530" Title="How to catch the Enter key received by Bluetooth?" Tags="|bluetooth|display|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1257" PostTypeId="2" ParentId="1256" CreationDate="2014-04-23T03:42:41.967" Score="4" Body="&lt;p&gt;It depends on what the enter key sends. It may be just CR (carriage return), LF (line feed), or both. You can check the &lt;a href=&quot;http://www.cdrummond.qc.ca/cegep/informat/professeurs/alain/images/ASCII1.GIF&quot; rel=&quot;nofollow&quot;&gt;ASCII table&lt;/a&gt; for the hex values for those characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LF is 0x0A and CR is 0x0D. Those are the characters you're looking for, you can add a &lt;code&gt;if&lt;/code&gt; for these cases in order to guard the call to &lt;code&gt;lcd.print(dato)&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char dato= Serial1.read(); //Comprobamos el dato &#xA;if (dato != 0x0A &amp;amp;&amp;amp; dato != 0x0F)&#xA;    lcd.print(dato);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastEditorUserId="84" LastEditDate="2014-04-23T05:11:50.530" LastActivityDate="2014-04-23T05:11:50.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1259" PostTypeId="2" ParentId="1241" CreationDate="2014-04-23T05:53:28.067" Score="2" Body="&lt;p&gt;In electronics, as usual in situations where a cricuit is misbehaving and we don't understand why, a solution that generally works is to add a &lt;strong&gt;decoupling cap&lt;/strong&gt; between &lt;code&gt;+5V&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, I would put at least &lt;strong&gt;220uF&lt;/strong&gt;; that would ensure two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the voltage used to control the servo never drops&lt;/li&gt;&#xA;&lt;li&gt;the voltage brought to Arduino by the USB does not drop either (which would have very bad impact on the Arduino, probably resetting it)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Electrolytic caps are a &lt;strong&gt;must-have&lt;/strong&gt; for every electronics hobbyist (and professional as well, of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about decoupling capacitors on &lt;a href=&quot;http://en.wikipedia.org/wiki/Decoupling_capacitor&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to @gwideman comment, it seems that using a decoupling capacitance &lt;strong&gt;above 10uF&lt;/strong&gt; in a USB 2.0 device would violate USB specs and &lt;strong&gt;&lt;em&gt;may damage&lt;/em&gt;&lt;/strong&gt; the USB host controller on the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was not aware of this limitation but I have already used decoupling capacitance up to 100uF in my circuits and never got any issue with my USB computer port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be due to extra electronics on the Arduino board that would &quot;isolate&quot; USB power from Arduino +5V anf d GND pins, I don't know (&lt;strong&gt;that should probably be the topic of a specific question&lt;/strong&gt;); or maybe I have just been lucky all this time...&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-04-26T10:32:13.917" LastActivityDate="2014-04-26T10:32:13.917" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="1260" PostTypeId="1" AcceptedAnswerId="1262" CreationDate="2014-04-23T07:48:16.900" Score="13" ViewCount="18352" Body="&lt;p&gt;On the documentation of Arduino, I quote:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Learning/Memory&quot;&gt;http://playground.arduino.cc/Learning/Memory&lt;/a&gt;&#xA;  Note: Flash (PROGMEM) memory can only be populated at program burn time. You can’t change &gt; the values in the flash after the program has started running.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And on the PROGMEM description:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/PROGMEM&quot;&gt;http://arduino.cc/en/Reference/PROGMEM&lt;/a&gt;&#xA;  Store data in flash (program) memory instead of SRAM. There's a description of the various types of memory available on an Arduino board.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The PROGMEM keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler &quot;put this information into flash memory&quot;, instead of into SRAM, where it would normally go.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So can we or can't we? Or it's not the same thing?&lt;/p&gt;&#xA;" OwnerUserId="1145" LastActivityDate="2019-10-07T02:42:01.810" Title="Can I write to Flash Memory using PROGMEM?" Tags="|progmem|memory-usage|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1261" PostTypeId="1" AcceptedAnswerId="1266" CreationDate="2014-04-23T09:06:56.640" Score="2" ViewCount="344" Body="&lt;p&gt;I want to measure the SPI clock (pin 13) using the Arduino example code for the SPI library (very simple example). Basically independent from the &lt;code&gt;loop&lt;/code&gt; function, the clock should be fired continuously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I deployed the Arduino SPI example code on the board and measured pin 13 on an oscilloscope, but nothing was found, always zero volt.&lt;/p&gt;&#xA;" OwnerUserId="1146" LastEditorUserId="510" LastEditDate="2017-11-12T12:01:32.357" LastActivityDate="2017-11-12T12:01:32.357" Title="Arduino Uno and Leonardo SPI clock can't be measured" Tags="|arduino-uno|arduino-leonardo|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1262" PostTypeId="2" ParentId="1260" CreationDate="2014-04-23T09:49:36.940" Score="9" Body="&lt;p&gt;The short answer is no: PROGMEM data is read-only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Flash memory limitations&lt;/strong&gt;&lt;br&gt;&#xA;The first thing to understand is that Flash memory (where program space lives) is designed for long-term fixed storage. Reading from it is very fast and precise. However, generally speaking, you can't modify it on a byte-by-byte basis (e.g. changing a specific variable). You usually have to erase and re-write it in large blocks. That makes it completely impractical for run-time manipulation, because you'd have to store a lot of redundant information somewhere else while you do the erase and write cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What PROGMEM actually does&lt;/strong&gt;&lt;br&gt;&#xA;Any literal data specified in your code (such as strings and numbers) always reside in program space at first (i.e. in Flash). However, when your sketch actually wants to use that data at runtime, it normally has to allocate some space for it in SRAM and copy it over. That means you end up with two copies: the fixed original in Flash, and the temporary copy in SRAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use the PROGMEM modifier, you're telling it not to make that second copy in SRAM. Instead, your sketch will simply access the original in Flash. That's very useful if you only ever have to &lt;em&gt;read&lt;/em&gt; the data, as it avoids the allocation and copy operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, copying it to SRAM is essential if you want to modify the data. Aside from the Flash limitations I mentioned above, it's also a question of code safety.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're able to modify the &lt;strong&gt;data&lt;/strong&gt; stored in program space, then it follows logically that you could also modify the &lt;strong&gt;code&lt;/strong&gt; stored in program space. That would mean that a simple mistake (or in theory a malicious attack) could result in your sketch being partially or fully rewritten at run-time. This could have very unpredictable results, ranging from simply ceasing to work, through to damaging/destroying any connected equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More information&lt;/strong&gt;&lt;br&gt;&#xA;You can learn more about the low-level PROGMEM stuff from here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.fourwalledcubicle.com/AVRArticles.php&quot;&gt;http://www.fourwalledcubicle.com/AVRArticles.php&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An older version of the same PROGMEM tutorial is available here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;p=243018&quot;&gt;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;p=243018&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-04-23T09:49:36.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1263" PostTypeId="1" AcceptedAnswerId="1264" CreationDate="2014-04-23T10:04:37.873" Score="3" ViewCount="2872" Body="&lt;p&gt;I was trying out a basic button tutorial on my new Arduino UNO. But for some reason, the Arduino was detecting the button as on (pressed) even when it was off (unpressed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some experimentation, I found that the digital pins were flickering between &lt;code&gt;HIGH&lt;/code&gt; and &lt;code&gt;LOW&lt;/code&gt;, even if there was just a loose wire plugged in with nothing at the other end. And the state of the button, etc. wasn't making any difference. I tried this with pins 5,6 and 7, and it's happening with all of them, even when the neighbouring pins are connected to the ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is this behaviour normal or is there something wrong with my input pins?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Since I'm new to Arduino, there might also be something wrong with my testing code. Here's what I used...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned int LED_PIN = 12;&#xA;const unsigned int BUTTON_PIN = 7;&#xA;const unsigned int INDICATOR_PIN = 13;&#xA;&#xA;void setup() {&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;  pinMode(BUTTON_PIN, INPUT);&#xA;  digitalWrite(LED_PIN, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  const int BUTTON_STATE = digitalRead(BUTTON_PIN);&#xA;&#xA;  if (BUTTON_STATE == HIGH) {&#xA;    digitalWrite(LED_PIN, HIGH);&#xA;    digitalWrite(INDICATOR_PIN, LOW);&#xA;  }&#xA;  else if (BUTTON_STATE == LOW) {&#xA;    digitalWrite(LED_PIN, LOW);&#xA;    digitalWrite(INDICATOR_PIN, HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This code makes the lights always in opposite states: when one is on, the other is off. When I ran the code, both lights seemed on, which meant they were probably flickering, which meant that there was some interference in the input pin.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1137" LastActivityDate="2014-04-23T10:23:59.497" Title="Interference at digital input (UNO)" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="0" ClosedDate="2014-04-24T01:16:33.170" ContentLicense="CC BY-SA 3.0" />
  <row Id="1264" PostTypeId="2" ParentId="1263" CreationDate="2014-04-23T10:23:59.497" Score="5" Body="&lt;p&gt;It sounds like you're seeing entirely normal behaviour. If you leave a digital input unconnected (or connected to an open button) then it's 'floating'. That means it can pick up interference from all sorts of things, and may appear to drift between high and low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual way to resolve this problem is using a pull-up or pull-down resistor. This is usually a high-ohm resistor (e.g. 10,000 Ohm or more) which will gently pull the pin HIGH or LOW in the absence of any other signal. When another signal comes in (e.g. from a button being pushed), it should have a much stronger effect than the resistor, so that is what the input will see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Uno has built-in pull-up resistors which you can use for this, although it will require a couple of changes. In your &lt;code&gt;setup()&lt;/code&gt; function, you can enable the pull-up on your input pin like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(BUTTON_PIN, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will cause the input to appear HIGH when the button is &lt;strong&gt;not&lt;/strong&gt; pushed. That means you'll need to wire the other end of your button to ground (negative) instead of the voltage supply (positive). If you've set it up correctly, the input should appear LOW when the button is pushed.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-04-23T10:23:59.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1265" PostTypeId="1" AcceptedAnswerId="1296" CreationDate="2014-04-23T14:04:52.393" Score="7" ViewCount="9526" Body="&lt;p&gt;Using an Arduino and an L293D IC, can I control the number of rotations a DC motor makes? Or can I only control the direction and speed of the motor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I purchased a two-wheeled robot platform to learn Arduino programming and electronics. The platform is here: &lt;a href=&quot;http://www.robotshop.com/en/dfrobot-2wd-mobile-platform-arduino.html&quot;&gt;http://www.robotshop.com/en/dfrobot-2wd-mobile-platform-arduino.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each wheel is controlled by a DC motor. I followed Adafruit's tutorial (&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing&quot;&gt;https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing&lt;/a&gt;) to control the motors with the help of an L293D IC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I realize that I can't directly control the rotations of the motor. I can control the direction, voltage, and time of the rotation. For example: turn forward at 50% voltage for 500 milliseconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's difficult to translate into actual rotations. The speed of the motor varies according to voltage (like if I switch from 2AA batteries to 4AA's) and weight (adding sensors slows the motors down). Every time I change voltage or weight, I have to guess how much voltage/time causes a single rotation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I should just buy stepper motors. Before I do that, I'll ask the community: Is there a way to control DC motors by rotations rather than time?&lt;/p&gt;&#xA;" OwnerUserId="1149" LastActivityDate="2014-04-25T18:18:22.567" Title="Control/count rotations of a DC motor" Tags="|motor|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1266" PostTypeId="2" ParentId="1261" CreationDate="2014-04-23T14:20:43.030" Score="4" Body="&lt;p&gt;Please note the SPI clock will only be active while it is shifting data. So simply put the spi.transfer in a hard loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  SPI.begin();&#xA;  while (1) {&#xA;    SPI.transfer(0x00);&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-04-23T14:20:43.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1267" PostTypeId="1" AcceptedAnswerId="1303" CreationDate="2014-04-23T17:53:55.487" Score="3" ViewCount="6162" Body="&lt;p&gt;I am able to control my monitor and most other applications by giving serial input to python through arduino.&#xA;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA; {&#xA;&#xA;  pinMode(2, INPUT); &#xA;  pinMode(3, INPUT);&#xA;  pinMode(4, INPUT);&#xA;  pinMode(5, INPUT);&#xA;  pinMode(6, INPUT);&#xA;  pinMode(7, INPUT);&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(digitalRead(2) == HIGH)&#xA;  {&#xA;    delay(5);&#xA;  }&#xA;  else &#xA;  {&#xA;    Serial.println(&quot;up&quot;);&#xA;  }&#xA;  if(digitalRead(3) == HIGH)&#xA;  {&#xA;    delay(5);&#xA;  }&#xA;  else &#xA;  {&#xA;    Serial.println(&quot;down&quot;);&#xA;  }&#xA;  if(digitalRead(4) == HIGH)&#xA;  {&#xA;    delay(5);&#xA;  }&#xA;  else &#xA;  {&#xA;    Serial.println(&quot;left&quot;);&#xA;  }&#xA;  if(digitalRead(5) == HIGH)&#xA;  {&#xA;    delay(5);&#xA;  }&#xA;  else &#xA;  {&#xA;    Serial.println(&quot;right&quot;);&#xA;  }&#xA;  if(digitalRead(6)== HIGH)&#xA;  {&#xA;    delay(5);&#xA;  } &#xA;  else&#xA;  {&#xA;    Serial.println(&quot;space&quot;);//orange&#xA;  }&#xA;  if(digitalRead(7)==HIGH)&#xA;  {&#xA;     delay(5);&#xA;  }   &#xA;  else&#xA;  {  &#xA;    Serial.println(&quot;nitro&quot;);//brown&#xA;  }  &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;from pymouse import PyMouse&#xA;from pykeyboard import PyKeyboard&#xA;&#xA;k = PyKeyboard()&#xA;&#xA;ser = serial.Serial('COM7', 9600)&#xA;&#xA;&#xA;#sp.write(&quot;AT\r\n&quot;.encode('ascii'))&#xA;&#xA;while True:&#xA;    p=ser.readline()&#xA;    print p&#xA;    if ('up' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.up_key)&#xA;&#xA;    if ('down' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.down_key)&#xA;&#xA;&#xA;    if ('right' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.right_key)&#xA;&#xA;&#xA;    if ('left' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.left_key)&#xA;&#xA;    if ('space' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.space_key)&#xA;&#xA;    if ('nitro' in p):&#xA;        k = PyKeyboard()&#xA;&#xA;        k.tap_key(k.enter_key)    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that..I am not able to play games such as NFS and other similar games using these controls..&#xA;What should i do??&lt;/p&gt;&#xA;" OwnerUserId="1151" LastEditorUserId="337" LastEditDate="2014-04-23T19:02:36.953" LastActivityDate="2021-05-14T05:55:50.877" Title="How to control Keyboard inputs using arduino(serial monitor) and python keyboard libraries?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1268" PostTypeId="1" CreationDate="2014-04-23T22:26:01.460" Score="3" ViewCount="217" Body="&lt;p&gt;I'm a bit new to electronics/Arduino projects, so am looking for some help on some wiring needed for a project involving this Pull Chain: &lt;a href=&quot;http://proto-pic.co.uk/pull-chain-switch/&quot; rel=&quot;nofollow&quot;&gt;http://proto-pic.co.uk/pull-chain-switch/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chain works like a fan chain would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have wired up the pull chain to a mini breadboard with a light that turns on and off just to test it's working. What I want to do, is get an analog/digital read each time the chain is pulled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? If so, would you be able to help me with how it would be wired up, as I am completely new to the electronics side of Arduino. I simply need to get a reading each time the chain is pulled, I don't need it to switch a light on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks all!&lt;/p&gt;&#xA;" OwnerUserId="1157" LastActivityDate="2014-04-23T23:45:47.310" Title="Pull Chain Switch" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1269" PostTypeId="2" ParentId="1268" CreationDate="2014-04-23T23:45:47.310" Score="2" Body="&lt;p&gt;Connect it between ground and an interrupt pin &lt;a href=&quot;http://arduino.cc/en/Reference/pinMode&quot; rel=&quot;nofollow&quot;&gt;configured as an input with the pullup enabled&lt;/a&gt;. &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;Configure the interrupt&lt;/a&gt; to trigger on any state change. &lt;a href=&quot;http://arduino.cc/en/Reference/DigitalRead&quot; rel=&quot;nofollow&quot;&gt;Check the digital value of the pin&lt;/a&gt; in the ISR.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-23T23:45:47.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1270" PostTypeId="1" CreationDate="2014-04-23T04:27:10.673" Score="6" ViewCount="3717" Body="&lt;p&gt;I am using this device for my Arduino that connects to the &lt;a href=&quot;http://en.wikipedia.org/wiki/On-board_diagnostics#OBD-II&quot; rel=&quot;nofollow&quot;&gt;OBD-II&lt;/a&gt; port of my car to get various information such as speed, rpm, etc. I am using this for a digital &lt;a href=&quot;http://en.wikipedia.org/wiki/Nixie_tube&quot; rel=&quot;nofollow&quot;&gt;Nixie tube&lt;/a&gt; speedometer using the smart Nixie tube from a &lt;a href=&quot;http://en.wikipedia.org/wiki/Kickstarter&quot; rel=&quot;nofollow&quot;&gt;Kickstarter&lt;/a&gt; project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pass the information to the Nixie tubes through serial and get information from the OBD-II through serial as well. I am getting speed updates about every 20 seconds and that is incredibly slow when the device can supposedly update up to 100 times per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally was using an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno&lt;/a&gt; and using software serial for the tubes, but I figured the slowdown was due to interupts interfering with the hardware serial, so I switched to the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 2560&lt;/a&gt; to use a second hardware serial pin to hopefully fix the problem, yet the same issue is occurring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code... There must be something I'm doing wrong. Serial2 is for the Nixie tubes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#import &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;#include &amp;lt;OBD.h&amp;gt;&#xA;&#xA;int ones = 0;&#xA;int tens = 0;&#xA;&#xA;int kphValue = 0;&#xA;int mphValue = 0;&#xA;&#xA;int rpmValue = 0;&#xA;&#xA;String onesString;&#xA;String tensString;&#xA;String payloadString;&#xA;String rpmString;&#xA;COBD obd;&#xA;&#xA;void setup(){&#xA;    Serial2.begin(9600);&#xA;    obd.begin();&#xA;&#xA;    //Initiate OBD-II connection until success&#xA;    while (!obd.init()){&#xA;        Serial2.print(&quot;$0,Y,Y,255,255,000,000$0,Y,Y,255,255,000,000!&quot;);&#xA;        delay(1000);&#xA;        Serial2.print(&quot;$0,Y,Y,000,000,000,000$0,Y,Y,000,000,000,000!&quot;);&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&#xA;void loop(){&#xA;    onesString = String(ones);&#xA;    tensString = String(tens);&#xA;    payloadString;&#xA;    rpmString;&#xA;&#xA;    if(obd.read(PID_RPM, rpmValue)){&#xA;        if (rpmValue &amp;lt; 3000){&#xA;            rpmString =&quot;,N,N,255,000,255,000&quot;;&#xA;        }&#xA;        else if (rpmValue &amp;gt;= 5000){&#xA;            rpmString = &quot;,N,N,255,255,000,000&quot;;&#xA;        }&#xA;        else if (rpmValue &amp;gt;= 3000){&#xA;            rpmString = &quot;,N,N,255,255,030,000&quot;;&#xA;        }&#xA;    }&#xA;&#xA;    if (obd.read(PID_SPEED, kphValue)){&#xA;        kphToMPH();&#xA;        payloadString = &quot;$&quot; + onesString + rpmString + &quot;$&quot; + tensString + &quot;rpmString&quot; + &quot;!&quot;;&#xA;        Serial2.print(payloadString);&#xA;    }&#xA;}&#xA;&#xA;void splitDigits(int input_number)&#xA;{&#xA;    ones = (input_number%10);&#xA;    tens = ((input_number/10)%10);&#xA;}&#xA;&#xA;void kphToMPH()&#xA;{&#xA;    mphValue = kphValue * 0.621371;&#xA;    splitDigits(mphValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;I am using the following library: &lt;a href=&quot;https://github.com/stanleyhuangyc/ArduinoOBD&quot; rel=&quot;nofollow&quot;&gt;https://github.com/stanleyhuangyc/ArduinoOBD&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1144" OwnerDisplayName="evan.stoddard" LastEditorUserId="1144" LastEditDate="2016-05-20T02:53:30.333" LastActivityDate="2016-05-26T02:59:06.510" Title="Super slow serial (UART) communication on Arduino" Tags="|serial|uart|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="1271" PostTypeId="2" ParentId="1270" CreationDate="2014-04-23T04:56:45.323" Score="6" Body="&lt;p&gt;I think the problem is not so much in the update speed, but in the fact that you loose accuracy in your calculation. The following lines are the culprit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int kphValue = 0;  // [-32768:32767]&#xA;int mphValue = 0;&#xA;mphValue = kphValue * 0.621371;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure the calculation will be entirely in integers to prevent calculation errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t kphValue = 0;  // [0:65535]&#xA;uint16_t mphValue = 0;&#xA;mphValue = ( kphValue * 621 ) / 1000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This limits kphValue to just over 100, if you want to go higher than that there are two option:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;multiply by 62 and divide by 100;&lt;/li&gt;&#xA;&lt;li&gt;use longer integers &lt;code&gt;int32_t&lt;/code&gt; [-2147483648:2147483647], which comes with enough room for multiplying by 621371 and dividing by 1000000, but will perform slower and with a larger memory footprint. Do you really need that accuracy?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="83" OwnerDisplayName="jippie" LastActivityDate="2014-04-23T06:49:29.973" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1272" PostTypeId="1" AcceptedAnswerId="1287" CreationDate="2014-04-24T07:26:04.390" Score="6" ViewCount="6543" Body="&lt;p&gt;I got a &lt;code&gt;String&lt;/code&gt; which as I understand is an Arduino object, and got some C++ code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x20,16,2); &#xA;&#xA;boolean borrar = false;&#xA;String IP;&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.init();&#xA;  lcd.backlight();&#xA;  pinMode(13,OUTPUT);&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  while (Serial1.available()) { &#xA;&#xA;    char caracter = Serial1.read(); //Comprobamos el caracter &#xA;&#xA;    switch(caracter) {&#xA;&#xA;    default:&#xA;                if (borrar) { &#xA;                              IP = &quot;&quot;; &#xA;                              lcd.clear();&#xA;                }&#xA;&#xA;                lcd.print(caracter);&#xA;                delay(125);&#xA;                borrar = false;&#xA;&#xA;                IP.concat(caracter);&#xA;                break;  &#xA;&#xA;    case '\r':                &#xA;    case 0x0F:&#xA;    case 0x0A:  &#xA;&#xA;                String res = &quot;&quot;;&#xA;                borrar = true;&#xA;                int num= atoi(IP.c_str());&#xA;                if (num &amp;lt; 127) &#xA;                  res=&quot;Clase A&quot;;&#xA;                if (num == 127) &#xA;                  res=&quot;Direccion reservada&quot;;&#xA;                if (num &amp;gt; 127 &amp;amp;&amp;amp; num &amp;lt; 192)&#xA;                  res=&quot;Clase B &quot;;&#xA;                if (num &amp;gt;= 192 &amp;amp;&amp;amp; num &amp;lt; 224)&#xA;                  res=&quot;Clase C &quot;;&#xA;                if (num &amp;gt;= 224 &amp;amp;&amp;amp; num &amp;lt; 240)&#xA;                  res=&quot;Clase D &quot;;&#xA;                if (num &amp;gt;= 240 &amp;amp;&amp;amp; num &amp;lt; 255)&#xA;                  res=&quot;Clase E &quot;;&#xA;                break;  &#xA;&#xA;  } //fin switch&#xA;&#xA;}//serial disponible&#xA;&#xA;&#xA;}//fin programa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this won't compile because of this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int num= atoi(IP.c_str())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As IP is a &lt;strong&gt;&lt;code&gt;String&lt;/code&gt;&lt;/strong&gt; and such method works for &lt;strong&gt;&lt;code&gt;string&lt;/code&gt;&lt;/strong&gt;. How can I make it compatible (convert it)?&lt;/p&gt;&#xA;" OwnerUserId="1143" LastActivityDate="2016-11-26T21:41:13.100" Title="How can I convert Arduino String to C string type?" Tags="|c++|data-type|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1273" PostTypeId="2" ParentId="1272" CreationDate="2014-04-24T08:30:57.550" Score="6" Body="&lt;p&gt;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char z[100];&#xA;IP.getBytes(z, 100);&#xA;z[IP.length()] = 0;&#xA;int n = atoi(z);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To retrieve bytes inside the string. This assumes IP string's length is shorter than 100. &lt;/p&gt;&#xA;" OwnerUserId="1162" LastEditorUserId="1162" LastEditDate="2014-04-24T08:44:08.980" LastActivityDate="2014-04-24T08:44:08.980" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1274" PostTypeId="2" ParentId="1272" CreationDate="2014-04-24T08:32:23.310" Score="2" Body="&lt;p&gt;Try updating to the latest version of the Arduino libraries/IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;c_str()&lt;/code&gt; method was introduced to the Arduino String class quite recently, I believe. That line of code certainly works fine for me on Arduino IDE 1.0.5.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-04-24T08:32:23.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1277" PostTypeId="1" CreationDate="2014-04-24T16:25:03.380" Score="3" ViewCount="192" Body="&lt;p&gt;A friend and I are working on building a smartwatch on a budget, so it’s a (very) low power project, but we are currently having a problem with the power supplying.&#xA;We already chose this board, because of its size and the BLE chip: &lt;a href=&quot;http://www.rfduino.com/product/rfd22301-rfduino-ble-smt/&quot; rel=&quot;nofollow&quot;&gt;RFduino BLE SMT&lt;/a&gt;&#xA;For now on, we are planning to use this battery &lt;a href=&quot;http://www.adafruit.com/products/1578&quot; rel=&quot;nofollow&quot;&gt;500 mAh LiPo battery&lt;/a&gt; (approx. 4V at full charge) with this voltage regulator &lt;a href=&quot;http://www.mouser.com/ds/2/495/mic5209-239527.pdf&quot; rel=&quot;nofollow&quot;&gt;Micrel MIC5209-3.6YS&lt;/a&gt; (the board supports 3.6V max.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is that the Voltage Regulator will apparently drain by itself too much energy from the battery (by heating), reducing drastically the autonomy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we would like to know if you guys can help us, if you can tell us exactly what (type of) regulator would be the best or if we need to find another battery.&lt;/p&gt;&#xA;" OwnerUserId="1170" LastEditorUserId="37" LastEditDate="2014-04-25T14:43:04.680" LastActivityDate="2014-04-25T14:43:04.680" Title="Which voltage regulator should I use?" Tags="|battery|bluetooth|electronics|" AnswerCount="1" CommentCount="5" ClosedDate="2014-04-24T18:04:54.703" ContentLicense="CC BY-SA 3.0" />
  <row Id="1278" PostTypeId="1" AcceptedAnswerId="1300" CreationDate="2014-04-24T16:38:46.137" Score="6" ViewCount="10232" Body="&lt;p&gt;At the moment I'm using two softserials to connect to a GPS and an GSM module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems not possible to have two open software-serials. So I was looking for an solution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the initial-setup, the GPS module is only needed to be read from; while the GSM module needs to be bidirectional. So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GPS &amp;gt; listen only&#xA;GSM &amp;gt; listen and write&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I came across the &lt;a href=&quot;https://github.com/adafruit/Adafruit-GPS-Library&quot; rel=&quot;noreferrer&quot;&gt;GPS library from Adafruit&lt;/a&gt;, which uses an interrupt to receive data. Is this &lt;em&gt;instead&lt;/em&gt; of a software serial. Or do I again run into the limitation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An other solution might be to use the D0 and D1 to attach eg the GPS module. But than I won't be able to see the debug messages in my serial monitor. Is that correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry in advance for these n00b questions. But I'm frustrated the things dont work as I want :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/746&quot; rel=&quot;noreferrer&quot;&gt;This is the adafruit GPS board&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;And the board with whom it is connected: &lt;a href=&quot;http://imall.iteadstudio.com/im120411004.html&quot; rel=&quot;noreferrer&quot;&gt;Gboard&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The Sim900 is connected to D2/D3 and the GPS is connected to A2/A3.&lt;/li&gt;&#xA;&lt;li&gt;D0/D1 are connected to a FTDI breakout board, which is plugged into my USB.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="756" LastEditorUserId="756" LastEditDate="2014-04-24T18:59:18.110" LastActivityDate="2014-09-04T17:33:54.070" Title="Simultanous read and read/write on two serial connections" Tags="|arduino-uno|serial|pins|interrupt|softwareserial|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1279" PostTypeId="2" ParentId="1278" CreationDate="2014-04-24T16:53:02.413" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit-GPS-Library/blob/master/Adafruit_GPS.h&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Adafruit_GPS.h&lt;/code&gt;&lt;/a&gt; (line 132-), which is included in &lt;a href=&quot;https://github.com/adafruit/Adafruit-GPS-Library/blob/master/Adafruit_GPS.cpp&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Adafruit_GPS.cpp&lt;/code&gt;&lt;/a&gt; (line 13) refers in turn to the SoftwareSerial library on AVR platform and Arduino IDE version &gt; 100.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __AVR__&#xA;#if ARDUINO &amp;gt;= 100&#xA;    SoftwareSerial *gpsSwSerial;&#xA;#else&#xA;    NewSoftSerial *gpsSwSerial;&#xA;#endif&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means it uses software serial on an Uno. It also means if your problem is indeed with Software Serial, that is the library to check for bugs / updates or commit a patch to.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-24T16:53:02.413" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1280" PostTypeId="2" ParentId="1277" CreationDate="2014-04-24T17:14:52.090" Score="1" Body="&lt;p&gt;I&lt;sub&gt;GND&lt;/sub&gt; which is mentioned on page 4 of the datasheet is apparently proportional to the output current. This accounts for about 2-5% of the total current drawn by the regulator, depending on its load. With the maximum voltage drop of 4 - 3.6 = 400mV, a switching regulator will make no real difference. I think your only option is to find another regulator that has better efficiency.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-24T17:14:52.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1281" PostTypeId="1" AcceptedAnswerId="1282" CreationDate="2014-04-24T19:37:30.180" Score="4" ViewCount="122" Body="&lt;p&gt;I am new to the arduino world and wanted to start playing with the micro controllers, I am a .NET developer by trade so not completely new to this kind of world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I purchased a seeedduino v3 and a Grove started kit (No soldering skills here) and can't even get the basics to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am setting up a simple button to light up the LED program. I have had it run once or twice but it seems really hit or miss on whether or not the Arduino IDE actually gets the program onto the seeedduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Arduino IDE (1.5.6-r2) set-up:&lt;/em&gt;&lt;/strong&gt;&#xA;Followed setup instructions found here: &lt;a href=&quot;http://www.seeedstudio.com/wiki/Seeeduino_v3.0#How_do_I_configure_the_Arduino_IDE.3F&quot; rel=&quot;nofollow&quot;&gt;SeeedDuino v3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Board: Arduino Duemilanove or Diecimila &lt;/li&gt;&#xA;&lt;li&gt;Processor: ATmega328&lt;/li&gt;&#xA;&lt;li&gt;Port: COM4 [this is what popped up once device was plugged in]&lt;/li&gt;&#xA;&lt;li&gt;Button is installed on D3&lt;/li&gt;&#xA;&lt;li&gt;LED is installed on D7&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Program:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int button = 3;&#xA;int LED = 7;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(button, INPUT); //define button on INPUT devices&#xA;  pinMode(LED, OUTPUT);   //define LED on OUTPUT device&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  int buttonState = digitalRead(button); //read the status of hte button&#xA;&#xA;  if(buttonState == HIGH) //also used (buttonState == 1)&#xA;  {&#xA;    digitalWrite(LED, HIGH); //also used digitalWrite(LED, 1)  &#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(LED, LOW); //also used digitalWrite(LED, 0)&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upload Verbose Message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verifying ...&#xA;avrdude: 1070 bytes of flash verified&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have only had the LED from this program turn on twice, then reloading it ruins it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;SIDE NOTE&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I try and run Burn BootLoader I get this message-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : usb&#xA;         Using Programmer              : stk500v2&#xA;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1172" LastActivityDate="2014-04-24T21:02:43.783" Title="SeeedDuino/Grove and the story of not being able to upload programs" Tags="|uploading|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1282" PostTypeId="2" ParentId="1281" CreationDate="2014-04-24T21:02:43.783" Score="4" Body="&lt;p&gt;OK mystery solved!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up getting &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow&quot;&gt;Visual Micro Debugger&lt;/a&gt; plug-in for my Visual Studio 2013 since I am native .NET programmer. I could see that the code was indeed loaded onto the board and when I pressed the button it was indeed getting to the line of code for setting the digital LED to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was a very unfortunate case of trying different components and learning I actually had 3 dead LEDs and one bad cable. After getting functioning ones it's all good. :) unlucky me just had 4 bad parts in my kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output from Visual Studio Debugging:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Legend:&#xA;line 12 = button state check&#xA;line 16 = button pressed turn on LED&#xA;line 20 = button not pressed turn off LED&#xA;&#xA;=================OUTPUT====================&#xA;14:01:04.372 SeeedDuinoPlayground.ino, line 12  loop() &#xA;14:01:04.372 SeeedDuinoPlayground.ino, line 16  loop() &#xA;14:01:04.481 SeeedDuinoPlayground.ino, line 10&#xA;14:01:04.481 SeeedDuinoPlayground.ino, line 12  loop()&#xA;14:01:04.592 SeeedDuinoPlayground.ino, line 16  loop()&#xA;14:01:04.592 SeeedDuinoPlayground.ino, line 10&#xA;14:01:04.696 SeeedDuinoPlayground.ino, line 12  loop()&#xA;14:01:04.697 SeeedDuinoPlayground.ino, line 20  loop()&#xA;14:01:04.804 SeeedDuinoPlayground.ino, line 10&#xA;14:01:04.804 SeeedDuinoPlayground.ino, line 12  loop()&#xA;14:01:04.912 SeeedDuinoPlayground.ino, line 20  loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1172" LastActivityDate="2014-04-24T21:02:43.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1283" PostTypeId="1" CreationDate="2014-04-24T21:02:48.340" Score="4" ViewCount="2939" Body="&lt;p&gt;I would like to test the contents of data received over a serial connection. In my loop() I store the data in bffr; and afterwards I would like to test to see if there are some predefined words in it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BFFSZ 90&#xA;char bffr[BFFSZ];&#xA;char bffridx; &#xA;&#xA;void loop()&#xA;{&#xA;   readline();&#xA;&#xA;   //- Test the bffr&#xA;       if(strstr(bffr, &quot;CLOSED&quot;)){ //- WORKS&#xA;          Serial.println(&quot;&amp;gt; conn. closed&quot;);&#xA;          digitalWrite(A1, HIGH); &#xA;       }else if(strstr(bffr, &quot;RING&quot;)){ //- WORKS&#xA;          Serial.println(&quot;&amp;gt; Someone is ringing&quot;);&#xA;          digitalWrite(A2, HIGH);&#xA;       }else if(strstr(bffr, &quot;0,7,j,BLINK&quot;)){ //- Doesn't work&#xA;          Serial.println(&quot;&amp;gt; Blink&quot;);&#xA;          digitalWrite(A2, HIGH);&#xA;          delay(300);&#xA;          digitalWrite(A2, LOW);&#xA;       }&#xA;}&#xA;&#xA;&#xA;void readline()&#xA;{&#xA;   memset(bffr,0,sizeof(bffr));&#xA;   char c;&#xA;   int i =0;&#xA;   bffridx = 0; // start at beginning&#xA;&#xA;&#xA;   long previousMillis = millis();&#xA;   while (1) {&#xA;     unsigned long currentMillis = millis();&#xA;     if(currentMillis - previousMillis &amp;gt; 20000) {&#xA;       Serial.println(&quot;TIMEOUT&quot;);&#xA;       return;&#xA;     }&#xA;     delay(2);&#xA;&#xA;     c=gsm.SimpleRead2();&#xA;     //- debug only, to see if there is something received.     &#xA;     Serial.write(c);&#xA;&#xA;     if (c == -1)&#xA;       continue;&#xA;     if (c == '\n')&#xA;       continue;&#xA;     if ((bffridx == BFFSZ-1) || (c == '\r')) {&#xA;       bffr[bffridx] = 0;&#xA;       return;&#xA;     }&#xA;&#xA;     bffr[bffridx++]= c;&#xA;     delay(2);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The debug-line makes that I can see the data flowing, eg when I phone the SIM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it looks like the buffer isn't tested properly. The first two will work, but the last test fails. It is part of a larger string: &lt;code&gt;$0,7,j,BLINK,567^&lt;/code&gt; But I thought the &lt;code&gt;strstr(1,2)&lt;/code&gt; searches for 2 in 1. And as &lt;code&gt;0,7,j,BLINK,&lt;/code&gt; is within the haystack I assume it wil return true. But apparently not...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;gsm.SimpleRead2()&lt;/code&gt; comes from &lt;a href=&quot;http://www.gsmlib.org/download.html&quot; rel=&quot;nofollow&quot;&gt;GSMlib&lt;/a&gt; and is my altered version of gsm.SimpleRead(). Instead of printing the char, I just return it so we can buffer it in the &lt;code&gt;readline&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SIMCOM900::SimpleRead()&#xA;{&#xA;&#xA; char datain;&#xA; if(_cell.available()&amp;gt;0){&#xA;   datain=_cell.read();&#xA;   if(datain&amp;gt;0){&#xA;     Serial.print(datain);&#xA;   }&#xA; }&#xA;}&#xA;char SIMCOM900::SimpleRead2()&#xA;{&#xA;&#xA; char datain;&#xA; if(_cell.available()&amp;gt;0){&#xA;   datain=_cell.read();&#xA;   if(datain&amp;gt;0){&#xA;     return datain;&#xA;   }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know the answer to this?&lt;/p&gt;&#xA;" OwnerUserId="756" LastEditorUserId="756" LastEditDate="2014-04-25T09:12:14.927" LastActivityDate="2014-04-25T09:12:14.927" Title="Check contents of buffer after serial read" Tags="|arduino-uno|programming|sketch|string|testing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1284" PostTypeId="2" ParentId="1283" CreationDate="2014-04-24T21:29:11.230" Score="1" Body="&lt;p&gt;After a &lt;code&gt;serial.read();&lt;/code&gt;, the data [as far as I can tell] is pretty much destroyed. You have two main options to accomplish this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Store the data in a string when read and then reference this later. I'd do this with a &lt;em&gt;global variable&lt;/em&gt;, that is declared outside of a method and accessible throughout your whole sketch.&lt;/li&gt;&#xA;&lt;li&gt;I haven't read throughout your whole code, but, if you only need to read one character, you can use &lt;a href=&quot;http://arduino.cc/en/Serial/Peek&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;serial.peek();&lt;/code&gt;&lt;/a&gt;. &lt;strong&gt;This only works if you need the first character of the buffer.&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most likely, your only option would be the first bullet. I'd implement this by adding a method something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String buffer_string_serial;&#xA;&#xA;void setup() { //code here }&#xA;&#xA;void loop() { //code here }&#xA;&#xA;int serial_read_buffer() {&#xA;  while(serial.avaliable() &amp;gt; 0) {&#xA;    buffer_string_serial = buffer_string_serial + serial.peek();&#xA;    return serial.read();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, just use &lt;code&gt;serial_read_buffer();&lt;/code&gt;. That will act similar to &lt;code&gt;serial.read();&lt;/code&gt;. The only difference is it will fill up the &lt;code&gt;buffer_string_serial&lt;/code&gt; string. You'll have to clear that out after you used all the data so it doesn't get full.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-04-24T21:29:11.230" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1285" PostTypeId="1" AcceptedAnswerId="1286" CreationDate="2014-04-25T01:37:05.237" Score="2" ViewCount="906" Body="&lt;p&gt;So I am working on speeding up a nixie tube speedometer, in this question: , but this brought up another question.  Would having matching baud rates for multiple external devices speed up processes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of the other question the OBD-II device is running at 38400 where the Nixie Tubes are running at 9600.  Since I'm taking the info from the OBD-II connector and doing a little math and sending it to the Nixie Tubes, would it be beneficial to have the same baud rate for both devices?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now... before you down-vote this question for making some sort of &quot;duplicate&quot; this also answers a question about having a &quot;master&quot; serial hub and having communication between different &quot;slave&quot; serial devices.&lt;/p&gt;&#xA;" OwnerUserId="1144" LastActivityDate="2014-04-25T22:30:26.307" Title="Matching Baud Rates" Tags="|arduino-uno|serial|uart|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1286" PostTypeId="2" ParentId="1285" CreationDate="2014-04-25T01:53:27.307" Score="2" Body="&lt;p&gt;It all depends on how often speed is being reported via the OBD-II connection. If the report rate is faster than the update rate of the tubes then yes, increasing the speed of the tube circuit (not necessarily the connection itself) can have an effect (as long as the tubes themselves can keep up, of course). If the speed is being reported slower than the tubes then don't bother unless you have &lt;em&gt;other&lt;/em&gt; reasons for increasing it, since both bit rates are already so much faster than the human mind can see, much less process.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-25T01:53:27.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1287" PostTypeId="2" ParentId="1272" CreationDate="2014-04-25T05:12:10.080" Score="3" Body="&lt;p&gt;Your code could be improved by removing the use of &lt;code&gt;IP&lt;/code&gt; string altogether, and directly calculating its numeric value while characters come in through &lt;code&gt;Serial1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;boolean borrar = false;&#xA;int IP = 0;&#xA;...&#xA;&#xA;void loop() {&#xA;  while (Serial1.available()) { &#xA;    char caracter = Serial1.read(); //Comprobamos el caracter &#xA;    switch(caracter) {&#xA;&#xA;    // NOTE it is better to replace default by the list of all digits...    &#xA;    case '0':&#xA;    case '1':&#xA;    case '2':&#xA;    case '3':&#xA;    case '4':&#xA;    case '5':&#xA;    case '6':&#xA;    case '7':&#xA;    case '8':&#xA;    case '9':&#xA;                if (borrar) { &#xA;                              IP = 0; &#xA;                              lcd.clear();&#xA;                }&#xA;&#xA;                lcd.print(caracter);&#xA;                delay(125);&#xA;                borrar = false;&#xA;&#xA;                IP *= 10;&#xA;                IP += (int) (caracter - '0');&#xA;                break;  &#xA;&#xA;    case '\r':                &#xA;    case 0x0F:&#xA;    case 0x0A:  &#xA;&#xA;                String res = &quot;&quot;;&#xA;                borrar = true;&#xA;                int num= IP;&#xA;                if (num &amp;lt; 127) &#xA;                  res=&quot;Clase A&quot;;&#xA;                if (num == 127) &#xA;                  res=&quot;Direccion reservada&quot;;&#xA;                if (num &amp;gt; 127 &amp;amp;&amp;amp; num &amp;lt; 192)&#xA;                  res=&quot;Clase B &quot;;&#xA;                if (num &amp;gt;= 192 &amp;amp;&amp;amp; num &amp;lt; 224)&#xA;                  res=&quot;Clase C &quot;;&#xA;                if (num &amp;gt;= 224 &amp;amp;&amp;amp; num &amp;lt; 240)&#xA;                  res=&quot;Clase D &quot;;&#xA;                if (num &amp;gt;= 240 &amp;amp;&amp;amp; num &amp;lt; 255)&#xA;                  res=&quot;Clase E &quot;;&#xA;                break;  &#xA;&#xA;  } //fin switch&#xA;&#xA;}//serial disponible&#xA;&#xA;}//fin programa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way would bring you 2 advantages:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a bit faster than working with &lt;code&gt;String&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;no dynamic memory allocation/deallocation (&lt;code&gt;String&lt;/code&gt; does a lot of these) which might lead your program to &lt;strong&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/763/im-using-too-much-ram-how-can-this-be-measured/787#787&quot;&gt;heap fragmentation&lt;/a&gt;&lt;/strong&gt; and eventually crash.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that I have not further refactored your code as I guessed it was just a snippet, not the complete code for your program. Otherwise, I would have performed further refinement like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;remove &lt;code&gt;num&lt;/code&gt; variable since it is the same as &lt;code&gt;IP&lt;/code&gt; now&lt;/li&gt;&#xA;&lt;li&gt;replace &lt;code&gt;res&lt;/code&gt; from &lt;code&gt;String&lt;/code&gt; to &lt;code&gt;const char*&lt;/code&gt; (to further reduce heap fragmentation due to &lt;code&gt;String&lt;/code&gt; usage)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-04-25T05:12:10.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1288" PostTypeId="1" AcceptedAnswerId="1308" CreationDate="2014-04-25T08:05:46.710" Score="4" ViewCount="15661" Body="&lt;p&gt;I am planning to build a device able to detect and tell a server via Wi-Fi if a chair is occupied. How would you do it? And how cheap do you think the device could be?&lt;/p&gt;&#xA;" OwnerUserId="1178" LastEditorUserId="972" LastEditDate="2018-03-14T18:45:44.943" LastActivityDate="2018-03-14T18:45:44.943" Title="Detect and stream if a chair is occupied" Tags="|sensors|wifi|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1289" PostTypeId="2" ParentId="1278" CreationDate="2014-04-25T08:43:37.010" Score="1" Body="&lt;p&gt;The solution to your problem might be to combine &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt; with SoftwareSerial. I haven't done it myself (yet) but I have the same problem as yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial does busy wait for counting time between two bits, so it can't read simultaneously from two ports (some bits could be lost).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AltSoftSerial was created to overcome some of these limitations. It's interrupt-based. Unfortunately, it's harwired for one port (and pins 7 &amp;amp; 8). My understanding is that you can combine it with SoftwareSerial to read from 2 simultaneous ports. Pins 7 &amp;amp; 8 aren't what you need, from the description of the GBoard, but AltSoftSerial is open source, you can change the pin numbers (and possibly some masks) in the source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2014-04-25T08:43:37.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1290" PostTypeId="2" ParentId="1265" CreationDate="2014-04-25T11:51:00.940" Score="3" Body="&lt;p&gt;Stepper would be heavy and battery consuming, as Ignacio says.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pololu makes an encoder for a wheel: &lt;a href=&quot;http://www.pololu.com/product/1217&quot; rel=&quot;nofollow&quot;&gt;http://www.pololu.com/product/1217&lt;/a&gt;, but obviously you can implement this in other ways too.  &lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-04-25T11:51:00.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1291" PostTypeId="2" ParentId="1288" CreationDate="2014-04-25T12:54:16.797" Score="5" Body="&lt;p&gt;I'm not going to answer this directly, because then you wouldn't learn anything! However, here are a few suggestions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a pressure sensor on the seat of the chair or&lt;/li&gt;&#xA;&lt;li&gt;Put a distance sensor (IR or ultrasonic) pointing at the chair.&lt;/li&gt;&#xA;&lt;li&gt;Use the official &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;noreferrer&quot;&gt;Arduino WiFi shield&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="37" LastActivityDate="2014-04-25T12:54:16.797" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1292" PostTypeId="2" ParentId="1288" CreationDate="2014-04-25T13:50:17.587" Score="6" Body="&lt;p&gt;For a soft seat you could sense occupancy with an LED and photo-sensor at opposite ends of a short somewhat flexible tube that gets flexed when the cushion compresses, interrupting the light. That or a microswitch would have to be the cheapest means of sensing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting from there to the server depends a little on how much work you're willing to do, from rolling your own micro-controller+WiFi PCB to purchasing off the shelf parts, which may in turn, depend on whether you need to monitor one chair or a whole auditorium.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-04-25T13:50:17.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1293" PostTypeId="1" AcceptedAnswerId="1345" CreationDate="2014-04-25T15:43:04.290" Score="2" ViewCount="3547" Body="&lt;p&gt;I am currently using an Arduino Mega 2560 to run this stepper motor driver (Big Easy Driver, ROB-11876 from sparkfun) &lt;a href=&quot;https://www.sparkfun.com/products/11876&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11876&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to use the sleep or enable function on this chip to decrease the power consumption when I am not using the motor. I have all the rest of the driver working properly (steps, direction etc.) but when I hook up a wire to either the sleep or enable section and send a respective high or low it doesn't appear to do anything. (Chip works as normal, power consumption stays the same). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested to see that the Arduino is outputting correctly and it seems to be. But other than this I'm kinda at a loss on what might be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions on why this might be or other things to test to try to narrow down the problem?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Found my answer from Sparkfun - see below&lt;/p&gt;&#xA;" OwnerUserId="1182" LastEditorUserId="1182" LastEditDate="2014-04-30T15:56:52.823" LastActivityDate="2014-04-30T15:56:52.823" Title="How to test the sleep / enable function of Stepper Driver?" Tags="|pins|arduino-mega|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1295" PostTypeId="2" ParentId="1251" CreationDate="2014-04-25T17:12:09.500" Score="3" Body="&lt;p&gt;Your best bet would probably be to interface with a colorimeter.  There is a tutorial for an open source colorimeter here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.appropedia.org/Open-source_colorimeter&quot; rel=&quot;nofollow&quot;&gt;http://www.appropedia.org/Open-source_colorimeter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IORodeo also sells a shield:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.iorodeo.com/colorimeter&quot; rel=&quot;nofollow&quot;&gt;http://www.iorodeo.com/colorimeter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vernier sells a colorimeter that may be suitable for your project &amp;amp; Sparkfun sells a shield to interface with Vernier sensors.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a colorimeter doesn't work you would have to use an electrode, which is pretty expensive and has a shelf life.&lt;/p&gt;&#xA;" OwnerUserId="1184" LastActivityDate="2014-04-25T17:12:09.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1296" PostTypeId="2" ParentId="1265" CreationDate="2014-04-25T18:18:22.567" Score="2" Body="&lt;p&gt;As you've discovered, there are a lot of variables involved, so you need &lt;em&gt;some&lt;/em&gt; sort of feedback.  A popular way to do this is with an encoder, but depending on your needs, other kinds of sensors can make do.  For example, if your problem is keeping the robot going in a straight line, an electronic compass can help.  For a line following robot, the line sensors are usually enough.  Range sensors can track your distance.  You get the idea.&lt;/p&gt;&#xA;" OwnerUserId="40" LastActivityDate="2014-04-25T18:18:22.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1297" PostTypeId="2" ParentId="1255" CreationDate="2014-04-25T18:31:59.893" Score="1" Body="&lt;p&gt;Some shields let you use jumpers or something to change the pin assignments, but I don't believe the Seed motor shield does.  What you can use is a &lt;a href=&quot;https://www.sparkfun.com/products/11002&quot; rel=&quot;nofollow&quot;&gt;go-between shield&lt;/a&gt; between the two shields to remap the pins on the top shield.  Then in your code, you just initialize the second instance using different pins.  You just have to make sure the alternate pins have the features you need, like pwm.&lt;/p&gt;&#xA;" OwnerUserId="40" LastActivityDate="2014-04-25T18:31:59.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1298" PostTypeId="1" AcceptedAnswerId="1301" CreationDate="2014-04-25T21:40:44.983" Score="4" ViewCount="130" Body="&lt;p&gt;I recently started messing around with an Arduino and I have made a few &quot;gadgets&quot; using shields. I then wondered how I would go about using things I can't find shields for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One specific thing I want to do is to be able to use the larger e-paper displays from Pervasive Displays (7'' and 10'') but a brief consultation with Google found no Arduino kits or shields. I then looked through the documentation of the timing controller for the 7'' display and found the information required to be able to use it (initiation, sending data to be drawn, opcodes, etc.). I then decided to check the Github repo for the examples for the 2'' displays and they seem to just do what the documentation says to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my observation naive here? Is it really as straightforward as following the documentation? No magic sauce?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I don't have a clue how complex using the 7'' display actually is, I just used it as an example because I had just looked it up...&lt;/p&gt;&#xA;" OwnerUserId="1185" LastActivityDate="2014-04-25T23:00:47.790" Title="How to use components that don't have a shield?" Tags="|shields|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1299" PostTypeId="2" ParentId="1285" CreationDate="2014-04-25T22:30:26.307" Score="0" Body="&lt;p&gt;If you are using different serial ports for each device (eg: using software serial for at least one of them on a Uno, or using separate hardware serial on a Mega2560), then it really doesn't matter whether they use the same baud rate or not.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are somehow multiplexing the same serial port (eg: input only from one device, output only to the other; or some external multiplexing hardware) then there might be a slight gain in not needing to change the baud rate when switching between devices, but probably not noticable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If either or both devices have some option to communicate faster, that might speed up your system - independent of whether they use the SAME rate.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-04-25T22:30:26.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1300" PostTypeId="2" ParentId="1278" CreationDate="2014-04-25T22:56:06.937" Score="0" Body="&lt;p&gt;So you want three serial ports: upload/debug (hardware serial), GSM (software serial) and GPS (software serial).  Unfortunately, two SoftSerial ports are not going to work at the same time (or even send and receive at the same time on one SoftSerial port).  In your current configuration it's not going to be solvable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can wire the GPS to different pins, there are a couple of options to try.  One would be to disconnect the FTDI when running (reconnect to program) so you can use the hardware serial port for either GSM or GPS (probably the former).  If you need some print statements for debugging, you could use SoftSerial or AltSoftSerial (and connect the FTDI differently).  Reconnecting between upload/debug and run phases would be a pain but it comes with the platform you are choosing and the number of serial ports you need; you might be able to wire up a DPDT switch externally to do the switching rapidly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other and perhaps easier approach would be to connect the GPS to pins 8 and 9, and use AltSoftSerial for the GPS; as long as your baud rate to the GSM is high enough that might work.  (SoftSerial for the GSM will turn off interrupts for excessive periods of time at low baud rates).  Using AltSoftSerial makes use of the single 16 bit timer (Timer1), so this won't work if you use any other library which requires Timer1.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-04-25T22:56:06.937" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1301" PostTypeId="2" ParentId="1298" CreationDate="2014-04-25T23:00:47.790" Score="4" Body="&lt;p&gt;Your observation is correct. Everything breaks down to some number of physical connections and some protocol for communicating with the device. Shields and libraries associated with them do most of the work for you, but not everything comes in a shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some common protocols for interfacing with devices, including &lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt;. From a quick peek at the &lt;a href=&quot;http://www.pervasivedisplays.com/products/2inch&quot; rel=&quot;nofollow&quot;&gt;driver interface sheet&lt;/a&gt;, it looks like they're using SPI. Well, your &lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;Arduino already supports that&lt;/a&gt; so you can hit the ground running with this display. You just need to know what commands to send to it, which you can find from the display's datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It looks like the 2&quot; screen requires 3.3V while the 7&quot; one supports up to 7V.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-04-25T23:00:47.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1302" PostTypeId="2" ParentId="1176" CreationDate="2014-04-25T23:31:38.560" Score="1" Body="&lt;p&gt;When you mentions &quot;loud sounds (i.e, a mic reading of ~600)&quot; I'm guessing that means you've successfully connected the mic to an ADC input and you are referring to analog readings, right?  (If not you may need to clarify).  I won't worry about scaling or offset biasing the inputs, assuming you have that part down and you can test the Analog input to detect loudness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Arduino can be dedicated to making this measurement (ie: doesn't need to do anything else while doing it), then the simplest solution might be a loop comparing the ADC input with some threshold you have determined, and using micros() to check the time different.  The micros() function has only 4 uS resolution, but the loop time will add more time than that anyway, and actually the limited bandwidth of your audio signals (speaker and mic both) will make any microsecond level measurement suspect anyway.  So the simple loop might be as accurate as you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int THRESHOLD = 600; // adjust&#xA;const int MINDELAY = 1000;  // adjust&#xA;&#xA;long &#xA;takeMeasurement() {&#xA;    while(analogRead(A4) &amp;lt; THRESHOLD); // wait for first trigger&#xA;    long start = micros();&#xA;    delayMicroseconds(MINDELAY); // let first noise die down&#xA;    while(analogRead(A4) &amp;lt; THRESHOLD); // wait for second trigger&#xA;    return micros() - start;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would call this function when you were ready to take a measurement.  To keep the loop time short (when it's waiting for a loud sound), it has no timeout, so it won't return until it does detect two loud sounds.  Depending on your need, you might need to change that and have an escape from the loops.  There are several ways that might be done:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;test for micros() exceeding some timeout within the loop&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;decrement a counter in the loop and exit if it goes to zero (or if the sound is detected)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;test a flag (volatile byte) in the loop, which gets set by a timer interrrupt&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which is best depends on other aspects of your overall design.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-04-25T23:31:38.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1303" PostTypeId="2" ParentId="1267" CreationDate="2014-04-26T00:08:31.313" Score="2" Body="&lt;p&gt;Your examples of sending input to the Arduino IDE monitor and to Python involve the Arduino sending data via &quot;Serial over USB&quot; convention. However this is not seen by the operating system (Windows, MacOS) as legitimate keyboard/mouse/joystick input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are separate USB conventions (device types) for keyboard/mouse/joystick. Only Arduinos where the USB interface is programmable are able to present those conventions, and some more easily than others, and require understanding some USB client libraries.  The link provided by Chris Stratton has some useful background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A particularly easy way to get into this is with the PJRC Teensy, &lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/&lt;/a&gt;, which comes with libraries and examples that let you do this out-of-the-box. See the &quot;Teensyduino&quot; section of their website for USB Keyboard, Mouse, Joystick and so on. These pages are useful background even if not using Teensy. It has attracted a small following of users interested in this area. Plus the various Teensies are conveniently small boards that fits nicely in some user-interface device you might want to build.&lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-04-26T00:08:31.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1304" PostTypeId="1" AcceptedAnswerId="1306" CreationDate="2014-04-26T21:38:54.610" Score="8" ViewCount="6093" Body="&lt;p&gt;I am creating a wireless sensor using an Attiny85.  I want to send the data to an arduino uno, so I purchased the 315mhz rf link kit from spark fun.  Since the Attiny85 does not have a TX I decided to use the Manchester library however it won't compile on the Attiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the steps from this blog :&#xA;&lt;a href=&quot;http://mchr3k-arduino.blogspot.mx/2012/01/wireless-sensor-node-part-2.html?showComment=1338749638806#c853067277980266192&quot;&gt;http://mchr3k-arduino.blogspot.mx/2012/01/wireless-sensor-node-part-2.html?showComment=1338749638806#c853067277980266192&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;WProgram.h&amp;gt; //otherwise it says it can't find Arduino.h&#xA;    #include &amp;lt;Manchester.h&amp;gt; //include the library to comunicate&#xA;    #define TxPin 2 //the pin that is used to send data&#xA;&#xA; int sensorPin = 4;&#xA; int ledPin = 3;&#xA; int count = 50;&#xA;&#xA; void setup(){&#xA;  pinMode (ledPin, OUTPUT);&#xA;  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84&#xA;  man.setupTransmit(TxPin, MAN_1200); //set transimt pin&#xA;}&#xA;&#xA;void loop(){&#xA;  if (count == 50){&#xA;   digitalWrite (ledPin, HIGH);&#xA;   count = 0;&#xA;   }&#xA;   int data = analogRead(sensorPin);&#xA;   man.transmit(data); //transmits and reads the data&#xA;   delay (100);&#xA;   count ++;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp: In function 'void MANRX_SetupReceive(uint8_t)':&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:366: error: 'TCCR2A' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:366: error: 'WGM21' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:368: error: 'TCCR2B' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:368: error: 'CS21' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:369: error: 'OCR2A' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:379: error: 'TIMSK2' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:379: error: 'OCIE2A' was not declared in this scope&#xA;/Users/joelsimonoff/Documents/Arduino/libraries/MANCHESTER/Manchester.cpp:380: error: 'TCNT2' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="11" LastEditDate="2014-04-26T21:50:46.713" LastActivityDate="2015-01-16T20:08:34.430" Title="Manchester Library Won't Compile for Attiny85" Tags="|programming|arduino-ide|compile|attiny|rf|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1305" PostTypeId="1" CreationDate="2014-04-26T22:28:06.293" Score="-1" ViewCount="1960" Body="&lt;p&gt;I have got Arduino Mega 2560, Arduino WiFi Shield and resistor 1.5K. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now PWM 2 is attached to the resistor then attached GND. 5V is attached between PWM2 and resistor's up point. I want to read the Arduino Mega's A7 analog input point in order to print this value on an Android Phone's web browser but, I get zero value every time surprisingly. It should be like 235, 350 something like integer or float kinds as usual. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to Android Phone's Google Chrome Web Browser Page, why there are too many zeros in the HTML? It should be different from zeros because I have already added a short wire to Analog A7 so as to make an antenna. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A photo of my setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MFCwt.jpg&quot; alt=&quot;My workside&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot of my Android web browser&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tH4Jq.png&quot; alt=&quot;Android Phone Screen&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial Monitor output&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vba5T.png&quot; alt=&quot;Arduino IDE &amp;amp; Serial Monitor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;Connectify-me&quot;;      &#xA;char pass[] = &quot;***&quot;;    &#xA;int status = WL_IDLE_STATUS;&#xA;float PPG = analogRead(A7);&#xA;boolean door_status = false;&#xA;WiFiServer server(80);&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while ( status != WL_CONNECTED) { &#xA;    Serial.print(&quot;Yazdigin SSID araniyor: &quot;);&#xA;    Serial.println(ssid);&#xA;    status = WiFi.begin(ssid, pass);&#xA;    delay(10000);&#xA;  } &#xA;  server.begin();&#xA;  printWifiStatus();&#xA;}&#xA;void loop() {       &#xA;  WiFiClient client = server.available();&#xA;  if (client) {&#xA;    Serial.println(&quot;Deger gonderildi&quot;);&#xA;    Serial.print(PPG);&#xA;    while (client.connected() &amp;amp; client.available()) {&#xA;          client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;li&amp;gt;&quot;);&#xA;          client.print(PPG);  //The value should different from zeros but everytime 0&#xA;          client.println(&quot;&amp;lt;/li&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;      }&#xA;    }&#xA;    delay(3000);&#xA;      client.stop();&#xA;      Serial.println(&quot;client disonnected&quot;);&#xA;  }&#xA;  void printWifiStatus() {&#xA;  Serial.print(&quot;Baglandigimiz SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Addressi browserda ac: &quot;);&#xA;  Serial.println(ip);&#xA;  long rssi = WiFi.RSSI();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="6936" LastEditDate="2015-07-29T18:51:21.747" LastActivityDate="2015-07-29T18:51:21.747" Title="Arduino Mega &amp; WiFi Shield; why web server every time says my A7 pin reads 0V?" Tags="|arduino-mega|shields|wifi|web-server|web-service|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1306" PostTypeId="2" ParentId="1304" CreationDate="2014-04-26T22:38:22.607" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/damellis/attiny/&quot;&gt;attiny&lt;/a&gt; is missing an option required to allow the Manchester library to function properly on ATtinyX5 devices, specifically definition of &lt;code&gt;__AVR_ATtinyX5__&lt;/code&gt; when a device is selected. In fact, it's missing quite a few things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The package I use for ATtinyX5 support is &lt;a href=&quot;http://code.google.com/p/arduino-tiny/&quot;&gt;arduino-tiny&lt;/a&gt;. I have verified that it defines that symbol properly. I recommend that you dump your current support package and install arduino-tiny instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-26T22:38:22.607" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="1307" PostTypeId="2" ParentId="1305" CreationDate="2014-04-26T22:49:55.700" Score="2" Body="&lt;p&gt;The capacitor in the sample-and-hold circuit in the ADC frontend is tied to ground and it is &lt;em&gt;very&lt;/em&gt; leaky. Unless you have a low or medium impedance output connected to it, you will always read the ground value. An antenna is a &lt;em&gt;very&lt;/em&gt; high impedance device.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-26T22:49:55.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1308" PostTypeId="2" ParentId="1288" CreationDate="2014-04-27T01:38:18.417" Score="6" Body="&lt;p&gt;Oh wow, so many ways you could do this.  To start, get an arduino with a wifi shield to transmit and read data.  Familiarize yourself with how the arduino works with the shield, and how to read it on the other end.  Then it's time to look at sensors you could use.  Here's a couple ideas, I would recommend using more than one and cross-checking:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Force sensor on base of chair: Can tell you how much weight is on a chair (Sparkfun SEN-09376)&lt;/li&gt;&#xA;&lt;li&gt;IR or sonic sensor on back of chair to detect distance (&lt;a href=&quot;https://www.sparkfun.com/products/242&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Vibration/shock sensor to detect if someone has sit down (&lt;a href=&quot;https://www.sparkfun.com/products/9197&quot; rel=&quot;noreferrer&quot;&gt;example&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Load sensor: literally a scale in a sensor. (Sparkfun SEN-10245)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The optimal solution if you had the cash would be to put all of them on the chair and use the arduino to compute all of the sensor values into one boolean.  However, if you only could have one sensor I would recommend the load sensor which would definitely be the most reliable of all the examples I gave.&lt;/p&gt;&#xA;" OwnerUserId="1194" LastActivityDate="2014-04-27T01:38:18.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1309" PostTypeId="1" AcceptedAnswerId="1310" CreationDate="2014-04-27T10:39:30.683" Score="1" ViewCount="392" Body="&lt;p&gt;Is it possible to cinnect the Arduino with a fischertechnik TX Controller? Maybe with I²C, but i want to use I²C for something else on the arduino. So are there multiple I²C Ports on the Arduino (I haven't got one yet)?&lt;/p&gt;&#xA;" OwnerUserId="1197" LastActivityDate="2014-04-27T11:17:30.260" Title="Connect Arduino with fischertechnik TX Controller" Tags="|robotics|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1310" PostTypeId="2" ParentId="1309" CreationDate="2014-04-27T11:17:30.260" Score="0" Body="&lt;p&gt;As described in the &lt;a href=&quot;http://arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire library&lt;/a&gt; that brings supports I²C support to Arduino, except for the &lt;strong&gt;DUE&lt;/strong&gt; that has 2 pairs of pins for 2 I²C buses, &lt;strong&gt;other Arduino boards support one I²C connection&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this is when you want to use hardware facilities of ATMEL chips that these limitations apply; there is a &lt;a href=&quot;http://playground.arduino.cc/Main/SoftwareI2CLibrary&quot; rel=&quot;nofollow&quot;&gt;software I²C library&lt;/a&gt; exists that allows using other pins for I²C. One major drawback, though, is that it is very slow; not sure if this is a problem in your situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important thing though: the principle of I²C is to be able to plug several slave devices (more than 100) to one master device. In general, Arduino is the master device, but the Wire library can be used as master or slave. Wouldn't that fit your requirements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this situation, you could just use the same I²C bus for everything, including connection to Fischertechnik TX controller.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-04-27T11:17:30.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1311" PostTypeId="2" ParentId="1305" CreationDate="2014-04-27T16:19:01.773" Score="2" Body="&lt;p&gt;You are reading the input pin &lt;code&gt;float PPG = analogRead(A7);&lt;/code&gt; only in the startup code of your program. Move that into the loop to have it updated before using it.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-27T16:19:01.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1312" PostTypeId="1" AcceptedAnswerId="1313" CreationDate="2014-04-27T17:35:01.970" Score="11" ViewCount="1575" Body="&lt;p&gt;I have started to play with and arduino UNO quite recently (without any prior experience with micro-controllers). I would like to use emacs instead of the IDE, and I'd also like to know what the IDE does under the hood, in order to be able to write my own makefile. The tutorials I've found are either outdated, or are presented as a series of steps without any explanation. I'd appreciate it if someone could explain to me how the whole compliation/linking/upload process works using gcc-avr and avr-dude, and how it is used by the IDE.&lt;/p&gt;&#xA;" OwnerUserId="1200" LastEditorUserId="37523" LastEditDate="2019-11-19T21:38:01.277" LastActivityDate="2021-02-15T19:56:40.403" Title="Understanding the compilation/linking/upload process (so I don't have to use the IDE)" Tags="|arduino-uno|avrdude|ide|avr-gcc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1313" PostTypeId="2" ParentId="1312" CreationDate="2014-04-27T17:53:51.597" Score="13" Body="&lt;p&gt;If you want an &lt;em&gt;exact&lt;/em&gt; duplication of what the IDE does but want it driven from the command line, that's what &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;noreferrer&quot;&gt;Ino&lt;/a&gt; is for. The full Arduino build process involves copying a lot of files from a lot of places, and is generally not trivial to duplicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're ready to let go of .ino files and the Arduino libraries, you get a much simpler toolset. avr-gcc compiles, avrdude uploads, and you're done. Here's one of my makefiles from a simple project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CC=avr-gcc&#xA;CXX=avr-c++&#xA;CXXFLAGS=-Wall -Wextra -mmcu=atmega1284p -Os&#xA;CFLAGS=$(CXXFLAGS)&#xA;BINARY=ledmatrix&#xA;OBJECTS=&#xA;&#xA;all: $(BINARY)&#xA;↹@avr-size $&amp;lt;&#xA;&#xA;$(BINARY): $(OBJECTS)&#xA;&#xA;clean:&#xA;↹@rm -f $(BINARY) $(BINARY).hex $(OBJECTS)&#xA;&#xA;upload: $(BINARY).hex&#xA;↹@avrdude -c usbasp -p m1284p -U flash:w:$&amp;lt;:i&#xA;&#xA;%.hex: %&#xA;↹@avr-objcopy -j .text -j .data -O ihex $&amp;lt; $@&#xA;&#xA;.PHONY: all clean upload&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If copying-and-pasting, be sure to replace all &quot;↹&quot; with tab characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created a &lt;a href=&quot;https://github.com/ivazqueznet/avrbuildsys&quot; rel=&quot;noreferrer&quot;&gt;repository with my buildsystem on Github&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-12-17T06:32:56.670" LastActivityDate="2015-12-17T06:32:56.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1314" PostTypeId="1" AcceptedAnswerId="1315" CreationDate="2014-04-27T19:12:11.227" Score="4" ViewCount="1642" Body="&lt;p&gt;I'm working on building my first robot. this is my first foray into DIY electronics. I already have an Arduino Uno, and I have ordered the &lt;a href=&quot;http://www.pololu.com/product/114&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tamiya double gearbox&lt;/a&gt; here. My goal is to control the gearbox to move the robot, but from what I've already read, I need to have something between the Ardiuno and the motors. It seems like people have trouble doing that because the included motors are low voltage, so the Arduino motor shield won't easily work.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a clear solution to making this thing run, in the simplest way possible. One thing I'm considering is replacing the motors in the gearbox &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/B00JR6IY4M&quot; rel=&quot;nofollow noreferrer&quot;&gt;with these motors&lt;/a&gt;. If I do that, am I right in thinking I could run them from the Arduino motor shield? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a simpler (or cheaper!) way of making it work than being stuck on the Arduino Motor shield, I'm game for that. I've just gravitated to that solution because it seems simpler as an electronics noob. (I haven't bought that shield yet.) But I'm really open to other solutions, so if you can, I'd appreciate the advice!  &lt;/p&gt;&#xA;" OwnerUserId="1202" LastEditorUserId="26916" LastEditDate="2017-11-04T18:44:41.387" LastActivityDate="2018-08-22T13:59:18.840" Title="How can I connect the Tamiya double gearbox to Arduino Uno?" Tags="|arduino-uno|shields|motor|arduino-motor-shield|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1315" PostTypeId="2" ParentId="1314" CreationDate="2014-04-27T19:47:05.840" Score="3" Body="&lt;p&gt;Here's what I've found about both the motor shield and the motors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Motors are 3-6V and will use a lot of amperage. &lt;strong&gt;This may be a problem with a mobile robot.&lt;/strong&gt; You'll have to figure out a power source that can provide 4+ amps... on battery power that's a lot. Personally, I would go with a continuous rotation servo for a compact, light robot.&lt;/li&gt;&#xA;&lt;li&gt;Motor sheild can provide 2x 2A channels at 5-12 V (&lt;a href=&quot;http://www.makershed.com/Official_Arduino_Motor_Shield_p/mksp12.htm?gclid=CIyNjIKygb4CFe5aMgodpQcAuw&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;) using the two &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; terminals on the bottom left side of the shield. You must connect external power, because USB can't provide enough power. I can't find if the motor shield will limit current if it goes over, but if you do use the gearbox, I'd recommend another route for control that's 1/6rd the price.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.pololu.com/product/2130&quot; rel=&quot;nofollow noreferrer&quot;&gt;This chip was recommended by Pololu on the product page.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/adDy1.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Time to whip out your soldering iron!&lt;/strong&gt; Really, soldering is a great investment and you'll get to a point soon where you'll &lt;em&gt;need&lt;/em&gt; one; there will be no other alternative. Luck for you, you only have to solder 16 joints. Headers are included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diagrams from Pololu's site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/t7iEx.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vwiM4.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DyuR1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DyuR1.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&#xA;  *(Click to enlarge ^^^)**&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*I added a little text to this image.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-04-27T19:47:05.840" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1318" PostTypeId="1" AcceptedAnswerId="1319" CreationDate="2014-04-28T02:18:55.963" Score="7" ViewCount="3943" Body="&lt;p&gt;A quick question about microcontroller digital level on I/O pins. I have a photo interrupter which is powered at 3.3V which is interfaced to Arduino UNO running at 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For microcontroller to detect high or low level is determined by signal higher than 5V*(2/3) = 3.33V is high and signal lower than 5V*(1/3) is low. What I don't understand is that arduino is able to detect the level change from the photo interrupter. Doesn't the supply on pins have to be greater than (2/3) or Vcc in order for it to detect logic high? The circuit works and I am able to count pulses from the interrupter but I want to know why that works considering the photo interrupt only gets about 3.23V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please clarify&lt;/p&gt;&#xA;" OwnerUserId="1213" OwnerDisplayName="David Norman" LastEditorUserId="1162" LastEditDate="2014-04-28T07:46:55.523" LastActivityDate="2014-04-28T12:55:58.287" Title="Level detection of 3.3V from 5V arduino" Tags="|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1319" PostTypeId="2" ParentId="1318" CreationDate="2014-04-28T02:39:11.007" Score="8" Body="&lt;p&gt;You've... misread the datasheet. The '328 input high voltage (V&lt;sub&gt;IH&lt;/sub&gt;) for most pins is 0.6V&lt;sub&gt;CC&lt;/sub&gt; minimum for devices with a 2.4-5.5V supply. This means that a 5V device has a 3V threshold.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-04-28T02:39:11.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1321" PostTypeId="1" AcceptedAnswerId="1326" CreationDate="2014-04-28T05:27:02.187" Score="9" ViewCount="61665" Body="&lt;p&gt;I have an Arduino Uno R3 board and after some time not in use it seems to have corrupted. My code is below, basically I want to rotate a servo 90 degrees every 12 hours but as soon as I plug it in the servo starts rotating non-stop. Have tried multiple delay steps and shortening and lengthening the write but the same effect happens.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;&#xA;&#xA;void setup {&#xA;  myservo.attach(10);&#xA;}&#xA;&#xA;void loop() {&#xA;  myservo.write(90); &#xA;  delay(3600000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1215" LastEditorUserId="71575" LastEditDate="2022-07-06T15:52:00.703" LastActivityDate="2023-10-25T17:10:21.433" Title="Servo won't stop rotating" Tags="|arduino-uno|continuous-servo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1322" PostTypeId="2" ParentId="707" CreationDate="2014-04-28T08:52:37.410" Score="2" Body="&lt;p&gt;Your code includes the duration of the output in subsequent measurements. Thus depending on the length of the output you will measure different times. This can be fixed by formating to fixed length output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next issue is that the UNO has a very poor timebase. Have a look here for a &lt;a href=&quot;http://blog.blinkenlight.net/experiments/dcf77/dcf77-scope/&quot; rel=&quot;nofollow&quot;&gt;comparison of different Arduino types vs. the DCF77 time reference.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion: if you need precise timing either get an Arduino with crystal or go for an RTC. I can highly recommend DS3231 / DS3232 RTCs since these usually achieve 2 ppm accuracy out of the box.&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2014-04-28T08:52:37.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1323" PostTypeId="1" CreationDate="2014-04-28T09:51:39.767" Score="9" ViewCount="1389" Body="&lt;p&gt;I'm trying to implement a card reader (i.e. credit cards) for shopping purposes, and AFAIK those cards are ISO 14443-A compliant (Mifare Classic 1K). I already made an Android app that can send custom APDU to read specific sectors by using raw SendBytes().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I need to build a circuit with a custom antenna, I chose Arduino-uno with a NFC module (was thinking about StrongLink SL013), I wanted to know if it's possible to send raw bytes and receive the response from the tag. I only found some higher-level implementation (readSector, writeSector and so on).&lt;/p&gt;&#xA;" OwnerUserId="1220" LastEditorUserId="46" LastEditDate="2014-04-28T11:51:07.023" LastActivityDate="2015-10-27T23:24:05.020" Title="RFID/NFC (13.56 MHz), is it possible to send raw bytes and receive response?" Tags="|arduino-uno|rf|rfid|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1324" PostTypeId="2" ParentId="1318" CreationDate="2014-04-28T12:47:44.907" Score="4" Body="&lt;p&gt;The designed threshold of the '328 logic is 45% of Vcc for all supply voltages, except the tolerance reduces from +/-25% of Vcc {&amp;lt;3V} to +/-15% of Vcc{&gt;3}  This tolerance is due to temperature and process variation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that the smaller the difference between the &quot;actual&quot; threshold and your input is your immunity to noise and it will work if there is low noise. Thus 45+15% = 60%* 5V=3V is guaranteed.  What is not guaranteed, is the accuracy of your 5V regulator which if say 10% high will increase the threshold 10% above  3V or 3.3V.   So then 3.1 would not be guaranteed. So ensure accuracy of 5 V is below 5.04 minus your noise immunity requirements.&lt;/p&gt;&#xA;" OwnerUserId="1224" LastEditorUserId="1224" LastEditDate="2014-04-28T12:55:58.287" LastActivityDate="2014-04-28T12:55:58.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1325" PostTypeId="1" CreationDate="2014-04-28T15:58:36.257" Score="2" ViewCount="398" Body="&lt;p&gt;I have very weird problem with a library I am creating. The library will be used to communicate between Arduino modules using XBee Series 1 modules. Library is very simple wrapper library around Arduino XBee library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have one function that reads received packet and sends it back. At the moment it is implemented as a simple &quot;echo&quot; service - the function just displays the data received and sends it back to per-defined address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I have three versions of this function, out of which one is not working.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A function taking no arguments: void processPacket()&lt;/li&gt;&#xA;&lt;li&gt;A function taking structure as a value as an argument: void processPacket(valuesStruct valuesStructData) - THIS VERSION OF THE FUNCTION IS NOT WORKING!&lt;/li&gt;&#xA;&lt;li&gt;A function taking pointer to the structure as an argument: void processPacket(valuesStruct* valuesStructData)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this moment I noticed strange behavior in the 2nd version of the function. I do nothing with the passed argument - the content of all three functions is &lt;strong&gt;the same.&lt;/strong&gt; In 2nd case the function reads wrong values from received XBee packet. In the 1st and 3rd case the function performs correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ExampleLib.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef ExampleLib_h&#xA;#define ExampleLib_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;XBee.h&amp;gt;&#xA;&#xA;#define ADDRESS_BROADCAST 0xffff&#xA;#define ADDRESS_PC 0x3333&#xA;&#xA;typedef struct&#xA;  {&#xA;    int valA;&#xA;    int valB;&#xA;    int valC;&#xA;  } valuesStruct;&#xA;&#xA;class ExampleLib&#xA;{&#xA;public:&#xA;    ExampleLib();&#xA;    void setSerial(Stream &amp;amp;serial);&#xA;    boolean tryReceivePacket();&#xA;    void processPacket();&#xA;    // THIS FUNCTION IS NOT WORKING!&#xA;    void processPacket(valuesStruct valuesStructData);&#xA;    void processPacket(valuesStruct* valuesStructData);&#xA;private:&#xA;    XBee xbee;&#xA;    Rx16Response rx16;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ExampleLib.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value read in line &lt;code&gt;byte* packetData = rx16.getData();&lt;/code&gt; is wrong when we trigger &lt;code&gt;processPacket(valuesStruct valuesStructData)&lt;/code&gt; function. In other cases the behavior is correct.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;XBee.h&amp;gt;&#xA;#include &quot;ExampleLib.h&quot;&#xA;&#xA;ExampleLib::ExampleLib()&#xA;{&#xA;    xbee = XBee();&#xA;    rx16 = Rx16Response();&#xA;}&#xA;&#xA;void ExampleLib::setSerial(Stream &amp;amp;serial)&#xA;{&#xA;    xbee.setSerial(serial);&#xA;}&#xA;&#xA;boolean ExampleLib::tryReceivePacket()&#xA;{&#xA;    xbee.readPacket();&#xA;&#xA;  if (xbee.getResponse().isAvailable()) {&#xA;    // got something&#xA;&#xA;    if (xbee.getResponse().getApiId() == RX_16_RESPONSE) {&#xA;      // got a rx packet&#xA;&#xA;      xbee.getResponse().getRx16Response(rx16);&#xA;      return true;&#xA;    } &#xA;    else {&#xA;      return false;&#xA;    }&#xA;  } &#xA;  else if (xbee.getResponse().isError()) {&#xA;    //nss.print(&quot;Error reading packet.  Error code: &quot;);  &#xA;    //nss.println(xbee.getResponse().getErrorCode());&#xA;    // or flash error led&#xA;    return false;&#xA;  } &#xA;&#xA;  return false;&#xA;}&#xA;void ExampleLib::processPacket()&#xA;{&#xA;  byte* packetData = rx16.getData();&#xA;  byte dataLength = rx16.getDataLength();&#xA;  Serial.print(&quot;START L:&quot;);&#xA;  Serial.println(dataLength);&#xA;  for (int i = 0; i &amp;lt; dataLength; i++) { &#xA;    Serial.print(packetData[i]);&#xA;    Serial.print(&quot; - &quot;); &#xA;  }&#xA;  Serial.println(&quot;END&quot;);&#xA;&#xA;  //16-bit addressing: Enter address of remote XBee, typically the coordinator&#xA;  Tx16Request tx = Tx16Request(ADDRESS_PC, packetData, sizeof(packetData));&#xA;  xbee.send(tx);&#xA;}&#xA;&#xA;void ExampleLib::processPacket(valuesStruct valuesStructData)&#xA;{&#xA;  processPacket();&#xA;}&#xA;&#xA;void ExampleLib::processPacket(valuesStruct* valuesStructData)&#xA;{&#xA;  processPacket();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino sketch&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;#include &amp;lt;ExampleLib.h&amp;gt;&#xA;&#xA;ExampleLib exampleLibObj = ExampleLib();&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  exampleLibObj.setSerial(Serial);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  boolean isPacketReceived = exampleLibObj.tryReceivePacket();&#xA;&#xA;  if (isPacketReceived) {&#xA;    // leave only one section, the rest should be commented&#xA;&#xA;    //Section 1: working&#xA;    exampleLibObj.processPacket();&#xA;&#xA;    //Section 2: not working&#xA;//    valuesStruct test;&#xA;//    test.valA = 0;&#xA;//    test.valB = 0;&#xA;//    test.valC = 0;&#xA;//    exampleLibObj.processPacket(test);&#xA;&#xA;    //Section 3: working&#xA;//  valuesStruct* test;&#xA;//  test-&amp;gt;valA = 0;&#xA;//  test-&amp;gt;valB = 0;&#xA;//  test-&amp;gt;valC = 0;&#xA;//  exampleLibObj.processPacket(test);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am really puzzled why in this one case function is performing differently. Looking forward to any suggestions to that issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1228" LastActivityDate="2014-05-06T13:32:08.350" Title="XBee, external libraries and passing structures as arguments" Tags="|c++|library|xbee|struct|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1326" PostTypeId="2" ParentId="1321" CreationDate="2014-04-28T18:26:53.427" Score="8" Body="&lt;p&gt;I suppose you are using a continuous servo otherwise you wouldn't be able to make it turn 90° more than twice (a normal servo has a varying angle of only 180°).&lt;/p&gt;&#xA;&lt;p&gt;Now if you are using a continuous servo, you have to be aware that the value you pass to &lt;code&gt;myservo.write()&lt;/code&gt; does not represent an angle anymore!&lt;/p&gt;&#xA;&lt;p&gt;With a continuous servo, the value passed to &lt;code&gt;myservo.write()&lt;/code&gt; now means a speed of rotation where, but the range of acceptable values is the same as for a normal servo, i.e. &lt;code&gt;[0; 180]&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; means max speed clockwise&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;90&lt;/code&gt; means no motion&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;180&lt;/code&gt; means max speed counter-clockwise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now if you want to turn the servo exactly 90°, then you must know the max speed of the servo, and from that, compute the time during which you must let it turn:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Start turning clockwise&#xA;myservo.write(0);&#xA;// Go on turning for the right duration&#xA;delay(TURN_TIME);&#xA;// Stop turning&#xA;myservo.write(90);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The problem here is to compute &lt;code&gt;TURN_TIME&lt;/code&gt;. For this, you must check the datasheet of your servo.&lt;/p&gt;&#xA;&lt;p&gt;On my own servo, a &lt;a href=&quot;http://www.feetechrc.com/product/analog-servo/micro-1-3kg-cm-360-degree-continuous-rotation-servo-fs90r/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Feetech Micro 1.3kg Continuous Rotation Servo FS90R&lt;/a&gt;, the max speed is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0.12s/60° when powered with 4.8V&lt;/li&gt;&#xA;&lt;li&gt;0.10s/60° when powered with 6V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;However, with the Arduino UNO, the supplied voltage should be &lt;strong&gt;exactly 5V, neither 4.8V, nor 6V&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If we take a linear approximation, then we can apply the following formula to find out the speed &lt;code&gt;T&lt;/code&gt; (in &lt;strong&gt;s/60°&lt;/strong&gt;):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;T = (0.12 - 0.10) * (V - 4.8) / (4.8 - 6.0) + 0.12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Hence, for 5V, we can take it for granted that the max speed should be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;T = (0.12 - 0.10) * (5.0 - 4.8) / (4.8 - 6.0) + 0.12 = 0.116667&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since we need 90°, this means we must run the servo at its max speed during:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;T' = T * 1.5 = 0.175s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Hence we now have the following program:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define TURN_TIME 175&#xA;&#xA;Servo myservo;&#xA;&#xA;void setup {&#xA;    myservo.attach(10);&#xA;    // Initially the servo must be stopped &#xA;    myservo.write(90);&#xA;}&#xA;&#xA;void loop() {&#xA;    // Start turning clockwise&#xA;    myservo.write(0);&#xA;    // Go on turning for the right duration&#xA;    delay(TURN_TIME);&#xA;    // Stop turning&#xA;    myservo.write(90);&#xA;&#xA;    // Wait for 12h&#xA;    delay(12 * 3600 * 1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Of course, you will need some experiments to find the &lt;strong&gt;exact&lt;/strong&gt; right values; you may also find out that the servo may be sensitive to noise and even when it should not move (value = &lt;code&gt;90&lt;/code&gt;), it does move (not fast, but still it moves).&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="92669" LastEditDate="2023-10-25T17:10:21.433" LastActivityDate="2023-10-25T17:10:21.433" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="1327" PostTypeId="1" CreationDate="2014-04-28T18:44:01.620" Score="1" ViewCount="914" Body="&lt;p&gt;I'm trying to set up an Arduino Cellular Shield SM5100B to send SMS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino UNO R2&lt;/li&gt;&#xA;&lt;li&gt;SM5100B&lt;/li&gt;&#xA;&lt;li&gt;&quot;Movistar&quot; SIM Card (Chile)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've uploaded a code similar to the one described &lt;a href=&quot;http://www.instructables.com/id/Arduino-Cellular-Shield-Tutorial/?lang=en&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, but when communication is supposed to star it cannot find a network. I suspect the problem is I haven't setup correctly the GSM band. But when I issue the command (AT+SBAND=7, same as in the US), it doesn't respond. How can I check in what band I'm on? And change the band?&lt;/p&gt;&#xA;" OwnerUserId="1229" LastEditorUserId="220" LastEditDate="2014-04-29T01:54:07.060" LastActivityDate="2014-06-05T13:48:37.093" Title="Set up an Arduino Cellular Shield SM5100B" Tags="|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1328" PostTypeId="1" CreationDate="2014-04-28T19:59:16.433" Score="1" ViewCount="220" Body="&lt;p&gt;I have a cute robot built on Arduino Uno and Ardumoto, and I am trying to reverse engineer it first, and to add some new sensors afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am stuck at how to deal with its program. I don't have the source code but I do not want to loose the program, yet in order to reverse engineer it I must write my own code and see if I can make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware, I am a n00b to microcontrolers, and pretty lame to electronics (full of enthusiasm though).&lt;/p&gt;&#xA;" OwnerUserId="1230" LastActivityDate="2014-04-28T19:59:16.433" Title="is it possible to backup an uploaded program?" Tags="|arduino-uno|uploading|bootloader|" AnswerCount="0" CommentCount="1" ClosedDate="2014-04-28T20:42:03.633" ContentLicense="CC BY-SA 3.0" />
  <row Id="1329" PostTypeId="1" AcceptedAnswerId="1420" CreationDate="2014-04-28T23:41:49.340" Score="11" ViewCount="38402" Body="&lt;p&gt;I am working on a project for my local Makerspace, we have limited budget so I was hoping to use the RFID-RC522 el'cheap'o RFID/NFC readers on eBay, I received a couple of SPI based boards, they work, however the code examples for them are limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found several different libraries and settled on this one: &lt;a href=&quot;https://github.com/ljos/MFRC522&quot;&gt;https://github.com/ljos/MFRC522&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trouble is that all the code available online seem to spawn from some Chinese guys Python code that people have translated, and hacked into an Arduino library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code works, but Mifare cards are meant to have 4, 7 or 10 byte UIDs and the example/library is returning a 5 byte serial number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no documentation and the &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC500.pdf&quot;&gt;NXP datasheet&lt;/a&gt; is incomprehensible... Additionally it seems to work with most cards, but it doesn't work with Mastercard PayWave cards which conform to the ISO 14443 standard. The more expensive RDM880 reader which is based on the MFRC500 works fine and has a nice library but the cost makes the implementation impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can someone help me to get this NXP MFRC522 based unit reading the UID from all ISO 14443 cards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;#define RFID_SS  10&#xA;#define RFID_RST 5&#xA;&#xA;MFRC522 rfid( RFID_SS, RFID_RST );&#xA;&#xA;void setup() {&#xA;  SPI.begin();&#xA;  Serial.begin(115200);&#xA;  rfid.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  byte data[MAX_LEN];&#xA;  byte uid[5];&#xA;&#xA;  if ( rfid.requestTag( MF1_REQIDL, data ) == MI_OK ) {&#xA;    if ( rfid.antiCollision( data ) == MI_OK ) {&#xA;      memcpy( uid, data, 5 );&#xA;      for ( int i = 0; i &amp;lt; 5; i++ ) {&#xA;        Serial.print( uid[i], HEX );&#xA;        Serial.print( ' ' );&#xA;      }&#xA;      Serial.println();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2024-01-10T15:34:54.710" Title="How do I use RFID-RC522 with an Arduino?" Tags="|rfid|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1331" PostTypeId="2" ParentId="910" CreationDate="2014-04-29T09:32:03.897" Score="2" Body="&lt;p&gt;I've finally found that when the MCU  to which Arduino is talking to was initialized, it would send spurious data to the Serial - I guess it would start first with a lower baud rate, and then switch to the programmed baud rate of 115200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, I had to &lt;code&gt;flush&lt;/code&gt; the Arduino serial RX before sending any data. So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte streamReadResponse;&#xA;Serial1.begin(115200);&#xA;Serial1.setTimeout(9000);&#xA;while (Serial1.read() &amp;gt;= 0)&#xA;           ; // do nothing&#xA;Serial1.print(cmd);&#xA;Serial1.print('\r');&#xA;Serial1.flush();  //wait for all the data to be sent to the serial&#xA;streamReadResponse = Serial1.readBytesUntil('&amp;gt;', data, dataLength);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="794" LastActivityDate="2014-04-29T09:32:03.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1332" PostTypeId="1" AcceptedAnswerId="1335" CreationDate="2014-04-29T12:16:21.570" Score="2" ViewCount="3046" Body="&lt;p&gt;I am tracking a bug in the &lt;a href=&quot;https://github.com/reprappro/Marlin&quot; rel=&quot;nofollow&quot;&gt;Marlin&lt;/a&gt; source code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just for those who is not familiar with Reprap 3D printer and G-code: Marlin is firmware that controls a &lt;a href=&quot;https://en.wikipedia.org/wiki/RepRap_Project&quot; rel=&quot;nofollow&quot;&gt;RepRap&lt;/a&gt; 3D printer. It receives G-code from a host computer (or read from SD card). Here the important thing is that if you send the &quot;M114&quot; command, it would report information about axis positions. Here, I extended this command to make it print some internal variable as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Marlin.ino file there is a line that says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int extrudemultiply=100; //100-&amp;gt;1 200-&amp;gt;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However my RepRap keeps extruding (and worse, ejecting back) a huge amount of filament. So I added some debug output for &lt;code&gt;M114&lt;/code&gt; command to output this value. It turns out this value is not the default value, 100, but something like 12374.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought somewhere inside the &lt;code&gt;setup()&lt;/code&gt; function this value might be changed. So I defined another variable,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int orig_extrudemultiply = 100;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then at the first line of &lt;code&gt;setup()&lt;/code&gt; function, I added the following line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;orig_extrudemultiply = extrudemultiply;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, I output this value for the &lt;code&gt;M114&lt;/code&gt; command. Still, it is not 100. So it looks like the default value is not effective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I have experience in C programming, I am new to Arduino development. How is a global variable being initialized in Arduino? In my case, what is the proper way to initialize this value?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Versioning&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally posted the official &lt;a href=&quot;https://github.com/ErikZalm/Marlin&quot; rel=&quot;nofollow&quot;&gt;Marlin&lt;/a&gt; link for the reference. However,&#xA;the version I actually use is &lt;a href=&quot;https://github.com/reprappro/Marlin&quot; rel=&quot;nofollow&quot;&gt;this fork&lt;/a&gt; from the RepRap Pro team. I was just following the &lt;a href=&quot;http://reprap.org/wiki/Melzi#Melzi_Arduino_Pin_Numbers&quot; rel=&quot;nofollow&quot;&gt;Melzi&lt;/a&gt; entry of the RepRap wiki, because my board is Melzi. I am not sure whether the latest version of Marlin works for my board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further details&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the commenter said, the first thing I thought of was memory corruption. So I wanted to narrow the problem down. Since that value is configurable through &lt;code&gt;M302 SXXX&lt;/code&gt; command, I tested this command, and it works without difficulty. This means there is nothing in the &lt;code&gt;loop&lt;/code&gt; function or the &lt;a href=&quot;https://en.wikipedia.org/wiki/Interrupt_handler&quot; rel=&quot;nofollow&quot;&gt;ISRs&lt;/a&gt; can affect this value when it is running stably. So I consider the problem must be in the &lt;code&gt;setup&lt;/code&gt; function or earlier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further tests shows that setting this value at the end of &lt;code&gt;setup&lt;/code&gt; or even at the beginning of &lt;code&gt;setup&lt;/code&gt; still works fine. This means the &lt;code&gt;setup&lt;/code&gt; function may not be the problematic one. The test in &quot;The Problem&quot; session was the last step, which, in my opinion, means the course of the problem must being run before entering &lt;code&gt;setup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further examination shows that although it looks like it works when I set the default value in the first line of &lt;code&gt;setup()&lt;/code&gt;, but that it is just luckily being 100. So once I add more padding variables it stops working until I move the default setting after the following line in &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EEPROM_RetrieveSettings(); // Loads data from EEPROM if available&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, since I &lt;code&gt;grep&lt;/code&gt;ed for &lt;code&gt;extrudemultiply&lt;/code&gt; before any test, and I didn't figure out this function, this function should not change this value. I guess there is some data overflow inside this function, so the value was changed expectationally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got to figure out what is wrong in this function.&lt;/p&gt;&#xA;" OwnerUserId="1238" LastEditorUserId="510" LastEditDate="2015-03-26T20:00:04.793" LastActivityDate="2015-03-26T20:00:04.793" Title="Default value of global variables is not set" Tags="|programming|variables|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1333" PostTypeId="2" ParentId="1288" CreationDate="2014-04-29T15:19:59.803" Score="4" Body="&lt;p&gt;You could use &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow&quot;&gt;the awesome CapSense-Library&lt;/a&gt;. Additionally to the Library you only need a thin piece of conducting material e.g. aluminium foil and two pins on your arduino. The only thing you have to do is experiment with different resistors to reliably distinguish between someone sitting on the chair or not. Advantages of this method are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;virtually no costs at all &lt;/li&gt;&#xA;&lt;li&gt;easy to implement&lt;/li&gt;&#xA;&lt;li&gt;not subject to wear and    tear&lt;/li&gt;&#xA;&lt;li&gt;should work with any kind of chair independent of material e.g.&lt;br&gt;&#xA;hard or soft surface&lt;/li&gt;&#xA;&lt;li&gt;consumes next to no power (I assume the whole device runs on battery since it's attached to a movable chair)&lt;/li&gt;&#xA;&lt;li&gt;could even sense a person in the process of seating her-/himself and enable you to start the music faster (my stereo for example takes a second or so to start up)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1242" LastEditorUserId="1242" LastEditDate="2014-04-29T18:06:37.920" LastActivityDate="2014-04-29T18:06:37.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1334" PostTypeId="1" CreationDate="2014-04-29T18:37:39.887" Score="2" ViewCount="3981" Body="&lt;p&gt;I am in the process of building my own &lt;a href=&quot;http://en.wikipedia.org/wiki/Sous-vide&quot; rel=&quot;nofollow noreferrer&quot;&gt;sous vide machine&lt;/a&gt; and like to replace the pump typically found in most commercial machines with a &lt;a href=&quot;http://en.wikipedia.org/wiki/Magnetic_stirrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;magnetic stirrer unit&lt;/a&gt;. I figured the easiest way would be to use a motor to spin a permanent magnet (instead of creating a strong rotating magnetic field electrically). I first started experimenting with some 12V DC fans leftover from an old computer. By either lowering the input voltage or via PWM I was able to obtain appropriate rotational speed (don't ask me about exact speeds, I guess around 300rpm or so). With the project maturing I am not sure which motor (type and/or exact model) to use. I hoped some of you might point me in the right direction for the type of motor or even better, could suggest a specific model. I considered stepper motors or continuous  servo motors. My criteria for the motor are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;easy to control rotational speed between 0 and around 500 or so rpm (for ramp up and variation of speed to increase turbulent flow)&lt;/li&gt;&#xA;&lt;li&gt;ability to rotate both clockwise and counter clockwise&lt;/li&gt;&#xA;&lt;li&gt;enough torque at all speeds to spin a disk with magnets attached (weight and inertia probably negligible, the to be used alnico magnets create a field strong enough to lift 0,4kg each)&lt;/li&gt;&#xA;&lt;li&gt;small axial dimensions&lt;/li&gt;&#xA;&lt;li&gt;reasonably priced and long lasting&lt;/li&gt;&#xA;&lt;li&gt;quiet &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The following picture shows a commercial magnetic stirrer found in your average laboratory. The blurry white object in the glass beaker is the the so called stir bar or &quot;fish&quot;, a PTFE coated permanent magnet. It spins due to the rotating magnetic field created by the actual device underneath the beaker. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/ysulU.jpg&quot; alt=&quot;Photo of a commercial magnetic stirrer used in laboratories&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1242" LastEditorUserId="1242" LastEditDate="2014-04-29T20:46:20.380" LastActivityDate="2016-01-01T20:58:40.803" Title="Which motor (type) to use for an arduino controlled magnetic stirrer?" Tags="|motor|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1335" PostTypeId="2" ParentId="1332" CreationDate="2014-04-29T19:05:46.410" Score="2" Body="&lt;p&gt;This variable is declared &lt;code&gt;volatile&lt;/code&gt; which is generally meaning that it can be modified by an &lt;strong&gt;Interrupt Service Routine&lt;/strong&gt; (&lt;strong&gt;ISR&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is perfectly possible that this ISR gets called before your &lt;code&gt;setup()&lt;/code&gt; function gets called and then it may modify this variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C and C++, variables defined as &lt;code&gt;type variable = xxx;&lt;/code&gt; are guaranteed to be initialized before any of your code starts to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this means you must look for the root of the problem somewhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget that it is perfectly possible that some code gets run before &lt;code&gt;setup()&lt;/code&gt; is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may try to search for the code that runs before &lt;code&gt;setup()&lt;/code&gt;; unfortunately it can be hard to find out this code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, in C++, there are a lot of possibilities for code to execute even before the &lt;code&gt;main()&lt;/code&gt; function gets called; for instance, declaring an instance of a class as a global variable, will call the class &lt;strong&gt;constructor&lt;/strong&gt; before &lt;code&gt;main()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would have to &lt;strong&gt;find out all class instances declared as global variables&lt;/strong&gt; in all source files, and then check the class constructor that gets called for each instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way could be to check the assembly produced for your program and find all calls occurring be fore &lt;code&gt;main()&lt;/code&gt;, but it can be harder if you can't read assembly.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-04-30T18:43:34.997" LastActivityDate="2014-04-30T18:43:34.997" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1336" PostTypeId="2" ParentId="1334" CreationDate="2014-04-29T20:46:49.193" Score="2" Body="&lt;p&gt;I'd personally recommend a continuous rotation servo or a brushed DC motor. Personally, for this kind of load, I think it would be easier and cheaper to go with the brushed DC motor. You have to remember a continuous rotation servo is a DC motor with some circuitry so you can send pulses to it to control the speed (although it's not directly proportional to the signal you send).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A servo is the only other option besides a brushless motor; both require a little more circuitry than the brushed motor/continuous servo. The additionally cost more. &lt;a href=&quot;http://quantumdevices.wordpress.com/2010/08/27/brushless-motors-vs-brush-motors-whats-the-difference/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This blog post covers the differences between brushed and brushless motors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For driving a continuous, you hook it up to power [depends on your servo voltage], ground, and another Arduino pin and use the &lt;a href=&quot;http://arduino.cc/en/reference/servo&quot; rel=&quot;nofollow noreferrer&quot;&gt;servo library&lt;/a&gt; to send a signal as a degree (90 = no speed, 180 = full speed forward, 0 = full speed backward).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A brushed you would need a h-bridge that allows you to either send voltage, send no voltage, or send reverse voltage (for backward). &lt;a href=&quot;http://www.pololu.com/product/2130&quot; rel=&quot;nofollow noreferrer&quot;&gt;This chip (~$5)&lt;/a&gt; does that for two motors and allows PWM for different speeds. It also includes a brake function, although that doesn't seem necessary for you. It can handle up to a &quot;2.4 A continuous (4 A peak).&quot; I talk about this in &lt;a href=&quot;https://arduino.stackexchange.com/questions/1314/how-can-i-connect-the-tamiya-double-gearbox-to-ardunio-uno/1315#1315&quot;&gt;this answer of mine&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quick note, if you want to control the &lt;em&gt;exact&lt;/em&gt; RPM of the device and not just manually adjust it to a good rate, you'll need some sort of a rotary encoder or similar. A reed switch (sends current depending on magnetic fields) would work perfectly for this purpose, just mount it below the magnets and figure out the degrees rotated by the motor for each &quot;pulse.&quot;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-04-29T20:46:49.193" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1337" PostTypeId="1" CreationDate="2014-04-29T21:23:55.607" Score="2" ViewCount="527" Body="&lt;p&gt;Goal: I would like to be able to transfer some information to an Arduino Uno board via an NFC shield/antenna. The situation requires that the NFC tag may potentially hit anywhere within a circular area about a 12 inches in diameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to increase the size of an NFC antenna? Possibly creating a loop antenna whereby the tag could be read from anywhere inside the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking maybe if that isn't possible, it might be better to create an antenna array spanning the size of the area needed. Though I may have problems with overlap or double reads this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone attempted this before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I am not worried about increasing the z distance from the plane, just the x/y range. In fact, I still want the z distance to be very short as to not interfere with other antennas nearby.&lt;/p&gt;&#xA;" OwnerUserId="1249" LastEditorUserId="1249" LastEditDate="2014-05-01T20:23:13.917" LastActivityDate="2014-05-01T20:23:13.917" Title="Larger NFC antenna?" Tags="|arduino-uno|sensors|proximity|" AnswerCount="1" CommentCount="2" ClosedDate="2014-04-30T16:27:46.103" ContentLicense="CC BY-SA 3.0" />
  <row Id="1338" PostTypeId="1" AcceptedAnswerId="1691" CreationDate="2014-04-29T22:18:31.973" Score="5" ViewCount="1595" Body="&lt;p&gt;This may be a better question for &lt;a href=&quot;https://physics.stackexchange.com/&quot;&gt;the Physics StackExchange&lt;/a&gt; so tell me if I should move the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a pretty simple script that I'm using to control the RPM of my stepper motor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){ &#xA;  digitalWrite(PIN, HIGH);&#xA;  delayMicroseconds(wait);&#xA;  digitalWrite(PIN, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as you can see it's just producing a pretty standard pulse, I have my Arduino connected to a driver that manages the motor. The &lt;code&gt;wait&lt;/code&gt; variable comes from a second order equation I derived from measuring the RPM with a Tachometer and tweaking the value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// From data RPM = 31729/x + 17.327 thus x = 31729/(RPM-17.527)&#xA;wait = M/(RPM-C);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works pretty well, I get readings consistently within only 1 - 2 rotations off. But the slope and intercept seem completely arbitrary to me. Is there a chance it has to do with the clock speed of the Arduino? I'm using an Uno and from playing around with the numbers I can't seem to find a relationship. From what I can tell, the driver looks hardwired so I don't think it has much to do with the equation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what these values, the slope/intercept mean?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Equation: &lt;code&gt;RPM=31729/wait + 17.327&lt;/code&gt; M:&lt;code&gt;31729&lt;/code&gt; and C:&lt;code&gt;17.327&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1252" LastEditorUserId="-1" LastEditDate="2017-04-13T12:40:17.797" LastActivityDate="2017-07-06T07:39:37.523" Title="Understanding the relationship of Pulse and Stepper RPM" Tags="|arduino-uno|motor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1339" PostTypeId="2" ParentId="1337" CreationDate="2014-04-30T05:14:47.363" Score="2" Body="&lt;p&gt;In general the size and geometry of the antenna is directly related to the carrier frequency. The antenna is tuned to the output signal of the transmitter/receiver. If you change an optimized antenna, it is no longer optimized and its performance will drop. So you can't keep extending an antenna, trying to improve its range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important question to be asked is if the existing antenna is already optimally sized for the transmitter/receiver. With these small things transmitter/receiver and antenna are usually closely matched. Even if the antenna is smaller than expected by math, the transmitter/receiver connected to it may be compensated for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a receiver or a &lt;strong&gt;low&lt;/strong&gt;&lt;sup&gt;*&lt;/sup&gt; power transmitter, there is no harm in testing another antenna, but you'll probably won't improve performance much.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*)&lt;/sup&gt; Notice that a high power transmitter can blow its output stage when connected to an unmatched load/antenna, but that is unlikely with NFC.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-04-30T05:14:47.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1340" PostTypeId="2" ParentId="1334" CreationDate="2014-04-30T07:28:08.467" Score="1" Body="&lt;p&gt;If you need to rotate huge loads, a permanent magnet coupled to the axis of a brushless DC motor, driven by an electronic speed controller (used for model aircrafts, multicopters, etc.) could be an option. This is the mechanical principle used in standard magnetic stirrers used in the lab, particularly when the stirrer has an additional heating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Small (and flat) magnetic stirrers without heating, similar to the one in your image, however often have no (rotating) mechanical parts at all, but use a set of coils periodically powered in sequence. Here, the only mechanically rotating part is the stirring bar itself. A commerically available model would be &lt;a href=&quot;http://www.ika.de/owa/ika/catalog.product_detail?iProduct=3907500&amp;amp;iCS=1&amp;amp;iProductgroup=188&amp;amp;iSubgroup=1&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-04-30T07:28:08.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1341" PostTypeId="1" AcceptedAnswerId="1350" CreationDate="2014-04-30T08:43:44.493" Score="2" ViewCount="715" Body="&lt;p&gt;I want to make a drone project, and to that I will use arduino as the platform. My plane is to use a Play Station controller to control the Drone in the air. In addition to that I want to connect a GPS-module. My question goes, is it possible to transmit the longitude and latitude from the GPS via the RF 433MHz to the receiver? When received the longitude and latitude how can I transmit them further to the Smartphone and display the data on google maps? I suggest it could be possible through the Xbee, but I am not sure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like if someone can confirm my idea, if not bring me a better way to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the image below, you can see the diagram of my design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qorvn.png&quot; alt=&quot;Image&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1256" LastActivityDate="2014-05-01T20:40:13.730" Title="Is it possible to transmit Longitude and Latitude via RF433MHz?" Tags="|arduino-uno|sensors|xbee|android|map|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1342" PostTypeId="2" ParentId="1341" CreationDate="2014-04-30T09:04:30.140" Score="2" Body="&lt;p&gt;If you are using Xbee modules in your project, why add 433MHz RF, just for the sole purpose of transmitting the location?  With the 433Mhz, you will have to implement error-correction yourself.&lt;/p&gt;&#xA;" OwnerUserId="831" LastActivityDate="2014-04-30T09:04:30.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1343" PostTypeId="2" ParentId="1332" CreationDate="2014-04-30T12:35:48.157" Score="2" Body="&lt;p&gt;The problem of this version of Marlin can be shown in the following piece of code (which is inside &lt;code&gt;EEPROM_RetrieveSettings&lt;/code&gt; function):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for (short i=0;i&amp;lt;4;i++) &#xA;  {&#xA;    axis_steps_per_unit[i]=tmp1[i];  &#xA;    max_feedrate[i]=tmp2[i];&#xA;    max_acceleration_units_per_sq_second[i]=tmp3[i];&#xA;    max_length[i]=tmp4[i];&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here &lt;code&gt;max_length&lt;/code&gt; is an array of 3 elements, not 4 (the X,Y and Z axes have a max length to avoid hitting the edge, but the extrude axis does not have such a limit - you should be able to extrude as many filament as you can supply), so the last statement in the loop overrides other variable(s).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for (short i=0;i&amp;lt;4;i++) &#xA;  {&#xA;    axis_steps_per_unit[i]=tmp1[i];  &#xA;    max_feedrate[i]=tmp2[i];&#xA;    max_acceleration_units_per_sq_second[i]=tmp3[i];&#xA;    if(i&amp;lt;3)&#xA;        max_length[i]=tmp4[i];&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for (short i=0;i&amp;lt;4;i++) &#xA;  {&#xA;    axis_steps_per_unit[i]=tmp1[i];  &#xA;    max_feedrate[i]=tmp2[i];&#xA;    max_acceleration_units_per_sq_second[i]=tmp3[i];&#xA;    if(i &amp;lt; sizeof(tmp4)/sizeof(tmp4[0]))&#xA;        max_length[i]=tmp4[i];&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Greate thanks to the answer writer and commenter. Without your help I couldn't follow the right track. &lt;/p&gt;&#xA;" OwnerUserId="1238" LastEditorUserId="1238" LastEditDate="2014-05-02T05:24:05.557" LastActivityDate="2014-05-02T05:24:05.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1344" PostTypeId="1" AcceptedAnswerId="1352" CreationDate="2014-04-30T13:20:01.850" Score="1" ViewCount="1971" Body="&lt;p&gt;I'm having some conflicts between the core &lt;code&gt;HardwareSerial.cpp&lt;/code&gt; and an external DMX library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For DMX I'm using the &lt;a href=&quot;http://www.deskontrol.net/blog/arduino-four-universes-dmx-512-library/&quot; rel=&quot;nofollow&quot;&gt;Four Universes DMX 512 Library&lt;/a&gt;. Using the library standalone, it all works perfectly. But when combining it with other libraries, I'm getting the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;core.a(HardwareSerial.cpp.o): In function '__vector_36':&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/HardwareSerial.cpp:147: multiple definition of '__vector_36'&#xA;Dmx\lib_dmx.cpp.o:C:\Program Files (x86)\Arduino\libraries\Dmx/lib_dmx.cpp:206: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The DMX library uses the UART hardware to generate the DMX signals. It supports four universes on the Arduino Mega since that has four UART hardware parts. Now, I'd like to only use the second hardware part, so the UART1. In the DMX library this is easily adjusted in the .h-file, by commenting out the non-used serial ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line from &lt;code&gt;lib_dmx.cpp&lt;/code&gt; that is conflicting is this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(USE_UART1)&#xA;ISR (SIG_USART1_RECV)&#xA;{&#xA;  ArduinoDmx1.Process_ISR_RX(1);&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line from &lt;code&gt;hardwareSerial.cpp&lt;/code&gt; that is conflicting is in the ISR here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(USART1_RX_vect)&#xA;  void serialEvent1() __attribute__((weak));&#xA;  void serialEvent1() {}&#xA;  #define serialEvent1_implemented&#xA;  ISR(USART1_RX_vect)&#xA;  {&#xA;    if (bit_is_clear(UCSR1A, UPE1)) {&#xA;      unsigned char c = UDR1;&#xA;      store_char(c, &amp;amp;rx_buffer1);&#xA;    } else {&#xA;      unsigned char c = UDR1;&#xA;    };&#xA;  }&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have been having issues with this for a very long time and don't have a solution at hand yet. It's also a but unclear to me how the interrupts on Arduinos are arranged. I've also included the .ino I'm using currently. I'm also using another Ethernet Library than the default, one that includes multicast UDP (found &lt;a href=&quot;https://github.com/aallan/Arduino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;lib_dmx.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; /***************************************************************************&#xA;&amp;gt; *&#xA;&amp;gt; * Title          : Arduino DMX512 library. 4 input/output universes.&#xA;&amp;gt; * Version        : v 0.3 beta&#xA;&amp;gt; * Last updated   : 07.07.2012&#xA;&amp;gt; * Target         : Arduino mega 2560, Arduino mega 1280, Arduino nano (1 universe)  &#xA;&amp;gt; * Author         : Toni Merino - merino.toni at gmail.com&#xA;&amp;gt; * Web            : www.deskontrol.net/blog&#xA;&amp;gt; *&#xA;&amp;gt; * Based on ATmega8515 Dmx library written by Hendrik Hoelscher, www.hoelscher-hi.de&#xA;&amp;gt; &#xA;&amp;gt; ;***************************************************************************/&#xA;&amp;gt; #ifndef __INC_DMX_H&#xA;&amp;gt; #define __INC_DMX_H&#xA;&amp;gt; &#xA;&amp;gt; #include &amp;lt;avr/io.h&amp;gt;&#xA;&amp;gt; #include &amp;lt;stdint.h&amp;gt;&#xA;&amp;gt; #include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&amp;gt; #include &amp;lt;util/delay.h&amp;gt;&#xA;&amp;gt; #if ARDUINO &amp;gt;= 100   #include &quot;Arduino.h&quot;&#xA;&amp;gt; #else    #include &quot;WProgram.h&quot;&#xA;&amp;gt; #endif&#xA;&amp;gt; &#xA;&amp;gt; //#define        USE_INTERBYTE_DELAY     // rare cases of equipment&#xA;&amp;gt; non full DMX-512 compliant, need this&#xA;&amp;gt; &#xA;&amp;gt; // *** comment UARTs not used *** //#define        USE_UART0&#xA;&amp;gt; #define        USE_UART1 //#define        USE_UART2 //#define        USE_UART3&#xA;&amp;gt; &#xA;&amp;gt; // New DMX modes *** EXPERIMENTAL ***&#xA;&amp;gt; #define        DMX512            (0)    // DMX-512 (250 kbaud - 512 channels) Standard USITT DMX-512&#xA;&amp;gt; #define        DMX1024           (1)    // DMX-1024 (500 kbaud - 1024 channels) Completely non standard - TESTED ok&#xA;&amp;gt; #define        DMX2048           (2)    // DMX-2048 (1000 kbaud - 2048 channels) called by manufacturers DMX1000K, DMX 4x or DMX 1M ???&#xA;&amp;gt; &#xA;&amp;gt; // DMX-512  (250 kbaud - 512 channels) Standard USITT DMX-512&#xA;&amp;gt; #define        IBG_512           (10)                      // interbyte gap [us]&#xA;&amp;gt; #define        DMX_512           ((F_CPU/(250000*8))-1)    // 250 kbaud&#xA;&amp;gt; #define        BREAK_512         ( F_CPU/(100000*8))       // 90.9 kbaud&#xA;&amp;gt; &#xA;&amp;gt; // DMX-1024 (500 kbaud - 1024 channels) Completely non standard&#xA;&amp;gt; #define        IBG_1024          (5)                       // interbyte gap [us]&#xA;&amp;gt; #define        DMX_1024          ((F_CPU/(500000*8))-1)    // 500 kbaud&#xA;&amp;gt; #define        BREAK_1024        ( F_CPU/(200000*8))       // 181.8 kbaud&#xA;&amp;gt; &#xA;&amp;gt; // DMX-2048 (1000 kbaud - 2048 channels) Non standard, but used by&#xA;&amp;gt; manufacturers as DMX1000K or DMX-4x or DMX 1M ???&#xA;&amp;gt; #define        IBG_2048          (2)                       // interbyte gap [us] + nop's to reach 2.5 uS&#xA;&amp;gt; #define        DMX_2048          ((F_CPU/(1000000*8))-1)   // 1000 kbaud&#xA;&amp;gt; #define        BREAK_2048        ( F_CPU/(400000*8))       // 363.6 kbaud&#xA;&amp;gt; &#xA;&amp;gt; // Inline assembly: do nothing for one clock cycle.&#xA;&amp;gt; #define        nop()             __asm__ __volatile__(&quot;nop&quot;)&#xA;&amp;gt; &#xA;&amp;gt; #ifdef __cplusplus extern &quot;C&quot; {&#xA;&amp;gt; #endif   #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;&amp;gt;     #if defined(USE_UART0)&#xA;&amp;gt;       void SIG_USART0_RECV  (void) __attribute__((__always_inline__));&#xA;&amp;gt;       void SIG_USART0_TRANS (void) __attribute__((__always_inline__));&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART1)&#xA;&amp;gt;       void SIG_USART1_RECV  (void) __attribute__((__always_inline__));&#xA;&amp;gt;       void SIG_USART1_TRANS (void) __attribute__((__always_inline__));&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART2)  &#xA;&amp;gt;       void SIG_USART2_RECV  (void) __attribute__((__always_inline__));&#xA;&amp;gt;       void SIG_USART2_TRANS (void) __attribute__((__always_inline__));&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART3)  &#xA;&amp;gt;       void SIG_USART3_RECV  (void) __attribute__((__always_inline__));&#xA;&amp;gt;       void SIG_USART3_TRANS (void) __attribute__((__always_inline__));&#xA;&amp;gt;     #endif   #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;&amp;gt;     #if defined(USE_UART0)&#xA;&amp;gt;       void USART_RX_vect    (void) __attribute__((__always_inline__));&#xA;&amp;gt;       void USART_TX_vect    (void) __attribute__((__always_inline__));&#xA;&amp;gt;     #endif   #endif&#xA;&amp;gt; #ifdef __cplusplus };&#xA;&amp;gt; #endif&#xA;&amp;gt; &#xA;&amp;gt; class CArduinoDmx  {    #if defined(__AVR_ATmega1280__) ||&#xA;&amp;gt; defined(__AVR_ATmega2560__)&#xA;&amp;gt;     #if defined(USE_UART0)&#xA;&amp;gt;       friend void SIG_USART0_RECV  (void);&#xA;&amp;gt;       friend void SIG_USART0_TRANS (void);&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART1)&#xA;&amp;gt;       friend void SIG_USART1_RECV  (void);&#xA;&amp;gt;       friend void SIG_USART1_TRANS (void);&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART2)  &#xA;&amp;gt;       friend void SIG_USART2_RECV  (void);&#xA;&amp;gt;       friend void SIG_USART2_TRANS (void);&#xA;&amp;gt;     #endif&#xA;&amp;gt;     #if defined(USE_UART3)  &#xA;&amp;gt;       friend void SIG_USART3_RECV  (void);&#xA;&amp;gt;       friend void SIG_USART3_TRANS (void);&#xA;&amp;gt;     #endif   #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;&amp;gt;     #if defined(USE_UART0)&#xA;&amp;gt;       friend void USART_RX_vect    (void);&#xA;&amp;gt;       friend void USART_TX_vect    (void);&#xA;&amp;gt;     #endif   #endif    public:    enum {IDLE, BREAK, STARTB, STARTADR};     // RX DMX states    enum {TXBREAK, TXSTARTB, TXDATA};  &#xA;&amp;gt; // TX DMX states&#xA;&amp;gt;       volatile uint8_t    *RxBuffer;            // array of RX DMX values    volatile uint8_t    *TxBuffer;            // array of TX DMX&#xA;&amp;gt; values&#xA;&amp;gt; &#xA;&amp;gt; private:    uint8_t     gRxState;    uint8_t    *gRxPnt;    uint8_t   &#xA;&amp;gt; IndicatorCount;    uint8_t     USARTstate;            uint8_t     RxByte;   &#xA;&amp;gt; uint8_t     RxState;    uint8_t     mUART;    uint8_t     gTxState;   &#xA;&amp;gt; uint16_t    RxCount;    uint16_t    gCurTxCh;         uint16_t   &#xA;&amp;gt; rx_channels;                  // rx channels number    uint16_t   &#xA;&amp;gt; tx_channels;                  // tx channels number    uint16_t   &#xA;&amp;gt; rx_address;                   // rx start address    uint16_t   &#xA;&amp;gt; tx_address;                   // tx start address    int8_t     &#xA;&amp;gt; rx_led;                       // rx indicator led pin    int8_t     &#xA;&amp;gt; tx_led;                       // tx indicator led pin    int8_t     &#xA;&amp;gt; control_pin;                  // max485 input/output selection pin   &#xA;&amp;gt; uint8_t     dmx_mode;                     // Standard USITT DMX512 =&#xA;&amp;gt; 0, non standard DMX1024 = 1, non standard DMX2048 (DMX1000K) = 2   &#xA;&amp;gt; uint8_t     speed_dmx;    uint8_t     speed_break;    uint16_t   &#xA;&amp;gt; CurTxCh;    uint8_t     TxState;    uint8_t    *RxPnt;&#xA;&amp;gt;    &#xA;&amp;gt; #if defined(USE_INTERBYTE_DELAY)       void        delay_gap          ();&#xA;&amp;gt; #endif&#xA;&amp;gt; &#xA;&amp;gt; public:    void        stop_dmx           ();    void        set_speed&#xA;&amp;gt; (uint8_t mode);    void        set_control_pin    (int8_t  pin)       &#xA;&amp;gt; { control_pin     = pin;      }    void        init_rx           &#xA;&amp;gt; (uint8_t mode);  // Standard USITT DMX512 = 0, non standard DMX1024 =&#xA;&amp;gt; 1, non standard DMX2048 (DMX1000K) = 2    void        set_rx_address  &#xA;&amp;gt; (uint16_t address)   { rx_address      = address;  }    void       &#xA;&amp;gt; set_rx_channels    (uint16_t channels)  { rx_channels     = channels;&#xA;&amp;gt; }    void        init_tx            (uint8_t mode);  // Standard USITT&#xA;&amp;gt; DMX512 = 0, non standard DMX1024 = 1, non standard DMX2048 (DMX1000K)&#xA;&amp;gt; = 2    void        set_tx_address     (uint16_t address)   { tx_address      = address;  }    void        set_tx_channels   &#xA;&amp;gt; (uint16_t channels)  { tx_channels     = channels; }&#xA;&amp;gt; &#xA;&amp;gt;    void        attachTXInterrupt  (void (*isr)(uint8_t uart))      {&#xA;&amp;gt; TXisrCallback   = isr; }   // register the user TX callback    void   &#xA;&amp;gt; attachRXInterrupt  (void (*isr)(uint8_t uart))      { RXisrCallback  &#xA;&amp;gt; = isr; }   // register the user RX callback&#xA;&amp;gt;        //void         Process_ISR_RX(uint8_t rx_isr_number);&#xA;&amp;gt; &#xA;&amp;gt;    void        (*TXisrCallback)   (uint8_t uart);    void       &#xA;&amp;gt; (*RXisrCallback)   (uint8_t uart);&#xA;&amp;gt; &#xA;&amp;gt;    inline void Process_ISR_RX     (uint8_t  rx_isr_number);    inline&#xA;&amp;gt; void Process_ISR_TX     (uint8_t  tx_isr_number);    public:   &#xA;&amp;gt; CArduinoDmx                    (uint8_t uart)       { rx_address     &#xA;&amp;gt; = 1; &#xA;&amp;gt;                                                          rx_channels     = 8;&#xA;&amp;gt;                                                          tx_address      = 1; &#xA;&amp;gt;                                                          tx_channels     = 8;&#xA;&amp;gt;                                                          mUART           = uart; }   };&#xA;&amp;gt; &#xA;&amp;gt; #if defined(USE_UART0)   extern CArduinoDmx ArduinoDmx0;&#xA;&amp;gt; #endif&#xA;&amp;gt; #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)   #if defined(USE_UART1)&#xA;&amp;gt;     extern CArduinoDmx ArduinoDmx1;   #endif   #if defined(USE_UART2)&#xA;&amp;gt;     extern CArduinoDmx ArduinoDmx2;   #endif   #if defined(USE_UART3)&#xA;&amp;gt;     extern CArduinoDmx ArduinoDmx3;   #endif&#xA;&amp;gt; #endif&#xA;&amp;gt; &#xA;&amp;gt; #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;lib_dmx.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/***************************************************************************&#xA;*&#xA;* Title          : Arduino DMX512 library. 4 input/output universes.&#xA;* Version        : v 0.3 beta&#xA;* Last updated   : 07.07.2012&#xA;* Target         : Arduino mega 2560, Arduino mega 1280, Arduino nano (1 universe)  &#xA;* Author         : Toni Merino - merino.toni at gmail.com&#xA;* Web            : www.deskontrol.net/blog&#xA;*&#xA;* Based on ATmega8515 Dmx library written by Hendrik Hoelscher, www.hoelscher-hi.de&#xA;&#xA;;***************************************************************************/&#xA;#include &quot;lib_dmx.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#if defined(USE_UART0)&#xA;  CArduinoDmx ArduinoDmx0(0);&#xA;#endif&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  #if defined(USE_UART1)&#xA;    CArduinoDmx ArduinoDmx1(1);&#xA;  #endif&#xA;  #if defined(USE_UART2)&#xA;    CArduinoDmx ArduinoDmx2(2);&#xA;  #endif&#xA;  #if defined(USE_UART3)&#xA;    CArduinoDmx ArduinoDmx3(3);&#xA;  #endif&#xA;#endif&#xA;&#xA;// *************** DMX Transmision Initialisation ****************&#xA;void CArduinoDmx::init_tx(uint8_t mode)&#xA;{&#xA;  cli();          //disable interrupts&#xA;  stop_dmx();                         //stop uart&#xA;  dmx_mode = mode;&#xA;  set_speed(dmx_mode);&#xA;&#xA;  if(control_pin != -1)&#xA;  {&#xA;    pinMode(control_pin,OUTPUT);        // max485 I/O control&#xA;    digitalWrite(control_pin, HIGH);    // set 485 as output&#xA;  }&#xA;&#xA;  if(mUART == 0)&#xA;  {&#xA;    pinMode(1, OUTPUT);&#xA;    UBRR0H   = 0;&#xA;    UBRR0L   = speed_dmx;  &#xA;    UCSR0A  |= (1&amp;lt;&amp;lt;U2X0);&#xA;    UCSR0C  |= (3&amp;lt;&amp;lt;UCSZ00)|(1&amp;lt;&amp;lt;USBS0);&#xA;    UCSR0B  |= (1&amp;lt;&amp;lt;TXEN0) |(1&amp;lt;&amp;lt;TXCIE0);&#xA;    UDR0     = 0;                                     //start USART 0&#xA;  }&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  else if(mUART == 1)&#xA;  {&#xA;    pinMode(18, OUTPUT); &#xA;    UBRR1H   = 0;&#xA;    UBRR1L   = speed_dmx;   &#xA;    UCSR1A  |= (1&amp;lt;&amp;lt;U2X1);&#xA;    UCSR1C  |= (3&amp;lt;&amp;lt;UCSZ10)|(1&amp;lt;&amp;lt;USBS1);&#xA;    UCSR1B  |= (1&amp;lt;&amp;lt;TXEN1) |(1&amp;lt;&amp;lt;TXCIE1);&#xA;    UDR1     = 0;                                     //start USART 1&#xA;  }&#xA;  else if(mUART == 2)&#xA;  {&#xA;    pinMode(16, OUTPUT); &#xA;    UBRR2H   = 0;&#xA;    UBRR2L   = speed_dmx;   &#xA;    UCSR2A  |= (1&amp;lt;&amp;lt;U2X2);&#xA;    UCSR2C  |= (3&amp;lt;&amp;lt;UCSZ20)|(1&amp;lt;&amp;lt;USBS2);&#xA;    UCSR2B  |= (1&amp;lt;&amp;lt;TXEN2) |(1&amp;lt;&amp;lt;TXCIE2);&#xA;    UDR2     = 0;                                     //start USART 2&#xA;  }&#xA;  else if(mUART == 3)&#xA;  {&#xA;    pinMode(14, OUTPUT); &#xA;    UBRR3H   = 0;&#xA;    UBRR3L   = speed_dmx;    &#xA;    UCSR3A  |= (1&amp;lt;&amp;lt;U2X3);&#xA;    UCSR3C  |= (3&amp;lt;&amp;lt;UCSZ30)|(1&amp;lt;&amp;lt;USBS3);&#xA;    UCSR3B  |= (1&amp;lt;&amp;lt;TXEN3) |(1&amp;lt;&amp;lt;TXCIE3);&#xA;    UDR3     = 0;                                     //start USART 3&#xA;  }&#xA;#endif&#xA;&#xA;  gTxState = BREAK;                                     // start with break&#xA;  TxBuffer = (uint8_t*)malloc(tx_channels);     // allocate mem for buffer&#xA;  memset((uint8_t*)TxBuffer, 0, tx_channels);   // fill buffer with 0's&#xA;  sei();          //enable interrupts&#xA;}&#xA;&#xA;// ************************ DMX Stop ***************************&#xA;void CArduinoDmx::stop_dmx()&#xA;{&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  if(mUART == 0)&#xA;  {&#xA;    UCSR0B &amp;amp;= ~((1&amp;lt;&amp;lt;RXCIE0) | (1&amp;lt;&amp;lt;TXCIE0) | (1&amp;lt;&amp;lt;RXEN0) | (1&amp;lt;&amp;lt;TXEN0));&#xA;  }&#xA;  else if(mUART == 1)&#xA;  {&#xA;    UCSR1B &amp;amp;= ~((1&amp;lt;&amp;lt;RXCIE1) | (1&amp;lt;&amp;lt;TXCIE1) | (1&amp;lt;&amp;lt;RXEN1) | (1&amp;lt;&amp;lt;TXEN1));&#xA;  }&#xA;  else if(mUART == 2)&#xA;  {&#xA;    UCSR2B &amp;amp;= ~((1&amp;lt;&amp;lt;RXCIE2) | (1&amp;lt;&amp;lt;TXCIE2) | (1&amp;lt;&amp;lt;RXEN2) | (1&amp;lt;&amp;lt;TXEN2));&#xA;  }&#xA;  else if(mUART == 3)&#xA;  {&#xA;    UCSR3B &amp;amp;= ~((1&amp;lt;&amp;lt;RXCIE3) | (1&amp;lt;&amp;lt;TXCIE3) | (1&amp;lt;&amp;lt;RXEN3) | (1&amp;lt;&amp;lt;TXEN3));&#xA;  }&#xA;#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;  if(mUART == 0)&#xA;  {&#xA;    UCSR0B &amp;amp;= ~((1&amp;lt;&amp;lt;RXCIE0) | (1&amp;lt;&amp;lt;TXCIE0) | (1&amp;lt;&amp;lt;RXEN0) | (1&amp;lt;&amp;lt;TXEN0));&#xA;  }&#xA;#endif&#xA;}&#xA;&#xA;// *************** DMX Reception Initialisation ****************&#xA;void CArduinoDmx::init_rx(uint8_t mode)&#xA;{&#xA;  cli();          //disable interrupts&#xA;  stop_dmx();&#xA;  dmx_mode = mode;&#xA;  set_speed(dmx_mode);&#xA;&#xA;  if(control_pin != -1)&#xA;  {&#xA;    pinMode(control_pin,OUTPUT);        //max485 I/O control&#xA;    digitalWrite(control_pin, LOW);     //set 485 as input&#xA;  }&#xA;&#xA;  if(mUART == 0)&#xA;  {&#xA;    pinMode(0, INPUT); &#xA;    UBRR0H   = 0;&#xA;    UBRR0L   = speed_dmx;&#xA;    UCSR0A  |= (1&amp;lt;&amp;lt;U2X0);&#xA;    UCSR0C  |= (3&amp;lt;&amp;lt;UCSZ00)|(1&amp;lt;&amp;lt;USBS0);&#xA;    UCSR0B  |= (1&amp;lt;&amp;lt;RXEN0) |(1&amp;lt;&amp;lt;RXCIE0);&#xA;  }&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  else if(mUART == 1)&#xA;  {&#xA;    pinMode(19, INPUT); &#xA;    UBRR1H   = 0;&#xA;    UBRR1L   = speed_dmx;&#xA;    UCSR1A  |= (1&amp;lt;&amp;lt;U2X1);&#xA;    UCSR1C  |= (3&amp;lt;&amp;lt;UCSZ10)|(1&amp;lt;&amp;lt;USBS1);&#xA;    UCSR1B  |= (1&amp;lt;&amp;lt;RXEN1) |(1&amp;lt;&amp;lt;RXCIE1);&#xA;  }&#xA;  else if(mUART == 2)&#xA;  {&#xA;    pinMode(17, INPUT); &#xA;    UBRR2H   = 0;&#xA;    UBRR2L   = speed_dmx;&#xA;    UCSR2A  |= (1&amp;lt;&amp;lt;U2X2); &#xA;    UCSR2C  |= (3&amp;lt;&amp;lt;UCSZ20)|(1&amp;lt;&amp;lt;USBS2);&#xA;    UCSR2B  |= (1&amp;lt;&amp;lt;RXEN2) |(1&amp;lt;&amp;lt;RXCIE2);&#xA;  }&#xA;  else if(mUART == 3)&#xA;  {&#xA;    pinMode(15, INPUT); &#xA;    UBRR3H   = 0;&#xA;    UBRR3L   = speed_dmx; &#xA;    UCSR3A  |= (1&amp;lt;&amp;lt;U2X3);&#xA;    UCSR3C  |= (3&amp;lt;&amp;lt;UCSZ30)|(1&amp;lt;&amp;lt;USBS3);&#xA;    UCSR3B  |= (1&amp;lt;&amp;lt;RXEN3) |(1&amp;lt;&amp;lt;RXCIE3);&#xA;  }&#xA;#endif&#xA;&#xA;  gRxState = IDLE;&#xA;  RxBuffer = (uint8_t*)malloc(rx_channels);   // allocate mem for buffer&#xA;  memset((uint8_t*)RxBuffer, 0, rx_channels); // fill buffer with 0's&#xA;  sei();          //enable interrupts&#xA;}&#xA;&#xA;// *************** DMX Reception ISR ****************&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  #if defined(USE_UART0)&#xA;    ISR (SIG_USART0_RECV)&#xA;    {&#xA;      ArduinoDmx0.Process_ISR_RX(0);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART1)&#xA;    ISR (SIG_USART1_RECV)&#xA;    {&#xA;      ArduinoDmx1.Process_ISR_RX(1);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART2)&#xA;    ISR (SIG_USART2_RECV)&#xA;    {&#xA;      ArduinoDmx2.Process_ISR_RX(2);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART3)&#xA;    ISR (SIG_USART3_RECV)&#xA;    {&#xA;      ArduinoDmx3.Process_ISR_RX(3);&#xA;    }&#xA;  #endif&#xA;#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;  #if defined(USE_UART0)&#xA;    ISR (USART_RX_vect)&#xA;    {&#xA;        ArduinoDmx0.Process_ISR_RX(0);&#xA;    } &#xA;  #endif&#xA;#endif&#xA;&#xA;void CArduinoDmx::Process_ISR_RX(uint8_t rx_isr_number)&#xA;{&#xA;  if(rx_isr_number == 0)&#xA;  {&#xA;    USARTstate = UCSR0A;                  //get state&#xA;    RxByte     = UDR0;                //get data&#xA;    RxState    = gRxState;                    //just get once from SRAM!!!&#xA;    if (USARTstate &amp;amp;(1&amp;lt;&amp;lt;FE0))         //check for break&#xA;    {                   &#xA;      UCSR0A  &amp;amp;= ~(1&amp;lt;&amp;lt;FE0);                 //reset flag&#xA;      RxCount  = rx_address;                  //reset frame counter&#xA;      gRxState = BREAK;&#xA;    }&#xA;  }&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;&#xA;  else if(rx_isr_number == 1)&#xA;  {&#xA;    USARTstate = UCSR1A;                  //get state&#xA;    RxByte     = UDR1;                //get data&#xA;    RxState    = gRxState;                    //just get once from SRAM!!!&#xA;    if (USARTstate &amp;amp;(1&amp;lt;&amp;lt;FE1))         //check for break&#xA;    {                   &#xA;      UCSR1A  &amp;amp;= ~(1&amp;lt;&amp;lt;FE1);                 //reset flag&#xA;      RxCount  = rx_address;                  //reset frame counter&#xA;      gRxState = BREAK;&#xA;    }&#xA;  }&#xA;  else if(rx_isr_number == 2)&#xA;  {&#xA;    USARTstate = UCSR2A;                  //get state&#xA;    RxByte     = UDR2;                //get data&#xA;    RxState    = gRxState;                    //just get once from SRAM!!!&#xA;    if (USARTstate &amp;amp;(1&amp;lt;&amp;lt;FE2))         //check for break&#xA;    {                   &#xA;      UCSR2A  &amp;amp;= ~(1&amp;lt;&amp;lt;FE2);                 //reset flag&#xA;      RxCount  = rx_address;                  //reset frame counter&#xA;      gRxState = BREAK;&#xA;    }&#xA;  }&#xA;  else if(rx_isr_number == 3)&#xA;  {&#xA;    USARTstate = UCSR3A;                  //get state&#xA;    RxByte     = UDR3;                //get data&#xA;    RxState    = gRxState;                    //just get once from SRAM!!!&#xA;    if (USARTstate &amp;amp;(1&amp;lt;&amp;lt;FE3))         //check for break&#xA;    {                   &#xA;      UCSR3A  &amp;amp;= ~(1&amp;lt;&amp;lt;FE3);                 //reset flag&#xA;      RxCount  = rx_address;                  //reset frame counter&#xA;      gRxState = BREAK;&#xA;    }&#xA;  }&#xA;#endif&#xA;&#xA;  if (RxState == BREAK)&#xA;  {&#xA;    if (RxByte == 0) &#xA;    {&#xA;      gRxState = STARTB;                          //normal start code detected&#xA;      gRxPnt   = ((uint8_t*)RxBuffer + 1);&#xA;    }&#xA;    else &#xA;      gRxState = IDLE;&#xA;  }&#xA;  else if (RxState == STARTB)&#xA;  {&#xA;    if (--RxCount == 0)                         //start address reached?&#xA;    {&#xA;      gRxState   = STARTADR;&#xA;      RxBuffer[0]= RxByte;&#xA;    }&#xA;  }&#xA;  else if (RxState == STARTADR)&#xA;  {&#xA;    RxPnt  = gRxPnt;&#xA;    *RxPnt = RxByte;&#xA;    if (++RxPnt &amp;gt;= (RxBuffer + rx_channels))    //all ch received?&#xA;    {&#xA;      gRxState= IDLE;&#xA;      if (*RXisrCallback) RXisrCallback(mUART);   // fire callback for read data&#xA;    }&#xA;    else &#xA;    {&#xA;      gRxPnt = RxPnt;&#xA;    }&#xA;  }                         &#xA;}&#xA;&#xA;// *************** DMX Transmision ISR ****************&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  #if defined(USE_UART0)&#xA;    ISR(SIG_USART0_TRANS)&#xA;    {&#xA;      ArduinoDmx0.Process_ISR_TX(0);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART1)&#xA;    ISR(SIG_USART1_TRANS)&#xA;    {&#xA;      ArduinoDmx1.Process_ISR_TX(1);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART2)&#xA;    ISR(SIG_USART2_TRANS)&#xA;    {&#xA;      ArduinoDmx2.Process_ISR_TX(2);&#xA;    }&#xA;  #endif&#xA;  #if defined(USE_UART3)&#xA;    ISR(SIG_USART3_TRANS)&#xA;    {&#xA;      ArduinoDmx3.Process_ISR_TX(3);&#xA;    }&#xA;  #endif&#xA;#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;  #if defined(USE_UART0)&#xA;    ISR(USART_TX_vect)&#xA;    {&#xA;      ArduinoDmx0.Process_ISR_TX(0);&#xA;    }&#xA;  #endif&#xA;#endif&#xA;&#xA;&#xA;void CArduinoDmx::Process_ISR_TX(uint8_t tx_isr_number)&#xA;{&#xA;  TxState = gTxState;&#xA;&#xA;  if(tx_isr_number == 0)&#xA;  {&#xA;    if (TxState == TXBREAK) //BREAK + MAB&#xA;    {&#xA;      UBRR0H   = 0;&#xA;      UBRR0L   = speed_break;&#xA;      UDR0     = 0;                                 //send break&#xA;      gTxState = TXSTARTB;&#xA;    }&#xA;    else if (TxState == TXSTARTB)&#xA;    {&#xA;      UBRR0H   = 0;&#xA;      UBRR0L   = speed_dmx;&#xA;      UDR0     = 0;                                 //send start byte&#xA;      gTxState = TXDATA;&#xA;      gCurTxCh = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;      #if defined(USE_INTERBYTE_DELAY)&#xA;        delay_gap();&#xA;      #endif    &#xA;      CurTxCh = gCurTxCh;&#xA;      UDR0 = TxBuffer[CurTxCh++];               //send data&#xA;      if (CurTxCh == tx_channels)&#xA;      {&#xA;        if (*TXisrCallback) TXisrCallback(0); // fire callback for update data&#xA;        gTxState = TXBREAK;   // new break if all ch sent&#xA;      }&#xA;      else &#xA;      {&#xA;        gCurTxCh = CurTxCh;&#xA;      }&#xA;    }&#xA;  }&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;&#xA;  else if(tx_isr_number == 1)&#xA;  {&#xA;    if (TxState == TXBREAK)&#xA;    {&#xA;      UBRR1H   = 0;&#xA;      UBRR1L   = speed_break;&#xA;      UDR1     = 0;                                 //send break&#xA;      gTxState = TXSTARTB;&#xA;    }&#xA;    else if (TxState == TXSTARTB)&#xA;    {&#xA;      UBRR1H   = 0;&#xA;      UBRR1L   = speed_dmx;&#xA;      UDR1     = 0;                                 //send start byte&#xA;      gTxState = TXDATA;&#xA;      gCurTxCh = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;      #if defined(USE_INTERBYTE_DELAY)&#xA;        delay_gap();&#xA;      #endif    &#xA;      CurTxCh = gCurTxCh;&#xA;      UDR1 = TxBuffer[CurTxCh++];               //send data&#xA;      if (CurTxCh == tx_channels)&#xA;      {&#xA;        if (*TXisrCallback) TXisrCallback(1); // fire callback for update data&#xA;        gTxState = TXBREAK;   // new break if all ch sent&#xA;      }&#xA;      else &#xA;      {&#xA;        gCurTxCh = CurTxCh;&#xA;      }&#xA;    }&#xA;  }&#xA;  else if(tx_isr_number == 2)&#xA;  {&#xA;    if (TxState == TXBREAK)&#xA;    {&#xA;      UBRR2H   = 0;&#xA;      UBRR2L   = speed_break;&#xA;      UDR2     = 0;                                 //send break&#xA;      gTxState = TXSTARTB;&#xA;    }&#xA;    else if (TxState == TXSTARTB)&#xA;    {&#xA;      UBRR2H   = 0;&#xA;      UBRR2L   = speed_dmx;&#xA;      UDR2     = 0;                                 //send start byte&#xA;      gTxState = TXDATA;&#xA;      gCurTxCh = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;      #if defined(USE_INTERBYTE_DELAY)&#xA;        delay_gap();&#xA;      #endif   &#xA;      CurTxCh = gCurTxCh;&#xA;      UDR2 = TxBuffer[CurTxCh++];               //send data&#xA;      if (CurTxCh == tx_channels)&#xA;      {&#xA;        if (*TXisrCallback) TXisrCallback(2); // fire callback for update data&#xA;        gTxState = TXBREAK;   // new break if all ch sent&#xA;      }&#xA;      else &#xA;      {&#xA;        gCurTxCh = CurTxCh;&#xA;      }&#xA;    }&#xA;  }&#xA;  else if(tx_isr_number == 3)&#xA;  {&#xA;    if (TxState == TXBREAK)&#xA;    {&#xA;      UBRR3H   = 0;&#xA;      UBRR3L   = speed_break;&#xA;      UDR3     = 0;                                 //send break&#xA;      gTxState = TXSTARTB;&#xA;    }&#xA;    else if (TxState == TXSTARTB)&#xA;    {&#xA;      UBRR3H   = 0;&#xA;      UBRR3L   = speed_dmx;&#xA;      UDR3     = 0;                                 //send start byte&#xA;      gTxState = TXDATA;&#xA;      gCurTxCh = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;      #if defined(USE_INTERBYTE_DELAY)&#xA;        delay_gap();&#xA;      #endif&#xA;      CurTxCh = gCurTxCh;&#xA;      UDR3 = TxBuffer[CurTxCh++];               //send data&#xA;      if (CurTxCh == tx_channels)&#xA;      {&#xA;        if (*TXisrCallback) TXisrCallback(3); // fire callback for update data&#xA;        gTxState = TXBREAK;   // new break if all ch sent&#xA;      }&#xA;      else &#xA;      {&#xA;        gCurTxCh = CurTxCh;&#xA;      }&#xA;    }&#xA;  }&#xA;#endif&#xA;}&#xA;&#xA;void CArduinoDmx::set_speed(uint8_t mode)&#xA;{&#xA;  if(mode == 0)&#xA;  {&#xA;    speed_dmx   = DMX_512;    // DMX-512  (250 kbaud - 512 channels) Standard USITT DMX-512&#xA;    speed_break = BREAK_512;&#xA;  }&#xA;  else if(mode == 1)&#xA;  {&#xA;    speed_dmx   = DMX_1024;   // DMX-1024 (500 kbaud - 1024 channels) Completely non standard, but usefull ;)&#xA;    speed_break = BREAK_1024;&#xA;  }&#xA;  else if(mode == 2)&#xA;  {&#xA;    speed_dmx   = DMX_2048;   // DMX-2048 (1000 kbaud - 2048 channels) Used by manufacturers as DMX1000K, DMX-4x or DMX-1M ???&#xA;    speed_break = BREAK_2048;&#xA;  }  &#xA;}&#xA;&#xA;#if defined(USE_INTERBYTE_DELAY)&#xA;&#xA;void CArduinoDmx::delay_gap() // rare cases of equipment non full DMX-512 compliant, need this&#xA;{&#xA;  if(dmx_mode == 0)&#xA;  {&#xA;    _delay_us(IBG_512);&#xA;  }&#xA;  else if(dmx_mode == 1)&#xA;  {&#xA;    _delay_us(IBG_1024);&#xA;  }&#xA;  else if(dmx_mode == 2)&#xA;  {&#xA;    _delay_us(IBG_2048);&#xA;  }&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;myFile.ino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*-----------------------------------------------------------------------------&#xA;        include files&#xA;------------------------------------------------------------------------------*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp.h&amp;gt;&#xA;#include &amp;lt;lib_dmx.h&amp;gt;&#xA;&#xA;#define DMX512  (0)&#xA;&#xA;byte mac[] = { 0xDD, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;IPAddress ip(10,0,0,2); // TODO: assign ip address from DHCP&#xA;unsigned int multicastPort = 8888;&#xA;IPAddress multicastIp(239,0,0,57);&#xA;&#xA;char packetBuffer[UDP_TX_PACKET_MAX_SIZE];&#xA;&#xA;EthernetUDP Udp;&#xA;&#xA;int sensorValue = 0;&#xA;int ledState = 0;&#xA;int DMXPin = 0;&#xA;&#xA;void setup() {&#xA;&#xA;  // DMX&#xA;  ArduinoDmx1.set_control_pin(DMXPin);&#xA;  ArduinoDmx1.set_rx_channels(1);&#xA;  ArduinoDmx1.set_tx_channels(5);&#xA;  ArduinoDmx1.init_tx(DMX512);&#xA;&#xA;  Ethernet.begin(mac,ip);&#xA;  Udp.beginMulti( multicastIp, multicastPort );&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  int packetSize = Udp.parsePacket();&#xA;  if(packetSize){&#xA;    Serial.print(&quot;Received packet of size &quot;);&#xA;    Serial.println(packetSize);&#xA;    Serial.print(&quot;From &quot;);&#xA;    IPAddress remote = Udp.remoteIP();&#xA;    for (int i =0; i &amp;lt; 4; i++){&#xA;      Serial.print(remote[i], DEC);&#xA;      if (i &amp;lt; 3){&#xA;        Serial.print(&quot;.&quot;);&#xA;      }&#xA;    }&#xA;    Serial.print(&quot;, port &quot;);&#xA;    Serial.println(Udp.remotePort());&#xA;&#xA;    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);&#xA;    Serial.println(&quot;Contents:&quot;);&#xA;    Serial.println(packetBuffer[0]);&#xA;&#xA;    ArduinoDmx1.TxBuffer[0] = (int)packetBuffer;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1258" LastEditorUserId="37" LastEditDate="2014-04-30T16:27:58.773" LastActivityDate="2016-01-18T08:40:37.497" Title="Multiple definition of '__vector_36' (intterupts)" Tags="|arduino-mega|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1345" PostTypeId="2" ParentId="1293" CreationDate="2014-04-30T15:55:48.770" Score="1" Body="&lt;p&gt;Just for future reference if anyone needs it I got the following from SparkFun:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Big Easy Driver Board, the Step, Dir, Sleep, Reset, and the Microstep pins are all &gt;pulled high with 20kΩ resistors, while Enable is pulled low with the same. So sleep is &gt;disabled (until explicitly enabled) and the stepper is enabled (until explicitly disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For much of the use of this board, there is no real need to adjust these settings, but If you &gt;want to achieve a low-power state you would pull the sleep pin low. This should disable much &gt;of the internal circuitry on the IC. In order to reduce power, Enable should be pulled high &gt;to disable the output FETs.&#xA;To test that the sleep function is working on the chip you can just jump it to low (ground). For me it turned out to be an error with the Arduino code rather than the chip. Here is also a good reference about pull-down / pull-up resistors. &lt;a href=&quot;http://www.bit-101.com/blog/?p=3813&quot; rel=&quot;nofollow&quot;&gt;http://www.bit-101.com/blog/?p=3813&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1182" LastActivityDate="2014-04-30T15:55:48.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1346" PostTypeId="5" CreationDate="2014-04-30T21:10:34.103" Score="0" Body="&lt;p&gt;Arduino Pro Mini is a microcontroller board based on the ATmega328. With 14 digital IO pins, 8 are analog inputs, 6 digital pins capable of PWM output. Programming and power is done via a six pin header which can be connected to a FTDI cable. The official board was designed and is manufactured by SparkFun Electronics, however there are many clones out there. It exist both 5V/16MHz and 3.3V/8MHz. It can be used with UART, SPI and I2C. &lt;/p&gt;&#xA;" OwnerUserId="27157" LastEditorUserId="27157" LastEditDate="2016-10-08T18:18:31.187" LastActivityDate="2016-10-08T18:18:31.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1347" PostTypeId="4" CreationDate="2014-04-30T21:10:34.103" Score="0" Body="An Arduino Pro Mini is a small microcontroller derived from the Arduino Uno using the ATmega328. It is unique for its tiny size and the required external FTDI adapter." OwnerUserId="1263" LastEditorUserId="27157" LastEditDate="2016-10-08T18:18:41.307" LastActivityDate="2016-10-08T18:18:41.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1348" PostTypeId="1" AcceptedAnswerId="1349" CreationDate="2014-04-30T21:32:45.820" Score="9" ViewCount="2479" Body="&lt;p&gt;According to &lt;a href=&quot;http://arduino.cc/en/reference/servo&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Servo library supports up to 12 motors on most Arduino boards and&#xA;  48 on the Arduino Mega. On boards other than the Mega, use of the&#xA;  library disables analogWrite() (PWM) functionality on pins 9 and 10,&#xA;  whether or not there is a Servo on those pins. On the Mega, up to 12&#xA;  servos can be used without interfering with PWM functionality; use of&#xA;  12 to 23 motors will disable PWM on pins 11 and 12.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, according to &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Digital I/O Pins 14 (of which 6 provide PWM output)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So how can the Uno control more than 6 servos if it only has 6 digital I/O pins that can provide PWM output?&lt;/p&gt;&#xA;" OwnerUserId="1265" LastEditorUserId="1265" LastEditDate="2014-04-30T21:44:14.990" LastActivityDate="2019-02-17T10:30:33.233" Title="How can the Arduino Uno support up to 12 servos if it only has 6 digital PWM pins?" Tags="|arduino-uno|pins|motor|pwm|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1349" PostTypeId="2" ParentId="1348" CreationDate="2014-04-30T22:13:23.090" Score="5" Body="&lt;p&gt;Although I haven't looked at the source myself, in these types of situations they usually use &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow noreferrer&quot;&gt;interrupt timer 1&lt;/a&gt;, which in PWM mode would have been associated with pins 9 and 10. This would explain why you can't use pulse width modulation on those pins. In fact, you can use any of the three timers for PWM &lt;a href=&quot;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow noreferrer&quot;&gt;on any digital pin, although it's not as good as the built in PWM options&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u3eoJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u3eoJ.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://bansky.net/blog_stuff/images/servo_pulse_width.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;bansky.net&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;(&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,14146.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;The above image accurately describes how the signals are sent to the servo motor. Such a waveform is similar to a standard PWM. The servo library can translate a degree to a waveform that the servo's IC will be able to use to adjust the motor's position with it's motor and potentiometer.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-02-17T10:30:33.233" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="1350" PostTypeId="2" ParentId="1341" CreationDate="2014-04-30T23:26:24.813" Score="0" Body="&lt;p&gt;Your design suffers several redundancies that should be fixed. First of all, you have an Xbee (only one, not a pair) &lt;em&gt;and&lt;/em&gt; a a 433 MHz transmitter/receiver combo. &lt;strong&gt;Why not just add another Xbee to the drone and remove the RF combo?&lt;/strong&gt; That would save a little battery life for the receiver end, and a lot of your time. You'll also get two way communication with error checking. Although an Xbee would increase your project size a &lt;em&gt;little&lt;/em&gt;, if you manually wired the Xbee instead of a shield (3.3V), it would save a lot of space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As some people point out, Bluetooth is a viable option that's fairly small and low cost. However, it would suffer shorter ranges and it would need a special configuration on the host side for a BT stack.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-05-01T20:40:13.730" LastActivityDate="2014-05-01T20:40:13.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1351" PostTypeId="1" CreationDate="2014-05-01T13:24:37.817" Score="3" ViewCount="844" Body="&lt;p&gt;My Arduino UNO board is part of a &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/__37893__Arduino_Tracked_Cellphone_Bluetooth_Robot_Kit.html&quot; rel=&quot;nofollow&quot;&gt;small robot&lt;/a&gt; that works when connected to the laptop by USB but it does not when plugged to the batteries. The baterries plug seems okay, it outputs 7.8 V. My UNO is connected to an ArduMoto board that manages the robot motors as well as a bluetooth chip. I have little experience with Arduino or electronics in general so I am stuck on the best course of action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Can I find out what is wrong with the power supply without completely isolating UNO from the robot?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If I separate UNO, how can I find out with certainty if my UNO power supply is damaged or not? Is there something in particular that I could measure with my multimeter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After fully charging my batteries I observed that the LEDs attached to the motor outputs are blinking fast. They blink for about one minute then nothing happens anymore. On USB everything works as expected. Those LEDs show that signal is going towards the motors, but why is it so different to USB? On USB power, the LEDs blink only when I command the robot to move through the BT board while under baterries they blink furiously for a minute and that is all that happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also don't know what happened to the batteries, they seem to be fully drained in just one minute, but I don't know how to test that, they appear to still have high voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use two LC 18650 4800 mAh 3.7 V UltraFire baterries. The motor shield is Ardumoto Keyes_L298P, very similar to &lt;a href=&quot;https://www.sparkfun.com/products/9815&quot; rel=&quot;nofollow&quot;&gt;Sparkfun's Ardumoto shield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have the actual code that is on my Arduino. It must be similar to the code on &lt;a href=&quot;http://www.mobot.es/MobotBTCar.html&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;, since I am using their Android app for BT communication with my robot, and it works on USB power supply.&lt;/p&gt;&#xA;" OwnerUserId="1230" LastEditorUserId="1230" LastEditDate="2014-05-03T13:02:50.563" LastActivityDate="2014-05-03T13:02:50.563" Title="Arduino Uno + Ardumoto + BT robot works from USB but not from baterries" Tags="|arduino-uno|shields|power|arduino-motor-shield|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1352" PostTypeId="2" ParentId="1344" CreationDate="2014-05-01T13:45:07.680" Score="1" Body="&lt;p&gt;It seems that, from the discussion on the page you link to, the author of the DMX Library himself is not sure how to get this to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest solution, it seems to me, is to modify HardwareSerial.cpp in your Arduino core to no longer use that interrupt vector.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-05-01T13:45:07.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1354" PostTypeId="2" ParentId="1193" CreationDate="2014-05-01T16:23:45.310" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long pressureOnTime; //millis() time when pressure switch is first turned on&#xA;&#xA;const unsigned long ledOnAfterTimeThreshold = 300000; //5 minutes * 60 sec * 1000 mSec&#xA;int pressureThreshold = 1; //minimum analog reading from pressure sensor considered to be &quot;on&quot;&#xA;&#xA;const int fsrAnalogePin = 0; &#xA;const int ledPin = 11; &#xA;&#xA;int ledState = LOW;&#xA;int pressureState = LOW;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    checkPressureSwitch();  &#xA;&#xA;    //do other stuff here&#xA;}&#xA;&#xA;&#xA;void checkPressureSwitch() {&#xA;    if( analogRead(fsrAnalogePin) &amp;gt;=  pressureThreshold ) &#xA;    {&#xA;        handlePressureOn();&#xA;    }&#xA;    else &#xA;    {&#xA;        handlePressureOff();&#xA;    }&#xA;&#xA;    digitalWrite(ledPin, ledState);&#xA;}&#xA;&#xA;void handlePressureOn() {&#xA;    if ( pressureState == LOW )&#xA;    {&#xA;        //pressure switch was off, but is now on&#xA;        pressureOnTime = millis();&#xA;        pressureState = HIGH;&#xA;    }&#xA;&#xA;    else if ( millis() - pressureOnTime &amp;gt;= ledOnAfterTimeThreshold ) &#xA;    {&#xA;        ledState = HIGH;&#xA;    }&#xA;}&#xA;&#xA;void handlePressureOff() {&#xA;    ledState = LOW;&#xA;    pressureState = LOW;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2014-05-05T14:17:01.220" LastActivityDate="2014-05-05T14:17:01.220" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1355" PostTypeId="1" AcceptedAnswerId="1426" CreationDate="2014-04-24T17:22:35.997" Score="1" ViewCount="258" Body="&lt;p&gt;I'm having a problem. I want to clear the screen on the connected console. And after the clear, I want to rerun my code. But I can't seem to figure out how to do it. Below is some part of the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;motorStyring.h&amp;gt;&#xA;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;#define PORT 6666&#xA;motorStyring mt;&#xA;int cm;&#xA;&#xA;  YunServer server(PORT);&#xA;  const int pingPin = 9;&#xA;  int led = 13;&#xA;    void setup() {&#xA;&#xA;    Serial.begin(115200);&#xA;    Bridge.begin();&#xA;    server.noListenOnLocalhost();&#xA;    server.begin();&#xA; }&#xA;    void loop() {&#xA;    long duration, inches, cm;&#xA;    pinMode(pingPin,OUTPUT);&#xA;    digitalWrite(pingPin,LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(pingPin, HIGH);&#xA;    delayMicroseconds(5);&#xA;    digitalWrite(pingPin,LOW);&#xA;    pinMode(pingPin, INPUT);&#xA;    duration = pulseIn(pingPin,HIGH);&#xA;    cm = microsecondsToCentimeters(duration);&#xA;    h();&#xA;   }&#xA;    void h()&#xA;   {&#xA;    YunClient client = server.accept();&#xA;     if (client.connected()) {&#xA;      String question = &quot;What would you like to drink?\nyou have 4    choises:\n1)Juice\n2)Vodca\n3)Soda\n4)Mix\n&quot;;&#xA;client.write((uint8_t*)&amp;amp;question[0], question.length());    &#xA;String response;&#xA;while (client.connected()) {&#xA;  if (client.available()) {&#xA;    char cmd = client.read();&#xA;    if (cmd == '\n') {&#xA;      break;&#xA;    } else {&#xA;      response += String(cmd);&#xA;    }&#xA;  }&#xA;}&#xA;if (response == &quot;juice&quot;) {&#xA;  juice();&#xA;&#xA;} else if (response == &quot;vodka&quot;) {&#xA;  vodka();&#xA;&#xA;} else if (response == &quot;soda&quot;) {&#xA;  soda();&#xA;&#xA;} else if (response == &quot;mix&quot;) {&#xA;  mix();&#xA;&#xA;} else {&#xA;&#xA;  String error = &quot;you didn't select anything that corrospond to an option. \n try agin&quot;;&#xA;  client.write((uint8_t*)&amp;amp;error[0], error.length());&#xA; }&#xA;   String awnser = &quot;Here is your &quot; + response;&#xA;   client.write((uint8_t*)&amp;amp;awnser[0], awnser.length());&#xA; }&#xA; delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to clear the screen on the console, so that all of the text from the previous code is not disturbing the user?&lt;/p&gt;&#xA;" OwnerUserId="1328" OwnerDisplayName="Lasse" LastEditorUserId="17196" LastEditDate="2017-04-18T23:51:46.627" LastActivityDate="2017-04-18T23:51:46.627" Title="Arduino Yún console clear" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1356" PostTypeId="1" CreationDate="2014-04-19T03:16:31.137" Score="7" ViewCount="5201" Body="&lt;p&gt;I have two XBee's connected to two Arduino Uno boards (one for each XBee). I connected each XBee to the X-CTU software, and have set the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;XBee 1&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Pan ID = 4270 &#xA;DL = 10 &#xA;MY = 20&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;XBee 2&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Pan ID = 4270 &#xA;DL = 20 &#xA;MY = 10&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Both&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;DD = 10000 &#xA;IC = FF &#xA;IR = 32&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, they should be on the same network and see each other as the 'other person' each is talking to. I'm using the TX and RX pins of the arduino and the XBee to communicate over the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When testing if each can hear the other, I loaded one arduino with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;// put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;// put your main code here, to run repeatedly:&#xA;  Serial.print('x');&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then another with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;// put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(7,OUTPUT);&#xA;  digitalWrite(7,LOW);&#xA;}&#xA;void loop() {&#xA;// put your main code here, to run repeatedly:&#xA;  if(Serial.available())&#xA;  {&#xA;    char getData = Serial.read();&#xA;    if(getData == 'x')&#xA;    {&#xA;      digitalWrite(7,HIGH);&#xA;      delay(500);&#xA;      digitalWrite(7,LOW);&#xA;      delay(500);&#xA;    }&#xA;  Serial.print(getData);&#xA;  getData = ' ';&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works perfectly. One LED will light up on the correct arduino in half second intervals. However, when I try to make them both communicate at the same time to each other, nothing happens. Neither LED will light up. The code for both arduino's is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(7,OUTPUT);&#xA;  digitalWrite(7,LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  Serial.print('x');&#xA;  delay(1000);&#xA;  if(Serial.available())&#xA;  {&#xA;      char getData = Serial.read();&#xA;      if(getData == 'y')&#xA;      {&#xA;        digitalWrite(7,HIGH);&#xA;        delay(500);&#xA;        digitalWrite(7,LOW);&#xA;        delay(500);&#xA;      }&#xA;      Serial.print(getData);&#xA;      getData = ' ';&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for one arduino I change the code to &lt;code&gt;Serial.print('y')&lt;/code&gt; and &lt;code&gt;if(getData == 'x')&lt;/code&gt; to listen for the other one. I also have tried delaying one arduino in the setup by one second to offset the sending and recieving, but that also doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need them to be able to listen and talk to each other, maybe even at the same time like this example. I'm trying to create a proximity sensor in, lets say the 'back', area communicate with the 'front' area, and an accelerometer and two switches from the 'front' communicate with the 'back'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any settings I can change in X-CTU, such as the baud rate or the amount of packets re-sent, to overcome this problem? Or is this merely a code issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have the power connected to the 3.3V pin of the arduino, and I'm using 470/220 Ohm resistors as voltage dividers for the output pins from the arduino to the XBee, so I don't think voltage is an issue here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have disconnected the arduino from the computer. I'm powering it via the USB-A to USB-B cord -&gt; 13000 mAh 5V DC rechargeable battery, so there should be no interference with the serial data lines. Pin 2 (RX) of the XBee is connected to pin D0 (RX) of the arduino, and pin 3 (TX) of the XBee is connected to pin D1 (TX) of the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerDisplayName="nathpilland" LastActivityDate="2014-05-01T16:42:42.683" Title="Communication with two XBee's and Arduinos over serial" Tags="|c++|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1357" PostTypeId="2" ParentId="1356" CreationDate="2014-04-26T13:28:49.600" Score="3" Body="&lt;p&gt;Did you set one of your modules into coordinator mode?&#xA;Every xBee network needs a coordinator. Therefore, you need to put one of your Xbee modules into coordinator mode using the &quot;Function Set&quot; dropdown box in X-CTU. The coordinator has the fixed address 0, so you need to set DL and HL address parts of the other module to 0. On your coordinator, you can set DL to FFFF and HL to 0, which is the broadcast address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Softserial won't help you. It's just a way to use some of the pins as an additional serial port. Don't use that if you can use a hardware serial port.&lt;/p&gt;&#xA;" OwnerDisplayName="dax" LastActivityDate="2014-04-26T17:34:55.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1358" PostTypeId="1" CreationDate="2014-03-23T14:27:45.640" Score="3" ViewCount="1406" Body="&lt;p&gt;I'm trying to communicate with the Arduino through the serial port to fade the LED. &#xA;There's the code running on my Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;aJSON.h&amp;gt;&#xA;aJsonStream serial_stream(&amp;amp;Serial);&#xA;&#xA;const int localID = 1;&#xA;int intensity = 100;        // fadeTo value(0% - 100%)&#xA;int currentIntensity = 0;   // how bright the LED actually is (0-100%) &#xA;int time = 0;               // milliseconds&#xA;int color[] = {0, 255, 0};&#xA;&#xA;int pinRed = 11;&#xA;int pinGreen = 10;&#xA;int pinBlue = 9;&#xA;int pinPower = 8;&#xA;&#xA;void fadeTo() {&#xA;  if(intensity != currentIntensity) {&#xA;    if(intensity &amp;gt; currentIntensity)&#xA;      currentIntensity+=1;&#xA;    else&#xA;      currentIntensity-=1;&#xA;&#xA;    analogWrite(pinRed,255-currentIntensity);&#xA;    analogWrite(pinGreen,255-currentIntensity);&#xA;    analogWrite(pinBlue,255-currentIntensity);&#xA;  }&#xA;}&#xA;&#xA;aJsonObject *createMsg()&#xA;{&#xA;    aJsonObject *orbData, *colorData;&#xA;&#xA;    orbData = aJson.createObject();&#xA;    aJson.addNumberToObject(orbData, &quot;id&quot;, (int)localID);&#xA;&#xA;    aJson.addNumberToObject(orbData, &quot;currentIntensity&quot;, (int)currentIntensity);&#xA;&#xA;    //aJson.addNumberToObject(orbData, &quot;time&quot;, (int)time);&#xA;&#xA;    colorData = aJson.createIntArray(color, 3);&#xA;    aJson.addItemToObject(orbData, &quot;color&quot;, colorData);&#xA;&#xA;    return orbData;&#xA;}&#xA;&#xA;// echo {\&quot;id\&quot;:1, \&quot;intensity\&quot;:150, \&quot;time\&quot;:10} &amp;gt;&amp;gt; /dev/ttyACM0 in terminal&#xA;// {&quot;id&quot;:1, &quot;intensity&quot;:150, &quot;time&quot;:10} in Serial Monitor&#xA;void processMsg(aJsonObject *msg)&#xA;{&#xA;    //Serial.println(&quot;Data succefully received.&quot;);&#xA;    Serial.println(&quot;received message: &quot;);&#xA;    aJson.print(msg, &amp;amp;serial_stream);&#xA;&#xA;    aJsonObject *idData = aJson.getObjectItem(msg, &quot;id&quot;);&#xA;    if(idData != NULL) &#xA;    {&#xA;        Serial.println(&quot;ID data succefully received.&quot;);&#xA;        if(localID == (idData-&amp;gt;valueint)) {&#xA;&#xA;            aJsonObject *intensityData = aJson.getObjectItem(msg, &quot;intensity&quot;);&#xA;            if(intensityData != NULL) {&#xA;                if(intensityData-&amp;gt;type != aJson_Int) {&#xA;                    Serial.println(&quot;Invalid data type for Intensity&quot;);&#xA;                    return;&#xA;                }&#xA;&#xA;                if(intensityData-&amp;gt;valueint == currentIntensity) {&#xA;                    Serial.println(&quot;The received intensity value is already the current LED intensity&quot;);&#xA;                    return;&#xA;                }&#xA;&#xA;                else {&#xA;                    Serial.println(&quot;Intensity data succefully received&quot;);&#xA;                    intensity = intensityData-&amp;gt;valueint;&#xA;                }&#xA;            }&#xA;            else {&#xA;                Serial.println(&quot;No intensity value received.&quot;);&#xA;                return;&#xA;            }&#xA;&#xA;            aJsonObject *timeData = aJson.getObjectItem(msg, &quot;time&quot;);&#xA;            if(timeData != NULL) {&#xA;                if(timeData-&amp;gt;type != aJson_Int) {&#xA;                    Serial.println(&quot;Invalid data type for time&quot;);&#xA;                    return;&#xA;                }&#xA;                else {&#xA;                    Serial.println(&quot;Time data succefully received&quot;);&#xA;                    time = (timeData-&amp;gt;valueint);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        else {&#xA;          Serial.println(&quot;The received ID is not mine.&quot;);&#xA;          return;  &#xA;        }  &#xA;    }&#xA;&#xA;    else {&#xA;      Serial.println(&quot;No ID data received.&quot;);&#xA;      return;&#xA;    }&#xA;&#xA;    Serial.println(&quot;received message: &quot;);&#xA;    aJson.print(msg, &amp;amp;serial_stream);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;&#xA;    pinMode(pinRed,OUTPUT);&#xA;    pinMode(pinGreen,OUTPUT);&#xA;    pinMode(pinBlue,OUTPUT);&#xA;    pinMode(pinPower,OUTPUT);&#xA;&#xA;    digitalWrite(pinPower,HIGH);&#xA;    digitalWrite(pinRed,HIGH);&#xA;    digitalWrite(pinGreen,HIGH);&#xA;    digitalWrite(pinBlue,HIGH);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    aJsonObject *orbData = createMsg();&#xA;&#xA;    Serial.println(&quot;current status: &quot;);&#xA;    aJson.print(orbData, &amp;amp;serial_stream);&#xA;&#xA;    Serial.println();&#xA;&#xA;    aJson.deleteItem(orbData);&#xA;    delay(100);&#xA;&#xA;    fadeTo();&#xA;&#xA;}&#xA;&#xA;&#xA;void serialEvent()&#xA;{&#xA;    if(serial_stream.available())&#xA;    {&#xA;        // first, skip any accidental whitespace like newlines&#xA;        serial_stream.skip();&#xA;    }&#xA;&#xA;    if(serial_stream.available())&#xA;    {&#xA;        aJsonObject *msg = aJson.parse(&amp;amp;serial_stream);&#xA;&#xA;        processMsg(msg);&#xA;&#xA;        aJson.deleteItem(msg);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, I can open my Serial Monitor in the Arduino IDE and send json data to the Arduino and I see live the changes through the output and the LED on the board. I can also send data through terminal to /dev/ttyACM0 while running Serial Monitor in the IDE and it works fine too. But as soon as I close the Serial Monitor and send data to the device through terminal, it breaks down. I can then open Serial Monitor and every time I get the ERROR from json parser --&gt; (&quot;No ID data received.&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone any idea why this is happening?&lt;/p&gt;&#xA;" OwnerDisplayName="Bagrat" LastEditorUserId="612" LastEditDate="2014-05-02T02:07:05.117" LastActivityDate="2015-04-29T05:09:11.197" Title="Arduino Serial Communication" Tags="|linux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1360" PostTypeId="2" ParentId="1270" CreationDate="2014-05-01T18:40:11.257" Score="3" Body="&lt;p&gt;try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#import &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;OBD.h&amp;gt;&#xA;&#xA;int kphValue = 0;&#xA;int rpmValue = 0;&#xA;&#xA;COBD obd;&#xA;&#xA;//array of character arrays, see http://arduino.cc/en/Reference/string&#xA;const char* rpmStrings[] = {    &quot;,N,N,255,000,255,000&quot;, &#xA;                                &quot;,N,N,255,255,030,000&quot;, &#xA;                                &quot;,N,N,255,255,000,000&quot; }; &#xA;&#xA;void setup(){&#xA;    Serial2.begin(9600);&#xA;    obd.begin();&#xA;&#xA;    //Initiate OBD-II connection until success&#xA;    while ( !obd.init() ) {&#xA;        Serial2.print(&quot;$0,Y,Y,255,255,000,000$0,Y,Y,255,255,000,000!&quot;);&#xA;        delay(1000);&#xA;        Serial2.print(&quot;$0,Y,Y,000,000,000,000$0,Y,Y,000,000,000,000!&quot;);&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;    if ( obd.read(PID_RPM, rpmValue) &amp;amp;&amp;amp; obd.read(PID_SPEED, kphValue) )&#xA;    {&#xA;        int rpmStringIndex = determineRpmIndex(rpmValue);&#xA;        int mphValue = kphToMPH(kphValue);&#xA;&#xA;        //payloadString = &quot;$&quot; + onesString + rpmString + &quot;$&quot; + tensString + &quot;rpmString&quot; + &quot;!&quot;;&#xA;        //using Arduino String objects is generally not a good idea due to memory constraints&#xA;        //it's probably ok, but I'd rather use character arrays and/or print a bit at a time rather than trying to assemble a giant string &#xA;        Serial2.print(&quot;$&quot;);&#xA;        Serial2.print(mphValue % 10); //ones&#xA;        Serial2.print(rpmStrings[rpmStringIndex]);&#xA;        Serial2.print(&quot;$&quot;);&#xA;        Serial2.print(mphValue / 10); //tens - integer division, don't need modulo&#xA;&#xA;        //do you really want to append the string &quot;rpmString!&quot; or did you want the contents of the variabe rmpString+&quot;!&quot; ?&#xA;        //I'm pretty sure you meant the latter&#xA;        Serial2.print(rpmStrings[rpmStringIndex]);&#xA;        Serial2.print(&quot;!&quot;);&#xA;    }&#xA;    else &#xA;    {&#xA;        //obd read error&#xA;        //add debugging output here to see if obd failed to respond correctly/on time&#xA;    }&#xA;}&#xA;&#xA;int kphToMph( int kphValue ) {&#xA;    //return a value rather than updating a global variable&#xA;    return ( int ) ( kphValue * 0.621371 );&#xA;}&#xA;&#xA;int determineRpmIndex( int rpmValue ) {&#xA;    if ( rpmValue &amp;gt;= 5000 )&#xA;        return 2;&#xA;&#xA;    if ( rpmValue &amp;gt;= 3000 )&#xA;        return 1;&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-05-01T18:40:11.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1361" PostTypeId="5" CreationDate="2014-05-01T23:16:35.097" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-05-01T23:16:35.097" LastActivityDate="2014-05-01T23:16:35.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1362" PostTypeId="4" CreationDate="2014-05-01T23:16:35.097" Score="0" Body="Radio-Frequency Identification. Uses electromagnetic fields to transmit data for identification purposes, such as between a tag and a reader. RFID is the precursor to Near Field Communication (NFC)." OwnerUserId="1263" LastEditorUserId="42" LastEditDate="2015-03-13T11:15:17.277" LastActivityDate="2015-03-13T11:15:17.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1363" PostTypeId="5" CreationDate="2014-05-01T23:19:39.727" Score="0" Body="&lt;p&gt;Official site: &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avrdude/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T00:13:40.330" LastActivityDate="2014-05-02T00:13:40.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1364" PostTypeId="4" CreationDate="2014-05-01T23:19:39.727" Score="0" Body="Programming utility for AVR micro-controllers." OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T00:13:36.967" LastActivityDate="2014-05-02T00:13:36.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1366" PostTypeId="5" CreationDate="2014-05-01T23:29:04.590" Score="0" Body="&lt;p&gt;Official site &lt;a href=&quot;http://arduiniana.org/libraries/tinygps/&quot; rel=&quot;nofollow&quot;&gt;http://arduiniana.org/libraries/tinygps/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T00:13:30.190" LastActivityDate="2014-05-02T00:13:30.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1367" PostTypeId="4" CreationDate="2014-05-01T23:29:04.590" Score="0" Body="A gps library providing: position, date, time, altitude, speed and course" OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T00:13:13.703" LastActivityDate="2014-05-02T00:13:13.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1368" PostTypeId="1" CreationDate="2014-05-01T23:38:16.460" Score="1" ViewCount="2519" Body="&lt;p&gt;Can a Arduino MEGA 2560 R3 provide enough current out of its pin to activate the &lt;a href=&quot;http://www.hebertech.com/view/3778-songle-srd-24vdc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Songle srd-24vdc-sl-c relay&lt;/a&gt;? Will powering the Arduino with an external power supply help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8zapx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2014-05-02T17:34:57.777" Title="Can Arduino Mega2560 Use this 24VDC Relay?" Tags="|arduino-mega|relay|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1369" PostTypeId="2" ParentId="1368" CreationDate="2014-05-02T02:13:28.003" Score="1" Body="&lt;p&gt;This relay cannot be &lt;strong&gt;directly&lt;/strong&gt; commanded by any Arduino because its coil require &lt;strong&gt;24V voltage&lt;/strong&gt; to be able to switch the contact; Arduino Mega pins output voltage is &lt;strong&gt;5V&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding &lt;strong&gt;current&lt;/strong&gt;, the &lt;strong&gt;relay coil needs 15mA&lt;/strong&gt; (&quot;high sensitivity&quot; model) &lt;strong&gt;or 18.7mA&lt;/strong&gt; (standard model), that would be OK for an Arduino Mega pin (&lt;strong&gt;max current = 40mA&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you would have to add some circuit to adapt voltage between the Arduino pin and the relay. For this, first of all &lt;strong&gt;you will need to get a second power supply&lt;/strong&gt; (in addition to the Arduino 5V supply used for Arduino) that can supply 24V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you could use a &lt;a href=&quot;http://en.wikipedia.org/wiki/MOSFET&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSFET&lt;/a&gt; transistor between the Arduino pin and the relay. A MOSFET is often used in so-called &lt;strong&gt;Solid State Relay&lt;/strong&gt; (&lt;a href=&quot;http://en.wikipedia.org/wiki/Solid-state_relay&quot; rel=&quot;nofollow noreferrer&quot;&gt;SSR&lt;/a&gt;) because it can almost do the same as a coil relay but is 100% electronic-based (no moving parts); however, contrarily to a coil relay, it does not provide galvanic isolation between the input and the output circuits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check out &lt;a href=&quot;https://arduino.stackexchange.com/questions/403/how-can-higher-current-devices-motors-solenoids-lights-etc-be-controlled-b&quot;&gt;this question&lt;/a&gt; to find out further information on MOSFET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personnally, I would rather replace that relay with a 5V relay model, as that would make the circuit simpler, and would remove the need for a second power supply.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-05-02T17:34:57.777" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1370" PostTypeId="1" CreationDate="2014-05-02T03:31:14.073" Score="11" ViewCount="10075" Body="&lt;p&gt;I have the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot;&gt;GSM shield&lt;/a&gt; and is there any ways to get the stored contacts on the SIM card? It seems that &lt;a href=&quot;http://arduino.cc/en/Reference/GSM&quot;&gt;the GSM library&lt;/a&gt; does not support writing data onto/ reading data from the SIM card?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim is to store the SIM card's phone number and some variables onto the SIM card itself, such, I would not need to change the program from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I need to do is enter all the variables in the SIM card via any mobile phone (perhaps by storing the variables as contacts, as phone book function should be very common on phones).&lt;/p&gt;&#xA;" OwnerUserId="1049" LastActivityDate="2019-11-07T09:23:06.863" Title="Getting the contacts/ storing contacts to SIM card" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1371" PostTypeId="1" CreationDate="2014-05-02T05:59:36.973" Score="0" ViewCount="2119" Body="&lt;p&gt;I am doing a project on Arduino controlled light dimmer circuit...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a separate circuit for zero crossing detector and IR receiver but when I am combining both of them in arduino then my IR receiver stops working and zero crossing interrupt is not detected...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;int RECEIVE_PIN = 8;&#xA;int AC_LOAD = 3;    &#xA;int dimming;  &#xA;&#xA;IRrecv irrecv(RECEIVE_PIN);&#xA;decode_results results;&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(9600);&#xA;    irrecv.enableIRIn();   &#xA;    pinMode(AC_LOAD, OUTPUT);         &#xA;    attachInterrupt(0, zero_crosss_int, RISING);  &#xA;}&#xA;&#xA;void zero_crosss_int()  &#xA;{&#xA;    int dimtime = 75*dimming;      &#xA;    delayMicroseconds(dimtime);    // Off cycle&#xA;    digitalWrite(AC_LOAD, HIGH);   // triac firing&#xA;    delayMicroseconds(10);         // triac On propogation delay&#xA;    digitalWrite(AC_LOAD, LOW);    // triac Off&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    if (irrecv.decode(&amp;amp;results)) &#xA;    {&#xA;        Serial.print(&quot;0x&quot;);&#xA;        Serial.println(&#xA;        results.value, HEX);&#xA;        delay(50);&#xA;&#xA;        if(results.value==0xE13DDA28)&#xA;            dimming = 120;&#xA;&#xA;        if(results.value==0xAD586662)&#xA;            dimming = 80;&#xA;&#xA;        if(results.value==0x273009C4)&#xA;            dimming = 20;&#xA;&#xA;        irrecv.resume();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with this????&lt;/p&gt;&#xA;" OwnerUserId="1275" LastEditorUserId="84" LastEditDate="2014-05-07T05:13:59.417" LastActivityDate="2018-03-06T10:27:33.480" Title="IR controlled light dimmer" Tags="|programming|arduino-due|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1372" PostTypeId="2" ParentId="1371" CreationDate="2014-05-02T11:31:16.227" Score="1" Body="&lt;p&gt;What you've described (without source code and/or a circuit diagram) sounds like you'll probably be using interrupts at least for the zero crossing detection. And probably the IR receiver too. The IR receiver is going to be your problem since the zero crossing is a very quick flag set and you're out of the interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the IR detection is going to take time, and if you're doing THAT in an interrupt you're going to be missing dozens of crossings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To mix the two you can leave the zero crossing in it's own interrupt, but you're probably better off handling the IR in the loop via a state machine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you say that neither are working, I'm going to hazard a guess and you're using the same interrupt or badly implemented them (possibly a timer and interrupt clash) and until you post some code people here aren't going to be able to help you any more than that. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-05-02T11:31:16.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1373" PostTypeId="2" ParentId="1370" CreationDate="2014-05-02T11:49:43.687" Score="6" Body="&lt;p&gt;What have you researched so far? Following the link you have given for the shield, about the third line of the description is a reference to the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/Quectel_M10_AT_commands.pdf&quot; rel=&quot;noreferrer&quot;&gt;AT Command Set&lt;/a&gt; used by the chip.&lt;/p&gt;&#xA;&lt;p&gt;I just did a couple of quick searches through it and found:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;2.2.4  ATD&amp;gt;&amp;lt;n&amp;gt;&lt;/code&gt; Originate phone call to number in memory&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;3.2.26 AT+CPBF&lt;/code&gt; Find phone book entries&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;3.2.27 AT+CPBR&lt;/code&gt; Read current phone book entries&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;3.2.28 AT+CPBS&lt;/code&gt; Select phone book memory storage&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;probably a good place to start.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-05-02T11:49:43.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1374" PostTypeId="1" AcceptedAnswerId="3181" CreationDate="2014-05-02T13:30:23.127" Score="9" ViewCount="2946" Body="&lt;p&gt;I'd like to write my sketches so that I can either build/upload them using the Arduino IDE, or optionally using GCC and a makefile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about including the function declarations at the top, but is there anything else to do in order for my sketch to be considered valid C++ by my compiler?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Understanding what the Arduino IDE does to .ino and .pde files is fine, but extraneous to my question, so this is not a duplicate. What I want to know is &quot;how do I write a program such that it is considered valid both by the Arduino IDE &lt;strong&gt;and&lt;/strong&gt; g++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The official(?) makefile &lt;a href=&quot;http://playground.arduino.cc/Learning/CommandLine&quot; rel=&quot;nofollow&quot;&gt;available here&lt;/a&gt; explains what to do if using the makefile &lt;em&gt;instead&lt;/em&gt; of the IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# The Arduino environment does preliminary processing on a sketch before&#xA;# compiling it.  If you're using this makefile instead, you'll need to do&#xA;# a few things differently:&#xA;#&#xA;#   - Give your program's file a .cpp extension (e.g. foo.cpp).&#xA;#&#xA;#   - Put this line at top of your code: #include &amp;lt;WProgram.h&amp;gt;&#xA;#&#xA;#   - Write prototypes for all your functions (or define them before you&#xA;#     call them).  A prototype declares the types of parameters a&#xA;#     function will take and what type of value it will return.  This&#xA;#     means that you can have a call to a function before the definition&#xA;#     of the function.  A function prototype looks like the first line of&#xA;#     the function, with a semi-colon at the end.  For example:&#xA;#     int digitalRead(int pin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but this doesn't explain how use &lt;em&gt;both&lt;/em&gt; the IDE and a makefile.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Update 2&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I recently found PlatformIO which doesn't answer this question directly, but does automate a lot of the process (generates Scons files for you) and so far I prefer the workflow over both the Arduino IDE and the source+makefile approach.  Good support from the authors as well.&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="37523" LastEditDate="2019-12-03T20:23:40.887" LastActivityDate="2019-12-03T20:23:40.887" Title="How to write makefile-compatible sketches?" Tags="|programming|c++|avr-gcc|gcc|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1375" PostTypeId="2" ParentId="1351" CreationDate="2014-05-02T14:04:55.427" Score="1" Body="&lt;p&gt;Are you powering the motors with a separate supply, and not direct from the Arduino? Motors should be powered separately and the power only switched by the Arduino. Otherwise, their current draw could be pulling down your battery voltage. And even with USB power, they could be drawing more current than spec'd for either the USB power source or the Arduino's regulator or output pins. The chip itself is spec'd for a maximum current of 40mA per pin and 200mA total.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-05-02T14:04:55.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1376" PostTypeId="2" ParentId="117" CreationDate="2014-05-02T14:11:30.250" Score="1" Body="&lt;p&gt;For a &lt;a href=&quot;https://github.com/hoosierEE/MicroPiano/blob/master/keykey/my_functions.ino#L106-L115&quot; rel=&quot;nofollow&quot;&gt;class project&lt;/a&gt; I used a CD4024 and two Arduino pins to drive a 7-segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some caveats to this approach. For example, to write a &lt;code&gt;high&lt;/code&gt; value to the first output of a ripple counter only requires a &lt;code&gt;reset&lt;/code&gt; and toggling the clock pin twice. But if you want to write &lt;code&gt;high&lt;/code&gt; to all n pins requires toggling the clock pin 2&lt;sup&gt;n&lt;/sup&gt; times, and during that time all the other pins are constantly toggling on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your application can deal with these limitations and you're short on pins, it's another option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus answer: there are a lot of examples of multiplexing inputs &lt;a href=&quot;http://www.openmusiclabs.com/learning/digital/input-matrix-scanning/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, many of which also apply to multiplexing outputs.&lt;/p&gt;&#xA;" OwnerUserId="889" LastActivityDate="2014-05-02T14:11:30.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1377" PostTypeId="5" CreationDate="2014-05-02T15:02:42.630" Score="0" Body="&lt;p&gt;This chart graphs the differences between the different Digi XBee modules &lt;a href=&quot;http://www.digi.com/pdf/chart_xbee_rf_features.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.digi.com/pdf/chart_xbee_rf_features.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T18:53:03.797" LastActivityDate="2014-05-02T18:53:03.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1378" PostTypeId="4" CreationDate="2014-05-02T15:02:42.630" Score="0" Body="XBee is a family of form factor compatible radio modules. Most are based on the 802.15.4-2003 standard." OwnerUserId="1263" LastEditorUserId="1263" LastEditDate="2014-05-02T18:52:57.793" LastActivityDate="2014-05-02T18:52:57.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1379" PostTypeId="2" ParentId="117" CreationDate="2014-05-02T15:08:51.920" Score="2" Body="&lt;p&gt;If it's all about LEDs, what about WS2812B LED strips, or just the driver chips themselves? You can control a virtually unlimited number of LEDs using just one pin! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although people are use to these in strips, they are available as standalone LEDs (known as neo pixels on Adafruit). Or if you're only driving a single colour, each WS2811 chip could control 3 LEDs by using each of the RGB outputs for a single LED each. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently just created created a project that uses 5 such LEDs: Door1 open/closed, Door2 open/closed, motor1 active, motor2 active and power. The &quot;active&quot; LEDs are dual purpose since I have red being the input from active motor and green being active flag inside the Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point being, with 1 pin and the library installed, you can control any number of LEDs &lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="6936" LastEditDate="2015-04-28T18:13:30.107" LastActivityDate="2015-04-28T18:13:30.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1380" PostTypeId="1" CreationDate="2014-05-02T15:46:20.820" Score="2" ViewCount="2087" Body="&lt;p&gt;I recently bought an Arduino Micro to see what all the fuss was about and I figured I'd use it with Ubuntu on an older Dell Latitude. I was able to install all of the files using some tutorials but I have this problem uploading sketches. After plugging in the board, the green top LED is consistently flashing so it seems to be working, but when I try to upload a sketch I get the following error &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connecting to programmer: .avrdude: Send: . [1b] &#xA;avrdude: Send: S [53] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to fix this? I tried pressing reset during the send as some forums have suggested but it doesnt seem to be working. &lt;/p&gt;&#xA;" OwnerUserId="1277" LastEditorUserId="11" LastEditDate="2014-05-02T18:54:24.490" LastActivityDate="2016-03-20T03:58:57.233" Title="Sketches not uploading to Micro from Ubuntu 14.04" Tags="|uploading|ubuntu|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1381" PostTypeId="1" CreationDate="2014-05-02T16:51:46.767" Score="1" ViewCount="74" Body="&lt;p&gt;I can't figure out why the next script is not working. I have attached the Arduino to one USB port of the raspberry pi, in which I've installed pyserial. I just want to turn off/on a led depending of the number I write on the Raspi console (1-&gt; on, 2-&gt; off).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int led=13;&#xA;&#xA;void setup(){&#xA;  Serial.begin(115200);&#xA;  pinMode(led,OUTPUT);&#xA;}&#xA;void loop(){&#xA;  if(Serial.available()){    &#xA;     mode(Serial.read() - '0');  &#xA;  }&#xA;}  &#xA;void  mode(int n){&#xA;&#xA;    if (n== 1){&#xA;         digitalWrite(led,HIGH);&#xA;    }    &#xA;    if (n== 2){&#xA;        digitalWrite(led,LOW);     &#xA;    }   &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: I double checked and the baudrate is configured also at 115200 at the raspi side.&#xA;In addition, if I place digitalWrite(led,HIGH) just before  the line  &quot;mode(Serial.read() - '0');&quot; the led turn on when I send some information from the raspi shell (so, works well). &lt;/p&gt;&#xA;" OwnerUserId="1278" LastActivityDate="2014-06-02T08:37:35.417" Title="Simple Script controlled by Raspberry not working" Tags="|serial|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1382" PostTypeId="2" ParentId="1381" CreationDate="2014-05-03T08:11:11.870" Score="1" Body="&lt;p&gt;Finally I've found the error, it was the serial communication baud rate: 115200. It seems that at higher speeds it not works properly, lowering it to 9600 do the trick.&lt;/p&gt;&#xA;" OwnerUserId="1278" LastActivityDate="2014-05-03T08:11:11.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1383" PostTypeId="2" ParentId="1241" CreationDate="2014-05-03T09:19:54.167" Score="1" Body="&lt;p&gt;I've experienced same behavior with this type of servos. In my case it was easier to spot since Arduino frequently rebooted when servo was approaching the boundaries of the swing - so it was clear it was consuming too much power, and USB port was unable to deliver that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheap dedicated 9V 1A AC/DC converter usually solves the problem. But if you can't wait for one to get delivered, get an iPad USB charger (nowadays everyone has it or has a neighbor/friend who has one). It is rated 10W, and it doesn't suffer from voltage drops even under high loads. Power your setup from it, and if you'd see it moves smoothly, you will have your answer.&lt;/p&gt;&#xA;" OwnerUserId="562" LastActivityDate="2014-05-03T09:19:54.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1384" PostTypeId="1" AcceptedAnswerId="1385" CreationDate="2014-05-03T12:26:07.773" Score="4" ViewCount="24850" Body="&lt;p&gt;I have a stepper motor connected to my Arduino like this using the ULN2003A Darlington Array:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Reference/unipolar_stepper_four_pins.jpg&quot; alt=&quot;Circuit Diagram&quot;&gt;&lt;br&gt;&#xA;&lt;img src=&quot;https://static.flickr.com/32/54357295_756c131217.jpg&quot; alt=&quot;Image&quot;&gt;&#xA;(Ignore the potentiometer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have programmed it with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;int in1Pin = 22;&#xA;int in2Pin = 23;&#xA;int in3Pin = 24;&#xA;int in4Pin = 25;&#xA;&#xA;Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(in1Pin, OUTPUT);&#xA;    pinMode(in2Pin, OUTPUT);&#xA;    pinMode(in3Pin, OUTPUT);&#xA;    pinMode(in4Pin, OUTPUT);&#xA;&#xA;    motor.setSpeed(25);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int steps = 360;&#xA;&#xA;    motor.step(steps);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the moment the motor rotates clockwise, how could I have it so it rotates in the opposite direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code was copied and edited from &lt;a href=&quot;http://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors/arduino-code&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The problem was that I had the two middle wires the wrong way round as said here: &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=kvi8dt2b5en5hhk02dlmjrotl5&amp;amp;topic=143276.msg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?PHPSESSID=kvi8dt2b5en5hhk02dlmjrotl5&amp;amp;topic=143276.msg&lt;/a&gt;‌​&lt;/p&gt;&#xA;" OwnerUserId="1290" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.330" LastActivityDate="2018-12-11T09:11:33.697" Title="Reverse turning of Stepper motor" Tags="|programming|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1385" PostTypeId="2" ParentId="1384" CreationDate="2014-05-03T12:40:37.393" Score="2" Body="&lt;p&gt;The answer is simple. Just pass a negative number of steps as an argument to &lt;code&gt;motor.step();&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another note: You forgot a semicolon on your second to last line. IIRC this doesn't matter in C, but &lt;strong&gt;it's just bad practice to do this.&lt;/strong&gt; If you add a line of code below that, then it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;int in1Pin = 22;&#xA;int in2Pin = 23;&#xA;int in3Pin = 24;&#xA;int in4Pin = 25;&#xA;&#xA;Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(in1Pin, OUTPUT);&#xA;    pinMode(in2Pin, OUTPUT);&#xA;    pinMode(in3Pin, OUTPUT);&#xA;    pinMode(in4Pin, OUTPUT);&#xA;&#xA;    motor.setSpeed(25);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int steps = 360;&#xA;    motor.step(steps);&#xA;    delay(100);&#xA;&#xA;    steps = -360;&#xA;    motor.step(steps);&#xA;    delay(500); //Semicolon added&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-03T12:40:37.393" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1386" PostTypeId="1" CreationDate="2014-05-03T16:12:09.187" Score="3" ViewCount="284" Body="&lt;p&gt;I'm using an Arduino Due with a logic level converter to interface with two different 5v sensors via I2C. Being of poor quality, these sensors have no data sheet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When either one of these sensors is plugged in, I am able to read from it without issue. The moment I plug the other one in as well, the I2C stops working, and I just get 0. I know that it's not an address collision issue, because they have different addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adding an additional set of pull-up resistors (such that they are in parallel with the built-in ones) in order to counteract potentially increased bus capacitance, but no dice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing this issue? I apologise for asking such a noob question.&lt;/p&gt;&#xA;" OwnerUserId="1112" LastEditorUserId="4628" LastEditDate="2014-12-13T21:13:40.187" LastActivityDate="2014-12-13T21:13:40.187" Title="Adding devices makes I2C read 0" Tags="|arduino-due|voltage-level|i2c|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1387" PostTypeId="1" CreationDate="2014-05-03T17:01:21.947" Score="3" ViewCount="826" Body="&lt;p&gt;I wanted to take the audio from a device such as the PC, insert it through different ADC in arduino, processing them with DSP and DAC REnter all through to the other speakers, reading here and there on the internet but some people were put in difficulty because Arduino has a data bus to 10 bits. What problems can cause this? I can not send the same 10 bits at a time, until you arrive at 32?&lt;/p&gt;&#xA;" OwnerUserId="1294" LastActivityDate="2017-06-17T21:36:11.410" Title="Arduino 1 can somehow support 32-bit audio?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ClosedDate="2017-06-19T12:15:32.100" ContentLicense="CC BY-SA 3.0" />
  <row Id="1388" PostTypeId="2" ParentId="1387" CreationDate="2014-05-03T17:20:21.887" Score="1" Body="&lt;p&gt;First of all,&lt;em&gt;what is the point of this?&lt;/em&gt; &lt;a href=&quot;https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem&quot;&gt;I'm afraid this is a XY question&lt;/a&gt;. You won't get that good of quality with Arduino. If you're hoping to create some sort of an amp, learn electronics and do that directly. Maybe you should just send data via serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, that aside, here's a chart I drew:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L8BAr.png&quot; alt=&quot;&quot;&gt;&#xA;(Excuse my poor image alignment, PowerPoint was being a little mean today)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bottom is all the &quot;channels&quot; the PC can send. The top is all the &quot;channels&quot; the Arduino can recieve. As you can see, there's a &lt;em&gt;huge&lt;/em&gt; degradation in quality. Not to mention, I made this that 1 bit = 1 &quot;channel,&quot; yet it's very much more than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A standard Arduino (Uno, Leonardo, etc.) has a 10 bit ADC that can read values 0-1023. The computer can output 0-4294967295! (It' exponentially grows due to permutations). You can see why I very much simplified my chart! :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DSP won't really work well, unless you are trying to do some weird alien sounding modifications or a cheesy echo to. You probably will want to add an external 32 bit ADC. I would recommend, additionally, adding a Due or Galileo that can process 32 bit integers without emulating a bigger chip, thus greatly reducing performance and giving you a low framerate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr: It'll work fine, but it'll have horrible sound quality. You can't send the same 10 bits until 32, since the computer changes that 32 bits into a voltage (sent to Arduino), and the Arduino translates that voltage into 10 bits.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-03-20T10:32:30.027" LastActivityDate="2014-05-03T17:20:21.887" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1389" PostTypeId="2" ParentId="26" CreationDate="2014-05-03T17:29:19.923" Score="3" Body="&lt;p&gt;I finally found what was causing the problem: the reset signal from pin 4 (DTR - Data Terminal Ready) on the DB9-Female connector was spiking up to 10V before going to 0V and was triggering high-voltage programming on the ATmega. Below is a scope shot showing the situation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/IM3RF.png&quot; alt=&quot;Scope shot showing voltage spike to 10V&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The yellow trace is &lt;code&gt;DTR&lt;/code&gt; signal while the green trace is the &lt;code&gt;RESET&lt;/code&gt; signal on the ATmega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to Atmel's &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_application-note_avr042.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmel AVR042: AVR Hardware Design Considerations application note&lt;/a&gt;, one should add an ESD diode between ATmega's &lt;code&gt;RESET&lt;/code&gt; and &lt;code&gt;Vcc&lt;/code&gt; to prevent the reset signal from triggering high-voltage programming mode, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GJuGd.png&quot; alt=&quot;Recommended RESET pin connection for ATmegas&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After adding such a small signal diode (1N4148) like the app note recommended, I got the issue fixed. See below the scope shot taken after the diode was added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kwpzB.png&quot; alt=&quot;Scope shot after fixing the board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the 10V peak is gone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That was a tricky one!! But I could never find what was wrong without research and the right tools. Money on a scope is money well spent!!&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-05-03T17:29:19.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1390" PostTypeId="1" CreationDate="2014-05-03T19:28:29.243" Score="0" ViewCount="132" Body="&lt;p&gt;How to make an input from computer using processing (like a password form) and trigger pin in arduino?&#xA;If you let some link to read more that would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2014-06-03T16:16:36.197" Title="Processing Input" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1391" PostTypeId="1" CreationDate="2014-05-03T19:56:33.070" Score="8" ViewCount="6295" Body="&lt;p&gt;I'm using the &lt;a href=&quot;http://www.pololu.com/product/2132&quot; rel=&quot;noreferrer&quot;&gt;Pololu DRV8825 Stepper Motor Driver&lt;/a&gt; to control a &lt;a href=&quot;http://www.ebay.co.uk/itm/Nema-17-1-7A-2-55V-Motor-ACT-17HS4417-Rep-rap-Nema17-Bipolar-/281122696759&quot; rel=&quot;noreferrer&quot;&gt;NEMA 17 Steppermotor&lt;/a&gt; with an Arduino Uno.  According to the Pololu website, the circuit should be wired as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/x76EK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did, however, deviate from this exact sketch a little bit:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Arduino (microcontroller) is powered by a USB cable connected to the computer&lt;/li&gt;&#xA;&lt;li&gt;I connected the 5V pin on the arduino to the + rail on a breadboard.  I then connected two wires on this rail to the &lt;strong&gt;RESET&lt;/strong&gt; and &lt;strong&gt;SLEEP&lt;/strong&gt; pins on the driver.&lt;/li&gt;&#xA;&lt;li&gt;I'm using a 9V battery to power the motor.&lt;/li&gt;&#xA;&lt;li&gt;I've connected the &lt;strong&gt;DIR&lt;/strong&gt; and &lt;strong&gt;STEP&lt;/strong&gt; pins to Arduino Uno pins 12 &amp;amp; 13, respectively.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Consequently, I coded and uploaded the following sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int stp = 13;  //connect pin 13 to step&#xA;int dir = 12;  // connect pin 12 to dir&#xA;int a = 0;     //  gen counter&#xA;&#xA;void setup() &#xA;{                &#xA;  pinMode(stp, OUTPUT);&#xA;  pinMode(dir, OUTPUT);       &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (a &amp;lt;  200)  //sweep 200 step in dir 1&#xA;   {&#xA;    a++;&#xA;    digitalWrite(stp, HIGH);   &#xA;    delay(10);               &#xA;    digitalWrite(stp, LOW);  &#xA;    delay(10);              &#xA;   }&#xA;  else &#xA;   {&#xA;    digitalWrite(dir, HIGH);&#xA;    a++;&#xA;    digitalWrite(stp, HIGH);  &#xA;    delay(10);               &#xA;    digitalWrite(stp, LOW);  &#xA;    delay(10);&#xA;&#xA;    if (a&amp;gt;400)    //sweep 200 in dir 2&#xA;     {&#xA;      a = 0;&#xA;      digitalWrite(dir, LOW);&#xA;     }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;RESULT&lt;/strong&gt;&lt;br&gt;&#xA;The stepper motor does not turn.  Instead, it just hisses at a high pitch.  After a short while, the driver gets very hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;THINGS I'VE TRIED&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I double checked to make sure that connected stepper wires pairs are properly connected to the &quot;A&quot; pins and &quot;B&quot; pins on the driver.&lt;/li&gt;&#xA;&lt;li&gt;I tried reversing the A1-A2 pair and B1-B2 pair in all possible combinations.  All combinations produce the same result as above.&lt;/li&gt;&#xA;&lt;li&gt;I tried increasing the motor power supply to 12V (8 alkaline AA batteries).  The same result occurs.&lt;/li&gt;&#xA;&lt;li&gt;I double checked to make sure the 100microF radial electrolytic capacitor is connected with the long end to the positive motor supply and short end to the negative motor supply (on a different breadboard rail than the logic power supply, of course).&lt;/li&gt;&#xA;&lt;li&gt;I tried using the 3.3V pin instead of the 5V pin to connect to SLEEP and RESET on the driver.  Again, the same result occurs.  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm not really sure what to try next to debug my circuit.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Hunch:&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do, however, have one suspicion based on a little warning box on the pololu website which reads:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Caution:&lt;/strong&gt; Installing the header pins so that the silkscreen side is up&#xA;  and the components are down can limit the range of motion of the&#xA;  trimpot used to set the current limit. If you plan on installing the&#xA;  header pins in this orientation, please set the current limit before&#xA;  soldering in the pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The way I soldered the headers onto the driver looks like the bottom left corner of the picture below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I4p4R.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Question:&lt;/strong&gt;&lt;br&gt;&#xA;Given that my stepper motor requires 1.7A current, is there anything I can do to improve this circuit to make it work?  Did I make any mistakes?  Is there anything else I should try or check?  Did I solder the header in the wrong way?&lt;/p&gt;&#xA;" OwnerUserId="667" LastEditorUserId="667" LastEditDate="2014-05-04T17:41:52.067" LastActivityDate="2016-01-04T19:40:57.463" Title="Debugging my Stepper Motor Driver circuit" Tags="|motor|" AnswerCount="4" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="1393" PostTypeId="2" ParentId="1391" CreationDate="2014-05-03T22:28:48.937" Score="2" Body="&lt;p&gt;&lt;strong&gt;A couple things I noticed first:&lt;/strong&gt; This is one of the best formatted questions I've ever seen... :) Anyway, your circuit looks fine to me except for a few things:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; This carrier board uses low-ESR ceramic capacitors, which makes it susceptible to destructive LC voltage spikes, especially when using power leads longer than a few inches. Under the right conditions, these spikes can exceed the 45 V maximum voltage rating for the DRV8825 and permanently damage the board, even when the motor supply voltage is as low as 12 V. One way to protect the driver from such spikes is to put a large &lt;strong&gt;(at least 47 µF) &lt;em&gt;electrolytic&lt;/em&gt; capacitor across motor power (VMOT) and ground&lt;/strong&gt; somewhere close to the board.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Added some italic/bold myself, quote from product page.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capacitors are cheap ($1.50 on eBay from US), and although new drivers are too, it's generally a good idea to build it right. There's nothing more annoying than waiting for shipping on something you shouldn't have had to fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, battery power (especially AAs) can be bulky if not done right, and may not provide enough current. Note that in a series configuration that &lt;strong&gt;it will provide the voltage of 8 AAs, but only the current of one.&lt;/strong&gt; You can't run a 1.7 A motor off of a single AA's current. Stab in the dark guess: you'll need ~80-100 AAs to provide enough current and voltage. I'm too lazy to measure the internal resistance and actually calculate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Suggested solution:&lt;/strong&gt; There are a million things that could go wrong. Without being there, I'm betting that your delay function is too short. What this will do is not provide enough time for the motor to move, thus it staying still. This would still use a lot of current (50% of the time it's full current to motor coils), therefore it would make the driver hot. (&lt;strong&gt;Note on heat:&lt;/strong&gt; &lt;em&gt;...to supply more than approximately 1.5 A per coil, a heat sink or other cooling method is required...&lt;/em&gt; -Product page: you'll need a heatsink to cool your chip down.) Also note that some heat is normal; a general rule of thumb is if it's too hot to hold your thumb on it for a few seconds, you need more cooling. Remember that the more it's used, the hotter it'll get, so keep this in mind when deciding if you want to add a heatsink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; You need to increase the delay time and provide more current than you have currently.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-03T22:28:48.937" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="1394" PostTypeId="2" ParentId="1390" CreationDate="2014-05-04T07:25:22.860" Score="0" Body="&lt;p&gt;You need to have a look at the Serial commands: &lt;a href=&quot;http://arduino.cc/en/Serial/read&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Serial/read&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ReadASCIIString&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ReadASCIIString&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1290" LastActivityDate="2014-05-04T07:25:22.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1395" PostTypeId="1" CreationDate="2014-05-04T09:33:20.107" Score="5" ViewCount="2473" Body="&lt;p&gt;im just looking for how to send/ write date to pc over serial port from arduino..vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have few Question to ask after taking so much time and couldn't figure it out myself. I hope you guys can guid me please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, i found i can use Serial.println() function to send some data then, on the pc side, it just checks and reads the port (/dev/tty..). But, how does this process actually work under the hood? So, if you use serial.println() it knows about where to write?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second i also found it's something to do with UART communication.. But, inside Hardware.cpp file, i couldn't find any function call to the one for UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third there is the code like extern HardwareSerial Serial; Then where is the definition of this Serial?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth There seem to have ring buffer for serial buffer. So, when data is being sent then, what and who fill the data into this buffer inside Hardware.cpp?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;please, forgive my silly question.. i'm just so curious about this..&lt;/p&gt;&#xA;" OwnerUserId="1301" LastActivityDate="2015-02-24T10:34:02.103" Title="how does serial port communication work under the hood?" Tags="|arduino-uno|programming|serial|c++|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1396" PostTypeId="1" CreationDate="2014-05-04T09:46:57.793" Score="4" ViewCount="4245" Body="&lt;p&gt;I have an Arduino GSM Shield mounted on an Arduino Uno. Can I stack this &lt;a href=&quot;https://www.sparkfun.com/products/10709#comment-5366048bce395fa40e8b4567&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPS shield&lt;/a&gt; above Arduino GSM shield? Will there be any pin configuration problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In GSM Shield hardware pin’s configuraton are as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 - Not connected&#xA;1 - Not connected&#xA;2 - GSM Rx&#xA;3 - GSM Tx&#xA;7 - Modem reset&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there is any problem, how can it be solved? I would be happy if there are any alternatives for the GPS shield.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-gsm-shield-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic of the Arduino GSM shield&lt;/a&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7ttFF.png&quot; alt=&quot;schematic of the Arduino GSM shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/GPSShield-v16.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic of the SparkFun GPS shield&lt;/a&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/zZUxI.png&quot; alt=&quot;schematic of the SparkFun GPS shield&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="84" LastEditDate="2015-02-12T05:58:39.970" LastActivityDate="2015-03-08T12:49:13.780" Title="Arduino shield stacking" Tags="|arduino-uno|gsm|tinygps|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1397" PostTypeId="1" AcceptedAnswerId="1400" CreationDate="2014-05-04T10:03:15.157" Score="1" ViewCount="4139" Body="&lt;p&gt;I am communicating with the Web server's database via Arduino GSM shield + GPRS connectivity&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{&#xA;  if (client.connect(server, port)) &#xA;     { &#xA;       ....... &#xA;      }&#xA;  else &#xA;     { &#xA;      Serial.println(&quot;Server not found&quot;); &#xA;      } &#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first time when the loop() runs in the serial port, the code works perfectly and stores in my server's db. The second time when the loop() runs after some delay, It is unable to connect to the server and results &quot;server not found&quot; . I don't know what is the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know if there is a way to connect continuously. Thank you&lt;/p&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2014-05-05T19:58:41.893" Title="client.connect() fails except the first time" Tags="|arduino-uno|gsm|web-server|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1398" PostTypeId="2" ParentId="1396" CreationDate="2014-05-04T10:42:18.900" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;https://www.sparkfun.com/products/10710&quot; rel=&quot;nofollow&quot;&gt;the shield description&lt;/a&gt;, the TX and RX of the GPS are mapped on pins 2 &amp;amp; 3, like your GSM, so you'll have to change that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Adafruit GPS + flash card shield, which is a bit cheaper (and uses pins 7&amp;amp;8).&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2014-05-04T10:42:18.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1399" PostTypeId="2" ParentId="1396" CreationDate="2014-05-04T10:42:50.197" Score="6" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I7hXM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;br&gt;&#xA;&lt;sup&gt;&lt;em&gt;Photo by &lt;a href=&quot;http://tronixstuff.com/&quot; rel=&quot;noreferrer&quot;&gt;John Boxall&lt;/a&gt;&lt;/em&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Which pins do they use?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To determine if two shields are compatible, you have to read the specifications of both shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best source for this information is the data sheets supplied with the shields. However there is also this &lt;a href=&quot;http://shieldlist.org/&quot; rel=&quot;noreferrer&quot;&gt;Shield List&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Can you reassign pins?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some shields provide a means to alter which pins are used for communications. This can take the form of a switch or a jumper - either pull-off or solder-bridge type. (the GPS shield in the question has jumpers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the shields do not support pin-reassignment or provides insufficient flexibility, to work-around incompatibilities you can use an in-between shield designed for the purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11002&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; is one example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You hear it all the time in the Arduino community, “will this shield work with my other shield?.” I think we’ve all been disappointed to find that two of our favorite shields compete for control of a digital pin here or a serial pin there. While there are sometimes some clever workarounds from elegant code modifications to aggressive ‘greenwiring,’ Mayhew Labs may have come up with the simplest solution thus far: The Go-Between Shield.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;Are any alternatives for the foo shield&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I notice that Arduino.cc now point people to the list referenced above. They used to have their &lt;a href=&quot;http://playground.arduino.cc/Main/SimilarBoards#goShie&quot; rel=&quot;noreferrer&quot;&gt;own list&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product recommendations are off-topic here but, obviously, you can &lt;a href=&quot;https://www.google.com/search?q=gps+shield&quot; rel=&quot;noreferrer&quot;&gt;search&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="316" LastEditorUserId="316" LastEditDate="2014-05-04T15:22:45.800" LastActivityDate="2014-05-04T15:22:45.800" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1400" PostTypeId="2" ParentId="1397" CreationDate="2014-05-04T12:55:31.750" Score="2" Body="&lt;p&gt;You have to disconnect before being able to connect again otherwise the controller will crash due to memory starvation. Every connect you do takes some memory to register state information. Not sure of the exact commands involved, but it'd look a bit like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (client.connect(server, port)) &#xA;     { &#xA;       ....... &#xA;       client.disconnect( .... );&#xA;      }&#xA;  else &#xA;........&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can check if you are already connected, and only do a reconnect when necessary, but I don't know which library you are using, let alone if there is a proper check available in it.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-05-04T13:00:49.240" LastActivityDate="2014-05-04T13:00:49.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1401" PostTypeId="1" AcceptedAnswerId="6668" CreationDate="2014-05-04T16:03:46.523" Score="7" ViewCount="1404" Body="&lt;p&gt;So, when searching for a way to play audio files through the Arduino, I came across this site: &lt;a href=&quot;http://maxoffsky.com/maxoffsky-blog/how-to-play-wav-audio-files-with-arduino-uno-and-microsd-card/&quot; rel=&quot;nofollow&quot;&gt;How to play WAV audio files with Arduino Uno and MicroSD card&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems like a really good library (although I haven't had the time to really play around with it yet). Has anyone used this before, and, if so, is it a good library to use, or do you know of better ones out there which you would recommend?&lt;/p&gt;&#xA;" OwnerUserId="1303" LastEditorUserId="6936" LastEditDate="2015-07-25T16:51:52.703" LastActivityDate="2015-07-25T16:51:52.703" Title="Playing audio files with sine wave from arduino" Tags="|pins|sd-card|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1402" PostTypeId="2" ParentId="1397" CreationDate="2014-05-04T18:09:21.537" Score="1" Body="&lt;pre&gt;&lt;code&gt;void loop() &#xA;{&#xA; if (client.connect(server, port)) &#xA; { &#xA;   ....... &#xA;&#xA;   client.stop(); &#xA;  }&#xA;&#xA; else &#xA; { &#xA;  Serial.println(&quot;Server not found&quot;); &#xA;  } &#xA; delay(1000); &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="1302" LastEditDate="2014-05-05T19:58:41.893" LastActivityDate="2014-05-05T19:58:41.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1403" PostTypeId="2" ParentId="1395" CreationDate="2014-05-05T00:02:12.963" Score="2" Body="&lt;p&gt;Serial.println knows where to write because Serial is an object. On boards with more than one port there will also be a Serial1,Serial2,etc. Each object corresponds to a port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ring buffers are filled from interrupts. When a new byte comes in, it triggers an interrupt that puts the byte in the buffer. When a byte is finished sending it triggers another interrupt that reads the next byte from the buffer and sends it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somewhere there is a source file that sets up the UART. It's full of writing special values to registers and low level things like that. I'm not sure what files things are defined in, but if you use the search feature on github there is tons of interesting stuff.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-05-05T00:02:12.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1404" PostTypeId="1" AcceptedAnswerId="1432" CreationDate="2014-05-05T04:51:03.373" Score="1" ViewCount="3892" Body="&lt;p&gt;I'm trying to fix arduino uno r3 that was burned-out.&#xA;I changed m16u2 chip on it. and now I need burn in:  &lt;code&gt;Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex&lt;/code&gt;&#xA;I'm using stk500v2 and connecting it to isp of arduino. Output log file of avrdude:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\&amp;gt;avrdude -c stk500v2 -P COM4 -p m16u2 -U flash:w:1.hex -vvvv&#xA;&#xA;avrdude: Version 6.1, compiled on Mar 13 2014 at 00:09:49&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2014 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\WinAVR-20100110\bin\avrdude.conf&quot;&#xA;&#xA;&#xA;         Using Port                    : COM4&#xA;         Using Programmer              : stk500v2&#xA;avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [01]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [0b]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [01]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [08]&#xA;avrdude: Recv: A [41]&#xA;avrdude: Recv: V [56]&#xA;avrdude: Recv: R [52]&#xA;avrdude: Recv: I [49]&#xA;avrdude: Recv: S [53]&#xA;avrdude: Recv: P [50]&#xA;avrdude: Recv: _ [5f]&#xA;avrdude: Recv: 2 [32]&#xA;avrdude: Recv: t [74]&#xA;avrdude: stk500v2_getsync(): found AVRISP programmer&#xA;         AVR Part                      : ATmega16U2&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC6&#xA;         RESET disposition             : possible i/o&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           eeprom        65    20     4    0 no        512    4    128  9000  90&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           flash         65     6   128    0 yes     16384  128    128  4500  45&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  90&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  90&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           efuse          0     0     0    0 no          1    0      0  9000  90&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           lock           0     0     0    0 no          1    0      0  9000  90&#xA;00 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           calibration    0     0     0    0 no          1    0      0     0&#xA; 0 0x00 0x00&#xA;                                  Block Poll               Page&#xA;      Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max&#xA;W   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---&#xA;-- ---------&#xA;           signature      0     0     0    0 no          3    0      0     0&#xA; 0 0x00 0x00&#xA;&#xA;         Programmer Type : STK500V2&#xA;         Description     : Atmel STK500 Version 2.x firmware&#xA;         Programmer Model: AVRISP&#xA;avrdude: Send: . [1b] . [02] . [00] . [02] . [0e] . [03] . [90] . [86]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [02]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [02]&#xA;avrdude: Recv: . [15]&#xA;avrdude: Send: . [1b] . [03] . [00] . [02] . [0e] . [03] . [91] . [86]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [02]&#xA;avrdude: Recv: . [14]&#xA;avrdude: Send: . [1b] . [04] . [00] . [02] . [0e] . [03] . [92] . [82]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [04]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [0a]&#xA;avrdude: Recv: . [1b]&#xA;         Hardware Version: 2&#xA;         Firmware Version Master : 2.10&#xA;avrdude: Send: . [1b] . [05] . [00] . [02] . [0e] . [03] . [94] . [85]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [05]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [03]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: U [55]&#xA;avrdude: Recv: E [45]&#xA;         Vtarget         : 8.5 V&#xA;         SCK period      : 0.1 us&#xA;&#xA;avrdude: Send: . [1b] . [06] . [00] . [0c] . [0e] . [10] . [c8] d [64] . [19]&#xA;[20] . [00] S [53] . [03] . [ac] S [53] . [00] . [00] 5 [35]&#xA;avrdude: Recv: . [1b]&#xA;avrdude: Recv: . [06]&#xA;avrdude: Recv: . [00]&#xA;avrdude: Recv: . [02]&#xA;avrdude: Recv: . [0e]&#xA;avrdude: Recv: . [10]&#xA;avrdude: Recv: . [c0]&#xA;avrdude: Recv: . [c1]&#xA;avrdude: stk500v2_command(): command failed&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;    avrdude: Send: . [1b] . [07] . [00] . [03] . [0e] . [11] . [01] . [01] . [00]&#xA;    avrdude: Recv: . [1b]&#xA;    avrdude: Recv: . [07]&#xA;    avrdude: Recv: . [00]&#xA;    avrdude: Recv: . [02]&#xA;    avrdude: Recv: . [0e]&#xA;    avrdude: Recv: . [11]&#xA;    avrdude: Recv: . [00]&#xA;    avrdude: Recv: . [01]&#xA;&#xA;    avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is what block with error does? can it be I shorted due soldering? or maybe burned chip? any issues? how I can check?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ps. programmer works perfect. checked!&lt;/p&gt;&#xA;" OwnerUserId="1309" OwnerDisplayName="Klasik" LastActivityDate="2014-05-06T20:58:13.990" Title="arduino 16u2 stk500v2_command(): command failed" Tags="|avr|avrdude|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1405" PostTypeId="1" CreationDate="2014-05-05T06:45:31.807" Score="3" ViewCount="7011" Body="&lt;p&gt;The Xbee requires a 3.3V power input and the Arduino Pro Mini (5V version) only provides a regulated 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; What will be the simplest way to provide a 3.3V rail to the XBee from the Arduino Pro Mini? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we use a voltage divider consisting of 2 resistors, the ratio should be 66/100, but how do we choose the resistor values?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we choose a 3.3V voltage regulator, will the &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000446.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;STMicroelectronics L78L33ACZ&lt;/a&gt; be suitable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3nr5L.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Between the voltage divider and voltage regulator, which is the preferred method? Is there a better alternative?&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="639" LastEditDate="2014-05-05T08:07:52.957" LastActivityDate="2014-05-11T15:36:28.237" Title="Using 3.3V XBee with Arduino Pro Mini 5V Version" Tags="|xbee|voltage-level|arduino-pro-mini|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1407" PostTypeId="2" ParentId="1370" CreationDate="2014-05-05T09:39:37.197" Score="2" Body="&lt;p&gt;Thanks to @Madivad for the AT command inspiration. I am not very familiar with GSM and Arduino. But anyway, the below worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Credits to @Madivad and &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=163155.0&quot; rel=&quot;nofollow&quot;&gt;people from the arduino forum.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;GSM gsmAccess(true);&#xA;int sizer = 200;&#xA;char myNumber[200];&#xA;int timeout = 5000; // in milli seconds&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  boolean notConnected = true;&#xA;&#xA;  Serial.println(&quot;Connecting to the GSM network&quot;);&#xA;&#xA;  while(notConnected){&#xA;    if(gsmAccess.begin() == GSM_READY) // Note: I do not require PIN #&#xA;      notConnected = false;&#xA;    else {&#xA;      Serial.println(&quot;Not connected, trying again&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(&quot;Connected&quot;);&#xA;&#xA;  theGSM3ShieldV1ModemCore.println(&quot;AT+CPBS=\&quot;SM\&quot;&quot;);  &#xA;  int start1 = millis();   &#xA;  while((millis() - start1) &amp;lt; timeout){&#xA;    Serial.print(theGSM3ShieldV1ModemCore.theBuffer().read());&#xA;  }   &#xA;  Serial.print(&quot;Set to look at SIM card storage&quot;);&#xA;&#xA;  // search for contact name &quot;test&quot;&#xA;  theGSM3ShieldV1ModemCore.println(&quot;AT+CPBF=\&quot;test\&quot;&quot;);  &#xA;  start1 = 0;&#xA;  start1 = millis();   &#xA;  while((millis() - start1) &amp;lt; timeout &amp;amp;&amp;amp; !theGSM3ShieldV1ModemCore.theBuffer().extractSubstring(&quot;,\&quot;&quot;, &quot;\&quot;,&quot;, myNumber, sizer)){&#xA;    Serial.print(theGSM3ShieldV1ModemCore.theBuffer().read());&#xA;  }   &#xA;  Serial.print(&quot;Got contact number&quot;);&#xA;&#xA; // print out the phone of &quot;test&quot;&#xA; Serial.println(myNumber);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1049" LastActivityDate="2014-05-05T09:39:37.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1410" PostTypeId="1" CreationDate="2014-05-05T17:41:26.540" Score="1" ViewCount="594" Body="&lt;p&gt;I'm just now getting into electronics (I don't know why I waited so long) and I'm just figuring out some stuff.  I picked up an Arduino kit from &lt;a href=&quot;http://www.vilros.com/arduino/uno-rev-3/ultimate-starter-kit.html&quot; rel=&quot;nofollow&quot;&gt;Vilros.com&lt;/a&gt; and a few other parts for my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently trying to work on a project that is basically a humidor keeper.  Living in So.California, it's extremely dry here and I would like a perfectly controlled environment for my humidor.  I purchased a few things like some humidity sensors (as an input obviously), a humidifier (basically a water canister with a sponge and tubes) some tube splitters and twist valves and most importantly, a small air pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The small air pump is what I'm having problems with at the moment.  &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00FHABXE0&quot; rel=&quot;nofollow&quot;&gt;This is the pump&lt;/a&gt;. Obviously it's a 3v pump.  I will be using the supplied 9v battery cable when the project is ready, so I understand I'll have to use resistors to bring the voltage down so I don't burn out the pump.  As I said, I'm new to this, so I'm trying to figure out ohms law to find out what kind of resistor(s) I will need.  The problem is, I don't know the amperage.  Where would I find this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at the details for the pump and what looks like amps (or milliamps) is really just the product number.  Can anyone help me out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I have my equation as r=6v / ?i  But where do I find the current?&lt;/p&gt;&#xA;" OwnerUserId="1316" LastActivityDate="2014-05-05T18:56:03.657" Title="Figuring out some numbers for a mini pump" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1411" PostTypeId="2" ParentId="1410" CreationDate="2014-05-05T18:16:31.293" Score="1" Body="&lt;p&gt;Unlike voltage, which depends on the source, the current depends on the motor itself. To find the current, you need to run the motor and measure it with a multimeter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              +------------+&#xA;    +---------+ Multimeter |&#xA;    |         +--------+---+&#xA;+---+---+              |    &#xA;| Motor |              |    &#xA;+---+---+  +--------+  |    &#xA;    |      | Power  +--+    &#xA;    +------+ source |       &#xA;           +--------+       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that when the motor is actually pumping, it will draw more current.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-05-05T18:24:45.410" LastActivityDate="2014-05-05T18:24:45.410" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1412" PostTypeId="2" ParentId="1410" CreationDate="2014-05-05T18:56:03.657" Score="2" Body="&lt;p&gt;There are two serious problems with your approach, which you will need to change in order to end up with a sound solution.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If by &quot;9v battery cable&quot; you mean that you intend to use a 9v battery, this is highly unsuitable for motor applications given its low power storage capacity and high internal impedance - without extreme care to use sleep modes, it probably can't even run the Arduino alone for a week.  It would be much more appropriate to use a larger capacity lower voltage source - 4 or 5 C or D cells for example.  A power supply could be another option, though given the water involved, be very careful to pick an isolated one and use a ground fault protected outlet.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Resistors are a poor way of reducing the supply voltage to a motor, as they are not only wasteful, but the applied power will depend too much on the load.  A professional solution would use pulse with modulation to apply the supply voltage at a reduced duty cycle - something you can try with one the various motor shield, but you will need to be careful not to overheat the motor by using too high a duty cycle.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Probably your best bet would be to buy a pump with a 6 or 7v motor (as is showing up in the associated products at the bottom of that page), or even replace the standard-form-factor motor in that pump with a higher voltage one.  A 7v or so supply voltage can then be a compromise solution for running both the motor and the arduino.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-05-05T18:56:03.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1413" PostTypeId="1" AcceptedAnswerId="1415" CreationDate="2014-05-05T20:04:44.733" Score="14" ViewCount="7150" Body="&lt;p&gt;I did some basic Arduino examples in the recent past, but I have never actually seen a shield for Arduino firsthand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder: If I put a shield on an Arduino (for example, the Adafruit Motor Shield), does it &quot;block&quot; the entire Arduino, including all input and output pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use a shield, and still connect additional components that would usually connect directly to the Arduino (say, a potentiometer, or anything similar)? Does this depend on the type of Arduino, or on the type of the shield, or is it not possible at all?&lt;/p&gt;&#xA;" OwnerUserId="1319" LastEditorUserId="46" LastEditDate="2014-05-05T22:00:27.107" LastActivityDate="2015-02-12T05:57:45.857" Title="If I put a shield on an Arduino, can I use the Arduino for anything else?" Tags="|shields|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1414" PostTypeId="2" ParentId="1413" CreationDate="2014-05-05T20:13:08.873" Score="3" Body="&lt;p&gt;As long as the shield uses stackable headers (or provides alternate headers) it doesn't block &lt;em&gt;any&lt;/em&gt; (broken out) pins, either input or output. It is possible to add more shields or components, but the circuit must still be &quot;valid&quot; (all inputs must be either be connected to an output or have the pullup enabled, no more than one push-pull output connected together, etc.), otherwise components may be damaged.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-05T20:13:08.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1415" PostTypeId="2" ParentId="1413" CreationDate="2014-05-05T20:14:35.997" Score="15" Body="&lt;p&gt;Normally, yes, you may plug other components to your setup after you plug your shield, but it depends on the shield exposing the unused Arduino pins through additional female headers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some shields even provide a little protoboard or perfboard to make it convenient for plugging or soldering additional components. Below are some examples:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mHAiC.jpg&quot; alt=&quot;Example of an Arduino protoboard shield&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/VbYmJ.jpg&quot; alt=&quot;Example of an Arduino perfoboard shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino shields are normally designed to be stackable, so you can plug one on top of the other. See &lt;a href=&quot;http://en.wikipedia.org/wiki/Arduino#Shields&quot; rel=&quot;nofollow noreferrer&quot;&gt;more on Arduino shields&lt;/a&gt; from this WikiPedia article. See below one example of stacked shields, shamefully stolen from &lt;a href=&quot;https://arduino.stackexchange.com/a/1399/46&quot;&gt;this great answer by RedGrittyBrick&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I7hXM.jpg&quot; alt=&quot;Example of many Arduino shields stacked together&quot;&gt;&lt;br&gt;&#xA;&lt;sup&gt;&lt;em&gt;Photo by &lt;a href=&quot;http://tronixstuff.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;John Boxall&lt;/a&gt;&lt;/em&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But note that &lt;strong&gt;you need to study carefully what pins each of the shields use to avoid conflicts between the boards&lt;/strong&gt;. Such conflicts may lead to damages.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-05-06T17:28:04.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1417" PostTypeId="2" ParentId="1397" CreationDate="2014-05-05T09:27:52.537" Score="0" Body="&lt;p&gt;If possible, do a check, if it's still connected with the server. Close the connection when work is done. You might also keep using the open connection, just try whatever works best for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But avoid opening a second connection, when you still have an open one. As an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{&#xA;    if(!client.connected())&#xA;    {&#xA;        if (client.connect(server, port))&#xA;        {&#xA;            ...&#xA;            client.disconnect();&#xA;        }&#xA;        else&#xA;            Serial.println(&quot;Server not found&quot;);&#xA;    }&#xA;    else&#xA;        client.disconnect();&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3588410" LastActivityDate="2014-05-05T09:27:52.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1418" PostTypeId="2" ParentId="1413" CreationDate="2014-05-05T21:23:09.140" Score="7" Body="&lt;p&gt;There are several distinct concerns to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Physical interference:&lt;/strong&gt; are headers provided to make it possible to stack the two shields on top of one another?  Do any protruding components block stacking?  Do any components have metal shield cans (for example the USB connector on the Uno itself) which can short out an adjacent PCB?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pin assignments:&lt;/strong&gt; generally you cannot use the same pin for two different purposes.  Many shield provide a way to alter the pins used in order to avoid those used by another shield.  Sometimes you can share a pin, for example two SPI devices can usually share their clock and data lines provided they have separate selects, and you may be able to even use those signals for other purposes while the SPI select is de-asserted.  Sometimes you can move a part from an unavailable hardware peripheral to a software emulated one, for example using software serial, bitbang SPI, or interrupt based PWM.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MCU resources:&lt;/strong&gt; Not specifically the shields themselves, but driver libraries may end up consuming large amounts of program memory or RAM, using up timer channels, needing interrupts frequently services with low latency, etc, so combinations may not be possible or may require alterations to library code.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-05-05T21:23:09.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1419" PostTypeId="2" ParentId="1413" CreationDate="2014-05-05T23:55:39.993" Score="1" Body="&lt;p&gt;Yes, but sometimes it interferes with the output and the input pin, and most shields use up the&#xA;CS, MOSI, MISO, SCK pin. Even through on some shields like wireless SD shield you can switch from USB to MICRO, this is going to interfere with your program. Say, when you want to access&#xA;the info on your SD card to run your Motor Shield.&lt;/p&gt;&#xA;" OwnerUserId="1324" LastEditorUserId="6936" LastEditDate="2015-02-12T05:57:45.857" LastActivityDate="2015-02-12T05:57:45.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1420" PostTypeId="2" ParentId="1329" CreationDate="2014-05-06T01:53:47.163" Score="6" Body="&lt;p&gt;Sorry, but I must disagree with your &lt;em&gt;'NXP datasheet is incomprehensible'&lt;/em&gt;. From the FIRST PAGE of the MFRC522 datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;'Remark: The MFRC522 supports all variants of the MIFARE Mini, MIFARE 1K, &#xA;MIFARE 4K, MIFARE Ultralight, MIFARE DESFire EV1 and MIFARE Plus RF &#xA;identification protocols'&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Radio-frequency_identification&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Here&lt;/strong&gt;&lt;/a&gt; it says the MFRC522 covers just a part of ISO/IEC 14443. The following are missing fron the NXP RC522:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;*MIFARE DESFire EV1&lt;/strong&gt; (includes AES encryption)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MIFARE DESFire EV2&lt;/strong&gt; (includes MIsmartApp, Transaction MAC, Unlimited Applications&#xA;MIFARE Plus drop-in replacement for MIFARE Classic with certified security level (AES 128 based))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;MIFARE SAM AV2&lt;/em&gt;&lt;/strong&gt; (secure access module that provides the secure storage of cryptographic keys and cryptographic functions)*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are probably the ones used in bank cards. Again, from the FIRST PAGE of the MFRC500 datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;'All protocol layers of the ISO/IEC 14443 A are supported.'&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to plow through all the different MIFARE / ISO/IEC 14443 specs to find out how many ID bytes there are for the different types (I suspect diferent types return a different quantity of bytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, basically, you're screwed. Spring for the expensive MFRC500-based reader. I assume that with the higher cost you also get a high-class API, documentation and examples or even (gasp!) tech support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="1325" LastEditorUserId="1325" LastEditDate="2014-05-06T02:00:03.850" LastActivityDate="2014-05-06T02:00:03.850" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1421" PostTypeId="1" CreationDate="2014-05-06T07:23:52.727" Score="5" ViewCount="20663" Body="&lt;p&gt;I am learning to work with the client - server communication. I am able to communicate with my server and able to store values in the table. But I want to receive one of the specific data from the database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I want to get the 'abc' value from the 'Current' column to store in a variable in my Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the code that I have done until now. I would be really happy if you could solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my database structure &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--------------------------------------------------- &#xA;| Device |  Previous |  Next |  Distance |  Current| &#xA;---------------------------------------------------&#xA;|katup123| xyz       | abc   | 2.600     | abc     |    &#xA;---------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my PHP code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;locator.php&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;$con=mysqli_connect(&quot;your_domain.com&quot;,&quot;peter&quot;,&quot;abc123&quot;,&quot;locate&quot;);&#xA;// Check connection&#xA;if (mysqli_connect_errno()) {&#xA;  echo &quot;Failed to connect to MySQL: &quot; . mysqli_connect_error();&#xA;}&#xA;$result = mysqli_query($con,&quot;SELECT Current FROM locate WHERE Device='katup123'&quot;);&#xA;&#xA;while($row = mysqli_fetch_array($result)) {&#xA;  echo $row['Current'];&#xA;  echo &quot;&amp;lt;br&amp;gt;&quot;; &#xA;}&#xA;?&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Include the GSM library&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;#define PINNUMBER &quot;&quot;&#xA;// APN data&#xA;#define GPRS_APN       &quot;GPRS_APN&quot; // replace your GPRS APNgpsll&#xA;#define GPRS_LOGIN     &quot;login&quot;    // replace with your GPRS login&#xA;#define GPRS_PASSWORD  &quot;password&quot; // replace with your GPRS password&#xA;// initialize the library instance&#xA;GSM gsmAccess;&#xA;GSMClient client;&#xA;GPRS gprs;&#xA;// URL, path &amp;amp; port (for example: arduino.cc)&#xA;char server[] = &quot;your_domain.com&quot;;&#xA;char path[] = &quot;/locater.php&quot;;&#xA;int port = 80; // port 80 is the default for HTTP&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting Arduino web client.&quot;);&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;  // Start GSM shield&#xA;  // If your SIM has PIN, pass it as a parameter of begin() in quotes&#xA;  while(notConnected) {&#xA;    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &amp;amp; (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))&#xA;      notConnected = false;&#xA;    else {&#xA;      Serial.println(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;GSM initialized&quot;);&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  char result [20];&#xA;  Serial.print(&quot; Connecting to server Database &quot;);&#xA;  if (client.connect(server, port)) {&#xA;    client.print(&quot;GET /locator.php?&quot;);&#xA;    Serial.print(&quot;GET /locator.php?&quot;);&#xA;    client.println(&quot; HTTP/1.1&quot;);&#xA;    Serial.println(&quot; HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.your_domain.com&quot;);&#xA;    Serial.println(&quot;Host: www.your_domain.com&quot;);&#xA;    client.println(&quot;User-Agent: Arduino&quot;);&#xA;    Serial.println(&quot;User-Agent: Arduino&quot;);&#xA;    client.println(&quot;Accept: text/html&quot;);&#xA;    Serial.println(&quot;Accept: text/html&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    Serial.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;    Serial.println();&#xA;    Serial.println(&quot;\nCOMPLETE!\n&quot;);&#xA;    client.stop();&#xA;  } else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    Serial.println(&quot;\n FAILED!\n&quot;);&#xA;  }&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I want to store the 'abc' value to my 'result' variable. I don't know how to do it.&lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="4628" LastEditDate="2017-08-19T05:45:23.057" LastActivityDate="2020-06-03T22:09:43.987" Title="How to receive data from my server database to a variable in my Arduino?" Tags="|arduino-uno|gsm|web-server|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1423" PostTypeId="2" ParentId="1327" CreationDate="2014-05-06T08:12:16.050" Score="1" Body="&lt;pre&gt;&lt;code&gt;/*&#xA; Band Management&#xA;&#xA; This sketch, for the Arduino GSM shield, checks the band&#xA; currently configured in the modem and allows you to change &#xA; it.&#xA;&#xA; Please check http://www.worldtimezone.com/gsm.html&#xA; Usual configurations:&#xA; Europe, Africa, Middle East: E-GSM(900)+DCS(1800)&#xA; USA, Canada, South America: GSM(850)+PCS(1900)&#xA; Mexico: PCS(1900)&#xA; Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)&#xA;&#xA;&#xA; Circuit:&#xA; * GSM shield &#xA;&#xA; created 12 June 2012&#xA; by Javier Zorzano, Scott Fitzgerald&#xA;&#xA; This example is in the public domain.&#xA; */&#xA; // libraries&#xA; #include &amp;lt;GSM.h&amp;gt;&#xA;&#xA; // initialize the library instance&#xA; GSMBand band;&#xA;&#xA; void setup()&#xA; {&#xA;   // initialize serial communications and wait for port to open:&#xA;   Serial.begin(9600);&#xA;   while (!Serial) {&#xA;     ; // wait for serial port to connect. Needed for Leonardo only&#xA;   }&#xA;&#xA;   // Beginning the band manager restarts the modem&#xA;   Serial.println(&quot;Restarting modem...&quot;);&#xA;   band.begin();&#xA;   Serial.println(&quot;Modem restarted.&quot;);&#xA;&#xA; };&#xA;&#xA;&#xA; void loop()&#xA; {&#xA;   // Get current band &#xA;   String bandName = band.getBand(); // Get and print band name&#xA;   Serial.print(&quot;Current band:&quot;);&#xA;   Serial.println(bandName);&#xA;   Serial.println(&quot;Want to change the band you’re on?&quot;);&#xA;   String newBandName;&#xA;   newBandName = askUser();&#xA;   // Tell the user what we are about to do…&#xA;   Serial.print(&quot;\nConfiguring band &quot;); &#xA;   Serial.println(newBandName); &#xA;   // Change the band &#xA;   boolean operationSuccess; &#xA;   operationSuccess = band.setBand(newBandName); &#xA;   // Tell the user if the operation was OK &#xA;   if(operationSuccess)&#xA;   { &#xA;     Serial.println(&quot;Success&quot;);&#xA;   } &#xA;   else&#xA;   { &#xA;     Serial.println(&quot;Error while changing band&quot;);&#xA;   } &#xA;&#xA;   if(operationSuccess)&#xA;   { &#xA;     while(true); &#xA;   } &#xA; }&#xA;&#xA; // This function offers the user different options&#xA; // through the Serial interface&#xA; // The user selects one&#xA; String askUser()&#xA; {&#xA;   String newBand; &#xA;   Serial.println(&quot;Select band:&quot;); &#xA;   // Print the different options &#xA;   Serial.println(&quot;1 : E-GSM(900)&quot;); &#xA;   Serial.println(&quot;2 : DCS(1800)&quot;); &#xA;   Serial.println(&quot;3 : PCS(1900)&quot;); &#xA;   Serial.println(&quot;4 : E-GSM(900)+DCS(1800) ex: Europe&quot;); &#xA;   Serial.println(&quot;5 : GSM(850)+PCS(1900) Ex: USA, South Am.&quot;); &#xA;   Serial.println(&quot;6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)&quot;); &#xA;&#xA;   // Empty the incoming buffer &#xA;   while(Serial.available()) &#xA;   Serial.read(); &#xA;&#xA;   // Wait for an answer, just look at the first character &#xA;   while(!Serial.available()); &#xA;   char c= Serial.read(); &#xA;   if(c=='1')&#xA;     newBand=GSM_MODE_EGSM; &#xA;   else if(c=='2')&#xA;     newBand=GSM_MODE_DCS; &#xA;   else if(c=='3')&#xA;     newBand=GSM_MODE_PCS; &#xA;   else if(c=='4')&#xA;     newBand=GSM_MODE_EGSM_DCS; &#xA;   else if(c=='5')&#xA;     newBand=GSM_MODE_GSM850_PCS; &#xA;   else if(c=='6')&#xA;     newBand=GSM_MODE_GSM850_EGSM_DCS_PCS; &#xA;   else&#xA;     newBand=&quot;GSM_MODE_UNDEFINED&quot;;&#xA;   return newBand;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="831" LastEditDate="2014-06-05T13:48:37.093" LastActivityDate="2014-06-05T13:48:37.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1424" PostTypeId="2" ParentId="1194" CreationDate="2014-05-06T08:29:53.240" Score="3" Body="&lt;p&gt;I would recommend the official &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;Arduino GSM shield&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="42" LastEditDate="2014-05-06T15:16:26.283" LastActivityDate="2014-05-06T15:16:26.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1425" PostTypeId="1" CreationDate="2014-05-06T13:13:42.960" Score="5" ViewCount="1645" Body="&lt;p&gt;Inspired by an example question before beta, can I make the Leonardo bootloader take less that 8 seconds to run? It is very slow and I want to speed it up somehow.&lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="46" LastEditDate="2014-05-06T13:33:33.817" LastActivityDate="2014-07-15T07:17:50.440" Title="Can I speed up the Leonardo bootloader?" Tags="|bootloader|arduino-leonardo|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1426" PostTypeId="2" ParentId="1355" CreationDate="2014-05-06T13:23:33.373" Score="1" Body="&lt;p&gt;Perhaps you could count the number of lines in the console and the print out enough carriage returns (&lt;code&gt;&quot;\n&quot;&lt;/code&gt;) to fill it with empty whitespace.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with a console with 100 lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int iter = 0; iter &amp;lt; 100; iter++) {&#xA;   client.write('\n');&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-06T13:23:33.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1427" PostTypeId="2" ParentId="1325" CreationDate="2014-05-06T13:32:08.350" Score="2" Body="&lt;p&gt;If the second isn't working, it may be best to use the other 2. Especially on the Arduino with limited RAM, you will not have enough if you pass a full struct to a function. Passing a pointer is less memory-intensive, and if it works, use it!&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-06T13:32:08.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1428" PostTypeId="1" CreationDate="2014-05-06T15:19:36.647" Score="1" ViewCount="3250" Body="&lt;p&gt;I'm building a control system for the heating of a house. A sensor reads the temperature inside and is then used as the input in the PID control. The temperature is then controlled by a servo which opens and closes a shunt were water runs to the radiators. I understand all the inner workings of the PID library for Arduino and PID in general, but &lt;strong&gt;the thing I don't understand is what I'm exactly supposed to do with the output signal I receive. In what way should the output signal correspond to how open or closed the shunt is?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand I can simply map the output signal to the servo signal, but is this the correct way? And with what angle coefficient should I map it with, cause that is basically set with the P parameter, isn't it? Is there some standard way to map the output signal to the actuator &quot;signal&quot;, so that that tuning parameters are somewhat &quot;standard&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone understands anything of what I tried to explain :)&lt;/p&gt;&#xA;" OwnerUserId="1332" LastEditorUserId="6452" LastEditDate="2015-04-10T15:26:21.790" LastActivityDate="2015-04-10T15:26:21.790" Title="How to map PID output to actuator control?" Tags="|servo|pid|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1430" PostTypeId="1" AcceptedAnswerId="1434" CreationDate="2014-05-06T16:52:23.560" Score="5" ViewCount="379" Body="&lt;p&gt;As soon as I plugged my brand new RedBoard (Sparkfun's Uno) into my computer, I saw the onboard LED (for pin 13) blink on and off every 1 second. This was before I even sent the first demo sketch to blink the LED. After I uploaded a sketch to change the blink time, the LED's blink cycle changed as I expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why was the LED blinking &lt;em&gt;before&lt;/em&gt; I sent my very first sketch? Is the RedBoard pre-loaded with a sketch? &lt;/p&gt;&#xA;" OwnerUserId="1333" LastActivityDate="2014-05-07T02:51:29.610" Title="Is the Sparkfun RedBoard pre-loaded with a blink sketch?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1432" PostTypeId="2" ParentId="1404" CreationDate="2014-05-06T20:58:13.990" Score="1" Body="&lt;p&gt;Here’s a decoding of the crucial pair of messages exchanged here. Protocol is documented &lt;a href=&quot;http://www.atmel.com/Images/doc2591.pdf&quot; rel=&quot;nofollow&quot;&gt;on Atmel’s site&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your machine sends:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[1b]                              Beginning of message&#xA;[06]                              Message sequence number&#xA;[00] [0c]                         Message body length (big endian)&#xA;[0e]                              Beginning of message body&#xA;[10]                              Command: CMD_ENTER_PROGMODE_ISP &#xA;[c8] [64] [19] [20] [00]          Various programming parameters&#xA;[53]                              Response value to look for&#xA;[03]                              Response index &#xA;[ac] [53] [00] [00]               Enter programming mode command&#xA;[35]                              Checksum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This causes the programmer to send the 4 bytes &lt;code&gt;0xAC 0x53 0x00 0x00&lt;/code&gt; to the MCU, and look for the value &lt;code&gt;0x53&lt;/code&gt; in the third of the 4 response bytes, as specified on page 260 of the &lt;a href=&quot;http://www.atmel.ch/Images/doc7799.pdf&quot; rel=&quot;nofollow&quot;&gt;data sheet&lt;/a&gt;. However, the programmer answers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[1b]                              Beginning of message&#xA;[06]                              Sequence number (matches message previously sent)&#xA;[00] [02]                         Response body length&#xA;[0e]                              Beginning of response body&#xA;[10]                              Command: CMD_ENTER_PROGMODE_ISP (Matches message)&#xA;[c0]                              STATUS_CMD_FAILED (This is the error message)&#xA;[c1]                              Checksum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means that tyne very first command sent to the microcontroller “failed” (most likely by not returning the expected answer byte).&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-05-06T20:58:13.990" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1433" PostTypeId="1" AcceptedAnswerId="1447" CreationDate="2014-05-06T23:29:23.740" Score="7" ViewCount="3160" Body="&lt;p&gt;After searching &lt;em&gt;for a quite long while&lt;/em&gt; over the internet, I have no choice but to try asking someone if they can explain me this apparently strange situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm doing some tests using some servo motors, trying to move them almost together using &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;Servo&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is, of course, working either for single Servos and multiple servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The case, more detailed, is about this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move one, two or more servo motors together.&lt;/li&gt;&#xA;&lt;li&gt;Force them to take ALMOST the same time to accomplish any action.&lt;/li&gt;&#xA;&lt;li&gt;Have a dynamic number of servos.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;About the first two points I had no problems to solve them, I was easily able to make a function and then make a library to accomplish such a job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since I'm NOT that used to C++ and I was wondering if it actually was possible to create an array of Servo objects, like you can actually do, on arduino, with strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String stringArray[] = {&quot;string1&quot;, &quot;string2&quot;, &quot;and so on, I love it.&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, after wondering a while, I've tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo servObject;&#xA;Servo servObject_2;&#xA;Servo servObject_3;&#xA;&#xA;Servo servos[] = {servObject, servObject_2, servObject_3};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you know what's cool? my function is actually working correctly by forcing the amount of elements of the servos array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I mean by that is that if I force my function to know that it is going to have 3 elements into the array it will, of course, work; However, for some reason, if I use &lt;code&gt;sizeof(servos);&lt;/code&gt; the value returned, surprisingly, is &lt;code&gt;2&lt;/code&gt;....&#xA;Moreover, if I only push two servo objects instead of three into the servo array, its &lt;code&gt;sizeof&lt;/code&gt; returns &lt;code&gt;6&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By googling, I've found out a couple of discussions about the fact that, for some reasons, in some cases, sizeof returns an incorrect value (if I'm not wrong it was the correct value -1), but in my case it apparently is not following any logic at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board I'm using is an Arduino nano w/ ATMEGA 328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea of why it is not returning the correct value? Am I actually going totally wrong because I shouldn't make an array of servo objects?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ps: I didn't post the whole code because it would've been useless, since the sizeof is the first function called in the &lt;code&gt;loop()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;briosheje&lt;/p&gt;&#xA;" OwnerUserId="1347" OwnerDisplayName="briosheje" LastActivityDate="2014-05-07T21:10:39.910" Title="Arduino sizeof Servo array objects is.. wrong?" Tags="|c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1434" PostTypeId="2" ParentId="1430" CreationDate="2014-05-07T02:51:29.610" Score="2" Body="&lt;p&gt;Yes, the RedBoard is preloaded with the blink sketch (or at least the two that I've purchased have been).&lt;/p&gt;&#xA;" OwnerUserId="150" LastActivityDate="2014-05-07T02:51:29.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1435" PostTypeId="2" ParentId="1428" CreationDate="2014-05-07T03:05:21.963" Score="2" Body="&lt;p&gt;I don't think you would need to use a PID library (or any control loop for that matter) to control a radiator. You could use a simple threshold code, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pseudocode:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Check temperature&#xA;If radiator is off and temperature &amp;gt; (ideal temp - threshold)&#xA;  turn radiator on&#xA;If radiator is on and temperature &amp;gt; (ideal temp + threshold)&#xA;  turn radiator off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-07T03:05:21.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1437" PostTypeId="2" ParentId="1371" CreationDate="2014-05-07T05:40:20.523" Score="0" Body="&lt;p&gt;One important problem in your code is concurrent access to &lt;code&gt;dimming&lt;/code&gt; variable. That may not be the only problem you have though.&lt;/p&gt;&#xA;&lt;p&gt;Indeed, &lt;code&gt;deeming&lt;/code&gt; is accessed for writing in your &lt;code&gt;loop()&lt;/code&gt;, but it can be simultaneously read by &lt;code&gt;zero_crosss_int()&lt;/code&gt; function which is executed in interruption mode because it was registered as such with &lt;code&gt;attachInterrupt()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Since &lt;code&gt;deeeming&lt;/code&gt; is an &lt;code&gt;int&lt;/code&gt; (2 bytes on AVR MCU), it cannot be read or written in just one clock-cycle (AVR is an 8-bit technology). Hence it is perfectly possible that &lt;code&gt;loop()&lt;/code&gt; gets interrupted by &lt;code&gt;zero_crosss_int()&lt;/code&gt; just in the middle of writing &lt;code&gt;dimming&lt;/code&gt;, eg in:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;dimming = 120;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that, in theory, concurrent acces in your case should not be an issue as long as &lt;code&gt;dimming&lt;/code&gt; is never greater than 255.&lt;/p&gt;&#xA;&lt;h2&gt;How do you protect access to &lt;code&gt;dimming&lt;/code&gt; variable?&lt;/h2&gt;&#xA;&lt;p&gt;You can do the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int dimming() {&#xA;    cli();&#xA;    int temp = dimming;&#xA;    sei();&#xA;}&#xA;&#xA;void dimming(int value) {&#xA;    cli();&#xA;    dimming = value;&#xA;    sei();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And replace any direct access to the &lt;code&gt;dimming&lt;/code&gt; variable in your code with a call to one of these functions above.&lt;/p&gt;&#xA;&lt;h2&gt;Will that fix your problem?&lt;/h2&gt;&#xA;&lt;p&gt;Maybe not unfortunately, as it is probable that mixing IRremote.h with your code brings other conflicts.&lt;/p&gt;&#xA;&lt;p&gt;But at least, this will solve a dormant bug in your code, a complex bug that may catch you some day.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-05-07T05:40:20.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1438" PostTypeId="1" CreationDate="2014-05-07T08:48:55.597" Score="3" ViewCount="2872" Body="&lt;p&gt;I am working on reading a text file from the server, using &lt;a href=&quot;http://arduino.cc/en/Reference/GSMClientConnected&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/GSMClientConnected&lt;/a&gt;. It gives me this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char path[]=&quot;/asciilogo.txt&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to store only the contents that are inside the text file to a variable (String). But &lt;code&gt;client.read();&lt;/code&gt; only reads a single character at a time. Also, it takes all the HTTP, GET, TIME parameters together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to store only the contents that are present in the text file to a string variable?&lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="1333" LastEditDate="2014-05-07T18:28:16.417" LastActivityDate="2016-01-28T12:04:43.377" Title="How to read a Text file from server and store to a separate variable?" Tags="|arduino-uno|gsm|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1439" PostTypeId="1" AcceptedAnswerId="1441" CreationDate="2014-05-07T09:14:34.433" Score="12" ViewCount="2404" Body="&lt;p&gt;I know that it is possible to connect a stepper motor directly to an arduino (&lt;a href=&quot;http://arduino.cc/en/Tutorial/StepperUnipolar&quot;&gt;as displayed here&lt;/a&gt;). I know that another option is to use a motor shield (for example the &lt;a href=&quot;http://arduino.cc/de/Main/ArduinoMotorShieldR3&quot;&gt;Arduino Motor Shield&lt;/a&gt; or the &lt;a href=&quot;http://www.adafruit.com/product/1438&quot;&gt;Adafruit Motor Shield&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to know: What are the actual advantages of using a motor shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it just a question of convenience? Or does a motor shield do something that could not easily performed without a shield? Does it allow me to connect more motors than I could connect directly without a shield (power supply comes to mind)?&lt;/p&gt;&#xA;" OwnerUserId="1319" LastActivityDate="2016-08-28T19:29:47.723" Title="What is the advantage of using a motor shield if I want to use a stepper motor?" Tags="|shields|motor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1440" PostTypeId="1" CreationDate="2014-05-07T09:16:27.927" Score="1" ViewCount="1628" Body="&lt;p&gt;I have an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;Arduino GSM shield&lt;/a&gt; and I plan to purchase an &lt;a href=&quot;http://www.adafruit.com/products/1272&quot; rel=&quot;nofollow&quot;&gt;Adafruit GPS shield&lt;/a&gt;. The GPS module uses Pin 7 &amp;amp; 8 for Rx and Tx, but the GSM shield uses Pin 7 for Modem Reset. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will the overlap on pin 7 affect it in any way? If it does cause issues, how can the problem be avoided?&lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="6936" LastEditDate="2015-02-12T05:57:19.827" LastActivityDate="2016-03-21T10:34:32.673" Title="GSM and GPS shield pin conflict" Tags="|arduino-uno|pins|shields|gsm|gps|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1441" PostTypeId="2" ParentId="1439" CreationDate="2014-05-07T12:22:15.700" Score="9" Body="&lt;p&gt;The example you linked to isn't actually connecting the Arduino &lt;em&gt;directly&lt;/em&gt; to a stepper motor. It's going via a ULN2003A driver. That's a very common Darlington transistor array, which basically just lets you use a small current to switch a larger load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's necessary because the Arduino pins can't safely source enough current to drive the stepper motor directly. It might work for a while, but it would damage your Arduino sooner or later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motor shields usually have a similar driver in them, but can also provide additional functionality which you might find useful. For example, the Adafruit shield you linked to is controlled by the I2C bus, and has its own on-board PWM. That means you can control several motors without needing any extra output pins on your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, motor shields aren't necessary. They can be helpful though, especially if you aren't familiar with the underlying electronics, or you don't want to build it yourself.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-07T12:22:15.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1442" PostTypeId="2" ParentId="1405" CreationDate="2014-05-07T14:06:42.560" Score="5" Body="&lt;p&gt;This is part of a Fritzing circuit I used to control the x'mas tree lights (the relays and sensors have been snipped out) with an XBee. This circuit uses a 3.3v LDO you may have to change the capacitor values depending on your regulator specs. I chose to use a separate 5V regulator (not shown) but it will work off the Pro Mini's +5V power rail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two FETs that do the actual level shifting, the bonus transistor allows you to reset the Arduino and thus gives you the ability to program it over the air via the XBee (beyond the scope of the question, but if you want to go wireless, go wireless all the way - do the Google for wireless programming over XBee if needed). Note the 0.1uF across the XBee power pins, I recommend this capacitor be placed as close to the XBee as possible to minimize noise (I solder it across the back of the XBee interface board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PzjWI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="58" LastActivityDate="2014-05-07T14:06:42.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1443" PostTypeId="1" CreationDate="2014-05-07T15:30:08.873" Score="3" ViewCount="1109" Body="&lt;p&gt;Hi we are using Arduino Leonardo with some electric paint and &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow&quot;&gt;Capacitive Sensor Libraries&lt;/a&gt;. We have a lot of variance in our Serial output from our sensors, we believe if we grounded the Arduino we would have more concrete values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Capacitive Sensor doc, it reveals to use a small capacitor to put on one of the pins. More details!&#xA;Another guide somewhere says to wrap the Arduino in plastic and tin foil. These are vague, and we have not landed success when we tried. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone had success grounding Arduino Leo? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="1354" LastEditorUserId="220" LastEditDate="2014-05-31T23:03:48.457" LastActivityDate="2014-05-31T23:03:48.457" Title="How Do I Properly Ground my Arduino Leonardo using Capacitive Sensor?" Tags="|arduino-leonardo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1444" PostTypeId="2" ParentId="1438" CreationDate="2014-05-07T15:38:37.353" Score="2" Body="&lt;p&gt;Here is what I found:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to have a special character like  &quot;*&quot; (a delimiter), from which important data will flow through.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char z = '*';&#xA;int s=0;&#xA;&#xA;void setup()&#xA;{ &#xA;  // usual initialization  &#xA;} &#xA;&#xA;void loop()&#xA;{&#xA;  if (client.available())  &#xA;  {&#xA;    char c = client.read();&#xA;    // Serial.print(c);&#xA;    if (z == c)&#xA;    {&#xA;      s=1;&#xA;    }&#xA;&#xA;  if(s == 1)&#xA;  {&#xA;    int i=0;&#xA;    k[i] = c;&#xA;    i=i+1;&#xA;    // Serial.print(k);&#xA;  }&#xA;&#xA;  place +=k;&#xA;&#xA;  Serial.print(place);&#xA;&#xA;  }&#xA;&#xA;.......&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="1333" LastEditDate="2014-05-07T17:45:07.737" LastActivityDate="2014-05-07T17:45:07.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1445" PostTypeId="1" AcceptedAnswerId="1468" CreationDate="2014-05-07T15:49:54.260" Score="-2" ViewCount="493" Body="&lt;p&gt;When I run my &lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Receive SMS&lt;/a&gt; example code, By default every time I get the same thing.I am trying to send sms to my sim card present in the Arduino GSM shield. I don't want this message. How to solve this problem ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gGZKX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="83" LastEditDate="2014-05-08T06:11:49.180" LastActivityDate="2014-05-08T19:44:03.780" Title="Receive SMS example gives me a garbage values" Tags="|arduino-uno|shields|gsm|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="1446" PostTypeId="2" ParentId="1439" CreationDate="2014-05-07T17:51:31.897" Score="5" Body="&lt;p&gt;Mechanical stability of the whole thing is probably the main advantage. I'd personally opt for a generic module or loose components. The main disadvantage of shields is pin conflicts when using more than one shield.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-05-07T17:51:31.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1447" PostTypeId="2" ParentId="1433" CreationDate="2014-05-07T18:58:02.687" Score="7" Body="&lt;p&gt;What you describe seems to be a common issue that many C or C++ developers can get (or have got) with &lt;code&gt;sizeof&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Take a look at the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;char a[3];&#xA;&#xA;int size(char b[]) {&#xA;    return sizeof b;&#xA;}&#xA;&#xA;void setup() {&#xA;    int size1 = sizeof a;&#xA;    int size2 = size(a);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In that code, &lt;code&gt;size1&lt;/code&gt; will be evaluated, by the compiler, to &lt;code&gt;3&lt;/code&gt; which is the real size of &lt;code&gt;a&lt;/code&gt; variable, whereas &lt;code&gt;size2&lt;/code&gt; will be &lt;code&gt;2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2&gt;Why so?&lt;/h2&gt;&#xA;&lt;p&gt;This is just because &lt;code&gt;sizeof a&lt;/code&gt; is evaluated by the compiler, and the compiler &lt;em&gt;knows&lt;/em&gt; that &lt;code&gt;a&lt;/code&gt; is an array of 3 &lt;code&gt;char&lt;/code&gt;; but when &lt;code&gt;a&lt;/code&gt; is passed as an argument to function &lt;code&gt;size()&lt;/code&gt;, it is converted to a pointer (to the first element of the array), hence its size is the &lt;strong&gt;size of a pointer&lt;/strong&gt;, which is &lt;code&gt;2&lt;/code&gt; bytes on AVR ATmega MCU.&lt;/p&gt;&#xA;&lt;p&gt;This subtlety of &lt;code&gt;sizeof&lt;/code&gt; may explain strange values as you describe.&lt;/p&gt;&#xA;&lt;h2&gt;How to fix the issue?&lt;/h2&gt;&#xA;&lt;p&gt;Most C functions that take an array as argument will require another argument that tells the size of the array; that's the way (the only one I think) to deal with this problem.&lt;/p&gt;&#xA;&lt;p&gt;Here is a sample code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Servo allServos[] = {...};&#xA;#define NUM_SERVOS (sizeof(allServos) / sizeof(Servo))&#xA;...&#xA;void handleServos(Servo *servos, int numServos) {&#xA;    for (int i = 0; i &amp;lt; numServos; i++) {&#xA;        servos[i].write(...);&#xA;        ...&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;    handleServos(allServos, NUM_SERVOS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is common practice in C to &lt;strong&gt;declare an array&lt;/strong&gt; and immediately after, &lt;strong&gt;define its size&lt;/strong&gt; as above.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-05-07T21:10:39.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1448" PostTypeId="1" AcceptedAnswerId="1449" CreationDate="2014-05-07T19:59:25.817" Score="14" ViewCount="38391" Body="&lt;p&gt;(I have a Sparkfun RedBoard, but this question seems to apply to R3 Unos and Uno-compatible boards.) As I was building the first circuit in my SIK guidebook (add a resistor, LED, hook it up and make it blink from code), I noticed a blue LED on the board itself did everything that the circuit's LED did - blinking according to the programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this LED here? What use cases is it for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of circuits will I have to adjust to account for this LED?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is pin 13 traditionally a debug or a troubleshooting pin? Where did this convention come from?&lt;/p&gt;&#xA;" OwnerUserId="1333" LastActivityDate="2014-05-10T05:27:23.243" Title="What's the deal with Uno's pin 13 LED?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1449" PostTypeId="2" ParentId="1448" CreationDate="2014-05-07T20:51:24.820" Score="11" Body="&lt;p&gt;The LED on pin 13 is used by the &lt;strong&gt;optiboot&lt;/strong&gt; loader (the one used on &lt;strong&gt;UNO&lt;/strong&gt;):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;at Arduino &lt;strong&gt;boot time&lt;/strong&gt; (the LED blinks a few times)&lt;/li&gt;&#xA;&lt;li&gt;when &lt;strong&gt;uploading a sketch&lt;/strong&gt; to Arduino&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I haven't checked other bootloaders, they may provide the same behavior as the optiboot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For optiboot, there are optional defines (at compile time) to modify this behavior:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;LED_START_FLASHES&lt;/code&gt; defines the number of flashes of pin 13 LED at boot time (can be set to &lt;code&gt;0&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LED_DATA_FLASH&lt;/code&gt; will use pin 13 LED during sketch upload if &lt;strong&gt;defined&lt;/strong&gt; at compile-time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These defines are explained in &lt;code&gt;hardware/arduino/bootloaders/optiboot/optiboot.c&lt;/code&gt; from within your Arduino IDE install directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change these, you will have to recompile the optiboot loader first and then burn it to your Arduino through an &lt;strong&gt;ISP programmer&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess one other reason for the LED on pin 13 was to simplify the demonstration of the &quot;&lt;em&gt;Hello World&lt;/em&gt;&quot; sketch for Arduino, namely the &lt;code&gt;Blink&lt;/code&gt; sketch, without the need for any extra component.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-07T20:51:24.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1450" PostTypeId="2" ParentId="1443" CreationDate="2014-05-08T00:56:27.163" Score="0" Body="&lt;p&gt;The simplest way to ground an Arduino is to attach the ground pin, found on the power header, to a grounded surface, like a metal pipe. As for the capacitor you mentioned, that is called a smoothing capacitor. It is a small capacitor, about 1microfarad, and goes between the supply of the sensor and the ground line.&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-08T00:56:27.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1452" PostTypeId="2" ParentId="1448" CreationDate="2014-05-08T08:01:24.813" Score="1" Body="&lt;p&gt;Yes, pin 13 is traditionally an output pin that drives an LED. But the blue LED should not be blinking as it is the &quot;power on&quot; indicator - do you have a grunty power supply to your board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can experiment with PWM to the pin13 LED, which will control its apparent brightness. There are plenty of example sketches on the web.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-05-08T08:01:24.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1453" PostTypeId="2" ParentId="1443" CreationDate="2014-05-08T08:38:33.180" Score="-1" Body="&lt;p&gt;It might help if you follow the diagram for connecting a button, that way the value of the capacitor sensor wont fluctuate...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Photo from &lt;a href=&quot;http://arduino.cc/en/tutorial/button&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/tutorial/button&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jxviv.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1357" LastEditorUserId="220" LastEditDate="2014-05-08T20:54:25.170" LastActivityDate="2014-05-08T20:54:25.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1454" PostTypeId="1" AcceptedAnswerId="1457" CreationDate="2014-05-08T10:17:51.620" Score="1" ViewCount="10166" Body="&lt;p&gt;Could I connect a device that requires minimum 5V 1A from the 5V Pin to the Ground and somehow turn it off inside  a sketch? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I'm using a Due based boad, the digix &lt;a href=&quot;http://digistump.com/wiki/digix/tutorials/basics&quot; rel=&quot;nofollow&quot;&gt;http://digistump.com/wiki/digix/tutorials/basics&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="157" LastEditorUserId="157" LastEditDate="2014-05-08T13:18:35.860" LastActivityDate="2014-05-08T21:06:30.000" Title="Can I turn off a device using the 5V and analog pins?" Tags="|programming|pins|power|voltage-level|analogwrite|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1455" PostTypeId="2" ParentId="1454" CreationDate="2014-05-08T10:26:04.467" Score="4" Body="&lt;p&gt;&lt;em&gt;Short answer: NO&lt;/em&gt;. It would fry your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Long answer:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current of Arduino pins is very limited (40mA max on UNO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to draw 1A, then you need a &lt;em&gt;transistor&lt;/em&gt; between the Arduino pin and your device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In such case, what you would normally do is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connect any Arduino logical pin to the transistor base (through a resistor), &lt;/li&gt;&#xA;&lt;li&gt;plug your device between a 5V supply (capable of 1A current providing) and the transistor collector, &lt;/li&gt;&#xA;&lt;li&gt;connect the transistor emitter to the Arduino GND pin (and connect that pin also to the 5V-1A supply)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;strong&gt;you don't need to use an analog pin&lt;/strong&gt; for that, a logical pin is enough if you just want to switch the device on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now notice that I specified &lt;strong&gt;a 5V 1A supply&lt;/strong&gt;, that should normally be &lt;strong&gt;distinct&lt;/strong&gt; from the 5V pin of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the next question is: &lt;strong&gt;can you draw 1A out of the Arduino 5V pin?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO page&lt;/a&gt; does not specify the current limitation on that pin. However it mentions the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So the max current on this pin depends on 2 factors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;what is the power supply for the board: it is either USB, or an external power supply, which can be connected to the power plug or to the Vin pin.&lt;/li&gt;&#xA;&lt;li&gt;the specs of the 5V regulator voltage on the Arduino board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you use USB as power supply, then you are limited to &lt;strong&gt;500mA&lt;/strong&gt; as stated in the Arduino UNO page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you use an external power supply that provides at least 1A, then we have to find out the max current by ourselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we take a look at &lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO schematics&lt;/a&gt;, then we see that this regulator is referenced as &quot;&lt;strong&gt;NCP1117ST50T3G&lt;/strong&gt;&quot; (this is &quot;&lt;strong&gt;U1&lt;/strong&gt;&quot; on the top-right corner).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/NCP1117-D.PDF&quot; rel=&quot;nofollow&quot;&gt;spec sheet for this regulator&lt;/a&gt; mentions that it can supply &lt;strong&gt;1.0A&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in theory, that should work, however, you also have to consider that this regulator &lt;strong&gt;also&lt;/strong&gt; supplies current to the Arduino borard itself and all its pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you love your Arduino and don't want to fry it, you should probably stay away from using its 5V pin for your purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you're open to experiment, you may try it :-)&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-05-08T17:11:34.127" LastActivityDate="2014-05-08T17:11:34.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1457" PostTypeId="2" ParentId="1454" CreationDate="2014-05-08T12:27:21.197" Score="7" Body="&lt;p&gt;You would use a transistor. Something like this would work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the Arduino controls a transistor to drive a brushless motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: Arduino Cookbook: (&lt;a href=&quot;https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-8/figure-8-9&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-8/figure-8-9&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;For the sake of clarity I should point out that the TIP102 is the device to use for the 1A required (not the 2N2222). And as pointed out by others the 5V supply of most Arduino boards would not be sufficient to supply 1A, so an external supply would be advised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JqfF7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2014-05-08T15:33:45.687" LastActivityDate="2014-05-08T15:33:45.687" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1459" PostTypeId="2" ParentId="1448" CreationDate="2014-05-08T16:56:31.927" Score="10" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What kind of circuits will I have to adjust to account for this LED?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You'll need to take it into account if you're using that pin as a digital input.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: Digital pin 13 is harder to use as a digital input than the&#xA;  other digital pins because it has an LED and resistor attached to it&#xA;  that's soldered to the board on most boards. If you enable its&#xA;  internal 20k pull-up resistor, it will hang at around 1.7V instead of&#xA;  the expected 5V because the onboard LED and series resistor pull the&#xA;  voltage level down, meaning it always returns LOW. If you must use pin&#xA;  13 as a digital input, set its pinMode() to INPUT and use an external&#xA;  pull down resistor. &lt;sub&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/DigitalPins&quot;&gt;Arduino - DigitalPins&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-05-08T16:56:31.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1460" PostTypeId="2" ParentId="1454" CreationDate="2014-05-08T17:32:38.883" Score="2" Body="&lt;p&gt;The simpler solution is to power Arduino from some external supply, then fork that power through a relay to controlled device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can switch the device by controlling that relay through your digital pin.&lt;/p&gt;&#xA;" OwnerUserId="1361" LastActivityDate="2014-05-08T17:32:38.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1461" PostTypeId="1" CreationDate="2014-05-08T18:06:38.353" Score="0" ViewCount="1309" Body="&lt;p&gt;I am working on SMS communication with my phone and Arduino. My intension is simple. When somebody send an SMS, the Arduino should read a text file located on my server and forward the content to the same number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is, when I send an SMS to my Arduino, which is waiting for my message, it does not read my message. But when I separately run this &lt;a href=&quot;http://arduino.cc/en/Reference/GSMSMSRead&quot; rel=&quot;nofollow&quot;&gt;example code&lt;/a&gt;, I see my SMS is received. It means my SMS is already present in the modem memory. But why does this happen? How to solve this? Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// libraries&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;// PIN Number&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// APN data&#xA;#define GPRS_APN       &quot;GPRS_APN&quot; // replace your GPRS APN&#xA;#define GPRS_LOGIN     &quot;login&quot;    // replace with your GPRS login&#xA;#define GPRS_PASSWORD  &quot;password&quot; // replace with your GPRS password&#xA;&#xA;// initialize the library instance&#xA;GSMClient client;&#xA;GPRS gprs;&#xA;GSM gsmAccess; &#xA;GSM_SMS sms;&#xA;&#xA;// URL, path &amp;amp; port (for example: arduino.cc)&#xA;char server[] = &quot;yourdomain.com&quot;;&#xA;char path[] = &quot;/current.txt&quot;;&#xA;int port = 80; // port 80 is the default for HTTP&#xA;&#xA;char k[30]; &#xA;char z = '*';&#xA;int s=0;&#xA;String place;&#xA;char remoteNum[20];  // telephone number to send sms&#xA;&#xA;void setup() {&#xA;    // initialize serial communications and wait for port to open:&#xA;    Serial.begin(9600);&#xA;    while (!Serial) {&#xA;        ; // wait for serial port to connect. Needed for Leonardo only&#xA;    }&#xA;    Serial.println(&quot;SMS connected&quot;);&#xA;    // connection state&#xA;    boolean notConnected = true;&#xA;    while(notConnected) {&#xA;        if((gsmAccess.begin(PINNUMBER)==GSM_READY) &amp;amp;&#xA;           (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))&#xA;            notConnected = false;&#xA;        else {&#xA;            Serial.println(&quot;Not connected&quot;);&#xA;            delay(1000);&#xA;        }&#xA;    }&#xA;    Serial.println(&quot;GPRS connected...&quot;);&#xA;    Serial.println(&quot;Server Connecting.&quot;);&#xA;    // if you get a connection, report back via serial:&#xA;    serverr();&#xA;}&#xA;&#xA;void loop() {&#xA;    if (sms.available()) {&#xA;        Serial.println(&quot;Message received from:&quot;);&#xA;        sms.remoteNumber(remoteNum, 20);&#xA;        Serial.println(remoteNum);&#xA;        sms.flush();&#xA;        Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;    }&#xA;}&#xA;&#xA;void smss() {&#xA;  // I just want phone number&#xA;    if (client.available()) {&#xA;        char c = client.read();&#xA;        //***************************************************&#xA;        //       Filtering a specific message&#xA;        //**************************************************&#xA;        if (z==c) {&#xA;            s=1;&#xA;        }&#xA;        if(s == 1) {&#xA;            int i=0;&#xA;            k[i] = c;&#xA;            i=i+1;&#xA;            // Serial.print(k);&#xA;        }&#xA;        place +=k;&#xA;        //Serial.print(place);&#xA;    }&#xA;    //***************************************************  &#xA;&#xA;    if (!client.available() &amp;amp;&amp;amp; !client.connected()) {&#xA;        sms.beginSMS(remoteNum);&#xA;        Serial.print(&quot;Place =&quot;);&#xA;        Serial.print(place);&#xA;        sms.print(place);&#xA;        sms.endSMS(); &#xA;        sms.flush();&#xA;        Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;        Serial.println();&#xA;        Serial.println(&quot;disconnecting.&quot;);&#xA;        client.stop();&#xA;        // do nothing forevermore:&#xA;        for(;;)&#xA;            ;&#xA;    }&#xA;}&#xA;&#xA;// if you didn't get a connection to the server:&#xA;// Serial.print(server);&#xA;&#xA;void serverr() {&#xA;    if (client.connect(server, port)) {&#xA;        client.print(&quot;GET /current.txt&quot;);&#xA;        Serial.print(&quot;GET /current.txt&quot;);&#xA;        client.println(&quot; HTTP/1.1&quot;);&#xA;        Serial.println(&quot; HTTP/1.1&quot;);&#xA;        client.println(&quot;Host: www.yourdomain.com&quot;);&#xA;        Serial.println(&quot;Host: www.yourdomain.com&quot;);&#xA;        client.println(&quot;User-Agent: Arduino&quot;);&#xA;        Serial.println(&quot;User-Agent: Arduino&quot;);&#xA;        client.println(&quot;Accept: text/html&quot;);&#xA;        Serial.println(&quot;Accept: text/html&quot;);&#xA;        client.println(&quot;Connection: close&quot;);&#xA;        Serial.println(&quot;Connection: close&quot;);&#xA;        client.println();&#xA;        Serial.println();&#xA;&#xA;        Serial.println(&quot;\nCOMPLETE!\n&quot;);&#xA;        //client.stop();&#xA;    } else {&#xA;        Serial.println(&quot;connection failed&quot;);&#xA;        Serial.println(&quot;\n FAILED!\n&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="4628" LastEditDate="2014-11-07T16:43:09.110" LastActivityDate="2016-02-01T02:07:22.693" Title="SMS in modem's memory" Tags="|arduino-uno|gsm|web-server|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1462" PostTypeId="2" ParentId="1443" CreationDate="2014-05-08T18:13:51.333" Score="3" Body="&lt;p&gt;The documentation for that library is recommending that you place a 100 pF capacitor between the sense pin and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I personally suspect you will get the best results when the user's presence affects at small mutual capacitance between a sense surface and a ground surface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One idea could be to have a large ground plane, and on it a smaller insulated &quot;sense&quot; plate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another could be to run two parallel traces in a spiral filling a large area&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do take care to secure you wires - they are part of your sensor too, and if they move relative to each other they will alter the baseline.  Any other mobile cables in the vicinity can have the same effect, especially if they contain a ground that can exhibit capacitance to the sense node.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-08T18:27:24.200" LastActivityDate="2014-05-08T18:27:24.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1463" PostTypeId="1" AcceptedAnswerId="1467" CreationDate="2014-05-08T18:42:58.920" Score="1" ViewCount="377" Body="&lt;p&gt;A digital pin's output voltage on an UNO board is 5V, which is equal to the output from the VCC. I read that the DC current limits of those pins are 40mA and 200mA respectively, and that a higher current could damage the board. Now, since &lt;strong&gt;V=RI&lt;/strong&gt;, I expect to get the same current whether I connect a DC motor to the VCC or to a digital pin. But, the motor spins slower when connected to the digital pin. Therefore, I'm not getting the same current, and the only thing I could think of in order to explain this apparent contradiction with ohm's law is that there must be some mechanism to keep the current flowing through a digital pin inferior to 40mA. But I also read somewhere (can't find/remember the source) that there are no such mechanisms (except for a fuse concerning the USB)... So as you see, I can't understand what's going on. It will be really nice if someone could explain that to me... thanks in advance!  &lt;/p&gt;&#xA;" OwnerUserId="1200" LastActivityDate="2014-05-08T19:36:27.667" Title="digital pin's current limit, ohm's law and DC motor" Tags="|arduino-uno|motor|voltage-level|current|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1464" PostTypeId="1" CreationDate="2014-05-01T15:08:14.743" Score="1" ViewCount="2532" Body="&lt;p&gt;My task is to measure distances quite rapidly and send the data to a computer. I need to do it with the following equipment:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tiny-circuits.com/shop/tinyduino-processor-board/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tinyduino Processor board&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tiny-circuits.com/shop/tinyshield-bluetooth-le/https://tiny-circuits.com/shop/tinyshield-bluetooth-le/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tinyduino Bluetooth LE shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tinyduino Cell Battery&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.parallax.com/product/28015?SortField=ProductName,ProductName&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ping))) Ultrasonic Distance Sensor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Distance&lt;/strong&gt;&#xA;&lt;br&gt;&#xA;I have found the distance already and it is right now stored in an int. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bluetooth&lt;/strong&gt;&#xA;&lt;br&gt;&#xA;For the bluetooth I am using the &lt;a href=&quot;https://github.com/jrowberg/bglib/tree/master/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;BGLib&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned above the distance is measured many times rapidly so I want to either transfer the data quickly or store the data somehow until measurement is done (after approximate 3 seconds). I have established connection to a connection already (GAP discoverabled undirected connectable). &#xA;Because I am using the Tinyduino Bluetooth LE shield, it already have a firmware that I cannot change. It consists of 2 charateristics: TX and RX. My problem is now I do not understand how to send the specific data to computer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Do I need to write a response to a command by the computer, or do I send a command with the &lt;code&gt;sendCommand&lt;/code&gt; function, or even a third?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And just another thing; is it better to store the data and wait till the measurement is over or should I try to transfer it while I measure it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(if there are some comments you would like to know what means, just write because they are Danish)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;BGLib.h&amp;gt;&#xA;#include &amp;lt;BGLibConfig.h&amp;gt;&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &quot;BGLib.h&quot;&#xA;&#xA;//Uncomment denne linje for at debugge via USB&#xA;//#define DEBUG&#xA;&#xA;//BLE er forkortelse for Bluetooth Low Energy&#xA;&#xA;// ================================================================&#xA;// BLE FORBINDELSESTILSTAND &#xA;// ================================================================&#xA;&#xA;// BLE TILSTANDSDEFINITONER&#xA;#define BLE_STATE_STANDBY           0&#xA;#define BLE_STATE_SCANNING          1&#xA;#define BLE_STATE_ADVERTISING       2&#xA;#define BLE_STATE_CONNECTING        3&#xA;#define BLE_STATE_CONNECTED_MASTER  4&#xA;#define BLE_STATE_CONNECTED_SLAVE   5&#xA;&#xA;// BLE state/link status&#xA;uint8_t ble_state = BLE_STATE_STANDBY;&#xA;uint8_t ble_encrypted = 0;  // 0 = not encrypted, otherwise = encrypted&#xA;uint8_t ble_bonding = 0xFF; // 0xFF = no bonding, otherwise = bonding handle&#xA;&#xA;// ================================================================&#xA;// HARDWARE FORBINDELSE OG GATT STRUKTUR SETUP&#xA;// ================================================================&#xA;&#xA;#define LED_PIN 13  // Status LED-pin&#xA;#define PING_PIN 11  // Ping pin til at ultralydssensor&#xA;&#xA;#define GATT_HANDLE_C_RX_DATA   17  // 0x11, supports &quot;write&quot; operation&#xA;#define GATT_HANDLE_C_TX_DATA   20  // 0x14, supports &quot;read&quot; and &quot;indicate&quot; operations&#xA;&#xA;// Brug softwareSerial på pins D3/D4 for RX/TX (Arduino side)&#xA;SoftwareSerial bleSerialPort(3, 4);&#xA;&#xA;// Opret BGLib objekt:&#xA;//  - use SoftwareSerial port for module comms&#xA;//  - use nothing for passthrough comms (0 = null pointer)&#xA;//  - enable packet mode on API protocol since flow control is unavailable&#xA;BGLib ble112((HardwareSerial *)&amp;amp;bleSerialPort, 0, 1);&#xA;&#xA;#define BGAPI_GET_RESPONSE(v, dType) dType *v = (dType *)ble112.getLastRXPayload()&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ARDUINO SETUP OG LOOP FUNKTIONER&#xA;// ================================================================&#xA;&#xA;// Kør under startup&#xA;void setup() {&#xA;    // Klargør status LED&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    digitalWrite(LED_PIN, LOW);&#xA;&#xA;    // BGLib lyttere&#xA;    ble112.ble_evt_system_boot = my_ble_evt_system_boot;&#xA;    ble112.ble_evt_connection_status = my_ble_evt_connection_status;&#xA;    ble112.ble_evt_connection_disconnected = my_ble_evt_connection_disconnect;&#xA;    //ble112.ble_evt_attributes_value = my_ble_evt_attributes_value;&#xA;&#xA;    // Åben Arduino USB serial, hvis vi skal debugge&#xA;    #ifdef DEBUG&#xA;      Serial.begin(38400);&#xA;    #endif&#xA;&#xA;    // Åben BLE software serial port&#xA;    bleSerialPort.begin(38400);&#xA;&#xA;    my_ble_evt_system_boot( NULL);&#xA;}&#xA;&#xA;// Main loop&#xA;void loop() {&#xA;    //Få afstand i microsekunder&#xA;    int *x = ping();&#xA;&#xA;    // Bliv ved med at spørge efter ny data hos BLE&#xA;    ble112.checkActivity();&#xA;&#xA;    // Få Arduino LED at blinke baseret på tilstand:&#xA;    //  - konstant = STANDBY&#xA;    //  - 1 puls per sekund = ADVERTISING&#xA;    //  - 2 puls per sekund = CONNECTED_SLAVE&#xA;    //  - 3 puls per sekund = CONNECTED_SLAVE med kryptering&#xA;    uint16_t slice = millis() % 1000;&#xA;    if (ble_state == BLE_STATE_STANDBY) {&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;    } else if (ble_state == BLE_STATE_ADVERTISING) {&#xA;        digitalWrite(LED_PIN, slice &amp;lt; 100); &#xA;    } else if (ble_state == BLE_STATE_CONNECTED_SLAVE) {&#xA;        if (!ble_encrypted) {&#xA;            digitalWrite(LED_PIN, slice &amp;lt; 100 || (slice &amp;gt; 200 &amp;amp;&amp;amp; slice &amp;lt; 300));&#xA;        } else {&#xA;            digitalWrite(LED_PIN, slice &amp;lt; 100 || (slice &amp;gt; 200 &amp;amp;&amp;amp; slice &amp;lt; 300) || (slice &amp;gt; 400 &amp;amp;&amp;amp; slice &amp;lt; 500));&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;int *ping()&#xA;{&#xA;    //Variabler til at lagre målte værdier&#xA;    int microseconds, cm;&#xA;&#xA;    //Send ping, som bagefter skal læses&#xA;    pinMode(PING_PIN, OUTPUT);&#xA;    digitalWrite(PING_PIN, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(PING_PIN, HIGH);&#xA;    delayMicroseconds(5);&#xA;    digitalWrite(PING_PIN, LOW);&#xA;&#xA;    //Aflæs tiden&#xA;    pinMode(PING_PIN, INPUT);&#xA;    microseconds = pulseIn(PING_PIN, HIGH);&#xA;&#xA;    //Konverter mikrosekunder til cm. Det går 29 microsekunder pr centimeter. &#xA;    //Halver afstand, fordi vi vil ikke have afstanden både frem og tilbage, men derimod kun den ene vej.&#xA;    cm = microseconds / 29 / 2;&#xA;&#xA;    #ifdef DEBUG&#xA;        Serial.print(cm, DEC);&#xA;    #endif&#xA;&#xA;    return &amp;amp;cm;&#xA;}&#xA;&#xA;// ================================================================&#xA;// APPLICATION HÆNDELSES FUNKTIONER&#xA;// ================================================================&#xA;&#xA;void my_ble_evt_system_boot(const ble_msg_system_boot_evt_t *msg) {&#xA;    #ifdef DEBUG&#xA;        Serial.print(&quot;###\tsystem_boot: { &quot;);&#xA;        Serial.print(&quot;major: &quot;); Serial.print(msg -&amp;gt; major, HEX);&#xA;        Serial.print(&quot;, minor: &quot;); Serial.print(msg -&amp;gt; minor, HEX);&#xA;        Serial.print(&quot;, patch: &quot;); Serial.print(msg -&amp;gt; patch, HEX);&#xA;        Serial.print(&quot;, build: &quot;); Serial.print(msg -&amp;gt; build, HEX);&#xA;        Serial.print(&quot;, ll_version: &quot;); Serial.print(msg -&amp;gt; ll_version, HEX);&#xA;        Serial.print(&quot;, protocol_version: &quot;); Serial.print(msg -&amp;gt; protocol_version, HEX);&#xA;        Serial.print(&quot;, hw: &quot;); Serial.print(msg -&amp;gt; hw, HEX);&#xA;        Serial.println(&quot; }&quot;);&#xA;    #endif&#xA;&#xA;    // SYSTEM BOOT betyder at systemet er på standby&#xA;    //ble_state = BLE_STATE_STANDBY;&#xA;    // ^^^ Spring over fordi vi alligevel skifter til advertising nedenunder&#xA;&#xA;    // Sæt advertisement interval to 200-300ms. Brug alle advertisement kanaler&#xA;    // (NOTE: min/max parametere er i 625 microsekunder)&#xA;    ble112.ble_cmd_gap_set_adv_parameters(320, 480, 7);&#xA;    while (ble112.checkActivity(1000));&#xA;&#xA;    // USE THE FOLLOWING TO LET THE BLE STACK HANDLE YOUR ADVERTISEMENT PACKETS&#xA;    // ========================================================================&#xA;    // start advertising general discoverable / undirected connectable&#xA;    ble112.ble_cmd_gap_set_mode(BGLIB_GAP_GENERAL_DISCOVERABLE, BGLIB_GAP_UNDIRECTED_CONNECTABLE);&#xA;    while (ble112.checkActivity(1000));&#xA;&#xA;    // set state to ADVERTISING&#xA;    ble_state = BLE_STATE_ADVERTISING;&#xA;}&#xA;&#xA;void my_ble_evt_connection_status(const ble_msg_connection_status_evt_t *msg) {&#xA;    #ifdef DEBUG&#xA;        Serial.print(&quot;###\tconnection_status: { &quot;);&#xA;        Serial.print(&quot;connection: &quot;); Serial.print(msg -&amp;gt; connection, HEX);&#xA;        Serial.print(&quot;, flags: &quot;); Serial.print(msg -&amp;gt; flags, HEX);&#xA;        Serial.print(&quot;, address: &quot;);&#xA;        // this is a &quot;bd_addr&quot; data type, which is a 6-byte uint8_t array&#xA;        for (uint8_t i = 0; i &amp;lt; 6; i++) {&#xA;            if (msg -&amp;gt; address.addr[i] &amp;lt; 16) Serial.write('0');&#xA;            Serial.print(msg -&amp;gt; address.addr[i], HEX);&#xA;        }&#xA;        Serial.print(&quot;, address_type: &quot;); Serial.print(msg -&amp;gt; address_type, HEX);&#xA;        Serial.print(&quot;, conn_interval: &quot;); Serial.print(msg -&amp;gt; conn_interval, HEX);&#xA;        Serial.print(&quot;, timeout: &quot;); Serial.print(msg -&amp;gt; timeout, HEX);&#xA;        Serial.print(&quot;, latency: &quot;); Serial.print(msg -&amp;gt; latency, HEX);&#xA;        Serial.print(&quot;, bonding: &quot;); Serial.print(msg -&amp;gt; bonding, HEX);&#xA;        Serial.println(&quot; }&quot;);&#xA;    #endif&#xA;&#xA;    // &quot;flags&quot; bit description:&#xA;    //  - bit 0: connection_connected&#xA;    //           Indicates the connection exists to a remote device.&#xA;    //  - bit 1: connection_encrypted&#xA;    //           Indicates the connection is encrypted.&#xA;    //  - bit 2: connection_completed&#xA;    //           Indicates that a new connection has been created.&#xA;    //  - bit 3; connection_parameters_change&#xA;    //           Indicates that connection parameters have changed, and is set&#xA;    //           when parameters change due to a link layer operation.&#xA;&#xA;    // check for new connection established&#xA;    if ((msg -&amp;gt; flags &amp;amp; 0x05) == 0x05) {&#xA;        // track state change based on last known state, since we can connect two ways&#xA;        if (ble_state == BLE_STATE_ADVERTISING) {&#xA;            ble_state = BLE_STATE_CONNECTED_SLAVE;&#xA;        } else {&#xA;            ble_state = BLE_STATE_CONNECTED_MASTER;&#xA;        }&#xA;    }&#xA;&#xA;    // update &quot;encrypted&quot; status&#xA;    ble_encrypted = msg -&amp;gt; flags &amp;amp; 0x02;&#xA;&#xA;    // update &quot;bonded&quot; status&#xA;    ble_bonding = msg -&amp;gt; bonding;&#xA;}&#xA;&#xA;void my_ble_evt_connection_disconnect(const struct ble_msg_connection_disconnected_evt_t *msg) {&#xA;    #ifdef DEBUG&#xA;        Serial.print(&quot;###\tconnection_disconnect: { &quot;);&#xA;        Serial.print(&quot;connection: &quot;); Serial.print(msg -&amp;gt; connection, HEX);&#xA;        Serial.print(&quot;, reason: &quot;); Serial.print(msg -&amp;gt; reason, HEX);&#xA;        Serial.println(&quot; }&quot;);&#xA;    #endif&#xA;&#xA;    // set state to DISCONNECTED&#xA;    //ble_state = BLE_STATE_DISCONNECTED;&#xA;    // ^^^ skip above since we're going right back into advertising below&#xA;&#xA;    // after disconnection, resume advertising as discoverable/connectable&#xA;    //ble112.ble_cmd_gap_set_mode(BGLIB_GAP_GENERAL_DISCOVERABLE, BGLIB_GAP_UNDIRECTED_CONNECTABLE);&#xA;    //while (ble112.checkActivity(1000));&#xA;&#xA;    // after disconnection, resume advertising as discoverable/connectable (with user-defined advertisement data)&#xA;    ble112.ble_cmd_gap_set_mode(BGLIB_GAP_USER_DATA, BGLIB_GAP_UNDIRECTED_CONNECTABLE);&#xA;    while (ble112.checkActivity(1000));&#xA;&#xA;    // set state to ADVERTISING&#xA;    ble_state = BLE_STATE_ADVERTISING;&#xA;&#xA;    // clear &quot;encrypted&quot; and &quot;bonding&quot; info&#xA;    ble_encrypted = 0;&#xA;    ble_bonding = 0xFF;&#xA;}&#xA;&#xA;/*void my_ble_evt_attributes_value(const struct ble_msg_attributes_value_evt_t *msg) {&#xA;    #ifdef DEBUG&#xA;        Serial.print(&quot;###\tattributes_value: { &quot;);&#xA;        Serial.print(&quot;connection: &quot;); Serial.print(msg -&amp;gt; connection, HEX);&#xA;        Serial.print(&quot;, reason: &quot;); Serial.print(msg -&amp;gt; reason, HEX);&#xA;        Serial.print(&quot;, handle: &quot;); Serial.print(msg -&amp;gt; handle, HEX);&#xA;        Serial.print(&quot;, offset: &quot;); Serial.print(msg -&amp;gt; offset, HEX);&#xA;        Serial.print(&quot;, value_len: &quot;); Serial.print(msg -&amp;gt; value.len, HEX);&#xA;        Serial.print(&quot;, value_data: &quot;);&#xA;        // this is a &quot;uint8array&quot; data type, which is a length byte and a uint8_t* pointer&#xA;        for (uint8_t i = 0; i &amp;lt; msg -&amp;gt; value.len; i++) {&#xA;            if (msg -&amp;gt; value.data[i] &amp;lt; 16) Serial.write('0');&#xA;            Serial.print(msg -&amp;gt; value.data[i], HEX);&#xA;        }&#xA;        Serial.println(&quot; }&quot;);&#xA;    #endif&#xA;&#xA;    // check for data written to &quot;c_rx_data&quot; handle&#xA;    if (msg -&amp;gt; handle == GATT_HANDLE_C_RX_DATA &amp;amp;&amp;amp; msg -&amp;gt; value.len &amp;gt; 0) {&#xA;        // set ping 8, 9, and 10 to three lower-most bits of first byte of RX data&#xA;        // (nice for controlling RGB LED or something)&#xA;        digitalWrite(8, msg -&amp;gt; value.data[0] &amp;amp; 0x01);&#xA;        digitalWrite(9, msg -&amp;gt; value.data[0] &amp;amp; 0x02);&#xA;        digitalWrite(10, msg -&amp;gt; value.data[0] &amp;amp; 0x04);&#xA;    }&#xA;}*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6402" OwnerDisplayName="Highace2" LastEditorUserId="6402" LastEditDate="2017-05-05T08:38:37.737" LastActivityDate="2017-05-05T08:38:37.737" Title="Sending information through Bluetooth 4.0 (LE) with Tinyduino" Tags="|c++|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1465" PostTypeId="1" CreationDate="2014-05-03T17:43:35.953" Score="1" ViewCount="9060" Body="&lt;p&gt;I have problems with the Wi-Fi shield example code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;*****&quot;;          //  your network SSID (name) &#xA;char pass[] = &quot;*****&quot;;   // your network password&#xA;&#xA;int status = WL_IDLE_STATUS;&#xA;char servername[]=&quot;google.com&quot;;  // remote server we will connect to&#xA;&#xA;WiFiClient client;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    //disable SD SPI&#xA;    pinMode(4, OUTPUT);&#xA;    digitalWrite(4, HIGH);&#xA;&#xA;    Serial.println(&quot;Attempting to connect to WPA network...&quot;);&#xA;    Serial.print(&quot;SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;&#xA;    status = WiFi.begin(ssid, pass);&#xA;    if ( status != WL_CONNECTED) { &#xA;        Serial.println(&quot;Couldn't get a wifi connection&quot;);&#xA;        // don't do anything else:&#xA;        while(true);&#xA;        } &#xA;     else {&#xA;     Serial.println(&quot;Connected to wifi&quot;);&#xA;     Serial.println(&quot;\nStarting connection...&quot;);&#xA;     // if you get a connection, report back via serial:&#xA;     if (client.connect(servername, 80)) {&#xA;         Serial.println(&quot;connected&quot;);&#xA;         // Make a HTTP request:&#xA;         client.println(&quot;GET /search?q=arduino HTTP/1.0&quot;);&#xA;         client.println();&#xA;      }&#xA;    }&#xA;}&#xA;&#xA; void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Wi-Fi Shield has connected with the internet Wi-Fi, but the last printing was &quot;Starting connection...&quot; I can't get to connect to (google.com), why?&lt;/p&gt;&#xA;" OwnerDisplayName="user3599622" LastEditorUserId="6936" LastEditDate="2016-02-21T08:12:13.737" LastActivityDate="2016-02-21T08:12:13.737" Title="Problems with using example code for Wi-Fi shield (arduino)" Tags="|wifi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1466" PostTypeId="2" ParentId="1465" CreationDate="2014-05-08T10:17:22.930" Score="0" Body="&lt;p&gt;I had this problem aswell. The problem was a bug with the official editor of arduino. I fixed this by downgrading the editor to version 1.0.3. (from 1.0.5) You can find a download link for it at the Arduino website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helped!&lt;br&gt;&#xA;-Kad&lt;/p&gt;&#xA;" OwnerUserId="1371" OwnerDisplayName="Kad" LastActivityDate="2014-05-08T10:17:22.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1467" PostTypeId="2" ParentId="1463" CreationDate="2014-05-08T19:27:30.770" Score="2" Body="&lt;p&gt;The ATmega (or any other processor that could reasonably be used on an Arduino) output pins consist of a &lt;code&gt;Totem Pole&lt;/code&gt; driver with a PMOS transistor which can drive the output towards Vdd and an NMOS transistor which can drive it towards ground.  Each of these can be modeled as a switch which has a small resistance when &quot;on&quot;, and due to device physics the PMOS transistor has a higher resistance than the NMOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 40ma figure is an &quot;Absolute Maximum&quot; rating - a limit above which damage could be possible.  At some current less than that, it is likely the voltage drop across the PMOS transistor will start to be great enough that the output voltage can only marginally be considered a logic &quot;high&quot; - it &lt;strong&gt;will be notably less than the supply&lt;/strong&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting your motor to an ATmega pin is an extreme, &lt;strong&gt;far out of spec&lt;/strong&gt;.  When you do that, the voltage drop across the PMOS transistor is much larger, making the output voltage quite low.  Additionally, the current flowing through the resistance produces heat within the chip, which can (at least as a rule-of-thumb concern) lead to damage.  Finally, your motor will produce &lt;code&gt;inductive kickback&lt;/code&gt;, &quot;spike&quot; voltage possibly high enough to pierce the gate oxide of the MOS gates in the chip, destroying it.  &lt;code&gt;Latchup&lt;/code&gt; is another possibility - a &lt;em&gt;sometimes temporary&lt;/em&gt; condition where the bulk of the die ends up biased to conduct in the wrong direction and the chip effectively shorts out its power supply, turning it into a &lt;em&gt;miniature space heater&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;There really are no components on your typical Arduino board designed to directly control a motor.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, for unidirectional control you should use a circuit with an &lt;code&gt;NPN&lt;/code&gt; bipolar transistor, &lt;code&gt;NMOS FET&lt;/code&gt;, magnetic relay, or solid state relay.  The latter are commonly available pre-assembled on shields.  With a transistor solution driving the motor in only one direction, it is generally advisable to pick an NPN transistor or NFET and place it in the negative lead of the motor, as the N devices work better due to the greater mobility of electrons than electron-holes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For bidirectional control, look for a &lt;code&gt;motor shield&lt;/code&gt; based on an &lt;code&gt;H bridge&lt;/code&gt; IC such as the &lt;code&gt;TB6612FNG&lt;/code&gt; or the less efficient bipolar &lt;code&gt;L298&lt;/code&gt; or &lt;code&gt;L293&lt;/code&gt;/&lt;code&gt;SN754410&lt;/code&gt;.  This basically puts a high current &lt;code&gt;Totem Pole&lt;/code&gt; driver on each lead of the motor, allowing you to drive them high &amp;amp; low for one direction or low &amp;amp; high for the other.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-08T19:36:27.667" LastActivityDate="2014-05-08T19:36:27.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1468" PostTypeId="2" ParentId="1445" CreationDate="2014-05-08T19:44:03.780" Score="2" Body="&lt;p&gt;Most Telecom operators agree for sending advertisements and promotions to their customers for certain business and some money. You can stop these promotion for your mobile by making (Do Not Disturb)DND active. In India, just do the following for DND Activation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ( Fully Blocked Category )&#xA;&#xA; Send SMS at START 0 to 1909 or Call at 1909 &#xA;&#xA;&#xA; Partial Blocked Category&#xA;&#xA;Send SMS at START 1 to 1909 to block Banking – Insurance – Financial Products – Credit Cards&#xA;Send SMS at START 2 to 1909 to block Real Estate&#xA;Send SMS at START 3 to 1909 to block Education&#xA;Send SMS at START 4 to 1909 to block Health&#xA;Send SMS at START 5 to 1909 to block Consumer Goods &amp;amp; Automobiles&#xA;Send SMS at START 6 to 1909 to block Communication – Broadcasting – Entertainment – IT&#xA;Send SMS at START 7 to 1909 to block Tourism&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;See more at: &lt;a href=&quot;http://www.techsiren.com/how-to-activate-do-not-disturb-india-registration/#sthash.F87Pfj5V.dpuf&quot; rel=&quot;nofollow&quot;&gt;http://www.techsiren.com/how-to-activate-do-not-disturb-india-registration/#sthash.F87Pfj5V.dpuf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2014-05-08T19:44:03.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1469" PostTypeId="2" ParentId="1454" CreationDate="2014-05-08T21:06:30.000" Score="-1" Body="&lt;p&gt;Have you try using a digital potentiometer name AD5220, it let you adjust the resistance &#xA;with using your hand. You can find more info about it at www.analog.com. I would upload an &#xA;image of the schematic but i just don't know how.&lt;/p&gt;&#xA;" OwnerUserId="1324" LastActivityDate="2014-05-08T21:06:30.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1470" PostTypeId="2" ParentId="1461" CreationDate="2014-05-08T21:18:53.953" Score="1" Body="&lt;p&gt;I see one problem with the global structure of your program; everytime &lt;code&gt;loop()&lt;/code&gt; is run, it: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;checks if an SMS is present, and gets the originating phone number if present, otherwise it just goes on, ie &lt;code&gt;smss()&lt;/code&gt; function returns &lt;strong&gt;without&lt;/strong&gt; modifying &lt;code&gt;remoteNumber&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;send an SMS to &lt;code&gt;remoteNumber&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One problem here is that your &lt;code&gt;loop()&lt;/code&gt; will repeatedly try to send an SMS to the same &lt;code&gt;remoteNumber&lt;/code&gt; even if no SMS was received; actually, to solve this issue, you should modify &lt;code&gt;smss()&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either &lt;strong&gt;wait (forever) for an SMS to be received&lt;/strong&gt; and return only in this situation&lt;/li&gt;&#xA;&lt;li&gt;or &lt;strong&gt;return a value (eg &lt;code&gt;bool&lt;/code&gt;) that indicates whether an SMS was received&lt;/strong&gt; or not; then an SMS should be sent if and only if an SMS was just received.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    GSM and GPRS initialization&#xA;    Connection to server&#xA;} &#xA;&#xA;void loop()&#xA;{&#xA;    if (smss())&#xA;    {&#xA;        Reading the txt file content in server&#xA;&#xA;        sms.beginSMS(remoteNum);&#xA;        sms.print(txtMsg);&#xA;        sms.endSMS(); &#xA;    }&#xA;}&#xA;&#xA;bool smss() // I just want phone number&#xA;{&#xA;    if (sms.available())&#xA;    {&#xA;        Serial.println(&quot;Message received from:&quot;);&#xA;        sms.remoteNumber(remoteNum, 20);&#xA;        Serial.println(remoteNum);&#xA;        sms.flush();&#xA;        Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;        return true;&#xA;    }&#xA;    return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this code does not integrate error support as it should; indeed &lt;code&gt;sms.remoteNumber()&lt;/code&gt; may return error codes (any value &lt;code&gt;&amp;gt;1&lt;/code&gt;), in which case you should consider no SMS was received at all.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-08T21:18:53.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1471" PostTypeId="1" AcceptedAnswerId="1483" CreationDate="2014-05-08T22:08:00.080" Score="8" ViewCount="41443" Body="&lt;p&gt;I have a &lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun Arduino Pro Micro with an ATmega32u4 on it&lt;/a&gt; and a &lt;a href=&quot;https://www.sparkfun.com/products/10253&quot; rel=&quot;nofollow noreferrer&quot;&gt;Roving Networks RN32 Bluetooth Module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Theoretically, I should be able to solder the Rx of the Bluetooth to the Tx on the arduino and vice versa and I should get serial communication over the Bluetooth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, I do not. However, as a first question: How do I get my Arduino to transmit data over the Tx pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded this to the Arduino with no hiccups: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup(){ &#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  Serial.print(&quot;HelloWurld&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I plug up my o-scope, I see no signal over the Tx line. Nada. I see data coming over the USB into the COM port on my computer, but nothing over the Tx pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the Arduino to put out serial data on the Tx pin?&lt;/p&gt;&#xA;" OwnerUserId="1365" OwnerDisplayName="user3320919" LastEditorUserId="37523" LastEditDate="2019-08-21T22:19:56.510" LastActivityDate="2019-08-21T22:19:56.510" Title="Arduino Pro Micro, get data out of Tx pin?" Tags="|serial|bluetooth|arduino-pro-micro|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="1472" PostTypeId="1" AcceptedAnswerId="1479" CreationDate="2014-05-08T22:14:18.870" Score="0" ViewCount="1909" Body="&lt;p&gt;Can I upload new programs onto a MEGA2560 through a serial port connected to pins 2&amp;amp;3?  (through the correct RS232&amp;lt;-&gt;TTL level shifters)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the 16U2 chip acts as a USB-&gt;serial converter and it also asserting the reset which starts the bootloader running on the 2650. Does it do anything else? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as I can time the reset correctly, is there anything else preventing reprogramming directly through the RX/TX pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if I do this, will the application program still be able to use the serial channel?&lt;/p&gt;&#xA;" OwnerUserId="1364" LastActivityDate="2014-05-10T02:53:02.167" Title="Can I load programs through the RS232 pins?" Tags="|arduino-mega|uploading|bootloader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1474" PostTypeId="2" ParentId="1471" CreationDate="2014-05-09T04:51:58.197" Score="5" Body="&lt;p&gt;The bluetooth board uses &lt;strong&gt;3.3V&lt;/strong&gt;, not 5V according the &lt;a href=&quot;https://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-42-ds.pdf&quot; rel=&quot;noreferrer&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you'll need to &lt;strong&gt;shift the voltage level&lt;/strong&gt; between it and the Arduino board (which is &lt;strong&gt;5V&lt;/strong&gt;). Note that the spec sheet shows how this can easily be done with 2 resistors (&lt;code&gt;R1&lt;/code&gt; and &lt;code&gt;R2&lt;/code&gt; in sheet typical application circuit, page 5).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, on the bluetooth module, the RS232 interface has 4 pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UART_TX&lt;/li&gt;&#xA;&lt;li&gt;UART_RX&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;UART_CTS&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;UART_RTS&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UART_CTS&lt;/strong&gt; must be &lt;strong&gt;0&lt;/strong&gt; to ensure the device reads incoming bytes. Normally this is done by an internal pulldown resistor, but you must ensure you did not connect that pin to &lt;strong&gt;+V&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, ensure that the baud rate of the module is properly set to &lt;strong&gt;9600 bauds&lt;/strong&gt;, the same as in your program.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-09T04:51:58.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1475" PostTypeId="1" AcceptedAnswerId="2882" CreationDate="2014-05-09T09:53:56.413" Score="1" ViewCount="3217" Body="&lt;p&gt;I am working with the MMA8452q accelerometer by Freescale.  I am trying to set it up to be in low power mode, to go to sleep when no motion has happened, and to wake up due to motion being detected and trigger the  interrupt that corresponds to it.  I am using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have verified the accelerometer works (i.e. can read off accelerometer data and communicate properly to it via I2C), and I have also verified that the interrupt and handler all work (by manually triggering the interrupt as compared to using the accelerometer).  However, after initializing using the code below, my interrupt due to motion is not getting triggered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;-The datasheet can be found here: &lt;a href=&quot;http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-App note can be found here: &lt;a href=&quot;http://cache.freescale.com/files/sensors/doc/app_note/AN4074.pdf&quot; rel=&quot;nofollow&quot;&gt;http://cache.freescale.com/files/sensors/doc/app_note/AN4074.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MMA8452::initMMA8452(unsigned char fsr)&#xA;{&#xA;    //CONFIGURE THE ACCELEROMETER   &#xA;    MMA8452Standby();  // Must be in standby to change registers&#xA;&#xA;    //Set up the full scale range to 2, 4, or 8g.&#xA;    if ((fsr==2)||(fsr==4)||(fsr==8))&#xA;        writeRegister(XYZ_DATA_CFG, fsr &amp;gt;&amp;gt; 2);  &#xA;    else&#xA;        writeRegister(XYZ_DATA_CFG, 0);&#xA;&#xA;    writeRegister(CTRL_REG1, readRegister(CTRL_REG1) | bmRES1DOT56);  //1.56Hz resolution in both wake and sleep mode (lowest power)&#xA;    writeRegister(CTRL_REG2, readRegister(CTRL_REG2) | (LP &amp;lt;&amp;lt; SMODS) | (LP &amp;lt;&amp;lt; MODS) | (1 &amp;lt;&amp;lt; SLPE));  //LOW POWER MODE IN SLEEP &amp;amp; ACTIVE STATES WITH LOWEST SAMPLING&#xA;&#xA;    writeRegister(CTRL_REG3, (1 &amp;lt;&amp;lt; WAKE_FF_MT));        //ONLY WAKE UP FROM MOTION DETECTION&#xA;    writeRegister(CTRL_REG4, (1 &amp;lt;&amp;lt; INT_EN_ASLP) | (1 &amp;lt;&amp;lt; INT_EN_FF_MT));  //ENABLE SLP/AWAKE INTERRUPT (INTERRUPT THROWN WHENEVER IT CHANGES) &amp;amp; MOTION INTERRUPT TO KEEP AWAKE&#xA;    writeRegister(ASLP_COUNT, ASLP_TIMEOUT);    //162s TIMEOUT BEFORE SLEEPING&#xA;&#xA;    writeRegister(CTRL_REG5, (1 &amp;lt;&amp;lt; INT_CFG_FF_MT) | (1 &amp;lt;&amp;lt; INT_CFG_ASLP));  //INTERRUPT SLEEP AND FREE FALL TO INT1 PIN OF MMA8452 &#xA;&#xA;    //SETUP THE MOTION DETECTION&#xA;    writeRegister(FF_MT_CFG, (1 &amp;lt;&amp;lt; ELE) | (1 &amp;lt;&amp;lt; OAE));      //MOTION DETECTION AND LATCH THE RESULT WHEN IT HAPPENS AS OPPOSED TO COMBINATIONAL REAL TIME&#xA;    writeRegister(FF_MT_THS, MOTION_THRESHOLD);             //MOTION DETECTION THRESHOLDS &#xA;    writeRegister(FF_MT_COUNT, MOTION_DEBOUNCE_COUNT);      //TIME MOTION NEEDS TO BE PRESENT ABOVE THE THRESHOLD BEFORE INTERRUPT CAN BE ASSERTED&#xA;&#xA;    MMA8452Active();&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1370" LastEditorUserId="42" LastEditDate="2014-05-09T10:11:32.553" LastActivityDate="2014-06-09T02:55:35.027" Title="Setting up the MMA8452 to trigger interrupt" Tags="|arduino-uno|firmware|accelerometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1477" PostTypeId="1" AcceptedAnswerId="1478" CreationDate="2014-05-09T11:57:57.010" Score="22" ViewCount="74152" Body="&lt;p&gt;Is it possible to reset an Arduino (i.e., to reboot it) from code (i.e from the sketch itself)? I know that is possible with a special circuit but is there a chance to make it just with code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code and the comment &lt;code&gt;//reset&lt;/code&gt; is where I want to force a reset.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;&#xA;int i;&#xA;int randSeed;&#xA;long randNumber;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;20 pseudo Zufallszahlen:&quot;);&#xA;  for (i=1;i&amp;lt;=20;i++) Serial.print(random(10));&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  //randomSeed(TrueRandom.random());&#xA;  randSeed = analogRead (A0);&#xA;  randomSeed(randSeed);&#xA;  Serial.print(&quot;Der 'seed' Wert: &quot;);&#xA;  Serial.println(randSeed);&#xA;  Serial.println();&#xA;  Serial.println(&quot;20 Zufallszahlen mit analogem 'seed' Wert:&quot;);&#xA;  for (i=1;i&amp;lt;=20;i++) Serial.print(random(10));&#xA;  Serial.println();&#xA;  Serial.println(&quot;---------------------------&quot;);&#xA;  Serial.println();&#xA;  delay(500);&#xA;  //reset  &#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to reset the micro-controller at the end of the setup function to show the effect of random numbers with and without a seed.&lt;/p&gt;&#xA;" OwnerUserId="233" LastEditorUserId="4628" LastEditDate="2017-05-01T08:24:10.870" LastActivityDate="2021-04-20T15:59:02.547" Title="Reset an Arduino Uno in code" Tags="|arduino-uno|software|reset|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1478" PostTypeId="2" ParentId="1477" CreationDate="2014-05-09T13:51:12.177" Score="25" Body="&lt;p&gt;There three ways to accomplish this. (last is my favorite)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Jumper an unused IO to the RESET pin. Leave it as INPUT for normal&#xA;    run, As it is externally pulled high. And when desired to reset set&#xA;    it as LOW and Output. (bang its rebooting).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup() {&#xA;  ...&#xA;  pinMode(PINtoRESET, INPUT);    // Just to be clear, as default is INPUT. Not really needed.&#xA;  digitalWrite(PINtoRESET, LOW); // Prime it, but does not actually set output. &#xA;  ...                            // Does disable 10K pull Up, but who cares.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then when desired...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;  pinMode(PINtoRESET, OUTPUT);   // lights out. Assuming it is jumper-ed correctly.&#xA;  while(1);                      // never gets here.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Jump to beginning of the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void(* resetFunc) (void) = 0;  // declare reset fuction at address 0&#xA;...&#xA;resetFunc(); //call reset&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But be careful&lt;/strong&gt;, this does not perform a true reset, in that all the registers ARE NOT DEFAULTED. Rather they and the IO are left as is. Where somethings from the bootloader and then the heap will be initialized. And reset are not!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Use the watchdog. The &lt;a href=&quot;https://github.com/WickedDevice/SoftReset&quot;&gt;SoftReset&lt;/a&gt; library makes it easy. Although it is not difficult to implement directly. Shown below..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;...&#xA;setup() {&#xA;  ...&#xA;  MCUSR = 0;  // clear out any flags of prior resets.&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then when desired...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;wdt_enable(WDTO_15MS); // turn on the WatchDog and don't stroke it.&#xA;for(;;) { &#xA;  // do nothing and wait for the eventual...&#xA;} &#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-05-10T02:51:32.867" LastActivityDate="2014-05-10T02:51:32.867" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="1479" PostTypeId="2" ParentId="1472" CreationDate="2014-05-09T14:03:52.050" Score="1" Body="&lt;p&gt;The stock bootloader will accept the load of new programs on PE0(RX input) and PE1(TX output) (of the ATmega2560) just after reset. Note PE0/1 on the Arduino correspond to pins D0 and D1. Not D2 and D3. You could change the Boot loader if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 1K series resistor between the 16U2 and 2560's PE0/1. So you can directly connect your external TTL serial port's TX(out) to PE0(D0), without harm. And correspondingly connect PE1(D1) to the TTL Serial port's RX(in). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you need to synchronize the bootloader. Either by manually synchronizing the Reset of the 2560 with the starting of the download (of AVRdude). Or by connecting the DTR(out) of the TTL Serial Port through a 100nF capacitor to the RESET pin of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also recommend putting the 16U2 into reset, to get it out of the way. Simply place a jumper between ICSP1's RESET2(pin5) and GND(pin6). &lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-05-10T02:53:02.167" LastActivityDate="2014-05-10T02:53:02.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1480" PostTypeId="2" ParentId="1194" CreationDate="2014-05-09T15:20:31.753" Score="2" Body="&lt;p&gt;I ended up ordering an &lt;a href=&quot;http://www.elechouse.com/elechouse/images/product/GSM_shield/GSM-GPRSModule.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Elechouse board&lt;/strong&gt;&lt;/a&gt; which uses the M10 chip. Found one on eBay for 59 USD. It appears to work fine with the official library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the manual says, it must be given external power - the USB cable isn't enough!&lt;/p&gt;&#xA;" OwnerUserId="943" LastActivityDate="2014-05-09T15:20:31.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1481" PostTypeId="1" AcceptedAnswerId="1482" CreationDate="2014-05-09T15:23:22.890" Score="6" ViewCount="1559" Body="&lt;p&gt;In which file can I find the calculation that is called with &lt;code&gt;random()&lt;/code&gt;? If it is not too much could you also post the content in your answer? I am using an Arduino Uno and its standard IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this in the &quot;WMath.cpp&quot; but that is not the final calculation. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void randomSeed(unsigned int seed)&#xA;{&#xA;  if (seed != 0) {&#xA;    srandom(seed);&#xA;  }&#xA;}&#xA;&#xA;long random(long howbig)&#xA;{&#xA;  if (howbig == 0) {&#xA;    return 0;&#xA;  }&#xA;  return random() % howbig;&#xA;}&#xA;&#xA;long random(long howsmall, long howbig)&#xA;{&#xA;  if (howsmall &amp;gt;= howbig) {&#xA;    return howsmall;&#xA;  }&#xA;  long diff = howbig - howsmall;&#xA;  return random(diff) + howsmall;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="233" LastEditorUserId="84" LastEditDate="2014-05-19T04:24:00.833" LastActivityDate="2017-01-08T21:26:09.117" Title="Formula / calculation of the function random() / randomSeed()" Tags="|arduino-uno|software|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1482" PostTypeId="2" ParentId="1481" CreationDate="2014-05-09T17:23:41.927" Score="7" Body="&lt;p&gt;The underlying &lt;code&gt;random()&lt;/code&gt; function isn't part of the Arduino code. It's actually part of &lt;code&gt;avr-libc&lt;/code&gt;. The Arduino IDE only comes with pre-compiled object code for it (as far as I know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's open source though. You can get information about it here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc&quot;&gt;http://www.nongnu.org/avr-libc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you look down the page a short way, you'll find the &quot;Source code and documentation&quot; link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;random()&lt;/code&gt; function is under &lt;code&gt;libc/stdlib/random.c&lt;/code&gt;. I would paste the source code here, but technically I'd have to include a whole copyright notice with it.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-09T17:23:41.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1483" PostTypeId="2" ParentId="1471" CreationDate="2014-05-09T20:33:32.830" Score="19" Body="&lt;p&gt;You appear to have a &quot;pro micro&quot; style board in which the USB communication is directly sourced from the main ATmega32u4 processor, rather than generated as serial data and then forwarded to a distinct USB-serial converter as on traditional Arduinos.   &lt;em&gt;Your question could have been resolved much more quickly if you had clearly stated the type of board you were using in words, rather than only as a product link (so I edited that into your question)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMicro&quot;&gt;documentation&lt;/a&gt; for the official Arduino Pro Micro:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Therefore to generate output on the hardware UART you will need to change all occurrences of &lt;code&gt;Serial&lt;/code&gt; to &lt;code&gt;Serial1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){ &#xA;    Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;    Serial1.print(&quot;HelloWurld&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The transmit data will be sourced from ATmega32u4 pin 21 which is &quot;D1&quot; (digital pin 1) on the headers.  If you wish to probe it, that would be the best place to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to transmit data out of a &lt;strong&gt;different pin&lt;/strong&gt; which is not connectied to the ATmega32u4's UART (as your example with digital pin 5 hints you might) you must instead use &lt;a href=&quot;http://arduino.cc/en/Tutorial/SoftwareSerialExample&quot;&gt;SoftwareSerial&lt;/a&gt; or similar implementation to bit-bang the serial data out of a general purpose I/O pin.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (inspired by &lt;a href=&quot;http://arduino.cc/en/Tutorial/SoftwareSerialExample&quot;&gt;this example&lt;/a&gt;): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(4, 5); // RX, TX&#xA;&#xA;void setup(){ &#xA;    mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;    mySerial.print(&quot;HelloWurld&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-10T02:23:52.627" LastActivityDate="2014-05-10T02:23:52.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1484" PostTypeId="1" AcceptedAnswerId="1499" CreationDate="2014-05-09T20:55:08.513" Score="9" ViewCount="2843" Body="&lt;p&gt;I have an object whose constructor gets passed a parameter. If I know the parameter value at compile time, I can construct the object statically:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;static FOOOBJ foo(3);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I understand that it isn't really done statically, i.e. by the compiler, but is actually done during setup).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I don't know the parameter value at compile time, I'd still like to pre-allocate space for the object but construct the object in that space at run time. Can it be done without a separate &lt;code&gt;.initialize()&lt;/code&gt; method? &lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-05-09T21:03:19.050" LastActivityDate="2015-01-19T07:52:10.723" Title="Allocate object memory statically; intialize it dynamically?" Tags="|programming|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1485" PostTypeId="2" ParentId="1484" CreationDate="2014-05-09T21:20:06.800" Score="4" Body="&lt;p&gt;You can use &lt;a href=&quot;http://en.wikipedia.org/wiki/Placement_syntax&quot; rel=&quot;nofollow&quot;&gt;placement syntax&lt;/a&gt; to specify an existing allocation in which to instantiate the class.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FOOOBJ foo(0);&#xA;&#xA; ...&#xA;&#xA;  FOOOBJ *f = new (foo) FOOOBJ(3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-09T21:20:06.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1487" PostTypeId="2" ParentId="1448" CreationDate="2014-05-10T05:27:23.243" Score="4" Body="&lt;p&gt;What everyone else said, plus: if you find the digital-13 LED gives you a problem, you can always remove it from the circuit, either by removing the LED, or the series resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be useful if you are running out of digital I/Os, or you want several contiguous I/O bits and don't want one of them to behave differently from the others. &lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-05-10T05:27:23.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1488" PostTypeId="2" ParentId="1428" CreationDate="2014-05-10T05:53:05.073" Score="2" Body="&lt;p&gt;If you can't find some actual info regarding applying PID to a water-based radiator system, then I'd suggest the following principles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I assume that the output of the PID algorithm appears as an An Arduino PWM output at some rate. This could be a fast rate, like in the hundreds of Hz (if the load is DC), or fractions of Hz, or even 10 sec or more cycle time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I assume that the PID algorithm is likely designed to expect that a linear change in output has a linear effect on the heating output. That is to say, as though it's controlling an electric heater, where, for example, 25% ON-time produces 25% of full heat output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If these are true, then you need to determine how that relates to what you can control on your shunt valve. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it acceptable for the valve to be turned full on/off on a proportion-of-10-seconds basis? Probably not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the valve be set to an intermittent position if fed with a 10 Hz or 100 Hz PWM signal, perhaps so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the latter, then a further question is how does the PWM range of values correspond to actual angle of the valve, and more to the point, how does it correspond to flow rate, and ultimately to heat delivery. Perhaps a 33% PWM signal is required to deliver 25% of the full-range heat, for example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(At a guess, I'd assume that heat delivery is proportional to flow, but as I think you anticipate, flow is not proportional to valve angle.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might just mock up your system, program the Arduino to output particular PWM values to the valve, and measure the resulting flow, and if possible, heat delivery. Then, interpose in the PID library the inverse function, perhaps as a lookup table. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when the PID library wants to command 25%, that number gets looked up in the table, which (continuing my example) translates it to a 33% PWM signal, and your program sends that value to the PWM output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that provides some ideas.&lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-05-10T05:53:05.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1490" PostTypeId="1" CreationDate="2014-05-10T12:32:05.647" Score="2" ViewCount="1605" Body="&lt;p&gt;i've got the following problem i'd like to get solved and i'm breaking my head, so please help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a rectangle with the following size 40 cm * 50 cm. On each corner of this rectangle I placed a Piezo element (it's an electronic element which measures the vibration)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rectangle is defined as followed: the left upper corner = A the left lower corner = B the right lower corner = C the right upper corner = D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trowing a ball on the surface and I'd like to calculate it's X and Y axis. The outcome of the piezo elements are as followed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A,B,C,D - 0 lowest vibration, 1023 highest vibration These values can be mapped to a number I can decide, so that means I can make it whatever we need it to be. Example: map 0,1023,0,100, meaning the new mapping will be 0 - 100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a possible solution here: &lt;a href=&quot;http://mathafou.free.fr/pbg_en/sol114.html&quot; rel=&quot;nofollow&quot;&gt;http://mathafou.free.fr/pbg_en/sol114.html&lt;/a&gt; The problem I got is that i don't know where the ball will be and therefor I don't know the angle it will fall on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing I do now is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: We trow the ball. The outcome could be ABC or what would be best ABCD results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought Pythagoras could come in handy here. The thing I did was: A*A+B*B=C*C (to get the square calculation done) A+B = AB, B+C = BC, A+C= AC, (to get the sides of a triangle) AB*BC=AC (We don't know AC but we can square root the outcome of AB*BC)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then i realised I just know how long the side is and I still don't know where the ball landed :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following I already implemented to scale it when it works (maybe not relevant now) A+B+C+D = Total outcome we can possibly get at that point (as we are relying on vibration) A,B,C,D/Total = the scale we need to calculate with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I call this A1,B1,C1,D1 so I can re-use this in the code The reason I do this, is the follow up I need it for. Im going to use a projector to project a video on the exact X/Y position. But that's not relevant I guess for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm programming this in Processing 2 : &lt;a href=&quot;http://processing.org&quot; rel=&quot;nofollow&quot;&gt;http://processing.org&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1377" LastEditorUserId="11" LastEditDate="2014-05-10T18:13:49.960" LastActivityDate="2014-06-09T21:04:00.680" Title="Calculating location with 4 piezo's" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1491" PostTypeId="1" AcceptedAnswerId="1502" CreationDate="2014-05-10T14:08:24.387" Score="2" ViewCount="4946" Body="&lt;p&gt;a couple of friends and i are working on a double axis solar tracker with a Adafruit Motor-shield V2 and 2x Adafruit bipolar stepper motors (200/rev).&#xA;We got the following code so far but are stuck with getting the steppers to stop at a certain angle (90° for vertical and 180° for horizontal) so that we dont tangle up the wires and avoid unnecessary movement. Any help and sugestions would be much appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;Adafruit_StepperMotor *stepperh = AFMS.getStepper(200, 1);  // declaring horizontal stepper&#xA;Adafruit_StepperMotor *stepperv = AFMS.getStepper(200, 2);  // declaring vertical stepper&#xA;&#xA;int ldr1 = A0;  // right ldr        &#xA;int ldr2 = A1;  // centre ldr&#xA;int ldr3 = A2;  // left ldr&#xA;int ldr4 = A3;  // top ldr&#xA;int ldr5 = A4;  // bottom ldr&#xA;&#xA;const int threshold = 550;  // limit to stop tracker from moving at night&#xA;&#xA;const int tol = 50;  // tolerance for ldrs // maybe vertical AND horizontal depending on difference?&#xA;&#xA;//int = countv&#xA;//int = counth&#xA;&#xA;//const int maxh = ?    // to prevent overturning horizontal (50 steps = 90°) &#xA;//const int minh = ?    // combine with count int's // i.e. if counth &amp;gt; 90 - stop&#xA;//const int maxv = ?    // to prevent overturning vertical&#xA;//const int minv = ?&#xA;&#xA;void setup()&#xA;{&#xA;  AFMS.begin();&#xA;  stepperv-&amp;gt;setSpeed(10);  &#xA;  stepperh-&amp;gt;setSpeed(10);    &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int right = analogRead(ldr1);  &#xA;  int centre = analogRead(ldr2);&#xA;  int left = analogRead(ldr3);&#xA;  int up = analogRead(ldr4);&#xA;  int down = analogRead(ldr5);&#xA;&#xA;  //STOP MOVEMENT//&#xA;  if ((left &amp;lt; threshold) &amp;amp;&amp;amp; (right &amp;lt; threshold) &amp;amp;&amp;amp; (up &amp;lt; threshold) &amp;amp;&amp;amp; (down &amp;lt; threshold)) {}  // stop any movement if sensor values below threshold &#xA;                                                                                               // at begining to check after every sensor reading&#xA;&#xA;  //HORIZONTAL MOVEMENT//&#xA;  if((right &amp;gt; centre + tol) &amp;amp;&amp;amp; (left + tol &amp;lt; centre))   // &amp;amp;&amp;amp; (right - ? &amp;gt; tol)     &#xA;  {&#xA;    stepperh-&amp;gt;onestep(BACKWARD,DOUBLE);  // add +1 to int counth // if (minh &amp;lt; counth &amp;lt; maxh) - move // else - stop // counth=counth++ , counth=counth--                            &#xA;  }&#xA;  else if((left &amp;gt; centre + tol) &amp;amp;&amp;amp; (right + tol &amp;lt; centre))  // &amp;amp;&amp;amp; (left - ? &amp;gt; tol)  &#xA;  {&#xA;    stepperh-&amp;gt;onestep(FORWARD,DOUBLE);                      &#xA;  }&#xA;  else {}  // do nothing&#xA;&#xA;  //VERTICAL MOVEMENT//&#xA;  if((up &amp;gt; centre + tol) &amp;amp;&amp;amp; (down + tol &amp;lt; centre))  // &amp;amp;&amp;amp; (up - ? &amp;gt; tol)  &#xA;  {&#xA;    stepperv-&amp;gt;onestep(BACKWARD,DOUBLE);   &#xA;  }&#xA;  else if((down + tol &amp;gt; centre) &amp;amp;&amp;amp; (up + tol &amp;lt; centre))  // &amp;amp;&amp;amp; (down - ? &amp;gt; tol)  &#xA;  {&#xA;    stepperv-&amp;gt;onestep(FORWARD,DOUBLE);  &#xA;  }&#xA;  else{}  // do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2014-12-02T21:34:54.500" Title="Solar Tracker Code - how to limit steppers to max &amp; min angle?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1492" PostTypeId="2" ParentId="14" CreationDate="2014-05-10T14:18:33.093" Score="5" Body="&lt;p&gt;And the Arduino team finally figured it out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/&quot; rel=&quot;noreferrer&quot;&gt;http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8" LastActivityDate="2014-05-10T14:18:33.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1493" PostTypeId="1" AcceptedAnswerId="3693" CreationDate="2014-05-10T16:57:49.153" Score="5" ViewCount="1204" Body="&lt;p&gt;I'm working on a medium sized robot project with multiple arduinos to control stuff. I've been planning on using a lead-acid battery pack, but then I was given 10 working and identical Asus laptop battery packs rated at 14.8 V 4400 mAh, and one old Asus laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I opened up one of the battery packs, because it was bad and it has a 4S2P battery configuration and a protection board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I hook all of these battery packs in parallel, or will power leak between the battery packs, and is that be a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there alternatively some 4S20P or 3S25P battery pack with charger I can purchase to put these batteries in?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I do have a step-down converter that will provide the Arduinos with the right voltage, regardless of input voltage up to 36 V)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to ask a similar question on electrical engineering, but ot was deemed off topic for the site.&lt;/p&gt;&#xA;" OwnerUserId="1379" LastActivityDate="2014-08-14T17:01:45.543" Title="Using multiple laptop battery packs to power everything" Tags="|power|battery|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1494" PostTypeId="2" ParentId="1493" CreationDate="2014-05-10T17:47:36.600" Score="3" Body="&lt;p&gt;I'd be cautious about hooking them in parallel. &lt;a href=&quot;https://learn.adafruit.com/li-ion-and-lipoly-batteries/multi-battery-packs&quot; rel=&quot;nofollow&quot;&gt;According to ADAfruit&lt;/a&gt; power leakage between batteries &lt;em&gt;is&lt;/em&gt; a problem.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[multipack parallel] ... batteries are assembled by a company that is experienced and certified to test and assemble battery packs. The individual batteries are tested and sorted by machine so that each pack has matching batteries with the same capacity and internal resistance. Individuals do not have this equipment, which is why you should not try to make your own packs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Are you certain all your batteries are the same age and have the same usage history? A brand-spanking new one &lt;em&gt;will&lt;/em&gt; try to charge an old worn battery to its own fresh voltage.&lt;/p&gt;&#xA;" OwnerUserId="382" LastActivityDate="2014-05-10T17:47:36.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1495" PostTypeId="2" ParentId="1490" CreationDate="2014-05-10T20:19:17.047" Score="5" Body="&lt;p&gt;You might want to look into how LORAN works, as I believe you can do something similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First premise: You want to look for the &lt;strong&gt;initial transient&lt;/strong&gt; caused by the impact propagating to sensors in various places on the periphery.  The signal in the material will end up bouncing around quite a bit before it dies out, but the leading edge of the initial transient should be unambiguous, so use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second premise: You have &lt;em&gt;no idea&lt;/em&gt; when the ball actually hits - you can also measure the &lt;strong&gt;difference in timing&lt;/strong&gt; between when various sensors first detect it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So take any two sensors, measure the time lag between when they detect the ball, and convert that via the speed of sound in your material.  This yields the &lt;em&gt;difference&lt;/em&gt; in the distance of the impact point from the two sensors.  If you know the position of the two sensors, and plot the curves of points which satisfy the equation of the measured difference in distance from each of them you can a class of conic section called a &lt;code&gt;hyperbola&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But so far you do not have an answer, but only a pair of curves along which the impact must lie.  So now take at least one new sensor, and repeate the exercise generation a new equation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combine the equations and solve to find the intersection of the curves - this is your point of impact.  It is possible to have more than one mathematical solution, but I think you will find that only one possible solution lies in the area between the sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Unfortunately, the ATmega328p A/D converter probably isn't fast enough to do a good job of this - at 10KSPS each sample is around 34mm in air, and around half a meter in typical solids - so you either need a much faster A/D, or else tune a comparator circuit to detect pulses and measure them with ATmega timer channels.)  &lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-10T20:27:09.557" LastActivityDate="2014-05-10T20:27:09.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1496" PostTypeId="2" ParentId="1405" CreationDate="2014-05-11T14:56:48.430" Score="1" Body="&lt;p&gt;You can use a voltage regulator to get the supply voltage down to 3.3v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Serial Lines, the best way forward is to use a good level convertor like &lt;a href=&quot;https://www.sparkfun.com/products/11978&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11978&lt;/a&gt; from sparkfun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to buy it, you can also make it using a couple of Mosfet's and resistors. Here's the &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/Logic_Level_Converter.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt; from Sparkfun.&lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2014-05-11T14:56:48.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1497" PostTypeId="2" ParentId="1491" CreationDate="2014-05-11T15:34:33.347" Score="1" Body="&lt;p&gt;When working with steppers you have to realise that you are not dealing with absolute coordinates. Unlike with, for example servos, which you command to go to particular angle, you command steppers to rotate a particular amount of steps in a particular direction. This creates in your case the problem that you cannot actively check the positions of the steppers without some sensing element.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a solution I would suggest that you would store the steps the steppers take in some variables, and then with the code limiting, that these variables don't go over a surtain number. With this method, you need to have a way of setting the zero point of the steppers, meaning from where to start the counting. This could for example be done by driving the system against some switch, and then setting the step variable to zero here. This is usually done once in the bootup, meaning that it is excecuted in the setup function. &lt;/p&gt;&#xA;" OwnerUserId="1332" LastActivityDate="2014-05-11T15:34:33.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1498" PostTypeId="2" ParentId="1405" CreationDate="2014-05-11T15:36:28.237" Score="1" Body="&lt;p&gt;&lt;strong&gt;The simplest way&lt;/strong&gt;, as you ask, is probably a resitor-based &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;voltage divider&lt;/a&gt;; its main drawback is the waste of energy in the resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gWyVW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate the &quot;best&quot; resistor values, you'll need to know the amount of &lt;strong&gt;current&lt;/strong&gt; needed by the XBee module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Vin&lt;/code&gt; = &lt;strong&gt;5V&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Vout&lt;/code&gt; = &lt;strong&gt;3.3V&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Iout&lt;/code&gt; = to be determined (check XBee spec sheet for that)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you have to resolve the following equations to calculate the resistor values you shall use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R1 = R2 x (Vin - Vout) / Vout&#xA;Iout = (Vin - Vout) / R1 - Vout / R2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These equations simply come from applying Ohm's law and Kirchhoff's circuit laws.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://www.power-io.com/library/appnotes/voltage-divider.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;site calculates the ideal resistor values&lt;/a&gt; for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;code&gt;Iout&lt;/code&gt; = &lt;strong&gt;100mA&lt;/strong&gt;, it gives the following values:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;R1 = 17 Ohm&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;R2 = 33 Ohm&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Another &lt;strong&gt;simple way&lt;/strong&gt; is to use a &lt;strong&gt;3.3V zener diode&lt;/strong&gt; if you have one on hand. You can google for good circuit examples.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-11T15:36:28.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1499" PostTypeId="2" ParentId="1484" CreationDate="2014-05-11T15:56:34.833" Score="3" Body="&lt;p&gt;Using an &lt;code&gt;initialize()&lt;/code&gt; method to a class is contrary to the principle of a class constructor, i.e. once a class instance has been &lt;strong&gt;constructed&lt;/strong&gt;, it should be &quot;&lt;strong&gt;ready to use&lt;/strong&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by Ignacio's answer, C++ placement syntax is much better for your purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with Arduino libraries, placement syntax is not supported &quot;out of the box&quot;, so you  have to implement it yourself; don't fear, that is quite straightforward:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void* operator new(size_t size, void* ptr)&#xA;{&#xA;    return ptr;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Placement syntax can be a complex beast in C++, but for your specific purpose, its usage can be rather simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char buffer[sizeof FOOOBJ];&#xA;static FOOOBJ* foo;&#xA;&#xA;void setup() {&#xA;    ...&#xA;    foo = new (buffer) FOOOBJ(3);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference with your current code is that &lt;code&gt;foo&lt;/code&gt; is now a pointer, hence any method call will use &lt;code&gt;-&amp;gt;&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you absolutely want to keep using &lt;code&gt;foo&lt;/code&gt; as an instance and not a pointer, then you can do it (but I don't advise it as explained later) by using a &lt;strong&gt;reference&lt;/strong&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char buffer[sizeof FOOOBJ];&#xA;static FOOOBJ&amp;amp; foo = *((FOOOBJ*) buffer);&#xA;&#xA;void setup() {&#xA;    ...&#xA;    new (buffer) FOOOBJ(3);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with this code, is that you cannot know if &lt;code&gt;foo&lt;/code&gt; has already been constructed with a real &lt;code&gt;FOOOBJ&lt;/code&gt; instance or not; using a pointer, you can always check if it is &lt;code&gt;0&lt;/code&gt; or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using placement syntax, you must be aware that you cannot &lt;code&gt;delete&lt;/code&gt; the &lt;code&gt;foo&lt;/code&gt; instance above. If you want to destroy &lt;code&gt;foo&lt;/code&gt; (i.e. ensure that its destructor is called), then you have to explicitly call the destructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo-&amp;gt;~FOOOBJ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-05-14T19:29:07.827" LastActivityDate="2014-05-14T19:29:07.827" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1500" PostTypeId="1" CreationDate="2014-05-11T21:20:30.683" Score="5" ViewCount="1977" Body="&lt;p&gt;What I am trying to do is, to have arduino in low power mode and waking up only when a packet is received and is available to be read from the buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A scenario : Zigbee XBee module is not receiving anything, arduino is asleep. Once this particular module receives any data from any other module, it makes the arduino wake up and process this packet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked almost everywhere possible about this, and people say they do not have a 100% working solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the XBee module produce a particular output on a specific pin when it receives data? If so, can I connect that pin to the interrupt enabled pin on arduino and with that interrupt arduino or wake it up?&#xA;do I need arduino mega for that or is the uno a good enough option?&lt;/p&gt;&#xA;" OwnerDisplayName="user1392" LastActivityDate="2014-05-12T12:48:50.967" Title="How to make XBee module interrupt/wake arduino" Tags="|arduino-uno|arduino-mega|xbee|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1501" PostTypeId="1" AcceptedAnswerId="1505" CreationDate="2014-05-12T01:21:59.547" Score="0" ViewCount="2585" Body="&lt;p&gt;I have the Adafruit Motor Shield V2 and an &lt;a href=&quot;https://www.adafruit.com/product/858&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit stepper motor&lt;/a&gt;. I have not soldered the shield onto the Arduino (which is an Uno) yet because I don't want to make anything permanent yet. I have the Arduino plugged into a DC wall adapter and have the VIN jumper in the shield, and the green power light on the shield is lit. This is how the stepper is connected. &lt;img src=&quot;https://i.stack.imgur.com/LPtx3.jpg&quot; alt=&quot;setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in the picture, all the wires from the stepper are plugged in. The order of the wires is what it says it should be on the &lt;a href=&quot;https://www.adafruit.com/product/858&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt;, which is &lt;code&gt;orange-pink-red-blue-yellow&lt;/code&gt;.  My sketch's code is an adapted version of the StepperExample from the Adafruit motor library. Here's the full code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;&#xA;Adafruit_StepperMotor *myMotor = AFMS.getStepper(513, 2);&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Stepper test!&quot;);&#xA;&#xA;  AFMS.begin();&#xA;  myMotor-&amp;gt;setSpeed(5);&#xA;}    &#xA;&#xA;void loop() {&#xA;  myMotor-&amp;gt;step(100, FORWARD, SINGLE); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the stepper still doesn't move. Can anyone point out what I'm doing wrong here?&lt;/p&gt;&#xA;" OwnerUserId="1304" LastActivityDate="2014-05-12T14:17:28.713" Title="Adafruit motor shield + Adafruit stepper not working" Tags="|arduino-uno|shields|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1502" PostTypeId="2" ParentId="1491" CreationDate="2014-05-12T01:53:31.717" Score="4" Body="&lt;p&gt;The only sure way is to use one or more position or limit switches. Steps can be lost (motor didn't move as commanded due to, f/ex, overload), the motor could be back-driven while powered down or if over-powered by the mechanical system, or your step counting could be faulty due to a bug or a power glitch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At power-up or at any time your software thinks it might have got out of sync with the mechanicals, back into the limit switch at low speed (so you don't hard-crash), and reset your software counters, and reposition from there.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-05-12T01:53:31.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1504" PostTypeId="2" ParentId="1439" CreationDate="2014-05-12T09:35:04.117" Score="4" Body="&lt;p&gt;I'm using a adafruit motorshield v2 for my solar tracker project with two stepper motors atm.&#xA;i'm quite a new to arduino and coding and i think the shield made it a lot easier for me to get a hang of it - easy to code and nicely stack able on the ardiuno (little soldering to assemble but not too difficult).&lt;/p&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2014-05-12T09:35:04.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1505" PostTypeId="2" ParentId="1501" CreationDate="2014-05-12T09:44:03.227" Score="5" Body="&lt;p&gt;As far as I know, you have to solder the header pins. Here is a nice video demonstrating the assembly: &lt;a href=&quot;http://www.youtube.com/watch?v=yt-SEOZT-hI&quot; rel=&quot;nofollow&quot;&gt;Motorshield V2 assembly&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1378" LastEditorUserId="37" LastEditDate="2014-05-12T14:17:28.713" LastActivityDate="2014-05-12T14:17:28.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1506" PostTypeId="2" ParentId="1500" CreationDate="2014-05-12T12:48:50.967" Score="3" Body="&lt;p&gt;The pin number 9 and 13 on the Xbee are DTR/RTS used for hardware handshaking. You can connect it to the interrupt pins on the Arduino and program the arduino to wake when the pulse changes. Enable the DTR/RTS feature from X-CTU and it should work. Check &lt;a href=&quot;http://www.digi.com/support/forum/3314/hardware-flow-control-of-xbee-module&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2014-05-12T12:48:50.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1508" PostTypeId="1" AcceptedAnswerId="1510" CreationDate="2014-05-12T18:31:24.423" Score="8" ViewCount="2254" Body="&lt;p&gt;I have got a String filled up with 0 and 1 and would like to get an Integer out of it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String bitString = &quot;&quot;; &#xA;int Number;&#xA;int tmp;&#xA;&#xA;bitString = &quot;&quot;;&#xA;  for (i=1;i&amp;lt;=10;i++)&#xA;  {&#xA;    tmp= analogRead (A0);&#xA;    bitString +=  tmp % 2;&#xA;    delay(50);&#xA;  }&#xA;// now bitString contains for example &quot;10100110&quot; &#xA;// Number = bitstring to int &amp;lt;-------------&#xA;// In the end I want that the variable Number contains the integer 166&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="233" LastEditorUserId="233" LastEditDate="2014-05-12T18:45:04.390" LastActivityDate="2014-05-12T19:33:06.370" Title="Convert a Bitstring into an integer value" Tags="|arduino-uno|programming|string|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1509" PostTypeId="2" ParentId="1508" CreationDate="2014-05-12T19:14:02.033" Score="5" Body="&lt;p&gt;Check out &lt;code&gt;strtoul()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should work something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;unsigned long result = strtoul(bitstring.c_str(), NULL, 2);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you have a long variable which can be converted into an int if needed.&lt;/p&gt;&#xA;" OwnerUserId="1407" LastEditorUserId="1407" LastEditDate="2014-05-12T19:20:28.937" LastActivityDate="2014-05-12T19:20:28.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1510" PostTypeId="2" ParentId="1508" CreationDate="2014-05-12T19:33:06.370" Score="6" Body="&lt;p&gt;If you only need the string for printing you can store value in an integer and then use the &lt;a href=&quot;http://arduino.cc/en/Serial/Print&quot;&gt;Serial.print(number,BIN)&lt;/a&gt; function to format the output as a binary value.  Appending integers to strings is a potentially costly operation both in performance and memory usage.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Number = 0;&#xA;int tmp;&#xA;&#xA;for (int i=9;i&amp;gt;=0;i--) {&#xA;  tmp = analogRead (A0);&#xA;  Number += (tmp % 2) &amp;lt;&amp;lt; i;&#xA;  delay(50);&#xA;}&#xA;Serial.print(Number, BIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-05-12T19:33:06.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1512" PostTypeId="1" CreationDate="2014-05-12T20:26:46.410" Score="0" ViewCount="663" Body="&lt;p&gt;I have Two Arduinos, One with the help of sensors it will dynamically updates in to my server database. Other Arduino, reads the stored contents from the server database and sends sms to phones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have a text file in my server which updates dynamically for every 5 min - 10 min. I am trying to read that text file contents. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want my server to be always connected, So It must be in &lt;code&gt;setup()&lt;/code&gt; function.&#xA;I want update only to my text file which dynamically changes, so it must be &lt;code&gt;loop()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to implement this ? Any Suggestion ?  &lt;/p&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="1302" LastEditDate="2014-05-13T12:23:38.570" LastActivityDate="2021-07-29T01:06:55.607" Title="How to update a text file dynamically" Tags="|arduino-uno|gsm|web-server|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1513" PostTypeId="1" AcceptedAnswerId="1514" CreationDate="2014-05-12T21:03:41.750" Score="9" ViewCount="5502" Body="&lt;p&gt;I'm following the &quot;Get Started with Arduino&quot; Guidebook, and I'm at the part where pulse width modulation (PWM) is discussed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The instructions say to create a simple circuit with a breadboard, red LED, arduino (connected at pin 9 and ground) and a 270 ohm resistor. My power source will be the usb connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a 510 ohm resistor. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;May I use it instead? &lt;/li&gt;&#xA;&lt;li&gt;In general, will using a resistor with a higher resistance than intended in a circuit fry the arduino?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks very much for your help. I'm new to arduino and electronic circuits. I have a Uno R3.&lt;/p&gt;&#xA;" OwnerUserId="1408" LastActivityDate="2014-05-13T14:22:27.703" Title="Use Higher Resistance Than Instructed in a Circuit" Tags="|arduino-uno|led|resistor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1514" PostTypeId="2" ParentId="1513" CreationDate="2014-05-12T21:55:14.487" Score="4" Body="&lt;p&gt;The cases where using a higher value resistor will damage a circuit exist, but are a bit less usual than the cases where it may simply produce a weaker result than desired, or a different frequency response than desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The primary situations where you do have to watch out come about where &quot;feedback&quot; is used to adjust one thing in relation to something else, and so putting a larger resistor on the &quot;sense&quot; side of the circuit can cause the &quot;output&quot; to be too high.  Examples you might run into would be adjustable voltage regulators (obvious potential for damage with wrong output) and op-amps (higher than desired output, though more often distortion than damage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems quite likely the the role of the resistor in your circuit is to limit the current through the LED - protecting that (and to a more vaguely best-practices degree, the ATmega pin) from damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your needs it could be worth noting that a parallel combination of two 510 ohm resistors will give an effective resistance of half that, or 255 ohms.  This is very close to the design intent, so might be a decent substitution (cheap resistors have a larger tolerance for piece-to-piece variation of value than that anyway).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally I would say the desired 270 ohms feels a little small, and that I'd prefer to start with 330 ohms.  But if you do parallel two 510's, the 255 ohms would give just under 20ma of current if connected directaly across a 5v supply.  Given your LED will have some forward voltage drop (varies widely with color), and your Arduino pin a little of its own, the actual voltage and thus current will be less - as a guess the end result is likely to be in the 15ma range, and not unreasonable for many common LEDs.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resistors would also be a fairly easy component to salvage out of old electronics - the leads will end up short, but other than that you basically just need to read the color code, and perhaps confirm the value after removal with a meter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately though it is worth buying an assortment of resistors - the 1/4 watt size are generally preferred for breadboarding as the leads are the best fit.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-12T22:00:28.000" LastActivityDate="2014-05-12T22:00:28.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1516" PostTypeId="1" CreationDate="2014-05-13T02:19:14.563" Score="-2" ViewCount="1207" Body="&lt;p&gt;I'm building a simple RC car which I want to control using android phone. The phone has bluetooth and Wi-Fi. My questions is what will be the cheapest way to connect the two devices at about 50-120m range? I have thought of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Cheap bluetooth module (&lt;a href=&quot;http://www.ebay.com/itm/Slave-HC-06-Wireless-Bluetooth-Transeiver-RF-Master-Module-Serial-for-Arduino-/181358244980?pt=LH_DefaultDomain_0&amp;amp;hash=item2a39cb3474&quot; rel=&quot;nofollow&quot;&gt;like this&lt;/a&gt;). Will this fit into my problem? What range I will archieve using this module.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wi-fi module. I can set the android device to be &quot;wi-fi hotspot&quot;, but the wi-fi shields are pretty expensive tho.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any suggestions will be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="1411" LastActivityDate="2014-05-13T05:30:12.030" Title="Cheapest way to connect android device to arduino wirelessly" Tags="|arduino-uno|shields|wifi|bluetooth|android|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1517" PostTypeId="2" ParentId="1516" CreationDate="2014-05-13T05:30:12.030" Score="3" Body="&lt;p&gt;&lt;strong&gt;Solution 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to change the coverage radius, sadly none of them would help you to achieve a coverage of 50m.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you are not using a camera feed and just want to control, I think &lt;a href=&quot;https://www.sparkfun.com/products/153&quot; rel=&quot;nofollow&quot;&gt;RF transceiver&lt;/a&gt; would be best solution for you. But to implement this you mist connect an Arduino Mega ADK to your android device. Serially receive your directions to mega and then transmit the directions over RF transceiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are willing to change the coverage range to less than 15m, you can use &lt;a href=&quot;https://www.sparkfun.com/products/10050&quot; rel=&quot;nofollow&quot;&gt;Wi-Fi Module&lt;/a&gt;. This will also help you to get live camera feed from your RC car to your phone. Forget about Bluetooth module as they are slow, less range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can increase the coverage of Wi-Fi Module if you have a Wi-Fi AP with huge transmit power. As long as the module is able to receive the signal from AP, your car would do great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; :- Here is a cool tip. Record every turn instruction and the time after which it was given. When the signal from transmitter or AP is absent for more than a particular time, you can program the car to take a U-turn and reverse the directions. Your car will come home without any instruction.&lt;/p&gt;&#xA;" OwnerUserId="1372" LastActivityDate="2014-05-13T05:30:12.030" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1518" PostTypeId="2" ParentId="1513" CreationDate="2014-05-13T14:22:27.703" Score="3" Body="&lt;p&gt;If the resistor is in series w the LED, it'll just be about half as bright when you use 510 vs 270 ohms. I=E/R and all -&gt; half the current. Your PWM will still work, but starting from a lesser brightness on down.&lt;/p&gt;&#xA;" OwnerUserId="382" LastActivityDate="2014-05-13T14:22:27.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1519" PostTypeId="1" AcceptedAnswerId="1520" CreationDate="2014-05-13T14:39:53.843" Score="-3" ViewCount="78" Body="&lt;p&gt;I am looking for a multi-purpose wire protocol for Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirements:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Range of at least 500ft (200m)&lt;/li&gt;&#xA;&lt;li&gt;No shield required&lt;/li&gt;&#xA;&lt;li&gt;Able to communicate between Arduino and Raspberry Pi&lt;/li&gt;&#xA;&lt;li&gt;Be able to run &quot;point-to-multipoint&quot;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1414" LastEditorUserId="1414" LastEditDate="2014-05-13T15:05:42.747" LastActivityDate="2014-05-13T15:31:56.513" Title="Looking for a protocol, any hints?" Tags="|hardware|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1520" PostTypeId="2" ParentId="1519" CreationDate="2014-05-13T15:31:56.513" Score="4" Body="&lt;p&gt;There is nothing that will work given those constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only have low power 5V signals on the Arduino which won't handle your distance requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could look into &lt;a href=&quot;http://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow&quot;&gt;RS-485&lt;/a&gt; using a &lt;a href=&quot;https://www.sparkfun.com/products/11959&quot; rel=&quot;nofollow&quot;&gt;shield&lt;/a&gt; on the arduino side and a &lt;a href=&quot;https://www.sparkfun.com/products/10124&quot; rel=&quot;nofollow&quot;&gt;breakout board&lt;/a&gt; on the Raspberry Pi.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-05-13T15:31:56.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1521" PostTypeId="1" AcceptedAnswerId="1524" CreationDate="2014-05-13T15:38:30.957" Score="1" ViewCount="858" Body="&lt;p&gt;I've got a program running on the Arduino that is supposed to turn on and off a pump.  currently, I am outputting the reads of the components that need to be read and it shows when the port (port 13) is supposed to turn on and when it's supposed to turn off.  When I use a multimeter between the port 13 and ground, everything works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I start the program and the port is off, I get a reading of 0.03v @20v max (to be more precise, I get 14.0 at 200mV) - Shouldn't this be zero? or is there always going to be some electricity flowing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the port is turned on: &lt;code&gt;digitalWrite(airPump, HIGH);&lt;/code&gt; (and yes, airPump is set to 13), the voltage reads between 4.0 and 4.51 with spikes down to 3.65 on my multimeter set at 20v max.  is it ever stable? (pictured below)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Hybdk.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the main question is: I'm supposed to be sending the power from port 13 to a DC-DC converter.  I tested the converter on a separate bread board just by itself.  I used a DC power supply and set it to 4.5v, then ran the power through the vIn, grounded the ground pin and ran the vOut to the multimeter (then to ground with the multimeter) and I got it set to output only 2.5v with a constant 4.5 running into it. (pictured below)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ekznO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tested whether or not changing the voltage input would change the output at all and it seems it does not, from 1.5-15v, the converter stays steady at 2.5v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I do the exact same set up on the arduino with the power from port 13 running into the voltage in on the DC-DC converter, it gives me a reading of 0.01v.  Any idea why this is happening?&#xA;&lt;img src=&quot;https://i.stack.imgur.com/rWelz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked probably over 30 times and rearranged everything just as many, but nothing seems to help.  I can't get a stable 2.5V output from the converter with the arduino...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Below is a simple wiring diagram:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/rBXeK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The image shows what it is supposed to do, but for testing purposes I made it so if the rH is higher than average (I just breath on it) then the pump will turn on.&lt;/p&gt;&#xA;" OwnerUserId="1316" LastEditorUserId="1316" LastEditDate="2014-05-13T18:37:45.707" LastActivityDate="2014-05-13T19:17:14.493" Title="DC-DC converter with Arduino not working" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1523" PostTypeId="1" AcceptedAnswerId="1525" CreationDate="2014-05-13T19:09:09.237" Score="0" ViewCount="324" Body="&lt;p&gt;So I have a project in which an arduino runs on a two cell LiPo battery and I need a fast, straight forward way to determine remaining battery charge (with an accuracy of 10% so I only have a readout with 10 LEDs on it) without using any major extra components (so using an external battery charge meter IC is cheating :P). How should I go about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(using arduino mini, LiPo is two cells: 7,4V 150mAh)&lt;/p&gt;&#xA;" OwnerUserId="1281" LastActivityDate="2014-05-14T04:31:03.400" Title="Measure LiPo / Li-Ion SOC or the ever standing question of how much juice is remaining in my battery?" Tags="|battery|software|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1524" PostTypeId="2" ParentId="1521" CreationDate="2014-05-13T19:17:14.493" Score="3" Body="&lt;p&gt;The arduino output pin cannot provide enough current to drive the pump. The DC-DC converter is not designed for this use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need external power supply with enough current to drive the motor that you switch on and off with the arduino output pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search for &quot;Arduino 3V DC motor control&quot; for examples of how to do this, there are many options.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-05-13T19:17:14.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1525" PostTypeId="2" ParentId="1523" CreationDate="2014-05-13T20:22:18.083" Score="1" Body="&lt;p&gt;Use a low-leakage op amp to divide the battery voltage by 8 (A&lt;sub&gt;V&lt;/sub&gt; of 1/8). Connect the output to an analog input. Set your reference to the internal 1.1V reference (&lt;a href=&quot;http://arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;INTERNAL&lt;/code&gt;&lt;/a&gt;). Perform analog reads. Full battery will be about 975 ((8.4V/8)/1.1V⋅1024 ~= 977.45455). Empty will be about 700 ((6.0V/8)/1.1V⋅1024 ~= 698.18182). Note that the voltage scaling for Li-ion cells is non-linear; see the datasheet for the cells for the appropriate scaling (and if you want more precise full and empty values).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-13T20:22:18.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1528" PostTypeId="2" ParentId="1523" CreationDate="2014-05-14T04:31:03.400" Score="0" Body="&lt;p&gt;If you are using a single cell, then the &lt;a href=&quot;https://www.sparkfun.com/products/10617&quot; rel=&quot;nofollow&quot;&gt;Fuel gauge&lt;/a&gt; from Sparkfun would be great. Instead of reading analog values manually it sends the battery level via I2C.&lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2014-05-14T04:31:03.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1530" PostTypeId="1" AcceptedAnswerId="1531" CreationDate="2014-05-14T07:32:24.333" Score="3" ViewCount="1850" Body="&lt;p&gt;I try to build a function generator (preferably a sine) with an &lt;a href=&quot;http://www.auctoris.co.uk/2011/05/25/arduino-function-generator-part-2/&quot; rel=&quot;nofollow&quot;&gt;R-2R ladder&lt;/a&gt; and a &lt;a href=&quot;https://www.indiegogo.com/projects/9-arduino-compatible-starter-kit-anyone-can-learn-electronics&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo by Borderless Electronics&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For performance reasons one should use &lt;code&gt;portd&lt;/code&gt; instead of &lt;code&gt;digitalWrite&lt;/code&gt;.&#xA;However the signal is not at all what I want (just noise). So upon further investigation I found that the digital pins were never on &lt;code&gt;HIGH&lt;/code&gt;. Pin 6 worked flawlessly. Furthermore I have tested the two failing pins with simple test programms and they behaved exactly as I would have expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; int sine[255];&#xA;&#xA; void setup() &#xA; { &#xA;     pinMode(0, OUTPUT); &#xA;     pinMode(1, OUTPUT); &#xA;     pinMode(2, OUTPUT); &#xA;     pinMode(3, OUTPUT); &#xA;     pinMode(4, OUTPUT); &#xA;     pinMode(5, OUTPUT); &#xA;     pinMode(6, OUTPUT);&#xA;     pinMode(7, OUTPUT); &#xA;&#xA;     float x; &#xA;     float y; &#xA;     for(int i=0;i&amp;lt;255;i++)&#xA;     {&#xA;          x=(float)i;&#xA;          y=sin((x/255)*2*PI);&#xA;          sine[i]=int(y*128)+128;&#xA;     }&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;     for (int i=0;i&amp;lt;255;i++) &#xA;     { &#xA;          PORTD=sine[i]; &#xA;          delayMicroseconds(10); &#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested this with two Arduinos of the exactly same type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Why are pins 5 and 7 never on &lt;code&gt;HIGH&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I have simplified everything down to one statement in the loop: &lt;code&gt;portd = x;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I vary x manually&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;expected&lt;/strong&gt; findings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x  -&gt;  #pin that is on high&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0  -&gt; None&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1  -&gt; 0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2  -&gt; 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4  -&gt; 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8  -&gt; 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;128 -&gt; 7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;actual&lt;/strong&gt; findings&lt;/p&gt;&#xA;&#xA;&lt;p&gt;x  -&gt;  #pin that is on high&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0  -&gt;  None&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1  -&gt;  3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2  -&gt;  2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4  -&gt;  0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8  -&gt;  1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;16 -&gt;  4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;32 -&gt;  None&lt;/p&gt;&#xA;&#xA;&lt;p&gt;64 -&gt;  None&lt;/p&gt;&#xA;&#xA;&lt;p&gt;128-&gt;  6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I test this by simply connecting an oscilloscope to the output pins. The behaviour is extremely strange since the pins seem to be in random order, some even missing to &lt;code&gt;portd&lt;/code&gt;. Furthermore &lt;code&gt;portd = B11111111&lt;/code&gt;, according to the manual, is equivalent to &lt;code&gt;portd = 255;&lt;/code&gt; and should set all pins on &lt;code&gt;HIGH&lt;/code&gt;. But in my case it sets every pin to &lt;code&gt;HIGH&lt;/code&gt;, except pins 5 and 7 are on &lt;code&gt;LOW&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1428" LastEditorUserId="1428" LastEditDate="2014-05-14T08:48:07.247" LastActivityDate="2014-05-14T16:40:13.863" Title="portd not writing on digital ports 5 and 7" Tags="|programming|pins|arduino-leonardo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1531" PostTypeId="2" ParentId="1530" CreationDate="2014-05-14T08:51:19.953" Score="4" Body="&lt;p&gt;This is because on ATmega 32u4, which is used in Arduino Leonardo,  pins 5 and 7 are not mapped to port D but to port C and E respectively, as you can see in the &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping32u4&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega 32u4 - Arduino Pin Mapping&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FHUON.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will have to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;either find another port where all 8 bits are available as digital outputs (note that I'm not sure one such port exists)&lt;/li&gt;&#xA;&lt;li&gt;or split each &lt;code&gt;sine[i]&lt;/code&gt; in 2 parts because you will have to work with 2 ports at the same time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-05-14T16:40:13.863" LastActivityDate="2014-05-14T16:40:13.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1533" PostTypeId="2" ParentId="1530" CreationDate="2014-05-14T10:47:37.447" Score="2" Body="&lt;p&gt;As @jfpoilpret points out, Arduino pins are not always mapped to port bits in a straightforward manner, and it’s crucial to understand the mapping for your particular model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, the Arduino Leonardo is designed in a way that &lt;strong&gt;none&lt;/strong&gt; of the ports has all 8 bits usable as I/O pins. As far as the microcontroller is concerned, ports B and D each have all 8 bits available, but the Arduino Leonardo/Micro design uses one bit on each port for a LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also recommend that if you’re using a PORTx register directly, instead of going through the Arduino API, that you also use the DDRx register to set pin directions, instead of trying to use &lt;code&gt;pinMode&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-05-14T10:47:37.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1534" PostTypeId="1" AcceptedAnswerId="1535" CreationDate="2014-05-14T10:58:06.223" Score="8" ViewCount="578" Body="&lt;p&gt;I have read the details on the products page for Arduino Yun but I have also read, on a Arduino forum, that there are only 18 digital pins because of Tx, and Rx. Is this true? I am not worried about the PWM, or analog capabilities of the pins, just purely digital.&lt;/p&gt;&#xA;" OwnerUserId="1432" LastActivityDate="2014-05-14T11:22:50.077" Title="How many total digital pin outs does the Arduino Yun have" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1535" PostTypeId="2" ParentId="1534" CreationDate="2014-05-14T11:22:50.077" Score="3" Body="&lt;p&gt;According to the official specification, it has 20 digital IO pins which can be used with &lt;code&gt;digitalRead()&lt;/code&gt; and &lt;code&gt;digitalWrite()&lt;/code&gt; etc.. As is typical on Arduino boards though, pins 0 and 1 &lt;em&gt;also&lt;/em&gt; act as serial Rx and Tx (respectively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can program it to use them for either purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The information you read might be referring to problems with uploading though. If you have something physically connected to pin 0 and/or 1, then you may have to disconnect it while you do an upload, otherwise it can interfere with the communication between your computer and the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're doing a lot of tinkering, then sometimes it's simply easier to avoid using pins 0 and 1 altogether, meaning you'd only have 18 IO pins left.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-14T11:22:50.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1536" PostTypeId="1" CreationDate="2014-05-14T15:05:15.967" Score="2" ViewCount="338" Body="&lt;p&gt;I plan to use the &lt;a href=&quot;https://www.sparkfun.com/products/241&quot; rel=&quot;nofollow&quot;&gt;SEN-00241&lt;/a&gt; IR Emitter and Detector pair to detect a ping pong ball moving fast between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand I could watch for voltage changes to detect this passing object, however how do people generally deal with ambient light changes? From my research it seems that the voltage will change with ambient light, and although I can take steps to create funnel vision between the 2 I'm sure it may still be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would you take constant readings and find averages over 10 consecutive readings to allow for changes in ambient light and set a new baseline reading? Then if the voltage changes dramatically and only for a few reads then I know that was the ball and not to change the baseline reading.&lt;/p&gt;&#xA;" OwnerUserId="1436" LastActivityDate="2014-06-13T16:08:21.890" Title="Detecting ball moving between IR pair and handling ambient light changes" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1537" PostTypeId="2" ParentId="1536" CreationDate="2014-05-14T15:39:51.323" Score="1" Body="&lt;p&gt;this is the same problem that IR remote/television has; how can TV they tell if that high voltage is a direct light or a logic 1 sent by remote? Simply because remote does not send a &quot;HIGH&quot; signal, but a modulated one, tipically at 36KHz. This mean a logic &quot;HIGH&quot; is a train of &quot;HIGH-LOW&quot; at 36KHz (you can see it as PWM at 50%duty cicle and 36KHz frequency)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ambient light des not have fast variation, and inside light are at 50-60Hz, so they will be &quot;filtered&quot; out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, until you see high voltage change at 36KHz, you have your beam fine, if it is not the case, then look at voltage: if fixed at normally low voltage, beam is broken; is fixed at normally high voltage then some light stronger than your emitter is &quot;blinding&quot; the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note that because 36KHz is a very use frequency on Remote, there a a lot of chip that will emit or read a modulated IR, but expose a normal digital input/output, but still can be done by software, expecially if hardware assistet (like PWM for output), interrupt for input&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-05-14T15:39:51.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1538" PostTypeId="1" CreationDate="2014-05-07T01:34:40.193" Score="0" ViewCount="1352" Body="&lt;p&gt;Hi, I am a pretty novice coder and I am getting this error consistently with a library I have installed. Here is the code I am trying to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SonarSRF02.h&amp;gt;&#xA;#include &amp;lt;SonarSRF08.h&amp;gt;&#xA;&#xA;#define leftAddress ( 0xF2 &amp;gt;&amp;gt; 1)&#xA;#define rightAddress ( 0xE0 &amp;gt;&amp;gt; 1)&#xA;#define mainAddress ( 0xF8 &amp;gt;&amp;gt; 1)&#xA;SonarSRF02 LeftSonar;&#xA;SonarSRF02 RightSonar;&#xA;SonarSRF08 MainSonar;&#xA;&#xA;char unit = 'c'; // 'i' for inches, 'c' for centimeters, 'm' for micro-seconds&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;&#xA;    LeftSonar.connect(leftAddress);&#xA;    Serial.println(&quot;Left SRF02 US-Sensor &quot;);&#xA;    Serial.println(LeftSonar.getSoft());&#xA;&#xA;    RightSonar.connect(rightAddress);&#xA;    Serial.println(&quot;Right SRF02 US-Sensor &quot;);&#xA;    Serial.println(RightSonar.getSoft());&#xA;&#xA;    MainSonar.connect(mainAddress);&#xA;    Serial.println(&quot;Main SRF08 US-Sensor &quot;);&#xA;    Serial.println(MainSonar.getSoft());&#xA;}&#xA;&#xA;void loop() {&#xA;    float sensorReading = 0;&#xA;&#xA;    sensorReading = LeftSonar.getRange(unit);&#xA;    // print out distance&#xA;    Serial.print(&quot;Distance from left: &quot;);&#xA;    Serial.print(sensorReading);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(unit);&#xA;    Serial.println();&#xA;&#xA;    sensorReading = RightSonar.getRange(unit);&#xA;    // print out distance&#xA;    Serial.print(&quot;Distance from right: &quot;);&#xA;    Serial.print(sensorReading);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(unit);&#xA;    Serial.println();&#xA;&#xA;    sensorReading = MainSonar.getRange(unit);&#xA;    // print out distance&#xA;    Serial.print(&quot;Distance from main: &quot;);&#xA;    Serial.print(sensorReading);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(unit);&#xA;    Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My project is using an SRF08 sensor with an Arduino Mega 2560&lt;/p&gt;&#xA;" OwnerDisplayName="user3610362" LastEditorUserId="729" LastEditDate="2014-05-26T14:44:11.803" LastActivityDate="2014-05-31T15:53:34.910" Title="error: no '' member function declared in class 'SonarSRF08'" Tags="|arduino-mega|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1539" PostTypeId="1" CreationDate="2014-05-08T14:33:36.647" Score="2" ViewCount="126" Body="&lt;p&gt;I'm having trouble with using parallel shift registers, I've studied example codes and I've come up with this function to set the pins to on or off. The problem is the first time the function runs all the output pins are set to HIGH regardless of the values in the array. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void updateRegister(int ClockPin,int DataPin,int LatchPin){&#xA;      int pinState;//Holds the state of the data pin&#xA;      pinMode(ClockPin, OUTPUT);//Sets the pinmode of the pins&#xA;      pinMode(DataPin, OUTPUT);//Sets the pinmode of the pins&#xA;      pinMode(LatchPin, OUTPUT);&#xA;      digitalWrite(LatchPin, 0);//Turns latch off to prevent bleedover while shifting&#xA;&#xA;      digitalWrite(DataPin, 0);//clear everything&#xA;      digitalWrite(ClockPin, 0);//clear everything&#xA;&#xA;      for (int i=1; i&amp;lt;=16; i++){//Repeats 16 times with i increment from 1 to 16&#xA;          if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH&#xA;          else{pinState= 1;}//If it equals false set it to 0, LOW&#xA;&#xA;          digitalWrite(DataPin, pinState);//Sets the data pin depening on the pinstate&#xA;          digitalWrite(ClockPin, 1);&#xA;          digitalWrite(DataPin, 0);&#xA;          digitalWrite(ClockPin, 0);&#xA;        }&#xA;      digitalWrite(LatchPin, 1);//Turns latch pin back on&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm storing the boolean values of the each pin in an array called Qout which is defined and all set to false like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    boolean Qout [17];//Holds the state for each pin&#xA;    for (int i = 1; i &amp;lt; 17; i++ ) {Qout[i]=false;}//Sets all output to off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I should start at Qout[0] but it just makes it way more confusing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me fix my function so that it actually works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I based it on &lt;a href=&quot;http://arduino.cc/en/Tutorial/ShftOut23&quot; rel=&quot;nofollow&quot;&gt;ShftOut23&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="StevenBrown" LastEditorUserId="5131" LastEditDate="2014-12-15T21:36:53.937" LastActivityDate="2014-12-15T21:36:53.937" Title="Parallel shift registers" Tags="|shift-register|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1540" PostTypeId="2" ParentId="1539" CreationDate="2014-05-14T16:50:52.180" Score="4" Body="&lt;p&gt;First of all, fix the following part of your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Qout[i]){pinState= 1;}//Checks the array for the value and if it is true sets the pinstate to 1, HIGH&#xA;else{pinState= 1;}//If it equals false set it to 0, LOW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Qout[i])&#xA;{&#xA;    //Checks the array for the value and if it is true sets the pinstate to 1, HIGH&#xA;    pinState = 1;&#xA;}&#xA;else&#xA;{&#xA;    //If it equals false set it to 0, LOW&#xA;    pinState = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, if you always set &lt;code&gt;pinState&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt;, it won't work as you expect :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you should rather use &lt;code&gt;HIGH&lt;/code&gt; and &lt;code&gt;LOW&lt;/code&gt; constants (more readable) instead of &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you could make the code much simpler this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinState = (Qout[i] ? HIGH : LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-05-14T17:34:53.383" LastActivityDate="2014-05-14T17:34:53.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1541" PostTypeId="1" AcceptedAnswerId="1554" CreationDate="2014-05-15T03:02:07.257" Score="4" ViewCount="3404" Body="&lt;p&gt;I was wondering if this can be done. I got a Nokia 106 and am trying to make it talk, but the audio jack doesn't seem to cooperate and the Fbus pins are right under the SIM slot, which is right under the battery. Any advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added: It seems that it talks AT commands, since it is a GSM model, but I'm not 100% positive.&lt;/p&gt;&#xA;" OwnerUserId="1441" LastEditorUserId="1441" LastEditDate="2014-05-15T20:40:21.327" LastActivityDate="2015-01-30T17:08:14.390" Title="Connecting Nokia 106 to Arduino" Tags="|serial|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1542" PostTypeId="1" AcceptedAnswerId="1551" CreationDate="2014-05-15T11:53:28.683" Score="2" ViewCount="981" Body="&lt;p&gt;I saw the &lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMExamplesWebClient&quot; rel=&quot;nofollow&quot;&gt;Web client Example &lt;/a&gt; , In the example, the server connection is initialized in &lt;code&gt;setup()&lt;/code&gt;. But I want the server to update the text file every time. So, I need the server connection to be in &lt;code&gt;loop()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, it is not working. Where is the problem in my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// APN data&#xA;#define GPRS_APN       &quot;GPRS_APN&quot; // replace your GPRS APN&#xA;#define GPRS_LOGIN     &quot;login&quot;    // replace with your GPRS login&#xA;#define GPRS_PASSWORD  &quot;password&quot; // replace with your GPRS password&#xA;&#xA;// initialize the library instance&#xA;GSMClient client;&#xA;GPRS gprs;&#xA;GSM gsmAccess; &#xA;&#xA;// URL, path &amp;amp; port (for example: arduino.cc)&#xA;char server[] = &quot;yourdomain.com&quot;;&#xA;char path[] = &quot;/current.txt&quot;;&#xA;&#xA;int port = 80; // port 80 is the default for HTTP&#xA;&#xA;void setup() {&#xA;// initialize serial communications and wait for port to open:&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;SMS connected&quot;);&#xA;&#xA;// connection state&#xA;boolean notConnected = true;&#xA;&#xA;// After starting the modem with GSM.begin()&#xA;// attach the shield to the GPRS network with the APN, login and password&#xA;while(notConnected) {&#xA;   if((gsmAccess.begin(PINNUMBER)==GSM_READY) &amp;amp;&#xA;    (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))&#xA;    notConnected = false;&#xA;&#xA;else {&#xA;     Serial.println(&quot;Not connected&quot;);&#xA;     delay(1000);&#xA;    }&#xA;   }&#xA;Serial.println(&quot;GPRS connected...&quot;);&#xA;Serial.println(&quot; Connecting to Server &quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;if (client.connect(server, port)) {&#xA;  client.print(&quot;GET /current.txt&quot;);&#xA;  Serial.print(&quot;GET /current.txt&quot;);&#xA;  client.println(&quot; HTTP/1.1&quot;);&#xA;  Serial.println(&quot; HTTP/1.1&quot;);&#xA;  client.println(&quot;Host: www.yourdomain.com&quot;);&#xA;  Serial.println(&quot;Host: www.yourdomain.com&quot;);&#xA;  client.println(&quot;User-Agent: Arduino&quot;);&#xA;  Serial.println(&quot;User-Agent: Arduino&quot;);&#xA;  client.println(&quot;Accept: text/html&quot;);&#xA;  Serial.println(&quot;Accept: text/html&quot;);&#xA;  client.println(&quot;Connection: close&quot;);&#xA;  Serial.println(&quot;Connection: close&quot;);&#xA;  client.println();&#xA;  Serial.println();&#xA;  Serial.println(&quot;\nCOMPLETE!\n&quot;);&#xA;  //client.stop();&#xA;&#xA;} else {&#xA;  Serial.println(&quot;connection failed&quot;);&#xA;  Serial.println(&quot;\n FAILED!\n&quot;);&#xA;}&#xA;&#xA;if (client.available()) {&#xA;  char c = client.read();&#xA;  Serial.print(c);&#xA;&#xA;} else {&#xA;  Serial.println();&#xA;  Serial.println(&quot;disconnecting.&quot;);&#xA;  client.stop();&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastEditorUserId="46" LastEditDate="2014-05-15T13:41:43.860" LastActivityDate="2014-05-15T17:25:55.387" Title="Unable to read text file from server" Tags="|arduino-uno|gsm|web-server|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1543" PostTypeId="1" AcceptedAnswerId="1544" CreationDate="2014-05-15T12:54:20.937" Score="5" ViewCount="622" Body="&lt;p&gt;I'd like to send a prototype board to a friend pre-programmed and wired. Ideally they should just need to plug in the USB and connect to it over a serial COM port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With another laptop I used for testing I had to install the full dev kit, sketch editor and all to get it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I somehow send just the portion of the kit that provides the COM drivers and not the rest? Is there a prebuilt install for just that portion?&lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2014-05-15T19:17:31.507" Title="Can a PC connect to an Arduino for serial communication without installing the entire dev kit?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1544" PostTypeId="2" ParentId="1543" CreationDate="2014-05-15T12:57:43.340" Score="7" Body="&lt;p&gt;On Windows in &lt;code&gt;C:\Program Files\Arduino&lt;/code&gt; there is a folder called &lt;code&gt;drivers&lt;/code&gt;, which contains all the drivers for the Arduino boards. I think that's what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-05-15T19:17:31.507" LastActivityDate="2014-05-15T19:17:31.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1546" PostTypeId="1" CreationDate="2014-05-12T03:16:38.450" Score="0" ViewCount="1638" Body="&lt;p&gt;So I built my First LED Cube and the thing turns ON!!! Pretty happy about that but here is my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try and get the Cube to display say a basic &quot;outline&quot; (a wire form of a cube only the outer most LEDs are on)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shift registers, that I have daisy chained together, give the correct display 80% of the time, but the other 20% give completely wrong LEDs lighting up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used 4 74HC595 shift registers linked together so I am only using 3 of my Arduino ports to control the 5*5*5 Cube.&#xA;The basic shape is there but the ones that are not meant to be lighting up cause a lot of flickering (or &lt;em&gt;ghosting&lt;/em&gt;?) in the center of the cube.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have thought about using pull up or pull down resistors but I find that, when I run my program at a slower rate, the LEDs that are lighting wrongly are lighting up controlled so I think it has to be something with my code or setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone got any experience with LED cubes doing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I am only using the output enable and disable to make use the wrong this is not displayed when I am shifting the data out, should I be using the clear?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last thing, does anyone have recommendations for the delay time to let each layer shine for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int clockPin = 8;&#xA;int dataPin = 7;&#xA;int set = 6;&#xA;&#xA;void setup() &#xA;{&#xA;  //set pins to output so you can control the shift register&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;  pinMode(set,OUTPUT);     &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;      digitalWrite(set,HIGH); // DISABLES OUTPUT&#xA;  // level 1 ( top )&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00000011);//from left 3rd to the 7th = levels 5-1,, The right first LED&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B11111000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B11000110);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00111111);// Makes the &quot; wire cube &quot;&#xA;      digitalWrite(set,LOW);  // enables output&#xA;      delay(2);&#xA;&#xA;       digitalWrite(set,HIGH); // DISABLES OUTPUT&#xA; // level 2&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00000101);//from left 3rd to the 7th = levels 5-1,, The right first LED&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the &quot; wire cube &quot;&#xA;      digitalWrite(set,LOW);  // enables output &#xA;      delay(2);&#xA;&#xA;      digitalWrite(set,HIGH); // DISABLES OUTPUT     &#xA; // level 3&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00001001);//from left 3rd to the 7th = levels 5-1,, The right first LED&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the &quot; wire cube &quot;&#xA;      digitalWrite(set,LOW);   // enables output&#xA;      delay(2);&#xA;&#xA;      digitalWrite(set,HIGH); // DISABLES OUTPUT &#xA; // level 4&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);//from left 3rd to the 7th = levels 5-1,, The right first LED&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the &quot; wire cube &quot;&#xA;      digitalWrite(set,LOW);   // enables output&#xA;      delay(2);&#xA;&#xA;      digitalWrite(set,HIGH); // DISABLES OUTPUT &#xA; // level 5 ( bottom )&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00100001);//from left 3rd to the 7th = levels 5-1,, The right first LED&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B11111000);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B11000110);// Makes the &quot; wire cube &quot;&#xA;      shiftOut(dataPin, clockPin, MSBFIRST, B00111111);// Makes the &quot; wire cube &quot;&#xA;      digitalWrite(set,LOW);   // enables output&#xA;      delay(2);        &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;" OwnerDisplayName="Spider999" LastEditorUserId="6936" LastEditDate="2015-02-11T21:05:48.000" LastActivityDate="2022-01-23T14:12:39.700" Title="LED Cube lighting wrong LEDs randomly" Tags="|led|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1547" PostTypeId="1" CreationDate="2014-05-13T15:25:56.590" Score="4" ViewCount="1790" Body="&lt;p&gt;I have an issue with debouncing.&#xA;I am using a MCP23017 as an I/O-extender with an Arduino. This uses I2C to communicate with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A variable amount of switches is connected to the MCP23017 (0-16 switches). On change of the inputs, an interrupt is generated and the Arduino captures this on rising edge. So whenever a button is pushed or released, an interrupt is generated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm confused as how I should debug them. One option would be to set a delay after an interrupt (of let's say 50 ms), before turning the interrupts back on. This could have an issue however, since multiple inputs are connected to the same interrupt line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to have a timestamp or something for the last time each switch was changed, and check if the time difference is big enough, otherwise ignore the next pulse. The problem with this is that it uses quit some resources as I have limited memory and there can be up to 8 extenders (so 8 * 16 = 128 inputs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the most efficient way to handle these interrupts with debouncing?&lt;/p&gt;&#xA;" OwnerUserId="1258" OwnerDisplayName="arbitter" LastActivityDate="2014-05-15T15:37:01.893" Title="Arduino Interrupt Debouncing" Tags="|c|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1548" PostTypeId="2" ParentId="1547" CreationDate="2014-05-13T15:31:10.397" Score="2" Body="&lt;p&gt;Add &lt;a href=&quot;http://www.labbookpages.co.uk/electronics/debounce.html&quot; rel=&quot;nofollow&quot;&gt;debouncing circuitry&lt;/a&gt; if you can; it's not that difficult.&lt;/p&gt;&#xA;" OwnerDisplayName="meaning-matters" LastActivityDate="2014-05-13T15:32:01.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1549" PostTypeId="2" ParentId="1547" CreationDate="2014-05-13T16:27:00.403" Score="2" Body="&lt;p&gt;Depends on the application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define efficiency. What are you looking to optimize for? Manhours spend coding/testing, processor speed, response time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are theses keys to a piano synth? Yes you'll want interrupt speed, and each key needs to not affect the surrounding keys. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it going to be rare that two keys are pressed anywhere near each other? a timeout for the ISR is perfectly legitimate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will the user not observe any lag when he flips a switch and resources are tight? Then polling could be a viable option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the EMI concerns and you need to filter out false positives? Well you're going to need do some more. Like sampling for sustained values or counting how long until the falling edge occurs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are so many options depending on what you want it to do. &lt;/p&gt;&#xA;" OwnerDisplayName="Philip" LastActivityDate="2014-05-13T16:27:00.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1550" PostTypeId="1" AcceptedAnswerId="1552" CreationDate="2014-05-15T17:20:35.320" Score="6" ViewCount="461" Body="&lt;p&gt;Could someone point me to the documentation that describes the gold dot and surrounding gold circle on the front of my arduino mega v2 board. It is right above the ICSP header and reset button, and directly underneath the letter 'U' in the silk screened word 'communication'&#xA;I've not been able to find any reference to it anywhere. Is is a jumper, a test pad, RF pad??? &lt;/p&gt;&#xA;" OwnerUserId="1445" LastActivityDate="2016-02-21T08:18:23.720" Title="What is the circular gold pad on arduino mega 2560 v2 and above?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1551" PostTypeId="2" ParentId="1542" CreationDate="2014-05-15T17:25:55.387" Score="0" Body="&lt;p&gt;Its working as long as the connection doesn't break or the server doesn't stall. We must wait till the response .  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (client.connected()) &#xA;{   &#xA; while(client.available()) &#xA; {    &#xA; char ch = client.read();&#xA; Serial.print(ch);   &#xA; }&#xA;} &#xA; client.stop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2014-05-15T17:25:55.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1552" PostTypeId="2" ParentId="1550" CreationDate="2014-05-15T18:06:50.287" Score="9" Body="&lt;p&gt;That is most likely a Fiducial Mark for the vision system of a pick-and-place assembly robot to key off of in order to more precisely place the components on their pads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look carefully, you will see a second one located below the DC barrel jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Boards like this are manufactured in a gridded panel having a number of copies in each direction, and only cut apart after they are largely complete.  With such a large workpiece, any linearity error in the manufacturing could result in a high-density component being misplaced far enough to cause problems.  Having a pair of fiducials on each individual board in the panel can help calibrate out errors not only which might otherwise accumulate over the large dimensions of the entire panel, but also rotational skew of the panel in its holder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DnA73.jpg&quot; alt=&quot;Picture of the Arduino 2560 from arduino.cc site&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see both on this picture of the Arduino Mega 2560 from the arduino.cc site&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-16T01:09:18.027" LastActivityDate="2014-05-16T01:09:18.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1553" PostTypeId="1" CreationDate="2014-05-15T19:11:16.410" Score="2" ViewCount="238" Body="&lt;p&gt;I have an Osepp Mega 2560 (Arduino Compatible) which I'm trying to use to run a RC Car from the remote control.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AojTG.jpg&quot; alt=&quot;http://dwkd.wordpress.com/2014/05/15/arduino-project/&quot;&gt;    &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can someone please explain how do I need to connect the pins from Osepp to the remote board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The setup&lt;/strong&gt; (please look at image for bolded details):&lt;br&gt;&lt;br&gt;&#xA; - Osepp 5v Power pin going to the &lt;b&gt;Positive&lt;/b&gt; (see red wire)&lt;br&gt;&#xA; - Osepp GND pin going to the &lt;b&gt;Negative&lt;/b&gt; (Black wire)&lt;br&gt;&#xA; - Osepp Pin 13 (pwm) going to the &lt;b&gt;signal to drive forward&lt;/b&gt; (bottom of the board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);&#xA;  digitalWrite(led, LOW); &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(led, LOW);   &#xA;  delay(10000);               &#xA;  digitalWrite(led, HIGH);    &#xA;  delay(10000);              &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;The Problem&lt;/b&gt;&lt;br&gt;&#xA;I expect that after 10 seconds the remote will start sending a signal to move forward.&lt;br&gt;&#xA;In actuality the signal gets sent right away, even though the pin is set to LOW.&#xA;&lt;br&gt;The &quot;&lt;b&gt;signal to drive forward&lt;/b&gt;&quot; spot where I soldered a wire from pin 13 is where power gets sent once you press down the joystick (also highlighted in the pic) and complete the circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;&#xA;&lt;br&gt;&#xA;FYI&lt;/b&gt;&lt;br&gt;&#xA;I am not trying to do any modulation, pin 13 may have been a poor choice.&lt;br&gt;&#xA;I do not have any kits nor manuals, just winging it&lt;br&gt;&#xA;The joystick for the forward action is actually suppose to be top left(missing in this case but you can see the circuit) and not the one highlighted in the picture&lt;/p&gt;&#xA;" OwnerUserId="1449" LastEditorUserId="1449" LastEditDate="2014-05-16T18:12:34.943" LastActivityDate="2014-05-16T18:12:34.943" Title="Arduino controlled remote for an rc car. What am I doing wrong?" Tags="|remote-control|electronics|" AnswerCount="0" CommentCount="14" ClosedDate="2016-02-04T20:16:46.740" ContentLicense="CC BY-SA 3.0" />
  <row Id="1554" PostTypeId="2" ParentId="1541" CreationDate="2014-05-15T22:38:48.977" Score="2" Body="&lt;p&gt;Here's the picture of the Nokia FBUS connector from your link:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/mPvXc.png&quot; alt=&quot;enter image description here&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here's a (slightly dubious) method of connection from some random web page&#xA;&lt;img src=&quot;https://i.stack.imgur.com/2l8Jh.png&quot; alt=&quot;enter image description here&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;which goes on to say&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The F-bus protocol uses 115,200bps so we can easily use the Arduino’s serial function to communication with the phone. All you need to is hook up the phones TX to the Arduino’s RX and then use a resistor divider (I choose 330 ohm resistors) to connect the Arduino’s TX to the phones RX as shown above.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That page goes on to show how to use an Arduino to get the phone to send SMS text messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.insidegadgets.com/2013/01/12/how-to-use-nokia-f-bus-to-send-an-sms-message/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.insidegadgets.com/2013/01/12/how-to-use-nokia-f-bus-to-send-an-sms-message/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.gsmhosting.com/vbb/f148/nokia-105-new-100-working-solution-1731398/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.gsmhosting.com/vbb/f148/nokia-105-new-100-working-solution-1731398/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="316" LastActivityDate="2014-05-15T22:38:48.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1555" PostTypeId="1" CreationDate="2014-05-16T13:54:15.577" Score="3" ViewCount="234" Body="&lt;p&gt;I would like to have an array of eight 7- and &lt;a href=&quot;http://4.bp.blogspot.com/-d4ug4mb_Cw0/T6y7ZVrbb-I/AAAAAAAAAsE/nj6Tfp0j26s/s400/SEV1.jpg&quot; rel=&quot;nofollow&quot;&gt;8-segment LED&lt;/a&gt; numerical displays on my Adafruit Trinket.&#xA;I know that there are some prebuilt arrays of 4 LED's. So 2 in array would do just fine.&#xA;However, my Adafruit Trinket doesn't have enough ports for that. I have heard something about connecting it to a small piece of controlling hardware that makes me able to have way less ports in need.&#xA;What is the appropriate way of connecting a lot of those LED's on only a few ports on a micro controller?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ideal output would be as follow: &#xA;88 88:88:88 or maybe 88 88.88.88&#xA;So ideally there would be a small space between the first group of 2 digits and the rest.&#xA;Basically, the last 6 digits will represent a time in minutes, seconds and hundreds of seconds.&lt;/p&gt;&#xA;" OwnerUserId="1100" LastActivityDate="2014-05-16T21:01:42.310" Title="8-segmet LED's on Adafruit Trinket" Tags="|led|display|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1556" PostTypeId="1" AcceptedAnswerId="1566" CreationDate="2014-05-16T18:39:28.903" Score="3" ViewCount="1026" Body="&lt;p&gt;I am trying to use interrupts to play notes on a speaker.  Timer2 works fine, but after about 15 seconds, Timer1 stops firing for about 5 seconds, and then it comes back on.  If I keep running the sketch, it will stop and resume every now and then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SPEAKER1 8&#xA;#define SPEAKER2 7&#xA;volatile bool swap1;&#xA;volatile bool swap2;&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;    digitalWrite(SPEAKER1, swap1);&#xA;    swap1 = !swap1;&#xA;}&#xA;&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;    digitalWrite(SPEAKER2, swap2);&#xA;    swap2 = !swap2;&#xA;}&#xA;&#xA;void playNote1(unsigned note) { //Play a note on Timer1.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitSet(TCCR1B, CS10);&#xA;    bitSet(TCCR1B, CS12);&#xA;    unsigned ticks = (16000000 / 1024) / (note);&#xA;    ticks /= 2;&#xA;    OCR1A = (ticks &amp;lt;= 65535 ? ticks : 65535);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;void playNote2(unsigned note) { //Play a note on Timer2.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitSet(TCCR2B, CS20);&#xA;    bitSet(TCCR2B, CS21);&#xA;    bitSet(TCCR2B, CS22);&#xA;    unsigned ticks = (16000000 / 1024) / (note);&#xA;    ticks /= 2;&#xA;    OCR2A = (ticks &amp;lt;= 255 ? ticks : 255);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;void stopNote1() {  //Stop playing a note on Timer1.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitClear(TCCR1B, CS10);&#xA;    bitClear(TCCR1B, CS12);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;void stopNote2() {  //Stop playing a note on Timer2.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitClear(TCCR2B, CS20);&#xA;    bitClear(TCCR2B, CS21);&#xA;    bitClear(TCCR2B, CS22);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;    pinMode(SPEAKER1, OUTPUT);&#xA;    pinMode(SPEAKER2, OUTPUT);&#xA;    pinMode(13, OUTPUT);&#xA;    // initialize timers&#xA;    cli();          // disable global interrupts&#xA;    TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;    // turn on CTC mode:&#xA;    bitSet(TCCR1B, WGM12);&#xA;    bitSet(TIMSK1, OCIE1A);&#xA;&#xA;    TCCR2A = 0;     // set entire TCCR2A register to 0&#xA;    TCCR2B = 0;     // same for TCCR2B&#xA;    // turn on CTC mode:&#xA;    bitSet(TCCR2A, WGM21);&#xA;    bitSet(TIMSK2, OCIE2A);&#xA;    sei();          // enable global interrupts&#xA;}&#xA;&#xA;void loop() {&#xA;    playNote1(523);&#xA;    delay(1000);&#xA;    stopNote1();&#xA;    delay(500);&#xA;    playNote1(131);&#xA;    delay(2000);&#xA;    stopNote1();&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1447" LastActivityDate="2014-05-17T09:40:24.623" Title="Timer1 stops firing" Tags="|arduino-uno|programming|timers|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1557" PostTypeId="2" ParentId="1555" CreationDate="2014-05-16T21:01:42.310" Score="2" Body="&lt;p&gt;For LED displays, I advise using a &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf&quot; rel=&quot;nofollow&quot;&gt;MAX7219&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;can manage up to 8 digits (7-segments + 1 LED for DP or colon separator) or up to 64 LEDs&lt;/li&gt;&#xA;&lt;li&gt;needs only 3 pins to manage display&lt;/li&gt;&#xA;&lt;li&gt;can be daisy-chained if you need to interface with more than 64 LEDs&lt;/li&gt;&#xA;&lt;li&gt;requires only 1 resistor to be fully functional&lt;/li&gt;&#xA;&lt;li&gt;is easily supported on Arduino with &lt;a href=&quot;http://playground.arduino.cc/uploads/Main/LedControl.zip&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have used it in several circuits and happy with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there also &lt;a href=&quot;http://playground.arduino.cc/Main/LEDMatrix&quot; rel=&quot;nofollow&quot;&gt;other libraries&lt;/a&gt; that support this circuit but I haven't used them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit has only one downside: its price (about $10 each); but the price is counter-balanced by its simplicity and the fact you don't need any additional component (e.g. transistors) besides a simple resistor.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-16T21:01:42.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1558" PostTypeId="1" CreationDate="2014-05-16T20:13:59.750" Score="3" ViewCount="2362" Body="&lt;p&gt;I currently have a servo wired to my Arduino and have imported the Servo.h.  Here is my sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo s1;&#xA;Servo s2;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  s1.attach(8);&#xA;  s2.attach(9);&#xA;}&#xA;int pos = 0;&#xA;void loop()&#xA;{&#xA;  pos = 0;&#xA;  if(s1.read() != pos)&#xA;    s1.write(pos);&#xA;  if(s2.read() != pos)&#xA;    s2.write(pos);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that even when my servos are at the position 0 it still tries to turn and I hear it trying.  What do I have to do to tell it to stop turning once it is already at the desired position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is my second bit of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s1.write(0);&#xA;  delay(5000);&#xA;  s1.write(100);&#xA;  delay(5000);&#xA;  s1.write(180);&#xA;  delay(5000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I write them to 100/180 (or any number) they are silent after the turn, but when I write them to 0 I hear them keep trying to turn...&lt;/p&gt;&#xA;" OwnerUserId="1535" OwnerDisplayName="Jister13" LastActivityDate="2015-04-13T10:55:07.793" Title="Servo Keeps Trying to Turn" Tags="|servo|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1559" PostTypeId="1" CreationDate="2014-05-16T22:52:20.187" Score="6" ViewCount="621" Body="&lt;p&gt;I have come across some Andruino Sensors like Motion, Light and all recommend to be connected to pin 2 or 3 on Andruino Uno board which are interrupt pins. This is especially true if you are looking for HIGH or LOW values. Why is that to be connected to interrupt pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example would be is I used CC3000 Wifi Breakout and Motion sensor. Both were in fight to occupy the interrupt pin 2. I have seen the Motion sesnor not working correctly after getting it's signal hooked to Pin 4[It has pull up resistor enabled]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do if i need to hook up more sensor which uses the limited interrupt pins and how should i handle the above scenario?&lt;/p&gt;&#xA;" OwnerUserId="1465" LastActivityDate="2014-08-02T15:57:25.863" Title="Why is that any sensor signal need to be hooked up to the interrupt pins on Andruino boards?" Tags="|sensors|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1560" PostTypeId="2" ParentId="1559" CreationDate="2014-05-16T23:39:22.793" Score="6" Body="&lt;p&gt;The interrupt pins are used to notify the MCU that a device needs attention. The INTx pins are chosen first because they are easy to program for; each gets a dedicated interrupt vector and hence ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another type of external interrupt though, the Pin Change interrupt. This can be invoked via any of the PCINTxx pins on the device; on the '328 &lt;em&gt;any&lt;/em&gt; pin can act as an interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main difference between INT and PCINT is that PCINTs are grouped into banks of 8, which means that once the ISR has been invoked the appropriate pins need to be checked for their level, which furthermore means that it is possible to misread an interrupt if a bank is shared by multiple devices and the interrupt pulse itself is very short.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further details can be read in the &quot;External Interrupts&quot; and &quot;Interrupts&quot; sections of the MCU datasheet.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-08-02T13:52:44.073" LastActivityDate="2014-08-02T13:52:44.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1561" PostTypeId="1" CreationDate="2014-05-17T01:39:34.690" Score="3" ViewCount="329" Body="&lt;p&gt;Problem: Have an LED strip do some animation (say it takes 15 seconds for that line of code to run) meanwhile, have a sensor (tried methods: PIR sensor and ultrasonic sensor) watching to see if an object passes by.  If it senses an object, stop the light animation and make the lights do something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issues: The PIR sensor takes too long to reset... I have the timing turned all the way to minimum and I am still able to count 12 seconds before it starts sensing motion again.  (Is there anyway to override this in the code?)  The other issue is the ultrasonic sensor, as far as I know, can't reliably run the first animation and watch for a change in distance then call an interrupt since an interrupt can only happen on FALLING, RISING, LOW, or CHANGE. This is an issue because the ultrasonic sensor is continuously sending LOW to HIGH then back to LOW for its pulses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OVERALL QUESTION: How can I effectively sense if an object passes by a sensor, run new LED animation then back to where it left off without having to wait 12 seconds every time.  Is there some other hardware I could try? Please help!?&lt;/p&gt;&#xA;" OwnerUserId="1468" LastActivityDate="2014-05-17T02:41:05.120" Title="Animated LED Strip &amp; Sensing an Object" Tags="|sensors|led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1562" PostTypeId="2" ParentId="1561" CreationDate="2014-05-17T02:41:05.120" Score="1" Body="&lt;p&gt;It seems as you are using the &lt;code&gt;delay();&lt;/code&gt; function for your code. The reason that it doesn't run anything is your Arduino does &lt;em&gt;nothing&lt;/em&gt; during the function. The easiest option IMHO is using &lt;code&gt;millis();&lt;/code&gt;. This will &quot;return&quot; a long datatype. Some example code (modified from example sketches in Arduino IDE):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; created 2005&#xA; by David A. Mellis&#xA; modified 8 Feb 2010&#xA; by Paul Stoffregen&#xA; modified 5/16/14 by Anno. Penguin&#xA; This example code is in the public domain.&#xA;*/&#xA;&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Sensor code&#xA;  unsigned long currentMillis = millis();&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, your code will be more complex than that. This one only blinks it, but you'll have to do some creative logic here. I don't know what the animation is, but most likely you'll need to add a few more variables (make sure to declare them outside &lt;code&gt;loop()&lt;/code&gt; so they aren't disposed of each iteration!).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-17T02:41:05.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1563" PostTypeId="1" AcceptedAnswerId="1564" CreationDate="2014-05-17T04:38:57.007" Score="3" ViewCount="837" Body="&lt;p&gt;I have a small circuit from a toy sword that has an LED and a small speaker. It was powered by a couple of small coin cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to figure out how to connect it to my Arduino so I can trigger it.&#xA;If I attached the circuit directly to the GND and +3.3V and press the switch in it I get the sound of a sword and flashing LED as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to somehow get the Arduino to trigger the circuit but am very new to Arduino and quite unsure of how to approach this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone advise how best to work with an existing low power circuit that can use the Arduino's power rails but needs the switch integrated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the noob question.&lt;/p&gt;&#xA;" OwnerUserId="1273" LastEditorUserId="1273" LastEditDate="2014-05-17T06:24:27.420" LastActivityDate="2014-05-17T06:24:27.420" Title="To connect a simple toy circuit and trigger with an arduino?" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1564" PostTypeId="2" ParentId="1563" CreationDate="2014-05-17T05:20:02.743" Score="1" Body="&lt;p&gt;You'll probably want to use a transistor to switch it on/off. You &lt;em&gt;could&lt;/em&gt; just use the Arduino's digital pin but they can only supply a limited amount of current. Transistors can work with larger currents. The Arduino switches the transistor and it powers the external circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of existing questions that may help you.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/508/how-to-switch-an-external-circuit-with-arduino&quot;&gt;How to switch an external circuit with Arduino?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/403/how-can-higher-current-devices-motors-solenoids-lights-etc-be-controlled-b&quot;&gt;How can higher current devices (motors, solenoids, lights, etc.) be controlled by an Arduino?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/a/509/11&quot;&gt;jippie's answer&lt;/a&gt; in the first link shows an example schematic for hooking up a transistor with a bunch of LEDs but you would replace them with your own circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8zae1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-05-17T05:20:02.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1566" PostTypeId="2" ParentId="1556" CreationDate="2014-05-17T09:40:24.623" Score="2" Body="&lt;p&gt;The problem you have is that &lt;strong&gt;you never reset Timer1 counter (&lt;code&gt;TCNT1&lt;/code&gt;) when you stop a note and then play another one&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, changing the clock divider selection to &quot;&lt;em&gt;no clock&lt;/em&gt;&quot; by clearing bits &lt;strong&gt;CS10&lt;/strong&gt; and &lt;strong&gt;CS12&lt;/strong&gt; as you do is not the most effective way to stop the timer; in fact, rather than stopping it, you can let it run but just &lt;strong&gt;disable its interrupts&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have modified your program and this worked correctly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SPEAKER1 8&#xA;volatile bool swap1;&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;    digitalWrite(SPEAKER1, swap1);&#xA;    swap1 = !swap1;&#xA;}&#xA;&#xA;void playNote1(unsigned note) { //Play a note on Timer1.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    unsigned ticks = (16000000 / 1024) / (note);&#xA;    ticks /= 2;&#xA;    OCR1A = (ticks &amp;lt;= 65535 ? ticks : 65535);&#xA;    TCNT1 = 0;&#xA;    bitSet(TIMSK1, OCIE1A);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;void stopNote1() {  //Stop playing a note on Timer1.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitClear(TIMSK1, OCIE1A);&#xA;    SREG = oldSREG;&#xA;}&#xA;&#xA;void setup() {&#xA;    pinMode(SPEAKER1, OUTPUT);&#xA;    pinMode(13, OUTPUT);&#xA;    // initialize timers&#xA;    cli();          // disable global interrupts&#xA;    TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;    TCCR1C = 0;     // same for TCCR1C&#xA;    // Set clock divider&#xA;    bitSet(TCCR1B, CS10);&#xA;    bitSet(TCCR1B, CS12);&#xA;    // turn on CTC mode:&#xA;    bitSet(TCCR1B, WGM12);&#xA;    bitClear(TIMSK1, OCIE1A);&#xA;    sei();          // enable global interrupts&#xA;}&#xA;&#xA;void loop() {&#xA;    playNote1(523);&#xA;    delay(1000);&#xA;    stopNote1();&#xA;    delay(500);&#xA;    playNote1(131);&#xA;    delay(2000);&#xA;    stopNote1();&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I have removed all code for Timer2 as it does not play any role in the initial problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important changes are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;setup()&lt;/code&gt; now performs Timer1 setup completely (CTC mode, clock divider); note that I also included &lt;strong&gt;TCCR1C&lt;/strong&gt; to ensure full setup (it is preferrable as Arduino libraries may have initialized it differently before &lt;code&gt;setup()&lt;/code&gt; is called); it also ensures Timer1 interrupts are initially disabled.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;playNote1&lt;/code&gt; now clears &lt;code&gt;TCNT1&lt;/code&gt; &lt;strong&gt;and then&lt;/strong&gt; enable Timer1 interrupt for &lt;code&gt;TIMER1_COMPA_vect&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;stopNote1()&lt;/code&gt; just disables Timer1 interrupt for &lt;code&gt;TIMER1_COMPA_vect&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To be complete, you would also want to limit &lt;strong&gt;useless consumption&lt;/strong&gt; on output &lt;strong&gt;pin 8&lt;/strong&gt;, thus stopping a note should also force its output level to &lt;code&gt;LOW&lt;/code&gt; (or &lt;code&gt;HIGH&lt;/code&gt; depending on your actual circuit behind, but &lt;code&gt;LOW&lt;/code&gt; is more likely):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void stopNote1() {  //Stop playing a note on Timer1.&#xA;    uint8_t oldSREG = SREG;&#xA;    cli();&#xA;    bitClear(TIMSK1, OCIE1A);&#xA;    swap1 = false;&#xA;    SREG = oldSREG;&#xA;    digitalWrite(SPEAKER1, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Now what about your code for Timer2, the code is the same, so why does it work?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Actually it doesn't :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you can't hear the difference between Timer2 is an 8-bit counter so if you don't reset it, then it won't take long until it reaches 255 and resets to 0, so only the first wave phase will be wrong but your hear won't notice that...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;strong&gt;you should also modify the code for Timer2&lt;/strong&gt; to make it correct.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-17T09:40:24.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1567" PostTypeId="1" CreationDate="2014-05-17T12:28:12.373" Score="1" ViewCount="41" Body="&lt;p&gt;I have been working on a project which deals with analysing data from sensors to matlab. How do i establish this communication. Please help me&lt;/p&gt;&#xA;" OwnerUserId="594" LastActivityDate="2014-05-17T12:28:12.373" Title="How to communicate arduino with Matlab" Tags="|arduino-uno|" AnswerCount="0" CommentCount="1" ClosedDate="2014-05-17T17:51:16.117" ContentLicense="CC BY-SA 3.0" />
  <row Id="1568" PostTypeId="2" ParentId="1559" CreationDate="2014-05-17T13:13:27.140" Score="4" Body="&lt;p&gt;Ignacio provides a great answer on the differences between the two types of interrupts.  But to add to that, it isn't a universal requirement to even use an interrupt.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Polling&lt;/strong&gt; is also a possibility, though it has been compared to periodically picking up the phone to see if anyone is trying to talk to you.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Advantages of using an interrupt can include faster response, background response while a program is primarily doing something else, and often an associated ability wake up the processor from low-power sleep mode used in battery powered gadgets.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But polling can have a role, for example when the program runs in a tight loop and can only take action in response to input at certain times anyway - an interrupt service routine that merely sets a flag to tell the main program loop that something has happened may or may not be much benefit.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Often the best solution is a hybrid approach - an interrupt service routine records events - especially ones which might vanish or be repeated before the main program loop can poll for them.  Then when the main program loop reaches a logical decision point, it checks the flags or event queue to see if the interrupt service routine has recorded anything to which it should respond.  Serial receive is typically handled this way in the Arduino framework.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-05-17T14:44:03.320" LastActivityDate="2014-05-17T14:44:03.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1569" PostTypeId="1" AcceptedAnswerId="1570" CreationDate="2014-05-17T20:48:05.950" Score="28" ViewCount="127420" Body="&lt;p&gt;I know that this is to initialize something:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want to know what it really means? &lt;/p&gt;&#xA;" OwnerUserId="670" LastEditorUserId="-1" LastEditDate="2019-03-27T02:56:52.423" LastActivityDate="2019-03-27T02:56:52.423" Title="What is Serial.begin(9600)?" Tags="|arduino-uno|serial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="1570" PostTypeId="2" ParentId="1569" CreationDate="2014-05-17T21:11:36.013" Score="25" Body="&lt;p&gt;&lt;code&gt;Serial.begin(9600)&lt;/code&gt; doesn't actually print anything. For that you'd want to use &lt;code&gt;Serial.print(&quot;Hello world!&quot;)&lt;/code&gt; to print the text &quot;Hello world!&quot; to the serial console. Rather it initializes the serial connection at 9600 bits per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both sides of the serial connection (i.e. the Arduino and your computer) need to be set to use the same speed serial connection in order to get any sort of intelligible data. If there's a mismatch between what the two systems think the speed is then the data will be garbled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9600 bits per second is the default for the Arduino, and is perfectly adequate for the majority of users, but you could change it to other speeds: &lt;code&gt;Serial.begin(57600)&lt;/code&gt; would set the Arduino to transmit at 57600 bits per second. You'd need to set whatever software you're using on your computer (like the Arduino IDE's serial monitor) to the same speed in order to see the data being sent.&lt;/p&gt;&#xA;" OwnerUserId="1472" LastEditorUserId="26916" LastEditDate="2017-09-08T09:53:40.320" LastActivityDate="2017-09-08T09:53:40.320" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1571" PostTypeId="1" CreationDate="2014-05-18T01:11:25.953" Score="4" ViewCount="7638" Body="&lt;p&gt;The &lt;a href=&quot;https://www.kickstarter.com/projects/ufactory/uarm-put-a-miniature-industrial-robot-arm-on-your&quot; rel=&quot;nofollow noreferrer&quot;&gt;uArm&lt;/a&gt; is a robot arm with a suction cup (or gripper). I'd like to try to make &lt;strong&gt;just the suction part&lt;/strong&gt; of it, and I'm wondering what components I'd need?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the looks of it, I'd need a hobby vacuum pump, but these seem few and far between on UK components sites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I power it? It looks like they're all 12v, and I believe Arduino gives you 5v?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Exact what components would I need? Do I need any shields?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a short video of the suction cup I'd like to copy:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=x6pJqdSk29Y&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yv5KA.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1455" LastEditorUserId="1455" LastEditDate="2014-05-18T01:37:49.257" LastActivityDate="2019-06-13T23:29:55.160" Title="How to make an electronic suction cup?" Tags="|robotics|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="1572" PostTypeId="2" ParentId="1571" CreationDate="2014-05-18T02:01:27.487" Score="1" Body="&lt;p&gt;There are two approaches I can think of that would work decently. Either a.) suck air out of a &quot;cup,&quot; turning off the pump when done. OR b.) have a valve where the arm pushes one part of the bag against the table to squeeze all the air out of it, and shutting a valve attached to the &quot;cup.&quot; Then, to release, the valve could be opened. For the suction cup, I'd personally try making it out of a suction cup hanger like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vxd3Bs.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Source: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00439SCZO&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.com/Set-Large-Suction-Hanger-Hook/dp/B00439SCZO&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The availability of these might vary by area, so I'm not sure how common these are in the UK. If you find one, make sure that it's pretty thick, with not that large of diameter so it's not too big to work with. I'd then remove the metal hook with pliers and drill a hole in the center. After that, you would need to superglue a tube through the center of the hole and seal it with some caulk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like I mentioned earlier, the two options are to a.) suck to grab and turn off pump to release or b.) have arm apply pressure to a flat surface and then shut a valve attached to the tube, creating negative pressure in the suction cup. Then, you could open the valve to balance the pressure and let the item go. I'd personally do the suction approach because, although it is louder and might use a little more electricity, it's a bit easier to build and execute and can grab in the air. I'm going to focus on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the pump approach, build the suction cup (like I said above), attach the tube to one end of the motor with a hose clamp, leave the other hose terminal unconnected, and connect the pump (through a relay) to a 12V 1A+ power supply. You can do this by connecting the + pin of the pump to the &quot;out&quot; (or similar) pin of a relay breakout board, the &quot;in&quot; (or similar) of the relay to the power supply +, and the - of the pump to the power supply's - wire. This will make a circuit similar identical to a switch (the switch being the relay). To connect the relay to the Arduino you will have to connect the relay's logic signal to a pin on the Arduino and then you can just write &lt;code&gt;HIGH&lt;/code&gt; or &lt;code&gt;LOW&lt;/code&gt; to turn the pump on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Forgot to mention, you can use a transistor, too. Also, I illustrated the second method (hopefully it makes this clear).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/glaEV.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-05-18T14:54:49.563" LastActivityDate="2014-05-18T14:54:49.563" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1574" PostTypeId="1" AcceptedAnswerId="1576" CreationDate="2014-05-18T17:37:48.883" Score="2" ViewCount="267" Body="&lt;p&gt;So, I'm trying to make a custom library to drive a 8x8 Bi-Color LED Matrix from 2 MAX7219's that incorporates two &quot;Matrix&quot; objects from the &quot;Matrix&quot; library and I cannot, for the life of me, figure out how to initialize them in my class. Can someone help me? By the way, I have been programming for 8 years, and consequently have a decent knowledge of the topic! Here is my current code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;header file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Matrix.h&quot;&#xA;#include &quot;Sprite.h&quot;&#xA;&#xA;&#xA;class ZackBiColorMatrix{&#xA;&#xA;    public:&#xA;&#xA;&#xA;        ZackBiColorMatrix(byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG);&#xA;&#xA;        Matrix r;&#xA;        Matrix g;&#xA;&#xA;        void setLED(byte col, byte row, byte val, char color);&#xA;        void writeSprite(byte x, byte y, Sprite sp, char color);&#xA;&#xA;&#xA;&#xA;    private:&#xA;&#xA;&#xA;&#xA;        byte redData;&#xA;        byte redLoad;&#xA;        byte redClock;&#xA;&#xA;        byte greenData;&#xA;        byte greenLoad;&#xA;        byte greenClock;&#xA;&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the .cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Sprite.h&quot;&#xA;#include &quot;Matrix.h&quot;&#xA;#include &quot;ZackBiColorMatrix.h&quot;&#xA;&#xA;&#xA;&#xA;ZackBiColorMatrix::ZackBiColorMatrix (byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG) {&#xA;&#xA;&#xA;&#xA;    redData = dataR;&#xA;    redLoad = loadR;&#xA;    redClock = clockR;&#xA;&#xA;    greenData = dataG;&#xA;    greenLoad = loadG;&#xA;    greenClock = clockG;&#xA;&#xA;    r = Matrix (redData, redClock, redLoad);&#xA;    g = Matrix (greenData, greenClock, greenLoad);&#xA;&#xA;}&#xA;&#xA;&#xA;void ZackBiColorMatrix::setLED (byte col, byte row, byte val, char color) {&#xA;&#xA;    if (color == 'g') {&#xA;&#xA;        g.write (col, row, val);&#xA;&#xA;    }&#xA;    else if (color == 'r') {&#xA;&#xA;        r.write (col, row, val);&#xA;&#xA;    }&#xA;&#xA;}&#xA;void ZackBiColorMatrix::writeSprite (byte x, byte y, Sprite sp, char color) {&#xA;&#xA;    if (color == 'g') {&#xA;&#xA;        g.write (x, y, sp);&#xA;&#xA;    }&#xA;    else if (color == 'r') {&#xA;&#xA;        r.write (x, y, sp);&#xA;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I use the Eclipse Arduino IDE if that matters.&lt;/p&gt;&#xA;" OwnerUserId="1095" LastEditorUserId="84" LastEditDate="2014-05-18T18:13:22.320" LastActivityDate="2014-05-18T18:13:22.320" Title="Initialize a &quot;Matrix&quot; object in my own library?" Tags="|c++|library|led|class|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1575" PostTypeId="1" CreationDate="2014-05-18T17:34:41.337" Score="2" ViewCount="1619" Body="&lt;p&gt;I am creating my own library for the Arduino and I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;class ServoMotorController {&#xA;    public:&#xA;        ServoMotorController(int servoPin, int motorPin, int angle);&#xA;        void setAngle(int angle);&#xA;        void setSpeed(int speed);&#xA;    private:&#xA;        Servo servo;&#xA;&#xA;        int servoPin;&#xA;        int servoAngle;&#xA;        int motorPin;&#xA;        int motorSpeed;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am getting the error that &lt;code&gt;Servo&lt;/code&gt; does not name a type; however if I do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;ServoMotorController.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my actual Arduino code then I do not get the error. &lt;strong&gt;Why is the include statement not working in my C++ lib?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1535" OwnerDisplayName="Jister13" LastActivityDate="2014-05-26T03:54:47.737" Title="Include statement not working" Tags="|c++|library|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1576" PostTypeId="2" ParentId="1574" CreationDate="2014-05-18T18:13:02.027" Score="1" Body="&lt;p&gt;This is a C++ question actually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C++, you initialize class members in the class constructor definition by using a &quot;&lt;a href=&quot;http://en.cppreference.com/w/cpp/language/initializer_list&quot; rel=&quot;nofollow&quot;&gt;member intialization list&lt;/a&gt;&quot; as follows for your example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ZackBiColorMatrix::ZackBiColorMatrix (byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG)&#xA;:   r(dataR, clockR, loadR),&#xA;    g(dataG, clockG, loadG) {&#xA;    ... Additional initialization here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a special C++ construct (note the colon &lt;code&gt;:&lt;/code&gt; after the constructor declaration but before its implementation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that, in your example, I think you don't need to declare &lt;code&gt;redData&lt;/code&gt;, &lt;code&gt;redLoad&lt;/code&gt;, &lt;code&gt;redClock&lt;/code&gt;, &lt;code&gt;greenData&lt;/code&gt;, &lt;code&gt;greenLoad&lt;/code&gt;, &lt;code&gt;greenClock&lt;/code&gt;, sicne they are not being used once your 2 &lt;code&gt;Matrix&lt;/code&gt; fields have been initialized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence you could simplify your class further, I think.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-18T18:13:02.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1577" PostTypeId="1" CreationDate="2014-05-18T18:49:05.867" Score="1" ViewCount="1437" Body="&lt;p&gt;I have arduino , upon arduino I have Arduino GSM shield (Tx-2, Rx-3, Modem reset-7) and upon it, I have the Adafruit GPS Logger shield. I am trying to send sms of Latitude  from the GPS Logger shield to my numer through GSM shield. I am getting a error ..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':&#xA;/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_3'&#xA;&#xA;GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here&#xA;SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':&#xA;/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_4'&#xA;&#xA;GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here&#xA;SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':&#xA;/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_5'&#xA;&#xA;GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the meaning of this error ? what should I do to solve it?&lt;/p&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2016-03-13T14:57:28.903" Title="SoftwareSerial error" Tags="|arduino-uno|gsm|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1579" PostTypeId="1" AcceptedAnswerId="1580" CreationDate="2014-05-18T21:31:16.687" Score="11" ViewCount="9618" Body="&lt;p&gt;According to the schematics, the Arduino Due has two USB inputs:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Native&lt;/li&gt;&#xA;&lt;li&gt;Programming&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Why is this? And when would I use the different ports?&lt;/p&gt;&#xA;" OwnerUserId="1484" LastEditorUserId="510" LastEditDate="2014-07-20T14:12:53.677" LastActivityDate="2016-06-06T13:22:28.047" Title="Why does the Arduino Due have a native and USB programming port?" Tags="|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1580" PostTypeId="2" ParentId="1579" CreationDate="2014-05-18T22:37:10.867" Score="8" Body="&lt;p&gt;Either port can be used for programming, but the native USB port lets you do other things:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It also enables the Due to emulate a USB mouse or keyboard to an attached computer. To&#xA;  use these features, see the &lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard&quot;&gt;Mouse and Keyboard library reference pages&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Native USB port can also act as a USB host for connected&#xA;  peripherals such as mice, keyboards, and smartphones. To use these&#xA;  features, see the &lt;a href=&quot;http://arduino.cc/en/Reference/USBHost&quot;&gt;USBHost reference pages&lt;/a&gt;. &lt;sub&gt;&lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardDue&quot;&gt;http://arduino.cc/en/Main/arduinoBoardDue&lt;/a&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you can use the Due to interface with USB devices or connect it to your computer and have it act like a USB device.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-05-18T22:37:10.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1581" PostTypeId="1" CreationDate="2014-05-18T23:41:16.890" Score="1" ViewCount="1612" Body="&lt;p&gt;I'm trying to connect to my Arduino board through a macbook pro with mac os x 10.9.3 installed. I'm following the instructions from the arduino guide and in the connection section:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot; Connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.&#xA;  If you're using the Arduino Uno or Arduino Mega 2560, a dialog box will appear telling you that a new network interface has been detected. Click &quot;Network Preferences...&quot;, and when it opens, simply click &quot;Apply&quot;. The Uno or Mega 2560 will show up as &quot;Not Configured&quot;, but it's working properly. Quit System Preferences.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I cannot see any ports that hold the USBModem port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to setup the connection in the right way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read some articles about making a lock folder and I followed them but they didn't work for me, I also tried following &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=198539.0&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; but the solution there didn't work as well.&lt;/p&gt;&#xA;" OwnerUserId="1485" LastEditorUserId="1487" LastEditDate="2014-05-19T04:23:10.127" LastActivityDate="2014-05-26T07:29:23.373" Title="Error while connecting Arduino to Macbook: “serial port already in use. try quitting any programs that may be using it”" Tags="|arduino-uno|serial|mac-os|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1582" PostTypeId="1" CreationDate="2014-05-19T04:21:30.980" Score="2" ViewCount="251" Body="&lt;p&gt;I have a Samsung Galaxy Note 10.1 with JuiceSSH installed. I also have Debian Linux installed via chroot. I'll be ordering an Intel Galileo to use as a portable compilation server. I have an attachment for the Note 10.1 that serves as a USB and an ethernet adapter. I figure I could power the Note 10.1 with the USB port and connect to it via SSH through the ethernet port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, &lt;a href=&quot;https://communities.intel.com/thread/46335&quot; rel=&quot;nofollow&quot;&gt;this post&lt;/a&gt; notes that in order to connect the Galileo via ssh, the LAN connection must be started manually through Arduino Sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to install Debian Linux on the Galileo, get rid of my chroot Debian on my tablet, and have that LAN connection started automatically when the Galileo boots so that I can just connect to it through JuiceSSH on my tablet. This is so I can do everything without depending on WiFi and compile &quot;offline&quot;. How do I automatically start the LAN connection and avoid having to use Arduino Sketch? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, does anyone know if ArduinoDroid works on the Galileo? &lt;/p&gt;&#xA;" OwnerUserId="1488" LastEditorUserId="3" LastEditDate="2014-05-19T16:39:41.520" LastActivityDate="2014-05-19T16:39:41.520" Title="How can I automatically start a LAN connection?" Tags="|linux|android|arduino-galileo|ssh|lan|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1583" PostTypeId="1" CreationDate="2014-05-19T13:06:33.267" Score="3" ViewCount="1958" Body="&lt;p&gt;Is there a way to test whether the UART Tx buffer is empty without waiting? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;serial.flush()&lt;/code&gt; waits, so it won't help me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried looking into &lt;code&gt;serial.SerialEvent()&lt;/code&gt;, but the link was broken on the Arduino reference page.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone point me to a description of it? &lt;/p&gt;&#xA;" OwnerUserId="1495" LastEditorUserId="3" LastEditDate="2014-05-19T16:39:11.123" LastActivityDate="2014-05-19T19:21:58.723" Title="Is there a way to test whether the UART Tx buffer is empty without waiting?" Tags="|serial|uart|softwareserial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1584" PostTypeId="2" ParentId="1581" CreationDate="2014-05-19T14:12:28.367" Score="0" Body="&lt;p&gt;Under what circumstances does this happen? I see this message whenever I try to download to the Arduino but I've left my terminal program connected to that port. The fix in that situation is to disconnect it (after a &amp;lt;face-palm&gt; to remind myself, yet again....  :-)&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-05-19T14:12:28.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1585" PostTypeId="1" CreationDate="2014-05-19T14:37:58.477" Score="6" ViewCount="32192" Body="&lt;p&gt;I have arduino pro mini 5V, 16M ATMega328 and CP2102 USB to TTL. I've wired them like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zlrea.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to upload a sketch to the arduino board I'm getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The board type and the serial port are correct. The sketch also compiles successfully and I've installed the CP2102 drivers. I've noticed that even if I unplug all wires from the arduino board(and just leave the cp2102 connected to the PC), I'm getting the same error again. I'm using Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone else encountered the same issue?&lt;/p&gt;&#xA;" OwnerUserId="1411" OwnerDisplayName="Deepsy" LastEditorUserId="1411" LastEditDate="2014-05-19T16:05:01.617" LastActivityDate="2018-11-14T19:26:53.690" Title="avrdude: stk500_getsync(): not in sync: resp=0x00" Tags="|uploading|arduino-pro-mini|" AnswerCount="10" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1586" PostTypeId="2" ParentId="1585" CreationDate="2014-05-19T14:53:06.147" Score="5" Body="&lt;p&gt;This error means that the program responsible for uploading (avrdude) can not communicate with your arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you reset the board just before programming? The reset pin of the arduino seems unconnected in your picture; so the board wouldn't be executing the bootloader when the serial cables expects it to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try either to reset the board manually just before programming, or connect the rst pin.&lt;/p&gt;&#xA;" OwnerUserId="367" OwnerDisplayName="Nicolas D" LastActivityDate="2014-05-19T14:53:06.147" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1589" PostTypeId="1" AcceptedAnswerId="1590" CreationDate="2014-05-19T18:36:09.847" Score="2" ViewCount="839" Body="&lt;p&gt;I have written this little snippet of code to interface with EM408 GPS.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial GPS = SoftwareSerial(2,3);  //rx,tx&#xA;void setup()&#xA;{&#xA;  GPS.begin(4800);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Serial.print(GPS.read(), BYTE);&#xA;  Serial.write(byte(GPS.read()));  //as of Arduino 1.0&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hardware side i have these connections: &lt;br&gt;&#xA;ENABLE: 3.3V &lt;br&gt;&#xA;Vcc   : 3.3V &lt;br&gt;&#xA;Ground: Ground &lt;br&gt;&#xA;Rx, Tx correctly connected to arduino and correctly initialized with SoftwareSerial&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the values i get are just junk data&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get these without ending...&#xA;I experimenting with changing the baud rate, still the same thing goes on.&#xA;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;br&gt;&#xA;I used to get random junk data before with the EM406 gps module, but i solved it by casting everything to BYTE. I have tried both approaches here, but the results are the same...&lt;/p&gt;&#xA;" OwnerUserId="1499" OwnerDisplayName="user1584421" LastActivityDate="2014-05-19T19:15:38.627" Title="arduino EM408 GPS problem" Tags="|serial|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1590" PostTypeId="2" ParentId="1589" CreationDate="2014-05-19T19:15:38.627" Score="2" Body="&lt;p&gt;The problem you get is that &lt;code&gt;read()&lt;/code&gt; does not wait for a byte to be available, it just returns &lt;code&gt;-1&lt;/code&gt; if there is no byte available; converted as an unsigned byte that becomes &lt;code&gt;255&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;strong&gt;ISO-8859-1&lt;/strong&gt;, which I guess is the encoding that your serial monitor is using, &lt;code&gt;255&lt;/code&gt; translates to &lt;code&gt;ÿ&lt;/code&gt;, so this is exactly what you observe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixing this problem is straightforward, just check that a byte is available on &lt;code&gt;SoftwareSerial&lt;/code&gt; before reading it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    if (GPS.available()) {&#xA;        Serial.write(byte(GPS.read()));  //as of Arduino 1.0&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-19T19:15:38.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1591" PostTypeId="2" ParentId="1583" CreationDate="2014-05-19T19:21:58.723" Score="1" Body="&lt;p&gt;It doesn't look like that function is implemented. The source for HardwareSerial.{cpp,h} are in &lt;code&gt;/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino&lt;/code&gt; under OS-X. (Someone better versed in Window than I may have to chime in here to point you to that source location.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking HardwareSerial::available() as a model, create a new function, say, HardwareSerial::txremaining(), that does the same thing, but for the transmit buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Left as an exercise for the student:&lt;br&gt;Make a common function that returns the contents of an arbitrary ring-buffer and use it in both ::available() and ::txremaining().&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-05-19T19:21:58.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1592" PostTypeId="2" ParentId="1585" CreationDate="2014-05-19T20:41:51.240" Score="6" Body="&lt;p&gt;It's hard to tell from your pictures, but are all the header pins soldered to the boards? If not, they need to be: there's no chance that the proper electrical connections will be made reliably if they're just inserted loosely into the holes.&lt;/p&gt;&#xA;" OwnerUserId="1217" LastActivityDate="2014-05-19T20:41:51.240" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1593" PostTypeId="1" CreationDate="2014-05-19T20:50:18.803" Score="2" ViewCount="1224" Body="&lt;p&gt;I have an Arduino Micro and an MPU6050 gyro/accelerometer board; I want to read DMP data from the MPU6050, but the sketch requires the use of the interrupt pin, of which I have none of the interrupt pins available and they cannot be switched around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering how to go about reading the DMP data when needed. I've tried but always just receive the value 180 for any reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you! &lt;/p&gt;&#xA;" OwnerUserId="1503" LastActivityDate="2019-12-11T01:31:00.553" Title="Using Arduino Micro with MPU6050" Tags="|accelerometer|mpu6050|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1594" PostTypeId="1" CreationDate="2014-05-20T05:30:52.037" Score="2" ViewCount="1504" Body="&lt;p&gt;I have this big bucket where I would like to install an arduino on the top of the bucket where it would calculate the % of the bucket being filled up with water. Then, every day at night the arduino will send a text message (via SIM card) to the server where it would collect data for that bucket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as a beginner point of view, I can understand that I will need:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;an Arduino Board&#xA;PING))) Ultrasonic Distance Sensor&#xA;Battery pack that would allow to run the board for a year?&#xA;and the Arduino GSM Shield (integrated antenna) OR the GSM/GPRS Module M10?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&#xA;What arduino board do I need for my setup?&#xA;How long will 2 large or 4 AA batteries lasts for receiving a value from the ultrasonic sensor once a day and sending that value to a server? The point of the instrument is to be as small as possible.&lt;/p&gt;&#xA;" OwnerUserId="1505" LastActivityDate="2014-05-20T12:06:14.960" Title="Send text according to an ultrasonic measurement, on battery" Tags="|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1595" PostTypeId="1" AcceptedAnswerId="1597" CreationDate="2014-05-20T06:00:34.627" Score="2" ViewCount="1523" Body="&lt;p&gt;I want to power a small motor with a 9V battery and control it with PWM using an Arduino Leonardo. I know I can power the motor separately, but this introduces the problem of needing a battery to power the motor (9V battery) and another power source to power the Arduino (another 9V battery?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Would it be safe&lt;/strong&gt; to simply power the Arduino with a 9V battery and use the Vin pin on the board (which is unregulated and outputs directly the power source powering the Arduino) to drive the motor? That way, I power everything from the 9V battery, and use a transistor to drive the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steve.&lt;/p&gt;&#xA;" OwnerUserId="1506" LastActivityDate="2015-09-30T07:48:41.723" Title="Power small hobby motor using Vin pin on Arduino and 9V battery, safe?" Tags="|motor|arduino-leonardo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1597" PostTypeId="2" ParentId="1595" CreationDate="2014-05-20T06:26:20.287" Score="1" Body="&lt;p&gt;If you use a transistor circuit as shown below, back EMF would not cause any trouble.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/87qTl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1372" LastActivityDate="2014-05-20T06:26:20.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1598" PostTypeId="1" CreationDate="2014-05-20T07:53:34.353" Score="3" ViewCount="485" Body="&lt;p&gt;I have built the circuit below using mux ICs. In a particular interval the respective selector pins get selected and analog signal from hall sensors are read and give a particular analog value out. There is a total of 30 hall sensors which are represented by &lt;code&gt;HS0&lt;/code&gt; to &lt;code&gt;HS31&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PdVWH.jpg&quot; alt=&quot;Multiplexer&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I wanted to set time as in the table below. After 8000ms I would like it to reset the time automatically and start reading. &lt;strong&gt;Can someone tell me which timer example would let me achieve this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TIME IS ms  OUT1    OUT2    OUT3    OUT4&#xA;  0-1000    HS0     HS8     HS16    HS24&#xA;1000-2000   HS1     HS9     HS17    HS25&#xA;2000-3000   HS2     HS10    HS18    HS26&#xA;3000-4000   HS3     HS11    HS19    HS27&#xA;4000-5000   HS4     HS12    HS20    HS28&#xA;5000-6000   HS5     HS13    HS21    HS29&#xA;6000-7000   HS6     HS14    HS22    HS30&#xA;7000-8000   HS7     HS15    HS23    HS31&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="46" LastEditDate="2014-05-20T16:38:54.610" LastActivityDate="2014-05-20T16:38:54.610" Title="Setting time frame in Arduino Uno" Tags="|arduino-uno|arduino-mega|time|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1599" PostTypeId="2" ParentId="1594" CreationDate="2014-05-20T12:06:14.960" Score="3" Body="&lt;p&gt;First of all: what is the intention of your setup? What are you trying to measure, what do you want to do with the data? Where is the bucket located, in your backyard or miles away in a forest?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I foresee some problems with your current setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, you need a enclosure that keeps your 'duino and other components dry and at a comfortable temperature. I don't know how severe the weather conditions are, but stuff can get unreliable when used close to the min/max operating temperatures. Can you find an enclosure that can protect your electronics against the elements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice: think of a good enclosure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, do you really think PING))) is the best sensor? Have you already tested how it behaves around water? Are the measurements correct?&#xA;Another option would be an array of metal strips, one connected to +V or GND, the others to separate ports on your Arduino. Space them evenly from the bottom of your bucket to your maximum water level (drill a hole in the bucket to prevent overflowing or drowning your duino). Poll the pins at a predefined interval (not too short, keeping battery life in mind) to see which ones make contact with the water (allowing current to flow from/to the pins from/to +V/GND)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice: do some research on sensors, or try to make your own&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way to communicate with your 'server' (what are you going to use?) totally depends on how far it is from the bucket. GSM shields are quite pricey, other alternatives may be preferable (and do not have additional phone costs).&#xA;Is your server on the other site of the window? Bluetooth? Somewhere in your backyard? Zigbee. Across the street? High-power Zigbee (if allowed by local authorities). Far away but with WIFI access? Zigbee, posting data to an online place. In the middle of nowhere but with great cell phone reception? GSM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice: check out wireless communication possibilities. There's a ton of them, each with pros and cons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last hurdle, energy. Your battery setup will most definitely NOT be able to provide enough energy for a whole year. There's just too little juice in them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino and standalone AVRs often have a sleep mode, in which power consumption can be very &lt;em&gt;very&lt;/em&gt; low. Google is your friend on this one. Still, that won't let your setup last a year.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless there was a gigantic glowing ball of plasma hanging around some 8 lightminutes from here and we could harness its incredible power with the use of photovoltaic elements... Wait, we totally can! Using (a) solar panel(s) and some simple circuitry you can recharge your batteries, and depending on the weather conditions this could keep your project up and running for a year.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice: get down and dirty with small solar panels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really appreciate your ambition. If done right, this could be quite the project for a beginner! Just make sure you thoroughly research every part of the system, on itself and as a whole. This could prevent a lot of disappointment and unnecessary costs, while only expanding your knowledge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-05-20T12:06:14.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1600" PostTypeId="1" CreationDate="2014-05-20T12:52:05.313" Score="0" ViewCount="619" Body="&lt;p&gt;Does anyone know how the data in data packet looks like when the USB is initialized as COM port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Arduino Mega 2560. I have initialized COM port with a baud rate of 9600. I know that there are four types of USB packets as &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Token Packet (Commonly used for device identification and transaction initiation.)&lt;/li&gt;&#xA;&lt;li&gt;Data Packet (Contains the data that needs to be transferred from host to client or vice-versa.)&lt;/li&gt;&#xA;&lt;li&gt;Acknowledgement Packet (Acknowledgement for error-free data reception.)&lt;/li&gt;&#xA;&lt;li&gt;Special Packets (Hub to hub communication and speed differential.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The payload in data packet is formatted as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DATA1 &gt;&gt; PAYLOAD &gt;&gt; CRC16 ; DATA2 &gt;&gt; &gt;&gt; PAYLOAD &gt;&gt; CRC16 ;&lt;/strong&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Till this point I am clear about whats happening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now all I want to know is &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How the data is structured in the PAYLOAD section, when USB is initialized as COM port?&lt;/li&gt;&#xA;&lt;li&gt;How the baud rate comes into picture i.e how a particular baudrate is achieved in this type of communication?&lt;/li&gt;&#xA;&lt;li&gt;How is communication in terms of packet sequence? Does the sequence of packets change? (Like token&gt;&gt;data&gt;&gt;ack&gt;&gt;data&gt;&gt;ack&gt;&gt;...)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I really need to know this urgently as I am working on program that has to connect with 3 MEga2560 boards through a USB hub. I want to fix my design constraints depending on what is the maximum baud rate that I can achieve for all boards.&lt;/p&gt;&#xA;" OwnerUserId="1372" LastActivityDate="2022-11-22T05:01:45.213" Title="Data packet format when USB initialized as COM port" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1601" PostTypeId="2" ParentId="1600" CreationDate="2014-05-20T13:34:46.767" Score="1" Body="&lt;p&gt;Once the USB connection is initialized as a COM port, it no longer utilizes traditional USB packets (only internally). It acts as a regular COM port. This layer of abstraction is created by 8u2 chip on Arduino side and by the driver on the PC side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to use the USB without the COM port abstraction, you have to probably configure the 8u2 chip to behave this way. I think it should be possible to configure to act as some HID device for example. You would also need to take care about the PC side and you might have to write your own driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a guide on hacking and configuring the 8u2 chip on Mega, see following link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/DFUProgramming8U2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1063" LastActivityDate="2014-05-20T13:34:46.767" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1602" PostTypeId="2" ParentId="1577" CreationDate="2014-05-20T15:23:49.973" Score="2" Body="&lt;p&gt;This error means, that there is library overlapping on a vectors. To solve this error, you need to modify your Library file :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;STEPS :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Remove the Softserial Library &lt;/li&gt;&#xA;&lt;li&gt;Download AltSoftSerial library&lt;/li&gt;&#xA;&lt;li&gt;if you have shield then you need to replace AltSoftSerial in place of SoftwareSerial in both .cpp as well as .h files.&lt;/li&gt;&#xA;&lt;li&gt;Import AltSoftSerial library in place of SoftwareSerial in the sketch.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Execute . &lt;/p&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2014-05-20T15:23:49.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1603" PostTypeId="1" CreationDate="2014-05-20T04:37:33.093" Score="3" ViewCount="2558" Body="&lt;p&gt;I am writing code on Arduino mega. My current code is working fine. However, I'm not using all the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I have the hex file for my code and I can purchase a Mega2560 MCU. Is there any way to upload the hex file to it and how?&lt;/li&gt;&#xA;&lt;li&gt;What are the circuits I would need to to build?&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Eagle files&lt;/a&gt; of the Arduino mega are available here. Is this circuit more than enough?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="904" OwnerDisplayName="AMPS" LastEditorUserId="42" LastEditDate="2014-05-22T09:44:03.860" LastActivityDate="2014-05-22T17:07:12.197" Title="How to program an empty Mega2560 with an Arduino sketch?" Tags="|bootloader|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1604" PostTypeId="2" ParentId="1603" CreationDate="2014-05-20T09:03:19.147" Score="3" Body="&lt;p&gt;If you buy an empty mega2560 IC. It won't contains any bootloader.&#xA;That means that you need an extra circuit, a programmer, to upload your HEX file into your MCU. &lt;a href=&quot;https://electronics.stackexchange.com/questions/57651/when-to-use-an-arduino-bootloader?rq=1&quot;&gt;&quot;When to use the bootloader&quot; questions link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if you buy your mega2560 from an Arduino provider, you should be able to order the MCU with the arduino booloader already programmed. Then a simple serial link from your PC to your MCU will suffice to program the MCU with your Arduino sketch using the Arduino environment. You could clone the serial part that you have on the Eagle files of the original Arduino to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Programming an empty chip requires a programmer&lt;/li&gt;&#xA;&lt;li&gt;Programming a chip that has a booloader requires either a programmer, or a simple serial link.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may also use another Arduino with the suited sketch as a programmer and use it for programming another empty MCU. There are examples of this on the web.&lt;/p&gt;&#xA;" OwnerDisplayName="Blup1980" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-05-20T09:03:19.147" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1605" PostTypeId="2" ParentId="1598" CreationDate="2014-05-20T15:45:59.147" Score="2" Body="&lt;p&gt;Could you tell us which multiplexer IC you are using? This way, we can help you better. Also, why do you need the 8 second cycle? Does it matter if it's a little shorter or longer? If timing does not have to be very precise it would make things a lot easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way: you say there are 30 sensors, but your table has 32...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following pseudocode will not work on your Arduino, but you can use the same structure.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorArray[32] // we will store our 32 sensor values here&#xA;&#xA;// these pins control the multiplexer chips&#xA;int selectPinZero = 8;&#xA;int selectPinOne = 9;&#xA;int selectPinTwo = 10;&#xA;&#xA;// these pins will receive the sensor values from the multiplexer chips&#xA;int inputPinOne = 0;&#xA;int inputPinTwo = 1;&#xA;int inputPinThree = 2;&#xA;int inputPintFour = 3;&#xA;&#xA;void setup(){&#xA;    // make sure the correct pins are inputs and outputs&#xA;    pinMode(selectPinZero, OUTPUT);&#xA;    pinMode(selectPinOne, OUTPUT);&#xA;    pinMode(selectPinTwo, OUTPUT);&#xA;&#xA;    pinMode(inputPinOne, INPUT);&#xA;    pinMode(inputPinTwo, INPUT);&#xA;    pinMode(inputPinThree, INPUT);&#xA;    pinMode(inputPinFour, INPUT);&#xA;}&#xA;&#xA;// all done, now keep reading the sensors&#xA;void loop(){&#xA;&#xA;    // set selectPins so that each Multiplexer will output its first channel&#xA;    digitalWrite(selectPinZero, HIGH); // or low, depending on your Multiplexer IC&#xA;    digitalWrite(selectPinOne, HIGH); // or low, depending on your Multiplexer IC&#xA;    digitalWrite(selectPinTwo, HIGH); // or low, depending on your Multiplexer IC&#xA;&#xA;    // start reading sensors&#xA;&#xA;    int i = 0;&#xA;    while(i&amp;lt;32){&#xA;        sensorArray[i] = analogRead(inputPinOne);&#xA;        i++; // variable i was 0, now 1 &#xA;&#xA;        sensorArray[i] = analogRead(inputPinTwo);&#xA;        i++; // variable i was 1, now 2 &#xA;&#xA;        sensorArray[i] = analogRead(inputPinThree);&#xA;        i++; // variable i was 2, now 3&#xA;&#xA;        sensorArray[i] = analogRead(inputPinFour);&#xA;        i++; // variable i was 3, now 4&#xA;&#xA;        /*&#xA;        use digitalWrite() on all the selectPins to make the Multiplexer IC output the next channel&#xA;        */&#xA;&#xA;        delay(1000); // wait 1000 milliseconds&#xA;    }&#xA;&#xA;    /*&#xA;    this will repeat until all 32 sensors are read and stored in the array&#xA;    */&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code is by no means optimized, but written to make it easy for you to understand. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-05-20T15:45:59.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1606" PostTypeId="1" CreationDate="2014-05-21T01:31:09.470" Score="0" ViewCount="578" Body="&lt;p&gt;In the project I am working on, I have a limited space with which I can work. I am using an Arduino Uno with 2 Adafruit motor shields, and when I stack them using normal, female stacking headers it is too tall to fit. I thought that one way to solve this would be to lay them out side to side rather than one on top of the other. So, instead of this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+--------Motor shield 2 ----------+&#xA;|||||||||||||||||||||||||||||||||||&#xA;+--------Motor shield 1 ----------+&#xA;|||||||||||||||||||||||||||||||||||&#xA;+---------Arduino Uno ------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it would look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;               -----------------------------------------Wires -------------------------------           &#xA;+---------Arduino Uno ------------+    +--------Motor shield 1 ----------+    +--------Motor shield 2 ----------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would this be possible if I were to connect all of the pins with wires, and has anyone successfully done this before?&lt;/p&gt;&#xA;" OwnerUserId="1304" LastActivityDate="2014-05-22T20:23:14.880" Title="Stacking shields without headers" Tags="|arduino-uno|shields|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1607" PostTypeId="2" ParentId="1606" CreationDate="2014-05-21T01:38:27.677" Score="1" Body="&lt;p&gt;It is possible to have some success with this, but keep in mind that the longer the wire, the higher the inductance and voltage drop across the wire. Prefer to use a star topology rather than a chain topology, with the Arduino in the middle of all the shields in use.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-21T01:38:27.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1608" PostTypeId="2" ParentId="791" CreationDate="2014-05-21T01:40:54.067" Score="1" Body="&lt;p&gt;Try the manchester library instead.&#xA;This post includes all the necessary info except wiring diagrams:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/1304/manchester-library-wont-compile-for-attiny85&quot;&gt;Manchester Library Won&amp;#39;t Compile for Attiny85&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-05-21T01:40:54.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1612" PostTypeId="1" AcceptedAnswerId="3110" CreationDate="2014-05-21T11:26:20.363" Score="6" ViewCount="17786" Body="&lt;p&gt;I have two &lt;a href=&quot;http://www.elecfreaks.com/wiki/index.php?title=2.4G_Wireless_nRF24L01p&quot; rel=&quot;noreferrer&quot;&gt;NRF24L01+ modules&lt;/a&gt; which are transceivers, but for my project I would like to send a very simple signal from one of these modules to the be read by the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would've been very simple if I had an Arduino on each side but due to power consumption constraints as well as size, cost and practicality, the transmitting side won't have one. Would it still be possible to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, the message itself is not important and can be set in stone, it will never change. I really just want to detect on the receiving side (which will have an Arduino) that the transmitter is in fact transmitting. Transmission will be triggered by a push-button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would have a way of identifying my particular transmitter from others on similar frequencies but I am not too precious about that.&lt;/p&gt;&#xA;" OwnerUserId="1515" LastEditorUserId="46" LastEditDate="2014-05-21T11:59:42.833" LastActivityDate="2017-10-29T08:53:17.160" Title="Is it possible to transmit using an NRF24L01+ without an Arduino?" Tags="|networking|system-design|remote-control|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1614" PostTypeId="2" ParentId="1612" CreationDate="2014-05-21T15:50:50.953" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P&quot; rel=&quot;nofollow&quot;&gt;nRF24L01+&lt;/a&gt; needs an external microcontroller to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe an XBee could be used if you want a &quot;single module&quot; solution, however using even the Atmega328p (standard for Arduino Uno) would probably be cheaper than this.&lt;/p&gt;&#xA;" OwnerDisplayName="user588" LastActivityDate="2014-05-21T15:50:50.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1615" PostTypeId="1" AcceptedAnswerId="1617" CreationDate="2014-05-21T15:51:17.457" Score="8" ViewCount="20839" Body="&lt;p&gt;I want to do something along the lines of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 4; i++) {&#xA;  analogRead(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which appears to work, but the following does not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 4; i++) {&#xA;  pinMode(i, INPUT);&#xA;  pinMode(i + 4, OUTPUT); // should make Analog Pin (i + 4) into an output&#xA;  digitalWrite(i + 4, LOW);&#xA;  analogRead(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, it appears to treat the pin addressed by &lt;code&gt;digitalWrite(i + 4, LOW);&lt;/code&gt; as one of the digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I really have to explicitly specify A0, A1, A2, ... anytime I want to loop over the analog pins?&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="889" LastEditDate="2014-05-21T18:06:36.593" LastActivityDate="2023-09-17T18:53:19.413" Title="How to loop over analog pins?" Tags="|programming|c++|analogread|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1616" PostTypeId="2" ParentId="1615" CreationDate="2014-05-21T17:57:15.597" Score="0" Body="&lt;p&gt;Your first loop will work just fine indeed, however, you might want to add &lt;code&gt;delay(1);&lt;/code&gt; after you &lt;code&gt;analogRead(i);&lt;/code&gt;, to give the ADC some time to settle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you elaborate on what you are trying to do with your second piece of code? As it looks right now, it doesn't really make sense to use &lt;em&gt;analog inputs&lt;/em&gt; as &lt;em&gt;digital outputs&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, you're trying to read a pin's input just a couple of lines after you specified the pin to be an output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please explain what you are trying achieve, so the nice folks around here can you help you better.&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-05-21T17:57:15.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1617" PostTypeId="2" ParentId="1615" CreationDate="2014-05-21T18:07:37.183" Score="11" Body="&lt;p&gt;Yes, the analog pins must be addressed using A0, A1,... when using them for digital I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the board you are using A0,A1,etc. are mapped to different values (for instance it looks like A0 is 18 on some boards but 14 on others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution for looping over the analog pins would be this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t analog_pins[] = {A0,A1,A2,A3,A4};&#xA;// Setup pins for input&#xA;for (int i = 0; i &amp;lt; 5; i++) { //or i &amp;lt;= 4&#xA;  digitalRead(analog_pins[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using the analog pins only with the &lt;code&gt;analogRead()&lt;/code&gt; call you can use 0,1,... instead of A0,A1,...&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="15453" LastEditDate="2015-12-10T15:28:27.243" LastActivityDate="2015-12-10T15:28:27.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1618" PostTypeId="1" CreationDate="2014-05-21T19:05:03.467" Score="7" ViewCount="12319" Body="&lt;p&gt;I followed a &lt;a href=&quot;http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/&quot; rel=&quot;noreferrer&quot;&gt;tutorial&lt;/a&gt; on how to setup arduino and bluetooth so it can be programmed without usb cables. I didn't use capacitors or resistors asthere doesn't seem to be a need for them. I have the serial output appearing on arduino serial console via bluetooth (no usb cable connected). Since the is a working connection that means it is working to a point. However when trying to upload I get &quot;avrdude: stk500_getsync(): not in sync: resp=0x4c&quot; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't connect pin 32 of hc-05 to arduino reset pin yet, could that be the issue? I don't actually need arduino to be reset since I can just kill the power to it manually at least for now. I also used 9600 as baud rate instead of 115200 as in the tutorial, because my arduino code used 9600 but maybe I misunderstood this and it actually needs to be 115200 regardless or my baud rate in arduino code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else could be the cause?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the answer by @sachleen I changed the baud rate as per the tutorial and soldered pin 32 of the hc-05 module to rst pin of arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After baud rate change opening arduino serial console no longer outputs anything. Why did this happen? I was getting serial output before when baud rate of hc-05 was 9600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After soldering the rst pin arduino also seems to reset after serial console is opened. I did not add the capacitor, is it required and if so why? I also excluded resistors since it seems they are only for voltage reduction from 5v to 3V (my arduino is 3.3V version).&lt;/p&gt;&#xA;" OwnerUserId="633" LastEditorUserId="633" LastEditDate="2014-05-22T21:27:07.140" LastActivityDate="2016-12-25T15:23:41.310" Title="Programming arduino via bluetooth module issue" Tags="|serial|bluetooth|arduino-pro-mini|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1619" PostTypeId="2" ParentId="1618" CreationDate="2014-05-21T19:10:29.773" Score="1" Body="&lt;p&gt;Both of those things will cause issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs to reset when its downloading a new sketch. You can manually reset it at just the right moment, but if you don't get the timing right, you'll get that issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The baud rate you set in your code for serial communication becomes irrelevant when you're loading a new sketch as that's set in the bootloader. Keep it at 115200 like the tutorial suggests.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-05-21T19:10:29.773" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1621" PostTypeId="1" AcceptedAnswerId="1629" CreationDate="2014-05-21T19:36:48.447" Score="2" ViewCount="4295" Body="&#xA;&#xA;&lt;p&gt;I have an Arduino reading serial data and responding to other inputs as well, I'm trying to read incoming serial data without using the while, if at all possible. the incoming serial data will be formatted in a specific manner each time and will be CSV; It will look like such:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;19,1400700083, 1-0,1-10,and other values delimited with a new line character &quot;/n&quot;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first value will tell how many bytes are coming in so the serial receive function wont parse data until it gets all the bytes,second value is a Unix time-stamp, the third value (1-0) is the &quot;get&quot; or set&quot; value; which will tell the Arduino to return a value or to set a value. The fourth (1-10) value will correspond to what variable to get or set. and the other values will be integers as well but are dependent on the other values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void CheckSerialData() { // begin function&#xA;&#xA;  if(Serial.available() &amp;gt;= 2) { // begin one, first line will be how many bytes incoming.&#xA;  int NumberOfIncomingBytes = Serial.parseInt();&#xA;    if(Serial.available() &amp;gt;= NumberOfIncomingBytes) { //begin two&#xA;    int IncomingTime = Serial.parseInt();&#xA;    setTime(IncomingTime); //time is always incoming with serial values&#xA;    int GetOrSetValue = Serial.parseInt(); //this value should be 1 or 0 for &quot;getting values(1)&quot; or &quot;setting values(0)&quot;&#xA;      if(GetOrSetValue == 1) { //BEGIN THREE&#xA;        int ValueToGet = Serial.parseInt(); &#xA;          switch(ValueToGet) {// BEGIN SWITCH&#xA;            case 0:&#xA;              Serial.print(GetTemp());&#xA;              Serial.print(&quot;/n&quot;);&#xA;              break;&#xA;            case 1:&#xA;              //serialwrite yaw pitch roll&#xA;              break;&#xA;            case 2:&#xA;              Serial.print(GetVoltage());&#xA;              Serial.print(&quot;/n&quot;);&#xA;              break;&#xA;            case 3:&#xA;              //append all RGB final values together and serial print it&#xA;              break;&#xA;            case 4:&#xA;              //print out accel values&#xA;              break;&#xA;            case 5:&#xA;              //print alarm alarmed status&#xA;              break;&#xA;            case 6:&#xA;              //print out last time alarm set off&#xA;              break;&#xA;            case 7:&#xA;              //print out time allowed lights to turn on&#xA;              break;&#xA;            case 8:&#xA;              //print out arduino time &#xA;              break;&#xA;            case 9:&#xA;              //print out system summary, (time,voltage,temp,yaw,pitch,roll,accel&#xA;              break;&#xA;&#xA;          }//END SWITCH&#xA;         }//END THREE &#xA;      else { //BEGIN TWO B //SET VALUES&#xA;      int ValueToGet = Serial.parseInt(); &#xA;          switch(ValueToGet) {// BEGIN SWITCH&#xA;            case 0:&#xA;              //set global rgb value set LEFT&#xA;              break;&#xA;            case 1:&#xA;              //set global rgb value set RIGHT&#xA;              break;&#xA;            case 2:&#xA;              //set global alarm value&#xA;              break;&#xA;            case 3:&#xA;              //set global angle to start flashing emergency led's&#xA;              break;&#xA;            case 4:&#xA;              //set turn signal RGB value&#xA;              break;&#xA;            case 5:&#xA;              //set time that lights are ok to turn on&#xA;              break;&#xA;            case 6:&#xA;              //set light override value&#xA;              break;&#xA;            case 7:&#xA;              //set pattern enable&#xA;              break;&#xA;&#xA;&#xA;          } //END SWITCH&#xA;&#xA;      }//END TWO B&#xA;&#xA;          }&#xA;        }//end two &#xA;      }//end one&#xA;    }//end function&#xA;    //**********************END SERIAL FUNCTION**************************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to know if this looks like it can work, or am I going about this all wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I don't have access to my Arduino currently to test the code)&lt;/p&gt;&#xA;" OwnerUserId="1671" OwnerDisplayName="Sam Williams" LastEditorUserId="10794" LastEditDate="2015-08-21T06:11:49.003" LastActivityDate="2015-08-21T06:11:49.003" Title="Arduino reading serial data non-blocking" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1624" PostTypeId="2" ParentId="1124" CreationDate="2014-05-22T04:06:34.130" Score="2" Body="&lt;p&gt;What model car do you have?  Most cars do not have the ability to control power windows from the car computer.  Late model cars will have the ability to control the window motors using bidirectional functions on a scan tool.  On any car, the window motors have two wires, if one wire is given power and one ground it will spin if you switch the wire that gets power with the wire that gets ground it spin in the opposite direction.  In my experience the way power windows work are both wires are ground while the switch is in the neutral position and by flipping the switch the switch will disconnect one of the grounds and replace it with a power.  Find a wiring diagram for your car, and look at how the windows are controlled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get a 2 relay breakout board such as this one (make sure you check the current ratings):&#xA;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0057OC6D8&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/SainSmart-2-CH-2-Channel-Relay-Module/dp/B0057OC6D8/ref=sr_1_1?ie=UTF8&amp;amp;qid=1400730995&amp;amp;sr=8-1&amp;amp;keywords=arduino+relay+12v&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the ground wire to the normally closed (when no power is applied to the relay this is connected to the output wire) side of both relays and the 12v power to the normally open (when power is applied to the relay this is connected to the output wire)side of both relays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to control the relay breakout board you choose one io pin per relay and set it as an output, then connect those pins to the corresponding pin on the breakout board. Set one of the pins to high (you apply power to one relay) the motor now has a power and a ground connection, set the opposite pin high to spin the other way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would place this in the driver side door underneath the window master switches because you can have access to every windows wires as they come out of the master switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some late model cars will have a different set up than the one described, but the window motor will only have two wires (it is just a brushed DC motor) just find the window motor and hookup there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="1192" LastEditDate="2014-10-30T02:36:30.990" LastActivityDate="2014-10-30T02:36:30.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1625" PostTypeId="1" CreationDate="2014-05-22T10:35:42.357" Score="6" ViewCount="6270" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EhaCw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is mine circuit. Intially i used arduino UNO directly for programming. Now i am Using atmega 328 IC for programming. I am trying to connect 32 hall sensor via Mux circut. I wanted to How to upload boot loader or HExfile Here. Will avr pocket programmer satisfy above circuit or i need to add addtional circuit here&#xA;&lt;a href=&quot;http://www.rhydolabz.com/index.php?main_page=product_info&amp;amp;products_id=597&quot; rel=&quot;noreferrer&quot;&gt;AVr pocket programmer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastActivityDate="2014-05-26T20:08:29.647" Title="bootloader uploading into Atmega328" Tags="|arduino-uno|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1626" PostTypeId="2" ParentId="1625" CreationDate="2014-05-22T11:01:43.010" Score="4" Body="&lt;p&gt;The AVR pocket programmer should work fine. Sparkfun has a &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader/connecting-the-programmer&quot; rel=&quot;nofollow noreferrer&quot;&gt;good guide for doing this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the pinout of the Atmega328:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/t7SJV.jpg&quot; alt=&quot;Atmega328 Pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll want to connect your programmer as follows (note, these are the pins for the bare Atmega328 chip &lt;em&gt;only&lt;/em&gt;. The pin numbers on an Arduino board are different.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Programmer Pin&amp;#09;&amp;#09;Atmega328 Pin&#xA;5V&amp;#09;&amp;#09;&amp;#09;Vcc (7)&#xA;GND&amp;#09;&amp;#09;&amp;#09;GND (8)&#xA;MOSI&amp;#09;&amp;#09;&amp;#09;Digital 11 / Physical 17&#xA;MISO&amp;#09;&amp;#09;&amp;#09;Digital 12 / Physical 18&#xA;SCK&amp;#09;&amp;#09;&amp;#09;Digital 13 / Physical 19&#xA;Reset&amp;#09;&amp;#09;&amp;#09;Reset (1)&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the physical pins on the chip are numbered differently than the logical pins. In the table above the &quot;Digital&quot; pin numbers are those colored yellow in the figure, while the &quot;Physical&quot; pins correspond to the black-on-white numbers around the edge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you already have the ICSP header connected to those pins (it's not completely clear in the schematic if that is the case), you can connect the programmer to those pins instead. This can be easy if you have a 6-pin ICSP cable with your programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you are already powering your Atmega328 from some other 5V power supply you can omit the &lt;code&gt;5V-Vcc&lt;/code&gt; pin. However, the programmer and the Atmega328 &lt;em&gt;must&lt;/em&gt; share a common ground, so be sure the GND pins are connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect your programmer to the computer using USB, open the Arduino IDE, select the correct serial port of the programmer, and pick &quot;Arduino Uno&quot; in the &quot;Board&quot; menu. You can program the bootloader by selecting &quot;Burn bootloader&quot; in the Tools menu, or you can simply write your program by selecting &quot;Uploading using programmer&quot; in the File menu.&lt;/p&gt;&#xA;" OwnerUserId="1472" LastActivityDate="2014-05-22T11:01:43.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1627" PostTypeId="1" CreationDate="2014-05-22T13:43:43.060" Score="0" ViewCount="567" Body="&lt;p&gt;I'd like to know which is the most powerful, lightest, and perhaps least expensive micro controller capable of running Arduino. &lt;/p&gt;&#xA;" OwnerUserId="1523" LastActivityDate="2014-05-22T16:29:04.773" Title="What is the smallest microcontroller capable of running Arduino?" Tags="|power|motor|wifi|" AnswerCount="1" CommentCount="5" ClosedDate="2014-06-09T15:51:11.097" ContentLicense="CC BY-SA 3.0" />
  <row Id="1628" PostTypeId="1" AcceptedAnswerId="1634" CreationDate="2014-05-22T15:05:13.280" Score="2" ViewCount="1787" Body="&lt;p&gt;I am new to Raspberry Pi (just brought mine before writing this post), and I am looking to see what is the most ideal way for two way communication between an Arduino and a Raspberry Pi (USB, SPI or I2C).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am asking is because I need to build a small, semi-autonomous robot and plan on using both the Arduino and Pi to control it, using the pins of the Arduino for the motor control and sensors and the Pi for video processing and autonomous part. Both will be on the robot itself. I am pretty good with the Arduino but never used a Raspberry Pi before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my biggest question is what would be the best form of communication for the two boards taking into account speed and safety (there is a voltage difference between the Pi and the Arduino).&lt;/p&gt;&#xA;" OwnerUserId="1529" LastEditorUserId="220" LastEditDate="2014-05-22T22:51:41.063" LastActivityDate="2014-05-26T13:15:35.060" Title="Arduino to Raspberry Pi wired communication" Tags="|arduino-mega|i2c|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1629" PostTypeId="2" ParentId="1621" CreationDate="2014-05-22T15:18:45.840" Score="2" Body="&lt;p&gt;Unfortunately your code could end up dropping data quite easily, or parsing it incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say your code has successfully read the first couple of bytes into &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt;. However, when it reaches &lt;code&gt;begin two&lt;/code&gt;, let's imagine the sender hasn't finished sending all the data yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code will drop through to &lt;code&gt;end two&lt;/code&gt;, discarding the &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt; value it just read. Next time round, it will start all over again from scratch, and attempt to read &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt; again. However, that data isn't there anymore. The next data waiting on serial will actually be the timestamp from the previous message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, it could end up parsing arbitrary data with unpredictable results, getting completely out-of-sync with the sender.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A way to fix it would be to store the &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt; value outside the function (e.g. as a global variable), along with a flag indicating if you're still waiting for the rest of the data to arrive. At the start of &lt;code&gt;CheckSerialData()&lt;/code&gt;, the code should check that flag. If it's true, then it should skip trying to read &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt;. Instead, go straight on to &lt;code&gt;begin two&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative approach would be to avoid using &lt;code&gt;NumberOfIncomingBytes&lt;/code&gt; at all. Each call to &lt;code&gt;CheckSerialData()&lt;/code&gt; would read whatever serial data is available, and accumulate it in a buffer. As soon as it hits a newline character, it will stop reading, and parse the data it's accumulated. If it runs out of serial data before it hits a newline, it should stop and carry on from there next time it's called.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-22T15:18:45.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1630" PostTypeId="2" ParentId="1627" CreationDate="2014-05-22T15:44:55.787" Score="6" Body="&lt;p&gt;Well, your questions is quite vague and perhaps overly broad.  I'll answer your main question &quot;what is the smallest,&quot; assuming you meant dimensionally, while keeping in mind that you also want the most powerful one in that size. The pricing of different chips like this will be fairly similar so I'll ignore that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I'm not sure what you meant by saying &quot;capable of running Arduino&quot; which may mean capable of having the Arduino bootloader installed or could mean being capable of running code written with Arduino libraries.  I'll assume the latter since it's the most practical requirement. I'll also assume you want an Atmel chip since it will be the most directly compatible with the Arduino libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is the most powerful of the smallest Atmel microcontrollers capable of running Arduino code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;The answer is probably the &lt;a href=&quot;http://www.digikey.com/product-detail/en/ATTINY10-MAHR/ATTINY10-MAHRCT-ND/2774321&quot;&gt;Attiny 10&lt;/a&gt; which comes in a 2 x 2mm 8-UFDFN Exposed Pad package, or a 2.9 x 1.6mm SOT-23-6 package for about one dollar in small quantities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see this &lt;a href=&quot;http://hackaday.com/2012/08/23/programming-the-attiny10-with-an-arduino/&quot;&gt;Hackaday article&lt;/a&gt; on how to use the Attiny10 with Arduino.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: After more research, I was unable to find an Arduino core for the Tiny10. So while you can program it with an Arduino using assembly or something, writing Arduino code for it won't work.  The smallest Attiny with an &lt;a href=&quot;https://www.google.com/search?num=20&amp;amp;q=attiny13%20arduino%20core&quot;&gt;Arduino core&lt;/a&gt; I could easily find is the &lt;a href=&quot;http://www.digikey.com/product-detail/en/ATTINY13A-MMU/ATTINY13A-MMU-ND/1914669&quot;&gt;Attiny13&lt;/a&gt; in a 3 x 3mm 10-VFDFN package.  The upside is that while not being that much bigger or more expensive, it's a way more capable chip for your project. &lt;/p&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2014-05-22T16:29:04.773" LastActivityDate="2014-05-22T16:29:04.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1632" PostTypeId="2" ParentId="1606" CreationDate="2014-05-22T20:23:14.880" Score="0" Body="&lt;p&gt;Yes, no problem running individual wires, and also like Craig says, only run the wires you need. For some inspiration, here's a project I did with a &lt;a href=&quot;http://forums.adafruit.com/viewtopic.php?f=22&amp;amp;t=44710&quot; rel=&quot;nofollow&quot;&gt;bit of hand wiring&lt;/a&gt;. And then there's &lt;a href=&quot;http://www.ducatimonsterforum.org/index.php?topic=64324.0&quot; rel=&quot;nofollow&quot;&gt;this project&lt;/a&gt; with kinda epic wiring.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-05-22T20:23:14.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1633" PostTypeId="1" AcceptedAnswerId="1636" CreationDate="2014-05-22T23:04:15.293" Score="3" ViewCount="549" Body="&lt;p&gt;Can I change the pins on the communication for a Master-Slave arduino Wire transmission? I want to communicate between 2 arduinos, but on one of them A4&amp;amp;A5 are taken&lt;/p&gt;&#xA;" OwnerUserId="1535" LastEditorUserId="368" LastEditDate="2014-05-23T01:42:24.313" LastActivityDate="2014-05-23T01:42:24.313" Title="Arduino Master-Slave Pins" Tags="|i2c|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1634" PostTypeId="2" ParentId="1628" CreationDate="2014-05-22T23:08:52.327" Score="1" Body="&lt;p&gt;Hands down, I can rule out the I&lt;sub&gt;2&lt;/sub&gt;C. &lt;a href=&quot;https://electronics.stackexchange.com/a/29041/18442&quot;&gt;This post sums it all up:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;SPI is faster.&lt;/li&gt;&#xA;  &lt;li&gt;I2C is more complex and not as easy to use if your microcontroller doesn't have an I2C   controller.&lt;/li&gt;&#xA;  &lt;li&gt;I2C only requires 2 lines.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since speed is your first priority, either do USB or SPI. I'd personally go with USB, just for the reason that it's simple. Nearly any programming language can inference with COM ports, but that's not the case with SPI. Also, for SPI, you would have to either use a level shifter, or do a voltage divider for the Arduino to RPi wires (for RPi to Arduino wires, Arduino can still sense 3.3V as HIGH.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;a href=&quot;https://arduino.stackexchange.com/a/299/220&quot;&gt;serial can be pretty fast&lt;/a&gt;. Technically, the Arduino can go up to 2 Mbps (not very fast compared to a lot of things, but fast enough for what the Arduino can even handle). One thing to note, the writer of the post stated that this is the highest you can practically achieve with the poorly optimized libraries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(500000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-05-22T23:08:52.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1636" PostTypeId="2" ParentId="1633" CreationDate="2014-05-22T23:50:31.530" Score="4" Body="&lt;p&gt;You cannot. Wire uses hardware I&lt;sup&gt;2&lt;/sup&gt;C, and on the Uno only A4 and A5 are connected to the TWI peripheral on the MCU. You will need to either switch to a bit-bang I&lt;sup&gt;2&lt;/sup&gt;C implementation or change the protocol you're using.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-22T23:50:31.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1637" PostTypeId="2" ParentId="1633" CreationDate="2014-05-23T00:25:19.000" Score="1" Body="&lt;p&gt;To complete Ignacio's answer, there's indeed no other hardware I2C on AVR Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only options you have to use other pins is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to use bitbang i2c, which is way slower ; &lt;/li&gt;&#xA;&lt;li&gt;or you can switch to the Arduino Due which features two TWI ports ; &lt;/li&gt;&#xA;&lt;li&gt;or you can use an SPI to I2C serial bridge such has &lt;a href=&quot;http://www.silabs.com/products/interface/spitoi2c/Pages/default.aspx&quot; rel=&quot;nofollow&quot;&gt;that one&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="379" LastActivityDate="2014-05-23T00:25:19.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1638" PostTypeId="5" CreationDate="2014-05-23T01:45:38.160" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/reference/wire&quot; rel=&quot;nofollow&quot;&gt;Wire&lt;/a&gt; library is used for both master and slave I&lt;sup&gt;2&lt;/sup&gt;C/TWI devices using the hardware peripheral on the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For physical wiring between the Arduino and other devices, use &lt;a href=&quot;/questions/tagged/wires&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;wires&amp;#39;&quot; rel=&quot;tag&quot;&gt;wires&lt;/a&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-05-23T02:44:01.473" LastActivityDate="2014-05-23T02:44:01.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1639" PostTypeId="4" CreationDate="2014-05-23T01:45:38.160" Score="0" Body="Use this tag for the Wire library, used for I2C/TWI communication." OwnerUserId="368" LastEditorUserId="220" LastEditDate="2014-05-23T02:43:47.957" LastActivityDate="2014-05-23T02:43:47.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1640" PostTypeId="1" CreationDate="2014-05-23T02:21:04.953" Score="-2" ViewCount="462" Body="&lt;p&gt;We need to control many leds, about 40 with arduino (UNO) and we need some remain turned on and other off at the same time. Muted or pinned vary constantly. &#xA;What should I use to do this, I have several Multiplexers CD4051 but with these I can just light a LED at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do some calculation and then need to turn LEDs 1,2,5,7 and need to be pinned to the following calculation. In the following calculation I need to turn leds 4, 5, 10, 12 pinned and need to follow. What I need is something like that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the multiplexer I can turn the LEDs I need and with minimal delay and it seems they are apprehended while, but I want to know if there is another alternative to do so&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="25788" LastEditDate="2016-09-19T02:51:42.430" LastActivityDate="2016-09-19T12:45:36.237" Title="controlling LEDs, few pin outputs lots of LEDs" Tags="|led|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1641" PostTypeId="1" AcceptedAnswerId="1685" CreationDate="2014-05-23T02:42:16.987" Score="1" ViewCount="232" Body="&lt;p&gt;I' making a Simon game with the arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know something is wrong with the inputs but i don't know why or how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the program takes an input and says it is correct no matter what it is or the length&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NOTES&#xA;&#xA;int tones[] = {NOTE_E5, NOTE_E6, NOTE_CS6, NOTE_A6};&#xA;String sequence;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT); //green&#xA;    pinMode(12, OUTPUT); //yellow&#xA;    pinMode(11, OUTPUT); //blue&#xA;    pinMode(10, OUTPUT); //red&#xA;    pinMode(7, INPUT); //green&#xA;    pinMode(6, INPUT); //yellow&#xA;    pinMode(5, INPUT); //blue&#xA;    pinMode(4, INPUT); //red&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    while(true) {&#xA;        delay(1000);&#xA;        randomSeed(random(random(1000000000)));&#xA;        sequence = String(random(4));&#xA;        boolean run = true;&#xA;        while(run) {&#xA;            for(int i = 0; i &amp;lt; sequence.length(); i++) {&#xA;                simonOut(sequence.charAt(i) - '0');&#xA;                delay(500);&#xA;                simonClear();&#xA;                delay(100);&#xA;            }&#xA;            for(int i = 0; i &amp;lt; sequence.length(); i++) {&#xA;                int input = simonIn();&#xA;                while(input &amp;lt; 0 || input &amp;gt; 3) {&#xA;                    delay(50);&#xA;                    input = simonIn();&#xA;                }&#xA;                if(sequence.charAt(i) - '0' == input) {&#xA;                    flash(0);&#xA;                    run = false;&#xA;                    goto reset;&#xA;                }&#xA;                else if(i = sequence.length() - 1)&#xA;                    flash(3);&#xA;            }&#xA;            sequence += random(4);&#xA;        }&#xA;        reset:;&#xA;    }&#xA;}&#xA;&#xA;void boolOut(long pin, boolean val) {&#xA;    digitalWrite(pin,val ? HIGH : LOW);&#xA;}&#xA;&#xA;void simonOut(long num) {&#xA;    boolOut(num + 10, true);&#xA;    tone(2, tones[num]);&#xA;}&#xA;&#xA; void flash(int led) {&#xA;     delay(300);&#xA;     for(int i = 0; i &amp;lt; 5; i++) {&#xA;         simonOut(led);&#xA;         delay(100);&#xA;         simonClear();&#xA;         delay(100);&#xA;     } &#xA; }&#xA;&#xA; void simonClear() {&#xA;     for(int i = 0; i &amp;lt; 4; i++){&#xA;         boolOut(i + 10, false);&#xA;     }&#xA;     noTone(2);&#xA; }&#xA;&#xA; int simonIn() {&#xA;     int ret = -1;&#xA;     for(int i = 0; i &amp;lt; 4; i++) {&#xA;         if(simonIn(i)){&#xA;             ret = i;&#xA;         }&#xA;     }&#xA;     if(ret != -1) {&#xA;         simonOut(ret);&#xA;         delay(500);&#xA;         simonClear();&#xA;         delay(100);&#xA;     }&#xA; }&#xA;&#xA; boolean simonIn(long num) {&#xA;     return digitalRead(num + 4) == HIGH;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1537" LastEditorUserId="84" LastEditDate="2014-05-25T06:24:31.680" LastActivityDate="2014-05-25T06:49:13.240" Title="help with input in a Simon arduino uno game" Tags="|arduino-uno|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1642" PostTypeId="2" ParentId="1640" CreationDate="2014-05-23T03:18:40.090" Score="3" Body="&lt;p&gt;The most common technique for doing this is called &lt;a href=&quot;http://en.wikipedia.org/wiki/Multiplexed_display&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;multiplexing&quot;&lt;/a&gt;. You arrange the 40 LEDs into 8 &quot;columns&quot; and 5 &quot;rows&quot; with common anodes and cathodes, and then you switch the columns or rows on or off individually, activating only the LEDs you want lit for that column or row. If done quickly enough it appears to the human eye that the LEDs are always lit due to &lt;a href=&quot;http://en.wikipedia.org/wiki/Persistence_of_vision&quot; rel=&quot;nofollow noreferrer&quot;&gt;persistence of vision&lt;/a&gt;. Note that the &lt;em&gt;physical&lt;/em&gt; display does not need to be a rectangle; this is simply the &lt;em&gt;logical&lt;/em&gt; arrangement used in order to simplify the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UCqdw.gif&quot; alt=&quot;LED multiplexing demonstration&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(note that the cathode side of the above image is wrong; the cathode needs to be &lt;strong&gt;low&lt;/strong&gt; when you want the LED to light)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.franksworkshop.com.au/Electronics/RGB/RGB.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;(source)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A naive implementation with 8 columns and 5 rows would use 13 pins to connect them all. However, since you don't need more than one column at a time what you can do is use a &lt;a href=&quot;http://www.ti.com/product/cd74hct138&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC138/238&lt;/a&gt; to use 3 inputs to control which of the 8 columns you want to activate. This drops the number of required pins to 8, which is low enough for anything larger than a ATtinyX5. Use of a 74HC595 for the 8 pins further drops the required MCU pins to 3, which is low enough for even a ATtiny4/5/9/10, but the timing is harder to get right due to the shift register.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-23T03:18:40.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1643" PostTypeId="1" CreationDate="2014-05-23T05:39:10.183" Score="-2" ViewCount="3109" Body="&lt;pre&gt;&lt;code&gt;int sensorArray[32] ;&#xA;int selectPinZero = 8;&#xA;int selectPinOne = 9;&#xA;int selectPinTwo = 10;&#xA;int selectpinthree=11;&#xA;int Enablepin=7;&#xA;&#xA;int inputPinOne = 0;&#xA;int inputPinTwo = 1;&#xA;&#xA;&#xA;&#xA;int sensor1;&#xA;int sensor2;&#xA;int voltage1;&#xA;int voltage2;&#xA;int Current_Sensor1[16];&#xA;int Current_Sensor2[16];&#xA;int row;&#xA;int column;&#xA;&#xA;int array[17][5]={&#xA;                    {0,0,0,0,0},&#xA;                    {0,0,0,0,1},&#xA;                    {0,0,0,1,0},  &#xA;                    {0,0,0,1,1},&#xA;                    {0,0,1,0,0},&#xA;                    {0,0,1,0,1},&#xA;                    {0,0,1,1,0},&#xA;                    {0,0,1,1,1},&#xA;                    {0,1,0,0,0},&#xA;                    {0,1,0,0,1 },&#xA;                    {0,1,0,1,0},&#xA;                    {0,1,0,1,1},&#xA;                    {0,1,1,0,0 },&#xA;                    {0,1,1,0,1},&#xA;                    {0,1,1,1,0 },&#xA;                    {0,1,1,1,1}, &#xA;                    {1,0,0,0,0} &#xA;                 };&#xA;&#xA;&#xA;unsigned long StopTime=0;&#xA;int Counter=0;&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);&#xA;  pinMode(selectPinZero, OUTPUT);&#xA;  pinMode(selectPinOne, OUTPUT);&#xA;  pinMode(selectPinTwo, OUTPUT);&#xA;  pinMode(selectpinthree,OUTPUT);&#xA;&#xA;  pinMode(inputPinOne, INPUT);&#xA;  pinMode(inputPinTwo, INPUT);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  for(row=0;row&amp;lt;17;row++)&#xA;  {&#xA;&#xA;    digitalWrite(Enablepin,array[row][0]);&#xA;    digitalWrite(selectPinZero,array[row][1]);&#xA;    digitalWrite(selectPinOne,array[row][2]);&#xA;    digitalWrite(selectPinTwo,array[row][3]);  &#xA;    digitalWrite(selectpinthree,array[row][4]);  &#xA;    sensor1=analogRead(inputPinOne);&#xA;    sensor2=analogRead(inputPinTwo);&#xA;    voltage1=sensor1 * ARDUINO_ANALOG_SCALING;&#xA;    voltage2=sensor2* ARDUINO_ANALOG_SCALING;&#xA;    Current_Sensor1[row]=(10*voltage1)-25;&#xA;    Current_Sensor2[row]=(10*voltage2)-25;&#xA;    Serial.print(&quot;Currentsensor1:&quot;);&#xA;    Serial.println( Current_Sensor1[row]);&#xA;    Serial.print(&quot;Currentsensor2:&quot;);&#xA;    Serial.println( Current_Sensor2[row]);&#xA;     Counter=Counter+1;&#xA;    Serial.print(&quot;Counter:&quot;);&#xA;    Serial.println(Counter);&#xA;    Serial.println(&quot;.......................&quot;);&#xA;        delay(1000);&#xA;&#xA;&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my Arduino code. I wanted to activate Digital pin for every 1000ms delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During each delay the analog value should be stored in an array of index.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to keep track of analog value read, or from which port I am reading. I could flicker the LED on the hardware side but it doesn't make any sense. Any method you can suggest here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Application:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 32 hall sensors connected via mux circuit. I wanted to know which sensor is reading value. I want any idea to might suggest to me to keep track here.&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="10794" LastEditDate="2015-07-18T05:12:44.553" LastActivityDate="2015-07-18T05:12:44.553" Title="Timestamp in Arduino" Tags="|arduino-uno|programming|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1645" PostTypeId="1" CreationDate="2014-05-23T11:28:12.860" Score="2" ViewCount="1198" Body="&lt;p&gt;Can somebody point me in the right direction for information on sending data to an Arduino nano?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project is to send data that is updated from a GUI (presently written in Python) to an Arduino nano that then makes adjustments to a number of servo motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the servo code working but am presently using potentiometers to control the servo positions &amp;amp; would like the control done via a GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What libraries would I need to be looking at. Have any of you done anything similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nic&lt;/p&gt;&#xA;" OwnerUserId="1544" LastActivityDate="2014-05-23T11:47:03.613" Title="Sending data from a GUI to an Arduino nano via USB" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1647" PostTypeId="2" ParentId="1595" CreationDate="2014-05-20T06:12:37.813" Score="0" Body="&lt;p&gt;Yes it is  OK to do that. But the thing you should consider in mind is &quot;What is the current requirement of the motor?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to motor a small motor with a 9V battery and control it with PWM&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means you have a servo motor, which might require a lot of current depending on the torque. So if you have a battery with low 'mAh', your battery will dry out very quickly. This might or might not be a problem for you depending on your requirements.&lt;/p&gt;&#xA;" OwnerUserId="1372" OwnerDisplayName="Damon" LastActivityDate="2014-05-20T06:12:37.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1648" PostTypeId="2" ParentId="1645" CreationDate="2014-05-23T11:47:03.613" Score="1" Body="&lt;p&gt;Arduino Nano supports FTDI i.e. Virtual Serial Port. So all you have to do is initialize the serial communication using &lt;a href=&quot;https://pypi.python.org/pypi/pyserial&quot; rel=&quot;nofollow&quot;&gt;pySerial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the data is entered into the GUI, store it in some variables. Send the data in variables to Arduino using Serial Communication. You might have design your own communication protocol on top of Virtual Serial Port in order to identify the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use the same library to send the acknowledgement or some data from Arduino to PC, if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps you. &lt;/p&gt;&#xA;" OwnerUserId="1372" LastActivityDate="2014-05-23T11:47:03.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1649" PostTypeId="1" AcceptedAnswerId="1650" CreationDate="2014-05-23T12:15:52.510" Score="2" ViewCount="2476" Body="&lt;p&gt;just saw this tweet and was interested what wires are used there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://twitter.com/EngineersGarage/status/448014811280842752/photo/1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://twitter.com/EngineersGarage/status/448014811280842752/photo/1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2fssl.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring Looks cleaner than the setup I currently have with &quot;normal&quot; wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1484" LastActivityDate="2016-11-22T17:35:45.133" Title="How to improve wiring a breadboard?" Tags="|wires|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1650" PostTypeId="2" ParentId="1649" CreationDate="2014-05-23T12:49:36.353" Score="6" Body="&lt;p&gt;I think the wire itself is perfectly normal. It looks like he's simply soldered right-angled header pins onto the ends. That way, the wires can lie flat on the breadboard instead of being bent over for connections, meaning the whole thing is lower-profile and a little easier to route neatly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also has the advantage that they will probably survive far more insertions/removals. With that said, it brings the disadvantage that it exposes the contacts more above the surface of the board, which could increase the risk of accidental connections (short circuits and such like).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-23T12:49:36.353" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1651" PostTypeId="1" AcceptedAnswerId="1864" CreationDate="2014-05-23T15:28:21.017" Score="1" ViewCount="1876" Body="&lt;p&gt;in the below Fritzing diagram, I have a button that has a pull-up resistor, which when pressed, sets the GPIO Pin 23 to HIGH. On the Raspberry Pi, when the button is released, the GPIO goes LOW. The Raspberry Pi detects when the button is released and pressed. This is my desired behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in my current configuration, I have PIN 13 connected to the Base of a NPN transistor to try to simulate the same behavior as the button with a pull-up resistor. When pin 13 is set to high, it sets the GPIO 22 Pin to high. When I set the Arduino Pin 13 to low, The GPIO Pin goes low but the Raspberry PI does not detect that GPIO 22 pin went low. Is there a way to simulate the same behavior as a button with a pull-up resistor with an OUTPUT pin from the arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bejPK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-06-06T17:53:28.280" Title="Setting a Pin to HIGH to simulate a button with a &quot;pull up&quot; resistor" Tags="|pins|resistor|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1652" PostTypeId="1" CreationDate="2014-05-23T15:30:20.167" Score="2" ViewCount="257" Body="&lt;p&gt;It seems they stop the production of arduino starter kit (official), it's hard to find it on pro website.&#xA;Is there an other very good starter kit to start ? I mean I would like to try everything on small given project before starting my own project. &lt;/p&gt;&#xA;" OwnerUserId="1549" LastActivityDate="2014-12-16T03:57:28.120" Title="Is arduino starter kit disappearing?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1653" PostTypeId="2" ParentId="1652" CreationDate="2014-05-23T16:03:56.810" Score="1" Body="&lt;p&gt;Make has one: &lt;a href=&quot;http://www.makershed.com/Getting_Started_with_Arduino_Kit_v3_0_p/msgsa.htm&quot; rel=&quot;nofollow&quot;&gt;Getting Started with Arduino Kit v3.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="11" LastEditDate="2014-05-23T16:08:33.503" LastActivityDate="2014-05-23T16:08:33.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1654" PostTypeId="2" ParentId="1643" CreationDate="2014-05-23T17:37:44.813" Score="1" Body="&lt;p&gt;You should download timer1 library from &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Timer1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Init timer1 with a value of 1000000 and it will perform an overflow every second. On every overflow it will perform an action, put your code to activate a pin there. And do the serial readings in your loop. &lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-05-23T17:37:44.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1655" PostTypeId="2" ParentId="1641" CreationDate="2014-05-23T18:15:57.320" Score="1" Body="&lt;p&gt;Is it possible that your problem might be just a typo? &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;#define NOTES&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;int tones[] = {NOTE_E5, NOTE_E6, NOTE_CS6, NOTE_A6};&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your array you talk about NOTE and you defined NOTES (See the S?)&lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-05-23T18:15:57.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1657" PostTypeId="2" ParentId="1625" CreationDate="2014-05-23T18:29:28.510" Score="0" Body="&lt;p&gt;Uploading Hexfile to your arduino can be done using this application:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://kmtronic.com/upload-hex-files-to-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://kmtronic.com/upload-hex-files-to-arduino.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is how you upload an Arduino Bootloader on an empty ATmega328 / ATmega328P-PU. Using an Arduino. (No need for a separate ISP Programmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Arduino Uno to other Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open the ArduinoISP firmware (in Examples) to your Arduino board.&lt;/li&gt;&#xA;&lt;li&gt;Select the items in the Tools &gt; Board and Serial Port &gt; Arduino Uno.&lt;/li&gt;&#xA;&lt;li&gt;Upload the ArduinoISP sketch.&lt;/li&gt;&#xA;&lt;li&gt;Wire your Arduino board to the target as shown in the diagram below. (Note: you'll need to add a 10 uF capacitor between reset and ground.)&lt;/li&gt;&#xA;&lt;li&gt;Also connect TX from Arduino A to the RX of Arduino B and RX from Arduino A to TX Arduino B.&lt;/li&gt;&#xA;&lt;li&gt;Select Target Board in Tools &gt; Board &gt; Arduino Duemilanove w/ ATmega328&lt;/li&gt;&#xA;&lt;li&gt;Select programmer in Tools &gt; Programmer &gt; Arduino as ISP&lt;/li&gt;&#xA;&lt;li&gt;Use the Burn Bootloader &gt; Arduino as ISP command.&lt;/li&gt;&#xA;&lt;li&gt;Go to Tools and Select Burn Bootloader. Done.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cVfzF.png&quot; alt=&quot;Upload to other Arduino Board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To upload on a breadboard without External clock.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Download: &lt;a href=&quot;http://arduino.cc/en/uploads/Tutorial/Breadboard.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;Breadboard.zip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Put boards.txt in your Arduino directory under Hardware &gt; ATmega328. (For windows usually (C:/Program files/Arduino/Hardware/ATmega/boards.txt))&lt;/li&gt;&#xA;&lt;li&gt;Close Arduino IDE and reopen it.&lt;/li&gt;&#xA;&lt;li&gt;Open the ArduinoISP firmware (in Examples) to your Arduino board.&lt;/li&gt;&#xA;&lt;li&gt;Select the items in the Tools &gt; Board and Serial Port &gt; Arduino Uno.&lt;/li&gt;&#xA;&lt;li&gt;Upload the ArduinoISP sketch.&lt;/li&gt;&#xA;&lt;li&gt;Hook pin13 from Arduino to pin19 on Chip&lt;/li&gt;&#xA;&lt;li&gt;Pin12 from Arduino to pin18 on chip&lt;/li&gt;&#xA;&lt;li&gt;Pin11 from Arduino to pin17 on chip&lt;/li&gt;&#xA;&lt;li&gt;Pin10 from Arduino to pin1 on chip&lt;/li&gt;&#xA;&lt;li&gt;pin0 from Arduino to pin3 on chip&lt;/li&gt;&#xA;&lt;li&gt;pin1 from Arduino to pin2 on Chip&lt;/li&gt;&#xA;&lt;li&gt;connect 5V from Arduino to pins 7 and 20 on chip&#xA;14, connect GND from Arduino to pins 8 and 22 on chip&lt;/li&gt;&#xA;&lt;li&gt;Select Target Board in Tools &gt; Board &gt; ATmega328 on breadboard (8 MHz internal clock)&lt;/li&gt;&#xA;&lt;li&gt;Select programmer in Tools &gt; Programmer &gt; Arduino as ISP.&lt;/li&gt;&#xA;&lt;li&gt;Select Tools &gt; Burn Bootloader. Done.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It's also possible with an Arduino Leonardo but you'll have to change some settings for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: You will need to put target board to Arduino Duemilanove w/ ATmega328 for programming the new chip (Uploading a code to it) instead of targeting Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="1532" LastEditorUserId="1532" LastEditDate="2014-05-26T20:08:29.647" LastActivityDate="2014-05-26T20:08:29.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1658" PostTypeId="1" AcceptedAnswerId="1675" CreationDate="2014-05-23T16:12:59.897" Score="0" ViewCount="2458" Body="&lt;p&gt;I'm adapting a sketch I found to send sensor data over a wifi chip (Nrf2401), and although I get the message through, the value I send contains decimals (e.g. 24.59), but the received message will only be 24.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there's something wrong on the transmitter part of the code, but I can't see what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;RF24_config.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;OneWire oneWire(4);&#xA;&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;// ce,csn pins&#xA;RF24 radio(8,7);&#xA;&#xA;// init data buffer to hold a sensor type byte and one uint16_t sensor data&#xA;unsigned char data[3] = {&#xA;  0};&#xA;unsigned long count=0;&#xA;void setup(void)&#xA;{&#xA;  sensors.begin();  &#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;**************V1 Send Sensor Data***********&quot;);&#xA;  radio.begin();&#xA;  radio.setPALevel(RF24_PA_LOW);&#xA;  radio.setChannel(0x4c);&#xA;&#xA;  // open pipe for writing&#xA;  radio.openWritingPipe(0xF0F0F0F0E1LL);&#xA;&#xA;  radio.enableDynamicPayloads();&#xA;  radio.setAutoAck(true);&#xA;  radio.powerUp();&#xA;  Serial.println(&quot;...Sending&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;&#xA;  sensors.requestTemperatures();&#xA;  float currentTemp;&#xA;  currentTemp = sensors.getTempCByIndex(0);&#xA;&#xA;&#xA;  //assign 'T' to represent a Temperature reading&#xA;  data[0] = 'T';&#xA;&#xA;  data[1] = currentTemp;&#xA;&#xA;  count++;&#xA;&#xA;  sprintf(data, &quot;T %5.2f\n&quot;, currentTemp);  // build command in data[]&#xA;  radio.txMode(strlen(data));               // set # bytes to xmit&#xA;  radio.write(data);                        // send bytes&#xA;&#xA;  // print and increment the counter&#xA;  Serial.print(&quot;Temperature sent:  &quot;);&#xA;  Serial.println(currentTemp);&#xA;  // pause a second&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, when I print currentTemp, it will display the decimals, but if I print data[1], it won't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified the code to include the answer from JRobert (updated code above), but it comes back the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nrf24SendSensorDataV1_ino.cpp: In function 'void loop()':&#xA;nrf24SendSensorDataV1_ino:56: error: invalid conversion from 'unsigned char*' to 'char*'&#xA;nrf24SendSensorDataV1_ino:56: error: initializing argument 1 of 'int sprintf(char*, const char*, ...)'&#xA;nrf24SendSensorDataV1_ino:57: error: 'class RF24' has no member named 'txMode'&#xA;nrf24SendSensorDataV1_ino:57: error: invalid conversion from 'unsigned char*' to 'const char*'&#xA;nrf24SendSensorDataV1_ino:57: error: initializing argument 1 of 'size_t strlen(const char*)'&#xA;nrf24SendSensorDataV1_ino:58: error: no matching function for call to 'RF24::write(unsigned char [3])'&#xA;C:\Users\Zuh\Downloads\arduino-1.0.1\libraries\RF24L01/RF24.h:281: note: candidates are: bool RF24::write(const void*, uint8_t)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made a dirty fix that will solve the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the transmitter code I've added:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t sensorValue = currentTemp*100;&#xA;//do the bit shift to put uint16 into uint8 array&#xA;data[1] = sensorValue &amp;gt;&amp;gt; 8;&#xA;data[2] = sensorValue;&#xA;// print and increment the counter&#xA;radio.write(data, sizeof(uint16_t)+1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will send the (temperature value)*100&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the receiver end, I just convert the uint16_t to a float element and divide it by 100.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t sensorValue = data[2] | data[1] &amp;lt;&amp;lt; 8;&#xA;float temp = (float) sensorValue/100;&#xA;Serial.print(&quot;T: &quot;); &#xA;Serial.println(temp); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Dirty, but effective!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks guys for the help, it really pointed me and my lousy programming skills to the right direction.&lt;/p&gt;&#xA;" OwnerUserId="1554" OwnerDisplayName="Eric Mitjans" LastEditorUserId="1554" LastEditDate="2014-05-25T23:19:56.970" LastActivityDate="2014-05-25T23:19:56.970" Title="Decimals missing when using radio.write(); with Arduino" Tags="|wifi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1659" PostTypeId="2" ParentId="1658" CreationDate="2014-05-23T16:25:01.020" Score="0" Body="&lt;p&gt;Since I can't comment yet I will place this as answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But have you tried to use &lt;code&gt;radio.print(data[1], DEC);&lt;/code&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DEC stands for Decimal for if you want to force something to print it in Decimals. When you want something to be printed in Hexadecimals you can use HEX for example. Hope this will help you. &lt;/p&gt;&#xA;" OwnerUserId="1532" OwnerDisplayName="Handoko" LastEditorUserId="11" LastEditDate="2014-05-23T19:37:06.720" LastActivityDate="2014-05-23T19:37:06.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1660" PostTypeId="2" ParentId="1658" CreationDate="2014-05-23T16:25:54.277" Score="0" Body="&lt;p&gt;data[] is an array of three chars.  You assign the letter &quot;T&quot; to data[0] (the first char of the array), then data[1] = currentTemp attempts to assign a float to the second char in the data array - floats won't fit in chars.&lt;/p&gt;&#xA;" OwnerUserId="1498" OwnerDisplayName="Peter Bennett" LastActivityDate="2014-05-23T16:25:54.277" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1661" PostTypeId="1" AcceptedAnswerId="1670" CreationDate="2014-05-23T19:37:45.530" Score="2" ViewCount="9937" Body="&lt;p&gt;I'm using an Arduino Leonardo to interface with two pressure sensors and Python on my laptop, a MackBook Pro. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using arduino IDE V. 1.5.4, Python V. 2.7.6, and OSX 10.8.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One pressure sensor is digital, using the Wire lib, and the other is analog.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch compiles, runs, and works until I try to get the data in Python using pyserial.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I try to grab a bunch of data using the readlines method in the scrip it will only return blank data or hang, depending on the serial object timeout settings. My python code sometimes works from the repl when I initialize the serial object and wait before reading from it.  If I don't wait the serial object will only partially fill a list and then any future reads will return an empty string.  This continues even after closing the serial object and reopening it in Python, or closing the serial object in Python and then opening the Serial Monitor in the Arduino IDE.  Once the serial port stops sending, I have to reset the Leonardo in order to read new data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could be running into some kind of buffering problem, but if that were the case I would expect future calls to return data.  Another option is that the Wire protocol is getting stuck and halting the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int ADDRESS = 0x28;//I2C address of sensor&#xA;int REQUEST = 4;//# of bytes to request from sensor&#xA;int BAUD = 19200;//serial rate&#xA;int PRESSURE_PIN = 1;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(A1, INPUT);&#xA;  Wire.begin();        // join i2c bus (address optional for master)&#xA;  Serial.begin(BAUD);  // start serial for output&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Wire.requestFrom(ADDRESS, REQUEST);    // request 6 bytes from slave device #2&#xA;&#xA;  Serial.print(analogRead(PRESSURE_PIN));&#xA;  Serial.print(',');&#xA;&#xA;  while(Wire.available())    // slave may send less than requested&#xA;  { &#xA;     Serial.print(((unsigned int)Wire.read() &amp;lt;&amp;lt; 8) + Wire.read());&#xA;     Serial.print(',');&#xA;     Serial.println(((unsigned int)Wire.read()) &amp;lt;&amp;lt; 3) + (Wire.read() &amp;gt;&amp;gt; 5);&#xA;  }&#xA;&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is how I read it from python &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;&#xA;serial_port = '/dev/tty.usbmodem1a1221'&#xA;ser = serial.Serial(serial_port, 19200, timeout=0)&#xA;&#xA;vals = [val.split(',')[0:2] for val in ser.readlines(1001*14)]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1553" LastActivityDate="2014-05-30T15:07:43.167" Title="Why does serial port stop sending data?" Tags="|serial|python|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1663" PostTypeId="2" ParentId="1651" CreationDate="2014-05-23T21:40:39.180" Score="0" Body="&lt;p&gt;If you don't mind using SMD components you could use the NX3V1G66 analog switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you send a signal to the IC it will simulate a push button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there are leaded versions of this IC but I haven't found them on the website where I order all my components. &lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-05-23T21:40:39.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1664" PostTypeId="2" ParentId="1651" CreationDate="2014-05-23T22:20:03.800" Score="1" Body="&lt;p&gt;First of all, I don't think you will need &lt;em&gt;full&lt;/em&gt; simulation of a button. There are a couple of things this approach won't have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bouncing: it'll be (kinda, minus interference) a square wave. With a real button, the metal contacts &quot;bounce,&quot; thus creating a weird waveform. Depending on interference, you'll still need debouncing code, although I would be surprised if it was necessary. I'd inlcude it in case I modified it to add a real button and/or there's some weird interference.&lt;/li&gt;&#xA;&lt;li&gt;The time it's &quot;pushed&quot; may be very short, depending on your code. Keep this in mind when designing this.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, you're hooking up the Arduino and the RPi together, with a voltage divider or a level shifter between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltage divider:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ia8Nw.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/voltage-dividers/all?print=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is a voltage regulator (drawn four different ways; it's the same circuit). I calculated the values you will need: 1700 ohm for R1, 3300 ohm for R2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, serial (with USB of the Arduino) communication would be a lot easier...&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-23T22:20:03.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1665" PostTypeId="2" ParentId="1661" CreationDate="2014-05-23T22:34:36.490" Score="0" Body="&lt;p&gt;The Arduino forums talk the Arduino resetting when the serial port is opened. A solution as stated in the forums is to add a short delay. See if that works.&#xA;&lt;br&gt;Source: &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,18371.0.html&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,18371.0.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1557" LastActivityDate="2014-05-23T22:34:36.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1667" PostTypeId="1" AcceptedAnswerId="1668" CreationDate="2014-05-24T08:57:55.190" Score="4" ViewCount="2557" Body="&lt;p&gt;i just bought the starter kit and am currently working my way through the examples in the book when i came across some numbers used in the manual that seems a little too specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in project #3,the love-o-meter, i had to divide the sensor value by 1024.0, and the explanation for it was never given in the manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, in project #4(which i'm currently at), the book states that i have to convert sensor readings from 0 - 1023, to a value between 0 to 255.Is the number 1024/1023 simply an arbitrary number/limit set by the sensor's manufacturers? Also, is they any significance or reason that analogueWrite only accepts positive values up to 255?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1563" LastActivityDate="2014-05-25T20:48:11.840" Title="Significance of the numbers used in the manual" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1668" PostTypeId="2" ParentId="1667" CreationDate="2014-05-24T10:25:55.530" Score="4" Body="&lt;p&gt;The range 0 - 1023 comes from the analog-to-digital converters (ADC) built-in to your Arduino. What they do is take a voltage reading (e.g. from your sensor) and compare it to the analog reference voltage (which is typically 5 volts, although it can be changed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It converts that reading to a binary number. The ADCs on board a typical Arduino have 10 bits of precision. The maximum number you can represent with 10 binary bits is 1023. Therefore, a reading of 0V is converted to the number 0; a reading of 5V is converted to the number 1023; and so on (it handles all the in-between values too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;analogWrite()&lt;/code&gt; works quite differently. It's not actually producing a varying voltage on the output (i.e. it's not true digital-to-analog conversion). Instead, it's using Pulse Width Modulation (PWM) to do something similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means it sends lots of 5V pulses on the output in quick succession. The 0 - 255 values you give it affect the duty cycle -- that is, how long each pulse is compared to the gaps between pulses. The longer the pulses are, the 'stronger' the signal is. This is very useful for applications such as controlling the brightness of an LED or the speed of a basic DC motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PWM signal is controlled by timers built-in to the microcontroller. I suspect it's the capabilities of those timers which determine the input range for &lt;code&gt;analogWrite()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get more information from the online documentation for Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/Reference/AnalogRead&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/Reference/AnalogWrite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-05-24T10:25:55.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1669" PostTypeId="1" AcceptedAnswerId="1694" CreationDate="2014-05-24T11:31:06.060" Score="2" ViewCount="772" Body="&lt;p&gt;I've got a cmps10 compass module hooked up to my arduino due through a logic level converter. I am writing code to convert the raw magnetometer readings into a bearing that I can use but have run into a huge problem. My bearings are all funky for some reason. They are totally unrelated to the actual bearing of the robot. I know the sensor is fine because I am able to get the tilt compensated reading from it and it works great. One thing I noticed is that the magnetometer reading on the X-axis is always positive could this be the problem? The X-axis high byte generally between 0x00 and 0x03. My code is below (i2cBus = &amp;amp;Wire)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i2cBus-&amp;gt;beginTransmission(I2C_Address);           &#xA;i2cBus-&amp;gt;write(byte(10));                              &#xA;i2cBus-&amp;gt;endTransmission();&#xA;&#xA;i2cBus-&amp;gt;requestFrom(I2C_Address, 4);&#xA;xMagHighByte = i2cBus-&amp;gt;read();           &#xA;xMagLowByte = i2cBus-&amp;gt;read();&#xA;yMagHighByte = i2cBus-&amp;gt;read();           &#xA;yMagLowByte = i2cBus-&amp;gt;read();&#xA;&#xA;xMag = short(xMagHighByte&amp;lt;&amp;lt;8);&#xA;xMag |= xMagLowByte;&#xA;yMag = short(yMagHighByte&amp;lt;&amp;lt;8);&#xA;yMag |= yMagLowByte;&#xA;&#xA;if(yMag!=0){&#xA;  magBearing = (atan2(xMag,yMag)*180.0)/3.141592654;&#xA;}&#xA;else if(xMag&amp;gt;0) magBearing=0.0;&#xA;else if(xMag&amp;lt;0) magBearing=180.0;&#xA;else magBearing = 1000;&#xA;if(magBearing &amp;lt; 0) magBearing+=360;&#xA;magBearing=360-magBearing;&#xA;return magBearing;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1112" LastEditorUserId="1112" LastEditDate="2014-05-24T11:45:10.403" LastActivityDate="2014-05-25T23:15:07.407" Title="Reading CMPS10 raw values" Tags="|sensors|arduino-due|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1670" PostTypeId="2" ParentId="1661" CreationDate="2014-05-24T13:34:23.683" Score="0" Body="&lt;p&gt;The leonardo &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoLeonardoMicro?from=Guide.ArduinoLeonardo&quot; rel=&quot;nofollow&quot;&gt;doesn't reset&lt;/a&gt; when the serial port is opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check it isn't python, run your Arduino code, then open the terminal and run&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screen /dev/tty.usbmodem1a1221 19200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: to exit the screen session type Ctrl-A Ctrl=\ (see &lt;a href=&quot;http://hints.macworld.com/article.php?story=20061109133825654&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). If you just close the window it will stay connected and lock up the serial port until you recycle the power on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Arduino program spits out just fine to screen, then python is the problem. One thing that can happen is a python/java/whatever program can lock up the serial port driver, &lt;em&gt;but recycling the Arduino power, not restarting the program,&lt;/em&gt; is required to reinitialise the driver. So the Arduino is not necessarily problem, as the serial port will stay locked up for ALL programs. So &quot;I would expect future calls to return data&quot; is actually wrong. If I stuff up the serial port code in my java interface programs the same kind of thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other ideas:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make the delay longer than 10ms.&lt;/li&gt;&#xA;&lt;li&gt;Make sure hardware flow control is off in the python serial&lt;/li&gt;&#xA;&lt;li&gt;Flash a LED in the Arduino loop to see if it is the main loop locked up or if that is running fine. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-05-24T13:34:23.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1671" PostTypeId="2" ParentId="1651" CreationDate="2014-05-24T13:57:56.247" Score="1" Body="&lt;p&gt;I don't think your circuit is correct. If red is positive and your switch is momentary closed then it actually pulls GPIO23 low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise with the NPN transistor, using it in this way gives you an inverter. It should work if internal pull ups are enabled on GPIO22 and you remove the resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF GPIO23 is 5V tolerant, you can instead connect the resistor to 5V and GPIO23 straight to the collector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also have a 1K resistor between the arduino pin 13 and the base of the transistor to limit the base current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This all assumes that the VCE of the transistor is lower than the 0.8V low-level cutoff of the GPIO pins (it should be).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, if GPIO23 is 5V tolerant, just connect it straight to the Arduino. If it isn't, follow penguins advice and use a voltage divider.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-05-24T13:57:56.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1672" PostTypeId="1" AcceptedAnswerId="1678" CreationDate="2014-05-24T14:17:18.997" Score="3" ViewCount="3252" Body="&lt;p&gt;I bought a few atmega328p chips but unfortunately they came with the Arduino bootloader and they are set to use the external clock. I want to reset their fuses using avrdude so I can use the internal 8mhz clock but it's not working. How can I (if even possible) reset their fuses using the Arduino? I have no other programmer and here are the arguments I use for avrdude as well as the response:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C .\avrdude.conf -p m328p -c arduino -P \\.\COM12 -b 115200 -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Response:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude.exe: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude.exe: Device signature = 0x1e950f&#xA;avrdude.exe: reading input file &quot;0x62&quot;&#xA;avrdude.exe: writing lfuse (1 bytes):&#xA;&#xA;Writing |  ***failed;  &#xA;################################################## | 100% 0.06s&#xA;&#xA;avrdude.exe: 1 bytes of lfuse written&#xA;avrdude.exe: verifying lfuse memory against 0x62:&#xA;avrdude.exe: load data lfuse data from input file 0x62:&#xA;avrdude.exe: input file 0x62 contains 1 bytes&#xA;avrdude.exe: reading on-chip lfuse data:&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude.exe: verifying ...&#xA;avrdude.exe: verification error, first mismatch at byte 0x0000&#xA;             0x62 != 0x00&#xA;avrdude.exe: verification error; content mismatch&#xA;&#xA;avrdude.exe: safemode: lfuse changed! Was 62, and is now 0&#xA;Would you like this fuse to be changed back? [y/n] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="335" LastActivityDate="2014-05-24T23:48:53.973" Title="Reset fuses on atmega328p using Arduino" Tags="|arduino-uno|atmega328|avrdude|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1673" PostTypeId="1" AcceptedAnswerId="1686" CreationDate="2014-05-24T14:37:57.790" Score="3" ViewCount="3139" Body="&lt;p&gt;I have an Arduino Uno R3 and would like to use it to program a blank ATmega328 on a breadboard. I've followed the instructions for the 8 MHz version on &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; with an added 10K pullup resistor on the &lt;code&gt;RESET&lt;/code&gt; pin of the ATmega328 on the breadboard; and I've uploaded the &lt;code&gt;ArduinoISP&lt;/code&gt; sketch from the Arduino 1.0.5 distribution to my Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also added the metadata for my setup: the following is the contents of  &lt;code&gt;~/sketchbook/hardware/breadboard/boards.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)&#xA;&#xA;atmega328bb.upload.protocol=stk500v1&#xA;atmega328bb.upload.maximum_size=30720&#xA;atmega328bb.upload.speed=57600&#xA;&#xA;atmega328bb.bootloader.low_fuses=0xE2&#xA;atmega328bb.bootloader.high_fuses=0xDA&#xA;atmega328bb.bootloader.extended_fuses=0x05&#xA;atmega328bb.bootloader.path=arduino:atmega&#xA;atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex&#xA;atmega328bb.bootloader.unlock_bits=0x3F&#xA;atmega328bb.bootloader.lock_bits=0x0F&#xA;&#xA;atmega328bb.build.mcu=atmega328&#xA;atmega328bb.build.f_cpu=8000000L&#xA;atmega328bb.build.core=arduino:arduino&#xA;atmega328bb.build.variant=arduino:standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also added the following section to my &lt;code&gt;~/.avrduderc&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;part&#xA;    id          = &quot;m328&quot;;&#xA;    desc        = &quot;ATMEGA328&quot;;&#xA;    has_debugwire   = yes;&#xA;    flash_instr     = 0xB6, 0x01, 0x11;&#xA;    eeprom_instr    = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,&#xA;              0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,&#xA;              0x99, 0xF9, 0xBB, 0xAF;&#xA;    stk500_devcode  = 0x86;&#xA;    # avr910_devcode    = 0x;&#xA;    signature       = 0x1e 0x95 0x14;&#xA;    pagel       = 0xd7;&#xA;    bs2         = 0xc2;&#xA;    chip_erase_delay    = 9000;&#xA;    pgm_enable = &quot;1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1&quot;,&#xA;         &quot;x x x x x x x x x x x x x x x x&quot;;&#xA;&#xA;    chip_erase = &quot;1 0 1 0 1 1 0 0 1 0 0 x x x x x&quot;,&#xA;         &quot;x x x x x x x x x x x x x x x x&quot;;&#xA;&#xA;    timeout = 200;&#xA;    stabdelay   = 100;&#xA;    cmdexedelay = 25;&#xA;    synchloops  = 32;&#xA;    bytedelay   = 0;&#xA;    pollindex   = 3;&#xA;    pollvalue   = 0x53;&#xA;    predelay    = 1;&#xA;    postdelay   = 1;&#xA;    pollmethod  = 1;&#xA;&#xA;    pp_controlstack =&#xA;    0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,&#xA;    0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,&#xA;    0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,&#xA;    0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;&#xA;    hventerstabdelay    = 100;&#xA;    progmodedelay   = 0;&#xA;    latchcycles     = 5;&#xA;    togglevtg       = 1;&#xA;    poweroffdelay   = 15;&#xA;    resetdelayms    = 1;&#xA;    resetdelayus    = 0;&#xA;    hvleavestabdelay    = 15;&#xA;    resetdelay      = 15;&#xA;    chiperasepulsewidth = 0;&#xA;    chiperasepolltimeout = 10;&#xA;    programfusepulsewidth = 0;&#xA;    programfusepolltimeout = 5;&#xA;    programlockpulsewidth = 0;&#xA;    programlockpolltimeout = 5;&#xA;&#xA;    memory &quot;eeprom&quot;&#xA;    paged       = no;&#xA;    page_size   = 4;&#xA;    size        = 1024;&#xA;    min_write_delay = 3600;&#xA;    max_write_delay = 3600;&#xA;    readback_p1 = 0xff;&#xA;    readback_p2 = 0xff;&#xA;    read = &quot; 1 0 1 0 0 0 0 0&quot;,&#xA;           &quot; 0 0 0 x x x a9 a8&quot;,&#xA;           &quot; a7 a6 a5 a4 a3 a2 a1 a0&quot;,&#xA;           &quot; o o o o o o o o&quot;;&#xA;&#xA;    write = &quot; 1 1 0 0 0 0 0 0&quot;,&#xA;            &quot; 0 0 0 x x x a9 a8&quot;,&#xA;        &quot; a7 a6 a5 a4 a3 a2 a1 a0&quot;,&#xA;        &quot; i i i i i i i i&quot;;&#xA;&#xA;    loadpage_lo = &quot; 1 1 0 0 0 0 0 1&quot;,&#xA;              &quot; 0 0 0 0 0 0 0 0&quot;,&#xA;              &quot; 0 0 0 0 0 0 a1 a0&quot;,&#xA;              &quot; i i i i i i i i&quot;;&#xA;&#xA;    writepage = &quot; 1 1 0 0 0 0 1 0&quot;,&#xA;            &quot; 0 0 x x x x a9 a8&quot;,&#xA;            &quot; a7 a6 a5 a4 a3 a2 0 0&quot;,&#xA;            &quot; x x x x x x x x&quot;;&#xA;&#xA;    mode        = 0x41;&#xA;    delay       = 20;&#xA;    blocksize   = 4;&#xA;    readsize    = 256;&#xA;    ;&#xA;&#xA;    memory &quot;flash&quot;&#xA;    paged       = yes;&#xA;    size        = 32768;&#xA;    page_size   = 128;&#xA;    num_pages   = 256;&#xA;    min_write_delay = 4500;&#xA;    max_write_delay = 4500;&#xA;    readback_p1 = 0xff;&#xA;    readback_p2 = 0xff;&#xA;    read_lo = &quot; 0 0 1 0 0 0 0 0&quot;,&#xA;          &quot; 0 0 a13 a12 a11 a10 a9 a8&quot;,&#xA;          &quot; a7 a6 a5 a4 a3 a2 a1 a0&quot;,&#xA;          &quot; o o o o o o o o&quot;;&#xA;&#xA;    read_hi = &quot; 0 0 1 0 1 0 0 0&quot;,&#xA;          &quot; 0 0 a13 a12 a11 a10 a9 a8&quot;,&#xA;          &quot; a7 a6 a5 a4 a3 a2 a1 a0&quot;,&#xA;          &quot; o o o o o o o o&quot;;&#xA;&#xA;    loadpage_lo = &quot; 0 1 0 0 0 0 0 0&quot;,&#xA;              &quot; 0 0 0 x x x x x&quot;,&#xA;              &quot; x x a5 a4 a3 a2 a1 a0&quot;,&#xA;              &quot; i i i i i i i i&quot;;&#xA;&#xA;    loadpage_hi = &quot; 0 1 0 0 1 0 0 0&quot;,&#xA;              &quot; 0 0 0 x x x x x&quot;,&#xA;              &quot; x x a5 a4 a3 a2 a1 a0&quot;,&#xA;              &quot; i i i i i i i i&quot;;&#xA;&#xA;    writepage = &quot; 0 1 0 0 1 1 0 0&quot;,&#xA;            &quot; 0 0 a13 a12 a11 a10 a9 a8&quot;,&#xA;            &quot; a7 a6 x x x x x x&quot;,&#xA;            &quot; x x x x x x x x&quot;;&#xA;&#xA;    mode        = 0x41;&#xA;    delay       = 6;&#xA;    blocksize   = 128;&#xA;    readsize    = 256;&#xA;&#xA;    ;&#xA;&#xA;    memory &quot;lfuse&quot;&#xA;    size = 1;&#xA;    min_write_delay = 4500;&#xA;    max_write_delay = 4500;&#xA;    read = &quot;0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0&quot;,&#xA;           &quot;x x x x x x x x o o o o o o o o&quot;;&#xA;&#xA;    write = &quot;1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0&quot;,&#xA;            &quot;x x x x x x x x i i i i i i i i&quot;;&#xA;    ;&#xA;&#xA;    memory &quot;hfuse&quot;&#xA;    size = 1;&#xA;    min_write_delay = 4500;&#xA;    max_write_delay = 4500;&#xA;    read = &quot;0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0&quot;,&#xA;           &quot;x x x x x x x x o o o o o o o o&quot;;&#xA;&#xA;    write = &quot;1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0&quot;,&#xA;            &quot;x x x x x x x x i i i i i i i i&quot;;&#xA;    ;&#xA;&#xA;    memory &quot;efuse&quot;&#xA;    size = 1;&#xA;    min_write_delay = 4500;&#xA;    max_write_delay = 4500;&#xA;    read = &quot;0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0&quot;,&#xA;           &quot;x x x x x x x x x x x x x o o o&quot;;&#xA;&#xA;    write = &quot;1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0&quot;,&#xA;            &quot;x x x x x x x x x x x x x i i i&quot;;&#xA;    ;&#xA;&#xA;    memory &quot;lock&quot;&#xA;    size = 1;&#xA;    min_write_delay = 4500;&#xA;    max_write_delay = 4500;&#xA;    read = &quot;0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0&quot;,&#xA;           &quot;x x x x x x x x x x o o o o o o&quot;;&#xA;&#xA;    write = &quot;1 0 1 0 1 1 0 0 1 1 1 x x x x x&quot;,&#xA;            &quot;x x x x x x x x 1 1 i i i i i i&quot;;&#xA;    ;&#xA;&#xA;    memory &quot;calibration&quot;&#xA;    size = 1;&#xA;    read = &quot;0 0 1 1 1 0 0 0 0 0 0 x x x x x&quot;,&#xA;           &quot;0 0 0 0 0 0 0 0 o o o o o o o o&quot;;&#xA;    ;&#xA;&#xA;    memory &quot;signature&quot;&#xA;    size = 3;&#xA;    read = &quot;0 0 1 1 0 0 0 0 0 0 0 x x x x x&quot;,&#xA;           &quot;x x x x x x a1 a0 o o o o o o o o&quot;;&#xA;    ;&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I thought I'd be good to go: I've set the programmer type to &lt;code&gt;ArduinoISP&lt;/code&gt; and the board type to &lt;code&gt;ATmega328 on a breadboard (8 MHz internal clock)&lt;/code&gt; in the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I try to either upload the Arduino bootloader, or use the &lt;code&gt;Upload using programmer&lt;/code&gt; feature on the &lt;code&gt;Blink&lt;/code&gt; example, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Full output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328 -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/build6008715511691559175.tmp/Blink.cpp.hex:i &#xA;&#xA;avrdude: Version 5.11.1, compiled on Apr 28 2013 at 18:46:46&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/cactus/.avrduderc&quot;&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : stk500v1&#xA;         Overriding Baud Rate          : 19200&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;         AVR Part                      : ATMEGA328&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : STK500&#xA;         Description     : Atmel STK500 Version 1.x firmware&#xA;avrdude: Send: A [41] . [80]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [02] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [01] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [12] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [98]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;         Hardware Version: 2&#xA;         Firmware Version: 1.18&#xA;         Topcard         : Unknown&#xA;avrdude: Send: A [41] . [84]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [85]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [86]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [87]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [89]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;         Vtarget         : 0.0 V&#xA;         Varef           : 0.0 V&#xA;         Oscillator      : Off&#xA;         SCK period      : 0.1 us&#xA;&#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [01] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [12] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: P [50]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | avrdude: Send: V [56] 0 [30] . [00] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;################avrdude: Send: V [56] 0 [30] . [00] . [02] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;################################## | 100% 0.06s&#xA;&#xA;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've double-checked and triple-checked, I've rebuilt the whole circuit on another breadboard with another ATmega328, I've even checked the jumper cables one by one, they all work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I use my Arduino Uno as an ISP to upload code to this blank ATmega328?&lt;/p&gt;&#xA;" OwnerUserId="1568" OwnerDisplayName="Cactus" LastActivityDate="2014-05-25T08:08:30.350" Title="Using ArduinoISP on an Arduino Uno to program an ATmega328" Tags="|avr|isp|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1675" PostTypeId="2" ParentId="1658" CreationDate="2014-05-24T15:59:30.510" Score="0" Body="&lt;p&gt;From the Arduino playground &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf2401&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; for the Nrf2401 library, the .write method accepts either: a byte to transmit, a pointer to your &lt;code&gt;unsigned char&lt;/code&gt; buffer; or a void argument meaning use the library's internal buffer. You must have called the .txmode() method first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're trying to use your own buffer, you'll need to make it long enough to contain the message you want to transmit (plus one byte for the terminating NUL). You'll need a character representation of the value you want to send, not the binary number itself. At a quick read of the library doc I didn't see the message format the library wants, but assuming it's something like:&#xA;  &lt;code&gt;T&amp;lt;space&amp;gt;12.34&amp;lt;newline&amp;gt;&lt;/code&gt;, you'll need something like this (untested, it may need tweaking)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(data, &quot;T %5.2f\n&quot;, currentTemp);  // build command in data[]&#xA;radio.txMode(strlen(data));               // set # bytes to xmit&#xA;radio.write(data);                        // send bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-05-25T12:10:59.873" LastActivityDate="2014-05-25T12:10:59.873" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1677" PostTypeId="2" ParentId="1667" CreationDate="2014-05-24T18:50:08.710" Score="1" Body="&lt;p&gt;More explanation: binary numbers are different than base 10 as you probably know. The meaning of those numbers is simple. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with 1 and double it. Keep doubling. You will soon hit 256 (computers start at 0 not 1,  so you have to take that into account, 0-255 is 256 different values). Keep doubling and you will soon hit 1024 (0-1023). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So these numbers are not arbitrary, they are Base 10 (0-9 like you learned in school) representations of Binary Numbers, more specifically, the high limit a given length of binary digits can represent before having to add another digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1111111 is binary for 127, with 0 thats 128 different values those 7 digits can represent. To get to 255, you have to add a digit for 8 total digits, 11111111 = 255. 9 digits or 111111111 = 511 and ten digits or 1111111111 = 1023.&lt;/p&gt;&#xA;" OwnerUserId="1575" LastActivityDate="2014-05-24T18:50:08.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1678" PostTypeId="2" ParentId="1672" CreationDate="2014-05-24T21:38:15.377" Score="3" Body="&lt;p&gt;You cannot set the fuses using the Arduino bootloader, since they cannot be self-programmed. You must use either serial or parallel programming via ArduinoISP or an external programmer to set them. Since the chip is configured to use an external crystal you must either connect a crystal up to the chip appropriately (see sections 9.3 or 9.4 of the datasheet) or use parallel programming. You will then be able to use the &lt;code&gt;lfuse&lt;/code&gt;, &lt;code&gt;hfuse&lt;/code&gt;, and &lt;code&gt;efuse&lt;/code&gt; memory types to read and write the fuse bytes.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-24T21:38:15.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1679" PostTypeId="2" ParentId="1673" CreationDate="2014-05-24T22:03:36.003" Score="0" Body="&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is the clue to the solution. The signature is different between different versions of the ATmega328, for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ATmega328-PU&lt;/li&gt;&#xA;&lt;li&gt;ATmega328P-PU&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and so on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can google on &quot;arduino signature error ATmega328P&quot; to find the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One hint is: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=201920.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=201920.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can be more specific if you post the version off the ATmega328 you have.&lt;/p&gt;&#xA;" OwnerUserId="1576" LastEditorUserId="37" LastEditDate="2014-05-24T23:52:20.757" LastActivityDate="2014-05-24T23:52:20.757" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1680" PostTypeId="2" ParentId="1673" CreationDate="2014-05-24T23:45:33.067" Score="2" Body="&lt;p&gt;Do you have another UNO or similar? Try getting the boot loader upload working on a stock board just to confirm it is not the programmer. 0x000000 usually means it can't talk to the chip being programmed.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-05-25T08:08:30.350" LastActivityDate="2014-05-25T08:08:30.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1683" PostTypeId="1" AcceptedAnswerId="1684" CreationDate="2014-05-24T11:38:22.843" Score="2" ViewCount="3295" Body="&lt;p&gt;I have configured my arduino as a flash programmer and i'm sending data to an atmega328P. It is actually working and the data is send to my atmega328. But what is strange that the _delay_ms from  from the Arduino library is not delaying in accurate seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;_delay_ms(1000) who should wait from 1s, is actually more 8 seconds from my atmega328P hardware point of view. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is what could possibly turn the program wrong. I'm strongly assuming that this a misconfigured clock cycle from my Atmega, but this is my newbie guess,  it can be something else, that's why I'm posting my question here. Can someone can hint me what's wrong with my configuration?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the sample code, a dumb toggle pin on / off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;util/delay.h&amp;gt; // from arduino library&#xA;&#xA;/*&#xA;*/&#xA;&#xA; DDRB |= 0b0000001;&#xA;&#xA;  while (1) {&#xA;    PORTB = 0b00000001;&#xA;    _delay_ms(1000); // it should be 1 second, but on my hardware it is more ~8 seconds &#xA;&#xA;    PORTB = 0b00000000;&#xA;    _delay_ms(1000);&#xA;  }   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my configuration is (from arduino IDE) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Arduino Pro / pro Mini (3,3v 8 Mhz) / Atmega 328&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Arduino Pro / pro Mini (5v 16 Mhz) / Atmega 328&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;expecting that more power will affect speed, but the result is actually the same.&lt;/p&gt;&#xA;" OwnerDisplayName="Mr Bonjour" LastActivityDate="2014-05-25T01:58:11.367" Title="util/delay.h from arduino _delay_ms not delaying in accurate time with my hardware configuration" Tags="|spi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1684" PostTypeId="2" ParentId="1683" CreationDate="2014-05-24T12:16:39.643" Score="5" Body="&lt;p&gt;At a 30000 ft. level, it's because the defined &lt;code&gt;F_CPU&lt;/code&gt; value doesn't match your hardware. This can happen because the incorrect device is chosen in the IDE or because the device is misconfigured in boards.txt, or because the hardware is somehow different from what is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that you are using a bare ATmega328P, assuming that you've selected the correct crystal, and that the apparent time scale is 8x, it is likely that the CKDIV8 fuse is set. This means that the chip is running at 1/8 the crystal speed. You will need to unprogram (set to 1) bit 7 of the low fuse byte in order to reset it. Use &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduinoisp#bonus-using-with-avrdude&quot;&gt;AVRdude from the command line&lt;/a&gt; to read the low fuse byte (&lt;code&gt;-U lfuse:r:-:h&lt;/code&gt;), set the bit (lfuse | 0x80), and then write it back (&lt;code&gt;-U lfuse:w:0xnn:m&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-05-24T12:47:39.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1685" PostTypeId="2" ParentId="1641" CreationDate="2014-05-25T06:49:13.240" Score="2" Body="&lt;p&gt;The problem in your code is there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int simonIn() {&#xA;    int ret = -1;&#xA;    for(int i = 0; i &amp;lt; 4; i++) {&#xA;        if(simonIn(i)){&#xA;            ret = i;&#xA;        }&#xA;    }&#xA;    if(ret != -1) {&#xA;        simonOut(ret);&#xA;        delay(500);&#xA;        simonClear();&#xA;        delay(100);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This method never returns any value, so that means the caller will just tke whatever is in the stack at that time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            int input = simonIn();&#xA;            while(input &amp;lt; 0 || input &amp;gt; 3) {&#xA;                delay(50);&#xA;                input = simonIn();&#xA;            }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;input&lt;/code&gt; could be anything there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the fix should be easy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int simonIn() {&#xA;    int ret = -1;&#xA;    for(int i = 0; i &amp;lt; 4; i++) {&#xA;        if(simonIn(i)){&#xA;            ret = i;&#xA;        }&#xA;    }&#xA;    if(ret != -1) {&#xA;        simonOut(ret);&#xA;        delay(500);&#xA;        simonClear();&#xA;        delay(100);&#xA;    }&#xA;    return ret;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's surprising you did not get a &lt;strong&gt;warning from the compiler&lt;/strong&gt; on that one, which IDE do you use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, regarding your code, I would also advise you the following improvements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;break down the &lt;code&gt;loop()&lt;/code&gt; code further into functions that do &lt;strong&gt;ONE&lt;/strong&gt; thing, e.g. &lt;code&gt;showSequence(sequence)&lt;/code&gt;, &lt;code&gt;checkInput(seuquence)&lt;/code&gt;, &lt;code&gt;readSimonInput()&lt;/code&gt; (this last function would only return a value between 0 and 3 included. That would make your code much clearer.&lt;/li&gt;&#xA;&lt;li&gt;use the right types for your variables: I see you abuse usage of &lt;code&gt;long&lt;/code&gt; where &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;byte&lt;/code&gt;, or you mix different types for the same data, thus forcing the compiler to cast data on some function calls.&lt;/li&gt;&#xA;&lt;li&gt;avoid hardcoding constants in your code, e.g. you could define the number of buttons, the first pin of buttons, the first pin of LEDs, the various delays.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-05-25T06:49:13.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1686" PostTypeId="2" ParentId="1673" CreationDate="2014-05-25T07:02:53.950" Score="3" Body="&lt;p&gt;Feeling really stupid about it in retrospect...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last thing I tried was taking the ATmega328P out from the Arduino Uno and plugging the blank ATmega328 in its place, thinking I could use the Uno programmer as such to burn the bootloader on the chip. That didn't work and I don't know if it's supposed to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to plug the new chip into the DIL on the Uno, I had to bend the DIP legs inwards slightly to give it a smaller straddle. After seeing that it didn't work, I plugged the ATmega328P back into the Uno and plugged the ATmega328 back into the breadboard. However, this time, because of the smaller straddle, it slipped in deeper into the breadboard, the plastic package actually touching the board. And with this setup, wiring it up again via the Arduino and using the &lt;code&gt;ArduinoISP&lt;/code&gt; I was able to burn both the bootloader and (via the 'Upload with programmer' functionality) test programs to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR: I didn't have the blank ATmega328 properly plugged into the breadboard...&lt;/p&gt;&#xA;" OwnerUserId="1568" LastActivityDate="2014-05-25T07:02:53.950" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1687" PostTypeId="2" ParentId="847" CreationDate="2014-05-25T08:21:22.183" Score="0" Body="&lt;p&gt;I would connect TX and RX to one of the 3 extra serial ports on the Due. Pins 0 and 1 are used for the USB-Serial communication&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-05-25T08:21:22.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1688" PostTypeId="2" ParentId="1288" CreationDate="2014-05-25T10:58:31.500" Score="2" Body="&lt;p&gt;You could use Electric Field Sensing, it allows you to detect the presence and position of conductive objects even if the sensor is covered by an opaque object. The technology is used in cars to detect if someone is sitting in a seat so the car can beep at you to put your seat-belt on. However, if all you want to do is detect presence then this is no better than using CapSense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://web.media.mit.edu/~jrs/efs.html&quot; rel=&quot;nofollow&quot;&gt;http://web.media.mit.edu/~jrs/efs.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Electric_field_proximity_sensing&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Electric_field_proximity_sensing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To communicate with a server over WiFi you could use the Arduino WiFi shield, the Arduino Yun (which has on-board WiFi) or buy a ethernet WiFi adapter and use it with an Arduino board which has ethernet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoWiFiShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardYun&lt;/a&gt;&#xA;(Arduino board with on-board WiFi)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardEthernet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1185" LastActivityDate="2014-05-25T10:58:31.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1689" PostTypeId="1" CreationDate="2014-05-25T19:48:21.197" Score="3" ViewCount="2990" Body="&lt;p&gt;I am planning to connect multiple Arduinos to my Raspberry Pi. There are basically two ways I can achieve that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an USB hub. Each Arduino will then be available through ordinary serial commands both for reading and writing. The USB hub I have is powered and can handle both communications and powering the Arduinos.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use I2C, so that the Arduinos are I2C slaves of the Raspberry Pi.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since USB is used for updating the Arduino, I don't have the best feeling about using this same connection for &quot;management&quot; tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Are there any known disadvantages to using the pre built USB socket on&#xA;the Arduino in &quot;production&quot;, any best practises or similar saying that I should not do&#xA;this? Is this USB socket meant to be used for debugging and code deployment only?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plan is to let the computer send commands to the Arduinos using a serial protocol. The computer will automatically detect whenever an Arduino is connected and immediately send a &quot;hello&quot; command over serial. The Arduino is then supposed to send back its &quot;name&quot; and a list of capability keywords. A capability may be &quot;motion-sensor&quot;. The computer will then know that it can ask the Arduino if it has detected motion. Other capabilities may be &quot;temperature-sensor&quot;, &quot;barometric-sensor&quot;, &quot;lights&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's for a generic open source home automation system/robotics system I am working on creating a framework for.&lt;/p&gt;&#xA;" OwnerUserId="1379" LastEditorUserId="1379" LastEditDate="2014-05-26T07:58:56.257" LastActivityDate="2014-05-26T15:04:33.687" Title="Interfacing Arduino through USB or I2C?" Tags="|serial|i2c|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1690" PostTypeId="2" ParentId="1667" CreationDate="2014-05-25T20:48:11.840" Score="2" Body="&lt;p&gt;To clarify, analogRead() has a 10 bit range due to the arduino's Analog to Digital Converter, or ADC. 10 bits can store 1024 (2^10) different values; counting zero as a value gives the range 0-1023. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In arduino 0 is the reading when a pin is grounded, 1023 is the reading when an analog pin is connected to Vref, or 5v if there is nothing wired to Vref. The sensors provide a voltage somewhere between these values, but not the actual numbers your code gets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;analogWrite() accepts 8 bit numbers. That is 2^8 or 256 different values, called 0-255. It only simulates an analog voltage by pulsing a pin rapidly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, the numbers are not arbitrary, but express the limits of the arduino chip's IO. They look random because they were written in decimal, but in binary they are very simple. If you are interested, you could look into replacing the decimal numbers in the code with hexadecimal numbers, which make their binary representations very obvious by way of 16 being 2^4.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-25T20:48:11.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1691" PostTypeId="2" ParentId="1338" CreationDate="2014-05-25T22:04:24.447" Score="2" Body="&lt;p&gt;The real answer to this question requires understanding exactly what hardware you have. The formula, assuming one step per pulse, is that the delay should be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;wait = (MicroSecondsPerMinute)&lt;em&gt;(1/RPM)&lt;/em&gt;(1/PulsesPerRevolution) - overhead&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where overhead is the extra time it takes to run digitalWrite twice and loop. It is small, but if it were zero your code would not work because the amount of time your signal is LOW would be zero as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your numbers suggest Pulses Per Revolution is around 1891. This will be the product of how many steps per revolution the motor is wired for and how many bits of microstepping the driver is doing. A 225 step motor with 3 bit microstepping (8 fractional steps per &quot;true&quot; step) would have PPR of 1800 for example. Your number does not precisely match any common setups, but is exactly in the range expected, with 1600 and 2000 being normal for small steppers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the &quot;overhead&quot; term, RPM as a function of wait should not be linear. Your constant value should be a function of RPM; in fact, when RPM gets much larger than the number of Microseconds per minute it should converge to being equal to RPM. In this case your RPM is so low that approximating it to 17 is probably valid and all error too small to notice. It could be causing some of the oddness of your PPR value though.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-25T22:04:24.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1692" PostTypeId="5" CreationDate="2014-05-25T23:13:42.220" Score="0" Body="&lt;p&gt;Bluetooth is a wireless communication standard which uses ultra-high frequency (UHF) radio waves. Line-of-sight between the devices is not required, although it is only intended for exchanging data over fairly short distances, such as between a mobile phone and a headset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Built-in Bluetooth support is available on the official &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardBT?from=Main.ArduinoBoardBluetooth&quot; rel=&quot;nofollow&quot;&gt;Arduino BT&lt;/a&gt; board, and in various Arduino compatible development boards from third party manufacturers. Alternatively, Bluetooth support can be added to other Arduino boards through the use of a shield or generic components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag should be used for questions about using Bluetooth with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:13:42.220" LastActivityDate="2014-05-25T23:13:42.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1693" PostTypeId="4" CreationDate="2014-05-25T23:13:42.220" Score="0" Body="Bluetooth enables short-range wireless communication between devices." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:13:42.220" LastActivityDate="2014-05-25T23:13:42.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1694" PostTypeId="2" ParentId="1669" CreationDate="2014-05-25T23:15:07.407" Score="1" Body="&lt;p&gt;Compass modules are highly susceptible to interference from ferrous deposits underground and metals in or around your robot. To correct for them, you need to shift and scale both axis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But first, test if the sensor's X axis is working by watching the value while moving a small magnet around the sensor. If should overpower any stationary field and bias in the sensor, if it can't then there may be a problem with the sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calibrate the compass, first find the min and max value for each axis. Do this by reading all the outputs of an axis when moving the sensor in a complete circle in the environment you will be using it in. Making the robot drive in a circle when first turned on to calibrate itself is not a bad idea. Anyway, the shift is the negative average and the scale is half the difference between maximums. what really matters is that this &quot;distance&quot; is the same on both axis, but normalizing both is easier. For example, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float Scale, Shift, Value;&#xA;Scale =  (max-min)/2;&#xA;Shift = -(max+min)/2;&#xA;Value = float(raw+Shift)/Scale;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once both axis are corrected the atan2() function can work properly. If you were to plot the x and y points on a graph, they should trace a unit circle at the origin.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-25T23:15:07.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1695" PostTypeId="2" ParentId="1575" CreationDate="2014-05-25T23:31:08.597" Score="2" Body="&lt;p&gt;This is a symptom of the arduino IDE. libraries can't add other libraries to the include path, but the can use other libs if they have already been included. you can use an error directive so your compiler output is more informative at least&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef Servo_h&#xA;    #error &quot;ServoMotorController Lib requires Servo.h to be included first to function&quot;&#xA;#else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino 1.5.6 beta's new library format has a section for dependencies in the new library.properties file that should allow one library to add another to the include path, but I'm not entirely sure if the functionality is fully implemented yet (its beta after all). &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-05-26T03:54:47.737" LastActivityDate="2014-05-26T03:54:47.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1696" PostTypeId="5" CreationDate="2014-05-25T23:33:11.807" Score="0" Body="&lt;p&gt;Global System for Mobile Communications (GSM) is part of the second generation (2G) of mobile phone network technology. It was originally designed for two-way voice communication, but was later expanded to support more general data transfer, via GPRS and EDGE. It has been superseded by other technologies, but remains widely available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino support for GSM is often achieved by using the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;Arduino GSM Shield&lt;/a&gt;, although generic components can be used as well. In either case, a working SIM card and (typically) a contract or pre-payment plan with a mobile network operator is also required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Reference/GSM&quot; rel=&quot;nofollow&quot;&gt;GSM Library&lt;/a&gt; is available to facilitate programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino projects involving GSM often focus on text-messaging. However, audio communication is also possible.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:33:11.807" LastActivityDate="2014-05-25T23:33:11.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1697" PostTypeId="4" CreationDate="2014-05-25T23:33:11.807" Score="0" Body="GSM is a very widely used standard for communication over mobile phone networks." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:33:11.807" LastActivityDate="2014-05-25T23:33:11.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1698" PostTypeId="5" CreationDate="2014-05-25T23:51:05.493" Score="0" Body="&lt;p&gt;A web-server delivers data to clients across a network. The most common data is web-content, such as text or HTML files, plus any associated images, stylesheets (CSS), and scripts. Typically, the client is a web-browser, and the delivery occurs via the Hypertext Transfer Protocol (HTTP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to delivering static web-page data, the web-server may also process it in some way. For example, it may add sensor readings into the page. The page may also include a form which enables the user to submit data back to the server. When the server receives this data, it can act on it in some way, such as updating an internal database, or even controlling connected equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use an Arduino as a webserver, some kind of networking hardware is required, such as Ethernet or Wifi. This may be built-in to the board (e.g. the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow&quot;&gt;Arduino Ethernet&lt;/a&gt;), or added using external hardware (e.g. the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow&quot;&gt;Ethernet Shield&lt;/a&gt;). More information is available in &lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag should be used for questions about using an Arduino as a web-server.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:51:05.493" LastActivityDate="2014-05-25T23:51:05.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1699" PostTypeId="4" CreationDate="2014-05-25T23:51:05.493" Score="0" Body="A web-server is a system which delivers data such as web-pages to a client system." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-25T23:51:05.493" LastActivityDate="2014-05-25T23:51:05.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1700" PostTypeId="5" CreationDate="2014-05-26T00:02:23.990" Score="0" Body="&lt;p&gt;Batteries are electrochemical devices. That is, they store energy in chemical form, and can convert it to electrical energy when required. They are available in a very wide variety of configurations, producing different voltages, with different power output capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some are single-use devices which are disposed of when depleted. In consumer products, these are often referred to as alkaline batteries. Others types of battery may be recharged repeatedly for multiple uses, such as lithium ion or lead acid batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag should be used for questions about using batteries with Arduino devices. This can include using batteries as a power supply, but may also cover projects where the Arduino controls the batteries in some way (e.g. as part of a recharging circuit).&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-26T00:02:23.990" LastActivityDate="2014-05-26T00:02:23.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1701" PostTypeId="4" CreationDate="2014-05-26T00:02:23.990" Score="0" Body="A battery is an electrical power source which is often portable." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-26T00:02:23.990" LastActivityDate="2014-05-26T00:02:23.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1702" PostTypeId="5" CreationDate="2014-05-26T00:10:02.267" Score="0" Body="&lt;p&gt;Android is an open source Operating System (OS) based on Linux. It is primarily designed for use in portable touch-screen devices, such as mobile phones and tablets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tag should be used for questions about communication or data transfer between Arduino and Android devices. General Android questions can be asked on our sister site &lt;a href=&quot;https://android.stackexchange.com&quot;&gt;Android Enthusiasts&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="27346" LastEditDate="2019-01-15T10:24:25.100" LastActivityDate="2019-01-15T10:24:25.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1703" PostTypeId="4" CreationDate="2014-05-26T00:10:02.267" Score="0" Body="For questions about communication or data transfer between Arduino and Android devices. General Android questions can be asked on Android.SE." OwnerUserId="42" LastEditorUserId="27346" LastEditDate="2019-01-15T10:23:59.570" LastActivityDate="2019-01-15T10:23:59.570" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1704" PostTypeId="5" CreationDate="2014-05-26T00:41:40.220" Score="0" Body="&lt;p&gt;The C programming language is the (direct or indirect) predecessor of many modern programming languages, although it is still actively used and developed. It is very similar to C++, except that C is not object oriented. That is, it will only support simple data structures which have no member functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note: Arduino is usually programmed in C++, not C.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please &lt;strong&gt;do not&lt;/strong&gt; use this tag to indicate a general programming question. You may want to consider using the &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt; tag instead.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-26T00:41:40.220" LastActivityDate="2014-05-26T00:41:40.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1705" PostTypeId="4" CreationDate="2014-05-26T00:41:40.220" Score="0" Body="C is a procedural programming language which is widely used in embedded systems. PLEASE NOTE: Arduino is typically programmed in C++, not C." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-26T00:41:40.220" LastActivityDate="2014-05-26T00:41:40.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1706" PostTypeId="2" ParentId="1615" CreationDate="2014-05-26T03:51:18.950" Score="5" Body="&lt;p&gt;At least an Uno/Megas/leonardos, all the values mapped to analog pin numbers are consecutive, so &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = A0; i &amp;lt; A4; i++) {&#xA;  pinMode(i, OUTPUT); &#xA;  digitalWrite(i, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will set A0, A1, A2, and A3 to OUTPUT, and then LOW.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-26T03:51:18.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1707" PostTypeId="2" ParentId="1558" CreationDate="2014-05-26T04:06:30.280" Score="2" Body="&lt;p&gt;The reason they keep trying to turn is mechanical. The physical stop in the gears is hit before the encoder/potentiometer reaches its end point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make the servo stop fidgeting by completely relaxing it if you want. just use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s1.detach();&#xA;s2.detach();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and your arduino will stop sending any signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind that &quot;reading&quot; the value of a servo in arduino gives you the servo's current set point, not its current location. Your code in unfortunately unaware of a servo's actual location. With that in mind, setting your servo to go to 0, waiting for it to get there with a delay, and then detaching it will have the desired effect, but since it will not maintain position and you will need to reattach it to function again, using 1 or 2 as your far left endpoint is likely the better option. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-26T04:06:30.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1708" PostTypeId="2" ParentId="562" CreationDate="2014-05-26T04:18:29.273" Score="0" Body="&lt;p&gt;Take a look at &lt;a href=&quot;http://inotool.org&quot; rel=&quot;nofollow&quot;&gt;ino&lt;/a&gt; on linux and PCs and Mac.  It's available in the fedora repos, not sure about other distros; though, I'm sure everyone can install it from the &lt;a href=&quot;http://github.com/amperka/ino.git&quot; rel=&quot;nofollow&quot;&gt;github project site&lt;/a&gt;, regardless of the distribution.  According to the website, you can also install it with python setup tools:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    easy_install ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;BTW: sorry for not including this &quot;answer&quot; in a comment due to reputation restrictions.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the description from the fedora repos; I think it's taken directly from the &lt;code&gt;ino&lt;/code&gt; tool website:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;Summary     : Command line toolkit for working with Arduino hardware&#xA;URL         : http://inotool.org/&#xA;License     : MIT&#xA;Description : Ino is a command line toolkit for working with Arduino hardware.&#xA;            : &#xA;            : It allows you to:&#xA;            : Quickly create new projects&#xA;            : Build a firmware from multiple source files and libraries&#xA;            : Upload the firmware to a device&#xA;            : Perform serial communication with a device (aka serial monitor)&#xA;            : &#xA;            : Ino may replace Arduino IDE UI if you prefer to work with command line and&#xA;            : an editor of your choice or if you want to integrate Arduino build process&#xA;            : to third party IDE.&#xA;            : &#xA;            : Ino is based on make to perform builds. However Makefiles are generated&#xA;            : automatically and you'll never see them if you don't want to.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1562" LastEditorUserId="1562" LastEditDate="2014-05-26T07:07:19.293" LastActivityDate="2014-05-26T07:07:19.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1709" PostTypeId="2" ParentId="1581" CreationDate="2014-05-26T07:29:23.373" Score="2" Body="&lt;p&gt;Sorry about providing this as an answer, rather than comments; however, I do have &lt;em&gt;some&lt;/em&gt; suggestions to troubleshoot the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, check the usb connections with &lt;code&gt;lsusb&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    lsusb |grep -i arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly, you can try following the output of &lt;code&gt;dmesg&lt;/code&gt;; though, I'm not sure about the version of &lt;code&gt;dmesg&lt;/code&gt; your system's installation is running.  Newer version of &lt;code&gt;dmesg&lt;/code&gt; have a &quot;follow&quot; option available. On my Fedora system it's:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    dmesg -wH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the output as you plug in the arduino for messages related to the device, such as the resulting location of the &lt;code&gt;tty&lt;/code&gt;. As a desperate measure, you can also look in the &lt;code&gt;/dev/&lt;/code&gt; folder for the last modified device, and search your logs for those devices:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ls -alrth /dev/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1562" LastActivityDate="2014-05-26T07:29:23.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1710" PostTypeId="2" ParentId="1652" CreationDate="2014-05-26T07:36:50.847" Score="2" Body="&lt;p&gt;AFAIK, it's still available on the &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=product_info&amp;amp;cPath=2&amp;amp;products_id=185&quot; rel=&quot;nofollow&quot;&gt;arduino store&lt;/a&gt; website&lt;/p&gt;&#xA;" OwnerUserId="1562" LastActivityDate="2014-05-26T07:36:50.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1711" PostTypeId="2" ParentId="1689" CreationDate="2014-05-26T08:35:41.257" Score="2" Body="&lt;p&gt;One complication you should be aware of is that in its default configuration, an Arduino Uno (and I assume that is what you’re talking about) will automatically reset whenever a serial connection is opened to it. This is easily bypassed with a capacitor between RESET and GND, but not taking it into account might make for hours of debugging fun. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other complication is that just after a power up or RESET, an Arduino will delay for a second or two to listen for a programmer connection on the serial port, but that’s something you’ll have to take into account anyway.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-05-26T08:35:41.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1712" PostTypeId="2" ParentId="1628" CreationDate="2014-05-26T13:15:35.060" Score="0" Body="&lt;p&gt;Firsr of all, When you say &quot;there is a voltage difference&quot;, I assume you are referring to the raspberry pi being a 3.3v device vs the arduino's 5v, and not to some kind of ground potential difference. If theres a ground potential difference(which there shouldn't be in a robot), neither i2c or spi or usb will work without extra circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My short answer would be USB all the way because its easy and built into the arduino and pi. The only issue is that if anything mechanically bumps the usb enough to lose connection, sometimes linux is a little unpredictable with regards to naming serial ports, and when it reconnects it might give the arduino a different serial port name. But this isnt an issue if your cable isnt a cheap worn out one with a flaky connection like the one that bothered me for a hour today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB does have about a millisecond of latency because devices are usually polled at 1khz iirc. Using the raspberry pi hardware serial might be a good idea if milliseconds count which I doubt they do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But on the software side, raspi hardware serial and USB serial are the same. So there should be no problem switching between them if you need to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldnt bother with i2c or spi. Why fuss around when serial works so well?&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-05-26T13:15:35.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1713" PostTypeId="2" ParentId="1689" CreationDate="2014-05-26T13:34:17.060" Score="1" Body="&lt;p&gt;I would go with USB rather than I2C for these reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino can be powered via USB so there is no need for extra power supplies.&lt;/li&gt;&#xA;&lt;li&gt;The system will work with PCs, making it easier to develop the code and the product more versatile.&lt;/li&gt;&#xA;&lt;li&gt;USB cables are commercially available with standardised sockets. I2C cables would have to be made to specification (e.g. &lt;a href=&quot;http://www.nxp.com/documents/application_note/AN10658.pdf&quot; rel=&quot;nofollow&quot;&gt;this app note&lt;/a&gt;) and would require some kind of additional socket for robust termination.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino Wire (I2C) library will hang if you disconnect the cable in the middle of waiting for a byte.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A good product will be robust and easy to use. One thing you may wish to consider is to create an internet of thing (IoT) type system. This involves the Arduinos sending sensor data to the web via the RPi. It could be that the RPi is a dumb conduit for the Arduinos, or it could collate the data and present itself as the end device. Check out Xively for details. I made a basic system to do the former, it is on github &lt;a href=&quot;https://github.com/geometrikal/serial-xively-bridge&quot; rel=&quot;nofollow&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-05-26T13:34:17.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1714" PostTypeId="2" ParentId="1615" CreationDate="2014-05-26T13:41:44.230" Score="0" Body="&lt;p&gt;Pins 14 through 19 are the analog pins A0 to A5. &lt;code&gt;A0&lt;/code&gt; is just an alias for &lt;code&gt;14&lt;/code&gt; and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So another way of writing BrettM's answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 14; i &amp;lt; 18 i++) {&#xA;  pinMode(i, OUTPUT); &#xA;  digitalWrite(i, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-05-26T13:41:44.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1715" PostTypeId="2" ParentId="1689" CreationDate="2014-05-26T15:04:33.687" Score="1" Body="&lt;p&gt;In my opinion, think USB on the Arduino is stable enough for production use.* There are ways to rename your Arduino if someone would connect it to a computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the real problem with this approach is people tampering with it. I know it's open source and all, but do you really want users (if it does get produced on a big scale, which is unlikely, but &lt;em&gt;possible&lt;/em&gt;) without much tech knowledge plugging it into their computer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If none of that sounds like a problem to you (and the delay/reset problems outlined by others isn't a big deal), I'd say go for USB. It's pretty easy to use, and it's universal, thus someone could connect the system to their computer if you developed the software for PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Assuming you're using a full Arduino in a production environment, you won't care about if it shows up to the computer as &quot;Arduino Uno.&quot;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-26T15:04:33.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1716" PostTypeId="2" ParentId="1618" CreationDate="2014-05-26T15:14:22.193" Score="1" Body="&lt;p&gt;Have you got the TX from the Bluetooth module linked to the RX pin of the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have you need to unhook it whilst uploading. A better solution is not to use the TX RX pins of the Arduino and use serial software instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a simple tut but it spreads over a few pages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ianlangelectronic.webeden.co.uk/#/arduino-bluetooth/4583456314&quot; rel=&quot;nofollow&quot;&gt;http://ianlangelectronic.webeden.co.uk/#/arduino-bluetooth/4583456314&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Bluetooth baud rate bigger than 9600 is not recommended. The Arduino struggles to keep up if it's much faster than this.&lt;/p&gt;&#xA;" OwnerUserId="1591" LastActivityDate="2014-05-26T15:14:22.193" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1717" PostTypeId="1" AcceptedAnswerId="1718" CreationDate="2014-05-26T16:02:22.130" Score="7" ViewCount="4199" Body="&lt;p&gt;From the &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;noreferrer&quot;&gt;Capacitive Sensor Page&lt;/a&gt; on the Arduino website, it states the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The capacitiveSensor method toggles a microcontroller send pin to a new state and then waits for the receive pin to change to the same state as the send pin. A variable is incremented inside a while loop to time the receive pin's state change. The method then reports the variable's value, which is in arbitrary units.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;AND&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use a 1 megohm resistor (or less maybe) for absolute touch to activate. With a 10 megohm resistor the sensor will start to respond 4-6 inches away. With a 40 megohm resistor the sensor will start to respond 12-24 inches away (dependent on the foil size)...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, as mentioned above, what I'm measuring is the time taken to change state, and I understand that more resistance = more time taken = higher value, how exactly does increasing the resistance make the sensor more sensitive, allowing it to respond without even touching it (i.e., inches away)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I not simply increasing the time taken to change state by increasing resistance? How would that make it more sensitive?!?&lt;/p&gt;&#xA;" OwnerUserId="1563" LastEditorUserId="46" LastEditDate="2014-06-02T17:26:55.153" LastActivityDate="2014-06-02T17:26:55.153" Title="Why does increasing resistance make a capacitive sensor more sensitive?" Tags="|arduino-uno|sensors|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1718" PostTypeId="2" ParentId="1717" CreationDate="2014-05-26T16:14:33.397" Score="5" Body="&lt;p&gt;A capacitor is created from two conductors with a dielectric between them. The capacitance of the capacitor is determined by the surface area of the conductors and the distance between them. The larger the conductive surface, the higher the capacitance. &lt;strong&gt;The further apart the conductors, the smaller the capacitance. Using a higher resistance means that you can use a smaller capacitance, i.e. be further away from the sensor&lt;/strong&gt;, to get the same results.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-26T16:14:33.397" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1719" PostTypeId="1" AcceptedAnswerId="1721" CreationDate="2014-05-26T17:22:25.927" Score="11" ViewCount="290" Body="&lt;p&gt;I'm new to Arduino and I saw on their website that there are many different kinds of boards.&#xA;What are the differences, or to be more specific, how would I know which board meets my requirements? I understand that the shields can be connected to the board, but are some boards that do not support certain shields?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing, is it possible to connect external sensors to an Arduino board or there are special sensors that can communicate with the board? I want to use weight sensors.&lt;/p&gt;&#xA;" OwnerUserId="1592" LastEditorUserId="26916" LastEditDate="2017-09-08T21:55:38.447" LastActivityDate="2017-09-08T21:55:38.447" Title="How do I know if a board fits my requirements?" Tags="|sensors|shields|system-design|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1720" PostTypeId="2" ParentId="1719" CreationDate="2014-05-26T17:46:14.573" Score="2" Body="&lt;p&gt;To start with arduino you need to have some factors in consideration, for example the board you will chose, arduino UNO being the starting board for most beginners, if you are already an experienced programmer in C++ you might want to try more powerful boards.&#xA;You have a pretty good overview of all of them in this link :&#xA;&lt;a href=&quot;http://arduino.cc/en/Main/Products&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/Products&lt;/a&gt;&#xA;Also there are hundreds of shields out there, you will find some in the link above.&#xA;Adafruit also has some interesting ones, &lt;a href=&quot;https://www.adafruit.com/search?q=arduino&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/search?q=arduino&lt;/a&gt;, you can even find them on ebay, and you can always buy individual sensors, LEDs, buttons etc, and plug them in directly or in a breadboard.&#xA;Sparkfun has a big variety of very interesting sensors.&#xA;There is also a lot of open source shields out there, you can check a very simple one i designed myself :&#xA;&lt;a href=&quot;http://electropepper.org/projects/prototyping/item/proto-i-os-arduino-v1-0&quot; rel=&quot;nofollow&quot;&gt;http://electropepper.org/projects/prototyping/item/proto-i-os-arduino-v1-0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="832" LastActivityDate="2014-05-26T17:46:14.573" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1721" PostTypeId="2" ParentId="1719" CreationDate="2014-05-26T18:39:10.463" Score="8" Body="&lt;p&gt;&lt;strong&gt;Things to consider when picking an Arduino board:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do I want native keyboard/mouse support? If yes: you'll need the Leonardo (or it's breadboard mountable equivalent) or the TRE (not released, dual MCU board).&lt;/li&gt;&#xA;&lt;li&gt;Do I want a small form factor and/or have it breadboard mountable? If yes, choose a board like the Mini/Micro/Nano/etc.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you want to make it even smaller, either get a board without USB built in or try using an ATTiny&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Am I computing large numbers with it? If yes: use the Due, Galileo, or TRE (not released yet)&lt;/li&gt;&#xA;&lt;li&gt;Do I want video/audio? If yes: TRE is the only way to go as of now (but it's not released yet).&lt;/li&gt;&#xA;&lt;li&gt;Do I need a USB host (and not want to have an external shield)?  If yes, use the Mega ADK (limited support), Yun, TRE (again, not released yet), or Galileo.&lt;/li&gt;&#xA;&lt;li&gt;Do I need WiFi/ethernet built in? If yes; use the Yun, TRE (still, not released yet), Ethernet &lt;em&gt;board&lt;/em&gt;, or Galileo.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How many pins do I need (and how many of each type)?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Digital: simple ON or OFF. Use these for buttons, simple lights, some communication, etc.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Stay away from the Due if you don't want to mess with 3.3V logic. Most other boards are 5V. You can work around this with either voltage dividers (doesn't always work) or level shifters. As far as I know, you can't really do much if a sensor provides max 5V; level shifters AFAIK only work with digital signals.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;UART Pins: these are the pins that you can use the serial library on. (Note: this doesn't include the software-serial library). One of these on most boards is connected to a USB chip.&lt;/li&gt;&#xA;&lt;li&gt;SPI Pins: These are pins which are used by a form of communication (like on the Ethernet shield).&lt;/li&gt;&#xA;&lt;li&gt;Inturupt Pins: These can trigger an event when the signal getting sent to the board changes. There are a couple of different settings, but this can be used for near-instant response time when low latency is critical.&lt;/li&gt;&#xA;&lt;li&gt;PWM Pins: pins that go on and off to simulate a lower voltage. It does this by turning it on and off very rapidly. This is used often for dimming LEDs and controling the speed of a motor.&lt;/li&gt;&#xA;&lt;li&gt;Analog pins: pins that can read a voltage and convert it into a number.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino Due has a much higher precision rate, as it has more possible values and it has less voltage, thus much more accuracy. &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of these types of pins can act as a digital pin. All of these, except the analog pins, are under the &quot;digital pin&quot; section of your Arduino board. I didn't go into the technical aspects of the pins; I explained then in the simplest way I could.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I left a lot of boards out of this list, but this should give you some things to think about when choosing a board. There's a lot of weird quirks with this list, so it's incomplete, especially with the types of pins. You'll just have to do research and figure out what you need and if a board can meet your needs. Just make sure to not plan two things on the same pin, especially when mixing different shields and sensors! Shields &lt;em&gt;do&lt;/em&gt; take up pins.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Shields: they are pretty much compatible with every board except for if the board is 3.3V (newer shields can adapt automatically) OR if it's a breadboard mounted board, like the Nano. There are ways to work around this problem, but it's very difficult.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-26T18:39:10.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1722" PostTypeId="1" CreationDate="2014-05-26T20:33:51.730" Score="2" ViewCount="2873" Body="&lt;p&gt;My goal is to deliver very small quantities (100 microliters) of fluid to the (approximate) center of a 25mm x 75mm surface. My first idea was to repurpose an old inkjet printer for the project. I thought I'd load the fluid dispensers (probably 3ml syringes) into the unit where the ink cartridges would go and use an arduino to manipulate the linear encoder used by the printer to tell the dispenser unit where to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main problem at the moment is that I'm having trouble getting the dispenser unit to go exactly where I want it to. I've tried incorporating the PID library into my code to get the head to oscillate around the desired position until it stops at the right location. However the oscillation never stops and the head always moves beyond the desired position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out the easiest way to get this done. Maybe that'll mean moving away from using the inkjet printer but I'd like to get some feedback here before I make any decisions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;#include &amp;lt;PID_v1.h&amp;gt;&#xA;&#xA;//&#xA;//// Interrupt information&#xA;//// Int 0 on pin 2 &#xA;//// Int 1 on pin 3 Not used&#xA;//&#xA;#define encoderI 2  // Interrupt 0 is use&#xA;#define encoderQ 4 // Only use one interrupt in this example&#xA;#define maxPos   3733 // left hand side&#xA;#define minPos   0    // right hand side &#xA;#define maxSpeed 150&#xA;#define minSpeed 0&#xA;#define Freq     1600&#xA;#define maxWait  500 //12 millisec before stopping the motor&#xA;#define maxPositionError 10 //max error from actual desired position. It is approximately 0.032 of an inch&#xA;#define PIDsampleTime 25&#xA;&#xA;//&#xA;//// Tuning parameters &#xA;double kP=0.37; //Initial Proportional Gain &#xA;double kI=2; //Initial Integral Gain &#xA;double kD=0.020; //Initial Differential Gain &#xA;double Drive = 0;&#xA;&#xA;int outputSign;&#xA;//&#xA;double Setpoint, Input, Output;&#xA;&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,kP,kI,kD, DIRECT);&#xA;&#xA;volatile int ActualHeadPosition; //current position will be modified with each interrupt&#xA;volatile int PreviousHeadPosition; //Previous position will be modified with each interrupt&#xA;volatile uint8_t Speed = maxSpeed;                      //Speed for the dispenser head&#xA;volatile unsigned long lastPositionTime;&#xA;volatile int setPoint;&#xA;volatile int Err;&#xA;volatile int lastError;&#xA;volatile int Integral;&#xA;&#xA;// Create the motor shield object with the default I2C address&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;//&#xA;//// Select which 'port' M1, M2, M3 or M4. In this case, M1&#xA;Adafruit_DCMotor *dispenserDCMotor = AFMS.getMotor(1);&#xA;//&#xA;void setup() {&#xA;     Serial.begin(9600);           // set up Serial library at 9600 bps also this is the baud rate per second for the input?&#xA;     pinMode(encoderI, INPUT); //pin #2 is assigned as an input&#xA;     pinMode(encoderQ, INPUT); &#xA;     attachInterrupt(0, handleEncoder, CHANGE); &#xA;//  &#xA;     AFMS.begin(Freq);  &#xA;//   &#xA;//    // Set the speed to start, from 0 (off) to 255 (max speed)&#xA;    dispenserDCMotor-&amp;gt;setSpeed(Speed);&#xA;    dispenserDCMotor-&amp;gt;run(FORWARD);&#xA;//    // turn on motor&#xA;    dispenserDCMotor-&amp;gt;run(RELEASE);&#xA;//     &#xA;  Setpoint = 1800;&#xA;  myPID.SetSampleTime(PIDsampleTime);&#xA;  myPID.SetOutputLimits(minSpeed, maxSpeed);&#xA;&#xA;    //turn the PID on&#xA;    myPID.SetMode(AUTOMATIC);&#xA;&#xA;     //Initialize procedure should be the first thing&#xA;    Initialize();&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.print(&quot;, ActualHeadPosition: &quot;);Serial.print(ActualHeadPosition);Serial.print(&quot;, SetPoint: &quot;);Serial.println(setPoint);&#xA;&#xA;  setPoint = 1800;&#xA;  Input = ActualHeadPosition;&#xA;  outputSign = myPID.Compute();&#xA;  Err = setPoint - ActualHeadPosition;&#xA;  Serial.print(&quot;PID Output&quot;);Serial.print(Output);Serial.print(&quot; Error: &quot;);Serial.println(Err);&#xA;  Speed = Output;&#xA;  if (Err &amp;gt; 0){&#xA;    moveLeft();&#xA;    Serial.println(&quot;moveLeft&quot;);&#xA;  }&#xA;   else if (Err &amp;lt; 0){&#xA;     moveRight();&#xA;     Serial.println(&quot;moveRight&quot;);&#xA;  }&#xA;&#xA;};&#xA;//&#xA;void handleEncoder(){  &#xA;  lastPositionTime = millis();&#xA;   PreviousHeadPosition = ActualHeadPosition;&#xA;   if(digitalRead(encoderI) == digitalRead(encoderQ)){&#xA;     //dispenser is moving to the left&#xA;     ActualHeadPosition++;&#xA;   }&#xA;   else {&#xA;     //dispenser is moving to the right&#xA;     ActualHeadPosition--;&#xA;}&#xA;&#xA; }&#xA;&#xA;void moveLeft(){&#xA;  uint8_t i;&#xA;  dispenserDCMotor-&amp;gt;run(FORWARD);&#xA;  dispenserDCMotor-&amp;gt;setSpeed(Speed);  &#xA;}&#xA;&#xA;void moveRight(){&#xA;  uint8_t i;&#xA;&#xA;  dispenserDCMotor-&amp;gt;run(BACKWARD);&#xA;  dispenserDCMotor-&amp;gt;setSpeed(Speed);  &#xA;}&#xA;&#xA;boolean isMotorMoving(){&#xA;  if (((millis() - lastPositionTime) &amp;gt; maxWait))&#xA;    return false;&#xA;  else&#xA;    return true;&#xA;}&#xA;&#xA;void Initialize(){&#xA;    //Move to origin&#xA;    moveRight();&#xA;    while (isMotorMoving()){&#xA;  //    Serial.println(&quot;MOVING!&quot;);&#xA;  delay(10);&#xA;    }&#xA;    ActualHeadPosition = 0;&#xA;    PreviousHeadPosition = 0;&#xA;    dispenserDCMotor-&amp;gt;setSpeed(0);&#xA;    dispenserDCMotor-&amp;gt;run(RELEASE);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1597" LastEditorUserId="6452" LastEditDate="2015-04-10T15:26:11.040" LastActivityDate="2015-04-10T15:26:11.040" Title="Using arduino mega with linear encoder to control movement of dispenser" Tags="|arduino-mega|pid|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1723" PostTypeId="2" ParentId="1719" CreationDate="2014-05-27T07:08:36.107" Score="2" Body="&lt;p&gt;The usual suggestion I give to people new to Arduino is to get a Starter Kit (either from the &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=product_info&amp;amp;cPath=2&amp;amp;products_id=185&quot; rel=&quot;nofollow&quot;&gt;store&lt;/a&gt; or from a &lt;a href=&quot;http://arduino.cc/en/Main/Buy&quot; rel=&quot;nofollow&quot;&gt;local reseller&lt;/a&gt;): it contains an UNO, plenty of sensors and actuators and a projects book.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-05-27T07:08:36.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1724" PostTypeId="2" ParentId="1719" CreationDate="2014-05-27T09:42:31.747" Score="2" Body="&lt;p&gt;There are some good answers already, but here are a some secondary considerations&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Many Arduino boards use a ceramic resonator rather than a crystal as their timing source. This rules out using them in critical timing applications. For instance you might need to add a real time clock board if you need to keep track of time of day.&lt;/li&gt;&#xA;&lt;li&gt;The boards based on the Atmega328 chip only have three timers, and one of these (Timer 0) is used by the delay() function, which is in turn used by other libraries. Timer 1 and timer 2 get used if you include the PWM and tone libraries. The boards based on  the 2560 chip have 6 timers, which is a lot more generous.&lt;/li&gt;&#xA;&lt;li&gt;If you want to count external inputs at speed (i.e. up to 4MHz), you need to access the Tn pin of the appropriate timer counter(s). On the UNO, only T0 is exposed to the outside world, and the timer is already in use. Even the Mega2560 boards only seem to expose T0 and T5.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="881" LastEditorUserId="881" LastEditDate="2014-05-30T06:52:17.177" LastActivityDate="2014-05-30T06:52:17.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1725" PostTypeId="1" CreationDate="2014-05-24T10:42:09.440" Score="2" ViewCount="4391" Body="&lt;p&gt;Hi i'm new to AVR assembly language so i was trying to get delay function to create 1 ms , 100us, and 1us  delays to do that i need to figure out what to replace nop's with below here (mainboard arduino uno r3 ATmega328&#xA;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;delay_ms%=:    nop                 ; code to replace  nop  \n&quot;&#xA;&quot;delay_100us%=: nop                 ; code to replace  nop  \n&quot;&#xA;&quot;delay_1us%=:   nop                 ; code to replace nop  \n&quot;&#xA;&quot;               sbiw r30,1          ; decrement ms count (r31:r30)\n&quot;&#xA;&quot;               brne delay_ms%=     ; loop to delay_ms while &amp;gt; 0  \n&quot;&#xA;&quot;               ret                 ; return from subroutine      \n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rest is below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;word millisecs;   &#xA;Serial.begin(9600); &#xA;}   &#xA;void setup() asm volatile(&#xA;&quot;          ldi r16,0x3F    ; r16 = 00111111\n&quot;&#xA;&quot;          out 4,r16       ; set pins 8-13 as outputs in DDRB\n&quot; &#xA;::: &quot;r16&quot;);&#xA;millisecs = 1000;            // 1s blink delay&#xA;Serial.begin(9600);&#xA;}&#xA;void loop() &#xA;{&#xA;long starttime = millis();        // make a note of the start time&#xA;&#xA;asm volatile(&#xA;// jump to &quot;blink&quot; - ie jump around the delay_ms subroutine&#xA;&quot;            rjmp  blink%=        ; relative jump to 'blink' \n&quot;&#xA;&quot;          ldi r16,0x3F    ; r16 = 00111111\n&quot;&#xA;&quot;          out 4,r16       ; set pins 8-13 as outputs in DDRB\n&quot;&#xA;::: &quot;r16&quot;);&#xA;&#xA;registers used:&#xA;r31 - millisecond count (lo byte)&#xA;r30 - millisecond count (hi byte)&#xA;r17 - 100 microsecond count&#xA;r16 - 1 microsecond count&#xA;Overall delay (ms) = r30:r31 * r17 * r16&#xA;---------------------------------------------------------------------*/&#xA;&quot;delay_ms%=:    nop                 ; code to replace  nop  \n&quot;&#xA;&quot;delay_100us%=: nop                 ; code to replace  nop  \n&quot;&#xA;&quot;delay_1us%=:   nop                 ; code to replace nop  \n&quot;&#xA;&quot;               sbiw r30,1          ; decrement ms count (r31:r30)\n&quot;&#xA;&quot;               brne delay_ms%=     ; loop to delay_ms while &amp;gt; 0  \n&quot;&#xA;&quot;               ret                 ; return from subroutine      \n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3669884" LastEditorUserId="368" LastEditDate="2014-05-30T15:46:28.780" LastActivityDate="2022-10-20T06:39:58.247" Title="How to create delays in AVR assembly language" Tags="|avr|assembly|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1726" PostTypeId="1" AcceptedAnswerId="1727" CreationDate="2014-05-24T16:19:58.203" Score="32" ViewCount="40682" Body="&lt;p&gt;How does the Arduino handle serial buffer overflow?  Does it throw away the newest incoming data or the oldest?  How many bytes can the buffer hold?   &lt;/p&gt;&#xA;" OwnerDisplayName="HighLife" LastActivityDate="2015-08-09T00:21:40.273" Title="How does the Arduino handle serial buffer overflow?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1727" PostTypeId="2" ParentId="1726" CreationDate="2014-05-25T08:38:17.597" Score="16" Body="&lt;p&gt;For hardware serial ports you can see in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/HardwareSerial.cpp&quot;&gt;HardwareSerial.cpp&lt;/a&gt; that the buffer size varies depending on the amount of RAM available on the particular AVR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if (RAMEND &amp;lt; 1000)&#xA;    #define SERIAL_BUFFER_SIZE 16&#xA;#else&#xA;    #define SERIAL_BUFFER_SIZE 64&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a software serial port in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/libraries/SoftwareSerial/SoftwareSerial.h&quot;&gt;SoftwareSerial.h&lt;/a&gt; the receiver buffer size &lt;code&gt;_SS_MAX_RX_BUFF&lt;/code&gt; is defined as 64 bytes. In both cases it stops attempting to insert received data into the queue when it is full, so you could get a mix to old and new data depending on how you're retrieving data from the queue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally it would be best to ensure the buffer always gets emptied in a prompt manner to avoid the buffer filling. Maybe take a look at timers and implementing a simple state machine if your problem is related to other code blocking the main loop.&lt;/p&gt;&#xA;" OwnerUserId="290" OwnerDisplayName="PeterJ" LastActivityDate="2014-05-25T08:38:17.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1728" PostTypeId="1" CreationDate="2014-05-27T16:22:04.453" Score="13" ViewCount="3223" Body="&lt;p&gt;How can we make the Arduino board interact with old, analog telephone, and to make phone calls?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess it involves connecting the board to the telephone with some specific cable (how it's called?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, I assume it will require us to use the telephone low-level dialing protocol (in order to actually interact with the phone and to send commands). Where can I read about it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a reason to concern about conversation between the digital/serial board and an analogous device?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I've read that analog telephones have relatively high voltages that can easily damage the board. I'd love to get any information about things like this, related to connecting Arduino to analog telephones, in order to know about such issues and about what to be concerned and to explore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="1601" LastActivityDate="2014-08-14T19:37:49.220" Title="Making analog telephone calls?" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1729" PostTypeId="2" ParentId="1725" CreationDate="2014-05-27T20:27:22.257" Score="3" Body="&lt;p&gt;AVR LibC already has macros that do this, provided &lt;code&gt;F_CPU&lt;/code&gt; is set correctly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Note: The Arduino IDE gets the value for F_CPU from boards.txt&#xA;#define F_CPU xxxxxxxxxx&#xA;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA; ...&#xA;&#xA;_delay_ms(1);&#xA;_delay_us(100);&#xA;_delay_us(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-27T20:27:22.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1730" PostTypeId="2" ParentId="1728" CreationDate="2014-05-27T20:32:14.273" Score="5" Body="&lt;p&gt;Buy an external voice modem with a RS-232 connection. Connect it to a RS-232C shield. Use &lt;a href=&quot;http://en.wikipedia.org/wiki/Hayes_command_set&quot; rel=&quot;noreferrer&quot;&gt;AT commands&lt;/a&gt; to dial numbers and pick up calls. Use &lt;a href=&quot;http://en.wikipedia.org/wiki/Voice_modem_command_set&quot; rel=&quot;noreferrer&quot;&gt;voice AT commands&lt;/a&gt; to transmit or receive audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Never attempt to connect the telephone line directly to an Arduino since, yes, you will fry it. The voltage is all wrong in the first place, and goes even higher when the phone line rings.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-05-27T20:43:47.167" LastActivityDate="2014-05-27T20:43:47.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1731" PostTypeId="5" CreationDate="2014-05-27T23:35:42.643" Score="0" Body="&lt;p&gt;For more information see the &lt;a href=&quot;/questions/tagged/isr&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;isr&amp;#39;&quot; rel=&quot;tag&quot;&gt;isr&lt;/a&gt; tag.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:57.570" LastActivityDate="2015-08-30T20:37:57.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1732" PostTypeId="4" CreationDate="2014-05-27T23:35:42.643" Score="0" Body="Interrupts allow the processor to suspend normal operation temporarily so that a high-priority software or hardware event can be handled instead." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-27T23:35:42.643" LastActivityDate="2014-05-27T23:35:42.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1733" PostTypeId="5" CreationDate="2014-05-27T23:47:00.053" Score="0" Body="&lt;p&gt;The &lt;code&gt;analogWrite()&lt;/code&gt; function is part of the standard Arduino library. It does not allow true digital-to-analog conversion. Rather, it generates a PWM (Pulse Width Modulation) output signal on any compatible pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has the following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(pin, value);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first parameter identifies the IO pin number to generate the signal on. The second parameter should be in the range 0-255, and specifies the duty cycle to use (0 is 'always off', 255 is 'always on').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full documentation is available online here: &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/AnalogWrite&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Please only use this tag for questions which are specific to the &lt;code&gt;analogWrite()&lt;/code&gt; function. For questions about PWM in general, please use the &lt;a href=&quot;/questions/tagged/pwm&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pwm&amp;#39;&quot; rel=&quot;tag&quot;&gt;pwm&lt;/a&gt; tag.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-27T23:47:00.053" LastActivityDate="2014-05-27T23:47:00.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1734" PostTypeId="4" CreationDate="2014-05-27T23:47:00.053" Score="0" Body="The analogWrite() function is used to generate a PWM (Pulse Width Modulation) output signal on compatible pins." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-27T23:47:00.053" LastActivityDate="2014-05-27T23:47:00.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1735" PostTypeId="5" CreationDate="2014-05-28T00:08:21.070" Score="0" Body="&lt;p&gt;The purpose of a button is to change the state of a connection when it is pushed. The connection change may be momentary (push-to-make or push-to-break), or it may be toggled on/off by consecutive pushes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A microcontroller can monitor the connection, allowing the button to act as a simple input mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag when asking about using button components in Arduino projects. This can include issues such as connections and de-bouncing.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:08:21.070" LastActivityDate="2014-05-28T00:08:21.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1736" PostTypeId="4" CreationDate="2014-05-28T00:08:21.070" Score="0" Body="A button is a simple input component which responds to being pushed by a user." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:08:21.070" LastActivityDate="2014-05-28T00:08:21.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1737" PostTypeId="5" CreationDate="2014-05-28T00:22:45.237" Score="0" Body="&lt;p&gt;A variable holds data in a sketch/program. For example, a program might store the result of an analog-to-digital conversion in an integer variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = analogRead(2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, a variable named &lt;code&gt;val&lt;/code&gt; is being declared with type &lt;code&gt;int&lt;/code&gt; (integer). It is being initialised to contain the result of a call to &lt;code&gt;analogRead()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other common variable types can include &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;char&lt;/code&gt;, &lt;code&gt;long&lt;/code&gt;, and pointer, among others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables are technically distinct from objects (instances of a class/struct), but they are largely handled in the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this tag for Arduino programming issues which specifically relate to the use of variables. This is likely to be quite rare, so please consider that there may be a more suitable tag, such as &lt;a href=&quot;/questions/tagged/programming&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;programming&amp;#39;&quot; rel=&quot;tag&quot;&gt;programming&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:22:45.237" LastActivityDate="2014-05-28T00:22:45.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1738" PostTypeId="4" CreationDate="2014-05-28T00:22:45.237" Score="0" Body="Variables are used to store data in a sketch/program." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:22:45.237" LastActivityDate="2014-05-28T00:22:45.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1739" PostTypeId="5" CreationDate="2014-05-28T00:25:37.620" Score="0" Body="&lt;p&gt;A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://en.wikipedia.org/wiki/Servomotor&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="4900" LastEditDate="2019-08-06T08:43:08.770" LastActivityDate="2019-08-06T08:43:08.770" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1740" PostTypeId="4" CreationDate="2014-05-28T00:25:37.620" Score="0" Body="A servo is a type of motor which uses a feedback mechanism for precise control of speed and position." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:25:37.620" LastActivityDate="2014-05-28T00:25:37.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1741" PostTypeId="5" CreationDate="2014-05-28T00:29:12.393" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:29:12.393" LastActivityDate="2014-05-28T00:29:12.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1742" PostTypeId="4" CreationDate="2014-05-28T00:29:12.393" Score="0" Body="Modbus is a simple protocol for serial communication between electronic devices." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T00:29:12.393" LastActivityDate="2014-05-28T00:29:12.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1743" PostTypeId="2" ParentId="1722" CreationDate="2014-05-28T01:37:35.527" Score="1" Body="&lt;p&gt;The easiest option, using the code you have, is to spend a little time tuning the PID algorithm. The lines you are interested in are these&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double kP=0.37; //Initial Proportional Gain &#xA;double kI=2; //Initial Integral Gain &#xA;double kD=0.020; //Initial Differential Gain&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PID takes a setpoint and a current location, calculates error, and uses it to make a new output that should sent the location to the setpoint. It does this by adding &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P*(error)+I*(all historic error added together)+D*(recent change in error)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By changing the multipliers P, I, and D, you change how it reacts to different situations. In your system, the D value will have very little effect (at least in my experience). You should probably keep that where it is, or even just set it to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The P value controls direct response to error, and should be the main component in your setup. Try increasing this to make it move faster, and mildly decrease the oscillations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The I value controls how much all historic error affects output. It is the factor leading to all the oscillations. Lowering it will make your output settle sooner. It also assists when fighting other constant forces, or if static friction keeps the head locked in one position too close for the P term to overpower. My guess is in your isolated and low friction system, it should be very low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Increment these values slowly (.05 at a time maybe) and experiment, you should be able to fix your oscillations and make the system behave how you want. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-28T01:37:35.527" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1745" PostTypeId="5" CreationDate="2014-05-28T08:59:04.347" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T08:59:04.347" LastActivityDate="2014-05-28T08:59:04.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1746" PostTypeId="4" CreationDate="2014-05-28T08:59:04.347" Score="0" Body="AVR is the family of microcontrollers used in Arduino boards." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T08:59:04.347" LastActivityDate="2014-05-28T08:59:04.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1747" PostTypeId="1" CreationDate="2014-05-28T09:53:58.120" Score="4" ViewCount="413" Body="&lt;p&gt;I would like to integrate an Arduino Due into a project, which probably will evolve over time and will need some re-programming. Instead of having to disconnect and pull out the Arduino Due out from the enclosure, I was wondering whether it can be set up for wireless programming via an Xbee in a similar way as for the Arduino Fio (like described here: &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardFioProgramming&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardFioProgramming&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone tried that already or succeeded doing that?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2021-05-25T15:43:52.377" Title="Arduino Due - wireless programming via Xbee" Tags="|arduino-due|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1748" PostTypeId="1" CreationDate="2014-05-28T10:16:41.687" Score="8" ViewCount="7306" Body="&lt;p&gt;Ok, Arduino is a good technology but is it used professionally? Is the quality good enough to be used for professional purposes?&lt;/p&gt;&#xA;" OwnerUserId="1549" LastEditorUserId="729" LastEditDate="2014-05-28T22:20:23.563" LastActivityDate="2015-02-27T00:35:53.703" Title="Are there any products based on Arduino that are sold by companies?" Tags="|build|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1749" PostTypeId="2" ParentId="1748" CreationDate="2014-05-28T11:49:19.123" Score="6" Body="&lt;p&gt;Yes, you can also use an Arduino for professional usage. The Arduino is actually just a prototyping device and easy to use for people at home/school. I suppose there might be products on the market which were developed using an Arduino. But the most important thing is the Atmel MCU inside the Arduino which can be used for anything. But, if you wanna know if the ATmega328P-PU which is used in the Arduino Uno is a common MCU used by professionals? The answer would be no. Everything has to be smaller and better so it'll be more likely to find the same MCU like the Arduino Leonardo, Mega etc etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples where professionals might use an Arduino for as base (The end product will only contain the MCU of the Arduino):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Kid toys like an Simon Says Game, Line following toy cars etc etc.&lt;/li&gt;&#xA;&lt;li&gt;Small industrial products like an automated tape dispenser.&lt;/li&gt;&#xA;&lt;li&gt;AVR programmers.&lt;/li&gt;&#xA;&lt;li&gt;Card readers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1532" LastEditorUserId="1532" LastEditDate="2014-05-28T13:17:41.957" LastActivityDate="2014-05-28T13:17:41.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1750" PostTypeId="2" ParentId="1748" CreationDate="2014-05-28T11:54:43.337" Score="7" Body="&lt;p&gt;In theory, an Arduino board &lt;em&gt;could&lt;/em&gt; be used in some low-end professional products (i.e. where the performance and memory limitations aren't an issue). The build quality of the official boards is certainly good enough. The only issue they would potentially have is making suitably robust connections -- i.e. anything plugged into a female header would have the potential to get shaken loose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice though, using an Arduino board would only make sense for extremely small-scale projects, where only a few units will be produced, and where there will be a minimum of external circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A commercial project would normally have a custom circuit board designed. That allows them to economise on space and features, eliminating unnecessary costs. Even if it only saves a small amount per board, it can make a big difference if you're doing mass-production.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, a professional product could certainly use an AVR microcontroller or similar at its heart (much like the Arduino boards). Atmel was producing chips long before Arduino was around, and their products are well known and widely used. The choice really depends on the needs of the individual project.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-05-28T19:30:21.293" LastActivityDate="2014-05-28T19:30:21.293" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1751" PostTypeId="1" CreationDate="2014-05-28T22:45:54.887" Score="1" ViewCount="4888" Body="&lt;p&gt;I'm struggling to get the CC3000 to connect to a heroku hosted app, and other examples posted online haven't turned on the light bulb quite yet for me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gist is that I collect some temperature and humidity readings, and then send those via a GET request using the CC3000. The heroku app then reads the parameters and displays them on a page. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CC3000 hardware is A-OK, as I've tested it using the test sketches. The sketch I've put together (on github: &lt;a href=&quot;https://github.com/jsimms/compost_monitor&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jsimms/compost_monitor&lt;/a&gt;) works except for the last bit where it needs to connect to the server and send the HTTP request. Which makes me wonder if this is a heroku quirk, or if I'm just screwing something up right at the finish line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I define everything &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define WEBSITE      &quot;myapp.herokuapp.com&quot;&#xA;String route = &quot;/sensor&quot;;&#xA;uint32_t ip;&#xA;int port = 80; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then during setup, I use getHostByName to assign the ip variable. I print it out, just to confirm it was able to snag an ip. I then close it to make sure I don't screw up anything during the loop. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ip = 0;&#xA;  Serial.print(WEBSITE); Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;  while (ip == 0) {&#xA;    if (! cc3000.getHostByName(WEBSITE, &amp;amp;ip)) {&#xA;      Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  // Close the connection&#xA;  Serial.println(F(&quot;Closing connection...&quot;));&#xA;  cc3000.disconnect();&#xA;  Serial.println(F(&quot;Connection closed.&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;During the loop, I create a String with the request, and then call a function that actually does the request. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String request = &quot;GET &quot; + route + &quot;?temp=&quot; + temperature + &quot;&amp;amp;hum=&quot; + humidity + &quot; HTTP/1.0\r\n&quot;;&#xA;send_request(request);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, the send_request function is supposed to take care of connecting via TCP and sending it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send_request (String request)&#xA;{&#xA;  // Connect to server &#xA;  Serial.println(&quot;Connecting to server...&quot;);&#xA;  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, port); &#xA;&#xA;  // Send the request &#xA;  if (www.connected()) {&#xA;      www.println(request);&#xA;      www.println(F(&quot;User-agent: CompostMonitor/1.0\r\n&quot;));      &#xA;      www.println(F(&quot;\r\n&quot;));&#xA;      Serial.println(&quot;Connected &amp;amp; data sent successfully...&quot;);&#xA;    } &#xA;    else {&#xA;      Serial.println(F(&quot;Connection failed.&quot;));    &#xA;    }&#xA;&#xA;    while (www.connected()) {&#xA;      while (www.available()) {&#xA;&#xA;      // Read answer&#xA;      char c = www.read();&#xA;      Serial.println(c); &#xA;      }&#xA;    }&#xA;&#xA;  // Disconnect &#xA;  Serial.println(&quot;Closing connection...&quot;);&#xA;  Serial.println(&quot;&quot;); &#xA;  www.close(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I never get anything but connection failed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight and help would be wonderfully appreciated. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Ok. So, through the comments below, I was able to identify by telnet'ing the web app, that there was something wrong with the HTTP requests. I made a small tweak to the app, but the real issue was that I wasn't including Host: weathervane.herokuapp.com in the header. FML! I'm going to test out sending the request with the Arduino later tonight. Hopefully that puts an end to this HTTP 101 lesson I've been doing. &lt;/p&gt;&#xA;" OwnerUserId="1623" LastEditorUserId="1623" LastEditDate="2014-06-03T00:29:22.820" LastActivityDate="2015-03-29T09:57:38.073" Title="CC3000 - Send GET request to an app on heroku" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1752" PostTypeId="1" AcceptedAnswerId="1754" CreationDate="2014-05-29T08:10:51.407" Score="11" ViewCount="10193" Body="&lt;p&gt;I am trying to find some sort of wifi adapter for Arduino, it needs to be as small as possible (not a shield) and as cheap as possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I can only seem to find shields that cost about £10+ but I figured that if you can get a replacement wifi adapter for a laptop for next to nothing that I should be able to get a wifi adapter for Arduino much cheaper than this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible I just don't know what to search for.&lt;/p&gt;&#xA;" OwnerUserId="1622" LastEditorUserId="1622" LastEditDate="2014-05-29T09:56:47.413" LastActivityDate="2020-11-14T00:53:38.403" Title="What is the cheapest way to add wifi to Arduino?" Tags="|arduino-mega|wifi|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1753" PostTypeId="2" ParentId="1752" CreationDate="2014-05-29T11:24:43.540" Score="1" Body="&lt;p&gt;The Roving Networks RN-XV WiFly module (&lt;a href=&quot;http://www.watterott.com/de/Roving-Networks-RN-XV-WiFly-Module&quot; rel=&quot;nofollow&quot;&gt;found sold at €30&lt;/a&gt;) might be a solution. I've never tried it. It supports 802.11b/g.&lt;/p&gt;&#xA;" OwnerUserId="27" LastEditorUserId="365" LastEditDate="2014-05-29T14:11:53.097" LastActivityDate="2014-05-29T14:11:53.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1754" PostTypeId="2" ParentId="1752" CreationDate="2014-05-29T12:31:24.187" Score="8" Body="&lt;p&gt;Some months have passed since my previous answer and now the ESP8266 based WiFi modules are available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They get connected to your project serially (3.3V) and are controlled in a modem like way using AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a pricing of round about $5 they fit the question better than my previous OpenWrt based answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information about ESP8266 ask your favorite finding machine or &lt;a href=&quot;http://hackaday.com/tag/esp8266/&quot;&gt;list news with tag ESP8266 at Hackaday&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Old answer from the pre-ESP8266-days:)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I vote for a small router reflashed with OpenWrt like &quot;TP-Link TL-WR703N&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is like building an own Yùn with an Arduino of your choice...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The WR703N:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has Ethernet, 150MBit WiFi, USB and if you want to solder, a serial console and 2 GPIO-Pins which can be turned into I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This sure is not a chip- or stamp-sized solution but often cheaper than the alternatives, more powerfull and extendable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search the net with your favourite find'o'bot for &quot;arduino wr703n&quot; and you'll find lots of examples...&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="653" LastEditDate="2014-10-26T09:51:47.080" LastActivityDate="2014-10-26T09:51:47.080" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1755" PostTypeId="2" ParentId="1751" CreationDate="2014-05-29T14:56:41.347" Score="2" Body="&lt;p&gt;Have a look at this code:  &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/examples/SendTweet/SendTweet.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/examples/SendTweet/SendTweet.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a delay after &lt;code&gt;cc3000.connectTCP&lt;/code&gt; to wait for connection. Your code does not wait for the connection and thus gives 'connection failed' straight away.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(F(&quot;OK\r\nConnecting to server...&quot;));&#xA;t = millis();&#xA;do {&#xA;    client = cc3000.connectTCP(ip, 80);&#xA;} while((!client.connected()) &amp;amp;&amp;amp;&#xA;    ((millis() - t) &amp;lt; connectTimeout));&#xA;&#xA;if(client.connected()) { // Success!&#xA;&#xA;etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit based on comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;getHostByName returns positive value on success and negative on failure. Therefore the check should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (cc3000.getHostByName(WEBSITE, &amp;amp;ip) &amp;lt; 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also try putting &lt;code&gt;http://&lt;/code&gt; in the website address&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-05-30T11:57:50.350" LastActivityDate="2014-05-30T11:57:50.350" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="1757" PostTypeId="2" ParentId="1618" CreationDate="2014-05-29T16:06:28.957" Score="3" Body="&lt;p&gt;I wrote the tutorial you were following so maybe I can help. When I was building the circuit initially I used some of the other tutorials out there on Arduino Bluetooth programming which don't have a lot of the extra resistors and capacitor.  However, I couldn't get any of those to work reliably.  Using a circuit simulator and some trial and error, I ended up with the circuit shown in the tutorial which worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While there &quot;doesn't seem to be a need for&quot; some of the extra passives, if your circuit doesn't work without them, perhaps there is a need for them after all? ;-) Now, I have heard from other people that they were able to leave out certain bits so it seems that there is some variability in the hardware. But we're talking four passives to ensure reliable operation, so why leave them out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, a couple of points:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Pin 32 on the HC-05 becomes active upon Bluetooth connection.  We configure the pin to be active low so we can use it to auto-reset the Arduino upon serial connection to emulate what happens with the normal USB connection.  You can leave out the connection to pin 32 only if you want to have to manually reset the Arduino to program it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The 115200 baud rate is the rate for programming the Arduino and is set by the Arduino bootloader.  It is possible to re-flash the bootloader with a different configuration if you needed to for some reason.  &lt;p&gt;&#xA;So, the programming baud rate is fixed in the bootloader, but the communication baud rate is configurable in software using &lt;code&gt;Serial.begin()&lt;/code&gt;. However, the HC-05's baud rate has to be the same as the Arduino's, so you need to stick with the same baud rate for both programming and communication (115200 by default).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are two resistors involved with the reset, R3 and R2.  I believe R2 is only necessary for 5V Arduinos to act as a voltage divider with R3.  However, R3 should be included for any voltage Arduino. See this &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_application-note_avr042.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmel design note&lt;/a&gt; - &quot;The reset line has an internal pull-up resistor, but if the environment is noisy it can be insufficient and reset can therefore occur sporadically ... This pull-up resistor makes sure that reset does not go low unintended.&quot; R3 should be 4.7k or greater; most designs stick with 10k.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The capacitor C1 is necessary because Pin 32 stays low the entire time Bluetooth is connected.  If you connect RST to Pin 32 directly, the Arduino will just stay reset until the Bluetooth connection drops and nothing will work just as if you held down the reset button and never let go.&lt;br&gt;&#xA;&lt;p&gt;&#xA;With C1 in place, when Pin 32 goes low it will momentarily discharge C1, pulling RST low and resetting the Arduino. C1 will immediately begin charging through R3 back up to VCC which will restore RST to high, bringing the Arduino out of reset.  The values of R3 and C1 affect the timing of the reset and must be chosen appropriately.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't forget R1.  I can't remember the reason it is helpful, but it has something to do with the Arduino/Atmel UART.  I found the recommendation for adding it one day on an Atmel discussion board and it has solved a non-working circuit for me many times.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-05-29T16:06:28.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1758" PostTypeId="1" AcceptedAnswerId="1792" CreationDate="2014-05-29T16:30:12.650" Score="6" ViewCount="8263" Body="&lt;p&gt;I want to sample an Analog sensor as fast as possible, and time-stamp each sample that I take as accurately as possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm doing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = analogRead(SENSOR_PIN);&#xA;clocktime = micros();&#xA;&#xA;writeData(val, clocktime); // writes the values to an SD card&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there is a more-accurate way of time-stamping the data from the analogRead call. Put another way, I would like to record the exact time that the analogRead data was collected. My guess is that this is basically impossible on an Arduino, so what technique will let me get as close as possible?&lt;/p&gt;&#xA;" OwnerUserId="1632" LastEditorUserId="1632" LastEditDate="2014-06-03T20:24:34.987" LastActivityDate="2014-06-03T22:09:02.717" Title="What's the most accurate way to time-stamp analogRead data?" Tags="|time|analogread|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1759" PostTypeId="1" AcceptedAnswerId="1762" CreationDate="2014-05-29T18:12:55.957" Score="2" ViewCount="158" Body="&lt;p&gt;I used Arduino successfully on my old Linux Fedora 12 system. Now I have a brand new PC with Fedora 20, and have today installed Arduino on it. In my first attempt to use it I typed Arduino as follows at the root prompt, after the &quot;yum install arduino&quot; gave me &quot;Complete!&quot;, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Complete!&#xA;[1344][root@localhost:/home/Harry]# arduino&#xA;WARNING:  RXTX Version mismatch&#xA;    Jar version = RXTX-2.2&#xA;    native lib Version = RXTX-2.2pre2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Subsequently I have loaded the &quot;Blink&quot; sketch, and that is running nicely, whether I start the IDE from the command line, which still gives me the same WARNING, or from the desktop icon, which does not give it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: please, does this WARNING matter? If so, what should I do about it?&lt;/p&gt;&#xA;" OwnerUserId="1631" LastActivityDate="2014-05-29T21:37:34.440" Title="How do I avoid this error trying to connect arduino to pc with linux fedora 20" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1760" PostTypeId="1" CreationDate="2014-05-29T19:41:28.227" Score="1" ViewCount="439" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sxh3Z.jpg&quot; alt=&quot;enter image description here&quot;&gt;I have a weird thing with my servo, I really dont know what is wrong with my code, I tried everything. Either it is my connection on arduino or my code. Please help me guys, this is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;     &#xA;&#xA;int servoPin = 9;     &#xA;Servo servo;          &#xA;int angle = 0;         &#xA;int photocellPin = 0;  &#xA;&#xA;void setup() { &#xA;  servo.attach(servoPin);  &#xA;} &#xA;&#xA;void loop() { &#xA;  int reading = analogRead(photocellPin);     &#xA;  Serial.print(&quot;Reading = &quot;);&#xA;  Serial.println(photocellPin);&#xA;  int newAngle = reading / 2;             &#xA;  servo.write(newAngle);  &#xA;  delay(80);                      &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1634" LastEditorUserId="1634" LastEditDate="2014-05-29T20:08:08.440" LastActivityDate="2014-05-29T21:27:00.607" Title="Arduino servo acts weird with photocell (lightsensor)" Tags="|servo|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="1761" PostTypeId="2" ParentId="1760" CreationDate="2014-05-29T21:27:00.607" Score="3" Body="&lt;p&gt;Servos accept a signal from 0 to 180, with 90 being the center point on the servo. analogRead() will output a number from 0 to 1023. The arduino &quot;map&quot; function makes a conversion easy to do. just replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int newAngle = reading / 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int newAngle = map(reading, 0, 1023, 0, 180);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can read more about the map function here: &lt;a href=&quot;http://arduino.cc/en/reference/map&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/reference/map&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is hard to tell from the picture that everything else is wired correctly, but this should fix up your code. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-29T21:27:00.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1762" PostTypeId="2" ParentId="1759" CreationDate="2014-05-29T21:37:34.440" Score="2" Body="&lt;p&gt;The warning, as I'm sure you can tell, is about a mismatch in version of RXTX arduino is expecting, and what is installed on your system. If everything is functioning, I would not worry about it at all. The versions seem to only be slightly different, maybe just a few bug fixes are missing from the older one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;RXTX is a library for java to communicate with serial devices, but it is not under development anymore and only available from mirrors, not the original developer site. Arduino has moved on to a library called jSSC, which is currently being maintained, and a much better library IMHO. The change to jSSC is still only in the arduino beta version, 1.5.6r2 at time of writing, but it works very well. Anyway, if RXTX ever actually gives you trouble, you can download the beta version of arduino and not have to deal with it. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-29T21:37:34.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1763" PostTypeId="2" ParentId="1758" CreationDate="2014-05-29T21:48:24.000" Score="5" Body="&lt;p&gt;There is no more accurate way of getting time on the arduino, but I would suggest you use millis() instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;micros() returns microseconds, or millionths of a second, since the arduino was turned on. The issue is that the 32 bit unsigned integer used to store time on the arduino can only count about 70 minutes worth of micros before overflowing and resetting to 0. (see &lt;a href=&quot;http://arduino.cc/en/reference/micros&quot;&gt;http://arduino.cc/en/reference/micros&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;millis() is in thousandths of a second since the arduino turned on, and it will not reset for about 50 days. If you think one thousandths of a second is good enough resolution, it will probably be the better choice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need time to be absolute, as in the current day/hour/minute, you will need to buy a real time clock to plug into the arduino. They are about 20 bucks, and available from all the standard arduino accessory stores like sparkfun, adafruit, ect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On your question of the order, both commands run so quickly, I can think of no reason it would matter. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-05-29T21:48:24.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1764" PostTypeId="1" AcceptedAnswerId="1765" CreationDate="2014-05-29T23:40:56.367" Score="6" ViewCount="102" Body="&lt;p&gt;I am making a device which will have an Arduino board and a sensor attached to it. The sensor will acquire data every 10 minutes and the data will be uploaded to my server. The size of every upload is about 200 characters. I'd like this device to work anywhere in my city (US).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my options for uploading data to my server? Keep in mind that it will work without human intervention. FYI... this is NOT for reconnaissance device! ;)&lt;/p&gt;&#xA;" OwnerUserId="1637" LastEditorUserId="220" LastEditDate="2014-05-30T00:08:57.697" LastActivityDate="2014-05-30T14:03:32.260" Title="How do I remotely acquire data from Arduino based portable device?" Tags="|uploading|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1765" PostTypeId="2" ParentId="1764" CreationDate="2014-05-30T00:21:18.743" Score="5" Body="&lt;p&gt;I can't guarantee &lt;em&gt;anywhere&lt;/em&gt; in your city, but this hack will work pretty much wherever there is cell coverage for the carrier you choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll want the &lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;GSM shield&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/294KE.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Picture from Arduino&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, it uses pins 2, 3, and 7 on it. It also has the ability to solder (on the bottom of it) a microphone and speaker connection. You'll need to buy a SIM card and a contract to connect your shield to a network. I don't know how often you would use this, but I've seen a pay-as-you-go plan that charges you $2 for unlimited talk/text/internet per day. If you're going to use this once a month, that would be the way to go. I didn't look to see if they supported the GSM shield (it was on TMobile's site). You would want to contact them for more details. Also, depending on where you live, I don't know if you would get good coverage. This goes with any cell phone provider, but make &lt;em&gt;sure&lt;/em&gt; that you get coverage where you want to go (and don't always trust the maps they provide).&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="46" LastEditDate="2014-05-30T14:03:32.260" LastActivityDate="2014-05-30T14:03:32.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1767" PostTypeId="1" CreationDate="2014-05-30T02:28:33.580" Score="2" ViewCount="174" Body="&lt;p&gt;I have a &lt;code&gt;pins_arduino.h&lt;/code&gt; file for a given Arduino variant, installed in &lt;code&gt;~/sketchbook/hardware/attiny/variants/tiny14/pins_arduino.h&lt;/code&gt;. The IDE has no problem picking it up if I set the right board type. However, if I use a &lt;code&gt;Makefile&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BOARDS_TXT      = $(HOME)/sketchbook/hardware/attiny/boards-cli.txt&#xA;BOARD_TAG       = attiny44-8&#xA;&#xA;include /usr/share/arduino/Arduino.mk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then running &lt;code&gt;make&lt;/code&gt; fails to compile it because of a missing &lt;code&gt;pins_arduino.h&lt;/code&gt;. Moving the &lt;code&gt;tiny14&lt;/code&gt; directory to &lt;code&gt;/usr/share/arduino/hardware/arduino/variants&lt;/code&gt;  fixes the problem, but I don't want to pollute my system directory (and also, it sounds fragile if I ever remove/replace my Arduino software distribution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get the CLI &lt;code&gt;Make&lt;/code&gt; toolchain to pick up my &lt;code&gt;pins_arduino.h&lt;/code&gt; file from my &lt;code&gt;~/sketchbook&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="1568" LastEditorUserId="1568" LastEditDate="2014-05-30T02:34:49.973" LastActivityDate="2014-05-30T02:34:49.973" Title="Adding an Arduino variant into ~/sketchbook and using it from a Makefile" Tags="|arduino-ide|build|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1768" PostTypeId="2" ParentId="1538" CreationDate="2014-05-30T07:04:31.013" Score="3" Body="&lt;p&gt;&lt;strong&gt;Please note that I did not try to run your code on my Mega because I don't have SRFs&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;However, here is what I tried to recreate your error:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I went to the arduino homepage and downloaded the 1.0.5 version.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I downloaded the zipped library from this page &lt;a href=&quot;http://playground.arduino.cc/Main/SonarSrf08&quot; rel=&quot;nofollow noreferrer&quot;&gt;SRF08 Ultra Sonic Range Finder&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I imported the library into the arduino IDE. For this, I had to unpack the .zip and rename the folder of the library because arduino complained about non-ascii characters. I just called the enclosing folder &amp;quot;arduinoSRFmaster&amp;quot; without dashes. After that it let me import the library the usual way:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DbRD3.png&quot; alt=&quot;How to Install a Library&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After that I copied your code into a new sketch and hit Ctrl + R to compile and verify. It compiled just fine:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jdTRP.png&quot; alt=&quot;Successfull compiling&quot; /&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(Picture updated for compiling against MEGA)&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Please provide more information, like yor OS, Arduino Version, where you got the SRF Library from etc. if that didn't help.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-05-31T15:53:34.910" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1772" PostTypeId="2" ParentId="1661" CreationDate="2014-05-30T15:07:43.167" Score="0" Body="&lt;p&gt;My eventual workaround for the Leonardo was to set up a call-response loop on the Leonardo.  Here's the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int ADDRESS = 0x28;//I2C address of sensor&#xA;int REQUEST = 4;//# of bytes to request from sensor&#xA;int BAUD = 19200;//serial rate&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(A1, INPUT);&#xA;  Wire.begin();        // join i2c bus (address optional for master)&#xA;  Serial.begin(BAUD);  // start serial for output&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    Serial.read();&#xA;    Wire.requestFrom(ADDRESS, REQUEST);    // request 4 bytes from slave device at 0x28&#xA;    while(Wire.available())    // slave may send less than requested&#xA;    { &#xA;       Serial.print(((unsigned int)Wire.read() &amp;lt;&amp;lt; 8) + Wire.read());&#xA;       Serial.print(',');&#xA;       Serial.println(((unsigned int)Wire.read()) &amp;lt;&amp;lt; 3) + (Wire.read() &amp;gt;&amp;gt; 5);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to simplify a little.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no built in delay and requests made too quickly will result in either an empty response or old data from the sensor.  Have to take into account in requesting program.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The sketch will respond a number of times equal to the number of bits sent.  Use a single ASCII character for one response, 2 characters for 2 responses, etc...  This is important if you use an API similiar to a write() and writeln() as the second sends extra characters.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1553" LastActivityDate="2014-05-30T15:07:43.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1773" PostTypeId="1" AcceptedAnswerId="1775" CreationDate="2014-05-30T18:00:41.717" Score="9" ViewCount="4159" Body="&lt;p&gt;I've read that the &lt;code&gt;millis()&lt;/code&gt; function uses the same timer as a couple of PWM pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using those PWM pins, will &lt;code&gt;millis()&lt;/code&gt; still return the correct value?&lt;/p&gt;&#xA;" OwnerUserId="1656" LastEditorUserId="1656" LastEditDate="2016-03-24T12:13:17.313" LastActivityDate="2016-03-24T12:13:17.313" Title="Does millis() conflict with the PWM pins associated with timer 0?" Tags="|timers|pwm|millis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1774" PostTypeId="1" CreationDate="2014-05-30T18:23:16.767" Score="1" ViewCount="7435" Body="&lt;p&gt;I have the following code in which &lt;code&gt;requestLine&lt;/code&gt; is always empty and I can't figure out why. &lt;code&gt;request&lt;/code&gt; contains a raw HTTP request, and I want to get the first line of the request which contains the method and the URL.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean parseRequest(String* request)&#xA;{&#xA;  int firstEOLAt = request-&amp;gt;indexOf('\n');&#xA;  if (firstEOLAt &amp;lt; 0)&#xA;    return false;&#xA;  Serial.println(firstEOLAt);&#xA;  String requestLine = request-&amp;gt;substring(0, firstEOLAt);&#xA;  Serial.println(requestLine);&#xA;  // ...rest of the parsing will go here...&#xA;  return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first &lt;code&gt;println&lt;/code&gt; returns 26 as you would expect for the string &lt;code&gt;&quot;GET /ilyen_nincs HTTP/1.1&quot;&lt;/code&gt; (25 characters long), but then &lt;code&gt;requestLine&lt;/code&gt; is always empty. I wonder why?&lt;/p&gt;&#xA;" OwnerUserId="1648" LastActivityDate="2014-05-31T09:19:24.807" Title="How to use String.substring?" Tags="|arduino-uno|string|pointer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1775" PostTypeId="2" ParentId="1773" CreationDate="2014-05-30T18:37:23.830" Score="7" Body="&lt;p&gt;They do not conflict as &lt;code&gt;millis()&lt;/code&gt; strictly reads the immediate value in &lt;code&gt;TCNT0&lt;/code&gt; whereas PWM via timer 0 uses the hardware's ability to compare the value of &lt;code&gt;TCNT0&lt;/code&gt; with the values in &lt;code&gt;OCR0x&lt;/code&gt; without affecting the value of any of them.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-30T18:37:23.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1776" PostTypeId="1" CreationDate="2014-05-30T21:44:45.560" Score="3" ViewCount="3987" Body="&lt;p&gt;Is it possible to connect the nine pins from a USB 3.0 memory drive to the corresponding GPIO pins of the arduino (intel Galileo is what I am using, but it is very similar) and access the drive's memory through the implementation of the USB's protocol? I have searched around and have not been able to get a clear idea on how to do this or if it is even possible.&lt;/p&gt;&#xA;" OwnerUserId="1659" LastActivityDate="2014-05-30T23:06:27.743" Title="Connecting a USB 3.0 Flash Drive" Tags="|serial|pins|arduino-galileo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1777" PostTypeId="1" CreationDate="2014-05-30T21:50:25.483" Score="3" ViewCount="204" Body="&lt;p&gt;Ok, this is my first project where I've not had @forsvunnet close by to help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a camera connected to an optocoupler, that just fires HIGH then LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't get a button working with it, so when I push a button, it fires opto 3 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my sketch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // Pin 13 has an LED connected on most Arduino boards.&#xA;// give it a name:&#xA;int opto = 12;&#xA;int buttonInput = 2;     // the number of the pushbutton pin&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup()&#xA;{&#xA;// initialize the digital pin as an output.m&#xA;pinMode(opto, OUTPUT);&#xA;pinMode(buttonInput, INPUT);&#xA;digitalWrite(buttonInput, LOW);}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop()&#xA;{&#xA;  buttonState = digitalRead(buttonInput);&#xA;  if (buttonState == HIGH) {&#xA;      digitalWrite(opto, HIGH);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, LOW);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, HIGH);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, LOW);&#xA;  } else {&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anyone point me in the right direction? It's driving me mad.&lt;/p&gt;&#xA;" OwnerUserId="1660" LastActivityDate="2014-05-30T23:19:15.820" Title="Button to optocoupler to fire camera 4 times" Tags="|button|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1778" PostTypeId="2" ParentId="1776" CreationDate="2014-05-30T23:06:27.743" Score="1" Body="&lt;p&gt;Since this is going to be a long post, I'll post the summary above the fold to save some of you the effort of scrolling...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; No, it's not possible to do so with GPIO pins. There is another way to do this, but IDK if the rest of the Galileo will be a bottleneck (and it's pretty pricey). The stereotypical AVR Arduino is simply too underpowered (both from a MCU and amperage standpoint) to host USB 3.0. You need a shield to host USB 2.0, and even with that, I doubt that you can use 2.0 at it's full potential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mp6iF.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Basic corrections/things to note (before I begin):&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note: I'm no expert on the Galileo, I'm just doing this all from what I remember from what I've read in the past. If you spot an error, feel free to post a comment with a little explanation and I'll fix my post. However, I doubt that there will be any major errors, and the overall content (i.e. the tl;dr) should be fine.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;These figures are maximum that I'm posting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Speed: if speed is near maximums, or even 10%, what's the point of 3.0?&lt;/li&gt;&#xA;&lt;li&gt;Power: you never know with this one, so account for it being near limits, unless externally powered. Still, don't risk it.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it's a USB thumb drive, you're going to either get a breakout board for 3.0 and/or break open your device and solder wires onto it. Note that there doesn't seem to be a USB 3.0 breakout board (from a very quick search on Google). I'm also concerned that the wires you would use might not be high enough grade for extreme data transmission.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Only 7 of the 9 lines are used for data. The other two are 5V and GND.&lt;/li&gt;&#xA;&lt;li&gt;On a Galileo, you'll have to use the 5V selection for the IO pins.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On a Galileo, there's a Mini-PCIe port (although I can't seem to find it in the photos myself). You could &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B004NO0LK8&quot; rel=&quot;nofollow noreferrer&quot;&gt;add a Mini PCIe to USB 3.0 card&lt;/a&gt;. However, that will cost you almost $50 to do so, and by that time it might be better just to seek out another solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Photo of it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;img src=&quot;https://i.stack.imgur.com/TZpl2m.jpg&quot; alt=&quot;&quot;&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ask yourself &lt;em&gt;do I really need the speed?&lt;/em&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No: don't waste the money and the headache.&lt;/li&gt;&#xA;&lt;li&gt;Yes: consider either another platform or buying this product.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Keep in mind that, although it fits, it probably won't be able to get enough power for true USB 3.0 that your disk needs &lt;em&gt;and&lt;/em&gt; drivers will be rare. You for sure will want to research this more before shelling out the cash to buy this card.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Galileo doesn't run a full OS, so I'm highly doubtful that there's drivers.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Like I mentioned before, I'm not quite sure about the Galileo supplying enough power... again you need to check into this and maybe add an external voltage regulator (if all the other issues are resolved). USB 3.0 can provide up to 2x the power per port of 2.0, so when I say almost an amp, it's technically almost two amps (although I think at this point you'll just have to remember not to use the second port and call it one amp).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Technical problems:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I stated this before in the post:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;The stereotypical AVR Arduino is simply too underpowered to host USB 3.0. You need a shield to host USB 2.0, and even with that, I doubt that you can use 2.0 at it's full potential.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Galileo has native 2.0 support, so I'd recommend just getting a fast USB drive and using that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, think about it: the Galileo can handle roughly 400,000 instructions per second. USB 3.0 can send up to &lt;strong&gt;5,000,000 bits in the same amount of time!&lt;/strong&gt; Like mentioned before, it is the maximums, but still. AFAIK on the AVR boards it it takes multiple instructions to read one GPIO pin (for some reason I want to say 3, but that seems too low). I'd imagine that it'd be the same situation on the Galileo. I'm not quite sure about the instructions it takes to read a pin, correct me if I'm wrong anyone. Anyway, assume it takes four instructions per pin, and your device only sends 1 Gbps. That's still 1,000,000 times that a pin needs to be read when you can only read 100,000 in that time. Even so, you can't even &lt;em&gt;use&lt;/em&gt; the data, nor can you implement a loop or other code that combines bytes to read the data in the first place! Plus, you wouldn't have enough RAM!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not a USB expert, but IIRC it only asks the device for data as needed, but still, that'd be pointless to create your code for this and spend the extra money for 3.0 cables and devices. This paragraph is all from memory, I don't really know; &lt;strong&gt;&lt;em&gt;don't cite this paragraph.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you'd have to implement your own code for sending data to/from the device. No such code exists without hardware for 2.0, let alone 3.0.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Conclusion:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's near impossible to do so, and you'd need a lot of extra parts and have to read up on the USB 3.0 specs. I think it would take a great engineer 50+ years to accomplish this without developing an IC (which would cost money). Do you really &lt;em&gt;need&lt;/em&gt; the speed? If not, you can buy USB 2.0 host shields and communicate via SPI. That isn't very fast, but still, it's possible.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sources:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Info and photos are scattered on the following sources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/USB&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://en.wikipedia.org/wiki/USB&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/ArduinoCertified/IntelGalileo&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/ArduinoCertified/IntelGalileo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B004NO0LK8&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.com/StarTech-com-Express-SuperSpeed-Adapter-MPEXUSB3S2/dp/B004NO0LK8&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-30T23:06:27.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1779" PostTypeId="2" ParentId="1777" CreationDate="2014-05-30T23:19:15.820" Score="1" Body="&lt;p&gt;&lt;strong&gt;First of all, the loop (if it worked well) would only fire twice.&lt;/strong&gt; It should only fire when you turn it on/off in a cycle (unless it's a rising/falling edge circuit (i.e. a &lt;em&gt;pull down button&lt;/em&gt;/a falling edge interrupt), but I won't get into that). In your code you toggle it twice. The third one? I suspect that your camera only fires when it's given a low signal. This means that, when you set it to low in &lt;code&gt;setup()&lt;/code&gt;, it takes a photo. To fix this, switch all the &lt;code&gt;HIGH&lt;/code&gt;s and the &lt;code&gt;LOW&lt;/code&gt;s for the &lt;code&gt;opto&lt;/code&gt; pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code which I think should work for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pin 13 has an LED connected on most Arduino boards.&#xA;// give it a name:&#xA;int opto = 12;&#xA;int buttonInput = 2;     // the number of the pushbutton pin&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup()&#xA;{&#xA;// initialize the digital pin as an output.m&#xA;pinMode(opto, OUTPUT);&#xA;pinMode(buttonInput, INPUT);&#xA;digitalWrite(buttonInput, HIGH);}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop()&#xA;{&#xA;  buttonState = digitalRead(buttonInput);&#xA;  if (buttonState == HIGH) {&#xA;      digitalWrite(opto, LOW);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, HIGH);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, LOW);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, HIGH);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, LOW);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, HIGH);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, LOW);&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(opto, HIGH);&#xA;  } else {&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without much info about your camera, I'd imagine that the &lt;code&gt;HIGH&lt;/code&gt;/&lt;code&gt;LOW&lt;/code&gt; discrepancy is the issue. Another note: this code doesn't protect against bouncing. It's fine if as it is because the delays will cause the bounces to not be picked up. If you do a &quot;blink without delay&quot; type of sketch using &lt;code&gt;millis()&lt;/code&gt; and a loop, you might need to fix this. Like I said, it'll work fine now, but it's kind a crude fix since it could cause problems later if mixed with other code.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-05-30T23:19:15.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1780" PostTypeId="1" CreationDate="2014-05-30T23:56:25.060" Score="0" ViewCount="933" Body="&lt;p&gt;This is the first time I'm using my Arduino. It's an Arduino UNO R3. I have two boards. One works, but the other doesn't. I changed the ATmega328P from the broken one to the good one and it works, so I can confirm that the controller works. The issue seems to be in the board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug the board it doesn't come up either in Mac or in Windows. The LED blinks and the output pins have voltage, but it seems that it's only getting electricity from the computer, it's like the data channels don't respond. The other board works perfectly both on Windows and Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the logs on the Mac and nothing changes when I plug the board. It's like I'm not plugging anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to reset the board only? Maybe a component was badly soldered in the factory. I can't use the warranty because I got the board last year and never used it until now.&lt;/p&gt;&#xA;" OwnerUserId="1666" OwnerDisplayName="zago" LastEditorUserId="729" LastEditDate="2014-05-31T02:22:02.273" LastActivityDate="2015-06-25T21:12:41.940" Title="Arduino ATmega328P works but board (Uno R3) seems broken" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1781" PostTypeId="2" ParentId="1780" CreationDate="2014-05-31T00:30:04.340" Score="2" Body="&lt;p&gt;The R3 uses an ATmega16u2 in place of the FTDI. It is possible that it is not loaded, busted crystal, or it has no local power to it. It is a small SMT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use your good Arduino setup as ICSP programmer to talk to the ICSP of the 16u2 to see it is alive. And if so then program it.&lt;/p&gt;&#xA;" OwnerUserId="60" OwnerDisplayName="mpflaga" LastEditorUserId="46" LastEditDate="2014-05-31T01:27:49.470" LastActivityDate="2014-05-31T01:27:49.470" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1784" PostTypeId="1" CreationDate="2014-05-31T08:58:03.333" Score="21" ViewCount="52662" Body="&lt;p&gt;I am looking at using a 7 channel RC receiver with the Arduino Uno R3. In the documentation, there are mentions of a maximum of 2 interrupt pins, whereas on certain other blogs I have seen mentions of using upto 20 pins as interrupts, with PinChangeInt library. So, how many interrupts can the Arduino handle natively? And is this different from  how many can be handled with software support such as PinChangeInt?&lt;/p&gt;&#xA;" OwnerUserId="65" LastActivityDate="2018-02-24T21:25:47.890" Title="How many interrupt pins can an Uno handle?" Tags="|arduino-uno|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1785" PostTypeId="2" ParentId="1774" CreationDate="2014-05-31T09:19:24.807" Score="2" Body="&lt;p&gt;&lt;code&gt;GET /ilyen_nincs HTTP/1.1\n&lt;/code&gt; is 26 characters long so string indices are from 0 to 25. Since, your second argument in &lt;code&gt;substring(0, firstEOLAt);&lt;/code&gt; exceeds the end index of the string, you are running into unexpected behavior as per the &lt;a href=&quot;http://arduino.cc/en/Tutorial/StringSubstring&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; and getting an empty string.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Caution: make sure your index values are within the String's length or you'll get unpredictable results. This kind of error can be particularly hard to find with the second instance of substring() if the starting position is less than the String's length, but the ending position isn't.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="65" LastActivityDate="2014-05-31T09:19:24.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1786" PostTypeId="2" ParentId="1784" CreationDate="2014-05-31T12:54:56.070" Score="8" Body="&lt;p&gt;There are two types of interrupts. What the &lt;strong&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/Interrupts&quot; rel=&quot;noreferrer&quot;&gt;Arduino Playground&lt;/a&gt;&lt;/strong&gt; said:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The processor at the heart of any Arduino has two different kinds of interrupts: “external”, and “pin change”. There are only two external interrupt pins on the ATmega168/328 (ie, in the Arduino Uno/Nano/Duemilanove), INT0 and INT1, and they are mapped to Arduino pins 2 and 3. These interrupts can be set to trigger on RISING or FALLING signal edges, or on low level. The triggers are interpreted by hardware, and the interrupt is very fast. The Arduino Mega has a few more external interrupt pins available.&lt;/p&gt;&#xA;&lt;p&gt;On the other hand the pin change interrupts can be enabled on many more pins. For ATmega168/328-based Arduinos, they can be enabled on any or all 20 of the Arduino's signal pins; on the ATmega-based Arduinos they can be enabled on 24 pins. They are triggered equally on RISING or FALLING signal edges, so it is up to the interrupt code to set the proper pins to receive interrupts, to determine what happened (which pin? ...did the signal rise, or fall?), and to handle it properly. Furthermore, the pin change interrupts are grouped into 3 “port”s on the MCU, so there are only 3 interrupt vectors (subroutines) for the entire body of pins. This makes the job of resolving the action on a single interrupt even more complicated.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Basically, the external interrupts are extremely fast since they're all hardware based. However, there is also the pin change interrupts, but those seem to be much slower because they are mostly software based.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; the 20 interrupt pins together are much slower. The 2 interrupt pins are the fastest and most efficient.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I just looked at the datasheet and it says that a pin change interrupt is triggered for &lt;em&gt;any&lt;/em&gt; of the pins selected with no indication of which pin has changed (although it is split into three interrupt vectors).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For external interrupts, it'll tell you &lt;em&gt;pin 3 just changed&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;For pin change it'll tell you &lt;em&gt;a pin changed that you were&#xA;monitoring!&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you can see, a pin change interrupt adds a lot of overhead into the ISR that you have to handle by storing previous states and seeing if it's the pin you're worried about. It might be fine for a sleep state, but it's better to use the external interrupts.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-07-31T15:08:11.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1787" PostTypeId="1" AcceptedAnswerId="1790" CreationDate="2014-05-31T12:58:15.603" Score="0" ViewCount="889" Body="&lt;p&gt;I bought a waterproof temperature sensor from Ebay, I am fairly new to this and not sure what I need or need to do in order to get the sensor to output the current temperature to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any information on where I can get some information on how to wire this? I have looked at various videos online but they are all for a dallas temp sensor and use the dallas library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/181393039374?ssPageName=STRK%3aMEWNX%3aIT&amp;amp;_trksid=p3984.m1439.l2649&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/181393039374?ssPageName=STRK:MEWNX:IT&amp;amp;_trksid=p3984.m1439.l2649&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1622" LastActivityDate="2014-06-01T13:37:31.213" Title="1 Wire temperature sensor" Tags="|arduino-pro-mini|temperature-sensor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1788" PostTypeId="1" AcceptedAnswerId="1789" CreationDate="2014-05-31T16:52:14.733" Score="3" ViewCount="397" Body="&lt;p&gt;I think the answer is yes, but I wanted to ask the question anyway for future common reference. And to check my understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I want to power 10 LEDs with PWM with my Mega 2560. I have a bunch of 200 ohm resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the Mega and most other Arduinos can safely provide a maximum of 200mA total current. 200mA / 10 is 20mA per LED maximum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using my 200 ohm resistors I can calculate how much voltage will supply 20 mA of current:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V = 200 ohms * 20mA&#xA;V = 4V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I just need to make sure to analogWrite less than or equal to 4V to each of the ten LEDs and I won't cross the 200mA threshold. That's if PWM was true analog.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, PWM is not true analog, and if I analogWrite 4V to each pin, they're going to spend most of the time at 5V and some of the time at 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When every pin is at 5V the board has to supply&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(5V / 200 ohms) * 10 = 250mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is over the spec, so I am in danger of damaging my board. Right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I want to calculate the maximum current draw of the 10 LEDS being powered simultaneously with PWM, I have to assume that they are all getting 5V regardless of what I analogWrite to them. I do not actually have control over the voltage, I only have control over the resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus in order to be safe I need to get some new resistors with resistance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5V / 20mA = 250 ohms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this all correct?&lt;/p&gt;&#xA;" OwnerUserId="1656" LastActivityDate="2019-02-20T00:19:32.253" Title="Does the square-wave nature of PWM dictate how much resistance you need?" Tags="|voltage-level|pwm|current|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1789" PostTypeId="2" ParentId="1788" CreationDate="2014-05-31T22:22:45.590" Score="7" Body="&lt;p&gt;It's... mostly wrong. For three independent reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs themselves, like all diodes, absorb some of the electrovoltaic potential of the electricity passing through them, resulting in a voltage decrease in their circuit. This means that although 5V is being used to power the resistor and LED in a circuit, only some of that voltage is passing through the resistor. If we use a typical (for blue, white, and other exotic colors) forward voltage (V&lt;sub&gt;f&lt;/sub&gt;) of 2.8V, this means that the resistor only has 2.2V across it. For a 200ohm resistor, this means that only 11mA is passing through the circuit. If you want 20mA to pass through the LED you need to use a resistance of 110ohm instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the voltage from the MCU pins themselves depend on the current passing through them. Section 32.7 of the ATmega2560 datasheet, &quot;Typical Characteristics - Pin Driver Strength&quot; has charts for voltage versus current for both sourcing and sinking current; at 20mA the voltage drops to about 4.5V, which means that the resistance required for a 2.8V LED drops from 110ohm down to 85ohm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, although semiconductors (i.e. the MCU and LED) can be damaged when too much current passes through them, it is not the current itself that causes the damage. The current passing through the voltage drop results in a consumption of power, and this power subsequently turns into heat. This heat then causes the breakdown of the semiconductor material. Even a junky, third-hand LED can take bursts of current up to 35mA or so without being damaged, provided the duration is limited. With a PWM signal this duration is directly linked to both the frequency and the duty cycle of the signal. You will need to see the datasheet for the LED in question to figure out what the maximum safe current and duration are, but the implication is that if you keep the frequency high enough and the duty cycle low enough, you can get away without any resistor at all and both the MCU and LED will survive.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-05-31T22:22:45.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1790" PostTypeId="2" ParentId="1787" CreationDate="2014-06-01T13:37:31.213" Score="1" Body="&lt;p&gt;This probe has the Dallas (now Maxim) DS18b20 sensor in it so you're already on the right track. Search for DS18b20 at &lt;a href=&quot;http://www.arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt;. You'll find libraries and lots of forum discussions about using these sensors.&#xA;Also see page 6 of the &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf&quot; rel=&quot;nofollow&quot;&gt;DS18b20 datasheet&lt;/a&gt;; there are two schematics for wiring the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the parasitic mode (Figure 4 on that page) except I eliminated the transistor switch and connected the MCU pin for the strong-pullup directly to the one-wire bus.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-01T13:37:31.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1792" PostTypeId="2" ParentId="1758" CreationDate="2014-06-01T13:56:34.367" Score="3" Body="&lt;p&gt;For &quot;as fast as possible&quot;, I'd&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Rewrite your sampling code in assembly language (just those two statements, not the whole program); and&lt;/li&gt;&#xA;&lt;li&gt;Buffer the raw data pairs in memory if you have enough of it, then store it to the card after the measurement burst. If you need more data space, consider that the timing of a tight assembly loop will be consistent (and fast!) and can be measured. You may not need to read the clock at all. Note that you can get the same timing consistency using C/C++ if you read the analog and clock ports directly, and maybe as fast. It's just that with assembly language, WYWIWYG (what you write is what you get); the compilers' code-generators and optimizers won't mess with it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A possible issue with your code as you've written it is that writeData probably buffers the data on most calls, but whenever a call results in a full buffer, writes the whole buffer to the card, introducing jitter into your sampling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Addressing your edit of June 3, 2014, &quot;I would like to record the exact time that the analogRead data was collected&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you proposed using micros() (as opposed to a real-time clock), I assume you are satisfied with the relative time. Once you know your data collection code is completely predictable, then the offset from reading data to reading time is constant, and since we're using relative time anyway, can be discounted, or at least, corrected for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It isn't &lt;em&gt;completely&lt;/em&gt; predictable of course, since in this case, you're using an interrupt-maintained clock, and can expect that sometimes the interrupt will occur between the data read and the clock read, stretching the offset for that tuple. To get even more accurate, you'd need to keep interrupts off, read the timer yourself in an invariant way. f/ex, you might run the timer at such a rate that you could expect to take two or more samples between overflows of the low-order byte, read and store only the low order byte as your time sample, and post process the time data to reconstruct the high order byte by detecting wrap-around in the low-order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With no interrupts running, and once you know the rate at which you can sample data without reading the clock, you could read and save the clock once immediately prior to taking the first sample, and infer the times of each subsequent sample based on the known sample rate.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-06-03T22:09:02.717" LastActivityDate="2014-06-03T22:09:02.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1793" PostTypeId="1" AcceptedAnswerId="1804" CreationDate="2014-06-01T17:52:51.633" Score="0" ViewCount="531" Body="&lt;p&gt;I'm trying to figure out how to create some non-blocking code to strobe some RGB leds with analogwrite  7 times a second; I'm really not to sure how to go about this. If anybody could give me some help that'd be great! :)&lt;/p&gt;&#xA;" OwnerUserId="1671" LastActivityDate="2014-06-03T00:36:49.160" Title="Non-blocking strobing code?" Tags="|analogwrite|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="1794" PostTypeId="1" AcceptedAnswerId="1795" CreationDate="2014-06-01T21:34:03.997" Score="9" ViewCount="1112" Body="&lt;p&gt;I am looking to possibly monitor battery power to the Arduino using its ADC.  This is fairly straight forward and simple (especially if using the Arduino API); however, if the battery is powering the Arduino and is unregulated externally, won't the ADC reference voltage constantly be dropping with the battery?  In other words, wouldn't the ADC value would constantly read the same value (the max value) even though the battery would actually be decreasing in voltage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the case, it would be both inefficient and pointless to measure the battery voltage.&lt;/p&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2015-11-18T23:38:47.587" Title="Arduino ADC Reference Voltage if it is Battery Powered" Tags="|arduino-uno|battery|analogread|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1795" PostTypeId="2" ParentId="1794" CreationDate="2014-06-01T22:43:02.220" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... won't the ADC reference voltage constantly be dropping with the battery?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, which is why you either use or measure an internal bandgap reference instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;analogReference()&lt;/code&gt;&lt;/a&gt; function to select a reference appropriate for the board in use. Note that you will need to use a voltage divider to reduce the battery voltage to a value below that of the selected reference if you wish to measure it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To measure the bandgap voltage instead (using AV&lt;sub&gt;CC&lt;/sub&gt; as a reference and working &quot;backwards&quot;) you will need to set &lt;code&gt;MUX[3:0]&lt;/code&gt; in &lt;code&gt;ADMUX&lt;/code&gt; to 0b1110 and then perform an ADC reading directly (set &lt;code&gt;ADSC&lt;/code&gt; in &lt;code&gt;ADCSRA&lt;/code&gt; and wait until it resets, then read from &lt;code&gt;ADC[H:L]&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As always, see the MCU datasheet for details.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-06-01T22:43:02.220" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1798" PostTypeId="1" AcceptedAnswerId="1816" CreationDate="2014-06-02T05:03:38.993" Score="1" ViewCount="1018" Body="&lt;p&gt;I am using an &lt;a href=&quot;http://www.rfduino.com/&quot; rel=&quot;nofollow&quot;&gt;RFduino&lt;/a&gt; and an iOS application to control some RGB LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I'm sending a string command to the module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- (IBAction)fadeButtonPressed:(id)sender {&#xA;    [rfduino send:[@&quot;fade&quot; dataUsingEncoding:NSUTF8StringEncoding]];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These command(s) are coming back just fine on the RFduino side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void RFduinoBLE_onReceive(char *data, int len) {&#xA;  if (strncmp(data, &quot;fade&quot;, 4) == 0) {&#xA;    // begin fading chosen LED colour&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way of executing multiple functions on Arduino? It seems to me that there should be a better way of doing what I'm trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally for example I was getting an issue where the &quot;fade&quot; string was coming back as &quot;fadek&quot; so I used &lt;code&gt;strncmp(data, &quot;fade&quot;, 4)&lt;/code&gt; instead of &lt;code&gt;strcmp(data, &quot;fade&quot;)&lt;/code&gt; and this fixed the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I'd like a way of cleaning up my code and perhaps make it easier to introduce new bits of functionality depending on which strings are coming back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The functions I would like to be able to do would be controlling of the RGB colours and then &lt;em&gt;Fading&lt;/em&gt; or &lt;em&gt;Blinking&lt;/em&gt; that particular chosen colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if I wanted to introduce faster blinking? Rather than setting another command integer and adding another condition is there a cleaner approach?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The selection of the colours is set by selection of a color wheel within my iOS application. This is working fine. The problem is that the Blinking and Fading does not blink/fade the selected colour (&lt;code&gt;command 0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my entire sketch so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RFduinoBLE.h&amp;gt;&#xA;&#xA;// Pin 2 on the RGB LED.&#xA;int rgb2_pin = 2; // red&#xA;int rgb3_pin = 3; // green&#xA;int rgb4_pin = 4; // blue&#xA;int brightness = 0;&#xA;int fadeAmount = 5;&#xA;&#xA;// Command properties.&#xA;int command = 0;&#xA;&#xA;void setup() {&#xA;  // debug output at 9600 baud&#xA;  Serial.begin(9600);&#xA;&#xA;  // Setup the LEDs for output.&#xA;  pinMode(rgb2_pin, OUTPUT);&#xA;  pinMode(rgb3_pin, OUTPUT);&#xA;  pinMode(rgb4_pin, OUTPUT);&#xA;&#xA;  // This is the data we want to appear in the advertisement&#xA;  // (the deviceName length plus the advertisement length must be &amp;lt;= 18 bytes.&#xA;  RFduinoBLE.advertisementData = &quot;rgb&quot;;&#xA;&#xA;  // Start the BLE stack.&#xA;  RFduinoBLE.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  if (command == 1) { // Fade in/out chosen colour.&#xA;    analogWrite(rgb2_pin, brightness);&#xA;    analogWrite(rgb3_pin, brightness);&#xA;    analogWrite(rgb4_pin, brightness);&#xA;&#xA;    // Change the brightness for next time through the loop:&#xA;    brightness = brightness + fadeAmount;&#xA;&#xA;    // Reverse the direction of the fading at the ends of the fade:&#xA;    if (brightness == 0 || brightness == 255) {&#xA;      fadeAmount = -fadeAmount ;&#xA;    }&#xA;&#xA;    // Wait for 30 milliseconds to see the dimming effect&#xA;    delay(30);&#xA;  } else if (command == 2) { // Blink&#xA;    digitalWrite(rgb2_pin, HIGH);&#xA;    digitalWrite(rgb3_pin, HIGH);&#xA;    digitalWrite(rgb4_pin, HIGH);&#xA;    delay(200);&#xA;    digitalWrite(rgb2_pin, LOW);&#xA;    digitalWrite(rgb3_pin, LOW);&#xA;    digitalWrite(rgb4_pin, LOW);&#xA;    delay(200);&#xA;  }&#xA;}&#xA;&#xA;void RFduinoBLE_onConnect() {}&#xA;&#xA;void RFduinoBLE_onDisconnect() {}&#xA;&#xA;void RFduinoBLE_onReceive(char *data, int len) {&#xA;  Serial.println(data);&#xA;&#xA;  // Each transmission should contain an RGB triple.&#xA;  if (strncmp(data, &quot;fade&quot;, 4) == 0) {&#xA;    command = 1;&#xA;  } else if (strncmp(data, &quot;blink&quot;, 5) == 0) {&#xA;    command = 2;&#xA;  } else { // Change colour.&#xA;    // Reset other functions.&#xA;    command = 0;&#xA;&#xA;    if (len &amp;gt;= 3) {&#xA;      // Get the RGB values.&#xA;      uint8_t red = data[0];&#xA;      uint8_t green = data[1];&#xA;      uint8_t blue = data[2];&#xA;&#xA;      // Set PWM for each LED.&#xA;      analogWrite(rgb2_pin, red);&#xA;      analogWrite(rgb3_pin, green);&#xA;      analogWrite(rgb4_pin, blue);&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(command);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" OwnerDisplayName="gotnull" LastActivityDate="2014-06-12T06:37:19.370" Title="Executing multiple functions/commands on Arduino" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1799" PostTypeId="1" AcceptedAnswerId="1800" CreationDate="2014-06-02T05:57:28.000" Score="0" ViewCount="1108" Body="&lt;p&gt;So, i've worked with the pySerial module for python, where I communicated with my arduino via serial. However, this module only works for 32bits and I would like to make my project work on both architectures (I know the person could just install the 32-bits version on the 64-bits architecture). Also, the connection fails a lot of times and I wasn't able to correct it. &#xA;&lt;p&gt;I think I can use the true USB power of the arduino Leonardo to connect to the python in a different way, but I don't know where to start. But I think this approach will be more professional. &#xA;&lt;p&gt;Im really intersted in learning, so if you guys could at least indicate documents so I can understand how to make this connection between Leonardo and Python, I'll be happy. I've read the arduino page about the CDC but couldn't find useful information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;p&gt;Thank you so much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i used serial, I had problems with messages getting acumulated at the buffer, and then after some seconds i was reading 10s delayed messages. Also, when I sent a string like: &quot;12345678&quot;, it was really easy to get one number less, like: &quot;1345678&quot;. This happened frequently to me. So I think I need to implement a protocol to deal with these problems.&lt;/p&gt;&#xA;" OwnerUserId="1674" LastEditorUserId="1674" LastEditDate="2014-06-02T15:36:29.847" LastActivityDate="2014-06-02T16:08:38.487" Title="Best way to interact arduino and python" Tags="|serial|i2c|python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1800" PostTypeId="2" ParentId="1799" CreationDate="2014-06-02T07:05:18.470" Score="1" Body="&lt;p&gt;I did some work in Java using USB some years ago and I can share some experiences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Things are not neary as straightforward as using serial.&lt;/li&gt;&#xA;&lt;li&gt;Your code will probably be platform specific, windows being a bit more weird about handling usb. (unless using something to abstract that away, like &lt;a href=&quot;http://pyusb.sourceforge.net/docs/1.0/tutorial.html&quot; rel=&quot;nofollow&quot; title=&quot;PyUSB&quot;&gt;PyUSB&lt;/a&gt; which wraps libUSB or openUSB, this however does not guarantee platform independency because these libraries also have their weirdnesses).&lt;/li&gt;&#xA;&lt;li&gt;If you drop down to USB level programming, things can get very messy (again, this can be abstracted away). USB is (at least in my opinion) a complicated protocol, especially for beginners. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So unless you really need something that only USB can provide, a nice and dandy serial communication will give you much less headaches. Thats why serial did not die until now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for debugging why your communication is not reliable I would try several things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;See if your application might send something that is interpreted as a control character&lt;/li&gt;&#xA;&lt;li&gt;Drop your baud rate to something lower and see if it still loses data. If so, you might overflow the buffer of your receiver (and you would need &lt;a href=&quot;http://tldp.org/HOWTO/Text-Terminal-HOWTO-11.html&quot; rel=&quot;nofollow&quot;&gt;flow control&lt;/a&gt; in this case)&lt;/li&gt;&#xA;&lt;li&gt;Check your hardware! I've had bad wires or solders on numerous occasions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1643" LastEditorUserId="1643" LastEditDate="2014-06-02T16:08:38.487" LastActivityDate="2014-06-02T16:08:38.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1801" PostTypeId="1" AcceptedAnswerId="1803" CreationDate="2014-06-02T10:35:22.667" Score="9" ViewCount="5641" Body="&lt;p&gt;It's &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot;&gt;clearly documented&lt;/a&gt; that when global data is shared with an ISR and the main program, the data needs to be declared &lt;code&gt;volatile&lt;/code&gt; in order to guarantee memory visibility (and that only suffices for 1-byte data; anything bigger needs special arrangements to guarantee also atomicity). &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11488&quot;&gt;Here&lt;/a&gt; we have good rules:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variables only used outside an ISR should not be volatile.&lt;/li&gt;&#xA;&lt;li&gt;Variables only used inside an ISR should not be volatile.&lt;/li&gt;&#xA;&lt;li&gt;Variables used both inside and outside an ISR should be volatile.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But is &lt;code&gt;volatile&lt;/code&gt; needed when the variable is accessed from &gt; 1 ISRs, but not shared outside ISRs? For example, I have a function that maintains internal state using a &lt;code&gt;static&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void func() {&#xA;    static volatile long counter; // volatile or not?&#xA;    // Do stuff with counter etc.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That function is called in two ways: from pin interrupt, and from &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot;&gt;TimerOne library&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;attachInterrupt(0, func, CHANGE);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Timer1.attachInterrupt(func);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are no atomicity problems, since &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11488&quot;&gt;when an ISR is entered, interrupts are automatically disabled&lt;/a&gt;, but this &lt;code&gt;volatile&lt;/code&gt; is more of a compiler question: what is cached and what is not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better safe than sorry, of course...&lt;/p&gt;&#xA;" OwnerUserId="1552" LastEditorUserId="1552" LastEditDate="2014-06-02T11:57:11.240" LastActivityDate="2014-06-02T12:14:29.713" Title="Is volatile needed when variable is accessed from &gt; 1 ISRs, but not shared outside ISRs?" Tags="|interrupt|timers|isr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1802" PostTypeId="1" AcceptedAnswerId="1806" CreationDate="2014-06-02T11:19:43.883" Score="11" ViewCount="1052" Body="&lt;p&gt;The following snippets are from &lt;a href=&quot;https://code.google.com/p/arduino-timerone/source/browse/#svn%2Ftrunk&quot;&gt;TimerOne library source code&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// TimerOne.h:&#xA;void (*isrCallback)();&#xA;&#xA;// TimerOne.cpp:&#xA;ISR(TIMER1_OVF_vect) // interrupt service routine that wraps a user defined function supplied by attachInterrupt&#xA;{&#xA;  Timer1.isrCallback();&#xA;}&#xA;&#xA;// TimerOne.cpp:&#xA;void TimerOne::attachInterrupt(void (*isr)(), long microseconds)&#xA;{&#xA;  if(microseconds &amp;gt; 0) setPeriod(microseconds);&#xA;  isrCallback = isr; // register the user's callback with the real ISR&#xA;  TIMSK1 = _BV(TOIE1); // sets the timer overflow interrupt enable bit&#xA;  resume();                                                                                            &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question: if the timer is already running, and the main program calls &lt;code&gt;attachInterrupt()&lt;/code&gt;, could the timer interrupt occur there &lt;em&gt;during&lt;/em&gt; the function pointer assignment &lt;code&gt;isrCallback = isr;&lt;/code&gt;? Then, with lucky timing, &lt;code&gt;Timer1.isrCallback();&lt;/code&gt; function pointer would consist partly of the old and partly of the new address, causing the ISR jump to a bogus location?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose this might be the case, since function pointers are certainly wider than 1 byte, and accessing &gt; 1 byte data isn't atomic. Possible workarounds could be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Always call &lt;code&gt;detachInterrupt()&lt;/code&gt; to make sure the timer isn't running, before calling &lt;code&gt;attachInterrupt()&lt;/code&gt;, i.e. clarify Timer1 docs.&lt;/li&gt;&#xA;&lt;li&gt;Or, modify Timer1, disabling timer overflow interrupts temporarily just before &lt;code&gt;isrCallback = isr;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Does this make sense, or is there something in &lt;code&gt;Timer1&lt;/code&gt; sources or function pointer assignments that I've missed?&lt;/p&gt;&#xA;" OwnerUserId="1552" LastEditorUserId="1552" LastEditDate="2014-06-02T11:57:22.127" LastActivityDate="2016-10-24T00:04:30.887" Title="Are function pointer assignments atomic in Arduino?" Tags="|interrupt|timers|isr|pointer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1803" PostTypeId="2" ParentId="1801" CreationDate="2014-06-02T12:14:29.713" Score="9" Body="&lt;p&gt;&lt;code&gt;volatile&lt;/code&gt; only informs the compiler's code generator that the variable may be modified by something other than the code being generated, so not to assume any copy of it remains accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ISR code must be written/generated under the assumption that it has no context at entry, and preserve the CPU's context around its (ISR's) own operation. So, as with the indivisbility of non-atomic operations, volatility depends, &lt;em&gt;in this case*&lt;/em&gt;, on whether or not interrupts are allowed to nest. If non-nesting is guaranteed, the shared variable can not change by other than this ISR during its own execution. If your ISR might someday be used in an environment where interrupts are allowed to nest, then that constraint will no longer hold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;* &lt;em&gt;in this case&lt;/em&gt;:&#xA;&lt;br&gt;I'm assuming a software-maintained variable here. If we're talking about a variable that can be updated by a hardware event, a timer register for example, all bets are off: the variable is volatile no matter what.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-02T12:14:29.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1804" PostTypeId="2" ParentId="1793" CreationDate="2014-06-02T14:06:00.097" Score="1" Body="&lt;p&gt;What you want can be achieved with your MCUs timers and their associated interrupts. Timers are basically counters that run inside your hardware and they run decoupled from your code. Since one usually knows how fast these timers tick (e.g. how long it takes to count from one to two and so on) you can specify events that happen when a certain amount of timer ticks passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you have a look at &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;SimpleTimer&lt;/a&gt; and &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;Timer1&lt;/a&gt; (the second page is only for ATmega168/328)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both pages include some code samples where they specify some method that will be called every x milliseconds.&lt;/p&gt;&#xA;" OwnerUserId="1643" LastActivityDate="2014-06-02T14:06:00.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1805" PostTypeId="1" AcceptedAnswerId="1807" CreationDate="2014-06-02T16:14:59.037" Score="3" ViewCount="5645" Body="&lt;p&gt;I am currently tinkering with an arduino, and am using a potentiometer to change the brightness of an LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that usually, a resistor is added to the circuit to limit the current flowing through the circuit in order to prevent the LED from burning out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as I am currently using a potentiometer to adjust the LED's brightness, &lt;strong&gt;AND&lt;/strong&gt; as a potentiometer is basically a variable resistor, would I still need a resistor to prevent the LED from burning out? Currently, I do not see a difference between using a 220 ohm resistor and not using it, as the LED seems unaffected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pot=A0;&#xA;const int led=11;&#xA;int potValue;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  pinMode(pot,INPUT);&#xA;  pinMode(led,OUTPUT);&#xA;  analogWrite(led,100);&#xA;}&#xA;&#xA;void loop(){&#xA;  potValue = analogRead(pot);&#xA;  potValue=map(potValue,0,1023,0,255);&#xA;  analogWrite(led,potValue);&#xA;  Serial.println(potValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: My LED is hooked up to the arduino's PWM pin, and connected to ground on a breadboard.&lt;/p&gt;&#xA;" OwnerUserId="1563" LastEditorUserId="46" LastEditDate="2014-06-02T16:48:39.353" LastActivityDate="2014-06-02T22:07:50.117" Title="Do I need to use a resistor if I am using a potentiometer to control an LED's brightness?" Tags="|arduino-uno|pwm|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1806" PostTypeId="2" ParentId="1802" CreationDate="2014-06-02T16:34:59.583" Score="7" Body="&lt;p&gt;Have a look at the code for attachInterrupt() and detachInterrupt() in&#xA;&lt;code&gt;/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WInterrupts.c&lt;/code&gt; (well, that's where they are on a Mac, anyway. Arduino file structure on other OSes' probably looks similar in the lower levels of the path).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears that attachInterrupt() assumes that the interrupt in question is not yet enabled because it writes the function pointer without taking any precautions. Note that detachInterrupts() disables the target interrupt before writing a NULL-pointer to its vector. So I'd at least use a &lt;code&gt;detachInterrupt()&lt;/code&gt; / &lt;code&gt;attachInterrupt()&lt;/code&gt; pair&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd want to run any such code in a critical section, myself. It appears your first way (detach, then attach) would work, though I can't be sure it couldn't miss an unfortunately timed interrupt. The datasheet for your MCU might have more to say on that. But neither am I sure at this point, that a global &lt;code&gt;cli()&lt;/code&gt;/&lt;code&gt;sei()&lt;/code&gt; wouldn't miss it either. The ATMega2560 datasheet, section 6.8, does say &quot;When using the SEI instruction to enable interrupts, the instruction following SEI will be executed before any pending interrupts, as shown in this example&quot;, seeming to imply that it can buffer an interrupt while the interrupts are off.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-02T16:34:59.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1807" PostTypeId="2" ParentId="1805" CreationDate="2014-06-02T16:47:25.837" Score="4" Body="&lt;p&gt;Without a good quality picture of your setup or some schematics, it's hard to tell what's going on, but from your description, what you're doing is &lt;strong&gt;potentially harmful for the LED and the output pin D11&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, LEDs almost always need series resistors to limit their current. They don't limit currents and will burn if you don't do it for them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had the pot in series with the LED, which seems to be what you think is going on, you'd still need a series resistance so that when the pot is all the way to one side, effectively behaving like a 0&amp;Omega; resistor or a short, you'd still be limiting the current with the 2nd resistor. One would usually use Ohm's Law to calculate that 2nd resistance so that it lets the maximum current the LED can take when the pot is at 0&amp;Omega; position, usually 20mA for common LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But that's not how your circuit seems to be wired&lt;/strong&gt;. The pot is indirectly controlling the LED through an analog input and a PWM output via MCU. So it's not limiting the LED current, in the traditional sense. The pot seems to be wired between 5V and GND with the middle lead (the cursor) hooked up to the analog input A0. That's a variable voltage divider configuration that let's you select a continuous voltage between 0 and 5V that is in turn converted to a value between 0 and 1023 by the MCU ADC (Analog to Digital Converter) - that's the result of the &lt;code&gt;analogRead()&lt;/code&gt; call. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That value is then fed to a PWM analog output, through the &lt;code&gt;analogWrite()&lt;/code&gt; call, that will output a square wave to the LED. The relative position of the pot will determine the duty cycle of the PWM, i.e., how long the square wave is HIGH or LOW. The problem here is that this circuit where the LED is wired should have its own series current limiting resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me, if you didn't burn the LED or the D11 pin yet, is pure luck. If you were to turn the pot all the way to maximum brightness (&lt;strong&gt;don't do it&lt;/strong&gt;), the PWM output would act like a digital output put in HIGH level (5V continuously), and without a current limiting resistor, the D11 pin would exceed it's 40mA absolute maximum source current and burn. Unless there's another factor limiting the current that I don't know of, that is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some exceptional cases in which you can control the LED voltage closely so you don't need to limit the current (multiplexing, constant-current supply etc.), but these are really advanced configurations for us newbies. So, from know on, do it like I do it: ALWAYS put a series resistor, until you become familiar with these advanced configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, below are some links that you may find helpful about the topic:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/tutorials/219&quot; rel=&quot;nofollow&quot;&gt;SparkFun Tutorial on LED Current Limiting Resistors&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/LED_circuit#Series_resistor&quot; rel=&quot;nofollow&quot;&gt;WikiPedia Article about LED series resistors&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-06-02T22:07:50.117" LastActivityDate="2014-06-02T22:07:50.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1808" PostTypeId="1" AcceptedAnswerId="1809" CreationDate="2014-06-02T21:37:34.777" Score="2" ViewCount="537" Body="&lt;p&gt;Altough having found a lot of documentation concerning wiring of I²C buses, I'm still not sure about the following question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If both devices use separate power sources, is it a good idea to connect VCC/GND of those two devices?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two lines for SCL and SDA, connected to SCL/SDA pins on both devices A and B. The master device's VCC is connected to both lines using a pull-up resistor. Now as far as I understood, VCC/GND of the two devices should not be disconnected but I'm afraid I'd damage something if I'd connect them. As two separate power sources will never provide exactly the same voltage that would result in high currents, won't it? Or should I just connect them using some resistor to avoid high currents but provide the same voltage level?&lt;/p&gt;&#xA;" OwnerUserId="1681" LastActivityDate="2014-06-02T23:27:01.057" Title="Connect two Arduinos using I²C (wiring)" Tags="|i2c|wires|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1809" PostTypeId="2" ParentId="1808" CreationDate="2014-06-02T22:15:21.067" Score="3" Body="&lt;p&gt;The VCC lines aren't directly connected - you just have a shared data line with some voltage on it, which is always lower than VCC because of the resistor. Each device &quot;talks&quot; to the I2C bus by briefly connecting those lines to GND, which is common between both devices. Current is limited by the pull-up resistor, so it never gets too high. This makes it safe to directly link devices running at slightly different voltages.&lt;/p&gt;&#xA;" OwnerUserId="1620" LastActivityDate="2014-06-02T22:15:21.067" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="1810" PostTypeId="2" ParentId="1808" CreationDate="2014-06-02T23:27:01.057" Score="3" Body="&lt;p&gt;Here's what you need to do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Leave the VINs disconnected. I'm not sure that it's a bad idea, but it is pretty much pointless. Like sburlappp said, the resistors lower the voltage between them (and reduce the current). With a resistor, it wouldn't &lt;em&gt;hurt it&lt;/em&gt;, but there's really no need.&lt;/li&gt;&#xA;&lt;li&gt;Connect the grounds &lt;em&gt;directly&lt;/em&gt;. Here's the problem: voltage is relative; it is measured very much like gravitational potential energy. It's the difference between the amount of electricity in both parts that determines the voltage. I'm pretty sure that if you don't, with the extra power, it could &lt;em&gt;fry&lt;/em&gt; a component. That would happen when there is a lower concentration of electrons in &quot;ground&quot; on one of the boards than the other. That could result in many volts being passed along to the board. I haven't had this happen to me, nor have I really heard about this happening, but I guess it is a possibility.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-02T23:27:01.057" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1811" PostTypeId="2" ParentId="1793" CreationDate="2014-06-03T00:36:49.160" Score="0" Body="&lt;p&gt;Timers are the best way to go, (much) less overhead and you don't have to worry about it elsewhere in your code (other than managing variable use between your main loop and your ISRs). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I do have a habit of doing things the hard way in code first and then move to timers once I've got it the way I'd like. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is sample code to flash the on board LED X times per second, I have calculated it to mean, ON 7 times per second and OFF 7 times as well (meaning, there is a change of state 14 times per second). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code isn't efficient, it doesn't take into consideration that the value is already set or not, it just writes the value that it should be right now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to go to analogWrite and use PWM, just change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(LED, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(NEW_PIN, PWM_VALUE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED               13&#xA;#define TIMES_PER_SECOND  7&#xA;&#xA;const int M1 = 1000 / TIMES_PER_SECOND;&#xA;const int M2 = 1000 / TIMES_PER_SECOND / 2;&#xA;&#xA;void setup(){&#xA;  pinMode(LED,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  if(millis()%M1&amp;lt;M2){&#xA;    digitalWrite(LED, HIGH);&#xA;  } else {&#xA;    digitalWrite(LED, LOW);&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remember there is overhead with digital (and analog) writes, so (as I mentioned) you could check to see if the value is set already or not and skip the write.&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-03T00:36:49.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1813" PostTypeId="1" CreationDate="2014-06-03T02:20:18.070" Score="23" ViewCount="51003" Body="&lt;p&gt;In an Arduino sketch, is there a way to make asynchronous function calls within the loop? Like listening to requests through http server and process them in a &lt;strong&gt;non-blocking&lt;/strong&gt; way.&lt;/p&gt;&#xA;" OwnerUserId="1682" LastEditorUserId="1682" LastEditDate="2014-06-03T02:35:10.043" LastActivityDate="2023-04-08T20:10:42.833" Title="Asynchronous function calls in Arduino sketch" Tags="|programming|sketch|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1814" PostTypeId="2" ParentId="1813" CreationDate="2014-06-03T02:57:48.333" Score="16" Body="&lt;p&gt;&lt;strong&gt;Yes and no.&lt;/strong&gt; You're kinda vague on what you want to do. I've made this into a few different sections (mainly focused on reading sensor data... it applies to everything but that's the context I'm using):&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Threads&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;AFAIK all Arduinos only have one core (they can do one thing at once). For most Arduino boards, hardware multithreading isn't supported. However, &lt;a href=&quot;https://arduino.stackexchange.com/q/286/220&quot;&gt;there are ways to implement software multithreading&lt;/a&gt;. The approach by AsheeshR wouldn't work well for functions that take a long time to complete (i.e. something in a library that takes a while, or a delay) because it would get jammed up by those instructions, but it would work well for short functions like &lt;code&gt;pinMode()&lt;/code&gt;. The Protothreads library listed there might be better at this, but I don't really know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'd be hard to orchestrate this with HTTP, especially since you have to make &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Delays&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A common way for a sketch to stall is the use of a delay. This can be solved by using, in the main loop, a if statement and the &lt;a href=&quot;https://www.arduino.cc/reference/en/language/functions/time/millis/&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;millis()&lt;/code&gt;&lt;/a&gt; function that returns a time (not a clock time, but rather the time since the Arduino started). You could also do a loop within the loop to poll sensor data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;millis()&lt;/code&gt; approach wouldn't work well with things that cause the whole program to stall (i.e. &lt;em&gt;more&lt;/em&gt; delays or loops that last a noticeable amount of time). Note that 100ms IIRC is the general maximum time to make a UI not seem laggy.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Interrupts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Interrupts are a great way to keep things almost asynchronous. They run a short piece of code (that you specify) every time a pin state changes. It breaks from the &lt;code&gt;loop()&lt;/code&gt;, and goes back where it left off once the &quot;&lt;em&gt;ISR&lt;/em&gt;&quot; has been ran. I don't have much time to explain how to do this, but a quick Google search will yield a lot of results.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As far as you example, the threading section would be the most applicable. This topic is pretty vague, so you'll have to experiment with a few things and find something that works.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="57091" LastEditDate="2019-06-19T09:03:57.193" LastActivityDate="2019-06-19T09:03:57.193" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="1815" PostTypeId="2" ParentId="1813" CreationDate="2014-06-03T03:48:28.123" Score="3" Body="&lt;p&gt;I just posted some code for a &lt;a href=&quot;http://playground.arduino.cc/Code/TimerScheduler&quot; rel=&quot;nofollow&quot;&gt;task scheduler&lt;/a&gt; on the playground the other day, you may want to take a peek, maybe you can adapt it to your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's processor is inherently single-threaded and cannot multi-task. As has been mentioned there are however ways to create the illusion of multi-tasking. Annonomus Penguin hit on those pretty well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check out &lt;a href=&quot;https://code.google.com/p/arduino-timerone/&quot; rel=&quot;nofollow&quot;&gt;TimerOne&lt;/a&gt; (It's probably better ;)&lt;/p&gt;&#xA;" OwnerUserId="1656" LastEditorUserId="1656" LastEditDate="2014-06-03T03:54:17.630" LastActivityDate="2014-06-03T03:54:17.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1816" PostTypeId="2" ParentId="1798" CreationDate="2014-06-03T03:59:24.447" Score="1" Body="&lt;p&gt;Ended up going with something &lt;a href=&quot;https://stackoverflow.com/questions/24005992/arduino-state-machine&quot;&gt;like this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RFduinoBLE.h&amp;gt;&#xA;&#xA;// State properties.&#xA;int state = 1;&#xA;char command;&#xA;String hexstring;&#xA;&#xA;// RGB pins.&#xA;int redPin = 2;&#xA;int grnPin = 3;&#xA;int bluPin = 4;&#xA;&#xA;// Setup function to set RGB pins to OUTPUT pins.&#xA;void setup () {&#xA;  pinMode(redPin, OUTPUT);&#xA;  pinMode(grnPin, OUTPUT);&#xA;  pinMode(bluPin, OUTPUT);&#xA;&#xA;  // This is the data we want to appear in the advertisement&#xA;  // (the deviceName length plus the advertisement length must be &amp;lt;= 18 bytes.&#xA;  RFduinoBLE.deviceName = &quot;iOS&quot;;&#xA;  RFduinoBLE.advertisementInterval = MILLISECONDS(300);&#xA;  RFduinoBLE.txPowerLevel = -20;&#xA;  RFduinoBLE.advertisementData = &quot;rgb&quot;;&#xA;&#xA;  // Start the BLE stack.&#xA;  RFduinoBLE.begin();&#xA;}&#xA;&#xA;void loop () {&#xA;  switch (command) {&#xA;    case 1:&#xA;      // Blink.&#xA;    break;&#xA;    case 2:&#xA;      // Fade.&#xA;    break;&#xA;  }&#xA;&#xA;  //RFduino_ULPDelay(INFINITE);&#xA;}&#xA;&#xA;// Converts HEX as a String to actual HEX values.&#xA;// This is needed to properly convert the ASCII value to the hex&#xA;// value of each character.&#xA;byte getVal (char c) {&#xA;  if (c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9') return (byte)(c - '0');&#xA;  else return (byte)(c - 'a' + 10);&#xA;}&#xA;&#xA;// Process each function/command.&#xA;void processCommand (int command, String hex) {&#xA;  switch (command) {&#xA;    case 'b':&#xA;      command = 1; // Set blink mode.&#xA;    break;&#xA;    case 'f':&#xA;      command = 2; // Set fade mode.&#xA;    break;&#xA;    case 'c':&#xA;      // We put together 2 characters as is&#xA;      // done with HEX notation and set the color.&#xA;      byte red = getVal(hex.charAt(1)) + (getVal(hex.charAt(0)) &amp;lt;&amp;lt; 4);&#xA;      byte green = getVal(hex.charAt(3)) + (getVal(hex.charAt(2)) &amp;lt;&amp;lt; 4);&#xA;      byte blue = getVal(hex.charAt(5)) + (getVal(hex.charAt(4)) &amp;lt;&amp;lt; 4);&#xA;&#xA;      // Set the color.&#xA;      setColor (red, green, blue);&#xA;    break;&#xA;  }&#xA;}&#xA;&#xA;// Sets the color of each RGB pin.&#xA;void setColor (byte red, byte green, byte blue) {&#xA;  analogWrite(redPin, red);&#xA;  analogWrite(grnPin, green);&#xA;  analogWrite(bluPin, blue);&#xA;  delay(200);&#xA;}&#xA;&#xA;// This function returns data from the radio.&#xA;void RFduinoBLE_onReceive (char *data, int len) {&#xA;  for (int i = 0; i &amp;lt; len; i++) {&#xA;    stateMachine(data[i]);&#xA;  }&#xA;}&#xA;&#xA;// Main state machine function, which processes&#xA;// data depending on the bytes received.&#xA;void stateMachine (char data) {&#xA;  switch (state) {&#xA;    case 1:&#xA;      if (data == 1) {&#xA;        state = 2;&#xA;      }&#xA;    break;&#xA;    case 2:&#xA;      if (data == 'b' || data == 'f' || data == 'c') {&#xA;        command = data;&#xA;        hexstring = &quot;&quot;;&#xA;        state = 3;&#xA;      } else if (data != 1) { // Stay in state 2 if we received another 0x01.&#xA;        state = 1;&#xA;      }&#xA;    break;&#xA;    case 3:&#xA;      if ((data &amp;gt;= 'a' &amp;amp;&amp;amp; data &amp;lt;= 'z') || (data &amp;gt;= '0' &amp;amp;&amp;amp; data &amp;lt;= '9')) {&#xA;        hexstring = hexstring + data;&#xA;        if (hexstring.length() == 6) {&#xA;          state = 4;&#xA;        }&#xA;      } else if (data == 1) {&#xA;        state = 2;&#xA;      } else {&#xA;        state = 1;&#xA;      }&#xA;    break;&#xA;    case 4:&#xA;      if (data == 3) {&#xA;        processCommand(command, hexstring);&#xA;        state = 1;&#xA;      } else if (data == 1) {&#xA;        state = 2;&#xA;      } else {&#xA;        state = 1;&#xA;      }&#xA;    break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-06-12T06:37:19.370" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1817" PostTypeId="1" CreationDate="2014-06-03T08:37:33.053" Score="1" ViewCount="805" Body="&lt;p&gt;I'm new to Arduino, I want to use Arduino and a mobile phone screen to make a simple touch board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This phone screen I mean, is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ctyFB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I connect it to Arduino, and when my fingers touch the screen, Arduino can get the events?&lt;/p&gt;&#xA;" OwnerUserId="1685" LastActivityDate="2014-06-03T10:17:05.407" Title="Can I use arduino and mobile phone screen to make a touch board?" Tags="|events|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1818" PostTypeId="2" ParentId="1817" CreationDate="2014-06-03T10:17:05.407" Score="1" Body="&lt;p&gt;First, find a suitable phone screen! Good luck. Most of the touch screens that I have found are resistive, and will never feel like an iPhone. Try googling &quot;Arduino touch screen&quot;. Adafruit have a promising one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you find your screen, you will need to interface to it. With luck it will come with a pre-built library. Otherwise you will be up for quite a lot of coding.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-06-03T10:17:05.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1819" PostTypeId="1" CreationDate="2014-06-03T12:07:46.857" Score="0" ViewCount="803" Body="&lt;p&gt;I have bought this &lt;a href=&quot;http://www.controlanything.com/Merchant2/merchant.mvc?Screen=PROD&amp;amp;Store_Code=NCD&amp;amp;Product_Code=ZADR410PROXR_ZBMESH&amp;amp;Category_Code=&quot; rel=&quot;nofollow&quot;&gt;wireless ZigBee relay board&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wandering about an arduino sketch to get started, I have searched for 2 days now but with no results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was thinking of is to have an Arduino with ZigBee module to send signal to another ZigBee device on top of the relay, to be able to open/close relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;strong&gt;can anyone share a sample sketch for that board?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1687" LastEditorUserId="46" LastEditDate="2014-06-03T17:06:48.780" LastActivityDate="2014-06-03T17:06:48.780" Title="Zigbee Relay board communication with Arduino" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1820" PostTypeId="2" ParentId="1304" CreationDate="2014-06-03T12:42:39.753" Score="4" Body="&lt;p&gt;Having struggled through this myself, I can confirm that Joel's solution works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are quite a lot of posts around that suggests that you can't get the Manchester to work with Arduino1.0x and you need 0020. But you can. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key is to use the arduino-tiny from the link above, put the tiny folder which you get from there in /hardware and then rename it to attiny and “prospective boards” to boards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realise that this doesn’t say any more than Joel already has, but there is so much conflicting and contradictory information around I thought it would be worth adding in my experience&lt;/p&gt;&#xA;" OwnerUserId="1688" LastActivityDate="2014-06-03T12:42:39.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1821" PostTypeId="2" ParentId="1819" CreationDate="2014-06-03T12:48:16.823" Score="2" Body="&lt;p&gt;Take a look at this library : &lt;a href=&quot;https://code.google.com/p/xbee-arduino/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/xbee-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the XBee Library for Arduino, you will find simple sketch that are perfect bases for the application you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="1689" LastActivityDate="2014-06-03T12:48:16.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1822" PostTypeId="2" ParentId="1390" CreationDate="2014-06-03T16:16:36.197" Score="3" Body="&lt;p&gt;On the processing side you need to communicate with the arduino using the Serial class. To set up use something like the following. It is a bit of guess work &#xA;to find which of the serial ports to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial myPort;  &#xA;void setup() {&#xA;  // List all the available serial ports:&#xA;  println(Serial.list());&#xA;&#xA;  // Open the port you are using at the rate you want:&#xA;  myPort = new Serial(this, Serial.list()[6], 9600);&#xA;  myPort.buffer(2); // sets the size of the buffer, I send two bytes at a time&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read a write using the &lt;code&gt;Serial.read()&lt;/code&gt; and &lt;code&gt;Serial.write()&lt;/code&gt; see &lt;a href=&quot;https://processing.org/reference/libraries/serial/index.html&quot; rel=&quot;nofollow&quot;&gt;https://processing.org/reference/libraries/serial/index.html&lt;/a&gt; for the processing serial references.&lt;/p&gt;&#xA;" OwnerUserId="679" LastActivityDate="2014-06-03T16:16:36.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1823" PostTypeId="1" AcceptedAnswerId="1824" CreationDate="2014-06-03T16:24:18.880" Score="1" ViewCount="1349" Body="&lt;p&gt;I'm trying to make the ATTiny85 work with the MMA7660 accelerometer, so far, without any success. Google search for &quot;ATTiny85 MMA7660&quot; gives poor results, and I'm not sure it has been done at all, at least publicly, so I thought I'll try my luck here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've tried is using the &lt;a href=&quot;https://github.com/adafruit/TinyWireM&quot; rel=&quot;nofollow noreferrer&quot;&gt;TinyWireM&lt;/a&gt; library, in different combinations. The last one is based on the MMA7660 Arduino library, specially adjusted to the TinyWireM, and taken from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=103180.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; in Arduino forums (&lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=6uhahs306gip7a2d4hp2gjcbf3&amp;amp;action=dlattach;topic=103180.0;attach=17551&quot; rel=&quot;nofollow noreferrer&quot;&gt;direct link to download&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SCL is connected to PB0 and SDA to PB2, with 5k ohm pull-ups (I know that the recommended is 4.7k but this is what I have available, and I assumed it shouldn't make much difference).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Arduino IDE v1.5.6, which works successfully with other non-I2C attiny projects I have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the final code I am using the .pde example that comes with the MMA7660, altered to use SoftwareSerial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyWireM.h&amp;gt;&#xA;#include &amp;lt;MMA7660.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(-1,4);&#xA;&#xA;void setup()&#xA;{&#xA;  mySerial.begin(9600);&#xA;  MMA7660.init();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int x,y,z;&#xA;  delay(100); // There will be new values every 100ms&#xA;  MMA7660.getValues(&amp;amp;x,&amp;amp;y,&amp;amp;z);&#xA;  mySerial.print(&quot;x: &quot;);&#xA;  mySerial.print(x);&#xA;  mySerial.print(&quot; y: &quot;);&#xA;  mySerial.print(y);&#xA;  mySerial.print(&quot; z: &quot;);&#xA;  mySerial.println(z);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current problem with the above code is that the pointers just dump some memory without making any sense. If I try to see what TinyWireM.receive() command returns, values are 216 for all three variables. This is true even when I disconnect the MMA7660 from the prototyping board...! so I assume the problem is with the I2C itself, not working properly. The actual I2C address for the MMA (0x4C) and other relevant code is in MMA7660.cpp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?... Unfortunately I don't currently have another I2C device to examine the health of this protocol with my ATTiny85, so any experience you might have with this sort of configuration will be blessed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: I marked dvlabsllc's answer as accepted answer since it gave me the right direction to pinpoint the issue further down the library path. I have opened a new question regarding TinyWireM library &lt;a href=&quot;https://arduino.stackexchange.com/questions/1829/ic-with-attiny85-at-8mhz-using-tinywirem-library&quot;&gt;here&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-06-04T12:07:48.767" Title="MMA7660 accelerometer with ATTiny85" Tags="|attiny|accelerometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1824" PostTypeId="2" ParentId="1823" CreationDate="2014-06-03T17:55:54.763" Score="1" Body="&lt;p&gt;I have run into similar frustrations using standard libraries and I2C.  I would have to look into the code and try it out on my own before confirming anything about this particular code; however, in the meantime you might want to try a tool such as &lt;a href=&quot;http://playground.arduino.cc/Main/I2cScanner&quot; rel=&quot;nofollow&quot;&gt;I2cScanner&lt;/a&gt; that simply scans the I2C bus for all possible addresses and reports addresses that are &quot;alive&quot;.  This (or something similar as I am not sure if you are using Arduino API) might be a good start to just see if the I2C is working and that you have the correct address.&lt;/p&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2014-06-03T17:55:54.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1825" PostTypeId="1" CreationDate="2014-06-04T00:59:19.577" Score="0" ViewCount="8547" Body="&lt;p&gt;I have an Arduino Uno Rev. 3 and I'm trying to make it so that the Arduino can send a key press / mouse action to the computer. However, these libraries are restricted to a few other versions of the board. Is there another alternative method to doing this without actually pressing any buttons/interacting with the arduino other than USB? Thanks!&#xA;&lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1450" LastActivityDate="2014-06-04T01:33:23.670" Title="Keyboard/mouse libraries with UNO" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ClosedDate="2014-06-04T01:49:58.963" ContentLicense="CC BY-SA 3.0" />
  <row Id="1826" PostTypeId="2" ParentId="1825" CreationDate="2014-06-04T01:33:23.670" Score="1" Body="&lt;p&gt;It is actually possible, but not easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main MCU on the Uno, the ATmega328, is not capable of using the USB connection at a low enough level to make this possible. The &lt;a href=&quot;https://arduino.stackexchange.com/q/986/&quot;&gt;other MCU on the Uno R3&lt;/a&gt;, the ATmega16U2, is. You can reprogram it to act as almost any arbitrary USB device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the '16U2 has no connection to digital pins 2 and up or to any of the analog pins, you would have to program it to communicate with the '328 (or an external chip) via UART, and then have another program running on the '328 that would communicate with the other pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you will need an external programmer for this, since once the '16U2 is reprogrammed you will lose the ability to program the '328 until you restore the original programming. Using another board running ArduinoISP will work for this.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-06-04T01:33:23.670" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1827" PostTypeId="1" CreationDate="2014-06-04T08:47:19.597" Score="2" ViewCount="1056" Body="&lt;p&gt;I am planning to buy a Arduino board. I am also considering Arduino clones, too. My requirements are that the board should inbuilt communication modes like Ethernet, WiFi and a SD card slot, too. Also the board should have a decent amount of memory and the processor must be a a little more powerful than the Uno. The board must be capable of running a OS if possible! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was looking at the Yun and Due. The Yun has all the communication modes but runs on a low end processor. The Due on the other hand runs on a ARM processor but has none of the communication modes. So now I am in a fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Which board should I choose?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="1646" LastEditorUserId="46" LastEditDate="2014-06-04T11:05:22.257" LastActivityDate="2014-06-04T11:05:22.257" Title="Arduino/Arduino clone board suggestions" Tags="|arduino-due|arduino-yun|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1828" PostTypeId="2" ParentId="1827" CreationDate="2014-06-04T09:09:53.973" Score="2" Body="&lt;p&gt;I would go with a Yun. Despite having a low end CPU, it runs at 400MHz and the disk space can be expanded using the uSD card (see &lt;a href=&quot;http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/&quot; rel=&quot;nofollow&quot;&gt;this blog post&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't plan to make CPU intensive tasks (such as real time video streaming and manipulation), the Yun is a nice tool. Otherwise, the Tre fits better (however, at the time of writing, it &lt;a href=&quot;http://blog.arduino.cc/2014/05/13/arduino-tre-developer-edition/&quot; rel=&quot;nofollow&quot;&gt;still has to be released&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-06-04T09:09:53.973" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="1829" PostTypeId="1" CreationDate="2014-06-04T12:07:14.753" Score="5" ViewCount="15108" Body="&lt;p&gt;Hello fellow Arduino enthusiasts, I am trying to make the ATTiny85 talk I²C with a MMA7660 breakout board I have (it's an accelerometer, this is a follow up question to my &lt;a href=&quot;https://arduino.stackexchange.com/questions/1823/mma7660-accelerometer-with-attiny85&quot;&gt;previous one&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would state in advance that the I²C chip works perfectly with Arduino Nano, that I am using the Arduino IDE v1.5.6-r2, using the arduino-tiny core (from &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) and that until now I had no special issues working at 8MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The official documentation for the &lt;strong&gt;TinyWireM&lt;/strong&gt; library (at the &lt;a href=&quot;http://playground.arduino.cc/Code/USIi2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino playground website&lt;/a&gt;) states that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;By default the I2C master library (TinyWireM) is set to run at 1MHz.&#xA;  To run at 8MHz, #defines in USI_TWI_Master.h / .cpp must be changed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have made the following changes in &lt;strong&gt;USI_TWI_Master.cpp&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 8000000UL // was 1000000UL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have made the following changes in &lt;strong&gt;USI_TWI_Master.h&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SYS_CLK   8000.0 // was 1000.0&#xA;#define T2_TWI    1.3 // was 5 &#xA;#define T4_TWI    0.6 // was 4 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My guess is that the T2_TWI &amp;amp; the T4_TWI values are wrong. I also tried &lt;strong&gt;T2_TWI 40 and T4_TWI 32&lt;/strong&gt; (as stated &lt;a href=&quot;https://www.google.co.il/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=http://forum.arduino.cc/index.php?action=dlattach;topic=81338.0;attach=9917&amp;amp;ei=XgmPU-1XyNvsBq_GgIAG&amp;amp;usg=AFQjCNEr4yeeb28gUYe_4YVmlYgElMjRuA&amp;amp;sig2=TsJqLOXgP5XFU2KdijlJ_Q&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;), and &lt;strong&gt;T2_TWI 2 &amp;amp; T4_TWI 1&lt;/strong&gt; (as stated &lt;a href=&quot;https://github.com/aboudou/tinywiremcp23008/blob/master/USI_TWI_Master.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;) but no luck. I also tried some other values in between that I thought might make sense but it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I am running is the I²C scanner from &lt;a href=&quot;http://playground.arduino.cc/Main/I2cScanner&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; (which as I mentioned works perfectly with the Nano and finds the device), the blow is a modified version for interfacing the TinyWireM library instead of the Wire library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyWireM.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(-1,4);&#xA;&#xA;void setup()&#xA;{&#xA;  TinyWireM.begin();&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;\nI2C Scanner&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  byte error, address;&#xA;  int nDevices;&#xA;  mySerial.println(&quot;Scanning...&quot;);&#xA;  nDevices = 0;&#xA;  for(address = 1; address &amp;lt; 127; address++ ) &#xA;  {&#xA;    TinyWireM.beginTransmission(address);&#xA;    error = TinyWireM.endTransmission();&#xA;&#xA;    if (error == 0)&#xA;    {&#xA;      mySerial.print(&quot;I2C device found at address 0x&quot;);&#xA;      if (address&amp;lt;16) &#xA;        mySerial.print(&quot;0&quot;);&#xA;      mySerial.print(address,HEX);&#xA;      mySerial.println(&quot;  !&quot;);&#xA;&#xA;      nDevices++;&#xA;    }&#xA;    else if (error==4) &#xA;    {&#xA;      mySerial.print(&quot;Unknow error at address 0x&quot;);&#xA;      if (address&amp;lt;16) &#xA;        mySerial.print(&quot;0&quot;);&#xA;      mySerial.println(address,HEX);&#xA;    }  &#xA;  }&#xA;  if (nDevices == 0)&#xA;    mySerial.println(&quot;No I2C devices found\n&quot;);&#xA;  else&#xA;    mySerial.println(&quot;done\n&quot;);&#xA;&#xA;  delay(5000);           // wait 5 seconds for next scan&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;As a side note I would say that my logic analyzer was broken recently and I'm sure it would have helped here... Also I am aware of the sound-card hack to be used as logic analyzer, but would prefer to avoid adding more error-prone variables to the system, if possible, for now. &lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture of probing with Saleae logic analyzer of the two channels. The result of the code above is &quot;No I2C devices found&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tGSNp.png&quot; alt=&quot;Logic sampling of ATTiny I2C channels&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://oi57.tinypic.com/2s6vyv8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;(Full size picture)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would appreciate the insights of anyone with experience using ATTiny85 at 8Mhz with I²C successfully.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2021-02-04T13:24:47.990" Title="I²C with ATTiny85 at 8MHz using TinyWireM library" Tags="|i2c|attiny|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="1830" PostTypeId="1" AcceptedAnswerId="1831" CreationDate="2014-06-04T12:27:35.490" Score="13" ViewCount="20358" Body="&lt;p&gt;I'm currently on project #14 of the Arduino project book.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to control a processing sketch on my laptop using my Arduino. This is accomplished by using a potentiometer to control the background of an image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  Serial.write(analogRead(A0)/4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//imports serial library&#xA;import processing.serial.*;&#xA;//setups the serial object&#xA;Serial myPort;&#xA;//creates an object for the image&#xA;PImage logo;&#xA;//variable to store background color&#xA;int bgcolor = 0;&#xA;&#xA;void setup(){&#xA;  colorMode(HSB,255);&#xA;  logo = loadImage(&quot;http://arduino.cc/logo.png&quot;);&#xA;  size(logo.width,logo.height);&#xA;  println(&quot;Available serial ports&quot;);&#xA;  println(Serial.list());&#xA;  myPort = new Serial(this,Serial.list()[0],9600);&#xA;}&#xA;//equivalent of arduino's loop function&#xA;void draw(){&#xA;  if(myPort.available() &amp;gt; 0)&#xA;  {&#xA;    bgcolor = myPort.read();&#xA;    println(bgcolor);&#xA;  }&#xA;&#xA;  background(bgcolor,255,255);&#xA;  image(logo,0,0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, while the code works, and the background color changes as i turn the potentiometer, there is a &lt;strong&gt;huge&lt;/strong&gt; lag between turning the potentiometer and seeing the background change color, and the values from the Arduino/potentiometer change on the processing's serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Changing the speed of Serial communication&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've noticed that when I decrease the speed of Serial communication, e.g. around 100, the delay between turning the potentiometer and seeing it change on my laptop decreases to about 1 second. However, when I decrease the speed of Serial communication even further, e.g. a value of 1, the delay increases again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the flip side, at the standard speed of 9600, the delay is huge, roughly 5sec ++ before the changes in the potentiometer show up on the laptop/processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does decreasing the communication speed (up to a certain point) decrease the time lag, and increasing it increase the time lag? Also, is there anyway I can make it near instantaneous?&lt;/p&gt;&#xA;" OwnerUserId="1563" LastEditorUserId="37" LastEditDate="2014-09-06T12:04:15.717" LastActivityDate="2017-06-02T23:12:00.470" Title="Reducing lag between the arduino and a processing sketch on my computer" Tags="|arduino-uno|programming|serial|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1831" PostTypeId="2" ParentId="1830" CreationDate="2014-06-04T14:25:41.840" Score="11" Body="&lt;p&gt;You're outputting a reading every time round the Arduino &lt;code&gt;loop()&lt;/code&gt;, so it seems likely that your Processing program isn't running fast enough to keep up with it. Try putting a delay into the &lt;code&gt;loop()&lt;/code&gt; in your Arduino code to slow it down, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;    Serial.write(analogRead(A0)/4);&#xA;    delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I know, Processing aims to run at a consistent framerate, which you can modify using the &lt;a href=&quot;http://www.processing.org/reference/frameRate_.html&quot;&gt;&lt;code&gt;frameRate()&lt;/code&gt;&lt;/a&gt; function. By default, it's 60 frames per second, although it may run slower on older systems (or where you're running an intensive program). You can check how fast it's running by reading the &lt;a href=&quot;http://www.processing.org/reference/frameRate.html&quot;&gt;&lt;code&gt;frameRate&lt;/code&gt;&lt;/a&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Introducing a 50 millisecond delay into the Arduino loop means it will be updating a little under 20 times per second. That means it should be fast enough for user interface purposes, but should also be well within the capabilities of your Processing program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the baud rate (communication speed) is concerned, adjusting it by arbitrary amounts is likely to have unpredictable results. That's because the hardware will only support specific speeds, and trying to use anything else can result in the data appearing garbled on the other end. The &lt;a href=&quot;http://arduino.cc/en/Serial/begin&quot;&gt;&lt;code&gt;Serial.begin()&lt;/code&gt;&lt;/a&gt; documentation has some more information about supported baud rates.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-04T14:25:41.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1832" PostTypeId="1" AcceptedAnswerId="1833" CreationDate="2014-06-04T16:21:25.653" Score="6" ViewCount="2890" Body="&lt;p&gt;I'm totally new to Arduino and to electrodynamics in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what happens if I connect my digital pin to an analog input on Arduino, and make digitalWrite and analogRead on the according pins. Here are the options I can think about:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Just connect them directly - &lt;em&gt;it is not a short circuit, is it?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Connect a resistor in between - &lt;em&gt;the voltage should still be 5v, right? Whatever resistor I use?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make a circuit: digital output -&gt; resistor -&gt; ground, and connect the analog input in parallel (in between the resistor and ground) - &lt;em&gt;Does it make sense? What is the difference with the previous option?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you see, I'm really confused now. I would highly appreciate if someone could explain in detail what is happening in all the cases, with corresponding values for the &lt;em&gt;current&lt;/em&gt;, &lt;em&gt;voltage&lt;/em&gt; and &lt;em&gt;resistance&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1702" LastEditorUserId="6936" LastEditDate="2015-07-26T17:31:28.047" LastActivityDate="2018-02-22T18:44:34.533" Title="How to measure voltage with Arduino analog input" Tags="|arduino-uno|electricity|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1833" PostTypeId="2" ParentId="1832" CreationDate="2014-06-04T17:28:35.833" Score="3" Body="&lt;p&gt;You can connect digital pin to analog input directly. That's not very interesting though, since you'll only see two values from the analog input (at least theoretically).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The digital pin gives out 0 or 5 Volts. The analog pin expects 0 to 5 Volts input. The only thing that matters to the analog input is the &lt;em&gt;voltage&lt;/em&gt; with respect to ground. That can be between 0 to 5 volts (returned as 0...1023 by &lt;code&gt;analogRead&lt;/code&gt; function).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Just connect them directly - it is not a short circuit, is it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it's not a short circuit. In general, connecting &lt;em&gt;anything&lt;/em&gt; to an input is not a short circuit. Connecting output to another output is potentially a short circuit.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This makes no difference compared to connecting them directly, unless the resistor value is very high (should be hundreds of kOhms or even MOhms to see a difference, I suppose), because almost no current flows to the input.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Make a circuit: digital output -&gt; resistor -&gt; ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This makes no other difference than that the resistor loads, i.e. draws current from, the digital output. If the resistor value is too small, then the digital output is unable to supply enough current so the 5 V voltage could become less than 5 V, or you could even burn the chip.&lt;/p&gt;&#xA;" OwnerUserId="1552" LastActivityDate="2014-06-04T17:28:35.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1834" PostTypeId="1" AcceptedAnswerId="2877" CreationDate="2014-06-04T17:36:04.037" Score="0" ViewCount="5976" Body="&lt;p&gt;I have connected up my temperature sensor and I am trying to run the one wire address finder to find the address of the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when I run the code it gives me the error: 'OneWire' does not have a type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have imported by the temperature and the onewire libraries but it still does not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;OneWire ds(6);  // This is where the error is&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1622" LastActivityDate="2014-06-08T22:18:30.413" Title="Problems with Dallas temperature sensor code" Tags="|arduino-uno|temperature-sensor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1835" PostTypeId="2" ParentId="1830" CreationDate="2014-06-04T18:08:59.813" Score="7" Body="&lt;p&gt;Your polling loop runs at full speed of your processor,&#xA;and writes to the serial port in each round.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way, you're writing way more often to the serial port than it can handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The port writes out data as fast as you configured it, and &lt;strong&gt;buffer data&lt;/strong&gt; that is comming in from your program &lt;strong&gt;too fast&lt;/strong&gt;, to write it out as soon as possible.&#xA;It the buffer is full, it just drops new data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's important here is that it will keep the order of the values: It is a &lt;strong&gt;FIFO buffer&lt;/strong&gt;, working in First In/First Out order. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is:&lt;br&gt;&#xA; &lt;strong&gt;The loop fills the port buffer, and keeps it 100% full.&lt;/strong&gt;&lt;br&gt;&#xA;If you turn the potentiometer, the changed value &lt;strong&gt;get's written to the end of the buffer&lt;/strong&gt;, the port works as fast as it can to write out all elements in the buffer, that have still the old value.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally the value you are interested in. The most current value we wanted to see immediately was at the end of the FIFO, and first in/ first out also means last in/last out. The opposite of what we want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The maximum frequency it makes sense to read your data, is the frequency you can write it out, so you should use at least a delay that is long enough to write out the bytes at the current port speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;As another, independent measure to prevent this kind of delay in general,&lt;br&gt;&#xA; you could additionally set the write buffer of the port to a minimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would cause data to be dropped much earlier, instead of buffering a lot first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, in many applications that is not what you need; With bad luck, it could work anyway in the beginning, and get unstable in some situations when the timing changes based on things like processor load, and there are only &lt;strong&gt;some random data samples&lt;/strong&gt; that get dropped. A large buffer generally behaves much more deterministic, so do &lt;strong&gt;use a large buffer by default&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1703" LastEditorUserId="1703" LastEditDate="2014-06-18T10:21:14.137" LastActivityDate="2014-06-18T10:21:14.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1836" PostTypeId="1" AcceptedAnswerId="2886" CreationDate="2014-06-04T19:06:07.057" Score="0" ViewCount="11351" Body="&lt;p&gt;Just using the Basic Example &lt;code&gt;AnalogReadSerial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the setup routine runs once when you press reset:&#xA;  void setup() &#xA;{&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() &#xA;{&#xA;  // read the input on analog pin 0:&#xA;  int sensorValue = analogRead(A0);&#xA;  // print out the value you read:&#xA;  Serial.println(sensorValue);&#xA;  delay(1);        // delay in between reads for stability&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a basic voltage divider set up between two 10K resistors from 5V to GND. I have verified with a DMM that the DC voltage at pin A0 is 2.5V. Grounding the A0 pin has no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also seems that enabling either ADC channel 7 (Arduino pin AD0) or enabling every channel, putting the ADC in free-running mode, and deliberately setting it to &lt;em&gt;not&lt;/em&gt; sleep has no effect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ADC-&amp;gt;ADC_CHDR = 0;&#xA;ADC-&amp;gt;ADC_CHER |= 0xFF;&#xA;ADC-&amp;gt;ADC_MR |= 0b10000000;&#xA;ADC-&amp;gt;ADC_MR &amp;amp;= 0b11011111;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, by running the sketch &lt;code&gt;DigitalInputPullup&lt;/code&gt;, I can get the LED on pin 13 to toggle and serial communication to work as I tie the pin to ground, demonstrating that the board is being programmed properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I'm just stumped. Should be the simplest thing in the world and it's just not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;This is my attempt at manually controlling the ADC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned long value;&#xA;&#xA;void setup() &#xA;{&#xA;  //ADC setup&#xA;  ADC-&amp;gt;ADC_WPMR &amp;amp;= 0xFFFE; //disable write protect&#xA;  ADC-&amp;gt;ADC_CHER = 0b100; //Enable AD2     |&#xA;  ADC-&amp;gt;ADC_MR &amp;amp;= 0b11111111000000001111111100000000;&#xA;  ADC-&amp;gt;ADC_MR |= 0b00000000000100100000000000000000; //software trigger, hi res, no sleep, not free running&#xA;  ADC-&amp;gt;ADC_IER = 0b100; //enable interrupt&#xA;  ADC-&amp;gt;ADC_IMR = 0b100; //enable interrupt in mask&#xA;&#xA;  ADC-&amp;gt;ADC_CR |= 0b10; //start first conversion&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() &#xA;{&#xA;  ADC-&amp;gt;ADC_CR |= 0b10; //start conversion&#xA;  while (!(ADC-&amp;gt;ADC_ISR &amp;amp; 0b100)); //wait for conversion to end &#xA;&#xA;  for (int i = 0; i &amp;lt;= 15; i++)&#xA; { &#xA;    value = ADC-&amp;gt;ADC_CDR[i]; //read conversion data for all channels&#xA;    Serial.println(value);    &#xA; }&#xA;&#xA; Serial.println();&#xA; Serial.println();&#xA; Serial.println();&#xA;&#xA; delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just doesn't seem to be doing anything. &lt;code&gt;ADC_CHSR&lt;/code&gt; (the ADC channel status register) shows channel 2 and only channel 2 enabled and conversions are starting and completing, yet now the conversion data is always 2048. Here's the serial output of all 15 channels, now in 12 bit mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;0&#xA;4095&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;&#xA;&#xA;&#xA;0&#xA;0&#xA;4095&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1705" LastEditorUserId="1705" LastEditDate="2014-06-06T19:19:31.427" LastActivityDate="2020-11-15T14:07:08.253" Title="AnalogRead always 1023 on Arduino Due?" Tags="|arduino-due|analogread|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1837" PostTypeId="2" ParentId="1836" CreationDate="2014-06-04T19:44:18.267" Score="2" Body="&lt;p&gt;You need to add this to your setup():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(A0, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to set the pin for reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're reading an input that's already pulled up (in the middle of a voltage divider), that should be all. However, you can turn on the internal pull-up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(A0, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...while the pin is in input mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/PinMode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/AnalogInputPins&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/AnalogInputPins&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1620" LastActivityDate="2014-06-04T19:44:18.267" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1838" PostTypeId="1" AcceptedAnswerId="1843" CreationDate="2014-06-04T22:34:15.163" Score="0" ViewCount="1625" Body="&lt;p&gt;I'm not expert about web development but very excited of doing some rest call using the yun as server (with a minimal python or node.js server inside the openwrt machine in the yun) and expose sensors and actuators to the cloud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also worried about security. I don't want the super-shellproof system but just don't want that accidental visitors reads my home temperature or make my garden light switch on when I'm out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance I have a central unit yun with some logic inside it and few arduino yun that makes reads from sensors and runs actuators around my home. The communication between the central yun and the slaves is happening via REST calls. I'm using &lt;code&gt;curl&lt;/code&gt; for testing it, for instance. Here two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino Yun provide a simple user/password account when &lt;code&gt;arduinoname.local/arduino&lt;/code&gt; is called. How is it implemented?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Let's say I'm using node.js to make a super simple web-server, what is the best way to protect the communication central-yun and slave-yun? and to protect central-gun and internet communication? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Best way in term of computation (the yun machine is not very powerful and I'm going to use battery in some cases) and in term of &quot;easy to implement&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-06-05T07:08:10.143" Title="Arduino Yun and REST call security" Tags="|arduino-yun|web-server|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1840" PostTypeId="1" CreationDate="2014-06-05T00:40:40.570" Score="8" ViewCount="4811" Body="&lt;p&gt;I have followed &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard/&quot;&gt;this tutorial&lt;/a&gt; on flashing my Arduino R3 to turn it into a &quot;USB keyboard&quot;, but the article doesn't explain how the hex works, it's just for granted. Where can I learn about how to make my own hex file so that I can learn how to make my Arduino mimic &lt;em&gt;any&lt;/em&gt; USB device?&lt;/p&gt;&#xA;" OwnerUserId="1708" LastActivityDate="2020-11-26T01:53:10.460" Title="Where can I find out how to make a hex file for arduino firmware?" Tags="|firmware|flash|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1841" PostTypeId="2" ParentId="1840" CreationDate="2014-06-05T02:24:19.963" Score="2" Body="&lt;p&gt;The HEX file is simply a translated version of the AVR executable, which is in turn a translated version of AVR source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many tools available for turning (compiling) AVR source code into an AVR executable, including but not limited to the &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE&lt;/a&gt;, &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow&quot;&gt;Ino&lt;/a&gt;, AVR-GCC, and &lt;a href=&quot;http://www.atmel.com/tools/atmelstudio.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt;. Note that all four tools will compile the code the same way, since AVR-GCC is used under the hood by the other three.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -mmcu=atmega328 source.cc -o executable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you've compiled the code, you can use avr-objcopy to extract the appropriate sections from the executable into HEX files for programming into the flash and EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objcopy -j .text -j .data -O ihex executable executable.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow&quot;&gt;AVRDUDE&lt;/a&gt; to upload the various HEX files to the target device.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c arduino -P /dev/ttyUSB0 -b 19200 -p m328 -U flash:w:executable.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the USB libraries in Arduino/Ino and AVR LibC are limited; you will need to use Atmel Studio if you want full USB capabilities.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-06-05T02:24:19.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1842" PostTypeId="2" ParentId="1830" CreationDate="2014-06-05T02:50:25.777" Score="6" Body="&lt;p&gt;Instead of constantly sending serial data, only send data when the value of the potentiometer has changed over a certain threshold.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int oldValue = 0;&#xA;const int threshold = 5;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(A0, INPUT)&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(oldValue &amp;gt;= analogRead(A0)+threshold || oldValue &amp;lt;= analogRead(A0)-threshold)&#xA;  {&#xA;    Serial.println(analogRead(A0));&#xA;    oldValue = analogRead(A0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1709" LastActivityDate="2014-06-05T02:50:25.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1843" PostTypeId="2" ParentId="1838" CreationDate="2014-06-05T07:08:10.143" Score="1" Body="&lt;p&gt;Password protection of the REST API is done with &lt;a href=&quot;http://en.wikipedia.org/wiki/Basic_access_authentication&quot; rel=&quot;nofollow&quot;&gt;Basic Authentication&lt;/a&gt;. This, coupled with &lt;a href=&quot;http://en.wikipedia.org/wiki/HTTP_Secure&quot; rel=&quot;nofollow&quot;&gt;HTTPS&lt;/a&gt;, makes API calls more secure. Since the SSL certificate is self-generated, you'll need to run &lt;code&gt;curl&lt;/code&gt; with &lt;code&gt;-k&lt;/code&gt; parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Annonomus Penguin suggested, before going into securing the Yuns, you should secure the network they are using (e.g.: home WiFi should use a strong password).&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-06-05T07:08:10.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1844" PostTypeId="1" AcceptedAnswerId="1856" CreationDate="2014-06-05T12:34:34.223" Score="3" ViewCount="23646" Body="&lt;p&gt;I have a piece of electronic that controls a motor. It takes power from AC power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now there is a 10KOhm Potentiometer. The data sheet of this controller says that the control signal is 10Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the &lt;a href=&quot;http://we.tl/Kk89gm2PRL&quot; rel=&quot;nofollow noreferrer&quot;&gt;connections diagram&lt;/a&gt; (in Italian):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gieFs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to emulate the Potentiometer with Arduino. I'm not sure if PWM will do the job. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any hints?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="46" LastEditDate="2014-06-05T23:12:09.963" LastActivityDate="2019-01-21T02:14:57.640" Title="How to emulate an analog potentiometer with PWM" Tags="|arduino-uno|potentiometer|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="1845" PostTypeId="2" ParentId="1840" CreationDate="2014-06-05T13:17:32.537" Score="2" Body="&lt;p&gt;There are plenty of sites out there that document how to make/build such. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Example: http://hunt.net.nz/users/darran/ &#xA;or https://github.com/harlequin-tech/arduino-usb&#xA;GOOGLE: build usb keyboard 16u2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that when attempting this on the Uno R3, the DFU is updating the code on the 16U2 and not the 328p. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest for novices to use the Leonardo. Where there are stock examples in the IDE for using the application directly as USB HID. Avoiding any alterations to either the boot loader or the USB to Serial co-processor chip (the 16u2). Making it much simpler.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-06-05T13:17:32.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1846" PostTypeId="1" AcceptedAnswerId="1852" CreationDate="2014-06-05T17:37:55.640" Score="1" ViewCount="1526" Body="&lt;p&gt;I'm trying to control an led attached to my arduino via key presses on my laptop.When i hold down a key, the led should light up, and when i release the key, the led should turn off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While my code works ATM, i am wondering why my code will not work if i replace the numbers in my code with text/strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Processing code(Working)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial myPort;&#xA;&#xA;void setup(){&#xA;  println(&quot;The available ports are: &quot;);&#xA;  println(Serial.list());&#xA;  myPort = new Serial(this,Serial.list()[0],9600);&#xA;  myPort.buffer(8);&#xA;  size(500, 500);&#xA;}&#xA;&#xA;void draw(){&#xA;  if(keyPressed){&#xA;    if(key == 'r' || key == 'R'){&#xA;      myPort.write(1);&#xA;      println(&quot;red&quot;);&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void keyReleased(){&#xA;  myPort.write(2);println(&quot;released&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino Code(Working)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int red = 7;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  pinMode(red,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;void serialEvent(){&#xA;    int input = Serial.read();&#xA;  if(input == 1){&#xA;    digitalWrite(red,HIGH);&#xA;  }else if(input == 2){&#xA;    digitalWrite(red,LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Processing Code (Not working)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial myPort;&#xA;&#xA;void setup(){&#xA;  println(&quot;The available ports are: &quot;);&#xA;  println(Serial.list());&#xA;  myPort = new Serial(this,Serial.list()[0],9600);&#xA;  myPort.buffer(8);&#xA;  size(500, 500);&#xA;}&#xA;&#xA;void draw(){&#xA;  if(keyPressed){&#xA;    if(key == 'r' || key == 'R'){&#xA;      myPort.write(&quot;red&quot;);&#xA;      println(&quot;red&quot;);&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void keyReleased(){&#xA;  myPort.write(&quot;released&quot;);&#xA;  println(&quot;released&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino Code(Not working)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int red = 7;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  pinMode(red,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;void serialEvent(){&#xA;    int input = Serial.read();&#xA;  if(input == &quot;red&quot;){&#xA;    digitalWrite(red,HIGH);&#xA;  }else if(input == &quot;released&quot;){&#xA;    digitalWrite(red,LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the above example, i get the error ISO C++ forbids comparisons between pointers and integers.After googling the error, it was suggested that i replace the double quotes with single quotes, after which the arduino code is able to compile, but the processing code gives an error &quot;badly formed character constant(expecting quote,got e)&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then tried changing using double quotes for processing and single quotes for the arduino quote, but predictably, it did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does my code work when i pass numbers to the arduino via serial communication, and my code fails when i use text strings?&lt;/p&gt;&#xA;" OwnerUserId="1563" LastActivityDate="2014-06-05T22:15:38.863" Title="Reading text/strings via processing" Tags="|arduino-uno|programming|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1848" PostTypeId="1" CreationDate="2014-06-05T19:06:41.117" Score="5" ViewCount="21153" Body="&lt;p&gt;How I can connect more than 10 sensors to Arduino Uno R3? I calculated it and I can connect just 4 fire flame sensors (sensors which can find a fire (a candle, for example)) and maybe 1 ultrasonic sensor. I need more for my project. I need an IR Sensor, a fire flame sensor on every side, and 1 ultrasonic sensor in front. Additionally, I need to connect 2 DC motors, 1 fan, and 1 servo-motor for ultrasonic sensor. How can I solve this? I must buy Arduino Mega?&lt;/p&gt;&#xA;" OwnerUserId="1718" LastEditorUserId="220" LastEditDate="2014-06-05T21:28:19.950" LastActivityDate="2019-08-06T08:50:45.270" Title="How to connect more than 10 sensors to Arduino uno r3" Tags="|arduino-uno|sensors|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1849" PostTypeId="1" AcceptedAnswerId="1865" CreationDate="2014-06-05T19:48:56.400" Score="4" ViewCount="5108" Body="&lt;p&gt;The resources I've found regarding the Command Line interface seem to be out of date so I was hoping to find someone with experience using it. I'm currently running Arduino 1.5.6-r2 BETA on Windows 8.1 looking to upload code to an Arduino Leonardo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to create a script(Powershell) file that I can just use to upload code without user intervention. The actual upload part using Arduino CLI is just straight not working for me. If my understanding is correct I should have it already due to my version of the Arduino IDE but none of the functionality works so I'm doubting myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the command I'm attempting to run from Windows Command Prompt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Arduino\arduino.exe --board arduino:avr:leonardo --port COM3 --upload C:\Users\Dev\Documents\Arduino\myProject\myProject.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any insight into what I'm missing would be very much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Additionally, if anyone could provide information regarding the build/upload process which could lead me to a solution from within C# that would be even more amazing. &lt;/p&gt;&#xA;" OwnerUserId="1720" LastEditorUserId="1720" LastEditDate="2014-06-05T21:45:55.323" LastActivityDate="2015-12-16T16:39:25.183" Title="Uploading Sketches from Windows Command Line" Tags="|uploading|arduino-leonardo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1850" PostTypeId="1" CreationDate="2014-06-05T20:49:28.903" Score="2" ViewCount="1267" Body="&lt;p&gt;So I've recently been playing around with my arduino uno, and today it completely refuses to communicate with my computer at all. I've tried using other cables, switched OS (Tried Windows 8.1 and Ubuntu 14.04), and tried on my laptop, none of them recognise the device at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I've read, this problem can be caused my a program on it with a Serial.println() frequently used, which I believe is the case here. The solution for this problem is according to other answers, to hold the reset button while I upload an empty sketch to the arduino. However, I can't do this, since the computer doesn't communicate with the arduino at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what could've gone wrong, and how to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Alright, the problem seems to have resolved itself... I have no idea what made it work, I was frustrated and went to bed last night, and today it works without an issue..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT #2: Scratch that.. now I get this error when I try to upload a program to the arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude stk500_getsync() not in sync resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The device does show up in Device Manager, so I tried installing the arduino drivers for it, but it gives me the error code 10. Windows automatically installs some serial driver for it, but any attempts of serial communication with the arduino fails.&lt;/p&gt;&#xA;" OwnerUserId="1721" OwnerDisplayName="user3712918" LastEditorUserId="1721" LastEditDate="2014-06-06T17:03:26.730" LastActivityDate="2015-10-31T16:34:15.580" Title="How can I reset the program on an Arduino Uno while the device isn't recognised by my computer at all?" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="1851" PostTypeId="2" ParentId="1848" CreationDate="2014-06-05T21:50:46.257" Score="1" Body="&lt;p&gt;The Mega is the easiest way to get many pins is, as you said, the Mega. It has many other advantages, such as more amperage, more memory, and more UART ports. I highly recommend doing this route for a beginner, even if you get a clone instead of an official board. If none of this would be an advantage to you, there are a few different things.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Second MCU.&lt;/strong&gt; You can get another chip identical to the Uno's to connect. This is called an &lt;a href=&quot;http://playground.arduino.cc/Learning/AtmegaStandalone&quot; rel=&quot;nofollow&quot;&gt;ATmega standalone&lt;/a&gt;. They're fairly cheap. I&lt;sub&gt;2&lt;/sub&gt;C is the easiest way to connect them, using only two pins from each chip. The setup will depend on the project.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Multiplexing.&lt;/strong&gt; There is a way that you can connect more stuff than there is pins on the Arduino. This is called &lt;em&gt;multiplexing&lt;/em&gt;. It does affect performance a little, but for some applications it is worth it. Note: this won't work well with libraries or SPI/I&lt;sub&gt;2&lt;/sub&gt;C. The 4051 chip seems like a decent chip. &lt;a href=&quot;http://playground.arduino.cc/Learning/4051&quot; rel=&quot;nofollow&quot;&gt;The Arduino playground has good introduction article on this chip.&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-05T21:50:46.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1852" PostTypeId="2" ParentId="1846" CreationDate="2014-06-05T22:15:38.863" Score="2" Body="&lt;p&gt;The problem is that you're mixing different variable types. It's kinda an oil/water scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, the &lt;code&gt;serial.read();&lt;/code&gt; command returns an integer, &lt;code&gt;-1&lt;/code&gt; if there's nothing in the buffer. If there is something, it will return the character code (i.e. 93 = &lt;code&gt;a&lt;/code&gt;). Because of that, &lt;em&gt;it's an integer.&lt;/em&gt; When you put something in single quotes, it compiles as the equivalent ISO character code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when you do &lt;code&gt;input == 2&lt;/code&gt;, it is &lt;code&gt;integer [compared to] integer&lt;/code&gt;. When you do &lt;code&gt;input == &quot;string&quot;&lt;/code&gt;, you're doing &lt;code&gt;integer [compared to] string&lt;/code&gt;, thus you get errors. BTW: a string is a type of pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what you have to do is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string input = &quot;&quot;;&#xA;if(serial.avaliable()) {&#xA;    delay(100); //Wait for all data to be received&#xA;    while(serial.avaliable()) {&#xA;        string = string + char(serial.read());&#xA;    }&#xA;}&#xA;if(input == &quot;yay_it_works!) {&#xA;    //Done!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-05T22:15:38.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1853" PostTypeId="2" ParentId="1850" CreationDate="2014-06-05T22:37:39.523" Score="3" Body="&lt;p&gt;I had the same problem with my Arduino Leonardo. But when I kept the reset button pressed and plugged it into my laptop, it got recognised again. But since you're using an arduino uno it might also be the atmega16u2 which isn't working properly. If holding the reset button while plugging in the arduino to the laptop doesn't work, try to reset your atmega16u2 chip on the arduino. This is the chip which makes the communication from USB possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reset the atmega16u2 follow &lt;a href=&quot;http://arduino.cc/en/Hacking/Upgrading16U2Due&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial&lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-06-05T22:37:39.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1854" PostTypeId="2" ParentId="1848" CreationDate="2014-06-05T22:48:02.723" Score="2" Body="&lt;p&gt;I wouldn't recommend multiplexing, but I do agree that one way is to add a second MCU.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another better option is to use &lt;a href=&quot;https://www.sparkfun.com/products/733&quot; rel=&quot;nofollow&quot;&gt;an N-bit shift register&lt;/a&gt;.  These are little IC's that are exactly what the name entails: shift registers, and are much easier to setup and interface to than wasting a whole other microcontroller to add I/O's or multiplexing (which limits your application).  You effectively shift in the I/O settings that you want and then can latch those registers when you have the proper I/O sequence loaded into the register.  In other words if I wanted to have 8 new I/O pins, I could connect an 8-bit shift register to my MCU and if I wanted 4 of the first pins HIGH and the last 4 low, I would shift in 00001111b, then latch the data so that it appears on the output just as if it were any regular I/O pin on the MCU.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They only require a few pins to operate them (, so this is an easy way to add more sensors to your system.  As always, check the datasheet to make sure the IC meets your specs (in terms of current draw, voltage, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A disadvantage to this is that for an N-bit shift register, you will burn N clock cycles to load in the data.  For most applications this should be fine, but it is worth noting.  It also makes for slightly more complex code (although I am sure there are libraries for them out there). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I saw that you mentioned controlling things such as DC motors, etc.  Make sure you are not trying to directly drive them with the I/O pins, and are using a switch or transistor to control these types of peripherals.&lt;/p&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2014-06-05T22:48:02.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1855" PostTypeId="2" ParentId="1844" CreationDate="2014-06-05T23:21:35.173" Score="1" Body="&lt;p&gt;I won't be able to answer your question completely, but hopefully I'll be able to make things a bit clearer for someone more knowledgeable to complete the answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I could understand from the datasheet, inputs 1, 2 and 3 are used to connect a pot that will control the motor speed. It's the POTENZIOMETRO DI COMANDO (control pot) in the figure linked in the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet also specifies (in the figure below) that you can connect terminal 3 to ground and feed terminal 2 with a voltage from 0 to 10Vcc, that will control the motor. That's how you control the motor using a MCU, I suppose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uXukF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's where my knowledge is getting short. I'm guessing that a PWM signal won't do the trick. You'll need to feed an actual voltage in terminal 2 to control the motor properly. To do that you have a few alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use an ADC IC&lt;/li&gt;&#xA;&lt;li&gt;Use an &lt;a href=&quot;http://en.wikipedia.org/wiki/Resistor_ladder#R-2R_resistor_ladder_network_.28digital_to_analog_conversion.2C_or_DAC.29&quot; rel=&quot;nofollow noreferrer&quot;&gt;R2R resistor ladder network&lt;/a&gt; using digital outputs and some means to amplify its voltage to 10Vcc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I hope this helps a bit.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-06-05T23:21:35.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1856" PostTypeId="2" ParentId="1844" CreationDate="2014-06-06T00:26:07.993" Score="3" Body="&lt;p&gt;Adding to Ricardo's answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PWM can do the job, sort of. You need a low pass filter (LPF) to convert the PWM to an analog voltage and an amplifier to take it from 0-5 to 0-10V. Or you can get a dedicated digital-to-analog (DAC) chip but that will obviously be more expensive than a resistor and capacitor for the LPF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some tutorials on converting your PWM to an analog voltage:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino-info.wikispaces.com/Analog-Output&quot; rel=&quot;nofollow&quot;&gt;Analog-Output: How-To&lt;/a&gt;&#xA;&lt;a href=&quot;http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/&quot; rel=&quot;nofollow&quot;&gt;Arduino’s AnalogWrite – Converting PWM to a Voltage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to basically double the voltage. You do that with an operational amplifier. The resistors you pick for the op amp set its &quot;gain&quot;, in this case you want it to be 2 so you can go from ~5v (max output) to 10v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of that: &lt;a href=&quot;http://prometheusfusionperfection.com/2011/09/03/my-first-op-amp-circuit/&quot; rel=&quot;nofollow&quot;&gt;My First OP-AMP Circuit&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-06-06T00:26:07.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1857" PostTypeId="1" AcceptedAnswerId="1858" CreationDate="2014-06-06T01:25:21.727" Score="5" ViewCount="118" Body="&lt;p&gt;What documentation is available regarding the differences between the different Arduino platforms?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have some code written for an Arduino Teensy that I would like to run on an Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there documentation on the capabilities and equivalencies between each of the platforms?  e.g. memory, number of PWM outputs, etc?&lt;/p&gt;&#xA;" OwnerUserId="3540" OwnerDisplayName="Mark Harrison" LastEditorUserId="42" LastEditDate="2015-04-10T16:17:56.623" LastActivityDate="2015-04-10T16:17:56.623" Title="How do I convert code between Arduino platforms?" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1858" PostTypeId="2" ParentId="1857" CreationDate="2014-06-06T01:44:44.413" Score="4" Body="&lt;p&gt;The most detailed one seems to be &lt;a href=&quot;http://www.baldengineer.com/projects/arduino-comparison-chart/&quot; rel=&quot;nofollow&quot;&gt;Baldengineer's&lt;/a&gt;, but &lt;a href=&quot;http://arduino.cc/en/Products.Compare&quot; rel=&quot;nofollow&quot;&gt;Arduino&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/arduino_guide&quot; rel=&quot;nofollow&quot;&gt;SparkFun&lt;/a&gt;, and &lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-selection-guide/arduino-comparison-chart&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt; have their own as well, although more limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As always, the best source for information about them is the datasheets for both the MCU(s) used as well as for the boards themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And note that different macros are predefined for each MCU and feature (e.g. &lt;code&gt;__AVR_ATmega328__&lt;/code&gt; and &lt;code&gt;__AVR_HAVE_MUL__&lt;/code&gt;); it is possible to test for their existence in order to customize behavior.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-06-06T01:44:44.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1859" PostTypeId="2" ParentId="1830" CreationDate="2014-06-06T12:32:35.520" Score="14" Body="&lt;p&gt;As already pointed out, your Arduino is saying too much too fast. Adding &lt;code&gt;delay()&lt;/code&gt; will slow it down, but still it keeps yelling at Processing. Ideally, you want Processing to ask for the value when it's convenient, and then receive one answer from your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enter &lt;code&gt;SerialEvent()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As opposed to &lt;code&gt;loop()&lt;/code&gt; on your Arduino and &lt;code&gt;draw()&lt;/code&gt; in Processing, everything inside &lt;code&gt;serialEvent()&lt;/code&gt; only excutes when there is something new in the serial buffer. So instead of Processing asking questions as fast as possible and your Arduino yelling back even faster, they can have a nice, polite (asynchronous) conversation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both Processing and Arduino have a serialEvent. &lt;a href=&quot;http://arduino.cc/en/Tutorial/SerialEvent&quot;&gt;This is serialEvent() on the Arduino&lt;/a&gt; and &lt;a href=&quot;https://www.processing.org/reference/libraries/serial/serialEvent_.html&quot;&gt;this is serialEvent() in Processing.&lt;/a&gt; Using serialEvent on both sides, this is what would happen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Processing sends a character to the serial connection. This could be any character, but if we predetermine one we can filter out any unwanted requests caused by e.g. a noisy signal. For this example, let's send a &lt;code&gt;V&lt;/code&gt; every time we want a new reading of your potmeter. After the character is sent, we continue our business as usual. Not waiting around for an answer here!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the Arduino side nothing is happening, until it receives data in the serial buffer. It checks whether the incoming character is a &lt;code&gt;V&lt;/code&gt;, and lucky us, it is. The Arduino reads the potmeter's value once, outputs that value to serial once, and goes back to chilling out, maxing relaxing all cool. Protip: terminate the value with a character (&lt;code&gt;*&lt;/code&gt; in our case). This will help you in the next step.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Processing is doing its regular interfacey pixel business when all of a sudden there's &lt;strike&gt;a disturbance in the force&lt;/strike&gt; new data in the serial buffer. It switches to &lt;code&gt;serialEvent()&lt;/code&gt;, and starts reading the serial data, until our terminating &lt;code&gt;*&lt;/code&gt; is encountered. Knowing for sure this was the last character worth reading, we can now store the incoming value in a variable that stores the Arduino's reading.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;That's it. Processing now knows the new sensor value and carries on with whatever we tell it to do. Meanwhile, your Arduino is enjoying the weather or contemplating its existence until there is incoming serial data.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1429" LastEditorUserId="1429" LastEditDate="2014-06-19T11:45:49.910" LastActivityDate="2014-06-19T11:45:49.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="1860" PostTypeId="2" ParentId="169" CreationDate="2014-06-06T14:26:00.993" Score="2" Body="&lt;p&gt;A wire wrap tool can work well for this - the wrappings tend to be fairly secure if done right, though the wire itself can break if stressed.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-06-06T14:26:00.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1863" PostTypeId="2" ParentId="1844" CreationDate="2014-06-06T16:32:50.003" Score="2" Body="&lt;p&gt;You can use any typical motor control chip like a ULN2003 with PWM and maybe a smoothing capacitor, &lt;a href=&quot;http://lmgtfy.com/?q=uln2003+arduino&quot; rel=&quot;nofollow&quot;&gt;Google &quot;ULN2003 Arduino&quot;&lt;/a&gt; for many examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the pinouts from Ricardo's answer, you'd get the 10V from pin 1 and ground from pin 3, and feed the PWM'd output from the ULN2003 back into pin 2.&lt;/p&gt;&#xA;" OwnerUserId="1620" LastEditorUserId="1620" LastEditDate="2014-06-06T16:39:20.357" LastActivityDate="2014-06-06T16:39:20.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1864" PostTypeId="2" ParentId="1651" CreationDate="2014-06-06T17:53:28.280" Score="0" Body="&lt;p&gt;So the solution to this was to remove the transistor all together and connect the Arduino pin directly to the Pi. However, I need to change my Arduino sketch. The approach was to set the pin HIGH and go LOW when selected. I had it backwards.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-06-06T17:53:28.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1865" PostTypeId="2" ParentId="1849" CreationDate="2014-06-06T18:27:12.380" Score="3" Body="&lt;p&gt;Turns out that the Ignoring Bad Library Name error that I had been receiving regardless of if I ran Arduino IDE through command line or standalone was the issue. For whatever reason it was blocking the script with a dialog that then failed the upload regardless of if I manually moved through the popup. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final setup for those looking for this in the future:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Windows 8.1 x64 with Arduino IDE version 1.5.6-r2(I will revert to 1.0.5 and test with that, and report results) using a Leonardo board. Command is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working Directory: C:\Program Files (x86)\Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino --board arduino:avr:leonardo --port COM14 --upload C:\Users\Dev\Documents\Arduino\sketch_jun06a\sketch_jun06a.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: As promised, I attempted this with version 1.0.5-r2 and was unsuccessful. Potentially a 1.5.+ feature.&lt;/p&gt;&#xA;" OwnerUserId="1720" LastEditorUserId="1720" LastEditDate="2014-06-09T23:28:43.077" LastActivityDate="2014-06-09T23:28:43.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1866" PostTypeId="1" AcceptedAnswerId="1871" CreationDate="2014-06-06T17:29:39.103" Score="1" ViewCount="1314" Body="&lt;p&gt;I've never used Arduino but I know a few of its utilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to input audio from a Jack cable (analog) and be able to send it via Bluetooth, or Wi-Fi, or USB to an Android Phone and being able to print the values (from 0 to 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for tutorials but I just find the way to make the input but not the output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which one would you recommend me of Bluetooth, Wi-Fi and USB?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="1729" OwnerDisplayName="Rafa Firenze" LastActivityDate="2014-06-07T03:00:47.390" Title="Input audio from jack to Arduino, and output by" Tags="|android|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1867" PostTypeId="1" CreationDate="2014-06-06T18:37:07.520" Score="-3" ViewCount="862" Body="&lt;p&gt;I've recenly bought my first Arduino uno and I was messing with DC motors. I put on the prototype shield on arduino with a mini breadboard on it. I was using L293D bridge. I've connected everything and then put in my 6V battery pack and it BURNED. I don't know what happened. I didn't upload the code, I just connected batteries. I put negative to GND and positive to pin 8. Arduino is responding, but I'n not sure whether all pins are working, how do you check this?&lt;/p&gt;&#xA;" OwnerDisplayName="user44161" LastEditorUserId="11" LastEditDate="2014-06-06T19:58:31.537" LastActivityDate="2014-06-11T07:19:33.747" Title="Did I burn my Arduino UNO?" Tags="|motor|safety|battery|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="1868" PostTypeId="1" CreationDate="2014-06-06T21:24:36.457" Score="2" ViewCount="3927" Body="&lt;p&gt;The Arduino Mega 2560 Rev 3 has multiple relays connected to its digital output pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever the Arduino is reset (using reset button, turning on Serial Monitor etc), the Arduino turns on all relays then turns them off. I cant find any function in my sketch that causes the outputs to go HIGH then LOW. Assuming this is a normal feature of the Arduino, how can we prevent this and ensure that the outputs do not flip to the HIGH state?&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2017-09-10T11:46:12.677" Title="Prevent Arduino Mega from setting all Outputs to HIGH on Reset" Tags="|arduino-mega|pins|relay|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1869" PostTypeId="2" ParentId="1868" CreationDate="2014-06-06T21:47:46.190" Score="2" Body="&lt;p&gt;The ATmega2560 itself comes out of reset with all pins in high-Z (DDRx=0, PORTx=0). Your observations are likely due to the bootloader. Check the bootloader source to verify that it is responsible for this.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-06-06T21:47:46.190" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="1870" PostTypeId="2" ParentId="1867" CreationDate="2014-06-06T23:07:30.937" Score="4" Body="&lt;p&gt;To make sure all pins are responding you could put all your pins as input with internal pull-up except pin 13 which must be set as output. The on board led is connected to pin 13, so when you put pin13 high it will turn the led on. Connect every other pin 1 by 1 to the GND to see if the led is toggling once you've connected a pin to the GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to use this code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){  &#xA;for(int p = 0; p &amp;lt;= 12; p++){  // Define pin0 until pin12 to INPUT with internal pull-up resistor&#xA;pinMode(p, INPUT_PULLUP); &#xA;} &#xA;pinMode(A0, INPUT_PULLUP);  // Define pinA0 as INPUT with internal pull-up resistor&#xA;pinMode(A1, INPUT_PULLUP);  // Define pinA1 as INPUT with internal pull-up resistor&#xA;pinMode(A2, INPUT_PULLUP);  // Define pinA2 as INPUT with internal pull-up resistor&#xA;pinMode(A3, INPUT_PULLUP);  // Define pinA3 as INPUT with internal pull-up resistor&#xA;pinMode(A4, INPUT_PULLUP);  // Define pinA4 as INPUT with internal pull-up resistor&#xA;pinMode(A5, INPUT_PULLUP);  // Define pinA5 as INPUT with internal pull-up resistor&#xA;pinMode(13, OUTPUT);        // Define pin13 as OUTPUT (INTERNAL LED);&#xA;}&#xA;&#xA;void loop(){ &#xA;if(digitalRead(0, LOW)){   // If pin0 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(1, LOW)){   // If pin1 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(2, LOW)){   // If pin2 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(3, LOW)){   // If pin3 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(4, LOW)){   // if pin4 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;}&#xA; if(digitalRead(5, LOW)){  // If pin5 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;}&#xA; if(digitalRead(6, LOW)){  // If pin6 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(7, LOW)){   // If pin7 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(8, LOW)){   // If pin8 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(9, LOW)){   // If pin9 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(10, LOW)){  // If pin10 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(11, LOW)){  // If pin11 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(12, LOW)){  // If pin12 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(A0, LOW)){  // If pinA0 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(A1, LOW)){  // If pinA1 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(A2, LOW)){  // If pinA2 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(A3, LOW)){  // If pinA3 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;if(digitalRead(A4, LOW)){  // If pinA4 is connected to GND turn led off&#xA;digitalWrite(13, LOW); &#xA;} &#xA;if(digitalRead(A5, LOW)){  // If pinA5 is connected to GND turn led on&#xA;digitalWrite(13, HIGH); &#xA;} &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1532" LastEditorUserId="1532" LastEditDate="2014-06-11T07:19:33.747" LastActivityDate="2014-06-11T07:19:33.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1871" PostTypeId="2" ParentId="1866" CreationDate="2014-06-07T03:00:47.390" Score="3" Body="&lt;p&gt;The simplest solution: &lt;em&gt;it really depends.&lt;/em&gt; There are a couple of things to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bluetooth&lt;/strong&gt; would probably be the least professional to impliment. The easiest way to do this is &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.primavera.arduino.listener&quot; rel=&quot;nofollow&quot;&gt;with an app&lt;/a&gt;. You can impliment it into &lt;em&gt;your&lt;/em&gt; application with this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Let your own Android application receive data from Arduino by listening to the &quot;primavera.arduino.intent.action.DATA_RECEIVED&quot; intent. This intent will contain the &quot;primavera.arduino.intent.extra.DATA&quot; byte array with the received data. Call getByteArrayExtra(&quot;primavera.arduino.intent.extra.DATA&quot;) to retrieve the data. Send data to Arduino from your application by broadcasting an intent with action &quot;primavera.arduino.intent.action.SEND_DATA&quot;. Add the data to be sent as byte array extra &quot;primavera.arduino.intent.extra.DATA&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Still, that's pretty unprofessional IMHO. There are probably other ways to do this, but &lt;em&gt;Arduino Uno Communicator&lt;/em&gt; is the easiest by far that I've seen. The main advantage of Bluetooth is it works without a router and it's very cheap (as far as wireless). I can't remember if it's the HC4 or HC5 chip that is commonly available, but [one of those] can be picked up for around $6. Just connect via serial and issue AT commands.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;WiFi&lt;/strong&gt; would be the most professional. First of all, people hear &lt;em&gt;Wifi&lt;/em&gt; and they think &lt;em&gt;Ohh! Shiny! I'm going to buy it!&lt;/em&gt; That's just what I've observed in the past, but it may not always be true. WiFi can be done with the TL-WR703N router. &lt;a href=&quot;http://www.martinmelchior.be/2013/07/use-tp-link-tl-wr703n-to-send-arduino.html?m=1&quot; rel=&quot;nofollow&quot;&gt;This blog post&lt;/a&gt; outlines how you can even connect it &lt;em&gt;directly&lt;/em&gt; to the Arduino. You can also use an ethernet shield (or equivalence, I've seen breakout ethernet boards built for ~$5). Either way, it's a great way to add 5V WiFi to your Arduino. The only disadvantage is cost and it only works if you're near a WiFi router. If those aren't disadvantages, go ahead with WiFi; it's a great product.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;USB&lt;/strong&gt; is only useful if you want:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Speed&lt;/li&gt;&#xA;&lt;li&gt;Stability&lt;/li&gt;&#xA;&lt;li&gt;Portability (i.e. no WiFi Router)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Speed can be eliminated as a need if you only send data every 300 ms or so, depending on what you're doing. For WiFi, it might be best to only go to a webpage when an even occurs (i.e. button pushed on Arduino). Bluetooth and WiFi are stable enough if you're over short distances (and you couldn't go a long way with wires, anyway), and there's not too much interference (don't try at a football game with 50K cell phones... granted, they will be on different bands if using cell service, but Bluetooth may be on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as portability, for the price of an OTG cable for your phone, you'd be better off buying a Bluetooth module for a dollar extra.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Suggestion: go with WiFi unless you need the portability. Consider figuring out WPS so your users can connect to WiFi with a push of a button. I don't know if the TL-WR703N has support for WPS, via serial or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forgot to mention: I don't know everything about your app, but WiFi might have too much latency/overhead for near-instant response. As far as wireless, Bluetooth would have much lower latency AFAIK. (As you can tell, there's no perfect solution here :-))&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-07T03:00:47.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="1872" PostTypeId="1" AcceptedAnswerId="1874" CreationDate="2014-06-08T08:21:06.747" Score="0" ViewCount="375" Body="&lt;p&gt;I have 3 LEDs connected to my arduino which are controlled via laptop key presses with processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the LEDs are able to light up when the respective buttons are pressed, i am unable to light up all 3 LEDs simultaneously when i press all 3 keys at the same time. I am however able to light up 2 LEDs by pressing 2 buttons simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the LEDs light up when their respective buttons are pressed, so i know that it is not a defective LED and/or faulty connections/wiring at play but something else that is causing the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My processing code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial myPort;&#xA;&#xA;void setup(){&#xA;  println(&quot;The available ports are: &quot;);&#xA;  println(Serial.list());&#xA;  myPort = new Serial(this,Serial.list()[0],9600);&#xA;  myPort.buffer(64);&#xA;  size(500, 500);&#xA;}&#xA;&#xA;void draw(){&#xA;  if(keyPressed){&#xA;    if(key == 'r' || key == 'R'){&#xA;      myPort.write(1);&#xA;      println(&quot;red&quot;);&#xA;    }&#xA;    else if(key == 'y' || key == 'Y'){&#xA;      myPort.write(2);&#xA;      println(&quot;yellow&quot;);&#xA;    }&#xA;    else if(key == 'g' || key == 'G'){&#xA;      myPort.write(3);&#xA;      println(&quot;green&quot;);&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&#xA;void keyReleased(){&#xA; if(key == 'r' || key == 'R'){&#xA;      myPort.write(4);&#xA;      println(&quot;red released&quot;);&#xA;    }&#xA;    else if(key == 'y' || key == 'Y'){&#xA;      myPort.write(5);&#xA;      println(&quot;yellow released&quot;);&#xA;    }&#xA;    else if(key == 'g' || key == 'G'){&#xA;      myPort.write(6);&#xA;      println(&quot;green released&quot;);&#xA;    }&#xA;&#xA;  println(&quot;released&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int red = 7;&#xA;int yellow = 6;&#xA;int green = 5;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  pinMode(red,OUTPUT);&#xA;   pinMode(yellow,OUTPUT);&#xA;    pinMode(green,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;void serialEvent(){&#xA;    int input = Serial.read();&#xA;    if(input == 1){&#xA;      digitalWrite(red,HIGH);&#xA;    }&#xA;    else if(input == 2){&#xA;      digitalWrite(yellow,HIGH);&#xA;    }&#xA;    else if(input == 3){&#xA;      digitalWrite(green,HIGH);&#xA;    }&#xA;    else if(input == 4){&#xA;      digitalWrite(red,LOW);&#xA;    }&#xA;    else if(input == 5){&#xA;      digitalWrite(yellow,LOW);&#xA;    }&#xA;    else if(input == 6){&#xA;      digitalWrite(green,LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Things i've tried.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I've tried increasing the buffer size from 10(initially) to 64(in the code above)&lt;/li&gt;&#xA;&lt;li&gt;I've tried increasing the baud rate from 9600 to 12000, just in case it was the serial information not being read fast enough.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;None of the things i've tried, listed above, was above to solve my problem, and i dont see what could be causing the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="1563" LastActivityDate="2014-06-08T12:55:35.353" Title="Unable to light up all the LEDS connected to Arduino using processing" Tags="|arduino-uno|programming|serial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="1873" PostTypeId="2" ParentId="1848" CreationDate="2014-06-08T11:07:36.877" Score="7" Body="&lt;p&gt;You can easily increase number of I/O pins using an expander, e.g. PCF8574. &#xA;The expander can be connect using your SCL/SDA pins located next to GND/AREF pins. (Here you can find detailed photo: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=84190.0&quot; rel=&quot;noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=84190.0&lt;/a&gt;) You can connect up to 8 such expanders to extend the number of your digital pins to 64. &lt;br&gt;Once you connect it, here is a code snippet of how to use it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PCF8574.h&amp;gt; //library available at: https://github.com/skywodd/pcf8574_arduino_library&#xA;&#xA;void setup() {&#xA;  PCF8574 sensors;&#xA;  sensors.begin(0x20); //0x20 means that you connected A0, A1, A2 pins of PCF8574 to the ground&#xA;  sensors.pinMode(0, INPUT_PULLUP);&#xA;  sensors.pinMode(1, INPUT_PULLUP);&#xA;/*...*/&#xA;}&#xA;void loop() {      &#xA;&#xA;  byte sensorValue = sensors.digitalRead(0); //reads digital value of 1st sensor connected to pin 0 of PCF8574 expander&#xA;  /*...*/&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read more with &lt;a href=&quot;http://ardugonic.blogspot.com/2010/06/icm7218a-combined-with-pcf8574-to.html&quot; rel=&quot;noreferrer&quot;&gt;this tutorial&lt;/a&gt; (note: they are using wire interface, so the code will differ. Choose the one you prefer).&lt;/p&gt;&#xA;" OwnerUserId="1737" LastEditorUserId="1737" LastEditDate="2014-06-08T13:51:09.730" LastActivityDate="2014-06-08T13:51:09.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1874" PostTypeId="2" ParentId="1872" CreationDate="2014-06-08T12:55:35.353" Score="1" Body="&lt;p&gt;I'm guessing it is a hardware issue as I discussed in the comments above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have just set up a breadboard and copied your code verbatim into the Arduino IDE and Processing (I edited the port index to use). It works as desired. Pressing R, G, or Y will turn on the respective LED and releasing it will turn it off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can press these three keys in any combination of none on, one only, any two, or all three, and the LED gives the expected result. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keyboards were not initially designed to have multiple &quot;main&quot; keys pressed down at any one time, the exceptions to these being the modifier keys (Windows/Command, Option/Alt, Control and possibly some others (I'm thinking the older keyboards here that had &quot;other&quot; keys—Scroll Lock, Print Scr, etc—I'm really unsure). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears now, that some hardware and software may have overcome this. As I've said, your project works fine for me. Also, you could try three different keys, it could be a result of how the keys are scanned and you may stumble across three that don't interfere with each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I've suggested in the comments to your question, modify the code to utilise the modifier keys instead, or use the keyboard keys as toggles (ie press once for on, press again to turn it off). &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-08T12:55:35.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="1875" PostTypeId="1" CreationDate="2014-06-08T16:20:09.170" Score="2" ViewCount="549" Body="&lt;p&gt;I've found this code below, but I can't figure out how it works. Can someone explain to me the flow of the program?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(2, 3, 10, 7, 5, 4);&#xA;int mem=0;&#xA;void setup() {&#xA;    pinMode (12,OUTPUT);&#xA;    pinMode(13,OUTPUT);&#xA;    // initialize the LED pin as an output:&#xA;&#xA;    // initialize serial communications:&#xA;    Serial.begin(9600);&#xA;    lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    lcd.setCursor(12,1);&#xA;    int se25 = analogRead(A4);  &#xA;    int se50 = analogRead(A3); &#xA;    int se75 = analogRead(A5);&#xA;    int se100 = analogRead(A2);  &#xA;    if(se100&amp;gt;=1000){lcd.print(&quot;100%   &quot;);mem=100; }  &#xA;    else if(se75&amp;gt;=1000){lcd.print(&quot;75%   &quot;);mem=75; } &#xA;    else if(se50&amp;gt;=1000){lcd.print(&quot;50%   &quot;);mem=50; }&#xA;    else if(se25&amp;gt;=1000){lcd.print(&quot;25%  &quot;);mem=25; }&#xA;    else{lcd.print(&quot;emty&quot;);mem=0;}&#xA;    if(se100&amp;lt;1000&amp;amp;&amp;amp;se75&amp;lt;1000&amp;amp;&amp;amp;se50&amp;lt;1000&amp;amp;&amp;amp;se25&amp;lt;1000){&#xA;        digitalWrite(13,LOW);&#xA;        lcd.setCursor(12,1);&#xA;        lcd.print(&quot;emty&quot;);&#xA;    }&#xA;&#xA;    if(digitalRead(6)==HIGH){digitalWrite(13,LOW);}&#xA;&#xA;    if(digitalRead(6)==LOW&amp;amp;&amp;amp;mem&amp;gt;0) &#xA;    {// read the value of the potentiometer:&#xA;        int tempw = 0;&#xA;        //digitalWrite(12,LOW);&#xA;        int tempa = analogRead(A1);&#xA;        delay(20); &#xA;        int tempb = analogRead(A1);&#xA;        delay(20); &#xA;        int tempc = analogRead(A1);&#xA;        delay(20); &#xA;        int tempd = analogRead(A1);&#xA;        delay(20); &#xA;        int tempe = analogRead(A1);&#xA;        delay(20); &#xA;        int tempf = analogRead(A1);&#xA;        delay(20); &#xA;&#xA;        int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);&#xA;&#xA;        int temp = avg;  &#xA;        // map it to the range of the analog out:&#xA;        temp = map(temp, 0, 1023, 0, 4900); &#xA;        float tempx = temp * (0.1); &#xA;        // change the analog out value:&#xA;        int tempy=analogRead(A0);&#xA;        tempy = map(tempy, 0, 1023, 0, 150);&#xA;        // print the results to the serial monitor:&#xA;        lcd.setCursor(0,0);&#xA;        lcd.print(&quot;act T=&quot; ); &#xA;        lcd.print(tempx);&#xA;        lcd.print(&quot;'C  &quot; );&#xA;        lcd.setCursor(0,1);&#xA;        lcd.print(&quot;set T=&quot;);  &#xA;&#xA;        lcd.print(tempy);  &#xA;        // Serial.println(&quot;'C &quot;);&#xA;        lcd.print(&quot;'C  &quot;); &#xA;&#xA;        if(tempy&amp;lt;=tempx){digitalWrite(13,LOW);}&#xA;        if(tempy&amp;gt;tempx){digitalWrite(13,HIGH);}&#xA;&#xA;        delay(200);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1739" LastEditorUserId="220" LastEditDate="2014-06-10T20:33:07.843" LastActivityDate="2021-10-22T13:04:23.050" Title="How does this code work?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2874" PostTypeId="2" ParentId="1875" CreationDate="2014-06-08T17:59:41.907" Score="11" Body="&lt;p&gt;I'm assuming you already have some understanding of programming, so I won't literally explain everything line-by-line (that would probably be beyond the scope of this site, and would result in a very long answer). I'll try to explain the important points though. If you need to lookup more information about specific commands, I recommend checking out the &lt;a href=&quot;http://arduino.cc/en/Reference&quot;&gt;Arduino reference&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a very broad level, the program is taking some readings, and reporting data to a screen (LCD). I would guess that the data is the fluid level in a tank, as well as some kind of temperature reading. It's impossible to be sure about that though, as I don't know what's actually connected to the inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line creates an object for talking to the LCD screen. The numbers specify which pins it's connected to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal lcd(2, 3, 10, 7, 5, 4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;setup()&lt;/code&gt; function gets run once when the device starts up, and is typically used for initialisation tasks. In this case, the lines within &lt;code&gt;setup()&lt;/code&gt; initialise two pins as outputs (#12 and #13), initialise serial communication (which isn't actually being used), and initialise the LCD object/screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode (12,OUTPUT);&#xA;pinMode(13,OUTPUT);&#xA;...&#xA;Serial.begin(9600);&#xA;lcd.begin(16, 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The rest of the program is in the &lt;code&gt;loop()&lt;/code&gt; function, which runs repeatedly as long as the device is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following lines take 4 analog-to-digital readings (from different inputs), and output the approximate result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int se25 = analogRead(A4);  &#xA;int se50 = analogRead(A3); &#xA;int se75 = analogRead(A5);&#xA;int se100 = analogRead(A2);  &#xA;if(se100&amp;gt;=1000){lcd.print(&quot;100%   &quot;);mem=100; }  &#xA;else if(se75&amp;gt;=1000){lcd.print(&quot;75%   &quot;);mem=75; } &#xA;else if(se50&amp;gt;=1000){lcd.print(&quot;50%   &quot;);mem=50; }&#xA;else if(se25&amp;gt;=1000){lcd.print(&quot;25%  &quot;);mem=25; }&#xA;else{lcd.print(&quot;emty&quot;);mem=0;}&#xA;if(se100&amp;lt;1000&amp;amp;&amp;amp;se75&amp;lt;1000&amp;amp;&amp;amp;se50&amp;lt;1000&amp;amp;&amp;amp;se25&amp;lt;1000){&#xA;    digitalWrite(13,LOW);&#xA;    lcd.setCursor(12,1);&#xA;    lcd.print(&quot;emty&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My guess is that each of the analog readings comes from a different fluid sensor in a tank. If the top sensor shows a strong reading, the tank is considered full. Otherwise, it checks the next sensor down, and so on. If none of them shows a strong reading, the tank is considered empty. Interestingly, the condition for an empty tank is actually checked twice, which is presumably a mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Once again, bear in mind that I'm just guessing that the readings are from fluid sensors in a tank. I don't know for sure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The remainder of the code only runs if a particular input (#6) is low, and if the tank is not empty. Input #6 could be from some kind of override switch, but again that's just speculation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following block takes 6 analog readings, all from the same input. There's a short delay (20 millisecond) between each reading. The results are then averaged. This is a common approach when you want to try to eliminate noise spikes in an analog signal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int tempa = analogRead(A1);&#xA;delay(20); &#xA;int tempb = analogRead(A1);&#xA;delay(20); &#xA;int tempc = analogRead(A1);&#xA;delay(20); &#xA;int tempd = analogRead(A1);&#xA;delay(20); &#xA;int tempe = analogRead(A1);&#xA;delay(20); &#xA;int tempf = analogRead(A1);&#xA;delay(20); &#xA;&#xA;int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next block re-maps that reading onto a different range (presumably related to the expected temperature range). It then takes another analog reading from a different input, and remaps that to a different range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int temp = avg;  &#xA;&#xA;temp = map(temp, 0, 1023, 0, 4900); &#xA;float tempx = temp * (0.1); &#xA;&#xA;int tempy=analogRead(A0);&#xA;tempy = map(tempy, 0, 1023, 0, 150);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following block outputs the two re-mapped readings. It looks like both of them are treated as temperatures. One is presumably from a temperature sensor, and the other is presumably from a potentiometer used to calibrated the system:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.setCursor(0,0);&#xA;lcd.print(&quot;act T=&quot; ); &#xA;lcd.print(tempx);&#xA;lcd.print(&quot;'C  &quot; );&#xA;lcd.setCursor(0,1);&#xA;lcd.print(&quot;set T=&quot;);  &#xA;&#xA;lcd.print(tempy);  &#xA;&#xA;lcd.print(&quot;'C  &quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines compare the two readings from above, and set output pin 13 high or low depending on which reading is higher. I'd guess it could be connected to a warning light or similar.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(tempy&amp;lt;=tempx){digitalWrite(13,LOW);}&#xA;if(tempy&amp;gt;tempx){digitalWrite(13,HIGH);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lastly, this delay stops the loop from running too fast. Interestingly though, the code only reaches this point under certain circumstances. In other circumstances, there's no limit on loop execution speed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-08T17:59:41.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2875" PostTypeId="1" AcceptedAnswerId="2876" CreationDate="2014-06-08T18:01:43.597" Score="10" ViewCount="42104" Body="&lt;p&gt;I have code for an ultrasonic sensor which I found from a site. Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin 12&#xA;#define echoPin 13&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  int duration, distance;&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(1000);&#xA;  digitalWrite(trigPin, LOW);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;  distance = (duration/2) / 29.1;&#xA;  if (distance &amp;gt;= 200 || distance &amp;lt;= 0){&#xA;    Serial.println(&quot;Out of range&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.print(distance);&#xA;    Serial.println(&quot; cm&quot;);&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I don't understand the work of &lt;code&gt;pulseIn()&lt;/code&gt; function. I mean, I want to know when the time count starts and when it ends. For example, in this code, does the time start at &lt;code&gt;digitalWrite(trigPin, HIGH);&lt;/code&gt; or does the time start at the &lt;code&gt;pulseIn()&lt;/code&gt; function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's the second one, when it stops, then how does the time give us the distance of an obstacle when I am already delaying 1000 microseconds after I send a ping in air?&lt;/p&gt;&#xA;" OwnerUserId="670" LastEditorUserId="6936" LastEditDate="2016-01-24T20:59:30.687" LastActivityDate="2020-01-15T14:49:59.687" Title="What is the work of pulseIn?" Tags="|arduino-uno|sensors|pulsein|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2876" PostTypeId="2" ParentId="2875" CreationDate="2014-06-08T18:10:49.633" Score="9" Body="&lt;p&gt;From the docs:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reads a pulse (either HIGH or LOW) on a pin. For example, if value is&#xA;  HIGH, &lt;code&gt;pulseIn()&lt;/code&gt; waits for the pin to go HIGH, starts timing, then&#xA;  waits for the pin to go LOW and stops timing. Returns the length of&#xA;  the pulse in microseconds. &lt;a href=&quot;http://arduino.cc/en/Reference/pulseIn&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;sub&gt;pulsein&lt;/sub&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, in this case, &lt;code&gt;pulseIn(echoPin, HIGH)&lt;/code&gt; starts counting the number of microseconds until &lt;code&gt;echoPin&lt;/code&gt; goes HIGH and stores that in &lt;code&gt;duration&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It starts and ends on that line, it's what is known as a blocking function. It will really sit there until &lt;code&gt;echoPin&lt;/code&gt; goes high and tells you how long it took (unless you specify a timeout).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That also means that any delays you have before or after the &lt;code&gt;pulseIn&lt;/code&gt; call don't affect it in any way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you get distance from this time is by the following equation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;distance = (duration/2) / 29.1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You divide by two because it goes out and back so the time would be double that of a one-way travel. The 29.1 is the speed of sound (which is 343.5 m/s =&gt; 1 / 0.03435 = 29.1). So note the result is in CM's, not inches. You could probably figure it out by looking at the data sheet of the sensor or just get a lot of samples relating duration to distance (you would measure the distance manually) and get an equation that is very similar.&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="50728" LastEditDate="2020-01-15T14:49:59.687" LastActivityDate="2020-01-15T14:49:59.687" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="2877" PostTypeId="2" ParentId="1834" CreationDate="2014-06-08T22:18:30.413" Score="1" Body="&lt;p&gt;I presume the exact error you get is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: 'OneWire' does not name a type&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This error is typical when the OneWire library (or any other library for that matter) is not located under the  &lt;strong&gt;libraries&lt;/strong&gt; folder, which should be at the root of the Arduino installation folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, make sure that the OneWire.h and OneWire.cpp files are 1 folder down the hierarchy, as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Arduino Installation Folder]\libraries\OneWire\OneWire.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they are nested deeper inside the folder hierarchy, the Arduino IDE will not find these files in its initial scan, and you will get the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to close all Arduino IDE windows and re-open it after fixing the folder path.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-06-08T22:18:30.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2878" PostTypeId="1" AcceptedAnswerId="2890" CreationDate="2014-06-08T22:42:14.087" Score="0" ViewCount="2261" Body="&lt;p&gt;I've been working on a DIY keyboard project I have all the hardware designed and now its time for the code. For the microcontroller, I'm sort of locked into an Arduino UNO r3 as I already have it lying around. I know it doesn't have HID capabilities baked in, but I can flash different firmware to it. At first I was going to go with a generic HID firmware. This approach was problematic because it would require me to first write/send my Arduino sketch, then touch I wire to various portions of my UNO (it isn't SMD). After this,&#xA;I would flash the HID firmware and hope that there were no bugs in my sketch as fixing bugs would have required flashing Arduino firmware and repeating the aforementioned steps. I then had the idea to use Teensy firmware (&lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.pjrc.com/teensy/&lt;/a&gt;). This approach seems better, but I have questions regarding its feasibility. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I upload Teensy programs/sketches to the Arduino after I've&#xA;updated its firmware (if I had a real Teensy I could do this via the teensyduino plugin)?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Similarly, I'd like to write some software that allows me to remap&#xA;    the keyboard. Would the Teensy firmware allow this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does the Arduino have enough memory to support #2?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to reflash BOTH the 8u2 and the 16u2 on my UNO (for details see #2 in update one below)&lt;/li&gt;&#xA;&lt;li&gt;If 4 is possible is it possible to write code that would read/write the flash on the 8u2 as a filesystem? (for details see #2 in update one below)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Would the teensy firmware be a good option given these constraints?&lt;/strong&gt; I know I've focused mainly on the Teensy, but if you have a more straightforward approach I'd love to hear it. &lt;strong&gt;Also, I know Arduino has a keyboard library(&lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Reference/MouseKeyboard&lt;/a&gt;) but, it seems rather basic, seems to block other keyboard signals while in use, and isn't easily remappable(see #2). I haven't completely written this off, so if you think this would be the best option please let me know.&lt;/strong&gt; Thanks for any and all help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Thanks to one of the questions linked by @Ignacio Vazquez-Abrams(&lt;a href=&quot;https://arduino.stackexchange.com/questions/991/can-the-2nd-mcu-on-the-uno-r3-be-used-for-keyboard-emulation&quot;&gt;Can the 2nd MCU on the UNO R3 be used for keyboard emulation?&lt;/a&gt;) on the original question(weirdly it didn't show up here)  I have learned the following things(not necessarily from the question itself but by links provided in it):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the Atmel 8u2 of the UNO has 8kb of flash while the 16u2 has 16kb (should've known) I still don't know if either of these sizes are enough to hold my Teensy code AND 1+ map files generated by the mapping software I would make. (see #2 above)&lt;/li&gt;&#xA;&lt;li&gt;the 8u2 seems like the chip that tinkers are generally advised to reprogram as it wouldn't hold the Arduino sketch. If I'm uploading teensy firmware I shouldn't need Arduino sketch capability (Teensy has that built in) So What I might do is use the 16u2 as a place to hold the firmware my code and use the 8u2 as a filesystem to hold any maps I'd like to store. This leads to more questions see the newly added 4 and 5 &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2741" OwnerDisplayName="fozbstuios" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-10-03T00:06:55.707" Title="Feasability of flashing Arduino UNO r3 with teensy firmware for HID (keyboard) emulation purposes" Tags="|arduino-uno|atmega328|firmware|sketch-size|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2879" PostTypeId="1" AcceptedAnswerId="2966" CreationDate="2014-06-08T23:56:12.657" Score="-1" ViewCount="1602" Body="&lt;p&gt;I have an Arduino Duemilanove and em408.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is this:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;&#xA;TinyGPS gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(4800); &#xA;  }&#xA;&#xA;void loop()&#xA;{&#xA;  while (ss.available())&#xA;  {&#xA;    char c = byte(ss.read());&#xA;    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor&#xA;    if (gps.encode(c))&#xA;    {&#xA;      long lat, lon;&#xA;     unsigned long fix_age;&#xA;    gps.get_position(&amp;amp;lat, &amp;amp;lon, &amp;amp;fix_age);&#xA;    if (fix_age == TinyGPS::GPS_INVALID_AGE )&#xA;      Serial.println(&quot;No fix ever detected!&quot;);&#xA;    else if (fix_age &amp;gt; 2000)&#xA;      Serial.println(&quot;Data is getting STALE!&quot;);&#xA;    else&#xA;      Serial.println(&quot;Latitude and longitude valid!&quot;);&#xA;&#xA;      Serial.print(&quot;Lat: &quot;); &#xA;      Serial.print(lat);&#xA;      Serial.print(&quot; Lon: &quot;); &#xA;      Serial.println(lon);&#xA;&#xA;    }&#xA;    else Serial.println(&quot;No data!&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My output is this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;Latitude and longitude valid!&#xA;Lat: 32758239&#xA; Lon: 15637489&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;No data!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then i continue getting No data! forever...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Why does gps.encode() only manage to return true only 1 time? I have gotten the raw data from the gps (the commented code on my code snippet) and it's ok. Why it returns true only one time? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why the longitude/latidude data is like this? As far as i know, this isnt valid, correct?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Also tried with TinyGPS++.. but no luck in encoding too...&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(4800); &#xA;  }&#xA;&#xA;void loop()&#xA;{&#xA;  while (ss.available()&amp;gt;0)&#xA;  {&#xA;    char c = byte(ss.read());&#xA;    // Here i tried Serial.write(c); and i succesully saw the NMEA data in my serial monitor&#xA;    if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then&#xA;    {&#xA;      Serial.print(F(&quot;Location: &quot;)); &#xA;  if (gps.location.isValid())&#xA;  {&#xA;    Serial.print(gps.location.lat(), 6);&#xA;    Serial.print(F(&quot;,&quot;));&#xA;    Serial.print(gps.location.lng(), 6);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;  Date/Time: &quot;));&#xA;  if (gps.date.isValid())&#xA;  {&#xA;    Serial.print(gps.date.month());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.day());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.year());&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot; &quot;));&#xA;  if (gps.time.isValid())&#xA;  {&#xA;    if (gps.time.hour() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.hour());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.minute() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.minute());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.second() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.second());&#xA;    Serial.print(F(&quot;.&quot;));&#xA;    if (gps.time.centisecond() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.centisecond());&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.println();&#xA;&#xA;    }&#xA;    else Serial.println(&quot;No data!&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;New code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(4800); &#xA;}&#xA;&#xA;char clat[11];&#xA;char clng[11];&#xA;&#xA;void loop()&#xA;{&#xA;    //if (buttons || tilt) {&#xA;    //if (buttons &amp;amp; BUTTON_SELECT) {&#xA;&#xA;        bool isGpsLocationValid = false;&#xA;        do&#xA;        {  &#xA;            while (ss.available()&amp;gt;0)&#xA;            {&#xA;                char c = byte(ss.read());&#xA;                if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then&#xA;                {    &#xA;                    if (gps.location.isValid())&#xA;                    {&#xA;                        dtostrf(gps.location.lat(), 11, 6, clat);&#xA;                        dtostrf(gps.location.lng(), 11, 6, clng);&#xA;                        //send-print&#xA;                        //delay (just in case multiple bumps)&#xA;                        isGpsLocationValid = true;&#xA;                    }&#xA;                }   &#xA;             }&#xA;        } while (isGpsLocationValid == false);&#xA;        Serial.write(clat);&#xA;        Serial.println();&#xA;        Serial.write(clng);&#xA;       //}&#xA;    //}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: The newest code i have posted works 100%!&#xA;So if you have similar problems with that aweful gps, use this!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, TinyGPS and TinyGPS++ don't work well with this gps.&#xA;To be precice, there is a problem with the gps.encode(c) function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So using &lt;code&gt;if (gps.encode(c))&lt;/code&gt; most of the times returns false, except some rare occasions which returns true and then you can do some processing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My last code takes care of that problem by checking continuously, using a do...while loop.&#xA;If &lt;code&gt;if (gps.location.isValid())&lt;/code&gt; returns true, which means i have valid data, then i do the processing i want and end the do...while loop.&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="37523" LastEditDate="2019-07-29T13:31:18.613" LastActivityDate="2019-07-29T13:31:18.613" Title="tinygps abnormal behaviour with EM408 gps" Tags="|softwareserial|tinygps|arduino-duemilanove|" AnswerCount="2" CommentCount="8" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="2880" PostTypeId="1" AcceptedAnswerId="3162" CreationDate="2014-06-09T01:19:33.493" Score="0" ViewCount="675" Body="&lt;p&gt;I just installed the Arduino IDE in openSUSE 13.1. I am able to open the application using the run dialogue, so I know it has installed. However, there is no way to open the IDE from any application launcher. I have tried both the Kickoff and Lancelot applciation managers. I have also tried to uninstall and re-install the IDE, both through the 1-click on the Arduino website as well as through the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why I am unable to launch the application from the launcher? Thanks in advanced for any help!&lt;/p&gt;&#xA;" OwnerUserId="2740" LastActivityDate="2014-07-03T12:00:21.310" Title="Arduino IDE has no shortcut in openSUSE" Tags="|arduino-ide|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2881" PostTypeId="1" AcceptedAnswerId="2884" CreationDate="2014-06-08T23:52:20.927" Score="4" ViewCount="9767" Body="&lt;p&gt;I've hooked up my Arduino on &lt;a href=&quot;http://arduino.cc/documents/datasheets/LCD-WH1602B-TMI.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; LCD, and after running the following code, all I see is a row with black boxes and another one empty.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//LiquidCrystal d(RS, E, D4, D5, D6, D7);&#xA;LiquidCrystal lcd(0, 1, 2, 3, 4, 5);&#xA;&#xA;void setup() {                &#xA;     lcd.begin(16, 2);&#xA;     lcd.print(&quot;hello, world!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;     lcd.print(&quot;hello, world!&quot;);       &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wiring:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/nZumv.jpg&quot; alt=&quot;table showing wiring between arduino and lcd&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The UTP cable is used just for the data lines :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actual wiring photos: (sorry for the total klutz in the wiring, I had limited solid-core wires so I had to use these scrap ones)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://dl.dropboxusercontent.com/s/t7u0e8jt2640zep/Photo%2008-06-14%2008%2031%2013%20PM.jpg&quot; alt=&quot;wiring&quot;&gt;&#xA;&lt;img src=&quot;https://dl.dropboxusercontent.com/s/o9hg6i5drzva1x8/Photo%2008-06-14%2008%2031%2020%20PM.jpg&quot; alt=&quot;wiring&quot;&gt;&#xA;&lt;img src=&quot;https://dl.dropboxusercontent.com/s/3ugmxr0ddjcpz4x/Photo%2008-06-14%2008%2031%2031%20PM.jpg&quot; alt=&quot;wiring&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2742" OwnerDisplayName="wingleader" LastActivityDate="2015-08-18T14:57:05.923" Title="Arduino LCD shows only black boxes" Tags="|lcd|wires|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2882" PostTypeId="2" ParentId="1475" CreationDate="2014-06-09T02:55:35.027" Score="3" Body="&lt;p&gt;I played around more with it, and this code works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MMA8452::initMMA8452(unsigned char fsr, unsigned char dr, unsigned char sr, unsigned char sc, unsigned char mt, unsigned char mdc)&#xA;{&#xA;    MMA8452Standby();&#xA;&#xA;//Set up the full scale range to 2, 4, or 8g.&#xA;if ((fsr==2)||(fsr==4)||(fsr==8))&#xA;    writeRegister(XYZ_DATA_CFG, fsr &amp;gt;&amp;gt; 2);  &#xA;else&#xA;    writeRegister(XYZ_DATA_CFG, 0);&#xA;&#xA;writeRegister(CTRL_REG1, readRegister(CTRL_REG1) &amp;amp; ~(0xF8));&#xA;if (dr&amp;lt;= 7)&#xA;    writeRegister(CTRL_REG1, readRegister(CTRL_REG1) | (dr &amp;lt;&amp;lt; DR0));&#xA;if (sr&amp;lt;=3)&#xA;    writeRegister(CTRL_REG1, readRegister(CTRL_REG1) | (sr &amp;lt;&amp;lt; ASLP_RATE0));&#xA;&#xA;writeRegister(CTRL_REG2, readRegister(CTRL_REG2) | (LP &amp;lt;&amp;lt; SMODS) | (LP &amp;lt;&amp;lt; MODS) | (1 &amp;lt;&amp;lt; SLPE));  //LOW POWER MODE IN SLEEP &amp;amp; ACTIVE STATES WITH LOWEST SAMPLING&#xA;writeRegister(ASLP_COUNT, sc);&#xA;&#xA;// Set up interrupt 1 and 2: 1 = wake ups, 2 = data&#xA;writeRegister(CTRL_REG3, (1 &amp;lt;&amp;lt; WAKE_FF_MT) | (1 &amp;lt;&amp;lt; IPOL));  // Active high, push-pull interrupts, sleep wake up from motion detection&#xA;writeRegister(CTRL_REG4, (1 &amp;lt;&amp;lt; INT_EN_ASLP) | (1 &amp;lt;&amp;lt; INT_EN_FF_MT) |  (1 &amp;lt;&amp;lt; INT_EN_DRDY));  // DRDY ENABLE SLP/AWAKE INTERRUPT (INTERRUPT THROWN WHENEVER IT CHANGES) &amp;amp; MOTION INTERRUPT TO KEEP AWAKE&#xA;writeRegister(CTRL_REG5, (1 &amp;lt;&amp;lt; INT_CFG_ASLP) | (1 &amp;lt;&amp;lt; INT_CFG_FF_MT));  // DRDY on INT1, ASLP_WAKE INT2, FF INT2&#xA;writeRegister(CTRL_REG5, readRegister(CTRL_REG5));&#xA;&#xA;//SETUP THE MOTION DETECTION&#xA;writeRegister(FF_MT_CFG, 0xF8);     /*MOTION DETECTION AND LATCH THE &#xA;                                    //RESULT WHEN IT HAPPENS AS OPPOSED &#xA;                                    //TO COMBINATIONAL REAL TIME*/&#xA;    writeRegister(FF_MT_THS, mt);       //MOTION DETECTION THRESHOLDS &#xA;    writeRegister(FF_MT_COUNT, mdc);    //TIME MOTION NEEDS TO BE &#xA;                                        //PRESENT ABOVE THE THRESHOLD BEFORE INTERRUPT CAN BE ASSERTED&#xA;&#xA;    MMA8452Active();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2014-06-09T02:55:35.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2883" PostTypeId="1" CreationDate="2014-06-09T03:02:01.727" Score="0" ViewCount="2169" Body="&lt;p&gt;I've just started using Arduino and I need to make a code to simulate the behavior of a lizard, meaning that if you come close to it, it moves away from you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a &quot;Arduino duemilanove&quot; that my university lend me, I was told that it was an alternative version of Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of the servos says &quot;Tower Pro, mg996r, digihi-speed&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking different codes I made one which I think is correct. Also, I checked for each servo motor (I'm using two) and the proximity sensor running codes for everyone of them alone, if they worked well and they did but with this code, they supposed to move when you are closer than a meter but they don't stop spinning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone could help me with this, it would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Servo1 9&#xA;#define Servo2 11&#xA;#define trigPin 10&#xA;#define echoPin A0&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo1;&#xA;Servo servo2;&#xA;&#xA;int pos = 0;    // variable to store the servo position &#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(Servo1, OUTPUT);&#xA;  pinMode(Servo2, OUTPUT);&#xA;  servo1.attach(9);&#xA;  servo2.attach(11);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;  long duracion, distancia; // variables&#xA;&#xA;  /* Hacer el disparo */&#xA;  digitalWrite(10, LOW);  &#xA;  delayMicroseconds(2); &#xA;  digitalWrite(10, HIGH);  // Flanco ascendente&#xA;  delayMicroseconds(10);        // Duracion del pulso&#xA;  digitalWrite(10, LOW);  // Flanco descendente&#xA;&#xA;  /* Recepcion del eco de respuesta */&#xA;  duracion = pulseIn(A0, HIGH);&#xA;&#xA;  /* Calculo de la distancia efectiva */&#xA;  distancia = (duracion/2) / 29.1;&#xA;&#xA;  if (distancia&amp;lt;100){&#xA;    for(pos = 0; pos &amp;lt; 180; pos += 1)  // goes from 0 degrees to 180 degrees &#xA;    {                                  // in steps of 1 degree &#xA;      servo1.write(pos);    // tell servo to go to position in variable 'pos' &#xA;      servo2.write(pos);&#xA;      delay(15);                       // waits 15ms for the servo to reach the                 position &#xA;    } &#xA;    for(pos = 180; pos&amp;gt;=1; pos-=1)     // goes from 180 degrees to 0 degrees &#xA;    {                                &#xA;      servo1.write(pos);              // tell servo to go to position in variable                 'pos' &#xA;      servo2.write(pos);&#xA;      delay(15);                       // waits 15ms for the servo to reach the position &#xA;    } &#xA;&#xA;  }&#xA;  else{ &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1683" LastEditorUserId="37" LastEditDate="2014-06-09T15:29:14.900" LastActivityDate="2014-06-10T20:22:00.867" Title="Problems controlling servos using proximity sensor" Tags="|arduino-uno|sensors|servo|proximity|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2884" PostTypeId="2" ParentId="2881" CreationDate="2014-06-09T13:18:21.197" Score="2" Body="&lt;p&gt;The problem was that the R/W pin on the LCD was left floating, after I connected it to GND, I started working :)&lt;/p&gt;&#xA;" OwnerUserId="2742" LastActivityDate="2014-06-09T13:18:21.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2885" PostTypeId="1" AcceptedAnswerId="2889" CreationDate="2014-06-09T13:25:37.037" Score="1" ViewCount="71" Body="&lt;p&gt;I'm currently using a normal breadbord 'n' solid-core-wires for prototyping, but it gets messy when I need to connect a large number of pins on the arduino, as when using an LCD display + another sensor. What are my other options for prototyping? &lt;/p&gt;&#xA;" OwnerUserId="2742" LastActivityDate="2014-06-09T16:15:04.683" Title="Prototyping method" Tags="|pins|wires|prototype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2886" PostTypeId="2" ParentId="1836" CreationDate="2014-06-09T14:16:37.800" Score="0" Body="&lt;p&gt;I've abandoned all hope and decided that the ADC is just bad.&lt;/p&gt;&#xA;" OwnerUserId="1705" LastActivityDate="2014-06-09T14:16:37.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2887" PostTypeId="1" CreationDate="2014-06-09T15:48:29.143" Score="1" ViewCount="413" Body="&lt;p&gt;I've got two arduino nano devices connected via RF 433 MHz. The modules are MX-05V and MX-FS-03V. I'm using VirtualWire for sending and receiving. The speed is set to 1000 bps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One has got a pir sensor and sends &quot;1:ON&quot; when it detects movement and &quot;1:OFF&quot; when movement stops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other is just receiving these messages, but after a while (20 messages) the text is chopped off. I only receive &quot;1&quot;. If I restart everything the same thing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are currently on my table (cca 20cm distance) and powered by my PC via USB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do? Is it because the modules are from ebay and probably not the best quality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Receive part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// recieve&#xA;&#xA;int ledPin = 13;&#xA;int rcvPin = 13;&#xA;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages&#xA;byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Device is ready&quot;);&#xA;&#xA;  // Initialize the IO and ISR&#xA;  vw_set_rx_pin(rcvPin); // set pin for rx&#xA;  vw_setup(1000); // Bits per sec&#xA;  vw_rx_start(); // Start the receiver&#xA;&#xA;  digitalWrite(ledPin,HIGH);  &#xA;}&#xA;&#xA;void loop() {&#xA;  // non-blocking receive&#xA;  if (vw_get_message(message, &amp;amp;messageLength)) {&#xA;    Serial.print(&quot;Received: &quot;);&#xA;    for (int i = 0; i &amp;lt; messageLength; i++)  {&#xA;      Serial.write(message[i]);&#xA;    }&#xA;    Serial.println();&#xA;    digitalWrite(ledPin, LOW);&#xA;    delay(500);&#xA;    digitalWrite(ledPin,HIGH);  &#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Transmit part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;SimpleSend&#xA;This sketch transmits a short text message using the VirtualWire library&#xA;connect the Transmitter data pin to Arduino pin 12&#xA;pin 11 to high for power&#xA;gnd connected to gnd&#xA;*/&#xA;&#xA;// RF&#xA;int ledPin = 13;&#xA;int trxPin = 12;&#xA;int pwrPin = 11;&#xA;&#xA;// PIR&#xA;int inpPin = 2;               // choose the input pin (for PIR sensor)&#xA;int pirState = LOW;             // we start, assuming no motion detected&#xA;int val = 0;                    // variable for reading the pin status&#xA;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting...&quot;);&#xA;&#xA;  // PIR&#xA;  pinMode(inpPin, INPUT);     // declare sensor as input&#xA;  // RF&#xA;  pinMode(pwrPin, OUTPUT);   // Set digital pin 11 as OUTPUT pins&#xA;  digitalWrite(pwrPin,HIGH);  &#xA;&#xA;  // Initialize the IO and ISR&#xA;  vw_set_tx_pin(trxPin);&#xA;  vw_setup(1000); // Bits per sec&#xA;&#xA;  Serial.println(&quot;Device is ready to send.&quot;);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  val = digitalRead(inpPin);  // read input value&#xA;  if (val == HIGH) {            // check if the input is HIGH&#xA;    digitalWrite(ledPin, HIGH);  // turn LED ON&#xA;    if (pirState == LOW) {&#xA;      // we have just turned on&#xA;      Serial.println(&quot;Motion on seonsor 1!&quot;);&#xA;      send(&quot;1:ON&quot;);&#xA;      // We only want to print on the output change, not state&#xA;      pirState = HIGH;&#xA;    }&#xA;  } else {&#xA;    digitalWrite(ledPin, LOW); // turn LED OFF&#xA;    if (pirState == HIGH){&#xA;      // we have just turned of&#xA;      Serial.println(&quot;Motion ended on seonsor 1&quot;);&#xA;      send(&quot;1:OFF&quot;);&#xA;      // We only want to print on the output change, not state&#xA;      pirState = LOW;&#xA;    }&#xA;  }  &#xA;&#xA;}&#xA;&#xA;void send (char *message)&#xA;{&#xA;  vw_send((uint8_t *)message, strlen(message));&#xA;  vw_wait_tx(); // Wait until the whole message is gone&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2749" LastEditorUserId="220" LastEditDate="2014-06-10T20:35:13.970" LastActivityDate="2014-12-28T07:18:23.653" Title="RF missing characters" Tags="|programming|arduino-nano|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2888" PostTypeId="2" ParentId="2883" CreationDate="2014-06-09T15:59:27.657" Score="0" Body="&lt;p&gt;As an extra tip, from my experience do not power the servos from the same power supply as the sensors. I built a similar project to you and it didn't work as expected. I then powered the servos directly from the battery (6v) and the sensors and arduino from a regulated 5v supply taken from the battery.&#xA;The servos can cause power spikes that mess with the sensor readings.&lt;/p&gt;&#xA;" OwnerUserId="2750" LastActivityDate="2014-06-09T15:59:27.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2889" PostTypeId="2" ParentId="2885" CreationDate="2014-06-09T16:15:04.683" Score="0" Body="&lt;p&gt;One of the Arduino's greatest strengths are shields, and shields upon shields. (Another is it's ease of programming via USB amongst a whole host of others).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are perfect for prototyping. There's nothing wrong with breadboarding it as well, but it's pretty much one or the other (excluding making your own circuit board). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a garage controller and it has three shields on top of the arduino itself.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;XBee/wireless coms&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a relay shield, and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;a prototying shield where I have created custom circuitry (buttons, connectors, optocouplers etc). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Especially with the top shield, I have made several changes to get it to perform as I'd like. If I'd committed to making a custom board, then I would have had to change it (and re-change it). What I've done would be virtually impossible on a breadboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is, you use the shields to get your idea up and running, as a proof of concept. Then, you could/can leave it as is, or you could take the next step, break it down to the required components and make a custom PCB for your project. If it wasn't for shields and stacking shields, you would either breadboard it (which as you've indicated can get ugly, cumbersome and problematic), or make a PCB which (depending on the project) might not be a small task. So shield it up, test it out, then build your own based on what you've put together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not to say, you have to make your own PCB in the end, many projects can remain a shield on an arduino. So if you can find a shield to do specifically what you're after, then why wouldn't you use it? &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-09T16:15:04.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2890" PostTypeId="2" ParentId="2878" CreationDate="2014-06-09T16:48:27.897" Score="0" Body="&lt;p&gt;No, you can't put the teensy bootloader on the UNO. The teensy has an ATMEGA32U4 and the UNO has an ATmega328.  The 32U4 has USB support in hardware the 328 does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UNO does have a ATMEGA16U2 which does have USB in hardware like the 32U4 but it is programmed as a USB serial converter (to replace the FTDI chip used in earlier arduinos).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be possible to install a modified teensy bootloader on the 16U2 but that wouldn't help you because it is not connected to any of the I/O pins on the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case to install new firmware on the 16U2 you would need to buy something that can program the 16U2 via the ICSP and if you are going to buy something you might as well just buy a Leonardo or Teensy since they already support emulating a keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you really wanted to spend the time it might be possible to write your own bootloader for both the 16U2 and the 328 on the UNO in such a way that they emulate a teensy or Leonardo but it won't be easy, and you would be limited by the smaller memory available in the 16U2.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-06-09T16:48:27.897" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2893" PostTypeId="2" ParentId="2878" CreationDate="2014-06-09T17:45:14.430" Score="0" Body="&lt;p&gt;Teensy uses a proprietary boot loader called half K (as in 500 bytes). Doubt one would get the source or image to burn into the 16u2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you can get 8/16u2 USB to HID code examples here: &lt;a href=&quot;https://github.com/harlequin-tech/arduino-usb&quot; rel=&quot;nofollow&quot;&gt;https://github.com/harlequin-tech/arduino-usb&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-06-09T17:45:14.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2894" PostTypeId="2" ParentId="1840" CreationDate="2014-06-09T18:31:59.650" Score="2" Body="&lt;p&gt;It is possible, but it's kind of hard(especially if you want to mod both the 8u2 AND the 16u2. I'd recommend the Teensy(&lt;a href=&quot;https://www.pjrc.com/teensy/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.pjrc.com/teensy/index.html&lt;/a&gt;) I recently posted a question about a question similar to yours and after hearing about all the pitfall I decided to go with the Teensy. I has much richer USB/HID support by default (You can start on your project right away rather than trying to mod the UNO). Teensys are also relatively cheap ranging from $18 to $24. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By comparison, UNOs are $27.18 and are out of stock. To be fair both are probably cheaper used. This is probably moot since it seems you already have one. For more info, see my question (&lt;a href=&quot;https://arduino.stackexchange.com/questions/2878/feasability-of-flashing-arduino-uno-r3-with-teensy-firmware-for-hid-keyboard-e/&quot;&gt;Feasability of flashing Arduino UNO r3 with teensy firmware for HID (keyboard) emulation purposes&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2741" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-06-09T18:31:59.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2895" PostTypeId="1" AcceptedAnswerId="2910" CreationDate="2014-06-10T01:25:39.407" Score="0" ViewCount="238" Body="&lt;p&gt;Look at this snippet of code (from TinyGPS++ library):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(gps.location.lat(), 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It prints the latitude location with 6 decimal points.&#xA;I want, instead of printing that value, to have it assigned to a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But i want it assigned just like above, with six decimal points. Is there a way to do this?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2019-03-09T10:53:19.887" Title="Assigning formatted value to variable" Tags="|variables|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2896" PostTypeId="1" AcceptedAnswerId="2898" CreationDate="2014-06-10T08:48:39.097" Score="5" ViewCount="860" Body="&lt;p&gt;I'm beginning with electronics and don't have all the good reflexes yet. So here is my question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I do what I did here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.movod-design.com/forum_img/canIDoThis.jpg&quot; rel=&quot;noreferrer&quot;&gt;can i do this http://www.movod-design.com/forum_img/canIDoThis.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to add diodes between the Nano +5V and the junction point?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to have one button's state read by 2 Arduino Nano.&lt;/p&gt;&#xA;" OwnerUserId="2758" LastActivityDate="2018-10-11T18:05:32.880" Title="2 Arduino controller boards - 1 shared input" Tags="|arduino-nano|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2898" PostTypeId="2" ParentId="2896" CreationDate="2014-06-10T11:55:59.667" Score="8" Body="&lt;p&gt;You don't need to add anymore components to your schematic. But you can leave some components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before you're adding a button to your schematic please consider first how you want to detect your signal. A logic 1 as if a button is pressed? Or logic 0 as if a button is pressed. You can do this using pull-up and pull-down resistors. These resistors should be wired like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PrGmn.png&quot; alt=&quot;pull resistor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The 100Ohm resistor in an internal resistor from the MCU)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the pull-down resistor means that when the button is pressed you'd get a logic 1.&#xA;Using pull-up resistors means that when the button is pressed you'd get a logic 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I see your schematic it seems like you're trying to make a pushbutton with pull-down resistor. Then you should wire your arduino like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HtNNl.png&quot; alt=&quot;pull-down button&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use the Arduino internal pull-up resistors. That way you don't have to add the 10k resistor in your schematic. And your schematic will look like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uTxT0.png&quot; alt=&quot;internal pull-up&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the internal pull-up resistors from the Arduino you'll need to put this in your setup(): pinMode(pin, INPUT_PULLUP); where pin should be your pin number. Please keep in mind that when you use the internal pull-up resistor a logic 0 means the button is pressed.&lt;/p&gt;&#xA;" OwnerUserId="1532" LastEditorUserId="1532" LastEditDate="2014-06-11T08:46:43.430" LastActivityDate="2014-06-11T08:46:43.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2899" PostTypeId="1" AcceptedAnswerId="2900" CreationDate="2014-06-10T10:01:39.933" Score="5" ViewCount="8091" Body="&lt;p&gt;I am using Arduino GSM Shield receiving SMS from an Android app. And the content of this SMS will control a LED. If the content of this SMS is not &quot;off&quot;, the LED will be on and the content will be printed in the serial monitor. But if it is &quot;off&quot;, the LED will be off immediately. Besides, the LED will keep being on until the &quot;off&quot; message coming. For now, I used the code from the example of the software. But I cannot use the content of this SMS to control the status of LED. With the code below, the LED could not be turned on and the content could not be displayed on the monitor. I think it was because the sketch failed to get the whole content of this SMS. Could anybody tell me how to solve this problem? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;GSM gsmAccess;&#xA;GSM_SMS sms;&#xA;char senderNumber[20];  &#xA;int led=13;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(led,OUTPUT);&#xA;  digitalWrite(led,LOW);&#xA;  while (!Serial) {&#xA;    ;&#xA;  } &#xA;  Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;  boolean notConnected = true;&#xA;  while(notConnected)&#xA;    {&#xA;      if(gsmAccess.begin(&quot;6442&quot;)==GSM_READY)&#xA;        notConnected = false;&#xA;      else&#xA;        {&#xA;          Serial.println(&quot;Not connected&quot;);&#xA;          delay(1000);&#xA;        }&#xA;    }  &#xA;  Serial.println(&quot;GSM initialized&quot;);&#xA;  Serial.println(&quot;Waiting for messages&quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  char c;&#xA;  int val=0;&#xA;  val=digitalRead(led);&#xA;  if (val==HIGH){&#xA;    digitalWrite(led,HIGH);&#xA;  }&#xA;  if (sms.available()){&#xA;    Serial.println(&quot;Message received from:&quot;);&#xA;    sms.remoteNumber(senderNumber, 20);&#xA;    Serial.println(senderNumber);&#xA;&#xA;    if(sms.peek()=='#')&#xA;      {&#xA;        Serial.println(&quot;Discarded SMS&quot;);&#xA;        sms.flush();&#xA;      }&#xA;    while(c=sms.read())   &#xA;      if(c='off'){&#xA;        digitalWrite(led,LOW);&#xA;      }else{&#xA;        digitalWrite(led,HIGH);&#xA;        Serial.print(c);&#xA;      }&#xA;    Serial.println(&quot;\nEND OF MESSAGE&quot;);&#xA;    sms.flush();&#xA;    Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2796" OwnerDisplayName="Zhu" LastEditorUserId="6628" LastEditDate="2016-03-11T22:30:14.277" LastActivityDate="2017-03-05T04:28:53.097" Title="Receiving SMS by Arduino GSM Shield and control the LED with the content of this SMS?" Tags="|led|gsm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2900" PostTypeId="2" ParentId="2899" CreationDate="2014-06-10T11:12:57.077" Score="4" Body="&lt;p&gt;First of all, you have a typo: You need the double-equals operator in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (c == 'off') {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But more importantly, you can't use a &lt;code&gt;char&lt;/code&gt; variable to hold or compare more than one character at a time. I don't know the details of the Arduino GSM library, but if &lt;code&gt;sms.read()&lt;/code&gt; returns a string, then you'll need a string variable or an array of &lt;code&gt;char&lt;/code&gt; to hold the result.&lt;/p&gt;&#xA;" OwnerUserId="614" OwnerDisplayName="Dave Tweed" LastActivityDate="2014-06-10T11:12:57.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2902" PostTypeId="1" CreationDate="2014-06-10T19:19:19.090" Score="1" ViewCount="567" Body="&lt;p&gt;I plan to build a GPS logger for my car using a GPS device, an Arduino board and a SD Card. The plan is that the GPS device forwards the position to the Arduino which is responsible for storing the data on the SD card. However, I would like to regularly (say every hour) send my current position to a server at home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that you can use GPS pusher or puller, but I couldn't find any such devices on the Internet. Do these devices exist? What are my (other) options?&lt;/p&gt;&#xA;" OwnerUserId="2766" LastActivityDate="2017-09-04T05:48:48.230" Title="Are there any GPS data pusher for Arduino?" Tags="|tinygps|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2903" PostTypeId="2" ParentId="2902" CreationDate="2014-06-10T19:51:01.890" Score="2" Body="&lt;p&gt;Check &lt;a href=&quot;https://www.sparkfun.com/products/10039&quot; rel=&quot;nofollow noreferrer&quot;&gt;this shield&lt;/a&gt; out, it sounds almost exactly like what you need, plus it has OBD2 (CAN) access to log RPM, indicated speed, steering wheel angle, and whatever else your car exposes. You can get a GPS module from Sparkfun as well. Matter of fact, I'm using it in a &lt;a href=&quot;https://bitbucket.org/nearwood/carduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;very similar project&lt;/a&gt;, but development is paused until I upgrade to a Mega, since I've run out of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/J6pPW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield comes with example code that's hacked together from other sources but it serves the demo purpose well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for pushing to a server--that'd be tougher. I would go the route of a Bluetooth shield and make a corresponding app for the phone that pushes the data.&lt;/p&gt;&#xA;" OwnerUserId="2767" LastEditorUserId="2767" LastEditDate="2014-06-10T19:57:15.450" LastActivityDate="2014-06-10T19:57:15.450" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2904" PostTypeId="1" CreationDate="2014-06-10T20:08:27.583" Score="0" ViewCount="505" Body="&lt;p&gt;I'm looking for pressure sensors up to 22 kg and more. So far the highest capacity I could found was 25 lbs. Do higher ones not exist?&lt;/p&gt;&#xA;" OwnerUserId="2766" LastActivityDate="2014-06-13T04:45:57.127" Title="Are there any pressure sensor for 22 kg (~50lbs) and more?" Tags="|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2905" PostTypeId="2" ParentId="2883" CreationDate="2014-06-10T20:22:00.867" Score="1" Body="&lt;p&gt;I am new to servos as well, but I do have two coding thoughts. The servos I have used in the past have started in the halfway position. That would mean the &quot;pos&quot; variable would start off trying to go from the starting 90 position to the 0 value in 15ms. Not enough time before the next for loop. I could see that causing some weird spinning while the servos try to get to the intended position. So.. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pos = 90; // Start servo position.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And secondly, the &quot;distancia&quot; could just always be less than 100. I would try finding a max distance value to compare to vs a hard coded value. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {...&#xA;long duracion, distancia; // variables&#xA;boolean isMoveTrigger = false; // Movement trigger.&#xA;&#xA;/* Calculo de la distancia efectiva */&#xA;distancia = (duracion/2) / 29.1;&#xA;&#xA;// Store a maximum value.&#xA;if (distancia &amp;gt; maxDistance) {&#xA;    maxDistance = distancia;&#xA;}&#xA;&#xA;// Wait to get a starting maximum distance value.&#xA;if (countDown &amp;gt; 0) {&#xA;    countDown--;&#xA;} else {&#xA;    if (distancia &amp;gt; 0) {&#xA;      int distancePercentage = (maxDistance * 100) / distancia; // A 0-100 percentage of the maximum value.&#xA;      // Then trigger the movement when less than this percentage.&#xA;      isMoveTrigger = distancePercentage &amp;lt; 50;&#xA;    }&#xA;}&#xA;if (isMoveTrigger) {&#xA;    for(pos = 0; pos &amp;lt; 180; pos += 1) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2768" LastActivityDate="2014-06-10T20:22:00.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2906" PostTypeId="1" CreationDate="2014-06-11T03:36:01.053" Score="0" ViewCount="4790" Body="&lt;p&gt;I'm looking to build an air flow meter that will output in standard liters per minute. The cheapest sensors seems to be a car's Mass Air Flow sensor. I'm wondering if there is a way use  one of these MAF to measure air flow in liters per minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially I need to measure a medical ventilator's air flow in order to calibrate it. The gas flow analyzers that are normally used are way too expensive and offer too many extra features that I don't need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You&lt;/p&gt;&#xA;" OwnerUserId="2769" LastActivityDate="2017-03-25T10:23:04.353" Title="Reading a car mass air flow, volumetric air flow meter" Tags="|sensors|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2909" PostTypeId="1" CreationDate="2014-06-11T15:47:24.710" Score="2" ViewCount="2749" Body="&lt;p&gt;Is there a WiFi Shield or driver that supports monitor mode and receiving raw packets ?&lt;/p&gt;&#xA;" OwnerUserId="2779" LastActivityDate="2014-08-26T17:57:01.147" Title="Arduino Wifi Shield with monitor mode ( promiscuous mode )" Tags="|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2910" PostTypeId="2" ParentId="2895" CreationDate="2014-06-11T17:19:05.603" Score="0" Body="&lt;p&gt;Merely expanding on what ConnorWolf has said (which I saw yesterday), look at the link he gave you, it gives you a run down on the command you're after. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The dtostrf() function returns the pointer to the converted string s.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;char* dtostrf ( double          __val,&#xA;                signed char     __width,&#xA;                unsigned char   __prec,&#xA;                char *          __s &#xA;  )&lt;/code&gt;&lt;br&gt;&#xA;  The dtostrf() function converts the double value passed in val into an ASCII representationthat will be stored under s. The caller is responsible for providing sufficient storage in s.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Conversion is done in the format &quot;[-]d.ddd&quot;. The minimum field width of the output string (including the '.' and the possible sign for negative values) is given in width, and prec determines the number of digits after the decimal sign. width is signed value, negative for left adjustment.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From that, I wrote a short sketch that divides &lt;code&gt;millis()&lt;/code&gt; by 1000 and saves this in a float, we then use this float as a source for &lt;code&gt;dtostrf()&lt;/code&gt; to do it's work and store the result in a char array.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  char c[12];&#xA;  float f = millis()/1000.0;&#xA;  dtostrf(f,11,3,c);&#xA;  Serial.println(c);&#xA;  delay(111);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have picked arbitrary values, you're going to have to do the calculations on the size of the array to create (don't forget the leading negative sign, the digits before the decimal, the decimal and your precision digits &lt;em&gt;as well as the null terminator!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-11T17:19:05.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2911" PostTypeId="1" CreationDate="2014-06-11T17:13:18.050" Score="2" ViewCount="3235" Body="&lt;p&gt;I need to connect a speed sensor module with an Arduino Due and calculate the speed of an approaching object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the sensor is:&#xA;&lt;a href=&quot;http://www.limpkin.fr/index.php?post/2013/08/09/Making-the-electronics-for-a-%247-USD-doppler-motion-sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.limpkin.fr/index.php?post/2013/08/09/Making-the-electronics-for-a-%247-USD-doppler-motion-sensor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor already output a signal that its' frequency represents the speed of the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would really appreciate any help understating how can it be connected and operated by the Arduino without burning it, and how can I sample its output?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If more details are needed I'll be happy to supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;img src=&quot;https://i.stack.imgur.com/bCYgd.jpg&quot; alt=&quot;The module&amp;#39;s connectors&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Shimi Bitton" LastEditorUserId="11" LastEditDate="2014-06-11T20:53:13.660" LastActivityDate="2016-01-29T22:18:59.357" Title="Operating HB100 backpack with Arduino Due" Tags="|sensors|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2912" PostTypeId="1" CreationDate="2014-06-11T17:38:58.130" Score="-1" ViewCount="2219" Body="&lt;p&gt;I found similar type of code in many sites for coverting analog signal lm35 to centigrade.&#xA;But i can't understand that fully. So I need some help what this equation means&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tempC = (5.0 * tempC * 100.0)/1024.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you,&lt;/p&gt;&#xA;" OwnerUserId="670" LastActivityDate="2014-06-11T20:09:01.757" Title="what is the coversion details of temperature usnig lm35?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2913" PostTypeId="1" CreationDate="2014-06-11T17:51:32.260" Score="1" ViewCount="4862" Body="&lt;p&gt;Is it possible to measure the back EMF of a motor, using just the Arduino and no sensors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or what type of sensor do I need? One that measures current?&lt;/p&gt;&#xA;" OwnerUserId="2780" LastEditorUserId="6936" LastEditDate="2016-01-04T19:39:56.353" LastActivityDate="2016-01-04T19:39:56.353" Title="Seeking to measure back EMF of an electric motor via Arduino" Tags="|motor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2914" PostTypeId="2" ParentId="2912" CreationDate="2014-06-11T19:55:41.430" Score="3" Body="&lt;p&gt;I took a quick look at the data sheet for &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm35.pdf&quot; rel=&quot;nofollow&quot;&gt;LM35&lt;/a&gt; and it says that each centigrade means a 10 millivolt change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have an ADC with 10-bit resolution, it means you have 1024 steps from 0 V to 5 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The temperature is then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tempC = 5 * (ADCdata / 1024) * 100&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is equal to your equation. So it seems to be correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more thorough explanation of the formula:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets call the value you read from your LM35 &quot;ADCdata&quot;. The range of this value is determined by the resolution of the Analog-to-Digital Converter (ADC). The ADC converts a voltage to a digital value in the Arduino. This value is again what I refer to here as &quot;ADCdata&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the ADC resolution is 10-bits, it means the 5 volt input can be divided into 1024 equal levels. One level is about 5 millivolts (five thousands of a volt).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find what value &quot;ADCdata&quot; is in volts we need to divide it with the resolution (1024) and multiply with 5 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say we have a 2.5 volt input signal. The ADCdata will then be 512. If we now divide 512 by 1024 we get 0.5. Lets multiply that with 5 volts and we get 2.5 volts!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We know from the data sheet that 10 millivolts equals 1 centigrade. Since we have our value in volts (2.5 V, which is the same as 2500 millivolts) we need to multiply it with 100 to get centigrades.&lt;/p&gt;&#xA;" OwnerUserId="2778" LastEditorUserId="2778" LastEditDate="2014-06-11T20:09:01.757" LastActivityDate="2014-06-11T20:09:01.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2915" PostTypeId="1" AcceptedAnswerId="2916" CreationDate="2014-06-11T23:09:18.197" Score="1" ViewCount="1571" Body="&lt;p&gt;I would like to connect two Arduinos by a serial connection. Is it sufficient to connect TX1&amp;lt;--&gt;RX2 and RX1&amp;lt;--&gt;TX2 or do I also need to connect the GND of the two Arduinos?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2014-06-11T23:57:52.263" Title="Wired serial connection between two Arduinos - do they need a common Ground (GND)?" Tags="|arduino-uno|serial|arduino-due|arduino-nano|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2916" PostTypeId="2" ParentId="2915" CreationDate="2014-06-11T23:57:52.263" Score="2" Body="&lt;p&gt;Short answer: Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rx/Tx is referenced with a logic ground. Without ground being common, there is no way to determine what is high or low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sorry I don't have a more technical explanation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I thought I would add, if you are using the same power source, then they probably have a common ground. In this case, a common power source doesn't mean the wall side of a wall adapter, but the SAME wall adapter. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-11T23:57:52.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2917" PostTypeId="2" ParentId="907" CreationDate="2014-06-12T00:04:03.783" Score="1" Body="&lt;p&gt;It's really down to the manufacturer and what they identify their USB side as. I have found that Arduino(tm) provide a more meaningful (to me) identifier, eg &lt;code&gt;/dev/cu.usbmodemfa131&lt;/code&gt; Whilst the boards that use the FTDI chip have the more serialised numbers &lt;code&gt;/dev/cu.usbserial-A702NY8S&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-12T00:04:03.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2918" PostTypeId="2" ParentId="847" CreationDate="2014-06-12T09:48:21.663" Score="2" Body="&lt;p&gt;The most popular way to establish communication between an Arduino (I've used a Duemilanove) and a BLE module (I've used BLE113 that's on a DKBLE113) is through UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UART is a two wire interface (don't forget the common GND) with one RX and one TX.&#xA;You can use the SoftwareSerial library to define your communication object on the Arduino.&#xA;In contrast, the BLE113 uses four. The additional two are RTS and CTS (Request To Send and Clear To Send).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can configure the UART in two ways using &lt;em&gt;hardware.xml&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to the &amp;lt;&lt;em&gt;usart&lt;/em&gt; &gt; tag and set &lt;em&gt;flow = &quot;false&quot;&lt;/em&gt;. This &quot;disengages&quot; the RTS and CTS allowing a traditional two wire interface.&lt;/li&gt;&#xA;&lt;li&gt;Had you set &lt;em&gt;flow = &quot;true&quot;&lt;/em&gt;, you need to connect the RTS and CTS as well, which I had a big problem with, though the two are both digital.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Further, in &lt;em&gt;hardware.xml&lt;/em&gt;, you need to disable sleep mode by including &amp;lt;&lt;em&gt;sleep enable=&quot;false&quot; /&lt;/em&gt;&gt; within the &amp;lt;&lt;em&gt;hardware&lt;/em&gt;&gt; tag. This will solve all your problems.&#xA;If you intend to use sleep mode, you need to skip the previous step and instead govern the module's mode through the P0_0 pin. Moreover, there are additional definitions to be included in &lt;em&gt;hardware.xml&lt;/em&gt;, which are documented by BG. These work nicely for the BLE112 too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my exercise, I'd established communication at 9600 baud. It worked the same way when I increased it to 115200 baud (this is a plus in the BLE113).&lt;/p&gt;&#xA;" OwnerUserId="2785" LastActivityDate="2014-06-12T09:48:21.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2919" PostTypeId="2" ParentId="1840" CreationDate="2014-06-12T10:19:25.723" Score="2" Body="&lt;p&gt;You don't need to do something magical. Here's how you can use the Arduino IDE's affiliates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you compile or upload a sketch, the &lt;em&gt;.hex&lt;/em&gt; file is automatically created and stored in your computer's drive that has the OS installed (I've found this on Windows). You can access it by navigating to the directory containing temporary files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, the path will be something like this:&#xA;&lt;em&gt;C: &gt; Users &gt; Admin &gt; AppData &gt; Local &gt; Temp&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you'll see (a lot of) directories with names that go like &quot;build&quot;... followed by a big number. One of these directories contains compiler-generated files of the code you're looking for. From this location, you can search (using Windows Explorer, for example) and identify the &lt;em&gt;.hex&lt;/em&gt; file you're looking for by the date and time of last modification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you've got your &lt;em&gt;.hex&lt;/em&gt; file, you can upload it to your Arduino using Atmel FLIP after setting your Arduino's microcontroller to the Device Firmware Upgrade (DFU) mode. Atmel FLIP, an acronym for FLexible In-system Programmer, can be used very easily, thanks to its minimal UI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how to use FLIP:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to &lt;em&gt;File &gt; Load HEX File...&lt;/em&gt; and select the file.&lt;/li&gt;&#xA;&lt;li&gt;Choose your microcontroller by selecting the first icon on the bar.&lt;/li&gt;&#xA;&lt;li&gt;Choose your programming interface from the small list.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've used this with ATXmega that supports USB but it's not the same for all.&lt;/p&gt;&#xA;" OwnerUserId="2785" LastActivityDate="2014-06-12T10:19:25.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2921" PostTypeId="1" AcceptedAnswerId="2925" CreationDate="2014-06-12T17:22:40.060" Score="2" ViewCount="3260" Body="&lt;p&gt;I am trying to build a fan controller for my pc, the problem is that the example code(&lt;a href=&quot;http://playground.arduino.cc/Main/ReadingRPM&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/ReadingRPM&lt;/a&gt;) im using utilizes interrupts. On my uno I can then only read the rpm of one fan. I want to also control the rpm (via pwm) and monitor temperatures (via thermistors) Anyone know how I coud do it differently? I. E. Without interrupts. I would also like it to be as close to real time as possible&lt;/p&gt;&#xA;" OwnerUserId="2789" LastEditorUserId="2789" LastEditDate="2014-06-13T00:51:00.647" LastActivityDate="2014-06-14T18:55:42.407" Title="Reading the rpm of multiple fans" Tags="|arduino-uno|sensors|interrupt|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2922" PostTypeId="1" AcceptedAnswerId="2923" CreationDate="2014-06-12T19:55:13.287" Score="7" ViewCount="15766" Body="&lt;p&gt;I am trying to set up a way to reboot arduino on command. The code below should do that but it seems like my arduino just get's stuck in some sort of a loop where I cant upload or get any serial output. The green led (pin 13) flashes very fast. The only way to stop this is to cut power to the device, even reset button does not work. This happens only when &quot;R&quot; is received via serial or if wdt_reset() function is commented out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;int ledPin = 3;&#xA;&#xA;void setup()&#xA;{&#xA;  MCUSR=0;&#xA;  wdt_disable();&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;BOOT!&quot;);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  digitalWrite(ledPin, LOW);&#xA;  delay(500);&#xA;}&#xA;&#xA;void loop(){&#xA;  if (Serial.available() &amp;gt; 0){&#xA;    char cmd = Serial.read();&#xA;    if (cmd == 'R'){&#xA;      Serial.println(&quot;R received!&quot;);&#xA;      wdt_enable(WDTO_1S);&#xA;      delay(2000);&#xA;      Serial.println(&quot;1 SEC.&quot;);&#xA;    }&#xA;  }&#xA;  wdt_reset();&#xA;  digitalWrite(ledPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="633" LastActivityDate="2018-10-16T13:43:46.323" Title="Watchdog timer stuck in restart loop? (green led flashing)" Tags="|serial|arduino-pro-mini|reset|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2923" PostTypeId="2" ParentId="2922" CreationDate="2014-06-12T21:03:12.493" Score="4" Body="&lt;p&gt;One of the most obvious issues here is that you are enabling the watchdog timer with a delay of 1S and then you are asking the micro controller to sleep for 2S, printing something and then going back into the loop. This, in theory, should be fine(your wdt should trigger a reboot during the 2 second wait) but I've seen it cause issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally some bootloaders(notably the Optiboot bootloader on Uno and newer boards) can have issues with watchdog timers causing the wdt to remain enabled after reset even though the setup loop disables it. To start with - try increasing the wdt time to something greater than 2S(you should be able to do WDTO_8S) and see if the issue persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; - The OP is using an Arduino Pro Mini clone. The included bootloader on the Arduino Pro Mini does not support system restarts by the WDT. Essentially, on a device with a bootloader that does not support WDT restarts, the board will restart but the timer / reset will not causing the board to continuously reset on reboot. There are alternative bootloaders for Arduino boards that may resolve this issue. Another solution is to use a different method to reboot the board.&lt;/p&gt;&#xA;" OwnerUserId="2786" LastEditorUserId="11529" LastEditDate="2018-05-28T15:02:06.170" LastActivityDate="2018-05-28T15:02:06.170" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="2924" PostTypeId="2" ParentId="2904" CreationDate="2014-06-13T04:45:57.127" Score="2" Body="&lt;p&gt;Your problem may be that you are using sub-optimal search terms.&#xA;The kilogram is not a unit of pressure, but instead of mass.&#xA;Scales technically do not sense mass, but instead sense force.&#xA;This is assumed to be the force exerted by a resting body under earth gravity.&#xA;Pressure is force over an area, such as pounds-per-square-inch (PSI) or the Pascal which is a newton per square meter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the sensor you want is called a force cell.&#xA;The nice ones are rated in newtons or kilonewtons, with a kg being equivalent to &#xA;9.8 newtons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a load cell that take up to 50 kg.&#xA;&lt;a href=&quot;http://www.phidgets.com/products.php?product_id=3135&quot; rel=&quot;nofollow&quot;&gt;http://www.phidgets.com/products.php?product_id=3135&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sources:&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Force&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Force&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2794" LastActivityDate="2014-06-13T04:45:57.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2925" PostTypeId="2" ParentId="2921" CreationDate="2014-06-13T05:01:14.253" Score="3" Body="&lt;p&gt;If temperature regulation is what you seek, why bother with the Tachometer signal at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thermistors don't require interrupts. Why do you need fully closed loop fan control? A simple proportional control of each fan and each hot item would likely suffice in keeping your system cool. Noise concerns, perhaps?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://faculty.washington.edu/brengelm/neut_zone/pg4.html&quot; rel=&quot;nofollow&quot;&gt;A brief article on proportional temperature control&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ti.com/lit/ds/sbas386c/sbas386c.pdf&quot; rel=&quot;nofollow&quot;&gt;A data sheet on a TI chip that may have some inspiration for you&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2794" LastEditorUserId="2794" LastEditDate="2014-06-14T00:39:21.820" LastActivityDate="2014-06-14T00:39:21.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2927" PostTypeId="1" CreationDate="2014-06-13T16:37:10.517" Score="1" ViewCount="2488" Body="&lt;p&gt;I am working on building a &quot;simple&quot; HVAC thermostat. This is my current sketch. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // include the libraries for gizmos&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;dht11.h&amp;gt;&#xA;&#xA;dht11 DHT11; // Figure out what this line does&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins&#xA;&#xA;// These constants won't change:&#xA;const int ACledPin = 8;      // Air Conditioner LED (RED)&#xA;const int HTledPin = 9;      // Heat LED (YELLOW)&#xA;const int threshold = 77;    // an arbitrary threshold level that's in the range of the analog input&#xA;&#xA;const int RELAY_01 = 6;    // RELAY 1 PIN 9&#xA;const int RELAY_02 = 10;   // RELAY 2 PIN 10&#xA;&#xA;void setup() {&#xA;  DHT11.attach(7);       // Attach DHT11 sensor to pin 7&#xA;  lcd.begin(16, 2);      // set up the LCD's number of columns and rows:&#xA;  Serial.begin(9600);    // Serial setup&#xA;&#xA;  pinMode(ACledPin, OUTPUT);  // initialize pin 8 as output&#xA;  pinMode(HTledPin, OUTPUT);  // initialize pin 9 as output&#xA;  pinMode(RELAY_01, OUTPUT);  // initialize pin 6 as output&#xA;  pinMode(RELAY_02, OUTPUT);  // initialize pin 10 as output&#xA;&#xA;  // Leaves the relays in default &quot;off&quot; (no noise/click)&#xA;  digitalWrite(RELAY_01, HIGH);&#xA;  digitalWrite(RELAY_02, HIGH);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  float analogValue = (DHT11.fahrenheit()); // trying to set up the temp reading as an int variable&#xA;////////////// if then ////////////////&#xA;// if the analog value is high enough, turn on the LED:&#xA;  if (analogValue &amp;gt; threshold) {&#xA;    digitalWrite(ACledPin, HIGH);&#xA;    digitalWrite(HTledPin, LOW);&#xA;    digitalWrite(RELAY_01, HIGH);&#xA;    digitalWrite(RELAY_02, LOW);&#xA;  }&#xA;  else {&#xA;    digitalWrite(ACledPin, LOW);&#xA;    digitalWrite(HTledPin, HIGH);&#xA;    digitalWrite(RELAY_01, LOW);&#xA;    digitalWrite(RELAY_02, HIGH);&#xA;  }&#xA;&#xA;&#xA;Serial.println(analogValue);  // print the analog value:&#xA;&#xA;// Set up the LCD Stuff&#xA;  lcd.setCursor(0, 0);      // Set cursor to top left&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(analogValue, 1);&#xA;  lcd.print(&quot;F&quot;);&#xA;&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to add &quot;smoothing&quot; to the temperature reading. I Found this tutorial &lt;a href=&quot;http://arduino.cc/en/Tutorial/Smoothing&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/Smoothing&lt;/a&gt; and have it working the way I want it. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Define the number of samples to keep track of.  The higher the number,&#xA;// the more the readings will be smoothed, but the slower the output will&#xA;// respond to the input.  Using a constant rather than a normal variable lets&#xA;// use this value to determine the size of the readings array.&#xA;#include &amp;lt;dht11.h&amp;gt;&#xA;dht11 DHT11; // Figure out what this line does&#xA;&#xA;const int numReadings = 5;&#xA;&#xA;float readings[numReadings];      // the readings from the analog input&#xA;int index = 0;                    // the index of the current reading&#xA;float total = 0;                  // the running total&#xA;float average = 0;                // the average&#xA;&#xA;void setup()&#xA;{&#xA;  DHT11.attach(7);       // Attach DHT11 sensor to pin 7&#xA;  Serial.begin(9600);    // initialize serial communication with computer:&#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++) readings[thisReading] = 0; // initialize all the readings to 0:       &#xA;}&#xA;&#xA;void loop() {&#xA;  // subtract the last reading:&#xA;  total= total - readings[index];         &#xA;  // read from the sensor:  &#xA;  readings[index] = (DHT11.fahrenheit()); //analogRead(inputPin); &#xA;  // add the reading to the total:&#xA;  total= total + readings[index];       &#xA;  // advance to the next position in the array:  &#xA;  index = index + 1;                    &#xA;&#xA;  // if we're at the end of the array...&#xA;  if (index &amp;gt;= numReadings)              &#xA;    // ...wrap around to the beginning: &#xA;    index = 0;                           &#xA;&#xA;  // calculate the average:&#xA;  average = total / numReadings;         &#xA;  // send it to the computer as ASCII digits&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.print(&quot;Realtime: &quot;);&#xA;  Serial.println(DHT11.fahrenheit(),2);&#xA;  Serial.print(&quot;Average:  &quot;);&#xA;  Serial.println(average);   &#xA;  delay(2000);        // delay in between reads for stability            &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm new to Arduino and don't know the best way to do this. I'm not certain how to do multiple loops/delays in a single project, or if I even need to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've ended up with this based on the comments from @Craig. The only thing that needs some adjustment are the first 4 readings are low, so it would be nice to somehow ignore, probably not a big deal in the long run. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example readings on startup;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Realtime: 77.00&#xA;Average:  15.40&#xA;&#xA;Realtime: 77.00&#xA;Average:  30.80&#xA;&#xA;Realtime: 77.00&#xA;Average:  46.20&#xA;&#xA;Realtime: 77.00&#xA;Average:  61.60&#xA;&#xA;Realtime: 77.00&#xA;Average:  77.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Final code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the libraries for gizmos&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;dht11.h&amp;gt;&#xA;&#xA;dht11 DHT11; // Figure out what this line does&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins&#xA;&#xA;// These constants won't change:&#xA;const int ACledPin = 8;      // Air Conditioner LED (RED)&#xA;const int HTledPin = 9;      // Heat LED (YELLOW)&#xA;const int threshold = 77;    // an arbitrary threshold level that's in the range of the analog input&#xA;&#xA;const int RELAY_01 = 6;    // RELAY 1 PIN 9&#xA;const int RELAY_02 = 10;   // RELAY 2 PIN 10&#xA;&#xA;&#xA;&#xA;// START ADDITIONS ////////////////////////////////////////////////////////////////////////////////////////////////&#xA;const int numReadings = 5;&#xA;float readings[numReadings];      // the readings from the analog input&#xA;int index = 0;                    // the index of the current reading&#xA;float total = 0;                  // the running total&#xA;&#xA;&#xA;float get_smoothed_temp() {&#xA;    total = total - readings[index]; // remove oldest reading&#xA;    readings[index] = DHT11.fahrenheit();&#xA;    total += readings[index];&#xA;    index = (index + 1) % numReadings;&#xA;&#xA;    return (total / numReadings);&#xA;}&#xA;// END ADDITIONS ////////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;void setup() {&#xA;  DHT11.attach(7);       // Attach DHT11 sensor to pin 7&#xA;  lcd.begin(16, 2);      // set up the LCD's number of columns and rows:&#xA;  Serial.begin(9600);    // Serial setup&#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++) readings[thisReading] = 0; // initialize all the readings to 0:&#xA;&#xA;  pinMode(ACledPin, OUTPUT);  // initialize pin 8 as output&#xA;  pinMode(HTledPin, OUTPUT);  // initialize pin 9 as output&#xA;  pinMode(RELAY_01, OUTPUT);  // initialize pin 6 as output&#xA;  pinMode(RELAY_02, OUTPUT);  // initialize pin 10 as output&#xA;&#xA;  // Leaves the relays in default &quot;off&quot; (no noise/click)&#xA;  digitalWrite(RELAY_01, HIGH);&#xA;  digitalWrite(RELAY_02, HIGH);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  float analogValue = (get_smoothed_temp()); // trying to set up the temp reading as an int variable&#xA;////////////// if then ////////////////&#xA;// if the analog value is high enough, turn on the LED:&#xA;  if (analogValue &amp;gt; threshold) {&#xA;    digitalWrite(ACledPin, HIGH);&#xA;    digitalWrite(HTledPin, LOW);&#xA;    digitalWrite(RELAY_01, HIGH);&#xA;    digitalWrite(RELAY_02, LOW);&#xA;  }&#xA;  else {&#xA;    digitalWrite(ACledPin, LOW);&#xA;    digitalWrite(HTledPin, HIGH);&#xA;    digitalWrite(RELAY_01, LOW);&#xA;    digitalWrite(RELAY_02, HIGH);&#xA;  }&#xA;&#xA;&#xA;Serial.println(analogValue);  // print the analog value:&#xA;&#xA;// Set up the LCD Stuff&#xA;  lcd.setCursor(0, 0);      // Set cursor to top left&#xA;  lcd.print(&quot;Real F:&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;AVG  F:&quot;);&#xA;  lcd.print(analogValue, 1);&#xA;&#xA;&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2793" LastEditorUserId="2793" LastEditDate="2014-06-14T17:41:21.447" LastActivityDate="2014-06-15T20:07:02.893" Title="How to integrate smoothing into project (HVAC thermostat / controller)" Tags="|programming|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2929" PostTypeId="2" ParentId="2927" CreationDate="2014-06-13T20:15:04.077" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm not certain how to do multiple loops/delays in a single project&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;can't&lt;/em&gt; do this.* &lt;a href=&quot;https://arduino.stackexchange.com/questions/286/how-can-i-create-multiple-running-threads&quot;&gt;Software threading&lt;/a&gt; is the only way to do something like what you want, but it's too complex for what you need. What you want is to use the &lt;code&gt;millis()&lt;/code&gt; function to return the time and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// constants won't change. Used here to &#xA;// set pin numbers:&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// Variables will change:&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;&#xA;// the follow variables is a long because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;void setup() {&#xA;  // set the digital pin as output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // here is where you'd put code that needs to be running all the time.&#xA;&#xA;  // check to see if it's time to blink the LED; that is, if the &#xA;  // difference between the current time and last time you blinked &#xA;  // the LED is bigger than the interval at which you want to &#xA;  // blink the LED.&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then pull button changes while you wait for a new reading. Another way would be to use an &lt;em&gt;interrupt&lt;/em&gt; to interrupt the flow of the program when a button changes. I won't get into that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your use, you can use this template I made:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long previousMillis = 0;        // will store last time temp was updated&#xA;long interval = 1000;           // interval at which to check the temp (milliseconds)&#xA;&#xA;void setup() {&#xA;  //Foobar&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Bar of foo&#xA;  unsigned long currentMillis = millis();&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    previousMillis = currentMillis;   &#xA;    //Check Temp&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;*&lt;sub&gt;Not to be confused with the &lt;code&gt;loop&lt;/code&gt; statement.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-06-13T20:15:04.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2930" PostTypeId="2" ParentId="2927" CreationDate="2014-06-13T21:30:37.633" Score="3" Body="&lt;p&gt;What you want to do is replace your call to &lt;code&gt;DHT11.fahrenheit()&lt;/code&gt; with a call to a new function (e.g. get_smoothed_temp()) that keeps track of the last several readings and returns the smoothed value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int numReadings = 5;&#xA;float readings[numReadings];      // the readings from the analog input&#xA;int index = 0;                    // the index of the current reading&#xA;float total = 0;                  // the running total&#xA;&#xA;float get_smoothed_temp() {&#xA;    total = total - readings[index]; // remove oldest reading&#xA;    readings[index] = DHT11.fahrenheit();&#xA;    total += readings[index];&#xA;    index = (index + 1) % numReadings;&#xA;&#xA;    return (total / numReadings);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will still need to set the readings array to all zeros in the setup function.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-06-13T21:30:37.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2931" PostTypeId="1" AcceptedAnswerId="14540" CreationDate="2014-06-13T22:24:39.383" Score="-2" ViewCount="861" Body="&lt;p&gt;I have a broken Arduino Uno. The man tells that he connected power supply and USB at the same time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the new 16u2 (empty) chip. then asked my friend to re-solder it. He was using an air soldering station, but that did not work out. Then I try do that by myself. After 6 or 8 time I was successful. I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With stk500v2 programmer thru ICSP I burned in the hardware called:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I found in Arduino &quot;hardware&quot; folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then burned bootloader to 328p controller:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;optiboot_atmega328.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That hardware also from Arduino folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can upload sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;meaning that device not recognizing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My PC founds Arduino in device manager. 328p with ICSP programmable and working. (checked with blinking.hex 13 pin)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When pressing reset button the 13 led turns of then blinks fast several times that means the boot loader installed property.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right after pressing upload the Rx blinks 3 times after that I am getting error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strange isn't it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I what to know:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I suppose the first must start blinking Tx led?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can anyone show me how must look like rxd txd interrupts?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;So about my assumption that I overheated 16u2 and it does strange things. What are you thinking about that?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1309" LastEditorUserId="10794" LastEditDate="2015-08-26T03:24:49.223" LastActivityDate="2016-01-23T09:13:52.830" Title="How does RXD/TXD request signal look betwen 16u2 and 328p on oscilloscope?" Tags="|arduino-uno|atmega328|bootloader|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="2932" PostTypeId="1" AcceptedAnswerId="2933" CreationDate="2014-06-14T10:32:30.563" Score="5" ViewCount="635" Body="&lt;p&gt;I would like to set up a project with an ATtiny chip, such as the ATtiny84 or ATtiny85, in which I interface the microcontroller directly with an XBee for both wireless serial communication, as well as monitoring a digital signal from the Xbee (digital input to the ATtiny). As the Xbee chips can handle only 3.3V and will be damaged at higher voltages (such as 5V), I was wondering whether I can simply power the entire project at 3.3V so that all digital inputs and outputs will be at that voltage?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-03-09T18:30:23.223" Title="Operating / pin voltages ATTiny chips" Tags="|xbee|voltage-level|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2933" PostTypeId="2" ParentId="2932" CreationDate="2014-06-14T12:40:40.410" Score="5" Body="&lt;p&gt;Yes.  As given in the &lt;a href=&quot;http://www.atmel.com/devices/ATTINY85.aspx&quot; rel=&quot;nofollow&quot;&gt;datasheets&lt;/a&gt;, normal ATtinyX4/X5 chips can run with a supply between 2.7 and 5.5V inclusive, whereas the low-power versions can run between 1.8V and 5.5V. Mind the speed restrictions when running at lower voltages though; see the &quot;Electrical Characteristics&quot; section of each datasheet to determine the maximum characterized speed for a given voltage.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="4951" LastEditDate="2015-03-09T18:30:23.223" LastActivityDate="2015-03-09T18:30:23.223" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2934" PostTypeId="2" ParentId="2927" CreationDate="2014-06-14T16:18:14.210" Score="2" Body="&lt;p&gt;I've just done a fan controller (using digital sensors - DS18b20, in my case) and chose an exponential average for smoothing the readings because it doesn't require storing or managing old data and I could get the smoothing I needed. During setup I took a reading from each sensor and preset the averages to those values. That gives the system a &quot;running start&quot;; it doesn't need to wait for enough samples for the averages to settle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exponential average I chose was &lt;code&gt;(3 * oldAverage + tempr)/4&lt;/code&gt; because it gave the performance I needed and is easy and fast to calculate without floating point. Multiplying by 3 is done by shifting and adding; dividing by 4 is done by shifting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the routine I used. It could easily be put in-line; the compiler probably will:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int16_t xpavg(int16_t tempr, int16_t oldAverage)&#xA;{&#xA;   // (3*oldavg + 1*tempr)/4&#xA;   return( (((oldAverage&amp;lt;&amp;lt;1) + oldAverage + tempr) + 2) &amp;gt;&amp;gt; 2 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-06-15T20:07:02.893" LastActivityDate="2014-06-15T20:07:02.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2935" PostTypeId="2" ParentId="2921" CreationDate="2014-06-14T18:55:42.407" Score="0" Body="&lt;p&gt;If you only want 2 fans, the uno has 2 external interrupts, so you can use the same strategy as your example, just make another interrupt function for fan 2 and attach it on interrupt 1 instead of 0. the fan should be plugged in to pin 3 in this case. On a leonardo, you could have 5 fans on interrupts, and a mega has 6 external interrupts. See &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/attachInterrupt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need more than what your hardware can support, I would look into using a timed interrupt to check all the fans. If you find the minimum amount of time in-between reads to read your fans at max RPM and then use a timer interrupt to check some pins at that interval, you can probably read as many as you need, provided the interrupt routine stays fast enough. the function &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(function, period);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the libraries on this page : &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Timer1&lt;/a&gt;&#xA;should help you out with this.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-14T18:55:42.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2936" PostTypeId="2" ParentId="2913" CreationDate="2014-06-14T19:04:27.307" Score="1" Body="&lt;p&gt;You will need at least an external current sensor, the arduino has no way of measuring current built in. You will also need to measure the winding resistance of the motor beforehand. look to this answer for a good explanation:&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/54997/how-can-i-measure-back-emf-to-infer-the-speed-of-a-dc-motor&quot;&gt;https://electronics.stackexchange.com/questions/54997/how-can-i-measure-back-emf-to-infer-the-speed-of-a-dc-motor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DC current sensors compatible with arduino should not be hard to find; just search one of the standard hobby electronics components sites.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-14T19:04:27.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2937" PostTypeId="2" ParentId="2922" CreationDate="2014-06-14T21:51:53.103" Score="-1" Body="&lt;p&gt;You can restart the Arduino with this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;asm volatile (&quot;  jmp 0&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-06-14T21:51:53.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2938" PostTypeId="1" CreationDate="2014-06-15T08:08:46.500" Score="1" ViewCount="666" Body="&lt;p&gt;I thought this would be easy but how wrong I am... All I want to do is plot temperature data but I can't seem to get it to work. It reads it out on the serial monitor and says it has sent the data (in the serial monitor) but nothing on the Xively plots! Why?? Below is the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the API key and feedID from the Xively site. The useragent I'm assuming is the name of the project. My channels are called &lt;code&gt;sensorValue1&lt;/code&gt; and &lt;code&gt;sensorValue2&lt;/code&gt;. Please help - this is taking me far too long.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;Console.h&amp;gt;&#xA;#include &amp;lt;Process.h&amp;gt;&#xA;&#xA;#include &quot;DHT.h&quot;&#xA;#define DHTPIN 0&#xA;#define DHTTYPE DHT11&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA; #define APIKEY &quot;BLablablablabla&quot; // your pachube API key &#xA; #define FEEDID blablabla // your feed ID&#xA; #define USERAGENT &quot;SebYun2&quot; // user agent is the project name&#xA;&#xA;// set up net client info:&#xA;const unsigned long postingInterval = 60000; //delay between updates to xively.com&#xA;unsigned long lastRequest = 0; // when you last made a request&#xA;String dataString = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;  // start serial port:&#xA;  Bridge.begin();&#xA;  Serial.begin(9600);&#xA;  dht.begin();&#xA;  while(!Serial); // wait for Network Serial to open&#xA;  Serial.println(&quot;Xively client&quot;);&#xA;  // Do a first update immediately&#xA;  updateData();&#xA;  sendData();&#xA;  lastRequest = millis();&#xA;}&#xA;&#xA;void loop() {&#xA;  // get a timestamp so you can calculate reading and sending intervals:&#xA;  long now = millis();&#xA;  // if the sending interval has passed since your&#xA;  // last connection, then connect again and send data:&#xA;  if (now - lastRequest &amp;gt;= postingInterval) {&#xA;    updateData();&#xA;    sendData();&#xA;    lastRequest = now;&#xA;  }&#xA;}&#xA;&#xA;void updateData() {&#xA;  // convert the readings to a String to send it:   &#xA;  // Reading temperature or humidity takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  dataString = &quot;Temperature,&quot;;&#xA;  dataString += dht.readTemperature(false);&#xA;  delay(250);&#xA;  // add pressure:&#xA;  dataString += &quot;\nHumidity,&quot;;&#xA;  dataString += dht.readHumidity();&#xA;  int sensorValue1 =  analogRead(A0);&#xA;  delay(100);&#xA;  int sensorValue2 =  analogRead(A0);&#xA;  dataString += &quot;\nVoltage1,&quot;;&#xA;  dataString += sensorValue1*0.0049;&#xA;  Serial.print(sensorValue1);&#xA;  dataString += &quot;\nVoltage2,&quot;;&#xA;  Serial.print(sensorValue2);&#xA;  dataString += sensorValue2*0.0049;&#xA;  delay(1000);&#xA;}&#xA;&#xA;// this method makes a HTTP connection to the server:&#xA;void sendData() {&#xA;  // form the string for the API header parameter:&#xA;  String apiString = &quot;X-ApiKey: &quot;;&#xA;  apiString += APIKEY;&#xA;  // form the string for the URL parameter:&#xA;  String url = &quot;https://api.xively.com/v2/feeds/&quot;;&#xA;  url += FEEDID;&#xA;  url += &quot;.csv&quot;;&#xA;  // Send the HTTP PUT request&#xA;  // It is better to declare the Process here, so when the&#xA;  // sendData function finishes the resources are immediately&#xA;  // released. Declaring it global works too, BTW.&#xA;  Process xively;&#xA;  Serial.print(&quot;\n\nSending data... &quot;);&#xA;  xively.begin(&quot;curl&quot;);&#xA;  xively.addParameter(&quot;-k&quot;);&#xA;  xively.addParameter(&quot;--request&quot;);&#xA;  xively.addParameter(&quot;PUT&quot;);&#xA;  xively.addParameter(&quot;--data&quot;);&#xA;  xively.addParameter(dataString);&#xA;  xively.addParameter(&quot;--header&quot;);&#xA;  xively.addParameter(apiString); &#xA;  xively.addParameter(url);&#xA;  xively.run();&#xA;  Serial.println(&quot;done!&quot;);&#xA;  // If there's incoming data from the net connection,&#xA;  // send it out the Serial:&#xA;  while (xively.available()&amp;gt;0) {&#xA;    char c = xively.read();&#xA;    Serial.write(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2810" LastEditorUserId="4628" LastEditDate="2015-01-04T20:27:01.180" LastActivityDate="2015-01-04T20:27:01.180" Title="Can't send DHT11 temperature data to Xively from Yun" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2939" PostTypeId="1" AcceptedAnswerId="2955" CreationDate="2014-06-15T10:38:36.537" Score="3" ViewCount="2625" Body="&lt;p&gt;I am trying to blink an LED with PWM on Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what is wrong but my LED is not fading as expected. What is wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that I have bad registers settings, but I am not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED is connected to Arduino pin 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;const int delay=1000; &#xA;void initialize_PWM()&#xA;{&#xA;    TCCR0A|=(1&amp;lt;&amp;lt;WGM00)|(1&amp;lt;&amp;lt;WGM01)|(1&amp;lt;&amp;lt;COM0A1);&#xA;    TCCR0B=1;&#xA;    DDRB|=(1&amp;lt;&amp;lt;PB1); &#xA;}&#xA;&#xA;void set_pwm(uint8_t data)&#xA;{&#xA;    OCR0A=data;&#xA;}&#xA;&#xA;int main (void)&#xA;{&#xA;    initialize_PWM();&#xA;    uint8_t brightness=200;&#xA;    while(1)&#xA;    {&#xA;        for(brightness=0;brightness&amp;lt;255;brightness++)&#xA;        {&#xA;            set_pwm(brightness);&#xA;            _delay_ms(1);&#xA;        }&#xA;&#xA;        for(brightness=255;brightness&amp;gt;0;brightness--)&#xA;        {&#xA;            set_pwm(brightness);&#xA;            _delay_ms(1);&#xA;        }&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2811" LastEditorUserId="84" LastEditDate="2014-06-15T13:07:36.180" LastActivityDate="2014-06-17T15:20:07.063" Title="Arduino PWM fading led" Tags="|arduino-uno|led|pwm|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2940" PostTypeId="1" AcceptedAnswerId="2944" CreationDate="2014-06-15T11:23:22.690" Score="7" ViewCount="14418" Body="&lt;p&gt;My idea seems easy: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connect a button with arduino, then write some code and upload it to arduino. Then I open the notepad(or any other editor) on my computer. When I press the button, there will be a character &quot;A&quot; displayed in the notepad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried with my Arduino uno, and use &lt;code&gt;Serial.write/print&lt;/code&gt; function to send an &lt;code&gt;A&lt;/code&gt; to serial port &lt;code&gt;9600&lt;/code&gt;, but it seems the character &lt;code&gt;A&lt;/code&gt; only shows in the serial monitor GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is &quot;Arduino uno&quot; is OK to implement this?&lt;/li&gt;&#xA;&lt;li&gt;If not, what other board should I use?&lt;/li&gt;&#xA;&lt;li&gt;Is &lt;code&gt;Serial.write/print&lt;/code&gt; the correct function?&lt;/li&gt;&#xA;&lt;li&gt;Or shall I use the &lt;code&gt;Keyboard.???&lt;/code&gt; function?&lt;/li&gt;&#xA;&lt;li&gt;Do I have to write an application which runs on the computer and listens the serial port, and emit a real key event? (that's sad)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1685" LastEditorUserId="1685" LastEditDate="2014-06-15T12:10:44.507" LastActivityDate="2018-03-12T23:27:44.670" Title="Is it possible to press a button from Arduino and my computer will get a key event?" Tags="|arduino-uno|serial|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2941" PostTypeId="2" ParentId="2940" CreationDate="2014-06-15T12:43:17.863" Score="1" Body="&lt;p&gt;Your example describes collecting text - does that meet your goal or do you need to generate any kind of key-event? If you don't need to generate system events, any terminal emulator (not just the Arduino IDE) should be able listen to that same port and to log whatever it receives to a file.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-15T12:43:17.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2942" PostTypeId="2" ParentId="2940" CreationDate="2014-06-15T14:21:03.247" Score="-1" Body="&lt;p&gt;I think you also need to install &lt;code&gt;processing&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://processing.org/&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It enables you to program the computer-side of the application.&lt;/p&gt;&#xA;" OwnerUserId="2812" LastActivityDate="2014-06-15T14:21:03.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2944" PostTypeId="2" ParentId="2940" CreationDate="2014-06-15T15:46:28.707" Score="9" Body="&lt;p&gt;The Uno is not the best board for this. You may be able to get somewhere with the &lt;a href=&quot;http://practicalarduino.com/projects/virtual-usb-keyboard&quot;&gt;Virtual USB&lt;/a&gt; project but there are a couple of boards that are better suited for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those are the Arduino Leonardo, Micro, and Due. In those, you can use the &lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard&quot;&gt;Keyboard Library&lt;/a&gt; just like you are using the Serial library now. &lt;a href=&quot;http://arduino.cc/en/Reference/KeyboardPrint&quot;&gt;This page&lt;/a&gt; has an example very similar to your project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // make pin 2 an input and turn on the &#xA;  // pullup resistor so it goes high unless&#xA;  // connected to ground:&#xA;  pinMode(2, INPUT_PULLUP);&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  //if the button is pressed&#xA;  if(digitalRead(2)==LOW){&#xA;    //Send the message&#xA;    Keyboard.print(&quot;Hello!&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-06-15T15:46:28.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2945" PostTypeId="2" ParentId="2927" CreationDate="2014-06-15T16:47:45.993" Score="3" Body="&lt;p&gt;Your running average code is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick way to start up fast is to take your first reading in setup, and fill the array with that value instead of zero.  That way you always get a reasonable temperature from the smoothing, it just gradually drifts from the first reading to the average of multiple readings  (rather than from 0 - a bogus value - to the that average).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can work for the exponential smoothing too (old average = first reading).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to only average as many samples as you have put into the array (1 then 2, then 3 etc until it's filled).  That takes extra code to handle just the first few results, tho, and the simpler approach suggested above (initially fill the array with a legitimate reading) is usually fine.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-06-15T16:47:45.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2946" PostTypeId="1" AcceptedAnswerId="3309" CreationDate="2014-06-15T18:25:51.253" Score="9" ViewCount="32287" Body="&lt;p&gt;I am looking through the example code found &lt;a href=&quot;https://github.com/maniacbug/RF24/blob/master/examples/GettingStarted/GettingStarted.pde&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I know there are 6 pipes that the nRF24L01 module can use but I've been searching the internet for the address designations and have been able to find nothing. More specifically on line 37, is there a reference for where the author is getting 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2815" LastEditorUserId="653" LastEditDate="2017-12-18T21:31:25.170" LastActivityDate="2018-09-15T11:35:25.027" Title="nRF24L01 pipe question" Tags="|arduino-uno|nrf24l01+|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="2947" PostTypeId="1" CreationDate="2014-06-15T19:05:17.067" Score="2" ViewCount="231" Body="&lt;p&gt;I connected the output from an encoder motor to int0. this is used to increment a counter at every pulse. in the loop(), I check this counter and stops the motor if it is above certain value. But this &quot;if statement&quot; works erratically. The while loop should break at 380, but sometimes it breaks at 256. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(cnt);&#xA;cnt=0;&#xA;Serial.print(&quot;  &quot;);&#xA;Serial.print(cnt);&#xA;motor1_up(255);&#xA;motor2_up(255);&#xA;while(1)&#xA;{&#xA;    if(cnt&amp;gt;380)&#xA;    {&#xA;        Serial.print(&quot; break &quot;);&#xA;        Serial.print(cnt);&#xA;        break;&#xA;    }&#xA;}&#xA;motor1_down(255);&#xA;motor2_down(255);&#xA;Serial.print(&quot;  &quot;);&#xA;delay(40);&#xA;Serial.println(cnt);&#xA;motor1_down(0);&#xA;motor2_down(0);&#xA;delay(2000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the serial output &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1  0 break 381  389&#xA; 396  0 break 256  264&#xA; 271  0 break 381  389&#xA; 396  0 break 381  389&#xA; 396  0 break 256  264&#xA; 270  0 break 381  389&#xA; 397  0 break 381  390&#xA; 396  0 break 381  389&#xA; 397  0 break 381  389&#xA; 396  0 break 256  264&#xA; 271  0 break 381  389&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2816" LastEditorUserId="11" LastEditDate="2014-06-24T16:08:21.357" LastActivityDate="2014-06-24T16:08:21.357" Title="If statement behaves erratically" Tags="|rotary-encoder|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2949" PostTypeId="2" ParentId="2947" CreationDate="2014-06-15T19:59:23.980" Score="2" Body="&lt;p&gt;It looks like it could be a caching issue. If you're accessing a variable from the main loop &lt;em&gt;and&lt;/em&gt; from an interrupt handler, then you need to ensure it's declared as &lt;code&gt;volatile&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cnt = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That tells the compiler that the contents of the variable could change unexpectedly, i.e. when an Interrupt Service Routine is triggered. The result is that it always fetches the actual value from RAM, instead of relying on a cached copy which could be out-of-date.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-15T19:59:23.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2950" PostTypeId="1" CreationDate="2014-06-15T17:16:17.743" Score="0" ViewCount="1462" Body="&lt;p&gt;I would like to connect arduino mini pro to mini jack output and send sound through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would I need here, how can I connect the mini jack to arduino and how to send data of sounds (any library?) to that connected output?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sound source will be a music file ( streamed via bluetooth). I would like to be able to connect this output to a speaker and play (stream) music via bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either mono or stereo will be good for me. My plan is to: stream the music via bluetooth to bluetooth module (for now I think about HC-06), send that data stream through arduino mini pro to the output mini jack. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need in that case some kind of mp3/other format decoder module like &lt;a href=&quot;http://www.ebay.com/itm/VS1003B-MP3-Decoder-Module-Development-Board-STM32-Contains-Microphone-/121315052297?pt=LH_DefaultDomain_0&amp;amp;hash=item1c3ef0cb09&quot; rel=&quot;nofollow&quot;&gt;VS1003B on ebay&lt;/a&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="2813" OwnerDisplayName="Patryk" LastEditorUserId="42" LastEditDate="2015-04-10T16:18:30.513" LastActivityDate="2019-12-17T17:03:30.440" Title="How to connect mini jack output to arduino mini pro and send sound to it?" Tags="|bluetooth|audio|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="2951" PostTypeId="2" ParentId="2939" CreationDate="2014-06-15T20:24:35.557" Score="1" Body="&lt;p&gt;It's much too soon to optimize. Get your LED working using the standard (known working) libraries. Only then - and perhaps never, unless you find a need to - should your optimize (use direct register I/O). If it works with the libraries but not with your direct I/O, you'll know the bug lies in the direct I/O code and nowhere else, ruling out failed hardware, improper or unreliable connections, and programming errors elsewhere in your project. Right now, you don't know even that much.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-15T20:24:35.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2952" PostTypeId="1" CreationDate="2014-06-15T20:39:48.203" Score="-5" ViewCount="93" Body="&lt;p&gt;I'm thinking about using an Arduino for one of my Projekts. This would require that the Arduino can read/write a digital input/output in the order of 100kHZ to 1MHz. Is this possible or do I have to resort to my own boards using ATmegas?&lt;/p&gt;&#xA;" OwnerUserId="2817" LastActivityDate="2014-06-15T22:52:00.080" Title="Reading speed of different arduinos" Tags="|arduino-uno|arduino-due|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2953" PostTypeId="2" ParentId="2952" CreationDate="2014-06-15T21:21:15.073" Score="0" Body="&lt;p&gt;Any Arduino will do just fine. Technically, you could output 8 digital signals simultaneously at the Arduino's clock speed (16 MHz on most models), as it only takes one clock cycle to flip an output bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In more realistic scenarios 100kHz is no problem at all, and depending on your code 1MHz is possible as well.&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-06-15T21:21:15.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2954" PostTypeId="2" ParentId="2952" CreationDate="2014-06-15T22:52:00.080" Score="1" Body="&lt;p&gt;Focussing on your final question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this possible or do I have to resort to my own boards using ATmegas?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Remember, an Arduino is already just an ATMega already on a board. Designing your own board around an ATMega that is already part of the Arduino family is not going to significantly alter your project. That is unless you are going to have supplementing hardware, or go via higher clock speeds or ARM processing.  &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-15T22:52:00.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2955" PostTypeId="2" ParentId="2939" CreationDate="2014-06-15T23:16:34.910" Score="5" Body="&lt;p&gt;From your code you are using &lt;strong&gt;Timer0&lt;/strong&gt; in &lt;strong&gt;FastPWM mode with top = 0xFF&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this mode, as used in your code, &lt;code&gt;OCR0A&lt;/code&gt; defines the pulse width rate (more precisely, &lt;code&gt;OCR0A / 256&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Timer0&lt;/strong&gt; uses port &lt;code&gt;OC0A&lt;/code&gt; and &lt;code&gt;OC0B&lt;/code&gt; to ouput PWM signals, in your code, you are using only &lt;code&gt;OC0A&lt;/code&gt; (which is perfectly fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you take a look at &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot;&gt;ATmega 328 data sheet&lt;/a&gt;, chapter 14.3.3 you will see that pin &lt;code&gt;OC0A&lt;/code&gt; maps to &lt;strong&gt;port D, pin PD6&lt;/strong&gt; (on Arduino UNO, this is port &lt;strong&gt;D6&lt;/strong&gt;, according to &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168&quot;&gt;http://arduino.cc/en/Hacking/PinMapping168&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this means that &lt;strong&gt;you have used the wrong port&lt;/strong&gt; in your setup (Arduino pin D9 maps to &lt;code&gt;OC1A&lt;/code&gt;, which is pin &lt;strong&gt;PB1&lt;/strong&gt; of &lt;strong&gt;port B&lt;/strong&gt; on ATmega328, &lt;code&gt;OC1A&lt;/code&gt; is used by &lt;strong&gt;Timer1&lt;/strong&gt;, not Timer0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence you should do the following to fix the problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Plug the LED to Arduino pin D6 instead of D9&lt;/li&gt;&#xA;&lt;li&gt;Fix &lt;code&gt;initialize_PWM()&lt;/code&gt; by replacing &lt;code&gt;DDRB|=(1&amp;lt;&amp;lt;PB1);&lt;/code&gt; with &lt;code&gt;DDRD|=(1&amp;lt;&amp;lt;PD6);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Otherwise, if you want to keep Arduino pin D9, then you will have to change the timer you use: Timer1 instead of Timer0. Updating the code is left as an exercise!&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-06-15T23:16:34.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2957" PostTypeId="2" ParentId="2940" CreationDate="2014-06-16T03:41:27.043" Score="4" Body="&lt;p&gt;There is a micro designed more specifically for keyboard emulation, I haven't done any experimenting with it (yet), but it's very popular in the flight simulator world where these micro's are rigged up with buttons and switches and rotary encoders to simulate a cockpit. These inputs are converted to keyboard inputs (as far as I can see). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some general projects here: &lt;a href=&quot;https://www.pjrc.com/teensy/projects.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/projects.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some more keyboard specific stuff: &lt;a href=&quot;https://www.pjrc.com/teensy/usb_keyboard.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/usb_keyboard.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info on the teensy in the arduino environment: &lt;a href=&quot;https://www.pjrc.com/teensy/teensyduino.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/teensyduino.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically about what you're looking for, this could be quite useful: &lt;a href=&quot;https://www.pjrc.com/teensy/td_keyboard.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_keyboard.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not steering you away from Arduino, it's just something else to look into&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-16T03:41:27.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2958" PostTypeId="2" ParentId="2947" CreationDate="2014-06-16T04:40:32.767" Score="5" Body="&lt;p&gt;Not only must &lt;code&gt;cnt&lt;/code&gt; variable be declared &lt;code&gt;volatile&lt;/code&gt;, but accessing it from the main loop must also be protected because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it can be modified by an ISR&lt;/li&gt;&#xA;&lt;li&gt;it is longer than 1 byte&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In AVR architecture (8-bits), &lt;strong&gt;read/write operations on bytes are guaranteed to be atomic&lt;/strong&gt;, i.e. no function can access a byte while it is read/written by an ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;strong&gt;operations on types larger than bytes are not atomic!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that reading e.g. an &lt;code&gt;int&lt;/code&gt; variable from your main loop might be interrupted in the middle of the operation (only 1 byte read) by an ISR that could modify the value (both bytes this time); then when the ISR is finished the main loop would resume reading the second byte -modified by the ISR- of the variable, while keeping the first original byte -not modified by the ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would advise you to write a pair of functions to read and write &lt;code&gt;cnt&lt;/code&gt; in a protected way, i.e. with interrupts disabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cnt;&#xA;&#xA;void set_cnt(int val) {&#xA;    uint8_t status = SREG;&#xA;    cli();&#xA;    cnt = val;&#xA;    SREG = status;&#xA;}&#xA;&#xA;int get_cnt() {&#xA;    uint8_t status = SREG;&#xA;    cli();&#xA;    int val = cnt;&#xA;    SREG = status;&#xA;    return val;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What those functions do are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;get the current status of exceptions (from &lt;code&gt;SREG&lt;/code&gt; register)&lt;/li&gt;&#xA;&lt;li&gt;disable exceptions with &lt;code&gt;cli()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;access &lt;code&gt;cnt&lt;/code&gt; without any risk of it being accessed concurrently&lt;/li&gt;&#xA;&lt;li&gt;restore initial status of exceptions (to &lt;code&gt;SREG&lt;/code&gt; register)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Everywhere in your code (except in code called from an ISR where it is not necessary), you must then call these functions to access &lt;code&gt;cnt&lt;/code&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-06-16T04:40:32.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2959" PostTypeId="1" CreationDate="2014-06-16T11:31:04.983" Score="0" ViewCount="120" Body="&lt;p&gt;I have arduino UNO r3 ATMEGA 328P board and &lt;a href=&quot;http://www.seeedstudio.com/depot/TypeB-USB-cable-for-Arduino-Diecimila-and-Freeduino-p-130.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; kind of a cable. But I want to make and test a program that need to get the data through ethernet port. Can I do only with them. I want to know whether they are enough to that (there are any converter or virtual devices) or should I buy anything. &lt;/p&gt;&#xA;" OwnerDisplayName="ddarz4u" LastEditorUserId="313" LastEditDate="2014-06-16T13:45:04.390" LastActivityDate="2014-06-16T13:45:04.390" Title="How to program arduino for ethernet with only usb cable" Tags="|arduino-uno|uploading|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2960" PostTypeId="2" ParentId="2959" CreationDate="2014-06-16T11:51:30.960" Score="2" Body="&lt;p&gt;You can do the programming of the Arduino through the USB cable, but in order to test and operate the program, you'll need an Ethernet shield and a cable to connect that to the LAN.&lt;/p&gt;&#xA;" OwnerUserId="614" LastActivityDate="2014-06-16T11:51:30.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2963" PostTypeId="1" AcceptedAnswerId="2964" CreationDate="2014-06-16T21:16:06.667" Score="3" ViewCount="9977" Body="&lt;p&gt;I would like to use multiple (three) serial ports on an Arduino Due. Instead of polling the ports continuously, I would like to use a Serial.Event function for each of the ports. These handler functions will read out the incoming string from the port and parse the string (i.e. check for a pre-defined command and call a corresponding sub-routine). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering what is going to happen when serial data arrives at the same time at two different ports? For example, if the program is in the process of handling/parsing the first serial message, will it interrupt/abandon this process as soon as another SerialEvent on another port is triggered? Or will it complete the first SerialEvent routine before going to the second one?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2014-07-17T02:11:52.627" Title="SerialEvent handling when using multiple serial ports" Tags="|serial|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2964" PostTypeId="2" ParentId="2963" CreationDate="2014-06-16T21:40:14.480" Score="3" Body="&lt;p&gt;The built in serialEvent() function on arduino only responds to serial port 0, called just &quot;Serial&quot; in the code. To respond to messages on &quot;Serial1&quot;, use serialEvent1() on the Arduino Due there also exists serialEvent2() and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: the serialEvent() handlers are not on interrupts; they run sequentially in-between loops. If the loop is blocking they do not get run, and they do not interrupt eachother.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-06-17T01:31:36.980" LastActivityDate="2014-06-17T01:31:36.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2965" PostTypeId="2" ParentId="2963" CreationDate="2014-06-16T23:22:21.353" Score="2" Body="&lt;p&gt;That should be fairly simple to implement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each serial port has TX and RX interrupts. You just need to tie into the various interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://mbed.org/cookbook/Serial-Interrupts&quot; rel=&quot;nofollow&quot;&gt;Here is an example&lt;/a&gt; for a mbed, but it should be similar (both use ARM NVIC interrupt controllers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, this wouldn't involve touching the &lt;code&gt;serialEvent()&lt;/code&gt; function stuff at all, but rather implementing what it does using your own code.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you set up your own interrupt handlers, you also get the benefit of being able to control interrupt priority yourself. The ATSAM3X has 16 interrupt priority levels, and a interrupt of a higher priority can pre-empt a lower-level interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I Strongly suggest you read the &lt;a href=&quot;http://www.atmel.com/Images/doc11057.pdf&quot; rel=&quot;nofollow&quot;&gt;ATSAM3X datasheet&lt;/a&gt;. It describes the interrupt controller, as well as the rest of the processor peripherals.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2014-06-16T23:27:24.193" LastActivityDate="2014-06-16T23:27:24.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2966" PostTypeId="2" ParentId="2879" CreationDate="2014-06-17T00:32:11.877" Score="2" Body="&lt;p&gt;The newest code i have posted works 100%! So if you have similar problems with that aweful gps, use this!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, TinyGPS and TinyGPS++ don't work well with this gps. To be precice, there is a problem with the gps.encode(c) function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So using &lt;code&gt;if (gps.encode(c))&lt;/code&gt; most of the times returns false, except some rare occasions which returns true and then you can do some processing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My last code takes care of that problem by checking continuously, using a do...while loop. If &lt;code&gt;if (gps.location.isValid())&lt;/code&gt; returns true, which means i have valid data, then i do the processing i want and end the do...while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This code is for TinyGPS++ library. Same theory will work for TinyGPS too of course...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(4800); &#xA;}&#xA;&#xA;char clat[11];&#xA;char clng[11];&#xA;&#xA;void loop()&#xA;{&#xA;    bool isGpsLocationValid = false;&#xA;    do&#xA;    {  &#xA;        while (ss.available()&amp;gt;0)&#xA;        {&#xA;            char c = byte(ss.read());&#xA;            if (gps.encode(c)) //i previously used if(gps.encode(ss.read())); but no luck then&#xA;            {    &#xA;                if (gps.location.isValid())&#xA;                {&#xA;                    dtostrf(gps.location.lat(), 11, 6, clat);&#xA;                    dtostrf(gps.location.lng(), 11, 6, clng);                        &#xA;                    isGpsLocationValid = true;&#xA;                }&#xA;            }   &#xA;        }&#xA;    } while (isGpsLocationValid == false);&#xA;    Serial.write(clat);&#xA;    Serial.println();&#xA;    Serial.write(clng);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="-1" LastEditDate="2019-07-29T13:23:13.907" LastActivityDate="2019-07-29T13:23:13.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="2967" PostTypeId="1" CreationDate="2014-06-17T06:00:04.800" Score="1" ViewCount="741" Body="&lt;p&gt;I am following this &lt;a href=&quot;https://www.youtube.com/watch?v=vKVNmA8C6m8&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; to learn about Arduino wireless communication. I have 2 Arduino unos with Xbee S1s sitting on Xbee Pro shields. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've programmed the Xbee S1s by screening into the /dev/tty/* and configuring them with: &lt;code&gt;+++, ATID1234, ATMY1000 (ATMY1001), ATDL1001 (ATDL1000)&lt;/code&gt; and &lt;code&gt;ATWR&lt;/code&gt;. I've double checked the values to ensure they are correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i've created a super simple Sender and Receiver package:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sender.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int counter = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(counter++);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver.ino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Looping&quot;);&#xA;  while (Serial.available() == 0);    // wait&#xA;  int counter = Serial.parseInt();&#xA;  Serial.println(counter);&#xA;  Serial.flush();&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So first of all, when I upload my program to my arduino, I make sure that the S1s are not attached to the Pro shields which is attached to the unos. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When both of my unos are powered, I see a red light blinking but no indication of &quot;busy blinking&quot; which is supposed to happen when two XBee S1s are connected to the same channel. I am currently seeing a consistent blinking at about 1 second frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me why I am only able to see &quot;Looping&quot; in my Serial monitor on my receiver? &lt;/p&gt;&#xA;" OwnerUserId="2824" LastActivityDate="2016-02-16T05:40:20.123" Title="Sending wireless data over with xbee s1" Tags="|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2968" PostTypeId="2" ParentId="2939" CreationDate="2014-06-17T15:20:07.063" Score="1" Body="&lt;p&gt;The easiest way is to use the timer1 library written for arduino. You can download it &lt;a href=&quot;http://code.google.com/p/arduino-timerone/downloads/list&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install, simply unzip and put the files in Arduino/hardware/libraries/Timer1/&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Prescaler set for 16Mhz&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Prescale    Time per counter tick   Max Period&#xA;1   0.0625 uS   8.192 mS&#xA;8   0.5 uS  65.536 mS&#xA;64  4 uS    524.288 mS&#xA;256 16 uS   2097.152 mS&#xA;1024    64uS    8388.608mS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Max Period = (Prescale)&lt;em&gt;(1/Frequency)&lt;/em&gt;(2^17)&#xA;Time per Tick = (Prescale)*(1/Frequency)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instructions available using this library are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;initialize(period)&#xA;You must call this method first to use any of the other methods. You can optionally specify the timer's period here (in microseconds), by default it is set at 1 second. Note that this breaks analogWrite() for digital pins 9 and 10 on Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;setPeriod(period)&#xA;Sets the period in microseconds. The minimum period or highest frequency this library supports is 1 microsecond or 1 MHz. The maximum period is 8388480 microseconds or about 8.3 seconds. Note that setting the period will change the attached interrupt and both pwm outputs' frequencies and duty cycles simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pwm(pin, duty, period)&#xA;Generates a PWM waveform on the specified pin. Output pins for Timer1 are PORTB pins 1 and 2, so you have to choose between these two, anything else is ignored. On Arduino, these are digital pins 9 and 10, so those aliases also work. Output pins for Timer3 are from PORTE and correspond to 2,3 &amp;amp; 5 on the Arduino Mega. The duty cycle is specified as a 10 bit value, so anything between 0 and 1023. Note that you can optionally set the period with this function if you include a value in microseconds as the last parameter when you call it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;attachInterrupt(function, period)&#xA;Calls a function at the specified interval in microseconds. Be careful about trying to execute too complicated of an interrupt at too high of a frequency, or the CPU may never enter the main loop and your program will 'lock up'. Note that you can optionally set the period with this function if you include a value in microseconds as the last parameter when you call it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;setPwmDuty(pin, duty)&#xA;A fast shortcut for setting the pwm duty for a given pin if you have already set it up by calling pwm() earlier. This avoids the overhead of enabling pwm mode for the pin, setting the data direction register, checking for optional period adjustments etc. that are mandatory when you call pwm().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;detachInterrupt()&#xA;Disables the attached interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;disablePwm(pin)&#xA;Turns PWM off for the specified pin so you can use that pin for something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;read()&#xA;Reads the time since last rollover in microseconds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example - Sets up PWM output on pin 9 with a 50% duty cycle, and attaches an interrupt that toggles digital pin 10 every half second.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Timer1 library example&#xA; *  June 2008 | jesse dot tane at gmail dot com&#xA; */&#xA;&#xA;#include &quot;TimerOne.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(10, OUTPUT);&#xA;  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period&#xA;  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle&#xA;  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;  digitalWrite(10, digitalRead(10) ^ 1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // your program here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Timer1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-06-17T15:20:07.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2969" PostTypeId="1" AcceptedAnswerId="2970" CreationDate="2014-06-17T09:26:21.223" Score="2" ViewCount="1010" Body="&lt;p&gt;Are the SPI pins on the ICSP header of an Arduino Uno &quot;separable&quot; from the correspondent I/O pins - when one chooses to the use the ICSP header can the corresponding I/O pins be used for something else?&lt;/p&gt;&#xA;" OwnerUserId="11399" OwnerDisplayName="joaocandre" LastActivityDate="2014-06-17T15:54:31.397" Title="Can the SPI pins of an Arduino be separated from SPI?" Tags="|spi|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2970" PostTypeId="2" ParentId="2969" CreationDate="2014-06-17T11:38:08.740" Score="4" Body="&lt;p&gt;No.  Those pins are not separate on the microcontroller itself.  If you need to use SPI and still need more pins you may use analog inputs as digital inputs or outputs.  Otherwise you'll probably have to use an expander of some sort, or use a Mega or Due for additional inputs or outputs.&lt;/p&gt;&#xA;" OwnerUserId="349" OwnerDisplayName="Adam Davis" LastActivityDate="2014-06-17T11:38:08.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2971" PostTypeId="2" ParentId="2969" CreationDate="2014-06-17T14:19:08.143" Score="1" Body="&lt;p&gt;Actually, it can. You just can not use them at the same time. One needs to be careful to wire it in ways not to comprise the shared functions. Where MISO can be used as GPIO-INPUT and MOSI/SCK can be used as GPIO-OUTPUT, avoiding any pull up/downs, etc... As such electrical items may interfere with the ICSP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I use the ICSP programming, along with the MISO, MOSI and SCLK pins as hard SPI and use them as Bit Bang one-wire, all on the same board and same wires. I simply ensure the SPI is properly configured each at each use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One additionally needs to ensure that any peripherals on the shared SPI/ICSP lines are guaranteed to be in reset. Such as a pull down on such devices reset pins. Or a Pull Up on their ChipSelects. Noting that ATmega's GPIO pins are Hi-Z out of reset and during the ICSP. &lt;/p&gt;&#xA;" OwnerUserId="60" OwnerDisplayName="mpflaga" LastActivityDate="2014-06-17T14:19:08.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2972" PostTypeId="1" AcceptedAnswerId="2975" CreationDate="2014-06-17T16:26:03.833" Score="4" ViewCount="12767" Body="&lt;p&gt;I have an Arduino Uno linked up to an SRF04 ultrasonic sensor. I'm using the library from here: &lt;a href=&quot;https://code.google.com/p/srf04-library/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/srf04-library/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm then using the basic script &quot;Centimeter&quot; that comes in the examples. This gives me a reading, but it seems to be ~20-25% inaccurate. When it reads 100cm, the distance is actually nearer 80cm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've replaced the SRF04 with another, and the same issue occurs. Additionally, it seems when it reads out of range (or even on surfaces that give an uneven &quot;bounce&quot;), I get very random figures (e.g. -5cm). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone experienced something similar? &lt;/p&gt;&#xA;" OwnerUserId="2832" LastActivityDate="2020-10-11T18:11:51.030" Title="SRF04 Ultrasonic sensor - inaccurate readings" Tags="|arduino-uno|sensors|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2973" PostTypeId="2" ParentId="2972" CreationDate="2014-06-17T16:36:00.233" Score="2" Body="&lt;p&gt;This is pretty standard. Altitude and air temperature will change the speed of sound enough to cause these errors, and minor variations in sensors could compound the problem. I would try calculating your own scale to convert ping time to distance using actual measurements from where you live; The library probably uses the speed of sound at sea level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, any shape that poorly reflects or absorbs ultrasound will cause erroneous readings. There is really not much to do about this, sorry. If you have multiple sensors aimed a few degrees apart you are more likely to get one that will read the right distance. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-17T16:36:00.233" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2974" PostTypeId="2" ParentId="2972" CreationDate="2014-06-17T17:15:01.917" Score="3" Body="&lt;p&gt;While BrettM discussed some excellent points that can occur with ultrasonic/sonar/'Ping' sensors I've noticed a few others when I have used these sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first and most common issue with sensors of this type is accurately identifying what is triggering the distance value. Consider at an abstract level how these work. You've got the bit that transmits a 'ping'. It transmits the 'ping' and stops. At this point the bit that listens for the 'pong' activates and starts listening. These sensors work by sending out that 'ping' and starting a timer, the first 'pong' the sensor hears triggers a stop response to the timer and distance is, roughly, figured out from here.  Notice that there is no way for the sensor to distinguish where the 'pong' is coming from. If you yodel on a mountain you don't know which surface echoed back and this is the same issue you are potentially facing with your sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically when I work with people who are getting inaccurate readings from their sensors of the sort you are describing some variation of this issue is occurring. Often readings that are 'short' are so because there is an obstacle in the cone of the 'ping' that causes the sound to reflect back more quickly than expected for the surface you are measuring. Recall that sound is not a accurate,directed laser. Rather it spreads out in waves from the source. In my experience any objects within a roughly 160 degree arc(in my experience) in front of your sensor can cause these readings to be unusual. That can include the floor, your shoes, measuring devices. In theory the sensor is created to avoid these readings, in practice not so much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test if this is the case with your sensor setup I would recommend a few experiments. First setup the arduino and sensor in a fixed position and in such a way that the sensor is at the edge of a support surface with nothing but the surface you desire to measure in front of it. So, for example, set up the sensor on the very edge of a table facing a wall. Measure the distance from the wall to the support surface edge(table's edge). Some variation is normal, as described by BrettM, but 20% on 100 cm is a bit much in my experience. Once you get a solid, repeatable reading start changing the environment. Put something in the front arc of the sensor and see how that effects it. Move the sensor/support surface towards and away from the object. Typically when I see values like -5 that means something was too close to the sensor or, potentially, another sensor is interfering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is worth checking to confirm that there are no other range sensing devices in the area you are working within. Other devices sending out similar 'ping's can cause unusual readings(since they don't distinguish who's ping/pong is whose).&lt;/p&gt;&#xA;" OwnerUserId="2786" LastActivityDate="2014-06-17T17:15:01.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2975" PostTypeId="2" ParentId="2972" CreationDate="2014-06-17T19:44:56.387" Score="9" Body="&lt;p&gt;Just don't use that library, it seems poorly designed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how the distance for roundtrip is calculated (code excerpts):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long sum = 0;&#xA;for (int i=0;i&amp;lt;_average;i++)&#xA;{&#xA;    digitalWrite(_trigPin, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(_trigPin, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(_trigPin, LOW);&#xA;    _duration = pulseIn(_echoPin, HIGH);&#xA;    sum=sum+_duration;&#xA;}&#xA;return(int(sum/_average));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we remove the averaging stuff (as &lt;code&gt;_average&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt; by default), this boils down to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(_trigPin, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(_trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(_trigPin, LOW);&#xA;return int(pulseIn(_echoPin, HIGH));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pulseIn&lt;/code&gt; normally returns an &lt;code&gt;unsigned long&lt;/code&gt; which is the number of microseconds for a roundtrip of the sound wave emitted by the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we consider the speed of sound in the air to be about 340m/s (under average conditions of temperature and altitude), and if we consider an object that is 3m away from your sensor (which is the approximate max range of the SRF04 sensor), then &lt;code&gt;pulseIn()&lt;/code&gt; should return:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3 x 2 / 340 x 1000000 = 17646 us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far we don't see any particular problem, that's fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if we take a look at the &lt;a href=&quot;http://www.robot-electronics.co.uk/htm/srf04tech.htm&quot;&gt;SRF04 datasheet&lt;/a&gt; timing diagram, it is mentioned that if no object is detected, an echo of &lt;strong&gt;36ms&lt;/strong&gt; will be sent by the sensor; in this situation, &lt;code&gt;pulseIn()&lt;/code&gt; will return &lt;strong&gt;36000us&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that &lt;code&gt;36000&lt;/code&gt; does not fit into an &lt;code&gt;int&lt;/code&gt; (max value = &lt;code&gt;32767&lt;/code&gt;), the conversion to an &lt;code&gt;int&lt;/code&gt; will change it into a &lt;strong&gt;negative value&lt;/strong&gt;! That explains your strange negative outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now regarding accuracy, the library you are using has another issue; here is how the distance in cm is calculated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int DistanceSRF04::getDistanceCentimeter()&#xA;{&#xA;        return (getDistanceTime()/29/2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem here is the &lt;code&gt;int&lt;/code&gt; calculation, it should rather be performed as &lt;code&gt;float&lt;/code&gt;. For a speed of sound of 340 m/s, one should divide the time of the echo in us by &lt;code&gt;29.4&lt;/code&gt; (ie &lt;code&gt;1000000 / 340 / 100&lt;/code&gt;), not 29, that can make a difference in the final calculated distance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go on using this library, then just forget about the &lt;code&gt;getDistanceCentimeter()&lt;/code&gt;method and replace it with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;distance = (int) (sensor.getDistanceTime() / 29.4 / 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All calculation is then performed as &lt;code&gt;float&lt;/code&gt; and converted to &lt;code&gt;int&lt;/code&gt; distance only at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code should also explicitly detect negative values as meaning &quot;no object detected&quot;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-06-17T19:44:56.387" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2976" PostTypeId="1" CreationDate="2014-06-17T20:19:31.597" Score="1" ViewCount="122" Body="&lt;p&gt;In &lt;a href=&quot;https://docs.google.com/viewer?url=http%3A%2F%2Fwww.nostarch.com%2Fdownload%2Fsamples%2FArduinows_ch4.pdf&quot; rel=&quot;nofollow&quot;&gt;chapter 4&lt;/a&gt; of Arduino Workshop on page 85 (or page 31 in the pdf) it says that the voltage at AREF in the schematic is given by: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin * R2 / (R2 + R1)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the voltage is flowing from 5V to Ground so isn't AREF actually in parallel with R1, and so shouldn't AREF be given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin * R1 / (R1 + R2) ?&lt;/p&gt;&#xA;" OwnerUserId="2835" LastActivityDate="2014-06-17T20:57:15.987" Title="Why voltage at AREF is given by Vin * R2 / Rtotal" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2977" PostTypeId="2" ParentId="2976" CreationDate="2014-06-17T20:57:15.987" Score="3" Body="&lt;p&gt;You are correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;$$V_{ref} = \dfrac{R_1}{R_1 + R_2} \cdot V_{CC}$$&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or Vref = Vin * R1 / (R1 + R2) until we finally get &lt;a href=&quot;https://arduino.meta.stackexchange.com/questions/13/is-there-an-easy-way-to-enter-formulas-in-questions&quot;&gt;MathJax&lt;/a&gt; enabled on this site.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="-1" LastEditDate="2017-03-16T15:52:43.687" LastActivityDate="2014-06-17T20:57:15.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2978" PostTypeId="1" CreationDate="2014-06-17T23:17:17.617" Score="0" ViewCount="5243" Body="&lt;p&gt;I am just starting out a project and I am having a little bit of trouble. I want to send data collected from an IR distance sensor, and send it with an XBee Pro S2B to my computer so I can do other stuff with it. The code I am using right now is pretty simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;void loop(){&#xA; int distance = analogRead(0);&#xA;  Serial.println(distance);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I am having is that when I turn on the arduino with batteries and disconnect the usb cable, the tx light stops turning on and no serial data is sended, AND if I connect it to the computer via USB again it won't work anyway, only works right when I upload the code. The XBees are configured correctly, I have done the chat example on the Building Wireless Sensor Networks by Robert Faludy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it some code error? I must be really obvious.&#xA;By the way, when I upload the code and the serial data is sended throught usb, the data displayed on Arduino IDE's console is correct, so the sensor is wired correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino UNO and I have the XBee's and arduino's drivers installed correctly, and for the XBee I am using the XBee Explorer from Sparkfun&lt;/p&gt;&#xA;" OwnerUserId="2836" LastEditorUserId="84" LastEditDate="2014-06-18T04:57:46.737" LastActivityDate="2017-12-16T01:40:54.477" Title="Can't send serial data throught serial pins but it works with the usb port" Tags="|arduino-uno|serial|xbee|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2979" PostTypeId="2" ParentId="2978" CreationDate="2014-06-17T23:38:50.443" Score="1" Body="&lt;p&gt;I suggest you try to flash the pin 13 LED in your loop().  It seems like the Arduino is not booting correctly on the batteries?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial port on the uno is kinda messy, it shouldn't really be shared with the usb port like that.  I prefer the Leonardo for these applications - where the USB serial and serial pins are totally independent.&lt;/p&gt;&#xA;" OwnerUserId="2837" LastActivityDate="2014-06-17T23:38:50.443" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="2980" PostTypeId="1" AcceptedAnswerId="2981" CreationDate="2014-06-18T00:42:13.930" Score="2" ViewCount="203" Body="&lt;p&gt;I would like to manage many LEDs from my Arduino - 12 or so - but I do not have the available digital pins to do this. Only one LED needs to be on at one time. Instead, I was hoping to control these with an analog pin. I was wondering if there is some sort of switch out there which can take an analog signal and, based on the value, direct a 5V current to a certain LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that I could use a second Arduino for this, but I am trying to avoid that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help!&lt;/p&gt;&#xA;" OwnerUserId="2838" LastActivityDate="2020-09-23T03:13:23.093" Title="Direct 5V current based on analog signal" Tags="|analogwrite|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2981" PostTypeId="2" ParentId="2980" CreationDate="2014-06-18T01:30:02.177" Score="1" Body="&lt;p&gt;You can accomplish this digitally with a device called a &lt;em&gt;decoder&lt;/em&gt;. For example, the &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT154.pdf&quot; rel=&quot;nofollow&quot;&gt;74154&lt;/a&gt; takes 4 inputs and maps those to one of 16 outputs (depending on the binary coding of the inputs). From the data sheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 74HC154; 74HCT154 decoders accept four active HIGH binary address inputs and&#xA;  provide 16 mutually-exclusive active LOW outputs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2839" LastActivityDate="2014-06-18T01:30:02.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2984" PostTypeId="1" AcceptedAnswerId="2985" CreationDate="2014-06-18T04:37:16.840" Score="1" ViewCount="1324" Body="&lt;p&gt;I just received my starter kit from oddwires.com today and it came with a split-able ribbon cable for prototyping. I was curious if it is possible to split each wire off and use only what I need to for the tutorials or is that a bad idea? I am very excited to start playing around and learning this as it has been a interest of mine for many years.&lt;/p&gt;&#xA;" OwnerUserId="2840" LastActivityDate="2014-06-18T05:02:15.707" Title="splitable jumper wires question" Tags="|arduino-uno|wires|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="2985" PostTypeId="2" ParentId="2984" CreationDate="2014-06-18T05:02:15.707" Score="2" Body="&lt;p&gt;Each wire in the Dupont ribbon cable is is independent, and does not hold onto its neighbors with any real force. You can split them or join multiple wires together using larger connectors as desired.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-06-18T05:02:15.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2986" PostTypeId="2" ParentId="2978" CreationDate="2014-06-18T09:03:22.913" Score="0" Body="&lt;p&gt;You have an XBee shield on top of the Arduino UNO?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have an XBee attached to the computer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you describe your setup a little more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX Led on the Arduino is only on the USB side, and doesn't signify TX on the XBee. The XBee itself should/could have a TX/RX leds itself. Check the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Arduino schematic&lt;/a&gt; to confirm this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are you reading the Serial on the computer? Thru the Arduino serial monitor? That won't work for the XBee. You'll need another Serial monitor for the XBee attached to the computer. ie, Arduino with XBee shield. Then an XBee connected via some breakout board to the computer. The Arduino Serial monitor won't see the XBee (use hyperterm on windows or some serial port monitor on other systems). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, check your switch on the XBee (if you have one), most redirect the USB/Serial connection between computer/Arduino and Arduino/XBee. It's one or the other not both. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-18T09:03:22.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2987" PostTypeId="1" CreationDate="2014-06-18T14:50:48.320" Score="5" ViewCount="9262" Body="&lt;p&gt;&lt;em&gt;Edit - Sorry it's a &lt;strong&gt;Micro&lt;/strong&gt; not a Nano&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Micro board hooked up to an EasyDriver breakout using its 5V output to power the Micro. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I plugged it in and instead of booting up like normal the power LEDs on the wall plug, the easy driver, and the Arduino started flashing. The Micro became very hot, but not hot enough to burn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that if I plug the Micro into the USB port it just rapidly blinks the pin 13 LED. The PC does not detect the device but it does receive power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Holding or pushing the reset button doesn't seem to help at all. I've used different USB cables, and different ports on the PC as well to no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this something it can recover from? Why did all the LEDs blink like that? &lt;/p&gt;&#xA;" OwnerUserId="253" LastEditorUserId="6936" LastEditDate="2016-10-28T07:02:08.227" LastActivityDate="2021-09-27T09:22:14.647" Title="Arduino Micro just blinks, won't connect to PC" Tags="|arduino-nano|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="2988" PostTypeId="1" CreationDate="2014-06-14T22:09:09.483" Score="-2" ViewCount="2151" Body="&lt;p&gt;is it possible to connect Arduino Ethernet Shield direct to PC and send a String variable? How can I read it later on the PC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this code work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; // Shield MAC&#xA;&#xA;byte pc[] = &quot;192.168.0.13&quot;; // pc IP&#xA;EthernetClient client;&#xA;&#xA;void setup()&#xA;{&#xA;  Ethernet.begin(mac);&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  delay(5000);&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    client.println(&quot;Sample String&quot;);&#xA;    client.println();&#xA;  } else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="z0nk0" LastActivityDate="2014-06-19T08:31:15.223" Title="Arduino Ethernet Shield connection to PC" Tags="|lan|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2989" PostTypeId="1" CreationDate="2014-06-18T06:38:28.493" Score="0" ViewCount="85" Body="&lt;p&gt;Can an Arduino UNO and Arduino Leonardo do the same things?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the examples in the Arduino software say to use Leonardo e.g. &lt;a href=&quot;http://arduino.cc/en/Tutorial/KeyboardMessage&quot; rel=&quot;nofollow&quot;&gt;KeyboardMessage&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10289" OwnerDisplayName="user45803" LastEditorUserId="220" LastEditDate="2014-06-18T20:28:00.993" LastActivityDate="2014-06-18T20:28:00.993" Title="Keyboardmessage on Arduino UNO" Tags="|arduino-uno|programming|uploading|arduino-leonardo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2990" PostTypeId="2" ParentId="2989" CreationDate="2014-06-18T09:04:42.373" Score="1" Body="&lt;p&gt;No, the Uno and the Leonardo cannot do the same thing.  The Leonardo is a single MCU directly connected to the USB port. It is down to the software on that MCU as to how it communicates (what it enumerates as) on the USB bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno, conversely, is a dual MCU system. It has the &quot;main&quot; MCU (the ATMega328P) which is what you program, and that communicates to the USB port via another MCU.  The two MCUs are connected using TTL RS-232 (UART), so the only communication you have with your computer is through the Serial object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are benefits and problems with both approaches.  The benefits of the Leonardo are that you can emulate keyboards, mice, etc.  The down side is that the whole USB communication is more fragile and is at the mercy of the user.  The Uno's benefits are that the USB serial is always connected and available regardless of the state of the main MCU, which is much more friendly from the PC's point of view.  The down side is that it severely limits your communication options.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-06-18T09:04:42.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2991" PostTypeId="1" AcceptedAnswerId="2996" CreationDate="2014-06-18T20:03:39.383" Score="2" ViewCount="290" Body="&lt;p&gt;I've been using my Arduino UNO without a hith for a few days now, but suddenly I can't program it anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to programm my Arduino on Mac, I get the following Error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The USB option under serial port has disappeard (It was there before). Has anyone an idea on how to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last thing I did is use the serial port for some communication. A reboot hasn't improved anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried programming Linux, but it resulted in the exact same result.&lt;/p&gt;&#xA;" OwnerUserId="2817" LastEditorUserId="2817" LastEditDate="2014-06-18T20:18:02.083" LastActivityDate="2017-02-19T16:32:24.520" Title="No usb serial on Mac" Tags="|programming|serial|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="2993" PostTypeId="2" ParentId="2989" CreationDate="2014-06-18T20:27:30.440" Score="0" Body="&lt;p&gt;Yes you can, but not with that library. This method is a little advanced and requires you to upgrade a different type of firmware to your second MCU on your Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(The full tutorial is available &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code from the tutorial link shown above (for process outlined below):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t buf[8] = { &#xA;  0 };  /* Keyboard report buffer */&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  randomSeed(analogRead(0));&#xA;  delay(200);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  int randomChar = random(4, 130);&#xA;  long randomDelay = random(1000, 10000);&#xA;&#xA;  delay(randomDelay);&#xA;&#xA;  buf[2] = randomChar;    // Random character&#xA;  Serial.write(buf, 8); // Send keypress&#xA;  releaseKey();&#xA;}&#xA;&#xA;void releaseKey() &#xA;{&#xA;  buf[0] = 0;&#xA;  buf[2] = 0;&#xA;  Serial.write(buf, 8); // Release key  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what you need to do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get a DFU programmer&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Windows: Download Atmel's flip programmer from here &lt;a href=&quot;http://www.atmel.com/tools/flip.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/tools/flip.aspx&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Mac: Install MacPorts following these instructions: &lt;a href=&quot;http://www.macports.org/install.php#pkg&quot; rel=&quot;nofollow&quot;&gt;http://www.macports.org/install.php#pkg&lt;/a&gt; Once MacPorts is installed, in a Terminal window, type &lt;code&gt;sudo port install dfu-programmer&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Linux: from a command line type &lt;code&gt;sudo apt-get install dfu-programmer&lt;/code&gt; or &lt;code&gt;sudo aptitude install dfu-programmer&lt;/code&gt; depending on your distribution&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Source: &lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/DFUProgramming8U2&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download the Keyboard &lt;a href=&quot;http://www.fourwalledcubicle.com/LUFA.php&quot; rel=&quot;nofollow&quot;&gt;LUFA firmware&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You'll have to solder a resistor on a non-SMD Uno (that's outlined in the Arduino link in the second step)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect the Uno to your comptuer and reset the 8u2 (short the farthest left pair of metal contacts in the upper left hand corner of the Uno)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Upload the firmware using the GUI in flip, OR for Mac/Linux go to the directory where the firmware is using the terminal then:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Type this line (Still, Mac or Linux only):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo dfu-programmer at90usb82 erase&#xA;sudo dfu-programmer at90usb82 flash [Replace-this-with-file-name].hex&#xA;sudo dfu-programmer at90usb82 reset&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unplug/plug in your board and enjoy! Note: you'll have to flash the standard firmware to upload a new sketch and the flash the keyboard firmware again to get this to work.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-18T20:27:30.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2994" PostTypeId="1" AcceptedAnswerId="2997" CreationDate="2014-06-18T20:47:02.200" Score="2" ViewCount="540" Body="&lt;p&gt;I am new to Arduino. &#xA;I have been trying to connect a 7 segment display (3 digits) to my Arduino and I was successful, but I am not doing any connection to ground. I do not find the data sheet so I am not sure if this connection is well done.&#xA;My doubt is: Is the connection to ground necessary? Or how do Arduino pins work? I am using 12 pins of the Uno to do the set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My set up is the following:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ADNED.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2848" LastEditorUserId="2848" LastEditDate="2014-06-18T22:27:29.093" LastActivityDate="2014-06-19T03:58:58.480" Title="7 Segment Display SET UP" Tags="|arduino-uno|pins|wires|display|electronics|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="2995" PostTypeId="2" ParentId="2991" CreationDate="2014-06-18T20:54:01.180" Score="1" Body="&lt;p&gt;If I try to upload with no device connected, I get a dialog with the message &quot;port is blocked&quot; and a message in Eclipse's console window that the port is not found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm guessing you've got a sync problem. UNO should reset automatically when avrdude connects. Try manually resetting it just before you click to start the download. If that works, then the automatic reset has failed.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-18T20:54:01.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2996" PostTypeId="2" ParentId="2991" CreationDate="2014-06-18T21:33:28.743" Score="3" Body="&lt;p&gt;It seemed to be a hardware problem on the board. Thanks for the effort.&lt;/p&gt;&#xA;" OwnerUserId="2817" LastActivityDate="2014-06-18T21:33:28.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="2997" PostTypeId="2" ParentId="2994" CreationDate="2014-06-19T03:58:58.480" Score="1" Body="&lt;p&gt;I don't know exactly how your display is wired exactly, but it is certain that some sort of multiplexing is going on, since A: there is no wired ground, and B, you are controlling more LED's than you have pins going to the display. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiplexing manages this by using some trickery and persistence of vision. The pins for each part of the segment are all wired together. For example, the top segment on each of the three segments are all connected to one arduino pin. The common anode/cathode (depending on your specific display) for each of your three displays are wired separately however. Turning only one of the common pins on will cause only one display to function when the other pins set which segments are on. The micro controller then changes which common is active and what segments are on to illuminate the next character very quickly. It pulses between segments so quickly you cannot tell they are only on one third of the time each. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring inside the display will likely look similar to this:&#xA;&lt;a href=&quot;http://www.modd3d.com/articles/wp-content/uploads/normal-multiplexing-s.gif&quot; rel=&quot;nofollow&quot;&gt;http://www.modd3d.com/articles/wp-content/uploads/normal-multiplexing-s.gif&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-19T03:58:58.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="2998" PostTypeId="2" ParentId="2988" CreationDate="2014-06-19T08:31:15.223" Score="1" Body="&lt;p&gt;No, you seem to be off on a tangent. There at least two problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Ethernet library is designed to run on an Arduino board. If you set the IP address to the same as the PC IP address, the network will get confused and nothing will work reliably.&lt;/li&gt;&#xA;&lt;li&gt;Are you asking how one can publish data from an Arduino board and read the results on a PC? This is easier. Just set up the web server example on the Arduino, and access it from a browser on your PC.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-06-19T08:31:15.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3000" PostTypeId="1" CreationDate="2014-06-19T13:58:49.633" Score="2" ViewCount="2698" Body="&lt;p&gt;This is a question about programming. Mainly about the loop() function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example&#xA;Consider code where you get data from an accelerometer, and if the Gs are high enough you do something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the following pseudocode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;pinMode(1, INPUT);&#xA;bool flag = false;&#xA;}&#xA;&#xA;void loop&#xA;{&#xA;int x= analogRead(1);&#xA;if (x&amp;gt;2)   //if the Gs we get from accelerometer&#xA;  flag = true;&#xA;if (button)  // if user hits the emergency button&#xA;  flag = true;&#xA;&#xA;if (flag == true)&#xA;{&#xA;//GET SERIAL DATA (EG GPS COORDINATES)&#xA;//DO SOME HEAVY PROCESSING&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now loop runs repeatedly&#xA;That means all the commands are executed in a continuous/serial style&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since that happens, what will happen if the accelerometer reading where (x&gt;2), which is what we look for, happen in the REAL world, at a time where in the CPU, the cpu is at that time processing or checking following commands in the program flow, like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (button)  // if user hits the emergency button&#xA;      flag = true;&#xA;&#xA;    if (flag == true)&#xA;    {&#xA;    //GET SERIAL DATA (EG GPS COORDINATES)&#xA;    //DO SOME HEAVY PROCESSING&#xA;    }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any chance that the cpu will miss real world events, because at that time the real world event occured, the cpu was processing other code. Or rather, not checking for that at that time. For our example, when the event occured, it wasnt checking the analogread() at that time, but was processing following code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should i worry about that?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-19T23:33:36.403" Title="Code flow for precission applications" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3001" PostTypeId="2" ParentId="3000" CreationDate="2014-06-19T14:46:07.397" Score="2" Body="&lt;p&gt;Yes, in theory you can always miss events if you use a polling approach like that. Whether or not that's a problem depends on how accurate/frequent your data collection needs to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can often mitigate the issue to an acceptable level if you are able to poll fast enough. That's determined largely by what else your main loop is doing. The more work it has to do elsewhere, the longer it will take between calls to &lt;code&gt;analogRead()&lt;/code&gt; (and the more likely it is to miss something). Optimising your code can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also find that you can compensate sufficiently by interpolating between samples. Linear interpolation is very easy, although more complex options may also be possible, especially if you're processing the data offline afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If polling isn't working for you, then interrupts are the obvious alternative. Since you're reading an analog signal, you'd probably need some external circuitry which does a voltage comparison. You can get dedicated comparator IC's from all sorts of vendors, or use an op-amp circuit if you prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the signal goes over a pre-determined threshold, the comparator would have to pulse or assert a digital line. That could trigger an external interrupt pin on your microcontroller, which will execute custom handler code. See &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;attachInterrupt()&lt;/code&gt;&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-19T14:46:07.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3003" PostTypeId="1" CreationDate="2014-06-19T16:06:35.790" Score="0" ViewCount="1257" Body="&lt;p&gt;I am trying to do a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hardware-in-the-loop_simulation&quot; rel=&quot;nofollow&quot;&gt;Hardware-in-the-loop&lt;/a&gt; (HIL) system with Arduino and Simulink but the driver of my motor (Pololu VNH5019) works at 20kHz and simulink PWM block only supports 490Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to read and modify the code before it is sent to the Arduino to modify this and add other libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is not possible, there is any other visual environment (with blocs, like simulink or Xcos) to generate Arduino Code?&lt;/p&gt;&#xA;" OwnerUserId="2863" LastEditorUserId="46" LastEditDate="2015-10-20T11:54:56.247" LastActivityDate="2015-10-20T11:54:56.247" Title="Read Arduino code generated by Simulink" Tags="|arduino-uno|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3004" PostTypeId="2" ParentId="1278" CreationDate="2014-06-19T16:32:12.373" Score="-1" Body="&lt;p&gt;There is a working example of this, using the Adafruit Ultimate GPS, and the Arduino GSM shield&#xA;&lt;a href=&quot;http://www.mallinson-electrical.com/shop/gpsgsm&quot; rel=&quot;nofollow&quot;&gt;http://www.mallinson-electrical.com/shop/gpsgsm&lt;/a&gt;&#xA;I hope this helps&lt;/p&gt;&#xA;" OwnerUserId="2865" LastActivityDate="2014-06-19T16:32:12.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3005" PostTypeId="2" ParentId="3000" CreationDate="2014-06-19T18:07:22.247" Score="2" Body="&lt;p&gt;one should take into account the frequency response of the signal versus the sample rate. Per Arduino's web site &lt;a href=&quot;http://arduino.cc/en/Reference/analogRead&quot; rel=&quot;nofollow&quot;&gt;AnalogRead&lt;/a&gt; &quot;It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.&quot; or 5K/S for 2 AnalogRead's. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I read the output response of the &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/General/MMA7361L.pdf&quot; rel=&quot;nofollow&quot;&gt;accelerometer used on the Esplora&lt;/a&gt; is 300-400Hz. Note often there are additional filters between the accelerometer and the A2D input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in short there should be enough time to sample both X &amp;amp; Y along with a Z, leaving a margin of 10x. To do other things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just be careful not to do too much, with routines that block. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a matter of practice, it is best not to rely on a loop for what ever timing it loops at. But rather setup a timer, either by interrupt or by watching the millis(), to trigger the analog reads at a known interval. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;volatile int x,y,z;&#xA;void setup()&#xA;{&#xA;  Timer1.initialize(3000);         // initialize timer1 to overflow at 333hz&#xA;  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt&#xA;}&#xA;void callback()&#xA;{&#xA;  x = analogRead(A0);&#xA;  y = analogRead(A1);&#xA;  z = analogRead(A2);&#xA;}&#xA;void loop()&#xA;{&#xA;  noInterrupts(); // to ensure they are all in sync.&#xA;  // do something with x,y&amp;amp;z&#xA;  interrupts();&#xA;  // do something else, that is not blocking.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-06-19T23:33:36.403" LastActivityDate="2014-06-19T23:33:36.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3007" PostTypeId="1" CreationDate="2014-06-19T21:33:28.057" Score="2" ViewCount="392" Body="&lt;p&gt;I'm new to Arduino GPS and am wondering if I could be pointed in the right direction regarding code and wiring when hooking up my Parallax PMB-688 to an Arduino Uno&lt;/p&gt;&#xA;" OwnerUserId="2867" LastEditorUserId="26916" LastEditDate="2017-09-09T23:47:24.547" LastActivityDate="2017-09-09T23:47:24.547" Title="Arduino Uno wiring and code with Parallax PMB-688" Tags="|arduino-uno|programming|wires|tinygps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3008" PostTypeId="1" AcceptedAnswerId="3009" CreationDate="2014-06-20T00:57:02.117" Score="2" ViewCount="279" Body="&lt;p&gt;I am just starting out with an Arduino Diecimila and am playing around with LEDs, and am confused by why some circuits result in an LED not lighting up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Successful Scenarios:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yellow LED from pin13 to 16B on the breadboard, Green LED from 16A to GND. This works both LEDS light up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yellow LED from pin13 to 16A on the breadboard. Wire from 16E to 14E. Green LED from 14A to GND. This works and both LEDs light up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Failed Scenarios: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yellow LED from pin13 to 16A. Green LED from 16E to 14E. Yellow LED from 14A to GND. No LEDs light up. I would assume that all the LEDS are in series, and all 3 should light up, I assumed this would be exactly the same as my second successful scenario where the LED is acting the same as the wire.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yellow LED from pin13 to 16A. Wire from 16E to 14E. Yellow LED from 15A to GND. Green LED from 16B to 14B. Here I have both Yellow LEDS lit, but the Green LED is not lit. I was expecting that the Green LED would have been in parallel and should have lit up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In both failed scenarios I have swapped around the LEDs and proved that all the LEDs function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be some basic concept that I am not understanding with the circuits, any ideas?&lt;/p&gt;&#xA;" OwnerUserId="2874" OwnerDisplayName="stats" LastActivityDate="2014-06-20T11:36:14.140" Title="Confusion around LEDs on a breadboard" Tags="|led|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3009" PostTypeId="2" ParentId="3008" CreationDate="2014-06-20T01:24:14.217" Score="6" Body="&lt;p&gt;Scenario 1 fails because yellow and green LEDs have forward voltages of about 2V each, so when putting 3 in series, you need a forward voltage to light them that exceeds the 5V available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scenario 2 fails because the wire you have in parallel with the LED provides a path with a very low voltage drop (close to 0V), so the path through the LED with a ~2V voltage drop is not taken (and if you remove the wire, the same reasoning as in scenario 1 applies, so nothing would work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, you should never run LEDs without a series resistor, as your experiments will surely demonstrate to you soon ;-)&lt;/p&gt;&#xA;" OwnerUserId="353" OwnerDisplayName="microtherion" LastActivityDate="2014-06-20T01:24:14.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3010" PostTypeId="1" AcceptedAnswerId="3015" CreationDate="2014-06-20T11:56:01.807" Score="2" ViewCount="1642" Body="&lt;p&gt;I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(4800); &#xA;}&#xA;&#xA;char clat[11];&#xA;char clng[11];&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;        bool isGpsLocationValid = false;&#xA;        do&#xA;        {  &#xA;            while (ss.available()&amp;gt;0)&#xA;            {&#xA;                char c = byte(ss.read());&#xA;                if (gps.encode(c)) &#xA;                {    &#xA;                    if (gps.location.isValid())&#xA;                    {&#xA;                        dtostrf(gps.location.lat(), 11, 6, clat);&#xA;                        dtostrf(gps.location.lng(), 11, 6, clng);&#xA;                        isGpsLocationValid = true;&#xA;                    }&#xA;                }   &#xA;             }&#xA;        } while (isGpsLocationValid == false);&#xA;        Serial.write(clat);&#xA;        Serial.println();&#xA;        Serial.write(clng);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when all is done, the clng value is printed twice in the serial monitor.&#xA;The value i get is in this format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;27.275869  15.151013&#xA;  15.151013&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, clng is printed twice. Any ideas why is that?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-20T17:03:41.723" Title="Serial.write() prints a variable twice" Tags="|serial|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3012" PostTypeId="1" CreationDate="2014-06-20T13:19:16.577" Score="2" ViewCount="1806" Body="&lt;p&gt;I am trying to modify this sketch;&#xA;&lt;a href=&quot;https://github.com/itsallvoodoo/home_automation/blob/master/Arduino_HVAC_Controller/HVAC_Controller/HVAC_Controller.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/itsallvoodoo/home_automation/blob/master/Arduino_HVAC_Controller/HVAC_Controller/HVAC_Controller.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have a different temperature sensor, a DHT11, and I am using the libraries from Adafruit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DHT11 can't be constantly polled, 1 second intervals is the maximum rate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working (fighting) with the portion towards the bottom in the section: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean getTemp() {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As my sketch stands, I have &quot;currentTemp&quot; statically assigned to 79 degrees. When I upload, the arduino acts as I would expect it to given that data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I change it to 0 (zero) and try to set the temp by reading the sensor in the section starting at line 237  like this; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean getTemp() {&#xA;&#xA;  currentTemp = 0;&#xA;  long temp = 0;&#xA;&#xA;  if ((millis() - TempLastCheck) &amp;gt; 2000) {&#xA;    TempLastCheck = millis();&#xA;    //  currentTemp = dht.readTemperature(true);&#xA;      temp = dht.readTemperature(true);&#xA;     Serial.println(dht.readTemperature(true));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The LCD is blank after it restarts, and the arduino triggers the &quot;heat&quot; relay because the temperature is 0 (zero)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure I'm missing something simple, because the DHT11 outputs floats, or something... I'm too new to this language to know what I'm missing. Any help will be greatly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// name:     HVAC_Controller.ino&#xA;// author:   Chad Hobbs&#xA;&#xA;&#xA;// -------------LIBRARIES---------------- THESE ARE REQUIRED TO BE IN YOUR SKETCHBOOK\LIBRARY FOLDER FOR COMPILING ----&#xA;#include &amp;lt;Wire.h&amp;gt;                   // Protocol to communicate with I2C devices&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;      // LCD protocol&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;  // LCD + Button shield protocol&#xA;#include &quot;DHT.h&quot;                // DHT11 Temp/Humidity Sensor &#xA;// --------------PARAMETERS---------------------&#xA;int heat = 55;                    // This is the default heater trigger temp setting&#xA;int cool = 70;                    // This is the default cooling trigger temp setting&#xA;int buffer = 1;                   // This is the range away from the setpoint the heat or AC will overcool/heat to prevent shorter cycles&#xA;int heatPin = 7;                  // Digital pin used for turning on the heater relay&#xA;int coolPin = 8;                  // Digital pin used for turning on the AC relay&#xA;int cycleTime = 60;               // The length of time to delay running the AC or heat to prevent short cycling&#xA;boolean heatRunning = false;      // Stores whether the heater is currently running or not&#xA;boolean coolRunning = false;      // Stores whether the AC is currently running or not&#xA;long currentTemp = 0;             // Current room temperature&#xA;&#xA;int serialSpeed = 9600;           // Default serial comm speed&#xA;long oldTemp = 0;                 // Used to only update the currentTemp if the temp has changed&#xA;unsigned long timeOut;            // Backlight timeout variable&#xA;boolean editable = false;         // Determines whether or not button presses will do anything, used to avoid accidental changes&#xA;char* menu[] = {&quot;Cooling&quot;, &quot;Heating&quot;};  // Menu display for either setting the high point or the low point of the temp range&#xA;int menuPosition = 1;             // Current position in the setting menu&#xA;unsigned long heatLastRan;        // Stores the time the heater last ran&#xA;unsigned long coolLastRan;        // Stores the time the AC last ran&#xA;unsigned long TempLastCheck;      // Stores the last sensor reading ran&#xA;&#xA;// -------------Library Interaction--------------&#xA;// Create our LCD Shield instance&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;#define ON 0x7            // For single color LCD, set on to white&#xA;#define OFF 0x0           // For single color LCD, set off to black&#xA;&#xA;#define DHTTYPE DHT11   // DHT 11 &#xA;#define DHTPIN 4     // what pin we're connected to&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;&#xA;// ----------------------------------------------------------------------------------------&#xA;// Function Name: setup()&#xA;// Parameters:    None&#xA;// Returns:       None&#xA;// Description:   This function executes housekeeping duties and staging for the loop() function; executed once&#xA;// ----------------------------------------------------------------------------------------&#xA;void setup() {&#xA;&#xA;  //  pinMode(busPin,INPUT);  // Designate temperature bus pin data direction&#xA;  pinMode(heatPin, OUTPUT);               // Heat circuit relay&#xA;  pinMode(coolPin, OUTPUT);               // Cooling circuit relay&#xA;  Serial.begin(serialSpeed);&#xA;&#xA;&#xA;  lcd.begin(16, 2);       // set up the LCD's number of columns and rows&#xA;  lcd.setBacklight(ON);   // Start off with backlight on until time-out&#xA;  timeOut = millis();     // Set the initial backlight time&#xA;  TempLastCheck = millis();  // Set the initial sensor timing&#xA;&#xA;  dht.begin();&#xA;}&#xA;&#xA;// ----------------------------------------------------------------------------------------&#xA;// Function Name: loop()&#xA;// Parameters:    None&#xA;// Returns:       None&#xA;// Description:   This is the main executing block of the program, calling all ancillary functions to operate the Arduino&#xA;// ----------------------------------------------------------------------------------------&#xA;void loop() {&#xA;  if ((millis() - timeOut) &amp;gt; 30000) {                   // Turn on backlight for 30 seconds, else turn it off&#xA;    lcd.setBacklight(OFF);&#xA;    editable == false;&#xA;  } else {&#xA;    lcd.setBacklight(ON);&#xA;  }&#xA;&#xA;  lcd.setCursor(0, 1);                  // Starting position of character printing&#xA;&#xA;  uint8_t buttons = lcd.readButtons();  // Constantly check to see if something has been put on the bus&#xA;&#xA;  // --------------Handle updating Temp Change Display---------------------&#xA;  if (getTemp()) {                      // Constantly check to see if the temperature has changed, and update appropriately&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Temp:&quot;);&#xA;    lcd.print(currentTemp);&#xA;  }&#xA;&#xA;  // --------------Handle Button Presses---------------------&#xA;  if (buttons) {&#xA;    timeOut = millis();&#xA;    lcd.setBacklight(ON);&#xA;&#xA;&#xA;    if (buttons &amp;amp; BUTTON_SELECT) {      // Allow parameters to be changed only if the Select button has been pressed first&#xA;      editable = true;&#xA;    }&#xA;    if (editable) {                     // go to buttonHandler to handle menu switching and parameter manipulations&#xA;      buttonHandler(buttons);&#xA;    }&#xA;  }&#xA;&#xA;  // --------------Handle Heat and Cooling Cycles---------------------&#xA;  powerControl();&#xA;&#xA;}&#xA;&#xA;// ----------------------------------------------------------------------------------------&#xA;// Function Name: powerControlHandler()&#xA;// Parameters:    None&#xA;// Returns:       None&#xA;// Description:   This function will handle turning AC or Heat off and on based on current temp, timers, and setpoints&#xA;// ----------------------------------------------------------------------------------------&#xA;void powerControl() {&#xA;&#xA;  // TODO: Add in fan relay control&#xA;&#xA;&#xA;  // This executes if the heater is running and it gets warm enough to turn off.&#xA;  if (heatRunning &amp;amp;&amp;amp; (currentTemp &amp;gt; (heat + buffer))) {&#xA;    heatRunning = false;&#xA;    heatLastRan = millis();&#xA;    digitalWrite(heatPin, HIGH);&#xA;    return;&#xA;  }&#xA;&#xA;  // This executes if the AC is running and it gets cool enough to turn off&#xA;  if (coolRunning &amp;amp;&amp;amp; (currentTemp &amp;lt; (cool - buffer))) {&#xA;    coolRunning = false;&#xA;    coolLastRan = millis();&#xA;    digitalWrite(coolPin, HIGH);&#xA;    return;&#xA;  }&#xA;&#xA;  // This executes if it gets cold enough and the heater has not run for a minimum time (short cycle protection)&#xA;  if ((currentTemp &amp;lt; heat) &amp;amp;&amp;amp; ((millis() - heatLastRan) &amp;gt; cycleTime)) {&#xA;    digitalWrite(heatPin, HIGH);&#xA;    heatRunning = true;&#xA;    return;&#xA;  }&#xA;&#xA;  // This executes if it gets hot enough and the AC has not run for 10 minutes (short cycle protection)&#xA;  if ((currentTemp &amp;gt; cool) &amp;amp;&amp;amp; ((millis() - coolLastRan) &amp;gt; 60)) {&#xA;    digitalWrite(coolPin, HIGH);&#xA;    coolRunning = true;&#xA;    return;&#xA;  }&#xA;&#xA;  return;&#xA;}&#xA;&#xA;&#xA;// ----------------------------------------------------------------------------------------&#xA;// Function Name: buttonHandler()&#xA;// Parameters:    None&#xA;// Returns:       Boolean, True if the temperature has changed, else False&#xA;// Description:   This function polls the temp sensors, retrieves the values, and then returns&#xA;// ----------------------------------------------------------------------------------------&#xA;boolean buttonHandler(uint8_t buttons) {&#xA;&#xA;  // --------------PARAMETERS---------------------&#xA;  int heatModifier = 0;&#xA;  int coolModifier = 0;&#xA;&#xA;&#xA;  // --------------SETUP---------------------&#xA;  lcd.clear();&#xA;&#xA;  // If the UP Button is pushed, increasing the setpoint&#xA;  if (buttons &amp;amp; BUTTON_UP) {&#xA;    if (menuPosition == 0) {&#xA;      coolModifier = 1;&#xA;    }&#xA;    if (menuPosition == 1) {&#xA;      heatModifier = 1;&#xA;    }&#xA;  }&#xA;&#xA;  // If the Down Button is pushed, decreasing the setpoint&#xA;  if (buttons &amp;amp; BUTTON_DOWN) {&#xA;    if (menuPosition == 0) {&#xA;      coolModifier = -1;&#xA;    }&#xA;    if (menuPosition == 1) {&#xA;      heatModifier = -1;&#xA;    }&#xA;  }&#xA;&#xA;  // If the Left Button is pushed, change the menu context&#xA;  if (buttons &amp;amp; BUTTON_LEFT) {&#xA;    if (menuPosition == 1) {&#xA;      menuPosition = 0;&#xA;    } else {&#xA;      menuPosition = 1;&#xA;    }&#xA;  }&#xA;&#xA;  // If the Right Button is pushed, change the menu context&#xA;  if (buttons &amp;amp; BUTTON_RIGHT) {&#xA;    if (menuPosition == 1) {&#xA;      menuPosition = 0;&#xA;    } else {&#xA;      menuPosition = 1;&#xA;    }&#xA;  }&#xA;&#xA;  // If anything has been modified, update accordingly&#xA;  heat = heat + heatModifier;&#xA;  cool = cool + coolModifier;&#xA;&#xA;  // Print proper menu title and setpoint&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(menu[menuPosition]);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Setpoint: &quot;);&#xA;&#xA;  if (menuPosition == 0) {&#xA;    lcd.print(cool);&#xA;  }&#xA;  if (menuPosition == 1) {&#xA;    lcd.print(heat);&#xA;  }&#xA;&#xA;}&#xA;&#xA;// ----------------------------------------------------------------------------------------&#xA;// Function Name: getTemp()&#xA;// Parameters:    None&#xA;// Returns:       Boolean, True if the temperature has changed, else False&#xA;// Description:   This function polls the temp sensors, retrieves the values, and then returns&#xA;// ----------------------------------------------------------------------------------------&#xA;boolean getTemp() {&#xA;&#xA;  currentTemp = 79;&#xA;  long temp = 0;&#xA;&#xA;  if ((millis() - TempLastCheck) &amp;gt; 2000) {&#xA;    TempLastCheck = millis();&#xA;    //  currentTemp = dht.readTemperature(true);&#xA;     //temp = dht.readTemperature(true);&#xA;     Serial.println(dht.readTemperature(true));&#xA;  }&#xA;&#xA;  /////////////////////////////////////////////////////////////////////////////////////////////////////&#xA;  //  sensors.requestTemperatures(); // Send the command to the device to get temperatures&#xA;&#xA;  // Go through devices and read the temperatures&#xA;  //  for(int x = 0; x &amp;lt; numOfDevices; x++){&#xA;  //   temp = sensors.getTempF(addrs[x]);&#xA;  //  if(temp != currentTemp){&#xA;  //   currentTemp = temp;&#xA;  //    }&#xA;  //  }&#xA;  /////////////////////////////////////////////////////////////////////////////////////////////////////&#xA;  // Check to see if temperature has changed&#xA;  if (currentTemp != oldTemp) {&#xA;    oldTemp = currentTemp;&#xA;    return true;&#xA;  }&#xA;  else {&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2793" LastActivityDate="2014-06-21T11:50:33.910" Title="Trouble with variable types and integrating DHT11 temperature sensor" Tags="|programming|sensors|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3014" PostTypeId="1" CreationDate="2014-06-20T16:17:35.257" Score="1" ViewCount="3580" Body="&lt;p&gt;I am currently working on a project that requires communication between an android phone(galaxy s4) and an ATmega328 microprocessor. To connect these devices wirelessly I'm using an HC05 bluetooth module and to understand the connection I'm using pre-built arduino codes(turn LEDs on and off) and an android app called blueterm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This connection is established and able to transmit data when connected to the Arduino uno, but as soon as this chip is removed and connected to a standalone breadboard the connection fails. The standalone breadboard works fine and has been tested with many other projects and I have attached the breadboard connection below. The HC05 when connected to the breadboard changes the blinking pattern to notify the user it is connected but the serial connection is never made. Any help would be greatly appreciated, if any other information is needed feel free to ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/szHkd.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2876" LastEditorUserId="2876" LastEditDate="2014-06-20T18:05:39.243" LastActivityDate="2019-07-07T10:17:41.943" Title="Bluetooth module(HC05) works with Arduino Uno but not with breadboard (ATmega328)" Tags="|bluetooth|atmega328|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3015" PostTypeId="2" ParentId="3010" CreationDate="2014-06-20T17:03:41.723" Score="4" Body="&lt;p&gt;The width parameter to &lt;code&gt;dtostrf()&lt;/code&gt; is the width of the resulting string NOT including the null terminator. So you are overflowing the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[11];&#xA;char clng[11];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[12];&#xA;char clng[12];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it should work.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-06-20T17:03:41.723" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3016" PostTypeId="1" AcceptedAnswerId="3017" CreationDate="2014-06-21T02:16:48.240" Score="2" ViewCount="2593" Body="&lt;p&gt;I have an Arduino Ethernet shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;May I &lt;strong&gt;connect it to a machine that´s connected wirelessly to the internet&lt;/strong&gt; in order to get the arduino into the internet? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do I need to connect it &lt;strong&gt;only&lt;/strong&gt; to a router?&lt;/p&gt;&#xA;" OwnerUserId="2966" OwnerDisplayName="Rosamunda" LastActivityDate="2014-06-21T03:36:01.377" Title="Arduino Ethernet Shield: May I connect it to a PC connected to the internet via wifi?" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3017" PostTypeId="2" ParentId="3016" CreationDate="2014-06-21T03:36:01.377" Score="2" Body="&lt;p&gt;Assuming an Ethernet port on the PC, the Ethernet shield can be connected to it using an &lt;a href=&quot;http://en.wikipedia.org/wiki/Ethernet_crossover_cable&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ethernet &lt;strong&gt;crossover&lt;/strong&gt; cable&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xbJ3g.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;(&lt;em&gt;source: &lt;a href=&quot;http://en.wikipedia.org/wiki/File:Ethernet_MDI_crossover.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many recent PC network interfaces have automatic cross-over (&lt;a href=&quot;http://en.wikipedia.org/wiki/Medium_Dependent_Interface#Auto_MDI-X&quot; rel=&quot;nofollow noreferrer&quot;&gt;Auto MDI-X&lt;/a&gt;), with which even a regular (straight) Ethernet patch cable will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This merely addresses the &lt;strong&gt;physical Ethernet connectivity&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;strong&gt;actually routing IP packets&lt;/strong&gt; between the Arduino and the rest of the Internet, some software router or software bridge is required to run on the PC. Several open source routing products exist, especially for Linux and FreeBSD, but that is outside the scope of this StackExchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the Ethernet shield does not need a router, it an as well be hooked up to an Ethernet &lt;strong&gt;switch&lt;/strong&gt; or &lt;strong&gt;hub&lt;/strong&gt;. &lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2014-06-21T03:36:01.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3018" PostTypeId="2" ParentId="3012" CreationDate="2014-06-21T11:50:33.910" Score="1" Body="&lt;p&gt;First of, you read the temperature and put it into local variable &lt;code&gt;temp&lt;/code&gt;. You need to copy the value from &lt;code&gt;temp&lt;/code&gt; into &lt;code&gt;currentTemp&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, you are reading the temperature twice in a row. Once to assign it to &lt;code&gt;temp&lt;/code&gt; and again for the &lt;code&gt;Serial.println&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if ((millis() - TempLastCheck) &amp;gt; 2000) {&#xA;    TempLastCheck = millis();&#xA;    currentTemp = dht.readTemperature(true);&#xA;    Serial.println(currentTemp);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When setting the &lt;code&gt;currentTemp&lt;/code&gt; to 0 inside &lt;code&gt;getTemp&lt;/code&gt;, getTemp never return &lt;code&gt;true&lt;/code&gt;, because you initialized the value of &lt;code&gt;currentTemp&lt;/code&gt; with 0 (&lt;code&gt;long currentTemp = 0;&lt;/code&gt;). So it never changed, and the lcd is never updated. Just change it to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long currentTemp = -100;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-06-21T11:50:33.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3019" PostTypeId="2" ParentId="2980" CreationDate="2014-06-21T12:18:36.343" Score="3" Body="&lt;p&gt;If you have 4 pins available, you could use &lt;a href=&quot;http://en.wikipedia.org/wiki/Charlieplexing#Charlieplexing&quot; rel=&quot;nofollow noreferrer&quot;&gt;charlieplexing&lt;/a&gt; to selectively light up 12 led.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/bedxM.png&quot; alt=&quot;charlieplexing&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could use some IC. You could use the one Greg suggested. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use a shift-register. This requires only 2 or 3 pins, an will enable you to light up any one or more leds at the same time. Most have 8 outputs, but you can connect one to the other (daisychain), so with 2 shift-registers you can individually turn on/off 16 leds. You can easily control these using arduino's &lt;code&gt;shiftOut&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a port-expander using I2C to talk to it. More complicated, and a bit more expansive. But also more powerful. It will require only 2 pins (A4, and A5).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-06-21T12:18:36.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3020" PostTypeId="1" AcceptedAnswerId="3072" CreationDate="2014-06-21T13:10:52.310" Score="2" ViewCount="844" Body="&lt;p&gt;I am software programmer and hobby farmer. While I was working on a &lt;a href=&quot;http://en.wikipedia.org/wiki/Hydroponics&quot; rel=&quot;nofollow noreferrer&quot;&gt;hydroponic&lt;/a&gt; farming stuff, I had to use submersible pumps with timers. I don't want to buy timers that are actually a tedious scheduling process. so I am making one myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to toggle 230&amp;nbsp;V for turning a submersible pump(150-230&amp;nbsp;V and 18&amp;nbsp;W) ON/OFF. I read that Arduino may not able to supply enough input current that the relay requires. I am not sure about what transistor to use to amplify the input current. I came across a circuit diagram and a relay board. Do I still need to use a transistor and diode if I use this relay with an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;a href=&quot;http://www.ebay.in/itm/5V-2-Channel-Relay-Board-Module-10A-250AC-Opto-coupler-Arduino-Raspberry-Shield-/321432317541?pt=LH_DefaultDomain_203&amp;amp;hash=item4ad6dbee65&quot; rel=&quot;nofollow noreferrer&quot;&gt;two-channel relay&lt;/a&gt; I am about to use and the circuit is below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Fvat.jpg&quot; alt=&quot;Circuit to use relay with Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I follow the circuit if I am using this relay? The relay has a tolerance of 250&amp;nbsp;V. What if the voltage fluctuates above 250&amp;nbsp;V? I am going to use a 9&amp;nbsp;V battery to power the Arduino. Feel free to explain anything that I may have to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks marla for making it clear that I don't need diodes and transistors. Andy, as you said, I can't keep changing batteries often, and it will limit the system. Shall I use an adapter which reads output 5&amp;nbsp;V and 1&amp;nbsp;amperes? Will that drive the Arduino and be sufficient for both the relays?&lt;/p&gt;&#xA;" OwnerUserId="2883" OwnerDisplayName="codebrain" LastEditorUserId="510" LastEditDate="2014-06-27T20:03:56.413" LastActivityDate="2014-06-27T20:04:29.613" Title="Arduino Uno rev 3 toggling a 230 V submersible pump on intervals" Tags="|arduino-uno|relay|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3021" PostTypeId="1" CreationDate="2014-06-21T14:32:17.417" Score="2" ViewCount="308" Body="&lt;p&gt;I've done this laser trip wire:&#xA;&lt;a href=&quot;http://www.instructables.com/id/Another-Arduino-Laser-Tripwire/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Another-Arduino-Laser-Tripwire/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got it working, and now I'd like to send info to analytics - to measure how many times I enter the kitchen...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to take bits of code and add it to my code from:&#xA;&lt;a href=&quot;http://bigsnarf.wordpress.com/2013/12/24/arduino-sensor-python-and-google-analytics/&quot; rel=&quot;nofollow&quot;&gt;http://bigsnarf.wordpress.com/2013/12/24/arduino-sensor-python-and-google-analytics/&lt;/a&gt;&#xA;and one more which I can't post due to permissions....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but neither will work and adding this code breaks my basic functionality (I know as I measure it via the buzzer, it stops responding once I add this new code...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyone able to help?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is my basic working code for the laser trip wire that makes buzzer noise if someone walks through it:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Jonathan Robson Feb 09.&#xA;Laser tripwire activates a buzzer. adapted from&#xA;http://www.instructables.com/id/Arduino_Laser_Tripwire/&#xA;*/&#xA;&#xA;int buzzPin = 11; // buzzer connected to digital pin 11&#xA;&#xA;void setup() {&#xA;  pinMode(buzzPin, OUTPUT); // sets the digital pin as output&#xA;}&#xA;&#xA;void loop(){&#xA;  if(analogRead(0) &amp;lt; 850){ // this number depends on calibration of the photocell&#xA;    digitalWrite(buzzPin, HIGH); // turns buzzer on&#xA;    delay(1000); // waits for 1 second&#xA;    digitalWrite(buzzPin, LOW); // turns buzzer off&#xA;  } else{&#xA;    digitalWrite(buzzPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code with analytics additions I’ve added:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Jonathan Robson Feb 09.&#xA;Laser tripwire activates a buzzer. adapted from&#xA;http://www.instructables.com/id/Arduino_Laser_Tripwire/&#xA;*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[]     = {  0x0C, 0xD2, 0x92, 0xAC, 0x75, 0x0B };&#xA;&#xA;// To skip the DNS&#xA;IPAddress server(173,194,40,97); // www.google-analytics.com =&amp;gt; 173.194.40.97&#xA;EthernetClient client;&#xA;&#xA;int buzzPin = 11; // buzzer connected to digital pin 11&#xA;&#xA;&#xA;// Global switch (debug mode without API call)&#xA;boolean netword_enabled = true;&#xA;&#xA;int sendEventToGA() {&#xA;  int responseCode      = 0;&#xA;&#xA;  if (!netword_enabled) {&#xA;    return responseCode;  &#xA;  }&#xA;&#xA;  // open the connection&#xA;  if (client.connect(server, 80)) {&#xA;    int responseSize      = 0;&#xA;    int responseSizeMax   = 1024;&#xA;    char response[1024];&#xA;    String eventData = &quot;v=1&amp;amp;tid=UA-51525058-1&amp;amp;cid=123&amp;amp;t=event&amp;amp;ec=home%20movement&amp;amp;ea=door%20open&amp;amp;el=bedroom&quot;; // Refer to the Google documentation&#xA;&#xA;    Serial.println(&quot;Connection opened!&quot;);&#xA;&#xA;    // Write the HTTP request to the Client    &#xA;    client.println(&quot;POST /collect HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.google-analytics.com&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(eventData.length());&#xA;    client.println(&quot;Content-Type:application/x-www-form-urlencoded&quot;);&#xA;    client.println();&#xA;    client.println(eventData);&#xA;&#xA;    Serial.println(&quot;Request sent.&quot;);&#xA;&#xA;    // Wait a little bit&#xA;    delay(1000);&#xA;&#xA;    // Read the response, looking for the Response Code.&#xA;    while (client.available() &amp;amp;&amp;amp; client.connected() &amp;amp;&amp;amp; responseCode &amp;lt; 100 &amp;amp;&amp;amp; responseSize &amp;lt; responseSizeMax) {   &#xA;&#xA;      response[responseSize] = client.read();&#xA;      responseSize++;&#xA;      response[responseSize] = '\0'; // Set manualy the end of string char&#xA;&#xA;      // Here is the magic!&#xA;      sscanf (response, &quot;HTTP/1.%*d %d&quot;, &amp;amp;responseCode);&#xA;&#xA;      Serial.print(&quot;HTTP code &quot;);&#xA;      Serial.print(responseCode);&#xA;      Serial.print(&quot; founded in &quot;);&#xA;      Serial.println(response);&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(&quot;End of communications.&quot;);&#xA;&#xA;  client.stop();&#xA;  return responseCode;&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(buzzPin, OUTPUT); // sets the digital pin as output&#xA;  Serial.begin(9600);&#xA;&#xA;  // start the Ethernet connection&#xA;  if (netword_enabled &amp;amp;&amp;amp; Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    for(;;)&#xA;      ;&#xA;  }&#xA;&#xA;  // give the Ethernet shield a second to initialize:&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop(){&#xA;  int responseCode;&#xA;  if(analogRead(0) &amp;lt; 850){ // this number depends on calibration of the photocell&#xA;    digitalWrite(buzzPin, HIGH); // turns buzzer on&#xA;    responseCode = sendEventToGA();&#xA;    delay(1000); // waits for 1 second&#xA;    digitalWrite(buzzPin, LOW); // turns buzzer off&#xA;  } else{&#xA;    digitalWrite(buzzPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2884" LastEditorUserId="42" LastEditDate="2015-04-18T10:04:17.627" LastActivityDate="2018-02-25T13:30:09.743" Title="Arduino Laser Trip Wire with Analytics" Tags="|arduino-uno|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3023" PostTypeId="1" AcceptedAnswerId="3025" CreationDate="2014-06-21T18:16:38.353" Score="3" ViewCount="3514" Body="&lt;p&gt;I have an Arduino Duemilanove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://arduino.cc/en/Tutorial/StringAdditionOperator&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; on string concatenation. Yet, it didn't include my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a non constant character array, that later gets a value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[11];&#xA;dtostrf(gps.location.lat(), 11, 6, clat);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to output this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Latitude: 20.653425&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically I want a final string that contains: &quot;Latitude:&quot; + the value of the nonconstant array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="4628" LastEditDate="2017-06-22T15:02:42.093" LastActivityDate="2017-06-22T15:02:42.093" Title="Concatenation of non constant character array with a string" Tags="|programming|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3024" PostTypeId="2" ParentId="3023" CreationDate="2014-06-21T19:43:27.257" Score="3" Body="&lt;p&gt;It's possible and very easy to do. You can convert a character array to a string object with the &lt;code&gt;String(char_array_name_here)&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this you can just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String output = &quot;Latitude: &quot; + String(clat);  //Make sure to add a space so it's not &quot;Latitude:20.653425&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do this with any string, just remove the &lt;code&gt;String()&lt;/code&gt; part because you don't need to convert a string to a string!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note: you can just do this code if you're outputting it to the serial console:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Latitude: &quot; + clat);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Summary of edits: found a function I was searching for yesterday but couldn't find. Much simpler&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Other links:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/StringObject&lt;/a&gt;: main documentation for the string datatype&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/StringAdditionOperator&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/StringAdditionOperator&lt;/a&gt; how to append data to a string&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-06-22T21:08:56.193" LastActivityDate="2014-06-22T21:08:56.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3025" PostTypeId="2" ParentId="3023" CreationDate="2014-06-21T19:52:14.507" Score="6" Body="&lt;pre&gt;&lt;code&gt;char clat[10+11+1] = &quot;Latitude: &quot;;&#xA;dtostrf(gps.location.lat(), 11, 6, clat+10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you've named the buffer 'clat' I'm assuming it will always be used for latitude, so we've pre-initialized its size and contents, and we know where to begin the latitude value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, don't forget to size string buffers one more byte than the length of the maximum length string you intend to put in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 6/23/14:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your other question and your comment to this answer, I'll revise my suggestion to this. The ..printf() functions are particularly easy to use, saves you (mis)counting buffer positions, and don't add much lot more code than the Serial() object already includes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char outbuf[40+1];      // wider than nec, easier than counting&#xA;char clat[15+1]; clong[15+1]; // workspaces&#xA;&#xA;sprintf(outbuf, &quot;Latitude/Longitude: %s %s&quot;,&#xA;    dtostrf(gps.location.lat(), 10, 6, temp),&#xA;    dtostrf(gps.location.lng(), 10, 6, temp) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works because dtostrf() returns the address of the buffer you gave it; sprintf then takes that string (two of them in this case) when building your final output string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The printf() functions are often deprecated for embedded systems. They're large (but see my comment about that above); and they're non-reentrant, so don't do that! In these low-end systems we don't often multi-thread anyway - just be aware of that if you do. And even if you have to remove them later and go back to printing piece by piece, they can save you a lot of headaches during development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another way that avoids both printf and the 32 bytes of work buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char outbuf[40+1];&#xA;&#xA; strcpy(outbuf, &quot;Latitude/Longitude: &quot;);&#xA; dtostrf(gps.location.lat(), 12, 6, outbuf+strlen(outbuf));&#xA; dtostrf(gps.location.lng(), 12, 6, outbuf+strlen(outbuf));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can't initialize outbuf unless it is 1) static, and 2) not going to be used more than once, since its initial conditions won't be the same the second time around. I've increased the field-widths of dostrf() to be sure the outputs of the won't be run-together for large values.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-06-23T17:09:24.160" LastActivityDate="2014-06-23T17:09:24.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3027" PostTypeId="1" CreationDate="2014-06-22T16:16:32.107" Score="3" ViewCount="491" Body="&lt;p&gt;I'm working with Arduino Due and I have a sensor that outputs a square signal with voltages in the range of 0-5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Due specs there is a warning that says: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Providing higher voltages, like 5V to an I/O pin could damage the board.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to connect it to the board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2897" LastActivityDate="2014-06-22T16:57:19.957" Title="Input a signal from a sensor to an Arduino Due" Tags="|sensors|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3028" PostTypeId="2" ParentId="3027" CreationDate="2014-06-22T16:57:19.957" Score="2" Body="&lt;p&gt;This is a tough one. If it was digital IO sensor, a simple level shifter would suffice. However, since it's analog, you have limited options.&lt;/p&gt;&#xA;&lt;p&gt;The cheapest route (and the easiest) would be to use a voltage divider. They only take two resistors, and they divide linearly. That means 1/2 of 5V would be divided into 1/2 of 3.3V. You can then  use the full range of the Due (be careful not to use 0-1023, as it has a 12 bit ADC: it'll give you weird numbers).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;More on voltage dividers&lt;/a&gt;. &lt;a href=&quot;https://learn.sparkfun.com/tutorials/voltage-dividers/all?print=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Even more on voltage dividers&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To build one:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/teuuJ.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;From Sparkfun (link at bottom)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That's four different ways to build one. R1 would be 1700 ohms and R2 would be 3300 ohms. Vin would be from the sensor and Vout would be to the Due.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-06-22T16:57:19.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3029" PostTypeId="1" AcceptedAnswerId="3030" CreationDate="2014-06-22T17:47:37.207" Score="2" ViewCount="8390" Body="&lt;p&gt;Some days ago i started a thread.&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3023/concatenation-of-non-constant-character-array-with-a-sting&quot;&gt;concatenation of non constant character array with a sting&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a different question but on the same nature (string and chars)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what i want is one variable (string or char) that will hold a standard text and the value of gps coordinates latitude and longitude&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format is this: &quot;latitude/longitude: 30.111111 20.111111&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i have is a char that holds the standard text and the latitude: &quot;Latitude/Longitude: 30.111111&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have another char that holds the second value (longitude)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chars were generated with dtostrf():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[10 + 20 + 1] = &quot;Latitude/Longitude: &quot;;&#xA;char clng[10 + 1];&#xA;dtostrf(gps.location.lat(), 10, 6, clat+20);&#xA;dtostrf(gps.location.lng(), 10, 6, clng);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can also make the chars strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string1 = String(clat);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What have i tried:&#xA;1.Assigning clng to clat directly via dtostrf()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[10 + 20 + 10 + 1] = &quot;Latitude/Longitude: &quot;;&#xA;dtostrf(gps.location.lng(), 10, 6, clng+31);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It didnt work and got unexpected output&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;making clat a string and assign clng via for loop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;string1 = String(clat);&#xA;    for (int i=0; i&amp;lt;10; i++)&#xA;    string1[i+32]=clng[i];&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This doesnt append it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I run out of ideas here.&#xA;Any help from more experienced guys?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="1499" LastEditDate="2014-06-23T01:20:08.430" LastActivityDate="2014-06-23T01:20:08.430" Title="appending string to char and vice versa" Tags="|programming|string|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3030" PostTypeId="2" ParentId="3029" CreationDate="2014-06-22T18:05:13.593" Score="1" Body="&lt;p&gt;solved it. was simple actually. dont know how to do it with chars, but with strings there is the addition operator.&#xA;So i converted both to string and used the + operator.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[10 + 20 + 1] = &quot;Latitude/Longitude: &quot;;&#xA;char clng[10 + 1];&#xA;String string1, string2, finalstr;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and inside the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dtostrf(gps.location.lat(), 10, 6, clat+20);&#xA;dtostrf(gps.location.lng(), 10, 6, clng);&#xA;string1 = String(clat);&#xA;string2 = String(clng);&#xA;finalstr = string1 + string2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe that was too much work?&#xA;If you have any smarter alternatives, please provide!&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-22T18:05:13.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3031" PostTypeId="1" CreationDate="2014-06-22T20:18:13.453" Score="1" ViewCount="316" Body="&lt;p&gt;I want to use the GSM shield. For my project, I will hook it up directly to pins &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt; (TX/RX). Will it work right away? Do I have to know which is TX and which RX and declare it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will not be using SoftwareSerial.&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="220" LastEditDate="2014-06-22T20:21:29.400" LastActivityDate="2014-06-22T20:24:28.323" Title="Duemilanove serial TX/RX: which is what?" Tags="|serial|arduino-duemilanove|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3032" PostTypeId="2" ParentId="3031" CreationDate="2014-06-22T20:24:28.323" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I will not be using SoftwareSerial&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That means you'll use the standard &lt;code&gt;Serial()&lt;/code&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I have to[...] declare it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not if you use the standard &lt;code&gt;Serial.begin()&lt;/code&gt; instruction. The Duemilanove uses pins 0/1 automatically for TX/RX&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I have to know which is TX and which RX?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Kinda... you have to know which one is which so you wire it correctly. The TX of the board should go to the RX of the GSM shield, and vice versa. Pin 0 is RX and 1 is TX.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-06-22T20:24:28.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3034" PostTypeId="2" ParentId="3029" CreationDate="2014-06-22T21:19:00.650" Score="1" Body="&lt;p&gt;One thing I noticed is you do not need the &lt;code&gt;+&lt;/code&gt; in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[10 + 20 + 1] = &quot;Latitude/Longitude: &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char clat[31] = &quot;Latitude/Longitude: &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A much simpler way to do this is this:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables to initialize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char subfinal[40] = &quot;Latitude/Longitude: &quot;;&#xA;String final = &quot;&quot;; //You don't need this, you could always use `String(subfinal)` instead&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code inside a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dtostrf(gps.location.lat(), 10, 6, subfinal+10);&#xA;subfinal[29] = &quot; &quot;;&#xA;dtostrf(gps.location.lng(), 10, 6, subfinal+30);&#xA;final = String(subfinal);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it, so let me know if it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-06-22T22:27:07.073" LastActivityDate="2014-06-22T22:27:07.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3035" PostTypeId="1" AcceptedAnswerId="3036" CreationDate="2014-06-22T21:46:59.360" Score="2" ViewCount="72" Body="&lt;p&gt;I am having some issues with a simple circuit. I would expect this circuit to light up this LED constantly when the Arduino is plugged in. I have the &lt;a href=&quot;http://arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot;&gt;Blink&lt;/a&gt; tutorial sketch loaded, but I don't think that should matter with the pins I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I think I have going on: Arduino 5V Power --&gt; BB power --&gt; 100 Ohm resistor --&gt; BB line 25 --&gt; &lt;a href=&quot;https://www.sparkfun.com/products/11121&quot; rel=&quot;nofollow&quot;&gt;this LED&lt;/a&gt; --&gt; BB line 30 --&gt; BB Ground --&gt; Arduino Ground&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check out this picture for confirmation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14482775884&quot; rel=&quot;nofollow&quot; title=&quot;Arduino Question by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5478/14482775884_81a101e1b7.jpg&quot; alt=&quot;Arduino Question&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help that you can provide!&lt;/p&gt;&#xA;" OwnerUserId="2838" LastEditorUserId="2839" LastEditDate="2014-06-22T22:01:11.340" LastActivityDate="2014-06-22T22:02:25.813" Title="Issues with a basic circuit" Tags="|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3036" PostTypeId="2" ParentId="3035" CreationDate="2014-06-22T22:02:25.813" Score="6" Body="&lt;p&gt;Figured it out - stupid mistake as expected. The power and ground lines on my bread board don't go all the way across. They break right in the middle, as the lines show. I moved my ground connection to the left a few slots and it worked. Thanks for working through it with me jfpoilpret!&lt;/p&gt;&#xA;" OwnerUserId="2838" LastActivityDate="2014-06-22T22:02:25.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3037" PostTypeId="1" AcceptedAnswerId="3038" CreationDate="2014-06-23T02:44:21.150" Score="2" ViewCount="1463" Body="&lt;p&gt;I am testing a &lt;a href=&quot;http://www.ti.com/lit/ds/schs209c/schs209c.pdf&quot; rel=&quot;nofollow&quot;&gt;74HC4067E MUX&lt;/a&gt; setup with my Arduino Uno which I would like to use to selectively light up many LEDs, one at a time. For this first test, I am using a modified version of the &lt;a href=&quot;http://arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot;&gt;blink tutorial&lt;/a&gt;. Essentially, I am setting the 4 control pins to digital LOW and setting the input to HIGH, through a resistor appropriate for my LED. I am also providing 5V to the Vcc pin on the MUX. I don't really know why I am doing this, but it seems to work. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led_input = 0;&#xA;int led_ctrl_1 = 1;&#xA;int led_ctrl_2 = 2;&#xA;int led_ctrl_3 = 3;&#xA;int led_ctrl_4 = 4;&#xA;&#xA;void setup() {                &#xA;    pinMode(led_input, OUTPUT);  &#xA;    pinMode(led_ctrl_1, OUTPUT);  &#xA;    pinMode(led_ctrl_2, OUTPUT);  &#xA;    pinMode(led_ctrl_3, OUTPUT);  &#xA;    pinMode(led_ctrl_4, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;    // control signal&#xA;    digitalWrite(led_ctrl_1, LOW);&#xA;    digitalWrite(led_ctrl_2, LOW);&#xA;    digitalWrite(led_ctrl_3, LOW);&#xA;    digitalWrite(led_ctrl_4, LOW);&#xA;&#xA;    // input signal&#xA;    digitalWrite(led_input, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(led_input, LOW);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I know, the code could be more efficient.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blue LED is hooked up to I0 and blinks as it should. The problem comes when I try to change the control pin values. When I change it to, say 6...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// control signal&#xA;digitalWrite(led_ctrl_1, LOW);&#xA;digitalWrite(led_ctrl_2, HIGH);&#xA;digitalWrite(led_ctrl_3, HIGH);&#xA;digitalWrite(led_ctrl_4, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and I move my LED to I6, I get no blink. I've tested all the pins and it doesn't seem like there is a signal coming from any of them. I assume that I am using the chip wrong, but I'm not sure how. Pictures of my setup follow... any help is greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino pin 0 maps to chip pin 1 (through resistor) as input.&lt;/li&gt;&#xA;&lt;li&gt;Arduino pins 1-4 map to chip pins 10, 11, 14, and 13 in that order.&lt;/li&gt;&#xA;&lt;li&gt;I have a 5V going to chip pin 24.&lt;/li&gt;&#xA;&lt;li&gt;The LED is connected long leg to chip pin 9 in the images, the grounded.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14484539664&quot; rel=&quot;nofollow&quot; title=&quot;IMG_20140622_221940 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm3.staticflickr.com/2898/14484539664_0d67922a44.jpg&quot; alt=&quot;IMG_20140622_221940&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14505899703&quot; rel=&quot;nofollow&quot; title=&quot;IMG_20140622_221954 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5531/14505899703_d77567e6f9.jpg&quot; alt=&quot;IMG_20140622_221954&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14299200018&quot; rel=&quot;nofollow&quot; title=&quot;IMG_20140622_222012 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm3.staticflickr.com/2913/14299200018_60102f3c40.jpg&quot; alt=&quot;IMG_20140622_222012&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2838" LastActivityDate="2014-06-23T02:59:20.657" Title="Controlling an LED with the 74HC4067E multiplexer" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3038" PostTypeId="2" ParentId="3037" CreationDate="2014-06-23T02:59:20.657" Score="2" Body="&lt;p&gt;Pin 15 on that MUX is the enable pin, you need to tie it to ground. Otherwise, it's just floating, and it only would have worked by accident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you state:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am also providing 5V to the Vcc pin on the MUX. I don't really know why I am doing this, but it seems to work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The chip needs power to work. The Vcc pin is where you give it the +5V power. Without that, it might still work, but only by accident and depending on the inputs on the other pins.&lt;/p&gt;&#xA;" OwnerUserId="2839" LastActivityDate="2014-06-23T02:59:20.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3039" PostTypeId="1" AcceptedAnswerId="3049" CreationDate="2014-06-23T08:38:35.343" Score="6" ViewCount="6598" Body="&lt;p&gt;I'm implementing a filter for my IMU Sensor and thus I want close to real time data visualized on the computer. I use binary serial communication to facilitate the sending part for the arduino (as far as I know the serial.print is pretty slow). So I split my int16_t in two bytes and send it, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write((uint8_t)(gx &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gx &amp;amp; 0xFF));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that i directly send the next number (3 in total by now, maybe up to 7 2byte numbers in the future).&#xA;I read the thing in matlab with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dt(k) = toc;&#xA;tic;&#xA;bindata([1:6],k) = fread(s,[6,1],'int8');&#xA;time = cumsum(dt(1:k));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which reads 6 bytes (3 numbers) and then I recalculate the binary representation, concatenate them and get the original number (if someone can suggest an easier way.. I found matlab pretty unhandy here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, that the numbers get mixed by the time. Somewhen one byte isn't read or anything, so the bytes get messed up and a nonsense number is produced.One full number (2byte) is skipped for one sample exactly. Instead of this number one number is there twice. The next sample the order is messed up (shifted, such that the first number is second). This process appears after maybe 30 sec, sometimes a few minutes. After the first time it keeps shifting and jumping around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me, what to do here? Can I include some 'breakpoint'/line terminator, where the reader (matlab) knows, that we are at the start of the first number? Or how is this done actually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I have to add my main goal: I want to make the sending as fast for the arduino as possible. No extra calculations should be necessary (if possible).&#xA;And: the reason for these shifts seems to be the some time delay (slowness). I suspect it to be a slow matlab reading, since I saw fluent processing scripts in HIL reading. The errors have stopped however, since I turned the baude rate down. Only wrong numbers are the problem still.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May there be a possibility to loop around the fread and read just store the values after an added 'header'? So let's say a wrong ordering occures. Then I discard everything until the next 'a' char/byte and use the following 6 bytes to produce my 3 values. Then I wait for an 'a' again. For that I would have to loop fread(s,[1,1],'int8'); and search for the header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Program to send the gyro/accel data via serialport&#xA;// corresponding matlab programs: sensing.m and sensing_binary.m&#xA;// 2 security loops to guarantee a constant sampling time&#xA;&#xA;// #define DEBUG&#xA;#include &quot;GY86.h&quot;&#xA;#include &quot;Wire.h&quot;&#xA;&#xA;GY86 gy86;&#xA;int16_t ax, ay, az;&#xA;int16_t gx, gy, gz;&#xA;&#xA;uint32_t currenttime = 0;&#xA;uint32_t starttime = 0;&#xA;uint32_t starttime2 = 0;&#xA;&#xA;// #define OUTPUT_ACCEL_COUNTS&#xA;#define OUTPUT_GYRO_COUNTS&#xA;&#xA;// #define OUTPUT_ACCEL_BINARY&#xA;// #define OUTPUT_GYRO_BINARY&#xA;&#xA;&#xA;void setup () {&#xA;  Serial.begin(9600);&#xA;  gy86.setup();&#xA;}&#xA;&#xA;&#xA;void loop () {&#xA;  currenttime = millis();&#xA;  if (currenttime-starttime &amp;gt; 9)&#xA;  {&#xA;    while (micros()-starttime2 &amp;lt; 9000) { }&#xA;    starttime2 = micros();&#xA;&#xA;    // read raw accel/gyro measurements from device&#xA;    gy86.getSensorValues(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;    // testing constants&#xA;    // gx = -29;&#xA;    // gy = 245;&#xA;    // gz = 17;&#xA;&#xA;#ifdef OUTPUT_GYRO_COUNTS&#xA;    Serial.print((int)gx); Serial.print(F(&quot;\t&quot;));&#xA;    Serial.print((int)gy); Serial.print(F(&quot;\t&quot;));&#xA;    Serial.print((int)gz); Serial.print(F(&quot;\t&quot;));&#xA;#endif&#xA;#ifdef OUTPUT_ACCEL_COUNTS&#xA;    Serial.print(ax);   Serial.print(F(&quot;\t&quot;));&#xA;    Serial.print(ay);   Serial.print(F(&quot;\t&quot;));&#xA;    Serial.println(az); Serial.print(F(&quot;\t&quot;));&#xA;#endif&#xA;#if defined(OUTPUT_ACCEL_COUNTS) || defined(OUTPUT_GYRO_COUNTS)&#xA;    Serial.print(F(&quot;\n&quot;));&#xA;#endif&#xA;&#xA;#ifdef OUTPUT_ACCEL_BINARY&#xA;    Serial.write((uint8_t)(ax &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(ax &amp;amp; 0xFF));&#xA;    Serial.write((uint8_t)(ay &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(ay &amp;amp; 0xFF));&#xA;    Serial.write((uint8_t)(az &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(az &amp;amp; 0xFF));&#xA;#endif&#xA;#ifdef OUTPUT_GYRO_BINARY&#xA;    Serial.write((uint8_t)(gx &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gx &amp;amp; 0xFF));&#xA;    Serial.write((uint8_t)(gy &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gy &amp;amp; 0xFF));&#xA;    Serial.write((uint8_t)(gz &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gz &amp;amp; 0xFF));&#xA;#endif&#xA;&#xA;    starttime = currenttime;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2014-06-24T17:55:32.753" LastActivityDate="2014-06-30T13:56:13.173" Title="Binary serial transmission order of data" Tags="|serial|sensors|matlab|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3040" PostTypeId="1" AcceptedAnswerId="3046" CreationDate="2014-06-23T08:58:57.203" Score="2" ViewCount="576" Body="&lt;p&gt;first of all, I'm kindly apologizing for asking such stupid questions, but as my electronic-knowledge is dramatically limited, you are my only hope to get my problem solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty new to Arduino and my plans are to stack a lcd shield on a motor shield, which is stacked on the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup would be the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino MEGA2560&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;LCD-Shield &lt;a href=&quot;http://www.sainsmart.com/arduino/arduino-shields/lcd-shields/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html&quot; rel=&quot;nofollow&quot;&gt;http://www.sainsmart.com/arduino/arduino-shields/lcd-shields/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Motor-Shield &lt;a href=&quot;http://www.sainsmart.com/arduino/arduino-shields/motor-shields/sainsmart-l293d-motor-drive-shield-for-arduino-duemilanove-mega-uno-r3-avr-atmel.html&quot; rel=&quot;nofollow&quot;&gt;http://www.sainsmart.com/arduino/arduino-shields/motor-shields/sainsmart-l293d-motor-drive-shield-for-arduino-duemilanove-mega-uno-r3-avr-atmel.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My target is to enter specific values trough the LCD-shield (with its buttons) and to control a stepper-motor related to those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to my question: Can I realize my project with the mentioned parts and are the two shields stackable (with head extentions on the motor-shield) without creating interferences?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much for your time and answers in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;irie&lt;/p&gt;&#xA;" OwnerUserId="2901" LastActivityDate="2014-06-23T20:02:24.473" Title="Are these lcd and motor-shields stackable?" Tags="|arduino-mega|shields|motor|lcd|arduino-motor-shield|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3041" PostTypeId="1" AcceptedAnswerId="3044" CreationDate="2014-06-23T09:40:03.153" Score="7" ViewCount="3932" Body="&lt;p&gt;SerialGSM is a library for simplifying GSM shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is sample code for sending SMS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SerialGSM.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SerialGSM cell(2,3);&#xA;void setup(){&#xA; Serial.begin(9600);&#xA; cell.begin(9600);&#xA;  cell.Verbose(true);&#xA;  cell.Boot();&#xA;  cell.FwdSMS2Serial();&#xA;  cell.Rcpt(&quot;+972123456789&quot;);&#xA;  cell.Message(&quot;hello world&quot;);&#xA;  cell.SendSMS();&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  if (cell.ReceiveSMS()){&#xA;    Serial.println(cell.Message());&#xA;    cell.DeleteAllSMS();&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, he uses software serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I intend to use this for my school thesis, but I am using a shield, so I won't be using Software Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What bothers me is this line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SerialGSM cell(2,3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my case, do I declare it like this?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SerialGSM cell(0,1); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or will there be conflicts with serial? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: In other words, how do I declare the SeralGSM object using hardware serial and not software serial?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="6936" LastEditDate="2015-07-30T21:14:33.713" LastActivityDate="2017-09-05T07:23:23.063" Title="SerialGSM for GSM shield without SoftwareSerial" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3042" PostTypeId="1" CreationDate="2014-06-23T08:22:23.377" Score="7" ViewCount="30712" Body="&lt;p&gt;If I remove the transmission code from slave this works properly but I need to transmit from slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my master code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;void setup() {&#xA;  Wire.begin(3); &#xA;  Wire.onReceive(receiveEvent);&#xA;}&#xA;byte x = 0;&#xA;&#xA;void loop() {&#xA;  Wire.beginTransmission(9); &#xA;  Wire.write(&quot;s&quot;);        &#xA;  Wire.write(x);                &#xA;  Wire.endTransmission();    &#xA;  x++;&#xA;  delay(500);&#xA;}&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  if(Wire.available()){&#xA;    int x = Wire.read();&#xA;    Serial.println(x);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my slave code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;void setup() {&#xA;  Wire.begin(9);                // join i2c bus with address #9&#xA;  Wire.onReceive(receiveEvent); // register event&#xA;  Serial.begin(9600);           // start serial for output&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(100);&#xA;}&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  if(Wire.available()){&#xA;    char c = Wire.read(); &#xA;    Serial.print(c);&#xA;    if(c == 's'){&#xA;      int x = Wire.read();&#xA;      Serial.println(x);&#xA;      //transmit to master &#xA;      Wire.beginTransmission(3);&#xA;      Wire.write(1);&#xA;      Wire.endTransmission();&#xA;    } else {&#xA;      Wire.read();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible not to use Wire.onRequest(requestCallback); to send data to master? Kindly help.&lt;/p&gt;&#xA;" OwnerUserId="2907" OwnerDisplayName="srinivas" LastEditorUserId="4628" LastEditDate="2015-08-30T20:37:05.687" LastActivityDate="2015-09-30T07:34:08.077" Title="I2C 2 way communication between Arduino Uno and Arduino Mega" Tags="|arduino-uno|arduino-mega|i2c|avr|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3044" PostTypeId="2" ParentId="3041" CreationDate="2014-06-23T15:41:07.443" Score="5" Body="&lt;p&gt;&lt;code&gt;SerialGSM&lt;/code&gt; is designed to work with software serial, as you can see that from the class declaration in the &lt;code&gt;SerialGSM.h&lt;/code&gt; header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class SerialGSM : public SoftwareSerial {&#xA;...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, changing it to use hardware serial is more complicated than it looks. There are two potential ways you could go about it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Derive from &lt;code&gt;HardwareSerial&lt;/code&gt; instead of &lt;code&gt;SoftwareSerial&lt;/code&gt;. This would give you flexibility, but you'd have to take care of passing all the right data to the &lt;code&gt;HardwareSerial&lt;/code&gt; constructor, which is quite messy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't derive from anything. Use the global &lt;code&gt;Serial&lt;/code&gt; object, and manually replace all serial function calls with their &lt;code&gt;Serial.xxx()&lt;/code&gt; equivalents. This is probably easier, but it restricts you to a specific serial port.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both approaches involve quite a lot of coding, so they aren't trivial tasks. It's also important to note that &lt;code&gt;SerialGSM&lt;/code&gt; currently uses the global &lt;code&gt;Serial&lt;/code&gt; object to output debug information. You'd have to remove or modify that before converting to hardware serial, or else it could interfere.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-23T15:41:07.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3046" PostTypeId="2" ParentId="3040" CreationDate="2014-06-23T20:02:24.473" Score="4" Body="&lt;p&gt;No, it doesn't look like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD board uses digital pins 4-10 and analog 0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor board uses digital pins 3-12 if all motors are used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to stack boards look for boards that use I2C since they can share a single data bus.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-06-23T20:02:24.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3047" PostTypeId="2" ParentId="3003" CreationDate="2014-06-23T20:47:53.960" Score="1" Body="&lt;p&gt;Simulink just supplies code for all the things you could be up to, triggered by a serial command of yours. This is very slow and I think it's obvious, that you would want a fast and slim realization of everything possible, if you attempt to do HIL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a special part you think is only easy for you with blocks, just ask right away, but it is really easy to do everything you can wish for in a few simple lines.&#xA;Also this is better for you, because you really know, what's going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could provide some detail code, since I'm doing HIL myself atm, but you would need to specify a bit, what you are up to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To really answer your question: I don't know of any other visual programming tool for arduino and as stated above, my best knowledge is, that simulink uses pretty messy things. And loads them onto the board right away, right?&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2014-06-23T20:47:53.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3048" PostTypeId="2" ParentId="3039" CreationDate="2014-06-23T22:23:21.743" Score="3" Body="&lt;p&gt;You could add some kind of packet header/footer to the serial output. For example, if you sent the characters &quot;ab&quot; before the bytes for your number you could reject packets that only had 2 bytes in them. the serial would look like &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;ab123ab123ab12ab123&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The matlab code could see another &quot;ab&quot; come in before the previous packet finished and ignore the packet that ended up as only &quot;ab12&quot;, and then get itself back on track again. You should use 2 bytes for your header to avoid collisions with the actual data. Adding a checksum at the end of the packet would also allow you to detect bit swap errors. CRC or fletcher16 would work perfectly in this scenario, but in your case a checksum may be more than you need.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-23T22:23:21.743" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3049" PostTypeId="2" ParentId="3039" CreationDate="2014-06-23T23:23:25.820" Score="3" Body="&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; It seems as the problem is overflow. That means that the USB connection isn't keeping up with the data trying to be sent. To fix this you need to do one of the following things (or both):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Higher baud rate.&lt;/strong&gt; The baud rate is the frequency that data is sent. From what I've heard, anything above &lt;code&gt;500,000&lt;/code&gt; as a baud rate isn't helpful with the Arduino libraries.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino IDE only goes up so high. Try an application such as PuTTY to get higher baud rates on the serial monitor.&lt;/li&gt;&#xA;&lt;li&gt;Doing very high rates like this are best suited on as short of a cable as you can manage. I'd say 4 feet &lt;strong&gt;max&lt;/strong&gt;, although it depends on many factors, including cable quality. A shorter cable has less resistance (thus less errors).&lt;/li&gt;&#xA;&lt;li&gt;The rest of the answer still applies. You might want to add a simple parity bit to make sure the data doesn't get corrupted while sent. Adding two or three characters greatly reduces the risk of corruption, but at the expense of cutting your sampling rate in half and it doesn't verify data integrity. I don't know your exact situation, so adding a bit might not be possible.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Lower sampling rate:&lt;/strong&gt; you're sending too much, so a simple solution is just to add &lt;code&gt;delay(250);&lt;/code&gt; at the end of the loop so you don't overload the port.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original Answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing that comes to mind that is very efficient is a parity bit with another bit that's always the opposite of the parity bit. Why? Having an accidental thing where there the last two bits are opposite of each other and they all add up to a even number (ignoring the last bit) would be really odd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A parity bit is an extra bit so all the bits added up with the parity bit equals an even number. If it isn't quite right, then you know there's a problem. It works only for odd numbers of bits changed, so it isn't foolproof. An example is you have the bits &lt;code&gt;10010110&lt;/code&gt;. There are four &lt;code&gt;1&lt;/code&gt;s, so it's an even number, thus the parity bit will be &lt;code&gt;0&lt;/code&gt;. If it was an odd number, it would be &lt;code&gt;1&lt;/code&gt; to make the total count an even number. If the computer calculates it doesn't add up right (excuse my lame pun) then it's corrupted and the computer can discard it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To implement this you'd need to convert the number(s) and the parity bit to ASCII and then count the 0s and 1s. You can use a remainder function and divide by two so there will be a remainder of 1 if it's odd, thus it's corrupted. I'd personally take the latest bit and the x number before it, and just keep looping until you find a combination that satisfies the whole parity bit thing and is within a reasonable range that you've specified in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A line-break would suffice, but it takes up more bits and discovers only missing data, not corrupt data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you should be looking into &lt;em&gt;why&lt;/em&gt; there's a problem. Could you reduce the length of the USB cable? Upgrade your cable/try a different one? Slightly reduce the baud rate?&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-06-25T20:13:38.053" LastActivityDate="2014-06-25T20:13:38.053" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3051" PostTypeId="2" ParentId="1593" CreationDate="2014-06-24T08:06:09.103" Score="2" Body="&lt;p&gt;I searched quite some time for everything regarding the MPU6050, but there is just rumors and jokes about the dmp funcionality. One project encorporates the hard reverse-engeneering some wise people did, which is: &lt;a href=&quot;http://www.i2cdevlib.com/docs/html/class_m_p_u6050.html&quot; rel=&quot;nofollow&quot;&gt;http://www.i2cdevlib.com/docs/html/class_m_p_u6050.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also uses the interrupt, which I suppose you can't really avoid. Why exaclty this would be necessary though, is not a thing I could tell you.. I assume, that the dmp works somehow with the fifo buffer and can only interact through it. The cited library has examples with and without dmp, which I can really recommend.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this thing for a quadcopter however I can just say, that the dmp is too slow to control such a fast system, so maybe first consider what you really need. From my experience it does some magic things, but acts strange is due to it's not documentary it is a pain to work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2014-06-24T08:06:09.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3054" PostTypeId="1" AcceptedAnswerId="3057" CreationDate="2014-06-24T14:13:43.253" Score="1" ViewCount="719" Body="&lt;p&gt;I've been tasked to do an initial design for an Arduino setup that needs to run very infrequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I'd like the system to wake up &lt;em&gt;daily&lt;/em&gt; to take some sensor readings and report them back to a central site (the mesh network for this will be my next stage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since these things are going to be run on battery, I need it to be as insanely efficient as possible, with minimal power drain when not reading the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What facilities does Arduino have to do this?&lt;/p&gt;&#xA;" OwnerDisplayName="user2917" LastActivityDate="2014-06-24T15:38:03.130" Title="Efficient periodic wake up for sensor reads" Tags="|power|interrupt|timers|battery|system-design|" AnswerCount="1" CommentCount="1" ClosedDate="2014-06-24T16:10:02.833" ContentLicense="CC BY-SA 3.0" />
  <row Id="3055" PostTypeId="1" CreationDate="2014-06-24T15:09:09.533" Score="7" ViewCount="1387" Body="&lt;p&gt;I'm creating an XMPP chatbot for the Arduino Yun. However, I'm not too confident in the Python performance on such a low performance device and I'm much more comfortable with C++. Is there a C++ crosscompile environment available, and is there a port of the Bridge library to C++? Alternatively, documentation on how to interface with the ATMega using raw serial communication?&lt;/p&gt;&#xA;" OwnerUserId="2919" LastActivityDate="2015-02-24T10:17:06.087" Title="Arduino Yun C++ environment? Bridge + Cross-Compiler" Tags="|c++|arduino-yun|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3056" PostTypeId="1" AcceptedAnswerId="3073" CreationDate="2014-06-24T15:23:38.073" Score="0" ViewCount="1005" Body="&lt;p&gt;I'm trying to build a string of characters from several elements given by the &lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;TinyGPS++ library&lt;/a&gt; with the use of sprintf().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code making the string and printing it in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char posmsg[100], lat[14+1], lon[14+1];&#xA;&#xA;void sendString(){&#xA;  //- convert lat/lon&#xA;  dtostrf(gps.location.lat(), 10,6, lat);&#xA;  dtostrf(gps.location.lng(), 10,6, lon); &#xA;&#xA;  //- sprintf the string&#xA;  sprintf(posmsg, &quot;$%4d-%02d-%02d %02d:%02d:%02d,%s,%s,%i,%i,%i,%i,%i$&quot;,&#xA;          gps.date.year(),gps.date.month(),gps.date.day(),&#xA;          gps.time.hour(), gps.time.minute(), gps.time.second(),&#xA;          lat, lon,&#xA;          gps.speed.value(), gps.course.value(), gps.altitude.value(),&#xA;          gps.satellites.value(), gps.hdop.value()&#xA;        );&#xA;&#xA;  Serial.println(&quot;--------------------&quot;);&#xA;  Serial.println(posmsg);&#xA;  Serial.println(&quot;--------------------&quot;);&#xA;&#xA;  Serial.print(&quot;Speed:&quot;);&#xA;  Serial.println(gps.speed.value());&#xA;  Serial.print(&quot;Course:&quot;);Serial.println(gps.course.value());&#xA;  Serial.print(&quot;Height:&quot;);Serial.println(gps.altitude.value());&#xA;  Serial.print(&quot;Sats:&quot;);Serial.println(gps.satellites.value());&#xA;  Serial.print(&quot;HDOP:&quot;);Serial.println(gps.hdop.value());&#xA;  Serial.println(&quot;--------------------&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the result and what I expect... (spaces added for readability)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Result:&#xA; --------------------&#xA; $2014-06-24 15:17:11,  51.xxxxxx,   5.xxxxxx, 2, 0, 4964, 0, 3660$&#xA; --------------------&#xA; Speed:2&#xA; Course:4964&#xA; Height:3660&#xA; Sats:8&#xA; HDOP:110&#xA; --------------------&#xA;&#xA; Expected:&#xA; --------------------&#xA; $2014-06-24 15:17:11,  51.xxxxxx,   5.xxxxxx, 2, 4964, 3660, 8, 110$&#xA; --------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in the end of the string the numbers get displaced...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt; the type of the variables are all integers or unsigned integers, but the sprintf messes things up.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gps.speed.value(); // Raw speed in 100ths of a knot (i32)&#xA; gps.course.value(); // Raw course in 100ths of a degree (i32)&#xA; gps.altitude.value(); // Raw altitude in centimeters (i32)&#xA; gps.satellites.value(); // Number of satellites in use (u32)&#xA; gps.hdop.value(); // Horizontal Dim. of Precision (100ths-i32)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="756" LastEditorUserId="756" LastEditDate="2014-06-24T15:30:22.833" LastActivityDate="2014-06-25T04:50:18.783" Title="Unexpected behavior of sprintf with i32/u32" Tags="|arduino-uno|programming|sketch|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3057" PostTypeId="2" ParentId="3054" CreationDate="2014-06-24T15:38:03.130" Score="1" Body="&lt;p&gt;Please refer to &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/ArduinoSleepCode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it explains the details of a the sleep command and interrupts to re-a-wake. Where the power savings is from putting the resources individually into low power mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your solution, you may want to put everything in low power, except power_timer1_disable(). Where timer1 would be configured to provide an overflow interrupt, say every 1 minute or longer and then go back to powering all off and return to sleep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the article also mentions that the UNO's power supply is a linear regulator, which is very in-efficient. You may want to use your own. You can also get away with just running directly off of 2-3 AA's, if your other circuitry does not care. If this, then I would also suggest enabling the brown out detection, to ensure low battery does not get funny.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-06-24T15:38:03.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3058" PostTypeId="2" ParentId="3041" CreationDate="2014-06-24T15:41:15.917" Score="2" Body="&lt;p&gt;Never mind, i went with the GSM SMS example from arduino 1.0.5 (Don't know the version of arduino IDE that included this) and works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are considering using the SerialGSM library there is no need to!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CAUTION: In the Arduino's library, when you declare the phone number, you have to use international format&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Thanks bloomfield for the info you provided in the previous answer)&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-24T15:41:15.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3059" PostTypeId="1" AcceptedAnswerId="3060" CreationDate="2014-06-24T15:48:57.597" Score="12" ViewCount="52669" Body="&lt;p&gt;Inside my main loop there is this string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String string1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a function that will take string1 as parameter, and use it to send this string as SMS.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sendSMS(string1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the sendSMS() function (without parameters):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendSMS()&#xA;{ sms.beginSMS(remoteNumber);&#xA;  sms.print(finalstr);&#xA;  sms.endSMS();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Message sent!&quot;);&#xA;  delay(10000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I put the string input parameter in sendSMS?&lt;/li&gt;&#xA;&lt;li&gt;Do I also need to use a function prototype for sendSMS()? (so that it appears three times, 1 in the prototype, 1 in the declaration and one in the call). Or I don't need to use function prototype before the main loop()?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="37" LastEditDate="2014-11-12T21:02:59.260" LastActivityDate="2019-04-17T03:10:55.780" Title="Functions with string parameters" Tags="|programming|c++|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3060" PostTypeId="2" ParentId="3059" CreationDate="2014-06-24T16:46:54.063" Score="11" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Just change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendSMS()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendSMS(const String&amp;amp; thisIsAString)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then access the parameter inside the function with &lt;code&gt;thisIsAString&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No, you do not need a prototype.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2019-04-17T03:10:55.780" LastActivityDate="2019-04-17T03:10:55.780" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3061" PostTypeId="1" CreationDate="2014-06-24T17:12:42.960" Score="1" ViewCount="3728" Body="&lt;p&gt;I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;#define PINNUMBER &quot;&quot;  // Opt from user&#xA;#define GPS_RX_PIN 2&#xA;#define GPS_TX_PIN 3&#xA;#define WHITE 0x7  //For LCD library&#xA;&#xA;//Objects initialization&#xA;GSM gsmAccess;&#xA;GSM_SMS sms;&#xA;&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);&#xA;&#xA;// Chars and strings for gps values&#xA;char clat[10 + 20 + 1] = &quot;Latitude/Longitude: &quot;;&#xA;char clng[10 + 1];&#xA;String string1, string2, finalstr;&#xA;&#xA;&#xA;const int xpin = A0;                  // X-axis of the accelerometer&#xA;const int ypin = A1;                  // Y-axis&#xA;const int zpin = A2;                  // Z-axis (only on 3-axis models)&#xA;&#xA;float convX = 0.0, convY = 0.0, convZ = 0.0;&#xA;int sampleDelay = 20;&#xA;&#xA;char remoteNumber[20] = &quot;306978666866&quot;; // Opt from user&#xA;&#xA;uint8_t i = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); //GSM&#xA;  ss.begin(4800);     //gps&#xA;&#xA;  analogReference(EXTERNAL); // For external analog reference of ADXL335&#xA;  pinMode(xpin, INPUT);&#xA;  pinMode(ypin, INPUT);&#xA;  pinMode(zpin, INPUT);&#xA;&#xA;  // Set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  lcd.setBacklight(WHITE);&#xA;  lcd.setCursor(0, 0);&#xA;&#xA;  // GSM connection state&#xA;  boolean notConnected = true;&#xA;&#xA;  while(notConnected)&#xA;  {&#xA;    if(gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;      notConnected = false;&#xA;    else&#xA;    {&#xA;      lcd.print(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;  lcd.print(&quot;GSM initialized&quot;);&#xA;&#xA;  delay(2000);&#xA;  lcd.print(&quot;SELECT=Emergency&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  bool uniFlag = false;&#xA;  int x = analogRead(xpin);&#xA;  delay(1); // Add a small delay between pin readings. I read that you should&#xA;            // do this but haven't tested the importance.&#xA;&#xA;  int y = analogRead(ypin);&#xA;  delay(1);&#xA;&#xA;  int z = analogRead(zpin);&#xA;&#xA;  // zero_G is the reading we expect from the sensor when it detects&#xA;  // no acceleration. Subtract this value from the sensor reading to&#xA;  // get a shifted sensor reading.&#xA;  float zero_G = 502.0;&#xA;&#xA;  // 'scale' is the number of units we expect the sensor reading to&#xA;  // change when the acceleration along an axis changes by 1G.&#xA;  // Divide the shifted sensor reading by scale to get acceleration in Gs.&#xA;  //   610 (1g) - 502 (0g) = 108&#xA;  float scale = 108;&#xA;&#xA;  //value (g) = (measurement - 502)/ 108&#xA;  convX = ((float)x - zero_G)/scale;&#xA;  convY = ((float)y - zero_G)/scale;&#xA;  convZ = ((float)z - zero_G)/scale;&#xA;&#xA;  delay(sampleDelay);&#xA;&#xA;  if (convX &amp;gt; 2 || convX &amp;lt; -2 || convY &amp;gt; 2 || convY &amp;lt; -2)&#xA;    uniFlag = true;&#xA;&#xA;  uint8_t buttons = lcd.readButtons();&#xA;&#xA;  if (buttons) {&#xA;    if (buttons &amp;amp; BUTTON_SELECT) {&#xA;      uniFlag = true;}&#xA;  }&#xA;&#xA;  if (uniFlag == true)&#xA;  {&#xA;    bool isGpsLocationValid = false;&#xA;    do&#xA;    {&#xA;      while (ss.available()&amp;gt;0)&#xA;      {&#xA;        char c = byte(ss.read());&#xA;        if (gps.encode(c))&#xA;        {&#xA;          if (gps.location.isValid())&#xA;          {&#xA;            dtostrf(gps.location.lat(), 10, 6, clat+20);&#xA;            dtostrf(gps.location.lng(), 10, 6, clng);&#xA;            isGpsLocationValid = true;&#xA;            string1 = String(clat);&#xA;            string2 = String(clng);&#xA;            finalstr = string1 + string2;&#xA;          }&#xA;        }&#xA;      }&#xA;    } while (isGpsLocationValid == false);&#xA;  }&#xA;  sendSMS(finalstr);&#xA;}&#xA;&#xA;void sendSMS(String thisString)&#xA;{&#xA;  sms.beginSMS(remoteNumber);&#xA;  sms.print(thisString);&#xA;  sms.endSMS();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Message sent!&quot;);&#xA;  delay(10000); //for multiple bumps&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to compile it I get these errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GSM\GSM3SoftSerial.cpp.o: In function `__vector_5':&#xA;C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:525: multiple definition of `__vector_5'&#xA;SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:319: first defined here&#xA;GSM\GSM3SoftSerial.cpp.o: In function `__vector_4':&#xA;C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:518: multiple definition of `__vector_4'&#xA;SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:312: first defined here&#xA;GSM\GSM3SoftSerial.cpp.o: In function `__vector_3':&#xA;C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:511: multiple definition of `__vector_3'&#xA;SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:305: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is going on? Is it that GSM.h declares SoftwareSerial inside? Are there any solutions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the first time I get these kinds of compilation errors and have no idea what is going on or how to fix it.&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="510" LastEditDate="2017-12-02T12:42:41.177" LastActivityDate="2017-12-02T12:42:41.177" Title="Error compiling" Tags="|compile|" AnswerCount="2" CommentCount="3" ClosedDate="2014-06-24T20:58:36.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="3062" PostTypeId="2" ParentId="3061" CreationDate="2014-06-24T17:49:55.727" Score="3" Body="&lt;p&gt;Both &lt;code&gt;SoftwareSerial&lt;/code&gt; and &lt;code&gt;GSM&lt;/code&gt; are trying to declare the same interrupt vectors. You'll have to drop one of the libraries, find a replacement or change your code to omit one of the libraries. This is the disadvantage of using high level libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some Arduino's (Arduino Mega) have a microcontroller that supports more than one hardware serial channel, you may want to check that in the datasheet of the ATmega that is on the board.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-06-24T17:49:55.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3063" PostTypeId="2" ParentId="3061" CreationDate="2014-06-24T17:54:43.217" Score="1" Body="&lt;p&gt;I have not downloaded the libraries in question, but It would appear that there is a collision between &quot;SoftSerial.h&quot; and the &quot;GSM/GSM3SoftSerial.h&quot; built in to your GSM library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a disscussion of this conflict here:&#xA;&lt;a href=&quot;https://github.com/mainehackerclub/open_vehicle_tracker/issues/28&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mainehackerclub/open_vehicle_tracker/issues/28&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the answer is to use the &quot;AltSoftSerial&quot; library instead of the stock &quot;SoftSerial&quot; library. The &quot;AltSoftSerial&quot; library can be downloaded here&#xA;&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-06-24T17:54:43.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3064" PostTypeId="1" CreationDate="2014-06-24T21:22:05.317" Score="3" ViewCount="806" Body="&lt;p&gt;when I try to upload blink program to my Pro Mini, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude stk500_getsync() not in sync resp=0x00 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried everything, changing the COM port, different USB cable and even another computer. Here is what I'm dealing with: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Pro Mini 328 5v 16M (Fake) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;FT232RL USB to serial adapter &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing is connected to any pins on the Arduino, just trying to get LED to blink. I'm pretty sure the bootloader is installed, because when I hit the reset button, the LED blinks. I've tested the FTDI chip by connecting the TX and RX pins together, and it does echo in the serial monitor.&#xA;Help appreciated! &lt;/p&gt;&#xA;" OwnerUserId="2922" LastEditorUserId="11" LastEditDate="2014-06-25T05:26:06.603" LastActivityDate="2014-06-25T07:57:37.810" Title="Pro Mini not communicating with computer" Tags="|uploading|" AnswerCount="1" CommentCount="7" ClosedDate="2014-08-22T00:03:33.523" ContentLicense="CC BY-SA 3.0" />
  <row Id="3065" PostTypeId="2" ParentId="140" CreationDate="2014-06-24T21:34:39.797" Score="0" Body="&lt;p&gt;I've established a connection, sending numbers. By just changing Serial.write to Serial.print and fread to fscanf you can send/receive clear ASCII text instead of binary data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both matlab and arduino code can be found at this question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/24368670/matlab-plot-serial-data-continously&quot;&gt;https://stackoverflow.com/questions/24368670/matlab-plot-serial-data-continously&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-06-24T21:34:39.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3066" PostTypeId="1" CreationDate="2014-06-25T01:14:38.233" Score="5" ViewCount="772" Body="&lt;p&gt;I used Mifare Classic cards on a previous project and it worked brilliantly with the RIFD/NFC shield and Arduino Uno. I came across a Gen 2 EPC Class 1 RFID tags. This tags are long range ones. They use an IC chip called Alien Higgs3. I know that the shield itself is not capable of reading from a long range. I would just like to know if the shield is just able to read this type of tag even in close contact. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a UHF RFID Reader that I can use to connect it with the Arduino and read these tags?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice or suggestions are welcome. Thank alot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RFID Tag Specifications:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Protocol- EPC Class 1 Gen2&#xA;Frequency- 860-960 MHz&#xA;IC Type (chip)- Alien Higgs3&lt;/p&gt;&#xA;" OwnerUserId="2924" LastActivityDate="2018-04-30T22:57:11.597" Title="Can the Adafruit PN532 NFC/RFID be used to read Gen-2 EPC class RFID Tags?" Tags="|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3067" PostTypeId="1" CreationDate="2014-06-25T01:37:17.823" Score="1" ViewCount="7679" Body="&lt;p&gt;The title says it all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Angone with experience here on this subject?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use all Hardware serial, SoftwareSerial and AltSoftSerial on Arduino Duemilanove with At328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-30T14:52:14.937" Title="SoftwareSerial together with AltSoftSerial and HardwareSerial" Tags="|serial|softwareserial|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3068" PostTypeId="1" AcceptedAnswerId="3071" CreationDate="2014-06-25T03:11:02.417" Score="5" ViewCount="1715" Body="&lt;p&gt;My project is progressing quite well, but I am having some issues reading button presses through my MUX.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The Goal&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Cycle through twelve buttons and twelve LEDs. When a button is pressed, light up the corresponding LED. I have one MUX for the LEDs which is working great thanks to the stack exchange community. My button MUX is the issue.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The Symptom&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have one button hooked up to the MUX. When it is not pressed, nothing lights up - that's right. But when it is pressed, every LED lights up as it is cycled through. It is as if pressing this button for one of the MUX pins is sending a HIGH signal to all of the MUX pins.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The Pictures&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14502003495&quot; rel=&quot;noreferrer&quot; title=&quot;IMG_20140624_225046 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5545/14502003495_4793545dbc.jpg&quot; alt=&quot;IMG_20140624_225046&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;^^ You can see the big honking button in the bottom right. It is connected to 5V and then the MUX pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14502004145&quot; rel=&quot;noreferrer&quot; title=&quot;IMG_20140624_225054 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm4.staticflickr.com/3866/14502004145_f9e52b5ecd.jpg&quot; alt=&quot;IMG_20140624_225054&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;^^ I have two multiplexers. The one on the left is for the LEDs and the one on the right is for the buttons (of which I currently [ha!] have only one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14500677754&quot; rel=&quot;noreferrer&quot; title=&quot;IMG_20140624_225113 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm4.staticflickr.com/3878/14500677754_53a79981f5.jpg&quot; alt=&quot;IMG_20140624_225113&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14315398319&quot; rel=&quot;noreferrer&quot; title=&quot;IMG_20140624_225123 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm4.staticflickr.com/3849/14315398319_94e29448b9.jpg&quot; alt=&quot;IMG_20140624_225123&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/89742360@N03/14478894346&quot; rel=&quot;noreferrer&quot; title=&quot;IMG_20140624_225136 by nrbergeron, on Flickr&quot;&gt;&lt;img src=&quot;https://farm3.staticflickr.com/2905/14478894346_2a1be6103f.jpg&quot; alt=&quot;IMG_20140624_225136&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The Code&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// set vars for all the pins&#xA;int led_input = 0;&#xA;int led_ctrl_1 = 1;&#xA;int led_ctrl_2 = 2;&#xA;int led_ctrl_3 = 3;&#xA;int led_ctrl_4 = 4;&#xA;&#xA;int btn_input = 5;&#xA;int btn_ctrl_1 = 6;&#xA;int btn_ctrl_2 = 7;&#xA;int btn_ctrl_3 = 8;&#xA;int btn_ctrl_4 = 9;&#xA;&#xA;// how many MUX pins?&#xA;int players = 12;&#xA;&#xA;// function to take player number and convert to control pins&#xA;void ledWrite(int led, boolean val){&#xA;&#xA;    if(!val){&#xA;&#xA;        digitalWrite(led_input, LOW);&#xA;&#xA;    }else{&#xA;&#xA;        if((led - 8) &amp;gt;= 0){&#xA;            led = led - 8;&#xA;            digitalWrite(led_ctrl_4, HIGH);&#xA;        }else{&#xA;            digitalWrite(led_ctrl_4, LOW);&#xA;        }&#xA;&#xA;        if((led - 4) &amp;gt;= 0){&#xA;            led = led - 4;&#xA;            digitalWrite(led_ctrl_3, HIGH);&#xA;        }else{&#xA;            digitalWrite(led_ctrl_3, LOW);&#xA;        }&#xA;&#xA;        if((led - 2) &amp;gt;= 0){&#xA;            led = led - 2;&#xA;            digitalWrite(led_ctrl_2, HIGH);&#xA;        }else{&#xA;            digitalWrite(led_ctrl_2, LOW);&#xA;        }&#xA;&#xA;        if((led - 1) &amp;gt;= 0){&#xA;            led = led - 1;&#xA;            digitalWrite(led_ctrl_1, HIGH);&#xA;        }else{&#xA;            digitalWrite(led_ctrl_1, LOW);&#xA;        }&#xA;&#xA;        digitalWrite(led_input, HIGH);&#xA;    }&#xA;}&#xA;&#xA;// function to take player number and convert to control pins&#xA;int btnRead(int btn){&#xA;&#xA;    if((btn - 8) &amp;gt;= 0){&#xA;        btn = btn - 8;&#xA;        digitalWrite(btn_ctrl_4, HIGH);&#xA;    }else{&#xA;        digitalWrite(btn_ctrl_4, LOW);&#xA;    }&#xA;&#xA;    if((btn - 4) &amp;gt;= 0){&#xA;        btn = btn - 4;&#xA;        digitalWrite(btn_ctrl_3, HIGH);&#xA;    }else{&#xA;        digitalWrite(btn_ctrl_3, LOW);&#xA;    }&#xA;&#xA;    if((btn - 2) &amp;gt;= 0){&#xA;        btn = btn - 2;&#xA;        digitalWrite(btn_ctrl_2, HIGH);&#xA;    }else{&#xA;        digitalWrite(btn_ctrl_2, LOW);&#xA;    }&#xA;&#xA;    if((btn - 1) &amp;gt;= 0){&#xA;        btn = btn - 1;&#xA;        digitalWrite(btn_ctrl_1, HIGH);&#xA;    }else{&#xA;        digitalWrite(btn_ctrl_1, LOW);&#xA;    }&#xA;&#xA;    return digitalRead(btn_input);&#xA;}&#xA;&#xA;void setup(){&#xA;&#xA;    pinMode(led_input, OUTPUT);  &#xA;    pinMode(led_ctrl_1, OUTPUT);  &#xA;    pinMode(led_ctrl_2, OUTPUT);  &#xA;    pinMode(led_ctrl_3, OUTPUT);  &#xA;    pinMode(led_ctrl_4, OUTPUT);  &#xA;    pinMode(btn_input, INPUT);  &#xA;    pinMode(btn_ctrl_1, OUTPUT);  &#xA;    pinMode(btn_ctrl_2, OUTPUT);  &#xA;    pinMode(btn_ctrl_3, OUTPUT);  &#xA;    pinMode(btn_ctrl_4, OUTPUT);  &#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;    for(int x = 1; x &amp;lt;= players; x++){&#xA;&#xA;&#xA;        if(btnRead(x) == HIGH){&#xA;&#xA;            ledWrite(x, true);&#xA;            delay(100);&#xA;            ledWrite(x, false);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know this is a lot to trudge through, and I honestly appreciate any help you are willing to offer. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="2838" LastActivityDate="2014-06-25T04:07:00.807" Title="Reading button presses with the 74HC4067E multiplexer" Tags="|led|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3070" PostTypeId="1" CreationDate="2014-06-25T03:50:09.250" Score="3" ViewCount="1355" Body="&lt;p&gt;I have an analog electricity meter (AEM) and I would like to track my usage of electricity.&#xA;I've attempted to use the &lt;a href=&quot;http://www.digikey.com/product-detail/en/EE-SY310/OR525-ND/68127&quot; rel=&quot;nofollow&quot;&gt;EE-SY310 photo sensor&lt;/a&gt;, but that's not sensitive enough it seems. I suspect the black stripe on the dial is too thin to be picked up. The other concern on using any photo sensor is its dependance on light (obviously) hence no reading would be picked up during the night.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other: I've also found that AEMs work by using magnetic fields to move the dial. The &lt;a href=&quot;http://smile.amazon.com/Trifield-100XE-EMF-Meter/dp/B00050WQ1G/ref=sr_1_3?ie=UTF8&amp;amp;qid=1403667890&amp;amp;sr=8-3&amp;amp;keywords=magnetic%20field%20detector&quot; rel=&quot;nofollow&quot;&gt;magnetic field detector&lt;/a&gt; I used did not show much fluctuation when turning appliances on/off. The dial was pegged at the max. Therefore, I'm not so confident that a sensor to measure magnetic fields would work here, but I'm open to suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, would anyone know what sensor would be good to detect the black stripe on AEMs?&#xA;Preferably to also work without light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are &lt;a href=&quot;http://smile.amazon.com/Wattvision-WV2-A-Energy-Sensor-Gateway/dp/B005BI9K0C/ref=sr_1_3?ie=UTF8&amp;amp;qid=1403668106&amp;amp;sr=8-3&amp;amp;keywords=wattvision&quot; rel=&quot;nofollow&quot;&gt;off-the-shelve products&lt;/a&gt; that do this already, but where's the fun in that? &lt;/p&gt;&#xA;" OwnerUserId="381" LastActivityDate="2016-04-07T12:09:39.340" Title="What sensor would detect the black stripe on an analog electricity meter?" Tags="|sensors|electricity|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3071" PostTypeId="2" ParentId="3068" CreationDate="2014-06-25T04:07:00.807" Score="3" Body="&lt;p&gt;All your unused MUX input pins for the button MUX are floating. You will need to tie all of the unused inputs (those that do not have a physical button attached) to ground. Floating inputs are undefined and cause undefined output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when your attached button is &lt;em&gt;not&lt;/em&gt; pressed, its input will also be floating. You can avoid this by connecting the input pin on the MUX to ground using a resistor. That way, when the button is not pressed the input will be low (through the resistor), and when the button is pressed it will be high (through the button connection).&lt;/p&gt;&#xA;" OwnerUserId="2839" LastActivityDate="2014-06-25T04:07:00.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3072" PostTypeId="2" ParentId="3020" CreationDate="2014-06-25T04:24:03.430" Score="2" Body="&lt;p&gt;The Arduino will easily drive this relay board, and it needs only a very small input current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board you linked to has a built-in optical isolation circuit, so there is no direct electrical connection between the Arduino-side of the circuit and the relay side. This &lt;em&gt;should&lt;/em&gt; protect your Arduino if something goes wrong. For what it's worth, the product description specifies this board is suitable for &quot;AC [...] appliances such as [...] motors&quot;. A pump is primarily a motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage may fluctuate when the pump is started and stopped (&lt;a href=&quot;https://en.wikipedia.org/wiki/Counter-electromotive_force&quot; rel=&quot;nofollow&quot;&gt;Back-EMF&lt;/a&gt;). It's hard to say what this might do to the relay board if it goes way over specification. Perhaps you might be happier with a much more robust &lt;a href=&quot;http://en.wikipedia.org/wiki/Solid-state_relay&quot; rel=&quot;nofollow&quot;&gt;solid-state relay&lt;/a&gt; (SSR) that has a higher rating than the target load. Something &#xA;like &lt;em&gt;&lt;a href=&quot;http://www.dx.com/p/ssr-25da-25a-solid-state-relay-white-134494&quot; rel=&quot;nofollow&quot;&gt;SSR-25DA 25A Solid State Relay - White&lt;/a&gt;&lt;/em&gt;. Since solid-state relays are non-mechanical, they will not wear-out from repeated switching either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to build some fail-safe sensors into your project. For example, water level float switches for both high-water and low-water marks.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="510" LastEditDate="2014-06-27T20:04:29.613" LastActivityDate="2014-06-27T20:04:29.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3073" PostTypeId="2" ParentId="3056" CreationDate="2014-06-25T04:50:18.783" Score="2" Body="&lt;p&gt;Ints and unsigned ints are 16 bits on AVR ATmegas.&#xA;So while the argument passed is a 32-bit value, sprintf() is expecting a 16 bit value.  The stack is packed with twice as much data as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &quot;2,0,4964&quot; bit, it looks like it taking part of the previous/next parameter during processing, which makes me think this even more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use &lt;em&gt;long&lt;/em&gt; types, e.g.: %ld or %li and %lu&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-06-25T04:50:18.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3074" PostTypeId="2" ParentId="3070" CreationDate="2014-06-25T07:16:12.387" Score="3" Body="&lt;p&gt;A low cost option is the &lt;a href=&quot;http://www.vishay.com/docs/83760/tcrt5000.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TCRT5000&lt;/a&gt; infrared proximity sensor. While this is designed to sense objects coming close to the sensor, by reflection of the infrared light emitted by the integrated IR LED, it also does very well in detecting black versus reflective surfaces placed near it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two parts to making this work:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Reduce the drive current for the IR LED of the TCRT5000 to the bare minimum which causes detection of the non-black portion of the electricity meter disc. While the datasheet specifies a forward current of up to 60 mA absolute maximum, a quick experiment I conducted shows appreciable detected signal at as little as 4 mA forward current, for a metallic target surface 2 mm away. Tune the forward current to work with the actual distance and reflectivity of your particular electricity meter wheel. &lt;/li&gt;&#xA;&lt;li&gt;Place a black piece of card or plastic in front of the detector part of the TCRT5000, with a thin slit cut in it to align with the black strip on the electricity meter wheel. I am getting good results using a 1.2 mm plastic sheet with a 0.3 x 1.5 mm slit cut in it.&lt;br&gt;&#xA;Note that the two hemispherical plastic parts of the TCRT5000 look more or less the same, so you will have to identify which one is the detector, and ensure that you do not obstruct the emitter by mistake. The side with the angled vertical edges (right side of image below) is the emitter and must not be obstructed. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/O0tS1.jpg&quot; alt=&quot;TCRT5000&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this arrangement, the collector current through detector will dip significantly each time the black stripe passes in front of the detector. &lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2014-06-25T07:16:12.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3075" PostTypeId="2" ParentId="1512" CreationDate="2014-06-25T07:48:46.437" Score="1" Body="&lt;p&gt;It's difficult to answer without details of how your server works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your arduino is simply connected to the server, the server could open the arduino serial port (e.g.: COM5: or /dev/ttyUSB0) and simply read data.  The arduino would only need to serialWrite() data for the server to parse and store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your arduino is not connected but has ethernet support you could do a HTTP request to your server, and pass the data as a parameters to the request, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://your.server.ip/send_data?param1=10.3&amp;amp;param2=5.6&amp;amp;param3=foo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When your server processes this HTTP request, it appends param1, param2, param3 to that text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino could also beam data back to your server via IR, or bluetooth, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's lots of ways to do this.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-06-25T07:48:46.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3076" PostTypeId="2" ParentId="3064" CreationDate="2014-06-25T07:57:37.810" Score="1" Body="&lt;p&gt;You did set the Serial Port and then tell the Arduino IDE that it's talking to a Pro Mini right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gets me every time I switch between my Nano &amp;amp; Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the main menu&#xA;[Tools]-&gt;[Board]=&gt;&quot;Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega 328&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also had this problem trying to use a longer USB cable, it just wouldn't work.  The stock cable (shorter) worked fine.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-06-25T07:57:37.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3077" PostTypeId="2" ParentId="804" CreationDate="2014-06-25T08:00:49.103" Score="3" Body="&lt;p&gt;Did you remember to tell the IDE that the board type is a Nano?&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Tools&lt;/code&gt; -&amp;gt; &lt;code&gt;Board&lt;/code&gt; =&amp;gt; &lt;code&gt;Arduino Nano ...&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This gets me every time I swap between my Nano and Uno.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2022-07-25T01:26:49.053" LastActivityDate="2022-07-25T01:26:49.053" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3078" PostTypeId="2" ParentId="3067" CreationDate="2014-06-25T13:49:43.083" Score="2" Body="&lt;p&gt;in short - Yes. The following compiles and should work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the following links detail some subtle issues about HOW to use these various libraries. Some are more optimal depending upon your usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html#speed&quot; rel=&quot;nofollow&quot;&gt;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html#speed&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=152122.0;wap2&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=152122.0;wap2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to consider just using either Alt or Soft. &#xA;Note that NewSoftwareSerial is incorporated in the IDE 1.5.5+&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Software serial multple serial test&#xA;&#xA; Receives from the hardware serial, sends to software serial.&#xA; Receives from software serial, sends to hardware serial.&#xA;&#xA; The circuit:&#xA; * RX is digital pin 10 (connect to TX of other device)&#xA; * TX is digital pin 11 (connect to RX of other device)&#xA;&#xA; Note:&#xA; Not all pins on the Mega and Mega 2560 support change interrupts,&#xA; so only the following can be used for RX:&#xA; 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69&#xA;&#xA; Not all pins on the Leonardo support change interrupts,&#xA; so only the following can be used for RX:&#xA; 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).&#xA;&#xA; created back in the mists of time&#xA; modified 25 May 2012&#xA; by Tom Igoe&#xA; based on Mikal Hart's example&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; */&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;AltSoftSerial altSerial; &#xA;// AltSoftSerial always uses these pins:&#xA;// Board          Transmit  Receive   PWM Unusable&#xA;// -----          --------  -------   ------------&#xA;// Arduino Uno        9         8         10&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(4800);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;  altSerial.begin(9600);&#xA;  altSerial.println(&quot;Hello World&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;&#xA;  char c;&#xA;&#xA;  if (Serial.available()) {&#xA;    c = Serial.read();&#xA;    altSerial.print(c);&#xA;  }&#xA;  if (altSerial.available()) {&#xA;    c = altSerial.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-06-25T13:49:43.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3079" PostTypeId="1" AcceptedAnswerId="3080" CreationDate="2014-06-25T14:33:26.160" Score="13" ViewCount="76269" Body="&lt;p&gt;I am using Arduino and I would like to know if there is a function that returns the data type of a variable. That is, I would like to run something as like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Note: 'typeof' is a sample function that should return the data type.&#xA;Serial.println(typeof(myVar));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1015" LastActivityDate="2023-03-10T14:54:22.273" Title="How to retrieve the data type of a variable?" Tags="|serial|variables|data-type|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3080" PostTypeId="2" ParentId="3079" CreationDate="2014-06-25T16:01:27.450" Score="20" Body="&lt;p&gt;In a typical C++ program, you would use the &lt;code&gt;typeid&lt;/code&gt; operator, like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;std::cout &amp;lt;&amp;lt; typeid(myVar).name();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;However,&lt;/em&gt;&lt;/strong&gt; that requires a compiler feature called Runtime Type Information (RTTI). It's disabled in the Arduino IDE, presumably because it tends to increase the runtime memory requirements of the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get more information about the resource cost here: &lt;a href=&quot;https://stackoverflow.com/questions/579887/how-expensive-is-rtti&quot;&gt;https://stackoverflow.com/questions/579887/how-expensive-is-rtti&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any fully-featured C++ compiler will definitely support RTTI though. If you want to try using a 3rd party IDE (such as Eclipse with the Arduino plugin) then you could easily enable it. It's probably not worth the hassle just for that though.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative&lt;/strong&gt;&lt;br&gt;&#xA;A higher-performing (but less flexible) solution would be to use a traits class approach. This involves some funky template meta-programming:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Generic catch-all implementation.&#xA;template &amp;lt;typename T_ty&amp;gt; struct TypeInfo { static const char * name; };&#xA;template &amp;lt;typename T_ty&amp;gt; const char * TypeInfo&amp;lt;T_ty&amp;gt;::name = &quot;unknown&quot;;&#xA;&#xA;// Handy macro to make querying stuff easier.&#xA;#define TYPE_NAME(var) TypeInfo&amp;lt; typeof(var) &amp;gt;::name&#xA;&#xA;// Handy macro to make defining stuff easier.&#xA;#define MAKE_TYPE_INFO(type)  template &amp;lt;&amp;gt; const char * TypeInfo&amp;lt;type&amp;gt;::name = #type;&#xA;&#xA;// Type-specific implementations.&#xA;MAKE_TYPE_INFO( int )&#xA;MAKE_TYPE_INFO( float )&#xA;MAKE_TYPE_INFO( short )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add &lt;code&gt;MAKE_TYPE_INFO(..)&lt;/code&gt; lines for any type you want, including the names of custom classes. You could then use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int myVar = 17;&#xA;Serial.println( TYPE_NAME(myVar) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anything you don't define using &lt;code&gt;MAKE_TYPE_INFO(..)&lt;/code&gt; will show up as &lt;code&gt;&quot;unknown&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's some fairly advanced stuff in there, so I won't try to explain how it all works here. There are various tutorials on the web though about C++ template programming if you're interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: It's worth noting that the &lt;code&gt;typeof&lt;/code&gt; operator isn't standard C++, but is supported by a few compilers, such as GCC. It's basically an older equivalent of &lt;code&gt;decltype&lt;/code&gt;, which appears in the C++11 standard.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-06-26T08:52:34.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3083" PostTypeId="1" CreationDate="2014-06-25T19:12:52.733" Score="2" ViewCount="2065" Body="&lt;p&gt;I had a Roboteq motor controller, but it wasn't fast enough. I'm hoping Arduino will be faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supposing that the transfer is fast enough for my purposes, how can I read angular velocity, given that I have an encoder? Honestly, I'm not totally sure how to hook it up to an Arduino board.&#xA;I can't find a name for my encoder... &lt;a href=&quot;http://www.superdroidrobots.com/images/encoder-datasheet.jpg&quot; rel=&quot;nofollow&quot;&gt;This is the datasheet though&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with how to hook it up, and what commands to use in MATLAB?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2933" LastEditorUserId="2933" LastEditDate="2014-06-26T17:33:09.640" LastActivityDate="2014-06-26T17:33:09.640" Title="Controlling Arduino through MATLAB?" Tags="|arduino-uno|matlab|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3084" PostTypeId="1" CreationDate="2014-06-25T20:42:53.177" Score="2" ViewCount="1928" Body="&lt;p&gt;I was wondering if it was possible to use the utp port of a computer/laptop to transmit and receive data to an external device?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take a cat5 cable there are 8 wires, so lets say you have an Arduino would it be possible to use those wires for serial communication? If so how can I program the utp port? And is there a specification for this (for example use wire x for output and wire y for input..) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&#xA;Regards&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Ps: I had no idea on which sub.stackexchange to ask it hopefully it suits here.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1089" LastActivityDate="2014-06-25T23:31:49.477" Title="Use UTP Cable to transmit/receive data?" Tags="|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3085" PostTypeId="2" ParentId="721" CreationDate="2014-06-25T21:08:54.830" Score="1" Body="&lt;p&gt;In terms of cost, perhaps it would be best to build a 4x4 prototype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought was to use inexpensive servos with a flexible rod inside a sheath, perhaps a wire, like a bicycle brake/gear.  The amount of movement could then be governed by the size of the armature on an inexpensive servo.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servos will position themselves after being given the command, so there's no need to wait and do them one-by-one.  Fire off the command, then use some sort of multiplexed output like multiple 74HC595 shift registers to connect to the next one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the tiles were spring loaded, such that they returned to the topmost position by themselves, only a simple pull-string is needed to adjust the tile height.  Even a very light filament (like fishing line) would be strong enough for the pull.  This would allow the servos to be positioned even some metres away from the table.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-06-25T21:08:54.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3086" PostTypeId="2" ParentId="3083" CreationDate="2014-06-25T21:35:35.717" Score="1" Body="&lt;p&gt;Do all the processing on the Arduino, and supply the results to Matlab over serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not 100% sure about your particular encoder, but generally encoders talk in &quot;Grey Code&quot;.  This is a series of bits which allow you to know the direction the encoder has turned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of libraries and tutorials for Arduino dealing with encoders.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/RotaryEncoders&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.hobbytronics.co.uk/arduino-tutorial6-rotary-encoder&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/arduino-tutorial6-rotary-encoder&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The one I use comes from here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_Encoder.html&quot; rel=&quot;nofollow&quot;&gt;http://www.pjrc.com/teensy/td_libs_Encoder.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It would be best to use a library with interrupt routines on pins 2 &amp;amp; 3 (these support external hardware interrupts), so whenever the pin gets a signal from the encoder, the Arduino can act on it immediately.  If you do not use these pins, and have time-consuming processing in the loop(), it's easy to miss 'ticks' from the encoder.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Serial.h&amp;gt;&#xA;&#xA;// Rotary Encoder (Interrupt Driven)&#xA;#define ENCODER_PIN_A       2 /* must be pin2 for interrupt */&#xA;#define ENCODER_PIN_B       3 /* must be pin3 for interrupt */&#xA;#define ENCODER_OPTIMIZE_INTERRUPTS&#xA;#include &amp;lt;Encoder.h&amp;gt;&#xA;Encoder encoder(ENCODER_PIN_A,ENCODER_PIN_B);&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(115200);&#xA;    // Gentlemen, start your encoders&#xA;    pinMode(ENCODER_PIN_A,INPUT_PULLUP);&#xA;    pinMode(ENCODER_PIN_B,INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    unsigned long start_time = millis();&#xA;    Serial.println(&quot;Dear Matlab...&quot;);&#xA;&#xA;    while (1)&#xA;    {&#xA;        unsigned long now = millis();&#xA;        unsigned int encoder_value = encoder.read();&#xA;&#xA;        // Do whatever angular velocity processing is needed here&#xA;        unsigned long ticks_per_ms = encoder_value / (now - start_time);&#xA;&#xA;        // Send the result back to Matlab&#xA;        Serial.println(ticks_per_ms,DEC);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think for your encoder the &quot;A&quot; and &quot;B&quot; outputs are where the grey code will be coming from.  These would be connected to Arduino pins 2 &amp;amp; 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously the code above is not a complete solution, and needs to take care of edge-conditions like overflow of millis() after some time, etc. etc.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2014-06-25T21:41:30.663" LastActivityDate="2014-06-25T21:41:30.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3087" PostTypeId="2" ParentId="3084" CreationDate="2014-06-25T23:31:49.477" Score="3" Body="&lt;p&gt;By &quot;UTP&quot;, I'm assuming you're referring to Unshielded Twisted Pair. The shielding and twisting aren't really relevant, because they're just physical characteristics of the cable itself. They don't have any bearing on the sender or receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The salient point about UTP is that it uses differential transmission. That is, the data is sent down two wires at the same time, but one is inverted. The receiver uses the difference between the two signals to reconstruct the original data, eliminating any interference which may have been introduced en route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming the voltage level is safe (0-5v for most boards), you could connect each wire directly to an analog pin on the Arduino. If you read both continuously, and apply suitable thresholds/triggers in software to identify level changes, you could probably reconstruct the original signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's definitely not ideal though, as ADCs are comparatively slow, and you would never be able to read both at exactly the same time. That means the transmission would have to be quite slow in order to work. The exact speed would depend on how quickly your program could poll the ADCs and process the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be much better to use some external circuitry to handle the differential signal. It could then produce a nice clean digital output which you could feed directly to any input on the Arduino. It should be able to run a lot faster, and leave your program free to do other things. Any good electronics vendor will stock a variety of ICs which would do the job, depending on your exact requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting up your computer/laptop as a sender is a totally separate issue though. Many different ports use differential signals in some form, including ethernet, USB, and RS-232 (old DE-9 serial ports). Unfortunately, it would be very difficult to get direct control of their signal lines. You would almost certainly have to write your own device drivers, which is a pretty huge undertaking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to send serial data from your computer to an Arduino, the easiest way is just USB-to-TTL conversion. Most Arduino boards have this built-in, connected directly to the hardware serial lines on the microcontroller (which is how you upload programs/sketches). Alternatively, you can get external cables which do the conversion, and you can connect it manually to other pins, processing it using software serial.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-06-25T23:31:49.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3088" PostTypeId="1" CreationDate="2014-06-25T23:39:48.497" Score="6" ViewCount="3436" Body="&lt;p&gt;Most programs follow this route: They have a &lt;code&gt;Serial.begin()&lt;/code&gt; for the serial connection between PC and Arduino (the serial monitor) and they use SoftwareSerial for a device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you go the other way around? Can you use SoftwareSerial for the communication between PC and Arduino, and Serial for a device?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="6936" LastEditDate="2015-08-01T14:40:34.620" LastActivityDate="2015-08-01T14:40:34.620" Title="Using SoftwareSerial for the serial monitor" Tags="|serial|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3089" PostTypeId="1" CreationDate="2014-06-26T02:16:54.237" Score="4" ViewCount="2298" Body="&lt;p&gt;I am using L293d motor driver to drive 2 motors simutaniusly in several direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am not shure why there is 2 Vcc and 4 GND in this IC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell explain it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You...&lt;/p&gt;&#xA;" OwnerUserId="670" LastActivityDate="2014-06-27T03:42:24.863" Title="why there is 4 ground in l293d?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ClosedDate="2014-06-26T19:30:05.233" ContentLicense="CC BY-SA 3.0" />
  <row Id="3090" PostTypeId="2" ParentId="3089" CreationDate="2014-06-26T03:26:45.963" Score="2" Body="&lt;p&gt;They are connected together and used for heatsinking,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VS - is voltage supply&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VSS - is logic level definition, if your uC logic level is 5V then power this with 5V. This will define voltage levels for the signal to be considered 0 or 1&lt;/p&gt;&#xA;" OwnerUserId="527" LastEditorUserId="527" LastEditDate="2014-06-27T03:42:24.863" LastActivityDate="2014-06-27T03:42:24.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3091" PostTypeId="2" ParentId="3088" CreationDate="2014-06-26T03:31:10.243" Score="3" Body="&lt;p&gt;Short answer: no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 0 and 1 an an Uno are directly wired to the PC communication chip. You could make a board that was wired differently and connected SoftwareSerial to the PC, but you would have to switch it back to pins 0 and 1 when uploading to the arduino somehow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On an arduino leonardo &quot;Serial&quot; for communicating with PC over USB is different from &quot;Serial1&quot;, which is connected to pins 0 and 1 on the board. You can use both simultaneously, so if you really need to use hardware serial and PC comms at the same time, I recommend you buy a leonardo. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-06-26T17:59:30.407" LastActivityDate="2014-06-26T17:59:30.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3092" PostTypeId="2" ParentId="3089" CreationDate="2014-06-26T04:02:01.783" Score="5" Body="&lt;p&gt;It's explain in the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/l293d.pdf&quot; rel=&quot;noreferrer&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A VCC1 terminal, separate from VCC2, is provided for the logic inputs to minimize device power dissipation. &lt;sub&gt;(pg. 2)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;V&lt;sub&gt;CC1&lt;/sub&gt; is for the logic and V&lt;sub&gt;CC2&lt;/sub&gt; is for the motor supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The four grounds are all tied together internally and act as a heatsink for the chip. (pg. 11)&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-06-26T04:02:01.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3094" PostTypeId="2" ParentId="3089" CreationDate="2014-06-26T05:21:37.573" Score="2" Body="&lt;p&gt;Apart from heatsinking the four pins in parallel reduce the impedance (resistance) to ground. The actual bond wires that run from the chip to the leadframe are pretty thin and as an effect the resistance is &lt;em&gt;relatively&lt;/em&gt; high. By wiring these pins in parallel the impedance is reduced which is a good and important property when you are trying to drive high current loads. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the ground potential on the chip will be slightly lifted proportonal to the current in the ground connections. In practice this may cause strange effects like logic levels shifting up and down with load current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best to attach GND all to the ground plane, the impedance on the PCB will be low and and the large copper surface helps to keep temperature down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vcc1 is for logic and will often interface with your 5V microcontroller. &#xA;Vcc2 is the supply rail that will actually power the load.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-06-26T05:31:27.800" LastActivityDate="2014-06-26T05:31:27.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3095" PostTypeId="1" AcceptedAnswerId="46785" CreationDate="2014-06-26T11:16:49.937" Score="2" ViewCount="2912" Body="&lt;p&gt;My transceivers are running fine. I've written a few code and got them running. Then I decided to check the auto acknowledgement feature wherein we can return data back to the sender WITHOUT manually changing the radio modes on both units. But I find that the serial monitor always shows &quot;failed to transmit&quot;. Why is this happening, because otherwise they work fine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using maniacbug's RF24master library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Tx code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SPI.h&amp;gt;&#xA;#include&amp;lt;nRF24L01.h&amp;gt;&#xA;#include&amp;lt;RF24.h&amp;gt;&#xA;&#xA;int msg[1] = {1};&#xA;int rec[1] = {0};&#xA;bool stat = true;&#xA;RF24 radio(9,10);&#xA;const uint64_t pipe[1] = {0xF0F0F0F0E1LL};&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  radio.begin();&#xA;  delay(1000);&#xA;  radio.setAutoAck(true);&#xA;  radio.enableAckPayload();&#xA;  radio.openWritingPipe(pipe[0]);&#xA;  radio.setRetries(15,15);&#xA; }&#xA;void loop()&#xA;{&#xA;  if(stat)&#xA;  {&#xA;    radio.stopListening();&#xA;    bool ok = radio.write(msg,sizeof(msg));&#xA;    delay(100);&#xA;    if(ok)&#xA;    {Serial.println(&quot;transmitted successfully !!&quot;);}&#xA;    else&#xA;    {Serial.println(&quot;faileed to transmit&quot;);}&#xA;    msg[1]++;&#xA;    if(msg[1]&amp;gt;=200)&#xA;    {msg[1]=1;}&#xA;    stat = false;&#xA;    //delay(20);&#xA;  }&#xA;  if(!stat)&#xA;  {&#xA;    if(radio.isAckPayloadAvailable())&#xA;    {&#xA;      radio.read(rec,sizeof(rec));&#xA;      Serial.print(&quot;received ack payload is : &quot;);&#xA;      Serial.println(rec[1]);&#xA;      stat = true;    &#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the Rx part is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SPI.h&amp;gt;&#xA;#include&amp;lt;nRF24L01.h&amp;gt;&#xA;#include&amp;lt;RF24.h&amp;gt;&#xA;const uint64_t pipe = 0xF0F0F0F0E1LL;&#xA;RF24 radio(9,10);&#xA;int rec[1] = {0};&#xA;int ack[1] = {1};&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  radio.begin();&#xA;  delay(100);&#xA;  radio.setAutoAck(true);&#xA;  radio.enableAckPayload();&#xA;  radio.openReadingPipe(1,pipe);&#xA;  radio.startListening();&#xA;  radio.setRetries(15,15);&#xA;}&#xA;void loop()&#xA;{&#xA;  if(radio.available())&#xA;  {&#xA;    Serial.println(&quot;payload available....&quot;);&#xA;    bool ok = radio.read(rec,sizeof(rec));&#xA;    if(ok)&#xA;    {&#xA;        Serial.println(&quot;message received !!&quot;);&#xA;        Serial.print(&quot;integer got is : &quot;);&#xA;        Serial.println(rec[1]);&#xA;        radio.writeAckPayload(1,ack,sizeof(ack));&#xA;    }&#xA;    else&#xA;    {Serial.println(&quot;failed to receive the message&quot;);}&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2935" LastEditorUserId="6936" LastEditDate="2017-06-04T08:12:55.240" LastActivityDate="2017-11-19T16:42:24.620" Title="Auto acknowledge failed with nRF 24L01+ and Arduino" Tags="|remote-control|rf|" AnswerCount="1" CommentCount="6" ClosedDate="2017-11-21T21:22:51.313" ContentLicense="CC BY-SA 3.0" />
  <row Id="3097" PostTypeId="1" AcceptedAnswerId="3343" CreationDate="2014-06-26T20:17:28.730" Score="4" ViewCount="660" Body="&lt;p&gt;I've been playing with the HC-06 BT module lately, but now I want to do more with it and I'm not sure how to. I was wondering if it's possible to get signal strength from the module, or would I have to purchase another HC-0# module to do so? Also the HC-05, can initiate connection if I'm understanding documentation right, and return available devices in the area? &lt;/p&gt;&#xA;" OwnerUserId="1671" LastEditorUserId="11" LastEditDate="2014-07-16T16:07:16.597" LastActivityDate="2015-04-13T20:32:47.953" Title="HC-0# Bluetooth module questions" Tags="|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3098" PostTypeId="2" ParentId="3042" CreationDate="2014-06-26T23:14:50.857" Score="6" Body="&lt;p&gt;To join the bus as a master you cannot supply a 7-Bit slave address so your code has two slaves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below you will find 2 sketches that successfully sends data to a slave. I would suggest you start looking at the I2C protocol and understand there are 4 Modes: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Master-&gt;Transmitter&lt;/li&gt;&#xA;&lt;li&gt;Master-&gt;Receiver&lt;/li&gt;&#xA;&lt;li&gt;Slave-&gt;Transmitter&lt;/li&gt;&#xA;&lt;li&gt;Slave-&gt;Receiver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All communications regardless of how the data is transferred requires a master. It's the master that controls the clock pulses, thats why its always the master that initiates the communcation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Tutorial/MasterReader&quot;&gt;MasterReader&lt;/a&gt;/&lt;a href=&quot;http://arduino.cc/en/Tutorial/MasterWriter&quot;&gt;MasterWriter&lt;/a&gt; tutorials on the arduino forum should now possibly start to make a little more sense when understanding those modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code shows how a master sends data to a slave, and then how it requests data from the slave. If we look at this code from the master point-of-view, you can see it essentially says, send this byte to the client (m-&gt;t &amp;amp; s-&gt;r), then request data from the slave (m-&gt;r,s-&gt;t)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Master Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x60&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin(); &#xA;  randomSeed(analogRead(3));&#xA;  Serial.begin(9600);  &#xA;}&#xA;&#xA;byte x = 0;&#xA;&#xA;void loop()&#xA;{&#xA;  x = random(0,255);&#xA;  Serial.print(&quot;Sent: &quot;);&#xA;  Serial.print(x, HEX);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  Wire.beginTransmission(0x60);   &#xA;  Wire.write(x);                &#xA;  Wire.endTransmission();   &#xA;  delay(500);&#xA;  Serial.println(&quot;Requesting Data&quot;); &#xA;  Wire.requestFrom(SLAVE_ADDRESS, 1);&#xA;&#xA;  int bytes = Wire.available();&#xA;  Serial.print(&quot;Slave sent &quot;);&#xA;  Serial.print(bytes);&#xA;  Serial.print(&quot; of information\n&quot;);&#xA;  for(int i = 0; i&amp;lt; bytes; i++)&#xA;  {&#xA;    x = Wire.read();&#xA;    Serial.print(&quot;Slave Sent: &quot;);&#xA;    Serial.print(x, HEX);&#xA;    Serial.print(&quot;\n&quot;);&#xA;  }  &#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x60&#xA;byte x = 0x00;&#xA;void setup()&#xA;{&#xA;  Wire.begin(SLAVE_ADDRESS);&#xA;  Wire.onReceive(receiveEvent);&#xA;  Wire.onRequest(requestEvent);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(100);&#xA;}&#xA;&#xA;void requestEvent() &#xA;{&#xA;  Serial.print(&quot;Request from Master. Sending: &quot;);&#xA;  Serial.print(x, HEX);&#xA;  Serial.print(&quot;\n&quot;);&#xA;&#xA;  Wire.write(x);&#xA;}&#xA;&#xA;void receiveEvent(int bytes)&#xA;{&#xA;  if(Wire.available() != 0)&#xA;  {&#xA;    for(int i = 0; i&amp;lt; bytes; i++)&#xA;    {&#xA;      x = Wire.read();&#xA;      Serial.print(&quot;Received: &quot;);&#xA;      Serial.print(x, HEX);&#xA;      Serial.print(&quot;\n&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1148" LastEditorUserId="1148" LastEditDate="2014-06-27T06:23:30.253" LastActivityDate="2014-06-27T06:23:30.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3099" PostTypeId="2" ParentId="2906" CreationDate="2014-06-27T00:22:31.623" Score="3" Body="&lt;p&gt;There's no reason that an MAF couldn't be used with an Arduino.  It's likely that the sensor will run on 12v and output an analog voltage from 0 - 12, so you might need to use a voltage divider with the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this &lt;a href=&quot;https://learn.sparkfun.com/tutorials/voltage-dividers&quot; rel=&quot;nofollow&quot;&gt;Sparkfun article&lt;/a&gt; on implementing a voltage divider to scale down the 0-12 volt signal to 0-5v for the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="2942" LastActivityDate="2014-06-27T00:22:31.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3100" PostTypeId="1" CreationDate="2014-06-23T10:24:45.250" Score="2" ViewCount="4043" Body="&lt;p&gt;I've been trying to get a LCD I bought from deal extreme to work for some time with my ATTiny85 chip. It should be capable. &#xA;I've tried googling the device but there is no proper documentation, so I figured the best way to get the address is to scan for it. How ever, the code below does not work :( any pointers? Anyone else who has gotten this I2C LCD display to work with Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I have no other output then the screen, the thought behind the code is to scan for devices and then when it finds one (the LCD is the &lt;em&gt;only&lt;/em&gt; one connected to the bus) should then print the address :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only have a serial programmer and attiny85 chips, so I have no way to bring it to a full Arduino UNO or whatever for further debugging.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyWireM.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  TinyWireM.begin();&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  byte error, address;&#xA;&#xA;  for(address = 1; address &amp;lt; 127; address++ ) &#xA;  {&#xA;    TinyWireM.beginTransmission(address);&#xA;&#xA;    error = TinyWireM.endTransmission();&#xA;&#xA;    if (error == 0) break;&#xA;&#xA;    delay(5000);&#xA;  }&#xA;&#xA;  LiquidCrystal_I2C lcd(address, 16, 2);&#xA;&#xA;  lcd.init();&#xA;  lcd.backlight(); &#xA;  lcd.clear();&#xA;&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Hello World - &quot; + address);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I2C LCD: &lt;a href=&quot;http://www.dx.com/p/iic-i2c-2-5-blue-screen-lcd-display-module-for-arduino-green-black-266170#.U6f_B_l_vIc&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/iic-i2c-2-5-blue-screen-lcd-display-module-for-arduino-green-black-266170#.U6f_B_l_vIc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2964" OwnerDisplayName="Jason94" LastEditorUserId="11" LastEditDate="2014-06-27T14:34:53.833" LastActivityDate="2014-06-27T20:28:32.177" Title="I cannot find the I2C device by scanning" Tags="|i2c|lcd|attiny|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3102" PostTypeId="2" ParentId="3100" CreationDate="2014-06-27T18:58:30.083" Score="1" Body="&lt;p&gt;I'm not sure on your program, but I bought a LCD display from Deal Extreme. I use the following address to communicate with the display:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems as that is the correct address for the LCD.&lt;/p&gt;&#xA;" OwnerUserId="2951" LastEditorUserId="220" LastEditDate="2014-06-27T20:28:32.177" LastActivityDate="2014-06-27T20:28:32.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3103" PostTypeId="1" CreationDate="2014-06-27T18:08:44.933" Score="0" ViewCount="217" Body="&lt;p&gt;I have actually reap 3 numerical values ​​(3 sensors) from a remote XBee module and then manipulate these 3 signal with an Arduino card attached to another XBee module. To do this, I chose to use the IO line passing because it proved the easiest. My problem is this: for the XBee transmitter, I set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ATID 3001 &#xA;ATDL 2&#xA;ATMY 1 &#xA;ATIU 1 / / to activate the IO option &#xA;ATD0 3 / / where is plugged a pushbutton &#xA;ATD1 3 / / where is plugged another pushbutton&#xA;ATD2 3 / / where is plugged proximity sensor (presence)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the XBee receiver (the one connected with the arduino board):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ATID 3001 ATDL 1 ATMY 2 ATIA 1&#xA;ATD0 4 &#xA;ATD1 4 &#xA;ATD2 4 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where I'm stuck is on the Arduino programming. Which command is used to determine the change of state of xbee remote? because I want to know if the states of the sensors on input are high or low.&lt;/p&gt;&#xA;" OwnerUserId="2950" OwnerDisplayName="lolode" LastActivityDate="2014-07-29T08:58:13.027" Title="Arduino and XBee Series1" Tags="|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3104" PostTypeId="2" ParentId="2906" CreationDate="2014-06-27T21:33:14.473" Score="1" Body="&lt;p&gt;Does the sensor have to elecrtonic? How about a ball and tube flow-meter, say a lucite tube with a gradually expanding bore (harder) or constant bore just larger than a ping-pong ball, with a number of relief holes up the side (easier)? The higher the ball rises, the more air escapes through the relief holes. leaving less to support the ball while escaping around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd calibrate it with a positive displacement (piston) pump driven at values of (displacement/time) in the range if interest, and marking pen to record the ball position for each.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-06-27T21:33:14.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3105" PostTypeId="1" AcceptedAnswerId="3108" CreationDate="2014-06-27T21:31:34.097" Score="8" ViewCount="813" Body="&lt;p&gt;Arduino has become quite costly where I come from (2/3 of the price of Raspberry PI) so I have created an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;noreferrer&quot;&gt;Arduino Severino clone&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had used the device with the RS-232 Usb-Serial converter. But after a (long) while, the device stopped working. My friend came up with a point that RS-232 communication ranges between +6 to -6 V (with thresholds at +3 and -3 volts).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have tried FT232 which uses 0 to 5 volts instead. I have a little &lt;del&gt;Chinese&lt;/del&gt; &lt;a href=&quot;http://www.ftdichip.com/&quot; rel=&quot;noreferrer&quot;&gt;FTDI&lt;/a&gt; chip designed to do that:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/UI2pR.jpg&quot; alt=&quot;usb to serial front side&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1hK83.jpg&quot; alt=&quot;usb to serial back side&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after connecting it, it behaves unexpectedly. (it had crashed my PC, one of the communication LEDs is on all the time...) I realised that the Arduino board might get broken for a different reason (an accidental short-circuit is &lt;em&gt;very&lt;/em&gt; likely).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for which type of communication is this &lt;em&gt;&quot;Arduino&quot;&lt;/em&gt; designed?&lt;/p&gt;&#xA;" OwnerUserId="2955" OwnerDisplayName="Tomáš Zato" LastActivityDate="2014-06-28T01:50:43.463" Title="For which type of serial communication is Arduino Severino designed?" Tags="|serial|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3106" PostTypeId="2" ParentId="3105" CreationDate="2014-06-27T21:39:55.863" Score="1" Body="&lt;p&gt;A typical 5V Arduino will use logic-level serial - that is 0 and 5V signalling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS232 has signal levels of plus or minus 3 to 15 volts. RS-232 drivers and receivers must be able to withstand indefinite short circuit to ground or to any voltage level up to ±25 volts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://en.wikipedia.org/wiki/RS-232#Voltage_levels&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many RS232 interfaces will receive 0-5V signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the original serial Arduino had circuitry to tolerate RS232 signal levels on it's inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since most computers now have USB rather than RS232 ports, Most users of Arduinos use a USB to logic-level serial interface. Some of the most popular chips for this are from FTDI such as the FT232RL on your Chinese clone of a &quot;&lt;a href=&quot;http://www.adafruit.com/products/284&quot; rel=&quot;nofollow&quot;&gt;FTDI Friend&lt;/a&gt;&quot;. In this case all the signals are logic-level 0-5V (or 3.3V if you change the jumper link).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the following are probably OK&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; PC DE-9 RS232    ----- Severino DE-9&#xA; PC DB-25 RS232   ----- Severino DE-9&#xA; PC USB port ---- &quot;FTDI Friend&quot; ---- Arduino 0(RX), 1(TX), Reset, GND and (optionally) VCC.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="316" OwnerDisplayName="RedGrittyBrick" LastActivityDate="2014-06-27T22:19:49.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3107" PostTypeId="2" ParentId="3105" CreationDate="2014-06-27T21:42:02.230" Score="3" Body="&lt;p&gt;The arduino you linked to is designed for RS232-level serial signals, which can be guessed from the use of a DB09 connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FT232 print you show is for 5V TTL (or maybe 3.3V 'TTL') signaling. Not compatible with your arduino. (BTW: that chip is not Chinese at all, it is made by www.ftdichip.com IMO they make the best usb-to-serial chip/driver products.)&lt;/p&gt;&#xA;" OwnerUserId="43104" OwnerDisplayName="Wouter van Ooijen" LastActivityDate="2014-06-27T21:42:02.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3108" PostTypeId="2" ParentId="3105" CreationDate="2014-06-27T21:47:51.070" Score="4" Body="&lt;p&gt;Looking at the schematic of that board it uses a very crude signal inversion for the RS-232.  This allows it to work of a standard RS-232 signal direct from a computer - &lt;em&gt;just&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's far from ideal and really should use a MAX232 (or similar) chip for the interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your FT232 adaptor should bypass that chunk of the circuit and connect direct to pins 0 and 1 of the Arduino clone.  The DTR pin of the FT232 should connect to the RESET pin of the Arduino clone via a 100nF capacitor to allow the IDE to reset the board to enter the bootloader.  Oh, and of course, connect the ground to your Arduino clone too (something Arduino users often forget).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can follow the serial breakout board portion of the &lt;a href=&quot;http://arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;Arduino breadboard tutorial&lt;/a&gt; and apply it to your board.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-06-27T21:58:19.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3109" PostTypeId="2" ParentId="3105" CreationDate="2014-06-27T23:40:33.977" Score="2" Body="&lt;p&gt;The Arduino Severino (Single Sided Serial version 3 - S3V3rino) is designed to work with RS-232 serial interface, not with the TTL serial signal levels of your FT232 board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to use your FT232 board to connect your Severino to a USB port, you'll need connections like those in the schematics below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kIUi8.png&quot; alt=&quot;Serial TTL to ATmega328 schematics&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, basically you need these connections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  FTDI |  ATmega328           | Arduino Severino &#xA;----------------------------------------------------&#xA;  DTR  |  Pin 1 (thru cap C6) | RESET (thru cap C6) &#xA;  RXI  |  Pin 3               | TX (D1)  &#xA;  TXO  |  Pin 2               | RX (D0)  &#xA;  VCC  |  Not connected       | Not connected&#xA;  CTS  |  Not connected       | Not connected  &#xA;  GND  |  Pin 8 &amp;amp; 22          | Ground&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's basically the same Majenko suggested (but with a picture added).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure you can make these connections directly into the Severino without damaging the board or anything else. You'll probably need to cut the TX/RX traces that go from the ATmega328 to the DB9 female connector on the Severino and wire them to the FTDI header pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best would be to modify the Severino EagleCAD schematics to remove all the RS-232 circuitry and replace it by TTL connector as shown in my schematics above and, with that, etch and assembly a new board. It's a lot of work, but can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="46" OwnerDisplayName="Ricardo" LastActivityDate="2014-06-28T01:33:18.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3110" PostTypeId="2" ParentId="1612" CreationDate="2014-06-28T02:11:02.420" Score="5" Body="&lt;p&gt;The nRF24L01+ has a somewhat complex SPI based interface, where many registers have to be configured and tested and timeouts honored.  Therefore it requires some kind of microcontroller to send or receive even the simplest message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be as simple as a 3.3v Arduino Pro Mini (less than $3 with shipping), and there are libraries which simplify the task of interfacing to it - in particular see the RF24 library (there are many variations, see &lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/TMRh20/RF24&lt;/a&gt; for a good one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But many other microcontrollers could work as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you bite the bullet and accept the need for a microcontroller, yes the code can identify the source of the signal (which pushbutton) and much, much more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use a dedicated device like an xBee which can be configured using a Windows utility to send the state of an input pin to another xBee; basically there is already a programmed microcontroller on the module along with the radio (not nRF24L01+ compatible).&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-06-28T02:11:02.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3112" PostTypeId="1" CreationDate="2014-06-28T19:29:33.443" Score="2" ViewCount="486" Body="&lt;p&gt;I am researching the schematic of the arduino GSM shield.&#xA;Link is this:&#xA;&lt;a href=&quot;https://www.sparkfun.com/datasheets/DevTools/Arduino/cellular%20shield-v12.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/DevTools/Arduino/cellular%20shield-v12.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i do not understand is the upper right part, wich says ARDUINO_SHIELDNOHOLES.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i want to do is understand which pins are used for Rx and which for Tx.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there are four usable pins on the arduino side and six(?) pins on the other side which says jumper, where are six pins on seeminly two jumpers...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone understand what is going on here?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-29T02:55:07.223" Title="Understanding arduino shield schematics" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3113" PostTypeId="1" AcceptedAnswerId="31733" CreationDate="2014-06-28T19:36:28.753" Score="0" ViewCount="467" Body="&lt;p&gt;Is it possible to do simple wireless on an Arduino, digital, or analog (SDR)? I would like to hook one pin to an antenna (or piece of wire) and generate signals with simple modulations (analog or digital).&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="220" LastEditDate="2014-07-04T15:56:42.193" LastActivityDate="2016-11-29T17:46:48.290" Title="Arduino diy wireless" Tags="|rf|" AnswerCount="2" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3114" PostTypeId="1" CreationDate="2014-06-28T21:33:57.330" Score="6" ViewCount="3321" Body="&lt;p&gt;Does anyone know what the actual baud rate that the CDC Based virtual serial port on the Leonardo runs at is? Serial::being() for the CDC version is just empty, so it's not setting a baud rate anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I'm debating between using the 32u4 or the 328p with an FTDI chip and trying to figure out if the 32u4 will be slower... since it uses a virtual COM port I'm assuming it is, but I'd be happy if I was wrong :)&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-06-28T22:18:40.057" Title="ATMega32u4 (Leonardo) Serial Baud Rate" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3115" PostTypeId="2" ParentId="3114" CreationDate="2014-06-28T22:18:40.057" Score="3" Body="&lt;p&gt;I'm not sure if the concept of an &quot;actual baud rate&quot; is really meaningful in a pure USB connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience, the 32u4 is faster than the 328p at serial-heavy tasks. There is no intermediate chip, and USB has much larger hardware buffers than the serial port does. I don't know how much processing you're planning to do on your data, but I would expect that a 32u4 can process serial data pretty much as fast as you can generate/process it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the host side, it seems to me that there is very little difference in whether the &quot;virtual COM port&quot; has an FTDI or a 32u4 on the other end, so I don't see why one should be faster than the other (though admittedly they go through different device drivers).&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-06-28T22:18:40.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3116" PostTypeId="2" ParentId="3112" CreationDate="2014-06-28T22:56:15.427" Score="1" Body="&lt;p&gt;&quot;ARDUINO_SHIELDNOHOLES&quot; is a connector in the &lt;a href=&quot;https://github.com/sparkfun/SparkFun-Eagle-Libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;SparkFun EAGLE libraries&lt;/a&gt; which is basically, well, an Arduino shield. It provides the schematic symbol as well as the PCB landing pattern for such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins on the top right of the schematic are two sets of 3, which should have &lt;a href=&quot;https://electronics.stackexchange.com/questions/74259/how-are-jumpers-used&quot;&gt;jumpers&lt;/a&gt; connecting either 1 and 2, or 2 and 3. To use hardware serial to connect the Arduino to the SM5100B you connect 2 and 3 of the &quot;top&quot; one and 1 and 2 of the bottom one. This connects D0 (RX) and D1 (TX) of the Arduino to TXD0 and RXD0 of the SM5100B. If you want to use software serial instead, connect the other pairs. D2 will then be connected to TXD0 (and will become the software RX), and D3 will be connected to RXD0 (and will become the software TX).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for &quot;TXD0&quot; and &quot;RXD0&quot; themselves, those are &lt;strong&gt;net names&lt;/strong&gt;, and all wires with the same net name, such as those and the ones connected to pins 19 and 20 of the SM5100B, are considered to be the same wire even if they aren't connected in the schematic.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-06-29T00:42:29.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3117" PostTypeId="2" ParentId="3112" CreationDate="2014-06-29T02:55:07.223" Score="1" Body="&lt;p&gt;A lot of good shields will give you the option to use hardware or software serial, and that is what's happening here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While you think you see four pins on the arduino side and six on the jumper side, what you're actually seeing is (yes) the four pins on the arduino, but those four pins go to four pins on the jumpers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other two pins on the jumpers (the ones in the middle) go to the TX and RX of the shield. The shield itself only has one TX (&lt;code&gt;TXD0&lt;/code&gt; pin 2 on &lt;code&gt;JP4&lt;/code&gt;) and one RX (&lt;code&gt;RXD0&lt;/code&gt; pin 2 on &lt;code&gt;JP6&lt;/code&gt;). So the jumpers form the connection between your arduino and the shield. This is why they are the middle pins, because you put the jumper on the first two, or the last two, depending on what it is you want to achieve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will note the net names of pin 2 of &lt;code&gt;JP4&lt;/code&gt; and &lt;code&gt;JP6&lt;/code&gt; relate directly to (and are connected to) pin 19 and 20 respectively of the chip on the shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole benefit of the jumpers is you connect &lt;code&gt;JP4&lt;/code&gt; and &lt;code&gt;JP6&lt;/code&gt; pins 1 and 2 to which closes the circuit and uses the inbuilt hardware serial (pin 1 of the jumper being arduino hardware and pin 2 being the &lt;code&gt;TXD0&lt;/code&gt; source from the shield). Connecting pins 2 and 3 means you close the circuit between the shields TX and RX to the arduino GPIO pins &lt;code&gt;D2&lt;/code&gt; and &lt;code&gt;D3&lt;/code&gt; which you can assign when initialising your software serial. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-29T02:55:07.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3118" PostTypeId="2" ParentId="3103" CreationDate="2014-06-29T08:31:03.963" Score="1" Body="&lt;p&gt;There are two ways this could be tackled:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;physically through connections between the xbee and arduino and read the xbee pins directly (I've never done this, and it comes down to your shield supporting it). Each of the desired output pins of the receiving xbee would be tied to a GPIO pin of the arduino. Alternatively,&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;serially using &lt;code&gt;AT&lt;/code&gt; commands via the serial connection. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have never worked with series one, but essentially:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;setup a serial connection to your arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;send the desired &lt;code&gt;AT&lt;/code&gt; command requesting the pins value&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;read the serial port response&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Make sure to read the manual for the series 1 xbees for the right &lt;code&gt;AT&lt;/code&gt; commands and in how to interpret the results. &lt;a href=&quot;http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/point-multipoint-rfmodules/xbee-series1-module&quot; rel=&quot;nofollow&quot;&gt;Register at digi&lt;/a&gt; and download the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, just realise reading the xbee data is going to be different depending on how you have the xbee setup, ie &lt;code&gt;API&lt;/code&gt; vs &lt;code&gt;AT&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is someone who has done some work with series 1: &lt;a href=&quot;http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index&quot; rel=&quot;nofollow&quot;&gt;http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll leave the actual implementation to you since this sounds a little like a homework assignment. Give it a go using the second method above and see how you go. Then post back here (ie update the question) including source code and exact layout (schematic preferred) and we'll see where we can help you from there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hint: google such terms as: &quot;read data pins xbee arduino&quot; (without the quotes).&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-06-29T08:31:03.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3120" PostTypeId="1" CreationDate="2014-06-29T09:55:34.933" Score="2" ViewCount="3778" Body="&lt;p&gt;Like: basics of electrical circuits, etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to go far in Arduino and electronics.&lt;/p&gt;&#xA;" OwnerUserId="2949" LastActivityDate="2014-07-02T13:49:38.530" Title="What background do I need to have before starting Arduino?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ClosedDate="2014-07-02T18:58:46.320" ContentLicense="CC BY-SA 3.0" />
  <row Id="3121" PostTypeId="2" ParentId="3120" CreationDate="2014-06-29T10:55:29.243" Score="7" Body="&lt;p&gt;I am a Electrical technician and bought the starter kit from the Arduino team for my 13 year old son. My plan was to try the kit to teach my son about electronics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end result is that he is the one showing me new stuff. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion, you do not need any special background before starting with Arduino. You should have a interest in learning something new, and in learning about electronics. To get started, buy a tutorial book and a starter kit. (Many starter-kits comes with a tutorial book) When you have gone through the book, you will have some basic knowledge and a base to continue learning from. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck&lt;/p&gt;&#xA;" OwnerUserId="2951" LastActivityDate="2014-06-29T10:55:29.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3122" PostTypeId="1" CreationDate="2014-06-29T14:47:00.213" Score="0" ViewCount="496" Body="&lt;p&gt;I've looked around a ton so it's probably not available but does anyone know if there is a usable core for the ATMega16u2 (the chip the Uno and Due uses for USB to Serial). I have a project I was going to use the 32u4 for but they aren't really available for several months and the 16u2 has all the functionality that I would really need.&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2015-10-24T04:51:35.713" Title="Arduino core for ATMega16u2" Tags="|core-libraries|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3123" PostTypeId="1" CreationDate="2014-06-29T15:22:16.523" Score="0" ViewCount="1916" Body="&lt;p&gt;I've got the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int rx = -1;&#xA;const int tx = 4;&#xA;&#xA;SoftwareSerial mySerial(rx, tx);&#xA;&#xA;void setup() &#xA;{ &#xA;  mySerial.begin(2400);&#xA;  pinMode(tx, OUTPUT);&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  if(mySerial.available())&#xA;  {&#xA;    String data = &quot;Hello World&quot;;&#xA;&#xA;    for(int k = 0; k &amp;lt; data.length(); k++ )&#xA;    {&#xA;      mySerial.write(0xAA);&#xA;      mySerial.write(data[k]);&#xA;    }&#xA;&#xA;    mySerial.write(0xA9);&#xA;  }&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I'm trying to send to to a &lt;a href=&quot;http://www.dx.com/p/433mhz-wireless-transmitter-module-superregeneration-for-arduino-green-149254#.U7At__l_vIc&quot; rel=&quot;nofollow&quot;&gt;RF transmitter module&lt;/a&gt;. It all compiles just fine, but am I forgetting something? And does pin 4 = physical pin 3?&lt;/p&gt;&#xA;" OwnerUserId="2964" LastActivityDate="2014-06-30T17:21:58.027" Title="How can I send serial over RF?" Tags="|attiny|softwareserial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3124" PostTypeId="7" CreationDate="2014-06-29T16:46:31.633" Score="0" Body="&lt;ul&gt;&#xA;    &lt;li&gt;Specific issues with Arduino boards, clones, code, and the Arduino IDE&lt;/li&gt;&#xA;    &lt;li&gt;Real problems or questions that you’ve encountered&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-06-29T16:46:31.633" LastActivityDate="2014-06-29T16:46:31.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3125" PostTypeId="1" CreationDate="2014-06-29T19:21:48.337" Score="3" ViewCount="607" Body="&lt;p&gt;I want to read the source code of an arduino library that comes with the IDE. &#xA;Specifically the GSM.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont know the location of the standard libraries that come with the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only know the location of the user installed libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So where is the source code of GSM.h?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2018-10-22T10:08:16.930" Title="Arduino standard libraries location" Tags="|library|core-libraries|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3126" PostTypeId="2" ParentId="3125" CreationDate="2014-06-29T19:27:22.430" Score="4" Body="&lt;p&gt;Ok, i found out the location.&#xA;In Win 7, it is C:\Program Files (x86)\Arduino\libraries&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-06-29T19:27:22.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3127" PostTypeId="7" CreationDate="2014-06-29T20:16:55.550" Score="0" Body="&lt;ul&gt;&#xA;    &lt;li&gt;Anything not directly related to Arduino&lt;/li&gt;&#xA;    &lt;li&gt;Any question that doesn't require knowledge about the Arduino platform to answer (try Stack Overflow for general coding questions or Electrical Engineering for general electronics questions)&lt;/li&gt;&#xA;    &lt;li&gt;Questions that are primarily opinion-based&lt;/li&gt;&#xA;    &lt;li&gt;Questions with too many possible answers or that would require an extremely long answer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="-1" LastEditorUserId="220" LastEditDate="2014-06-29T20:16:55.550" LastActivityDate="2014-06-29T20:16:55.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3128" PostTypeId="2" ParentId="3123" CreationDate="2014-06-29T20:51:40.810" Score="0" Body="&lt;p&gt;First off, are you trying to send to the 433MHz transmitter? This will not work.&#xA;If you mean you are using the 433MHz transmitter to send data to a receiver, the VirtualWire.h library work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using another transmitter please add more info on the transmitter used in this project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;HumanHarddrive on youtube got a tutorial on the DX transmitter and receiver.&#xA;&lt;a href=&quot;http://www.youtube.com/watch?v=e8RhXtst7ME&quot; rel=&quot;nofollow&quot;&gt;Tutorial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2951" LastEditorUserId="2951" LastEditDate="2014-06-29T21:20:26.717" LastActivityDate="2014-06-29T21:20:26.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3130" PostTypeId="2" ParentId="716" CreationDate="2014-06-30T10:30:36.347" Score="1" Body="&lt;p&gt;The Ping))) sensor uses a crystal for timing.&#xA;Some of the cheap knock-offs actually use a MAX3232 chip (which is an RS232 serial port/usart) to detect the return pulse, just for the carrier detection. If the parallax is similar, these have a fairly wide range of frequencies they work at, since you never know the baud rate to expect, from 9600 up to 1mhz, although they are deliberately not very fussy about accidentally picking up nearby frequencies.&#xA;Since there's probably some other logic on the other chips, and everything is probably run off the one crystal, I'd recommend going to lower frequencies, otherwise you're overclocking.&#xA;Also, make sure to send a longer trigger pulse because all the logic will be slower.&#xA;From the picture, it looks like a 16MHz crystal, which must be divided down to the 40KHz.&#xA;So solder in a 14MHz, and an 11MHz, lengthen the 5 uS trigger pulse accordingly, and you should be good to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, you might also consider scanning further apart. If it's taking you 30 seconds, you're probably checking every degree; maybe try every 15 or 30 degrees (just make sure to give the servo time to move)&lt;/p&gt;&#xA;" OwnerUserId="2971" LastActivityDate="2014-06-30T10:30:36.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3132" PostTypeId="2" ParentId="3039" CreationDate="2014-06-30T13:56:13.173" Score="0" Body="&lt;p&gt;If what you want is high speed, the serial baud rate is your main concern. I assume that you are using an Arduino with a serial to USB converter chip, such as the Uno or Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transferring at 115200 baud, you send 11520 bytes/s at normal serial settings (1 start + 8 data + 1 stop bits = 10 bits to send 1 byte of data). With an Arduino running at 16 MHz clock, you can execute 16M / 11520 = 1389 instructions in the time it takes to transmit one byte. So you don't have to worry much about slow library routines, what you have to worry about is how many bytes you send. In that way you are right not to use Serial.print, as it will convert your int to ascii, making all number larger than 99 slower to transmit (for a uint16).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you send data with Serial.write it is first stored in a ring buffer, then transmitted in the background by an Interrupt Service Routine. The ring buffer is typically 64 bytes. Once the the buffer is full, a call to Serial.write will block until a byte has been transmitted, so there is space in the buffer again. Therefore the timing in your main loop isn't really necessary, you can remove it and your sampling rate will adapt to your serial baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the data has reached the serial to USB converter chip, it will be transmitted on the USB bus at 12 Mbit/s. I don't know the exact data transfer rate since there's a lot more overhead on USB than on the serial, but you can rest assured that the bottleneck isn't here. I don't think you have to worry about USB cable lengths as there is built-in error detection and retransmit in the USB protocol, and the speed is so much faster than the serial link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the computer the data can be buffered in several places, it all depends on device drivers and serial libraries used. I'm not an expert here. With no flow control, the drivers/libraries probably have no choice but to drop data if it is receiving more than the end application or later layer can process. Maybe matlab or it's serial implementation or you computer is slow in some way (the data really isn't arriving very fast at all for a modern computer). So you could lower the baud rate or try to deal with lost packets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a suggestion for dealing with lost packets: Reserve the upper x bits in each byte you transmit to hold the number of that byte in its sequence. You could f.ex. reserve 2 bits, allowing you to send up to 4 byte packets belonging together. Each byte-packet would have 6 data bits, enabling you to send numbers with 24 bits of precision.&#xA;To send a uint16:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send_int16(uint16_t data)&#xA;{&#xA;  Serial.write((0 &amp;lt;&amp;lt; 6) | (data &amp;amp; 0b00111111));&#xA;  data &amp;gt;&amp;gt;= 6;&#xA;  Serial.write((1 &amp;lt;&amp;lt; 6) | (data &amp;amp; 0b00111111));&#xA;  data &amp;gt;&amp;gt;= 6;&#xA;  Serial.write((2 &amp;lt;&amp;lt; 6) | (data &amp;amp; 0b00111111));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in matlab you should wait for a sequence of packets numbered 0, 1, 2 in the two uppermost bits, remove the numbering and put the packets together with bitwise operators.&#xA;If you get a malformed sequence, eg. 0, 2, can discard it and wait for the next byte starting with a zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't really used matlab, so you are on your own.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-06-30T13:56:13.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3133" PostTypeId="2" ParentId="3122" CreationDate="2014-06-30T14:36:52.283" Score="1" Body="&lt;p&gt;As @IgnacioVazquez-Abrams said, a 16u4 is virtually identical with a 32u4, so you can use a Leonardo or Micro core with a tiny modification to boards.txt. A 16u2 is a rather different animal, with fewer timers, many fewer pins, and no A/D converter, so you’d have to do a fair amount of editing to obtain a usable Arduino core. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, if you’re reasonably fluent in C++, building your own Arduino core is not very difficult, and I found it an instructive exercise. If you care about getting your project up as quickly as possible and not get sidetracked, however, go with the 16u4. &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-06-30T14:36:52.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3134" PostTypeId="2" ParentId="3067" CreationDate="2014-06-30T14:52:14.937" Score="1" Body="&lt;p&gt;You should be aware that SoftwareSerial is blocking other interrupts when sending/receiving. I'm not sure exactly how AltSoftSerial behaves, but I believe it was written to deal with that issue. The issue arises if you use a slow baud rate on the SoftwareSerial in combination with a high baud rate on hardware serial. Then you can loose incoming data on the hardware serial. AltSoftSerial will probably be completely blocked during SoftwareSerial activity - hardwareserial can still send / receive one-two bytes in the hardware tx/rx registers. According to &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&lt;/a&gt; you can use AltSoftSerial together with SoftwareSerial, as long as the baud rate for SoftwareSerial is at least 10 times the baud rate of that used for AltSoftSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you never transmit/receive simultaneously on different interface, you don't really have to worry about any of the above mentioned issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I write SoftwareSerial, I refer to NewSoftSerial, which has been called SoftwareSerial in Arduino for a while now (since 1.0 I believe).&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-06-30T14:52:14.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3135" PostTypeId="1" AcceptedAnswerId="3137" CreationDate="2014-06-30T15:41:19.077" Score="0" ViewCount="2616" Body="&lt;p&gt;I was trying to write a Telnet server that would be able to accept commands of sorts using the Arduino Ethernet library, and in order to access what the client was saying (to compare it to strings to check what command the client entered), I made a buffer string that would read until &lt;code&gt;\n&lt;/code&gt;, which is part of the standard Telnet library. However, the string would never get printed to the serial connection (just for debugging purposes). Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xFE, 0xED };  // this client's MAC address&#xA;&#xA;EthernetServer server(23);  // telnet is 23&#xA;boolean alreadyConnected = false;&#xA;&#xA;void setup() {&#xA;&#xA;  Ethernet.begin(mac);&#xA;&#xA;  server.begin();  // open the socket&#xA;&#xA;  Serial.begin(9600); &#xA;  while (!Serial) {&#xA;    ; // wait for serial to start, Leonardo only&#xA;  }&#xA;&#xA;  Serial.print(&quot;Connect to &quot;);&#xA;  Serial.print(Ethernet.localIP());&#xA;  Serial.println(&quot;:23.&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  EthernetClient c = server.available();&#xA;&#xA;  if (c) {&#xA;    String messageBuffer = &quot;&quot;;&#xA;&#xA;    if (!alreadyConnected) {&#xA;      c.flush();&#xA;      Serial.println(&quot;New client&quot;);&#xA;      c.println(&quot;test post, please ignore&quot;);&#xA;      alreadyConnected = true;&#xA;    }&#xA;    if (c.available() &amp;gt; 0) {&#xA;&#xA;      char thisChar = c.read();&#xA;&#xA;      //server.write(thisChar);&#xA;&#xA;      //buffer until the client sends a new line&#xA;      if (thisChar == '\n') {&#xA;        Serial.println(messageBuffer);&#xA;        messageBuffer = &quot;&quot;;&#xA;      } else {&#xA;        messageBuffer += thisChar;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most of this code was copied from the Telnet chat server example, but I changed the &lt;code&gt;Serial.write(thisChar)&lt;/code&gt; line, because I wanted to put it into a string first. When this is run, and a user &lt;code&gt;telnet&lt;/code&gt;s to the IP, the Arduino prints &lt;code&gt;New client&lt;/code&gt;, but when the user sends data, it doesn't print anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions for what I'm doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="2953" LastActivityDate="2015-01-10T19:26:47.857" Title="Buffering data from EthernetServer clients" Tags="|ethernet|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3136" PostTypeId="2" ParentId="3123" CreationDate="2014-06-30T17:21:58.027" Score="1" Body="&lt;p&gt;In your loop function you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(mySerial.available())&#xA;{&#xA;  String data = &quot;Hello World&quot;;&#xA;&#xA;  for(int k = 0; k &amp;lt; data.length(); k++ )&#xA;  {&#xA;    mySerial.write(0xAA);&#xA;    mySerial.write(data[k]);&#xA;  }&#xA;&#xA;  mySerial.write(0xA9);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;available()&lt;/code&gt; function returns the number of bytes available in the receive buffer. You say your module is a transmitter, so there will never be any data to receive (I can see the module doesn't even have a tx pin). Hence you will never transmit any data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said it's not a good idea to send data plain over wireless. It might work to some extent, but you'll likely get much more lost data. Look at the virtual wire library or google &quot;manchester coding&quot; if you wan't to roll your own.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-06-30T17:21:58.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3137" PostTypeId="2" ParentId="3135" CreationDate="2014-06-30T18:44:43.030" Score="0" Body="&lt;p&gt;Well, I asked on the #arduino IRC channel, and realized my stupid mistake. I was setting the buffer to &lt;code&gt;&quot;&quot;&lt;/code&gt; &lt;strong&gt;inside&lt;/strong&gt; the loop.&lt;/p&gt;&#xA;" OwnerUserId="2953" LastActivityDate="2014-06-30T18:44:43.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3140" PostTypeId="2" ParentId="1138" CreationDate="2014-07-01T07:37:51.463" Score="2" Body="&lt;p&gt;Have you checked out the Library homepage? &lt;a href=&quot;http://www.henningkarlsen.com/electronics/library.php?id=51&quot; rel=&quot;nofollow&quot;&gt;Henning Karlsen's library page&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He has made a user manual for the library. There is also a reference to what pin goes where in the requirements document.&lt;/p&gt;&#xA;" OwnerUserId="2951" LastEditorUserId="6936" LastEditDate="2015-07-25T16:50:31.483" LastActivityDate="2015-07-25T16:50:31.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3141" PostTypeId="1" CreationDate="2014-07-01T14:27:49.830" Score="2" ViewCount="366" Body="&lt;p&gt;I have a project that's currently using Arduino Uno with a cheap class-2 bluetooth serial adapter from ebay to send and receive data and control a LED light strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it struggles to establish connection at distances more than couple meters. I'd like to expand that range a bit - 15 meters with two load-bearing walls in the way. Bandwidth requirements are next to none - it should just move couple integers around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions how to do that on the cheap? From what I've seen, class-1 bluetooth adapters go for ~60$, two xbee modules + usb adapter end up costing even more, and wifi solutions seem to reside in the same price range. At that price point, it seems better to get a raspberry pi, wifi dongle and a couple beers for the software re-write. Am I overlooking some solution?&lt;/p&gt;&#xA;" OwnerUserId="2987" LastActivityDate="2014-07-01T17:20:43.210" Title="Cheap medium range wireless communication with a linux PC" Tags="|xbee|bluetooth|remote-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3142" PostTypeId="2" ParentId="3141" CreationDate="2014-07-01T15:19:57.607" Score="2" Body="&lt;p&gt;Since one end is a PC I would look into a Wifi shield for the arduino. That way you would not need any extra hardware on the PC side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a Wifi shield for less than 2 xbee modules. But using wifi will require changes to your code since it won't be using the serial port for communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another wireless option that I have no personal experience with is &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf2401&quot; rel=&quot;nofollow&quot;&gt;NRF2401&lt;/a&gt; modules -- you can get them dirt cheap on ebay (caveat emptor) but they use an SPI interface so you can't directly interface with them directly on the PC side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that depending on the LED strip you may not be able to drive it directly from a raspberry pi.  For example WS2811 driven LEDs (AKA adafruit NeoPixels) need precise timing that you can't get (or is tricky to get) with the raspberry pi.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-07-01T15:19:57.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3143" PostTypeId="2" ParentId="3141" CreationDate="2014-07-01T15:26:13.933" Score="0" Body="&lt;p&gt;&quot;&lt;a href=&quot;http://www.instructables.com/id/How-to-set-up-OpenWRT-on-a-pocket-router-WR703N/&quot; rel=&quot;nofollow&quot;&gt;Smart home automation webserver on OpenWRT router WR703N interfaced to Arduino, compared to Raspberry Pi and Ubuntu&lt;/a&gt;&quot; may lead you to some answers...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just think of that solution as a kind of &quot;homegrown Arduino YÙN&quot;... just older and cheaper: &quot;&lt;a href=&quot;http://hackaday.com/2012/06/12/nah-you-dont-need-an-ethernet-module-for-your-arduino/&quot; rel=&quot;nofollow&quot;&gt;Nah, you don’t need an Ethernet module for your Arduino&lt;/a&gt;&quot;&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="653" LastEditDate="2014-07-01T17:20:43.210" LastActivityDate="2014-07-01T17:20:43.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3144" PostTypeId="2" ParentId="3088" CreationDate="2014-07-01T16:38:11.980" Score="2" Body="&lt;p&gt;Yes you can. If you use a USB FTDI type cable to connect your computer to the SoftwareSerial pins, you can use a terminal emulator program (HyperTerm, putty, etc) to communicate with the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-07-01T16:38:11.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3145" PostTypeId="2" ParentId="3120" CreationDate="2014-07-01T16:41:54.170" Score="0" Body="&lt;p&gt;You need a basic understanding of programming because you will need to program in C++.&#xA;You need basic computer literacy, but I bet you've got that if you are on this website.&#xA;You need some understanding of electronics, such as a High-School level textbook. You need to understand resistors, diodes, voltages, current etc. Otherwise you'll get very frustrated.&lt;/p&gt;&#xA;" OwnerUserId="2750" LastActivityDate="2014-07-01T16:41:54.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3146" PostTypeId="2" ParentId="3120" CreationDate="2014-07-01T17:50:34.690" Score="0" Body="&lt;p&gt;You need to learn some absolute basics about electronics so you don't fry your arduino. (Don't exceed the current limits on the i/o pins. How to use Ohm's Law to calculate current. How to tie inputs to ground with a resistor. How to tie inputs to +5 through a resistor.  How to estimate the total current load of your entire circuit to make sure it doesn't overload the +5 regulated power from the Arduino. Basic precautions against static electricity.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beyond that, it makes a great learning tool, and you should be able to learn as you go. Build the sample projects that are on the Arduino website. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to buy a book on logic circuits. I read &quot;The CMOS Cookbook&quot; years ago, and it gave me a good strong grounding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll also want to learn programming, since you need to use C or C++. Again, though, you can use the Arduino as a learning tool. Looking at the sketches from the website and modifying them will help you learn.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-01T17:50:34.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3147" PostTypeId="2" ParentId="1612" CreationDate="2014-07-01T19:56:50.953" Score="3" Body="&lt;p&gt;An ATTiny85 can drive the NRF24L01+: &quot;&lt;a href=&quot;http://nerdralph.blogspot.ca/2014/01/nrf24l01-control-with-3-attiny85-pins.html&quot; rel=&quot;nofollow&quot;&gt;nrf24l01+ control with 3 ATtiny85 pins&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least this is not a &quot;full&quot; Arduino...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2015-06-06:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hackaday News: &quot;&lt;a href=&quot;http://hackaday.com/2015/06/05/embed-with-elliot-multiplexing-spi-uses-few-pins/&quot; rel=&quot;nofollow&quot;&gt;EMBED WITH ELLIOT: MULTIPLEXING SPI USES FEW PINS&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The referred blog entry is: &quot;&lt;a href=&quot;http://nerdralph.blogspot.ca/2015/05/nrf24l01-control-with-2-mcu-pins-using.html&quot; rel=&quot;nofollow&quot;&gt;nRF24l01 control with 2 MCU pins using time-division duplexed SPI&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(-: Nice countdown... 3 pins, 2 pins, ... ;-)&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="653" LastEditDate="2015-06-06T01:20:38.223" LastActivityDate="2015-06-06T01:20:38.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3148" PostTypeId="1" CreationDate="2014-07-01T22:19:58.160" Score="1" ViewCount="2937" Body="&lt;p&gt;I'm trying to program AtTiny13 using Arduino IDE. I have connected the atTiny to my PC using USBasp programer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to write a simple blink application to test whether it works or not. Which pins should I blink?&lt;/p&gt;&#xA;" OwnerUserId="2955" LastActivityDate="2015-02-20T18:39:41.323" Title="What pins should I use when blinking AtTiny13 with arduino IDE?" Tags="|arduino-ide|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3149" PostTypeId="2" ParentId="3148" CreationDate="2014-07-01T22:33:45.860" Score="1" Body="&lt;p&gt;You'll need an Arduino library that supports that chip, to make it appear in the Tools &gt; Board list.  The library docs will tell you which pins then correspond to which Arduino digital I/Os. From that you can decide which pin to attach an LED to (with resistor) and how to edit the blink sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;a href=&quot;http://www.instructables.com/id/Pimp-Your-Chocolates-with-Arduino-IDE-and-ATtiny13/step2/Program-the-ATtiny13/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Pimp-Your-Chocolates-with-Arduino-IDE-and-ATtiny13/step2/Program-the-ATtiny13/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="973" LastActivityDate="2014-07-01T22:33:45.860" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="3150" PostTypeId="1" CreationDate="2014-07-01T22:56:44.293" Score="3" ViewCount="1144" Body="&lt;p&gt;So, before starting to learn with something else, I'll give it one last try. The avrdude is complaining that the device signature doesn't match. Whatever, I don't care. To me, what's written on it is what counts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to force it to upload the program. It promises to ignore the problem if &lt;code&gt;-F&lt;/code&gt; is specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where are settings for avrdude parameters, like other IDEs have settings for their compilers?&lt;/p&gt;&#xA;" OwnerUserId="2955" LastActivityDate="2014-07-09T21:28:13.127" Title="How to add the -F switch for avrdude in Arduino IDE" Tags="|arduino-ide|attiny|avrdude|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3151" PostTypeId="1" AcceptedAnswerId="3152" CreationDate="2014-07-01T23:59:49.363" Score="1" ViewCount="1774" Body="&lt;p&gt;I'm looking to purchase an Arduino for a little robot I'm going to make.  The reason I've chosen Arduino is because it's much easier to use with servos and LEDs than a Raspberry Pi, but a nice little touch would be to have it play some sounds (voice recordings and mechanical SFX).  I was just wondering (now I'm not after opinions here, but looking more at how each of the boards have been designed) what the &lt;em&gt;best&lt;/em&gt; Arduino board for playing sound is, or if they are all pretty much the same in this regard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note 'pins' was the best tag I could find for this post for lack of a 'sound' or 'speakers' one.  If you want to edit it to something more appropriate please do)&lt;/p&gt;&#xA;" OwnerUserId="2784" LastEditorUserId="368" LastEditDate="2014-07-02T00:29:41.897" LastActivityDate="2016-02-26T22:39:24.767" Title="Best Arduino board to play sound" Tags="|audio|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3152" PostTypeId="2" ParentId="3151" CreationDate="2014-07-02T00:28:55.930" Score="4" Body="&lt;p&gt;If all you need is to play back lo-fi audio then any with PWM will do, which means that any Arduino will do. If you want hi-fi sound then you'll need a DAC, which means either choosing the Due or using a discrete DAC via SPI. If you need decoding of complex audio formats such as MP3 or Vorbis then you'll need either the Due for its power, or a separate audio playback shield that supports the formats you're interested in.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-02T00:28:55.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3153" PostTypeId="5" CreationDate="2014-07-02T00:32:17.197" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2014-07-02T00:32:17.197" LastActivityDate="2014-07-02T00:32:17.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3154" PostTypeId="4" CreationDate="2014-07-02T00:32:17.197" Score="0" Body="Using an Arduino to play noise, sounds, or music. Also for questions about audio input." OwnerUserId="368" LastEditorUserId="10794" LastEditDate="2015-09-02T01:46:21.913" LastActivityDate="2015-09-02T01:46:21.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3158" PostTypeId="1" CreationDate="2014-07-02T20:11:14.130" Score="0" ViewCount="909" Body="&lt;p&gt;many mac keyboards have a power button. Is there a way to mimic this power button shortcut from an arduino?&lt;/p&gt;&#xA;" OwnerUserId="3005" LastActivityDate="2019-03-23T19:03:33.350" Title="Mac Power via Keyboard Shortcut?" Tags="|mac-os|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3159" PostTypeId="1" CreationDate="2014-07-02T21:19:41.147" Score="2" ViewCount="134" Body="&lt;p&gt;I am working on a project where I am trying to get an input signal filtered according to its frequency. I checked the signal before it went into my DSP algorithm to see where the problem was and I found that the frequency was remaining the same no matter if I put in 30Hz 120Hz or 58kHz. This leads me to think I have a problem with the sampling rate. Does that sound like it is the actual issue? Or am I barking up the wrong tree?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just using the readADC command to read in the data&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()          //Setup Function to intialise ADC and Serial Communication&#xA;{&#xA;DDRC=0x00;            //PORTC as INPUT&#xA;DDRD=0xFF;            //PORTD is OUTPUT&#xA;DDRD=0xFF;&#xA;for(i=0;i&amp;lt;N;i++)&#xA;  {&#xA;    InitADC();&#xA;    a=ReadADC(4);&#xA;    x[i]=a;&#xA;  }&#xA;  Serial.begin(9600);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3007" LastEditorUserId="2839" LastEditDate="2014-07-13T22:07:38.280" LastActivityDate="2017-12-26T18:10:27.340" Title="Frequency will not change" Tags="|arduino-uno|signal-processing|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3160" PostTypeId="1" CreationDate="2014-07-02T22:11:01.817" Score="3" ViewCount="1327" Body="&lt;p&gt;I'm trying to create an app for my science fair that uses bluetooth to track people in a determined place.&#xA;I was thinking about one Arduino system to receive all the information and transmit through a network and some Arduino slaves to duplicate the signal and cover the hole place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Resuming...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino slaves placed all over the place to track people&lt;/li&gt;&#xA;&lt;li&gt;One Arduino connected to the network to receive all the information from the slaves and pass it through the network.&lt;/li&gt;&#xA;&lt;li&gt;Some kind of web app inside the main Arduino with an API to manage the data and make it friendly for third-party apps&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I was wondering of what kind of equipment should I buy to make this happen. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Each cellphone with it's bluetooth enabled will work as a person (sending signal) - my Arduino slaves will receive the signal (find bluetooth around it) and send the device name and signal strength to the arduino master - The arduino master (connected to the network) will interpenetrate the responses and send the results to the built-in web server - Apps will make requests to the web app to get this data and show in a plant where're these people.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it will work like these bluetooth stickers that you can plug in to your keys, phone e etc... and with the app you can search for them in your house via bluetooth from your cellphone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a better explanation:&#xA;&lt;a href=&quot;http://electronics.howstuffworks.com/bluetooth-surveillance.htm&quot; rel=&quot;nofollow&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3008" LastEditorUserId="3008" LastEditDate="2014-07-03T01:57:32.890" LastActivityDate="2016-02-19T12:42:28.750" Title="Bluetooth Master and Slave to track device's locations" Tags="|programming|wifi|web-server|bluetooth|networking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3161" PostTypeId="1" CreationDate="2014-07-03T03:29:04.933" Score="2" ViewCount="904" Body="&lt;p&gt;I have an &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;Adaruit Motor Shield v2&lt;/a&gt;, and a &lt;a href=&quot;https://www.adafruit.com/products/169&quot; rel=&quot;nofollow&quot;&gt;Tower Pro SG92R micro servo&lt;/a&gt;. I've got it setup so the shield works with my Arduino Uno, and I've successfully tested using other types of motors on the shield. I could not find any sample code for working with a servomotor though. The shield has two dedicated spots for a servo (labeled &quot;Servo 1&quot; and &quot;Servo 2&quot;). I'm planning to use wall wart transformer to power the motor separately from the Arduino. Any pointers/links to documentation/sample code would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2958" LastActivityDate="2014-07-03T15:50:20.743" Title="Is there some sample code for operating a servo with an Adafruit Motor Shield?" Tags="|arduino-uno|servo|arduino-motor-shield|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3162" PostTypeId="2" ParentId="2880" CreationDate="2014-07-03T12:00:21.310" Score="1" Body="&lt;p&gt;I had the same problem and this seems to work. If you right click on the Kickoff Application launcher and open 'edit applications' with KDE Menu Editor, you can 'add new item' where you want and give it a name (ArduinoIDE) and then just put arduino (small case) in the 'command' box, and shut down KDE Menu Editor, it should appear in the menu where ever you placed it. At least it did for me.&lt;/p&gt;&#xA;" OwnerUserId="3015" LastActivityDate="2014-07-03T12:00:21.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3163" PostTypeId="2" ParentId="3161" CreationDate="2014-07-03T15:50:20.743" Score="3" Body="&lt;p&gt;On the Motor shield the servo headers are directly connected to pins 9 and 10 (I think 9 is servo 2 and 10 is servo 1).  So you can use the standard servo examples using pins 9 and 10.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to power the servos with an external power supply you must cut a trace on the back of the board -- the silk screen tells you where to cut.  Then you need to connect power to the &quot;Opt Servo&quot; input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power to the servos is not changed by the power jumper used for the DC/stepper motors.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-07-03T15:50:20.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3164" PostTypeId="1" CreationDate="2014-07-03T18:09:59.903" Score="1" ViewCount="1345" Body="&lt;p&gt;So lately I've been trying to control the speed of a 120mm 4-pin computer fan using PWM. This is what I've got so far, with the part above void loop() being from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=109403.0&quot; rel=&quot;nofollow&quot;&gt;this thread&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Definition of Arduino type&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;#define  IS_MEGA  (1)&#xA;#define  IS_UNO   (0)&#xA;#else&#xA;#define  IS_MEGA  (0)&#xA;#define  IS_UNO   (1)&#xA;#endif&#xA;&#xA;// Analog output (i.e PWM) pins. These must be chosen so that we can change the PWM frequency without affecting the millis()&#xA;// function or the MsTimer2 library. So don't use timer/counter 1 or 2. See comment in setup() function.&#xA;// THESE PIN NUMBERS MUST NOT BE CHANGED UNLESS THE CODE IN setup(), setTransistorFanSpeed() AND setDiodeFanSpeed() IS CHANGED TO MATCH!&#xA;#if IS_UNO&#xA;// On the Uno we can only use the OC1B pin, so these pin numbers are both 10&#xA;const int transistorFanPin = 10;     // OC1B&#xA;const int diodeFanPin = 10;          // OC1B&#xA;#else&#xA;// On the Mega we use OC1B and OC1C&#xA;const int transistorFanPin = 12;     // OC1B&#xA;const int diodeFanPin = 13;          // OC1C&#xA;#endif&#xA;&#xA;// Definitions for PWM fan control&#xA;const unsigned char maxFanSpeed = 80;   // this is calculated as 16MHz divided by 8 (prescaler), divided by 25KHz (target PWM frequency from Intel specification) &#xA;&#xA;void setup()&#xA;{&#xA;  // Set up the PWM pins for a PWM frequency close to the recommended 25KHz for the Intel fan spec.&#xA;  // We can't get this frequency using the default TOP count of 255, so we have to use a custom TOP value.&#xA;&#xA;#if IS_UNO&#xA;&#xA;  // Only timer/counter 1 is free because TC0 is used for system timekeeping (i.e. millis() function),&#xA;  // and TC2 is used for our 1-millisecond tick. TC1 controls the PWM on Arduino pins 9 and 10.&#xA;  // However, we can only get PWM on pin 10 (controlled by OCR1B) because we are using OCR1A to define the TOP value.&#xA;  // Using a prescaler of 8 and a TOP value of 80 gives us a frequency of 16000/(8 * 80) = 25KHz exactly.&#xA;  TCCR1A = (1 &amp;lt;&amp;lt; COM1B1) | (1 &amp;lt;&amp;lt; COM1B0) | (1 &amp;lt;&amp;lt; WGM11) | (1 &amp;lt;&amp;lt; WGM10);  // OC1A (pin 9) disconnected, OC1B (pin 10) = inverted fast PWM  &#xA; #ifdef FAN_AUDIO_TEST&#xA;  // test code to get 440Hz output (= concert A) to test the logic &#xA;  OCR1AH = 0;&#xA;  OCR1BL = 71;  // 50% duty cycle &#xA;  TCCR1B = (1 &amp;lt;&amp;lt; WGM13) | (1 &amp;lt;&amp;lt; WGM12) | (1 &amp;lt;&amp;lt; CS12);  // TOP = OCRA, prescaler = 256&#xA;&#xA;  OCR1AL = 141; // TOP = 141, 16000000 / (256 * 142) = 440.014&#xA;  OCR1BH = 0;&#xA; #else&#xA;  OCR1AH = 79;&#xA;  OCR1AL = 0;  // TOP = 79&#xA;  TCCR1B = (1 &amp;lt;&amp;lt; WGM13) | (1 &amp;lt;&amp;lt; WGM12) | (1 &amp;lt;&amp;lt; CS11);  // TOP = OCR0A, prescaler = 8&#xA;&#xA;  OCR1BH = 0;&#xA;  OCR1BL = maxFanSpeed;  // max fan speed (i.e. pin 5 initially low all the time)  &#xA; #endif&#xA;&#xA;  TCNT1H = 0;&#xA;  TCNT1L = 0; &#xA;#else&#xA;&#xA;  // On the Mega we use TC1 and OCR1B, OCR1C&#xA;  TCCR1A = (1 &amp;lt;&amp;lt; COM1B1) | (1 &amp;lt;&amp;lt; COM1B0) | (1 &amp;lt;&amp;lt; COM1C1) | (1 &amp;lt;&amp;lt; COM1C1) | (1 &amp;lt;&amp;lt; WGM11) | (1 &amp;lt;&amp;lt; WGM10);  // OC1A disconnected, OC1B = OC1C inverted fast PWM  &#xA;  TCCR1B = (1 &amp;lt;&amp;lt; WGM13) | (1 &amp;lt;&amp;lt; WGM12) | (1 &amp;lt;&amp;lt; CS11);  // TOP = OCR1A, prescaler = 8&#xA;  TCCR1C = 0;&#xA;  OCR1AH = 0;&#xA;  OCR1AL = 79;  // TOP = 79&#xA;&#xA;  OCR1BH = 0;&#xA;  OCR1BL = maxFanSpeed;&#xA;  OCR1CH = 0;&#xA;  OCR1CL = maxFanSpeed;&#xA;&#xA;  TCNT1H = 0;&#xA;  TCNT1L = 0;&#xA;#endif&#xA;&#xA;  // We have to enable the ports as outputs before PWM will work.&#xA;  pinMode(transistorFanPin, OUTPUT);&#xA;  pinMode(diodeFanPin, OUTPUT);&#xA;  pinMode(A0, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// Set the transistor fan speed, where 0 &amp;lt;= fanSpeed &amp;lt;= maxFanSpeed&#xA;void setTransistorFanSpeed(unsigned char fanSpeed)&#xA;{&#xA;  OCR1BH = 0;&#xA;  OCR1BL = fanSpeed;&#xA;}&#xA;&#xA;// Set the diode fan speed, where 0 &amp;lt;= fanSpeed &amp;lt;= maxFanSpeed&#xA;void setDiodeFanSpeed(unsigned char fanSpeed)&#xA;{&#xA;#if IS_UNO&#xA;  OCR1BH = 0;&#xA;  OCR1BL = fanSpeed;&#xA;#else&#xA;  OCR1CH = 0;&#xA;  OCR1CL = fanSpeed;&#xA;#endif&#xA;}&#xA;&#xA;void loop() {&#xA;  if (analogRead(A0) &amp;gt;= 800) {&#xA;    setTransistorFanSpeed(80);&#xA;    Serial.println(&quot;HIGH&quot;);&#xA;    Serial.println(analogRead(A5));&#xA;  } else {&#xA;    setTransistorFanSpeed(0);&#xA;    Serial.println(&quot;LOW&quot;);&#xA;    Serial.println(analogRead(A5));&#xA;  }&#xA;  delay(100);&#xA;  Serial.println(&quot;I'm running.&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the serial monitor I'm getting the output I'm expecting (&quot;HIGH&quot; and 1023 when I've bridged the arduinos 5V pin to A0), but the signal doesn't seem to have any effect on the fan at all. In the thread linked above there's talk about this being an inverted fast PWM signal, and that it's assumed I'm using an opto isolator. Could this be why the signal doesn't have an effect on the fan? If anyone out there has any experience on this and are able to help me, that would be greatly appreciated.. :)&lt;/p&gt;&#xA;" OwnerUserId="1721" LastActivityDate="2014-08-05T16:50:39.347" Title="Need some help with controlling a fan through PWM" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3165" PostTypeId="1" AcceptedAnswerId="9729" CreationDate="2014-07-03T18:36:48.717" Score="3" ViewCount="3617" Body="&lt;p&gt;I am looking to implement a Microchip MCP7940 real time clock into my sensor data logging circuit that I have based on the Uno. Would the most logical solution be to attempt at changing an existing library to work with this clock (ie &lt;a href=&quot;https://github.com/jcw/rtclib&quot; rel=&quot;nofollow&quot;&gt;RTClib&lt;/a&gt;), or to begin from scratch and do the configuration directly in my program?&lt;/p&gt;&#xA;" OwnerUserId="2947" LastActivityDate="2015-03-31T00:51:26.260" Title="MCP7940 RTC Library" Tags="|arduino-uno|programming|i2c|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3167" PostTypeId="1" AcceptedAnswerId="3178" CreationDate="2014-07-03T21:20:10.413" Score="7" ViewCount="103403" Body="&lt;p&gt;I'm starting to build my first Arduino project but I'm running into some problems with serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get serial data from the console and store it in a char array called &quot;data&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when I send a new console message to the Arduino, I want it to clear the existing &quot;data&quot; array and store only the new data in that array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand exactly what's wrong with my code: I believe those nested Serial.available() statements don't work but I have no ideas on how to fix the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data is correctly stored by the Arduino but it concatenates the newer string to the old one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0;&#xA;char data[30];&#xA;boolean dataComplete = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  if (Serial.available() &amp;gt; 0){&#xA;    if (dataComplete == true){&#xA;    Serial.println(&quot;There is data already, clearing...&quot;);&#xA;    char data[30];&#xA;    dataComplete = false;&#xA;  }&#xA;    if (dataComplete == false){&#xA;      Serial.println(&quot;New command, collecting...&quot;);&#xA;      while (Serial.available()&amp;gt;0){&#xA;        char character = Serial.read();&#xA;        data[count] = character;&#xA;        count++;&#xA;      }&#xA;     dataComplete = true;&#xA;    }&#xA;  }&#xA;  Serial.print(&quot;Command received: &quot;);&#xA;  Serial.println(data);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="3020" LastActivityDate="2019-01-18T03:57:31.710" Title="Clear existing array when getting new serial command" Tags="|serial|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3168" PostTypeId="2" ParentId="3167" CreationDate="2014-07-03T21:41:55.460" Score="1" Body="&lt;p&gt;This probably doesn't do what you intend it to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;There is data already, clearing...&quot;);&#xA;char data[30];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your output says you are clearing the &lt;code&gt;data&lt;/code&gt; array, but you're doing no such thing. In fact, you are declaring a &lt;em&gt;new&lt;/em&gt; local variable called &lt;code&gt;data&lt;/code&gt;, which is independent of the global &lt;code&gt;data&lt;/code&gt; you already have declared at the top of your program. Local variables only exist within the scope in which they are declared (inside their nearest enclosing &lt;code&gt;{ }&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, your &lt;code&gt;count&lt;/code&gt; variable keeps track of how much data you have received. So perhaps do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;There is data already, clearing...&quot;);&#xA;count = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not the only thing that might cause your program to operate unexpectedly, but it should at least fix the problem stated in your question.&lt;/p&gt;&#xA;" OwnerUserId="2839" LastActivityDate="2014-07-03T21:41:55.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3169" PostTypeId="2" ParentId="3167" CreationDate="2014-07-04T00:33:49.480" Score="2" Body="&lt;p&gt;First of all, this is an &lt;em&gt;excellent&lt;/em&gt; example why whitespace matters. Your code is really hard to read as it is, as skimming over it, it seems as the second if statement is outside of the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixed code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0;&#xA;char data[30];&#xA;boolean dataComplete = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0){&#xA;    if (dataComplete == true){&#xA;      Serial.println(&quot;There is data already, clearing...&quot;);&#xA;      char data[30];&#xA;      dataComplete = false;&#xA;    }&#xA;    if (dataComplete == false){&#xA;      Serial.println(&quot;New command, collecting...&quot;);&#xA;      while (Serial.available()&amp;gt;0){&#xA;        char character = Serial.read();&#xA;        data[count] = character;&#xA;        count++;&#xA;      }&#xA;     dataComplete = true;&#xA;    }&#xA;  }&#xA;  Serial.print(&quot;Command received: &quot;);&#xA;  Serial.println(data);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, it seems as it prints &quot;Command received:&quot; every iteration, regardless of if there's new data or not (although, this could be the intended feature).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like mentioned, you don't &lt;em&gt;clear&lt;/em&gt; the variable, you just create a new one. You'll need to clear &lt;em&gt;and&lt;/em&gt; reset &lt;code&gt;count&lt;/code&gt; to fix this issue. However, just resetting count won't work if the second command is shorter than the one before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, why do you complicate the code with the &lt;code&gt;dataComplete&lt;/code&gt; variable? I simplified the code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0;&#xA;char data[30];&#xA;boolean dataComplete = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()){&#xA;    Serial.println(&quot;New command, collecting...&quot;);&#xA;    count = 0;&#xA;    data[] = &quot;&quot;;&#xA;    while (Serial.available()){&#xA;      char character = Serial.read();&#xA;      data[count] = character;&#xA;      count++;&#xA;    }&#xA;  }&#xA;  Serial.print(&quot;Command received: &quot;);&#xA;  Serial.println(data);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-04T00:33:49.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3172" PostTypeId="1" CreationDate="2014-07-04T07:18:18.970" Score="0" ViewCount="454" Body="&lt;p&gt;I'm a beginner in Arduino. I just installed Arduino IDE (arduino-1.0.5-r2-windows) but when I try to run its not responding and crashes after few minutes. I tried re-installing it and removing the temporary files but none of those helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what causes this problem and how to debug it?&lt;/p&gt;&#xA;" OwnerUserId="3023" LastEditorUserId="26916" LastEditDate="2017-09-09T23:49:12.667" LastActivityDate="2017-09-09T23:49:12.667" Title="Arduino IDE crashes without any warning" Tags="|arduino-ide|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3174" PostTypeId="1" CreationDate="2014-07-04T15:51:49.557" Score="2" ViewCount="887" Body="&lt;p&gt;The USB Serial speed on the teensy is WAY faster then on the Leonardo. Looks like because they have greatly improved the USB code. Has anyone had any luck using the Teensy core libraries on a Leonardo? I would imagine it should work as the hardware is basically the same.&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-07-04T15:51:49.557" Title="Teensy USB Core on Leonardo" Tags="|arduino-leonardo|teensy|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3175" PostTypeId="1" AcceptedAnswerId="3176" CreationDate="2014-07-04T18:15:20.697" Score="8" ViewCount="4382" Body="&lt;p&gt;I wanted to save some values to the EEPROM and also wanted to free up SRAM by avoiding some variable declarations, but EEPROM memory is byte wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I want to store an int value, I have to use some expressions repeatedly. I thought I would make some functions for those. But I am concerned that, if I create a function, it would still occupy SRAM memory, better I declare an int variable instead of using EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are the functions and the local variables stored in SRAM? Does it only store the address of the fuction pointer from the flash memory or all the variables and commands are stored on the stack?&lt;/p&gt;&#xA;" OwnerUserId="3030" LastEditorUserId="510" LastEditDate="2014-07-05T15:10:17.787" LastActivityDate="2015-08-05T21:24:00.503" Title="How is stack memory used for fuctions and local variables?" Tags="|sram|eeprom|memory-usage|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3176" PostTypeId="2" ParentId="3175" CreationDate="2014-07-04T18:46:37.470" Score="4" Body="&lt;p&gt;Only the function's data is stored on the stack; its code stays in flash.&#xA;You can't really reduce SRAM use by using EEPROM instead because, as you have seen, EEPROM isn't addressable in the same way. The code to read and store EEPROM also needs to use some SRAM - probably as much SRAM as you were trying to save! EEPROM is also slow to write, and has a limited lifetime (in number of writes to each byte), both of which make it impractical to use for storing the kind of temporary data we usually put on the stack. It is better suited to saving infrequently changed data, like the unique device configuration for mass-produced devices, or capturing infrequent errors for later analysis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edited:&lt;/strong&gt;&#xA;There is no stack for that function &lt;em&gt;until&lt;/em&gt; the function has been called, so yes, that is when any of the function's data get's put there. What happens after the function returns is that its stack-frame (its reserved area of SRAM) is no longer reserved. It will eventually be re-used by another function call. &lt;a href=&quot;http://www.kriha.de/docs/lectures/operatingsystems/cruntime/foil09.html&quot; rel=&quot;nofollow&quot;&gt;Here is a diagram&lt;/a&gt; of a C stack in memory. When a stack frame is no longer useful, it is simply released and its memory becomes available to be re-used.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-07-05T18:57:47.893" LastActivityDate="2014-07-05T18:57:47.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3177" PostTypeId="2" ParentId="3175" CreationDate="2014-07-04T18:52:09.137" Score="5" Body="&lt;p&gt;Local variables and function parameters are stored on the stack. However, that is not a reason not to use them. Computers are designed to work that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stack memory is only in use while a function is active. As soon as the function returns, the memory is freed. Stack memory is a GOOD Thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't want to use recursive functions with lots of levels of recursion, or allocate lots of large structures on the stack. Normal use is fine however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 6502 stack is only 256 bytes, but the Apple II works just fine.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-04T18:52:09.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3178" PostTypeId="2" ParentId="3167" CreationDate="2014-07-04T18:59:37.807" Score="18" Body="&lt;p&gt;To clear an array you would do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for( int i = 0; i &amp;lt; sizeof(data);  ++i )&#xA;   data[i] = (char)0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memset(data, 0, sizeof(data));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, which does the same thing using a library function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, because strings of characters (not referring to 'String' objects here) are terminated by a zero byte, only the first byte needs to be zeroed: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data[0] = (char)0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will do it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-07-04T18:59:37.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3179" PostTypeId="1" CreationDate="2014-07-05T05:41:11.433" Score="6" ViewCount="27110" Body="&lt;p&gt;I think I bricked two ATmega328Ps when I was trying to burn new bootloaders using Arduino Pro Mini, the USBasp programmer and the Extreme Burner AVR software. I had two ATMega328p with bad booloaders and I intended burn the correct bootloader to the chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I connected the USBasp programmer to my Arduino Pro Mini equipped with an ATmega328P. I verified that communication was good as I could read and write to EEPROM. All was excellent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using the following fuses:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LOW Fuse Byte=0x62&#xA;High Fuse Byte=0xD9&#xA;Extended=0xFF &#xA;Lock = 0xFF&#xA;Calibration = 0xFFFF FF8A&#xA;Then the following happened:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I killed the 1st chip when I only pressed button ERASE CHIP on the programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I killed the 2nd chip when I wrote the following fuses to it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LOW Fuse Byte=0xFF&#xA;High Fuse Byte=0xDA&#xA;Extended=0xFD &#xA;Lock Fuse = 0xCF&#xA;In both cases I had the following error message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cannot Communication with chip&#xA;Power On failed&#xA;avrdude output similar messages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RC=-1. No answer...&#xA;(avrdude -c usbasp -p m328p -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m )&#xA;How can I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I reset all the fuses to factory default to make the chips respond again?&lt;/p&gt;&#xA;" OwnerUserId="3034" LastActivityDate="2018-02-22T09:26:44.173" Title="How to reset ATmega328P fuses using USBasp programmer?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3180" PostTypeId="2" ParentId="3172" CreationDate="2014-07-05T07:09:13.670" Score="1" Body="&lt;p&gt;Installing Arduino 1.5.6 solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="3023" LastActivityDate="2014-07-05T07:09:13.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3181" PostTypeId="2" ParentId="1374" CreationDate="2014-07-05T12:36:58.920" Score="1" Body="&lt;p&gt;By gcc/g++ I think you're referring specifically to avr-gcc/avr-g++.  Your arduino code probably won't be considered valid C/C++ code because gcc will try to compile with your PC as the target system. Many of the Macros in &quot;WProgram.h&quot; will refer to inaccessible memory on your target system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Providing you include the header file &quot;WProgram.h&quot; and you build your code with the Arduino Makefile above (which uses avr-g++ not g++), your cpp files should compile and link correctly.  Likewise, you will be able to open your Arduino code within the IDE and Verify your code there.  The IDE puts in the &quot;WProgram.h&quot; file for you, so technically it would be included twice.  However, the include guards will prevent any duplicate code from being compiled.&lt;/p&gt;&#xA;" OwnerUserId="3037" LastActivityDate="2014-07-05T12:36:58.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3182" PostTypeId="1" AcceptedAnswerId="3185" CreationDate="2014-07-05T15:00:15.833" Score="25" ViewCount="57339" Body="&lt;p&gt;What frequency do Arduinos use for normal PWM when you use analogWrite()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And is it different for different Arduino model? I'm interested specifically in the Mega 2560, but also want to know if it's consistent between models.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen a passing references to the Arduino using 500 Hz, which seems really slow. &lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="395" LastEditDate="2021-03-21T19:51:59.250" LastActivityDate="2023-01-09T13:47:10.950" Title="What is the frequency of PWM output on Arduino" Tags="|pwm|analogwrite|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3183" PostTypeId="2" ParentId="3164" CreationDate="2014-07-05T17:24:35.993" Score="3" Body="&lt;p&gt;You need to connect the ground of the fan (/12volt power-supply) to the ground of the Arduino. If you don't connect the grounds, there is no path for electrons to flow.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-05T17:24:35.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3184" PostTypeId="1" AcceptedAnswerId="3212" CreationDate="2014-07-05T17:30:12.147" Score="3" ViewCount="7436" Body="&lt;p&gt;I am researching to find the best method to work with in order to control the arduino from a web interface (hosted on a web server using PHP) and also sending data from arduino to webserver and save to mySql.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 methods which I have found that a lot use are save the data to a text file or in the url.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the best or are there any better methods?&lt;/p&gt;&#xA;" OwnerUserId="3039" LastActivityDate="2015-05-10T22:00:29.430" Title="Arduino communicating back and forth with PHP server" Tags="|arduino-uno|ethernet|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3185" PostTypeId="2" ParentId="3182" CreationDate="2014-07-05T20:13:29.760" Score="36" Body="&lt;p&gt;The PWM signal is generated by timers on the AVR chips. Each timer can generate a PWM signal on two or three different pins. Each pin can have it's own duty cycle, but they share the PWM frequency. You can change the frequency of the PWM by changing the clock source for the timers. By default they use the CPU clock divided by 64, ie. they have their prescaler set to 64 by Arduino initialization code.&#xA;  To confuse things more there are two different PWM modes: fast PWM and phase correct PWM. In fast PWM the timer counts to 255, then overflows and starts over from 0 (256 different states). In phase correct PWM the timer counts to 255, then changes direction and counts downwards to zero, changes direction and so on (510 different states).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega has 5 timers, timer0 - timer4. Because timer0 is also used for the millis and micros functions it uses fast PWM, whereas the other timers are configured for phase correct PWM. This results in different frequencies on different pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Pin 4 and 13, controlled by timer0:&lt;br&gt;&#xA;16 Mhz / 64 / 256 = 976.56 Hz&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other PWM pins, controlled by timer1-4:&lt;br&gt;&#xA;16 Mhz / 64 / 510 = 490.20 Hz&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The calculation is: Clock / Prescaler / PWM mode number of states&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation is the same for all other Arduino boards I know of, except they have less timers that connect to different pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the PWM frequency by changing the timer prescaler. See this page: &lt;a href=&quot;http://playground.arduino.cc/Main/TimerPWMCheatsheet&quot;&gt;http://playground.arduino.cc/Main/TimerPWMCheatsheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to make the timers count to a different value than 255. On the 8 bit timers you will loose an output pin, but on the 16 bit timers you can use the Input Capture Register to define a TOP value. The input capture functionality is a feature rarely used in the Arduino community so you likely won't miss it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino libraries only allow you to use 8 bit resolution, even on the 16 bit timers. If you want the higher resolution, you will have to write your own analogWrite, or use a library made for the purpose.&#xA;On the Arduino Mega timer0 and timer2 are 8 bit, while the rest are 16 bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By changing the mode of the 16 bit timers to make use of the full resolution, in combination with changing the prescaler and the TOP value, you can achieve a very wide range of PWM frequencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The maximum frequency you can achieve is clock / 4, by setting the prescaler to 1 and TOP to 3 in fast PWM mode - a lower value isn't allowed. This will give you a 4 MHz PWM with 2 bit resolution. It can be on 0%, 25%, 50%, or 75% of the time. A higher TOP value will give you a higher resolution at a lower frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a longer explanation read this &lt;a href=&quot;http://www.righto.com/2009/07/secrets-of-arduino-pwm.html&quot;&gt;article&lt;/a&gt; or refer to the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing the prescaler, PWM mode, or TOP value for timer0 will mess with &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2014-07-06T16:53:41.837" LastActivityDate="2014-07-06T16:53:41.837" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3186" PostTypeId="1" AcceptedAnswerId="3197" CreationDate="2014-07-05T22:54:17.813" Score="1" ViewCount="13826" Body="&lt;p&gt;Does arduino run AC or DC? Based on my small knowledge on the crystal in an arduino, it seems like AC makes sense. True? No?&lt;/p&gt;&#xA;" OwnerUserId="3044" LastActivityDate="2014-07-06T20:13:53.380" Title="Does Arduino run AC or DC" Tags="|arduino-uno|current|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3187" PostTypeId="2" ParentId="3186" CreationDate="2014-07-05T23:11:37.187" Score="1" Body="&lt;p&gt;Have a look at this: &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&lt;/a&gt; and try and have a guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to be nasty, but have you at least googled this? Google: &quot;Arduino Power Source&quot; and the first hit is &lt;a href=&quot;http://playground.arduino.cc/Learning/WhatAdapter&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/WhatAdapter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It runs from USB as well as from an external power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your question: DC &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-07-05T23:11:37.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3188" PostTypeId="2" ParentId="1773" CreationDate="2014-07-06T00:01:06.827" Score="6" Body="&lt;p&gt;Just to add to @Ignacio's answer which has directly answered your question. The &quot;conflict&quot; you speak of is in relation to &lt;code&gt;Timer0&lt;/code&gt;'s prescaler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the most part, you can use those pins (incidentally pins 5 and 6 on the UNO) with PWM without an issue, and read the correct value of &lt;code&gt;millis()&lt;/code&gt; (as well as get the expected delay from &lt;code&gt;delay&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you run into problems is if you want to change the prescaler (usually to modify the frequency of the PWM signal). If you change this, then you directly affect the calculation and reporting of &lt;code&gt;millis()&lt;/code&gt; and the length of &lt;code&gt;delay(x)&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2014-07-06T00:01:06.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3189" PostTypeId="1" AcceptedAnswerId="3190" CreationDate="2014-07-06T00:34:23.267" Score="1" ViewCount="161" Body="&lt;p&gt;So I am learning arduino code by going through examples and playing with them, and I came across something interesting. I am not fluent in any coding language but I am fully familiarized with computer logic and function so I can read what you suggest just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is, why are these two code pieces different? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =  13;     &#xA;&#xA;int ledState = LOW;            &#xA;&#xA;long interval = 1000;          &#xA;&#xA;void setup() {&#xA;&#xA;pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis &amp;gt; interval) {&#xA;&#xA;    currentMillis = 0;  &#xA;&#xA;&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;&#xA;&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my code, or rather modification to this code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =  13;     &#xA;&#xA;&#xA;int ledState = LOW;           &#xA;long previousMillis = 0;      &#xA;&#xA;&#xA;long interval = 1000;      &#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;&#xA;    previousMillis = currentMillis;   &#xA;&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How is it that the first code works, and the second code turns the led on and either terminates or never turns the LED off? The code is designed to blink the LED once every 1 second.&lt;/p&gt;&#xA;" OwnerUserId="3044" LastActivityDate="2014-07-06T21:26:50.203" Title="Questions on programming logic?" Tags="|arduino-uno|code-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3190" PostTypeId="2" ParentId="3189" CreationDate="2014-07-06T01:31:30.457" Score="2" Body="&lt;p&gt;Ah yes, &lt;em&gt;this&lt;/em&gt; problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the declaration of &lt;code&gt;currentMillis&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long currentMillis = ...;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now note the declaration of &lt;code&gt;previousMillis&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long previousMillis = ...;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You wouldn't think that one little word could make that much difference, but it does. It &lt;em&gt;completely&lt;/em&gt; changes how C performs mathematics. &lt;code&gt;previousMillis&lt;/code&gt; &lt;em&gt;must&lt;/em&gt; also be &lt;code&gt;unsigned&lt;/code&gt; or you will get undesired results.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-06T01:31:30.457" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3192" PostTypeId="1" AcceptedAnswerId="3195" CreationDate="2014-07-06T05:29:31.483" Score="2" ViewCount="1241" Body="&lt;p&gt;I would like to send information between my Arduino and my computer. Is there a way to send multiple variables from one Arduino? If so, how would I go about separating the variables?&lt;/p&gt;&#xA;" OwnerUserId="3045" LastEditorUserId="220" LastEditDate="2014-07-06T14:26:43.270" LastActivityDate="2015-09-04T18:04:17.637" Title="How to send multi variable information over serial?" Tags="|serial|arduino-mega|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3193" PostTypeId="2" ParentId="3175" CreationDate="2014-07-06T07:23:26.277" Score="5" Body="&lt;p&gt;The AVR (the microcontroller family traditionally used on Arduino boards) is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Harvard_architecture&quot; rel=&quot;noreferrer&quot;&gt;Harvard Architecture&lt;/a&gt;, meaning that executable code and variables are in two separate memories - in this case flash and SRAM. The executable code never leaves flash memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you call a function the return address is usually pushed to the stack - the exception is when the function call happens at the end of the calling function. In this case the return address of the function that called the calling function will be used instead - it is already on the stack.&lt;br&gt;&#xA;  Whether any other data is put on the stack depends on the register pressure in the calling function and in the called function. Registers are the working area of the CPU, the AVR has 32 1-byte registers. The registers can be accessed directly by CPU instructions, whereas data in SRAM will first have to be stored in registers. Only if arguments or local variable are too big or too many to fit in registers will they be put on the stack. However, structures are always stored on the stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read the details of how the stack is used by the GCC compiler on the AVR platform here: &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc#Frame_Layout&quot; rel=&quot;noreferrer&quot;&gt;https://gcc.gnu.org/wiki/avr-gcc#Frame_Layout&lt;/a&gt;&lt;br&gt;&#xA;Read the sections &quot;Frame Layout&quot; and &quot;Calling Convention&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-06T07:23:26.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3194" PostTypeId="1" CreationDate="2014-07-06T08:30:07.810" Score="1" ViewCount="1941" Body="&lt;p&gt;I want to monitor the temperatur around the house and outside. I want to save the data to mysql and then create some kind of webapplication that displlays the data. It is pretty easy to find temperature sensors that transmitts over 433Mhz, and I have thought about &lt;a href=&quot;http://www.telldus.com/products/tellstick&quot; rel=&quot;nofollow&quot;&gt;Telldus tellstick&lt;/a&gt; to receive data and store them. This receiver costs about 30 - 40 $ and 10 - 20 $ for each sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since I just learned that Arduino can be used for everything, I would love to hear more about it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please give me an introduction to what I would need to make this solution? The arduino should basicly receive data from 433 Mhz sensors and store it to MySQL. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What woulds be the challanges when doing something like this?&lt;/p&gt;&#xA;" OwnerUserId="3047" LastActivityDate="2014-07-08T20:43:13.937" Title="Arduino 433Mhz weather sensor receiver" Tags="|temperature-sensor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3195" PostTypeId="2" ParentId="3192" CreationDate="2014-07-06T15:02:23.160" Score="3" Body="&lt;p&gt;&lt;strong&gt;You have three options for what you want to achieve (if I understand it right):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Have a fixed length for each variable:&lt;/strong&gt; If I know each number is going to be two digits, I can send &quot;1234&quot; and the other side can figure out the numbers are &quot;12&quot; and &quot;34&quot;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Have a delimiter character:&lt;/strong&gt; Have a character that signals a new variable. For example: &quot;213|1234&quot; would translate into &quot;213&quot; and &quot;1234&quot;. You could even use the newline character to signal a new line (with &lt;code&gt;Serial.println();&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Do some sort of validation to separate the data:&lt;/strong&gt; If sending a favorite number and favorite color, I can send &quot;12RED345BLUE&quot; and the other side it can find that it's &quot;12&quot; (both numbers), then &quot;RED&quot; (all letters), then &quot;345&quot; (three numbers), and finally &quot;BLUE&quot; (again, all letters).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-06T15:02:23.160" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3196" PostTypeId="2" ParentId="1374" CreationDate="2014-07-06T15:05:58.783" Score="1" Body="&lt;p&gt;Generally you'll need to state the &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; functions, they are just wrappers of the IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {}&#xA;void loop() {}&#xA;&#xA;int main() {&#xA;  setup();&#xA;  while (1)&#xA;    loop();&#xA;&#xA;  return 0; // never reached&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works both in the IDE and on the command line.&#xA;As you specify the Board and SerialPort in the IDE,&#xA;you'll need also to specify both in the Makefile.&#xA;So you'll end up with two configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people leave the IDE because they prefer use different &#xA;editors or have more configuration options by setting&#xA;the compiler and linker switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it really easy, you can use &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;Arduino Makefile&lt;/a&gt;. Today&#xA;starred with 347.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here an example Makefile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# try: make help&#xA;#&#xA;include /usr/share/arduino/Arduino.mk&#xA;ARDUINO_DIR = /usr/share/arduino&#xA;# list boards with: make show_boards&#xA;BOARD_TAG = promicro16&#xA;ARDUINO_LIBS = EEPROM &#xA;# MONITOR_CMD = picocom -b 9600&#xA;MONITOR_CMD = moni -config ACM0-9600.cfg&#xA;ARDUINO_PORT = /dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00&#xA;# ARDUINO_PORT = /dev/ttyACM0&#xA;# ARDUINO_PORT = /dev/ttyUSB0&#xA;OPTIMIZATION_FLAGS = -Os -fexpensive-optimizations -fstrength-reduce&#xA;#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The '*.ino' files don't need to be changed and the &lt;code&gt;Makefile&lt;/code&gt; file is to be placed in the same directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile I prefer the &lt;code&gt;Makefile&lt;/code&gt; way, but I still use the IDE for small projects.&lt;/p&gt;&#xA;" OwnerDisplayName="user3028" LastEditorDisplayName="user3028" LastEditDate="2014-07-06T15:17:09.200" LastActivityDate="2014-07-06T15:17:09.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3197" PostTypeId="2" ParentId="3186" CreationDate="2014-07-06T16:04:50.710" Score="7" Body="&lt;p&gt;As a general rule, any modern electronic device with computational ability has to use DC. The reason is that they use specific voltage levels to indicate binary/logical states (i.e. 0's and 1's).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, an ideal DC supply (Direct Current) should provide a constant voltage. That allows the circuit to effectively turn it on an off to represent binary states. (In reality, there's no such thing as truly &quot;off&quot; though, because voltage is relative.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the voltage from an AC supply (Alternating Current) is constantly varying. If you plot it on a chart, you should see a nice sine wave, flowing smoothly between positive and negative several times per second. Hypothetically, if a digital circuit tried to use AC then it would get very confused, because everything would seem to be turning on and off all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all that said, it's very common to turn AC into DC through a process called rectification. For example, that's what allows DC devices to get power from an AC outlet (e.g. to run your computer or charge your phone).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-07-06T16:04:50.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3198" PostTypeId="1" AcceptedAnswerId="3200" CreationDate="2014-07-06T16:58:01.687" Score="0" ViewCount="1290" Body="&lt;p&gt;I need to use a motor shield and an LCD keypad shield simultaneously hooked up to a single Arduino Mega Board. Since I can't physically stack them, I decided to reroute all the pins used for the LCD keypad shield. When I reroute all pins &lt;strong&gt;except&lt;/strong&gt; the two power pins, the LCD and keypad work fine. But when I disconnect those 2 pins and connect them to any other power source than the Arduino Mega, it fails. The screen becomes either blank / jumble of illegible characters / brief moments of expected output followed by the same jumble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior is really strange since the power pins don't carry any information, they are just power sources. The LCD keypad shield shouldn't be able to discriminate whether the power is coming from the Arduino Mega or not - but it does. I checked with a voltmeter that all power sources I tried are DC 5V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I thought this is because the &lt;code&gt;lcd.begin()&lt;/code&gt; function is called only once, so I rewrote my code to re-initialize the lcd at every iteration. This doesn't solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture of the setup that works. (rerouting all pins &lt;em&gt;except&lt;/em&gt; the power.) Ignore the location of analog input cable, since it doesn't do anything in the current code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yGRiL.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one that fails. The only difference from above is the power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/60Trk.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// select the pins used on the LCD panel&#xA;LiquidCrystal lcd(28, 29, 24, 25, 26, 27);&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.begin(16, 2);              &#xA;  lcd.print(&quot;Hello World!&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  lcd.begin(16, 2);             &#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Hello World!&quot;);&#xA;  delay(1000);&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Hello Again!&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="3049" LastEditorUserId="3049" LastEditDate="2014-07-06T17:04:07.887" LastActivityDate="2014-08-21T04:39:38.763" Title="Running an LCD keypad shield from a separate power source" Tags="|power|lcd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3199" PostTypeId="1" CreationDate="2014-07-06T16:38:45.347" Score="0" ViewCount="408" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/D3HIY.png&quot; alt=&quot;Upload Debug&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error I receive while trying to upload to the Arduino.&#xA;I have installed FTDI drivers for mac. (&lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_2_18.dmg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_2_18.dmg&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is part of a quadcopter: &lt;a href=&quot;https://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=50460&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=50460&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The processor is an Atmel 328P. Do I have the correct drivers? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else could be the issue?&lt;/p&gt;&#xA;" OwnerDisplayName="user2588096" LastEditorUserId="313" LastEditDate="2014-09-06T00:12:30.227" LastActivityDate="2014-09-06T00:12:30.227" Title="Cannot upload program to Arduino Duemilanove w/ Atmega328" Tags="|arduino-due|uploading|atmega328|ftdi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3200" PostTypeId="2" ParentId="3198" CreationDate="2014-07-06T17:08:17.640" Score="1" Body="&lt;p&gt;You can use a different power source, but the two circuit need to have a common ground, since all electrical signals are relative to ground. So connect a wire from GND on the LCD to GND on your Arduino and everything should work as expected.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-06T17:08:17.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3201" PostTypeId="1" AcceptedAnswerId="3250" CreationDate="2014-07-06T17:11:04.080" Score="0" ViewCount="1868" Body="&lt;p&gt;i have a idea to create a small screen which displays video recorded from arduino with camera. so camera will be back side of human and screen will be at near to eye. human can see the pictures from back side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have found &lt;a href=&quot;https://electronics.stackexchange.com/questions/29139/processing-ntsc-video-feed-for-spi-display&quot;&gt;https://electronics.stackexchange.com/questions/29139/processing-ntsc-video-feed-for-spi-display&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but its not give me a clear idea. is there any one who can advice me for that kind project?&lt;/p&gt;&#xA;" OwnerUserId="2846" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-07-10T20:06:57.073" Title="Arduino based small LCD screen with camera video capturing" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3202" PostTypeId="1" CreationDate="2014-07-06T19:02:18.887" Score="10" ViewCount="1935" Body="&lt;p&gt;The Arduino &lt;a href=&quot;http://arduino.cc/en/Tutorial/DigitalReadSerial&quot;&gt;Digital Read Serial&lt;/a&gt; tutorial guides you through the wiring of a simple button. My questions are centered around the resistor.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Why is the resistor necessary?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I think I understand this, but correct me if I am wrong. To ensure that the input pin reads a low signal, and does not float, we should connect the pin to ground when the button is not pushed. When the button gets pushed, we will have a 5V signal flowing to both the pin and to ground. Kirchhoff's voltage law states that total voltage in closed loop must equal zero, so we have to deal with this 5V that is flowing directly to ground. That is why we put a resistor between the button and ground.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;How was the resistor value chosen?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This is what I am unclear on. Ohm's law states that...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;resistance = voltage / current&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a 5V supply and the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot;&gt;Arduino Uno&lt;/a&gt; spec says that the pin provides 40 mA of DC current. So..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;resistance = 5V / 0.04A = 125 Ohms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;http://arduino.cc/en/Tutorial/DigitalReadSerial&quot;&gt;Digital Read Serial&lt;/a&gt; tutorial, &lt;strong&gt;why do we have a 10K Ohms resistor?&lt;/strong&gt; That is way overkill, right? Which leads to another question: &lt;strong&gt;Can you ever put too much resistance in place, if your only goal is to obliterate voltage?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any feedback!&lt;/p&gt;&#xA;" OwnerUserId="2838" LastActivityDate="2014-07-15T14:40:50.500" Title="Digital Read Serial tutorial - calculating the resistor value" Tags="|arduino-uno|resistor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3203" PostTypeId="1" AcceptedAnswerId="3204" CreationDate="2014-07-06T19:12:01.687" Score="4" ViewCount="564" Body="&lt;p&gt;I am trying to make an automatic lock which stays open during different times and on different days. I want the door open Monday through Friday 8am to 5pm. On Saturdays and Sundays I want the door locked. I will be using an electric lock strike the + wire to pin 9 and - to ground on arduino. I am using an LED for development purposes for now because I don't have the lock yet. The code I have now works (stays open) for 8am to 5pm through the whole week but i want the door locked for Saturdays and Sundays. This is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Time.h&amp;gt;&#xA;#define doorPin 9&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(doorPin, OUTPUT); // Connected to relay to activate the door lock&#xA;  setTime(10,1,1,6,7,2014);&#xA;}&#xA;&#xA;void loop() {&#xA;if (hour()&amp;gt;=8 &amp;amp;&amp;amp; hour()&amp;lt;=17){&#xA;  digitalWrite(doorPin, HIGH);&#xA;}&#xA;else if (weekday()==1 || weekday()==7){&#xA;  digitalWrite(doorPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="274" LastEditorUserId="274" LastEditDate="2014-07-06T20:02:51.843" LastActivityDate="2014-07-06T23:00:15.173" Title="How can I make my Arduino code work?" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3204" PostTypeId="2" ParentId="3203" CreationDate="2014-07-06T19:47:04.347" Score="6" Body="&lt;p&gt;This is what's happening: it's still between 8 AM and 5 PM on the weekend, so it unlocks it. Since you use an &lt;code&gt;else if&lt;/code&gt;, it terminates the &lt;code&gt;if&lt;/code&gt; statement and never checks the day between 8 and 5. I'm almost positive that if you checked it another time in the day, it'd be &quot;locked.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixed code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Time.h&amp;gt;&#xA;#define doorPin 9&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(doorPin, OUTPUT); // Connected to relay to activate the door lock&#xA;  setTime(10,1,1,6,7,2014);&#xA;}&#xA;&#xA;void loop() {&#xA;if ((hour()&amp;gt;=8 &amp;amp;&amp;amp; hour()&amp;lt;=17) &amp;amp;&amp;amp; !(weekday()==1 || weekday()==7)){&#xA;  digitalWrite(doorPin, HIGH);&#xA;}&#xA;else {&#xA;  digitalWrite(doorPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: &lt;code&gt;!&lt;/code&gt; means &quot;not.&quot; Thus, the door is locked only if it's not a weekend and it's between 8 and 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;Additionally, you might want to get a lock that is the other way around: unlocked only with power applied so someone can't unplug the Arduino to get access.&lt;/strike&gt; EDIT: miscommunication, ignore this part paragraph...&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-07-06T20:18:23.190" LastActivityDate="2014-07-06T20:18:23.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3205" PostTypeId="2" ParentId="3202" CreationDate="2014-07-06T19:48:51.270" Score="6" Body="&lt;p&gt;You're very close. The resistor is there to act as a pull down resistor; If the input pin is floating it is just an antenna picking up random static. The key is that when positive is supplied (by pressing the button) the positive source needs to &quot;overwhelm&quot; the pull down resistor so that the input pin reads positive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there were no resistance, than the input pin would be reading in the middle of a direct path that does not favor positive or negative. Asside from the direct short that would be occurring, Which state the arduino would read I suspect would either be random or some property of the power supply; It would probably still read ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the resistor, the signal is read directly connected to positive, before the load resistance. This way it will be sure to get a HIGH signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exact size of the resistor is of little consequence. Too small and you waste current, but too much resistance is effectively just disconnecting ground again. There is a very wide range of values that will work fine between those. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to note that when an arduino pin is set to input mode, it will effectively supply no current. It can be moddeled is being in series with a 100 megaOhm resistor. see &lt;a href=&quot;http://arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/DigitalPins&lt;/a&gt; &#xA;for details.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-07-08T02:22:16.933" LastActivityDate="2014-07-08T02:22:16.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3206" PostTypeId="2" ParentId="3186" CreationDate="2014-07-06T20:13:53.380" Score="3" Body="&lt;p&gt;All digital logic circuits run on DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduino boards include a voltage regulator. You can feed them an input ranging from 7 to 12 volts, and they &quot;clean up&quot; that input and lock it to precisely 5 volts, the voltage needed by the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can also run directly off the regulated 5 volts from the USB connector.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-06T20:13:53.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3207" PostTypeId="2" ParentId="3189" CreationDate="2014-07-06T21:18:28.847" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Two%27s_complement&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Two%27s_complement&lt;/a&gt; - good read regarding signed numbers in binary format. It really isn't &quot;complex&quot;; the highest bit being &quot;1&quot; denotes a negative number. As there is no &quot;-0&quot; the negative numbers also have an offset of one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you mix unsigned and signed - you simply get unexpected results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to be very precise, i.e. check if the signed number is negative and handle it with care to make it &quot;compatible&quot; with the unsigned number before you use them together. &#xA;What &quot;care&quot; ends up be in reality depends on what you expect to get out of it, as result.&lt;/p&gt;&#xA;" OwnerDisplayName="user3043" LastEditorDisplayName="user3043" LastEditDate="2014-07-06T21:26:50.203" LastActivityDate="2014-07-06T21:26:50.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3208" PostTypeId="2" ParentId="3203" CreationDate="2014-07-06T23:00:15.173" Score="3" Body="&lt;p&gt;Adding to Annonomus Penguin's answer, it might be cleaner and easier to understand if you extract the variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool doorOpen = ( (hour()&amp;gt;=8 &amp;amp;&amp;amp; hour()&amp;lt;=17) &amp;amp;&amp;amp; !(weekday()==1 || weekday()==7) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in my eyes even nicer if you unnegate the last part, ymmv:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool doorOpen = ( (hour()&amp;gt;=8 &amp;amp;&amp;amp; hour()&amp;lt;=17) &amp;amp;&amp;amp; (weekday()!=1 &amp;amp;&amp;amp; weekday()!=7) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use them directly in the code without the if statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite( doorPin, doorOpen ? HIGH : LOW );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you make sure that the doorPin always gets set and you din't forget a path like in your if-elseif-nothing version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another benefit is you can test independently if the doorOpen variable is correct and if the functionality that is triggered by it is correct.&lt;/p&gt;&#xA;" OwnerUserId="3054" LastActivityDate="2014-07-06T23:00:15.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3209" PostTypeId="2" ParentId="3199" CreationDate="2014-07-07T01:41:25.370" Score="1" Body="&lt;p&gt;You may have wrong port:  &lt;strong&gt;/dev/tty.usbserial-A9007LXq&lt;/strong&gt; works with Duemilanove on my Mac.&lt;/p&gt;&#xA;" OwnerUserId="382" LastActivityDate="2014-07-07T01:41:25.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3210" PostTypeId="1" AcceptedAnswerId="3211" CreationDate="2014-07-07T01:10:25.670" Score="1" ViewCount="315" Body="&lt;p&gt;I'm using WiShield library from: &lt;a href=&quot;https://github.com/jcmuller/WiShield&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jcmuller/WiShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong with this library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Web Server using Flash&#xA; *&#xA; * A simple web server example using the WiShield 2.0&#xA; * that reads the manufacturing ID from the Flash and&#xA; * displays it on a webpage.&#xA; */&#xA;&#xA;#include &amp;lt;WiShield.h&amp;gt;&#xA;#include &amp;lt;dataflash.h&amp;gt;&#xA;&#xA;#define WIRELESS_MODE_INFRA    1&#xA;#define WIRELESS_MODE_ADHOC    2&#xA;&#xA;#define FLASH_SLAVE_SELECT 7&#xA;#define WIFI_SLAVE_SELECT  10&#xA;&#xA;// Wireless configuration parameters ----------------------------------------&#xA;unsigned char local_ip[] = {192,168,1,2};   // IP address of WiShield&#xA;unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address&#xA;unsigned char subnet_mask[] = {255,255,255,0};  // subnet mask for the local network&#xA;const prog_char ssid[] PROGMEM = {&quot;ASYNCLABS&quot;}; // max 32 bytes&#xA;&#xA;unsigned char security_type = 0;    // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2&#xA;&#xA;// WPA/WPA2 passphrase&#xA;const prog_char security_passphrase[] PROGMEM = {&quot;12345678&quot;};   // max 64 characters&#xA;&#xA;// WEP 128-bit keys&#xA;// sample HEX keys&#xA;prog_uchar wep_keys[] PROGMEM = {   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,     0x09, 0x0a, 0x0b, 0x0c, 0x0d,   // Key 0&#xA;                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 1&#xA;                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // Key 2&#xA;                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00    // Key 3&#xA;                            };&#xA;&#xA;// setup the wireless mode&#xA;// infrastructure - connect to AP&#xA;// adhoc - connect to another WiFi device&#xA;unsigned char wireless_mode = WIRELESS_MODE_INFRA;&#xA;&#xA;unsigned char ssid_len;&#xA;unsigned char security_passphrase_len;&#xA;//---------------------------------------------------------------------------&#xA;&#xA;unsigned char mfg_id[4];&#xA;&#xA;void setup()&#xA;{&#xA;  initShield();  &#xA;}&#xA;&#xA;// This is the webpage that is served up by the webserver&#xA;const prog_char webpage[] PROGMEM = &quot;HTTP/1.1 200 OK\r\nContent-Type:     text/html\r\n\r\n&quot;&#xA;                                &quot;&amp;lt;html&amp;gt;&amp;lt;body style=\&quot;margin:100px\&quot;&amp;gt;&quot;&#xA;                                &quot;&amp;lt;center&amp;gt;&quot;&#xA;                                &quot;&amp;lt;h1&amp;gt;Flash Mfg ID: 000 000 000&amp;lt;/h1&amp;gt;&quot;&#xA;                                &quot;&amp;lt;form method=post action=\&quot;/upload\&quot; enctype=\&quot;multipart/form-data\&quot;&amp;gt;&quot;&#xA;                                &quot;&amp;lt;b&amp;gt;FS Image Upload&amp;lt;/b&amp;gt;&quot;&#xA;                                &quot;&amp;lt;p&amp;gt;&quot;&#xA;                                &quot;&amp;lt;input type=file name=i size=40&amp;gt; &amp;amp;nbsp; &amp;lt;input type=submit value=\&quot;Upload\&quot;&amp;gt;&quot;&#xA;                                &quot;&amp;lt;/form&amp;gt;&quot;&#xA;                                &quot;&amp;lt;/center&amp;gt;&quot;&#xA;                                &quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;;&#xA;&#xA;void loop()&#xA;{ &#xA;  dflash.read_id(mfg_id);&#xA;&#xA;  WiFi.run();&#xA;}&#xA;&#xA;void initShield()&#xA;{&#xA;  // there is some contention on the SPI between the flash and wifi chip,&#xA;  // so disable both devices at the beginning until they are properly&#xA;  // initialized by their respective libraries&#xA;  pinMode(FLASH_SLAVE_SELECT, OUTPUT);&#xA;  digitalWrite(FLASH_SLAVE_SELECT, HIGH);&#xA;  pinMode(WIFI_SLAVE_SELECT, OUTPUT);&#xA;  digitalWrite(WIFI_SLAVE_SELECT, HIGH);&#xA;&#xA;  // now init dataflash&#xA;  dflash.init(FLASH_SLAVE_SELECT);&#xA;&#xA;  // now init wifi&#xA;  WiFi.init();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Tomir Schmite Jr." LastActivityDate="2014-07-07T02:35:31.660" Title="Error building Arduino WiShield Flash example: 'dflash' was not declared in this scope" Tags="|wifi|flash|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3211" PostTypeId="2" ParentId="3210" CreationDate="2014-07-07T01:33:27.563" Score="0" Body="&lt;p&gt;I doubt anything is wrong with the library, but in your initShield and loop methods you refer to a variable called 'dflash' which does not seem to be defined anywhere.  &lt;/p&gt;&#xA;" OwnerUserId="3832" OwnerDisplayName="alex.forencich" LastActivityDate="2014-07-07T01:33:27.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3212" PostTypeId="2" ParentId="3184" CreationDate="2014-07-07T11:28:35.420" Score="3" Body="&lt;p&gt;I would suggest your best bet would be to pass messages back and forth via JSON, via Get/Post http request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to send data, you send a POST request (to the PHP server) with your data in JSON in the content.  To get instructions, you send a GET request to the PHP server and get a contents field with JSON in it.&lt;/p&gt;&#xA;" OwnerUserId="3058" LastActivityDate="2014-07-07T11:28:35.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3215" PostTypeId="2" ParentId="3202" CreationDate="2014-07-07T16:22:17.217" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Why is the resistor necessary?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino inputs have very high resistance. The datasheed of the Atmega328&#xA;says 100 MOhm for ADC, Such high values are good, but have also the drawback to deal with parasitic effects (resistance, inductance, capacitance). Such effects can also be used as &lt;a href=&quot;http://wiki.edwindertien.nl/doku.php?id=modules%3acapacitive&quot; rel=&quot;nofollow&quot;&gt;Capacitance Sensors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;How was the resistor value chosen?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The resistor needs to have an arbitrary value, that is smaller than the input resistance. 10k and above are good for disabling the input leakage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you can also leave out the resistor when you use the internal pull-up resitors. In this case you deal with negative logic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(3, INPUT);&#xA;digitalWrite(3, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On pin 3 you'll measure &lt;code&gt;HIGH&lt;/code&gt; and the button needs to be connected to the pin and the ground. The internal I/0 pull-up resistor has the value of 50k.&lt;/p&gt;&#xA;" OwnerDisplayName="user3028" LastEditorDisplayName="user3028" LastEditDate="2014-07-09T16:07:40.820" LastActivityDate="2014-07-09T16:07:40.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3216" PostTypeId="1" CreationDate="2014-07-07T16:25:50.280" Score="7" ViewCount="6106" Body="&lt;p&gt;I want to wire Arduino Due connectors to a breadboard 8-at-a-time, so they're easier to remove and more reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried these &lt;a href=&quot;http://www.digikey.com/product-detail/en/A9AAT-0802F/A9AAT-0802F-ND/160785&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flat Flex Cable Assemblies&lt;/a&gt; (FFC assemblies) terminated with &quot;solder lugs&quot; from Digi-Key, but the pins are just a little too short to penetrate the Arduino connectors well.  Similarly they barely reach into to the breadboard contacts, so they tend to fall out.  Anyone find a workable product for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/a47tU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA; &lt;img src=&quot;https://i.stack.imgur.com/WiCEB.jpg&quot; alt=&quot;Flat Flex Cable Assembly&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/1649/how-to-improve-wiring-a-breadboard&quot;&gt;This solution&lt;/a&gt; is good but requires a lot of manual soldering.  Looking for prepackaged.&lt;/p&gt;&#xA;" OwnerUserId="44" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-07-08T10:11:31.027" Title="Breadboard-to-Arduino wiring with flat flex cable assemblies?" Tags="|arduino-due|wires|prototype|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3217" PostTypeId="2" ParentId="3216" CreationDate="2014-07-07T16:45:48.317" Score="7" Body="&lt;p&gt;Search for male-male jumper wire. Some of what you'll find is individual wires but there are also many that are connected together and you can rip off the width you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;a href=&quot;http://www.adafruit.com/products/758&quot; rel=&quot;nofollow noreferrer&quot;&gt;one from Adafruit&lt;/a&gt; but there is no shortage of them on ebay/amazon.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/3FKgE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-07-07T16:45:48.317" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3218" PostTypeId="2" ParentId="3216" CreationDate="2014-07-07T21:13:22.327" Score="3" Body="&lt;p&gt;Although &lt;a href=&quot;https://arduino.stackexchange.com/a/3217/220&quot;&gt;Sachleen's answer&lt;/a&gt; is preferable in a lot of situations, there are a few other options that you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Quick note on his answer: I find clamping a row of those wires together and rubbing a thin line of superglue over the connectors a useful way to keep them together. It's not very neat, but it works pretty well and, with that many wires connected, can make it more stable than before.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two main alternatives I see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ribbon cable:&lt;/strong&gt; very similar to the wires pointed out in Sachleen's answer, only the connectors come already as one piece.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fAb86.jpg&quot; alt=&quot;&quot;&gt;&#xA;  &lt;em&gt;Source: &lt;a href=&quot;http://www.adafruit.com/blog/wp-content/uploads/2012/06/window-207.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.adafruit.com/blog/wp-content/uploads/2012/06/window-207.jpg&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They are typically two rows, but I've seen them before with one (although pretty rare). You could just ignore one row of those and use some male headers to connect the same side of the ribbon cable to the breadboard/Due.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;DIY:&lt;/strong&gt; although you said that you didn't like soldering, it's still the best solution here IMHO. You'll need soldering later on, and breadboards aren't reliable beyond just simple development, so you'll need to learn at one point or another. This is a great entry project because it's pretty hard to mess a simple thing like this up, unless you accidentally bridge two joints. However, you won't damage an expensive chip if you mess up (which you will on the first few times you solder), you can just clean the joints and start over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, just grab some perf board and some wire (twisted pair (similar to CAT5e)/ribbon cable with or without an adapter and plug/loose wires, and a few rows of male headers. The type of wire you choose doesn't really matter, just don't get something too thick or too thin. Anyway, solder some headers to the perf board and then you can solder the wires/the socket (if you choose a ribbon cable with ends) together. You can then cut the perf board to size (you can do this step before soldering) and you're done!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-07-07T21:13:22.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3219" PostTypeId="1" CreationDate="2014-07-07T23:55:34.867" Score="7" ViewCount="1576" Body="&lt;p&gt;I am working on a project that uses a potentiometer and an ultrasonic sensor to create MIDI signals. This is my first time working with an arduino. I took a class in C++, but am teaching myself some C in order to program the arduino. So far I have been looking at code that has been written, I've been trying to understand it and mess with it so that my arduino works. The first code creates notes, but I have no control over what notes play or when they play. The first code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int val;&#xA;int AnalogValue = 0;    &#xA;byte note = 0;  &#xA;SoftwareSerial midiSerial(2, 3);&#xA;&#xA;void setup () &#xA;{&#xA;&#xA;  pinMode(Pingpin, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  midiSerial.begin(31250);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  val = 0;&#xA;  digitalWrite(Pingpin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(Pingpin, HIGH);&#xA;  delayMicroseconds(5);&#xA;  digitalWrite(Pingpin, LOW);&#xA;&#xA;  AnalogValue = analogRead(0);&#xA;  note = AnalogValue/8;&#xA;&#xA;  pinMode(Pingpin, INPUT); &#xA;  val = digitalRead(Pingpin); &#xA;  while(val == LOW) &#xA;  { &#xA;    noteOn(val, note, 0x40);&#xA;  }&#xA;  while(val == HIGH) &#xA;  {&#xA;     noteOn(val, note, 0x40);       &#xA;&#xA;  }&#xA;&#xA;}&#xA;void noteOn(byte cmd, byte data1, byte  data2) &#xA;{&#xA;    midiSerial.write(cmd);&#xA;   midiSerial.write(data1);&#xA;   midiSerial.write(data2);&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second code makes more sense to me, but I get no notes to play. I am lost, and can't seem to get the second code to work. Second code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int val; &#xA;int timecount; &#xA;int AnalogValue;  &#xA;int ultrasoundValue; &#xA;const int Pingpin = 8;&#xA;&#xA;byte note = 0;  &#xA;&#xA;SoftwareSerial midiSerial(2, 3); &#xA;&#xA;void setup ()&#xA;{&#xA;&#xA;  pinMode(Pingpin, OUTPUT); &#xA;  Serial.begin(9600);&#xA;  midiSerial.begin(31250);&#xA;}&#xA;void loop()&#xA;{&#xA;  AnalogValue = analogRead(0); &#xA;  note = AnalogValue/8; &#xA;  Serial.print(note,HEX);&#xA;  Serial.print(&quot;\t&quot;);&#xA;&#xA;  timecount = 0; &#xA;  val = 0;  &#xA;  digitalWrite(Pingpin, LOW); &#xA;  delayMicroseconds(2); &#xA;  digitalWrite(Pingpin, HIGH);&#xA;  delayMicroseconds(5);  &#xA;  digitalWrite(Pingpin, LOW); &#xA;&#xA;  pinMode(Pingpin, INPUT); &#xA;  val = digitalRead(Pingpin); &#xA;  while(val == LOW) &#xA;  { &#xA;   val = digitalRead(Pingpin);&#xA;  }&#xA;&#xA;  while(val == HIGH)&#xA;  { &#xA;   val = digitalRead(Pingpin);&#xA;   timecount++;       &#xA;  }&#xA;&#xA;   ultrasoundValue = timecount; &#xA;   ultrasoundValue = ultrasoundValue - 14; &#xA;   ultrasoundValue = ultrasoundValue / 5;&#xA;&#xA;  Serial.print(ultrasoundValue);&#xA;&#xA;if(ultrasoundValue &amp;gt; 127)   &#xA; {&#xA;&#xA; }&#xA;&#xA;else &#xA;  {&#xA;&#xA;   noteOn(ultrasoundValue, note, 0x40); &#xA;&#xA;  }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;void noteOn(byte cmd, byte data1, byte  data2)   &#xA;{&#xA;   midiSerial.write(cmd);&#xA;   midiSerial.write(data1);&#xA;   midiSerial.write(data2);&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3066" LastEditorUserId="3988" LastEditDate="2014-09-18T16:35:21.327" LastActivityDate="2014-09-18T16:35:21.327" Title="Sending MIDI messages using PING ultrasonic sensor" Tags="|arduino-uno|programming|midi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3220" PostTypeId="2" ParentId="3219" CreationDate="2014-07-08T00:39:35.050" Score="3" Body="&lt;p&gt;There is quite a bit that needs to be addressed for these programs to work, and I don't know too much about midi, but i'll use the arduino midi tutorial for info. &lt;a href=&quot;http://arduino.cc/en/Tutorial/Midi?from=Tutorial.MIDI&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/Midi?from=Tutorial.MIDI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first code will take one measurement of an analog value, set it to note, make one digital reading of pingPin, set that to val, and then write noteOn() forever afterwards. The second code will continually make analog and Ping readings and then write those to serial if the ping reading is greater than 127.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Infinite loop aside, Your programs don't work largely because they send the sensor data in the wrong ways. The first byte sent to noteOn is a command byte, it should not contain sensor data. the arduino tutorial uses the command 0x90 to control the note being played on channel one. the second byte is the note and the third byte is velocity, which seems to work like volume.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to set the pitch and volume of channel one, you need to repeatedly send &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noteOn( 0x90, note, volume); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to play a note based on the analog readings that both of your codes set to &quot;note&quot; only when the ping value is larger than 127, you need something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(ultrasoundValue &amp;gt; 127){&#xA;    noteOn(0x90, note, 0x45); //middle volume according to arduino tutorial&#xA;} else {&#xA;    noteOn(0x90, note, 0x00); //make the note silent by using 0 volume&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you instead wanted to control the pitch with the ultrasoundValue, you would need to scale the value to being within 0-255, and then use that as note instead of the analog reading. You can get much more complicated than this, but you will need to find a reference for the MIDI protocol you can use.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-07-08T00:39:35.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3221" PostTypeId="1" CreationDate="2014-07-08T04:04:13.493" Score="2" ViewCount="239" Body="&lt;p&gt;I'm developing a system that will get the GPS signal and send it though the GSM with information about position, speed and temperature from some digital sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I'm using the GPS EM408, the Arduino mega plus the GSM board (official one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the GPS (by the library TinyGPSPlus) gives me the same speed for long time or sometimes give me 0km/h.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch works like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA;   getGPSData() - ~ 1 sec to execute and take one data from the GPS.&#xA;   getSensors() - ~ 1 sec to execute and take one data from the digital sensors.&#xA;   sendData() - ~ 6 n 10 secs to send the data through the internet. &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The whole process takes around 10 ~ 15 secs to be completed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the sendData() and the system starts getting the GPS information each second the speed value works perfectly but if I get the data from the GPS each 12 secs (because of the GSM delay) the speed doesn't work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that the problem is because the library TinyGPSPlus calculate the speed between two points and the getGPSData() only takes one information each loop and the next point has 15 secs of difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I've added a &quot;for(i=0;i&amp;lt;=4;i++)&quot; to the getGPSData() enforcing it to get at least 4 times of position before the GSM send it over the internet, now is working better but still getting the wrong value or sometimes it freezes to the same speedy for long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to add a second board and put both to communicate with I2C turning it &quot;dual core&quot;, where one board will be getting the data from the GPS each second and another one will send though the data each 15 secs, but the GSM freezes sometimes when the I2C is connected :(. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone has any clue how to do it?&lt;/p&gt;&#xA;" OwnerUserId="3068" LastEditorUserId="3068" LastEditDate="2014-07-08T04:19:24.847" LastActivityDate="2015-05-08T23:21:18.967" Title="GPS - Speed doesn't update as should - EM408 &amp; Arduino Mega &amp; GSM" Tags="|arduino-mega|gsm|i2c|c|tinygps|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3222" PostTypeId="2" ParentId="3184" CreationDate="2014-07-08T09:37:05.297" Score="1" Body="&lt;p&gt;Another method is to use MQTT. That's a protocol often used for embedded messaging. Find &lt;a href=&quot;http://knolleary.net/arduino-client-for-mqtt/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; the (one of the?) arduino client.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a server you can install &lt;a href=&quot;http://mosquitto.org/&quot; rel=&quot;nofollow&quot;&gt;mosquitto&lt;/a&gt; either on the same system running the web server, or on a different one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Than the communication logic with php will be done with &lt;a href=&quot;https://github.com/mgdm/Mosquitto-PHP&quot; rel=&quot;nofollow&quot;&gt;mosqitto-php&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;advantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;decoupling the web server(s) from the arduino(s)&lt;/li&gt;&#xA;&lt;li&gt;lightweight protocol for the arduino&lt;/li&gt;&#xA;&lt;li&gt;easy interface with more applications (eg, storing data in mysql, independently of the web server, or any new in the future)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;disadvantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;few more work setting up the mosquitto server.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="710" LastActivityDate="2014-07-08T09:37:05.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3223" PostTypeId="1" CreationDate="2014-07-01T22:13:45.677" Score="1" ViewCount="200" Body="&lt;p&gt;I have a Parallax PMB-688 GPS module I'm using with an Arduino and was wondering if I could hook up a compass directly to my GPS. The GPS has an RX port which I hypothesized a compass could be attached to but I don't know if the GPS would be able to comprehend the compass data alone or if I would need to hook it up to the Arduino separately. Please let me know if you have done this or know whether or not it will work. Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chris&lt;/p&gt;&#xA;" OwnerUserId="2867" OwnerDisplayName="chrisclifford" LastEditorUserId="42" LastEditDate="2015-04-10T16:20:10.613" LastActivityDate="2015-04-10T16:20:10.613" Title="Can I hook up a compass directly to my GPS module?" Tags="|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3224" PostTypeId="2" ParentId="3223" CreationDate="2014-07-02T12:00:37.483" Score="1" Body="&lt;p&gt;Unfortunately this will not work. If you take a look at the documentation for the module (&lt;a href=&quot;http://www.parallax.com/sites/default/files/downloads/28501-PMB-688-v0.1.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://www.parallax.com/sites/default/files/downloads/28501-Polstar-NMEA-Commands.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) you'll see that the RX pin is just there to receive commands for doing things like changing the baud rate and the protocol. The GPS wouldn't be able to comprehend the compass data.&lt;/p&gt;&#xA;" OwnerUserId="2999" OwnerDisplayName="thip" LastActivityDate="2014-07-02T12:00:37.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3225" PostTypeId="2" ParentId="3216" CreationDate="2014-07-08T10:11:31.027" Score="5" Body="&lt;p&gt;Again similar to Sachleen's answer. You can crimp your own connectors onto a ribbon cable, that way you can have the desired header size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've just done this manually with some pliers (I couldn't afford the crimping tool) a bit tricky but I'm pleased with the results. I got all of the bits I needed from www.hobbytronics.co.uk. Anywho I'm happy with the results now after a few failed attempts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OTDLf.jpg&quot; alt=&quot;You can see my attempts here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2762" LastActivityDate="2014-07-08T10:11:31.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3226" PostTypeId="1" CreationDate="2014-07-08T12:14:44.503" Score="3" ViewCount="23013" Body="&lt;p&gt;Even I can't do similarly with my 2.4&quot; TFT LCD in here still: &lt;a href=&quot;https://arduino.stackexchange.com/questions/1138/2-4-tft-lcd-shield-isnt-working-on-arduino-mega&quot;&gt;2.4&amp;quot; TFT LCD Shield isn&amp;#39;t working on Arduino Mega&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have bought 3.5&quot; TFT LCD display for my Arduino Mega 2560 R3 to try whether I could run the screen or not, and it is not working now! I am so depressed and angry for these two's misbehaviors. I have already checked website and a lot of Arduino IDE code examples and libraries such as UTFT.h, UTouch.h, UTFT_MEGA, UTFT_CTE, TFTLCD. I tried these and I can not run my 3.5&quot; screen. Where am I faulty? There is something below the screen shield: www.mcufriend.com and 3.5&quot; TFTLCD for Arduino 2560. Are there any basic code or have anyone tried to run Mcufriend's displays correctly? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cDu67.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZhSEg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-01-29T20:51:08.973" Title="3.5&quot; TFT LCD Display is not working with Arduino Mega 2560 R3" Tags="|arduino-mega|shields|lcd|display|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3230" PostTypeId="1" AcceptedAnswerId="3231" CreationDate="2014-07-08T18:16:47.457" Score="5" ViewCount="339" Body="&lt;p&gt;NOTE: this code was working perfectly fine in another program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a simple piece of code that puts the Arduino to sleep. When it is finished and intergrated into my project, it will only wake the processor up when an alarm from an external RTC triggers one of the hardware interrupts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;    set_sleep_mode(SLEEP_MODE_PWR_DOWN);        //deep sleep mode&#xA;    Serial.println(&quot;Device is going to sleep...&quot;);&#xA;    sleep_enable();        //put device to sleep&#xA;&#xA;    sleep_disable();        //Device restarts here on wake&#xA;    Serial.println(&quot;Device is awake...&quot;);        &#xA;    delay(1000);        //to slow down serial output&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In theory, the program should shut down the processor indefinitely because there is nothing available to wake it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the device continues waking itself up immediately after shutting down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried attaching the interrupts hoping it was some kind of anomalous watch-dog function. I have tried tying the interrupt pins to +5V and also (in a separate attempt) to GND. Nothing has helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is causing the processor (and/or program) to constantly wake itself up?&lt;/p&gt;&#xA;" OwnerUserId="2947" LastActivityDate="2014-07-08T18:28:39.003" Title="What is causing my Uno to wake up?" Tags="|arduino-uno|programming|interrupt|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3231" PostTypeId="2" ParentId="3230" CreationDate="2014-07-08T18:28:39.003" Score="8" Body="&lt;p&gt;&lt;code&gt;sleep_enable()&lt;/code&gt; &lt;em&gt;allows&lt;/em&gt; the MCU to sleep, but it does not &lt;em&gt;cause&lt;/em&gt; it to sleep. Call &lt;code&gt;sleep_cpu()&lt;/code&gt; after enabling.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-08T18:28:39.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3232" PostTypeId="2" ParentId="3194" CreationDate="2014-07-08T20:43:13.937" Score="1" Body="&lt;p&gt;You could use an Arduino with an ethernet shield to store the data to a MySQL server on the local network. See this &lt;a href=&quot;http://drcharlesbell.blogspot.dk/2013/04/introducing-mysql-connectorarduino_6.html&quot; rel=&quot;nofollow&quot;&gt;blog post&lt;/a&gt; for an introduction to a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tellstick is designed to be plugged into a USB host, so it doesn't make much sense in combination with an Arduino. You can get a USB host module but it's an expensive solution and you are using way more hardware than necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you could get 433 MHz receivers dirt cheap on ebay, but I'm afraid they only work on one channel, and there are a bunch of channels in the 433 MHz spectrum. So they might not work with the sensors you are talking about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use eg. Arduino Pro Mini's in combination with a 433 MHz transmitter, powered by a battery. You could get the temperature reading from the internal sensor, or use an external one. The internal sensor takes quite a bit of calibration work to give a precise reading though.&lt;br&gt;&#xA;You can get Pro Mini clones on ebay for a few dollars. You would have to dive into sleep modes and such, if you don't want't the batteries eaten away in a short time. To program it, you'll need an FTDI cable, or another Arduino programmed as an ArduinoISP (In System Programmer).&lt;br&gt;&#xA;As an alternative to the Pro Mini board you could use a plain AVR chip, but it will be more work.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-08T20:43:13.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3233" PostTypeId="2" ParentId="1465" CreationDate="2014-07-09T08:29:04.313" Score="2" Body="&lt;p&gt;Have you upgraded the firmware in your wifi shield? If not, it will have problems connecting. Compile and upload this sketch. If it shows the firmware version as 1.0.0, then you need to upgrade the firmware. If it shows 1.1.0, then it is current as of today.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600); &#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(&quot;WiFi shield not present&quot;); &#xA;    // don't continue:&#xA;    while(true);&#xA;  } &#xA;&#xA;  Serial.print(&quot;Firmware version: &quot;);&#xA;  Serial.println(WiFi.firmwareVersion());&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please Note: The chips are numbered differently but run the same Wi-Fi firmware. You can upgrade the firmware without any worries.&lt;/p&gt;&#xA;" OwnerUserId="3086" LastEditorUserId="42" LastEditDate="2014-07-09T10:23:49.610" LastActivityDate="2014-07-09T10:23:49.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3236" PostTypeId="2" ParentId="1425" CreationDate="2014-07-09T15:33:36.600" Score="1" Body="&lt;p&gt;Detailed instructions on how to shorten the bootloader time of Leonardo etc. are explained &lt;a href=&quot;http://www.leonardomiliani.com/en/2013/accorciamo-i-tempi-del-bootloader-della-leonardomicroesplora/&quot; rel=&quot;nofollow&quot;&gt;[here]&lt;/a&gt; (as stated by @Chris Stratton).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The crux of the matter was to redefine the timeout period&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* ./arduino/hardware/arduino/bootloaders/caterina/Caterina.c */&#xA;#define TIMEOUT_PERIOD 8000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to a lower value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I do not have such issues with Leonardo it boots very fast.&#xA;So this issue depends on your environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;strong&gt;OptiBoot&lt;/strong&gt;, an alternative bootloader that really boots faster &lt;a href=&quot;https://code.google.com/p/optiboot/&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;:&lt;/p&gt;&#xA;" OwnerDisplayName="user3028" LastEditorDisplayName="user3028" LastEditDate="2014-07-15T07:17:50.440" LastActivityDate="2014-07-15T07:17:50.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3237" PostTypeId="2" ParentId="3150" CreationDate="2014-07-09T15:44:18.113" Score="3" Body="&lt;p&gt;The error probably means that you have selected a wrong configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To modify the IDE to insert the &lt;code&gt;-F&lt;/code&gt; seems to be the hard way,&#xA;however the easy way is to make a wrapper to &lt;code&gt;avrdude&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd ./arduino/hardware/tools/&#xA;$ mv avrdude avrdude.orig&#xA;$ cat &amp;gt;avrdude.sh&#xA;  #!/bin/sh&#xA;&#xA;  ./avrdude.orig -F $@&#xA;  ^D&#xA;$ chmod +x avrdude.sh&#xA;$ ln -s avrdude.sh avrdude&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3028" LastEditorDisplayName="user3028" LastEditDate="2014-07-09T21:28:13.127" LastActivityDate="2014-07-09T21:28:13.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3238" PostTypeId="2" ParentId="2946" CreationDate="2014-07-09T15:55:30.913" Score="2" Body="&lt;p&gt;The values &lt;code&gt;0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL&lt;/code&gt; are arbitrary values and define the adresses of the senders and receivers to talk to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the Mirf library&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mirf.setRADDR((byte *)&quot;serv1&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;they can be also strings like &lt;code&gt;serv1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;RF24&lt;/code&gt; uses&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;write_register(RX_ADDR_P0, &amp;amp;value, 5);&#xA;write_register(TX_ADDR, &amp;amp;value, 5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3028" LastActivityDate="2014-07-09T15:55:30.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3239" PostTypeId="1" AcceptedAnswerId="3839" CreationDate="2014-07-09T19:42:51.387" Score="5" ViewCount="463" Body="&lt;p&gt;I've got a question regarding the use of Millis() on a Leonardo Arduino. I'm currently using it to time 4 seconds elapsed while sending a serial message every second. These messages play a sound. On the fourth message the sound is different to signify that the Arduino has started an event. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running into an issue where the sounds are &lt;strong&gt;occasionally&lt;/strong&gt; being played sporadically without a consistent 1 second between them. I'm wondering if there is a better way of doing what I'm doing? During the timing the Arduino is doing nothing else, and the receiving computer is also generally not doing anything taxing. Is this even an issue from the Arduino side? My receiving program is written in C# using System.IO.Ports.SerialPort. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason this is done through Arduino is because the event started by the Arduino needs to correspond exactly to the sounds, though if this remains unresolved I will need to rework this.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Code as requested.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    //Setup Code&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    //Code that handles other serial messages and various states&#xA;    if (isSpecificState == true)&#xA;        onSpecificState();&#xA;}&#xA;&#xA;void onSpecificState()&#xA;{&#xA;    //Setup to handle state&#xA;&#xA;    long holdStart = millis();&#xA;    long holdDuration = 0;&#xA;&#xA;    boolean print1 = false;&#xA;    boolean print2 = false;&#xA;    boolean print3 = false;&#xA;    boolean print4 = false;&#xA;&#xA;    while(holdDuration &amp;lt;= 4000)&#xA;    {               &#xA;        if (holdDuration &amp;gt;= 4000 &amp;amp;&amp;amp; !print4)&#xA;        {&#xA;            Serial.println(&quot;tt_sound:2&quot;);&#xA;            print4 = true;&#xA;        }            &#xA;        else if (holdDuration &amp;gt;= 3000 &amp;amp;&amp;amp; !print3)&#xA;        {&#xA;            Serial.println(&quot;tt_sound:1&quot;);&#xA;            print3 = true;&#xA;        }&#xA;        else if (holdDuration &amp;gt;= 2000 &amp;amp;&amp;amp; !print2)&#xA;        {&#xA;            Serial.println(&quot;tt_sound:1&quot;);&#xA;            print2 = true;&#xA;        }&#xA;        else if (holdDuration &amp;gt;= 1000 &amp;amp;&amp;amp; !print1)&#xA;        {&#xA;            Serial.println(&quot;tt_sound:1&quot;);&#xA;            print1 = true;&#xA;        }&#xA;        holdDuration = millis() - holdStart;&#xA;    }&#xA;&#xA;    //Handle state&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I mentioned in the comments, the Arduino is doing nothing else while the timing is happening. &lt;/p&gt;&#xA;" OwnerUserId="1720" LastEditorDisplayName="user3028" LastEditDate="2014-07-15T17:58:34.530" LastActivityDate="2014-08-18T21:31:25.147" Title="Arduino Leonardo timing Inconsistency" Tags="|serial|arduino-leonardo|time|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3241" PostTypeId="1" CreationDate="2014-07-09T23:20:17.690" Score="0" ViewCount="699" Body="&lt;p&gt;Is it possible to read the exhaust gas pressure of a turbo car with an Arduino, and then control an electric motor based on the pressure?&lt;/p&gt;&#xA;" OwnerUserId="3103" LastEditorUserId="6936" LastEditDate="2017-06-04T08:07:38.117" LastActivityDate="2018-01-09T01:38:39.827" Title="Read car high temperature exhaust pressure sensor" Tags="|sensors|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3243" PostTypeId="1" AcceptedAnswerId="3252" CreationDate="2014-07-10T07:27:07.787" Score="1" ViewCount="8700" Body="&lt;p&gt;Here is my very simple IR emitter circuit.&#xA;OSI5FU5111C-40 is an infrared LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Qaqn.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the IRremote library from &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&#xA;in this simple sketch,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;unsigned int raw[100]={... *SOME RAW SIGNAL* ...};&#xA;IRsend irsend;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.read() != -1) {&#xA;    for (int i = 0; i &amp;lt; 3; i++) {&#xA;      Serial.print(&quot;Start sending ...&quot;);&#xA;      irsend.sendRaw(raw, 100, 38); &#xA;      delay(40);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is when I send &lt;code&gt;1&lt;/code&gt; to serial monitor,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it outputs triple &lt;code&gt;Start sending ...&lt;/code&gt; and LED emits no signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I test the voltage between PIN3 and GND before and after sending the &lt;code&gt;1&lt;/code&gt;.&#xA;The voltage stays around 1V3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would someone please give me some advice? Thank you! &lt;/p&gt;&#xA;" OwnerUserId="3105" LastActivityDate="2014-07-10T22:47:14.803" Title="Why PIN3 stays at 1v3 in a IR emitter project?" Tags="|arduino-uno|library|arduino-leonardo|remote-control|ir|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3244" PostTypeId="1" AcceptedAnswerId="3245" CreationDate="2014-07-10T11:25:16.007" Score="-2" ViewCount="233" Body="&lt;ol&gt;&#xA;&lt;li&gt;What are the materials I will need for the project? We want the project to work like this: When the door is opened, we get an alert to our Android Phone. &lt;/li&gt;&#xA;&lt;li&gt;What is the circuit structure going to look like?&lt;/li&gt;&#xA;&lt;li&gt;Which is simpler, GPRS, Bluetooth or Wifi to get the alert?&lt;/li&gt;&#xA;&lt;li&gt;What is the best IDE to work on for this project?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3108" LastActivityDate="2014-07-10T12:29:19.630" Title="How does one build a door motion sensor project with Arduino Uno board to send alerts to an Android Phone?" Tags="|arduino-uno|arduino-ide|android|" AnswerCount="1" CommentCount="0" ClosedDate="2014-07-10T20:42:56.643" ContentLicense="CC BY-SA 3.0" />
  <row Id="3245" PostTypeId="2" ParentId="3244" CreationDate="2014-07-10T12:29:19.630" Score="2" Body="&lt;p&gt;If I could comment on this, I would say that this question really sounds like you haven't actually done any research to look into a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in simple terms:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino Uno, Android phone, GSM shield, contact sensor or limit switch&lt;/li&gt;&#xA;&lt;li&gt;The sensor or switch needs to be connected to an I/O pin on the Arduino, and will probably need to be connected to 5V.&lt;/li&gt;&#xA;&lt;li&gt;GSM(GPRS) is going to provide the most mobility&lt;/li&gt;&#xA;&lt;li&gt;Arduino&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2947" LastActivityDate="2014-07-10T12:29:19.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3247" PostTypeId="1" CreationDate="2014-07-10T15:39:26.353" Score="4" ViewCount="1418" Body="&lt;p&gt;I'm new here. I'm not a native speaker, so pardon my English.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just received my Arduino Leonardo today. I tried some basic calculations and stuff like blinking and LCD interfacing. Its interesting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now trying to make a tachometer with the Leonardo. I'm following &lt;a href=&quot;http://duino4projects.com/arduino-rpm-counter-tachometer-code/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the board they've used differs from the Arduino Leonardo (ie pin 3 is &lt;code&gt;interrupt0&lt;/code&gt; in the Leonardo but it is pin 2 in the Arduino Uno board used in the tutorial). I tried changing the pins on the program and reconnecting the circuit but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QgCBO.gif&quot; alt=&quot;Circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code from the tutorial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Optical Tachometer&#xA; *&#xA; * Uses an IR LED and IR phototransistor to implement an optical tachometer.&#xA; * The IR LED is connected to pin 13 and ran continually.&#xA; * Pin 3 (interrupt 0) is connected across the IR detector.&#xA; *&#xA; * Code based on: www.instructables.com/id/Arduino-Based-Optical-Tachometer/&#xA; * Coded by: arduinoprojects101.com&#xA; */&#xA;&#xA;int ledPin = 13; // IR LED connected to digital pin 13&#xA;volatile byte rpmcount;&#xA;unsigned int rpm;&#xA;unsigned long timeold;&#xA;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&#xA;void rpm_fun() {&#xA;  //Each rotation, this interrupt function is run twice,&#xA;  //so take that into consideration for calculating RPM&#xA;  //Update count&#xA;  rpmcount++;&#xA;}&#xA;&#xA;void setup() {&#xA;  lcd.begin(16, 2); // intialise the LCD&#xA;  //Interrupt 0 is digital pin 2, so that is where the IR detector is connected&#xA;  //Triggers on FALLING (change from HIGH to LOW)&#xA;  attachInterrupt(0, rpm_fun, FALLING);&#xA;  //Turn on IR LED&#xA;  pinMode(ledPin, OUTPUT);&#xA;  digitalWrite(ledPin, HIGH);&#xA;  rpmcount = 0;&#xA;  rpm = 0;&#xA;  timeold = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;  //Update RPM every second&#xA;  delay(1000);&#xA;  //Don't process interrupts during calculations&#xA;  detachInterrupt(0);&#xA;  //Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt&#xA;  //happened once per revolution instead of twice. Other multiples could be used&#xA;  //for multi-bladed propellers or fans&#xA;  rpm = 30*1000/(millis() - timeold)*rpmcount;&#xA;  timeold = millis();&#xA;  rpmcount = 0;&#xA;  //Print out result to LCD&#xA;  lcd.clear();&#xA;  lcd.print(&quot;RPM=&quot;);&#xA;  lcd.print(rpm);&#xA;  //Restart the interrupt processing&#xA;  attachInterrupt(0, rpm_fun, FALLING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me to fix the project? Has anyone here tried this project before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="3112" LastEditorUserId="4628" LastEditDate="2017-10-04T06:57:24.473" LastActivityDate="2021-11-27T04:06:45.587" Title="Leonardo-based tachometer?" Tags="|programming|motor|lcd|interrupt|arduino-leonardo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3248" PostTypeId="1" AcceptedAnswerId="3249" CreationDate="2014-07-10T19:03:41.753" Score="9" ViewCount="6256" Body="&lt;p&gt;I have an problem, which at first thoughts (and being new to Arduino) I though was a perfect application for an Arduino. However, after trying and failing to implement it I am doubting myself!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply - I need to control many LEDs independently, many of which will have their own individual patterns - for example &quot;5 seconds on - 5 seconds off&quot;. &quot;continuous flashes&quot; - or sequences such as &quot;2 flashes, pause, 1 flash&quot;. Obviously without the luxury of threads I am becoming a little unstuck. Be great to hear if a) Arduino is the best choice and b) if it is - how can I go about this!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance :)&lt;/p&gt;&#xA;" OwnerUserId="3116" LastActivityDate="2024-02-18T00:20:25.693" Title="Multiple independent LED patterns" Tags="|led|interrupt|threads|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3249" PostTypeId="2" ParentId="3248" CreationDate="2014-07-10T19:42:02.033" Score="9" Body="&#xA;&#xA;&lt;p&gt;Handling multiple patterns at the same time is certainly possible with a platform like Arduino, and there are a number of ways you could go about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One method I would consider is writing functions which effectively represent each pattern mathematically. You'd just pass it the total time that's elapsed in your program so far, and it will do the appropriate action for that specific moment in time. It will return immediately afterwards (no delays or anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do that, you'll first need to know how long a single cycle of the pattern lasts. You can then use the modulo operator to figure out how far through the current cycle you are. From there, all you need to do is have some &lt;code&gt;if&lt;/code&gt; conditions to determine what to do at any given time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what it might look like for your &quot;5 seconds on, 5 seconds off&quot; pattern:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;function pattern5on5off(unsigned long totalTime)&#xA;{&#xA;  // Calculate how far through the current cycle we are&#xA;  const unsigned long cycleTime = totalTime % 10000;&#xA;&#xA;  // If we're in the first 5 seconds of the cycle then turn the light on.&#xA;  // Otherwise, turn it off.&#xA;  if (cycleTime &amp;lt; 5000)&#xA;    digitalWrite(3, HIGH);&#xA;  else&#xA;    digitalWrite(3, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Admittedly, constantly calling &lt;code&gt;digitalWrite()&lt;/code&gt; when you don't technically need to isn't very efficient. It shouldn't cause any harm though, and is fairly easy to optimise if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the above example in a sketch, you'd just need to call it in &lt;code&gt;loop()&lt;/code&gt;, and pass the number you get from &lt;code&gt;millis()&lt;/code&gt;; e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;  const unsigned long totalTime = millis();&#xA;&#xA;  pattern5on5off(totalTime);&#xA;&#xA;  // call other patterns here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other patterns will be more complex, but follow the same principle. You'd just to use appropriate &lt;code&gt;if&lt;/code&gt; statements to express your logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The vital thing to remember is that the function represents a specific moment in time. It should never pause or delay the program, otherwise it will prevent the other patterns from running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: Timing on the first cycle&lt;/strong&gt;&lt;br&gt;&#xA;As jfpoilpret noted in the comments, the very first cycle will start at a random point. This is because the first time you call &lt;code&gt;millis()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt;, it won't start at 0 (the device will already have been running for a short time before &lt;code&gt;loop()&lt;/code&gt; gets called). It's easy to resolve though, if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would do it by offsetting the &lt;code&gt;totalTime&lt;/code&gt; value by the whatever value you got on the very first time around &lt;code&gt;loop()&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;unsigned long g_startTime = 0;&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned long totalTime = 0;&#xA;&#xA;  if (g_startTime == 0) {&#xA;    // This is the first cycle.&#xA;    // Store the start time so we can compensate later.&#xA;    g_startTime = millis();&#xA;&#xA;  } else {&#xA;    // This is not the first cycle.&#xA;    // Compensate for the start time.&#xA;    totalTime = millis() - g_startTime;&#xA;  }&#xA;&#xA;  pattern5on5off(totalTime);&#xA;  // etc..&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-07-11T08:49:12.137" LastActivityDate="2014-07-11T08:49:12.137" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3250" PostTypeId="2" ParentId="3201" CreationDate="2014-07-10T20:06:57.073" Score="0" Body="&lt;p&gt;An Arduino doesn't have anywhere near the processing ability to transcode video from a camera unless you had an abysmal frame rate and very low quality. Even then, you would have to add extra storage because the Arduino would be over capacity in a heartbeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend converting this project to a higher powered board like the Udoo. I have the &lt;a href=&quot;http://www.udoo.org/&quot; rel=&quot;nofollow&quot;&gt;Udoo Quad&lt;/a&gt; and it's beastly considering its form factor. You're going to need something a lot bigger than an Arduino!&lt;/p&gt;&#xA;" OwnerUserId="3064" LastActivityDate="2014-07-10T20:06:57.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3251" PostTypeId="2" ParentId="3248" CreationDate="2014-07-10T20:31:21.740" Score="4" Body="&lt;p&gt;Arduino is a fine choice for the task - easy to get started with. The key is to write non-blocking code. You could take a look at the BlinkWithoutDelay example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a suggestion for your task:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Timing suquences for the LED's in milliseconds&#xA;// First value is on time, second value is off time,&#xA;// third value on time and so on (up to 10 values)&#xA;// One row for each LED&#xA;unsigned int led_timing[][10] = {&#xA;  {5000, 5000},&#xA;  {100, 1000},&#xA;  {100, 100, 100, 1500, 100, 1500}&#xA;};&#xA;&#xA;// The pins the LED's are connected to&#xA;byte led_pins[] = {11, 12, 13};&#xA;&#xA;// Keep track of timing sequence&#xA;// Array size taken from led_pins&#xA;unsigned long last_change[sizeof(led_pins)/sizeof(led_pins[0])];&#xA;byte timing_i[sizeof(led_pins)/sizeof(led_pins[0])];&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialize LED's as output&#xA;  for (byte i = 0; i &amp;lt; sizeof(led_pins)/sizeof(led_pins[0]); i++)&#xA;  {&#xA;    pinMode(led_pins[i], OUTPUT);&#xA;    digitalWrite(led_pins[i], HIGH);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  // Current timestamp&#xA;  unsigned long now = millis();&#xA;&#xA;  // Keep track of sequence for each LED&#xA;  for (byte i = 0; i &amp;lt; sizeof(led_pins)/sizeof(led_pins[0]); i++)&#xA;  {&#xA;    if (now - last_change[i] &amp;gt;= led_timing[i][timing_i[i]])&#xA;    {&#xA;      digitalWrite(led_pins[i], !digitalRead(led_pins[i]));&#xA;      timing_i[i]++;&#xA;&#xA;      // Start over at the end of timing sequence&#xA;      timing_i[i] %= sizeof(led_timing[i])/sizeof(led_timing[i][0]);&#xA;&#xA;      last_change[i] = now;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-10T20:31:21.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3252" PostTypeId="2" ParentId="3243" CreationDate="2014-07-10T22:47:14.803" Score="0" Body="&lt;p&gt;A few things. As somebody else suggested, try a normal red LED and make sure that works first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that your resistor is allowing too much current through the LED. A high-current LED might tolerate 20 mA (thousandths of an amp.) With a 47 ohm resistor, you're pumping 5/47, or about 106 mA into the LED, which is likely more than 5 times what it is designed to handle. You will quickly burn out your LED. You should use a 270 ohm resistor instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also try just setting pin 3 to an output with this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(3, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then manually setting that pin to on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(3, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the LED lights up, you know the pin is working correctly. Then use the code you posted with the same setup, and make sure your LED flashes. If THAT works, try putting your IR LED back in the circuit. &lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-10T22:47:14.803" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3253" PostTypeId="2" ParentId="501" CreationDate="2014-07-11T00:10:00.817" Score="17" Body="&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/Waterlevel&quot; rel=&quot;noreferrer&quot;&gt;http://playground.arduino.cc/Main/Waterlevel&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above link had a nice approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xlx2a.png&quot; alt=&quot;Water level detection using Pressure Transducer&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The principle is the same as traditional pneumatic level gauge, excepted that the dial indicator is replaced by a pressure transducer, and the manually-operated pump is replaced by an aquarium air pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the pump is on, air flows through the weighted PVC pipe to the bottom of the tank, where bubbles appear. At this moment, the air pressure in the PVC pipe is equal to the hydrostatic pressure at the bottom of the tank. As the water pressure at the bottom of the tank is directly proportional to the water level, the same goes for the air pressure in the PVC tube. The air pressure is then converted to an analog voltage by the pressure transducer. This voltage can be read easily by the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A big advantage of this method with regards to other existing techniques is that no electronic or metallic parts needs to be placed in the tank, where the environmental conditions (mainly humidity) are not favorable. This avoids any risk of corrosion.&lt;/p&gt;&#xA;" OwnerUserId="3123" LastEditorUserId="3123" LastEditDate="2014-07-11T05:55:16.603" LastActivityDate="2014-07-11T05:55:16.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3254" PostTypeId="1" AcceptedAnswerId="3256" CreationDate="2014-07-11T01:31:49.590" Score="2" ViewCount="201" Body="&lt;p&gt;I have an arduino duemilanove with ATmega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Been doing several experiments with multiple peripherals&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had no problem uploading at all&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when i try to upload a big program (27,074 bytes (of a 30,720 byte maximum))&#xA;it compiles fine, then says uploading...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some time passes i get this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The board and serial port connections are fine.&#xA;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Then i tried to upload the blink example, but i get the same error for some reason&#xA;Everything worked fine before i uploaded my &quot;big&quot; program&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-07-11T11:06:24.100" Title="Problem uploading big program to arduino" Tags="|uploading|" AnswerCount="1" CommentCount="0" ClosedDate="2015-03-01T17:35:27.383" ContentLicense="CC BY-SA 3.0" />
  <row Id="3255" PostTypeId="1" AcceptedAnswerId="3262" CreationDate="2014-07-11T03:56:57.230" Score="1" ViewCount="8679" Body="&lt;p&gt;I have a brand new board which is a clone of the Mega2560.  I need to install the USB firmware on the 16U2 and the bootloader on the 2650 chip.  I have Atmel Studio and a JTAGICE-3. Using those, I can download HEX files compiled with the Arduino  IDE, and they run successfully. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm having trouble finding Mega-specific instructions for getting the firmware installed so that I can use the Arduino ISP protocol for downloading new sketches. I can find much more information about the Uno than the Mega. And much of the information I do find seems to be dated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Which are the right files to download?&lt;br&gt;&#xA;   I've tried to install the 'MEGA-dfu_and_usbserial_combined.hex' to the 16U2 and the 'stk500boot_v2_mega2560.hex' to the 2560. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the IDE won't connect via AVR ISP, and I get no serial communications from a serial sample sketch downloaded with the ICE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) What are the correct Fuse settings after I flash those files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Is there a good way to confirm that the 16U2  USB converter is working correctly in isolation from the 2560 chip?&lt;/p&gt;&#xA;" OwnerUserId="1364" LastActivityDate="2015-08-09T11:38:38.320" Title="How do I install the firmware on an Arduino Mega clone?" Tags="|arduino-mega|bootloader|firmware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3256" PostTypeId="2" ParentId="3254" CreationDate="2014-07-11T11:06:24.100" Score="4" Body="&lt;p&gt;The sync error is a common issue that doesn't have one simple solution (as shown &lt;a href=&quot;https://arduino.stackexchange.com/questions/17/some-dude-named-avr-wont-let-me-upload-my-program-aka-avrdude-stk500-getsync&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It means that the computer can't communicate with the processor, but it recognizes that it's there (out of sync). This is probably due to something (a peripheral, stray wire) interfering with the transmission from computer to device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solutions that have worked in the past:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Unplugging the Arduino for 30 seconds, then plugging it back in.&lt;/li&gt;&#xA;&lt;li&gt;Removing any wires connected to Rx and Tx pins during upload.&lt;/li&gt;&#xA;&lt;li&gt;Soldering components connected to Rx or Tx to the board (in this case, I was using a shield that allowed me to do this)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are lots of solutions available from different sources on the internet, but I have not come across one that names program size as the reason.&lt;/p&gt;&#xA;" OwnerUserId="2947" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-07-11T11:06:24.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3257" PostTypeId="1" CreationDate="2014-07-11T13:04:09.910" Score="1" ViewCount="511" Body="&lt;p&gt;I need to communicate my arduino by bluetooth but I'm living in a small town recently so I can't buy a bluetooth shield for my arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my question: Can I use a usb bluetooth dongle on my Arduino &lt;strong&gt;without a shield?&lt;/strong&gt;&#xA;PS: There is no need to re-use that bluetooth dongle with usb again.&lt;/p&gt;&#xA;" OwnerUserId="3127" LastEditorUserId="11" LastEditDate="2014-07-11T14:18:11.760" LastActivityDate="2014-07-11T14:23:12.163" Title="Using Bluetooth Dongle on Arduino" Tags="|serial|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3258" PostTypeId="2" ParentId="3257" CreationDate="2014-07-11T13:33:54.810" Score="2" Body="&lt;p&gt;Unless your Arduino is based on a AT90USBXX7, no. Bluetooth dongles are highly integrated and have no accessible interfaces other than USB.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-11T13:33:54.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3259" PostTypeId="2" ParentId="3257" CreationDate="2014-07-11T14:23:12.163" Score="5" Body="&lt;p&gt;You'll most likely need a USB host shield (&lt;a href=&quot;https://www.sparkfun.com/products/9947&quot;&gt;like this&lt;/a&gt;) for the Arduino to be able to communicate with the dongle, so that doesn't help. You may (this is a long shot) be able to crack open the dongle, look up some datasheets, and possibly find a serial interface inside that you could connect to Arduino... but like I said, it's a long shot.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-07-11T14:23:12.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3260" PostTypeId="1" AcceptedAnswerId="3315" CreationDate="2014-07-11T14:48:26.100" Score="4" ViewCount="4147" Body="&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; The issue turned out to be with my work laptop. Our IT department has them configured in such a way that the assignment of serial ports is different somehow. When I plugged in on my personal Macbook Pro it all worked perfectly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I just got my first Arduino. Its an UNO R3. I'm running OS X 10.8.5 (Mountain Lion) and the Arduino IDE 1.0.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under &lt;strong&gt;Tools&gt;Board&lt;/strong&gt; I have Arduino Uno selected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under &lt;strong&gt;Tools&gt;Serial&lt;/strong&gt; Port my options are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-Serial-1&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-Serial-1&lt;/li&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-Serial-2&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-Serial-2&lt;/li&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-Modem&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-Modem&lt;/li&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-PDA-Sync&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-PDA-Sync&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've tried all of them, but when I try to upload a sketch it fails. Most give the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The two &quot;modem&quot; options return this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial port '/dev/tty.Bluetooth-Modem' already in use. Try quitting any programs that may be using it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm at a loss. None of these serial ports seems correct but there aren't any other options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also under &lt;strong&gt;Tools&gt;Programmer&lt;/strong&gt; which option should I be using?&lt;/p&gt;&#xA;" OwnerUserId="3128" LastEditorUserId="3128" LastEditDate="2014-07-14T15:20:46.683" LastActivityDate="2015-02-16T16:37:02.897" Title="No valid serial ports for Arduino UNO on Mac" Tags="|arduino-uno|serial|mac-os|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3262" PostTypeId="2" ParentId="3255" CreationDate="2014-07-11T18:50:42.170" Score="2" Body="&lt;p&gt;Let focus on one thing at a time, that is flashing the 16u2. You can see if you've successfully done that when you can see the Arduino in your device-manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of, &lt;code&gt;MEGA-dfu_and_usbserial_combined.hex&lt;/code&gt; is, as stated on the github page, for the 8u2, not the 16u2. Since you already have a ISP programmer you don't need the dfu functionality.  You can just flash the precompiled &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex&quot; rel=&quot;nofollow&quot;&gt;Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex&lt;/a&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fuses can also be found in the &lt;a href=&quot;https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/atmegaxxu2&quot; rel=&quot;nofollow&quot;&gt;readme.txt on github&lt;/a&gt;: &lt;code&gt;-U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m&lt;/code&gt;. I don't see any difference in the fuses between the 8u2 and 16u2, so they should work for the 16u2 too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-11T18:50:42.170" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3263" PostTypeId="2" ParentId="3260" CreationDate="2014-07-11T21:03:58.770" Score="1" Body="&lt;p&gt;Have you hooked up your Arduino prior to pulling down the tools&gt;Serial Port menu? I only see the port for my Arduino listed when it's actually connected and running. (And it's never one of the bluetooth ports.) I don't have my Arduino with me at the moment so I can't tell you exactly what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that on my MBP (running 10.9.4) I have to be sure to plug the USB cable into the CORRECT USB port. The other port maps to a different port in the list of serial ports.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-11T21:03:58.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3264" PostTypeId="1" AcceptedAnswerId="3265" CreationDate="2014-07-11T17:19:22.477" Score="3" ViewCount="1366" Body="&lt;p&gt;I have 10 Arduino Pro Minis and one Arduino Uno. Via breadboard, if I connect Pro Minis in parallel, can I program all of them at same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;" OwnerUserId="3153" OwnerDisplayName="siniradam" LastEditorUserId="26916" LastEditDate="2017-09-09T08:08:54.940" LastActivityDate="2017-09-09T08:08:54.940" Title="Is it possible to program a few Arduinos at the same time?" Tags="|uploading|arduino-pro-mini|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3265" PostTypeId="2" ParentId="3264" CreationDate="2014-07-11T19:26:13.840" Score="4" Body="&lt;p&gt;Arduino Pro Mini is programmed through serial, using a bootloader. It uses &lt;code&gt;STK500&lt;/code&gt; protocol, which is described by &lt;a href=&quot;http://www.atmel.com/Images/doc2525.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmel&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, it can be possible to program multiple boards if only one TX Arduino pin is connected to USB-Serial converter, and all RX are in parralel, but this is an unreliable method. Only the board with TX pin connected can send its status back to programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Mini also requires a physical reset before uploading. Make sure that all Reset pins are connected together when reset button is pressed.&lt;/p&gt;&#xA;" OwnerUserId="3156" OwnerDisplayName="Dexter" LastActivityDate="2014-07-11T19:26:13.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3266" PostTypeId="1" CreationDate="2014-07-12T06:59:59.480" Score="14" ViewCount="15451" Body="&lt;p&gt;Before I install the Arduino IDE, I was just wondering whether I could just use notepad++ to write the files and move them into correct location. I assume notepad++ doesn't support Arduino code, but I suspect there will be a mod for it, even though sketches are a low-end version of C++, which is supported.&lt;/p&gt;&#xA;" OwnerDisplayName="user3137" LastEditorUserId="37" LastEditDate="2014-07-12T15:11:03.900" LastActivityDate="2014-10-05T13:00:18.837" Title="Can I use notepad++ for writing sketches?" Tags="|ide|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3267" PostTypeId="2" ParentId="3113" CreationDate="2014-07-12T11:16:42.540" Score="-1" Body="&lt;p&gt;Based off of what you have said, the simplest way to achieve what you want to do with your Arduino would be to use a WiFi shield, and setup the Arduino to function as a web server. I have included two links: the first link shows you Arduino's sponsored WiFi shield and explains the basics of how to use it. The second link addresses your question of using the Arduino+WiFi shield to generate WiFi signals, by setting it up as a web server. Both links contain sample codes from Arduino that you can copy and paste. Assuming that you are using the native Arduino software, you can also go to: File &gt; Examples &gt; WiFi &gt; WiFiWebServer, and the same code from the Arduino websites that I listed will be there for you to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WiFiWebServer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/ArduinoWiFiShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would always recommend that whenever you want to accomplish a certain task, such as WiFi signal generation, displaying characters on a LCD, or anything else, you search for a shield to use for that application. Shields always make life extremely easier. I hope this helps. :)&lt;/p&gt;&#xA;" OwnerUserId="3141" LastActivityDate="2014-07-12T11:16:42.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3268" PostTypeId="2" ParentId="3266" CreationDate="2014-07-12T11:22:06.457" Score="1" Body="&lt;p&gt;Its fine,  you have to start asking questions somewhere right? You could use notepad++ to write your files and move them to a correct location, but it would be pointless, because you would need a mod to compile and upload it to your Arduino. I would recommend just using the native Arduino IDE, because it does all the work for you, all you have to do is write your code, upload it, and sit back and watch. &lt;/p&gt;&#xA;" OwnerUserId="3141" LastActivityDate="2014-07-12T11:22:06.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3269" PostTypeId="1" AcceptedAnswerId="3275" CreationDate="2014-07-12T13:31:11.143" Score="6" ViewCount="44070" Body="&lt;p&gt;I have wired up a small project with a shift register (see below), but depending on how I put the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/sn74hc595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC595&lt;/a&gt; IC (8-bit shift register with 3-state output register), the green and yellow LEDs of the Arduino stop shining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are these LEDs for? Do they tell something about a possible damage of the IC/short circuit in the setup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/juRGS.jpg&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1484" LastEditorUserId="510" LastEditDate="2015-12-31T08:44:00.880" LastActivityDate="2020-07-07T14:33:23.793" Title="What purpose does the yellow and green LEDs have on the Arduino?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3270" PostTypeId="1" AcceptedAnswerId="3272" CreationDate="2014-07-12T13:31:50.530" Score="31" ViewCount="55547" Body="&lt;p&gt;When doing RF, you have many options.&#xA;Three of the most basic are in the title box&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;WiFi&lt;/li&gt;&#xA;&lt;li&gt;Xbee&lt;/li&gt;&#xA;&lt;li&gt;NRF24L01&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What are the practical differences in using them. What is the purpose of each other and the pros and cons. What would you use depending on the application you had?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have a project in mind, but i want to start learning about Rf. I searched ebay for wireless devices. but i couldnt understand the differences. My goal is simply learning&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2019-01-06T06:21:07.990" Title="Whats the difference between RF options (wifi, xbee, NRF24L01)" Tags="|wifi|xbee|rf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3271" PostTypeId="1" CreationDate="2014-07-12T14:01:23.307" Score="0" ViewCount="257" Body="&lt;p&gt;I know the Arduino is a nice quick and dirty prototyping board. You quickly test your idea, and if you want to proceed you can do so with AVRs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Upload the program to Arduino, then remove the AVR chip and make a PCB (with the bootloader)&lt;/li&gt;&#xA;&lt;li&gt;Start from scratch with AVR (not always feasible because many libs are in Arduino)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now what is the purpose of a system that has processors that cannot be removed? For example the Arduino Galileo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure, you can do many things with it, but bottom line, you cannot remove the processor and do something with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, imagine you are prototyping a system you wish to, then, market and sell. That is feasible with the Arduino Uno family.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if you did in in Galileo? Even if it worked, you couldn't sell your system because you rely on the prototyping board. You cannot remove the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am i missing something?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="6936" LastEditDate="2016-11-12T19:24:26.180" LastActivityDate="2016-11-12T19:24:26.180" Title="What is the purpose of Galileo (or other unremovable chips)" Tags="|prototype|arduino-galileo|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3272" PostTypeId="2" ParentId="3270" CreationDate="2014-07-12T14:30:33.147" Score="45" Body="&lt;p&gt;There are many different type of RF networks with various advantages and disadvantages. The main things I consider when choosing a wireless communication method are network topology, data rate and power consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;WiFi:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;High data rate (54Mbit/s +) but also high power consumption. Used when you need to connect directly to the internet, such as an internet-of-things device, and have an external power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;XBee:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Low data rate (250kbit/s) and low power consumption. Used to make mesh-type sensor networks; each XBee device can communication with each other, and &lt;em&gt;through&lt;/em&gt; each other via the mesh to devices that are out of range. Used for networks of devices, particular home automation and sensors. &lt;a href=&quot;https://en.wikipedia.org/wiki/Xbee&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bluetooth:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Medium data rate and medium power consumption. IEEE standard has different device profiles to enable interoperability between devices. 'Pairing' type network however, so not useful for sensor networks, but good for controlling devices using a laptop or phone which usually have Bluetooth on board. Communicates with Arduino via serial RX and TX pins. &lt;a href=&quot;https://en.wikipedia.org/wiki/Bluetooth&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bluetooth Low Energy, ANT, etc:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very low data rate and very low power. These RF chips can run for years on an AA battery and so are used for things like heart rate sensors. The data rate is quite low so only good for transferring a small amount of data such as sensor readings. Most devices are setup as peripherals and can only connect to one 'central' device, so no good for sensor networks. Bluetooth low energy is supported by the latest mobile phones and laptops however. Useful to enable control of a device using a phone or laptop, for example a LED lamp. (See redbearlab for some Arduino options)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;GSM&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Phone connection. TODO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;nRF24L01&lt;/strong&gt; &lt;strong&gt;/&lt;/strong&gt; &lt;strong&gt;RFM12B&lt;/strong&gt; &lt;strong&gt;/&lt;/strong&gt; &lt;strong&gt;RFM22B(SI4432)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Popular proprietary transceivers. They can connect via SPI and have a lot of fancy features like low power modes, multiple channels, channel hopping, frequency calibration, CRC, retransmit and so on. The nRF24L01 from Nordic Semiconductor &lt;a href=&quot;http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01&quot;&gt;link&lt;/a&gt; operates in the 2.4GHz band, others use the ISM band 433/470/868/915Mhz. &#xA;These are todays state of the art highly integrated and low cost hardware for  reliable telemetry and consumer applications. The range is between 10m and 150m. The SI4432/RFM22B has the range of about 1.5Km.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other RF modules&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple and cheap serial devices. Single transmitter/receiver or transceiver that operate in the ISM band &lt;a href=&quot;https://en.wikipedia.org/wiki/ISM_band&quot;&gt;link&lt;/a&gt;. Often used as garage door opener. Useful for sensor network where interoperability with other devices is not required and you can implement your own protocol. &lt;a href=&quot;https://en.wikipedia.org/wiki/RF_module&quot;&gt;link&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorDisplayName="user3028" LastEditDate="2014-07-15T07:32:05.577" LastActivityDate="2014-07-15T07:32:05.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3273" PostTypeId="2" ParentId="3271" CreationDate="2014-07-12T14:42:54.440" Score="3" Body="&lt;p&gt;Edit: As Chris points out, this answer is more about the simple AVR Arduinos. For comment on the Galileo and other more complex MCUs, please refer to Chris' answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Arduino compatibility you can program the Arduino boot loader into the microcontroller using the ICSP pins. You do not need a chip from an Arduino board, you just solder a blank one in. Once the boot loader is on there you can use the Arduino IDE to upload sketches via the UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not necessary to use the Arduino system to write programs. You include the Arduino library files in a normal C++ project in many different IDEs and use the avr toolchain to compile and avrdude to upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of a board I just got back from PCBA. (The picture was sent by the PCB company for checking). Initially I made the board using an Arduino Pro Mini 3.3V, SD card breakout board, LSM303DHLC accelerometer breakout from Pololu, and Real Time Clock (RTC) breakout. Once everything was working I drew up a PCB in Eagle CAD, using the core of Arduino Pro Mini board plus the individual SD card, LSM303DLHC and RTC chips. I also added a 3.3V boost converter so I could get a constant 3.3V off 2 AA batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/meINZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board has the ICSP pins broken out. Actually, you will find they are broken out on most Arduino boards. Using another &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino as ISP&lt;/a&gt; I can program the Arduino boot loader via the ICSP pins, and then sketches can be uploaded via the UART using the Arduino IDE. In the IDE the board that is selected is &quot;Arduino Pro Mini 3.3V 8MHz&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino boot loader is a small piece of firmware that runs on startup. It allows you to send a program over the UART which it stores into FLASH memory itself. It is not absolutely necessary. You can program the chip using the ICSP as well. It is really convenient however. Using software like &lt;a href=&quot;http://russemotto.com/xloader/&quot; rel=&quot;nofollow noreferrer&quot;&gt;xloader&lt;/a&gt; you can upload Arduino programs without the IDE. Really handy when other people are using the board and you don't want to share your code. Alternatively, you can write a script for avrdude to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This project is for a university so I'm leaving it as Arduino compatible. In a commercial engineering environment, I would choose a more appropriate MCU (one with lower power consumption for a battery device) and rewrite the program to be more efficient and not rely on the Arduino and third-party libraries.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-07-17T14:22:22.620" LastActivityDate="2014-07-17T14:22:22.620" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3274" PostTypeId="2" ParentId="3266" CreationDate="2014-07-12T14:47:13.887" Score="3" Body="&lt;p&gt;The Arduino files are just text files with the *.ino extension, so it is OK to edit them with a text editor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE is needed to compile them (easily) however. To make an Arduino project without the IDE, create a directory e.g. MyProject, and create a file inside it called MyProject.ino. They have to have the same name. Adding extra *.ino files inside the directory will result in extra tabs in the Arduino IDE for those files when you open MyProject.ino.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-12T14:47:13.887" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3275" PostTypeId="2" ParentId="3269" CreationDate="2014-07-12T15:06:15.097" Score="13" Body="&lt;p&gt;The green LED is marked with &lt;code&gt;ON&lt;/code&gt;, and it indicates that the Arduino has power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The yellow LED is marked &lt;code&gt;L&lt;/code&gt; and is just connected to pin 13. So when you set pin 13 to HIGH the LED lights up. You can however still use pin 13 for other things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the green LED stops shining you most likely have a short somewhere. As the short will drain all power away, so the Arduino has no power left to light the LED(s).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-09-21T07:19:57.947" LastActivityDate="2016-09-21T07:19:57.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3276" PostTypeId="2" ParentId="3271" CreationDate="2014-07-12T15:18:40.873" Score="1" Body="&lt;p&gt;You are right. There are however people that use an arduino for hobby, and don't want to invest more time into learning to make PCB and programming bare AVRs. For some people getting some leds to blink is already very hard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also look at the amount of Arduino shields that are available. The target group of Arduino's has shifted from hobby electronics people to just regular people wanting to get some project working. People are okay with sacrificing an entire arduino board, adding some shields and putting it inside a Tupperware box. As long as it solves their problem, or does something cool.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-12T15:18:40.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3277" PostTypeId="2" ParentId="3271" CreationDate="2014-07-12T16:27:35.607" Score="0" Body="&lt;p&gt;Arduino boards, with or without removable chips, provide a lot of facilities ready to go for experimenters, prototypers, students, artists and other tinkerers who aren't necessarily interested in the electronics but just want a programmable controller to get a job done. They can often be the cheapest way to build a one-off system once you consider the labor to build a less expensive board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really easy to program AVR chips on a breadboard or, in most cases, right on the custom project board. You don't need Arduino to do that. I've built up and programmed ATMega328p projects without ever taking my Arduino out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a project I prototyped on an Arduino Mega2560 and later ported to the project board with soldered-in chip. The cable is a USB FTDI serial cable, a stock item that connects any chip with a TTL UART directly to a computer USB port. (The green daughter board is an X-10 RF transmitter and the reason I prototyped this project on a larger CPU). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ewRb1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often I develop project code solely on the project board; it's just about as easy. About the only advantages I get from using the larger board is multiple serial lines so I don't have to keep switching my terminal app off and on to allow down loading, and I can include lots of extra debugging code and libraries that I won't need in the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your favorite tool set will work either way. The Arduino IDE, Eclipse, or bare-nekkid ARVdude at the command line. If your project code needs the Rx/Tx pins, you may need to build one board with jumpers to disconnect the project's serial hardware while you're downloading.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-07-12T16:59:17.243" LastActivityDate="2014-07-12T16:59:17.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3278" PostTypeId="2" ParentId="3266" CreationDate="2014-07-12T20:37:04.127" Score="12" Body="&lt;p&gt;You can easily use notepad++ or any text editor to edit arduino code files (.pde or .ino). I use the sublime text editor for all my arduino coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you noted, the arduino syntax is c++, so setting the syntax highlighting mode to c++ is all that you need to do; no mod should be necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino includes a &quot;Use external editor&quot; option in the preferences menu that will make it reload the file every time you compile or upload. It also disables editing in the editor window. In this mode, just save your file in any editor, change to the arduino window, and hit upload. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since 1.5, arduino has had command line support. most editors allow making the &quot;build&quot; button execute arbitrary commands in the current directory. by setting build to run &quot;arduino --verify&quot; or &quot;arduino --upload&quot; you can code in any editor you want even without having an arduino window open.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-07-12T20:37:04.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3280" PostTypeId="1" AcceptedAnswerId="3288" CreationDate="2014-07-13T00:55:09.533" Score="3" ViewCount="4069" Body="&lt;p&gt;I'm flying out for vacation, and I want to take some of my half-done arduino projects with me to work on.  I'm concerned that aiprort security might mistake my devices for something sinister or at bare minimum 'suspicious' and be confiscated.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone ever had any negative experiences taking arduino-esque wiring projects through airport security?  &lt;/p&gt;&#xA;" OwnerUserId="667" LastEditorUserId="667" LastEditDate="2014-07-13T01:05:27.063" LastActivityDate="2016-10-11T02:09:26.787" Title="Any problems taking arduino(esque) devices through airport security?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3281" PostTypeId="2" ParentId="3280" CreationDate="2014-07-13T01:15:29.480" Score="2" Body="&lt;p&gt;It will depend on your particular country of course. Check the rules on cabin baggage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Australia, Arduino boards should pose no problem. It is best to not take any batteries or tools with edges (screwdrivers) or heavy tools (wrenches). In case they do want to have a look, place the boards at the top of your bag for easy access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have traveled to Europe from Australia with half a suitcase full of large PCBs with no problem. The only time my bag was opened was when I was carrying a tea pot stand, which was in the shape of a tea pot. Apparently it looked like a gun. &lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-13T01:15:29.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3282" PostTypeId="2" ParentId="3280" CreationDate="2014-07-13T01:48:18.263" Score="3" Body="&lt;p&gt;I don't think that is a problem. I have taken my arduino several times with me when I travel by plane and have never had any problems. I have even carried an oscilloscope and I only was warned about the pointy probes. I have taken international flights with it without any problems. However, always verify the airline baggage restrictioins.&lt;/p&gt;&#xA;" OwnerUserId="3144" LastActivityDate="2014-07-13T01:48:18.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3284" PostTypeId="1" CreationDate="2014-07-13T12:05:06.947" Score="1" ViewCount="1186" Body="&lt;p&gt;I am using the following components to build simple motobot:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;Arduino motor shield, &lt;/li&gt;&#xA;&lt;li&gt;servo, &lt;/li&gt;&#xA;&lt;li&gt;sonar HC-SR04, &lt;/li&gt;&#xA;&lt;li&gt;magician chessis,&lt;/li&gt;&#xA;&lt;li&gt;DC adapter with 4 AA batteries. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All works fine while USB cable is plugged. As soon as I unplug USB cable servo and sonar stop working, although motors connected to motor shield continue rolling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I read around internet motor shield operates with 7-12V voltage. I need 5V for sonar and servo. So they both are connected to 5V pin on the shield board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I overcome this issue?&lt;/p&gt;&#xA;" OwnerUserId="1665" LastActivityDate="2014-09-15T04:27:01.397" Title="Sonar and servo stop working when usb cable unplugged" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3285" PostTypeId="2" ParentId="3284" CreationDate="2014-07-13T12:44:06.207" Score="0" Body="&lt;p&gt;Add an extra 2-4 AA batteries in series. 4 x AA is 6V for fresh batteries, 4V when the batteries are at the end of their life, which is not enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to get a boost converter, e.g. &lt;a href=&quot;http://www.miniinthebox.com/0-9v-5v-to-5v-600ma-dc-dc-step-up-boost-module_p508927.html?currency=AUD&amp;amp;litb_from=paid_adwords_shopping&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, so you can supply 5V with less than 5V.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-13T12:44:06.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3286" PostTypeId="1" AcceptedAnswerId="3296" CreationDate="2014-07-13T15:57:58.720" Score="2" ViewCount="15750" Body="&lt;p&gt;I purchased several nRF24L01+ (RF24) radios to use with my Arduino Uno and Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;a href=&quot;http://maniacbug.github.io/RF24/GettingStarted_8pde-example.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;GettingStarted&lt;/a&gt; sketch and nRF24L01+ connected to my Uno, I get nice debugging info in my serial monitor. However when I connect the nRF24L01+ to my Micro, upload the sketch and open the serial monitor I get no debugging information. There is no info displayed in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the Arduino Uno when set to Transmit, does not see the other nRF24L01+. Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my pinout to connect the nRF24L01+ to the Micro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line    From Arduino Pin    To nRF24L01+ &#xA;GND     GND                 1&#xA;3V3     3V3                 2&#xA;CE      9                   3&#xA;CSN     10                  4&#xA;SCK     SCK                 5&#xA;MOSI    MOSI                6&#xA;MISO    MISO                7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the nRF24L01+&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VkpaI.jpg&quot; alt=&quot;Nrf24L01+&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Copyright (C) 2011 J. Coliz &amp;lt;maniacbug@ymail.com&amp;gt;&#xA;&#xA; This program is free software; you can redistribute it and/or&#xA; modify it under the terms of the GNU General Public License&#xA; version 2 as published by the Free Software Foundation.&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;RF24.h&quot;&#xA;#include &quot;printf.h&quot;&#xA;&#xA;//&#xA;// Hardware configuration&#xA;//&#xA;&#xA;// Set up nRF24L01 radio on SPI bus plus pins 9 &amp;amp; 10 &#xA;&#xA;RF24 radio(9,10);&#xA;&#xA;//&#xA;// Topology&#xA;//&#xA;&#xA;// Radio pipe addresses for the 2 nodes to communicate.&#xA;const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };&#xA;&#xA;//&#xA;// Role management&#xA;//&#xA;// Set up role.  This sketch uses the same software for all the nodes&#xA;// in this system.  Doing so greatly simplifies testing.  &#xA;//&#xA;&#xA;// The various roles supported by this sketch&#xA;typedef enum { role_ping_out = 1, role_pong_back } role_e;&#xA;&#xA;// The debug-friendly names of those roles&#xA;const char* role_friendly_name[] = { &quot;invalid&quot;, &quot;Ping out&quot;, &quot;Pong back&quot;};&#xA;&#xA;// The role of the current running sketch&#xA;role_e role = role_pong_back;&#xA;&#xA;void setup(void)&#xA;{&#xA;  //&#xA;  // Print preamble&#xA;  //&#xA;&#xA;  Serial.begin(57600);&#xA;  printf_begin();&#xA;  printf(&quot;\n\rRF24/examples/GettingStarted/\n\r&quot;);&#xA;  printf(&quot;ROLE: %s\n\r&quot;,role_friendly_name[role]);&#xA;  printf(&quot;*** PRESS 'T' to begin transmitting to the other node\n\r&quot;);&#xA;&#xA;  //&#xA;  // Setup and configure rf radio&#xA;  //&#xA;&#xA;  radio.begin();&#xA;&#xA;  // optionally, increase the delay between retries &amp;amp; # of retries&#xA;  radio.setRetries(15,15);&#xA;&#xA;  // optionally, reduce the payload size.  seems to&#xA;  // improve reliability&#xA;  radio.setPayloadSize(8);&#xA;&#xA;  //&#xA;  // Open pipes to other nodes for communication&#xA;  //&#xA;&#xA;  // This simple sketch opens two pipes for these two nodes to communicate&#xA;  // back and forth.&#xA;  // Open 'our' pipe for writing&#xA;  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)&#xA;&#xA;  if ( role == role_ping_out )&#xA;  {&#xA;    radio.openWritingPipe(pipes[0]);&#xA;    radio.openReadingPipe(1,pipes[1]);&#xA;  }&#xA;  else&#xA;  {&#xA;    radio.openWritingPipe(pipes[1]);&#xA;    radio.openReadingPipe(1,pipes[0]);&#xA;  }&#xA;&#xA;  //&#xA;  // Start listening&#xA;  //&#xA;&#xA;  radio.startListening();&#xA;&#xA;  //&#xA;  // Dump the configuration of the rf unit for debugging&#xA;  //&#xA;&#xA;  radio.printDetails();&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  //&#xA;  // Ping out role.  Repeatedly send the current time&#xA;  //&#xA;&#xA;  if (role == role_ping_out)&#xA;  {&#xA;    // First, stop listening so we can talk.&#xA;    radio.stopListening();&#xA;&#xA;    // Take the time, and send it.  This will block until complete&#xA;    unsigned long time = millis();&#xA;    printf(&quot;Now sending %lu...&quot;,time);&#xA;    bool ok = radio.write( &amp;amp;time, sizeof(unsigned long) );&#xA;&#xA;    if (ok)&#xA;      printf(&quot;ok...&quot;);&#xA;    else&#xA;      printf(&quot;failed.\n\r&quot;);&#xA;&#xA;    // Now, continue listening&#xA;    radio.startListening();&#xA;&#xA;    // Wait here until we get a response, or timeout (250ms)&#xA;    unsigned long started_waiting_at = millis();&#xA;    bool timeout = false;&#xA;    while ( ! radio.available() &amp;amp;&amp;amp; ! timeout )&#xA;      if (millis() - started_waiting_at &amp;gt; 200 )&#xA;        timeout = true;&#xA;&#xA;    // Describe the results&#xA;    if ( timeout )&#xA;    {&#xA;      printf(&quot;Failed, response timed out.\n\r&quot;);&#xA;    }&#xA;    else&#xA;    {&#xA;      // Grab the response, compare, and send to debugging spew&#xA;      unsigned long got_time;&#xA;      radio.read( &amp;amp;got_time, sizeof(unsigned long) );&#xA;&#xA;      // Spew it&#xA;      printf(&quot;Got response %lu, round-trip delay: %lu\n\r&quot;,got_time,millis()-got_time);&#xA;    }&#xA;&#xA;    // Try again 1s later&#xA;    delay(1000);&#xA;  }&#xA;&#xA;  //&#xA;  // Pong back role.  Receive each packet, dump it out, and send it back&#xA;  //&#xA;&#xA;  if ( role == role_pong_back )&#xA;  {&#xA;    // if there is data ready&#xA;    if ( radio.available() )&#xA;    {&#xA;      // Dump the payloads until we've gotten everything&#xA;      unsigned long got_time;&#xA;      bool done = false;&#xA;      while (!done)&#xA;      {&#xA;        // Fetch the payload, and see if this was the last one.&#xA;        done = radio.read( &amp;amp;got_time, sizeof(unsigned long) );&#xA;&#xA;        // Spew it&#xA;        printf(&quot;Got payload %lu...&quot;,got_time);&#xA;&#xA;        // Delay just a little bit to let the other unit&#xA;        // make the transition to receiver&#xA;        delay(20);&#xA;      }&#xA;&#xA;      // First, stop listening so we can talk&#xA;      radio.stopListening();&#xA;&#xA;      // Send the final one back.&#xA;      radio.write( &amp;amp;got_time, sizeof(unsigned long) );&#xA;      printf(&quot;Sent response.\n\r&quot;);&#xA;&#xA;      // Now, resume listening so we catch the next packets.&#xA;      radio.startListening();&#xA;    }&#xA;  }&#xA;&#xA;  //&#xA;  // Change roles&#xA;  //&#xA;&#xA;  if ( Serial.available() )&#xA;  {&#xA;    char c = toupper(Serial.read());&#xA;    if ( c == 'T' &amp;amp;&amp;amp; role == role_pong_back )&#xA;    {&#xA;      printf(&quot;*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r&quot;);&#xA;&#xA;      // Become the primary transmitter (ping out)&#xA;      role = role_ping_out;&#xA;      radio.openWritingPipe(pipes[0]);&#xA;      radio.openReadingPipe(1,pipes[1]);&#xA;    }&#xA;    else if ( c == 'R' &amp;amp;&amp;amp; role == role_ping_out )&#xA;    {&#xA;      printf(&quot;*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r&quot;);&#xA;&#xA;      // Become the primary receiver (pong back)&#xA;      role = role_pong_back;&#xA;      radio.openWritingPipe(pipes[1]);&#xA;      radio.openReadingPipe(1,pipes[0]);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastEditorUserId="6936" LastEditDate="2016-02-01T07:50:27.763" LastActivityDate="2016-02-01T07:53:10.613" Title="nRF24L01+ (RF24) radio with Arduino Micro" Tags="|rf|arduino-pro-micro|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3287" PostTypeId="2" ParentId="3284" CreationDate="2014-07-13T19:58:40.343" Score="0" Body="&lt;p&gt;Because I use nodejs with help of &lt;a href=&quot;https://github.com/rwaldron/johnny-five&quot; rel=&quot;nofollow&quot;&gt;johnny-five library&lt;/a&gt; I asked the question on the project wiki. This is the answer from Rick Waldron:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't unplug the USB, doing so kills the communication between the program and the board. Those components that continue functioning only do so b/c they are still receiving power. To free the bot from tethers, check out the guide at the bottom of this page: &lt;a href=&quot;https://github.com/rwaldron/johnny-five/wiki&quot; rel=&quot;nofollow&quot;&gt;https://github.com/rwaldron/johnny-five/wiki&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1665" LastActivityDate="2014-07-13T19:58:40.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3288" PostTypeId="2" ParentId="3280" CreationDate="2014-07-14T00:36:36.543" Score="2" Body="&lt;p&gt;I personally haven't taken my Arduino through security, but here are a few things I'd look at before flying:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;International flights might be more secure, so keep that in mind.&lt;/li&gt;&#xA;&lt;li&gt;(Like already mentioned) check your bags whenever possible&lt;/li&gt;&#xA;&lt;li&gt;Go extra early in case you do have to explain to the TSA (or equivalent). You don't want to miss your flight!&lt;/li&gt;&#xA;&lt;li&gt;Take it out of your bag so it doesn't look like you're hiding anything. The more open you are about it, the less suspicious they'll be.&lt;/li&gt;&#xA;&lt;li&gt;Bring any original packaging for your Arduino/parts.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A few other things I've read to do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take tickets if going to some event like a Maker Faire, especially if they can look it up online. If they seem skeptical, you could always pull it up on your phone.&lt;/li&gt;&#xA;&lt;li&gt;Don't make &lt;a href=&quot;http://www.instructables.com/id/Explosive-Alarm-Clock/&quot; rel=&quot;nofollow&quot;&gt;it look like a bomb&lt;/a&gt; (i.e. &lt;strong&gt;don't be stupid!&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Don't take tools unless needed&lt;/li&gt;&#xA;&lt;li&gt;Be patient and calm if they stop you. You have nothing to hide from them (Right? &lt;strong&gt;&lt;em&gt;Right?&lt;/em&gt;&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-14T00:36:36.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3289" PostTypeId="2" ParentId="3269" CreationDate="2014-07-14T00:39:30.657" Score="2" Body="&lt;p&gt;Also note that there is the TX and RX pins on Uno (orange/yellowish) are for the USB connection. When the LED labeled TX is lit up, the Arduino is transmitting data to the computer. When the RX is lit up, it is receiving data from the computer.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-14T00:39:30.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3291" PostTypeId="1" CreationDate="2014-07-08T13:18:46.017" Score="1" ViewCount="79" Body="&lt;p&gt;I am making an arduino game and the requirement is that my arduino reads 4 analog values from the pots. I dont know whether I should use an external battery supply or the 5V from the duino' itself. I dont want my ICs to get fried or nothing happening at all.&lt;/p&gt;&#xA;" OwnerDisplayName="user3816505" LastEditorUserId="42" LastEditDate="2015-04-10T16:20:56.297" LastActivityDate="2015-04-10T16:20:56.297" Title="How do I attach 4 input pots to arduino?" Tags="|analogread|potentiometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3292" PostTypeId="2" ParentId="3291" CreationDate="2014-07-08T21:17:10.387" Score="3" Body="&lt;p&gt;It doesn't really matter as long as the the voltage across your pots doesn't exceed the ARef or IORef voltage, which is usually equal to Vcc (3.3V or 5V) for the Arduino boards. It's best to use the 5V from your board. The ADC inputs are relatively high impedance so very little current flows through. Don't use very large value pots or you might not get the correct values from your analog inputs.&lt;/p&gt;&#xA;" OwnerDisplayName="EvangelosEm" LastActivityDate="2014-07-08T21:17:10.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3294" PostTypeId="1" CreationDate="2014-07-14T11:37:56.140" Score="2" ViewCount="385" Body="&lt;p&gt;I want to reclaim the space reserved for the bootloader on my ATMega32u4 (Leonardo chip).&#xA;But the lowest boot flash size I can see is BOOTSZ=11 which is 256 words (512 bytes). Is it not possible to completely disable it?&#xA;Basing this off of this: &lt;a href=&quot;http://www.engbedded.com/fusecalc&quot; rel=&quot;nofollow&quot;&gt;http://www.engbedded.com/fusecalc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-07-14T15:00:42.500" Title="Disable Boot Flash completely on ATMega" Tags="|bootloader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3295" PostTypeId="1" AcceptedAnswerId="3320" CreationDate="2014-07-14T11:50:21.537" Score="10" ViewCount="16675" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update&lt;/strong&gt;: I started playing with a genuine Deumilanove and exactly same problem happened to it - d13 led blinking, but avrdude says &lt;code&gt;stk500_recv(): programmer is not responding&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded a largish sketch ~15kb to Arduino Nano v3.0 (clone) and that left the board in an unusable state. When connected to USB, a power LED goes on immediately and 1-2 seconds later the yellow &quot;L&quot; starts blinking really fast.&#xA;&lt;a href=&quot;http://www.ebay.com/itm/161091236453&quot; rel=&quot;noreferrer&quot;&gt;Here's the board I use&lt;/a&gt;, it's a cheap clone, but it worked really well before today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when I try to upload a new sketch I get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried making and ISP programmer out of genuine Duemilanove, using &lt;a href=&quot;http://letsmakerobots.com/content/make-arduino-isp-programmer&quot; rel=&quot;noreferrer&quot;&gt;nano's ISP pins&lt;/a&gt; and tried following &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;noreferrer&quot;&gt;official instructions&lt;/a&gt; (didn't use any capacitors/resistors).&#xA;Either way when I click &quot;Burn Bootloader&quot; result is the same error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have connected &quot;debug&quot; leds to D7,8,9 and heartbeat fades in and out in idle, others stay dark.&#xA;When I click &quot;Burn Bootloader&quot; all leds go dark then it does few quick blinks on 7, then similar pattern for 8, and then heartbeat resumes. Sometimes this sequence is repeated twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried editing preferences.txt to bypass bootloader, but that didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I restore this board or do a low level reset?&lt;/strong&gt;&#xA;It seems to be in some failure mode, with pin 13 oscillating, but I don't know what that means.&lt;/p&gt;&#xA;" OwnerUserId="3155" LastEditorUserId="3155" LastEditDate="2014-12-18T03:36:00.920" LastActivityDate="2018-10-22T13:47:21.287" Title="Arduino Nano not responding with yellow led blinking fast" Tags="|bootloader|arduino-nano|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3296" PostTypeId="2" ParentId="3286" CreationDate="2014-07-14T13:00:18.557" Score="1" Body="&lt;p&gt;Perhaps you use the wrong pins. This is really a pitfall &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have the Atmega Pins, the consecutive pins of the headers and the pins written on the PCB, i.e. 9 could be 9 on the PCB which is A9. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Chinese 'Micro Pro' and I switched to (2,3) instead of (9,10).&lt;/p&gt;&#xA;" OwnerDisplayName="user3028" LastActivityDate="2014-07-14T13:00:18.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3297" PostTypeId="1" AcceptedAnswerId="3298" CreationDate="2014-07-14T13:57:59.687" Score="0" ViewCount="2204" Body="&lt;p&gt;I'm fairly new to this and I need some help before I buy anything...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I understand correctly I can buy an arduino, couple of shields and just stack them one onto another if they are compatible...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll be doing some work with an arduino and I would need both WiFi and GSM shields but I'm not sure if they're compatible... On the arduino.cc I saw that they both use pin 7 (GSM as modem reset and WiFi as &quot;handshake&quot;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can use both of the shields even though they use the same pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3163" OwnerDisplayName="user2908998" LastActivityDate="2017-02-04T10:06:03.890" Title="Arduino stacking wifi and gsm shield" Tags="|wifi|gsm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3298" PostTypeId="2" ParentId="3297" CreationDate="2014-07-14T14:13:33.970" Score="1" Body="&lt;p&gt;You can still use both of them although you'll need to buy another piece to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11002&quot; rel=&quot;nofollow&quot;&gt;This is called the Go-Between Shield&lt;/a&gt; and it basically lets you re-route a pin to a different one.  You will need to change the pin number in your code to the one you re-assign that signal to but it will still work.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The signals you listed that go on that pin are very incompatible, as in if you try to do it, you'll have problems.  Every time your Wifi shield will try to connect to something, your GSM shield will reset.&lt;/p&gt;&#xA;" OwnerUserId="6732" OwnerDisplayName="Shannon Strutz" LastActivityDate="2014-07-14T14:13:33.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3299" PostTypeId="2" ParentId="3294" CreationDate="2014-07-14T15:00:42.500" Score="4" Body="&lt;p&gt;It is not possible to set the bootloader space to 0, but it is possible to unlock the bootloader space entirely by unprogramming the lock bits as well as to enable normal booting by unprogramming BOOTRST in the high fuse byte. Access to the entire chip will then be fully unrestricted.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-14T15:00:42.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3300" PostTypeId="1" AcceptedAnswerId="3302" CreationDate="2014-07-14T16:25:46.567" Score="3" ViewCount="2021" Body="&lt;p&gt;I've been programming and testing an Arduino based quadcopter for the past 4 months. Until now I did not need to use an external power source for my sensors. Now I want to use the 'BEC' power from my electronics speed controllers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of the 4 ESCs gives 5V @ 2A. I would set these up in a parallel circuit, which would give me 5V @ 8A (theoretically).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to use a cheap chinese voltage sensor to sense the voltage from my 5000mAh 25-50c 11.1v battery. I'm not sure if it is safe to connect my batteries wires to my sensor with the 125A that it can put out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is whether or not it is safe to have a common ground on Arduino with an 8A power supply AND if it is safe to use a 5V 8A power supply with these sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a problem that I've encountered before:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;while powering my IMU off the BEC and sending motor PWM signals, my sketch would run for about 10 seconds then freeze. It was not until I powered my IMU off the Arduinos 5V power that I was able to run the sketch flawlessly. What could have been causing that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made a diagram of my circuit in Fritzing (not actually tested yet due to fear of ruining my sensors). I'm using an Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZLogT.jpg&quot; alt=&quot;Fritzing diagram&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3159" LastEditorUserId="84" LastEditDate="2014-07-15T04:37:59.323" LastActivityDate="2014-07-15T04:37:59.323" Title="Autonomous Quadcopter power distribution and sensing concerns" Tags="|power|battery|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3302" PostTypeId="2" ParentId="3300" CreationDate="2014-07-14T18:39:19.743" Score="2" Body="&lt;p&gt;Your question is quite long. I've broken it up into several parts:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;whether or not it is safe to have a common ground on arduino with an 8 amp power supply &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. In fact, if you have any electrical connection (even a signal) between those two, you'll &lt;em&gt;need&lt;/em&gt; a common ground to ensure integrity of the data being sent.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if it is safe to use a 5 volt 8 amp power supply with these sensors.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I didn't see how much they drew. Without a lot of information, I'm going to say &lt;em&gt;yes&lt;/em&gt;. If you don't need that much current, consider removing one of them so you only have 6A or 4A, since 8A is quite a bit if you aren't using it (and you might waste electricity in the conversion process). Make sure to have a thick enough wire for it. A best practice scenario would be to use each ESC separately or use two of the ESCs in parallel (with all  of the grounds connected!). This would isolate the current to either 4A or 2A.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;while powering my IMU off the BEC and sending motor PWM signals my sketch would run for about 10 seconds then freeze. It was not until i powered my IMU off the arduinos 5 volt power that I was able to run the sketch flawlessly. What could have been causing that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not quite sure what would be causing that without seeing the code/circuit for that. The only thing I can think of is the grounds weren't connected and the signal got corrupted.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-14T18:39:19.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3304" PostTypeId="2" ParentId="3264" CreationDate="2014-07-15T00:57:45.537" Score="3" Body="&lt;p&gt;In this case I would recommend considering using multiple USB-to-Serial Ports and simply replacing the &quot;.\arduino-1.5.6-r2\hardware\tools\avr\bin\avrdude.exe&quot; with a batch file that then called 10 (or any number of Serial Ports) of your choice.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would recommend reading my answer from &lt;a href=&quot;https://stackoverflow.com/questions/24688215/programming-arduinos-from-a-centralized-location/24688854#24688854&quot;&gt;Programming Arduino's from a centralized location&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where that solution may be a bit more complicated, then needed. But the same pieces would allow you to create a custom programmer that can specifically call the custom avrdude. Allowing the original methods to still exist.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Additionally worth noting. Is that you can turn on verbose for the compiling and uploading from the IDE's preferences. This will display the temporary directory that contains the exact location of the bin file and command executed to upload. Which can then be easily re-executed your convenience. Noting the temporary directory is not immediately destroyed. Where you can also change the arguments to execute different ports and sending it to the background. To call others. So that you can simultaneously upload many devices. &lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-07-15T00:57:45.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3305" PostTypeId="2" ParentId="3291" CreationDate="2014-07-15T01:04:25.913" Score="1" Body="&lt;p&gt;Set up 4 pins as inputs. Wire the pots as voltage dividers (center wired to the input through a small-value resistor. One of the ends of the pot wired to +5V from your Arduino, and the other end wired to ground.)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-07-15T14:31:32.793" LastActivityDate="2014-07-15T14:31:32.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3308" PostTypeId="1" AcceptedAnswerId="3310" CreationDate="2014-07-15T11:14:52.647" Score="1" ViewCount="1915" Body="&lt;p&gt;I was wondering if someone could try and solve a major problem I've been having with a brand new &lt;a href=&quot;http://arduino.cc/en/Main/Robot&quot; rel=&quot;nofollow&quot;&gt;Arduino Robot&lt;/a&gt; (similar to an Arduino Leonardo). Any input would be very much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been working with an Arduino Robot on a summer internship for the last week with no major problems. However, a couple of days ago, it stopped running programs and couldn't be detected when being plugged into the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When plugged in or turned on, the LCD turns on with nothing displayed on the screen and the power LED also switches on. However, no program is run (I had a working program involving the LCD uploaded at the time it stopped functioning, which would normally run). Also when plugged in, the Arduino is completely undetected by the computer, with the 'Serial Port' option under Tools grayed out, the device not showing up in device manager, and no signs that a device has been plugged-in. I've tried 3 different USB cables - one of which I tested on another device - and 3 different computers (with Windows 7, 8.1 and Linux Ubuntu installed). On the Linux computer, I ran lsusb before and after plugging in the device and saw no change. I've also tried various solutions such as re-installing the drivers and the Arduino software, using MProg and various rebooting/unplugging-replugging variations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I think the problem is almost definitely with the Arduino Robot itself. I'll give a little information about the problems I encountered previously, to see whether something I did affected it or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first problem I had with the robot was entirely by my own fault and was pretty foolish of me (I'm new to electronics - this being my first project involving it). I ran code from &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29&quot; rel=&quot;nofollow&quot;&gt;this website&lt;/a&gt; (the first set of coding on the page) to try and see whether I could get the LCD to work - not realizing that it wouldn't work for a different type of LCD. After uploading the code, the speaker made a loud constant buzzing noise. Fortunately after uploading a different code, the problem was resolved. I'm doubtful that this could have affected the robot, but since I'm so new to this I'll leave it to one of you to decide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next problem was one to do with uploading. The robot worked fine for a couple of days after the first problem until I came across this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When uploading programs, there would be a 'device disconnecting' sound from the computer and the program would fail to upload (I can give details on the error messages if you need them). I managed to solve the issue using an odd solution involving hitting the reset button at just the right time while a program was uploading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this, the robot worked for a few hours. In this time I tried to play with the 'turn' function, which didn't seem to work very well at all (the robot would turn angles very different to the ones given) and started creating programs playing around with the LCD. It was at this point the robot stopped functioning properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So does anyone have any idea what might be wrong? I have no idea how to fix this problem and I've been trying to find a solution for almost 2 full days now. Any input at all would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3169" LastActivityDate="2017-01-18T17:03:03.160" Title="What's wrong with my undetected, unresponsive Arduino Robot?" Tags="|serial|uploading|arduino-leonardo|bootloader|robotics|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3309" PostTypeId="2" ParentId="2946" CreationDate="2014-07-15T11:38:22.413" Score="5" Body="&lt;p&gt;As most of the people have posted, the values for the pipe are arbitrary, but must follow the rules per the API:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pipes 1-5 should share the first 32 bits. Only the least significant&#xA;  byte should be unique, e.g.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Before I answer your question, I think an explanation on Hex and Decimal values are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 40 bit hexadecimal is a number representation of base 16. A decimal is of base 10. So you can convert a Hex Value to Decimal. As this is out of scope for the question, you can google on how to convert from one to another. There are some online converters:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hex to Decimal Converter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will see when you convert the Hex value to decimal, that its just a number representation. When you convert, you drop the &lt;code&gt;0x&lt;/code&gt; and &lt;code&gt;LL&lt;/code&gt;. As stated the &lt;code&gt;0x&lt;/code&gt; indicates the value is a hex value and &lt;a href=&quot;https://stackoverflow.com/a/7036077&quot;&gt;&lt;code&gt;LL&lt;/code&gt; means type Long Long&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer your question, use the a converter to find a hex number like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;F0F0F0F0A1&#xA;F0F0F0F0A2&#xA;F0F0F0F0B4&#xA;F0F0F0F0E9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just change the last 2 digits (least significant bit):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pipes 1-5 should share the first 32 bits. Only the least significant byte should be unique, e.g.&#xA;   openReadingPipe(1,0xF0F0F0F0AA);&#xA;   openReadingPipe(2,0xF0F0F0F066);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add the &lt;code&gt;0x&lt;/code&gt; and &lt;code&gt;LL&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0xF0F0F0F0A1LL&#xA;0xF0F0F0F0A2LL&#xA;0xF0F0F0F0B4LL&#xA;0xF0F0F0F0E9LL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am no expert on hex, as I am learning, so if I am incorrect, then please someone correct me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the nRF24L01 datasheet makes the following point that the choice of address is not completely arbitrary:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: Addresses where the level shifts only one time (that is, 000FFFFFFF) can often be detected in noise and can give a false detection, which may give a raised Packet Error Rate. Addresses as a continuation of the preamble (hi-low toggling) also raises the Packet Error Rate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="490" LastEditorUserId="43025" LastEditDate="2018-09-15T11:35:25.027" LastActivityDate="2018-09-15T11:35:25.027" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3310" PostTypeId="2" ParentId="3308" CreationDate="2014-07-15T11:40:03.887" Score="2" Body="&lt;p&gt;I'm pretty sure and sadly to announce you that the usb communication of your Arduino Leonardo Compatible is dead and the arduino is connecting to the computer just like an alimentation Source no more.&#xA;And since Arduino Leonardo based on The ATmega32U4 which has built-in USB communication ,so the Atmedga32U4 is dead(u-processor) too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not a software matter but hardware one.&lt;/p&gt;&#xA;" OwnerUserId="3086" LastActivityDate="2014-07-15T11:40:03.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3312" PostTypeId="2" ParentId="3202" CreationDate="2014-07-15T14:40:50.500" Score="1" Body="&lt;p&gt;You've already gotten a couple of good answers on why a pull-down resistor is needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To summarize, you need to connect the input to ground to keep the input from floating semi-randomly between high and low. You use a resistor so that when you close the switch, you don't create a short circuit between the +5V supply and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another point, though. The Arduino's inputs include an optional internal, software-controlled &lt;strong&gt;pull-up&lt;/strong&gt; resistor. If you first set up the pin as an input, then write a HIGH value to that port, it activates the pull-up resistor. That causes the pin to read as HIGH when nothing is connected to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then connect your switch to ground instead of +5V. You then need to change your code logic to treat a HIGH value as not pressed, and a LOW value as pressed. This lets you simplify your wiring a little, since you don't need an external resistor.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-15T14:40:50.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3314" PostTypeId="2" ParentId="3308" CreationDate="2014-07-15T18:51:05.113" Score="2" Body="&lt;p&gt;You should try to connect to the board using an in-system-programmer. If you have another Arduino lying around, you can upload the ArduinoISP sketch to and use it as a programmer. Alternatively you can buy a cheap programmer on ebay for a few dollars, just search for &quot;avr programmer&quot;. You should look up the placement of the MOSI, MISO,SCK, and RESET pins on your board and connect them appropriately(GND connection is also needed and VCC unless you have another power source).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For ArduinoISP you can run avrdude like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp -p atmega32u4 -b 19200 -P [serial port, eg. /dev/ttyUSB0 in Linux]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If avrdude can read the chip signature, then at least part of the chip is probably OK. Try to upload a sketch. If it works, you should locate the Leonardo bootloader and flash it to the board. See if it brings back the USB connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have any luck with these methods you might want to look into high voltage programming.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-15T18:51:05.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3315" PostTypeId="2" ParentId="3260" CreationDate="2014-07-15T19:53:56.050" Score="1" Body="&lt;p&gt;The issue turned out to be with my work laptop. Our IT department has them configured in such a way that the assignment of serial ports is different somehow. When I plugged in on my personal Macbook Pro it all worked perfectly.&lt;/p&gt;&#xA;" OwnerUserId="3128" LastActivityDate="2014-07-15T19:53:56.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3316" PostTypeId="1" CreationDate="2014-07-15T20:43:47.140" Score="1" ViewCount="3066" Body="&lt;p&gt;When trying to upload to my Mega r2, it simply times out during uploading.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried burning the bootloader, but that also gave an error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error while burning bootloader.&#xA;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can see the arduino in my Devices and Printers in control panel, so I don't think the board is burnt.  The power light also is on.  Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="1194" LastActivityDate="2015-11-12T15:21:03.140" Title="Mega 2560 Doesn't Respond" Tags="|arduino-mega|bootloader|avrdude|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3318" PostTypeId="1" CreationDate="2014-07-15T20:48:40.137" Score="1" ViewCount="18" Body="&lt;p&gt;Basically I want a contact to a socket (keep open) for sending strings and characters as well as receiving them. I do not want anything to do with web. I am writing my own server in vb and actually have that working. I also have working the Arduino ethernetshield. I just wanted an alternative wifi solution.&lt;/p&gt;&#xA;" OwnerUserId="3178" LastActivityDate="2014-07-15T20:48:40.137" Title="Client or WiFiClient wrapper for adafruit CC3000 wifi other than web" Tags="|arduino-mega|" AnswerCount="0" CommentCount="1" ClosedDate="2014-07-15T22:49:21.257" ContentLicense="CC BY-SA 3.0" />
  <row Id="3319" PostTypeId="2" ParentId="3241" CreationDate="2014-07-15T22:19:10.593" Score="1" Body="&lt;p&gt;Yes, I don't see why it wouldn't be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need a sturdy barometer, preferably a digital I2C one because they are typically more accurate. I recently bought this one to measure altitude: &lt;a href=&quot;http://www.adafruit.com/products/1603&quot; rel=&quot;nofollow noreferrer&quot;&gt;BMP180 Barometric Pressure/Temperature/Altitude Sensor- 5V ready&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful about the temperature that the sensor will have to deal with, its maximum temperature is 85°C (185°F).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor, I'm assuming, would be fairly large so you would need a beefy motor driver that uses a 5 volt logic level, maybe like this one: &lt;a href=&quot;http://www.seeedstudio.com/depot/L298-Dual-HBridge-Motor-Driver-p-284.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;L298 Dual H-Bridge Motor Driver&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a fairly difficult project, I'd say mostly because of the difficulty you would have mounting the barometer and motor. Never the less, it still is possible. &lt;/p&gt;&#xA;" OwnerUserId="3159" LastEditorUserId="6936" LastEditDate="2017-06-04T08:10:46.137" LastActivityDate="2017-06-04T08:10:46.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3320" PostTypeId="2" ParentId="3295" CreationDate="2014-07-15T23:37:13.590" Score="11" Body="&lt;p&gt;I successfully restored both boards using the reset button:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Power off the board (I disconnected the USB cable from computer)&lt;/li&gt;&#xA;&lt;li&gt;Press and hold the reset button&lt;/li&gt;&#xA;&lt;li&gt;Connect USB cable (keep holding the reset button)&lt;/li&gt;&#xA;&lt;li&gt;Click &quot;Upload Sketch&quot;&lt;/li&gt;&#xA;&lt;li&gt;Wait a second or two until Arduino software says &quot;Uploading...&quot; in the status bar&lt;/li&gt;&#xA;&lt;li&gt;Release the reset button&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Use these steps to upload any small sketch, Blink example is a good choice.&lt;/p&gt;&#xA;" OwnerUserId="3155" LastActivityDate="2014-07-15T23:37:13.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3322" PostTypeId="2" ParentId="1092" CreationDate="2014-07-16T10:43:58.607" Score="1" Body="&lt;p&gt;I wrote a simple JSON-RPC library (on top of aJson) with example of how to turn a led on with JSON-RPC procedure call:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Code: &lt;a href=&quot;https://github.com/cloud-rocket/arduino-json-rpc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/cloud-rocket/arduino-json-rpc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Documentation: &lt;a href=&quot;http://www.cloud-rocket.com/2014/03/serial-json-rpc-server-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.cloud-rocket.com/2014/03/serial-json-rpc-server-arduino/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3186" LastEditorUserId="11" LastEditDate="2014-07-16T16:04:49.593" LastActivityDate="2014-07-16T16:04:49.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3323" PostTypeId="1" CreationDate="2014-07-16T11:03:16.017" Score="1" ViewCount="423" Body="&lt;p&gt;I am trying to write to a XML file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can write some values but limited. When I add an extra line or value the xml file stop updating and all commands I have after the xml.close(); aren't executed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  File xml = FileSystem.open(&quot;/mnt/sda1/Data/data.xml&quot;, FILE_WRITE); // open the file&#xA;  if(xml){&#xA;    Serial.println(&quot;XML Opened&quot;);&#xA;    xml.println(&quot;&amp;lt;?xml version=\'1.0\' encoding=\'UTF-8\'?&amp;gt; &quot;);&#xA;    xml.println(&quot;&amp;lt;sea&amp;gt;&quot;);&#xA;      xml.println(&quot;\t&amp;lt;temperatures&amp;gt;&quot;); //ASCII control codes (TAB)&#xA;        xml.print(&quot;\t\t&amp;lt;water&amp;gt;&quot;);&#xA;          xml.print(waterTmp);&#xA;        xml.println(&quot;&amp;lt;/water&amp;gt;&quot;);&#xA;      xml.println(&quot;\t&amp;lt;/temperatures&amp;gt;&quot;);&#xA;    xml.println(&quot;&amp;lt;/sea&amp;gt;&quot;);&#xA;&#xA;&#xA;    xml.close();&#xA;  }&#xA;  else{&#xA;    Serial.print(&quot;XML Error&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For e.g if I add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xml.print(&quot;\t\t&amp;lt;air&amp;gt;&quot;);&#xA;xml.print(airTMP);&#xA;xml.println(&quot;&amp;lt;/air&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this lines of code are alone in a sketch everything is good.&#xA;Another strange thing is if I add the same line twice or more times it can write them to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any idea how this problem could be solved?&lt;/p&gt;&#xA;" OwnerUserId="3187" LastActivityDate="2014-07-20T20:22:41.953" Title="Arduino Yun. Write to XML file problem" Tags="|arduino-yun|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3324" PostTypeId="1" AcceptedAnswerId="3328" CreationDate="2014-07-16T14:45:25.937" Score="10" ViewCount="60293" Body="&lt;p&gt;I bought an Arduino-compatible Freaduino board atmega8 (I selected the board type as Arduino ng or older atmega8). I installed the Arduino IDE on Mac OS X and the FTDI drivers. But my serial port looks like this when I connect the board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qjd7o.png&quot; alt=&quot;screenshot 1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when I try to upload the program, this is the error I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w97Vv.png&quot; alt=&quot;screenshot 2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me what is the mistake? I am clueless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: the problem was I had not installed the driver properly (I guess). I uninstalled and reinstalled them and it worked perfectly. Also made a YouTube tutorial regarding the same. &lt;a href=&quot;http://youtu.be/BwatajQO_88&quot; rel=&quot;noreferrer&quot;&gt;http://youtu.be/BwatajQO_88&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3191" LastEditorUserId="4628" LastEditDate="2015-07-03T12:36:31.847" LastActivityDate="2016-02-16T01:29:29.843" Title="Arduino compatible's serial port not showing Mac OSX" Tags="|uploading|arduino-ide|avrdude|avr|mac-os|" AnswerCount="4" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3325" PostTypeId="2" ParentId="3324" CreationDate="2014-07-16T14:56:02.203" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/guide/macOSX&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/guide/macOSX&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That link should almost definitely get it working for you.  Ensure (as in Step 7) that the board you have is the same one that is selected in Tools-&gt;Board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in step 8, since you have connected via a USB cable, it should be one of the USB named options.  &lt;/p&gt;&#xA;" OwnerUserId="3193" LastActivityDate="2014-07-16T14:56:02.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3326" PostTypeId="2" ParentId="1465" CreationDate="2014-07-16T15:47:00.410" Score="0" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;WiServer.h&amp;gt;&#xA;&#xA;#define WIRELESS_MODE_INFRA 1&#xA;//#define WIRELESS_MODE_ADHOC   2&#xA;&#xA;// Wireless configuration parameters ----------------------------------------&#xA;unsigned char local_ip[] = {146, 227, 174, 29};      // Indirizzo IP&#xA;unsigned char gateway_ip[] = {146, 227, 175, 254};      // Indirizzo gateway IP&#xA;unsigned char subnet_mask[] = {255, 255, 248, 0};   // Subnet Mask&#xA;const prog_char ssid[] PROGMEM = {&quot;enduroam&quot;};      // SSID access point&#xA;&#xA;unsigned char security_type = 3;    // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2&#xA;&#xA;// WPA/WPA2 passphrase&#xA;const prog_char security_passphrase[] PROGMEM = {&quot;EAP-MSCHAP V2&quot;};  // max 64 characters&#xA;// setup the wireless mode&#xA;// infrastructure - connect to AP&#xA;// adhoc - connect to another WiFi device&#xA;unsigned char wireless_mode = WIRELESS_MODE_INFRA;&#xA;&#xA;unsigned char ssid_len;&#xA;unsigned char security_passphrase_len;&#xA;// End of wireless configuration parameters ----------------------------------------&#xA;// This is our page serving function that generates web pages&#xA;boolean sendMyPage(char* URL) {&#xA;&#xA;    // Check if the requested URL matches &quot;/&quot;&#xA;    if (strcmp(URL, &quot;/&quot;) == 0) {&#xA;        // Use WiServer's print and println functions to write out the page content&#xA;        WiServer.print(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;        WiServer.print(&quot;Hello World!&quot;);&#xA;        WiServer.print(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;&#xA;        // URL was recognized&#xA;        return true;&#xA;    }&#xA;    // URL not found&#xA;    return false;&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;  // Initialize WiServer and have it use the sendMyPage function to serve pages&#xA;  WiServer.init(sendMyPage);&#xA;&#xA;  // Enable Serial output and ask WiServer to generate log messages (optional)&#xA;  Serial.begin(57600);&#xA;  WiServer.enableVerboseMode(true);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  // Run WiServer&#xA;  WiServer.server_task();&#xA;&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3195" LastEditorUserId="11" LastEditDate="2014-07-16T16:06:17.237" LastActivityDate="2014-07-16T16:06:17.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3327" PostTypeId="1" CreationDate="2014-07-12T08:34:57.853" Score="0" ViewCount="737" Body="&lt;p&gt;I have a problem regarding Seeedstudio Bluetooth shield &lt;a href=&quot;http://www.seeedstudio.com/depot/Bluetooth-Shield-p-866.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/Bluetooth-Shield-p-866.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't detect its presence by any other devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I uploaded to Arduino is a standard example for slave device from the library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;   //Software Serial Port&#xA;#define RxD 6&#xA;#define TxD 7&#xA;&#xA;#define DEBUG_ENABLED  1&#xA;&#xA;SoftwareSerial blueToothSerial(RxD,TxD);&#xA;&#xA;void setup() &#xA;{ &#xA;    Serial.begin(9600);&#xA;    pinMode(RxD, INPUT);&#xA;    pinMode(TxD, OUTPUT);&#xA;    setupBlueToothConnection(); &#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;    char recvChar;&#xA;    while(1)&#xA;    {&#xA;        if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield&#xA;            recvChar = blueToothSerial.read();&#xA;            Serial.print(recvChar);&#xA;        }&#xA;        if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here&#xA;            recvChar  = Serial.read();&#xA;            blueToothSerial.print(recvChar);&#xA;        }&#xA;    }&#xA;} &#xA;&#xA;void setupBlueToothConnection()&#xA;{&#xA;    blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400&#xA;    blueToothSerial.print(&quot;\r\n+STWMOD=0\r\n&quot;); //set the bluetooth work in slave mode&#xA;    blueToothSerial.print(&quot;\r\n+STNA=SeeedBTSlave\r\n&quot;); //set the bluetooth name as &quot;SeeedBTSlave&quot;&#xA;    blueToothSerial.print(&quot;\r\n+STOAUT=1\r\n&quot;); // Permit Paired device to connect me&#xA;    blueToothSerial.print(&quot;\r\n+STAUTO=0\r\n&quot;); // Auto-connection should be forbidden here&#xA;    delay(2000); // This delay is required.&#xA;    blueToothSerial.print(&quot;\r\n+INQ=1\r\n&quot;); //make the slave bluetooth inquirable &#xA;    Serial.println(&quot;The slave bluetooth is inquirable!&quot;);&#xA;    delay(2000); // This delay is required.&#xA;    blueToothSerial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've uploaded it to Arduino UNO, connected the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED marked as D1 is blinking green, and D2 is switched off. The device is not detected by none of the  devices I've tried &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please Help Me&lt;/p&gt;&#xA;" OwnerDisplayName="user2358175" LastActivityDate="2015-12-23T20:57:42.923" Title="Arduino Uno R3 Bluetooth Shield is not discovering in any of the device" Tags="|bluetooth|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3328" PostTypeId="2" ParentId="3324" CreationDate="2014-07-16T17:17:11.693" Score="8" Body="&lt;p&gt;From the OSX System Report we learn that your board is based on an SiLabs CP2102 converter (or workalike), but according to your question you installed the drivers for an entirely different product from FTDI &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Arduino.cc has used FTDI in the past and CDC/ACM today, I don't believe they have ever used SiLabs so their instructions probably don't cover that, but other vendors obviously have)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install the CP2102 drivers and it should work if you use the /dev/tty.XX device which then appears when you plug in the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SiLabs appears to provide the drivers at &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx&quot; rel=&quot;noreferrer&quot;&gt;http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just for sake of completeness, there are &lt;em&gt;at least&lt;/em&gt; 5 distinct protocols/chips in use for serial-like USB communication with embedded devices:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;FTDI &#xA;&lt;li&gt;CDC/ACM Virtual Com Port&#xA;&lt;li&gt;SiLabs CP210x&#xA;&lt;li&gt;Prolific PL-2303&#xA;&lt;li&gt;ch340&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(Additional possibilities could include actual RS232 serial or serial-over-bluetooth) &lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-01-24T19:28:09.553" LastActivityDate="2015-01-24T19:28:09.553" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3329" PostTypeId="2" ParentId="3271" CreationDate="2014-07-16T17:41:48.177" Score="1" Body="&lt;p&gt;The pentium-class x86 based Galileo mentioned in the question title appears intended to meet project needs which have (memory, compute, or interface) requirements beyond the capability of the simple AVR (or perhaps even ARM) based Arduino boards.   It's not uncommon in the Arduino realm to see people trying to use the little processors for tasks which exceed their capability, and it appears intended to address that problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While one can breadboard the equivalent of the AVR based Arduinos, or duplicate the functionality of those or even the simpler ARM-based boards on a hobbyist-designed 2 layer PCB, implementing something like the Galileo would require a many-layer board designed by an experienced PCB designer.  &lt;strong&gt;For low-volume uses, someone would probably just buy the existing boards and use them&lt;/strong&gt; (there is a longstanding market of embedded control modules intended for such use) - only at high volumes would it be cost effective to re-implement the board or its equivalent.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-07-16T18:42:33.213" LastActivityDate="2014-07-16T18:42:33.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3330" PostTypeId="1" CreationDate="2014-07-16T18:44:27.507" Score="2" ViewCount="1793" Body="&lt;p&gt;Im a newbie on this arduino thing and I would like to build a curtain remotecontrolled from a local webpage with 2 buttons... a up an a down... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the connection via my phone the the local page with the buttons. :D &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem on this one is that the buttons' if statement (command == on); doesnt work or in other words the client.println(command); get the &quot;on&quot; command and write it on the page... but it dont do the function in the if statement (the button)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me...? it should be simple..:D  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Bridge.h&amp;gt;&#xA;    #include &amp;lt;YunServer.h&amp;gt;&#xA;    #include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;    int LEDPIN = 3; // your LED PIN&#xA;    YunServer server;&#xA;&#xA;    String readString;&#xA;&#xA;&#xA;    void setup() {&#xA;  // Start our connection&#xA;  Serial.begin(9600);&#xA;  pinMode(LEDPIN,OUTPUT);&#xA;  digitalWrite(LEDPIN,HIGH); // turn on Led while connecting&#xA;  Bridge.begin();  &#xA;&#xA;  // Show a fancy flash pattern once connected&#xA;  digitalWrite(LEDPIN,LOW); &#xA;  delay(150);&#xA;  digitalWrite(LEDPIN,HIGH); &#xA;  delay(150);&#xA;  digitalWrite(LEDPIN,LOW); &#xA;  delay(150);&#xA;  digitalWrite(LEDPIN,HIGH); &#xA;  delay(150);&#xA;  digitalWrite(LEDPIN,LOW); &#xA;  delay(150);&#xA;&#xA;  // Disable for some connections:&#xA;  // Start listening for connections  &#xA;&#xA;  // server.listenOnLocalhost();&#xA;  server.begin();&#xA;&#xA;}&#xA;&#xA;/* ------------------------------------------------*/&#xA;/* --------------- End WIFI connection ------------*/&#xA;/* ------------------------------------------------*/&#xA;&#xA;&#xA;void loop() {&#xA;  YunClient client = server.accept();&#xA;  if (client) {&#xA;      process(client);&#xA;    client.stop();&#xA;  }&#xA;  delay(50);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void process(YunClient client) {&#xA;  String command = client.readStringUntil('\\'); &#xA;&#xA;  client.println(&quot;Status: 200&quot;);&#xA;  client.println(&quot;Content-type: text/html&quot;);&#xA;  client.println();&#xA;  client.println(&quot;&amp;lt;B&amp;gt;&amp;lt;Center&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;a href='/arduino/on\\'&amp;gt;ON&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;a href='/arduino/off\\'&amp;gt;OFF&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;  client.print(&quot;Command: &quot;);&#xA;  client.println(command);&#xA;  client.println(&quot;&amp;lt;/B&amp;gt;&amp;lt;/Center&amp;gt;&quot;);&#xA;&#xA;&#xA;/* ------------------------------------------------*/&#xA;/* ------------------- Buttons --------------------*/&#xA;/* ------------------------------------------------*/&#xA;&#xA;&#xA;  if (command == &quot;on&quot;) {&#xA;    digitalWrite(LEDPIN,HIGH);&#xA;    digitalWrite(13,HIGH);&#xA;  }&#xA;&#xA;  if (command == &quot;off&quot;) {&#xA;    digitalWrite(LEDPIN,LOW);&#xA;     digitalWrite(13,LOW); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3196" LastActivityDate="2014-10-21T03:38:35.260" Title="Wifi server to control led on and off from local webpage.. - ..if statement doesnt work..." Tags="|wifi|led|arduino-yun|web-server|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3331" PostTypeId="1" AcceptedAnswerId="3332" CreationDate="2014-07-16T19:35:27.783" Score="7" ViewCount="68563" Body="&lt;p&gt;When I am trying to compile the following code,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int delayTime = 1;&#xA;int charBreak = 2.1;&#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;int rled1 = 1;&#xA;int rled2 = 2;&#xA;int rled3 = 3;&#xA;int rled4 = 4;&#xA;int rled5 = 5;&#xA;int gled1 = 6;&#xA;int gled2 = 7;&#xA;int gled3 = 8;&#xA;int gled4 = 9;&#xA;int gled5 = 10;&#xA;int bled1 = 11;&#xA;int bled2 = 12;&#xA;int bled3 = 13;&#xA;int bled4 = 14;&#xA;int bled5 = 15;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;int ra[] = {4,288,18464,288,4};&#xA;int ga[] = {2,144,9232,144,2};&#xA;int ba[] = {1,72,4616,72,2};&#xA;int rb[] = {18724,16644,16644,2080,0};&#xA;int gb[] = {9362,8322,8322,1040,0};&#xA;int bb[] = {4681,4161,4161,520,0};&#xA;int rc[] = {2336,16388,16388,2080,0};&#xA;int gc[] = {1168,8194,8194,1040,0};&#xA;int bc[] = {584,4097,4097,520,0};&#xA;int rd[] = {18724,16388,16388,2336,0};&#xA;int gd[] = {9362,8194,8194,1168,0};&#xA;int bd[] = {4681,4097,4097,584,0};&#xA;int re[] = {18724,16644,16644,16388,0};&#xA;int ge[] = {9362,8322,8322,8194,0};&#xA;int be[] = {4681,4161,4161,4097,0};&#xA;int rf[] = {18724,16640,16640,16384,0};&#xA;int gf[] = {9362,8320,8320,8192,0};&#xA;int bf[] = {4681,4160,4160,4096,0};&#xA;int rg[] = {2336,16388,16420,16416,2084};&#xA;int gg[] = {1168,8194,8210,8208,1042};&#xA;int bg[] = {584,4097,4105,4104,521};&#xA;int rh[] = {18724,256,256,256,18724};&#xA;int gh[] = {9362,128,128,128,9362};&#xA;int bh[] = {4681,64,64,64,4681};&#xA;int ri[] = {0,16388,18724,16388,0};&#xA;int gi[] = {0,8194,9362,8194,0};&#xA;int bi[] = {0,4097,4681,4097,0};&#xA;int rj[] = {32,4,16388,18720,16384};&#xA;int gj[] = {16,2,8194,9360,8192};&#xA;int bj[] = {8,1,4097,4680,4096};&#xA;int rk[] = {18724,256,2080,16388,0};&#xA;int gk[] = {9362,128,1040,8194,0};&#xA;int bk[] = {4681,64,520,4097,0};&#xA;int rl[] = {18724,4,4,4,0};&#xA;int gm[] = {9362,2,2,2,0};&#xA;int bm[] = {4681,1,1,1,0};&#xA;int rm[] = {18724,2304,36,2304,18724};&#xA;int gm[] = {9362,1152,18,1152,9362};&#xA;int bm[] = {4681,576,9,576,4681};&#xA;int rn[] = {18724,2304,36,18724,0};&#xA;int gn[] = {9362,1152,18,9362,0};&#xA;int bn[] = {4681,576,9,4681,0};&#xA;int ro[] = {2336,16388,16388,2336,0};&#xA;int go[] = {1168,8194,8194,1168,0};&#xA;int bo[] = {584,4097,4097,584,0};&#xA;int rp[] = {18724,16640,16640,2048,0};&#xA;int gp[] = {9362,8320,8320,1024,0};&#xA;int bp[] = {4681,4160,4160,512,0};&#xA;int rq[] = {2336,16388,16420,2336,36};&#xA;int gq[] = {1168,8194,8210,1168,18};&#xA;int bq[] = {584,4097,4105,584,9};&#xA;int rr[] = {18724,16640,16672,2052,0};&#xA;int gr[] = {9362,8320,8336,1026,0};&#xA;int br[] = {4681,4160,4168,513,0};&#xA;int rs[] = {2048,16644,16644,32,0};&#xA;int gs[] = {1024,8322,8322,16,0};&#xA;int bs[] = {512,4161,4161,8,0};&#xA;int rt[] = {16384,16384,18724,16384,16384};&#xA;int gt[] = {8192,8192,9362,8192,8192};&#xA;int bt[] = {4096,4096,4681,4096,4096};&#xA;int ru[] = {18720,4,4,18720,0};&#xA;int gu[] = {9360,2,2,9360,0};&#xA;int bu[] = {4680,1,1,4680,0};&#xA;int rv[] = {18432,288,4,288,18432};&#xA;int gv[] = {9216,144,2,144,9216};&#xA;int bv[] = {4608,72,1,72,4608};&#xA;int rw[] = {18688,36,2304,36,18688};&#xA;int gw[] = {9344,18,1152,18,9344};&#xA;int bw[] = {4672,9,576,9,4672};&#xA;int rx[] = {16388,2080,256,2080,16388};&#xA;int gx[] = {8194,1040,128,1040,8194};&#xA;int bx[] = {4097,520,64,520,4097};&#xA;int ry[] = {16388,2080,256,2048,16384};&#xA;int gy[] = {8194,1040,128,1024,8192};&#xA;int by[] = {4097,520,64,512,4096};&#xA;int rz[] = {16420,16644,16644,18436,0};&#xA;int gz[] = {8210,8322,8322,9218,0};&#xA;int bz[] = {4105,4161,4161,4609,0};&#xA;int reos[] = {0,4,0,0,0};&#xA;int geos[] = {0,2,0,0,0};&#xA;int beos[] = {0,1,0,0,0};&#xA;int rque[] = {2048,16420,16640,2048,0};&#xA;int gque[] = {1024,8210,8320,1024,0};&#xA;int bque[] = {512,4105,4160,512,0};&#xA;int rexcl[] = {0,18692,0,0,0};&#xA;int gexcl[] = {0,9346,0,0,0};&#xA;int bexcl[] = {0,4673,0,0,0};&#xA;&#xA;void displayLine(int line)&#xA;{&#xA;  int myline; myline = line;&#xA;  if (myline&amp;gt;=16384) {digitalWrite(rled1, HIGH); myline-=16384;} else {digitalWrite(rled1, LOW);}&#xA;  if (myline&amp;gt;=8192) {digitalWrite(gled1, HIGH); myline-=8192;} else {digitalWrite(gled1, LOW);}&#xA;  if (myline&amp;gt;=4096) {digitalWrite(bled1, HIGH); myline-=4096;} else {digitalWrite(bled1, LOW);}&#xA;  if (myline&amp;gt;=2048) {digitalWrite(rled2, HIGH); myline-=2048;} else {digitalWrite(rled2, LOW);}&#xA;  if (myline&amp;gt;=1024) {digitalWrite(gled2, HIGH); myline-=1024;} else {digitalWrite(gled2, LOW);}&#xA;  if (myline&amp;gt;=512) {digitalWrite(bled2, HIGH); myline-=512;} else {digitalWrite(bled2, LOW);}&#xA;  if (myline&amp;gt;=256) {digitalWrite(rled3, HIGH); myline-=256;} else {digitalWrite(rled3, LOW);}&#xA;  if (myline&amp;gt;=128) {digitalWrite(gled3, HIGH); myline-=128;} else {digitalWrite(gled3, LOW);}&#xA;  if (myline&amp;gt;=64) {digitalWrite(bled3, HIGH); myline-=64;} else {digitalWrite(bled3, LOW);}&#xA;  if (myline&amp;gt;=32) {digitalWrite(rled4, HIGH); myline-=32;} else {digitalWrite(rled4, LOW);}&#xA;  if (myline&amp;gt;=16) {digitalWrite(gled4, HIGH); myline-=16;} else {digitalWrite(gled4, LOW);}&#xA;  if (myline&amp;gt;=8) {digitalWrite(bled4, HIGH); myline-=8;} else {digitalWrite(bled4, LOW);}&#xA;  if (myline&amp;gt;=4) {digitalWrite(rled5, HIGH); myline-=4;} else {digitalWrite(rled5, LOW);}&#xA;  if (myline&amp;gt;=2) {digitalWrite(gled5, HIGH); myline-=2;} else {digitalWrite(gled5, LOW);}&#xA;  if (myline&amp;gt;=1) {digitalWrite(bled5, HIGH); myline-=1;} else {digitalWrite(bled5, LOW);}&#xA;&#xA;}&#xA;&#xA;void displayChar(char c)&#xA;{&#xA;  if (c == 'ra'){for (int i = 0; i &amp;lt;5; i++){displayLine(ra[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rb'){for (int i = 0; i &amp;lt;5; i++){displayLine(rb[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rc'){for (int i = 0; i &amp;lt;5; i++){displayLine(rc2[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rd'){for (int i = 0; i &amp;lt;5; i++){displayLine(rd[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 're'){for (int i = 0; i &amp;lt;5; i++){displayLine(re[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rf'){for (int i = 0; i &amp;lt;5; i++){displayLine(rf[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rg'){for (int i = 0; i &amp;lt;5; i++){displayLine(rg[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rh'){for (int i = 0; i &amp;lt;5; i++){displayLine(rh[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ri'){for (int it = 0; it &amp;lt;5; it++){displayLine(ri[it]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rj'){for (int i = 0; i &amp;lt;5; i++){displayLine(rj[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rk'){for (int i = 0; i &amp;lt;5; i++){displayLine(rk[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rl'){for (int i = 0; i &amp;lt;5; i++){displayLine(rl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rm'){for (int i = 0; i &amp;lt;5; i++){displayLine(rm[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rn'){for (int i = 0; i &amp;lt;5; i++){displayLine(rn[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ro'){for (int i = 0; i &amp;lt;5; i++){displayLine(ro[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rp'){for (int i = 0; i &amp;lt;5; i++){displayLine(rp[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rq'){for (int i = 0; i &amp;lt;5; i++){displayLine(rq[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rr'){for (int i = 0; i &amp;lt;5; i++){displayLine(rr[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rs'){for (int i = 0; i &amp;lt;5; i++){displayLine(rs[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rt'){for (int i = 0; i &amp;lt;5; i++){displayLine(rt[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ru'){for (int i = 0; i &amp;lt;5; i++){displayLine(ru[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rv'){for (int i = 0; i &amp;lt;5; i++){displayLine(rv[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rw'){for (int i = 0; i &amp;lt;5; i++){displayLine(rw[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rx'){for (int i = 0; i &amp;lt;5; i++){displayLine(rx[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ry'){for (int i = 0; i &amp;lt;5; i++){displayLine(ry[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'rz'){for (int i = 0; i &amp;lt;5; i++){displayLine(rz[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'r!'){for (int i = 0; i &amp;lt;5; i++){displayLine(rexcl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'r?'){for (int i = 0; i &amp;lt;5; i++){displayLine(rques[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'r.'){for (int i = 0; i &amp;lt;5; i++){displayLine(reos[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ga'){for (int i = 0; i &amp;lt;5; i++){displayLine(ga[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gb'){for (int i = 0; i &amp;lt;5; i++){displayLine(gb[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gc'){for (int i = 0; i &amp;lt;5; i++){displayLine(gc2[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gd'){for (int i = 0; i &amp;lt;5; i++){displayLine(gd[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ge'){for (int i = 0; i &amp;lt;5; i++){displayLine(ge[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gf'){for (int i = 0; i &amp;lt;5; i++){displayLine(gf[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gg'){for (int i = 0; i &amp;lt;5; i++){displayLine(gg[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gh'){for (int i = 0; i &amp;lt;5; i++){displayLine(gh[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gi'){for (int it = 0; it &amp;lt;5; it++){displayLine(gi[it]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gj'){for (int i = 0; i &amp;lt;5; i++){displayLine(gj[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gk'){for (int i = 0; i &amp;lt;5; i++){displayLine(gk[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gl'){for (int i = 0; i &amp;lt;5; i++){displayLine(gl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gm'){for (int i = 0; i &amp;lt;5; i++){displayLine(gm[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gn'){for (int i = 0; i &amp;lt;5; i++){displayLine(gn[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'go'){for (int i = 0; i &amp;lt;5; i++){displayLine(go[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gp'){for (int i = 0; i &amp;lt;5; i++){displayLine(gp[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gq'){for (int i = 0; i &amp;lt;5; i++){displayLine(gq[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gr'){for (int i = 0; i &amp;lt;5; i++){displayLine(gr[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gs'){for (int i = 0; i &amp;lt;5; i++){displayLine(gs[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gt'){for (int i = 0; i &amp;lt;5; i++){displayLine(gt[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gu'){for (int i = 0; i &amp;lt;5; i++){displayLine(gu[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gv'){for (int i = 0; i &amp;lt;5; i++){displayLine(gv[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gw'){for (int i = 0; i &amp;lt;5; i++){displayLine(gw[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gx'){for (int i = 0; i &amp;lt;5; i++){displayLine(gx[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gy'){for (int i = 0; i &amp;lt;5; i++){displayLine(gy[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'gz'){for (int i = 0; i &amp;lt;5; i++){displayLine(gz[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'g!'){for (int i = 0; i &amp;lt;5; i++){displayLine(gexcl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'g?'){for (int i = 0; i &amp;lt;5; i++){displayLine(gques[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'g.'){for (int i = 0; i &amp;lt;5; i++){displayLine(geos[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'ba'){for (int i = 0; i &amp;lt;5; i++){displayLine(ba[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bb'){for (int i = 0; i &amp;lt;5; i++){displayLine(bb[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bc'){for (int i = 0; i &amp;lt;5; i++){displayLine(bc2[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bd'){for (int i = 0; i &amp;lt;5; i++){displayLine(bd[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'be'){for (int i = 0; i &amp;lt;5; i++){displayLine(be[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bf'){for (int i = 0; i &amp;lt;5; i++){displayLine(bf[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bg'){for (int i = 0; i &amp;lt;5; i++){displayLine(bg[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bh'){for (int i = 0; i &amp;lt;5; i++){displayLine(bh[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bi'){for (int it = 0; it &amp;lt;5; it++){displayLine(bi[it]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bj'){for (int i = 0; i &amp;lt;5; i++){displayLine(bj[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bk'){for (int i = 0; i &amp;lt;5; i++){displayLine(bk[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bl'){for (int i = 0; i &amp;lt;5; i++){displayLine(bl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bm'){for (int i = 0; i &amp;lt;5; i++){displayLine(bm[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bn'){for (int i = 0; i &amp;lt;5; i++){displayLine(bn[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bo'){for (int i = 0; i &amp;lt;5; i++){displayLine(bo[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bp'){for (int i = 0; i &amp;lt;5; i++){displayLine(bp[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bq'){for (int i = 0; i &amp;lt;5; i++){displayLine(bq[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'br'){for (int i = 0; i &amp;lt;5; i++){displayLine(br[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bs'){for (int i = 0; i &amp;lt;5; i++){displayLine(bs[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bt'){for (int i = 0; i &amp;lt;5; i++){displayLine(bt[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bu'){for (int i = 0; i &amp;lt;5; i++){displayLine(bu[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bv'){for (int i = 0; i &amp;lt;5; i++){displayLine(bv[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bw'){for (int i = 0; i &amp;lt;5; i++){displayLine(bw[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bx'){for (int i = 0; i &amp;lt;5; i++){displayLine(bx[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'by'){for (int i = 0; i &amp;lt;5; i++){displayLine(by[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'bz'){for (int i = 0; i &amp;lt;5; i++){displayLine(bz[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'b!'){for (int i = 0; i &amp;lt;5; i++){displayLine(bexcl[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'b?'){for (int i = 0; i &amp;lt;5; i++){displayLine(bques[i]);delay(delayTime);}displayLine(0);}&#xA;  if (c == 'b.'){for (int i = 0; i &amp;lt;5; i++){displayLine(beos[i]);delay(delayTime);}displayLine(0);}&#xA;  delay(charBreak);&#xA;}&#xA;&#xA;void displayString(char* s)&#xA;{&#xA;  for (int i = 0; i&amp;lt;=strlen(s); i++)&#xA;  {&#xA;  displayChar(s[i]);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  displayString(&quot;sunil&quot;);&#xA;  Serial.print(&quot;freeMemory()=&quot;);&#xA;    Serial.println(freeMemory());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am getting the following error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_jul17b:63: error: redefinition of 'int gm []'&#xA;sketch_jul17b:60: error: 'int gm [5]' previously defined here&#xA;sketch_jul17b:64: error: redefinition of 'int bm []'&#xA;sketch_jul17b:61: error: 'int bm [5]' previously defined here&#xA;sketch_jul17b.ino: In function 'void displayChar(char)':&#xA;sketch_jul17b:139: error: 'rc2' was not declared in this scope&#xA;sketch_jul17b:164: error: 'rques' was not declared in this scope&#xA;sketch_jul17b:168: error: 'gc2' was not declared in this scope&#xA;sketch_jul17b:177: error: 'gl' was not declared in this scope&#xA;sketch_jul17b:193: error: 'gques' was not declared in this scope&#xA;sketch_jul17b:197: error: 'bc2' was not declared in this scope&#xA;sketch_jul17b:206: error: 'bl' was not declared in this scope&#xA;sketch_jul17b:222: error: 'bques' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know why this error is occurring.&lt;/p&gt;&#xA;" OwnerUserId="3197" LastActivityDate="2018-10-17T08:07:37.180" Title="error: redefinition of ' '" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3332" PostTypeId="2" ParentId="3331" CreationDate="2014-07-16T19:42:26.617" Score="2" Body="&lt;p&gt;You have a combination of trying to define the same name twice, for example &quot;gm&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int gm[] = {9362,2,2,2,0};&#xA;int bm[] = {4681,1,1,1,0};&#xA;int rm[] = {18724,2304,36,2304,18724};&#xA;int gm[] = {9362,1152,18,1152,9362};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And using others such &quot;rc2&quot; which you have never defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code won't compile and work until you make it self-consistent.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-07-16T19:42:26.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3333" PostTypeId="2" ParentId="3331" CreationDate="2014-07-16T20:11:56.887" Score="3" Body="&lt;p&gt;The first errors happen because you are trying to define a variable with the same name in the same scope twice, like here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int gm[] = {9362,2,2,2,0};&#xA;int bm[] = {4681,1,1,1,0};&#xA;int rm[] = {18724,2304,36,2304,18724};&#xA;int gm[] = {9362,1152,18,1152,9362};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gm is defined two times which is not allowed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other error happens because you are referencing variables you never declared like here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (c == 'rc'){for (int i = 0; i &amp;lt;5; i++){displayLine(rc2[i]);delay(delayTime);}displayLine(0);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;rc2 isn't defined anywhere.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Besides there are some other issues with your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int charBreak = 2.1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int&lt;/code&gt; types can only contain whole numbers, so &lt;code&gt;charBreak&lt;/code&gt; will be set to two and not two point one. You probably wan't to use a &lt;code&gt;float&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;void displayChar(char c)&lt;/code&gt; you try to compare a char with two chars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (c == 'ra')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That won't work. The char type can only contain a single character, so the comparison will always be false. Two chars like this &lt;code&gt;'ab'&lt;/code&gt; in single quotes are interpreted as 16 bit number. Two chars in double quotes are interpreted as a null-terminated string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char cstring1[] = &quot;ab&quot;;&#xA;char cstring2[] = {'a', 'b', '\0'};&#xA;&#xA;if (strcmp(cstring1, cstring2) == 0)&#xA;  // The two strings are identical&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;strcmp&lt;/code&gt; returns 0 on match-.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-16T20:11:56.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3335" PostTypeId="1" AcceptedAnswerId="3338" CreationDate="2014-07-16T20:49:50.157" Score="4" ViewCount="2695" Body="&lt;p&gt;I've recently ordered an Arduino Yun and several other components to begin on a small robotics project (based on an old 4x4 RC Truck).  Although not mandatory for what I'd like to do, I was wondering how feasible it would be to mount a small camera or two and write some software for the Linux portion of the Yun to do basic image/video analysis such as face detection and computer vision based path finding?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly this is a question about the processing power capabilities of the Yun.  Has anyone had any luck doing simple image analysis/recognition on this processor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also, if anyone with 150+ rep could edit this to create and add the &quot;computer-vision&quot; tag that would be great)&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="2967" LastEditDate="2014-07-17T11:20:27.157" LastActivityDate="2015-08-26T15:16:22.143" Title="How useful could the Arduino Yun be in computer vision in a robotics project?" Tags="|arduino-yun|robotics|signal-processing|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3336" PostTypeId="2" ParentId="3316" CreationDate="2014-07-16T23:05:47.860" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Check if you have selected the right board  &lt;/li&gt;&#xA;&lt;li&gt;Have you installed FTDI drivers? If you have installed them update them to the latest version. They can be found &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (Also see &lt;a href=&quot;http://arduino.cc/en/Guide/Howto&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/Howto&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work check if the device is getting recognized by the system by running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dmesg | grep -i tty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the device is not recognized then try using a different cable/USB port.&lt;br&gt;&#xA;Just to make sure, check if the board is working properly by testing it on another computer.&lt;/p&gt;&#xA;" OwnerUserId="3191" LastEditorUserId="220" LastEditDate="2015-07-15T14:09:46.827" LastActivityDate="2015-07-15T14:09:46.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3337" PostTypeId="1" CreationDate="2014-07-16T23:52:30.100" Score="2" ViewCount="3917" Body="&lt;p&gt;Today I got Arduino Leonardo to replace my Uno. I've tried running one of sketches I use on the Uno, but with no luck. When I start the upload, RX LED on the Leonardo flashes few times, and after several seconds, L LED pulsates and I get this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\COM9&quot;: The system cannot find the file specified.&#xA;&#xA;avrdude: ser_send(): write error: sorry no info avail&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've checked in &lt;em&gt;Device Manager&lt;/em&gt;, where it says that Arduino Leonardo is on COM3, and COM3 is also set in Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I change COM port to 9 in &lt;em&gt;Device Manager&lt;/em&gt; and also in Arduino IDE and then try to upload the sketch, things start to roll out like above, but this time IDE freezes for 5-10 mins on &quot;Uploading...&quot; part, and finally unfreezes with this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Found programmer: Id = &quot;B¨J&quot;; type = &#xA;    Software Version = &#xA;avrdude: error: buffered memory access not supported. Maybe it isn't&#xA;a butterfly/AVR109 but a AVR910 device?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Several more infos:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- OS: Win7 64-bit&#xA;- Arduino IDE: 1.0.5-r2&#xA;- Other serial devices: Only Bluetooth that I've manually assigned to COM200, to avoid possible conflicts.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3199" LastActivityDate="2020-08-04T06:23:51.277" Title="Problem loading sketch to Leonardo" Tags="|serial|uploading|bootloader|arduino-leonardo|avrdude|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3338" PostTypeId="2" ParentId="3335" CreationDate="2014-07-17T00:07:48.103" Score="3" Body="&lt;p&gt;It probably has enough memory and speed to run &lt;a href=&quot;http://opencv.org/&quot; rel=&quot;nofollow&quot;&gt;basic object recognition software&lt;/a&gt;, but I there's a better solution, and that's to do your image capture and your object recognition with another device, and use the Arduino to act on the incoming data in some way. That would give you enough juice to do object tracking or searching. I plan to do this for my copter gimbal hopefully to be able to track objects on the ground, like criminals running from the cops for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This product will work great for that. Since you need a camera anyway, I think this is a pretty good deal... &lt;a href=&quot;http://petapixel.com/2013/09/01/pixy-low-cost-camera-recognizes-follows-objects-color/&quot; rel=&quot;nofollow&quot;&gt;http://petapixel.com/2013/09/01/pixy-low-cost-camera-recognizes-follows-objects-color/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can be purchased here: &lt;a href=&quot;http://www.adafruit.com/products/1906&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/1906&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AdaFruit has tutorials to help you get started.  (Computer-vision doesn't exist as a tag right now and I can't create it, but I tried, sorry)&lt;/p&gt;&#xA;" OwnerUserId="228" LastActivityDate="2014-07-17T00:07:48.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3339" PostTypeId="2" ParentId="3335" CreationDate="2014-07-17T03:05:27.713" Score="0" Body="&lt;p&gt;I am guessing not very useful. Image recognition is quite CPU-intensive, and Arduinos are slow, memory-starved, 8-bit processors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Unix side of the Yun runs at 400 MHz, which is quite a bit faster than the Arduino part, but still quite slow compared to a mobile phone or desktop computer. And 64MB of RAM isn't enough to hold even a single HD image, never mind the data you would need to have in RAM to do image analysis. You'd probably have to limit yourself to 640x480, and the slow processor and lack of enough flash for large code libraries would be a problem. (You've only got 16 MB of flash memory on the LINUX processor.) I don't know if you can run programs from an SD card or not. That might solve your code storage problems, but you're still going to struggle with 64 MB of RAM.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-17T03:05:27.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3341" PostTypeId="1" AcceptedAnswerId="3342" CreationDate="2014-07-17T13:48:15.237" Score="5" ViewCount="300" Body="&lt;p&gt;The arduino has a USB port which can connect to a computer.  The cable used to make this connection has a standard USB connector at one end (that connects to the computer) and a &quot;larger&quot; connector on the opposite end (that connects to the arduino).  See picture below:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cDAFp.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the name of this &quot;larger&quot; connector?  &lt;/p&gt;&#xA;" OwnerUserId="667" LastEditorUserId="612" LastEditDate="2014-07-17T16:50:08.860" LastActivityDate="2014-07-17T17:36:37.757" Title="USB cable connector" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3342" PostTypeId="2" ParentId="3341" CreationDate="2014-07-17T14:00:09.970" Score="3" Body="&lt;p&gt;They are both standard USB. The end which goes into the computer is type A (or USB-A), and the end which goes into the Arduino is type B (or USB-B). The USB-B connector is also commonly used on devices such as printers and scanners. The distinction mainly exists so it's obvious which device is the host (i.e. the computer) and which device is the client (i.e. the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, other types of USB connector exist as well. You will probably be familiar with mini and micro USB connectors, which can be found on various devices such as digital cameras and mobile phones.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-07-17T17:36:37.757" LastActivityDate="2014-07-17T17:36:37.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3343" PostTypeId="2" ParentId="3097" CreationDate="2014-07-17T14:44:39.887" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I was wondering if it's possible to get signal strength from the module&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it doesn't appear so from the data sheet / AT command list.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also the HC-05, can initiate connection if I'm understanding documentation right, and return available devices in the area? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, and it can get the signal strengths.  You should be able to get an HC-05 module on a breakout board from Ebay for less than $10 delivered.  There's also a method to update the HC-06 firmware to be an HC-05 but it's probably easier for you to buy one.&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-07-17T14:44:39.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3344" PostTypeId="2" ParentId="1" CreationDate="2014-07-17T15:08:02.040" Score="9" Body="&lt;p&gt;We've been running our Arduino-based RFID access system at Bloominglabs Hackerspace in Bloomington IN since late 2011 and aside from a couple power outages and software updates it runs around the clock, no problem. More recently we added a networked thermostat, same deal - it's running round the clock.&lt;/p&gt;&#xA;" OwnerUserId="3004" LastActivityDate="2014-07-17T15:08:02.040" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3345" PostTypeId="1" AcceptedAnswerId="3347" CreationDate="2014-07-17T18:16:53.837" Score="5" ViewCount="2341" Body="&lt;p&gt;I upgraded to Arduino 1.5.7 in hopes of using the command line interface for a larger project. However, the old package I was using to program the ATTiny85 chip with the Sparkfun Tiny AVR Programmer no longer works. I'm getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer.&#xA;processing.app.debug.RunnerException&#xA;    at processing.app.debug.Compiler.getCommandCompilerCPP(Compiler.java:597)&#xA;    at processing.app.debug.Compiler.compileFiles(Compiler.java:275)&#xA;    at processing.app.debug.Compiler.compileSketch(Compiler.java:642)&#xA;    at processing.app.debug.Compiler.compile(Compiler.java:125)&#xA;    at processing.app.Sketch.build(Sketch.java:1589)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1611)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1597)&#xA;    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2397)&#xA;    at java.lang.Thread.run(Unknown Source)&#xA;Caused by: java.lang.NullPointerException&#xA;    at processing.app.helpers.StringReplacer.replaceFromMapping(StringReplacer.java:97)&#xA;    at processing.app.helpers.StringReplacer.replaceFromMapping(StringReplacer.java:89)&#xA;    at processing.app.helpers.StringReplacer.formatAndSplit(StringReplacer.java:37)&#xA;    at processing.app.debug.Compiler.getCommandCompilerCPP(Compiler.java:595)&#xA;    ... 8 more&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does a package exist that will allow me to program the chip in 1.5.7?&lt;/p&gt;&#xA;" OwnerUserId="3212" LastEditorUserId="11" LastEditDate="2014-07-17T20:36:59.110" LastActivityDate="2014-08-11T06:50:13.993" Title="Is programming the ATTiny85 possible in 1.5?" Tags="|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3347" PostTypeId="2" ParentId="3345" CreationDate="2014-07-17T19:34:17.330" Score="7" Body="&lt;p&gt;You can download a version of arduino-tiny for IDE 1.5.x from &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2014-08-11T06:50:13.993" LastActivityDate="2014-08-11T06:50:13.993" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3348" PostTypeId="1" CreationDate="2014-07-18T10:05:35.250" Score="3" ViewCount="1873" Body="&lt;p&gt;I had fun making a 3x3x3 led cube. Now I want to build a bigger one. I'd like to find out the best IC for it. I've seen that some projects uses multiplexer like 4051 or 74HC595.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to make it at least 8x8x8 (so the multiplexer has to easily be spotted in cascade), possibly supporting also the pwm (to fade the leds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I'm a little bit scared by the real time with a lot of LED.. do I have to solve the problem in hardware (with a &quot;faster&quot; multiplexer) o via software?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-07-21T13:06:20.100" Title="Best multiplexer for a led cube" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3349" PostTypeId="2" ParentId="3348" CreationDate="2014-07-18T12:20:37.400" Score="4" Body="&lt;p&gt;Those aren't multiplexing chips. Those are just chips to give you more outputs than your arduino has. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The multiplexing is just done on the microcontroller. But it depends on how you are wiring the leds. You can wire the cube to use less digital outputs, but you'll end up with a less bright leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use no multiplexing. That way the leds are lid with a 100% duty cycle. But for that you'd need 512 outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can choose to light up only one level at a time. That way you only need 72 outputs (64 for the leds, and 8 for selecting the level). This is a form of multiplexing. Since only one level is lid at a time, the leds have a duty cycle of 12.5%. Please note that because of the way humans perceive light, it will look more like 1/3rd the brightness, instead of 1/8th (so that's great). Also note that since you only need one level to be on at a time, some people prefer to use a decade counter IC for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also choose to only light one row at a time. That way you only need 24 outputs (8 for the leds, 8 to select which row, 8 to select which level). But you'd need some additional circuitry to combine row- and level-selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are specialized multiplexing IC, but those only support rows and colums (not level). So you need 1 chip for each level, and more problematically you need to run 8-row and 8-culumn wires for each level to the bottom. That's quite a bit of wire, which might ruin the aesthetics of the cube.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short. There are quite a few ways of making a 8x8x8 cube. I'd suggest finding a well documented build from someone else that you like and follow that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite a bit of information. I hope it's of help. If you have any more question feel free to ask.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-18T12:20:37.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3350" PostTypeId="1" CreationDate="2014-07-18T14:34:32.980" Score="0" ViewCount="322" Body="&lt;p&gt;Is there any free/open or commercial/paid Arduino IDE Sketch Debugger (not Atmel chip factory standard tool set) with Breakpoint and Variable read/set capability? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about VM on web. Is there any similar product? &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2016-02-26T16:50:01.263" Title="Debugger with Breakpoint and Variable read/set capability" Tags="|variables|ide|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3351" PostTypeId="1" AcceptedAnswerId="3352" CreationDate="2014-07-18T14:36:56.677" Score="1" ViewCount="3184" Body="&lt;p&gt;I have a raspberryPi and Arduino connected via i2C. On the RPi I have a python script that takes int values and simply sends them to the RPi, which in turn echoes them back. I am trying to debug this, since I am unable to send ints larger than 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thought was that I might be able to connect the arduino slave directly to my Mac, and then use the Arduino serial monitor to help with debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the python script will not run, because I assume i2C can only be run on a Linux kernel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I mistaken?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an edited portion of my python code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import smbus&#xA;import time&#xA;# for RPI version 1, use &quot;bus = smbus.SMBus(0)&quot;&#xA;bus = smbus.SMBus(1)&#xA;&#xA;# This is the address we setup in the Arduino Program&#xA;address = 0x04&#xA;&#xA;def writeNumber(value):&#xA;    bus.write_byte(address, value)&#xA;    return -1&#xA;&#xA;def readNumber():&#xA;    number = bus.read_byte(address)&#xA;    return number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="765" LastEditorUserId="765" LastEditDate="2014-07-21T15:30:07.037" LastActivityDate="2014-07-21T15:30:07.037" Title="Debugging i2C from Mac OSX desktop" Tags="|serial|python|debugging|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3352" PostTypeId="2" ParentId="3351" CreationDate="2014-07-18T16:14:52.967" Score="0" Body="&lt;p&gt;No, your Mac doesn't have I2C support. It was pointed out &lt;a href=&quot;https://arduino.stackexchange.com/questions/3351/debugging-i2c-from-mac-osx-desktop#comment6515_3351&quot;&gt;in the comments&lt;/a&gt; that there might be some legacy port, but it won't be usable due to driver limitations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're getting a few things confused. USB is it's own technology, separate from I2C/UART/SPI. I'm not sure how you would even &lt;em&gt;wire&lt;/em&gt; I2C to your Mac. The serial monitor in Arduino is for USB COM ports, not related to I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as debugging, there's a few options. First of all, &lt;a href=&quot;https://electronics.stackexchange.com/questions/49752/debugging-i2c-bus-using-aCn-oscilloscope&quot;&gt;there are a few ways to debug I2C using an oscilloscope&lt;/a&gt;. If that's too expensive, you could also get away with a &lt;a href=&quot;https://www.sparkfun.com/products/8938&quot; rel=&quot;nofollow noreferrer&quot;&gt;logic analyzer&lt;/a&gt;. The one I just linked was at Sparkfun for $150. If that's still too expensive and you're willing to risk $30, &lt;a href=&quot;http://www.ebay.com/itm/2-in-1-USB-Blaster-amp-Logic-Analyzer-UART-SPI-I2C-EPM240-CPLD-Cyclone-IV-FPGA-MCU-/231036000665?_trksid=p2054897.l4275&quot; rel=&quot;nofollow noreferrer&quot;&gt;you can find cheap ones on eBay&lt;/a&gt; (most with little/no documenation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know your code, so I can't advise you on how to fix it. If you need to debug at such a low level, extra hardware is needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't seem like a maximum of 255 that odd, since that's the maximum number that you can do with one byte. You might have to split data up into multiple bytes with some sort of delimiter character. With some quick mental math, it seems as two bytes can give you numbers up to 65,535 if you combine both bytes (i.e. &lt;code&gt;10101010&lt;/code&gt; + &lt;code&gt;01010101&lt;/code&gt; = &lt;code&gt;1010101001010101&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: this seems like the Arduino code you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x04&#xA;int number = 0;&#xA;int num1 = 0;&#xA;int num2 = 0;&#xA;int state = 0;&#xA;boolean secondByte = false;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;    Serial.begin(9600);         // start serial for output&#xA;    // initialize i2c as slave&#xA;    Wire.begin(SLAVE_ADDRESS);&#xA;&#xA;    // define callbacks for i2c communication&#xA;    Wire.onReceive(receiveData);&#xA;    Wire.onRequest(sendData);&#xA;&#xA;    Serial.println(&quot;Ready!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(100);&#xA;}&#xA;&#xA;// callback for received data&#xA;void receiveData(int byteCount){&#xA;    while(Wire.available()) {&#xA;        if(secondByte) {&#xA;            num2 = Wire.read();&#xA;            number = (num1 &amp;lt;&amp;lt; 8) + num2;&#xA;&#xA;            Serial.print(&quot;data received: &quot;);&#xA;            Serial.println(number);&#xA;&#xA;            if (number == 1){&#xA;                if (state == 0){&#xA;                    digitalWrite(13, HIGH); // set the LED on&#xA;                    state = 1;&#xA;                }&#xA;                else{&#xA;                    digitalWrite(13, LOW); // set the LED off&#xA;                    state = 0;&#xA;                }&#xA;             }&#xA;         } else {&#xA;             num1 = Wire.read();&#xA;         }&#xA;         secondByte != secondByte;&#xA;    }&#xA;}&#xA;&#xA;// callback for sending data&#xA;void sendData(){&#xA;    Wire.write(num1);&#xA;    Wire.write(num2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Python code will have to do the similar thing. Note: the first part of the number (reading left to right) will be sent first.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-07-18T20:58:29.783" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3353" PostTypeId="1" CreationDate="2014-07-16T20:42:29.760" Score="2" ViewCount="933" Body="&lt;p&gt;I am currently working on a Arduino project that combines an InertiaOne IMU sensor board (from Atmel), with an Arduino UNO and two motors driven by a Makeblock driver board. All sensors communicate using I2C, with different addresses. My issue is that the program runs just fine for a while (everything between 1 second and 2 minutes), but suddenly lock up inside the Wire.requestFrom-function that handles I2C communication. More specifically, I believe that the code hangs at one of these points in the Wire library (the code is a direct copy):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;// wait until twi is ready, become master receiver&#xA;while(TWI_READY != twi_state){&#xA;    continue;&#xA;}&#xA;...&#xA;// wait for read operation to complete&#xA;while(TWI_MRX == twi_state){&#xA;    continue;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I know, there are only two units that utilise I2C in the system, both of which are embedded onto the InertiaOne circuit board. What I find very strange is that reading these two sensors works just fine when no motors are running, but that the problem occurs when the motors are activated. My first reaction was to use separate power supplies for the motors and sensor board since the issue could have been caused by a dip in the voltage and a reset of the sensor board, but without any change of result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running out of things to try, and do simply not have the required understanding of I2C and embedded systems to see what exactly the issue is. Could it simply be that some of my parts are faulty, or am I perhaps overlooking something?&lt;/p&gt;&#xA;" OwnerUserId="3246" OwnerDisplayName="Tormod Haugene" LastEditorUserId="220" LastEditDate="2014-07-18T19:35:47.760" LastActivityDate="2015-07-03T05:23:48.633" Title="Lockup while evaluating Wire.requestFrom function (Arduino)" Tags="|arduino-uno|c++|i2c|robotics|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3354" PostTypeId="1" CreationDate="2014-07-18T21:24:19.190" Score="10" ViewCount="31830" Body="&lt;p&gt;I want my real-time clock to set its time as the time on my PC. However, when I run the following sketch, the real-time clock reports the time as being 32-33 seconds earlier than my PC says the time is. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 RTC;&#xA;&#xA;void setup () {&#xA;  Serial.begin(57600);&#xA;  Wire.begin();&#xA;  RTC.begin();&#xA;&#xA;  if (! RTC.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;// following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;// uncomment it &amp;amp; upload to set the time, date and start run the RTC!&#xA;    RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;}&#xA;&#xA;void loop () {&#xA;  DateTime now = RTC.now();&#xA;  Serial.print(now.year(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.month(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.day(), DEC);&#xA;  Serial.print(' ');&#xA;  Serial.print(now.hour(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.minute(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.second(), DEC);&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried manually setting the time on the RTC, but I end up with the same problem: the RTC is always 32-33 seconds behind what I set it to. The lag happens as soon as I run the sketch. It seems very odd to me that no matter how I try to set the time, I end up with exactly the same error. I can tell the Arduino to report the time as being 33 seconds after what the RTC says it is, but this solution seems kind of sketchy, and I am worried that something is fundamentally wrong with my RTC or the way I am using it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino Uno with an Assembled Data Logging Shield from Adafruit. The data logging shield uses a DS1307 RTC. Has anyone had this problem before, or have any ideas about what could be causing it? Any help would be much appreciated. &lt;/p&gt;&#xA;" OwnerUserId="3113" LastEditorUserId="220" LastEditDate="2014-07-18T22:43:06.433" LastActivityDate="2020-06-26T14:06:50.740" Title="Why is my real time clock getting the wrong time from my PC?" Tags="|arduino-uno|programming|time|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3355" PostTypeId="2" ParentId="3354" CreationDate="2014-07-18T22:02:44.717" Score="17" Body="&lt;p&gt;The &lt;code&gt;__DATE__&lt;/code&gt; and &lt;code&gt;__TIME__&lt;/code&gt; are set when the code is compiling so they will naturally be behind since the code still needs to finish compiling and then be flashed to the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://playground.arduino.cc/code/time&quot;&gt;Arduino Playground&lt;/a&gt; for an example of how to sync it to your computer over serial.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;TimeSerial.pde shows Arduino as a clock without external hardware.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It is synchronized by time messages sent over the serial port.   A&#xA;  companion Processing sketch will automatically provide these messages &#xA;  if it is running and connected to the Arduino serial port.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-07-18T22:02:44.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3356" PostTypeId="2" ParentId="3335" CreationDate="2014-07-18T22:05:03.310" Score="1" Body="&lt;p&gt;Maybe you can consider adding Raspberry Pi board to run OpenCV which is well supported by hundreds of books and tutorials.  See 20 tutorial from initial setting up to running typical functions in &lt;a href=&quot;http://www.stemapks.com/opencv.html&quot; rel=&quot;nofollow&quot;&gt;http://www.stemapks.com/opencv.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;a href=&quot;http://opencv-srf.blogspot.hk/&quot; rel=&quot;nofollow&quot;&gt;http://opencv-srf.blogspot.hk/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, there are many examples / tutorial / book on linking Arduino to RPi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, from web demo, Pixy CMUcam5 seems very good as a semi-ready-made solution. Watch the demo and see if it does what you want. If yes, then, it is easy solution. OpenCV is a library, it can do many tricks but need learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-18T22:05:03.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3357" PostTypeId="1" CreationDate="2014-07-19T03:13:08.957" Score="2" ViewCount="1754" Body="&lt;p&gt;I've just received my Uno today and already I think I may have broken it :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to connect to usb and upload a sketch (the blink). However, I then tried to connect a circuit to do the Hello World LCD example. After trying this a few times, I noticed the LCD chip get very hot...and I had mis-wired it. In any case, after a few more tries, the USB connection to my Arduino UNO stopped working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried swapping the cable, connecting it to another mac and to a windows with no luck. I'm worried I may have shorted the USB bus chip when trying Hello World.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried connecting a 12V DC power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still get the green power light and the amber L light...&#xA;Did I break my Uno?&#xA;How do I troubleshoot this one?&#xA;thanks&lt;/p&gt;&#xA;" OwnerUserId="3225" LastEditorUserId="37" LastEditDate="2014-08-28T22:34:39.863" LastActivityDate="2014-08-29T08:45:19.540" Title="Arduino UNO USB not recognized" Tags="|arduino-uno|serial|atmega328|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3359" PostTypeId="2" ParentId="3337" CreationDate="2014-07-19T11:02:53.617" Score="1" Body="&lt;p&gt;Per &lt;a href=&quot;https://arduino.stackexchange.com/users/497/imjosh&quot;&gt;imjosh&lt;/a&gt;'s suggestion, I've installed IDE version 1.5.7 BETA and that solved my problem.&lt;br&gt;&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3199" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-07-19T11:02:53.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3360" PostTypeId="2" ParentId="3357" CreationDate="2014-07-19T12:12:54.950" Score="2" Body="&lt;p&gt;When the LCD pulled enough current to overheat, the Arduino's power supply (which I gather was the Uno's USB interface, at the time) was probably stressed to the point of failure. One fortunate result is that the Arduino took the hit instead of the computer's USB port that was supplying it. It's not clear which part was involved but here's a discussion on another forum concerning a &lt;a href=&quot;http://embdev.net/topic/331929&quot; rel=&quot;nofollow&quot;&gt;similar failure and replacing the ATMegaxU2&lt;/a&gt; which does USB-interface duty on the Uno (x = 8, if it's a rev 2 Uno, x = 16, if rev 3). It may be possible to replace the failed chip - regulator or USB interface (though with LEDs working, it's probably not the regulator). Otherwise, you can probably still program it with an ISP (In System Programmer). But the easiest way to do that is probably involves another Uno.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-07-19T12:55:27.873" LastActivityDate="2014-07-19T12:55:27.873" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3361" PostTypeId="1" AcceptedAnswerId="3364" CreationDate="2014-07-19T15:19:37.643" Score="6" ViewCount="12142" Body="&lt;p&gt;I bought this thing off of eBay:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/0SNrQ.jpg&quot; alt=&quot;USBtoFT232RL&quot;&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://www.ebay.com/itm/161305918505&quot; rel=&quot;nofollow noreferrer&quot;&gt;eBay Link&lt;/a&gt;&lt;br&gt;&#xA;&lt;br&gt;&#xA;Will it allow me to program an ATmega[xxx] (Arduino clone) with a bootloader?&lt;br&gt;&#xA;&lt;br&gt; --&amp;gt; If so, how would I go about it? What should I do, and what should I certainly not do?&lt;br&gt;&#xA;&lt;br&gt; --&amp;gt; If not, what do I need (or where can I learn) to be able to use an Arduino clone with the Arduino IDE?&lt;br&gt;&#xA;&lt;br&gt;&#xA;I'm a bit new to Arduino, and since I learned that a fair amount of the clones being sold on eBay don't have a bootloader, I wondered how to fix this. (and the &amp;quot;barebones&amp;quot; seem to be quite a bit cheaper)&#xA;&lt;br&gt;&lt;br&gt;&#xA;&lt;hr&gt;&#xA;&lt;br&gt;&#xA;&lt;strong&gt;Answer&lt;/strong&gt; - &lt;em&gt;summarized from different answers below (as I can only mark one answer below as accepted):&lt;/em&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can you use an FT232R to burn a bootloader onto an AVR (such as an ATmega328)?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;=&amp;gt; Yes you can, though it's a bit annoying to do, as it's slow and a bit more complicated than just plug and play. See the first part of &lt;a href=&quot;https://arduino.stackexchange.com/questions/3361/i-bought-usb-ft232rl-can-i-use-it-to-program-a-bootloader-onto-an-arduino#3364&quot;&gt;Chris Stratton's answer&lt;/a&gt; below.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;I already have a working Arduino style board, can I use that?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;=&amp;gt; Yes, you can use for example a UNO-style board to program another. This process is explained here: &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;, which was referenced in the second part of &lt;a href=&quot;https://arduino.stackexchange.com/questions/3361/i-bought-usb-ft232rl-can-i-use-it-to-program-a-bootloader-onto-an-arduino#3364&quot;&gt;Chris Strattons' answer&lt;/a&gt; below.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;The two options above are too much of a hassle for me, or I don't have an Arduino yet/available, is there another option?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;=&amp;gt; Yes, you can buy a USB to ISP (In-System Programmer) board/programmer. They're pretty cheap and are called USBISP or USBASP for example. Here's an example: &lt;a href=&quot;http://www.ebay.com/itm/180980285082&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/180980285082&lt;/a&gt;, referenced at the end of &lt;a href=&quot;https://arduino.stackexchange.com/questions/3361/i-bought-usb-ft232rl-can-i-use-it-to-program-a-bootloader-onto-an-arduino#3363&quot;&gt;MatsK's answer&lt;/a&gt;. (or an even cheaper one: &lt;a href=&quot;http://www.ebay.com/itm/390806886235&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/390806886235&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3241" OwnerDisplayName="DaJF" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-07-21T09:09:40.997" Title="I bought USB &gt; FT232RL, can I use it to program a bootloader onto an Arduino?" Tags="|bootloader|avr|isp|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3362" PostTypeId="2" ParentId="3361" CreationDate="2014-07-19T16:02:52.537" Score="2" Body="&lt;p&gt;You must use a ISP or (HV)PP programmer in order to write the Arduino (or similar) bootloader to the chip first. Only once you have done so will you be able to program it via a serial connection.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-19T16:02:52.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3363" PostTypeId="2" ParentId="3361" CreationDate="2014-07-19T16:50:14.607" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Will it allow me to program an ATmega[xxx] (Arduino clone) with a&#xA;  bootloader?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;NO. The serial device can only be used when the Atmel ATmega chip has a bootloader burned onto it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;--&gt; If so, how would I go about it? What should I do, and what should I certainly not do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To burn a bootloader onto a Atmel AVR chip you need a &quot;AVR ISP (In-System Programmer)&quot;.&#xA;There is a small 2x3 pin contact on your Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE under the menu &quot;Tools&quot;, &quot;Programmer&quot; you will find the different &quot;AVR ISP (In-System Programmer)&quot; that you can use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that some programmer have an 2x5 pin ISP contact and if that is the case you will also need to buy a 2x3 to 2x5 adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref.: &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/Bootloader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;--&gt; If not, what do I need (or where can I learn) to be able to use an Arduino clone with the Arduino IDE?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most Arduino clones bought on ebay have info witch clone of Arduino they are.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm a bit new to Arduino, and since I learned that a fair amount of&#xA;  the clones being sold on eBay don't have a bootloader, I wondered how&#xA;  to fix this. (and the &quot;barebones&quot; seem to be quite a bit cheaper)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Im a bit confused, I have bought ~10 Arduino clones from ebay and all had a bootloader. And they are clones of UNO, Nano, Leonardo and Mini Pro and that is what I uses for settings in my Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interested in witch ebay clones that doesn't have a bootloader, could you post a comment with that info?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a USBASP (example: &lt;a href=&quot;http://goo.gl/kCiMd&quot; rel=&quot;nofollow&quot;&gt;http://goo.gl/kCiMd&lt;/a&gt;) as my external programmer.&lt;/p&gt;&#xA;" OwnerUserId="1576" LastActivityDate="2014-07-19T16:50:14.607" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3364" PostTypeId="2" ParentId="3361" CreationDate="2014-07-19T19:59:13.220" Score="5" Body="&lt;p&gt;In fact, you can, but you are unlikely to enjoy it as it will be fairly slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this module is intended for serial communications - which the ATmega won't support until it has a bootloader on it - the chip around which it is built can also be operated in &quot;bitbang&quot; mode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ftdichip.com/Support/Documents/AppNotes/AN_232R-01_Bit_Bang_Mode_Available_For_FT232R_and_Ft245R.pdf&quot;&gt;http://www.ftdichip.com/Support/Documents/AppNotes/AN_232R-01_Bit_Bang_Mode_Available_For_FT232R_and_Ft245R.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using reconfigured pins of this wired to the ISP pins of your target, and an implementation of the ISP algorithm running on the PC, it will indeed be possible to load a bootloader on to a new ATmega chip.  However, USB is not designed for this type of usage - it is meant to move large blocks of data, rather than to efficiently do sequences of tiny operations.  &lt;strong&gt;The result is that the loading process will be drastically slower than with other methods.&lt;/strong&gt;  You may also spend a fair amount of time tracking down software to do it, or writing your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have an already working Arduino-style board available, you can use that to program your new chip:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-07-19T20:07:05.110" LastActivityDate="2014-07-19T20:07:05.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3366" PostTypeId="1" CreationDate="2014-07-20T12:56:05.233" Score="1" ViewCount="1227" Body="&lt;p&gt;I want to use timer 0 to generate a rectangular signal on OC0A (D11) without the use of Arduino specific functions (that use timers for themselves). When I toggle D11 manually using a loop, I hear a sound in the connected piezo, but with my sample code, I don't hear something:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ALARM_PIN 11&#xA;&#xA;void setup() {&#xA;  digitalWrite(ALARM_PIN, LOW);&#xA;  pinMode(ALARM_PIN, OUTPUT);&#xA;  noInterrupts();&#xA;&#xA;  OCR0A = 60;&#xA;  // Toggle OC0A on compare match&#xA;  TCCR0A = (0 &amp;lt;&amp;lt; COM0A1)&#xA;         | (1 &amp;lt;&amp;lt; COM0A0)&#xA;  // CTC mode&#xA;         | (1 &amp;lt;&amp;lt; WGM01)&#xA;         | (0 &amp;lt;&amp;lt; WGM00);&#xA;  // prescaler = 256&#xA;  TCCR0B = (0 &amp;lt;&amp;lt; WGM02)&#xA;         | (1 &amp;lt;&amp;lt; CS02);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea, what could be wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've played with it a little bit more:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED_PIN 9&#xA;&#xA;void setup() {&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;  TCCR0B = (1 &amp;lt;&amp;lt; CS02);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(LED_PIN, TCNT0 &amp;gt; 250);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This causes my LED to light very dim, so the timer is running up to 255. But as soon as I set TCCR0A, nothing is lighting up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED_PIN 9&#xA;&#xA;void setup() {&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;  OCR0A = 60;&#xA;  TCCR0A = (1 &amp;lt;&amp;lt; WGM01);&#xA;  TCCR0B = (1 &amp;lt;&amp;lt; CS02);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(LED_PIN, TCNT0 &amp;gt; 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2014-07-21T17:05:03.813" LastActivityDate="2014-07-21T17:05:03.813" Title="Leonardo (32u4): Timer0 problems with CTC mode" Tags="|arduino-leonardo|timers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3367" PostTypeId="2" ParentId="3366" CreationDate="2014-07-20T17:14:28.890" Score="2" Body="&lt;p&gt;You should re-enable interrupts after you finish setting up. Use either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;interrupts(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sei();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to don't want to use the arduino specific commands. Even if the code does not need interrupts, background code does use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer 0 is used in arduino for some basic &quot;house keeping&quot; function like keeping time. I'm not sure if that could be part of your problem. you could try using a different timer. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-07-20T18:18:40.767" LastActivityDate="2014-07-20T18:18:40.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3368" PostTypeId="2" ParentId="3366" CreationDate="2014-07-20T18:10:23.700" Score="0" Body="&lt;p&gt;Your value of &lt;code&gt;60&lt;/code&gt; for &lt;code&gt;OCRA&lt;/code&gt; will give you tone of around 16666hz which isn't audible to us humans. Try setting it to 255. That should give you a 4000hz tone, which is audible. (Or get your neighbors dog, and see if he dislikes hearing it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;http://eleccelerator.com/avr-timer-calculator/&quot; rel=&quot;nofollow&quot;&gt;this online calculator&lt;/a&gt; to help you get the correct value for &lt;code&gt;OCRA&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you need 2 cycles to get a full wavelength (1 low and one high), so two toggles.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-20T18:10:23.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3369" PostTypeId="1" CreationDate="2014-07-20T18:13:24.870" Score="8" ViewCount="2240" Body="&lt;p&gt;When the Leonardo was introduced, I think, I've read some articles about being cautious to do some things, that could cause it to not load any new sketches any more, so one has to rewrite the bootloader. Because I plan to use power-saving options, e.g. to disable unused hardware components like USB port, I fear to do something wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One Leonardo-delicacy I've found so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if interrupts are disabled, uploading new sketches fails unless one presses the Reset button as soon as the Arduino IDE is showing &quot;Uploading...&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What stuff (except of the usual hardware-related thinks like connecting output-configured pins to fixed potentials) could damage the controller or require to reflash the Leonardo with a fresh bootloader?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2014-07-22T04:30:35.367" LastActivityDate="2014-08-27T02:32:26.207" Title="Leonardo (32u4): ways to brick it programmatically" Tags="|power|arduino-leonardo|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3370" PostTypeId="2" ParentId="3226" CreationDate="2014-07-20T18:17:33.910" Score="0" Body="&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/s/fce43rxofttl001/Librer%C3%ADas%20UTFT%20%2B%20UTouch%20para%203.5%20TFTLCD%20para%20Arduino%20Mega%202560%20%20-%20copia.rar&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/fce43rxofttl001/Librer%C3%ADas%20UTFT%20%2B%20UTouch%20para%203.5%20TFTLCD%20para%20Arduino%20Mega%202560%20%20-%20copia.rar&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First delete the old UTFT library, then copy and paste the library inside de RAR file.&lt;/p&gt;&#xA;" OwnerUserId="3240" LastEditorUserId="37" LastEditDate="2014-07-20T23:47:36.640" LastActivityDate="2014-07-20T23:47:36.640" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3372" PostTypeId="2" ParentId="791" CreationDate="2014-07-20T20:28:52.693" Score="1" Body="&lt;p&gt;I spent some time getting VirtualWire to work on attiny84. I see two issues with your code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Since the tiny85 only has one timer, that one is being used by both VirtualWire and &lt;code&gt;millis&lt;/code&gt;/&lt;code&gt;micros&lt;/code&gt;. So your delays won't work as expected.&lt;/li&gt;&#xA;&lt;li&gt;VirtualWire uses default values for vw_ptt_pin (10) and vw_rx_pin (11). Those pins don't exist on the attiny85. When &lt;code&gt;vwsetup&lt;/code&gt; calls &lt;code&gt;pinMode&lt;/code&gt; with these values, it causes writes to arbitrary memory addresses. This is likely to make your sketch behave unpredictably. To fix set &lt;code&gt;vw_set_ptt_pin()&lt;/code&gt; and &lt;code&gt;vw_set_rx_pin()&lt;/code&gt; to pins that exist on the tiny85 or modify the VirtualWire source.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="46" LastEditDate="2014-07-21T01:04:53.910" LastActivityDate="2014-07-21T01:04:53.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3374" PostTypeId="2" ParentId="3348" CreationDate="2014-07-21T13:06:20.100" Score="1" Body="&lt;p&gt;You could use a few TLC 5940 PWM Drivers (&lt;a href=&quot;http://www.ti.com/product/tlc5940&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/product/tlc5940&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each one has 16 channels which would mean to power an 8*8*8 cube would need 32 Drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can use multiplexing to reduce the number of 5940's you would need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could use 4 X 5940's which would give you 64 channels and use 8 X time multiplexing to give you 512 channels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 4096 PWM steps giving you lots of control over brightness and can take up to 17v which should be more than enough for any LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the added features for the 5940 is because it is a current sink, you dont need a resistor on every LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working on a project with TLC5940's that requires control over 512 RGB LED's meaning I have  1536 individual channels to control&lt;/p&gt;&#xA;" OwnerUserId="3248" LastActivityDate="2014-07-21T13:06:20.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3377" PostTypeId="1" CreationDate="2014-07-21T19:55:03.023" Score="0" ViewCount="952" Body="&lt;p&gt;I've got an SD card and speaker hooked up to my nano and I can play mono audio files easily. My question is, is it possible to control the speed of a motor using the pwm output to the speaker? I tried just hooking the motor in where the speaker was, but that produced no noticeable variations in speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, is it possible to analyse the wav file on the nano and control the motor that way? (i.e. motor speed is dependant on volume at a given time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks  &lt;/p&gt;&#xA;" OwnerUserId="533" LastActivityDate="2014-07-21T20:22:08.360" Title="Controlling a motor with a wav file" Tags="|motor|pwm|audio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3378" PostTypeId="2" ParentId="3377" CreationDate="2014-07-21T20:09:34.897" Score="2" Body="&lt;p&gt;Regular sound files will have an even amount of time spend energizing the coil positive and negative, so the motor will not spin around in the normal sense. With a strong enough amplifier it will produce the sounds in the file like a speaker, but it will not noticeably turn.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actual PWM varies the percentage of the time the signal is HIGH in a fixed frequency square wave, thus all the different values are the same &quot;pitch&quot;. Audio varies amplitude and frequency, but the cumulative effect of audio waves is neutral, it spends half of the time below neutral and half above neutral voltage. The simplest analogy I can think of is audio being itself, even vibrations in air, and motor PWM being wind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure if it possible to generate a sound file that would turn the motor, it probably depends on the file type. In any case, you would be better off with a far simpler amplifier like a transistor, MOSFET, or H-Bridge on one of your nano's actual PWM pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to whether or not you could analyse the file on arduino, it also depends on file type. The code for the arduino WAV sheild I've seen does not have the arduino actually processing data, but It should be possible with a simple enough file type for arduino to decompress. WAV is not normally compressed, just raw data, so your limits are the RAM and if you can code something to glean volume from the raw data. I don't have much experience in that kind of file processing on AVR so I'm not going to call it either way. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-07-21T20:22:08.360" LastActivityDate="2014-07-21T20:22:08.360" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3380" PostTypeId="1" AcceptedAnswerId="3381" CreationDate="2014-07-21T21:47:13.423" Score="2" ViewCount="100" Body="&lt;p&gt;This is an extremely noobie question, but I have a 5V at 2A power source. This power source is going to be powering 6 Sharp IR distance sensors(20-150cm) and a few other low current consumption sensors(ie Xbee). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is if it is safe to simply use that power source without some sort of resistor between the power source and sensors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also the IR sensors have a analog output. Is that same to plug into the arduino's analog pins?&lt;/p&gt;&#xA;" OwnerUserId="3159" LastActivityDate="2014-07-23T01:29:07.863" Title="Maximum Current?" Tags="|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3381" PostTypeId="2" ParentId="3380" CreationDate="2014-07-21T21:58:14.960" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;also the IR sensors have a analog output. Is that same to plug into the arduino's analog pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the sensors won't generate more than 5V, it should be safe. (Generally, they're all less than 5V. However, verify this...)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is if it is safe to simply use that power source without some sort of resistor between the power source and sensors?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You probably don't need a resistor*. Current is supplied on demand; if you need 1A but have a 2A supply, only 1A will flow. Voltage, however, is constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, some parts will pull more current than they can safely use (like a LED, so &lt;em&gt;then&lt;/em&gt; you would use a resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should all be found on the datasheet (especially with a more trusted brand like Sharp). Just look for example circuits and input voltage/forward voltage. A quick note, make sure to connect the grounds if you're not driving the Arduino directly from the power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;*There probably is an internal resistor for the LED. Again, &lt;strong&gt;datasheets, datasheets, datasheets!&lt;/strong&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-21T21:58:14.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3382" PostTypeId="1" AcceptedAnswerId="16432" CreationDate="2014-07-22T02:29:43.907" Score="1" ViewCount="211" Body="&lt;p&gt;i would like to measure some signals from arduino and send it to a pc using USART and display the results in a c# winform application. Does anyone have such a project example ?&#xA;Besides, i want to send the data in live time mode, each values should be directly transmitted and then the second measurement ( sample rate 100 kHz )&#xA;Thanks a lot &lt;/p&gt;&#xA;" OwnerUserId="1146" LastEditorUserId="490" LastEditDate="2015-10-23T15:58:56.563" LastActivityDate="2015-10-23T15:58:56.563" Title="Arduino Controlling through C#" Tags="|arduino-uno|arduino-leonardo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3384" PostTypeId="1" CreationDate="2014-07-22T04:33:25.727" Score="2" ViewCount="1601" Body="&lt;p&gt;&lt;strong&gt;EDIT: after reading up on some stuff and with the help of the comments people left, I'm certain that it's an overflow issue, but I'm not sure how to solve that...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I just got an Arduino Yun today and have been figuring out how to use it.  I seem to have run into a problem though and haven't been able to solve it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I stripped down the YunSerialTerminal sketch that allows accessing the yun linux terminal over a usb com port:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);      // open serial connection via USB-Serial&#xA;  Serial1.begin(250000);   // open serial connection to Linux&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) {             // got anything from USB-Serial?&#xA;    int c = Serial.read();              // read from USB-serial&#xA;    Serial1.write(c);                   // write to Linux&#xA;  }&#xA;  if (Serial1.available()) {            // got anything from Linux?        &#xA;    int c = Serial1.read();             // read from Linux  &#xA;    Serial.write(c);                    // write to USB-serial&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works for the most part, but has some odd differences from connecting via ssh over wifi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to be dropping random characters from the screen (due to buffer overflow):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vQ5XT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, it's messed up some of the text such as md5um which should be md5sum and the formatting is all off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gets even worse when launching elinks terminal web browser (which works beautifully when connecting via ssh over wifi):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nf3vQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also tried different programs (other than putty), including the arduino ide serial monitor, and they all produce the exact same result (and yes I'm setting them to the correct port speed as well).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea what I'm doing wrong?  I've tried many different port speed combinations and they all produce the same result.  It seems that the atheros-atmel link is set to 250000 baud (Which is why I have to use that speed on Serial1 in my sketch), but can that be changed?  I've read some things about how 250000 is way too fast when the atmel is involved, but is there a way to change that speed without losing the Bridge library functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, could someone else with a yun try this sketch and verify that it works? Load it, and connect with putty via serial (using whatever com port arduino bound to) and double tap tab key to see if the command listing is missing letters.&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="3065" LastEditDate="2014-07-22T17:08:31.920" LastActivityDate="2014-07-22T17:08:31.920" Title="Arduino Yun Serial Terminal Overflow Issues?" Tags="|serial|arduino-yun|terminal|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3385" PostTypeId="2" ParentId="3226" CreationDate="2014-07-22T06:10:44.387" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.henningkarlsen.com/electronics/library.php?id=51&quot; rel=&quot;nofollow&quot;&gt;http://www.henningkarlsen.com/electronics/library.php?id=51&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download hennings new UTFT library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;in myGLCD define R61581 as this is the driver chip for 3.5 display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards!&lt;/p&gt;&#xA;" OwnerUserId="3260" LastActivityDate="2014-07-22T06:10:44.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3387" PostTypeId="1" CreationDate="2014-07-22T16:16:43.707" Score="2" ViewCount="6978" Body="&lt;p&gt;I am using Python &lt;strong&gt;smbus&lt;/strong&gt; &lt;code&gt;write_word_data&lt;/code&gt; method to send int values from a Raspberry Pi to an Arduino using I²C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be the correct method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I send values from 0-255, I see the following in my Arduino serial monitor&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0,0,0&lt;br&gt;&#xA;  0,1,0&lt;br&gt;&#xA;  0,2,0&lt;br&gt;&#xA;  … &lt;br&gt;&#xA;  0,255,0&lt;br&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sending 256 I see:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0,0,1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For 257 I see:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0,1,1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Etc, etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, how would I modify the following Arduino code to properly 'reconstitute' the int values, and then send them back to the RPi?&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x04&#xA;int number = 0;&#xA;int state = 0;&#xA;bool newData = false;&#xA;&#xA;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  // initialize i2c as slave&#xA;  Wire.begin(SLAVE_ADDRESS);&#xA;  // define callbacks for i2c communication&#xA;  Wire.onReceive(receiveData);&#xA;  Wire.onRequest(sendData);&#xA;  Serial.println(&quot;Ready!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(receivedValue);&#xA;  newData=false;&#xA;}&#xA;&#xA;// callback for received data&#xA;void receiveData(int byteCount) {&#xA;  while(Wire.available()) {&#xA;    newData = true;&#xA;    Wire.read();&#xA;    if(Wire.available() == 2) {&#xA;      receivedValue = Wire.read() | Wire.read() &amp;lt;&amp;lt; 8;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;// callback for sending data&#xA;void sendData() {&#xA;  Wire.write(number);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="765" LastEditorUserId="4628" LastEditDate="2017-02-03T04:21:11.090" LastActivityDate="2017-04-04T05:42:11.110" Title="Receiving two-byte int values over serial" Tags="|serial|i2c|python|raspberrypi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3388" PostTypeId="2" ParentId="3387" CreationDate="2014-07-22T17:18:00.830" Score="2" Body="&lt;pre&gt;&lt;code&gt;void receiveData(int byteCount){&#xA;&#xA;  // Looks like your number is sent in a 3 byte packet&#xA;  if (bytecount == 3)&#xA;  {&#xA;&#xA;    // Discard first number as it is seemingly alway zero&#xA;    Wire.read();&#xA;&#xA;    // Read low byte into rxnum&#xA;    int rxnum = Wire.read();&#xA;&#xA;    // Read high byte into rxnum&#xA;    rxnum += Wire.read() &amp;lt;&amp;lt; 8;&#xA;&#xA;    // Send back&#xA;    sendInt(rxnum);&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void sendInt(int num){&#xA;&#xA;  // Uncomment below if you want so send back in same format&#xA;  // Wire.write(0);&#xA;&#xA;  // Send low byte&#xA;  Wire.write((uint8_t)num);&#xA;&#xA;  // Send high byte&#xA;  num &amp;gt;&amp;gt;= 8;&#xA;  Wire.write((uint8_t)num);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-22T17:18:00.830" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3389" PostTypeId="1" CreationDate="2014-07-22T17:31:23.607" Score="3" ViewCount="933" Body="&lt;p&gt;Is it possible to connect the Yun to wifi using 802.1X authentication?  802.1X is WPA2-Enterprise that uses a username and password (per user) instead of one password (for every user).  I don't see a way to do it from the Yun web interface, but is there a way to do it from the linino terminal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, the Atheros AR9331 chip should be capable of this, but I don't see a way to do it with the software included on linino, there must be a way to install something for this?&lt;/p&gt;&#xA;" OwnerUserId="3065" LastEditorUserId="3065" LastEditDate="2015-03-06T16:49:01.610" LastActivityDate="2015-03-06T16:49:01.610" Title="Connecting Arduino Yun to wifi with 802.1X authentication" Tags="|wifi|arduino-yun|linux|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3390" PostTypeId="1" AcceptedAnswerId="3408" CreationDate="2014-07-22T17:42:54.280" Score="2" ViewCount="3805" Body="&lt;p&gt;i am working on a project which requires changing the direction of the DC motor using arduino. that is I want the DC motor to rotate clockwise when i press key 'A' and anti clockwise when i press key 'D' on my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have v+ and v- input wires from battery. i have connected one end of the DC motor to gnd of the battery. On the other end of DC motor i want to connect V+ and V- input from the battery to spin the DC motor in clockwise and anticlockwise respectively. I have used BC547 npn transistor.&#xA;i do not know how to change inputs (v+ to v- and vice-versa) using arduino when key is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is there any method other than H-bridge method to do so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i use arduino uno.&lt;/p&gt;&#xA;" OwnerUserId="3191" LastActivityDate="2014-07-23T17:07:08.387" Title="Changing direction of DC motor" Tags="|arduino-uno|serial|motor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3391" PostTypeId="1" AcceptedAnswerId="3393" CreationDate="2014-07-22T18:48:23.477" Score="0" ViewCount="511" Body="&lt;p&gt;The following code works correctly in reading single int values. It also works correctly for 3-4 seconds if I 'stream' the values in constantly (Mouse move coordinates) before I get an IO error and the i2C bus connection is dropped. I assume this is some sort of buffer overrun...or? Can anyone get me on the right track here? What changes do I need to make so that I can constantly stream in serial data?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x04&#xA;int zeroByte;&#xA;int state = 0;&#xA;int receivedValue = 0;&#xA;&#xA;int numBytes = 0;&#xA;&#xA;bool newData = false;&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;    Serial.begin(9600);         // start serial for output&#xA;    // initialize i2c as slave&#xA;    Wire.begin(SLAVE_ADDRESS);&#xA;&#xA;    // define callbacks for i2c communication&#xA;    Wire.onReceive(receiveData);&#xA;    Wire.onRequest(sendData);&#xA;&#xA;    Serial.println(&quot;Ready!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(100);&#xA;    if(newData){&#xA;&#xA;      Serial.println(receivedValue);&#xA;      newData=false;&#xA;    }&#xA;}&#xA;&#xA;// callback for received data&#xA;void receiveData(int byteCount){&#xA;&#xA;    while(Wire.available()) {&#xA;        newData = true;&#xA;        zeroByte = Wire.read();&#xA;&#xA;         if(Wire.available() == 2)&#xA;  {&#xA;    receivedValue = Wire.read() | Wire.read() &amp;lt;&amp;lt; 8;&#xA;&#xA;&#xA;  }&#xA;&#xA;     }                               &#xA;}&#xA;&#xA;// callback for sending data&#xA;void sendData(){&#xA;&#xA;    Wire.write(receivedValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="765" LastEditorUserId="765" LastEditDate="2014-07-22T21:13:41.230" LastActivityDate="2014-07-22T21:13:41.230" Title="Proxying streaming i2c data(int values) to serial" Tags="|i2c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3392" PostTypeId="2" ParentId="3390" CreationDate="2014-07-22T18:50:39.753" Score="0" Body="&lt;p&gt;L298 IC is very popular way of doing it. IN1 IN2 to control direction, open circuit and breaking (short circuit of motor terminals). EN1 for PWM speed control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ready made module PCB widely available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;useful info&#xA;&lt;a href=&quot;https://www.sparkfun.com/products/9670&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9670&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,84439.0.html&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,84439.0.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-22T18:50:39.753" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3393" PostTypeId="2" ParentId="3391" CreationDate="2014-07-22T20:22:49.360" Score="0" Body="&lt;p&gt;Your I2C bus is operating at 100 kHz. Your serial connection is set to 9600 baud. In case you are sending coordinates at a pace faster than the serial interface can keep up, the buffer will fill up. I assume you are using hardware serial (uno, mega, etc). Once the buffer is filled up Serial.write (which is called by Serial.println) will block until the buffer has free space. But the serial transmission depends on interrupts, and you are calling Serial.write inside an interrupt routine. By defult interrupt routines block other interrupts from happening. So your program gets stuck there and locks up both the serial transmission and the I2C interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be a good idea to put the serial write outside the interrupt routine, in the loop. Make a global variable &lt;code&gt;bool newData = false;&lt;/code&gt; and set it true in the receiveData function. In your loop check the flag and transmit the data. Then set the flag to false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will still experience data loss if the serial interface can't keep up, but your application wont lock up. To solve the data loss simply use a higher baud rate, eg. 115200.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-22T20:22:49.360" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3394" PostTypeId="1" CreationDate="2014-07-22T20:43:10.110" Score="1" ViewCount="365" Body="&lt;p&gt;Currently using i2C to connect a RPi with an arduino. It seems i2C is quite finicky and, drops the bus immediately if there are any IO errors. Since what i am building is meant to be semi permanent, I am worried that i2C may not be the best choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone done any real world testing of i2C vs GPIO for RPi to arduino communication?&lt;/p&gt;&#xA;" OwnerUserId="765" LastActivityDate="2014-10-22T02:50:21.437" Title="Is i2C more or less robust than GPIO?" Tags="|pins|i2c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3395" PostTypeId="2" ParentId="3380" CreationDate="2014-07-23T01:29:07.863" Score="4" Body="&lt;p&gt;A few other points, in addition to Penguin's excellent answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure your 5V supply is a REGULATED supply. Unregulated power supplies will exceed their target voltage when unloaded, and &quot;droop&quot; to lower than their target voltage when under heavy load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite a few digital components can be destroyed if their input voltage varies too much from 5V, especially over-voltage. TTL is especially sensitive to over-voltage (which destroys the circuit) and to malfunctioning on under-voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even a regulated power supply will have some ripple if you switch heavy loads on it. You might want to use separate, isolated supplies for your high power and low power logic systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A higher current regulated supply will be &quot;stiffer&quot; and therefore more stable if run at lower loads.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-23T01:29:07.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3396" PostTypeId="1" CreationDate="2014-07-23T02:20:19.733" Score="1" ViewCount="1128" Body="&lt;p&gt;I'm just beginning to use Processing along side with Arduino and need help linking the two. Just to get started, I just wanted to send a single character (eventually strings) to the Arduino and have the Arduino light up a matrix if the Arduino receives the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code for the Arduino (I'm using an Arduino Uno): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX.h&amp;gt;   // Core graphics library&#xA;#include &amp;lt;RGBmatrixPanel.h&amp;gt; // Hardware-specific library&#xA;&#xA;// Set up the matrix&#xA;#define CLK 8 &#xA;#define LAT A3&#xA;#define OE  9&#xA;#define A   A0&#xA;#define B   A1&#xA;#define C   A2&#xA;RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);&#xA;&#xA;int incomingByte = 0;   // for incoming serial data&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps&#xA;  matrix.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;    if(Serial.available() &amp;gt; 0) {&#xA;    incomingByte = Serial.read();&#xA;&#xA;    // Print a white &quot;Done!&quot; to the matrix&#xA;    matrix.setCursor(1, 0);&#xA;    matrix.setTextSize(0);&#xA;    matrix.setTextColor(matrix.Color333(7, 7, 7));&#xA;    matrix.print(&quot;Done!&quot;);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's the code for Processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example by Tom Igoe&#xA;&#xA;import processing.serial.*;&#xA;&#xA;// The serial port:&#xA;Serial myPort;&#xA;&#xA;// List all the available serial ports:&#xA;println(Serial.list());&#xA;&#xA;// Open the port you are using at the rate you want:&#xA;myPort = new Serial(this, Serial.list()[1], 9600);&#xA;&#xA;// Send a capital &quot;A&quot; out the serial port&#xA;myPort.write(65);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run the processing sketch and then upload the code to the Arduino, but get nothing. The Arduino is using COM3 and I believe the Processing sketch is too, but that may be where I'm messing up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I open up the serial monitor and send some data to the Arduino that way, then the LED lights up fine, but only when I do it through that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3257" LastEditorUserId="3257" LastEditDate="2014-07-23T17:24:41.420" LastActivityDate="2015-08-19T03:36:50.290" Title="Unable to send data from Processing to Arduino through ports" Tags="|arduino-uno|serial|uploading|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3397" PostTypeId="1" CreationDate="2014-07-23T03:17:28.473" Score="2" ViewCount="2191" Body="&lt;p&gt;I'm attempting to create something similar in nature to the &lt;a href=&quot;http://ubertooth.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;Ubertooth one&lt;/a&gt;. I'd like to sniff Bluetooth packets using the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a few nRF24L01+ wireless modules, which appear to operate on a frequency similar to Bluetooth LE. Unfortunately, I don't believe this will work for Bluetooth or BLE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to sniff radio frequencies in the Bluetooth range from Arduino, am I on the right track?&lt;/p&gt;&#xA;" OwnerUserId="3273" LastEditorUserId="84" LastEditDate="2014-07-23T05:11:33.590" LastActivityDate="2014-07-23T05:11:33.590" Title="Sniffing Bluetooth Packets" Tags="|bluetooth|rf|hardware|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3398" PostTypeId="1" CreationDate="2014-07-23T04:50:31.940" Score="0" ViewCount="2679" Body="&lt;p&gt;I am using a grove GPS &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_GPS&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_GPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I attached the GPS to Serial1 of Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The baudrate of the GPS is set to 9600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Library wise, I am using TinyGps to parse the GPS data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GPS receiver can only get a valid data if it can see a clear sky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read uBlox documentation and it states that I can use A-GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is, how do I actually set the Grove GPS that is attached to my Mega, to use A-GPS?&lt;/p&gt;&#xA;" OwnerUserId="3274" LastEditorUserId="84" LastEditDate="2014-07-23T05:13:39.657" LastActivityDate="2014-07-23T11:03:16.033" Title="How do I set Grove GPS to use A-GPS?" Tags="|arduino-uno|arduino-mega|c|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3399" PostTypeId="2" ParentId="3398" CreationDate="2014-07-23T11:03:16.033" Score="2" Body="&lt;p&gt;A-GPS uses a network connection to download GPS almanac and ephemeris data to enable satellites to be located faster. Otherwise the GPS device has to wait for the data to be sent by a satellite, which may take up to 12.5 minutes. Alternatively, the GPS device can send noise GPS data to an assistance server which will process it and send back a fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A-GPS requires a network connection to an A-GPS server. You can't just 'turn it on'. There are some modules out there that combine GPS with a 3G modem which do A-GPS automatically.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-23T11:03:16.033" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3400" PostTypeId="2" ParentId="3369" CreationDate="2014-07-23T11:18:43.300" Score="0" Body="&lt;p&gt;The one I know of is making the Leonard act like a USB mouse that flaps everywhere and types random keys so you can't reprogram it without doing some kind of trick to get around it. But they mention this on the api docs.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-07-23T11:18:43.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3401" PostTypeId="1" AcceptedAnswerId="3402" CreationDate="2014-07-23T11:52:31.593" Score="1" ViewCount="3425" Body="&lt;p&gt;The datasheet for the accelerometer states that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ogmVl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the data output from the accelerometer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tvidg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to mask the first two bits using a bitwise AND command with B0011111111111111.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use this code, but unfortunately the first 2 bits are still &quot;11&quot; so the value has not changed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bresult=0b0011111111111111&amp;amp;result;&#xA;Serial.print(bresult,BIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would I bits mask the first two bits and will arduino automatically know how to convert to twos compliment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The variable result is of data type &quot;long&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to an answer, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bresult= result&amp;lt;&amp;lt;2;&#xA;Serial.print(bresult,BIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got this result which is great but is it possible to remove the last two zeros because this is making my value larger?&#xA;The image below shows result then bresult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/V32NY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3168" LastEditorUserId="3168" LastEditDate="2014-07-23T14:10:52.320" LastActivityDate="2014-07-23T14:10:52.320" Title="Bit mask first 2 bits of 16 bits for accelerometer" Tags="|arduino-uno|serial|accelerometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3402" PostTypeId="2" ParentId="3401" CreationDate="2014-07-23T12:16:41.447" Score="2" Body="&lt;p&gt;Since it won't convert to two's complement if the sign bit is the 14 bit instead of the 16th, it would be easier to just shift the value left by 2. So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int bresult= result&amp;lt;&amp;lt;2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;&amp;lt;&amp;lt;2&lt;/code&gt; is the same as &lt;code&gt;*4&lt;/code&gt; the result will be 4 times as high. So you need to divide the result by 4. Since you already have to multiply by &lt;code&gt;0.025&lt;/code&gt; (or divide by 40), you end up having to multiply by &lt;code&gt;0.00625&lt;/code&gt; (or divide by 160).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-23T12:16:41.447" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3403" PostTypeId="2" ParentId="3401" CreationDate="2014-07-23T13:39:09.457" Score="0" Body="&lt;p&gt;For the arduino, &lt;code&gt;long&lt;/code&gt; is 32 bits, &lt;code&gt;int&lt;/code&gt; is 16 and &lt;code&gt;char&lt;/code&gt; is 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Save the result in an &lt;code&gt;int&lt;/code&gt; not a &lt;code&gt;long&lt;/code&gt;. Then Gerben's method &lt;code&gt;int bresult = (result &amp;lt;&amp;lt; 2)/4&lt;/code&gt; should work. This is because &lt;code&gt;&amp;lt;&amp;lt; 2&lt;/code&gt; moves everything left two bits, but &lt;code&gt;/ 4&lt;/code&gt; move every thing right two bits &lt;em&gt;with new bytes the same as the sign bit.&lt;/em&gt; So you get a &lt;strong&gt;16 bit&lt;/strong&gt; signed variable with the correct number. If you have it as a long you would have to do &#xA;&lt;code&gt;int bresult = (result &amp;lt;&amp;lt; 18)/(2^18)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW Serial.print(bresult,BIN); is always going to give you up to 16 bits. There is no 14 bit type.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-23T13:39:09.457" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3404" PostTypeId="2" ParentId="61" CreationDate="2014-07-23T13:48:06.570" Score="14" Body="&lt;p&gt;You can use &lt;a href=&quot;http://www.yenka.com&quot; rel=&quot;noreferrer&quot;&gt;Yenka&lt;/a&gt; (free for home use) to simulate Arduino, PIX, PIXACE and other boards with digital, analog and serial I/O. It provides a lot of components and sample projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/c3JWZ.png&quot; alt=&quot;Yenka Arduino simulation&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3281" LastActivityDate="2014-07-23T13:48:06.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3405" PostTypeId="2" ParentId="3369" CreationDate="2014-07-23T13:49:42.783" Score="1" Body="&lt;p&gt;If you upload a program that changes the speed of the USB core it would be almost bricked. What would happen is this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Power on, boot loader starts, USB device enumerated on PC.&lt;/li&gt;&#xA;&lt;li&gt;A few second later program start, USB core speed changed, USB device disappears from PC&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The issue here is that not only do you have to hit reset to program, after the reset you have to quickly select the right com port and then upload before the program starts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Redbearlab Blend Micro requires a USB core speed to be set in the user program. In their setup instructions there is a step to edit the Arduino main.cpp and add a section to do so. If this step is missed, the above problem happens.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-23T13:49:42.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3406" PostTypeId="2" ParentId="3387" CreationDate="2014-07-23T15:19:28.853" Score="1" Body="&lt;p&gt;Ir seems to me that there is something wrong with the Python Raspberry Pi code. What you show is 3 bytes of data, not 2. That's wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're writing a 2 byte word, I would expect to see 2 bytes, not 3. You might want to post a question on the Raspberry Pi forum to get help resolving &lt;strong&gt;THAT&lt;/strong&gt; problem first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're stuck with the sending code you have, then here's what you would do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at your data, the first byte is always zero. You want to discard it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second byte is your low order byte, and your third byte of data is the high order byte. You need to do some juggling to get the data into the correct byte order, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readWordWithPadding()&#xA;{&#xA;  if (Wire.available()&amp;lt;3)&#xA;  {&#xA;    newData = false;&#xA;    return;&#xA;  }&#xA;    newData = true;&#xA;&#xA;  Wire.read(); //Throw away the filler byte&#xA;  int lowByte = Wire.read();&#xA;  int hiByte = Wire.read();&#xA;&#xA;  //Shift the high byte by 8 bits and add in the low byte&#xA;  receivedValue = (hiByte &amp;lt;&amp;lt; 8) + lowByte ;&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-23T15:19:28.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3408" PostTypeId="2" ParentId="3390" CreationDate="2014-07-23T17:07:08.387" Score="1" Body="&lt;p&gt;Since you have both a V+ and V- you could just use 2 transitors. If you look at an H-bridge, you only need half the circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem is that you need V- to disconnect the NPN transistor, and the arduino can only go as low as GND. So you'd need a second transistor to drive it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same might also be needed for the PNP side, if the arduino voltage is regulated to a lower value than V+. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this schematic applicable, but only use the left side. The right side of the motor should be connected to ground (or the middle voltage of your battery). , and replace the opto's with normal transistors.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Ov3qO.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Come to think of it, I'm not entirely confident about replacing the bottom opto, since battery-negative is below GND in your case. I think it should work, but I'm still quite new to this stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure you add something like 1k resistors to the base of the transistors (that replace the opto's)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-23T17:07:08.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3409" PostTypeId="1" AcceptedAnswerId="3410" CreationDate="2014-07-23T17:19:49.940" Score="2" ViewCount="1690" Body="&lt;p&gt;I'm trying to bypass Bridge library and read serial directly from nodejs. I'm on the last sys upgrade (1.3) I have correctly installed nodes and serial module via opkg install. I have also commented out the line in the &lt;code&gt;/etc/inittab&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ttyATH0::askfirst:/bin/ash --login&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;dudee&quot;);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my node.js code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var SerialPort = require(&quot;serialport&quot;).SerialPort&#xA;var serialPort = new SerialPort(&quot;/dev/ttyATH0&quot;, {&#xA;    baudrate: 9600,&#xA;    dataBits: 8,&#xA;    parity: 'none',&#xA;    stopBits: 1,&#xA;    flowControl: false&#xA;}, false);&#xA;&#xA;console.log(&quot;hello&quot;);&#xA;&#xA;serialPort.on(&quot;open&quot;, function () {&#xA;    console.log('open');&#xA;    serialPort.on('data', function(data) {&#xA;        console.log('data received: ' + data);&#xA;    });&#xA;});&#xA;&#xA;serialPort.on('error', function(err) {&#xA;    console.log('error: '+err);&#xA;});&#xA;&#xA;serialPort.open();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I ssh to yun and run the script I don't see any &quot;dudee&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/test# node serial.js&#xA;hello&#xA;open&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While if I open the serial monitor I see it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run the node script on my computer (changing the right serial port name) everything works nice and I see the dude..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can it be?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2014-07-23T17:44:14.863" LastActivityDate="2016-02-25T09:21:33.953" Title="Arduino Yun, node.js and serial" Tags="|serial|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3410" PostTypeId="2" ParentId="3409" CreationDate="2014-07-23T20:09:59.413" Score="2" Body="&lt;p&gt;Autosolved thanks to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=194934.15&quot; rel=&quot;nofollow&quot;&gt;this old forum post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is &lt;code&gt;Serial1&lt;/code&gt; not &lt;code&gt;Serial&lt;/code&gt;.&#xA;In the Arduino code in the Yun &lt;code&gt;Serial&lt;/code&gt; is a different object from &lt;code&gt;Serial1&lt;/code&gt;. Even if it is not super well document (or at least not in the first dumb google search) here are some links that talks about &lt;code&gt;Serial1&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/YunSerialTerminal&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/YunSerialTerminal&lt;/a&gt;&#xA;&lt;a href=&quot;http://andrea-toscano.com/arduino-yun-tcpip-to-serial1-redirect/&quot; rel=&quot;nofollow&quot;&gt;http://andrea-toscano.com/arduino-yun-tcpip-to-serial1-redirect/&lt;/a&gt;&#xA;&lt;a href=&quot;http://crossbar.io/iotcookbook/Arduino-Yun-Disable-Bridge/&quot; rel=&quot;nofollow&quot;&gt;http://crossbar.io/iotcookbook/Arduino-Yun-Disable-Bridge/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2016-02-25T09:21:33.953" LastActivityDate="2016-02-25T09:21:33.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3411" PostTypeId="1" CreationDate="2014-07-17T18:00:57.703" Score="-2" ViewCount="1024" Body="&lt;p&gt;I'm completely new to Arduino, I bought a Rampos 1.4 and an Arduino Mega 2560 to build a Prusa Mendel 3D printer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I connect the Arduino via USB to my computer, open the software and click to upload the blink example, it does anything and says Uploading to i/o board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens when I use Arduino 0022 and then when I use Arduino 1.0.5 r2 that is the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what is happening, and I don't know what to do.&lt;/p&gt;&#xA;" OwnerDisplayName="oriol20" LastEditorUserId="4628" LastEditDate="2015-11-26T14:48:53.377" LastActivityDate="2016-01-25T20:04:34.373" Title="Error uploading on Arduino Mega 2560" Tags="|avrdude|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3412" PostTypeId="1" CreationDate="2014-07-23T21:51:25.047" Score="2" ViewCount="6121" Body="&lt;p&gt;I'm pretty new to this whole thing so please excuse my lack of familiarity with terminology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking to build two &quot;buzzers&quot; of sorts. One will live on the ground floor and the other will live on the fourth floor. There is wireless internet as well as wired internet available to connect the two. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the basic idea. I might put more frills in later. Both buzzers have one button and one LED. I want it so that once a buzzer's button is pressed, the LED lights on both buzzers will light up. Then, only when buzzer two's button is pressed, will the LED lights on both buzzers turn off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty tied up on the two Arduinos communicating with each other. Is it possible to do something like that?&lt;/p&gt;&#xA;" OwnerUserId="3289" LastEditorUserId="4628" LastEditDate="2017-05-29T11:09:12.863" LastActivityDate="2017-05-29T11:09:12.863" Title="How can I get two Arduinos to &quot;talk&quot; to each other?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3413" PostTypeId="2" ParentId="3412" CreationDate="2014-07-23T22:58:47.893" Score="0" Body="&lt;p&gt;Benefits of a networked device:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Fairly fast because it has to be able to transfer large amounts of data&lt;/li&gt;&#xA;&lt;li&gt;Can be compatible and used with computers, servers, and mobile devices. You might also only have to have one Arduino (if the second one would only be acting as a bridge between the protocol and the computer)&lt;/li&gt;&#xA;&lt;li&gt;Why &lt;em&gt;wouldn't&lt;/em&gt; you want to have a networked Arduino :)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So that rules out the protocols I2C, UART, and SPI. I find Bluetooth too hard to work with (it seems to have only a short range) using an Arduino. That leaves us with Wifi, wired network connection, and USB. USB would be best if you could run a short wire, but most USB peripherals aren't really designed to be used 100 feet away from the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With ethernet and Wifi left, I'm going to advise you to go with a wired connection if possible. Benefits of keeping it wired:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Even &lt;em&gt;faster&lt;/em&gt; (with lower latiencies)&lt;/li&gt;&#xA;&lt;li&gt;Lower cost to interface with&lt;/li&gt;&#xA;&lt;li&gt;More reliable than Wifi&lt;/li&gt;&#xA;&lt;li&gt;No pesky Wifi passwords&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; Without a ton of info, &lt;strong&gt;wired internet&lt;/strong&gt; (a.k.a. ethernet) seems to be the best choice.  Other wireless options don't provide the distance you need and you (probably) can't run a wire with another protocol.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-23T22:58:47.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3414" PostTypeId="1" CreationDate="2014-07-23T23:39:16.370" Score="1" ViewCount="1557" Body="&lt;p&gt;I coded a ring buffer for my Arduino to buffer data from either the SPI or TWI ports. In the .h file I used a pointer for the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef uint8_t *ring_buffer_t;&#xA;typedef uint8_t ring_count_t;&#xA;typedef uint8_t ring_index_t;&#xA;typedef uint8_t ring_size_t;&#xA;&#xA;typedef struct ring_t &#xA;{&#xA;    ring_buffer_t buffer;&#xA;    ring_count_t  count;&#xA;    ring_index_t  head;&#xA;    ring_index_t  tail;&#xA;    ring_size_t   size;&#xA;}rint_t;&#xA;&#xA;int ring_init(ring_t *r, ring_buffer_t buffer, ring_size_t size);&#xA;&#xA;// other function prototypes to add and remove from the ring buffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is more code to handle adding and removing from the buffer, but I am simplifying here. Then in my .c file I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;string.h&amp;gt;&#xA;&#xA;void ring_init(ring_t *r, ring_buffer_t buffer, ring_size_t size)&#xA;{&#xA;    r-&amp;gt;buffer = buffer;&#xA;    r-&amp;gt;size   = size;&#xA;    r-&amp;gt;head   = 0;&#xA;    r-&amp;gt;tail   = 0;&#xA;    r-&amp;gt;count  = 0;&#xA;&#xA;    // clear out the buffer memset cheaper by 12 bytes rather than for loop&#xA;    memset((void *)r-&amp;gt;buffer, 0, r-&amp;gt;size);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then somewhere in code where the ring buffer is going to be used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In SPI.h ...&#xA;#define MAX_BUFFER_SIZE 32&#xA;ring_t  rx_ring;&#xA;uint8_t spi_rx_buffer[MAX_BUFFER_SIZE];&#xA;&#xA;#define MAX_BUFFER_SIZE 32&#xA;ring_t  tx_ring;&#xA;uint8_t spi_tx_buffer[MAX_BUFFER_SIZE];&#xA;&#xA;&#xA;In SPI.c ...&#xA;void spi_init( ... )&#xA;{&#xA;    ring_init(&amp;amp;rx_ring, spi_rx_buffer, MAX_BUFFER_SIZE);&#xA;    ring_init(&amp;amp;tx_ring, spi_tx_buffer, MAX_BUFFER_SIZE);&#xA;&#xA;    // initialize other spi parameters&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any issues with my code that are obvious that I am not seeing? I ask because I ran the code and it works, but I feel I am doing something wrong. I can code in C and remember something about malloc() for dynamic memory allocation, just not sure if what I am doing qualifies. Or should this work creating a buffer of some defined size?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help or ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: 07/27/2014 Added code to try and make what I am trying to do clear. Let me know, thanks.&lt;/p&gt;&#xA;" OwnerUserId="3291" LastEditorUserId="3291" LastEditDate="2014-07-28T03:15:36.933" LastActivityDate="2014-10-29T10:08:49.460" Title="Is it bad coding practice to design a buffer using pointers?" Tags="|programming|pointer|memory-usage|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3415" PostTypeId="2" ParentId="3414" CreationDate="2014-07-24T00:05:00.103" Score="0" Body="&lt;p&gt;Not enough info. You have a struct ring_t that has a pointer to an array of uint8_t's. In your ring_init method, your code assumes that the pointer points to valid memory. If you have not explicitly pointed the pointer to a block of memory, either stack memory or heap memory, then yes, there is a problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You COULD malloc the ring buffer, or you could create it as a global variable. If you've only got one ring buffer it's probably just as well to make the buffer a global and set the pointer in your setup method.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-24T00:05:00.103" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3416" PostTypeId="2" ParentId="3414" CreationDate="2014-07-24T01:12:47.803" Score="1" Body="&lt;p&gt;Don't bother with &lt;code&gt;malloc&lt;/code&gt; unless you need to. If you explicitly define your buffer before hand then you can use &lt;code&gt;avr-size&lt;/code&gt; to &lt;a href=&quot;https://stackoverflow.com/questions/960389/how-can-i-visualise-the-memory-sram-usage-of-an-avr-program&quot;&gt;check your SRAM usage&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the C compiler automatically adds code to initialise global variables to 0, so you don't need ring_init if your define the array explicitly. See &lt;a href=&quot;https://stackoverflow.com/questions/2218254/variable-initialization-in-c&quot;&gt;https://stackoverflow.com/questions/2218254/variable-initialization-in-c&lt;/a&gt; for initialisation comments. Even if buffer was filled with non-zeros it wouldn't matter because it should be written to before being read from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change the ring buffer from chars to ints, etc. you will have to change &lt;code&gt;memset&lt;/code&gt;, as it assumes chars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will MAX_BUFFER_SIZE change? If not, you could put the buffer in &lt;code&gt;ring_t&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-07-31T08:29:10.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3417" PostTypeId="2" ParentId="3394" CreationDate="2014-07-24T01:31:39.953" Score="1" Body="&lt;p&gt;Here are a few things to remember:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should have a ground connection between the RPi and Arduino&lt;/li&gt;&#xA;&lt;li&gt;I2C was meant for really short distances on a printed circuit board&lt;/li&gt;&#xA;&lt;li&gt;Arduino runs at 5 Volt logic levels and RPi at 3.3 Volt logic levels - you need a level translator between them to make that work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the RPi and the Arduino are not far apart, I would say less than 1 foot (30 cm) and you have the grounds connected between the boards, then it is a software issue. I2C is meant for short distances any anything longer than a foot puts too much capaitance on the wires and starts causing unreliable communication. I would not even use it for more than a few inches unless it was on a circuit board where you control the capacitance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming your using the Wire library on the Arduino side. On the RPi side I would use the the Adafruit I2C library for the RPi as I have had success using the library to communicate with I2C sensors listed on their site. Here is the link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/using-the-bmp085-with-raspberry-pi/configuring-the-pi-for-i2c&quot; rel=&quot;nofollow&quot;&gt;Adafruit RPi I2C Tutorial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3291" LastEditorUserId="3291" LastEditDate="2014-07-24T01:39:32.403" LastActivityDate="2014-07-24T01:39:32.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3418" PostTypeId="2" ParentId="3412" CreationDate="2014-07-24T01:32:18.090" Score="3" Body="&lt;p&gt;&lt;strong&gt;Wired&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Communication speed is not a factor - you only have to transmit an on/off signal. The simplest method would be to run a 4-wire cable, like a telephone cable, between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wires would be&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;GND &lt;/li&gt;&#xA;&lt;li&gt;5V (maybe) &lt;/li&gt;&#xA;&lt;li&gt;Ground floor output -&gt; fourth floor input&lt;/li&gt;&#xA;&lt;li&gt;Fourth floor output -&gt; ground floor input&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The steps are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Both wire 3 and 4 start LOW When ground floor button is pressed, ground floor led goes on, wire 3 is set HIGH. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fourth floor is monitoring wire 3, when it goes HIGH, fourth floor led goes on, and    wire 4 is set HIGH &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ground floor is monitoring wire 4, when it goes HIGH, ground floor led goes off, and wire 3 is set LOW &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fourth floor is monitoring wire 3, when it goes LOW, fourth floor led goes off,    and wire 4 is set LOW &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ground floor is monitoring wire 4, when it    goes LOW, it begins waiting for a button press again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Wire 2 can be used for 5V (or 3.3V depending on the Arduino) so that one of the devices can be powered off the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wireless&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other option is to attach an RF transceiver to each Arduino, something like &lt;a href=&quot;https://www.sparkfun.com/products/691&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; would be good as it has 100m line-of-site range which you might need to get through 4 floors of concrete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Learning&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start off with the simple wired method shown above. When it is working, connect wire 3 and 4 into the RX and TX pins and try to communicate using the serial port. Finally, move on to the wireless transceivers.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-24T01:32:18.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3419" PostTypeId="1" CreationDate="2014-07-24T01:58:44.633" Score="0" ViewCount="843" Body="&lt;p&gt;I have a few Arduino's along with XBee Shields communicating with one another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having is that, when all the Arduinos+XBee Shields are powered via USB(PC) they seem to work fine and all transmissions get through to one another. But, when I use them with 9Volt batteries(fairly new batteries) the whole thing crashes and I never receive responses back from the battery powered ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if this is really a power issue? wouldn't a 9volt be enough to power a single arduino(uno)+xbee shield?&lt;/p&gt;&#xA;" OwnerDisplayName="user3292" LastActivityDate="2014-09-22T16:40:10.977" Title="Arduino uno + XBee Shield Not transmitting when under battery power?" Tags="|arduino-uno|shields|power|xbee|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3420" PostTypeId="2" ParentId="3419" CreationDate="2014-07-24T04:09:43.073" Score="1" Body="&lt;p&gt;Using a multimeter you can confirm your theory by looking for a voltage drop on the power connections to the XBee and into the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9V batteries don't store much charge, nominally 563mAh according to wikipedia. It is possible that the fairly new batteries are not that new after all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the XBee, power consumption varies. 40mA for a normal XBee (ZigBee), 200mA for pro, and 309mA when transmitting for the new XBee WiFi. If the battery is low, the high current draw plus internal battery resistance may drop the 9V output to below the 7V needed for the UNO's voltage regulator to function correctly.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-24T04:09:43.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3422" PostTypeId="1" CreationDate="2014-07-24T07:54:17.503" Score="3" ViewCount="2443" Body="&lt;p&gt;2 days back I bought Arduino Yun. I'm able to flash Led on 13 pin. And I'm able to flash Led on Bread board connected to A0. I'm able to run linux commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want control A0 pin using Linux/Python program. Is this possible? I read many documents. But I didn't find thing related to this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How I  can flash the LED using Linux programs?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3298" LastEditorUserId="612" LastEditDate="2014-07-24T18:05:11.513" LastActivityDate="2017-08-07T09:51:18.153" Title="Can I control analog IO pins using Yun Linux" Tags="|arduino-yun|linux|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3423" PostTypeId="1" CreationDate="2014-07-24T08:13:13.623" Score="1" ViewCount="1378" Body="&lt;p&gt;I'm currently trying to write to and read from an 25LC256-E EEPROM with my Arduino Uno via SPI. I've made a program which is supposed to do this, but I only get weird answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sending in a Serial-string.&#xA;This string should start with 'w', 'r' or 'e', depending on what action I want to perform. The second character should be an int between 0 and 3 to determine witch PIN I should use as slave (currently I'm using only 1 slave, so the int should always be 0).&#xA;The rest of the string gets written to the EEPROM, one byte/character at the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;    #define WREN  6&#xA;    #define WRDI  4&#xA;    #define RDSR  5&#xA;    #define WRSR  1&#xA;    #define READ  3&#xA;    #define WRITE 2&#xA;&#xA;    // Multiple slaves for future project&#xA;    const int CHANNELS[4] = {10, 8, 7, 4};&#xA;    String readResult;&#xA;&#xA;    void setup() {&#xA;&#xA;      Serial.begin(9600);&#xA;      channelSetup(); // Set all slave pins in CHANNELS to OUTPUT and HIGH&#xA;&#xA;      SPI.begin();&#xA;      SPI.setDataMode(SPI_MODE3);&#xA;      SPI.setClockDivider(SPI_CLOCK_DIV2);&#xA;      SPI.setBitOrder(MSBFIRST);&#xA;&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;      Serial.println(&quot;START&quot;);&#xA;&#xA;      while(!Serial.available());&#xA;      delay(20);&#xA;&#xA;      // Get all available bytes/characters&#xA;      String serialInput = getSerialStream(Serial.available());&#xA;&#xA;      // Second character in serialInput is an int between 0 and 3&#xA;      int channel = makeValidChannel(serialInput[1]);&#xA;&#xA;      // &quot;channel&quot; must be between 0 and 3&#xA;      // to be able to point to CHANNELS&#xA;      if (channel &amp;gt;= 0 &amp;amp;&amp;amp; channel &amp;lt;= 3) {&#xA;&#xA;        // First character decides what to do&#xA;        switch (serialInput[0]) {&#xA;&#xA;          case 'w':&#xA;            writeToChannel(channel, serialInput.substring(2));&#xA;            break;&#xA;&#xA;          case 'r':&#xA;            readResult = &quot;EMPTY&quot;;&#xA;            readResult = readFromChannel(channel);&#xA;            Serial.print(&quot;Result: &quot;);&#xA;            Serial.println(readResult);&#xA;            break;&#xA;&#xA;          case 'e':&#xA;            overWriteEEPROM(channel);&#xA;            break;&#xA;&#xA;          default:&#xA;            Serial.println(&quot;INVALID FIRST OPERATION&quot;);&#xA;&#xA;        }&#xA;&#xA;      }&#xA;&#xA;      else&#xA;        Serial.print(&quot;INVALID CHANNEL: &quot;);&#xA;        Serial.println(channel);&#xA;&#xA;    }&#xA;&#xA;    void channelSetup() {&#xA;&#xA;      for (int i = 0; i &amp;lt; sizeof(CHANNELS); i++) {&#xA;&#xA;        pinMode(CHANNELS[i], OUTPUT);&#xA;        digitalWrite(CHANNELS[i], HIGH);&#xA;&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    String getSerialStream(int numOfChars) {&#xA;&#xA;      char serialStream[numOfChars + 1];&#xA;      int i;&#xA;&#xA;      for (i = 0; i &amp;lt; numOfChars; i++) {&#xA;&#xA;        serialStream[i] = char(Serial.read());&#xA;        delay(5);&#xA;&#xA;      }&#xA;&#xA;      serialStream[i] = '\0';&#xA;      return String(serialStream);&#xA;&#xA;    }&#xA;&#xA;    int makeValidChannel(char chIn) {&#xA;&#xA;      int channel = chIn - '0';&#xA;      //channel -= 48;&#xA;&#xA;      if (channel &amp;gt;= 0 &amp;amp;&amp;amp; channel &amp;lt;= 3)&#xA;        return channel;&#xA;      else&#xA;        return -1;&#xA;&#xA;    }&#xA;&#xA;    void writeToChannel(int channel, String message) {&#xA;&#xA;      int slaveselect = CHANNELS[channel];&#xA;      int i;&#xA;&#xA;      // Write enabled&#xA;      digitalWrite(slaveselect, LOW);&#xA;      SPI.transfer(WREN);&#xA;      digitalWrite(slaveselect, HIGH);&#xA;      delay(5);&#xA;&#xA;      // Disable Write Protection&#xA;      digitalWrite(slaveselect, LOW);&#xA;      SPI.transfer(WRSR);&#xA;      SPI.transfer(0);&#xA;      digitalWrite(slaveselect, HIGH);&#xA;      delay(5);&#xA;&#xA;      for (i = 0; i &amp;lt; message.length(); i++) {&#xA;&#xA;        digitalWrite(slaveselect, LOW);&#xA;        SPI.transfer(WRITE);&#xA;        SPI.transfer(0);&#xA;        SPI.transfer(i);&#xA;        SPI.transfer(message[i]);&#xA;        digitalWrite(slaveselect, HIGH);&#xA;        delay(5);&#xA;&#xA;      }&#xA;&#xA;      // When writing of &quot;message&quot; is done,&#xA;      // add a 0-byte as terminating character&#xA;      digitalWrite(slaveselect, LOW);&#xA;      SPI.transfer(WRITE);&#xA;      SPI.transfer(0);&#xA;      SPI.transfer(i);&#xA;      SPI.transfer(0x00);&#xA;      digitalWrite(slaveselect, HIGH);&#xA;      delay(5);&#xA;&#xA;&#xA;      // Enable Write Protection&#xA;      digitalWrite(slaveselect, LOW);&#xA;      SPI.transfer(WRSR);&#xA;      SPI.transfer(3);&#xA;      digitalWrite(slaveselect, HIGH);&#xA;      delay(5);&#xA;&#xA;      // Write Disabled&#xA;      digitalWrite(slaveselect, LOW);&#xA;      SPI.transfer(WRDI);&#xA;      digitalWrite(slaveselect, HIGH);&#xA;      delay(5);&#xA;&#xA;    }&#xA;&#xA;    String readFromChannel(int channel) {&#xA;&#xA;      Serial.println(&quot;Reading started&quot;);&#xA;&#xA;      int slaveselect = CHANNELS[channel];&#xA;      char outputArr[64];&#xA;      int i = 0;&#xA;&#xA;      while (true) {&#xA;&#xA;        digitalWrite(slaveselect, LOW);&#xA;        SPI.transfer(READ);&#xA;        SPI.transfer(0);&#xA;        SPI.transfer(i);&#xA;        outputArr[i] = SPI.transfer(0x00);&#xA;        digitalWrite(slaveselect, HIGH);&#xA;        delay(5);&#xA;&#xA;        if (outputArr[i] == 0x00 || i &amp;gt;= 64) {&#xA;&#xA;          outputArr[i] = '\0';&#xA;          return String(outputArr);  &#xA;&#xA;                }&#xA;&#xA;        else&#xA;          i++;&#xA;&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    void overWriteEEPROM(int channel) {&#xA;&#xA;      char zeroArr[64];&#xA;      for (int i = 0; i &amp;lt; 256; i++) {&#xA;&#xA;        zeroArr[i] = 0;&#xA;&#xA;      }&#xA;&#xA;      writeToChannel(channel, String(zeroArr))&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3170" LastEditorUserId="37622" LastEditDate="2022-11-21T06:00:27.457" LastActivityDate="2022-11-21T06:00:27.457" Title="Can't read from / write to SPI EEPROM" Tags="|arduino-uno|serial|spi|eeprom|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="3424" PostTypeId="1" AcceptedAnswerId="3428" CreationDate="2014-07-24T08:27:01.760" Score="3" ViewCount="3345" Body="&lt;p&gt;I'm using a single sonar, but I want to use two sonar to know another distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I use my single sonar:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;NewPing.h&amp;gt;&#xA;&#xA;    #define TRIGGER_PIN  9&#xA;    #define ECHO_PIN  10&#xA;    #define MAX_DISTANCE  100 // in CM&#xA;    ...&#xA;    NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); &#xA;    ...&#xA;    delay(100); &#xA;    unsigned int uS = sonar.ping(); &#xA;    int cm = uS / US_ROUNDTRIP_CM; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I Want to use a second one to calculate another distance, how to?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TRIGGER_PIN_2  11&#xA;#define ECHO_PIN_2  12&#xA;...&#xA;new NewPing sonar(TRIGGER_PIN_2, ECHO_PIN_2, MAX_DISTANCE);&#xA;...&#xA;???&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this one, I'll try this when I will get my second sonar&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SONAR_NUM     2&#xA;#define MAX_DISTANCE 200&#xA;...&#xA;NewPing sonar[SONAR_NUM] = {     &#xA;  NewPing(9, 10, MAX_DISTANCE),&#xA;  NewPing(11, 12, MAX_DISTANCE)&#xA;};&#xA;...&#xA;delay(100); &#xA;unsigned int uS1 = sonar[0].ping(); &#xA;int cm1 = uS1 / US_ROUNDTRIP_CM; &#xA;&#xA;unsigned int uS2 = sonar[1].ping(); &#xA;int cm2 = uS2 / US_ROUNDTRIP_CM; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3299" LastEditorUserId="3299" LastEditDate="2014-07-24T08:45:14.097" LastActivityDate="2014-07-24T12:26:09.917" Title="How to use two Sonar's" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3425" PostTypeId="1" AcceptedAnswerId="3426" CreationDate="2014-07-24T08:34:38.570" Score="4" ViewCount="11337" Body="&lt;p&gt;I use the Pin 7 to get the status of a push button. I put 10Kohm R on the - .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The status is unstable because arduino says thet I push it but it is not true...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int button = 7;&#xA;...&#xA;// var for reading pushbutton value&#xA;int buttonState = 0;&#xA;...&#xA;buttonState = digitalRead(button);&#xA;  if(buttonState == HIGH)&#xA;  {&#xA;    myFunction();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ARDUINO PIN 7 &amp;lt;---&gt; R 10Kohm &amp;lt;--&gt; [switch] &amp;lt;---&gt; VCC&lt;/p&gt;&#xA;" OwnerUserId="3299" LastEditorUserId="2973" LastEditDate="2014-07-25T10:18:39.797" LastActivityDate="2014-07-25T10:18:39.797" Title="Unstable reading from pushbutton on digital pin" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3426" PostTypeId="2" ParentId="3425" CreationDate="2014-07-24T10:24:31.840" Score="10" Body="&lt;p&gt;At the moment, your resistor isn't doing anything useful. When your switch is open, the pin is still 'floating', which means it's ending up with random stray readings from nearby electromagnetic fields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You basically need two connections coming from your Arduino pin. One goes through a resistor straight to ground. The other goes through your switch straight to +5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, the resistor is acting as a pull-down, because it holds your pin at Ground whenever the switch is open. You could swap over the ground and +5V, and it the resistor would function as a pull-up instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question deals with the same kind of issue:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/186/button-state-changing-randomly/187&quot;&gt;Button state changing randomly&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-07-24T10:24:31.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3427" PostTypeId="2" ParentId="3396" CreationDate="2014-07-24T11:16:34.943" Score="1" Body="&lt;p&gt;When you open a serial connection to Arduino Uno the atmega328 microcontroller is usually reset(this depends if the OS is configured to toggle the DTR serial control signal on/off when a port is opened). Just after a reset the bootloader (optiboot) runs to see if you are trying to upload a new sketch. If the bootloader doesn't receive any meaningful communication it will start your sketch after ~1 sec. All communication sent to the serial port while the bootloader is running is lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use the serial monitor you are too slow to notice the 1 second where the board won't respond to your commands. But the processing sketch is another story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest fix will be to insert a delay after you open the serial port and before you send any data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Wait 1.2 sec&#xA;int start = millis();&#xA;while (millis() - start &amp;lt; 1200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you would rather use a hardware fix you can connect a 10uF capacitor between RESET and GND pins that will prevent the board from being reset by the usb to serial converter.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2014-07-24T19:56:29.067" LastActivityDate="2014-07-24T19:56:29.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3428" PostTypeId="2" ParentId="3424" CreationDate="2014-07-24T12:26:09.917" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Maybe this one, I'll try this when I will get my second sonar&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Ding ding ding!&lt;/em&gt; Yeah, this would be one way to do that. That creates an &lt;em&gt;array&lt;/em&gt; so you can reference the sonar with &lt;code&gt;sonar[i]&lt;/code&gt;, where &lt;code&gt;i&lt;/code&gt; is either 0 or 1 for the first or second number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For only two sensors, it might be easier just to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NewPing sonar1(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);&#xA;NewPing sonar2(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can run the other code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(100); &#xA;unsigned int uS1 = sonar1.ping(); &#xA;int cm1 = uS1 / US_ROUNDTRIP_CM; &#xA;&#xA;unsigned int uS2 = sonar2.ping(); &#xA;int cm2 = uS2 / US_ROUNDTRIP_CM;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A little less code to read, whichever one you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason you can do this is you can replace the &lt;code&gt;sonar&lt;/code&gt; with whatever you wanted (following C++ variable rules like no spaces, etc.). You could call it &lt;code&gt;Arduino_Sonar&lt;/code&gt; if you wanted to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array is basically a simple way of grouping variables together easily. It's not convenient to declare 500 differently name variables; I can just do &lt;code&gt;int numbers[500];&lt;/code&gt; to declare them. An array might be more useful if you're expanding your circuit, but either is correct.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-24T12:26:09.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3429" PostTypeId="2" ParentId="3425" CreationDate="2014-07-24T13:12:54.967" Score="7" Body="&lt;p&gt;Note that you can also activate the internal pull-up resistor on the pin by first making it an input, then setting it to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT);&#xA;digitalWrite(pin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;EDIT:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Based on info from Craig (in the comments below) it's simpler to use the new pinMode INPUT_PULLUP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then wire the switch directly to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the simplest way to wire a pushbutton to an arduino (no resistor needed) but &lt;strong&gt;do&lt;/strong&gt; you need an extra line of code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the pin will read as HIGH when not pressed, and LOW when pressed (which might seem counter-intuitive)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-07-25T01:19:48.680" LastActivityDate="2014-07-25T01:19:48.680" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3431" PostTypeId="2" ParentId="3422" CreationDate="2014-07-24T14:01:34.177" Score="0" Body="&lt;p&gt;I haven't used a Yun before, but here is my understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Yun is really 2 separate computers with a bidirectional serial port between them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output pins are on the Arduino side. If you want to control Arduino pins from the LINUX side, you need to come up with a simple command syntax for communicating between the 2 computers and write code on both sides that supports that command syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say the command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalPinx=n;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where x is the pin number, and n is a value, 0 or 1. (for digital pins). For a PWM output pin you could use a command analogPin and values of n from 0 to 255:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogPinx=n;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the LINUX side you'd just send that command through the serial port to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino side, you'd write a loop that would wait for data to come into the serial port from the LINUX chip. If it gets data, it would read it into a buffer until it saw a semicolon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it would break the data into separate lines using the semicolon as a delimiter, search for &quot;digitalPin&quot; or &quot;analogPin&quot;, parse the data between the command and the semicolon for the values, and issue the digitalWrite or analogWrite command using those values.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-24T14:01:34.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3432" PostTypeId="2" ParentId="3419" CreationDate="2014-07-24T14:39:49.240" Score="0" Body="&lt;p&gt;The usb port on your computer can supply about 500mA of current. If geometrikal is correct about the 563mAh and you are using an XBee pro or a higher current draw radio, you could easily be hitting the current limit of the battery. Another aspect of this is the &lt;a href=&quot;http://en.wikipedia.org/wiki/Internal_resistance&quot; rel=&quot;nofollow&quot;&gt;internal resistance&lt;/a&gt; of the battery. I'll let you read about it, but it is another current limiting factor. All of this boils down to once you are drawing more current than the battery can provide the voltage drops. Once it gets down to below what the Arduino board can regulate the microcontroller will reset.&lt;/p&gt;&#xA;" OwnerUserId="3301" LastActivityDate="2014-07-24T14:39:49.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3433" PostTypeId="2" ParentId="3419" CreationDate="2014-07-24T15:36:02.343" Score="0" Body="&lt;p&gt;Is space an issue? Have you considered using 6 AA batteries? From what I've read basically the current provided by a battery is determined by it's size so C is bigger than AA which is bigger than AAA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 9volt battery is from what I understand made up of 6 AAAA cells and therefore has a much lower maximum current. about 563mAh rather than about 1500mAh depending upon the type you choose. &lt;/p&gt;&#xA;" OwnerUserId="2762" LastActivityDate="2014-07-24T15:36:02.343" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3434" PostTypeId="1" AcceptedAnswerId="3444" CreationDate="2014-07-24T18:20:36.117" Score="3" ViewCount="9941" Body="&lt;p&gt;I have the (more or less) Leonardo-compatible board Olimexino-32u4. Both, the TX- and RX-LED are permanently on. To reduce power-consumption, I want to disable them &lt;strong&gt;by software&lt;/strong&gt;. What is the reliable way to do it?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2014-07-25T06:16:56.950" LastActivityDate="2021-05-15T14:51:32.123" Title="Leonardo: disable TX- and RX-LED" Tags="|arduino-leonardo|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3435" PostTypeId="1" CreationDate="2014-07-24T21:41:55.700" Score="2" ViewCount="260" Body="&lt;p&gt;I have the following sensor stick: &lt;a href=&quot;https://www.sparkfun.com/products/10724&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10724&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has an accelerometer, gyroscope, and magnetometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected it to an arduino and am reading the accelerometer values while the sensor is completely flat and the values jump all over the place:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ie&#xA;0&#xA;2&#xA;3&#xA;7&#xA;-5&#xA;12&#xA;35&#xA;-3&#xA;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I am reading them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Accel_Init()&#xA;{&#xA;  Wire.beginTransmission(ACCEL_ADDRESS);&#xA;  Wire.write(0x2D);  // Power register&#xA;  Wire.write(0x08);  // Measurement mode&#xA;  Wire.endTransmission();&#xA;  delay(5);&#xA;  Wire.beginTransmission(ACCEL_ADDRESS);&#xA;  Wire.write(0x31);  // Data format register&#xA;  Wire.write(0x08);  // Set to full resolution&#xA;  Wire.endTransmission();&#xA;  delay(5);&#xA;&#xA;  // Because our main loop runs at 50Hz we adjust the output data rate to 50Hz (25Hz bandwidth)&#xA;  Wire.beginTransmission(ACCEL_ADDRESS);&#xA;  Wire.write(0x2C);  // Rate&#xA;  Wire.write(0x09);  // Set to 50Hz, normal operation&#xA;  Wire.endTransmission();&#xA;  delay(5);&#xA;}&#xA;&#xA;// Reads x, y and z accelerometer registers&#xA;void Read_Accel()&#xA;{&#xA;  int i = 0;&#xA;  byte buff[6];&#xA;&#xA;  Wire.beginTransmission(ACCEL_ADDRESS); &#xA;  Wire.write(0x32);  // Send address to read from&#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.beginTransmission(ACCEL_ADDRESS);&#xA;  Wire.requestFrom(ACCEL_ADDRESS, 6);  // Request 6 bytes&#xA;  while(Wire.available())  // ((Wire.available())&amp;amp;&amp;amp;(i&amp;lt;6))&#xA;  { &#xA;    buff[i] = Wire.read();  // Read one byte&#xA;    i++;&#xA;  }&#xA;  Wire.endTransmission();&#xA;&#xA;  if (i == 6)  // All bytes received?&#xA;  {&#xA;    // No multiply by -1 for coordinate system transformation here, because of double negation:&#xA;    // We want the gravity vector, which is negated acceleration vector.&#xA;    accel[0] = (((int) buff[3]) &amp;lt;&amp;lt; 8) | buff[2];  // X axis (internal sensor y axis)&#xA;    accel[1] = (((int) buff[1]) &amp;lt;&amp;lt; 8) | buff[0];  // Y axis (internal sensor x axis)&#xA;    accel[2] = (((int) buff[5]) &amp;lt;&amp;lt; 8) | buff[4];  // Z axis (internal sensor z axis)&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong that these values aren't the same?&lt;/p&gt;&#xA;" OwnerUserId="1535" LastActivityDate="2014-09-23T13:43:15.107" Title="9 DoF Sensor Accelerometer Readings Inconsistent" Tags="|arduino-uno|i2c|accelerometer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3436" PostTypeId="1" CreationDate="2014-07-24T21:52:19.370" Score="0" ViewCount="522" Body="&lt;p&gt;I have a Arduino Mega 2560 connected to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;L293D Motor Driver IC connected to two small size dc motors. &lt;/li&gt;&#xA;&lt;li&gt;MPU-9150 using i2c &lt;/li&gt;&#xA;&lt;li&gt;Xbee v1.1 arduino shield by seeed&lt;/li&gt;&#xA;&lt;li&gt;Li-po battery, 7.4 volts, 2200 mah. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All components are tested separately, they all are working fine, the sensor readings showing data on serial monitor, the l293 drives the motors, xbee sends wireless serial data on pc, and li-po is also working fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked the wiring alot of times. It all seems to be correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem arises when i connect all of them together, since I am using a single power source, I power the l293d with the Li-po and the Arduino also with the Li-po. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When the L293D is powered using Li-po and it starts drawing current from the battery, the serial monitor/arduino gets stuck. It doesnt show sensor readings anymore, while the dc motors start spinning. And they continue to spin, until I break connection with the battery.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Without the l293d powered, the sensor readings are working fine, everything is going normal, as it should, but as soon as the l293d is connected, arduino is stuck..&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have searched alot of forums for this, found some info, perhaps something to do analog and digital ground? mpu-9150 is digital ground. So that is why it stops the arduino mega as the l293d starts drawing current. All hell breaks loose. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody please help me with this? it is giving me headaches ever since! &lt;/p&gt;&#xA;" OwnerUserId="3305" LastEditorUserId="3305" LastEditDate="2014-07-26T15:58:14.700" LastActivityDate="2014-07-26T15:58:14.700" Title="Arduino gets stuck: battery powered, wireless, dc motor drive" Tags="|serial|sensors|current|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="3437" PostTypeId="2" ParentId="3436" CreationDate="2014-07-24T22:23:00.380" Score="2" Body="&lt;p&gt;My guess is that your motors are drawing too much current and the voltage from your battery is dropping too low for the voltage regulator on the Arduino. Looking at the data sheet, the L293D will provide up to 600-mA for up to 2 motors at a time. That's up to 1.2 amps, a whole lot of current. I would suggest trying to power your arduino from a separate 9 volt battery as an experiment.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-24T22:23:00.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3439" PostTypeId="1" CreationDate="2014-07-25T03:07:00.007" Score="1" ViewCount="861" Body="&lt;p&gt;I am trying to prep my wiring for a 8x8 Led Matrix w/ Bluetooth according to the following instructable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-SPI-7-Bi-color-LED-Matrix-Scrolling-Text-D/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-SPI-7-Bi-color-LED-Matrix-Scrolling-Text-D/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of soldering everything together I'd much rather use a breadboard. I'm new to wiring, breadboards, and Arduino's in general. I was wondering if anyone could look over my sketch and see that the connections I've made are valid. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm basing my wiring off this image (See original instructable for higher resolution):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/UkLpO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize the bluetooth module isn't the same. I'm just using this as a reference. The wires leading off the top of the board will be going to the LED Driver module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Thanks for the feedback guys. I have decided to go with the Innogear HC-05 module. I've adjusted the wiring according to that model.&#xA;As per the suggestions, I've switched my power and ground rail and eliminated the resistors and ground for TX communication. (I've still kept a ground for the BT).&#xA;Here's my new attempt:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/RoBTD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3306" LastEditorUserId="3306" LastEditDate="2014-07-25T22:09:23.590" LastActivityDate="2014-07-26T22:04:42.163" Title="Help with wiring? Fritzing example inside" Tags="|led|bluetooth|wires|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3440" PostTypeId="1" AcceptedAnswerId="3441" CreationDate="2014-07-25T07:31:37.260" Score="3" ViewCount="553" Body="&lt;p&gt;I am following &lt;a href=&quot;http://horrorcoding.altervista.org/arduino-development-with-eclipse-a-step-by-step-tutorial-to-the-basic-setup/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; guide. Now I want to create the Create the &quot;ArduinoCore library&quot;. But when I am creating a new project, I can not select ATmega16U2 as MCU type. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my Arduino Due R3-E and UNO SMD R3 both use ATmega16U2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What shall I do O_o??? &lt;/p&gt;&#xA;" OwnerUserId="3309" LastActivityDate="2014-07-25T10:58:39.763" Title="MCU Type ATmega16U2 not avaliable in Eclipse AVR Plugin" Tags="|arduino-uno|arduino-due|eclipse|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3441" PostTypeId="2" ParentId="3440" CreationDate="2014-07-25T10:58:39.763" Score="5" Body="&lt;p&gt;The &lt;code&gt;ATmega16U2&lt;/code&gt; on those boards isn't intended to be programmable by the end-user. It's only there to help convert from USB to TTL serial, which lets your computer communicate with the board's main microcontroller. It replaces the FTDI chip which was used on some older boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of the Uno, the main microcontroller is the &lt;code&gt;ATmega328&lt;/code&gt;. For the Due, it's the &lt;code&gt;AT91SAM3X8E&lt;/code&gt;. If you want to program them from the Arduino IDE, you can usually just select the board by name from the drop-down menu.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-07-25T10:58:39.763" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3442" PostTypeId="2" ParentId="3439" CreationDate="2014-07-25T12:23:10.670" Score="1" Body="&lt;p&gt;Those are, in fact, the same board. When you look at this image (from Amazon)...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KfM6Qm.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;...you can see that there are really six pins, just two of them aren't soldered.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Your circuit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On the power rails, you have the 5V and ground switched. It'll work okay, but you're asking for trouble later on when trying to work with it and accidentally plugging a wire into the wrong rail.&lt;/li&gt;&#xA;&lt;li&gt;Also, from the reviews on Amazon, it says that it can be powered with 5V since the breakout board provides voltage conversion. However, no one specifically mentions the TX/RX, so I'd not risk it. &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00JP05S6C&quot; rel=&quot;nofollow noreferrer&quot;&gt;This module&lt;/a&gt; (seems to be same chip) costs less and a reviewer specifically says that it converts voltage for both power &lt;em&gt;and&lt;/em&gt; the TX/RX.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm not going to verify the resistor values, since you don't seem to need them if you get the other module I listed.&lt;/li&gt;&#xA;&lt;li&gt;If you still did want to do the 5V/3.3V conversion, you should connect the power wire to the 3.3V pin, not the 5V rail on the breadboard&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; it seems as you just need to skip the resistors for the yellow wire and make a direction connection. I'm not 100% sure about &lt;em&gt;that specific part&lt;/em&gt; but there was another one that a reviewer specified that this was okay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I cannot comment on the other wires for the shields, but at a quick glance it looks good.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-25T12:23:10.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3443" PostTypeId="2" ParentId="3435" CreationDate="2014-07-25T12:40:19.323" Score="2" Body="&lt;p&gt;In 'FULL_RES' mode the number you get is amount of 4mg units. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So 1 is 4mg, 2 is 8mg, -4 = -32mg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that your current code doesn't interpret the first bit (so the 13th from the right) as the sign bit, so you'll never get negative values. (&lt;a href=&quot;https://arduino.stackexchange.com/questions/3401/bit-mask-first-2-bits-of-16-bits-for-accelerometer&quot;&gt;Question related to this&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I think it is actually more like 3.9mg.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-07-25T12:40:19.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3444" PostTypeId="2" ParentId="3434" CreationDate="2014-07-25T13:23:01.243" Score="3" Body="&lt;p&gt;Try adding this to your setup routine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TXLED0;&#xA;RXLED0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;These macros (and their cousins TXLED1, RXLED1) are used to control the TX an RX LED's on Leonardo. They are defined in &lt;a href=&quot;https://github.com/arduino/ArduinoCore-avr/blob/9f8d27f09f3bbd1da1374b5549a82bda55d45d44/variants/leonardo/pins_arduino.h#L95-L98&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/arduino/ArduinoCore-avr/blob/9f8d27f09f3bbd1da1374b5549a82bda55d45d44/variants/leonardo/pins_arduino.h#L95-L98&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If that doesn't work you can try the solutions suggested here: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=145262.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=145262.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="55966" LastEditDate="2021-05-15T14:51:32.123" LastActivityDate="2021-05-15T14:51:32.123" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3445" PostTypeId="2" ParentId="3434" CreationDate="2014-07-25T13:42:25.870" Score="1" Body="&lt;p&gt;The TXled is connected to physical pin 22, or PD5. RXled is connected to pin 8, or PB0. They are connected to the cathode of the led, so they have to be HIGH to turn &lt;strong&gt;off&lt;/strong&gt; the leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn them HIGH use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PORTD |= (1&amp;lt;&amp;lt;PORTD5);&#xA;PORTB |= (1&amp;lt;&amp;lt;PORTB0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure what the firmware does, and if it sets the leds back to low every once and a while. So in addition I would suggest also setting those pins to inputs. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRD &amp;amp;= ~(1&amp;lt;&amp;lt;DDD5);&#xA;DDRB &amp;amp;= ~(1&amp;lt;&amp;lt;DDB0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-25T13:42:25.870" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3446" PostTypeId="1" CreationDate="2014-07-25T15:21:22.110" Score="1" ViewCount="7484" Body="&lt;p&gt;I am new on Arduino, and I am trying to use the Ethernet shield...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but it need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;IP adress&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;MAC adress&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;IP adress is easy to get... but not MAC..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can I get my arduino MAC adress?&lt;/p&gt;&#xA;" OwnerUserId="3313" LastActivityDate="2015-10-12T23:27:37.753" Title="Arduino Mega - get mac adress" Tags="|ethernet|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3447" PostTypeId="2" ParentId="3446" CreationDate="2014-07-25T15:26:59.793" Score="1" Body="&lt;p&gt;Arduino doesn't have a MAC address, your Ethernet adapter shield however will. The MAC address is likely printed on the interface and is constructed from 12 hexadecimal numbers, usually grouped 2 hex digits at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it isn't printed on the box or the shield, then the only way to find out is to connect it to your network, configure a valid IP address on the shield and try to connect to it (eg. ping to the address) from your PC) Then you can list MAC addresses from your PC  with &lt;code&gt;arp -a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or when using dynamic addresses and DHCP, you can find the mac address in you DHCP server (probably your home router).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, you need a sketch on your Arduino to configure an IP address.&lt;/p&gt;&#xA;" OwnerUserId="83" LastEditorUserId="83" LastEditDate="2014-07-25T15:46:08.647" LastActivityDate="2014-07-25T15:46:08.647" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3448" PostTypeId="2" ParentId="3446" CreationDate="2014-07-25T15:36:27.260" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Current Ethernet shields come with a sticker indicating the MAC address you should use with them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoEthernetShield&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-25T15:36:27.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3449" PostTypeId="2" ParentId="3434" CreationDate="2014-07-25T16:17:43.600" Score="7" Body="&lt;p&gt;Reading the answer from Gerben I realised the core of the issue: The TX/RX LED's on the Leonardo are wired PIN-LED-5V(common anode), whereas on the Olimexino-32U4 they are wired PIN-LED-GND(common cathode). So the two boards will need inverse signals for the same visual output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compare:&lt;br&gt;&#xA;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-32U4/resources/OLIMEXINO-32U4_rev_A3.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-32U4/resources/OLIMEXINO-32U4_rev_A3.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The most elegant solution will be to add a new board type (the code below is for IDE 1.0.x):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In your sketchbook create a folder 'hardware' and inside that 'olimexino'. In the olimexino folder create a file boards.txt with this content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;olimexino32u4.name=Olimexino-32U4&#xA;olimexino32u4.upload.protocol=avr109&#xA;olimexino32u4.upload.maximum_size=28672&#xA;olimexino32u4.upload.speed=57600&#xA;olimexino32u4.upload.disable_flushing=true&#xA;olimexino32u4.bootloader.low_fuses=0xff&#xA;olimexino32u4.bootloader.high_fuses=0xd8&#xA;olimexino32u4.bootloader.extended_fuses=0xcb&#xA;olimexino32u4.bootloader.path=caterina&#xA;olimexino32u4.bootloader.file=Caterina-Leonardo.hex&#xA;olimexino32u4.bootloader.unlock_bits=0x3F&#xA;olimexino32u4.bootloader.lock_bits=0x2F&#xA;olimexino32u4.build.mcu=atmega32u4&#xA;olimexino32u4.build.f_cpu=16000000L&#xA;olimexino32u4.build.vid=0x2341&#xA;olimexino32u4.build.pid=0x8036&#xA;olimexino32u4.build.core=arduino:arduino&#xA;olimexino32u4.build.variant=olimexino32u4&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create another folder 'variants' inside the olimexino folder.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Inside that, create the folder 'olimexino32u4'.&lt;/li&gt;&#xA;&lt;li&gt;Now copy 'arduino/hardware/arduino/variants/leonardo/pins_arduino.h' to that folder&lt;/li&gt;&#xA;&lt;li&gt;Open the copy for editing - the path should be 'sketchbook/hardware/olimexino/variants/olimexino32u4/pins_arduino.h'.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change the section that deals with TXLED and RXLED by swapping the macros that end in 1 with those that end in 0. It should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TX_RX_LED_INIT  DDRD |= (1&amp;lt;&amp;lt;5), DDRB |= (1&amp;lt;&amp;lt;0)&#xA;#define TXLED1          PORTD |= (1&amp;lt;&amp;lt;5)&#xA;#define TXLED0          PORTD &amp;amp;= ~(1&amp;lt;&amp;lt;5)&#xA;#define RXLED1          PORTB |= (1&amp;lt;&amp;lt;0)&#xA;#define RXLED0          PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;0)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't own the board so I can't test the solution. I hope that it solves your problem - just choose 'Olimexino-32U4' from the Tools-&gt;Board menu.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-07-25T16:17:43.600" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3450" PostTypeId="2" ParentId="3446" CreationDate="2014-07-25T16:26:11.073" Score="3" Body="&lt;p&gt;A MAC address must be unique throughout the environment in which it operates, but apart from that is largely arbitrary.  Typically the problem is solved by selling 3-octet prefixes (called OUI's) to manufacturers, who then uniquely assign the remaining 3 octets to individual device units they manufacturer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you are unable to discovery a globally unique address assigned to your device by its manufacturer, and know that its traffic will be confined to a local network, you can use a privately assigned (ie, &quot;made up&quot;) address with the &lt;strong&gt;Locally Administered&lt;/strong&gt; bit set.   An address of the form&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;02-xx-xx-xx-xx-xx-xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or any other with the 2's bit of the first octet set will satisfy this criteria as long as you guarantee that it is unique in your system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be especially careful not to set the 1's bit of the first octet - if you do so, traffic will be marked as broadcast and so given wider distribution/attention than needed, wasting network capacity and processor time of connected devices.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-07-25T18:45:50.417" LastActivityDate="2014-07-25T18:45:50.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3451" PostTypeId="1" CreationDate="2014-07-25T20:10:44.563" Score="1" ViewCount="316" Body="&lt;p&gt;I want to drive my model trains (märklin) with my arduino UNO, it requires 32 watt (&lt;code&gt;0-12/24v, 2A MAX(changes)&lt;/code&gt;)&#xA;This is Direct current&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I amplify the output of the arduino to get my 32 watt?&lt;/p&gt;&#xA;" OwnerUserId="3320" LastActivityDate="2014-07-25T21:28:41.353" Title="Arduino amplifier" Tags="|arduino-uno|voltage-level|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3452" PostTypeId="2" ParentId="3451" CreationDate="2014-07-25T20:25:10.247" Score="1" Body="&lt;p&gt;You certainly can. For relatively small amplifications, you can use transistors. MOSFETs are similar and work well for larger solid state amplification. If all you need is to turn power on or off (no switching faster than ~20Hz) a relay is you best bet, but most standard ones take more power than a raw arduino output can provide so you have to buy one for this purpose. They are all easy to use, for the most part just plug in ground, power, signal, and signal out. You can look up any of these for more details on use, it should not be hard to find.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest pre-built solution is something like this relay board: &lt;a href=&quot;http://www.sainsmart.com/arduino-compatibles-1/relay/arduino-pro-mini.html&quot; rel=&quot;nofollow&quot;&gt;http://www.sainsmart.com/arduino-compatibles-1/relay/arduino-pro-mini.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-07-25T20:25:10.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3453" PostTypeId="2" ParentId="3451" CreationDate="2014-07-25T21:28:41.353" Score="0" Body="&lt;p&gt;This company, among others, has a range of drivers, meeting your volt/current/PWM speed control requirements, with good documentation, manual and use examples. &lt;a href=&quot;http://www.pololu.com/category/11/brushed-dc-motor-drivers&quot; rel=&quot;nofollow&quot;&gt;http://www.pololu.com/category/11/brushed-dc-motor-drivers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-25T21:28:41.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3454" PostTypeId="1" CreationDate="2014-07-26T01:53:11.090" Score="1" ViewCount="267" Body="&lt;p&gt;I'm a computer programmer, but I've never done anything with Arduino. I'd like to build something that holds a polisher (this one, in specific: &lt;a href=&quot;http://www.homedepot.com/p/BLACK-DECKER-6-in-Random-Orbit-Waxer-Polisher-WP900/202516385&quot; rel=&quot;nofollow&quot;&gt;http://www.homedepot.com/p/BLACK-DECKER-6-in-Random-Orbit-Waxer-Polisher-WP900/202516385&lt;/a&gt;) on a metal pole, and moves the polisher up and down (vertically) on the pole at varying speeds (I'd like to use arduino to control the motor/speed)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the sort of thing Arduino would be able to do? If so, can anyone point me to any motors that would work? If not, any tips on where else I should look?&lt;/p&gt;&#xA;" OwnerUserId="3321" LastEditorUserId="220" LastEditDate="2014-07-27T18:32:32.860" LastActivityDate="2014-07-27T18:32:32.860" Title="Moving an item on a pole, can an Arduino work for my project?" Tags="|motor|hardware|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3455" PostTypeId="1" CreationDate="2014-07-26T06:49:32.860" Score="0" ViewCount="9891" Body="&lt;p&gt;i am following Jeremy blum's tutorial on youtube. &lt;a href=&quot;http://youtu.be/5bHPKU4ybHY&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt; i have done the exact same circuit design as he has.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/EOjS3.png&quot; alt=&quot;circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the dc motor just makes a continuous beep sound when i run this code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int motorPin = 9;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;    for(int i = 0; i &amp;lt;= 255; i++)&#xA;    {&#xA;        analogWrite(motorPin, i);&#xA;        delay(10);&#xA;    }&#xA;&#xA;    delay(500);&#xA;&#xA;    for(int i = 255; i &amp;gt;= 0; i--)&#xA;    {&#xA;        analogWrite(motorPin, i);&#xA;        delay(10);&#xA;    }&#xA;&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am clueless as to why this is happening. would be glad if someone could help me out here.&lt;/p&gt;&#xA;" OwnerUserId="3191" LastEditorUserId="470" LastEditDate="2014-07-26T08:40:55.603" LastActivityDate="2020-06-01T13:21:14.860" Title="DC motor makes noise but does not rotate" Tags="|programming|motor|sketch|pwm|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3456" PostTypeId="1" AcceptedAnswerId="3459" CreationDate="2014-07-26T11:48:04.553" Score="0" ViewCount="161" Body="&lt;p&gt;I am trying to use the MakeyMakey with the Arduino (not as an Arduino) and then use a USB to TTL module to send the keys pressed to the Arduino. Is this possible? Do I have to reprogram?&lt;/p&gt;&#xA;" OwnerDisplayName="user3076" LastActivityDate="2014-07-26T19:20:09.420" Title="MakeyMakey + Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3457" PostTypeId="2" ParentId="3454" CreationDate="2014-07-26T12:05:24.360" Score="2" Body="&lt;p&gt;I am also a software guy by profession. I've always liked tinkering with electronics, and have recently gotten into Arduino. It is an excellent platform for developing hybrid hardware/software solutions for problems like this. It is very easy to use, both hardware and software. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a large ecosystem of add-ons called &quot;Shields&quot; that just plug in. You can probably find a motor control shield that will do exactly what you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your biggest challenge, I think, is going to be mechanical. How will you hold the polisher in position, and make a mechanism that will raise and lower it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Off the top of my head what I come up with is a U shaped metal bar with a threaded rod in the opening of the U. You'd build a &quot;sled&quot; that would grip the bar and would have teeth that would grip the threaded rod. Then your would have a motor on the end of the assembly that would turn the threaded rod to move the sled up and down on the bar. You'd attach the polisher to the sled. You'd probably need a spring or rubber holder so that the polisher would press gently on the surface being polished but with some freedom of motion.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-26T12:05:24.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3458" PostTypeId="2" ParentId="3439" CreationDate="2014-07-26T14:35:00.000" Score="2" Body="&lt;p&gt;I am the author for the Instructable ethanx94's wiring is based on. It seems like the active and helpful members here have already helped iron things out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone is using the Arduino sketch downloaded from my instructable but is using ethanx94's wiring, do remember to change the SPI SS (Slave Select) pin in the sketch from 10 to 53 to reflect the correct pin used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for the following line in the sketch and change the pin number 10 to 53:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int SPI_CS = 10;// This SPI Chip Select pin controls the MAX7219&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int SPI_CS = 53;// This SPI Chip Select pin controls the MAX7219&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3325" LastEditorUserId="220" LastEditDate="2014-07-26T22:04:42.163" LastActivityDate="2014-07-26T22:04:42.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3459" PostTypeId="2" ParentId="3456" CreationDate="2014-07-26T19:20:09.420" Score="0" Body="&lt;p&gt;one possibility is to use HOST SHIELD &#xA;&lt;a href=&quot;http://www.circuitsathome.com/products-page/arduino-shields&quot; rel=&quot;nofollow&quot;&gt;http://www.circuitsathome.com/products-page/arduino-shields&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is now as host&#xA;Makey is keyboard&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-26T19:20:09.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3460" PostTypeId="2" ParentId="3455" CreationDate="2014-07-26T19:39:44.307" Score="1" Body="&lt;p&gt;analogWrite uses PWM. Is the motor you are using designed for pulsed operation? Try using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(motorPin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-07-26T19:39:44.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3461" PostTypeId="1" AcceptedAnswerId="3607" CreationDate="2014-07-26T21:10:43.403" Score="5" ViewCount="4228" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/bblanchon/ArduinoJson&quot; rel=&quot;noreferrer&quot;&gt;ArduinoJson&lt;/a&gt; library. There is a &lt;a href=&quot;https://github.com/bblanchon/ArduinoJson/blob/master/examples/JsonParserExample/JsonParserExample.ino&quot; rel=&quot;noreferrer&quot;&gt;great example&lt;/a&gt; for parsing a single JSON object in the source code. I am attempting to iterate over an array of JSON objects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;JsonParser.h&amp;gt;&#xA;&#xA;using namespace ArduinoJson::Parser;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  char json[] = &quot;[{\&quot;sensor\&quot;:\&quot;gps\&quot;,\&quot;time\&quot;:1351824120,\&quot;data\&quot;:[48.756080,2.302038]}, \&#xA;    {\&quot;sensor\&quot;:\&quot;gps\&quot;,\&quot;time\&quot;:1351824140,\&quot;data\&quot;:[50.756080,21.302038]}]&quot;;&#xA;&#xA;  JsonParser&amp;lt;32&amp;gt; parser;&#xA;  JsonArray root = parser.parse(json);&#xA;&#xA;  if (!root.success()) {&#xA;    Serial.println(&quot;JsonParser.parse() failed&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  for (JsonArrayIterator item = root.begin(); item != root.end(); ++item) {&#xA;    // unsure of what to do here.&#xA;&#xA;    Serial.println((*item)[&quot;data&quot;]);&#xA;    // results in: &#xA;    // ParseJsonArray:21: error: call of overloaded &#xA;    //   'println(ArduinoJson::Parser::JsonValue)' is ambiguous&#xA;&#xA;    JsonObject something = JsonObject(*item);&#xA;    Serial.println(something[&quot;sensor&quot;]);&#xA;    // results in :&#xA;    // ParseJsonArray:26: error: call of overloaded&#xA;    //   'println(ArduinoJson::Parser::JsonValue)' is ambiguous&#xA;  }&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;item is of type JsonValue. I would like to treat it as a JsonObject and pull some data out of it.&lt;/p&gt;&#xA;" OwnerUserId="3330" LastEditorUserId="220" LastEditDate="2014-07-27T18:24:29.087" LastActivityDate="2016-05-31T11:37:24.087" Title="Parsing JSON on the Arduino" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3462" PostTypeId="1" CreationDate="2014-07-26T22:15:35.370" Score="6" ViewCount="9412" Body="&lt;p&gt;I try to build custom controller and now searching for bluetooth hid module. Which BT HID module compatible with arduino? (not bluetooth serial)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;List of some modules:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;BlueSMiRF HID - from sparkfun, expensive (based on rn-42, also available RN-42-EK evaluation board) ✔ compatible&lt;/li&gt;&#xA;&lt;li&gt;HM-10 bluetooth module - around $10 (aliexpress), based on cc2540 ht&#xA;tp://www.ti.com/product/cc2540&lt;/li&gt;&#xA;&lt;li&gt;HC-05 Transceiver Module  - less $10, maybe supports HID after firmware upgrade(??)&lt;/li&gt;&#xA;&lt;li&gt;Bluegiga wt12&lt;/li&gt;&#xA;&lt;li&gt;Bluefruit EZ-HID from Adafruit ~$20 (suggested by &lt;a href=&quot;https://arduino.stackexchange.com/a/3715/3332&quot;&gt;mwwalk&lt;/a&gt;) ✔ compatible&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="3332" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-22T06:50:14.313" Title="Bluetooth HID module" Tags="|bluetooth|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3463" PostTypeId="1" CreationDate="2014-07-27T04:11:31.753" Score="2" ViewCount="659" Body="&lt;p&gt;I am doing my CBT, and i need help...&lt;br&gt;&#xA;I need a Webservice in C#, and it will send commands to my Arduino( Mega 2560 + Ehternet Shield )...&lt;br&gt;&#xA;My Webservice will recibe commands from Android and Web&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w6oUy.png&quot; alt=&quot;&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanna know what kind of C# WebService Project I have to create...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qm2ax.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3313" LastEditorUserId="3313" LastEditDate="2014-08-01T23:14:19.140" LastActivityDate="2014-08-01T23:14:19.140" Title="Arduino + Web Service" Tags="|arduino-mega|android|web-service|" AnswerCount="0" CommentCount="5" ClosedDate="2014-07-27T05:48:36.180" ContentLicense="CC BY-SA 3.0" />
  <row Id="3464" PostTypeId="1" CreationDate="2014-07-27T07:15:09.877" Score="0" ViewCount="801" Body="&lt;p&gt;I am wondering if its possible to program a board that is developed using SIM900 and GPS module to make http rest calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://stackoverflow.com/questions/23842394/c-c-http-client-library-for-embedded-projects&quot;&gt;this library&lt;/a&gt;. My question is, will I need a microcontroller for this ?&lt;/p&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2017-08-30T08:48:41.353" Title="SIM900 + GPS Module making http rest calls" Tags="|tinygps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3465" PostTypeId="2" ParentId="3455" CreationDate="2014-07-27T10:00:32.380" Score="1" Body="&lt;p&gt;I'm wondering if a 10 ms delay between steps is long enough for the motor to respond, especially with a cap across its terminals.  Besides that the whole thing is over in 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that AnalogWrite generates a PWM signal of about 500hz or about 2ms wave period.  So in 10 ms you get 5 pulses of the same amplitude and smoothed by the cap.  At low values of &quot;i&quot;, say i=10, then the pulse is only 10/255*2ms wide or about 78uS. At low values of i, a 180deg rotation has to occur in the time you apply the pulse for the motor to rotate, well not exactly but close enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most small DC motors are 2 pole, so you're expecting at least one 180degree rotation in 5x78uS or about in 400uS.  That would be a full rotation in about 800uS, say 1mS, or 1000 rotations in 1 second, or 60000rpm, from a standing start if the duty cycle was held constant.  You have very little power at low &quot;i&quot; so I'd be surprised if there is enough to overcome friction and inertia.  On higher values I guess it's still not enough to overcome the inertia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor well may run at the higher values of &quot;i&quot; but then the program immediately counts down again.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I suggest you start the counter at say 125 or even higher. Also make the delay between counting up and counting back down much longer so you can actually see the effect before it counts down again. I would also want to make the delay between counts higher so there is more time for current to flow in the motor's (inductive) windings.  Remember an inductor resists a change in current. Now that I think about it, this is probably more important than the inertia and friction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here is a challenge... Change the delay between counts first, and report your results here.  Then reset that and change a different parameter, and so on. Eventually make a number of changes together...I'm curious to see the outcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I suspect the sound is from the motor laminations changing shape at high frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&#xA;P&lt;/p&gt;&#xA;" OwnerUserId="3335" LastActivityDate="2014-07-27T10:00:32.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3466" PostTypeId="2" ParentId="3226" CreationDate="2014-07-27T13:43:38.503" Score="0" Body="&lt;p&gt;This might be a silly suggestion, but the mega2560 is 5v, and the display is 3.3v...and you need an interface board between.  I have successfully run a 3.2&quot; display using this interface board &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.elecfreaks.com/store/lcd-tft01-arduino-shield-v20-shd09-p-213.html&quot; rel=&quot;nofollow&quot;&gt;http://www.elecfreaks.com/store/lcd-tft01-arduino-shield-v20-shd09-p-213.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps&lt;/p&gt;&#xA;" OwnerUserId="3335" LastActivityDate="2014-07-27T13:43:38.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3468" PostTypeId="2" ParentId="3464" CreationDate="2014-07-27T15:20:05.313" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is, will I need a microcontroller for this ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Yes.&lt;/strong&gt; There are certain things that you need a &quot;man in the middle&quot; to control. Without a microcontroller, how will you tell it what site to visit? How often to send the HTTP request? How to format the HTTP request? Is there any other thing you need this to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People often hope that they can hook up two &lt;strong&gt;complex&lt;/strong&gt; devices that are almost setup to be slaves (like shields, sensors, and outputs) to a microprocessor. Unless the two were specifically designed to work together (or they use a standard, very specific protocol), your chances of building this without a microchip is like trying to build a skyscraper with popsicle sticks. It's possible, but there are cheaper and much easier/more efficient ways to doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Well, they're both SPI/I2C/UART/USB/Serial! Why not?&lt;/em&gt; Well, although we're all humans and we use verbal communication as a protocol, do we all understand each other? Not really... For those protocols, they're designed to have a &quot;master&quot; and a &quot;slave.&quot; A master would be powerful and have control over all the slaves. Hooking a GSM and GPS shield together is like hooking two slave devices together. It's not going to work out (unless you're aiming for blue smoke...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; you trying to mix two things that don't mix. Buy an Arduino Nano clone for $8 and have your circuit actually work.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-27T15:20:05.313" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3469" PostTypeId="2" ParentId="3461" CreationDate="2014-07-27T17:05:59.107" Score="2" Body="&lt;p&gt;Got it! Initially, casting the retrieval of the item from the JsonObject before printing was enough.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;JsonObject something = JsonObject(*item);&#xA;Serial.println((char*)something[&quot;sensor&quot;]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although, I think this looks better.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* sensor = (*item)[&quot;sensor&quot;];&#xA;Serial.println(sensor);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3330" LastEditorUserId="220" LastEditDate="2014-07-27T18:24:48.057" LastActivityDate="2014-07-27T18:24:48.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3470" PostTypeId="1" AcceptedAnswerId="3471" CreationDate="2014-07-27T19:17:28.103" Score="6" ViewCount="7329" Body="&lt;p&gt;I read the following online:&#xA;If you plug in both USB power (say from a pc) and external power via the 2.1mm jack, the Arduino chooses power source automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the external 2.1mm DC is providing greater than 6.6V, the Arduino will take power from it instead of the USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, is this accurate?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, my real question:&#xA;If I am powering my Arduino via external DC, can I still communicate with my Raspberry Pi using serial via the USB?&lt;/p&gt;&#xA;" OwnerUserId="3336" LastActivityDate="2014-07-27T19:41:19.437" Title="Can I use an external power supply and still communicate with my computer over Serial?" Tags="|serial|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3471" PostTypeId="2" ParentId="3470" CreationDate="2014-07-27T19:41:19.437" Score="10" Body="&lt;p&gt;Yes you can. It still leaves the data/ground lines intact, it just doesn't bridge the 5V line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;Arduino Uno Schematic v.3&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wVZoy.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;USBVCC&lt;/code&gt; is directly from the 5V on the USB jack (well, technically there's a fuse there). It then goes through a transistor (&lt;code&gt;T1&lt;/code&gt;) that only allows power through when there is no power coming from the 5V regulator (that regulates the VIN voltage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The USB jack:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ms8IE.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see pin 1 of the USB jack (5V) goes through the fuse to &lt;code&gt;USBVCC&lt;/code&gt;. The next ones &lt;code&gt;D+&lt;/code&gt;/&lt;code&gt;D-&lt;/code&gt; are the data lines that go through resistors to the ATMEGA16U (used for USB to UART). The last one just ties into ground.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-27T19:41:19.437" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3472" PostTypeId="1" AcceptedAnswerId="3473" CreationDate="2014-07-28T02:04:55.107" Score="0" ViewCount="2819" Body="&lt;p&gt;I am using a MPU6050 Accelerometer/Gyro breakout (GY-521) to retrieve data and send it to a java program. I have tried several ways, but I couldn't find a way to send the float values calculated from the Arduino over Serial. Could you please let me know a good way of serial communication with Arduino and a Java Program? Thanks in advance.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;UPDATE&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your comments and replies. What I have tried is the I2Cdev library code. I could work with it without any issue. Code is in this &lt;a href=&quot;http://www.i2cdevlib.com/devices/mpu6050#source&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. I also could run the processing code to get a visual output. But the problem I have i that I'm not able to send the accelerometer and gyro data to a Java/C# program and process it from there. I tried sending an array of FIFO bytes from the Arduino and convert it from the C# code and processing code, but it didn't give me correct results. Now what i did was, just to send a string of values and receive it from the C# program. But I don't know whether it's good method. I would be glad if you could help me in this. Thanks again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef OUTPUT_TEAPOT&#xA;        // display quaternion values in InvenSense Teapot demo format:&#xA;        teapotPacket[2] = fifoBuffer[0];&#xA;        teapotPacket[3] = fifoBuffer[1];&#xA;        teapotPacket[4] = fifoBuffer[4];&#xA;        teapotPacket[5] = fifoBuffer[5];&#xA;        teapotPacket[6] = fifoBuffer[8];&#xA;        teapotPacket[7] = fifoBuffer[9];&#xA;        teapotPacket[8] = fifoBuffer[12];&#xA;        teapotPacket[9] = fifoBuffer[13];&#xA;        Serial.write(teapotPacket, 14); //Serial.write(buf, len)&#xA;        teapotPacket[11]++; // packetCount, loops at 0xFF on purpose&#xA;    #endif&#xA;&#xA;    #ifdef OUTPUT_ACCEL_STR_RAW        &#xA;        mpu.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;        String accelGyroRaw = &quot;STX,&quot;;&#xA;        accelGyroRaw += ax;&#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += ay;&#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += az;&#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += gx;&#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += gy;&#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += gz; &#xA;        accelGyroRaw += ',';&#xA;        accelGyroRaw += &quot;ETX&quot;;&#xA;&#xA;        Serial.println(accelGyroRaw);&#xA;&#xA;    #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C# Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Program&#xA;{&#xA;    static SerialPort port = new SerialPort(&quot;COM7&quot;, 115200);&#xA;    //static int serialCount = 0;&#xA;    //static int aligned = 0;&#xA;    //static char[] teapotPacket = new char[14];&#xA;    //static float[] q = new float[4];&#xA;&#xA;    static void Main(string[] args)&#xA;    {&#xA;&#xA;        Console.WriteLine(&quot;****** Serial Console Read ********&quot;);&#xA;        port.Open();&#xA;        port.DataReceived += port_DataReceived;&#xA;&#xA;        Console.Read();&#xA;    }&#xA;&#xA;    static void port_DataReceived(object sender, SerialDataReceivedEventArgs e)&#xA;    {&#xA;&#xA;        string s = port.ReadLine();&#xA;        string[] accelGyroVals = s.Split(',');&#xA;        string[] accl = new string[3];&#xA;        string[] gyro = new string[3];&#xA;&#xA;        if (accelGyroVals[0] == &quot;STX&quot; &amp;amp;&amp;amp; accelGyroVals[accelGyroVals.Length - 1] == &quot;ETX\r&quot;)&#xA;        {&#xA;            accl[0] = accelGyroVals[1];&#xA;            accl[1] = accelGyroVals[2];&#xA;            accl[2] = accelGyroVals[3];&#xA;&#xA;            gyro[0] = accelGyroVals[4];&#xA;            gyro[1] = accelGyroVals[5];&#xA;            gyro[2] = accelGyroVals[6];&#xA;&#xA;            Console.WriteLine(&quot;a : &quot; + accl[0] + &quot; , &quot; + accl[1] + &quot; , &quot; + accl[2] + &quot;\t g : &quot; + gyro[0] + &quot; , &quot; + gyro[1] + &quot; , &quot; + gyro[2]);&#xA;        }&#xA;&#xA;    }&#xA;&#xA;    static void CurrentDomain_ProcessExit(object sender, EventArgs e)&#xA;    {&#xA;        if (port.IsOpen)&#xA;        {&#xA;            port.Close();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry for this for lengthy code and if my question is unclear. It's my first time to work with an IMU. Thank you. &lt;/p&gt;&#xA;" OwnerUserId="3339" LastEditorUserId="220" LastEditDate="2014-07-28T16:07:02.863" LastActivityDate="2014-12-18T05:46:42.097" Title="Sending MPU6050 data over serial to Java/C# Program" Tags="|serial|programming|arduino-mega|mpu6050|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3473" PostTypeId="2" ParentId="3472" CreationDate="2014-07-28T06:05:31.747" Score="1" Body="&lt;p&gt;You may find RXTX java library helpful.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can format the data (float as calculated at Arduino side) in any mannner that you desire. RXTX library will send the data. It will then up to the Java program (non Arduino side, like PC, etc.) how to interpret the data and extract the values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/interfacing/java&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/interfacing/java&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-28T06:05:31.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3474" PostTypeId="1" CreationDate="2014-07-28T08:27:05.187" Score="1" ViewCount="1007" Body="&lt;p&gt;I am using MPU6050 IMU for getting accelerometer and gyro data. I could read the data using the code from the &lt;a href=&quot;http://www.i2cdevlib.com/devices/mpu6050#source&quot; rel=&quot;nofollow&quot;&gt;I2Cdev library&lt;/a&gt; here, but the problem I have is that I can't use this data in a meaningful manner. As an example I want to define the motion of an object in x,y,z axis using accelerometer data. Although I get a set of values, I can't understand how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I could convert these values to ms&lt;sup&gt;-2&lt;/sup&gt; units, I hope I would be able to achieve this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you provide me some advice, code or reference to work on this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried the code &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050?action=sourceblock&amp;amp;num=1&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; to get the raw values. &lt;/p&gt;&#xA;" OwnerUserId="3339" LastEditorUserId="220" LastEditDate="2014-07-28T16:05:25.113" LastActivityDate="2015-07-24T04:30:37.393" Title="Problem with interpretting and using the IMU data" Tags="|arduino-mega|accelerometer|mpu6050|gyroscope|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3475" PostTypeId="2" ParentId="3474" CreationDate="2014-07-28T08:34:19.160" Score="1" Body="&lt;p&gt;You may want to take a look of freeimu library which take care of all needed processing and present filtered and data-fused data (not just raw data) in easy to use roll, pitch and yaw format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.varesano.net/projects/hardware/FreeIMU&quot; rel=&quot;nofollow&quot;&gt;http://www.varesano.net/projects/hardware/FreeIMU&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see demo video in which the on screen data mirror physical motion of the sensor&#xA;&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;amp;v=rFvX3vZJHTQ&quot; rel=&quot;nofollow&quot;&gt;http://www.youtube.com/watch?feature=player_embedded&amp;amp;v=rFvX3vZJHTQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hope this helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-28T08:34:19.160" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3476" PostTypeId="2" ParentId="847" CreationDate="2014-07-28T09:34:44.347" Score="0" Body="&lt;p&gt;Well I found another way how to make it work, you just need to put CTS from BLE on GND, and RTS open &quot;in the air&quot; and that's it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see these on this link: &lt;a href=&quot;https://bluegiga.zendesk.com/entries/23143152--REFERENCE-Using-or-bypassing-flow-control-with-UART-communication&quot; rel=&quot;nofollow&quot;&gt;https://bluegiga.zendesk.com/entries/23143152--REFERENCE-Using-or-bypassing-flow-control-with-UART-communication&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="744" LastEditorUserId="-1" LastEditDate="2015-08-09T09:33:43.243" LastActivityDate="2015-08-09T09:33:43.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3478" PostTypeId="1" CreationDate="2014-07-28T15:40:07.503" Score="1" ViewCount="2281" Body="&lt;p&gt;I'm working with the Arduino Due ans I used the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// period of pulse accumulation and serial output, milliseconds&#xA;#define MainPeriod 100&#xA;long previousMillis = 0; // will store last time of the cycle end&#xA;volatile unsigned long duration=0; // accumulates pulse width&#xA;volatile unsigned int pulsecount=0;&#xA;volatile unsigned long previousMicros=0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(19200); &#xA;  attachInterrupt(6, myinthandler, RISING);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned long currentMillis = millis();&#xA;  if (currentMillis - previousMillis &amp;gt;= MainPeriod) &#xA;  {&#xA;    previousMillis = currentMillis;   &#xA;    // need to bufferize to avoid glitches&#xA;    unsigned long _duration = duration;&#xA;    unsigned long _pulsecount = pulsecount;&#xA;    duration = 0; // clear counters&#xA;    pulsecount = 0;&#xA;    float Freq = 1e6 / float(_duration);&#xA;    Freq *= _pulsecount; // calculate F&#xA;    // output time and frequency data to RS232&#xA;    Serial.print(currentMillis);&#xA;    Serial.print(&quot; &quot;); // separator!&#xA;    Serial.print(Freq);&#xA;    Serial.print(&quot; &quot;); &#xA;    Serial.print(_pulsecount);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(_duration);&#xA;  }&#xA;}&#xA;&#xA;void myinthandler() // interrupt handler&#xA;{&#xA;  unsigned long currentMicros = micros();&#xA;  duration += currentMicros - previousMicros;&#xA;  previousMicros = currentMicros;&#xA;  pulsecount++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to measure the frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can measure frequencies higher than 1.5kHz accurately, but I can't seem to measure lower frequencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I measure lower frequencies, say 400Hz and above?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="3343" LastEditorUserId="220" LastEditDate="2014-07-28T16:06:25.100" LastActivityDate="2016-01-14T04:10:29.607" Title="Measure square wave frequency" Tags="|programming|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3479" PostTypeId="1" CreationDate="2014-07-28T20:36:53.270" Score="2" ViewCount="66480" Body="&lt;p&gt;I want to have a LED turn on when I push a button and go off when I push the button a second time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 4;    &#xA;const int motorPin =  10;  &#xA;const int ledPin = 6;&#xA; int x = 1;&#xA;// variables will change:&#xA;int buttonState = 0;         &#xA;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(motorPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);   &#xA;  pinMode(ledPin, OUTPUT);  &#xA;}&#xA;&#xA;void loop(){&#xA;  buttonState = digitalRead(buttonPin);&#xA;  if (buttonState == HIGH &amp;amp;&amp;amp; x==1) { &#xA;     digitalWrite(motorPin , 1);&#xA;     x=0;&#xA;    } &#xA;  if (buttonState == HIGH &amp;amp;&amp;amp; x==0){&#xA;    digitalWrite(motorPin, 0);&#xA;    x=1;&#xA;  } &#xA;  delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could be wrong?&lt;/p&gt;&#xA;" OwnerUserId="3346" LastEditorUserId="4628" LastEditDate="2015-11-22T14:53:21.867" LastActivityDate="2020-06-01T07:16:10.620" Title="How to toggle LED on button press?" Tags="|button|" AnswerCount="10" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3480" PostTypeId="1" CreationDate="2014-07-28T20:41:38.197" Score="2" ViewCount="1340" Body="&lt;p&gt;I am working on Fall Detection in humans. A system that would raise alarm when a person falls. For this I plan to use acceleration to see if it is a fall and orientation change to reduce false positives. I was trying to get angle of orientation using gyroscope,accelerometer and magnetometer. According to what I have googled I shouldn't use gyroscope alone as when we integrate to get angle the result is not accurate and I should use sensor fusion and filter using kalman filter or complementary filter. I can't use accelerometer  as during a fall the acceleration won't be only from gravity. I am a newbie so I don't know how to proceed. Correct me if I have understood anything wrong till now.&lt;/p&gt;&#xA;" OwnerUserId="3347" LastActivityDate="2014-08-27T23:25:24.630" Title="How can I implement sensor fusion using a gyroscope and a magnetometer to find the orientation?" Tags="|accelerometer|mpu6050|gyroscope|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3481" PostTypeId="1" CreationDate="2014-07-28T20:47:03.880" Score="0" ViewCount="1568" Body="&lt;p&gt;I am working on a human fall detection system using accelerometer and gyroscope which raises alarm in case of a fall. In all the papers I have read people have used net acceleration magnitude and compared it with a threshold and coupled it with change in orientation to detect fall. My question is would it be better to use acceleration in z-axis(normal to earth's surface) and compare it to threshold as compared to net acceleration as it might reduce false positives as net acceleration can exceed threshold in case of running but that won't happen if i take only acceleration in z-axis. Is my approach right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3480/how-can-i-implement-sensor-fusion-using-a-gyroscope-and-a-magnetometer-to-find-t&quot;&gt;How can I implement sensor fusion using a gyroscope and a magnetometer to find the orientation?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3347" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-07-29T01:02:20.290" Title="How do I proceed with a fall detection sensor?" Tags="|accelerometer|mpu6050|gyroscope|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3482" PostTypeId="2" ParentId="3480" CreationDate="2014-07-28T22:43:15.623" Score="0" Body="&lt;p&gt;Such system, some even has airbag, has been around in university/research/papers for many years.  Presumably, falling means a marked change in 'data values'. One can easily log some data (accel and gyro) by falling on bed and plot the values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May you find some inspiration in followings&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CEMQFjAC&amp;amp;url=http%3A%2F%2Fcourses.daiict.ac.in%2Fmod%2Fresource%2Fview.php%3Fid%3D2430%26redirect%3D1&amp;amp;ei=Ls_WU5-cOob_8QW3v4KoCA&amp;amp;usg=AFQjCNEDUyJKTNYFCi71rX13RMlxoHL8kg&amp;amp;bvm=bv.71778758,d.dGc&quot; rel=&quot;nofollow&quot;&gt;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CEMQFjAC&amp;amp;url=http%3A%2F%2Fcourses.daiict.ac.in%2Fmod%2Fresource%2Fview.php%3Fid%3D2430%26redirect%3D1&amp;amp;ei=Ls_WU5-cOob_8QW3v4KoCA&amp;amp;usg=AFQjCNEDUyJKTNYFCi71rX13RMlxoHL8kg&amp;amp;bvm=bv.71778758,d.dGc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.com/search?q=human+fall+detection+system&amp;amp;safe=off&amp;amp;tbm=vid&amp;amp;source=lnms&amp;amp;sa=X&amp;amp;ei=ps3WU6jGMYyE8gWxo4LYCA&amp;amp;ved=0CAoQ_AUoAw&amp;amp;biw=1577&amp;amp;bih=800&amp;amp;dpr=1#q=elderly+fall+detection+airbag&amp;amp;safe=off&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com/search?q=human+fall+detection+system&amp;amp;safe=off&amp;amp;tbm=vid&amp;amp;source=lnms&amp;amp;sa=X&amp;amp;ei=ps3WU6jGMYyE8gWxo4LYCA&amp;amp;ved=0CAoQ_AUoAw&amp;amp;biw=1577&amp;amp;bih=800&amp;amp;dpr=1#q=elderly+fall+detection+airbag&amp;amp;safe=off&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-28T22:43:15.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3483" PostTypeId="2" ParentId="3479" CreationDate="2014-07-28T23:13:33.637" Score="4" Body="&lt;p&gt;Don't forget to turn ON the LED:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(ledPin, HIGH);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And OFF:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(ledPin, LOW);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2768" LastActivityDate="2014-07-28T23:13:33.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3484" PostTypeId="2" ParentId="3480" CreationDate="2014-07-28T23:16:01.533" Score="1" Body="&lt;p&gt;The magnetometer will be very difficult to use because you have no idea what the local magnetic field will look like around the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gyroscope can help you keep track of angular orientation data during accelerations, but unless you know exactly how this is going to be attached to the human it will not help because you cannot orient the relative angles to the subject. A person can fall with or without rotating in the air as well, so I don't see it helping much anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kalman filters are great, but overkill; you are not doing inertial navigation over long distances, so don't bother. Simple averaging will suffice.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accelerometer should be able to detect falls by itself. The only way it will ever &quot;Zero out&quot; is in freefall, and if that zeroing is long enough and then followed by a very hard acceleration against the direction of gravity (the crash) you can call it a fall. Unless the person has some kind of engine to produce thrust, or is going so fast air resistance is a factor, there will be no accelerations in the air. Simplely calibrating of the threshold for being in freefall, the time necessary to call it a fall, and the necessary strength of the following crash should be able to detect falls or jumps with almost no false positives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance if you want to track short falls where the object is never fully off the ground, a large dip in acceleration data will still be seen, so just set the &quot;zero&quot; threshold high.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-07-28T23:16:01.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3485" PostTypeId="2" ParentId="3481" CreationDate="2014-07-29T01:02:20.290" Score="1" Body="&lt;p&gt;Find the derivative of acceleration over time, also known as &lt;a href=&quot;http://en.wikipedia.org/wiki/Jerk_%28physics%29&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;jerk&lt;/strong&gt;&lt;/a&gt;. Falling will have a specific jerk pattern, whereas normal shaking and banging will have a completely differrent pattern.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-07-29T01:02:20.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3488" PostTypeId="1" CreationDate="2014-07-29T03:56:13.303" Score="3" ViewCount="1057" Body="&lt;p&gt;I am currently trying to communicate between 3 Arduinos using I2C. One of them acts as a master, while the rest act as slaves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can request data correctly from the master. But if I were to do 2 consecutive requests, I will only get data for the last request. Please assist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define BLUNO_SLAVE 0x09&#xA;#define BLUNO_SLAVE_2 0X0A&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  Serial.println(&quot;Initialized as Master&quot;);&#xA;  Serial.println(&quot;Reading from slave 1 now..&quot;);&#xA;  //Wire.beginTransmission(BLUNO_SLAVE);&#xA;  Wire.requestFrom(BLUNO_SLAVE, 25);  //char occupy 1 byte&#xA;  //Wire.endTransmission();&#xA;  Serial.println(&quot;Reading from slave 2 now..&quot;);&#xA;  Wire.requestFrom(BLUNO_SLAVE_2, 30);&#xA;}&#xA;&#xA;void loop () {&#xA;  while(Wire.available()) {&#xA;    char c = Wire.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slave 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin(0x09);  //slave address&#xA;  Serial.println(&quot;Serials initialized&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Wire.onRequest(returnData);&#xA;}&#xA;&#xA;void returnData() {&#xA;  Wire.write(&quot;received master's request&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slave 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin(0x0A);  //slave address&#xA;  Serial.println(&quot;initialized!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Wire.onRequest(returnData);&#xA;}&#xA;&#xA;void returnData() {&#xA;  delay(60000);  //60 * 1000 = 60 seconds&#xA;  Wire.write(&quot;Lat: 103.123456, Lon: 1.098765&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output on the master:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Initialized as Master&#xA;Reading from slave 1 now..&#xA;Reading from slave 2 now..&#xA;Lat: 103.123456, Lon: 1.098765&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On top of that, I do not understand why the 1 minute delay was not executed before the slaves write the GPS coordinates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured out from &lt;a href=&quot;http://playground.arduino.cc/Main/WireLibraryDetailedReference&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/WireLibraryDetailedReference&lt;/a&gt;&#xA;that each call to the &lt;code&gt;requestFrom()&lt;/code&gt; method, RESETS the read buffer. I looked at my code back and I saw a silly mistake on the master code. So, I corrected the master code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define BLUNO_SLAVE 0x09&#xA;#define BLUNO_SLAVE_2 0X0A&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  Serial.println(&quot;Initialized as Master&quot;);&#xA;  Serial.print(&quot;Slave 1: &quot;);&#xA;  Wire.requestFrom(BLUNO_SLAVE, 25);  //char occupy 1 byte&#xA;  readData();&#xA;  //each call to requestFrom, RESETs the read buffer index&#xA;  Serial.println();&#xA;  Serial.print(&quot;Slave 2: &quot;);&#xA;  Wire.requestFrom(BLUNO_SLAVE_2, 30);&#xA;  readData();&#xA;}&#xA;&#xA;void loop () {&#xA;}&#xA;&#xA;void readData () {&#xA;  while(Wire.available()) {&#xA;  char c = Wire.read();&#xA;  Serial.print(c);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But still, I don't understand why slave2 writes the data immediately instead of waiting for 1 minute?&lt;/p&gt;&#xA;" OwnerUserId="3274" LastEditorUserId="4628" LastEditDate="2014-11-27T16:11:37.090" LastActivityDate="2014-11-27T16:11:37.090" Title="Cannot read from 2 I2C slaves consecutively" Tags="|arduino-uno|programming|c++|i2c|c|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3489" PostTypeId="1" CreationDate="2014-07-29T05:35:08.820" Score="1" ViewCount="595" Body="&lt;p&gt;I am using atmega 328pu instead of atmega328p-pu. I am trying to upload the bootloader using AVR pocket programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have changed signature from &lt;code&gt;0x1e 0×95 0x0F&lt;/code&gt; to &lt;code&gt;0x1e 0×95 0×14&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(&lt;a href=&quot;http://www.crash-bang.com/resource/bootload-atmega328/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Relevant link&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/j3vxm.jpg&quot; alt=&quot;circuit diagram&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mw3Zl.jpg&quot; alt=&quot;error report&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="220" LastEditDate="2014-07-30T18:16:29.840" LastActivityDate="2014-07-30T18:16:29.840" Title="arduino boot loader problem" Tags="|arduino-uno|electronics|arduino-duemilanove|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3490" PostTypeId="2" ParentId="3479" CreationDate="2014-07-29T08:23:21.037" Score="2" Body="&lt;p&gt;You are not handling debouncing at all. Mechanical buttons typically bounce for a few milliseconds after an &quot;on&quot; press. Arduino software (or some specialist hardware) needs to handle this. This really matters when you expect a button to toggle some output pin.&lt;/p&gt;&#xA;" OwnerUserId="881" LastEditorUserId="881" LastEditDate="2014-07-29T08:54:54.587" LastActivityDate="2014-07-29T08:54:54.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3491" PostTypeId="2" ParentId="3479" CreationDate="2014-07-29T09:34:34.897" Score="5" Body="&lt;p&gt;At the moment, you've got two main problems. Firstly, both your &lt;code&gt;if&lt;/code&gt; statements are being triggered one after the other. This is because the first &lt;code&gt;if&lt;/code&gt; statement sets &lt;code&gt;x&lt;/code&gt; to 0, which is part of the condition the second &lt;code&gt;if&lt;/code&gt; statement looks for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is that you're not monitoring the previous state of the button. &lt;code&gt;buttonState&lt;/code&gt; will appear &lt;code&gt;HIGH&lt;/code&gt; every time round loop, even if the button has been held down for several seconds. The result is that the output pin will be quickly getting turned on and off all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is store the last known state of the button. On every iteration of the main loop, only respond to the button if it's currently &lt;code&gt;HIGH&lt;/code&gt;, &lt;em&gt;and&lt;/em&gt; if it was &lt;code&gt;LOW&lt;/code&gt; last time round the loop. You also need to make sure your two &lt;code&gt;if&lt;/code&gt; statements are mutually exclusive; i.e. if you trigger one then don't trigger the other by mistake too, or it will cancel it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this should work better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This will store the last known state of the button&#xA;int oldButtonState = LOW;&#xA;&#xA;void loop()&#xA;{&#xA;  // Get the current state of the button&#xA;  int newButtonState = digitalRead(buttonPin);&#xA;&#xA;  // Has the button gone high since we last read it?&#xA;  if (newButtonState == HIGH &amp;amp;&amp;amp; oldButtonState == LOW) {&#xA;&#xA;    if (x == 0) {&#xA;      // Toggle on&#xA;      digitalWrite(ledPin, HIGH);&#xA;      x = 1;&#xA;&#xA;    } else {&#xA;      // Toggle off&#xA;      digitalWrite(ledPin, LOW);&#xA;      x = 0;&#xA;    }&#xA;  }&#xA;&#xA;  // Store the button's state so we can tell if it's changed next time round&#xA;  oldButtonState = newButtonState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As noted elsewhere, you still need to debounce the button, otherwise you're likely to get some false-positives. That can be done in hardware or software. A really simple way to get around it temporarily is to put in a delay of several milliseconds every time you detect the button changing state. It's not perfect, but it might be enough to get you started.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-07-29T09:34:34.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3492" PostTypeId="1" AcceptedAnswerId="3495" CreationDate="2014-07-29T09:37:34.300" Score="2" ViewCount="1149" Body="&lt;p&gt;I am really interested in IoT (enthusiastic noob) and I would like to use the arduino board. Here are the steps according to me, with my queries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;User goes to example.com/arduino_switch&lt;/li&gt;&#xA;&lt;li&gt;Interacts with an HTML form to toggle an action&lt;/li&gt;&#xA;&lt;li&gt;Sends the data over the Internet (This is the part I have problem understanding)&lt;/li&gt;&#xA;&lt;li&gt;Arduino receives the data point (how can we do this? polling a url or can we actively send it)&lt;/li&gt;&#xA;&lt;li&gt;performs the action (easy to do for me)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any and all help will be appreciated, even if its just pointing me to the right resources.&lt;/p&gt;&#xA;" OwnerUserId="3352" LastActivityDate="2014-07-29T13:54:35.080" Title="Arduino Control over the internet" Tags="|arduino-due|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3493" PostTypeId="2" ParentId="3492" CreationDate="2014-07-29T09:57:35.560" Score="3" Body="&lt;p&gt;You have two choices:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Arduino regularly communicates with an external web server, sending data and asking if there is anything to do. This is the way Mitsubishi heatpumps can be controlled from the web. The advantage is that your internet connection does not need to publish a web server. Drawback is that the communication is slow (being dependent on the polling interval), plus the need for a web server to talk to. For instance, to control your Mitsubishi heatpump, you need to create an account on one of their servers for the purpose.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino exposes a web interface that is then exposed to the internet. This needs configuration of your internet router and preferably a static IP address on the internet. Security is a problem, and I'm not sure that even the Due can do HTTPS plus some form of authentication. I used this method, but fronted my Arduino with an old laptop running Linux and Apache web server. The laptop does the authentication and HTTPS processing. Advantage is near real-time control; disadvantage is the amount of hardware and configuration required.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-07-29T09:57:35.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3494" PostTypeId="2" ParentId="3489" CreationDate="2014-07-29T10:23:08.967" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;(Note for the Arduino Uno: you'll need to add a 10 uF capacitor&#xA;  between reset and ground.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-07-29T10:23:08.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3495" PostTypeId="2" ParentId="3492" CreationDate="2014-07-29T13:54:35.080" Score="2" Body="&lt;p&gt;kiwiron has a great answer, but I have a few things to add:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;You don't have to risk security...&lt;/strong&gt; you can create a VPN to your network &lt;em&gt;or&lt;/em&gt; you could just stay inside local LAN. It's just if you want to access it from outside&lt;/li&gt;&#xA;&lt;li&gt;If you can't get a static IP for your network from your ISP, you can use something like &lt;a href=&quot;http://www.noip.com/&quot; rel=&quot;nofollow&quot;&gt;No-IP&lt;/a&gt; to give you a name like &lt;code&gt;example.no-ip.biz&lt;/code&gt; that's easier to remember and it will change the IP when your IP changes. I've used them before...&lt;/li&gt;&#xA;&lt;li&gt;A Raspberry Pi might be a good partner in crime to work with the HTTPS connection with a web server like Nginx and with PHP to run a script. I personally like the Arduino better for interfacing with the actual components since it is 5V and has 40 mA per pin, but it's possible that you could use the GPIO pins on a Pi for your server. This might be a little cheaper since you can remove the ethernet shield and replace that with USB.&lt;/li&gt;&#xA;&lt;li&gt;For the approach of polling a web server, it might be better to have the web server send a GET request to the Arduino and then the Arduino can respond ASAP.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For this, you might want to learn the basics of &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_HTTP_header_fields&quot; rel=&quot;nofollow&quot;&gt;HTTP headers&lt;/a&gt; and try to figure out what goes on behind the scenes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(how can we do this? polling a url or can we actively send it)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Assuming you're using the Arduino directly, here's roughly what would happen:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The client would request the Arduino for the content for the homepage using HTTP requests&lt;/li&gt;&#xA;&lt;li&gt;The Arduino would send the content and close the connection&lt;/li&gt;&#xA;&lt;li&gt;In the HTML there's a little attribute to the form that tells it to send the data via post to &lt;code&gt;response.php&lt;/code&gt;. The client hits &quot;submit&quot; and it sends the data via POST to that URL.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino sees that it's sending data to that URL and reads the data and then process it accordingly. The socket is closed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-29T13:54:35.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3496" PostTypeId="1" CreationDate="2014-07-29T13:43:07.017" Score="2" ViewCount="1661" Body="&lt;p&gt;I bought a CC3000 Wifi Shield from Sparkfun and attached it to Arduino Uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As first thing I tested the board with the board test example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SparkFun CC3000 - Board Test&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CC3000 initialization complete &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Firmware version: 1.24 &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;MAC address: 70:FF:76:01:30:1E &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finished board test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Then I scanned the networks:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SparkFun CC3000 - Scan Test&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CC3000 initialization complete &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Scanning APs. Waiting for scan to complete. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Access Points found:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SSID: dnhm MAC address: 20:AA:4B:08:AA:CC RSSI: 58 Security: WPA2&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;SSID: dnhm-guest MAC address: 20:AA:4B:08:AA:CE RSSI: 58 Security: Unsecured&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finished scan test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I set the SSID and the password and tried to connect:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SparkFun CC3000 - Connection Test&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CC3000 initialization complete &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Connecting to: dnhm &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not connect to AP &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not obtain connection details &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not disconnect from network Finished connection test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SparkFun CC3000 - Connection Test&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CC3000 initialization complete Connecting to: dnhm-guest &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not connect to AP &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not obtain connection details &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not disconnect from network &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finished connection test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It did not connect none of the available connections, I reserved an IP address on the router for the mac address, but nothing changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I turned on logs on the router (Linksys e2500) and nothing appeared in logs as if the device never tried to connect. (I can see relevant logs when I re-connect with my notebook)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use wpa2 so I kept the security setting as it is. I also have a 5ghz SSID and it does not show up in the scan. So I did not try to connect to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried the smart config example with my ipad and it did not work either, the output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SparkFun CC3000 - SmartConfig&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CC3000 initialization complete &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Starting SmartConfig &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Send connection details from app now! &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Waiting to connect… &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not connect with SmartConfig &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not obtain connection details &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Looking up IP address of: www.sparkfun.com &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not lookup host by name &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Pinging 0.0.0.0 3 times… &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: no ping response &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error: Could not disconnect from network &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Finished SmartConfig test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Obviously the board works (It can scan/find the networks), but cant connect them. What should I do as next step to troubleshoot the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sample I used for connection testing: (I double checked the protocol from router's wifi settings to make sure I'm using the correct one)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /****************************************************************&#xA;ConnectionTest.ino&#xA;CC3000 Connection Test&#xA;Shawn Hymel @ SparkFun Electronics&#xA;January 30, 2014&#xA;https://github.com/sparkfun/SFE_CC3000_Library&#xA;&#xA;Connects to the access point given by the SSID and password and&#xA;waits for a DHCP-assigned IP address. To use a static IP&#xA;address, change the #define USE_DHCP from 1 to 0 and assign an&#xA;IP address to static_ip_addr in the Constants section.&#xA;&#xA;NOTE: Static IP is not working at this time.&#xA;&#xA;The security mode is defined by one of the following:&#xA;WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2&#xA;&#xA;Hardware Connections:&#xA;&#xA; Uno Pin    CC3000 Board    Function&#xA;&#xA; +5V        VCC or +5V      5V&#xA; GND        GND             GND&#xA; 2          INT             Interrupt&#xA; 7          EN              WiFi Enable&#xA; 10         CS              SPI Chip Select&#xA; 11         MOSI            SPI MOSI&#xA; 12         MISO            SPI MISO&#xA; 13         SCK             SPI Clock&#xA;&#xA;Resources:&#xA;Include SPI.h and SFE_CC3000.h&#xA;&#xA;Development environment specifics:&#xA;Written in Arduino 1.0.5&#xA;Tested with Arduino UNO R3&#xA;&#xA;This code is beerware; if you see me (or any other SparkFun &#xA;employee) at the local, and you've found our code helpful, please&#xA;buy us a round!&#xA;&#xA;Distributed as-is; no warranty is given.&#xA;****************************************************************/&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000.h&amp;gt;&#xA;&#xA;// Pins&#xA;#define CC3000_INT      2   // Needs to be an interrupt pin (D2/D3)&#xA;#define CC3000_EN       7   // Can be any digital pin&#xA;#define CC3000_CS       10  // Preferred is pin 10 on Uno&#xA;&#xA;// IP address assignment method&#xA;#define USE_DHCP        1   // 0 = static IP, 1 = DHCP&#xA;&#xA;// Connection info data lengths&#xA;#define IP_ADDR_LEN     4   // Length of IP address in bytes&#xA;#define MAC_ADDR_LEN    6   // Length of MAC address in bytes&#xA;&#xA;// Constants&#xA;char ap_ssid[] = &quot;SSID&quot;;                  // SSID of network&#xA;char ap_password[] = &quot;PASSWORD&quot;;          // Password of network&#xA;unsigned int ap_security = WLAN_SEC_WPA2; // Security of network&#xA;unsigned int timeout = 30000;             // Milliseconds&#xA;//const char static_ip_addr[] = &quot;0.0.0.0&quot;;&#xA;&#xA;// Global Variables&#xA;SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);&#xA;&#xA;void setup() {&#xA;&#xA;    ConnectionInfo connection_info;&#xA;    int i;&#xA;&#xA;    // Initialize Serial port&#xA;    Serial.begin(115200);&#xA;    Serial.println();&#xA;    Serial.println(&quot;---------------------------------&quot;);&#xA;    Serial.println(&quot;SparkFun CC3000 - Connection Test&quot;);&#xA;    Serial.println(&quot;---------------------------------&quot;);&#xA;&#xA;    // Initialize CC3000 (configure SPI communications)&#xA;    if ( wifi.init() ) {&#xA;        Serial.println(&quot;CC3000 initialization complete&quot;);&#xA;    } else {&#xA;        Serial.println(&quot;Something went wrong during CC3000 init!&quot;);&#xA;    }&#xA;&#xA;#if (USE_DHCP == 1)&#xA;    // Connect using DHCP&#xA;    Serial.print(&quot;Connecting to: &quot;);&#xA;    Serial.println(ap_ssid);&#xA;    if(!wifi.connect(ap_ssid, ap_security, ap_password, timeout)) {&#xA;        Serial.println(&quot;Error: Could not connect to AP&quot;);&#xA;    }&#xA;#elif (USE_DHCP == 0)&#xA;    // Connect using static IP&#xA;    // ***TODO: Connect using static IP&#xA;#endif&#xA;&#xA;    // Print out connection details&#xA;    if( !wifi.getConnectionInfo(connection_info) ) {&#xA;        Serial.println(&quot;Error: Could not obtain connection details&quot;);&#xA;    } else {&#xA;        Serial.println(&quot;Connected!&quot;);&#xA;        Serial.println();&#xA;&#xA;        // Print MAC address&#xA;        Serial.print(&quot;CC3000 MAC Address: &quot;);&#xA;        for ( i = 0; i &amp;lt; MAC_ADDR_LEN; i++ ) {&#xA;            if ( connection_info.mac_address[i] &amp;lt; 0x10 ) {&#xA;                Serial.print(&quot;0&quot;);&#xA;            }&#xA;            Serial.print(connection_info.mac_address[i], HEX);&#xA;            if ( i &amp;lt; MAC_ADDR_LEN - 1 ) {&#xA;                Serial.print(&quot;:&quot;);&#xA;            }&#xA;        }&#xA;        Serial.println();&#xA;&#xA;        // Print IP Address&#xA;        Serial.print(&quot;IP Address: &quot;);&#xA;        printIPAddr(connection_info.ip_address);&#xA;        Serial.println();&#xA;&#xA;        // Print subnet mask&#xA;        Serial.print(&quot;Subnet Mask: &quot;);&#xA;        printIPAddr(connection_info.subnet_mask);&#xA;        Serial.println();&#xA;&#xA;        // Print default gateway&#xA;        Serial.print(&quot;Default Gateway: &quot;);&#xA;        printIPAddr(connection_info.default_gateway);&#xA;        Serial.println();&#xA;&#xA;        // Print DHCP server address&#xA;        Serial.print(&quot;DHCP Server: &quot;);&#xA;        printIPAddr(connection_info.dhcp_server);&#xA;        Serial.println();&#xA;&#xA;        // Print DNS server address&#xA;        Serial.print(&quot;DNS Server: &quot;);&#xA;        printIPAddr(connection_info.dns_server);&#xA;        Serial.println();&#xA;&#xA;        // Print SSID&#xA;        Serial.print(&quot;SSID: &quot;);&#xA;        Serial.println(connection_info.ssid);&#xA;        Serial.println();&#xA;    }&#xA;&#xA;    // Disconnect&#xA;    if ( wifi.disconnect() ) {&#xA;        Serial.println(&quot;Disconnected&quot;);&#xA;    } else {&#xA;        Serial.println(&quot;Error: Could not disconnect from network&quot;);&#xA;    }&#xA;&#xA;    // Done!&#xA;    Serial.println(&quot;Finished connection test&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // Do nothing&#xA;    delay(1000);&#xA;&#xA;}&#xA;&#xA;// Print out an IP Address in human-readable format&#xA;void printIPAddr(unsigned char ip_addr[]) {&#xA;    int i;&#xA;&#xA;    for (i = 0; i &amp;lt; IP_ADDR_LEN; i++) {&#xA;        Serial.print(ip_addr[i]);&#xA;        if ( i &amp;lt; IP_ADDR_LEN - 1 ) {&#xA;            Serial.print(&quot;.&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3358" OwnerDisplayName="dvdnhm" LastEditorUserId="3358" LastEditDate="2015-01-27T23:53:34.097" LastActivityDate="2015-12-04T18:53:21.547" Title="Connection issues with TI CC3000 &amp; Arduino Uno" Tags="|arduino-uno|wifi|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3497" PostTypeId="1" AcceptedAnswerId="3502" CreationDate="2014-07-29T10:41:38.140" Score="0" ViewCount="911" Body="&lt;p&gt;I am working with Arduino and Android. I am interested in connecting Arduino (Mega 2560 ADK) to my Android tablet (Nexus 7) wirelessly. The chepaest option is via bluetooth but the communication in not reliable. Now I would like to connect it via WiFi. But I don't want to use WiFi shield on my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Arduino can send the information to my laptop via serial USB connection will it be possible to put this information on my home WiFi network and get it on my Android device by connecting it to the same WiFi network?&lt;/p&gt;&#xA;" OwnerUserId="3393" OwnerDisplayName="dreemsp" LastActivityDate="2014-07-29T20:01:01.553" Title="Connecting Arduino Android Wirelessy" Tags="|wifi|android|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3498" PostTypeId="2" ParentId="3489" CreationDate="2014-07-29T14:14:35.900" Score="1" Body="&lt;p&gt;It sounds as if you are using the Arduino IDE to &quot;Upload using Programmer&quot;. If so; in the preferences enable Verbose output for upload. From this you should see all of the avrdude output. Not just the error message. Hopefully with this you will see signature of the chip you actually read. You will also see the full and exact avrdude.exe command that is being executed. Note the path/filename of the avrdude.conf, to ensure it is the one you changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this you can attempt it manually, and tweak it. Try adding the -F to it. Or execute the equivalent to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -b 19200 -p atmega644p -C avrdude.conf -c stk500v1 -P COM4 -n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where the &quot;-n&quot; is &quot;Do not write anything to the device.&quot; just read the signature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer to use a GUI in front of avrdude. &lt;a href=&quot;http://translate.google.com/translate?hl=en&amp;amp;sl=ja&amp;amp;u=http://yuki-lab.jp/hw/avrdude-GUI/&amp;amp;prev=/search%3Fq%3Davrdude%2Bgui%2Byuki%2Blab%26client%3Dfirefox-a%26hs%3DYOU%26rls%3Dorg.mozilla:en-US:official%26channel%3Dsb&quot; rel=&quot;nofollow&quot;&gt;Yuki's GUI&lt;/a&gt; is a good example. Just need to point it to the EXE and have a copy of the conf file in the same directory.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I should mention the Arduino way of doing this, is to create a new boards.txt file with this chip and add (not change) the avrdude.conf file. This will allow programing either from selecting the correct board. but that is another subject.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-07-29T14:14:35.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3500" PostTypeId="1" CreationDate="2014-07-29T18:26:05.983" Score="2" ViewCount="9874" Body="&lt;p&gt;I am trying to communicate with my Arduino Duemilanove via an RS232 cord. I simply want to be able to send a byte (or char) to my Arduino from a desktop application.  The Arduino is plugging into USB COM5 on my computer.  I have the RS232 plugged into COM1, and then I have pins 2, 3 and 5 on the other end of the RS232 connected to Arduino pins TX, RX, and GND, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a serial comm class for C++ at the following link: &lt;a href=&quot;http://playground.arduino.cc/Interfacing/CPPWindows&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino and C++ (for Windows)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have added the .h and .cpp files from the above example as &lt;code&gt;Serial.h&lt;/code&gt; and &lt;code&gt;Serial.cpp&lt;/code&gt; (I think the example uses &lt;code&gt;SerialClass.h&lt;/code&gt; and &lt;code&gt;SerialClass.cpp&lt;/code&gt;, I just changes the names).  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On my Arduino, I have the following code running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ARDUINO&#xA;char incomingByte = 0;&#xA;&#xA;void setup() {&#xA;        Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;        // send data only when you receive data:&#xA;        if (Serial.available() &amp;gt; 0) {&#xA;                // read the incoming byte:&#xA;                incomingByte = Serial.read();&#xA;&#xA;                // say what you got:&#xA;                Serial.print(&quot;I received: &quot;);&#xA;                Serial.println(incomingByte, HEX);&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And my C++ program is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// C++&#xA;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;Windows.h&amp;gt;&#xA;#include &quot;Serial.h&quot;&#xA;&#xA;using namespace std;&#xA;&#xA;int main(void)&#xA;{&#xA;    Serial port(&quot;COM1&quot;);&#xA;&#xA;    char* msg = &quot;Hello Arduino!&quot;;&#xA;    int msgLen = strlen(msg);&#xA;    bool writeSuccess = port.WriteData(msg, msgLen);&#xA;&#xA;    cout &amp;lt;&amp;lt; &quot;\n\n&quot;;&#xA;    system(&quot;PAUSE&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When I use the Arduino's serial port viewer to see what is bring printed, I'm getting very strange values that don't match what I'm sending (as far as I can tell).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I send &quot;Hello Arduino!&quot;, the arduino prints the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I received: FFFFFFAB&#xA;I received: 3A&#xA;I received: 3A&#xA;I received: A&#xA;I received: FFFFFFFA&#xA;I received: FFFFFFEB&#xA;I received: 6D&#xA;I received: 37&#xA;I received: 15&#xA;I received: 2D&#xA;I received: 23&#xA;I received: 21&#xA;I received: FFFFFFBD&#xA;I received: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not appear to be the correct hex for &quot;Hello Arduino!&quot;, but I have no idea why it's not correct.  Does anyone have any clue what I'm doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="3360" OwnerDisplayName="user50333" LastEditorUserId="6936" LastEditDate="2017-06-04T08:34:05.577" LastActivityDate="2018-07-31T12:02:10.220" Title="Serial communication between PC and Arduino via RS232 using C++" Tags="|serial|c++|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3501" PostTypeId="2" ParentId="3478" CreationDate="2014-07-29T19:52:09.837" Score="1" Body="&lt;p&gt;It seems you have a problem of concurrent access to &lt;code&gt;duration&lt;/code&gt; and &lt;code&gt;pulsecount&lt;/code&gt; variables which are inter-related; with your code, it is possible that (and I guarantee that it will):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;loop()&lt;/code&gt; reads &lt;code&gt;duration&lt;/code&gt; value (in line &lt;code&gt;unsigned long _duration = _duration;&lt;/code&gt;) but gets interrupted before executing the next line&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;myinthandler()&lt;/code&gt; changes both &lt;code&gt;duration&lt;/code&gt; and &lt;code&gt;pulsecount&lt;/code&gt; (it cannot be interrupted as it is already triggered by an interrupt)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;loop()&lt;/code&gt; proceeds to where it was interrupted (after &lt;code&gt;myinthandler()&lt;/code&gt; returns) and executes line &lt;code&gt;unsigned long _pulsecount = pulsecount;&lt;/code&gt;: the values in &lt;code&gt;_duration&lt;/code&gt; and &lt;code&gt;_pulsecount&lt;/code&gt; do not match anymore!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To protect the access to &lt;code&gt;pulsecount&lt;/code&gt; and &lt;code&gt;duration&lt;/code&gt; variables, you have to disable interrupts inside &lt;code&gt;loop()&lt;/code&gt; just for the time you get their values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    ...&#xA;    // Disable interrupts while we get and reset duration and pulsecount&#xA;    cli();&#xA;    unsigned long _duration = duration;&#xA;    unsigned long _pulsecount = pulsecount;&#xA;    duration = 0; // clear counters&#xA;    pulsecount = 0;&#xA;    // Now we can re-enable interrupts again&#xA;    sei();&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-07-29T19:52:09.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3502" PostTypeId="2" ParentId="3497" CreationDate="2014-07-29T20:01:01.553" Score="0" Body="&lt;p&gt;Yes, if the laptop and tablet are on the same network communication will be possible. One way to implement this would be to have a client/server setup that communicates over TCP/IP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The laptop can act as a TCP/IP server and also communicate through the serial interface to your arduino. Many languages will be able to do this, Java, C/C++, Python, whatever you're comfortable with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The android tablet can then connect to the TCP/IP server as a client and send and receive data through your WiFi. Have a look at &lt;a href=&quot;http://developer.android.com/reference/java/net/Socket.html&quot; rel=&quot;nofollow&quot;&gt;the android documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would a simple solution but for a more permanent solution you could also setup a web server on your laptop, look into the apache webserver. Your tablet would be able to communicate with the web server through http requests. The web server can then start further scripts to send data to the arduino or maintain a serial connection depending on your implementation.&lt;/p&gt;&#xA;" OwnerUserId="1407" LastActivityDate="2014-07-29T20:01:01.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3504" PostTypeId="1" CreationDate="2014-07-29T20:35:31.990" Score="2" ViewCount="2043" Body="&lt;p&gt;Background: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been working on an exoskeleton project with a group of friends, and I need help.  I made another post on the robotics.stackexchange site for the drive system: &lt;a href=&quot;https://robotics.stackexchange.com/questions/4323/exoskeleton-drive-system-help&quot;&gt;https://robotics.stackexchange.com/questions/4323/exoskeleton-drive-system-help&lt;/a&gt;.  You can also check out our first prototype on youtube: &lt;a href=&quot;https://www.youtube.com/watch?v=NL_aCwJSRiE&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=NL_aCwJSRiE&amp;amp;feature=youtu.be&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device is going to be controlled by an iPad that we created via bluetooth.  We are using the adafruit bluefruitLE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are attempting to control 4 motors (2 knee motors and 2 hip motors) from an Arduino Mega.  We will be using 2 Roboclaw 2x60A motor controllers.  We are trying to get the motors to mimic the graph (see attached).&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/uF1fw.jpg&quot; alt=&quot;Gait Graph&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The graph is in degrees per percent cycle (a gait cycle).  We are using 50 gait cycles per minute for tests but we hope to make it adjustable.&lt;br&gt;&#xA;We can change percent cycle to time in milliseconds using dimensional analysis (ie) 50 cycles/min = 8.333x10^-4 cycles/ms  —-&gt;  1/8.333x10^-4 cycles/ms is approx. 1200 ms/cycle.  So if you multiply the cycle times 1200 you get millisecond for a certain percent of the cycle (ie) 0.5cycles(50 percent of cycle) * 1200ms/cycle = 600 ms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We will have a position feedback system incorporated in the drive system but because it is a prototype and I wanted to make the code as versatile as posible I created a function: getDegrees(int jointNum), so if I change the position feedback system I only have to change the getDegrees method.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to mimic the graph we broke the graph up into sections.  Each section represents a different velocity.  We are going to run a correction algorithm so far we have just done the P in PID, we have used a modifier of 1.5.  Then we saved the value that the section ended on so next gait cycle when it runs that section the algorithm will start off closer to the target value.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help developing a strategy in order to sync the movement of the 4 joints while running a correction algorithm on each joint individually.  While the device is running we need to be able to constantly check for a bluetooth message from the iPad.  The bluetooth messages come in via SPI from the adafruit bluefruitLE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been able to run a single joint by using a while statement (ie) &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i = 0;&#xA;void loop(){&#xA;targetAngle = nextAngle[i]; //nextAngle is an array of points so nextAngle[0] through nextAngle[1] represents one section of the graph.&#xA;i++&#xA;if (getDegrees(1)&amp;lt; targetAngle){&#xA;double deg = getDegrees(1);&#xA;while (deg&amp;lt;targetAngle){&#xA;/*&#xA;*&#xA;*Execute drive code&#xA;*&#xA;*/&#xA;deg = getDegrees(1);&#xA;}else{&#xA;double deg = getDegrees(1);&#xA;while (deg&amp;gt;targetAngle){&#xA;/*&#xA;*&#xA;*Execute drive code&#xA;*&#xA;*/&#xA;deg = getDegrees(1);&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main problem with that code is its like using the delay() function instead of millis() is that it stops the program while its executing the code, and I cannot run multiple motors and check for bluetooth messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Major Challenges:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The drive commands must be based off of angle and not time.  It is ok if we tell it do 50 cycles per minute and it does 52 or 48 but its not okay if it only does 97% of the motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible solutions I have come up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using one arduino for each joint, and making them all slaves of a master arduino and the master arduino would act as the middle man sort of between the joints, making sure that they are synced up.  That way each arduino could use code similar to what I have already tried and confirmed to work.  But I would prefer to run it all from one arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help developing a strategy in order to sync the movement of the 4 joints while running a correction algorithm on each joint individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the right forum for this question?  Or is it more of a Stack Overflow or Robotics question?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be greatly appreciated,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--  Joel&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="-1" LastEditDate="2017-04-13T12:49:17.743" LastActivityDate="2014-07-30T03:36:24.240" Title="Exoskeleton Motor Control Code" Tags="|programming|motor|sketch|system-design|algorithm|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3505" PostTypeId="2" ParentId="501" CreationDate="2014-07-29T21:27:01.000" Score="6" Body="&lt;p&gt;It's tricky when you only have a small hole to work with, so trying to get inside to install a series of floats or contact pins on the side is not ideal. The ultrasonic is a good idea, but I don't know how that would be achieved. Personally, I would try the cable, as it is simple enough to drop it in the hole, and wait for your results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to try running a cable through it, you might want to use this &lt;a href=&quot;http://vegetronix.com/Products/AquaPlumb/&quot; rel=&quot;nofollow&quot;&gt;Water Level Sensor&lt;/a&gt;, or at least base your own project on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is non-corrosive, and has no moving parts, which is supposed to lead to a heightened accuracy, and less chance of it failing or breaking down. The enclosure is water-proof, and you can buy one with a relay attached to fit your monitoring needs. The only issue that I see is that it isn't wireless, but other than that, it seems to be pretty functional.  &lt;/p&gt;&#xA;" OwnerUserId="3362" LastEditorUserId="3452" LastEditDate="2014-08-12T15:42:04.747" LastActivityDate="2014-08-12T15:42:04.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3506" PostTypeId="2" ParentId="3414" CreationDate="2014-07-29T22:50:16.877" Score="0" Body="&lt;p&gt;Simple answer: No, it isn't bad practice at all. I write with pointers all the time. Pointer referencing usually compiles to more efficient code than does array referencing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But:&#xA;It looks like you've confused a pointer with the thing it is supposed to point to. The member you call 'buffer' is declared as pointer to unsigned byte. It doesn't appear to get initialized anywhere; it should be initialized with the address of an array of unsigned bytes (at least) as large as your ring buffer needs to be. I don't see this in anywhere in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have described, the buffer could be allocated at run time with malloc() (but it's best not to save malloc() &amp;amp; free() for things you &lt;em&gt;have to&lt;/em&gt; create and destroy on the fly; or direct the compiler to allocate it before your program gets control, with something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RINGBUFSIZE 32&#xA;&#xA;uint8_t ring_buffer_memory[RINGBUFSIZE];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and initialize your pointer to it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;r-&amp;gt;buffer = ring_buffer_memory;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will initialize your pointer to the first of (in this case) 32 bytes of zeroed memory reserved for the ring buffer. In your code, it's quite likely the pointer contains &lt;code&gt;0&lt;/code&gt;, thus pointing to memory location zero and is definitely not what you mean to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A word on variable names - adopt a convention for naming your variables that help a future reader (probably you!) understand/remember what that variable is for. In this case I'd probably use &lt;code&gt;ringBuf&lt;/code&gt; for the array, and &lt;code&gt;pRingBuf&lt;/code&gt; for its pointer. As a new reader of this code, I'd find it pretty inconvenient to have to have to remember that &lt;code&gt;buffer&lt;/code&gt; is really a pointer (and what the heck was the buffer called!?).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-07-31T00:59:24.300" LastActivityDate="2014-07-31T00:59:24.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3507" PostTypeId="1" CreationDate="2014-07-29T23:23:41.277" Score="5" ViewCount="1416" Body="&lt;p&gt;I'm new to the Arduino Yun and I'm trying to convert a sketch written for the Arduino Uno with a Ethernet Shield. The sketch does HTTP posts to Azure Mobile Services.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added in the &lt;code&gt;Bridge.h&lt;/code&gt; and &lt;code&gt;YunClient.h&lt;/code&gt; libraries in place of the &lt;code&gt;Ethernet.h&lt;/code&gt; one for the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My modified sketch compiles, however, I don't think the http posts are working. I don't see my table updating in Azure.&#xA;&#xA;    /*&#xA;    ** This sample Arduino sketch uploads telemetry data to Azure Mobile Services&#xA;    ** See the full article here: &lt;a href=&quot;http://hypernephelist.com/2014/07/11/arduino-uno-azure-mobile-services.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hypernephelist.com/2014/07/11/arduino-uno-azure-mobile-services.html&lt;/a&gt;&#xA;    **&#xA;    ** Thomas Conté @tomconte&#xA;    */&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;//#include &amp;lt;Ethernet.h&amp;gt; // removed as not used by Yun&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// not sure if these libraries are required?&#xA;#include &amp;lt;HttpClient.h&amp;gt;&#xA;#include &amp;lt;Process.h&amp;gt;&#xA;&#xA;// Ethernet shield MAC address (sticker in the back)&#xA;//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;// 90:A2:DA:F8:28:38&#xA;&#xA;// Azure Mobile Service address&#xA;// You can find this in your service dashboard&#xA;const char *server = &quot;myhost.azure-mobile.net&quot;;&#xA;&#xA;// Azure Mobile Service table name&#xA;// The name of the table you created&#xA;const char *table_name = &quot;my_data&quot;;&#xA;&#xA;// Azure Mobile Service Application Key&#xA;// You can find this key in the 'Manage Keys' menu on the dashboard&#xA;const char *ams_key = &quot;HJRxFXXXXXXXXXXXXXXXXXXXNQoMcXXXXXXx99&quot;;&#xA;&#xA;//EthernetClient client;&#xA;YunClient client;&#xA;&#xA;char buffer[64];&#xA;&#xA;/*&#xA;** Send an HTTP POST request to the Azure Mobile Service data API&#xA;*/&#xA;&#xA;void send_request(int value)&#xA;{&#xA;  Serial.println(&quot;\nconnecting...&quot;);&#xA;&#xA;    Serial.print(&quot;sending &quot;);&#xA;    Serial.println(value);&#xA;&#xA;    // POST URI&#xA;    sprintf(buffer, &quot;POST /tables/%s HTTP/1.1&quot;, table_name);&#xA;    client.println(buffer);&#xA;&#xA;    // Host header&#xA;    sprintf(buffer, &quot;Host: %s&quot;, server);&#xA;    client.println(buffer);&#xA;&#xA;    // Azure Mobile Services application key&#xA;    sprintf(buffer, &quot;X-ZUMO-APPLICATION: %s&quot;, ams_key);&#xA;    client.println(buffer);&#xA;&#xA;    // JSON content type&#xA;    client.println(&quot;Content-Type: application/json&quot;);&#xA;&#xA;    // POST body&#xA;    sprintf(buffer, &quot;{\&quot;value\&quot;: %d}&quot;, value);&#xA;&#xA;    // Content length&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(strlen(buffer));&#xA;&#xA;    // End of headers&#xA;    client.println();&#xA;&#xA;    // Request body&#xA;    client.println(buffer);&#xA;&#xA;}&#xA;&#xA;/*&#xA;** Wait for response&#xA;*/&#xA;&#xA;void wait_response()&#xA;{&#xA;  while (!client.available()) {&#xA;    if (!client.connected()) {&#xA;      return;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;/*&#xA;** Read the response and dump to serial&#xA;*/&#xA;&#xA;void read_response()&#xA;{&#xA;  bool print = true;&#xA;&#xA;  while (client.available()) {&#xA;    char c = client.read();&#xA;    // Print only until the first carriage return&#xA;    if (c == '\n')&#xA;      print = false;&#xA;    if (print)&#xA;      Serial.print(c);&#xA;  }&#xA;}&#xA;&#xA;/*&#xA;** Close the connection&#xA;*/&#xA;&#xA;void end_request()&#xA;{&#xA;  client.stop();&#xA;}&#xA;&#xA;/*&#xA;** Arduino Setup&#xA;*/&#xA;&#xA;void setup()&#xA;{&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;Starting Bridge&quot;);&#xA;Bridge.begin();&#xA;&#xA;}&#xA;&#xA;/*&#xA;** Arduino Loop&#xA;*/&#xA;&#xA;void loop()&#xA;{&#xA;  int val = analogRead(A0);&#xA;&#xA;  send_request(val);&#xA;  wait_response();&#xA;  read_response();&#xA;  end_request();&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3364" LastEditorUserId="37523" LastEditDate="2019-05-10T17:38:18.477" LastActivityDate="2021-08-29T08:04:25.420" Title="Converting Arduino Uno with Ethernet Shield sketch for Arduino Yún" Tags="|arduino-yun|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="3508" PostTypeId="1" AcceptedAnswerId="3509" CreationDate="2014-07-30T01:22:05.183" Score="2" ViewCount="850" Body="&lt;p&gt;The arduino website states that the operating voltage of an arduino is 7-12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does the arduino work powered on just usb then? As usb only outputs 5V and 500ma.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it preferable to say run the arduino on an external 9V dc power source, or does it make no difference?&lt;/p&gt;&#xA;" OwnerUserId="3336" LastActivityDate="2014-07-30T01:29:50.240" Title="Why does arduino work on usb power?" Tags="|power|voltage-level|electricity|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3509" PostTypeId="2" ParentId="3508" CreationDate="2014-07-30T01:29:50.240" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The arduino website states that the operating voltage of an arduino is 7-12V.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's when it goes through the voltage regulator. It's a &lt;em&gt;linear regulator&lt;/em&gt;, meaning it wastes a lot of power as heat. The regulator outputs 5V that's given to the MCU. The USB voltage bypasses the regulator and goes to a fuse before going to the common 5V for the board. If less than 7V is given to the regulator, it will produce less than 5V.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it preferable to say run the arduino on an external 9V dc power source, or does it make no difference?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Usually, yes. A 9V supply would give you more than 500ma, giving you flexibility to add higher current components like motors and lots of LEDs. It will make no difference if you have a single LED connected.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-30T01:29:50.240" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3510" PostTypeId="2" ParentId="3504" CreationDate="2014-07-30T02:01:30.883" Score="1" Body="&lt;p&gt;Here's what I came up with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You have a certain percent of the gain cycle equal one &quot;step&quot; (step may be a bad term in this situation, but I'm using it because of stepper motors).&lt;/li&gt;&#xA;&lt;li&gt;You have a &lt;strong&gt;blocking&lt;/strong&gt; function that will move the motors and control all the P(ID) logic&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before this function is called, the main code will use a variable to store the desired time to do the next &quot;step.&quot;&lt;/li&gt;&#xA;&lt;li&gt;It will have a loop with &quot;substeps.&quot; So it would look kinda like this:&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void function nextStep(int var1, int var2) {&#xA;    //Read sensors and put into variables&#xA;    until(condition == true) { //Condition to see if the motors are at the right degree&#xA;        //Adjust motors not in the right place&#xA;        delayAndCheckBT(10); //Look at the bottom for this function&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also have it accept a few percent of variance as tolerance so it's not shakey, but that's more of the PID control than anything. You'll have to make sure that many 'steps' doesn't make the PID controller unstable.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When that code is done, the main function will check to see if the desired time for the next step has passed (or if it's now). If it's passed/now, then it will execute. Otherwise, it will not execute the next step and continue executing the main loop.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Great? No. The problem is you need to check for bluetooth! To do this, I've made two functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void checkBT() {&#xA;    //Checks BT. Make sure this is non blocking: if you need to, set a few global variables&#xA;    //Note this code will get called a LOT, so don't implement any delays or loops: inside here: use millis().&#xA;}&#xA;void delayAndCheckBT(int timeToWait) {&#xA;    unsigned long finishTime = millis() + timeToWait;&#xA;    while (millis()&amp;lt;finishTime) {&#xA;        checkBT();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-30T02:01:30.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3511" PostTypeId="2" ParentId="3504" CreationDate="2014-07-30T03:36:24.240" Score="2" Body="&lt;p&gt;As your question &quot;to sync the movement of the 4 joints while running a correction algorithm on each joint individually.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Referring to the first part of your question&lt;/strong&gt;, &lt;strong&gt;sync&lt;/strong&gt; the movement, assume your are doing this at either commercial or university project level, &lt;strong&gt;popular practice&lt;/strong&gt; is to use 'hard real time preemptive operating system&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RTOS, real time operating system, is a piece of system software that coordinates execution of your multi thread user software at &lt;strong&gt;precise and predictable&lt;/strong&gt; time accuracy in order of millisecond. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;RTOS involve money and learning time. You may want to continue using the simpler system that you already having now and work in just one joint, hence, no issue of syncing multiple joints. Once you reach some maturity on single joint, then, expand to syncing 4 joints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RTOS can be commercial with full support or free of charge. Some are dual mode. Same software may either be free or if you choose, can buy commercial full support. There are simple and full-scale implementations where functionality, complexity, learning time and software cost (commercial  or free) varies by huge extend. You will then be more able to choose when you done the above single joint system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Introduction &lt;a href=&quot;http://en.wikipedia.org/wiki/RTOS&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/RTOS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also real time 'executive' (smaller and less functions). For example, ucos II (older and simple version) is used by many people.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-30T03:36:24.240" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3512" PostTypeId="1" CreationDate="2014-07-30T05:06:50.277" Score="2" ViewCount="1022" Body="&lt;p&gt;I am using below sensor (accelerometer) .My application is a solar tracker, where I wanted to convert the sensor output into +70° to -70° format. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I convert the angle?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADC_ref 2.56&#xA;#define zero_x 1.569&#xA;#define zero_y 1.569    &#xA;#define zero_z 1.569    &#xA;#define sensitivity_x 0.3    &#xA;#define sensitivity_y 0.3    &#xA;#define sensitivity_z 0.3&#xA;&#xA;unsigned int value_x;&#xA;unsigned int value_y;&#xA;unsigned int value_z;&#xA;&#xA;float xv;&#xA;float yv;&#xA;float zv;&#xA;&#xA;float angle_x;&#xA;float angle_y;&#xA;float angle_z;&#xA;&#xA;void setup() {    &#xA;  //analogReference(INTERNAL2V56);    &#xA;  Serial.begin(9600);    &#xA;}&#xA;&#xA;void loop() {    &#xA;  value_x = analogRead(A0);&#xA;&#xA;//  value_y = analogRead(A1);&#xA;  //value_z = analogRead(A2);&#xA;&#xA;  Serial.print(&quot;voltage  of x&quot;);&#xA;  Serial.println(value_x);&#xA;  /*Serial.print(&quot;voltage  of y&quot;);&#xA;   Serial.println(value_y);&#xA;   Serial.print(&quot;voltage  of z&quot;);&#xA;   Serial.println(value_z);&#xA;   */&#xA;  //xv=(value_x/1024.0*2.5)/sensitivity_x;&#xA;/*  zv=(value_z/1024.0*ADC_ref-zero_z)/sensitivity_z;&#xA;  yv=(value_y/1024.0*ADC_ref-zero_y)/sensitivity_y;&#xA;  xv=(0.0032226562499999998*value_x)/sensitivity_x;&#xA;  angle_x =atan2(-yv,-zv)*57.2957795+90;&#xA;&#xA;  Serial.print (&quot;x= &quot;);&#xA;  Serial.println (xv);&#xA;  Serial.print(&quot;x_degree= &quot;);&#xA;  Serial.print(angle_x);&#xA;  Serial.println(&quot; deg&quot;);    &#xA;&#xA;  /*Serial.print(&quot; g &quot;);       &#xA;&#xA;   Serial.print (&quot;y= &quot;);&#xA;   Serial.print (yv);&#xA;   Serial.print(&quot; g &quot;);&#xA;&#xA;&#xA;&#xA;   Serial.print (&quot;z= &quot;);&#xA;   Serial.print (zv);&#xA;   Serial.print(&quot; g &quot;);&#xA;&#xA;   Serial.print(&quot;\n&quot;);&#xA;&#xA;   Serial.print(&quot;Rotation &quot;);&#xA;&#xA;   Serial.print(&quot;x= &quot;);&#xA;&#xA;   angle_x =atan2(-yv,-zv)*57.2957795+180;&#xA;&#xA;   Serial.print(angle_x);&#xA;   Serial.print(&quot; deg&quot;);&#xA;   Serial.print(&quot; &quot;);&#xA;&#xA;   Serial.print(&quot;y= &quot;);&#xA;&#xA;   angle_y =atan2(-xv,-zv)*57.2957795+180;&#xA;&#xA;   Serial.print(angle_y);&#xA;   Serial.print(&quot; deg&quot;);&#xA;   Serial.print(&quot; &quot;);&#xA;&#xA;   Serial.print(&quot;z= &quot;);&#xA;&#xA;   angle_z =atan2(-yv,-xv)*57.2957795+180;&#xA;&#xA;   Serial.print(angle_z);&#xA;   Serial.print(&quot; deg&quot;);&#xA;   Serial.print(&quot;\n&quot;);&#xA;   */&#xA;  delay(1000);&#xA;  //delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.ebay.in/itm/ADXL335-analog-3-axis-Accelerometer-Module-For-Arduino-MEGA-AVR-PIC-Etc-/331259252773?pt=LH_DefaultDomain_203&amp;amp;hash=item4d20971025&amp;amp;_uhb=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Description&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/SMD/adxl335.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Datasheet of ADXL335&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have inclinometer off the shelf its V&lt;sub&gt;out&lt;/sub&gt; is 0~5&amp;nbsp;V and angle measure from -70° to 70°, and I calculated as below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void calcPos()&#xA;{    &#xA;  Sensor_Value=analogRead(A3); &#xA;  voltage = Sensor_Value * ARDUINO_ANALOG_SCALING;&#xA;  tracker_actual_pos=(30*voltage)-75;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="6936" LastEditDate="2017-06-04T08:29:41.960" LastActivityDate="2018-07-01T18:37:53.093" Title="Analog angle conversion from +70° to -70°" Tags="|arduino-uno|sensors|accelerometer|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3513" PostTypeId="2" ParentId="3489" CreationDate="2014-07-30T06:00:11.367" Score="1" Body="&lt;p&gt;This sounds like the programmer is not seeing the ATMega328 MCU, or the Arduino IDE is not seeing the programmer. Changing the signature won't be of any help as the IDE (or AVRDude) is not seeing the ATmega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest that you double-check your connections, and set the options in the IDE to verbose output - then repost the info here.&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-07-30T06:00:11.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3514" PostTypeId="1" AcceptedAnswerId="3515" CreationDate="2014-07-30T06:42:37.403" Score="0" ViewCount="344" Body="&lt;p&gt;It's kind of hard to get full guide from the internet. I just wanna buy a book for UAV guide. I gotta make DIY drones. I'd appreciat it if you recommend good books.&lt;/p&gt;&#xA;" OwnerUserId="3310" LastEditorUserId="37" LastEditDate="2014-07-30T12:38:03.030" LastActivityDate="2014-07-30T12:38:03.030" Title="Can anyone tell me the best books for studying UAV?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ClosedDate="2014-07-30T12:39:03.617" ContentLicense="CC BY-SA 3.0" />
  <row Id="3515" PostTypeId="2" ParentId="3514" CreationDate="2014-07-30T06:54:17.997" Score="0" Body="&lt;p&gt;Not a book, but try the following course from EdX, the online MOOC:&#xA;&lt;a href=&quot;https://www.edx.org/course/tumx/tumx-autonavx-autonomous-navigation-1658&quot; rel=&quot;nofollow&quot;&gt;https://www.edx.org/course/tumx/tumx-autonavx-autonomous-navigation-1658&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-07-30T06:54:17.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3516" PostTypeId="2" ParentId="1371" CreationDate="2014-07-30T07:56:23.673" Score="0" Body="&lt;p&gt;It seems that the jaydeep might have been building my circuit and  used the provided code: &lt;a href=&quot;http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/step4/Arduino-controlled-light-dimmer-The-software/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/step4/Arduino-controlled-light-dimmer-The-software/&lt;/a&gt;&#xA;so obviously this problem has my interest.&#xA;With regard to the 'dimming' variable, that will not go beyond 128 so I might as well have used 'byte'  to define it.&#xA;The IR remote library is I presume that of Ken Shirrif and that one uses the Timer2 interrupt. In principle, combining those two interrupts shouldnt necessarily cause a problem as I have done so as well (in using the timer interrupt rather than 'delay to trigger the TRIAC).&#xA;But in that case the entire timer interrupt was handled within the period of  the mains wavelength (100 or 83 ms depending on frequency).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don’t think the access to the 'dimming' variable -as jfpoilpret mentions- is the problem (though he makes some sound remarks), as that will just remain as is for a specific  light level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem -as  is also suggested above- might well be in the fact that the IR receive takes too long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... disregarding interrupt priority for a moment, if the code is hanging around in the timer interrupt routine and there is a zerocrossing, that won't be detected, or, if the code is just doing a zero crossing detection, the timer is  screwed up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In comes interrupt priority: The external interrupt has the highest priority (other than reset). So.. when  the IR receive routine is busy in the Timer service routine and a zerocrossing arrives, it will be taken out of that routine, zerocrossing will be handled and ideally, it should continue with the timer routine again.&#xA;However, your remote has no idea what is going on in the Arduino and some of the code sent will be missed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;all of this shouldn’t need to be a problem if the external interrupt was fast, but as most of the waiting is actually done within this interrupt, it could take up to almost 10mS/8.3mS (when 'dimming' approaches 128).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution?&#xA;Well, I can't say much about the Timer2 interrupts in Ken's library, But on 'my side' of the software, what could be done is to shorten the external interrupt by removing the delays and use (yet another) timer interrupt.&#xA;Ken uses Timer2, so this would have to be timer1.&#xA;So, whenever there is a zerocross, there is no waiting in a delay, but it will be handled by timer1&#xA;An example is given in &lt;a href=&quot;http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/step6/Arduino-controlled-light-dimmer-The-software-III/&quot; rel=&quot;nofollow&quot;&gt;Step 6 of my instructable&lt;/a&gt;. There is no guarantee this will work but there is a good chance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me just point out that the basic  program I supplied was just given as an example, It uses much computer time in waiting and therefore isn’t the best to combine with other actions of the processor.&lt;/p&gt;&#xA;" OwnerUserId="3367" LastActivityDate="2014-07-30T07:56:23.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3517" PostTypeId="1" AcceptedAnswerId="3547" CreationDate="2014-07-30T07:59:50.990" Score="3" ViewCount="563" Body="&lt;p&gt;I am building a small wireless controlled robot using the Arduino and the raspberry pi. It works by the user wirelessly connecting through to the raspberry Pi (using vnc or some other form wirelessly) and using the user inputs to send a command to the Arduino which controls the motorised wheels. SO for example if the user presses the up button, a 'W&quot; command is sent from the Raspberry Pi to the Arduino which then reads it and pushes the wheels forward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was looking to use one of the new Arduino-Raspberry Pi bridges to connect the two to make it easier to use, but I am not too familiar on how they work. Had a few question such as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How exactly do they work (connection wise)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) is it possible to write one python code in the raspberry pi that when run can load the specific ino code into arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) which bridge would be the most suited for my project? (eg: Arduberry, alamode, gertduino, etc?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry really new to the raspberry pi and need to find a solution soon so any help would be awesome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="1529" LastActivityDate="2014-07-31T08:22:38.847" Title="Raspberry pi -Arduino bridge" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3518" PostTypeId="2" ParentId="3517" CreationDate="2014-07-30T09:00:55.003" Score="0" Body="&lt;p&gt;Have you thought about using the Raspberry Pi to control the robot directly, instead of adding the complexity of having the Pi talk to the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python allows you to control the GPIO pins of the Pi, and as long as you connect a suitable motor driver (to protect your Pi), you should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to connect the Pi to the Arduino, then you could also look at doing this using Serial communications and wouldn't need the complexity of a bridge - just need a logic-level converter to convert the 5V of the Arduino to the 3.3v of the Pi&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-07-30T09:00:55.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3519" PostTypeId="1" CreationDate="2014-07-30T10:40:54.903" Score="2" ViewCount="531" Body="&lt;p&gt;Having recently entered the world of Arduino I am seeking to make, as my first project, a ball that will sense my dogs approach and roll away. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can handle the rolling part but I have been unable to find a sensor that will work when fully embedded in the ball (so the dog cannot bite or swallow it). This means no ultrasound or infra red or normal proximity sensor will do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best bet - an inductive proximity sensor (with a metal object attached to dog's collar) is only effective at a maximum distance of 8 cm and that is far too little. I need something that activates at say 1 foot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas anyone?&lt;/p&gt;&#xA;" OwnerUserId="3368" LastActivityDate="2014-08-02T00:02:50.100" Title="Need a sensor to make ball roll away from pet but which sensor?" Tags="|sensors|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3520" PostTypeId="2" ParentId="3519" CreationDate="2014-07-30T11:02:42.290" Score="0" Body="&lt;p&gt;Interesting.  You may want to consider using strong,small, modern rare earth, low cost (silver color) magnetic that can work up to 1 foot, depending on size and shape of magnetic. Test different size/shape mag with simple mechanical compass to check the distance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to use one of those popular sensor board with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) MPUxxxx (3D accel to sensor gravity in 3D to know which way is up and down)&#xA;b) 3D magnetic sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both sensors are 3D and you know which direction the dog is coming (direction and mag strength, changed from background earth magnetic field when dog is coming, gives distance) and which 3D orientation of the ball is and hence to calculate which way to move a weight inside the ball to make the roll. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Biological disclaimer, no idea if dog health may be affected, positively or negatively (people sells human magnetic collar with health claim), by constant, 24 hours, magnetic collar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-30T11:02:42.290" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3521" PostTypeId="1" CreationDate="2014-07-25T07:51:53.067" Score="0" ViewCount="1004" Body="&lt;p&gt;I am trying to write a class/function that I think I will be using often in my Arduino IDE, I know the code but where should i save the file so that the IDE picks it up without a full directory address in the #include line, as you may guess I'm a little new to this....&lt;/p&gt;&#xA;" OwnerUserId="3311" OwnerDisplayName="user2331041" LastActivityDate="2015-01-26T15:27:32.353" Title="file directory for saving .cpp &amp; .h for the Arduino IDE for short #include statement" Tags="|c++|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3522" PostTypeId="2" ParentId="3519" CreationDate="2014-07-30T11:14:46.880" Score="1" Body="&lt;p&gt;Perhaps an RFID tag on your dogs collar and a reader inside the ball will work.&#xA;You will just have to find a reader and tag combination that can work from the range you need, I think some RFID can work from over 1ft.&#xA;EDIT: You will need active tags (battery powered) to get over a foot range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PIR sensors detect heat given off by humans and animals, so they make work through the ball. (not totally sure though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: i think PIR that is capable of detecting small animals may be your best bet you would just have to calibrate the range of detection some how &lt;/p&gt;&#xA;" OwnerUserId="3336" LastEditorUserId="3336" LastEditDate="2014-08-02T00:02:50.100" LastActivityDate="2014-08-02T00:02:50.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3523" PostTypeId="2" ParentId="790" CreationDate="2014-07-30T12:09:33.727" Score="-1" Body="&lt;p&gt;Add the module as software serial then add these lines to setup() these line tell us the Bluetooth to turn into data mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bluetooth.begin(115200);&#xA;bluetooth.print(&quot;$$$&quot;);&#xA;delay(100);&#xA;bluetooth.println(&quot;U,9600,N&quot;);&#xA;bluetooth.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3369" LastEditorUserId="37" LastEditDate="2014-07-30T12:28:15.033" LastActivityDate="2014-07-30T12:28:15.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3524" PostTypeId="1" AcceptedAnswerId="3530" CreationDate="2014-07-30T12:17:00.790" Score="1" ViewCount="78" Body="&lt;p&gt;I've taken apart an &lt;a href=&quot;https://plus.google.com/111652317143259686566/posts/75TraxED8bg&quot; rel=&quot;nofollow&quot;&gt;old range finder (see photo here)&lt;/a&gt;. It uses a circular, seemingly gold-plated, two-wire sensor that I'd like to re-use in an Arduino project.&#xA;I'm looking for a datasheet of the sensor and/or a circuit-diagram. Any help is welcome.﻿&lt;/p&gt;&#xA;" OwnerUserId="2812" LastActivityDate="2014-07-30T14:24:30.783" Title="What is this component? (range finder)" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3525" PostTypeId="2" ParentId="3519" CreationDate="2014-07-30T13:25:24.430" Score="0" Body="&lt;p&gt;Idea 1: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put a transceiver in the dogs collar, and one in the ball. Monitor the RSSI (received signal strength). If it goes above a threshold, roll away. Adjust the threshold to set the correct distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Idea 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put an accelerometer inside the ball. Whenever it detects a knock (dog's paw etc) roll away for a few seconds.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-07-30T13:25:24.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3526" PostTypeId="2" ParentId="3521" CreationDate="2014-07-30T13:28:05.573" Score="1" Body="&lt;p&gt;If you think you will be reusing this code frequently, you might want to make a library as suggested by Joachim. Your library can then be added to any sketch you write using a &lt;code&gt;#include&lt;/code&gt; statement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino website has a nice guide on writing libraries, check it out &lt;a href=&quot;http://arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would just like to include your header file in a sketch without writing a library, placing the header file in the same directory as your sketch should compile if you use &lt;code&gt;#include &quot;header_file_name.h&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1407" LastActivityDate="2014-07-30T13:28:05.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3527" PostTypeId="1" CreationDate="2014-07-30T13:40:21.997" Score="2" ViewCount="713" Body="&lt;p&gt;I am getting back into doing some hardware stuff after a fairly long time away and am having a hard time getting back into it. I have a &lt;a href=&quot;https://www.pjrc.com/teensy/pinout2b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Teensy 2.0&lt;/a&gt; and am trying to run a basic sketch that when a button is pressed will output 0, but my button is always High. I think that I miswired something but my breadboard looks like all the tutorials so I'm just confused as to what is going on and would appreciate any help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pinBtnUp = 0;&#xA;const int pinLEDOutput = 11;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(38400);&#xA;&#xA;  //Setup the pin modes.&#xA;  pinMode( pinLEDOutput, OUTPUT );&#xA;  //Special for the Teensy is the INPUT_PULLUP&#xA;  //It enables a pullup resitor on the pin.&#xA;  pinMode( pinBtnUp, INPUT_PULLUP );&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(digitalRead(pinBtnUp));  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HO3lS.jpg&quot; alt=&quot;Breadboard&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3371" LastActivityDate="2014-07-30T14:08:48.150" Title="Simply Button Problem (Teensy 2.0)" Tags="|button|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3528" PostTypeId="2" ParentId="3527" CreationDate="2014-07-30T13:59:34.370" Score="2" Body="&lt;p&gt;You would need to place your button over the &quot;valley&quot; in the centre of the breadboard, separating teh top 2 and bottom 2 legs of the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently the wire connecting the button to Pin 0 on your teensy is also connected to your pullup resistor on the breadboard, as it is in the same row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To help troubleshoot this kind of thing I always find a digital multimeter very useful.&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-07-30T13:59:34.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3529" PostTypeId="2" ParentId="3527" CreationDate="2014-07-30T14:08:48.150" Score="2" Body="&lt;p&gt;You should post a higher quality version next time.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Wiring:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First of all, the button looks like it's not all the way in. Fix that first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, from your picture, it looks like the green wire isn't in the right row:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eHMZl.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't tell for sure. Also, like mentioned before, you to put the button over the gap between the two sides of the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you have a pullup resistor in your circuit &lt;em&gt;and&lt;/em&gt; you enable it on the Arduino. And your physical pullup resistor isn't connected to your signal line. And you short your signal line to ground. All of this is incorrect wiring...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If utilizing the internal pullup resistor (like you are in your code), all you should need to do for a circuit is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fLDxJ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just be sure to connect the 5V rail to 5V and the green wire to your digital pin.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Code:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;That's all fine. When doing logic with a button, be sure to &lt;em&gt;debounce&lt;/em&gt; it.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-07-30T14:08:48.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3530" PostTypeId="2" ParentId="3524" CreationDate="2014-07-30T14:24:30.783" Score="1" Body="&lt;p&gt;The big circular parts likely is ultrasonic transducer as used in instant camera. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.uoxray.uoregon.edu/polamod/&quot; rel=&quot;nofollow&quot;&gt;http://www.uoxray.uoregon.edu/polamod/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.com/?gws_rd=ssl#q=polaroid+ultrasonic+ranging+module&amp;amp;revid=399558007&amp;amp;safe=off&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com/?gws_rd=ssl#q=polaroid+ultrasonic+ranging+module&amp;amp;revid=399558007&amp;amp;safe=off&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working principle is same as modern unit, easily available at a few US dollars. The transducer does NOT work by itself, needs the associate PCB to work.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-07-30T14:24:30.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3531" PostTypeId="1" CreationDate="2014-07-30T15:39:07.580" Score="3" ViewCount="3546" Body="&lt;p&gt;Trying to modify the native mouse methods so that it can use absolute, rather than the relative values it currently uses. This is so it can function as a touch screen pointer, and NOT a mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am using this modified HID.cpp file here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/nospam2000/Arduino/commit/7b77d1e84d7b80819f049e5fd6e7bafa0d06521f#diff-0dd97502971c8a55546092b93abd32caR349&quot; rel=&quot;nofollow&quot;&gt;https://github.com/nospam2000/Arduino/commit/7b77d1e84d7b80819f049e5fd6e7bafa0d06521f#diff-0dd97502971c8a55546092b93abd32caR349&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly works, but the author has mapped to the maximum and minimum possible int values, (-32768 to 32767) and no matter what permutation of values I use with the native map method, I can't get it to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone wrestled with this problem and has a solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since posting found another possible solution &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,94140.0.html&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,94140.0.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However with this solution the mouse movements are WAY too coarse for any monitor with a resolution above 100x100. Tried changing the LOGICAL_MAXIMUM value in HID.cpp but that alone doesn't work. Any C++ gurus possibly able to have a look?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going back to the first solution this is the map method calls I am using, which should theoretically work!. TAR_WIDTH is the horizontal display resolution of my target monitor. TAR_HEIGHT is the vertical display resolution&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xPos2= map(xPos, 0, TAR_WIDTH, -32768, 32767);&#xA;yPos2= map(yPos, 0, TAR_HEIGHT, -32768, 32767);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What happens is that when the x value is roughly -2800 or less than, I've reached the left edge of my monitor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ditto for y, when less than or equal to -2800, I've reached the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving to the right and or down, once I reach roughly a value of 5000, x, OR y, the mouse wraps back to the left or top edge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This value of 5000 represents only about 2/3 the width of my target monitor so I'm never able to fully map my mouse movement. Make sense?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in summary, if I use solution1, I need to figure out how to fully map to my monitor. If solution 2, the movement is too coarse(and the mouseclick doesn't work).&lt;/p&gt;&#xA;" OwnerUserId="765" LastEditorUserId="765" LastEditDate="2014-07-30T20:02:30.217" LastActivityDate="2015-03-30T07:54:03.703" Title="Using Leonardo and getting absolute x,y Mouse values" Tags="|arduino-leonardo|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3532" PostTypeId="2" ParentId="3519" CreationDate="2014-07-30T16:04:37.700" Score="0" Body="&lt;p&gt;Other than the answers above/below, you also could try infra-red lights and photosensitive transistors. However, that has some troubles, such as not working properly in the sunlight, or the material that the ball is made of blocking the light, and therefore not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVOID MAGNETS! You could get your dog stuck in some metal, like a fridge. To get one working in such distance, you would need an awfully powered magnet, which could be strong enough to permanently impact circuitry in close range, such as a home theater which sits close to the ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, how are you going to fit it all in a ball that is bite-sized? i'm actually interested in that. Aren't you worried of the dog munching it and breaking/swallowing circuits?&lt;/p&gt;&#xA;" OwnerUserId="3374" LastActivityDate="2014-07-30T16:04:37.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3533" PostTypeId="1" CreationDate="2014-07-30T16:34:34.550" Score="2" ViewCount="505" Body="&lt;p&gt;I am trying to control an RGB LED strip with an Arduino. I have followed the tutorials in both of these websites: &lt;br/&gt;&#xA;Using MOSFETs: &lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips?view=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/rgb-led-strips?view=all&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZTJij.gif&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;br/&gt;&#xA;Using LED Amplifiers: &lt;a href=&quot;http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Jt91f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;br/&gt;&#xA;I have tried both setups and none of them work for me. When I try the setup with the MOSFETs, I am able to control each color but the blue LEDs are dimmer than the red and green, and therefore I can't mix any colors with blue.&#xA;&lt;br/&gt;&lt;br/&gt;&#xA;When I try the LED Amplifiers, I am not able to control any light at all. Only the blue LEDs light up but the red and green dont. Also the blue LEDs stay ON the whole time and the only way to turn them off is to disconnect them from the DC power source. &lt;br/&gt;&lt;br/&gt;&#xA;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="3375" LastActivityDate="2015-03-19T14:53:33.967" Title="RGB LED strip with Arduino" Tags="|arduino-uno|led|mosfet|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2015-05-02T15:28:42.763" ContentLicense="CC BY-SA 3.0" />
  <row Id="3535" PostTypeId="1" CreationDate="2014-07-29T23:06:42.333" Score="4" ViewCount="17835" Body="&lt;p&gt;I am trying to control an RGB LED strip with an Arduino. I have followed the tutorials in both of these websites: &lt;br/&gt;&#xA;Using MOSFETs: &lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips?view=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/rgb-led-strips?view=all&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZTJij.gif&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;br/&gt;&#xA;Using LED Amplifiers: &lt;a href=&quot;http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/LED-Strip-Controller-w-LED-Amp-Arduino/&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Jt91f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;br/&gt;&#xA;I have tried both setups and none of them work for me. When I try the setup with the MOSFETs, I am able to control each color but the blue LEDs are dimmer than the red and green, and therefore I can't mix any colors with blue.&#xA;&lt;br/&gt;&lt;br/&gt;&#xA;When I try the LED Amplifiers, I am not able to control any light at all. Only the blue LEDs light up but the red and green dont. Also the blue LEDs stay ON the whole time and the only way to turn them off is to disconnect them from the DC power source. &lt;br/&gt;&lt;br/&gt;&#xA;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="3375" OwnerDisplayName="lomas09" LastActivityDate="2015-05-06T17:15:32.507" Title="RGB LED Strips with Arduino" Tags="|mosfet|" AnswerCount="4" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3536" PostTypeId="2" ParentId="3535" CreationDate="2014-07-30T00:29:04.487" Score="0" Body="&lt;p&gt;From the drawings in that instructable, you need the Arduino ground and the 12 volt ground connected together - perhaps the line you have marked &quot;+3v or 5v&quot; should really be ground?&lt;/p&gt;&#xA;" OwnerUserId="1498" OwnerDisplayName="Peter Bennett" LastActivityDate="2014-07-30T00:29:04.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3537" PostTypeId="2" ParentId="3535" CreationDate="2014-07-30T21:02:04.367" Score="2" Body="&lt;p&gt;For the mosfet circuit. Are you using an external power supply? The reason why you cannot mix any color might be due to the fact that you're not providing enough current to the led strip, so it just work fine when turning on each channel individually. Check the current the led strip draws (which usually is provided as amp per channel per meter) and use a power supply that can provide enough current for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the adafuit page&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Connect a 9-12V power supply to the Arduino so that Vin supplies the high voltage to the LED strip. If you want, you can also just use a separate wire that connects to a power supply that provides about +12V. Make sure to connect the ground of that supply to the ground of the Arduino/MOSFETs!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7945" OwnerDisplayName="cagnarrogna" LastActivityDate="2014-07-30T21:02:04.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3538" PostTypeId="1" CreationDate="2014-07-30T21:42:14.537" Score="1" ViewCount="1981" Body="&lt;p&gt;I want to learn AVR C programming instead of arduino programming. I have an arduino UNO board and few Atmega328 chips that I bought, and Atmel studio for programming. Can I use Arduino Uno board as programmer to flash the chips from Atmel Studio? Or any other alternatives?&lt;/p&gt;&#xA;" OwnerUserId="3382" LastEditorDisplayName="user4236" LastEditDate="2015-07-08T13:23:43.167" LastActivityDate="2015-07-08T13:23:43.167" Title="Using Arduino to learn AVR programming" Tags="|arduino-uno|avr|programmer|atmel-studio|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3539" PostTypeId="1" AcceptedAnswerId="3544" CreationDate="2014-07-30T23:54:30.127" Score="3" ViewCount="11824" Body="&lt;p&gt;I made a super simple arduino uno sketch to send a serial byte once every second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;   Serial.write(12); // send a byte with the value 12&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My arduino is hooked up to com 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other end of the line, I have a C++ program with the following read function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Serial::ReadData(char *buffer, unsigned int nbChar)&#xA;{&#xA;    //Number of bytes we'll have read&#xA;    DWORD bytesRead;&#xA;    //Number of bytes we'll really ask to read&#xA;    unsigned int toRead;&#xA;&#xA;    //Use the ClearCommError function to get status info on the Serial port&#xA;    ClearCommError(this-&amp;gt;hSerial, &amp;amp;this-&amp;gt;errors, &amp;amp;this-&amp;gt;status);&#xA;&#xA;    //Check if there is something to read&#xA;    if(this-&amp;gt;status.cbInQue&amp;gt;0)&#xA;    {&#xA;        //If there is we check if there is enough data to read the required number&#xA;        //of characters, if not we'll read only the available characters to prevent&#xA;        //locking of the application.&#xA;        if(this-&amp;gt;status.cbInQue&amp;gt;nbChar)&#xA;        {&#xA;            toRead = nbChar;&#xA;        }&#xA;        else&#xA;        {&#xA;            toRead = this-&amp;gt;status.cbInQue;&#xA;        }&#xA;&#xA;        //Try to read the require number of chars, and return the number of read bytes on success&#xA;        if(ReadFile(this-&amp;gt;hSerial, buffer, toRead, &amp;amp;bytesRead, NULL) &amp;amp;&amp;amp; bytesRead != 0)&#xA;        {&#xA;            return bytesRead;&#xA;        }&#xA;&#xA;    }&#xA;&#xA;    //If nothing has been read, or that an error was detected return -1&#xA;    return -1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to check only one time if data is available, so obviously I have to loop through it until data comes in.  I did that in my main program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Serial.h&quot;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;&#xA;using namespace std;&#xA;&#xA;int main(void)&#xA;{&#xA;    Serial serial(&quot;COM3&quot;);&#xA;&#xA;    char* c = &quot;&quot;;&#xA;    int len = strlen(c);&#xA;    while(c == &quot;&quot;)&#xA;    {&#xA;        serial.ReadData(c, len);&#xA;    }&#xA;&#xA;    cout &amp;lt;&amp;lt; &quot;\n\n&quot;;&#xA;    system(&quot;PAUSE&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I do this, my C++ program gets stuck in an infinite loop waiting for data from the arduino, and I cannot figure out why this is happening.  My program never sees the data the arduino is sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This Serial class works and is configured properly because I can SEND all the data I want to the arduino without any problems.  My issues are only with reading back from the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me figure out why this is not working?&lt;/p&gt;&#xA;" OwnerUserId="3386" LastEditorUserId="37523" LastEditDate="2020-02-14T23:45:10.760" LastActivityDate="2020-02-14T23:45:10.760" Title="Why can't this C++ program read my arduino's Serial.write()?" Tags="|arduino-uno|serial|c++|strlen|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3542" PostTypeId="2" ParentId="3538" CreationDate="2014-07-31T00:52:28.220" Score="1" Body="&lt;p&gt;If your chips have a bootloader already installed in them, you can use any USB -&gt; Serial cable (FTDI cable) to program them in-circuit on their Rx/Tx pins. If not, you can use the Uno to program a boot loader into them (one time) and program them with the cable from then on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use standard C, you can use the bare chips or the UNO. You'll want a different environment than the Arduino IDE, though. That can be anything from an editor, the the gnu compiler tools run from a command line, to almost any other IDE. A number of people, myself included, use the Eclipse IDE with an AVR plug-in and do almost everything from writing the code to programming the AVR from within it. (I say 'almost' only because I personally prefer a full-blown programming editor, run outside of the IDE, for initial creation of sizeable projects or major edits and rewrites. That isn't necessary, though).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-07-31T00:52:28.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3543" PostTypeId="1" CreationDate="2014-07-31T02:49:08.423" Score="2" ViewCount="117" Body="&lt;p&gt;I have a program where the Arduino acts as an Ethernet Server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The client continuously sends packets which is of the following format&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start Byte=0x7E;&#xA;Some Data/Command Bytes;      //Can be of varying length&#xA;End Byte=0x7A;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some packets take more time to process than others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is what is the best way to read the bytes of the memory so that we always work on one packet at a time.I can read in data from the buffer one at a time and loop through till the &lt;code&gt;END BYTE&lt;/code&gt; is reached but it doesn't seem a very efficient way to get the packets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be interested if someone has better ideas on how to read in packets one at a time from the buffer in the most efficient way possible.&lt;/p&gt;&#xA;" OwnerUserId="3389" LastActivityDate="2014-07-31T02:49:08.423" Title="Best way to process data received by EthernetServer" Tags="|ethernet|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3544" PostTypeId="2" ParentId="3539" CreationDate="2014-07-31T05:21:39.027" Score="7" Body="&lt;p&gt;The problem is in your C++ program at the other end of the line (not the Arduino side):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* c = &quot;&quot;;&#xA;int len = strlen(c);&#xA;while(c == &quot;&quot;)&#xA;{&#xA;    serial.ReadData(c, len);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, &lt;code&gt;len&lt;/code&gt; is zero because that is the length of &quot;&quot; , the empty string! Thus, in your loop, you ask &lt;code&gt;ReadData&lt;/code&gt; to read 0 bytes. Hence, the condition of your &lt;code&gt;while&lt;/code&gt; loop is always true as, &lt;code&gt;c&lt;/code&gt; never changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;code&gt;while&lt;/code&gt; condition seems incorrect as it is not recommended in C++ to compare 2 strings (defines as &lt;code&gt;char *&lt;/code&gt; or &lt;code&gt;char [...]&lt;/code&gt;) with &lt;code&gt;==&lt;/code&gt;. In your situation, what is important is the number of characters read by &lt;code&gt;ReadData&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c[LEN + 1];&#xA;int numBytes = 0;&#xA;while(true)&#xA;{&#xA;    numBytes = serial.ReadData(c, LEN);&#xA;    if (numBytes != -1)&#xA;    {&#xA;        // Terminate the string if we want to use c variable as a string&#xA;        c[numBytes] = 0;&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the code above, &lt;code&gt;LEN&lt;/code&gt; is the number of characters you want to read at one time, in you example it should be set to 1, either as a &lt;code&gt;#define&lt;/code&gt; or as a &lt;code&gt;const&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// either:&#xA;#define LEN 1&#xA;// or:&#xA;const int LEN = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above also ensures that &lt;code&gt;c&lt;/code&gt; can be used as a normal string, by adding a &lt;code&gt;0&lt;/code&gt; at the end. This is mandatory only if you want to use string functions on &lt;code&gt;c&lt;/code&gt; such as &lt;code&gt;strlen&lt;/code&gt;, &lt;code&gt;strcpy&lt;/code&gt;, &lt;code&gt;strchr&lt;/code&gt;... otherwise &lt;code&gt;numBytes&lt;/code&gt; is enough to manage the number of characters read into &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-07-31T05:59:05.990" LastActivityDate="2014-07-31T05:59:05.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3545" PostTypeId="2" ParentId="3538" CreationDate="2014-07-31T06:23:18.783" Score="1" Body="&lt;p&gt;If you're starting out then Atmel Studio is a good option - it's very easy to install and get up and running, and I use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use an Arduino as an ISP you're going to need to use AVRDude.  You can configure Atmel Studio to flash chips using AVRDude - I struggled with this but eventually got it working, you can look &lt;a href=&quot;http://www.crash-bang.com/using-usbtiny-with-atmelstudio/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; if it will help - not specifically for the Arduino as ISP, but should get you started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally you should also double-check whether you have ATmega328-PU or ATmega328P-PU - AVRDude doesn't support the ATmega328-PU (without the P) so you'll need to do a workaround (again something that I've been caught out with in the past, [here's how I worked around it] (&lt;a href=&quot;http://www.crash-bang.com/resource/bootload-atmega328/&quot; rel=&quot;nofollow&quot;&gt;http://www.crash-bang.com/resource/bootload-atmega328/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck - programming the AVR directly is more challenging but gives you more control.&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-07-31T06:23:18.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3546" PostTypeId="1" AcceptedAnswerId="3554" CreationDate="2014-07-31T06:41:06.220" Score="2" ViewCount="8610" Body="&lt;p&gt;In &lt;a href=&quot;https://arduino.stackexchange.com/questions/3489/arduino-boot-loader-problem&quot;&gt;this post&lt;/a&gt;, it was mentioned that to get the Arduino IDE to support an ATmega328 (only the ATmega328P is supported):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I should mention the Arduino way of doing this, is to create a new&#xA;  boards.txt file with this chip and add (not change) the avrdude.conf&#xA;  file. This will allow programing either from selecting the correct&#xA;  board. but that is another subject.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After a great deal of research in the past, and attempted modifications to boards.txt and avrdude.conf, I arrived at the conclusion that the Toolchain doesn't support the ATmega328 therefore the changes will have no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone confirm that they have successfully found a way to make these changes, so we can avoid the need for a work-around?&lt;/p&gt;&#xA;" OwnerUserId="3365" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-01T18:05:45.350" Title="How to modify Arduino boards.txt to support new MCUs" Tags="|avrdude|atmega328|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3547" PostTypeId="2" ParentId="3517" CreationDate="2014-07-31T07:53:22.753" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;1) How exactly do they work (connection wise)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Physically they all sit on the GPIO sockets of the Pi, sitting on top of the pi. The &lt;a href=&quot;http://www.element14.com/community/docs/DOC-64326/l/gertduino-add-on-board-for-raspberry-pi&quot; rel=&quot;nofollow&quot;&gt;Gertduino&lt;/a&gt; and &lt;a href=&quot;http://www.makershed.com/products/alamode-for-raspberry-pi&quot; rel=&quot;nofollow&quot;&gt;AlaMode&lt;/a&gt; seem to have the same form factor as the Pi which makes them a little more appealing to me but I guess then is personal choice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Communication appears to differ but it will use &lt;a href=&quot;http://www.bitsharr.com/rtxu6LvK&quot; rel=&quot;nofollow&quot;&gt;Serial&lt;/a&gt;, &lt;a href=&quot;https://www.google.co.uk/search?q=SPI%20communication%20between%20raspberry%20pi%20and%20arduino&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; or &lt;a href=&quot;http://www.adafruit.com/blog/2014/02/21/connecting-an-arduino-to-a-raspberry-pi-using-i2c-raspberry_pi-piday-raspberrypi/&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt;. I would imagine that you'd be able to choose an alternate one but not read enough about them to know for sure. Serial appears to be fairly simple, and it would be easy to debug, however you might struggle if you wanted to receive data on the Pi without the communication being initiated by the Pi.  I2C would overcome this as you can run it in &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,13579.0.html&quot; rel=&quot;nofollow&quot;&gt;multi-master&lt;/a&gt; mode. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) is it possible to write one python code in the raspberry pi that&#xA;  when run can load the specific ino code into arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you can call external programs with python I would say that even if you have to resort to this mechanism then it would be possible. You can turn on the debugging in the Arduino IDE to see what it actually does, then either script it or make the calls from your python program. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;3) which bridge would be the most suited for my project? (eg:&#xA;  Arduberry, alamode, gertduino, etc?)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'd go for either the gertduino or alamode purely on looks particularly the matched form factor.&lt;/p&gt;&#xA;" OwnerUserId="2762" LastEditorUserId="2762" LastEditDate="2014-07-31T08:22:38.847" LastActivityDate="2014-07-31T08:22:38.847" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3548" PostTypeId="2" ParentId="1180" CreationDate="2014-07-31T08:09:33.993" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;http://www.mathworks.com/academia/student_version/&quot; rel=&quot;nofollow&quot;&gt;MATLAB Student Edition&lt;/a&gt;, &#xA;this can save your time for further analysis, too.&#xA;You can just open the COM port in MATLAB and plot the received signal and/or save the signal in the workspace or whatever. MATLAB makes everything easy!&lt;/p&gt;&#xA;" OwnerUserId="3392" LastEditorUserId="3281" LastEditDate="2015-02-23T19:12:22.383" LastActivityDate="2015-02-23T19:12:22.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3549" PostTypeId="2" ParentId="501" CreationDate="2014-07-31T12:50:14.067" Score="1" Body="&lt;p&gt;The bubble tube method (&lt;a href=&quot;http://dexautomation.com/?p=9&quot; rel=&quot;nofollow&quot;&gt;http://dexautomation.com/?p=9&lt;/a&gt;) springs to mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also capacitive measurement is doable (&lt;a href=&quot;http://olimex.wordpress.com/2012/02/02/duinomite-project-tank-fluids-level-metering-by-capacitance-measurement/&quot; rel=&quot;nofollow&quot;&gt;http://olimex.wordpress.com/2012/02/02/duinomite-project-tank-fluids-level-metering-by-capacitance-measurement/&lt;/a&gt;) but more tricky. If you can use the steel inside the concrete it can be made completely contactless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note, that if the water is meant for consumption without filtering or purification you may want to refrain from direct-contact methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling for &quot;tank level measurement arduino&quot; yields lots of potentially useful results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is consumption so erratic that you can't predict when the tank needs filling? &lt;/p&gt;&#xA;" OwnerUserId="2812" LastEditorUserId="6588" LastEditDate="2015-01-07T23:01:52.667" LastActivityDate="2015-01-07T23:01:52.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3550" PostTypeId="1" CreationDate="2014-07-31T14:53:08.697" Score="2" ViewCount="750" Body="&lt;p&gt;I tried this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;#include &quot;DHT.h&quot;&#xA;#include&amp;lt;stdlib.h&amp;gt;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed&#xA;&#xA;&#xA;// WLAN parameters&#xA;#define WLAN_SSID       &quot;ID&quot;&#xA;#define WLAN_PASS       &quot;PASS&quot;&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA&#xA;&#xA;&#xA;#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data &#xA;                                   // received before closing the connection.  If you know the server&#xA;                                   // you're accessing is quick to respond, you can reduce this value.&#xA;#define DHTPIN 7&#xA;#define DHTTYPE DHT11&#xA;&#xA;&#xA;&#xA;// What page to grab!&#xA;#define WEBSITE      &quot;myapp.herokuapp.com&quot; //your website&#xA;&#xA;uint32_t ip;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;const unsigned long connectTimeout  = 15L * 1000L;&#xA;void setup(void)&#xA;{&#xA;    Serial.begin(115200);&#xA;    //Serial.begin(9600);&#xA;    Serial.println(F(&quot;\nInitializing...&quot;));&#xA;    if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;    Serial.print(F(&quot;\nAttempting to connect to &quot;)); Serial.println(WLAN_SSID);&#xA;    if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;    Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;    Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;  ///if he login and he can show info/ mean he login and only then continue&#xA;    while (! displayConnectionDetails()) {&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&#xA;&#xA;&#xA;void loop(void)&#xA;{&#xA; float h = dht.readHumidity();&#xA;  float t = dht.readTemperature();&#xA;&#xA;  int temperature = (int) t;&#xA;  int humidity = (int) h;&#xA;&#xA;  String temperatures=String(temperature);&#xA;  String humiditys=String(humidity);&#xA;&#xA;  Serial.print(&quot;Temperature: &quot;);&#xA;  Serial.print(temperatures);&#xA;  Serial.print(&quot; F /&quot;);&#xA;  Serial.print(&quot;Humidity: &quot;);&#xA;  Serial.print(humiditys);&#xA;  Serial.print(&quot;%&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;   // Create the request.&#xA;  String request = &quot;GET /plants/0003/create_measurement?capsules=1&amp;amp;humidity=&quot; + humiditys + &quot;&amp;amp;soil_moisture=40&amp;amp;temperature=&quot; + temperatures + &quot; &amp;amp;water_tank=10&amp;amp;light=20&amp;amp;battery=4 HTTP/1.1\r\n&quot;;&#xA;  // Print and Send the request&#xA;  Serial.println(&quot;About to send: &quot;);&#xA;  Serial.print(request);&#xA;  Serial.print(F(&quot;Host: &quot;));&#xA;  Serial.print(WEBSITE);&#xA;  Serial.print(F(&quot;\r\n&quot;));&#xA;  Serial.print(F(&quot;User-Agent: Compost Monitor/1.0\r\n&quot;));&#xA;  Serial.println();&#xA;  send_request(request);&#xA;&#xA;}&#xA;&#xA;void send_request (String request)&#xA;{&#xA;  Serial.println(&quot;Enter Request&quot;);&#xA;  ip = 0;&#xA;  // Try looking up the website's IP address&#xA;  Serial.print(WEBSITE); Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;  while (ip == 0) {&#xA;    if (cc3000.getHostByName(WEBSITE, &amp;amp;ip)&amp;lt;0) {&#xA;      Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;    Serial.println();&#xA;Serial.println(&quot;after Ip&quot;);&#xA;&#xA;  Adafruit_CC3000_Client www ;&#xA;   unsigned long t = millis();&#xA;&#xA;do {&#xA;    Serial.println(&quot;Into do&quot;);&#xA;   www = cc3000.connectTCP(ip, 80);&#xA;} while((!www.connected()) &amp;amp;&amp;amp;&#xA;    ((millis() - t) &amp;lt; connectTimeout));&#xA;&#xA;  String b=&quot;0&quot;;&#xA;  if(www.connected())&#xA;  {&#xA;  b=&quot;1&quot;;&#xA;  }&#xA;  Serial.println(&quot;! Out Do&quot; + b);&#xA;  if (www.connected()) {&#xA;    www.print(request);&#xA;    www.print(F(&quot;Host: &quot;));&#xA;    www.print(WEBSITE);&#xA;    www.print(F(&quot;\r\n&quot;));&#xA;    www.print(F(&quot;User-Agent: Compost Monitor/1.0\r\n&quot;));&#xA;    www.print(F(&quot;\r\n&quot;));&#xA;    www.println();&#xA;  } else {&#xA;    Serial.println(F(&quot;Connection failed&quot;));&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;-------------------------------------&quot;));&#xA;Serial.println(&quot;time to reed&quot;);&#xA;  /* Read data until either the connection is closed, or the idle timeout is reached. */&#xA;  unsigned long lastRead = millis();&#xA;  while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    while (www.available()) {&#xA;      char c = www.read();&#xA;      Serial.print(c);&#xA;      lastRead = millis();&#xA;    }&#xA;  }&#xA;  www.close();&#xA;  Serial.println(F(&quot;-------------------------------------&quot;));&#xA;Serial.println(&quot;no time to reed&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;bool displayConnectionDetails(void)&#xA;{&#xA;  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;  if(!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv, &amp;amp;dnsserv))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;    return false;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;    Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;    Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;    Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;    Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;    Serial.println();&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sends data to my server. However, no entries are appearing on my server.&lt;/p&gt;&#xA;" OwnerUserId="3399" LastEditorUserId="220" LastEditDate="2014-07-31T15:20:11.000" LastActivityDate="2014-07-31T15:20:11.000" Title="How to send data from cc3000 to herokuapp server" Tags="|serial|networking|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3551" PostTypeId="2" ParentId="1585" CreationDate="2014-07-31T15:10:15.183" Score="0" Body="&lt;p&gt;This problem is caused by using the wrong USB cable. I have three cables, two of which work find, and one of which has this issue. The cables with the ferrite bead around them will work. The one cable that I have which works has a braided shield surrounding the conductors, and it is about 2 feet long. I have a 3 foot cable with no bead and no shield that exhibits this issue.&lt;/p&gt;&#xA;" OwnerUserId="3400" LastActivityDate="2014-07-31T15:10:15.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3552" PostTypeId="1" CreationDate="2014-07-31T15:25:40.080" Score="1" ViewCount="5513" Body="&lt;p&gt;I am relatively new to Arduino platform and not know much. I am working on a Bicycle speedometer with turn and stop indicators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am planning on connecting an inductor magnet to calculate the rotation of my front wheel while providing the following services from the same arduino board:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Input horn and turn indicator switches.&lt;/li&gt;&#xA;&lt;li&gt;Output to turn indicators. &lt;/li&gt;&#xA;&lt;li&gt;Stop light when one of the brakes is&#xA;applied.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;While I am sure of how to connect all the sensors, except the magnet, I am not sure how to handle the various inputs and the outputs at once. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must be able to horn and stuff while the indicator blinks at a regular interval all the while the monitor keeps displaying my speed and distance covered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any reference or help would be greatly appreciated.&#xA;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bharath. S.&lt;/p&gt;&#xA;" OwnerUserId="3402" LastActivityDate="2014-08-02T15:17:13.633" Title="How to handle multiple input pins at once?" Tags="|programming|sketch|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3554" PostTypeId="2" ParentId="3546" CreationDate="2014-07-31T15:40:52.083" Score="4" Body="&lt;p&gt;Please, Note that the Arduino IDE is behind on many of the tools. In this case avrdude and its conf file, along with avr-gcc &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;needs to support the m328 in addition to m328p. This can be done by either updating &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\arduino-1.5.6-r2\hardware\tools\avr\bin\avrdude.exe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to something like &lt;a href=&quot;http://download.savannah.gnu.org/releases/avrdude/&quot; rel=&quot;nofollow&quot;&gt;avrdude-6.1-svn-20131205-mingw32&lt;/a&gt;. along with replacing the conf file with the new one&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file that has both m328 along with the m328p. Note 6.1 supports a parent method, making it easy to duplicate chips with different signatures. Or use existing 5.11 and add to its &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\arduino-1.5.6-r2\hardware\tools\avr\etc\avrdude.conf &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file by duplicating the entire m328p section and renaming the new entry to &quot;m328&quot; along with the correct signature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr-gcc need to be updated to support compiling both the m328p and m328. Yes, it just a semantic thing. But the next part will send either ATmega328p or ATmega328 to both gcc and dude. which both need to support it. One can simply copy over &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.\arduino-1.5.6-r2\hardware\tools\avr\ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the new tool chain. I used &lt;a href=&quot;http://sourceforge.net/projects/mobilechessboar/files/avr-gcc%20snapshots%20%28Win32%29/&quot; rel=&quot;nofollow&quot;&gt;avr-gcc-4.8_2013-03-06_mingw32&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Third:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;replace the following line in boards.txt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.build.mcu=atmega328p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## Arduino ATmega328P&#xA;## ---------------------------------------------&#xA;uno.menu.cpu.atmega328p=ATmega328P&#xA;uno.menu.cpu.atmega328p.build.mcu=atmega328p&#xA;&#xA;## Arduino ATmega328&#xA;## ---------------------------------------------&#xA;uno.menu.cpu.atmega328=ATmega328&#xA;uno.menu.cpu.atmega328.build.mcu=atmega328&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will add an option to the IDE when UNO is selected for either chip. And subsequently send the correct MCU to both the compiler and avrdude.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Proof:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are the verbose output of the IDE with the above changes. Note the -mmcu and -p for both options. As a real unit is was not connected it yielded the &quot;not in sync&quot; error. Where this shows it all works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\projects\Arduino\arduino-1.5.6-r2\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\variants\standard C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp -o C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp.o &#xA;...&#xA;C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex &#xA;&#xA;Sketch uses 444 bytes (1%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;C:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/bin/avrdude -CC:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex:i &#xA;&#xA;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;...&#xA;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\projects\Arduino\arduino-1.5.6-r2\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328 -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino -IC:\projects\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\variants\standard C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp -o C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp\sketch_jul31a.cpp.o &#xA;...&#xA;C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex &#xA;&#xA;Sketch uses 444 bytes (1%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;C:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/bin/avrdude -CC:\projects\Arduino\arduino-1.5.6-r2/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328 -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\mflaga\AppData\Local\Temp\build6597836883576934105.tmp/sketch_jul31a.cpp.hex:i &#xA;&#xA;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;...&#xA;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-07-31T15:40:52.083" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3555" PostTypeId="1" CreationDate="2014-07-31T15:47:14.483" Score="2" ViewCount="1121" Body="&lt;p&gt;I'm having trouble figuring out how to start my project. The objective is to control a robot with four servo motors and six DC motors through bluetooth. I have a bluetooth shield from Adafruit and I'm using the Arduino UNO. Ideally, I want to control this robot by sending it packets through Processing. The problem is I don't know how to create a packet with a header, payload, and checksum. I can't find any examples; can anyone help me find something to help me get started?&lt;/p&gt;&#xA;" OwnerUserId="3403" LastEditorUserId="3403" LastEditDate="2014-08-06T15:43:21.347" LastActivityDate="2014-08-06T15:43:21.347" Title="Arduino Packet for Bluetooth" Tags="|motor|bluetooth|servo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3556" PostTypeId="2" ParentId="3555" CreationDate="2014-07-31T17:01:31.133" Score="2" Body="&lt;p&gt;First, depending on the degree of reliability you need, you may not actually have to do this yourself, as the bluetooth implementation will already invisibly-to-you add, verify, and remove a packet and checksum framing around your data.  But let's assume you want to add your own as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A packet is a batch of data to be transmitted as a contained unit.  It may or may not contain exactly one useful message, but it is quite convenient if it does, and since you will be doing your own packetization (at this level) you can make sure that it does.  So basically you will transmit something that has a structure, for example:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Hi, I'm a packet&lt;/li&gt;&#xA;&lt;li&gt;attention HAL&lt;/li&gt;&#xA;&lt;li&gt;&quot;Open the pod bay doors&quot;&lt;/li&gt;&#xA;&lt;li&gt;The bytes in this message should add up to xx if you ignore the overflow&lt;/li&gt;&#xA;&lt;li&gt;That was a packet&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are countless ways you could implement this, but your life will be a lot easier if you make both the messages and the packet structure human readable, so that you can watch on the serial monitor, and perhaps even type manually.  So let's say you did something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;M1=200/BF\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For simplicity sake, instead of having a &quot;Hi I'm a packet&quot; header, we just use the newline character '\n' to mark the end of a packet, and &lt;em&gt;assume&lt;/em&gt; that whatever comes next is the start of a new packet.  Further, since bluetooth is already creating a one-to-one link, you don't need to address who you are talking to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we have a message, for example &quot;M1=200&quot; meaning &quot;drive motor 1 at PWM level 200&quot; (out of 255).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm somewhat randomly choosing the '/' character to mark the division between the message body and it's checksum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;BF&quot; might be the low two hex digits of adding up all the previous bytes in this message (it's not, I just picked something random).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally you have your newline to mark the end of a message &lt;strong&gt;and&lt;/strong&gt; the end of a packet, since in this scheme we've decided that 1 packet = 1 message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For extra fun, if the robot itself is not dangerous, you can make a test mode where the receiver will accept messages with no '/' and checksum, and only check the checksum on those where it is present.  This would allow you to manually type messages into a terminal when you are experimenting.  Or you can make your own specialized terminal program which calculates and appends a checksum each time you press return&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-07-31T17:01:31.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3557" PostTypeId="2" ParentId="3552" CreationDate="2014-07-31T17:11:38.920" Score="-1" Body="&lt;p&gt;Since your post mentioned that you are relatively new to Arduino, in case you have not done below, you may start by &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) get a printed book, ebook or 'well structured' tutorial, says, systematically covering 10 to 20 topics instead of short tutorial on just one topic &lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) this will get you covered for your task 1 to 3, but, only as individual tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) after mastering (b), try to combine them, instead of stand alone in tutorial &lt;/p&gt;&#xA;&#xA;&lt;p&gt;d) interrupt is advance topic and not be cover in many starting books. You can see &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/attachInterrupt&lt;/a&gt;   Interrupt works only on certain pins, depending on which Arduino board model.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-07-31T17:56:30.213" LastActivityDate="2014-07-31T17:56:30.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3558" PostTypeId="2" ParentId="3555" CreationDate="2014-07-31T17:26:17.567" Score="1" Body="&lt;p&gt;Start simple.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;send serial data from PC. either use Arduino USB port or on real hardware serial port, needs USB to serial adaptor and a terminal software. (see diagram in below web)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;for starting, no need for header. Just use simple text as defined yourself&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;on Arduino side, read serial input. For example, type letter 'a' on PC will blink LED, 'b' to move servo 30 degree&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replace serial communication (like RS-232 or a UART) with Bluetooth. Bluetooth supports many 'profiles', like headset, keyboard, etc. that are not suitable in your case. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;See below video. You need to use the SPP profile. see &lt;a href=&quot;https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/bluetooth-basics/bluetooth-profiles&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure your purchased bluetooth device supports SPP. Some bluetooth device are permanently setup to do one fix action. However, many bluetooth need to be 'programmed' (told what to do) before doing the task via AT command. Set speed, pairing, etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/using-the-bluesmirf/example-code-using-command-mode&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/using-the-bluesmirf/example-code-using-command-mode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-07-31T18:10:08.273" LastActivityDate="2014-07-31T18:10:08.273" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3559" PostTypeId="1" CreationDate="2014-07-31T19:48:15.447" Score="0" ViewCount="904" Body="&lt;p&gt;I need to access distance data using a LV-EZ0 Maxtronix ultrasonic sensor: &lt;a href=&quot;http://www.maxbotix.com/Ultrasonic_Sensors/MB1000.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;MB1000&#xA;LV-MaxSonar®-EZ0™High Performance Ultrasonic Rangefinder&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest what particular arduino libraries or code would be most useful?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed this new ping library, &lt;a href=&quot;http://playground.arduino.cc/Code/NewPing&quot; rel=&quot;nofollow noreferrer&quot;&gt;NewPing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this work for my purposes with this particular sensor?&lt;/p&gt;&#xA;" OwnerUserId="765" LastEditorUserId="6936" LastEditDate="2017-06-04T08:19:37.753" LastActivityDate="2017-06-04T08:24:05.967" Title="Coding and libraries for Maxtronix Ultrasonic sensors" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3560" PostTypeId="2" ParentId="3559" CreationDate="2014-08-01T03:09:33.497" Score="1" Body="&lt;p&gt;Likely work in pulse mode (library you mentioned) and sure work in RS232 serial mode (spec. in data sheet page 2, top, read data number as text). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many sensors do you need and how fast update rate? Serial mode is easier if you application need small number of sensor at 'nominal' update rate (Arduino has limited number of hardware serial port, although softserial library may help). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, in pulse mode, the RX and PW pin is similar to Trig and Echo pin on many widely available sensor (several models number, basically following similar principle). Need care about the high and low relationship as may differ from the default value in library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken from the &lt;a href=&quot;http://www.maxbotix.com/documents/MB1000_Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;data sheet of LV-MaxSonar®-EZ0&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;R X – If held low, the EZ0™ will stop ranging. Bring high for 20uS or&#xA;  more to command a range reading.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;P W – This pin outputs a pulse width representation of range&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Specifically you may want to first try the simple (old) ping: &lt;a href=&quot;http://arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ping Ultrasonic Range Finder&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changes needed:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your sensor data sheet requires 20&amp;nbsp;&amp;mu;s trigger pulse while the above is 2&amp;nbsp;&amp;mu;s;  &lt;/li&gt;&#xA;&lt;li&gt;The library read a high pulse. Your sensor data sheet 'send pulse' which likely imply a HIGH pulse, may not need change;  &lt;/li&gt;&#xA;&lt;li&gt;The library use one pin for both in and out. your is one pin in (in for sensor, out for Arduino) for trigger and one put out for measurement. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, another library. Note the author states that many sensor from the factory differs (may need small change in code): &lt;a href=&quot;http://playground.arduino.cc/Main/MaxSonar&quot; rel=&quot;nofollow noreferrer&quot;&gt;Distance Detection&#xA;with MaxSonar ultrasonic rangefinder&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="6936" LastEditDate="2017-06-04T08:24:05.967" LastActivityDate="2017-06-04T08:24:05.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3561" PostTypeId="2" ParentId="3552" CreationDate="2014-08-01T04:09:09.487" Score="0" Body="&lt;p&gt;Since I apparently can't comment yet, here's an incomplete but I think useful answer; this is a perspective on how I would go about it:&#xA;For the brake lights it's pretty easy to just put it in a loop that 'if brakes, brake light on'. I would say keep everything in one loop, no interrupts or anything. If an indicator switch is on, the loop gets the current time with millis(), sets a flag to on, and turns on the light. It then loops like normal, checks the flag and if sufficient time has passed turns off the light, gets a new time, and unchecks the flag. If i understand your needs correctly, the rest is just 'if input high, output high' that you can check every time through the loop. Can't help with the magnet though, no experience there. &lt;/p&gt;&#xA;" OwnerUserId="813" LastActivityDate="2014-08-01T04:09:09.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3562" PostTypeId="1" AcceptedAnswerId="3563" CreationDate="2014-08-01T07:31:04.180" Score="5" ViewCount="4950" Body="&lt;p&gt;I have this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;#include &amp;lt;RGBMood.h&amp;gt;&#xA;&#xA;int RECV_PIN = 2;  // IR-Receiver PIN&#xA;int led = 13;       // Satus-LED PIN&#xA;int modus;          // Modus for Interrupt-Querry &#xA;int ledr = 11;       // RGB LED red PIN&#xA;int ledg = 12;       // RGB LED green PIN                       &#xA;int ledb = 13;       // RGB LED blue PIN&#xA;int SerialBuffer = 0; &#xA;&#xA;RGBMood m(ledr, ledg, ledb);&#xA;&#xA;int timerwert = 20;   // Timer time for Interrupt in ms&#xA;&#xA;String readString;&#xA;&#xA;// Color arrays&#xA;int black[3]  = { 0, 0, 0 };&#xA;int white[3]  = { 100, 100, 100 };&#xA;int red[3]    = { 100, 0, 0 };&#xA;int green[3]  = { 0, 100, 0 };&#xA;int blue[3]   = { 0, 0, 100 };&#xA;int yellow[3] = { 40, 95, 0 };&#xA;int dimWhite[3] = { 30, 30, 30 };&#xA;&#xA;int brightness = 0;    // how bright the LED is&#xA;int fadeAmount = 5;    // how many points to fade the LED by&#xA;// etc.&#xA;&#xA;// Set initial color&#xA;int redVal = black[0];&#xA;int grnVal = black[1]; &#xA;int bluVal = black[2];&#xA;&#xA;int wait = 10;      // 10ms internal crossFade delay; increase for slower fades&#xA;int hold = 0;       // Optional hold when a color is complete, before the next crossFade&#xA;int DEBUG = 1;      // DEBUG counter; if set to 1, will write values back via serial&#xA;int loopCount = 60; // How often should DEBUG report?&#xA;int repeat = 3;     // How many times should we loop before stopping? (0 for no stop)&#xA;int j = 0;          // Loop counter for repeat&#xA;&#xA;// Initialize color variables&#xA;int prevR = redVal;&#xA;int prevG = grnVal;&#xA;int prevB = bluVal;&#xA;&#xA;#define ON                0xF4F37A66&#xA;#define OFF               0x1363ADB4&#xA;#define BRIGHTNESS_UP     0xE6721691&#xA;#define BRIGHTNESS_DOWN   0xE9721B48&#xA;#define FLASH             0xFFF00F&#xA;#define STROBE            0xFFE817&#xA;#define FADE              0x39ED1255&#xA;#define SMOOTH            0xFFC837&#xA;&#xA;#define RED               0x9D561314&#xA;#define GREEN             0XCB8E93A5&#xA;#define BLUE              0xC88E8EEC&#xA;#define WHITE             0x16DBBEE3&#xA;&#xA;#define ORANGE            0xFFB04F&#xA;#define YELLOW_DARK       0xFFA857&#xA;#define YELLOW_MEDIUM     0xFF9867&#xA;#define YELLOW_LIGHT      0xFF8877&#xA;&#xA;#define GREEN_LIGHT       0XFF30CF&#xA;#define GREEN_BLUE1       0XFF28D7&#xA;#define GREEN_BLUE2       0XFF18E7&#xA;#define GREEN_BLUE3       0XFF08F7&#xA;&#xA;#define BLUE_RED          0XFF708F&#xA;#define PURPLE_DARK       0XFF6897&#xA;#define PURPLE_LIGHT      0XFF58A7&#xA;#define PINK              0XFF48B7&#xA;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledr, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(ledg, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(ledb, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(led, OUTPUT); // set Status-LED as Output &#xA;  m.setMode(RGBMood::RANDOM_HUE_MODE);  // Automatic random fade.&#xA;  m.setHoldingTime(4000);  // Keep the same color for 4 seconds before fading again.&#xA;  m.setFadingSteps(150);   // Fade with 150 steps.&#xA;  m.setFadingSpeed(50);    // Each step last 50ms. A complete fade takes 50*150 = 7.5 seconds&#xA;  m.setHSB(random(359), 255, 255);&#xA;&#xA;Serial.begin(9600);&#xA;&#xA;  irrecv.enableIRIn(); // Start of IR-Recive&#xA;&#xA;  Timer1.initialize(timerwert); // Initialisation of Timer-Interrupts&#xA;  Timer1.attachInterrupt(leseIR); // IR-Read from Interrupt&#xA;}&#xA;&#xA;void leseIR(){&#xA;  if (irrecv.decode(&amp;amp;results)){&#xA;     irrecv.resume();  // Receive the next value&#xA;    switch (results.value)  {&#xA;&#xA;      case FADE: // Modus Fade (DIY 4)&#xA;        modus = 1;  &#xA;      break;&#xA;&#xA;      case 0xFF906F: // Modus pcambi (DIY 5)&#xA;        modus = 2;  &#xA;      break;&#xA;&#xA;      case ON:  //Power&#xA;       modus = 0;&#xA;        crossFade(white);         // RGB LEDs Off &#xA;      break;&#xA;            case OFF:  //Power&#xA;       modus = 0;&#xA;        crossFade(black);         // RGB LEDs Off &#xA;      break;&#xA;&#xA;      case BLUE:  //Blau 0,0,255&#xA;        modus = 0;&#xA;      crossFade(blue);&#xA;      break;&#xA;&#xA;      case RED: //Rot&#xA;        modus = 0;&#xA;        crossFade(red);&#xA;      break;&#xA;&#xA;      case GREEN://Grün&#xA;        modus = 0;&#xA;        crossFade(green);&#xA;      break;  &#xA;&#xA;      case WHITE: //Weiss&#xA;        modus = 0;&#xA;        crossFade(white);&#xA;      break;&#xA;&#xA;      case BRIGHTNESS_UP: //DIMMING&#xA;        modus = 0;&#xA;        // fade in from min to max in increments of 5 points:&#xA;  for(int fadeValue = 0 ; fadeValue &amp;lt;= 255; fadeValue +=5) { &#xA;    // sets the value (range from 0 to 255):&#xA;    analogWrite(ledg, fadeValue);    &#xA;&#xA;  }&#xA;&#xA;      break;&#xA;&#xA;       case BRIGHTNESS_DOWN: //orange&#xA;        modus = 0;&#xA;      for(int fadeValue = 255 ; fadeValue &amp;gt;= 0; fadeValue -=5) { &#xA;    // sets the value (range from 0 to 255):&#xA;    analogWrite(ledg, fadeValue);    &#xA;      }&#xA;&#xA;      break;&#xA;&#xA;      case 0xFFAA55://Grün mitrtel&#xA;        modus = 0;&#xA;&#xA;      break;  &#xA;&#xA;      case 0xFF926D: //blau mittel&#xA;        modus = 0;&#xA;&#xA;      break; &#xA;&#xA;      case 0xFF12ED: //rosa&#xA;        modus = 0;&#xA;&#xA;      break;      &#xA;&#xA;&#xA;     }             // Switch END&#xA;&#xA;  }               &#xA;&#xA;}                  &#xA;&#xA;void loop() {&#xA;if(modus==1){    // Querry pb Modus:1 &#xA;m.tick();&#xA;}&#xA;&#xA;      Serial.println(results.value, HEX);&#xA;      Serial.println(DEC);&#xA;      Serial.println(DEC);&#xA;      Serial.println(DEC);&#xA;&#xA;  } &#xA;&#xA;&#xA;  int calculateStep(int prevValue, int endValue) {&#xA;  int step = endValue - prevValue; // What's the overall gap?&#xA;  if (step) {                      // If its non-zero, &#xA;    step = 1020/step;              //   divide by 1020&#xA;  } &#xA;  return step;&#xA;}&#xA;&#xA;/* The next function is calculateVal. When the loop value, i,&#xA;*  reaches the step size appropriate for one of the&#xA;*  colors, it increases or decreases the value of that color by 1. &#xA;*  (R, G, and B are each calculated separately.)&#xA;*/&#xA;&#xA;int calculateVal(int step, int val, int i) {&#xA;&#xA;  if ((step) &amp;amp;&amp;amp; i % step == 0) { // If step is non-zero and its time to change a value,&#xA;    if (step &amp;gt; 0) {              //   increment the value if step is positive...&#xA;      val += 1;           &#xA;    } &#xA;    else if (step &amp;lt; 0) {         //   ...or decrement it if step is negative&#xA;      val -= 1;&#xA;    } &#xA;  }&#xA;  // Defensive driving: make sure val stays in the range 0-255&#xA;  if (val &amp;gt; 255) {&#xA;    val = 255;&#xA;  } &#xA;  else if (val &amp;lt; 0) {&#xA;    val = 0;&#xA;  }&#xA;  return val;&#xA;}&#xA;&#xA;/* crossFade() converts the percentage colors to a &#xA;*  0-255 range, then loops 1020 times, checking to see if  &#xA;*  the value needs to be updated each time, then writing&#xA;*  the color values to the correct pins.&#xA;*/&#xA;&#xA;void crossFade(int color[3]) {&#xA;  // Convert to 0-255&#xA;  int R = (color[0] * 255) / 100;&#xA;  int G = (color[1] * 255) / 100;&#xA;  int B = (color[2] * 255) / 100;&#xA;&#xA;  int stepR = calculateStep(prevR, R);&#xA;  int stepG = calculateStep(prevG, G); &#xA;  int stepB = calculateStep(prevB, B);&#xA;&#xA;  for (int i = 0; i &amp;lt;= 1020; i++) {&#xA;    redVal = calculateVal(stepR, redVal, i);&#xA;    grnVal = calculateVal(stepG, grnVal, i);&#xA;    bluVal = calculateVal(stepB, bluVal, i);&#xA;&#xA;    analogWrite(ledr, redVal);   // Write current values to LED pins&#xA;    analogWrite(ledg, grnVal);      &#xA;    analogWrite(ledb, bluVal); &#xA;&#xA;    delay(wait); // Pause for 'wait' milliseconds before resuming the loop&#xA;&#xA;&#xA;  }&#xA;  // Update current values for next loop&#xA;  prevR = redVal; &#xA;  prevG = grnVal; &#xA;  prevB = bluVal;&#xA;  delay(hold); // Pause for optional 'wait' milliseconds before resuming the loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's working like a charm, the fade operates smoothly using &lt;code&gt;timer1&lt;/code&gt;, the colors appear correct on led, but I can't fix the brightness part. &lt;strong&gt;Can  someone provide sample code to do this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone else wants to use the code, I'm using an Arduino Mega 2560, please use the same PINs as mine since timers works only on 11,12,13 on this Arduino. (&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_TimerOne.html&quot; rel=&quot;nofollow&quot;&gt;link with pin info regarding several Arduino boards&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,90160.0.html&quot; rel=&quot;nofollow&quot;&gt;RGB mood library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/PaulStoffregen/TimerOne&quot; rel=&quot;nofollow&quot;&gt;TimerOne library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;IR Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm using a small Xbox 360 IR control (no numbers keypad), some HEX codes are left intact from the original sketch found on internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=256671&quot; rel=&quot;nofollow&quot;&gt;original topic&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3409" LastEditorUserId="3409" LastEditDate="2014-08-04T07:17:02.657" LastActivityDate="2019-05-16T16:33:05.637" Title="Arduino Remote controlled RGB LED strip, having issues with brightness/dimming" Tags="|programming|led|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3563" PostTypeId="2" ParentId="3562" CreationDate="2014-08-01T10:07:41.133" Score="2" Body="&lt;p&gt;You don't have a delay in the fade loop, this goes from 0 to 255 almost instantly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int fadeValue = 0 ; fadeValue &amp;lt;= 255; fadeValue +=5) { &#xA;    // sets the value (range from 0 to 255):&#xA;    analogWrite(ledg, fadeValue);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not sure you want to fade from off to on in one go. If you want to just increment and decrement the brightness:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First notice that &lt;code&gt;prevR, prevG, prevB&lt;/code&gt; hold the current led values. So we shall use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change the switch case to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case BRIGHTNESS_UP:&#xA;    modus = 0;&#xA;    int c[3];&#xA;    // decrease by 0.9*value but also take off 2 so we get to zero&#xA;    c[0] = (prevR-2) * 90 / 100;&#xA;    c[1] = (prevG-2) * 90 / 100;&#xA;    c[2] = (prevB-2) * 90 / 100;&#xA;    for( int j = 0; j &amp;lt; 3; j++ ) {&#xA;        if (c[j] &amp;lt; 0) c[j] = 0;&#xA;    }&#xA;    crossFade(c);&#xA;    break;&#xA;&#xA;case BRIGHTNESS_DOWN:&#xA;    modus = 0;&#xA;    int c[3];&#xA;    // increase value by 1/0.9 but also add 2 so we get off zero&#xA;    c[0] = (prevR+2) * 100 / 90 + 2;&#xA;    c[1] = (prevG+2) * 100 / 90 + 2;&#xA;    c[2] = (prevB+2) * 100 / 90 + 2;&#xA;    for( int j = 0; j &amp;lt; 3; j++ ) {&#xA;        if (c[j] &amp;gt; 100) c[j] = 100;&#xA;    }&#xA;    crossFade(c);&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't check this to see if it works see please test and see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different approach:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Global variable for brightness:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int brightness = 100;&#xA;int c[3];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change this value each time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case BRIGHTNESS_UP:&#xA;    modus = 0;&#xA;    brightness += 5;&#xA;    if (brightness &amp;gt; 255) brightness = 255;&#xA;    c[0] = prevR; c[1] = prevG; c[2] = prevB;&#xA;    crossFade(c);&#xA;    break;&#xA;&#xA;case BRIGHTNESS_DOWN:&#xA;    modus = 0;&#xA;    brightness -= 5;&#xA;    if (brightness &amp;lt; 0) brightness = 0;&#xA;    c[0] = prevR; c[1] = prevG; c[2] = prevB;&#xA;    crossFade(c);&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in &lt;code&gt;crossFade&lt;/code&gt; we change the last few lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(ledr, redVal * brightness / 255);   // Write current values to LED pins&#xA;analogWrite(ledg, grnVal * brightness / 255);      &#xA;analogWrite(ledb, bluVal * brightness / 255); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that what might be happening is that the color is reduced by brightness, then that reduced value is saved in prevR/G/B when actually it should just be the full brightness value. Try changing last bit of &lt;code&gt;crossFade&lt;/code&gt; to :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prevR = color[0]; &#xA;prevG = color[1]; &#xA;prevB = color[2];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-08-02T13:56:45.530" LastActivityDate="2014-08-02T13:56:45.530" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3564" PostTypeId="1" CreationDate="2014-08-01T15:23:37.927" Score="0" ViewCount="93" Body="&lt;p&gt;I am new to Arduino and SIM300/900 world. But I see that there is a possibility of building a vehicle tracker (approximate locality since I will use GPRS network location) using just these 2 boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, is my assumption correct ? Can I build a vehicle tracker using just Arduino &lt;strong&gt;Nano&lt;/strong&gt; and SIM300 mobule ? Is there a board that has both of them on one board so that I dont have to buy them separately ? Cost is a major factor on the decision.&lt;/p&gt;&#xA;" OwnerUserId="3328" LastActivityDate="2014-08-01T18:21:42.620" Title="Arduino Nano and SIM300 module for http calls for location" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3565" PostTypeId="1" CreationDate="2014-08-01T16:45:45.973" Score="0" ViewCount="584" Body="&lt;p&gt;I have looked through the AT command set of Arduino GSM Shield boards. I dont find any AT command that provides network GPS. I wonder what I am missing. Why isn't it possible for GSM module to provide NetworkGPS (the one that is not really accurate) ?&lt;/p&gt;&#xA;" OwnerUserId="3328" LastActivityDate="2016-01-25T02:50:40.520" Title="Arduino GSM Module with network GPS" Tags="|gsm|arduino-nano|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3566" PostTypeId="2" ParentId="3565" CreationDate="2014-08-01T17:22:38.983" Score="1" Body="&lt;p&gt;Simple answer is that it is function of cellular network (phone company) instead of the module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More informative answer is, Position is calculated by network via &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;serving cell base station ID and location &lt;/li&gt;&#xA;&lt;li&gt;when phone on standby, it monitors signal strength from multiple base stations and signal strength is roughly related to distance &lt;/li&gt;&#xA;&lt;li&gt;when phone on transmitting, base station has one more piece of information. It calculates distance through time taken for signal to travel to multiple base stations (called 'time advance' in original GSM)   &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;US E911 utilizes these to locate the phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good technical paper with diagrams&#xA;&lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=6&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CEUQFjAF&amp;amp;url=https%3A%2F%2Fwww.fig.net%2Fpub%2Fcostarica_1%2Fpapers%2Fts08%2Fts08_01_schwieger_2407.pdf&amp;amp;ei=Ms3bU8-DItfr8AXT7oLQCg&amp;amp;usg=AFQjCNHImn4G34WC0Naw8IH6g1gfLzykuQ&amp;amp;bvm=bv.72197243,d.dGc&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=6&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CEUQFjAF&amp;amp;url=https%3A%2F%2Fwww.fig.net%2Fpub%2Fcostarica_1%2Fpapers%2Fts08%2Fts08_01_schwieger_2407.pdf&amp;amp;ei=Ms3bU8-DItfr8AXT7oLQCg&amp;amp;usg=AFQjCNHImn4G34WC0Naw8IH6g1gfLzykuQ&amp;amp;bvm=bv.72197243,d.dGc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Positioning_%28telecommunications%29&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Positioning_%28telecommunications%29&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3328" LastEditDate="2014-08-02T06:37:53.370" LastActivityDate="2014-08-02T06:37:53.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3567" PostTypeId="1" AcceptedAnswerId="3596" CreationDate="2014-08-01T17:32:26.717" Score="1" ViewCount="4147" Body="&lt;p&gt;I'm trying to get audio data from an ADC connected to an Arduino into a host PC.  I've done some digging and found LUFA, which I think Arduino uses under the hood. Is it possible to use the Arduino as a USB device, and if so, are there any examples?  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3413" LastEditorUserId="11" LastEditDate="2014-08-01T18:22:04.050" LastActivityDate="2014-09-01T18:48:39.797" Title="Using Arduino as USB Device?" Tags="|avr|audio|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3568" PostTypeId="2" ParentId="3564" CreationDate="2014-08-01T17:38:44.183" Score="1" Body="&lt;p&gt;Not really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Module can read the cell ID by below command. However, only phone company has the list of cell ID and their location. This information is only accurate to serving range of a cell, mostly in range of, 0.1 to 15km, from very dense city to country&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Module can also read network ID and know, from public information, the country and network operator name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example taken from web:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CREG?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should give you a result like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+CREG: 2,1,&quot;1030&quot;,&quot;639E&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Working through the 4 returned values, the &quot;2&quot; reflects the&#xA;current &quot;+CREG&quot; setting (2 means &quot;Enables unexpected network&#xA;registration and location information messages&quot;), &quot;1&quot; indicates&#xA;that the phone is registered with the network, &quot;1030&quot; is the&#xA;Location Area Code (LAC) in hex (4144 decimal), and &quot;639E&quot; is the&#xA;CellID (CI) in hex (25502 decimal).&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="11" LastEditDate="2014-08-01T18:21:42.620" LastActivityDate="2014-08-01T18:21:42.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3569" PostTypeId="1" CreationDate="2014-08-01T18:47:26.297" Score="1" ViewCount="353" Body="&lt;p&gt;I am a true beginner here. Trying to build a &quot;slot machine&quot; type game and am in the beginning stages. Found a RNG for LCD code and tweaked it a bit to get three digits to display randomly. Worked just fine. But what I'm trying to accomplish is getting a red LED to blink when none of the RN match, blue when 2 RN match, and green when 3 RN match. What is happening now, is that the LCD will no longer generate random numbers when I press my button UNless I hold the button in for a couple of seconds. As soon as the random numbers appear my green led flashes briefly then the red and blue blink opposite of each other (red on 1 sec, off 1 sec, blue on 1 sec, off 1 sec, repeat......green only briefly when random numbers change). So after hours and hours of searching goggle and trying to figure this out on my own I am turning the folks who know what they are doing :)Please tell me what I am doing wrong.... Any help would be greatly appreciated. So why did the RNG stop working with a single press of my button, and where is my code wrong that gets the correct lighting operation? Here is my code so far&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;WProgram.h&amp;gt;&#xA; #include&amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&#xA;/* pin laayout of the LCD with the arduino:&#xA;arduino pin = LCD pins &#xA;7=RS&#xA;8=E&#xA;9=D4&#xA;10=D5&#xA;11=D6&#xA;12=D7&#xA;RW=ground&#xA;*/&#xA;&#xA;int inpin=2; //switchpin&#xA;int reading; // stocks switchpin&#xA;&#xA;int inpin2=4; //switchpin&#xA;int reading2; //stocks switchpin&#xA;&#xA;int inpin3=6; //switchpin&#xA;int reading3; //stocks switchpin&#xA;&#xA;int ran; //stocks random number for dice roll 1 &#xA;int ran2; //stocks random number for dice roll 2&#xA;int ran3; //stocks random number for dice roll 3&#xA;&#xA;int outpin=LOW;&#xA;int LED1=0; // red LED&#xA;&#xA;int outpin2=LOW;&#xA;int LED2=1; // Blue LED&#xA;&#xA;int outpin3=LOW;&#xA;int LED3=3; // Green LED&#xA;&#xA;void setup()&#xA;&#xA; {&#xA; lcd.begin(16,2);&#xA;   pinMode(LED1,OUTPUT);&#xA;   pinMode(LED2,OUTPUT);&#xA;   pinMode(LED3,OUTPUT);&#xA; }&#xA;&#xA;  void loop()&#xA;  {&#xA;&#xA;    //reading of switch&#xA;&#xA;    reading=digitalRead(inpin);&#xA;    reading2=digitalRead(inpin2);&#xA;    reading3=digitalRead(inpin3);&#xA;&#xA;    //random numbers generation&#xA;&#xA;    ran3=random(6);&#xA;    ran2=random(6);&#xA;    ran=random(6);&#xA;&#xA;    {&#xA;    if (reading != reading2 != reading3);&#xA;      digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;      delay(1000);               // wait for a second&#xA;      digitalWrite(LED1, LOW);    // turn the LED off by making the voltage LOW&#xA;      delay(1000);               // wait for a second&#xA;  }&#xA;&#xA;  {&#xA;    if (reading3 == reading2 || reading);&#xA;      digitalWrite(LED2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;      delay(500);               // wait for a second&#xA;      digitalWrite(LED2, LOW);    // turn the LED off by making the voltage LOW&#xA;      delay(500);               // wait for a second&#xA;  }&#xA;&#xA;  {&#xA;    if (reading==reading2==reading3)&#xA;      digitalWrite(LED3, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;      delay(250);               // wait for a second&#xA;      digitalWrite(LED3, LOW);    // turn the LED off by making the voltage LOW&#xA;      delay(250);               // wait for a second&#xA;  }&#xA;&#xA;    // Set the screen for the PL1 and PL2 label on the top.&#xA;&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;RL 1&quot;);&#xA;&#xA;    lcd.setCursor(6,0);&#xA;    lcd.print(&quot;RL 2&quot;);&#xA;&#xA;    lcd.setCursor(12,0);&#xA;    lcd.print(&quot;RL 3&quot;);&#xA;&#xA;    //display of random number.&#xA;&#xA;    if (reading==HIGH){&#xA;        lcd.setCursor(2,1);&#xA;        lcd.print(ran);&#xA;       delay(250);} // not really clean but used as a debouche founction. That way the µC can read only once the inpin within 250ms. i'll try to improve that. &#xA;&#xA;&#xA;   if(reading2==HIGH){ //same as the player , only the location of the result on the screen is different  &#xA;       lcd.setCursor(6,0);&#xA;       lcd.print(&quot;RL 2&quot;);&#xA;       lcd.setCursor(8,1);&#xA;       lcd.print(ran2);&#xA;      delay(250);}&#xA;&#xA;      if(reading3==HIGH){ //same as the player , only the location of the result on the screen is different  &#xA;       lcd.setCursor(12,0);&#xA;       lcd.print(&quot;RL 3&quot;);&#xA;       lcd.setCursor(14,1);&#xA;       lcd.print(ran3);&#xA;      delay(250);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the original code I found: &lt;a href=&quot;http://www.desiquintans.com/articles.php?page=randuino&quot; rel=&quot;nofollow&quot;&gt;http://www.desiquintans.com/articles.php?page=randuino&lt;/a&gt; (which also shows how it is wired up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tweaked to get the 3 random numbers and not just the two that it was set to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&#xA;/* pin laayout of the LCD with the arduino:&#xA;arduino pin = LCD pins &#xA;7=RS&#xA;8=E&#xA;9=D4&#xA;10=D5&#xA;11=D6&#xA;12=D7&#xA;RW=ground&#xA;*/&#xA;&#xA;int inpin=2; //switchpin&#xA;int reading; // stocks switchpin&#xA;&#xA;int inpin2=4; //switchpin&#xA;int reading2; //stocks switchpin&#xA;&#xA;int inpin3=6;&#xA;int reading3;&#xA;&#xA;int ran; //stocks randoms for player 1 &#xA;int ran2; //stocks random for player 2&#xA;int ran3;&#xA;&#xA;void setup(){&#xA;  lcd.begin(16,2);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;    //reading of switch&#xA;&#xA;    reading=digitalRead(inpin);&#xA;    reading2=digitalRead(inpin2);&#xA;    reading3=digitalRead(inpin3);&#xA;&#xA;    //random numbers generation&#xA;&#xA;    ran3=random(6);&#xA;    ran2=random(6);&#xA;    ran=random(6);&#xA;&#xA;&#xA;    // Set the screen for the PL1 and PL2 label on the top.&#xA;&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;RL 1&quot;);&#xA;&#xA;    lcd.setCursor(6,0);&#xA;    lcd.print(&quot;RL 2&quot;);&#xA;&#xA;    lcd.setCursor(12,0);&#xA;    lcd.print(&quot;RL 3&quot;);&#xA;&#xA;    //display of random number.&#xA;&#xA;    if (reading==HIGH){&#xA;      lcd.setCursor(2,1);&#xA;      lcd.print(ran);&#xA;      delay(250);} // not really clean but used as a debouche founction. That way the µC can read only once the inpin within 250ms. i'll try to improve that. &#xA;&#xA;&#xA;   if(reading2==HIGH){ //same as the player , only the location of the result on the screen is different  &#xA;       lcd.setCursor(6,0);&#xA;       lcd.print(&quot;RL 2&quot;);&#xA;        lcd.setCursor(8,1);&#xA;        lcd.print(ran2);&#xA;      delay(250);}&#xA;&#xA;      if(reading3==HIGH){ //same as the player , only the location of the result on the screen is different  &#xA;       lcd.setCursor(12,0);&#xA;       lcd.print(&quot;RL 3&quot;);&#xA;        lcd.setCursor(14,1);&#xA;        lcd.print(ran3);&#xA;      delay(250);}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3414" LastEditorUserId="186" LastEditDate="2014-09-14T14:03:18.903" LastActivityDate="2014-09-14T14:03:18.903" Title="LED's won't light up when LCD/RNG hits 2 || 3 of a kind" Tags="|arduino-uno|sketch|lcd|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="3570" PostTypeId="1" CreationDate="2014-08-01T19:27:04.480" Score="1" ViewCount="529" Body="&lt;p&gt;I've been going through my program again and again, and I can't figure out what is causing it not to work as intended.  First, the story: I'm trying to use an Arduino to control a bunch of relays which are controlling sockets (8 of them). I want to use an Adafruit Trellis LED panel/switches to do this. Basically, when the button is pressed, the LED lights up and the relay gets tripped.  Pressing it again does the reverse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will provide my code for inspection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_Trellis.h&quot;&#xA;&#xA;/***************************************************&#xA;This example shows reading buttons and setting/clearing buttons in a loop&#xA;&quot;momentary&quot; mode has the LED light up only when a button is pressed&#xA;&quot;latching&quot; mode lets you turn the LED on/off when pressed&#xA;&#xA;Up to 8 matrices can be used but this example will show 4 or 1&#xA;****************************************************/&#xA;&#xA;#define MOMENTARY 0&#xA;#define LATCHING 1&#xA;// set the mode here&#xA;#define MODE LATCHING &#xA;&#xA;&#xA;Adafruit_Trellis matrix0 = Adafruit_Trellis();&#xA;&#xA;// uncomment the below to add 3 more matrices&#xA;/*&#xA;Adafruit_Trellis matrix1 = Adafruit_Trellis();&#xA;Adafruit_Trellis matrix2 = Adafruit_Trellis();&#xA;Adafruit_Trellis matrix3 = Adafruit_Trellis();&#xA;// you can add another 4, up to 8&#xA;*/&#xA;&#xA;// Just one&#xA;Adafruit_TrellisSet trellis = Adafruit_TrellisSet(&amp;amp;matrix0);&#xA;// or use the below to select 4, up to 8 can be passed in&#xA;//Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&amp;amp;matrix0, &amp;amp;matrix1, &amp;amp;matrix2, &amp;amp;matrix3);&#xA;&#xA;// set to however many you're working with here, up to 8&#xA;#define NUMTRELLIS 1&#xA;&#xA;#define numKeys (NUMTRELLIS * 16)&#xA;&#xA;// Connect Trellis Vin to 5V and Ground to ground.&#xA;// Connect the INT wire to pin #A2 (can change later!)&#xA;#define INTPIN A2&#xA;// relay pins&#xA;#define relay1 2&#xA;#define relay2 3&#xA;#define relay3 4&#xA;#define relay4 5&#xA;#define relay5 6&#xA;#define relay6 7&#xA;#define relay7 8&#xA;#define relay8 9&#xA;int i = 0;&#xA;&#xA;&#xA;// Connect I2C SDA pin to your Arduino SDA line&#xA;// Connect I2C SCL pin to your Arduino SCL line&#xA;// All Trellises share the SDA, SCL and INT pin! &#xA;// Even 8 tiles use only 3 wires max&#xA;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    Serial.println(&quot;Trellis on&quot;);&#xA;&#xA;    // INT pin requires a pullup&#xA;    pinMode(INTPIN, INPUT);&#xA;    //relay pins&#xA;    pinMode(relay1, OUTPUT);&#xA;    pinMode(relay2, OUTPUT);&#xA;    pinMode(relay3, OUTPUT); &#xA;    pinMode(relay4, OUTPUT);&#xA;    pinMode(relay5, OUTPUT);&#xA;    pinMode(relay6, OUTPUT);&#xA;    pinMode(relay7, OUTPUT);&#xA;    pinMode(relay8, OUTPUT);&#xA;&#xA;    digitalWrite(INTPIN, HIGH);&#xA;&#xA;    // begin() with the addresses of each panel in order&#xA;    // I find it easiest if the addresses are in order&#xA;    trellis.begin(0x70);  // only one&#xA;    // trellis.begin(0x70, 0x71, 0x72, 0x73);  // or four!&#xA;&#xA;    // light up all the LEDs in order&#xA;    for (uint8_t i = 0; i &amp;lt; numKeys; i++) {&#xA;        trellis.setLED(i);&#xA;        trellis.writeDisplay();&#xA;        delay(50);&#xA;    }&#xA;    // then turn them off&#xA;    for (uint8_t i = 0; i &amp;lt; numKeys; i++) {&#xA;        trellis.clrLED(i);&#xA;        trellis.writeDisplay();&#xA;        delay(50);&#xA;    }&#xA;}&#xA;&#xA;void toggleLight(int i){&#xA;    if (trellis.isLED(i))&#xA;        trellis.clrLED(i);&#xA;    else&#xA;        trellis.setLED(i);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(30); // 30ms delay is required, dont remove me!&#xA;    //init relay states&#xA;    static int relay1state = 0;&#xA;    static int relay2state = 0;&#xA;    static int relay3state = 0;&#xA;    static int relay4state = 0;&#xA;    static int relay5state = 0;&#xA;    static int relay6state = 0;&#xA;    static int relay7state = 0;&#xA;    static int relay8state = 0;&#xA;&#xA;    if (MODE == MOMENTARY) {&#xA;        // If a button was just pressed or released...&#xA;        if (trellis.readSwitches()) {&#xA;            // go through every button&#xA;            for (uint8_t i = 0; i &amp;lt; numKeys; i++) {&#xA;                // if it was pressed, turn it on&#xA;                if (trellis.justPressed(i)) {&#xA;                    Serial.print(&quot;v&quot;); Serial.println(i);&#xA;                    trellis.setLED(i);&#xA;                }&#xA;                // if it was released, turn it off&#xA;                if (trellis.justReleased(i)) {&#xA;                    Serial.print(&quot;^&quot;); Serial.println(i);&#xA;                    trellis.clrLED(i);&#xA;                }&#xA;            }&#xA;            // tell the trellis to set the LEDs we requested&#xA;            trellis.writeDisplay();&#xA;        }&#xA;    }&#xA;&#xA;    if (MODE == LATCHING) {&#xA;        // If a button was just pressed or released...&#xA;        if (trellis.readSwitches()) {&#xA;            // go through every button&#xA;            for (i; i &amp;lt; numKeys; i++) {&#xA;                // if it was pressed...&#xA;                if (trellis.justPressed(i)) {&#xA;&#xA;                    switch (i)&#xA;                    {&#xA;                    case '0':&#xA;                        relay1state ^= 1; // xor current value with 1 (causes value to toggle)&#xA;                        if (relay1state) {&#xA;                            delay(100);&#xA;                            digitalWrite(relay1, HIGH);&#xA;                            toggleLight(i);&#xA;                            Serial.println(&quot;Outlet 1 on&quot;);&#xA;                            break;&#xA;                        }&#xA;                        else {&#xA;                            delay(100);&#xA;                            digitalWrite(relay1, LOW);&#xA;                            toggleLight(i);&#xA;                            Serial.println(&quot;Outlet 1 off&quot;);&#xA;                            break;&#xA;                        }&#xA;&#xA;                    case '1':&#xA;                        relay2state ^= 1; // xor current value with 1 (causes value to toggle)&#xA;                        if (relay2state) {&#xA;                            delay(100);&#xA;                            digitalWrite(relay2, HIGH);&#xA;                            toggleLight(i);&#xA;                            Serial.println(&quot;Outlet 2 on&quot;);&#xA;                            break;&#xA;                        }&#xA;                        else {&#xA;                            delay(100);&#xA;                            digitalWrite(relay2, LOW);&#xA;                            toggleLight(i);&#xA;                            Serial.println(&quot;Outlet 2 off&quot;);&#xA;&#xA;                            break;&#xA;                        }&#xA;                        //...add case 3-8 &amp;amp; 9-15&#xA;                    }&#xA;                    trellis.writeDisplay();&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3415" LastEditorUserId="3415" LastEditDate="2014-08-01T19:48:50.323" LastActivityDate="2014-12-30T03:51:44.993" Title="Using an Adafruit Trellis to control a set of relays" Tags="|led|i2c|relay|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3571" PostTypeId="2" ParentId="3570" CreationDate="2014-08-01T19:52:05.423" Score="0" Body="&lt;p&gt;There's an issue with your switch case statement. You switch on &lt;code&gt;int i&lt;/code&gt; but your cases use chars like &lt;code&gt;'1'&lt;/code&gt;. This is comparing the value of &lt;code&gt;i&lt;/code&gt; to the integer value of the character 0 or 1 which are actually 48 and 49 respectively. Check out an ASCII table for more info on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try removing the single quotes and just have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch(i) {&#xA;    case 0:&#xA;        //case 0 stuff&#xA;        break;&#xA;    case 1:&#xA;        //case 1 stuff&#xA;        break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will compare the value of &lt;code&gt;i&lt;/code&gt; to the number that you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose another way to fix this would be to add 48 to &lt;code&gt;i&lt;/code&gt; every time you check it. I would change the case statements though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be declaring the ready state variables outside of your &lt;code&gt;loop()&lt;/code&gt; function and then initializing them in &lt;code&gt;setup()&lt;/code&gt;.&#xA;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ready1state;&#xA;void setup() {&#xA;    //setup stuff&#xA;    ready1state = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;    //loop stuff&#xA;    ready1state ^= 1;&#xA;    //use ready1state&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1407" LastEditorUserId="1407" LastEditDate="2014-08-01T20:32:09.830" LastActivityDate="2014-08-01T20:32:09.830" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3572" PostTypeId="2" ParentId="3567" CreationDate="2014-08-02T00:00:01.287" Score="0" Body="&lt;p&gt;I am confused on what your end purpose is.  do you want something that works or you want to make a project for self-learning purpose.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For ready-made products that you can buy, if you want the PC to be able to input and output sound, there are hundreds models of a) sound card plug into PC  b) external sound card link to PC via USB cable    They ranges from a few USD to 50 to 200 with huge range of performance in terms of sampling rate and number of bits (low noise).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ardu build-in ADC is 10 to 12 bits. These card are 16 to 24 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See&#xA;&lt;a href=&quot;http://www.bestbuy.com/site/computer-cards-components/sound-cards/abcat0507003.c?id=abcat0507003&quot; rel=&quot;nofollow&quot;&gt;http://www.bestbuy.com/site/computer-cards-components/sound-cards/abcat0507003.c?id=abcat0507003&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;24 bits 116 dB SNR very low noise&#xA;&lt;a href=&quot;http://us.creative.com/p/sound-blaster/sound-blaster-z&quot; rel=&quot;nofollow&quot;&gt;http://us.creative.com/p/sound-blaster/sound-blaster-z&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used them as test instrument for commercial/university projects with success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw on TV news that same setup (high bit card, at -110dB or lower noise level) used in the underwater signal search for MH370 down plane months ago. &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-08-02T00:00:01.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3573" PostTypeId="1" AcceptedAnswerId="3606" CreationDate="2014-08-02T00:11:19.937" Score="4" ViewCount="1390" Body="&lt;p&gt;I'm building a small library that will be used and production and released open source. I'm paying a lot of attention to the &quot;best practices&quot; to make sure this code is reliable and easy to use. I also would also like to make this easy to edit. I'm having an issue with the naming scheme of the whole project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few Arduino naming quirks. If I have a sketch called &lt;code&gt;mylib&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;...I can't create a tab called &lt;code&gt;mylib.cpp&lt;/code&gt;. However, I &lt;em&gt;can&lt;/em&gt; create a file called &lt;code&gt;mylib.h&lt;/code&gt;...&lt;/li&gt;&#xA;&lt;li&gt;...The folder and main sketch file &lt;strong&gt;must&lt;/strong&gt; be the same name as the folder it is in&lt;/li&gt;&#xA;&lt;li&gt;...The sketch name (and folder) cannot contain any spaces.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Well, why are you creating a sketch for a library?&lt;/em&gt; The Arduino IDE won't open a &lt;code&gt;.cpp&lt;/code&gt; file unless there's a sketch in that folder (and you have to open the &lt;code&gt;.ino&lt;/code&gt;/&lt;code&gt;.pde&lt;/code&gt; file in that folder). I'm trying to get this to work with the Arduino IDE so, if users need to edit the library, then can just open the file and go to the correct tab. If they use an external editor, they won't be able to compile it to see if there are any errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd ideally just do this structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_lib&#xA;   |- my_lib.ino&#xA;   |- mylib.cpp&#xA;   |- mylib.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, a user might see that the folder is called &lt;code&gt;my_lib&lt;/code&gt; and try including the file &lt;code&gt;my_lib.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is a major oversight in the Arduino IDE, but I need to have this work with the Arduino IDE. If it was just me working on this code, I might consider making the library directly in a project directory, but that isn't ideal. Is there anything that I can do to bypass this/make it easy for users to edit? Is there any &quot;standard&quot;/&quot;convention&quot; that defines how to do this?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2017-10-23T01:03:16.053" Title="How to avoid odd naming rules for Arduino when writing a library?" Tags="|library|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3574" PostTypeId="2" ParentId="3570" CreationDate="2014-08-02T00:38:21.713" Score="1" Body="&lt;p&gt;Stepping back from your code problems, why are you using relays? Do you mean electromechanical relays? Those draw a lot of current and you need to wire them with a protection diode so they don't destroy the control circuit when you disconnect the power and the inductive field on the relay coil collapses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're switching AC power, mechanical relays are a reasonable way to go, but for DC like motors/LEDs, etc, it's usually better to use electronic switches of some kind (e.g. transistors).&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-02T00:38:21.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3575" PostTypeId="2" ParentId="3562" CreationDate="2014-08-02T06:21:13.213" Score="1" Body="&lt;p&gt;I've moved the &lt;code&gt;analogWrite&lt;/code&gt; part of the code inside the &lt;code&gt;switch case&lt;/code&gt; &lt;code&gt;BRIGHTNESS_UP&lt;/code&gt; &amp;amp; &lt;code&gt;BRIGHTNESS_DOWN&lt;/code&gt; and it's working. I also removed the &lt;code&gt;crossFade(c);&lt;/code&gt; line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the working code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;#include &amp;lt;RGBMood.h&amp;gt;&#xA;&#xA;int RECV_PIN = 2;  // IR-Receiver PIN&#xA;int led = 13;       // Satus-LED PIN&#xA;int modus;          // Modus for Interrupt-Querry &#xA;int ledr = 11;       // RGB LED red PIN&#xA;int ledg = 12;       // RGB LED green PIN                       &#xA;int ledb = 13;       // RGB LED blue PIN&#xA;int SerialBuffer = 0; &#xA;int c[3];&#xA;&#xA;&#xA;//RGB Pins Array&#xA;int CH[3] = {11, 12, 13};&#xA;int val[3] = {0, 0, 0}; // led brightness 0-255&#xA;&#xA;&#xA;RGBMood m(ledr, ledg, ledb);&#xA;&#xA;int timerwert = 20;   // Timer time for Interrupt in ms&#xA;&#xA;String readString;&#xA;&#xA;// Color arrays&#xA;int black[3]  = { 0, 0, 0 };&#xA;int white[3]  = { 100, 100, 100 };&#xA;int red[3]    = { 100, 0, 0 };&#xA;int green[3]  = { 0, 100, 0 };&#xA;int blue[3]   = { 0, 0, 100 };&#xA;int yellow[3] = { 40, 95, 0 };&#xA;int dimWhite[3] = { 30, 30, 30 };&#xA;&#xA;int brightness = 100;    // how bright the LED is&#xA;int fadeAmount = 5;    // how many points to fade the LED by&#xA;// etc.&#xA;&#xA;// Set initial color&#xA;int redVal = black[0];&#xA;int grnVal = black[1]; &#xA;int bluVal = black[2];&#xA;&#xA;int wait = 10;      // 10ms internal crossFade delay; increase for slower fades&#xA;int hold = 0;       // Optional hold when a color is complete, before the next crossFade&#xA;int DEBUG = 1;      // DEBUG counter; if set to 1, will write values back via serial&#xA;int loopCount = 60; // How often should DEBUG report?&#xA;int repeat = 3;     // How many times should we loop before stopping? (0 for no stop)&#xA;int j = 0;          // Loop counter for repeat&#xA;&#xA;&#xA;// Initialize color variables&#xA;int prevR = redVal;&#xA;int prevG = grnVal;&#xA;int prevB = bluVal;&#xA;&#xA;#define ON                0xF4F37A66&#xA;#define OFF               0x1363ADB4&#xA;#define BRIGHTNESS_UP     0xE6721691&#xA;#define BRIGHTNESS_DOWN   0xE9721B48&#xA;#define FLASH             0xFFF00F&#xA;#define STROBE            0xFFE817&#xA;#define FADE              0x39ED1255&#xA;#define SMOOTH            0xFFC837&#xA;&#xA;#define RED               0x9D561314&#xA;#define GREEN             0XCB8E93A5&#xA;#define BLUE              0xC88E8EEC&#xA;#define WHITE             0x16DBBEE3&#xA;&#xA;#define ORANGE            0xFFB04F&#xA;#define YELLOW_DARK       0xFFA857&#xA;#define YELLOW_MEDIUM     0xFF9867&#xA;#define YELLOW_LIGHT      0xFF8877&#xA;&#xA;#define GREEN_LIGHT       0XFF30CF&#xA;#define GREEN_BLUE1       0XFF28D7&#xA;#define GREEN_BLUE2       0XFF18E7&#xA;#define GREEN_BLUE3       0XFF08F7&#xA;&#xA;#define BLUE_RED          0XFF708F&#xA;#define PURPLE_DARK       0XFF6897&#xA;#define PURPLE_LIGHT      0XFF58A7&#xA;#define PINK              0XFF48B7&#xA;#define MAX 255 &#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledr, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(ledg, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(ledb, OUTPUT); // Set RGB LED Pins as Output&#xA;  pinMode(led, OUTPUT); // set Status-LED as Output &#xA; //initiate rgb pins output&#xA;    for (int i=0; i&amp;lt;3; i++)&#xA;  {&#xA;    pinMode(CH[i], OUTPUT);&#xA;  }&#xA;&#xA;  m.setMode(RGBMood::RANDOM_HUE_MODE);  // Automatic random fade.&#xA;  m.setHoldingTime(4000);  // Keep the same color for 4 seconds before fading again.&#xA;  m.setFadingSteps(150);   // Fade with 150 steps.&#xA;  m.setFadingSpeed(50);    // Each step last 50ms. A complete fade takes 50*150 = 7.5 seconds&#xA;  m.setHSB(random(359), 255, 255);&#xA;&#xA;Serial.begin(9600);&#xA;&#xA;  irrecv.enableIRIn(); // Start of IR-Recive&#xA;&#xA;  Timer1.initialize(timerwert); // Initialisation of Timer-Interrupts&#xA;  Timer1.attachInterrupt(leseIR); // IR-Read from Interrupt&#xA;}&#xA;&#xA;void leseIR(){&#xA;  if (irrecv.decode(&amp;amp;results)){&#xA;     irrecv.resume();  // Receive the next value&#xA;    switch (results.value)  {&#xA;&#xA;      case FADE: // Modus Fade (DIY 4)&#xA;        modus = 1;  &#xA;      break;&#xA;&#xA;      case 0xFF906F: // Modus pcambi (DIY 5)&#xA;        modus = 2;  &#xA;      break;&#xA;&#xA;      case ON:  //Power&#xA;       modus = 0;&#xA;        crossFade(white);         // RGB LEDs Off &#xA;      break;&#xA;            case OFF:  //Power&#xA;       modus = 0;&#xA;        crossFade(black);         // RGB LEDs Off &#xA;      break;&#xA;&#xA;      case BLUE:  //Blau 0,0,255&#xA;        modus = 0;&#xA;      crossFade(blue);&#xA;      break;&#xA;&#xA;      case RED: //Rot&#xA;        modus = 0;&#xA;        crossFade(red);&#xA;      break;&#xA;&#xA;      case GREEN://Grün&#xA;        modus = 0;&#xA;        crossFade(green);&#xA;      break;  &#xA;&#xA;      case WHITE: //Weiss&#xA;        modus = 0;&#xA;        crossFade(white);&#xA;      break;&#xA;&#xA;      case BRIGHTNESS_UP: //DIMMING UP&#xA;        modus = 0;&#xA;    brightness += 5;&#xA;    if (brightness &amp;gt; 255) brightness = 255;&#xA;    c[0] = prevR; c[1] = prevG; c[2] = prevB;&#xA;    analogWrite(ledr, redVal * brightness / 255);   // Write current values to LED pins&#xA;    analogWrite(ledg, grnVal * brightness / 255);      &#xA;    analogWrite(ledb, bluVal * brightness / 255);&#xA;&#xA;      break;&#xA;&#xA;       case BRIGHTNESS_DOWN: //DIMMING DOWN&#xA;         modus = 0;&#xA;    brightness -= 5;&#xA;    if (brightness &amp;lt; 0) brightness = 0;&#xA;    c[0] = prevR; c[1] = prevG; c[2] = prevB;&#xA;    analogWrite(ledr, redVal * brightness / 255);   // Write current values to LED pins&#xA;    analogWrite(ledg, grnVal * brightness / 255);      &#xA;    analogWrite(ledb, bluVal * brightness / 255);&#xA;&#xA;&#xA;      break;&#xA;&#xA;      case 0xFFAA55://Grün mitrtel&#xA;        modus = 0;&#xA;      break;  &#xA;&#xA;      case 0xFF926D: //blau mittel&#xA;        modus = 0;&#xA;&#xA;      break; &#xA;&#xA;      case 0xFF12ED: //rosa&#xA;        modus = 0;&#xA;&#xA;      break;      &#xA;&#xA;&#xA;     }             // Switch END&#xA;&#xA;  }               &#xA;}                  &#xA;&#xA;void loop() {&#xA;if(modus==1){    // Querry pb Modus:1 &#xA;m.tick();&#xA;}&#xA;if(modus==2){    // Querry pb Modus:1 &#xA;&#xA;}&#xA;        Serial.println(prevR);&#xA;        Serial.println(prevG);&#xA;        Serial.println(prevB);&#xA;//      Serial.println(results.value, HEX);&#xA;//      Serial.println(DEC);&#xA;//      Serial.println(DEC);&#xA;//      Serial.println(DEC);&#xA;//      Serial.print(&quot;channel 1,2,3 values:&quot;);              // sends  brightness values to the serial monitor&#xA;    //  for(int i=0; i&amp;lt;3; i++){                             // every time the remote is pressed&#xA;    //  Serial.print(CH[i]);&#xA;//      Serial.print(&quot;   &quot;);&#xA;    // } &#xA;  } &#xA;&#xA;&#xA;  int calculateStep(int prevValue, int endValue) {&#xA;  int step = endValue - prevValue; // What's the overall gap?&#xA;  if (step) {                      // If its non-zero, &#xA;    step = 1020/step;              //   divide by 1020&#xA;  } &#xA;  return step;&#xA;}&#xA;&#xA;/* The next function is calculateVal. When the loop value, i,&#xA;*  reaches the step size appropriate for one of the&#xA;*  colors, it increases or decreases the value of that color by 1. &#xA;*  (R, G, and B are each calculated separately.)&#xA;*/&#xA;&#xA;int calculateVal(int step, int val, int i) {&#xA;&#xA;  if ((step) &amp;amp;&amp;amp; i % step == 0) { // If step is non-zero and its time to change a value,&#xA;    if (step &amp;gt; 0) {              //   increment the value if step is positive...&#xA;      val += 1;           &#xA;    } &#xA;    else if (step &amp;lt; 0) {         //   ...or decrement it if step is negative&#xA;      val -= 1;&#xA;    } &#xA;  }&#xA;  // Defensive driving: make sure val stays in the range 0-255&#xA;  if (val &amp;gt; 255) {&#xA;    val = 255;&#xA;  } &#xA;  else if (val &amp;lt; 0) {&#xA;    val = 0;&#xA;  }&#xA;  return val;&#xA;}&#xA;&#xA;/* crossFade() converts the percentage colors to a &#xA;*  0-255 range, then loops 1020 times, checking to see if  &#xA;*  the value needs to be updated each time, then writing&#xA;*  the color values to the correct pins.&#xA;*/&#xA;&#xA;void crossFade(int color[3]) {&#xA;  // Convert to 0-255&#xA;  int R = (color[0] * 255) / 100;&#xA;  int G = (color[1] * 255) / 100;&#xA;  int B = (color[2] * 255) / 100;&#xA;&#xA;  int stepR = calculateStep(prevR, R);&#xA;  int stepG = calculateStep(prevG, G); &#xA;  int stepB = calculateStep(prevB, B);&#xA;&#xA;  for (int i = 0; i &amp;lt;= 1020; i++) {&#xA;    redVal = calculateVal(stepR, redVal, i);&#xA;    grnVal = calculateVal(stepG, grnVal, i);&#xA;    bluVal = calculateVal(stepB, bluVal, i);&#xA;&#xA;    analogWrite(ledr, redVal);   // Write current values to LED pins&#xA;    analogWrite(ledg, grnVal);      &#xA;    analogWrite(ledb, bluVal); &#xA;&#xA;    delay(wait); // Pause for 'wait' milliseconds before resuming the loop&#xA;&#xA;&#xA;  }&#xA;  // Update current values for next loop&#xA;  prevR = redVal; &#xA;  prevG = grnVal; &#xA;  prevB = bluVal;&#xA;  delay(hold); // Pause for optional 'wait' milliseconds before resuming the loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;thanks geometrikal for your support! You believe it's possible to manipulate the dimming of the fade effect too? It's using the RGBMood class to create a HSB color mix.&lt;/p&gt;&#xA;" OwnerUserId="3409" LastEditorUserId="3409" LastEditDate="2014-08-02T07:07:38.210" LastActivityDate="2014-08-02T07:07:38.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3576" PostTypeId="1" AcceptedAnswerId="3580" CreationDate="2014-08-02T06:21:16.747" Score="0" ViewCount="804" Body="&lt;p&gt;I want to make a system that always have the same current (about 1ma) in a water with silver electrode. At start it will be purified water so conductivity will be really low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with time silver particle will be released in water, raising his conductivity so if I don't lower the voltage the current will raise too (meaning that bigger particle will be released which I don't want too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there any way I can measure low current and adapt voltage with the result (since deducting resistance wouldn't be hard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know about ASC712 but It seem that he can't be precise enough (steps of 13ma max) to my use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I precise it's not that long I'm trying to get back in electronics with arduino so many school things have been forgotten. &lt;/p&gt;&#xA;" OwnerUserId="3417" LastActivityDate="2014-08-02T20:32:31.297" Title="Measure low current with variable voltage" Tags="|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3577" PostTypeId="2" ParentId="3576" CreationDate="2014-08-02T07:03:37.047" Score="1" Body="&lt;p&gt;Alternatively, you can buy ready made unit. Random search from web give example like this has 3 models for, 1.5, 3 and 6kV 1mA constant current.  &lt;a href=&quot;http://www.matsusada.com/high-voltage/sc/&quot; rel=&quot;nofollow&quot;&gt;http://www.matsusada.com/high-voltage/sc/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Safety first if self make (do you need a unit for use or you want to do exercise trying to make it). &lt;strong&gt;May not be a easy project.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your post stated 'purified water', resistance will be really high, in many mega ohm range, if it is really pure.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First measure resistance with multitester to get realistic ohm reading in pure and later stage when &quot;with time silver particle will be released in water&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hi and then lower ohm will get you voltage needed. to drive 1mA through multiple mega ohm need kilo volt and need special circuit and suitable experience for hi volt safety.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-02T20:32:31.297" LastActivityDate="2014-08-02T20:32:31.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3579" PostTypeId="1" AcceptedAnswerId="3581" CreationDate="2014-08-02T09:19:12.867" Score="1" ViewCount="944" Body="&lt;p&gt;I want to write a lipoly powered arduino device that can be launched from sleep mode by pressing a certain key that is connected to ground. Usually, when no in sleep mode I enable the internal pull-up resistor for a definite level. But when in sleep mode, I assume this would drain to much power and hence I want to avoid it. Is it sufficient to just wait for a pin-change interrupt on the same port pin without the internal or an additional external pull-up resistor?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2014-08-02T13:50:20.377" Title="External (pin change) interrupt and power consumption" Tags="|power|interrupt|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3580" PostTypeId="2" ParentId="3576" CreationDate="2014-08-02T09:32:05.267" Score="3" Body="&lt;p&gt;What you want is called a constant current source. You can actually build a simple one using &lt;a href=&quot;http://en.wikipedia.org/wiki/Current_source#mediaviewer/File:Const_cur_src_113.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;one transistor&lt;/a&gt; ; but a better one uses two transistors - as in the left example below - see &lt;a href=&quot;http://www.talkingelectronics.com/projects/TheTransistorAmplifier/TheTransistorAmplifier-P2.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; for explanations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/E01sN.gif&quot; alt=&quot;Transistor based current source&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the leds would be your load, R=680 Ohm would give you about 1mA - and you would need to increase the value of the 2k2 resistor to somewhere around 22k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that, as John Williams noted, forcing 1mA through a high resistance requires high voltage : 1MOhm would need 1kV, 10MOhm needs 10kV etc. That's very dangerous voltages! and quite some power as well : 10kV at 1mA means 10W. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you need to define your needs first :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is a tolerable error on the absolute value of current? (Would constant 1.1mA be OK?)&lt;/li&gt;&#xA;&lt;li&gt;What is a tolerable error on the current variations? (Would current varying between 1.19mA and 1.21mA be OK?)&lt;/li&gt;&#xA;&lt;li&gt;Do you absolutely need 1mA right from start? Or can you accept a lower current at start, growing with increased conductivity until 1mA is reached and then being held nicely constant?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the above examples are fine, a current source as described above would do the job nicely for less than 1USD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need a constant current source right from the start, then be prepared to work with expensive and dangerous pieces of equipment.&lt;/p&gt;&#xA;" OwnerUserId="367" LastActivityDate="2014-08-02T09:32:05.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3581" PostTypeId="2" ParentId="3579" CreationDate="2014-08-02T09:50:21.260" Score="3" Body="&lt;p&gt;You &lt;strong&gt;must not&lt;/strong&gt; leave CMOS inputs floating. This will &lt;em&gt;increase&lt;/em&gt; power consumption, and as a worst result may damage the device. Use an external pull-up if you feel that the internal pull-up passes too much current.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-08-02T13:50:20.377" LastActivityDate="2014-08-02T13:50:20.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3582" PostTypeId="2" ParentId="3579" CreationDate="2014-08-02T11:30:50.943" Score="0" Body="&lt;p&gt;Tutorial from University of South Florida&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=HiAbxSO_9nU&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=HiAbxSO_9nU&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internal pull-up resistor does not drain too much current. Only leakage in nA range. It is correct to use pull up, in your case, as this is what it is designed to do. As Ignacio Vazquez-Abrams, do not leave input pin open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MCU are designed to do the precise action you mentioned, to wake up on pin change as in mass produced wrist watch and TV remote controller. On remote, MCU sleeps until key pressed. On watch, it wake on timer 1 second) and key change. &lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-02T11:54:27.090" LastActivityDate="2014-08-02T11:54:27.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3584" PostTypeId="2" ParentId="3552" CreationDate="2014-08-02T14:26:17.167" Score="1" Body="&lt;p&gt;How fast do we need to read the magnetic switch to not miss any pulses? I'll make some working assumptions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using 700c wheel and 28mm tire [assumed; adjust as necessary]&lt;/li&gt;&#xA;&lt;li&gt;Rolling radius 2.1m [&lt;a href=&quot;http://www.bikecalc.com/wheel_size_math&quot; rel=&quot;nofollow&quot;&gt;from here&lt;/a&gt;; there are other ways to arrive at this]&lt;/li&gt;&#xA;&lt;li&gt;Max speed 22 m/sec (50mph), [working assumption; adjust as you see fit]&lt;/li&gt;&#xA;&lt;li&gt;Magnet and switch interact for at most 3% of a rotation, [WAGuess]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The wheel will have to turn at ~10RPS at max speed giving a pulse period of 100ms. The pulse width will be at most 3% of that, or 3ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your service loop would have to execute in somewhat less than 3ms, every time, in order to not miss any wheel pulses and that's if I haven't been too optimistic about the pulse width. I'd personally assume a 1ms maximum loop time, then test it on the road by sampling &amp;amp; logging wheel-pulse level with an Arduino at at least 10x that rate or 10+KHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or I'd go with an interrupt-driven wheel pulse period timer not width) to ease the constraints on the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main loop need only poll your turn, brake, and horn switches and a timer for blinking the turn signals. Even if the timing is a little erratic for some reason, no harm is done, and nothing is likely to be apparent to the rider or other road users.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-08-02T14:26:17.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3585" PostTypeId="2" ParentId="3552" CreationDate="2014-08-02T15:17:13.633" Score="1" Body="&lt;p&gt;You need a finite state machine. Then you can have code that would typically require &lt;code&gt;delay()&lt;/code&gt; but without blocking the &lt;code&gt;loop()&lt;/code&gt; while it waits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a crude class I wrote to do it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;stateMachine.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; StateMachine&#xA;&#xA; Class to perform some state machine logic on the Arduino&#xA;*/&#xA;&#xA;#if (ARDUINO &amp;gt;= 100)&#xA; #include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA; #include &amp;lt;WProgram.h&amp;gt;&#xA; #include &amp;lt;pins_arduino.h&amp;gt;&#xA;#endif&#xA;&#xA;class StateMachine &#xA;{&#xA;  public:&#xA;  // Constructor&#xA;  StateMachine(void (*)(void));&#xA;  // Functions&#xA;  void update(void);&#xA;  void nextState(uint16_t, uint32_t);&#xA;  uint16_t currentState(void);&#xA;  void stop(void);&#xA;&#xA;  private:&#xA;  void (*callback)(void);   // Callback to state machine code&#xA;  uint16_t state;      // Current state of the machine&#xA;  uint32_t delay;      // Delay until state change. Delay of -1 is stopped&#xA;  uint32_t timer;      // Timer to keep track of last run time&#xA;  uint8_t isRunning;   // Are we running?&#xA;  int16_t counter[2];  // Two counters for general use&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;stateMachine.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; StateMachine&#xA;&#xA; Class to perform some state machine logic on the Arduino&#xA;*/&#xA;&#xA;#include &quot;StateMachine.h&quot;&#xA;&#xA;//&#xA;// Constructor&#xA;//&#xA;StateMachine::StateMachine(void (*callbackFunction) (void)) {&#xA;  state = 0;&#xA;  delay = 0;&#xA;  timer = 0;&#xA;  isRunning = 0;&#xA;  callback = callbackFunction;&#xA;  counter[0] = 0;&#xA;  counter[1] = 0;&#xA;}&#xA;&#xA;//&#xA;// Update the state machine&#xA;//&#xA;// Use in loop()&#xA;// Will keep running over and over unless stop()ed&#xA;//&#xA;void StateMachine::update(void) {&#xA;  if (isRunning) {&#xA;    if(millis() - timer &amp;gt;= delay) {&#xA;      timer = millis();&#xA;      //Call the state machine&#xA;      callback();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//&#xA;// Current state&#xA;//&#xA;uint16_t StateMachine::currentState() {&#xA;  return state;&#xA;}&#xA;&#xA;//&#xA;// Next state&#xA;//&#xA;void StateMachine::nextState(uint16_t nextState, uint32_t nextDelay) {&#xA;  state = nextState;&#xA;  delay = nextDelay;&#xA;  isRunning = 1;&#xA;  //Restart timer&#xA;  timer = millis();&#xA;}&#xA;&#xA;//&#xA;// Stop&#xA;//&#xA;void StateMachine::stop()&#xA;{&#xA;  isRunning = 0;  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you need a function with the logic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void exampleStateMachineCallback()&#xA;{&#xA;  switch (exampleStateMachine.currentState()) {&#xA;    case 0:&#xA;      //initialise everything and then got to state 1 immediately&#xA;      exampleStateMachine.nextState(1,0);&#xA;      break;&#xA;&#xA;    case 1:&#xA;      //do something then do state 2 500ms later&#xA;      exampleStateMachine.nextState(2,500);&#xA;      break;&#xA;&#xA;    case 2:&#xA;      //do something then do state 1 500ms later&#xA;      exampleStateMachine.nextState(1,500);&#xA;      break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally in the global variables we join them up&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;StateMachine exampleStateMachine = StateMachine(exampleStateMachineCallback);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in &lt;code&gt;loop()&lt;/code&gt; we call update all the time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;exampleStateMachine.update();&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The states implement your logic. For example, state 1 in the above code could be turn on the led, and state 2 could be turn it off. State 0 might prepare some variables. If you wanted the led to start flashing with a button press it might look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(LEFT_BUTTON) == HIGH) exampleStateMachine.nextState(0,0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if you wanted to stop it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exampleStateMachine.stop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the StateMachine class I put two counters, you could use these to do other timers. For example, to flash a led for 30 seconds it might look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void exampleStateMachineCallback()&#xA;{&#xA;  switch (exampleStateMachine.currentState()) {&#xA;    case 0:&#xA;      exampleStateMachine.counter[0] = 0;&#xA;      exampleStateMachine.nextState(1,0);&#xA;      break;&#xA;&#xA;    case 1:&#xA;      digitalWrite(13,HIGH);&#xA;      exampleStateMachine.nextState(2,500);&#xA;      break;&#xA;&#xA;    case 2:&#xA;      digitalWrite(13,LOW);&#xA;      exampleStateMachine.counter[0]++;&#xA;      if (exampleStateMachine.counter[0] &amp;gt;= 30) exampleStateMachine.stop();&#xA;      else exampleStateMachine.nextState(1,500);&#xA;      break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-02T15:17:13.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3587" PostTypeId="1" AcceptedAnswerId="3863" CreationDate="2014-08-02T16:47:21.120" Score="2" ViewCount="2801" Body="&lt;p&gt;As the title, I'd like to reset the Arduino sketch from the linux machine. Is it possible? how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution could be to save the hex file inside the sd card and then upload it via the lua sketch but I think there is a smarter solution.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-08-20T08:56:43.893" Title="YUN. How to reset the micro controller from linux?" Tags="|arduino-yun|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3588" PostTypeId="1" CreationDate="2014-08-02T16:53:54.013" Score="0" ViewCount="2911" Body="&lt;p&gt;I'd like to use an H-Bridge  AND send PWM signal.&lt;/p&gt;&#xA;&lt;p&gt;I've used this schematics: &lt;a href=&quot;http://itp.nyu.edu/physcomp/Labs/DCMotorControl&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://itp.nyu.edu/physcomp/Labs/DCMotorControl&lt;/a&gt;&#xA;and use the PWM signal inside the &lt;em&gt;enablePin&lt;/em&gt;. But the H_Bridge is getting very hot.&lt;/p&gt;&#xA;&lt;p&gt;Am I wrong?&lt;/p&gt;&#xA;&lt;h3&gt;EDIT:&lt;/h3&gt;&#xA;&lt;p&gt;I'm using and H-Bridge but not for driving a motor, instead I'm driving a peltier cell (like this one: &lt;a href=&quot;https://www.sparkfun.com/products/10080&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/10080&lt;/a&gt;). What I'm trying to achieve is to have a fixed peltier cell and to have in the same side sometimes hot, sometimes cold. This behaviour is done by switching the positive and negative with the H-Bridge. To control how much cold and how much hot I'm using PWM.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-08-02T21:11:23.160" Title="H_Bridge with PWM gets too hot" Tags="|arduino-uno|pwm|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3589" PostTypeId="2" ParentId="3587" CreationDate="2014-08-02T17:02:03.287" Score="2" Body="&lt;p&gt;According to the Yun schematic, GPIO18 of the SoC is connected to the MCU reset circuitry. Toggling it should allow you to reset the MCU.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-02T17:02:03.287" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3590" PostTypeId="1" AcceptedAnswerId="3593" CreationDate="2014-08-02T17:02:06.777" Score="1" ViewCount="1660" Body="&lt;p&gt;I've got 2 int16_t numbers, say 388 and 10288, which are sensor readings from an accelerometer. I want to estimate the angle of the device on that, but seemingly there are some type overflow issues:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My final goal is this:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;theta =  atan(-ax/sqrt((float)ay*ay+az*az));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem occurs in the bracket: ay^2 and az^2 are the 2 power of the given numbers. I recalculated with matlab and for the above example I get &lt;code&gt;a^2+b^2 = 388^2+10288^2 = 105993488&lt;/code&gt; what I get from the arduino however is &lt;code&gt;152848&lt;/code&gt;.&#xA;To be short: I don't know much about fixed point math or thelike and I couldn't find a sufficient answer to this: How do I calculate the square root term?&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2014-08-02T19:40:15.050" Title="square root of large number" Tags="|accelerometer|data-type|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3592" PostTypeId="2" ParentId="3588" CreationDate="2014-08-02T17:32:06.253" Score="3" Body="&lt;p&gt;Short answer: You're drawing too much current through the H-bridge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer answer: The H-bridge is most efficient when fully on and that's when the chip gets rated for the maximum current. The rating also, probably, states that a heat sink is attached to the chip. Using PWM to slow down the motor decreases the current going through the bridge, but also incurs inefficiencies because the transistors / MOSFETs are partially on, and thus acting somewhat as resistors. This inefficiency manifests as heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have several options.&lt;br&gt;&#xA;1. Choose a smaller motor.  This reduces the overall current needed.  Only feasible if this is a learning project.&lt;br&gt;&#xA;2. Choose a beefier H-bridge.  This increases the ratings of the bridge to handle current for this motor.&lt;br&gt;&#xA;3. Add a heat-sink to the existing bridge.  This will help dissipate the heat generated.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally I'd recommend both 2 and 3, but it depends on your ultimate goal of the project.&lt;/p&gt;&#xA;" OwnerUserId="3416" LastEditorUserId="3416" LastEditDate="2014-08-02T18:01:00.780" LastActivityDate="2014-08-02T18:01:00.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3593" PostTypeId="2" ParentId="3590" CreationDate="2014-08-02T17:53:54.957" Score="5" Body="&lt;p&gt;You need 2 typecasts. So &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;atan(-ax/sqrt((float)ay*ay+(float)az*az));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise it will use int16_t for the right side of the addition and overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though for speed you might want to typecast them as &lt;code&gt;long&lt;/code&gt; (&lt;code&gt;int32_t&lt;/code&gt;), as floats calculations on the arduino are really slow. The &lt;code&gt;sqrt&lt;/code&gt; function will covert this double into a float for you.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-08-02T19:40:15.050" LastActivityDate="2014-08-02T19:40:15.050" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3594" PostTypeId="2" ParentId="3588" CreationDate="2014-08-02T18:02:28.177" Score="2" Body="&lt;p&gt;This L298N board with heat sink is widely available, low cost, used in many successful project with 2 amperes capacity to support reasonably large motors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Video, tutorial, code example in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=qwNvYYqBy7I&quot; rel=&quot;nofollow&quot;&gt;http://www.youtube.com/watch?v=qwNvYYqBy7I&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.icstation.com/product_info.php?products_id=2540#.U90l_kBbIlh&quot; rel=&quot;nofollow&quot;&gt;http://www.icstation.com/product_info.php?products_id=2540#.U90l_kBbIlh&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino-info.wikispaces.com/MotorDrivers&quot; rel=&quot;nofollow&quot;&gt;http://arduino-info.wikispaces.com/MotorDrivers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino-info.wikispaces.com/ArduinoShieldL298N&quot; rel=&quot;nofollow&quot;&gt;http://arduino-info.wikispaces.com/ArduinoShieldL298N&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-08-02T18:02:28.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3595" PostTypeId="2" ParentId="3588" CreationDate="2014-08-02T18:07:44.047" Score="2" Body="&lt;p&gt;Are you using the &lt;code&gt;L293NE&lt;/code&gt; or the &lt;code&gt;SN754410&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess it the &lt;code&gt;L293NE&lt;/code&gt;. With this one, if you set the enable to low, it will go into &quot;Fast motor stop&quot;. What this does is short the two pins of the motor. This will make the motor turn into a dynamo, will all the current that is being generated going through the IC. This will make the IC hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also means you motors are running very inefficiently.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-02T18:07:44.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3596" PostTypeId="2" ParentId="3567" CreationDate="2014-08-02T18:07:44.747" Score="2" Body="&lt;p&gt;LUFA is used for the USB to serial firmware on the separate USB-serial bridge AVR found on Uno and newer Megas. The firmware is compiled using a supplied makefile. Otherwise LUFA isn't used by Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But LUFA is probably the right choice if you want to make a USB audio device. It comes with examples of both input and output audio devices. But you will have to compile using the supplied makefile, unless you are really ninja. On a Linux distro it's easy - don't know about other OS'es.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The demo &quot;Audio Input Device Demo&quot; comes with LUFA and is ompatible with the atmega32u4 used on Leonardo. It can be set up to sample analog input and send it to the pc. From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On start-up the system will automatically enumerate and function as a USB microphone. By default, the demo will produce a square wave test tone when the board button is pressed. If USE_TEST_TONE is not defined in the project makefile, incoming audio from the ADC channel 1 will be sampled and sent to the host computer instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-02T18:07:44.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3597" PostTypeId="2" ParentId="3588" CreationDate="2014-08-02T19:55:18.893" Score="2" Body="&lt;p&gt;According to data sheet from factory, L293 and L298 do not go into fast stop mode if you connect and program them as below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have two inputs to control direction and one ENABLE for PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When PWM signal is zero, both transistors are high impedance according to page 2 of factory data in &lt;a href=&quot;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=2&amp;amp;ved=0CDUQFjAB&amp;amp;url=http%3A%2F%2Fwww.ti.com%2Flit%2Fds%2Fsymlink%2Fl293d.pdf&amp;amp;ei=0z7dU-G4OZPf8AX-loDQCA&amp;amp;usg=AFQjCNEHiZAPaBUP_j8kV3BBPstAKiFDyw&amp;amp;bvm=bv.72197243,d.dGc&quot; rel=&quot;nofollow&quot;&gt;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=2&amp;amp;ved=0CDUQFjAB&amp;amp;url=http%3A%2F%2Fwww.ti.com%2Flit%2Fds%2Fsymlink%2Fl293d.pdf&amp;amp;ei=0z7dU-G4OZPf8AX-loDQCA&amp;amp;usg=AFQjCNEHiZAPaBUP_j8kV3BBPstAKiFDyw&amp;amp;bvm=bv.72197243,d.dGc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data sheet Page 6 of L298, PWM connects to enable. CD is 10 and 01 for direction. fast stop is CD 00 or 11&#xA;&lt;a href=&quot;http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00000240.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00000240.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-08-02T19:55:18.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3598" PostTypeId="1" AcceptedAnswerId="3599" CreationDate="2014-08-02T19:58:51.857" Score="1" ViewCount="115" Body="&lt;p&gt;What does the &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=MQ2_Smoke_Detector_Shield_for_Arduino&quot; rel=&quot;nofollow&quot;&gt;MQ-2&lt;/a&gt; sensor detect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it detects concentrations of flammable gas. But does it detect smoke from fires too?&#xA;What about smoke from cigarettes, and other things?&lt;/p&gt;&#xA;" OwnerUserId="3425" LastEditorUserId="-1" LastEditDate="2014-08-06T12:13:25.410" LastActivityDate="2014-08-06T12:13:25.410" Title="What is exactly MQ-2 sensor?" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3599" PostTypeId="2" ParentId="3598" CreationDate="2014-08-02T20:26:43.707" Score="3" Body="&lt;p&gt;Simple answer is no. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are about 10 similar sensors, each detect specific kind of chemicals &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-08-02T20:26:43.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3600" PostTypeId="1" CreationDate="2014-08-03T04:22:49.190" Score="1" ViewCount="417" Body="&lt;pre&gt;&lt;code&gt;int i, j;&#xA;char data;&#xA;int flag=0;&#xA;&#xA;void loop() &#xA;{&#xA;if(Serial.available() &amp;gt; 0){&#xA;    data  = Serial.read();&#xA;    flag=0;&#xA;  }&#xA;&#xA;  if (data == 'd' &amp;amp;&amp;amp; 'b') {&#xA;    digitalWrite(cONOF, HIGH);&#xA;  } else if (data == 't' &amp;amp;&amp;amp; 'w') {&#xA;    digitalWrite(cONOF, LOW);&#xA;  }&#xA;&#xA;&#xA;  if (data == 'y' &amp;amp;&amp;amp; 'w') {&#xA;    digitalWrite(start, HIGH);&#xA;    delay(2000);&#xA;    digitalWrite(start, LOW);&#xA;  }&#xA;&#xA;&#xA;  if (data == 'e' &amp;amp;&amp;amp; 'r' &amp;amp;&amp;amp; 'h' &amp;amp;&amp;amp; 'i') {&#xA;    for (i=0;i&amp;lt;10;i++) {&#xA;      digitalWrite(horn, HIGH);&#xA;      delay(100);&#xA;      digitalWrite(horn, LOW);&#xA;      delay(100);&#xA;    }&#xA;    for (j=0;j&amp;lt;10;j++) {&#xA;      digitalWrite(horn, HIGH);&#xA;      delay(500);&#xA;      digitalWrite(horn, LOW);&#xA;      delay(500);&#xA;    }&#xA;    digitalWrite(horn, LOW);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to read data from the USART where the messages have more than one character. I tried the code above but it doesn't work well. For example, I want to send the message 'db' to turn the output on, but just sending 'd' also turns it on, how do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="3427" LastEditorUserId="1566" LastEditDate="2014-08-03T04:32:24.090" LastActivityDate="2014-08-03T04:44:42.937" Title="Read multiple char from USART" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3602" PostTypeId="2" ParentId="3600" CreationDate="2014-08-03T04:44:42.937" Score="1" Body="&lt;p&gt;You need split the reading into two processes - storing the characters and checking if they are the right message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To store the characters for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String message = &quot;&quot;;&#xA;&#xA;void loop() &#xA;{&#xA;while(Serial.available()) {&#xA;    char b = Serial.read();&#xA;&#xA;    if (b == '\r') {&#xA;        processMessage();&#xA;        message = &quot;&quot;;&#xA;    }&#xA;    else {&#xA;        message += b;&#xA;    }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The process might look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void processMessage() {&#xA;&#xA;    if (message == &quot;fb&quot;) {&#xA;         foo();&#xA;    }&#xA;    else if (message == &quot;bf&quot;) {&#xA;         bar();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just use the &lt;a href=&quot;http://playground.arduino.cc/code/messenger&quot; rel=&quot;nofollow&quot;&gt;Messenger library&lt;/a&gt; usually. But note you have to change &lt;code&gt;WProgram.h&lt;/code&gt; to &lt;code&gt;Arduino.h&lt;/code&gt; in &lt;code&gt;Messenger.cpp&lt;/code&gt; to get it to work.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-03T04:44:42.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3603" PostTypeId="1" AcceptedAnswerId="3605" CreationDate="2014-08-03T10:33:40.753" Score="5" ViewCount="614" Body="&lt;p&gt;Is there a delay function available that does not use &lt;code&gt;millis()&lt;/code&gt; which itself makes use of a timer? Does not need to be hyper-exact.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2014-08-03T17:09:31.560" Title="Delay function without using a timer" Tags="|time|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3604" PostTypeId="1" AcceptedAnswerId="3610" CreationDate="2014-08-03T10:37:01.740" Score="0" ViewCount="1836" Body="&lt;p&gt;Why is a toroidal inductor being used in the RFID reader described in &lt;em&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DIYRFIDReader&quot; rel=&quot;nofollow&quot;&gt;DIY FSK RFID Reader&lt;/a&gt;&lt;/em&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel that a toroidal inductor wouldn't be very effective in grasping the changes in electromagnetic field changes.&lt;/p&gt;&#xA;" OwnerUserId="1711" LastEditorUserId="510" LastEditDate="2016-03-21T00:19:41.680" LastActivityDate="2016-03-21T00:19:41.680" Title="125 kHz RFID reader with Arduino" Tags="|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3605" PostTypeId="2" ParentId="3603" CreationDate="2014-08-03T10:55:54.570" Score="4" Body="&lt;pre&gt;&lt;code&gt;delayMicroseconds(1000);// maximum delay is 65535 uS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;util/delay.h&amp;gt;&#xA;_delay_ms(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-08-03T17:09:31.560" LastActivityDate="2014-08-03T17:09:31.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3606" PostTypeId="2" ParentId="3573" CreationDate="2014-08-03T11:17:45.267" Score="5" Body="&lt;p&gt;Yep, the Arduino IDE kinda sucks eventually. There is no best practise really, as Arduino &lt;code&gt;*.ino&lt;/code&gt; files aren't proper c / c++ anyway. I would hope that people who know how to write C++ classes (as opposed to Arduino) would be able to do it outside the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion would be to make the *.ino file a test file. That is, it runs a set of functions to check that the library behaves as desired. It could also include example code, so people who use the library know how to include it in their programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that being said, time to fly Penguin...  Ditch the Arduino IDE and go with embedXcode or some other third party IDE template :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/32kbD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I just wanted to put a pic of a penguin)&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-03T11:17:45.267" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3607" PostTypeId="2" ParentId="3461" CreationDate="2014-08-03T13:32:11.853" Score="3" Body="&lt;p&gt;This is how I would write this loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (JsonArrayIterator it = root.begin(); it != root.end(); ++it) &#xA;{    &#xA;  JsonObject row = *it;    &#xA;&#xA;  char*  sensor    = row[&quot;sensor&quot;];  &#xA;  long   time      = row[&quot;time&quot;];  &#xA;  double latitude  = row[&quot;data&quot;][0];&#xA;  double longitude = row[&quot;data&quot;][1];&#xA;&#xA;  Serial.println(sensor);&#xA;  Serial.println(time);&#xA;  Serial.println(latitude, 6);&#xA;  Serial.println(longitude, 6);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And, if C++11 is available (which is not the case with Arduino IDE 1.0.5):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (auto row : root) &#xA;{    &#xA;  char*  sensor    = row[&quot;sensor&quot;];  &#xA;  long   time      = row[&quot;time&quot;];  &#xA;  double latitude  = row[&quot;data&quot;][0];&#xA;  double longitude = row[&quot;data&quot;][1];&#xA;&#xA;  Serial.println(sensor);&#xA;  Serial.println(time);&#xA;  Serial.println(latitude, 6);&#xA;  Serial.println(longitude, 6);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3430" LastActivityDate="2014-08-03T13:32:11.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3609" PostTypeId="1" CreationDate="2014-08-03T18:48:24.373" Score="2" ViewCount="160" Body="&lt;p&gt;I want to power down my Olimexino as much as possible and only wakeup on a pin-change interrupt. I removed the 3.3V/5V jumper (so the processor does not get power) and 3µA were displayed, so the voltage regulator is really a low power variant. What I have done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;power_all_disable();&#xA;set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;sleep_enable();&#xA;sleep_cpu();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This resulted in still using 220µA. Now I disable the ADC, too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ADCSRA = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which reduces it to 100µA. I've tried to disable further ADC-stuff using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ACSR = 0;&#xA;ADMUX = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and tried to disable (?) the Watchdog Timer using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WDTCSR = 1 &amp;lt;&amp;lt; WDP3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but without any further improvements. The datasheet for the 32u4 suggests to disable the Brown-Out-Detector, too, but I don't seem to be able to do that using code, but only by setting some fuses which is not possible directly using the Arduino IDE. Any further ideas?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2014-08-03T18:48:24.373" Title="Olimexino (32u4): power down" Tags="|power|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3610" PostTypeId="2" ParentId="3604" CreationDate="2014-08-03T22:54:15.223" Score="1" Body="&lt;p&gt;Yes, Chris Stratton is right. A toroidal inductor keeps flux within the core, reduces the external flux to near zero and have near zero ability to grasp/convert external flux/magnetic field into electrical signal. Apparently, the word 'toroidal' was used in loose sense referring to a circularly shaped coil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an real-life commercial product, a 125&amp;nbsp;kHz coil typically has many turns on a very thin wire on an open-air core (no core).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example profession factory made a 125&amp;nbsp;kHz RFID with a &lt;a href=&quot;http://en.wikipedia.org/wiki/GitHub&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt; Arduino library and photos of an antenna coil:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://www.seeedstudio.com/depot/125Khz-RFID-module-UART-p-171.html&quot; rel=&quot;nofollow&quot;&gt;125 kHz RFID module - UART&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/Seeed-Studio/RFID_Library&quot; rel=&quot;nofollow&quot;&gt;Seeed-Studio/RFID_Library&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/index.php?title=125Khz_RFID_module_-_UART&quot; rel=&quot;nofollow&quot;&gt;125Khz RFID module - UART&lt;/a&gt;&lt;/em&gt; (wiki)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, see &lt;em&gt;&lt;a href=&quot;http://www.8051projects.net/news-i140-5-building-rfid-card-reader-using-pic-microcontroller.html&quot; rel=&quot;nofollow&quot;&gt;Building RFID Card Reader using PIC Microcontroller&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, for higher frequency RFID, not shown in above examples, coils have fewer turns than for 125&amp;nbsp;kHz.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="510" LastEditDate="2016-03-21T00:19:26.680" LastActivityDate="2016-03-21T00:19:26.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3612" PostTypeId="1" AcceptedAnswerId="3887" CreationDate="2014-08-04T00:16:42.560" Score="0" ViewCount="2031" Body="&lt;p&gt;I wanted to use both &lt;a href=&quot;https://github.com/TMRh20/TMRpcm&quot; rel=&quot;nofollow noreferrer&quot;&gt;TMRpcm&lt;/a&gt; and &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/VirtualWire/&quot; rel=&quot;nofollow noreferrer&quot;&gt;VirtualWire&lt;/a&gt; with ATmega328 in an Arduino-like board I'm making, but both libraries use TIMER1. I wanted to use each lib for the following purposes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TMRpcm: play a WAV sound from an SD Card;&lt;/li&gt;&#xA;&lt;li&gt;VirtualWire: to receive commands from an RF remote control.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki/Advanced-Features&quot; rel=&quot;nofollow noreferrer&quot;&gt;TMRpcm Advanced Features Wiki&lt;/a&gt; has a section on &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki/Advanced-Features#timer2-usage&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to use TIMER2 instead&lt;/a&gt;, but I couldn't get it to work. They also say:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This is usually not the best solution.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So, before I spend any more time on this, I would like to hear what you guys have to say.&lt;/p&gt;&#xA;&lt;p&gt;So, my question is: &lt;strong&gt;is there a workaround to solve this conflict on the use of TIMER1, so I can use both libs in my project?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If not, &lt;strong&gt;what other alternatives do I have?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My circuits for reading the SD card and driving the speaker are similar to the schematic in this Instructable: &lt;a href=&quot;http://www.instructables.com/id/Playing-Wave-file-using-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Playing Wave file using Arduino&lt;/a&gt;. And I'm using one of those&#xA;&lt;a href=&quot;http://www.soldafria.com.br/datasheet/RWS-375-6(433_92mhz).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;433MHz Receiver modules&lt;/a&gt; for the RF part (standard, working circuit).&lt;/p&gt;&#xA;&lt;p&gt;Both features, the RF receiver and SD card WAV playing, work correctly, when run separately (with separate sketches).&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-04T19:52:45.523" Title="Using both TMRpcm and VirtualWire libs with ATmega328, despite the conflict on TIMER1" Tags="|timers|sd-card|virtualwire|tmrpcm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3613" PostTypeId="1" AcceptedAnswerId="3615" CreationDate="2014-08-04T01:19:08.970" Score="5" ViewCount="1528" Body="&lt;p&gt;I am doing a light speed determination experimsmt. Lightspeed is around 3*10^8 m/s. For this, I need to measure time interval between 2 light sensors in nanoseconds, Somewhere about 50ns. Is this possible using the Uno R3? I know the clock is 16MHz only but is the clock irrelevantto the topic? If it is not possible, Some tips would be helpful. Thank you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for irrelevant tags. No suitable tags found.&lt;/p&gt;&#xA;" OwnerUserId="3432" LastActivityDate="2014-08-04T06:07:25.027" Title="Shortest time interval that Arduino Uno R3 can read" Tags="|time|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3615" PostTypeId="2" ParentId="3613" CreationDate="2014-08-04T06:07:25.027" Score="2" Body="&lt;p&gt;At 16MHz, the quickest operation that the cpu can do (a one cycle operation) will take 62.5 nanoseconds (1/(16*10^6) seconds). That means the best resolution you could conceivably have is 62.5 ns chunks. It will take considerably longer than one clock to respond to an outside event though, so making an experiment will be really tough even then.&lt;/p&gt;&#xA;&lt;p&gt;Maybe you could build an experiment like the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fizeau-Foucault_apparatus#mediaviewer/File:Fizeau.JPG&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fizeau apparatus&lt;/a&gt; where the arduino measured pulses of light that make it back through the slit? Those would be measured in microseconds. The arduino could change the speed of the grooved wheel and maximize the returning pulse width, reading the rpm then gives you the speed of light.&lt;/p&gt;&#xA;&lt;p&gt;I'll note that since the meter is defined by the speed of light, and the foot defined by the meter, You would not be measuring the speed of light in feet or meters per second; you would be measuring the length of a meter given how long a second is, or vice versa.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-08-04T06:07:25.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3616" PostTypeId="2" ParentId="3612" CreationDate="2014-08-04T07:00:23.427" Score="2" Body="&lt;p&gt;You could edit the VirtualWire.cpp source to use Timer2 instead of Timer1. For VirtualWire 1.18 the relevant section starts on line 512 with &lt;code&gt;#else // ARDUINO&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On line 515 change &lt;code&gt;(uint16_t)-1&lt;/code&gt; to &lt;code&gt;(uint8_t)-1&lt;/code&gt; since Timer2 is only 8 bit. Then change all the TCCR1A, TCCR1B, OCR1A, TIMSK1 and OCIE1A to their Timer2 equivalent (hint: swap the 1's for 2's). Line 533 should be the last. On line 778 you also need to make a change to use TIMER2_COMPA_vect for VW_TIMER_VECTOR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that it helps.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-04T07:00:23.427" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3617" PostTypeId="1" AcceptedAnswerId="3710" CreationDate="2014-08-04T22:12:52.627" Score="0" ViewCount="102" Body="&lt;p&gt;I would like to be able to design an Arduino circuit for a fridge monitor that would have a temperature sensor, a small speaker to emit a sound when the temperature changes past a threshold and an LCD screen showing the current temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a few examples online, but I would like to know why components like capacitors and transistors are used in their circuits so I'd be able to design similar circuits myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this list of electronics topics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Basic Theory&lt;/li&gt;&#xA;&lt;li&gt;Basic Passive Components&lt;/li&gt;&#xA;&lt;li&gt;Passive Circuits&lt;/li&gt;&#xA;&lt;li&gt;Discrete Active Components&lt;/li&gt;&#xA;&lt;li&gt;Active Circuits&lt;/li&gt;&#xA;&lt;li&gt;Integrated Circuits&lt;/li&gt;&#xA;&lt;li&gt;Digital Logic&lt;/li&gt;&#xA;&lt;li&gt;Analog&lt;/li&gt;&#xA;&lt;li&gt;Signals&lt;/li&gt;&#xA;&lt;li&gt;Outputs&lt;/li&gt;&#xA;&lt;li&gt;Inputs&lt;/li&gt;&#xA;&lt;li&gt;Digital Electronics&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some of these things, like digital logic seem unnecessary in such a project, but obviously some others are useful, but I don't know which. I'd like to know what it would be useful to study so I can understand the reasons for the circuit design of something like a fridge monitor.&lt;/p&gt;&#xA;" OwnerUserId="3442" LastEditorUserId="220" LastEditDate="2014-08-05T23:40:26.110" LastActivityDate="2014-08-10T11:27:10.800" Title="What electronics should I study to create something like a fridge temperature monitor?" Tags="|electronics|" AnswerCount="1" CommentCount="6" ClosedDate="2014-12-10T15:18:07.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="3618" PostTypeId="1" CreationDate="2014-08-04T22:29:07.997" Score="0" ViewCount="1035" Body="&lt;p&gt;I am using &lt;a href=&quot;http://www.dx.com/p/micro-sd-card-storage-memory-board-module-for-arduino-146706?Utm_rid=52746118&amp;amp;Utm_source=affiliate#.U-AHiEQVYjg&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; micro-sd card reader, and my wiring configuration is as follows (double and triple checked):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3.3v goes to 3.3v on the Arduino UNO&#xA;GND goes to Ground on Arduino UNO&#xA;D0 goes to pin 12 on Arduino UNO&#xA;D1 goes to pin 11 on Arduino UNO&#xA;CLK goes to pin 13 on Arduino UNO&#xA;D3 goes to pin 4 on Arduino UNO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the 'basic' example from the &lt;a href=&quot;https://github.com/TMRh20/TMRpcm&quot; rel=&quot;nofollow&quot;&gt;TMRpcm library&lt;/a&gt;, everything compiles and uploads properly with no warnings. Looking at the Serial Monitor, I get &quot;SD Fail&quot;, which, according to the comments, means that the SD card failed to initialize. The card is present, and works in my computer. Do I have something wired wrong, or is there another issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using a different pin for D3, and changed the code as needed. Still no luck.&lt;/p&gt;&#xA;" OwnerUserId="1303" LastEditorUserId="1303" LastEditDate="2014-08-04T22:36:11.113" LastActivityDate="2017-06-09T03:25:52.687" Title="Using TMRpcm object, why is the SD Card failing to be found by arduino?" Tags="|sd-card|audio|tmrpcm|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3619" PostTypeId="1" CreationDate="2014-08-05T06:25:52.100" Score="3" ViewCount="287" Body="&lt;p&gt;I am using Arduino uno. My data is storing into EEPROM whenever i run my program, it will store multiple data depend on the loop. For my program it calculate 10 sample in 0.1 sec, so 100 sample in 1 sec. How can i know how much memory i can run? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have added this code to my program it display 895. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;int freeRam () {&#xA;  extern int __heap_start, *__brkval; &#xA;  int v; &#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;void setup(){&#xA;Serial.begin(9600);&#xA;Serial.println(freeRam());}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3450" OwnerDisplayName="Fufu Alex" LastActivityDate="2014-08-05T07:53:45.613" Title="Knowing the Arduino memory capacity" Tags="|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3620" PostTypeId="2" ParentId="3619" CreationDate="2014-08-05T07:07:27.920" Score="5" Body="&lt;p&gt;The &lt;code&gt;freeRam()&lt;/code&gt; method you are suggesting calculates the &quot;space&quot; between the &lt;code&gt;heap&lt;/code&gt; and the &lt;code&gt;stack&lt;/code&gt;, thus it returns the free &lt;code&gt;SRAM&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no way to calculate free remaining &lt;code&gt;EEPROM&lt;/code&gt; (if that is what you are asking), since it just contains some arbitrary data at arbitrary locations. Get the &lt;code&gt;EEPROM&lt;/code&gt; capacity from the device data sheet and make sure to write within its boundaries.&lt;/p&gt;&#xA;" OwnerUserId="3446" LastEditorUserId="3446" LastEditDate="2014-08-05T07:18:56.773" LastActivityDate="2014-08-05T07:18:56.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3623" PostTypeId="1" AcceptedAnswerId="3624" CreationDate="2014-08-05T10:09:51.127" Score="1" ViewCount="2317" Body="&lt;p&gt;I have a sketch to display a temperature obtained from 1-wire DS18B20 sensors. The sketch works fine, however when I connect two sensors to my board, the text on the LCD displays gets corrupted (### and other symbols shown instead of a temperature).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried plugging each of the two DS18B20 sensors individually and it works with both of them, the problem shows only when I use both at the same time. I am connecting them both with black to ground, red to 5V and white to Dx and to 5V via a 4.7 kOhm pull-up resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have little idea how to check what is wrong - is it some kind of interference, insufficient voltage, or a SW problem?&lt;/p&gt;&#xA;" OwnerUserId="3452" LastActivityDate="2014-08-05T10:25:00.427" Title="LCD showing weird characters when using two 1-wire temperature sensors" Tags="|lcd|1-wire|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3624" PostTypeId="2" ParentId="3623" CreationDate="2014-08-05T10:25:00.427" Score="0" Body="&lt;p&gt;After some more searching I have found &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=kpntcnv2f3dq544iuh5inrl404&amp;amp;topic=86731.msg650003#msg650003&quot; rel=&quot;nofollow&quot;&gt;Arduino forum topic LCD text corrupts after Arduino runs for length of time&lt;/a&gt;. I have followed &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=j4imm6sr0dbrnas4pp1unc8ae5&amp;amp;topic=86731.msg653008#msg653008&quot; rel=&quot;nofollow&quot;&gt;this advice&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In particular, try running the LCD ground wire directly to a ground pin on the Arduino (not to the breadboard) and keep it short.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This seemed to solve the issue, therefore it was likely some kind of interference on the ground wiring. (Before this, the ground to the LCD went trought the breadboard power bus).&lt;/p&gt;&#xA;" OwnerUserId="3452" LastActivityDate="2014-08-05T10:25:00.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3625" PostTypeId="1" AcceptedAnswerId="3626" CreationDate="2014-08-05T11:17:40.777" Score="11" ViewCount="101258" Body="&lt;p&gt;Recently I have linked up a typical 16*2 LCD (Liquid Crystal Display) display to my Arduino Uno and have linked all the pins up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my connection:(LCD pin first)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1=GND, 2=+5v, 4=11, 6=12, 11=5, 12=4, 12=3, 14=2, 15=backlight positive, 16=backlight negative&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  // set up the LCD's number of columns and rows: &#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;hello, world!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // set the cursor to column 0, line 1&#xA;  // (note: line 1 is the second row, since counting begins with 0):&#xA;  lcd.setCursor(0, 1);&#xA;  // print the number of seconds since reset:&#xA;  lcd.print(millis()/1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the code that is the default for the LCD, I didn't write it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have done all this and when I turn it on the screen is blank and nothing is happening. Could anyone explain what I have done wrong?&lt;/p&gt;&#xA;" OwnerUserId="3454" LastEditorUserId="6936" LastEditDate="2015-03-22T14:45:31.397" LastActivityDate="2016-07-15T17:33:47.357" Title="Why is my LCD 16*2 is not displaying any characters, although all the wiring is correct?" Tags="|arduino-uno|programming|pins|lcd|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3626" PostTypeId="2" ParentId="3625" CreationDate="2014-08-05T11:31:04.300" Score="7" Body="&lt;p&gt;Check out this tutorial on &lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1&quot; rel=&quot;noreferrer&quot;&gt;Adafruit&lt;/a&gt;. It will walk you through setting it up. In the tutorial they change the pins, which I believe is the issue here. Here is a snippet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pmgMg.jpg&quot; alt=&quot;Fritzing Diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And change your pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-08-05T11:31:04.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3628" PostTypeId="2" ParentId="815" CreationDate="2014-08-05T14:25:37.967" Score="4" Body="&lt;p&gt;There are small board-mount AC/DC converters like this one &lt;a href=&quot;http://www.digikey.com/product-detail/en/BP5063-5/BP5063-5-ND/658569&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com/product-detail/en/BP5063-5/BP5063-5-ND/658569&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3456" LastActivityDate="2014-08-05T14:25:37.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3629" PostTypeId="1" AcceptedAnswerId="4344" CreationDate="2014-08-05T15:21:30.417" Score="3" ViewCount="1019" Body="&lt;p&gt;This is a home heating system hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to add an arduino in-line between my thermostat and air handler; and possibly between the air handler and outdoor compressor. The long-term goal is to post long-term statistics to an RRD web page (run time, power consumption, temp, etc.) and control the blower (without the heat) automatically when we are burning our wood stove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The product is a Nordyne IQDrive (notable in that the equipment comes with 5 separate brand logos to adhere to the equipment: Tappan, Frigidaire, Westinghouse, Nutone, and Broan).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this stage, all I want to attempt to do is to tap the serial links and record the conversations. I would prefer not to shoot myself in the foot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;System Field Wiring Instructions&quot; describe both links as &quot;serial.&quot; The wiring diagrams label the connection points as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;air handler interface board --&gt; [description] --&gt; thermostat&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      G --&amp;gt; GND --&amp;gt; C&#xA;      - --&amp;gt; DX- --&amp;gt; B-&#xA;      + --&amp;gt; DX+ --&amp;gt; A+&#xA;      R --&amp;gt; R   --&amp;gt; R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Googl'ing these might indicate that this is an RS485 (never heard of it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I tap and record the communication?&lt;/p&gt;&#xA;" OwnerUserId="3380" LastActivityDate="2014-09-25T23:22:28.300" Title="How to tap my thermostat's serial line" Tags="|serial|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3630" PostTypeId="1" CreationDate="2014-08-05T17:56:09.917" Score="0" ViewCount="1063" Body="&lt;p&gt;I'm new to the Arduino world (or the electronics world for that matter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the Arduino Yun and the WifiStatus code works fine (so does the HttpClient). &#xA;But every time I try to run the bridge sample code, all I see is the pin 13 led light up, and the browser commands don't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I have updated the open-wrt to ver. 1.3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts on why this would be happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to reboot arduino using the hardware switches as well as from the web console. The blink sketch works fine, so does the WifiStatus code and the HttpClient code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other problem I face after every few uploads is that the IDE is stuck at &quot;Uploading...&quot;. I have tried to give it more time (even an hour). But then I had to unplug it from the Mac and restarted. Then it worked but only for a few times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this problem is not specific to the Bridge code. The uploading issue has occurred with other sample code as well. But at least the code worked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the result from the command &lt;code&gt;ls /dev/tty.*&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.Bluetooth-Incoming-Port    /dev/tty.usbmodem1431&#xA;/dev/tty.Bluetooth-Modem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3459" LastEditorUserId="3459" LastEditDate="2014-08-07T02:20:59.453" LastActivityDate="2014-08-07T02:33:40.027" Title="Arduino Yun's sample &quot;Bridge&quot; code not working" Tags="|arduino-yun|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3631" PostTypeId="2" ParentId="3569" CreationDate="2014-08-05T18:01:08.137" Score="2" Body="&lt;p&gt;So after a ton more research I figured out what I was doing wrong. For anyone who reads these answers, I found two web sites to be an enormous help. They are &lt;a href=&quot;http://playground.arduino.cc/uploads/Main/arduino_notebook_v1-1.pdf&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/uploads/Main/arduino_notebook_v1-1.pdf&lt;/a&gt;  and  &lt;a href=&quot;http://mikrohw.wz.cz/HakDuino/Arduino_Cookbook.pdf&quot; rel=&quot;nofollow&quot;&gt;http://mikrohw.wz.cz/HakDuino/Arduino_Cookbook.pdf&lt;/a&gt;   Good luck to you and have fun with your project. Thank you Gerben &amp;amp; Doowybbob for responding and trying to get me to look in the right direction. Turns out that a lot of my code was correctly heading in the right direction. But in my if statements, I wasn't addressing all the possible states. So now the LEDs light up at the appropriate time and I also added a buzzer. Here is my final code...... Thanks and Cheers, SWTORguy &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PIEZO 5 // pin 5 is capable of PWM (Pulse width modulation) output to drive tones&#xA;#include &amp;lt;WProgram.h&amp;gt;&#xA;#include&amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;  LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&#xA;/* pin laayout of the LCD with the arduino:&#xA;arduino pin = LCD pins &#xA;7=RS&#xA;8=E&#xA;9=D4&#xA;10=D5&#xA;11=D6&#xA;12=D7&#xA;RW=ground&#xA;*/&#xA;&#xA;const int button = A5;  // changes 2 to an integer from a constant&#xA;int buttonState;&#xA;int prevButtonState;&#xA;&#xA;int inpin=2; //switchpin (rolling of dice1)&#xA;int reading; // stocks switchpin&#xA;&#xA;int inpin2=4; //switchpin (rolling of dice2)&#xA;int reading2; //stocks switchpin&#xA;&#xA;int inpin3=6; //switchpin (rolling of dice3)&#xA;int reading3; //stocks switchpin&#xA;&#xA;int ran; //stocks randoms for dice 1 &#xA;int ran2; //stocks random for dice 2&#xA;int ran3; // stocks random for dice 3&#xA;&#xA;int outpin=LOW;&#xA;int LED1=13; //red LED&#xA;&#xA;int outpin2=LOW;&#xA;int LED2=1; //blue LED&#xA;&#xA;int outpin3=LOW;&#xA;int LED3=3; //green LED&#xA;&#xA;int outpin4=LOW;&#xA;int BUZ=5; //piezio Buzzer&#xA;&#xA;int del = 500; //buzzers delay time for inbetween LED flashes&#xA;&#xA;void setup(){&#xA;   lcd.begin(16,2);&#xA;   pinMode (PIEZO, OUTPUT); //pin mapping&#xA;   pinMode(LED1,OUTPUT); //pin mapping&#xA;   pinMode(LED2,OUTPUT); //pin mapping&#xA;   pinMode(LED3,OUTPUT); //pin mapping&#xA;   pinMode (button, INPUT); //pin mapping&#xA;   pinMode (reading, INPUT); //pin mapping&#xA;   pinMode (reading2, INPUT); //pin mapping&#xA;   pinMode (reading3, INPUT); //pin mapping&#xA;}&#xA;&#xA;void loop(){&#xA;    buttonState = digitalRead (button);&#xA;    if (buttonState != prevButtonState &amp;amp;&amp;amp; buttonState == HIGH) //pushing the button&#xA;    {&#xA;    //reading of switch    &#xA;    reading=digitalRead(inpin);&#xA;    reading2=digitalRead(inpin2);&#xA;    reading3=digitalRead(inpin3);&#xA;&#xA;    //random numbers generation    &#xA;    ran3=random(1,7); // #'s 1 through 6&#xA;    ran2=random(1,7); // #'s 1 through 6&#xA;    ran=random(1,7); // #'s 1 through 6   &#xA;&#xA;&#xA;    // Set the LCD screen for dice 1-3 label on the top.    &#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;die&quot;);&#xA;&#xA;    lcd.setCursor(5,0);&#xA;    lcd.print(&quot;die2&quot;);&#xA;&#xA;    lcd.setCursor(11,0);&#xA;    lcd.print(&quot;die3&quot;);&#xA;&#xA;    //display of random number.    &#xA;    if (reading==HIGH){&#xA;        lcd.setCursor(2,1);&#xA;        lcd.print(ran);&#xA;        delay(250); // not really clean but used as a debounce function.&#xA;    }&#xA;&#xA;    if(reading2==HIGH){  &#xA;       lcd.setCursor(5,0);&#xA;       lcd.print(&quot;die2&quot;);&#xA;       lcd.setCursor(8,1);&#xA;       lcd.print(ran2);&#xA;      delay(250);&#xA;    }&#xA;&#xA;    if(reading3==HIGH){&#xA;       lcd.setCursor(11,0);&#xA;       lcd.print(&quot;die3&quot;);&#xA;       lcd.setCursor(14,1);&#xA;       lcd.print(ran3);&#xA;       delay(250);&#xA;    }&#xA;&#xA;    /*the logic that tells which LED to blink and when to sound the buzzer&#xA;      dependent upon which state the random numbers dispayed are in*/&#xA;    if (ran == ran2 &amp;amp;&amp;amp; ran2 == ran3) // random number state (3 of a kind)&#xA;    {&#xA;      for (int c=0; c &amp;lt;= 2; c++) // variable defining how many times the green LED will blink and buzzer sound&#xA;      {&#xA;          digitalWrite(PIEZO, LOW); // buzzer off&#xA;          delay(del); // wait for .5 second&#xA;          digitalWrite(LED3, HIGH);   // Green - turn the LED on (HIGH is the voltage level)&#xA;          delay(100);               // wait for a second&#xA;          digitalWrite(LED3, LOW);    // turn the LED off by making the voltage LOW&#xA;          delay(100);               // wait for a second&#xA;          analogWrite(PIEZO, 128); //Buzzer on&#xA;          delay(del); // wait for .5 second&#xA;      }&#xA;      digitalWrite(PIEZO, LOW); //buzzer off&#xA;    }else{&#xA;        if(ran == ran2 || ran2 == ran3 || ran == ran3) // random number state (2 of a kind)&#xA;        {&#xA;            for (int b=0; b &amp;lt;= 2; b++) // variable defining how many times the blue LED will blink and buzzer sound&#xA;            {&#xA;                digitalWrite(PIEZO, LOW); // buzzer off&#xA;                delay(del); // wait for .5 second&#xA;                digitalWrite(LED2, HIGH);  //Blue - turn the LED on (HIGH is the voltage level)&#xA;                delay(100);   // wait for a second&#xA;                digitalWrite(LED2, LOW);  // turn the LED off by making the voltage LOw&#xA;                delay(100);   // wait for a second&#xA;                analogWrite(PIEZO, 128); //Buzzer on&#xA;                delay(del); // wait for .5 second&#xA;            }&#xA;            digitalWrite(PIEZO, LOW); //buzzer off&#xA;        }else{&#xA;            for (int a=0; a &amp;lt;= 10; a++) // variable defining how many times the red LED will blink.&#xA;            {&#xA;                digitalWrite(LED1, HIGH);   // Red - turn the LED on (HIGH is the voltage level)&#xA;                delay(100);               // wait for a second&#xA;                digitalWrite(LED1, LOW);    // turn the LED off by making the voltage LOW&#xA;                delay(100);               // wait for a second&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;  }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3414" LastEditorUserId="186" LastEditDate="2014-09-14T13:52:58.267" LastActivityDate="2014-09-14T13:52:58.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3632" PostTypeId="1" AcceptedAnswerId="3633" CreationDate="2014-08-05T21:31:20.613" Score="7" ViewCount="9587" Body="&lt;p&gt;I currently use my Arduino to program Attiny85. As I have one of these &lt;a href=&quot;http://www.ebay.com/itm/New-1PCS-5PIN-PL2303-USB-To-TTL-Auto-Converter-Adapter-Module-unit-For-arduino-/141150349286&quot;&gt;USB-to-TTL adapters&lt;/a&gt; I am wondering if it is possible to program Attiny85 with it, to free up my Arduino. I know it is possible to program Atmega's with such a thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is in fact possible to use the converter as a simple programmer for Attiny's, how should I connect the converter to the Attiny?&lt;/p&gt;&#xA;" OwnerUserId="3464" LastActivityDate="2014-08-05T22:20:03.980" Title="Is it possible to program an Attiny85 with a USB-to-TTL converter?" Tags="|avr|attiny|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3633" PostTypeId="2" ParentId="3632" CreationDate="2014-08-05T22:20:03.980" Score="5" Body="&lt;p&gt;Yes, it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the FTDI chip (assuming that is what you have) can be accessed as either Virtual Com Port &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;noreferrer&quot;&gt;VCP&lt;/a&gt; or &lt;a href=&quot;http://www.ftdichip.com/Drivers/D2XX.htm&quot; rel=&quot;noreferrer&quot;&gt;D2XX&lt;/a&gt;. Where VCP is the traditional method of using them as Serial Ports with avrdude calling &quot;-c arduino -P COM3 -b115200&quot;. However the later D2XX method allows for the pins to be Bit Bang'ed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can see in this &lt;a href=&quot;http://doswa.com/2010/08/24/avrdude-5-10-with-ftdi-bitbang.html&quot; rel=&quot;noreferrer&quot;&gt;tutorial&lt;/a&gt; it is possible to call avrdude with a programmer of &quot;-c ftdi&quot;. Assuming that the D2XX drivers are installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I see in the current releases 1.0.5r2 and 1.5.7's avrdude's config files that a programmer of type &quot;avrftdi&quot; is supported, as opposed to the article &quot;ftdi&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that is not to say the IDE natively supports its. You will have to either call avdude manually. Or add the &quot;avrftdi&quot; to &quot;\arduino-1.5.7\hardware\arduino\avr\programmers.txt&quot; so that the IDE will be aware of it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That all said I see &quot;Tiny AVR Programmer&quot; that are very in-expensive.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-08-05T22:20:03.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3634" PostTypeId="1" CreationDate="2014-08-05T22:38:55.417" Score="1" ViewCount="13645" Body="&lt;p&gt;I've tried different USB cables, computers, ports and none of them can detect my possibly bricked Mega 2560 R3. Nothing shows up at all in the Device Manager, not even &quot;Unknown Device&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the board is plugged in via USB, the &quot;L&quot; LED is constantly lit as well as the &quot;ON&quot; LED next the reset button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up on this article here and I gave it a try, which I believe is putting it in DFU mode. However I'm not having any luck with this. &lt;a href=&quot;http://www.wayneandlayne.com/blog/2011/02/16/fixing-linux-firmware-issues-on-arduino-mega-2560/&quot; rel=&quot;nofollow&quot;&gt;http://www.wayneandlayne.com/blog/2011/02/16/fixing-linux-firmware-issues-on-arduino-mega-2560/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any one have any ideas on where to go from here? I'm very new with Arduino.&lt;/p&gt;&#xA;" OwnerDisplayName="user29269" LastEditorUserId="1576" LastEditDate="2014-08-06T00:26:42.197" LastActivityDate="2018-02-21T07:35:55.547" Title="Computer not detecting my Arduino MEGA 2560 R3" Tags="|arduino-mega|led|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3636" PostTypeId="2" ParentId="3634" CreationDate="2014-08-06T00:00:30.197" Score="0" Body="&lt;p&gt;I have had the same symptom with a Arduino Decimilia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case had the USB to Serial chip failed. I used a USB to Serial device to verify the problem&lt;/p&gt;&#xA;" OwnerUserId="1576" LastActivityDate="2014-08-06T00:00:30.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3637" PostTypeId="2" ParentId="1868" CreationDate="2014-08-06T06:10:31.867" Score="0" Body="&lt;p&gt;There is an alternative to change the bootloader. Introduce a RC circuit in the relay driver that delay the rely to switch ON.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Please add info about the relay and/or driver circuit for a better answer.&lt;/p&gt;&#xA;" OwnerUserId="1576" LastActivityDate="2014-08-06T06:10:31.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3638" PostTypeId="1" AcceptedAnswerId="3643" CreationDate="2014-08-06T07:12:50.567" Score="2" ViewCount="3350" Body="&lt;p&gt;I have my Arduino Uno connected to the PC via USB when prototyping.  I am developing a thermometer with memory, using DS18B20 sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When PC is shut down, there is no power on the USB and the Arduino is off. Sometimes, when my PC is turned off for several hours and then, when I turn it on, the Arduino is started, but it behaves &quot;strange&quot; - the program is showing buggy values on the display, looking like if there is some bug in the sketch. However, when I upload the sketch again, it works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buggy values are the averages for the run, computed simply by summing a float and dividing by int. What I see is e.g. instead of seeing something around 23.5 I see 85.1. The current values read from the sensor look OK (show 23.5 as expected), but I cannot tell for sure if perhaps some value read early might be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not easy to reproduce, I see it only sometimes, always when powering Arduino on after several hours without power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first idea is either the sketch got corrupted during the long power down, or variables are initialized wrong, and the sample sum / sample count is not zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I though the sketches are uploaded into the Flash RAM, which should be non-volatile &lt;a href=&quot;http://arduino.cc/en/Tutorial/Memory&quot; rel=&quot;nofollow&quot;&gt;according to the docs&lt;/a&gt;. Is there something obvious I am missing, some explanation why is the sketch working differently after long power down?&lt;/p&gt;&#xA;" OwnerUserId="3452" LastEditorUserId="3452" LastEditDate="2018-03-28T13:08:45.370" LastActivityDate="2018-03-28T13:08:45.370" Title="Wrong data from DS18B20 temperature sensor after long power off" Tags="|sensors|power|sketch|flash|temperature-sensor|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3639" PostTypeId="1" AcceptedAnswerId="3641" CreationDate="2014-08-06T07:31:01.310" Score="2" ViewCount="2938" Body="&lt;p&gt;This is something I'm struggling with for a while and fail to find solid solution.&#xA;The Arduino IR library provides method for recording arbitrary IR code and re-sending it. This gave me different results every time I recorded the IR remote, so I wrote a little code, based on interrupts, that try to record the IR rise/fall as accurately as possible. &#xA;I am working with ATTiny85 running at 8Mhz on internal oscillator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(4,3);&#xA;&#xA;const int dataSize = 40;&#xA;int data[dataSize];&#xA;int dataLength[dataSize];&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(0, OUTPUT); // 0 is IR receiver pin&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Start&quot;);&#xA;  attachInterrupt(0,IR_ISR,CHANGE); &#xA;  mySerial.println(&quot;Registered&quot;);&#xA;  sei();&#xA;}&#xA;volatile unsigned long prev = micros();&#xA;volatile unsigned long curr = -1;&#xA;volatile unsigned short index = 0;&#xA;volatile bool rising = true;&#xA;void IR_ISR()&#xA;{&#xA;  if (!rising)&#xA;  {&#xA;    dataLength[index] = micros() - curr;&#xA;    rising = !rising;&#xA;    return;&#xA;  }&#xA;&#xA;  curr = micros();&#xA;&#xA;  data[index++] = (int)curr-prev;&#xA;&#xA;  prev = curr; &#xA;  rising = !rising;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  delay(5000);&#xA;  for (int i=1; i&amp;lt;dataSize; i++)&#xA;  {&#xA;    mySerial.print(data[i]);&#xA;    mySerial.print(&quot;(&quot;);&#xA;    mySerial.print(dataLength[i]);&#xA;    mySerial.print(&quot;)&quot;);&#xA;    mySerial.print(&quot;; &quot;);&#xA;  }&#xA;  mySerial.println();&#xA;  index = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is that the milliseconds alter on each record of the remote control, here is an example of the output of 3 attempts of clicking at the same button of the remote control (I pasted only the first 5 IR modulations to avoid too much text, total is about 39):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Start&lt;br&gt;&#xA;  Registered&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;14104(9496); 1184(672); 1184(616); 1160(656); 1176(672); ...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;14096(9480); 1184(664); 1208(568); 1136(616); 1184(664); ...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;14096(9384); 1216(576); 1136(616); 1184(664); 1208(560); ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The format is: [microseconds from previous falling edge](microseconds from rise to fall);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the results vary. According to the &lt;a href=&quot;http://arduino.cc/en/Reference/Micros&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; website, the micros() function has a 8 microseconds resolution on 8Mhz AVR's, but the difference between reads is bigger than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not reliable enough for me to solidly duplicate a remote control, and I'm looking for a resolution that will provide accurate results, as the magnitude of every deviation increases when the voltages are low (for example, with a 3v 2032 coin battery half discharged). &lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2020-03-14T19:13:42.980" Title="Reliably duplicate custom IR remote control with ATTiny85" Tags="|attiny|ir|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3641" PostTypeId="2" ParentId="3639" CreationDate="2014-08-06T09:04:50.363" Score="4" Body="&lt;p&gt;The exact duration of the pulses don't matter much. In your example, you see that in all three recorded samples that's &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;about 14000 (about 9400); about 1200 (about 600); about 1200 (about 600) etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What matters is that nowhere you have pulses of about 900 : in other words if the receiver detects a 672 pulse it will know that it's definitely a 600, not a 1200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you send exactly those values, the receiver will recognize it. &lt;/p&gt;&#xA;" OwnerUserId="367" LastActivityDate="2014-08-06T09:04:50.363" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3642" PostTypeId="1" CreationDate="2014-08-06T09:13:44.793" Score="2" ViewCount="8004" Body="&lt;p&gt;I'm trying to follow this &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial to program an ATtiny85 micro-controller using my Arduino Uno r3 as the ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am up to the final step on the tutorial, but get an error when attempting to compile my sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'OUTPUT' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried multiple &quot;Blink&quot; scripts, but none have seemed to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My full error log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Blink.ino:10:21: error: Arduino.h: No such file or directory&#xA;Blink.ino: In function 'void setup()':&#xA;Blink:15: error: 'OUTPUT' was not declared in this scope&#xA;Blink:15: error: 'pinMode' was not declared in this scope&#xA;Blink.ino: In function 'void loop()':&#xA;Blink:20: error: 'HIGH' was not declared in this scope&#xA;Blink:20: error: 'digitalWrite' was not declared in this scope&#xA;Blink:21: error: 'delay' was not declared in this scope&#xA;Blink:22: error: 'LOW' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried including Arduino.h, no help, and changing &quot;OUTPUT&quot; to &quot;0x01&quot;, as it is defined to said value in Arduino.h, but instead got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: 'pinMode' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas as to what is happening?&lt;/p&gt;&#xA;" OwnerUserId="3470" LastActivityDate="2015-01-24T23:14:03.537" Title="'OUTPUT' was not declared in this scope - ATtiny85 with Arduino Uno r3 as ISP" Tags="|arduino-uno|attiny|arduinoisp|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3643" PostTypeId="2" ParentId="3638" CreationDate="2014-08-06T10:13:58.503" Score="3" Body="&lt;p&gt;There should be no difference between turning on your computer and plugging in a USB cable. The embedded devices typically plugged into a USB ports such as mice, keyboards, wireless adapters, hard drives, etc don't have their FLASH memory corrupted when the computer is turned on so it is unlikely that your Arduino would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To confirm there isn't something dodgy going on with the USB power supplied to the board, use a multimeter to monitor the 5V pin of the Arduino. If the voltage isn't going too high or too low then everything should be fine. Even if it goes too low, the microcontroller will have brown-out-detect enabled to shut it down in this event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You mentioned a display. Perhaps, and this is pure speculation, some how the display is being initialised wrongly due to the Arduino being reset by USB connection. If the display has a general reset command, or a reset pin, enable it at the start of your sketch to ensure the display is in its default state.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-06T10:13:58.503" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3644" PostTypeId="1" AcceptedAnswerId="3650" CreationDate="2014-08-06T12:34:21.570" Score="1" ViewCount="102" Body="&lt;p&gt;I want the bottom row of my LCD to display the counting function and include text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.setCursor(0, 1);&#xA;lcd.print(&quot;Launch in&quot;millis()/1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it comes out with an error, what part is wrong?&lt;/p&gt;&#xA;" OwnerUserId="3454" LastEditorUserId="37" LastEditDate="2014-08-06T13:54:16.950" LastActivityDate="2017-04-23T05:24:14.580" Title="My counting function is not working with the text on my lcd" Tags="|programming|lcd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3645" PostTypeId="1" CreationDate="2014-08-06T12:39:22.620" Score="1" ViewCount="225" Body="&lt;p&gt;As the title says there is any program that can simulate an arduino due? I like the design of Proteus 8 but he can't simulate it. Only the arduino Uno R3, Mega and another one that I forgot the name.&lt;/p&gt;&#xA;" OwnerUserId="3471" LastActivityDate="2014-08-06T12:39:22.620" Title="There is any way to simulate an arduino due?" Tags="|programming|arduino-due|simulator|" AnswerCount="0" CommentCount="0" ClosedDate="2015-04-10T13:41:53.160" ContentLicense="CC BY-SA 3.0" />
  <row Id="3648" PostTypeId="2" ParentId="3644" CreationDate="2014-08-06T13:56:00.880" Score="1" Body="&lt;p&gt;Change the last line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;Launch in &quot; + (millis() / 1000));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; &lt;em&gt;concatenates&lt;/em&gt; the string &lt;code&gt;Launch in&lt;/code&gt; with the number that results from &lt;code&gt;millis() / 1000&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2017-04-23T05:24:14.580" LastActivityDate="2017-04-23T05:24:14.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3649" PostTypeId="2" ParentId="3644" CreationDate="2014-08-06T13:56:42.000" Score="1" Body="&lt;pre&gt;&lt;code&gt;lcd.setCursor(0, 1);&#xA;lcd.print(&quot;Launch in &quot;);&#xA;lcd.print(millis()/1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-06T13:56:42.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3650" PostTypeId="2" ParentId="3644" CreationDate="2014-08-06T13:58:34.027" Score="1" Body="&lt;p&gt;The last line in the code you provided won't compile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;lcd.print()&lt;/code&gt; function expects a char, byte, int, long or string (taken from the LiquidCrystal docs) and you're trying to combine a string and an int which the compiler isn't going to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to print both would be to have two lcd.print statements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;launch in &quot;);&#xA;lcd.print(millis()/1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most of this is taken from quickly googling displaying time on an lcd screen.&#xA;Check out this forum post, it seems similar to what you want to do: &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,12003.0.html&quot; rel=&quot;nofollow&quot;&gt;click me!&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1407" LastEditorUserId="84" LastEditDate="2014-11-26T19:21:13.603" LastActivityDate="2014-11-26T19:21:13.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3651" PostTypeId="1" AcceptedAnswerId="3662" CreationDate="2014-08-06T14:30:15.640" Score="1" ViewCount="3223" Body="&lt;p&gt;My code means that when i press a button it displays a word, but by default words are already there and i need to get rid of those default words.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(7,8,9,10,11,12);&#xA;&#xA;int buttonApin = 4;&#xA;&#xA;void setup() {&#xA; pinMode(buttonApin, INPUT_PULLUP);&#xA;  // set up the LCD's number of columns and rows: &#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;Mission Control &quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (digitalRead(buttonApin) == LOW)&#xA;  {&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;Test&quot;);&#xA;  } &#xA;&#xA;&#xA;  lcd.setCursor(0, 1);&#xA;&#xA;lcd.print(&quot;launch in &quot;);  &#xA;lcd.print(millis()/1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3454" LastEditorUserId="3454" LastEditDate="2014-08-06T16:55:53.797" LastActivityDate="2014-08-06T22:32:54.400" Title="On my lcd my characters collide, how can i remove one(because of the programming)" Tags="|arduino-uno|programming|pins|lcd|sketch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3653" PostTypeId="2" ParentId="3651" CreationDate="2014-08-06T16:14:48.863" Score="3" Body="&lt;p&gt;Either clear the display first, or print enough spaces after to overwrite the existing text.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-06T16:14:48.863" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3655" PostTypeId="1" AcceptedAnswerId="3675" CreationDate="2014-08-06T18:56:01.853" Score="2" ViewCount="15770" Body="&lt;p&gt;I'm a beginner with Arduino and i have acquired the Arduino UNO R3 board. i have followed the instructions on arduino website in order to install the board, however it fails and still remains as an unrecognised device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;consequently, arduino IDE reports that COM1 is not found, and the 'ports' menu is grayed out.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;steps i have tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1) install the Arduino 1.0.5 IDE&lt;/strong&gt; &#xA;   &lt;br/&gt;- the installation failes near the end when installing the arduino board&#xA;&lt;strong&gt;&lt;br/&gt;2) install the Arduino 1.5.7 BETA IDE&lt;/strong&gt;&#xA;&lt;br/&gt;- the installation is successful but arduino device is still unrecognized.&#xA;&lt;strong&gt;&lt;br/&gt;3) i have tried manually installing the drivers by letting windows search in the arduino IDE installation folder/drivers/&lt;/strong&gt; &#xA;&lt;br/&gt;- it reports that the best driver is already installed - &quot;usb unrecognized device&quot;&#xA;&lt;strong&gt;&lt;br/&gt;4) i have tried installing the drivers by manulally loading the &lt;code&gt;.inf&lt;/code&gt; files from the IDE installation folders, and installing all the &lt;code&gt;serial converter A/B/C/D&lt;/code&gt; in the list&lt;/strong&gt; &lt;br/&gt;- all failed to install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have done all the above for both IDE 1.0.5 and 1.5.7b with windows installer And zipped files, under administrative rights in windows 8.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do i get this to work?&lt;/p&gt;&#xA;" OwnerUserId="3479" LastActivityDate="2020-04-11T19:24:26.730" Title="USB device not recognised - windows 8.1" Tags="|arduino-uno|" AnswerCount="3" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="3657" PostTypeId="1" CreationDate="2014-08-06T18:59:10.167" Score="3" ViewCount="274" Body="&lt;p&gt;Not exactly Arduino-specific, but if you want to get a daily usable device (instead of a floating wire connection on your table) you eventually want to put your (Arduino-based) device into a nice casing. What are the different types of cases that people use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found soap cases as well as kitchen boxes (used one &lt;a href=&quot;https://github.com/vmcrash/ArduinoDccAccessoryCentral/blob/master/screenshots/front.jpg&quot; rel=&quot;nofollow&quot;&gt;large cheese box&lt;/a&gt; from Mepal Rosti).&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="1566" LastEditDate="2014-08-09T21:52:15.440" LastActivityDate="2014-08-09T21:52:15.440" Title="What transparent casings are commonly used for smaller devices with a display" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ClosedDate="2014-08-07T22:24:59.910" ContentLicense="CC BY-SA 3.0" />
  <row Id="3658" PostTypeId="1" AcceptedAnswerId="3661" CreationDate="2014-08-06T19:30:41.987" Score="7" ViewCount="1398" Body="&lt;p&gt;I'm trying to make a class work with Arduino, however it doesn't seem to trigger properly. The &lt;strong&gt;code is compiling&lt;/strong&gt; perfectly, and it's supposed to control the &lt;strong&gt;leg of an hexapod&lt;/strong&gt;. Also, the example sweep works on this servo, so no problem here. However, the servo is not actually moving. I'm thinking it has something to do with the order of declaring the variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;// Abstract each leg, so only those functions can be accessed&#xA;class Leg {&#xA;  // Actions that can be triggered from outside&#xA;  public:&#xA;    Leg(int hipPin, int kneePin);&#xA;    void up();&#xA;&#xA;  // These should be only available for the leg&#xA;  private:&#xA;    Servo hip;&#xA;    Servo knee;&#xA;  };&#xA;&#xA;Leg::Leg(int hipPin, int kneePin) {&#xA;  hip.attach(hipPin);&#xA;  knee.attach(kneePin);&#xA;  }&#xA;&#xA;// Testing the leg: move it up&#xA;void Leg::up() {&#xA;  for(int pos = 0; pos &amp;lt; 180; pos += 1) {&#xA;    hip.write(pos);&#xA;    delay(15);&#xA;    }&#xA;  }&#xA;&#xA;&#xA;// Initialize the leg&#xA;Leg topLeft(9, 10);&#xA;&#xA;void setup() {&#xA;  }&#xA;&#xA;// Test the function up()&#xA;void loop() {&#xA;  topLeft.up();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm testing only the pin 9 (leaving the 10 empty). It &lt;em&gt;seems in pain&lt;/em&gt;, meaning, you can see the servo trembling but not moving really at 0 degrees.&lt;/p&gt;&#xA;" OwnerUserId="731" LastActivityDate="2018-09-17T08:01:34.230" Title="Arduino Servo won't move when using classes" Tags="|arduino-uno|c++|class|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3659" PostTypeId="1" CreationDate="2014-08-06T21:06:05.057" Score="0" ViewCount="216" Body="&lt;p&gt;I have a problem understanding the following code:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;PROGMEM  prog_uint16_t x={1232,3232,43343};&#xA;rawlen = pgm_read_word_near(x);&#xA;memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why do we need this? -&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;rawlen * sizeof(uint16_t));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why not this? -&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3483" LastEditorUserId="42" LastEditDate="2015-04-10T13:40:38.673" LastActivityDate="2015-04-10T13:40:38.673" Title="question about progmem" Tags="|flash|progmem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3660" PostTypeId="2" ParentId="3659" CreationDate="2014-08-06T21:22:17.157" Score="2" Body="&lt;p&gt;Probably because x is an &lt;strong&gt;array&lt;/strong&gt; of integers (although in the code you posted you miss the '[]'), thus memcpy_p should run over &lt;code&gt;rawlen&lt;/code&gt; integers, each integer occupies &lt;code&gt;sizeof(uint16_t)&lt;/code&gt; bytes, hence &lt;code&gt;rawlen * sizeof(uint16_t)&lt;/code&gt; bytes in program memory space.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-08-06T21:22:17.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3661" PostTypeId="2" ParentId="3658" CreationDate="2014-08-06T22:11:18.057" Score="5" Body="&lt;p&gt;It looks this problem may be due to bad order of initializers calls for global variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C++, the order of global variable initialization is unpredictable across different compilation units (i.e. C++ source files, not header files). Initialization order is only respected &lt;strong&gt;inside&lt;/strong&gt; one compilation unit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your program, there are several global variables that, if initialized in the wrong order, will fail your program:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Leg topLeft;&lt;/code&gt; this is your class instance&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;servo_t servos[MAX_SERVOS];&lt;/code&gt;, &lt;code&gt;int8_t Channel[_Nbr_16timers ];&lt;/code&gt; and &lt;code&gt;uint8_t ServoCount = 0;&lt;/code&gt; all defined in &lt;code&gt;Servo.cpp&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;Servo.attach()&lt;/code&gt; requires that the 3 variables above have already been initialized, which you cannot be sure of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can you fix that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By not performing the &lt;code&gt;attach()&lt;/code&gt; in &lt;code&gt;Leg&lt;/code&gt; constructor but delegating it to some kind of &lt;code&gt;init()&lt;/code&gt; method that you can call from &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Leg {&#xA;    // Actions that can be triggered from outside&#xA;    public:&#xA;    void init(int hipPin, int kneePin);&#xA;    void up();&#xA;&#xA;    // These should be only available for the leg&#xA;    private:&#xA;    Servo hip;&#xA;    Servo knee;&#xA;};&#xA;&#xA;Leg::init(int hipPin, int kneePin) {&#xA;    hip.attach(hipPin);&#xA;    knee.attach(kneePin);&#xA;}&#xA;&#xA;// Testing the leg: move it up&#xA;void Leg::up() {&#xA;    for(int pos = 0; pos &amp;lt; 180; pos += 1) {&#xA;        hip.write(pos);&#xA;        delay(15);&#xA;    }&#xA;}&#xA;&#xA;// Declare the leg&#xA;Leg topLeft;&#xA;&#xA;void setup() {&#xA;    // Initialize the leg&#xA;    topLeft.init(9, 10);&#xA;}&#xA;&#xA;// Test the function up()&#xA;void loop() {&#xA;    topLeft.up();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-08-07T19:25:09.277" LastActivityDate="2014-08-07T19:25:09.277" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3662" PostTypeId="2" ParentId="3651" CreationDate="2014-08-06T22:25:45.560" Score="3" Body="&lt;p&gt;The HD44780 controller has a 80 bytes (characters) memory, in order to support up to 2x40 character displays. Since you use a 2x16 display, there is an empty space in the memory you can use on your benefit. It's like having two desktops, you are able to show one or the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refer to &lt;a href=&quot;http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LCD Addressing&lt;/a&gt; for a visualization of the the memory locations and detailed explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/a9SV4.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything you write in locations &lt;code&gt;setCursor(16, 0)&lt;/code&gt; to &lt;code&gt;setCursor(39, 0)&lt;/code&gt; and &lt;code&gt;setCursor(16, 1)&lt;/code&gt; to &lt;code&gt;setCursor(39, 1)&lt;/code&gt; will not be visible until you scroll to the left. Consequently you can have some text already written in the hidden area and then alternate the shown text just by scrolling left and right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(7,8,9,10,11,12);&#xA;&#xA;int buttonApin = 4;&#xA;&#xA;void setup() {&#xA;   // set up the LCD's number of columns and rows: &#xA;  lcd.begin(16, 2);  &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (digitalRead(buttonApin) == LOW)&#xA;  {&#xA;    // write text to the visible area&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;showing 0,0-15,0&quot;);&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;showing 1,0-15,1&quot;);&#xA;&#xA;    // write text to the hidden area&#xA;    lcd.setCursor(16, 0);&#xA;    lcd.print(&quot;now  16,0-31,0&quot;);&#xA;    lcd.setCursor(16, 1);&#xA;    lcd.print(&quot;now  16,1-31,1&quot;);&#xA;&#xA;    while (1) {  // scroll to the left and back to show different text without writing a single character&#xA;    delay(2000);&#xA;    for(uint8_t i=0;i&amp;lt;16;i++) lcd.scrollDisplayLeft();&#xA;    delay(2000);&#xA;    for(uint8_t i=0;i&amp;lt;16;i++) lcd.scrollDisplayRight();&#xA;    }&#xA;&#xA;  } &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code changes the visible text just by scrolling&lt;/p&gt;&#xA;" OwnerUserId="470" LastEditorUserId="470" LastEditDate="2014-08-06T22:32:54.400" LastActivityDate="2014-08-06T22:32:54.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3663" PostTypeId="2" ParentId="3657" CreationDate="2014-08-07T00:01:06.787" Score="4" Body="&lt;p&gt;So far we have used:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ABS cases (pic camdenboss.com):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jurth.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Small pelicases (convenient to open, pic pelican-case.com):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/n9stH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3D printed cases with a clear perspex window (pic instructables.com):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/icgSr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen other people use laser cut perspex (pic spikenzielabs.com):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xo4Ly.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-07T00:01:06.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3664" PostTypeId="2" ParentId="484" CreationDate="2014-08-07T02:13:23.827" Score="10" Body="&lt;p&gt;I created a project that fully replaces the Arduino Bootloader. You are able to upload sketches and use it as HID. See Project HID on Github: &lt;a href=&quot;https://github.com/NicoHood/HID&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/NicoHood/HID&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user3486" LastActivityDate="2014-08-07T02:13:23.827" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3665" PostTypeId="1" CreationDate="2014-08-07T01:33:15.510" Score="0" ViewCount="448" Body="&lt;p&gt;I am trying to use a &lt;a href=&quot;http://www.acam.de/fileadmin/Download/_software/TDC/GP22_main_AN034.c&quot; rel=&quot;nofollow&quot;&gt;program&lt;/a&gt; that has been written for  STM32 microprocessor for interfacing with a Time to Digital Converter &lt;a href=&quot;http://www.acam.de/fileadmin/Download/pdf/UFC/English/DB_GP22_en.pdf&quot; rel=&quot;nofollow&quot;&gt;TDC GP22&lt;/a&gt; via SPI interface. I would like to use the same program and adapt it to suit Arduino Uno for interfacing with TDC GP22. This would really help save a lot of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please suggest me the most effective way to do this ?&lt;/p&gt;&#xA;" OwnerUserId="3511" OwnerDisplayName="user18197" LastEditorUserId="220" LastEditDate="2014-08-07T13:49:47.300" LastActivityDate="2014-08-07T14:27:16.417" Title="Adapt program to suit Arduino UNO" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3666" PostTypeId="2" ParentId="3630" CreationDate="2014-08-07T02:33:40.027" Score="1" Body="&lt;p&gt;I ended up doing two things. First I got a replacement hardware. That made the bridge code start working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I also changed the port from &lt;code&gt;/dev/tty.usbmodem1431&lt;/code&gt; to &lt;code&gt;/dev/cu.usbmodem1431&lt;/code&gt;. As shown in the picture below. That fixed the issue with IDE getting stuck at &quot;Uploading...&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if this fix will last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oByJ5.png&quot; alt=&quot;Arduino Tools Menu&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3459" LastActivityDate="2014-08-07T02:33:40.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3667" PostTypeId="1" AcceptedAnswerId="4894" CreationDate="2014-08-07T09:40:02.750" Score="3" ViewCount="3497" Body="&lt;p&gt;I started my first try in programming an ATTINY13 with my Arduino 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seemed fine, however when I wanted to run the blink example, my LED did not blink, it keeps lighting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using 5V as input voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not change the blink example except for the correct pin number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the wiring seems correct, when I change the pin number the LED stays dark, so my program is arriving propperly on the ATTINY.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I start playing with the delays (delaymicroseconds) I get the LED to become darker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation of the ATTINY13 (www.atmel.com/images/doc2535.pdf) mentions a maximum clock frequency of 20MHz. When I choose the ATTINY13 from the Arduino IDE board menu it is listed with a 9.6MHz clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could this be a reason?&#xA;How can I adjust or take care of that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;----------- Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was starting with the default blink example (&lt;code&gt;delay(1000)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I played with both, the normal &lt;code&gt;delay&lt;/code&gt; and the &lt;code&gt;delayMicroseconds&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following codes dimmed the LED:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(3, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(3, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(3, LOW);&#xA;  delayMicroseconds(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which makes me believe the LED is blinking very fast.&#xA;A similar sketch with normal &lt;code&gt;delay&lt;/code&gt; does not make the LED dim:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(3, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(3, HIGH);&#xA;  delay(1);&#xA;  digitalWrite(3, LOW);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And as mentioned with the default blink sketch the LED nothing happens as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also made the delay a ever increasing variable to see if something is happening, no luck.&#xA;And I have 2 ATTINYs to test, same result for both...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--- Edit2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 3;&#xA;&#xA;void setup() {&#xA;  pinMode(led, OUTPUT);&#xA;  digitalWrite(led, HIGH);&#xA;  delayMicroseconds(100);&#xA;  digitalWrite(led, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I moved switching the LED on and off into the setup function. Strangely enough, by changing the delay between 1000 and 100 micro seconds, the LED gets lighter and darker...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;---- Edit 3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mwhqi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is the ATTINY specific code I added to the Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attiny13.name=ATtiny13 (internal 9.6 MHz clock)&#xA;attiny13.bootloader.low_fuses=0x7a&#xA;attiny13.bootloader.high_fuses=0xff&#xA;attiny13.upload.maximum_size=1024&#xA;attiny13.build.mcu=attiny13&#xA;attiny13.build.f_cpu=9600000L&#xA;attiny13.build.core=arduino:arduino&#xA;attiny13.build.variant=tiny8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3488" LastEditorUserId="3488" LastEditDate="2014-08-08T17:57:35.687" LastActivityDate="2014-11-06T08:43:40.413" Title="Attiny13 + Arduino" Tags="|arduino-mega|led|attiny|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3668" PostTypeId="2" ParentId="3573" CreationDate="2014-08-07T14:24:50.647" Score="3" Body="&lt;p&gt;For anyone curious what I did, I ended up doing a naming convention like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my_lib_v1_2&#xA;   |- my_lib_v1_2.ino&#xA;   |- mylib.cpp&#xA;   |- mylib.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, the user could include &lt;code&gt;mylib.h&lt;/code&gt; still, and people with the Arduino IDE could edit it.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-07T14:24:50.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3669" PostTypeId="2" ParentId="3665" CreationDate="2014-08-07T14:27:16.417" Score="1" Body="&lt;p&gt;You'll be wasting your time tring to convert the code on a procedure by procedure basis.  Arduino has different libraries, different clocks, different pins, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you flowchart the code, and then work out which of the Arduino libraries (SPI, LCD, etc.) you can use to achieve the flow.  You'll be able to drop some of the initialisation code probably as Arduino is easier to run &quot;out the box&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no quick-and-easy solution here - it's a re-write... as you'll find is often the case migrating code from one MCU to another.&lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-08-07T14:27:16.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3671" PostTypeId="2" ParentId="3657" CreationDate="2014-08-07T15:18:58.510" Score="3" Body="&lt;p&gt;If you have affordable access to a laser cutter, then you could laser cut a box to exactly match your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Laser cutters typically come with software that reads SVG or DXF files. &#xA;Find out what file types are used, then search the web for something like &quot;laser cut box design tool SVG&quot;, and you'll find a bunch of ways to make the box outline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this &lt;a href=&quot;http://boxmaker.rahulbotics.com/&quot; rel=&quot;nofollow&quot;&gt;laser cut box web site&lt;/a&gt; generates a pdf file, which you can 'print'. You fill in a few parameters, and it does the rest, generating all the profiles for interlocking edges. Even though the edges are interlocking, you might want to add some glue to make it more robust.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An advantage of laser cutting is you can choose the materials. Maybe you'd like wood, with a transparent red acrylic lid. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A further advantage, if your laser can read things like SVG or DXF, is you could use a CAD or drawing program to modify the box. So, for example, you could 'etch' labels onto a control panel, or cut extra holes to mount LEDs. Or just decorate the outside of the box.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastActivityDate="2014-08-07T15:18:58.510" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3673" PostTypeId="2" ParentId="3667" CreationDate="2014-08-07T15:40:16.457" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The documentation of the ATTINY13 (www.atmel.com/images/doc2535.pdf) mentions a maximum clock frequency of 20MHz. When I choose the ATTINY13 from the Arduino IDE board menu it is listed with a 9.6MHz clock.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Could this be a reason? How can I adjust or take care of that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't think it is the reason, as it is totally fine to underclock your chip. In fact, most Arduino boards are underclocked. In fact, &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;the Arduino Uno's chip&lt;/a&gt; can do 20MHz, but it is only ran at 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the comments, your oscillator might be off. &lt;em&gt;However&lt;/em&gt;, it should still blink. If you're saying changing the pin makes it go dark, then some code is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is your delay is way to short. You said you were using &lt;code&gt;delayMicroseconds()&lt;/code&gt;. Emphasis on &lt;em&gt;microseconds&lt;/em&gt;, not milliseconds. (1 second = 1,000 milliseconds; 1 millisecond = 1,000 microseconds) If you meant to be using milliseconds, it is very possible that you are changing the power to the LED at 1,000 times a second, instead of 1. This would make the LED dimmer than directly to power, but it would still appear lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinmode(LEDPIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(LEDPIN, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LEDPIN, LOW);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, replace the &lt;code&gt;LEDPIN&lt;/code&gt; with the right value.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-07T15:40:16.457" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3675" PostTypeId="2" ParentId="3655" CreationDate="2014-08-07T16:41:54.747" Score="1" Body="&lt;p&gt;The issue was resolved by changing my USB cable. the cable in the kit was new and seemed to supply power to the arduino board, but windows was unable to identify the board using that cable. maybe the data wires were damaged.&#xA;&lt;br/&gt; in any case, i changed the cable and everything worked smoothly. &#xA;&#xA;" OwnerUserId="3479" LastActivityDate="2014-08-07T16:41:54.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3676" PostTypeId="1" AcceptedAnswerId="3677" CreationDate="2014-08-07T17:02:50.550" Score="1" ViewCount="1390" Body="&lt;p&gt;I'm trying to use a little pump with my arduino nano:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  pinMode(waterPump, OUTPUT);&#xA;}&#xA;...&#xA;  while (val &amp;lt; valueWater)&#xA;  {&#xA;    Serial.println (&quot;in while&quot;); // testing purpose&#xA;    digitalWrite(waterPump, HIGH);&#xA;    delay(1000); // 1 second&#xA;    digitalWrite(waterPump, LOW);&#xA;    val = analogRead(sondeEau);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try this one, pump isn't working. When I unplug the waterPump pin, I see &quot;LED3&quot; that run, and when I plut it, LED3 is not running, why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to plug pump directly on 5V on arduino, pump works well...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the pump I bought: &lt;a href=&quot;http://www.dx.com/p/hsyy01-water-pump-motor-w-hose-white-silver-236808&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/hsyy01-water-pump-motor-w-hose-white-silver-236808&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance to help me!&lt;/p&gt;&#xA;" OwnerUserId="3299" LastActivityDate="2014-08-08T14:10:17.573" Title="little pump isn't working" Tags="|motor|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3677" PostTypeId="2" ParentId="3676" CreationDate="2014-08-07T18:42:18.690" Score="3" Body="&lt;p&gt;&lt;em&gt;You plugged this directly into your Arduino?&lt;/em&gt; You might as well have dropped your Arduino in the water you are pumping...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino can only supply &lt;strong&gt;40mA&lt;/strong&gt; per pin. However, you pump requires &lt;strong&gt;800 mA&lt;/strong&gt;!!! Often, when overloading a pin, the Arduino chip is fried. Even worse, a typical USB port can only supply 500 mA, so you could have fried your computer if using USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need a motor driver. Like mentioned in the comments, the Arduino motor shield is a great place to start. If you don't to spend all that money, you have a few options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &lt;em&gt;relay&lt;/em&gt; is an easy way that works with almost all voltages and any reasonable amount of current.&lt;/li&gt;&#xA;&lt;li&gt;If you want something a little more professional, a &lt;em&gt;transistor,&lt;/em&gt; like a &lt;em&gt;MOSFET&lt;/em&gt; would be the way to go. They're fairly cheap, but you have to know which to pick (that's hard to do in practice).&lt;/li&gt;&#xA;&lt;li&gt;You can also get a half H-bridge which I think would work well for your situation.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I unplug the waterPump pin, I see &quot;LED3&quot; that run, and when I plut it, LED3 is not running, why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The motor is likely taking up all the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; get an external power source and get a proper motor driver.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-07T18:42:18.690" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3678" PostTypeId="2" ParentId="3676" CreationDate="2014-08-07T18:42:48.413" Score="4" Body="&lt;p&gt;As Chris says, you should never plug a high current device like a motor directly into a pin on your Arduino. That motor is rated at 800 mA, which is more than you can draw from the entire 5V supply on the Arduino!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The digital pins are rated for 40 mA max, if I remember correctly. You tried to draw 20 times that much. There is a decent chance that you burned out the driver for that digital pin. I would try hooking an LED through a 220 ohm resistor and to ground and see if it still lights up when you send it a HIGH logic signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a simple DC motor you should be able to use a high current transistor and an external power supply to drive it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  If I were doing this I would use a logic-level MOSFET to drive the pump directly, plus a flyback diode. To use a relay, you will still need a transistor to power the relay coil, AND a flyback diode. Your circuit might look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3TJKg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that I made no attempt to pick the RIGHT kind of diode and transistor. Ignore the part numbers shown in the schematic. I just used the defaults.)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-08-08T14:10:17.573" LastActivityDate="2014-08-08T14:10:17.573" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3679" PostTypeId="1" CreationDate="2014-08-07T19:56:36.590" Score="3" ViewCount="7977" Body="&lt;p&gt;I am new to the microcontroller world and circuits, so bare with me. I recently bought some 5V arduino pro mini microcontrollers. I have been playing with them and they work fine, I have been powering it from an usb connection. &lt;br/&gt; &#xA;Now I want to power the board using a 9V battery, I connected the + to the RAW pin and the Ground to the Ground pin on the Arduino. &lt;br/&gt;&#xA;My question is if I can still use the VCC pins? I understand the board has a voltage regulator that from my understanding it brings down the 9V to 5V. I thought this 5 volts were available through the VCC pin but I connected an LED to it and nothing happens.&#xA;&lt;br/&gt;&lt;br/&gt;&#xA;I have tried this method with an arduino Uno and it works so I dont know why it doesnt work with the Pro Mini.&lt;/p&gt;&#xA;" OwnerUserId="3375" LastActivityDate="2017-04-02T09:52:06.433" Title="Arduino Pro Mini (5V) Raw Pin and VCC Pin" Tags="|arduino-uno|battery|arduino-pro-mini|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3680" PostTypeId="1" CreationDate="2014-08-07T20:11:26.650" Score="21" ViewCount="13514" Body="&lt;p&gt;If I have multiple Arduinos connected over USB to a Linux computer, and they show up as &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;/tty/ACM0  &lt;/li&gt;&#xA;&lt;li&gt;/tty/ACM1&lt;/li&gt;&#xA;&lt;li&gt;/tty/ACM2&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I identify which Arduino is which &lt;strong&gt;without connecting to them via serial connection&lt;/strong&gt;? Is there a serial number or a unique id on the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Situation: Uno R3, Mega, Leonardo with /ttyACM[1,2,3]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;lsusb output with devices in the order mentioned above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;...&#xA;Bus 001 Device 011: ID 2341:0043&#xA;Bus 001 Device 013: ID 2341:8036&#xA;...&#xA;Bus 001 Device 014: ID 2341:0042&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lsusb -d vendor:device -vvv shows for each one&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uno&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Bus 001 Device 014: ID 2341:0042&#xA;Device Descriptor:&#xA;  bLength                18&#xA;  bDescriptorType         1&#xA;  bcdUSB               1.10&#xA;  bDeviceClass            2 Communications&#xA;  bDeviceSubClass         0&#xA;  bDeviceProtocol         0&#xA;  bMaxPacketSize0         8&#xA;  idVendor           0x2341&#xA;  idProduct          0x0042&#xA;  bcdDevice            0.01&#xA;  iManufacturer           1 Arduino (www.arduino.cc)&#xA;  iProduct                2&#xA;  iSerial               220 55330313735351910141&#xA;  bNumConfigurations      1&#xA;  Configuration Descriptor:&#xA;    bLength                 9&#xA;    bDescriptorType         2&#xA;    wTotalLength           62&#xA;    bNumInterfaces          2&#xA;    bConfigurationValue     1&#xA;    iConfiguration          0&#xA;    bmAttributes         0xc0&#xA;      Self Powered&#xA;    MaxPower              100mA&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        0&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           1&#xA;      bInterfaceClass         2 Communications&#xA;      bInterfaceSubClass      2 Abstract (modem)&#xA;      bInterfaceProtocol      1 AT-commands (v.25ter)&#xA;      iInterface              0&#xA;      CDC Header:&#xA;        bcdCDC               10.01&#xA;      CDC ACM:&#xA;        bmCapabilities       0x06&#xA;          sends break&#xA;          line coding and serial state&#xA;      CDC Union:&#xA;        bMasterInterface        0&#xA;        bSlaveInterface         1&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x82  EP 2 IN&#xA;        bmAttributes            3&#xA;          Transfer Type            Interrupt&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0008  1x 8 bytes&#xA;        bInterval             255&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        1&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           2&#xA;      bInterfaceClass        10 CDC Data&#xA;      bInterfaceSubClass      0 Unused&#xA;      bInterfaceProtocol      0&#xA;      iInterface              0&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x04  EP 4 OUT&#xA;        bmAttributes            2&#xA;          Transfer Type            Bulk&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               1&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x83  EP 3 IN&#xA;        bmAttributes            2&#xA;          Transfer Type            Bulk&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               1&#xA;Device Status:     0x0000&#xA;  (Bus Powered)&#xA;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Leonardo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Bus 001 Device 013: ID 2341:8036&#xA;Device Descriptor:&#xA;  bLength                18&#xA;  bDescriptorType         1&#xA;  bcdUSB               2.00&#xA;  bDeviceClass            0 (Defined at Interface level)&#xA;  bDeviceSubClass         0&#xA;  bDeviceProtocol         0&#xA;  bMaxPacketSize0        64&#xA;  idVendor           0x2341&#xA;  idProduct          0x8036&#xA;  bcdDevice            1.00&#xA;  iManufacturer           1 Arduino LLC&#xA;  iProduct                2 Arduino Leonardo&#xA;  iSerial                 0&#xA;  bNumConfigurations      1&#xA;  Configuration Descriptor:&#xA;    bLength                 9&#xA;    bDescriptorType         2&#xA;    wTotalLength          100&#xA;    bNumInterfaces          3&#xA;    bConfigurationValue     1&#xA;    iConfiguration          0&#xA;    bmAttributes         0x80&#xA;      (Bus Powered)&#xA;    MaxPower              500mA&#xA;    Interface Association:&#xA;      bLength                 8&#xA;      bDescriptorType        11&#xA;      bFirstInterface         0&#xA;      bInterfaceCount         2&#xA;      bFunctionClass          2 Communications&#xA;      bFunctionSubClass       2 Abstract (modem)&#xA;      bFunctionProtocol       1 AT-commands (v.25ter)&#xA;      iFunction               0&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        0&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           1&#xA;      bInterfaceClass         2 Communications&#xA;      bInterfaceSubClass      2 Abstract (modem)&#xA;      bInterfaceProtocol      0 None&#xA;      iInterface              0&#xA;      CDC Header:&#xA;        bcdCDC               1.10&#xA;      CDC Call Management:&#xA;        bmCapabilities       0x01&#xA;          call management&#xA;        bDataInterface          1&#xA;      CDC ACM:&#xA;        bmCapabilities       0x06&#xA;          sends break&#xA;          line coding and serial state&#xA;      CDC Union:&#xA;        bMasterInterface        0&#xA;        bSlaveInterface         1&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x81  EP 1 IN&#xA;        bmAttributes            3&#xA;          Transfer Type            Interrupt&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               0&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x83  EP 3 IN&#xA;        bmAttributes            2&#xA;          Transfer Type            Bulk&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               0&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        2&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           1&#xA;      bInterfaceClass         3 Human Interface Device&#xA;      bInterfaceSubClass      0 No Subclass&#xA;      bInterfaceProtocol      0 None&#xA;      iInterface              0&#xA;        HID Device Descriptor:&#xA;          bLength                 9&#xA;          bDescriptorType        33&#xA;          bcdHID               1.01&#xA;          bCountryCode            0 Not supported&#xA;          bNumDescriptors         1&#xA;          bDescriptorType        34 Report&#xA;          wDescriptorLength     101&#xA;          Report Descriptor: (length is 101)&#xA;            Item(Global): Usage Page, data= [ 0x01 ] 1&#xA;                            Generic Desktop Controls&#xA;            Item(Local ): Usage, data= [ 0x02 ] 2&#xA;                            Mouse&#xA;            Item(Main  ): Collection, data= [ 0x01 ] 1&#xA;                            Application&#xA;            Item(Local ): Usage, data= [ 0x01 ] 1&#xA;                            Pointer&#xA;            Item(Main  ): Collection, data= [ 0x00 ] 0&#xA;                            Physical&#xA;            Item(Global): Report ID, data= [ 0x01 ] 1&#xA;            Item(Global): Usage Page, data= [ 0x09 ] 9&#xA;                            Buttons&#xA;            Item(Local ): Usage Minimum, data= [ 0x01 ] 1&#xA;                            Button 1 (Primary)&#xA;            Item(Local ): Usage Maximum, data= [ 0x03 ] 3&#xA;                            Button 3 (Tertiary)&#xA;            Item(Global): Logical Minimum, data= [ 0x00 ] 0&#xA;            Item(Global): Logical Maximum, data= [ 0x01 ] 1&#xA;            Item(Global): Report Count, data= [ 0x03 ] 3&#xA;            Item(Global): Report Size, data= [ 0x01 ] 1&#xA;            Item(Main  ): Input, data= [ 0x02 ] 2&#xA;                            Data Variable Absolute No_Wrap Linear&#xA;                            Preferred_State No_Null_Position Non_Volatile Bitfield&#xA;            Item(Global): Report Count, data= [ 0x01 ] 1&#xA;            Item(Global): Report Size, data= [ 0x05 ] 5&#xA;            Item(Main  ): Input, data= [ 0x03 ] 3&#xA;                            Constant Variable Absolute No_Wrap Linear&#xA;                            Preferred_State No_Null_Position Non_Volatile Bitfield&#xA;            Item(Global): Usage Page, data= [ 0x01 ] 1&#xA;                            Generic Desktop Controls&#xA;            Item(Local ): Usage, data= [ 0x30 ] 48&#xA;                            Direction-X&#xA;            Item(Local ): Usage, data= [ 0x31 ] 49&#xA;                            Direction-Y&#xA;            Item(Local ): Usage, data= [ 0x38 ] 56&#xA;                            Wheel&#xA;            Item(Global): Logical Minimum, data= [ 0x81 ] 129&#xA;            Item(Global): Logical Maximum, data= [ 0x7f ] 127&#xA;            Item(Global): Report Size, data= [ 0x08 ] 8&#xA;            Item(Global): Report Count, data= [ 0x03 ] 3&#xA;            Item(Main  ): Input, data= [ 0x06 ] 6&#xA;                            Data Variable Relative No_Wrap Linear&#xA;                            Preferred_State No_Null_Position Non_Volatile Bitfield&#xA;            Item(Main  ): End Collection, data=none&#xA;            Item(Main  ): End Collection, data=none&#xA;&#xA;            ......&#xA;&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x84  EP 4 IN&#xA;        bmAttributes            3&#xA;          Transfer Type            Interrupt&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               1&#xA;Device Status:     0x0000&#xA;  (Bus Powered)&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And Mega256:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;Bus 001 Device 014: ID 2341:0042&#xA;Device Descriptor:&#xA;  bLength                18&#xA;  bDescriptorType         1&#xA;  bcdUSB               1.10&#xA;  bDeviceClass            2 Communications&#xA;  bDeviceSubClass         0&#xA;  bDeviceProtocol         0&#xA;  bMaxPacketSize0         8&#xA;  idVendor           0x2341&#xA;  idProduct          0x0042&#xA;  bcdDevice            0.01&#xA;  iManufacturer           1 Arduino (www.arduino.cc)&#xA;  iProduct                2&#xA;  iSerial               220 55330313735351910141&#xA;  bNumConfigurations      1&#xA;  Configuration Descriptor:&#xA;    bLength                 9&#xA;    bDescriptorType         2&#xA;    wTotalLength           62&#xA;    bNumInterfaces          2&#xA;    bConfigurationValue     1&#xA;    iConfiguration          0&#xA;    bmAttributes         0xc0&#xA;      Self Powered&#xA;    MaxPower              100mA&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        0&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           1&#xA;      bInterfaceClass         2 Communications&#xA;      bInterfaceSubClass      2 Abstract (modem)&#xA;      bInterfaceProtocol      1 AT-commands (v.25ter)&#xA;      iInterface              0&#xA;      CDC Header:&#xA;        bcdCDC               10.01&#xA;      CDC ACM:&#xA;        bmCapabilities       0x06&#xA;          sends break&#xA;          line coding and serial state&#xA;      CDC Union:&#xA;        bMasterInterface        0&#xA;        bSlaveInterface         1&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x82  EP 2 IN&#xA;        bmAttributes            3&#xA;          Transfer Type            Interrupt&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0008  1x 8 bytes&#xA;        bInterval             255&#xA;    Interface Descriptor:&#xA;      bLength                 9&#xA;      bDescriptorType         4&#xA;      bInterfaceNumber        1&#xA;      bAlternateSetting       0&#xA;      bNumEndpoints           2&#xA;      bInterfaceClass        10 CDC Data&#xA;      bInterfaceSubClass      0 Unused&#xA;      bInterfaceProtocol      0&#xA;      iInterface              0&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x04  EP 4 OUT&#xA;        bmAttributes            2&#xA;          Transfer Type            Bulk&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               1&#xA;      Endpoint Descriptor:&#xA;        bLength                 7&#xA;        bDescriptorType         5&#xA;        bEndpointAddress     0x83  EP 3 IN&#xA;        bmAttributes            2&#xA;          Transfer Type            Bulk&#xA;          Synch Type               None&#xA;          Usage Type               Data&#xA;        wMaxPacketSize     0x0040  1x 64 bytes&#xA;        bInterval               1&#xA;Device Status:     0x0000&#xA;  (Bus Powered)&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="709" LastEditorUserId="4628" LastEditDate="2014-11-07T16:42:58.637" LastActivityDate="2020-01-02T15:23:23.703" Title="In Linux, how to identify multiple Arduinos connected over USB?" Tags="|linux|" AnswerCount="8" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3682" PostTypeId="1" AcceptedAnswerId="3684" CreationDate="2014-08-07T20:44:59.103" Score="6" ViewCount="36550" Body="&lt;p&gt;I read few posts and tutorials on this topic but none of them kind of answered my questions.  I bought this L298N motor board and i have two motors that are rated 3V&#xA;&lt;img src=&quot;https://i.stack.imgur.com/T3URN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now i am trying to understand how to connect it to arduino and power the motors.&lt;br&gt;&#xA;For example i have a 12V (8x 1.5v AA batteries) I can connect to VCC and GND then enable ENA with a jumper and connect PWN port from arduino to INA. This way i can control the voltage that is coming out from OUTA and OUTB  I can bring down the 12V to 3V.&lt;br&gt;&#xA;Now the question is can i use the +5 (regulated voltage) on the driver board and connect it to arduino Vin and GND to ground to power the arduino? Is that viable solution.  I actually tried it and it works.  I am worried that it is not enough voltage to properly power the arduino.  It's suggested to connect 7v - 12v to Vin.  I am also going to connect a red lab ble shield on top of arduino that is powered by 5v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another question is if i use 12 volts battery and step it down to 3v with PWN is that going to heat up the L298N chip? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/n7C3i.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;Another option is connecting 9V battery to arduino and then using Vin and GND to power the motor shield and the motors.  The problem there if motor draws more then 1Amp that wouldn't be good for the arduino.  Also if i would switch to 9v+ motors then it wouldn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third option is to have two separate power sources. 9V for arduino and 5v+ for powering the motors.  Does it make sense to use two power sources? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This project seems like a good way to learn about arduino and electronics&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NEOMART Brand New Original High Quality Chips L298N&#xA;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E58EA90&quot; rel=&quot;noreferrer&quot;&gt;http://www.amazon.com/gp/product/B00E58EA90/ref=oh_aui_detailpage_o04_s00?ie=UTF8&amp;amp;psc=1&lt;/a&gt;&#xA;Product Details&#xA;1. driver chip: L298N Dual H-Bridge Motor Driver IC&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;drive section terminal supply area Vs: +5V ~ +35V; such as the need to take power within the board, the supply area Vs: +7V ~ +35V&lt;/li&gt;&#xA;&lt;li&gt;drive section peak current Io: 2A&lt;/li&gt;&#xA;&lt;li&gt;logical part of the terminal supply area Vss: +5V ~ +7V(can take power within the board +5V)&lt;/li&gt;&#xA;&lt;li&gt;logical part of the operating current range: 0 ~ 36mA&lt;/li&gt;&#xA;&lt;li&gt;Control signal input voltage range:&#xA;Low:-0.3V ≤ Vin ≤ 1.5V&#xA;High: 2.3V ≤ Vin ≤ Vss&lt;/li&gt;&#xA;&lt;li&gt;enable signal input voltage range:&#xA;Low: -0.3 ≤ Vin ≤ 1.5V (control signal is invalid)&#xA;High: 2.3V ≤ Vin ≤ Vss (control signal active)&lt;/li&gt;&#xA;&lt;li&gt;Maximum power consumption: 20W (when the temperature T = 75℃)&lt;/li&gt;&#xA;&lt;li&gt;Storage temperature: -25℃ ~ +130℃&lt;/li&gt;&#xA;&lt;li&gt;Driver Board Size: 48mm*43mm*33mm (with fixed copper pillar and the heat sink height)&lt;/li&gt;&#xA;&lt;li&gt;Other Extensions: control of direction indicators, the logic part of the plate to take power interface.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8XdEy.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to clarify regarding using 12 volt battery and having 2 motors that I think max voltage is 3 volts.  If i use PWN and step down the voltage to 3 volts will L298N produce a lot more heat to step the voltage down?&lt;br&gt;&#xA;Probably in this case would be the best just to get two separate power supplies 9 volts for arduino and 4.5 volts for the motor drive to supply 3 volts for each motor.  Unless i get better motors that support 6v - 9v then i can use the 12 volts battery for both arduino and motors.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the motor drivers, I thought they are used to prevent the noise and power spikes from motors?  I guess you still have to consider it either way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance! &lt;/p&gt;&#xA;" OwnerUserId="1409" LastEditorUserId="1409" LastEditDate="2014-08-08T01:53:03.497" LastActivityDate="2019-03-21T07:56:52.897" Title="Question different ways of connecting L298N motor driver board to arduino and motors and powering them" Tags="|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3683" PostTypeId="1" CreationDate="2014-08-07T21:52:29.860" Score="2" ViewCount="495" Body="&lt;p&gt;I am looking into using the &lt;a href=&quot;http://playground.arduino.cc/Code/SerialIP&quot; rel=&quot;nofollow&quot;&gt;SerialIP library&lt;/a&gt; to connect my Arduino to the internet through it's USB connection to my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I cannot figure out how to establish the SLIP connection to the Arduino from my Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library's documentation says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Perhaps the most difficult part of using this library is figuring out&#xA;  how to establish the SLIP connection to the Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It suggests the use of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo slattach -L -s 115200 -p slip /dev/ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On linux systems. However, on my Mac running OS X 10.10, there is no such command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran into &lt;a href=&quot;https://discussions.apple.com/thread/2491031?start=0&amp;amp;tstart=0&quot; rel=&quot;nofollow&quot;&gt;this thread&lt;/a&gt; on the Apple forums regarding the missing &lt;code&gt;slattach&lt;/code&gt; command, which sounds like it was removed in OS X 10.6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use the SerialIP Arduino library on my Mac?&lt;/p&gt;&#xA;" OwnerUserId="64" LastActivityDate="2014-08-07T21:52:29.860" Title="How can I use the SerialIP library on my Arduino through a Mac?" Tags="|serial|tcpip|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3684" PostTypeId="2" ParentId="3682" CreationDate="2014-08-07T22:20:43.150" Score="5" Body="&lt;p&gt;Here is a link to a &lt;a href=&quot;http://www.robotoid.com/appnotes/circuits-bridges.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;robotoid&lt;/a&gt; page which describes a way to use it.&lt;br&gt;&#xA;Here is a link to &lt;a href=&quot;http://www.funnyrobotics.com/2011/03/arduino-with-l298n-based-dual-motor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;funnyrobotics&lt;/a&gt; which explains how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am confident that you could use a search engine to find more examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One trick is to use image search. Then look for pictures which look like your photo, and which have extra writing on them. Most people who add labels and writing to the photo are writing to help beginners understand how to use something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;That L298N board claims to have a 5V regulator for powering the Arduino, in which case you could use a single power supply, and let the motor board feed the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two schools of thought on powering the Arduino and motors:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use two separate power supplies, one for the motor and one for the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Use one supply for both the motor, and Arduino.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Using one supply is simple overall. One concern is electric motors can create a lot of electrical noise. If this is not adequately filtered, it might get injected into the Arduino and maybe cause the microcontroller to reset, or become temporarily unstable. The single supply advocates say the power supply to the Arduino should be properly filtered using capacitors and a proper voltage regulator usually, and the problem is solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree in principle. However, I have seen situations where the transient failure was so brief it looked 'mysterious'. It took time and effort to track it down. Sometimes it was because the motor power supply was underpowered. When the motor 'stalled', for example when changing direction, taking maximum current, the power supply voltage might dip enough to cause the Arduino supply to dip, and reset the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary, if you are going to use a single power source for both motor and Arduino, ensure it has plenty of electrical noise filtering, and is a bit over-engineered to cope with the motor stalling. Specifically, it should be able to supply the motors stall current without dipping too low for the Arduino. The 'professional' approach is to have the Arduino monitor the main power supply, and detect that voltage dip. However, that is more complexity, and I suggest you avoid that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: If you are concerned you might have weird, hard to trace problems, using a single supply, try to design the system so that the Arduino can be 'unplugged' and given its own supply. That should be easy to do with that L298N board as the connections are screw terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using two separate power supplies should &lt;em&gt;reduce&lt;/em&gt; the chances of electrical noise from the motors getting into the Arduino. In some circumstances is it useful to be able to change the motor power supply, or switch it off, without powering the Arduino off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the motor voltage is a lot higher than the 5V needed by the arduino, simple techniques to step down the voltage (linear regulators, like the part on that L298N board) convert the excess power to heat, which is quite inefficient. Much above, about, 18V it can generate enough heat to reach quite a high temperature (i.e. 100C) unless it has a good heatsink. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, a simple, cheap solution is to use a second small power supply for the Arduino. An Arduino is likely using under 100mA, so a PP3 would be okay for, maybe, a few hours. A longer term approach is to step the motor voltage down efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use two power supplies, connect the two 'ground' (i.e. or most negative battery connections) together so that they have a common 'ground' reference. That way the Arduino signals will control the motor driver reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;PWM does not step down voltage. It gives the illusion of less power because the full voltage is only applied for a fraction of each millisecond. When it is on, it is providing (very close to) the full 'motor' voltage. If the 'motor voltage' connected to that L298N board is 12V, then the motor will see 12V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, even if the motor is rated at only 3volts, it is unlikely to break only because 12V is applied across it. A 3V motor is as likely to break because it gets too hot, or spun too fast (e.g. the bearings get damaged). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will likely get too hot under load, or spin too fast if the PWM signal is on for more than, WAG 50% of the time (but there is no warranty with WAG = Wild-A$$-Guess).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, and only if, your software doesn't run PWM more than 50%, then those motors may be okay. That is a risk I might be prepared to take if the motors are cheap, and replacements easy to get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Skimming the datasheet, the L298N needs an absolute &lt;em&gt;minimum&lt;/em&gt; motor supply of 2.3V+2.5V = 4.8V.&lt;br&gt;&#xA;Also, the output switches which control the motor appear to 'drop' a minimum of 1.8volts.&lt;br&gt;&#xA;So I think it would be okay with 6V or 7.2V (maybe upto 9V) motor voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IIRC the arduino will work okay with 7.2V upwards, i.e. 6 x NiMh batteries. A higher voltage is just converted to heat by the on-board voltage regulator. I might be tempted to experiment with the L298N boards 5V output, unless you have seen complaints about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming the motors are brushed DC motors (and not steppers or something exotic)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor driver will handle switching the current that the motor needs. However, each time the current is switched on or off, the motor will draw current, or generate current (remember it is a motor and also a generator). That could cause the power rail to dip, or even feed current into power or ground. There are diodes on the board to prevent those spikes doing anything awful to the chip, but there is still current flowing through wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, every rev of the motor, the brushes will break one connection, and make a different connection with the commutator, typically 6 times. (The commutator is the mechanical system that directs the current to flow the correct way round in the motors spinning electromagnet). That creates electrical noise. In some cases so much that you can hear it on an old fashioned radio receiver or analogue TV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So noise may be a problem. People typically put a 10nF-100nF, relatively high voltage (say 50V), capacitor directly across the motors power connections, at the motor end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If things get bad, I did a quick search and this &lt;a href=&quot;http://www.kerrywong.com/2012/01/26/a-short-guide-on-motor-electrical-noise-reduction/&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog&lt;/a&gt; looked okay, it illustrates ways to use capacitors and inductors to reduce motor noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't worry too much. Put 10nF-100nF across the motor wires, and see what happens.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2019-03-07T00:13:26.937" LastActivityDate="2019-03-07T00:13:26.937" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3685" PostTypeId="2" ParentId="3618" CreationDate="2014-08-08T01:55:56.560" Score="1" Body="&lt;p&gt;See  &lt;a href=&quot;https://github.com/greiman/SdFat&quot; rel=&quot;nofollow&quot;&gt;https://github.com/greiman/SdFat&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ensure it works with the sdinfo example, and then you can just use the sdformatter example to format the card.&lt;/p&gt;&#xA;" OwnerUserId="3499" LastActivityDate="2014-08-08T01:55:56.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3686" PostTypeId="2" ParentId="3679" CreationDate="2014-08-08T03:41:06.167" Score="3" Body="&lt;p&gt;As others have pointed out, without a current limiting resistor you may have fried the LED. Thus you might need another LED to test with. On a typical LED with a 1.2 forward voltage drop, a 220 ohm resistor will limit current to about 17 mA (i = v/r.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;forward voltage = supply voltage - LED voltage drop&#xA;forward voltage  = (5.0 - 1.2) = 3.8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;current = 3.8V/220ohms = 17 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the specs on your LEDs. 1.2 V forward voltage drop is common on little LEDs. Max current of 20 mA is common as well, but it doesn't pay to go all the way to the max. That's the &quot;do not exceed or you may destroy it&quot; level.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-08T03:41:06.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3687" PostTypeId="2" ParentId="3680" CreationDate="2014-08-08T06:19:01.840" Score="7" Body="&lt;p&gt;Assuming your distro is using &lt;code&gt;udev&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;udevadm info --query=all --name=/dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might need root privileges to run this(sudo / su). It will output a list of information like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;P: /devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/tty/ttyACM0&#xA;N: ttyACM0&#xA;S: serial/by-id/usb-Dean_Camera_LUFA_USB-RS232_Adapter_74133353537351403012-if00&#xA;S: serial/by-path/pci-0000:00:1d.2-usb-0:2:1.0&#xA;E: DEVLINKS=/dev/serial/by-id/usb-Dean_Camera_LUFA_USB-RS232_Adapter_74133353537351403012-if00 /dev/serial/by-path/pci-0000:00:1d.2-usb-0:2:1.0&#xA;E: DEVNAME=/dev/ttyACM0&#xA;E: DEVPATH=/devices/pci0000:00/0000:00:1d.2/usb4/4-2/4-2:1.0/tty/ttyACM0&#xA;E: ID_BUS=usb&#xA;E: ID_MM_CANDIDATE=1&#xA;E: ID_MODEL=LUFA_USB-RS232_Adapter&#xA;E: ID_MODEL_ENC=LUFA\x20USB-RS232\x20Adapter&#xA;E: ID_MODEL_FROM_DATABASE=Uno R3 (CDC ACM)&#xA;E: ID_MODEL_ID=0043&#xA;E: ID_PATH=pci-0000:00:1d.2-usb-0:2:1.0&#xA;E: ID_PATH_TAG=pci-0000_00_1d_2-usb-0_2_1_0&#xA;E: ID_REVISION=0001&#xA;E: ID_SERIAL=Dean_Camera_LUFA_USB-RS232_Adapter_74133353537351403012&#xA;E: ID_SERIAL_SHORT=74133353537351403012&#xA;E: ID_TYPE=generic&#xA;E: ID_USB_DRIVER=cdc_acm&#xA;E: ID_USB_INTERFACES=:020201:0a0000:&#xA;E: ID_USB_INTERFACE_NUM=00&#xA;E: ID_VENDOR=Dean_Camera&#xA;E: ID_VENDOR_ENC=Dean\x20Camera&#xA;E: ID_VENDOR_FROM_DATABASE=Arduino SA&#xA;E: ID_VENDOR_ID=2341&#xA;E: MAJOR=166&#xA;E: MINOR=0&#xA;E: SUBSYSTEM=tty&#xA;E: UDEV_LOG=3&#xA;E: USEC_INITIALIZED=751387324986&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is for an Uno with modified firmware on the atmega16u2(usb to serial). The lines of interest are probably ID_MODEL_ID and ID_MODEL_FROM_DATABASE.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-08T06:19:01.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3688" PostTypeId="1" AcceptedAnswerId="3689" CreationDate="2014-08-08T08:13:04.777" Score="16" ViewCount="15920" Body="&lt;p&gt;Yesterday afternoon I have left my Arduino running on a fresh Alkaline 9V battery (+ connected to Vin, - connected to GND). Today morning (16 hours later) the LCD display was no longer visible, and when I measured the volatage, I saw the battery was depleted to my surprise - its idle voltage was only 7 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My device is Arduino Uno with LCD 2x16 with LCD backlight and 2 DS18B20 sensors. Is it normal for such device to deplete 9V battery this quick?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://arduino.stackexchange.com/a/79/3452&quot;&gt;an answer to What are (or how do I use) the power saving options of the Arduino to extend battery life? question&lt;/a&gt; and I think what I see might be related to this, however I am not sure. If it is, is there some common schematics how to connect Arduino to be powered by a battery efficiently?&lt;/p&gt;&#xA;" OwnerUserId="3452" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-08T01:58:26.083" Title="Arduino powering from 9V battery" Tags="|power|battery|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3689" PostTypeId="2" ParentId="3688" CreationDate="2014-08-08T08:52:14.980" Score="21" Body="&lt;p&gt;&lt;strong&gt;Power consumption&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino boards use a fair bit of power compared to other embedded systems with similar functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three main factors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The NCP1117 (&lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/NCP1117-D.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;) 5V linear regulator in the Arduino UNO&#xA;R3 (&lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt;) has a quiescent current of around 6mA.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The ATMega328P (&lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;) draws around 5mA @ 8MHz and 5V, and probably more than double that at 16MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;user2973:&lt;/em&gt; The ATMega16U2 used for USB communications also draws approximately 13mA.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;LEDs and other peripherals also draw some current. In your circuit, the LCD backlight is probably drawing 4mA as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When dropping 9V to 5V via a linear regulator, almost half of the power is lost by the regulator due to its 4V drop. &lt;em&gt;Duncan&lt;/em&gt; comments that this nearly doubles the &lt;em&gt;quiescent&lt;/em&gt; power draw from 9V as well as the power needed for every mA of 5V, since 4/9ths of the power gets wasted as heat by the voltage regulator. An efficient switching regulator would put out 5V with little wasted energy, effectively reducing the current draw seen by the battery by 4/9ths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A duracell 9V battery (&lt;a href=&quot;http://ww2.duracell.com/media/en-US/pdf/gtcl/Product_Data_Sheet/NA_DATASHEETS/PC1604_US_PC.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;) drops from 9V to 7V in around 7.5 hours with a 50mA current draw. Therefore, a rough guess is that your circuit draws around 25mA, which sounds about right based on the description of your circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, alkaline battery life is non-linear with respect to current. For very small currents (&amp;lt;1mA) the life of an Alkaline approaches that of a lithium battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Getting current down&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some tips to get the current consumption down:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Regulator:&lt;/em&gt; Replace the regulator with one with a low quiescent current, or better yet, a switching regulator (also with low quiescent current). A switching regulator uses 'pulses' of current and some external inductor and capacitors to give a reasonable steady voltage output. It doesn't waste energy like with the voltage drop of linear regulator and efficiency in the high 90% are possible.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There are buck (step down) converters that take the battery as input, then connect directly to 5V and GND, bypassing VIN and the regulator. &lt;a href=&quot;http://littlebirdelectronics.com.au/products/pololu-5v-step-up-step-down-voltage-regulator-s7v7f5&quot; rel=&quot;nofollow noreferrer&quot;&gt;This one&lt;/a&gt; from Pololu both steps up and down, and has 0.1mA quiescent current.&lt;/li&gt;&#xA;&lt;li&gt;Alternatively, you could use some 1.5V alkaline batteries, and a boost (step up) converter to get the voltage up to 5V (e.g. &lt;a href=&quot;https://www.sparkfun.com/products/10968&quot; rel=&quot;nofollow noreferrer&quot;&gt;this product&lt;/a&gt; from Sparkfun). It seems boost converters are more commonly stocked.&lt;/li&gt;&#xA;&lt;li&gt;Finally, you could buy a rechargeable lithium battery with charging shield. This advantage of this is not having to buy new batteries, and for a tiny bit bigger than a 9V battery the lithium one has much greater capacity. A really cool product is the &lt;a href=&quot;http://www.seeedstudio.com/depot/Seeeduino-Stalker-Waterproof-Solar-Kit-p-911.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;seeeduino stalker waterproof kit&lt;/a&gt; that includes a charging circuit, battery, solar panel and other goodies.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;ATMega328P:&lt;/em&gt; Rather than using &lt;code&gt;delay&lt;/code&gt; for timing and spinning in &lt;code&gt;loop&lt;/code&gt; endlessly waiting for something to happen, re-write your code so that it goes to sleep in between sensor reads, etc. There are a few &lt;a href=&quot;http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/&quot; rel=&quot;nofollow noreferrer&quot;&gt;low power libraries&lt;/a&gt; out there that use the watchdog timer for periodic wakeup from sleep which are handy. You can get the current consumption of the ATMega328P below 0.1mA during sleep.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;LCD:&lt;/em&gt; Turn off the backlight, or even the entire LCD. Add a button to the design that the user can push to activate the LCD and have it turn off after a set amount of inactivity.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Peripherals:&lt;/em&gt; Most peripheral chips also have a sleep mode that drastically reduces their power consumption. Remove power LEDs and other indicators that are not necessary.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;ATMegu16U2:&lt;/em&gt; &lt;em&gt;user2973&lt;/em&gt; comments It seems this chip is quite power hungry (&lt;em&gt;user2973&lt;/em&gt;). It could be removed to save power and just use the UART instead, but that seems like overkill. There are Arduino Pro boards that are just the bare bones Arduino without the USB interface that could be used instead of the UNO.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;em&gt;Batteries:&lt;/em&gt; Other alkaline cells have much greater capacity. For example, a 1.5V AA has over 2000mAh for low currents. Using AA cells plus a boost converter can increase the time before battery replacement. Use D cells (16000mAh) and it will run for quite a while. :D&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With appropriate power supply and coding you can get a reasonable amount of life out of a battery. Using the above principles, I have made an Arduino derivative board that measures a few sensors and stores the readings to an SD card every half a second. It can last for about 4 months on 2 AA batteries, so it is definetly possible to have low power and remain in the Arduino ecosystem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chip I used for the low power in my board is the LTC3525-3.3V. It takes an input voltage as low as 0.8V and boosts up to 3.3V and a 5V version is also available. I designed a PCB for this chip as there was no ready-made breakout, and in the datasheet there are reference designs. The main critera for choosing this chip was it still had high efficiency at very low currents. Some other converters need a small minimum current draw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest consumer of power on the board ended up being the micro SD card. It can vary between 0.1mA and 1.5mA of idle current depending on the manufacturer. I have found Verbatim and Lexar cards to consume the least amount of power. I will &lt;a href=&quot;https://electronics.stackexchange.com/questions/37173/low-power-micro-sd-card-storage&quot;&gt;this EE.SE question&lt;/a&gt; up to date with the results of my micro SD card power consumption tests.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-08-08T23:09:50.403" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="3690" PostTypeId="2" ParentId="3638" CreationDate="2014-08-08T09:32:34.450" Score="0" Body="&lt;p&gt;The number you are seeing instead - 85.1, is suspiciously close to a Farenheit reading instead of Celcius - my guess is that there maybe a setup step for the Dallas DB18B20 that you are issuing too early for it, before it has initialised, and so it is ignoring it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess would be steps being a unit setting, and a calibration setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can you attempt to wait a little time (perhaps 100 millis) before initialising the temperature control library.&lt;/p&gt;&#xA;" OwnerUserId="3477" LastActivityDate="2014-08-08T09:32:34.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3691" PostTypeId="2" ParentId="3688" CreationDate="2014-08-08T09:48:16.593" Score="3" Body="&lt;p&gt;I think an Arduino Uno is not suitable for such projects. Some components on the board draw too many amps, as @geometrikal correctly points out. If you're up to a challenge, I would advise you to take your project to another level and go barebones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sparkfun has a good article about how to increase battery life, using an ATmega328 that you also have on your Arduino Uno:&#xA;&lt;a href=&quot;https://www.sparkfun.com/tutorials/309&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/tutorials/309&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for ways to create a circuit with only the components that you really need, and have your microcontroller sleep as much as possible.&lt;/p&gt;&#xA;" OwnerUserId="3501" LastActivityDate="2014-08-08T09:48:16.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3693" PostTypeId="2" ParentId="1493" CreationDate="2014-08-08T15:56:46.820" Score="2" Body="&lt;p&gt;In case you didn't know it already you can hook any batteries in parallel by adding a diode on every battery to avoid current from any other battery flowing back to it. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; battery&#xA;      |+  diode&#xA;+----||---&amp;gt;|---+&#xA;|     |        |&#xA;|              |&#xA;|     |+       |&#xA;+----||---&amp;gt;|---+----o V++&#xA;|     |        &#xA;|&#xA;_&#xA;V GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The drawback&lt;/strong&gt; is that you have a small drop of voltage on the diodes and of course a small power loss too. If for example you're drawing 0.5 Amp from the batteries and you're using an 1N4001 diode which has a voltage drop of about 0.7 Volts then expect  0.350 Watts of power loss (0.5A x 0.7V). So choose the diode with the lowest voltage drop that can handle the current you need. There are solutions to lower the power that is wasted but they're more complex.&lt;/p&gt;&#xA;" OwnerUserId="3507" LastActivityDate="2014-08-08T15:56:46.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3695" PostTypeId="2" ParentId="3667" CreationDate="2014-08-09T00:21:03.480" Score="1" Body="&lt;p&gt;Pin 1 is active low reset. Try connecting it to 5V to run the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CAtGH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-09T00:21:03.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3697" PostTypeId="1" AcceptedAnswerId="3698" CreationDate="2014-08-09T08:09:23.843" Score="1" ViewCount="2158" Body="&lt;p&gt;I'm noticing a crash when testing out some interrupt code for a project I'm working on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've returned to the example provided with the library &lt;a href=&quot;http://code.google.com/p/arduino-pcimanager/&quot; rel=&quot;nofollow&quot;&gt;PciManager&lt;/a&gt; and I'm still experiencing the same issue. There doesn't appear to be any patten to when the crash appears, and on occasion I've been playing for several minutes and not seen a crash. NOTE I had to add a file (Task.h) from the developers other project (&lt;a href=&quot;http://code.google.com/p/arduino-softtimer/&quot; rel=&quot;nofollow&quot;&gt;SoftTimer&lt;/a&gt;) to get it to compile.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PciManager.h&amp;gt;&#xA;#include &amp;lt;PciListenerImp.h&amp;gt;&#xA;&#xA;#define INPUT_PIN 3&#xA;&#xA;PciListenerImp listener(INPUT_PIN, onPinChange);&#xA;&#xA;int i = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  PciManager.registerListener(INPUT_PIN, &amp;amp;listener);&#xA;  Serial.println(&quot;Ready.&quot;);&#xA;&#xA;}&#xA;&#xA;void onPinChange(byte changeKind) {&#xA;  i++;&#xA;  Serial.print(&quot;pci : &quot;);&#xA;  Serial.print(i);&#xA;  Serial.print(&quot; : &quot;);&#xA;  Serial.println(changeKind);&#xA;}&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a wire connected to pin 3 and 3.3v which I'm pulling out and then connecting again. Some times when disconnected it continually interrupts, I was expecting this. Sometimes it doesn't which I found strange, the crash appears to happen more in the latter case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a trace from the serial monitor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ready.&#xA;pci : 1 : 0&#xA;pci : 2 : 1&#xA;pci : 3 : 0&#xA;pci : 4 : 1&#xA;pci : 5 : 0&#xA;pci : 6 : 1&#xA;pci : 7 : 0&#xA;pci : 8 : 1&#xA;pci : 9 : 0&#xA;pci : 10 : 1&#xA;pci : 11 : 0&#xA;pci : 12 : 1&#xA;pci : 13 : 0&#xA;pci : 14 : 1&#xA;pci : 15 : 0&#xA;pci : 16 : 1&#xA;pci : 17 : 0&#xA;pci : 18 : 1&#xA;pci : 19 : 0&#xA;pci : 20 : 1&#xA;pci :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've run this on a &lt;a href=&quot;http://shrimping.it/blog/shrimp-kit/&quot; rel=&quot;nofollow&quot;&gt;shrimp&lt;/a&gt; and on a freeduino diecimila compatible board both resulting in the same effect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway down to question; is the issue the way I'm interrupting? i.e. not stopping the floating pin? or is it a problem with the library, or is it a fundamental problem with pin change interrupts.  &lt;/p&gt;&#xA;" OwnerUserId="2762" LastActivityDate="2016-01-04T19:40:21.520" Title="'crash' when using pin change interrupts" Tags="|interrupt|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3698" PostTypeId="2" ParentId="3697" CreationDate="2014-08-09T11:01:53.600" Score="5" Body="&lt;p&gt;Your &lt;code&gt;onPinChange()&lt;/code&gt; function is called with interrupts disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For you what it means is this function should:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;last &lt;strong&gt;as short as possible&lt;/strong&gt; (because &lt;strong&gt;NO&lt;/strong&gt; interrupts are handled during its execution, that includes timers that are used by several Arduino core libraries)&lt;/li&gt;&#xA;&lt;li&gt;not use &lt;code&gt;Serial&lt;/code&gt; functions as these functions are slow and sometimes wait on interrupts (that could thus mean &lt;em&gt;wait forever&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can read further advice about these so-called &lt;em&gt;Interrupt Service Routines&lt;/em&gt; (&lt;strong&gt;ISR&lt;/strong&gt;) &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://gammon.com.au/interrupts&quot;&gt;there&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to trace all calls to &lt;code&gt;onPinChange()&lt;/code&gt; then you will have to use some kind of &lt;a href=&quot;http://en.wikipedia.org/wiki/Circular_buffer&quot;&gt;circular buffer&lt;/a&gt; as a global &lt;code&gt;volatile&lt;/code&gt; variable, which will be written into by &lt;code&gt;onPinChange()&lt;/code&gt; and read from by &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accessing that buffer from &lt;code&gt;loop()&lt;/code&gt; should be protected against concurrent write by ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is sample code I have just written (disclaimer, I have not checked that it compiles but I think it should work correctly) that uses such a circular buffer as described above, and ensures all shared variables accesses are protected against concurrent write by ISR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PciManager.h&amp;gt;&#xA;#include &amp;lt;PciListenerImp.h&amp;gt;&#xA;&#xA;// Structures and function to manage circular buffer of changes&#xA;struct Change {&#xA;    int i;&#xA;    byte kind;&#xA;};&#xA;&#xA;// We allow max SIZE changes in the buffer; if onPinChange() is called more often&#xA;// than loop(), then at one time the buffer will be overwritten.&#xA;const int SIZE = 100;&#xA;volatile Change changes[SIZE];&#xA;volatile int start = 0;&#xA;volatile int end = 0;&#xA;&#xA;// Get the next change recorded by onPinChange()&#xA;Change* nextChange() {&#xA;    static Change change;&#xA;    Change* result = 0;&#xA;    // Disable interrupts as we are accessing variables modified by onPinChange&#xA;    cli();&#xA;    if (start != end) {&#xA;        change = changes[start];&#xA;        start = (start + 1) % SIZE;&#xA;        result = &amp;amp;change;&#xA;    }&#xA;    // Re-enable interrupts before leaving the function&#xA;    sei();&#xA;    return result;&#xA;}&#xA;&#xA;#define INPUT_PIN 3&#xA;&#xA;PciListenerImp listener(INPUT_PIN, onPinChange);&#xA;&#xA;// No change necessary in setup()&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    PciManager.registerListener(INPUT_PIN, &amp;amp;listener);&#xA;    Serial.println(Ready.);&#xA;}&#xA;&#xA;void loop() {&#xA;    // Get the next change recorded by onPinChange (if any)&#xA;    Change* change = nextChange();&#xA;    if (change != 0) {&#xA;        // One change occurred since last time, trace it to Serial&#xA;        Serial.print(&quot;pci : &quot;);&#xA;        Serial.print(change-&amp;gt;i);&#xA;        Serial.print(&quot; : &quot;);&#xA;        Serial.println(change-&amp;gt;kind);&#xA;    }&#xA;}&#xA;&#xA;void onPinChange(byte changeKind) {&#xA;    // i does not have to be visible outside this function&#xA;    static int i = 0;&#xA;    i++;&#xA;    // Write information to the end of the circular buffer&#xA;    Change&amp;amp; change = changes[end];&#xA;    change.i = i;&#xA;    change.kind = changeKind;&#xA;    // Prepare for the next call (write to the next item of the buffer)&#xA;    end = (end + 1) % SIZE;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-09T11:01:53.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3699" PostTypeId="2" ParentId="3697" CreationDate="2014-08-09T12:07:06.790" Score="3" Body="&lt;p&gt;Note that disconnecting a wire on an input pin is also not going to give you the results you expect. A disconnected input pin's value will float, and you'll get a semi-random mixture of 1s and 0s. You should either connect an external pull-up/pull-down resistor, or activate the internal pull-up resistor when you configure the pin (by setting the pin to INPUT_PULLUP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer using INPUT_PULLUP, since that saves wiring an external resistor. Use INPUT_PULLUP, then wire the pin through a pushbutton switch to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then look for a high-to-low transition on the pin to signify a button press.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-09T12:07:06.790" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3700" PostTypeId="1" AcceptedAnswerId="4990" CreationDate="2014-08-09T12:26:29.273" Score="14" ViewCount="35324" Body="&lt;p&gt;Can't upload sketches to Arduino Nano clone with USB to serial chip ch340.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing drivers and plugging in, device has the name &lt;code&gt;cu/tty.wch ch341 USB=&amp;gt;RS232 fa130&lt;/code&gt; (with spaces), but Arduino can't recognize the full name (only &lt;code&gt;tty.wch&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to rename device in Mac OS or change device identifier?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: &lt;code&gt;ch340&lt;/code&gt; new driver &lt;a href=&quot;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=178&quot;&gt;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=178&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="3332" LastEditorUserId="220" LastEditDate="2015-07-20T21:41:54.373" LastActivityDate="2015-11-26T07:36:17.467" Title="Rename device name (ch340 usb to serial) Mac OS" Tags="|osx|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3701" PostTypeId="1" CreationDate="2014-08-09T20:09:16.917" Score="1" ViewCount="2971" Body="&lt;p&gt;A while ago, I found a library for the MAX72XX that had functions for writing text to the display, but unfortunately cannot find such library now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which would be the best library to use for a text and number display? I'm using LedControl but it is very awkward to use.&lt;/p&gt;&#xA;" OwnerUserId="3517" LastActivityDate="2016-01-19T08:35:20.040" Title="MAX72XX with 8 digit 7 segment display library" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3702" PostTypeId="1" AcceptedAnswerId="3706" CreationDate="2014-08-09T21:15:58.030" Score="15" ViewCount="24188" Body="&lt;p&gt;I am having problems controlling a 3.5&quot; Floppy Disk Drive with an Arduino Uno.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the floppy disk drive powered with a computer power supply that is switched on, and the Arduino powered by my computer's USB.  I have cut apart the ribbon of a 34-pin IDC connector to be able to route the pins to my Arduino.  I am able to turn the floppy disk motor on and move the read/write head back and forth, but I am never able to read any pulses from the Track-0 or Index pins.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have pins 7, 15, 17, 19, and 25 from the floppy all grounded to my Arduino, and I have pins 8, 16, 18, 20, and 26 from the floppy connected to my arduino as output pins so I can control the drive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am expecting the Index to pulse when the disk motor makes a rotation, and for Track 0 to change when I am at the outside of the disk, but they are both always LOW.  Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is the spec I found for the back of the floppy disk unit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    2   /REDWC  Input Density Select&#xA;    4   n/c N/A Reserved&#xA;    6   n/c N/A Reserved&#xA;    8   /INDEX  Output Index&#xA;    10  /MOTEA  Input Motor Enable A &#xA;    12  /DRVSB  Input Drive Sel B&#xA;    14  /DRVSA  Input Drive Sel A &#xA;    16  /MOTEB  Input Motor Enable B&#xA;    18  /DIR    Input Direction&#xA;    20  /STEP   Input Step &#xA;    22  /WDATE  Input Write Data&#xA;    24  /WGATE  Input Floppy Write Enable&#xA;    26  /TRK00  Output Track 0&#xA;    28  /WPT    Output Write Protect&#xA;    30  /RDATA  Output Read Data&#xA;    32  /SIDE1  Input  Head Select&#xA;    34  /DSKCHG Output Disk Change/Ready&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here a schematic of what I have hooked up&lt;/strong&gt;&#xA;&lt;strong&gt;&lt;em&gt;(The breadboard in this circuit diagram represents the IDC connector that is plugged into the 3.5&quot; floppy drive.)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pEHOT.png&quot; alt=&quot;Floppy &amp;amp; Arduino Connections&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is a photo of the IDC Connector and I labelled which wires are connected to the Arduino.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DdFX0.jpg&quot; alt=&quot;Labelled IDC Connector&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here's the code I am running.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//constants&#xA;static const int IN = LOW;&#xA;static const int OUT = HIGH;&#xA;static const int pulseDelayTime = 6;&#xA;&#xA;//pins&#xA;int indexPin = 2; //8 on the drive INDEX&#xA;int track0Pin = 3; //26 on the drive. TRACK 0&#xA;int dirPin = 6; //18 on the drive. DIRECTION&#xA;int stepPin = 7; //20 on the drive. STEP&#xA;int motorEnableBPin = 9; //16 on the drive. MOTOR ENABLE B&#xA;&#xA;unsigned long motorSpinTime = 1000UL; //in ms&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  //initial delay&#xA;  delay(3000);&#xA;&#xA;  //setup serial monitor&#xA;  Serial.begin(9600);      &#xA;&#xA;  //setup pins.&#xA;  pinMode(dirPin, OUTPUT);&#xA;  pinMode(stepPin, OUTPUT);&#xA;  pinMode(motorEnableBPin, OUTPUT);&#xA;  pinMode(indexPin, INPUT);&#xA;  pinMode(track0Pin, INPUT);&#xA;&#xA;  //turn the motor off initially&#xA;  digitalWrite(motorEnableBPin, HIGH);&#xA;&#xA;  //print state here.&#xA;  printState(&quot;Setup done.&quot;);&#xA;&#xA;  //spin the disk some.&#xA;  printState(&quot;Begin to spin motor&quot;);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  printState(&quot;Done spinning motor&quot;);&#xA;&#xA;  //step read/write head all the way in.&#xA;  stepAllTheWayIn();&#xA;&#xA;  //spin the disk some more.&#xA;  printState(&quot;Begin to spin motor&quot;);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  printState(&quot;Done spinning motor&quot;);&#xA;&#xA;  //step read/write head all the way out.&#xA;  stepAllTheWayOut();&#xA;&#xA;  //spin the disk even more.&#xA;  printState(&quot;Begin to spin motor&quot;);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  spinMotorForThisManyMs(motorSpinTime);&#xA;  printState(&quot;Done spinning motor&quot;);&#xA;&#xA;  //never completes.&#xA;  waitForIndex();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;//spins the disk motor for a number of ms and prints the state&#xA;void spinMotorForThisManyMs(unsigned long msToSpin) {&#xA;&#xA;  //start spinning&#xA;  digitalWrite(motorEnableBPin,LOW);&#xA;&#xA;  //delay.. keep printing the state&#xA;  unsigned long maxTimeMs = millis() + msToSpin;  &#xA;  while(millis() &amp;lt; maxTimeMs ) {&#xA;    printState(&quot;Spinning&quot;);    &#xA;  }&#xA;&#xA;  //stop spinning&#xA;  digitalWrite(motorEnableBPin,HIGH);&#xA;}&#xA;&#xA;&#xA;&#xA;//step the read/write head all the way to the center&#xA;void stepAllTheWayIn() {&#xA;  for(int i=0;i&amp;lt;100;i++) {&#xA;    printState(&quot;Stepping In&quot;);&#xA;    stepInALittle();&#xA;  }&#xA;}&#xA;&#xA;//step the read/write head all the way to the outside&#xA;void stepAllTheWayOut() {&#xA;  for(int i=0;i&amp;lt;100;i++) {&#xA;    printState(&quot;Stepping Out&quot;);&#xA;    stepOutALittle();&#xA;  }&#xA;}&#xA;&#xA;//print the state of the index and track&#xA;void printState(const char* charPrint) {&#xA;  Serial.print(&quot; Index:&quot;);&#xA;  Serial.print(digitalRead(indexPin));&#xA;  Serial.print(&quot; Track:&quot;);&#xA;  Serial.print(digitalRead(track0Pin));&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.println(charPrint);&#xA;}&#xA;&#xA;//move the head towards the outside a little&#xA;void stepOutALittle() {&#xA;  digitalWrite(dirPin,HIGH);&#xA;  stepPulse();&#xA;}&#xA;&#xA;//move the head towards the center a little&#xA;void stepInALittle() {&#xA;  digitalWrite(dirPin,LOW);&#xA;  stepPulse();&#xA;}&#xA;&#xA;//pulse the step pin&#xA;void stepPulse() {&#xA;  digitalWrite(stepPin,LOW);&#xA;  delay(pulseDelayTime);&#xA;  digitalWrite(stepPin,HIGH);&#xA;}&#xA;&#xA;//waits for the index to trigger. this never gets completed.&#xA;void waitForIndex() {&#xA;&#xA;  printState(&quot;beginning to wait for index pin to pulse&quot;);&#xA;&#xA;  //start spinning&#xA;  digitalWrite(motorEnableBPin,LOW);&#xA;&#xA;  //wait for pulse&#xA;  while(digitalRead(indexPin));&#xA;  //wait for end of pulse 0&#xA;  while(!digitalRead(indexPin));&#xA;&#xA;  printState(&quot;end of waiting for index pin to pulse&quot;);&#xA;&#xA;  //stop spinning&#xA;  digitalWrite(motorEnableBPin,HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is the output I am getting.&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Index:0 Track:0 Setup done.&#xA; Index:0 Track:0 Begin to spin motor&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Done spinning motor&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Stepping In&#xA; Index:0 Track:0 Begin to spin motor&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Done spinning motor&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Stepping Out&#xA; Index:0 Track:0 Begin to spin motor&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Spinning&#xA; Index:0 Track:0 Done spinning motor&#xA; Index:0 Track:0 beginning to wait for index pin to pulse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&#xA;I am now receiving my expected results due to geometrikal's answer.   While researching this problem I found a few code examples of Arduino to Floppy Drive. I noticed that they were setting their input pins to HIGH, but I never realized why they were doing this.  After fixing my problem, I found this in some Arduino documentation (which made me realize the code examples I had were using an older version of the Arduino IDE):  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Prior to Arduino 1.0.1, it was possible to configure the internal pull-ups      in the following manner:&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT);           // set pin to input&#xA;digitalWrite(pin, HIGH);       // turn on pullup resistors`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Arduino 1.0.1+ you can do it this way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3518" OwnerDisplayName="Jeff Lett" LastEditorUserId="3518" LastEditDate="2014-08-10T15:49:44.963" LastActivityDate="2020-02-14T18:39:54.163" Title="Controlling Floppy Disk Drive with Arduino" Tags="|arduino-uno|hardware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3703" PostTypeId="2" ParentId="3702" CreationDate="2014-08-09T21:42:51.320" Score="3" Body="&lt;p&gt;You should replace &lt;code&gt;int&lt;/code&gt; with &lt;code&gt;unsigned long&lt;/code&gt; in all locations where you deal with time in milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is that &lt;code&gt;millis()&lt;/code&gt; returns an &lt;code&gt;unsigned long&lt;/code&gt;, thus using &lt;code&gt;int&lt;/code&gt; to store &lt;code&gt;millis()&lt;/code&gt; value, you have a loss of information due to automatic cast performed by the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The changes you have to perform are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long motorSpinTime = 1000UL; //in ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//spins the disk motor for a number of ms and prints the state&#xA;void spinMotorForThisManyMs(unsigned long msToSpin) {&#xA;&#xA;  //start spinning&#xA;  digitalWrite(motorEnableBPin,LOW);&#xA;&#xA;  //delay.. keep printing the state&#xA;  unsigned long maxTimeMs = millis() + msToSpin;  &#xA;  while(millis() &amp;lt; maxTimeMs ) {&#xA;    printState(&quot;Spinning&quot;);    &#xA;  }&#xA;&#xA;  //stop spinning&#xA;  digitalWrite(motorEnableBPin,HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I have also performed some optimization in the waiting loop by calculating the maximum time once and then compare &lt;code&gt;millis()&lt;/code&gt; directly to that value. This is not mandatory but I just find it a bit more clean.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-09T21:42:51.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3704" PostTypeId="1" CreationDate="2014-08-09T22:12:05.753" Score="0" ViewCount="929" Body="&lt;p&gt;I'm new to XBee and a colleague setup a sender/receiver pair. I'm using an usb breakout and reading the values using this &lt;a href=&quot;https://code.google.com/p/xbee-api/wiki/Processing&quot; rel=&quot;nofollow noreferrer&quot;&gt;java XBee API&lt;/a&gt; in Processing/Java.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I'm having is two of the pins(analog 3 and 4) seem to have a strange alternating pattern and this makes it harder to read the values. Here's what I mean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a recording of the plot I'm drawing of the values:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/1VR74.gif&quot; alt=&quot;analog plot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and here are some values. I noticed there were duplicate entries, so I removed those:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;654,28&#xA;65,28&#xA;65,366&#xA;52,366&#xA;52,263&#xA;607,263&#xA;607,23&#xA;45,23&#xA;45,554&#xA;164,554&#xA;164,138&#xA;393,138&#xA;393,14&#xA;33,14&#xA;33,677&#xA;432,677&#xA;432,64&#xA;77,64&#xA;24,237&#xA;24,345&#xA;659,345&#xA;659,29&#xA;61,29&#xA;74,378&#xA;74,226&#xA;455,226&#xA;455,16&#xA;42,16&#xA;42,592&#xA;225,592&#xA;225,107&#xA;348,107&#xA;348,13&#xA;27,13&#xA;27,700&#xA;515,700&#xA;515,56&#xA;60,56&#xA;60,392&#xA;372,392&#xA;372,70&#xA;98,70&#xA;98,141&#xA;12,141&#xA;12,456&#xA;663,456&#xA;663,30&#xA;64,30&#xA;74,349&#xA;74,224&#xA;554,224&#xA;554,20&#xA;41,20&#xA;41,600&#xA;256,600&#xA;256,96&#xA;127,96&#xA;127,87&#xA;13,87&#xA;13,502&#xA;659,502&#xA;659,37&#xA;75,37&#xA;75,251&#xA;20,251&#xA;20,364&#xA;631,364&#xA;631,25&#xA;55,25&#xA;55,436&#xA;128,436&#xA;128,165&#xA;447,165&#xA;447,16&#xA;38,16&#xA;38,618&#xA;224,618&#xA;224,107&#xA;251,14&#xA;25,14&#xA;25,700&#xA;535,700&#xA;535,54&#xA;67,54&#xA;69,323&#xA;69,235&#xA;568,235&#xA;568,21&#xA;49,21&#xA;49,503&#xA;182,503&#xA;330,128&#xA;330,12&#xA;13,12&#xA;13,498&#xA;665,498&#xA;665,35&#xA;76,35&#xA;76,247&#xA;47,247&#xA;47,277&#xA;313,277&#xA;313,12&#xA;22,12&#xA;22,691&#xA;513,691&#xA;513,56&#xA;157,56&#xA;157,53&#xA;18,53&#xA;18,640&#xA;169,640&#xA;103,48&#xA;103,105&#xA;12,105&#xA;12,389&#xA;209,389&#xA;209,30&#xA;65,30&#xA;65,353&#xA;19,353&#xA;19,282&#xA;200,282&#xA;200,18&#xA;21,18&#xA;21,681&#xA;152,681&#xA;152,54&#xA;123,54&#xA;123,47&#xA;14,47&#xA;14,526&#xA;654,526&#xA;654,37&#xA;74,37&#xA;74,260&#xA;17,260&#xA;17,387&#xA;655,387&#xA;655,29&#xA;61,29&#xA;61,375&#xA;74,375&#xA;74,249&#xA;512,249&#xA;512,18&#xA;32,18&#xA;32,678&#xA;255,678&#xA;255,92&#xA;270,92&#xA;270,11&#xA;25,11&#xA;25,319&#xA;557,319&#xA;557,53&#xA;61,53&#xA;61,165&#xA;115,165&#xA;115,133&#xA;195,133&#xA;195,18&#xA;20,18&#xA;20,317&#xA;594,317&#xA;594,48&#xA;126,48&#xA;126,41&#xA;14,41&#xA;14,281&#xA;653,281&#xA;653,40&#xA;80,40&#xA;80,96&#xA;35,96&#xA;35,189&#xA;623,189&#xA;623,25&#xA;55,25&#xA;55,191&#xA;139,191&#xA;139,123&#xA;468,123&#xA;468,16&#xA;31,16&#xA;31,306&#xA;622,306&#xA;622,45&#xA;82,45&#xA;82,90&#xA;24,90&#xA;24,345&#xA;207,345&#xA;207,32&#xA;66,32&#xA;66,347&#xA;22,347&#xA;22,247&#xA;201,247&#xA;201,18&#xA;41,18&#xA;41,616&#xA;82,616&#xA;82,82&#xA;93,82&#xA;93,147&#xA;12,147&#xA;12,472&#xA;206,472&#xA;206,33&#xA;73,33&#xA;73,287&#xA;18,287&#xA;18,274&#xA;204,274&#xA;204,19&#xA;49,19&#xA;49,526&#xA;64,526&#xA;64,103&#xA;182,103&#xA;182,14&#xA;27,14&#xA;27,701&#xA;457,701&#xA;457,61&#xA;225,61&#xA;225,19&#xA;19,19&#xA;19,654&#xA;592,654&#xA;592,48&#xA;105,48&#xA;105,125&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the pattern I noticed the higher values occur every 3rd value but also the values seem to oscillate like on a sine wave. If I read only the 3rd value of each sensor that seems remove the 'gaps', but the sine wave pattern is still visible. When I physically get the two pots connected to analog pins 3 and 4 (index 2 and 3 in my plot) I can notice the maximum value either increases or decreases, but the sine pattern is still there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also started going though the XBee manual and found this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Analog samples are returned as 10-bit values. The analog reading is&#xA;  scaled such that 0x0000 represents 0V, and 0x3FF = 1.2V. (The analog&#xA;  inputs on the module cannot read more than 1.2V.) Analog samples are&#xA;  returned in order starting with AIN0 and finishing with AIN3, and the&#xA;  supply voltage. Only enabled analog input channels return data as&#xA;  shown in the figure below. To convert the A/D reading to mV, do the&#xA;  following: AD(mV) = (A/D reading * 1200mV) / 1023&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I'm not very experienced with electronics, but it looks like a linear mapping to me and I haven't found anything else pointing to this oscillation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My naive approach would be to work out the period or this sine wave and see how much the amplitude changes when I physically turn the pots versus the 'default' position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also started looking at signal processing and thought that potentially I could use a 'wavelet' to detect a pattern and then see difference between the expected one and the current signal, but that sounds a bit overkill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my naive approach decent ? What's the simplest way to read values from a signal like this ?&lt;/p&gt;&#xA;" OwnerUserId="3505" LastActivityDate="2014-08-11T09:27:58.100" Title="How to process this XBee analog pins signal?" Tags="|serial|xbee|signal-processing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3705" PostTypeId="1" CreationDate="2014-08-10T01:26:39.167" Score="2" ViewCount="128" Body="&lt;p&gt;I am working with a &lt;a href=&quot;https://arduino.stackexchange.com/questions/304/what-are-the-svg-pins-for-on-the-sainsmart-uno-clone&quot;&gt;Sainsmart Uno with SVG header pins&lt;/a&gt;.  This header is really convenient for hooking a servo to directly, so I have two servos connected to it on D9 and D10 and a 9v battery supplying power via the power jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to work fine at first, but eventually (sometimes quickly), the board becomes unresponsive.  If, instead, I wire my servos to use the 5v pin on the Arduino (not from this SVG header), I don't run into this trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if I am running into a limitation of this header Voltage pin?  Has anyone had any success using this mechanism to drive servos?  Certainly, I don't NEED to do it this way, but it sure is convenient.  &lt;/p&gt;&#xA;" OwnerUserId="3519" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-08-10T01:26:39.167" Title="Can I use the SVG headers on the SainSmart Uno to drive servos?" Tags="|arduino-uno|power|servo|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3706" PostTypeId="2" ParentId="3702" CreationDate="2014-08-10T02:48:02.770" Score="11" Body="&lt;p&gt;According to this (dead link):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://bitsavers.trailing-edge.com/pdf/nec/FD1035_Product_Description_Jul84.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://bitsavers.trailing-edge.com/pdf/nec/FD1035_Product_Description_Jul84.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;This is an archived copy of the &lt;a href=&quot;https://ia801902.us.archive.org/3/items/bitsavers_necFD1035Pl84_876629/FD1035_Product_Description_Jul84.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;FD1035 3.5&quot; Floppy disk drive: Product Description July 1984 - PDF&lt;/a&gt;:&lt;/em&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://archive.org/details/bitsavers_necFD1035Pl84_876629&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://archive.org/details/bitsavers_necFD1035Pl84_876629&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The outputs are open-collector, so a pull-up resistor is required. You can instead enable the Arduino internal pull-ups on those pins by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(indexPin, INPUT_PULLUP);&#xA;pinMode(track0Pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="6936" LastEditDate="2018-08-06T17:50:34.840" LastActivityDate="2018-08-06T17:50:34.840" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="3707" PostTypeId="2" ParentId="3704" CreationDate="2014-08-10T08:13:24.840" Score="2" Body="&lt;p&gt;Sounds like your pots are not connected correctly and you pick up noise. The waveform you are seeing could be from the mains, or another source. Stray magnetic fields from transformers etc. can couple and be picked up by your circuit and you will notice them if your input is of high impedance. The atmosphere is also full of electromagnetic radiation from human sources and from space, that you can also pick up. The longer wires that are connected to your high impedance input, the more noise you will pick up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your pots should be wired 1.2V-AIN-GND, with the 1.2V source being low impedance, coming from a power supply/regulator and not eg. a voltage divider. If your potentiometer is high impedance (say 100 kOhm), and it is connected with wires from eg. a breadboard, you might want to add a decoupling capacitor between AIN and GND. 0.1 uF would be a typical value. It will short out AC waveforms(noise) to ground.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-10T08:13:24.840" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3708" PostTypeId="1" AcceptedAnswerId="3709" CreationDate="2014-08-10T08:59:47.990" Score="2" ViewCount="509" Body="&lt;p&gt;I found this wonderful breakout board based on &lt;a href=&quot;https://www.sparkfun.com/products/9716#comment-53e7333cce395f8b068b4567&quot; rel=&quot;nofollow&quot;&gt;FT232&lt;/a&gt;. I wonder if I can use this board for connecting my arduino to a USB dongle for 3g/GPRS connection ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand this board can be connected to the serial data pins of the arduino board. And if I connect the USB dongle to the FT232 board, I should be able to run AT commands from the arduino board.&lt;/p&gt;&#xA;" OwnerUserId="3328" LastActivityDate="2014-08-10T09:41:40.903" Title="Connecting a Arduino to FT232" Tags="|serial|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3709" PostTypeId="2" ParentId="3708" CreationDate="2014-08-10T09:41:40.903" Score="5" Body="&lt;p&gt;Unfortunately, no, as the FT232 would have to act as a USB host device. A &lt;a href=&quot;http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino&quot;&gt;USB host shield&lt;/a&gt; might work if someone has written driver code to support 3G modems.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-10T09:41:40.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3710" PostTypeId="2" ParentId="3617" CreationDate="2014-08-10T11:27:10.800" Score="0" Body="&lt;p&gt;A fridge temperature monitor (or any system that talks to world using some data) will include a sensor (temperature sensor like LM35), a controller (to do calculations, arduino ofcourse) and an output (display, like LCD). The topics you should be aware of, are digital electronics, basic passive components (working of resistor, capacitor etc). And a little arduino programming and lots of logic.&lt;/p&gt;&#xA;" OwnerUserId="3521" LastActivityDate="2014-08-10T11:27:10.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3711" PostTypeId="2" ParentId="3535" CreationDate="2014-08-10T11:40:20.177" Score="2" Body="&lt;p&gt;The LED strip with blue ones requires a higher current drive. Arduino output pins can drive only 20mA max(ideal). Try an external power source. &lt;/p&gt;&#xA;" OwnerUserId="3521" LastActivityDate="2014-08-10T11:40:20.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3712" PostTypeId="1" AcceptedAnswerId="3716" CreationDate="2014-08-10T14:18:08.780" Score="0" ViewCount="9564" Body="&lt;p&gt;I'm not sure if I'm being really really stupid, but why doesn't this work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int x; x &amp;lt; 8; x++) {&#xA;    for (int y; y &amp;lt; 8; y++) {&#xA;      Serial.print(x);&#xA;      Serial.println(y);&#xA;      delay(100);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int x; x &amp;lt; 8; x++) {&#xA;    Serial.println(x);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first produces no output over Serial, whereas the second one prints out the numbers 0 to 7 as expected. I'm using a Teensy 3.1.&lt;/p&gt;&#xA;" OwnerUserId="3522" LastActivityDate="2018-10-24T20:45:07.837" Title="Nested For Loop" Tags="|programming|teensy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3713" PostTypeId="2" ParentId="3697" CreationDate="2014-08-10T14:33:56.807" Score="5" Body="&lt;p&gt;I'm going to include this answer even though I think there's a very little chance that it is the problem because I just wasted ten hours on a project before finding it and it's an easy check so it won't take much time either way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On AVR chips, if you have enabled interrupts and one occurs and you don't have an ISR for it, it will call the default ISR which resets the board. You can test if this is happening by redefining the default ISR by creating a function ISR(BADISR_vect){};  I would put a serial print in there and run it again and see if it's happening. If you don't want to do serial (for obvious reasons) just toggle an LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also agree it's probably a bad idea to be doing this on a floating pin. I'd use the internal pull-up resister to keep it high then connect a wire between that pin and ground to simulate a button. &lt;/p&gt;&#xA;" OwnerUserId="3152" LastEditorUserId="10907" LastEditDate="2016-01-04T19:40:21.520" LastActivityDate="2016-01-04T19:40:21.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3714" PostTypeId="2" ParentId="3634" CreationDate="2014-08-10T15:32:19.377" Score="0" Body="&lt;p&gt;It sounds like the USB to serial chip has failed. You could test this by using another arduino or a programmer like the AVRISP mkII to load a program that way and see if it's your whole board or just the serial chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the board and main chip are still good, you could just get used to uploading with this new method, or you could try to reprogram the other chip used for serial. I know it I'd possible but ever time I've burned one this hadn't help so YMMV. &lt;/p&gt;&#xA;" OwnerUserId="3152" LastEditorUserId="26916" LastEditDate="2017-09-08T23:18:15.353" LastActivityDate="2017-09-08T23:18:15.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3715" PostTypeId="2" ParentId="3462" CreationDate="2014-08-10T15:40:28.443" Score="4" Body="&lt;p&gt;I'm not entirely sure from your question if you want just the module or a whole breakout board.  If the latter, try this from adafruit. It can very easily do his either as mouse or keyboard and is well documented and supported so I think this would be much easier to get running initially. &lt;a href=&quot;http://www.adafruit.com/products/1535&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/1535&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3152" LastActivityDate="2014-08-10T15:40:28.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3716" PostTypeId="2" ParentId="3712" CreationDate="2014-08-10T15:43:53.743" Score="7" Body="&lt;p&gt;You are not initializing x and y.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a local variable isn't initialized, it will &quot;inherit&quot; the value contained in the register assigned to the variable by the compiler. The fact that your single loop example worked is pure luck - the assigned register happened to contain 0 at that point in execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change your nested loop like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int x = 0; x &amp;lt; 8; x++) {&#xA;  for (int y = 0; y &amp;lt; 8; y++) {&#xA;    Serial.print(x);&#xA;    Serial.println(y);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Global variables, on the other hand, are guaranteed by the c++ standard to be initialized to zero. The compiler will make sure to write zeros to those memory addresses before the main program code executes.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-10T15:43:53.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3717" PostTypeId="1" CreationDate="2014-08-10T16:39:30.563" Score="2" ViewCount="967" Body="&lt;p&gt;I am a newbie to the arduino world. And am trying to work out a configuration that does not involve USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if this configuration will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any 3g modems that work on Rs232 interface. That should get rid of the USB compatibility that costs 3 times a arduino.&lt;/p&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="3328" LastEditDate="2014-08-11T02:38:52.527" LastActivityDate="2014-08-11T02:38:52.527" Title="Using Arduino RS232 to a modem (only RS232)" Tags="|serial|uart|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3719" PostTypeId="1" AcceptedAnswerId="3722" CreationDate="2014-08-10T22:13:59.380" Score="2" ViewCount="1783" Body="&lt;p&gt;I'm using FastLED with a custom board built around the ATMega32u4. When I set it to use Software SPI, everything works fine, but when I use hardware SPI it just hangs whenever it tries to write out the data (FastLED.show()).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally mocked this up on an Arduino Pro Micro and it worked fine there. That makes me think that it's a hardware issue but, as I mentioned, SPI output &lt;em&gt;does&lt;/em&gt; work, but only when bit-banged. Which really doesn't make much sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this by also just using the built in SPI classes and I get the same thing. No luck with hardware SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone else ever see something like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schematic of my circuit is below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4R7AW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-08-11T06:42:14.167" Title="Arduino: Hardware SPI hangs, bit-bang does not" Tags="|spi|atmega32u4|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3721" PostTypeId="2" ParentId="1232" CreationDate="2014-08-11T01:06:34.597" Score="2" Body="&lt;p&gt;Using 1.5.6-r2 with Eclipse cause the Due to hung in Default_Handler function after entering main and polling a few times for the next SysTick gettin passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some weak symbol declarations are done twice (i.e. the SysTick_Handler function definitions). They appear to overwrite each others weak alias depending on the link time usage of the objects. All declarations (not only the failing SysTick_Hanlder) from cortex_handler.c are getting overwritten by weak symbol redeclaration inside startup_sam3xa.c.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This commit seems to already address a weak symbol definition problem.&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/commit/65f00a69c74ca0def8d7f1d7597327945a04a33f&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/commit/65f00a69c74ca0def8d7f1d7597327945a04a33f&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, to fix it. Just comment out the part in startup_sam3xa.c with the weak symbol declaration regarding the vectors. Lines 53 to 129.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also work to just remove the file completely.&#xA;The startup handler code and vector map should be provided by gcc arm built-in libraries instead.&lt;/p&gt;&#xA;" OwnerUserId="1310" LastEditorUserId="1310" LastEditDate="2014-08-11T01:13:14.340" LastActivityDate="2014-08-11T01:13:14.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3722" PostTypeId="2" ParentId="3719" CreationDate="2014-08-11T06:42:14.167" Score="5" Body="&lt;p&gt;According to &lt;a href=&quot;http://www.atmel.ch/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_%20Datasheet.pdf&quot;&gt;ATmega32u4 datasheet&lt;/a&gt;, section 17.2.1 (SPI / SS Pin Functionality / Master Mode:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;If SS is configured as an input, it must be held high to ensure Master SPI operation.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your circuit, SS pin (#8 on package), also labeled as &quot;&lt;strong&gt;(SS/PCINT0) PB0&lt;/strong&gt;&quot;, is left unconnected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible that PB0 is also configured as input somewhere in your program or libraries? In this case, it should be connected to Vcc.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-11T06:42:14.167" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3723" PostTypeId="2" ParentId="3704" CreationDate="2014-08-11T09:27:58.100" Score="1" Body="&lt;p&gt;Sounds familiar .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First i will test whether i am reading something or just picking up random noise due to poor connection or error in coding (data conversion arithmetic etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect 1 pin to ground and another to 1.2V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should read 1024 and 0 on e 2 pins . If not check circuit and code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vadc = (ADC/1024) * Vref&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you connect Vref ?&lt;/p&gt;&#xA;" OwnerUserId="3528" LastActivityDate="2014-08-11T09:27:58.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3724" PostTypeId="2" ParentId="3184" CreationDate="2014-08-11T09:39:12.737" Score="0" Body="&lt;p&gt;Buy a uart wifi such as WiFly series chip. You can control e chip via UART AT command. The chip capable of sending http post get to/from a server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this guide as an example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://the.machini.st/posts/35&quot; rel=&quot;nofollow&quot;&gt;http://the.machini.st/posts/35&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3528" LastActivityDate="2014-08-11T09:39:12.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3725" PostTypeId="1" CreationDate="2014-08-11T09:43:34.327" Score="1" ViewCount="2300" Body="&lt;p&gt;Do Arduinos meet military standards?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, where does it fall short? Is it something internal to the chip which might be corrected via external circuit? How could I evaluate the potential of a device I'm building?&lt;/p&gt;&#xA;" OwnerUserId="3528" LastEditorUserId="37" LastEditDate="2014-08-12T15:43:43.697" LastActivityDate="2017-08-08T02:34:49.873" Title="Do Arduinos meet military standards?" Tags="|safety|coding-standards|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3726" PostTypeId="2" ParentId="3725" CreationDate="2014-08-11T11:15:52.143" Score="0" Body="&lt;p&gt;It is not mil spec. Making something comply with milspec is a big, complex subject. (A subject I know very little about.)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-11T11:15:52.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3727" PostTypeId="2" ParentId="3725" CreationDate="2014-08-11T11:20:21.657" Score="1" Body="&lt;p&gt;Defiantly not. If you wanted to use it for very early prototyping then I think it would be fine. However, it really depends on the use because lets admit it Adriuno boards don't have huge amounts of processing power and are somewhat limited to capabilities.&lt;/p&gt;&#xA;" OwnerUserId="3530" LastActivityDate="2014-08-11T11:20:21.657" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3728" PostTypeId="1" CreationDate="2014-08-11T06:08:44.173" Score="4" ViewCount="13905" Body="&lt;p&gt;I'm using a 5V &lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Pro Micro&lt;/a&gt; (&lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Boards/Pro_Micro_v13.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For my project, I'm using the VCC pin to output power to an external device.  I need VCC to output 3.3V to the external device.  Can I open jumper SJ1 to reduce the voltage of the VCC pin without affecting the operation of the other parts of the unit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZzMmK.png&quot; alt=&quot;Circuit schematic&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3540" OwnerDisplayName="Mark Harrison" LastEditorUserId="6936" LastEditDate="2016-02-19T11:16:27.787" LastActivityDate="2021-03-18T14:54:40.270" Title="Can I change VCC pin to 3.3V on a 5V Arduino Pro Micro?" Tags="|power|voltage-level|resistor|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3729" PostTypeId="2" ParentId="3728" CreationDate="2014-08-11T07:36:19.380" Score="5" Body="&lt;p&gt;No. If you change the voltage to 3,3 Volt you also have to change the crystal to 8MHz and reprogram the ATmega32u4 to meet the new frequency.&lt;/p&gt;&#xA;" OwnerUserId="1576" OwnerDisplayName="MatsK" LastActivityDate="2014-08-11T07:36:19.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3730" PostTypeId="1" AcceptedAnswerId="3734" CreationDate="2014-08-11T13:26:49.220" Score="1" ViewCount="1143" Body="&lt;p&gt;I have arduino UNO hooked up with wtv020-sd-16p and it works fine, playing audio files - speaker is connected right to the WTV020's pin #4 and #5. However, volume is rather low. So I have ordered LM386 amplifier module. I have wired it's IN pin with WTV020's pin #2 AUDIO-L. But no sound comes out of speaker. I can hear only some scratches from the speaker while arduino is running. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LM386 is pretty easy, only VCC, IN and GND pins, so there is nothing much to screw up. I am wondering, what could be the problem ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help or hints in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Only to note, when WTV020 is playing sound, speaker goes completely mute. When it doesn't play sound, little scratchy sounds can be heard from speaker. Maybe it could help with analysis ?&lt;/p&gt;&#xA;" OwnerUserId="3533" LastEditorUserId="3533" LastEditDate="2014-08-11T14:57:00.613" LastActivityDate="2014-08-11T16:52:30.113" Title="LM386 module not working" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3731" PostTypeId="1" CreationDate="2014-08-11T16:17:23.277" Score="3" ViewCount="2832" Body="&lt;p&gt;thanks for taking the time to read this, I really appreciate it.&#xA;I am very new to Arduino and the Micro controller world so please forgive my ignorance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have an old 7 segment display that displays outside temperature, what i want to do is read the temp into the Arduino and light up an LED if the temperature gets high, and a different color if the temp gets low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know i can use a thermometer and plug it into the Arduino and go from there, but that would be cheating. So my question is, can i read each pin of the 7 segment display and translate that into a number into the Arduino? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Task: &lt;strong&gt;Read&lt;/strong&gt; a dual  10 pin 7 segment by &lt;strong&gt;jumping&lt;/strong&gt; wires into the Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Setup: I am using the code and setup found here: &quot;&lt;a href=&quot;http://blog.rastating.com/using-a-7-segment-led-display-w-arduino-uno/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://blog.rastating.com/using-a-7-segment-led-display-w-arduino-uno/&lt;/a&gt;&quot; to display a number (21) for testing purposes. I want to jump the pins into another Arduino and read &quot;21&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;please see pictures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be very very appreciated!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks again for reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Da26i.jpg&quot; alt=&quot;This is the main goal.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gNJto.jpg&quot; alt=&quot;Another picture of the main goal.![][2]&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This last picture shows &quot;21&quot; using the code and set up on the above link.&#xA;I want to jump another Arduino into the breadboard and read &quot;21&quot; or any other temperature (depends on outside thermometer) into the serial monitor. Now the challenging part is the code, Im not really good at coding but i understand if this had 1 pin for each LED i would just read each one and translate it into the serial monitor. However this only has 10 pins therefore represents a challenge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any input is greatly appreciated, I dont even know how to start.&lt;/p&gt;&#xA;" OwnerUserId="3537" LastActivityDate="2022-02-02T19:29:42.890" Title="Reading a 10 pin 7 segment (2 digits) sing Arduino 1. Please Help!" Tags="|c++|led|display|analogread|temperature-sensor|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3732" PostTypeId="1" AcceptedAnswerId="3736" CreationDate="2014-08-11T16:18:26.570" Score="-1" ViewCount="4472" Body="&lt;p&gt;I have a project with leds and sensors, this is my first project in Arduino and I want to know if it need resistors and how and where?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use 16-Bit I/O Expander &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP23017&lt;/a&gt; for leds and multiplexer &lt;a href=&quot;http://pdf.datasheetcatalog.net/datasheets/120/109150_DS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;CD4051&lt;/a&gt; for sensors &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm35.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;LM35&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jUCjl.jpg&quot; alt=&quot;My design&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="609" LastEditorUserId="609" LastEditDate="2014-08-11T16:25:48.977" LastActivityDate="2014-08-11T17:54:30.040" Title="Sensors and leds. This need resistors? and how?" Tags="|sensors|led|resistor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3733" PostTypeId="1" CreationDate="2014-08-11T16:42:10.537" Score="2" ViewCount="8590" Body="&lt;p&gt;I'm currently studying embedded systems on eDx.&#xA;&lt;a href=&quot;https://courses.edx.org/courses/UTAustinX/UT.6.01x/1T2014/info&quot; rel=&quot;nofollow&quot;&gt;https://courses.edx.org/courses/UTAustinX/UT.6.01x/1T2014/info&lt;/a&gt; (must login to see)&#xA;&lt;a href=&quot;http://users.ece.utexas.edu/~valvano/edX/index.html&quot; rel=&quot;nofollow&quot;&gt;http://users.ece.utexas.edu/~valvano/edX/index.html&lt;/a&gt; (don't need to login)&#xA;and I found out that TM4C123 is quite similar to Arduino.&#xA;but I haven't worked TM4C123 yet.(I ordered it and I'm waiting for it)&#xA; I don't know much about it.&#xA;and it's not that popular as Arduino I guess.&#xA;so If anyone has used Tm4C123, please give me some information compared to Arduino.&lt;/p&gt;&#xA;" OwnerUserId="3310" LastEditorUserId="3310" LastEditDate="2014-08-11T17:13:41.767" LastActivityDate="2017-02-06T08:58:30.023" Title="Is TM4C123 similar to Arduino?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3734" PostTypeId="2" ParentId="3730" CreationDate="2014-08-11T16:52:30.113" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;when WTV020 is playing sound, speaker goes completely mute. When it doesn't play sound, little scratchy sounds can be heard from speaker. Maybe it could help with analysis&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed - what you are describing sounds like the DC component of the Arduino's output is outside the workable range of the amplifier, effectively cutting it off.  When there is no output, the voltage is within range and little bits of noise are able to be amplified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to fix the cutoff problem with a series capacitor to block the DC component of the input, allowing only the AC signal through - a common technique for coupling between stages in Audio and RF systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of the capacitor will depend on the impedance of the circuit it is driving.  A bare input to many chips could use a quite small value, while a circuit with feedback or a voltage-divider volume control might require a larger or carefully chosen one.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-08-11T16:52:30.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3735" PostTypeId="2" ParentId="3731" CreationDate="2014-08-11T17:02:05.870" Score="3" Body="&lt;p&gt;Your display is multiplexed, so you will need to monitor not only the segment lines but also the digit lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First figure out if your display is &quot;common anode&quot; or &quot;common cathode&quot; as the logic in one case will be inverted from that of the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your test case, you can write the driving and reading arduinos to the display in the same way, but configure all the connected pins on the reading one as inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky part is going to be detecting when the segment select has changed, but you could do it by storing the current value of each select pin, and then reading the new value.  If you see that the old value was inactive and the new value active, then wait a tiny amount of time and read all of the segment lines.  You want to wait long enough to make sure that the data lines have been driven to match, but no so long that you get the data for the next digit instead.  If you have access to a scope, you can find the best value, but you could also experiment by making the delay short until you get wrong data, making it long until you get wrong data, and then picking an intermediate value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find it easiest to read all 7 or 8 segment lines into a single byte value, and then compare it to each element in the lookup table you used in the driver code until you find a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't know the exact wiring of the segments on the unknown target board, consider printing the bytes to the serial monitor as you cause the displayed values to change (cup of ice water, cup of hot water...) and taking notes of the segment values vs. the digits you see display.  It will be a puzzle, but one you should be able to figure out.  &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-08-11T17:02:05.870" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3736" PostTypeId="2" ParentId="3732" CreationDate="2014-08-11T17:54:30.040" Score="3" Body="&lt;p&gt;You will definitely need resistors for each LED connected to MCP23017 circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is necessary because without resistor the following is likely to happen:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;burn each LED that is lit on as it would be fed too much current&lt;/li&gt;&#xA;&lt;li&gt;burn the MCP23017 because it is rated for 125mA maximum (20mA per output pin)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The resistor to use normally depends on the color of each LED as those LEDs have different electrical charasteristics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically one LED (3 or 5mm) needs no more than 20mA to be lit (lower current such as 10mA is generally provides enough light).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other important LED characteristic is its &lt;strong&gt;forward voltage&lt;/strong&gt;, which depends on the color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://led.linear1.org/1led.wiz&quot; rel=&quot;nofollow&quot;&gt;This link&lt;/a&gt; will help you calculate the &quot;ideal&quot; resistor for each LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sensors part, I see no reason to use any resistor to connect them to 4051 circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last important point is related to the use of &lt;strong&gt;I2C&lt;/strong&gt; bus by the MCP23017 circuits. &lt;a href=&quot;http://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow&quot;&gt;I2C bus&lt;/a&gt; is &quot;open drain&quot; and thus requires pullup resistors for both &lt;strong&gt;SCL&lt;/strong&gt; and &lt;strong&gt;SDA&lt;/strong&gt; lines.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-11T17:54:30.040" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3737" PostTypeId="2" ParentId="3733" CreationDate="2014-08-11T18:51:00.133" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://www.ti.com/tool/ek-tm4c123gxl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tiva C LaunchPad&lt;/a&gt; is comparable to the Arduino Due in power and capabilities, but is incompatible with the stock Arduino ecosystem. It uses &quot;&lt;a href=&quot;https://www.ti.com/ww/en/launchpad/boosterpacks.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;BoosterPacks&lt;/a&gt;&quot; rather than &lt;a href=&quot;http://shieldlist.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Shields&lt;/a&gt;, and &lt;a href=&quot;http://www.ti.com/tool/ccstudio&quot; rel=&quot;nofollow noreferrer&quot;&gt;Code Composer Studio&lt;/a&gt; (or other [some non-gratis] tools) instead of the Arduino IDE and libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://energia.nu/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Energia IDE&lt;/a&gt; is a port of the Arduino IDE and significantly simplifies configuration and programming Tiva C launchpads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware of odd quirks with the Tiva C Launchpad board, such as the &lt;a href=&quot;http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/236248&quot; rel=&quot;nofollow noreferrer&quot;&gt;0-ohm shunts that must be removed&lt;/a&gt; if you want all pins to be completely independent. &lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="30674" LastEditDate="2017-02-06T08:58:30.023" LastActivityDate="2017-02-06T08:58:30.023" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3738" PostTypeId="2" ParentId="3725" CreationDate="2014-08-11T18:53:54.450" Score="5" Body="&lt;p&gt;It depends on the application. For something like a rechargeable torch, Arduino might exceed the specifications. For a weapons system, NEVER (and &lt;strong&gt;this is one of the &lt;em&gt;specific&lt;/em&gt; prohibitions in the &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=conditions&quot; rel=&quot;nofollow noreferrer&quot;&gt;license agreement&lt;/a&gt;&lt;/strong&gt; - see section 1.5 &lt;em&gt;note: link currently broken&lt;/em&gt;). You also have to consider that there's literally thousands of armies in the world and they all have different standards. What might be acceptable to one might not be acceptable to another. Hamas uses rockets I wouldn't consider safe for anything, and they use them effectively - the &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CB8QFjAA&amp;amp;url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FQassam_rocket&amp;amp;ei=6QvpU8HTAY7toASWroKwBg&amp;amp;usg=AFQjCNEo1p4fmf7z50ubVtBvXmItqD4nWQ&amp;amp;sig2=qJRL1_apQAqHK7O6Qn30cw&amp;amp;bvm=bv.72676100,d.cGU&quot; rel=&quot;nofollow noreferrer&quot;&gt;Qassam rocket&lt;/a&gt; would never meet US military standards but it works great for Hamas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;US military standards are so complicated, nobody can answer this question for you. You're gonna need an army of lawyers to do that... here's &lt;a href=&quot;http://www.dsp.dla.mil/APP_UIL/displayPage.aspx?action=content&amp;amp;contentid=66&quot; rel=&quot;nofollow noreferrer&quot;&gt;a link&lt;/a&gt; to some documents to get started though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note there are multiple standards which may apply to a given device. For example, you will see common off the shelf desktop computers (running Windows) used for some things in a military installation, but they could never be used to control a vehicle. Bottom line - you're gonna need a lawyer to navigate this. (You are better off selling your devices directly to soldiers, if you can live with that if it fails.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dsp.dla.mil/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.dsp.dla.mil/&lt;/a&gt; - Terrible site - get used to that if you want to deal with govs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OH BTW... if you want to use Arduino to prototype something, and you plan to remove &quot;Arduino&quot; later, running straight from the ATMega - that's the whole point of Arduino! It is a prototyping system, not intended to be used wholly in products. Arduino is very little more than a break-out board for the ATMega processor, a robust (kinda) power supply, and a runtime environment in C++.&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2017-08-08T02:34:49.873" LastActivityDate="2017-08-08T02:34:49.873" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3739" PostTypeId="1" AcceptedAnswerId="3746" CreationDate="2014-08-11T20:33:31.397" Score="3" ViewCount="2807" Body="&lt;p&gt;I want to use xbee's to communicate between two different arduinos.  I'm using &lt;a href=&quot;http://youtu.be/mPx3TjzvE9U&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; as a guide to setup my xbee's. I've already used XCTU to setup one xbee as a router and another as a coordinator (both in ZIGBEE AT mode).  I used XCTU's terminal feature to verify that info was being sent and received properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I have both arduinos connected to the same PC via USB cables, but the communication is taking place through the Xbee's.  I also made sure to disconnect the TX &amp;amp; RX wires when uploading the sketches to avoid an AVRDUDE error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to test the communication by sending a &quot;hello world&quot; message once every five seconds, from the router to the coordinator.  To do this, I wrote the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Code for Arduino attached to Xbee in Router AT mode&#xA;void setup(){&#xA; Serial.begin(9600); &#xA;}&#xA;&#xA;void loop(){&#xA;  Serial.println(&quot;Hello World!&quot;);&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Code for Arduino attached to Xbee in Coordinator AT mode&#xA;void setup(){&#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop(){&#xA;  if (Serial.available()&amp;gt;0){&#xA;    Serial.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked the serial monitor for the arduino connected to the router, and it does exactly what I expected to see:  a new Hello World message once every 5 seconds.  However, the serial monitor on the arduino connected to the coordinator does not produce the desired effect:  &lt;strong&gt;&lt;em&gt;the &quot;hello world&quot; message instantly displays the message over a hundred times per second and repeats without end, each time on a separate, new line&lt;/em&gt;&lt;/strong&gt;.  Sometimes, when I turn the serial monitor on, the message instantly appears with a few repetitions before displaying some strange characters and stopping altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if the problem is with the serial monitor or with the xbee.  Any help with this problem would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="667" LastEditorUserId="667" LastEditDate="2014-08-12T15:01:46.573" LastActivityDate="2014-08-13T04:32:16.137" Title="Serial.write displaying repeating output from Xbee communication" Tags="|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3740" PostTypeId="2" ParentId="3725" CreationDate="2014-08-11T21:44:50.830" Score="1" Body="&lt;p&gt;Your question is broad. My first reaction is to say No.  But in order to be very accurate (or fair), your should find the application standard. Military has an extensive library of standards ranging from manufacturing and testing.  Therefore, take a look at the standard regulating your application. Only after this assessment, the question of whether Arduino will suffice a military application will be accurately answered.&lt;/p&gt;&#xA;" OwnerUserId="3323" LastActivityDate="2014-08-11T21:44:50.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3741" PostTypeId="2" ParentId="3731" CreationDate="2014-08-11T23:37:26.303" Score="1" Body="&lt;p&gt;First of all, make sure that the voltage is below 5V (but above 2.5V so it can register as HIGH on a digital pin). If not, it will either fry your Arduino or won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the code, you can do one of the two following things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a library like &lt;strong&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;PinChangeInt&lt;/a&gt;&lt;/strong&gt; to help you detect when and what changed.&lt;/li&gt;&#xA;&lt;li&gt;Store the data and check every so often.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Chris Stratton had a good idea with the byte and compare it. To do this, you would do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte data = 0;&#xA;if(digitalRead(10) == HIGH) {&#xA;  data |= B00000001;&#xA;}&#xA;if(digitalRead(11) == HIGH) {&#xA;  data |= B00000010;&#xA;}&#xA;if(digitalRead(12) == HIGH) {&#xA;  data |= B00000100;&#xA;}&#xA;//...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, this is &lt;em&gt;bit-wise math&lt;/em&gt; that sets one bit of your byte to a 1. If it is a 0, then you leave it alone (all bits default to 0 because of how I declared &lt;code&gt;data&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If pins 10 and 12 were HIGH, the byte would look like this in binary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-11T23:37:26.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3742" PostTypeId="2" ParentId="3731" CreationDate="2014-08-12T00:33:56.680" Score="1" Body="&lt;p&gt;so I realized that the 2 pins that are driving this toggle at 4kHz, when one is on the other is off, but there is a 6usec time when both pins are on. So what im trying to do now is adding &quot;if right bit is == 1, if A=1 b=0 c=1 d=1... and so on&quot; then number = 6 then scan for it. Im not sure how to use that library. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;// read the input pin:&#xA;//int buttonState = digitalRead(pushButton);&#xA;int State_A = digitalRead(A);&#xA;int State_B = digitalRead(B);&#xA;int State_C = digitalRead(c);&#xA;int State_D = digitalRead(D);&#xA;int State_E = digitalRead(E);&#xA;int State_F = digitalRead(F);&#xA;int State_G = digitalRead(G);&#xA;int State_DP = digitalRead(DP);&#xA;int State_RIGHT = digitalRead(RIGHT);&#xA;int State_LEFT = digitalRead(LEFT);&#xA;&#xA;if (State_LEFT==1)&#xA;{&#xA; if(State_A==0 &amp;amp; State_B==1 &amp;amp; State_C==0 &amp;amp; State_D==0 &amp;amp; State_E==0 &amp;amp; State_F==0 &amp;amp; State_G==0)&#xA;{&#xA;number=6;&#xA;Serial.println(number);&#xA;// Serial.print(State_LEFT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i plan to add that for every digit. is there any easier way to do that?&lt;/p&gt;&#xA;" OwnerUserId="3537" LastActivityDate="2014-08-12T00:33:56.680" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3743" PostTypeId="1" AcceptedAnswerId="3754" CreationDate="2014-08-12T03:34:42.763" Score="1" ViewCount="6862" Body="&lt;p&gt;I have seen several references where the solution to interfacing a 5V Arduino with a 3.3V nRF24L01+ was to power the nRF24L01+ externally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I do this?  The ground of the nRF24L01+ is connected to the Arduino; can I simply attach 3.3V power between the power and ground pins of the nRF24L01+?&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-08-12T16:51:45.740" Title="Externally Powering a 3.3V device (nRL24L01+) with a 5V Arduino Pro Mini?" Tags="|power|arduino-pro-mini|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3744" PostTypeId="2" ParentId="3743" CreationDate="2014-08-12T07:39:03.167" Score="1" Body="&lt;p&gt;Yes, You can.&#xA;In any communication system, each module should have the same reference point of operation, or else the line is said to float. Here it is GND of arduino mini and GND of nRF24L01+.&lt;/p&gt;&#xA;" OwnerUserId="3521" LastActivityDate="2014-08-12T07:39:03.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3745" PostTypeId="2" ParentId="3700" CreationDate="2014-08-12T08:36:17.960" Score="5" Body="&lt;p&gt;I send email about this issue to WCH, and they change drivers to the latest version on their website, this is direct link &lt;a href=&quot;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=178&quot;&gt;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=178&lt;/a&gt; (driver works and device has proper name in &lt;code&gt;dev/&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="3332" LastActivityDate="2014-08-12T08:36:17.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3746" PostTypeId="2" ParentId="3739" CreationDate="2014-08-12T09:21:09.357" Score="1" Body="&lt;p&gt;Code is correct and it does what it is asked to. The receiver code reads the RX pin of arduino which is connected to the Xbee. The same pin is used by the FT232 interface IC to send data to your computer through USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;hello world&quot; you send is received by the Xbee and is send to microcontroller and FT232 at same time as that pin is shared between them. Thus the &quot;hello world&quot; will be seen in serial monitor, first time from Xbee and second time, from &lt;code&gt;Serial.write(Serial.read())&lt;/code&gt; of the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check whether the settings are correct from &lt;a href=&quot;http://www.ladyada.net/make/xbee/arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;, as Xbee will not be configured as P2P. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4AxOG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3521" LastEditorUserId="3521" LastEditDate="2014-08-13T04:32:16.137" LastActivityDate="2014-08-13T04:32:16.137" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3747" PostTypeId="1" AcceptedAnswerId="3765" CreationDate="2014-08-12T09:26:32.140" Score="5" ViewCount="1944" Body="&lt;p&gt;I am having problems with values i get from Pololu MinIMU-9 boards's magnetometer. I am using Arduino-micro and the arduino library from Pololu. The sensor on the board is 3 axis accelero- and magnetometer LSM303.&#xA;The problem is - the highest value always seems to be in vertical axis, not horisontal, as i would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, here is the data i got when i put sensor flat on the table and made 360 clockwise turn in horizontal plane:&#xA;(values are X Y Z)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-6 102 -516&#xA;-11 103 -515&#xA;-11 103 -515&#xA;-21 102 -514&#xA;-31 109 -515&#xA;-40 114 -512&#xA;-57 116 -509&#xA;-57 116 -509&#xA;-77 111 -507&#xA;-93 109 -506&#xA;-104 106 -507&#xA;-104 106 -507&#xA;-114 99 -508&#xA;-126 88 -504&#xA;-131 74 -507&#xA;-142 52 -507&#xA;-142 52 -507&#xA;-151 31 -506&#xA;-150 4 -509&#xA;-147 -27 -513&#xA;-147 -27 -513&#xA;-133 -60 -513&#xA;-119 -80 -519&#xA;-112 -87 -517&#xA;-102 -97 -521&#xA;-102 -97 -521&#xA;-89 -101 -522&#xA;-77 -101 -524&#xA;-50 -104 -527&#xA;-50 -104 -527&#xA;-43 -105 -529&#xA;-14 -98 -532&#xA;2 -92 -535&#xA;23 -92 -535&#xA;23 -92 -535&#xA;36 -81 -534&#xA;66 -54 -534&#xA;76 -32 -531&#xA;76 -32 -531&#xA;76 -21 -532&#xA;78 -7 -531&#xA;85 10 -528&#xA;91 39 -524&#xA;91 39 -524&#xA;94 50 -524&#xA;91 63 -524&#xA;76 75 -525&#xA;76 75 -525&#xA;63 82 -526&#xA;47 93 -525&#xA;44 98 -522&#xA;44 98 -522&#xA;38 104 -521&#xA;26 110 -521&#xA;26 112 -518&#xA;21 116 -519&#xA;21 116 -519&#xA;18 116 -518&#xA;12 120 -517&#xA;11 120 -515&#xA;11 120 -515&#xA;8 120 -517&#xA;5 122 -515&#xA;-5 123 -514&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turning the sensor &quot;upside down&quot; and then rotating it in horisontal plane again gives similar results, only Z axis has positive 500+ value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shouldn't the magnetometer always point in the direction of the magnetic field - in X or Y direction?&#xA;I have tried this in different rooms and buildings and got the same results.&#xA;Rotating the sensor on other axes yields the same results - vertical axis has the largest (and constant) value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, here is the code i used to get the values.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LSM303.h&amp;gt;&#xA;LSM303 compass;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  compass.init();&#xA;  compass.enableDefault();&#xA;}&#xA;&#xA;void loop(){&#xA;  compass.readMag();&#xA;  Serial.print(compass.m.x);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(compass.m.y);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(compass.m.z);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3542" LastActivityDate="2014-08-13T01:15:40.683" Title="Strange values from LSM303 Magnetometer" Tags="|sensors|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3748" PostTypeId="1" AcceptedAnswerId="3752" CreationDate="2014-08-12T09:40:51.090" Score="2" ViewCount="2385" Body="&lt;p&gt;I have implemented a PWM controlled LED backlight for the LCD in my Arduino Uno design. One LCD backlight pin is connected to +5V, the second to the ground via 220 Ohm resistor and MOSFET controlled from a PWM capable D9 pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to work fine, I do not see any oscillation, but after some reading about PWM I am not sure if I perhaps should connect a 100 uF capacitor to smooth the voltage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the MOSFET even necessary? It seems backlight is drawing about 5 mA - can I perhaps drive it directly from the D9 pin, using the resistor? (It seems another user in &lt;a href=&quot;https://arduino.stackexchange.com/questions/1805/do-i-need-to-use-a-resistor-if-i-am-using-a-potentiometer-to-control-an-leds-br?rq=1&quot;&gt;Do I need to use a resistor if I am using a potentiometer to control an LED&amp;#39;s brightness?&lt;/a&gt; is controlling brightness without any of those.)&lt;/p&gt;&#xA;" OwnerUserId="3452" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-08-12T14:37:10.040" Title="Arduino LED backlight - should PWM be used with transistor or capacitor?" Tags="|lcd|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3749" PostTypeId="2" ParentId="3743" CreationDate="2014-08-12T10:12:47.160" Score="-1" Body="&lt;p&gt;you can download the references from this link: &lt;a href=&quot;https://s3-ap-northeast-1.amazonaws.com/sain-amzn/20/20-019-102/NRF24L01.rar&quot; rel=&quot;nofollow&quot;&gt;https://s3-ap-northeast-1.amazonaws.com/sain-amzn/20/20-019-102/NRF24L01.rar&lt;/a&gt; &#xA;Hope the information may be helpful. Cheers!&lt;/p&gt;&#xA;" OwnerUserId="3468" LastActivityDate="2014-08-12T10:12:47.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3750" PostTypeId="2" ParentId="1239" CreationDate="2014-08-12T10:23:42.130" Score="0" Body="&lt;p&gt;How about this one? &lt;a href=&quot;http://cgi.ebay.de/ws/eBayISAPI.dll?ViewItem&amp;amp;item=380915024016&amp;amp;ssPageName=STRK:MESE:IT&quot; rel=&quot;nofollow&quot;&gt;http://cgi.ebay.de/ws/eBayISAPI.dll?ViewItem&amp;amp;item=380915024016&amp;amp;ssPageName=STRK:MESE:IT&lt;/a&gt; &#xA;The MG-811 is highly sensitive to CO2 and less sensitive to alcohol and CO.&lt;/p&gt;&#xA;" OwnerUserId="3468" LastActivityDate="2014-08-12T10:23:42.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3751" PostTypeId="2" ParentId="3731" CreationDate="2014-08-12T12:03:06.750" Score="0" Body="&lt;p&gt;What you are trying to do is tricky and awkward, and probably not worth the trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also above your current skill level, both in hardware and software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the other poster has said, the display is likely multiplexed. If so, it sends a value to 1 digit, then to the next, and alternates them quickly. Only one digit at a time is actually lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also possible that the digits are latched. The processor sends a value to one digit at a time and that digit's circuitry remembers the value until it changes again. However that's  less likely because it's more complex and expensive to do&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To decode a multiplexed display you'll need to figure out how the multiplexing is done. There are lots of different ways it could be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say it's common anode. It might have the anodes of a digit wired together, and have them both connected to the controller. The anode that's currently being displayed would be connected to +5, and the cathodes of like segments from each digit would be wired together in parallel. To drive a digit, the control circuitry would connect the anode of that digit to the positive supply, and connect the segments to be displayed to ground. All other connections would be left floating. Then it would disconnect the anode of the first digit and connect the anode of the other digit to the positive supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display may also have a logic level that determines which segment is being driven. For a 2 digit display all you'd need is one line, and a HIGH would drive 1 digit and a LOW would drive the other digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A logic analyzer would help you sort this out, but you need to know how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also try researching the thermometer you're using and see if you can find a schematic for it, in the documentation, the manufacturer website, or in a patent &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you figure out how to read the segment values from each digit, you will need a truth table that maps segment values to numbers, and will need to do a lookup. That is intermediate level C programming.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-12T12:03:06.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3752" PostTypeId="2" ParentId="3748" CreationDate="2014-08-12T14:37:10.040" Score="6" Body="&lt;p&gt;&lt;strong&gt;You don't need the MOSFET, you don't need the capacitor, you &lt;em&gt;do&lt;/em&gt; need the resistor.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins on your Arduino can deliver up to 20mA comfortably, so in this case there is no need for the MOSFET. However, if you were to replace your backlight with a high power LED, your current setup will work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a capacitor, your PWM is a nice square wave. The cap will, depending on its capacity and the resistor in your circuit, turn that into a more rounded waveform, or very ripply DC. Whichever is the case, it will not benefit the (dimming of) your LED. With some bad luck it will even introduce flickering instead of preventing it!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why you should still use the resistor is to prevent the LED from drawing too much current. Without it, it's simply a game between the LED and the Arduino pin to see who will burn first. Whoever wins, you'll end up with a destroyed backlight or fried Arduino. Adding a component costing a few cents can prevent that.&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-08-12T14:37:10.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3753" PostTypeId="1" AcceptedAnswerId="3762" CreationDate="2014-08-12T15:01:41.500" Score="9" ViewCount="34603" Body="&lt;p&gt;I am new to Arduino (and computer programming in general), so I apologize if this question  looks silly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I set up a basic arduino-LED connection, I have problems sending INTEGERS to arduino through the serial port. I can easily send characters such as 'm', 'o' and so on.. However if I send a number it looks like it simply does not get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Arduino code, ideally it should get a value from the usb port through python or the serial monitor and then adjust the brightness of the LED according to the value. (value must be in range [0,255]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I am using ARDUINO UNO and PYTHON 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//--------------------------&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LED = 10;&#xA;int number;&#xA;&#xA;void setup(){&#xA;&#xA;pinMode(LED,OUTPUT);&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;number = Serial.read();&#xA;Serial.print(number);&#xA;Serial.print('\n');&#xA;if(number == -1){&#xA;number = 0;&#xA;}&#xA;&#xA;else if(number &amp;gt; 255){&#xA;&#xA;number = 255;&#xA;&#xA;}&#xA;&#xA;else if(number &amp;lt; 0){&#xA;&#xA;number = 0;&#xA;}&#xA;&#xA;analogWrite(LED,number);&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I input a value into the Serial port or through Python, for instance 0, it gives me 48 as answer (which, interestingly, is the ASCII code for 0!) and lights up the LED which is not what should happen since at 0 the LED should be off!!&#xA;I am missing something but I cannot find what... Could you please tell me what is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I use in Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import time&#xA;try:&#xA;    arduino = serial.Serial(port,speed)&#xA;    time.sleep(2)&#xA;    print(&quot;Connection to &quot; + port + &quot; established succesfully!\n&quot;)&#xA;except Exception as e:&#xA;    print(e)&#xA;&#xA;#Note: for characters such as 'a' I set data = b'a' to convert the data in bytes&#xA;#However the same thing does not work with numbers...&#xA;data = 0&#xA;data = arduino.write(valueToWrite)&#xA;time.sleep(2)&#xA;arduino.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what am I doing wrong or misunderstanding? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3546" LastActivityDate="2014-08-12T22:01:39.090" Title="How to send numbers to Arduino UNO via Python 3 and the module serial" Tags="|arduino-uno|python|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3754" PostTypeId="2" ParentId="3743" CreationDate="2014-08-12T15:55:29.650" Score="4" Body="&lt;p&gt;To connect the nRF24L01+ to a 5V Pro Mini you will need external 3.3V power supply to power the nRF24L01+.  The ground for the Pro Mini and the ground for the nRF24L01+ should be tied together to ensure a common ground reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The inputs to the nRF24L01+ are 5V tolerant so you will not need a level shifter to convert the 5V Digital IO on the Pro Mini to 3.3V. Be aware the not all 3.3V devices have 5V tolerant inputs like nRF24L01+.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to look into using a &lt;a href=&quot;https://www.sparkfun.com/products/11114&quot; rel=&quot;nofollow&quot;&gt;3.3V Pro Mini&lt;/a&gt; with that you should be able to use the regulated 3.3V power on the Pro Mini to power the nRF24L01+. Be aware that the 3.3V Pro Mini only runs at 8MHz instead of 16MHz.&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="337" LastEditDate="2014-08-12T16:51:45.740" LastActivityDate="2014-08-12T16:51:45.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3755" PostTypeId="1" AcceptedAnswerId="3764" CreationDate="2014-08-12T16:14:36.887" Score="1" ViewCount="11046" Body="&lt;p&gt;When I use JSSC and call &lt;code&gt;serialPort.readLine(event.getEventValue())&lt;/code&gt; from &lt;code&gt;public void serialEvent(SerialPortEvent event)&lt;/code&gt; I've got fragments, not all string. What I must do to get all string from begin to &lt;code&gt;&quot;\r\n&quot;&lt;/code&gt;? What I must do to get all string from my start marker (like &lt;code&gt;&quot;[start]&quot;&lt;/code&gt;) to my stop marker (like &lt;code&gt;&quot;[stop]&quot;&lt;/code&gt;)? What to modify in this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private static class PortReader implements SerialPortEventListener {&#xA;    public void serialEvent(SerialPortEvent event) {&#xA;        if(event.isRXCHAR() &amp;amp;&amp;amp; event.getEventValue() &amp;gt; 0){&#xA;            try {&#xA;                String data = serialPort.readString(event.getEventValue());&#xA;                serialPort.writeByte((byte) 1);&#xA;            }&#xA;            catch (SerialPortException ex) {&#xA;                System.out.println(ex);&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3510" LastEditorUserId="37" LastEditDate="2014-08-12T17:19:31.590" LastActivityDate="2014-09-13T23:06:52.827" Title="How to use readLine from JSSC" Tags="|serial|programming|" AnswerCount="1" CommentCount="4" ClosedDate="2014-08-13T17:21:17.127" ContentLicense="CC BY-SA 3.0" />
  <row Id="3756" PostTypeId="2" ParentId="3638" CreationDate="2014-08-12T16:56:13.857" Score="4" Body="&lt;p&gt;I researched this once when I was getting consistent, exactly 85 degC readings from my sensors. The &lt;a href=&quot;https://duckduckgo.com/l/?kh=-1&amp;amp;uddg=http%3A%2F%2Fdatasheets.maximintegrated.com%2Fen%2Fds%2FDS18B20.pdf&quot; rel=&quot;nofollow&quot;&gt;Maxim DS18b20 data sheet&lt;/a&gt; (rev 042208, page 4, in a footnote to Table 1) says: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The power-on reset value of the temperature register is +85°C.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Double check that the Arduino code is follows the sensor communication protocol correctly.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-08-12T16:56:13.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3757" PostTypeId="1" CreationDate="2014-08-12T16:41:57.177" Score="1" ViewCount="7225" Body="&lt;p&gt;I bought an Arduino-on-breadboard kit. I have several PCs with serial ports, and now I'm being told I need a USB-to-serial converter. I thought I was ready to start uploading sketches, so how can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to understand serial communications and am capable of wiring a &lt;a href=&quot;https://en.wikipedia.org/wiki/MAX232&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAX232&lt;/a&gt; chip into a &lt;a href=&quot;https://hackaday.io/project/43857/gallery#93070cbab9a55ed645fc2aa7dc3c54c3&quot; rel=&quot;nofollow noreferrer&quot;&gt;breaduino&lt;/a&gt; if necessary, but I'm not sure it will work, so to save some time I'm asking, mostly because I was unable to figure it out with Google searches alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I also have a stk500, but then I would be out of the easiness of using Arduino sketches and the programming language. I need the fastest route to prototyping/testing my sketches.&lt;/p&gt;&#xA;" OwnerUserId="3563" OwnerDisplayName="user51193" LastEditorUserId="510" LastEditDate="2018-03-11T14:59:33.200" LastActivityDate="2018-03-11T14:59:33.200" Title="Arduino serial port programming" Tags="|serial|programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3758" PostTypeId="2" ParentId="3757" CreationDate="2014-08-12T18:14:43.157" Score="0" Body="&lt;p&gt;If your PCs have real RS-232 serial ports (rare these days), you can use those directly.  Otherwise, you will need a USB&amp;lt;-&gt;RS-232 serial adaptor cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Correction:&lt;/strong&gt;  I thought my Arduino did have an RS-232 port, but I was thinking of another board.  If your board only has a TTL-level serial port (ie. direct from the ATMega328), then you need either an RS-232 level translator, or a USB&amp;lt;-&gt;TTL serial cable.  A suitable cable is available from Adafruit (and no doubt, others).&lt;/p&gt;&#xA;" OwnerUserId="1498" LastEditorUserId="1498" LastEditDate="2014-08-12T19:16:46.277" LastActivityDate="2014-08-12T19:16:46.277" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3760" PostTypeId="2" ParentId="3757" CreationDate="2014-08-12T18:48:10.660" Score="1" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6a9HT.jpg&quot; alt=&quot;enter image description here&quot;&gt;An RS232 port wired via a level converter (as you mentioned max232) and a 1uF capacitor between RTS and &quot;Arduino reset pin&quot; &lt;a href=&quot;http://tronixstuff.com/2010/06/14/getting-started-with-arduino-chapter-ten/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Getting started with Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The capacitor is to trigger a reset on the Arduino so the bootloader kicks in and awaits a &quot;Arduino sketch&quot; via the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your setup is AKA &quot;Arduino Bare bone&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1576" LastActivityDate="2014-08-12T18:48:10.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3761" PostTypeId="2" ParentId="3753" CreationDate="2014-08-12T21:01:19.713" Score="1" Body="&lt;p&gt;&lt;code&gt;Serial.read()&lt;/code&gt; reads only &lt;strong&gt;ONE&lt;/strong&gt; character from the serial port and returns its ASCII value, which explains the &lt;code&gt;48&lt;/code&gt; you got.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read a complete number, you have 2 options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use &lt;code&gt;Serial.parseInt()&lt;/code&gt; that reads as many characters as needed and performs the conversion before returning the read number as an &lt;code&gt;int&lt;/code&gt;. Please further check the &lt;a href=&quot;http://arduino.cc/en/Serial/ParseInt&quot; rel=&quot;nofollow&quot;&gt;reference&lt;/a&gt; here.&lt;/li&gt;&#xA;&lt;li&gt;You read eachn character in a loop (with &lt;code&gt;Serial.read()&lt;/code&gt;) until the last one, put each read charcater into a buffer (&lt;code&gt;char&lt;/code&gt; array) then convert the resulting string to a number with the standard C function &lt;code&gt;atoi&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of course, the first option is the easiest one but it will return &lt;code&gt;0&lt;/code&gt; if nothing is read after a 1s timeout (configurable with &lt;code&gt;Serial.setTimeout()&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-12T21:01:19.713" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3762" PostTypeId="2" ParentId="3753" CreationDate="2014-08-12T22:01:39.090" Score="6" Body="&lt;p&gt;Parsing on the Arduino can be slow and time-consuming (which is bad if you use clock prescaling or have time-critical tasks), so let's do it in Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that you're sending the numbers as ASCII whereas you need to be sending them as raw binary. This is where &lt;a href=&quot;https://docs.python.org/3/library/struct.html&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;struct&lt;/code&gt;&lt;/a&gt; comes in.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3&amp;gt;&amp;gt; import struct&#xA;3&amp;gt;&amp;gt; print(struct.pack('&amp;gt;B', 0))&#xA;b'\x00'&#xA;3&amp;gt;&amp;gt; print(struct.pack('&amp;gt;B', 255))&#xA;b'\xff'&#xA;3&amp;gt;&amp;gt; print(struct.pack('&amp;gt;2B', 255, 0))&#xA;b'\xff\x00'&#xA;3&amp;gt;&amp;gt; print(struct.pack('&amp;gt;H', 9000))&#xA;b'#('&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what you really want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data = arduino.write(struct.pack('&amp;gt;B', valueToWrite))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or something to that effect.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-12T22:01:39.090" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3763" PostTypeId="1" AcceptedAnswerId="3766" CreationDate="2014-08-12T21:12:31.553" Score="0" ViewCount="1132" Body="&lt;p&gt;I'm having an issue programming the Arduino Uno with Sparkfun's MAX3232 breakout board attached.  Sometimes the Arduino IDE won't see the Uno plugged in.  I'm thinking of  connecting a switch to the GND or the 3V - 5.5V pin so I don't have to disconnect the breakout board when programming.  Are there any better solutions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sparkfun link: &lt;a href=&quot;https://www.sparkfun.com/products/11189&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11189&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3554" OwnerDisplayName="user2218339" LastEditorUserId="4539" LastEditDate="2014-10-29T05:20:20.883" LastActivityDate="2014-10-29T05:20:20.883" Title="Issues programming Arduino Uno with Sparkfun's MAX3232 breakout board" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3764" PostTypeId="2" ParentId="3755" CreationDate="2014-08-12T23:32:48.000" Score="3" Body="&lt;p&gt;The event gets fired when a single character is received, not the whole string. You have to build the string up until you get to &lt;code&gt;\r\n&lt;/code&gt; and then process it. This is my code for a similar project. It uses a protocol where &lt;code&gt;&amp;gt;&lt;/code&gt; signifies the start of a message and &lt;code&gt;\r&lt;/code&gt; signifies the end. &lt;code&gt;processMessage&lt;/code&gt; is a function to process the entire message and update GUI elements etc. It is invoked using &lt;code&gt;runLater&lt;/code&gt; because the serialEvent function will be on a different thread to the GUI thread.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;StringBuilder message = new StringBuilder();&#xA;Boolean receivingMessage = false;&#xA;public void serialEvent(SerialPortEvent event) {&#xA;    if(event.isRXCHAR() &amp;amp;&amp;amp; event.getEventValue() &amp;gt; 0){&#xA;        try {&#xA;            byte buffer[] = serialPort.readBytes();&#xA;            for (byte b: buffer) {&#xA;                if (b == '&amp;gt;') {&#xA;                    receivingMessage = true;&#xA;                    message.setLength(0);&#xA;                }&#xA;                else if (receivingMessage == true) {&#xA;                    if (b == '\r') {&#xA;                        receivingMessage = false;&#xA;                        String toProcess = message.toString();&#xA;                        Platform.runLater(new Runnable() {&#xA;                            @Override public void run() {&#xA;                                processMessage(toProcess);&#xA;                           }&#xA;                        });&#xA;                    }&#xA;                    else {&#xA;                        message.append((char)b);&#xA;                    }&#xA;                }&#xA;            }                &#xA;        }&#xA;        catch (SerialPortException ex) {&#xA;            System.out.println(ex);&#xA;            System.out.println(&quot;serialEvent&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A simpler version for you might be the following. &lt;code&gt;processMessage&lt;/code&gt; is called whenever a &lt;code&gt;\r&lt;/code&gt; or &lt;code&gt;\n&lt;/code&gt; is received and there are some bytes in the message.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;StringBuilder message = new StringBuilder();&#xA;public void serialEvent(SerialPortEvent event) {&#xA;    if(event.isRXCHAR() &amp;amp;&amp;amp; event.getEventValue() &amp;gt; 0){&#xA;        try {&#xA;            byte buffer[] = serialPort.readBytes();&#xA;            for (byte b: buffer) {&#xA;                    if ( (b == '\r' || b == '\n') &amp;amp;&amp;amp; message.length() &amp;gt; 0) {&#xA;                        String toProcess = message.toString();&#xA;                        Platform.runLater(new Runnable() {&#xA;                            @Override public void run() {&#xA;                                processMessage(toProcess);&#xA;                           }&#xA;                        });&#xA;                        message.setLength(0);&#xA;                    }&#xA;                    else {&#xA;                        message.append((char)b);&#xA;                    }&#xA;            }                &#xA;        }&#xA;        catch (SerialPortException ex) {&#xA;            System.out.println(ex);&#xA;            System.out.println(&quot;serialEvent&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things fixed:  1. Using &lt;code&gt;StringBuilder&lt;/code&gt; instead of &lt;code&gt;String&lt;/code&gt; to save making a lot objects every time the message is incremented. 2. Make a copy of the message string before passing to &lt;code&gt;runLater&lt;/code&gt; otherwise when it does run it will use the up to date version of the string, which could have new characters, and thus cause problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edt 2:&lt;/strong&gt;&#xA;On Windows I found it needed &lt;code&gt;if(event.isRXCHAR() &amp;amp;&amp;amp; event.getEventValue() &amp;gt; 0)&lt;/code&gt; as the event would sometimes be fired with 0 bytes causing a null point exception in &lt;code&gt;for (byte b: buffer)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-09-13T23:06:52.827" LastActivityDate="2014-09-13T23:06:52.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3765" PostTypeId="2" ParentId="3747" CreationDate="2014-08-12T23:50:41.333" Score="5" Body="&lt;p&gt;The earth's magnetic field is not parallel with the ground. In some locations it can be pointing more down than across. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOAA has a &lt;a href=&quot;http://www.ngdc.noaa.gov/geomag-web/#igrfwmm&quot; rel=&quot;nofollow noreferrer&quot;&gt;magnetic field calculator&lt;/a&gt; where you can enter you latitude and longitude. For example, I am located at approx  19deg S 147degE and the field is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;North Comp    East Comp    Vertical Comp    Total magnitude&#xA;32,434.4 nT   4,280.6 nT   -36,035.1 nT     48,670.7 nT &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the downwards strength is more than the other two combined for my location. I'm guessing the calculator will also show a very strong down component for your location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some other things to be aware of are that the LSM303DLHC magnetometer can have quite large offsets, up to the equivalent of 2 earth magnetic fields, and therefore requires calibration. Also hard and soft iron distortions can affect the readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Please see my answer &lt;a href=&quot;https://electronics.stackexchange.com/questions/22144/magnetometer-%E2%88%9E-shaped-calibration/22271#22271&quot;&gt;here&lt;/a&gt; for methods to calibrate the sensor.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-08-13T01:15:40.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3766" PostTypeId="2" ParentId="3763" CreationDate="2014-08-13T00:15:15.093" Score="1" Body="&lt;p&gt;Switching the power off to the MAX3232 appears to be okay.&lt;br&gt;&#xA;There are no components connected to the Rx and Tx lines on the breakout board to complicate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the break out does not give access to pin 1, EN which is &quot;Enable Control&quot;, or pin 18 SHDN &quot;Shutdown Control&quot;. AFAICT they could have been used to turn off the receiver and transmitters of the MAX3232. That would have been ideal. Maybe contact Sparkfun and suggest the improvement to put them on pads for folks to use, and offer to beta test it :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the MAX3232 says that it is able to withstand a continuous short on the Tx line, so it sounds pretty tolerant to minor abuse. Also, the diagrams dont show any pull-ups on the MOS/TTL Tx line. So I would expect it t be okay if you shut the power off, but continued to wiggle the Tx Rx pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to disconnect the Tx pin from the Arduino, so that the MAX3232 wouldn't interfere with the host PC's USB comms. It sounds like the thing on the RS232 connection will ignore data it receive while the Arduino is being programmed. If that is not true, then it would need to be disconnected too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, switching off power looks like a reasonable approach.&#xA;Disconnecting Tx and Rx also looks reasonable, and slightly better than powering the MAX3232 off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know how you want to do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: The MAX232 datasheet shows that part should not be driven by a high when the chip is unpowered. However the MAX3232 datasheet does not carry that warning. My preference would be to use the MAX3232 signals 'EN' and 'SHDN'. However those are not available on the breakout. I'd recommend having the part powered, and disconnecting Tx and Rx from the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2014-08-13T18:57:17.417" LastActivityDate="2014-08-13T18:57:17.417" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3767" PostTypeId="1" AcceptedAnswerId="3768" CreationDate="2014-08-13T03:39:13.373" Score="1" ViewCount="1940" Body="&lt;p&gt;I'm driving a large stepper motor via a GeckoBoard G213V and arduino UNO and I have that mostly working fine. However, I'd like to 'release' the stepper so it can swing freely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's two reasons I want to do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) (Most important) I want the rotated object to naturally swing back to the 0 position thanks to gravity.&#xA;2) The motor gets hot - I'd rather not juice it when it should just be sat at 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody know how I can do this? I'm using the AccelStepper library so a solution compatible with that would be ideal.&lt;/p&gt;&#xA;" OwnerUserId="3555" LastActivityDate="2014-08-13T03:57:13.113" Title="Release power to stepper motor" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3768" PostTypeId="2" ParentId="3767" CreationDate="2014-08-13T03:57:13.113" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;http://www.geckodrive.com/g213v-rev-7&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;TERMINAL 7 Disable&lt;/strong&gt;&lt;br&gt;&#xA;  This terminal will force the winding currents to zero when tied to the step and direction controller +5V.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The DISABLE input on the G213V is optically isolated and requires logic “1” to DISABLE and logic “0” to ENABLE the drive. Once it is disabled, the motor windings are unergenized[sic] and &lt;strong&gt;&lt;em&gt;the motor freewheels.&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;(emphasis mine)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, feed the disable input a high.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-13T03:57:13.113" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3769" PostTypeId="2" ParentId="3733" CreationDate="2014-08-13T04:36:58.203" Score="1" Body="&lt;p&gt;I have completed the edX course, and the TM4C123 is significantly different to the Arduino from a programming perspective. Each family of microcontrollers have (on the surface) a fair amount in common - GPIO pins, an ADC or two, timers etc. However the way these work internally are very different - different registers, different process for using them, different gotchas to look out for, etc. If you're looking at tackling a new MCU family, be prepared to effectively learn a new &quot;language&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, the Launchpads from Texas Instruments have a processing-based language similar to the Arduino - called Energia - which should work on your TM4C123. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enjoy the course, I did. &lt;/p&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-08-13T04:36:58.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3770" PostTypeId="1" CreationDate="2014-08-13T09:16:06.960" Score="6" ViewCount="5415" Body="&lt;p&gt;I need to create a millisecond capable visual clock - I will use the clock for visual frame synchronization of multiple cameras. I found &lt;a href=&quot;http://embedded-lab.com/blog/?p=8559&quot; rel=&quot;nofollow&quot;&gt;this project&lt;/a&gt; but it seems to use a LED display that only has resolution of one 1/100th of a second. Not sure if the digits can be shifted to show milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess I need to use LED instead of LCD display because of the ms refresh rate? Can someone help with my project please? I am a SW programmer and have zero experience in HW programming. So I am new to Arduino too - I have not done any project at all yet. I do own neither Arduino nor LED display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3514" LastEditorUserId="3514" LastEditDate="2014-09-07T10:04:28.403" LastActivityDate="2017-02-16T17:22:42.183" Title="Visual clock with millisecond display refresh rate" Tags="|led|timers|millis|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3771" PostTypeId="1" AcceptedAnswerId="3783" CreationDate="2014-08-13T18:47:33.097" Score="1" ViewCount="1944" Body="&lt;p&gt;The pinhole camera is a &lt;a href=&quot;http://www.monoprice.com/Product?c_id=110&amp;amp;cp_id=11018&amp;amp;cs_id=1101801&amp;amp;p_id=9285&amp;amp;seq=1&amp;amp;format=2&quot; rel=&quot;nofollow&quot;&gt;420TVL, 3.7mm Passive Infrared Detector Color Covert Security Camera&lt;/a&gt;. Can I use this camera with an arduino creation? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I don't know to answer the question:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Does the power need something special arduino can't offer?&lt;/li&gt;&#xA;&lt;li&gt;Is the arduino powerful enough to push the video feed/photos to a computer or any other method to video/photos. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here are some specs from the site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Sensor   1/3&quot; Sony Super HAD II CCD&lt;/li&gt;&#xA;  &lt;li&gt;Picture Elements  NTSC 768x494&lt;/li&gt;&#xA;  &lt;li&gt;PAL 752x582&lt;/li&gt;&#xA;  &lt;li&gt;Horizontal Resolution 420 TVL&lt;/li&gt;&#xA;  &lt;li&gt;Minimum Illumination  0.001 Lux&lt;/li&gt;&#xA;  &lt;li&gt;S/N Ratio more than 50dB&lt;/li&gt;&#xA;  &lt;li&gt;Scanning System   2:1 interlace&lt;/li&gt;&#xA;  &lt;li&gt;Synchronous System    Internal, Negative sync&lt;/li&gt;&#xA;  &lt;li&gt;Auto Electronic Shutter   NTSC 1/60s ~ 1/100,000s&lt;/li&gt;&#xA;  &lt;li&gt;PAL 1/50s ~ 1/100,000s&lt;/li&gt;&#xA;  &lt;li&gt;Gamma Characteristics 0.45&lt;/li&gt;&#xA;  &lt;li&gt;Video Output  1 Vpp, 75 ohms&lt;/li&gt;&#xA;  &lt;li&gt;Auto Gain Control Auto&lt;/li&gt;&#xA;  &lt;li&gt;Power / Current   DC 12V (±10%) / 150mA&lt;/li&gt;&#xA;  &lt;li&gt;Lens  3.7mm Taper Pinhole Lens&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is it possible? They're on sale but I don't want to throw money away and find out that they don't work with any arduino. Also, I don't have any setup for this to be plugged into. Therefore, I'm not tied down to previous creations the cameras need to fit in.&lt;/p&gt;&#xA;" OwnerUserId="3558" LastActivityDate="2014-08-14T15:29:32.423" Title="Can I use this pinhole camera with arduino?" Tags="|power|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3772" PostTypeId="1" AcceptedAnswerId="3773" CreationDate="2014-08-13T20:16:19.923" Score="15" ViewCount="19902" Body="&lt;p&gt;The uno has digital pins marked 0-13. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;0 is marked as rx and 1 is marked as tx. &#xA;Can these two pins be used as regular digital pins if i am short of digital pins?&lt;/p&gt;&#xA;" OwnerUserId="3336" LastActivityDate="2018-05-14T01:28:57.757" Title="Can tx and rx pins on the uno be used like regular digital pins?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3773" PostTypeId="2" ParentId="3772" CreationDate="2014-08-13T20:20:59.530" Score="11" Body="&lt;p&gt;Yes you can perfectly use these 2 pins as long as your program does not use &lt;code&gt;Serial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Serial data over USB goes through copper traces connected to the rx and tx pins, connecting them to the USB to serial converter chip.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-08-13T20:43:47.370" LastActivityDate="2014-08-13T20:43:47.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3774" PostTypeId="1" AcceptedAnswerId="3778" CreationDate="2014-08-13T20:23:08.100" Score="19" ViewCount="187255" Body="&lt;p&gt;I'd like to make three arrays of the same length. According to the &lt;a href=&quot;http://arduino.cc/en/Reference/array&quot;&gt;documentation&lt;/a&gt;, Arrays must be defined as &lt;code&gt;int myArray[10];&lt;/code&gt; where 10 can be substituted for a known length (another integer), or filled with an array &lt;code&gt;{2, 3, 5, 6, 7}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I attempted to declare a value &lt;code&gt;int arrSize = 10;&lt;/code&gt; and then an array based on that size &lt;code&gt;int myArray[arrSize];&lt;/code&gt;, I get the following: &lt;code&gt;error: array bound is not an integer constant&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to variably determine array sizes, or do I just need to hardcode them? (I was taught hardcoding is bad and something to avoid at all costs.)&lt;/p&gt;&#xA;" OwnerUserId="3559" LastActivityDate="2021-06-15T13:10:00.500" Title="How can I declare an array of variable size (Globally)" Tags="|programming|variables|code-optimization|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3775" PostTypeId="2" ParentId="3770" CreationDate="2014-08-13T20:26:16.733" Score="1" Body="&lt;p&gt;Assuming you camera's shutter is fast enough to capture a display updating every millisecond:&lt;br&gt;&#xA;Get individual digit seven segment (LED) displays. The ones with multiple digits together are usually multiplexed and that might not work for your application(the multiplexing frequency would have to be higher than 1000 Hz or only one/some digits would be visible at a time). Using single digit displays, hook up each digit to a shift register such as the 74HC595. Then you only need two Arduino pins to control each digit (Data and clock, latch clock can be shared by all the shift registers). Use protection resistors for each individual segment diode and mind the current limit of the shift register when lighting all segments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 16 MHz you have 16000 instructions per ms so that shouldn't be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know too much about LCD displays, but with LED's and a latching shift register transitions should be update pretty much instantaneous(from a millisecond perspective).&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2014-08-16T06:29:37.573" LastActivityDate="2014-08-16T06:29:37.573" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3777" PostTypeId="2" ParentId="3774" CreationDate="2014-08-13T20:37:52.520" Score="0" Body="&lt;p&gt;The size of the array must be known at compile time. Otherwise you should allocate memory dynamically using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *chararray = malloc(sizeof(char)*x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where x(an integer) can be set in the application code (you could load it from eeprom if you wanted it be a persistent but configurable setting).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However if you just want to declare some arrays of the same size, you just have to declare the number a constant like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int arrsize = 10;&#xA;char array1[arrsize];&#xA;int array2[arrsize];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think not hardcoding things only makes sense if you would reasonably expect the user to want to change the setting at some point. I don't know if that's the case.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-08-13T20:37:52.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3778" PostTypeId="2" ParentId="3774" CreationDate="2014-08-13T20:40:32.717" Score="29" Body="&lt;p&gt;Your question has 2 parts actually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1/ How can I declare the constant size of an array outside the array?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either use a macro&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ARRAY_SIZE 10&#xA;...&#xA;int myArray[ARRAY_SIZE];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or use a constant&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ARRAY_SIZE = 10;&#xA;...&#xA;int myArray[ARRAY_SIZE];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you initialized the array and you need to know its size then you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myArray[] = {1, 2, 3, 4, 5};&#xA;const int ARRAY_SIZE = sizeof(myArray) / sizeof(int);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the second &lt;code&gt;sizeof&lt;/code&gt; is on the type of each element of your array, here &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2/ How can I have an array which size is dynamic (i.e. not known until runtime)?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that you will need dynamic allocation, which works on Arduino, but is generally not advised as this can cause the &quot;heap&quot; to become fragmented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do (C way):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Declaration&#xA;int* myArray = 0;&#xA;int myArraySize = 0;&#xA;&#xA;// Allocation (let's suppose size contains some value discovered at runtime,&#xA;// e.g. obtained from some external source)&#xA;if (myArray != 0) {&#xA;    myArray = (int*) realloc(myArray, size * sizeof(int));&#xA;} else {&#xA;    myArray = (int*) malloc(size * sizeof(int));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or (C++ way):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Declaration&#xA;int* myArray = 0;&#xA;int myArraySize = 0;&#xA;&#xA;// Allocation (let's suppose size contains some value discovered at runtime,&#xA;// e.g. obtained from some external source or through other program logic)&#xA;if (myArray != 0) {&#xA;    delete [] myArray;&#xA;}&#xA;myArray = new int [size];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more about problems with heap fragmentation, you can refer to &lt;a href=&quot;https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-05-20T16:13:12.843" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3779" PostTypeId="1" CreationDate="2014-08-13T21:30:36.517" Score="1" ViewCount="4194" Body="&lt;p&gt;I try to connect arduino with motor using DRV-8835. The problem I have - simply nothing happens. I used tutorial from &lt;a href=&quot;http://www.instructables.com/id/The-SnapMobile-Start-Your-Physical-Computing-Engin/step6/Building-the-Prototype-Wiring-Up-the-Arduino-the-D/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/The-SnapMobile-Start-Your-Physical-Computing-Engin/step6/Building-the-Prototype-Wiring-Up-the-Arduino-the-D/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code for arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    pinMode(7, OUTPUT);&#xA;    pinMode(5, OUTPUT);&#xA;    pinMode(8, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(8, HIGH);&#xA;  digitalWrite(7, HIGH);&#xA;  analogWrite(5, 255);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe someone has scheme how to connect wires to motor. Now I'm not sure if I made a mistake or motor driver is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pjvbm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3560" LastEditorUserId="3560" LastEditDate="2014-08-14T17:32:16.063" LastActivityDate="2017-09-19T20:32:08.090" Title="How to connect DRV-8835 to arduino" Tags="|arduino-uno|motor|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3781" PostTypeId="1" AcceptedAnswerId="3805" CreationDate="2014-08-14T02:52:40.590" Score="14" ViewCount="71643" Body="&lt;p&gt;I'm using an Arduino UNO to program a pre-compiled hex image to an ATTINY45, using the avrdude in the Arduino IDE directory, on Windows 7. The Uno has the ISP sketch loaded from the examples directory and that works- the heartbeat LED pulses nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the hardware side I have &lt;a href=&quot;http://highlowtech.org/?p=1706&quot;&gt;this setup&lt;/a&gt;, except the ATTINY is surface-mount, soldered to a surfboard with all its pins verified-soldered with a voltmeter. I use a header-pin strip, held by hand to get the pins touching the surfboard, to get the signals from the Uno to the ATTINY.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the command lines, which I took from looking at the IDE's debugging output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REM set the fuse for 8MHz, so the ISP programmer can work&#xA;C:\Progra~1\Arduino\hardware\tools\avr\bin\avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -e -Uefuse:w:0xff:m -Uhfuse:w:0xdf:m -Ulfuse:w:0xe2:m &#xA;REM load the program&#xA;C:\Progra~1\Arduino\hardware\tools\avr\bin\avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -Uflash:w:firefly.hex:i&#xA;REM set fuse for 1MHz, as the project requires&#xA;C:\Progra~1\Arduino\hardware/tools/avr/bin/avrdude -CC:\Progra~1\Arduino\hardware/tools/avr/etc/avrdude.conf -v -pattiny45 -cstk500v1 -P\\.\COM7 -b19200 -e -Uefuse:w:0xff:m -Uhfuse:w:0xdf:m -Ulfuse:w:0x62:m &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-I try running those separately, but always get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;     Double check connections and try again, or use -F to override&#xA;     this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but sometimes the number is ff0000 or ffff00 or ffffff&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that &quot;Arduino uses a slightly modified version of avrdude to upload sketches to the Arduino board. The standard version queries for the board's device signature in a way not understood by the bootloader, resulting in this error.&quot; Does this mean that using the Arduino avrdude with a new ATTINY chip, no bootloader on it, would also cause that same error? In other words, is the modified avrdude incapable of querying a non-Arduino-bootloaded AVR chip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or does that error simply mean I don't have a good contact between all my programmer pins and the ATTINY?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, are the fuse settings truly needed, can the Uno program the flash into an attiny running at 1MHz and thus save me some steps?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I would just buy a &quot;real&quot; programmer, but need to get this code in the next two days, and am in a rural part of Nova Scotia)&lt;/p&gt;&#xA;" OwnerUserId="3561" LastActivityDate="2019-05-08T22:32:33.057" Title="When using Arduino Uno as ISP does &quot;Yikes! Invalid device signature&quot; mean a bad connection, bad config, or bad version of avrdude?" Tags="|attiny|avrdude|isp|arduinoisp|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3783" PostTypeId="2" ParentId="3771" CreationDate="2014-08-14T15:29:32.423" Score="3" Body="&lt;p&gt;No, you cannot use this with an Arduino without additional hardware in between, and even with it, not as more than a still camera (or maybe low quality video for one of the ARM- rather than ATmega-based boards).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first problem is that this camera has a high speed analog output called composite video.  It is basically what would be fed into a modulator to produce an old-style analog TV signal.  Capturing this digitally requires an Analog to Digital converter (ADC) capable of several million measurements per second, while that on the classic ATmega-based Arduino tops out at around ten thousand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But let's say you had an additional Analog-to-digital converter to put in between this and your arduino.  The next problem is that the data rate out of the camera will be too high, and the Arduino won't have enough RAM memory to buffer it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, you could get a &quot;frame grabber&quot; consisting of an ADC and its own buffer memory, which would take a still snapshot of the video and allow the arduino to read it out more slowly.  But you can buy cameras which already do that with their onboard electronics, and allowing something like an Arduino to read the still image data out over a moderate speed serial interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even the ARM-based arduino boards would be taxed to keep up with the output of a video ADC and do much of anything useful with the results - typical digital cameras do not record raw images to SD card, but do JPEG compression within a frame.  When cheap digital cameras operate in video mode, they compress each frame of the video before storing it (just as with stills - they do not compress between frames in the manner of real video recorders), and are able to get that processing done in time because the actual computing hardware is optimized for it in a way that none of the Arduinos are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to experiment with a camera on a development platform, there is one with a high speed digital interface sold as an add-on for the Raspberry Pi board.  Or you can use a more inexpensive USB webcam with that.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-08-14T15:29:32.423" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3784" PostTypeId="1" AcceptedAnswerId="3801" CreationDate="2014-08-14T16:15:13.783" Score="1" ViewCount="2852" Body="&lt;p&gt;I'm trying to upload a hex file from Java/Processing but running into some issues.&#xA;Here is my code so far, based on the Arduino IDE's upload verbose output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;    //C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM96 -b115200 -D -Uflash:w:C:\Users\HM\AppData\Local\Temp\build5909267154049588263.tmp/sketch_aug13a.cpp.hex:i&#xA;    String ArduinoPath = &quot;C:\\Program Files (x86)\\Arduino&quot;;&#xA;    String hexPath = &quot;C:\\Users\\HM\\AppData\\Local\\Temp\\build1023547366107161384.tmp/sketch_aug13a.cpp.hex&quot;;&#xA;    String port = &quot;COM96&quot;;&#xA;    runCommand(new String[]{ArduinoPath+&quot;/hardware/tools/avr/bin/avrdude&quot;, &quot;-C&quot;+ArduinoPath+&quot;/hardware/tools/avr/etc/avrdude.conf&quot;,&quot;-v&quot;,&quot;-v&quot;,&quot;-v&quot;,&quot;-v&quot;,&quot;-patmega328p&quot;,&quot;-carduino&quot;,&quot;-P&quot;+port,&quot;-b115200&quot;,&quot;-D&quot;,&quot;-Uflash:w:&quot;+hexPath+&quot;:i&quot;});&#xA;  }&#xA;  void runCommand(String[] cmd){&#xA;&#xA;    String s = null;&#xA;&#xA;    try {&#xA;&#xA;      Process p = Runtime.getRuntime().exec(cmd);&#xA;      BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));&#xA;      BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));&#xA;&#xA;      // read the output from the command&#xA;      System.out.println(&quot;command out:\n&quot;);&#xA;      while ( (s = stdInput.readLine ()) != null) System.out.println(s);&#xA;      System.out.println(&quot;errors (if any):\n&quot;);&#xA;      while ( (s = stdError.readLine ()) != null) System.out.println(s);&#xA;&#xA;    }catch (IOException e) {&#xA;      System.out.println(&quot;something went wrong: \n&quot;);&#xA;      e.printStackTrace();&#xA;    }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I run this from command line it uploads without any issues, but from the code above I always get this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardw&#xA;are\tools\avr\etc\avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM96&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: ser_open(): can't open device &quot;\\.\COM96&quot;: Access is denied.&#xA;&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3505" LastEditorUserId="3505" LastEditDate="2014-08-14T16:54:21.607" LastActivityDate="2014-08-15T17:05:38.290" Title="How to upload an arduino sketch from java / processing?" Tags="|arduino-uno|avrdude|terminal|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3787" PostTypeId="1" CreationDate="2014-08-14T19:29:36.100" Score="0" ViewCount="9411" Body="&lt;p&gt;I attached two images of the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0iL7l.jpg&quot; alt=&quot;TFT Front image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/csK7R.jpg&quot; alt=&quot;TFT Back Image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought an Arduino Mega 2560 R3 with a TFT 3.5 Display shield in China.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I know from my research is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There are no data sheets available in the Internet.&lt;/li&gt;&#xA;&lt;li&gt;The factory's web site, in China, is in Chinese, and there is no information in English.  &lt;/li&gt;&#xA;&lt;li&gt;I achieved to know the factory is www.mcufriend.com, because it is the only reference in the shield.  &lt;/li&gt;&#xA;&lt;li&gt;Apparently the drive to use is R61581.&lt;/li&gt;&#xA;&lt;li&gt;Using suggested libraries from Henning Karlsen (&lt;a href=&quot;http://www.henningkarlsen.com/electronics/library.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.henningkarlsen.com/electronics/library.php&lt;/a&gt;)&#xA;(UTFT, UTFT Geometry, tiny Fat, UTFT Tiny Fat, UTouch and UTFT buttons) . These libraries don't work with this shield.  &lt;/li&gt;&#xA;&lt;li&gt;Some people say that this shield requires 3.3 [Volts] to work, but the Vcc pin connected goes to 5V and it contains a Voltage regulator. I suppose it drops the voltage from 5[V] to 3.3[V] in the middle of the back side of the screen shield (see the upper photo - U1).  &lt;/li&gt;&#xA;&lt;li&gt;The specs that I found, say that this is a 262,144 Color 320x480 Dot Graphic LCD screen using a LCD driver a Si TFT Panel.  &lt;/li&gt;&#xA;&lt;li&gt;This screen includes a touch pad and a Micro SD memory reader.&lt;/li&gt;&#xA;&lt;li&gt;After using the geometry test included in the library folder UTF Geometry mentioned on #5, and using all the drivers found in the documentation included by Henning Karlsen in a .pdf doc, I couldn't get this shield to work. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to make this screen work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know is too much technology involved to be a fake shield, but it should be very useful to have this working. Do you agree with me?&lt;/p&gt;&#xA;" OwnerUserId="3556" LastEditorUserId="6936" LastEditDate="2016-02-21T11:21:16.960" LastActivityDate="2016-02-21T11:21:16.960" Title="Arduino Mega 2560 - TFT 3.5 Display is not working with libraries suggested" Tags="|arduino-mega|" AnswerCount="1" CommentCount="3" ClosedDate="2014-10-12T22:37:30.587" ContentLicense="CC BY-SA 3.0" />
  <row Id="3788" PostTypeId="2" ParentId="1728" CreationDate="2014-08-14T19:37:49.220" Score="3" Body="&lt;p&gt;Connect a microcontroller to a telephone line is a rather technical task and requires knowledge concerning the operation of the line, but it is not an impossible task, although it can be dangerous, and sample some nasty shocks if you're not prepared for such work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially you should build a rectifier circuit, mainly for its polarizing power circuit, since you do not know which is the antibody positive your telephone line but know that tensions are measured inversely ie, when measured with respect to ground (GND) the measures will be negative, this is because it was discovered that the poles of the batteries used to be gnawed less well when connected to the system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second step is you develop a small coupler to avoid connecting your circuit directly to the telephone line. For this you can use a pair of low-pass filters, which are placed at each connection point of the line after the bridge rectifier, and the downside of the bridge rectifier is connected to ground your circuit with this filter. And the plus point is connected to a PWM output of your controller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other important information you can not connect the PWM port directly to this filter, because the voltage levels in the telephone line are quite different, namely: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When the line rings you get a voltage exceeding 60V oscillating above 20Hz. &lt;/li&gt;&#xA;&lt;li&gt;When the line is in standby mode it remains between 30V and 48V as your carrier and region. &lt;/li&gt;&#xA;&lt;li&gt;When the line is busy or because your circuit or another extension you will have a voltage between 6V and 12V. &lt;/li&gt;&#xA;&lt;li&gt;Already the audio modulation in their line occurs with peak 0,7Volts equivalent to 3dBm therefore its PWM output should give output like this. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To match the level of your line voltage with the telephonic system you can use a voltage divider which has an output of 0 to 0,7Volts ie when the door PWM pulse maximum output voltage of 5V should be 0,7Volts the divisor resistive. Another way is to use an operational amplifier having a gain reverse, thus reducing output. you can also use a optoacoplado circuit with 4n25 and thus polarize the phototransistor for such variation with the pulses in your diode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important component in this circuit is a pair of diodes to be done clipping the signal, ie, as our voltage limit for audio is 0,7Volts after the filters put a couple of diodes between the positive and negative of your signal filtered in the bridge rectifier, so prevent signals above this level reaches the arduino when ouver noise on the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More Information: &lt;a href=&quot;http://carlosdelfino.eti.br/WorkshopTelefoniaAutomacao/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://carlosdelfino.eti.br/WorkshopTelefoniaAutomacao/&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/OpL1s.png&quot; alt=&quot;A General Schema About This&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3570" LastActivityDate="2014-08-14T19:37:49.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3789" PostTypeId="1" CreationDate="2014-08-14T20:04:02.400" Score="0" ViewCount="2490" Body="&lt;p&gt;I've set up a DC motor connected to my Arduino Uno with the following layout. I'm using a 1.5V - 3V DC motor that was purchased from RadioShack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int controlPin = 9;&#xA;&#xA;void setup(){&#xA;  pinMode(controlPin, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  while(!Serial);&#xA;  Serial.println(&quot;Ready&quot;); &#xA;}&#xA;&#xA;void loop(){&#xA;  if(Serial.available()){&#xA;    int s = Serial.parseInt();&#xA;    if(s &amp;gt;= 0 &amp;amp;&amp;amp; s &amp;lt;= 255){&#xA;      Serial.println(s);&#xA;      analogWrite(controlPin, s); &#xA;    }&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I connect the motor through the Arduino 5V pin it only hums until I set the speed &lt;code&gt;s&lt;/code&gt; to 200 or greater. This seems odd because I'm supplying 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a next step I decided to try a 9V battery (I don't really care if I fry the motor, I just wanted to experiment). Of course this is over the recommended voltage, but I assumed if I sent a low enough signal (&lt;code&gt;s&lt;/code&gt;) through pin 9 it might not destroy the motor. However, to my surprise, when I connected the 9V battery (as illustrated below) the motor immediately starts spinning. I measured the current and it seems to be ~150mA when connected to the 9V battery. It seems like the circuit is connected even though I'm not sending any signal from pin 9 to the transistor. If I removed any of the wires connected to ground, the motor, obviously, stops spinning. My expectation, which is apparently wrong, was that the motor wouldn't spin until I sent a signal from pin 9 to the transistor. What am I not grasping here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FUsj6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a picture as my diagram may be wrong based on comments below. This shows the diode reversed as suggested by Chris.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/l9RFU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also moved the jumper going from pin 9 to the breadboard out of the Vcc column and directly into the row with the resistor. I'm not sure if that resolves the short mentioned in comments.&lt;/p&gt;&#xA;" OwnerUserId="3577" LastEditorUserId="37" LastEditDate="2014-08-15T19:05:08.873" LastActivityDate="2014-08-16T01:35:44.390" Title="Why does my dc motor immediately spin when connected to a 9v battery?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3792" PostTypeId="1" AcceptedAnswerId="3794" CreationDate="2014-08-14T22:49:00.657" Score="0" ViewCount="168" Body="&lt;p&gt;I am attempting to do a simple example with the Rotary Angle Sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is my development environment:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.visualstudio.com/en-us/products/visual-studio-premium-with-msdn-vs.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Studio 2013 Premium&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.visualmicro.com/page/Arduino-Debug-In-Visual-Studio.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Debug Tool&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oyOS4.png&quot; alt=&quot;Visual Studio Solution and Projects&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Board setup (Simple as can be single analog input):&lt;/strong&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/dBgoO.jpg&quot; alt=&quot;Seeeduino V3 Setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ROTARYSENSOR = A0; &#xA;&#xA;void setup()&#xA;{&#xA;    Serial.println(&quot;Setup Start...&quot;);&#xA;    Serial.begin(9600); //Set the serial communication frequency at 9600 bits per second&#xA;&#xA;    pinMode(ROTARYSENSOR, INPUT);&#xA;&#xA;    Serial.println(&quot;Setup End!&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(&quot;Loop Start...&quot;);&#xA;&#xA;    int value = analogRead(ROTARYSENSOR);&#xA;    Serial.println(value); //display on serial monitor&#xA;    delay(1000); //wait 1000ms before printing next value&#xA;&#xA;    Serial.println(&quot;Loop End!&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a single solution with multiple projects as my sensor playground. All other projects I have so far work flawlessly no issues.  Although with this project (RotaryAngleSensor) I am getting a strange message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not seeing any of the Serial.println() messages. What is printed to the screen after a good 30 seconds is &lt;strong&gt;&lt;em&gt;S?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what could be returning this S? to the standard output?&lt;/p&gt;&#xA;" OwnerUserId="1172" LastEditorUserId="1172" LastEditDate="2014-08-15T03:10:05.633" LastActivityDate="2014-08-15T03:10:05.633" Title="Seeeduino V3.0 (Atmega 328P) and Rotary Angle Sensor Mystery Message" Tags="|sensors|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3793" PostTypeId="2" ParentId="421" CreationDate="2014-08-15T00:09:44.563" Score="1" Body="&lt;p&gt;This will command a Talon SR from an Arduino.  I used an Uno and had the Talon hooked up to a CIM motor &amp;amp; gearbox and it ran fine.  I don't understand the code well enough to know if it's generating the 1-2ms PWM signal you asked about and your control resolution will definitely be limited to roughly 1% of range - all I know is that it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, make sure your wiring is set up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Black PWM wire goes to GND&#xA;Red PWM wire goes to 5V (right next to GND on the Arduino)&#xA;White PWM wire goes to pin 3 (or some other Arduino PWM pin)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;  //This comes with the Arduino&#xA;&#xA;int talon_pin = 3;&#xA;&#xA;Servo talon;&#xA;&#xA;/* The 'Servo.h' library allows you to control motors and servos by passing any value between&#xA;0 and 180 into the &quot;write&quot; method (talon.write() in this program).&#xA;For a motor:   0 is full power in one direction,&#xA;             180 is full direction in the opposite direction,&#xA;              90 is stop.&#xA;For a servo:   0 is all the way one direction,&#xA;             180 is all the way in the opposite direction,&#xA;              90 is the middle.&#xA;*/&#xA;&#xA;int talon_max_forward = 180;  //this might not actually be forward&#xA;int talon_max_reverse = 00;    //this might not actually be reverse&#xA;int talon_stop = 90;          //this is definitely stop (if the Talon is calibrated right)&#xA;&#xA;void setup() {  &#xA;  talon.attach(talon_pin);  //This tells the arduino to control this pin like it's a servo/motor  &#xA;}&#xA;&#xA;void loop() {  &#xA;  talon.write(talon_max_forward);   //full power one way&#xA;  delay(2000);                      //wait 2 seconds&#xA;  talon.write(talon_stop);          //full power the other way&#xA;  delay(2000);                      //wait 2 seconds&#xA;  talon.write(talon_max_reverse);   //full power one way&#xA;  delay(2000);                      //wait 2 seconds&#xA;  talon.write(talon_stop);          //full power the other way&#xA;  delay(2000);                      //wait 2 seconds&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Talon I used was fresh out of the box and had never been calibrated before, so the &quot;stop&quot; didn't actually stop - it just moved slowly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calibrate it, use a paper clip or pen / pencil to press and release the CAL button on the Talon (next to the LED).  You have to press AND release when commanded to stop (after going full + and full - in between), but the motor doesn't turn when the button is pressed.  I calibrated by running the program above with the motor attached, waiting for the motor to &quot;stop&quot;, then pressing and holding for 8 seconds.  If you have trouble hitting it, increase one of the delays after a talon_stop command.&lt;/p&gt;&#xA;" OwnerUserId="3485" LastActivityDate="2014-08-15T00:09:44.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3794" PostTypeId="2" ParentId="3792" CreationDate="2014-08-15T01:05:45.477" Score="2" Body="&lt;p&gt;One problem is that you try to generate serial output &lt;strong&gt;before&lt;/strong&gt; you initiate Serial.  This could have odd results beyond just making that message fail.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Setup Start...&quot;);&#xA;Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;Serial.println(&quot;Setup Start...&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course your posted code never reads the sensor...&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-08-15T01:05:45.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3796" PostTypeId="1" CreationDate="2014-08-15T10:12:29.110" Score="2" ViewCount="1027" Body="&lt;p&gt;I want to make two or more boards to blink an LED at the same time (within 1 ms difference) The boards cannot be connected with wires to each other and will be located in different rooms. How can I do this? What components do I need?&lt;/p&gt;&#xA;" OwnerUserId="3382" LastEditorUserId="7904" LastEditDate="2015-03-16T00:23:00.873" LastActivityDate="2015-05-15T14:15:24.060" Title="Multiple boards blinking at same time" Tags="|led|time|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3797" PostTypeId="2" ParentId="3796" CreationDate="2014-08-15T10:51:27.977" Score="0" Body="&lt;p&gt;You could certainly do it with multiple Arduinos, each with a WiFi shield, but that would cost a lot of money.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I would suggest building a low power radio transmitter that sends simple morse code clicks, and then building amplifier boards that use the clicks to trigger LED blinks. You'd need to use a frequency that is open for low power use in your country, like the range for garage door openers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen circuits in old electronics kits for building morse code transmitters, but they might not meet current FCC regulations.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-15T10:51:27.977" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3798" PostTypeId="2" ParentId="3789" CreationDate="2014-08-15T13:56:05.133" Score="3" Body="&lt;p&gt;Your wiring diagram is a jumbled mess, and makes it impossible to figure out what's really going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that you have a mistake somewhere in your wiring. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems I see with your wiring diagram:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You show pin 9 from the Arduino wired to the positive rail of your breadboard. If the positive rail is connected to a 9V battery, this will likely destroy pin 9 of your Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You show the gate/base of your transistor wired to the positive rail of your breadboard. This would switch your transistor on constantly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You show the symbol for a MOSFET transistor, but the label on it lists it as a 222A, which is an NPN BJT, not a MOSFET.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You don't show any wires connecting the left and right side rails of your breadboard.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You're using a row of your breadboard as the ground rather than the rails. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The picture you posted is too small to tell if your wiring diagram is wrong or if you actually connected things incorrectly, and the wire from your 9V battery is blocking the camera's view of key connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like your wire from pin 9 is NOT connected to the power rail, but is instead connected to column 1 in your breadboard, which is good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some strong conventions in wiring with breadboards and you should learn to follow them. The two pairs of columns of sockets on the left and right are for positive and negative supply voltage. Usually you wire them together and connect them to regulated power. Sometimes they will be used for different voltages, although you need to be really careful if you do this, since connecting to the wrong side can fry components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's confusing the way you've created your wiring diagram, but it looks like you have your flyback protection diode wired correctly, which is good. That's very important, as DC motors and other inductors create destructive reverse voltages as they are switched on and off, and without a flyback diode it can destroy solid state devices like ICs or even transistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should re-wire your breadboard using the proper conventions, and post a corrected wiring diagram that really shows what's going on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A picture where we can see all the wires and components clearly would also help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until you better learn what you are doing I would strongly advise against powering things directly from a 9V battery. When you do that, a mistake in wiring will fry your Arduino and/or any ICs you have on your breadboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire the 9V to the V-in pin on your Arduino, and then bring 5V and ground from the Arduino onto the +/- supply rails of the breadboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also notice that in your code, you never set the state of controlPin in your setup method. You should add this line to your setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(controlPin, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way the pin starts out in the OFF state, and then later on you can us an analogWrite to set it to the desired output level.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-15T13:56:05.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3799" PostTypeId="2" ParentId="3779" CreationDate="2014-08-15T14:20:17.977" Score="1" Body="&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    pinMode(8, OUTPUT);//MODE&#xA;    pinMode(5, OUTPUT);//AENBL&#xA;    pinMode(7, OUTPUT);//APHASE&#xA;}&#xA;&#xA;void loop() {&#xA;  pinMode(7, HIGH);//APHASE&#xA;  pinMode(8, HIGH);//MODE&#xA;  pinMode(5, HIGH);//AENBL&#xA;  delay(200);&#xA;  pinMode(5, LOW);//AENBL&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.pololu.com/product/2135&quot; rel=&quot;nofollow&quot;&gt;Here is a description of the breakout board&lt;/a&gt;, this shows a requirement of PWM on AENBL for speed control. Try different  delays.&lt;/p&gt;&#xA;" OwnerUserId="3521" LastEditorUserId="3521" LastEditDate="2014-08-15T14:33:07.200" LastActivityDate="2014-08-15T14:33:07.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3800" PostTypeId="2" ParentId="3770" CreationDate="2014-08-15T14:34:13.103" Score="7" Body="&lt;p&gt;You need to define the parameters of the problem more clearly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, and most importantly, what is the shutterspeed you'll be using? If it's longer than 1 ms, then you can't use a 7-segment display to show the MS count, since the camera shutter would be open for multiple values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if your shutterspeed is a single MS, your shutter won't be synchronized with your timer, so sometimes the shutter will be open when the display switches. That can even happen with the seconds digit of your time display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using a video camera, assume the frame rate is 60 fps, which gives a likely shutterspeed somewhere around 16.6 ms. That's way too long to display ms time values using 7-segment displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ring of LED idea is good, but I would tweak it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I would do: Build an LED clock to display whole number seconds. Don't multiplex, use latches and drive each 7-segment display constantly. (There are off-the-shelf CMOS chips that are latching 7-segment drivers.) If you only care about the 1s digit of the second value, only use 1 7-segment display. That will make things easier to wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use 3 rings or columns of 10 LEDs for the MS display: tenths, hundredths, and thousandths. I would lean towards using columns since it would be visually easier to read. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display will show your seconds as numbers, and 3 columns of 10 LEDs, showing the sub-second time range in 10ths, 100ths, and 1000ths. If the shutter opening spans multiple MS, as it will very likely do, all the LEDs that represent the sub-second time will be lit in the image, so you will get a nice clean visual image of the time SPAN that the shutter was open (All the LEDs from the start to the end of the shutter opening will be lit.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could drive the 3 columns of LEDs using 3 4017 divide-by-10 counters. These chips have both a 1-of-10- output, which will drive an LED, and a count/10 output, which would feed the next stage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write Arduino code that generates a short positive pulse every MS. Feed that into the clock input of the 4017 driving the thousandths digit. Feed the out/10 output of that chip to the clock input of the hundredths 4017, and the output of the hundredths 4017 into the clock input of the tenths 4017. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can drive the whole ms display with 2 Arduino lines: The ms clock, and a reset line tied to all your 4017 counters' reset lines. To start timing, first pulse the reset line to zero them all out, then start your ms clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My CMOS cookbook doesn't say how much current the 4017 will put out to it's 1-of-10 outputs, but I bet it's enough to drive a display LED directly. You could wire all 10 LEDs in each column as common cathode, with a single current limiting resistor between each column's common cathode and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could probably set up a timer pin on the Arduino to generate a millisecond pulsed output, but that's not something I've learned how to do yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Occasionally you'll get a whole second 7-segment display with 2 different values captured in a frame, but that will be rare, and you will be able to figure out what happened from the frames immediately before and after it. (Previous frame shows a 5. Current frame shows a 5 and a 6 superimposed, so it's a mess. Conclusion, this frame shows the end of second 5 and the beginning of second 6.)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-08-15T14:42:16.873" LastActivityDate="2014-08-15T14:42:16.873" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="3801" PostTypeId="2" ParentId="3784" CreationDate="2014-08-15T17:05:38.290" Score="1" Body="&lt;p&gt;I'd first would try to find out the right command when running on command line (&lt;code&gt;cmd.exe&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you launch an external command from Java which generates output, you should/must read the output (&lt;code&gt;p.getInputStream()&lt;/code&gt;, &lt;code&gt;p.getErrorStream()&lt;/code&gt;) using separate threads. Otherwise your application might hang for no obvious reason.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2014-08-15T17:05:38.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3802" PostTypeId="2" ParentId="3789" CreationDate="2014-08-15T19:12:49.653" Score="2" Body="&lt;p&gt;You need to turn the transistor 180 degrees (assuming you are indeed p2n2222a).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WttJl.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Collector should go to the motor, Emitter should go to ground. In your photo you have those two swapped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't think the diode is the correct way around in that photo. That will just short out the battery, thought admittedly that would prevent the motor from spinning (-: &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-15T19:12:49.653" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3803" PostTypeId="1" CreationDate="2014-08-15T20:55:55.127" Score="2" ViewCount="439" Body="&lt;p&gt;I am making a fire fighting robot and I need a sensor. I want the sensor detection range to be about 6m or 7m (about 18ft to 20ft).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is which sensor should I choose to get that detection range? I've found that some small IR sensors are not suitable for my range required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm making a simulated one. It might be confused if there are non-fire distractions so I'm asking for a technique that can improve the sensor range and determination very very effective... or which sensor should I choose?? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want the IR sensor to be more directional. If I need it to be more directional I can use 2 or 3 or more. It is no problem. I want the IR sensors to improve their detection range. I can only get 2m now. I want it to be about 4m or 5m.&lt;/p&gt;&#xA;" OwnerUserId="3581" LastEditorUserId="3621" LastEditDate="2014-08-24T22:41:24.270" LastActivityDate="2014-08-24T22:41:24.270" Title="Flame Sensors Problems" Tags="|arduino-uno|sensors|hardware|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3805" PostTypeId="2" ParentId="3781" CreationDate="2014-08-16T00:58:58.670" Score="12" Body="&lt;p&gt;I soldered wires to pads to be sure the connection was good, and used those wires for programming from the Uno. Then the programmer worked, without any edits to the command lines as posted in the question. I ran a few variations and was able to answer all my questions, and a few more besides:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;Yikes! Invalid device signature&quot; error was being caused by poor contact between the programmer (Uno) and the ATTINY pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It had nothing to do with the bootloader not being on the new microcontroller. The new ATTINY45 chip doesn't need a bootloader for the in-circuit programmer to work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Uno can program the ATTINY45 configured to either of its speeds, 1MHz or 8MHz. The factory settings are fine, and don't require changing the fuses.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Both &lt;i&gt;avrdude&lt;/i&gt; versions worked for programming- the 6.1 from the author's site, and the modified one from the Arduino IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;i&gt;avrdude&lt;/i&gt; can program via the Uno using any of &lt;code&gt;-c avrisp&lt;/code&gt;, &lt;code&gt;-c arduino&lt;/code&gt;, or &lt;code&gt;-c stk500v1&lt;/code&gt;, it doesn't matter which.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One little question I wasn't able to answer, was what speed the Uno programs at (communication speed between the Arduino I/O pins &amp;amp; microcontroller being flashed). Is it related to the serial port speed? But it turned out to be not pertinent to answering this problem. Someone else can ask it if curious enough.&lt;/p&gt;&#xA;" OwnerUserId="3561" LastActivityDate="2014-08-16T00:58:58.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3808" PostTypeId="1" CreationDate="2014-08-16T08:28:57.150" Score="2" ViewCount="511" Body="&lt;p&gt;I have connected my GSM module to my Arduino. Using AT commands I am able to connect to internet.&#xA;  Using the following link of tutorials, I tried to connect to internet&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMExamplesXivelyClient&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/GSMExamplesXivelyClient&lt;/a&gt;&#xA;  In this the device is showing not connected. So I tried to debug it. In the attachGPRS &#xA;(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD = 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and GPRS_READY = 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening? What is GPRS_READY ?&lt;/p&gt;&#xA;" OwnerUserId="3588" LastActivityDate="2014-08-16T08:28:57.150" Title="SIM 900 + Arduino Mega attachGPRS problem, GPRS_READY" Tags="|arduino-mega|gsm|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3809" PostTypeId="2" ParentId="3770" CreationDate="2014-08-16T13:25:55.640" Score="3" Body="&lt;p&gt;I think Duncan C's 'user interface' is excellent. It is clean, simple and elegant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using individual LEDs is much better than digits. IMHO it is much more flexible, and avoids the ambiguity of digits.  +1 for the concept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would make it 'softer', and use a lot fewer components. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By going 'softer' you could have more flexibility, which would give you the ability to expand the useful resolution of the 'clock'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Duncan C made a very important point that digits are useless if a digit changes during the photograph. However, that is still a potential problem with the three lines of LEDs. When the exposure time is longer than the duration of the 'lower digit' line of LEDs, information is lost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Certainly Duncan C's design could be speeded up or slowed down to adjust for that, but it has a built in resolution limit because it counts in 10's. Imposing the digital idea of '10' on an analogue system (which is similar to a child's abacus) loses some of three inherent flexibility in the fundamental superiority (in this case) of an analogue display. I suggest making it 'soft' so that the system can be 'tweaked' in software after the electronics are completed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of fixed function decade counters, use shift registers . Then there is complete flexibility to change the 'user interface' in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reduce the number of components use shift registers &lt;em&gt;designed to drive LEDs&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, Texas instruments make many LED-drivers. The lowest cost ones, in Dual-In-Line packages (which can be used in a breadboard, and so would be easier to prototype) that I found on RS were TLC5916/TLC5917. Each device drives 8 LEDs, so Duncan C's design would use 4. This is &lt;em&gt;more expensive&lt;/em&gt; than decade counters. However, I think the cost (about 5GBP) may be worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One benefit is they are 'constant current' drivers, and so eliminate the current-limiting resistors on each LED. Each device uses one resistor to program the current for all 8 LEDs. That won't save much money, but it will save a lot of wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These shift registers are fed a pattern of data bits, one at a time, using a second 'clock' signal to tell the shift-register when the data bit is valid. Toggling the clock loads the data bit. So you could cascade them, end-to-end, exactly like cascaded counters. To reduce the CPU load, the input to the chain of shift registers could be loaded autonomously, 8 bits at a time by using the SPI peripheral in the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use 4 pins to load data simultaneously, with one pin driving a shared clock. Those shift registers can operate much faster than even Arduino assembler (upto 30MHz/bit). So this needn't take much time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The outputs of the shift registers do not change until a further signal is sent. Then they all change output simultaneously. So your cameras won't be confused by seeing the data being loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there is more software complexity than cascaded counters. However, there is no constraints on what data they show. For example, you might decide that you would like 20 LEDs worth of resolution, so that cameras have a wider exposure time and the frames can still be synchronised or 'positioned' relative to one another in time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anther advantage of this 'soft' behaviour is, you could add lots more LEDs and get pretty much any resolution you might need, using exactly the same hardware technology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach shares an advantage of Duncan C's design. Time is indicated by discrete points of light, and not shape. So it should be relatively straightforward to use image processing to process images. That might be very important if the cameras are video cameras.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;br&gt;&#xA;To clarify a few points. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is purely software which determines the behaviour of the LEDs in a shift-register based approach. Hence it is practical and straightforward, to simulate decade counters. So the 'user interface' can not be worse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The complexity of a chain of shift-registers is the same as decade counters, if you want to use them that way. However for a few pins more, the shift registers could be loaded independently, which might have some benefits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using constant current LED drivers reduces the number of resistors to wire by a factor of 8. TI and others sell devices with 16 and 24 LED drivers, so the number of packages might be reduced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The decade counter has a built in restriction. Not suprising, it gives no more than 10% resolution. However if you need 5%, it can't do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shift-register-based electronics could emulate a 'clock face', so if 5% is needed, use 20 LEDs for that part. If 1% is required, add some more shift registers and LEDs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Summary&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;&#xA;Duncan C's concept of using an 'analogue abacus' display is, IMHO, a more robust user interface than LED Arabic digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, IMHO a hard-wired implementation using decade counters is an unnecessary restriction, limiting resolution. Shift registers make the display 'soft'. Wiring up shift registers is the same complexity as decade counters. Using LED drivers, saves a lot of wiring.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2014-08-16T14:45:58.677" LastActivityDate="2014-08-16T14:45:58.677" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3811" PostTypeId="1" AcceptedAnswerId="3813" CreationDate="2014-08-16T16:54:12.690" Score="2" ViewCount="1132" Body="&lt;p&gt;I have a cheap MPU 6050 chip that communicates over 3.3V I2C. I can talk to it just fine on my Leonardo. If I add an additional Adafruit Motor shield (the old one), my MPU 6050 demo sketch hangs somewhere, and I get nothing back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I see, the pins I use for the I2C communication are not used at all by the motor shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the MPU6050 connected to SCL, SDA, GND and 3.3V, the motor shield uses almost all other pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional Info:&#xA;I am using this sketch currently: &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Lots of &quot;Serial.println&quot;s later, I've narrowed it down a bit. The example sketch above hangs on the statement &quot;Wire.endTransmission();&quot; on line 279 of the I2CDev library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Connecting the motor shield to external power seems to fix my problem. Weird =) I am still interested in the reason for this behavior.&lt;/p&gt;&#xA;" OwnerUserId="3592" LastEditorUserId="3592" LastEditDate="2014-08-16T19:08:36.917" LastActivityDate="2014-08-17T02:31:46.613" Title="I2C seems to stop working when I attach an AF motor shield" Tags="|i2c|arduino-leonardo|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3813" PostTypeId="2" ParentId="3811" CreationDate="2014-08-17T02:31:46.613" Score="4" Body="&lt;p&gt;Motors draw large amounts of current, and will either cause your power supply voltage to sag if you draw more current than your power supply can support, or cause blips in the power supply that will cause you all sorts of problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to take steps to isolate the power from the motor shield from the power for the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are you powering the motor shield? How are you powering the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your power supply has enough current to support both your Arduino and your motors then you can probably solve the problem by adding an isolation capacitor between the Vin port on your Arduino and ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What that does is to filter out temporary variations in the input voltage that's being fed to the Arduino. Without it, the Vin voltage to the Arduino is probably dropping as your motor draws large pulses of current, and &lt;strong&gt;that&lt;/strong&gt; causes the output from the voltage regulator to droop as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to pick the rating of the cap. A trip to the Electrical Engineering stack exchange is probably in order.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-17T02:31:46.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3814" PostTypeId="1" AcceptedAnswerId="3821" CreationDate="2014-08-17T06:15:35.997" Score="2" ViewCount="2846" Body="&lt;p&gt;In order to fit &lt;strong&gt;maximum user program&lt;/strong&gt; into the chip, how to free up Flash space (0.5 kilo bytes for UNO, 2 KB pro Mini, 8KB for ATMega2560) by &lt;strong&gt;removing the bootloader on Atmega328&lt;/strong&gt; (UNO, Pro Mini, or similar)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What &lt;strong&gt;software&lt;/strong&gt; development tools needed (like Atmel AVR Studio software or similar)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What &lt;strong&gt;hardware&lt;/strong&gt; flash writing / debug tools needed (like JTAG hardware programmer/debugger)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is the &lt;strong&gt;procedure&lt;/strong&gt;? Where can I get &lt;strong&gt;more information&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: Update boot loader size for different boards&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-17T16:11:26.370" LastActivityDate="2014-08-17T17:02:57.493" Title="How to free up Flash space by removing the bootloader on UNO?" Tags="|bootloader|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3817" PostTypeId="2" ParentId="3239" CreationDate="2014-08-17T14:00:52.240" Score="1" Body="&lt;p&gt;There is only a very slight chance that you meet the &lt;code&gt;holdDuration &amp;gt;= 4000&lt;/code&gt; condition in the while loop. Only when holdDuration will be exactly 4000 the while loop will be executed AND the subsequent test in the if statement will pass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial print commands can easily take long enough to have &lt;code&gt;millis()&lt;/code&gt; jump from a number less than 4000 to a number higher than 4000 in a single pass of the while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prove this assumption, increase the while test to &lt;code&gt;holdDuration &amp;lt;= 4100&lt;/code&gt; and see if the intermittent effect goes away.&lt;/p&gt;&#xA;" OwnerUserId="83" LastActivityDate="2014-08-17T14:00:52.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3818" PostTypeId="1" AcceptedAnswerId="3820" CreationDate="2014-08-17T15:52:11.770" Score="1" ViewCount="301" Body="&lt;p&gt;I bought &lt;a href=&quot;https://www.sparkfun.com/products/9911&quot; rel=&quot;nofollow&quot;&gt;an OBD connector&lt;/a&gt; from Sparkfun to try to connect to my vehicle via arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just beginning and am not sure if I can just connect the connector pics to the arduino directly, or if there is some other required hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if I can connect directly and why or why not?&lt;/p&gt;&#xA;" OwnerDisplayName="user3596" LastEditorUserId="37" LastEditDate="2014-08-18T23:38:57.800" LastActivityDate="2014-09-17T23:43:16.300" Title="OBD Connector to Arduino" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3819" PostTypeId="1" AcceptedAnswerId="3823" CreationDate="2014-08-17T16:29:46.920" Score="6" ViewCount="3121" Body="&lt;p&gt;According to &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardProMini&quot;&gt;official web info&lt;/a&gt; bootloader sizes are &lt;strong&gt;0.5, 2 and 8 kilo bytes&lt;/strong&gt; for UNO, Pro mini and ATMega2560. I believe all three boot loaders do similar job of receiving serial link data and write to Flash memory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;UNO and Pro mini use &lt;strong&gt;same/similar&lt;/strong&gt; ATMega168/328 chips but boot loader size are 0.5 and 2 KB.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATMega2560 apparent has a more &lt;strong&gt;advanced MCU&lt;/strong&gt; which presumably should use similar or even less memory to do the same task, but the size is significantly large at &lt;strong&gt;8 KB&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why sizes differ? Small difference may be explained by different development teams, but, should be &lt;strong&gt;that much different&lt;/strong&gt;, from 0.5 to 8KB.  &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2018-05-02T06:22:24.923" Title="Why bootloader sizes differs from 0.5 to 8 kilo bytes for different boards?" Tags="|arduino-uno|bootloader|arduino-pro-mini|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3820" PostTypeId="2" ParentId="3818" CreationDate="2014-08-17T16:38:58.417" Score="1" Body="&lt;p&gt;I briefly read up on this subject and I found out this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like there's a protocol called &lt;em&gt;J1850&lt;/em&gt;. There's no native support on the Arduino for that, but you might be able to do something bit-banging if you can find the specifications for this protocol. If you do this, I'd advise accessing the registers directly and skipping the &lt;code&gt;digitalRead()&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few protocols in use, so it is hard to know without knowing the car you drive to even tell what the car will send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&quot;http://pinoutsguide.com/CarElectronics/car_obd2_pinout.shtml&quot; rel=&quot;nofollow&quot;&gt;More on this topic...&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, it seems like you need a chip to use with this. &lt;a href=&quot;https://www.sparkfun.com/products/9555&quot; rel=&quot;nofollow&quot;&gt;Sparkfun also sells a breakout board for the STN1110 OBD-II to UART chip&lt;/a&gt; &lt;em&gt;(&lt;a href=&quot;https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;tutorial)&lt;/a&gt;&lt;/em&gt;. I couldn't really find anything else besides &lt;a href=&quot;http://arduinodev.com/hardware/obd-kit/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you probably need another chip to do this work. The Arduino isn't meant to do all of these protocols, and the OBD isn't UART-compatible.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-17T16:38:58.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3821" PostTypeId="2" ParentId="3814" CreationDate="2014-08-17T17:02:57.493" Score="2" Body="&lt;p&gt;You'll need to use an ISP programmer with avrdude. Perform a chip erase and then unprogram the &lt;code&gt;BOOTRST&lt;/code&gt; fuse in the high fuse byte.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-17T17:02:57.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3822" PostTypeId="1" AcceptedAnswerId="3824" CreationDate="2014-08-17T17:40:14.073" Score="4" ViewCount="9409" Body="&lt;p&gt;As stated in &lt;a href=&quot;http://arduino.cc/en/Main/FAQ&quot; rel=&quot;nofollow&quot;&gt;www.Arduino.cc FAQ&lt;/a&gt;, &quot;Can I use an Arduino board without the Arduino software? Sure. It's just an AVR development board, you can use straight AVR C or C++ (with avr-gcc and avrdude or AVR Studio) to program it.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For UNO/Pro Mini(ATMega328) and ATmega2560, does these two chips support JTAG type (some chip manufacturers may use different name) programmer / hardware-based debugger in same manner as the ST-Link/J-Link programmer/debugger where one can &lt;strong&gt;load code&lt;/strong&gt; into the MCU and perform &lt;strong&gt;hardware break point&lt;/strong&gt; and single stepping? Example as in  &lt;a href=&quot;http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF252419?sc=internet/evalboard/product/252419.jsp&quot; rel=&quot;nofollow&quot;&gt;STM32 development board with ST-LINK programmer / debugger&lt;/a&gt; where the chip has built-in debug circuit that communicate with ST-Link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="37523" LastEditDate="2019-12-02T18:36:09.793" LastActivityDate="2019-12-02T18:36:09.793" Title="Does ATMega 328/2560 chips support JTAG-type programmer and hardware debugger?" Tags="|arduino-uno|avrdude|debugging|avr-gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3823" PostTypeId="2" ParentId="3819" CreationDate="2014-08-17T17:47:06.407" Score="6" Body="&lt;p&gt;Bootloader of the Mini and Uno are pretty much the same. (I can't find the source-code but the hex files are only slightly different). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2k is because they haven't updated &lt;code&gt;mini328.upload.maximum_size&lt;/code&gt; in &lt;code&gt;boards.txt&lt;/code&gt;. Probably because that would break the board for users that haven't updated the bootloader yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2560 is using a stk500v2 compatible boot loader instead of Optiboot (uno and mini), because optiboot only supports upto 64kb addresses. Not sure why it is that much bigger though.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-17T17:47:06.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3824" PostTypeId="2" ParentId="3822" CreationDate="2014-08-17T17:53:49.277" Score="6" Body="&lt;p&gt;The ATmegaXX8 does not support JTAG, but the ATmegaXX0, 'XX1, and 'XX4 do. The 'XX8 (as well as other AVR families) supports debugWIRE, which allows debugging over ISP. You will need one of Atmel's debuggers such as the AVR ONE! or the Atmel-ICE as well as Atmel Studio in order to use it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-17T17:53:49.277" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3826" PostTypeId="1" AcceptedAnswerId="3831" CreationDate="2014-08-17T23:39:20.667" Score="22" ViewCount="4299" Body="&lt;p&gt;I'm designing an Arduino style board with built-in LEDs for several of the pins. To simplify assembly of the board and save on components, I was wondering whether it would be safe for those LEDs to share a single resistor, as in this diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jWXVT.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, the power dissipated through the resistor (3mA per pin @ 3V) is not a real problem. The reason I was hesitating is that LEDs in a parallel configuration should not share resistors, but is it safe to think that separate microcontroller pins don't count as a common anode, even if both pins are high?&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-08-21T15:37:14.397" Title="Can two LEDs attached to different pins share their resistor?" Tags="|led|resistor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3827" PostTypeId="2" ParentId="3826" CreationDate="2014-08-18T00:52:59.440" Score="19" Body="&lt;p&gt;Your circuit is safe from the electronic viewpoint, so long as the LEDs used can withstand a back-emf of 4v or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If only one LED is on at a time, all will be sweet. But if two or more are on, the brightness will drop and the brightness between LEDS will probably be inconsistent. The forward voltage drop of individual LEDS tend to vary a little, so one is likely to hog most of the available current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A separate resistor per LED is probably best.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-08-18T00:52:59.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3828" PostTypeId="1" AcceptedAnswerId="3830" CreationDate="2014-08-18T01:19:17.093" Score="8" ViewCount="6125" Body="&lt;p&gt;Say I wrote a compiled sketch to EEPROM then read it. Could I run the program from EEPROM? I guess the question is: Can an Arduino run software not in flash memory in the middle of executing the software in flash?&lt;/p&gt;&#xA;" OwnerUserId="3603" LastActivityDate="2014-08-18T04:38:00.047" Title="Is it possible to run a binary from EEPROM?" Tags="|arduino-uno|sketch|compile|flash|eeprom|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3829" PostTypeId="2" ParentId="3828" CreationDate="2014-08-18T04:26:46.440" Score="6" Body="&lt;p&gt;No. The foundation of a &lt;a href=&quot;http://en.wikipedia.org/wiki/Harvard_architecture&quot;&gt;Harvard architecture&lt;/a&gt; such as AVR is to only allow code that exists within program space to be executed, and EEPROM is not within program space. It is possible, however, to write a &lt;a href=&quot;http://en.wikipedia.org/wiki/Virtual_machine#Process_virtual_machines&quot;&gt;virtual machine&lt;/a&gt; that will run from flash. This VM can then read program-become-data from anywhere and take action based on it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-18T04:26:46.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3830" PostTypeId="2" ParentId="3828" CreationDate="2014-08-18T04:38:00.047" Score="9" Body="&lt;p&gt;Short answer: No; From the atmega328's data sheet (though it applies to all AVR's): &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AVR uses a Harvard architecture – with&#xA;  separate memories and buses for program and data. Instructions in the program memory are&#xA;  executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the program memory&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Program Flash memory space is divided in two sections, the Boot Program section and the&#xA;  Application Program section. Both sections have dedicated Lock bits for write and read/write&#xA;  protection. The SPM instruction that writes into the Application Flash memory section must&#xA;  reside in the Boot Program section&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's architecture prevents using external program memory, but you can load anything into program memory at boot. At that point I would venture to say you are just programming AVR and not arduino, since you would need to replace the arduino bootloader and break the arduino IDE's ability to upload programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately you could also use an emulator or interpreter of some intermediate language; basically code that steps through and runs other code. As a general rule an emulator runs around 8x slower. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are micro-controllers from other brands that do support this functionality, I know a couple different PIC's do.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-08-18T04:38:00.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3831" PostTypeId="2" ParentId="3826" CreationDate="2014-08-18T08:17:18.287" Score="18" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Can&lt;/strong&gt; two LEDs attached to different pins share their resistor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;can&lt;/strong&gt; : yes&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;should&lt;/strong&gt; : probably not&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your resistor act here as a current limiter, say to &lt;em&gt;3mA&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you light one LED at a time, you give 3mA to &lt;em&gt;that&lt;/em&gt; LED&#xA;If you light 2 LEDs, you give 3mA for both of them (more of less 1.5mA each)&#xA;If you light 3 LEDs, you give 3mA for all of them (&lt;em&gt;on average&lt;/em&gt; 1mA each)&#xA;&lt;br&gt;&lt;sub&gt;Things are even a little bit more subtle, as different LED might have different forward voltage, so one LED might very well drain 10% more current than an other.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &quot;Amps made LED bright&quot;, less Amp is less light. On LED light with that setup will give &quot;full light on&quot;, and more LED you add, less would bright each one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an edit to that answer, there is one case I might consider that arrangement for &quot;multi-LED lighting&quot;. This is if you are &lt;a href=&quot;http://en.wikipedia.org/wiki/Multiplexed_display&quot;&gt;multiplexing your LEDs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is lighting only one at a time, but cycling fast enough from one LED to the next so that the human eye would &lt;em&gt;see&lt;/em&gt; them all lit at once.&lt;/p&gt;&#xA;" OwnerUserId="3607" LastEditorUserId="3607" LastEditDate="2014-08-21T15:37:14.397" LastActivityDate="2014-08-21T15:37:14.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3832" PostTypeId="1" CreationDate="2014-08-18T12:03:08.107" Score="2" ViewCount="11991" Body="&lt;p&gt;I'm a beginner in Arduino world and I want to create a simple SD datalogger that works with GPS (module NEO-6M) and light sensor. I know there are a number of tutorials on GPS logging including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://bobcravens.com/2010/08/create-a-gps-data-logger-using-the-arduino/&quot; rel=&quot;nofollow&quot;&gt;Create a GPS Data Logger Using The Arduino&lt;/a&gt; (Bob Cravens)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Geo-Data-Logger-ArduinoGPSSDAccelerometer-to-l/&quot; rel=&quot;nofollow&quot;&gt;Geo Data Logger: Arduino+GPS+SD+Accelerometer&lt;/a&gt; (Instructables)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduinodev.com/mtk3329-10hz-gps-module-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;Making a SD card GPS logger with Arduino and MTK3329 GPS module&lt;/a&gt; (Arduinodev)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;but my problem is that those tutorials are either too complex (i.e. include extra stuff like displays) or they don't use &lt;a href=&quot;http://arduiniana.org/libraries/tinygps/&quot; rel=&quot;nofollow&quot;&gt;TinyGPS&lt;/a&gt; or &lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;TinyGPS++&lt;/a&gt; library. In the first step I've managed to get GPS working and displaying the result on my laptop screen (via &lt;code&gt;Serial.print()&lt;/code&gt;) using example code from &lt;a href=&quot;http://arduiniana.org/libraries/tinygps/&quot; rel=&quot;nofollow&quot;&gt;TinyGPS&lt;/a&gt; library. In the next step I managed to use tutorial for &lt;a href=&quot;https://learn.adafruit.com/adafruit-data-logger-shield?view=all&quot; rel=&quot;nofollow&quot;&gt;Adafruit Data Logger&lt;/a&gt; to log data on SD card. The problem: light sensor logs ok, but for GPS it only logs a strings of 99.999999. Tried various tweaks but so far not sure what I got wrong. I use Arduino Uno, NEO-6M GPS, Catalex MicroSD Card Adapter, simple LDR. Here is my current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;TinyGPS++.h&amp;gt;&#xA;    #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;    #include &quot;SD.h&quot;&#xA;&#xA;    //input for the light detecting sensor (LDR)&#xA;    int LDR = A3;   &#xA;&#xA;    //inputs and triggers for GPS&#xA;    TinyGPSPlus gps;&#xA;    SoftwareSerial ss (7, 8); // TX=7, RX=8 &#xA;&#xA;    // digital pin 4 for the SD cs line&#xA;    const int chipSelect = 4;&#xA;    File logfile;// the logging file&#xA;&#xA;    //data logger timing and other &#xA;    #define LOG_INTERVAL  1000 // mills between entries&#xA;    #define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the card&#xA;    uint32_t syncTime = 0; // time of last sync()&#xA;    #define ECHO_TO_SERIAL   1 // echo data to serial port&#xA;    #define WAIT_TO_START    0 // Wait for serial input in setup()    &#xA;&#xA;    void setup() {&#xA;      Serial.begin(9600);&#xA;      ss.begin(9600);&#xA;      Serial.println();&#xA;&#xA;      #if WAIT_TO_START&#xA;        Serial.println(&quot;Type any character to start&quot;);&#xA;        while (!Serial.available());&#xA;      #endif //WAIT_TO_START&#xA;&#xA;      // initialize the SD card&#xA;      Serial.print(&quot;Initializing SD card...&quot;);&#xA;&#xA;      pinMode(10, OUTPUT);&#xA;&#xA;      // see if the card is present and can be initialized:&#xA;      if (!SD.begin(chipSelect)) {&#xA;        Serial.println(&quot;Card failed, or not present&quot;);&#xA;        // don't do anything more:&#xA;        return;&#xA;      }&#xA;      Serial.println(&quot;card initialized.&quot;);&#xA;&#xA;      // create a new file&#xA;      char filename[] = &quot;LOGGER00.CSV&quot;;&#xA;      for (uint8_t i = 0; i &amp;lt; 100; i++) {&#xA;        filename[6] = i/10 + '0';&#xA;        filename[7] = i%10 + '0';&#xA;        if (! SD.exists(filename)) {&#xA;          // only open a new file if it doesn't exist&#xA;          logfile = SD.open(filename, FILE_WRITE); &#xA;          break;  // leave the loop!&#xA;        }&#xA;      }&#xA;&#xA;      Serial.print(&quot;Logging to: &quot;);&#xA;      Serial.println(filename);&#xA;&#xA;      logfile.println(&quot;date,time,lat,long,light&quot;);&#xA;&#xA;      #if ECHO_TO_SERIAL&#xA;        Serial.println(&quot;lat,log,date,time,altitude,light&quot;);&#xA;      #endif// attempt to write out the header to the file&#xA;    }&#xA;&#xA;void loop(void) {  &#xA;&#xA;   // delay for the amount of time we want between readings&#xA;   delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));&#xA;&#xA;   //here is GPS data (if I got it right)&#xA;   while (ss.available() &amp;gt; 0)&#xA;   gps.encode(ss.read());&#xA;   logfile.print(gps.date.value());&#xA;   logfile.print(&quot;, &quot;);&#xA;   logfile.print(gps.time.value());&#xA;   logfile.print(&quot;, &quot;);&#xA;   logfile.print(gps.location.lat(), 6);&#xA;   logfile.print(&quot;, &quot;);&#xA;   logfile.print(gps.location.lng(), 6);&#xA;   logfile.print(&quot;, &quot;);&#xA;   #if ECHO_TO_SERIAL&#xA;      Serial.print(gps.date.value());&#xA;      Serial.print(&quot;, &quot;);  &#xA;      Serial.print(gps.time.value());&#xA;      Serial.print(&quot;, &quot;);  &#xA;      Serial.print(gps.location.lat(), 6);&#xA;      Serial.print(&quot;, &quot;);  &#xA;      Serial.print(gps.location.lng(), 6);&#xA;      Serial.print(&quot;, &quot;);  &#xA;   #endif&#xA;&#xA;   //Read light intensity&#xA;   float lux = 500/(10.72/(5-(photocellReading * 0.00488759))*(photocellReading * 0.00488759));&#xA;   logfile.println(lux);&#xA;   #if ECHO_TO_SERIAL&#xA;      Serial.println(lux);&#xA;   #endif //ECHO_TO_SERIAL&#xA;&#xA;   //write data to disk&#xA;   if ((millis() - syncTime) &amp;lt; SYNC_INTERVAL) return;&#xA;   syncTime = millis();&#xA;   logfile.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3548" LastActivityDate="2014-10-01T11:00:58.550" Title="GPS logging on SD card using TinyGPS" Tags="|arduino-uno|tinygps|sd-card|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3833" PostTypeId="1" AcceptedAnswerId="3835" CreationDate="2014-08-18T18:16:15.723" Score="1" ViewCount="851" Body="&lt;p&gt;In order to allow &lt;strong&gt;bigger user program size&lt;/strong&gt;, is it possible and advisable to &lt;strong&gt;reload Pro Mini&lt;/strong&gt; with the boot loader originally &lt;strong&gt;designed for UNO&lt;/strong&gt;. This will save 1.5 KB flash space (UNO boot loader is 0.5KB, Pro Mini is 2KB). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a smaller boot loader is an 'intermediate' step to get more space while still enjoy the easy benefit of the Arduino IDE and many library/code example. Of course, ultimate step is to remove all boot loader (only small saving of 0.5KB if above is possible) and switch to ATmel development environment, ATmel studio, which is complex but programmer has full control of everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I miss anything in the followings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to believe that it is possible as &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) same ATMega328 chip is used in both board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Pro Mini is essentially cutting UNO into two halves, the MCU and the USB/Serial converter now use external USB to Serial converter    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Pro Mini board is reloaded with UNO boot loader, how should the boards.txt file be edited to reflect the changes so that the IDE will handle it correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-18T18:30:18.723" LastActivityDate="2014-08-18T20:08:30.740" Title="Is it advisable to reload Pro Mini with the bootloader originally designed for UNO to save 1.5 KB flash space?" Tags="|arduino-uno|bootloader|arduino-pro-mini|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3834" PostTypeId="1" CreationDate="2014-08-18T18:35:51.437" Score="2" ViewCount="928" Body="&lt;p&gt;Some clients, let's say 5 &amp;lt;= x &amp;lt;= 10, have to send information wirelessly to a server. Transmission does not need to be reliable (ACK).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range would be between 50 and 100m, and may include soft obstacles like trees, cars, etc, but not major ones like whole buildings or concrete walls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as I plan to build about 20 clients, the price should be as low as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thoughts?&lt;/p&gt;&#xA;" OwnerUserId="3619" LastActivityDate="2014-08-19T07:31:27.420" Title="Which wireless technology should I use for medium range, many to one, bidirectional communication?" Tags="|wifi|bluetooth|rf|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3835" PostTypeId="2" ParentId="3833" CreationDate="2014-08-18T20:08:30.740" Score="1" Body="&lt;p&gt;You can just flash the newest &lt;a href=&quot;https://raw.githubusercontent.com/arduino/Arduino/master/hardware/arduino/bootloaders/optiboot/optiboot_atmega328-Mini.hex&quot; rel=&quot;nofollow&quot;&gt;optiboot_atmega328-Mini.hex&lt;/a&gt;. That one should also be only .5k in size, as it starts writing at the same address (&lt;code&gt;7E00&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you divide &lt;code&gt;7E00&lt;/code&gt; by two you get &lt;code&gt;3F00&lt;/code&gt; (This is because AVRs use 16-bit words for addressing while .hex files work with bytes (8-bit)). (I figured that one out, just now)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;3F00&lt;/code&gt; is exactly the start of the &lt;code&gt;Boot Loader Flash Section&lt;/code&gt; when you  have selected a 256-words &lt;code&gt;Boot Size&lt;/code&gt; (page 291 of the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;). 256-words is the 0.5kb you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just make sure you have the &lt;code&gt;BOOTSZ1&lt;/code&gt;, &lt;code&gt;BOOTSZ0&lt;/code&gt; fuses set to &lt;code&gt;1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the &lt;code&gt;boards.txt&lt;/code&gt;. I think you only need to change &lt;code&gt;mini328.upload.maximum_size=28672&lt;/code&gt; to &lt;code&gt;mini328.upload.maximum_size=32256&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-18T20:08:30.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3836" PostTypeId="1" AcceptedAnswerId="3838" CreationDate="2014-08-18T20:26:56.780" Score="1" ViewCount="903" Body="&lt;p&gt;I am experiencing problems when I put parts of my code into custom functions and then have Arduino Mega 2560 run it. The code works fine when I put it all in the void loop() function, but when I create new functions then call those functions in the loop() function, it doesn't do what I want it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code where I put everything in the loop function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;Location.txt: Date/Time , Latitude (deg decimal), Longitude, Altitude (m)&#xA;Speed.txt: Date/Time, Speed (m/s), Heading (deg)&#xA;*/&#xA;&#xA;#include&amp;lt;TinyGPS.h&amp;gt;&#xA;#include&amp;lt;SD.h&amp;gt;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;int CS = 53;&#xA;&#xA;long lat,lon;&#xA;unsigned long time, date;&#xA;int year,tinseconds;&#xA;byte month, day, hour, minute, second, hundredths;&#xA;unsigned long age;&#xA;char dataString[20];&#xA;TinyGPS GPS;&#xA;&#xA;struct GPSstruct {&#xA;  String dateTime;&#xA;  int timeseconds;&#xA;  float C_lat;&#xA;  float C_lon;&#xA;  float C_alt;&#xA;  float heading;&#xA;  float speedmps;&#xA;};&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial1.begin(38400);&#xA;  pinMode(CS, OUTPUT);&#xA;  if(!SD.begin(CS))&#xA;  {&#xA;    Serial.println(F(&quot;Card Failure&quot;));&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;if(Serial1.available()){ // check for gps data&#xA;   if(GPS.encode(Serial1.read())){ // encode gps data&#xA;    GPS.crack_datetime(&amp;amp;year, &amp;amp;month, &amp;amp;day, &amp;amp;hour, &amp;amp;minute, &amp;amp;second, &amp;amp;hundredths, &amp;amp;age);&#xA;    GPS.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude in degree decimals multiplied by 10^5&#xA;    sprintf(dataString, &quot;%02d/%02d/%02d %02d:%02d:%02d&quot;,month,day,year,hour,minute,second);&#xA;    tinseconds = second + minute*60 + hour*3600;&#xA;    float C_lat = ((float)lat)/1000000; //to get degree decimals&#xA;    float C_lon = ((float)lon)/1000000;&#xA;    float C_alt = GPS.f_altitude();&#xA;    float heading = GPS.f_course();&#xA;    float speedmps = GPS.f_speed_mps();&#xA;    GPSstruct A = {dataString,tinseconds,C_lat,C_lon,C_alt,heading,speedmps};&#xA;&#xA;//DEBUG&#xA;    Serial.println();&#xA;    Serial.print(F(&quot;Date/Time: &quot;));Serial.println(dataString);&#xA;    Serial.print(F(&quot;Time (sec): &quot;));Serial.println(tinseconds);&#xA;    Serial.print(F(&quot;Lat: &quot;));Serial.println(C_lat,5);&#xA;    Serial.print(F(&quot;Lon: &quot;));Serial.println(C_lon,5);&#xA;    Serial.print(F(&quot;Alt: &quot;));Serial.println(C_alt);&#xA;    Serial.print(F(&quot;Heading: &quot;));Serial.println(heading);&#xA;    Serial.print(F(&quot;Speed: &quot;));Serial.println(speedmps);&#xA;//END of DEBUG&#xA;&#xA;//add the code below makes alt = 1000000 for a long time then it fixes at some ?wierd? number&#xA;//------//&#xA;  File dataFile = SD.open(&quot;Location.txt&quot;, FILE_WRITE); //Records date/time, lat, lon, alt&#xA;    if (dataFile)&#xA;    {&#xA;      dataFile.print(A.dateTime);dataFile.print(&quot; , &quot;);dataFile.print(A.C_lat,5);dataFile.print(&quot; , &quot;);dataFile.print(A.C_lon,5);dataFile.print(&quot; , &quot;);dataFile.println(A.C_alt);&#xA;      dataFile.close();&#xA;    }&#xA;    else&#xA;    {&#xA;       Serial.println(F(&quot;Location.txt cannot be opened!&quot;)); &#xA;    }&#xA;&#xA;&#xA;   File dataFile2 = SD.open(&quot;Speed.txt&quot;,FILE_WRITE); //Records date/time, speed, heading&#xA;   if (dataFile2)&#xA;   {&#xA;     dataFile2.print(A.dateTime);dataFile2.print(&quot; , &quot;);dataFile2.print(A.speedmps);dataFile2.print(&quot; , &quot;);dataFile2.println(A.heading);&#xA;     dataFile2.close();&#xA;   }&#xA;   else&#xA;   {&#xA;     Serial.println(F(&quot;Speed.txt cannot be opened!&quot;));&#xA;   }&#xA;//------//&#xA;   }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code where I put them into two custom functions and call them in loop()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;TinyGPS.h&amp;gt;&#xA;#include&amp;lt;SD.h&amp;gt;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;int CS = 53;&#xA;long lat,lon;&#xA;unsigned long time, date;&#xA;int year,tinseconds;&#xA;byte month, day, hour, minute, second, hundredths;&#xA;unsigned long age;&#xA;char dataString[20];&#xA;TinyGPS GPS;&#xA;&#xA;struct GPSstruct {&#xA;  char dateTime[20];&#xA;  int timeseconds;&#xA;  float C_lat;&#xA;  float C_lon;&#xA;  float C_alt;&#xA;  float heading;&#xA;  float speedmps;&#xA;};&#xA;&#xA;//Function Prototypes&#xA;struct GPSstruct GPSdata(void);&#xA;void SDlogger(struct GPSstruct);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial1.begin(38400);&#xA;  pinMode(CS, OUTPUT);&#xA;  SD.begin(CS);&#xA;}&#xA;&#xA;//GPS data function:&#xA;struct GPSstruct GPSdata(void) {&#xA;static GPSstruct A;&#xA;&#xA; if(Serial1.available()){ // check for gps data&#xA;   if(GPS.encode(Serial1.read())){ // encode gps data&#xA;    GPS.crack_datetime(&amp;amp;year, &amp;amp;month, &amp;amp;day, &amp;amp;hour, &amp;amp;minute, &amp;amp;second, &amp;amp;hundredths, &amp;amp;age);&#xA;    GPS.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude in degree decimals multiplied by 10^5&#xA;    sprintf(dataString, &quot;%02d/%02d/%02d %02d:%02d:%02d&quot;,month,day,year,hour,minute,second);&#xA;    tinseconds = second;&#xA;    float C_lat = ((float)lat)/1000000; //to get degree decimals&#xA;    float C_lon = ((float)lon)/1000000;&#xA;    float C_alt = GPS.f_altitude();&#xA;    float heading = GPS.f_course();&#xA;    float speedmps = GPS.f_speed_mps();&#xA;    strcpy(A.dateTime, dataString);&#xA;    A.C_lat = C_lat;&#xA;    A.C_lon = C_lon;&#xA;    A.C_alt = C_alt;&#xA;    A.heading = heading;&#xA;    A.speedmps = speedmps;&#xA;&#xA;//DEBUG&#xA;    Serial.print(F(&quot;Date/Time: &quot;));Serial.println(dataString);&#xA;    Serial.print(F(&quot;Time (sec): &quot;));Serial.println(tinseconds);&#xA;    Serial.print(F(&quot;Lat: &quot;));Serial.println(C_lat);&#xA;    Serial.print(F(&quot;Lon: &quot;));Serial.println(C_lon);&#xA;    Serial.print(F(&quot;Alt: &quot;));Serial.println(C_alt);&#xA;    Serial.print(F(&quot;Heading: &quot;));Serial.println(heading);&#xA;    Serial.print(F(&quot;Speed: &quot;));Serial.println(speedmps);&#xA;    Serial.println();&#xA;//END of DEBUG&#xA;  }&#xA; }&#xA; return A;&#xA;}&#xA;&#xA;//SD data logging funct:&#xA;void SDlogger(struct GPSstruct A)&#xA;{&#xA;   File dataFile = SD.open(&quot;Location.txt&quot;, FILE_WRITE); //Records date/time, lat, lon, alt&#xA;    if (dataFile)&#xA;    {&#xA;      dataFile.print(A.dateTime);dataFile.print(&quot; , &quot;);dataFile.print(A.C_lat);dataFile.print(&quot; , &quot;);dataFile.print(A.C_lon);dataFile.print(&quot; , &quot;);dataFile.println(A.C_alt);&#xA;      dataFile.close();&#xA;    }&#xA;    else&#xA;    {&#xA;       Serial.println(F(&quot;Location.txt cannot be opened!&quot;)); &#xA;    }&#xA;   File dataFile2 = SD.open(&quot;Speed.txt&quot;,FILE_WRITE); //Records date/time, speed, heading&#xA;   if (dataFile2)&#xA;   {&#xA;     dataFile2.print(A.dateTime);dataFile2.print(&quot; , &quot;);dataFile2.print(A.speedmps);dataFile2.print(&quot; , &quot;);dataFile2.println(A.heading);&#xA;     dataFile2.close();&#xA;   }&#xA;   else&#xA;   {&#xA;     Serial.println(F(&quot;Speed.txt cannot be opened!&quot;));&#xA;   } &#xA;} &#xA;void loop()&#xA;{&#xA;  struct GPSstruct Gdata = GPSdata();&#xA;  SDlogger(Gdata);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The one with all the code in the loop function prints all the serial.println commands and writes data into the micro SD card, but the one with custom functions DOESN'T print serial.println commands in GPSdata function and only prints that &quot;Location.txt/Speed.txt cannot be opened!&quot; and have writes 0 into the mirco SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening? Is it memory problems? (But the other one works fine)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code here is meant to be a part of a bigger main code that uses these GPS data, so I would prefer it if I can keep the main script clean using custom functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3650" OwnerDisplayName="Frank Hu" LastEditorUserId="220" LastEditDate="2014-08-18T22:14:03.837" LastActivityDate="2014-08-18T22:14:03.837" Title="Arduino Custom Function Problem" Tags="|programming|atmega328|sd-card|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3838" PostTypeId="2" ParentId="3836" CreationDate="2014-08-18T20:57:44.567" Score="2" Body="&lt;p&gt;Admittedly, your code is somewhat hard to read without an actual editor (not your fault), but I think the issue is that in the first code (everything in one loop), the matching bracket from the initial if-statement (&lt;code&gt;if(Serial1.available()) {&lt;/code&gt;) is located &lt;em&gt;after&lt;/em&gt; the SD logging functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second code (decomposing the code), you have the SD logging done &lt;em&gt;outside&lt;/em&gt; the if-statement. My guess is that &lt;code&gt;Serial1.available() = false&lt;/code&gt; initially, so in the first piece of code, it skips everything else and loop until &lt;code&gt;Serial1.available() == true&lt;/code&gt;. That probably doesn't take long, so you just see everything working. In the second code, you return &lt;code&gt;static GPSstruct A&lt;/code&gt; (I'm not sure you want this to be static, but I could be wrong) which has been initialized but contains no useful data (it's uninitialized). The &lt;code&gt;void loop()&lt;/code&gt; then takes that empty struct and passes it over to &lt;code&gt;SDlogger(struct GPSstruct)&lt;/code&gt;. That function doesn't do any error-checking to make sure that &lt;code&gt;A&lt;/code&gt; has useful information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy workaround would be to add a field to the &lt;code&gt;GPSstruct&lt;/code&gt; for whether or not it contains data. It's a simple &lt;code&gt;boolean&lt;/code&gt; value. The code might look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct GPSstruct {&#xA;  boolean containsData;&#xA;  String dateTime;&#xA;  int timeseconds;&#xA;  float C_lat;&#xA;  float C_lon;&#xA;  float C_alt;&#xA;  float heading;&#xA;  float speedmps;&#xA;};&#xA;&#xA;...&#xA;&#xA;if(Serial1.available()){&#xA;  A.containsData = true;&#xA;  ...&#xA;} else {&#xA;  A.containsData = false;&#xA;}&#xA;&#xA;...&#xA;&#xA;void SDlogger(struct GPSstruct A) {&#xA;  if(A.containsData) {&#xA;    ...&#xA;  } else {&#xA;    return;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, as I was typing this, it got migrated...&lt;/p&gt;&#xA;" OwnerUserId="3622" LastActivityDate="2014-08-18T20:57:44.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3839" PostTypeId="2" ParentId="3239" CreationDate="2014-08-18T21:31:25.147" Score="0" Body="&lt;p&gt;&lt;strong&gt;Thoughs:&lt;/strong&gt;&#xA;Unfortunately I have been unable to get to the bottom of this issue. I noticed the problem tends to happen the first time the interaction starts after the computer and Arduino are idle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without knowing too much about how the serial communication is built I'm guessing that without traffic the connection is put to sleep, or generally inactive, and the sound delay is a result of the connection needing to re-initialize or something of that nature. I cant recall a time when the issue occurred and I had a recent correct previous interaction. Once it works any immediate retrial will also behavior correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&#xA;I have since moved my timing/sound playing component within my C# app. The Arduino now signals the start of the timer, and then end of the timer with an immediate start to my event.&lt;/p&gt;&#xA;" OwnerUserId="1720" LastActivityDate="2014-08-18T21:31:25.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3840" PostTypeId="1" AcceptedAnswerId="3841" CreationDate="2014-08-19T00:37:25.707" Score="2" ViewCount="13765" Body="&lt;p&gt;Within the Arduino IDE Serial.* output can be viewed with Tools / Serial Monitor.  How can I view Serial.* output on an Android?  As a concrete example, how can I view the output from Examples / Communication / ASCIITable?&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2022-08-12T12:30:04.017" Title="How do I view Serial Output on an Android Device?" Tags="|android|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3841" PostTypeId="2" ParentId="3840" CreationDate="2014-08-19T00:37:25.707" Score="4" Body="&lt;p&gt;These steps will allow your Android device to function as an Arduino Terminal. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download a Serial Terminal app.  I'm using &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.passiontech.support.en&quot; rel=&quot;nofollow&quot;&gt;Android Hyperterminal, English version&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Attach an OTG (&quot;On The Go&quot;) cable to your Android device.&lt;/li&gt;&#xA;&lt;li&gt;Attach your Arduino to the OTG using your regular USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Make sure the terminal program is set to the same baud rate as your sketch.&lt;/li&gt;&#xA;&lt;li&gt;Run the terminal App and select the USB port.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-08-19T00:37:25.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3842" PostTypeId="1" AcceptedAnswerId="3846" CreationDate="2014-08-19T03:30:15.010" Score="1" ViewCount="125" Body="&lt;p&gt;I'm using &lt;code&gt;avr-size&lt;/code&gt; to see the size of library objects to free up some FLASH. Why are &lt;code&gt;Tone.cpp&lt;/code&gt; and &lt;code&gt;IPAddress.cpp&lt;/code&gt; getting built? e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cd /var/folders/3j/6wp3hvrj34n0xg3xzq6vjq380000gn/T/build8391693238079360471.tmp/&#xA;localhost:build8391693238079360471.tmp&#xA;$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-size *.o&#xA;   text    data     bss     dec     hex filename&#xA;      0       0       0       0       0 CDC.cpp.o&#xA;      0       0       0       0       0 HID.cpp.o&#xA;   1816       0     170    1986     7c2 HardwareSerial.cpp.o&#xA;    512       0       6     518     206 IPAddress.cpp.o&#xA;  10186     391     377   10954    2aca MainINOFile.cpp.o&#xA;   1872      14       0    1886     75e Print.cpp.o&#xA;   1414       1       0    1415     587 Stream.cpp.o&#xA;   1365       1      21    1387     56b Tone.cpp.o&#xA;      0       0       0       0       0 USBCore.cpp.o&#xA;    288       0       4     292     124 WInterrupts.c.o&#xA;    306       0       0     306     132 WMath.cpp.o&#xA;   4796       1       1    4798    12be WString.cpp.o&#xA;     30       0       0      30      1e main.cpp.o&#xA;    618       6       0     624     270 malloc.c.o&#xA;     56       0       0      56      38 new.cpp.o&#xA;    450       0       0     450     1c2 realloc.c.o&#xA;    588       0       9     597     255 wiring.c.o&#xA;    266       1       0     267     10b wiring_analog.c.o&#xA;    550       0       0     550     226 wiring_digital.c.o&#xA;    320       0       0     320     140 wiring_pulse.c.o&#xA;    260       0       0     260     104 wiring_shift.c.o&#xA;$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-size */*.o&#xA;   text    data     bss     dec     hex filename&#xA;   2790       0       0    2790     ae6 DS3231/DS3231.cpp.o&#xA;     38       0       1      39      27 EEPROM/EEPROM.cpp.o&#xA;   1444       0       0    1444     5a4 LSM303/lsm303.cpp.o&#xA;    782       0       0     782     30e Messenger/Messenger.cpp.o&#xA;    116       0       1     117      75 SPI/SPI.cpp.o&#xA;    142       0       4     146      92 SdFat/MinimumSerial.cpp.o&#xA;   2568       0       0    2568     a08 SdFat/Sd2Card.cpp.o&#xA;  10644       0       4   10648    2998 SdFat/SdBaseFile.cpp.o&#xA;   1322       2       0    1324     52c SdFat/SdFat.cpp.o&#xA;    152       0       0     152      98 SdFat/SdFatUtil.cpp.o&#xA;    233       0       0     233      e9 SdFat/SdFile.cpp.o&#xA;    736       0       0     736     2e0 SdFat/SdStream.cpp.o&#xA;   2604       0     523    3127     c37 SdFat/SdVolume.cpp.o&#xA;   3395       0       0    3395     d43 SdFat/istream.cpp.o&#xA;   1635       0       0    1635     663 SdFat/ostream.cpp.o&#xA;    754       0      86     840     348 Wire/Wire.cpp.o&#xA;$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-size *.elf&#xA;   text    data     bss     dec     hex filename&#xA;  29204     442    1279   30925    78cd MainINOFile.cpp.elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-08-19T04:59:41.163" LastActivityDate="2014-08-19T13:26:28.153" Title="Why are Tone.cpp and IPAddress.cpp getting built for my project?" Tags="|avr-toolchain|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3843" PostTypeId="2" ParentId="3834" CreationDate="2014-08-19T05:08:40.937" Score="1" Body="&lt;p&gt;RF433 modules are about as cheap as you get. You can get a tx/rx pair(separate modules) for 1-2 USD on ebay. Just search for &quot;433mhz module&quot;. 100m or longer range should be possible with a proper antenna - a wire of the correct length. Use wavelength / 4, for 433MHz that is ~173mm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The modules just communicate over a serial interface and they send the data straight to the air. But for better transmission the 1's and 0's need to be balanced and a &quot;training preamble&quot; before a data transmit balances the receiver for better noise immunity. Use a library such as &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/VirtualWire/&quot; rel=&quot;nofollow&quot;&gt;virtualwire&lt;/a&gt; to take care of data decoding/encoding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The common cheap transmitters on ebay allow you to supply a higher voltage to the module for increased transmission power.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively if you want transmitter and receiver in the same module you could go for nrf24l01 based modules. I haven't yet used them myself but they are dirt cheap as well. They operate at 2.4Ghz using a proprietary protocol with retransmit etc built-in. The modules have way more pins than the cheap RF433 modules, but you can also find arduino libraries to interface with them. The cheap kind use an antenna etched straight on to the print board. According to &lt;a href=&quot;http://hallard.me/nrf24l01-real-life-range-test/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; the open air range is 50-80m depending in the data payload in a transmission.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2014-08-19T05:22:37.700" LastActivityDate="2014-08-19T05:22:37.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3844" PostTypeId="2" ParentId="3834" CreationDate="2014-08-19T07:31:27.420" Score="2" Body="&lt;p&gt;Depends on how much data you're sending, what packet structure you want to use, whether you want to spin your own PCBs or use a plug-in module, whether you need a low-power solution, etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that distance, probably a sub-1GHz solution would work best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had good results with the TI range of &lt;a href=&quot;http://www.ti.com/product/CC110L&quot; rel=&quot;nofollow&quot;&gt;Value Line transceivers&lt;/a&gt; as they offload all the packet-handling, sync-words, CRC etc. from the microcontroller.  The modules also handle addressing, and have a &quot;listen before talking&quot; functionality - both of which could be useful with your physical architecture.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Down sides:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You'd probably need to spin your own PCB - they have good reference&#xA;designs. &lt;/li&gt;&#xA;&lt;li&gt;No library for Arduino... but I'd personally rather use a&#xA;transceiver that manages all the low-level comms between the modules&#xA;so I can focus on the application.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3365" LastActivityDate="2014-08-19T07:31:27.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3845" PostTypeId="1" CreationDate="2014-08-19T10:52:08.637" Score="0" ViewCount="430" Body="&lt;p&gt;I got this 8-unit, 7-segment, 2-digit display board with 24 pins and I am wondering how I can interface with this from my Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is labeled ROHM BP-006LH-GC and it has 8 units of the LB202VL LED display. Please see these photos of the board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FcZRY.jpg&quot; alt=&quot;Front of ROHM BP-006LH-GC board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/67bhk.jpg&quot; alt=&quot;Back of ROHM BP-006LH-GC board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vBymz.jpg&quot; alt=&quot;Side of ROHM BP-006LH-GC board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the datasheet for the LB202VL unit and I have been trying to make an independent unit on the board to work but I haven't been successful in setting its display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the LB202VL unit can be found here: &lt;a href=&quot;http://pdf.datasheetarchive.com/datasheetsmain/Datasheets-27/DSA-525461.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://pdf.datasheetarchive.com/datasheetsmain/Datasheets-27/DSA-525461.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me explain how I can work with this and set the display from my Arduino? After having attempted a few times I feel a little lost with this so any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="3630" LastEditorUserId="3630" LastEditDate="2014-08-19T11:18:20.037" LastActivityDate="2016-01-18T07:03:14.603" Title="How to use ROHM LB202VL display (on BP-006LH-GC board) with Arduino?" Tags="|arduino-uno|led|display|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3846" PostTypeId="2" ParentId="3842" CreationDate="2014-08-19T13:26:28.153" Score="2" Body="&lt;p&gt;As stated the IDE's equivalent to the make will compile anything everything it can find, in scope. But its linker has eliminate garbage enabled, hence anything not called or not static will not be linked into the EXE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &quot;avr-objdump -t&quot; to create a map from your elf. And -d for an assembly listing. As to see exactly what is in the EXE, for your self. You need to enable show verbose output of compilation from the IDE's preferences, to display the temporary directory that contains the elf file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\DOCUME~1\mflaga\LOCALS~1\Temp\build6395515806682540138.tmp&amp;gt;C:\projects\Arduino\hardware\tools\avr\bin\avr-objdump -t MP3Shield_Library_Demo.cpp.elf &amp;gt; MP3Shield_Library_Demo_wo_mem.cpp.elf.map&#xA;C:\DOCUME~1\mflaga\LOCALS~1\Temp\build6395515806682540138.tmp&amp;gt;C:\projects\Arduino\hardware\tools\avr\bin\avr-objdump -d MP3Shield_Library_Demo.cpp.elf &amp;gt; MP3Shield_Library_Demo_wo_mem.cpp.elf.lst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did the above and commented out a call to a function member of my library, between subsequent builds. To see that the code was not linked into the assembly.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-08-19T13:26:28.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3847" PostTypeId="1" CreationDate="2014-08-19T18:28:30.827" Score="1" ViewCount="4221" Body="&lt;p&gt;Is it possible to set the Arduino Yun up as an ssh client? If so, how?&lt;/p&gt;&#xA;" OwnerUserId="3633" LastEditorUserId="37" LastEditDate="2014-08-19T20:32:25.873" LastActivityDate="2014-09-19T09:06:56.907" Title="Arduino yun as ssh client" Tags="|arduino-yun|ssh|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3848" PostTypeId="1" AcceptedAnswerId="3849" CreationDate="2014-08-19T18:38:28.543" Score="1" ViewCount="895" Body="&lt;p&gt;I have an ArbotiX-m Arduino board, and have followed the &lt;a href=&quot;http://learn.trossenrobotics.com/arbotix/7-arbotix-quick-start-guide&quot; rel=&quot;nofollow&quot;&gt;setup guide&lt;/a&gt; on Trossen robotics all the way to the 5th step. I have a Mac running OS X 10.10 and use Arduino 1.0.5. I installed the necessary drivers and copied the files to the Sketchbook directory. When I try to load the sample ArbotiXBlink program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pin 0 maps to the USER LED on the ArbotiX Robocontroller.&#xA;int led = 0;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It verifies just fine, but when I click upload, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Binary sketch size: 1,088 bytes (of a 65,536 byte maximum)&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; The board was trying to get power from the 5V instead of USB&lt;/p&gt;&#xA;" OwnerUserId="3632" LastEditorUserId="3632" LastEditDate="2015-01-25T19:31:39.577" LastActivityDate="2016-01-25T08:27:49.550" Title="ArbotiX-M Problem uploading to the board" Tags="|avrdude|mac-os|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3849" PostTypeId="2" ParentId="3848" CreationDate="2014-08-19T20:55:15.557" Score="2" Body="&lt;p&gt;I figured why my board wasn't responding! Apparently, the power pin was connected to the 5V supply instead of usb. Silly me!&lt;/p&gt;&#xA;" OwnerUserId="3632" LastActivityDate="2014-08-19T20:55:15.557" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3850" PostTypeId="1" AcceptedAnswerId="17527" CreationDate="2014-08-19T21:24:02.897" Score="3" ViewCount="10481" Body="&lt;p&gt;When I remove the SD card and try to open a file, I can detect the error properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how do I detect that the card has been replaced after an error? My first thought was to call &lt;code&gt;SD.begin()&lt;/code&gt; again but it appears that this function returns true exactly once and false thereafter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simplified example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  SD.begin(pin); // called exactly once. Works.&#xA;}&#xA;void loop() {&#xA;  // stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this does not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  SD.begin(pin); // first time calling this function: works.&#xA;}&#xA;void loop() {&#xA;  delay(1000);&#xA;  SD.begin(pin); // always fails&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd rather not reset the microcontroller just for this.&lt;/p&gt;&#xA;" OwnerUserId="889" LastActivityDate="2015-11-06T10:53:13.203" Title="SD.begin() fails second time" Tags="|sd-card|reliability|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3851" PostTypeId="1" AcceptedAnswerId="3853" CreationDate="2014-08-19T21:58:41.283" Score="2" ViewCount="1256" Body="&lt;p&gt;I am making a &quot;Electronic Dice&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 7 LEDs to form the output, and this works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is getting a random result on the output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int die_face = 1;&#xA;&#xA;void loop()&#xA;{&#xA;    if (analogRead(BUTTON_PIN) == HIGH)&#xA;    {&#xA;        paintDieFace((die_face % 6) + 1);&#xA;    }&#xA;&#xA;    die_face += 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, that roughly 95% of the time I get a 1.&lt;br&gt;&#xA;Most of the time it's not a 1, it's a 2, or very rarely a 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried paintDieFace() with millis()%6+1 too, but always get the same result.&#xA;When it's painted with random(1,7); I get 1, 2 or 3 100% of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this some sort of timing issue?  I just don't get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to clarify - The paintDieFace() function is working perfectly, I'm logging the result to serial too.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="37" LastEditDate="2014-08-19T23:30:49.963" LastActivityDate="2014-09-19T02:02:38.973" Title="Getting a random number for electronic dice" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3852" PostTypeId="2" ParentId="3851" CreationDate="2014-08-19T23:53:39.810" Score="0" Body="&lt;p&gt;I've had better success with this version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not work out the problem with the first version.  Although I did find the rear legs of the push-button were lighting up a LED - but only when pushed.  As the result is only displayed when the button is not pushed, I don't see how it could make a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the modulus of 6 is a problem, perhaps this does really output more ones than anything else.  Obviously looping the dice_number variable 1-&gt;6 removes the necessity for it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LEDS_34_PIN 2  // Output pins used&#xA;#define LEDS_16_PIN 3&#xA;#define LEDS_25_PIN 4&#xA;#define LED_7_PIN   5&#xA;&#xA;#define BUTTON_PIN  6  // Input&#xA;&#xA;&#xA;unsigned char dice_number  = 0;     // this is what will be shown on the die face&#xA;&#xA;void setup()&#xA;{&#xA;    // Tell the Arduino we're writing to some pins&#xA;    pinMode(LEDS_34_PIN, OUTPUT);&#xA;    pinMode(LEDS_16_PIN, OUTPUT);&#xA;    pinMode(LEDS_25_PIN, OUTPUT);&#xA;    pinMode(LED_7_PIN,   OUTPUT);&#xA;&#xA;    // ... and reading a button&#xA;    pinMode(BUTTON_PIN, INPUT);&#xA;&#xA;&#xA;    // Do a testing-dance first&#xA;    for (int i=1; i&amp;lt;=6; i++)&#xA;    {&#xA;        paintDieFace(i);&#xA;        delay(500);&#xA;    }&#xA;    paintDieFace(0);&#xA;&#xA;}&#xA;&#xA;&#xA;// Show a dice-dot-style number&#xA;// based on LEDs laid out like&#xA;//    [1]     [4]&#xA;//    [2] [7] [5]&#xA;//    [3]     [6]&#xA;void paintDieFace(unsigned char number)&#xA;{&#xA;    // Turn off all LEDs&#xA;    digitalWrite(LEDS_34_PIN, LOW); &#xA;    digitalWrite(LEDS_16_PIN, LOW); &#xA;    digitalWrite(LEDS_25_PIN, LOW); &#xA;    digitalWrite(LED_7_PIN,   LOW);&#xA;&#xA;    if (number == 1 || number == 3 || number == 5 || number &amp;gt; 6)&#xA;    {&#xA;        digitalWrite(LED_7_PIN, HIGH);&#xA;    }&#xA;    if (number &amp;gt;= 2)&#xA;    {&#xA;        // LEDs 3 &amp;amp; 4 are on for all numbers greater-than 1&#xA;        digitalWrite(LEDS_34_PIN, HIGH); &#xA;    }&#xA;    if (number &amp;gt;= 4)&#xA;    {&#xA;        // LEDs 1 &amp;amp; 6 are on for 4, 5 and 6&#xA;        digitalWrite(LEDS_16_PIN, HIGH); &#xA;    }&#xA;    if (number &amp;gt;= 6)&#xA;    {&#xA;        // LEDs 2 &amp;amp; 5 are only on for 6 (or more)&#xA;        digitalWrite(LEDS_25_PIN, HIGH); &#xA;    }&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    int button_pushed = digitalRead(BUTTON_PIN);    &#xA;    if (button_pushed == HIGH)&#xA;    {&#xA;        // The user has pushed the button, change the die reading &#xA;        paintDieFace(dice_number);&#xA;        delay(20);  // flicker the LEDs if button held in&#xA;    }&#xA;&#xA;    dice_number += 1;&#xA;    if (dice_number == 7)&#xA;        dice_number = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-08-19T23:53:39.810" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3853" PostTypeId="2" ParentId="3851" CreationDate="2014-08-20T01:12:54.000" Score="2" Body="&lt;p&gt;First of all, look at this line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (analogRead(BUTTON_PIN) == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You probably want to use &lt;em&gt;&lt;code&gt;digitalRead()&lt;/code&gt;&lt;/em&gt;. Note that it is okay to use digitalRead() on an analog pin, just make sure to use the right pin number (&lt;code&gt;A0&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/3a8ad75bcef5932cfc81c4746a87ddbdbd7e6402/hardware/arduino/cores/robot/Arduino.h&quot; rel=&quot;nofollow&quot;&gt;Arduino Source&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define HIGH 0x1&#xA;#define LOW  0x0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Ignore the &lt;code&gt;0x&lt;/code&gt;, that is just specifying that it's hexadecimal. However, 0 and 1 are the same in any base)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, really, this function is only activated when &lt;code&gt;analogRead()&lt;/code&gt; returns 1, which could possibly cause a problem later if it doesn't check at the right time. &lt;strong&gt;Note:&lt;/strong&gt; now is a good time to remind you about debouncing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your actual code, since you want it to be simple, I suggest you forget that code that you wrote. &lt;a href=&quot;http://arduino.cc/en/reference/random&quot; rel=&quot;nofollow&quot;&gt;Arduino has a built in random library&lt;/a&gt;, which works unless you have some special need for a random number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your final code should look like something like this in the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    if (analogRead(BUTTON_PIN) == HIGH) {&#xA;        paintDieFace(random(1, 6);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you should also use this code here in your setup (make sure that analog pin is floating: nothing should be attached to it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;randomSeed(analogRead(A1));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It actually isn't random, just &lt;em&gt;pseudo-random&lt;/em&gt;. That means it relies on an equation to generate what seem to be random numbers. Because there has to be a default value of where the equation starts (the &lt;em&gt;seed&lt;/em&gt;), it will repeat the same numbers &lt;em&gt;every time&lt;/em&gt; you run it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're wondering how this works, know that the analog pin is affected by a ton of external factors when there is no other electric signal attached.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-08-20T01:25:53.057" LastActivityDate="2014-08-20T01:25:53.057" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3855" PostTypeId="1" AcceptedAnswerId="3857" CreationDate="2014-08-20T04:06:02.270" Score="2" ViewCount="3330" Body="&lt;p&gt;In context of getting the MCU on Pro Mini and ATMega2560 (chip is ATmega328 and ATMega 2560) to &lt;strong&gt;sleep and power down modes,&lt;/strong&gt; so as to run on &lt;strong&gt;one set of battery for months&lt;/strong&gt;, appreciate idea and comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially, I looked at web postings and get the following general idea. Did I miss anything?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is sleep mode done via ATMel factory library, Arduino-level user contributed library, or the Arduino IDE? Many web posting are along the line of getting it partially working but only at half expected current reduction, etc. That is, current do reduced, but, not enough. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there several such library? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are they? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which one is better support and more functions? (no need for easy to use, can do registers programming, when needed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance &lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-20T14:37:01.907" LastActivityDate="2015-07-05T22:07:33.743" Title="Sleep mode and months of operation on small battery" Tags="|power|sleep|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3856" PostTypeId="1" AcceptedAnswerId="3865" CreationDate="2014-08-20T04:24:21.277" Score="0" ViewCount="577" Body="&lt;p&gt;In context of Pro Mini and ATMega2560 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fuses, as documented in chip factory doc are complex topics (I have not really used it before), appreciate pointers and advises, to narrow down those that are &lt;strong&gt;needed for contexted task&lt;/strong&gt; and left un-needed in their default modes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which fuses are used within context of the IDE in &lt;strong&gt;general&lt;/strong&gt;, and in specific of software &lt;strong&gt;loading&lt;/strong&gt; via bootloader and ISP? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which fuses related to sleep and power down modes, in context that individual chip modules can be set to various power-saving modes via registers. Does fuses play a part in getting the power-saving effect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-20T05:23:01.023" LastActivityDate="2014-08-20T14:24:09.477" Title="MCU fuses used by Pro Mini and ATMega 2560 and power down" Tags="|power|fuses|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3857" PostTypeId="2" ParentId="3855" CreationDate="2014-08-20T04:43:09.787" Score="4" Body="&lt;p&gt;Have a read through the Jeelabs blog which documents the author's very successful attempt at making a very low power wireless sensor node that can run for months off coin cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://jeelabs.org&quot; rel=&quot;nofollow&quot;&gt;http://jeelabs.org&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a library based on this project called Jeelib:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://jeelabs.net/pub/docs/jeelib/&quot; rel=&quot;nofollow&quot;&gt;http://jeelabs.net/pub/docs/jeelib/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jeelib contains a class called &lt;code&gt;Sleepy&lt;/code&gt; that allows for easy sleeping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rocketscream did a thorough test of the current consumptions with the different modes here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/&quot; rel=&quot;nofollow&quot;&gt;http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to them, you can get the ATMega328P down to 1.7uA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you do something about the power supply on a normal Arduino board you won't be able to extend the battery life by much at all. See my answer here for some more details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3688/arduino-powering-from-9v-battery/3689#3689&quot;&gt;Arduino powering from 9V battery&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-20T04:43:09.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3858" PostTypeId="1" CreationDate="2014-08-20T05:08:19.007" Score="1" ViewCount="712" Body="&lt;p&gt;To make LCD display, Pro Mini and ATMega2560 to run on one set of battery for months, appreciate idea and comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which LCD to use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which LCD chip controller chip (hide inside the LCD) has better power saving mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which library with functions of power saving and also can put out &lt;strong&gt;VERY beautiful&lt;/strong&gt; per-programmed display, like multiple fonts, different fonts size, some graphics like circle, rectangles, color fills, gradual-color-changing background with text and graphic at 'foreground' (as in PC power point style)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under context of  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Small Mono chrome 2 lines text display&lt;/li&gt;&#xA;&lt;li&gt;3 inches mono chrome graphic 128 x 64 or similar      &lt;/li&gt;&#xA;&lt;li&gt;3 inches color graphic, 320 x240 or similar&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-09-20T05:15:31.540" Title="LCD display under power saving mode" Tags="|power|lcd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3859" PostTypeId="1" AcceptedAnswerId="38337" CreationDate="2014-08-20T06:17:48.963" Score="0" ViewCount="5111" Body="&lt;p&gt;Where is a simple program that demonstrates unidirectional data transmission over a pair of nRF24L01+ radios?  It should have adequate output so that a beginner can determine that the transmission is working properly.&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2017-05-13T16:35:12.107" Title="&quot;Hello World&quot; program for nRF24L01+?" Tags="|nrf24l01+|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3860" PostTypeId="2" ParentId="3859" CreationDate="2014-08-20T08:01:47.757" Score="1" Body="&lt;p&gt;Here are several &quot;getting started&quot; articles that contain simple programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://tmrh20.github.io/RF24&quot; rel=&quot;nofollow&quot;&gt;http://tmrh20.github.io/RF24&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/nrf24-arduino/VaC2U5D1o_s&quot; rel=&quot;nofollow&quot;&gt;https://groups.google.com/forum/#!topic/nrf24-arduino/VaC2U5D1o_s&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html&quot; rel=&quot;nofollow&quot;&gt;http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3365" LastEditorUserId="11529" LastEditDate="2015-08-18T12:37:03.293" LastActivityDate="2015-08-18T12:37:03.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3861" PostTypeId="1" CreationDate="2014-08-20T08:18:51.747" Score="1" ViewCount="405" Body="&lt;p&gt;I have an Arduino Mega 2560  with a GPRS seeedstudio shield and an USB Host CircuitsAtHome shield which work fine when powered with USB or with an adjustable voltage regulator set at 8V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I set this voltage regulator at 7V (minimum voltage from the spec to get the better efficiency) I am still reading 5V and 3.3V on the pins of the Arduino and all the leds of the Arduino and the GPRS shield seems fine but the USB Host CircuitsAtHome shield seems to not work properly.&#xA;I cannot debug it using the console because if I plug the USB cable, everything works fine...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why 7V fail while 8V is ok?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The adjustable voltage regulator can provide up to 5A which is plenty.&lt;/p&gt;&#xA;" OwnerUserId="1009" LastActivityDate="2014-08-20T23:53:44.930" Title="Mega 2560 powered with 7V don't work correctly" Tags="|arduino-mega|power|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3862" PostTypeId="2" ParentId="3847" CreationDate="2014-08-20T08:54:26.690" Score="1" Body="&lt;p&gt;You need to install package &lt;code&gt;openssh-client&lt;/code&gt;: it's available in the &lt;a href=&quot;http://downloads.arduino.cc/openwrtyun/1/packages/index.html&quot; rel=&quot;nofollow&quot;&gt;package list&lt;/a&gt;. See &lt;a href=&quot;http://arduino.cc/en/Tutorial/YunPackageManager&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; about how to install optional packages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can call &lt;code&gt;ssh&lt;/code&gt; on the Linux side using &lt;code&gt;Process&lt;/code&gt; from the &lt;code&gt;Bridge&lt;/code&gt; Arduino library.&#xA;Best is when you execute single or grouped commands using a syntax as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh user@your_other_host 'echo 1; echo 2'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Managing an open ssh session is possible but I think may be troublesome, so avoid it if you can.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-08-20T08:54:26.690" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3863" PostTypeId="2" ParentId="3587" CreationDate="2014-08-20T08:56:43.893" Score="3" Body="&lt;p&gt;Use command &lt;code&gt;reset-mcu&lt;/code&gt;: it's a linux script that resets the 32u4 via GPIO&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-08-20T08:56:43.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3864" PostTypeId="1" AcceptedAnswerId="3879" CreationDate="2014-08-20T10:58:38.727" Score="0" ViewCount="657" Body="&lt;p&gt;Im using a variant of Arduino Due embedded on a ARM (Udoo). And I have connected a Medlab SPO2 Pearl 200 sensor to Serial1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im just trying to parse input from Serial1 to Serial, in a human-readable format (Hexadecimal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The protocol is described in this image:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/XxZJt.png&quot; alt=&quot;Protocol SPo2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And using this Arduino code I reveice two times the &quot;no finger detected line&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int lineLength = 16;&#xA;int spo2read[16];&#xA;int readed = 0;&#xA; if (Serial1.available()) {&#xA;    int inByte = Serial1.read();&#xA;    if (readed &amp;lt; lineLength) {&#xA;      spo2read[readed] = inByte;&#xA;    }&#xA;    readed++;&#xA;    if (readed == lineLength) {&#xA;      Serial.print(&quot;SPO2: &quot;);&#xA;      for (int i = 0; i &amp;lt;= lineLength; i++) {&#xA;        Serial.print(spo2read[i], HEX);&#xA;        Serial.print( delimeter);&#xA;      }&#xA;      Serial.println(&quot;&quot;);&#xA;&#xA;      readed = 0;&#xA;    }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output with no finger is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPO2: A,FB,2,F9,0,FA,0,FC,A,FB,2,F9,0,FA,0,FC,0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Buf if I put my finger, all is messed up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPO2: 7C,74,6B,62,5A,51,4A,42,3B,34,30,2E,2F,30,31,33,0,&#xA;SPO2: 36,38,3B,3E,3D,3C,3C,3B,3B,38,34,2F,2C,2B,2B,29,0,&#xA;SPO2: 24,21,1E,1D,1E,1E,1F,20,22,24,26,28,2B,2D,30,32,0,&#xA;SPO2: 35,37,39,3C,3E,40,42,44,45,4A,4F,53,55,57,59,5C,0,&#xA;SPO2: 5E,60,61,F9,0,FA,0,FC,1A,FB,0,F8,62,62,62,63,0,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sensor doesn't sends a \n or \r so I don't know exactly how to parse the data&lt;/p&gt;&#xA;" OwnerUserId="3641" LastEditorUserId="3641" LastEditDate="2014-08-20T11:12:50.453" LastActivityDate="2014-08-21T07:53:00.903" Title="Parse data from sensor without delimeters" Tags="|serial|sensors|arduino-due|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3865" PostTypeId="2" ParentId="3856" CreationDate="2014-08-20T14:24:09.477" Score="1" Body="&lt;p&gt;The data sheets are the ultimate source. However, that may be a bit overwhelming. I find the below great resources very helpful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;Online Fuse Calculator&lt;/a&gt; There are many others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;a href=&quot;http://translate.google.com/translate?hl=en&amp;amp;sl=ja&amp;amp;u=http://yuki-lab.jp/hw/avrdude-GUI/&amp;amp;prev=/search%3Fq%3Davrdude-GUI%2Byuki-lab.jp%26client%3Dfirefox-a%26hs%3Drmn%26rls%3Dorg.mozilla:en-US:official%26channel%3Dsb%26biw%3D1160%26bih%3D724&quot; rel=&quot;nofollow&quot;&gt;avrdude-GUI&lt;/a&gt;&#xA;there are many others out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) the .\arduino-1.5.7\hardware\arduino\avr\boards.txt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.bootloader.low_fuses=0xFF&#xA;uno.bootloader.high_fuses=0xDE&#xA;uno.bootloader.extended_fuses=0x05&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;4) I also read the fuses from any device before I stomp over them. And check into what each mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for narrowing down the features the Online Calculator very helpful to start with and then read into the data sheet for ones of interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the most part there have several questions and answers for low power modes, using interrupts to re-awake. Where there appears to no direct fuses to save power, outside of clock source and speed. Arguably Brown Out detect is a fuse, but that is not directly related to saving power.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-08-20T14:24:09.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3866" PostTypeId="2" ParentId="3864" CreationDate="2014-08-20T15:11:12.323" Score="0" Body="&lt;p&gt;actually I don't think it is all mixed up&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as per geometrikal use the markers to parse the data stream&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe your above sample data started mid-stream during the 0xF8 of the wave form.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;F8,...&#xA;...,7C,74,6B,62,5A,51,4A,42,3B,34,30,2E,2F,30,31,33,0,36,38,3B,3E,3D,3C,3C,3B,3B,38,34,2F,2C,2B,2B,29,0,24,21,1E,1D,1E,1E,1F,20,22,24,26,28,2B,2D,30,32,0,35,37,39,3C,3E,40,42,44,45,4A,4F,53,55,57,59,5C,0,5E,60,61&#xA;F9,0&#xA;FA,0&#xA;FC,1A&#xA;FB,0&#xA;F8,62,62,62,63,0,...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe reading this as a finite length does not portray the data for easy interpetation. Given that 0xF8 is a variable length protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the reparse of your data initially appears to be legitimate parse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said I do read the SPO2, Pulse as zero. Where it may be likely the sensor has not finished its reading and auto gain cycles.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-08-20T15:34:20.397" LastActivityDate="2014-08-20T15:34:20.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3868" PostTypeId="2" ParentId="3850" CreationDate="2014-08-20T17:27:52.243" Score="1" Body="&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;software reset&lt;/strong&gt;, while inelegant, was much simpler to implement and debug than trying to add &quot;retry&quot; type functionality to &lt;code&gt;SD.h&lt;/code&gt;. The other alternative would be to access &lt;code&gt;SDFatLib.h&lt;/code&gt; or the other lower-level stuff (which &lt;code&gt;SD.h&lt;/code&gt; is a wrapper for) directly, so if someone has that solution, I'll accept it instead of this one.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Original&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Here is something, which &lt;s&gt;is working well enough for me at the moment:&lt;/s&gt; does not reliably work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool SDState{false};&#xA;File LogFile;&#xA;&#xA;bool trySDCard(void)&#xA;{&#xA;    // sanity check: maybe the SD card is actually here?&#xA;    LogFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;    delay(10);&#xA;    if (LogFile) {&#xA;        LogFile.close();&#xA;        return true;&#xA;    }&#xA;    int8_t counter{10};&#xA;    while (counter &amp;amp;&amp;amp; !SDState) {&#xA;        SDState = SD.begin(TFT_CARD_CS);&#xA;        Serial.print(counter);&#xA;        Serial.print(&quot; &quot;);&#xA;        counter--;&#xA;        delay(100);&#xA;    }   &#xA;    Serial.print(&quot;SD: &quot;);&#xA;    Serial.println(SDState);&#xA;    return SDState;&#xA;}&#xA;&#xA;void setup() {&#xA;    SDState = SD.begin(TFT_CARD_CS);&#xA;    Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;    // NB. Simplified a lot (exitMenuMessage(string) is my custom function defined elsewhere)&#xA;    switch (state) {&#xA;        case SD_RETRY:&#xA;            exitMenuMessage(trySDCard() ? &quot;found SD card&quot; : &quot;no SD card&quot;);&#xA;            break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;Seems to work&lt;/s&gt; Sometimes works if I insert the SD card &lt;em&gt;while&lt;/em&gt; &lt;code&gt;trySDCard()&lt;/code&gt; is running.&lt;/p&gt;&#xA;" OwnerUserId="889" LastEditorUserId="889" LastEditDate="2014-08-24T15:34:32.413" LastActivityDate="2014-08-24T15:34:32.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3871" PostTypeId="2" ParentId="3861" CreationDate="2014-08-20T21:58:09.453" Score="2" Body="&lt;p&gt;The Voltage-Regulator has a dropout-voltage of 1,2V, but in line to the regulator is a diode, which adds another minimum 0,7V (dont know the exact part number, so i guessed the voltage of a Si-diode at ~1A). So you have to supply at least 5 + 1,2 + 0,7 = 6,9V. I presume the circuit doesnt draw a constant current all the time, so from time to time the regulator cant supply the 5V because you sink under the necessary dropout-voltage of the rehulator/diode-combination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; Use 8V  or bypass the Diode D1 (with a solder-bridge) and use 7V if its a must and you are sure the input-polarity is always correct.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino-Mega-2560-schematic: &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-mega2560_R3-sch.pdf&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/uploads/Main/arduino-mega2560_R3-sch.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3654" LastActivityDate="2014-08-20T21:58:09.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3872" PostTypeId="1" AcceptedAnswerId="3873" CreationDate="2014-08-20T23:15:07.613" Score="6" ViewCount="7806" Body="&lt;p&gt;I'm trying to datalog to a EyeFi SD card by writing to a file with a jpg extension. Here's that portion of my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// see if the directory exists, create it if not.&#xA;if( !SD.exists(&quot;/DCIM/100NIKON&quot;) ) &#xA;{&#xA;  if( SD.mkdir(&quot;/DCIM/100NIKON&quot;) ) &#xA;  {&#xA;    Serial.print(&quot;File directory created: &quot;);&#xA;  } &#xA;  else {&#xA;    error(&quot;File directory not created&quot;);&#xA;  }&#xA;}&#xA;else&#xA;{&#xA;  Serial.print(&quot;File directory exists: &quot;);&#xA;}&#xA;&#xA;// Test file&#xA;char filename[] = &quot;DSCN0000.JPG&quot;;&#xA;&#xA;if (! SD.exists(filename))&#xA;{&#xA;  logfile = SD.open(filename, FILE_WRITE); // only open a new file if it doesn't exist&#xA;}&#xA;&#xA;if (! logfile)&#xA;{&#xA;  error(&quot;Couldnt create file&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino creates the directory, but the file is still saved to the root.  I would love some help or tips on this.&lt;/p&gt;&#xA;" OwnerUserId="3554" LastActivityDate="2014-08-20T23:48:19.737" Title="How do I specify a working directory when saving to SD card?" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3873" PostTypeId="2" ParentId="3872" CreationDate="2014-08-20T23:48:19.737" Score="5" Body="&lt;p&gt;You're creating a directory, and then &lt;em&gt;not writing the file into it&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to change the filename to &lt;code&gt;/DCIM/100NIKON/DSCN0000.JPG&quot;;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;SD.open()&lt;/code&gt; takes the &lt;strong&gt;full filepath to the file&lt;/strong&gt;, not just the file*name*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://arduino.cc/en/Reference/SD&quot; rel=&quot;noreferrer&quot;&gt;Arduino Docs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The file names passed to the SD library functions can include paths&#xA;  separated by forward-slashes, /, e.g. &quot;directory/filename.txt&quot;.&#xA;  Because the &lt;strong&gt;working directory is always the root of the SD card&lt;/strong&gt;, a&#xA;  name refers to the same file whether or not it includes a leading&#xA;  slash (e.g. &quot;/file.txt&quot; is equivalent to &quot;file.txt&quot;). As of version&#xA;  1.0, the library supports opening multiple files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(emphasis mine)&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-08-20T23:48:19.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3874" PostTypeId="2" ParentId="3861" CreationDate="2014-08-20T23:53:44.930" Score="1" Body="&lt;p&gt;You need to be clear about how you are hooking this up. Are you feeding 7V into the Vin on the Arduino? If so, then the voltage regulator on the Arduino is attempting to regulate 7V down to 5V. As Echo says, 7V isn't quite enough for the built-in voltage regulator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your voltage regulator outputs clean, noise and ripple free regulated voltage, you could set it to 5.0 volts and feed it directly into the Arduino's 5V line, bypassing the regulator on the Arduino completely. If you do this you need to make absolutely sure that you give it exactly +5V though, as you will likely destroy the board if you go much over 5V or wire it backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's a switching regulator then you might need to add a choke to the output of the regulator to get rid of high frequency noise on its output.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-08-20T23:53:44.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3875" PostTypeId="1" CreationDate="2014-08-21T00:11:34.300" Score="0" ViewCount="1745" Body="&lt;p&gt;I have an Arduino sketch with a timer interrupt class and would like to place the TIMER2Services() function in the TimerTwoTest.ino file for easy access. On compile I get a multiple definition of tmb2 error in the .ino TIMER2Services() function. I have tried all the variations I can think of but no luck. Is there a way to do this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TimerTwoTest.cpp.o: In function `TIMER2Services()':&#xA;D:\Arduino157/TimerTwoTest.ino:41: multiple definition of `tmb2'&#xA;TimerTwo.cpp.o:C:\Users\...\build8577138580185682113.tmp/TimerTwo.cpp:10: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;collect2.exe:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwo.h:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Tmb2&#xA;{&#xA;  public:&#xA;  void initTIMER2(unsigned int Hz, unsigned int ulPeriod);&#xA;  void resetTIMER2(unsigned int Hz, unsigned int ulPeriod);&#xA;  TIMER2_TYPE getPeriodTIMER2(void);&#xA;  void activeTIMER2 (void);&#xA;  private:&#xA;}tmb2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwo.cpp:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern void TIMER2Services(void);&#xA;&#xA;[this function is line 10 for the error]&#xA;void Tmb2::initTIMER2(unsigned int Hz, unsigned int ulPeriod){  //setperiod and enable interrupt&#xA;  if (Hz){&#xA;    ulPeriod = 1000/Hz;    //if Hz &amp;gt; 0 use frequency microseconds&#xA;  }&#xA;  Timer2.attachInterrupt(TIMER2Services).setPeriod(ulPeriod).start();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwoTest.ino:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned long burpCount = 0;&#xA;&#xA;//This routine services the interrupt&#xA;void TIMER2Services(void){&#xA;  burpCount++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3655" LastEditorUserId="220" LastEditDate="2014-08-21T00:49:32.130" LastActivityDate="2014-08-22T20:22:20.780" Title="Calling a function that is outside of a class from inside" Tags="|interrupt|timers|class|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3876" PostTypeId="2" ParentId="3875" CreationDate="2014-08-21T04:09:51.540" Score="2" Body="&lt;p&gt;The problem is your definition of tmb2.  You're declaring the variable in the header file, and not the C(++) file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please try this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwo.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __TIMER_TWO_H__&#xA;#define __TIMER_TWO_H__&#xA;&#xA;extern void TIMER2Services(void);&#xA;&#xA;class Tmb2&#xA;{&#xA;    public:&#xA;        void initTIMER2(unsigned int Hz, unsigned int ulPeriod);&#xA;        void resetTIMER2(unsigned int Hz, unsigned int ulPeriod);&#xA;        TIMER2_TYPE getPeriodTIMER2(void);&#xA;        void activeTIMER2 (void);&#xA;    private:&#xA;};&#xA;&#xA;#endif // #ifndef __TIMER_TWO_H__&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The #ifndef TIMER stuff saves you getting multiple definitions from header files if they're included more than once.  There's other ways to do this, but this is simple and well-known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwo.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerTwo.h&quot;&#xA;&#xA;void Tmb2::initTIMER2(unsigned int Hz, unsigned int ulPeriod)&#xA;{  &#xA;    //setperiod and enable interrupt&#xA;    if (Hz)&#xA;    {&#xA;        ulPeriod = 1000/Hz;    //if Hz &amp;gt; 0 use frequency microseconds&#xA;    }&#xA;    Timer2.attachInterrupt(TIMER2Services).setPeriod(ulPeriod).start();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TimerTwoTest.ino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerTwo.h&quot;&#xA;&#xA;Tmb2 tmb2;&#xA;volatile unsigned long burpCount = 0;&#xA;&#xA;// This routine services the interrupt&#xA;void TIMER2Services(void)&#xA;{&#xA;    burpCount++;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    tmb2.initTIMER2(blah1,blah2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the sake of neatness, I'd move TIMER2Services into class Tmb2 as a static function... if possible.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2014-08-22T20:22:20.780" LastActivityDate="2014-08-22T20:22:20.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3877" PostTypeId="2" ParentId="3858" CreationDate="2014-08-21T04:26:21.260" Score="1" Body="&lt;p&gt;Use an eInk/ePaper style display, which uses no power while the display is not changing.  These come in monochrome greyscale, and have excellent readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solves only part of your problem as you still need to power the CPU.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-08-21T04:26:21.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3878" PostTypeId="2" ParentId="3198" CreationDate="2014-08-21T04:39:38.763" Score="1" Body="&lt;p&gt;Those little 16x2 LCDs are quite prone to power fluctuations.  Even powered solely by an Arduino I've seen them run OK for a few minutes than turn to showing gibberish.  Ensure you have good power connections, bring your power in as close as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe a capacitor across the power input to the display might help.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-08-21T04:39:38.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3879" PostTypeId="2" ParentId="3864" CreationDate="2014-08-21T07:53:00.903" Score="0" Body="&lt;p&gt;I have used the source code available on the Medlab web, and do some &quot;modifications&quot; to be Arduino compatible.&#xA;I dont wanna the waveform data, because my final program will do the waveforms acording the data received, so I don't &quot;listen&quot; to the waveform packet&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean startbyte = false; &#xA;byte buf = 0;&#xA;&#xA;  while (Serial1.available() &amp;gt; 3)&#xA;  {&#xA;    buf = Serial1.read();&#xA;    if (buf &amp;gt; 0xfc)&#xA;    {&#xA;      buf = Serial1.read();&#xA;    }&#xA;&#xA;&#xA;    if ((startbyte == true) &amp;amp;&amp;amp; buf &amp;gt; 0xF7)&#xA;    {&#xA;      startbyte = false;&#xA;    }&#xA;&#xA;    if (buf &amp;gt; 0xf7 &amp;amp;&amp;amp; startbyte == false)&#xA;    {&#xA;      //startbyte = true;&#xA;      if (buf == 0xf8)&#xA;      {&#xA;        startbyte = true;&#xA;      }&#xA;&#xA;      if (buf &amp;gt; 0xf8)&#xA;      {&#xA;        byte RX = buf;&#xA;        buf = Serial1.read();&#xA;        if (buf &amp;gt; 0xfc)&#xA;        {&#xA;          buf = Serial1.read();&#xA;        }&#xA;&#xA;        if (RX == 0xf9)&#xA;        {&#xA;          //SPO = buf;&#xA;          Serial.print(&quot;SV:&quot;);&#xA;          Serial.print(buf, DEC);&#xA;          Serial.println();&#xA;        }&#xA;&#xA;        else if (RX == 0xfa)&#xA;        {&#xA;          //Pulse = buf;&#xA;          Serial.print(&quot;SPV:&quot;);&#xA;          Serial.print(buf, DEC);&#xA;          Serial.println();&#xA;        }&#xA;        else if (RX == 0xfb)&#xA;        {&#xA;          //Status = buf;&#xA;          Serial.print(&quot;StV:&quot;);&#xA;          Serial.print(buf, DEC);&#xA;          Serial.println();&#xA;        }&#xA;&#xA;        else if (RX == 0xfc)&#xA;        {&#xA;          //quality = buf;&#xA;          Serial.print(&quot;QV:&quot;);&#xA;          Serial.print(buf, DEC);&#xA;          Serial.println();&#xA;          Serial.println();&#xA;        }&#xA;        else { }&#xA;      }&#xA;&#xA;&#xA;    }&#xA;    else if (startbyte == true)&#xA;    {&#xA;     //Waveform data&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3641" LastActivityDate="2014-08-21T07:53:00.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3880" PostTypeId="1" CreationDate="2014-08-21T10:59:43.310" Score="0" ViewCount="2129" Body="&lt;p&gt;I'm using my Arduino Leonardo as a Mouse but I'm experimenting a strange behaviour.&#xA;I put my mouse at (-1, -1) (absolute) coordinates and then I execute this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Move.move(com[curr_cmd_id].x, com[curr_cmd_id].y, 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where that point is (334, 180) (relative coords) (and I checked it through Serial console)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the pointer is actually moving to the right but then it stops. Let's say it reaches the point (334, 0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mouse.move(com[curr_cmd_id].x, 0, 0);&#xA;delay(500);&#xA;Mouse.move(0, com[curr_cmd_id].y, 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but still the same behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then finally I tried this one (which it actually solves my problem but it's a dirty solution):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i;&#xA;for(i=0; i&amp;lt;com[curr_cmd_id].x; i++){&#xA;  Mouse.move(1,0,0);&#xA;  delay(1);&#xA;}&#xA;for(i=0; i&amp;lt;com[curr_cmd_id].y; i++){&#xA;  Mouse.move(0,1,0);&#xA;  delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could anybody help me in understanding what's going on here? How can I achieve a simple and direct relative movement for my pointer?&#xA;Thanks you in advance!!&lt;/p&gt;&#xA;" OwnerUserId="3663" LastActivityDate="2016-01-27T13:16:25.637" Title="Wrong Mouse.move() output in Arduino Leonardo" Tags="|programming|arduino-leonardo|sketch|pointer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3881" PostTypeId="1" AcceptedAnswerId="3884" CreationDate="2014-08-21T12:14:28.757" Score="9" ViewCount="36195" Body="&lt;p&gt;I'm trying to make an opening and closing little door that should open or close every 12 hours. I was wondering if I could just make a small looping script with a delay() for 12 hours, delay(43 200 000 000); I guess? However, I have no idea if that's possible and/or recommendable. Some feedback/alternatives(if needed) would be nice :)&lt;/p&gt;&#xA;" OwnerUserId="3665" LastActivityDate="2019-06-02T06:34:05.537" Title="Very long delay() possible?" Tags="|arduino-uno|timers|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3882" PostTypeId="2" ParentId="3881" CreationDate="2014-08-21T13:03:07.543" Score="1" Body="&lt;p&gt;Do you have a sleep(unsigned int seconds) available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, this would allow you to delay() a very long time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (unsigned int bigloop=0; bigloop&amp;lt;65535; bigloop++)&#xA;{&#xA;   for (unsigned int smallloop=0; smallloop&amp;lt;65535; smallloop++)&#xA;   {&#xA;      for (unsigned int tinyloop=0; tinyloop&amp;lt;65535; tinyloop++)&#xA;      {&#xA;         delay(65535);&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3621" LastActivityDate="2014-08-21T13:03:07.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3883" PostTypeId="2" ParentId="3881" CreationDate="2014-08-21T13:04:11.093" Score="7" Body="&lt;p&gt;&lt;code&gt;delay()&lt;/code&gt; has its uses, but for long delays it's no good. It simply tells the microcontroller to do nothing for &lt;code&gt;x&lt;/code&gt; clock cycles. During that time, your Arduino can't do anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet would be to use a thing called a Real Time Clock (RTC). These chips are specifically made to keep track of time, and you can connect them to your Arduino with ease. &lt;a href=&quot;http://playground.arduino.cc/Main/DS1302&quot;&gt;Here's an example of how you could do that.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2014-08-21T13:04:11.093" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3884" PostTypeId="2" ParentId="3881" CreationDate="2014-08-21T14:08:03.857" Score="10" Body="&lt;p&gt;The real time clock method is the most accurate way but otherwise use &lt;code&gt;millis&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long startMillis = millis();&#xA;while (millis() - startMillis &amp;lt; LONG_DELAY_MS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will delay up to approx. 4294967295ms (2^32-1) or 49 days, after which the timer will catch up to the value of &lt;code&gt;startMillis&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-08-22T22:52:06.017" LastActivityDate="2014-08-22T22:52:06.017" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="3885" PostTypeId="2" ParentId="3881" CreationDate="2014-08-21T14:28:40.883" Score="7" Body="&lt;p&gt;You could use the watchdog interrupt and have your MCU sleep while waiting and save power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But notice that you'll only save power if your board also saves it. That means you have to have a low quiescent voltage regulator instead of the usual regulators that equip the most common Arduino boards, such as the Uno. Otherwise, it doesn't matter whether your MCU saves energy if your board doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;// This variable is made volatile because it is changed inside an interrupt function&#xA;volatile int sleep_count = 0; // Keep track of how many sleep cycles have been completed.&#xA;const int interval = 720; // Interval in minutes between waking and doing tasks.&#xA;const int sleep_total = (interval*60)/8; // Approximate number of sleep cycles &#xA;// needed before the interval defined above elapses. Not that this does integer math.&#xA;&#xA;void setup(void) {&#xA;    watchdogOn(); // Turn on the watch dog timer.&#xA;    // Disable the ADC by setting the ADEN bit (bit 7) to zero.&#xA;    ADCSRA = ADCSRA &amp;amp; B01111111;&#xA;    // Disable the analog comparator by setting the ACD bit (bit 7) to one.&#xA;    ACSR = B10000000;&#xA;    // Disable digital input buffers on all analog input pins by setting bits 0-5 to one.&#xA;    DIDR0 = DIDR0 | B00111111;&#xA;}&#xA;&#xA;void loop(void) {&#xA;    goToSleep(); // ATmega328 goes to sleep for about 8 seconds&#xA;    // and continues to execute code when it wakes up&#xA;    if (sleep_count == sleep_total) {&#xA;        // CODE TO BE EXECUTED PERIODICALLY&#xA;    }&#xA;}&#xA;&#xA;void goToSleep() {&#xA;    set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Set sleep mode.&#xA;    sleep_enable(); // Enable sleep mode.&#xA;    sleep_mode(); // Enter sleep mode.&#xA;    // After waking from watchdog interrupt the code continues&#xA;    // to execute from this point.&#xA;    sleep_disable(); // Disable sleep mode after waking.&#xA;}&#xA;&#xA;void watchdogOn() {&#xA;    // Clear the reset flag, the WDRF bit (bit 3) of MCUSR.&#xA;    MCUSR = MCUSR &amp;amp; B11110111;&#xA;    // Set the WDCE bit (bit 4) and the WDE bit (bit 3) of WDTCSR. &#xA;    WDTCSR = WDTCSR | B00011000; &#xA;    // Set the watchdog timeout prescaler value to 1024 K &#xA;    // which will yeild a time-out interval of about 8.0 s.&#xA;    WDTCSR = B00100001;&#xA;    // Enable the watchdog timer interupt.&#xA;    WDTCSR = WDTCSR | B01000000;&#xA;    MCUSR = MCUSR &amp;amp; B11110111;&#xA;}&#xA;&#xA;ISR(WDT_vect) &#xA;{&#xA;    sleep_count ++; // keep track of how many sleep cycles have been completed.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code I copied is from this page: &lt;a href=&quot;http://www.fiz-ix.com/2012/11/low-power-arduino-using-the-watchdog-timer/&quot;&gt;Low-Power Arduino Using the Watchdog Timer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2014-08-21T15:40:50.737" LastActivityDate="2014-08-21T15:40:50.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3886" PostTypeId="2" ParentId="3772" CreationDate="2014-08-21T14:49:30.540" Score="3" Body="&lt;p&gt;Also you will probably want to ensure these wires are not connected when programming the Arduino. Otherwise you may have problems.&lt;/p&gt;&#xA;" OwnerUserId="3004" LastActivityDate="2014-08-21T14:49:30.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3887" PostTypeId="2" ParentId="3612" CreationDate="2014-08-21T18:44:29.103" Score="0" Body="&lt;p&gt;I ended up working around the issue by building a board with two ATmegas in it. One MCU handles the sound while the other handles the RF receiver, each using its own TIMER1, both communicating via I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's kind of a low tech dual core controller board. Not the most efficient solution, but it worked great for me. &lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-08-21T18:44:29.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3888" PostTypeId="1" AcceptedAnswerId="3899" CreationDate="2014-08-21T22:07:52.453" Score="0" ViewCount="1352" Body="&lt;p&gt;I'm using the Adafruit SD shield with a Mega board and wrote a simple program to log data.  I am outputting a constant stream of data at 115200 baudrate from another Arduino to the Mega.  The data output is mostly good, but there are places where some data are skipped.  These skipped data usually occurs around a file flush.  I've tried playing around with the flush frequency and the soft buffer size, but to no avail.  I'm not sure what these hiccups are caused by and would like some help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void)&#xA;{&#xA;  while (Serial1.available())&#xA;  {&#xA;    softBuffer[i] = Serial1.read();&#xA;    i++;&#xA;  }&#xA;&#xA;  if (i &amp;gt;= SOFT_BUFFER_SIZE)&#xA;  {&#xA;    for (x = 0; x &amp;lt; SOFT_BUFFER_SIZE; x++)&#xA;    {&#xA;      logfile.print(softBuffer[x]);&#xA;    }&#xA;&#xA;    logfile.flush();&#xA;&#xA;&#xA;    i = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3554" LastActivityDate="2014-08-22T23:38:34.940" Title="SD datalogger sometimes skips readings" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3889" PostTypeId="2" ParentId="3330" CreationDate="2014-08-22T01:29:39.480" Score="1" Body="&lt;p&gt;Pretty sure your problem is coming from the fact that you chose to use the backslash as your terminator character. The backslash requires special handling when encoded as a URL. You can observe this by Googling for &quot;\&quot; and and the results page you'll see your query in the address bar assigned to the &quot;q&quot; variable:&#xA;q=%5C&#xA;my entire URL looked like this, you may have something a bit different:&#xA;&lt;a href=&quot;https://www.google.com/?gws_rd=ssl#q=%5C&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com/?gws_rd=ssl#q=%5C&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok - so if you want a quick fix, stop using the \ to terminate your commands, since backslashes are often used to help sort out special characters (like &quot;TAB&quot; as \t) it's a a really bad choice, but an honest mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change your code to generate links terminated with dashes you can get around the issue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;&amp;lt;a href='/arduino/on-'&amp;gt;ON&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;client.println(&quot;&amp;lt;a href='/arduino/off-'&amp;gt;OFF&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and of course change your readStringUntil invocation too&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.readStringUntil('-');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;You might want to use the &quot;&lt;em&gt;&quot; if the hostname part of your URL contains a space:&#xA;&lt;a href=&quot;http://my-web-server.com/on_&quot; rel=&quot;nofollow&quot;&gt;http://my-web-server.com/on&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one more alternative, seek the &quot;%&quot; instead since that's going to be used to encode the backslash. In that case you just need to change the readStringUntil() &lt;/p&gt;&#xA;" OwnerUserId="3671" LastEditorUserId="3671" LastEditDate="2014-08-22T03:12:13.057" LastActivityDate="2014-08-22T03:12:13.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3890" PostTypeId="1" AcceptedAnswerId="3928" CreationDate="2014-08-22T10:26:31.200" Score="0" ViewCount="9935" Body="&lt;p&gt;I apologize in advance, because there is a lot of tutorials out there about programming arduinos with another arduino, however I can't find really simple one I could understand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Arduino Uno SMD version and Arduino Pro mini 328. I want to upload sketch to Arduino Pro mini using Arduino Uno in ISP mode (I guess).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know EXACTLY which pins need to be connected and if all I need is Arduino IDE to upload my sketch to Pro mini ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="3533" LastActivityDate="2017-10-24T20:40:17.897" Title="Programming Arduino Pro mini 328 with Arduino Uno SMD" Tags="|arduino-pro-mini|isp|arduino-uno-smd|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="3892" PostTypeId="1" AcceptedAnswerId="4093" CreationDate="2014-08-22T17:49:19.980" Score="2" ViewCount="1614" Body="&lt;p&gt;I would like to use these 2 components with an Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Motor Shield R3 &lt;/li&gt;&#xA;&lt;li&gt;nRF24L01 2.4GHz Wireless Transceiver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I use Stepper for the motor shield, and SPI + RF24 for the wireless transceiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could write 2 sketches that work perfectly, but how can I combine them together?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that they both require access to pins 11, 12 and 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2014-09-08T00:31:23.630" Title="Motor shield and wireless transceiver compete for same pins" Tags="|arduino-motor-shield|nrf24l01+|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3893" PostTypeId="1" AcceptedAnswerId="3894" CreationDate="2014-08-22T18:11:00.023" Score="5" ViewCount="175" Body="&lt;p&gt;In Linux Fedora 20 Arduino I want to use the Timer library from &lt;a href=&quot;https://github.com/JChristensen/Timer&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, from which  I have downloaded the folder &lt;code&gt;Timer-master.zip&lt;/code&gt;, but, when I try to import it, I get the Arduino message that it cannot be imported because its name includes characters other than plain ACSII letters and numbers. I have tried copying the file to &lt;code&gt;Timermaster.zip&lt;/code&gt; and importing that instead, but still got exactly the same failure message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, how do I get out of this impasse?&lt;/p&gt;&#xA;" OwnerUserId="1631" LastEditorUserId="1631" LastEditDate="2014-08-24T12:36:35.820" LastActivityDate="2014-08-24T12:36:35.820" Title="In Linux, how do I get this Arduino library to work" Tags="|arduino-uno|library|timers|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3894" PostTypeId="2" ParentId="3893" CreationDate="2014-08-22T18:45:31.810" Score="4" Body="&lt;p&gt;What's causing the problem is that the folder name inside the zip has a hyphen in it, just extract the folder from this zip and rename it to &lt;code&gt;timer&lt;/code&gt; instead of &lt;code&gt;timer-master&lt;/code&gt;. I just imported it on Fedora 20.&lt;/p&gt;&#xA;" OwnerUserId="3683" LastActivityDate="2014-08-22T18:45:31.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3895" PostTypeId="2" ParentId="3892" CreationDate="2014-08-22T21:58:46.613" Score="2" Body="&lt;p&gt;This is the core of embedded design and &quot;hacking&quot; and highlights one of my peeves about Arduino design: too much focus on the pin numbers and physical location on the PCBs, rather than the actual functions on those pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So? Physically move the pins on the Motor Shield. Here are 3 options in order of the most hack-ish to most-clean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Use an edge cutter to cut the bottom of the pins off the motor shield then solder jumpers to the nub to other pins that &lt;strong&gt;are&lt;/strong&gt; free.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Use a hot air station to desolder that header row, solder in your jumpers, and put back only the pins you want. Board designs with such limited foresight (like your situation) is what led me to buy my hot air station. And now I pretty much use sensor shields for my interfacing outside the stack or proto shields to be intermediate layers to translate pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Cut the trace on the motor shield PCB itself to free the SPI pins. Then find pins that have your function (pwm?) and also are NOT used by any other shields in your &quot;stack&quot;. Solder a jumper from the exposed trace on SPI pins to your free &quot;new&quot; pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you stalk through my answers there are write-ups on two test benches I made and you can get ideas from the various work-arounds I have employed to get my hardware working.&lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2014-08-22T21:58:46.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3896" PostTypeId="1" CreationDate="2014-08-22T22:24:51.363" Score="0" ViewCount="403" Body="&lt;p&gt;is it possible to perform an action maximum x times per hour on the arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a automatic water sprinkler that sprays when the humidity is lower than 50%. but if the sprayer performs this &quot;spray&quot; more than 4 times an hour the humidity wil be to high and wil rise to fast.so is there a way to restrict the amount of times an action is performed per hour,and then if the next hour comes the sprayer can perform his &quot;sprays&quot; 4 times before it stops again&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sorry for bad english, this is not the language I speak (and type) mutch&lt;/p&gt;&#xA;" OwnerUserId="3687" LastActivityDate="2017-05-24T03:02:23.180" Title="perform an action maximum x times per hour" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3897" PostTypeId="2" ParentId="3896" CreationDate="2014-08-22T22:51:56.600" Score="3" Body="&lt;p&gt;Sure it's possible. It would be better if you had a real time clock module. Then you could use time-of-day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to define your problem a little better. Would it be ok to run the sprinkler every 5 minutes, then not again for 40 minutes, for a total of 4 sprays in an hour, but clustered together? Do you want to prevent 4 sprays in a clock hour, or not go over an average of 4 sprays per hour?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a realtime clock module, I guess here's what I would do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a spray, record the time (in millis). Then in your loop, don't spray again for 15 minutes (15*1000*3600 milliseconds.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code would look something like this: (not real code, more like pseudocode)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned long fifteenMinutes = 15*1000*3600;&#xA;unsigned long nextSprayTime = 0;&#xA;&#xA;loop()&#xA;{&#xA;  if (millis() &amp;gt;= nextSprayTime)&#xA;  {&#xA;    if (humidity &amp;lt; 50)&#xA;    {&#xA;      spray();&#xA;      nextSprayTime = millis() + fifteenMinutes;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: You said, in comments:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;i want it not to go over 4 sprays an hour,i have the ds1307 rtc&#xA;  module. situation: ist an automatic egg incubator and the humidity&#xA;  must be between 50% and 60%.i control the sprayer whit a dht11 sensor&#xA;  an a servo connected to an spray bottle. if the humidity is below 50 %&#xA;  the servo starts whit spraying.the servo keeps on spraying every&#xA;  second until that 60% mark is reached and then shuts of.so the amount&#xA;  of water in the box is way to much and so the humidity keeps on&#xA;  climbing until the 100% mark whit is deadly for the eggs&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ok, that gives your readers a clearer picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're dealing with a process control problem, not just a hardware or software problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you spray water, it will likely take several minutes for the change in humidity to stabilize and be detected by your sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your current approach sounds wrong because you dump far too much water into the system, and don't give it time to reach a new equilibrium before adding more water.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to collect some data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is going to be a significant lag between putting a spray into the incubator and sensing the increase in humidity, and when the increase reaches it's max.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to measure that lag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to know how much a single spray increases the humidity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should probably **ALSO* figure out how many sprays at a time you can spray before water droplets form on the walls of your incubator and on your eggs, since I assume that is very bad and to be avoided at all costs. Thus I would add a moisture detector to your system (A small piece of cloth with electrodes on it at 2 locations a couple of CM apart, and a sensitive conductivity sensor that detects the change from insulator to weak conductor that takes place when the cloth becomes saturated with water.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also figure out how fast the humidity in your incubator drops if you don't add any water, for a variety of different conditions. (Likely affected by current humidity, outside temp and outside relative humidity, so you probably want 2 humidity sensors, one inside and one outside the incubator, and to record all the variables and graph them.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest writing a data collection program. You might want to run it with the serial cable connected to a PC constantly, or install an SD card and save your data there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all your tests, you probably want to wait a significant time (15 minutes? 1/2 hour? 1 hour?) for the incubator to reach equilibrium before beginning your test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want the conditions of your incubator to be as close to your real-world conditions as possible. You might want to put eggs (dummy eggs, grocery store eggs at room temp, or something like that) in the incubator during the test to allow for the amount of water they absorb. You want the outside temp to be as close to your real-world temp as possible. If the incubator will be exposed to direct sunlight, air vents, wind, etc, then you want those same conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At each step in every test you should record the current time, the current outside temp and humidity, and the current incubator temp and humidity, and the time of each spray you trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add your condensation detector at the beginning, and any time it detects condensation you should sound an alarm, record the time that it trips, and abort the current test. If you get liquid condensation you've done something wrong and need to adjust.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write a program for your computer that graphs all your data points over time. Every time you run a test (other than the very first test) graph all the data and look at it. Patterns will probably jump out at you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Record the time and the current humidity. Add one spray of water, and then record the humidity for 15 minutes. Look for an increase in humidity and when it peaks. The time from adding a spray to the peak increase in humidity is what you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 2:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then modify your program to log the spray-to-peak-humidity-increase time, and each time it detects the humidity starting to drop again, spray once more, log the current outside temp and humidity, the inside humidity and outside time of the spray, and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will give you spray-to-peak-humitity lag times over a range of humidity values. Graph that data with starting relative humidity on the x axis and the lag time on the y axis and look at it. Is it a constant value? A straight line? Is it a geometric curve? Exponential? Come up with a curve that fits the data fairly well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 3:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A test that uses an increasing number of sprays, looking for how many sprays you can do at once before you cause condensation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with 2 sprays. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for the peak increase in humidity, and once the humidity starts to drop, increment your spray counter to 3, spray that many times, and repeat. When the condensation alarm trips, stop the test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the number of consecutive sprays you can do before the moisture alarm trips will probably change for different starting humidity levels. My guess is that the max number of sprays you can add without triggering condensation will be highest at your lowest humidity level, and as the humidity increases, you'll get condensation with less and less sprays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 4:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Figure out how to measure the max number of sprays that trigger condensation when you start at less than your minimum humidity, at your minimum humidity, at halfway between min and max, and at max. (This experiment will take some thought since it's not easy to get to a given humidity level, and once you trigger condensation you'll have to stop, dry everything out, and start again.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 5:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get your incubator as close to the maximum acceptable humidity (60%) as you can at the beginning of the test, or even a little above. Simply record the humidity every minute until it drops to the lowest acceptable level (50%). Graph the data. That will show you how fast the humidity drops if you do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Test 6:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat test 5 for the range of outside conditions you might find in your production environment. (If you're in a climate-controlled space, do you have summer and winter thermostat settings? Test for those upper and lower ranges. How much does your indoor humidity level vary?)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Now what?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now you have lots and lots of data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More than likely you have an idea of how many sprays you can add at a time without triggering condensation over your humidity range. This should be fairly simple: (for example, at humidity &amp;lt; 50% to 52%, you can use 3 sprays.  AT 53-55%, 2 sprays. Above 55%, 1 spray.) You should also have a rough idea how much increase you'll get in humidity for a given number of sprays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have an idea of how fast the humidity drops if you don't add water.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have an idea how long it takes for a spray set of sprays to cause a peak in the humidity level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write a program that strives to keep the incubator in the middle of your desired range. If 50% is your absolute minimum humidity level and 60% is your max, then trigger sprays at 52%, not 50%. Spray as many sprays as you can without causing condensation (or overshooting your max humidity), then lock out sprays for the time period you calculated as the time it takes for your sprays to cause the maximum increase in humidity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've found that the max number of sprays you can do at a time is different for different humidity levels, use code that comes up with a number of sprays that stays below that limit. Also try to estimate how much increase in humidity you get per spray, and each time you trigger a series of sprays, stay below the number of sprays that reaches your max humidity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you've found that the conditions outside the incubator have a big effect on your system, adjust your code to compensate for those changing conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want a system that uses small adjustments over time to keep a system at near equilibrium. Big adjustments will likely cause wild variations in conditions that go outside of the acceptable range.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Other considerations:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Do you need to open the incubator at regular intervals to check on the eggs or turn them, or do you have an egg turner? If you do need to open the incubator, you will need to figure out the effect this has on your temp and humidity levels for the range of outside conditions you face. You can probably build your system with a door sensor that detects you opening the door, the outside temp and humidity, and how long the door is open. Once you close the door, it would note the new inside temp and humidity and make an educated guess as to how much the humidity will drop after being open, and add water accordingly.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-08-23T14:45:12.753" LastActivityDate="2014-08-23T14:45:12.753" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3899" PostTypeId="2" ParentId="3888" CreationDate="2014-08-22T23:38:34.940" Score="1" Body="&lt;p&gt;The SD card library works by filling up a 512 byte buffer. Once full, the data is written to disk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;flush&lt;/code&gt; command updates the directory listing with the correct size for the file and also updates the file allocation table. It only needs to be done once, just before you pull the card out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While &lt;code&gt;flush&lt;/code&gt; is doing its thing, the internal serial buffer of the Arduino is filling up with new bytes. The internal buffer is 64 bytes long so if &lt;code&gt;flush&lt;/code&gt; takes too long, the internal buffer fills up and you lose characters. You could edit HardwareSerial.cpp in the Arduino program directory to make it say 256 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this &lt;code&gt;softBuffer&lt;/code&gt; is not needed. Simply write straight to the card and let the internal buffer handle the buffering. See &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/HardwareSerial.cpp&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/HardwareSerial.cpp&lt;/a&gt; for the Serial code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long bytesWritten = 0;&#xA;void loop(void)&#xA;{&#xA;  while (Serial1.available())&#xA;  {&#xA;    logfile.write(Serial1.read());&#xA;    bytesWritten++;&#xA;    if(bytesWritten &amp;gt; BYTES_PER_FLUSH) logfile.flush();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-22T23:38:34.940" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3900" PostTypeId="2" ParentId="3896" CreationDate="2014-08-23T13:11:32.133" Score="0" Body="&lt;p&gt;You might be spraying faster than the sensor or the environment can respond, causing your humidity overshoot your goal. Try spraying way less often, experimenting with the interval until you understand more about the dynamics of the humidity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first guess would be to try once per minute and see whether that still overshoots or if it fails to maintain the humidity. That will tell you whether to increase the interval more or to decrease it. Writing the time and humidity readings to the terminal and plotting those may help you understand your system behavior better.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-08-23T13:11:32.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3902" PostTypeId="1" AcceptedAnswerId="3905" CreationDate="2014-08-24T00:23:01.767" Score="0" ViewCount="1486" Body="&lt;p&gt;My question is simple. Does Arduino set the digitalwrite() the moment it is called or at the end of the while loop. E.G.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;               &#xA;void setup()&#xA;{&#xA;  pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{for(int i=0; i&amp;lt;10; i++){&#xA;if(i%2==0){&#xA;  digitalWrite(ledPin, HIGH);   &#xA;  delay(1000);}else{                  &#xA;  digitalWrite(ledPin, LOW);    &#xA;  delay(1000);      }           &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3700" OwnerDisplayName="user1198289" LastEditorUserId="83" LastEditDate="2014-08-24T08:17:53.950" LastActivityDate="2016-08-30T05:27:59.223" Title="Arduino Digitalwrite for while loop set" Tags="|programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3903" PostTypeId="2" ParentId="3902" CreationDate="2014-08-24T00:29:34.183" Score="0" Body="&lt;p&gt;Arduino sets the pin at the moment digitalWrite() is called.&lt;/p&gt;&#xA;" OwnerUserId="3713" OwnerDisplayName="CopperMaze" LastActivityDate="2014-08-24T00:29:34.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3904" PostTypeId="2" ParentId="3902" CreationDate="2014-08-24T00:30:55.757" Score="0" Body="&lt;p&gt;The condition&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(i%2==0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be checked immediately upon entering the &quot;for&quot; loop, and again on every iteration of that loop. It will be the first code executed on each iteration. One form or another of the digitalWrite() will be called next, followed by the delay().&lt;/p&gt;&#xA;" OwnerUserId="3621" OwnerDisplayName="TDHofstetter" LastActivityDate="2014-08-24T00:30:55.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3905" PostTypeId="2" ParentId="3902" CreationDate="2014-08-24T01:06:11.993" Score="2" Body="&lt;p&gt;A key point of the Arduino 'language' is &lt;em&gt;every&lt;/em&gt; statement is completed before the next one can begin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple statement has a '&lt;code&gt;;&lt;/code&gt;' at the end of it.&lt;br&gt;&#xA;Or followed by '&lt;code&gt;)&lt;/code&gt;' instead of '&lt;code&gt;;&lt;/code&gt;' in &lt;code&gt;for (...; ...; statement)&lt;/code&gt; loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;digitalWrite()&lt;/code&gt; will set the pin, HIGH or LOW, &lt;em&gt;before&lt;/em&gt; it completes and allows the next statement, &lt;code&gt;delay(...)&lt;/code&gt; to begin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note:&lt;br&gt;&#xA;Actually &lt;code&gt;digitalWrite()&lt;/code&gt; takes a small amount of time to do its work, so it is not &lt;em&gt;exactly&lt;/em&gt; 'the moment' it is called. &lt;code&gt;digitalWrite()&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; pretty quick, a few millionths of a second, which is usually near enough to be practically 'the moment' for most applications. &lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2014-08-24T10:37:34.513" LastActivityDate="2014-08-24T10:37:34.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3906" PostTypeId="1" AcceptedAnswerId="3907" CreationDate="2014-08-24T04:22:05.830" Score="3" ViewCount="5756" Body="&lt;p&gt;Is it possible to write an Arduino program to an AVR chip that does not have teh Arduino bootloader installed?  What is the process to do so?&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-08-24T07:28:58.103" Title="How do I write an Arduino program to an AVR chip without the Arduino bootloader?" Tags="|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3907" PostTypeId="2" ParentId="3906" CreationDate="2014-08-24T04:59:30.177" Score="6" Body="&lt;h3&gt;Step 1: Get yourself a programmer.&lt;/h3&gt;&#xA;&lt;p&gt;This can be anything from a USBasp to an Arduino programmed for ISP all the way to an AVR ONE!. Some can be used from the IDE, and some cannot.&lt;/p&gt;&#xA;&lt;h3&gt;Step 2: Set up the chip as expected from the entry in boards.txt and from the datasheet.&lt;/h3&gt;&#xA;&lt;p&gt;Add a crystal, decoupling caps, whatever. Don't connect power yet.&lt;/p&gt;&#xA;&lt;h3&gt;Step 3: Connect the programmer.&lt;/h3&gt;&#xA;&lt;p&gt;If using ISP, connect the ISP pins. If using JTAG, connect the JTAG pins. If using something else, see the programmer and chip documentation for connection details. You may want to connect power at this point for the next step.&lt;/p&gt;&#xA;&lt;h3&gt;Step 4: Program fuses.&lt;/h3&gt;&#xA;&lt;p&gt;Program the oscillator, BOR, CKDIV8, EESAVE fuses as desired/required. &lt;a href=&quot;http://www.engbedded.com/fusecalc&quot; rel=&quot;noreferrer&quot;&gt;Fuse calculator&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Step 5: Compile the program and write it to the chip.&lt;/h3&gt;&#xA;&lt;p&gt;If using the IDE, select the programmer in &lt;code&gt;Tools&lt;/code&gt; | &lt;code&gt;Programmer&lt;/code&gt; and then hold shift when clicking the Upload button (or press Ctrl-Shift-U). If your programmer is not supported by the IDE then compile the program (&lt;code&gt;Sketch&lt;/code&gt; | &lt;code&gt;Verify/Compile&lt;/code&gt; or Ctrl-R), locate the temporary directory it has been built in, and use avrdude or your JTAG program to upload it to the programmer.&lt;/p&gt;&#xA;&lt;h3&gt;Step 6: There is no step 6. You're done.&lt;/h3&gt;&#xA;&lt;p&gt;I just wanted to see if you would read this far.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-08-24T04:59:30.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3908" PostTypeId="1" CreationDate="2014-08-24T05:02:21.973" Score="1" ViewCount="1208" Body="&lt;p&gt;I'm sorry if this isn't the right area. Teensy uses the arduino ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen some people show off the 144 mhz and 168 mhz option in their ide. I read in the Teensyduino 1.19 release notes that the options were added but not enabled. I would like to know how to enable it or if I somehow downloaded an older version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S I get the 96 mhz option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks ahead of time!&lt;/p&gt;&#xA;" OwnerUserId="3159" LastActivityDate="2015-11-21T14:33:39.033" Title="Teensy 3.1 no overclock option for 168 MHz" Tags="|teensy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3910" PostTypeId="2" ParentId="3906" CreationDate="2014-08-24T07:28:58.103" Score="1" Body="&lt;p&gt;If there are no memory restrictions (too large program) which eliminates this option, I'd try to write the Arduino bootloader first and then continue normally. This has the advantage of simple reprogramming if required.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2014-08-24T07:28:58.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3913" PostTypeId="1" AcceptedAnswerId="3915" CreationDate="2014-08-24T22:45:59.623" Score="1" ViewCount="3299" Body="&lt;p&gt;I'm using a customised C++ implementation of ArrayList based on the method found in Processing. The original code is by &lt;a href=&quot;https://gist.github.com/obedrios/2970053&quot; rel=&quot;nofollow&quot;&gt;Obed Isai Rios&lt;/a&gt;, but I've added a &lt;a href=&quot;https://gist.github.com/geotheory/263bef188b7a164bae87&quot; rel=&quot;nofollow&quot;&gt;version to Github with more explicit file structure&lt;/a&gt;.  The arraylist is appended to by the &lt;code&gt;add_string_item&lt;/code&gt; method, which works ok in the format &lt;code&gt;arraylist-&amp;gt;add_string_item(&quot;text string&quot;)&lt;/code&gt; but fails when the same input is a String variable.  The following script illustrates:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ArrayList.h&quot;&#xA;void setup(){&#xA;  ArrayList *list = new ArrayList(&quot;text1&quot;);&#xA;  list-&amp;gt;add_string_item(&quot;text2&quot;);&#xA;  String str = &quot;text3&quot;;&#xA;  list-&amp;gt;add_string_item(str);&#xA;}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This fails on the last line with error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;no matching function for call to 'ArrayList::add_string_item(String&amp;amp;)'&#xA;&#xA;sketch_aug24b.ino: In function 'void setup()':&#xA;sketch_aug24b:7: error: no matching function for call to 'ArrayList::add_string_item(String&amp;amp;)'&#xA;/Users/robinedwards/Documents/Arduino/libraries/ArrayList/ArrayList.h:17: note: candidates are: void ArrayList::add_string_item(char*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with C++ so can't figure out why this method accepts a string but not when assigned to a String object &lt;code&gt;str&lt;/code&gt;.  I'm pretty sure it's because I need to coerce to char* but not sure how to do this.  I've tried &lt;code&gt;toCharArray&lt;/code&gt; without success, although this seems the right direction.  Very grateful for any assistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ArrayList.cpp code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;ArrayList.h&quot;&#xA;&#xA;ArrayList::ArrayList(char* init){&#xA;  stringlist = (char**)malloc(10*sizeof(char*));&#xA;  stringlist[0] = init;&#xA;  this-&amp;gt;size = 1; &#xA;}&#xA;&#xA;ArrayList::~ArrayList(void)&#xA;{&#xA;}&#xA;&#xA;void ArrayList::add_string_item(char* item){&#xA;  char **neulist = (char**)malloc((size+1)*sizeof(char*));&#xA;  for(int i=0; i&amp;lt;size; i++){&#xA;    neulist[i] = stringlist[i];&#xA;   }&#xA;   //&#xA;   neulist[size] = item;&#xA;   stringlist = neulist;&#xA;   size = size + 1;&#xA;}&#xA;&#xA;void ArrayList::set_string_item(char* item, int index){&#xA;  stringlist[index] = item;&#xA;}&#xA;&#xA;void ArrayList::remove_selected_item(int index){&#xA;  char **neulist = (char**)malloc((size-1)*sizeof(char*));&#xA;  //From Begining&#xA;  for(int i=0; i&amp;lt;index; i++){&#xA;    neulist[i] = stringlist[i]; &#xA;  }&#xA;  //From next Index  &#xA;  for(int i=index; i&amp;lt;=size-1; i++){&#xA;    neulist[i] = stringlist[i+1];&#xA;  }&#xA;  //free(matrix);&#xA;  stringlist = neulist;&#xA;  size = size - 1;&#xA;}&#xA;&#xA;void ArrayList::empty_list(){&#xA;   size = 1;&#xA;   char **neulist = (char**)malloc((size)*sizeof(char*));   &#xA;   stringlist = neulist;&#xA;   stringlist[0] = &quot;EMPTY&quot;;&#xA;}&#xA;&#xA;void ArrayList::display_string_list(){&#xA;   Serial.begin(9600);&#xA;  for(int i=0; i&amp;lt;size; i++){&#xA;    Serial.println(stringlist[i]);&#xA;   }&#xA;}&#xA;&#xA;char** ArrayList::get_stringlist(){&#xA;  return this-&amp;gt;stringlist;&#xA;}&#xA;&#xA;char* ArrayList::get_item(int index){&#xA;  return this-&amp;gt;stringlist[index];&#xA;}&#xA;&#xA;void ArrayList::set_stringlist(char** stringlist){&#xA;  this-&amp;gt;stringlist = stringlist;&#xA;}&#xA;&#xA;int ArrayList::get_size(){&#xA;  return this-&amp;gt;size;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3698" LastEditorUserId="3698" LastEditDate="2014-08-26T11:04:25.343" LastActivityDate="2014-08-26T11:04:25.343" Title="ArrayList implementation fails for string object" Tags="|programming|arduino-mega|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3914" PostTypeId="1" AcceptedAnswerId="3918" CreationDate="2014-08-25T09:45:41.580" Score="1" ViewCount="866" Body="&lt;p&gt;For use with ATMega 48 (old Arduino?), 328 (UNO, Pro Mini) and 2560 (Mega2560) chips, what is the capability for the AVRISP and USBASP programmers on:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Can it read, write fuse?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can it read, write Program Flash?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can it work 3.3 and 5 volts?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What workable clock frequency range on the MCU? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can it be used under Arduino ISP to write to board so as to erase the bootloader and use the FULL flash space for big user program (eliminate boot loader saves 0.5 to 8KB space on above Arduino boards)?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can it be used with ATMel factory software development tools (Atmel studio and associated tools) to use MCU on chip hardware based breakpoint (Debug wire, JTag, or other names, as on different MCU)?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-08-25T14:45:41.243" Title="What is the capability of AVRISP and USBASP on ATMega48, 328, 2560?" Tags="|flash|debugging|fuses|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3915" PostTypeId="2" ParentId="3913" CreationDate="2014-08-25T10:08:43.767" Score="2" Body="&lt;p&gt;&lt;em&gt;In theory&lt;/em&gt;, there's no reason why you shouldn't be able to call it by using &lt;code&gt;toCharArray()&lt;/code&gt;. You would need to call it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str = &quot;text3&quot;;&#xA;char * buf = new char[str.length()+1];&#xA;str.toCharArray(buf, str.length()+1);&#xA;&#xA;list-&amp;gt;add_string_item(buf);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That allocates a &lt;code&gt;char&lt;/code&gt; buffer, copies the string data into it, then passes that buffer pointer to the list to be stored. Note that the buffer is one character larger than the string, as it needs to add a null terminator at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is a &lt;strong&gt;major&lt;/strong&gt; problem with the rest of your code, which could eventually cause your Arduino to crash or do other strange things (depending on how much you use the list object).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike Java, C++ is not a garbage-collected language, meaning it won't automatically clean-up memory for you. If you call &lt;code&gt;new&lt;/code&gt; or &lt;code&gt;malloc()&lt;/code&gt; to allocate heap memory, you have to call &lt;code&gt;delete&lt;/code&gt; or &lt;code&gt;free()&lt;/code&gt; (respectively) when you're finished with it to deallocate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply overwriting a pointer with another call to &lt;code&gt;malloc()&lt;/code&gt; is not enough; it results in a &lt;strong&gt;memory leak&lt;/strong&gt;. This means the block of memory it was previously using is lost, and cannot be reused again as long as the program is running. On a platform like Arduino, which has limited memory, you can very quickly run out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixing the design of your class is probably beyond the scope of an answer on this site. I would strongly recommend working through some C++ tutorials (of which there are hundreds online).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, you should generally use &lt;code&gt;new&lt;/code&gt;/&lt;code&gt;delete&lt;/code&gt; instead of &lt;code&gt;malloc()&lt;/code&gt;/&lt;code&gt;free()&lt;/code&gt;. It doesn't make much difference when you're using arrays of &lt;code&gt;char&lt;/code&gt; or &lt;code&gt;char*&lt;/code&gt;, but it's important if you want to allocate class instances.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-08-25T10:08:43.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3916" PostTypeId="1" AcceptedAnswerId="3922" CreationDate="2014-08-25T12:21:54.420" Score="0" ViewCount="534" Body="&lt;p&gt;I want to build an arduino-based RC Tank, which should be controlled with a notebook or smartphone (Android). Bluetooth would be an easy solution, but the range is a bit short for a RC Vehicle, so I want to controll it via WIFI. I found a ton of examples and tutorials on how to do that but all of them reqire a router which both the arduino and the Smartphone are connected to. Any idea on how to directly control an Arduino with an smartphone via WIFI?&lt;/p&gt;&#xA;" OwnerUserId="3712" LastActivityDate="2014-08-25T18:16:00.080" Title="Control Arduino via Wifi directly?" Tags="|wifi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3917" PostTypeId="1" AcceptedAnswerId="3919" CreationDate="2014-08-25T13:16:49.477" Score="1" ViewCount="3356" Body="&lt;p&gt;I recently created a state machine for my latest Arduino project. It is a simple LED control, but it has many different modes and functions. I created a template for my state machine so I can use it in the future, but I am looking to take it to the next level. Here is a copy of the current template for reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*Setup Variables here*/&#xA;int nextState;&#xA;int currState;&#xA;&#xA;/*Fill enum with all case names*/&#xA;enum cases{&#xA;&#xA;  init;&#xA;  idle;&#xA;  case1;&#xA;  case2;&#xA;  leave;&#xA;&#xA;};&#xA;&#xA;/*Begin Program*/&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  currState = init;&#xA;}&#xA;&#xA;void loop(){&#xA;  switch(currState){&#xA;&#xA;    case init:&#xA;      /*Prepare program here*/&#xA;      nextState = idle;&#xA;      break;&#xA;&#xA;    case idle:&#xA;      if (input1){&#xA;        nextState = case1;&#xA;      }else if (input2){&#xA;        nextState = case2;&#xA;      }else{&#xA;        nextState = idle;&#xA;      }   &#xA;&#xA;    case case1:&#xA;      //Code for case1 here&#xA;      break;&#xA;&#xA;    case case2:&#xA;      //Code for case2 here&#xA;      break;&#xA;&#xA;  }&#xA;&#xA;  currState = nextState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to make a Queued State Machine (QSM). This means that instead of a single variable nextState, I can add several states to be executed. Is the best way to do this an array? I have not found much in my research about how to add and remove elements easily, so if this is the best way, could you point me towards a good tutorial on these types of array functions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advanced for all the help!&lt;/p&gt;&#xA;" OwnerUserId="2740" LastEditorUserId="2967" LastEditDate="2014-08-26T02:25:00.130" LastActivityDate="2014-08-26T02:25:00.130" Title="Using an array as a queue" Tags="|programming|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3918" PostTypeId="2" ParentId="3914" CreationDate="2014-08-25T14:45:41.243" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Depends on the specific hardware. See the documentation for the &lt;em&gt;exact&lt;/em&gt; variant you have.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;See 3.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No. They have their own protocol that you must use instead. They are selectable from the &lt;code&gt;Programmer&lt;/code&gt; menu in the IDE though. However, you must unprogram the fuse bits outside of the IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No. They are low-cost tools meant to be used for programming only. You will need an Atmel-supplied debugger in order to use Atmel Studio's debugging features.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-25T14:45:41.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3919" PostTypeId="2" ParentId="3917" CreationDate="2014-08-25T15:47:38.383" Score="5" Body="&lt;p&gt;Have an array with fixed size, and have &lt;strong&gt;two&lt;/strong&gt; indexes. One pointing to the first/current item in the queue, the other to the last item in the queue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It actually better/easier to have the second index point to where the next item has to be written)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add an item to the queue:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check that that the queue isn't full (second index is the same as the first)&lt;/li&gt;&#xA;&lt;li&gt;If not write to second index.&lt;/li&gt;&#xA;&lt;li&gt;Increment second index, and modulo array/queue size, so it wraps around.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To read from the queue&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read value at the first index&lt;/li&gt;&#xA;&lt;li&gt;Increment first index, modulo array/queue size&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-25T15:47:38.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3920" PostTypeId="1" AcceptedAnswerId="3921" CreationDate="2014-08-25T16:08:25.990" Score="2" ViewCount="1349" Body="&lt;p&gt;I'm using sublime text for editing and modifying my arduino libraries. Sublime text is pretty pretty, useful and embed a very powerfull plugin system. Someone created an Arduino plugin for it. The compilation function works but the upload doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to upload on an arduino leonardo using Windows 7 x64.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did anyone tried to fix this problem ?&lt;/p&gt;&#xA;" OwnerUserId="3713" LastEditorUserId="3713" LastEditDate="2014-08-25T17:04:48.517" LastActivityDate="2014-09-01T19:50:54.030" Title="Why is Arduino STINO upload function not working?" Tags="|uploading|arduino-leonardo|arduino-ide|debugging|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3921" PostTypeId="2" ParentId="3920" CreationDate="2014-08-25T16:59:49.087" Score="2" Body="&lt;p&gt;I finally found it: Problem was solved after commenting those three lines in */Arduino-like IDE/app/uploader.py:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if force_to_reset:&#xA;    pre_serial_port = serial_port&#xA;    wait_for_upload_port = self.args.get('upload.wait_for_upload_port', 'true') == 'true'&#xA;    serial_port = resetSerial(pre_serial_port, self.output_console, wait_for_upload_port)&#xA;    # if self.args['cmd'] != 'avrdude':&#xA;    #   if serial_port.startswith('/dev/'):&#xA;    #       serial_port = serial_port[5:]&#xA;    if serial_port:&#xA;        for cur_command in self.command_list:&#xA;            command_text = cur_command.getCommand()&#xA;            command_text = command_text.replace(pre_serial_port, serial_port)&#xA;            cur_command.setCommand(command_text)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3713" LastEditorUserId="3713" LastEditDate="2014-09-01T19:50:54.030" LastActivityDate="2014-09-01T19:50:54.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3922" PostTypeId="2" ParentId="3916" CreationDate="2014-08-25T18:16:00.080" Score="1" Body="&lt;p&gt;If your computer/tablet/phone can act as a WiFi hotspot, you could use that to avoid the router. Many smartphones have that capability, as do many notebooks (as geometrikal mentioned, it's usually referred to as an 'ad-hoc' network on PCs). Create the network (or turn on hotspot capability), and connect to the network you created from your Arduino. &lt;/p&gt;&#xA;" OwnerUserId="764" LastActivityDate="2014-08-25T18:16:00.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3923" PostTypeId="1" AcceptedAnswerId="3947" CreationDate="2014-08-25T18:24:50.857" Score="2" ViewCount="1400" Body="&lt;p&gt;I've been writing to an EyeFi SD card with an Arduino Mega.  I've managed to get the files to upload wirelessly, but I noticed that my data gets cut off when the file reaches a size of 24 kb.  If I use a normal SD card, the file is able to keep logging past 24 kb.  The EyeFi card is able to upload large images, so I'm not sure what is limiting my file size for the EyeFi card.  Can I get some advice?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*************** SETUP ***************/&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;&#xA;  // initialize the SD card&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;  pinMode(10, OUTPUT); // make sure that the default chip select pin is set to&#xA;&#xA;  // see if the card is present and can be initialized:&#xA;  if (!SD.begin(10,11,12,13))&#xA;  {&#xA;    error(&quot;Card failed, or not present&quot;);&#xA;  }&#xA;  Serial.println(&quot;Card initialized&quot;);&#xA;&#xA;  // see if the directory exists, create it if not.&#xA;  if( !SD.exists(directory) &amp;amp;&amp;amp; !SD.mkdir(directory) )&#xA;    error(&quot;File directory not created&quot;);    &#xA;&#xA;  newFile();&#xA;&#xA;  Serial1.begin(115200);&#xA;&#xA;  while (Serial1.peek() != '!' )&#xA;    Serial1.read();&#xA;&#xA;  i = 0;  &#xA;}&#xA;&#xA;/*************** MAIN LOOP ***************/&#xA;void loop(void)&#xA;{&#xA;  if (Serial1.available())&#xA;  {&#xA;    logfile.print( (char)Serial1.read() );&#xA;    i++;&#xA;  }&#xA;&#xA;  if (i &amp;gt;= SOFT_BUFFER_SIZE)&#xA;  {&#xA;    logfile.flush();&#xA;&#xA;    if( logfile.size() &amp;gt; 20480 &amp;amp;&amp;amp; logfile.size() &amp;lt; (20480 + SOFT_BUFFER_SIZE) )&#xA;      Serial.println(&quot;Minimum File Size Achieved.&quot;);&#xA;&#xA;    i = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3554" LastEditorUserId="3554" LastEditDate="2014-08-25T18:41:05.080" LastActivityDate="2014-08-27T16:58:56.380" Title="File Size Problem with EyeFi SD Card and Arduino Mega" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3924" PostTypeId="1" AcceptedAnswerId="3925" CreationDate="2014-08-24T16:29:30.187" Score="1" ViewCount="464" Body="&lt;p&gt;I have been trying to upload bootloader on ATmega328P SMT package on a custom PCB using Arduino Uno as ISP, I was quite successful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Googled a lot and have tried numerous ways, sometimes I was able to successfully upload the bootloader, but I am not able to upload the sketch am getting &quot;avr sync error&quot;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;What kind of bootloader should I use for this particular package?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How should I upload the sketches into the chip?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2907" OwnerDisplayName="srinivas" LastActivityDate="2014-08-25T18:33:18.147" Title="Uploading bootloader on ATmega328P SMT package using Arduino Uno" Tags="|bootloader|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3925" PostTypeId="2" ParentId="3924" CreationDate="2014-08-24T20:38:44.583" Score="2" Body="&lt;p&gt;I've had success with bootloader of the Arduino IDE.&#xA;I used to have some trouble uploading sketches, but I solved them by doing this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If the atmega is already soldered in a pcb and you have a pull up resistor, or something else connected to the reset pin, disconnect it. reset pin must be free.&lt;/li&gt;&#xA;&lt;li&gt;Connect the tx, rx and rst pins of your atmega to your arduino.&lt;/li&gt;&#xA;&lt;li&gt;Press the Upload button in the Arduino IDE and see the leds tx,rx in your arduino, just after the first blink, press the reset button, after that both of the leds should start blinking and in the end your code should be uploaded.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerDisplayName="ehilario" LastActivityDate="2014-08-24T20:38:44.583" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3926" PostTypeId="1" CreationDate="2014-08-25T19:23:46.873" Score="0" ViewCount="67918" Body="&lt;p&gt;I just bought VS1838B IR module (&lt;a href=&quot;http://www.robotistan.com/IR-Alici-Verici-Kumanda-Seti-IR-Receiver-Module-Wireless-Remote-Control-Kit,PR-1788.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;from here&lt;/a&gt;) and I’m trying to make it work. Below you can find the circuit to see how I have connected the 1838B IR receiver:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L6f6j.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;My Code (&lt;a href=&quot;http://paste.ubuntu.com/8143467/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt;) :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 2;&#xA;IRrecv irrecv(RECV_PIN);&#xA;decode_results results;&#xA;#define CH1 0xFFA25D &#xA;#define CH 0xFF629D&#xA;#define CH2 0xFFE21D&#xA;...&#xA;#define BUTON8 0xFF4AB5&#xA;#define BUTON9 0xFF52AD&#xA;&#xA;void setup()&#xA;&#xA;{&#xA;&#xA; Serial.begin(9600);&#xA;&#xA; irrecv.enableIRIn(); &#xA;&#xA;}&#xA;&#xA;void loop() {&#xA; &#xA;&#xA; if (irrecv.decode(&amp;amp;results)) &#xA;  {&#xA;&#xA; if (results.value == CH1) &#xA;&#xA; {&#xA;&#xA; Serial.println(&amp;quot;CH-&amp;quot;); &#xA; }&#xA;&#xA; if (results.value == CH) &#xA;&#xA; {&#xA;&#xA; Serial.println(&amp;quot;CH&amp;quot;); &#xA;&#xA; }&#xA;&#xA; if (results.value == CH2) &#xA;&#xA; {&#xA;&#xA; Serial.println(&amp;quot;CH+&amp;quot;); &#xA;&#xA; }&#xA;&#xA; ...&#xA;&#xA; if (results.value == BUTON8) &#xA;&#xA; {&#xA;&#xA; Serial.println(&amp;quot;BUTON8&amp;quot;); &#xA;&#xA; }&#xA;if (results.value == BUTON9) &#xA;&#xA; {&#xA;&#xA; Serial.println(&amp;quot;BUTON9&amp;quot;); &#xA;&#xA; }&#xA; irrecv.resume();&#xA;&#xA; }&#xA;&#xA; &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But I'm not getting any output from Serial Monitor.&#xA;Can you help me for debugging it?&lt;/p&gt;&#xA;" OwnerUserId="3716" LastEditorUserId="70020" LastEditDate="2021-04-08T01:04:55.630" LastActivityDate="2023-12-27T00:46:19.533" Title="Using VS1838B with Arduino" Tags="|remote-control|ir|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="3927" PostTypeId="1" CreationDate="2014-08-26T00:38:21.713" Score="4" ViewCount="6836" Body="&lt;p&gt;I am attempting to interface a OV7670 camera to an arduino Due. (I am fairly new to this although have been programming for many years).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to generate a clock signal for the camera at a minimum of 8Mhz - I realise using the pre-scalers I can only get an approximation but I am cool with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I finally got a nice steady 3mhz signal from the sketch below (note that the irq routine for TC6 is not used and will be removed very soon (as soon as I get home).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I have a conceptial problem with the timers because as I am initialising RA and RC to 1 and telling via TC_Configure to toggle the line, and because I am using CLOCK1 (42 Mhz), I believe with those values of RA and RC I should be getting a 21'ish MHZ signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ie RA starts at zero. First CLOCK1 tick. (at second/48,000,000) interval. RA Goes to 1 COmpares to RC Because they are equal, resets RA to 0 and toggles TIOA6 Next Clock1 tick occurs.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said I am only getting a 3Mhz signal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void TC6_Handler()&#xA;{&#xA;        TC_GetStatus(TC2, 0);&#xA;&#xA;}&#xA;&#xA;void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq) {&#xA;        pmc_set_writeprotect(false);&#xA;        pmc_enable_periph_clk((uint32_t)irq);&#xA;&#xA;        TC_Configure(tc, channel,&#xA;               TC_CMR_WAVE |&#xA;               TC_CMR_WAVSEL_UP_RC |&#xA;               TC_CMR_TCCLKS_TIMER_CLOCK1|&#xA;               TC_CMR_ACPA_TOGGLE );  // RC compare TOGGLES TIOA);&#xA;&#xA;        TC_SetRA(tc, channel, 1); //50% high, 50% low&#xA;        TC_SetRC(tc, channel, 1);&#xA;&#xA;&#xA;        PIO_Configure(PIOC,&#xA;                   PIO_PERIPH_B,&#xA;                   PIO_PC25B_TIOA6,&#xA;                   PIO_DEFAULT);&#xA;&#xA;       TC_Start(tc, channel);&#xA;&#xA;}&#xA;&#xA;void setup(){&#xA;&#xA;        startTimer(TC2, 0, TC6_IRQn);&#xA;}&#xA;&#xA;void loop(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3717" LastEditorUserId="220" LastEditDate="2014-08-27T20:56:29.523" LastActivityDate="2016-10-01T06:59:48.667" Title="Arduino Due - creating an 8Mhz clock signal" Tags="|arduino-due|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3928" PostTypeId="2" ParentId="3890" CreationDate="2014-08-26T02:35:38.133" Score="1" Body="&lt;p&gt;check this tutorial:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Examples-2-Use-an-Arduino-as-a-FTDI-Progr/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-Examples-2-Use-an-Arduino-as-a-FTDI-Progr/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Works fine for me (I have a redboard, also with SMD microcontroller). In short this is the pinMap:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UNO BOARD (SMD)    Pro Mini 5V&#xA;       GND             GND&#xA;       5V              VCC&#xA;       RX              RX1&#xA;       TX              TX1&#xA;       Reset           GRN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3718" LastActivityDate="2014-08-26T02:35:38.133" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3929" PostTypeId="1" CreationDate="2014-08-26T04:17:15.590" Score="4" ViewCount="23549" Body="&lt;p&gt;I am using an Arduino Uno with the Arduino as ISP sketch to program an ATtiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed this &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow&quot; title=&quot;Programming an ATtiny w/ Arduino 1.0&quot;&gt;tutorial&lt;/a&gt; to set up to program the ATtiny, and successfully got it to run Blink and an interrupt-free version of my program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then added an interrupt triggered by a button and got it working on the Arduino Uno (with a software debounce in the ISR). Now I want to run that sketch, with appropriate pin changes, on the ATtiny. Which pins correspond to which interrupt IDs for &lt;code&gt;attachInterrupt()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or can I not use &lt;code&gt;attachInterrupt()&lt;/code&gt;? If I can't, how do I do set up an interrupt on an ATtiny85?&lt;/p&gt;&#xA;" OwnerUserId="3720" OwnerDisplayName="mouseas" LastActivityDate="2015-07-27T23:00:53.610" Title="ATTiny85 Interrupt id vs pin when programming with Arduino" Tags="|attiny|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="3930" PostTypeId="2" ParentId="3629" CreationDate="2014-08-26T13:08:16.920" Score="1" Body="&lt;p&gt;I read the WikiPedia article on RS485 (&lt;a href=&quot;http://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://en.wikipedia.org/wiki/RS-485&lt;/a&gt;). The more I learn about RS485, the more likely it seems this is the right track. RS485 is typically wired in a bus with as many as 32 nodes. It's noise tolerant and more than fast enough for a heating/cooling system. At slower data speeds, it can run as far as 4000 feet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next step appears to be trying to record some traffic. I found this question on the EE Stack Exchange about tapping RS485: &lt;a href=&quot;https://electronics.stackexchange.com/questions/30511/hijack-observe-rs485-communication-data-by-wire-tapping&quot;&gt;https://electronics.stackexchange.com/questions/30511/hijack-observe-rs485-communication-data-by-wire-tapping&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A USB widget appears to be affordable. Inserting the widget between the two ends (I'll try and test to see whether the ends both have termination resisters) should be some easy wiring.&lt;/p&gt;&#xA;" OwnerUserId="3380" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-08-26T13:08:16.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3931" PostTypeId="1" AcceptedAnswerId="3943" CreationDate="2014-08-26T14:27:00.367" Score="0" ViewCount="2938" Body="&lt;p&gt;I recently bought a USB-powered desk light. Is it possible to control (turn on/off) it with the Arduino Uno? The desk light has 3W so needs 600mA.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Should I connect the USB wire with the 5V pin of the Arduino (which can spend up to 800mA) or should I use an external USB power supply ?&lt;/li&gt;&#xA;&lt;li&gt;How to control the light when using an external USB power supply ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3722" LastActivityDate="2014-08-27T13:21:55.130" Title="What's the best way to control a USB-powered desk light" Tags="|arduino-uno|power|led|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3932" PostTypeId="2" ParentId="3931" CreationDate="2014-08-26T14:44:30.547" Score="-1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;power lamp from 5v source ( not from the arduino 5v port, but could be spliced into the same line powering the arduino or use a hub )&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;use a transistor to switch the usb 5v line&lt;/strong&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;connect the base pin (and resistor) of the transistor to any arduino digital out pin&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3723" LastEditorUserId="3723" LastEditDate="2014-08-26T17:20:08.770" LastActivityDate="2014-08-26T17:20:08.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3933" PostTypeId="2" ParentId="2909" CreationDate="2014-08-26T17:57:01.147" Score="2" Body="&lt;p&gt;Does it have to be a shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would consider buying a cheap Wi-Fi router instead with good open-source support and a way to interface it to the Arduino. Their price is near to the price of Wi-Fi shields.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;They consume little power, can be powered by 5V and have built in Wi-Fi.&lt;/li&gt;&#xA;&lt;li&gt;Some have a built-in USB port, most have a serial port, which can be used to talk to the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;You would have to put custom firmware on it, plus the program which receives the raw packets for you.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Specifically, I would get a TP-Link TL-WR703ND for this task.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It can be fed 5 Volts, or 3.3 Volts with a little hacking&lt;/li&gt;&#xA;&lt;li&gt;It has USB&lt;/li&gt;&#xA;&lt;li&gt;It also has serial, and you can even hack an I2C port onto it&lt;/li&gt;&#xA;&lt;li&gt;It can run OpenWRT&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://wiki.openwrt.org/toh/tp-link/tl-wr703n&quot; rel=&quot;nofollow&quot;&gt;More info&lt;/a&gt; on this particular router&lt;/p&gt;&#xA;" OwnerUserId="3724" LastActivityDate="2014-08-26T17:57:01.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3934" PostTypeId="2" ParentId="3158" CreationDate="2014-08-26T18:13:24.563" Score="2" Body="&lt;p&gt;There are multiple ways to do that.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You could use an Arduino Leonardo as a keyboard, then send a shortcut command to shut down or sleep the computer. You can edit these from System Preferences&gt;Keyboard&gt;Shorcuts&gt;Services. &#xA;The keycode 0x66 does not work for mac, but may for other operating systems &lt;a href=&quot;http://joshfire-tech.tumblr.com/post/65032568887/arduino-keyboard-emulation-send-real-key-codes&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could write a small program (I'd do it in Python) which communicates with the Arduino over the serial port and shuts down the Mac if the Arduino wants it to.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could sacrifice an USB keyboard and use a relay to &quot;press&quot; the power key.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3724" LastEditorUserId="-1" LastEditDate="2019-03-23T19:03:33.350" LastActivityDate="2019-03-23T19:03:33.350" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="3935" PostTypeId="2" ParentId="3931" CreationDate="2014-08-26T20:16:26.633" Score="0" Body="&lt;p&gt;You have a couple options here. The main idea is that you're going to add a switch to the light's circuit and that switch will be controlled by the arduino. It's important that you keep the electronics for the light and the electronics for your arduino separate, 600mA will damage your arduino which no one wants. You can power the light and arduino from the same power supply, make sure it can handle the power draw though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To actually switch the circuit you could use an NPN transistor as mentioned above, with the lamp's - terminal flowing into the C pin, an arduino GPIO pin connected to the B pin and the E pin grounded. When you set your arduino's pin &lt;code&gt;HIGH&lt;/code&gt; the transistor will allow current to flow and light up the lamp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option that actually physically separates the circuits is to use an opto-coupler. They're little IC's that serve this exact purpose. The have a light and a light sensitive transistor inside them, so when the light illuminates, the transistor allows current to flow. In your case, you would hook up an arduino pin to the + pin on the light side of the coupler and ground the - pin. Then connect your lamp in the same to the other side, +5v into the + pin on the transistor side and the lamp's positive terminal to the output pin. Again, when the arduino pin goes &lt;code&gt;HIGH&lt;/code&gt;, the lamp will light up. &lt;/p&gt;&#xA;" OwnerUserId="1407" LastEditorUserId="1407" LastEditDate="2014-08-27T13:21:55.130" LastActivityDate="2014-08-27T13:21:55.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3936" PostTypeId="1" CreationDate="2014-08-26T20:58:10.453" Score="2" ViewCount="2565" Body="&lt;h2&gt;Test case:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;2 arduino nodes with nRF24L01+ transceivers. Using maniacbug's RF24 library. Using pipes 0 and 1. (Auto-ACK is ON for all pipes by default)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I set Auto-ACK ON for all pipes &lt;code&gt;rf24.setAutoAck(true)&lt;/code&gt;: it works.&#xA;When I set Auto-ACK OFF for all pipes &lt;code&gt;rf24.setAutoAck(false)&lt;/code&gt;: it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when Auto-ACK is ON for pipe1 and OFF for pipe0 (I want pipe0 for broadcasting) &lt;code&gt;rf24.setAutoAck(0,false)&lt;/code&gt;:it stop working (no packet is received or sent).&#xA;Same thing with Auto-ACK ON for pipe0 and OFF for pipe1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Couldn't find anything about it on the datasheet neither other forums nor here. Is there something I'm missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test sketches:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Node 1&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;RF24 rf24(9,8);&#xA;&#xA;uint64_t pipe0 = 12312312LL;&#xA;uint64_t pipe1 = 11111111LL;&#xA;&#xA;int data[2];    &#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(115200);&#xA;    data[0] = 123;&#xA;    data[1] = 456;&#xA;&#xA;    rf24.begin();&#xA;    rf24.setChannel(109);&#xA;    rf24.setPayloadSize(2);&#xA;    rf24.setDataRate(RF24_2MBPS);&#xA;    rf24.openReadingPipe(0,pipe0);&#xA;    rf24.openReadingPipe(1,pipe1);&#xA;    rf24.openWritingPipe(22222222LL);&#xA;    rf24.setAutoAck(0,false);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    delay(1000);&#xA;    Serial.print(&quot;ACK: &quot;);&#xA;    Serial.println(rf24.write(data,sizeof(data)));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Node 2:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;RF24 rf24(9,8);&#xA;&#xA;uint64_t pipe0 = 12312312LL;&#xA;uint64_t pipe1 = 22222222LL;&#xA;&#xA;int data[2];    &#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(115200);&#xA;&#xA;    rf24.begin();&#xA;    rf24.setChannel(109);&#xA;    rf24.setPayloadSize(2);&#xA;    rf24.setDataRate(RF24_2MBPS);&#xA;    rf24.openReadingPipe(0,pipe0);&#xA;    rf24.openReadingPipe(1,pipe1);&#xA;    rf24.setAutoAck(0,false);   &#xA;    rf24.startListening();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if(rf24.available())&#xA;    {&#xA;        Serial.println(&quot;Got somethin&quot;);&#xA;        int incoming;&#xA;        rf24.read((byte *) &amp;amp;incoming,2);&#xA;        Serial.println(incoming);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3725" LastActivityDate="2015-03-05T17:28:01.057" Title="Setting EN_AA (auto ACK) to 0x01 or 0x02 makes nRF24L01+ stop sending/receiving" Tags="|nrf24l01+|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3937" PostTypeId="2" ParentId="3369" CreationDate="2014-08-26T23:01:45.533" Score="1" Body="&lt;p&gt;I managed to brickwall an ATMega128RFA1. The bootloader, and the software I uploaded in it, were working fine. But it was impossible to erase/write the ROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After checking for what have happened, I discovered in the datasheet that some fuses in the AVR core are intended to protect accidental writing on the ROM. Some kind of security fuses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never found the bug which wrote in these bytes (as it was a really big program and we were 3 peoples involved in the coding) but yeah, we just blew a fuse and lost an MCU because of a bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the leonardo, several things could happen, but none of these can brickwall your board unless you blow one of this protection fuse.&lt;/p&gt;&#xA;" OwnerUserId="3713" LastActivityDate="2014-08-26T23:01:45.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3938" PostTypeId="2" ParentId="3369" CreationDate="2014-08-27T02:32:26.207" Score="1" Body="&lt;p&gt;It is possible, &lt;a href=&quot;http://oneweekwonder.blogspot.co.uk/2014/07/bootjacker-amazing-avr-bootloader-hack.html&quot; rel=&quot;nofollow&quot;&gt;with some really clever code&lt;/a&gt;, to exploit the bootloader to overwrite itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excerpt:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The solution is actually conceptually fairly simple. A bootloader, by&#xA;  its very nature is designed to download new firmware to the device.&#xA;  Therefore it will contain at least one spm instruction. Because the&#xA;  spm configuration register must be written no more than 4 cycles&#xA;  before the spm instruction it means there are very few sequences that&#xA;  practically occur: just sts, spm or out, spm sequences. So, all you&#xA;  need to is find the sequence in the bootloader section; set up the&#xA;  right registers and call it.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;However, it turned out there was a major problem with that too. The&#xA;  V-USB self-programming bootloader's spm instructions aren't a neat&#xA;  little routine, but are inlined into the main code; so calling it&#xA;  would just cause the AVR to crash as it tried to execute the rest of&#xA;  the V-USB bootloader.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Nasty, but again there's a solution. By using a timer clocked at the&#xA;  CPU frequency (which is easy on an AVR), you can create a routine in&#xA;  assembler which sets up the registers for the Bootloader's out, spm&#xA;  sequence; calls it and just at the moment when it's executed the first&#xA;  cycle of the spm itself, the timer interrupt goes off and the AVR&#xA;  should jump to your interrupt routine (in Application space). The&#xA;  interrupt routine pops the bootloader address and then returns to the&#xA;  previous code - which is the routine that sets up the out, spm&#xA;  sequence. This should work, because when you apply spm instructions to&#xA;  the bootloader section the CPU is halted until it's complete.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So basically, you can do some fancy programming, and get the bootloader to hose itself, rendering the MCU useless without a dedicated programmer.&lt;/p&gt;&#xA;" OwnerUserId="86" LastActivityDate="2014-08-27T02:32:26.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3939" PostTypeId="2" ParentId="1329" CreationDate="2014-08-27T02:58:50.037" Score="1" Body="&lt;p&gt;The MFRC522::requestTag() returns the card type in the first two bytes of the 2nd parameter (&lt;em&gt;data&lt;/em&gt; in your example above).  You will need to look at this value to determine which sort of card it is.  Use this information to print out the required &lt;em&gt;N&lt;/em&gt; bytes of ID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a pinch, you could dump out the full 16 bytes (MAX_LEN), and test them with your various card types to see which bytes are changing in a deterministic manner, thus allowing you to determine the correct length of the ID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in case it saves you some time, if you call that library's self-test functions - getFirmwareVersion() and digitalSelfTestPass(); it's necessary to call MFRC522::begin() again, otherwise it's not possible to read RFID IDs (at the time of writing of course.)&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2014-08-27T02:58:50.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3940" PostTypeId="1" CreationDate="2014-08-27T03:44:17.943" Score="0" ViewCount="3249" Body="&lt;p&gt;So, I've made a sketch on my Yun, which I would like to be able to take information from a webpage (like a button) and have the Arduino Microcontroller perform functions based on what button is being pressed. I have an html file with the webpage of buttons. I also have a sketch that responds to those button presses. When I upload the project via WiFi, everything copies over properly. The html file gets copied to the SD card, the sketch gets loaded onto the Arduino Microntroller, and I can browse to the webpage with my browser. However, whenever I click on the button within the webpage, nothing gets sent back to the Arduino Microcontroller. If actually program the webpage into the actual sketch, everything works fine, but not if the webpage is being loaded onto the SD card. After that, no data gets passed between the Linio and the Atmel Microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to be able to have the webpage be hosted by the Linio processor, but pass information about button presses to the actual Atmel Microcontroller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how to do this properly? I would like to stay away from JScript and AJAX as much as possible. However, I guess I'll use them only if it's absolutely necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge&amp;gt;&#xA;#include &amp;lt;Console.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;YunServer server;&#xA;boolean receiving = false;&#xA;&#xA;void setup() {&#xA;  Bridge.begin();&#xA;  Console.begin();&#xA;  server.listenOnLocalhost();&#xA;  server.begin();&#xA;  Console.println(&quot;Ready&quot;);&#xA;}&#xA;&#xA;void loop() {  &#xA;  YunClient client = server.accept();&#xA;&#xA;  if (client) {&#xA;    Console.println(&quot;Client Connected&quot;);&#xA;    String request = client.readString();&#xA;    Console.println(request);&#xA;&#xA;    boolean currentLineIsBlank = true;&#xA;    boolean sentHeader = false;&#xA;&#xA;    while (client.connected()) {&#xA;       if (client.available()) {&#xA;         char c = client.read();&#xA;&#xA;       if (receiving &amp;amp;&amp;amp; c == ' ') receiving = false;&#xA;&#xA;       if (c == '?') receiving = true;&#xA;&#xA;       if (receiving) {&#xA;          if (c == 'A') {&#xA;            Console.println(&quot;Three Beeps&quot;);&#xA;            threeBeeps();&#xA;            break;&#xA;          }&#xA;          else if (c == 'B') {&#xA;            Console.println(&quot;Fast Beeps&quot;);&#xA;            fastBeeps();&#xA;            break;&#xA;          } &#xA;          else if (c == 'C') {&#xA;            Console.println(&quot;Fast Scale&quot;);&#xA;            fastScale();&#xA;            break; &#xA;          }&#xA;          else if (c == 'D') {&#xA;            Console.println(&quot;Alarm&quot;);&#xA;            playAlarm();&#xA;            break; &#xA;          }&#xA;          else if (c == 'E') {&#xA;            Console.println(&quot;Evil Alarm&quot;);&#xA;            evilChord(); &#xA;            break;&#xA;          }&#xA;        }&#xA;        if (!sentHeader) {&#xA;&#xA;  /*** I COMMENTED THIS PART OUT WHEN TESTING THE ACTUAL HTML FILE ***/&#xA;  /************************* ON THE SD CARD **************************/      &#xA;&#xA;           //client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;           //client.println(&quot;Content-Type: text/html\n&quot;);&#xA;           // &#xA;           //client.println(&quot;&amp;lt;form action='' method='get'&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='hidden' name='A' value='1' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='submit' value='Three Beeps' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;           //          &#xA;           //client.println(&quot;&amp;lt;form action='' method='get'&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='hidden' name='B' value='2' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='submit' value='Fast Beeps' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;           //          &#xA;           //client.println(&quot;&amp;lt;form action='' method='get'&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='hidden' name='C' value='3' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='submit' value='Fast Scale' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;           //          &#xA;           //client.println(&quot;&amp;lt;form action='' method='get'&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='hidden' name='D' value='4' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='submit' value='Alarm' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;           //&#xA;           //client.println(&quot;&amp;lt;form action='' method='get'&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='hidden' name='E' value='5' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;input type='submit' value='Evil Siren' /&amp;gt;&quot;);&#xA;           //client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;&#xA;             sentHeader = true; &#xA;        }&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) break;&#xA;&#xA;        if (c == '\n') {&#xA;           currentLineIsBlank = true; &#xA;        }&#xA;        else if(c != '\r') {&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    delay(5);&#xA;    client.stop();&#xA;  }&#xA;}&#xA;&#xA;void threeBeeps() {&#xA;  for (int i = 0; i &amp;lt; 3; i++) {&#xA;    tone(11,2200);&#xA;    delay(100);&#xA;    noTone(11);&#xA;    delay(100); &#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&#xA;void fastScale() {&#xA;  for (int i = 0; i &amp;lt; 1000; i++) {&#xA;    tone(11,(i * 2)); &#xA;    delay(1);&#xA;  }&#xA;  for (int i = 1000; i &amp;gt; 0; i--) {&#xA;    tone(11,(i * 2)); &#xA;    delay(1);&#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&#xA;void playAlarm() {&#xA;  for (int i = 0; i &amp;lt; 5; i++) {&#xA;    for (int j = 1000; j &amp;lt; 4000; j++) {&#xA;      tone(11,j);  &#xA;    }&#xA;    for (int j = 4000; j &amp;gt; 1000; j--) {&#xA;      tone(11,j);&#xA;    }&#xA;  }&#xA;  noTone(11); &#xA;}&#xA;&#xA;void fastBeeps() {&#xA;  for (int i = 0; i &amp;lt; 6; i++) {&#xA;    tone(11,2000);&#xA;    delay(50);&#xA;    noTone(11);&#xA;    delay(50); &#xA;  }&#xA;  noTone(11); &#xA;}&#xA;&#xA;void evilChord() {&#xA;  for (int i = 0; i &amp;lt; 5; i++) {&#xA;    tone(11,1110);&#xA;    delay(500);&#xA;    tone(11,785);  &#xA;    delay(500);&#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the code in my index.html file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;    &amp;lt;form action='' method='get'&amp;gt;&#xA;    &amp;lt;input type='hidden' name='A' value='1'&amp;gt;&#xA;    &amp;lt;input type='submit' value='Three Beeps' /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;&#xA;    &amp;lt;form action='' method='get'&amp;gt;&#xA;    &amp;lt;input type='hidden' name='B' value='2'&amp;gt;&#xA;    &amp;lt;input type='submit' value='Fast Beeps' /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;&#xA;    &amp;lt;form action='' method='get'&amp;gt;&#xA;    &amp;lt;input type='hidden' name='C' value='3'&amp;gt;&#xA;    &amp;lt;input type='submit' value='Fast Scale' /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;&#xA;    &amp;lt;form action='' method='get'&amp;gt;&#xA;    &amp;lt;input type='hidden' name='D' value='4'&amp;gt;&#xA;    &amp;lt;input type='submit' value='Alarm' /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;&#xA;    &amp;lt;form action='' method='get'&amp;gt;&#xA;    &amp;lt;input type='hidden' name='E' value='5'&amp;gt;&#xA;    &amp;lt;input type='submit' value='Evil Siren' /&amp;gt;&#xA;    &amp;lt;/form&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can probably tell, the 5 buttons the webpage generates tells the Arduino to play a sound corresponding to the pressed button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like I said, I can program the webpage into the actual sketch (all commented out for the time being), and everything works just dandy. However, if I load the webpage onto the SD card in the Yun, I can still browse to it by browsing to &lt;code&gt;&quot;Arduino.local/sd/&amp;lt;project name&amp;gt;&quot;&lt;/code&gt;, but the buttons no longer function since the webpage was sent to the client from the Linio and not the Arduino. The reason I am wanting to let the Linio handle the webpage is because it can handle much larger webpages much more quickly without taking up precious sketch room on the Arduino. Also, I CAN read an SD card with the Arduino and send the webpage to the clients that way, but it's way too slow compared to using the Linio. So, does anybody know how to take the button presses from the Linio and send them back to the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="3727" LastActivityDate="2014-08-28T05:43:58.983" Title="Arduino Yun Webpage Server Issues" Tags="|arduino-yun|web-server|web-service|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3941" PostTypeId="2" ParentId="3940" CreationDate="2014-08-27T08:39:36.150" Score="1" Body="&lt;p&gt;Your form actions are empty: when you'll press the buttons, they will send data to the current URL (something like &lt;code&gt;/sd/project_name/index.html&lt;/code&gt;) instead of the &lt;code&gt;/arduino&lt;/code&gt; url, which sends data to YunClient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading your sketch, I think they are something like &lt;code&gt;/arduino/?A=1&lt;/code&gt;, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of advices:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;start from the sketch and make sure you can control it from the browser. Manually type the expected URLs and verify the played sound.&lt;/li&gt;&#xA;&lt;li&gt;Make the URLs easy to read, like &lt;code&gt;/arduino/sound/A&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use the approach of Bridge example: code something like&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;String command = client.readStringUntil('/');&#xA;if (command == &quot;sound&quot;) {&#xA;  char soundType = client.read()&#xA;  if (soundType == 'A') {&#xA;    ...&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-08-27T08:39:36.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3942" PostTypeId="2" ParentId="3927" CreationDate="2014-08-27T09:37:27.287" Score="0" Body="&lt;p&gt;1) Timer counts close to zero are useless... i.e. they work same, as if count = 0; (I ran Due timers with TIMER_CLOCK_2 i.e. MCK/8 or 10.5MHz many times) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Select a reasonable pre-scalar depending on output frequency you need such that RC count will be a bit more. Here 42 MHz (TIMER_CLOCK_1)  means you need a count of RC = 5 approximately (with RA = RC/2 for 50% duty ratio) for 8 MHz. When RA closes to RC we get output of half frequency i.e. close to 4 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think here better option is to use master clock itself i.e. 84 MHz, then RC = 10 (approximately)(with RA = RC/2 for 50% duty ratio). Master clock can be selected using TIMER_CLOCK_5 (I am not sure..please check in the data sheet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May be Arduino Due (with its clock and using timers) is not good option to generate pulses at that higher frequency (you can't execute other routines in just 10 clock cycles!) . If no additional processing is needed, why not go for a pulse generating IC....just my opinion :-)&lt;/p&gt;&#xA;" OwnerUserId="3731" LastActivityDate="2014-08-27T09:37:27.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3943" PostTypeId="2" ParentId="3931" CreationDate="2014-08-27T13:07:02.177" Score="0" Body="&lt;p&gt;Use a TIP120 Darlington transistor to switch the current.&#xA;This webpage has a detailed guide. &lt;a href=&quot;http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/&quot; rel=&quot;nofollow&quot;&gt;http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/&lt;/a&gt;&#xA;Use the example with the light bulb - no diode is needed in your case.&lt;/p&gt;&#xA;" OwnerUserId="336" LastActivityDate="2014-08-27T13:07:02.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3944" PostTypeId="1" AcceptedAnswerId="3945" CreationDate="2014-08-27T14:25:02.967" Score="1" ViewCount="109" Body="&lt;p&gt;What software is available for use with AVRISP and USBASP on ATMega328, 2560 for read/write fuse, flash and EEPROM for UNO, Pro Mini and Mega2560 board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(a fact question not opinion) Which software did you use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did it work straight forward (like the software did all the needed 'auto select')?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it need human selection for options, etc. on the above 3 boards?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need WinAVR installed before able to use the 'ISP software'?&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-08-27T14:33:48.473" LastActivityDate="2014-09-26T17:57:23.057" Title="What software is available for use with AVRISP and USBASP on ATMega48, 328, 2560?" Tags="|software|isp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3945" PostTypeId="2" ParentId="3944" CreationDate="2014-08-27T14:43:48.193" Score="2" Body="&lt;p&gt;Almost everyone uses either &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow&quot;&gt;AVRDUDE&lt;/a&gt; (directly or indirectly, e.g. via the Arduino IDE) or the upload capability in Atmel Studio. I cannot speak for AS, but AVRDUDE does require &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude.html&quot; rel=&quot;nofollow&quot;&gt;options&lt;/a&gt; to tell it which programmer and device to use. WinAVR includes AVRDUDE, but is not strictly required as Win32 downloads are available at the AVRDUDE site.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-27T14:43:48.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3946" PostTypeId="1" CreationDate="2014-08-27T16:57:18.647" Score="2" ViewCount="3522" Body="&lt;p&gt;I am working on prototyping an underwater navigation system with Arduino. It's going to be used to track movement underwater from a starting point and then be able to tell how to get back to that point or relatively close. The unit would only be going a few hundred feet underwater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino Nano, is this going to be sufficient? Also, what IMU would you recommend? I'm sure it will need to at least have a 3-axis gyroscope, 3-axes accelerometer, and possibly a 3-axis magnetometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This does need to be relatively affordable. Currently I'm building a unit that can go underwater and just record data onto an SD card so that I can take the data and map it out to check the IMUs accuracy, error margin, along with test various filters on the data. Any recommendations would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3736" LastActivityDate="2014-08-27T17:42:31.270" Title="Arduino Underwater Inertial Navigation" Tags="|arduino-nano|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3947" PostTypeId="2" ParentId="3923" CreationDate="2014-08-27T16:58:56.380" Score="2" Body="&lt;p&gt;After some testing and research, I found out that the Eye-Fi SD card starts a transfer once a file reaches 20kb or more and will not upload a file again once it has been transfered already.  The solution, as suggested by ChrisStratton, is to log to a temporary file and trigger a transfer once the file is ready.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took advantage of the fact that the Eye-Fi only transferring files in the standard camera folders.  In my case, I used the Nikon naming convention: DCIM/100NIKON/DSCNxxxx.JPG  (xxxx is the photo number ranging from 0000 to 9999), but there are also others.  Check on the Eye-Fi website for compatible cameras.  I created a temporary file called TEMP.TMP and stored it to the root folder of the card and logged to it.  Once I'm ready to transfer the file, TEMP.TMP gets renamed to &quot;DCIM/100NIKON/DSCNxxxx.JPG&quot; and the whole file is transferred all at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code.  I'm using the software serial (pins 10, 11, 12, 13) of the Mega:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Running with 256kb serial buffer (modified HardwareSerial.cpp)&#xA;//Added file time stamps&#xA;&#xA;#include &quot;SdFat.h&quot;&#xA;#include &quot;SdFatConfig.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the card&#xA;uint32_t syncTime = 0; // time of last sync()&#xA;&#xA;#define ECHO_TO_Serial     1 // echo data to Serial port&#xA;#define WAIT_TO_START      0 // Wait for Serial input in setup()&#xA;#define MESSAGE_SIZE      11 // Message size of &quot;!G N +1234&quot; + CR&#xA;#define SOFT_BUFFER_SIZE  256// 25 Messages of 11 chars each&#xA;&#xA;const uint8_t chipSelect = 10;&#xA;&#xA;SdFat sd;&#xA;SdFile logfile; //create log file&#xA;&#xA;RTC_DS1307 RTC;&#xA;DateTime filedate;&#xA;&#xA;uint16_t date;&#xA;uint16_t time;&#xA;&#xA;int i = 0;&#xA;int x = 0;&#xA;&#xA;char directory[] = &quot;DCIM/100NIKON&quot;;&#xA;char filename[] = &quot;DCIM/100NIKON/DSCN0000.JPG&quot;;&#xA;char tempfile[] = &quot;TEMP.TMP&quot;;&#xA;&#xA;/*************** ERROR ***************/&#xA;void error(char *str)&#xA;{&#xA;  Serial.print(&quot;error: &quot;);&#xA;  Serial.println(str);&#xA;  while(1);&#xA;}&#xA;&#xA;/*********** TEMP FILE CREATION ***********/&#xA;void newFileName()&#xA;{&#xA;  sd.chdir(&quot;/&quot;); //check DCIM/100NIKON directory&#xA;  // create a temp file &#xA;  for (uint16_t i = 0; i &amp;lt; 10000; i++)&#xA;  {&#xA;    filename[18] = i/1000 + '0';&#xA;    filename[19] = (i/100)%10 + '0';&#xA;    filename[20] = (i/10)%10 + '0';&#xA;    filename[21] = i%10 + '0';&#xA;    if (! sd.exists(filename))&#xA;    {&#xA;      Serial.print(&quot;New file name: &quot;);&#xA;      Serial.println(filename);&#xA;      break;  // leave the loop!&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;/****** call back for file timestamps *****/&#xA;void dateTime(uint16_t* date, uint16_t* time) {&#xA;  DateTime now = RTC.now();&#xA;&#xA;  // return date using FAT_DATE macro to format fields&#xA;  *date = FAT_DATE(now.year(), now.month(), now.day());&#xA;&#xA;  // return time using FAT_TIME macro to format fields&#xA;  *time = FAT_TIME(now.hour(), now.minute(), now.second());&#xA;}&#xA;&#xA;/*************** SETUP ***************/&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  RTC.begin();&#xA;&#xA;  if(! RTC.isrunning() )&#xA;    Serial.println(&quot;RTC is not running&quot;);&#xA;&#xA;  // set date time callback function&#xA;  SdFile::dateTimeCallback(dateTime); &#xA;&#xA;  // initialize the SD card&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;&#xA;  // see if the card is present and can be initialized:&#xA;  if (! sd.begin(chipSelect, SPI_HALF_SPEED))&#xA;    error(&quot;Card failed, or not present&quot;);&#xA;&#xA;  Serial.println(&quot;Card initialized&quot;);&#xA;&#xA;  // see if the directory exists, create it if not.&#xA;  sd.chdir(&quot;/&quot;);&#xA;  if( !sd.exists(directory) &amp;amp;&amp;amp; !sd.mkdir(directory) )&#xA;    error(&quot;File directory not created&quot;); &#xA;&#xA;  // create new file name&#xA;  newFileName();&#xA;&#xA;  // Scan root folder for temp files&#xA;  sd.chdir(&quot;/&quot;);&#xA;  while( logfile.openNext(sd.vwd(), O_READ)){&#xA;    if( !logfile.isDir() ) {     &#xA;      logfile.printName(&amp;amp;Serial);&#xA;      if( logfile.fileSize() &amp;lt; 20480 ){&#xA;        Serial.print(&quot; file size too small. &quot;);&#xA;        Serial.print(logfile.fileSize());&#xA;        Serial.println(&quot; bytes.&quot;);&#xA;        logfile.remove(); //Delete under sized files&#xA;      }else&#xA;        if( !logfile.rename(sd.vwd(), filename))&#xA;          error(&quot; could not be renamed.&quot;);&#xA;        else{&#xA;          Serial.print(&quot; renamed to &quot;);&#xA;          Serial.println(filename);&#xA;        }&#xA;    }&#xA;    logfile.close();&#xA;  }&#xA;&#xA;  // create temp file&#xA;  sd.chdir(&quot;/&quot;);&#xA;  if(!logfile.open(tempfile, O_WRITE | O_CREAT)) // only open a new file if it doesn't exist&#xA;    error(&quot;couldnt create temp file&quot;);&#xA;&#xA;  Serial1.begin(115200);&#xA;&#xA;  // Rotate the buffer&#xA;  for( int j = 0; j &amp;lt; 256; j++) {&#xA;    Serial1.read();&#xA;  }&#xA;&#xA;  // Look for the '!' character&#xA;  while (Serial1.peek() != '!' )&#xA;    Serial1.read();&#xA;&#xA;  Serial.println(&quot;Logging...&quot;);&#xA;  Serial.println();&#xA;&#xA;  // Reset buffer index to 0&#xA;  i = 0;  &#xA;}&#xA;&#xA;/*************** MAIN LOOP ***************/&#xA;void loop(void)&#xA;{&#xA;  if (Serial1.available()){&#xA;    logfile.print( (char)Serial1.read() );  &#xA;    i++;&#xA;  }&#xA;&#xA;  if (i &amp;gt;= SOFT_BUFFER_SIZE)&#xA;  {&#xA;    logfile.sync();&#xA;    i = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3554" LastActivityDate="2014-08-27T16:58:56.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3948" PostTypeId="2" ParentId="3946" CreationDate="2014-08-27T17:42:31.270" Score="4" Body="&lt;p&gt;The nano can run an IMU just fine, but unfortunately no accelerometer based IMU short of some fancy missile guidance tech is going to be able to track position as accurately as you seem to want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the Gyro and Magnometer only help with rotational orientation, the accelerometer is the only source of info on linear motion, and it has to be integrated twice to get position or distance. This site has a great explanation: &#xA;&lt;a href=&quot;http://www.chrobotics.com/library/accel-position-velocity&quot; rel=&quot;noreferrer&quot;&gt;http://www.chrobotics.com/library/accel-position-velocity&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As their table shows, even with an angular error of only .1 degrees, after 1 minute your position could be off by 62 meters with a standard quality accelerometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as IMU's go, the MPU 6050 (accl, gyro) and MPU 9150 (Accl, gyro and mag) are pretty standard in the hobby area, and sparkfun has some breakouts. The AltiIMU from Pololu has similar features and comparable cost. If you don't want to do the sensor processing the UM7 from chrobotics works well, but is significantly more expensive.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-08-27T17:42:31.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3949" PostTypeId="1" CreationDate="2014-08-27T18:50:21.237" Score="2" ViewCount="209" Body="&lt;p&gt;I'm building something that will mostly run on bare ATmega328p at 8 MHz (as described eg. &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11637&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;), but sometimes I need to run the same code on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to &lt;strong&gt;&lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.ino#L21&quot; rel=&quot;nofollow&quot;&gt;initialize the DHT library&lt;/a&gt;&lt;/strong&gt; depending on the clock frequency. For simplicity, I'd rather detect the running environment runtime, in the program itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there a straightforward way to detect the clock speed (from fuses?) or some other difference between a stock UNO board and a bare ATmega328p using the internal 8 MHz clock?&lt;/p&gt;&#xA;" OwnerUserId="943" LastActivityDate="2014-09-01T04:20:06.833" Title="How to detect if running Arduino or bare Atmega328p?" Tags="|frequency|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3951" PostTypeId="2" ParentId="3949" CreationDate="2014-08-27T21:09:40.597" Score="3" Body="&lt;p&gt;Bare vs Stock is nearly impossible to detect at compile time. Where it depends on what you think you are trying to determine versus detect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I can think of is creating a different Board definition; one for your bare and the other being the stock (i.g. UNO). Where now in IDE 1.5 see &lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&quot; rel=&quot;nofollow&quot;&gt;github.com/arduino/Arduino/wiki/…&lt;/a&gt; the parameter uno.build.board=AVR_UNO, which provides is used to set a compile-time variable ARDUINO_{build.board} to allow use of conditional code between #ifdefs. So you can create bare board definition with e.g. bare.build.board=MY_BARE and then have some #ifdef's for ARDUINO_MY_BARE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise wrap some #ifdef's around F_CPU as @sechleen points out. This is viable and done often in the core libraries.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-08-27T21:09:40.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3952" PostTypeId="1" AcceptedAnswerId="3953" CreationDate="2014-08-27T22:01:13.843" Score="0" ViewCount="192" Body="&lt;p&gt;I am simultaneously using a LEGO sound sensor in pin A5 and a RadioShack Tricolor LED Strip (Product #2760339) in pin A0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sound sensor alone works as expected (producing values based on volume) running only code to read the value and output to the serial monitor. However when I upload the program to use the LED strip, read the sensor value and output to the serial monitor, the sensor value caps at 174. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program given to run the LED strip can be found at &lt;a href=&quot;http://blog.radioshack.com/2013/06/tricolor-led-strip/&quot; rel=&quot;nofollow&quot;&gt;http://blog.radioshack.com/2013/06/tricolor-led-strip/&lt;/a&gt;&#xA;The code I added to this was pulled mostly directly from the AnalogInOutSerial example provided by Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the full code;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/***************************************************************************/    &#xA;//            Hardware: RadioShack Tricolor LED Strip&#xA;//            Arduino IDE: Arduino-1.0&#xA;//            Date:      April 17, 2013&#xA;//            Copyright© 2013 RadioShack Corporation&#xA;//&#xA;//  This library is free software; you can redistribute it and/or&#xA;//  modify it under the terms of the GNU Lesser General Public&#xA;//  License as published by the Free Software Foundation; either&#xA;//  version 2.1 of the License, or (at your option) any later version.&#xA;//&#xA;//  This library is distributed in the hope that it will be useful,&#xA;//  but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA;//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&#xA;//  Lesser General Public License for more details.&#xA;//&#xA;//  You should have received a copy of the GNU Lesser General Public&#xA;//  License along with this library; if not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;&#xA;//&#xA;/*****************************************************************************/&#xA;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;// ******** DEBUG ==== should auto config to adapt different mother board *********&#xA;//#define DATA_1 (PORTF |=  0X01)    // DATA 1    // for ATMEGA&#xA;//#define DATA_0 (PORTF &amp;amp;=  0XFE)    // DATA 0    // for ATMEGA&#xA;//#define STRIP_PINOUT DDRF=0xFF  // for ATMEGA&#xA;#define DATA_1 (PORTC |=  0X01)    // DATA 1    // for UNO&#xA;#define DATA_0 (PORTC &amp;amp;=  0XFE)    // DATA 0    // for UNO&#xA;#define STRIP_PINOUT (DDRC=0xFF)    // for UNO&#xA;&#xA;PROGMEM const unsigned long rainbow_full[5][10]={&#xA;  {0xff0000,0x00ff00,0x0000ff,0xffff00,0xff00ff,0xffffff,0xff6622,0xff0000,0xff0000,0xff0000},&#xA;&#xA;};&#xA;PROGMEM const unsigned long off[1][10] = {&#xA;   {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red1[1][10] = {&#xA;   {0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red2[1][10] = {&#xA;   {0xff0000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red3[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red4[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red5[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red6[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0x000000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red7[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0x000000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red8[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0x000000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long red9[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0x000000},&#xA;};&#xA;PROGMEM const unsigned long redfull[1][10] = {&#xA;   {0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000},&#xA;};&#xA;&#xA;&#xA;/*PROGMEM const unsigned long pattern_test_blue[10][10]={&#xA;  {0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00ff00},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_green[10][10]={&#xA;  {0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000ff},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_white[10][10]={&#xA;  {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_comet1[][10]={&#xA;  {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},&#xA;  {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_comet2[][10]={&#xA;  {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},&#xA;  {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},&#xA;  {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},&#xA;  {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},&#xA;  {0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000},&#xA;  {0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000},&#xA;  {0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000},&#xA;  {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},&#xA;  {0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0x111111,0x444444,0xffffff},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_comet3[][10]={&#xA;  {0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff},&#xA;  {0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444},&#xA;  {0x111111,0x444444,0xffffff,0x000000,0x000000,0x000000,0x000000,0xffffff,0x444444,0x111111},&#xA;  {0x000000,0x111111,0x444444,0xffffff,0x000000,0x000000,0xffffff,0x444444,0x111111,0x000000},&#xA;  {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x111111,0x444444,0xffffff,0xffffff,0x444444,0x111111,0x000000,0x000000},&#xA;  {0x000000,0x000000,0x000000,0xffffff,0x444444,0x444444,0xffffff,0x000000,0x000000,0x000000},&#xA;  {0x000000,0x000000,0xffffff,0x444444,0x111111,0x111111,0x444444,0xffffff,0x000000,0x000000},&#xA;  {0x000000,0xffffff,0x444444,0x111111,0x000000,0x000000,0x111111,0x444444,0xffffff,0x000000},&#xA;  {0xffffff,0x444444,0x111111,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xffffff},&#xA;};&#xA;&#xA;PROGMEM const unsigned long pattern_test_rainbow[10][10]={&#xA;  {0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000},&#xA;  {0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000},&#xA;  {0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000},&#xA;  {0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff},&#xA;  {0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff},&#xA;  {0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00,0x0000ff},&#xA;  {0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00,0x00ff00},&#xA;  {0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00,0xffff00},&#xA;  {0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000,0xff7f00},&#xA;  {0xff7f00,0xffff00,0x00ff00,0x0000ff,0x6f00ff,0x8f00ff,0x000000,0x000000,0x000000,0xff0000},&#xA;};&#xA;&#xA;&#xA;*/&#xA;&#xA;// ***********************************************************************************************************&#xA;// *&#xA;// *                            Power Up Init.&#xA;// *&#xA;// *&#xA;// ***********************************************************************************************************&#xA;&#xA;int sensorvalue = 0;&#xA;int outputvalue = 0;&#xA;void setup() {&#xA;&#xA;&#xA;&#xA;&#xA;  STRIP_PINOUT;        // set output pin - DEBUG: should auto detect which mother board for use&#xA;&#xA;&#xA;  reset_strip();&#xA;  Serial.begin(9600);&#xA;  //noInterrupts();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;// ***********************************************************************************************************&#xA;// *&#xA;// *                            Main Loop &#xA;// *&#xA;// *&#xA;// ***********************************************************************************************************&#xA;void loop() &#xA;{&#xA;&#xA;&#xA;&#xA;&#xA;    sensorvalue = analogRead(A5);&#xA;    outputvalue = map(sensorvalue, 0, 174, 0, 18);&#xA;    if(outputvalue == 0){&#xA;      send_1M_pattern(off, 1, 20);&#xA;    }&#xA;&#xA;    else if(outputvalue &amp;gt; 0 &amp;amp;&amp;amp; outputvalue &amp;lt;= 3){&#xA;      send_1M_pattern(red1, 1, 20);&#xA;    }&#xA;    else if(outputvalue &amp;gt; 3 &amp;amp;&amp;amp; outputvalue &amp;lt;= 5){&#xA;      send_1M_pattern(red2, 1, 20);&#xA;    }&#xA;    else if(outputvalue &amp;gt; 5 &amp;amp;&amp;amp; outputvalue &amp;lt;= 7){&#xA;      send_1M_pattern(red3, 1, 20);&#xA;    }&#xA;    else if(outputvalue &amp;gt; 7 &amp;amp;&amp;amp; outputvalue &amp;lt;= 9){&#xA;      send_1M_pattern(red4, 1, 20);&#xA;    }&#xA;&#xA;    else if(outputvalue &amp;gt; 9 &amp;amp;&amp;amp; outputvalue &amp;lt;= 11){&#xA;      send_1M_pattern(red5, 1, 20);&#xA;    }&#xA;&#xA;    else if(outputvalue &amp;gt; 11 &amp;amp;&amp;amp; outputvalue &amp;lt;= 13){&#xA;      send_1M_pattern(red6, 1, 20);&#xA;    }&#xA;&#xA;    else if(outputvalue &amp;gt; 13 &amp;amp;&amp;amp; outputvalue &amp;lt;= 16){&#xA;      send_1M_pattern(red9, 1, 20);&#xA;    }&#xA;&#xA;    else if(outputvalue &amp;gt; 16){&#xA;      send_1M_pattern(rainbow_full, 1, 20);&#xA;    }&#xA;    Serial.print(&quot;sensor = &quot; );&#xA;    Serial.print(sensorvalue);&#xA;    Serial.print(&quot;\t output = &quot;);&#xA;    Serial.println(outputvalue);&#xA;&#xA;    delay(2);&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;  /*&#xA;    frame++;&#xA;    if(frame&amp;lt;=10) LEDSTRIP_PATTERN_0();&#xA;    if(10&amp;lt;frame&amp;lt;=20) LEDSTRIP_PATTERN_0();&#xA;    if(20&amp;lt;frame&amp;lt;=30) LEDSTRIP_PATTERN_0();&#xA;    if(frame&amp;gt;30) frame=1;&#xA;   */&#xA;  //delay(1);&#xA;}&#xA;&#xA;&#xA;/*******************************************************************************&#xA; * Function Name  : send_1M_pattern&#xA; * Description    : Transmit pattern to whole 1 meter strip&#xA; *                  &#xA; * Input          : pointer to ROM pattern; pattern length; frame rate&#xA; *                  &#xA; * Output         : None&#xA; * Return         : None&#xA; *******************************************************************************/&#xA;void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate)&#xA;{&#xA;  int i=0;&#xA;  int j=0;&#xA;  uint32_t temp_data;&#xA;&#xA;  for (i=0;i&amp;lt;pattern_no;i++)&#xA;  {&#xA;    noInterrupts();&#xA;    for (j=0;j&amp;lt;10;j++)&#xA;    {&#xA;      temp_data=pgm_read_dword_near(&amp;amp;data[i][j]);&#xA;      send_strip(temp_data);&#xA;    }&#xA;    interrupts();&#xA;&#xA;    delay(frame_rate);&#xA;&#xA;  }&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;/*******************************************************************************&#xA; * Function Name  : send_strip&#xA; * Description    : Transmit 24 pulse to LED strip&#xA; *                  &#xA; * Input          : 24-bit data for the strip&#xA; *                  &#xA; * Output         : None&#xA; * Return         : None&#xA; *******************************************************************************/&#xA;void send_strip(uint32_t data)&#xA;{&#xA;  int i;&#xA;  unsigned long j=0x800000;&#xA;&#xA;&#xA;  for (i=0;i&amp;lt;24;i++)&#xA;  {&#xA;    if (data &amp;amp; j)&#xA;    {&#xA;      DATA_1;&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);    &#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;&#xA;/*----------------------------*/&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);  &#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);  &#xA;      __asm__(&quot;nop\n\t&quot;);  &#xA;      __asm__(&quot;nop\n\t&quot;);        &#xA;/*----------------------------*/      &#xA;      DATA_0;&#xA;    }&#xA;    else&#xA;    {&#xA;      DATA_1;&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);    &#xA;      DATA_0;&#xA;/*----------------------------*/      &#xA;       __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);&#xA;      __asm__(&quot;nop\n\t&quot;);      &#xA;/*----------------------------*/         &#xA;    }&#xA;&#xA;    j&amp;gt;&amp;gt;=1;&#xA;  }&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;/*******************************************************************************&#xA; * Function Name  : reset_strip&#xA; * Description    : Send reset pulse to reset all color of the strip&#xA; *                  &#xA; * Input          : None&#xA; *                  &#xA; * Output         : None&#xA; * Return         : None&#xA; *******************************************************************************/&#xA;void    reset_strip()&#xA;{&#xA;  DATA_0;&#xA;  delayMicroseconds(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3740" LastEditorUserId="3740" LastEditDate="2014-08-28T00:45:29.737" LastActivityDate="2014-08-28T01:49:18.647" Title="Arduino Uno- Analog serial monitor not reading values over 174" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="3953" PostTypeId="2" ParentId="3952" CreationDate="2014-08-28T01:49:18.647" Score="2" Body="&lt;p&gt;A5 is PC5. Your code sets it as an output. Since you only need A0 (PC0) to be an output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define STRIP_PINOUT (DDRC = _BV(PC0))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow&quot;&gt;Uno pin mappings&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-28T01:49:18.647" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="3954" PostTypeId="2" ParentId="3940" CreationDate="2014-08-28T05:43:58.983" Score="0" Body="&lt;p&gt;I fixed my problem by changing my sketch to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge&amp;gt;&#xA;#include &amp;lt;Console.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;YunServer server;&#xA;boolean receiving = false;&#xA;&#xA;void setup() {&#xA;  Bridge.begin();&#xA;  Console.begin();&#xA;  server.listenOnLocalhost();&#xA;  server.begin();&#xA;  Console.println(&quot;Ready&quot;);&#xA;}&#xA;&#xA;void loop() {  &#xA;  YunClient client = server.accept();&#xA;&#xA;  if (client) {&#xA;    String command = client.readString();&#xA;    command.trim();&#xA;&#xA;    if (command == &quot;threeBeeps&quot;) {&#xA;      Console.println(&quot;Three Beeps&quot;);&#xA;      threeBeeps();&#xA;    }&#xA;    if (command == &quot;fastBeeps&quot;) {&#xA;      Console.println(&quot;Fast Beeps&quot;);&#xA;      fastBeeps();&#xA;    } &#xA;    if (command == &quot;fastScale&quot;) {&#xA;      Console.println(&quot;Fast Scale&quot;);&#xA;      fastScale();&#xA;    }&#xA;    if (command == &quot;siren&quot;) {&#xA;      Console.println(&quot;Siren&quot;);&#xA;      playSiren();&#xA;    }&#xA;    if (command == &quot;evilAlarm&quot;) {&#xA;      Console.println(&quot;Evil Alarm&quot;);&#xA;      evilChord(); &#xA;    }&#xA;    client.stop();&#xA;  }&#xA;  delay(50);&#xA;}&#xA;&#xA;void threeBeeps() {&#xA;  for (int i = 0; i &amp;lt; 3; i++) {&#xA;    tone(11,2200);&#xA;    delay(100);&#xA;    noTone(11);&#xA;    delay(100); &#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&#xA;void fastScale() {&#xA;  for (int i = 0; i &amp;lt; 1000; i++) {&#xA;    tone(11,(i * 2)); &#xA;    delay(1);&#xA;  }&#xA;  for (int i = 1000; i &amp;gt; 0; i--) {&#xA;    tone(11,(i * 2)); &#xA;    delay(1);&#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&#xA;void playSiren() {&#xA;  for (int i = 0; i &amp;lt; 5; i++) {&#xA;    for (int j = 1000; j &amp;lt; 4000; j++) {&#xA;      tone(11,j);  &#xA;    }&#xA;    for (int j = 4000; j &amp;gt; 1000; j--) {&#xA;      tone(11,j);&#xA;    }&#xA;  }&#xA;  noTone(11); &#xA;}&#xA;&#xA;void fastBeeps() {&#xA;  for (int i = 0; i &amp;lt; 6; i++) {&#xA;    tone(11,2000);&#xA;    delay(50);&#xA;    noTone(11);&#xA;    delay(50); &#xA;  }&#xA;  noTone(11); &#xA;}&#xA;&#xA;void evilChord() {&#xA;  for (int i = 0; i &amp;lt; 5; i++) {&#xA;    tone(11,1110);&#xA;    delay(500);&#xA;    tone(11,785);  &#xA;    delay(500);&#xA;  }&#xA;  noTone(11);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also by changing my webpage to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;&#xA;    &amp;lt;script type=&quot;text/javascript&quot; src=&quot;zepto.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;    &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&#xA;function threeBeeps() {&#xA;$('#content').load('/arduino/threeBeeps');&#xA;}&#xA;function fastBeeps() {&#xA;$('#content').load('/arduino/fastBeeps');&#xA;}&#xA;function fastScale() {&#xA;$('#content').load('/arduino/fastScale');&#xA;}&#xA;function siren() {&#xA;$('#content').load('/arduino/siren');&#xA;}&#xA;function evilAlarm() {&#xA;$('#content').load('/arduino/evilAlarm');&#xA;}&#xA;&amp;lt;/script&amp;gt;&#xA;&#xA;&amp;lt;/head&amp;gt;&#xA;&#xA;&amp;lt;body onload=&quot;setInterval(refresh, 2000);&quot;&amp;gt;&#xA;&amp;lt;span id=&quot;content&quot;&amp;gt;&amp;lt;/span&amp;gt;&#xA;&#xA;&amp;lt;button onclick=&quot;threeBeeps()&quot;&amp;gt;Three Beeps&amp;lt;/button&amp;gt;&#xA;&amp;lt;button onclick=&quot;fastBeeps()&quot;&amp;gt;Fast Beeps&amp;lt;/button&amp;gt;&#xA;&amp;lt;button onclick=&quot;fastScale()&quot;&amp;gt;Fast Scale&amp;lt;/button&amp;gt;&#xA;&amp;lt;button onclick=&quot;siren()&quot;&amp;gt;Siren&amp;lt;/button&amp;gt;&#xA;&amp;lt;button onclick=&quot;evilAlarm()&quot;&amp;gt;Evil Alarm&amp;lt;/button&amp;gt;&#xA;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also include the &lt;code&gt;zepto.min.js&lt;/code&gt; Javascript file.&lt;/p&gt;&#xA;" OwnerUserId="3727" LastActivityDate="2014-08-28T05:43:58.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3957" PostTypeId="1" CreationDate="2014-08-28T12:21:14.530" Score="1" ViewCount="402" Body="&lt;p&gt;I have created a retro keyobard using a ZX spectrum and a PRO MICRO based on the info here: &lt;a href=&quot;http://blog.tynemouthsoftware.co.uk/2013/04/arduino-leonardo-based-zx81-usb-keyboard.html&quot; rel=&quot;nofollow&quot;&gt;http://blog.tynemouthsoftware.co.uk/2013/04/arduino-leonardo-based-zx81-usb-keyboard.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When plugged into my laptop or a raspberry PI it works fine. However, when running any of the emulators like FUSE it doesn't work at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain why this is and what I have to do to make it work? Searching around on the web I see it has something to do with the key mapping which I can understand for when I do shifted keys but why it doesn't work when I just press p is eluding me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;When using a USB sniffing program I can see that my &quot;real&quot; keyboard sends 0x8 bytes for an 'a' 00 00 04 00 00 00 00 00&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT my arduino sends 0x9 for an 'a' 02 00 00 04 00 00 00 00 00 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Snippets of the the code I am using is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// keyMap and keyMapShifted are both 2D arrays of type byte&#xA;byte keyMap[8][5] = { {'5', '4', '3', '2', '1' ....etc&#xA;byte key = shifted ? keyMapShifted[[r][c] : keyMap[r][c]&#xA;Keyboard.write(key)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideas? A Bug? Do I have to rewrite Keyboard.write?&lt;/p&gt;&#xA;" OwnerUserId="3747" LastEditorUserId="3747" LastEditDate="2014-08-29T23:03:13.990" LastActivityDate="2014-08-29T23:03:13.990" Title="USB Keyboard in Retro Emulators" Tags="|programming|arduino-pro-micro|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="3959" PostTypeId="1" AcceptedAnswerId="3979" CreationDate="2014-08-28T13:59:10.810" Score="1" ViewCount="14998" Body="&lt;p&gt;I'm trying to scroll a string in the second row of the LCD while letting the string on the first row stay intact. I use Serial to run that part of the code as you can see. It work at first but when I try to make it run again it doesn't display anything on the second row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I borrowed the code from :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://code.nishantarora.in/arduino-lcd-projects/src/3f10686e7464665c5c59d7be772c00af7a4a93e8/scrollOneLine/scrollOneLine.ino?at=master&quot; rel=&quot;nofollow&quot;&gt;http://code.nishantarora.in/arduino-lcd-projects/src/3f10686e7464665c5c59d7be772c00af7a4a93e8/scrollOneLine/scrollOneLine.ino?at=master&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And made some changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the library&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// init the lcd display according to the circuit&#xA;LiquidCrystal lcd(9, 8, 7, 6, 5, 4);&#xA;&#xA;// it's a 16x2 LCD so...&#xA;int screenWidth = 16;&#xA;int screenHeight = 2;&#xA;&#xA;String line1;&#xA;String line2;&#xA;&#xA;int stringStart, stringStop = 0;&#xA;int scrollCursor = screenWidth;&#xA;&#xA;String CompleteString;&#xA;String stringArray[] = {&quot;s=Plane&quot;, &quot;i=Car&quot;, &quot;h=Boat&quot;, &quot;u=Rocket&quot;, &quot;d=Jet&quot;,  &quot;p=Submarine&quot;, &quot;l=Truck&quot;, &quot;b=Bicycle&quot;, &quot;m=Skate&quot;, &quot;enter=Train&quot;};&#xA;&#xA;String string1 = &quot;String&quot;;&#xA;&#xA;int countMovement=0;&#xA;int arraylimit = 9;&#xA;&#xA;void setup() {&#xA;&#xA;   lcd.begin(screenWidth,screenHeight);&#xA;   Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;   char ser = Serial.read();&#xA;&#xA;   if ( ser == 'c' ) {  &#xA;     CompleteString=&quot;&quot;;&#xA;&#xA;     for (int i = 0 ; i &amp;lt;= arraylimit; i++) {&#xA;        CompleteString += stringArray[i] + &quot; &quot;; // Convert String Array To Single String&#xA;     }&#xA;&#xA;     roop(string1,CompleteString);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void roop(String line1, String line2) {&#xA;&#xA;  countMovement = 0;&#xA;&#xA;  while ( ( countMovement ) &amp;lt; (line2.length() + screenWidth )  ) {&#xA;&#xA;     lcd.setCursor(scrollCursor, 1);&#xA;     lcd.print(line2.substring(stringStart,stringStop));&#xA;     lcd.setCursor(4, 0); // 1 = word eat array of words very cool&#xA;     lcd.print(line1);&#xA;     delay(300);&#xA;     lcd.clear();&#xA;&#xA;     if(stringStart == 0 &amp;amp;&amp;amp; scrollCursor &amp;gt; 0){&#xA;        // Serial.println(scrollCursor);     &#xA;        scrollCursor--;&#xA;        stringStop++;&#xA;     } else if (stringStart == stringStop){&#xA;        stringStart = stringStop = 0;&#xA;        scrollCursor = screenWidth;&#xA;     } else if (stringStop == line1.length() &amp;amp;&amp;amp; scrollCursor == 0) {&#xA;        stringStart++;&#xA;     } else {&#xA;       stringStart++;&#xA;       stringStop++;&#xA;     }&#xA;&#xA;     countMovement++;&#xA;&#xA;  }&#xA;&#xA;  lcd.setCursor(4, 0);&#xA;  lcd.print(line1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From what I can see using Serial as debugging is that the problem resides in the function &quot;roop&quot; and in specific the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if(stringStart == 0 &amp;amp;&amp;amp; scrollCursor &amp;gt; 0){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that the statement is being pass on and so it doesn't move the string as it's suppose to. I could be wrong but placing a Serial call in there yields no result the second time the function is called but the first time it did.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated! And I know the community will be grateful too since it's difficult from what I can see in post to achieve this and make it autonomous so that no big modifications needs to be done. &lt;/p&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="37" LastEditDate="2014-08-28T22:29:23.670" LastActivityDate="2015-03-27T11:06:19.823" Title="Scroll String Only On Second Line Using 2x16 LCD" Tags="|programming|lcd|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3960" PostTypeId="1" CreationDate="2014-08-28T15:10:27.543" Score="0" ViewCount="885" Body="&lt;p&gt;I'm building a Arduino Nano based underwater navigation system using an IMU and various sensors. The only problem with this is that I cannot get the speed or velocity(at least reliably) and it would help the accuracy of my navigation system immensely if I had accurate speed to go off of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any ideas on how I could measure the speed of my Arduino underwater? I've seen some people recommend paddle wheel like sensors but this needs to be accurate for slow movement.&lt;/p&gt;&#xA;" OwnerUserId="3736" LastActivityDate="2015-01-27T01:26:53.713" Title="What sensor would I use to get the speed or velocity of my Arduino based nav system?" Tags="|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3961" PostTypeId="1" CreationDate="2014-08-28T19:17:39.430" Score="1" ViewCount="164" Body="&lt;p&gt;As in title. I've got quadrocopter where Li-Po is parallely connected to motors as well as to arduino. May current driftage cause arduino hangs ?&lt;/p&gt;&#xA;" OwnerUserId="3751" LastActivityDate="2014-08-30T21:58:25.163" Title="May arduino hang when current is changing over time?" Tags="|current|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3962" PostTypeId="1" AcceptedAnswerId="3963" CreationDate="2014-08-28T21:09:49.777" Score="2" ViewCount="5545" Body="&lt;p&gt;I want to send text over serial monitor to Arduino and make Arduino return that string back to me over serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made this function which reads from serial input and returns a string object.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String readSerial() {&#xA;    String input;&#xA;    while(Serial.available() &amp;gt; 0)&#xA;        input.concat(Serial.read());&#xA;    return input;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;loop()&lt;/code&gt; I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available()) Serial.print(readSerial());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I just do something like &lt;code&gt;Serial.print(&quot;Hello world!&quot;);&lt;/code&gt; everything is fine. But, if I try to return string object I get lot's of numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess &lt;code&gt;Serial.print&lt;/code&gt; doesn't know how to read &lt;code&gt;String&lt;/code&gt; object and returns ASCII codes of characters or something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update]&lt;/strong&gt;&#xA;I have checked it, and it's indeed outputing ASCII codes. For &lt;code&gt;Hi&lt;/code&gt; I get &lt;code&gt;72105&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update]&lt;/strong&gt;&#xA;I have updated my &lt;code&gt;readSerial&lt;/code&gt; function to use this :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;input += (char)Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But now I'm getting carriage return and new line after every character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[SEND] Hi&#xA;H(CR)&#xA;i(CR)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, how can I make it return my text so that is readable?&lt;/p&gt;&#xA;" OwnerUserId="3756" LastEditorUserId="3756" LastEditDate="2014-08-28T21:37:15.500" LastActivityDate="2016-03-30T16:51:24.970" Title="Print string from arduino to serial monitor" Tags="|serial|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3963" PostTypeId="2" ParentId="3962" CreationDate="2014-08-28T21:38:36.543" Score="1" Body="&lt;p&gt;&lt;code&gt;String.concat()&lt;/code&gt; takes a &lt;code&gt;String&lt;/code&gt; as the second argument. &lt;code&gt;Serial.read()&lt;/code&gt; returns an &lt;code&gt;int&lt;/code&gt;. The compiler creates code that converts the &lt;code&gt;int&lt;/code&gt; into a &lt;code&gt;String&lt;/code&gt; similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;input.concat(String(Serial.read()));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's tell the compiler what you really want instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;input.concat((char)Serial.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will tell the compiler to do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;input.concat(String((char)Serial.read()));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We are now having the compiler call the correct &lt;code&gt;String&lt;/code&gt; constructor, and the code will work as we expect.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-28T21:38:36.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3964" PostTypeId="1" AcceptedAnswerId="3965" CreationDate="2014-08-28T22:06:26.997" Score="1" ViewCount="3745" Body="&lt;p&gt;I have two devices. Sensor for temperature and humidity and lcd screen. Both require SDA pin, and I have only one on my arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want my display to show current temperature but I don't know how to connect two things on one pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I somehow read from other pins maybe?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what can I do if I have only 1 5V source and I have two devices that require 5V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino model is &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 2560 R3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;http://meteobox.tk/files/AM2301.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; aosong sensor (AM2301), and I have YwRobots 2 row LCD screen which I want to connect to my board along with sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So... I'm not sure how to connect those two if both require SDA and I have only one.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3756" LastActivityDate="2014-08-28T22:12:48.647" Title="Two devices on one SDA input" Tags="|sensors|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3965" PostTypeId="2" ParentId="3964" CreationDate="2014-08-28T22:12:48.647" Score="3" Body="&lt;p&gt;You can have multiple I&lt;sup&gt;2&lt;/sup&gt;C devices on the same bus (sharing both SDA and SCL), as long as they have different addresses. The library used to access them should know (or be told, if required) what the address for the device is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they are not I&lt;sup&gt;2&lt;/sup&gt;C devices then they cannot both use SDA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Aosong device is &lt;em&gt;not&lt;/em&gt; an I&lt;sup&gt;2&lt;/sup&gt;C device, but there is no need to connect its &quot;SDA&quot; pin to the Arduino's &quot;SDA&quot; pin; any unused digital pin should work, as long as the library is told which pin to find it on and as long as the electrical requirements of the connection are met.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-08-28T22:12:48.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="3966" PostTypeId="2" ParentId="3961" CreationDate="2014-08-29T00:37:37.303" Score="4" Body="&lt;p&gt;There really isn't any such thing as &quot;Current driftage&quot;. If you draw too much current from your battery it will cause the voltage to drop, and if it drops too much, the Arduino will stop working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have high current devices like motors being switched on the same power supply as your Arduino you should add a reservoir capacitor as close to the input of your Arduino as possible. That will even out short term drops and spikes in supply voltage as your motors switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you draw too much current continuously then your supply voltage will drop and stay dropped, and a reservoir capacitor won't help. In that case you need a higher current battery (or separate power supplies for your Arduino and motors.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: From your question it's pretty clear that you don't understand voltage and current and how they relate. I suggest you read up on the subject.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, the amount of current that flows through a component is determined by the voltage divided by the resistance: i = v/r. (Where i = current in amps, v = voltage, and r = resistance in ohms.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current that will flow will be limited by the max current that the power supply can provide. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a non-regulated supply like a battery, the voltage from the supply will drop as you draw more and more current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a regulated supply, the supply keeps the voltage constant up to it's maximum current limit.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-08-30T21:58:25.163" LastActivityDate="2014-08-30T21:58:25.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3968" PostTypeId="1" AcceptedAnswerId="3969" CreationDate="2014-08-29T04:59:02.237" Score="0" ViewCount="988" Body="&lt;p&gt;I have a Freetronics &lt;a href=&quot;http://littlebirdelectronics.com.au/products/etherten-100-arduino-compatible-with-onboard-ethernet&quot; rel=&quot;nofollow&quot;&gt;Etherten&lt;/a&gt; and am trying to use the &lt;a href=&quot;http://littlebirdelectronics.com.au/products/nfc-shield-v2-0&quot; rel=&quot;nofollow&quot;&gt;NFC Shield&lt;/a&gt; - both the board and shield are trying to use Pins D10,D11,D12,D13&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question - Is there an elegant way to have these two work together.  This really applies to any combination of shield with conflicting pins.  I'm thinking maybe use some in between headers or M/F jumper wires?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a neat way to do it?&lt;/p&gt;&#xA;" OwnerUserId="3769" OwnerDisplayName="mad_z" LastActivityDate="2014-08-29T05:50:30.013" Title="Arduino Shield Pin Conflict" Tags="|pins|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3969" PostTypeId="2" ParentId="3968" CreationDate="2014-08-29T05:50:30.013" Score="2" Body="&lt;p&gt;You need this: &lt;a href=&quot;https://www.sparkfun.com/products/11002&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11002&lt;/a&gt;&lt;br&gt;&#xA;&quot;The Go-Between Shield “goes between” two shields that aren’t compatible and effectively reassigns the pins. This trickery is achieved by isolating the top and bottom sides of the shield with surface mount headers and breaking them out into tables of jumpers that can be bridged to divert signals to and from different pins.&quot;&lt;/p&gt;&#xA;" OwnerUserId="1307" LastActivityDate="2014-08-29T05:50:30.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3970" PostTypeId="1" CreationDate="2014-08-29T08:28:38.077" Score="-2" ViewCount="24482" Body="&lt;p&gt;I have a SIM900 module and Arduino, both are working fine. In my previous programs I have use strstr() command to find specific word from a string but they were constants and pre defined in the program but now I want to read serial communication from SIM900 and detect a specific word from it. But it is showing me &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;invalid conversion from 'char' to 'const char'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is my program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x;&#xA;char sms;&#xA;char response;&#xA;char disp;&#xA;void setup()&#xA;{&#xA;  Serial.begin(2400);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  while(Serial.available() == 0);&#xA;&#xA;  if(Serial.available() &amp;gt; 0)&#xA;  {    &#xA;    sms = Serial.read();&#xA;&#xA;    disp = sms;&#xA;    if (strstr(disp,&quot;track&quot;)) //Comparing word entered with word stored in program&#xA;    {&#xA;      Serial.println(&quot;Found the  word!&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3761" LastEditorUserId="3761" LastEditDate="2014-08-29T18:16:56.727" LastActivityDate="2015-06-27T08:33:18.520" Title="how to use strstr() in serial communication?" Tags="|arduino-uno|programming|serial|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3972" PostTypeId="2" ParentId="3961" CreationDate="2014-08-29T08:38:17.750" Score="1" Body="&lt;p&gt;May i ask why you don't have a separate battery for the arduino? If it is because of weight, an arduino can run of CR2032 batteries, gives it its own power supply, this should solve the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a battery with more longevity Google &quot;6v 2/3 battery&quot; (2/3 the size of an AA battery), small with loads of voltage for the arduino and with some skilled programming it should last for a flight or two, and the +side, you can get it rechargable.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-08-29T08:38:17.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3973" PostTypeId="2" ParentId="3357" CreationDate="2014-08-29T08:45:19.540" Score="2" Body="&lt;p&gt;You can try and buy the Arduino serial board, and connect it directly to the pins on the Arduino , see if this works, basicly override the Arduino's own interface, or if you have another Arduino you can try and &quot;serial&quot; connect them using the first Arduino as ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Else it is like JRobert says, you could move the chip from another arduino burn it on that one and then put it back, using the second Arduino as a run only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not least, you may find a cheap broken Arduino board on some online auction site, where the chip is broken, then move the defect chip to your defect board, and the working chip to the working board, and throw the defect Arduino in the electronics recycling. &lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-08-29T08:45:19.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3974" PostTypeId="1" AcceptedAnswerId="3977" CreationDate="2014-08-29T09:40:45.457" Score="-1" ViewCount="1656" Body="&lt;p&gt;I am not able to get my code to pass&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if(gsmAccess.begin(PINNUMBER)==GSM_READY) {&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have modified the PIN number on my sim card to be &lt;code&gt;0000&lt;/code&gt;, and yet its stuck on &lt;code&gt;begin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I prepare the SIM CARD to pass the begin&lt;/p&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="3328" LastEditDate="2014-08-30T09:36:13.570" LastActivityDate="2015-01-27T12:38:52.057" Title="Code does not pass `gsmAccess.begin(PINNUMBER)==GSM_READY)`" Tags="|gsm|" AnswerCount="1" CommentCount="4" ClosedDate="2015-01-28T03:02:28.430" ContentLicense="CC BY-SA 3.0" />
  <row Id="3975" PostTypeId="2" ParentId="3960" CreationDate="2014-08-29T12:07:09.750" Score="1" Body="&lt;p&gt;On small recreational sailboats there is a small propeller on the bottom, when it turns it dials a speedometer, the faster it turns the faster the ship goes, a similar setup should be possible. With a small propeller and 2 ball bearings and an optocoupler, (same principle you got in the scroll button on your mouse, you should be able to pull it off with minimal resistance since there is no physical parts.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-08-29T12:07:09.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3977" PostTypeId="2" ParentId="3974" CreationDate="2014-08-29T13:24:57.653" Score="1" Body="&lt;p&gt;Try putting the SIM card into a mobile phone in case it hasn't been initialised by your provider. Set up the PIN for the card using the settings on the phone, see the manual for instructions on how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can use the PIN you entered on the phone to unlock the SIM in your code.&lt;/p&gt;&#xA;" OwnerUserId="336" LastActivityDate="2014-08-29T13:24:57.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3978" PostTypeId="2" ParentId="3970" CreationDate="2014-08-29T13:40:09.327" Score="1" Body="&lt;p&gt;There are two problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) you are trying to have the Arduino's single UART talk to both the SIM900 and the PC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) disp needs to be an array of char's, as to compare for words phrases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following. It implements a 2nd Soft serial port to which you can connect the SIM900. Along with building an array char at a time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;char buffer[16];&#xA;#define buffer_size sizeof(buffer)/sizeof(buffer[0])&#xA;int8_t buffer_pos = 0;&#xA;&#xA;void setup() {&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  Serial.println(&quot;Serial to mySerial demo started&quot;);&#xA;&#xA;  buffer_pos = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;  char inByte;&#xA;  while (mySerial.available()) {&#xA;    inByte = mySerial.read();&#xA;    while (buffer_pos &amp;gt;= buffer_size) {&#xA;      for (int8_t i = 0; i &amp;lt; buffer_size - 1; i++) { // if shift buff left if at end of buff&#xA;        buffer[i] = buffer[i + 1];&#xA;      }&#xA;      buffer_pos--;&#xA;    }&#xA;    buffer[buffer_pos++] = inByte;&#xA;    if (strcasestr(buffer, &quot;track&quot;)) {&#xA;      buffer_pos = 0;&#xA;      Serial.println(&quot;TRACK FOUND!&quot;);&#xA;    } else {&#xA;      Serial.write(inByte);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-08-31T03:38:42.887" LastActivityDate="2014-08-31T03:38:42.887" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="3979" PostTypeId="2" ParentId="3959" CreationDate="2014-08-29T14:04:56.973" Score="1" Body="&lt;p&gt;You need to reset the &lt;code&gt;stringStart&lt;/code&gt;, &lt;code&gt;stringStop&lt;/code&gt; and &lt;code&gt;scrollCursor&lt;/code&gt; at the beginning of the roop function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void roop(String line1, String line2) {&#xA;&#xA;  countMovement = 0;&#xA;  stringStart = 0;&#xA;  stringStop = 0;&#xA;  scrollCursor = screenWidth;&#xA;&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you also need to move the &lt;code&gt;lcd.clear&lt;/code&gt; up. Or else the screen will be blanked when the roop function is done scrolling.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&#xA;  while ( ( countMovement ) &amp;lt; (line2.length() + screenWidth )  ) {&#xA;&#xA;     lcd.clear();&#xA;     lcd.setCursor(scrollCursor, 1);&#xA;     lcd.print(line2.substring(stringStart,stringStop));&#xA;     lcd.setCursor(4, 0); // 1 = word eat array of words very cool&#xA;     lcd.print(line1);&#xA;     delay(300);&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-29T14:04:56.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3981" PostTypeId="1" AcceptedAnswerId="3983" CreationDate="2014-08-30T11:48:29.533" Score="3" ViewCount="1458" Body="&lt;p&gt;When I read about mega2560 I saw it has 54 digital that can be used as input or output.&lt;br&gt;&#xA;later on I saw the some of them are used for things like communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would like to know if the communication pin can still be used as output ? (to power leds)&lt;/p&gt;&#xA;" OwnerUserId="3777" LastEditorUserId="313" LastEditDate="2014-08-31T16:06:05.210" LastActivityDate="2016-07-08T15:35:30.083" Title="Mega2560 R3 pin functions" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3982" PostTypeId="2" ParentId="3981" CreationDate="2014-08-30T12:06:03.530" Score="1" Body="&lt;p&gt;Yes, you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are referring to SPI, I2C, and the 4 serial interfaces. If you want to use those you have to use the predefined pins for that. If you are not using those you can use them as normal GPIO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want Serial communication for debugging, you shouldn't use digital pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need even more pins, you can even use the analog pins and digital input/output pins.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-08-30T12:06:03.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3983" PostTypeId="2" ParentId="3981" CreationDate="2014-08-30T12:18:48.397" Score="2" Body="&lt;p&gt;Yes. &lt;strong&gt;&lt;em&gt;Any&lt;/em&gt; pin can be used as a digital input/output.&lt;/strong&gt; However, you cannot use certain communications when using those pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The types of communication and their effects on the pins:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt;:&lt;/strong&gt; This protocol is used for certain communications with certain breakout boards and shields. For example, the ethernet shield uses SPI to connect. On the Mega(2560), it is pins 50-53.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/reference/wire&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt;:&lt;/strong&gt; This protocol is also for connecting to external items. It is much slower than SPI, but uses only two pins. On the Mega, it uses pins 20/21.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;UART/Serial:&lt;/strong&gt; UART is a communication method that uses two wires and transmits bytes of data. It is often used to connect to things that don't need &lt;em&gt;extreme&lt;/em&gt; amounts of data passed, but need a stable two way connection.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On all standard boards, the main UART is on pins 0 and 1. This is usually connected to a UART to USB chip which is sent to the computer. Note: you should still be able to upload sketches if they act as an &lt;em&gt;output&lt;/em&gt; and random on/off won't hurt the device.&lt;/li&gt;&#xA;&lt;li&gt;The Mega(2560) also has UART on pins 14/15, 16/17, and 18/19.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastEditorUserId="23666" LastEditDate="2016-07-08T15:35:30.083" LastActivityDate="2016-07-08T15:35:30.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3986" PostTypeId="1" AcceptedAnswerId="3994" CreationDate="2014-08-30T13:37:40.353" Score="0" ViewCount="6882" Body="&lt;p&gt;I need to slice a string (eg- 4:288:18464:288:4) at &quot;:&quot; into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when &quot;4:288:18464:288:4,&quot; is given to arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void displayString(char* s)&#xA;{&#xA;  char* text = strtok(s,&quot;:&quot;);&#xA;&#xA;  while(text != NULL){&#xA;  text = strtok(NULL,&quot;:&quot;);}&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(Serial.available() &amp;gt; 0)&#xA;    {&#xA;        str = Serial.readStringUntil(',');&#xA;        str.toCharArray(text,99);&#xA;    }&#xA;  displayString(text);&#xA;Serial.println(text);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3197" LastEditorUserId="368" LastEditDate="2014-08-30T16:50:12.603" LastActivityDate="2014-08-31T07:25:50.047" Title="Slice string at “:”" Tags="|serial|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3987" PostTypeId="1" CreationDate="2014-08-30T13:49:01.707" Score="2" ViewCount="1132" Body="&lt;p&gt;I have an Intel Galileo (1st gen) and a servo motor (Tower Pro SG90).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem: my servo moves only in one direction and it doesn't turn back.&#xA;I want to perform a movement from 0° to 90° and then from 90° to 0° again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I have just tried the official arduino snippet for servo motor that should perform a similar movement. But, as said before, the servo doesn't turn back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here the code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;  // create servo object to control a servo &#xA;                // a maximum of eight servo objects can be created &#xA;&#xA;int pos = 0;    // variable to store the servo position &#xA;&#xA;void setup() &#xA;{ &#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;} &#xA;&#xA;&#xA;void loop() &#xA;{ &#xA;  for(pos = 0; pos &amp;lt; 180; pos += 1)  // goes from 0 degrees to 180 degrees &#xA;  {                                  // in steps of 1 degree &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;  for(pos = 180; pos&amp;gt;=1; pos-=1)     // goes from 180 degrees to 0 degrees &#xA;  {                                &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously I have made the attachments like on &lt;a href=&quot;http://arduino.cc/en/Tutorial/sweep&quot; rel=&quot;nofollow&quot;&gt;arduino tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every help will be greatly appreciated! :)&#xA;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3779" LastActivityDate="2014-08-30T13:49:01.707" Title="Galileo - servo motor moves only in one direction and it doesn't turn back" Tags="|servo|arduino-galileo|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3988" PostTypeId="2" ParentId="3959" CreationDate="2014-08-30T17:32:08.207" Score="0" Body="&lt;p&gt;The answer from the user Gerben worked perfect. So I'll be posting another solution I came upon and the one from my original question for feature reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the library&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// init the lcd display according to the circuit&#xA;LiquidCrystal lcd(9, 8, 7, 6, 5, 4);&#xA;&#xA;// it's a 16x2 LCD so...&#xA;int screenWidth = 16;&#xA;int screenHeight = 2;&#xA;&#xA;String line1;&#xA;String line2;&#xA;&#xA;int stringStart, stringStop = 0;&#xA;int scrollCursor = screenWidth;&#xA;&#xA;String CompleteString;&#xA;String stringArray[] = {&quot;s=Plane&quot;, &quot;i=Car&quot;, &quot;h=Boat&quot;, &quot;u=Rocket&quot;, &quot;d=Jet&quot;, &quot;p=Submarine&quot;, &quot;l=Truck&quot;, &quot;b=Bicycle&quot;, &quot;m=Skate&quot;, &quot;enter=Train&quot;};&#xA;String string1 = &quot;String&quot;;&#xA;boolean ArrayRead = true;&#xA;int countMovement=0;&#xA;int arraylimit = 9;&#xA;&#xA;// most of the part is pretty basic&#xA;void setup() {&#xA;&#xA;   lcd.begin(screenWidth,screenHeight);&#xA;   Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;   char ser = Serial.read();&#xA;&#xA;   if ( ser == 'c' ) {  &#xA;      CompleteString=&quot;&quot;;&#xA;&#xA;      for (int i = 0 ; i &amp;lt;= arraylimit; i++) {&#xA;         CompleteString += stringArray[i] + &quot; &quot;; // Convert String Array To Single String&#xA;      }&#xA;&#xA;      roop(string1,CompleteString);&#xA;   }&#xA;&#xA;}&#xA;&#xA;void roop(String line1, String line2) {&#xA;&#xA;   countMovement = 0;&#xA;   stringStart = 0;&#xA;   stringStop = 0;&#xA;   scrollCursor = screenWidth;&#xA;&#xA;   while ( ( countMovement ) &amp;lt; (line2.length() + screenWidth )  ) {&#xA;&#xA;      lcd.clear();&#xA;      lcd.setCursor(scrollCursor, 1);&#xA;      lcd.print(line2.substring(stringStart,stringStop));&#xA;      lcd.setCursor(5, 0); // 1 = word eat array of words very cool&#xA;      lcd.print(line1);&#xA;      delay(300);&#xA;      lcd.clear();&#xA;      if(stringStart == 0 &amp;amp;&amp;amp; scrollCursor &amp;gt; 0){     &#xA;         scrollCursor--;&#xA;         stringStop++;&#xA;      } else if (stringStart == stringStop){&#xA;         stringStart = stringStop = 0;&#xA;         scrollCursor = screenWidth;&#xA;      } else if (stringStop == line1.length() &amp;amp;&amp;amp; scrollCursor == 0) {&#xA;         stringStart++;&#xA;      } else {&#xA;         stringStart++;&#xA;         stringStop++;&#xA;      }&#xA;&#xA;      countMovement++;&#xA;&#xA;   }&#xA;&#xA;   lcd.setCursor(4, 0);&#xA;   lcd.print(line1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other code provided by the user &quot;HazardsMind&quot; for I2C LCD Module: The changes made are Serial communication and adapted for the 6 pin LCD Module.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the library&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// init the lcd display according to the circuit&#xA;LiquidCrystal lcd(9, 8, 7, 6, 5, 4);&#xA;&#xA;//char * SerialComm[70];&#xA;//{&quot;s = Plane i=Car h=Boat u=Rocket d=Jet p=Submarine l=Truck b=Bicycle m=Skate enter=Train&quot;};&#xA;&#xA;#define N_CHARS  ((sizeof(MessageOut)/sizeof(MessageOut[0]))-1)&#xA;#define N_CHARS2  ((sizeof(MessageOut2)/sizeof(MessageOut2[0]))-1)&#xA;&#xA;//int len = strlen(SerialComm);&#xA;&#xA;char MessageOut[30];&#xA;char MessageOut2[30];&#xA;&#xA;&#xA;&#xA;int index = 19, index2 = 0;&#xA;unsigned long oldTime = 0, oldTime2 = 0;&#xA;&#xA;byte indexer = 0; // Index into array; where to store the character&#xA;char inData[58]; // Allocate some space for the string&#xA;char inChar; // Where to store the character read&#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   lcd.begin(16, 2);                      // initialize the lcd  &#xA;}&#xA;&#xA;void loop() &#xA;&#xA;&#xA;  while(Serial.available() &amp;gt; 0) // Don't read unless&#xA;                                              // there you know there is data&#xA;  {&#xA;      if(indexer &amp;lt; 57) // One less than the size of the array&#xA;      {&#xA;         inChar = Serial.read(); // Read a character&#xA;         inData[indexer] = inChar; // Store it&#xA;         indexer++; // Increment where to write next&#xA;         inData[indexer] = '\0'; // Null terminate the string&#xA;      }&#xA;  }&#xA;  // Now do something with the string (but not using ==)&#xA;&#xA;  // Serial.print(inData);&#xA;  setHeadingRight(&quot;Royal&quot;, 0, 500);&#xA;  setHeadingLeft(inData, 1, 500);&#xA;&#xA;  //setHeadingRight(&quot;Hello Welcome&quot;, 0, 1000); // message, row, duration&#xA;  // setHeadingLeft(&quot;Welcome&quot;, 1, 500);&#xA;}&#xA;&#xA;void setHeadingRight(char * msg, byte row, unsigned long duration) &#xA;{&#xA;   strncpy(MessageOut, msg, sizeof(MessageOut));&#xA;   if(millis() - oldTime &amp;gt; duration) // check the difference of the current time &quot;millis()&quot; to the previous time &quot;oldTime&quot; against the duration you want.&#xA;   {&#xA;      oldTime = millis(); // update oldTime with the current time&#xA;      if(index &amp;gt;= 0) // make sure the index does not go under 0&#xA;      { &#xA;        index--; // decrecment index by 1&#xA;        for (int i = 0; i &amp;lt; N_CHARS; i++) // this part here displays the message on the display&#xA;        {&#xA;           lcd.setCursor(i,row); // set the column to show the element in the array&#xA;           if(index == N_CHARS) index = 0; // set index back to 0 if the index has reached the arrays max size.&#xA;&#xA;              if(MessageOut[index++] != NULL) // if the element @ index is anything but NULL, show it.&#xA;                  lcd.print(MessageOut[index-1]);&#xA;              else &#xA;                  lcd.print(' '); // if the element @ index is NULL, display a space.   &#xA;        }&#xA;      }&#xA;   else index = 19; // if index is less than 0, then set it back to 19&#xA; }&#xA;}&#xA;&#xA;void setHeadingLeft(char * msg, byte row, unsigned long duration2) &#xA;{&#xA;  strncpy(MessageOut2, msg, sizeof(MessageOut2));&#xA;  if(millis() - oldTime2 &amp;gt; duration2)&#xA;  {&#xA;     oldTime2 = millis();&#xA;     if(index2 &amp;lt; 20) // check to see if index2 is under the array max size&#xA;     {&#xA;        index2++; // increment index&#xA;        for (int i = 0; i &amp;lt; N_CHARS2; i++) // same as above&#xA;        {&#xA;           lcd.setCursor(i,row);&#xA;           if(index2 == N_CHARS2) index2 = 0;&#xA;&#xA;              if(MessageOut2[index2++] != NULL)&#xA;                 lcd.print(MessageOut2[index2-1]);&#xA;              else &#xA;                 lcd.print(' ');    &#xA;              }&#xA;           }&#xA;           else index2 = 0; // otherwise set it back to 0&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3626" LastActivityDate="2014-08-30T17:32:08.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3990" PostTypeId="1" AcceptedAnswerId="3991" CreationDate="2014-08-30T22:49:10.667" Score="1" ViewCount="6390" Body="&lt;p&gt;I was thinking of using my Arduino to turn on and off a computer remotely. I would like to know if the 5v header pin on a computer's motherboard (which I’m using instead of a USB because the 5v pin provides a constant power supply) can power an Arduino UNO without frying it. If the Arduino can be powered where would the cable from the 5v motherboard pin go into the Arduino?&#xA;&lt;img src=&quot;https://i.stack.imgur.com/U2K3l.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;↑ These are the pins I would like to use &lt;/p&gt;&#xA;" OwnerUserId="3733" LastEditorUserId="3733" LastEditDate="2014-09-09T21:23:31.763" LastActivityDate="2014-09-09T22:09:16.353" Title="Can I power an Arduino with a computer's motherboard?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3991" PostTypeId="2" ParentId="3990" CreationDate="2014-08-31T04:34:27.020" Score="2" Body="&lt;p&gt;You want to tap off of the +5VSB pin of the &lt;a href=&quot;http://pinouts.ru/Power/atxpower_pinout.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATX&lt;/a&gt; or &lt;a href=&quot;http://pinouts.ru/Power/btx_mbpower_pinout.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;BTX&lt;/a&gt; power supply connector and send it to the 5V pin on the Arduino. Where this will directly drive the VCC(5V) of the UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mfHGK.png&quot; alt=&quot;enter image description here&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that 5V of the USB basically drives the VCC directly, except through a MOSFET that acts as a blocking diode to prevent local VCC from flowing back to the 5V_USB.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Not sure if you are suggesting that the 5V USB is frying Arduino's. If so that is bad. If true; Fix that first.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That said (with good 5V usb) you should be able to find or configure (BIOS) so that a USB connector will remain powered, and allow a wake up from mouse movement. Hence a possible solution would be to use a Leonardo/Micro's Mouse emulation to do just that as to wake the PC, without any hardware mod's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Freeduino Micro's are pretty cheap.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-08-31T04:34:27.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="3992" PostTypeId="1" AcceptedAnswerId="3995" CreationDate="2014-08-31T05:44:49.050" Score="9" ViewCount="21477" Body="&lt;p&gt;I have really bad eyesight, so whenever I plug in the power wire and the GND wire I always double check if I'm actually plugging in to the power port not one of the two GND ports. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does an Arduino UNO have two GND ports, and for what application would one use both of them?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="6936" LastEditDate="2015-07-30T19:48:07.043" LastActivityDate="2015-07-30T19:48:07.043" Title="Why does an Arduino UNO need two GND ports?" Tags="|arduino-uno|power|pins|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3993" PostTypeId="1" CreationDate="2014-08-31T06:39:07.187" Score="0" ViewCount="14021" Body="&lt;p&gt;I am getting an error on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CSTT=&quot;TATA.DOCOMO.INTERNET&quot;,&quot;&quot;,&quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ;&#xA;  }&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;  delay(3000);&#xA;  Serial.println(&quot;AT+CGATT=1&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CGDCONT=1,\&quot;IP\&quot;,\&quot;TATA.DOCOMO.INTERNET\&quot;&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CDNSCFG=\&quot;4.4.4.4\&quot;,\&quot;8.8.8.8\&quot;&quot;);&#xA;  delay(1000);&#xA;  Serial.println(&quot;AT+CSTT=\&quot;TATA.DOCOMO.INTERNET\&quot;,\&quot;\&quot;,\&quot;\&quot;&quot;);&#xA;  delay(2000);&#xA;  Serial.println(&quot;AT+CIICR&quot;);&#xA;  delay(5000);&#xA;  Serial.println(&quot;AT+CIFSR&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CIPSTATUS&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CDNSORIP=1&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;www.google.com\&quot;,\&quot;80\&quot;&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT+CIPSEND&quot;);&#xA;  delay(500);&#xA;  Serial.println(&quot;AT&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // run over and over&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CGATT=1&#xA;&#xA;OK&#xA;AT+CGDCONT=1,&quot;IP&quot;,&quot;TATA.DOCOMO.INTERNET&quot;&#xA;&#xA;OK&#xA;AT+CDNSCFG=&quot;4.4.4.4&quot;,&quot;8.8.8.8&quot;&#xA;&#xA;OK&#xA;AT+CSTT=&quot;TATA.DOCOMO.INTERNET&quot;,&quot;&quot;,&quot;&quot;&#xA;&#xA;ERROR&#xA;AT+CIICR&#xA;&#xA;ERROR&#xA;AT+CIFSR&#xA;&#xA;ERROR&#xA;AT+CIPSTATUS&#xA;&#xA;OK&#xA;&#xA;STATE: IP IND&#xA;AT+CDNSORIP=1&#xA;&#xA;OK&#xA;AT+CIPSTART=&quot;TCP&quot;,&quot;www.google.com&quot;,&quot;80&quot;&#xA;&#xA;ERROR&#xA;AT+CIPSEND&#xA;&#xA;ERROR&#xA;AT&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="37" LastEditDate="2014-11-29T19:52:10.693" LastActivityDate="2019-09-26T08:26:21.043" Title="AT+CSTT throws an error" Tags="|programming|gsm|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3994" PostTypeId="2" ParentId="3986" CreationDate="2014-08-31T07:25:50.047" Score="1" Body="&lt;p&gt;You don't use &lt;code&gt;strtok&lt;/code&gt; the way it should:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* text = strtok(s,&quot;:&quot;);&#xA;while(text != NULL){&#xA;    text = strtok(NULL,&quot;:&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code just replaces, in &lt;code&gt;s&lt;/code&gt;, all occurrences of &lt;code&gt;:&lt;/code&gt; with &lt;code&gt;0&lt;/code&gt; (i.e. a byte of value 0, not the ASCII value of &lt;code&gt;'0'&lt;/code&gt;), thus terminating each substring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of &lt;code&gt;displayString(text)&lt;/code&gt; call from &lt;code&gt;loop()&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt; still points to the 1st character of the original string (in your post &lt;code&gt;4:288:18464:288:4&lt;/code&gt;), but that string now terminates at the position of the first &lt;code&gt;:&lt;/code&gt;, which explains why &lt;code&gt;Serial.println(text)&lt;/code&gt; prints just &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you want to split the original string into an array of substrings, as asked in your question, you need to modify &lt;code&gt;displayString&lt;/code&gt; this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Maximum number of substrings expected&#xA;const int MAX_SUBSTRINGS = 5;&#xA;// Array of pointers to each substring after displayString() has been called&#xA;static char* substrings[MAX_SUBSTRINGS];&#xA;&#xA;void displayString(char* s) {&#xA;    // First clear the array of substrings&#xA;    for (int i = 0; i &amp;lt; MAX_SUBSTRINGS; i++)&#xA;        substrings[i] = 0;&#xA;    // Now split the input string&#xA;    char* text = strtok(s,&quot;:&quot;);&#xA;    int i = 0;&#xA;    while (text != 0 &amp;amp;&amp;amp; i &amp;lt; MAX_SUBSTRINGS) {&#xA;        // A toekn was found: append it to the array of substrings&#xA;        substrings[i++] = text;&#xA;        text = strtok(0,&quot;:&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After calling &lt;code&gt;displayString(text)&lt;/code&gt;, you can use its result in &lt;code&gt;loop()&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    if (Serial.available() &amp;gt; 0)&#xA;    {&#xA;        str = Serial.readStringUntil(',');&#xA;        str.toCharArray(text,99);&#xA;    }&#xA;    displayString(text);&#xA;    for (int i = 0; i &amp;lt; MAX_SUBSTRINGS; i++) {&#xA;        if (substrings[i] != 0)&#xA;            Serial.println(substrings[i]);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will work &lt;strong&gt;ONLY&lt;/strong&gt; if the original string contains no more than 5 substrings delimited by &lt;code&gt;:&lt;/code&gt;. If the max number of substrings cannot be known at compile time, then you'll have to use dynamic allocation, &lt;a href=&quot;https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino/687#687&quot;&gt;which is generally not a very good idea on embedded platforms&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-08-31T07:25:50.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3995" PostTypeId="2" ParentId="3992" CreationDate="2014-08-31T07:38:15.340" Score="12" Body="&lt;p&gt;In electronics circuits, a major point in connecting two circuits and make them &quot;talk&quot; together is to ensure, at the minimum, that they have a common reference of voltage (typically called &lt;code&gt;GND&lt;/code&gt; and defined as &lt;code&gt;0V&lt;/code&gt; voltage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino, GND pins can be used in 2 situations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;to directly power the Arduino with an external supply which cannot be plugged to USB or power jack. In this case, the positive voltage of that external power source shall also be supplied to &lt;strong&gt;Vin&lt;/strong&gt; pin.&lt;/li&gt;&#xA;&lt;li&gt;to connect Arduino GND to your circuits.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Having 2 distinct GND pins is, I think, just a matter of convenience when you want to build prototypes but don't necessarily have a breadboard (if you use a breadboard, you will just need to connect its power rail to Arduino GND pin and use this power rail directly).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-31T07:38:15.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3996" PostTypeId="1" AcceptedAnswerId="3998" CreationDate="2014-08-31T09:58:18.260" Score="9" ViewCount="16389" Body="&lt;p&gt;From the sample code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(4800);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the difference between, why use 2 types of calls to make AT command calls.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SoftwareSerial mySerial (10,11)&#xA;  mySerial.begin(10,11)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Serial.begin(9600)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit, this answers my question in my own words based on @jfpoilpret response.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It is important to &lt;strong&gt;initialize both Serial and SoftwareSerial&lt;/strong&gt;, since SoftwareSerial is used to send the actual commands to the GSM, and Serial is used to &lt;code&gt;view&lt;/code&gt; all the commands and their responses on the debug port of the GSM&lt;/li&gt;&#xA;&lt;li&gt;The pins on the GSM and Arduino are used to connect the the 2, and pass on &lt;strong&gt;actual commands&lt;/strong&gt;. While the RS232 is only used for debugging. We can however connect a RS232 to USB connector so as to connect the GSM to the desktop(or laptop)&lt;/li&gt;&#xA;&lt;li&gt;The code in the loop is essential to help &lt;strong&gt;convert&lt;/strong&gt; all actual commands to the debugging RS232 port, and the other way around, so as to enable us to use a tool like &lt;code&gt;cutecom&lt;/code&gt; (on ubuntu) to pass commands to the GSM serial input pins.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Important Note : When using cutecom ensure that you select &lt;strong&gt;CR line end&lt;/strong&gt; to send commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="3328" LastEditDate="2014-09-01T03:02:21.653" LastActivityDate="2017-02-22T14:11:44.277" Title="Difference between SoftwareSerial and Serial" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="3997" PostTypeId="1" AcceptedAnswerId="26387" CreationDate="2014-08-31T10:18:01.327" Score="6" ViewCount="8490" Body="&lt;p&gt;I am testing this basic &lt;a href=&quot;http://arduino.cc/en/tutorial/button&quot; rel=&quot;noreferrer&quot;&gt;button example &lt;/a&gt; from the Arduino tutorial page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit lets power flow to pin 2 when the button is pressed. When the button is not pressed, the power goes through the resistor to ground, but my question is: why would you even need the connection to ground?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't you have power flow from 5V to pin2 or just have NO connection at all when the button is not pressed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/d93mf.png&quot; alt=&quot;Button&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3732" LastActivityDate="2018-11-06T15:10:35.023" Title="Why does this button have a connection to ground?" Tags="|button|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3998" PostTypeId="2" ParentId="3996" CreationDate="2014-08-31T10:39:51.010" Score="10" Body="&lt;p&gt;All Atmel MCU, on which Arduino models are based, include special hardware for serial communication; this part of the MCU is called &lt;strong&gt;USART&lt;/strong&gt; (stands for &lt;em&gt;Universal Synchronous/Asynchronous Receiver/Transmitter&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the Arduino model you have, you may have only one (eg on UNO) or more USART (leonardo, mega...) on the board MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each MCU USART is mapped to specific pins of the board, you cannot change those pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino, if you use the monitor to send debug information to your PC, then one USART is used, this is when you used &lt;code&gt;Serial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need more than one serial communication link (e.g. because you have some devices that communicate through serial) but your Arduino model has only one USART, then you have to use the library &lt;code&gt;SoftwareSerial&lt;/code&gt; that &quot;simulates&quot; the job of an USART only by software. Hence it is much less optimized than the hardware USART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One advantage of &lt;code&gt;SoftwareSerial&lt;/code&gt; is that you can map it to any pair of pins you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going to your code sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously here, &lt;code&gt;Serial&lt;/code&gt; is used for debugging (sending info to the serial monitor of your PC), whereas &lt;code&gt;mySerial&lt;/code&gt; is used to communciate with the GSM device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this sketch is used to allow you to type AT commands on the monitor, which will then be forwarded to the GSM device; conversely, any strings returned from the GSM device will be echoed to the serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-08-31T10:39:51.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="3999" PostTypeId="2" ParentId="3997" CreationDate="2014-08-31T12:07:45.240" Score="13" Body="&lt;p&gt;That resistor is called a pull-down resistor. It's there to make sure pin 2 read low when the button isn't pressed. If you don't put it there pin 2 is left 'floating', and it could erroneously read a high value. Google it for more info. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to simplify you circuit you could instead use a pull-up resistor, and connect the button to ground instead of 5v. The ATMega chip on the arduino has these pull-up resistors build into the chip itself, so you don't need to add one to the breadboard. Just not that the input values will be reversed. So pin2 will read LOW when the button is pressed, and HIGH when not. To activate the internal pull-up use &lt;code&gt;pinMode(2, INPUT_PULLUP)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2018-06-05T15:42:33.403" LastActivityDate="2018-06-05T15:42:33.403" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4000" PostTypeId="2" ParentId="3993" CreationDate="2014-08-31T12:11:59.707" Score="0" Body="&lt;p&gt;Try &lt;code&gt;AT+CSTT=&quot;TATA.DOCOMO.INTERNET&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-08-31T12:11:59.707" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4001" PostTypeId="2" ParentId="3992" CreationDate="2014-08-31T13:27:06.623" Score="2" Body="&lt;p&gt;If you are not using a shield and are directly adding components to the arduino it is nice to have 2 ground so you can attach several components without having to add a bread board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be precise, you have 3 ground, since the third is sitting on the left hand side of the board (looking in to the USB port)&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-08-31T13:27:06.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4002" PostTypeId="1" CreationDate="2014-08-31T14:33:02.063" Score="1" ViewCount="1402" Body="&lt;p&gt;I am looking to wire up 16 pieces of flexinol (&lt;a href=&quot;http://www.musclewires.com/MWFlexinol.php&quot; rel=&quot;nofollow&quot;&gt;http://www.musclewires.com/MWFlexinol.php&lt;/a&gt;)  using an arduino board. Ideally I would like to be able to activate them independently, meaning that they could all be on, off or in any combination in between. My understanding that they would need to draw more current than the board could handle so some type of shield would be necessary?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3789" LastActivityDate="2014-09-30T15:42:25.770" Title="Controlling flexinol with an arduino board?" Tags="|power|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4003" PostTypeId="2" ParentId="4002" CreationDate="2014-08-31T14:50:29.230" Score="1" Body="&lt;p&gt;First thing's first, this just seems to be a wire that has special characteristics. If so, we just need to find out the resistance and use &lt;strong&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Ohm&amp;#39;s_law&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ohm's law&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the product page, I found this image:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PbZP7.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can tell from that that it has a resistance of 20 ohms and a recommended current of 1 amp. First, let's see how much current it would draw with a 5V supply. I prefer using a &lt;a href=&quot;http://www.dccwiki.com/images/f/fb/Ohm&amp;#39;s_law_triangle.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ohm's law triangle&lt;/a&gt;, just because I'm a very visual person. So with this math:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5 / 20 = 0.25&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's 250 mA, but an Arduino can only provide 40 mA! Furthermore, it is only 1/4 of the recommended current that the manufacturer specifies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the full current the OEM specifies you'll need a 20 V power supply capable of at least 1A. Even then, you might want to put in a &lt;em&gt;power resistor&lt;/em&gt; to limit the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Driving this with Arduino:&lt;/strong&gt; So, we have a few problems here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is 20W, which is quite a bit in the Arduino world&lt;/li&gt;&#xA;&lt;li&gt;We need to control the current/voltage dynamically&lt;/li&gt;&#xA;&lt;li&gt;You need 16 of them, so we don't want something too costly&lt;/li&gt;&#xA;&lt;li&gt;You probably can't find something to fit your needs that is &lt;em&gt;one&lt;/em&gt; shield.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What comes to mind is a transistor. I'm not skilled with picking them out, but there are a lot of guides online. You'd then want to add a capacitor and a resistor to make some sort of filter and connect it to a PWM pin to send a varied voltage to the transistor, which will vary the amount of power going through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use a &lt;em&gt;relay&lt;/em&gt;. However, that only does ON or OFF. A &lt;em&gt;solid state relay (SSR)&lt;/em&gt; would allow you to use PWM on the relay and then you could add a capacitor/resistor combo on the other end of it, but you'd need a pretty large capacitor or a pretty large frequency for the PWM (which you can modify).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-08-31T14:50:29.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4004" PostTypeId="2" ParentId="3949" CreationDate="2014-08-31T16:28:01.813" Score="1" Body="&lt;p&gt;The easiest way to distinguish your bare AVR from the arduino board at run time is to build the bare AVR board with a distinguishing feature - such as a known&#xA;voltage on one of the D/A ports - that won't be present on your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-09-01T04:20:06.833" LastActivityDate="2014-09-01T04:20:06.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4005" PostTypeId="1" CreationDate="2014-08-31T18:54:42.167" Score="5" ViewCount="1126" Body="&lt;p&gt;I have a TinyRTC I2C clock in one of my Arduino projects, and it works most of the time. But occasionally, it will report the time as 165 hours, 85 minutes and 25 seconds (165:85:25) for a couple of seconds, then go back to the correct time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this has got something to do with a fairly complicated I2C bus that I'm running: it has 12 devices connected to it (the clock, an LCD and 10 BlinkM LED programmable lights).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I've tried to debug, to no avail:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Replaced the RTC and battery &lt;/li&gt;&#xA;&lt;li&gt;Replaced I2C pullup resistors&lt;/li&gt;&#xA;&lt;li&gt;Redid the I2C wiring   &lt;/li&gt;&#xA;&lt;li&gt;Checked current draw of my project (.2A) and made sure the power&#xA;supply can handle that (it can)&lt;/li&gt;&#xA;&lt;li&gt;Used 3 different power supplies in case I was getting noise&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think this is something to do with the I2C bus... the clock works fine when nothing much else is happening on the bus, but as soon as there's lots of activity (LEDs being sent messages, or perhaps other things) it starts reporting the time as 165:85:25).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how I could (a) isolate the cause of this problem; (b) get right to implementing a solution?&lt;/p&gt;&#xA;" OwnerUserId="3568" LastActivityDate="2015-02-04T00:32:04.747" Title="I2C RTC returning bad times - sometimes" Tags="|i2c|time|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4007" PostTypeId="2" ParentId="1358" CreationDate="2014-09-01T00:37:04.300" Score="1" Body="&lt;p&gt;I had a similar problem trying to use the commands such as :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;echo 1 &gt; /dev/ttyACM0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and found that I needed privileges to perform serial communication in this way like:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sudo echo 1 &gt; /dev/ttyACM0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could also try setting the baud rate you are communicating at :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sudo echo 1 &gt; /dev/ttyACM0 9600&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;GOOD LUCK!&lt;/p&gt;&#xA;" OwnerUserId="3793" LastActivityDate="2014-09-01T00:37:04.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4009" PostTypeId="1" CreationDate="2014-09-01T03:14:57.620" Score="0" ViewCount="2585" Body="&lt;p&gt;I need to measure voltage between 0-10 volts using my Arduino Due.  I have an ADS7805p chip, which I believe will work, but am not sure how to wire it on my breadboard.  I'm used to just using the chip on the arduino, but that only goes 0-5 volts and I can't loose the resolution by converting.  Can someone, please, point me to or instruct me on how to wire something like this to my arduino?&lt;/p&gt;&#xA;" OwnerUserId="3794" LastActivityDate="2014-10-01T21:02:47.540" Title="Using a 16 bit ADC chip with arduino" Tags="|arduino-due|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4010" PostTypeId="1" AcceptedAnswerId="4018" CreationDate="2014-09-01T08:25:19.730" Score="1" ViewCount="5049" Body="&lt;p&gt;This &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; states that the CE and CSN pins can be specified.  Can I specify A0 and A1 as these pins?&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-09-01T18:38:29.437" Title="Can the nRF24L01+ CE and CSN pins be attached to Arduino pins A0 and A1?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4011" PostTypeId="1" AcceptedAnswerId="4012" CreationDate="2014-09-01T08:27:05.310" Score="2" ViewCount="8706" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/pinMode&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/pinMode&lt;/a&gt; notes that&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The analog input pins can be used as digital pins, referred to as A0, A1, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is it possible to configure these pins as digital output pins as well?&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-09-01T08:34:24.417" Title="Can I specify that analog pins be used for digital output?" Tags="|digital|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4012" PostTypeId="2" ParentId="4011" CreationDate="2014-09-01T08:34:24.417" Score="2" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/AnalogInputPins&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/AnalogInputPins&lt;/a&gt; states&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The analog pins can be used identically to the digital pins, using the aliases A0 (for analog input 0), A1, etc. For example, the code would look like this to set analog pin 0 to an output, and to set it HIGH:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(A0, OUTPUT);&#xA;digitalWrite(A0, HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are several caveats on that page regarding this.&lt;/p&gt;&#xA;" OwnerUserId="3540" LastActivityDate="2014-09-01T08:34:24.417" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4014" PostTypeId="2" ParentId="4009" CreationDate="2014-09-01T11:36:18.857" Score="0" Body="&lt;p&gt;If you really need 16 bits of resolution then you could use that chip, but it's going to be a lot of work. Also beware that according to Mouser's website, it is not recommended for new applications. It sounds like it's being phased out/replaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at the data sheet linked from Mouser's website:&#xA;&lt;a href=&quot;http://www.mouser.com/ds/2/405/sbas020d-114025.pdf&quot; rel=&quot;nofollow&quot;&gt;ADS7805p datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has 16 bits of parallel data output, plus what sounds like 2 control lines, CS and R/(not)C (Don't know how to make the proper symbol.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you pull CS and R/C low to trigger a conversion, then wait for not busy to go low, switch R/C to high, then read the 16 bits of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use this chip you're going to need 18 or 19 pins from your Arduino. You might want to consider a chip with a serial interface instead.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-09-01T18:57:37.227" LastActivityDate="2014-09-01T18:57:37.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4015" PostTypeId="1" CreationDate="2014-09-01T12:18:00.580" Score="3" ViewCount="1935" Body="&lt;p&gt;I recently started programming with Arduino and and currently I'm making a project to read RPM and Speed of my car using Arduino Uno. So far I got everything working but the speed value does not show properly. I have used one hardware counter and two interrupts in this project.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Timer 1 on pin 5 - Count pulses from car's ECU to calculate speed.&lt;/li&gt;&#xA;&lt;li&gt;Int0 on pin 2 - Read ignition pulse to calculate RPM.&lt;/li&gt;&#xA;&lt;li&gt;int1 on pin 3 - 5v in from headlight switch to control the brightness of the display (MAX729 7 seg 8 digit).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I can get the proper reading from RPM and also the brightness control is working properly. Here is my codes below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;LedControl.h&amp;gt;&#xA;&#xA;// inputs: DIN pin, CLK pin, LOAD pin. number of chips&#xA;LedControl display = LedControl(12, 10, 11, 1);&#xA;&#xA;//SPEEDO-----------------------------------------------------------&#xA;const int hardwareCounterPin = 5;&#xA;const int samplePeriod = 1000; //in milliseconds&#xA;const float pulsesPerMile = 4000; // this is pulses per mile for Toyota. Other cars are different.&#xA;const float convertMph = pulsesPerMile/3600;&#xA;unsigned int count;&#xA;float mph;&#xA;int kph;&#xA;int roundedKph;&#xA;int previousKph;&#xA;int prevCount;&#xA;//----------------------------------------------------------------&#xA;&#xA;//RPM-------------------------------------------------------------&#xA;//Configuration for the Tachometer variables&#xA;const int sensorPin = 2;&#xA;const int sensorInterrupt = 0;&#xA;const int timeoutValue = 5;&#xA;volatile unsigned long lastPulseTime;&#xA;volatile unsigned long interval = 0;&#xA;volatile int timeoutCounter;&#xA;int rpm;&#xA;int rpmlast = 3000;&#xA;int rpm_interval = 3000;&#xA;//---------------------------------------------------------------&#xA;&#xA;//Brightness control---------------------------------------------&#xA;int brightnessIndicator = 13;  //Light pin 13 led to show that brightness control is in action.&#xA;int brightnessIn = 3;  //Sensor in from headlight positive wire to control the brightness.&#xA;//---------------------------------------------------------------&#xA;&#xA;void setup(void) {&#xA;  //Serial.begin(9600);&#xA;&#xA;  display.shutdown(0, false);  // turns on display&#xA;  display.setIntensity(0, 10); // 15 = brightest&#xA;  printTrueno(); //Print my car's name&#xA;  delay(3000);&#xA;  initToZero(); //Print all zeros before going to the loop&#xA;&#xA;  TCCR1A = 0; //Configure hardware counter &#xA;  TCNT1 = 0;  // Reset hardware counter to zero&#xA;&#xA;  //Config for the Tach&#xA;  pinMode(sensorPin, INPUT);&#xA;  attachInterrupt(sensorInterrupt, &amp;amp;sensorIsr, RISING);&#xA;  lastPulseTime = 0;&#xA;  timeoutCounter = 0;&#xA;&#xA;  //Config for brightness control&#xA;  pinMode(brightnessIndicator, OUTPUT);  //LED output&#xA;  pinMode(brightnessIn,INPUT);  //Sensor in&#xA;  attachInterrupt(1, changeBrightness, CHANGE);  //Attach the 2nd interrupt&#xA;  changeBrightness();  //Check for head lights on or not.&#xA;}&#xA;&#xA;void loop() {&#xA;  //SPEEDO-----------------------------------------------------------&#xA;  // This uses the hardware pulse counter on the Arduino.&#xA;  // Currently it collects samples for one second.&#xA;  bitSet(TCCR1B, CS12); // start counting pulses&#xA;  bitSet(TCCR1B, CS11); // Clock on rising edge&#xA;  delay(samplePeriod); // Allow pulse counter to collect for samplePeriod&#xA;  TCCR1B = 0; // stop counting&#xA;  count = TCNT1; // Store the hardware counter in a variable&#xA;  TCNT1 = 0;     // Reset hardware counter to zero&#xA;  mph = (count/convertMph)*10; // Convert pulse count into mph. 10x allows retaining 10th of mph resolution.&#xA;  kph = ((unsigned int) mph)*1.6; // Convert to kph and cast to integer. &#xA;&#xA;  int x = kph / 10;&#xA;  int y = kph % 10;&#xA;&#xA;  // Round to whole mile per hour&#xA;  if(y &amp;gt;= 5){&#xA;    roundedKph = x + 1;&#xA;  }&#xA;  else {&#xA;    roundedKph = x;&#xA;  }&#xA;&#xA;  //If kph is less than 1 kph just show 0kph.&#xA;  //Readings of 0.9kph or lower are some what erratic and can&#xA;  //occasionally be triggered by electrical noise.&#xA;  //if(x == 0){&#xA;  if(x &amp;lt; 2){  // 1 was triggered by some noise signal.&#xA;    roundedKph = 0;&#xA;  }&#xA;&#xA;  // Don't display kph readings that are more than 50 kph higher than the previous reading because it is probably a spurious reading.&#xA;  if(roundedKph &amp;lt; 181){&#xA;    if((roundedKph - previousKph) &amp;gt; 50) {&#xA;      Serial.println(previousKph);&#xA;      printNumber(previousKph, 0);&#xA;    }&#xA;    else {&#xA;      Serial.println(roundedKph);&#xA;      printNumber(roundedKph, 0);&#xA;    }&#xA;  }&#xA;&#xA;  previousKph = roundedKph; // Set previousMph for use in next loop.&#xA;  //-----------------------------------------------------------------&#xA;&#xA;  //RPM--------------------------------------------------------------&#xA;  if(rpm &amp;gt;= 0) {  //Remove the minus values   &#xA;&#xA;    //Let's keep this RPMr value under control, between 0 and 9999&#xA;    rpm = constrain (rpm, 0, 9999);&#xA;&#xA;    //If the engine is not running, print 0&#xA;    if ((micros() - lastPulseTime) &amp;lt; 5e6 ) {&#xA;      rpm = rpm;&#xA;    }&#xA;    else {&#xA;      rpm = 0;&#xA;    }&#xA;&#xA;    if (rpm &amp;lt; 250)&#xA;      rpm = 0;&#xA;    //Serial.println(rpm);&#xA;    printNumber(rpm, 1);&#xA;  }&#xA;  //-----------------------------------------------------------------&#xA;}&#xA;&#xA;//Each time the interrupt receives a rising tach signal, it'll run this subroutine&#xA;void sensorIsr() {&#xA;  unsigned long now = micros();&#xA;  interval = now - lastPulseTime;&#xA;  if (interval &amp;gt; 5000){&#xA;     rpm = 61000000UL/(interval * 2);&#xA;     lastPulseTime = now;&#xA;  }&#xA;}&#xA;&#xA;void changeBrightness() {&#xA;  int val = digitalRead(brightnessIn);  //Read the sensor value&#xA;&#xA;  if(val == 1){  //If the headlights are on, pin goes HIGH.&#xA;    digitalWrite(brightnessIndicator, HIGH);   //turn the LED on&#xA;    display.setIntensity(0, 6); //Reduce the brightness.&#xA;  }&#xA;  else {&#xA;    digitalWrite(brightnessIndicator, LOW);    //turn the LED off&#xA;    display.setIntensity(0, 14);  //increase the brightness.&#xA;  }&#xA;}&#xA;&#xA;void printNumber(int v, int flag) {&#xA;    int ones;&#xA;    int tens;&#xA;    int hundreds;&#xA;    int thousands;&#xA;&#xA;    if (flag==0){&#xA;      ones = v%10;&#xA;      v = v/10;&#xA;      tens = v%10;&#xA;      v= v/10;&#xA;      hundreds = v;&#xA;&#xA;      //Now print the number digit by digit&#xA;      if (hundreds&amp;gt;0)&#xA;        display.setDigit(0,0,(byte)hundreds,false);&#xA;      else&#xA;        display.setChar(0,0,' ',false);&#xA;&#xA;      display.setDigit(0,1,(byte)tens,false);       &#xA;      display.setDigit(0,2,(byte)ones,false);&#xA;    }&#xA;    else if (flag=1) {&#xA;      ones = v%10;&#xA;      v = v/10;&#xA;      tens = v%10;&#xA;      v = v/10;&#xA;      hundreds = v%10;&#xA;      v = v/10;&#xA;      thousands = v%10;&#xA;&#xA;      //Now print the number digit by digit&#xA;      display.setDigit(0,4,(byte)thousands,false);&#xA;      display.setDigit(0,5,(byte)hundreds,false);&#xA;      display.setDigit(0,6,(byte)tens,false);&#xA;      display.setDigit(0,7,(byte)ones,false);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the problem is between Timer1 and first interrupt. Can someone please help me to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="3806" OwnerDisplayName=" Vajira Lasantha" LastEditorUserId="3806" LastEditDate="2014-09-01T22:31:42.433" LastActivityDate="2016-02-22T18:19:55.773" Title="Arduino Hardware timer and interrupts issue" Tags="|arduino-uno|interrupt|timers|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4018" PostTypeId="2" ParentId="4010" CreationDate="2014-09-01T18:38:29.437" Score="2" Body="&lt;p&gt;Yes, you can. The &lt;a href=&quot;https://github.com/aaronds/arduino-nrf24l01/blob/master/Mirf/Mirf.cpp#L85-86&quot; rel=&quot;nofollow&quot;&gt;mirf library&lt;/a&gt; is using the regular arduino functions &lt;code&gt;pinMode&lt;/code&gt; and &lt;code&gt;digitalWrite&lt;/code&gt; to manipulate the pins. So A0 and A1 should work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that when you use SPI (which the NRF does), you have to use pin 10 (SS) as an OUTPUT (as to not put the AVR into SPI slave mode).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-01T18:38:29.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4019" PostTypeId="1" CreationDate="2014-09-01T19:03:06.623" Score="1" ViewCount="21098" Body="&lt;p&gt;I am using an Arduino Leonardo together with a GY-521 breakout board (like &lt;a href=&quot;http://www.amazon.de/Arduino-GY-521-MPU-6050-gyroscope-accelerometer/dp/B00AZH43JC&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;, &lt;a href=&quot;http://playground.arduino.cc/uploads/Main/MPU6050-V1-SCH.jpg&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt;) for an &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;MPU 6050&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently trying to get the DMP Version of &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&quot; rel=&quot;nofollow&quot;&gt;the examples from Mr Rowberg&lt;/a&gt; to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For all my tests, I use these connections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GY-521 -&gt;  Leonardo &lt;/li&gt;&#xA;&lt;li&gt;VCC -&gt; 5V (3.3V has the same behaviour)&lt;/li&gt;&#xA;&lt;li&gt;SDA -&gt; SDA &lt;/li&gt;&#xA;&lt;li&gt;SCL -&gt; SCL &lt;/li&gt;&#xA;&lt;li&gt;GND -&gt; GND&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &quot;raw&quot; sketch works fine, I can read out the sensor data. For the DMP version I think I need to connect the INT pin to pin 3 on the leonardo, to allow the MPU6050 to trigger an interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as soon as I connect INT to anything (pins 0 through 3), the sketches do not find the MPU6050 any more. (They report &quot;&quot;MPU6050 connection failed&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my wiring off, or is my chip defective, and even more important, how could I figure that out on my own in the future? =)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; &#xA;The example source code says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* =========================================================================&#xA;   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch&#xA;   depends on the MPU-6050's INT pin being connected to the Arduino's&#xA;   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is&#xA;   digital I/O pin 2.&#xA; * ========================================================================= */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The example does nothing (that I can see) to configure this pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit again:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've borrowed an oscilloscope. SDA and SCL sit on 3.3V during normal communication, and I can see packets being exchanged. As soon as I connect the INT pin to any input pin on my Leonardo, both SDA and SCL go to ground. This means nothing to me, but maybe to someone else.&lt;/p&gt;&#xA;" OwnerUserId="3592" LastEditorUserId="3592" LastEditDate="2014-09-03T19:00:53.627" LastActivityDate="2019-04-21T19:45:50.827" Title="How to connect the INT pin of a MPU 6050?" Tags="|arduino-leonardo|mpu6050|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4021" PostTypeId="2" ParentId="4009" CreationDate="2014-09-01T20:44:42.270" Score="1" Body="&lt;p&gt;The ADS7805 is old but still a pretty good ADC. I could imagine that you just have a few lying around that you want to use. I would simply wire it to two parallel in / serial out chips like the 74HC589 or CD4021 as used in this example:&lt;br&gt;&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ShiftIn&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/ShiftIn&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start the conversion as described in Duncan C's answer and then simply clock in all 16 bits. I think you could then probably get away with 4 or 5 control lines.&lt;/p&gt;&#xA;" OwnerUserId="3804" LastActivityDate="2014-09-01T20:44:42.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4022" PostTypeId="1" AcceptedAnswerId="4024" CreationDate="2014-09-01T21:41:59.810" Score="8" ViewCount="2168" Body="&lt;p&gt;I'm currently playing with Arduino's hardware timers, and a question came to my mind. Let me explain it a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's suppose I want a certain function to execute every 1024 clock ticks. AFAIK, I could achieve this in several ways, playing with the prescaler value for Timer2, and its CTC:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Setting the prescaler to 1 and the CTC to 1024&lt;/li&gt;&#xA;&lt;li&gt;Setting the prescaler to 8 and the CTC to 128&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;li&gt;Setting the prescaler to 1024 and the CTC to 1.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All these ways would achieve what I want, but, which one is more efficient? Or it doesn't matter at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for sharing your knowledge :P&lt;/p&gt;&#xA;" OwnerUserId="3619" LastActivityDate="2016-01-14T21:47:03.403" Title="When setting hardware timers as interrupts, should I prefer a lower prescaler value or a lower CTC?" Tags="|interrupt|timers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4023" PostTypeId="2" ParentId="4019" CreationDate="2014-09-02T01:46:27.470" Score="0" Body="&lt;p&gt;Is it possible that the INT pin on the MPU 6050 in an input, not an output? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The symptoms you describe make it sound like you're locking the gyro chip into an interrupt state so it's not responding any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wasn't able to figure out the use of the INT pin from a quick scan of the data sheet however. It would take more careful study.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have your Arduino pin set up as an input or an output? And if it's an input, does it have a pull-up or pull-down resistor, either internal or external, set up? &lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-02T01:46:27.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4024" PostTypeId="2" ParentId="4022" CreationDate="2014-09-02T04:11:50.067" Score="2" Body="&lt;p&gt;If 'clock tick' count (here 1024), timer width and  MCU clock used are constant (a fixed value), I would not go for last option i.e. prescalar 1024 and CTC of 1. Here are my reasons (specially for Arduino ) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) When CTC is close to zero ( like 1-&gt; 10), sometimes timer behaves as if count is zero and outputs a square wave (with 50% duty ratio) with half the demanded frequency. So make CTC reasonably big. But again selecting a high clock frequency (pre scalar 1) may also show reduced accuracy. A intermediate option I think is better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) When count CTC changes dynamically in a process, timer pre scalar should be selected such that CTC count will always be less than or equal to timer width over whole process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. the maximum 'timer tick count' should be comfortably accommodated by the timer with it's given width. Even here same dilemma again occurs, then selection based on point 1 is better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not enough, then only way I think is to implement each case  physically and check which combination gives you the best results. Practical results I think are more reliable ( may be you will get a board specific efficient combination!)&lt;/p&gt;&#xA;" OwnerUserId="3731" LastEditorUserId="3731" LastEditDate="2014-09-02T04:17:37.643" LastActivityDate="2014-09-02T04:17:37.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4025" PostTypeId="1" AcceptedAnswerId="4026" CreationDate="2014-09-02T05:20:04.543" Score="6" ViewCount="8257" Body="&lt;p&gt;I have been controlling my servomotors for a while now only using pin 0. After some research, it has became apparent to me that the ports with &lt;code&gt;~&lt;/code&gt; are the PWM pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that all pins sent out PWM signals, therefore the motor was able to move back and forth. Now I'm really confused as to how the motor was able to turn without using a &lt;code&gt;~&lt;/code&gt; pin like pin 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain why I should or should not use PWM signal when controlling a motor?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="37" LastEditDate="2014-09-06T21:17:07.760" LastActivityDate="2014-09-06T21:17:21.493" Title="Difference between PWM and regular output port for servos?" Tags="|pins|pwm|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4026" PostTypeId="2" ParentId="4025" CreationDate="2014-09-02T05:55:45.573" Score="3" Body="&lt;p&gt;Servos does not use PWM, it uses PPM:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PWM = Pulse width modulation, The pulse start at 0ms, and is high for the percentage of the time compared to the percentage of the voltage you want, 5v signal, if you want 1v, the pulse is 20ms High and 80ms Low.&lt;/li&gt;&#xA;&lt;li&gt;PPM = Pulse position modulation, The pulse length is always 5ms High and 95ms low, but the interesting part is if high starts after 5ms or 50ms (or any other).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So PWM is to lower voltage, PPM is a signal pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that no matter what port you are using on the arduino you are able to control a servo since you only need High or Low, and not a lower voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to be aware of in this case is on the arduino is a PPM signal is using up a timer. The arduino has 3 timers where of 2 is available, one is used internally. Though there is code where you can attach up to 3 servos on the same internal timer.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="37" LastEditDate="2014-09-06T21:17:21.493" LastActivityDate="2014-09-06T21:17:21.493" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4027" PostTypeId="1" CreationDate="2014-09-02T13:52:23.330" Score="3" ViewCount="8924" Body="&lt;p&gt;I need to measure around &lt;strong&gt;50 - 100 analog sensors&lt;/strong&gt; (resistors). This poses two challenges:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino has fewer analog pins. I'm targeting something small like arduino Mini or Nano, which can have up to 8 analog pins. The solution for this could be several multiplexors &lt;a href=&quot;http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-analog-multiplexerdemultiplexer/&quot; rel=&quot;nofollow&quot;&gt;like this one&lt;/a&gt;. &lt;strong&gt;Is there a better option?&lt;/strong&gt; Is this the best way to read so many analog sensors with Arduino? I am thinking also in several arduino mini talking through wifi / bluetooth with the main one which would also aid with Problem #2.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There would be &lt;strong&gt;a lot of cables&lt;/strong&gt; for this setup, and I need to keep it all as flat and flexible as possible. So I was thinking of some kind of adesive copper conductor, paper printed circuit or plastic. The thing is that it would become difficult to create if I do it myself. What would be the easiest way to achieve a multi-track, flexible circuit for substituing Arduino cables?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="731" LastEditorUserId="731" LastEditDate="2014-12-03T12:55:00.523" LastActivityDate="2015-02-03T06:48:03.473" Title="Reading many analog signals in arduino" Tags="|pins|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4028" PostTypeId="1" CreationDate="2014-09-02T18:53:56.497" Score="11" ViewCount="1595" Body="&lt;p&gt;I'm looking to make a 15 x 15 grid of load sensors and RGB LEDs for an interactive dance floor. Each node will be driven by an arduino and the entire floor will be managed by a RaspberryPi. I'm trying to figure out the best way to have the nodes communicate with the Pi. Ideally the network would have these characteristics: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Low cost per node&lt;/li&gt;&#xA;&lt;li&gt;Raspberry Pi as the master, arduino nodes as slaves&lt;/li&gt;&#xA;&lt;li&gt;Ability to know where each node is in the grid&lt;/li&gt;&#xA;&lt;li&gt;Healing: If a node goes down it doesn't take out all the others.&lt;/li&gt;&#xA;&lt;li&gt;Can easily replace broken nodes&lt;/li&gt;&#xA;&lt;li&gt;The electronics for each node will be ~12 inches apart&lt;/li&gt;&#xA;&lt;li&gt;The master will be 5 - 10 feet away from the matrix.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So far I have been toiling over a few ides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I2C&lt;/strong&gt;&#xA;This would allow each node to be addressable, however, it seems that Arduino will only allow up to 127 addresses and this matrix will have at least 225 nodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SPI&lt;/strong&gt;&#xA;If daisy chained it would be easy to know where each node is in the matrix. But if one node were to break all the nodes after it would stop communicating. (right?) I could have each row daisy chained separately, so if one goes down it only affects that row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1-Wire&lt;/strong&gt;&#xA;&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_OneWire.html&quot;&gt;1-wire&lt;/a&gt; also looks promising. I'd have to figure out my own way of determining node placement, which could be achieved a variety of ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Custom Serial&lt;/strong&gt;&#xA;Each node has a serial connection (rx/tx) for each of it's four sides. This would allow it to communicate to each of it's neighbors directly and pass along messages that are not addressed to it. If one node were to go down, the message would be automatically routed around the broken node since there are several paths to each destination. This option is a little crazy and I'd prefer to avoid something so custom and convoluted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;USB&lt;/strong&gt;&#xA;This would require a USB hub in each node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;XBee&lt;/strong&gt;&#xA;Too expensive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other thoughts or options?&lt;/p&gt;&#xA;" OwnerUserId="3819" LastEditorUserId="3819" LastEditDate="2014-09-02T21:43:36.027" LastActivityDate="2014-10-09T11:20:20.047" Title="Cheap Wired Multipoint Mesh Network" Tags="|serial|i2c|spi|networking|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4029" PostTypeId="1" AcceptedAnswerId="4030" CreationDate="2014-09-02T20:12:58.013" Score="0" ViewCount="946" Body="&lt;p&gt;I'm working on a small project that is creating me a headache. I know arduimo (ATmega 328P .... etc. ..) has an internal voltage source code millivolts, but I would like to know how the full source code become percentage where 3 volts = 0%  and 4.2 volts = % 100% ??? . I appreciate the help because in codes is not my forte. I leave the code so Help me complete. Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long readVcc() {&#xA;  long result;&#xA;  // Read 1.1V reference against AVcc&#xA;  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);&#xA;  delay(2); // Wait for Vref to settle&#xA;  ADCSRA |= _BV(ADSC); // Convert&#xA;  while (bit_is_set(ADCSRA,ADSC));&#xA;  result = ADCL;&#xA;  result |= ADCH&amp;lt;&amp;lt;8;&#xA;  result = 1126400L / result; // Back-calculate AVcc in mV&#xA;  return result;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println( readVcc(), DEC );&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3822" OwnerDisplayName="piopio" LastEditorUserId="6452" LastEditDate="2015-04-15T23:02:50.627" LastActivityDate="2015-04-15T23:02:50.627" Title="Internal volts in arduino for percent battery" Tags="|voltage-level|battery|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4030" PostTypeId="2" ParentId="4029" CreationDate="2014-09-02T20:46:24.677" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/reference/map&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char level = map(readVcc(), 3000, 4200, 0, 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-09-02T20:46:24.677" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4031" PostTypeId="1" AcceptedAnswerId="4034" CreationDate="2014-09-02T22:58:54.123" Score="-3" ViewCount="11216" Body="&lt;p&gt;I am experiencing some very strange behavior with my arduino. I have a switch-case statement in the loop() method, and the break methods are not only breaking out of the case block, but also out of the loop() statement. Is this normal, and if so, how can I edit the structure so it doesn't do that?&#xA;My code structure looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  switch(int i){&#xA;    case 1:{&#xA;      //do something&#xA;      break;// this also breaks out of the loop() method.&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3826" LastEditorUserId="3826" LastEditDate="2014-09-02T23:07:28.943" LastActivityDate="2014-09-03T00:07:27.257" Title="Break statement terminating loop()" Tags="|arduino-uno|programming|sketch|" AnswerCount="2" CommentCount="1" ClosedDate="2014-09-10T15:04:28.293" ContentLicense="CC BY-SA 3.0" />
  <row Id="4032" PostTypeId="2" ParentId="4031" CreationDate="2014-09-02T23:16:43.560" Score="1" Body="&lt;p&gt;Your sample is too simple to test your hypothesis (which is wrong, by the way.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set up serial output so you can test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  Serial.println(&quot;Before switch statement&quot;);&#xA;  int i = 1;&#xA;  switch (i)&#xA;  {&#xA;    case 1:&#xA;      Serial.println(&quot;In case 1&quot;);&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;In default case&quot;);&#xA;  }&#xA;  Serial.println(&quot;After switch statement.&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even add an outer for loop to make things a little more complicated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  Serial.println(&quot;Before for loop statement&quot;);&#xA;  for (int i = 1; i&amp;lt; 10; i++)&#xA;  {&#xA;    Serial.print(&quot;In for loop before switch, i = &quot;);&#xA;    Serial.println(i);&#xA;    switch (i)&#xA;    {&#xA;      case 1:&#xA;        Serial.println(&quot;In case 1&quot;);&#xA;        break;&#xA;      default:&#xA;        Serial.println(&quot;In default case&quot;);&#xA;    }&#xA;    Serial.println(&quot;After switch statement.&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Examine the output on the serial monitor of your computer. You should find that the &quot;After switch statement&quot; line always appears after the &quot;before switch...&quot; line in both versions of the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Break breaks from the innermost scope. If you have nested levels of scope, like a function and then a switch statement inside the function, the break statement breaks out of that inner level. In the second example, the break broke out of the switch but the for loop kept running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is very basic C programming and not specific to Arduino.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-02T23:16:43.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4033" PostTypeId="2" ParentId="4027" CreationDate="2014-09-02T23:43:07.123" Score="0" Body="&lt;p&gt;As I read your question I was thinking of the 4067 chip as part of the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd rig one 4067 as the anode and another as the cathode on a grid of 64 resistors. You'd then send select an anode channel and a cathode channel, feed +5 volts into the common for the anode channel, and then feed the common from the anode channel into an ADC input on your Arduino. You'd need to allow for the fact that those chips have an internal resistance of around 180 ohms, (at least the TI chip I looked up did. My CMOS cookbook lists 200 ohms resistance.) As long as you're measuring resistances that are substantially bigger than 400 ohms, that should work (or you could precisely measure the resistance of your 4067 chips at your operating temperature and then adjust your math to compensate.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind you you'd have to sample these resistances one at a time, in round-robin fashion. It would be kinda slow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to test more than 64 resistances, you could use 2 4067s on either the anode side or the cathode side and use the inhibit pin to select the chip. That would give you the ability to sample 128 resistances. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find some 8 and 16-channel serial ADCs. You could use those and some select logic to do the same thing. Take a look at the AD7490. That's a 16 channel serial ADC. That and one of the 4067 16-channel MUX chips would give you 64 ADC inputs in banks of 16.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-02T23:43:07.123" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4034" PostTypeId="2" ParentId="4031" CreationDate="2014-09-03T00:07:27.257" Score="1" Body="&lt;p&gt;I just realized it wasn't the sketch, but a faulty SD card reader on my computer corrupted my SD card. BIG TIME.&lt;/p&gt;&#xA;" OwnerUserId="3826" LastActivityDate="2014-09-03T00:07:27.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4038" PostTypeId="2" ParentId="4028" CreationDate="2014-09-03T15:59:59.230" Score="1" Body="&lt;p&gt;For I2C you can try &lt;a href=&quot;http://www.linear.com/product/LTC4312&quot; rel=&quot;nofollow&quot;&gt;http://www.linear.com/product/LTC4312&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will allow you to make two I2C networks to address all the nodes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the wiring for I2C will be a nightmare, but it might be necessary if you want the nodes to be independent. &lt;/p&gt;&#xA;" OwnerUserId="3818" LastActivityDate="2014-09-03T15:59:59.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4039" PostTypeId="1" CreationDate="2014-09-03T18:11:50.193" Score="13" ViewCount="7345" Body="&lt;p&gt;Arduino sketches usually feature a &lt;a href=&quot;http://arduino.cc/en/Reference/Setup&quot;&gt;&lt;code&gt;setup&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://arduino.cc/en/Reference/Loop&quot;&gt;&lt;code&gt;loop&lt;/code&gt;&lt;/a&gt; function. Are these functions only provided for convenience or do they actually have special purposes? (e.g.: are some operations disallowed or allowed in setup and loop)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are these two pieces of code equivalent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Classic&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    pinMode(LED_BUILTIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(LED_BUILTIN, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(LED_BUILTIN, LOW);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Without loop&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    pinMode(LED_BUILTIN, OUTPUT);&#xA;&#xA;    while(true) {&#xA;        digitalWrite(LED_BUILTIN, HIGH);&#xA;        delay(1000);&#xA;        digitalWrite(LED_BUILTIN, LOW);&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to write code without either setup or loop, providing, for example, a &lt;code&gt;main&lt;/code&gt; method or other entry point?&lt;/p&gt;&#xA;" OwnerUserId="3838" LastEditorUserId="10794" LastEditDate="2015-10-29T06:36:56.937" LastActivityDate="2018-03-21T13:20:28.143" Title="Is setup and loop provided for convenience?" Tags="|programming|c++|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4040" PostTypeId="2" ParentId="4039" CreationDate="2014-09-03T18:26:03.100" Score="10" Body="&lt;p&gt;Those pieces of code are pretty much the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp#L43-L48&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino source code&lt;/a&gt; you'll see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup();&#xA;&#xA;for (;;) {&#xA;  loop();&#xA;  if (serialEventRun) serialEventRun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I'm not sure what &lt;code&gt;serialEventRun()&lt;/code&gt; does.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think you can 'overload' the &lt;code&gt;main&lt;/code&gt; function declaration. Also note that the main function calls &lt;code&gt;init&lt;/code&gt;, which e.g. configures the timers, so &lt;code&gt;millis()&lt;/code&gt; etc. will work.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="44959" LastEditDate="2018-03-21T13:20:28.143" LastActivityDate="2018-03-21T13:20:28.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4041" PostTypeId="2" ParentId="4039" CreationDate="2014-09-03T18:28:20.203" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Are these functions only provided for convenience or do they actually have special purposes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino libraries do a tiny bit of housekeeping with &lt;code&gt;loop()&lt;/code&gt;, related to &lt;a href=&quot;http://arduino.cc/en/Reference/SerialEvent&quot;&gt;serial handling&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are these two pieces of code equivalent:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Only if you never use serial events.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not while strictly using the Arduino libraries via the IDE; the linker will complain of either duplicate &lt;code&gt;main&lt;/code&gt; definitions or of missing &lt;code&gt;setup&lt;/code&gt; or &lt;code&gt;loop&lt;/code&gt; definitions.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-03T18:28:20.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4043" PostTypeId="2" ParentId="4039" CreationDate="2014-09-04T02:52:24.950" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The last time I used the IDE, you could have a project with no &lt;code&gt;.ino&lt;/code&gt;/&lt;code&gt;.pde&lt;/code&gt; file, only &lt;code&gt;.cpp&lt;/code&gt;files; since it's the mangling of the &lt;code&gt;.ino&lt;/code&gt; into a &lt;code&gt;.cpp&lt;/code&gt; that defines the &lt;code&gt;main&lt;/code&gt; function, if you bypass that step then you can define your own &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the IDE no longer allows this (as I've heard) you can still do the same thing with e.g. a Makefile-based build outside the IDE, without giving up the Arduino libraries. The caveats that I know of are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should &lt;code&gt;#include &quot;Arduino.h&quot;&lt;/code&gt; if you want access to the library functions.&lt;/li&gt;&#xA;&lt;li&gt;You should call &lt;code&gt;init()&lt;/code&gt; if you want the library to set up peripherals the way you're used to.&lt;/li&gt;&#xA;&lt;li&gt;You should put the &lt;code&gt;serialEvent&lt;/code&gt; code that Gerben points out in your mainloop if you want a &lt;code&gt;serialEvent&lt;/code&gt; handler to run (but you probably don't need this anyway if you want to write your own mainloop).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3508" LastActivityDate="2014-09-04T02:52:24.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4044" PostTypeId="1" CreationDate="2014-09-04T04:52:06.887" Score="0" ViewCount="186" Body="&lt;p&gt;I have been using my arduino uno for many months and it worked very well even till today morning but an hour ago I tried to upload a sketch and arduino IDE showed my this &quot;&lt;strong&gt;avrdude: stk500_getsysc(): not in sync: resp =0x00&lt;/strong&gt;&quot; , at first I thought maybe I burned my atmega32 chip but I bypassed reset and gnd with a jumper wire and opened serial monitor and my atmega32 still printing serial data,so problem must be something else,and also my led13 isn't blinking.Is it problem with bootloader?if so how can I reload bootloader in my board without using another arduino?&lt;/p&gt;&#xA;" OwnerUserId="3761" LastActivityDate="2014-09-04T08:50:59.553" Title="Arduino not responding" Tags="|arduino-uno|bootloader|avrdude|" AnswerCount="1" CommentCount="0" ClosedDate="2015-02-22T18:06:35.693" ContentLicense="CC BY-SA 3.0" />
  <row Id="4045" PostTypeId="1" AcceptedAnswerId="4046" CreationDate="2014-09-04T05:43:43.213" Score="0" ViewCount="414" Body="&lt;p&gt;I am trying to connect 4 small DC motors to Arduino, like those in the following image:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/3wWMY.jpg&quot; alt=&quot;my kit, 4WD, with 4 simple motors&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specification for each of them is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Suggested Voltage: 3V DC;&lt;br&gt;&#xA;  No Load Speed: 65 ± 10rpm;&lt;br&gt;&#xA;  No Load Current: 125mA (170mA MAX).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I have no useful knowledge in electronics to do so...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be really thankful if anyone could explain me why it is so difficult to connect DC motors to Arduino (I've heard about problems with the magnetic field, but I don't really understand why); and possible point me to an easy (and cheap) solution. I am, of course, willing to study (not expecting a complete solution).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware there are some shields for doing this kind of connection, but they are really expensive, and I've seen some people using only transistors or components like SN754410.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance! :-)&lt;/p&gt;&#xA;" OwnerUserId="3847" LastActivityDate="2014-09-04T08:29:57.373" Title="Arduino + simple DC motors? (4WD kit)" Tags="|arduino-uno|motor|robotics|arduino-motor-shield|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4046" PostTypeId="2" ParentId="4045" CreationDate="2014-09-04T08:29:57.373" Score="0" Body="&lt;p&gt;First you make 4 parallel H-Bridges, &lt;a href=&quot;http://en.wikipedia.org/wiki/H_bridge&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/H_bridge&lt;/a&gt; then you attach it to an external powersource ( or attach directly to the battery to prevent burning your arduino )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attach every up to a pin, making it high makes the motor running, you need 8 pins for this, eg pin 1 makes motor 1 go forward, pin 2 makes motor 1 go back and so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is by far the most practical solution, but it is the easiest, and can be done with 8 PNP and 8 NPN transistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't know how transistors work i suggest &lt;a href=&quot;https://www.youtube.com/watch?v=-td7YT-Pums&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=-td7YT-Pums&lt;/a&gt; collins lab, it is both educational and entertaining. &lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-09-04T08:29:57.373" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4047" PostTypeId="2" ParentId="4044" CreationDate="2014-09-04T08:50:59.553" Score="2" Body="&lt;p&gt;I'm personally not really in to this RTFM kind of answer, but in this case it really do answer most of your questions about the bootloader part: &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Hacking/Bootloader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the error, a quick search on SO gives you this: &lt;a href=&quot;https://stackoverflow.com/questions/24240285/arduino-nano-3-avrdude-stk500-getsync-not-in-sync-resp-0x00&quot;&gt;https://stackoverflow.com/questions/24240285/arduino-nano-3-avrdude-stk500-getsync-not-in-sync-resp-0x00&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-09-04T08:50:59.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4048" PostTypeId="2" ParentId="1278" CreationDate="2014-09-04T17:33:54.070" Score="0" Body="&lt;p&gt;I've done exactly this.  The secret sauce for me was the &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerialListen&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial.listen()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before running your GSM commands you have to make sure the GSM module's SoftwareSerial port is &quot;listening&quot;.  Then when you're done you have to &lt;code&gt;listen()&lt;/code&gt; again to the GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is, of course, not terribly efficient, while the GSM port is listening any GPS data will be lost, but at least in my case the impact was negligible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is here: &lt;a href=&quot;https://github.com/lectroidmarc/gsm-tracker&quot; rel=&quot;nofollow&quot;&gt;https://github.com/lectroidmarc/gsm-tracker&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, I have also considered plugging the GPS into the UART and running debug messages to a SoftwareSerial serial port, to be monitored during testing with another Arduino.  I'm just not sure the benefit would be there.&lt;/p&gt;&#xA;" OwnerUserId="3855" LastActivityDate="2014-09-04T17:33:54.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4051" PostTypeId="1" CreationDate="2014-08-13T19:04:25.437" Score="3" ViewCount="3961" Body="&lt;p&gt;I'm pretty new to microcontrollers and Arduino and since I can't find any satisfying information on my problem, I hope that you might answer them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project is actually quite simple: I just want to write out data over a serial connection via USB, the problem: My Arduino Nano has to run as USB Host. That's because the other device is a vacuum cleaner: Neato XV-25 with a mini usb jack. I was already able to 'talk' to it using a Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I don't have much knowledge about USB communication, I would like to know the following, before I start digging deeper:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I found out, that I would not be able to use the 'usual' usb port of the nano. But I've read a few things about that 'V-USB' library, but did not understand very much. Would it be possible to create a USB Host with this library, that can communicate via a virtual serial connection?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I stumbled across the USBHost for Android Nano. It's a shield, but I'm not sure if it would fit my needs. Is it able to handle serial communication? And is there somewhere a store where I can get it cheap? I think more than 20$ for a shield is a bit too much...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerDisplayName="Timo K" LastEditorUserId="4539" LastEditDate="2014-10-29T05:19:36.507" LastActivityDate="2015-01-27T07:38:40.203" Title="Using Arduino Nano as USB Host" Tags="|shields|arduino-nano|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4052" PostTypeId="2" ParentId="4051" CreationDate="2014-09-05T14:20:08.703" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;V-USB is a software-only implementation of a low-speed USB &lt;strong&gt;device&lt;/strong&gt; for Atmel’s AVR® microcontrollers&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No host support here, sorry.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The USB host shield handles the hardware bit and simplifies the software bit. It is up to the firmware to support the various USB profiles. Version 2.0 of the library supports CDC with a few devices; check to see if they would be correct for your purpose.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-05T14:20:08.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4053" PostTypeId="1" CreationDate="2014-09-05T18:19:37.980" Score="1" ViewCount="112" Body="&lt;p&gt;I'm developing a project (Data logger) that requires that the Arduino remains on for several weeks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it okay to leave it on for about 6 weeks? Do I need to frequently reset it?&lt;/p&gt;&#xA;" OwnerUserId="3404" LastEditorUserId="37" LastEditDate="2014-09-05T20:31:09.863" LastActivityDate="2014-09-05T20:31:09.863" Title="Is it bad to leave my Arduino UNO on uninterruped?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ClosedDate="2014-09-07T12:49:13.250" ContentLicense="CC BY-SA 3.0" />
  <row Id="4054" PostTypeId="2" ParentId="4053" CreationDate="2014-09-05T19:40:48.483" Score="1" Body="&lt;p&gt;This question has a very broad answer. As it depends upon your implementation of both hardware and software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In very short - &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That all depends on your code. The hardware should be able to be left on indefinitely, assuming it is all within spec's. Assuming that, then the biggest concern is the code running on it. Where largest problem of concern is running out of resources. Such as memory. If your code as a memory leak then it will be a problem. Or if there is a bug in the code that can cause it to get stuck. The later can be addressed by employing the WatchDog, which will reset (loose all data) if the code gets unexpectedly stuck. &lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-09-05T19:40:48.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4055" PostTypeId="1" CreationDate="2014-09-05T21:05:55.140" Score="-1" ViewCount="7009" Body="&lt;p&gt;I have loaded an example sketch that came with the installation of the Arduino software onto my Uno.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  int sensorValue = analogRead(A0);&#xA;  Serial.println(sensorValue);&#xA;  delay(1);       &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this time TX light is continuously on. It's remaining on even after resetting it. How do I end &lt;code&gt;void loop&lt;/code&gt; so that TX light goes off.&lt;/p&gt;&#xA;" OwnerUserId="3873" LastEditorUserId="3466" LastEditDate="2014-09-06T12:45:34.260" LastActivityDate="2022-09-30T16:08:52.163" Title="Unable to terminate &quot;void loop&quot;" Tags="|arduino-uno|programming|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4056" PostTypeId="1" CreationDate="2014-09-05T21:53:26.470" Score="4" ViewCount="920" Body="&lt;p&gt;I am working off an Arduino Uno with an &lt;a href=&quot;http://www.adafruit.com/products/364&quot; rel=&quot;nofollow noreferrer&quot;&gt;AdaFruit PN532 NFC/RFID shield&lt;/a&gt;. The goal is to have a shoe box, with a false bottom. Under that false bottom would be my prototype, which I hope will be able to detect any MIFARE tag that is in the box, above the false bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range obviously for these devices is practically touching, but I was was wondering if there is anyway to extend the reach of the NFC/RFID shield, so that the entire false bottom of the box could act as that antenna.&lt;/p&gt;&#xA;" OwnerUserId="3875" LastEditorUserId="4628" LastEditDate="2017-09-26T04:52:06.350" LastActivityDate="2018-01-24T07:27:26.130" Title="Is it possible to extend the reach of a PN532 NFC/RFID shield?" Tags="|arduino-uno|sensors|rfid|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4057" PostTypeId="2" ParentId="4055" CreationDate="2014-09-05T22:04:17.983" Score="6" Body="&lt;p&gt;The TX LED is on, because this sketch is periodically printing the value of the analog pin 0 onto the serial port. The LED seems to be constantly on, because the delay between two &lt;code&gt;Serial.println()&lt;/code&gt; calls is only approx. 1 ms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you replace the 1 with 1000 for example, the TX LED should flash once per second. Start the serial monitor in your Arduino IDE too see the transmitted analog values. Delete the &lt;code&gt;Serial.&lt;/code&gt; calls to remove the serial port functionality altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read the documentation of the &lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Reference/Loop&quot;&gt;loop()&lt;/a&gt; and the &lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Reference/Delay&quot;&gt;delay()&lt;/a&gt; functions.&lt;/p&gt;&#xA;" OwnerUserId="3466" LastActivityDate="2014-09-05T22:04:17.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4058" PostTypeId="2" ParentId="4056" CreationDate="2014-09-05T23:07:13.320" Score="1" Body="&lt;p&gt;I suspect not. NFC is designed for short range for privacy reasons. Some RFID systems have longer ranges (a few meters). They work by using an electromagnet to create a switching magnetic field. The RFID/NFC chip takes power from the magnetic field and then modulates a signal onto it, which the sensor detects. In order for it to work the chip needs to be close enough to get as strong enough field to power itself, and to modulate that field. &lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-05T23:07:13.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4059" PostTypeId="2" ParentId="4055" CreationDate="2014-09-06T00:00:41.613" Score="8" Body="&lt;p&gt;The implied question is how to turn off the Tx LED, which has already been answered and is probably the answer you're looking for. But the question you asked is how to end the &lt;code&gt;loop()&lt;/code&gt; function. Not to be pedantic but to clarify the use of &lt;code&gt;loop&lt;/code&gt;, the simple answer is, &quot;you can't&quot;. &lt;code&gt;loop()&lt;/code&gt; is called from a forever loop in the C/C++ main program, function &lt;code&gt;main()&lt;/code&gt;, so returning from it, either with a &lt;code&gt;return&lt;/code&gt; statement or by reaching the final close &lt;code&gt;}&lt;/code&gt; causes &lt;code&gt;loop()&lt;/code&gt; to be called again. This is intentional as the &lt;code&gt;main()&lt;/code&gt; function in an embedded system is never supposed to return, thus it must keep re-running the application program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update (since this question just reappeared on the front page, I'll add the following to my answer):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;loop()&lt;/code&gt; reads and prints continuously. If you had wanted that code to be executed only once, you could put in &lt;code&gt;setup()&lt;/code&gt; and leave &lt;code&gt;loop()&lt;/code&gt; empty. Then the sketch would initialize the serial output, read an analog value, print it - once - followed by entering the empty &lt;code&gt;loop()&lt;/code&gt; and remaining there until power-down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A way to execute the loop function once is to write an infinite loop at the end of it, so &lt;code&gt;loop()&lt;/code&gt; would never return and thus never be re-executed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;  int sensorValue = analogRead(A0);&#xA;  Serial.println(sensorValue);&#xA;  delay(1);&#xA;&#xA;  while(1)&#xA;     ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-01-23T18:50:19.127" LastActivityDate="2015-01-23T18:50:19.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4061" PostTypeId="2" ParentId="4055" CreationDate="2014-09-06T03:28:09.723" Score="2" Body="&lt;p&gt;Seeing as questions about turning off the LED, and the nature of exiting &lt;code&gt;loop&lt;/code&gt; have been answered, I'll also answer the question they both seem to lead to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the overall intention is to &quot;turn off&quot; the MCU, outside of turning off the power supply, it can be put into &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;sleep mode&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on how you configure the MCU before entering sleep mode, it can even be allowed to wake up on further USART communication.&lt;/p&gt;&#xA;" OwnerUserId="3876" LastActivityDate="2014-09-06T03:28:09.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4062" PostTypeId="2" ParentId="1868" CreationDate="2014-09-06T05:52:34.617" Score="2" Body="&lt;p&gt;The relay board you are using has active low inputs to control the relays.&#xA;In your sketch when you are initialising the pins as outputs they are by default set low (this is turning all your relays on).&#xA;set the pins as outputs and set them high, they will be low for a very short time (too short for the relay to turn on effectively).&lt;/p&gt;&#xA;" OwnerUserId="3877" LastEditorUserId="19409" LastEditDate="2017-09-10T11:46:12.677" LastActivityDate="2017-09-10T11:46:12.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4065" PostTypeId="1" AcceptedAnswerId="4066" CreationDate="2014-09-06T09:45:57.270" Score="0" ViewCount="234" Body="&lt;p&gt;I have a PIR motion sensor and would like some ultra bright UV led lights to fade in when this is triggered. It is one unit, consisting of 225 led lights connected to 240v mains (Australia). I bought a relay for the basic on/off function but was wondering if fading on and off can be done relatively easily - this is my first arduino project. I would value any suggestions.&lt;/p&gt;&#xA;" OwnerUserId="3880" LastActivityDate="2014-09-06T11:39:12.703" Title="Fade in UV lights connected to mains" Tags="|led|relay|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4066" PostTypeId="2" ParentId="4065" CreationDate="2014-09-06T11:39:12.703" Score="1" Body="&lt;p&gt;Most LED lights can't be dimmed from the mains supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to dim LEDs you have 2 choices: Limit the current through each LED or series string of LEDs, or pulse them very rapidly with a varying ratio of on/off times (known as a variable &quot;duty cycle&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's usually easiest to pulse them. To do that you need to be able to control the flow of DC to the LED array. If you were to take apart your IR array you would very likely find an AC to DC power supply that then feeds the LEDs through current limiting resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can figure out the voltage and current that comes out of the DC power supply, you can select a power transistor (almost certainly a logic level power MOSFET) to wire in as an electronic switch that enables you to pulse the power to the LEDs using a logic signal from your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is actually a lot simpler than it sounds. You would cut 1 wire inside your LED array, solder in a single transistor to the 2 ends of the cut wire, and run the third wire from the transistor out to your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos have several I/O lines that can be configured for PWM (Pulse Width Modulation) which is designed for this very purpose. You'd connect a PWM line to the gate of a logic level power MOSFET, and then send it a signal from 0 to 255, which would effectively dim the LED array in 255 brightness steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are beginner sample projects that let you dim single visible light LEDs using this very approach. (For a single LED you don't need a transistor though, so they are really easy to wire up. All you need is a current limiting resistor.) I suggest you find and build one of those projects to get a feel for how (and how well) it works.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-06T11:39:12.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4067" PostTypeId="1" AcceptedAnswerId="4068" CreationDate="2014-09-06T13:45:59.060" Score="1" ViewCount="1078" Body="&lt;p&gt;I just begun with the Arduino starter kit, and in the second example I would like to test some changes to learn more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is to have a green LED shining, and when pressing the button the two red LEDs blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int switchState = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(2, INPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;&#xA;  // the button is pressed&#xA;  digitalWrite(3, LOW);&#xA;&#xA;  digitalWrite(4, LOW);&#xA;  digitalWrite(5, HIGH);&#xA;  delay(250); // wait for a quarter second&#xA;  // toggle the LEDs&#xA;  digitalWrite(4, HIGH);&#xA;  digitalWrite(5, LOW);&#xA;  delay(250); // wait fo a quarter second&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  switchState = digitalRead(2);&#xA;  // this is a comment&#xA;  if(switchState == LOW)&#xA;  {&#xA;    // the button is not pressed&#xA;    digitalWrite(3, HIGH); // green LED&#xA;    digitalWrite(4, LOW); // red LED&#xA;    digitalWrite(5, LOW); // red LED&#xA;  }&#xA;  else&#xA;  {&#xA;    // the button is pressed&#xA;    digitalWrite(3, LOW);&#xA;&#xA;    digitalWrite(4, LOW);&#xA;    digitalWrite(5, HIGH);&#xA;    delay(250); // wait for a quarter second&#xA;    // toggle the LEDs&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(5, LOW);&#xA;    delay(250); // wait fo a quarter second&#xA;  }&#xA;} // go back to the beginning of the loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added a modification into the schema (a fourth LED in parallel with the green), like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1jCas.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZcS7d.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the added LED is not shining. It's a long time ago I finish school and I forgot a lot of things. Am I wiring the fourth LED incorrectly?&lt;/p&gt;&#xA;" OwnerUserId="3840" LastEditorUserId="37" LastEditDate="2014-09-06T16:54:17.647" LastActivityDate="2014-09-06T16:54:17.647" Title="Arduino starter kit example LEDS modification" Tags="|arduino-uno|led|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4068" PostTypeId="2" ParentId="4067" CreationDate="2014-09-06T15:47:58.573" Score="1" Body="&lt;p&gt;Blue LEDs have a higher V&lt;sub&gt;f&lt;/sub&gt; than green LEDs, hence much less current will pass through it, not enough to make it visible. Give it its own resistor instead of sharing the resistor with the green.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-06T15:47:58.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4069" PostTypeId="2" ParentId="4055" CreationDate="2014-09-06T16:19:41.037" Score="2" Body="&lt;p&gt;Don't write code in the loop() that should be executed only a few times. Or use a counter. Or an external button. For the permanent light, increase the delay between calls.&lt;/p&gt;&#xA;" OwnerUserId="3883" LastActivityDate="2014-09-06T16:19:41.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4070" PostTypeId="1" AcceptedAnswerId="4074" CreationDate="2014-09-06T17:17:42.097" Score="6" ViewCount="14740" Body="&lt;p&gt;When I used &lt;code&gt;Serial.println()&lt;/code&gt; in the code I naively believed I would see the characters that I sent displayed on that little black area just under the interface (just like a terminal).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int moveServo;&#xA;&#xA;Servo myservo;&#xA;&#xA;void setup()&#xA;{&#xA;  myservo.attach(0);&#xA;  Serial.println(&quot;      Hello Earth&quot;);&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me just where &lt;code&gt;Hello Earth&lt;/code&gt; would be displayed?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="37" LastEditDate="2014-09-06T21:21:34.507" LastActivityDate="2014-09-07T10:39:15.003" Title="Serial.println(): Where is the text printed?" Tags="|serial|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4071" PostTypeId="1" AcceptedAnswerId="4079" CreationDate="2014-09-06T17:19:55.333" Score="43" ViewCount="23527" Body="&lt;p&gt;In a lot of the sample code online people add the line &lt;code&gt;Serial.begin(9600)&lt;/code&gt; in the setup block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I look up what &lt;code&gt;Serial.begin()&lt;/code&gt; is on the official documentation, it says that it controls the bit per second data transfer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the obvious question is, why not use 28800, the highest transfer rate? Why do people settle for 9600? What is the limitation here?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="37" LastEditDate="2014-09-06T21:14:36.687" LastActivityDate="2014-09-08T22:39:15.220" Title="Serial.begin(): Why not always use 28800?" Tags="|serial|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4072" PostTypeId="2" ParentId="4071" CreationDate="2014-09-06T17:45:28.613" Score="0" Body="&lt;p&gt;I think the main reason people use 9600 most of the time is that it's the default baud rate in the Arduino IDE. Also, faster data rates could also be unreliable if the serial signal has to travel a long way - although I have no idea why this was selected as an optimum speed.&lt;/p&gt;&#xA;" OwnerUserId="3724" LastEditorUserId="3724" LastEditDate="2014-09-06T19:04:53.497" LastActivityDate="2014-09-06T19:04:53.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4073" PostTypeId="2" ParentId="4071" CreationDate="2014-09-06T17:52:39.843" Score="3" Body="&lt;p&gt;I think it is a kind of tradition to use a transfer rate that is not the slowest one (300) but also not one that could eventually cause problems in some setups (28800 or even 115200). The PC serial port (most often a FTDI232 USB adapter) can cope with higher rates but your DIY hardware may not. So 9600 bps has established itself as some kind of standard transfer rate for code examples.&lt;/p&gt;&#xA;" OwnerUserId="3466" LastActivityDate="2014-09-06T17:52:39.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4074" PostTypeId="2" ParentId="4070" CreationDate="2014-09-06T17:52:41.777" Score="11" Body="&lt;p&gt;The IDE on your computer has a menu item under the tools menu called &quot;Serial Monitor.&quot; On my Mac, at least, it is indeed a black area under the source editor for the current sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It won't work unless you call the &lt;code&gt;Serial.begin()&lt;/code&gt; function in your setup method before the first &lt;code&gt;Serial.print()/println()/write()&lt;/code&gt; function call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Set up the serial port @ 9600 baud for display back to the computer&#xA;Serial.begin(9600);&#xA;delay(25);&#xA;Serial.println(&quot;Hello world!&quot;:);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-09-07T10:39:15.003" LastActivityDate="2014-09-07T10:39:15.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4075" PostTypeId="2" ParentId="4070" CreationDate="2014-09-06T17:56:06.107" Score="3" Body="&lt;p&gt;You can open the serial console in the Arduino IDE by pressing ctrl-shift-M (as in Monitor) or selecting it in the menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to use the serial interface, you have to initialize it using &lt;code&gt;Serial.begin(9600);&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt; before calling any other function which writes to it. You can use any other baud rate - but this is the default in the Arduino IDE, if you change it, you should change it in the IDE too.&lt;/p&gt;&#xA;" OwnerUserId="3724" LastActivityDate="2014-09-06T17:56:06.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4076" PostTypeId="1" AcceptedAnswerId="4081" CreationDate="2014-09-06T19:18:52.017" Score="8" ViewCount="134056" Body="&lt;p&gt;When I started Arduino, I did not expect that everything must be contained in an infinite loop. I thought I could just write something like: motor start -&gt; motor stop. But in actuality, what I get is motor start -&gt; motor stop -&gt; motor start -&gt; ... forever and ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is commonly done to stop a servo after it is in a desired position? Do I use &lt;code&gt;servo.write(desired position)&lt;/code&gt; to keep it from turning? Do I detach the output wire?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some of the risks involved?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="37" LastEditDate="2014-09-06T21:06:34.793" LastActivityDate="2017-10-05T04:04:04.830" Title="What is commonly done to stop a servo after reaching desired position?" Tags="|servo|" AnswerCount="7" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4077" PostTypeId="2" ParentId="4076" CreationDate="2014-09-06T19:46:58.737" Score="9" Body="&lt;p&gt;A normal servo doesn't have a &quot;go&quot; function, it only has positional control. That is, whether you run &lt;code&gt;servo.write(90)&lt;/code&gt; forever or once, the servo will go to 90 and continue to actively keep that position until you write another position. The only way to turn a servo  off is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servo.detach();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a normal DC motor, you will need to turn it on then off and then have kind of state tracking in the loop to never turn it on again, using a variable or &lt;code&gt;millis()&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you want something to only run once, put it in &lt;code&gt;setup()&lt;/code&gt; (maybe within a loop in setup for simple tasks).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can simulate ending the program by entering an infinite loop with &lt;code&gt;while(true){}&lt;/code&gt; or &lt;code&gt;for(;;){}&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="4628" LastEditDate="2017-10-05T04:02:30.740" LastActivityDate="2017-10-05T04:02:30.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4078" PostTypeId="1" AcceptedAnswerId="4080" CreationDate="2014-09-06T19:52:50.373" Score="0" ViewCount="3695" Body="&lt;p&gt;Every time that I open the Serial Monitor, my &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno&lt;/a&gt;, seems to go back to &lt;code&gt;void setup()&lt;/code&gt;. Is it a normal thing?&lt;/p&gt;&#xA;" OwnerUserId="3404" LastEditorUserId="510" LastEditDate="2015-09-28T13:43:50.910" LastActivityDate="2015-09-28T13:43:50.910" Title="Why does my Arduino seem to reboot every time that I open Serial Monitor?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ClosedDate="2014-09-07T12:57:29.617" ContentLicense="CC BY-SA 3.0" />
  <row Id="4079" PostTypeId="2" ParentId="4071" CreationDate="2014-09-06T20:17:05.430" Score="55" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why do people settle?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;People settle because it is more than fast enough.  The most common use is just to print some stuff on a terminal for debuggin.  9600 baud is 960 characters per second, or 12 x 80 character lines per second.  How fast can you read? :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your program is using the serial port for bulk data transfer, you would choose not to settle.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the limitation...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The limits on serial are high.  Directly you can use 115200 baud in your programs and it will just work.  The Arduino terminal will allow a max of 115200, but other programs such as RealTerm would let you run higher.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware serial will run to 1 M baud.  If you read around you will see people have used up to 1 M by directly controlling the UART.  You might get benefit of high baud rates for uses such as transmitting via a bluetooth chip.  If you are using the hardware serial interface to exchange from chip to chip with just a short distance, then 1 M baud is completely feasible.  Think of all the SPI and I2C devices that operate just fine at 1 MHz clock rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over larger distances, you will start to have problems with noise when using logic level (plain 0 to 5V) signalling.  To use larger distances, you would add a transceiver to provide robust signalling, commonly RS-232 and less commonly RS-485.  With RS-232 you could run a mega bit at distances of 10's of feet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The microprocessor clock speed will be the real limit.  With a hardware UART, the processor must load one byte to the UART every 10 bits (for N81).  So when you get to 1 M baud it will be a challenge for the 16 MHz processor to keep the UART supplied with data.  A new byte will be sent every 160 clock ticks, which is very few lines of code.  For a short burst of data, you might achieve that rate.  The message is, the processor will run out of speed before the UART is the limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, this all applies to &lt;strong&gt;HardwareSerial&lt;/strong&gt;, software serial is very different.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastEditorUserId="37" LastEditDate="2014-09-06T20:42:13.563" LastActivityDate="2014-09-06T20:42:13.563" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4080" PostTypeId="2" ParentId="4078" CreationDate="2014-09-06T20:17:32.847" Score="5" Body="&lt;p&gt;That is a normal feature of Arduinos, not an error. I find it mildly annoying sometimes, but it's nice for interactive programs that want some kind of menu message to be the first thing you see in the terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want help disabling the auto reset, your options are detailed in &lt;em&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection&quot; rel=&quot;nofollow&quot;&gt;Disabling Auto Reset On Serial Connection&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="510" LastEditDate="2015-09-27T15:49:36.207" LastActivityDate="2015-09-27T15:49:36.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4081" PostTypeId="2" ParentId="4076" CreationDate="2014-09-06T20:50:08.570" Score="15" Body="&lt;p&gt;You do not &quot;stop&quot; a servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A servo is always running.  In a general sense, the servo is a control loop that takes as input a position target and applies force to hold at the requested target.  If you want the target to be maintained, then the servo must be running.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A servo motor contains electronics that are internally turning a DC motor on and off as necessary to hold the target position.  If the target does not match the current position, it turns on the motor to turn until the two match.  Once the output shaft reaches what you requested, the electronics inside the servo motor turn the motor &quot;off&quot;.  Off meaning the DC motor is drawing little or no current.  The servo control loop is always running comparing the shaft position to a target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you powered off the entire servo motor, the position is not under control and could move.  For many applications if you unplugged the wires, the gears and motors apply enough friction that it would not turn.  But in general, you do not count on friction to make things work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Do I use...Servo.Write(desired position) to keep it from turning?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes.  To tell a servo to stay at one position, you can just keep sending it the same target. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you do not have to Write() again and again.  If you want, you can keep track of what the last setting was and apply only when you have a change.   For example, you can code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(position_target != position_last_set) {&#xA;  Servo.Write(position_target);&#xA;  position_last_set = position_target;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regardless of your code, under the hood, Servo is constantly transmitting the position target to the servo motor.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-09-06T20:50:08.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4082" PostTypeId="1" AcceptedAnswerId="4083" CreationDate="2014-09-06T21:43:58.720" Score="3" ViewCount="4617" Body="&lt;p&gt;Has anyone ever accidentally or inadvertently connected connected the supply port with the ground port with a wire? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does Arduino provide internal safety to prevent the circuit board from shorting out?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastActivityDate="2014-09-06T22:38:21.097" Title="Curious: What would happen if you connect 5V and GND port directly with a wire" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4083" PostTypeId="2" ParentId="4082" CreationDate="2014-09-06T22:38:21.097" Score="6" Body="&lt;p&gt;There is some protection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When powered from the USB port, the UNO has a 0.5 A fuse.  This is a self resetting fuse that will trip when the current is high, and reset when it cools back down.  These fuses are great for peripherals that might be exposed to occasional &quot;oops&quot;.  See the &lt;a href=&quot;https://www.bourns.com/pdfs/mfmsmf.pdf&quot;&gt;data sheet&lt;/a&gt; for more details of the part on the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When powered from the PWRIN plug, the voltage regulator provides some protection.  The device on the UNO contains over current and over temperature protection, which is common for regulators such as this.  The device will get very hot, and the protection will activate to limit the current (see &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/NCP1117-D.PDF&quot;&gt;datasheet&lt;/a&gt; for details).  By design, the regulator chip should protect itself from being destroyed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to first order, if you by mistake connect the +5 on the header to GND, all that will happen is Vcc will be reduced to near zero Volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The caveat is that a small spark can be generated when you make this short to ground, especially if you have a bunch of capacitors on Vcc.  That spark may cause a voltage transient that could damage a pin.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-09-06T22:38:21.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4086" PostTypeId="1" AcceptedAnswerId="4087" CreationDate="2014-09-07T03:42:15.423" Score="1" ViewCount="975" Body="&lt;p&gt;I'm trying to control a single motor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press 'a', then motor 1 should turn to 0, if I press 's', then motor 1 should turn to 180&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;char key = 0;&#xA;const unsigned int BAUD_RATE = 9600;&#xA;&#xA;Servo Servo_0;&#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Servo_0.attach(0);&#xA;  Servo_0.write(0);&#xA;&#xA;  Serial.begin(BAUD_RATE);&#xA;&#xA; // Serial.println(&quot;      Arduino Serial Servo Control&quot;);&#xA; // Serial.println(&quot;Press &amp;lt; or &amp;gt; to move, spacebar to center&quot;);&#xA; // Serial.println();&#xA;&#xA;}&#xA;&#xA;/*&#xA;a - 97&#xA;s - 115&#xA;d - 100&#xA;f - 102&#xA;*/&#xA;&#xA;void loop() {&#xA;&#xA;  if(Serial.available()&amp;gt;0)&#xA;  {&#xA;      key = Serial.read();&#xA;      Serial.print(&quot;I received: &quot;);&#xA;      Serial.println(key, DEC);&#xA;&#xA;     if(key == byte(97))&#xA;     {&#xA;&#xA;       Serial.print(&quot;Turning Motor 1 to 0 deg&quot;);&#xA;       Servo_0.write(0);&#xA;&#xA;     }&#xA;     else if(key==byte(115))&#xA;     {&#xA;       Serial.print(&quot;Turning Motor 1 to 180 deg&quot;);&#xA;       Servo_0.write(180);&#xA;&#xA;     }  &#xA;&#xA;     delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what is happening is that the motors are barely turning after I enter the key onto the Arduino monitor interface. Can anyone diagnose as to what might be happening?&lt;/p&gt;&#xA;" OwnerUserId="3786" LastEditorUserId="3786" LastEditDate="2014-09-07T04:13:39.947" LastActivityDate="2014-09-07T06:49:19.620" Title="Keyboard Control Not Working As Intended" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4087" PostTypeId="2" ParentId="4086" CreationDate="2014-09-07T06:49:19.620" Score="4" Body="&lt;p&gt;The problem I see is that your servo is attached to pin 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 0 and 1 are used by arduino unos and megas for serial communication, so you can't output to a motor and send/receive serial at the same time. Try moving the servo to pin 3 and see what happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In response to your comment, any character sent from any terminal (or other piece of hardware) will work; you do not need to use Processing to communicate with an arduino.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-09-07T06:49:19.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4088" PostTypeId="1" AcceptedAnswerId="4091" CreationDate="2014-09-07T11:12:53.893" Score="2" ViewCount="1079" Body="&lt;p&gt;I'd like to build a simple GPS system. It should be very little. For the software side, I will build an API, so from my PC/smartphone/whatever else I could ask the GPS system where it is located (I think Google provides this kind of feature).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this? My main problem is the GPS and the its building. I'd like to build the smallest thing possible, because I have to hide it. My idea is to hide this GPS system in my bike: I'd like to locate my bike if someone stole it. As you can see, internet is a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not asking to design anything. I would only know what I need to build a basic GPS system that has just the feature described. What do I need? Is it possible to do it? Does GPS require Internet connection? I would know if I could make it or not without internet access.&lt;/p&gt;&#xA;" OwnerUserId="3889" LastEditorUserId="220" LastEditDate="2014-09-07T13:35:09.153" LastActivityDate="2014-09-07T20:37:43.670" Title="Building a gps system" Tags="|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4089" PostTypeId="2" ParentId="4071" CreationDate="2014-09-07T13:50:27.637" Score="3" Body="&lt;p&gt;Back in the mists of time, the &quot;gold standard&quot; for remote keyboards (using a a telephone modem, and teletypes, if you remember those) was 9600 baud, initially achievable only over a dedicated phone line. Time moves on, slowly; technology advances, rapidly; and memory moves even more slowly than time (it seems). We can routinely communicate, at least over a several meters, at a couple of orders of magnitude faster than 9600 baud. What was once considered a gold standard is no longer gold, but still thought of as standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr: It's history, not technology.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-09-08T22:39:15.220" LastActivityDate="2014-09-08T22:39:15.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4091" PostTypeId="2" ParentId="4088" CreationDate="2014-09-07T20:37:43.670" Score="4" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;&quot;Is it possible to do it?&quot;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well... everything is possible :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&quot;Does GPS require Internet connection?&quot;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS doesn't require internet. A GPS receiver (e.g. &lt;a href=&quot;http://www.modulestek.com/prodts/GPS/Mars740-mini/Mars740-mini_SPEC.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.modulestek.com/prodts/GPS/Mars740-mini/Mars740-mini_SPEC.pdf&lt;/a&gt;) is connected to the reading unit via USB or a RS232 interface. The protocol is very simple. However it only provides latitude and longitude. If you want to have an address, map data is required (for &lt;em&gt;this&lt;/em&gt; you would need internet - or a large memory). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course such a system requires good signals from the GPS satellites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&quot;What do I need?&quot;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you need a GPS receiver (see above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you need a microcontroller unit which runs your application and does all the control of the external units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, you need a GSM module (e.g. &lt;a href=&quot;http://www.exp-tech.de/Shields/Wireless/GSM-GPRS/adafruit-fona-mini-cellular-gsm-breakout-sma.html&quot; rel=&quot;nofollow&quot;&gt;http://www.exp-tech.de/Shields/Wireless/GSM-GPRS/adafruit-fona-mini-cellular-gsm-breakout-sma.html&lt;/a&gt;) to send a message.&#xA;Don't forget the antenna for connection to the mobile communication network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth, you need a power supply. Ideally it has a battery which can be reloaded when driving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you may see, if you put all this together you are far from the &quot;smallest thing possible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually any modern smartphone could be enough. Mount it &quot;invisible&quot; under your saddle, connect it to a bike charger, find the proper App and that's it - although it might not be the smallest solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know any, but I'm sure there &lt;em&gt;are&lt;/em&gt; products off the shelf that fulfil your requirements, designed and developed by experienced engineers, and thus smaller and maybe cheaper than what you ever could achieve on your own.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-09-07T20:37:43.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4092" PostTypeId="1" AcceptedAnswerId="4094" CreationDate="2014-09-07T18:51:05.160" Score="4" ViewCount="36040" Body="&lt;p&gt;I was playing around with my Arduino Uno R3 board with Sublime Text 2 &amp;amp; 'Stino' as IDE&lt;br&gt; &#xA;I am not sure if it is my code is the problem or if I broke something...&lt;br&gt;&#xA;I pressed upload while another sketch didn't finish uploading, even the original Arduino IDE can't upload new sketches anymore!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// singleServo.ino&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo;&#xA;const int button = 2;&#xA;const int led = 13;&#xA;const int buzzerPin = 10;&#xA;const int duration = 180;&#xA;&#xA;int stateLED = LOW;&#xA;int previous = LOW;&#xA;&#xA;void setup() {&#xA;    pinMode(led, OUTPUT);&#xA;    pinMode(button, INPUT);&#xA;    pinMode(buzzerPin, OUTPUT);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    int stateButton;&#xA;&#xA;    stateButton = digitalRead(button);&#xA;&#xA;    if (stateButton == LOW &amp;amp;&amp;amp; previous == LOW) {&#xA;        if (stateLED == HIGH) &#xA;        { &#xA;            stateLED = LOW; &#xA;            initAction(duration);&#xA;        }&#xA;        else &#xA;        { &#xA;            stateLED = HIGH;&#xA;        }&#xA;    }&#xA;&#xA;    digitalWrite(led, stateLED);&#xA;    previous = stateButton;&#xA;    servo.detach();&#xA;}&#xA;&#xA;void initAction(int time_iA){&#xA;    tone(buzzerPin, 523, 200);&#xA;    delay(200);&#xA;&#xA;    shiftServo(180, time_iA);&#xA;&#xA;    tone(buzzerPin, 262, 200);&#xA;}&#xA;&#xA;void shiftServo(int angle, int time_sS) {&#xA;    servo.attach(9);&#xA;    delay(500);&#xA;    int position;&#xA;&#xA;    for(position=0; position &amp;lt;= angle; position += 1)&#xA;    {&#xA;        servo.write(position);&#xA;        delay(time_sS / 180);&#xA;        Serial.println(servo.read());&#xA;    }&#xA;    // for(position=angle; position &amp;gt;= 0; position -= 1)&#xA;    // {&#xA;    //  servo.write(position);&#xA;    //  delay(time_sS / 90);&#xA;    // }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am a newbie with all things Arduino - Please help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;After rebooting the system (Ubuntu Linux 14.04) everything was working just fine again!&lt;br&gt;But I'm going to take the serial functions out too.&lt;/p&gt;&#xA;" OwnerUserId="3898" OwnerDisplayName="robertgz" LastEditorUserId="3898" LastEditDate="2014-09-08T08:45:55.993" LastActivityDate="2021-12-29T19:48:50.703" Title="Arduino Uno 3: Stuck at 'uploading...' sketches" Tags="|ide|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4093" PostTypeId="2" ParentId="3892" CreationDate="2014-09-08T00:31:23.630" Score="0" Body="&lt;p&gt;For prototyping, use male to female jumper wires to connect the Arduino Uno to the robot shield. It is a bit of a pain, but it makes it easy to free the conflicting pins for the wireless transceiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more permanent solution, look at Chris K's answer.&lt;/p&gt;&#xA;" OwnerUserId="3682" LastActivityDate="2014-09-08T00:31:23.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4094" PostTypeId="2" ParentId="4092" CreationDate="2014-09-08T00:52:52.907" Score="1" Body="&lt;p&gt;You have to wait for the first and all other uploads to fail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are not sure, a reboot is the most reliable solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that if your sketch sends a lot of data over serial, a manual reset of the board may be needed.&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="643" LastEditDate="2014-09-08T09:00:14.500" LastActivityDate="2014-09-08T09:00:14.500" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4095" PostTypeId="1" AcceptedAnswerId="4922" CreationDate="2014-09-08T03:10:08.710" Score="1" ViewCount="15076" Body="&lt;p&gt;I would like to control 16 motors with a servo shield, however, I have found scant to nothing sample code online. The one I was able to find is...strange to say the least&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/kachok/arduino-libraries/blob/master/Adafruit_PWMServoDriver/examples/servo/servo.pde&quot; rel=&quot;nofollow&quot;&gt;https://github.com/kachok/arduino-libraries/blob/master/Adafruit_PWMServoDriver/examples/servo/servo.pde&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_PWMServoDriver.h&amp;gt;&#xA;&#xA;// called this way, it uses the default address 0x40&#xA;Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();&#xA;&#xA;#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)&#xA;#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)&#xA;&#xA;uint8_t servonum = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;16 channel Servo test!&quot;);&#xA;&#xA;  pwm.begin();&#xA;&#xA;  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // Drive each servo one at a time&#xA;  Serial.println(servonum);&#xA;  for (uint16_t pulselen = SERVOMIN; pulselen &amp;lt; SERVOMAX; pulselen++) {&#xA;    pwm.setPWM(servonum, 0, pulselen);&#xA;  }&#xA;  delay(500);&#xA;  for (uint16_t pulselen = SERVOMAX; pulselen &amp;gt; SERVOMIN; pulselen--) {&#xA;    pwm.setPWM(servonum, 0, pulselen);&#xA;  }&#xA;  delay(500);&#xA;&#xA;  servonum ++;&#xA;  if (servonum &amp;gt; 15) servonum = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Im used to controlling motors using servo.write, but with the shield, it doesn't seem very intuitive as to how I should control the motors. How does Servomin and Servomax map to 0 degree and 180 degree?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone please elucidate!&lt;/p&gt;&#xA;" OwnerUserId="3786" LastActivityDate="2014-11-08T16:01:13.770" Title="Sample code for using adafruit servo shield?" Tags="|arduino-uno|servo|adafruit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4096" PostTypeId="2" ParentId="4095" CreationDate="2014-09-08T03:22:50.553" Score="1" Body="&lt;p&gt;Adafruit's guide for the shield is here:&#xA;&lt;a href=&quot;https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how much the library you linked and the official one differ. They seem to be used the same way, but you should probably stick with the official one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are going to have to use setPWM(pin, on, off) since the arduino is not generating the signals like it would with servo.write(), the arduino is sending commands to a chip on the shield that generates the signals for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit recommends calibrating SERVOMIN and SERVOMAX yourself with whatever brand of servo you plan on using, but those default values should be pretty close. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-09-08T03:22:50.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4098" PostTypeId="2" ParentId="4071" CreationDate="2014-09-08T07:18:48.100" Score="9" Body="&lt;p&gt;In addition to all the interesting answers, it worth mentioning that setting the serial speed to &lt;em&gt;XXX&lt;/em&gt; bits/s does not necessary imply &lt;em&gt;XXX&lt;/em&gt; bits/s on the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clocks -- even quartz based -- are imperfect and subject to drift. In addition, as the serial clock is usually generated through a power-of-two pre-divisor and (integer) counter, all value cannot be accurately obtained given a base clock frequency. With the help of the start/stop bits, asynchronous serial communication may be tolerant to some clock drift. But this has limits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if your ATmega328PA is running at 1MHz, you can achieve 9600b/s at 0.2% of error. But at 14400b/s the error is -3.5% (actually communicating at 13900b/s). And at 28800b/s, the error is +8.5% (actually communicating at 31200b/s). All those figures are from &lt;em&gt;ATmega48PA-88PA-168PA-328PA datasheet, p200&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is &lt;em&gt;not&lt;/em&gt; an issue when two identical devices communicate together (as there are in fact communicating at the &lt;em&gt;same&lt;/em&gt; speed). It &lt;em&gt;might&lt;/em&gt; be an issue when communicating between different devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Increasing the base frequency does not necessary improve significantly the accuracy. For example, running the same ATmega328PA as above at 2MHz does not really give better results as those are mostly due to rounding errors. But running it 1.8432MHz give very accurate bps from 2400b/s up to 57.6kHz.&lt;/p&gt;&#xA;" OwnerUserId="3607" LastEditorUserId="3607" LastEditDate="2014-09-08T07:30:01.003" LastActivityDate="2014-09-08T07:30:01.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4099" PostTypeId="1" AcceptedAnswerId="4298" CreationDate="2014-09-08T08:19:10.357" Score="5" ViewCount="2372" Body="&lt;p&gt;So recently my company threw away some rather large and reasonably old laser printers. One was a LaserJet 9050dn the other was a Epson printer/scanner combination. Being a little industrial I thought let me salvage them and brought them home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to salvage a couple of stepper motors. However I am having huge trouble is getting them to step properly. So lets get into the details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Components used:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1x Freetronics eleven (Arduino Uno compatbile) &lt;/li&gt;&#xA;&lt;li&gt;1X H-Bridge driver shield(Freetronics rated for 40V/2A max). &lt;/li&gt;&#xA;&lt;li&gt;1X Old scanner power supply which has a output of 24V/2A.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Currently there are two stepper motors I am interested in using. They have the following part numbers:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1X MITSUMI M42SP-4N &lt;/li&gt;&#xA;&lt;li&gt;1X Minebea-Matshushita 17PM-J212-G2ST&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Just to keep this short I am going to focus on the Minebea-Matshushita 17PM-J212-G2ST. I have been unable to find exact matches on these serial numbers when looking for datasheets but I have managed to find the following sheets on the net.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.eminebea.com/en/product/rotary/steppingmotor/hybrid/standard/data/17pm-k.pdf&quot; rel=&quot;nofollow&quot;&gt;Minebea-Matshushita 17PM-K&lt;/a&gt; datasheets found from Minebea. However I cant match the model exactly.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.theprojectasylum.com/electronicsprojects/componentdata/minebeasteppedatacirca1999.html&quot; rel=&quot;nofollow&quot;&gt;Minebea Stepper Motor Information &amp;amp; Specifications&lt;/a&gt; also carries some useful information.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So it appears that these are 24V steppers(in both cases). The Minebea-Matshushita 17PM-J212-G2ST appears to have a step angle of 1.8 degrees which should give me 200 steps per revolution. I have not been able to find the current needed to drive this motor but judging by the looks of things it will be between 0.8A and 1.2A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then used my multimeter to find the pairs of wires. It has 4 wires coming out (Bipolar motor I guess). The colours of the wires are red, yellow,orange and blue. First pair was red and yellow with red being positive/anode. Second pair orange blue with orange positive/anode side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wired my power supply into my h-bridge and started using the &lt;a href=&quot;http://www.freetronics.com/pages/hbridge-motor-driver-shield-quickstart-guide#.VA1jNfmvUrW&quot; rel=&quot;nofollow&quot;&gt;recipe and quickstart&lt;/a&gt; found at the freetonics site. This is where the frustration begins. When asking the motor to do one complete revolution(360 degrees) it does more than 360 degrees at times and other times it does less. I tied a cable tie to the motor so I can confirm it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried the one-step-at a time sketch to see if I can troubleshoot it. Here is what I have noticed. The steps are mostly correct one step at a time clockwise however every now and again it will jump counter clock wise and then clock wise again. I suppose you can call it a jitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly both these motor show the same behaviour pretty good step action just every 25 degrees or so a jitter. So I suspect that this might not be bi-polar motors but uni-polar? &lt;a href=&quot;http://josafatisai.blogspot.com.au/2013/04/wiring-mitsumi-stepper-m42sp-4np-with.html&quot; rel=&quot;nofollow&quot;&gt;This blog&lt;/a&gt; entry points me to believe that this might be the case. However the datasheet in this case points to a M42SP-7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question would be simple how do I figure out if they are bi-polar or uni-polar? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me with a proper datasheet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips would be really appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I can get both motors to step clock-wise and counter clock-wise I just cant get them to do a whole 360 degrees without a jitter. Based on the &lt;a href=&quot;http://josafatisai.blogspot.com.au/2013/04/wiring-mitsumi-stepper-m42sp-4np-with.html&quot; rel=&quot;nofollow&quot;&gt;Wiring Mitsumi stepper ( M42sp-4np) with arduino blog &lt;/a&gt; it appears that the Mitsumi is a uni-polar motor with a 2-2 phase excitation. What stumps me is that the wires are paired thus it must be bi-polar?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So last night I tried 2-2 phase excitation with the MITSUMI M42SP-4N and it appears to be solve the problem with this motor in particular. From early observations the motor now steps without jitter, however it was late so I will need to confirm this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was previously using 1-1 phase excitation i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Step number: 1a 1b 2a 2b&#xA;1            1  0  0  0  &#xA;2            0  0  1  0  &#xA;3            0  1  0  0  &#xA;4            0  0  0  1 &#xA;5            1  0  0  0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When using 2-2 phase excitation I get a more steady step however this needs to be confirmed a bit more:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Step number   1a 1b 2a 2b&#xA;1             1  0  0  1&#xA;2             1  0  1  0&#xA;3             0  1  1  0&#xA;4             0  1  0  1&#xA;5             1  0  0  1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just some added observations. The headache continues but I am learning a LOT about steppers motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not a 2-2 phase excitation these are definitely bi-polar. I am currently watching the Minebea-Matshushita 17PM-J212-G2ST do 360 degrees both clock and counter-clockwise. I hooked them up to a 12V/1A power supply both motors are running smoother and cooler and stepping relatively jitter free. I suspect the whole issue is a lack of a proper data-sheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will update as things progress and once solved add pictures and sketches so the next lucky sod wont loose as much hair as me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to Chris who made me look at the sketch in detail again. These motors seem to have a minimum rpm of sorts. I was trying to go for a really slow rpm under 5rpm at this speed these motors show the jitter effect. However when moving the speed to 10rpm and up no jitter.&lt;/p&gt;&#xA;" OwnerUserId="3897" LastEditorUserId="3897" LastEditDate="2014-09-10T11:45:33.307" LastActivityDate="2014-10-28T21:26:40.283" Title="Salvaged Stepper Motor Blues" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4100" PostTypeId="1" CreationDate="2014-09-08T08:42:11.410" Score="2" ViewCount="3869" Body="&lt;p&gt;I have found bunch of information about how to hack an RC car with a PCB; and how to control an Arduino from a receiver. Also how to run a servo from an Arduino, but I'm looking for a way to make an Arduino send signals to a 27&amp;nbsp;MHz 3 channel receiver, Using three potentiometers to decide servo location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any information about this somewhere? - I have an old transmitter lying around if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Links, pointers - anything is welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[It does not have to be 27&amp;nbsp;MHz AM, it is just what I have on the shelve, without investing in new gear]&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="6936" LastEditDate="2018-09-29T03:20:44.040" LastActivityDate="2018-09-29T03:23:02.657" Title="Is it possible to make an Arduino send signals to an RC receiver?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="4101" PostTypeId="2" ParentId="4100" CreationDate="2014-09-08T15:44:06.180" Score="2" Body="&lt;p&gt;The easiest way would be to open up the transmitter, desolder the potentiometer used for the stick and solder the cables to Arduino's PWM instead. Then use &lt;code&gt;analogWrite()&lt;/code&gt; to simulate stick position. If your TX would use that potentiometer with more than 5&amp;nbsp;V, you'll not able to use full ppm values. A RC or a RCL filter may be needed between PWM output and RC input to &quot;smooth&quot; the PWM into an analog signal. There are a lot of online calculator to find good &lt;em&gt;R, C and L&lt;/em&gt; to polish your signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This assuming your TX is using potentiometer like stick; if it is a really cheap one, it may be using &lt;em&gt;buttons&lt;/em&gt;. If this is the case, then you connect a transistor in parallel with the button, that way you can keep manual button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to program your Arduino to look for ppm signal (normally 50&amp;nbsp;Hz with high starting value with a period from 500 to 2000&amp;nbsp;µs) and then look for this signal into the Tx PCB; if found cut the trace of the generator and solder your cable from Arduino. I've seen around a lot of libraries outputting ppm (they are used on drones to mix single ppm channel back to PPM to use only one pin from logic board without having to hack standard RX&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="6936" LastEditDate="2018-09-29T03:18:47.767" LastActivityDate="2018-09-29T03:18:47.767" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="4102" PostTypeId="1" CreationDate="2014-09-08T18:21:36.027" Score="1" ViewCount="253" Body="&lt;p&gt;First things first, I have found some solutions to this problems but they all involved for printing to serial monitor. I am trying to take the information from the sensors and write them to an sd card. Here is my code so far: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//-----Writes Data to SD Card-----//&#xA;if(!Data) {&#xA;    u8g.firstPage();  &#xA;    do {&#xA;       drawFileError();&#xA;    } while( u8g.nextPage() );&#xA;    while (1);  // don't do anything more:&#xA;} &#xA;&#xA;dcounter++;&#xA;if (dcounter=1){&#xA;&#xA;    Data = SD.open(&quot;Data.txt&quot;, O_CREAT | O_APPEND | O_WRITE);&#xA;    Data.println(Header);&#xA;    Data.print(strutcDate + &quot;  &quot;);&#xA;    Data.print(strutcTime + &quot;  &quot;);&#xA;    Data.print(strgpsStatus + &quot;  &quot;);&#xA;    Data.print(strmodeIndicator + &quot;  &quot;);&#xA;    Data.print(strlatitude + &quot;  &quot;);&#xA;    Data.print(strlongitude + &quot;  &quot;);&#xA;    Data.print(strspeedOverGnd + &quot;  &quot;);&#xA;    Data.print(strcourseOverGnd + &quot;  &quot;);&#xA;    Data.print(t);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(f);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(h);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(hi);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(press_pKa);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.println(str);&#xA;    Data.close();&#xA;} else{&#xA;    Data.print(strutcDate + &quot;  &quot;);&#xA;    Data.print(strutcTime + &quot;  &quot;);&#xA;    Data.print(strgpsStatus + &quot;  &quot;);&#xA;    Data.print(strmodeIndicator + &quot;  &quot;);&#xA;    Data.print(strlatitude + &quot;  &quot;);&#xA;    Data.print(strlongitude + &quot;  &quot;);&#xA;    Data.print(strspeedOverGnd + &quot;  &quot;);&#xA;    Data.print(strcourseOverGnd + &quot;  &quot;);&#xA;    Data.print(t);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(f);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(h);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(hi);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.print(press_pKa);&#xA;    Data.print(&quot;  &quot;);&#xA;    Data.println(str);&#xA;    Data.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;two questions: is it possible for me to reduce this chunk of code into something smaller? is there a way to decrease print time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Ahh I see, the problem with my code is that the last few values are floats.Any way to shorten those as well, or do i need to do it individually? I do agree about the adding string parts.&lt;/p&gt;&#xA;" OwnerUserId="3910" LastEditorUserId="220" LastEditDate="2014-09-09T02:35:46.583" LastActivityDate="2014-09-09T02:35:46.583" Title="Optmizing print code when writing to file, and reducing print time" Tags="|arduino-mega|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4103" PostTypeId="2" ParentId="4100" CreationDate="2014-09-08T18:36:16.113" Score="1" Body="&lt;p&gt;Many RC TX have a remote connector where you can input the signal and not having to open them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, 27&amp;nbsp;MHz RC are a train of pulses, of variable width, from 2 to 20&amp;nbsp;ms each, one for each channel, flowed by a 20&amp;nbsp;ms pause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be recreated in a single output pin.&lt;/p&gt;&#xA;" OwnerUserId="3913" LastEditorUserId="6936" LastEditDate="2018-09-29T03:23:02.657" LastActivityDate="2018-09-29T03:23:02.657" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4104" PostTypeId="2" ParentId="4102" CreationDate="2014-09-08T20:22:11.857" Score="-1" Body="&lt;p&gt;Maybe this helps with speed. It will however use more memory, so use with caution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Data.println(Header);&#xA;Data.println(strutcDate + &quot; &quot; + strutcTime + &quot;  &quot; + strgpsStatus + &quot;  &quot; + strmodeIndicator + &quot;  &quot; + strlatitude + &quot;  &quot; + strlongitude + &quot;  &quot; + strspeedOverGnd + &quot;  &quot; + strcourseOverGnd + &quot;  &quot; + t + &quot;  &quot; + f + &quot;  &quot; + h + &quot;  &quot; + hi + &quot;  &quot; + press_pKa + &quot;  &quot; + str);&#xA;Data.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-08T20:22:11.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4105" PostTypeId="1" CreationDate="2014-09-08T22:11:53.653" Score="2" ViewCount="5590" Body="&lt;p&gt;I am trying to read/send CanBus messages using a Arduino Due. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of now I have used &lt;a href=&quot;https://github.com/collin80/due_can&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/collin80/due_can&lt;/a&gt; library to setup my Can Bus interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Vector Software CanAylzer to see what CAN message are being received. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is where I have my issue.&#xA;Although the CanAylzer software is being able to detect Can Messages on the line it gives be a Bit error on bit position 119. All the fields of relevance for me ID,Data etc seem to be reported fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a snapshot of the CanAylzer Error Frame. Below is my Arduino code . Any help would be awesome. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/LMLWi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the ino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Arduino Due - CAN Sample 1&#xA;// Brief CAN example for Arduino Due&#xA;// Test the transmission from CAN0 Mailbox 0 to CAN1 Mailbox 0&#xA;&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;variant.h&quot;&#xA;#include &quot;due_can.h&quot;&#xA;&#xA;#define TEST1_CAN_TRANSFER_ID    0x18FF0017 //random 29 bits&#xA;#define TEST1_CAN0_TX_PRIO       1&#xA;#define CAN_MSG_DUMMY_DATA       0xABC&#xA;&#xA;// CAN frame max data length&#xA;#define MAX_CAN_FRAME_DATA_LEN   8&#xA;&#xA;// Message variable to be send&#xA;uint32_t CAN_MSG_1 = 0;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;   // start serial port at 115200 bps:&#xA;&#xA;   Serial.begin(115200);&#xA;   Serial.println(&quot;Program Started&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;   CAN_FRAME frame1, frame2;&#xA;   // say what you got:&#xA;   Serial.print(&quot;Sent Value: &quot;);&#xA;   Serial.println(CAN_MSG_1, DEC);&#xA;&#xA;   // Initialize CAN0 and CAN1, baudrate is 250kb/s&#xA;   CAN.init(CAN_BPS_250K);&#xA;   CAN2.init(CAN_BPS_250K);&#xA;&#xA;   //Initialize the definitions for the frames we'll be sending.&#xA;   //This can be done here because the frame never changes&#xA;   frame1.id = TEST1_CAN_TRANSFER_ID;&#xA;   frame1.length = MAX_CAN_FRAME_DATA_LEN;&#xA;   //Priority&#xA;   frame1.priority = 0;&#xA;   frame1.rtr = 1;&#xA;   //Below we set the 8 data bytes in 32 bit (4 byte) chunks&#xA;   //Bytes can be set individually with frame1.data.bytes[which] = something&#xA;   frame1.data.low = 0xAFAFAFAF;&#xA;   frame1.data.high = CAN_MSG_DUMMY_DATA;&#xA;   //We are using extended frames so mark that here. Otherwise it will just use&#xA;   //the first 11 bits of the ID set&#xA;   frame1.extended = 1;&#xA;&#xA;   CAN.sendFrame(frame1);&#xA;   while (1) {&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Update&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Ok so here are the printed(via serial port) values of various registers. I don't think it is a problem with the values in the registers. I have cross referenced these with the SAM3X/A (on the due) Micro-controller manual (chapter 41, pertaining to the CAN). The only one I am fishy about is the baudrate one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial Port Initialized&#xA;******START OF LOOP ******&#xA;No of Sent frames: 1&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_SR:( Status Register)&#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 11 | 10 | 9 | 8&#xA;      0 | 0  | 0 | 0&#xA;&#xA;Bits 15 | 14 | 13 | 12&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 19 | 18 | 17 | 16&#xA;     0  | 1  | 1  | 0&#xA;&#xA;Bits 23 | 22 | 21 | 20&#xA;     1  | 0  | 1  | 0&#xA;&#xA;Bits 27 | 26 | 25 | 24&#xA;     0  | 1  | 0  | 0&#xA;&#xA;Bits 31 | 30 | 29 | 28&#xA;     0  | 1  | 0  | 0&#xA;&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;#####END OF LOOP ######&#xA;&#xA;&#xA;Serial Port Initialized&#xA;******START OF LOOP ******&#xA;No of Sent frames: 1&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_MR: (Mode Register)&#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 0 | 0 | 1&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 26 | 25 | 24&#xA;     0  | 0  | 0&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;#####END OF LOOP ######&#xA;&#xA;******START OF LOOP ******&#xA;No of Sent frames: 4&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_MID7: (Message ID Register Mailbox 7)&#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 1 | 1 | 1&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 1&#xA;&#xA;Bits 11 | 10 | 9 | 8&#xA;     0  | 0  | 0 | 0&#xA;&#xA;Bits 15 | 14 | 13 | 12&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 19 | 18 | 17 | 16&#xA;     1  | 1  | 1  | 1&#xA;&#xA;Bits 23 | 22 | 21 | 20&#xA;     1  | 1  | 1  | 1&#xA;&#xA;Bits 27 | 26 | 25 | 24&#xA;     1  | 0  | 0  | 0&#xA;&#xA;Bits 31 | 30 | 29 | 28&#xA;     0  | 0  | 1  | 1&#xA;&#xA;&#xA;Serial Port Initialized&#xA;******START OF LOOP ******&#xA;No of Sent frames: 1&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_ECR: (Error Count Register)&#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 11 | 10 | 9 | 8&#xA;     0  | 0  | 0 | 0&#xA;&#xA;Bits 15 | 14 | 13 | 12&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 19 | 18 | 17 | 16&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 23 | 22 | 21 | 20&#xA;     1  | 0  | 0  | 0&#xA;&#xA;Bits 27 | 26 | 25 | 24&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 31 | 30 | 29 | 28&#xA;     0  | 0  | 0  | 0&#xA;&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;#####END OF LOOP ######&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lastly and most importantly in my opinion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial Port Initialized&#xA;******START OF LOOP ******&#xA;No of Sent frames: 1&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_MSR7: (CAN Message Status Register Mailbox 7) &#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 0&#xA;&#xA;Bits 11 | 10 | 9 | 8&#xA;      0 | 0  | 0 | 0&#xA;&#xA;Bits 15 | 14 | 13 | 12&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 19 | 18 | 17 | 16&#xA;     1  | 0  | 0  | 0&#xA;&#xA;Bits 23 | 22 | 21 | 20&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 27 | 26 | 25 | 24&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 31 | 30 | 29 | 28&#xA;     0  | 0  | 0  | 0&#xA;&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;#####END OF LOOP ######&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the Baud rate register&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;******START OF LOOP ******&#xA;No of Sent frames: 1&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;CAN_BR: &#xA;Bits 3 | 2 | 1 | 0&#xA;     0 | 0 | 0 | 1&#xA;&#xA;Bits 7 | 6 | 5 | 4&#xA;     0 | 0 | 0 | 1&#xA;&#xA;Bits 11 | 10 | 9 | 8&#xA;     0 |  0  | 1 |  0&#xA;&#xA;Bits 15 | 14 | 13 | 12&#xA;     0  | 0  | 1  | 0&#xA;&#xA;Bits 19 | 18 | 17 | 16&#xA;     1  | 0  | 0  | 1&#xA;&#xA;Bits 23 | 22 | 21 | 20&#xA;     0  | 0  | 1  | 0&#xA;&#xA;Bits 27 | 26 | 25 | 24&#xA;     0  | 0  | 0  | 0&#xA;&#xA;Bits 28&#xA;     0&#xA;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&amp;lt;&amp;gt;&#xA;#####END OF LOOP ######&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find what all the register bits details on Atmel's website or leave some way for me to email the documentation to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any Help would be much appreciated! &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update 2:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have attached 2 different Oscilloscope readings and deconstructed the entire binary representation of the Can message manually. Furthermore I calculated the associated CRC's of the two different messages, and then compared them to the ones the hardware created and found them(hardware ones) to be incorrect. I have provided a link to &lt;a href=&quot;https://drive.google.com/folderview?id=0BwRY4KO_k7sUdmN5RWJVZnFHSVE&amp;amp;usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google Drive&lt;/a&gt; where the results from the Oscilloscope can be found. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: the messages I used had in one 7 A's(hex, i.e 28bits) for the ID and 16 A's for the Data field.&#xA;The second one had 7 C's for the Id and 16 C's for the Data field.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both are 2.0B can extended frames.&lt;img src=&quot;https://i.stack.imgur.com/eFw36.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hEVhK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3914" LastEditorUserId="3914" LastEditDate="2014-10-15T17:58:15.630" LastActivityDate="2018-05-29T17:42:14.820" Title="Aduino Due Can messages" Tags="|programming|arduino-due|" AnswerCount="0" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="4106" PostTypeId="2" ParentId="4102" CreationDate="2014-09-08T22:49:53.953" Score="0" Body="&lt;p&gt;I would analize what I want to write, extrapolate all numeric value, then create a structure that hold numeric value. So at every write I would write the structure (it is a binary write, so use fixed byte size) followed by all others string(or even place string in different file, but may turn out harder to manipulate or fix in case of problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to read it you'll need to read back the structure, followed by eventual know number of string. If string may be of unknown number,, just put the number of following string into the struct. Outside string, as you can see, you need no special char to signal the end of chunk of data :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unrelated: please, remove all println in the if rather than the header as they are equal to the else; then remove the else statement (but not the else body!) That way the if will open file and add header, and then the code will always add the rest of code. It would be a shame if you edit your else branch and forgot the if, or viceversa. Code style matters, trust me&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-09-08T22:49:53.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4107" PostTypeId="1" CreationDate="2014-09-08T22:51:55.057" Score="4" ViewCount="4416" Body="&lt;p&gt;I've researched how to attach multiple buttons to a single analog input using a resistor network. Instructables has a good lesson on this: &lt;a href=&quot;http://www.instructables.com/id/How-to-access-5-buttons-through-1-Arduino-input/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-to-access-5-buttons-through-1-Arduino-input/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My requirement is that I need to attach an interrupt to buttons (ie the analog input) before reading the analog value, so that all the buttons can act as a trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works for voltages in the higher range, but not in the lower range (the trigger input waits for a RISING edge). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can any one suggest a circuit that steps a &gt;0V+ to +5V input to a +5V output so that any button push would trigger the input?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, does anyone have other suggestions on how to use triggers for each button?&lt;/p&gt;&#xA;" OwnerUserId="3225" LastActivityDate="2015-06-22T19:34:15.707" Title="Multiple Buttons on Single Analog Pin and Trigger Pin Arduino Uno" Tags="|pins|interrupt|voltage-level|button|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4108" PostTypeId="2" ParentId="4102" CreationDate="2014-09-08T23:11:14.467" Score="2" Body="&lt;p&gt;First of all, the only difference between the two parts of the &quot;if&quot; statement is that, the first time, it prints the header. Instead of that code, you could do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//(Include the top part of the code here...)    &#xA;dcounter++;&#xA;if (dcounter=1){&#xA;    Data = SD.open(&quot;Data.txt&quot;, O_CREAT | O_APPEND | O_WRITE);&#xA;    Data.println(Header);&#xA;}&#xA;Data.print(strutcDate + &quot;  &quot;);&#xA;Data.print(strutcTime + &quot;  &quot;);&#xA;Data.print(strgpsStatus + &quot;  &quot;);&#xA;Data.print(strmodeIndicator + &quot;  &quot;);&#xA;Data.print(strlatitude + &quot;  &quot;);&#xA;Data.print(strlongitude + &quot;  &quot;);&#xA;Data.print(strspeedOverGnd + &quot;  &quot;);&#xA;Data.print(strcourseOverGnd + &quot;  &quot;);&#xA;Data.print(t);&#xA;Data.print(&quot;  &quot;);&#xA;Data.print(f);&#xA;Data.print(&quot;  &quot;);&#xA;Data.print(h);&#xA;Data.print(&quot;  &quot;);&#xA;Data.print(hi);&#xA;Data.print(&quot;  &quot;);&#xA;Data.print(press_pKa);&#xA;Data.print(&quot;  &quot;);&#xA;Data.println(str);&#xA;Data.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like already mentioned, you can append strings with the &lt;code&gt;+&lt;/code&gt; operator. This would be the final code then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//(Include the top part of the code here...)&#xA;dcounter++;&#xA;if (dcounter=1){&#xA;    Data = SD.open(&quot;Data.txt&quot;, O_CREAT | O_APPEND | O_WRITE);&#xA;    Data.println(Header);&#xA;}&#xA;Data.println(strutcDate + &quot; &quot; + strutcTime + &quot;  &quot; + strgpsStatus + &quot;  &quot; + strmodeIndicator + &quot;  &quot; + strlatitude + &quot;  &quot; + strlongitude + &quot;  &quot; + strspeedOverGnd + &quot;  &quot; + strcourseOverGnd + &quot;  &quot; + t + &quot;  &quot; + f + &quot;  &quot; + h + &quot;  &quot; + hi + &quot;  &quot; + press_pKa + &quot;  &quot; + str);&#xA;Data.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;FYI, it doesn't seem like you should close the stream every iteration at the end since you only open it the first time.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-09-08T23:11:14.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4109" PostTypeId="2" ParentId="4107" CreationDate="2014-09-08T23:54:11.703" Score="6" Body="&lt;p&gt;Use the analog comparator in the ATmega328P to trigger an interrupt once the input voltage rises enough to indicate a button press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the analog network to both the analog input and D6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your lowest analog voltage is not greater than 1.2V then apply a voltage greater than 0V but more than 40mV less than your lowest analog voltage to D7. If you have &lt;em&gt;not&lt;/em&gt; connected the voltage then configure the comparator to use the internal bandgap reference (&lt;code&gt;ACSR |= _BV(ACBG)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enable the comparator interrupt and capture on a rising edge (&lt;code&gt;ACSR |= _BV(ACIE) | _BV(ACIS1) | _BV(ACIS0)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disable the digital input on D6 (AIN0), and on D7 (AIN1) if connected to a voltage reference (&lt;code&gt;DIDR1 |= _BV(AIN0D)&lt;/code&gt;, &lt;code&gt;DIDR1 |= _BV(AIN1D)&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&quot;&gt;Write an ISR&lt;/a&gt; that does what you want on comparator trigger (&lt;code&gt;ISR(ANALOG_COMP_vect) { ... }&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now go back and read all that &lt;strong&gt;&lt;em&gt;three more times&lt;/em&gt;&lt;/strong&gt; until you understand it. As always, see the ATmega328P datasheet for details.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-08T23:54:11.703" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4110" PostTypeId="1" CreationDate="2014-09-09T01:41:59.830" Score="3" ViewCount="6952" Body="&lt;p&gt;Ok, serialEvent &quot;runs after loop()&quot; and it is not an interrupt.&#xA;AS far as I know main() has two functions  - setup and &quot;infinite&quot; loop.&#xA;So where does serialEvent comes in? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if I do not want loop()  to run and use only setup than  I cannot use serialEvent. &lt;/p&gt;&#xA;" OwnerUserId="3916" LastActivityDate="2014-09-09T02:44:05.483" Title="How does serialEvent gets into main()?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4111" PostTypeId="2" ParentId="4110" CreationDate="2014-09-09T01:48:04.683" Score="7" Body="&lt;p&gt;Yes you are correct, the event handlers will not do anything in setup. Main runs &quot;setup()&quot;, then loops infinity through &quot;loop()&quot;, but gives the serial event handlers a chance to run in between. The actual main that runs on the arduino is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(void)&#xA;{&#xA;    init();&#xA;&#xA;    initVariant();&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this is found (on linux at least) in arduino/hardware/arduino/avr/cores/arduino/main.cpp&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;serialEventRun()&quot; is in HardwareSerial.cpp, but is not very interesting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, Serial itself will still work fine in setup(). If you want to use the same event handler function, all you have to do is call &quot;serialEventRun()&quot; yourself periodically. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-09T02:44:05.483" LastActivityDate="2014-09-09T02:44:05.483" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4113" PostTypeId="1" CreationDate="2014-09-09T06:15:46.817" Score="-2" ViewCount="7942" Body="&lt;p&gt;I have two problems in the code below. This ACS712 sensor is too noisy so I am not getting the count value properly, since I need approximate reading I consider curve is linear, and calculate the slope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problems are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I take a 10 sample average, the first value it reads properly, i.e. 512 is count value, other value taking as 0. I don't why. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once current exceeds 1A, my relay output should go low. Once it goes low it waits for 30s &amp;amp; again it must high the relay high. Since I am checking output in loop, it making high &amp;amp; low without waiting for 30s. Can someone help me how can I do this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you used without MStimer, the &lt;code&gt;newaverage&lt;/code&gt; values print 512 which is my reference, but for other 9 values print &lt;code&gt;newaverage&lt;/code&gt; as zero.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MsTimer2.h&amp;gt;&#xA;&#xA;#define RELAY1  3&#xA;#define RELAY2  4&#xA;&#xA;int num_readings=10;&#xA;//int total;&#xA;int readings[10];&#xA;int index;&#xA;float CS_Value;&#xA;static float Output_Current;&#xA;float mad;&#xA;float madstd;&#xA;float lowlimit ;&#xA;float highlimit;&#xA;int count;&#xA;int total;  &#xA;int reading;  &#xA;static int newaverage;&#xA;unsigned long Wait_Time=30000;&#xA;unsigned long Current_Time;&#xA;static int Tripped_Flag=0;&#xA;&#xA;&#xA;float standard_deviation(int avg1) {&#xA;  total = 0;&#xA;  for( int i=0; i&amp;lt;num_readings; i++)&#xA;    total = total + pow((avg1 -readings[i]), 2);&#xA;  return sqrt(total/num_readings);&#xA;}&#xA;&#xA;int  average() &#xA;{&#xA;  total = 0;&#xA;  for( int i=0; i&amp;lt;num_readings; i++)&#xA;  {&#xA;    total = total + readings[i];&#xA;  }&#xA;  return total/num_readings;&#xA;}&#xA;&#xA;void TakeReading()&#xA;{&#xA;&#xA;  reading = analogRead(A0);&#xA;  readings[index] = reading;&#xA;  index = index + 1; &#xA;&#xA;  if (index &amp;gt;= num_readings)&#xA;  {&#xA;    index=0;&#xA;    int avg = average();&#xA;    float std = standard_deviation(avg);&#xA;    madstd = mad * std;&#xA;    lowlimit = avg - madstd;&#xA;    highlimit = avg + madstd;&#xA;&#xA;&#xA;    total=0;&#xA;    count=0;&#xA;    for(int i=0; i&amp;lt;num_readings; i++) {&#xA;      // Check if the values of the readings are within the limits.&#xA;      if(readings[i] &amp;gt;= lowlimit &amp;amp;&amp;amp; readings[i] &amp;lt;= highlimit) {&#xA;        total = total + readings[i];&#xA;        count = count + 1;&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    // compute the new average&#xA;    newaverage = total/count;&#xA;    // send it to the serial port (as ASCII digits)&#xA;&#xA;    Serial.print(&quot;Newaverage:&quot;);&#xA;    Serial.println(newaverage, DEC);&#xA;    Output_Current = 0.0336666666667*newaverage - 17.17; &#xA;    //return(Output_Current);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;  // sets the serial port to 9600&#xA;  Serial.begin(9600);&#xA;  pinMode(RELAY1, OUTPUT);&#xA;  pinMode(RELAY2, OUTPUT);&#xA;  Relay_Intialize();&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  MsTimer2::set(50, TakeReading); // 500ms period&#xA;  MsTimer2::start();&#xA;  //  CS_Value=  TakeReading();&#xA;  Serial.print(&quot;current is :&quot;);&#xA;  Serial.println(Output_Current);&#xA;  //if (CS_Value&amp;gt;0.95 &amp;amp;&amp;amp; Tripped_Flag==0)&#xA;  if (Output_Current&amp;gt;0.95 &amp;amp;&amp;amp; Tripped_Flag==0)&#xA;  {&#xA;    Serial.println(&quot;Main Activate&quot;);&#xA;    Serial.print(&quot;Tripped_Flag_status:&quot;);&#xA;    Serial.println(Tripped_Flag);&#xA;    Relay_Activate();&#xA;&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;&#xA;    Serial.println(&quot;Main Deactivate&quot;);&#xA;    Serial.print(&quot;Tripped_Flag_status:&quot;);&#xA;    Serial.println(Tripped_Flag);&#xA;    Relay_Deactivate();&#xA;  }&#xA;  Serial.println(&quot;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,&quot;);&#xA;  delay(1000);&#xA;&#xA;}&#xA;&#xA;&#xA;void Relay_Activate()&#xA;{&#xA;  for (unsigned long start = millis(); millis() - start &amp;lt; 10000;)&#xA;  {&#xA;    digitalWrite(RELAY1,LOW);&#xA;    digitalWrite(RELAY2,LOW);&#xA;    Serial.println(&quot;RELAY GOT TRIPPED&quot;);&#xA;    Tripped_Flag=1;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void  Relay_Deactivate()&#xA;{&#xA;  digitalWrite(RELAY1,HIGH);&#xA;  digitalWrite(RELAY2,HIGH);&#xA;  Serial.println(&quot;RELAY NOT TRIPPED&quot;);&#xA;  Tripped_Flag=0;&#xA;&#xA;}&#xA;&#xA;void Relay_Intialize()&#xA;{&#xA;  Serial.println(&quot;RELAY GOT INTIALISE....&quot;);&#xA;  digitalWrite(RELAY1,HIGH);&#xA;  digitalWrite(RELAY2,HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Is2C7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Is2C7.jpg&quot; alt=&quot;Data output when load connected with MS library&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:28.597" LastActivityDate="2015-08-07T12:17:28.597" Title="Sample average of analog of current sensor" Tags="|arduino-uno|programming|sensors|c|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4114" PostTypeId="1" AcceptedAnswerId="4118" CreationDate="2014-09-09T06:31:51.920" Score="5" ViewCount="2174" Body="&lt;p&gt;I'm building a line follower with arduino, here some part that I'm going to use&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino Uno&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Motor Shield 2A &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=69&quot; rel=&quot;noreferrer&quot;&gt;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=69&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;LCD Keypad&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 Channel Line Tracking Sensor &lt;a href=&quot;http://www.aliexpress.com/item/4Channel-Infraed-Line-Tracking-Sensor-Module-w-Connector-Line/2021343637.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.aliexpress.com/item/4Channel-Infraed-Line-Tracking-Sensor-Module-w-Connector-Line/2021343637.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm using LiPo Batteries 3 Cell 11.1v for power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new in here so I didn't know how to stack that shield, if I recall I can stack up Arduino and the LCD Keypad, and Arduino and the Motor Shield, but didnt know how to stack those 2 together and adding another sensor like that line tracking sensor. May I know how to resolve that? thanks.&lt;/p&gt;&#xA;" OwnerUserId="3920" LastActivityDate="2016-03-27T17:47:50.400" Title="Stacking Arduino Shield (Motor Shield, LCD Keypad, LED Sensor)" Tags="|sensors|lcd|arduino-motor-shield|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4115" PostTypeId="2" ParentId="4113" CreationDate="2014-09-09T08:51:49.697" Score="2" Body="&lt;p&gt;I didn't have a look at your item 2, but regarding item 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please consider that in function &lt;code&gt;TakeReading()&lt;/code&gt;, if the condition is never true, count is 0 when you come to &lt;code&gt;newaverage = total/count;&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what the Arduino does in case 0/0, but -1 may be a proper return value.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastEditorUserId="6936" LastEditDate="2015-08-07T08:09:51.100" LastActivityDate="2015-08-07T08:09:51.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4116" PostTypeId="1" CreationDate="2014-09-09T14:14:39.203" Score="1" ViewCount="2565" Body="&lt;p&gt;I'm having problems with using Arduino Leonardo PWM outputs (I'm actually using YUN board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need 4 PWM outputs that generally have the same base frequency of around 10 to 20 Hz or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using timer 1 (A-pin-9,B-pin-10,C-pin-11) and timer 4 (A-pin-13)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get pins 9,10,and 13 PWM output working decent, but for some reason pin 11 PWM frequency is much much higher. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 9,10,11 should be working off TIMER 1 which all use the same pre-scaler, so I dont know how 9 and 10 can have one frequency, and 11 have a different frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code can anybody see anything wrong? thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define PWM_4A_PIN  13 &#xA;    #define PWM_1C_PIN  11&#xA;&#xA;    #define PWM_1B_PIN  10 &#xA;    #define PWM_1A_PIN  9 &#xA;&#xA;    void setup() {&#xA;     TCCR1B = TCCR1B &amp;amp; 0b11111000 | 0x05;&#xA;     TCCR4B = TCCR1B &amp;amp; 0b11110000 | 0x09;&#xA;     analogWrite(PWM_4A_PIN,128);&#xA;     analogWrite(PWM_1C_PIN,128);&#xA;     analogWrite(PWM_1B_PIN,128);&#xA;     analogWrite(PWM_1A_PIN,128);&#xA;    }&#xA;&#xA;    void loop() &#xA;    {&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3923" LastActivityDate="2014-09-09T15:31:25.877" Title="Confusing Arduino Leonardo PWM" Tags="|arduino-yun|arduino-leonardo|pwm|atmega32u4|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4117" PostTypeId="2" ParentId="4116" CreationDate="2014-09-09T14:26:38.043" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Pins 9,10,11 should be working off TIMER 1 which all use the same pre-scaler, so I dont know how 9 and 10 can have one frequency, and 11 have a different frequency.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unless D11 is configured as OC0A instead of OC1C, which means that it will work off timer 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0A &amp;amp;= ~(_BV(COM0A1) | _BV(COM0A0));&#xA;TCCR1A |= _BV(COM1C1) | _BV(COM1C0);&#xA; ...&#xA;OCR1C = ...;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-09-09T15:31:25.877" LastActivityDate="2014-09-09T15:31:25.877" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4118" PostTypeId="2" ParentId="4114" CreationDate="2014-09-09T15:03:41.890" Score="3" Body="&lt;p&gt;The Motor Shield 2A plugs in on top of the Arduino Uno, and the LCD Keypad plugs in on top of the motor shield. [But see &lt;em&gt;Edit 1&lt;/em&gt; below]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is better information about the  4 Channel Line Tracking Sensor at &lt;a href=&quot;http://www.uctronics.com/channel-tracking-sensor-module-line-hunting-sensor-p-1463.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;uctronics.com&lt;/a&gt; where you can see that its main board (with the LM339 chip) connects to the Arduino via six lines: Vcc, Gnd, Out1, Out2, Out3, Out4.  That main sensor board does not mount on the stack, but instead can be located whereever is convenient and leaves its four comparator-level pots accessible for adjustment.&#xA;Mount the four small boards for the tracking module as convenient and necessary for line following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For connecting the six lines from the sensor main board to the Uno, you probably will need to solder two headers (rows of pins) to a board in the stack.  Using right-angle headers (see below) will allow the pins to come out of the side of the stack without interfering with other layers of the stack.  One of the headers should let you connect sensor Out1...Out4 digital outputs to four otherwise unused analog or digital pins, and the other header should let you connect Vcc and Gnd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SEASS.jpg&quot; alt=&quot;6-pin angle header, 0.1&amp;quot; spacing&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit 1:&lt;/em&gt;&lt;/strong&gt; In the &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;LCD shield page&lt;/a&gt;, section 2 (Diagram) shows Vcc, Gnd, and D0-D3 available at the top right corner (the angled corner).  Those six pins probably are a reasonable place to add a six-pin angled header for the sensor board.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the LCD KeyPad Shield is a &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;DFRobot.com&lt;/a&gt; model, the &lt;a href=&quot;http://www.shieldlist.org/dfrobot/lcd&quot; rel=&quot;nofollow noreferrer&quot;&gt;summary pinout&lt;/a&gt; at shieldlist.org shows that its use of D4,5,6,7 will conflict with use of &lt;a href=&quot;http://www.shieldlist.org/dfrobot/2a-motor&quot; rel=&quot;nofollow noreferrer&quot;&gt;those same lines&lt;/a&gt; by the DFRobot 2A Motor Shield.  There are several ways to handle a conflict like this:  &lt;strong&gt;1,&lt;/strong&gt; use two Uno's, one per shield; &lt;strong&gt;2,&lt;/strong&gt; make one shield or the other use different lines; &lt;strong&gt;3,&lt;/strong&gt; share the lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 2&lt;/strong&gt; could work as follows:  Stack the LCD shield directly on the Uno (or any other compatible Arduino).  Besides a header for the sensor board, add a header for a cable to the motor board, and drive the motor board's D4-7 inputs with some other lines from the Uno, eg A4-7.  [Alternately  one could remove the D4-7 pins on the LCD shield and jumper from A4-7 to the D4-7 lines on the LCD shield.  This would leave the boards in a single stack but would make some serious changes to the LCD board.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 3&lt;/strong&gt; would work as follows:  The LCD shield only pays attention to D4-7 (which from the &lt;a href=&quot;http://www.dfrobot.com/wiki/images/a/a7/LCDKeypad_Shield_SCH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;DFRobot schematic&lt;/a&gt; drive DB4-DB7 on an LCD TC1602 chip) when the TC1602's E line is strobed.  See pages 7 and 8 of Adafruit.com's &lt;a href=&quot;https://www.adafruit.com/datasheets/TC1602A-01T.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;copy of TC1602 specs&lt;/a&gt;, where timing diagrams show about half-microsecond times for writing to or reading from the TC1602.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to run tests with your motors and see if they work ok in spite of the four inputs to the motor shield being random during the occasional half-microseconds that data is being written to the LCD.  You might have to add more diodes or capacitors to  suppress electrical noise due to rapid switching.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=69&quot; rel=&quot;nofollow noreferrer&quot;&gt;DFRobot's motor shield page&lt;/a&gt; has links to that board's schematic and to its L298 chip data sheet.  Page 7 of the datasheet says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An external bridge of diodes are required when inductive loads are driven and when the inputs of the IC are chopped; Shottky diodes would be preferred.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The motor shield schematic shows diodes; although not drawn using &lt;a href=&quot;http://en.wikipedia.org/wiki/Schottky_diode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Schottky diode&lt;/a&gt; symbols they might be Schottky anyway (which would give better noise suppression, less heating, etc).  The schematic also shows that JP1, a 16-pin dual row header, has jumpers that control ENA and ENB on the L298.  In a &quot;proper solution&quot; for sharing D4-7 between the LCD and motor shields, you'd drive ENA and ENB low when using D4-7 for LCD i/o, which would allow the attached motors to briefly free run, as opposed to being suddenly commanded to stop or reverse.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2014-09-11T15:05:00.420" LastActivityDate="2014-09-11T15:05:00.420" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4119" PostTypeId="1" CreationDate="2014-09-09T17:42:23.627" Score="8" ViewCount="2401" Body="&lt;p&gt;Not a pure Arduino question really. I'm actually using a standalone ATmega168. So far I've been using AVR-ISP programmer (working from AVR Studio) to program the chip. After everything is done, the chip will be covered and I will only have access to the I2C pins. The MISO,MOSI, etc pins will be unreachable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just wondering if there was a way to use the I2C pins to update the program that is burned on the chip. I won't need to burn the bootloader again, but just to update the program if it needs to be.&lt;/p&gt;&#xA;" OwnerUserId="3925" LastActivityDate="2018-02-11T08:00:56.210" Title="Burning sketch with I2C" Tags="|arduino-uno|i2c|atmega328|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4120" PostTypeId="2" ParentId="4119" CreationDate="2014-09-09T19:07:07.727" Score="3" Body="&lt;p&gt;You need to write a I2C bootloader to the AVR. There seems to be a &lt;a href=&quot;https://code.google.com/p/raspy-juice/wiki/Bootloader&quot; rel=&quot;nofollow&quot;&gt;project that has already created such a bootloader&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Atmel has provided a &lt;a href=&quot;http://www.atmel.com/ru/ru/Images/doc8435.pdf&quot; rel=&quot;nofollow&quot;&gt;TWI/I2C bootloader&lt;/a&gt; for their XMega processors (not the ATmega168).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next problem is uploading the code via I2C. You'd need some hardware to convert USB  to I2C. And some software to talk to this hardware. The last part is probably supported by AVR studio, as Atmel has provided an I2C bootloader. Though I'm not sure both of the above bootloaders are using a compatible protocol over the I2C.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-09-09T19:12:32.533" LastActivityDate="2014-09-09T19:12:32.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4121" PostTypeId="1" AcceptedAnswerId="4122" CreationDate="2014-09-09T17:05:53.097" Score="0" ViewCount="343" Body="&lt;p&gt;I need a way to rewrite the switch case part in a more efficient way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int y , x ;&#xA;byte dataArray[6];&#xA;&#xA;void setup () {&#xA;   pinMode(8,OUTPUT);  &#xA;   pinMode(11,OUTPUT);&#xA;   pinMode(12,OUTPUT);&#xA;&#xA;   Serial.begin(9600);&#xA;   dataArray[0] = 0x3 ; //00000011&#xA;   dataArray[1] = 0x5 ; //00000101&#xA;   dataArray[2] = 0x9 ; //00001001&#xA;   dataArray[3] = 0x11; //00010001&#xA;   dataArray[4] = 0x21; //00100001&#xA;   dataArray[5] = 0x41; //01000001&#xA;}&#xA;&#xA;void loop () {&#xA;   while (Serial.available()&amp;gt;0) {&#xA;     y = Serial.read();&#xA;     x = Serial.read();&#xA;     switch ( x ) {&#xA;     case 1:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW);&#xA;     break;&#xA;&#xA;     case 2:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW); &#xA;     break;&#xA;&#xA;     case 3:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW); &#xA;     break;&#xA;&#xA;      case 4:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW); &#xA;     break;&#xA;&#xA;      case 5:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW); &#xA;     break;&#xA;&#xA;      case 6:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW); &#xA;     break;&#xA;&#xA;     default:&#xA;        digitalWrite(8,LOW);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        shiftOut(11,12,LSBFIRST,0);&#xA;        digitalWrite(8,HIGH);&#xA;        delay(10);&#xA;        digitalWrite(8,LOW);&#xA;     break;&#xA;     }&#xA;   }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3936" OwnerDisplayName="Abdelrahman Tarief" LastEditorUserId="46" LastEditDate="2014-09-10T17:55:57.390" LastActivityDate="2014-09-10T17:55:57.390" Title="Serial input parallel output shift registers with arduino" Tags="|c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4122" PostTypeId="2" ParentId="4121" CreationDate="2014-09-09T17:29:17.390" Score="2" Body="&lt;pre&gt;&lt;code&gt;unsigned char i;&#xA;&#xA;digitalWrite(8,LOW);&#xA;for(i=0;i&amp;lt;=6;i++){&#xA;    if(x+i==6) shiftOut(11,12,LSBFIRST,dataArray[y]);&#xA;    else shiftOut(11,12,LSBFIRST,0);&#xA;    }&#xA;digitalWrite(8,HIGH);&#xA;delay(10);&#xA;digitalWrite(8,LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="venny" LastActivityDate="2014-09-09T17:29:17.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4123" PostTypeId="2" ParentId="3990" CreationDate="2014-09-09T21:44:27.730" Score="0" Body="&lt;p&gt;As stated by @mpflaga you can power your Arduino by the 5v power rail. As @ Gerben mentions in a comment, doing this will bypass the polyfuse. Because of this, I &lt;a href=&quot;https://www.virtuabotix.com/bareduino328-plus-regulate-your-bareduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;create my own&lt;/a&gt; Arduino for less than $10 (US) with a power regulator. Using a  &lt;code&gt;L7805ACP&lt;/code&gt; will regulate the power. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part List:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;• 1 x P-DIP ATMEGA328P-PU programmed with Duemilanove Bootloader&#xA;• 3 x Through-Hole 22pF Capacitors (2 for crystal and 1 for Analog power smoothing)&#xA;• 1 x Through-Hole HC-49S 16 MHz Crystal (for clock)&#xA;• 1 x 5 Volt regulator (peak current 2 A, nominal )(L7805ACP&#xA;  Input Voltage = 7.5 to 18 V&#xA;  Output Voltage Low 4.8 Volts Nominal 5 Volts  High 5.2 Volts)&#xA;• 1 x 22 uF Capacitor (to stabilize power rail during rapid current draw.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/q0ymm.jpg&quot; alt=&quot;Homemade Arduino &quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2014-09-09T22:09:16.353" LastActivityDate="2014-09-09T22:09:16.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4124" PostTypeId="1" CreationDate="2014-09-10T00:43:46.253" Score="1" ViewCount="2924" Body="&lt;p&gt;I'm currently trying to code a simple program that would allow me to light up an individual LED on an 8X8 LED board using a double array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the problems:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the rows can ON individually UNTIL I turn all 8 rows ON. When I do this the last column turns OFF by itself (see attached pictures). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The columns aren't even working properly either. Every time I assign a column ON, the last column faintly turns ON too (one of the LEDs light in that column is broken so that is expect to be OFF. See picture).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think those are the reasons why I am not able to singly assign a particular LED to be ON according to assignments in the array. If someone could spot my mistakes, it would greatly be appreciated. Thanks!    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led2 = 2;&#xA;int led3 = 3;&#xA;int led4 = 4;&#xA;int led5 = 5;&#xA;int led6 = 6;&#xA;int led7 = 7;&#xA;int led8 = 8;&#xA;int led9 = 9;&#xA;int led10 = 10;&#xA;int led11 = 11;&#xA;int led12 = 12;&#xA;int led13 = 13;&#xA;int led16 = 16;&#xA;int led17 = 17;&#xA;int led18 = 18;&#xA;int led19 = 19;&#xA;&#xA;int rowPins [8] ={led19, led18, led11, led7, led12, led5, led4, led16};//assigning each LED to a row.&#xA;int columnPins [8] ={led13, led17, led9, led10, led2, led8, led3, led6};//assigning each LED to a column&#xA;&#xA;int image [8][8]=&#xA;{&#xA;&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;{0,0,0,0,0,0,0,0},&#xA;&#xA;};&#xA;&#xA;void setup() &#xA;{           &#xA;  for (int i = 0; i&amp;lt;8; i++)  &#xA;  {&#xA;      pinMode(rowPins[i], OUTPUT);  &#xA;      pinMode(columnPins[i], OUTPUT);    &#xA;  }&#xA;}//end of setup() &#xA;&#xA;&#xA;&#xA;&#xA;void loop ()&#xA;{&#xA;for (int y=0; y&amp;lt;8; y++)&#xA;{&#xA; for (int x=0; x&amp;lt;8; x++)&#xA; {&#xA;   if (image[x][y]==1)&#xA;   {&#xA;     digitalWrite (columnPins[x], HIGH);&#xA;   }&#xA;   else&#xA;   {&#xA;     digitalWrite(columnPins[x], LOW);&#xA;   } &#xA; }//end of 2nd for loop  &#xA;&#xA;  digitalWrite(rowPins[y], LOW);&#xA;  delayMicroseconds(100);&#xA;  digitalWrite(rowPins[y], HIGH);&#xA;}//end of first for loop&#xA;}//end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eax3Z.jpg&quot; alt=&quot;When all 8 rows are ON the last column turns OFF&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/G0m3w.jpg&quot; alt=&quot;When only 7 rows are ON&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fc4Kj.jpg&quot; alt=&quot;when one column is ON the other is faintly also ON&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3927" LastActivityDate="2014-09-10T20:04:58.323" Title="8X8 LED not lightning up according to matrix assignment on a Arduino Nano" Tags="|led|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4125" PostTypeId="2" ParentId="4124" CreationDate="2014-09-10T06:04:07.110" Score="3" Body="&lt;p&gt;I don't see any program statements in the code as shown to cause the described behavior, and imagine it is some hardware problem.  (I'm assuming you put some non-zero values into the &lt;code&gt;image[][]&lt;/code&gt; array; it looks to me like nothing should light up when &lt;code&gt;image[][]&lt;/code&gt; is all-zeroes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware problems break into several categories:  A wiring problem (which we can't see without much better pictures); incorrect software setup of HW; temporary misbehavior of the processor; or permanent damage.  For the sake of discussion, suppose temporary misbehavior applies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Temporary misbehavior can be caused by overheating.  Overheating can be caused by drawing or sinking a lot of current for too long a time.  (If a large current is a fast transient event, it may have little effect.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that most Arduino I/O lines are rated to sink or source at most 40 mA current each.  Ground and Vcc lines have higher limits, like 200 or 100 mA.  For more details see the spec sheet for your processor; also see &lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArduinoPinCurrentLimitations&lt;/a&gt; at arduino.cc, and &lt;a href=&quot;https://electronics.stackexchange.com/q/17962&quot;&gt;Real maximum current for ATmega328?&lt;/a&gt; on Electronics SE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If an LED is directly connected to 5V, it is likely to draw several times more current than nominal.  Connecting  an LED directly to an Arduino digital line also will allow it to draw too much current.  Connecting 8 LEDs to a single processor IO line is likely to cause enough overheating to damage the processor permanently.  You may need to add 8 or 16 resistors to your circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, instead of trying to debug while using a 100 μs multiplexing delay in your program, and instead of turning on lots of lights at the same time, try turning on one at a time for a brief but visible period each, and see if the array of lights scans ok, via code like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rowPins[]    = {19, 18, 11, 7, 12, 5, 4, 16}; //assign row lines&#xA;int columnPins[] = {13, 17, 9, 10,  2, 8, 3,  6}; //assign col lines&#xA;&#xA;void setup() { &#xA;  int i;          &#xA;  for (i=0; i&amp;lt;8; ++i) {&#xA;    pinMode(rowPins[i], OUTPUT);  &#xA;    digitalWrite(rowPins[i], HIGH);&#xA;    pinMode(columnPins[i], OUTPUT); &#xA;    digitalWrite(columnPins[i], LOW);   &#xA;  }&#xA;}&#xA;void loop () {&#xA;  int x, y;&#xA;  for (y=0; y&amp;lt;8; ++y) {&#xA;    digitalWrite(rowPins[y], LOW);&#xA;    for (x=0; x&amp;lt;8; ++x)  {&#xA;      digitalWrite (columnPins[x], HIGH);&#xA;      delay(250);     // wait about .25 seconds&#xA;      digitalWrite(columnPins[x], LOW);&#xA;    }&#xA;    digitalWrite(rowPins[y], HIGH);&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If multiple lights are on there may be miswiring on your project board, or the chip might be damaged, or there may be some roundabout leakage path from columns to ground or from rows to Vcc.  If you make the delay longer or add a pushbutton to advance manually, you can check voltages on LEDs and wires, or measure currents in wires, and perhaps deduce what the path is.  &lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-09-10T20:04:58.323" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4127" PostTypeId="1" AcceptedAnswerId="4131" CreationDate="2014-09-10T11:03:09.840" Score="4" ViewCount="6054" Body="&lt;p&gt;I have the following circuit and want to use the Arduino Mega 2560 as an debugger for an other Microcontroller.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/uEZTh.png&quot; alt=&quot;circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am looking for the code to redirect the UART input from &quot;P17 (RX2)&quot; to the serial USB and the data coming from the serial USB to the output of &quot;P16 (TX2)&quot;&lt;/p&gt;&#xA;" OwnerUserId="233" LastActivityDate="2014-09-10T16:46:09.340" Title="Code to use an Arduino Mega 2560 to transfer UART &lt;-&gt; USB to debug an other Microcontroller" Tags="|arduino-mega|uart|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4128" PostTypeId="1" AcceptedAnswerId="4130" CreationDate="2014-09-10T12:06:27.523" Score="7" ViewCount="419" Body="&lt;p&gt;On the Arduino website it states that the analog pins read voltages from 0 to 5 volts (default) and return a value from 0 to 1023. One can also set the range with analogReference(). However, this is probably assuming the Arduino is running at 5 volts. If one powers the board with, say 4 volts, will the analog reference still be 5 volts default, or changed to the input voltage of 4 volts?&lt;/p&gt;&#xA;" OwnerDisplayName="user3933" LastActivityDate="2020-09-20T03:34:20.360" Title="Analog Reference and Power Voltage" Tags="|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4130" PostTypeId="2" ParentId="4128" CreationDate="2014-09-10T13:02:26.637" Score="4" Body="&lt;p&gt;Your suspicions are correct. Calling &lt;code&gt;analogReference()&lt;/code&gt; with a value of &lt;code&gt;DEFAULT&lt;/code&gt; sets the ADC reference to the voltage at AV&lt;sub&gt;CC&lt;/sub&gt; which at least on the Uno R3 is tied directly to V&lt;sub&gt;CC&lt;/sub&gt; and hence has the same voltage as whatever you're supplying there.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-10T13:02:26.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4131" PostTypeId="2" ParentId="4127" CreationDate="2014-09-10T16:46:09.340" Score="4" Body="&lt;p&gt;A very simple sketch to pass serial through looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial1.begin(/*BAUD*/);&#xA;  Serial2.begin(/*BAUD*/);&#xA;}&#xA;&#xA;void loop(){&#xA;  if(Serial1.available()){&#xA;    Serial2.print((char)Serial1.read());&#xA;  }&#xA;  if(Serial2.available()){&#xA;    Serial1.print((char)Serial2.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would advise both run at the same baud rate, otherwise you may need to do some extra buffering yourself if the arduino starts running out of buffer space. If you want to use the mega's USB connection instead of &quot;Serial1&quot; like your schematic, just switch &quot;Serial1&quot; to &quot;Serial&quot;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-09-10T16:46:09.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4132" PostTypeId="1" CreationDate="2014-09-10T17:35:42.583" Score="1" ViewCount="627" Body="&lt;p&gt;Im building an electrical system for my EBike.  My bike has 2 power sources, one is the 48 volt battery, the other is a 12 power converter coming off the battery pack.  I need an arduino shield that has 4 switching channels.  2 that can take in the 48 volt and switch it on and off, and two that can take in the 12 volt and switch it on and off.  Something that can take the 12 volt to power the arduino uno would be nice but I can find a chip to do that if necessary.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since these are lights, normally off would be more more efficient but with the power consumption we are talking about, i can probably run the battery all day to the point of dry and the fets eat all of 50 feet worth of power staying closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know of anything like that?  I found several shields out there like &lt;a href=&quot;http://arduino-info.wikispaces.com/Brick-4ChannelPowerFetSwitch&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; but all of them seem to be setup to take 1 voltage input and switch it between the 4 or 6 fets on the board, not different voltages per fet and since I'm a programmer, not an EE so I have trouble reading the schematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because my grounds have to be tied, its easier to switch the positive on and off than the negative.&lt;/p&gt;&#xA;" OwnerUserId="3938" LastEditorUserId="37" LastEditDate="2014-09-10T17:45:17.587" LastActivityDate="2018-06-04T19:08:49.517" Title="Selecting a MOSFET Shield" Tags="|mosfet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4133" PostTypeId="1" AcceptedAnswerId="4134" CreationDate="2014-09-10T18:35:41.930" Score="1" ViewCount="2810" Body="&lt;p&gt;In my low power project, I'm using a Arduino Pro Mini (5V, 16 MHz, ATMEGA328) and a low wattage 3W power supply. Everything else on the system other than the Arduino uses a max of 1.98W.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much power should I budget for the Arduino Pro Mini (without any mods, ie: disconnecting the voltage regulator and LED)?&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2014-09-11T06:59:06.207" Title="Budgeting Power for 5V Arduino Pro Mini" Tags="|power|arduino-pro-mini|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4134" PostTypeId="2" ParentId="4133" CreationDate="2014-09-11T06:59:06.207" Score="2" Body="&lt;p&gt;Arduino mini, and atmega328 in general use less than 10mA with default arduino code. Turning down unused component (ADC and so on), using deep sleep and optimizing pbc would lover this consumption a lot, in the land of uA&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-09-11T06:59:06.207" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4135" PostTypeId="1" AcceptedAnswerId="4178" CreationDate="2014-09-11T07:29:31.323" Score="2" ViewCount="1709" Body="&lt;p&gt;In the example of the arduino starter kit the point is to use a potenciometer to control a servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;angle = map(potVal, 0, 1023, 0, 179);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output in the serial&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;potVal: 1023, angle: 179&#xA;potVal: 1015, angle: 177&#xA;potVal: 1023, angle: 179&#xA;potVal: 1016, angle: 177&#xA;potVal: 1023, angle: 179&#xA;potVal: 1023, angle: 179&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed that the servo is shaking like trying to go passing over the 179, when it is suppose to use an angle max 180º (0-179)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the problem?&lt;/p&gt;&#xA;" OwnerUserId="3840" LastActivityDate="2014-09-14T07:34:10.160" Title="Arduino starter kit servo is shaking" Tags="|arduino-uno|servo|map|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4136" PostTypeId="1" AcceptedAnswerId="4240" CreationDate="2014-09-11T08:24:58.630" Score="2" ViewCount="2104" Body="&lt;p&gt;I'm new here and also new to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a rather specific problem and I've posted to the official Forum &#xA;on arduino.cc two days ago (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=265800.0&quot; rel=&quot;nofollow&quot;&gt;original Post&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly, I've yet to recieve any help and since it's a project for work, theres a (loose) schedule. So I've decided to post it here as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have some ideas, it'd be really great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I've posted this question without acknowleding some forum rules please tell me so that I can write better posts in the future ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Patrick&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;The original Posts as Text :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Post # 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hello Guys,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my first time posting in the forum since I'm new to Arduino, so please be kind  smiley-wink.&#xA;Me and a colleague of mine have been given a Project to create with arduino hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Project is, that you should be able to read NFC tags with the arduino&#xA;and send them to a server to be checked and eventually being written into a db.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware:&#xA;Arduino Uno R3 (funduino.de/index.php/shop/product/view/2/4)&#xA;Adafruit CC3000 (www.adafruit.com/products/1469)&#xA;Adafruit PN532 (www.adafruit.com/products/789)&#xA;Stepper Motor (not yet included and not relevant for the problem)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry about not using hyperlinks, but the forum says I'm not allowed to post more than 2 links at once...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now on to the Problem:&#xA;When we're using the shields separately (meaning connecting the arduino to either of the shields by itself), the shields work fine. The cc3000 gets a connection and the PN532 reads cards.&#xA;Now we've tried to stack them together for live use. That's where the trouble starts...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect the PN532 5V to the arduino 3.3V&#xA;and CC3000 VIN to 5V arduino,&#xA;the shields both do what they should with separate example sketches ('readMifare' and 'buildTest').&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I put my sketch in (which combines both of those sketches and some other stuff)&#xA;and comment out the initialization of either the PN532 or the CC3000, the other shield works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I try to use both, the CC3000 and the PN532,&#xA;the CC3000 tries to initialize, but falls into a loop of restarts.&#xA;I've read that that (possibly) is because of the lack of power supply.&#xA;(I've connected a 12V wall-wart by the way and it didn't work with that either)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manual says, that the CC3000 needs 5V, but can work on 3.3V too (though I didn't find a source to explain how)&#xA;and the PN532 needs 3.3V to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong, or is it a problem with the arduino?&#xA;If I'm doing it wrong, how am I connecting these parts correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really am not that good with electronics and didn't find a sollution to my problem nearly a days worth of searching the net.&#xA;For your understanding I'll post the script I'm using and some pictures of the board setup.&#xA;Thanks in advance for ANY help you guys can give me (even if it's just  good guide for problems like mine) ^^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Patrick&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part of the sketch that initializes the components (and also where the CC3000 gets stuck...)&#xA;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//WLAN-Libraries&#xA;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;&#xA;//NFC-Libraries&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_NFCShield_I2C.h&amp;gt;&#xA;&#xA;//Motor-Libraries&#xA;#include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;//NFC-shield PINs&#xA;#define IRQ   (2)&#xA;#define RESET (4)  // Not connected by default on the NFC Shield&#xA;&#xA;Adafruit_NFCShield_I2C nfc(IRQ, RESET);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Motor-settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int stepsPerRevolution = 180;  // change this to fit the number of steps per revolution&#xA;                                     // for your motor&#xA;&#xA;Stepper Motor(stepsPerRevolution, 6,7,8,9);  // initialize the stepper library on pins 8 through 11:          &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Wifi-settings&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                                         SPI_CLOCK_DIV2); // you can change this clock speed&#xA;&#xA;#define WLAN_SSID       &quot;mySSID&quot;           // changed for your convenience&#xA;#define WLAN_PASS       &quot;myPassphrase&quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;Adafruit_CC3000_Client www;  //defines how we will refer to the cc3000 connection object&#xA;&#xA;// What page to grab!&#xA;#define WEBSITE      &quot;10.2.10.170&quot;  //NOTE: CC3000 doesn't seem to like the default localhost address of 127.0.0.1 - need to enter actual IP&#xA;#define WEBPAGE     &quot;/index.php&quot;&#xA;&#xA;&#xA;//this is the counter that will be used for uploading data&#xA;long pollCounter = 1; &#xA;&#xA;//used for storing data for upload&#xA;//set it to the data type that suits your data&#xA;int&#xA;  NFC_ID, Session_ID, UID_final;&#xA;&#xA;//used for commands received from base station&#xA;int&#xA;  command_open, command_close;&#xA;&#xA;  boolean pollFlag = false;         //tells the sketch whether to poll or not&#xA;&#xA;//declare a variable to hold a numeric IP address&#xA;//can be overridden below if you use lookup&#xA;  uint32_t ip = (192L &amp;lt;&amp;lt; 24) | (168L&amp;lt;&amp;lt;16) | (1&amp;lt;&amp;lt;8) | 13;&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Initialization of the modules (Motor, Wifi, NFC-Reader)&#xA;*/&#xA;/**************************************************************************/&#xA;&#xA;&#xA;void setup(void)&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Set up the Motor for the lock&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // set the Motor speed at 60 rpm:&#xA;  Motor.setSpeed(60);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Set up the Wifi module&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); &#xA;&#xA;  Serial.print(&quot;Free RAM: &quot;); Serial.println(getFreeRam(), DEC);&#xA;&#xA;  /* Initialize the Wifi module */&#xA;  Serial.println(F(&quot;\nInitializing...&quot;));                 //&amp;lt;======== Here the CC3000 gets stuck in a loop&#xA;  if (!cc3000.begin())                                          //                          when both shields are connected&#xA;    {&#xA;      Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;      while(1);&#xA;    }&#xA;&#xA;  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;    {&#xA;      delay(100); // ToDo: Insert a DHCP timeout!&#xA;    }  &#xA;&#xA;  /* Display the IP address DNS, Gateway, etc. */  &#xA;  while (! displayConnectionDetails())&#xA;    {&#xA;      delay(1000);&#xA;    }&#xA;&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Set up the NFC module&#xA;      if (pollFlag == true) &#xA;      {&#xA;            nfc.begin();&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        uint32_t versiondata = nfc.getFirmwareVersion();&#xA;        if (! versiondata) {&#xA;          Serial.print(&quot;Didn't find PN53x board&quot;);&#xA;          while (1); // halt&#xA;        }&#xA;        // Got ok data, print it out!&#xA;        Serial.print(&quot;Found chip PN5&quot;); Serial.println((versiondata&amp;gt;&amp;gt;24) &amp;amp; 0xFF, HEX); &#xA;        Serial.print(&quot;Firmware ver. &quot;); Serial.print((versiondata&amp;gt;&amp;gt;16) &amp;amp; 0xFF, DEC); &#xA;        Serial.print('.'); Serial.println((versiondata&amp;gt;&amp;gt;8) &amp;amp; 0xFF, DEC);&#xA;&#xA;        // configure board to read RFID tags&#xA;        nfc.SAMConfig();&#xA;&#xA;        Serial.println(&quot;Waiting for an ISO14443A Card ...&quot;);&#xA;  }&#xA;  else {&#xA;     Serial.println(&quot;Failed to initialize NFC-Reader... Sorry...&quot;); &#xA;  }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope I'm not messing up the image-uploads...&#xA;(I kept the wiring-colors where I coul for you to see the connections easily)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The boards connected via cables (both separately working)&#xA;www.directupload.net/file/d/3740/j3y3tx38_jpg.htm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The boards put together&#xA;www.directupload.net/file/d/3740/yb9q6qla_jpg.htm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The boards connected together with the Wifi in the picture.&#xA;(You can't see the LED on the CC3000 light up, but I swear it does  smiley-wink)&#xA;www.directupload.net/file/d/3740/uorksjrj_jpg.htm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Post # 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, I got myself a multimeter today to measure if it is really a problem with the power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the NFC-Reader running I measured 4.85V on the 5V-Pin and 3.32V on the 3.3V-Pin.&#xA;This means, that the CC3000 should have enough Power to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm now looking for a possible address collision in the libraries (specifically I2C- and SPI-collisions). As I'm still new to this, help is really appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Morning everyone!&#xA;What I've found out since yesterday is, that the PN532 uses I2C while the CC3000 uses SPI to communicate. When I looked through the libraries I found out that the PN532 includes Wire.h which gets its address at &quot;nfc.begin();&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the begin-function in Wire.cpp there is an address transmitted to the function, but I can't find it's source. Is it possible that that address collides with the one the CC3000 uses?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I uploaded an I2C-Scanner to the UNO, it said that the only device fount is the PN532 on address '0x24'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really know what to do with that info though, since there are more libraries being included (like  which in term calls others) and I cant even find these on the Mac I'm working on at the moment...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #3:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem has been solved in the arduino.cc forum. The SRAM was overflowing, but applying the F()-macro to the strings being printed solved the issue!&#xA;(Just in case someone has similar issues ^^)&lt;/p&gt;&#xA;" OwnerUserId="3945" LastEditorUserId="11" LastEditDate="2014-09-12T15:49:44.373" LastActivityDate="2015-03-09T04:07:15.773" Title="Problem connecting Arduino Uno with Wifi and NFC" Tags="|arduino-uno|wifi|i2c|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4137" PostTypeId="2" ParentId="3184" CreationDate="2014-09-11T08:35:39.827" Score="1" Body="&lt;p&gt;It sounds like your first need is a way to send the bytes back and forth.  A secondary question will be what that data should consist of (eg: text commands, binary commands, etc).  Let's tackle the &quot;how&quot; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have described two dynamics to the communication between server and Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The arduino &quot;sends data to the server&quot; where PHP code will save it&#xA;to MySQL; if your Arduino can be an internet client (eg: has an&#xA;ethernet or wifi interface), it could use GET or POST (or PUT) HTTP calls to&#xA;php code.  GET is easiest, but normally GET calls shouldn't change the server, only&#xA;query it -- but many people make exceptions for small devices and small&#xA;amounts of data which can be encoded in the URL.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The web server &quot;controls the Arduino&quot;.  Unless the Arduino sets up&#xA;an internet server, it is going to have to poll the web server from&#xA;time to time to find out what it should do (ie: to be controlled). &#xA;It can pretty easily use a GET to fetch some text which it can&#xA;interpret.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm guessing that HTTP will be the easiest path for communicating, because you probably understand that if you are a PHP programmer, and because it can often get through firewalls more easily if that matters; but a simple TCP socket or UDP datagrams are also possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you can send blocks of bytes between the server and the Arduino, you can focus on what those bytes should contain.  That could be simple text commands, or some binary protocol, or even the MQTT protocol transactions that another answer references.  You haven't given enough info to help select the protocol and format, so I'm assuming you are mostly looking at this time for the method of communicating, as described above.  If you want to ask about the format of what to send back and forth once you have the data flowing, please make that a new question.  You can test the basics by just sending a &quot;Hello&quot; text string between server and Arduino.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastEditorUserId="1186" LastEditDate="2014-09-12T06:39:51.853" LastActivityDate="2014-09-12T06:39:51.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4138" PostTypeId="1" AcceptedAnswerId="4144" CreationDate="2014-09-11T10:24:13.073" Score="0" ViewCount="11654" Body="&lt;p&gt;I tried the code shown below (&lt;a href=&quot;http://letsplaywitharduino.blogspot.in/p/gsm-modem-with-arduino-uno.html&quot; rel=&quot;nofollow&quot;&gt;found here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);  //Baud rate of the GSM/GPRS Module &#xA;  Serial.print(&quot;\r&quot;);&#xA;  delay(1000);                  &#xA;  Serial.print(&quot;AT+CMGF=1\r&quot;);    &#xA;  delay(1000);&#xA;  Serial.print(&quot;AT+CMGS=\&quot;+919449835011\&quot;\r&quot;);    //Number to which you want to send the sms&#xA;  delay(1000);&#xA;  Serial.print(&quot;Test SMS -Jay\r&quot;);   //The text of the message to be sent&#xA;  delay(1000);&#xA;  Serial.write(0x1A);&#xA;  delay(1000); &#xA;}&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I interfaced my GSM SIM900A module to the Arduino UNO (connections - GSM Tx to Arduino Rx, GSM Rx to Arduino Tx, GSM provided with supply (12V) using external adapter, GSM gnd to Arduino gnd).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dumped the code into Arduino and then opened the Arduino IDE serial terminal. In the serial terminal, I get &lt;code&gt;AT+CMGF=1AT+CMGS=&quot;+919449835011&quot;Test SMS -Jay\r&lt;/code&gt; being displayed and I am not receiving any sms to my phone. I am not sure if its a problem with the code or connections.&lt;/p&gt;&#xA;" OwnerUserId="3892" LastEditorUserId="37" LastEditDate="2014-09-11T20:07:53.130" LastActivityDate="2016-07-15T04:40:45.310" Title="Not able to send SMS to Mobile using GSM900A and Arduino Uno" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4139" PostTypeId="1" AcceptedAnswerId="14430" CreationDate="2014-09-11T10:59:58.317" Score="0" ViewCount="8163" Body="&lt;p&gt;I am working on building a pure sine wave inverter using an Arduino Uno to output two PWM signals for the top and bottom half of the wave. Currently I am outputting pre-calculated values with an interrupt as PWM. This seems to be working but I was wondering if anyone had any feedback on my design, and whether there is a better way to go about doing this. I will also need to incorporate feedback into this to vary the max PWM duty cycle, and I am worried the ATMEGA will not be able to keep up do this fast enough. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know if you want any more details, thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Olls&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1iyveHnOxIzqg907T6pu4znsJE-6tg40juMihDvU8Tbg/edit?usp=sharing&quot; rel=&quot;nofollow&quot;&gt;spreadsheet&lt;/a&gt; I'm using to calculate the values.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;&#xA;int duty_cycle;&#xA;int x = 0;&#xA;&#xA;// sin_table is made up of sin(0-400) values multiplied by PWM_PERIOD&#xA;// https://docs.google.com/spreadsheets/d/1iyveHnOxIzqg907T6pu4znsJE-6tg40juMihDvU8Tbg/edit?usp=sharing&#xA;uint8_t _sin[] = { // Calculated for 50Hz at 200 pulses per half wave.&#xA;    0,0,0,1,1,1,2,2,3,3,3,4,4,5,5,5,6,6,6,7,7,8,8,8,9,9,9,10,10,10,11,11,12,12,12,13,13,13,14,14,14,15,15,15,15,16,16,16,17,17,17,17,18,18,18,19,19,19,19,19,20,20,20,20,21,21,21,21,21,22,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21,20,20,20,20,19,19,19,19,19,18,18,18,17,17,17,17,16,16,16,15,15,15,15,14,14,14,13,13,13,12,12,12,11,11,10,10,10,9,9,9,8,8,8,7,7,6,6,6,5,5,5,4,4,3,3,3,2,2,1,1,1,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,5,5,5,6,6,6,7,7,8,8,8,9,9,9,10,10,10,11,11,12,12,12,13,13,13,14,14,14,15,15,15,15,16,16,16,17,17,17,17,18,18,18,19,19,19,19,19,20,20,20,20,21,21,21,21,21,22,22,22,22,22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21,20,20,20,20,19,19,19,19,19,18,18,18,17,17,17,17,16,16,16,15,15,15,15,14,14,14,13,13,13,12,12,12,11,11,10,10,10,9,9,9,8,8,8,7,7,6,6,6,5,5,5,4,4,3,3,3,2,2,1,1,1,0,0,0&#xA;};&#xA;&#xA;void setup() {&#xA;    // Pin mode, and set low.&#xA;    DDRD = DDRD | B00011000;&#xA;    PORTD = B00000000;&#xA;&#xA;    Timer1.initialize(47);&#xA;    Timer1.attachInterrupt(pwm);&#xA;}&#xA;&#xA;void pwm() {&#xA;    if (PIND &amp;amp; B00000100) { // Inhibit switch&#xA;&#xA;        // Lower half or upper half of wave, start PWM pulse&#xA;        if (x &amp;gt; 200) {&#xA;            PORTD = B00010000;&#xA;        } else {&#xA;            PORTD = B00001000;&#xA;        }&#xA;&#xA;        duty_cycle = _sin[x];&#xA;        if (duty_cycle &amp;gt; 3) {&#xA;            delayMicroseconds(duty_cycle);&#xA;        }&#xA;&#xA;        PORTD = B00000000;&#xA;&#xA;        x++;&#xA;        if (x &amp;gt; 400) {&#xA;            x = 0;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3317" LastActivityDate="2023-12-23T18:10:28.480" Title="Sine Wave Inverter" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4140" PostTypeId="1" CreationDate="2014-09-11T13:03:57.983" Score="1" ViewCount="1218" Body="&lt;p&gt;When I connect the Vcc and GND of my circuit to the 5v and GND in my Arduino, it is powered off and stops working. What is the reason and how shall I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/18eHM.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShiftOut&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial to Parallel Shifting-Out with a 74HC595&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3936" LastEditorUserId="3917" LastEditDate="2015-11-29T20:49:57.127" LastActivityDate="2015-11-29T20:49:57.127" Title="When I connect the Vcc and GND of my circuit to my Arduino, it is powered off?" Tags="|power|shift-register|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4141" PostTypeId="2" ParentId="4135" CreationDate="2014-09-11T16:57:53.323" Score="5" Body="&lt;p&gt;If the problem is due to jittery pot readings, you may want to smooth the &lt;code&gt;potval&lt;/code&gt; data sequence by code like the following, where &lt;code&gt;rawreading&lt;/code&gt; stands for what you just read from the potentiometer's input line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;potval = alpha*potval + (1-alpha)*rawreading;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set &lt;code&gt;alpha&lt;/code&gt; to a number (eg 0.8 or 0.9 or 0.95 etc) between 0 and 1.  &lt;code&gt;alpha&lt;/code&gt; represents the fraction of the old value that you retain, and  &lt;code&gt;1-alpha&lt;/code&gt; represents the fractional influence of the new raw reading.   &lt;code&gt;alpha&lt;/code&gt; closer to 1 causes smoother but slower response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer integer arithmetic for faster or smaller code, then represent &lt;code&gt;alpha&lt;/code&gt; as a ratio of integers.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;potval = (potval*12 + rawreading)/13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The technique mentioned above is called &lt;em&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Exponential_smoothing#The_exponential_moving_average&quot; rel=&quot;nofollow&quot;&gt;exponential smoothing&lt;/a&gt;&lt;/em&gt; or  &lt;em&gt;exponential moving average&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2014-09-13T17:20:26.863" LastActivityDate="2014-09-13T17:20:26.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4142" PostTypeId="2" ParentId="4132" CreationDate="2014-09-11T18:15:46.277" Score="2" Body="&lt;p&gt;You can make your own. Buy a protoshield and 4 fets (and a few resistors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use the shield you linked to, by not using the &lt;code&gt;+&lt;/code&gt; terminals on the board. Just connect the &lt;code&gt;+&lt;/code&gt; of the lights directly to the battery and only the &lt;code&gt;-&lt;/code&gt; of the light to the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno can be powered by up-to 20V, so you can connect it directly to the battery.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2018-06-04T19:08:49.517" LastActivityDate="2018-06-04T19:08:49.517" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4143" PostTypeId="1" CreationDate="2014-09-11T18:34:04.270" Score="0" ViewCount="900" Body="&lt;p&gt;I would like to control normal household appliances like lamps, pumps etc. using my Arduino with up to 5 A. I looked a little around, but it seems, that most relais draw more current than the Arduino is capable of supplying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I switch an 230 V AC current using my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="2817" LastActivityDate="2014-09-12T05:50:10.250" Title="Switch 230V 50Hz using a digital out pin" Tags="|relay|transistor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4144" PostTypeId="2" ParentId="4138" CreationDate="2014-09-11T19:53:54.617" Score="1" Body="&lt;p&gt;looks like you should be using &lt;code&gt;Serial.begin(2400);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also, I'm assuming your sms phone number isn't actually 919449835011 and that that's not actually the number you used in your code&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2014-09-11T19:53:54.617" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4145" PostTypeId="1" CreationDate="2014-09-11T21:48:53.613" Score="2" ViewCount="312" Body="&lt;p&gt;I am trying to figure out how to build a system of devices that could, on command, notify similar devices that are within a configurable distance. Maximum ranges would need to be around 20' though up to 40' would be preferable. Accuracy +- 20% is acceptable as is degradation due to things such as large intervening objects, walls, buildings etc. Only one notification is expected in any given 10 second block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking the sending device could send a ultrasonic ping, and then send a data packet with the ping time stamp and range notification to all devices in range. And then each receiver could compare the ping receive time and range notification and calculate if it is within the range given in the data packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this work? Is there a better way to do this?&lt;/p&gt;&#xA;" OwnerUserId="3950" LastActivityDate="2014-09-11T21:48:53.613" Title="Could a bluetooth, speaker and microphone equiped arduino be used to form a range sensing swarm?" Tags="|sensors|bluetooth|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4146" PostTypeId="1" AcceptedAnswerId="4162" CreationDate="2014-09-12T01:04:52.837" Score="1" ViewCount="3100" Body="&lt;p&gt;I have a &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/MAX3222-MAX3241.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;max3232&lt;/a&gt; hooked up to the RX and TX pins of the Arduino Due.  I'm trying to write a simple program to relay messages received from USB and output as RS232 through the chip.  Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char readbyte;&#xA;&#xA;void setup(){&#xA;  Serial.begin(115200);  &#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  while (Serial.available() &amp;gt; 0 ) {&#xA;    readbyte = Serial.read();&#xA;    Serial.print(readbyte);&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This program works when I don't have the MAX2323 hooked up (e.g. I send &quot;123&quot; and get &quot;123&quot; echoed back), but when I hook up the MAX2323, the Arduino isn't sending back.  I've written another test program that sends random data and it seems to work fine.  I'm at a lost at what is wrong with my simple program, can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the schematic:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/PY27U.png&quot; alt=&quot;Circuit&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3554" LastEditorUserId="37" LastEditDate="2014-09-13T12:07:24.563" LastActivityDate="2014-09-13T12:07:24.563" Title="Receiving and sending on the Arduino Duemilanove with an MAX3232 chip" Tags="|serial|arduino-duemilanove|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4147" PostTypeId="2" ParentId="4143" CreationDate="2014-09-12T03:02:49.347" Score="1" Body="&lt;p&gt;Get a logic level n-channel MOSFET that is rated for your relay's voltage and current requirements, and an external DC power supply that's able to put out enough current to drive the relay. Feed the power supply into the relay coil. Connect the ground of the coil to the drain of the MOSFET. Connect the source of the MOSFET to ground. Connect the MOSFET gate to your Arduino control pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might be able to find a relay that will run on 5V at low enough current that you can drive it with a MOSFET and the 5V out from your Arduino, but make sure you don't exceed the total current limit of your Arduino's regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you put a flyback protection diode in parallel with your relay coil, pointing to block the normal flow of current through the coil, so you don't fry your transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can buy solid state relays that can switch large AC loads using logic level signals, but they're expensive. &lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-12T03:02:49.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4148" PostTypeId="2" ParentId="4143" CreationDate="2014-09-12T05:50:10.250" Score="4" Body="&lt;p&gt;The good advice to people asking how to drive a relay to control mains voltage is: &lt;strong&gt;don't&lt;/strong&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with a complete solution such as those from PowerswitchTail.com and sold by many places:  &lt;a href=&quot;http://www.powerswitchtail.com/Pages/PowerSwitchTail240vackit.aspx&quot; rel=&quot;nofollow&quot;&gt;Powerswitch Tail&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get these already built or in kit form.  The 20 $ price is small price compared to damage to people or home you might incur with a home built solution.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-09-12T05:50:10.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4149" PostTypeId="1" AcceptedAnswerId="4151" CreationDate="2014-09-12T09:24:42.913" Score="2" ViewCount="719" Body="&lt;p&gt;I'm trying to control two DC 3-6V motors with a HG7881 driver and an Arduino Nano, but the Nano is always resetting if it has the same power supply than the driver. I'm connecting the batteries to HG7881 Vcc and Nano Vin (and also same ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I power the Nano with USB and the driver with batteries then it works but that's not a good solution for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is, is there any way to make both driver and Nano work with the same power supply?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="3823" LastActivityDate="2014-09-12T20:25:49.493" Title="Powering motors" Tags="|motor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4151" PostTypeId="2" ParentId="4149" CreationDate="2014-09-12T11:16:09.767" Score="1" Body="&lt;p&gt;You need to know the peak current demands of your motor circuit before you can solve this problem. If you have a digital multimeter you can measure the constant current, and make a guess at the peak current. Put your multimeter in series with the motor driver and operate it at full power. The peak current may be as high as twice the steady current of the running motor. Also check the current with the motor under heavy load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need a power supply that can put out that much current, plus the current of your Arduino, without the voltage dropping below the minimum requirement for the Arduino voltage regulator (~7 volts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of batteries are you using? If you put 6 C cells in series you'll get 9 volts and pretty high peak current.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-09-12T20:25:49.493" LastActivityDate="2014-09-12T20:25:49.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4152" PostTypeId="1" AcceptedAnswerId="4155" CreationDate="2014-09-12T14:24:21.903" Score="2" ViewCount="4144" Body="&lt;p&gt;I need a circuit or something to power up IR leds as arduino only give 5v and IR leds needs 1.2V. Is there a way to make one arduino pin a power supply of 1.2 V code or something ?&lt;/p&gt;&#xA;" OwnerUserId="3936" LastEditorUserId="3936" LastEditDate="2016-12-10T22:24:24.023" LastActivityDate="2016-12-10T22:24:24.023" Title="How to power IR LEDs with arduino?" Tags="|arduino-uno|led|ir|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4154" PostTypeId="2" ParentId="4149" CreationDate="2014-09-12T15:41:30.950" Score="3" Body="&lt;p&gt;If the reset is due to transients when the motor starts or stops, you can get by with isolating Nano power via a diode and capacitor.  (See below.)  If, on the other hand, the motor is dragging the supply voltage so low the Nano won't run, you may need to add a separate battery for the Nano or upgrade your batteries, as mentioned in Duncan's answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To isolate Nano power from motor power, open the connection between battery V+ and Nano Vcc; connect the anode of a diode to V+; connect the cathode to the positive lead of a capacitor of a few hundred microfarads and to Nano Vcc.  Connect the capacitor's negative lead to ground.  If simple diode+capacitor filtering isn't enough, you probably should attach an oscilloscope and find out more exactly what's happening.  Further options include series resistors, wound inductors, and ferrite beads, as seen in some &lt;a href=&quot;https://www.google.com/search?q=power+supply+filtering&amp;amp;biw=1140&amp;amp;bih=640&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ei=xxMTVM-0K4nGiwLW34GoBQ&amp;amp;sqi=2&amp;amp;ved=0CDQQsAQ&quot; rel=&quot;nofollow&quot;&gt;Google images&lt;/a&gt; for power supply filtering.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2014-09-12T15:41:30.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4155" PostTypeId="2" ParentId="4152" CreationDate="2014-09-12T15:56:47.790" Score="4" Body="&lt;p&gt;Typically, rational control of an LED sets the amount of current that goes through the LED, rather than setting its voltage.  You could add series resistors so that when the desired current is flowing through the LED, about 1.2 volts is across the LED and the rest (say 3.6–3.8V) is across the resistor.  (See &lt;a href=&quot;https://www.google.com/search?q=power+supply+filtering&amp;amp;biw=1140&amp;amp;bih=640&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ei=xxMTVM-0K4nGiwLW34GoBQ&amp;amp;sqi=2&amp;amp;ved=0CDQQsAQ#tbm=isch&amp;amp;q=Arduino+LED+series+resistor&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google images&lt;/a&gt; for typical circuits, and see various &lt;a href=&quot;https://www.google.com/?gws_rd=ssl#q=arduino+led+resistor+calculator&quot; rel=&quot;nofollow noreferrer&quot;&gt;LED resistor&lt;/a&gt; calculator, eg the &lt;a href=&quot;http://www.hacktronics.com/Tools/led-resistor-calculator.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;LED resistor calculator&lt;/a&gt; at hacktronics.com.)  It also is possible to use PWM to control LED brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you have 3.6V across a resistor and 1.2V across an LED, you are wasting 3/4 of the power expended.  When LEDs are low voltage (ie, like 1.2V for your LEDs, vs. 1.6 for typical red or orange LEDs, vs 3+ V for white or blue) you can put several of them in series.  For example, put three of your IR LEDs in series, and calculate R so that 1.2 V drops across a resistor and 3.6 across the series of LEDs.  Also try four LEDs in series, and calculate R to drop 0.1 to 0.3 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit 1:&lt;/em&gt;&lt;/strong&gt; Ignacio Vazquez-Abrams says, a little  obscurely, “Getting warmer. But this is a IR LED” and also “Pull up the datasheet for a IR LED. Read it carefully. The AVR can't handle one of the numbers”, perhaps in reference to IR LED current requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical 5mm IR LEDs can handle several times more current than typical 5mm visible light LEDs.  For example, a typical green LED might be rated 30 mA max sustained current and 20 mA recommended, while a typical IR LED might be rated 100 mA max and 50 mA recommended.  Also note that 50 mA is 10 mA more than the 40 mA that most Arduino pins list as absolute max.  A sustained current of 40 mA or more in or out of an Arduino i/o pin may damage the processor.  If you want to drive a high-current IR LED, use an external driver (eg a transistor).  See eg the answer to &lt;a href=&quot;https://electronics.stackexchange.com/q/55823&quot;&gt;How can I efficiently drive an LED?&lt;/a&gt; in Electronics SE, which shows dropping resistor calculations, constant current sources, etc. Also see links given in &lt;a href=&quot;https://electronics.stackexchange.com/a/56133/7479&quot;&gt;JYelton's answer&lt;/a&gt; to  &lt;a href=&quot;https://electronics.stackexchange.com/q/56131&quot;&gt;Infra Red LEDs - Voltage Advice&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Treesrule14 points out “IR leds ... don't emit in the visible light range”, which is true; they emit infrared radiation, or heat.  Note, using an IR LED in a remote control usually is incompatible with controlling its average brightness with PWM; the pulses used in PWM would conflict with the pulse train in typical &lt;a href=&quot;http://en.wikipedia.org/wiki/RC-5&quot; rel=&quot;nofollow noreferrer&quot;&gt;36, 38, or 40 KHz IR control protocols&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-09-12T23:00:10.937" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4156" PostTypeId="1" CreationDate="2014-09-12T18:08:00.960" Score="0" ViewCount="154" Body="&lt;p&gt;How would you send data wirelessly from arduino uno to a pc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know you can connect wifi shield / wifi breakout to arduino and use that, but what other ways are there and how practical would they be?&lt;/p&gt;&#xA;" OwnerUserId="3937" LastActivityDate="2014-09-12T19:07:34.740" Title="Connecting arduino to a PC" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4157" PostTypeId="2" ParentId="4156" CreationDate="2014-09-12T18:32:44.917" Score="1" Body="&lt;p&gt;You have several options. One is Bluetooth and another is &lt;a href=&quot;https://raspberrypi.stackexchange.com/a/22460/13281&quot;&gt;nRF24L01+ 2.4GHz Wireless Transceiver&lt;/a&gt;. I love the &lt;code&gt;nRF24L01+&lt;/code&gt;. They are cheap and there are tons of examples online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The concept with the &lt;code&gt;nRF24L01+&lt;/code&gt; is to connect the RF24 to a Ft232rl Ftdi Usb to Ttl Serial Adapter. The Ft232rl  connects to your PC. Most modern computer languages support communicating via Serial. This is the way to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google around for a ton of tutorials&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2014-09-12T19:07:34.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4159" PostTypeId="1" CreationDate="2014-09-12T22:06:23.263" Score="1" ViewCount="883" Body="&lt;p&gt;I have a two amp 5VDC power rail.  I have configured a motor shield to use external DC (by moving a jumper.)  Is it ok to share the rail between the arduino's 5V and Gnd pins, and the motor shield?&lt;/p&gt;&#xA;" OwnerUserId="3959" LastActivityDate="2014-09-13T12:33:51.123" Title="Is it ok to share the same power rail for the arduino and a shield?" Tags="|power|shields|arduino-motor-shield|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4160" PostTypeId="2" ParentId="4159" CreationDate="2014-09-12T22:22:13.310" Score="0" Body="&lt;p&gt;Yes, but I wouldn't try to do it through the 5V pin on the Arduino. Run a separate 18AWG or larger wire to bring power and ground to the shield.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-12T22:22:13.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4161" PostTypeId="1" AcceptedAnswerId="4166" CreationDate="2014-09-13T00:06:54.973" Score="-1" ViewCount="1123" Body="&lt;p&gt;I have the problem, that I want some Arduinos communicate in a wireless mesh network using the VirtualWire library but also be able to receive (and send) codes for my rc sockets using the RCSwitch library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some Arduinos using VirtualWire and some devices using the hx2262 IC for RC-Decoding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to send and receive messages between the Arduinos (each message must be at least 10 bytes long) and also be able to send and receive messages from the hx2262 RC power sockets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea would be to use VirtualWire for inter Arduino communication and RCSwitch for the power sockets. Both work fine as long as I do not put both libraries on the same controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea to solve that problem?&lt;/p&gt;&#xA;" OwnerUserId="3961" LastEditorUserId="84" LastEditDate="2014-09-13T07:26:56.913" LastActivityDate="2016-02-06T12:07:44.733" Title="Using VirtualWire and RCSwitch in same PRoject" Tags="|virtualwire|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4162" PostTypeId="2" ParentId="4146" CreationDate="2014-09-13T03:19:45.440" Score="1" Body="&lt;p&gt;With your final comment, the behavior is understandable.  The schematic will help &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/S0xch.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have wired two devices to the single UART on the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX pin (output) on the ATMEGA8 is connected to the input pins of both your MAX2323 and the FT232 chip on the Ardiuno.  That works okay because 1 output pin can easily drive 2 inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RX pin (input) on the ATMEGA8 is connected to the &lt;strong&gt;output&lt;/strong&gt; pins of both your MAX and FT.  The two transceivers are both attempting to drive the single input -- this is a bad thing.  When one output pin tries to drive logic 1 and the other is driving logic 0, one of the devices will win and one will lose.  Whether any of the devices is physically damaged depends on whether one device can source enough current to damage the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you haven't broken anything because of the wise series resistors, R8, you see on the schematic.  The series resistor limits the current to 5 mA even if you short the RX pin to ground.  The series resistor is what creates the unequal behavior:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The ability of the FT chip to source current and drive a logic 1 is limited. So when the FT chip tries to drive logic 1 and the MAX is output 0, a 5 V drop will be seen across R8.  The RX pin is on the MAX side, so the Arduino sees 0.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The MAX chip is not limited.  When it drives 1 and the FT is at 0 there is still 5 V across the resistor.  But the RX pin is on the MAX side and sees the 1's (data).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want the Arduino to receive from two devices you need to &quot;add&quot; the data correctly with a circuit.  There are several ways, here are two:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an OR gate to combine the data.  The serial bus is idle at zero.  When data comes across it is a sequence of 1 bits.  Remove R8 and connect the M8RXD side to the OR input.  Connect the MAX to the other OR input.  Connect the OR output to the RX input.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Cheap and small is &quot;wire or'd&quot;.  Remove R8 and replace with small diode, pointing at RX.  Connect small pull down resistor (10k) from RX to ground.  Connect external MAX with diode pointing at RX.  In this arrangement, either chip will source current towards the RX ping to drive a logic 1, but neither chip can sink current to drive the logic 0.  Only the pull down resistor creates the 0.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-09-13T03:19:45.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4163" PostTypeId="1" CreationDate="2014-09-13T03:59:44.753" Score="5" ViewCount="5876" Body="&lt;p&gt;I have searched online, and haven't found anyone hitting this issue. Strangely my Bluetooth HC-05 is returning encoded data. I have tried using different boards - Induing, Uno, Freeduino and I have the same problem with them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Bluetooth module I am using is a &lt;a href=&quot;https://www.fabtolab.com/radio/bluetooth/HC-05-bluetooth-module-6-pin&quot; rel=&quot;nofollow noreferrer&quot;&gt;HC-05 Bluetooth Module&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I pass 'AT' command, I expect the return to be 'OK'. I get data as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CF  A7  86  85&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is 8-bit data, and if I drop the MSB I would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4F  27  06  05&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead I should have received:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4F  4B  0D  0A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looked at the binary pattern to understand if this is something like 7 bit encoding used in GSM.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Actual Data&#xA;CF       A7       86       85&#xA;11001111 10100111 10000110 10000101&#xA;&#xA;Expected Data&#xA;4F  4B  0D  0A&#xA;01001111 01001011 00001101 00001010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried other AT commands and everything appears to be encoded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I have written is pretty standard, module is blinking at 2 sec pulse (in command mode). I get encoded output for all AT commands. I even tried ORGL, INIT and other commands as suggested on various discussion threads.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BtDongle = SoftwareSerial(10, 11);&#xA;&#xA;void setup() {&#xA;  digitalWrite(9, LOW);&#xA;  delay(100);&#xA;  digitalWrite(9, HIGH);&#xA;  delay(100);  &#xA;  Serial.begin(9600);&#xA;  Serial.write(&quot;AT Command: \n\n&quot;);&#xA;  BtDongle.begin(38400); &#xA;}&#xA;&#xA;void loop() {&#xA;  while(BtDongle.available()) {&#xA;    unsigned char data = BtDongle.read();&#xA;    Serial.println(data, HEX);&#xA;  }&#xA;&#xA;  while(Serial.available()) {&#xA;    char data = Serial.read();&#xA;    Serial.print(data);&#xA;    BtDongle.print(data);&#xA;  }    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3965" LastEditorUserId="27346" LastEditDate="2019-04-12T13:59:20.770" LastActivityDate="2019-06-06T15:11:02.877" Title="Bluetooth HC-05 module returns encoded data" Tags="|arduino-uno|bluetooth|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4164" PostTypeId="1" CreationDate="2014-09-13T04:26:55.870" Score="2" ViewCount="337" Body="&lt;p&gt;I recently started with a domotic project, I began creating a lock opening with a RFID&#xA;currently I'm trying improving the code (I took from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=256260&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=256260&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but I have some question about the security of this system (or any in the domotic way).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I know any system is 100% secure. starting from there, I was thinking, what happens if someone known that the system is built in the arduino platform and has some knowlege about it, that person can create a sketch, upload to the board and make &quot;opening&quot; all the pings?, they will have access to that room or thing I'm protecting (or trying). This is just a excercise, I don't want to go in depth about the external security that the board/system must have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, searching topics about it, I didn't find anything to help in the solution of this theoretical problem. I read some articles about the bootloader and I think, the solution can be there, I know Arduino is a openSource solution, but I think it doesn't mean insecure, so I think some kind of system who check a key before to load a sketch can help. It can have a default key, who can be used to the developing process, and other key (any) who must be verified, in the current sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll try to explain it a little better:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Developing Mode&lt;/strong&gt;&#xA;Bootloader [No Key] -----&gt; can upload any sketch &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Production Mode&lt;/strong&gt;&#xA;Bootloader[check mode] -----&gt; [Sketch with the secure key] &#xA;[Upload New sketch] -----&gt; Bootloader[check the key in the new sketch with the key in the current sketch] (allow or block access, according as appropriate)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have deep knowledge in criptography or bootloading, so I don't know if it's corret solution. I saw there are some way to &quot;download&quot; the code of the board (in a bin), I don't know if with this way the key will be exposed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can someone tell me if this basic security would be helpful?&#xA;if it's, can be possible to implement? how?&#xA;Will the key be exposed in the bin (in case of download)?&lt;/p&gt;&#xA;" OwnerUserId="3966" LastEditorUserId="3966" LastEditDate="2014-09-13T04:43:29.537" LastActivityDate="2014-09-13T12:45:50.527" Title="Improvement security in a domotic project" Tags="|bootloader|sketch|safety|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4165" PostTypeId="1" CreationDate="2014-09-13T10:00:01.320" Score="2" ViewCount="1320" Body="&lt;p&gt;I'm looking for an Arduino board that include this sensors out of the box:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CO&lt;sub&gt;2&lt;/sub&gt;&lt;/li&gt;&#xA;&lt;li&gt;Humidity&lt;/li&gt;&#xA;&lt;li&gt;Noise&lt;/li&gt;&#xA;&lt;li&gt;Temperature&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've found here &lt;a href=&quot;https://arduino.stackexchange.com/questions/269/using-the-waspmote-sensor-board&quot;&gt;Using the Waspmote Sensor Board&lt;/a&gt; something that could be enough, but I'm searching for more options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a lot of searches on the Internet without good results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="3970" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-10-11T19:50:32.297" Title="Arduino + CO2 + humidity + noise + temperature sensors on one board" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4166" PostTypeId="2" ParentId="4161" CreationDate="2014-09-13T12:13:53.867" Score="0" Body="&lt;p&gt;I finally found a solution: Just use both libraries. The problem I head: VirtualWire uses Pin numbering, RCSwitch uses Interrupt numbering. That was the reason, why it did not work.&lt;/p&gt;&#xA;" OwnerUserId="3961" LastActivityDate="2014-09-13T12:13:53.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4167" PostTypeId="2" ParentId="4164" CreationDate="2014-09-13T12:26:27.650" Score="0" Body="&lt;p&gt;A major factor in digital security is physical security. If you want a secure system you have to keep the bad guys from being able to connect wires and such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have your Arduino inside a secure box inside your locked house, and it is not connected to the internet, the only way an intruder will be able to access it is to get into your house. Once inside the house you should require a second, higher level of security to unlock the Arduino's enclosure and muck with it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Arduino is inside your house and an intruder doesn't have physical access to it, they can't install new apps on it or do ANYTHING with bootloaders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use encryption of some sort you will not have very good security. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can build an RFID or NFC system that uses a challenge-response scheme with encryption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this: When the house detects a unique RFID identifier, it generates a random number and encrypts it with that key's public encryption key. It sends the encrypted number to the key, which decrypts it using it's private key, then re-encrypts it with the house's public key and sends it back. The house decrypts the number, verifies that it is the correct number, and only then unlocks the door. The house is programmed to time out pretty quickly if it doesn't receive the correct key, to avoid brute force cracking of the encryption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also want a system where after a modest number of wrong responses, the system locks out for a couple of minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With crypto, it doesn't matter if an intruder captures the RFID/NFC communication between the house and the key. What's sent is a one-time, encrypted code. Without the encryption keys, the intruder can't do anything with that data. It just looks like noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better is to add second factor authentication like a numeric code the user has to type, some sort of biometric scan, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above requires a fair amount of smarts in the key. There are RFID chips out there that have built-in crypto support. I don't know how good they are however. You either need hardware crypto support or a pretty high powered chip (ARM or better) to do crypto in a pocket sized device.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-13T12:26:27.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4168" PostTypeId="2" ParentId="4159" CreationDate="2014-09-13T12:33:51.123" Score="2" Body="&lt;p&gt;the Vin pin on the Arduino is the source to the internal voltage regulator. It needs about 7 volts in order to work. If you try to feed 5V into the Vin then the Arduino won't get a full 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motors draw a lot of current, and cause transients on the power line as they switch on and off. (They will cause transients even in a regulated supply, because it takes the regulator time to respond to the rapidly changing load of the motor.) If you're going to feed both your motor shield and the Arduino's 5V from the same power supply, you will need a reservoir capacitor between 5V and ground as close to the Arduino 5V input as possible. The reservoir capacitor will even out drops and spikes in power to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd be much better off feeding 7-9V into the Arduino's Vin. That way it's power is regulated separately.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-13T12:33:51.123" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4169" PostTypeId="1" AcceptedAnswerId="4172" CreationDate="2014-09-13T12:38:19.667" Score="15" ViewCount="38738" Body="&lt;p&gt;I use my Arduino IDE to either upload my sketch to a Arduino or ATTiny or ATmega328. As you know each device can have a different pinout. Does the Arduino compiler support &lt;code&gt;ifdef&lt;/code&gt;, depending on the board I am connected to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef Attiny85&#xA;       a=0; b=1; c=2;&#xA;#else&#xA;       // arduino&#xA;       a=9; b=10; c=11;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2014-10-22T18:58:08.773" LastActivityDate="2014-10-22T18:58:08.773" Title="Arduino IDE #ifdef" Tags="|arduino-ide|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4170" PostTypeId="2" ParentId="4164" CreationDate="2014-09-13T12:45:50.527" Score="1" Body="&lt;p&gt;First of all, a quick rule that you should follow... It is called &lt;a href=&quot;http://en.wikipedia.org/wiki/Kerckhoffs&amp;#39;s_principle&quot; rel=&quot;nofollow&quot;&gt;Kerckhoffs's principle&lt;/a&gt;. Wikipedia states it as this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A cryptosystem should be secure even if everything about the system, except the key, is public knowledge.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, you're never going to reach &quot;full security.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the attacker can physically access your Arduino, all bets are off. They can upload new code, replace the Arduino, or just simply rewire your circuit so the door opens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, they may be able to remove the RFID module and replace it with another Arduino board that sends random data in the right format hundreds or thousands of times a second. If they find the key code, they can make a new RFID tag with that ID. Thus, it is essential to keep that ID private.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's what you should do (in this scenario, password = RFID key's ID):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Make sure they can touch or access as little as possible.&lt;/strong&gt; If you can, embed the RFID receiver inside a wall so they don't know where the receiver is and would have to break the wall to access it. If they break the wall, they could break the door, so this isn't necessarily a major security flaw. Of course, remember the sensitivity of your receiver.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Obfuscate your code:&lt;/strong&gt; If you do something where you combine only certain bits/bytes of a few different strings to get a passcode to be compared to the sensor value. Of course, the compiler will remove most of this in an attempt to optimize your code. Note that this isn't actual security, just making the intruder having to do more work. A lot of people discourage this since it gives you a false sense of security, but I encourage it because it will take a little bit longer to hack into your application if they get your code. Remember that at any time they can use &lt;code&gt;Serial.println(finalPasswordHere);&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;If you're really worried, hash it.&lt;/strong&gt; AVR chips probably don't have enough power to do advanced hashes like SHA-512. There seems to be a few MD5 hash algorithms for Arduino. MD5 isn't really secure with only a few digits, but if you have a 30 character hash that would take a long time to brute-force it. Add a salt with a ton of random characters (ex: &lt;code&gt;lsjJK399!$%^&amp;amp;flk2&lt;/code&gt;) that aren't normally found in lookup tables. You'd combine the salt and the ID for the tag into one hash and put that in the code. Then, you'd hard code that hash into the main code. When you want to check if the ID being scanned is correct, you'd hash it with the salt and then compare that to the known hash. If you have more than one ID in the system, it's a good idea to have a different salt for each.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-09-13T12:45:50.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4171" PostTypeId="1" AcceptedAnswerId="4173" CreationDate="2014-09-13T12:48:29.450" Score="1" ViewCount="222" Body="&lt;p&gt;I am interested in learning about arduino.  What is the quickest and cheapest way to find out if this is something I can and want to do?&lt;/p&gt;&#xA;" OwnerUserId="3972" LastActivityDate="2014-09-13T12:58:40.553" Title="What is the best way to get started?" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4172" PostTypeId="2" ParentId="4169" CreationDate="2014-09-13T12:50:31.033" Score="15" Body="&lt;p&gt;Yes. Here is the syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)&#xA;    //Code here&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also do something like this for the Mega:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;    //Code here&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming the implementation for the ATtiny is correct, your code should be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined (__AVR_ATtiny85__)&#xA;       a=0; b=1; c=2;&#xA;#else&#xA;       //Arduino&#xA;       a=9; b=10; c=11&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-09-13T13:11:07.450" LastActivityDate="2014-09-13T13:11:07.450" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4173" PostTypeId="2" ParentId="4171" CreationDate="2014-09-13T12:55:57.360" Score="0" Body="&lt;p&gt;By an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoStarterKit&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino starter kit&lt;/a&gt; and do all the projects. There are components and instructions for 15 different circuits. This is not cheap, but I think it will give you a good taste for electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/p7x7q.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-09-13T12:55:57.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4174" PostTypeId="2" ParentId="4171" CreationDate="2014-09-13T12:58:40.553" Score="1" Body="&lt;p&gt;The starter kit would get you everything you need to do a whole set of projects. Alternatively there is a PDF on the Arduino site with a whole set of projects in it. You could go through it, put together an inventory of the parts you need, and order those parts from an electronics supplier like Mouser, DigiKey, Jameco, etc, and save some money. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The starter kit is probably worth the extra money, though, because it has everything you need, plus an organized set of lessons that teach you the various skills you'll need.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-13T12:58:40.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4175" PostTypeId="1" AcceptedAnswerId="4177" CreationDate="2014-09-13T15:29:50.823" Score="1" ViewCount="429" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2LYkt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cant understand what is going on here , I was trying to find way to send through Serial a number for example 12 and then extract from it number 1 and 2 and store them in two different variables , but suddenly i was unable to make a simple division !!&lt;/p&gt;&#xA;" OwnerUserId="3936" LastActivityDate="2014-09-13T18:17:21.157" Title="Serial data to arduino problem" Tags="|arduino-uno|serial|c|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4176" PostTypeId="2" ParentId="4175" CreationDate="2014-09-13T15:42:20.897" Score="4" Body="&lt;p&gt;Do you want to eventually do &lt;code&gt;12 / 10&lt;/code&gt; or &lt;code&gt;1 / 10&lt;/code&gt; and &lt;code&gt;2 / 10&lt;/code&gt;? If the second one, you'll have to read all the serial values into an array and convert those characters to their plain integer values (subtracting 48 from each value). After that, you'll have to add them together with the correct placeholders (&lt;code&gt;A * 100 + B * 10 + C&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, the &lt;code&gt;read()&lt;/code&gt; function returns &lt;strong&gt;one character in the ASCII format&lt;/strong&gt;. ACII basically representing characters on your screen with numbers. 48 displays a 0 on your screen, 49 a 1, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're also facing a problem where your numbers are getting truncated. This means it cuts off the decimal. For when you send &lt;code&gt;100&lt;/code&gt;, it is &lt;code&gt;48 / 10 = 4.8&lt;/code&gt;, however &lt;code&gt;4.8&lt;/code&gt; becomes just &lt;code&gt;4&lt;/code&gt;. The same thing happens for 49.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, you need to use a &lt;code&gt;float&lt;/code&gt; data type. This allows decimal values. You also want to make sure that the conversion from float to string works correctly for the &lt;code&gt;Serial.print()&lt;/code&gt; so you don't end up with &lt;code&gt;4&lt;/code&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available()) {&#xA;  float number = (float)(Serial.read() - 48) / 10;&#xA;  Serial.println(number, 4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-09-13T17:18:50.880" LastActivityDate="2014-09-13T17:18:50.880" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4177" PostTypeId="2" ParentId="4175" CreationDate="2014-09-13T17:11:06.590" Score="3" Body="&lt;p&gt;Anonymous Penguin's code works for me on an Uno after fixing a couple of typos.  It is often best to make sure that both the numerator and the denominator are floats to ensure that the result is also treated as a float.  So please try the following where the 10 is replaced with a 10.0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available()) &#xA;{&#xA;  float number = (float)(Serial.read() - 48) / 10.0;&#xA;  Serial.println(number, 4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to deal with each digit separately an array might be best but that will depend on your end goal.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_LENGTH = 10;&#xA;char buffer[MAX_LENGTH];&#xA;char lineFeed = 10;&#xA;&#xA;int length = Serial.readBytesUntil(lineFeed, buffer, MAX_LENGTH);&#xA;int i = 0;&#xA;while( i &amp;lt; length )&#xA;{&#xA;  //do what ever needs to be done to each character here, I'll just convert them to an int and print them as an example&#xA;  Serial.println( buffer[i]-48 );&#xA;  i++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3973" LastEditorUserId="3973" LastEditDate="2014-09-13T18:17:21.157" LastActivityDate="2014-09-13T18:17:21.157" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4178" PostTypeId="2" ParentId="4135" CreationDate="2014-09-13T17:31:07.197" Score="4" Body="&lt;p&gt;I like this method the best (personal preference) for smoothing signals:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//In setup&#xA;int bufferedVal = analogRead(A0);&#xA;int unbufferedVal = analogRead(A0);&#xA;#define _TOLERANCE_ 5&#xA;&#xA;//The loop&#xA;unbufferedVal = analogRead(A0);&#xA;if(abs(unbufferedVal - bufferedVal) &amp;gt;= _TOLERANCE_ ) {&#xA;  bufferedVal = unbufferedVal;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This finds the error using the &lt;code&gt;abs()&lt;/code&gt; function (absolute value; makes sure it is positive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing you can do is round it to the tenth placeholder (i.e. 88 -&gt; 90, 83 -&gt; 80) so it always is a good number to work with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = analogRead(A0);&#xA;val += 5;&#xA;val = val / 10;&#xA;val = val * 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last two lines work because of the lack of precision that integers offer with decimals. If I divide 88 by 10, it doesn't output 8.8; it outputs 8 instead. We then multiply by ten again so it isn't 8 when it really should be 80. The only problem with this is it only rounds down. We can fix this by adding 5 (the halfway point between 10 and 0). That way, it goes: 88 to 93 to 9.3 to 9 to 90.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I'm not sure if the compiler will notice the redundancy of the last two lines. If it acts weird, try using the &lt;code&gt;volatile&lt;/code&gt; keyword.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2014-09-14T00:42:12.940" LastActivityDate="2014-09-14T00:42:12.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4179" PostTypeId="1" AcceptedAnswerId="4181" CreationDate="2014-09-13T18:11:34.067" Score="1" ViewCount="5842" Body="&lt;p&gt;I am new, but I am wondering what options I may have to control a 12v line that connects to a light with Arduino i/o.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the voltage limitations of an arduino, I am thinking using some kind of 5v relay to switch a 12v line on/off ( if it exists )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I was also hoping to be able to utilize the PWM pins in conjunction with a 12v line to 'reduce' it to 6v without using a resistor.  (though I would have no idea how to go about this, or if it is even possible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3964" LastActivityDate="2014-09-13T18:55:32.440" Title="Using Arduino to control a 12v car light system?" Tags="|pwm|voltage-level|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4180" PostTypeId="1" AcceptedAnswerId="4182" CreationDate="2014-09-13T18:27:47.800" Score="3" ViewCount="282" Body="&lt;p&gt;I'm a longtime C programmer. I've also done a little C++, a little Java, and a LOT of Objective-C, but am fairly new to the Arduino platform and it's IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far all my sketches have had a single source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see how you copy libraries into the libraries sub-folder of your Arduino source folder, either from the Mac finder or from the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to understand somebody else's project (The &quot;Camera Axe&quot; device for high speed photography.) in that project there is a folder for the entire sketch, &quot;cameraAxe&quot;. In that folder there's a file called &quot;cameraAxe.ino&quot;, which follows the usual convention that the sketch's main source file needs to be inside a folder with the same name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for this project there are 17 other source &quot;.ino&quot; files. Looking at the main &quot;cameraAxe.ino&quot; file, it only #includes 2 files, &quot;EEPROM.h&quot; and &quot;DogmCA.h&quot;, both using the convention of enclosing the filename in angle brackets so the compiler knows to look in it's libraries directory. That makes perfect sense to me, and works like any other C compiler I've ever seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I &lt;strong&gt;DON'T&lt;/strong&gt; understand is how the compiler knows where to find the code for the many functions that are defined in other files in the same folder. There a function projectileMenu() which handles the menu for configuring a projectile sensor. That function is defined in the file menu01_projectile.ino, but it doesn't have a header, and there's no #include anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the compiler treat all the &quot;.ino&quot; files in your sketch folder as part of your source and compile them all together and as if they are one large file? I see tabs in the IDE for each of the files, which suggests that it does. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if there are dependencies among the files? What defines the order in which they are compiled? Or is it a 2 pass compiler where the order of function definitions doesn't matter? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;::wanders off, muttering in confusion::&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-13T21:44:04.777" Title="How does Arduino IDE for mac deal with functions in other files" Tags="|arduino-ide|c|build|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4181" PostTypeId="2" ParentId="4179" CreationDate="2014-09-13T18:55:32.440" Score="3" Body="&lt;p&gt;Yes, you can use a relay. However, you'll almost certainly need to drive the relay with a transistor because the current requirements of the relay will be too high for an Arduino pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better to use a logic MOSFET N-channel transistor as an electronic switch. You connect the Arduino's output pin to the gate of the transistor. You connect the + terminal of your 12 volt source to one end of the light, and connect the other wire from the light to the drain on the MOSFET. You then connect the source pin on the MOSFET to ground, and tie the ground of your Arduino to the 12 volt negative terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this setup, the MOSFET acts as a switch. When you switch the output pin of your Arduino to HIGH, the MOSFET turns on, providing a very low resistance path to ground. Current flows from the +12 volt supply, through the light, through the MOSFET, and to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the Arduino's output pin is low, the MOSFET acts as an open switch. There's no path to ground so the light is not lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't use PWM to lower 12 volts to 6 volts without some additional circuitry. PWM rapidly pulses the output from all the way on to all the way off. If you feed a PWM pin into a transistor, it can be used to create a higher voltage and/or current pulsed signal. However, pulsed DC is not the same thing as a lower DC voltage. You'd need to feed the pulsed 12 volts through a reservoir capacitor, perhaps 2 capacitors (and possibly a choke)  in order to average out the pulses into a lower DC voltage. That simple approach would work ok for powering a 6 volt incandescent light, but would not be good enough to power a solid state component because the output would not be even enough. It would have a fair amount of ripple and high frequency noise in it.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-13T18:55:32.440" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4182" PostTypeId="2" ParentId="4180" CreationDate="2014-09-13T21:25:39.187" Score="3" Body="&lt;p&gt;arduino has its own little .ino preprocessor that generates forward declarations (like in a header file) for all function in the project's .ino files. Most of the time this just makes things less confusing for new users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with the entire process, but the effect is that any function in any .ino is known to all other .ino code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything with .h or .cpp in a library or in the project file is treated as normal c++ code and not subject to arduino's manipulations. It will need &quot;#include&quot;s. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are interested, there is a hack to make arduino not mess with a function in a .ino file: add an empty &quot;throw()&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo() throw() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-13T21:44:04.777" LastActivityDate="2014-09-13T21:44:04.777" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4183" PostTypeId="1" AcceptedAnswerId="4184" CreationDate="2014-09-13T22:38:24.817" Score="0" ViewCount="375" Body="&lt;p&gt;I have a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00IMOSEJA&quot; rel=&quot;nofollow noreferrer&quot;&gt;GP2Y0A21YK0F Sharp IR Analog Distance Sensor 10-80cm + Cable, Arduino Compatible&lt;/a&gt; and its is connected to my Arduino. All works well and I can read the analog data with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define RX 2 // receive&#xA;#define TX 3 // transmit&#xA;#define SEN1 4&#xA;SoftwareSerial mySerial =  SoftwareSerial(RX, TX);&#xA;&#xA;void setup()  &#xA;{&#xA;&#xA;  mySerial.begin(4800);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;&#xA;   int reading = analogRead(SEN1);   &#xA;   mySerial.println(reading);&#xA;   delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NWzZQ.jpg&quot; alt=&quot;GP2Y0A21YK0F&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the code runs on the Attiny with the &lt;code&gt;GP2Y0A21YK0F&lt;/code&gt; IR Sensor connected, the Attiny84 resets over and over. The Attiny84 and &lt;code&gt;GP2Y0A21YK0F&lt;/code&gt; are part of the same circuit e.g. Attiny and &lt;code&gt;GP2Y0A21YK0F&lt;/code&gt; share the power and ground rail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I disconnect the &lt;code&gt;GP2Y0A21YK0F&lt;/code&gt;, the program runs and stops resetting. I was able to reproduce this on an Attiny85 and ATMega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The strange thing is, it works fine on the Arduino. Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-09-17T23:23:19.720" Title="Attiny84A and IR Sensor" Tags="|power|attiny|analogread|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4184" PostTypeId="2" ParentId="4183" CreationDate="2014-09-13T22:58:25.113" Score="3" Body="&lt;p&gt;It sounds like the microcontroller is browning out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IR sensors are notorious for taking a lot of power when they operate; often they will tax a small power supply and cause the voltage to droop low enough to reset/brownout the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try either putting a fairly beefy capacitor on the power bus, or getting a larger power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;edit&lt;/strong&gt;: I reverted another user's edit to this answer; &quot;droop&quot; is in fact the correct term for what is going on: &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_droop&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Voltage_droop&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="3979" LastEditorUserId="3979" LastEditDate="2014-09-17T23:23:19.720" LastActivityDate="2014-09-17T23:23:19.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4185" PostTypeId="2" ParentId="4135" CreationDate="2014-09-14T07:34:10.160" Score="1" Body="&lt;p&gt;Since the previous answers were all code-related, let me suggest you use a smoothing capacitor. In noisy environments, or where you want to get more consistent readings, place a capacitor across your signal lines (signal to ground). The result is less &quot;spikes&quot; in your readings, and can sometimes cause a slight delay in signal changes, as charge has to build up in the capacitor before the voltage goes up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor&quot; rel=&quot;nofollow&quot;&gt;http://www.learningaboutelectronics.com/Articles/What-is-a-smoothing-capacitor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3981" LastActivityDate="2014-09-14T07:34:10.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4186" PostTypeId="1" CreationDate="2014-09-14T18:30:03.537" Score="2" ViewCount="357" Body="&lt;p&gt;I am working on assembling the ROFI robot from Project Biped (&lt;a href=&quot;http://www.projectbiped.com/prototypes/rofi&quot; rel=&quot;nofollow&quot;&gt;http://www.projectbiped.com/prototypes/rofi&lt;/a&gt;) and I have not been able to run any arduino program as they will not function correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be more specific, when I attempt to run 12 servos on a single Arduino Mega, the servos twitch uncontrollably and do not move to the positions which are set in the program.  At the same time the power light on the arduino mega blinks and does not turn solid (as opposed to if I use less than 11 servos when the pwr light is solid).  I predict it might be the power source but after checking the batteries with the multimeter they check out to be fine (7.6 V).  The circuit is pretty simple, I am using a servo shield connected to a 6V regulator connected in parallel to two 7.2 V 1350 mah LiPo batteries.  The arduino is connected through the dc power jack to the same circuit in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   #include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;// 0 Right Ankle (roll)&#xA;// 1 Right Lower Leg &#xA;// 2 Right Knee &#xA;// 3 Right Middle Leg &#xA;// 4 Right Upper Leg &#xA;// 5 Right Hip (roll)&#xA;//LEFT LEG JOINTS&#xA;// 6 Left Ankle (roll)&#xA;// 7 Left Lower Leg &#xA;// 8 Left Knee &#xA;// 9 Left Middle Leg &#xA;// 10 Left Upper Leg &#xA;// 11 Left Hip (roll)&#xA;&#xA;int c=0;&#xA;&#xA;Servo rightAnkle;&#xA;Servo lowerLeg;&#xA;Servo rightKnee; &#xA;Servo rightMiddleLeg; &#xA;Servo rightUpperLeg; &#xA;Servo rightHip;&#xA;Servo leftAnkle;&#xA;Servo leftLowerLeg; &#xA;Servo leftKnee; &#xA;Servo leftMiddleLeg; &#xA;Servo leftUpperLeg; &#xA;Servo leftHip;&#xA;&#xA;void setup(){&#xA;  rightAnkle.attach(0);&#xA;  lowerLeg.attach(1);&#xA;  rightKnee.attach(2); &#xA;  rightMiddleLeg.attach(3);&#xA;  rightUpperLeg.attach(4);&#xA;  rightHip.attach(5);&#xA;  leftAnkle.attach(6);&#xA;  leftLowerLeg.attach(7);&#xA;  //leftKnee.attach(8); &#xA;  //leftMiddleLeg.attach(9); &#xA;  leftUpperLeg.attach(10); &#xA;  leftHip.attach(11);&#xA;}&#xA;&#xA;void loop(){&#xA;  rightAnkle.write(90);&#xA;  lowerLeg.write(90);&#xA;  rightKnee.write(90);&#xA;  rightMiddleLeg.write(90);&#xA;  rightUpperLeg.write(90);&#xA;  rightHip.write(100);&#xA;  leftAnkle.write(90);&#xA;  leftLowerLeg.write(90); &#xA;  leftKnee.write(90); &#xA;  leftMiddleLeg.write(90); &#xA;  leftUpperLeg.write(90); &#xA;  leftHip.write(90);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3985" LastActivityDate="2017-08-18T17:05:30.157" Title="Servo library unable to control more than 11 servos" Tags="|arduino-mega|servo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4188" PostTypeId="1" AcceptedAnswerId="4191" CreationDate="2014-09-14T22:01:20.343" Score="1" ViewCount="225" Body="&lt;p&gt;i'm a little new in this.&#xA;I have an alarm system panel which has TX,RX wires with 12V output/input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can i  read the output with arduino and control it with serial communication?&lt;/p&gt;&#xA;" OwnerUserId="3765" LastActivityDate="2014-09-15T03:41:11.097" Title="How to serial connect arduino galileo to alarm system" Tags="|serial|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4189" PostTypeId="2" ParentId="4186" CreationDate="2014-09-14T22:39:07.713" Score="1" Body="&lt;p&gt;It sounds to me like you're exceeding the current limits of your power supply. Add up the current drawn by your servos (and their controller(s), and also the current drawn by your Arduino and any other circuits you have. I bet you'll find that at 12 servos, you go over the current limit of your regulator. You might need a higher current regulator or a second one.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-14T22:39:07.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4191" PostTypeId="2" ParentId="4188" CreationDate="2014-09-15T03:41:11.097" Score="1" Body="&lt;p&gt;First of all, you'll need to make sure this is UART and not another protocol. Don't worry, if it's not UART the worst thing that could happen is jumbled data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, you will need a 12v to 5v (or 3.3v) logic level shifter. When you have that you'll need to connect the Arduino to the system through the level shifter to pins 0/1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't know what you'll receive or can send without looking at the serial output and doing a little tinkering. You don't even know what the serial port does. It could just be for setting up the system. &lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-09-15T03:41:11.097" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4192" PostTypeId="2" ParentId="3284" CreationDate="2014-09-15T04:27:01.397" Score="1" Body="&lt;p&gt;Sonar modules are notorious for pulling so much instantaneous power during their brief pulses that they often reset the processor, causing the Arduino to start all over from the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any way of knowing whether your program is executing more-or-less normally, or if your program in the Arduino is getting reset?&#xA;If not, you need better debugging tools.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;(tangential rant about debugging tools)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Many people debug by sprinkling their code with print(F()) statements that get sent to a LCD screen or a serial port.&#xA;Other people debug by sprinking their code with statements that turn on and off a series of LEDs of various colors, or at least a single LED with a (hopefully easy-to-decode) blink code.&#xA;Some kinds of problems are much easier to track down with an oscilloscope.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;dealing with high-current pulses&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My best guess is that the sonar is pulling very brief high-current pulses from the battery, which causes the battery voltage to droop low enough to reset the Arduino.&#xA;When the USB cable is plugged in, (I'm guessing that) the additional power supplied by the USB cable somehow keeps the Arduino from resetting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many sonar modules (very briefly) pull 1 A or 2 A, far more than a USB cable or a handful of AA batteries can supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many ways to solve that problem, but if I were you I would first see if that is really the problem in this case.&#xA;Possibly the quickest way to tell is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use at least 2 separate battery packs.&lt;/li&gt;&#xA;&lt;li&gt;Hook all the grounds of all the battery packs and all the devices together.&lt;/li&gt;&#xA;&lt;li&gt;hook the positive power of one battery pack to the Arduino and nothing else.&lt;/li&gt;&#xA;&lt;li&gt;Hook the power lead of all the other devices to some other battery pack (ideally a different battery pack for each device).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then run the test again.&#xA;This should give you a clue as to whether the problem is the Arduino seeing power-supply droop (which separate battery packs should &quot;fix&quot;), or something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem really is power supply droop, there are a variety of ways to fix it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(a) Many people recommend: use a large 1000 uF capacitor directly across the power pins of the sonar, and a 10 Ohm or 100 Ohm resistor between the battery positive and that capacitor. &lt;a href=&quot;http://diydrones.com/forum/topics/sonar-noise-reduction-update&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,146260.0.html&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt; &lt;a href=&quot;http://www.societyofrobots.com/sensors_sonar.shtml&quot; rel=&quot;nofollow&quot;&gt;(c)&lt;/a&gt; &lt;a href=&quot;http://www.uoxray.uoregon.edu/polamod/&quot; rel=&quot;nofollow&quot;&gt;(d)&lt;/a&gt; &lt;a href=&quot;https://www.zagrosrobotics.com/sonar.htm&quot; rel=&quot;nofollow&quot;&gt;(e)&lt;/a&gt; &lt;a href=&quot;http://david.carybros.com/html/ultrasonic.html&quot; rel=&quot;nofollow&quot;&gt;(f)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;(b) Use a large capacitor directly across the power pins of the Arduino, and a diode from the battery to that capacitor so that normally the diode allows the battery to charge the capacitor, but when the sonar or whatever briefly drags the battery voltage to a low level, the diode blocks the sonar from pulling energy &quot;backwards&quot; out of that capacitor, and the capacitor is large enough to run the Arduino during the sonar pulse.&lt;/li&gt;&#xA;&lt;li&gt;(c) Get a dedicated &quot;logic&quot; battery array to power the Arduino and a few LEDs, etc., and a separate (often much larger) &quot;dirty power&quot; battery array to power the sonar, motors, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-09-15T04:27:01.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4193" PostTypeId="1" CreationDate="2014-09-15T12:17:01.003" Score="1" ViewCount="223" Body="&lt;p&gt;I working on a prototype with an Arduino UNO and an &lt;a href=&quot;https://www.adafruit.com/products/1697&quot; rel=&quot;nofollow&quot;&gt;AdaFruit Low Energy Blue tooth&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an array of uint32_t that I am trying to send via blue tooth to a given device.  I don't think i can send the array so I was trying to send it as a comma separated string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can print out each individual index of that array just fine, but its completely blank when i try to make a comma separated String..  See code and comments below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Ay Array:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t items[]= {0,3513728,7925384,0,0,0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In My Loop:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String output = &quot;&quot;;&#xA;&#xA;for(int i = 0; i&amp;lt;6;  i++){&#xA;&#xA;  BTLEserial.print(items[i]); // Prints as expected&#xA;  output += getStringForUI32_T(items[i]);&#xA;  output+=&quot;,&quot;;&#xA;&#xA; }&#xA; BTLEserial.print(output); // prints BLANK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I imagine this has something to do with memory but I am at a complete loss.. Please help!&lt;/p&gt;&#xA;" OwnerUserId="3875" LastActivityDate="2018-05-02T01:15:50.623" Title="Blank Serial Print AdaFruit BTLE" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4194" PostTypeId="1" CreationDate="2014-09-15T14:20:02.620" Score="2" ViewCount="4906" Body="&lt;p&gt;There are existing projects that allow the Uno and other devices using the ATmega8u2 to operate as a USB MIDI HID, such as &lt;a href=&quot;http://morecatlab.akiba.coocan.jp/morecat_lab/MocoLUFA.html&quot; rel=&quot;nofollow&quot;&gt;MocoLUFA&lt;/a&gt;. Unfortunately, as far as I am aware, these require uploading new firmware that isn't compatible with programming via the Arduino UI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any similar projects for the ATmega32u4 (Leonardo, Micro)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use an Arduino as a USB MIDI HID, while still being able to program it as normal? &lt;/p&gt;&#xA;" OwnerUserId="3988" LastEditorUserId="11" LastEditDate="2014-09-15T15:28:20.637" LastActivityDate="2016-06-22T20:10:46.047" Title="USB MIDI HID with the ATmega32u4?" Tags="|arduino-leonardo|firmware|atmega32u4|midi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4195" PostTypeId="2" ParentId="4193" CreationDate="2014-09-15T14:56:39.513" Score="1" Body="&lt;p&gt;I'd probably do it directly like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i&amp;lt;6;  i++) {&#xA;  BTLEserial.print(items[i]);&#xA;  BTLEserial.print(',');&#xA;}&#xA;BTLEserial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But with the string I think it would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String output = &quot;&quot;;&#xA;&#xA;for(int i = 0; i&amp;lt;6;  i++) {&#xA;  output += getStringForUI32_T(items[i]);&#xA;  output+=&quot;,&quot;;&#xA;}&#xA;BTLEserial.println(output[0]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as someone else got it working using String on your adafruit thread maybe this is just barking up the wrong tree.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2015-01-15T06:24:40.463" LastActivityDate="2015-01-15T06:24:40.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4196" PostTypeId="1" AcceptedAnswerId="4197" CreationDate="2014-09-15T15:18:12.963" Score="8" ViewCount="2769" Body="&lt;p&gt;I just ran into this article: &lt;a href=&quot;http://playground.arduino.cc/Learning/WhatAdapter&quot;&gt;Arduino: What adapter?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says that the external power supply should be 9-12V. That really surprises me, since my Arduino Uno can also be powered via USB, which is 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later he talks about a 9V pin. But I can only see a 5V and 3.3V pin on mine. Is he talking about a different version of Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Judging from the picture, his Arduino looks slightly different from my Arduino Uno R3, but I can't tell which version is on the picture.&lt;/p&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2014-11-24T17:40:34.917" Title="Power supply voltage confusion" Tags="|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4197" PostTypeId="2" ParentId="4196" CreationDate="2014-09-15T15:27:57.203" Score="9" Body="&lt;p&gt;The board has a voltage regulator which converts 9-12V to the 5V that the chip uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does it need 9V if the board works at 5V? Well, it doesn't need 9 exactly, but it needs something greater than 5. The reason for this is that the regulator has whats called a &lt;a href=&quot;http://en.wikipedia.org/wiki/Dropout_voltage&quot;&gt;dropout voltage&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot;&gt;schematic of the Uno&lt;/a&gt; we see it uses a &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/NCP1117-D.PDF&quot;&gt;NCP1117&lt;/a&gt;, which has a dropout of 1.2V. So the minimum voltage you can give it to get 5V is 6.2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 9V pin is the Vin pin which is at the same level as the input voltage (before converting).&lt;/p&gt;&#xA;" OwnerUserId="11" LastEditorUserId="11" LastEditDate="2014-09-15T16:25:47.813" LastActivityDate="2014-09-15T16:25:47.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4199" PostTypeId="1" CreationDate="2014-09-15T18:16:47.150" Score="1" ViewCount="5431" Body="&lt;p&gt;While wiring up my new Arduino Uno R3 on a proto-board, I accidentally shorted the 5V pin directly to Ground. The LED's immediately turned off and connection was lost. It was powered by USB connection. After 3-5 seconds I removed the short. The LED's have remained out, and I haven't been able to reestablish connection with my computer since. I've unplugged and re-plugged the USB cable and tried the re-set button plenty of times. This short shouldn't have fried the board...  what happened? How can I get my Arduino working again??&lt;/p&gt;&#xA;" OwnerUserId="3994" LastActivityDate="2014-11-13T12:45:36.527" Title="Arduino Uno R3 not working after shorting 5V to GND" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4200" PostTypeId="1" AcceptedAnswerId="4201" CreationDate="2014-09-15T22:40:19.723" Score="2" ViewCount="4886" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qIFWb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bZxmF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int MAX_LENGTH = 2;&#xA;char buffer[MAX_LENGTH];&#xA;char lineFeed = 2;&#xA;&#xA;SoftwareSerial   Xbee(10, 11);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Xbee.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int length = Serial.readBytesUntil(lineFeed, buffer, MAX_LENGTH);&#xA;  int i = 0;&#xA;  while( i &amp;lt; length )&#xA;  { &#xA;    Serial.print(buffer[i]-48); &#xA;    Xbee.print(buffer[i]-48);  &#xA;    i++;&#xA;  }        &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_LENGTH = 2;&#xA;char buffer[MAX_LENGTH];&#xA;char lineFeed = 2;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int length = Serial.readBytesUntil(lineFeed, buffer, MAX_LENGTH);&#xA;  int i = 0;&#xA;&#xA;  while( i &amp;lt; length )&#xA;  { &#xA;    Serial.print(buffer[i]-48);&#xA;    i++;&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- The Rx xbee is receiving data even if am not sending and even if the TX xbee is powered off&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- When i send data from the TX xbee id didn't get revived by the RX xbee &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to solve both problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*** What i need exactly is to send serial data from my pc to arduino and send it wireless through xbee and then receive to the other arduino connected to my circuit   &lt;/p&gt;&#xA;" OwnerUserId="3936" LastEditorUserId="3936" LastEditDate="2014-09-16T16:14:56.420" LastActivityDate="2016-07-27T00:56:32.923" Title="Receiver xbee receiving data even if the Transmitter is not sending?" Tags="|arduino-uno|xbee|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4201" PostTypeId="2" ParentId="4200" CreationDate="2014-09-16T00:46:03.643" Score="2" Body="&lt;p&gt;The reason that it is printing characters with no input is that the readBytesUntil function has a timeout. If no new characters are received for a certain amount of time, &quot;Serail.setTimeout()&quot; seconds, it will just continue with the code. the default timeout is 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason you are not receiving what you transmit (or at least a reason) is that the RX code does not read from an xbee, but reads from regular &quot;serial&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you try something simple first to test the xbee's configuration, like having TX run this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;    xbee.println(&quot;Hello&quot;);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and RX run something to echo serial like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void loop(){&#xA;     if(xbee.available()){&#xA;         Serial.print((char)xbee.read());&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And make sure you set up an xbee object an the receiving side first.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-16T01:31:48.730" LastActivityDate="2014-09-16T01:31:48.730" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4202" PostTypeId="1" CreationDate="2014-09-16T01:29:55.923" Score="0" ViewCount="5218" Body="&lt;p&gt;I'm writing a software that can receive data from Arduino via Bluetooth. My software is pretty fine now, at least it can pair with my hardware but when I try to test whether it can receive data via Bluetooth, I'm stuck. My Arduino receives temperature readings from a sensor at Analog pin 0. My Bluetooth module HC-05 connects with Arduino at Digital 0 and 1 (RX and TX pin respectively, as default). I don't know how to push data from Analog pin 0 to the Bluetooth module. Thanks in advance for any suggestion.&lt;/p&gt;&#xA;" OwnerUserId="3996" LastActivityDate="2016-10-21T15:39:16.430" Title="how to push data from an Arduino pin to Bluetooth module" Tags="|arduino-uno|bluetooth|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4203" PostTypeId="2" ParentId="4196" CreationDate="2014-09-16T03:46:12.173" Score="7" Body="&lt;p&gt;And the third part of your question: It is possible to bypass the voltage regulator and feed REGULATED 5 volts directly to the 5V pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's how the Arduino is powered using USB. The USB power is already regulated 5V, and is fed directly to the 5V pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware of doing this yourself however. You better be certain the 5V you're feeding in is a clean, filtered and regulated 5V. If it's not you run the risk of destroying your Arduino (and possibly anything connected to it's 5V lines.)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-11-24T17:40:34.917" LastActivityDate="2014-11-24T17:40:34.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4204" PostTypeId="1" AcceptedAnswerId="4205" CreationDate="2014-09-16T04:32:42.277" Score="2" ViewCount="5574" Body="&lt;p&gt;Just to make sure I don't set my board on fire, is there any information out there about the maximum current per pin/pin group on an Arduino Micro? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/arduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;This page&lt;/a&gt; states I can get 40mA per pin, but are there limits on group of pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As stated &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,148734.0.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, there are pin groups which should not exceed 100mA. But could not find anything about that in the ATmega32u4 datasheet, or any other Arduino Micro related websites.&lt;/p&gt;&#xA;" OwnerUserId="3998" LastEditorUserId="42" LastEditDate="2014-09-16T08:09:40.360" LastActivityDate="2014-09-16T08:09:40.360" Title="What are the current limits on an Arduino Micro?" Tags="|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4205" PostTypeId="2" ParentId="4204" CreationDate="2014-09-16T04:39:51.530" Score="4" Body="&lt;p&gt;It's in the notes in section 29.2:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state&#xA;  conditions (non-transient), the following must be observed:&lt;br&gt;&#xA;  ATmega16U4/ATmega32U4:&lt;br&gt;&#xA;  1.)The sum of all IOL, for ports A0-A7, G2, C4-C7 should not exceed 100 mA.&lt;br&gt;&#xA;  2.)The sum of all IOL, for ports C0-C3, G0-G1, D0-D7 should not exceed 100 mA.&lt;br&gt;&#xA;  3.)The sum of all IOL, for ports G3-G5, B0-B7, E0-E7 should not exceed 100 mA.&lt;br&gt;&#xA;  4.)The sum of all IOL, for ports F0-F7 should not exceed 100 mA.&lt;br&gt;&#xA;  If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater&#xA;  than the listed test condition.&lt;/li&gt;&#xA;  &lt;li&gt;Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady&#xA;  state conditions (non-transient), the following must be observed:&lt;br&gt;&#xA;  ATmega16U4/ATmega32U4:&lt;br&gt;&#xA;  1)The sum of all IOH, for ports A0-A7, G2, C4-C7 should not exceed 100 mA.&lt;br&gt;&#xA;  2)The sum of all IOH, for ports C0-C3, G0-G1, D0-D7 should not exceed 100 mA.&lt;br&gt;&#xA;  3)The sum of all IOH, for ports G3-G5, B0-B7, E0-E7 should not exceed 100 mA.&lt;br&gt;&#xA;  4)The sum of all IOH, for ports F0-F7 should not exceed 100 mA.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the device will likely not &lt;em&gt;fail&lt;/em&gt; if these are exceeded, but the rest of the numbers in the table may no longer apply.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-16T04:39:51.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4206" PostTypeId="1" CreationDate="2014-09-16T09:30:53.640" Score="0" ViewCount="6595" Body="&lt;p&gt;I am trying to send command serially through Vb.through serial monitor working fine . But Through VB it not detecting port&#xA;&lt;strong&gt;My arduino code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 2; // the number of the LED pin&#xA;&#xA;void setup() {&#xA;Serial.begin(9600); // set serial speed&#xA;pinMode(ledPin, OUTPUT); // set LED as output&#xA;digitalWrite(ledPin, LOW); //turn off LED&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;while (Serial.available() == 0); // do nothing if nothing sent&#xA;int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number&#xA;&#xA;if (val == 1) { // test for command 1 then turn on LED&#xA;Serial.println(&quot;LED on&quot;);&#xA;digitalWrite(ledPin, HIGH); // turn on LED&#xA;}&#xA;else if (val == 0) // test for command 0 then turn off LED&#xA;{&#xA;Serial.println(&quot;LED OFF&quot;);&#xA;digitalWrite(ledPin, LOW); // turn off LED&#xA;}&#xA;else // if not one of above command, do nothing&#xA;{&#xA;//val = val;&#xA;Serial.println(&quot;Wrong command&quot;);&#xA;}&#xA;Serial.println(val);&#xA;Serial.flush(); // clear serial port&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;VB Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Imports System.IO&#xA;Imports System.IO.Ports&#xA;Imports System.Threading&#xA;&#xA;Public Class Form1&#xA;    Shared _continue As Boolean&#xA;&#xA;&#xA;    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&#xA;&#xA;        SerialPort1.Open()&#xA;        SerialPort1.PortName = &quot;COM3&quot;&#xA;&#xA;        SerialPort1.BaudRate = 9600&#xA;        SerialPort1.DataBits = 8&#xA;        SerialPort1.Parity = IO.Ports.Parity.None&#xA;        SerialPort1.StopBits = IO.Ports.StopBits.One&#xA;        SerialPort1.Handshake = IO.Ports.Handshake.None&#xA;        SerialPort1.Encoding = System.Text.Encoding.Default 'very important!&#xA;&#xA;    End Sub&#xA;&#xA;&#xA;    Private Sub Button1_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_Click.Click&#xA;        SerialPort1.Open()&#xA;        SerialPort1.Write(&quot;1&quot;)&#xA;        SerialPort1.Close()&#xA;    End Sub&#xA;&#xA;&#xA;&#xA;    Private Sub Button2_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_Click.Click&#xA;        SerialPort1.Open()&#xA;        SerialPort1.Write(&quot;0&quot;)&#xA;        SerialPort1.Close()&#xA;    End Sub&#xA;&#xA;&#xA;End Class&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error I am getting .Arduino port is 3. and configured to port 3 . i dont know why it giving error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;The port 'com10' does not exist.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This Line added as you said&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Private Sub Current_Read_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&#xA;        SerialPort1.Open()&#xA;        Dim str As String&#xA;        str = SerialPort1.ReadExisting&#xA;        Current_Read.Text = str&#xA;        SerialPort1.Close()&#xA;    End Sub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is working But data not being updating&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Private Sub Current_Read_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&#xA;        Current_Read.Text =SerialPort1.ReadLine&#xA;    End Sub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="904" LastEditDate="2014-09-17T06:25:20.833" LastActivityDate="2014-09-17T06:25:20.833" Title="Arduino and visual basic Serial data" Tags="|arduino-uno|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4207" PostTypeId="2" ParentId="4206" CreationDate="2014-09-16T10:22:19.957" Score="1" Body="&lt;p&gt;You've opened the port before you've configured it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-16T10:22:19.957" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4208" PostTypeId="2" ParentId="812" CreationDate="2014-09-16T11:03:31.070" Score="0" Body="&lt;p&gt;Use the Arduino to set the start and stop time. Always leave the heater switched on and use something like the 'Mains Switch widget' from SF innovations to control the mains. This unit has a mains relay, is fused to protect against fire and is enclosed in a plastic case.&#xA;&lt;a href=&quot;http://www.sf-innovations.co.uk/mains-switch-widget.html&quot; rel=&quot;nofollow&quot;&gt;http://www.sf-innovations.co.uk/mains-switch-widget.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4000" LastActivityDate="2014-09-16T11:03:31.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4209" PostTypeId="2" ParentId="235" CreationDate="2014-09-16T11:48:20.540" Score="2" Body="&lt;p&gt;Playing with mains is dangerous - so best to use a kit designed for that purpose. Be careful with units designed in the US - their safety requirements are a bit different from UK and Europe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the Power Switch Tail kits do not include a fuse - if the appliance being controlled goes faulty and starts drawing a bigger current, the switch could burn up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one designed with Uk safety features in mind:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.sf-innovations.co.uk/mains-switch-widget.html&quot; rel=&quot;nofollow&quot;&gt;http://www.sf-innovations.co.uk/mains-switch-widget.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4001" LastActivityDate="2014-09-16T11:48:20.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4210" PostTypeId="1" CreationDate="2014-09-16T12:31:50.927" Score="2" ViewCount="540" Body="&lt;p&gt;I need to incorporate a battery monitor using a 10 led bar graph. I am powering the arduino with a 7.4(though it reads 7.67) V  lithium polymer battery through the arduino`s power jack. The goal is to monitor that battery. How would I go about doing this? I have a LM3914 driver to use if I want but I am clueless as to what to do.&lt;/p&gt;&#xA;" OwnerUserId="3912" LastEditorUserId="3912" LastEditDate="2014-09-16T13:49:51.183" LastActivityDate="2014-09-17T00:16:48.383" Title="Battery Monitoring System for Arduino" Tags="|battery|" AnswerCount="0" CommentCount="2" ClosedDate="2017-11-20T05:20:18.740" ContentLicense="CC BY-SA 3.0" />
  <row Id="4211" PostTypeId="2" ParentId="4199" CreationDate="2014-09-16T16:17:24.323" Score="6" Body="&lt;p&gt;Have you tried restarting the computer? The computer will shut down the USB port to protect it from a malfunction like this (over-current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also try the ports on the other side of the computer (or front/back) as they're usually on different controllers.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-09-16T16:17:24.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4212" PostTypeId="2" ParentId="4202" CreationDate="2014-09-16T19:17:49.473" Score="1" Body="&lt;p&gt;The HC-05 looks like like any other terminal to the Arduino so any serial operations that you would use for a wired terminal can be used with the HC-05. See the HC-05's manual for how to set it up initially. Note that HC-05s don't forget their settings and they have no reset command to put them into a known state, so write down your settings for your future reference.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- Read the analog pin value;&#xA;- Convert the value into whatever physical units you require;&#xA;- Print the result with Serial.print() or Serial.println()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:  You wrote that your HC-05 is connected to Digital 0 and 1, but you created your SoftwareSerial, &lt;code&gt;mySerial&lt;/code&gt;, to transmit on Digital 11. In that case your HC-05's receive pin must be connected to Digital 11.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-09-20T23:53:37.993" LastActivityDate="2014-09-20T23:53:37.993" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4213" PostTypeId="1" CreationDate="2014-09-16T21:04:49.107" Score="0" ViewCount="161" Body="&lt;p&gt;My receiver xbee is receiving data even if the transmitter is disconnected , so if i am sending the string hello world , the receiver will repeat this string . &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    Serial.println(&quot;Hello&quot;);&#xA;    delay(1000);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;     if(Serial.available()&amp;gt;0){&#xA;         Serial.print((char)Serial.read());&#xA;     }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3936" LastEditorUserId="1566" LastEditDate="2014-09-24T12:18:28.577" LastActivityDate="2014-09-24T13:25:25.027" Title="Receiver xbee receiving data while the Transmitter is powered off?" Tags="|arduino-uno|xbee|c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4214" PostTypeId="1" CreationDate="2014-09-16T23:52:51.910" Score="23" ViewCount="24083" Body="&lt;p&gt;Every time I design a serial protocol to be used between two arduinos, I feel a bit like I'm reinventing a wheel. I wonder if there are any best practices or patterns people follow. This question is less about the actual code, but more about the format of the messages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I wanted to tell an arduino to flash it's first LED 3 times I might send:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;^L1,F3\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;'^': starts a new command&lt;/li&gt;&#xA;&lt;li&gt;'L': Defines the command, (L: target this command to an LED)&lt;/li&gt;&#xA;&lt;li&gt;'1': Target the first LED&lt;/li&gt;&#xA;&lt;li&gt;',': Command line separator, new value in this message to follow&lt;/li&gt;&#xA;&lt;li&gt;'F': Flash sub-command&lt;/li&gt;&#xA;&lt;li&gt;'3': 3 times (Flash the LED three times)&lt;/li&gt;&#xA;&lt;li&gt;'\n': End the command&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thoughts? How do you usually approach writing a new serial protocol? What about if I wanted to send a query from arduino 1 to arduino 2 and then receive a response?&lt;/p&gt;&#xA;" OwnerUserId="3819" LastEditorUserId="3819" LastEditDate="2015-03-03T00:12:13.480" LastActivityDate="2016-10-07T14:04:10.083" Title="Communication Protocol Best Practices and Patterns" Tags="|serial|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4217" PostTypeId="2" ParentId="4214" CreationDate="2014-09-17T02:13:55.520" Score="10" Body="&lt;p&gt;I do not have any formal expertise on serial protocols, but I've used them quite a few times, and more or less settled on this scheme:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Packet header)(ID byte)(data)(fletcher16 checksum)(Packet Footer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually make the header 2 bytes and the Footer 1 byte. My parser will dump everything when it sees a new packet header, and attempt to parse the message if it sees a footer. If the checksum fails, it will not ditch the message, but continue adding until the footer character is found and a checksum succeeds. That way the footer only needs to be one byte since collisions don't disrupt the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ID is arbitrary, sometimes with the length of the data section being the bottom nibble (4 bits). A second length bit could be used but I normally don't bother since the length does not need to be known to parse correctly, so seeing the right length come through for a given ID is just more confirmation that the message was correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fletcher16 checksum is a 2 byte checksum with nearly the same quality as CRC but is much easier to implement. some details &lt;a href=&quot;https://en.wikipedia.org/wiki/Fletcher&amp;#39;s_checksum&quot;&gt;here&lt;/a&gt;. The code can be as simple as this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i=0; i &amp;lt; bufSize; i++ ){&#xA;   sum1 = (sum1 + buffer[i]) % 255;&#xA;   sum2 = (sum2 + sum1) % 255;&#xA;}&#xA;uint16_t checksum = (((uint16_t)sum1)&amp;lt;&amp;lt;8) | sum2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also used a call and respone system for critical messages, Where the PC will send a message every 500ms or so until it gets an OK message with a checksum of the whole original message as data (including the original checksum). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This scheme is, of course, not well suited for being typed into a terminal like your example would be.  Your protocol seems pretty good for being limited to ASCII and I'm sure is easier for a quick project that you want to be able to directly read and send messages. For larger projects it is nice to have the density of a binary protocol and the security of a checksum.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-17T05:17:54.710" LastActivityDate="2014-09-17T05:17:54.710" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4218" PostTypeId="1" AcceptedAnswerId="4221" CreationDate="2014-09-17T02:19:33.640" Score="2" ViewCount="3930" Body="&lt;p&gt;I am a novice Arduino programmer and am currently having trouble with a SH5461AS 4-digit/7-segment LED when using it with an Arduino Uno. I have struggled to find an accurate datasheet/tutorial of any kind for this particular model (It is the LED without the colons in between digits 2 and 3) but I believe I have it figured out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have it going through a HC595 shift register but when I removed the register and connected the LED directly to the board the problem remained. My code below is with the shift register; I am displaying it this way because it is simpler to view and I thought it would make it easier to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can display a single digit at a time correctly. However, when I try to display 2+ digits at one time, they are in the incorrect order.&#xA;For example, I can count 1-9 on the first digit, then 1-9 on the 2nd digit, and so on and everything displays correctly (other digits are off). But as soon as I try to display multiple digits they are in the wrong order. So if I try to display 12__ with the last 2 digits off, 21__ is displayed with the last two digits off. If I try to display &lt;em&gt;23&lt;/em&gt;, &lt;em&gt;32&lt;/em&gt; is displayed. If I try to display 1234, 4123 is displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am at a loss because the code seems like it should be simple.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int DATA = 0;&#xA;const int LATCH = 1;&#xA;const int CLOCK = 2;&#xA;&#xA;const int DIGIT_ONE = 3;&#xA;const int DIGIT_TWO = 4;&#xA;const int DIGIT_THREE = 5;&#xA;const int DIGIT_FOUR = 6;&#xA;&#xA;//digits[0-9] corresponds to the patterns for numbers 0 -&amp;gt; 9.&#xA;//Add 1 to the digits[X] to turn on the dot.&#xA;byte digits[] = {B11111100, B00011000, B01101110, B00111110, B10011010, B10110110, B11110010, B00011100, B11111110, B10111110};&#xA;&#xA;void setup() {&#xA;  pinMode(DATA, OUTPUT);&#xA;  pinMode(CLOCK, OUTPUT);&#xA;  pinMode(LATCH, OUTPUT);&#xA;&#xA;  pinMode(DIGIT_ONE, OUTPUT);&#xA;  pinMode(DIGIT_TWO, OUTPUT);&#xA;  pinMode(DIGIT_THREE, OUTPUT);&#xA;  pinMode(DIGIT_FOUR, OUTPUT);&#xA;&#xA;  digitalWrite(DIGIT_ONE, HIGH);&#xA;  digitalWrite(DIGIT_TWO, HIGH);&#xA;  digitalWrite(DIGIT_THREE, HIGH);&#xA;  digitalWrite(DIGIT_FOUR, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  writeDigit(DIGIT_TWO, 2);&#xA;  writeDigit(DIGIT_THREE, 3);&#xA;}&#xA;&#xA;/*&#xA; * Write a digit to the 4-digit 7-segment LED&#xA; * - digitPin corresponding to the pin on the LED to light up the correct digit.&#xA; * - number 0-9 to display on the LED&#xA; */&#xA;void writeDigit(int digitPin, int number) {&#xA;  digitalWrite(digitPin, LOW);&#xA;&#xA;  digitalWrite(LATCH, LOW);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);&#xA;  digitalWrite(LATCH, HIGH);&#xA;&#xA;  digitalWrite(digitPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in this instance, I am expecting &lt;em&gt;23&lt;/em&gt; but &lt;em&gt;32&lt;/em&gt; is displaying instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also having trouble with some bleeding (I don't know what the correct term is) where some segments are very faintly glowing even though I am not doing it intentionally. This is a much smaller issue, however, than digits randomly in the wrong order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it would help, I can try to post the circuit diagram as well.&lt;/p&gt;&#xA;" OwnerUserId="3827" LastEditorUserId="3827" LastEditDate="2014-09-17T02:40:09.557" LastActivityDate="2016-04-07T06:00:46.443" Title="4-digit 7 Segment LED displaying numbers in the wrong order" Tags="|arduino-uno|programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4219" PostTypeId="1" CreationDate="2014-09-17T02:22:52.643" Score="4" ViewCount="1879" Body="&lt;p&gt;I'm setting up a grid of 200+ slave modules which will be about 12 inches apart and the master will be anywhere from 5 to 10 meters away from the closest module. Each slave module will have a ATtiny85 to manage the sensor reading, LEDs and the network protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The communication packets will be small and will probably be at 115200 baud if using ATTiny85's TTL serial or 1MHz if using SPI. In either case, the modules will be connected in a daisy chain to each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each module will have a resistive touch sensor and be driving about 12 - 16 RGB LEDs (I'm making a step responsive disco dance floor). There will be 12v+ running to each module to drive the LEDs and regulated down to 5V for the ATtiny.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which brings me to my question. With these constraints, do you think the ATtiny85's built-in serial or SPI would still work well over the 5 to 10 meters from the closest module to the master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know some people push towards RS422 or RS485 transceivers for distance applications, but I'd like to keep the total part count down, if possible.&lt;/p&gt;&#xA;" OwnerUserId="3819" LastActivityDate="2014-10-01T06:37:49.927" Title="Distance and Serial or SPI" Tags="|serial|spi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4220" PostTypeId="2" ParentId="4218" CreationDate="2014-09-17T02:52:57.300" Score="1" Body="&lt;p&gt;I found the data sheet here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AK2B-35.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AK2B-35.pdf&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a horrible bit of writing. Not at all clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like it's multiplexed. You use pins 14, 16, 13, 3, 5, 11, 15, and 7 as the cathodes for the segments on a digit (ground the pins for the segments you want to light.) Pin 7 appears to be the decimal place for a given digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the pins 1, 2, 6, or 8 should be fed a +5V to light a particular digit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other pins control the colons and other dots on the display. Let's ignore those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To light the display here's what I THINK you would do (I'm tired, and didn't study the data sheet that closely, so I may may be wrong here)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For pins 14, 16, 13, 3, 5, 11, 15, and 7: These are the cathodes for the segments in the current digit you are driving. Set the pins you want to light as digital outputs, LOW. Set the others as inputs, which will make them essentially open circuits. The selected pins will be grounded, and the ones set as inputs will not be connected to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pull pin 1 HIGH to light the selected segments in digit 1. Put it back low, set the segment pins, then pull pin 2 HIGH to light that digit. Repeat, pulling pins 6 and 8 high to light the selected segments in digits 3 and 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd have to cycle rapidly through the digits, lighting 1 at a time, in order to make them appear all lit at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get that working first without using shift registers. (It will take 11 I/O lines to drive all 4 digits and their decimal places - 1 less if you don't care about the decimal place.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that if your drive all the pins using a shift register then some of the unlit segments will be fed reverse voltage. (When set as an output, sending a LOW connects the output pin to ground, and setting it high drives it to 5V. With all the control pins driven from outputs of a shift register, the off segments will have 5 volts on them, and the off digit select pins will have ground on them.) &lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-17T02:52:57.300" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4221" PostTypeId="2" ParentId="4218" CreationDate="2014-09-17T05:12:39.927" Score="3" Body="&lt;p&gt;Here is a datasheet I found that seems a better macth for your display model (that's the datasheet for a display that I use):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.play-zone.ch/en/fileuploader/download/download/?d=1&amp;amp;file=custom%2Fupload%2FFile-1356269320.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.play-zone.ch/en/fileuploader/download/download/?d=1&amp;amp;file=custom%2Fupload%2FFile-1356269320.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the datasheet I directly got from my local supplier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to what you say, the problem does not seem to be a wiring problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks more like a &lt;strong&gt;timing&lt;/strong&gt; issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeDigit(int digitPin, int number) {&#xA;  digitalWrite(digitPin, LOW);&#xA;&#xA;  digitalWrite(LATCH, LOW);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);&#xA;  digitalWrite(LATCH, HIGH);&#xA;&#xA;  digitalWrite(digitPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first issue when you call &lt;code&gt;writeDigit()&lt;/code&gt; is that it forces the cathod low &lt;strong&gt;BEFORE&lt;/strong&gt; having set the shift register, so the digit will first show the current register value, i.e. the one from the previous call to &lt;code&gt;writeDigit()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it pushes the new value for the segments on the shift register, that will be fast but not as fast as two consecutive calls to &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we try to roll and expand the &lt;code&gt;loop()&lt;/code&gt; call in your example that will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// First call: writeDigit(DIGIT_TWO, 2)&#xA;  digitalWrite(DIGIT_TWO, LOW);&#xA;  digitalWrite(LATCH, LOW);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[2]);&#xA;  digitalWrite(LATCH, HIGH);&#xA;  digitalWrite(DIGIT_TWO, HIGH);&#xA;&#xA;// Second call: writeDigit(DIGIT_THREE, 3)&#xA;  digitalWrite(DIGIT_THREE, LOW);&#xA;  digitalWrite(LATCH, LOW);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[3]);&#xA;  digitalWrite(LATCH, HIGH);&#xA;  digitalWrite(DIGIT_THREE, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The calls to &lt;code&gt;loop()&lt;/code&gt; and &lt;code&gt;writeDigit()&lt;/code&gt; are negligible in terms of timing here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the sequence above, most of the time is spent in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  shiftOut(DATA, CLOCK, LSBFIRST, digits[2]);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[3]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that means your function will:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;show the previous value on the new digit for &lt;code&gt;t1 us&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;show the new value of the new digit for &lt;code&gt;t2 us&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;with &lt;code&gt;t1 &amp;gt;&amp;gt; t2&lt;/code&gt;, hence your eyes will see the opposite of your intent!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix that issue you definitely need to introduce some delay to reverse what your eyes will see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeDigit(int digitPin, int number) {&#xA;  digitalWrite(LATCH, LOW);&#xA;  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);&#xA;  digitalWrite(LATCH, HIGH);&#xA;  digitalWrite(digitPin, LOW);&#xA;  delayMicroseconds(100);    &#xA;  digitalWrite(digitPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the code above:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no digit shows while the shift register is set&lt;/li&gt;&#xA;&lt;li&gt;the requested digit shows immediately after the shift registry has been written and lacthed, and for a duration of 100us, which will be much longer than the rest of the time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That code should also get rid of the &quot;bleeding&quot; you observed.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-09-17T05:12:39.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4222" PostTypeId="2" ParentId="4214" CreationDate="2014-09-17T05:14:35.597" Score="16" Body="&lt;p&gt;There are a lot of ways to write a serial protocol depending on what functionality you might want and how much error checking you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the common things you see in point to point protocols are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;End of message&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest ASCII protocols just have an end of message character sequence, often &lt;code&gt;\r&lt;/code&gt; or &lt;code&gt;\n&lt;/code&gt; as this is what gets printed when the enter key is hit. Binary protocols might use &lt;code&gt;0x03&lt;/code&gt; or some other common byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Start of message&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with just having end of message is that you don't know what other bytes have already been received when you send your message. These bytes would then be prefixed to the message and cause it to be interpreted wrongly. For example, if the Arduino just woke from sleep there might be some garbage in the serial buffer. To get around this you have a start of message sequence. In your example, &lt;code&gt;^&lt;/code&gt;,  in binary protocols often &lt;code&gt;0x02&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Error Checking&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the message can be corrupted we need some error checking. This could be a checksum or a CRC error or something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Escape Characters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be that the checksum adds to a control character, such as the 'start of message' or 'end of message' byte, or the message contains a value equal to a control character. The solution is to introduce an escape character. The escape character is placed before a &lt;em&gt;modified&lt;/em&gt; control character so that the actual control character is not present. E.g. if a start character is 0x02, using the escape character 0x10 we can send the &lt;em&gt;value&lt;/em&gt; 0x02 in the message as the byte pair 0x10 0x12 (byte XOR control character)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Packet number&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a message is corrupted we could request a resend with a nack or retry message, but if multiple messages have been sent then only the latest message can be resent. Instead the packet can be given a number that rolls over after a certain number of messages. For example, if this number is 16, the transmitting device can store the last 16 messages send and if any were corrupted the receiving device can request a resend using the packet number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Length&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often in binary protocols you see a length byte which tells the receiving device how many characters are in the message. This adds another level of error checking as if the correct number of bytes were not received then there was an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Arduino specific&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When coming up with a protocol for Arduino the first consideration is how reliable is the communications channel. If you are sending over most wireless mediums, XBee, WiFi, etc, there is already built in error checking and retries and thus no point in putting these in your protocol. If you are sending over RS422 for a couple of kilometres then it will be necessary. The things I would include are the start of message and end of message characters, as you have. My typical implementation looks something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;gt;messageType,data1,data2,…,dataN\n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Delimiting the data parts with a comma allows for easy parsing, and the message is sent using ASCII. ASCII protocols are great because you can type messages into the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a binary protocol, maybe to shorten the message sizes, you will have to implement escaping if a data byte can be the same as a control byte. Binary control characters are better for systems where the full spectrum of error checking and retries is desired. The payload can still be ASCII if desired.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2016-10-07T14:04:10.083" LastActivityDate="2016-10-07T14:04:10.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4223" PostTypeId="1" AcceptedAnswerId="4224" CreationDate="2014-09-17T05:33:51.933" Score="1" ViewCount="5612" Body="&lt;p&gt;I'm trying to get an arduino board to detect simple free fall condtions. Currently, I have a 9DOF sensor (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide&lt;/a&gt;) and am able to get the raw data from the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I am unsure what to do from here onwards. From what I manage to gather, there is an alternative sensor ADXL345 accelerometer that has an inbuilt free fall component. I have tried modfying the code in such a way that it will work with the sensor I am using but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The free fall detection does not need to be extremely accurate/precise considering there are many fall/jerk patterns. It is just for a proof of concept for a project of mine. With that in mind, any suggestions on how to proceed will be greatly appreciated (or if I should just get the ADXL345 accelerometer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2016-10-16T15:49:01.570" Title="Enable free fall detection using Arduino" Tags="|accelerometer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4224" PostTypeId="2" ParentId="4223" CreationDate="2014-09-17T05:38:58.400" Score="4" Body="&lt;p&gt;Sitting an accelerometer flatly on a bench will produce a value of 1G in one of the 3 axes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Free fall of an accelerometer (assuming you haven't reached terminal velocity) should read near zero on all 3 axes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not aware of a mode you can set for this, but if you check the values of the 3 axes and all are close to zero, you are probably in a free fall condition.&lt;/p&gt;&#xA;" OwnerUserId="4007" LastActivityDate="2014-09-17T05:38:58.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4225" PostTypeId="1" CreationDate="2014-09-17T06:28:04.430" Score="1" ViewCount="760" Body="&lt;p&gt;recently i trying to make the pixy pet work for my project. (&lt;a href=&quot;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/playing-with-your-pet&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/playing-with-your-pet&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the given code for the arduino IDE, but i keep on getting this error Arduino: 1.5.7 (Windows 7), Board: &quot;Arduino Leonardo&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sketch_sep17a.ino:27:24: fatal error: ZumoMotors.h: No such file or directory compilation terminated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This report would have more information with &quot;Show verbose output during compilation&quot; enabled in File &gt; Preferences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Code, im using, was given by the official maker of the Pixy Pet. Please have a look. ( &lt;a href=&quot;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/the-code&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/the-code&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You.&lt;/p&gt;&#xA;" OwnerUserId="4009" LastEditorUserId="42" LastEditDate="2014-09-17T11:50:17.107" LastActivityDate="2016-05-09T23:03:58.107" Title="Arduino IDE Unable to detect ZumoMotor.H ( PIXY PET )" Tags="|c++|arduino-leonardo|library|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4226" PostTypeId="1" CreationDate="2014-09-17T06:32:52.230" Score="-1" ViewCount="597" Body="&lt;p&gt;I am posting my simple code here, I wanted to print the Output_Current Inspite when delay function called.Below is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MsTimer2.h&amp;gt;&#xA;&#xA;&#xA;int Analog_Pin=5;&#xA;int newaverage;&#xA;float Output_Current;&#xA;#define RELAY1  7&#xA;#define MAX_TRIP_COUNT  5&#xA;float Current_Limit=0.6;&#xA;static int Trip_Count=0;&#xA;static int Tripped_Flag=1;&#xA;int Serial_Status=0;&#xA;&#xA;&#xA;&#xA;void TakeReading()&#xA;{&#xA;  newaverage = analogRead(A5);&#xA;&#xA;//  Serial.print(&quot;newaverage:&quot;);&#xA;  //Serial.println(newaverage);&#xA;  Output_Current = 0.0336666666667*newaverage - 17.17; &#xA;}&#xA;&#xA;&#xA;void Chk_Relay_Tripped()&#xA;{&#xA;  if(Output_Current&amp;gt;=Current_Limit)&#xA;  {&#xA;    Trip_Count=Trip_Count+1; &#xA;    if((Trip_Count&amp;gt;=MAX_TRIP_COUNT) &amp;amp;&amp;amp;(Serial_Status==0))&#xA;    {&#xA;&#xA;      Trip_Count=0;&#xA;&#xA;  MsTimer2::set(30000, Relay_Activate); // 500ms period&#xA;  MsTimer2::start();&#xA;     // Relay_Activate();&#xA;    }&#xA;    else&#xA;      if(Serial_Status==1)&#xA;      {&#xA;        Serial.println(&quot;&amp;gt; MODE&quot;);&#xA;        Relay_Deactivate(); &#xA;      }&#xA;&#xA;  } &#xA;  else&#xA;  {&#xA;    Trip_Count=Trip_Count-1;&#xA;    if(Trip_Count&amp;lt;0)&#xA;    {&#xA;      Trip_Count=0;&#xA;    }&#xA;&#xA;    if(Trip_Count&amp;lt;MAX_TRIP_COUNT &amp;amp;&amp;amp; Serial_Status==1)&#xA;    {&#xA;      Relay_Deactivate();&#xA;      Serial_Status=0;&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void Relay_Activate()&#xA;{&#xA;   // MsTimer2::stop();&#xA;&#xA;   for (unsigned long start = millis(); millis() - start &amp;lt; 10000;)&#xA;  {&#xA;    digitalWrite(RELAY1,HIGH);&#xA;    Serial_Status=1;&#xA;  }&#xA;&#xA;    digitalWrite(RELAY1,HIGH);&#xA;    Serial_Status=1;&#xA;&#xA;}&#xA;&#xA;void  Relay_Deactivate()&#xA;{&#xA;  digitalWrite(RELAY1,LOW);&#xA; // Serial_Status=0;&#xA;}&#xA;&#xA;void Relay_Intialize()&#xA;{&#xA;  digitalWrite(RELAY1,LOW);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); // set serial speed&#xA;  pinMode(RELAY1, OUTPUT); // set LED as output&#xA;  //digitalWrite(RELAY1, LOW); //turn off LED&#xA;&#xA;  pinMode(Analog_Pin,INPUT);&#xA;  Relay_Intialize();&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void loop(){&#xA;  TakeReading();&#xA;  Chk_Relay_Tripped();&#xA;  Serial.println(Output_Current);&#xA;   //while (Serial.available() == 0); // do nothing if nothing sent&#xA;  int val = Serial.read() - '0';&#xA;  if (val == 1) { // test for command 1 then turn on LED&#xA;    Serial.println(&quot;RELAY on&quot;);&#xA;    digitalWrite(RELAY1, LOW); // turn on LED&#xA;    Serial_Status=1;&#xA;&#xA;  }&#xA;  else if (val == 0) // test for command 0 then turn off LED&#xA;  {&#xA;    Serial.println(&quot;RELAY OFF&quot;);&#xA;    digitalWrite(RELAY1, HIGH); // turn off LED&#xA;    Serial_Status=0;&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In above code everything working fine. But as soon as this function called . It wait 30s. after that it will print data. But i wanted to print data on serial monitor even if this function called. Please let me know how can i do this. Main intenstion of code is when current &gt;1A trip the relay , wait for 30S and connect back. I wanted to print output even in 30S&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Relay_Activate()&#xA;{&#xA;&#xA;   for (unsigned long start = millis(); millis() - start &amp;lt; 30000;)&#xA;  {&#xA;    digitalWrite(RELAY1,HIGH);&#xA;    Serial_Status=1;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="904" LastEditDate="2014-09-17T10:15:50.620" LastActivityDate="2014-09-17T10:36:47.237" Title="Relay activation" Tags="|arduino-uno|serial|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4227" PostTypeId="2" ParentId="4226" CreationDate="2014-09-17T10:36:47.237" Score="0" Body="&lt;p&gt;I read you code as: check the output current every 500ms. If it exceeds the limit more than &lt;code&gt;MAX_TRIP_COUNT&lt;/code&gt; times, set &lt;code&gt;Relay_Activate&lt;/code&gt; to run after 30secs. In &lt;code&gt;Relay_Activate&lt;/code&gt;, write &lt;code&gt;HIGH&lt;/code&gt; to the &lt;code&gt;RELAY1&lt;/code&gt; over and over for 30 seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Relay_Activate()&#xA;{&#xA;  for (unsigned long start = millis(); millis() - start &amp;lt; 30000;)&#xA;  {&#xA;    digitalWrite(RELAY1,HIGH);&#xA;    Serial_Status=1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think you really mean to do this, especially as after the 30 seconds you are not writing &lt;code&gt;LOW&lt;/code&gt; to turn it off. Maybe you mean that after 30 seconds it should start checking the current again?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Relay_Activate()&#xA;{&#xA;  digitalWrite(RELAY1,HIGH);&#xA;  Serial_Status=1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you want is a state machine so that your delays don't hold up your loop. Here is some pseudo code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop {&#xA;&#xA;* read current&#xA;* print out current&#xA;&#xA;switch(current_state) {&#xA;  //Normal operation&#xA;  case 0:&#xA;    * check if tripped&#xA;      - if tripped change state to 1&#xA;  //Turn on relay&#xA;  case 1:&#xA;    * turn on relay&#xA;    * set state_timer = millis()&#xA;    * change state to 2&#xA;  //Turn of relay after 30 seconds&#xA;  case 2:&#xA;    * if millis() -state_timer &amp;gt; 30000 turn off relay&#xA;    * change state to 0&#xA;}&#xA;delay 500ms&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-09-17T10:36:47.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4230" PostTypeId="2" ParentId="4225" CreationDate="2014-09-17T11:47:42.447" Score="1" Body="&lt;p&gt;It looks like you need to install the ZumoMotors library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one available at the following link, although I don't know for sure that it's the same one your Pixy Pet requires:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pololu/zumo-shield&quot; rel=&quot;nofollow&quot;&gt;https://github.com/pololu/zumo-shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That page includes instructions on how to install the libraries. If you get stuck, there's more help in the official Arduino documentation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Guide/Libraries&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/Libraries&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-09-17T11:47:42.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4231" PostTypeId="1" CreationDate="2014-09-17T13:01:29.343" Score="2" ViewCount="320" Body="&lt;p&gt;I am testing a set-up using the TinkerKit shield for Arduino Uno, and a few TinkerKit inputs and outputs. I have an issue with the code provided on the &lt;a href=&quot;http://www.tinkerkit.com/linear-pot/&quot; rel=&quot;nofollow&quot;&gt;TinkerKit website&lt;/a&gt; for the potentiometer component:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinkerKit.h&amp;gt;&#xA;&#xA;// creating the object 'pot' that belongs to the 'TKPotentiometer' class&#xA;TKPotentiometer pot(I0);&#xA;&#xA;// creating the object 'led' that belongs to the 'TKLed' class &#xA;TKLed led(O0);                              &#xA;&#xA;int brightnessVal = 0;  // value read from the pot&#xA;&#xA;void setup() {&#xA;  // initialize serial communications at 9600 bps&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the potentiometer's value:&#xA;  brightnessVal = pot.read();            &#xA;&#xA;  // set the led brightness&#xA;  led.brightness(brightnessVal);       &#xA;&#xA;  // print the results to the serial monitor:&#xA;  Serial.print(&quot;brightness = &quot; );                      &#xA;  Serial.println(brightnessVal);      &#xA;&#xA;  // wait 10 milliseconds before the next loop&#xA;  delay(10);                    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error message when compiling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Class TKPotentiometer has no member named 'read'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://www.tinkerkit.com/linear-pot/&quot; rel=&quot;nofollow&quot;&gt;this webpage&lt;/a&gt;, though, &lt;code&gt;read&lt;/code&gt; should be a member of the class. Why am I receiving this message?&lt;/p&gt;&#xA;" OwnerUserId="4013" LastActivityDate="2015-02-14T17:20:32.823" Title="Class TKPotentiometer has no member named 'read'" Tags="|arduino-uno|potentiometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4232" PostTypeId="2" ParentId="4231" CreationDate="2014-09-17T13:05:03.197" Score="1" Body="&lt;p&gt;As soon as I finished writing the question, it came to my mind that perhaps I misspelled something, so I looked for a file in the Menu's sketchbook that I could load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With my surprise, I found the same exact code as I posted, with a little difference:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pot.read()&lt;/code&gt; was substituted with &lt;code&gt;pot.get()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4013" LastActivityDate="2014-09-17T13:05:03.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4233" PostTypeId="1" CreationDate="2014-09-17T17:42:32.883" Score="1" ViewCount="685" Body="&lt;p&gt;I've programmed the Arduino Uno to generate PWM corresponding to the serial input values. And it works fine with an LED. I took the connection from PWM pin 3 (where I set the output) to the base of a BC548 transistor and connected the motor in series with an external motor power supply (Vcc) and the collector and the emmitter is grounded (to both Arduino's GND pin and the external supply's). The motor had a fly wheel diode, 4N4007, and a capacitor of 1&amp;nbsp;µF for protection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I connect the motor and provide it with the PWM input, it works for a few seconds and then I see a few flashes in the rx and tx LEDs, and it stops working even with a serial input or reset. I need to turn it off and then on to make it work again. The same thing repeats when I connect the motor, but it works fine with an LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix that??&lt;/p&gt;&#xA;" OwnerUserId="4016" LastEditorUserId="510" LastEditDate="2015-10-18T09:07:59.177" LastActivityDate="2015-12-17T09:27:36.463" Title="Cannot drive DC motor with Arduino PWM" Tags="|arduino-uno|motor|pwm|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4234" PostTypeId="1" CreationDate="2014-09-17T19:50:19.963" Score="1" ViewCount="144" Body="&lt;p&gt;I'm a newbie on the all Arduino platform and I'm currently building a drone with Autopilot functionality. I've heard about ArduPilot and I'm wondering if that is all I need, in terms of controllers (I'm excluding the ESC, engines, and the rest). Can I simply program the ArduPilot, connect a Wireless interface to it and merrily be able to control it ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&#xA;r &lt;/p&gt;&#xA;" OwnerUserId="4018" LastActivityDate="2014-09-17T23:09:10.707" Title="Do we need another controller when using ArduPilot?" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4235" PostTypeId="1" AcceptedAnswerId="4239" CreationDate="2014-09-17T22:49:53.910" Score="1" ViewCount="3760" Body="&lt;p&gt;I'm trying to build a small personal weather station. The rain sensor, and wind speed sensor use interrupts. The barometric sensor uses i2c SDA and SCL. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/arduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;Reading the Arduino Yun manual&lt;/a&gt;, it says there are 5 interrupt pins, but 2 of them are SCL/SDA (pins D2 and D3), and 2 of them are serial comms between Linio and the 32U4 (pins 0 and 1). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leaves me with 1 interrupt pin left (pin 7). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a work around to get my 2 digital sensors AND SDA SCL pins connected?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do use pins 0 and 1 (Linux serial), what do I risk? I will need to use the Bridge to relay information to the internet. &lt;/p&gt;&#xA;" OwnerUserId="306" LastActivityDate="2014-09-18T08:24:15.793" Title="Arduino Yun - not enough i2c &amp; interrupt pins?" Tags="|arduino-yun|i2c|digital|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4236" PostTypeId="2" ParentId="4234" CreationDate="2014-09-17T23:09:10.707" Score="1" Body="&lt;p&gt;There are a few key points worth making before answering your question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Ardupilot&lt;/strong&gt; has undergone a re-branding and is now known as &lt;strong&gt;APM&lt;/strong&gt;; this change was made to reflect that the technology has grown beyond strictly using an Arduino environment. You can see this for yourself at &lt;a href=&quot;http://ardupilot.com/&quot; rel=&quot;nofollow&quot;&gt;their website&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The term(s) Ardupilot/APM have been used somewhat interchangeably for both the hardware and software. This can be confusing so I'll refer to the hardware as an &quot;APM Kit&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can I simply program the ArduPilot, connect a Wireless interface to it and merrily be able to control it ?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, &lt;a href=&quot;http://store.3drobotics.com/t/parts/autopilots&quot; rel=&quot;nofollow&quot;&gt;3DRobotics&lt;/a&gt; offers APM Kits that are plug-and-play hardware packages with preloaded firmware. They (optionally) supply all of the components needed to operate a small unmanned hobby aircraft including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Power module&lt;/li&gt;&#xA;&lt;li&gt;Transmitter and receiver for the APM-to-Ground-Station link&lt;/li&gt;&#xA;&lt;li&gt;GPS module w/ compass&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The user is generally expected to provide:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Airframe&lt;/li&gt;&#xA;&lt;li&gt;Batteries&lt;/li&gt;&#xA;&lt;li&gt;Servos&lt;/li&gt;&#xA;&lt;li&gt;RC transmitter and receiver&lt;/li&gt;&#xA;&lt;li&gt;An additional voltage-regulator/BEC if using high-torque servos&lt;/li&gt;&#xA;&lt;li&gt;A computer (groundstation)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, the unspoken question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How easy is it to setup Ardupilot/APM to work safely and correctly?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In truth, it takes considerable effort to put together a properly working system. The plug-and-play hardware saves you a great deal of trouble but tuning and operating an RC aircraft requires a different skillset. If you're experienced in RC, this &lt;em&gt;may&lt;/em&gt; not be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From experience, you can expect to spend a number of weekends configuring and tuning APM (the software) even if you have a perfectly tuned RC aircraft. &lt;/p&gt;&#xA;" OwnerUserId="4021" LastActivityDate="2014-09-17T23:09:10.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4237" PostTypeId="2" ParentId="4233" CreationDate="2014-09-17T23:57:06.293" Score="0" Body="&lt;p&gt;It's hard to know without an oscilloscope, but as a guess you might be seeing voltage spikes on Vcc at the reset pin due to inductive load dumps from the motor.  Per Atmel app note &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_application-note_avr042.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR042&lt;/a&gt;, you might try a 5V zener diode from the reset pin to ground and/or a capacitor to snub the spikes.&lt;/p&gt;&#xA;" OwnerUserId="4023" LastActivityDate="2014-09-17T23:57:06.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4238" PostTypeId="2" ParentId="4235" CreationDate="2014-09-18T00:14:42.580" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/OR_gate&quot; rel=&quot;nofollow&quot;&gt;OR&lt;/a&gt; the interrupt lines together so that you only need 1 external interrupt. Then when an interrupt is triggered, poll the devices until you find the one that triggered the interrupt. If the interrupt outputs are open-drain then you can wired-OR them together, otherwise you will need something like the 74LVC32 to OR the push-pull outputs together.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-18T00:14:42.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4239" PostTypeId="2" ParentId="4235" CreationDate="2014-09-18T02:08:26.597" Score="2" Body="&lt;p&gt;Any of the port B pins on the ATmega32u4 can interrupt on pin change. Unlike the external interrupts however, these pin change interrupts share the same interrupt vector. So in the interrupt routine you have to work out which one fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The port B pin change interrupt is not support by the Arduino core library so you have to download a third-party library. This one seems fairly recent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/arduino-pinchangeint/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-pinchangeint/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you connect your two interrupt lines to spare Port B pins and monitor for pin changes.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-09-18T02:08:26.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4240" PostTypeId="2" ParentId="4136" CreationDate="2014-09-18T06:06:58.503" Score="0" Body="&lt;p&gt;The problem has been solved in the arduino.cc forum. The SRAM was overflowing, but applying the F()-macro to the strings being printed solved the issue! (Just in case someone has similar issues ^^)&lt;/p&gt;&#xA;" OwnerUserId="3945" LastActivityDate="2014-09-18T06:06:58.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4242" PostTypeId="1" CreationDate="2014-09-18T15:32:40.150" Score="1" ViewCount="405" Body="&lt;p&gt;My wording might be a bit confusing, if I plug an 8 volt battery into Vin, will the arduino be powered and will the 5V pins work?&lt;/p&gt;&#xA;" OwnerUserId="3912" LastActivityDate="2014-09-19T00:05:10.760" Title="If I connect a battery to the vin pin on the arduino, will the 5V pin be activated?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4243" PostTypeId="2" ParentId="4242" CreationDate="2014-09-18T15:51:19.153" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;strong&gt;VIN.&lt;/strong&gt; The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMega&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-18T15:51:19.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4244" PostTypeId="1" CreationDate="2014-09-18T18:25:31.097" Score="4" ViewCount="3891" Body="&lt;p&gt;I'm trying to retrieve / synchronize time from PC using this Time lib function: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setSyncProvider( requestSync);  //set function to call when sync required&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It sends ASCII BEL (07) character to PC, but I'm getting no response using &lt;code&gt;Serial.available&lt;/code&gt;. What am I missing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to run a specific app on the PC to get a response? The docs do not specify that. &lt;/p&gt;&#xA;" OwnerUserId="3916" LastEditorUserId="42" LastEditDate="2014-09-19T09:16:42.107" LastActivityDate="2014-09-19T09:36:20.877" Title="How to implement setSyncProvider and verify it is working with PC" Tags="|arduino-uno|time|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4245" PostTypeId="1" CreationDate="2014-09-18T19:46:03.427" Score="1" ViewCount="1450" Body="&lt;p&gt;I'm trying to connect Arduino Leonardo to an Android tablet. I would like to make the Arduino send commands (using pushbuttons or a slider for example) to the tablet to switch between pages, to select a file on the desktop, to scroll up and down the screen, etc.&lt;/p&gt;&#xA;" OwnerUserId="4039" LastEditorUserId="61722" LastEditDate="2022-07-27T20:43:31.930" LastActivityDate="2022-12-25T07:04:25.500" Title="How to control Android app with Arduino" Tags="|arduino-leonardo|android|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4247" PostTypeId="2" ParentId="4242" CreationDate="2014-09-19T00:05:10.760" Score="3" Body="&lt;p&gt;Yes, that's what the Vin pin is for: unregulated voltage or a voltage higher than 5V. Then the 5V pin will be at 5V, regulated by the on board regulator. You would only connect a source to the 5V pin if the source is already a regulated 5V.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-09-19T00:05:10.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4248" PostTypeId="2" ParentId="4244" CreationDate="2014-09-19T09:36:20.877" Score="2" Body="&lt;p&gt;Yes, you'll need something running on the PC which is monitoring the serial port, and which will provide a response in the appropriate format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The download on &lt;strong&gt;&lt;a href=&quot;http://playground.arduino.cc/code/time&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;&lt;/strong&gt; contains a Processing sketch which will do this for you. After you've unzipped it, look in &lt;code&gt;Time/Examples/Processing/SyncArduinoClock&lt;/code&gt;. Open the sketch in Processing, run it, and then start your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're not familiar with it, Processing is a free programming language / environment based on Java. It's aimed largely at beginners and non-programmers, and is quite commonly used for communicating with Arduino projects via Serial. You can download it here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.processing.org&quot; rel=&quot;nofollow&quot;&gt;http://www.processing.org&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-09-19T09:36:20.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4249" PostTypeId="2" ParentId="4219" CreationDate="2014-09-19T11:48:19.173" Score="1" Body="&lt;p&gt;I have a few years working with DMX, SPI (and other serial) &amp;amp; LEDs. I have worked with DMX and a video dance floor for 10+ years previously. I would offer that &quot;some people&quot; are correct. You will get a reliable system with differential pair signalling (such as DMX).&#xA;I have found from experience that over 5m of unbalanced serial starts chancing it. Over 10m and you are likely to come up with at least reliability issues, but more likely garbage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used the TI SN75176B driver a fair bit and is cheap and works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depends on your audience. You can afford to chance it for your bedroom, but not paid business. &lt;/p&gt;&#xA;" OwnerUserId="4048" LastActivityDate="2014-09-19T11:48:19.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4250" PostTypeId="1" CreationDate="2014-09-19T13:06:31.293" Score="1" ViewCount="863" Body="&lt;p&gt;I wasn't sure where to ask this question, but since it's actually an Arduino project, I'll try it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to upgrade my old car with ultrasonic parking sensors: I've already bought HC-SR04s as sensors and started to play on my breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what I'm still unsure about: if I place them in my car's rear bumber, how can I make them resistent to rain or dirt or something like that?&#xA;As pictured on &lt;a href=&quot;http://en.wikipedia.org/wiki/Parking_sensors&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;, the sensor is covered with a small piece. But what could I use to cover the holes in the bumper, without interfering with the ultrasonic measuring?&lt;/p&gt;&#xA;" OwnerUserId="4049" LastActivityDate="2014-09-19T17:23:59.027" Title="How can I make ultrasonic sensors resistent to splashes and dirt?" Tags="|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4251" PostTypeId="1" AcceptedAnswerId="4253" CreationDate="2014-09-19T13:41:41.977" Score="0" ViewCount="5628" Body="&lt;p&gt;I'm trying to set up a simple web-server with Arduino Yun without an SD card, i.e via REST, if I understood it right (I'm new to some of these stuff). I want to be able to &quot;get&quot; data (sent by Arduino) through a jQuery script and show the user a formatted HTML page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I provide you a simplified version of my Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;const byte internalLED = 13;&#xA;&#xA;YunServer server;&#xA;&#xA;void setup() {&#xA;  pinMode(internalLED, OUTPUT);&#xA;  digitalWrite(internalLED, HIGH);     // Turn the led on to advise about bridge begin in progress&#xA;  Bridge.begin();          // Let's activate the Yun Bridge...&#xA;  ledBlink(150);           // ...bridge activation done (user sees a blink)&#xA;  // server.listenOnLocalhost();       // Listen for incoming connection only from localhost (no one from the external network could connect)&#xA;  server.begin();          // Let's acrivate the Yun server...&#xA;  ledBlink(150);           // ...server activation done (user sees a blink)&#xA;}&#xA;&#xA;void loop() {&#xA;  YunClient client = server.accept();  // Get clients coming from server&#xA;  if (client)                          // Is there a new client?&#xA;  {&#xA;    client.print(77);                  // Send a &quot;77&quot; to client (e.g. browser)&#xA;    client.stop();                     // Close connection and free resources.&#xA;    ledBlink(500);&#xA;  }&#xA;  delay(50);&#xA;}&#xA;&#xA;void ledBlink(int delayTime) {&#xA;  digitalWrite(internalLED, HIGH); // Turn (or keep) the LED on&#xA;  delay(delayTime);&#xA;  digitalWrite(internalLED, LOW);  // Turn (or keep) the LED off&#xA;  delay(delayTime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Arduino Yun is connected via WiFi with static IP (192.168.1.98) to the same network of my laptop, and they can ping each other. Right now, if I insert into my browser the address &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://192.168.1.98/arduino/whatever&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I correctly receive a simple «77» (no quotes or \r\n)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I cannot &quot;get&quot; it when opening the page get_test.html (which is on my harddisk, not in the SD):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;&amp;lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&amp;lt;script&amp;gt;&#xA;    $.get(&quot;http://192.168.1.98/arduino/whatever&quot;, {}, function(data,status){&#xA;      alert(&quot;Data: &quot; + data + &quot;\nStatus: &quot; + status);&#xA;    });&#xA;&amp;lt;/script&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is strange to me because this html code works if I change the address inside the &quot;get&quot; request with &lt;a href=&quot;https://dl.dropboxusercontent.com/u/12389503/demo_test.txt&quot; rel=&quot;nofollow&quot;&gt;https://dl.dropboxusercontent.com/u/12389503/demo_test.txt&lt;/a&gt; which consists only of a «21» (no \r\n). The problem is I don't even receive the alert when the address is the IP of Arduino, but the board is receiving the request since I can see the led blinking once, as expected.&#xA;I'm running out of tests, any suggestion is welcome.&lt;/p&gt;&#xA;" OwnerUserId="4047" LastActivityDate="2014-09-19T14:47:59.440" Title="Webserver with Arduino Yun without SD" Tags="|arduino-yun|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4253" PostTypeId="2" ParentId="4251" CreationDate="2014-09-19T14:47:59.440" Score="0" Body="&lt;p&gt;Whenever making ajax calls from/to different hosts (as your pc and the yun) you should use &lt;a href=&quot;http://api.jquery.com/jquery.getjson/&quot; rel=&quot;nofollow&quot;&gt;JSONP&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-09-19T14:47:59.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4254" PostTypeId="2" ParentId="4202" CreationDate="2014-09-19T15:14:43.620" Score="0" Body="&lt;p&gt;It's my code. Can anyone suggest anything wrong with it if my idea is to push data from Analog pin 0 to Digital pin 11, which is the Tx pin on Arduino connecting to Rx pin on HC-05?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11); &#xA;int tempPin=0;&#xA;&#xA;void setup()&#xA;{&#xA;Serial.begin(9600);&#xA;mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA; float reading = analogRead(tempPin); // reading on tempPin        &#xA; float voltage = reading*5.0/1024.0; // the resolution of a pin is 10 bit,&#xA; float tempC = voltage/0.01; // 10mV = 1 Celcius &#xA; mySerial.write(tempC);&#xA;&#xA; delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3996" LastActivityDate="2014-09-19T15:14:43.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4255" PostTypeId="2" ParentId="4250" CreationDate="2014-09-19T16:23:51.490" Score="2" Body="&lt;p&gt;I don't think you'll be able to cover that sensor in a way that will still allow it to work. There are waterproof ultrasonic sensors out there, here's one on &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00BJTRGQW&quot; rel=&quot;nofollow&quot;&gt;Amazon&lt;/a&gt;, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other thing you might want to look at is IR instead of ultrasonic. That's easier to weatherproof since the IR emitter/receiver are already covered. You'll probably have less range with IR, though.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2014-09-19T16:23:51.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4256" PostTypeId="2" ParentId="4250" CreationDate="2014-09-19T17:23:59.027" Score="1" Body="&lt;p&gt;Maybe at a minimum for testing you could point the sensor downwards and then use a reflector to discourage water and dust. Something like: &lt;a href=&quot;http://letsmakerobots.com/content/cyperbolic-reflector-review&quot; rel=&quot;nofollow&quot;&gt;http://letsmakerobots.com/content/cyperbolic-reflector-review&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2768" LastActivityDate="2014-09-19T17:23:59.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4261" PostTypeId="1" CreationDate="2014-09-20T04:50:09.607" Score="1" ViewCount="359" Body="&lt;p&gt;I am trying to build a 36-line cable tester, using the Digistump DigiX (99 i/o pins). Digital pins 0-35 are outputs, connected via the cable in question, to (in a perfect world) digital input pins 36-72. The plan is to have 36 neopixels (to conserve DigiX pins), one corresponding to each line in the cable. Currently they light up green for connection and red for no connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to check if output 0 goes to input 36, but there are more potential problems in a cable than no connection... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if there is a short and output 0 goes to 36 and 42? It will still show up as correct when it tests 0 to 36... I somehow need to &quot;ask&quot; it what, if any, inputs (pins 36-72) are HIGH when only output 0 is HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how I'm going to display this extra data yet (Lcd maybe? Or maybe any pins shorted together all use a unique led color...), but I want to make sure the idea will work before I move on to that. Here is what I have working so far, just using a 3-line cable for now. And yes, I'm new to this. Any advice would be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS 3&#xA;#define LED_PIN 6&#xA;CRGB leds[NUM_LEDS];&#xA;#define brightness 25&#xA;int var = 0;&#xA;&#xA;void setup() {&#xA;  for (int sendPins=0; sendPins &amp;lt;= 2; sendPins++) {&#xA;    pinMode(sendPins, OUTPUT); }&#xA;&#xA;  for (int recPins=3; recPins &amp;lt;= 5; recPins++) {&#xA;    pinMode(recPins, INPUT); }&#xA;&#xA;    FastLED.addLeds&amp;lt;NEOPIXEL, LED_PIN&amp;gt;(leds, NUM_LEDS);&#xA;    FastLED.clear();&#xA;}&#xA;&#xA;void loop() {&#xA;  while (var &amp;lt; 3) {    //so it only runs once for each line in the cable.&#xA;    var++;&#xA;  for (int sendPins=0; sendPins &amp;lt; 3; sendPins++) {&#xA;    digitalWrite(sendPins, HIGH);&#xA;&#xA;    int recPins = map(sendPins, 0, 2, 3, 5);  //made more sense to me than another for loop.&#xA;&#xA;     int recPin = digitalRead(recPins);&#xA;     if (recPin == HIGH)&#xA;     {&#xA;      leds[sendPins].g = brightness;&#xA;      leds[sendPins].r = 0;&#xA;      FastLED.show();&#xA;     }&#xA;     else&#xA;     {&#xA;      leds[sendPins].r = brightness;&#xA;      leds[sendPins].g = 0;&#xA;      FastLED.show();&#xA;     }&#xA;&#xA;      digitalWrite(sendPins, LOW);&#xA;      delay(250);      //just for testing so i know it's going through them all.&#xA;  }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4057" LastActivityDate="2016-01-23T07:27:19.067" Title="What is the simplest way to &quot;ask&quot; the arduino which input pins are HIGH?" Tags="|pins|led|system-design|code-optimization|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4262" PostTypeId="2" ParentId="4261" CreationDate="2014-09-20T07:03:35.587" Score="2" Body="&lt;p&gt;There is a technique, which I used some 40 years ago to test for changes on a set of input pins. This can easily be configured to test serially. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put a 1 on an output pin say 5. Create an integer e.g. 010000 with a &lt;code&gt;1&lt;/code&gt; in the appropriate position. Read ALL inputs and &lt;code&gt;XOR&lt;/code&gt; with the created integer. If one and only one input is &lt;code&gt;1&lt;/code&gt; the resultant value will be &lt;code&gt;0&lt;/code&gt;. This is easy to implement in a loop just by shifting the &lt;code&gt;1&lt;/code&gt; left each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The technique works if you can read all inputs into a integer. This was OK for our 32 bits, but could be extended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is probably easier to code than explain, but depends on what you have to do to read all inputs.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-09-20T07:03:35.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4263" PostTypeId="1" CreationDate="2014-09-20T12:56:51.863" Score="0" ViewCount="2333" Body="&lt;p&gt;recently i bought this oled display .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OEQgv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.wvshare.com/product/0.96inch-OLED-A.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.wvshare.com/product/0.96inch-OLED-A.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can i connect it with arduino . Driver Chip is SSD1306 . Supported Interface are 3-wire SPI, 4-wire SPI, I2C . it's can display two colors Yellow and Blue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i need some guidance on how to hook it up with arduino lets say using i2c protocol . and is there any existing library ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note : on the wvshare website there's only code sample for STM32 Microcontrollers . &lt;/p&gt;&#xA;" OwnerUserId="4061" LastEditorUserId="4061" LastEditDate="2014-09-20T13:15:53.677" LastActivityDate="2019-11-03T18:17:01.450" Title="need help hooking up an oled display" Tags="|i2c|display|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4265" PostTypeId="2" ParentId="4261" CreationDate="2014-09-20T14:36:55.327" Score="0" Body="&lt;p&gt;I believe you can read the port register that contains the current state for your pin. The port names take the form of &quot;PORTA&quot; - &quot;PORTE&quot;. (The number of port registers varies with the processor in your arduino, and the pin to port mappings are also different across processor models, so this approach will tie you to Arduino models that use the same processor chip)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach would be to store the state you write to each pin to a boolean variable and just read that. Create a central method that takes a pin number and a new state. That method would save the new value to an array, indexed using the pin number, and then also set the pin. You could then write a method that would read the current pin value from the same array .&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-20T14:36:55.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4266" PostTypeId="1" AcceptedAnswerId="4267" CreationDate="2014-09-20T15:38:17.750" Score="2" ViewCount="585" Body="&lt;p&gt;Slightly distractedly, I went and connected 5V to the 3.3V pin on my &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=1044&quot; rel=&quot;nofollow noreferrer&quot;&gt;DFRobot Bluno&lt;/a&gt; (the pins are right next to each other!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The magic smoke leaked out of the &lt;a href=&quot;http://www.webtronico.com/documentos/AMS1117_33V.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMS1117&lt;/a&gt; 3.3V regulator in a neat little puff. The sketch that was loaded on the board still runs fine, but the Bluno is no longer recognised by my Macbook Pro when I plug it into USB (I have tried different ports and different cables; they're all fine—it's the USB on the Bluno that's fried.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an attempt to repair it, I've &lt;a href=&quot;https://www.sparkfun.com/tutorials/98&quot; rel=&quot;nofollow noreferrer&quot;&gt;replaced the AMS1117&lt;/a&gt; (check the third paragraph of that tutorial—ha!) with an &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000546.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;LF33ABV&lt;/a&gt;; this went well and I'm now getting a stable 3.3V on the 3.3V pin. Check out my handiwork:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/m0vBK.jpg&quot; alt=&quot;Bluno with original AMS1117 SMD 3.3V regulator replaced by a through-hole LF33ABV&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Bluno still isn't being recognised by the USB ports on my Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way to upload new sketches to the Bluno? Theoretically you can do so over BTLE, but you need another Bluno to act as the &quot;peripheral&quot; and I don't have one to hand. I have various other Arduinos laying about if that helps.&lt;/p&gt;&#xA;" OwnerUserId="3536" LastActivityDate="2014-09-20T15:53:01.597" Title="Resurrecting a fried Arduino (Bluno) USB port" Tags="|uploading|bluetooth|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4267" PostTypeId="2" ParentId="4266" CreationDate="2014-09-20T15:53:01.597" Score="4" Body="&lt;p&gt;Upload via ICSP. See those six pins next to the regulator you so expertly tacked on? Those are the ICSP pins. You'll need a second controller or programmer to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4064" LastActivityDate="2014-09-20T15:53:01.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4268" PostTypeId="1" CreationDate="2014-09-20T16:02:18.333" Score="0" ViewCount="2456" Body="&lt;p&gt;I wanted to use the cigarette lighter receptacle of a car as the power supply for the Arduino Mega. From 12&amp;nbsp;V, I will convert it to a 7&amp;nbsp;V supply, but my problem is, what must be the minimum current or electrical power to be fed into the Arduino Mega?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And are there any things I have to do to the Arduino Mega 2560 for it to function well in supplying it a 7&amp;nbsp;volts supply from a car?&lt;/p&gt;&#xA;" OwnerUserId="4062" LastEditorUserId="510" LastEditDate="2015-02-18T19:04:32.760" LastActivityDate="2015-02-18T19:04:32.760" Title="Minimum current or power for Arduino Mega" Tags="|arduino-mega|power|current|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4270" PostTypeId="2" ParentId="4268" CreationDate="2014-09-20T20:22:59.747" Score="2" Body="&lt;p&gt;The Arduino's voltage regulator is rated for a suggested input range of 7 to 12 volts. Automobile power will range from slightly below 12 volts to over 13 volts, so stepping it down to 7 volts is a good idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the data sheet it doesn't say how much current it draws. Since it uses a linear power supply it will likely draw the same amount of current regardless of the input voltage, and simply waste the power from a higher input voltage as heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power from a car cigarette lighter should have plenty of current, so your proposed setup should work just fine. Is your 7 volt supply regulated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you could also use a &quot;buck&quot; style switching power supply to feed 5 volts directly into the 5V line. There are several buck style power supplies on the market for less than $10 US that will provide up to 3A of regulated 5 volts.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-20T20:22:59.747" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4271" PostTypeId="1" CreationDate="2014-09-21T03:43:20.310" Score="0" ViewCount="449" Body="&lt;p&gt;I have setup a arduino with a SIM300 based GSM board. I have&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Tx of Arduino connected to the Rx of GSM board&lt;/p&gt;&#xA;&lt;p&gt;Rx of Arduino connected to the Tx of GSM board&lt;/p&gt;&#xA;&lt;p&gt;Gn of Arduino connected to the Gd of GSM board&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The GSM has a Vodafone 3g sim, activated with 3g. The GSM board has 2 LED's, one remains &lt;code&gt;ON&lt;/code&gt; and the other blinks ever 4-5 seconds. Which I guess means that its configured to work with the SIM.&lt;/p&gt;&#xA;&lt;p&gt;I then run the following code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  mySerial.begin(9600);&#xA;&#xA;  Serial.println(&amp;quot;Serial ports initialized&amp;quot;);&#xA; &#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CGATT=1&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CGDCONT=1,\&amp;quot;IP\&amp;quot;,\&amp;quot;TATA.DOCOMO.INTERNET\&amp;quot;,\&amp;quot;0.0.0.0\&amp;quot;,0,0&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CDNSCFG=\&amp;quot;8.8.8.8\&amp;quot;,\&amp;quot;8.8.4.4\&amp;quot;&amp;quot;);&#xA;   delay(1000);&#xA;   Serial.println(&amp;quot;AT+CSTT=\&amp;quot;TATA.DOCOMO.INTERNET\&amp;quot;,\&amp;quot;\&amp;quot;,\&amp;quot;\&amp;quot;&amp;quot;);&#xA;   delay(2000);&#xA;   Serial.println(&amp;quot;AT+CIICR&amp;quot;);&#xA;   delay(5000);&#xA;   Serial.println(&amp;quot;AT+CIFSR&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CIPSTATUS&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CDNSORIP=1&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CIPSTART=\&amp;quot;TCP\&amp;quot;,\&amp;quot;http://myec2DNS-us-west-2.compute.amazonaws.com:myportnumber/mywebservice/myreques/Authentication/Request?identity=somecode&amp;amp;identityType=sometype\&amp;quot;,\&amp;quot;myportnumber\&amp;quot;&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT+CIPSEND&amp;quot;);&#xA;   delay(500);&#xA;   Serial.println(&amp;quot;AT&amp;quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;On cutecom I get te following&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Serial ports initialized&#xA;AT+CGATT=1&#xA;AT+CGDCONT=1,&amp;quot;IP&amp;quot;,&amp;quot;TATA.DOCOMO.INTERNET&amp;quot;,&amp;quot;0.0.0.0&amp;quot;,0,0&#xA;AT+CDNSCFG=&amp;quot;8.8.8.8&amp;quot;,&amp;quot;8.8.4.4&amp;quot;&#xA;AT+CSTT=&amp;quot;TATA.DOCOMO.INTERNET&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;&#xA;AT+CIICR&#xA;AT+CIFSR&#xA;AT+CIPSTATUS&#xA;AT+CDNSORIP=1&#xA;AT+CIPSTART=&amp;quot;TCP&amp;quot;,&amp;quot;http://myec2DNS-us-compute.amazonaws.com:8080/myservice/mycommand/Authentication/Request?identity=%somecode&amp;amp;identityType=1&amp;quot;,&amp;quot;8080&amp;quot;&#xA;AT+CIPSEND&#xA;AT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run `tail -f  /var/lib/tomcat7/logs/localhost_access_log.2014-09-20.txt' on my webserver, I get nothing from the arduino.&lt;/p&gt;&#xA;&lt;p&gt;What am I missing here ?&lt;/p&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-21T05:04:18.360" Title="GSM arduino to webservice not working" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4272" PostTypeId="2" ParentId="4263" CreationDate="2014-09-21T05:35:44.920" Score="2" Body="&lt;p&gt;it's working with u8glib.  but i am using  4-wire SPI. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;constructor for U8GLIB&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9,8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pin configuration was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino -   Oled Display&#xA;13 -    CLK&#xA;11 -    DIN (SI)&#xA;10 -    CS&#xA;9 - D/C (A0)&#xA;8 - RES&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the reset pin is required. i used 3.3v  arduino pin for vcc .&lt;/p&gt;&#xA;" OwnerUserId="4061" LastActivityDate="2014-09-21T05:35:44.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4273" PostTypeId="1" AcceptedAnswerId="4276" CreationDate="2014-09-21T10:10:09.530" Score="2" ViewCount="10459" Body="&lt;p&gt;Following the arduino starter kit, one of the projects uses a push button to on/off a motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end they suggest to try to use a potentiometer to control the speed of the motor.&#xA;I already did it, but I am not sure how I should use the capacitors(I placed one with the pot).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In one of the previous examples they used 2 100uF capacitors(one for the pot. and another for a servo motor) and I was wondering if this would be the same case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my circuit:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/gDyCe.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/862vQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/cnFAy.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int POT_PIN = A0;&#xA;const int MOTOR_PIN = 9;&#xA;int motorSpeed = 0;&#xA;int potVal = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(MOTOR_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  potVal = analogRead(POT_PIN);&#xA;&#xA;  motorSpeed = map(potVal, 0, 1023, 0, 255);&#xA;&#xA;  analogWrite(MOTOR_PIN, motorSpeed);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Previous example with capacitors:&lt;/em&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/PiSwG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/EfjKa.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myServo;&#xA;&#xA;int const POT_PIN = A0;&#xA;int potVal;&#xA;int angle;&#xA;&#xA;int alpha = 0.8;&#xA;int rawReading;&#xA;&#xA;void setup()&#xA;{&#xA;  myServo.attach(9);&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  rawReading = analogRead(POT_PIN);&#xA;  potVal = alpha*potVal + (1-alpha)*rawReading;&#xA;  Serial.print(&quot;potVal: &quot;);&#xA;  Serial.print(potVal);&#xA;&#xA;  angle = map(potVal, 0, 1023, 0, 179);&#xA;  Serial.print(&quot;, angle: &quot;);&#xA;  Serial.println(angle);&#xA;&#xA;  myServo.write(angle);&#xA;  delay(15);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3840" LastEditorUserId="3840" LastEditDate="2014-09-21T15:58:49.183" LastActivityDate="2016-01-21T14:48:13.013" Title="Use potentiometer to control motor's speed" Tags="|motor|system-design|potentiometer|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4274" PostTypeId="1" CreationDate="2014-09-21T14:03:18.520" Score="0" ViewCount="498" Body="&lt;p&gt;My Objective :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to send my Mifare's unique number with some other parameters to my server database. As soon as the tag come closer to NFC, it detects, and some additional details are passed to the server Database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps done :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have Arduino UNO, Arduino GSM shield and Adafruit NFC shield . I had tried my test with UNO and works well. But to add some more features, due to memory salvation it could not be achieved through UNO. Then we moved to MEGA.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are some changes need to be done with MEGA to make [url]&lt;a href=&quot;http://arduino.cc/en/Guide/GSMShieldLeonardoMega[/url]&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/GSMShieldLeonardoMega[/url]&lt;/a&gt; GSM shield coordinate with the microcontroller[Take the Pin 2 out from GSM shield and with jumper connect Pin 2 with Pin 10]. Then we did and we tested it with GSM web client example and worked fine.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now to accomplish our goal, when we placed NFC shield above the GSM shield and executed same GSM web client example, it is not working. And Suddenly once in a blue moon it connects to the GSM network and works . But often, it fails. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;[code]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Web client&#xA;&#xA; This sketch connects to a website through a GSM shield. Specifically,&#xA; this example downloads the URL &quot;http://arduino.cc/asciilogo.txt&quot; and &#xA; prints it to the Serial monitor.&#xA;&#xA; Circuit:&#xA; * GSM shield attached to an Arduino&#xA; * SIM card with a data plan&#xA;&#xA; created 8 Mar 2012&#xA; by Tom Igoe&#xA;&#xA; http://arduino.cc/en/Tutorial/GSMExamplesWebClient&#xA;&#xA; */&#xA;&#xA;// libraries&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;// PIN Number&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// APN data&#xA;#define GPRS_APN       &quot;GPRS_APN&quot; // replace your GPRS APN&#xA;#define GPRS_LOGIN     &quot;login&quot;    // replace with your GPRS login&#xA;#define GPRS_PASSWORD  &quot;password&quot; // replace with your GPRS password&#xA;&#xA;// initialize the library instance&#xA;GSMClient client;&#xA;GPRS gprs;&#xA;GSM gsmAccess; &#xA;&#xA;// URL, path &amp;amp; port (for example: arduino.cc)&#xA;char server[] = &quot;arduino.cc&quot;;&#xA;char path[] = &quot;/asciilogo.txt&quot;;&#xA;int port = 80; // port 80 is the default for HTTP&#xA;&#xA;void setup()&#xA;{&#xA;  // initialize serial communications and wait for port to open:&#xA;  Serial.begin(115200);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;Starting Arduino web client.&quot;);&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;&#xA;  // After starting the modem with GSM.begin()&#xA;  // attach the shield to the GPRS network with the APN, login and password&#xA;  while(notConnected)&#xA;  {&#xA;    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &amp;amp;&#xA;      (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))&#xA;      notConnected = false;&#xA;    else&#xA;    {&#xA;      Serial.println(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  // if you get a connection, report back via serial:&#xA;  if (client.connect(server, port))&#xA;  {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    // Make a HTTP request:&#xA;    client.print(&quot;GET &quot;);&#xA;    client.print(path);&#xA;    client.println(&quot; HTTP/1.1&quot;);&#xA;    client.print(&quot;Host: &quot;);&#xA;    client.println(server);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;  } &#xA;  else&#xA;  {&#xA;    // if you didn't get a connection to the server:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // if there are incoming bytes available &#xA;  // from the server, read them and print them:&#xA;  if (client.available())&#xA;  {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;&#xA;  // if the server's disconnected, stop the client:&#xA;  if (!client.available() &amp;amp;&amp;amp; !client.connected())&#xA;  {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;&#xA;    // do nothing forevermore:&#xA;    for(;;)&#xA;      ;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the problem? and where is the problem ?&lt;/p&gt;&#xA;" OwnerUserId="1302" LastActivityDate="2016-02-15T12:12:43.860" Title="Problem with NFC on Arduino MEGA" Tags="|arduino-mega|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4275" PostTypeId="2" ParentId="1180" CreationDate="2014-09-21T15:09:16.303" Score="2" Body="&lt;p&gt;I made an equivalent tool in python that print real time data from ADXL345 accelerometer.&#xA;&lt;a href=&quot;https://github.com/mba7/SerialPort-RealTime-Data-Plotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/mba7/SerialPort-RealTime-Data-Plotter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;may be it will be helpful for someone&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/b1Ywo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just choose the serial com and speed and sent a serial data on the following format:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3 inputs, every input is a 2 bytes (Two's complement )&lt;/li&gt;&#xA;&lt;li&gt;6 bytes seperated by a space&lt;/li&gt;&#xA;&lt;li&gt;the packet is a string terminated by '\n'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Could be easily adapted to change this format &lt;/p&gt;&#xA;" OwnerUserId="4069" LastEditorUserId="4069" LastEditDate="2014-09-29T10:24:19.577" LastActivityDate="2014-09-29T10:24:19.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4276" PostTypeId="2" ParentId="4273" CreationDate="2014-09-21T17:10:25.487" Score="4" Body="&lt;p&gt;Ah, now I see. Your confusion in this case is perfectly understandable. They threw a couple of capacitors into the circuit without explaining &lt;em&gt;why they were added in the first place&lt;/em&gt;. In order to understand why capacitors were added you need to go a little deeper into electronics theory, specifically &lt;strong&gt;capacitance&lt;/strong&gt; and &lt;strong&gt;inductance&lt;/strong&gt;, what they are and how they work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inductance is, to put it succinctly, resistance (&lt;em&gt;not&lt;/em&gt; related to the resistance in resistors, measured in ohms) to change in current by sacrificing or absorbing voltage. If current is 0, then inductance will try to keep it at 0, if at 1A then it will try to keep it at 1A, and so on. Inductance is caused by the magnetic fields generated by electricity flowing through a conductor, and hence &lt;strong&gt;every conductor exhibits some measure of inductance&lt;/strong&gt;. (Coils have much higher inductance though, since the magnetic fields of the loops reinforce each other. And a &quot;core&quot; material such as ferrite or iron intensifies the magnetic field.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, this isn't a large problem if your conductors are short, but as they get longer their inductance can cause power issues. Sudden power demand increases are unable to be accommodated because the supply can't put the increased current through the inductance quickly enough. This is where capacitance comes in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capacitance is resistance to change in &lt;em&gt;voltage&lt;/em&gt; by sacrificing or absorbing &lt;em&gt;current&lt;/em&gt;. When something tries to reduce the voltage either through power consumption or because of high-speed switching, capacitance holds the voltage as close to constant as it can by pulling or dumping electricity out of or into the circuit. Capacitance is caused by charges between two conductors attracting each other through a non-conductive material.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what happens is that a circuit needs bursts of power to work, and if the wires connecting the supply to the circuit have too much inductance then the circuit will be starved of power. We balance this by placing a capacitance close to the circuit so that it can supply power to the circuit for the short time while the supply is busy overcoming the inductance of the wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo, being a mechanical device, needs a decent amount of power. We put a &lt;strong&gt;bulk capacitor&lt;/strong&gt; near it on the supply lines to help provide this power. The analog input connected to the potentiometer needs much, &lt;em&gt;much&lt;/em&gt; less power, so the inductance there isn't a problem and we forgo the capacitor there.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-21T17:10:25.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4277" PostTypeId="2" ParentId="3387" CreationDate="2014-09-21T17:46:03.960" Score="1" Body="&lt;p&gt;Unless (and until) your application needs high enough data rates that you need to make the most efficient use possible of your data channel (or you're talking to an inflexible hardware device that dictates the data protocol), you'll save yourself a lot of headaches by sending human-readable strings, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x= 12345, y=   -32&#xA;x=   432, y=-33221&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can reconstitute them at the other end with with &lt;code&gt;atol()&lt;/code&gt;, log them  to a file, be able to understand them later, and see instantly whether the sender sent what you expected it to. Don't optimize until you have to; you may not have to.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-09-24T13:53:40.607" LastActivityDate="2014-09-24T13:53:40.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4278" PostTypeId="1" AcceptedAnswerId="4279" CreationDate="2014-09-19T02:04:07.963" Score="0" ViewCount="150" Body="&lt;p&gt;I am using Arduino Leonardo and &lt;a href=&quot;https://www.sparkfun.com/products/9815&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ardumoto&lt;/a&gt; to drive 2 12v motors running at 1.3 amps each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I purchased a rechargeable battery of 12V with 5AH&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first started by plugging in the battery to the Arduino via the barrel jack. Arduino then sparks and is fried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read somewhere that I wasn't supposed to hook it up to the Arduino and to hook it up to the VIN ports in the Ardumoto. I purchased a new Arduino and plugged in the Positive and negative from the battery to the ports and now the Ardumoto board fried (copper lining on board burnt off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm reading online and from what I've gathered, the Ardumoto can handle a max of 18 volts and a maximum of 2 amps per each output. I'm obviously missing something and would not like to fry my boards next time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please assist?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/M1ix9.png&quot; alt=&quot;hook up of ardumoto&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/IKzUF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="14387" OwnerDisplayName="teknicalissue" LastEditorUserId="4539" LastEditDate="2014-10-25T16:13:00.803" LastActivityDate="2014-10-25T16:13:00.803" Title="Over voltage on Arduino and Ardumoto" Tags="|motor|arduino-leonardo|arduino-motor-shield|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4279" PostTypeId="2" ParentId="4278" CreationDate="2014-09-19T05:17:40.593" Score="1" Body="&lt;p&gt;From your description, everything &lt;em&gt;should&lt;/em&gt; be wired correctly. It should not have failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, testing this sort of thing with a 5 amp-hour lead-acid battery is not a great way to get started, since a battery that large can source a &lt;em&gt;lot&lt;/em&gt; of current, and doing anything wrong will likely produce immediate and spectacular failure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, the only think I can think of is that you have the polarity of the output lugs/pins on the battery backwards. Buy a $5 multimeter, and check them.&lt;/p&gt;&#xA;" OwnerUserId="86" OwnerDisplayName="Connor Wolf" LastActivityDate="2014-09-19T05:17:40.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4280" PostTypeId="1" AcceptedAnswerId="4282" CreationDate="2014-09-21T20:42:16.330" Score="1" ViewCount="1815" Body="&lt;p&gt;I'm not super-good with my electrical foo. But I've managed to get a &lt;a href=&quot;https://www.sparkfun.com/datasheets/IC/uln2803a.pdf&quot; rel=&quot;nofollow&quot;&gt;ULN2803&lt;/a&gt; wired up to give the +12v that my RGB LED strip needs. The strip has four connectors, RGB and common +12v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My concern is that (I think) the Arduino is shorting out- while the Arduino processes my loop, the USB connection dies and the RX/TX LEDs light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I am wiring things. I'm currently powering the Arduino through USB, so when I say &quot;power supply&quot; I'm referring to the +12v supply I'm using.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;power supply ground to Arduino ground, ULN2803 pin 9.&lt;/li&gt;&#xA;&lt;li&gt;power supply +12v to 2803 pin 10, common +12v on LED strip.&lt;/li&gt;&#xA;&lt;li&gt;arduino output pin 11 to 2803 pin 1&lt;/li&gt;&#xA;&lt;li&gt;2803 pin 18 to green LED strip&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, that's my circuit. It works- the strip lights up. But again, I think it's wrong. How do I correct it?&lt;/p&gt;&#xA;" OwnerUserId="4070" LastEditorUserId="4070" LastEditDate="2014-09-21T22:18:29.857" LastActivityDate="2014-09-22T00:00:10.277" Title="ULN2803 and common-anode RGB strip; how am I doing it wrong?" Tags="|led|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4282" PostTypeId="2" ParentId="4280" CreationDate="2014-09-22T00:00:10.277" Score="1" Body="&lt;p&gt;The COM pin on the ULN2803 is for protection when driving inductive loads, which means motors, solenoid.  For an LED, nothing needs connect to COM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chip you are using is a low side driver.  That means it connects between the low side of the load (your LED) and ground.  When you drive +5 to the input pin, the transistors will conduct, connecting the output pin to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for your LED strip make the following connections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino output pin -&gt; driver input, 1B = pin 1 &lt;/li&gt;&#xA;&lt;li&gt;driver output, 1C = pin 18 -&gt; LED strip R G or B &lt;/li&gt;&#xA;&lt;li&gt;+12 -&gt; LED strip common power&lt;/li&gt;&#xA;&lt;li&gt;ground -&gt; GND = pin 9&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Without the ground connection on the driver chip, no surprise that odd things happened.  There are diodes designed to protect the input and output pins (&lt;a href=&quot;http://www.ti.com/lit/ds/symlink/uln2803a.pdf&quot; rel=&quot;nofollow&quot;&gt;see chip data sheet&lt;/a&gt;).  Without the ground connection to the driver chip, the input protection diode might have been conducting back to the microcontroller output pin.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-09-22T00:00:10.277" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4283" PostTypeId="1" AcceptedAnswerId="4285" CreationDate="2014-09-22T00:53:17.937" Score="0" ViewCount="227" Body="&lt;p&gt;I'm planning on an Arduino project for a restaurant I work at that would require determining how busy it is at any point in time, but I'm not sure how I would go about procuring this information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have access to any of their IT systems or I would have simply pulled the data from their till systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking perhaps measuring the ambient sound of the restaurant as it gets quite loud during peak time but that could be thrown off when the music volume is adjusted.&lt;/p&gt;&#xA;" OwnerUserId="4074" LastEditorUserId="4074" LastEditDate="2014-09-22T09:22:48.557" LastActivityDate="2014-09-22T09:31:32.647" Title="Sensing busy-ness of a restaurant?" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4284" PostTypeId="1" AcceptedAnswerId="4286" CreationDate="2014-09-22T05:10:39.913" Score="3" ViewCount="18470" Body="&lt;p&gt;I'm looking for a way to allow Arduino to control a motor using PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far what I have gathered is that using Arduino's PWM sets the digital value of 255 to 5v and 0 to 0v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However what I am looking to do is to set the motors to stop at 2.5v, move forward as it approaches 5v and move backwards as it approaches 0v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion on how I would go about accomplishing this will be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2017-07-28T05:37:56.397" Title="Use Arduino's PWM to control motor direction?" Tags="|motor|pwm|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4285" PostTypeId="2" ParentId="4283" CreationDate="2014-09-22T09:12:14.660" Score="1" Body="&lt;p&gt;There are a few ways to  go about it but my initial thoughts would be to detect people entering (and exciting) the front door and simply keep a running total.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motion detector &#xA;&lt;a href=&quot;http://www.adafruit.com/products/189&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/189&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IR beam detectors&#xA;&lt;a href=&quot;http://arduino-info.wikispaces.com/InfraredBeamPair&quot; rel=&quot;nofollow&quot;&gt;http://arduino-info.wikispaces.com/InfraredBeamPair&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3772" LastEditorUserId="3772" LastEditDate="2014-09-22T09:31:32.647" LastActivityDate="2014-09-22T09:31:32.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4286" PostTypeId="2" ParentId="4284" CreationDate="2014-09-22T09:50:53.293" Score="6" Body="&lt;p&gt;You seem to have misunderstood PWM here. It's actually a digital signal which is constantly pulsing on and off very quickly (several hundred times per second). You don't actually change the output voltage at all -- it's only ever HIGH or LOW (+5v or +0v). The thing you change is how long the signal is HIGH for on each pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page gives a deeper explanation: &lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM&quot;&gt;http://arduino.cc/en/Tutorial/PWM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're controlling a DC motor, this approach is actually better than varying the voltage. The constant pulses still make the motor turn at an adjustable speed, but without losing torque. PWM is also useful for controlling the brightness of LEDs, which don't respond so well to changes in current/voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To address your original motor control question, there's no sensible way to change the motor's direction using the PWM value. You will need some additional circuitry which is able to reverse the polarity of the connections to the motor (meaning your PWM value just controls speed, and doesn't care about direction).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An H-bridge is the usual approach for this. Here's a fairly good tutorial which covers the basic principles: &lt;a href=&quot;http://www.instructables.com/id/H-Bridge-on-a-Breadboard&quot;&gt;http://www.instructables.com/id/H-Bridge-on-a-Breadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously you'd need to modify it for use with your Arduino project. The push switches could easily be replaced by digital signals from a couple of Arduino pins. The motor's power supply would be controlled by the PWM signal. You'll need an extra transistor for that, because you can't safely power the motor directly from an Arduino pin.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-09-22T09:50:53.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4287" PostTypeId="1" CreationDate="2014-08-27T19:05:56.063" Score="3" ViewCount="284" Body="&lt;p&gt;I recently read &lt;a href=&quot;http://horrorcoding.altervista.org/arduino-development-with-eclipse-a-step-by-step-tutorial-to-the-basic-setup/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; post about setting up Eclipse for Arduino.  I Build the test project with no erros, but when I go to upload my test project it just hangs at 5%, with no error messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I unplug the arduino-uno it cancels the upload, so I know it can see the arduino board. It is just not uploading. Does anyone have any ideas as to what is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know whats changed, but now it doesn't hang i just get a message after trying to upload:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3875" OwnerDisplayName="erik" LastActivityDate="2014-09-22T09:59:51.900" Title="Eclipse AVR for arduino not uploading" Tags="|avrdude|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4289" PostTypeId="2" ParentId="4284" CreationDate="2014-09-22T11:35:52.240" Score="0" Body="&lt;p&gt;You can use a MOSFET to control a DC motor directly from an Arduino. Using a H-Bridge is another way to control DC motors. Probably the L298N is the most used one but I prefer TB6612FNG. It's a bit expensive, but uses much less current and is something with a better response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will find tons of tutorial with both modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="3823" LastEditorUserId="19409" LastEditDate="2017-07-27T13:14:55.990" LastActivityDate="2017-07-27T13:14:55.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4290" PostTypeId="2" ParentId="4284" CreationDate="2014-09-22T15:41:16.493" Score="0" Body="&lt;p&gt;continuous rotation servo demonstrates a different approach of using PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A continuous rotation servo is a standard servo modified in 2 ways. First the &quot;position feedback&quot; in the servo is disconnected and set to always read as if the servo was in the center position. Second the &quot;stop&quot; which physically prevents the motor from turning 360 degrees is removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then if you set the servo to 0 degrees it rotates fast in one direction if you set it 180 degrees it move in the opposite direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/modifying-servos-for-continuous-rotation&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/modifying-servos-for-continuous-rotation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="337" LastEditorUserId="35247" LastEditDate="2017-07-28T05:37:56.397" LastActivityDate="2017-07-28T05:37:56.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4291" PostTypeId="1" CreationDate="2014-09-22T16:18:51.253" Score="1" ViewCount="7402" Body="&lt;p&gt;I have two 300RPM 12V DC motors connected to arduino motor shield r3 that is mounted on arduino uno board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is my motors  runs very slow some times not even running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After googling I found I need to use external power supply. I did  supplied 9 volt dc power to arduino motor shield r3. &#xA;But still motor is running very slow what could be the issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When supplying power to arduino motor shield r3  via external power supply pins do I need still need to provide separate power to arduino uno board via power jack. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use 9 volt dc for arduino uno board and another 9 volt batter to arduino motor shield r3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is single 9 volt batter enough for running two 300RPM 12 dc motor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/H8ohz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My program &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          void setup() {&#xA;&#xA;          //Setup Channel A&#xA;          pinMode(12, OUTPUT); //Initiates Motor Channel A pin&#xA;          pinMode(9, OUTPUT); //Initiates Brake Channel A pin&#xA;&#xA;          //Setup Channel B&#xA;          pinMode(13, OUTPUT); //Initiates Motor Channel A pin&#xA;          pinMode(8, OUTPUT);  //Initiates Brake Channel A pin&#xA;&#xA;        }&#xA;&#xA;        void loop(){&#xA;&#xA;&#xA;          //Motor A forward @ full speed&#xA;          digitalWrite(12, HIGH); //Establishes forward direction of Channel A&#xA;          digitalWrite(9, LOW);   //Disengage the Brake for Channel A&#xA;          analogWrite(3, 255);   //Spins the motor on Channel A at full speed&#xA;&#xA;          //Motor B backward @ half speed&#xA;          digitalWrite(13, LOW);  //Establishes backward direction of Channel B&#xA;          digitalWrite(8, LOW);   //Disengage the Brake for Channel B&#xA;          analogWrite(11, 123);    //Spins the motor on Channel B at half speed&#xA;&#xA;&#xA;          delay(3000);&#xA;&#xA;&#xA;          digitalWrite(9, HIGH);  //Engage the Brake for Channel A&#xA;          digitalWrite(9, HIGH);  //Engage the Brake for Channel B&#xA;&#xA;&#xA;          delay(1000);&#xA;&#xA;&#xA;          //Motor A forward @ full speed&#xA;          digitalWrite(12, LOW);  //Establishes backward direction of Channel A&#xA;          digitalWrite(9, LOW);   //Disengage the Brake for Channel A&#xA;          analogWrite(3, 123);    //Spins the motor on Channel A at half speed&#xA;&#xA;          //Motor B forward @ full speed&#xA;          digitalWrite(13, HIGH); //Establishes forward direction of Channel B&#xA;          digitalWrite(8, LOW);   //Disengage the Brake for Channel B&#xA;          analogWrite(11, 255);   //Spins the motor on Channel B at full speed&#xA;&#xA;&#xA;          delay(3000);&#xA;&#xA;&#xA;          digitalWrite(9, HIGH);  //Engage the Brake for Channel A&#xA;          digitalWrite(9, HIGH);  //Engage the Brake for Channel B&#xA;&#xA;&#xA;          delay(1000);&#xA;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4080" OwnerDisplayName="shakthydoss" LastEditorUserId="4539" LastEditDate="2014-10-25T16:12:19.547" LastActivityDate="2014-10-25T16:12:19.547" Title="Two 300RPM 12V DC motors connected to arduino motor shield r3 power supply" Tags="|arduino-uno|power|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="4292" PostTypeId="1" CreationDate="2014-09-22T17:22:30.963" Score="0" ViewCount="5318" Body="&lt;p&gt;I have come across the various blogs which talks about cloning RF remote using cheap 434 MHz Tx/Rx and RCSwitch library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using RF 434 MHz ASK (&lt;a href=&quot;https://www.sparkfun.com/products/10532&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10532&lt;/a&gt;) module with arduino, but the range I get it very less , just around 5-6 centimeters. Seems these RF 434 MHz modules are not stable. So I am planning to use now another RF Module which uses NRF905.&#xA;Link - &#xA;&lt;a href=&quot;http://www.ebay.com/itm/2pcs-NRF905-wireless-module-PTR8000-wireless-transmission-433-486-915MHz-/270963407796&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/2pcs-NRF905-wireless-module-PTR8000-wireless-transmission-433-486-915MHz-/270963407796&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My query is can I use NFR905 based RF modules which is also 434 Mhz to clone any existing remote working on 434 MHz. Please help&lt;/p&gt;&#xA;" OwnerUserId="4081" LastActivityDate="2015-01-20T23:53:48.193" Title="RF Remote Clone using NRF905" Tags="|arduino-uno|rf|remote-control|nrf24l01+|virtualwire|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4293" PostTypeId="2" ParentId="4291" CreationDate="2014-09-22T18:20:25.530" Score="2" Body="&lt;p&gt;The external power of the shield is connected to the VIN pin, so it will power the Arduino via that. (vin goes to the voltage regulator that will provide the 5v the arduino needs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect two batteries in parallel to provide mode current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since they are 12v motors, they would need 12v to run at maximum power. 9v is a lot less than that.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-22T18:20:25.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4294" PostTypeId="2" ParentId="4292" CreationDate="2014-09-22T18:30:17.667" Score="1" Body="&lt;p&gt;You can connect an external antenna to pin 8 on that module. Just use a piece of wire that is 17.3cm long. But since the range is that bad to start with, probably means it isn't tuned very well. I'd return it, or try fiddling with the pot at the back. Not sure why Sparkfun has these crap transceivers for sale. Transceivers without a crystal are very inaccurate in their frequency. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only need to transmit, I'd suggest this products: &lt;a href=&quot;https://www.sparkfun.com/products/10534&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10534&lt;/a&gt;&#xA; . Those worked great for me, and are currently switching on the power sockets for my lights when it gets dark enough.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-22T18:30:17.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4296" PostTypeId="1" AcceptedAnswerId="4304" CreationDate="2014-09-22T20:47:28.297" Score="2" ViewCount="3485" Body="&lt;p&gt;I want to control a low voltage (hobby class) motor with a 8Mhz/3.3v Arduino Pro Micro.  I'd like to power both from 2 alkaline cells.  The motor draws approximately 1 A @ 3V with new batteries.  I would be doing PWM of a couple of channels at the normal Arduino rates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought is to connect the batteries to the Vcc pin (not Vraw) and run the Arduino unregulated at about 3V, but somewhat less when the motor is running.  I'm willing to reprogram the fuses for a lower brownout voltage (or none) if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm feeling my way on the rest of this - I'll lay out my (perhaps naive) approach and get some feedback about whether I'm understanding it, and how to proceed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With such a low battery voltage, a TIP120 darlington seems to drop too much voltage and substantially reduce the motor speed/power.  So I'm thinking that I need to use a power N channel MOSFET, and it appears that I need to be fairly selective to get one which can sufficiently turn on with a &amp;lt;3V gate to source voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm considering something like the &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;FQP30N06L &lt;a href=&quot;http://www.mouser.com/ds/2/149/FQP30N06L-244344.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/ds/2/149/FQP30N06L-244344.pdf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I read the datasheet correctly, Vgs of 3V and a load Ids of 1A would result in less than 100mV drop Vds.  But this transistor may be overkill, and the TO220 package is larger than I'd prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm willing to deal with SOT-23-3 surface mount packaging, there are some options like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Toshiba SSM3K324RLF &lt;a href=&quot;http://www.semicon.toshiba.co.jp/info/docget.jsp?type=datasheet&amp;amp;lang=en&amp;amp;pid=SSM3K324R&quot; rel=&quot;nofollow&quot;&gt;http://www.semicon.toshiba.co.jp/info/docget.jsp?type=datasheet&amp;amp;lang=en&amp;amp;pid=SSM3K324R&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Infineon BSS806NE  &lt;a href=&quot;http://www.mouser.com/ds/2/196/BSS806NE_Rev2%2001-359816.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/ds/2/196/BSS806NE_Rev2%2001-359816.pdf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I'm reading it right, with 2x1.5v (nominal) batteries directly powering an Arduino Pro Micro, I can sufficiently drive Vgs to handle 1A Ids at a small Vds and a low enough power dissipation, with any of these three.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would put a reverse diode and a cap across the motor.  I've seen devices with a small electrolytic across the motor terminals, and I've seen a smaller value ceramic cap - what's the best practices?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a feasible and reasonable approach?  What are the gotcha's that I need to take into consideration?  Any advice about choosing among these (or other) transistors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My concerns are: not understanding MOSFETs enough, and the unregulated power supply being too noisy for the ATMega328p when it's also powering the motor.  Can I handle the latter by adding another cap or two across the Arduino Pro Micro's Vcc/Ground?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Backup option: run 3x1.5v alkalines and power the Arduino Pro Micro through its regulated Vraw input.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-09-23T15:16:42.970" Title="Driving power MOSFET from 3.3v or lower Arduino Pro Mini" Tags="|power|arduino-pro-mini|mosfet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4297" PostTypeId="2" ParentId="4271" CreationDate="2014-09-22T21:20:24.720" Score="1" Body="&lt;p&gt;it seems like you are using the wrong serial interface. I see &lt;code&gt;Serial&lt;/code&gt; and &lt;code&gt;mySerial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After &lt;code&gt;mySerial.begin()&lt;/code&gt; you write to &lt;code&gt;Serial&lt;/code&gt;, not to &lt;code&gt;mySerial&lt;/code&gt; which runs on pins 10 and 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's when you send the AT Commands from your Serial connection to the Arduino? It Should redirect them to the GSM board.&lt;/p&gt;&#xA;" OwnerUserId="4085" LastEditorUserId="37" LastEditDate="2014-09-23T02:35:51.833" LastActivityDate="2014-09-23T02:35:51.833" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4298" PostTypeId="2" ParentId="4099" CreationDate="2014-09-22T21:51:24.903" Score="3" Body="&lt;p&gt;Keeping this here for future reference. It appears these motors have a minimum RPM of sorts and running them on a lower RPM causes the jitter effect described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like I mentioned in the updates when running at 10RPM or above these motors seem to perform very nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I recently bought a ADAFruit motorshield and I am getting much more stable results with this shield and the stepper motors. I am even running them off 6V and they are working perfectly even at lower rpm.&lt;/p&gt;&#xA;" OwnerUserId="3897" LastEditorUserId="3897" LastEditDate="2014-10-28T21:26:40.283" LastActivityDate="2014-10-28T21:26:40.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4300" PostTypeId="2" ParentId="4274" CreationDate="2014-09-22T22:41:15.617" Score="1" Body="&lt;p&gt;It is likely that placing the GSM shield between the Arduino Mega and the NFC shield is interfering with the GSM antenna.  Antennas react in strange and usually less useful ways when large conductors are placed nearby.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try reversing the order of attaching the shields, or you could try spacing the shields further apart using &quot;stackable Arduino headers&quot; (you can do a web search for suppliers).  If there is an option for an external antenna, that would be even better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get GSM working, you might still have some trouble with the NFC shield, as it's possible that the GSM transmitter being so close could interfere with the NFD's circuitry - not because they use the same frequences, but just because any conductor so close might pick up electrical noise, and there will be various sensitive circuitry in the NFC electronics.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2014-09-22T22:41:15.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4301" PostTypeId="1" AcceptedAnswerId="4302" CreationDate="2014-09-23T07:45:39.677" Score="1" ViewCount="100" Body="&lt;p&gt;This is what I get using a MMA7361 breakout board (just the IC, no resistors or capacitors). The IC is powered using arduino nano's 3v3 pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The x, y, z values are read from analog pins A0, A1, A2. The readings are subtracted with 338.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x   y   z &#xA;-4 -26 44&#xA;44 -27 -5&#xA;-57 -11 27&#xA;-29 -23 22&#xA;28 -21 9&#xA;-44 3 20&#xA;-26 -14 39&#xA;26 -32 -8&#xA;-17 -12 19&#xA;-30 -15 35&#xA;4 -26 14&#xA;24 -43 49&#xA;-58 -19 0&#xA;16 -29 24&#xA;9 -48 13&#xA;-58 -42 12&#xA;12 -47 14&#xA;-24 -31 9&#xA;-46 -31 10&#xA;16 -52 1&#xA;-43 -21 8&#xA;-31 -25 16&#xA;37 -18 11&#xA;-45 -10 20&#xA;-22 -36 16&#xA;27 -19 20&#xA;-5 -9 1&#xA;-59 -10 10&#xA;37 -18 30&#xA;-53 -18 16&#xA;-30 -8 10&#xA;54 -19 17&#xA;-27 -29 15&#xA;-40 -23 -14&#xA;-1 -18 19&#xA;34 -22 2&#xA;-35 -24 41&#xA;13 -17 7&#xA;-14 -17 21&#xA;-39 -14 35&#xA;-19 -31 6&#xA;62 -9 34&#xA;-63 -16 16&#xA;-12 -6 23&#xA;60 -33 36&#xA;-45 -2 34&#xA;-18 -15 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the x value, when the whole thing is not moving, can range from -59 to +44. This looks very unusual as other people's reading seems to have just +-3 deviations. What might be wrong with my setup?&lt;/p&gt;&#xA;" OwnerUserId="4088" LastActivityDate="2014-09-23T09:33:44.833" Title="MMA7361 readings deviate a lot" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4302" PostTypeId="2" ParentId="4301" CreationDate="2014-09-23T09:33:44.833" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;(just the IC, no resistors or capacitors)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;What might be wrong with my setup?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's easy: You miss the capacitors ;-)&#xA;Check figure 5 of the &lt;a href=&quot;http://cache.freescale.com/files/sensors/doc/data_sheet/MMA7361LC.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; and try again.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-09-23T09:33:44.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4303" PostTypeId="1" CreationDate="2014-09-23T13:16:00.450" Score="7" ViewCount="10276" Body="&lt;p&gt;This question might seem stupid, but I have been curious about it for a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am a new engineering student, and we learned a lot about &quot;designing a controller&quot;. For example, design controller for a car steering system and so on. All the &quot;controllers&quot; we designed are in the Laplace domain aka s-domain. And most of the times it will be just a transfer function. So how do real control system engineers use these transfer functions in arduino and other microcontrollers? I mean you cannot just put the function in there right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have to convert the transfer function to some other form and write the code for the microcontroller or is there a simpler way to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time!&lt;/p&gt;&#xA;" OwnerUserId="4092" LastActivityDate="2017-04-22T11:24:50.920" Title="From transfer function to arduino" Tags="|programming|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4304" PostTypeId="2" ParentId="4296" CreationDate="2014-09-23T15:16:42.970" Score="1" Body="&lt;p&gt;I don't think the mosfets will be an issue. Looking at the last one (BSS806NE); in figure 5 in the datasheet you see that for 1A and 1.4v (Vgs) you'd get a Vds of only .1v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think a bigger problem might be the voltage of the batteries dropping under load. You'd have to measure that with a multimeter while the motor is running. A simple cap might help with a little noise, but not with the voltage dropping while the motor is running. Not sure how much the AVR would mind having its supply voltage dropping all of a sudden.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the top of my head the minimal voltage of the Atmega328 @8mhz is 1.8v, while default fuse settings use 2.7v, so I'd probably change to fuses to make BOD at 1.8v. Other fuses don't need to change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Backup option sound good, though you might have to go with 4 x 1.5v depending on the voltage drop under load. Another alternative might be to have two sets of 1.5v batteries in parallel, halving the current load on each battery.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-23T15:16:42.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4307" PostTypeId="1" CreationDate="2014-09-23T19:25:17.557" Score="1" ViewCount="3332" Body="&lt;p&gt;I am new to Arduino and I am trying to control it through MATLAB.  I have downloaded the arduino IO package and installed it.I am using MATLAB 2014a.I have a LED and I change its brightness by changing the PWM voltage as follows :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a=arduino('COM3');&#xA;brightness_step = (5-0)/20;&#xA;   for i = 1:20&#xA;      writePWMVoltage(a, 11, i*brightness_step);&#xA;      val=a.analogRead(0);&#xA;      display(val)&#xA;      pause(0.1);&#xA;   end&#xA;&#xA;   for i = 1:20&#xA;      writePWMVoltage(a, 11, 5-i*brightness_step);&#xA;      val=a.analogRead(0);&#xA;      display(val)&#xA;      pause(0.1);&#xA;   end&#xA;clear a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works great except for the analogRead part which throws the following error :&#xA;&lt;strong&gt;No appropriate method, property, or field analogRead for class arduino.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="4090" LastEditorUserId="4090" LastEditDate="2014-09-23T19:56:43.897" LastActivityDate="2016-02-18T02:23:40.497" Title="analogRead function not working in MATLAB" Tags="|arduino-uno|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4308" PostTypeId="1" CreationDate="2014-09-23T22:38:26.387" Score="0" ViewCount="1498" Body="&lt;p&gt;I have a project in Microsoft Visual Studio C# and I have to pass JSON data to my Arduino via Ehternet Shield.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it works:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/FIqpE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? How to do it?&lt;/p&gt;&#xA;" OwnerUserId="3313" LastEditorUserId="3313" LastEditDate="2014-09-24T10:55:47.710" LastActivityDate="2014-09-24T10:55:47.710" Title="Webservice C# JSON to Arduino" Tags="|web-service|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4309" PostTypeId="2" ParentId="1180" CreationDate="2014-09-24T01:10:40.683" Score="6" Body="&lt;p&gt;You can try &lt;strong&gt;&lt;a href=&quot;https://code.google.com/p/serialchart/&quot; rel=&quot;noreferrer&quot;&gt;serialchart&lt;/a&gt;&lt;/strong&gt;. It's pretty strait forward program. It does exactly what you asked. The only disadvantage is that it requires data in CSV format (does not meet first point).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Screenshot from project page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7I9kA.png&quot; alt=&quot;example&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4102" LastActivityDate="2014-09-24T01:10:40.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4311" PostTypeId="1" AcceptedAnswerId="4312" CreationDate="2014-09-24T05:41:55.423" Score="1" ViewCount="233" Body="&lt;p&gt;Using a H-bridge, I've connected my DC Motors to an Arduino. When I accept the external power source from a wall, using a 9V battery eliminator, the motors spin well and consistently. However, when I connect it to a 9V battery, the motors spin slower, and the speed deteriorates till the motors stop. This happens in approximately 5 minutes. I checked with multiple 9V batteries of the same type. I have tested the batteries to check if they're dead after the motors stop. They are not, and if I reconnect the motors to them, the same process occurs all over again. I have checked for short circuits, and there are none. Any possible ideas as to why this is happening?&lt;/p&gt;&#xA;" OwnerUserId="4104" LastActivityDate="2014-09-24T10:05:45.720" Title="Why does the battery eliminator connected to the wall provide a better spin to my dc motors than my battery of the same voltage?" Tags="|arduino-uno|power|motor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4312" PostTypeId="2" ParentId="4311" CreationDate="2014-09-24T05:51:48.220" Score="4" Body="&lt;p&gt;First off, never use 9V batteries to power motors or any device that consumes more than a few hundreds mA. Those batteries are just too weak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now a battery eliminator is not a pure equivalent as it can typically supply 800 mA or more, depending on the model you get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only commonalities between the battery and the eliminator are the 9V voltage and the socket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to power DC motors with batteries then rather use several 1.5V batteries in series.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-09-24T05:51:48.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4313" PostTypeId="2" ParentId="4311" CreationDate="2014-09-24T05:54:12.013" Score="2" Body="&lt;p&gt;Batteries use a chemical process to produce power. If you draw to much current (motors use quite lot) the chemical process can't keep up and the voltage will drop, resulting in a slower running motor. Try connecting two batteries in parallel. That way each battery only has to produce half the current. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-09-24T05:54:12.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4314" PostTypeId="1" CreationDate="2014-09-24T05:21:56.813" Score="3" ViewCount="2533" Body="&lt;p&gt;I am designing a experiment of controlling 6 small wind turbines wirelessly. For each wind turbine, I need to measure power time series (or voltage or current time series) from the generator, and control blade pitch angle, yaw angle, and generator load (using variable resistance). The control input will be all PWM signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am planning to put an Arduino UNO with a ZigBee wireless module to each wind turbine, making it measure the power time series and transmit to the central node, as well as receive the control input from the central node and command the control input to servo motors. The central node will be additional Arduino UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible for each Arduino to send time series signal to central node wirelessly without interference with other Arduino? (6 wind turbines transmitting time series to a central server). If it is possible, How can I implement such network ? recommending a source for learning would be also greatly helpful.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Interface between the central node and the computer software: The algorithm in the computer need to process the received power time series and determine the optimum control input for 6 wind turbines. Then these control input should be transmitted to wirelessly to 6 wind turbines. In such case, what is the good option to interface the algorithm and the Arduino connected to the computer? Currently the algorithm is written in Matlab. I heard there is the sketch interfacing Arduino and Matlab, is it efficient enough for such project?   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4106" OwnerDisplayName="Jinkyoo Park" LastEditorUserId="313" LastEditDate="2014-09-24T12:34:08.643" LastActivityDate="2014-10-02T17:04:08.580" Title="Communicating between a computer and multiple Arduinos" Tags="|arduino-uno|networking|matlab|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4317" PostTypeId="2" ParentId="4303" CreationDate="2014-09-24T09:02:49.007" Score="5" Body="&lt;p&gt;Let's assume you have an Arduino that you have arranged to sample a signal with a sample rate of 1/T that is then processed by your controller. Let's also assume that the processing time for your controller is small compared to T e.g. 0.1/T&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, you need to convert the controller transfer function to discrete time. There are lots of ways to do this. Matlab has a convenient c2d() function. One way you can do it on paper (not the best way), is to use Euler's Method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;s=(z-1)/T&lt;/strong&gt;   where T is the sampling period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Converting a transfer function then: &lt;strong&gt;(s+a)/(s+b) =&gt; (z-(1-aT))/(z-(1-bT))&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have a TF in z such as : &lt;strong&gt;Y(z)/X(z)=(z-c)/(z-d)&lt;/strong&gt;  where Y is the output and X is the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To implement this in a controller you need this as a difference equation in terms of delays. So convert the equation to a function of (z^-1) which is a delay:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Y(z)/X(z) = (1-cz^-1)/(1-dz^-1)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and re-write as:&#xA;&lt;strong&gt;Y(Z)(1-dz^-1) = X(z)(1-cz^-1)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Y(Z)-d.Y(z).z^-1 = X(z)-c.X(z).z^-1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and change to sample time treating z^-1 as a delay:&#xA;&lt;strong&gt;y(n) - d.y(n-1) = x(n) - c.x(n-1)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rearranging:&#xA;&lt;strong&gt;y(n) = d.y(n-1) + x(n) - c.x(n-1)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can implement this easily in the Arduino by realising that y(n-1) is the previous value of y(n) and similarly for x(n), and x(n) is the value input to the controller; i.e. the reference minus the output from the ADC.&lt;/p&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2014-09-25T10:59:30.990" LastActivityDate="2014-09-25T10:59:30.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4318" PostTypeId="2" ParentId="4311" CreationDate="2014-09-24T10:05:45.720" Score="4" Body="&lt;p&gt;The question is not about volts, but current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 9V battery is notoriously bad at powering anything that requires high current, like running a motor. Due to to chemical nature of the battery, the 9V will struggle to keep supplying enough current and will fairly quickly drain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A regular alkaline 9V block can supply you with 565 mAh, which is not much if you power motors. You'll have more luck with LiPo (lithium polymer) batteries, which are capable of supplying 2200 mAh or more!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To learn more about different types of batteries check out &lt;a href=&quot;https://learn.sparkfun.com/tutorials/battery-technologies&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/battery-technologies&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wall power can quite easily provide the required current your motors need.&lt;/p&gt;&#xA;" OwnerUserId="3930" LastActivityDate="2014-09-24T10:05:45.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4319" PostTypeId="2" ParentId="4308" CreationDate="2014-09-24T10:12:10.070" Score="2" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using an Ethernet Shield, you should be able to run a webserver on the Arduino and simple do an HTTP request from your C# webservice to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check this tutorial on how to write a webserver for arduino using the ethernet shield: &lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WebServer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing an HTTP request of any kind from C# should be easy enough and is not in the scope of this site.&lt;/p&gt;&#xA;" OwnerUserId="3930" LastActivityDate="2014-09-24T10:12:10.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4320" PostTypeId="2" ParentId="4213" CreationDate="2014-09-24T13:25:25.027" Score="1" Body="&lt;p&gt;As @Garben mentioned, we do not know what is your question, problem or whatever...&#xA;Provide some more information about wiring. I looked at your question 5 mins and still can't get what is wrong...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are you doing here??? Sending from Arduino+XBEE to another Arduino+XBEE???&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    Serial.println(&quot;Hello&quot;);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you are resending what you got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;     if(Serial.available()&amp;gt;0){&#xA;         Serial.print((char)Serial.read());&#xA;     }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what is your problem? Or is this all your code???&#xA;Arduino has to have &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;//Set up your Arduino here&#xA;}&#xA;void loop(){&#xA;//Code here will run over and over and over...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-09-24T13:25:25.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4321" PostTypeId="1" CreationDate="2014-09-24T14:19:04.357" Score="1" ViewCount="335" Body="&lt;p&gt;I just picked up a new Arduino Micro for a project, but the first time I tried to upload to it, things went terribly wrong. The USB cable was loose, so the power light kept blinking on and off. When I did get it stable, I accidentally had 'Uno' selected under 'Tools-&gt;Board'. I think this was the source of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware that the solution for these kinds of problems is to try to upload some simple code while in bootloader mode, but pressing reset shortly after pressing the Upload button. But this board doesn't even respond when I press reset. I have tried it with both the on-board button and with an externally button linking RS to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the board doesn't show up in my Device Manager, not even as an &quot;Unknown Device&quot;. The device managed doesn't even refresh when I plug it in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the connection is okay because the power light is on. And I know it's not a driver issue or an issue with the port, because I have no trouble getting a different Micro recognized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I haven't tried is burning the bootloader through ICSP, since I don't have the right cable. Is there anything else I can try, or is this just bricked?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, everyone&lt;/p&gt;&#xA;" OwnerUserId="4108" LastActivityDate="2015-06-27T20:34:54.257" Title="Micro not detected, can't reset" Tags="|bootloader|reset|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4323" PostTypeId="2" ParentId="1380" CreationDate="2014-09-24T16:52:44.733" Score="0" Body="&lt;p&gt;The only way I have been able to fix this is revert back to Ubuntu 12.04. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is something about 14.04 that does not play nice with the Micro. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried running avrdude on the command line as well with no luck. The Arduino IDE code jumps through some hoops to detect the proper USB port, so timing is probably critical. I don't know the secret sauce for 14.04 though. The micro is tricky since USB is disconnected and reconnected during programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anybody has better luck with this please update. &lt;/p&gt;&#xA;" OwnerUserId="4110" LastEditorUserId="84" LastEditDate="2014-09-24T19:29:35.477" LastActivityDate="2014-09-24T19:29:35.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4326" PostTypeId="1" CreationDate="2014-09-24T19:30:12.387" Score="2" ViewCount="20983" Body="&lt;p&gt;Do ultrasonic sensors sense through transparent materials?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case, I have to read if there's something inside a transparent acrylic bottle.&lt;/p&gt;&#xA;" OwnerUserId="4115" LastEditorUserId="37" LastEditDate="2014-09-24T19:51:16.607" LastActivityDate="2019-05-19T10:09:25.717" Title="Do ultrasonic sensors sense through transparent materials?" Tags="|sensors|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4328" PostTypeId="2" ParentId="4326" CreationDate="2014-09-24T20:00:33.977" Score="2" Body="&lt;p&gt;I'm assuming you mean a &quot;normal&quot; sensor, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TaZjQm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultrasonic sensors work by sending out sound waves. Obviously, sound waves don't care whether a material is transparent or opaque, so they are blocked just as easily by acrylic as by a brick wall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note: If you look on the front of an ultrasonic sensor, you will notice that it is covered by a screen, not glass or plastic. This is why.&lt;/p&gt;&#xA;" OwnerUserId="37" LastActivityDate="2014-09-24T20:00:33.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4329" PostTypeId="2" ParentId="4326" CreationDate="2014-09-24T20:00:45.480" Score="-1" Body="&lt;p&gt;Well, you can visualize babies in a womb using ultrasonic sensors. So why should it be a problem to &quot;hear&quot; inside a bottle? Maybe not with the sensors you can afford, and maybe not with an arduino, but basically &lt;a href=&quot;http://en.wikipedia.org/wiki/Ultrasonic_testing&quot; rel=&quot;nofollow&quot;&gt;it is possible&lt;/a&gt;, even if the bottle is not transparent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if the bottle is open, and the content is liquid, a simple approach could be implementing a kind of ultrasonic range finder. This can be done with comparatively cheap hardware.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-09-24T20:00:45.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4330" PostTypeId="2" ParentId="1180" CreationDate="2014-09-24T22:06:03.857" Score="2" Body="&lt;p&gt;While I haven't used it myself, &lt;a href=&quot;http://wiki.ros.org/rqt_plot&quot; rel=&quot;nofollow&quot;&gt;&quot;rqt_plot&quot;&lt;/a&gt; running on the PC seems to be a popular way to plot data on a PC that comes over a serial port from an Arduino running a sketch that includes the &lt;a href=&quot;http://wiki.ros.org/rosserial_arduino&quot; rel=&quot;nofollow&quot;&gt;rosserial_arduino&lt;/a&gt; library or the &lt;a href=&quot;https://github.com/hbrobotics/ros_arduino_bridge&quot; rel=&quot;nofollow&quot;&gt;ros_arduino_bridge&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20Oscilloscope&quot; rel=&quot;nofollow&quot;&gt;Arduino Oscilloscope Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://answers.ros.org/question/28548/rosserial-arduino/&quot; rel=&quot;nofollow&quot;&gt;rosserial arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://defendtheplanet.net/2014/05/21/ultrasonic-sensor-hc-sr04-as-a-ros-range-publisher/&quot; rel=&quot;nofollow&quot;&gt;visualize everything using rqt_plot... my first arduino micro ros project&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&quot;7/24: Now that I have the Arduino set up using Kessel, I can &lt;a href=&quot;http://bdml.stanford.edu/Main/NikhilLeleSummer&quot; rel=&quot;nofollow&quot;&gt;visualize the data better using ROS tools&lt;/a&gt;&quot;&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-09-24T22:06:03.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4332" PostTypeId="2" ParentId="4326" CreationDate="2014-09-25T01:18:41.053" Score="1" Body="&lt;p&gt;Ultrasonic sensors detect echoes of high frequency sounds bouncing off of a boundary between  air and some other substance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have pointed out, the light transmission properties of an object (transparency to light) has nothing to do with its transparency to ultrasonic sound waves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible to project ultrasonic sounds through solids or liquids, but that's not what these sensors are designed to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to send ultrasonic pulses through an acrylic bottle will no doubt mess up the signals. Try pointing one of these sensors at an acrylic bottle in a controlled environment (fixed distance, mounted firmly and the same way each time, a solid back-stop at a fairly large, fixed distance behind the bottle to avoid varying echoes from behind the bottle) and check the distance measurement with the bottle full and empty. If you detect a difference in readings, then use those 2 different distance values for full and empty. (But make sure your production environment is the same as your test environment, including the area around and behind the bottle you're measuring)&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-25T01:18:41.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4334" PostTypeId="2" ParentId="4307" CreationDate="2014-09-25T06:41:19.907" Score="0" Body="&lt;p&gt;Sorry, I don't have MatLab to verify this but try this in the two places you call a.analogRead(0);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val=analogRead(a,0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is based on what appears to be the &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/32374-matlab-support-for-arduino--aka-arduinoio-package-/content/arduino.m&quot; rel=&quot;nofollow&quot; title=&quot;classdef for arduino&quot;&gt;classdef for the arduino object&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3973" LastActivityDate="2014-09-25T06:41:19.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4337" PostTypeId="1" CreationDate="2014-09-25T02:30:03.083" Score="1" ViewCount="9522" Body="&lt;p&gt;I'm using the arduino uno hooked up to two LEDs. One is in pin 3 and the other one in pin 5. I know that pin 3 is controlled by timer3 and pin 5 by timer 1. I've tried a lot of things to have two independent frequencies. I really don't care about the PWM, I have it to 50% (constant).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are resources to set the frequency (&lt;a href=&quot;http://playground.arduino.cc/Main/TimerPWMCheatsheet&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/TimerPWMCheatsheet&lt;/a&gt;), but these are predefined frequencies. I need to have one PWM at 650Hz and the other at 850Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any recommendations on how to approach this problem?&lt;/p&gt;&#xA;" OwnerUserId="4129" OwnerDisplayName="Tomasero" LastActivityDate="2020-08-23T19:31:19.857" Title="How can I set two PWM at two different frequencies?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4338" PostTypeId="2" ParentId="4337" CreationDate="2014-09-25T09:35:18.887" Score="0" Body="&lt;p&gt;There is a great library with functions to change PWM frequency on Arduino microcontrollers, called&#xA;&lt;a href=&quot;https://code.google.com/p/arduino-pwm-frequency-library/&quot; rel=&quot;nofollow&quot;&gt;arduino-pwm-frequency-library&lt;/a&gt;. I hope this helps you.&lt;/p&gt;&#xA;" OwnerUserId="4131" OwnerDisplayName="user3704293" LastActivityDate="2014-09-25T09:35:18.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4339" PostTypeId="1" AcceptedAnswerId="4362" CreationDate="2014-09-25T18:20:58.150" Score="5" ViewCount="2698" Body="&lt;p&gt;I am running out of code and data memory space on ATMega328P. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code size is big as I used several libraries, but, I only use a few functions of those library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, the default IDE is only doing a partial job in &lt;strong&gt;dead code removal&lt;/strong&gt; (remove unreferenced code and data). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some experiments shows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A normal program that uses several Arduino libraries is 22 kilo bytes in code size.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rename setup to o_setup. &#xA;Rename loop to o_loop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void setup(){};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void loop(){};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code size is 8 kilo bytes while the program is 'empty' effectively.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Start&lt;/strong&gt; a new program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void setup(){};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void loop(){};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code size is 0.5 kilo bytes  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Apparently, the IDE (linker called by IDE) is doing a 'partial' dead code removal job, as reducing code from 22kB to 8kB (case 1 and 2), &lt;strong&gt;instead of 0.5kB&lt;/strong&gt; (case 3). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I &lt;strong&gt;enable maximum dead code removal&lt;/strong&gt; function (reclaim code space occupied by unused library functions)?&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="1576" LastEditDate="2019-02-13T09:54:17.467" LastActivityDate="2019-02-13T09:54:17.467" Title="How to enable maximum Dead Code Removal?" Tags="|arduino-ide|code-optimization|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4340" PostTypeId="1" AcceptedAnswerId="4341" CreationDate="2014-09-25T19:53:42.290" Score="2" ViewCount="492" Body="&lt;p&gt;What can be used like Lego or other construction sets, but is more serious and 'professional'?  E.g. what comes with gears and screws and things like that, but is geared to serious modelling or more permanent projects?&lt;/p&gt;&#xA;" OwnerUserId="3959" LastActivityDate="2014-09-25T20:27:57.393" Title="Lego / Meccano style blocks for 'serious' projects" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4341" PostTypeId="2" ParentId="4340" CreationDate="2014-09-25T20:22:48.193" Score="2" Body="&lt;p&gt;Here is what comes to mind (by no means exhaustive):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;billed as &quot;the Industrial erector set&quot;, &lt;a href=&quot;http://www.8020.net/Default.asp&quot; rel=&quot;nofollow&quot;&gt;8020&lt;/a&gt; is legitimately used in industry for that kind of purpose, and if I remember correctly, pretty expensive. It is the most &quot;professional&quot; thing I can think of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.openbeamusa.com/&quot; rel=&quot;nofollow&quot;&gt;OpenBeam&lt;/a&gt; styles itself as the the cheaper, &quot;open sourced&quot; 8020. I've frequently heard of it being used in 3d printers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are not as serious or professional, but might be worth mentioning:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://mindsirobotics.com/&quot; rel=&quot;nofollow&quot;&gt;MINDSi&lt;/a&gt; is pretty close to the mindstorms, but tries to be more rigid/durable. It's aimed at robotics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.servocity.com/html/actobotics.html&quot; rel=&quot;nofollow&quot;&gt;Servo City's actobotics&lt;/a&gt; is an aluminum modular building system. It is also sold on sparkfun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not used these enough to give good comparisons, but I hope one of these will be what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-25T20:27:57.393" LastActivityDate="2014-09-25T20:27:57.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4342" PostTypeId="1" AcceptedAnswerId="4345" CreationDate="2014-09-25T20:45:37.100" Score="2" ViewCount="2328" Body="&lt;p&gt;My team has a C++ program from another microcontroller that we are moving to Arduino, which is currently divided into two main folders, the sketch and libraries. We want to be able to open some of the library files in the Arduino IDE along with the sketch, something it will do automatically if they are in the same folder, but not allow otherwise. The files in question are referenced from the other libraries though, which means moving just a few of them results in compilation errors. We don't want to move them all to the sketch folder, since that defeats the purpose, but a few of my teammates are vehemently opposed to having to edit them using another IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a way to have these files open in the Arduino IDE with the sketch? Or do I have to tell my teammates to suck it up and use a second editor if they want to make changes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, a way to get the libraries able to reference files in the sketch folder would also work.&lt;/p&gt;&#xA;" OwnerUserId="4130" LastEditorUserId="4130" LastEditDate="2014-09-26T15:22:37.787" LastActivityDate="2014-09-26T15:22:37.787" Title="Opening .h and .cpp files from folders other than the sketch folder" Tags="|arduino-ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4343" PostTypeId="2" ParentId="4337" CreationDate="2014-09-25T22:42:06.773" Score="4" Body="&lt;p&gt;The ATMega PWM hardware underlying the Arduino primarily supports changing the duty cycle; the frequencies can only be selected from a few fixed choices.  Typically the timers run from 0 to 255 or 65535 and loop back to 0, and you can select where within that full cycle the output changes on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since what you want is a simple 50% duty cycle with fine control of frequency, the PWM functions are not very useful.  What you want is tone or frequency control.  The ATMega timers support this too, but it's a different function than PWM. For frequency control, the timer will cycle from 0 to your choice of upper limit.  So for example, you might count up to 200 instead of 255; or to 201 - so you get much finer control of frequency.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike PWM, on the ATMega328p used in the Uno, you can only get one frequency per timer (you can get two PWM outputs per timer - both at the same frequency).  And if you want millis() and microseconds() and delay() to continue to work, you don't want to mess with timer 0 for frequency control (you can get PWM from timer 0 if you accept the default frequencies).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that leaves you with two frequency controllable timers - timer 1 (16 bit resolution) and timer 2 (8 bit resolution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the tone() function in the Arduino library for examples of a single tone at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For multiple simultaneous frequencies (on different pins) see this library: &lt;a href=&quot;https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation&lt;/a&gt;.  You can have two tones at a time, or three if you don't need millis() etc.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastEditorUserId="1186" LastEditDate="2014-09-25T22:51:07.540" LastActivityDate="2014-09-25T22:51:07.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4344" PostTypeId="2" ParentId="3629" CreationDate="2014-09-25T23:16:37.753" Score="4" Body="&lt;p&gt;I does sound like RS-485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get cheap RS-485 transceivers from the usual sources.  These take the 0..5v TX line and convert it to RS-485 voltages, or RS-485 voltages and convert to the 0..5v RX expected by your Arduino.  You would normally enable only one direction at a time - sending RS-485 from the Arduino TX or receiving RS-485 to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you just want to receive, so keep the transmit side (TX to RS-485) disabled, while enabling the receive side (RS-485 to RX).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS-485 is just an electrical standard, and they could be sending any pattern of on and off signals they want, but often they will be sending asynchronous data with one start bit, 7-8 data bits, and one stop bit per character - which the Arduino's Serial port can handle.  So it's worth testing to see if that works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next thing you need to know is the clock rate, or &quot;baud rate&quot;, which is how many bits per second (including start and stop bits) it is sending.  Often you can figure this out by trying some standard rates like 1200,2400,4800,9600,19200,38400,57600,115200 (there are others) and printing the results to your screen - when you are at the wrong rate you will get nothing, or some odd garbage.  When you get the right rate, it will look more reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If no speed works, you may need to reverse A and B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might temporarily hook up an LED and a resistor (say 2.2K or higher) between the RX from the RS-485 and your 5v power.  This will give you an idea of when there are transmissions from or to the thermostat.  If it only transmits once a minute, say, you might have to wait a while for each speed test.  Or changing the set temperature may trigger a send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to test the lower speeds at least using Software Serial, and then echo the received data to the hardware serial port which goes to the Serial Terminal in the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, you may need to figure out the protocol - the structure of the data.  Protocols vary widely.  It may be text or it may be binary; if it's binary you may want to have the arduino convert each character (values 0..255) into hexadecimal (00..FF) for printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most protocols for this kind of control send data in a burst, or packet.  You will likely be able to detect the start and end by the timing (ie: a long pause between the end and the start of the next).  Of course, some protocols might send several packets continuously, but still the first character (or binary value) after a long pause will often be the packet header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that there may be packets from the themostat, and packets to the thermostat, and you will see both without knowing which is which (so long as you are just passively tapping the line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this is enough of a pointer to get you started.  Decoding protocols is a more extended subject.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastEditorUserId="1186" LastEditDate="2014-09-25T23:22:28.300" LastActivityDate="2014-09-25T23:22:28.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4345" PostTypeId="2" ParentId="4342" CreationDate="2014-09-26T00:22:11.737" Score="1" Body="&lt;p&gt;I don't recommend this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) Because the arduino editor is pretty bad for serious coding&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) Because you will need to have a header guard on all library code that doesn't have one already (even in .cpp's)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if you really have to, the only way I can think of is to make a symbolic link to the library file in the sketch directory. It works, but the file gets compiled twice, so you need those header guards on everything. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-09-26T00:22:11.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4346" PostTypeId="1" CreationDate="2014-09-26T05:29:43.627" Score="0" ViewCount="1079" Body="&lt;p&gt;I have problem with WDT reset. After reset the device goes on for a boot loop. from the following link &lt;a href=&quot;https://code.google.com/p/arduino/issues/detail?id=181&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino/issues/detail?id=181&lt;/a&gt;&#xA;It has been mentioned that there is problem with Bootloader because some of them does not support wdt properly.How can i find which version of bootloader is running in my arduino mega 2560 . Which version of bootloader support wdt properly? where these bootloaders can be found?&lt;/p&gt;&#xA;" OwnerDisplayName="Subramanian Meenakshi Sundaram" LastActivityDate="2014-09-26T14:10:20.820" Title="Finding arduino bootloader version?" Tags="|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4347" PostTypeId="1" CreationDate="2014-09-26T09:34:20.680" Score="0" ViewCount="15914" Body="&lt;p&gt;I'm beginning to do kind of sophisticated things (well.. for my entry level skill) and I have to control a display with 3 LED and 4/5 types of events and status.&lt;/p&gt;&#xA;&lt;p&gt;I'm using the BlinkWithoutDelay example duplicating all the variables for different status/events but the code is really messy, full of puzzling nested &lt;code&gt;if&lt;/code&gt; statements.&lt;/p&gt;&#xA;&lt;p&gt;How to simplify the things? I don't know what to choose, because OOP could be a choice but I think it will hurt the low-memory thing inside the Arduino Uno/Leonardo. Interrupts could be another choice but I think they are like threads, and following the &lt;a href=&quot;http://en.wikipedia.org/wiki/KISS_principle&quot; rel=&quot;nofollow noreferrer&quot;&gt;KISS principle&lt;/a&gt; I'd like to stay away from them.&lt;/p&gt;&#xA;&lt;p&gt;So, can someone advice me some article/tutorial/code-to-read/whatever to understand how to use a lot of LEDs and keep a lot internal status without screw my brain?&lt;/p&gt;&#xA;&lt;h2&gt;EDIT:&lt;/h2&gt;&#xA;&lt;p&gt;It is a little bit hard to reproduce a simple skelton of my messy code, but it looks like this (in pseudocode maybe)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    if(state==0) handleState0();&#xA;    if(state==1) handleState1();&#xA;    if(state==2) handleState2();&#xA;    if(state==3) handleState3();&#xA;    readButtons();&#xA;    readSensors();&#xA;    …&#xA;}&#xA;&#xA;// this is a block of variables that I have to copy-and-paste &#xA;// every time I have to blink a led (hoping that there is &#xA;// nothing blocking that can skrew up everything)&#xA;unsigned long previousMillis_1 = 0;&#xA;const long interval_1 = 1000;&#xA;int ledState_1 = LOW;&#xA;&#xA;void handleState1() {&#xA;  // Green led blinking, yellow is fixed&#xA;  // this is a copy-and-paste code hard to maintain, &#xA;  // easily broken from any blocking call (like also I2C)&#xA;  // and hard to refactor or isolate&#xA;  unsigned long currentMillis_1 = millis();&#xA;  if(currentMillis_1 - previousMillis_1 &amp;gt;= interval_1) {&#xA;    previousMillis_1 = currentMillis_1;   &#xA;    if (ledState_1 == LOW) ledState_1 = HIGH;&#xA;    else ledState_1 = LOW;&#xA;    digitalWrite(pinGreen, ledState_1);&#xA;    digitalWrite(pinYellow, LOW);&#xA;}&#xA;&#xA;unsigned long previousMillis_2 = 0;&#xA;const long interval_2 = 1000;&#xA;int ledState_2 = LOW;&#xA;&#xA;void handleState2() {&#xA;  // Yellow led blinking, green is fixed&#xA;  // same as before&#xA;  unsigned long currentMillis_2 = millis();&#xA;  if(currentMillis_2 - previousMillis_2 &amp;gt;= interval_2) {&#xA;    previousMillis_2 = currentMillis_2;   &#xA;    if (ledState_2 == LOW) ledState_2 = HIGH;&#xA;    else ledState_2 = LOW;&#xA;    digitalWrite(pinYellow, ledState_2);&#xA;    digitalWrite(pinGreen, LOW);&#xA;}&#xA;&#xA;void handleButtonPressed() {&#xA;  // this skrew everything and because is blocking &#xA;  // and should be inserted in the main loop with &#xA;  // some global variables: active/disable, counter, &#xA;  // and non-blocking vars like previousMills, interval, etc etc&#xA;  Serial.println(&amp;quot;\ndisplayAccessDenied&amp;quot;);&#xA;  for(int i=0; i&amp;lt;3; i++) {&#xA;    digitalWrite(pinRed, LOW);&#xA;    delay(100);&#xA;    digitalWrite(pinRed, HIGH);&#xA;    delay(100);&#xA;  } digitalWrite(pinRed, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I feel a little bit lost but all the Arduino example arounds are super simple and to make a middle-level LED interface I have to screw my minds with something that is not working as 100% and other than Arduino I find only super-hard articles on microprocessors with low-level C code. But the pasted example is not working at 100% AND super hard to read, maintain, etc.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2024-02-18T00:00:38.187" Title="Guide to code for multitasking and non blocking timers" Tags="|programming|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4348" PostTypeId="2" ParentId="4346" CreationDate="2014-09-26T13:56:55.407" Score="1" Body="&lt;p&gt;In all practicality; put a known boot loader on it. Because if it is a problem version you will need to replace it anyways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Mega uses STK500 protocol. Which only shows a command to read its type (or signature) and not its version of firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a good exercise, but not really worth the time to go deeper into it, as programmers are cheap and or you can use another Arduino as the programmer. &lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-09-26T13:56:55.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4349" PostTypeId="2" ParentId="4346" CreationDate="2014-09-26T14:01:08.047" Score="1" Body="&lt;p&gt;The watchdog timer will reset the Arduino in case of a timeout. The way to prevent this from happening is to catch the WDT interrupt.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(WDT_vect)&#xA;{&#xA;  // do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has nothing to do with the bootloader. The fix suggested in the link above only makes the bootloader detect a reset triggered by a WDT event, and have it not add any delay. This delay is normally needed to see if the usb-host is trying to upload a new program.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-09-26T14:10:20.820" LastActivityDate="2014-09-26T14:10:20.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4350" PostTypeId="1" AcceptedAnswerId="4351" CreationDate="2014-09-26T15:35:06.667" Score="2" ViewCount="1911" Body="&lt;p&gt;Do I need to &lt;strong&gt;re-install many libraries&lt;/strong&gt; (or similar 'house keeping' works)? Is the upgrade straight forward?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, from Arduino web, one need 1.5 BETA series for use with Due. For Pro Mini, UNO and ATMega2560, should one use &lt;strong&gt;1.5 BETA or 1.0.6&lt;/strong&gt; (no beta, presumable stable)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running out of code space. Wonder if the upgrade will install a &lt;strong&gt;newer gcc&lt;/strong&gt; compiler and smaller code size? &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-09-26T19:55:05.397" Title="Now at IDE 1.0.5, should I upgrade to 1.0.6 or 1.5.7 Beta for Pro mini and ATMega2560 use?" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4351" PostTypeId="2" ParentId="4350" CreationDate="2014-09-26T16:50:21.170" Score="2" Body="&lt;p&gt;Old libraries will work with 1.5 Beta, but you will most likely need to copy any of your own libraries over to the new beta installation, depending on if they were installed to the sketchbook location or inserted into the installation before. That should be about all you need to do after installing the beta for it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Beta supports all the regular boards as well as the Due and Yun. I doubt you will see any change in binary size if you update. I've been using the beta for some time now and it has been quite stable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which version you should use is up to you, the differences are relatively minor. I think the beta adds a few convenient features, but there are no changes to the code or functionality like the switch to v1.0 made.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-09-26T19:55:05.397" LastActivityDate="2014-09-26T19:55:05.397" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4352" PostTypeId="2" ParentId="4350" CreationDate="2014-09-26T17:47:25.693" Score="3" Body="&lt;p&gt;I have had trouble with 1.5.7 (Beta), so I would stick with 1.0.6. As for code space, you might want to look into &lt;a href=&quot;http://www.atmel.com/tools/atmelstudio.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio (Free)&lt;/a&gt;, which uses a Visual Studio shell as the IDE. It blows the Arduino IDE out-of-water. Atmel is the maker of all the AT chips, so the Atmel Studio IDE is a great IDE for writing AVR code. Lots of tutorials online and there is a Arduino plug in called &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow&quot;&gt;Visual Micro (Free also)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2014-09-26T17:54:19.950" LastActivityDate="2014-09-26T17:54:19.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4353" PostTypeId="2" ParentId="3944" CreationDate="2014-09-26T17:57:23.057" Score="0" Body="&lt;p&gt;As Ignacio Vazquez-Abrams mentioned, you should look into &lt;a href=&quot;http://www.atmel.com/tools/atmelstudio.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt;. You can use a 3rd party AVR programmer (Arduino w/isp) or one from Atmel. The IDE is awesome and has a lot of features like setting fuse bits.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-09-26T17:57:23.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4354" PostTypeId="1" AcceptedAnswerId="4377" CreationDate="2014-09-26T18:29:36.480" Score="5" ViewCount="2002" Body="&lt;p&gt;If switch from &lt;strong&gt;Arduino IDE to Atmel studio or Visual Micro&lt;/strong&gt;, how to &lt;strong&gt;use existing Arduino library&lt;/strong&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Library serves important function of 'packaging' real and complex hardware (like NRF24L01 radio board) into functions of 'relatively standard format', like radio.init, radio.write, radio.read, radio.on, etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This allows user to easily use the hardware without reading the data sheet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can the same be achieved under Atmel studio?&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="19409" LastEditDate="2016-04-27T17:55:37.367" LastActivityDate="2016-04-27T17:55:37.367" Title="Can I switch from Arduino IDE to Atmel studio or Visual Micro but still use Arduino library?" Tags="|library|ide|visualstudio|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4356" PostTypeId="1" AcceptedAnswerId="4361" CreationDate="2014-09-26T22:37:30.170" Score="3" ViewCount="32021" Body="&lt;p&gt;I'm learning the arduino platform and working on a circuit that connects the two pins of a piezo buzzer -- one to ground and the other to a digital pin of the arduino board. In this configuration, is the arduino's digital pin acting as the positive terminal of the circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino docs seem to suggest it is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;They (the digital pins) can provide a substantial amount of current to other &gt;circuits. Atmega pins can source (provide positive current) or sink (provide &gt;negative current) up to 40 mA (milliamps) of current to other devices/circuits.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can the digital pins act as both positive and negative terminals in circuits? Does this question even make sense? What resources are out there that can help me better understand the underlying electronics of the arduino and microcontrollers in general?&lt;/p&gt;&#xA;" OwnerUserId="4148" OwnerDisplayName="Jog" LastEditorUserId="4539" LastEditDate="2014-10-26T14:13:42.930" LastActivityDate="2015-07-24T22:36:43.547" Title="Digital pins on Arduino function as both positive and negative terminals?" Tags="|pins|digital|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4357" PostTypeId="2" ParentId="4356" CreationDate="2014-09-26T22:45:46.257" Score="3" Body="&lt;p&gt;Step one: read the data sheet for the microcontroller.  In there is a nice diagram that shows you exactly how the IO pins work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins can work in 2 modes: input, and output.  You're interested in output mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The drive state of a CMOS output pin consists of two MOSFETs, one connecting the pin to Vcc and the other connecting it to GND.  Only one of the MOSFETs is ever turned on at a time, so the output pin is either connected to Vcc through one MOSFET, or connected to GND through the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it's connected to Vcc it's said to be &lt;em&gt;sourcing current&lt;/em&gt;, since it's at a positive potential compared to ground and current can flow &lt;em&gt;out&lt;/em&gt; of the pin to light an LED (say), and when it's connected to GND it's said to be &lt;em&gt;sinking current&lt;/em&gt; because current can flow &lt;em&gt;into&lt;/em&gt; the pin to get to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example of how it all works, consider how you would connect up and power a capacitative humidity sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These sensors require a square wave at around 1KHz to operate.  The humidity defines the impedance, and as part of an impedance divider (like a resistor divider) the output voltage is relative to the humidity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, they don't just want any square wave, but require a square wave that reverses polarity around a virtual ground point, and that means reversing the polarity of the power across the sensor at 1KHz.  How can you do that with an Arduino? The answer is simple:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the sensor to two IO pins rather than 1 IO pin and GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both pins are set as output, and one is set HIGH with the other set LOW.  So the voltage across it is 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you switch the outputs over, so the one that was HIGH is now LOW, and the one that was LOW is now HIGH.  The power across the sensor has been reversed!  It's now (effectively) -5V (compared to what it was before).&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastEditorUserId="4143" LastEditDate="2014-09-27T09:53:21.283" LastActivityDate="2014-09-27T09:53:21.283" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4358" PostTypeId="2" ParentId="4356" CreationDate="2014-09-26T22:52:00.973" Score="1" Body="&lt;p&gt;When a GPIO pin is set to output mode, you can either drive it &quot;high&quot; (ie: VCC), or &quot;low&quot; (GND). They can not, however, drive a negative voltage (ie: -VCC). If you want to create a negative voltage, you'd need some external GPIO expander chip sourced off some negative voltage supply, or you'd need to create a negative voltage rail source via a buck-boost converter or similar to generate it from Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately for you, Arduino already has a pieze-electric buzzer library, and wiring it up is dead simple. The relevant GPIO pin is connected to the buzzer's positive terminal, and the buzzers negative terminal is grounded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/W0cqs.png&quot; alt=&quot;Wiring of Arduino Uno to Pieze Electric Buzzer&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4152" OwnerDisplayName="Dogbert" LastActivityDate="2014-09-26T22:52:00.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4359" PostTypeId="2" ParentId="4356" CreationDate="2014-09-26T22:53:59.397" Score="2" Body="&lt;p&gt;Arduino's digital output pin can not output a voltage lower than GND.  In other words, the voltage on the digital output is always positive with respect to GND.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can it be a negative terminal?  It depends.  There is no universal definition for &quot;positive terminal&quot; and  &quot;negative terminal&quot;.  If you want to use these terms, you define what &quot;negative terminal&quot; is for each particular case.  Suppose, you want to sink the current through an LED (and a series resistor).  Then you connect the resistor to the VCC and Anode (negative terminal of the LED) to the digital output.  Then you could say that digital output is the negative terminal for the LED.&lt;/p&gt;&#xA;" OwnerDisplayName="Nick Alexeev" LastActivityDate="2014-09-26T22:53:59.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4360" PostTypeId="2" ParentId="3055" CreationDate="2014-09-26T23:09:00.100" Score="1" Body="&lt;p&gt;The Linux side of the Yun is just an OpenWRT installation. It has hardly been modified at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To cross-compile you will first need a Linux computer, or a Linux virtual machine.  Then you need to download the OpenWRT source code and configure it for the Yun (I think it defaults to the right settings).  Then you can build the whole OpenWRT image.  One side-effect of that is it compiles and configures a full cross-compiling environment for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use that cross-compiling environment to compile your own code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-09-26T23:09:00.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4361" PostTypeId="2" ParentId="4356" CreationDate="2014-09-26T23:33:54.637" Score="3" Body="&lt;p&gt;The answer to your question is basically yes, you can use ATmega I/O pins as +/- power supply terminals for other circuits. But there's a limit to what you can power that way (20mA per pin and 100mA total per ATmega). In practice this means you can only power the simplest circuits (single LEDs per pin, and not many LEDs in total, for example). As a general rule, you should really look for other ways to power anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there's a problem with the citation you gave. That 40mA figure is the absolute maximum current per pin, but that should be avoided. Safest is to use about 20mA of maximum current per pin. Also, the ATmega pins should not have more than 200mA flowing through Vcc and GND (also an absolute maximum that should also be avoided).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, you should either power other stuff off of the regulated +5V that also feeds the ATmega (up to the regulator capacity that depends on the Arduino board - 500mA for the Arduino Uno - 1A for LM7805 regulators - and so on). You could also use the unregulated power in some cases. Then you should use digital pins on the ATmega to switch transistors on and off which in turn will switch your load. Sometimes you can use transistors to switch relays, that in turn will switch even larger loads.   &lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-09-26T23:33:54.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4362" PostTypeId="2" ParentId="4339" CreationDate="2014-09-27T03:36:18.007" Score="6" Body="&lt;p&gt;Enable your IDE's verbose of the compile via the preferences. From there you can see exactly what and how it is being compiled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short the IDE (and toolchain) will compile everything and anything it can find into an object. Where only the used code is compiled in the linking phase, as garbage collection is enabled with the &quot;--gc-sections&quot; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the optimization level is &quot;-Os&quot; or &quot;Optimize for size&quot;. In IDE 1.0.+ this appears to be hardcoded. Where as in IDE 1.5.+ the compiler options are configurable, in &quot;\arduino-1.5.6-r2\hardware\arduino\avr\platform.txt&quot; can be customized to meet your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you can use the avr-objdump command as described in &lt;a href=&quot;https://stackoverflow.com/questions/15291750/does-importing-libraries-load-everything-in-arduino/15296808#15296808&quot;&gt;https://stackoverflow.com/questions/15291750/does-importing-libraries-load-everything-in-arduino/15296808#15296808&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend 1.5.6r2 and not 1.5.7 as the gcc commands won't run individually without some path manipulation.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="30414" LastEditDate="2019-02-12T15:06:01.530" LastActivityDate="2019-02-12T15:06:01.530" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4363" PostTypeId="2" ParentId="3055" CreationDate="2014-09-27T08:45:01.760" Score="1" Body="&lt;p&gt;Even if &lt;a href=&quot;https://github.com/arduino/openwrt-packages-yun/pull/7&quot; rel=&quot;nofollow&quot;&gt;compiling C++ on the openwrt of the yun is possible&lt;/a&gt; with the &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=268347.0&quot; rel=&quot;nofollow&quot;&gt;last release of the yun-openwrt&lt;/a&gt; you should make a &lt;strong&gt;yun build-chain&lt;/strong&gt;. That makes you compile on you computer for the processor architecture of the embedded machine on the yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never done but you can find some informations about it in those links:&#xA;- &lt;a href=&quot;https://github.com/arduino/openwrt-yun&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/openwrt-yun&lt;/a&gt;&#xA;- &lt;a href=&quot;http://fibasile.github.io/arduino-yun-custom-buildroot.html&quot; rel=&quot;nofollow&quot;&gt;http://fibasile.github.io/arduino-yun-custom-buildroot.html&lt;/a&gt;&#xA;- &lt;a href=&quot;http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html&quot; rel=&quot;nofollow&quot;&gt;http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html&lt;/a&gt;&#xA;- &lt;a href=&quot;https://github.com/arduino/openwrt-yun/issues/20&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/openwrt-yun/issues/20&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other question.. for sure you can read/write serial directly from the openwrt. You need to disable the Bridge library (there are a lot of post around the internet. one is &lt;a href=&quot;http://cylonjs.com/documentation/platforms/yun/&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; see the &lt;code&gt;Disabling the Bridge Script&lt;/code&gt; chapter) and manually handle the serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps!&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-09-27T08:45:01.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4364" PostTypeId="1" AcceptedAnswerId="4367" CreationDate="2014-09-27T13:03:35.180" Score="7" ViewCount="9141" Body="&lt;p&gt;The program becomes harder to read (at least on my particular monitor) after upgrading. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to change font &lt;strong&gt;Color to darker&lt;/strong&gt; color and/or &lt;strong&gt;Type to thicker stroke&lt;/strong&gt; (like B in this question editor) for IDE 1.5.6r2?&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2018-05-30T18:51:14.443" Title="Can I change font Color and/or Type for IDE 1.5.6r2?" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4365" PostTypeId="2" ParentId="4354" CreationDate="2014-09-27T13:14:12.490" Score="3" Body="&lt;p&gt;At the end of the day, an Arduino library and the Arduino core are just files full of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing to stop you creating a project in Atmel studio (or wherever) and importing all those files into your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need all the core files (hardware/arduino/core/arduino/*) plus all the files for the libraries you want to use.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-09-27T13:14:12.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4366" PostTypeId="2" ParentId="4356" CreationDate="2014-09-27T13:49:21.810" Score="1" Body="&lt;p&gt;To summarize other people's answers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos have a whole bunch of GPIO, or general purpose I/O, pins. They can be configured as digital inputs or digital outputs. Certain pins can also be configured as analog inputs or PWM outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a simple digital pin, if it is an input, it has nearly infinite impedance. (It looks like an open connection.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's an output, it acts like a current source (connected to +5V) if it's HIGH, and acts like a current sink (connected to ground) if it's LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino I/O pins (on most boards, check your board's specs) have a hard limit of 40mA of current flowing through them, but you should generally keep the current below 20 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is a ground connection the same as a negative connection? Sort of. Some circuits include ground, one or more positive voltage sources, and one or more negative voltage sources. Audio (analog) circuits, for example, often need ground, +12, and -12 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos don't deal with negative voltages, and applying a voltage that's less than ground to any pin will likely destroy it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think in terms of positive voltage and ground, not positive and negative. It's less ambiguous. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't think of Arduino pins as being power sources. Remember that they are LOGIC pins, and only put our very small amounts of current. Trying to source or sink too much current from an Arduino pin may destroy it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to source or sink more than 20mA, use a transistor as a switch to handle the higher current load. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to all that, you need to watch the total current that you pass through all your logic pins, and also the total current you draw from the power supply. Check the specs on your board and make sure you stay within the limits.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastEditorUserId="2967" LastEditDate="2014-09-27T14:30:06.603" LastActivityDate="2014-09-27T14:30:06.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4367" PostTypeId="2" ParentId="4364" CreationDate="2014-09-27T14:35:32.550" Score="6" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under the file menu select the preferences. From this you can find and than view/edit the preferences.txt file, which has the color settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/lib/preferences.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;preferences.txt&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="337" LastEditDate="2018-05-30T18:51:14.443" LastActivityDate="2018-05-30T18:51:14.443" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="4368" PostTypeId="1" AcceptedAnswerId="4384" CreationDate="2014-09-27T15:38:59.647" Score="1" ViewCount="3901" Body="&lt;p&gt;After installing IDE 1.5.6r2, there are two .exe files, &lt;strong&gt;arduino_debug&lt;/strong&gt;.exe and &lt;strong&gt;arduino&lt;/strong&gt;.exe (which is same name as previously installed IDE 1.0.5). &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2014-09-29T07:22:43.120" Title="What is arduino_debug.exe for IDE 1.5.6r2?" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4370" PostTypeId="1" AcceptedAnswerId="4373" CreationDate="2014-09-28T07:05:27.413" Score="0" ViewCount="4230" Body="&lt;p&gt;My Ethernet server keeps crashing after pulling the RGB values from the string. It remains connected if I'm just toggling a pin, but whenever the string has the rgb values in it, the RGB values are pulled, the LED changes but then the server crashes and won't take any more requests. Do I need to restart the server after it plucks the RGB values for another read? If so, how would I go about doing this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, James :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example HTTP request that causes the crash: /?LED=B233+G011+R133&amp;amp;t=T HTTP/1.1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;Ethernet.h&amp;gt;&#xA;    #include &amp;lt;string.h&amp;gt;&#xA;&#xA;    byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; &#xA;    byte ip[] = {192, 168, 0, 102 }; &#xA;    byte gateway[] = {192, 168, 0, 1 }; &#xA;    byte subnet[] = {255, 255, 255, 0 }; &#xA;    EthernetServer server(84);&#xA;    ; &#xA;&#xA;    char* redstring={0};&#xA;    String blue1;&#xA;    String green1;&#xA;    String red1;&#xA;    String testString = &quot;0123456789&quot;;&#xA;&#xA;&#xA;    int blue;&#xA;    int green;&#xA;    int red;&#xA;    int been=0;&#xA;    int b=0;&#xA;    int g=0;&#xA;    int r=0;&#xA;    //////////////////////&#xA;&#xA;    void setup(){&#xA;&#xA;    pinMode(11, OUTPUT);&#xA;    pinMode(9, OUTPUT);&#xA;    pinMode(7, OUTPUT);&#xA;    pinMode(6, OUTPUT);&#xA;&#xA;    //start Ethernet&#xA;    Ethernet.begin(mac, ip, gateway, subnet);&#xA;    server.begin();&#xA;&#xA;    //enable serial data print &#xA;    Serial.begin(9600); &#xA;    Serial.println(&quot;SERVER RUNNING HTTP / GET&quot;); &#xA;    }&#xA;&#xA;    void loop(){&#xA;     ////////////////////////////////////////&#xA;     EthernetClient client = server.available();&#xA;if (client) {&#xA;while (client.connected()) {&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;&#xA;    //read char by char HTTP request&#xA;    if (sizeof(redstring) &amp;lt; 100) {&#xA;&#xA;      //store characters to string &#xA;      redstring += c; &#xA;      //Serial.print(c);&#xA;    } &#xA;&#xA;    //if HTTP request has ended&#xA;    if (c == '\n') {&#xA;&#xA;      ///////////////////////////////////////////&#xA;&#xA;      Serial.println(redstring);&#xA;&#xA;&#xA;&#xA;      client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;      client.println(&quot;Content-Type: text/html&quot;);&#xA;      client.println();&#xA;      client.println(&quot;&amp;lt;HTML&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;link rel=\&quot;shortcut icon\&quot; href=\&quot;data:image/x-icon;,\&quot; type=\&quot;image/x-icon\&quot;&amp;gt;&quot;); &#xA;      client.println(&quot;&amp;lt;HEAD&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;TITLE&amp;gt;Arduino GET&amp;lt;/TITLE&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;/HEAD&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;BODY&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;H1&amp;gt;HTML GET&amp;lt;/H1&amp;gt;&quot;);&#xA;      //change ip back if not local&#xA;      client.println(&quot;&amp;lt;FORM ACTION=\&quot;http://192.168.0.102:84\&quot; method=get &amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;JQUERY: &amp;lt;INPUT TYPE=TEXT NAME=\&quot;LED\&quot; VALUE=\&quot;\&quot; SIZE=\&quot;25\&quot; MAXLENGTH=\&quot;50\&quot;&amp;gt;&amp;lt;BR&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;INPUT TYPE=SUBMIT NAME=\&quot;t\&quot; VALUE=\&quot;T\&quot;&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;/FORM&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;BR&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;/BODY&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;/HTML&amp;gt;&quot;);&#xA;&#xA;      delay(1);&#xA;      //stopping client&#xA;      client.stop();&#xA;      /////////////////////&#xA;      //readString = Character.toUpperCase(readString); &#xA;      for (int i = 1; i &amp;lt; sizeof(redstring); i++) {&#xA;        if (strchr(redstring, 'B') &amp;amp;&amp;amp; &amp;amp;&amp;amp; redstring[i+1] &amp;gt; -1) {&#xA;          blue=redstring[i+1, i+4];&#xA;          analogWrite(11, blue); &#xA;          delay(1000);&#xA;                      }&#xA;&#xA;        if (strchr(redstring, 'G') &amp;amp;&amp;amp; redstring[i+1] &amp;gt; -1) {&#xA;          green=redstring[i+1, i+4];&#xA;          analogWrite(9, green); &#xA;          delay(1000);&#xA;                      }&#xA;&#xA;&#xA;        if (strchr(redstring, 'R')&amp;amp;&amp;amp; redstring[i+1] &amp;gt; -1) {&#xA;          red=redstring[i+1, i+4];&#xA;          analogWrite(7, red); &#xA;          delay(1000);&#xA;                      }&#xA;&#xA;&#xA;&#xA;      }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;      //clearing string for next read&#xA;           redstring=&quot;&quot;;&#xA;          (redstring, &quot;0&quot;, sizeof(redstring));&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4155" LastEditorUserId="4155" LastEditDate="2014-09-28T16:49:50.870" LastActivityDate="2014-09-29T08:28:30.747" Title="Arduino Ethernet Client crashes after obtaining values from string" Tags="|arduino-mega|ethernet|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4372" PostTypeId="2" ParentId="4356" CreationDate="2014-09-28T14:52:26.573" Score="0" Body="&lt;p&gt;First of all, the Arduino doesn't supply negative voltage. It flows from positive to &lt;em&gt;ground&lt;/em&gt;, the reference point that determines voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I'm not quite sure of the exact details of the inner-workings of the ATmega chip, but I assume it goes something like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A CPU cycle modifies a CPU register (or similar memory/latch somewhere)&lt;/li&gt;&#xA;&lt;li&gt;To the output of that &quot;register,&quot; a circuit is connected that:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Shorts the pin to 5V if HIGH&lt;/li&gt;&#xA;&lt;li&gt;Shorts the pin to GND if LOW&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I suppose the latch could be directly connected to the pin, but I think that the current draw might be too high for the latch circuit, so an external transistor is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That above isn't anything that's really technically correct (as these details aren't always released), but its intended purpose is to show you how it basically works from a logic point of view.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then manipulate the pin's connection using either of these two pieces of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//HIGH (== 5V)&#xA;pinMode(5, OUTPUT);&#xA;digitalWrite(5, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//LOW (== GND; 0V)&#xA;pinMode(4, OUTPUT);&#xA;digitalWrite(4, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-09-28T14:52:26.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4373" PostTypeId="2" ParentId="4370" CreationDate="2014-09-28T17:41:45.567" Score="3" Body="&lt;p&gt;Using &lt;code&gt;String&lt;/code&gt;, which uses dynamic allocation/deallocation on the heap is not advised in embedded platforms, as this can quickly lead to heap fragmentation, eventually leading to memory exhaustion, heap/stack collision...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First off, you should try to replace all &lt;code&gt;String&lt;/code&gt; usage, everywhere in your program, with C-tyle strings, i.e. &lt;code&gt;char*&lt;/code&gt; or &lt;code&gt;char xxx[...]&lt;/code&gt; along with dedicated C functions to deal with them: &lt;code&gt;strchr&lt;/code&gt;, &lt;code&gt;strstr&lt;/code&gt;, &lt;code&gt;strcpy&lt;/code&gt;, &lt;code&gt;strcat&lt;/code&gt;, &lt;code&gt;strtok&lt;/code&gt;, &lt;code&gt;atoi&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you can avoid using global variables and use the stack for many of them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    ...&#xA;    if (client) {&#xA;        char readString[101];&#xA;        const int READ_STRING_SIZE = sizeof(readString) - 1;&#xA;        int readIndex = 0;&#xA;        while (client.connected()) {&#xA;            if (client.available()) {&#xA;                char c = client.read();&#xA;                if (readIndex &amp;lt; READ_STRING_SIZE) {&#xA;                    readString[readIndex++] = c;&#xA;                }&#xA;&#xA;                if (c == '\n') {&#xA;                    // Terminate the read string&#xA;                    readString[readIndex] = 0;&#xA;                    Serial.println(readString);&#xA;&#xA;                    // Prepare for next reeading&#xA;                    readIndex = 0;&#xA;&#xA;                    client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;                    ...&#xA;                    client.stop();&#xA;&#xA;                    // convert readString to all uppercase&#xA;                    for (i = 0; i &amp;lt; strlen(readString); i++)&#xA;                        readString[i] = toupper(readString[i]);&#xA;&#xA;                    bool b = false;&#xA;                    bool r = false;&#xA;                    bool g = false;&#xA;                    int blue, red, green;&#xA;&#xA;                    // Look for 'B' value&#xA;                    char* bb = strchr(readString, 'B');&#xA;                    if (bb != 0 &amp;amp;&amp;amp; isdigit(bb[1]) {&#xA;                        blue = atoi(&amp;amp;bb[1]);&#xA;                        analogWrite(11, blue);&#xA;                        delay(500);&#xA;                        b = true;&#xA;                    }&#xA;                    // Same for 'G' and 'R' value&#xA;                    ...&#xA;                    if (b &amp;amp;&amp;amp; r &amp;amp;&amp;amp; g) {&#xA;                        Serial.print(&quot;CHANGING RED TO: &quot;);&#xA;                        Serial.println(red);&#xA;                        Serial.print(&quot;CHANGING GREEN TO: &quot;);&#xA;                        Serial.println(green);&#xA;                        Serial.print(&quot;CHANGING BLUE TO: &quot;);&#xA;                        Serial.println(blue);&#xA;                    }&#xA;                }&#xA;&#xA;                if (strstr(readString, &quot;PIN6&quot;) != 0) {&#xA;                    digitalWrite(6, !digitalRead(6));&#xA;                    ...&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this sample code, we have completely removed dynamic memory allocation.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-09-29T08:28:30.747" LastActivityDate="2014-09-29T08:28:30.747" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4374" PostTypeId="1" AcceptedAnswerId="4375" CreationDate="2014-09-28T21:09:24.170" Score="1" ViewCount="2545" Body="&lt;p&gt;I am trying to read from a quadrature rotary encoder using an Arduino UNO R3. This is done by connecting the encoder's channel A pin to the Arduino interrupt 0 pin (digital IO pin 2). Inside the interrupt routine I then read the value of channel B (connected to digital IO pin 8) to determine the direction of rotation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to read the correct value of channel B using the digitalRead() function, but when I use bitRead() it always gives me a 0. As far as I know digital IO pin 8 is mapped to PORTB bit 0, so I am using bitRead(PORTB, 0) to read the bit. I also tried to read all of the other pins, but all of them show 0, except the LED at pin 13, which shows 0s and 1s when it gets toggled (It is also the only pin defined to be an OUTPUT pin, whereas the encoder uses INPUT pins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int channelA = 0;&#xA;int channelB = 8;&#xA;volatile int rotateNumber = 0;&#xA;volatile boolean interrupted = false;&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(115200);&#xA;&#xA;    attachInterrupt(channelA, rotate, RISING);&#xA;    pinMode(channelB, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;   if(interrupted){&#xA;       Serial.println(rotateNumber)&#xA;       interrupted = false;&#xA;   }&#xA;}&#xA;&#xA;void rotate(){&#xA;  if(bitRead(PORTB, 0) == 1)&#xA;     rotateNumber++; &#xA;  else&#xA;     rotateNumber--; &#xA;&#xA;  interrupted = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4167" OwnerDisplayName="barefootcoder" LastEditorUserId="10794" LastEditDate="2015-09-12T00:53:17.383" LastActivityDate="2015-09-12T00:53:17.383" Title="bitRead() gives wrong answer Arduino UNO R3" Tags="|arduino-uno|c++|interrupt|rotary-encoder|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4375" PostTypeId="2" ParentId="4374" CreationDate="2014-09-28T21:18:53.850" Score="4" Body="&lt;p&gt;&lt;code&gt;PORTx&lt;/code&gt; is the latched value last written there. The external value is found in &lt;code&gt;PINx&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-09-28T21:18:53.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4376" PostTypeId="1" AcceptedAnswerId="4389" CreationDate="2014-09-28T21:54:06.227" Score="5" ViewCount="32452" Body="&lt;p&gt;I'm new to Arduino and I have two devices that I'm trying to control:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A RGB LED light strip that can change colors&lt;/li&gt;&#xA;&lt;li&gt;A light sensor that can detect the ambient light level&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is have the LED strip continuously cycle through a rainbow of colors, and the light sensor will adjust the brightness of the LED strip based on the ambient light level. Here are the two pieces of code by themselves, which I've tested in isolation and confirmed that they work properly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED strip:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;j = (j + 1) % 256; // current iteration of the light cycle&#xA;&#xA;// set the strip color&#xA;for(int i=0; i&amp;lt; strip.numPixels(); i++) {&#xA;  strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) &amp;amp; 255));&#xA;}&#xA;&#xA;// display the new colors and wait 20ms before the next cycle&#xA;strip.show();&#xA;delay(20);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Light sensor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sensors_event_t event;&#xA;tsl.getEvent(&amp;amp;event); // get a light measurement&#xA;strip.setBrightness(event.light); // set the brightness of the LED strip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the light sensor takes anywhere from 100ms to 600ms to get a reading, and &lt;code&gt;tsl.getEvent(&amp;amp;event)&lt;/code&gt; is a blocking call, so the end result is that the LED strip updates way too slowly. I would need to run the two side by side so that the light sensor read does not block the LED strip update. Any idea how I can accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="4168" LastActivityDate="2015-01-01T07:34:27.183" Title="How can I run two loops simultaneously on an Arduino Uno?" Tags="|arduino-uno|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4377" PostTypeId="2" ParentId="4354" CreationDate="2014-09-28T23:19:11.450" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://www.visualmicro.com&quot; rel=&quot;nofollow&quot;&gt;Visual Micro&lt;/a&gt; supports all Arduino libraries in the same way that the Arduino IDE supports these libraries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using Visual Micro in Atmel Studio your sketch code remains identical to the Arduino IDE. You can switch between the two IDEs and see the same compiler results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can not see your user libraries on the &quot;Atmel Studio&gt;Projects&gt;Add/Import Sketch Library&quot; menu then this means you have configured the SketchBook folder path incorrectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino and Visual Micro use the SketchBook folder to find user libraries in a sub folder called 'Libraries'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend leaving the sketchbook folder empty because Visual Micro will then auto discover the SketchBook folder that the Arduino IDE uses and remove the possibility of confusion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the sketchbook folder is empty and has not been set in the Arduino IDE the default will be myDocuments\Arduino, therefore your user libraries will be expected to exist in myDocuments\Arduino\Libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@John, in response to your question below. It's a big topic and maybe best answered in our forum. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few examples are: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Ability to re-define arduino core to use tools such as cygwin, we see&#xA;the Arducopter example as a good one for this. They produce a window&#xA;SITL program. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Obviously we can all use the flexible Arduino 1.5 config structure to&#xA;define our own hardware and build process but we also support the&#xA;Teensy customization system which allows windows apps/tools to manage&#xA;the build process and tool chains. Visual Micro supports both of&#xA;these customizations combined in the same hardware def but also a&#xA;number of other build properties. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is also the ability, in Visual Micro, to add compiler #defines&#xA;for project or configuration and the ability to add programmers that&#xA;use, for example, the atmel toolchain (if using atmel studio). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Libraries can be referenced with a folder name (unlike arduino) which&#xA;allows different projects to use similar libraries but of different&#xA;versions. (Library paths are declared for the lib folder roots as&#xA;well as individual libraries). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you consider the various different build properties build&#xA;properties of Arduino, Teensy, Energia, ChipKIT and Intel then add a&#xA;few on top this describes what you can do in any project regardless&#xA;of hardware IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2014-09-29T18:44:36.057" LastActivityDate="2014-09-29T18:44:36.057" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4378" PostTypeId="2" ParentId="4376" CreationDate="2014-09-28T23:30:44.723" Score="1" Body="&lt;p&gt;Setup a 'state server' in your loop(). Put simply this means keeping track of the next command for each task, then doing one thing in each task per loop().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one task needs to run at a faster speed than another task you can use a timer in your loop to decide what to do next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a task needs a pause then save the &quot;Last Run&quot; millis() to a global variable and ignore the task until the correct amount of time has passed. Do not use a delay(), always let the loop() run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is that the loop() runs as often as possible but you do one thing each time it runs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes a while to get the hang of this way of working but it leaves the Arduino processor free to process all jobs evenly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int task1Status=0;&#xA;int task2Status=0;&#xA;&#xA;void loop()&#xA;{&#xA;  doOneThingOfTask1();&#xA;  doOneThingOfTask2();&#xA;}&#xA;&#xA;//10 things to light the leds, but only do one&#xA;void doOneThingOfTask1()&#xA;{&#xA;  if (task1Status==10)&#xA;    task1Status=0;&#xA;&#xA;  switch (task1Status)&#xA;  {&#xA;    case 0:&#xA;       //start doing a new process&#xA;&#xA;    case 1:&#xA;       //do something&#xA;&#xA;    case 9:&#xA;       //do the last thing&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2014-09-28T23:30:44.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4379" PostTypeId="2" ParentId="4376" CreationDate="2014-09-28T23:42:32.633" Score="3" Body="&lt;p&gt;The arduino is not a multithreaded or multi-tasking device. You have to write your different functions to &quot;play nice&quot; with each other. Blocking code is death for this sort of multitasking. You might need to rewrite your code that reads the light sensor to be non-blocking. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can get that code to be non blocking then Visual Micro's post is the way to go.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-09-28T23:42:32.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4380" PostTypeId="1" AcceptedAnswerId="4381" CreationDate="2014-09-29T02:49:44.190" Score="5" ViewCount="6669" Body="&lt;p&gt;I have a project that uses timers and interrupts frequently. A lot of CPU time is spent handling ISRs over an extended period of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this affect code inside the main loop that relies on the millis() function since a significant amount of time is spent processing the ISRs?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2021-01-05T22:17:54.857" Title="Is `millis()` affected by long ISRs?" Tags="|interrupt|millis|isr|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4381" PostTypeId="2" ParentId="4380" CreationDate="2014-09-29T02:49:44.190" Score="8" Body="&lt;p&gt;After some digging around in the core, it seems like Arduino updates &lt;code&gt;millis()&lt;/code&gt; with a 8 bit timer: it uses overflow with a prescaler value of 64. In simpler terms, it has it set up so a certain piece of code (the ISR) is run approximately once per millisecond on a 16MHz system (and proportionately less frequently on slower clocked systems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When that ISR is ran, it increments a variable that is used by the &lt;code&gt;millis()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, even if some non-interruptable code is being ran for a fraction of a millisecond, it won't matter since the bit for that interrupt vector will still remain set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is a problem when the ISR is ran less often than it should be triggered. This may be a result of using &lt;code&gt;noInterrupts()&lt;/code&gt; for an extended period of time or when too many other interrupts are being ran and there is not enough CPU for all of the tasks. If a lot of the other ISRs have a higher &lt;em&gt;interrupt priorities&lt;/em&gt;, it is possible that the code for the &lt;code&gt;millis()&lt;/code&gt; may never be ran. In this case, you would have more serious issues than this, but it is something to keep in mind when you're writing code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general rule of thumb of ISRs still apply: &lt;strong&gt;keep it short!!!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if you require extreme accuracy, the built in function isn't the best choice. A RTC is a good idea for long term time keeping.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="353" LastEditDate="2014-09-29T11:54:14.317" LastActivityDate="2014-09-29T11:54:14.317" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4382" PostTypeId="1" CreationDate="2014-09-26T11:37:16.893" Score="0" ViewCount="100" Body="&lt;p&gt;If you have a prototype with arduino and you wish to create a real product can you do it or the fact that it contains the arduino bootloader prevents you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, i dont have a product ready. I am thinking options though. Or maybe i will have to go find a job&lt;/p&gt;&#xA;" OwnerUserId="1499" OwnerDisplayName="user1584421" LastActivityDate="2014-09-29T06:16:30.710" Title="Creating a product with arduino bootloader" Tags="|bootloader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4383" PostTypeId="2" ParentId="4382" CreationDate="2014-09-26T11:56:42.027" Score="2" Body="&lt;p&gt;A quick google search found &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=104149.0&quot; rel=&quot;nofollow&quot;&gt;this info on the Arduino Forum&lt;/a&gt; which a user kindly shows the rules relating to this stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Optiboot bootloader is not actually an Arduino 'product'. Boards you design and software you write using Arduino IDE and libraries does not need to be disclosed to anybody, other than having the objects available (probably in a hidden part of your product's support website, in a &quot;firmware&quot; sub section) for some reason relating to being able to build the source against newer versions of Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently making a product which I intend to use Arduino libraries and IDE and bootloader for fast development, but the board, schematics, and essentially the application code except for the libraries from Arduino will be mine. If you copy or build stuff specifically for/from Arduino hardware, you must(?) release certain source/schematics etc.&lt;/p&gt;&#xA;" OwnerUserId="4179" OwnerDisplayName="KyranF" LastActivityDate="2014-09-26T11:56:42.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4384" PostTypeId="2" ParentId="4368" CreationDate="2014-09-29T07:22:43.120" Score="1" Body="&lt;p&gt;Windows binaries can either be Window or Console applications. A Window application can NOT produce text output. Text output is the easiest way to gather error messages related to bugs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, &lt;code&gt;arduino_debug.exe&lt;/code&gt; should be used by Windows users that have found a bug in the Arduino IDE and wish to contribute submitting an &lt;a href=&quot;https://github.com/arduino/Arduino/issues&quot; rel=&quot;nofollow&quot;&gt;issue on github&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-09-29T07:22:43.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4386" PostTypeId="1" CreationDate="2014-09-29T10:39:58.130" Score="0" ViewCount="152" Body="&lt;p&gt;So I bought the Arduino starter kit a few weeks ago and I've done a few of the projects in the book supplied with the set. Unfortunately the book is quite poor, with inaccurate explanations and sometimes no explanation behind what they want you to do in the projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to know what people would reccomend? I found 2 well reviewed books; Arduino for Dummies and Arduino Workshop, but I'm torn which to take. So I'm asking in here in hope that I can save time and money on buying and reading a good book from the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a programmer by profession and also know a bit of physics, but have little experience with electronics.&lt;/p&gt;&#xA;" OwnerUserId="4175" LastEditorUserId="4175" LastEditDate="2014-09-30T04:30:22.640" LastActivityDate="2014-09-30T04:30:22.640" Title="A good place to begin with Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="8" ClosedDate="2014-09-30T05:48:49.143" ContentLicense="CC BY-SA 3.0" />
  <row Id="4389" PostTypeId="2" ParentId="4376" CreationDate="2014-09-29T13:02:06.807" Score="6" Body="&lt;p&gt;You can make the sensor return data faster by lowering it's accuracy.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also modify the library to not power-down the sensor after each reading. Just open &lt;code&gt;TSL2561.cpp&lt;/code&gt;, find the &lt;code&gt;getFullLuminosity&lt;/code&gt; function, and comment out the line reading &lt;code&gt;disable();&lt;/code&gt; and the 12 lines reading &lt;code&gt;switch (_integration){ ... }&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution is, to have the pixels update every 20ms using a &lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;noreferrer&quot;&gt;timer&lt;/a&gt;. You can have the timer, interrupt the main loop every 20ms and update the pixel values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I can't really help you with timers, as I myself set the registers for my timers, and ISRs directly, which isn't for beginners. But there are probably libraries for it, to make it more user friendly.)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-09-29T18:48:34.823" LastActivityDate="2014-09-29T18:48:34.823" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4390" PostTypeId="2" ParentId="4380" CreationDate="2014-09-29T13:39:57.927" Score="1" Body="&lt;p&gt;ABSOLUTELY&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any ISR that is long will prevent millis() from incrementing. It can be dubiously slow skew of this clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ISR function always start off with blocking interrupts with the cli() command at start and finish by enabling them with the sei() command. Blocking other ISR's along with Timer0's OverFlow interrupt which is used for increamenting the millis counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any extended use of noInterrupts() or cli() or implied use with ISR's should be carefully short in duration. There is no general harm in executing either of interrupts() or sei() with in the ISR, as to allow interrupts again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the VS1053 library I have Data Request on an INT pin. Which's ISR may read from the SdCard, which can take a very long time. So I re-enable the interrupts() before reading the SdCard, but still in the ISR. &lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-09-29T13:39:57.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4391" PostTypeId="2" ParentId="4376" CreationDate="2014-09-29T17:10:01.947" Score="1" Body="&lt;p&gt;Your first, biggest problem is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the light sensor takes anywhere from 100ms to 600ms to get a reading, and tsl.getEvent(&amp;amp;event) is a blocking call,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need non-blocking access to the light sensor. Look at the library code to see what it is doing when it blocks. Chances are it waits for the sensor to set a 'done' bit. If so, you'll need to modify the library, either by&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;adding a boolean &lt;code&gt;.isDone()&lt;/code&gt; function that tests the done bit, and don't let your main program call for a reading until isDone() == TRUE; or&lt;/li&gt;&#xA;&lt;li&gt;making .getEvent() a non-blocking such that it immediately returns an obviously invalid reading (such as -1) instead of blocking if the sensor isn't ready yet.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That leaves your main program free to service whatever needs doing and is ready to do without holding up everything for the slow sensor.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-09-29T17:10:01.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4392" PostTypeId="2" ParentId="4386" CreationDate="2014-09-29T20:20:44.577" Score="2" Body="&lt;p&gt;I have read a lot of materials, watched many videos and completed lots of searching to find great stater Arduino lessons. By far the best place I found was &lt;/p&gt;&#xA;&#xA;&lt;p&gt;opensourcehardwaregroup.com&#xA;&lt;a href=&quot;http://opensourcehardwaregroup.com&quot; rel=&quot;nofollow&quot;&gt;Free to start learning Arduino site&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Free initial course and if you like the lessons you can pay a small fee to get to the advanced course. You will learn a lot!&lt;/p&gt;&#xA;" OwnerUserId="3772" LastActivityDate="2014-09-29T20:20:44.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4393" PostTypeId="1" CreationDate="2014-09-24T19:39:30.313" Score="1" ViewCount="5977" Body="&lt;p&gt;I'm a computer systems engineering student and was planning to buy an Arduino to learn embedded C programming. After researching I found mention that an Arduino may not be a good choice for a beginner that wants to learn about programming embedded systems using C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if that is true, can an Arduino be programmed in C without using C++ and the other included class libraries? I'd prefer to learn how to program things at a fairly low level and not rely on libraries that hide details of the underlying hardware. Can the Arduino be used as a general AVR / microcontroller development platform to learn embedded C programming?&lt;/p&gt;&#xA;" OwnerDisplayName="R3ack" LastActivityDate="2018-10-30T14:11:55.127" Title="Using an Arduino for learning embedded C programming" Tags="|c|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4394" PostTypeId="2" ParentId="4393" CreationDate="2014-09-30T01:11:21.813" Score="3" Body="&lt;p&gt;The Arduino is a great place to start embedded C programming. You can use both C and CPP. There are tons of tutorials online and there are a bunch of books available. In addition there are lots of libraries available on GIT HUB for interfacing with all types of hardware like RF24 Wireless Transceivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go into more low level programming, you can. For example, you can set all Port B pins to Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;&#xA;  // initialize the digital pins as an output.&#xA;  DDRB = 0xff;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-09-30T01:11:21.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4395" PostTypeId="1" AcceptedAnswerId="4404" CreationDate="2014-09-30T05:13:12.207" Score="0" ViewCount="474" Body="&lt;p&gt;This is the error which shows up after the sketch is compiled and starts uploading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some sort of fix to this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no shields connected to it, not even I/O pins are being used, just trying the simple Blink sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE : It was working find before and then it started acting crazy&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Binary sketch size: 1,084 bytes (of a 32,256 byte maximum)&#xA;C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM3 -b115200 -D -Uflash:w:G:\Temp\build5658632448223358877.tmp\Blink.cpp.hex:i &#xA;&#xA;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : \\.\COM3&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;         AVR Part                      : ATMEGA328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;avrdude: Send: A [41] . [80]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [98]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;         Hardware Version: 3&#xA;         Firmware Version: 4.4&#xA;avrdude: Send: A [41] . [84]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [85]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [86]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [87]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [89]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [03] &#xA;avrdude: Recv: . [10] &#xA;         Vtarget         : 0.3 V&#xA;         Varef           : 0.3 V&#xA;         Oscillator      : 28.800 kHz&#xA;         SCK period      : 3.3 us&#xA;&#xA;avrdude: Send: A [41] . [81]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: A [41] . [82]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [04] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: P [50]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | avrdude: Send: u [75]   [20] &#xA;avrdude: Recv: . [14] . [1e] . [95] . [0f] . [10] &#xA;################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: Send: V [56] . [a0] . [03] . [fc] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [fd] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [fe] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: V [56] . [a0] . [03] . [ff] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [00] &#xA;avrdude: Recv: . [10] &#xA;avrdude: reading input file &quot;G:\Temp\build5658632448223358877.tmp\Blink.cpp.hex&quot;&#xA;avrdude: writing flash (1084 bytes):&#xA;&#xA;Writing | avrdude: Send: U [55] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [0c] . [94] a [61] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] . [9d] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [00] . [00] . [00] . [00] $ [24] . [00] ' [27] . [00] * [2a] . [00] . [00] . [00] . [00] . [00] % [25] . [00] ( [28] . [00] + [2b] . [00] . [00] . [00] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;#####avrdude: Send: U [55] @ [40] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] # [23] . [00] &amp;amp; [26] . [00] ) [29] . [00] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [02] . [02] . [02] . [02] . [02] . [02] . [03] . [03] . [03] . [03] . [03] . [03] . [01] . [02] . [04] . [08] . [10]   [20] @ [40] . [80] . [01] . [02] . [04] . [08] . [10]   [20] . [01] . [02] . [04] . [08] . [10]   [20] . [00] . [00] . [00] . [07] . [00] . [02] . [01] . [00] . [00] . [03] . [04] . [06] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [11] $ [24] . [1f] . [be] . [cf] . [ef] . [d8] . [e0] . [de] . [bf] . [cd] . [bf] . [11] . [e0] . [a0] . [e0] . [b1] . [e0] . [ea] . [e3] . [f4] . [e0] . [02] . [c0] . [05] . [90] . [0d] . [92] . [a2] 0 [30] . [b1] . [07] . [d9] . [f7] . [11] . [e0] . [a2] . [e0] . [b1] . [e0] . [01] . [c0] . [1d] . [92] . [ab] 0 [30] . [b1] . [07] . [e1] . [f7] . [0e] . [94] . [0c] . [02] . [0c] . [94] . [1b] . [02] . [0c] . [94] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [80] . [91] . [00] . [01] ` [60] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [08] . [95] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] y [79] . [01] . [08] . [95] . [1f] . [92] . [0f] . [92] . [0f] . [b6] . [0f] . [92] . [11] $ [24] / [2f] . [93] ? [3f] . [93] . [8f] . [93] . [9f] . [93] . [af] . [93] . [bf] . [93] . [80] . [91] . [06] . [01] . [90] . [91] . [07] . [01] . [a0] . [91] . [08] . [01] . [b0] . [91] . [09] . [01] 0 [30] . [91] . [0a] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] # [23] / [2f] - [2d] _ [5f] - [2d] 7 [37]   [20] . [f0] - [2d] W [57] . [01] . [96] . [a1] . [1d] . [b1] . [1d]   [20] . [93] . [0a] . [01] . [80] . [93]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [06] . [01] . [90] . [93] . [07] . [01] . [a0] . [93] . [08] . [01] . [b0] . [93] . [09] . [01] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [80] . [93] . [02] . [01] . [90] . [93] . [03] . [01] . [a0] . [93] . [04] . [01] . [b0] . [93] . [05] . [01] . [bf] . [91] . [af] . [91] . [9f] . [91] . [8f] . [91] ? [3f] . [91] / [2f] . [91] . [0f] . [90] . [0f] . [be] . [0f] . [90] . [1f] . [90] . [18] . [95] . [9b] . [01] . [ac] . [01] . [7f] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] f [66] . [b5] . [a8] . [9b] . [05] . [c0] o [6f] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [7f] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [86] . [0f] . [91] . [1d]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [a1] . [1d] . [b1] . [1d] b [62] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] j [6a] . [95] . [d1] . [f7] . [bc] . [01] - [2d] . [c0] . [ff] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [e6] . [b5] . [a8] . [9b] . [05] . [c0] . [ef] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [ff] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [8e] . [0f] . [91] . [1d] . [a1] . [1d] . [b1] . [1d] . [e2] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] . [ea] . [95] . [d1] . [f7] . [86] . [1b] . [97] . [0b] . [88] ^ [5e] . [93] @ [40] . [c8] . [f2] ! [21] P [50] 0 [30] @ [40] @ [40] @ [40] P [50] @ [40] h [68] Q [51] | [7c] O [4f] ! [21] . [15] 1 [31] . [05] A [41] . [05] Q [51] . [05] q [71] . [f6] . [08] . [95] x [78] . [94] . [84] . [b5]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] @ [40] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [82] ` [60] . [84] . [bd] . [84] . [b5] . [81] ` [60] . [84] . [bd] . [85] . [b5] . [82] ` [60] . [85] . [bd] . [85] . [b5] . [81] ` [60] . [85] . [bd] . [ee] . [e6] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [e8] . [f0] . [e0] . [10] . [82] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [e0] . [e8] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [eb] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [e0] . [eb] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [ea] . [e7] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [80] . [81] . [80] h [68] . [80] . [83] . [10] . [92] . [c1] . [00] . [08] . [95] . [cf] . [93] . [df] . [93] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [86] V [56] . [9f] O [4f]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [fc] . [01] 4 [34] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] . [84] . [91] . [88] # [23] i [69] . [f1] . [90] . [e0] . [88] . [0f] . [99] . [1f] . [fc] . [01] . [e8] Y [59] . [ff] O [4f] . [a5] . [91] . [b4] . [91] . [fc] . [01] . [ee] X [58] . [ff] O [4f] . [c5] . [91] . [d4] . [91] f [66] # [23] Q [51] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [89] # [23] . [0b] . [c0] b [62] 0 [30] a [61] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [83] + [2b] . [88] . [83] / [2f] . [bf] . [06] . [c0] . [9f] . [b7] . [f8] . [94] . [8c] . [91] . [83] + [2b] . [8c] . [93] . [9f] . [bf] . [df] . [91] . [cf] . [91] . [08] . [95] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [82] U [55] . [9f] O [4f] . [fc] . [01] $ [24] . [91] . [ca] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] . [80] F [46] . [86] V [56] . [9f] O [4f] . [fc] . [01] . [94] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] 4 [34] . [91] 3 [33] # [23] . [09] . [f4] @ [40] . [c0] &quot; [22] # [23] Q [51] . [f1] # [23] 0 [30] q [71] . [f0] $ [24] 0 [30] ( [28] . [f4] ! [21] 0 [30] . [a1] . [f0] &quot; [22] 0 [30] . [11] . [f5] . [14] . [c0] &amp;amp; [26] 0 [30] . [b1] . [f0] ' [27] 0 [30] . [c1] . [f0] $ [24] 0 [30] . [d9] . [f4] . [04] . [c0] . [80] . [91] . [80] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [80] . [00] . [8f] } [7d] . [80] . [93] . [80] . [00] . [10] . [c0] . [84] . [b5] . [8f] w [77] . [02] . [c0] . [84] . [b5] . [8f] } [7d] . [84] . [bd] . [09] . [c0] . [80] . [91] . [b0] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [b0] . [00] . [8f] } [7d] . [80] . [93] . [b0] . [00] . [e3] / [2f] . [f0] . [e0] . [ee] . [0f] . [ff] . [1f] . [ee] X [58] . [ff] O [4f] . [a5] . [91] . [b4] . [91] / [2f] . [b7]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [02]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: d [64] . [00] &amp;lt; [3c] F [46] . [f8] . [94] f [66] # [23] ! [21] . [f4] . [8c] . [91] . [90] . [95] . [89] # [23] . [02] . [c0] . [8c] . [91] . [89] + [2b] . [8c] . [93] / [2f] . [bf] . [08] . [95] . [cf] . [93] . [df] . [93] . [0e] . [94] &amp;gt; [3e] . [01] . [0e] . [94] . [97] . [00] . [c0] . [e0] . [d0] . [e0] . [0e] . [94] . [80] . [00]   [20] . [97] . [e1] . [f3] . [0e] . [94] . [00] . [00] . [f9] . [cf] . [f8] . [94] . [ff] . [cf] . [0d] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;### | 100% 0.27s&#xA;&#xA;avrdude: 1084 bytes of flash written&#xA;avrdude: verifying flash memory against G:\Temp\build5658632448223358877.tmp\Blink.cpp.hex:&#xA;avrdude: load data flash data from input file G:\Temp\build5658632448223358877.tmp\Blink.cpp.hex:&#xA;avrdude: input file G:\Temp\build5658632448223358877.tmp\Blink.cpp.hex contains 1084 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | avrdude: Send: U [55] . [00] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [0c] . [94] a [61] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] . [9d] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [00] . [00] . [00] . [00] $ [24] . [00] ' [27] . [00] * [2a] . [00] . [00] . [00] . [00] . [00] % [25] . [00] ( [28] . [00] + [2b] . [00] . [00] . [00] . [00] . [00] &#xA;avrdude: Recv: . [10] &#xA;#####avrdude: Send: U [55] @ [40] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: # [23] . [00] &amp;amp; [26] . [00] ) [29] . [00] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [02] . [02] . [02] . [02] . [02] . [02] . [03] . [03] . [03] . [03] . [03] . [03] . [01] . [02] . [04] . [08] . [10]   [20] @ [40] . [80] . [01] . [02] . [04] . [08] . [10]   [20] . [01] . [02] . [04] . [08] . [10]   [20] . [00] . [00] . [00] . [07] . [00] . [02] . [01] . [00] . [00] . [03] . [04] . [06] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [11] $ [24] . [1f] . [be] . [cf] . [ef] . [d8] . [e0] . [de] . [bf] . [cd] . [bf] . [11] . [e0] . [a0] . [e0] . [b1] . [e0] . [ea] . [e3] . [f4] . [e0] . [02] . [c0] . [05] . [90] . [0d] . [92] . [a2] 0 [30] . [b1] . [07] . [d9] . [f7] . [11] . [e0] . [a2] . [e0] . [b1] . [e0] . [01] . [c0] . [1d] . [92] . [ab] 0 [30] . [b1] . [07] . [e1] . [f7] . [0e] . [94] . [0c] . [02] . [0c] . [94] . [1b] . [02] . [0c] . [94] . [00] . [00] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [80] . [91] . [00] . [01] ` [60] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [08] . [95] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] y [79] . [01] . [08] . [95] . [1f] . [92] . [0f] . [92] . [0f] . [b6] . [0f] . [92] . [11] $ [24] / [2f] . [93] ? [3f] . [93] . [8f] . [93] . [9f] . [93] . [af] . [93] . [bf] . [93] . [80] . [91] . [06] . [01] . [90] . [91] . [07] . [01] . [a0] . [91] . [08] . [01] . [b0] . [91] . [09] . [01] 0 [30] . [91] . [0a] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] # [23] / [2f] - [2d] _ [5f] - [2d] 7 [37]   [20] . [f0] - [2d] W [57] . [01] . [96] . [a1] . [1d] . [b1] . [1d]   [20] . [93] . [0a] . [01] . [80] . [93] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [00]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [06] . [01] . [90] . [93] . [07] . [01] . [a0] . [93] . [08] . [01] . [b0] . [93] . [09] . [01] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [80] . [93] . [02] . [01] . [90] . [93] . [03] . [01] . [a0] . [93] . [04] . [01] . [b0] . [93] . [05] . [01] . [bf] . [91] . [af] . [91] . [9f] . [91] . [8f] . [91] ? [3f] . [91] / [2f] . [91] . [0f] . [90] . [0f] . [be] . [0f] . [90] . [1f] . [90] . [18] . [95] . [9b] . [01] . [ac] . [01] . [7f] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] f [66] . [b5] . [a8] . [9b] . [05] . [c0] o [6f] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [7f] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [86] . [0f] . [91] . [1d] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [a1] . [1d] . [b1] . [1d] b [62] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] j [6a] . [95] . [d1] . [f7] . [bc] . [01] - [2d] . [c0] . [ff] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [e6] . [b5] . [a8] . [9b] . [05] . [c0] . [ef] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [ff] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [8e] . [0f] . [91] . [1d] . [a1] . [1d] . [b1] . [1d] . [e2] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] . [ea] . [95] . [d1] . [f7] . [86] . [1b] . [97] . [0b] . [88] ^ [5e] . [93] @ [40] . [c8] . [f2] ! [21] P [50] 0 [30] @ [40] @ [40] @ [40] P [50] @ [40] h [68] Q [51] | [7c] O [4f] ! [21] . [15] 1 [31] . [05] A [41] . [05] Q [51] . [05] q [71] . [f6] . [08] . [95] x [78] . [94] . [84] . [b5] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] @ [40] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [82] ` [60] . [84] . [bd] . [84] . [b5] . [81] ` [60] . [84] . [bd] . [85] . [b5] . [82] ` [60] . [85] . [bd] . [85] . [b5] . [81] ` [60] . [85] . [bd] . [ee] . [e6] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [e8] . [f0] . [e0] . [10] . [82] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [e0] . [e8] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [eb] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [e0] . [eb] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [ea] . [e7] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [80] . [81] . [80] h [68] . [80] . [83] . [10] . [92] . [c1] . [00] . [08] . [95] . [cf] . [93] . [df] . [93] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [86] V [56] . [9f] O [4f] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [80] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [fc] . [01] 4 [34] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] . [84] . [91] . [88] # [23] i [69] . [f1] . [90] . [e0] . [88] . [0f] . [99] . [1f] . [fc] . [01] . [e8] Y [59] . [ff] O [4f] . [a5] . [91] . [b4] . [91] . [fc] . [01] . [ee] X [58] . [ff] O [4f] . [c5] . [91] . [d4] . [91] f [66] # [23] Q [51] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [89] # [23] . [0b] . [c0] b [62] 0 [30] a [61] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [83] + [2b] . [88] . [83] / [2f] . [bf] . [06] . [c0] . [9f] . [b7] . [f8] . [94] . [8c] . [91] . [83] + [2b] . [8c] . [93] . [9f] . [bf] . [df] . [91] . [cf] . [91] . [08] . [95] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [82] U [55] . [9f] O [4f] . [fc] . [01] $ [24] . [91] . [ca] . [01] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [c0] . [01]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] . [80] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [86] V [56] . [9f] O [4f] . [fc] . [01] . [94] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] 4 [34] . [91] 3 [33] # [23] . [09] . [f4] @ [40] . [c0] &quot; [22] # [23] Q [51] . [f1] # [23] 0 [30] q [71] . [f0] $ [24] 0 [30] ( [28] . [f4] ! [21] 0 [30] . [a1] . [f0] &quot; [22] 0 [30] . [11] . [f5] . [14] . [c0] &amp;amp; [26] 0 [30] . [b1] . [f0] ' [27] 0 [30] . [c1] . [f0] $ [24] 0 [30] . [d9] . [f4] . [04] . [c0] . [80] . [91] . [80] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [80] . [00] . [8f] } [7d] . [80] . [93] . [80] . [00] . [10] . [c0] . [84] . [b5] . [8f] w [77] . [02] . [c0] . [84] . [b5] . [8f] } [7d] . [84] . [bd] . [09] . [c0] . [80] . [91] . [b0] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [b0] . [00] . [8f] } [7d] . [80] . [93] . [b0] . [00] . [e3] / [2f] . [f0] . [e0] . [ee] . [0f] . [ff] . [1f] . [ee] X [58] . [ff] O [4f] . [a5] . [91] . [b4] . [91] / [2f] . [b7] &#xA;avrdude: Recv: . [10] &#xA;######avrdude: Send: U [55] . [00] . [02]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;avrdude: Send: t [74] . [00] &amp;lt; [3c] F [46]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [f8] . [94] f [66] # [23] ! [21] . [f4] . [8c] . [91] . [90] . [95] . [89] # [23] . [02] . [c0] . [8c] . [91] . [89] + [2b] . [8c] . [93] / [2f] . [bf] . [08] . [95] . [cf] . [93] . [df] . [93] . [0e] . [94] &amp;gt; [3e] . [01] . [0e] . [94] . [97] . [00] . [c0] . [e0] . [d0] . [e0] . [0e] . [94] . [80] . [00]   [20] . [97] . [e1] . [f3] . [0e] . [94] . [00] . [00] . [f9] . [cf] . [f8] . [94] . [ff] . [cf] . [0d] . [00] &#xA;avrdude: Recv: . [10] &#xA;### | 100% 0.20s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 1084 bytes of flash verified&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3039" LastActivityDate="2014-09-30T16:25:27.973" Title="Getting a long avrdude error while uploading a simple sketch to arduino uno" Tags="|arduino-uno|avrdude|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4396" PostTypeId="2" ParentId="4314" CreationDate="2014-09-30T05:25:22.510" Score="0" Body="&lt;p&gt;In such a case I would use HTTP requests from a web server using PHP to arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a simple explanation the PHP sends a string in its url and then the arduino checks for that string and do something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used such method and it served me well and actually fast too.&lt;/p&gt;&#xA;" OwnerUserId="3039" LastActivityDate="2014-09-30T05:25:22.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4397" PostTypeId="2" ParentId="4314" CreationDate="2014-09-30T07:43:31.613" Score="1" Body="&lt;p&gt;It is very interesting project. In my opinion, i would not do like you want to control generators from one point.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Look at &lt;a href=&quot;http://en.wikipedia.org/wiki/ZigBee&quot; rel=&quot;nofollow&quot;&gt;ZigBee&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Wireless_sensor_network&quot; rel=&quot;nofollow&quot;&gt;Wireless sensor network&lt;/a&gt;. It is possible. Do more search, also there are several books about networking.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I think that would be more efficient to control the wind turbine with an Arduino and send only data to the main computer. Main computer should do some calculations or send some main configuration data or control on/off wind turbine basis of:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.1  Metrological data (wind speed or else);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.2 Storage SOC(if you will store it in batteries or somewhere);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.3 Required power of grid and etc. etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO like you said, connected to computer could do just data collection and making it compatible with computer(MatLab or whatever) and spread control data from PC to targeted Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Added links&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could not add more than 2 links due to low reputation :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;http://www.digi.com/pdf/wp_zigbeevsdigimesh.pdf , http://forum.arduino.cc/index.php?topic=105273.0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-09-30T07:43:31.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4398" PostTypeId="1" AcceptedAnswerId="4399" CreationDate="2014-09-30T09:16:50.000" Score="1" ViewCount="778" Body="&lt;p&gt;I don't have much experience with electronics. I was wondering if it is possible to create a push button switch, which will turn on the device only if it is tapped twice in quick succession?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is tapped only once, then the device should behave as if nothing happened (i.e. tapping the switch again after a specified duration should have no effect).&lt;/p&gt;&#xA;" OwnerUserId="4189" LastEditorUserId="37" LastEditDate="2014-09-30T11:15:40.347" LastActivityDate="2017-09-09T02:21:20.080" Title="Turn Arduino on only by double tapping switch?" Tags="|button|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4399" PostTypeId="2" ParentId="4398" CreationDate="2014-09-30T09:23:32.260" Score="2" Body="&lt;p&gt;You can use something like the ATtiny25/45/85 then have a button cell battery to power it, make it a sleeper that listens to the button, and when clicked it activates the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is then turned on keeping a capacitor alive holding a transistor active, then add another button that drains the capacitor, thus closing the transistor and turning the Arduino off. Or you can program the ATtiny to drain the capacitor if the button is held down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A button cell on an ATtiny in sleepmode should last around a year or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just some information to get you going further:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Learning/arduinoSleepCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Learning/arduinoSleepCode&lt;/a&gt; : The sleeper code, it is power saving using interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&lt;/a&gt; : How to burn an ATtiny using Arduino. Fairly simple, did it myself a few times.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="26916" LastEditDate="2017-09-09T02:21:20.080" LastActivityDate="2017-09-09T02:21:20.080" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4400" PostTypeId="2" ParentId="4337" CreationDate="2014-09-30T11:44:57.720" Score="0" Body="&lt;p&gt;IF you need to dim leds use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*PWM signal on most pins is approximately 490 Hz&#xA;On the Uno and similar boards, pins 5 and 6 &#xA;have a frequency of approximately 980 Hz&#xA;brightness1, brightness2 = from 0(0v) to 255(5v)&#xA;So make eqution to calculate needed frequency*/&#xA;&#xA;//LED are connected to:&#xA;const int ledPin1 = 5; &#xA;const int ledPin2 = 6; &#xA;byte brightness1 = 100; // ~2v&#xA;byte brightness2 = 200; // ~4v&#xA;void setup()&#xA;{&#xA;  // initialize the ledPin as an output:&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    // set the brightness of the LED:&#xA;    analogWrite(ledPin1, brightness1);&#xA;    analogWrite(ledPin2, brightness2);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-09-30T12:39:34.450" LastActivityDate="2014-09-30T12:39:34.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4402" PostTypeId="1" CreationDate="2014-09-30T14:19:09.127" Score="10" ViewCount="35289" Body="&lt;p&gt;I am a beginner and I want to learn AVR C/C++. Can I do this using an Arduino?  (I'm asking this because I already have one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, could someone tell me using which IDE can I write code in pure C/C++ and then flash it to the Atmega328P on the Arduino?  Or, should I get an AVR and a programmer instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched all over the internet and I'm really confused by all the terminology. Could someone explain it to me?    &lt;/p&gt;&#xA;" OwnerUserId="4194" LastEditorUserId="19409" LastEditDate="2022-01-04T00:52:20.670" LastActivityDate="2022-01-04T00:52:20.670" Title="How can I program an arduino in pure C/C++?" Tags="|c++|c|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="4403" PostTypeId="2" ParentId="4402" CreationDate="2014-09-30T14:56:59.917" Score="4" Body="&lt;p&gt;Yes, get an AVR programmer instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) You can flash your arduino board with &lt;strong&gt;avrdude/avr-gcc&lt;/strong&gt;. Install these tools, find the datasheet of atmega328 (google it), use the board pinouts to connect to your programmer (stk500v2/ISP) and voila! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Keep in mind that by &quot;manually&quot; flashing your atmaga on arduino board you're removing bootloader that is needed to load your sketches from ARDUINO IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Use your favourite C/C++ IDE&lt;/p&gt;&#xA;" OwnerUserId="4195" LastActivityDate="2014-09-30T14:56:59.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4404" PostTypeId="2" ParentId="4395" CreationDate="2014-09-30T16:25:27.973" Score="3" Body="&lt;p&gt;This is not an error. AVRDude is running with the Verbose flag on. Verbose in English means: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;using or expressed in more words than are needed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7ZYID.png&quot; alt=&quot;Running with the Verbose flag.&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-09-30T16:25:27.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4405" PostTypeId="1" AcceptedAnswerId="4406" CreationDate="2014-09-30T22:03:46.430" Score="1" ViewCount="970" Body="&lt;p&gt;I am completely new to this, and a novice when it comes to electronics but I want to learn.&#xA;Can someone pls tell me how I would connect the display in the photo here with an Arduino Uno (which I have ordered).  The plan is to interface my car with this transparent display to produce a form of HUD.&#xA;I have done some searching but to no avail so far, would appreciate being pointed in the right direction.&#xA;many thanks&lt;img src=&quot;https://i.stack.imgur.com/5KfTx.jpg&quot; alt=&quot;transparent LCD clock&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4166" LastActivityDate="2014-10-01T00:14:08.033" Title="How do I connect this display to an Arduino Uno" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4406" PostTypeId="2" ParentId="4405" CreationDate="2014-10-01T00:14:08.033" Score="3" Body="&lt;p&gt;You're in for a &lt;em&gt;lot&lt;/em&gt; of work. Everything on the PCB is useless to you, so you'd have to interface the raw panel to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first matter is to remove the panel from the board. You will need to desolder all of the connections, and then solder either some sort of rigid connector or individual wires to the large ribbon connector. The only advice I can give you is &quot;be prepared to fail&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you've done that, you will need to read &lt;a href=&quot;http://www.atmel.com/Images/doc8103.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR340&lt;/a&gt; in order to learn how to drive the panel. Note that the Uno itself does not have enough pins to drive the panel directly, so you will need to get an I/O expander or two for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I mention that you're in for a lot of work? Well, I'm mentioning it again. Good luck though.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-01T00:14:08.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4407" PostTypeId="1" AcceptedAnswerId="4414" CreationDate="2014-10-01T00:19:12.370" Score="7" ViewCount="4146" Body="&lt;p&gt;I have to track a large amount of data (for an Arduino) in a program while taking care of a fair amount of other business.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with a struct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyStruct&#xA;{&#xA;   // note: these names might as well be foo bar baz&#xA;   uint8_t color; &#xA;   boolean state; &#xA;   uint8_t area;&#xA;   uint8_t number;&#xA;   uint8_t len;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an array of 800 of these. At 5 bytes each, that's 4Kb, or half the ram on the Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed to a struct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyStruct&#xA;{&#xA;   uint8_t color : 3; // max value 7&#xA;   // uint8_t state : 1; *** moved, thanks Ignacio ***&#xA;   uint8_t area : 5; // m.v. 31&#xA;   uint8_t number;&#xA;   uint8_t len : 5; // m.v. 31&#xA;   uint8_t state : 1; // m.v. 1&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand this reduces the size of each instance to 3 bytes, for a total of 2.4Kb in my array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read that in some implementations / chipsets using bit fields in structs can lead to less efficient execution. Obviously this is a more efficient use of memory, but my question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does the Arduino handle bit fields? Will it be better, worse, or negligibly different in terms or speed when iterating through an array of bit field structs? Is there a good way to test this?&lt;/p&gt;&#xA;" OwnerUserId="3230" LastEditorUserId="3230" LastEditDate="2014-10-01T00:45:32.067" LastActivityDate="2014-10-01T17:23:53.300" Title="Advisability of Using Bit Fields in Structs" Tags="|arduino-mega|c++|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4408" PostTypeId="2" ParentId="4402" CreationDate="2014-10-01T00:29:52.550" Score="3" Body="&lt;p&gt;If you're a beginner, I suggest you write C in the Arduino IDE. The libraries are very useful and I think the Arduino/Wiring/Processing environment will cover all your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out the Lightblue Bean (&lt;a href=&quot;http://punchthrough.com/bean/&quot; rel=&quot;nofollow&quot;&gt;http://punchthrough.com/bean/&lt;/a&gt;) it is a good example of the power of that platform. Even experienced embedded programmers can use it, since the underlying register are still accessible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now programming on the Ti MSP430, and while I can appreciate the possibilities, I miss the simplicity of Arduino; much easier to get started with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to &lt;a href=&quot;http://arduino.cc/en/main/software&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/main/software&lt;/a&gt; to download the 1.0.6. IDE software, plug your Arduino, go to Tools-&gt;Board to select your Arduino, select the appropriate &quot;tty&quot; port in the Tools-&gt;Serial_Port.&#xA;Then write in pure C and download. There are tons of examples included with the IDE.&lt;/p&gt;&#xA;" OwnerUserId="4202" LastEditorUserId="11" LastEditDate="2014-10-01T03:42:16.183" LastActivityDate="2014-10-01T03:42:16.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4409" PostTypeId="2" ParentId="40" CreationDate="2014-10-01T00:37:25.207" Score="3" Body="&lt;p&gt;I use Xcode, set up as an external editor. I write everything in libraries, and the sketch simply call the libraries.&lt;/p&gt;&#xA;" OwnerUserId="4202" LastEditorUserId="4628" LastEditDate="2017-04-04T11:33:45.303" LastActivityDate="2017-04-04T11:33:45.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4410" PostTypeId="1" CreationDate="2014-10-01T01:06:59.240" Score="3" ViewCount="1151" Body="&lt;p&gt;I am planning to control multiple Dynamixel servos (MX28T or MX-64T) wirelessly using an Arduino Mega. Since this servo uses serial communication, I need an additional serial port to interface with XBee module. Although it seems to be very common application controlling these servos wirelessly based on Arduino, I could't find any of them in web. I found the two very well constructed libraries.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/slide-33/downloads/list&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://code.google.com/p/slide-33/downloads/list&lt;/a&gt;. This library is for MX28T servo, which is the same servo I am trying to use, but it uses UNO;therefore, I cannot interface with XBee.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.pablogindel.com/informacion/the-arduinodynamixel-resource-page/&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Arduino/Dynamixel Resource Page...&lt;/a&gt; This library uses UART1 (serial1) to interface with servo (AX-12) motors. Therefore, I can connect XBee module to UART0. But, the problem is that this library is outdated and not compatible with MX64-T servo anymore. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any one who has experience in controlling Dynamixel MX24T, MX64T servo series using XBee module simultaneously? If you have experience, please share with me.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible for Arduino Mega can interface with Xbee module using Serial1 (i.e., RX18 TX19)? If it can, I might be able to use the library1 without any modification. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4106" LastEditorUserId="6936" LastEditDate="2017-06-04T08:17:29.623" LastActivityDate="2020-09-28T04:48:20.267" Title="Controlling Dynamixel MX24T, MX64T servo wirelessly using Arduino Mega?" Tags="|serial|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4411" PostTypeId="2" ParentId="3539" CreationDate="2014-10-01T01:08:45.270" Score="2" Body="&lt;pre&gt;&lt;code&gt;char* c = &quot;&quot;;&#xA;while(c == &quot;&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable named c is a misnomer, because it is a pointer to a string, not a character.&#xA;For example c = 0x123456.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use a more explicit name for your variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This first line assigns a pointer to an empty string to the c pointer.&#xA;So, the value stored at address 0x123456 == whatever pointer to a static memory address containing '\0'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that no memory has been allocated to hold characters. Only a pointer to char has been allocated. Thus you cannot store anything in your string!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could write something like:&#xA;&lt;code&gt;char data[2] = &quot;&quot;;&lt;/code&gt;&#xA;That would allocate a pointer, and a string to hold 2 characters&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The second line, &lt;code&gt;while(c == &quot;&quot;)&lt;/code&gt; compares a real memory pointer (e.g. 0x123456) with a compiler pointer.&#xA;&lt;code&gt;&quot;&quot;&lt;/code&gt; is not a real application pointer, you should not manipulate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that second line relies on a compiler behavior.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I were you I would wrap the multi-char routine into a single-char routine. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ReadChar(char *c)&#xA;{&#xA;  return ReadData(c, 1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main()&#xA;{&#xA;  char c;&#xA;  ReadChar(&amp;amp;c);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On a different note, I think the compiler should catch such error.&#xA;The line &lt;code&gt;c == &quot;&quot;&lt;/code&gt; would never do anything useful and should be caught.&lt;/p&gt;&#xA;" OwnerUserId="4202" LastEditorUserId="6250" LastEditDate="2014-12-15T16:49:54.377" LastActivityDate="2014-12-15T16:49:54.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4412" PostTypeId="1" CreationDate="2014-10-01T03:34:47.230" Score="1" ViewCount="2026" Body="&lt;p&gt;So I am working on this lab for my Embedded Systems class, but I can't seem to read anything but the first bit of PORTC.  What's even weirder is that if any of the pins go low the first bit will go to 0, while all the others stay at 0 no matter what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /*&#xA; * Lab_4A.c&#xA; *&#xA; *  Reads the value of one distance sensor&#xA; *  and reports if light/dark to the LCD.&#xA; *&#xA; *  Created on: Sep 24, 2014&#xA; *  Author: Austin R. Bartz&#xA; *&#xA; *  LCD Connections:&#xA; *  E   - PB4 (Digital 12)&#xA; *  RS  - PB5 (Digital 13)&#xA; *  R/W - GND&#xA; *  Data 4,5,6,7 - PD4,5,6,7 (Digital 4,5,6,7)&#xA; *&#xA; *  Sensor Connections:&#xA; *  Sensor 8 - PC0 (Analog A0)&#xA; *  Sensor 7 - PC1 (Analog A1)&#xA; *  Sensor 6 - PC2 (Analog A2)&#xA; *  Sensor 5 - PC3 (Analog A3)&#xA; */&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;inttypes.h&amp;gt;&#xA;#include &amp;lt;MSOE/delay.c&amp;gt;&#xA;#include &amp;lt;MSOE/bit.c&amp;gt;&#xA;#include &amp;lt;MSOE/lcd.c&amp;gt;&#xA;#include &amp;lt;user/initPorts.c&amp;gt;&#xA;#include &amp;lt;user/readPorts.c&amp;gt;&#xA;#include &amp;lt;user/writePorts.c&amp;gt;&#xA;&#xA;void printBinaryLCD(uint8_t);&#xA;uint8_t readSensors();&#xA;&#xA;int main(void)&#xA;{&#xA;    lcd_init();&#xA;    lcd_clear();&#xA;    while(1)&#xA;    {&#xA;        uint8_t val = readSensors();&#xA;        printBinaryLCD(val);&#xA;    }&#xA;}&#xA;&#xA;void printBinaryLCD(uint8_t val)&#xA;{&#xA;    lcd_home();&#xA;    uint8_t A = ((PINC &amp;amp; (1&amp;lt;&amp;lt;3)) == (1&amp;lt;&amp;lt;3));&#xA;    lcd_print_uint8(A);&#xA;    lcd_goto_xy(1,0);&#xA;    uint8_t B = ((PINC &amp;amp; (1&amp;lt;&amp;lt;2)) == (1&amp;lt;&amp;lt;2));&#xA;    lcd_print_uint8(B);&#xA;    lcd_goto_xy(2,0);&#xA;    uint8_t C = ((PINC &amp;amp; (1&amp;lt;&amp;lt;1)) == (1&amp;lt;&amp;lt;1));&#xA;    lcd_print_uint8(C);&#xA;    lcd_goto_xy(3,0);&#xA;    uint8_t D = ((PINC &amp;amp; (1&amp;lt;&amp;lt;0)) == (1&amp;lt;&amp;lt;0));&#xA;    lcd_print_uint8(D);&#xA;}&#xA;&#xA;uint8_t readSensors()&#xA;{&#xA;    DDRC = 1;&#xA;    PORTC = 1;&#xA;    delay_us(10);&#xA;    DDRC = 0;&#xA;    PORTC = 0;&#xA;    delay_ms(1);&#xA;    return PINC;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="4203" LastActivityDate="2015-05-29T11:36:22.493" Title="Why can't I read anything but Pin 0 of PORTC?" Tags="|pins|lcd|c|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4413" PostTypeId="2" ParentId="4219" CreationDate="2014-10-01T06:37:49.927" Score="0" Body="&lt;p&gt;Sounds like a fascinating project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like the majority of signals are driven by one ATTiny85 and received by a neighboring ATTiny85 about 12 inches away, with a good ground connection between them.&#xA;Those signals can be directly connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were you, I would go ahead and get differential transceivers for the 10 meter distance.&#xA;If you use daisy-chain SPI, then you need 3 differential line drivers at one end of the cable and 1 differential line driver at the other (and the corresponding line receivers to match); plus GND and +12VDC.&#xA;If you use a SN75176BP as a line driver and another one as a line receiver for each SPI signal, that's a total of less than $8 for those 8 interface chips.&#xA;(You need fewer line driver chips if you somehow daisy-chain TTL UART serial, since it uses fewer pins, but requires each chip to have more precise baud clock).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The software should not even be able to detect the difference between a simple wire from the output pin of one chip to the input pin of the next chip, vs. a line driver, some twisted pair cable, and a line receiver between those same two chips running the same software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people use the rule of thumb that if a bit time is less than 10 times the time it takes for something traveling at the speed of light to make a round trip from the transmitter to the receiver and back, then you must use differential signaling with line termination.&#xA;At 1 MHz, that gives a (1-way) cable length of 15 meters before you must use differential signaling with line termination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So using the differential line drivers is probably overkill, but I'd rather have the first prototype work rather than cut corners on 100 things that I'm 99% sure &lt;em&gt;probably&lt;/em&gt; won't matter, and then spend a lot of time debugging trying to figure out which one or two of those 100 things turns out that it &lt;em&gt;does&lt;/em&gt; matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to distance, loading might also be an issue.&#xA;In particular, the &quot;CLK&quot; and &quot;/CS&quot; pins from the SPI master apparently need to drive every SPI slave.&#xA;You can't really expect a single MCU output pin or even a single RS485 line receiver to be able to drive 200+ other chips.&#xA;A line driver or other buffer every 10 or so chips is more than adequate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://jeelabs.org/2013/06/19/what-if-the-signal-lines-are-very-long/&quot; rel=&quot;nofollow&quot;&gt;&quot;What if the SPI signal lines are very long?&quot;&lt;/a&gt;&#xA;(this experiment completely neglects the effects of interference from &lt;em&gt;other&lt;/em&gt; noisy devices).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nxp.com/documents/application_note/AN10364.pdf&quot; rel=&quot;nofollow&quot;&gt;AN10364 &quot;Transmitting the I2C signals as differential signals using RS-485 hardware&quot;&lt;/a&gt;&#xA;(Like SPI, I2C signals were never intended to be transmitted long distances over wire cables.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.baranidesign.com/rs485/rs485.html&quot; rel=&quot;nofollow&quot;&gt;&quot;Maximum Unterminated Network Speed Calculator&quot;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-10-01T06:37:49.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4414" PostTypeId="2" ParentId="4407" CreationDate="2014-10-01T08:04:39.223" Score="8" Body="&lt;p&gt;What you are facing is the classic time-memory tradeoff.  The bit fields will be smaller in memory,  but will take more time to operate on.  You can count that no matter what processor, the bit fields will be slower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use the word &lt;em&gt;efficient&lt;/em&gt;, but that word has no certain meaning without a metric for what is good or bad.  When you only have 8 k of RAM, using memory is bad, time may be cheap.  If you have real time constraints, then using time is bad and memory may be cheap.  In general, you can only buy your way out of this tradeoff.  In other words, when you find both time and memory bad, spend cash and use a bigger chip.  There is no single answer for what is good or bad.  This is part of why there are so many choices for microcontrollers, people fit the chip to the application and application to the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Populating the bits of a bit field will be slower than filling of complete bytes.  Take for example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = 5;&#xA;...&#xA;asimplestruct.len = x;&#xA;// vs&#xA;abitfield.len = x;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first simple case will just:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;load value of x to a register&lt;/li&gt;&#xA;&lt;li&gt;store it to the byte for len&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The second does something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;loads the current value of abitfield&lt;/li&gt;&#xA;&lt;li&gt;loads a mask&lt;/li&gt;&#xA;&lt;li&gt;clears the bits for len&lt;/li&gt;&#xA;&lt;li&gt;loads current value of x&lt;/li&gt;&#xA;&lt;li&gt;loads a mask &lt;/li&gt;&#xA;&lt;li&gt;clears off unused bits of x&lt;/li&gt;&#xA;&lt;li&gt;shifts the bits of x&lt;/li&gt;&#xA;&lt;li&gt;or's x with the abitfield&lt;/li&gt;&#xA;&lt;li&gt;stores the current value back to memory&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If all your operations are packing data into the bit field, or unpacking out of the bitfield, you should expect slower execution.  Bit fields are a type of compression - they cost ticks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But moving around bit fields will be faster because there are less bytes to load and store.  If you where sorting this array, the smaller byte count could be an advantage.  If you where transferring them over a serial port, the compressed size of the bitfield might be a winner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with respect to your question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a good way to test this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The only good way to test this is to write test cases for both approaches using a pattern that closely matches your application.  It really matters what mix of operations you perform to decide whether the difference is negligible or significant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When doing this sort of optimization experiment, definitely use source control on your project.  You can create a local GIT or Mercurial repository with just a few clicks.  Keeping a chain of checkpoints allows you to tear up your code exploring the effects of different implementations.  If you take a wrong turn, the repository allows you to simply go back to the last good point and try another path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Side note:  This time memory tradeoff exists in the opposite direction also.  If you look through the compiler options for desktop class processors, you will find something called &lt;em&gt;structure packing&lt;/em&gt;.  This option allow you to add blank bytes between single byte fields such that they stay aligned at word or double word boundaries.  This may seem crazy to throw away RAM on purpose, but on processors with 16 or 32 bit wide registers and buses, so called word or dword aligned memory operations can be faster than byte wise operations.)&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-10-01T08:04:39.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4415" PostTypeId="2" ParentId="1612" CreationDate="2014-10-01T09:37:34.710" Score="0" Body="&lt;p&gt;1) Easy way&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This transmitter uses &lt;em&gt;only&lt;/em&gt; SPI interface so you need to drive it some logic unit, i.e. microcontroller that supports this interface (i.e. AVR atmega8) and is able to use driver for this module as a ready to use set of high level functions to express your intentions in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Badly bad way&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the SPI to I2C converter as well. Connect it to your computer via serial port - but note that it's a big effort. You will need to port nRF24L01 driver, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.elecrow.com/nrf24l01-wireless-shield-spi-to-i2c-interface-for-arduino-p-737.html&quot; rel=&quot;nofollow&quot;&gt;http://www.elecrow.com/nrf24l01-wireless-shield-spi-to-i2c-interface-for-arduino-p-737.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4195" LastActivityDate="2014-10-01T09:37:34.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4417" PostTypeId="2" ParentId="4407" CreationDate="2014-10-01T11:26:33.070" Score="1" Body="&lt;p&gt;A little tip - I see that the struct is not a 1B aligned for 8bit CPU. At the end of your struct you can add &lt;em&gt;padding&lt;/em&gt; 2bit length or rethink increase of the size of &lt;strong&gt;state&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyStruct&#xA;{&#xA;   uint8_t color : 3; // max value 7&#xA;   // uint8_t state : 1; *** moved, thanks Ignacio ***&#xA;   uint8_t area : 5; // m.v. 31&#xA;   uint8_t number;&#xA;   uint8_t len : 5; // m.v. 31&#xA;   uint8_t state : 1; // m.v. 1&#xA;   uint8_t padding : 2;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4195" LastActivityDate="2014-10-01T11:26:33.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4418" PostTypeId="2" ParentId="4314" CreationDate="2014-10-01T14:49:46.000" Score="0" Body="&lt;p&gt;I have done a similar project in the past;&#xA;for simplicity's sake, lets call the 6 arduino's + turbines &quot;Endnode&quot; and the central receiving and sending arduino the &quot;Controller&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general idea is that each endnode periodically sends a zigbee package(it's important that it is an actual zigbee package, do some research on this subject) to the controller.&#xA;The controller can receive these packages in the form of a serial interrupt. that way, whenever a package is send, the controller instantly starts to handle it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The controller can send the data to the computer, I recommend using http transfer, as it's easy and probably fast enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This proces can be reversed in order to send a command to the endnodes to control the turbine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're interested in my previous work on this subject, I reccomend you check out:&#xA;&lt;a href=&quot;https://code.google.com/p/brakel/source/browse/trunk/Libraries&quot; rel=&quot;nofollow&quot;&gt;Libraries of my previous work&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And &#xA;&lt;a href=&quot;https://code.google.com/p/brakel/source/browse/trunk/BrakelCoordinator/BrakelCoordinator.ino&quot; rel=&quot;nofollow&quot;&gt;The sketch used for the project&lt;/a&gt;&#xA;I appologize for any weirdness, as it was a student project. But it worked flawless ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck!&lt;/p&gt;&#xA;" OwnerUserId="4213" LastActivityDate="2014-10-01T14:49:46.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4419" PostTypeId="1" CreationDate="2014-10-01T15:05:23.110" Score="2" ViewCount="769" Body="&lt;p&gt;My SD card initializes fine in the beginning. It finds the right file and opens it. However, after 5 or 6 minutes of data logging, the error &quot;file not found&quot; appears on my LCD. Why would this be the case? I need this to work consistently for at least an hour, this 5 to 6 minutes will not do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in my code the &quot;sv&quot; and &quot;cpm&quot; data is not yet initialized, due to another problem incorporating a sensor. I left these in there, and the data is just logged as 0 for those variables.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MPL115A1Lib.h&amp;gt;  // Pressure Sensor MPL115A1&#xA;#include &amp;lt;DHT.h&amp;gt;  // Temperature and Humidity Sensor RTH03&#xA;#include &amp;lt;U8glib.h&amp;gt;  // LCD Display 128x64&#xA;#include &amp;lt;floatToString.h&amp;gt;  // Converts floats to strings&#xA;#include &amp;lt;GPS610F.h&amp;gt;  // GPS-610F Module&#xA;#include &amp;lt;RFZuluArduino.h&amp;gt;  // Zulu 2km RF Module&#xA;#include &amp;lt;SD.h&amp;gt; //SD data logger&#xA;&#xA;//----- Defining Modules and Variables ------//&#xA;// Pressure Sensor&#xA;MPL115A1Lib PressSens;  // Defines Pressure Sensor for library&#xA;#define FT_TO_M(x) ((long)((x)*(0.3048)))&#xA;#define KPA_TO_INHG(x) ((x)*(0.295333727))&#xA;#define KPA_TO_MMHG(x) ((x)*(7.50061683))&#xA;#define KPA_TO_PSIA(x) ((x)*(0.145037738))&#xA;#define KPA_TO_KGCM2(x) ((x)*(0.0102))&#xA;#define INHG_TO_PSIA(x) ((x)*(0.49109778))&#xA;#define DEGC_TO_DEGF(x) ((x)*(9.0/5.0)+32.0)&#xA;&#xA;float press_pKa = 0;&#xA;float temp_c = 0;&#xA;long alt_ft = 0;&#xA;char charPress[7];  // Stores pressure&#xA;char charTemp[6];  // Stores temperature in C&#xA;char charAlt[5];  // Stores altitude&#xA;// Temperature &amp;amp; Humidity Sensor&#xA;#define DHTPIN 48     // Defines signal pin connection&#xA;#define DHTTYPE DHT22   // Defines Sensor model # DHT22 (RTH03)&#xA;DHT dht(DHTPIN, DHTTYPE);  // Defines the Temp/Humd Sensor&#xA;float t = 0;  // temp&#xA;float h = 0;  // rel. humd.&#xA;float f = 0;  // temp in f&#xA;float hi = 0;  // heat index&#xA;char rh[6];  // Stores Relative Humidity&#xA;char tempC[6];  // Stores Temperature in °C&#xA;char tempF[7];  // Stores Temp in F&#xA;char heatIndex[7];  // Stores heat index&#xA;char degree[3] = {176, 67};  // Stores °C symbol&#xA;char degreeF[3] = {176, 70};  // Stores °F symbol&#xA;// LCD Display&#xA;U8GLIB_ST7920_128X64_4X u8g(41, 42, 43);  // Defines LCD pins (SPI: EN = 41, RW = 42, RS = 43)&#xA;// GPS Module&#xA;GPS610F gps(17, 16, 28, 26, 44, 27, 9600);  // Defines GPS pins (SDI, SDO1, SDO2, PIO, PPS, RST, baudRate)&#xA;String gpsData;&#xA;char charGPS[82] = &quot;&quot;;&#xA;String strnmeaProto;&#xA;String strutcTime;&#xA;String strgpsStatus;&#xA;String strlatitude;&#xA;String strnsIndicator;&#xA;String strlongitude;&#xA;String strewIndicator;&#xA;String strspeedOverGnd;&#xA;String strcourseOverGnd;&#xA;String strutcDate;&#xA;String strmagVarDegrees;&#xA;String strmagVarDirection;&#xA;String strmodeIndicator;&#xA;String strcheckSum;&#xA;char nmeaProto[6] = &quot;&quot;;&#xA;char utcTime[11] = &quot;&quot;;&#xA;char gpsStatus[2] = &quot;&quot;;&#xA;char latitude[11] = &quot;&quot;;&#xA;char nsIndicator[2] = &quot;&quot;;&#xA;char longitude[11] = &quot;&quot;;&#xA;char ewIndicator[2] = &quot;&quot;;&#xA;char speedOverGnd[6] = &quot;&quot;;&#xA;char courseOverGnd[6] = &quot;&quot;;&#xA;char utcDate[7] = &quot;&quot;;&#xA;char magVarDegrees[6] = &quot;&quot;;&#xA;char magVarDirection[2] = &quot;&quot;;&#xA;char modeIndicator[2] = &quot;&quot;;&#xA;char checkSum[3] = &quot;&quot;;&#xA;char tempTime[9] = &quot;&quot;;&#xA;char tempDate[9] = &quot;&quot;;&#xA;char tempLat[12] = &quot;&quot;;&#xA;char tempLong[13] = &quot;&quot;;&#xA;// RF Module&#xA;RFZuluArduino rf(15, 14, 2, 3, 4, 5, 4800);  // Defines the RF module's pins (rx1, tx1, RTS, CTS, RST, PD, baudRate)&#xA;//Data Logger&#xA;const int chipsSelect = 10;&#xA;File Data;&#xA;String Header = &quot;DATE(utc)  TIME(utc)  STATUS  MODE  LATITUDE(deg)  LONGITUDE(deg)  SPEED(km)  COURSE(deg)  Temperature(C)  Temperature(F)  Humidity(%RH)  Heat Index(F)  Pressure(kPA)  Altitude(m&quot;; //CPM  uSV/hr&quot;;&#xA;int dcounter = 0;&#xA;//Geiger Counter&#xA;unsigned int gcount = 0;&#xA;unsigned int countStartTime = 0;&#xA;int countsPerMinute;&#xA;float coefficientOfConversion = 140.0 / 60000.0;&#xA;float sV = 0;&#xA;String str;  // temporary string&#xA;int draw_state = 0;&#xA;int tracker = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(53, OUTPUT);&#xA;  dht.begin();&#xA;  if (!SD.begin(10, 11, 12, 13)) {&#xA;    // see if the card is present and can be initialized:&#xA;    u8g.firstPage();&#xA;    do {&#xA;      drawCardError();&#xA;    }&#xA;    while (u8g.nextPage());&#xA;    while (1);  // don't do anything more:&#xA;  }&#xA;  Serial1.begin(9600);&#xA;  // start serial port for geiger counter&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(1000);&#xA;  //----- Get Sensor Data -----//&#xA;  // Temp/Humid&#xA;  h = dht.readHumidity();&#xA;  t = dht.readTemperature();&#xA;  f = dht.readTemperature(true);&#xA;  /*if (isnan(h) || isnan(t) || isnan(f)) {  // check for failed reading from sensor&#xA;    return;&#xA;    }*/&#xA;  hi = dht.computeHeatIndex(f, h);&#xA;  // Pressure Sensor&#xA;  press_pKa = PressSens.calculatePressurekPa();&#xA;  alt_ft = PressSens.calculateAltitudeFt(press_pKa);&#xA;  // GPS&#xA;  gpsData = gps.getData();&#xA;  strnmeaProto = gps.dataFields(0);&#xA;  strutcTime = gps.dataFields(1);&#xA;  strgpsStatus = gps.dataFields(2);&#xA;  strlatitude = gps.dataFields(3);&#xA;  strnsIndicator = gps.dataFields(4);&#xA;  strlongitude = gps.dataFields(5);&#xA;  strewIndicator = gps.dataFields(6);&#xA;  strspeedOverGnd = gps.dataFields(7);&#xA;  strcourseOverGnd = gps.dataFields(8);&#xA;  strutcDate = gps.dataFields(9);&#xA;  strmagVarDegrees = gps.dataFields(10);&#xA;  strmagVarDirection = gps.dataFields(11);&#xA;  strmodeIndicator = gps.dataFields(12);&#xA;  strcheckSum = gps.dataFields(13);&#xA;&#xA;  //----- Convert to Transmit -----//&#xA;  // Temp/Humid&#xA;  floatToString(rh, h, 1);  // relative humidity&#xA;  floatToString(tempC, t, 1);  // temperature in C&#xA;  floatToString(tempF, f, 1);  // temp in F&#xA;  floatToString(heatIndex, hi, 1);  // heat index&#xA;  // Pressure Sensor&#xA;  str = String(FT_TO_M(alt_ft));  // convert altitude in ft to m&#xA;  str.toCharArray(charAlt, 5);  // covert string to char array&#xA;  floatToString(charPress, press_pKa, 2);&#xA;  // GPS Module&#xA;  gpsData.toCharArray(charGPS, 80);  // convert string to char array&#xA;  strnmeaProto.toCharArray(nmeaProto, 6);&#xA;  // time&#xA;  strutcTime.toCharArray(utcTime, 11);&#xA;  tempTime[0] = utcTime[0];&#xA;  tempTime[1] = utcTime[1];&#xA;  tempTime[2] = ':';&#xA;  tempTime[3] = utcTime[2];&#xA;  tempTime[4] = utcTime[3];&#xA;  tempTime[5] = ':';&#xA;  tempTime[6] = utcTime[4];&#xA;  tempTime[7] = utcTime[5];&#xA;  strgpsStatus.toCharArray(gpsStatus, 2);&#xA;  // latitude&#xA;  strlatitude.toCharArray(latitude, 11);&#xA;  strnsIndicator.toCharArray(nsIndicator, 2);&#xA;  tempLat[0] = latitude[0];&#xA;  tempLat[1] = latitude[1];&#xA;  tempLat[2] = 176;   // °&#xA;  tempLat[3] = latitude[2];&#xA;  tempLat[4] = latitude[3];&#xA;  tempLat[5] = latitude[4];&#xA;  tempLat[6] = latitude[5];&#xA;  tempLat[7] = latitude[6];&#xA;  tempLat[8] = 39;  // '&#xA;  tempLat[9] = ' ';&#xA;  tempLat[10] = nsIndicator[0];&#xA;  // longitude&#xA;  strlongitude.toCharArray(longitude, 11);&#xA;  strewIndicator.toCharArray(ewIndicator, 2);&#xA;  tempLong[0] = longitude[0];&#xA;  tempLong[1] = longitude[1];&#xA;  tempLong[2] = longitude[2];&#xA;  tempLong[3] = 176;   // °&#xA;  tempLong[4] = longitude[3];&#xA;  tempLong[5] = longitude[4];&#xA;  tempLong[6] = longitude[5];&#xA;  tempLong[7] = longitude[6];&#xA;  tempLong[8] = longitude[7];&#xA;  tempLong[9] = 39;  // '&#xA;  tempLong[10] = ' ';&#xA;  tempLong[11] = ewIndicator[0];&#xA;  strspeedOverGnd.toCharArray(speedOverGnd, 6);&#xA;  strcourseOverGnd.toCharArray(courseOverGnd, 6);&#xA;  // date&#xA;  strutcDate.toCharArray(utcDate, 7);&#xA;  tempDate[0] = utcDate[0];&#xA;  tempDate[1] = utcDate[1];&#xA;  tempDate[2] = '/';&#xA;  tempDate[3] = utcDate[2];&#xA;  tempDate[4] = utcDate[3];&#xA;  tempDate[5] = '/';&#xA;  tempDate[6] = utcDate[4];&#xA;  tempDate[7] = utcDate[5];&#xA;  strmagVarDegrees.toCharArray(magVarDegrees, 6);&#xA;  strmagVarDirection.toCharArray(magVarDirection, 2);&#xA;  strmodeIndicator.toCharArray(modeIndicator, 2);&#xA;  strcheckSum.toCharArray(checkSum, 3);&#xA;  // transmit the data&#xA;  rf.transmit(gpsData, tempC, rh, charPress);&#xA;  //-----Writes Data to SD Card-----//&#xA;  Data = SD.open(&quot;DATA&quot;, FILE_WRITE);&#xA;  if (!Data) {&#xA;    u8g.firstPage();&#xA;    do {&#xA;      drawFileError();&#xA;    }&#xA;    while (u8g.nextPage());&#xA;    while (1);  // don't do anything more:&#xA;  }&#xA;  dcounter++;&#xA;  if (dcounter == 1) {&#xA;    Data.println(Header);&#xA;  }&#xA;  Data.print(strutcDate + &quot;     &quot; + strutcTime + &quot;   &quot; + strgpsStatus + &quot;      &quot; + strmodeIndicator + &quot;     &quot; + strlatitude + &quot;     &quot; + strlongitude + &quot;     &quot; + strspeedOverGnd + &quot;        &quot; + strcourseOverGnd + &quot;          &quot;);&#xA;  Data.print(t);&#xA;  Data.print(&quot;          &quot;);&#xA;  Data.print(f);&#xA;  Data.print(&quot;            &quot;);&#xA;  Data.print(h);&#xA;  Data.print(&quot;         &quot;);&#xA;  Data.print(hi);&#xA;  Data.print(&quot;            &quot;);&#xA;  Data.print(press_pKa);&#xA;  Data.print(&quot;         &quot; + str + &quot;  &quot;);&#xA;  Data.flush();&#xA;  Data.print(countsPerMinute);&#xA;  Data.print(&quot;  &quot;);&#xA;  Data.println(sV, 5);&#xA;  Data.flush();&#xA;  //----- Output to LCD Display -----//&#xA;  u8g.firstPage();&#xA;  do {&#xA;    draw();&#xA;  }&#xA;  while (u8g.nextPage());&#xA;  tracker++;&#xA;  if (tracker &amp;lt;= 2) {&#xA;    draw_state = 0;&#xA;  } else if (tracker &amp;lt;= 5) {&#xA;    draw_state = 1;&#xA;  } else if (tracker &amp;lt;= 8) {&#xA;    draw_state = 2;&#xA;  } else {&#xA;    tracker = 3;&#xA;  }&#xA;}&#xA;&#xA;//----- LCD Display Drawings -----//&#xA;void drawCardError() {&#xA;  u8g.setColorIndex(1);&#xA;  u8g.setFont(u8g_font_baby);&#xA;  u8g.drawStr(12, 32, &quot;Card Failed, or not present&quot;);&#xA;}&#xA;&#xA;void drawFileError() {&#xA;  u8g.setColorIndex(1);&#xA;  u8g.setFont(u8g_font_baby);&#xA;  u8g.drawStr(5, 32, &quot;Error opening DATA&quot;);&#xA;}&#xA;&#xA;void draw(void) {&#xA;  LCDprepare();&#xA;  switch (draw_state) {&#xA;    case 0:&#xA;      AECLlogo();&#xA;      break;&#xA;    case 1:&#xA;      SensorInfo();&#xA;      break;&#xA;    case 2:&#xA;      GpsInfo();&#xA;      break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3912" LastEditorUserId="4628" LastEditDate="2017-01-18T04:45:44.773" LastActivityDate="2017-08-16T13:03:04.853" Title="SD card fails to write every 5 or 6 minutes" Tags="|arduino-mega|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4421" PostTypeId="2" ParentId="4245" CreationDate="2014-10-01T16:56:43.463" Score="-1" Body="&lt;p&gt;First, get a Lightblue Bean, &lt;a href=&quot;http://punchthrough.com/bean/&quot; rel=&quot;nofollow&quot;&gt;http://punchthrough.com/bean/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has everything you need:&#xA;- arduino&#xA;- bluetooth&#xA;- API&#xA;- code example&#xA;- android sdk&#xA;- ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Develop your product using this platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to scale and build your own platform, then you will have a foundation to validate your work.&lt;/p&gt;&#xA;" OwnerUserId="4202" LastActivityDate="2014-10-01T16:56:43.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4422" PostTypeId="2" ParentId="4407" CreationDate="2014-10-01T17:23:53.300" Score="3" Body="&lt;p&gt;A discussion of bit-fields wouldn't be complete without mentioning that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Structures with bit-fields may be used as a portable way of attempting to reduce the storage required for a structure (with the probable cost of increasing the instruction space, and time, needed to access the fields), or as a non-portable way to describe a storage layout known at the bit level.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;[Kernighan &amp;amp; Ritchie, &lt;em&gt;The C Programming Language, Second Edition&lt;/em&gt;, Appendix A-8.3]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other posters, including yourself, have addressed the space/time tradeoff. But what is sometimes missed (possibly not relevant to your application - ?) is the complete &lt;em&gt;implementation-dependence of the storage layout&lt;/em&gt;. This matters when applications share this data with another process: Reading or writing hardware, whose register bit-assignments are necessarily fixed; communicating the data to another system (via network or storage device doesn't matter); or to another application on the same system, that may have been compiled with a different compiler or version of the compiler.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-10-01T17:23:53.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4423" PostTypeId="1" CreationDate="2014-10-01T20:14:05.633" Score="2" ViewCount="1933" Body="&lt;p&gt;I am currently using an Adafruit motor shield on my arduino uno for the first time.&#xA;The idea is turning the stepper motor with basicly 1RPM. But i just cant do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the first time working with this setup, and i dont know what to do.&#xA;Can you people help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i'm using the Arduino Uno with ADAFRUIT motorshield. The steppermotor is 48steps / rev&#xA;&lt;a href=&quot;http://robocraft.ru/files/datasheet/28BYJ-48.pdf&quot; rel=&quot;nofollow&quot;&gt;DATASHEET&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code i have at the moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AFMotor.h&amp;gt;&#xA;&#xA;AF_Stepper motor(48, 1);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  motor.setSpeed(1);&#xA;&#xA;  motor.step(48, FORWARD, DOUBLE);&#xA;  motor.release();&#xA;  delay(10);&#xA;}&#xA;&#xA;void loop () {&#xA;  motor.step(48, FORWARD, DOUBLE);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Greetings from Holland.&lt;/p&gt;&#xA;" OwnerUserId="4218" LastEditorUserId="10794" LastEditDate="2016-01-30T05:34:50.377" LastActivityDate="2016-01-30T05:34:50.377" Title="Stepper motor clock" Tags="|c++|motor|hardware|stepper|" AnswerCount="2" CommentCount="5" ClosedDate="2016-01-30T05:33:52.037" ContentLicense="CC BY-SA 3.0" />
  <row Id="4425" PostTypeId="2" ParentId="4423" CreationDate="2014-10-02T10:00:34.353" Score="0" Body="&lt;p&gt;If the stepper gives you 48 steps and an hour has 60, you need to provide 1,25 rounds in one hour given you only move the minute hand. Then with some gearing you should be able to move the hour hand every round there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best way to do this is to is either to move the hand once and then delay 1 minute, 1 minute = 60 seconds &lt;strong&gt;x&lt;/strong&gt; 1000 milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then need to figure out what it requires of the stepper motor to make 1 step, with some stepper motors you need to move forward 1 cycle and then back a half. to make a step. You should find all this in the documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please provide feedback in the comments below so we can improve the answer.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-10-02T10:00:34.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4426" PostTypeId="1" CreationDate="2014-10-02T11:25:01.397" Score="0" ViewCount="3521" Body="&lt;p&gt;I have a problem to combine both code for Arduino GSM Shield and Adafruit Ultime GPS Shield. I already change my code to the basic one like examples. I think i found the problem. The problem is when i want to do get request to the url/web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is the link to the Adafruit Ultimate GPS Shield.&lt;/strong&gt;&#xA;&lt;a href=&quot;https://github.com/adafruit/Adafruit-GPS-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit Library&lt;/a&gt;&#xA;&lt;a href=&quot;https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit Ultimate GPS Shield Info&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code base on example of Arduino GSM Library (GSM Web Client) and Adafruit GPS Library (Parsing)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is the code that make my code not working. If i put the code i do not receive any data at serial.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DhQqd.png&quot; alt=&quot;Blank Data at serial&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // if you get a connection, report back via serial:&#xA; if (client.connect(server, port))&#xA; {&#xA;    Serial.println(&quot;connected&quot;);&#xA;   // Make a HTTP request:&#xA;   client.print(&quot;GET &quot;);&#xA;   client.print(path);&#xA;   client.println(&quot; HTTP/1.1&quot;);&#xA;   client.print(&quot;Host: &quot;);&#xA;   client.println(server);&#xA;   client.println(&quot;Connection: close&quot;);&#xA;   client.println();&#xA; } &#xA; else&#xA; {&#xA;  // if you didn't get a connection to the server:&#xA;  Serial.println(&quot;connection failed&quot;);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is the basic code that working so far&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ngvU7.png&quot; alt=&quot;Working Code&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ********************************************&#xA;//   GPS Library&#xA;// ********************************************&#xA;#include &amp;lt;Adafruit_GPS.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;&#xA;// ********************************************&#xA;//   GSM Library&#xA;// ********************************************&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;&#xA;// ********************************************&#xA;//   Sim Card Pin Number if available&#xA;// ********************************************&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;&#xA;// ********************************************&#xA;//   Set Up APN data for GPRS Connection&#xA;// ********************************************&#xA;#define GPRS_APN       &quot;Maxis&quot; // replace your GPRS APN&#xA;#define GPRS_LOGIN     &quot;maxis&quot;    // replace with your GPRS login&#xA;#define GPRS_PASSWORD  &quot;wap&quot; // replace with your GPRS password&#xA;&#xA;&#xA;// ********************************************&#xA;//   Initialize GSM Library&#xA;// ********************************************&#xA;GSMClient client;&#xA;GPRS gprs;&#xA;GSM gsmAccess; &#xA;&#xA;// ********************************************&#xA;//   Setup Arduino to browse URL/web through GPRS&#xA;//   The code below will setup path like:&#xA;//   http://arella.com.my/urltomysql.php?firstname=Muhammad&amp;amp;lastname=Faiz&#xA;//   When Arduino browse the web, it will submit firstname:Muhammad&#xA;//   and lastname:Faiz into database. I want to store GPS data into database       later&#xA;// ********************************************&#xA;char server[] = &quot;arella.com.my&quot;;&#xA;char path[] = &quot;/urltomysql.php?firstname=Muhammad&amp;amp;lastname=Faiz&quot;;&#xA;int port = 80; // port 80 is the default for HTTP&#xA;&#xA;&#xA;// ********************************************&#xA;//  Set Adafruit GPS to use software serial on pin &#xA;//  D9 &amp;amp; D10 on Arduino. Use Jumper Wire from D7,D8 to D9,D10&#xA;// ********************************************&#xA;SoftwareSerial mySerial(10, 9);&#xA;Adafruit_GPS GPS(&amp;amp;mySerial);&#xA;&#xA;&#xA;// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console&#xA;// Set to 'true' if you want to debug and listen to the raw GPS sentences. &#xA;#define GPSECHO  false&#xA;&#xA;// this keeps track of whether we're using the interrupt&#xA;// off by default!&#xA;boolean usingInterrupt = false;&#xA;void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy&#xA;&#xA;&#xA;//***********************************************&#xA;// convert NMEA GPS Format to Google Map Format&#xA;//***********************************************&#xA;int degLatInt, degLongInt;&#xA;float minLatFloat, minLongFloat, googleMapsLat, googleMapsLong;&#xA;char* lat_str = new char[10];&#xA;char* long_str = new char[10];&#xA;char degLatString[5], degLongString[5];&#xA;&#xA;&#xA;void setup()  &#xA;{ &#xA;   Serial.begin(115200);&#xA;   gsmAccess.begin(PINNUMBER);&#xA;   gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);&#xA;&#xA;   boolean notConnected = true;&#xA;   while(notConnected)&#xA;   {&#xA;      if((gsmAccess.begin(PINNUMBER)==GSM_READY) &amp;amp;&#xA;         (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))&#xA;         notConnected = false;&#xA;      else&#xA;      {&#xA;         Serial.println(&quot;Not connected&quot;);&#xA;         delay(1000);&#xA;      }&#xA;   }&#xA;   // If i enable the code below, my code not working.&#xA;   /* if (client.connect(server, port))&#xA;      {&#xA;      Serial.println(&quot;connected&quot;);&#xA;      // Make a HTTP request:&#xA;      client.print(&quot;GET &quot;);&#xA;      client.print(path);&#xA;      client.println(&quot; HTTP/1.1&quot;);&#xA;      client.print(&quot;Host: &quot;);&#xA;      client.println(server);&#xA;      client.println(&quot;Connection: close&quot;);&#xA;      client.println();&#xA;  } */&#xA;&#xA;&#xA; //***********************************************&#xA; // Setup Adafruit GPS Shield&#xA; //***********************************************&#xA; // connect at 115200 so we can read the GPS fast enough and echo without  dropping chars&#xA; // also spit it out&#xA;&#xA; Serial.println(&quot;Adafruit GPS library basic test!&quot;);&#xA;&#xA; // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800&#xA; GPS.begin(9600);&#xA;&#xA; // uncomment this line to turn on RMC (recommended minimum) and GGA (fix     data) including altitude&#xA; GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);&#xA; // uncomment this line to turn on only the &quot;minimum recommended&quot; data&#xA; //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);&#xA; // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since&#xA; // the parser doesn't care about other sentences at this time&#xA;&#xA; // Set the update rate&#xA; GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate&#xA; // For the parsing code to work nicely and have time to sort thru the data, and&#xA; // print it out we don't suggest using anything higher than 1 Hz&#xA;&#xA; // Request updates on antenna status, comment out to keep quiet&#xA; GPS.sendCommand(PGCMD_ANTENNA);&#xA;&#xA; // the nice thing about this code is you can have a timer0 interrupt go off&#xA; // every 1 millisecond, and read data from the GPS for you. that makes the&#xA; // loop code a heck of a lot easier!&#xA; useInterrupt(true);&#xA;&#xA;   delay(1000);&#xA;}&#xA;&#xA;// Interrupt is called once a millisecond, looks for any new GPS data, and stores it&#xA;SIGNAL(TIMER0_COMPA_vect) {&#xA;   char c = GPS.read();&#xA;   // if you want to debug, this is a good time to do it!&#xA;   #ifdef UDR0&#xA;   if (GPSECHO)&#xA;   if (c) UDR0 = c;  &#xA;   // writing direct to UDR0 is much much faster than Serial.print &#xA;   // but only one character can be written at a time. &#xA;   #endif&#xA;}&#xA;&#xA;void useInterrupt(boolean v) {&#xA;   if (v) &#xA;   {&#xA;      // Timer0 is already used for millis() - we'll just interrupt somewhere&#xA;      // in the middle and call the &quot;Compare A&quot; function above&#xA;      OCR0A = 0xAF;&#xA;      TIMSK0 |= _BV(OCIE0A);&#xA;      usingInterrupt = true;&#xA;   } else &#xA;   {&#xA;      // do not call the interrupt function COMPA anymore&#xA;      TIMSK0 &amp;amp;= ~_BV(OCIE0A);&#xA;      usingInterrupt = false;&#xA;   }&#xA;}&#xA;&#xA;uint32_t timer = millis();&#xA;&#xA;void loop()                     // run over and over again&#xA;{&#xA;   // if a sentence is received, we can check the checksum, parse it...&#xA;   if (GPS.newNMEAreceived()) {&#xA;   // a tricky thing here is if we print the NMEA sentence, or data&#xA;   // we end up not listening and catching other sentences! &#xA;   // so be very wary if using OUTPUT_ALLDATA and trytng to print out data&#xA;   //Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived()  flag to false&#xA;&#xA;   if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag  to false&#xA;      return;  // we can fail to parse a sentence in which case we should just wait for another&#xA;   }&#xA;&#xA;   // if millis() or timer wraps around, we'll just reset it&#xA;   if (timer &amp;gt; millis())  timer = millis();&#xA;   // approximately every 2 seconds or so, print out the current stats&#xA;   if (millis() - timer &amp;gt; 5000) { &#xA;      timer = millis(); // reset the timer&#xA;&#xA;      Serial.print(&quot;\nTime: &quot;);&#xA;      Serial.print(GPS.hour+8, DEC); Serial.print(':');&#xA;      Serial.print(GPS.minute, DEC); Serial.print(':');&#xA;      Serial.print(GPS.seconds, DEC); Serial.print('.');&#xA;      Serial.println(GPS.milliseconds);&#xA;      Serial.print(&quot;Date: &quot;);&#xA;      Serial.print(GPS.day, DEC); Serial.print('/');&#xA;      Serial.print(GPS.month, DEC); Serial.print(&quot;/20&quot;);&#xA;      Serial.println(GPS.year, DEC);&#xA;      Serial.print(&quot;Fix: &quot;); Serial.print((int)GPS.fix);&#xA;      Serial.print(&quot; quality: &quot;); Serial.println((int)GPS.fixquality); &#xA;      if (GPS.fix) {  &#xA;         /////////// Latitude /////////////&#xA;         // Convert NMEA Latitude to String&#xA;         dtostrf(GPS.latitude, 7, 4, lat_str); //convert GPS.latitude from float to String. 7 - means 8 characters long ; 4 - means 4 decimal point &#xA;&#xA;         // Get Degree substring from latitude String&#xA;        strncpy(degLatString, lat_str, 1); // Get Degree from Full Latitude String. Example 311.7799 - Get 3&#xA;&#xA;        // Get Minutes substring from latitude String&#xA;        char* minLatString = lat_str + 1; // Move pointer up 1 position. Example 311.7799 will move to 11.7799&#xA;&#xA;        // Convert Deg String to int&#xA;        degLatInt = atoi(degLatString);&#xA;&#xA;        // COnvert Min String to float&#xA;        minLatFloat = atof(minLatString);&#xA;&#xA;        //Convert NMEA latitude to Google Maps latitude&#xA;        googleMapsLat = degLatInt + (minLatFloat / 60); &#xA;        Serial.print(&quot;Google Map Latitude: &quot;);&#xA;        Serial.println(googleMapsLat, 4);&#xA;&#xA;        //////////// Longitude /////////////&#xA;        // Convert NMEA Longitude to String&#xA;        dtostrf(GPS.longitude, 8, 4, long_str); //convert GPS.latitude from float to String. 8 - means 9 characters long ; 4 - means 4 decimal point &#xA;&#xA;        // Get Degree substring from latitude String&#xA;        strncpy(degLongString, long_str, 3); // Get Degree from Full Latitude String. Example 10141.91699 - Get 141&#xA;&#xA;        // Get Minutes substring from latitude String&#xA;        char* minLongString = long_str + 3; // Move pointer up 3 position. Example 10141.9169 will move to 41.7799&#xA;&#xA;        // Convert Deg String to int&#xA;        degLongInt = atoi(degLongString);&#xA;&#xA;        // COnvert Min String to float&#xA;        minLongFloat = atof(minLongString);&#xA;&#xA;        //Convert NMEA latitude to Google Maps latitude&#xA;        googleMapsLong = degLongInt + (minLongFloat / 60); &#xA;        Serial.print(&quot;Google Map Longitude: &quot;);&#xA;        Serial.println(googleMapsLong, 4);&#xA;&#xA;        Serial.print(&quot;Speed (KM): &quot;); Serial.println(GPS.speed * 1.85);&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4222" LastEditorUserId="6452" LastEditDate="2015-03-25T17:54:45.967" LastActivityDate="2017-03-17T11:02:17.977" Title="Combine Code Arduino GSM Shield and Adafruit GPS Shield" Tags="|arduino-uno|shields|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4427" PostTypeId="1" AcceptedAnswerId="4432" CreationDate="2014-10-02T16:03:08.193" Score="0" ViewCount="384" Body="&lt;p&gt;Is the &lt;a href=&quot;http://store.atmel.com/PartDetail.aspx?q=p:10500070;c:100114#tc:description&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmel STK500&lt;/a&gt; worth using as a AVR programmer and Dev board? I am starting to get to into AVR programming with Atmel studio. I plan on purchasing the &lt;a href=&quot;http://store.atmel.com/PartDetail.aspx?q=p:10500053;c:100112#tc:description&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVRDragon&lt;/a&gt; and also looking into purchasing the Atmel STK500. This might be too broad of a question, but are their any benefits in using the Atmel STK500?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Atmel STK500&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/blQAZ.jpg&quot; alt=&quot;Atmel STK500&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-10-03T00:31:10.393" Title="Atmel STK500 and Atmel Studio" Tags="|avr|programmer|atmel-studio|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4428" PostTypeId="2" ParentId="4314" CreationDate="2014-10-02T17:04:08.580" Score="0" Body="&lt;p&gt;From experience my recommendation would be to use Arduino nanos and NRF24L01 modules, using this library: &lt;a href=&quot;http://tmrh20.github.io/RF24/&quot; rel=&quot;nofollow&quot;&gt;http://tmrh20.github.io/RF24/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use nanos for monitoring and one for acting as host. I presume you are comfortable writing a vb.net app or similar for reading the host serial data via usb?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite simply, your six monitors will await signals addressed to them. Depending on that signal, they can either transmit their current data, or change turbine settings, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With clever coding you can avoid multiple arduinos attempting to transmit simultaneously, and avoid any interference issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck, drop me a line for more info if needed. Using nano clones and pack of NRF24L01 modules for &amp;lt; $10 you'll be able to set this experiment up very cheaply - aside from the turbines!&lt;/p&gt;&#xA;" OwnerUserId="4228" LastActivityDate="2014-10-02T17:04:08.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4429" PostTypeId="1" CreationDate="2014-09-10T14:06:35.953" Score="0" ViewCount="865" Body="&lt;p&gt;I'm having some trouble getting this arduino code to compile. It's not my project, but it should compile totally fine. Having never worked with the Arduino before, these errors are a bit intimidating, but I'll try to be specific enough for someone to get a guess. So...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this directory with these files: &lt;img src=&quot;https://i.stack.imgur.com/qmhbv.png&quot; alt=&quot;here&quot;&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that the ArduCAM_OSD.ino has the loop and setup functions. When I try to compile the ino and solution I get these errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from ArduCam_Max7456.cpp:4:&#xA;&#xA;ArduCam_Max7456.h:78: error: expected class-name before '{' token&#xA;&#xA;ArduCam_Max7456.h:84: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:84: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:87: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:91: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:91: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:98: error: 'size_t' does not name a type&#xA;&#xA;ArduCam_Max7456.h:99: error: 'uint8_t' has not been declared&#xA;&#xA;ArduCam_Max7456.h:100: error: 'BetterStream' has not been declared&#xA;&#xA;ArduCam_Max7456.h:102: error: 'uint8_t' does not name a type&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'void OSD::init()':&#xA;&#xA;ArduCam_Max7456.cpp:38: error: 'video_mode' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'void OSD::setMode(int)':&#xA;&#xA;ArduCam_Max7456.cpp:109: error: 'video_mode' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp:110: error: 'video_center' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'int OSD::getMode()':&#xA;&#xA;ArduCam_Max7456.cpp:123: error: 'video_mode' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'int OSD::getCenter()':&#xA;&#xA;ArduCam_Max7456.cpp:138: error: 'video_center' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: At global scope:&#xA;&#xA;ArduCam_Max7456.cpp:162: error: prototype for 'void OSD::setPanel(uint8_t, uint8_t)' does &#xA;not match any in class 'OSD'&#xA;&#xA;ArduCam_Max7456.h:84: error: candidate is: void OSD::setPanel(int, int)&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'void OSD::openPanel()':&#xA;&#xA;ArduCam_Max7456.cpp:177: error: 'row' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp:177: error: 'col' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: In member function 'void OSD::closePanel()':&#xA;&#xA;ArduCam_Max7456.cpp:206: error: 'row' was not declared in this scope&#xA;&#xA;ArduCam_Max7456.cpp: At global scope:&#xA;&#xA;ArduCam_Max7456.cpp:212: error: prototype for 'void OSD::openSingle(uint8_t, uint8_t)' does &#xA;not match any in class 'OSD'&#xA;&#xA;ArduCam_Max7456.h:91: error: candidate is: void OSD::openSingle(int, int)&#xA;&#xA;&#xA;ArduCam_Max7456.cpp:236: error: no 'size_t OSD::write(uint8_t)' member function declared in &#xA;class 'OSD'&#xA;&#xA;ArduCam_Max7456.cpp:251: error: prototype for 'void OSD::control(uint8_t)' does not match &#xA;any in class 'OSD'&#xA;&#xA;ArduCam_Max7456.h:87: error: candidate is: void OSD::control(int)&#xA;&#xA;ArduCam_Max7456.cpp:268: error: prototype for 'void OSD::write_NVM(int, uint8_t*)' does not &#xA;match any in class 'OSD'&#xA;&#xA;ArduCam_Max7456.h:99: error: candidate is: void OSD::write_NVM(int, int*)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The most notable of these is the first error. Here's the class, in a header file, throwing the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class OSD: public BetterStream&#xA;{&#xA;  public:&#xA;    OSD(void);&#xA;    void init(void);&#xA;    void clear(void);&#xA;    void plug(void);&#xA;    void setPanel(uint8_t start_col, uint8_t start_row);&#xA;    void openPanel(void);&#xA;    void closePanel(void);&#xA;    void control(uint8_t ctrl);&#xA;    void detectMode(void);&#xA;    void setMode(int mode);&#xA;    void setBrightness();&#xA;    void openSingle(uint8_t x, uint8_t y);&#xA;    int getMode(void);&#xA;    int getCenter(void);&#xA;    virtual int     available(void);&#xA;    virtual int     read(void);&#xA;    virtual int     peek(void);&#xA;    virtual void    flush(void);&#xA;    virtual size_t write(uint8_t c);&#xA;    void write_NVM(int font_count, uint8_t *character_bitmap);&#xA;    using BetterStream::write;&#xA;  private:&#xA;    uint8_t start_col, start_row, col, row, video_mode, video_center;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, since I know confidently that this should compile, I'm convinced that I've made some &#xA;small syntactical error that can be fixed easily. In case anyone needs to see more of the files, you can access them all on the google code page &lt;a href=&quot;http://arducam-osd.googlecode.com/svn/trunk/ArduCAM_OSD/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Alternatively, please feel free to ask any questions.&lt;/p&gt;&#xA;" OwnerDisplayName="coderRed" LastActivityDate="2014-12-05T20:22:02.477" Title="Newbie has difficulty compiling unedited svn Arduino code that should work" Tags="|c++|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="4430" PostTypeId="1" AcceptedAnswerId="4438" CreationDate="2014-10-02T21:23:09.157" Score="0" ViewCount="4171" Body="&lt;p&gt;I just have a question regarding Arduino output-pins and Voltage divider, because I am getting other results than what my calculations are giving me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have measured the output-pin (from the Arduino) at 4.74V, according to my caulculations I will have and output voltage of 3.39V, with R1 = 4k ohm and R2 = 10k ohm, but when I use my multimeter to measure I read a voltage of 0.97V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested with a 9V battery, measured to 8.72V. With the same resistors, the calculations gives me 6.23V as output, when I use my multimeter I can read a output of 6.21 which I consider as ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, why is my output from the Arduino only 0.97V with the voltage divider?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For information: I am using Arduino OSEPP Uno R3 Plus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can give me helpfull information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;***************************************update********************************************&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int echoPin = 7;&#xA;int trigPin = 6;&#xA;&#xA;int SignalPin = 10;&#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(trigPin, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  float distanceCentimeters;&#xA;  int pulseLenMicroseconds;&#xA;&#xA;  digitalWrite(trigPin, LOW);&#xA;  delayMicroseconds(20);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(100);&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  pulseLenMicroseconds = pulseIn(echoPin, HIGH);&#xA;&#xA;  distanceCentimeters = pulseLenMicroseconds / 29.387 / 2;&#xA;&#xA;  if(distanceCentimeters &amp;lt;= 35 &amp;amp;&amp;amp; distanceCentimeters &amp;gt;= 10){&#xA;&#xA;      digitalWrite(SignalPin, HIGH);&#xA;&#xA;  } else {&#xA;&#xA;      digitalWrite(SignalPin, LOW);&#xA;&#xA;  }&#xA;&#xA;  delay(400);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Image of the setup (not with Raspberry Pi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0HDVY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4229" LastEditorUserId="4229" LastEditDate="2014-10-03T12:14:38.407" LastActivityDate="2014-10-03T15:07:22.563" Title="Arduino output pin from 5V to 3.3V" Tags="|arduino-uno|electricity|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4431" PostTypeId="2" ParentId="2878" CreationDate="2014-10-03T00:06:55.707" Score="0" Body="&lt;p&gt;Its is possible and very easy to do. See the HID Project and the Hoodloader:&#xA;&lt;a href=&quot;https://github.com/NicoHood/HID&quot; rel=&quot;nofollow&quot;&gt;https://github.com/NicoHood/HID&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/NicoHood/Hoodloader&quot; rel=&quot;nofollow&quot;&gt;https://github.com/NicoHood/Hoodloader&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user3486" LastActivityDate="2014-10-03T00:06:55.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4432" PostTypeId="2" ParentId="4427" CreationDate="2014-10-03T00:31:10.393" Score="2" Body="&lt;p&gt;Benefits of STK500? Sure:&lt;br&gt;&#xA;- It has push buttons&lt;br&gt;&#xA;- It has LEDs&lt;br&gt;&#xA;- It has easy accessible connectors to any controller pin&lt;br&gt;&#xA;&lt;br&gt;&#xA;Actually that's all. If you want/need to make use of this, buy both. Use the STK for &quot;rapid prototyping&quot; and the Dragon for debugging.&lt;br&gt;&#xA;But if your budget allows it, have a look at the STK600 instead of 500. It's more expensive, but not so &quot;old-fashioned&quot;, and it has much more features.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-10-03T00:31:10.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4433" PostTypeId="1" CreationDate="2014-10-03T05:53:56.453" Score="0" ViewCount="3865" Body="&lt;p&gt;Can anyone help me with the code-ing to allow the robot to stop at a certain distance when the robot is approaching the tracked object. I am trying to implement it as a colour tracking wheel chair. For Example, the motorized wheelchair is able to track the colour of the shirt of the person infront is wearing and follow the person, and at the same time it is able to leave a distance between the person infront and the wheelchair to prevent collision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the pixy robot : &lt;a href=&quot;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code :&lt;a href=&quot;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/the-code&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/pixy-pet-robot-color-vision-follower-using-pixycam/the-code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently the code is only able to track the object till it reaches the object. But my objective is to let it chase the object, but at the same time, leaving a 1 metre distance&#xA;away from the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me. Thank you&lt;/p&gt;&#xA;" OwnerUserId="4009" LastActivityDate="2017-04-01T07:56:15.377" Title="Pixy(CMUcam5) robot Distance code" Tags="|programming|arduino-leonardo|robotics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4434" PostTypeId="1" CreationDate="2014-10-03T08:57:43.690" Score="1" ViewCount="558" Body="&lt;p&gt;I'm trying to get my Arduino GSM shield working with the example &quot;Send SMS&quot; code provided. However, when I upload and compile the program, the serial monitor displays &quot;SMS Messages Sender&quot; and nothing else occurs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would greatly appreciate it if someone can tell me where I could have gone wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : I'm currently using the Arduino Mega. The shield I'm using is the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino GSM Shield&lt;/a&gt;. I'm following the guide provided by the Arduino's website with the code part of the example that comes with the Arduino program, see &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoGSMShield#toc9&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sending a SMS message&lt;/a&gt;. Attached is what is shown on the monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using both a USB cable and an external power supply. I have performed the jumper wire modification required for the Mega to work with the shield as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/euw7D.png&quot; alt=&quot;Console output&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3210" LastEditorUserId="6936" LastEditDate="2016-01-02T20:41:59.943" LastActivityDate="2016-07-02T23:35:00.267" Title="Arduino GSM Shield not responding?" Tags="|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4435" PostTypeId="1" CreationDate="2014-10-03T09:33:29.643" Score="3" ViewCount="2807" Body="&lt;p&gt;I am trying to connect gsm module with my arduino uno. confused about the use of isp and icsp&lt;/p&gt;&#xA;" OwnerDisplayName="user4236" LastActivityDate="2014-10-03T16:03:33.153" Title="What is the use of ISP and ICSP in Arduino?" Tags="|arduino-uno|programming|uploading|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4436" PostTypeId="1" CreationDate="2014-10-03T11:31:51.753" Score="2" ViewCount="2287" Body="&lt;p&gt;I am trying to send color() data from Processing to Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code from Processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial myPort;&#xA;&#xA;void setup(){&#xA;  myPort = new Serial(this, Serial.list()[7], 9600);&#xA;}&#xA;&#xA;&#xA;void draw(){&#xA;  color[] c1 = {color(99,0,0),color(255,0,0) };&#xA;  for (int i = 0; i &amp;lt; c1.length; i++ ){&#xA;    int value = int(red(c1[0]));&#xA;    myPort.write(value);&#xA;    println(value);&#xA;    delay(2000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It sends the 99.0 data to Arduino. Here is the Arduino code for getting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  while(Serial.available() &amp;gt; 0){&#xA;    int recieved = Serial.read();    &#xA;      Serial.print(recieved);&#xA;    }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is when Arduino receive data it doesn't take one by one. When i watch Arduino serial monitor, the data comes at different chunks like, 9...99...999..9.. etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to send several color info from Processing into arduino, it might be a long array of value. What is the best way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="3080" OwnerDisplayName="orionlogic" LastActivityDate="2014-10-09T12:36:44.890" Title="Send Processing color data into Arduino" Tags="|serial|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4437" PostTypeId="2" ParentId="4436" CreationDate="2014-10-03T12:30:34.407" Score="5" Body="&lt;p&gt;The 'best' solution depends on many things, your skill, the performance of the system, and the other tasks it needs to do in the available time. There are some examples of doing data transfer between Processing and the Arduino in the Arduino example programs. So it is worth looking through them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seems to be some inconsistencies in your question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You wrote &quot;It sends the 99.0 data to Arduino&quot;, which has a decimal point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet the code is printing an &lt;code&gt;int&lt;/code&gt; i.e. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int value = int(red(c1[0]));&#xA;myPort.write(value); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, the processing code only looks at the red component of c1[0]: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int value = int(red(c1[0])); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so it can only send a sequence of '9'. So that looks like a bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few basic strategies to write data that can be easily read. Two popular ways are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;send fixed length messages, or prefix a message with the size of the&#xA;data, and have a fixed format of data. For example, use a one byte&#xA;count to say how many colours are being sent, then send three bytes,&#xA;in the same order, for each colour&lt;/li&gt;&#xA;&lt;li&gt;use non-data bytes to separate the data. For example use a ','&#xA;between R, G or B and '\n' to mark the end of the data. To keep&#xA;things simple, never use those values as data values. That is pretty&#xA;much how programming languages work. It is much more complex to read&#xA;than fixed format data, but can give more flexibility.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Data is often sent as printable characters (e.g. 173 would be three bytes havig the ASCII values '1', '7', '3'). If it is fixed format, it would always be three bytes. For your purposes, I'd probably send each data byte as two hex characters (ASCII '0' to '9' and 'A' to 'F'. This is slightly more complex than pure binary. However it is fixed format, and more importantly it is easier to test by hand using the Arduino serial monitor, you can just type stuff and it is relatively easy to do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pure binary data is much more difficult to fully test, and often relies on a piece of software which also needs testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary: There are a couple of ways, it is hard to say which is best. For simplicity try to make it simple by being fixed format.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastEditorUserId="3493" LastEditDate="2014-10-03T13:11:08.300" LastActivityDate="2014-10-03T13:11:08.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4438" PostTypeId="2" ParentId="4430" CreationDate="2014-10-03T14:52:18.963" Score="2" Body="&lt;p&gt;Your code does not configured SignalPin as an output, but only trigPin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As already explained in comments, your observed voltage is due not really to the voltage divider you constructed, but rather one formed by the &quot;weak&quot; internal pull-up resistance and your external resistors.  From your measurement, it appears the value of the weak internal pull-up is about 35K, which is within the range of expectations.  That and your 4K external form the top of the divider (39K) while your 10K forms the lower half, yielding about a fifth of the supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;some&lt;/em&gt; versions of the Arduino library, writing to an input pin enables and disables the internal pull-up resistor, so you could have observed your program seeming to control the pin - but at minimal drive strength.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the desired behavior, you merely need to add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(SignalPin, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-10-03T15:07:22.563" LastActivityDate="2014-10-03T15:07:22.563" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4439" PostTypeId="2" ParentId="4435" CreationDate="2014-10-03T15:03:22.927" Score="6" Body="&lt;p&gt;ISP/ICSP has no role when utilizing a typical, properly functioning Arduino, as the program code compiled from sketches is instead downloaded via a bootloader (either serial, often behind an on-board USB-serial converter, or else directly USB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The role of ISP in the Arduino ecosystem is mostly limited to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Loading a bootloader into new chips which do not have one, or have somehow lost theirs (note however that you can buy pre-loaded ATmega328's from many sources at a small premium)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As an alternative program loading scheme when the tiny amount of program memory used by the bootloader must be re-claimed for a particularly large sketch&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Programing alternate targets to which the Arduino libraries have been partially ported, especially resource-constrained ones where the bootloader takes up a larger fraction of the total memory, such as the the ATtiny25/45/85&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Replacing or modifying the firmware of an on-board USB-serial micro such as the 16u2 on an Uno to perform a different function, such as emulate a keyboard or mouse.  However, this chip can also be programmed over its USB interface in DFU mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Programming other non-Arduino devices used in a project (though these often have a different ISP scheme than the ATmega series).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But a typical project using purchased board(s) will involve none of these.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;SPI vs. ISP&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As jfpoilpret points out, a very popular way of interfacing chips to a microcontroller is the Serial Peripheral Inteface, or SPI.  Like ISP, this is a synchronous (has a distinct clock line) serial interface with a master and a slave, a mode or enable pin, and a distinct data line in each direction.  Some Arduinos use MCUs like the ATmega328p which re-use their SPI pins for ISP (with the reset functioning as the mode pin).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In effect, ISP is a sort of special &quot;SPI-like&quot; interface mode for programming an ATmega - often using the master-mode SPI engine of the programer to do the actual transfers.  But &quot;ISP&quot; applies only when programming an ATmega - the more generic case of communicating with a peripheral would be &quot;SPI&quot;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's my impression that most GSM modules use asynchronous serial interfaces (ie, utilizing a UART engine), but there may be some which use SPI or other synchronous schemes, at least as an option.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2014-10-03T16:03:33.153" LastActivityDate="2014-10-03T16:03:33.153" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4442" PostTypeId="1" CreationDate="2014-10-03T18:51:51.347" Score="1" ViewCount="1519" Body="&lt;p&gt;I want to use a servo motor and control it by an Arduino Duemilanove (or a Leonardo). It seems to work fine when I connect it directly to Arduino's VCC, GND and an PWM pin. But I am a bit worried if this is a good idea. The multimeter shows that it draws up to 0.6A which is about 10 times of what I'd expect that the Arduino can provide. Is this correct or does this apply only to the digital out pins? Would it be better to power the servo using an external power supply?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it would be a nice and easy solution to power the Arduino using a USB power supply and to cut the USB cable and connect the servo directly to the +5V of the USB. But is there even a difference in powering the Arduino via USB and connecting the servo to the VCC of the Arduino? Is it a problem to connect GND and UGND?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(After first tests, I think that the Arduino led is pulsating less using the hacked USB cable, but still a pulsating LED shows that the servo is drawing a lot of power from the board.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus question: does your answer apply to all Arduino models? (I am interested especially in Leonardo and Duemilanove.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar discussion:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,22132.0.html&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,22132.0.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4240" LastActivityDate="2014-10-04T00:07:02.463" Title="Power servo with external power using a hacked USB cable" Tags="|power|servo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4444" PostTypeId="1" AcceptedAnswerId="8454" CreationDate="2014-10-04T00:02:06.760" Score="2" ViewCount="105" Body="&lt;p&gt;My Arduino mini is experiencing some really strange problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the BlinkWithoutDelay example sketch for testing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =  13;&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;void setup() {&#xA;    pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW)&#xA;        ledState = HIGH;&#xA;    else&#xA;        ledState = LOW;&#xA;&#xA;   // set the LED with the ledState of the variable:&#xA;   digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The program basically turns pin 13 on and off every 1000ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I uploaded this sketch into the mini (via Arduino Uno board, sans Atmega chip), the scope reading of pin 13 shows nice square waves (1s pulsewidth, 2s period), as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then unplug the USB cable powering the mini through the Uno board, wait for a few seconds for the scope traces to settle (I only have an old analog one at hand), and then plug it back in to turn on the board. However, the pin output is different - I now get a train of three pulses (60ms wide, 60ms between pulses) at sporadic intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uploading the sketch then yields the desired square waves again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going on here? I'm fairly sure the mini has nonvolatile memory and it's intact (otherwise the bootloader through which I upload the sketch would not work).&lt;/p&gt;&#xA;" OwnerUserId="4243" LastActivityDate="2015-02-05T21:24:31.557" Title="Arduino mini requires uploading on every power up?" Tags="|bootloader|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4446" PostTypeId="1" CreationDate="2014-10-04T01:07:38.937" Score="1" ViewCount="388" Body="&lt;p&gt;I have built a twitter bot with my Arduino and an Ethernet shield&#xA;right now, the way to make it tweet something is to manually add a phase into the code and upload it to the board for each new tweet, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to create a simple way of scrolling through a queue of phrases and tweeting each consecutive one after a given amount of time (several hours).&#xA;the issue I'm seeing is that, the code needs to rerun for each tweet, and I can't figure out what needs to be in what loop. Also the entire thing needs to delay for 3.6e^6(1 hour) milliseconds (the code takes delays in milliseconds) so that I don't spam the feed, &#xA;the twitter for this project is @ether_bot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;Twitter.h&amp;gt;&#xA;&#xA;/*&#xA;void speech()&#xA;{&#xA;  //this is where i would put the que of tweets&#xA;}&#xA;*/&#xA;&#xA;// the next three lines connect the ethernet shield to the local network and establish a link with the twitter account&#xA;byte ip[] = { 192,168,1,104 }; &#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEU }; //address for the shield&#xA;Twitter twitter(&quot;2790106893-5ljE7WPyyGe16SqTMEm8CN5gpwDquhGnyjH2TCM&quot;); &#xA;char msg[] = &quot;hello again, im getting some major work done soon!&quot;; // message to tweet&#xA;&#xA;void setup()&#xA;{&#xA;  delay(30000);&#xA;  Ethernet.begin(mac, ip);  // makes the connection &#xA;  Serial.begin(9600); //opens a serial interface similar to the prnt window in bluejay&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;connecting ...&quot;);&#xA;&#xA;  if (twitter.post(msg)) &#xA;  {&#xA;    int status = twitter.wait();&#xA;&#xA;    if (status == 200)&#xA;    { &#xA;      Serial.println(&quot;OK.&quot;);&#xA;    }&#xA;    else&#xA;    {&#xA;      Serial.print(&quot;failed : code &quot;);  //stuff happens here idk &#xA;      Serial.println(status);&#xA;    }&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;connection failed.&quot;);&#xA;  }&#xA;&#xA;  do {} while(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4244" LastEditorUserId="4279" LastEditDate="2014-10-06T23:55:14.997" LastActivityDate="2014-10-06T23:55:14.997" Title="I want to be able to upload a batch of tweets to a twitter bot to be qued' for tweeting" Tags="|arduino-uno|programming|c++|ethernet|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4447" PostTypeId="1" AcceptedAnswerId="4470" CreationDate="2014-10-04T03:53:10.493" Score="7" ViewCount="16188" Body="&lt;p&gt;I have an arduino project that will work while plugged into a generic outlet. But I want to connect a battery in case the power goes out. I know there are various power sources (&lt;a href=&quot;https://www.sparkfun.com/products/337&quot; rel=&quot;noreferrer&quot;&gt;coin cell&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/products/8483&quot; rel=&quot;noreferrer&quot;&gt;polymer lithium&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/products/10512&quot; rel=&quot;noreferrer&quot;&gt;9V&lt;/a&gt;, etc.). But if I code my project to use the backup power if the main power goes down, would that mean the backup always has to be running? How would I go about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help! Every time you help me you save a kitten!!&lt;/p&gt;&#xA;" OwnerUserId="4245" LastActivityDate="2023-08-18T17:20:56.283" Title="Can I have backup power for an Arduino device?" Tags="|power|battery|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4448" PostTypeId="2" ParentId="4446" CreationDate="2014-10-04T04:24:15.627" Score="1" Body="&lt;p&gt;First create an array of all the messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NUM_MESSAGES 3&#xA;const char *msg[NUM_MESSAGES] = { &#xA;    &quot;This is the first message&quot;, &#xA;    &quot;This is the second&quot;,&#xA;    &quot;Third time lucky&quot; };&#xA;int msg_num = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in the loop, switch between messages and add a delay&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  Serial.println(&quot;connecting ...&quot;);&#xA;  if (twitter.post(*msg[msg_num])) &#xA;  {&#xA;    int status = twitter.wait();&#xA;    if (status == 200)&#xA;    { &#xA;      Serial.println(&quot;OK.&quot;);&#xA;    }&#xA;    else&#xA;    {&#xA;      Serial.print(&quot;failed : code &quot;);  //stuff happens here idk &#xA;      Serial.println(status);&#xA;    }&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;connection failed.&quot;);&#xA;  }&#xA;&#xA;  //Next message&#xA;  msg_num++;&#xA;  if (msg_num &amp;gt;= NUM_MESSAGES) msg_num = 0;&#xA;  delay(1000*60*60);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-04T04:24:15.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4449" PostTypeId="1" AcceptedAnswerId="4454" CreationDate="2014-10-04T07:04:05.480" Score="5" ViewCount="899" Body="&lt;p&gt;I am building my Arduino project with a makefile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BOARD_TAG = uno&#xA;ARDUINO_PORT = /dev/ttyACM0&#xA;USER_LIB_PATH = /home/prakhar/dev/alfred/arduino/libraries&#xA;CPPFLAGS=-x c++ -std=c++11 -Wall -DUNIX_ENVIRONMENT -DHAVE_NAMESPACES -DHAVE_STD&#xA;include /usr/share/arduino/Arduino.mk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I keep getting this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cc1plus: error: unrecognized command line option &quot;-std=c++11&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I googled and &lt;a href=&quot;https://stackoverflow.com/questions/14674597/cc1plus-error-unrecognized-command-line-option-std-c11-with-g&quot;&gt;this&lt;/a&gt; says that I need to update g++/gcc. I already have the newset versions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prakhar@sim74stic ~ $ avr-g++ --version&#xA;avr-g++ (GCC) 4.9.1&#xA;Copyright (C) 2014 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&#xA;prakhar@sim74stic ~ $ avr-gcc --version&#xA;avr-gcc (GCC) 4.9.1&#xA;Copyright (C) 2014 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&#xA;prakhar@sim74stic ~ $ g++ --version&#xA;g++ (GCC) 4.9.1 20140903 (prerelease)&#xA;Copyright (C) 2014 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I installed &lt;code&gt;arduino&lt;/code&gt; from the &lt;code&gt;AUR&lt;/code&gt; (packages &lt;code&gt;aur/arduino 1:1.0.6-1&lt;/code&gt; and &lt;code&gt;aur/arduino-mk 1.3.4-2&lt;/code&gt;).&#xA;Can anybody point out what I'm doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="297" LastEditDate="2015-07-31T03:57:13.990" LastActivityDate="2015-07-31T03:57:13.990" Title="Cannot compile C++11 code via Makefile" Tags="|arduino-uno|c++|avr|compile|build|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4450" PostTypeId="1" AcceptedAnswerId="4452" CreationDate="2014-10-04T14:38:04.250" Score="0" ViewCount="249" Body="&lt;p&gt;I'm using a sketch that helps to reset Da Vinci XYZPrinter cartridge EEPROMs, and it's based on the NanodeUNIO library. It uses digital pin 7 for data. I want to use my TFT Touch Shield to set the extruder temperature, but the shield also makes use for digital pin 7. Being that the sheild is wired to use pin 7, it can't be changed. But any pin that can be used as a digital pin should be useable with NanodeUNIO (at least, that is my assumption), but I can't find where in NanodeUNIO it sets the data pin. Where is that pin set, and how can it be changed?&lt;/p&gt;&#xA;" OwnerUserId="3928" LastActivityDate="2014-10-04T15:23:39.243" Title="Setting data pin with NanodeUNIO" Tags="|eeprom|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4451" PostTypeId="1" AcceptedAnswerId="4455" CreationDate="2014-10-04T15:00:37.667" Score="10" ViewCount="44844" Body="&lt;p&gt;I have been trying to count pulses from a 12,500&amp;nbsp;Hz square wave to trigger an output. Here's the code I have so far. When the Arduino is reset it prints 315 to the serial over a 25&amp;nbsp;ms sample. 315 x 40 = 12600. Which seems to me it's working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My only problem is it only returns this number once upon reset of the board. Now if I move that same code down into &lt;code&gt;void loop&lt;/code&gt;, it counts consecutively giving me inconstant returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not understanding what I need to put in the loop section so I can repeatedly and accurately count how many toggles of the input pin I am getting over a period of time so I can do something to the output based off the presence of the 12,500 Hz signal or not.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;volatile int IRQcount;&#xA;int pin = 2;&#xA;int pin_irq = 0; //IRQ that matches to pin 2&#xA;&#xA;void setup() {&#xA;   // Put your setup code here, to run once:&#xA;  Serial.begin (9600);&#xA;  attachInterrupt(pin_irq, IRQcounter, RISING);&#xA;  delay(25);&#xA;  detachInterrupt(pin);&#xA;  Serial.print(F(&quot;Counted = &quot;));&#xA;  Serial.println(IRQcount);&#xA;}&#xA;&#xA;void IRQcounter() {&#xA;  IRQcount++;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Put your main code here, to run repeatedly:&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the above code, every time I press the reset button I get one line in the serial window.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Counted = 441&#xA;Counted = 442&#xA;Counted = 441&#xA;Counted = 441&#xA;Counted = 441&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to get the same result, but repeating over and over. That way if the signal drops out I can trigger an output to turn off (LOW). When the signal is present the output will go high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempt was to move the attach interrupt down into &lt;code&gt;void loop&lt;/code&gt;, so it would repeat. Here's what it looks like.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;volatile int IRQcount;&#xA;int pin = 2;&#xA;int pin_irq = 0; //IRQ that matches to pin 2&#xA;&#xA;void setup() {&#xA;  // Put your setup code here, to run once:&#xA;  Serial.begin (9600);&#xA;}&#xA;&#xA;void IRQcounter() {&#xA;   IRQcount++;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Put your main code here, to run repeatedly:&#xA;&#xA;  attachInterrupt(pin_irq, IRQcounter, RISING);&#xA;  delay(25);&#xA;  detachInterrupt(pin);&#xA;  Serial.print(F(&quot;Counted = &quot;));&#xA;  Serial.println(IRQcount);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The return I get is self-updating, but the &quot;count&quot; instead of starting from 0 each time starts from the previous count. So it gets larger and larger. I am looking to return a constant value that represents my 12500&amp;nbsp;Hz signal so that, and only that, will trigger my output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Counted = 442&#xA;Counted = 886&#xA;Counted = 1330&#xA;Counted = 177&#xA;Counted = 2221&#xA;Counted = 2667&#xA;Counted = 3112&#xA;Counted = 3557&#xA;Counted = 4002&#xA;Counted = 4448&#xA;Counted = 4893&#xA;Counted = 5338&#xA;Counted = 5784&#xA;Counted = 6229&#xA;Counted = 6674&#xA;Counted = 7120&#xA;Counted = 7565&#xA;Counted = 8010&#xA;Counted = 8456&#xA;Counted = 8901&#xA;Counted = 9347&#xA;Counted = 9792&#xA;Counted = 10237&#xA;Counted = 10683&#xA;Counted = 11130&#xA;Counted = 11576&#xA;Counted = 12022&#xA;Counted = 12469&#xA;Counted = 12915&#xA;Counted = 13361&#xA;Counted = 13808&#xA;Counted = 14254&#xA;Counted = 14700&#xA;Counted = 15147&#xA;Counted = 15593&#xA;Counted = 16040&#xA;Counted = 16486&#xA;Counted = 16932&#xA;Counted = 17378&#xA;Counted = 17825&#xA;Counted = 18271&#xA;Counted = 18717&#xA;Counted = 19164&#xA;Counted = 19610&#xA;Counted = 20056&#xA;Counted = 20503&#xA;Counted = 20949&#xA;Counted = 21395&#xA;Counted = 21842&#xA;Counted = 22288&#xA;Counted = 22735&#xA;Counted = 23169&#xA;Counted = 23616&#xA;Counted = 24062&#xA;Counted = 24508&#xA;Counted = 24955&#xA;Counted = 25401&#xA;Counted = 25730&#xA;Counted = 25756&#xA;Counted = 26200&#xA;Counted = 26646&#xA;Counted = 27093&#xA;Counted = 27539&#xA;Counted = 27985&#xA;Counted = 28432&#xA;Counted = 28878&#xA;Counted = 29324&#xA;Counted = 29770&#xA;Counted = 30217&#xA;Counted = 30663&#xA;Counted = 31110&#xA;Counted = 31556&#xA;Counted = 32002&#xA;Counted = 32449&#xA;Counted = -32641&#xA;Counted = -32195&#xA;Counted = -31748&#xA;Counted = -31302&#xA;Counted = -30855&#xA;Counted = -30408&#xA;Counted = -29962&#xA;Counted = -29515&#xA;Counted = -29069&#xA;Counted = -28622&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4250" LastEditorUserId="41448" LastEditDate="2019-11-27T15:38:13.477" LastActivityDate="2019-11-27T15:38:13.477" Title="Counting pulses with interrupt" Tags="|interrupt|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4452" PostTypeId="2" ParentId="4450" CreationDate="2014-10-04T15:23:39.243" Score="2" Body="&lt;p&gt;&lt;code&gt;xyz_dv_eprom.ino&lt;/code&gt; uses low-level access rather than Arduino calls to manipulate PD7, most likely for speed reasons. Lines 96 through 104 (specifically 96, 97, 100, and 104) need to be modified in order to change both the port and the bit used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow&quot;&gt;ATmegaXX8 pin mapping&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping2560&quot; rel=&quot;nofollow&quot;&gt;ATmegaXXX0 pin mapping&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping32u4&quot; rel=&quot;nofollow&quot;&gt;ATmegaXXU4 pin mapping&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-04T15:23:39.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4453" PostTypeId="1" CreationDate="2014-10-04T15:27:28.657" Score="0" ViewCount="2108" Body="&lt;p&gt;I have posted this on the Arduino forum also, but I give it more chance if posted here also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying to use my Arduino Mega as an ISP for programming two different ATMEGA328P's and a ATINY2313, but I just don't succeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running the Arduino IDE (version 1.5.8 ) on windows 7. I've been using these &lt;a href=&quot;http://www.instructables.com/id/How-to-use-Arduino-Mega-2560-as-Arduino-isp/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-to-use-Arduino-Mega-2560-as-Arduino-isp/&lt;/a&gt; &lt;a href=&quot;http://www.instructables.com/id/Arduino-ATtiny2313-Programming-Shield/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-ATtiny2313-Programming-Shield/&lt;/a&gt; instructables for help. The circuit are built on a breadboard. On my Arduino Mega is use the pins reset: 53, MOSI: 51, MISO: 50, SCK: 52.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I upload the arduino as ISP sketch on my Mega. There are LEDs on the programming, error and heartbeat outputs, the heardbeat is pounding. I then select the according board from the boards list (the ATINY2313 1MHz from the instructable for the ATTINY and either the Arduino UNO or the Arduino Duelimanove for the ATMEGA328P) and after that the programmer árduino as ISP'. When uploading the Blink sketch I get errors like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: Yikes! Invalid device signature&#xA;avrdude: stk500_getsync(): not in sync: resp=0x00&#xA;avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51&#xA;I have tried things like capacitors/resistors between the reset and the ground or between the reset and the +5V, but nothing different. I have searched for help on the internet and alot of people have problems with it, but no clear or working answers. I have been looking at the MegaISP guide form Arduino, but this is not very clear to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea where to start anymore. Does anybody have an idea what I can try or where to start searching for answers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appriciate all the help I can get!&lt;/p&gt;&#xA;" OwnerUserId="4251" LastActivityDate="2016-02-07T05:18:46.850" Title="Arduino Mega 2560 as ISP for ATTINY2313 / ATMEGA328P" Tags="|arduino-mega|attiny|atmega328|avr|isp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4454" PostTypeId="2" ParentId="4449" CreationDate="2014-10-04T16:01:11.820" Score="6" Body="&lt;p&gt;As I turns out, the &lt;code&gt;avr-gcc (GCC) 4.9.1&lt;/code&gt; goodies weren't being used at all! The arduino package was using a decrepit version of gcc,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;prakhar@sim74stic ~ $ /usr/share/arduino/hardware/tools/avr/bin/avr-g++ --version&#xA;avr-g++ (GCC) 4.3.2&#xA;Copyright (C) 2008 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&#xA;prakhar@sim74stic ~ $ /usr/share/arduino/hardware/tools/avr/bin/avr-gcc --version&#xA;avr-gcc (GCC) 4.3.2&#xA;Copyright (C) 2008 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;All I had to do was specify&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AVR_TOOLS_DIR = /usr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to exexute with &lt;code&gt;-std=c++11&lt;/code&gt; flag (I also had to add an &lt;code&gt;-fpermissive&lt;/code&gt; flag to compile &lt;code&gt;C&lt;/code&gt; with &lt;code&gt;g++&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="297" LastEditDate="2014-10-05T11:29:40.467" LastActivityDate="2014-10-05T11:29:40.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4455" PostTypeId="2" ParentId="4451" CreationDate="2014-10-04T16:03:12.280" Score="9" Body="&lt;p&gt;You need to reset IRQCount back to &lt;code&gt;0&lt;/code&gt; before attaching the interrupt again. Otherwise it will just continue counting from where it stopped last time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would actually keep the interrupt attached and just reset the variable just before the delay. That way the overhead of attach/detachinterrupt doesn't get added to the 25ms delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int IRQcount;&#xA;int pin = 2;&#xA;int pin_irq = 0; //IRQ that matches to pin 2&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin (9600);&#xA;  attachInterrupt(pin_irq, IRQcounter, RISING);&#xA;}&#xA;&#xA;void IRQcounter() {&#xA;  IRQcount++;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  IRQcount = 0;&#xA;  delay(25);&#xA;  int result = IRQcount;&#xA;  Serial.print(F(&quot;Counted = &quot;));&#xA;  Serial.println(result);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since an int is 2 bytes an interrupt might occur in the middle of setting/reading those two bytes. This might result in an occasional wrong value. To prevent that you should disable interrupt while setting/reading the value&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int IRQcount;&#xA;int pin = 2;&#xA;int pin_irq = 0; //IRQ that matches to pin 2&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin (9600);&#xA;  attachInterrupt(pin_irq, IRQcounter, RISING);&#xA;}&#xA;&#xA;void IRQcounter() {&#xA;  IRQcount++;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  cli();//disable interrupts&#xA;  IRQcount = 0;&#xA;  sei();//enable interrupts&#xA;&#xA;  delay(25);&#xA;&#xA;  cli();//disable interrupts&#xA;  int result = IRQcount;&#xA;  sei();//enable interrupts&#xA;&#xA;  Serial.print(F(&quot;Counted = &quot;));&#xA;  Serial.println(result);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-04T16:03:12.280" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4456" PostTypeId="1" AcceptedAnswerId="4461" CreationDate="2014-10-04T16:34:42.080" Score="7" ViewCount="7831" Body="&lt;p&gt;Are all Arduino shields compatible with all Arduino boards? Like is the Wi-Fi one compatible with the Arduino Nano &amp;amp; Micro as well as the Uno, etc., or do I need to be careful when buying shields that they'll be compatible with my board? Also, the shields just plug into the boards, don't they?&lt;/p&gt;&#xA;" OwnerUserId="4253" LastEditorUserId="6936" LastEditDate="2015-08-05T14:55:13.550" LastActivityDate="2015-08-05T14:55:13.550" Title="Are all Arduino shields compatible with all Arduino boards?" Tags="|shields|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4457" PostTypeId="2" ParentId="4456" CreationDate="2014-10-04T16:52:51.437" Score="1" Body="&lt;p&gt;For the most part, all the shields are compatible with all the boards that have a matching shield footprint. For example, the Uno, Leonardo, and the front half of the mega all have their header pins laid out in the standard arduino shield shape. If your board has this shield footprint, then all you have to do is plug the shield in on top and upload the right code to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nano and micro have a different size and shape than a standard arduino, and so shields will not have a handy way of attaching to them. Since they do have standard arduino chips on them, they are technically compatible, but you would have to make your own wiring to attach them.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-10-04T16:52:51.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4458" PostTypeId="1" CreationDate="2014-10-04T18:26:16.630" Score="61" ViewCount="264853" Body="&lt;p&gt;I believe I can supply the Arduino with power in three different ways: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use USB. The design trusts the 5V to be regulated, and does not regulate it in any way. &lt;/li&gt;&#xA;&lt;li&gt;Use a regulated power source, trusted to be 5V, and connect it to GND and 5V. &lt;/li&gt;&#xA;&lt;li&gt;Connect an unregulated power source, eg a battery, to GND and VIN. This should be above 6.2V (since the dropout voltage is 1.2V) and preferably between 9V and 12V. There is a built-in regulator that will supply the Arduino with exactly 5V. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But can I use any of those pins to power other components. E.g. if the Arduino is powered with USB, can I use the 5V pin to power a diode? I thought I could, but the voltage is 4.70V, while the USB is 5.07V. The VIN is 4.26V btw. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the 5V and VIN only for powering the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2023-09-01T17:28:30.867" Title="What are the 5V and VIN pins for?" Tags="|voltage-level|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4459" PostTypeId="2" ParentId="4458" CreationDate="2014-10-04T19:06:51.320" Score="6" Body="&lt;p&gt;They can also be used to draw power from the barrel jack (Vin) or from USB or the on-board regulator (5V). The schematic of the board shows all exact power paths.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-04T19:06:51.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4460" PostTypeId="2" ParentId="4458" CreationDate="2014-10-04T19:07:11.083" Score="37" Body="&lt;p&gt;No. You can draw power from the 5v and VIN pins on the arduino. VIN is the completely unaltered input power before the regulator (it will be useless if regulated 5v is supplied directly). Outputting power is what the 5v pin is intended to be used for, not as a power input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardUno&quot;&gt;arduino website&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5V. This pin outputs a regulated 5V from the regulator on the&#xA;  board. The board can be supplied with power either from the DC power&#xA;  jack (7 - 12V), the USB connector (5V), or the VIN pin of the board&#xA;  (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the&#xA;  regulator, and can damage your board. We don't advise it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-10-04T20:52:31.440" LastActivityDate="2014-10-04T20:52:31.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4461" PostTypeId="2" ParentId="4456" CreationDate="2014-10-04T21:01:02.923" Score="7" Body="&lt;p&gt;When you want to choose a shield for your board you should check:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- &lt;strong&gt;Pin-out&lt;/strong&gt;, this one is the least concerning one , Most arduino boards are Shield pin-out compatible and you can verify it visually, for others, normally there are some converter boards (e.g for NANO), and in the worst case, building a converter board or wiring the shield to board is trivial in most situations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- &lt;strong&gt;Shield operating voltage should match your board's&lt;/strong&gt;, most shields operate at 5V, 3.3V or both. Normally AVR-based boards (e.g. UNO, Mega, ...) operate at 5V and ARM based ones (e.g. Due, ...) operate at 3.3V, So we should choose the shield accordingly &lt;em&gt;(just keep in mind that most shield are designed with Arduino UNO in mind so it's more likely that your shields operate at 5V)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- &lt;strong&gt;Library&lt;/strong&gt;, Lots of Libraries for Arduino shields bypass Arduino library abstraction (mostly for performance reasons) and use hardware specific features (e.g directly write on specific ports), here is source of some incompatibilities between your board and the shield, for example there are handful of TFT LCD shields in the market which their library only supports UNO boards, in these cases you should either port it to your board's (based on micro-controller model and it's architecture, sometimes its as easy as changing some pin/port definitions and sometimes as hard as writing the library from scratch).&lt;/p&gt;&#xA;" OwnerUserId="4249" LastActivityDate="2014-10-04T21:01:02.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4462" PostTypeId="1" AcceptedAnswerId="4463" CreationDate="2014-10-04T23:19:54.073" Score="2" ViewCount="1756" Body="&lt;p&gt;While using NEO 6M and getting close-to-perfect accuracy, connecting the 3dr uBlox LEA 6H shows incoming characters, but gibberish data (at 38400) like it is connecting to a wrong baud rate (although it isn't, i've checked it with u-center and works when connected to Ardupilot).&#xA;So i guess it is some kind of configuration to show only certain parts of NMEA (if it is showing NMEA and not something else).&lt;/p&gt;&#xA;" OwnerUserId="4256" LastActivityDate="2017-12-23T03:42:21.490" Title="uBlox LEA 6H and UNO no data" Tags="|arduino-mega|tinygps|gps|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4463" PostTypeId="2" ParentId="4462" CreationDate="2014-10-05T01:14:23.470" Score="2" Body="&lt;p&gt;Your uBlox LEA 6H is most likly configured to use the UBX binary protocol and not NMEA at all. This protocol, as well as how to switch your LEA 6H between NMEA and UBX is in this document, from the uBlox website:&#xA;&lt;a href=&quot;http://www.u-blox.com/images/downloads/Product_Docs/u-blox6_ReceiverDescriptionProtocolSpec_%28GPS.G6-SW-10018%29.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.u-blox.com/images/downloads/Product_Docs/u-blox6_ReceiverDescriptionProtocolSpec_%28GPS.G6-SW-10018%29.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to use the code from the ArduPilotMega project to communicate in UBX, they use the UBX protocol and the code is open source, but I can't guarantee its very good quality.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-10-05T01:14:23.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4466" PostTypeId="1" CreationDate="2014-10-05T07:18:45.367" Score="1" ViewCount="3166" Body="&lt;p&gt;I have two successfully working individual programs,&#xA;&lt;strong&gt;1.GPS coordinate extract program.&lt;/strong&gt;&#xA;&lt;strong&gt;2.EEPROM saving and reading program.&lt;/strong&gt;&#xA;now all I want to do is combine them both, whenever GPS location is updated ,I want to save that latitude data to EEPROM memory repalcing the previously saved data, but I guess my program is unable to save it,its just showing blank spaces when reading EEPROM,please help me guys..here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; &#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#define RXPin 8&#xA;#define TXPin 9&#xA;#define GPSBaud 9600&#xA;#define ConsoleBaud 9600&#xA;&#xA;// The serial connection to the GPS device&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;// The TinyGPS++ object&#xA;TinyGPSPlus gps;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;int address = 0; &#xA;int read_value = 0; &#xA;char data;&#xA;void setup()&#xA;{&#xA;  Serial.begin(ConsoleBaud);&#xA;  ss.begin(GPSBaud);&#xA;  Serial.println(&quot;Previous value stored :&quot;);&#xA;  for(address = 0; address &amp;lt; 25; address ++)        // read the entire EEPROM memory&#xA;  {  &#xA;    read_value = EEPROM.read(address);&#xA;    Serial.write(read_value);&#xA;  }&#xA;  Serial.println(&quot;\n&quot;);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  while (ss.available() &amp;gt; 0)&#xA;    gps.encode(ss.read());&#xA;&#xA;  if (gps.location.isUpdated() || gps.altitude.isUpdated())&#xA;  {&#xA;    Serial.print(&quot;Location: &quot;); &#xA;    Serial.print(gps.location.lat(), 6);&#xA;    Serial.print(&quot;,&quot;);&#xA;    Serial.print(gps.location.lng(), 6);&#xA;    Serial.println(&quot;\n&quot;);&#xA;&#xA;    data=(gps.location.lat(), 6);&#xA;&#xA;    for(address = 0; address &amp;lt; 25;  )&#xA;    {&#xA;      EEPROM.write(address, data); &#xA;      address ++;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3761" LastActivityDate="2018-05-17T15:57:03.657" Title="How to store gps values in EEPROM arduino?" Tags="|arduino-uno|tinygps|eeprom|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4467" PostTypeId="2" ParentId="4466" CreationDate="2014-10-05T12:51:36.120" Score="1" Body="&lt;p&gt;You might try using &lt;code&gt;sprintf&lt;/code&gt;. First define a buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char data[25];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use &lt;code&gt;sprintf&lt;/code&gt; to print to the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(data, &quot;Location: %.3f,%.3f\n&quot;, gps.location.lat(), gps.location.lon());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%.3f&lt;/code&gt; prints a float with 3 decimal places. Check out the &lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/printf/&quot; rel=&quot;nofollow&quot;&gt;printf&lt;/a&gt; reference for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then write the buffer to EEPROM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(address = 0; address &amp;lt; 25; address++ )&#xA;{&#xA;  EEPROM.write(address, data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-10-06T00:14:14.653" LastActivityDate="2014-10-06T00:14:14.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4468" PostTypeId="2" ParentId="4466" CreationDate="2014-10-05T12:52:10.380" Score="2" Body="&lt;p&gt;Consider TinyGPS++ over TinyGPS only if you are running on Due or processor which can take advantage of the higher precision of 64-bit “double” floating-point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;char data;&lt;/code&gt; should be &lt;code&gt;double data;&lt;/code&gt;. You're wasting resources otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;data=(gps.location.lat(), 6);&lt;/code&gt; isn't how you do it. You only need to specify precision when writing to &lt;code&gt;Serial&lt;/code&gt;, like &lt;code&gt;Serial.print(gps.location.lat(), 6);&lt;/code&gt;. Make it &lt;code&gt;data = gps.location.lat();&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;address ++;&lt;/code&gt; should be &lt;code&gt;address = address &amp;lt;=512-sizeof(address) ? (address + sizeof(data)): 0 ;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;address &amp;lt;=512-sizeof(address)&lt;/code&gt; ensures that the last value written to the &lt;code&gt;EEPROM&lt;/code&gt; is written in it's entirety. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I would recommend &lt;a href=&quot;http://playground.arduino.cc/Code/EEPROMWriteAnything&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; to save you data structure directly to &lt;code&gt;EEPROM&lt;/code&gt;, and what @jfpoilpret mentions.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2014-10-05T12:52:10.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4469" PostTypeId="2" ParentId="3266" CreationDate="2014-10-05T13:00:18.837" Score="4" Body="&lt;p&gt;You can use any editor to write Arduino code. @BrettM has already detailed it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of the external editor option, you can do away with the Arduino IDE completely using &lt;code&gt;Makefile&lt;/code&gt; and build and upload your code yourself.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino IDE sucks. Ok, I admit it’s nice for beginners and for the&#xA;  click-and-forget kind of programmers, but it needs the full Java stack&#xA;  and hides to the user the fundamental steps involved in compiling and&#xA;  uploading programs to the arduino board.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I (like many other software developers) prefer to understand what I’m&#xA;  doing and running a Makefile from the command line is the way to see&#xA;  the individual steps and choose which to run and when. Finally, I’m&#xA;  not going to drop my favourite editor just to write arduino programs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.itopen.it/2012/02/12/arduino-1-0-development-with-a-makefile/&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt;'s how to do it.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2014-10-05T13:00:18.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4470" PostTypeId="2" ParentId="4447" CreationDate="2014-10-05T15:30:17.920" Score="4" Body="&lt;p&gt;You could set up a relay to work in reverse with the mains power.&lt;/p&gt;&#xA;&lt;p&gt;Have your backup battery connected to the gate contacts of the relay, and then use the mains power running your project to open the relay and keep it open as long as there is power. If the mains turns off, then the relay closes and the battery is connected.&lt;/p&gt;&#xA;&lt;p&gt;You might want to put something in line with the power to the Arduino to make sure you don't get any spikes when things switch.&lt;/p&gt;&#xA;&lt;p&gt;I hope this helps as I love kittens&lt;/p&gt;&#xA;" OwnerUserId="4244" LastEditorUserId="90731" LastEditDate="2023-08-18T17:20:56.283" LastActivityDate="2023-08-18T17:20:56.283" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="4472" PostTypeId="1" CreationDate="2014-10-05T19:21:01.207" Score="0" ViewCount="480" Body="&lt;p&gt;How can I get weight that has been measured by an Arduino device to show up on an iOS mobile or tablet device as a number? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Warmly,&#xA;N. &lt;/p&gt;&#xA;" OwnerUserId="4261" OwnerDisplayName="Natasha H" LastActivityDate="2014-10-05T21:33:42.357" Title="Communication between Arduino and iOS device" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4473" PostTypeId="2" ParentId="4472" CreationDate="2014-10-05T20:39:17.110" Score="2" Body="&lt;p&gt;There are cables that let you plug in to the 30 pin connector and get a connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a BLE shield and write code for both platforms that communicate via BLE, or a WiFi shield.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-10-05T20:39:17.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4474" PostTypeId="2" ParentId="4472" CreationDate="2014-10-05T20:46:03.573" Score="0" Body="&lt;p&gt;There are a couple apps for this application but first you need the Arduino connected to the internet. It's called Iarduino and the instructables can be found &lt;a href=&quot;http://www.instructables.com/id/Control-Arduino-Board-Wirelessly-With-iPhone-iPad/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. I don't believe that you can communicate with your ios device with blue tooth. The app should allow for serial communication but I am not an expert on serial. &lt;/p&gt;&#xA;" OwnerUserId="3693" LastEditorUserId="4172" LastEditDate="2014-10-05T21:33:42.357" LastActivityDate="2014-10-05T21:33:42.357" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4475" PostTypeId="1" AcceptedAnswerId="4476" CreationDate="2014-10-05T22:38:08.187" Score="1" ViewCount="1929" Body="&lt;p&gt;For my Arduino project I have a &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-neopixel-uberguide.pdf&quot; rel=&quot;nofollow&quot;&gt;Neopixel RGB Strip&lt;/a&gt; with 72 LED's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can successfully change the colour of any of the LED's (at the moment I'm only setting the first one 0 for testing purposes) so I know my wiring isn't the problem here, it's my coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to do is be able to select a color and then another color and have the first color fade to the next color and so forth (much like the LIFX bulbs behave when using the iPhone application).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have at the moment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am logging output of all the variables to give you an indication of what's going on. I'm not 100% sure on where I'm going wrong or whether there's a much easier way to do what I'm after (I'm open to suggestions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function takes a parameter called &lt;code&gt;command&lt;/code&gt;, which is a string separated by commas:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. &lt;code&gt;255, 0, 0&lt;/code&gt; (RED) or &lt;code&gt;0, 255, 0&lt;/code&gt; (GREEN).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*******************************************************************************&#xA; * Function Name  : tinkerSetColour&#xA; * Description    : Sets the strip with the appropriate colour&#xA; * Input          : Pin and value&#xA; * Output         : None.&#xA; * Return         : 1 on success and a negative number on failure&#xA; *******************************************************************************/&#xA;int Rstart = 0, Gstart = 0, Bstart = 0;&#xA;int Rnew = 0, Gnew = 0, Bnew = 0;&#xA;&#xA;int tinkerSetColour(String command)&#xA;{&#xA;    sprintf(rgbString, &quot;Rstart %i, Gstart %i, Bstart %i&quot;, Rstart, Gstart, Bstart);&#xA;    Spark.publish(&quot;rgb&quot;, rgbString);&#xA;&#xA;    sprintf(rgbString, &quot;Rnew %i, Gnew %i, Bnew %i&quot;, Rnew, Gnew, Bnew);&#xA;    Spark.publish(&quot;rgb&quot;, rgbString);&#xA;&#xA;    // Clear strip.&#xA;    strip.show();&#xA;&#xA;    int commaIndex = command.indexOf(',');&#xA;    int secondCommaIndex = command.indexOf(',', commaIndex+1);&#xA;    int lastCommaIndex = command.lastIndexOf(',');&#xA;&#xA;    int red = command.substring(0, commaIndex).toInt();&#xA;    int grn = command.substring(commaIndex+1, secondCommaIndex).toInt();&#xA;    int blu = command.substring(lastCommaIndex+1).toInt();&#xA;&#xA;    int Rend = red, Gend = grn, Bend = blu;&#xA;&#xA;    sprintf(rgbString, &quot;Rend %i, Gend %i, Bend %i&quot;, Rend, Gend, Bend);&#xA;    Spark.publish(&quot;rgb&quot;, rgbString);&#xA;&#xA;    // Larger values of 'n' will give a smoother/slower transition.&#xA;    int n = 200;&#xA;    for (int i = 0; i &amp;lt; n; i++)&#xA;    {&#xA;        Rnew = Rstart + (Rend - Rstart) * i / n;&#xA;        Gnew = Gstart + (Gend - Gstart) * i / n;&#xA;        Bnew = Bstart + (Bend - Bstart) * i / n;&#xA;&#xA;        // Set pixel color here.&#xA;        strip.setPixelColor(0, strip.Color(Rnew, Gnew, Bnew));&#xA;    }&#xA;&#xA;    sprintf(rgbString, &quot;Rnew %i, Gnew %i, Bnew %i&quot;, Rnew, Gnew, Bnew);&#xA;    Spark.publish(&quot;rgb&quot;, rgbString);&#xA;&#xA;    Rstart = red, Gstart = grn, Bstart = blu;&#xA;&#xA;    sprintf(rgbString, &quot;Rstart %i, Gstart %i, Bstart %i&quot;, Rstart, Gstart, Bstart);&#xA;    Spark.publish(&quot;rgb&quot;, rgbString);&#xA;&#xA;    return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is the colors are not fading between themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apologies if any of this is confusing. I can provide more information if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the &lt;strong&gt;output&lt;/strong&gt; selecting &lt;strong&gt;RED&lt;/strong&gt; to begin with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rstart 0, Gstart 0, Bstart 0&#xA;Rnew 0, Gnew 0, Bnew 0&#xA;Rend 255, Gend 0, Bend 0&#xA;Rnew 253, Gnew 0, Bnew 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the &lt;strong&gt;output&lt;/strong&gt; selecting &lt;strong&gt;GREEN&lt;/strong&gt; directly afterwards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rstart 255, Gstart 0, Bstart 0&#xA;Rnew 253, Gnew 0, Bnew 0&#xA;Rend 0, Gend 255, Bend 0&#xA;Rnew 2, Gnew 253, Bnew 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then the &lt;strong&gt;output&lt;/strong&gt; selecting &lt;strong&gt;BLUE&lt;/strong&gt; after that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rstart 0, Gstart 255, Bstart 0&#xA;Rnew 2, Gnew 253, Bnew 0&#xA;Rend 0, Gend 23, Bend 255&#xA;Rnew 0, Gnew 25, Bnew 253&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastEditorUserId="37" LastEditDate="2014-10-06T00:21:55.000" LastActivityDate="2014-10-06T01:31:08.590" Title="Arduino function to fade from one RGB color to the next" Tags="|arduino-uno|programming|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4476" PostTypeId="2" ParentId="4475" CreationDate="2014-10-06T01:31:08.590" Score="4" Body="&lt;p&gt;There is no delay in there. It will fade very quickly, add a delay e.g. 5ms with &lt;code&gt;n&lt;/code&gt; = 200 for a 1 second fade:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int n = 200;&#xA;for (int i = 0; i &amp;lt; n; i++)&#xA;{&#xA;    Rnew = Rstart + (Rend - Rstart) * i / n;&#xA;    Gnew = Gstart + (Gend - Gstart) * i / n;&#xA;    Bnew = Bstart + (Bend - Bstart) * i / n;&#xA;&#xA;    // Set pixel color here.&#xA;    strip.setPixelColor(0, strip.Color(Rnew, Gnew, Bnew));&#xA;&#xA;    delay(5);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other thing is your last value of &lt;code&gt;n&lt;/code&gt; in the loop is 199, not 200, and thus &lt;code&gt;Rnew&lt;/code&gt; etc don't have the correct final value. Change the comparison to be &lt;code&gt;&amp;lt;=&lt;/code&gt; not &lt;code&gt;&amp;lt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt;= n; i++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-06T01:31:08.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4477" PostTypeId="1" CreationDate="2014-10-06T00:23:54.147" Score="2" ViewCount="415" Body="&lt;p&gt;I'm basically wondering if it's OK to &lt;code&gt;Serial.write()&lt;/code&gt; or print in the function I register to be called when I2C data is received.  I can't seem to find the execution context or any warnings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/WireOnReceive&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/WireOnReceive&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4325" OwnerDisplayName="tarabyte" LastEditorUserId="42" LastEditDate="2015-04-10T16:25:35.593" LastActivityDate="2015-04-10T16:25:35.593" Title="What is the execution context of the function registered via the Wire.onReceive() method?" Tags="|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4478" PostTypeId="2" ParentId="4477" CreationDate="2014-10-06T02:11:19.700" Score="2" Body="&lt;p&gt;Looking at &lt;code&gt;twi.c&lt;/code&gt; in the Arduino libraries, it seems the callback function is called from within the I2C interrupt service routine (ISR). Any code in the call back will lengthen the ISR so it will have to be short. I don't think &lt;code&gt;Serial.write&lt;/code&gt; will be too much of a problem; the TX interrupt will be delayed to the end of the I2C ISR which finishes straight after the callback and the &lt;code&gt;Serial.write&lt;/code&gt; function is fairly short.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to have a longer function run, you could instead have the callback store bytes in a ring buffer, then check for any available bytes in the main &lt;code&gt;loop()&lt;/code&gt;.. but this is what the &lt;code&gt;Wire&lt;/code&gt; class helps with already.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-06T02:11:19.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4479" PostTypeId="1" CreationDate="2014-10-06T06:21:15.383" Score="0" ViewCount="1786" Body="&lt;p&gt;I'm trying to send data over serial and pick it up in a ruby script. I'm using the serialport gem (&lt;a href=&quot;https://rubygems.org/gems/serialport&quot; rel=&quot;nofollow&quot;&gt;https://rubygems.org/gems/serialport&lt;/a&gt;) as stated in the Arduino docs (&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Ruby&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Interfacing/Ruby&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, I'm trying to print out some gyroscope data, particularly the x, y, and z. This is what my arduino sketch looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  // ... do some gyro stuff here&#xA;}&#xA;&#xA;void loop() {&#xA;  gyro.read();&#xA;&#xA;  Serial.print((int)gyro.g.x);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print((int)gyro.g.y);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print((int)gyro.g.z);&#xA;&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My ruby script is pretty straight forward as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;require &quot;serialport&quot;&#xA;port_str = &quot;/dev/tty.usbmodemfa141&quot;&#xA;baud_rate = 9600&#xA;data_bits = 8&#xA;stop_bits = 1&#xA;parity = SerialPort::NONE&#xA;&#xA;sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)&#xA;while true do&#xA;  message = sp.gets&#xA;  if message&#xA;    message.chomp!&#xA;&#xA;    puts message&#xA;  end&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the output that I get is choppy. What I mean by that is that the numbers don't come out as a single line as I intend:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;52 9&#xA;5&#xA;250&#xA; -28&#xA; 85&#xA;25&#xA;9 -5&#xA;1 69&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if I replace it with &quot;Hello World&quot;, it'll come out as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;He&#xA;llo&#xA;Wor&#xA;ld&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas why? Thanks in advance for any help.&lt;/p&gt;&#xA;" OwnerUserId="4263" LastEditorUserId="4263" LastEditDate="2014-10-06T16:17:14.737" LastActivityDate="2015-01-06T23:11:30.130" Title="Ruby and Arduino over Serial" Tags="|programming|serial|gyroscope|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4480" PostTypeId="1" AcceptedAnswerId="4489" CreationDate="2014-10-06T07:56:44.453" Score="8" ViewCount="32767" Body="&lt;p&gt;Nano is from 2008, and micro from 2012. Micro seems better on every parameter, in particular in having a better (I think) microcontroller, ATMega32u4, over ATMega328P. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, all the shops I've checked out, both local and online, sell the Nano, and only some sell Micro. And Nano is always more expensive than Micro. E.g. at RS-Online 26GBP for Nano (&lt;a href=&quot;http://uk.rs-online.com/web/p/processor-microcontroller-development-kits/6961667/&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;) and 16GBP for Micro (&lt;a href=&quot;http://uk.rs-online.com/web/p/processor-microcontroller-development-kits/7717667/&quot; rel=&quot;noreferrer&quot;&gt;link&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do many shops only sell the inferior product?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the older and less capable Nano more expensive? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would anyone buy the Nano over the Micro? &lt;/p&gt;&#xA;" OwnerUserId="3267" LastEditorUserId="653" LastEditDate="2014-10-06T12:41:18.193" LastActivityDate="2014-10-08T11:04:25.060" Title="Are there any reasons to pick Nano over Micro?" Tags="|arduino-nano|arduino-micro|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4481" PostTypeId="2" ParentId="4480" CreationDate="2014-10-06T11:49:38.497" Score="2" Body="&lt;p&gt;It depends on what's your focus on. From pure microcontroller view, the 328P compared to the 32u4&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;is 4MHz faster &lt;/li&gt;&#xA;&lt;li&gt;has two Touch Channels more&lt;/li&gt;&#xA;&lt;li&gt;has picoPower technology&lt;/li&gt;&#xA;&lt;li&gt;has an RTC&lt;/li&gt;&#xA;&lt;li&gt;has a lower minimum supply voltage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If one or more of these features are essential for your project, the Nano may be the better choice. &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the price: &lt;br&gt;&#xA;I'm not sure if it can have such a high influence, but there may have been a technology shrink. That's why a modern 32bit micro is cheaper than an old-fashioned 8 or 16bit micro, at least in B2B pricing.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-10-06T11:49:38.497" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4482" PostTypeId="1" AcceptedAnswerId="4486" CreationDate="2014-10-06T15:49:35.720" Score="0" ViewCount="3780" Body="&lt;p&gt;I have a Arduino Uno with 14 digital pins. I believe they have an output of 5V.&#xA;But they can also &lt;em&gt;input&lt;/em&gt; values. I'm not sure of what exactly it reads when it does that (amperage, voltage ...). Also, &lt;em&gt;how&lt;/em&gt; do they read it? How can such a tiny thing possibly know what it's receiving?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to provide a little more context to the reading part of this question, here's an example circuit. I have a 5V battery connected to an LED and a 220 Ohm resistor. Next thing in the circuit is a wire, which exits the main circuit and connects to a digital pin on the Arduino Uno (here it reads the value). Then the main circuit closes by connecting to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope my question is clear enough :)&lt;/p&gt;&#xA;" OwnerUserId="4270" OwnerDisplayName="PenguinCake" LastEditorUserId="4270" LastEditDate="2014-10-06T16:19:30.923" LastActivityDate="2023-07-06T15:11:18.757" Title="Arduino: How does digitalRead read a value? And what is this value?" Tags="|pins|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4484" PostTypeId="2" ParentId="4482" CreationDate="2014-10-06T16:21:26.900" Score="2" Body="&lt;p&gt;&lt;strong&gt;It measures voltage&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input circuit is conceptually similar to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TUJaw.gif&quot; alt=&quot;CMOS input&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Voltages close to 5V will turn the lower transistor on and the upper one off.&lt;/li&gt;&#xA;&lt;li&gt;Voltages close to 0V will turn the upper one on and the lower one off.&lt;/li&gt;&#xA;&lt;li&gt;Voltages in the middle will turn both on to some extent, which is not recommended, and may be read as either 0 or 1 with a threshold in the middle.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&quot;Such a tiny thing&quot; contains tens or hundreds of thousands of transistors.&lt;/p&gt;&#xA;" OwnerUserId="4269" LastEditorUserId="3941" LastEditDate="2014-10-06T17:50:33.003" LastActivityDate="2014-10-06T17:50:33.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4485" PostTypeId="1" CreationDate="2014-10-06T16:28:17.573" Score="1" ViewCount="8126" Body="&lt;p&gt;I have an Arduino Due and want to save data to an SD card. For this I use a 3.2 'display of ITead with integrated SD slot (&lt;a href=&quot;http://imall.iteadstudio.com/im120419006.html&quot; rel=&quot;nofollow&quot;&gt;http://imall.iteadstudio.com/im120419006.html&lt;/a&gt;). This I connected to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Arduino doesn’t detect the SD card (I've tried two different cards and also reformatted both). I wired the three SD ports correctly to the SPI. I wired the CS output on to pin 4, 10 or 52 (each one once tested), without success. I have also tried using ICSP instead of SPI, which the Arduino website suggests. Again, without success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test program I used is a  test program on the Arduino website for SD cards (the program in the end of the post, changes marked in bold). Is the problem in the program code or is it a hardware problem? If it is a software problem, could you send me a test program that is designed for Arduino Due?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have invested several hours and read tens of forums but found nothing comparable. Also, the proposed solutions never worked. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;  SD card test &#xA;&#xA; This example shows how use the utility libraries on which the'&#xA;SD library is based in order to get info about your SD card.&#xA;Very useful for testing a card when you're not sure whether its working or not.&#xA;&#xA; The circuit:&#xA;  * SD card attached to SPI bus as follows:&#xA;** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila&#xA;** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila&#xA;** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila&#xA;** CS - depends on your SD card shield or module. &#xA;        Pin 4 used here for consistency with other Arduino examples&#xA;&#xA;&#xA; created  28 Mar 2011&#xA;by Limor Fried &#xA; modified 9 Apr 2012&#xA;by Tom Igoe&#xA;*/&#xA;// include the SD library:&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;**#include &amp;lt;SPI.h&amp;gt;**&#xA;&#xA;// set up variables using the SD utility library functions:&#xA;Sd2Card card;&#xA;SdVolume volume;&#xA;SdFile root;&#xA;&#xA;// change this to match your SD shield or module;&#xA;// Arduino Ethernet shield: pin 4&#xA;// Adafruit SD shields and modules: pin 10&#xA;// Sparkfun SD shield: pin 8&#xA;const int chipSelect = **10**;    &#xA;&#xA;void setup() {&#xA;// Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;   while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.print(&quot;\nInitializing SD card...&quot;);&#xA;  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.&#xA;  // Note that even if it's not used as the CS pin, the hardware SS pin &#xA;  // (10 on most Arduino boards, 53 on the Mega) must be left as an output &#xA;  // or the SD library functions will not work. &#xA;  pinMode(**chipSelect**, OUTPUT);     // change this to 53 on a mega&#xA;  **SPI.begin(chipSelect); //habe ich eingeführt, da es in einigen Foren erwähnt wird, funktioniert jedoch mit und ohne nicht. //I made this, becaus it’s mentioned in severals forums, but it didn’t workt wiht it and whitout it**     // change this to 53 on a mega &#xA;&#xA;  // we'll use the initialization code from the utility libraries&#xA;  // since we're just testing if the card is working!&#xA;  if (!card.init(SPI_HALF_SPEED, chipSelect)) {&#xA;    Serial.println(&quot;initialization failed. Things to check:&quot;);&#xA;    Serial.println(&quot;* is a card is inserted?&quot;);&#xA;    Serial.println(&quot;* Is your wiring correct?&quot;);&#xA;    Serial.println(&quot;* did you change the chipSelect pin to match your shield or module?&quot;);&#xA;    return;&#xA;  } else {&#xA;   Serial.println(&quot;Wiring is correct and a card is present.&quot;); &#xA;  }&#xA;&#xA;  // print the type of card&#xA;  Serial.print(&quot;\nCard type: &quot;);&#xA;  switch(card.type()) {&#xA;    case SD_CARD_TYPE_SD1:&#xA;      Serial.println(&quot;SD1&quot;);&#xA;      break;&#xA;    case SD_CARD_TYPE_SD2:&#xA;      Serial.println(&quot;SD2&quot;);&#xA;      break;&#xA;    case SD_CARD_TYPE_SDHC:&#xA;      Serial.println(&quot;SDHC&quot;);&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;Unknown&quot;);&#xA;  }&#xA;&#xA;  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32&#xA;  if (!volume.init(card)) {&#xA;    Serial.println(&quot;Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card&quot;);&#xA;    return;&#xA;  }&#xA;  // print the type and size of the first FAT-type volume&#xA;  uint32_t volumesize;&#xA;  Serial.print(&quot;\nVolume type is FAT&quot;);&#xA;  Serial.println(volume.fatType(), DEC);&#xA;  Serial.println();&#xA;&#xA;  volumesize = volume.blocksPerCluster(); // clusters are collections of blocks&#xA;  volumesize *= volume.clusterCount(); // we'll have a lot of clusters&#xA;  volumesize *= 512; // SD card blocks are always 512 bytes&#xA;  Serial.print(&quot;Volume size (bytes): &quot;);&#xA;  Serial.println(volumesize);&#xA;  Serial.print(&quot;Volume size (Kbytes): &quot;);&#xA;  volumesize /= 1024;&#xA;  Serial.println(volumesize);&#xA;  Serial.print(&quot;Volume size (Mbytes): &quot;);&#xA;  volumesize /= 1024;&#xA;  Serial.println(volumesize);&#xA;  Serial.println(&quot;\nFiles found on the card (name, date and size in bytes): &quot;);&#xA;  root.openRoot(volume);&#xA;  // list all files in the card with date and size&#xA;  root.ls(LS_R | LS_DATE | LS_SIZE);&#xA;}&#xA;&#xA;void loop(void) {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4268" LastEditorUserId="4131" LastEditDate="2016-04-05T08:40:59.243" LastActivityDate="2016-04-05T08:40:59.243" Title="Arduino Due SD Card" Tags="|arduino-due|spi|sd-card|icsp|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4486" PostTypeId="2" ParentId="4482" CreationDate="2014-10-06T17:06:03.430" Score="2" Body="&lt;p&gt;Modern digital electronics is made from many tiny electronic components called MOSFETs (a type of transistor). They can be switched on and off using a voltage, and a very small amount of current. They use the majority of the power when they are switching on and off; the rest of the time they use virtually no power. It this very low-power capability which allows us to make complex digital electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Electronically, a MOSFET looks like a tiny capacitor, which triggers a very low-power switch, on and off. Once there is charge on the MOSFETs capacitor, the switch will stay on or off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A modern large-scale processor, for example the type of device Intel makes, contains billions of MOSFETs, but requires less than 100W, and switches billions of times/second. So we can be confident that a MOSFET can be switched using much less than 1/10,000,000W. At 5V, that means 1/50,000,000A, or 0.000,000,02A, i.e. 0.02µA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the input circuit, connected to an Arduino's pin has some protection, to protect the MOSFETs from static electricity (which could damage or destroy the capacitor), then a complementary pair of MOSFETs (called N-Chanel and P-Chanel). The input voltage switches one on, and the other off. It typically requires less than a micro-amp of current, but at a voltage close to ground or 5V. See pjc50's diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So an Arduino input pin, connected to the 5V end of the resistor and LED will take a tiny amount of current, for a short time, to switch on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that pin is connected between the LED and resistor, at some voltage less than 5V, but more than 0V, then it might not switch fully. It might not give a reliable value of digital 0 or digital 1, and might switch high and low rapidly influenced by electrical noise in the environment.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2014-10-06T18:03:36.737" LastActivityDate="2014-10-06T18:03:36.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4487" PostTypeId="1" AcceptedAnswerId="4492" CreationDate="2014-10-06T18:59:57.557" Score="1" ViewCount="353" Body="&lt;p&gt;Hey folks … I was hoping some of you might cast your eye over my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It splits up a string read from EEprom into an array of separate strings. Based on String length information stored in a separate array. (tempArray[])&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It reads fine … and also seems to process fine (ie. it does turn one long string into separate array items)      for some reason it stops working no the 8th array item?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The splitting code (problem) starts on line 80 and i have included the output above it in comments.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/Ax4R6t6J&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/Ax4R6t6J&lt;/a&gt;   &amp;lt;&amp;lt; Full code also available here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void reJigFromMemory(){&#xA;&#xA;  Serial.print(&quot;Eeprom read 1 :&quot;);&#xA;  Serial.println(eepromReadOne);&#xA;  Serial.print(&quot;EEprom read 2 :&quot;);&#xA;  Serial.println(eepromReadTwo);&#xA;  String tempArray[10];&#xA;&#xA;  int charLength=eepromReadOne.length()+1;&#xA;  char charBuff[charLength];&#xA;  eepromReadOne.toCharArray(charBuff, charLength);&#xA;&#xA;  //// GET MEMORY LOCATIONS&#xA;  /*&#xA;converts long string of numbers:&#xA;   13161717171717252533&#xA;   into separate strings:&#xA;   13&#xA;   16&#xA;   17&#xA;   17&#xA;   17&#xA;   17&#xA;   17&#xA;   25&#xA;   25&#xA;   33&#xA;&#xA;   And stores them in an array.&#xA;   */&#xA;  for (int i = 0; i &amp;lt;10 ; i++){&#xA;    tempArray[i]+=charBuff[i*2];&#xA;    tempArray[i]+=charBuff[(i*2)+1];&#xA;    Serial.print(&quot;I just translated :&quot;);&#xA;    Serial.println(tempArray[i]);&#xA;  }&#xA;  /// GET THE STRINGS USING THE ABOVE ARRAYS&#xA;  /*&#xA;converts long list of data ie:&#xA;   |0|Bingo#999#|1|Retest2#9222#|2|Retest3#92299#|3|Retest4#99339#|4|Retest5#95599#|5|Retest6#96699#|6|Retest7#99119#|7|User Defined eighth#0#|8|User Defined ninth #0#|9|User Defined tenth (last) .#0#&#xA;&#xA;   into individual array strings:&#xA;&#xA;   From Number = :0&#xA;   To number : 13&#xA;   Record 0 :          |0|Bingo#999#&#xA;   From Number = :13&#xA;   To number : 29&#xA;   Record 1 :          |1|Retest2#9222#&#xA;   From Number = :29&#xA;   To number : 46&#xA;   Record 2 :          |2|Retest3#92299#&#xA;   From Number = :46&#xA;   To number : 63&#xA;   Record 3:           |3|Retest4#99339#&#xA;   From Number = :63&#xA;   To number : 80&#xA;   Record 4:           |4|Retest5#95599#&#xA;   From Number = :80&#xA;   To number : 97&#xA;   Record 5:           |5|Retest6#96699#&#xA;   From Number = :97&#xA;   To number : 114&#xA;   Record 6 :          |6|Retest7#99119#&#xA;   From Number = :114&#xA;   To number : 139&#xA;   Record 7 :               &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; THIS ONE IS MISSING ? WHY?&#xA;   From Number = :139&#xA;   To number : 164&#xA;   Record 8 :               &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; THIS ONE IS MISSING ? WHY?&#xA;   From Number = :164&#xA;   To number : 197&#xA;   Record 9 :               &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; THIS ONE IS MISSING ? WHY?&#xA;&#xA;   */&#xA;  String tempArray2[10];&#xA;  int fromLocation = 0;&#xA;  int toLocation=0;&#xA;&#xA;  for (int i = 0; i &amp;lt;10 ; i++){                 /////// LINE 80&#xA;&#xA;    toLocation += tempArray[i].toInt();&#xA;&#xA;    fromLocation += tempArray[i-1].toInt();&#xA;    tempArray2[i]=eepromReadTwo.substring(fromLocation,toLocation);&#xA;    Serial.print(&quot;From Number = :&quot;);&#xA;    Serial.println(fromLocation);&#xA;    Serial.print(&quot;To number : &quot;);&#xA;    Serial.println(toLocation);&#xA;    Serial.print(&quot;I just translated :&quot;);&#xA;    Serial.println(tempArray2[i]);&#xA;&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3793" LastEditorUserId="3793" LastEditDate="2014-10-07T00:52:40.417" LastActivityDate="2014-10-07T00:52:40.417" Title="Problems with substring loop" Tags="|c++|string|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4488" PostTypeId="2" ParentId="4429" CreationDate="2014-10-06T19:36:11.487" Score="1" Body="&lt;p&gt;It sounds like you are missing the libraries that the project was build for. BetterStream was part of the library system of the Ardu projects at diydrones.com&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally for Ardu projects they use a modified version (their own) of the Arduino IDE but I don't know if the Arducam project works the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you will find a better answer over in the support forum as &lt;a href=&quot;http://www.diydrones.com&quot; rel=&quot;nofollow&quot;&gt;http://www.diydrones.com&lt;/a&gt; which is where Arducam comes from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the source files look like they replace libraries so it might be that you just need a different core from diyd&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2014-10-06T19:36:11.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4489" PostTypeId="2" ParentId="4480" CreationDate="2014-10-06T21:13:56.833" Score="12" Body="&lt;p&gt;The main difference between the ATmega32u4 and the ATmega328P is that the 32u4 has onboard USB. When ATmega328P are used in an Arduino they are often coupled with an FTDI USB to serial chip. The FTDI chip is about $5 so this may be where the extra cost comes in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having the USB chip separate is actually not a bad thing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Atmega328P consumes less power than the ATmega32u4&lt;/li&gt;&#xA;&lt;li&gt;FTDI chips are common, so the drivers are on most computers, whereas the 32u4 requires an .inf file to be loaded on Windows.&lt;/li&gt;&#xA;&lt;li&gt;The FTDI chip uses the FTDI vendor and product ID and thus can be used in large-quantity commercial projects whereas the ATmega32u4 would require purchase of a vendor id and product id from the USB group. (My conclusion after reading around the net a bit, please correct if wrong). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-06T21:13:56.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4491" PostTypeId="1" AcceptedAnswerId="4518" CreationDate="2014-09-29T19:12:51.873" Score="0" ViewCount="629" Body="&lt;p&gt;I got a bare conductive board ( which is based on arduino leonardo ) . I was trying to upload a blink sketch using arduion 1.5.7. But its always failing and here is the log. I never work a leonardo before. Any ideas what is happing with this ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;&#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /tmp/build5447563659949358969.tmp/Blink.cpp -o /tmp/build5447563659949358969.tmp/Blink.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_analog.c -o /tmp/build5447563659949358969.tmp/wiring_analog.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_digital.c -o /tmp/build5447563659949358969.tmp/wiring_digital.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_shift.c -o /tmp/build5447563659949358969.tmp/wiring_shift.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WInterrupts.c -o /tmp/build5447563659949358969.tmp/WInterrupts.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/hooks.c -o /tmp/build5447563659949358969.tmp/hooks.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_pulse.c -o /tmp/build5447563659949358969.tmp/wiring_pulse.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring.c -o /tmp/build5447563659949358969.tmp/wiring.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial3.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial3.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Tone.cpp -o /tmp/build5447563659949358969.tmp/Tone.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial1.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial1.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial2.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial2.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Print.cpp -o /tmp/build5447563659949358969.tmp/Print.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HID.cpp -o /tmp/build5447563659949358969.tmp/HID.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/USBCore.cpp -o /tmp/build5447563659949358969.tmp/USBCore.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/IPAddress.cpp -o /tmp/build5447563659949358969.tmp/IPAddress.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WMath.cpp -o /tmp/build5447563659949358969.tmp/WMath.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WString.cpp -o /tmp/build5447563659949358969.tmp/WString.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/main.cpp -o /tmp/build5447563659949358969.tmp/main.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial0.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/new.cpp -o /tmp/build5447563659949358969.tmp/new.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Stream.cpp -o /tmp/build5447563659949358969.tmp/Stream.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER=&quot;Bare Conductive&quot; -DUSB_PRODUCT=&quot;Touch Board&quot; -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/CDC.cpp -o /tmp/build5447563659949358969.tmp/CDC.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_analog.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_digital.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_shift.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WInterrupts.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/hooks.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_pulse.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring.c.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial3.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Tone.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial1.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial2.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Print.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HID.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/USBCore.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/IPAddress.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WMath.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WString.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/main.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial0.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/new.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Stream.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/CDC.cpp.o &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega32u4 -o /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.o /tmp/build5447563659949358969.tmp/core.a -L/tmp/build5447563659949358969.tmp -lm &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.eep &#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.hex &#xA;&#xA;Sketch uses 4,798 bytes (16%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 157 bytes (6%) of dynamic memory, leaving 2,403 bytes for local variables. Maximum is 2,560 bytes.&#xA;Forcing reset using 1200bps open/close on port /dev/ttyACM0&#xA;PORTS {/dev/ttyACM0, } / {} =&amp;gt; {}&#xA;PORTS {} / {} =&amp;gt; {}&#xA;PORTS {} / {/dev/ttyACM0, } =&amp;gt; {/dev/ttyACM0, }&#xA;Found upload port: /dev/ttyACM0&#xA;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avrdude -C/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/build5447563659949358969.tmp/Blink.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr  3 2014 at 21:52:43&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/root/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : avr109&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : butterfly&#xA;         Description     : Atmel AppNote AVR109 Boot Loader&#xA;&#xA;Connecting to programmer: .avrdude: Send: . [1b] &#xA;avrdude: Send: S [53] &#xA;avrdude: Recv: C [43] &#xA;&#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And My dmesg output is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 3616.984079] usb 4-2: new full-speed USB device number 11 using uhci_hcd&#xA;[ 3617.155216] usb 4-2: New USB device found, idVendor=2a6e, idProduct=8003&#xA;[ 3617.155224] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0&#xA;[ 3617.155229] usb 4-2: Product: Touch Board&#xA;[ 3617.155234] usb 4-2: Manufacturer: Bare Conductive&#xA;[ 3617.158323] cdc_acm 4-2:1.0: This device cannot do calls on its own. It is not a modem.&#xA;[ 3617.158359] cdc_acm 4-2:1.0: ttyACM0: USB ACM device&#xA;[ 3617.166427] input: Bare Conductive Touch Board as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.2/input/input22&#xA;[ 3617.166675] hid-generic 0003:2A6E:8003.0007: input,hidraw1: USB HID v1.01 Mouse [Bare Conductive Touch Board] on usb-0000:00:1a.1-2/input2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And My lsusb output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 002 Device 002: ID 04f2:b179 Chicony Electronics Co., Ltd &#xA;Bus 002 Device 004: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)&#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Bluetooth 2.0 Interface [Broadcom BCM2045]&#xA;Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 004 Device 011: ID 2a6e:8003  &#xA;Bus 004 Device 002: ID 1d57:0008 Xenta &#xA;Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4320" OwnerDisplayName="Achayan" LastEditorUserId="37" LastEditDate="2014-11-12T14:18:43.357" LastActivityDate="2014-11-12T14:18:43.357" Title="Arduino Leonardo Upload issue with ubuntu 14.04" Tags="|arduino-ide|bare-conductive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4492" PostTypeId="2" ParentId="4487" CreationDate="2014-10-06T23:47:31.250" Score="1" Body="&lt;p&gt;Your 2nd for loop should look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int fromLocation = 0;&#xA;int toLocation=0;&#xA;&#xA;for (int i = 0; i &amp;lt;10 ; i++)&#xA;{                 /////// LINE 80&#xA;&#xA;    toLocation += tempArray[i].toInt();&#xA;&#xA;    tempArray2[i]=eepromReadTwo.substring(fromLocation,toLocation);&#xA;    Serial.print(&quot;From Number = :&quot;);&#xA;    Serial.println(fromLocation);&#xA;    Serial.print(&quot;To number : &quot;);&#xA;    Serial.println(toLocation);&#xA;    Serial.print(&quot;I just translated :&quot;);&#xA;    Serial.println(tempArray2[i]);&#xA;    fromLocation += tempArray[i].toInt();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the first pass through the loop, fromLocation is 0. toLocation starts at 0 and gets the value in tempArray2[0] added to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After extracting a string, you add the current array value to fromLocation to advance the pointer to the beginning of the next string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that String objects are very inefficient way to save 2 digit numbers. It would be better use an array of ints, and write code that extracts 2 characters at a time into int values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With only 20 String objects it's not a huge deal, but bear in mind that String objects take a lot of memory overhead on a memory-starved platform like an Arduino. Better to learn how to use C strings.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-10-06T23:47:31.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4494" PostTypeId="1" AcceptedAnswerId="4538" CreationDate="2014-10-07T08:30:56.987" Score="1" ViewCount="4467" Body="&lt;p&gt;I'm using the Registers of the Arduino micro to get a signal for Electronic Speed Controllers (ESC) for brushless motors.&#xA;As far as I read, ESCs interpret everything they can, while just ignoring too fast update rates. If somebody knows better, this would be a great time to yell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to get a digital signal, where a timespan between 1 and 2 ms is HIGH and the rest low. Ideally I want this at 50-400Hz, since 488Hz is the fastest possible frequency, and 50 Hz the standard Servo frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to use Phase Correct Mode to count up and down continuously. As the value in the counter reaches my set OCRnx on the way up, it sets the output pin LOW, as it reaches the same value on the way down, after reaching TOP(value), it sets the output HIGH. In ATmega documentation terms, this is NON-inverted Phase-Correct-PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I set the Registers DDR (to set the pin as output), TCCR1A and TCCR1B and ICR1 (TOPvalue = between 20000 and 2500).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now using OCR1A = 1000 should give me a pulse width of 1000ms. This is the expected or target behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My testing code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// using a 16-bit timer to generate PWM signals for ESCs&#xA;&#xA;// Phase Correct Mode counts from Bottom to Top and back to Bottom&#xA;// with a prescaler of 8&#xA;// motor signal (OCRnx) uses values of 1000 (idle) - 2000 (max)&#xA;// which directly corresponds to microseconds HIGH-time&#xA;// setting the range to (BOTTOM) 0 - TOPvalue sets the frequency&#xA;&#xA;// two important formulas are:&#xA;// frequency(PWM) = F_CPU / (2*Prescalar*TOPvalue)&#xA;//&#xA;// PulseWidth [s] = High-tick-count / (F_CPU/Prescalar)&#xA;// High-tick-count = 2 * OCR-value&#xA;&#xA;// n = number of timer (1,3)&#xA;// x = A,B,C&#xA;&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;// #include &amp;lt;Arduino.h&amp;gt;&#xA;// #define DEBUG&#xA;// #include &amp;lt;Moto.h&amp;gt;&#xA;&#xA;#define PRESCALAR 8&#xA;#define PWM_FREQUENCY 50&#xA;#define TOP_VALUE F_CPU/(2*PRESCALAR*PWM_FREQUENCY)&#xA;&#xA;&#xA;uint16_t dutytime = 1000; // this gives idle throttle signal&#xA;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(115200);&#xA;  // moto.setup();&#xA;&#xA;  // TIMER 1&#xA;  // TIMSK1 = 0; // disable Interrupts for timer1&#xA;  DDRB |= (1&amp;lt;&amp;lt;DDB5); // D9 Output&#xA;  DDRC |= (1&amp;lt;&amp;lt;DDC6); // D5 Output&#xA;&#xA;  // set 1000ms to start motors in idle mode&#xA;  OCR1A = 1000L;&#xA;  OCR3A = 1000L;&#xA;&#xA;  // bits 7,5,3 PWM Output on pins A,B,C respectively&#xA;  // bits 1,0 WGM_1,0: phase correction mode&#xA;  // TCCR1A |= B10000010; // in hex: 0xAA for all 3 = B 1010 1010&#xA;  TCCR1A |= (1&amp;lt;&amp;lt;COM1A1)|(1&amp;lt;&amp;lt;WGM11);&#xA;  // bit 4,3 WGM_3,2: phase correction mode&#xA;  // bits 2,1,0 Prescalar: 8&#xA;  // TCCR1B |= B00010010; // in hex: 0x12; B 0001 0010&#xA;  TCCR1B |= (1&amp;lt;&amp;lt;WGM13)|(1&amp;lt;&amp;lt;CS11);&#xA;  ICR1 = TOP_VALUE;&#xA;&#xA;  // TIMER 3&#xA;  // TIMSK3 = 0; // disable Interrupts for timer3&#xA;  // bit 7 PWM Output on pin A&#xA;  // bits 1,0 WGM_1,0: phase correction mode&#xA;  TCCR3A |= B10000010; // in hex: 0x82; // B 1000 0010&#xA;  // bit 4,3 WGM_3,2: phase correction mode&#xA;  // bits 2,1,0 Prescalar: 8&#xA;  TCCR3B |= B00010010; // in hex: 0x12; B 0001 0010&#xA;  ICR3 = TOP_VALUE; // TOPvalue = 2048&#xA;&#xA;}//setup&#xA;&#xA;&#xA;void loop(void) {&#xA;&#xA;  // Serial.println(TOP_VALUE);&#xA;  // delay(500);&#xA;  while (dutytime &amp;lt; 2000) {&#xA;    dutytime += 150;&#xA;    OCR1A = dutytime;&#xA;    OCR3A = dutytime;&#xA;    Serial.println(dutytime);&#xA;    delay(1500);&#xA;  }&#xA;  while (dutytime &amp;gt; 1000) {&#xA;    dutytime -= 150;&#xA;    OCR1A = dutytime;&#xA;    OCR3A = dutytime;&#xA;    Serial.println(dutytime);&#xA;    delay(1500);&#xA;  }&#xA;&#xA;}//loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I repeated the settings for timer3 to get something to compare to. Both do give the same: if i delete the loop and just write &lt;code&gt;loop{}&lt;/code&gt; nothing happens. The pins are high and seem to stay so. With the while loops activated, my multimeter gives me 1Hz (which are the changes of course) and between 99.9% duty cycle and 96%.&#xA;An led, which i connected to it blinks every second a very short time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2014-10-10T11:42:44.520" LastActivityDate="2014-10-15T11:59:01.333" Title="PWM generation using Registers" Tags="|motor|pwm|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4495" PostTypeId="1" CreationDate="2014-10-07T10:19:44.657" Score="0" ViewCount="901" Body="&lt;p&gt;It has been mentioned here &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoEthernetShield&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoEthernetShield&lt;/a&gt; that corresponding libraries take care of chip select between SD and W5100 in Arduino Ethernet shield. Does it take care properly all the time? What happens if the Chipselect is not properly managed by libraries? Does that cause blocking of code?&lt;/p&gt;&#xA;" OwnerUserId="4287" LastEditorUserId="37" LastEditDate="2014-10-07T10:49:25.100" LastActivityDate="2014-10-07T13:32:29.157" Title="While using Arduino Ethernet shield, do we need to explicitly select/Deselect SD and W5100 in our code?" Tags="|arduino-mega|shields|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4496" PostTypeId="2" ParentId="4447" CreationDate="2014-10-07T10:32:10.433" Score="2" Body="&lt;p&gt;I have been looking into this myself.  After getting some advice online I have come up with this circuit :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CU9E5.png&quot; alt=&quot;Comparator&quot;&gt;&#xA;&lt;a href=&quot;http://everycircuit.com/circuit/5059191601364992&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://everycircuit.com/circuit/5059191601364992&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The top left power source is the mains supply and the bottom  left is the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A voltage divider is connected to both that then feeds into an OPAMP comparator.  For illustrative purposes there is a switch at the top left you can toggle to see the circuit in action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the mains power gets cut off the op amp comparator sends a logic level signal through the diode and into the mosfet which enables the battery circuit.   the capacitor is there to keep power while the comparator makes the switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link on every circuit is interactive, so feel free to have a play about with it.  The LED represents your Arduino.  The OpAmp is powered by the Positive and negative rails of thi diagram (impossible to draw on EveryCircuit)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to attach a voltage regulator to this circuit (at the input of the Arduino) so that the voltage doesn't change to your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's where I researched about comparator OPAMPS ... &lt;a href=&quot;http://www.dummies.com/how-to/content/electronics-components-how-to-use-an-op-amp-as-a-v.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Setting up a comparator OpAmp circuit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LM358 is a good very cheap OPAMP for this circuit.   All parts well sourced will cost you about £1 (or less).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if your battery is rechargeable you can try this circuit :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fXiGI.png&quot; alt=&quot;battery Backup Circuit 2&quot;&gt;&#xA;&lt;a href=&quot;http://everycircuit.com/circuit/5232232327282688&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://everycircuit.com/circuit/5232232327282688&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again this is just for illustrative purposes.   You will need a 5V step-up converter to get 5v from a 3.7v battery.  Also the battery I am using has a builtin protection circuit, if yours doesn't it's important you include it in your schematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here's a video of it working for me with a 3.7V Li-Polymer Battery:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=Sv2rjVqQg3U&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=Sv2rjVqQg3U&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3793" LastEditorUserId="3793" LastEditDate="2014-10-14T18:33:15.643" LastActivityDate="2014-10-14T18:33:15.643" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4497" PostTypeId="2" ParentId="4447" CreationDate="2014-10-07T11:15:11.140" Score="2" Body="&lt;p&gt;I suggest this &quot;&lt;a href=&quot;http://www.adafruit.com/products/1944&quot; rel=&quot;nofollow&quot;&gt;Battery boost&lt;/a&gt;&quot; circuit from AdaFruit. It's designed to do exactly what you describe. An Arduino needs a smooth, steady 5 V supply with no &quot;blips&quot;. The AdaFruit unit does just that, and charges the battery while on Mains supply.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-10-07T11:15:11.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4498" PostTypeId="1" CreationDate="2014-10-07T08:29:31.313" Score="-4" ViewCount="265" Body="&lt;p&gt;I have an Arduino Yun. I am trying to upload the code in Arduino but after I click on Upload, I get the error message shown in the image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first it showed the Arduino Yun under the port tab, after this message no Arduino is showing in port tab.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/TcaI7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The portion of the error visible in the image:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerDisplayName="Bad Coder" LastEditorUserId="26916" LastEditDate="2017-10-26T00:39:26.820" LastActivityDate="2017-10-26T00:39:26.820" Title="Problem uploading to Arduino Yun" Tags="|arduino-yun|uploading|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4499" PostTypeId="2" ParentId="4495" CreationDate="2014-10-07T13:32:29.157" Score="2" Body="&lt;p&gt;Here we have a nice example of a single Shield requiring TWO libraries. The Ethernet.h and SD.h where the later appears as an after thought and is not demonstrated by the Example. As it is done so in the SD examples. However, their styles are slightly different. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Ethernet libary as mentioned (provided within) the IDE is hardcoded to implement the Chip Select for the W5100 on corresponding pin. When using the typical purchased Ethernet Shield, there is no need to configure it. Unlike the SD library, which requires the pin to configured using the SD.begin(4) member function. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!SD.begin(4)) {&#xA;  Serial.println(&quot;initialization failed!&quot;);&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where again on the typical Ethernet shield the SD card is at pin D4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note being hardcode that the Ethernet library selects the matching pin to corresponding shield.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private:&#xA;#if defined(ARDUINO_ARCH_AVR)&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  inline static void initSS()    { DDRB  |=  _BV(4); };&#xA;  inline static void setSS()     { PORTB &amp;amp;= ~_BV(4); };&#xA;  inline static void resetSS()   { PORTB |=  _BV(4); };&#xA;#elif defined(__AVR_ATmega32U4__)&#xA;  inline static void initSS()    { DDRB  |=  _BV(6); };&#xA;  inline static void setSS()     { PORTB &amp;amp;= ~_BV(6); };&#xA;  inline static void resetSS()   { PORTB |=  _BV(6); }; &#xA;#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)&#xA;  inline static void initSS()    { DDRB  |=  _BV(0); };&#xA;  inline static void setSS()     { PORTB &amp;amp;= ~_BV(0); };&#xA;  inline static void resetSS()   { PORTB |=  _BV(0); }; &#xA;#else&#xA;  inline static void initSS()    { DDRB  |=  _BV(2); };&#xA;  inline static void setSS()     { PORTB &amp;amp;= ~_BV(2); };&#xA;  inline static void resetSS()   { PORTB |=  _BV(2); };&#xA;#endif&#xA;#endif // ARDUINO_ARCH_AVR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the case of the UNO (or the else case) Port B Bit 2 is D10.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;worth noting that SD library has an alternate method of initializing and using the SD card &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!card.init(SPI_HALF_SPEED, chipSelect)) {&#xA;  Serial.println(&quot;initialization failed. Things to check:&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where chipSelect would be D10 in this case.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-10-07T13:32:29.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4500" PostTypeId="1" AcceptedAnswerId="4539" CreationDate="2014-10-07T19:44:31.993" Score="2" ViewCount="15506" Body="&lt;p&gt;I need to write and read some data from SD card. I link SD card(LC STUDIO) to Arduino (UNO). I use &lt;a href=&quot;http://www.instructables.com/id/Arduino-DIY-SD-Card-Logging-Shield/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; for create my project. In first day I don't have any problem and data correctly save to file. But now my circuit isn't work nicely. When Arduino is running the sketch I don't saw any error message.But when I link the SD card to my laptop, I don't saw any file on card!!&#xA;The code is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;const int chipSelect = 10;&#xA;&#xA;File file;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ;&#xA;  }&#xA;&#xA;&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;  pinMode(10, OUTPUT);&#xA;&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&quot;Card failed, or not present&quot;);&#xA;  }&#xA;  Serial.println(&quot;card initialized.&quot;);&#xA;  //creating file&#xA;  file = SD.open(&quot;test.txt&quot;,FILE_WRITE);&#xA;  file.close();&#xA;  //write data to file&#xA;  file = SD.open(&quot;test.txt&quot;,FILE_WRITE);&#xA;  if(file){&#xA;    file.println(&quot;OK!!&quot;);&#xA;    file.println(&quot;1&quot;);&#xA;    file.println(&quot;2&quot;);&#xA;    file.println(&quot;3&quot;);&#xA;    file.println(&quot;OK!!&quot;);&#xA;    file.close();&#xA;  }&#xA;}&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3745" LastActivityDate="2017-05-07T16:25:02.883" Title="Arduino can't create file in sd card" Tags="|arduino-uno|sd-card|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4501" PostTypeId="2" ParentId="4498" CreationDate="2014-10-07T19:58:23.517" Score="1" Body="&lt;p&gt;In the Arduino IDE, click on &lt;code&gt;Tools&lt;/code&gt; (on the menu bar). Then, open the submenu &lt;code&gt;Board&lt;/code&gt; and make sure &quot;YUN&quot; is selected.&lt;/p&gt;&#xA;" OwnerUserId="3745" LastEditorUserId="37" LastEditDate="2014-10-08T15:28:35.513" LastActivityDate="2014-10-08T15:28:35.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4502" PostTypeId="2" ParentId="4485" CreationDate="2014-10-07T20:15:29.980" Score="0" Body="&lt;p&gt;I use SD card with Arduino UNO. I connected SD card to the Arduino and I saw the Arduino don’t detect the SD card. Then  I see &lt;a href=&quot;http://www.instructables.com/id/Arduino-DIY-SD-Card-Logging-Shield/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; and Arduino detect the SD card now.&#xA;Don't connect the SD card breakout board to Arduino and use non-inverting hex buffer(4050).&lt;/p&gt;&#xA;" OwnerUserId="3745" LastActivityDate="2014-10-07T20:15:29.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4504" PostTypeId="2" ParentId="4498" CreationDate="2014-10-07T20:27:12.043" Score="0" Body="&lt;p&gt;Seems like you havent chose the appropriate serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under tools, you'll also find serial port - make sure the appropiate one is selected.&lt;/p&gt;&#xA;" OwnerUserId="4293" LastActivityDate="2014-10-07T20:27:12.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4505" PostTypeId="1" AcceptedAnswerId="4515" CreationDate="2014-10-08T01:09:12.847" Score="1" ViewCount="1201" Body="&lt;p&gt;I am not very experienced in this, but I was wondering if Code::Blocks has a way of getting a debugger that runs for Arduino chips, specifically. I understand there is Arduino IDE for but does it allow debugging specific to those microcontrollers (Amtel and such)?&lt;/p&gt;&#xA;" OwnerUserId="4317" OwnerDisplayName="Blizzard" LastActivityDate="2014-10-08T18:13:48.700" Title="Debugger for Code::Blocks + Arduino" Tags="|debugging|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4506" PostTypeId="2" ParentId="4480" CreationDate="2014-10-08T03:53:26.163" Score="3" Body="&lt;p&gt;I'd buy the NANO and STEER CLEAR of the micro with that 32u4 chip. The good ol' 328p chip also has a FTDI chip to handle USB to serial while the other chip handles it on its own. The problem is that the Micro's bootloader ONLY allows trying to program it with USB and requires a special driver. With Linux, only a few select versions have the needed driver. If your Linux version doesn't have the driver, you're out of luck. In that case, take it back or donate it to a hackerspace. You will NEVER make it work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was at the arduino.cc site about this and tried everything only to get increasingly annoyed about that lemon of a card. You know it's time to give up when you get flamed. &lt;/p&gt;&#xA;" OwnerUserId="4297" LastEditorUserId="42" LastEditDate="2014-10-08T11:04:25.060" LastActivityDate="2014-10-08T11:04:25.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4509" PostTypeId="1" CreationDate="2014-10-08T06:54:21.513" Score="1" ViewCount="837" Body="&lt;p&gt;I want to communicate between Arduino Mini Pro (china import) and a stm32f4 running netmf runtime. At the moment I'm able to communicate between SPI1 and SPI2 on the stm32 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I switched on the Arduino. I'm using the RF24 library and modified the GettingStarted sample to simply open pipes and send the same byte array again and again to the stm32.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works for the first transmit but after that I did not receive any interrupts on the receiver side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both NRF24L01+ are power supplied by a breadboard power supply module which supplies 500ma (max USB bus). The Arduino is connected and power supplied by a CP2102 USB/Serial adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NETMF Address: 0F0F0F0F0F&#xA;Arduino Address: 0F0F0F0F0E&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As arduino uses little endian, I reverse the bytes on stm32 side before writing the address into the pipe. But I'm already unsure if I need that step (adding the Arduino address on netmf side).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;RF24.h&quot;&#xA;#include &quot;printf.h&quot;&#xA;&#xA;RF24 radio(9,10);&#xA;&#xA;const int payload_size = 4;&#xA;const char payload[] = &quot;PING&quot;;&#xA;&#xA;void setup(void)&#xA;{&#xA;&#xA;    Serial.begin(57600);&#xA;    printf_begin();&#xA;    radio.begin();&#xA;    radio.enableDynamicPayloads();&#xA;    radio.setChannel(77);&#xA;    radio.setAutoAck(true);&#xA;    radio.setRetries(15,15);&#xA;    radio.setDataRate(RF24_2MBPS);&#xA;    radio.openWritingPipe((uint64_t)0x0F0F0F0F0FLL);&#xA;    radio.openReadingPipe(1,(uint64_t)0x0F0F0F0F0ELL);&#xA;    radio.stopListening();&#xA;    radio.printDetails();&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;    unsigned long time = millis();&#xA;    bool ok = radio.write( payload, payload_size );&#xA;&#xA;    if (ok)&#xA;        printf(&quot;SUCCESS %lu...\n&quot;,time);&#xA;    else&#xA;        printf(&quot;fail %lu...\n&quot;,time);&#xA;&#xA;    // Try again 1s later&#xA;    delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's my NETmf code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NRF24L01Plus _module = new NRF24L01Plus();&#xA;&#xA;&#xA;public override void Init()&#xA;{&#xA;    _module.Initialize(SPI_Devices.SPI2, Pins.GPIO_PIN_D_8, Pins.GPIO_PIN_D_10, Pins.GPIO_PIN_B_12);&#xA;    _module.Configure(new byte[] { 0x0F, 0x0F, 0x0F, 0x0F, 0x0F }, 77, NRFDataRate.DR2Mbps);&#xA;&#xA;    // both handlers are never executed&#xA;    _module.OnDataReceived += this.OnReceive;&#xA;    _module.OnInterrupt += _module2_OnInterrupt;&#xA;&#xA;    _module.Enable();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4298" LastEditorUserId="4298" LastEditDate="2014-10-10T08:47:18.007" LastActivityDate="2015-01-08T10:31:58.103" Title="Arduino NRF24L01+ arduino to netmf transmit issue" Tags="|arduino-pro-mini|nrf24l01+|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4510" PostTypeId="2" ParentId="4485" CreationDate="2014-10-08T08:40:52.753" Score="1" Body="&lt;p&gt;Thank you very much. I solved part of the problem. I tried it whit a new SD Card. When I use pin 52, I am able to read the card information with the program above. But only if I use SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 10 doesn't work at all and Pin 4 a bit. If I work with Pin 4, it accepts the card, but it can't find out what format the SD card has. This is kind of weird, I think, because Arduino say alls three pins should work (&lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SPI&lt;/a&gt;). Does anybody knows something about this?&lt;/p&gt;&#xA;" OwnerUserId="4268" LastEditorUserId="4628" LastEditDate="2015-12-06T12:11:09.957" LastActivityDate="2015-12-06T12:11:09.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4511" PostTypeId="1" AcceptedAnswerId="4512" CreationDate="2014-10-08T10:43:31.877" Score="3" ViewCount="5944" Body="&lt;p&gt;I am a complete novice in Arduino and moderately experienced with the language C++. What if I want to use the output from the serial monitor in C++ code in real time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also how can I write to the serial monitor. Which libraries are available for this? Also please give me links to sites where I can learn more about this topic. I am using &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4303" LastEditorUserId="510" LastEditDate="2015-08-10T00:01:58.410" LastActivityDate="2015-08-10T00:02:02.930" Title="How to use output from Arduino in C++ code?" Tags="|arduino-uno|serial|c++|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4512" PostTypeId="2" ParentId="4511" CreationDate="2014-10-08T12:19:48.447" Score="2" Body="&lt;p&gt;Unfortunately, C++ doesn't have native support for serial I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the Windows API directly if you're feeling adventurous. It can be a little complicated to get to grips with, but not insurmountable. You can get basic information about it &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ff802693.aspx&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. There's an example of using it with Arduino &lt;a href=&quot;http://playground.arduino.cc/Interfacing/CPPWindows&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternative, you could use a 3rd party library. &lt;a href=&quot;http://www.codeproject.com/Articles/992/Serial-library-for-C&quot; rel=&quot;nofollow&quot;&gt;This one&lt;/a&gt; looks good, although I haven't actually used it myself.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-10-08T12:19:48.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4513" PostTypeId="2" ParentId="4505" CreationDate="2014-10-08T13:47:56.837" Score="1" Body="&lt;p&gt;Answer: Code blocks does not currently have an Arduino debugger. The Arduino IDE does not have a debugger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an Arduino debugger in Atmel Studio using the Visual Micro plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you have to use Ms Windows to use Atmel Studio which might not be available to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Visual Micro debugger is simple and uses usb so does not require additional hardware but as your experience grows you might also like to progress to fully blown hardware debug using the native Atmel Studio Tools&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.visualmicro.com/page/Debugging-for-Arduino.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Micro debug in Atmel Studio&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/tools/atmelstudio.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmel Studio Download&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1BV46.png&quot; alt=&quot;Arduino usb debugger&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2014-10-08T18:13:48.700" LastActivityDate="2014-10-08T18:13:48.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4514" PostTypeId="2" ParentId="4479" CreationDate="2014-10-08T13:54:23.427" Score="0" Body="&lt;p&gt;Yes Arduino code is fine although your should use println() as a terminator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should read the message into a tmpMessage var. If tmpMessage is empty then break out the loop otherwise concatenate tmpMessage into the message var.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then print the message var after the loop when no more data arrives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It must be ruby inserting the line breaks when you use puts&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2014-10-08T13:54:23.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4515" PostTypeId="2" ParentId="4505" CreationDate="2014-10-08T15:31:24.753" Score="0" Body="&lt;p&gt;If you are interested in on-board debugging or off-board debugging, you will need a programmer/debugger. I would recommend the Atmel &lt;a href=&quot;http://www.atmel.com/tools/avrdragon.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR Dragon&lt;/a&gt;. Atmel AVR Dragon uses the Atmel Studio 6.2, which is a great IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AXFgx.gif&quot; alt=&quot;AVR Dragon&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-10-08T15:31:24.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4516" PostTypeId="2" ParentId="4511" CreationDate="2014-10-08T21:32:20.647" Score="0" Body="&lt;p&gt;@Peter has already posted library links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend that you use &lt;a href=&quot;http://en.wikipedia.org/wiki/Node.js&quot; rel=&quot;nofollow&quot;&gt;Node.js&lt;/a&gt; (&lt;a href=&quot;https://github.com/voodootikigod/node-serialport&quot; rel=&quot;nofollow&quot;&gt;node-serialport&lt;/a&gt;) or &lt;a href=&quot;http://en.wikipedia.org/wiki/Python_%28programming_language%29&quot; rel=&quot;nofollow&quot;&gt;Python&lt;/a&gt; (&lt;a href=&quot;http://playground.arduino.cc/interfacing/python&quot; rel=&quot;nofollow&quot;&gt;serial&lt;/a&gt;), which have excellent native serial support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these use C++ internally to communicate over Serial (Serial.h).&#xA;Try &lt;a href=&quot;https://github.com/voodootikigod/node-serialport/tree/master/src&quot; rel=&quot;nofollow&quot;&gt;going through the code&lt;/a&gt; Node.js uses internally, and if you are willing to write that much, by all means use the library.&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="510" LastEditDate="2015-08-10T00:02:02.930" LastActivityDate="2015-08-10T00:02:02.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4518" PostTypeId="2" ParentId="4491" CreationDate="2014-10-08T23:52:49.020" Score="0" Body="&lt;p&gt;Try the arduino.cc forums. Post your logs, and you MIGHT get an answer that'll work. The guys who developed the Leonardo got it to work with Ubuntu 10.04 without a special device driver. I use Ubuntu like you but not the magic 10.04 version and was forced to give up on the Leonardo despite heroic effort. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that 32u4 chip the Leonardo (and Micro) use. Instead of having a separate FTDI chip like a good ol' UNO, it handles USB on its own. With a bootloader on a Leonardo that enables only USB to be used (besides ICSP) Windows needs a funny .inf file to make it work. But Linux? In this case, Windows of a given version is Windows is Windows. Linux boxes are more like people in that each has its own personality, given the zillion distributions and versions thereof. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm convinced that the Leonardo developers merely got lucky with Ubuntu 10.04. &lt;/p&gt;&#xA;" OwnerUserId="4297" LastActivityDate="2014-10-08T23:52:49.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4520" PostTypeId="1" AcceptedAnswerId="4521" CreationDate="2014-10-09T07:39:11.900" Score="5" ViewCount="934" Body="&lt;p&gt;As it is possible to program a ATtiny45 using Arduino as ISP Programmer, is there a way to backup an ATtiny45 program to a .hex file using Arduino?&lt;/p&gt;&#xA;" OwnerUserId="975" LastActivityDate="2014-10-09T07:56:14.837" Title="Extract .hex from ATtiny45 using Arduino" Tags="|attiny|avrdude|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4521" PostTypeId="2" ParentId="4520" CreationDate="2014-10-09T07:56:14.837" Score="5" Body="&lt;p&gt;Assuming the lock bits on the device haven't been set, sure. Simply prepare the Arduino for ArduinoISP, hook up the ATtiny45, and perform a read using AVRDUDE instead of a write (&lt;code&gt;-U flash:r:foo.hex:i&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-09T07:56:14.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4522" PostTypeId="1" AcceptedAnswerId="4601" CreationDate="2014-10-09T09:29:54.357" Score="1" ViewCount="1069" Body="&lt;p&gt;I'm gonna start a project with an IMU with a bluetooth support inside a small board (mini or lillypad) and send datas to the mobile phone. But I'm quite new to those kind of technologies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to choose a module for handling both operate voltage restriction and memory capacity for both library (IMU and bluetooth).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice obj which arduino / IMU breakout / bluetooth module / battery to use? Or some similar projects?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-10-14T11:01:49.987" Title="Using IMU for a small Arduino and bluetooth support" Tags="|bluetooth|accelerometer|gyroscope|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4523" PostTypeId="2" ParentId="4436" CreationDate="2014-10-09T11:05:38.667" Score="-1" Body="&lt;p&gt;The communication between the arduino and processing is 9600bit/s I suppose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will mean, that one bit needs 0.104ms to be sent. But with your Arduino code and the while-function you don't wait till the 8 bits of your byte are arrived and the arduino-loop is to fast for the serial connection. Wit other words: you cant use our wihile() function, use an if statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x;&#xA;if (Serial.available()&amp;gt;0) {&#xA;  x = Serial.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for debugging you can include once more the Serial.print()-function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sorry for my terrible English...)&lt;/p&gt;&#xA;" OwnerUserId="4322" LastActivityDate="2014-10-09T11:05:38.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4524" PostTypeId="2" ParentId="4028" CreationDate="2014-10-09T11:20:20.047" Score="1" Body="&lt;p&gt;I think I would use RS-485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this standard, you can write your own communication-protocol and with arduino it is easy to use with the Serial class. As extensions for the Arduino you only use the MAX485 because it uses the UART-cip of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have absolutely no experience with the rasperypi but I think it does also have an UART-Cip what would mean, that you can also connect the MAX485.&lt;/p&gt;&#xA;" OwnerUserId="4322" LastActivityDate="2014-10-09T11:20:20.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4525" PostTypeId="2" ParentId="4509" CreationDate="2014-10-09T11:26:03.223" Score="1" Body="&lt;p&gt;I have a couple of projects that use the NRF24L01+ and the RF24 Library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned in my comment, the examples provided is not asynchronous. I am not sure if the library supports asynchronous operations. Nevertheless, in your example, one radio should be in transmit mode and the other receive. If you look at the examples, the author uses modes (role_ping_out and role_ping_back). Basicly, the author wrote the code so you can both send and receive. But you can't do send and receive at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the example cope in the library, you can see where you need to stop receiving and start sending:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.stopListening();&#xA;&#xA;// Send the final one back.&#xA;printf(&quot;Sent response.\n\r&quot;);&#xA;radio.write( &amp;amp;got_time, sizeof(unsigned long) );&#xA;&#xA;// Now, resume listening so we catch the next packets.&#xA;radio.startListening();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on the other radio stop sending and start receiving:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.startListening();&#xA;&#xA;// Wait here until we get a response, or timeout (250ms)&#xA;unsigned long started_waiting_at = __millis();&#xA;bool timeout = false;&#xA;while ( ! radio.available() &amp;amp;&amp;amp; ! timeout ) {&#xA;__msleep(30); //add a small delay to let radio.available to check payload&#xA;  if (__millis() - started_waiting_at &amp;gt; 200 )&#xA;    timeout = true;&#xA;}&#xA;&#xA;// Describe the results&#xA;if ( timeout )&#xA;{&#xA;  printf(&quot;Failed, response timed out.\n\r&quot;);&#xA;}&#xA;else&#xA;{&#xA;  // Grab the response, compare, and send to debugging spew&#xA;  unsigned long got_time;&#xA;  radio.read( &amp;amp;got_time, sizeof(unsigned long) );&#xA;&#xA;  // Spew it&#xA;  printf(&quot;Got response %lu, round-trip delay: %lu\n\r&quot;,got_time,__millis()-got_time);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is a bit confusing, I would suggest you load the Getting Started example on both your radios. Once you get that working, you can get a better idea on how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-10-09T11:26:03.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4526" PostTypeId="2" ParentId="4436" CreationDate="2014-10-09T11:31:55.097" Score="1" Body="&lt;p&gt;&lt;code&gt;int value = int(red(c1[0]));&lt;/code&gt; gives you &lt;strong&gt;99&lt;/strong&gt; not &lt;strong&gt;99.0&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could read a byte (that's what &lt;code&gt;Serial.read&lt;/code&gt; returns; &lt;strong&gt;not an int&lt;/strong&gt;), and make some decision based on that character, then read again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you could read all the available data till &lt;code&gt;'\n'&lt;/code&gt; new line character comes. What &lt;code&gt;println(value);&lt;/code&gt; line does it sends &lt;code&gt;99&lt;/code&gt;+&lt;code&gt;'\n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Buffer to store incoming commands from serial port&#xA;String inData;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Waiting for Processing color...\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    while (Serial.available() &amp;gt; 0)&#xA;    {&#xA;        char recieved = Serial.read();&#xA;        inData += recieved; &#xA;&#xA;        // Process message when new line character is recieved&#xA;        if (recieved == '\n')&#xA;        {&#xA;            Serial.print(&quot;Arduino Received: &quot;);&#xA;            Serial.print(inData);&#xA;&#xA;            inData = &quot;&quot;; // Clear recieved buffer&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case this is not working change your processing code line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myPort.write(value);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myPort.println(value);&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myPort.write(value);&#xA;myPort.write('\n'); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-09T12:28:25.080" LastActivityDate="2014-10-09T12:28:25.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4527" PostTypeId="2" ParentId="4436" CreationDate="2014-10-09T12:36:44.890" Score="4" Body="&lt;p&gt;You have to implement a serial protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be either binary or ASCII. Binary has the advantage that the messages are short and well structured due to fixed parameter size. ASCII has advantage that you can type the messages into the serial monitor for debugging and typically data bytes are numerical ('0', '1' etc) while message bytes are text ('setcolour' etc) which means conflicting bytes do not have to be escaped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get started, try the &lt;a href=&quot;http://playground.arduino.cc/Code/Messenger&quot; rel=&quot;nofollow&quot;&gt;Messenger library&lt;/a&gt;. Note that &lt;code&gt;#include &quot;WProgram.h&quot;&lt;/code&gt; has to be changed to &lt;code&gt;#include &quot;Arduino.h&quot;&lt;/code&gt; in the &lt;code&gt;.cpp&lt;/code&gt; and &lt;code&gt;.h&lt;/code&gt; files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the set colour message, if you used something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setcolour,99,0,0,255,0,0\n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use &lt;code&gt;Messenger&lt;/code&gt; to parse it like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preamble:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Messenger.h&quot;&#xA;Messenger message = Messenger(','); //Message values separated by ','&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;message.attach(messageCompleted);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available()) {&#xA;    byte inbyte = Serial.read();&#xA;    message.process(inbyte);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then implement the callback function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void messageCompleted()&#xA;{&#xA;    if (message.checkString(&quot;setcolour&quot;)) {&#xA;        colour1[0] = message.readInt();&#xA;        colour1[1] = message.readInt();&#xA;        colour1[2] = message.readInt();&#xA;        colour2[0] = message.readInt();&#xA;        colour2[1] = message.readInt();&#xA;        colour2[2] = message.readInt();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;colour1&lt;/code&gt; and &lt;code&gt;colour2&lt;/code&gt; store the two RGB values.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-09T12:36:44.890" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4528" PostTypeId="1" AcceptedAnswerId="4529" CreationDate="2014-10-09T14:02:57.657" Score="5" ViewCount="140" Body="&lt;p&gt;I'd like to update the sketch of a device that a friend out of state is testing. I could have them install the full editor and send the source code but I'd rather not require them to do something so technical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to compile the firmware binary and push that out to a device over the COM port more directly?&lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2014-10-09T14:24:27.020" Title="How do send sketch updates to devices without the editor?" Tags="|uploading|firmware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4529" PostTypeId="2" ParentId="4528" CreationDate="2014-10-09T14:24:27.020" Score="4" Body="&lt;p&gt;In general, yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compile routine creates a .hex file in a temporary directory that contains the flash image for the device. One can use AVRDUDE to upload this .hex file to the Arduino from the command line. It is simply a matter of getting the command arguments correct in order to tell it where and how to upload the image. Enabling verbose output in the IDE will tell you both exactly where the .hex file is located and what arguments are required for the board selected.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-09T14:24:27.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4530" PostTypeId="1" CreationDate="2014-10-09T15:15:43.540" Score="2" ViewCount="19554" Body="&lt;p&gt;My project involves and RFID reader connected to an Arduino Pro Mini (5V, 16MHz) and an Adafruit CC3000 breakout WiFi chip. The device reads RFID tags and sends them to my web service. I am using Software Serial to read the RFID device data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After I scan something, the Arduino tries to send the value that was read to the web service. This obviously causes a delay and the program only continues execution (i.e. next iteration of the loop() function) after the data has been sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is simple. While the value is being sent, the serial buffer is can still accept scans from the RFID reader and on subsequent iterations, because there is data in the buffer the device attempts to send data again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I stop the software serial port from receiving data while I am trying to send data to the web service? Then when the data is sent successfully, how can I re-enable the software serial port from accepting data?&lt;/p&gt;&#xA;" OwnerUserId="4295" LastActivityDate="2020-04-22T17:18:45.593" Title="How can I stop SoftwareSerial from receiving data and re-enable it at some other point?" Tags="|serial|arduino-pro-mini|softwareserial|rfid|" AnswerCount="7" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4531" PostTypeId="1" AcceptedAnswerId="4543" CreationDate="2014-10-09T15:32:15.680" Score="1" ViewCount="1768" Body="&lt;p&gt;I'm trying to get data from a sensor, but don't see how I can get data back. I'm looking at the data on the I2C bus with a logic analyzer, and I'm sending what I expect, but I seem to cut off the slave before he can respond.  My understanding from the &lt;a href=&quot;http://www.consensic.com/DataSheet/DAT-0007,%20rev0.1%20CPS121%20Data%20Sheet.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; is that I need to send this command to wake it up and request a measurement:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0xD8 0x30 0x0A&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and then I need to send this command to get the data:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0xD8 0x06 0xD9&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define HEARTBEAT_PIN            (13)&#xA;&#xA;#define 7BIT_ADDR                (0x6C)&#xA;#define ADDR_WRITE               (0xD8)&#xA;#define ADDR_READ                (0xD9)&#xA;&#xA;#define MAX_NUM_RX_BYTES         (8)&#xA;#define MAX_NUM_TX_BYTES         (8)&#xA;&#xA;&#xA;static uint8_t tx_buffer[MAX_NUM_TX_BYTES];&#xA;static uint8_t rx_buffer[MAX_NUM_RX_BYTES];&#xA;static uint8_t new_rx_data;&#xA;&#xA;void setup(void) {&#xA;  // Clear any module memory&#xA;  memset(tx_buffer, 0, MAX_NUM_TX_BYTES);&#xA;  memset(rx_buffer, 0, MAX_NUM_RX_BYTES);&#xA;  new_rx_data = false;&#xA;&#xA;  Wire.begin();  &#xA;}&#xA;&#xA;void loop(void) {&#xA;  RequestMeasurement();&#xA;  delay(10);&#xA;  GetData();&#xA;  delay(500);&#xA;}&#xA;&#xA;void RequestMeasurement(void) {&#xA;  // MR: 0xD8 0x30 0x0A&#xA;  // Internal (to IC) register address?&#xA;  tx_buffer[0] = 0x30;&#xA;  // Request-measurement command&#xA;  tx_buffer[1] = 0x0A;&#xA;  Wire.beginTransmission(7BIT_ADDR);&#xA;  Wire.write(tx_buffer, 2);&#xA;  Wire.endTransmission(true);&#xA;}&#xA;&#xA;void GetData(void) {&#xA;  // GD: 0xD8 0x06 0xD9 0x?? 0x?? 0x?? 0x?? 0x?? (0x?? =&amp;gt; slave data)&#xA;  // Slave address + 'write' indication bit&#xA;  // Internal (to IC) register address?&#xA;  tx_buffer[0] = 0x06;&#xA;  // Slave address + 'read' indication bit&#xA;  tx_buffer[1] = ADDR_READ;&#xA;&#xA;  Wire.beginTransmission(7BIT_ADDR);&#xA;  Wire.write(tx_buffer, 2);&#xA;  Wire.endTransmission(true);&#xA;&#xA;  // HOW DO I LEAVE THE BUS OPEN LONG ENOUGH&#xA;  // FOR THE SLAVE DEVICE TO RESPOND WITH THE DATA?&#xA;  //Wire.requestFrom(7BIT_ADDR, 3, true); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4325" LastActivityDate="2014-10-10T22:15:09.167" Title="How to wait for next n bytes in I2C exchange?" Tags="|i2c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4532" PostTypeId="2" ParentId="4530" CreationDate="2014-10-09T16:22:43.590" Score="9" Body="&lt;p&gt;Call &lt;a href=&quot;https://github.com/arduino/Arduino/blob/3a8ad75bcef5932cfc81c4746a87ddbdbd7e6402/libraries/SoftwareSerial/SoftwareSerial.cpp#L415-419&quot;&gt;serial.end()&lt;/a&gt; to stop receiving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then call &lt;code&gt;serial.begin(...)&lt;/code&gt; again when you want to start listening again.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-09T16:22:43.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4533" PostTypeId="2" ParentId="4531" CreationDate="2014-10-09T17:06:03.470" Score="2" Body="&lt;p&gt;In the diagram there is a &lt;code&gt;S&lt;/code&gt; after sending &lt;code&gt;0x60&lt;/code&gt;. You first write to the device, letting it you want to read, and then you start reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you need to do something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void GetData(void) {&#xA;  Wire.beginTransmission(7BIT_ADDR);&#xA;  Wire.write(0x06);&#xA;  Wire.endTransmission(false);//don't terminate connection&#xA;&#xA;  Wire.requestFrom(7BIT_ADDR, 3);//this will send the 0xD9&#xA;  pressure = ( (uint32_t) i2cread() &amp;lt;&amp;lt; 16) | ( i2cread() &amp;lt;&amp;lt; 8 ) | i2cread();//or something &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I've never used I2C.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-09T17:06:03.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4534" PostTypeId="2" ParentId="4500" CreationDate="2014-10-09T17:53:24.470" Score="0" Body="&lt;p&gt;If there is no file on the card, you must first create the &quot;test.txt&quot; file and put it in the main directory of your SD card. Your code doesn't create a file and I don't think you can even do that with the SD library. If you want to create a file, you are going to have to use the SDfat library. Also take out this part of your code : &#xA;    &lt;code&gt;file.close();&lt;/code&gt;&#xA;    &lt;code&gt;file = SD.open(&quot;test.txt&quot;,FILE_WRITE);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are just opening, then closing, and then reopening.&lt;/p&gt;&#xA;" OwnerUserId="3912" LastActivityDate="2014-10-09T17:53:24.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4535" PostTypeId="2" ParentId="3327" CreationDate="2014-10-09T21:43:22.717" Score="1" Body="&lt;p&gt;As per this site: &lt;a href=&quot;http://www.rjanick.com/2012/11/26/seeed-studio-bluetooth-shield/&quot; rel=&quot;nofollow&quot;&gt;http://www.rjanick.com/2012/11/26/seeed-studio-bluetooth-shield/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try switching the &lt;code&gt;#define rxd&lt;/code&gt; and &lt;code&gt;#define txd&lt;/code&gt; pin numbers in the code, inversely corresponding to the ones that the jumpers are connected to on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance: my pins are jumped from the BT_TX line to digital 6 (and BT_RX to pin 7), so in the code I write &lt;code&gt;#define TxD 7&lt;/code&gt;, and &lt;code&gt;RxD 6&lt;/code&gt;. This made the board's LEDs blink differently (red blinks on D2 until connection).&lt;/p&gt;&#xA;" OwnerUserId="4329" LastEditorUserId="37" LastEditDate="2014-10-09T23:42:50.423" LastActivityDate="2014-10-09T23:42:50.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4537" PostTypeId="2" ParentId="1138" CreationDate="2014-10-10T03:46:38.913" Score="7" Body="&lt;p&gt;I just happened to buy the same LCD Shields a few days ago, looking for a library to use it with a MEGA 2560 board I found &lt;a href=&quot;https://github.com/Smoke-And-Wires/TFT-Shield-Example-Code&quot;&gt;https://github.com/Smoke-And-Wires/TFT-Shield-Example-Code&lt;/a&gt; which supports both &lt;strong&gt;UNO&lt;/strong&gt; and &lt;strong&gt;MEGA&lt;/strong&gt; boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage is very, simple if we want to use it for &lt;strong&gt;MEGA&lt;/strong&gt; we should change the header &lt;code&gt;#include &quot;uno_24_shield.h&quot;&lt;/code&gt; in &lt;strong&gt;SWTFT.cpp&lt;/strong&gt; to &lt;code&gt;#include &quot;mega_24_shield.h&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Description (useful for adding suppport for the shield in other libraries):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incompatibility comes from different Port mappings for Arduino pin-out between Mega and UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in &lt;strong&gt;UNO&lt;/strong&gt; LCD shield will be connected through:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| LCD Data Bit  |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| Digital pin # |  7  |  6  |  5  |  4  |  3  |  2  |  9  |  8  |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| Uno port/pin  | PD7 | PD6 | PD5 | PD4 | PD3 | PD2 | PB1 | PB0 |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;strong&gt;MEGA&lt;/strong&gt; it will be connected through:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| LCD Data Bit  |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| Digital pin # |  7  |  6  |  5  |  4  |  3  |  2  |  9  |  8  |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;| MEGA port/pin | PH4 | PH3 | PE3 | PG5 | PE5 | PE4 | PH6 | PH5 |&#xA;+---------------+-----+-----+-----+-----+-----+-----+-----+-----+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4249" LastActivityDate="2014-10-10T03:46:38.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4538" PostTypeId="2" ParentId="4494" CreationDate="2014-10-10T14:02:01.293" Score="0" Body="&lt;p&gt;What I did wrong was using &lt;code&gt;|=&lt;/code&gt; instead of &lt;code&gt;=&lt;/code&gt; . Apparently Arduino set some of these Bits on start, which didn't change.&#xA;Now it works like a charm and I added a frequency choice, which works for at least 50,200,400,488 Hz. Everything in between should work aswell!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working testcode for timer1 with serial input of HIGH-time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PRESCALAR 8&#xA;#define PWM_FREQUENCY 50&#xA;#define TOP_VALUE F_CPU/(2*PRESCALAR*PWM_FREQUENCY)&#xA;&#xA;uint16_t dutytime = 1000; // this gives idle throttle signal&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(115200);&#xA;&#xA;  // TIMER 1&#xA;  DDRB |= (1&amp;lt;&amp;lt;DDB5); // D9 Output&#xA;&#xA;  // set 1000ms to start motors in idle mode&#xA;  OCR1A = 1000L;&#xA;&#xA;  // bits 7,5,3 PWM Output on pins A,B,C respectively (COMnx1)&#xA;  // bits 1,0 WGM1(1,0): phase correction mode&#xA;  TCCR1A = B10000010; // in hex: 0xAA for all 3 = B 1010 1010&#xA;  // bit 4,3 WGM_3,2: phase correction mode&#xA;  // bits 2,1,0 Prescalar: 8&#xA;  TCCR1B = B00010010; // in hex: 0x12; B 0001 0010&#xA;  ICR1 = TOP_VALUE;&#xA;}//setup&#xA;&#xA;&#xA;void loop(void) {&#xA;  // Serial.println(TOP_VALUE);&#xA;  dutytime = serial_input();&#xA;  if (dutytime) {&#xA;    OCR1A = dutytime;&#xA;  }&#xA;  delay(500);&#xA;}//loop&#xA;&#xA;&#xA;float serial_input() {&#xA;  double num = 0;&#xA;  while(Serial.available()) {&#xA;    delay(2);&#xA;    char ser = Serial.read();&#xA;    if(isDigit(ser)) {&#xA;      num = (num*10)+(ser-48);&#xA;    }else{ break; }&#xA;  }&#xA;  if (num) {Serial.println(num);}&#xA;  return num;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2014-10-15T11:59:01.333" LastActivityDate="2014-10-15T11:59:01.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4539" PostTypeId="2" ParentId="4500" CreationDate="2014-10-10T14:41:22.973" Score="1" Body="&lt;p&gt;Thank you all...&#xA;I found solution for my problem.&#xA;The circuit and the sketch isn't any problem. But I saw &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=122947.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; and I think problem is because of LC Studio's SD card. In previous circuit I connect 5v pin of SD card to 5v pin on arduino. But now I disconnect that and connect 3v3 pin on card to 3v3 on arduino.&#xA;Now it's work very nice. And I don't know &quot;why?&quot; . Any idea? &lt;/p&gt;&#xA;" OwnerUserId="3745" LastActivityDate="2014-10-10T14:41:22.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4540" PostTypeId="1" AcceptedAnswerId="11756" CreationDate="2014-10-10T16:29:49.010" Score="2" ViewCount="196" Body="&lt;p&gt;I'm trying to write a simple compiler in the Arduino language that I am making up for my lab.  The compiler will have to be able to turn a string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;do command_one 3 times&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a data structure that represents this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;command_one&amp;gt;, &amp;lt;command_one&amp;gt;, &amp;lt;command_one&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it should also be able to turn something more complicated like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;do do c_one do c_two 2 times 2 times c_thr 2 times&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a data structure that represents this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_thr&amp;gt; &amp;lt;c_one&amp;gt;&#xA;                &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_thr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another function will then read the commands out one by one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These examples show all of the functionality that I would want from the compiler.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having design issues for the compiler that I want to create.  Initially, I just wanted to do some string manipulation and turn the input string into an array of integers representing commands.  However, since the compiler will be outputting an arbitrarily large number of commands, and since arrays in Arduino need to be initialized with a length, this could be a problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not fluent in Arduino so I am hoping that an Arduino whiz can show me a quick solution.  I have already come up with the suggested solution on my own in Python, however, my solution in Python has to do with the ability to change the length of lists on the fly.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also notice that I posted the &lt;a href=&quot;https://stackoverflow.com/questions/26303582/simple-compiler-design-help-variable-length-arrays-for-c&quot;&gt;same question&lt;/a&gt; in the C++ stackexchange.  I am trying to write the same code for an Arduino and in C++.  I know that Arduino code is based on C++, if the answer is the same in Arduino as it is in C++ that would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="4335" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-05-12T10:49:54.590" Title="Simple compiler design help: Variable length arrays in Arduino?" Tags="|arduino-due|compile|" AnswerCount="3" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="4541" PostTypeId="2" ParentId="4540" CreationDate="2014-10-10T18:11:10.870" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;The Arduino IDE features nearly full C++ &lt;em&gt;language&lt;/em&gt; support (at least for C++03 features).&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;library&lt;/em&gt; support is limited, but any standard component you need, you should be able to get an open source implementation that compiles.&lt;/li&gt;&#xA;&lt;li&gt;That said, you have &lt;strong&gt;2K&lt;/strong&gt; of RAM to work with on an Arduino, so the kind of C++ code you would write for a general purpose computer just won’t get you very far.&lt;/li&gt;&#xA;&lt;li&gt;I could be wrong, but I very much doubt there are full Python implementations for Arduino.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Thanks to Mr. Penguin for pointing out that we’re dealing with an Arduino Due, not an Uno (I had overlooked the OP’s tag). 96K of memory is actually a decent amount to play with, so grab a library implementation like &lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; and use the C++ techniques you wish to use.&lt;/p&gt;&#xA;" OwnerUserId="353" LastEditorUserId="353" LastEditDate="2014-10-11T04:04:04.570" LastActivityDate="2014-10-11T04:04:04.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4542" PostTypeId="2" ParentId="4531" CreationDate="2014-10-10T19:35:18.847" Score="3" Body="&lt;p&gt;First off; when talking about I2C bus, an important point to clarify: did you connect pullup resistors to both &lt;strong&gt;SDA&lt;/strong&gt; and &lt;strong&gt;SCL&lt;/strong&gt; lines (&lt;code&gt;A4&lt;/code&gt; and &lt;code&gt;A5&lt;/code&gt; respectively)? Without those, the I2C bus will not work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I2C protocol is quite low-level and a bit complex; but fortunately, the &lt;strong&gt;Wire&lt;/strong&gt; library that comes with Arduino helps a lot and hides some of this complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using Wire library, there is a first point to keep in mind:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device address is 7 bits only, the 8th bit is used to define the direction of data (read or write). You don't need to care about this direction bit as Wire deals with it for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your situation, the device address is &lt;code&gt;0x6C&lt;/code&gt;, ie &lt;code&gt;1101100&lt;/code&gt; in binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands you mentioned that you want to send to the device, &lt;code&gt;0xD8 0x30 0x0A&lt;/code&gt; and &lt;code&gt;0xD8 0x06 0xD9&lt;/code&gt; already include the device address and the write bit (&lt;code&gt;0&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0xD8&lt;/code&gt; is &lt;code&gt;1101 1000&lt;/code&gt; ie &lt;code&gt;1101100&lt;/code&gt; plus the &lt;code&gt;0&lt;/code&gt; direction bit at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that &lt;code&gt;0xD8 0x06 0xD9&lt;/code&gt; is made of 2 commands actually:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0xD8 0x06&lt;/code&gt; is a write command to tell the device hich register we want to read&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0xD9&lt;/code&gt; is just the device address followed by the read bit (&lt;code&gt;1&lt;/code&gt;): this is the way the I2C master tells a slave that the former will now wait for data sent from the latter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is important to split this command in 2 because each will use a specific API from Wire library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing to your device with the Wire library will be done this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// First command: start measurement&#xA;Wire.beginTransmission(0x6C);&#xA;Wire.write(0x30);&#xA;Wire.write(0x0A);&#xA;Wire.endTransmission();&#xA;&#xA;// Second command: tell the device what register we want to read&#xA;Wire.beginTransmission(0x6C);&#xA;Wire.write(0x0A);&#xA;Wire.endTransmission();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can start reading from your device with a different API:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.requestFrom(0x6C, 3);&#xA;byte b1 = Wire.read();&#xA;byte b2 = Wire.read();&#xA;byte b3 = Wire.read();&#xA;// Now rebuild value from the 3 bytes just read...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;Wire.requestFrom(0x6C, 3);&lt;/code&gt; will send the &lt;code&gt;0xD9&lt;/code&gt; that is calculated from the device address &lt;code&gt;0x6C&lt;/code&gt; and the read bit. SO you don't have (and you should not) send &lt;code&gt;0xD9&lt;/code&gt; yourself, Wire doesit for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that I use &lt;code&gt;Wire.endTransmission()&lt;/code&gt; without the &lt;code&gt;stop&lt;/code&gt; argument. Not sure if this is mandatory, but it worked fine on my I2C experiments.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-10-10T19:35:18.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4543" PostTypeId="2" ParentId="4531" CreationDate="2014-10-10T22:15:09.167" Score="0" Body="&lt;p&gt;Ensure pullups (see datasheet for min acceptable resistance) are on I2C lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I didn't understand at first was where the Wire library would bit shift and add read/write indication bits.  And those start/stop booleans.  After some testing and a closer read of the docs, I got this to work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;#define BAR_7BIT_ADDR         (0x6C)&#xA;#define MAX_NUM_RX_BYTES      (5)&#xA;#define MAX_NUM_TX_BYTES      (3)&#xA;#define FIRST_TEMP_BYTE_INDEX (3)&#xA;&#xA;uint8_t new_rx_data;&#xA;uint8_t tx_buffer[MAX_NUM_TX_BYTES];&#xA;uint8_t rx_buffer[MAX_NUM_RX_BYTES];&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(57600);&#xA;  Wire.begin();&#xA;}&#xA;&#xA;void loop(void) {&#xA;  // If new data is available&#xA;  if (new_rx_data) {&#xA;    new_rx_data = false;&#xA;&#xA;    // Process the data in the background&#xA;    PrintRxData();&#xA;  }&#xA;&#xA;  BAR_RequestMeasurement();&#xA;  BAR_GetData();&#xA;&#xA;  // This is a bit of a hack to get this function to execute.&#xA;  // After attempting to register this function as a callback with&#xA;  // the Wire.onReceive() method the function wouldn't execute.&#xA;  BAR_OnDataReceived(0);&#xA;&#xA;  // Wait a tit, then do it again&#xA;  delay(500);&#xA;}&#xA;&#xA;void RequestMeasurement(void) {&#xA;  // MR: 0xD8 0x30 0x0A&#xA;  // Internal (to IC) register address&#xA;  tx_buffer[0] = 0x30;&#xA;  // Request-measurement command&#xA;  tx_buffer[1] = 0x0A;&#xA;  Wire.beginTransmission(BAR_7BIT_ADDR);&#xA;  Wire.write(tx_buffer, 2);&#xA;  Wire.endTransmission(true);&#xA;}&#xA;&#xA;void GetData(void) {&#xA;  // GD: 0xD8 0x06 0xD9 response from slave&#xA;  // Internal (to IC) register address&#xA;  tx_buffer[0] = 0x06;&#xA;  Wire.beginTransmission(BAR_7BIT_ADDR);&#xA;  Wire.write(tx_buffer, 1);&#xA;  Wire.endTransmission(false);&#xA;  Wire.requestFrom(BAR_7BIT_ADDR, 5, true);&#xA;}&#xA;&#xA;void OnDataReceived(int num_bytes) {  &#xA;  uint8_t i = 0;&#xA;  while (Wire.available() &amp;amp;&amp;amp; i &amp;lt; MAX_NUM_RX_BYTES) {&#xA;    rx_buffer[i++] = Wire.read();&#xA;  }&#xA;&#xA;  // Indicate to the background that there is new rx data&#xA;  new_rx_data = true;&#xA;}&#xA;&#xA;void PrintRxData(void) {&#xA;  Serial.print(&quot;Pressure [kPa]: &quot;);&#xA;  Serial.print(ToKpa(rx_buffer));&#xA;  Serial.print(&quot;\r\n&quot;);&#xA;&#xA;  Serial.print(&quot;Temperature [C]: &quot;);&#xA;  Serial.print(ToCelsius(&amp;amp;rx_buffer[FIRST_TEMP_BYTE_INDEX]));&#xA;  Serial.print(&quot;\r\n&quot;);&#xA;}&#xA;&#xA;// Returns the pressure in kPa given raw binary data&#xA;float ToKpa(uint8_t* raw_data) {&#xA;  // example: raw_data[3] = {0x63, 0x6C, 0xBB}; =&amp;gt; 101.81kPa&#xA;  // return ((float)((((uint32_t)raw_data[0]) * 65536) |&#xA;  //                  (((uint32_t)raw_data[1]) * 256)  |&#xA;  //                  (((uint32_t)raw_data[2]) * 1))) / 64.0 / 1000.0;&#xA;  return ((float)((&#xA;                  (((uint32_t)raw_data[0]) &amp;lt;&amp;lt; 16) |&#xA;                  (((uint32_t)raw_data[1]) &amp;lt;&amp;lt; 8)  |&#xA;                  (((uint32_t)raw_data[2]) &amp;lt;&amp;lt; 0)&#xA;                  ) &amp;gt;&amp;gt; 6)) / 1000.0;&#xA;}&#xA;&#xA;// Returns the temperature in Celsius given raw binary data&#xA;float ToCelsius(uint8_t* raw_data) {&#xA;  // example: raw_data[2] = {0x18, 0xE6}; =&amp;gt; 24.90C&#xA;  // return ((float)(((uint32_t)raw_data[0]) * 256) + (((uint32_t)raw_data[1]) * 1)) / 256.0;&#xA;  return ((float)(&#xA;                 (((uint32_t)raw_data[0]) &amp;lt;&amp;lt; 8) |&#xA;                 (((uint32_t)raw_data[1]) &amp;lt;&amp;lt; 0)&#xA;                 )) / 256.0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4325" LastActivityDate="2014-10-10T22:15:09.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4544" PostTypeId="2" ParentId="4540" CreationDate="2014-10-11T03:21:06.933" Score="2" Body="&lt;p&gt;You question isn't totally clear to me, so this is just a pile of advice:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I think that you &lt;em&gt;might&lt;/em&gt; be looking for a &lt;code&gt;run()&lt;/code&gt; type of command, where you can run any function in code. However, since C++ is a &lt;em&gt;compiled&lt;/em&gt; language, this is not possible. You can only do this in scripting languages.&lt;/li&gt;&#xA;&lt;li&gt;Besides that, you want a variable length array? I haven't been able to confirm that this works with Arduino, but I know in standard C++ it is called &lt;em&gt;dynamic memory allocation&lt;/em&gt; and you can do this with a pointer.&lt;/li&gt;&#xA;&lt;li&gt;As for the string to store your data, where you're heading is wrong if you care about efficiency. I'd go with an array of integers (&lt;code&gt;unsigned int myData[2] = {1, 290};&lt;/code&gt;) since you can store a &lt;em&gt;lot&lt;/em&gt; more data in two bytes than you could typing out the function names.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the &quot;multiple run&quot; function of your language, a simple for loop might work better to save space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int x = 5; x &amp;lt;3; x++) {&#xA;  //Code here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another thing you might want to do is store this &quot;code&quot; on a SD card encoded in two characters to yield a number like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte valOne = SD.read();&#xA;byte valTwo = SD.read();&#xA;int outputVal = (valOne &amp;lt;&amp;lt; 8) + valTwo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would solve the whole variable array crisis in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;End of unorganized thoughts...&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-10-11T03:21:06.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4545" PostTypeId="1" AcceptedAnswerId="4550" CreationDate="2014-10-11T06:24:11.670" Score="1" ViewCount="4499" Body="&lt;p&gt;I am trying to wire a fss1-102z 5v ssr relay to my arduino nano but i cant get it to work here is my circuit. It stays stuck on and i cant get it to turn off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SEXkJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bluetooth control code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char val;         // variable to receive data from the serial port&#xA;int ledpin = 2;  // LED connected to pin 2 (on-board LED)&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT&#xA;  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT&#xA;&#xA;    Serial.begin(9600);       // start serial communication at 115200bps&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;  if( Serial.available() )       // if data is available to read&#xA;  {&#xA;    ;&#xA;  }&#xA;  val = Serial.read();         // read it and store it in 'val'&#xA;&#xA;  if( val == 'a' )               // if 'a' was received led 2 is switched off&#xA;  {&#xA;    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2&#xA;  }&#xA;&#xA;  if( val == 'A' )               // if 'A' was received led 2 on&#xA;  {&#xA;    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2&#xA;  }&#xA;&#xA;  if( val == 'b' )               // if 'b' was received led 3 is switched off&#xA;  {&#xA;    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3&#xA;  }&#xA;&#xA;  if( val == 'B' )               // if 'B' was received led 3 on&#xA;  {&#xA;    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3&#xA;  } //else (ledpin = 3, LOW)        //set led pin 3 to low state&#xA;&#xA;  if( val == 'C' )               // if 'C' was received led 2 on for 1 second&#xA;  {&#xA;    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2&#xA;    delay(1000);                     // wait 1 second&#xA;    digitalWrite(ledpin, HIGH);      // turn Off pin 2&#xA;  }&#xA;&#xA;  if( val == 'D' )               // if 'D' was received led 3 on for 1 second&#xA;  {&#xA;    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3&#xA;    delay(1000);                     // wait 1 second&#xA;    digitalWrite(ledpin, HIGH);      // turn Off pin 3&#xA;  }&#xA;&#xA;  if( val == 'E' )               // if 'E' was received led 2 on for 5 seconds&#xA;  {&#xA;    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2&#xA;    delay(5000);                     // wait 500 milli seconds&#xA;    digitalWrite(ledpin, HIGH);      // turn Off pin 2&#xA;  }&#xA;&#xA;  if( val == 'F' )               // if 'F' was received led 3 on for 5 seconds&#xA;  {&#xA;    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3&#xA;    delay(5000);                     // wait 500 milli seconds&#xA;    digitalWrite(ledpin, HIGH);       // turn Off pin 3&#xA;  }&#xA;&#xA;  if( val == 'G' )               // if 'G' was received turn led pin 2 on for 500ms then switch off and turn on pin 3 for 500 mili seconds then off&#xA;  {&#xA;    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2&#xA;    delay(500);                     // wait 500mili second&#xA;    digitalWrite(ledpin, HIGH);      // turn Off pin 2&#xA;    digitalWrite(ledpin = 3, LOW);  // turn ON pin 2&#xA;    delay(500);                     // wait 500 mili second&#xA;    digitalWrite(ledpin, HIGH);      // turn Off pin 2&#xA;  }&#xA;&#xA;  if( val == 'h' )               // if 'h' was received switch off all pins&#xA;  {&#xA;    digitalWrite(ledpin = 13, LOW);    // turn Off pin 13&#xA;    digitalWrite(ledpin = 2, HIGH);      // turn Off pin 2&#xA;    digitalWrite(ledpin = 3, HIGH);      // turn Off pin 3&#xA;}&#xA;&#xA;  if( val == 'H' )               // if 'H' was received switch pin 2 on and off 1000 times&#xA;&#xA;  for(int i = 0; i &amp;lt; 1000; i++)&#xA;  {&#xA;    digitalWrite(ledpin = 2, HIGH);  // turn ON pin 2&#xA;   delay (1000); //wait 1000 mili seconds&#xA;    digitalWrite(ledpin = 2, LOW);  // turn Off pin 2&#xA;   delay (1000); //wait 1000 mili seconds&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3584" LastEditorUserId="84" LastEditDate="2014-10-11T13:16:20.400" LastActivityDate="2014-10-13T07:02:25.023" Title="How do you wire a ssr relay to a arduino nano" Tags="|arduino-nano|relay|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4546" PostTypeId="1" CreationDate="2014-10-11T06:32:13.040" Score="1" ViewCount="921" Body="&lt;p&gt;I need to emulate a component that measures an input mechanically and varies resistance from 0 to infinity (a more detailed set of specs list it at 20-1,000ohms, though I'll have to actually check its true values myself once I have physical access to it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim is to replace this troublesome mechanical component with a current (read as available and serviceable) component, and convert the signal from the new component into an emulated signal (varying resistance) from the old component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not certain as to the resolution required (how big the steps can be), though it may be able to handle 50ohm 'leaps', just judging by the range of mechanical movement and my past experience with replacing similar mechanical systems with ready-made kits for conversions.  I'd like to smooth the curve a whole lot more than 50ohm leaps though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have barely an idea where to begin on this.  I thought maybe a resistor ladder and a set of transistors triggered by the arduino to connect into the different points in the line, though I suspect there has to be a better way to achieve a much better result (and I don't think I have enough outputs for that anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a digital component that can vary its resistance using a PWM signal or maybe an analog signal from an arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI, I greatly appreciate your input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The controller provides a constant voltage to the component, and the controller then looks at the ground (the voltage over a static resistor) I presume. It is an actual load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I may be able to provide a variable voltage to the controller on its ground pin, though I have never seen that done on them before. I think that may be the trick, though the controller may(??) dislike it? I can try that.. The next best thing (only 2nd because it requires more components) would be the digital pot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone ever forged a return signal on a circuit thats supposed to supply its own constant voltage to a resistor type sensor?&lt;/p&gt;&#xA;" OwnerUserId="4337" LastEditorUserId="407" LastEditDate="2014-10-12T22:32:38.230" LastActivityDate="2014-10-12T22:32:38.230" Title="Adjust resistance of a circuit" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4547" PostTypeId="2" ParentId="4546" CreationDate="2014-10-11T07:42:36.597" Score="3" Body="&lt;p&gt;What about a digital potentiometer&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Digital_potentiometer&quot; rel=&quot;nofollow&quot;&gt;Digital Pot&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many types available, generally controlled via a serial interface e.g SPI&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2014-10-11T07:42:36.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4548" PostTypeId="2" ParentId="4545" CreationDate="2014-10-11T08:31:59.913" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;Is it really 5v relay?&lt;/li&gt;&#xA;&lt;li&gt;Need your code.&lt;/li&gt;&#xA;&lt;li&gt;Check your output is really 5v.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You do a lot of mistakes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Int ledPin2=2;&#xA;Int ledPin3=3;&#xA;...&#xA;pinMode(ledPin2,OUTPUT);&#xA;pinMode(ledPin3,OUTPUT);&#xA;...&#xA;digitalWrite(ledPin2,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am on way now. I will edit and my answer when get back. Now correct your code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should improve your code... I edited it with switch cases. Also edit your comments because they are wrong!!! In the end there is &lt;code&gt;Serial.printout&lt;/code&gt; states of pins. If you want uncomment them.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the edited code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char val;         // variable to receive data from the serial port&#xA;int ledpin2 = 2, ledpin3 = 3, ledpin13 = 13;  // LED connected to pin 2 (on-board LED)&#xA;bool status = true;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledpin2, OUTPUT); // pin 2 (on-board LED) as OUTPUT&#xA;  pinMode(ledpin3, OUTPUT); // pin 3 (on-board LED) as OUTPUT&#xA;  pinMode(ledpin13, OUTPUT);&#xA;  Serial.begin(9600);       // start serial communication at 115200bps&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;  if( Serial.available() )       // if data is available to read&#xA;  {&#xA;  val = Serial.read();         // read it and store it in 'val'&#xA;  switch (val){&#xA;    case 'a':&#xA;    digitalWrite(ledpin2, HIGH);    // turn ON pin 2&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'A':&#xA;    digitalWrite(ledpin2, LOW);&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'b':&#xA;    digitalWrite(ledpin3, HIGH);&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'B':&#xA;    digitalWrite(ledpin3, LOW);&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'C':&#xA;    digitalWrite(ledpin2, LOW);  // turn OFF pin 2&#xA;    delay(1000);                     // wait 1 second&#xA;    digitalWrite(ledpin2, HIGH);      // turn ON pin 2&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'D':&#xA;    digitalWrite(ledpin3, LOW);  // turn OFF pin 3&#xA;    delay(1000);                     // wait 1 second&#xA;    digitalWrite(ledpin3, HIGH);      // turn ON pin 3&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'E':&#xA;    digitalWrite(ledpin2, LOW);       // turn OFF pin 2&#xA;    delay(5000);                      // wait 500 milli seconds&#xA;    digitalWrite(ledpin2, HIGH);      // turn ON pin 2&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'F':&#xA;    digitalWrite(ledpin3, LOW);  // turn ON pin 3&#xA;    delay(5000);                     // wait 500 milli seconds&#xA;    digitalWrite(ledpin3, HIGH);       // turn Off pin 3&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'G':&#xA;    digitalWrite(ledpin2, LOW);  // turn ON pin 2&#xA;    delay(500);                     // wait 500mili second&#xA;    digitalWrite(ledpin2, HIGH);      // turn Off pin 2&#xA;    digitalWrite(ledpin3, LOW);  // turn ON pin 2&#xA;    delay(500);                     // wait 500 mili second&#xA;    digitalWrite(ledpin3, HIGH);      // turn Off pin 2&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'h':&#xA;    digitalWrite(ledpin13, LOW);    // turn Off pin 13&#xA;    digitalWrite(ledpin2, HIGH);      // turn Off pin 2&#xA;    digitalWrite(ledpin3, HIGH);      // turn Off pin 3&#xA;    status = true;&#xA;    break;&#xA;&#xA;    case 'H':&#xA;    for(int i = 0; i &amp;lt; 1000; i++)&#xA;  {&#xA;    digitalWrite(ledpin2, HIGH);  // turn ON pin 2&#xA;    delay (1000); //wait 1000 mili seconds&#xA;    digitalWrite(ledpin2, LOW);  // turn Off pin 2&#xA;    delay (1000); //wait 1000 mili seconds&#xA;  }&#xA;  status = true;&#xA;    break;&#xA;  }&#xA;  }&#xA;&#xA;  /* Print out state of pin */&#xA;  /*&#xA;  if (status) {&#xA;   Serial.print(&quot;ledpin2 = &quot;);&#xA;   Serial.print(bitRead(PORTD,2));&#xA;   Serial.print(&quot; ,ledpin3 = &quot;);&#xA;   Serial.print(bitRead(PORTD,3));&#xA;   Serial.print(&quot; ,ledpin13 = &quot;);&#xA;   Serial.println(bitRead(PORTD,7));&#xA;   status = false;&#xA;  }*/&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-13T07:02:25.023" LastActivityDate="2014-10-13T07:02:25.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4549" PostTypeId="1" AcceptedAnswerId="4553" CreationDate="2014-10-11T11:38:17.700" Score="1" ViewCount="462" Body="&lt;p&gt;I have Arduino IDE 1.0.5 in win7 x64. I have so many library units. A pity that I can't scroll down to my other options. Is it Arduino.exe's problem or something else? How can I add triangle to scroll down and scroll up to see whole Sketchbook and Examples list? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/feW18.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2014-10-13T16:44:29.193" Title="I can't scroll Arduino IDE's example &amp; scketch lists down" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4550" PostTypeId="2" ParentId="4545" CreationDate="2014-10-11T11:59:11.840" Score="2" Body="&lt;p&gt;According to its &lt;a href=&quot;http://www.ateco.it/pdf/art058_fss1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;, the &lt;code&gt;FSS1-102Z&lt;/code&gt; doesn't work with DC-voltage. Also the minimal voltage required is 50VAC. Here is the excerpt from the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TudEW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="84" LastEditDate="2014-10-11T17:04:11.650" LastActivityDate="2014-10-11T17:04:11.650" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4551" PostTypeId="2" ParentId="4549" CreationDate="2014-10-11T12:09:59.600" Score="0" Body="&lt;p&gt;You can get to the examples in Explorer. Just go to &lt;code&gt;My Documents&lt;/code&gt;\ &lt;code&gt;Arduino&lt;/code&gt;\ &lt;code&gt;libraries&lt;/code&gt;\ &lt;code&gt;&amp;lt;library-name&amp;gt;&lt;/code&gt;\ &lt;code&gt;examples&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one made me chuckle. Thank you for sharing.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-11T12:09:59.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4553" PostTypeId="2" ParentId="4549" CreationDate="2014-10-11T14:17:18.120" Score="2" Body="&lt;p&gt;Try using 1.5.+. It has scroll arrows to allow larger lists of menus, bigger than the screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find that most, if not all, sketches work equally well, if not better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Up to 1.5.6r2 uses the same version of compiler as 1.0.+'s. 1.5.7 and newer uses a new compiler, that is more sctrict. All stock libraries work. And well written 3rd parties work. I personally use 1.5 and test backwards to 1.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a fork of 1.0 called ERW that has the scrolling. But 8t is becoming obsolete.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="46" LastEditDate="2014-10-13T16:44:29.193" LastActivityDate="2014-10-13T16:44:29.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4555" PostTypeId="1" CreationDate="2014-10-11T17:34:32.090" Score="3" ViewCount="1063" Body="&lt;p&gt;I will start an Arduino project and its main requirement is that some RFID readers (at most 6 readers) be connected and controled by the arduino board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have a strong background in eletronics, and therefore I do not have any idea in how to start it. Is it possible to connect more than one RFID reader to an Arduino board? If it is possible, which reader is the best for this porpouse?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another requirement of this project is the need to send the data collected by each RFID reader to a PC server through WIFI. For this what is better to use, an Arduino UNO with a WIFI shield or an Arduino YUN? What is better and why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!!!&lt;/p&gt;&#xA;" OwnerUserId="4342" LastEditorUserId="84" LastEditDate="2014-10-11T19:46:38.123" LastActivityDate="2014-10-11T19:46:38.123" Title="Hub RFID Arduino + WIFI" Tags="|arduino-uno|arduino-yun|wifi|rfid|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4556" PostTypeId="1" AcceptedAnswerId="4557" CreationDate="2014-10-11T16:44:54.813" Score="10" ViewCount="35072" Body="&lt;p&gt;I'm new to Arduino, and I am trying a couple of tutorials. What does this line do in a program?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (! Serial); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Brendan" LastActivityDate="2014-10-11T19:10:39.460" Title="What does the line &quot;while (! Serial);&quot; do in an Arduino program?" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4557" PostTypeId="2" ParentId="4556" CreationDate="2014-10-11T16:52:26.603" Score="12" Body="&lt;p&gt;On boards with an FT232 chip or other USB-&gt;Serial bridge chip (Uno, Mega, etc) it does absolutely nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On boards with a direct USB connection, such as the Leonardo or the Yùn it waits for an active serial connection to be established by the PC (i.e., for the serial port to be opened by a piece of software).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you open the serial port of a board like the Uno or Mega the whole board usually resets&lt;sup&gt;*&lt;/sup&gt;, so opening the serial port allows you to see the first bits of the serial data.  On the Leonardo etc it doesn't reset when you open the serial, so any serial output during the setup() function would be missed.  Adding that line makes the board pause until you open the serial port, so you get to see that initial bit of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*) Unless you specifically write some software that doesn't assert DTR when you open the port&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastEditorUserId="4143" LastEditDate="2014-10-11T19:10:39.460" LastActivityDate="2014-10-11T19:10:39.460" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4559" PostTypeId="1" CreationDate="2014-10-12T02:42:54.583" Score="0" ViewCount="364" Body="&lt;p&gt;I am using the Arduino WifiWebClient to insert records into a RoR (Ruby on Rails) app. It works but it only inserts one field regardless of the number of arguments I send. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I test with Curl&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -d &quot;sale[itemId]=1234&amp;amp;sale[machineId]=4567&quot;  http://myapp.herokuapp.com/sales&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will create a Sale record and populate both fields itemId and machineId. Everything OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I send the following instruction from the Arduino, it will only populate the first field:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am only including the POST method to simplifly the code, the rest of the code is similar to &lt;a href=&quot;http://arduino.cc/en/Reference/WiFiClient&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/WiFiClient&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendPOST() //client function to send/receive POST request data.&#xA;{&#xA;if (client.connect(URL,PORT)) {  //starts client connection, checks for connection&#xA;Serial.println(&quot;connected&quot;);&#xA;&#xA;Serial.println(&quot;POST /sales HTTP/1.1&quot;); //download text&#xA;Serial.println(&quot;From: Arduino1&quot;);&#xA;Serial.println(&quot;Host: evening-sierra-3769.herokuapp.com&quot;);&#xA;Serial.println(&quot;User-Agent: HTTPTool/1.1&quot;);&#xA;Serial.println(&quot;Connection: close&quot;);&#xA;Serial.println(&quot;Cache-Control : no-cache&quot;);&#xA;Serial.println(&quot;Pragma: no-cache&quot;);&#xA;Serial.println(&quot;Expires: -1&quot;);&#xA;Serial.println(&quot;Content-Type: application/x-www-form-urlencoded&quot;);&#xA;Serial.print(&quot;Content-Length: &quot;);&#xA;Serial.println(31);&#xA;Serial.println();&#xA;Serial.println(&quot;sale[machineId]=\&quot;09876543211234\&quot;&quot;);&#xA;Serial.println(&quot;sale[itemId]=\&quot;09876543211234\&quot;&quot;);&#xA;Serial.println();&#xA;&#xA;client.println(&quot;POST /sales HTTP/1.1&quot;); //download text&#xA;client.println(&quot;From: Arduino1&quot;);&#xA;client.println(&quot;Host: evening-sierra-3769.herokuapp.com&quot;);  // Will be needed if apache is configured for VHOSTS&#xA;client.println(&quot;User-Agent: HTTPTool/1.1&quot;);&#xA;client.println(&quot;Connection: close&quot;);&#xA;client.println(&quot;Cache-Control : no-cache&quot;);&#xA;client.println(&quot;Pragma: no-cache&quot;);&#xA;client.println(&quot;Expires: -1&quot;);&#xA;client.println(&quot;Content-Type: application/x-www-form-urlencoded&quot;);&#xA;client.print(&quot;Content-Length: &quot;);&#xA;client.println(31);&#xA;client.println();&#xA;client.println(&quot;sale[machineId]=09876543211234\r\n&quot;);&#xA;client.println(&quot;sale[itemId]=09876543211234\r\n&quot;);&#xA;client.println();&#xA;&#xA;Serial.println(&quot;ARDUINO: HTTP message sent&quot;);&#xA;delay(3000);&#xA;if(client.available())&#xA;{&#xA;  Serial.println(&quot;ARDUINO: HTTP message received&quot;);&#xA;  Serial.println(&quot;ARDUINO: printing received headers and script response...\n&quot;);&#xA;&#xA;  while(client.available())&#xA;  {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;else&#xA;{&#xA;  Serial.println(&quot;ARDUINO: no response received / no response received in time&quot;);&#xA;}&#xA;&#xA;client.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4347" LastActivityDate="2015-02-09T06:22:48.403" Title="Cannot send two arguments from a WebClient" Tags="|arduino-uno|wifi|shields|web-service|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4560" PostTypeId="2" ParentId="4559" CreationDate="2014-10-12T04:22:12.537" Score="1" Body="&lt;p&gt;Solved!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changed the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;Content-Type: multipart/form-data&quot;);   &#xA;client.print(&quot;Content-Length: &quot;);&#xA;client.println(63);&#xA;client.println();&#xA;client.println(&quot;sale[itemId]=123456789012341234&amp;amp;sale[machineId]=123456789012341234\r\n&quot;);&#xA;client.println(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4347" LastActivityDate="2014-10-12T04:22:12.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4561" PostTypeId="1" CreationDate="2014-10-12T08:16:01.597" Score="3" ViewCount="753" Body="&lt;p&gt;I'm developing an active sonar using Costas arrays and Golomb rulers. I need the Arduino to switch between frequencies very quickly to shorten the length of the ping, both to improve processing and to lessen speed of sound limitations. I also need to know the exact times each frequency will be released from the Arduino so the real time computer can ignore those frequencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to generate the melodies I want using the &lt;code&gt;tone()&lt;/code&gt; command, but I couldn't find the time required to change frequencies or the standard deviation of that time. I'm also not sure what the minimum length of PWM is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I want to know, what is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The switching time for changing PWM frequencies&lt;/li&gt;&#xA;&lt;li&gt;The standard deviation of that switching time&lt;/li&gt;&#xA;&lt;li&gt;The minimum length PWM pulse that can be generated&lt;/li&gt;&#xA;&lt;li&gt;The standard deviation of the length of that minimum PWM pulse.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And how might I achieve those minimums?&lt;/p&gt;&#xA;" OwnerUserId="4350" LastEditorUserId="10794" LastEditDate="2015-08-22T05:55:33.263" LastActivityDate="2015-08-22T05:55:33.263" Title="tone() and PWM limits" Tags="|pwm|timers|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4562" PostTypeId="2" ParentId="4462" CreationDate="2014-10-12T08:30:53.803" Score="1" Body="&lt;p&gt;You can configure the ublox lea6H GPS to read either through NMEA protocol or the UBX protocol. You just need to send some configuration messages. For good data rate it is better to use UBX protocol as it gives data in binary format inducing less delay.In case you need to test your device you can use my GPS code for arduino mega - customized ardupilot gps code  - UBX protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ksskarthik/Team_Pushpak/blob/master/TP_GPS&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ksskarthik/Team_Pushpak/blob/master/TP_GPS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4351" LastActivityDate="2014-10-12T08:30:53.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4564" PostTypeId="1" CreationDate="2014-10-12T10:02:22.487" Score="0" ViewCount="201" Body="&lt;p&gt;Does somebody know if the &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow&quot;&gt;IRremote library&lt;/a&gt; is compatible with Moteino boards? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, do you know a cheap solution to build a IR-remote controllable via wireless?&lt;/p&gt;&#xA;" OwnerUserId="4352" LastEditorUserId="6936" LastEditDate="2016-02-21T08:02:08.233" LastActivityDate="2016-02-21T08:02:08.233" Title="IRremote library and Moteino" Tags="|wifi|ir|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4565" PostTypeId="1" AcceptedAnswerId="4570" CreationDate="2014-10-12T11:45:42.483" Score="1" ViewCount="1789" Body="&lt;p&gt;We are building an outdoor snow melting system for the pavement. It would be nice if it could turn on itself only when it is needed: if there is snow, ice in the surface or the pavement is wet and the temperature is below the freezing point. Is there a good way to detect if the surface of something is snowy, icy or wet?&lt;/p&gt;&#xA;" OwnerUserId="87" LastActivityDate="2021-01-05T19:57:40.697" Title="How to sense snow and ice?" Tags="|sensors|automatization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4566" PostTypeId="1" AcceptedAnswerId="4569" CreationDate="2014-10-12T12:45:52.953" Score="4" ViewCount="2138" Body="&lt;p&gt;I'm new to Arduino and also new to electronics. I'm following the tutorial &lt;a href=&quot;http://arduino.cc/en/Tutorial/DigitalReadSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I'm not understanding the importance of the resistor in this schematic diagram. Can someone please help me on this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ilSHW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4354" LastActivityDate="2017-03-10T08:55:05.980" Title="Importance of resistor" Tags="|resistor|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4567" PostTypeId="2" ParentId="4566" CreationDate="2014-10-12T13:12:19.957" Score="4" Body="&lt;p&gt;Without the resistor, closing the switch would connect the positive supply directly to the negative supply. This would cause the voltage across all digital components in the circuit to drop close to 0V, &lt;strong&gt;crashing the whole thing&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-12T13:12:19.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4568" PostTypeId="2" ParentId="4546" CreationDate="2014-10-12T13:23:27.363" Score="2" Body="&lt;p&gt;A &lt;a href=&quot;http://en.wikipedia.org/wiki/JFET&quot; rel=&quot;nofollow&quot;&gt;JFET&lt;/a&gt; can act as a voltage-controlled resistor. It will need additional components if you require precision (a shunt resistor and a couple of op amps come to mind), but it should do. JFETs are rarer than they used to be, but still should be available for a few decades.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-12T13:23:27.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4569" PostTypeId="2" ParentId="4566" CreationDate="2014-10-12T18:10:13.543" Score="10" Body="&lt;p&gt;That resistor, where positioned, is called a pull-down resistor, and if replaced by a straight wire, that circuit would short out when the switch was closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of this is that when a digital input pin is not connected, it floats, and if the switch were open that pin could see upwards of 2v floating value from external and internal noise. With Digital circuitry, any value in this float range can be invalid and return invalid results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A pull down resistor will generally have a very high ohmic value &gt;5kohm, as to allow as little current pass as possible. Here, you are shorting the pin to ground through the resistor so it will not have a LOW value when the switch is open, instead of possibly invalid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the switch is closed, you will have 5v passing through switch into the pin, to be read as a HIGH value, also sending 5v across a 10k or so resistor to ground, consuming only .5mA of current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It you want to see what I mean by a floating value, debug the output of any analog pin with a wire going nowhere, and watch as the value changes. Try touching the wire, now add a pull down to ground, or try pulling it up to 5v and observe the behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy Arduinoing!&lt;/p&gt;&#xA;" OwnerUserId="407" LastEditorUserId="407" LastEditDate="2014-10-19T22:28:19.790" LastActivityDate="2014-10-19T22:28:19.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4570" PostTypeId="2" ParentId="4565" CreationDate="2014-10-12T18:15:18.970" Score="7" Body="&lt;p&gt;If the pavement is black, you could detect snow by infrared reflectivity. You might detect wet by resistivity. That leaves ice. Reflectivity might work there, too, at a different threshold. You'd need to experiment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility might be a short-range sonar. If the measured distance changes, something is there. Ice would probably read as nearer. You'd probably need to average a number of measurements to increase the measurement resolution; you care about very thin ice coatings. Snow might well read as no return - but again, experiment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A combination of the reflectivity and sonar might be the most reliable.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-10-12T18:15:18.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4571" PostTypeId="2" ParentId="3787" CreationDate="2014-10-12T18:18:43.777" Score="0" Body="&lt;p&gt;I have the same display. It has ILI9137 chip using 8-bit mode, so original Henning Karlsen UTF library doesn't work. You can find this library patched to support this display using Arduino MEGA at &lt;a href=&quot;https://github.com/dgolda/UTFT&quot; rel=&quot;nofollow&quot;&gt;https://github.com/dgolda/UTFT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If display wouldn't work it is probably broken. I've received first piece broken - only backlight was working, but second and third was OK.&lt;/p&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2014-10-12T18:18:43.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4572" PostTypeId="1" AcceptedAnswerId="4573" CreationDate="2014-10-12T18:31:59.523" Score="9" ViewCount="10378" Body="&lt;p&gt;I have got some difficulties understanding the memory management.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in program memory. I think of it as embedded somewhere in the code segment, which must be fairly possible inside a von-Neumann-architecture. I want to make use from that to make my UI menu on a LCD possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm bewildered by those instructions to just read and print data from program memory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strcpy_P(buffer, (char*)pgm_read_word(&amp;amp;(string_table[i]))); // Necessary casts and dereferencing, just copy. &#xA;    Serial.println( buffer );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why on earth do I have to copy the damn content to RAM before accessing it? And if this is true, what happens to all the code then? Is it also loaded to RAM before execution? How is the code (32kiB) handled then with only 2kiB RAM? Where are those little goblins carrying floppy disks?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And even more interesting: What happens to literal constants like in this expression:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 5*(10+7)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are 5, 10 and 7 really copied to RAM before loading them into registers? I just can't believe that.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-07-05T02:39:22.427" Title="PROGMEM: do I have to copy data from flash to RAM for reading?" Tags="|flash|progmem|memory-usage|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4573" PostTypeId="2" ParentId="4572" CreationDate="2014-10-12T18:43:27.130" Score="10" Body="&lt;p&gt;AVR is a modified &lt;a href=&quot;http://en.wikipedia.org/wiki/Harvard_architecture&quot;&gt;Harvard architecture&lt;/a&gt; family, so code is stored in flash only, whereas data exists primarily in RAM when being manipulated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, let's address your questions.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why on earth do I have to copy the damn content to RAM before accessing it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't need to per se, but by default code assumes that data is in RAM unless the code is modified to specifically look in flash for it (such as with &lt;code&gt;strcpy_P()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And if this is true, what happens to all the code then? Is it also loaded to RAM before execution?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nope. Harvard architecture. See the Wikipedia page for the full details.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How is the code (32kiB) handled then with only 2kiB RAM?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The preamble generated by the compiler copies the data that should be modifiable/modified into SRAM before running the actual program.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Where are those little goblins carrying floppy disks?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Dunno. But if you happen to see them then there's nothing I can do to help.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... are 5, 10 and 7 really copied to RAM before loading them into registers?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nah. The compiler evaluates the expression at compile time. Whatever else happens depends on the lines of code around it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-12T18:43:27.130" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4576" PostTypeId="2" ParentId="4566" CreationDate="2014-10-13T01:25:40.293" Score="4" Body="&lt;p&gt;In the above circuit there are several other resistances that are being ignored for simplicity and because most of them are extremely tiny. However, one of the resistances is significant, and that it the internal resistance of the power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the resistor shown in the schematic, the internal resistance of the battery becomes the most significant resistance in the circuit and the voltage measure at D2 would remain near zero when the switch is closed and very near zero when the switch is opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the resistor shown were several thousand ohms or greater, the voltage at D2 would measure close to 5 volts when the switch is closed and zero when the switch is open (however D2 will be subject to picking up any nearby static electricity or strong electromagnetic fields when the switch is open).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent D2 from being subject to spurious noise, resistors are often used between signal points and ground to dampen any such undesired noise. To better imagine how this works, imagine a 100 megohm resistor connected to D2 with the other end hanging out into the air. The unconnected end of the large resistor is acting like an antenna picking up any possible noise in the vicinity. Because the resistor shown in the diagram is so much smaller then the imaginary resistor, the noise will seem to be shorted out to ground in comparison. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a very real sense, this schematic is telling you to add in a known resistor to ground or suffer from the effects of all the resistors not show; some being very very high resistance and some being nearly non-existent.&lt;/p&gt;&#xA;" OwnerUserId="4363" LastEditorUserId="42" LastEditDate="2014-10-14T15:15:31.567" LastActivityDate="2014-10-14T15:15:31.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4577" PostTypeId="1" CreationDate="2014-10-13T07:28:09.040" Score="0" ViewCount="454" Body="&lt;p&gt;I am looking for cheap way to have very basic wireless communication between an Arduino and a iphone.&#xA;I don't need to send complex data, it would be sufficient to &quot;trigger&quot; the arduino: let's say it is reading a certain pin voltage and waiting for it to be up in order to do stuff, my goal is to trigger this pin up by any (wireless and iphone friendly) mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have figured out two solutions: wi-fi shield, cheap RF transceiver. The problem with the latter is that it is not trivial to communicate with a RF transceiver from an iphone. I should add another arduino controlling an RF transceiver on the iphone side and commanding this arduino with an usb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wi-fi shield on the other hand is too expensive. Even small routers such as the wr703n (30 euro more or less) is too expensive in my opinion. I just want to send a &quot;bit&quot; of information, so I don't want to spend more than 10 euro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third option would be to hack some cheap wi-fi controlled tool, such a lamp or plug: do you know any?&#xA;Do you have any other idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4352" LastActivityDate="2014-10-13T09:43:46.743" Title="Cheap arduino wi-fi TRIGGER" Tags="|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4578" PostTypeId="2" ParentId="4577" CreationDate="2014-10-13T09:43:46.743" Score="3" Body="&lt;p&gt;WiFi you either need a WiFi router or for either the iPhone or Arduino to create a network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RF transceiver you need external circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The common way to do this at the moment is using Bluetooth Low Energy. Using a Bluetooth Low Energy (BLE) shield you can directly connect the Arduino to a modern iPhone or Android phone (supporting Bluetooth 4.0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out redbearlabs, who have a range of shields and BLE-enabled Arduino clones. There are example sketches and iOS apps on the net. I have made a BLE controlled RGB light using the redbearlabs BlendMicro and example OSX application.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-13T09:43:46.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4579" PostTypeId="2" ParentId="4564" CreationDate="2014-10-13T09:54:10.213" Score="1" Body="&lt;p&gt;You need two spare digital pins to use the IR-library. These pins can be set to whatever you like. Pins D3 to D7 are free on the Moteino so the library will be OK to use if you connect the IR LED and receiver to two of those pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/COq75.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-13T09:54:10.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4580" PostTypeId="1" AcceptedAnswerId="4600" CreationDate="2014-10-13T11:44:01.197" Score="4" ViewCount="18641" Body="&lt;p&gt;I have trouble compiling this sketch. The error I get is&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'SoftwareSerial' does not name a type&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any ideas how could I fix it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include SoftwareSerial.h&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;Ready!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;&#xA;  // for HC-05 use 38400 when poerwing with KEY/STATE set to HIGH on power on&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4367" LastEditorUserId="37" LastEditDate="2014-10-13T13:29:12.773" LastActivityDate="2018-07-12T07:56:12.707" Title="Error: 'SofwareSerial' does not name a type" Tags="|programming|softwareserial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4581" PostTypeId="2" ParentId="4564" CreationDate="2014-10-13T11:55:00.033" Score="0" Body="&lt;p&gt;Your Arduino do not need to be wireless to be able to control it wirelessly. &#xA;If you have a wireless network at home (which most people do), there is usally some ethernet RJ45 ports as well. &#xA;So instead you use a very cheap ENC28J60 to connect your arduino to the network. You can then access your Arduino wirelessly through your home router. As long as it is connected to your local network its should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for connecting the IR sender and reciever, you need as said before, one digital pin for recieving IR-signals and one digital pin for sending. Which should be no problem even when adding the ENC28J60. It should also work very well with the Moteino if you choose to go that way.&lt;/p&gt;&#xA;" OwnerUserId="1357" LastActivityDate="2014-10-13T11:55:00.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4582" PostTypeId="2" ParentId="4580" CreationDate="2014-10-13T12:00:38.627" Score="8" Body="&lt;p&gt;You forgot the quotation marks, try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SoftwareSerial.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-13T12:00:38.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4583" PostTypeId="1" AcceptedAnswerId="4584" CreationDate="2014-10-10T16:05:09.923" Score="0" ViewCount="188" Body="&lt;p&gt;I'm trying to write a simple compiler in C++ for a language that I am making up for my lab.  The compiler will have to be able to turn a string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;do command_one 3 times&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a data structure that represents this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;command_one&amp;gt;, &amp;lt;command_one&amp;gt;, &amp;lt;command_one&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it should also be able to turn something more complicated like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;do do c_one do c_two 2 times 2 times c_thr 2 times&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into a data structure that represents this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_thr&amp;gt; &amp;lt;c_one&amp;gt;&#xA;                &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_one&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_two&amp;gt; &amp;lt;c_thr&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another function will then read the commands out one by one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These examples show all of the functionality that I would want from the compiler.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having design issues for the compiler that I want to create.  Initially, I just wanted to do some string manipulation and turn the input string into an array of integers representing commands.  However, since the compiler will be outputting an arbitrarily large number of commands, and since arrays in C++ need to be initialized with a length, this could be a problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not fluent in C++ so I am hoping that a C++ whiz can show me a quick solution.  I have already come up with the suggested solution on my own in Python, however, my solution in Python has to do with the ability to change the length of lists on the fly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I am also intending to use this code for an Arduino, which supports C++ code but not the standard libraries.  I found the vector solution to work in my C++ code, but it will not work in the Arduino interface.  Is there a way to do the compiling WITHOUT using vectors? &lt;/p&gt;&#xA;" OwnerUserId="4335" OwnerDisplayName="Paul Terwilliger" LastActivityDate="2014-10-13T12:46:32.507" Title="Simple compiler design help: Variable length arrays?" Tags="|c++|" AnswerCount="2" CommentCount="5" ClosedDate="2014-10-13T21:00:13.577" ContentLicense="CC BY-SA 3.0" />
  <row Id="4584" PostTypeId="2" ParentId="4583" CreationDate="2014-10-10T16:16:01.853" Score="3" Body="&lt;p&gt;In C++ there is a std library container called vector you can use to create variable length arrays. You can use it like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;vector&amp;gt;&#xA;// ...&#xA;std::vector&amp;lt;int&amp;gt; commands;&#xA;// ...&#xA;// parse string and generate commands, add your commands with push_back&#xA;commands.push_back(new_command);&#xA;// and you can access elements in the array like normal&#xA;commands[0];&#xA;// and also see how many elements are in the array&#xA;commands.size();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also want to mention the std stack, which I think would be a helpful class for managing the states of your nested loops. Each time your interpreter enters a new loop for example, push to the top of the stack how many times to run, and each iteration count down till 0 and pop (just as an example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Because you can't use vectors C++ also supplies the new and delete keywords to dynamically allocate and delete memory. However as arduino has really low memory I don't recommend trying to implement an expansible array on this.&#xA;This post here mentions that program memory and global memory is shared on 2K: &lt;a href=&quot;https://stackoverflow.com/a/16281821/996197&quot;&gt;new operator on arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may just want to go with a reasonably sized static array on arduino considering the memory limitations. I would suggest using a pool or the new + delete stuff but any implementation you add to deal with memory management will take away space you need for your interpreter and its instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I don't know what data type you've chosen to represent your instructions but char is probably best  on the embedded implementation if your instruction set is small as it only occupies one byte each.&lt;/p&gt;&#xA;" OwnerUserId="4378" OwnerDisplayName="Steve" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-10-11T04:14:08.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4585" PostTypeId="2" ParentId="4583" CreationDate="2014-10-10T19:55:29.617" Score="0" Body="&lt;p&gt;After Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you cant use vectors ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... or use variable length arrays, if the compiler you are using it, supports it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... the other viable solution is to get your own list or vector library, either from an existing open source library or implementing your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers.&lt;/p&gt;&#xA;" OwnerDisplayName="umlcat" LastActivityDate="2014-10-10T20:00:45.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4586" PostTypeId="1" CreationDate="2014-10-11T16:43:55.673" Score="0" ViewCount="145" Body="&lt;p&gt;We have &lt;a href=&quot;http://www.servocity.com/html/precision_digital_speed_contro.html&quot; rel=&quot;nofollow&quot;&gt;this controller&lt;/a&gt; that we are planning to use with &lt;a href=&quot;http://www.servocity.com/html/12_rpm_hd_precision_planetary_.html&quot; rel=&quot;nofollow&quot;&gt;this motor&lt;/a&gt;. How do we plug it to the Arduino to make it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a totally new subject for our school team, since we are mostly programmers, so your help will be really appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6287" OwnerDisplayName="Aerozeek" LastActivityDate="2014-11-12T21:16:25.370" Title="Help connecting an Arduino and an electronic speed controller" Tags="|motor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4587" PostTypeId="2" ParentId="4586" CreationDate="2014-10-11T17:50:55.053" Score="0" Body="&lt;p&gt;As the controller and motor are from the same vendor, they can help you with specific questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That motor controller is designed to emulate a servo motor. So it takes a servo-motor signal:&#xA;Ground&#xA;Power&#xA;PPM signal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino servo library will drive the PPM signal. Power and ground for the controller need to come from a separate power supply. The Arduino can't power it.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastActivityDate="2014-10-11T17:50:55.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4588" PostTypeId="1" CreationDate="2014-10-10T09:07:34.690" Score="0" ViewCount="12421" Body="&lt;p&gt;I'm an amateur and I wish to use timers in my project. I'm using an Arduino Mega 2560 with a touch-sensitive screen with six  DS18B20 temperature sensors and a DS1307 RTC (real time clock). I would like to query my sensors every 1 or 2 minutes to refresh the screen for temperature acquisition. I do not how to program timers to schedule the readings and which timers to use?&lt;/p&gt;&#xA;" OwnerDisplayName="pascal007" LastEditorUserId="313" LastEditDate="2014-10-13T20:21:51.217" LastActivityDate="2014-10-13T20:21:51.217" Title="Using timers on an Arduino Mega 2560" Tags="|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4589" PostTypeId="2" ParentId="4588" CreationDate="2014-10-13T02:21:37.063" Score="2" Body="&lt;p&gt;You can use the function &lt;code&gt;millis()&lt;/code&gt;, that returns the number of milliseconds since the Arduino board began running the current program (unsigned long). This number will overflow (go back to zero), after approximately 50 days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code below uses the &lt;code&gt;millis()&lt;/code&gt; function, a command that returns the number of milliseconds since the Arduino board started running its current program, to blink an LED.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Blink without Delay&#xA;&#xA; Turns on and off a light emitting diode(LED) connected to a digital  &#xA; pin, without using the delay() function.  This means that other code&#xA; can run at the same time without being interrupted by the LED code.&#xA;&#xA; The circuit:&#xA; * LED attached from pin 13 to ground.&#xA; * Note: on most Arduinos, there is already an LED on the board&#xA; that's attached to pin 13, so no hardware is needed for this example.&#xA;&#xA;&#xA; created 2005&#xA; by David A. Mellis&#xA; modified 8 Feb 2010&#xA; by Paul Stoffregen&#xA;&#xA; This example code is in the public domain.&#xA;&#xA;&#xA; http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&#xA; */&#xA;&#xA;// constants won't change. Used here to &#xA;// set pin numbers:&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// Variables will change:&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;&#xA;// the follow variables is a long because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;void setup() {&#xA;  // set the digital pin as output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // here is where you'd put code that needs to be running all the time.&#xA;&#xA;  // check to see if it's time to blink the LED; that is, if the &#xA;  // difference between the current time and last time you blinked &#xA;  // the LED is bigger than the interval at which you want to &#xA;  // blink the LED.&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4880" OwnerDisplayName="Fernando Sakugava" LastActivityDate="2014-10-13T02:32:45.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4590" PostTypeId="2" ParentId="4588" CreationDate="2014-10-13T02:45:20.490" Score="0" Body="&lt;p&gt;You can use the watchdog timer for that. Below is part of the code that I use to make temperature readings every 8 seconds using the watchdog timer. It compiles on Arduino IDE 1.0.5 for Arduino Uno R3 board, but be warned that I didn't run it as it is below (so it's untested). You can change variables &lt;code&gt;COUNTER_TRIGGER&lt;/code&gt; and &lt;code&gt;WATCHDOG_PARAM&lt;/code&gt; to adjust its timing it to your liking. Note also that I'm using ATmega328P, so map it accordingly to your MCU.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;#define WDTCR_REG WDTCSR&#xA;#define SERIAL_DEBUG&#xA;&#xA;int COUNTER_TRIGGER = 1; // 1 * 8 sec = 8 seconds&#xA;int WATCHDOG_PARAM = 9; // 9 = 8 sec&#xA;// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms, 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec&#xA;&#xA;volatile long watchdog_counter = 0;&#xA;int counter_trigger = COUNTER_TRIGGER;&#xA;&#xA;const byte TEMP_PIN = A5;&#xA;&#xA;void setup() {&#xA;  #ifdef SERIAL_DEBUG&#xA;  Serial.begin(9600);&#xA;  #endif&#xA;&#xA;  pinMode(TEMP_PIN, INPUT);&#xA;&#xA;  //Power down various bits of hardware to lower power usage&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;  sleep_enable();&#xA;&#xA;  // ADCSRA &amp;amp;= ~(1&amp;lt;&amp;lt;ADEN); //Disable ADC&#xA;  ACSR = (1&amp;lt;&amp;lt;ACD); //Disable the analog comparator&#xA;  DIDR0 = 0x3F; //Disable digital input buffers on all ADC0-ADC5 pins&#xA;&#xA;  sei();&#xA;  setup_watchdog(WATCHDOG_PARAM);&#xA;}&#xA;&#xA;void loop() {&#xA;  #ifdef SERIAL_DEBUG&#xA;  Serial.print(&quot;Sleeping...&quot;);&#xA;  Serial.flush();&#xA;  delay(20);&#xA;  #endif&#xA;&#xA;  sleep_mode();&#xA;&#xA;  #ifdef SERIAL_DEBUG&#xA;  Serial.println(&quot;awake&quot;);&#xA;  #endif&#xA;  // Zzzz...&#xA;&#xA;  #ifdef SERIAL_DEBUG&#xA;  Serial.print(&quot;watchdog_counter = &quot;);&#xA;  Serial.println(watchdog_counter);&#xA;  Serial.print(&quot;counter_trigger = &quot;);&#xA;  Serial.println(counter_trigger);&#xA;  #endif&#xA;&#xA;  if (watchdog_counter &amp;gt;= counter_trigger) {&#xA;    watchdog_counter = 0;&#xA;    doSomething();&#xA;  } &#xA;}&#xA;&#xA;void doSomething() {&#xA;  // do your thing here&#xA;}&#xA;&#xA;// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms, 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec&#xA;void setup_watchdog(int ii) {&#xA;  byte bb;&#xA;  int ww;&#xA;  if (ii &amp;gt; 9 ) ii=9;&#xA;  bb=ii &amp;amp; 7;&#xA;  if (ii &amp;gt; 7) bb|= (1&amp;lt;&amp;lt;5);&#xA;  bb|= (1&amp;lt;&amp;lt;WDCE);&#xA;  ww=bb;&#xA;&#xA;  MCUSR &amp;amp;= ~(1&amp;lt;&amp;lt;WDRF);&#xA;  // start timed sequence&#xA;  WDTCR_REG |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE);&#xA;  // set new watchdog timeout value&#xA;  WDTCR_REG = bb;&#xA;  WDTCR_REG |= _BV(WDIE);&#xA;}&#xA;&#xA;// executed when watchdog timer expires&#xA;ISR(WDT_vect) {&#xA;  watchdog_counter++; // increment volatile&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't remember where I got it. I'll add proper attribution when I find out who provided the code... soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="46" OwnerDisplayName="Ricardo" LastActivityDate="2014-10-13T02:45:20.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4591" PostTypeId="1" AcceptedAnswerId="4594" CreationDate="2014-10-11T23:57:58.063" Score="2" ViewCount="727" Body="&lt;p&gt;I want to control these motors: &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/uh_viewitem.asp?idproduct=6247&amp;amp;aff=61689&quot; rel=&quot;nofollow&quot;&gt;hexTronik DT750 Brushless Outrunner 750kv&lt;/a&gt; with this battery: &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=8934&amp;amp;aff=61689&quot; rel=&quot;nofollow&quot;&gt;Turnigy 2200mAh 3S 25C Lipo Pack&lt;/a&gt; and these ESCs: &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=4312&amp;amp;Product_Name=TURNIGY_Plush_18amp_Speed_Controller&amp;amp;aff=61689&quot; rel=&quot;nofollow&quot;&gt;TURNIGY Plush 18amp Speed Controller&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to this field of driving brush-less motors. Can someone tell me if I need anything else? Will this set-up work without anything getting destroyed?&lt;/p&gt;&#xA;" OwnerUserId="4440" OwnerDisplayName="Sock314" LastActivityDate="2014-10-13T20:34:08.327" Title="Controlling ESC with Arduino" Tags="|motor|pwm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4593" PostTypeId="2" ParentId="4586" CreationDate="2014-10-13T19:21:14.137" Score="1" Body="&lt;p&gt;HobbyKing, which sells Arduinos and is a great source for motors and controllers, has an instructable on this at &lt;a href=&quot;http://www.instructables.com/id/ESC-Programming-on-Arduino-Hobbyking-ESC/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/ESC-Programming-on-Arduino-Hobbyking-ESC/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found another on the OpenROV site, at &lt;a href=&quot;http://community.openrov.com/forum/topics/how-do-i-activate-electric-speed-controller-with-arduino&quot; rel=&quot;nofollow&quot;&gt;http://community.openrov.com/forum/topics/how-do-i-activate-electric-speed-controller-with-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you actually try googling &quot;arduino electronic speed control&quot; before coming here?&lt;/p&gt;&#xA;" OwnerUserId="4375" LastEditorUserId="4375" LastEditDate="2014-10-13T19:26:20.170" LastActivityDate="2014-10-13T19:26:20.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4594" PostTypeId="2" ParentId="4591" CreationDate="2014-10-13T20:34:08.327" Score="2" Body="&lt;p&gt;I 've been working on an autonomous arduino quadcopter for about 7 months now and I have a few tips for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) your setup seems fine as long as your motors aren't going to draw more amps than your ESC can supply, but It is always a good idea to buy ESCs with a higher &quot;max amps&quot; than your motors draws. I would choose 25 amp max ESCs or higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In order to control the motors via PWM, I use the Servo library because you get a resolution from 700-2000 as opposed to &quot;analogWrite&quot; which gives a default resolution of 0-255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) your ESC probably has a minimum pulse width value before it will start. I would recommend writing a program that gives you the ability to plug in values from 700-2000, and use the program to slowlly find that arming pulse width value. Mine is 1110 for reference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have anymore questions, I will glady answer them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;May I ask, what is your project?&lt;/p&gt;&#xA;" OwnerUserId="3159" LastActivityDate="2014-10-13T20:34:08.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4595" PostTypeId="1" AcceptedAnswerId="20332" CreationDate="2014-10-13T20:37:20.120" Score="0" ViewCount="67" Body="&lt;p&gt;I am using an external 5 volt power supply to power my Sonar, and I am using a Teensy 3.1 &#xA;to read in analog signal  from the sonar. my question is since the teensy is only 3.3v tolerant with analog in, is it safe to use with the maxbotix sonar?  &lt;/p&gt;&#xA;" OwnerUserId="3159" LastActivityDate="2016-02-04T20:19:30.453" Title="Maxbotixs LV-EZ4 analog read question" Tags="|teensy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4596" PostTypeId="1" AcceptedAnswerId="4597" CreationDate="2014-10-13T21:58:13.010" Score="2" ViewCount="1659" Body="&lt;p&gt;I bought an ATMega328P-PU and burned OptiBoot onto it using a second &lt;em&gt;Arduino Uno R3&lt;/em&gt; with great success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then put the microcontroller back on the (empty) Uno R3 (DIP) Board for programming, connected USB and uploaded the blink sketch successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to the weird stuff:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Blink&lt;/code&gt; works on the Arduino Board itself, but if I pull it out and stick it into my breadboard, the program seems to not start. Here are some facts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;happens with or without external crystal &lt;code&gt;16.000&lt;/code&gt; &lt;em&gt;(Pin 9-10)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;happens with or without the 22pF capacitors from &lt;code&gt;crystal&lt;/code&gt; to &lt;code&gt;GND&lt;/code&gt; &lt;em&gt;(9-GND, 10-GND)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;happens with Fuses set to internal OSC or to external clock &lt;em&gt;(Uno default)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;happens with or without the &lt;code&gt;ADC VCC&lt;/code&gt; &lt;em&gt;(Pin 20)&lt;/em&gt; and &lt;code&gt;REFERENCE&lt;/code&gt; &lt;em&gt;(Pin 21)&lt;/em&gt; Pins @ 5V&lt;/li&gt;&#xA;&lt;li&gt;happens on 5V and on 3V3&lt;/li&gt;&#xA;&lt;li&gt;happens with or without external Pullup on &lt;code&gt;RESET&lt;/code&gt; Pin (1)&lt;/li&gt;&#xA;&lt;li&gt;Most of the output Pins sit at &lt;code&gt;0.8 V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4361" LastActivityDate="2014-10-14T17:48:23.237" Title="ATMega328P not running sketch in standalone (works in Uno R3 Board though)" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4597" PostTypeId="2" ParentId="4596" CreationDate="2014-10-13T22:03:54.217" Score="3" Body="&lt;h2&gt;I found the solution by accident.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While I used my multimeter to measure the voltages between GND and the Pins (for the last fact), I noticed the program running at weird speeds. I. e. the LED started blinking.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What did I measure?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Actually I was just measuring one of the &lt;code&gt;crystal&lt;/code&gt; pins &lt;em&gt;(Pin 9 or 10)&lt;/em&gt;. The sketch went running for a few seconds and very different speeds and then stopped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This small change in voltage gave the ATMega the &lt;code&gt;clock&lt;/code&gt; signal it needs to step through the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I need less capacitance of the two capacitors as mentioned in the comments. I will update the answer with more information later on.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The perfect solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the comments, I really chose the wrong capacitors. It worked without, but we want the stability so use a bright light and a magnifying glass if you are unsure. Really, do it.&lt;/p&gt;&#xA;" OwnerUserId="4361" LastEditorUserId="4361" LastEditDate="2014-10-14T17:48:23.237" LastActivityDate="2014-10-14T17:48:23.237" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4599" PostTypeId="2" ParentId="1386" CreationDate="2014-10-14T04:08:45.767" Score="1" Body="&lt;p&gt;Your problem is probably from the level converter. Which one did you use?&#xA;Most level converters are uni-directional, and don't work for I2C.&#xA;See the App note and device from NXP:&#xA;&lt;a href=&quot;http://www.adafruit.com/datasheets/an97055.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/datasheets/an97055.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4202" LastActivityDate="2014-10-14T04:08:45.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4600" PostTypeId="2" ParentId="4580" CreationDate="2014-10-14T09:38:03.053" Score="4" Body="&lt;p&gt;Add to @geometrikal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-10-14T09:38:03.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4601" PostTypeId="2" ParentId="4522" CreationDate="2014-10-14T11:01:49.987" Score="1" Body="&lt;p&gt;If you're new to Arduino I'd suggest avoiding the Mini and the BULLSH-fun that external programmers bring. &#xA;Something like the Pro Micro is much easier, almost as small, and less likely to bite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often the best way to pick hardware is to look for a tutorial (like &lt;a href=&quot;http://bildr.org/2012/03/stable-orientation-digital-imu-6dof-arduino/&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; one) before deciding what to buy. While I personally haven't used IMUs it looks like the &quot;6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345&quot; from SparkFun would be (relatively) easy to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used the RN-41/2 Bluetooth modems (the same as are found in BlueSMiRF modules) and usually gotten on OK with them. There are plenty of tutorials available with a bit of Googleing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/categories/138&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt; do a good line of Lipo batteries and chargers. They also have wireless charging modules if you're looking for extra brag-factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastActivityDate="2014-10-14T11:01:49.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4602" PostTypeId="2" ParentId="3179" CreationDate="2014-10-14T16:11:17.943" Score="1" Body="&lt;p&gt;As someone mentioned, the first chip you may be able to fix by passing -B10 to avrdude.  In order to program an AVR, the programmer has to be running at a slower speed than the chip you're programming is running.  The fuses you have set cause the chip to run at 1Mhz using the internal clock, and -B10 will cause it to go slower (the defaults are suitable for programming a chip that is running faster than 4MHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second chip, the fuses are set to 8MHz using an external crystal, so in order to fix it, you'll need to hook up an 8MHz crystal, or use a high voltage programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="323" LastActivityDate="2014-10-14T16:11:17.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4603" PostTypeId="1" CreationDate="2014-10-14T19:59:18.883" Score="2" ViewCount="1174" Body="&lt;p&gt;So I'm working on my car and now I've got my sights on the electrical system. I've installed a keyless entry system and a pulse timer for the dome light. Now, I'd like to give the dome light the fade effect all the modern cars have. After looking around, it seems an Arduino would be the most reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently own an board similar to the Arduino Nano, specifically the SainSmart Nano. So I've determined that I'd power the board with a constant 12V, use pin 7 as input, and use pin 9 as output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int domeLightIn = 7;&#xA;int domeLightOut = 9;&#xA;int brightness = 0;&#xA;int fadeAmount = 5;&#xA;&#xA;void setup() {&#xA;  pinMode(domeLightOut, OUTPUT);&#xA;  pinMode(domeLightIn, INPUT);&#xA;  digitalRead(domeLightIn);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Case 1: State of Door: Open/Closed&#xA;  // Case 2: State of Switch: On/Off&#xA;  // Case 3: State of KES: Active/Inactive&#xA;&#xA;  //Case 1: If door is closed and led is off, brightness remains 0;&#xA;  //Case 2: If switch is off and led is off, brightness remains 0;&#xA;  //Case 3: If KES is inactive and led is off, brightness remains 0;&#xA;  if (digitalRead(domeLightIn) == LOW &amp;amp;&amp;amp; brightness != 255){&#xA;    brightness = 0;&#xA;  }&#xA;&#xA;  //Case 1: If door is open and led is off, brightness will fade in;&#xA;  //Case 2: If switch is on and led is off, brightness will fade in;&#xA;  //Case 3: If KES is active and led is off, brightness will fade in;&#xA;  if (digitalRead(domeLightIn) == HIGH &amp;amp;&amp;amp; brightness != 255) {&#xA;    for (brightness = 0; brightness &amp;lt; 255; brightness = brightness + fadeAmount) {&#xA;      analogWrite(domeLightOut, brightness);&#xA;      delay(35);&#xA;    }&#xA;  }&#xA;&#xA;  //Case 1: If door is closed and led is on, brightness will fade out;&#xA;  //Case 2: If switch is off and led is on, brightness will fade out;&#xA;  //Case 3: If KES is inactive and led is on, brightness will fade out;&#xA;  if (digitalRead(domeLightIn) == LOW &amp;amp;&amp;amp; brightness == 255) {&#xA;    for (brightness = 255; brightness &amp;gt; 0; brightness = brightness - fadeAmount) {&#xA;      analogWrite(domeLightOut, brightness);&#xA;      delay (35);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am unsure whether I am using digitalRead() correctly along with wiring the input. So, am I doing this right? or perhaps there is a better way?&lt;/p&gt;&#xA;" OwnerUserId="4388" LastEditorUserId="4388" LastEditDate="2014-10-14T20:26:46.643" LastActivityDate="2015-04-29T01:28:00.047" Title="Car dome light fading with arduino nano" Tags="|led|pwm|arduino-nano|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4604" PostTypeId="1" CreationDate="2014-10-14T20:14:11.693" Score="2" ViewCount="220" Body="&lt;p&gt;So I'm trying to use the GSM shield to communicate with my smart phone. The SIM card that came with the shield only works with other devices on that network, and it's an obscure latin network that I don't have so I cant use that one, and I bought another t-mobile SIM card activation kit, but I can't figure out how to activate it without having an actual T-mobile number. Somebody please help me! Either help me figure out a way to get the T-mobile SIM card to work or tell me what other SIM to use! If you used the GSM shield with a different SIM card, could you give me a link to where you bought it? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4390" LastActivityDate="2014-10-14T20:14:11.693" Title="GSM shield SIM card troubles" Tags="|arduino-uno|gsm|shields|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4605" PostTypeId="1" CreationDate="2014-10-14T20:14:46.947" Score="3" ViewCount="1439" Body="&lt;p&gt;I'm currently looking at my Arduino MEGA 2560 board and was just wondering why there are different ports to it e.g. ANALOG IN, DIGITAL, Communication? in fact I've only seen this in some microcontrollers. Not many microcontrollers have ports dedicated to certain things. Is anyone able to give me an answer as to why there is different ports to the microcontroller? is it making it easier for the chip to handle etc. A detailed but not too detailed answer would be great!&lt;/p&gt;&#xA;" OwnerUserId="4391" LastActivityDate="2021-07-31T00:09:16.353" Title="Why does an Arduino MEGA 2560 have different PORTS" Tags="|arduino-mega|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="4606" PostTypeId="2" ParentId="4603" CreationDate="2014-10-14T20:22:41.953" Score="1" Body="&lt;p&gt;You're not using digitalWrite properly. You should do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(domeLightIn) == LOW &amp;amp;&amp;amp; brightness != 255){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just a sidequestion. What is pin7 connected to? If it's a 12v signal, you'd have to convert it down to 5v somehow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the 12v in the car can be up-to 14v, and can have some huge spikes. Not sure if the sainsmart's regulator can handle those spikes. It might die prematurely. It's also just wasting 60% (generating heat!), turning 12v to 5v. I would suggest adding one of those cheap car-phone-chargers.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-14T20:22:41.953" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4607" PostTypeId="2" ParentId="4605" CreationDate="2014-10-15T06:03:46.317" Score="1" Body="&lt;p&gt;Thats because Arduino has configured the Mega to do so. In microcontrollers you need to select what use will each pin have based on the availability. To make user interface easy arduino has done this based on what is commonly used by everyone. Even then some functions are still not disabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example 50,51,52,53 are SPI pins on mega which use Pin change interrupt for working. Thus it not necessary we use them for SPI we can also use them for Pin change interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar is the case for pins 10,11,12,13. These PWM pins can also be used for Pin change interrupt but other PWM pins cannot.&lt;/p&gt;&#xA;" OwnerUserId="4351" LastActivityDate="2014-10-15T06:03:46.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4608" PostTypeId="2" ParentId="3316" CreationDate="2014-10-15T06:08:05.303" Score="1" Body="&lt;p&gt;I have seen this error numerous times before. I think the possibilities could be that either some external device is connected on RX, TX pins of arduino mega or mega is not getting sufficient power. Some connection from your board is trying to pull more than the limit current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and off course the answers suggested above are also right. check out every possibility.&lt;/p&gt;&#xA;" OwnerUserId="4351" LastActivityDate="2014-10-15T06:08:05.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4609" PostTypeId="2" ParentId="3316" CreationDate="2014-10-15T07:43:31.593" Score="0" Body="&lt;p&gt;When you try to upload a sketch do the Receive and/or Transmit lights on the Arduino blink?  If not you may not be getting serial communication.  Try a loopback test (connect D0 to D1 and see if stuff you type in Serial Monitor comes back as it should).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, go to &lt;code&gt;My Computer&amp;gt;Properties&amp;gt;Device Manager&lt;/code&gt; and search for &lt;code&gt;Ports(COM&amp;amp;LPT)&amp;gt;&lt;/code&gt;is there Arduino MEGA??? If not you have no drivers installed or they haven't been installed automaticly or your arduino is dead :)). If it is drivers you have to update them. In same &lt;code&gt;Device Manager&lt;/code&gt; expand &lt;code&gt;Other devices&lt;/code&gt;. There should be some &lt;code&gt;Unknown devices&lt;/code&gt;. Update Mega drivers &lt;code&gt;Update Driver Software&lt;/code&gt;, &lt;code&gt;Browse my computer...&lt;/code&gt; and &lt;code&gt;C:\...\arduino\drivers&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-15T07:50:01.273" LastActivityDate="2014-10-15T07:50:01.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4610" PostTypeId="1" AcceptedAnswerId="32609" CreationDate="2014-10-15T07:45:16.907" Score="7" ViewCount="39856" Body="&lt;p&gt;I am trying to build a simple fan controller (single fan). So far I have successfully created a circuit which powers the fan with an external 12v DC adapter and added a transistor (NPN) to switch it on and off. The transistor is connected to a PWM port on the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When putting &lt;code&gt;HIGH&lt;/code&gt; on the port the fan works perfectly at high speed, but when I want to lower the speed (say &lt;code&gt;analogWrite(fanPin, 150)&lt;/code&gt;) it starts to make a humming noise. I believe this is caused by the use of PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to control the speed of the fan without (too much) noise?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ps. The fan is a Cooler Master 3-wire PC fan. Transistor is a P2N2222A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Here is the schema I am using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UIYfW.png&quot; alt=&quot;schema&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4387" LastEditorUserId="4387" LastEditDate="2014-10-15T18:41:05.100" LastActivityDate="2020-06-01T17:25:47.937" Title="How to eliminate noise from PWM controlled 12V fan at low speed" Tags="|arduino-uno|motor|pwm|transistor|" AnswerCount="9" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4611" PostTypeId="2" ParentId="4610" CreationDate="2014-10-15T07:53:12.027" Score="0" Body="&lt;p&gt;&lt;strong&gt;coment&lt;/strong&gt; add circuit to know what you have done &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does your circuit looks similar like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you use resistor for transistor? Diode for fan?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2cDEz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that you do not have diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the diode is to allow current that is flowing in the motor coil to continue to flow in the same direction when the transistor turns off. When the transistor turns off, the voltage at the transistor collector will &lt;strong&gt;rise&lt;/strong&gt; as it was flowing out of the motor. From &lt;strong&gt;Vce(SAT)&lt;/strong&gt; it will rise above the power supply voltage and stop only when the transistor breaks down (or when it starts to ring with parasitic capacitance). By putting a diode from the transistor collector to the +12V rail, you prevent the voltage across the transistor from exceeding 12V and and allow the motor current to continue to flow.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-15T08:15:02.580" LastActivityDate="2014-10-15T08:15:02.580" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4612" PostTypeId="1" AcceptedAnswerId="4633" CreationDate="2014-10-15T11:16:20.953" Score="3" ViewCount="4726" Body="&lt;p&gt;I think about building my own robotic mower, therefore I would like to detect if the surface the mower in moving on is grass, pavement, gravel ... etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which sensors would be the best choice in order to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The benefits:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no parimeter wire to bury    &lt;/li&gt;&#xA;&lt;li&gt;possible lawn edge detection (here most mowers fail to do a good job)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4407" LastActivityDate="2014-10-17T08:03:09.363" Title="Detecting grass, pavement, gravel" Tags="|sensors|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4613" PostTypeId="1" CreationDate="2014-10-15T12:15:14.973" Score="0" ViewCount="234" Body="&lt;p&gt;Just got my Yun today.  Successfully connected to my home wireless, installed YunSysUpgrade_v1.5.1, &#xA;and divied up my Micro SD card for Linino and Windows file system with YunDiskSpaceExpander, &#xA;and got files serving on the native file server from the SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't seem to touch the wireless section from a sketch.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running a mod of the example ScanNetworks sketch - here's the relevant part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  delay(1000);&#xA;  String fv = WiFi.firmwareVersion();&#xA;  Serial.println(&quot;Version: &quot;);&#xA;  Serial.println( fv );&#xA;  Serial.println(&quot;Status: &quot;);&#xA;  Serial.println( WiFi.status() );&#xA;  // scan for existing networks:&#xA;  Serial.println(&quot;Scanning available networks...&quot;);&#xA;  listNetworks();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the ouptut: no version and a status of 255 (which I cannot find documentation on....)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Version: &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Status:&lt;br&gt;&#xA;  255 &#xA;  Scanning available networks...&#xA;  ** Scan Networks ** &#xA;  number of available networks:0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I looked at installing wifi_dnld.elf, but could not find jumper 3 on my Yun, so assumed it was for the 'true shield'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong, or do I need to return this to amazon?&lt;/p&gt;&#xA;" OwnerUserId="4403" LastEditorUserId="11" LastEditDate="2014-10-15T16:12:04.497" LastActivityDate="2014-10-15T16:12:04.497" Title="Cant's code against Yun Wireless Section" Tags="|arduino-yun|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4614" PostTypeId="2" ParentId="4613" CreationDate="2014-10-15T13:31:41.920" Score="1" Body="&lt;p&gt;&lt;code&gt;WiFi&lt;/code&gt; library won't work with the Yun: it's meant to work only with the WiFi shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Yun, everything but the pins is connected to the linux cpu. For the microcontroller to use all the devices available to linux, including wifi, you need to use the &lt;code&gt;Bridge&lt;/code&gt; library. Try running example &lt;code&gt;WifiStatus&lt;/code&gt; (Examples -&gt; Bridge -&gt; WifiStatus)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A drop in replacement (almost) of both Ethernet and WiFi libraries is the &lt;code&gt;YunClient&lt;/code&gt;/&lt;code&gt;YunServer&lt;/code&gt; pair, part of the &lt;code&gt;Bridge&lt;/code&gt; library. Check out the docs at &lt;a href=&quot;http://arduino.cc/en/Reference/YunBridgeLibrary&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/YunBridgeLibrary&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-10-15T13:31:41.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4615" PostTypeId="2" ParentId="4612" CreationDate="2014-10-15T13:33:10.337" Score="1" Body="&lt;p&gt;You may need to use a combination of sensors. I can't think of any single sensor that can reliably detect the different surfaces. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An IR sensor could detect the difference between grass (cooler) and pavement/gravel (warmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ultrasonic ranging sensor could detect the difference in heights between the grass and pavement/gravel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A photoelectric sensor could detect the difference in reflectivity between the grass and gravel/pavement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A visual camera could be used with image processing to detect color differences, although this may be too processing intensive for an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A final possibility would be measuring the resistance to movement of the wheels. The robot will travel easier over the hard surface of pavement/gravel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would think that a combination of the above sensors would provide the most reliability and accuracy. However, it will still likely be limited to one location without recalibration. The weather will even cause a change in some of the sensors (photoelectric for example on a sunny vs. cloudy day).&lt;/p&gt;&#xA;" OwnerUserId="4393" LastActivityDate="2014-10-15T13:33:10.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4616" PostTypeId="2" ParentId="4612" CreationDate="2014-10-15T14:06:44.417" Score="2" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YIUwt.jpg&quot; alt=&quot;Sensors in lawn mover&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try to use a force sensitive sensor to detect when grass blades touch it. &lt;/p&gt;&#xA;" OwnerUserId="381" LastActivityDate="2014-10-15T14:06:44.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4617" PostTypeId="1" AcceptedAnswerId="4618" CreationDate="2014-10-15T14:24:10.983" Score="0" ViewCount="2173" Body="&lt;p&gt;I am an arduino enthusiast and i am new to it.just wanted to know weather the micro processor itself could create a file in its memory while its is running. I know that it is possible to read a write from a file in c++ but is it possible to do so in an arduino (while it's running).&lt;/p&gt;&#xA;" OwnerUserId="4409" LastEditorUserId="4409" LastEditDate="2014-10-15T15:39:55.423" LastActivityDate="2014-10-15T16:42:07.973" Title="Can arduino create a file in its memory?" Tags="|memory-usage|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4618" PostTypeId="2" ParentId="4617" CreationDate="2014-10-15T16:42:07.973" Score="2" Body="&lt;p&gt;To answer the original question: Basically, yes, you can write libraries to implement a file system using the memories of an embedded microcontroller. &lt;br&gt;&#xA;However, if it's feasible highly depends on the controller architecture and its peripherals. &lt;br&gt;&#xA;Some of them (e.g. the one on Arduino Due) allow Flash reprogramming while an application is running from Flash.&lt;br&gt;&#xA;Others require to have the application running in a special boot block or even in RAM when accessing the Flash for writing (this should be the case on an Arduino Uno)&lt;br&gt;&#xA;And others don't allow Flash accesses from application at all.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway:&lt;br&gt;&#xA;The use of this for your purpose is very little, because the interface to the PC would also have to support the file system (for example, you could implement a FTP server and use an Ethernet connection...). &#xA;&lt;br&gt;Therefore, the SD card approach is surely a very good suggestion.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-10-15T16:42:07.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4619" PostTypeId="2" ParentId="4566" CreationDate="2014-10-15T17:41:35.793" Score="2" Body="&lt;p&gt;Check out the internal pull-up resistor (disconnected by default) for Arduino as well. Save yourself wiring up an extra resistor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(5, INPUT_PULLUP); // Enable internal pull-up resistor on pin 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From SparkFun: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pull-up-resistors/what-is-a-pull-up-resistor&quot; rel=&quot;nofollow&quot;&gt;Pull-up Resistors&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="2768" LastActivityDate="2014-10-15T17:41:35.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4620" PostTypeId="2" ParentId="4610" CreationDate="2014-10-15T19:50:52.303" Score="3" Body="&lt;p&gt;Try using pin 3 (or 11) and lower the prescaler of timer 2 using the following code in your &lt;code&gt;setup&lt;/code&gt;;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//move from /64 prescaler to /32 prescaler&#xA;TCCR2B |= _BV(CS20);//set bit (remove this line for a /8 prescaler)&#xA;TCCR2B |= _BV(CS21);//set bit&#xA;TCCR2B &amp;amp;= ~_BV(CS22);//clear bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Halving the prescaler will double the frequency.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-15T19:50:52.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4622" PostTypeId="2" ParentId="4612" CreationDate="2014-10-15T20:40:14.243" Score="1" Body="&lt;p&gt;A combination of colour sensors as the predominant one and proximity sensors as the secondary one should work fine. Around $10 so definitely worth trying out. Also, the code should be relatively easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are links as samples. I hope this helps :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dx.com/p/tcs230-color-sensor-detector-module-for-arduino-148739?tc=AUD&amp;amp;gclid=Cj0KEQjwtvihBRCd8fyrtfHRlJEBEiQAQcubtEsIYEj3sI86-P4W3tnviua5B44ZwO722gmYXFFSQogaAt2T8P8HAQ#.VD7aD1ZdbCQ&quot; rel=&quot;nofollow&quot;&gt;$6 colorvsensor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://m.miniinthebox.com/ultrasonic-module-hc-sr04-distance-measuring-transducer-sensor-for-arduino-201211270080054_p478889.html?currency=AUD&amp;amp;litb_from=paid_adwords_shopping&amp;amp;gclid=Cj0KEQjwtvihBRCd8fyrtfHRlJEBEiQAQcubtGOvddT9LtfF7yBDOkZ4PbQyYhWMWjHNbTYx3EB8_BwaAvE-8P8HAQ&quot; rel=&quot;nofollow&quot;&gt;$4 Proximity  sensor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3772" LastActivityDate="2014-10-15T20:40:14.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4623" PostTypeId="1" AcceptedAnswerId="4624" CreationDate="2014-10-16T03:31:13.507" Score="0" ViewCount="6113" Body="&lt;p&gt;I have a 12v/1.5 amp barrel plug power supply on my Arduino Uno. I have two servos that say they are rated for 4.8v to 6v, but no amps are specified. When my circuit is configured as it is in this image, it appears to work fine. (In my test sketch, I'm constantly and simultaneously rotating them from 0 - 180 degrees and then in reverse.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't understand why it works. I assumed the 5v pin can only supply 5v of total power to the whole configuration. Is it instead supplying a regulated 5v at as needed between both servos from a total pool of 12v (presumably up to 10v at once)? Do I need voltage regulation? Shouldn't I have to know the amps for the servo(s) and use some sort of resistance?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any information and advice you can share on learning about the concepts underlying a situation like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bkXNT.png&quot; alt=&quot;Running two servos from one 12v power supply&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I ultimately modified my approach based on the feedback received here by wiring a separate 5v/2a power supply to the breadboard for the two servos, and wiring the rest of the circuit appropriately (using a common ground, etc.). &lt;/p&gt;&#xA;" OwnerUserId="4401" LastEditorUserId="4401" LastEditDate="2015-03-03T06:27:43.497" LastActivityDate="2015-03-03T06:27:43.497" Title="How do voltage and resistance work for two 5v servos when using an external 12v power supply?" Tags="|arduino-uno|power|voltage-level|servo|current|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4624" PostTypeId="2" ParentId="4623" CreationDate="2014-10-16T03:43:42.473" Score="4" Body="&lt;p&gt;Because the supplies of both servos are connected in parallel, they both see the same voltage. Hence there is no &quot;pool&quot;, both are being supplied the same 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a regulator on the Arduino which reduces the 12V input down to 5V. It does so by burning off the other [7V times however much current is being used] as heat. Since you are supplying it with 1.5A, the most it can supply is in turn 1.5A.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-16T03:43:42.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4625" PostTypeId="2" ParentId="4623" CreationDate="2014-10-16T06:00:16.367" Score="4" Body="&lt;p&gt;Addition to Ignacio. Explanation from real life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gregir, look at your home devices like TV, micro wave, fridge and so on. They all need 220-230 V AC and you can plug all them to one socket. As Ignacio said voltage doesn't plus. The current does plus, for ex. you have 2 servos connected in parralel, both 5V, no load current 0.1A. So to run them with no load you will have to supply 5V and 0.1+0.1=0.2A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to explain at very basic level ;) &lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-10-16T06:00:16.367" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4627" PostTypeId="2" ParentId="3316" CreationDate="2014-10-16T13:11:02.637" Score="1" Body="&lt;p&gt;Download the devel filter.exe file from this site. Install it and target your programmer (I assume you are programming via ISP if you're using avrdude)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/&quot; rel=&quot;nofollow&quot;&gt;http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will eliminate the 'USB not found' problem.&lt;/p&gt;&#xA;" OwnerUserId="4423" LastActivityDate="2014-10-16T13:11:02.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4629" PostTypeId="1" CreationDate="2014-10-16T13:42:26.403" Score="3" ViewCount="869" Body="&lt;p&gt;I have an Arduino Mega2560 configured to Hiduino, which makes the Arduino a driverless class-compliant MIDI interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently converting RS232 serial I/O data to midi data using the 'hairless midi-serial' software running in the background. I am hoping that I can utilize this Hiduino interfacing to send and receive this data in the same fashion, just through the Arduino instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am lead to believe this would require the MIDI library to be used to program the 2560 to understand the serial bytes coming from the controller and converting to the appropriate midi bytes into my program, and vice versa.  I am just getting into programming. Could someone could give an example of how a program could be written to send and receive this data through the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="4423" LastEditorUserId="4423" LastEditDate="2014-11-16T20:28:26.517" LastActivityDate="2014-11-16T20:28:26.517" Title="Hiduino as a Serial-USB midi coverter" Tags="|serial|arduino-mega|softwareserial|midi|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4630" PostTypeId="1" AcceptedAnswerId="4632" CreationDate="2014-10-16T16:53:51.697" Score="0" ViewCount="3463" Body="&lt;p&gt;I had my Arduino Uno connected to an external 12 V supply for 2-3 hours as I was working on other parts of my project. Suddenly the voltage from pin 9 which I was monitoring in the oscillator dropped down to 0 approximately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went on removing the external supply. The board was very very hot. I then connected the USB to my laptop and I got an error 43 (Windows did not allow the device to connect because it was reporting problems). I can't load any program of course. The 5 V pin works but it outputs a voltage lower than usual (at about 3.9 V). When I connect the external supply the 5 V pin outputs full voltage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea? Any fix?&lt;/p&gt;&#xA;" OwnerUserId="4090" LastEditorUserId="6936" LastEditDate="2016-04-25T10:04:37.277" LastActivityDate="2020-10-12T15:59:38.947" Title="Arduino Uno suddenly not recognized in Windows 8.1 (code 43)" Tags="|arduino-uno|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4631" PostTypeId="2" ParentId="4572" CreationDate="2014-10-16T21:33:55.953" Score="8" Body="&lt;p&gt;This is how &lt;code&gt;Print::print&lt;/code&gt; prints from program memory in the Arduino library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t Print::print(const __FlashStringHelper *ifsh)&#xA;{&#xA;  const char PROGMEM *p = (const char PROGMEM *)ifsh;&#xA;  size_t n = 0;&#xA;  while (1) {&#xA;    unsigned char c = pgm_read_byte(p++);&#xA;    if (c == 0) break;&#xA;    n += write(c);&#xA;  }&#xA;  return n;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;__FlashStringHelper*&lt;/code&gt; is an empty class that allows for overloaded functions like print to differentiate a pointer to program memory from one to normal memory, as both are seen as &lt;code&gt;const char*&lt;/code&gt; by the compiler (see &lt;a href=&quot;https://stackoverflow.com/questions/16597437/arduino-f-what-does-it-actually-do&quot;&gt;https://stackoverflow.com/questions/16597437/arduino-f-what-does-it-actually-do&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could overload the &lt;code&gt;print&lt;/code&gt; function for your LCD display so that it takes a &lt;code&gt;__FlashStringHelper*&lt;/code&gt; argument, lets call it &lt;code&gt;LCD::print&lt;/code&gt;, and then use &lt;code&gt;lcd.print(F(&quot;this is a string in progmem&quot;));' to call it.&lt;/code&gt;F()` is a macro that ensures the string is in program memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To predefine the string  (to be compatible with built-in Arduino print) I have used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char firmware_version_s[] PROGMEM = {&quot;1.0.2&quot;};&#xA;__FlashStringHelper* firmware_version = (__FlashStringHelper*) firmware_version_s;&#xA;...&#xA;Serial.println(firmware_version);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think an alternative would be something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t LCD::print_from_flash(const char *pgms)&#xA;{&#xA;  const char PROGMEM *p = (const char PROGMEM *) pgms;&#xA;  size_t n = 0;&#xA;  while (1) {&#xA;    unsigned char c = pgm_read_byte(p++);&#xA;    if (c == 0) break;&#xA;    n += write(c);&#xA;  }&#xA;  return n;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would avoid the &lt;code&gt;__FlashStringHelper&lt;/code&gt; cast.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-10-16T21:33:55.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4632" PostTypeId="2" ParentId="4630" CreationDate="2014-10-16T21:53:07.553" Score="2" Body="&lt;p&gt;Something is shorted out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you connect via USB, the USB port cannot supply enough current because of the short. The output drops to 3.9V and the USB port on your computer reports an error, probably due to over current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you connect the external power supply, it has enough power to supply the short. The output remains at 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can think of power supplies as having a very small internal resistance (R_p), and the board as being a resistive load (R_b). This forms a voltage divider, but because R_b &gt;&gt; R_p the voltage seen by the board is basically the same as that of the power supply. With a short, R_b is often &amp;lt; R_p, and thus the voltage seen by the board is much lower than the power supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix will depend on which component is getting hot. Plug in the external power supply and check which one it is. &lt;em&gt;Note: The component will get hot enough to burn your finger after a few seconds.&lt;/em&gt; One way is to check one component at a time, disconnecting the power between each check. Start with the big ICs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If either the Atmega328P or the smaller ATmega8u2 (?) are hot, they will have to be replaced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, boards don't short out by themselves. Something is wrong with your circuit or you may have placed the board down on some conductive surface. If you post you circuit we might be able to spot the problem.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-10-16T21:53:07.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4633" PostTypeId="2" ParentId="4612" CreationDate="2014-10-17T08:03:09.363" Score="0" Body="&lt;p&gt;I have found this DIY mower page (where they apparently already implemented a grass sensor). &lt;a href=&quot;http://www.ardumower.de/index.php/en/ardumower-topics/sensors/lawn-sensor&quot; rel=&quot;nofollow&quot;&gt;Grass sensor&lt;/a&gt;. Other useful info can also be found (mixed in english and german).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are measuring the capacity of the underground in about 2cm (1inch) height. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On gravel or other hard material this is near 0 (as the sensor is in the air). On grass the value is higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Haven't though of this solution, should be the way to go.&lt;/p&gt;&#xA;" OwnerUserId="4407" LastActivityDate="2014-10-17T08:03:09.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4634" PostTypeId="1" CreationDate="2014-10-17T09:07:45.953" Score="0" ViewCount="2628" Body="&lt;p&gt;I need to work with SD card and &lt;code&gt;TCRT5000 sensor&lt;/code&gt; (Reflective Optical Sensor with Transistor Output) and save data from sensor to file. So I select &lt;code&gt;Arduino Uno&lt;/code&gt; and added to it a SD card shield(from LC STUDIO) and a &lt;code&gt;TCRT5000 sensor&lt;/code&gt; but it isn't working.&#xA;My circuit and code is here:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/DzJLv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;const int chipSelect = 10;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(chipSelect, OUTPUT);&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&quot;Card failed, or not present&quot;);&#xA;    while(true);&#xA;  }&#xA;  Serial.println(&quot;card initialized.&quot;);&#xA;  File dataFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;  dataFile.close();&#xA;  dataFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;  if(dataFile){&#xA;    dataFile.println(&quot;Start:&quot;);&#xA;  }else{&#xA;    Serial.println(&quot;Error in creating file.&quot;);&#xA;    while(true);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  float value = analogRead(A3);&#xA;  File dataFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;  if (dataFile) {&#xA;    dataFile.println(value);&#xA;    Serial.println(value);&#xA;    dataFile.close();&#xA;  }else{&#xA;    Serial.println(&quot;Error in opening file.&quot;);&#xA;  }&#xA;  delay(5);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;TCRT5000&lt;/code&gt; isn't connected SD card working without any problem.&#xA;I think it is related to current and supply current. Any idea?&lt;/p&gt;&#xA;" OwnerUserId="3745" LastEditorUserId="4131" LastEditDate="2015-08-04T23:29:49.647" LastActivityDate="2015-12-03T05:17:57.707" Title="SD Card shield and TCRT5000 sensor aren't working together on arduino uno" Tags="|arduino-uno|sensors|sd-card|current|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4635" PostTypeId="1" CreationDate="2014-10-17T10:56:50.043" Score="4" ViewCount="1482" Body="&lt;p&gt;I have the arduino duemilanove with atMega328.&#xA;The frequency is 16Mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to sample and record from the audio jack.&#xA;I searched and i found if i want to record &quot;everything - so to speak&quot;, i have to sample at 44100Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means this is unfeasible with my arduino, since my frequency is only 16MHz?&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2014-10-17T14:07:04.197" Title="Is it possible to sample sound with arduino?" Tags="|audio|frequency|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4636" PostTypeId="2" ParentId="4635" CreationDate="2014-10-17T11:18:10.713" Score="6" Body="&lt;p&gt;For the AtMega328's ADC the datasheet says &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;• Up to 76.9kSPS (Up to 15kSPS at Maximum Resolution)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, sampling two channels at 10bit resolution and 44.1kHz is not possible.&lt;br&gt;&#xA;If 8bit resolution is enough, and if there's only one channel to sample, it should be able to do the job.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer Connor's comment:&lt;br&gt;&#xA;Of course, this does only apply when using the internal ADC. Connecting an external ADC (via SPI or whatever) makes it possible to sample data at the desired speed.&lt;br&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But anyway, the next question is: Is 16MHz fast enough to process the sampled data (which are received every (22.6/channels) microseconds? ;-)&lt;/p&gt;&#xA;" OwnerUserId="3878" LastEditorUserId="3878" LastEditDate="2014-10-17T14:07:04.197" LastActivityDate="2014-10-17T14:07:04.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4638" PostTypeId="1" AcceptedAnswerId="4639" CreationDate="2014-10-17T19:36:16.980" Score="0" ViewCount="978" Body="&lt;p&gt;I was doing some research about this subject and I only have more questions than answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want a little IMU sensor (I don't know which hardware I should get) that sends data wirelessly to my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sender part (IMU + sender + battery) should be small (tennis ball size is fine) and the receiving part should be an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I buy? How can I achieve this? I was looking at a lot of ideas: Xbees, bluetooth, radio receivers, Arduino Nano, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My focus is on the Arduino code, I just need that the IMU sends data at least at a ratio of 10ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a plus I would love to have more than one Wireless IMU sensor connected to my Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4438" LastEditorUserId="84" LastEditDate="2014-10-18T08:05:44.013" LastActivityDate="2014-10-18T08:05:44.013" Title="Wireless Sensor (IMU) to Arduino" Tags="|sensors|communication|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4639" PostTypeId="2" ParentId="4638" CreationDate="2014-10-17T22:20:38.383" Score="3" Body="&lt;p&gt;You have not really given enough specifications for any choice of radio to make a difference in your scenario. Any list of products would be very long, overly summarized, and not relevant in a month, So I'll try and outline the thought process I would take in finding the fit for a project I was making.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Radio:&lt;/strong&gt; Which type of radio to choose will depend on a lot of specific factors, but its more than likely that multiple options will work perfectly. You seem to know the major methods, Xbee, bluetooth, Wifi, and for very long distances, GSM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should consider the problem, define what you need by looking at the amount of data per second you want sent, the necessary range, the power you have available in the battery, any region specific laws, and anything else you can think of needing. Also consider if you really need an arduino as the receiver, or if you have a Bluetooth equipped laptop or wireless router on hand that could take that roll for you. Then look around at sparkfun or wherever and find the cheapest, most popular method that fits the bill. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IMU:&lt;/strong&gt; Many IMU's exist with more or less the exact same features, so I will recommend a similar process. Look at the power consumption, output rate, sensitivity, and communication method you project needs, and find the cheapest and/or best rated item at your preferred electronics retailer that fits the bill. the MPU6000's are popular these days. The altIMUv4 has a magnetometer and barometer included as well. Shop around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will most likely want to put an arduino nano/micro/trinket/whatever with the IMU to translate to your communication method. Some radios work with UART serial, but not many IMU's output like this. Those that do cost more because they have a coprocessor on board. Consider if buying a co-processor equipped board will make your sensor processing easier before you discount it for the elevated price. In depth sensor fusion gets pretty hairy, and for some, not having to worry about it could be worth $50. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-10-17T22:20:38.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4640" PostTypeId="1" AcceptedAnswerId="4641" CreationDate="2014-10-17T22:57:32.043" Score="1" ViewCount="2223" Body="&lt;p&gt;I have a header file, where I try to collect global variable declarations. When trying to typedef a map I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n file included from Dis0_10.ino:7:&#xA;/var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build8295701509021940161.tmp/globals.h:23: error: expected initializer before '&amp;lt;' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;relevant code snippets from global.h are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef GLOBALS&#xA;#define GLOBALS&#xA;#include &amp;lt;map&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef std::map&amp;lt;uint8_t,uint8_t&amp;gt; memmap_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no clue, why this statement should fail. I consider it rather straight forward. So I think there must be some problems of &lt;a href=&quot;https://stackoverflow.com/questions/6558697/c-map-expected-initializer-before-token&quot;&gt;this kind here&lt;/a&gt;. Or am I missing another include?&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2017-04-16T22:45:15.180" Title="problem using std::map. Are there known obstructing macros?" Tags="|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4641" PostTypeId="2" ParentId="4640" CreationDate="2014-10-18T02:16:31.107" Score="3" Body="&lt;p&gt;The C++ standard library is not available for arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some implementations of similar containers or certain functions exist on the web, but for the most part the standard library is impractical on a device with such small amounts of both RAM and program memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An implementation of SGI STL for AVR has been documented here: &lt;a href=&quot;http://andybrown.me.uk/wk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;http://andybrown.me.uk/wk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;map is mentioned as being particularly impractical for anything less than an arduino mega(1280). An example of maps working is included on the page so it seems like a good lead if you really must use one, but I've never done this myself so I cant guarantee it still works.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-10-18T02:16:31.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4642" PostTypeId="1" AcceptedAnswerId="4647" CreationDate="2014-10-18T06:56:19.897" Score="0" ViewCount="49" Body="&lt;p&gt;I hava an Arduino Duemilanove but I think that its FTDI chip is crashed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Mega too, so can I use it to program my Duemilanove?&lt;/p&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="84" LastEditDate="2014-10-18T08:07:15.163" LastActivityDate="2014-12-17T23:04:11.633" Title="Use Arduino Mega to program Arduino Duemilanove" Tags="|arduino-mega|arduino-duemilanove|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4645" PostTypeId="1" CreationDate="2014-10-18T14:49:37.190" Score="4" ViewCount="9400" Body="&lt;p&gt;I understand that el wire and paper needs a special power source known as an inverter to light it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I wanted to control it from an arduino, what point would I connect the arduino to the light or inverter?&lt;/p&gt;&#xA;" OwnerUserId="4446" LastActivityDate="2017-05-08T16:04:28.593" Title="Controlling EL wire or panels with arduino" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4647" PostTypeId="2" ParentId="4642" CreationDate="2014-10-18T22:16:10.963" Score="1" Body="&lt;p&gt;Yes, this is not an uncommon activity.  This is called using an Arduino as an In-System Programmer (ISP)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page has the information and Arduino program you need.  You'll need to adjust for the Arduino Mega pin differences, but that's fairly easy.&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where the ArduinoISP page references pin 13, on the Mega it's pin 52.&#xA;Where the ArduinoISP page references pin 12, on the Mega it's pin 50.&#xA;Where the ArduinoISP page references pin 11, on the Mega it's pin 51.&#xA;Where the ArduinoISP page references pin 10, on the Mega it's pin 53.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you should be able to connect the Mega to the patient in the same way as described, load the ArduinoISP sketch into the Mega, preferably from the GitHub repository linked in the article (&lt;a href=&quot;https://github.com/rsbohn/arduinoisp&quot; rel=&quot;nofollow&quot;&gt;https://github.com/rsbohn/arduinoisp&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3416" LastActivityDate="2014-10-18T22:16:10.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4648" PostTypeId="1" CreationDate="2014-10-18T23:45:21.063" Score="1" ViewCount="4895" Body="&lt;p&gt;Currently I have been doing a project where I need to know the speed of the vehicle, I have implemented the following code but the results have not been good because when the vehicle is in motion always prints &lt;code&gt;STOPPED&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the OBDII-UART card from Sparkfun with Arduino MEGA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The connection of the cards shown in the image attached below&#xA;&lt;img src=&quot;https://i.stack.imgur.com/J3JDI.png&quot; alt=&quot;OBDII-UART -- ARDUINO MEGA&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  1.   char rxData[20];&#xA;  2.   char rxIndex = 0;&#xA;  3.   String inputString = &quot;&quot;;&#xA;  4.   boolean stringComplete = false;&#xA;  5.   void setup(){&#xA;  6.   Serial.begin(9600);&#xA;  7.   Serial1.begin(9600);&#xA;  8.   Serial.flush();&#xA;  9.   Serial1.flush();&#xA;  10.   //Reset IC&#xA;  11.   Serial1.println(&quot;ATZ&quot;);&#xA;  12.   delay(1500);&#xA;  13.   getOBDResponse();&#xA;  14.   Serial.println(rxData);&#xA;  15.   clearBuffer();&#xA;  16.   getOBDResponse();&#xA;  17.   Serial.println(rxData);&#xA;  18.   clearBuffer();&#xA;  19.   //Sets IC to defults&#xA;  20.   Serial1.println(&quot;ATD&quot;);&#xA;  21.   delay(1000);&#xA;  22.   getOBDResponse();&#xA;  23.   Serial.println(rxData);&#xA;  24.   clearBuffer();&#xA;  25.   getOBDResponse();&#xA;  26.   Serial.println(rxData);&#xA;  27.   clearBuffer();&#xA;  28.   Serial1.println(&quot;ATSP0&quot;);&#xA;  29.   delay(1000);&#xA;  30.   getOBDResponse();&#xA;  31.   Serial.println(rxData);&#xA;  32.   clearBuffer();&#xA;  33.   getOBDResponse();&#xA;  34.   Serial.println(rxData);&#xA;  35.   clearBuffer();&#xA;  36.   Serial1.println(&quot;010D&quot;);&#xA;  37.   delay(1000);&#xA;  38.   getOBDResponse();&#xA;  39.   Serial.println(rxData);&#xA;  40.   clearBuffer();&#xA;  41.   getOBDResponse();&#xA;  42.   Serial.println(rxData);&#xA;  43.   clearBuffer();&#xA;  44.   Serial1.println(&quot;ATDP&quot;);&#xA;  45.   delay(1000);&#xA;  46.   getOBDResponse();&#xA;  47.   Serial.println(rxData);&#xA;  48.   clearBuffer();&#xA;  49.   getOBDResponse();&#xA;  50.   Serial.println(rxData);&#xA;  51.   clearBuffer();&#xA;  52.   //Bus initiation&#xA;  53.   Serial1.println(&quot;ATSI&quot;);&#xA;  54.   delay(3000);&#xA;  55.   getOBDResponse();&#xA;  56.   Serial.println(rxData);&#xA;  57.   clearBuffer();&#xA;  58.   getOBDResponse();&#xA;  59.   Serial.println(rxData);&#xA;  60.   clearBuffer();&#xA;  61.   Serial.flush();&#xA;  62.   Serial1.flush();&#xA;  63.   }&#xA;  64.   void loop(){&#xA;  65.   /*&#xA;  66.   if(stringComplete){&#xA;  67.   Serial.println(inputString);&#xA;  68.   inputString = &quot;&quot;;&#xA;  69.   stringComplete = false;&#xA;  70.   }&#xA;  71.   */&#xA;  72.   Serial1.flush();&#xA;  73.   Serial1.println(&quot;010D&quot;);&#xA;  74.   getOBDResponse();&#xA;  75.   Serial.println(rxData);&#xA;  76.   clearBuffer();&#xA;  77.   getOBDResponse();&#xA;  78.   Serial.println(rxData);&#xA;  79.   clearBuffer();&#xA;  80.   }&#xA;  81.   void getOBDResponse(){&#xA;  82.   char inChar = 0;&#xA;  83.   while(inChar != '\r'){&#xA;  84.   if(Serial1.available() &amp;gt; 0){&#xA;  85.   if(Serial1.peek() == '\r'){&#xA;  86.   inChar = Serial1.read();&#xA;  87.   rxData[rxIndex] = '\0';&#xA;  88.   rxIndex = 0;&#xA;  89.   }else{&#xA;  90.   inChar = Serial1.read();&#xA;  91.   rxData[rxIndex++] = inChar;&#xA;  92.   }&#xA;  93.   }&#xA;  94.   }&#xA;  95.   }&#xA;  96.   void clearBuffer(){&#xA;  97.   int i;&#xA;  98.   for(i = 0; i &amp;lt; 20; i++){&#xA;  99.   rxData = '';&#xA;  100.   }&#xA;  101.   }&#xA;  102.   void serialEvent1(){&#xA;  103.   while(Serial1.available()){&#xA;  104.   char input = (char)Serial1.read();&#xA;  105.   inputString += input;&#xA;  106.   if(input == '\r'){&#xA;  107.   stringComplete = true;&#xA;  108.   }&#xA;  109.   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have based on the example is the page of the card &lt;a href=&quot;https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide/connecting-to-an-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide/connecting-to-an-arduino&lt;/a&gt;, but when I set the protocol sends me Ok, but when I ask for the speed I send a message from Seeking I do not understand.Information truck tried to read from the console on a laptop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I accuratley get the speed of the car?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, now I require to get the speed I have entered the command according to the command table ELM327 I quickly attached.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Bs3Ux.png&quot; alt=&quot;Parameter Identification&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4453" LastEditorUserId="4453" LastEditDate="2014-10-19T19:36:24.870" LastActivityDate="2017-05-29T23:40:12.787" Title="How can I be engaging the arduino mega with OBD-II UART card?" Tags="|arduino-mega|uart|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4649" PostTypeId="1" AcceptedAnswerId="4650" CreationDate="2014-10-19T04:03:21.263" Score="-1" ViewCount="1798" Body="&lt;p&gt;How can you sense a closed circuit? I want to have 4 pins with disconnected wires and when touched with a fifth wire play a specific note on a piezo buzzer until disconnected again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Capacitive-Touch-Arduino-Keyboard-Piano/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;This project&lt;/a&gt; loops through several keys and checks whether they are being touched using the &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow&quot;&gt;Capactive Sensor library&lt;/a&gt;. I want to do something similar, but not with capacitive sensing. Alternatively, it may work to have the buzzer always trying to play a note, but only sounds when one of the 4 circuits is close. I'm just not sure how that would work in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is their code that uses capactive sensing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;#include &quot;pitches.h&quot;&#xA;&#xA;#define COMMON_PIN      2    // The common 'send' pin for all keys&#xA;#define BUZZER_PIN      A4   // The output pin for the piezo buzzer&#xA;#define NUM_OF_SAMPLES  10   // Higher number whens more delay but more consistent readings&#xA;#define CAP_THRESHOLD   150  // Capactive reading that triggers a note (adjust to fit your needs)&#xA;#define NUM_OF_KEYS     8    // Number of keys that are on the keyboard&#xA;&#xA;// This macro creates a capacitance &quot;key&quot; sensor object for each key on the piano keyboard:&#xA;#define CS(Y) CapacitiveSensor(2, Y)&#xA;&#xA;// Each key corresponds to a note, which are defined here. Uncomment the scale that you want to use:&#xA;int notes[]={NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5}; // C-Major scale&#xA;&#xA;// Defines the pins that the keys are connected to:&#xA;CapacitiveSensor keys[] = {CS(3), CS(4), CS(5), CS(6), CS(7), CS(8), CS(9), CS(10)};&#xA;&#xA;void setup() { &#xA;  // Turn off autocalibrate on all channels:&#xA;  for(int i=0; i&amp;lt;8; ++i) {&#xA;    keys[i].set_CS_AutocaL_Millis(0xFFFFFFFF);&#xA;  }&#xA;  // Set the buzzer as an output:&#xA;  pinMode(BUZZER_PIN, OUTPUT); &#xA;}&#xA;&#xA;void loop() {    &#xA;  // Loop through each key:&#xA;  for (int i = 0; i &amp;lt; 8; ++i) {&#xA;    // If the capacitance reading is greater than the threshold, play a note:&#xA;    if(keys[i].capacitiveSensor(NUM_OF_SAMPLES) &amp;gt; CAP_THRESHOLD) {&#xA;      tone(BUZZER_PIN, notes[i]); // Plays the note corresponding to the key pressed&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="223" LastActivityDate="2014-10-19T04:12:18.710" Title="Sense Whether Circuit is Closed" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4650" PostTypeId="2" ParentId="4649" CreationDate="2014-10-19T04:12:18.710" Score="6" Body="&lt;p&gt;Connect your fifth wire to ground. Set the four inputs to &lt;code&gt;INPUT_PULLUP&lt;/code&gt;. The four inputs will default &lt;code&gt;HIGH&lt;/code&gt;, and be pulled &lt;code&gt;LOW&lt;/code&gt; when connected to the ground wire.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-19T04:12:18.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4651" PostTypeId="2" ParentId="4645" CreationDate="2014-10-19T10:34:19.550" Score="0" Body="&lt;p&gt;You could connect the Arduino to the light using a relay or any electronic switches (transistors and etc) that can take around 10 to 15mA per meter (so its distance dependent). You could use this link &lt;a href=&quot;https://learn.adafruit.com/el-wire/soldering-to-el-wire&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/el-wire/soldering-to-el-wire&lt;/a&gt; to find out where to solder the switch connections to  &lt;/p&gt;&#xA;" OwnerUserId="4456" LastActivityDate="2014-10-19T10:34:19.550" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4652" PostTypeId="1" AcceptedAnswerId="4653" CreationDate="2014-10-19T11:47:11.280" Score="1" ViewCount="7836" Body="&lt;p&gt;Is it possible to directly communicate USB D+ D- to Arduino Mega serial port TX RX?&lt;/p&gt;&#xA;" OwnerUserId="3030" LastActivityDate="2014-10-19T12:45:02.990" Title="USB D+ D- to Arduino Mega RX TX" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4653" PostTypeId="2" ParentId="4652" CreationDate="2014-10-19T12:21:48.767" Score="2" Body="&lt;p&gt;No, D+/- are high frequency USB signals. TX/RX is 5V UART protocol, i.e. compeletely different. But you can e.g. use AT90USB128x processor to avoid 16u2 bridge. The prosessor is not so mighty as 2560 but it's cheaper and simplifies design.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastEditorUserId="3825" LastEditDate="2014-10-19T12:45:02.990" LastActivityDate="2014-10-19T12:45:02.990" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4654" PostTypeId="1" CreationDate="2014-10-19T14:32:22.280" Score="0" ViewCount="1085" Body="&lt;p&gt;Can someone please tell me what's going on with my LCD screen and how I can fix this issues below?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno R3 w/ ATMEGA 328P-PU&lt;/li&gt;&#xA;&lt;li&gt;16x2 LCD&lt;/li&gt;&#xA;&lt;li&gt;TowerPro MicroServo SG90&lt;/li&gt;&#xA;&lt;li&gt;DPDT Slide Switch w/ 120 ohm resistor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&#xA;Read the sensor value (If switch is on or off), and move a servo accordingly while displaying switch state on LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt;&#xA;LCD display seems to receive random data during program run (see image). All starts up well, and as soon as a few seconds have lapsed in the void loop(), the screen becomes garbled. Also, the switch value (while debugging) gets a zero reading while HIGH, acting accordingly as if the switch was off. The servo motor runs as it should, but gets random pulses every now and again where it starts to buzz, but doesn't turn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Images:&lt;/strong&gt;&#xA;Three images below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uP7ZR.jpg&quot; alt=&quot;Outcome 1&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wTFLb.jpg&quot; alt=&quot;Outcome 2&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/upDjK.jpg&quot; alt=&quot;Garbled Data Received&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Schematic:&lt;/strong&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/89tdw.png&quot; alt=&quot;Schema&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Coding:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;const int sensorPin = A0;    // select the input pin for the potentiometer&#xA;int ledPin = 13;      // select the pin for the LED&#xA;int sensorValue = 0;  // variable to store the value coming from the sensor&#xA;int oldPos = 0;&#xA;int pos = 0;&#xA;int oldStat = 0;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;Servo servo;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  lcd.begin(16, 2);&#xA;  lcd.setCursor (0, 0);&#xA;  lcd.print(&quot;Starting up FSS!&quot;);&#xA;  delay(700);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Init SERVO...&quot;);&#xA;  delay(500);&#xA;  servo.attach(9);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;SERVO Success!&quot;);&#xA;  delay(400);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Testing SERVO...&quot;);&#xA;  servo.write(0);&#xA;  delay(200);&#xA;  servo.write(90);&#xA;  delay(200);&#xA;  servo.write(45);&#xA;  delay(300);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;SERVO Running!&quot;);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Select AUX Source&quot;);&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  lcd.clear();&#xA;  lcd.setCursor (0, 0);&#xA;  lcd.print(&quot;Select AUX Src&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;&#xA;  sensorValue = analogRead(sensorPin);&#xA;  Serial.print(&quot;Sensor: &quot;);&#xA;  Serial.println(sensorValue);&#xA;&#xA;  if(sensorValue == 0){&#xA;    //if(sensorValue = oldStat){&#xA;      oldStat = sensorValue;&#xA;      digitalWrite(ledPin, LOW);&#xA;      lcd.print(&quot;Switch is OFF&quot;);&#xA;      pos = 45;&#xA;&#xA;      Serial.println(&quot;Switch is OFF&quot;);&#xA;    //}&#xA;  } else{&#xA;    digitalWrite(ledPin, HIGH);&#xA;    lcd.print(&quot;Switch is ON&quot;);&#xA;    pos = 120;&#xA;    Serial.println(&quot;Switch is ON&quot;);&#xA;  }&#xA;&#xA;  if (pos != oldPos){&#xA;    servo.write(pos);&#xA;  }&#xA;&#xA;  oldPos = pos;&#xA;&#xA;  delay (700);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4457" LastActivityDate="2014-10-19T14:50:53.657" Title="Unusual LCD behaviour" Tags="|arduino-uno|lcd|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4655" PostTypeId="2" ParentId="4654" CreationDate="2014-10-19T14:50:53.657" Score="4" Body="&lt;p&gt;Insufficient decoupling. Put a 100nF cap on the supply lines at the LCD and a 100uF cap on the supply lines at the servo.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-19T14:50:53.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4658" PostTypeId="1" CreationDate="2014-10-20T05:32:03.697" Score="0" ViewCount="409" Body="&lt;p&gt;I'm working on this project where I have interfaced a LED strip (a two wire LED strip) with &lt;a href=&quot;http://redbearlab.com/blendmicro/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; Arduino (its not an Uno). I have setup every thing correctly according to &lt;a href=&quot;http://www.instructables.com/id/PWM-an-RGB-LED-Strip-with-Arduino/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; instructable. I'm able to make a simple blinky pattern and I turn it on/off with an Android app I made to communicate with the Arduino using Bluetooth on my phone. Cool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I cannot understand is, since the strip is two wired, how should I address individual LEDs on the strip to make more complex patterns? Can I use bit shifts? Reading an article from Makezine (insufficient reps to post more than 2 links), it says that I should connect the strup directly to the output pin. IMO, this will fry the Arduino or in a less virulent sway, not light up the strip in any way.&lt;/p&gt;&#xA;" OwnerUserId="4468" LastActivityDate="2014-10-20T07:55:46.280" Title="Controll LED Strip with Arduino BLE" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4659" PostTypeId="2" ParentId="4658" CreationDate="2014-10-20T07:55:46.280" Score="1" Body="&lt;p&gt;Addressing individual LEDS on a simple strip with LEDs in series and/or parallel connection is just not possible. &lt;br&gt;&#xA;Connecting the strip directly to an output pin is completely nonsense. Forget it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a strip with digital LED controllers populated, as described (for instance) in another link mentioned in your second link: &lt;a href=&quot;http://www.adafruit.com/products/306&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/306&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at this, then I'm sure you will come back with more detailed questions ;-)&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-10-20T07:55:46.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4661" PostTypeId="1" CreationDate="2014-10-14T04:26:51.813" Score="1" ViewCount="708" Body="&lt;p&gt;I have two Arduinos on a RS-485 line, one acting as a Master and the other as a Slave.  The Master simply transmits information to the Slave, which parses it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They work fine when the Master is turned on first and then the Slave is turned on.  However, I'd like to  make it so that the Slave can be disconnected and reconnected to the line and re-discover the connection (ideally without resetting either Arduino). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code from the Slave's loop &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void loop()&#xA;     {&#xA;&#xA;       if (RS485Serial.available() &amp;gt;0 )  //Look for data from other Arduino&#xA;       {   &#xA;        char byteSend = RS485Serial.read();    // Read received byte&#xA;        String str = String(byteSend);&#xA;         if (str == &quot;&amp;lt;&quot;)  {      //  beginning of the transmission&#xA;       // does stuff here&#xA;      }&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relevant section of Master's loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  output_value =&quot;&amp;lt;1,1,1,1,1,1,1&amp;gt;&quot;;&#xA; RS485Serial.print(output_value);&#xA; delay(250);&#xA; RS485Serial.flush();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any advice is appreciated...&lt;/p&gt;&#xA;" OwnerUserId="4389" OwnerDisplayName="Matt H" LastEditorUserId="42" LastEditDate="2015-04-10T16:26:23.587" LastActivityDate="2015-08-30T21:14:57.440" Title="RS-485 with Arduino" Tags="|serial|rs485|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4664" PostTypeId="1" AcceptedAnswerId="4665" CreationDate="2014-10-20T14:18:08.080" Score="0" ViewCount="68" Body="&lt;p&gt;Is there a way to connect and read the output of a long stem thermometer like this one to an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oydBw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4474" LastEditorUserId="4474" LastEditDate="2014-10-20T14:23:28.963" LastActivityDate="2014-10-20T17:27:06.063" Title="Connecting a Long Stem Thermometer to an Arduino to automate the recording of temperature in an experiment" Tags="|arduino-uno|hardware|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4665" PostTypeId="2" ParentId="4664" CreationDate="2014-10-20T17:27:06.063" Score="0" Body="&lt;p&gt;Interfacing with a temperature sensor such as the DS18B20 (&lt;a href=&quot;https://www.sparkfun.com/products/11050&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11050&lt;/a&gt;) would be much simpler than trying to interface with a thermometer with unknown internals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Theoretically, yes, you can use the thermometer you posted, but it won't be simple. The only way to know what you would have to do to interface with it is to open it up and see what's inside. You would still have to calibrate it though to make any sense of the readings you get from it.&lt;/p&gt;&#xA;" OwnerUserId="4393" LastActivityDate="2014-10-20T17:27:06.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4666" PostTypeId="1" AcceptedAnswerId="4674" CreationDate="2014-10-20T18:06:31.327" Score="1" ViewCount="425" Body="&lt;p&gt;I'm trying to concurrently learn electronics and Arduino, and have recently moved from simply powering LEDs to servos. In all my attempts with servos and reading about them (especially multiple ones, and when using external power supply plugged into the board), experienced users often mention you use voltage regulators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen some Arduino schematics with servos and voltage regulators, most that include some capacitors, but I can't seem to find any tutorials or resources that explain why, when and how to use these parts when learning electronics &amp;amp; Arduino. (I'd like to go from there to transistors, mosfets, etc.)&lt;/p&gt;&#xA;" OwnerUserId="4401" LastActivityDate="2014-10-28T23:56:08.133" Title="Where can I find beginner resources on using voltage regulators with Arduino circuits?" Tags="|voltage-level|servo|electronics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4667" PostTypeId="1" CreationDate="2014-10-20T19:22:12.370" Score="2" ViewCount="10361" Body="&lt;p&gt;I just bought the sensor &lt;a href=&quot;http://www.sainsmart.com/sainsmart-dht11-temperature-and-relative-humidity-sensor-module-for-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;DHT11&lt;/a&gt; and trying to test it with the library code provided by the IDE, but I always get the same error on &lt;code&gt;.read()&lt;/code&gt; . Code -2&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*####################################################################&#xA;FILE: dht11_functions.pde - DHT11 Usage Demo.&#xA;VERSION: 2S0A&#xA;&#xA;PURPOSE: Measure and return temperature &amp;amp; Humidity. Additionally provides conversions.&#xA;&#xA;LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)&#xA;GET UPDATES: https://www.virtuabotix.com/&#xA;&#xA;  --##--##--##--##--##--##--##--##--##--##--&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |&#xA;  ##  ##  ##  ## DHT11 SENSOR ##  ##  ##  ##&#xA;  ##  ##  ##  ##  ##FRONT ##  ##  ##  ##  ##&#xA;  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##&#xA;  --##--##--##--##--##--##--##--##--##--##--&#xA;      ||       ||          || (Not    ||&#xA;      ||       ||          || Used)   ||&#xA;    VDD(5V)   Readout(I/O)          Ground&#xA;&#xA;HISTORY:&#xA;Joseph Dattilo (Virtuabotix LLC) - Version 2S0A (27 May 12)&#xA;-Rewritten to with more powerful Versalino functionality&#xA;Joseph Dattilo (Virtuabotix LLC) - Version 0.4.5 (11/11/11)&#xA;-Made Library Arduino 1.0 Compatible&#xA;Joseph Dattilo (Virtuabotix LLC) - Version 0.4.0 (06/11/11)&#xA;-Fixed bugs (squish)&#xA;Mod by Rob Tillaart - Version 0.3 (28/03/2011)&#xA;Mod by SimKard - Version 0.2 (24/11/2010)&#xA;George Hadjikyriacou - Original version (??)&#xA;#######################################################################*/&#xA;&#xA;&#xA;#include &amp;lt;dht11.h&amp;gt;&#xA;&#xA;dht11 DHT11;&#xA;&#xA;void setup()&#xA;{&#xA;    DHT11.attach(2);&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;DHT11 TEST PROGRAM &quot;);&#xA;    Serial.print(&quot;LIBRARY VERSION: &quot;);&#xA;    Serial.println(DHT11LIB_VERSION);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(&quot;\n&quot;);&#xA;&#xA;    int chk = DHT11.read();&#xA;&#xA;    Serial.print(&quot;Read sensor: &quot;);&#xA;    switch (chk)&#xA;    {&#xA;        case 0: Serial.println(&quot;OK&quot;); break;&#xA;        case -1: Serial.println(&quot;Checksum error&quot;); break;&#xA;        case -2: Serial.println(&quot;Time out error&quot;); break;&#xA;        default: Serial.println(&quot;Unknown error&quot;); break;&#xA;    }&#xA;&#xA;    Serial.print(&quot;Humidity (%): &quot;);&#xA;    Serial.println((float)DHT11.humidity, DEC);&#xA;&#xA;    Serial.print(&quot;Temperature (°C): &quot;);&#xA;    Serial.println((float)DHT11.temperature, DEC);&#xA;&#xA;    Serial.print(&quot;Temperature (°F): &quot;);&#xA;    Serial.println(DHT11.fahrenheit(), DEC);&#xA;&#xA;    Serial.print(&quot;Temperature (°K): &quot;);&#xA;    Serial.println(DHT11.kelvin(), DEC);&#xA;&#xA;    Serial.print(&quot;Dew Point (°C): &quot;);&#xA;    Serial.println(DHT11.dewPoint(), DEC);&#xA;&#xA;    Serial.print(&quot;Dew PointFast (°C): &quot;);&#xA;    Serial.println(DHT11.dewPointFast(), DEC);&#xA;&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is my ouput:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DHT11 TEST PROGRAM &#xA;LIBRARY VERSION: 2S0A&#xA;&#xA;&#xA;Read sensor: Time out error&#xA;Humidity (%): 0.0000000000&#xA;Temperature (Â°C): 0.0000000000&#xA;Temperature (Â°F): 32.0000000000&#xA;Temperature (Â°K): 273.1499938964&#xA;Dew Point (Â°C): nan&#xA;Dew PointFast (Â°C): nan&#xA;&#xA;&#xA;Read sensor: Time out error&#xA;Humidity (%): 0.0000000000&#xA;Temperature (Â°C): 0.0000000000&#xA;Temperature (Â°F): 32.0000000000&#xA;Temperature (Â°K): 273.1499938964&#xA;Dew Point (Â°C): nan&#xA;Dew PointFast (Â°C): nan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The wiring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-left pin: 5v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-right pin: gnd&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-middle pin: 5v - digital2 - through 10kO resistor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hQQf0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HqhAN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATED:&lt;/strong&gt;&#xA;I found a &lt;a href=&quot;http://playground.arduino.cc/Main/DHT11Lib&quot; rel=&quot;nofollow noreferrer&quot;&gt;library&lt;/a&gt; that works. I also changed the wiring because I found out the sainsmart dht11 switches the pins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-left: signal with 10kO and to 5v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-middle: 5v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-right: GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now just a question.&#xA;What is the difference between these two dht11 sensors.&#xA;&lt;a href=&quot;http://www.exp-tech.de/Sensoren/DHT11-Feuchte-Temperatur-Sensor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dht11 basic&lt;/a&gt;&#xA;&lt;a href=&quot;http://www.sainsmart.com/sainsmart-dht11-temperature-and-relative-humidity-sensor-module-for-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;dht11 with board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one from sainsmart has a piece of circuit I don't know what it is.(I have a lack on electronics I try to fix step by step...) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;It is a resitor, capacitor?&lt;/strong&gt; it says 103.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does this affect to the wiring?&lt;/p&gt;&#xA;" OwnerUserId="3840" LastEditorUserId="3840" LastEditDate="2014-10-24T07:05:58.423" LastActivityDate="2016-01-09T15:40:00.870" Title="Basics with DHT11" Tags="|sensors|wires|temperature-sensor|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4668" PostTypeId="1" CreationDate="2014-10-20T20:22:23.570" Score="1" ViewCount="800" Body="&lt;p&gt;I am successful putting and retrieving a char array into Arduino flash memory using &lt;a href=&quot;https://www.arduino.cc/reference/en/language/variables/utilities/progmem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PROGMEM&lt;/a&gt; char arrays.&lt;/p&gt;&#xA;&lt;p&gt;I am building my application using header files with a class definition / implementation and would like to keep the strings in the same header file.&lt;/p&gt;&#xA;&lt;p&gt;If I define another PROGMEM char array neither one can be executed. In other words, these PROGMEM are global arrays as far as the Arduino compiler is concerned. They compile, but they won't show up.&lt;/p&gt;&#xA;&lt;p&gt;Here is my test code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  lcd.clear();&#xA;  lcd.print(*strFlashDebug[0]);  // in CDebug&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(*strFlashTrack[0]);  // in CTrack&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I put both definitions in the same header file, it only works with only one &lt;em&gt;lcd.print&lt;/em&gt; enabled, not commented out.&lt;/p&gt;&#xA;&lt;p&gt;It appears that multiple PROGMEM arrays can be defined and compiled, but only one is actually usable. What is the explanation?&lt;/p&gt;&#xA;" OwnerUserId="3916" LastEditorUserId="510" LastEditDate="2023-09-16T11:38:33.140" LastActivityDate="2023-09-16T15:02:00.640" Title="Using PROGMEM to save RAM" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4669" PostTypeId="2" ParentId="4668" CreationDate="2014-10-20T21:35:56.390" Score="0" Body="&lt;p&gt;A PROGMEM variable definition (i.e., declaration) allocates memory in FLASH. You need use an &lt;em&gt;extern&lt;/em&gt; clause in the header file and a physical declaration in the C code which is linked in your code. It's pays also for potential static class properties.&lt;/p&gt;&#xA;&lt;p&gt;Also check if &lt;em&gt;lcd.print()&lt;/em&gt; accepts a PROGMEM array, i.e., if the overloaded procedure is defined and called.&lt;/p&gt;&#xA;&lt;p&gt;Just note I recommend using much more effective string formatting via file streams (FILE) and &lt;em&gt;fprintf_P()&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastEditorUserId="510" LastEditDate="2023-09-16T11:38:42.103" LastActivityDate="2023-09-16T11:38:42.103" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="4670" PostTypeId="2" ParentId="4667" CreationDate="2014-10-20T21:53:07.917" Score="0" Body="&lt;p&gt;It seems you wiring is ok, although I think you already have pull-up resistor on breakout board (look for a small 103 resistor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you can try another library for DHT?&#xA;I have used one made by adafruit (&lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/DHT-sensor-library&lt;/a&gt;) and everything worked just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Ian&lt;/p&gt;&#xA;" OwnerUserId="4479" LastActivityDate="2014-10-20T21:53:07.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4672" PostTypeId="1" CreationDate="2014-10-21T01:00:36.303" Score="3" ViewCount="556" Body="&lt;p&gt;I bought a cheap &quot;Make&quot; kit at RadioShack, which includes some sort of proprietary Arduino Uno compatible motor/sensor shield. Naturally, the documentation is pretty bad. The documentation and Arduino code for the kit is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It includes &lt;a href=&quot;https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit/raw/master/Schematics/2770168-CorePCB_schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;a circuit schematic&lt;/a&gt; (2770168-CorePCB_schematic.pdf), but I'm still having trouble mapping the pins to the Arduino's pins. Can anyone help me make sense of this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've made out so far is the shield's screw terminals appear to be connected to quadruple h-bridges. However, there are several other pin headers that I can't quite make out. I think it also directly exposes 4 of the Uno's ADC pins and 4 DIO pins. There are four pins for dual IR line sensors, but there's a lot of circuitry between these and any Arduino pins. Almost everything feeds into a DC6688F2SCN chip, but I can't find a datasheet anywhere, so I have no idea what it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manual says jumpers on J16 need to be removed in order to connect to the Uno over USB, so it looks like I can't use the shield with the board and debug via USB at the same time. Is this board worth investigating or should I trash it?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="26916" LastEditDate="2017-11-24T11:07:27.303" LastActivityDate="2018-06-22T18:14:14.493" Title="Debugging a RadioShack Arduino motor/sensor shield" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4674" PostTypeId="2" ParentId="4666" CreationDate="2014-10-21T19:15:45.773" Score="1" Body="&lt;p&gt;My understanding is that the capacitors smooth the signals. This helps the internal workings of the regulator not overshoot when compensating for a change in the input or the output. If the capacitors are not there then there is a chance of oscillation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A search of google for Voltage Regulator Tutorial will give you quite a few results, here is one that I found (obviously this could change so if it does just do a search and go from there)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.baldengineer.com/tutorials/regulator-basics/&quot; rel=&quot;nofollow&quot;&gt;regulator basics&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link above is a good explanation that is not too in depth. But as stated in the comments look at the datasheet for specific values needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also did a search for 'what are the capacitors for on a voltage regulator' and found some good info about why they are needed.&lt;/p&gt;&#xA;" OwnerUserId="4488" LastEditorUserId="4488" LastEditDate="2014-10-27T14:41:44.713" LastActivityDate="2014-10-27T14:41:44.713" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4675" PostTypeId="1" AcceptedAnswerId="4676" CreationDate="2014-10-21T21:54:22.897" Score="1" ViewCount="2375" Body="&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/6/6f/Positive_Negative_Logic_connection_of_Switch_with_Microcontroller_pin.png&quot; alt=&quot;Positive Negative Logic connection of Switch&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried in my Arduino the negative logic to get a digital input from a switch (with 10 KΩ resistance). If I want to use the positive logic what kind of resitance I have to use? For me seems that 10KOhm it to big and probably a smaller resistor should be used. How do we compute the value of the resistor? The schemes of Negative and Positive Logic from &lt;a href=&quot;http://users.ece.utexas.edu/~valvano/Volume1/E-Book/C8_SwitchLED.htm&quot; rel=&quot;nofollow&quot;&gt;Valvano's notes/ebook - University of Texas&lt;/a&gt; gives 10 kΩ in both cases. Is it correct?&lt;/p&gt;&#xA;" OwnerUserId="1061" LastEditorUserId="1061" LastEditDate="2014-10-22T12:23:18.023" LastActivityDate="2014-10-22T17:52:11.357" Title="Resistance in Switch (negative vs positive logic)" Tags="|arduino-uno|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4676" PostTypeId="2" ParentId="4675" CreationDate="2014-10-21T23:05:45.420" Score="3" Body="&lt;p&gt;From a pure electronics viewpoint, there is no real difference between both circuits, the difference will be handled by your code running on the MCU, as a close switch will either be &lt;code&gt;HIGH&lt;/code&gt; or &lt;code&gt;LOW&lt;/code&gt; depending on the logic you used to wire your switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistor must be present for 2 reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to avoid producing a shortcut between &lt;code&gt;+5V&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt; when the switch is closed, without it the shortcut would probably damage your power supply circuitry (if both pins are directly taken from Arduino, that would mean damaging Arduino supply circuits)&lt;/li&gt;&#xA;&lt;li&gt;to make the voltage pin attached to the pin the &quot;&lt;em&gt;winner&lt;/em&gt;&quot; of both voltage pins when the switch is closed, ie that pin will provide the level to Arduino input pin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The value of the resistor should  be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;high enough to limit the current between &lt;code&gt;+5V&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt; when the switch is closed, preventing damage and limiting overall power consumption of your circuit&lt;/li&gt;&#xA;&lt;li&gt;not too high to allow providing a voltage level to the input pin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using 10k means that, applying Ohm's law, when closing the switch, a 0.5mA current would flow from &lt;code&gt;+5V&lt;/code&gt; to &lt;code&gt;GND&lt;/code&gt;, which is generally acceptable in terms of consumption and cwill not damage your power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the input pin is &quot;&lt;strong&gt;high impedance&lt;/strong&gt;&quot; which means it has no voltage level if not connected to anything, and it does not supply or sink any current (or more accurqtely a negligible current only).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, it is good to know that Arduino MCU offers the &lt;code&gt;INPUT_PULLUP&lt;/code&gt; mode for digital pins, where an internal resistor pulls up the pin input to 5V.  This enables you to directly connect your switch between the pin and &lt;code&gt;GND&lt;/code&gt;. So you just have to code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(XXX, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(XXX, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For information, according to ATmega328P datasheet (the MCU of Arduino UNO), those internal pullup resistors have a value between 20k and 50k.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-10-22T17:52:11.357" LastActivityDate="2014-10-22T17:52:11.357" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4677" PostTypeId="1" CreationDate="2014-10-21T21:38:31.953" Score="1" ViewCount="759" Body="&lt;p&gt;I'm using 3 Arduino Uno boards with Ethernet shields. Each is connected to my home Internet switch with an Ethernet cable.  I assigned a different local IP address to each Arduino and gave each board a different MAC Address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each Uno is collecting temperature/humidity for a bedroom in my house.  The data is sent to a MySQL Database using PHP/HTML.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They work fine for a while (5 minutes) and then they conflict each other.  If I use one Arduino at a time it works fine, but I can't get them to work together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to solve the problem?&lt;/p&gt;&#xA;" OwnerUserId="4503" OwnerDisplayName="Alfredo" LastEditorUserId="3917" LastEditDate="2015-11-24T06:06:20.320" LastActivityDate="2015-11-24T06:06:20.320" Title="Why can't I connect more than one Arduino Uno + Ethernet Shield to my network?" Tags="|arduino-uno|shields|ethernet|networking|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4678" PostTypeId="2" ParentId="3003" CreationDate="2014-10-22T00:44:20.210" Score="1" Body="&lt;p&gt;Simulink most definitely supports higher PWM frequencies than 490Hz. I know because I have used it to generate PWMs in the 20kHz range on microcontroller boards. I suggest you post more details or screenshots of your work. Have someone help you determine where you are going wrong.&lt;/p&gt;&#xA;" OwnerUserId="4393" LastActivityDate="2014-10-22T00:44:20.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4679" PostTypeId="1" CreationDate="2014-10-22T05:12:03.627" Score="2" ViewCount="13385" Body="&lt;p&gt;I am wiring some LED's with buttons to trigger them but i don't know if i have the wiring right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xat1x.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /* switch&#xA; * &#xA; * Each time the input pin goes from LOW to HIGH (e.g. because of a push-button&#xA; * press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's&#xA; * a minimum delay between toggles to debounce the circuit (i.e. to ignore&#xA; * noise).  &#xA; *&#xA; * David A. Mellis&#xA; * 21 November 2006&#xA; */&#xA;&#xA;int inPin = 2;         // the number of the input pin&#xA;int outPin = 13;       // the number of the output pin&#xA;&#xA;int state = HIGH;      // the current state of the output pin&#xA;int reading;           // the current reading from the input pin&#xA;int previous = LOW;    // the previous reading from the input pin&#xA;&#xA;// the follow variables are long's because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long time = 0;         // the last time the output pin was toggled&#xA;long debounce = 200;   // the debounce time, increase if the output flickers&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(inPin, INPUT);&#xA;  pinMode(outPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  reading = digitalRead(inPin);&#xA;&#xA;  // if the input just went from LOW and HIGH and we've waited long enough&#xA;  // to ignore any noise on the circuit, toggle the output pin and remember&#xA;  // the time&#xA;  if (reading == HIGH &amp;amp;&amp;amp; previous == LOW &amp;amp;&amp;amp; millis() - time &amp;gt; debounce) {&#xA;    if (state == HIGH)&#xA;      state = LOW;&#xA;    else&#xA;      state = HIGH;&#xA;&#xA;    time = millis();    &#xA;  }&#xA;&#xA;  digitalWrite(outPin, state);&#xA;&#xA;  previous = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;note&#xA;  The code is not set to the pins yet.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3584" LastEditorUserId="3584" LastEditDate="2014-10-22T06:28:37.490" LastActivityDate="2015-02-07T21:30:35.787" Title="How do i wire a switch to control Leds on a arduino nano" Tags="|led|arduino-nano|digital|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4680" PostTypeId="1" CreationDate="2014-10-22T09:33:17.383" Score="1" ViewCount="209" Body="&lt;p&gt;i am german and my english is not the best, anyway i hope you will understand my problem. &#xA;At the moment i construct a little car with some friends. We have still completed the frame and now we think about controlling it in a electronic way. For example with a controller of a playstation or with our smartphones, however, it should be electronic, so i think about to do this with an arduino board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have two motors. One for the direction and the other one for the movement. &#xA;The first has about 8 ampere and about 12 volt, the other has 800 watt, so around 40 ampere and 24 volt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, whether it is possible and if so how to control them (or one them) with an arduino board and what do i need in addition?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be great if you could help us :)&lt;/p&gt;&#xA;" OwnerUserId="4498" LastActivityDate="2015-02-20T10:33:33.227" Title="Controlling bigger motors with an arduino board" Tags="|motor|android|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4681" PostTypeId="1" AcceptedAnswerId="4683" CreationDate="2014-10-22T11:56:15.507" Score="9" ViewCount="48987" Body="&lt;p&gt;I am used to Arduino sketches with a &lt;code&gt;void setup()&lt;/code&gt; part that runs once, and a &lt;code&gt;void loop()&lt;/code&gt; part that keeps looping. What happens when you have void functions outside of the main &lt;code&gt;void loop()&lt;/code&gt;? Will these all keep looping in parallel or do they run one after the other? Or do certain void functions only run once certain criteria has been met (like a while loop)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in the code below, when will the &lt;code&gt;void receiveData(int byteCount)&lt;/code&gt; and the &lt;code&gt;void sendData()&lt;/code&gt; functions run?  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//I2C_test&#xA;&#xA;//This code demonstrates communication via an I2C bus between a raspberry pi and an arduino.&#xA;//When the Raspberry pi (master) sends data to the Arduino (slave), the Arduino uses this&#xA;//data to control a motor. After the Arduino has recieved data from the master, it then collects&#xA;//data from the external environment via a sensor and sends this data back to the Raspberry pi.&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;int number = 0; //Declare variables&#xA;int val = 0;&#xA;&#xA;void setup() {&#xA;  //Anything between the curly brackets runs once when the arduino is turned on or reset&#xA;  pinMode(0, INPUT);&#xA;  //Set pin 0 as input and 3 as output&#xA;  pinMode(3, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  //Set the data rate for serial transmission at 9600bps&#xA;  Wire.begin(0x04);&#xA;  //Initiate the Wire library, join the Arduino as a slave, and specify its 7 bit slave address&#xA;  Wire.onReceive(receiveData);&#xA;  //Define callbacks for i2c communication&#xA;  Wire.onRequest(sendData);&#xA;}&#xA;&#xA;void loop() {&#xA;  //The code between the curly brackets keeps repeating&#xA;  delay(100);&#xA;}&#xA;&#xA;void receiveData(int byteCount) {&#xA;  while(Wire.available()) {&#xA;    number = Wire.read();&#xA;    //Set the variable &quot;number&quot; to the data sent by the master&#xA;    analogWrite(3, number);&#xA;    //Write this number to pin 3 (PWM). This controls the motor speed&#xA;  }&#xA;  val = analogRead(0);&#xA;  //Read the voltage on pin 0 (connected to the sensor). Map input voltages between 0 and 5 volts into integer values between 0 and 1023&#xA;}&#xA;&#xA;void sendData() {&#xA;  Wire.write(val);&#xA;  //Send the data read from the sensor to the master.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4499" LastEditorUserId="4628" LastEditDate="2017-02-03T14:51:41.883" LastActivityDate="2019-02-05T10:09:42.390" Title="How do functions outside of void loop work?" Tags="|arduino-uno|i2c|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4682" PostTypeId="2" ParentId="4681" CreationDate="2014-10-22T12:32:16.833" Score="1" Body="&lt;p&gt;It works as normal function, it must be called to make sense. loop()/setup() are called from a main() function which is compiled from Arduino directory and linked in. receiveData/sendData are to called from your program which root is in loop/setup functions.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-22T12:32:16.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4683" PostTypeId="2" ParentId="4681" CreationDate="2014-10-22T12:32:21.800" Score="11" Body="&lt;p&gt;The &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; functions are unusual because they are called automatically for you by the Arduino code. No other functions behave this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, a function will never run unless you explicitly call it yourself (e.g. from within &lt;code&gt;setup()&lt;/code&gt; or &lt;code&gt;loop()&lt;/code&gt;), or instruct another part of the program to call it. (There are other ways to execute functions, but that usually involves some very advanced tinkering which is best avoided.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;pinMode()&lt;/code&gt; is a function just like any other. It only runs when you actually put something like &lt;code&gt;pinMode(3, INPUT)&lt;/code&gt; in your code. At that point, it runs once, finishes, and then the calling function carries on from where it left off (they never run in parallel).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example code you've posted is quite interesting. Look at these lines in &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.onReceive(receiveData);&#xA;Wire.onRequest(sendData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These lines are telling the &lt;code&gt;Wire&lt;/code&gt; object to call &lt;code&gt;receiveData()&lt;/code&gt; and &lt;code&gt;sendData()&lt;/code&gt; in response to I2C events. It does this by passing function pointers which are stored and used by &lt;code&gt;Wire&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd recommend searching for information about &lt;strong&gt;C/C++ function pointers&lt;/strong&gt; online if you want to learn more about this. You may also be interested to explore Arduino's &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot;&gt;&lt;code&gt;attachInterrupt()&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-10-22T12:32:21.800" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4684" PostTypeId="1" CreationDate="2014-10-22T13:46:15.890" Score="2" ViewCount="102" Body="&lt;p&gt;I'd like to extract data collected by a battery powered arduino for example once a day without stopping it and not using SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's posible, when I want to extract the collected data, to connect a laptop through the USB and then get data because Arduino is, at regulat time intervals, calling 'Serial.println(...)'?&lt;/p&gt;&#xA;" OwnerUserId="4502" LastActivityDate="2014-12-22T00:56:34.457" Title="Extract arduino collected data periodically" Tags="|debugging|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4685" PostTypeId="2" ParentId="4684" CreationDate="2014-10-22T14:35:54.333" Score="0" Body="&lt;p&gt;Yes, you can do it. Depends how much data to have enough storage space. You also need consider potential memory endurance. E.g. external I2C ferromagnetic memory is good option. Of course it's not on Arduino board, you implement extension.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-22T14:35:54.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4687" PostTypeId="1" AcceptedAnswerId="4688" CreationDate="2014-10-22T20:19:21.293" Score="0" ViewCount="417" Body="&lt;p&gt;The title sums it all up. While testing  the new proximity detector I bought off of Amazon, a spark flew from some random area and my Arduino's On LED went off while its Loop LED stayed in a dim state. I am here to ask you guys if this basically counts my Arduino as fried and that I need a new one, or if I should wait and see if it works again, being that I wrote this 5 minutes after the thing happened. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;afroraydude&lt;/p&gt;&#xA;" OwnerUserId="4509" OwnerDisplayName="afroraydude" LastEditorUserId="4539" LastEditDate="2014-10-25T06:21:06.170" LastActivityDate="2015-02-26T15:46:24.930" Title="Is my Arduino UNO fried?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4688" PostTypeId="2" ParentId="4687" CreationDate="2014-10-22T20:37:07.460" Score="6" Body="&lt;p&gt;It's hard to tell without further testing. Do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Remove the Uno from the faulty circuit, making sure you remove all the wiring from the Arduino board.&lt;/li&gt;&#xA;&lt;li&gt;Plug the Uno into the USB port. Does the ON LED light up? Does the built-in LED on D13 blink three times? (this should happen if you had the optiboot bootloader)&lt;/li&gt;&#xA;&lt;li&gt;Remove the USB cable and plug the Uno to a 9V source through the barrel power connector. Do the same test above.&lt;/li&gt;&#xA;&lt;li&gt;Can you upload the Blink sketch? If you can, does it make D13 LED blink once a second?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Report your findings by updating your question.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-02-26T15:46:24.930" LastActivityDate="2015-02-26T15:46:24.930" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4691" PostTypeId="2" ParentId="4684" CreationDate="2014-10-23T00:39:23.240" Score="1" Body="&lt;p&gt;This is a bit crude, but I think you could use an FTDI cable (which is a USB to UART converter) to have a program in your laptop talk to the Arduino using its UART (serial) interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do it, you could plug the USB side of a FTDI serial cable to your laptop. The other end of the cable has a plug with 6 pins, 2 of which are the TX and RX serial signals. You could plug those two signals to pins D0 and D1 (RX &amp;amp; TX) of your Arduino using male-to-male jumpers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of software, you could code the Arduino sketch to listen on the serial port for a command from your laptop. When the command arrives, it would output the stored data (could be comma separated values with CR+LF as end of line). Your laptop would then listen for the answer and retrieve the data.&lt;/p&gt;&#xA;" OwnerUserId="46" LastActivityDate="2014-10-23T00:39:23.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4692" PostTypeId="1" CreationDate="2014-10-23T04:52:01.693" Score="0" ViewCount="1100" Body="&lt;p&gt;I am new to arduino and Xbee these stuff.&#xA;Trying to send RPM (obtained and calculated by arduino using puulse function) data from arduino to Xbee as analog input to xbee series1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems XBee analog input read a range of 0 volts to 1.2 volts.&#xA;However, not quite sure how to implement and write the corret code.&#xA;Following are Arduino code and schematic circuit.&#xA;Any idea?&#xA;I really appreciate your help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 7;  //7&#xA;float rpm;&#xA;float duration;&#xA;float y;&#xA;&#xA;unsigned long val;&#xA;float rps;&#xA;float read_rpm;&#xA;int pin_out=10;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;  pinMode(pin, INPUT);&#xA;  pinMode(pin_out,OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; val =  pulseIn(pin, LOW,70000000);&#xA;&#xA; duration=(float)val/1000000.00;&#xA; rps= 1.00/duration;&#xA;rpm=60.00*rps;&#xA;&#xA;analogWrite(pin_out,(int)rpm);&#xA;&#xA;Serial.print(&quot;RPM=\t&quot;);&#xA;&#xA;Serial.print(rpm);&#xA;&#xA;&#xA;Serial.print(&quot;\t rps= \t&quot;);&#xA;&#xA;Serial.print(rps);&#xA;&#xA;Serial.print(&quot;\t dt=\t&quot;);&#xA;&#xA;Serial.println(val);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uRcSP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4103" LastEditorUserId="3866" LastEditDate="2014-10-23T04:58:57.793" LastActivityDate="2014-10-23T06:32:16.003" Title="How to send RPM data as analog input from arduino to Xbee" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4693" PostTypeId="2" ParentId="4692" CreationDate="2014-10-23T05:16:09.517" Score="2" Body="&lt;p&gt;I would suggest you to send bytes instead of &quot;analog value&quot;. When you calculate your value, not sure why you use &lt;code&gt;float&lt;/code&gt; and then convert it to &lt;code&gt;int&lt;/code&gt;, but here is how i would do. Communicate to xbee via serial communication, send bytes to xbee(its even easier than &quot;analog value&quot;). Added if statment to print RPM every second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;/* Serial communication with Xbee.&#xA;On Arduino pin 9 is Rx connect to Xbee Tx, &#xA;pin 8 is Txconnect to Xbee Rx*/&#xA;SoftwareSerial xbeeSerial(9, 8); // RX, TX&#xA;&#xA;int pin = 7;  //7&#xA;float rpm;&#xA;float duration;&#xA;float y;&#xA;&#xA;unsigned long val,time;&#xA;float rps;&#xA;float read_rpm;&#xA;int pin_out=10;&#xA;&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  pinMode(pin, INPUT);&#xA;  pinMode(pin_out,OUTPUT);&#xA;  Serial.println(&quot;I am ready to send some RPM!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  xbeeSerial.begin(9600);&#xA;  time = millis();&#xA;}&#xA;&#xA;void loop()// run over and over&#xA;{&#xA; val =  pulseIn(pin, LOW,70000000);&#xA;&#xA; duration=(float)val/1000000.00;&#xA; rps= 1.00/duration;&#xA;rpm=60.00*rps;&#xA;&#xA;/* Sending float to Xbee&#xA;Float is 4 byte size*/&#xA;serialFloatPrint(rpm);&#xA;&#xA;int floatToInt = (int)rpm;&#xA;&#xA;/* To send INT to XBEE&#xA;Int is 2 byte size*/&#xA;xbeeSerial.write(highByte(floatToInt));&#xA;xbeeSerial.write(lowByte(floatToInt));&#xA;&#xA;/*Print RPM every second*/&#xA;If(millis()-time&amp;gt;1000){&#xA;  Serial.print(&quot;RPM=\t&quot;);&#xA;  Serial.print(rpm);&#xA;  Serial.print(&quot;\t rps= \t&quot;);&#xA;  Serial.print(rps);&#xA;  Serial.print(&quot;\t dt=\t&quot;);&#xA;  Serial.println(val);&#xA;  time = millis();&#xA; }&#xA;}&#xA;&#xA;void serialFloatPrint(float f) {&#xA;  byte * b = (byte *) &amp;amp;f;&#xA;  //xbeeSerial.print(&quot;f:&quot;);&#xA;  xbeeSerial.print(b[0]);&#xA;  xbeeSerial.print(b[1]);&#xA;  xbeeSerial.print(b[2]);&#xA;  xbeeSerial.print(b[3]);&#xA;  /* DEBUG */&#xA;  Serial.println();&#xA;  Serial.print(b[0],BIN);&#xA;  Serial.print(b[1], BIN);&#xA;  Serial.print(b[2], BIN);&#xA;  Serial.println(b[3], BIN);&#xA;  //*/&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-23T06:32:16.003" LastActivityDate="2014-10-23T06:32:16.003" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4694" PostTypeId="2" ParentId="4680" CreationDate="2014-10-23T06:10:07.317" Score="2" Body="&lt;p&gt;DC motors are typically driven with some sort of BJT/MOSFET solution that will be able to sink enough current to drive the motor because a microcontroller pin can only usually provide a few mA of power.  See &lt;a href=&quot;http://www.dummies.com/how-to/content/how-to-spin-a-dc-motor-with-the-arduino.html&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; for info on basic microcontroller DC motor control.  If slow response is acceptable and only one level of power is required (i.e. no PWM) even power relays could be used to turn on off the motor.  Some applications could use this.  However, for your application, it sounds like you will want more responsive control over the motor and need a particularly high power MOSFET to properly drive your application as your motor is very high power.  Such FETS such as &lt;a href=&quot;http://www.digikey.com/product-highlights/us/en/ixys-gigamos-power-mosfets/332&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; could be used to properly control such a motor using the microcontroller.  Do note additional protection circuitry will be necessary and is probably the topic of another feed, but this would be a place to start if you wanted to build it from scratch.  Otherwise go with an over the shelf driver board which will probably have something like the link above used on it.&lt;/p&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2014-10-23T06:10:07.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4695" PostTypeId="1" CreationDate="2014-10-23T13:46:51.823" Score="14" ViewCount="35807" Body="&lt;p&gt;Is there any central place that we can get drawing pattern functions for the addressable LED strips like the once based on the WS2812B component?  These are sold on the Adafruit site under the NeoPixel name.  For example I know of a few pattern examples like the Larson Scanner (Cylon), a candle light flicker or a rainbow pattern.  However I could not find a single pattern repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a &lt;a href=&quot;http://datadictionary.blogspot.com/2014/08/new-arduino-moving-rainbow-lab-for-kids.html&quot;&gt;project&lt;/a&gt; for kids learning to program the Arduino and it would be nice to have all the patterns in a single place and to be able to switch between the program examples with a mode switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If people send me links I am happy to post a blog of them.&lt;/p&gt;&#xA;" OwnerUserId="4519" LastEditorUserId="4519" LastEditDate="2014-10-30T04:08:58.527" LastActivityDate="2018-01-15T01:51:09.877" Title="Pattern library for addressable LED strips" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4696" PostTypeId="1" AcceptedAnswerId="4697" CreationDate="2014-10-23T15:04:44.637" Score="10" ViewCount="2891" Body="&lt;p&gt;As you know, the Arduino IDE resets the Arduino when the Serial Monitor is opened. I want also my program to do it. But I don't know how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I examined the source code of the Arduino IDE (Serial.java &amp;amp; SerialMonitor.java), but I can't find where it sends the reset command. Where is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use C# to communicate with serial.&lt;/p&gt;&#xA;" OwnerUserId="4430" LastEditorUserId="510" LastEditDate="2015-10-06T11:43:09.273" LastActivityDate="2015-10-06T11:43:09.273" Title="How to reset Arduino from software" Tags="|serial|reset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4697" PostTypeId="2" ParentId="4696" CreationDate="2014-10-23T15:21:23.383" Score="10" Body="&lt;p&gt;OK, I have solved this by sending DSR pulse as seen on code below: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mySerial.DtrEnable = true;&#xA;mySerial.Open();&#xA;Thread.Sleep(1000);&#xA;mySerial.DtrEnable = false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4430" LastEditorUserId="4430" LastEditDate="2014-10-24T09:09:47.903" LastActivityDate="2014-10-24T09:09:47.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4700" PostTypeId="1" AcceptedAnswerId="4701" CreationDate="2014-10-24T01:48:50.583" Score="0" ViewCount="5683" Body="&lt;p&gt;I am trying to use the sleep function in lieu of &lt;code&gt;delay()&lt;/code&gt;, but when I include &lt;code&gt;sleep()&lt;/code&gt;, I get &lt;code&gt;Sweep.cpp:60:10: error: ‘sleep’ was not declared in this scope&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read some place, about &lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&lt;/code&gt; but that is a fail.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;void setup() {                &#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);   // set the LED on&#xA;  sleep(1);              // wait for a second&#xA;  digitalWrite(13, LOW);    // set the LED off&#xA;  sleep(1000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to locate &lt;code&gt;sleep.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ locate sleep.h | grep avr&#xA;/usr/lib/avr/include/avr/sleep.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So then I started reading &lt;code&gt;avr/sleep.h&lt;/code&gt;, and it seems like I'm doing it right, according to the examples. So, why might this be failing?&lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="37" LastEditDate="2014-10-24T17:45:52.623" LastActivityDate="2014-10-24T17:45:52.623" Title="error: ‘sleep’ was not declared in this scope" Tags="|programming|library|avr|sleep|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4701" PostTypeId="2" ParentId="4700" CreationDate="2014-10-24T03:48:41.527" Score="4" Body="&lt;p&gt;&quot;sleep()&quot; is not a function on arduino. The sleep.h file contains functions for the hardware sleep functionality used to reduce power consumption when processing isn't necessary. &quot;delay()&quot; is the right thing to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVR only has one thread, and so there is no meaning to pausing execution by deferring to another thread. Hardware interrupts will always interrupt the current code no matter what it is doing, they are not equivalent to threads (although they can introduce similar bugs). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to wait and still do other calculations you will need to write code that can wait for a time without blocking. This can be done many ways, one way being to use the arduino library function &quot;millis()&quot; to repeatedly check if it is time to do a certain action, and doing something else for a while if not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, vanilla arduino should be using its own packaged avr lib, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino/hardware/tools/avr/avr/include/avr/sleep.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of the one located in your usr/lib directory. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-10-24T05:12:49.163" LastActivityDate="2014-10-24T05:12:49.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4703" PostTypeId="1" CreationDate="2014-10-24T09:59:12.710" Score="3" ViewCount="538" Body="&lt;p&gt;I'm trying to use CTC mode on Arduino 1 but I have the following problem.&#xA;I need to generate an interrupt on threshold B and A and I have set the prescaler to 1 since I want to generate interrupt A at 15999 (correspond to 1ms) and interupt B at 15( ie a number small enough from the start of counting).&#xA;I'have write a println function in ISR(A and B) to proof the calling of the latter but the program does not print all the characters in the println function and furthermore the counter does not reset at treshold A but stop his work.&#xA;How I can resolve the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the program I wrote:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {  &#xA;    TCCR1A = 0x00;                // No outputs on compare math, no PWM mode    &#xA;    TCCR1B = 1 | (1 &amp;lt;&amp;lt; WGM12);    // Enable CTC mode up to OCR1A and prescaler /1 -&amp;gt; Start&#xA;    //TCCR1B = 0b00001001;  &#xA;    TCCR1C = 0x00;                // Nothing to set into C register  &#xA;&#xA;&#xA;    OCR1A = 15999;                // Set Threshold A  &#xA;    OCR1B = 15;                // Set Threshold B  &#xA;    TCNT1 = 0;                    // Clear Counter  &#xA;&#xA;    TIFR1 = (1 &amp;lt;&amp;lt; OCIE1A) | (1 &amp;lt;&amp;lt; OCIE1B);    // Clear Interrupt flag Match A and B&#xA;&#xA;    TIMSK1 = (1 &amp;lt;&amp;lt; OCIE1A) | (1 &amp;lt;&amp;lt; OCIE1B);   // Enable Interrapt flag Match A and B&#xA;&#xA;    analogRead(A0);            // Dummy Read to make Arduino setting the AD  &#xA;    ADCSRA |= (1 &amp;lt;&amp;lt; ADIE);     // Enable AD Interrupt on conversion completed  &#xA;    ADCSRB = 5;                // Select Timer 1 Match B as trigger  &#xA;    ADCSRA |= 1 &amp;lt;&amp;lt; ADATE;      // Enable Auto trigger  &#xA;&#xA;&#xA;    Serial.begin(115200);      // Initialize the USART  &#xA;    Serial.println(&quot;Start&quot;);   // Write the welcome message  &#xA;&#xA;&#xA;&#xA;}  &#xA;&#xA;void loop() {  &#xA;    // Nothing to do    &#xA;}  &#xA;&#xA;&#xA;ISR(ADC_vect)  &#xA;{ &#xA;    Serial.print(TCNT1);  &#xA;    Serial.print(&quot; - ADC Conversion Completed (&quot;);   &#xA;    Serial.print(ADC);  &#xA;    Serial.println(&quot;)&quot;);  &#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)  &#xA;{  &#xA;    TCNT1=0;  &#xA;    Serial.print(TCNT1);  &#xA;    Serial.println(&quot; - Interrupt A&quot;);  &#xA;}  &#xA;&#xA;ISR(TIMER1_COMPB_vect)  &#xA;{  &#xA;    Serial.print(TCNT1);  &#xA;    Serial.println(&quot; - Interrupt B&quot;);  &#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4528" LastEditorUserId="4143" LastEditDate="2014-10-24T13:27:14.787" LastActivityDate="2014-10-24T13:27:14.787" Title="ctc mode on atmega 328" Tags="|arduino-uno|programming|atmega328|c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4704" PostTypeId="2" ParentId="4703" CreationDate="2014-10-24T10:17:01.400" Score="4" Body="&lt;p&gt;I don't know about configuring the timers on an AVR off hand, but one thing I will point out:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Never ever use Serial in an ISR.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Serial is interrupt driven - when there are characters in the outgoing serial buffer an interrupt routine sends them out through the serial port.  That can't happen when you're in an interrupt routine yourself, so when the buffer fills up the next Serial.write() (print, etc) blocks until there is room in the buffer for the next character.  As the ISR can't run, that space never appears, so the print(), write(), etc never finish and the program locks up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should store any incoming values in your ISRs into volatile variables, and set flags to indicate to your main program what has happened in the ISR - then your main loop() reads (and resets) those flags and prints out the statuses you want.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-10-24T10:17:01.400" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4705" PostTypeId="1" AcceptedAnswerId="4714" CreationDate="2014-10-24T12:05:19.787" Score="0" ViewCount="3075" Body="&lt;p&gt;I have ordered my HC-05 BT modules.&#xA;My question is this:&#xA;Is it possible to send multiple channels over bluetooth. For example, stereo sound has two channels. I think i have seen people do this but i'm not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible, could you please provide some more information on how its done?&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1499" LastActivityDate="2016-10-03T08:10:45.703" Title="Sending multiple channels with bluetooth" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4706" PostTypeId="2" ParentId="4376" CreationDate="2014-10-24T13:46:08.313" Score="0" Body="&lt;p&gt;There are libraries that allow multitasking, for instance my library &lt;a href=&quot;https://launchpad.net/arduos&quot; rel=&quot;nofollow&quot;&gt;arduOS&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;arduos16.h&amp;gt;&#xA;#include &amp;lt;arduos_core.h&amp;gt;&#xA;#include &amp;lt;roundscheduler.h&amp;gt;&#xA;&#xA;SYS_enable_preemptive; // do NOT forget this!!!&#xA;void setup()&#xA;{&#xA;    auto sched = new SYS::RoundScheduler(2);&#xA;    sched-&amp;gt;add(&amp;amp;loop1); // those 2 are functions.&#xA;    sched-&amp;gt;add(&amp;amp;loop2);&#xA;    SYS::start();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But keep in mind that actual multitasking can be rather tricky, with very obscure bugs. (but you can find them).&lt;/p&gt;&#xA;" OwnerUserId="4531" LastEditorUserId="37" LastEditDate="2014-10-24T18:08:46.663" LastActivityDate="2014-10-24T18:08:46.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4707" PostTypeId="1" CreationDate="2014-10-24T16:29:09.130" Score="1" ViewCount="293" Body="&lt;p&gt;I'm trying to make project to monitor my home. I am using some gas sensors and temperature and humidity sensors. I want to do this wirelessly and I think the &#xA;best thing to do that is XBee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this code for the transmitter Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char dataPacket[64];&#xA;&#xA;int gx = 1;&#xA;int gy = 321;&#xA;int gz = 456;&#xA;int ax = 654;&#xA;int ay = 789;&#xA;int az = 987; &#xA;int mx = 147; &#xA;int my = 258; &#xA;int mz = 369;&#xA;&#xA;void setup(){&#xA;&#xA; Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;   sprintf(dataPacket, &quot;X%d&quot; ,gx);&#xA;    //  sprintf(dataPacket, &quot;A%dB%dC%dD%dE%dF%dG%dH%dI%d&quot;, gx, gy, gz, ax, ay, az, mx,     my, mz);&#xA;Serial.println(dataPacket);&#xA;&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gx gy gz .... these are the sensor reading variables&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and in the receiving Arduino I use this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;    // Start up our serial port, we configured our XBEE devices for 9600 bps.&#xA;    Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;    if(Serial.available() &amp;gt; 0)&#xA;{&#xA;     while(Serial.available() &amp;gt; 0)&#xA; {&#xA;        char dataPacket[64];&#xA;&#xA;for (int i = 0; i &amp;lt; 64; i++)&#xA;{&#xA;  dataPacket[i] = Serial.read();&#xA; Serial.print(dataPacket[0]);&#xA;&#xA;}&#xA;&#xA;String show = Serial.readStringUntil('C') ;&#xA;delay(500);&#xA;&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but i can't split the values from the stream and put them into their variables (gx gy ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have idea how to split it?&lt;/p&gt;&#xA;" OwnerUserId="4533" LastEditorUserId="313" LastEditDate="2014-11-03T22:42:53.057" LastActivityDate="2014-11-03T22:42:53.057" Title="split reading sensors values from stream after it via xbee" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4709" PostTypeId="1" AcceptedAnswerId="4715" CreationDate="2014-10-24T20:58:24.140" Score="1" ViewCount="1868" Body="&lt;p&gt;I'm working on a custom Arduino core based on the teensy code and want to be able to get the board USB VID/PID from boards.txt, as in .board.vid and .board.pid&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I can tell, Arduino already does this for the Leonardo and similar since if I change the VID/PID in boards.txt then the sketch will run with those values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how do I actually get at them? Right now the code I have has hard coded values, but it would be great to make them dynamic.&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2014-10-25T00:39:07.453" Title="Get board.vid and board.pid value in code" Tags="|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4710" PostTypeId="2" ParentId="4707" CreationDate="2014-10-24T21:01:26.990" Score="2" Body="&lt;p&gt;Try a communication protocol with a &lt;code&gt;,&lt;/code&gt; as a delimiter like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;messageId,data1,data2,data3,....,dataN\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use the &lt;code&gt;Messenger&lt;/code&gt; library to parse it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my answer on comms protocols here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/4214/communication-protocol-best-practices-and-patterns/4222#4222&quot;&gt;Communication Protocol Best Practices and Patterns&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An how to use the &lt;code&gt;Messenger&lt;/code&gt; library here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/4436/send-processing-color-data-into-arduino/4527#4527&quot;&gt;Send Processing color data into Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-10-24T21:01:26.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4711" PostTypeId="1" CreationDate="2014-10-24T23:23:30.643" Score="1" ViewCount="7795" Body="&lt;p&gt;I have made this If-Then-Else code, but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I tough only the analog code is wrong, but if I take a digital port, the code doesn't work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorPin = A0;    // select the input pin for the potentiometer&#xA;int sensorValue = 0.00001;  // variable to&#xA;&#xA;void setup() {&#xA;  pinMode(13, OUTPUT);  //LED BORD UIT&#xA;  pinMode(12, OUTPUT);  //LED4&#xA;  pinMode(11, OUTPUT);  //LED3&#xA;  pinMode(10, OUTPUT);  //LED2&#xA;  pinMode(9, OUTPUT);   //LED1&#xA;  pinMode(8, OUTPUT);   //Elektro Magneet&#xA;  pinMode(A0, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (A0 == HIGH) {&#xA;     digitalWrite(13, LOW); &#xA;     digitalWrite(12, HIGH);   //LED on, magnet off&#xA;     digitalWrite(11, HIGH);   &#xA;     digitalWrite(10, HIGH);   &#xA;     digitalWrite(9, HIGH);&#xA;     digitalWrite(8, LOW);     &#xA;&#xA;  } else {    &#xA;     digitalWrite(13, LOW); &#xA;     digitalWrite(12, LOW);   // LED Off, magnet on&#xA;     digitalWrite(11, LOW);   &#xA;     digitalWrite(10, LOW);   &#xA;     digitalWrite(9, LOW);      &#xA;     digitalWrite(8, HIGH);     &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Alex" LastActivityDate="2014-11-10T18:36:35.250" Title="Arduino if else code" Tags="|c|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4712" PostTypeId="2" ParentId="4711" CreationDate="2014-10-24T23:27:34.320" Score="2" Body="&lt;p&gt;You're comparing the pin variable value with &lt;code&gt;HIGH&lt;/code&gt;. If you want to get the value &lt;em&gt;at a digital input&lt;/em&gt; then you need to use &lt;a href=&quot;http://arduino.cc/en/Reference/digitalRead&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;digitalRead()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-10-24T23:27:34.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4713" PostTypeId="2" ParentId="4711" CreationDate="2014-10-24T23:29:06.300" Score="9" Body="&lt;p&gt;Replace the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (A0 == HIGH) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (digitalRead(A0) == HIGH) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you plan on using the pin back as an analog input, use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (analogRead(A0) &amp;gt; 512) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The explanation is what Ignacio said: you were comparing the pin &quot;name&quot; &lt;code&gt;A0&lt;/code&gt; directly to &lt;code&gt;HIGH&lt;/code&gt; instead of reading from the input named &lt;code&gt;A0&lt;/code&gt;. To make it clearer, the two lines are equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (A0 == HIGH)&#xA;if (0 == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's more about what pin names to use with digitalRead() and analogRead() here: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/67087/analogread0-or-analogreada0&quot;&gt;analogRead(0) or analogRead(A0) at EE.SE&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="46" OwnerDisplayName="Ricardo" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-10-24T23:36:21.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4714" PostTypeId="2" ParentId="4705" CreationDate="2014-10-25T00:26:07.007" Score="2" Body="&lt;p&gt;The BT module will connect as a SPP (serial port) device, and then pass the serial data to and from the arduino and whatever you choose to connect to (that supports SPP). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one channel, and in any case only one set of TX and RX wires that will be connected to your arduino, but this does not stop you from sending as much data of as many different types as you want. You are only limited by the BAUD rate and how much time the message will take to send. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For complicated data transfers you will need to write the code for a protocol so both sides can make sense of what the other says. You are free to do whatever you can think of here, although if you need to make a complicated protocol you might get some use out of the answers to this question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/4214/communication-protocol-best-practices-and-patterns/&quot;&gt;Communication Protocol Best Practices and Patters&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-10-25T00:26:07.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4715" PostTypeId="2" ParentId="4709" CreationDate="2014-10-25T00:39:07.453" Score="1" Body="&lt;p&gt;The preprocessor will sub in the values for the names &quot;USB_PID&quot; and &quot;USB_VID&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this line in &quot;platform.txt&quot; grabs them and makes build flags for them: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the -D* option in the build is equivalent to the following lines being in the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define USB_VID /*value of build.vid*/&#xA;#define USB_PID /*value of build.pid*/&#xA;#define USB_MANUFACTURER /*value of build.usb_manufacturer*/&#xA;#define USB_PRODUCT /*value of build.usb_product*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are curious, they are used by the libraries in &quot;USBCore.cpp&quot;. Also, they will never be defined for devices they don't apply to.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-10-25T00:39:07.453" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4718" PostTypeId="1" CreationDate="2014-10-25T11:20:24.750" Score="0" ViewCount="218" Body="&lt;p&gt;I stumbled upon &lt;a href=&quot;https://arduino.stackexchange.com/questions/61/can-i-program-for-arduino-without-having-a-real-board&quot;&gt;this&lt;/a&gt; question here, so I tried the Codeblocks alternative. After opening an Arduino Project, and leaving all options to default, I ran the Arduino version of the Hello World. A popup opened that requests a serial port to move on. What error did I do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If more details are needed I'll answer the comments. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="4543" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-11-05T20:01:49.427" Title="How do I activate emulation in the Coddeblocks Arduino IDE" Tags="|arduino-uno|emulation|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4721" PostTypeId="1" AcceptedAnswerId="4733" CreationDate="2014-10-25T17:38:31.057" Score="2" ViewCount="5268" Body="&lt;p&gt;I just acquired a Arduino learning kit, which includes a 20x4 LCD display. I was going to test it, so I grabbed an example &quot;hello world&quot; program from the Arduino docs, connected the display appropriately, and then &quot;Voila! ... Oh, it didn't work.&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display lights up both its backlight and characters, however not in any desirable pattern. The first and third lines are full white (display is white-on-blue), while lines 2 and 4 are full blue. See picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4PyVc.jpg&quot; alt=&quot;lines: white blue white blue&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below schematic is exactly how I've connected the display, which should be correct.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kWKVx.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fkWKVx.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I triple-checked all wiring for any shorts, adjusted the potentiometer to a good value and quadruple-checked the connections, and wasn't able to find any errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The dead-simple example program is following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// LiquidCrystal display with:&#xA;// rs on pin 12&#xA;// rw on pin 11&#xA;// enable on pin 10&#xA;// d4, d5, d6, d7 on pins 5, 4, 3, 2&#xA;LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);&#xA;&#xA;&#xA;void setup() {&#xA;    // Print a message to the LCD.&#xA;    lcd.begin(20, 4);&#xA;    lcd.print(&quot;hello, world!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4547" LastActivityDate="2015-02-12T07:48:18.207" Title="20x4 LCD shows alternating blank lines" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4722" PostTypeId="2" ParentId="4721" CreationDate="2014-10-25T18:25:17.340" Score="0" Body="&lt;p&gt;I had similar problem and I found that I had wrong contrast/brightness. Communication was working but just the characters were invisible. I spent much time, changed the LCD and in the last minute before went to rubish I got it.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-25T18:25:17.340" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4725" PostTypeId="1" AcceptedAnswerId="4727" CreationDate="2014-10-26T01:36:55.833" Score="8" ViewCount="1706" Body="&lt;p&gt;Is there any significant performance trade-off between buttons wired with the internal vs external pull-up/down resistors? I see a lot of tutorials demonstrating the use of external resistors when wiring a simple button, like &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Pushbutton&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;http://arduino.cc/en/tutorial/button&quot;&gt;this&lt;/a&gt;. But since the Arduino/AVR includes internal pull-up resistors, you can wire a button without any external resistor as demonstrated &lt;a href=&quot;http://arduino.cc/en/Tutorial/InputPullupSerial&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any good reason to complicate your design with an extra resistor?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2014-10-26T03:51:58.110" Title="Performance of internal vs external resistors" Tags="|arduino-uno|button|resistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4726" PostTypeId="2" ParentId="4725" CreationDate="2014-10-26T01:44:11.303" Score="0" Body="&lt;p&gt;I think it depends on the application you're going for.  A simple switch probably doesn't need a resistor, since it doesn't require the chip to provide any specific voltage or current.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're trying to run an LED or something that requires a specific amount of current or voltage, then you may be better off supplying the power connection &amp;amp; resistor rather than relying on the chip to provide the proper power to the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another situation may be where you're approaching the maximum power output of the chip that you might change to external pull-up/down resistors.&lt;/p&gt;&#xA;" OwnerUserId="3416" LastActivityDate="2014-10-26T01:44:11.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4727" PostTypeId="2" ParentId="4725" CreationDate="2014-10-26T03:51:58.110" Score="5" Body="&lt;p&gt;If you are using the pin as an input in close proximity to the Arduino there is little reason to use an external pullup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of factors to consider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the switch is some distance from the chip and/or in a noisy environment it will be more susceptible to interference as the internal pullups are high impedance (20kΩ to 150kΩ depending on model).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pin is used as both input &amp;amp; output the pullup can reduce the voltage swing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other applications e.g. Raspberry Pi the state of the pin between boot and software initialisation can be significant, but this should not be an issue with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-10-26T03:51:58.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4728" PostTypeId="1" AcceptedAnswerId="4731" CreationDate="2014-10-26T04:20:21.693" Score="0" ViewCount="225" Body="&lt;p&gt;I'm attempting to compile this simple &lt;a href=&quot;https://github.com/thomasfredericks/Bounce-Arduino-Wiring/blob/master/Bounce2/examples/bounce/bounce.ino&quot; rel=&quot;nofollow&quot;&gt;bounce.ino&lt;/a&gt; example with the &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow&quot;&gt;ino&lt;/a&gt; tool, but it's giving me the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bounce2.h: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've placed it in the same directory as bounce.ino. Why can't it find the header?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I'm using Ubuntu.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="10794" LastEditDate="2015-09-06T08:53:29.930" LastActivityDate="2015-09-06T08:53:29.930" Title="Compiling includes with Ino" Tags="|build|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4729" PostTypeId="1" CreationDate="2014-10-26T05:32:58.290" Score="0" ViewCount="832" Body="&lt;p&gt;I'm trying to find a way to set a -D compiler option from within the boards.txt file. Basically set a #define for use in code. There are already some special ones like board.vid but is there a generic way to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow the Teensy add-on adds a little magic that allows the IDE to recognize options like:&#xA;.board.define0=-DHELLOWORLD&#xA;.board.option0=-DHELLOWORLD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, add the -DHELLOWORD (#define HELLOWORLD) to the command line for GCC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, I can't get this to work without the Teensy add-on installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do this with the stock IDE?&lt;/p&gt;&#xA;" OwnerUserId="600" LastEditorUserId="37523" LastEditDate="2019-11-21T23:40:39.060" LastActivityDate="2019-11-21T23:40:39.060" Title="Add -D option via boards.txt" Tags="|compile|gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4730" PostTypeId="2" ParentId="1752" CreationDate="2014-10-26T09:17:21.613" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://www.ti.com/product/cc3000&quot; rel=&quot;nofollow&quot;&gt;Texas Instruments CC3000&lt;/a&gt; module 10USD/1000pcs, it does only support connecting to AP, i.e. no AdHoc/AP which is useless for direct using with iPad.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-26T09:17:21.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4731" PostTypeId="2" ParentId="4728" CreationDate="2014-10-26T09:44:05.190" Score="0" Body="&lt;p&gt;What OS are you using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in Linux (and some OS X installations) you should note that bounce.h and Bounce.h are two completely different files - you need to make sure you have the capitalization the same in your #include directive as the actual file on disk is.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-10-26T09:44:05.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4733" PostTypeId="2" ParentId="4721" CreationDate="2014-10-26T13:24:37.550" Score="1" Body="&lt;p&gt;Just putting the jumper wires in the plated holes, doesn't always give a good connection. Try applying some lateral force, to make sure all of them have proper contact. Wiring looks otherwise fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more permanent solution would be to solder some male headers to the display, so you can properly seat it into the breadboard.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-10-26T13:24:37.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4734" PostTypeId="1" CreationDate="2014-10-26T13:59:10.603" Score="0" ViewCount="531" Body="&lt;p&gt;The amount of memory needed for my user interface is outrageous. Hence I decided to use flash memory. But after some successful readouts from program space, problems emerge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated:&lt;/strong&gt;&#xA;I have some sort of initialisation files to collect all global arrays which go into flash like this: (intitialisation.cpp)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef INITIALISATIONDEF&#xA;#define INITIALISATIONDEF&#xA;&#xA;#include &quot;initialisation.h&quot; //which includes Arduino libraries and &quot;globals.h&quot;&#xA;&#xA;&#xA;const uint8_t gl_PsNMenuType[MAXMENUS] PROGMEM = { 0, 0, 0, 0, 0};  // this is, what I intend to read out later. &#xA;const uint8_t gl_PsNMenuParent[MAXMENUS] PROGMEM = { MAXMENUS, 0, 0, 0, 0};  &#xA;const uint8_t gl_PsNMenuFixTexts[MAXMENUS][MAXFIXTEXTSPM] PROGMEM = {  &#xA;  { 20, 2, MFTS, MFTS, MFTS}, // 0&#xA;  {2, 9, 1, MFTS, MFTS}, // 1&#xA;  {2, 10, MFTS, MFTS}, //2&#xA;  {2, 11, MFTS}, //3&#xA;  {2, 12, MFTS} //4&#xA;&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated:&lt;/strong&gt;&#xA;while I propagate all global vars via another header (globals.h):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef GLOBALS&#xA;#define GLOBALS&#xA;#define SDTXT&#xA;&#xA;#define MAXMENUS 80    &#xA;#define MAXFIXTEXTSPM 5  &#xA;&#xA;#include &quot;initialisation.h&quot;&#xA;extern const uint8_t gl_PsNMenuType[MAXMENUS];&#xA;extern const uint8_t gl_PsNMenuParent[MAXMENUS];  // referenz auf den übergeordneten MP&#xA;extern const uint8_t gl_PsNMenuFixTexts[MAXMENUS][MAXFIXTEXTSPM];  // Liste der festen Menütexte zu jedem MP&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as one can see, I do not initialise my arrays fully, as I'm in a development phase, but the first bytes should be zeroed out correctly AFAIK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, when accessing my stored values later in a third file: (uimenu.cpp)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;uimenu.h&quot; // which includes globals.h and initialisation.h&#xA;&#xA;// somewhere in the code inside a function, with uint8_t mp=0:&#xA;Serial.print(pgm_read_byte(gl_PsNMenuType[mp]));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last line should print 0, as stated in initialisation, but it prints 12.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I think, I'm doing sth. substantially wrong here, but have no clue at the moment. I have several guesses:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I should not use const with PROGMEM. I did this to be informed by the compiler, if I accidentally write to an array stored in flash.&lt;/li&gt;&#xA;&lt;li&gt;I made some mess with #includes, perhaps with order of occurrence. At the moment I try to sort the order out.&lt;/li&gt;&#xA;&lt;li&gt;There's something with having global variables or arrays defined and declared in a header and accessed in another source files function. But I cannot imagene, what.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Updated:&lt;/strong&gt; something wrong with my indices for my arrays? is uint8_t insufficient?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you need more information or code, I'll edit my question accordingly. Thanks in advance! I appreciate any help.&#xA;(all files were edited for brevity before posting them)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;I moved the definitions of the progmem arrays to the source file and all macro constants (#define) to globals.h. The outcome is: different numbers are printed, but they are wrong whatsoever. I poked elsewhere into the progmem array and got other wrong numbers.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2014-10-26T14:55:40.100" LastActivityDate="2015-11-22T06:39:01.300" Title="Data from PROGMEM array mismatches initialisation" Tags="|progmem|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4735" PostTypeId="2" ParentId="4729" CreationDate="2014-10-26T14:06:46.517" Score="2" Body="&lt;p&gt;Yes, it is possible in the 1.5.+ IDE. while not possible in the 1.0.+ and earlier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&quot; rel=&quot;nofollow&quot;&gt;Hardware-specification&lt;/a&gt; refers to both the boards.txt and platform.txt files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in short the boards.txt file specifies...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.build.f_cpu=16000000L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the platform.txt uses in the compile commands such as ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; -DF_CPU={build.f_cpu}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can your own. There is already a &quot;build.extra_flags=&quot; that some of the USB devices use to add their own FLAGs conditionally on the board type.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-10-26T14:06:46.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4736" PostTypeId="1" AcceptedAnswerId="4742" CreationDate="2014-10-26T15:04:10.003" Score="3" ViewCount="10746" Body="&lt;p&gt;Please don't judge me for asking this question i have never touch arduino before but We plan to use it in our thesis we are doing a budget plan and it must include wires. can anyone tell me the common wire sizes used? This is to estimate the prices.&lt;/p&gt;&#xA;" OwnerUserId="4474" LastActivityDate="2015-05-01T09:10:41.877" Title="Common Wire sizes for connecting peripherals to arduino" Tags="|wires|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4737" PostTypeId="1" CreationDate="2014-10-26T16:24:07.120" Score="1" ViewCount="986" Body="&lt;p&gt;What's the best way to wire a &lt;a href=&quot;https://solarbotics.com/download.php?file=483&quot; rel=&quot;nofollow&quot;&gt;QRB1114 IR sensor&lt;/a&gt; to an Arduino Uno? I'm attempting to use it as a white-line-on-black-background line detector. Google shows many different ways wire it to an Arduino, but I'm using &lt;a href=&quot;http://www.engr.ucsb.edu/~mdnip/me170c/images/qrb1114.png&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; because of its simplicity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I tested the circuit using the AnalogInput example code, I'm not getting the expected behavior. It registers a reading of 0 for both white and black backgrounds (I'm using white and black electrical tape as test surfaces), and occasionally registers between 5-10 if there's nothing in front of it at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the most likely problem? Is this circuit an improper way of wiring the sensor? Is my sensor defective? Is the code not reading it properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my test code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUTTON_PIN 2&#xA;#define LED_PIN 13&#xA;&#xA;const int IR_SENSOR_PIN = A0;&#xA;int sensorValue = 0;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    sensorValue = analogRead(IR_SENSOR_PIN);&#xA;    Serial.println(sensorValue);  &#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2014-10-26T17:02:31.653" Title="How to wire QRB1114 IR sensor to an Arduino Uno" Tags="|arduino-uno|sensors|analogread|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4738" PostTypeId="2" ParentId="4737" CreationDate="2014-10-26T17:02:31.653" Score="2" Body="&lt;p&gt;It was a dumb programming/wiring problem on my end. As I discovered from &lt;a href=&quot;http://abrobotics.tripod.com/Snuffy/line_sensor.htm&quot; rel=&quot;nofollow&quot;&gt;this description&lt;/a&gt;, the signal pin needs a pullup resistor. Since my circuit doesn't have that, I need to enable the pullup resistor on A0, which I wasn't doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After modifying my code to do that, the sensor works as expected.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2014-10-26T17:02:31.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4739" PostTypeId="1" CreationDate="2014-10-26T23:44:01.540" Score="5" ViewCount="616" Body="&lt;p&gt;I have ATmega168a on a breadboard. I am programming it via the Arduino IDE and a FT232RL USB adapter. When I select my board for 168 and upload, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stk500_getsync(): not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally this error means that either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My wiring is not correct&lt;/li&gt;&#xA;&lt;li&gt;I choose the wrong board&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So to double check my wiring, I replace the 168 with a 328p. I am able to program the 328, so I think its the board selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;Ardiono Diecimila or Duemilanove w/ ATmega168&lt;/code&gt; and I also have a custom board entry:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;atmega168bb.name=ATmega168 breadboard (16 MHz internal clock)&#xA;atmega168bb.upload.protocol=stk500&#xA;atmega168bb.upload.maximum_size=14336&#xA;atmega168bb.upload.speed=57600&#xA;&#xA;atmega168bb.bootloader.low_fuses=0x62&#xA;atmega168bb.bootloader.high_fuses=0xDF&#xA;atmega168bb.bootloader.extended_fuses=0xF9&#xA;atmega168bb.bootloader.path=arduino:atmega&#xA;atmega168bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_16MHz.hex&#xA;atmega168bb.bootloader.unlock_bits=0x3F&#xA;atmega168bb.bootloader.lock_bits=0x0F&#xA;&#xA;atmega168bb.build.mcu=atmega168&#xA;atmega168bb.build.f_cpu=16000000L&#xA;atmega168bb.build.core=arduino:arduino&#xA;atmega168bb.build.variant=arduino:standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I am able to program the 168 via my AVR Programmer/Debugger. If you are wondering why I should just use the AVR Dragon, there reason is that I a sometimes don't want to remove the chip from the bread board while developing and programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions I can try?&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2017-08-16T12:03:06.070" Title="ATmega168a Breadboard - can't load via Arduino IDE" Tags="|programming|arduino-ide|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4740" PostTypeId="1" AcceptedAnswerId="4741" CreationDate="2014-10-27T05:09:00.110" Score="2" ViewCount="756" Body="&lt;p&gt;I have a ATmega328p chip from a kit that was supposed to be an Arduino compatible thing. I decided to go beyond Arduino and try to program the chip directly. I setup an UNO as an Arduino ISP, more or less like the image here, but added some LEDs to pins 8, 9 and 10 for feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dvyjj.png&quot; alt=&quot;Arduino ISP&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This image has this caption.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because no external clock source is connected, the ATmega must be configured to use its internal clock.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think this chip was flashed with whatever tells it to use an external oscillator. And I do not have an external oscillator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I tell the chip to again use an internal oscillator when using an UNO as my programmer?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;» avrdude -p m328p -c avrisp -b 19200 -P /dev/cu.usbmodem1d11121&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.05s&#xA;&#xA;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume a device id of zero means the chip is not responding with data? because it's core is not cycling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need an oscillator installed just so I can wake it it up and tell it to not use an oscillator?&lt;/p&gt;&#xA;" OwnerUserId="942" LastActivityDate="2014-11-05T04:35:12.270" Title="Flashing a ATmega328 that came from an Arduino to not use an external oscillator" Tags="|avrdude|oscillator-clock|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4741" PostTypeId="2" ParentId="4740" CreationDate="2014-10-27T05:15:02.000" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I need an oscillator installed just so I can wake it it up and tell it to not use an oscillator?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, yes you do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pick up a 8-16MHz crystal (&lt;em&gt;not&lt;/em&gt; an oscillator) and two 15pF capacitors and use &lt;strong&gt;very, very short&lt;/strong&gt; wires to connect them to the chip as shown in the &quot;System Clock and Clock Options&quot; section of the '328P datasheet. You will then be able to reprogram the fuses using AVRDUDE.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-27T05:15:02.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4742" PostTypeId="2" ParentId="4736" CreationDate="2014-10-27T09:39:58.547" Score="6" Body="&lt;p&gt;Depends what you’re doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For low power (&amp;lt; 12v, 500mA) peripherals and digital signals:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you’re going to use breadboard (and you really should start with breadboard) you’ll need solid core hook up wire. You can find pre-cut, pre-stripped sets with a variety of lengths and colours if you’re looking for neatness and simplicity. &#xA;(An example can be found at: &lt;a href=&quot;http://www.maplin.co.uk/p/jump-wire-kit-fs65v&quot; rel=&quot;nofollow&quot;&gt;http://www.maplin.co.uk/p/jump-wire-kit-fs65v&lt;/a&gt;)&#xA;Usually it’s 22AWG wire, so you could get a reel and cut it yourself if you’re going to need a lot or are going to solder it in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you’re done breadboarding and want to make something more permanent you should look at rainbow cable. You can tear it to get anything from 2 to 32 way cables, and it’s almost impossible to get the wrong way around. You can solder it directly to a PCB or crimp connectors onto the ends for more flexibility.&#xA;(You can find this stuff everywhere, but Sparkfun is always there if you can’t: &lt;a href=&quot;https://www.sparkfun.com/products/10649&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10649&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For higher power (&gt; 12v, 1A): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep it away from the Arduino! Use switching transistors, relays, or MOSFETs and use cabling that meets, or preferably exceeds, the power that you’re going to put through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don’t know where you’re going to buy this, but in the UK I use Mouser, Farnell, and RS for most of my electronics supplies. Never buy cabling off Ebay, a lot of it is counterfeit and won’t meet the claimed spec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastEditorUserId="4385" LastEditDate="2015-05-01T09:10:41.877" LastActivityDate="2015-05-01T09:10:41.877" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4744" PostTypeId="1" CreationDate="2014-10-27T12:09:05.157" Score="2" ViewCount="937" Body="&lt;p&gt;I need to connect piezoelectric accelerometer to Arduino. Precisely, it's this one: &lt;a href=&quot;http://www.pcb.com/Products.aspx?m=352C34&quot; rel=&quot;nofollow&quot;&gt;http://www.pcb.com/Products.aspx?m=352C34&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specs show that it generates 100 mV/g, but when I connected it between ground and analog input with 1M pulldown resistor, analog input stays at 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino analog input resolution and accuracy is absolutely fine for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone point me to right direction in connecting this kind of sensor to Arduino?&lt;/p&gt;&#xA;" OwnerUserId="4564" LastEditorUserId="37" LastEditDate="2014-10-27T16:10:30.387" LastActivityDate="2014-12-22T15:24:52.847" Title="ICP Accelometer Arduino" Tags="|sensors|analogread|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4745" PostTypeId="1" CreationDate="2014-10-27T13:54:11.577" Score="1" ViewCount="4278" Body="&lt;p&gt;I'm trying to detect baud rate of Arduino Mega2560 by using C#. My code is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SerialPort SP=new SerialPort();&#xA;SP.BaudRate = 115200;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BaudRate is specified as a constant like this, but I would like to automatically detect it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if Arduino code includes Serial.begin(xxxx), program should declare SP.BaudRate = xxxx.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do it?&lt;/p&gt;&#xA;" OwnerUserId="4430" LastActivityDate="2014-10-27T16:19:27.137" Title="Auto detecting Baud Rate of Arduino" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4746" PostTypeId="2" ParentId="4745" CreationDate="2014-10-27T16:19:27.137" Score="1" Body="&lt;p&gt;I'm not a C# programmer but &lt;a href=&quot;https://stackoverflow.com/a/16590749/4138037&quot;&gt;this&lt;/a&gt; StackOverflow answer might be what you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-10-27T16:19:27.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4748" PostTypeId="1" CreationDate="2014-10-27T17:10:16.823" Score="0" ViewCount="1107" Body="&lt;p&gt;I am new to Arduino. I am trying to use Pulsioximeter sensor with e-health Platform (&lt;a href=&quot;http://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical&quot; rel=&quot;nofollow&quot;&gt;http://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical&lt;/a&gt;) on Arduino Uno. &lt;i&gt;Line number 13 is working fine in the example code given in the library and works just fine.&lt;/i&gt; But when I try to upload my custom code (setup function definition is given below), &lt;b&gt;I get an error stating 'readPulsioximeter' not defined in this scope&lt;/b&gt;. The error doesn't seem obvious to me. Please guide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the custom code upto setup() function: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt; eHealth.h &amp;gt;&#xA;#include &amp;lt; PinChangeInt.h &amp;gt;&#xA;bool configuration = false;&#xA;//bool in_it=true;&#xA;byte val; // variable to receive data from the serial port&#xA;int ledpin = 13; // LED connected to pin 48 (on-board LED)&#xA;int A=1;&#xA;void setup() {&#xA;           pinMode(ledpin, OUTPUT); &#xA;           Serial.begin(115200);&#xA;           eHealth.initPulsioximeter();&#xA;           //Attach the interruptions for using the pulsioximeter.&#xA;           PCintPort::attachInterrupt(6, readPulsioximeter, RISING);&#xA;           delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt; EDIT1: &lt;/b&gt;&#xA;readPulsioximeter is declared in eHealth.h library which has been included in program. The function has been defined as below in eHealth.cpp file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //!******************************************************************************&#xA;    //!     Name:   readPulsioximeter()                                             *&#xA;    //!     Description: It reads a value from pulsioximeter sensor.                *&#xA;    //!     Param : void                                                            *&#xA;    //!     Returns: void                                                           *&#xA;    //!     Example: readPulsioximeter();                                           *&#xA;    //!******************************************************************************&#xA;    void eHealthClass::readPulsioximeter(void)&#xA;    {&#xA;        uint8_t digito[] = {0,0,0,0,0,0};&#xA;        uint8_t A = 0;&#xA;        uint8_t B = 0;&#xA;        uint8_t C = 0;&#xA;        uint8_t D = 0;&#xA;        uint8_t E = 0;&#xA;        uint8_t F = 0;&#xA;        uint8_t G = 0;&#xA;        for (int i = 0; i&amp;lt;6 ; i++) { // read all the led's of the module&#xA;            A = !digitalRead(13);&#xA;            B = !digitalRead(12);&#xA;            C = !digitalRead(11);&#xA;            D = !digitalRead(10);&#xA;            E = !digitalRead(9);&#xA;            F = !digitalRead(8);&#xA;            G = !digitalRead(7);&#xA;            digito[i] = segToNumber(A, B, C ,D ,E, F,G);    &#xA;            delayMicroseconds(2800); //2800 microseconds&#xA;        }&#xA;            SPO2 = 10 * digito[5] + digito[4];&#xA;            BPM  = 100 * digito[2] + 10 * digito[1] + digito[0];&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4565" LastEditorUserId="84" LastEditDate="2015-02-25T20:07:45.087" LastActivityDate="2016-02-21T07:55:59.220" Title="'readPulsioximeter' was not declared in this scope" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4749" PostTypeId="2" ParentId="4748" CreationDate="2014-10-27T17:24:24.120" Score="1" Body="&lt;p&gt;The problem is that you have no function called &quot;readPulsioximeter&quot; in your code. Either define it, pick a different function, or remove that line of code.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-27T17:24:24.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4750" PostTypeId="1" CreationDate="2014-10-27T17:54:25.980" Score="1" ViewCount="1196" Body="&lt;p&gt;I want to log data from Sensors (Say Temperature, moisture or humidity) to a MYSQL database (provided by a online hosting company). Is it possible to establish communication between Arduino Yun and that database and log the data to it &lt;/p&gt;&#xA;" OwnerUserId="4567" LastActivityDate="2014-10-28T08:39:04.673" Title="Arduino Yun - Sensor Data logging to MYSQL on External Server" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4751" PostTypeId="1" CreationDate="2014-10-27T18:33:23.173" Score="5" ViewCount="17254" Body="&lt;p&gt;I was programing the arduino and things were going great.&#xA;Then I plugged in another chip, and went to burn a boot loader.&#xA;(New chips) now, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I try to upload code to old chips, I get: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ten times.&#xA;I have tried reseting, and it doesnt do anything.&#xA;when I plug the device in, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;dmesg shows that the device responds to my PC&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[526199.130716] usb 3-1: new full-speed USB device number 7 using xhci_hcd&#xA;[526199.149422] usb 3-1: New USB device found, idVendor=2341, idProduct=0043&#xA;[526199.149427] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[526199.149430] usb 3-1: Manufacturer: Arduino (www.arduino.cc)&#xA;[526199.149433] usb 3-1: SerialNumber: 649343332353518022F0&#xA;[526199.149579] usb 3-1: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes&#xA;[526199.149766] cdc_acm 3-1:1.0: ttyACM0: USB ACM device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;IDE settings:&#xA;board: Audruino Uno&#xA;serial posrt /dev/ttyACM0&#xA;Programer: AVRISP mkII&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried AVR ISP&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the command line, I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   avr-gcc -DF_CPU=16000000UL -mmcu=atmega328 -o Balls.out Balls.c&#xA;   avr-objcopy -O ihex -R .eeprom Balls.out  Balls.hex&#xA;   sudo avrdude -V -F -c stk500v1 -p m328 -b 19200 -P /dev/ttyACM0 -U flash:w:Balls.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;each time, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I troubleshoot the Arduino Uno?&#xA;Is this thing broken?&lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="4527" LastEditDate="2014-10-27T19:05:45.653" LastActivityDate="2016-01-02T17:28:29.763" Title="avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;" Tags="|arduino-uno|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="4752" PostTypeId="2" ParentId="1849" CreationDate="2014-10-27T20:04:56.933" Score="1" Body="&lt;p&gt;I recommend you to look into cross-platform tool named &lt;a href=&quot;http://platformio.ikravets.com&quot; rel=&quot;nofollow&quot;&gt;PlatformIO&lt;/a&gt;. It has support for &lt;em&gt;Windows OS&lt;/em&gt; and doesn't require &lt;em&gt;Arduino IDE&lt;/em&gt; or any tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://platformio.ikravets.com/#!/get-started&quot; rel=&quot;nofollow&quot;&gt;Get Started&lt;/a&gt; let's install platform and setup environment for your Arduino Leonardo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Install new development platform&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; platformio platforms install atmelavr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Initialize new PlatformIO based project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; cd path\to\empty\directory&#xA;&amp;gt; platformio init&#xA;# Project has been initialized!&#xA;# Please put your source code to `src` directory, external libraries to `lib`&#xA;# and setup environments in `platformio.ini` file.&#xA;# Then process project with `platformio run` command.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setup environments in the &lt;em&gt;Project Configuration File&lt;/em&gt; &lt;code&gt;platformio.ini&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[env:my_leonardo_board]&#xA;platform = atmelavr&#xA;framework = arduino&#xA;board = leonardo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Process the project’s environments&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; platformio run --target upload&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S: What is interesting, this tool allows you to manage libraries via CLI and then you can build Arduino-based source code with single line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;%HEADER_FILE_OF_INSTALLED_LIB&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4568" LastEditorUserId="14883" LastEditDate="2015-12-16T16:39:25.183" LastActivityDate="2015-12-16T16:39:25.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4753" PostTypeId="1" CreationDate="2014-10-27T22:15:02.183" Score="5" ViewCount="613" Body="&lt;p&gt;Can anyone recommend an Arduino-based asynchronous scheduling library for controlling a small mobile robot?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm writing the control code for a small 2-wheeled Arduino-Uno based robot. It has a few bumper sensors, IR sensors, and ultrasonic sensors. I've written an initial pass from scratch, using &lt;code&gt;loop()&lt;/code&gt; to read sensors and set motor values appropriately and then wait for the motor to have effect, but I'm finding this cluggy. Some of the sensors, like the ultrasonic range finders, require a small delay to operate, and the motors require a delay to have an effect. Blocking &lt;code&gt;loop()&lt;/code&gt; is the simplest way to achieve this, but it wastes cycles, and can be difficult to time each action properly without throwing off other behaviors. Writing an asynchronous scheduler would be more efficient, but a lot more complicated, and I expect I would be reinventing the wheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://playground.arduino.cc/Main/LibraryList#Sched&quot; rel=&quot;noreferrer&quot;&gt;this list&lt;/a&gt;, of existing scheduling libraries, but I'm not sure which, if any, would be appropriate.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-09-24T12:49:59.847" Title="Asynchronous control framework" Tags="|arduino-uno|library|core-libraries|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4754" PostTypeId="2" ParentId="4748" CreationDate="2014-10-27T22:19:55.253" Score="1" Body="&lt;p&gt;It looks like your missed naming the eHealth object, and that that statement should read:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;PCintPort::attachInterrupt(6, eHealth.readPulsioximeter, RISING);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as you did with the initPulsioximeter call. (In otherwords, &quot;which pulsioximeter?&quot;).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-10-27T22:19:55.253" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4755" PostTypeId="2" ParentId="3488" CreationDate="2014-10-27T23:12:22.813" Score="2" Body="&lt;p&gt;I recommend you to just set a semaphore inside your handler. When your handler is called, set it, nothing more. In your main loop, poll for this semaphore and do your communication when true. When you receive this semaphore you can easily wait as long as you like without breaking interrupt handling. As interrupt service routines should always be as short as possible, both in terms of time and code, it is generally a bad idea to do complex communication from within or wait for something. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And don't forget the &quot;volatile&quot; keyword for your semaphore. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2014-10-27T23:12:22.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4757" PostTypeId="1" CreationDate="2014-10-28T06:50:31.157" Score="1" ViewCount="1991" Body="&lt;p&gt;I try to send serial data RPM to XBee series1 and then from XBee to another XBee wirelessly in API with Escapes Mode. I think I have to send the data Frame.But not very sure.&#xA;Any help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is the code to read RPM and send to XBee?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;/* Serial communication with Xbee.&#xA;On Arduino pin 9 is Rx connect to Xbee Tx, &#xA;pin 8 is Txconnect to Xbee Rx*/&#xA;SoftwareSerial xbeeSerial(9, 8); // RX, TX&#xA;&#xA;XBee xbee = XBee();&#xA;&#xA;int pin = 7;  //7&#xA;float rpm;&#xA;float duration;&#xA;float y;&#xA;&#xA;unsigned long val,time;&#xA;float rps;&#xA;float read_rpm;&#xA;&#xA;&#xA;&#xA;uint8_t start_data[] = { 0x7E, 0x00, 0x50, 0x01, 0x01, 0xff, 0xff,0x00, 0x05, 0x00,0x01,0x03, 0x84, 0x00 };&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(pin, INPUT);&#xA;  Serial.println(&quot;I am ready to send some RPM!&quot;);&#xA;  xbeeSerial.begin(9600);&#xA;  time = millis();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;void loop()// run over and over&#xA;{&#xA; val =  pulseIn(pin, LOW,70000000);&#xA;&#xA; duration=(float)val/1000000.00;&#xA; rps= 1.00/duration;&#xA;rpm=60.00*rps;&#xA;&#xA;/* Sending float to Xbee&#xA;Float is 4 byte size*/&#xA;serialFloatPrint(rpm);&#xA;&#xA;int floatToInt = (int)rpm;&#xA;&#xA;/* To send INT to XBEE&#xA;Int is 2 byte size*/&#xA;xbeeSerial.write(highByte(floatToInt));&#xA;xbeeSerial.write(lowByte(floatToInt));&#xA;&#xA;  Serial.write(0x03);&#xA;&#xA;  delay(2000);&#xA;}&#xA;&#xA;void serialFloatPrint(float f) {&#xA;  byte * b = (byte *) &amp;amp;f;&#xA;&#xA;  //xbeeSerial.print(&quot;f:&quot;);&#xA;  xbeeSerial.print(b[0]);&#xA;  xbeeSerial.print(b[1]);&#xA;  xbeeSerial.print(b[2]);&#xA;  xbeeSerial.print(b[3]);&#xA;  /* DEBUG */&#xA;  Serial.println();&#xA;  Serial.print(b[0],BIN);&#xA;  Serial.print(b[1], BIN);&#xA;  Serial.print(b[2], BIN);&#xA;  Serial.println(b[3], BIN);&#xA;  //*/&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4103" LastEditorUserId="4103" LastEditDate="2014-10-29T23:25:21.167" LastActivityDate="2017-08-16T11:02:11.143" Title="Need help to send serial data from arduino to XBee and to another XBee wirelessly?" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="4758" PostTypeId="2" ParentId="4757" CreationDate="2014-10-28T08:31:09.483" Score="1" Body="&lt;p&gt;You are using it as in non-API mode when data are passed to Xbee wireless transparently. To use Xbee in API mode use e.g. &lt;a href=&quot;http://code.google.com/p/xbee-arduino/&quot; rel=&quot;nofollow&quot;&gt;Xbee-Arduino&lt;/a&gt; library.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-28T08:31:09.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4759" PostTypeId="2" ParentId="4750" CreationDate="2014-10-28T08:39:04.673" Score="1" Body="&lt;p&gt;Yes, you can do that &lt;a href=&quot;http://dev.mysql.com/doc/connector-python/en/connector-python-examples.html&quot; rel=&quot;nofollow&quot;&gt;using python&lt;/a&gt; as well as other languages, or you can &lt;a href=&quot;https://www.temboo.com/arduino/yun/mysql&quot; rel=&quot;nofollow&quot;&gt;use Temboo&lt;/a&gt;: there's an example bundled with the Arduino IDE, it's called &quot;SendDataToMySQL&quot;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-10-28T08:39:04.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4760" PostTypeId="2" ParentId="815" CreationDate="2014-10-28T13:59:23.180" Score="2" Body="&lt;p&gt;This looks like the smallest and cheapest one from all of the above mentioned:&#xA;&lt;a href=&quot;http://www.ebay.co.uk/itm/AC-DC-Power-Supply-Buck-Converter-Step-Down-Module-5V-700mA-for-Arduino-U-/121355318138&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/AC-DC-Power-Supply-Buck-Converter-Step-Down-Module-5V-700mA-for-Arduino-U-/121355318138&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4577" LastActivityDate="2014-10-28T13:59:23.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4761" PostTypeId="2" ParentId="4347" CreationDate="2014-10-28T14:49:32.387" Score="3" Body="&lt;p&gt;It is not really clear what you want here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to execute things in a certain time, then take a look at &lt;a href=&quot;http://playground.arduino.cc/Code/Scheduler&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Scheduler&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if you want more than just that (multiple tasks, preemptive multitasking) &lt;a href=&quot;https://launchpad.net/arduos&quot; rel=&quot;nofollow&quot;&gt;https://launchpad.net/arduos&lt;/a&gt; (arduOS can also just serve to run things in a certain time, but without having to use a function all the time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While OOP MIGHT take more program memory, an object without virtual functions only takes the RAM the variables in it take (if you have a byte (1 byte) and an int (2 bytes) in an object it would take 3 bytes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the AVR-architecture (the one most Arduinos use) the program is directly executed from a flash-memory and only the variables are in the RAM&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The if-state-handling you are doing there can be done easier using arrays like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void(*handler)(void)&#xA;handler stateHandlers[STATES] = {&amp;amp;handle1, &amp;amp;handle2, &amp;amp;handle3 ...&#xA;// handle? are functions without the () !&#xA;void handleState(int state)&#xA;{&#xA;    if(state &amp;gt;= STATES)&#xA;        return;&#xA;    stateHandlers[state]();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, you can also use arrays to store the states of the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that &lt;code&gt;HIGH&lt;/code&gt; is just 1 and &lt;code&gt;LOW&lt;/code&gt; is 0, so technically a bit would be enough to store the states.&lt;/p&gt;&#xA;" OwnerUserId="4531" LastEditorUserId="84" LastEditDate="2014-10-29T05:27:24.987" LastActivityDate="2014-10-29T05:27:24.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4762" PostTypeId="1" AcceptedAnswerId="4764" CreationDate="2014-10-28T16:35:52.973" Score="0" ViewCount="18873" Body="&lt;p&gt;How can I convert a byte array to float? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send_data() {&#xA;    CCPACKET data;&#xA;    data.length=2;&#xA;&#xA;    float lon=26.533255;&#xA;    float lat=27.533463;&#xA;&#xA;&#xA;    data.data[0]=lon;&#xA;    data.data[1]=lat;&#xA;&#xA;    if(cc1101.sendData(data)){&#xA;    Serial.println(data.data[0]);&#xA;    Serial.println(data.data[1]);&#xA;&#xA;    Serial.println(&quot; sent ok &quot;);&#xA;    return true;&#xA;    }else{&#xA;    Serial.println(&quot;sent failed &quot;);&#xA;    return false;&#xA;    }&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is when I print those two variables it just prints lon 26.00 and lat 27.00 but not lon 26.533255 lat 27.533463 as I expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the header file for CCPACKET I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _CCPACKET_H&#xA;#define _CCPACKET_H&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;/**&#xA; * Buffer and data lengths&#xA; */&#xA;#define CC1101_BUFFER_LEN        64&#xA;#define CC1101_DATA_LEN          CC1101_BUFFER_LEN - 3&#xA;&#xA;/**&#xA; * Class: CCPACKET&#xA; * &#xA; * Description:&#xA; * CC1101 data packet class&#xA; */&#xA;class CCPACKET&#xA;{&#xA;  public:&#xA;    /**&#xA;     * Data length&#xA;     */&#xA;    byte length;&#xA;&#xA;    /**&#xA;     * Data buffer&#xA;     */&#xA;    byte data[CC1101_DATA_LEN];&#xA;&#xA;    /**&#xA;     * CRC OK flag&#xA;     */&#xA;    boolean crc_ok;&#xA;&#xA;    /**&#xA;     * Received Strength Signal Indication&#xA;     */&#xA;    byte rssi;&#xA;&#xA;    /**&#xA;     * Link Quality Index&#xA;     */&#xA;    byte lqi;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was trying to fix it by this part of code, but without success:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float lon=26.533543;&#xA;&#xA;*((float *)data.data[0]) = lon;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone help me to convert the byte array to float?&lt;/p&gt;&#xA;" OwnerUserId="1256" LastEditorUserId="6936" LastEditDate="2015-04-01T00:08:36.397" LastActivityDate="2015-04-01T00:08:36.397" Title="How to convert byte array to float" Tags="|programming|c++|data-type|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4763" PostTypeId="2" ParentId="4762" CreationDate="2014-10-28T20:41:20.820" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;/**&#xA;  &lt;em&gt;Data buffer&lt;/em&gt;/&#xA;  byte data[CC1101_DATA_LEN];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That line of code declares an array of datatype &lt;a href=&quot;http://arduino.cc/en/Reference/Byte&quot; rel=&quot;nofollow&quot;&gt;byte&lt;/a&gt;. I suggest you review &lt;a href=&quot;http://arduino.cc/en/Reference/VariableDeclaration&quot; rel=&quot;nofollow&quot;&gt;variable declaration for Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A byte will store an 8-bit unsigned number with a range of 0 to 255, no decimal points. I also suggest you review truncation to understand how computer systems handle mathematic calculations that produce decimal results when the result is being stored in a variable type that doesn't store decimals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A float stores a 32-bit value with decimal point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quick answer to your problem is to change the above quoted code from byte to float.&lt;/p&gt;&#xA;" OwnerUserId="4393" LastActivityDate="2014-10-28T20:41:20.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4764" PostTypeId="2" ParentId="4762" CreationDate="2014-10-28T21:18:31.977" Score="3" Body="&lt;p&gt;You can choose to treat the byte array as a float array by typecasting. Your attempt isn't far from a solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;((float *)data.data)[0] = lon; // uses data.data[0] ... data.data[3]&#xA;((float *)data.data)[1] = lat; // uses data.data[4] ... data.data[7]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When printing you should also treat the data array as float array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(((float *)data.data)[0]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like you are sending the data over some interface. Then of course you need to typecast the binary data back into a  float at the receiving end (if you want to do something useful with it) - similar to what is done above when it is passed to Serial.println.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2014-10-28T21:18:31.977" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4765" PostTypeId="2" ParentId="4739" CreationDate="2014-10-28T22:26:16.147" Score="0" Body="&lt;p&gt;Try adding a 1k resistor on the TxD and RxD pins to your chip. And a 100nF capacitor like the schematic below. And a 10k Pull-up resistor to the reset pin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Target processor                                 USB to Serial converter&#xA;(Atmega 168)                               &#xA;GND   ------------------------------------------ GND&#xA;&#xA;5V    &amp;lt;----------------------------------------- 5V&#xA;RX    &amp;lt;--- 1K ---------------------------------- TX&#xA;TX    ---- 1K ---------------------------------&amp;gt; RX&#xA;RESET &amp;lt;----||----------------------------------- DTR_PIN&#xA;  |       100nF    &#xA; 10K&#xA;  |&#xA; 5V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will help stabalizing the signals.&lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-10-28T22:26:16.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4766" PostTypeId="2" ParentId="4666" CreationDate="2014-10-28T23:56:08.133" Score="2" Body="&lt;p&gt;In order to get a smooth signal to your power regulator you should use some capacitors before and after the voltage regulator. It will look something like this when you use the 7805 voltage regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z2L6V.png&quot; alt=&quot;7805 Voltage Regulator&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This schematic is from a dutch website. Uin means Vin and Uuit means Vout. C2 and C3 are bipolar capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also smart to put a diode before the voltage regulator to make sure the voltage flows only to one direction. The values of C1, C2, C3 and C4 and pretty standard and coul be used for the other Voltage regulators as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage Regulators come in different fixed values and tey have a minimum and maximum voltage they can handle. Here's a small table of the most common VR's with their minimum input voltages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Part Number     Output Voltage (V)      Minimum Input Voltage (V)&#xA;7805            +5                      7.3&#xA;7806            +6                      8.3&#xA;7808            +8                      10.5&#xA;7809            +9                      11.5&#xA;7810            +10                     12.5&#xA;7812            +12                     14.6&#xA;7815            +15                     17.7&#xA;7818            +18                     21.0&#xA;7824            +24                     27.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note that the output currents of these Voltage Regulators listed above is max 1A. When they're called like 78S05 or 78S09 it'll be a 2A Voltage Regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing that could be important when you're using the minimum input voltages. If you put a diode before the Voltage Regulator there will be a small voltage drop. For a 1N4007 the voltage drop will be around the 0.5V. The voltage drop will only occur before the voltage regulator though, so when you don't use the minimal input values you don't have to mind about it.&lt;/p&gt;&#xA;" OwnerUserId="1532" LastActivityDate="2014-10-28T23:56:08.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4767" PostTypeId="1" AcceptedAnswerId="8491" CreationDate="2014-10-29T17:10:39.230" Score="1" ViewCount="116" Body="&lt;p&gt;I'm clueless when it comes to the information on datasheets for switches. When I see a datasheet for LEDs or servos, I'm used to seeing a fairly straightforward call out for the required volts and amps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A project I'm working on now requires turning on an LED using a float switch like this one:&#xA;&lt;a href=&quot;http://www.seeedstudio.com/depot/water-level-switch-p-565.html&quot; rel=&quot;nofollow&quot;&gt;Water Level Switch&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The max switching voltage and current values, and minimum voltage info is really throwing me. The minimum voltage, for instance, is 250v DC! Does a $5 switch really require 250 volts? I haven't been able to find many schematics where they are just using a switch like this without a pump or other hardware, but I seem to remember seeing someone run a switch like this with 5v pin. And I'm totally unsure what the current would be/if I need a resistor, etc.&lt;/p&gt;&#xA;" OwnerUserId="4401" LastActivityDate="2015-02-07T17:46:05.850" Title="What does the datasheet information for a switch mean?" Tags="|sensors|power|voltage-level|resistor|electronics|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4769" PostTypeId="1" AcceptedAnswerId="4770" CreationDate="2014-10-29T17:36:16.210" Score="5" ViewCount="18175" Body="&lt;p&gt;So, after the sketch is uploaded, and I want to turn the Arduino off while it is running a sketch, all I have to do is unplug it.&#xA;Should be safe as long as nothing is uploading.&#xA;But I wonder, if I use serial communication between the Arduino and my Computer in a sketch, does it harm either if I simply unplug it?&lt;/p&gt;&#xA;" OwnerUserId="4591" LastActivityDate="2015-10-31T16:44:41.760" Title="Can I simply unplug the Arduino usb if serial communication is active?" Tags="|arduino-uno|serial|uploading|usb|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4770" PostTypeId="2" ParentId="4769" CreationDate="2014-10-29T17:42:01.963" Score="5" Body="&lt;p&gt;if the sketch is uploaded, it wont hurt it to unplug. Just give it another source of power and it will run its sketch.&lt;/p&gt;&#xA;" OwnerUserId="4592" LastActivityDate="2014-10-29T17:42:01.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4771" PostTypeId="2" ParentId="4769" CreationDate="2014-10-29T20:40:02.637" Score="3" Body="&lt;p&gt;You can unplug it, it does not harm.&#xA;If your arduino does not need power, eg. for writing EEPROM or FLASH, then no danger there.&#xA;(in case it was writing EEPROM/FLASH it could write it faulty but usually even that is not a problem either)&lt;/p&gt;&#xA;" OwnerUserId="4593" LastActivityDate="2014-10-29T20:40:02.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4772" PostTypeId="2" ParentId="756" CreationDate="2014-10-29T20:52:52.650" Score="1" Body="&lt;p&gt;As Stino claims to use the installed Arduino IDE you already have, which means you can not differentiate at compile time. &lt;/p&gt;&#xA;" OwnerUserId="4593" LastActivityDate="2014-10-29T20:52:52.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4773" PostTypeId="1" AcceptedAnswerId="4778" CreationDate="2014-10-29T21:47:24.337" Score="1" ViewCount="4983" Body="&lt;p&gt;I would like to extend my arduino uno with WIFI and I am checking different options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.exp-tech.de/Shields/Wireless/WiFi/Adafruit-CC3000-Breakout-with-Onboard-Ceramic-Antenna.html&quot; rel=&quot;nofollow&quot;&gt;Adafruit-CC3000-Breakout-with-Onboard-Ceramic-Antenna&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.exp-tech.de/Shields/Arduino-WiFi-Shield-integrierte-Antenne.html&quot; rel=&quot;nofollow&quot;&gt;Arduino WiFi Shield (integrierte Antenne)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Viewing the price, obviously I understand that the shield will have more functions, I think also it is more &quot;friendly&quot; for programming and the breakout requires more low level code(I am not afraid of it...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have an arduino yun but it is busy with a project, so I need something for the uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what kind of projects could be better each of them? and what are the main differences between a shield and a breakout?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in the future I would do some projects with gsm, so this question could be similar ... gsm shield vs breakout.&lt;/p&gt;&#xA;" OwnerUserId="3840" LastEditorUserId="3840" LastEditDate="2014-10-30T09:22:52.823" LastActivityDate="2014-10-30T18:54:47.373" Title="Breakout vs Shield" Tags="|arduino-uno|wifi|shields|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4774" PostTypeId="1" AcceptedAnswerId="4775" CreationDate="2014-10-29T21:56:17.313" Score="2" ViewCount="1450" Body="&lt;p&gt;I have an Arduino Uno. I am building a custom shield and was wondering how I would connect two of the LEDs on the shield to the TX / RX LEDs on the Uno. Digital pins 0 and 1 seem obvious, but after further research, it appears that they are not for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In better terms, I want two LEDs on my shield that replicate the TX / Rx LEDs on the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I do this?&lt;/p&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2014-10-29T22:47:30.947" Title="How to pass rx/tx led outputs to a shield" Tags="|arduino-uno|serial|led|shields|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4775" PostTypeId="2" ParentId="4774" CreationDate="2014-10-29T22:04:27.793" Score="4" Body="&lt;p&gt;The TX/RX LEDs on the Uno are not connected to the main MCU but are instead connected to the USB communication chip, be it a FTDI or ATmega16U2. You would need to solder wires to the appropriate connections on the board and then connect them to the shield in question.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-29T22:04:27.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4777" PostTypeId="2" ParentId="4773" CreationDate="2014-10-29T22:06:01.983" Score="4" Body="&lt;p&gt;Shields are in a form factor suited for direct attachment to the Arduino, but have fixed functionality for their connections. Breakout boards require more wiring work, but allow you to connect to any appropriate pins.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-29T22:06:01.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4778" PostTypeId="2" ParentId="4773" CreationDate="2014-10-29T22:22:07.823" Score="2" Body="&lt;p&gt;If you prototyping for a device intended for production then use breakout board with supposed WiFi module. Also if space is constraint then shield might be problem. For a hobby system use WiFi shield, which uses rather complicated circuit with AVR32 MCU, but you just plug-in and uses prooved libs. For production MCU would mean one more firmware flashing, upgrades, maintainance and higher price - from my point of view useless.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-29T22:22:07.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4780" PostTypeId="2" ParentId="4774" CreationDate="2014-10-29T22:47:30.947" Score="2" Body="&lt;p&gt;If you need just indicate data on TX/RX you can make simple circuit on shield bound to TX/RX lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EhMRw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-29T22:47:30.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4782" PostTypeId="1" AcceptedAnswerId="4981" CreationDate="2014-10-30T02:06:45.260" Score="0" ViewCount="2336" Body="&lt;p&gt;I'm trying to create a function that prints out an XML tag with a value. I have the code below, but kind of stuck. I'd like to be able to call the function, and pass a value that could be a float, int, string or char. Appreciate any help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char PingTime[6] = &quot;3ms&quot;;&#xA;char PingText[60] = &quot;ping reply blah blah&quot;;&#xA;float humidity = &quot;40.56&quot;;&#xA;int DigialPin = 0;&#xA;&#xA;PrintXMLTag(cl,&quot;pingtime&quot;,PingTime); &#xA;PrintXMLTag(cl,&quot;PingText&quot;,PingText);  &#xA;PrintXMLTag(cl,&quot;humidity&quot;,humidity);    &#xA;PrintXMLTag(cl,&quot;DigialPin&quot;,DigialPin);  &#xA;&#xA;void PrintXMLTag_DEC(EthernetClient cl, const char* tag, NotSure?? val) &#xA;{&#xA;  char tmp [100];&#xA;  StrClear(tmp,100);&#xA;&#xA;  // If val type is float ----------------------&#xA;  int d1 = val; // Get the integer part &#xA;  float f2 = val - d1; // Get fractional part &#xA;  int d2 = trunc(f2 * 10000);// Turn into integer &#xA;  sprintf(tmp,&quot;&amp;lt;%s&amp;gt;%d.%02d&amp;lt;/%s&amp;gt;\n&quot;,tag,d1,d2,tag);&#xA;  // end float&#xA;&#xA;  // If val type is string ----------------------&#xA;&#xA;  // If val type is int ----------------------&#xA;&#xA;  // If val type is char ----------------------&#xA;&#xA;  cl.print(tmp);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update, now converting the type to char before calling the PrintXML function resolves my initial issue. If I use the code below it seems to chew up a lot of memory, is there something obviously wrong? As a workaround I'm just printing the XML tags using cl.print and the memory usage is stable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void PrintXMLTag(EthernetClient cl, char* tag,  char* val) &#xA;{&#xA;  char tmp [100];&#xA;  sprintf(tmp,&quot;&amp;lt;%s&amp;gt;%s&amp;lt;/%s&amp;gt;\n&quot;,tag,val,tag);&#xA;  cl.print(tmp);&#xA;  StrClear(tmp,100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4597" LastEditorUserId="4597" LastEditDate="2014-10-31T03:31:55.257" LastActivityDate="2014-11-14T04:09:08.357" Title="Help with a function that accepts different parameter types" Tags="|programming|variables|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4783" PostTypeId="1" CreationDate="2014-10-30T02:20:51.393" Score="3" ViewCount="37383" Body="&lt;p&gt;For some reason I can't use the &lt;code&gt;Time.h&lt;/code&gt; lib.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you guys tell me how to create a string from the datetime into a format like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yyyy.MM.dd:hh.mm.ss&#xA;2014.10.29:07.12.33&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Seems odd that I can't find any examples of this.&lt;/p&gt;&#xA;" OwnerUserId="4599" LastEditorUserId="6936" LastEditDate="2019-04-30T23:07:06.223" LastActivityDate="2021-07-19T08:06:06.060" Title="DateTime to string" Tags="|string|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="4784" PostTypeId="1" CreationDate="2014-10-30T02:30:16.903" Score="2" ViewCount="143" Body="&lt;p&gt;curious if a Arduino could be configured to read and serial print raw binary bits from a proprietary serial encoder used on machine tools and robots... if so, might have a lot of other possible uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made up a 120 volt servo drive for manually moving big fanuc machine/robot servos, handy during rebuilding/service to be able to move a axis without a control...but the older drives read 4 gray code channels kinda like a set of halls for brushless commutation...on the serial versions, same drive could move the motor if I could decipher the commutation bits and output graycode to the drive... a tiny Arduino looks like a ideal little thing to try doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scoped out the signals long ago, kinda know where the bits are, but need to be able to actually print them out thru 90 degrees of shaft rotation to find the 12 steps for commutation required by the drive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is new to me, but in the past few days have been quite impressed with its abilities. If anyone can suggest a way for Arduino to read a repeating 77 bit data stream at ~100K baud, I'm all ears... I think a 'serial snoop tool' with easily changed baud rates(including non-standard) and 'word length', then serial print out could be really handy. to prevent overflow in my case, could only do the serial print every X milliseconds, and I could just rotate slow enough to get a decent sample.&lt;/p&gt;&#xA;" OwnerUserId="4598" LastActivityDate="2014-10-30T02:30:16.903" Title="Arduino as serial 'snoop' tool for 77 bits at 100k baud?" Tags="|serial|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4785" PostTypeId="1" CreationDate="2014-10-30T02:53:53.323" Score="1" ViewCount="658" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mzoWL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to construct 4 reactors for an experiment requiring mixing. We want to automate the mixing and at the same time reduce cost. can we connect multiple stepper motors with 5 or 6 wires on one shield version 2?&lt;/p&gt;&#xA;" OwnerUserId="4474" LastEditorUserId="4474" LastEditDate="2014-10-30T07:16:59.130" LastActivityDate="2014-12-29T09:37:58.710" Title="Multiple Stepper Motors in One Shield?" Tags="|arduino-mega|motor|shields|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4786" PostTypeId="1" CreationDate="2014-10-30T05:40:29.070" Score="0" ViewCount="3536" Body="&lt;p&gt;I need Help in two thing Here.&#xA;1)My main project is i have 23 hallsensors with analog output. There are connected to arduino UNO analog pins using 16:1 Mux or 8:1 mux circuit. The currently i can receive data properly with proper switching. Which are floating point values.&#xA;Second stage: Now this has to communicate via MODbus protocol .(here only transmission is pending)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Now I am in to transmission data. Here i am using basic library downloaded from&#xA;[Download link modbus library][1] &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my setup is like this&#xA;I have arduino Board. RS485 sheild and USB to RS485 converter. Qmodbus software to view data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have uploaded the below code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ModbusRtu.h&amp;gt;&#xA;&#xA;// data array for modbus network sharing&#xA;uint16_t au16data[16] = {&#xA;  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };&#xA;&#xA;/**&#xA; *  Modbus object declaration&#xA; *  u8id : node id = 0 for master, = 1..247 for slave&#xA; *  u8serno : serial port (use 0 for Serial)&#xA; *  u8txenpin : 0 for RS-232 and USB-FTDI &#xA; *               or any pin number &amp;gt; 1 for RS-485&#xA; */&#xA;Modbus slave(1,0,0); // this is slave @1 and RS-232 or USB-FTDI&#xA;&#xA;void setup() {&#xA;  slave.begin( 9600 ); // baud-rate at 19200&#xA;}&#xA;&#xA;void loop() {&#xA;  slave.poll( au16data, 16 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so i am expecting this answer if i am not wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t au16data[16] = {&#xA;  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i am getting data as below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Whats making wrong to get below data??&#xA;2)If i want to store float values how can name uint16_t au16data[16] or changes to be made&#xA;3) Is there any working code ON modbus![OUTPUt of MODBUS][2]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Finally i got it working i can read The values. Now i am in second part. I have totally 20 values . currently i stored them as integer only. But my values are flaoting point.How to split real &amp;amp; floating value store in au16data[16] register.???&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume i got my Sensor value converted as &#xA;*&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CS=30.10&#xA;Int_CS=int(CS)&#xA;FLOAT_CS=(Int_CS-CS)*100&#xA;How to store the Int_CS &amp;amp; FLOAT_CS values in au16data[0]??&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;*&lt;/p&gt;&#xA;" OwnerUserId="904" LastEditorUserId="904" LastEditDate="2014-10-31T05:21:34.790" LastActivityDate="2015-04-29T09:10:24.580" Title="Modbus master slave" Tags="|arduino-uno|programming|modbus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4787" PostTypeId="2" ParentId="4786" CreationDate="2014-10-30T06:16:07.693" Score="1" Body="&lt;p&gt;In Modbus protocol, &lt;code&gt;coils&lt;/code&gt; are bits and &lt;code&gt;registers&lt;/code&gt; are 16-bit unsigned integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence if you ask Modbus to read your &lt;code&gt;au16data&lt;/code&gt; array as coils, and not as registers (which is what they actually are), then you'll get the binary representation for them with QModbus:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your first register is &lt;code&gt;3&lt;/code&gt; which is &lt;code&gt;0000 0000 0000 0011&lt;/code&gt; in binary. Then when you read it as an array of 16 cils, you get these bit values, in reverse order (bit 0 is the lowest order bit and bit 15 is the highest order bit of your register); this is exactly what QModbus shos you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First 2 bits are 1&lt;/li&gt;&#xA;&lt;li&gt;All other bits are 0&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now regarding &lt;code&gt;float&lt;/code&gt; values, if I remember correctly this is just not possible with Modbus protocol, hence you cannot do it out of the box. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do, however, is to &lt;strong&gt;cast one float as 2 registers&lt;/strong&gt; and transmit it this way, then it is up to the Modbus client to cast it back to a float; but QModbus will not do that for you as it strictly follows Modbus standard.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-10-30T06:16:07.693" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4788" PostTypeId="2" ParentId="4785" CreationDate="2014-10-30T08:03:33.000" Score="1" Body="&lt;p&gt;Depending on the shield you can connect an external powersource through mosfets or transistors (Depending on the size of the steppermotor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if it is smaller motors with a 12v powersource, i really don't se why you would do that, since stepper motor controllers cost about $2-$4 each. Being cost effective i think that writing this question would cost more than actually just go and buy 6-8 controllers. (Don't buy the shield ones, they are overly expensive)&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2014-10-30T08:03:33.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4790" PostTypeId="1" AcceptedAnswerId="4799" CreationDate="2014-10-30T11:07:18.453" Score="1" ViewCount="529" Body="&lt;p&gt;I understand that when connecting an LED and a resistor in series; the resistor can be placed on any side of the LED as the current will remain same in a series connection. Please correct me if I'm wrong, but I was under the impression that conventionally the electrons flow from positive to negative. So shouldn't the resistor be placed before an LED to limit the flow of charge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this scenario the negative is connected ground and the positive to a power source. So I don't understand the chain Link analogy as well. Where the whole chain moves as a whole because here the flow ends with the GND right ?&lt;/p&gt;&#xA;" OwnerUserId="4601" LastActivityDate="2014-10-30T17:56:37.867" Title="Which side should I connect the resistor on?" Tags="|led|resistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4792" PostTypeId="1" AcceptedAnswerId="4793" CreationDate="2014-10-30T11:56:37.283" Score="0" ViewCount="280" Body="&lt;pre&gt;&lt;code&gt;char cTime[22];&#xA;&#xA;sprintf(cTime, &quot;%04s/%02s/%2s:%02s:%02s:%02s&quot;, year(), month(), day(), hour(), minute(), second());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;sprintf&lt;/code&gt; line causes this error:**B0100000063f694Š&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me debug this?&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4600" LastEditorUserId="84" LastEditDate="2014-10-30T17:34:18.557" LastActivityDate="2014-10-30T18:10:09.803" Title="sprintf trouble" Tags="|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4793" PostTypeId="2" ParentId="4792" CreationDate="2014-10-30T12:31:41.727" Score="1" Body="&lt;p&gt;&lt;em&gt;%s&lt;/em&gt; is string macro but output of &lt;em&gt;year(),...&lt;/em&gt; is probably an integer type. Use &lt;em&gt;%d&lt;/em&gt; or &lt;em&gt;%u&lt;/em&gt; macros in format.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-10-30T12:31:41.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4794" PostTypeId="2" ParentId="4790" CreationDate="2014-10-30T12:47:56.190" Score="1" Body="&lt;p&gt;Resistor on any side of led will intercept current flow.&#xA;Just use another analogy with water, tube and water tap.&lt;/p&gt;&#xA;" OwnerUserId="4602" LastActivityDate="2014-10-30T12:47:56.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4795" PostTypeId="1" AcceptedAnswerId="4883" CreationDate="2014-10-30T14:10:54.587" Score="0" ViewCount="5873" Body="&lt;p&gt;I'm trying to get the color sensor TCS3200 to give color values with a delay lower than 4000 ms. I've found a library to interface the TCS3200 from this &lt;a href=&quot;http://www.elecfreaks.com/5521.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified the code to serve my needs and its works fine, almost! The before mentioned library uses &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;TimerOne.h&lt;/a&gt;, which can not accept a delay lower than 4000 ms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is therefor, if it is somehow possible to modify my code, so I can lower the delay?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;#define S0     6&#xA;#define S1     5&#xA;#define S2     4&#xA;#define S3     3&#xA;#define OUT    2&#xA;&#xA;int   g_count = 0;    // count the frequecy&#xA;int   g_array[3];     // store the RGB value&#xA;int   g_flag = 0;     // filter of RGB queue&#xA;float g_SF[3];        // save the RGB Scale factor&#xA;&#xA;// Init TSC230 and setting Frequency.&#xA;void TSC_Init()&#xA;{&#xA;  pinMode(S0, OUTPUT);&#xA;  pinMode(S1, OUTPUT);&#xA;  pinMode(S2, OUTPUT);&#xA;  pinMode(S3, OUTPUT);&#xA;  pinMode(OUT, INPUT);&#xA;&#xA;  digitalWrite(S0, LOW);  // OUTPUT FREQUENCY SCALING 2%&#xA;  digitalWrite(S1, HIGH); &#xA;}&#xA;&#xA;// Select the filter color &#xA;void TSC_FilterColor(int Level01, int Level02)&#xA;{&#xA;  if(Level01 != 0)&#xA;    Level01 = HIGH;&#xA;&#xA;  if(Level02 != 0)&#xA;    Level02 = HIGH;&#xA;&#xA;  digitalWrite(S2, Level01); &#xA;  digitalWrite(S3, Level02); &#xA;}&#xA;&#xA;void TSC_Count()&#xA;{&#xA;  g_count ++ ;&#xA;}&#xA;&#xA;void TSC_Callback()&#xA;{&#xA;  switch(g_flag)&#xA;  {&#xA;    case 0: &#xA;         TSC_WB(LOW, LOW);              //Filter without Red&#xA;         break;&#xA;    case 1:&#xA;         g_array[0] = g_count;&#xA;         TSC_WB(HIGH, HIGH);            //Filter without Green&#xA;         break;&#xA;    case 2:&#xA;         g_array[1] = g_count;&#xA;         TSC_WB(LOW, HIGH);             //Filter without Blue&#xA;         break;&#xA;    case 3:&#xA;         g_array[2] = g_count;&#xA;         TSC_WB(HIGH, LOW);             //Clear(no filter)   &#xA;         break;&#xA;   default:&#xA;         g_count = 0;&#xA;         break;&#xA;  }&#xA;}&#xA;&#xA;void TSC_WB(int Level0, int Level1)      //White Balance&#xA;{&#xA;  g_count = 0;&#xA;  g_flag ++;&#xA;  TSC_FilterColor(Level0, Level1);&#xA;  Timer1.setPeriod(1000000);             // set 1s period&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  TSC_Init();&#xA;  Serial.begin(115200);&#xA;  Timer1.initialize();             // defaulte is 1s&#xA;  Timer1.attachInterrupt(TSC_Callback);  &#xA;  attachInterrupt(0, TSC_Count, RISING);  &#xA;&#xA;  delay(4000);&#xA;&#xA;  for(int i=0; i&amp;lt;3; i++)&#xA;    Serial.println(g_array[i]);&#xA;&#xA;  g_SF[0] = 255.0/ g_array[0];     //R Scale factor&#xA;  g_SF[1] = 255.0/ g_array[1] ;    //G Scale factor&#xA;  g_SF[2] = 255.0/ g_array[2] ;    //B Scale factor&#xA;&#xA;  Serial.println(g_SF[0]);&#xA;  Serial.println(g_SF[1]);&#xA;  Serial.println(g_SF[2]);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  g_flag = 0;&#xA;&#xA;    int R = int(g_array[0] * g_SF[0]);&#xA;    int G = int(g_array[1] * g_SF[1]);&#xA;    int B = int(g_array[2] * g_SF[2]);    &#xA;&#xA;&#xA;    if((R&amp;gt;245) &amp;amp;&amp;amp; (R&amp;lt;265) &amp;amp;&amp;amp; (G&amp;gt;245) &amp;amp;&amp;amp; (G&amp;lt;265) &amp;amp;&amp;amp; (B&amp;gt;245) &amp;amp;&amp;amp; (B&amp;lt;265))    // White&#xA;    {&#xA;      Serial.println(&quot;Color is white&quot;);&#xA;    }else if((R&amp;gt;24) &amp;amp;&amp;amp; (R&amp;lt;44) &amp;amp;&amp;amp; (G&amp;gt;56) &amp;amp;&amp;amp; (G&amp;lt;76) &amp;amp;&amp;amp; (B&amp;gt;95) &amp;amp;&amp;amp; (B&amp;lt;115))  // Blue&#xA;    {&#xA;      Serial.println(&quot;Color is blue&quot;);&#xA;    }else if((R&amp;gt;56) &amp;amp;&amp;amp; (R&amp;lt;76) &amp;amp;&amp;amp; (G&amp;gt;107) &amp;amp;&amp;amp; (G&amp;lt;127) &amp;amp;&amp;amp; (B&amp;gt;80) &amp;amp;&amp;amp; (B&amp;lt;100))  // Green&#xA;    {&#xA;      Serial.println(&quot;Color is green&quot;);    &#xA;    }else if((R&amp;gt;171) &amp;amp;&amp;amp; (R&amp;lt;191) &amp;amp;&amp;amp; (G&amp;gt;154) &amp;amp;&amp;amp; (G&amp;lt;174) &amp;amp;&amp;amp; (B&amp;gt;71) &amp;amp;&amp;amp; (B&amp;lt;91))  // Yellow&#xA;    {&#xA;      Serial.println(&quot;Color is yellow&quot;);  &#xA;    }else if((R&amp;gt;77) &amp;amp;&amp;amp; (R&amp;lt;97) &amp;amp;&amp;amp; (G&amp;gt;46) &amp;amp;&amp;amp; (G&amp;lt;66) &amp;amp;&amp;amp; (B&amp;gt;43) &amp;amp;&amp;amp; (B&amp;lt;63))  // Brown&#xA;    {&#xA;      Serial.println(&quot;Color is brown&quot;);    &#xA;    }else if((R&amp;gt;39) &amp;amp;&amp;amp; (R&amp;lt;59) &amp;amp;&amp;amp; (G&amp;gt;38) &amp;amp;&amp;amp; (G&amp;lt;58) &amp;amp;&amp;amp; (B&amp;gt;36) &amp;amp;&amp;amp; (B&amp;lt;56))  // Brown dark&#xA;    {&#xA;      Serial.println(&quot;Color is brown dark&quot;);    &#xA;    }else if((R&amp;gt;20) &amp;amp;&amp;amp; (R&amp;lt;40) &amp;amp;&amp;amp; (G&amp;gt;43) &amp;amp;&amp;amp; (G&amp;lt;63) &amp;amp;&amp;amp; (B&amp;gt;48) &amp;amp;&amp;amp; (B&amp;lt;68))  // Turkis&#xA;    {&#xA;       Serial.println(&quot;Color is turkis&quot;);   &#xA;    }else if((R&amp;gt;39) &amp;amp;&amp;amp; (R&amp;lt;59) &amp;amp;&amp;amp; (G&amp;gt;77) &amp;amp;&amp;amp; (G&amp;lt;97) &amp;amp;&amp;amp; (B&amp;gt;55) &amp;amp;&amp;amp; (B&amp;lt;75))  // Green&#xA;    {&#xA;       Serial.println(&quot;Color is green&quot;);   &#xA;    }else&#xA;    {&#xA;      Serial.print(&quot;Red = &quot;);&#xA;      Serial.println(R);&#xA;      Serial.print(&quot;Green = &quot;);&#xA;      Serial.println(G);&#xA;      Serial.print(&quot;Blue = &quot;);&#xA;      Serial.println(B);&#xA;&#xA;    };&#xA;&#xA;   delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've searched all over the net and didn't find any good solutions, where I can still specify the colours by hex degree. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All help would be highly appreciated! &lt;/p&gt;&#xA;" OwnerUserId="4606" LastEditorUserId="6936" LastEditDate="2016-02-18T12:27:05.083" LastActivityDate="2016-02-18T12:27:05.083" Title="TCS3200 color sensor not reading with delay lower then 4000 ms using TimerOne.h" Tags="|arduino-uno|sensors|library|timers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4796" PostTypeId="2" ParentId="4782" CreationDate="2014-10-30T14:43:16.480" Score="0" Body="&lt;p&gt;take a look at: &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/functions2/&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/doc/tutorial/functions2/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template &amp;lt;typename SomeType&amp;gt;&#xA;SomeType sum (SomeType a, SomeType b)&#xA;{&#xA;  return a+b;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This appears to be what you want.&lt;/p&gt;&#xA;" OwnerUserId="4531" LastActivityDate="2014-10-30T14:43:16.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4797" PostTypeId="1" CreationDate="2014-10-30T15:08:52.157" Score="0" ViewCount="666" Body="&lt;p&gt;I'm asking if how can I implement this one. I'm aware about multiple devices being connected over SPI, like having to select individual SS pin for each. Adafruit's CC3000 works fine alone along with the default Adafruit library. CC3000 uses SPI. MFRC522 RFID module by sonmicro (bought at Sparksfun) uses SPI too. It works fine too, independently. But whenever I connect them together, only WiFi works perfectly. I dont want to turn on and off the wifi to make way for the RFID to communicate since it takes some time for it to be connected in a wireless network. I want the two to work synchronously (or having to be scheduled but really fast that's unnoticeable by the user)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here's my code as of now. i cannot post it here as strange things happen i don't know why haha &lt;a href=&quot;https://drive.google.com/file/d/0B0bZsYo0xMH8YV9uWXJaRFdPT3M/view?usp=sharing&quot; rel=&quot;nofollow&quot;&gt;https://drive.google.com/file/d/0B0bZsYo0xMH8YV9uWXJaRFdPT3M/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking of replacing the RFID with SonMicro's SM130 RFID Module w/ SparkFun Eval board with UART (convertible to I2c) or Adafruit's PN532 with I2c by default. Are these okay to be paired with SPIs like the CC3000? Or should I change CC3000 with the Official WiFi module (UART) or WiFly Module (SPI-to-UART)&lt;/p&gt;&#xA;" OwnerUserId="4609" LastActivityDate="2014-12-29T21:41:15.670" Title="Adafruit CC3000 WiFi Module working together with MFRC522 RFID Module Issues both SPI over Arduino" Tags="|wifi|spi|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4799" PostTypeId="2" ParentId="4790" CreationDate="2014-10-30T15:54:22.070" Score="1" Body="&lt;p&gt;Another way to look at it is this:&lt;br&gt;Imagine the current flowing through the LED toward the resistor to be greater than the current flowing out of the resistor toward ground. The only way this could happen is if some of the charge - the difference due to the different currents - accumulated in the resistor. But that cannot happen forever, and not even for any appreciable length of time. (If it could, and did, the device would eventually fail - spectacularly!) So, because charge in must equal charge out over time (and over a very short period, at that) current in has to equal current out.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-10-30T17:56:37.867" LastActivityDate="2014-10-30T17:56:37.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4800" PostTypeId="2" ParentId="4782" CreationDate="2014-10-30T16:08:41.390" Score="0" Body="&lt;p&gt;If your goal is really to print the value from XML, you don't need to worry about types, as long as you believe the XML to be correctly formed. The value in the XML file is already character string just print it. The converting from string to variable (sprintf()) and back to string (Serial.print() or printf()) is unnecessary.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-10-30T17:59:02.970" LastActivityDate="2014-10-30T17:59:02.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4801" PostTypeId="1" AcceptedAnswerId="4868" CreationDate="2014-10-30T16:20:56.883" Score="4" ViewCount="2220" Body="&lt;p&gt;This question is regarding a project using an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have one of these &lt;a href=&quot;http://www.sparkfun.com/products/11102&quot; rel=&quot;nofollow&quot;&gt;quadrature rotary encoders&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a slightly modified version of the code from the article, &lt;a href=&quot;http://www.hessmer.org/blog/2011/01/30/quadrature-encoder-too-fast-for-arduino&quot; rel=&quot;nofollow&quot;&gt;Quadrature Encoder too Fast for Arduino (with Solution)&lt;/a&gt;, which uses a library called &lt;a href=&quot;http://code.google.com/p/digitalwritefast/&quot; rel=&quot;nofollow&quot;&gt;digitalwritefast&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My version of the code on &lt;a href=&quot;http://pastebin.com/ts1QzbgM&quot; rel=&quot;nofollow&quot;&gt;pastebin&lt;/a&gt; - I modified to use different pins for the Uno and a single encoder:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;digitalWriteFast.h&amp;gt;  // library for high performance reads and writes by jrraines&#xA;&#xA;#define c_LeftEncoderInterrupt 0&#xA;#define c_LeftEncoderPinA 2&#xA;#define c_LeftEncoderPinB 3&#xA;&#xA;volatile bool _LeftEncoderBSet;&#xA;volatile long _LeftEncoderTicks = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200); &#xA;  pinMode(c_LeftEncoderPinA, INPUT);      &#xA;  digitalWrite(c_LeftEncoderPinA, LOW); &#xA;  pinMode(c_LeftEncoderPinB, INPUT);&#xA;  digitalWrite(c_LeftEncoderPinB, LOW);&#xA;  attachInterrupt(c_LeftEncoderInterrupt, HandleLeftMotorInterruptA, RISING);&#xA;}&#xA;&#xA;// Interrupt service routines for the left motor's quadrature encoder&#xA;void HandleLeftMotorInterruptA()&#xA;{&#xA;  _LeftEncoderBSet = digitalReadFast2(c_LeftEncoderPinB);   // read the input pin&#xA;  _LeftEncoderTicks -= _LeftEncoderBSet ? -1 : +1;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.print(_LeftEncoderTicks);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am attaching output A of the encoder to pin 2 and output B to pin 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This setup works fine and I can detect turns in both directions, but my problem is, if I set pin B to any other pin, I get positive direction only (regardless of the direction in which the encoder is turned) - as if pin B isn't plugged in at all (I am modifying &lt;code&gt;c_LeftEncoderPinB&lt;/code&gt; accordingly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming that this is something to do with pin 3 being the only other interrupt pin on the Uno (I can't see anything else unique about that pin). Yet I don't know why because the interrupt is on pin A (we're reading the value of pin B in that interrupt, though).&lt;/p&gt;&#xA;" OwnerUserId="4612" LastEditorUserId="6936" LastEditDate="2016-02-18T15:04:16.223" LastActivityDate="2016-02-18T15:04:16.223" Title="Rotary encoder on Uno and interrupts issue" Tags="|arduino-uno|rotary-encoder|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4802" PostTypeId="2" ParentId="4801" CreationDate="2014-10-30T17:13:10.187" Score="2" Body="&lt;p&gt;When turning one way, A is asserted, then B is asserted, then A is deasserted then B is deasserted. You can detect this because A is asserted first, even if you can't tell when B has changed. But if you turn the opposite way then you fail to detect the initial assertion of B, and the code fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you may be able to do is use &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;PinChangeInt&lt;/a&gt; to capture the pin change interrupt rather than an external interrupt. This should allow you to use almost any I/O pins on the Uno for the encoder.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-30T17:13:10.187" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4803" PostTypeId="2" ParentId="4783" CreationDate="2014-10-30T17:40:25.647" Score="2" Body="&lt;p&gt;There's no built in function to do that, I'm afraid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you create a method that will format the string like so. Something along the lines of: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void formatTime()&#xA;{&#xA;   string str = year() + &quot;.&quot; + month() + &quot;.&quot; + day() + &quot;:&quot; + hour() + &quot;FILL IN THE REST&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4613" LastActivityDate="2014-10-30T17:40:25.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4804" PostTypeId="2" ParentId="4792" CreationDate="2014-10-30T18:10:09.803" Score="0" Body="&lt;p&gt;Yes - try making each of the %-specifiers match the kind of conversion you want for each variable in the rest of the call. F/ex, %d converts an integer to a string in decimal radix, %f converts a double to a number with a decimal fraction, etc. In all cases, the output will be as characters; you don't need to specify that.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-10-30T18:10:09.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4805" PostTypeId="1" AcceptedAnswerId="4808" CreationDate="2014-10-30T18:20:46.217" Score="2" ViewCount="1357" Body="&lt;p&gt;I plan on creating a homebrew Arduino breakout board using the ATMEGA328P smd version. I'm geeting confused by the wealth of information out there as to whether I should be using ICSP or ISP to program it. It is a blank chip, aka no Arduino bootloader on it yet. I'd rather not have to buy a specialized programmer to burn the bootloader, I do have another Arduino I could use to burn the bootloader and upload sketches to it with. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question is; Do I use ISP or ICSP, or both?&lt;/p&gt;&#xA;" OwnerUserId="1671" LastActivityDate="2020-07-25T22:48:58.887" Title="Homebrew Arduino using ATMEGA328P, ISP or ICSP?" Tags="|bootloader|atmega328|isp|icsp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4806" PostTypeId="2" ParentId="4805" CreationDate="2014-10-30T18:30:44.617" Score="2" Body="&lt;p&gt;ICSP is used for PICs, not AVRs. Use ISP, which can be performed either by an Arduino via ArduinoISP or by a dedicated programmer.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-10-30T19:16:48.213" LastActivityDate="2014-10-30T19:16:48.213" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4807" PostTypeId="2" ParentId="4773" CreationDate="2014-10-30T18:48:06.260" Score="3" Body="&lt;p&gt;A breakout board usually has the sole purpose of making a single chip (gross generalization here...) available to the experimenter by &quot;breaking out&quot; its signal lines on to dedicated pins - header pins, for instance. It is only large enough for the chip and the printed circuit wiring to do this, and seldom adds any function beyond what the chip itself provides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &quot;shield&quot; is a larger board that usually plugs directly onto an Arduino board, matches its form factor, and is built for a dedicated more complex function, like a complete GPS system or cellular communication system (although some shields are left mostly blank to provide you the space to build your own device). They probably have several chips engineered and built into a complete plug-and-go sub-system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is to learn to use a chip or other device without having to solder up your own board, especially with surface mount devices. The other is a ready-to-go system building block.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-10-30T18:54:47.373" LastActivityDate="2014-10-30T18:54:47.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4808" PostTypeId="2" ParentId="4805" CreationDate="2014-10-30T19:25:50.473" Score="1" Body="&lt;p&gt;To program it you could use an ISP programmer. In which case you would not need the bootloader. You can &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;use an Arduino as an ISP programmer&lt;/a&gt;, but that's not really a long term solution, as you can no longer use the arduino for anything else.&lt;/p&gt;&#xA;&lt;p&gt;The other option is to program it using a usb-to-serial. In this case you do need the arduino bootloader. To program this bootloader (once) you can use the above method, using an arduino board.&lt;/p&gt;&#xA;&lt;p&gt;Third option would be implement USB into the bootloader, just like the &lt;em&gt;completely Open Source&lt;/em&gt; Pro Trinket (&lt;a href=&quot;https://github.com/adafruit/Adafruit_ProTrinket_Bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;bootloader&lt;/a&gt; and &lt;a href=&quot;https://learn.adafruit.com/system/assets/assets/000/018/948/large1024/adafruit_products_protrink5vschm.png?1408558753&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt;). You'd have to add some resistors, zener diodes and a usb plug (just strip an old usb cable). A bit more technical and challenging, but definitely the cheapest&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="186" LastEditDate="2020-07-25T22:48:58.887" LastActivityDate="2020-07-25T22:48:58.887" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="4810" PostTypeId="2" ParentId="4797" CreationDate="2014-10-30T20:51:15.877" Score="1" Body="&lt;p&gt;I couldn't get your code to download so this might be wrong, but it sounds like the modules are running different SPI modes: &lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Mode_numbers&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Mode_numbers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had this problem a few years ago. You'd expect SPI to be SPI, but it comes in four different flavours and they won't talk to each other on the same bus. Unfortunately there's no solution but to replace the modules; the Arduino can only run one SPI bus, so can only talk to one of these modules at a time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you can run UART and I2C or UART and SPI concurrently by using SoftwareSerial (don't use the native Tx/Rx pins, bad things happen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your best bet is to switch to modules that use I2C or UART. Personally I'd use UART, simply for the simplicity of having two separate connections and a higher data rate.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastEditorUserId="4385" LastEditDate="2014-11-29T21:35:35.957" LastActivityDate="2014-11-29T21:35:35.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4812" PostTypeId="1" CreationDate="2014-10-30T21:27:14.247" Score="2" ViewCount="660" Body="&lt;p&gt;I am intending to show the initial, searching for signal..., screen until the location is updated and then show the location on the lcd. However, even after the led on the gps indicates a satellite fix, the screen never leaves the searching for signal screen. Any help would be greatly appreciated-- very new to microcontroller programming. Sorry for the poorly formatted code block as well, I am in a rush.&#xA;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;&#xA;#define RXPin 2&#xA;#define TXPin 3&#xA;#define GPSBaud 4800&#xA;&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;TinyGPSPlus gps;&#xA;LiquidCrystal lcd(12, 11, 10, 7, 6, 5, 4);  &#xA;&#xA;double latt;&#xA;double lon;&#xA;int screen;&#xA;&#xA;void setup(void);&#xA;void loop(void);&#xA;void readGPS(void);&#xA;void update(void);&#xA;void render(void);&#xA;&#xA;void setup() {&#xA;     //variable initialization&#xA;     latt = 0.0;&#xA;     lon = 0.0;&#xA;     screen = 0;&#xA;&#xA;     //lcd initial setup&#xA;     pinMode(9, OUTPUT);&#xA;     analogWrite(9, 100);&#xA;     pinMode(13, OUTPUT);&#xA;     digitalWrite(13, HIGH);&#xA;&#xA;     //display intial screen&#xA;     lcd.begin(16,2);&#xA;     lcd.clear();&#xA;     lcd.setCursor(0,0);&#xA;     lcd.print(&quot;Searching for&quot;);&#xA;     lcd.setCursor(6,2);&#xA;     lcd.print(&quot;Signal ...&quot;);&#xA;     ss.begin(GPSBaud); &#xA;}&#xA;&#xA;void loop() {&#xA;    readGPS();&#xA;    update();&#xA;}&#xA;&#xA;/** Receives data from the gps if available */&#xA;void readGPS() {&#xA;    while (ss.available() &amp;gt; 0) {&#xA;        gps.encode(ss.read());&#xA;    }&#xA;}&#xA;&#xA;/** Processes the data read by readGPS() */&#xA;void update() {&#xA;    if (gps.location.isUpdated()) {&#xA;        latt = gps.location.lat();&#xA;        lon = gps.location.lng();&#xA;        render();       &#xA;    }&#xA;}&#xA;&#xA;/** Displays the current screen on the lcd */&#xA;void render() {&#xA;    if (screen == 0) {&#xA;        lcd.clear();&#xA;        lcd.setCursor(0,0);&#xA;        lcd.print(&quot;Lat:&quot;);&#xA;        lcd.print(latt);&#xA;        lcd.print(&quot; Lng:&quot;);&#xA;        lcd.print(lon);&#xA;        lcd.setCursor(0,1);&#xA;        lcd.print(&quot;Sats:&quot;);&#xA;        lcd.print(gps.satellites.value());&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4618" LastEditorUserId="84" LastEditDate="2014-10-31T05:27:25.043" LastActivityDate="2015-02-02T17:52:01.770" Title="Adafruit gps breakout module help" Tags="|arduino-uno|lcd|tinygps|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4816" PostTypeId="2" ParentId="1329" CreationDate="2014-10-31T01:46:00.627" Score="1" Body="&lt;p&gt;Try using the most popular one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;https://github.com/miguelbalboa/rfid&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is working for me. It returns the uID as what you desire. Just remove the other functions just the getting of the uid from its example.&lt;/p&gt;&#xA;" OwnerUserId="4609" LastActivityDate="2014-10-31T01:46:00.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4817" PostTypeId="1" AcceptedAnswerId="4826" CreationDate="2014-10-31T02:40:07.877" Score="1" ViewCount="1222" Body="&lt;p&gt;Update: This piece of code does not do the same as the one in the right answer, it also reacts when one lets go of the button.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int button_prev = 0;&#xA;int button = 0;&#xA;&#xA;void loop(){&#xA;&#xA;    button_prev = button;&#xA;&#xA;    button = digitalRead(12);&#xA;&#xA;    if (button_prev != button) {&#xA;&#xA;      digitalWrite(act_pin[j], HIGH);&#xA;&#xA;      j = (j+1) % 5;&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I printed out j and it seems like, instead of counting up +1 everytime the button is pressed once, it turns +1 and then +1 again which makes two LEDs at a time turn on.&#xA;But I don't see where the behavior of j comes from...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Update: There was a mistake in the code which caused the random behavior, but now, nothing happens when I push the button.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[I wrote a sketch which is supposed to make the Arduino turn one of five LEDs on one after another every time I press the switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But instead of turning one LED on after another, directly after upload it just makes them turn on and of at random. I don't push the button.&#xA;&lt;code&gt;Serial.println&lt;/code&gt; as well just spits out one character, similiar looking to a &lt;code&gt;d&lt;/code&gt;.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone point out my mistake to me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the circuit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ohDRc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and this is the &lt;em&gt;old code&lt;/em&gt; of the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int act_pin[6] = {A0, A1, A2, A3, A4};&#xA;&#xA;int j = 0;&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  for (int k = 0; k &amp;lt; 5; k++) {&#xA;&#xA;     pinMode(act_pin[k], OUTPUT); //sets analog pins A0 - A4 as output&#xA;&#xA;     digitalWrite(act_pin[k], LOW); //turns LEDs connected to A0 - A4 off&#xA;&#xA;     pinMode(12, INPUT); //sets pin connected to button as input&#xA;&#xA;}&#xA;&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;  char button = {digitalRead(12)}; //stores if the button was pressed&#xA;&#xA;  Serial.println(button);&#xA;&#xA;  if(button == HIGH){ &#xA;&#xA;    digitalWrite(act_pin[j], HIGH); //turns LEDs on A0 - A4 on one after one with every button press &#xA;&#xA;    j = (j+1) % 5; //makes digitalWrite jump to the next LED next time the button is pressed and limits it to 4&#xA;&#xA;    button = LOW; //turns the button's pin low again, so nothing will happen until the button is pressed again&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4591" LastEditorUserId="84" LastEditDate="2014-11-01T13:42:59.590" LastActivityDate="2014-11-01T13:42:59.590" Title="Unintended reaction: Sketch makes LEDs turn on and of randomly/LEDs don't react" Tags="|led|sketch|button|debounce|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="4818" PostTypeId="2" ParentId="4817" CreationDate="2014-10-31T02:54:37.327" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;if(button = HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Oops.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (button == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And see the &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;Debounce example sketch&lt;/a&gt; to learn how to debounce inputs.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-10-31T02:54:37.327" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4819" PostTypeId="1" CreationDate="2014-10-31T03:19:19.857" Score="1" ViewCount="1118" Body="&lt;p&gt;I'm using 1mOhm resistor in parallel to a piezo that is connected to analog1 pin on the Due, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nd4Y6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the following code to observe the readings in the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int piezo = A0;&#xA;int threshold = 200;//anything over 200 means I've hit the piezo&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;//this part checks if the threshold has been reached and then writes the strenght of the signal &#xA;&#xA;void loop(){&#xA;    int piezoVal = analogRead(piezo);&#xA;&#xA;    if (piezoVal&amp;gt;threshold){&#xA;        Serial.println(piezoVal);&#xA;&#xA;        delay(10); //delay is used to prevent from getting multiple values one after another, usually 3-4&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The things that bother me are: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;if I do not use threshold, then I am constantly getting readings from the piezo, even if the threshold is slightly below 200. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if I do not use delay, then I'm getting getting multiple values one after another&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and the strangest thing is while I hit the mouse pad that covers the piezo, the readings in the serial monitor are not matching the force being used to trigger the piezo. Sometimes they stay the same, sometimes they reach 6-700 after I directly touch the piezo, sometimes I hit really hard and I only get some slight increase (for ex. from 225 to 229).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This doesn't make sense to me. I think the stronger the vibration, the higher the values should be. Cause I've tried with two different piezos and different resistors (1mOhm, 1.2 mOhm and 1.5 mOhm) and I'm still getting the same result. I bought the Due few days ago in order to build a drum kit, and I have no problem with sending midi notes to a DAW, but this piezo sensitivity thing is driving me crazy. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="4622" LastEditorUserId="84" LastEditDate="2014-10-31T05:33:06.460" LastActivityDate="2014-12-30T08:58:08.620" Title="Problem with piezo readings and Arduino Due" Tags="|arduino-due|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4820" PostTypeId="2" ParentId="4817" CreationDate="2014-10-31T05:49:50.220" Score="2" Body="&lt;p&gt;Your code has a serious bug here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(button == HIGH){ &#xA;&#xA;    digitalWrite(act_pin[j], HIGH);&#xA;&#xA;    j = j+1;&#xA;&#xA;    button = LOW;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You increment &lt;code&gt;j&lt;/code&gt; without any boundary so it will have the following cycling values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0, 1, 2, 3 ... 32767, -32768, -32767 ... -1, 0 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hence, quickly &lt;code&gt;act_pin[j]&lt;/code&gt; will return garbage...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is easy, you must limit &lt;code&gt;j&lt;/code&gt; to &lt;code&gt;[0,1,2,3,4]&lt;/code&gt;, just replace the &lt;code&gt;j = j + 1&lt;/code&gt; line as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;j = (j + 1) % 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%&lt;/code&gt; is the modulo integral operation that will give you the reminder of dividing j by 5, which is always strictly less than 5, and it cycles as you want.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-10-31T05:49:50.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4821" PostTypeId="1" CreationDate="2014-10-31T05:53:08.713" Score="1" ViewCount="2602" Body="&#xA;&#xA;&lt;p&gt;I have simple code. The library downloaded from &lt;a href=&quot;https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;github:smarmengol/Modbus-Master-Slave-for-Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to store floating point. In the code blow, I type casted to integer value. As I know &lt;code&gt;uint16_t au16data[30];&lt;/code&gt; is integer &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include&quot;glob.h&quot;&#xA;&#xA;&#xA;#define ID   1&#xA;int8_t state = 0;&#xA;Modbus slave(ID, 0, 0);&#xA;unsigned long tempus;&#xA;// data array for modbus network sharing&#xA;uint16_t au16data[30];&#xA;&#xA;void Take_Reading()&#xA;{&#xA;  for(row=0;row&amp;lt;9;row++)&#xA;  {&#xA;  int k=(8*array[row][0]+4*array[row][1]+2*array[row][2]+1*array[row][3]);&#xA;    digitalWrite(Enablepin,array[row][0]);&#xA;    digitalWrite(SO_enable,array[row][1]);&#xA;    digitalWrite(S1_enable,array[row][2]);&#xA;    digitalWrite(S2_enable,array[row][3]); &#xA;   //delay(100); &#xA;    Sensor_Value0=analogRead(A0);&#xA;    Sensor_Value1=analogRead(A5);&#xA;   Mux1_array[row]=(Sensor_Value0 * ARDUINO_ANALOG_SCALING);&#xA;   Mux2_array[row]=(Sensor_Value1 * ARDUINO_ANALOG_SCALING);&#xA;&#xA;   Current_Value1[row]=  (Mux1_array[row]*40)-98;&#xA;   Current_Value2[row]=  (Mux2_array[row]*40)-98;&#xA;&#xA;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;     wdt_enable(WDTO_8S);&#xA;   slave.begin( 9600 );&#xA;  tempus = millis() + 100;&#xA;  pinMode(3,OUTPUT);&#xA;  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino&#xA;  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino&#xA;  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino&#xA;  pinMode(Enablepin, OUTPUT) ;// pin can enable/disable using digital IO 4 of arduino&#xA;  pinMode(A0, INPUT) ;&#xA;  pinMode(A5, INPUT) ;&#xA;&#xA;//  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(3,HIGH);&#xA;// wdt_reset();&#xA; Take_Reading(); &#xA; state = slave.poll( au16data,30 );&#xA;  if (state &amp;gt; 4) {&#xA;    tempus = millis() + 50;&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;  if (millis() &amp;gt; tempus) digitalWrite(13, LOW );&#xA;&#xA;Modbus_call();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void Modbus_call()&#xA;{&#xA;&#xA;/*reading of coil where i can succefully read value*/&#xA;  au16data[0]=(int)Current_Value1[0];&#xA;  au16data[1]=(int)Current_Value1[1];&#xA;  au16data[2]=(int)Current_Value1[2];&#xA;  au16data[3]=(int)Current_Value1[3];&#xA;  au16data[4]=(int)Current_Value1[4];&#xA;  au16data[5]=(int)Current_Value1[5];&#xA;  au16data[6]=(int)Current_Value1[6];&#xA;  au16data[7]=(int)Current_Value1[7];&#xA;  au16data[8]=(int)Current_Value1[8]; &#xA;  au16data[9]=(int)Current_Value2[0];&#xA;  au16data[10]=(int)Current_Value2[1];  &#xA;  au16data[11]=(int)Current_Value2[2];&#xA;  au16data[12]=(int)Current_Value2[3];&#xA;  au16data[16]=(int)Current_Value2[4];&#xA;   au16data[17]=(int)Current_Value2[5];&#xA;   au16data[18]=(int)Current_Value2[6];&#xA;   au16data[19]=(int)Current_Value2[7];&#xA; uint16_t calcCRC( au16data[15]);&#xA;     au16data[13] = slave.getInCnt();&#xA;  au16data[14] = slave.getOutCnt();&#xA;  au16data[15] = slave.getErrCnt(); &#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Conversion method as below.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;CS=30.10&#xA;Int_CS=int(CS)&#xA;FLOAT_CS=(Int_CS-CS)*100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to store the &lt;code&gt;Int_CS&lt;/code&gt; &amp;amp; &lt;code&gt;FLOAT_CS&lt;/code&gt; values in &lt;code&gt;au16data[0]&lt;/code&gt;??&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have change code accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nd4WO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nd4WO.jpg&quot; alt=&quot;Output file&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I get zero. After some time its values don't even show&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include&quot;glob.h&quot;&#xA;&#xA;&#xA;#define ID   1&#xA;int8_t state = 0;&#xA;Modbus slave(ID, 0, 0);&#xA;unsigned long tempus;&#xA;// data array for modbus network sharing&#xA;uint16_t au16data[5];&#xA;float auFloatData[30];&#xA;void Take_Reading()&#xA;{&#xA;  for(row=0;row&amp;lt;9;row++)&#xA;  {&#xA;  int k=(8*array[row][0]+4*array[row][1]+2*array[row][2]+1*array[row][3]);&#xA;    digitalWrite(Enablepin,array[row][0]);&#xA;    digitalWrite(SO_enable,array[row][1]);&#xA;    digitalWrite(S1_enable,array[row][2]);&#xA;    digitalWrite(S2_enable,array[row][3]); &#xA;   //delay(100); &#xA;    Sensor_Value0=analogRead(A0);&#xA;    Sensor_Value1=analogRead(A5);&#xA;   Mux1_array[row]=(Sensor_Value0 * ARDUINO_ANALOG_SCALING);&#xA;   Mux2_array[row]=(Sensor_Value1 * ARDUINO_ANALOG_SCALING);&#xA;&#xA;   Current_Value1[row]=  (Mux1_array[row]*40)-98;&#xA;   Current_Value2[row]=  (Mux2_array[row]*40)-98;&#xA;&#xA;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;     wdt_enable(WDTO_8S);&#xA;   slave.begin( 9600 );&#xA;  tempus = millis() + 100;&#xA;  pinMode(3,OUTPUT);&#xA;  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino&#xA;  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino&#xA;  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino&#xA;  pinMode(Enablepin, OUTPUT) ;// pin can enable/disable using digital IO 4 of arduino&#xA;  pinMode(A0, INPUT) ;&#xA;  pinMode(A5, INPUT) ;&#xA;&#xA;//  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(3,HIGH);&#xA;// wdt_reset();&#xA; Take_Reading(); &#xA; state = slave.poll( au16data,5 );&#xA;  if (state &amp;gt; 4) {&#xA;    tempus = millis() + 50;&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;  if (millis() &amp;gt; tempus) digitalWrite(13, LOW );&#xA;&#xA;Modbus_call();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void Modbus_call()&#xA;{&#xA;&#xA;/*reading of coil where i can succefully read value*/&#xA;  auFloatData[20]=Current_Value1[0];&#xA;  auFloatData[21]=Current_Value1[1];&#xA;  auFloatData[22]=Current_Value1[3];&#xA;  auFloatData[4]=Current_Value1[4];&#xA;  auFloatData[5]=Current_Value1[5];&#xA;  auFloatData[6]=Current_Value1[6];&#xA;  auFloatData[7]=Current_Value1[7];&#xA;  auFloatData[8]=Current_Value1[8]; &#xA;  auFloatData[9]=Current_Value2[0];&#xA;  auFloatData[10]=Current_Value2[1];  &#xA;  auFloatData[11]=Current_Value2[2];&#xA;  auFloatData[12]=Current_Value2[3];&#xA;  auFloatData[16]=Current_Value2[4];&#xA;   auFloatData[17]=Current_Value2[5];&#xA;   auFloatData[18]=Current_Value2[6];&#xA;   auFloatData[19]=Current_Value2[7];&#xA;uint16_t calcCRC( au16data[3]);&#xA;     au16data[1] = slave.getInCnt();&#xA;  au16data[2] = slave.getOutCnt();&#xA;  au16data[3] = slave.getErrCnt(); &#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="10794" LastEditDate="2015-08-07T07:04:14.933" LastActivityDate="2017-04-29T10:45:34.130" Title="Modbus slave data into word" Tags="|arduino-uno|data-type|modbus|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4822" PostTypeId="2" ParentId="4821" CreationDate="2014-10-31T06:09:07.247" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Sizes&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://developer.mbed.org/users/mbed714/notebook/integer-types-int-long-and-long-long/&quot; rel=&quot;nofollow&quot;&gt;Integer Types (int, long and long long)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of Boolean type is 1 byte(s)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Number of bits in a character: 8&#xA;Size of character types is 1 byte&#xA;Signed char min: -128 max: 127&#xA;Unsigned char min: 0 max: 255&#xA;Default char is unsigned&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of short int types is 2 bytes&#xA;Signed short min: -32768 max: 32767&#xA;Unsigned short min: 0 max: 65535&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of int types is 4 bytes&#xA;Signed int min: -2147483648 max: 2147483647&#xA;Unsigned int min: 0 max: 4294967295&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of long int types is 4 bytes&#xA;Signed long min: -2147483648 max: 2147483647&#xA;Unsigned long min: 0 max: 4294967295&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Size of long long types is 8 bytes&#xA;Signed long long min: -9223372036854775808 max: 9223372036854775807&#xA;Unsigned long long min: 0 max: 18446744073709551615&#xA;Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;What do you want to achieve with &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CS=30.10 // 30.10&#xA;Int_CS=int(CS) // 30&#xA;FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you have to do like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float CS = 30.10;&#xA;au16data[0]= (int)(CS*100);//3010.00 &amp;gt; 3010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for better way use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float auFloatData[30]; // &#xA;...&#xA;auFloatData[0]=Current_Value1[0];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-10-31T10:48:53.843" LastActivityDate="2014-10-31T10:48:53.843" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4823" PostTypeId="2" ParentId="4819" CreationDate="2014-10-31T07:08:12.070" Score="2" Body="&lt;p&gt;The problem is timing.  When you tap or hit the sensor it produces an impulse response: a signal that increases to a peak, then decays back to zero.  You are expecting the code to capture the peak value.  Your code is spinning in loop() as quickly as possible, but captures just the first point above the threshold. The signal can still be increasing when you capture and print.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So imagine this stream of signal values&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time  signal   analogRead()&#xA;      at pin   occurs&#xA;----  ------   --------&#xA; 1     190      190&#xA; 2     190&#xA; 3     199      &#xA; 4     210    &#xA; 5     220      220 - trips threshold, prints and then waits&#xA; 6     230&#xA; 7     260&#xA; 8     280&#xA; 9     320      (this point occurs during delay())&#xA; 10    280&#xA; 11    260&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same exact signal, but at a slightly different time could be read different by the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time  signal   analogRead()&#xA;      at pin   occurs&#xA;----  ------   --------&#xA; 1     190      &#xA; 2     190&#xA; 3     199      199&#xA; 4     210    &#xA; 5     220      &#xA; 6     230&#xA; 7     260      260&#xA; 8     280&#xA; 9     320      (closer, but still did not read the peak)&#xA; 10    280&#xA; 11    260&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the strategy of catching the first point above the threshold makes it unlikely you can capture the peak value.  There are two ways forward: hardware or software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use electronics that latches the maximum value.  If you search &quot;peak hold circuit&quot; you will find many circuits that would capture and hold the peak.  That frees the Arduino to somewhat lazily spin in the loop and still be able to accurately capture the peak.  Once it sees the value is no long increasing, it resets the peak hold and goes back to waiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use code to capture the peak. Something along the lines of this psuedo code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastreading = analogread()&#xA;if(lastreading &amp;gt; threshold) {&#xA;  peakreading = lastreading&#xA;  keeplooking = true&#xA;  while(keeplooking) {&#xA;    nextreading = analogRead()&#xA;    if(nextreading &amp;gt; lastreading) {&#xA;      // the signal is increasing, save this and see if next point is even higher&#xA;      peakreading = nextreading&#xA;      lastreading = nextreading&#xA;    }&#xA;    else {&#xA;      //signal is decreasing, the peak is over&#xA;      keeplooking = false&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This software approach could still miss a sharp peak that occurs between analogRead()'s, but may be good enough for your use.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-10-31T07:08:12.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4824" PostTypeId="2" ParentId="4511" CreationDate="2014-10-31T09:28:07.583" Score="1" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;windows.h&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#define ARDUINO_WAIT_TIME 2000&#xA;using namespace std;&#xA;&#xA;string portNumber;&#xA;HANDLE hSerial;&#xA;bool connected;&#xA;COMSTAT status;&#xA;&#xA;bool connectPrinter(char *portName){&#xA;&#xA;    //Connects to the port.&#xA;    hSerial = CreateFileA(portName,&#xA;    GENERIC_READ | GENERIC_WRITE,&#xA;    0,&#xA;    NULL,&#xA;    OPEN_EXISTING,&#xA;    FILE_ATTRIBUTE_NORMAL,&#xA;    NULL);&#xA;&#xA;    if(hSerial==INVALID_HANDLE_VALUE)&#xA;    {&#xA;        if(GetLastError()==ERROR_FILE_NOT_FOUND){&#xA;            printf(&quot;ERROR: Handle was not attached. Reason: %s not available.\n&quot;, portName);&#xA;            return false;&#xA;        }&#xA;        else&#xA;        {&#xA;            //If port is in use by another program or did not closed previous process.&#xA;            printf(&quot;ERROR!!! \n&quot;);&#xA;            CloseHandle(hSerial);&#xA;            return false;&#xA;        }&#xA;    }&#xA;    else&#xA;    {&#xA;&#xA;        DCB dcbSerialParams = {0};&#xA;&#xA;        if (!GetCommState(hSerial, &amp;amp;dcbSerialParams))&#xA;        {&#xA;            printf(&quot;failed to get current serial parameters!&quot;);&#xA;            return false;&#xA;        }&#xA;        else&#xA;        {&#xA;            // Set Serial Port specifications.&#xA;            dcbSerialParams.BaudRate=CBR_115200;&#xA;            dcbSerialParams.ByteSize=8;&#xA;            dcbSerialParams.StopBits=ONESTOPBIT;&#xA;            dcbSerialParams.Parity=NOPARITY;&#xA;&#xA;             if(!SetCommState(hSerial, &amp;amp;dcbSerialParams))&#xA;             {&#xA;                printf(&quot;ALERT: Could not set Serial Port parameters&quot;);&#xA;                return false;&#xA;             }&#xA;             else&#xA;             {&#xA;                 connected = true;&#xA;                 printf(&quot;Connection Successful for :%s !!! \n&quot; ,portName);&#xA;                 //Wait 2s as the arduino board will be reseting&#xA;                 return true;&#xA;                 Sleep(ARDUINO_WAIT_TIME);&#xA;             }&#xA;        }&#xA;    }&#xA;&#xA;}&#xA;&#xA;&#xA;int readData(char *buffer,unsigned int nbChar){&#xA;&#xA;    DWORD bytesRead;&#xA;    DWORD dwCommModemStatus;&#xA;&#xA;        //Set the type of data to be caught.(RXCHAR -&amp;gt; Data available on RX pin.)&#xA;        SetCommMask (hSerial, EV_RXCHAR );&#xA;&#xA;        while (hSerial != INVALID_HANDLE_VALUE)&#xA;        {&#xA;          // Wait for an event to occur for the port.&#xA;          WaitCommEvent (hSerial, &amp;amp;dwCommModemStatus, 0);&#xA;&#xA;          if (dwCommModemStatus &amp;amp; EV_RXCHAR )&#xA;          {&#xA;                //unsigned int toRead;&#xA;                //ClearCommError(this-&amp;gt;hSerial, &amp;amp;this-&amp;gt;errors, &amp;amp;this-&amp;gt;status);&#xA;                do&#xA;                {&#xA;                  // Read the data from the serial port.&#xA;                    ReadFile (hSerial, buffer, 1, &amp;amp;bytesRead, 0);&#xA;                  // Display the data read.&#xA;                      printf (&quot;%s&quot; ,buffer);&#xA;&#xA;                } while (bytesRead &amp;gt; 0);&#xA;          }&#xA;        }&#xA;    //}&#xA;    //If nothing has been read, or that an error was detected return -1&#xA;    return -1;&#xA;}&#xA;&#xA;    int main()&#xA;    {&#xA;&#xA;        char* buffer = new char[32768];&#xA;        int nbChar= 32768;&#xA;        string str=&quot;COMx&quot;; // Use your port number to connect&#xA;&#xA;        char * writable = new char[str.size() + 1];&#xA;        std::copy(str.begin(), str.end(), writable);&#xA;        writable[str.size()] = '\0';&#xA;&#xA;        connectPrinter(writable); &#xA;        delete []writable;&#xA;        readData(buffer,nbChar);&#xA;        return 0;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;try this one, it should work. Comment below if it does not work. You might reset Arduino to read data in method &lt;code&gt;void setup()&lt;/code&gt; in Arduino code. I recommend you to use C#, Java or Python for efficiency.&lt;/p&gt;&#xA;" OwnerUserId="4430" LastEditorUserId="4430" LastEditDate="2014-11-12T08:06:25.140" LastActivityDate="2014-11-12T08:06:25.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4826" PostTypeId="2" ParentId="4817" CreationDate="2014-10-31T16:32:55.010" Score="1" Body="&lt;p&gt;I think you're looking for the action (in pseudo-code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ONCE (Button Pressed):&#xA;    Light LED j;&#xA;    j++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you have an IF(button) in a Loop{}. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WHILE (Button Pressed):&#xA;    Light LED j;&#xA;    j++&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when you press the button j will increment every iteration of Loop {}  (very fast) and you won't be able to see the LEDs changing. Your 'button = LOW' is not effective because 'button' gets set again the next time if the button is still pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try printing j instead of button at the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(j);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that should highlight the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would implement a ONCE(Button Pressed) function by observing the previous button state and checking it has changed from LOW to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    button_prev = button;&#xA;    button = digitalRead(12);&#xA;// Check if button changed from LOW to HIGH&#xA;    if (!button_prev &amp;amp;&amp;amp; button) {&#xA;    ...code&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: Dealing with Contact Bounce&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switches are mechanical so they don't switch cleanly. This is called contact bounce and means the switch switches on/off very rapidly for about 10ms or so after the contact has been pressed or released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.picotech.com/experiments/switch_bounce/measuring-switch-bounce.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Measuring Switch Bounce&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I0Zol.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can deal with it quite simply in the code as follows (pseudo code) just by waiting for the bounce to dissapear and checking the button is still pressed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ONCE (Button Pressed):&#xA;   WAIT(20ms)              // wait for the bounce to stop&#xA;   IF(Button Pressed):     // Ensure the button is still pressed&#xA;    ...code...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try the following Arduino Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    button_prev = button;&#xA;    button = digitalRead(12);&#xA;// Check if button changed from LOW to HIGH&#xA;    if (!button_prev &amp;amp;&amp;amp; button) {&#xA;       delay(20);                 // Wait for debounce&#xA;       if(digitalRead(12))  {     // Make sure the button is still pressed&#xA;        ...code&#xA;       }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="113" LastEditorUserId="113" LastEditDate="2014-11-01T12:17:10.917" LastActivityDate="2014-11-01T12:17:10.917" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4828" PostTypeId="1" CreationDate="2014-11-01T02:33:19.387" Score="0" ViewCount="254" Body="&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the code to this, but it does not work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;`if ((millis() - lastDebounceTime) &gt; debounceDelay) {&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (button) {&#xA; //DEBOUNCING&#xA;&#xA;     if (!button_prev &amp;amp;&amp;amp; button) {&#xA;&#xA;      int e = input[j];`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to debounce a button and integrated this code &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Tutorial/Debounce&lt;/a&gt; into my sketch.&#xA;The result is, that there is no reaction to the button at all.&#xA;I can't figure out the mistake, but maybe someone else sees what I overlook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Circuit&#xA;&lt;img src=&quot;https://i.stack.imgur.com/xKIfJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parts marked with &lt;code&gt;//DEBOUNCING&lt;/code&gt; are only for the purpose of it, parts marked &lt;code&gt;//DEBOUNCE relevant&lt;/code&gt; are necessary for the code to run as well when there is no debouncing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  //setting button pin as input and LOW&#xA;&#xA;  pinMode(8, INPUT);&#xA;  digitalWrite(8, LOW); //DEBOUNCE relevant&#xA;&#xA;&#xA;  //setting input pins as output&#xA;&#xA;  int act_pin[6] = {A0, A1, A2, A3, A4};&#xA;&#xA;  int k = 0;&#xA;&#xA;  for (k = 0; k &amp;lt; 5; k++) {&#xA;&#xA;      pinMode(act_pin[k], OUTPUT);&#xA;&#xA;    }&#xA;&#xA;&#xA;  //setting state pins as output&#xA;&#xA;  int z_pin[5] = {2, 3, 4, 5};&#xA;&#xA;  int a = 0;   &#xA;&#xA;  for (a = 0; a &amp;lt; 4; a++) {&#xA;&#xA;      pinMode(z_pin[a], OUTPUT);&#xA;&#xA;   }&#xA;&#xA;&#xA;  //setting output pins as output&#xA;&#xA;  int out_pin[6] = {9, 10, 11};&#xA;&#xA;  int b = 0;&#xA;&#xA;  for (b = 0; b &amp;lt; 3; b++) {&#xA;&#xA;      pinMode(out_pin[b], OUTPUT);&#xA;&#xA;   }&#xA;&#xA;&#xA;  //setting input  &#xA;&#xA;  for(k = 0; k &amp;lt; 5; k++) {&#xA;&#xA;      randomSeed(analogRead(5));&#xA;&#xA;      int i = random(2);&#xA;&#xA;&#xA;      if(i == 1){&#xA;&#xA;         digitalWrite(act_pin[k], HIGH);&#xA;&#xA;         input[k] = 1;&#xA;&#xA;         Serial.print(input[k]);&#xA;&#xA;      }&#xA;&#xA;       else{&#xA;&#xA;         digitalWrite(act_pin[k], LOW);&#xA;&#xA;         input[k] = 0;&#xA;&#xA;         Serial.print(input[k]);&#xA;&#xA;&#xA;      }&#xA;&#xA;    } &#xA;&#xA;   //setting initial situation&#xA;&#xA;   digitalWrite(2, LOW);&#xA;   digitalWrite(3, HIGH);&#xA;   digitalWrite(4, LOW);&#xA;   digitalWrite(5, LOW);&#xA;&#xA;&#xA;   }&#xA;&#xA;//DEBOUNCING&#xA;&#xA;long lastDebounceTime = 0;  // the last time the button pin was toggled&#xA;long debounceDelay = 50;    // the debounce time; increase if the output flickers&#xA;int buttonState;&#xA;&#xA;//DEBOUNCING&#xA;&#xA;&#xA;boolean button_prev = 0;&#xA;&#xA;boolean button = 0;&#xA;&#xA;int j = 0; //value shows current lamp being processed&#xA;&#xA;//setting initial state&#xA;&#xA;char z[4] = &quot;z_0&quot;; &#xA;&#xA;void loop() {&#xA;&#xA;    button_prev = button;&#xA;&#xA;    button = digitalRead(8); //DEBOUNCE relevant&#xA;&#xA;    // DEBOUNCING&#xA;    if (button != button_prev) {&#xA;&#xA;    lastDebounceTime = millis();&#xA;&#xA;    }&#xA;&#xA;    if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;&#xA;       if (button != button_prev) {&#xA;     //DEBOUNCING&#xA;&#xA;         if (!button_prev &amp;amp;&amp;amp; button) {&#xA;&#xA;          int e = input[j];&#xA;&#xA;           //provides a nice output&#xA;            Serial.println(&quot; &quot;);&#xA;            Serial.print(&quot;Current lamp being processed:&quot;);&#xA;            Serial.println(j);&#xA;            Serial.println(&quot; &quot;);&#xA;            Serial.print(&quot;Current input:&quot;);&#xA;            Serial.println(e);&#xA;&#xA;&#xA;             delta(e, z);&#xA;&#xA;            Serial.print(&quot;State outside function:&quot;);&#xA;            Serial.println(z);&#xA;&#xA;            lamda(e, z);&#xA;&#xA;             j = (j+1) % 5;&#xA;&#xA;      }&#xA;&#xA;&#xA;    } &#xA;&#xA;   }&#xA;}     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4591" LastEditorUserId="4591" LastEditDate="2014-11-01T12:06:06.633" LastActivityDate="2015-01-01T22:24:17.307" Title="Debouncing results in no reaction at all" Tags="|arduino-uno|sketch|button|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4829" PostTypeId="2" ParentId="4828" CreationDate="2014-11-01T03:52:29.437" Score="1" Body="&lt;p&gt;It's difficult to tell without seeing your circuit, but it looks like there could be a mix up between pin 12 and pin 8.  Can see that you initialize the pinMode for pin 12 in setup, but it isn't used in the loop.  You didn't initialize pin 8 (not completely necessary) in setup, but it is used in the loop.  If you don't feel this is relevant, please provide some more detail.&lt;/p&gt;&#xA;" OwnerUserId="4539" LastActivityDate="2014-11-01T03:52:29.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4830" PostTypeId="1" CreationDate="2014-11-01T04:27:25.747" Score="8" ViewCount="2929" Body="&lt;p&gt;I'd like to be able to upgrade software on an arduino without physically touching the device or stringing a cable. Can it be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will pick wireless protocol that makes that easiest.&lt;/p&gt;&#xA;" OwnerUserId="4631" LastActivityDate="2015-10-16T14:39:22.427" Title="Over-the-air upgrades?" Tags="|wifi|bluetooth|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4831" PostTypeId="2" ParentId="4830" CreationDate="2014-11-01T05:53:00.940" Score="2" Body="&lt;p&gt;It's possible to write a bootloader running in RAM (or even in Flash, maybe in a special boot block - depends on the microcontroller). &lt;br&gt;&#xA;This bootloader has to be able to establish the wireless communication, understand the protocol and to erase/write Flash memory. &lt;br&gt;&#xA;There are basically two approaches for software upgrading:&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The bootloader looks at startup for a &quot;software upgrade&quot; command. If it is received, it waits for the programming sequence. If it is not received, it starts the application.&lt;br&gt;&lt;/li&gt;&#xA;&lt;li&gt;The application is able to receive such a command and gives control to the bootloader then.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What protocol you choose is almost irrelevant. Just make sure that there are enough resources for keeping it in RAM/Flash.&#xA;On an Arduino Due - for instance - there are more than enough resources for any such implementation. &lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-11-01T05:53:00.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4833" PostTypeId="2" ParentId="4828" CreationDate="2014-11-01T11:44:17.083" Score="0" Body="&lt;p&gt;If the button has stopped bouncing then (button_prev == button) and the inner if (button != button_prev)  will fail. Basically you're trying to ensure the button is steady but then you're checking that it changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;&#xA;       if (button) {     // Check the button is still pressed&#xA;       ... code...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="113" LastActivityDate="2014-11-01T11:44:17.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4835" PostTypeId="1" CreationDate="2014-11-02T01:04:40.283" Score="1" ViewCount="2183" Body="&lt;p&gt;On my Arduino Yun (openwrt-yun, updated to latest version), I have a bluetooth dongle in the usb port; I have installed bluez-libs and bluez-utils (and python-bluez).  They show up as version 5.13.  hciconfig and hcitool work properly.  There does not seem to be any utility installed to pair with a device, nor can I figure out how to get pairing to work by editing config files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can find the device with hciconfig and hcitool, but rfcomm can't connect without the pin.  If I try the same sequence on my Linux laptop after pairing with the gui, rfcomm is able to connect, so I know the device is working properly (JY-MCU HC-06 on another Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the recommendations I can find on the web indicate I should be able to use simple-agent or bluez-simple-agent, but they are not installed with these packages (there is no bluez-tools package for this distro).  If I manually copy the python script for the agent to the device and run it, it fails, saying that org.bluez can't be found with dbus.  There is no bluetoothd running, and no init script for any bluetooth demon.  None of the bt* tools are available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found a description of how to set a pin code in /var/lib/bluetooth/[bt-addr]/pincodes (where bt-addr is my dongle address) containing a line of the form:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[device-addr]  [pincode]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but this seems to have no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried settings in /etc/bluetooth/main.conf and /etc/bluetooth/rfcomm.conf, but I think they may only be for incoming connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4643" LastActivityDate="2015-10-10T20:12:12.647" Title="How can I pair a Bluetooth dongle on arduino Yun (openwrt-yun)?" Tags="|arduino-yun|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4836" PostTypeId="2" ParentId="4828" CreationDate="2014-11-02T19:42:17.103" Score="0" Body="&lt;p&gt;You've probably fixed this already but pin 8 is always grounded, regardless of the button state.  Pin 8 should be connected between the button and the pull-down resistor.&lt;/p&gt;&#xA;" OwnerUserId="4646" LastActivityDate="2014-11-02T19:42:17.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4837" PostTypeId="1" AcceptedAnswerId="4840" CreationDate="2014-11-02T20:14:26.260" Score="1" ViewCount="1469" Body="&lt;p&gt;I'd like for a 16x2 LCD monitor from &lt;a href=&quot;https://www.sparkfun.com/products/9394&quot; rel=&quot;nofollow&quot;&gt;Sparkfun&lt;/a&gt; to display sensor data from a 4-directional tilt sensor from &lt;a href=&quot;http://learn.parallax.com/KickStart/28036&quot; rel=&quot;nofollow&quot;&gt;Parallax&lt;/a&gt;. The Arduino board is a Duemillanove. The board will run and power both programs and modules, but the serial monitor displaying the tilt sensor data will not relay the info to the LCD display. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the two pieces of code I am trying to get to work together—they are both from Arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the tilt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { &#xA;   Serial.begin(9600); &#xA;} &#xA;void loop() { &#xA;   Serial.print(&quot;Photo 1: &quot;); &#xA;   Serial.print(digitalRead(6), DEC); // Display Out 1 value &#xA;   Serial.print(&quot;; &quot;); &#xA;   Serial.print(&quot;Photo 2: &quot;); &#xA;   Serial.println(digitalRead(7), DEC); // Display Out 2 value &#xA;   delay(250); // Wiat 1/4 second &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the LCD:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; // Attach the serial display's RX line to digital pin 2 &#xA;SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused) &#xA;void setup() { &#xA;  mySerial.begin(9600); // set up serial port for 9600 baud &#xA;  delay(500); // wait for display to boot up &#xA;} &#xA;void loop() { &#xA;  mySerial.write(254); // move cursor to beginning of first line    &#xA;  mySerial.write(128); &#xA;  mySerial.write(&quot; &quot;); // clear display &#xA;  mySerial.write(&quot; &quot;); &#xA;  mySerial.write(254); // move cursor to beginning of first line &#xA;  mySerial.write(128); &#xA;  mySerial.write(&quot;movement recorded&quot;); &#xA;  while(1); // &#xA;  wait forever &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still tinkering with the suggested program from @Ariser shown below, but keep getting a compile error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tilt_lcd_ase.cpp: In function ‘void loop()’:&lt;br&gt;&#xA;tilt_lcd_ase.cpp:24:43: error: expected ‘)’ before ‘;’ token&lt;br&gt;&#xA;tilt_lcd_ase.cpp:25:43: error: expected ‘)’ before ‘;’ token  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done some research and one person had a similar problem, but it was within #include not void loop. The search continues, but if anyone has a suggestion please chime in. The liquid crystal library is also turning up similar errors but it needs a closer look.  &lt;/p&gt;&#xA;" OwnerUserId="4648" LastEditorUserId="4648" LastEditDate="2014-11-17T01:10:08.560" LastActivityDate="2014-11-20T16:47:07.107" Title="How to display tilt sensor data on an LCD?" Tags="|lcd|arduino-duemilanove|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4839" PostTypeId="2" ParentId="739" CreationDate="2014-11-02T22:18:41.553" Score="0" Body="&lt;p&gt;This happens to me.&#xA;In my case, I had upgraded the version of arduino and seems the preferences file was causing the problem.&#xA;Just delete ~/.arduino/preferences.txt file (with Arduino IDE closed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Close Arduino IDE&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;execute this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rm ~/.arduino/preferences.txt&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Launch Arduino IDE&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This worked for me, hope it works for someone else.&#xA;I am using Linux Mint 17 and I upgraded from Arduino 1.05 to Arduino 1.06 by extracting the Arduino IDE, I am not using the one in the repo.&#xA;(Of course, after adding your user to the corresponding group as mentioned by others, but if that wont help you try this)&lt;/p&gt;&#xA;" OwnerUserId="4649" LastActivityDate="2014-11-02T22:18:41.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4840" PostTypeId="2" ParentId="4837" CreationDate="2014-11-02T22:48:51.797" Score="0" Body="&lt;p&gt;The serial monitor cannot relay data from different peripheral unit in an arduino system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you have certain misconception of the hard and software. Your USB connection to the microcontroller on the arduino is just a trunk for a asynchronous serial transmission. In the past this was done via a RS-232 interface. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what is it, that you see in your serial monitor? That's just a bunch of characters sent by the microcontroller on your arduino. This data is sent from the microcontroller, because some piece of software fills the fifo of its serial interface. In fact, such commands are executed, when you call the method &quot;Serial.print()&quot;. Data gets then sent to your PC, Mac or whatever you are running your IDE on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now on the very same microcontroller the software for your tilt sensor is being executed. How could the serial monitor (which resides on your PC) route data from your tilt sensor to your LCD display? I'll tell you: It can't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In fact you could write a terminal script on your PC which reads data from serial and writes it back to the same interface, but it may cross your mind, that this might be a very big indirection)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what do you wanna accomplish? You want to put data read from a device connected to your Arduino to another device connected to your Arduino. So you better tell it the Arduino. The serial monitor will not be involved, hence you won't need any calls of Serial.print() to accomplish that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;To help you with that task, we need to see the code you have written so far. &lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok. first thing you need to know: You can't have two arduino sketches running simultaneously on your arduino. This is, because there is nothing like an operating system on your arduino which might provide a scheduler to run both programs. (If you want, look up scheduler on wiki, as it is very useful to know what you can't have)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need two pieces of code to run on the same microcontroller (the big black thing on your arduino) one doing the tilt sensor readings and the other printing data on your display. Hence you have to make one program out of two. To accomplish this, you have two problems to solve.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;you have to execute both code fragments alterantely, which, because the controller is fast enough, boils down to do both task &lt;em&gt;nearly&lt;/em&gt; simultaneously&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you have to bring the data which is acquired by code part 1 from the tilt sensor to code part 2 writing to the display. This is (for people into programming) rather simple as it simply has to be stored in a variable. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I recommend you to look up some programming basics at the arduino home page concerning the &quot;setup&quot; function and the &quot;loop&quot; function. But for now: You can have only one of each running on your arduino. Everything which is inside &quot;setup&quot; is executed only once after powerup. Everything which is inside &quot;loop&quot; is going to be executed over and over again consecutively (if nothing breaks).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your program might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; // Attach the serial display's RX line to digital pin 2 &#xA;SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused) &#xA;&#xA;char gl_senstr1[15];&#xA;char gl_senstr2[15];&#xA;&#xA;&#xA;void setup() { &#xA;  mySerial.begin(9600); // set up serial port for 9600 baud &#xA;  delay(500); // wait for display to boot up &#xA;} &#xA;&#xA;void loop() { &#xA;  mySerial.write(254); // move cursor to beginning of first line    &#xA;  mySerial.write(128); &#xA;  mySerial.write(&quot; &quot;); // clear display &#xA;  mySerial.write(&quot; &quot;); &#xA;  mySerial.write(254); // move cursor to beginning of first line &#xA;  mySerial.write(128); &#xA;  mySerial.write(&quot;movement recorded&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;      sprintf(gl_senstr1, &quot;%d&quot;, digitalRead(6); &lt;p&gt;&lt;/strike&gt;&#xA;&lt;strike&gt;      sprintf(gl_senstr2, &quot;%d&quot;, digitalRead(7); &lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  sprintf(gl_senstr1, &quot;%d&quot;, digitalRead(6)); &#xA;  sprintf(gl_senstr2, &quot;%d&quot;, digitalRead(7)); &#xA;&#xA;  mySerial.write(&quot;sensor1: &quot;);&#xA;  mySerial.write(gl_senstr1);&#xA;  mySerial.write(&quot; sensor2: &quot;);&#xA;  mySerial.write(gl_senstr2);&#xA;&#xA;   delay(250); // Wiat 1/4 second &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did not test it, because I neither own your display nor that sensor. But you can give it a try. You eventually have to dive into the art of programming if you want to accomlish little more than this. This is where the rubber meets the road. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2014-11-20T16:47:07.107" LastActivityDate="2014-11-20T16:47:07.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4841" PostTypeId="2" ParentId="4830" CreationDate="2014-11-03T04:05:27.073" Score="6" Body="&lt;p&gt;The best and easiest solution I've found is to use the Bluefruit EZ-Link from Adafruit.  They have a module you plug into the Serial/Power/reset pins (&lt;a href=&quot;http://www.adafruit.com/product/1588&quot;&gt;link here&lt;/a&gt;) or a shield for the uno (&lt;a href=&quot;http://www.adafruit.com/products/1628&quot;&gt;link here&lt;/a&gt;).  They've also got a great description and how-to guide (&lt;a href=&quot;https://learn.adafruit.com/introducing-bluefruit-ez-link/arduino-programming&quot;&gt;link here&lt;/a&gt;) that is pretty good.  It basically appears as a serial bluetooth link in the arduino IDE and you program it like normal.  It has the added benefit of being of use not only for programming, but also for sending and receiving data.&lt;/p&gt;&#xA;" OwnerUserId="3152" LastActivityDate="2014-11-03T04:05:27.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4842" PostTypeId="2" ParentId="4801" CreationDate="2014-11-03T05:21:10.590" Score="0" Body="&lt;p&gt;My first thought is that something else is off because there is no reason that shouldn't work.  It will of course only count 1/4 of the ticks since that's how it was designed to work for very fast motors.  I can't comment yet but to Gerben above, I think it is meant to be bidirectional as indicated by the ternary operator.  My guess is the problem is with the digitalReadFast library and I would be interested to know if this works when using digitalRead() instead.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second thought is that this is usually not the best way to do things.  Firstly, you would need a really fast motor for the read fast function to matter.  Secondly, you're sacrificing resolution by only using one interrupt instead of two.  The more generally accepted method is to attach both pins of the encoder to an interrupt.  Alternatively, you could use pin change interrupts which allow any pin to be used as an interrupt.  However, there are only 3 interrupt service routines on the Uno, one for each port of pins.  Whenever one pin on that port triggers, the ISR triggers and you need to keep track of the pin states in order to do anything with it.  Here's a good example of the &lt;a href=&quot;http://bildr.org/2012/08/rotary-encoder-arduino/&quot; rel=&quot;nofollow&quot;&gt;first&lt;/a&gt; and info on the &lt;a href=&quot;http://thewanderingengineer.com/2014/08/11/arduino-pin-change-interrupts/&quot; rel=&quot;nofollow&quot;&gt;second&lt;/a&gt; method.&lt;/p&gt;&#xA;" OwnerUserId="3152" LastActivityDate="2014-11-03T05:21:10.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4843" PostTypeId="1" AcceptedAnswerId="4850" CreationDate="2014-11-03T06:51:30.383" Score="1" ViewCount="146" Body="&lt;p&gt;So I made a program that controls two LED's when two buttons are pressed, but one of the LED's comes on when the button isn't pressed. And what's weird is that if I literally move around the breadboard the LED might turn off for a little, and if hold the button down while doing it the LED remains solid. I have done a lot of taking out and switching wires without any unexpected effects. However, if I switch the LED wires the other LED turns and stays on while the first one turns off, so I am pretty sure that it is a programming error. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin1 = 8;&#xA;const int buttonPin1 = 1;&#xA;const int ledPin2 = 9;&#xA;const int buttonPin2 = 2;&#xA;&#xA;int buttonState1 = 0;&#xA;int buttonState2 = 0;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(buttonPin1, INPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(buttonPin2, INPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;buttonState1 = digitalRead(buttonPin1);&#xA;buttonState2 = digitalRead(buttonPin2);&#xA;&#xA;  if (buttonState1 == LOW)&#xA;  {&#xA;    digitalWrite(ledPin1, HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(ledPin1, LOW); &#xA;  }&#xA;&#xA;  if (buttonState2 == LOW)&#xA;  {&#xA;    digitalWrite(ledPin2, HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(ledPin2, LOW); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4653" LastActivityDate="2014-11-04T21:52:13.490" Title="Led on when not supposed to be" Tags="|programming|led|button|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4844" PostTypeId="2" ParentId="4830" CreationDate="2014-11-03T08:04:58.197" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun?from=Products.ArduinoYUN&quot; rel=&quot;nofollow&quot;&gt;Arduino Yun&lt;/a&gt; can be remotely reflashed (either via wifi or network cable): you'll have to select its IP address under the &quot;Tools &gt; Boards&quot; menu of the Arduino IDE and then press the upload button as usual.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-11-03T08:04:58.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4848" PostTypeId="2" ParentId="4843" CreationDate="2014-11-03T10:08:20.343" Score="0" Body="&lt;p&gt;I don't think it is necessary to do the declaration of int buttonstate1 = 0; and int buttonstate2 = 0; seeing that in your loop the buttonstates gets read by you using digitalRead. Also I don't think the buttons is inverted, because you aren't using a pull up resistor if I'm correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this helped. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also something that I found helped a lot is that if you use a lastbuttonstate variable too. Than your if statement might look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonstate1 == HIGH &amp;amp;&amp;amp; previousbuttonstate1 == LOW)&#xA;{&#xA;digitalWrite(ledPin1, HIGH);&#xA;previousbuttonstate1 = buttonstate1;&#xA;}&#xA;&#xA;else if(buttonstate1 == HIGH &amp;amp;&amp;amp; previousbuttonstate1 == HIGH)&#xA;{&#xA;digitalWrite(ledPin1, HIGH);&#xA;}&#xA;&#xA;else if(buttonstate1 == LOW &amp;amp;&amp;amp; previousbuttonstate1 == HIGH)&#xA;{&#xA;digitalWrite(ledPin1, LOW);&#xA;previousbuttonstate1 = buttonstate1;&#xA;}&#xA;&#xA;else&#xA;{&#xA;digitalWrite(ledPin1, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically adding the previousbuttonstate1 just gives it a more accurate way of checking the button state(I'm typing under correction).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the sloppy answer, but hopefully it helps.&lt;/p&gt;&#xA;" OwnerUserId="4473" LastActivityDate="2014-11-03T10:08:20.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4849" PostTypeId="1" AcceptedAnswerId="4851" CreationDate="2014-11-03T10:20:09.437" Score="2" ViewCount="721" Body="&lt;p&gt;I'm trying to read a tachogenerator from a washing machine. It outputs an alternating current, with multiple periods per revolution. The voltage for my test case (constant rpm) reads 5.5V. I attached the tachogenerator to Digital 2 and GND and ran this sketch, just to see if a change is detected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;volatile int state = LOW;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);&#xA;  attachInterrupt(0, blink, RISING);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(ledPin, state);&#xA;  delay(500);&#xA;}&#xA;&#xA;void blink() {&#xA;  if (state == LOW) state != state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the LED does not light when I start the motor. When I measure the voltage while it is connected to the Arduino, it shows only about 0.7V, which would explain why the LED is not reacting. But why is this?&lt;/p&gt;&#xA;" OwnerUserId="4657" LastActivityDate="2014-11-03T10:44:15.397" Title="Reading a tachogenerator" Tags="|sensors|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4850" PostTypeId="2" ParentId="4843" CreationDate="2014-11-03T10:37:44.227" Score="5" Body="&lt;p&gt;The behavior you describe is symptomatic of a floating input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess you have directly wired your buttons between input pins and +5V (or GND, that won't change the observed behavior).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when you don't push the button, the input pin is left floating and can be read as HIGH or LOW based on strange factors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution to this is to use pullup (if you connect the other side of the button to GND) or pulldown (if your button is connected to +5V) resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following image, off the arduino website, shows such a circuit with a pulldown resistor, i.e. connect the switch to +5V and the resistor to GND:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://arduino.cc/en/uploads/Tutorial/button_schem.png&quot; alt=&quot;Pullup resistor example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An even simpler way is to connect the buttons to GND and use &lt;code&gt;pinMode(pin, INPUT_PULLUP);&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.347" LastActivityDate="2014-11-04T21:52:13.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4851" PostTypeId="2" ParentId="4849" CreationDate="2014-11-03T10:44:15.397" Score="3" Body="&lt;p&gt;There's an obvious code problem in your &lt;code&gt;blink()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;state != state;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above statement will never modify your state variable. The &lt;code&gt;!=&lt;/code&gt; operator in C/C++ does not perform an assignment (unlike operators such as &lt;code&gt;+=&lt;/code&gt; and &lt;code&gt;-=&lt;/code&gt;). It's a comparison operator which just tests for inequality. You presumably meant to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;state = !state;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That may not fix your problem entirely though. You might find that the interrupt doesn't get reliably triggered anyway because it's not designed to handle AC. I'd recommend using an external comparator circuit to generate a clean digital signal, such as a Schmitt trigger.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-03T10:44:15.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4853" PostTypeId="2" ParentId="4830" CreationDate="2014-11-03T14:49:55.573" Score="1" Body="&lt;p&gt;Yes, it can be done. Lowpowerlab.com has Moteino which can be programmed OTA. &lt;/p&gt;&#xA;" OwnerUserId="381" LastActivityDate="2014-11-03T14:49:55.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4854" PostTypeId="1" CreationDate="2014-11-03T13:17:20.047" Score="0" ViewCount="4037" Body="&lt;p&gt;I have a breadboard Arduino; made with ATMega328PU and a UART connector using a CT2102 breakout board. With the help of &lt;a href=&quot;http://startrobotics.blogspot.de/2013/05/how-to-use-ir-led-and-photodiode-with-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this site&lt;/a&gt; I created a simple IR sensor, now the problem is that in the Serial Monitor I'm getting a constant value of &lt;strong&gt;1023&lt;/strong&gt;. Even on removing the receiver (photodiode), the value's starts dropping like a capacitor discharges, and then stabilizes at some value (around 260-300). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When everything was working correctly, the value dropped to a sudden &lt;strong&gt;zero&lt;/strong&gt; on removing the receiver, but now it isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;robot&quot; was working perfectly and was reading the values correctly, but suddenly, the values dropped; we checked it and the Serial Monitor showed the same values. To check if the connections are working, I removed a wire from the Analog Pin of the Breadboard-Duino, and the values started to drop: like a periodic function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code was used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pd=2;                      //Photodiode to digital pin 2&#xA;int buzz=13;                   //piezo buzzer to digital pin 13  &#xA;int senRead=0;                 //Readings from sensor to analog pin 0  or A0&#xA;int limit=850 / 4;                 //Threshold range of an obstacle  &#xA;void setup()    &#xA;{  &#xA;  pinMode(pd,OUTPUT);  &#xA;  pinMode(buzz,OUTPUT);  &#xA;  digitalWrite(pd,HIGH);       //supply 5 volts to photodiode  &#xA;  digitalWrite(buzz,LOW);      //set the buzzer in off mode (initial condition)  &#xA;  Serial.begin(9600);          //setting serial monitor at a default baund rate of 9600  &#xA; }  &#xA;void loop()  &#xA;{  &#xA;  int val=analogRead(senRead) / 4;  //variable to store values from the photodiode  &#xA;  Serial.println(val);          // prints the values from the sensor in serial monitor  &#xA;  if(val &amp;lt;= limit)              //If obstacle is nearer than the Threshold range  &#xA;  {  &#xA;   digitalWrite(buzz,HIGH);     // Buzzer will be in ON state  &#xA;   delay(20);  &#xA;  }  &#xA;  else if(val &amp;gt; limit)          //If obstacle is not in Threshold range  &#xA;  {  &#xA;   digitalWrite(buzz,LOW);      //Buzzer will be in OFF state  &#xA;       delay(20);  &#xA;  }  &#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The phototransistor/diode is a standard 2pin component which came with the IR sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/24CLS.jpg&quot; alt=&quot;Image&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4670" OwnerDisplayName="user3102854" LastActivityDate="2017-10-21T02:52:33.517" Title="Arduino's Serial Monitor Showing Constant Value" Tags="|led|serial|uart|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4855" PostTypeId="2" ParentId="4854" CreationDate="2014-11-03T13:28:14.450" Score="1" Body="&lt;p&gt;In your initialisation where you declare each variable and 'connecting' them to a pin you make a mistake. Now you say that senRead is a digital pin instead of a analog pin. Change the value to A0 so you will get &lt;/p&gt;&#xA;&#xA;&lt;p&gt;int senRead = A0;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in your void Setup() you forget to declare your analog pin as an input. Add a pinMode command that sets senRead as an input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this doesn't fix your problem then it is probably hardware related. Check the connections on your breadboard will most of the times solve alot of problems. &lt;/p&gt;&#xA;" OwnerDisplayName="T J" LastActivityDate="2014-11-03T13:28:14.450" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4857" PostTypeId="1" AcceptedAnswerId="4859" CreationDate="2014-11-03T20:55:07.843" Score="2" ViewCount="1018" Body="&lt;p&gt;I have 16x16 LED matrix and I want to show some custom characters on it. I saw font made with array like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte zero[16] = { // Create byte array number 0&#xA;        B0111110,&#xA;        B1111111,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1100011,&#xA;        B1111111,&#xA;        B0111110&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I dont know how to parse it to x, y positions. Can someone help me? Do you know better way to store characters that is easily readable by human? Thanks&lt;/p&gt;&#xA;" OwnerUserId="4663" LastActivityDate="2014-11-03T22:35:57.807" Title="How to parse array to x,y positions?" Tags="|arduino-uno|programming|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4858" PostTypeId="2" ParentId="4857" CreationDate="2014-11-03T21:15:46.487" Score="0" Body="&lt;p&gt;Th example looks like the character '0', 8 bits wide and 16 bits high, though it could be the 16x8 due to '0's symmetry. Find the '2' array, for instance and plot the 1-bits on a piece of graph paper (even a hand-drawn grid will do). Once you should see the character shape you'll know how the bits/dots are arranged in the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your LED array has a square pitch (same spacing vertically and horizontally), 16-bit high characters may appear rather tall and skinny. If so, you could re-plot the characters to suit yourself. If you do decide to hand code them, look at your display hardware. It probably (but not necessarily) accepts 8 horizontally-adjacent bits at a time. But regardless, you can simplify your display code if one array-byte contains 8 bits that will be output at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--------- Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a lot missing from your question but I'll pick some assumptions to base an answer on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Y = array_index;&#xA;X = (6-bit_position) + (is_right_hand_character ? 8 : 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;based on assumptions that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you want the display coordinates of a given bit in the array;&lt;/li&gt;&#xA;&lt;li&gt;the origin (0,0) of your display is the upper left hand corner LED;&lt;/li&gt;&#xA;&lt;li&gt;the first character starts in column 0; the second in column 8; The&#xA;leftmost bit to display is in bit-6 of each byte and bit 7 (MSb) is&#xA;not used;&lt;/li&gt;&#xA;&lt;li&gt;you'll use zero-based coordinates.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The 'Y' coordinate is pretty straight-forward - byte-0 is the first byte.&#xA;The 'X' coordinate is found by subtracting the position of the bit of interest from 6, and maybe adding 8, since bit-6 goes into column-0 or column-8 for the left or right character, respectively.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-11-03T22:00:37.967" LastActivityDate="2014-11-03T22:00:37.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4859" PostTypeId="2" ParentId="4857" CreationDate="2014-11-03T21:52:08.203" Score="2" Body="&lt;p&gt;To get the value at a particular location, use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean val = zero[y] &amp;amp; ((B1 &amp;lt;&amp;lt; maxX) &amp;gt;&amp;gt; x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;y&lt;/code&gt; is the y position from 0 to &lt;code&gt;zero.length&lt;/code&gt;, &lt;code&gt;maxX&lt;/code&gt; is the length of the binary constants minus one (in this case, it would be 6), and &lt;code&gt;x&lt;/code&gt; is the x position from 0 to &lt;code&gt;maxX&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see &lt;a href=&quot;http://arduino.cc/en/Tutorial/BitMask&quot; rel=&quot;nofollow&quot;&gt;BitMask&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="37" LastEditorUserId="37" LastEditDate="2014-11-03T22:35:57.807" LastActivityDate="2014-11-03T22:35:57.807" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4861" PostTypeId="1" CreationDate="2014-11-03T23:02:18.890" Score="1" ViewCount="949" Body="&lt;p&gt;I've heard about a alternative Arduino IDE called &lt;a href=&quot;https://github.com/aporto/mariamole&quot; rel=&quot;nofollow&quot;&gt;MariaMole&lt;/a&gt; and really liked the idea, but I just don't know how to install it on Mac OS X. The &lt;a href=&quot;https://github.com/aporto/mariamole&quot; rel=&quot;nofollow&quot;&gt;GitHub page&lt;/a&gt; claims that it is compatible with Mac but I just can't find a tutorial, or instructions, as to how the Git files can be compiled on Mac.&lt;/p&gt;&#xA;" OwnerUserId="4666" LastEditorUserId="6936" LastEditDate="2015-03-16T13:28:11.403" LastActivityDate="2015-03-16T13:28:11.403" Title="Installing MariaMole (Alternative IDE) on Mac" Tags="|ide|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4862" PostTypeId="1" AcceptedAnswerId="4865" CreationDate="2014-11-04T01:33:43.410" Score="1" ViewCount="5131" Body="&lt;p&gt;I'm having trouble adding attachInterrupt in a library that I am creating. I researched a lot, and I noticed that this is a common mistake, but do not quite understand the answers I found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error in question is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_nov04a.ino: In function 'void setup()':&#xA;sketch_nov04a:10: error: argument of type 'void (Teste::)()' does not match 'void (*)()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My library is as follows: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Teste.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef TESTE_H&#xA;#define TESTE_H&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class Teste&#xA;{&#xA;public:&#xA;    volatile long lastWindIRQ;&#xA;    volatile byte windClicks;&#xA;&#xA;  void wspeedIRQ();&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Teste.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Teste.h&quot;&#xA;&#xA;void Teste::wspeedIRQ()&#xA;{&#xA;  if (millis() - this.lastWindIRQ &amp;gt; 10)&#xA;  {&#xA;    this.lastWindIRQ = millis();&#xA;    this.windClicks++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;my implementation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Teste.h&amp;gt;&#xA;&#xA;Teste teste;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(2, INPUT);&#xA;  digitalWrite(2, HIGH);&#xA;  attachInterrupt(0, teste.wspeedIRQ, FALLING);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(teste.windClicks);&#xA;  delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Updated the error and corrected the problem cited by Ignacio&lt;/p&gt;&#xA;" OwnerUserId="3837" LastEditorUserId="3837" LastEditDate="2014-11-04T09:41:38.777" LastActivityDate="2017-09-18T09:18:29.747" Title="AttachInterrupt in a library" Tags="|arduino-uno|library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4864" PostTypeId="1" CreationDate="2014-11-04T06:35:54.433" Score="2" ViewCount="481" Body="&lt;p&gt;I have a fio v3 + a 9DOF sensor hooked up to an XBEE. On another UNO board, I have a GSM shield and another XBEE board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fiov3 is supposed to sample data from the sensor, send it through the xbee. The receiving XBEE will then receive and pass the data to the UNO. The UNo then activates the GSM shield on condition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However my resulting output on the UNO is as shown :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ThE8h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data received is corrupted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE ON UNO.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*****************************************************************&#xA;XBee_Serial_Passthrough.ino&#xA;&#xA;Set up a software serial port to pass data between an XBee Shield&#xA;and the serial monitor.&#xA;&#xA;Hardware Hookup:&#xA;  The XBee Shield makes all of the connections you'll need&#xA;  between Arduino and XBee. If you have the shield make&#xA;  sure the SWITCH IS IN THE &quot;DLINE&quot; POSITION. That will connect&#xA;  the XBee's DOUT and DIN pins to Arduino pins 2 and 3.&#xA;*****************************************************************/&#xA;// We'll use SoftwareSerial to communicate with the XBee:&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)&#xA;// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)&#xA;SoftwareSerial XBee(2, 3); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  // Set up both ports at 9600 baud. This value is most important&#xA;  // for the XBee. Make sure the baud rate matches the config&#xA;  // setting of your XBee.&#xA;  XBee.begin(9600);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial.available())&#xA;  { // If data comes in from serial monitor, send it out to XBee&#xA;    XBee.write(Serial.read());&#xA;  }&#xA;  if (XBee.available())&#xA;  { // If data comes in from XBee, send it out to serial monitor&#xA;    Serial.write(XBee.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;CODE ON FIOV3.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt; // Included for SFE_LSM9DS0 library&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SFE_LSM9DS0.h&amp;gt;&#xA;&#xA;#define LSM9DS0_XM  0x1D // Would be 0x1E if SDO_XM is LOW&#xA;#define LSM9DS0_G   0x6B // Would be 0x6A if SDO_G is LOW&#xA;// Create an instance of the LSM9DS0 library called `dof` the&#xA;// parameters for this constructor are:&#xA;// [SPI or I2C Mode declaration], [gyro I2C address], [xm I2C address]&#xA;LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM);&#xA;&#xA;const byte INT1XM = 4; // INT1XM tells us when accel data is ready&#xA;//const byte INT2XM = 8; // INT2XM tells us when mag data is ready&#xA;//const byte DRDYG = 7;  // DRDYG tells us when gyro data is ready&#xA;const int buttonPin = 15;     // the number of the pushbutton pin&#xA;&#xA;&#xA;int buttonState = 0;    &#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(INT1XM, INPUT);&#xA;  //pinMode(INT2XM, INPUT);&#xA;  // pinMode(DRDYG, INPUT);&#xA;  pinMode(buttonPin, INPUT);  &#xA;&#xA;  dof.setAccelODR(dof.A_ODR_1600);&#xA;  dof.setAccelScale(dof.A_SCALE_16G);&#xA;&#xA;  Serial.begin(115200); // Start serial at 115200 bps&#xA;  Serial1.begin(9600); &#xA;  // Use the begin() function to initialize the LSM9DS0 library.&#xA;  // You can either call it with no parameters (the easy way):&#xA;&#xA;  uint16_t status = dof.begin();&#xA;  // Or call it with declarations for sensor scales and data rates:  &#xA;  //uint16_t status = dof.begin(dof.G_SCALE_2000DPS, dof.A_SCALE_6G, dof.M_SCALE_2GS);&#xA;&#xA;  // begin() returns a 16-bit value which includes both the gyro and&#xA;  // accelerometers WHO_AM_I response. You can check this to make sure&#xA;  // communication was successful.&#xA;  // Serial.println(status, HEX);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  //Serial1.println(&quot;Hello!&quot;); &#xA;&#xA;   buttonState = digitalRead(buttonPin);&#xA;&#xA;  if (buttonState == 1) {   &#xA;&#xA;    //  Serial1.println(&quot;Hello!&quot;); &#xA;&#xA;  printAccel();&#xA;  }&#xA;&#xA;  //if (Serial1.available()){&#xA;     // Serial.write(Serial1.read());&#xA;//  }&#xA;&#xA;}&#xA;&#xA;void printAccel()&#xA;{&#xA;  // Only read from the accelerometer if the accel interrupts,&#xA;  // which means that new data is ready.&#xA;  if (digitalRead(INT1XM))&#xA;  {&#xA;    // Use the readAccel() function to get new data from the accel.&#xA;    // After calling this function, new values will be stored in&#xA;    // the ax, ay, and az variables.&#xA;    dof.readAccel();&#xA;&#xA;    Serial.print(&quot;A: &quot;);&#xA;&#xA;    // Using the calcAccel helper function, we can get the&#xA;    // accelerometer readings in g's.&#xA;    Serial.print(dof.calcAccel(dof.ax));&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(dof.calcAccel(dof.ay));&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.println(dof.calcAccel(dof.az));&#xA;&#xA;&#xA;    Serial1.print(&quot;A: &quot;);&#xA;&#xA;    // Using the calcAccel helper function, we can get the&#xA;    // accelerometer readings in g's.&#xA;    Serial1.print(dof.calcAccel(dof.ax));&#xA;    Serial1.print(&quot;, &quot;);&#xA;    Serial1.print(dof.calcAccel(dof.ay));&#xA;    Serial1.print(&quot;, &quot;);&#xA;    Serial1.println(dof.calcAccel(dof.az));&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea how to mitigate this would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastEditorUserId="3210" LastEditDate="2014-11-04T13:37:00.107" LastActivityDate="2014-11-04T13:37:00.107" Title="Garbled data output from sensor through XBEE?" Tags="|arduino-uno|serial|gsm|xbee|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4865" PostTypeId="2" ParentId="4862" CreationDate="2014-11-04T10:16:20.960" Score="4" Body="&lt;p&gt;The problem is that &lt;code&gt;wspeedIRQ()&lt;/code&gt; is a member function (i.e. it's part of the &lt;code&gt;Teste&lt;/code&gt; class), but &lt;code&gt;attachInterrupt()&lt;/code&gt; expects a non-member function (i.e. a function which is static and/or not part of a class at all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a very important distinction in C++ because it affects how the compiler calls the function behind-the-scenes. There is unfortunately no way to use a member function directly with &lt;code&gt;attachInterrupt()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Various workarounds are possible though. The simplest is to write a wrapper function which calls the member function. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Teste teste;&#xA;&#xA;// This is a non-member function...&#xA;void isr()&#xA;{&#xA;    // ...which calls the member function:&#xA;    teste.wspeedIRQ();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    //...&#xA;&#xA;    // Setup interrupt to use a non-member function&#xA;    attachInterrupt(0, isr, FALLING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, your implementation of &lt;code&gt;wspeedIRQ()&lt;/code&gt; won't compile at the moment anyway. The reason is that &lt;code&gt;this.&lt;/code&gt; is invalid. It's a pointer so the correct syntax is &lt;code&gt;this-&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In practice, you usually don't need to use &lt;code&gt;this&lt;/code&gt; to access member data. C++ figures it out automatically, unless there's a naming conflict.)&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-04T10:16:20.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4868" PostTypeId="2" ParentId="4801" CreationDate="2014-11-04T12:36:59.017" Score="0" Body="&lt;p&gt;OK embarrassingly it turns out my wiring was wrong! I was going astray as it was working in both directions as described, even when only one of the outputs was connected, as long output B was connected to an interrupt. Once the wiring was sorted everything worked perfectly, in both directions, using just one of the interrupt ports.&lt;/p&gt;&#xA;" OwnerUserId="4612" LastActivityDate="2014-11-04T12:36:59.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4870" PostTypeId="2" ParentId="4861" CreationDate="2014-11-04T18:44:36.877" Score="0" Body="&lt;p&gt;For mac its not yet released (&lt;a href=&quot;http://dalpix.com/mariamole-download&quot; rel=&quot;nofollow&quot;&gt;See website&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To try the experimental mac version, you'll have to compile it yourself with the code found on that github repository you linked to &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-04T18:44:36.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4871" PostTypeId="1" AcceptedAnswerId="4872" CreationDate="2014-11-04T19:35:51.860" Score="0" ViewCount="7086" Body="&lt;p&gt;As the title suggests, I have many &quot;expected `)' before ';' token&quot; errors. The issue is, I have this stuff in. So now I am confused, why am I getting this if the things are there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new here and had an issue with adding code, so here is the pastebin link to it: &lt;a href=&quot;http://pastebin.com/4WXxsXkB&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/4WXxsXkB&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the the pastebin link to the error:&#xA;&lt;a href=&quot;http://pastebin.com/QyehP86M&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/QyehP86M&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone understand how this could happen?&lt;/p&gt;&#xA;" OwnerUserId="4509" LastActivityDate="2014-11-05T17:32:52.413" Title="Many &quot;expected `)' before ';' token&quot; errors" Tags="|programming|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4872" PostTypeId="2" ParentId="4871" CreationDate="2014-11-04T19:41:41.047" Score="5" Body="&lt;p&gt;You have two #define statements at the top of your code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin 3; &#xA;#define echoPin 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way &lt;code&gt;#define&lt;/code&gt; works is that it replaces every instance of the name with everything after it on the line so &lt;code&gt;trigPin&lt;/code&gt; is being replaced with &lt;code&gt;3;&lt;/code&gt; as opposed to &lt;code&gt;3&lt;/code&gt; as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixing this should solve some of your problems.&lt;/p&gt;&#xA;" OwnerUserId="3818" LastEditorUserId="3866" LastEditDate="2014-11-05T17:32:52.413" LastActivityDate="2014-11-05T17:32:52.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4875" PostTypeId="1" AcceptedAnswerId="6842" CreationDate="2014-11-05T01:04:35.323" Score="0" ViewCount="753" Body="&lt;p&gt;I have a project that require for the main computer to do most of the processing then for it to send the X and Y coordinates of this processing to the arduino. This at the time didn't seem very hard but now that I have started to dive into serial some more I am completely confused. All of the example I have seen for serial only consist of 1 set of numbers and rather confusing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino code I kinda want to go like this&#xA;&lt;a href=&quot;http://pastebin.com/aLJfEExw&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/aLJfEExw&lt;/a&gt; (I know this is probably completely wrong but I am pretty lost right now)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Python code is this right now &#xA;&lt;a href=&quot;http://pastebin.com/4aN4dnSC&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/4aN4dnSC&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you guys could help explain this better for me it would be amazing. I understand that my code is probably wrong. So if you guys could provide an example of how to send the two different sets of int's it would be amazing. Because I am completely and utterly lost.  &lt;/p&gt;&#xA;" OwnerUserId="3693" LastEditorUserId="11529" LastEditDate="2016-03-21T11:40:19.227" LastActivityDate="2016-03-21T11:40:37.040" Title="How to send two different sets of int numbers over serial?" Tags="|serial|python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4877" PostTypeId="1" CreationDate="2014-11-05T02:33:05.583" Score="2" ViewCount="6484" Body="&lt;p&gt;I have two Arduinos, a nano and a mega. I want to output 16 bit PWM, but can seem to only get it working on the nano. I'm adapting the code from this website: &lt;a href=&quot;http://www.ofrecordings.com/2014/03/16/how-to-set-up-16-bit-pwm-with-an-arduino-uno-atmega328/&quot; rel=&quot;nofollow&quot;&gt;http://www.ofrecordings.com/2014/03/16/how-to-set-up-16-bit-pwm-with-an-arduino-uno-atmega328/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Set PB1/2 as outputs.&#xA;  DDRB |= (1 &amp;lt;&amp;lt; DDB1) | (1 &amp;lt;&amp;lt; DDB2);&#xA;&#xA;  TCCR1A =&#xA;      (1 &amp;lt;&amp;lt; COM1A1) | (1 &amp;lt;&amp;lt; COM1B1) |&#xA;      // Fast PWM mode.&#xA;      (1 &amp;lt;&amp;lt; WGM11);&#xA;  TCCR1B =&#xA;      // Fast PWM mode.&#xA;      (1 &amp;lt;&amp;lt; WGM12) | (1 &amp;lt;&amp;lt; WGM13) |&#xA;      // No clock prescaling (fastest possible&#xA;      // freq).&#xA;      (1 &amp;lt;&amp;lt; CS10);&#xA;  OCR1A = 0;&#xA;  // Set the counter value that corresponds to&#xA;  // full duty cycle. For 15-bit PWM use&#xA;  // 0x7fff, etc. A lower value for ICR1 will&#xA;  // allow a faster PWM frequency.&#xA;  ICR1 = 0xffff;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Use OCR1A and OCR1B to control the PWM&#xA;  // duty cycle. Duty cycle = OCR1A / ICR1.&#xA;  // OCR1A controls PWM on pin 9 (PORTB1).&#xA;  // OCR1B controls PWM on pin 10 (PORTB2).&#xA;  OCR1A = 0x0000;&#xA;  delay(500);&#xA;  OCR1A = 0x8000;&#xA;  delay(500);&#xA;  OCR1A = 0xffff;&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That code works on the nano, but not on the mega. I expect that it output PWM on pins 11 and 12, but no luck. Care to explain how I can get it working? It's an entirely different microprocessor, and I'm not sure which parts of the code to change.&lt;/p&gt;&#xA;" OwnerUserId="4581" OwnerDisplayName="user1637451" LastEditorUserId="84" LastEditDate="2014-11-05T04:21:58.180" LastActivityDate="2014-12-08T08:30:37.460" Title="16 bit PWM on a mega" Tags="|pwm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4878" PostTypeId="2" ParentId="4877" CreationDate="2014-11-05T02:51:16.747" Score="0" Body="&lt;p&gt;According to this chart:&#xA;&lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping2560&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/PinMapping2560&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mega does not support PWM on those digital pins. It looks like 14 of the 54 pins do, use the chart to find which pins to use.&lt;/p&gt;&#xA;" OwnerDisplayName="Jarrod Christman" LastActivityDate="2014-11-05T02:51:16.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4879" PostTypeId="2" ParentId="4875" CreationDate="2014-11-05T03:15:38.010" Score="2" Body="&lt;p&gt;I looked at your code, but the main problem seems to be that you have not defined the problem, and it is thus not possible to definitively answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The conventional solution to this would be to send 2 numbers with separator (usually space) followed by a newline. I know Arduino does not have an inbuilt function to do this, but you could write one. &lt;a href=&quot;http://arduino.cc/en/Tutorial/SerialEvent&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/SerialEvent&lt;/a&gt; shows one way this could be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to send bytes (how long is each number? I would guess 16 bits) so you would send 4 bytes and on reception assemble them into 2 16 bit integers. Whether you need to ensure the data is synchronised depends on your problem. If you are sending continuous data this is essential, and you could use the kind of compelled sequence signalling you seem to be implying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the code it looks like you are sending from a Raspberry Pi. If I were doing this I would probably use I²C (at least over a short distance).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="2902" LastEditDate="2016-03-21T11:40:37.040" LastActivityDate="2016-03-21T11:40:37.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4880" PostTypeId="2" ParentId="4740" CreationDate="2014-11-05T04:35:12.270" Score="1" Body="&lt;p&gt;Even though an answer has been accepted, I just want to add for future viewers that you can google for arduino breadboard internal oscillator and get the text to copy into the boards.txt file.  That will allow you to use the Arduino IDE to burn the fuses.  You will be able to find versions to run at both 8mhz and 1mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you have an extra Uno laying around, you could always pop the chip in there and reset the fuses, then take it out and use it on a breadboard.&lt;/p&gt;&#xA;" OwnerUserId="3152" LastActivityDate="2014-11-05T04:35:12.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4881" PostTypeId="1" AcceptedAnswerId="4905" CreationDate="2014-11-05T09:39:14.707" Score="0" ViewCount="1310" Body="&lt;p&gt;I have an RFID reader: &lt;a href=&quot;http://img.tradeindia.com/fp/1/641/264.jpg&quot; rel=&quot;nofollow&quot;&gt;http://img.tradeindia.com/fp/1/641/264.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like above along with ITEAD TFT shield &amp;amp; GSM Modem. The RFID reader has an RS-232 port as well as GND, TX and 5V pins. I am using an Arduino Mega 2560 board. I have connected the TX, GND of RFID reader to RX3 pin 15 / GND (pin) of Arduino. Note I am supplying 12 V to RFID via an adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the ITEAD TFT shield consumes the TX0, RX0 pins—so I cannot make use of the RX0 and TX0 pins. Though I have not written the code for GSM modem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now while running the program below, I am getting junk output both in my TFT display as well as the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define __AVR__&#xA;#include &amp;lt;UTFT.h&amp;gt;&#xA;&#xA;// Declare which fonts we will be using&#xA;extern uint8_t SmallFont[];&#xA;extern uint8_t BigFont[];&#xA;extern uint8_t SevenSegNumFont[];&#xA;UTFT myGLCD(ITDB24,59,58,57,56);&#xA;String myString = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;   Serial3.begin(9600);&#xA;   myGLCD.InitLCD();&#xA;   myGLCD.clrScr();&#xA;}&#xA;&#xA;void loop() {&#xA;  myGLCD.setFont(BigFont);&#xA;  if (Serial3.available()) {&#xA;    int inByte = Serial3.read();&#xA;     myString += String(inByte);&#xA;    }&#xA;    if(myString.length() == 10)&#xA;      myGLCD.print(myString, CENTER, 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;TFT Screen output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1310494848&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial Monitor Output: non printable junk character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value is incorrect, I am pretty sure, what am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that the ITEAD shield is sending or rather using RX0/TX0 pins very frequently—some data is going through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW what is the functionality of &lt;a href=&quot;http://arduino.cc/en/Tutorial/SoftwareSerialExample&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/SoftwareSerialExample&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use 3 different Serial I/Os individually at the same time without disturbing any other I/O?&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="37" LastEditDate="2014-11-07T13:34:02.410" LastActivityDate="2014-11-25T13:57:02.383" Title="Arduino Mega 2560 RFID Serial Communication" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4883" PostTypeId="2" ParentId="4795" CreationDate="2014-11-05T11:36:06.423" Score="2" Body="&lt;p&gt;You can increase the frequency (x10) by setting S0 HIGH and S1 LOW. Then you can change the timerone frequency from once a second to once every 100ms (Timer1.setPeriod(100000);). Then you can change your delay to delay(400). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I think you only need to wait for a bit over 3 timerone cycles, so delay(350) should also work.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-05T11:36:06.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4884" PostTypeId="1" AcceptedAnswerId="4885" CreationDate="2014-11-05T08:39:36.003" Score="0" ViewCount="495" Body="&lt;p&gt;I made arduino-stack which consists of arduino r3, robotdf motor shild and robotdf lcd shield. But motor shield and lcd use same pins 4 and 5, so we have a conflict of pins. Can i use other pins?&lt;/p&gt;&#xA;" OwnerUserId="4692" OwnerDisplayName="user2500581" LastActivityDate="2014-11-05T11:36:42.807" Title="Stack arduino, motor shield and lcd shield" Tags="|motor|lcd|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4885" PostTypeId="2" ParentId="4884" CreationDate="2014-11-05T09:40:40.323" Score="0" Body="&lt;p&gt;Stack one shield on top of the Arduino itself and connect the other shield using wires. This way you can pick your own pin assignment for the 'external' shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful when using a specific library though, sometimes the used pins are hard-coded in the library itself. Modifying the .h and .cpp files for the library is possible, so you could (hard code) assign your own used pins.&lt;/p&gt;&#xA;" OwnerUserId="4710" OwnerDisplayName="Mr Jones" LastActivityDate="2014-11-05T09:40:40.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4886" PostTypeId="1" CreationDate="2014-11-05T16:45:53.050" Score="2" ViewCount="604" Body="&lt;p&gt;I want to use an arduino &lt;strong&gt;duemilanove atmega168&lt;/strong&gt; for audio signal processing. I can sample the signal at around 38.5kHz using &lt;a href=&quot;http://www.instructables.com/id/Arduino-Audio-Input/step6/Sampling-rate-of-40kHz/&quot; rel=&quot;nofollow&quot;&gt;this code&lt;/a&gt;. I want to send the sampled data over the serial to a computer for processing.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Data acquisition rate: 38.5 kbps (using 8-bit precision)&lt;/li&gt;&#xA;&lt;li&gt;Maximum serial communication rate: 115200 bps (I don't know exactly how this relates to the transfer rate of the actual data (without any overheads), but anyhow the limit is 13.94 kbps)&lt;/li&gt;&#xA;&lt;li&gt;Arduino flash memory: 16 kB  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would like to transmit around 4-5 seconds of the audio signal to the computer. Is there a way to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="4690" LastEditorUserId="4690" LastEditDate="2014-11-05T17:09:16.183" LastActivityDate="2015-02-03T22:30:44.983" Title="High frequency audio sampling and storage" Tags="|serial|audio|signal-processing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4887" PostTypeId="2" ParentId="4886" CreationDate="2014-11-05T19:38:12.737" Score="3" Body="&lt;p&gt;After doing some reading here &lt;a href=&quot;https://arduino.stackexchange.com/questions/4071/serial-begin-why-not-always-use-28800?rq=1&quot;&gt;Serial.begin(): Why not always use 28800?&lt;/a&gt; and looking at the manual for the 168. You should be able to achieve the baud rate you want by directly programming the USAR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the answer there you should be able to use miniterm to keep up with a high baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As stated there you might run into problems with computer power. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read chapter 20 here &lt;a href=&quot;http://www.atmel.com/images/doc2545.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.atmel.com/images/doc2545.pdf&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you can set up the USART speed (UDR0) and the control registers (UCSR0A,UCSR0B and UCSR0C) such that you can send data pretty fast. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if you can't access that link and if you need me to explain some more about these things.&lt;/p&gt;&#xA;" OwnerUserId="3818" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-11-05T19:38:12.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4888" PostTypeId="2" ParentId="4718" CreationDate="2014-11-05T20:01:49.427" Score="1" Body="&lt;p&gt;I have not done extensive testing with the simulator but here is what you do open code blocks start a new project. Then under the target choose simulator. See the picture for details. &lt;img src=&quot;https://i.stack.imgur.com/P1EUX.png&quot; alt=&quot;Image of Code Blocks&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just tested it out for the simple program but this looks pretty cool.&lt;/p&gt;&#xA;" OwnerUserId="3818" LastActivityDate="2014-11-05T20:01:49.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4889" PostTypeId="1" AcceptedAnswerId="4892" CreationDate="2014-11-06T02:39:18.020" Score="0" ViewCount="4678" Body="&lt;p&gt;Using Arduino Uno with 3.5mm Jack connected to ground and pin 1 for TX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need to send two commands&#xA;I want to send &#xA;0XAA13FE010113 for Mute on, and &#xA;0XAA13FE010012 for Mute off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple Serial Command to turn Monitor Mute on and off every 5 seconds....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tried everything byte character, array, write with hex, print :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx for a helping a rookie &#xA;I want to impress my team &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Ideal quick answer below. thx to @martynas &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t muteON[] = { 0xAA, 0x13, 0xFE, 0x01, 0x01, 0x13 };&#xA;uint8_t muteOFF[] = { 0xAA, 0x13, 0xFE, 0x01, 0x00, 0x12 };&#xA;.... &#xA;void loop() {&#xA; Serial.write( muteON, sizeof(muteON) );  &#xA; delay(5000);               // wait for 5 second&#xA; Serial.write( muteOFF, sizeof(muteOFF) );&#xA; delay(5000);               // wait for 5 second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4695" LastEditorUserId="4695" LastEditDate="2014-11-14T08:47:40.923" LastActivityDate="2014-11-14T08:47:40.923" Title="Sending Serial Hex Command from Pin 1 (Tx)" Tags="|arduino-uno|serial|programming|sketch|" AnswerCount="1" CommentCount="2" ClosedDate="2014-11-06T17:32:40.310" ContentLicense="CC BY-SA 3.0" />
  <row Id="4891" PostTypeId="1" CreationDate="2014-11-06T06:56:44.683" Score="0" ViewCount="1357" Body="&lt;p&gt;How would I establish a serial connection with python without using the serial monitor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is give my python script some input and have the arduino do something (blink for example)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to be able to read in data with the arduino to give it to my python script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What modules for python would be useful? I'm just starting out and don't have much of an idea for this one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a windows7 machine with python 2.7.6 and have an UNO board and a Leonardo board that I want to be able to use. &lt;/p&gt;&#xA;" OwnerUserId="4699" LastActivityDate="2014-11-06T08:23:27.090" Title="How would I establish a serial connection with python without using the serial monitor?" Tags="|arduino-uno|serial|arduino-leonardo|python|" AnswerCount="1" CommentCount="3" ClosedDate="2014-11-06T17:31:34.757" ContentLicense="CC BY-SA 3.0" />
  <row Id="4892" PostTypeId="2" ParentId="4889" CreationDate="2014-11-06T06:56:57.833" Score="1" Body="&lt;p&gt;there are 6 bytes just make &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte muteON[] = {0xAA,0x13,0xFE,0x01,0x01,0x13};&#xA;byte muteOFF[] = {0XAA,0x13,0xFE,0x01,0x00,0x12};&#xA;...&#xA;/* To send mute ON comand */&#xA;for(byte i =0;i&amp;lt;sizeof(muteON);i++)(Serial.write(muteON[i]));&#xA;/* To send mute OFF comand */&#xA;for(byte i =0;i&amp;lt;sizeof(muteOFF);i++)(Serial.write(muteOFF[i]));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-11-06T06:56:57.833" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4893" PostTypeId="2" ParentId="4891" CreationDate="2014-11-06T08:23:27.090" Score="1" Body="&lt;p&gt;This question is about &lt;strong&gt;Python&lt;/strong&gt; not Arduino... Before asking here please ask &lt;strong&gt;GOOGLE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the answer &lt;a href=&quot;http://www.instructables.com/id/Arduino-and-Python/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;Arduino and Python&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;## import the serial library&#xA;import serial&#xA;&#xA;## Boolean variable that will represent &#xA;## whether or not the arduino is connected&#xA;connected = False&#xA;&#xA;## open the serial port that your ardiono &#xA;## is connected to.&#xA;ser = serial.Serial(&quot;COM11&quot;, 9600)&#xA;&#xA;## loop until the arduino tells us it is ready&#xA;while not connected:&#xA;    serin = ser.read()&#xA;    connected = True&#xA;&#xA;## Tell the arduino to blink!&#xA;ser.write(&quot;1&quot;)&#xA;&#xA;## Wait until the arduino tells us it &#xA;## is finished blinking&#xA;while ser.read() == '1':&#xA;    ser.read()&#xA;&#xA;## close the port and end the program&#xA;ser.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Open a serial connection and flash LED when input is received&#xA;&#xA;void setup(){&#xA;  // Open serial connection.&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.write('1'); &#xA;}&#xA;&#xA;void loop(){ &#xA;  if(Serial.available() &amp;gt; 0){      // if data present, blink&#xA;    digitalWrite(13, HIGH);&#xA;    delay(500);            &#xA;    digitalWrite(13, LOW);&#xA;    delay(500); &#xA;    digitalWrite(13, HIGH);&#xA;    delay(500);            &#xA;    digitalWrite(13, LOW);&#xA;    Serial.write('0');&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-11-06T08:23:27.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4894" PostTypeId="2" ParentId="3667" CreationDate="2014-11-06T08:43:40.413" Score="1" Body="&lt;p&gt;I switched to a different ATTINY 13 driver and core definition in the Arduino IDE and this made it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately by playing around I lost track of the old driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now using smeezkekitty's core13 which I found here: &lt;a href=&quot;http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/&quot; rel=&quot;nofollow&quot;&gt;http://elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3488" LastActivityDate="2014-11-06T08:43:40.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4896" PostTypeId="1" AcceptedAnswerId="4917" CreationDate="2014-11-06T12:18:19.433" Score="2" ViewCount="2846" Body="&lt;p&gt;I'm really at my wits end. For a couple of hours I have been programming a custom board that uses everything as on the Arduino Leonardo. A few hours ago I am not able to upload anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   avrdude: error: buffered memory access not supported. &#xA;   Maybe it isn't a butterfly/AVR109 but a AVR910 device?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried everything from re-installing the IDE, re-installing the board in Device Manager, changing the COM Port. I really just don't know anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some more data that might be relevant or useful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     Using Port                     :\\.\COM6 &#xA;     Using Programmer              : avr109&#xA;     Overriding Baud Rate          : 57600&#xA;     AVR Part                      : ATmega32U4&#xA;     Chip Erase delay              : 9000 us&#xA;     PAGEL                         : PD7&#xA;     BS2                           : PA0&#xA;     RESET disposition             : dedicated&#xA;     RETRY pulse                   : SCK&#xA;     serial program mode           : yes&#xA;     parallel program mode         : yes&#xA;     Timeout                       : 200&#xA;     StabDelay                     : 100&#xA;     CmdexeDelay                   : 25&#xA;     SyncLoops                     : 32&#xA;     ByteDelay                     : 0&#xA;     PollIndex                     : 3&#xA;     PollValue                     : 0x53&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[EDIT]&#xA;I've now checked the battery (yes with a multimeter), it is fully charged, as it charges when the USB is connected. I've also tried a different computer, along with a different USB cable. &lt;/p&gt;&#xA;" OwnerUserId="2904" LastEditorUserId="2904" LastEditDate="2014-11-06T15:53:57.530" LastActivityDate="2014-11-08T08:04:21.410" Title="Unable to upload sketch to Leonardo" Tags="|uploading|arduino-leonardo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4900" PostTypeId="1" CreationDate="2014-11-06T16:01:36.717" Score="9" ViewCount="1039" Body="&lt;p&gt;Consider the following minimal example, where I set &lt;code&gt;pinMode&lt;/code&gt; before calling SPI functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  pinMode(10, OUTPUT);&#xA;  SPI.begin(10);&#xA;  SPI.setDataMode(10,SPI_MODE1);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(1000);&#xA;  SPI.transfer(10,1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when &lt;code&gt;SPI.transfer(10,1)&lt;/code&gt; is called in &lt;code&gt;loop()&lt;/code&gt;, I always see that the slave selected pin goes down to 1.65V, but not 0 as it should! (see image below)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oAruY.jpg&quot; alt=&quot;pin mode set before calling SPI functions&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we don't call &lt;code&gt;pinMode()&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  SPI.begin(10);&#xA;  SPI.setDataMode(10,SPI_MODE1);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(1000);&#xA;  SPI.transfer(10,1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We get what we would expect when calling &lt;code&gt;SPI.transfer&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wxn6b.jpg&quot; alt=&quot;pin Mode not set&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that a bug or do you have an explanation for that behaviour? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much in advance for your time and interest!&lt;/p&gt;&#xA;" OwnerUserId="3309" LastEditorUserId="4628" LastEditDate="2015-11-29T21:38:10.643" LastActivityDate="2015-12-29T21:46:15.990" Title="SPI Arduino Due conflict with pinMode(), bug?" Tags="|arduino-due|spi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4901" PostTypeId="1" CreationDate="2014-11-06T20:13:12.847" Score="1" ViewCount="1016" Body="&lt;p&gt;I heard that Servo library cannot send and receive from other arduinos without inturrupting the timer and messing up the motors. SoftwareServo is supposedly the answer to this. Is this true? Neither libraries are working for this problem at the moment.&lt;/p&gt;&#xA;" OwnerUserId="4705" LastActivityDate="2015-05-06T04:11:51.397" Title="Servo limitations vs SoftwareServo" Tags="|servo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4902" PostTypeId="2" ParentId="4901" CreationDate="2014-11-06T21:01:41.170" Score="1" Body="&lt;p&gt;I'm not sure which SoftwareServo library you are talking about, but with regards to the built in &quot;Servo.h&quot;, no, it will not disrupt the arduino's other communication abilities, and they will not disrupt it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used servos simultaneously with Serial, I2C, and SPI before and never had any problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo library does use a timer, but it will only conflict with an external library or code that uses the same timer. Which timer it uses depends on the board, just look in libraries/Servo/src/avr/ServoTimers.h to see which it uses, in what order as they fill up. Filling one up takes effort though, by default it puts up to 12 servos on each timer. The processing overhead is very low since they only update at 50Hz, so that will not become a problem.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-11-07T00:58:21.813" LastActivityDate="2014-11-07T00:58:21.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4903" PostTypeId="2" ParentId="3680" CreationDate="2014-11-07T01:17:57.573" Score="1" Body="&lt;p&gt;I'd be mighty tempted to identify some other way, like having the sketch itself respond to a special identify command, just to avoid USB's odd ways of identifying devices.&lt;/p&gt;&#xA;" OwnerUserId="168" LastActivityDate="2014-11-07T01:17:57.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4904" PostTypeId="1" CreationDate="2014-11-07T07:47:34.897" Score="2" ViewCount="1045" Body="&lt;p&gt;I am looking to have an Arduino UNO stack with a GSM Shield and an XBEE shield for wireless communication. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since the GSM Shield requires digital pins 2 and 3, I would have to reroute the RX/TX of the XBee to another digital pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried changing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial XBee(2, 3); // RX, TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to other values, but this does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about doing this?&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2014-11-07T07:47:34.897" Title="Change XBee shield TX/RX Software serial?" Tags="|arduino-uno|gsm|xbee|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4905" PostTypeId="2" ParentId="4881" CreationDate="2014-11-07T09:44:44.703" Score="1" Body="&lt;p&gt;First of all, try testing 1 functionality at a time to isolate the issue.&#xA;Now you do not know if the LCD is not working correctly, or if the serial communication with the RFID module is not working correctly. Connect it to a computer and test both independently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When getting gibberish from a serial line, usually it means the baudrate doesn't match. Both devices have to send the same amount of bits per seconds in order to communicate with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the Arduino example to test 2 serial lines (for Arduino Mega) at the same time: &lt;a href=&quot;http://arduino.cc/en/Tutorial/MultiSerialMega&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/MultiSerialMega&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4710" LastActivityDate="2014-11-07T09:44:44.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4906" PostTypeId="1" CreationDate="2014-11-07T11:28:53.770" Score="16" ViewCount="39833" Body="&lt;p&gt;I'd like to know the differences between these two boards: &lt;a href=&quot;https://www.sparkfun.com/products/11113&quot; rel=&quot;noreferrer&quot;&gt;Arduino Pro Mini&lt;/a&gt; and &lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;noreferrer&quot;&gt;Arduino Pro Micro&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I've read &lt;a href=&quot;https://electronics.stackexchange.com/questions/96805/how-to-program-arduino-nano-pro-mini-pro-micro-clone-that-has-no-usb-port&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://www.sparkfun.com/arduino_guide&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; related post, it is not clear enough. I've always used the Arduino Uno or Leonardo and I'm a little bit scared of using these compact miniaturised boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen so far those differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Micro doesn’t need the separate FTDI, while the Mini does&lt;/li&gt;&#xA;&lt;li&gt;The Micro takes more time to boot up due to USB device (keyboard/mouse) emulation (is more like a Leonardo than an Uno)&lt;/li&gt;&#xA;&lt;li&gt;They both have 5 V and 3.3 V versions&lt;/li&gt;&#xA;&lt;li&gt;The Mini has 2 more digital IO and 2 more analog Inputs (1 more PWM)&lt;/li&gt;&#xA;&lt;li&gt;The pinout is the same (a shield designed for the Pro Mini is OK also with Pro Micro)&lt;/li&gt;&#xA;&lt;li&gt;Micro is more expensive (IF you don't have already an FTDI cable).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, what I care about most is the boot up time (because it could make debug harder) but other than that.. if I don't need the 2 more Digital IO and the 2 more Analog Inputs.. why buy one over the other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And some more question: can I use the Mini boot loader inside the Micro to avoid the boot up time (if I do not need the keyboard/mouse emulation)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the power consumption the same? Can I use the same battery?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if this is a silly question but I'm little bit confused.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="19409" LastEditDate="2017-11-29T23:00:09.057" LastActivityDate="2017-11-29T23:29:33.963" Title="All the differences between Arduinos: Pro Mini &amp; Pro Micro" Tags="|arduino-pro-mini|arduino-pro-micro|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4907" PostTypeId="2" ParentId="4906" CreationDate="2014-11-07T13:15:54.590" Score="14" Body="&lt;p&gt;It is more the differences between ATMega328P + FTDI (Pro Mini) vs ATMega32u4 (Pro Micro)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from the minor pin differences, the peripherals for both MCUs are the same. The major difference is the ATMega32u4 has built in full-speed USB. This allows the board to function as a USB device by implementing the appropriate USB stack. E.g. it can act as a&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB to serial converter (CDC device)&lt;/li&gt;&#xA;&lt;li&gt;Keyboard or mouse (HID device)&lt;/li&gt;&#xA;&lt;li&gt;USB hard drive (MSC device)&lt;/li&gt;&#xA;&lt;li&gt;MIDI controller&lt;/li&gt;&#xA;&lt;li&gt;and more...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The LUFA library from AVR devices can be used for this but means going outside of the Arduino IDE and compiling proper C code using the latest avr-gcc tools. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino core library has built-in support for the HID and CDC device profiles. The CDC profile is used for comms with the Leonardo, Micro, etc. while the HID profile is used for keyboard / mouse emulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Leonardo / Micro boot loader implements a CDC profile for communications with the PC. This CDC profile uses Arduino vendor and product ids so unlike FTDI devices, requires an extra step to install an &lt;code&gt;*.inf&lt;/code&gt; file on Windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to recompile the Pro Mini bootloader for the Micro, but even then it would require an FTDI board as programming would need to be done via the TX and RX UART pins. If you we going to go to all that trouble you could just recompile the proper boot loader to have a shorter time out. Why is difference of 1 or 2 seconds in boot loader time important?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATMega32u4 uses more power than the ATMega328P.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-11-07T13:15:54.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4908" PostTypeId="1" CreationDate="2014-11-07T13:36:18.710" Score="0" ViewCount="349" Body="&lt;p&gt;I have an Arduino board with a sensor, an OLED screen and an XBee module. I've setup the timer interrupts in timer1 to sample the sensor every one second. &#xA;I've done the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tried to update the OLED screen with the reading and it works. &lt;/li&gt;&#xA;&lt;li&gt;tried sending the reading from inside loop over XBee and it works.&lt;/li&gt;&#xA;&lt;li&gt;tried doing both of the above and the Arduino seems to shut down after a bit.&lt;/li&gt;&#xA;&lt;li&gt;tried sending the reading from inside the timer interrupt handler and it doesn't work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are there limitations on what interrupt handlers can do that I'm not aware of? (Other than using time delays)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Source code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;Adafruit_SSD1306.h&amp;gt;&#xA;&#xA;XBee xbee = XBee();&#xA;ZBRxResponse response = ZBRxResponse();&#xA;ZBTxRequest sensorml_level_0_zbTx = ZBTxRequest(addr64, sensorml_payload_level_0,sizeof(sensorml_payload_level_0));&#xA;ZBTxRequest keepalive_level_0_zbTx = ZBTxRequest(addr64, keepalive_payload_level_0,sizeof(keepalive_payload_level_0));&#xA;&#xA;union u_tag {&#xA;   uint8_t b[4];&#xA;   float fval;&#xA;} &#xA;u;&#xA;&#xA;void setup() {&#xA;   display.begin(SSD1306_SWITCHCAPVCC);&#xA;   Serial.begin(9600);&#xA;   xbee.setSerial(Serial);&#xA;   noInterrupts();&#xA;   TCCR1A = 0;&#xA;   TCCR1B = 0;&#xA;   TCNT1  = 0;&#xA;   OCR1A = 62500;&#xA;   TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;   TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;   TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;   TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;   interrupts();&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect){&#xA;   reading =  analogRead(SENSORPIN);&#xA;   reading = (1023 / reading)  - 1;&#xA;   reading = SERIESRESISTOR / reading;&#xA;   reading = -0.15784 * reading + 305.17;&#xA;   sendObservation(reading,00);&#xA;}&#xA;&#xA;void sendObservation(float value, int id){&#xA;   char idBuffer[] = &quot;00&quot;;&#xA;   sprintf(idBuffer,&quot;%02d&quot;,id);&#xA;   uint8_t frame[] = {'0','1','|','0','0','#','0','0','0','0'};&#xA;   frame[3] = idBuffer[0];&#xA;   frame[4] = idBuffer[1];&#xA;   u.fval = value;&#xA;   for (int i=6;i&amp;lt;10;i++){&#xA;      frame[i]=u.b[i-6];&#xA;   }&#xA;   ZBTxRequest request = ZBTxRequest(addr64, frame, sizeof(frame));&#xA;   xbee.send(request);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I skipped most variable declarations to keep the code short.&lt;/p&gt;&#xA;" OwnerUserId="4713" LastEditorUserId="37" LastEditDate="2014-11-07T14:02:43.877" LastActivityDate="2015-11-03T03:37:35.853" Title="Using XBee and OLED screens with Timer Interrupts" Tags="|arduino-mega|xbee|interrupt|timers|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4909" PostTypeId="2" ParentId="4908" CreationDate="2014-11-07T14:53:36.883" Score="1" Body="&lt;p&gt;I suspect &lt;code&gt;send()&lt;/code&gt; is blocking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;XBee::send()&lt;/code&gt; calls &lt;code&gt;_serial-&amp;gt;flush()&lt;/code&gt; (see &lt;a href=&quot;https://code.google.com/p/xbee-arduino/source/browse/XBee.cpp#1461&quot; rel=&quot;nofollow&quot;&gt;code&lt;/a&gt;). &lt;code&gt;Serial.write()&lt;/code&gt; buffers data to be written, sets &lt;code&gt;transmitting = true&lt;/code&gt;, clears &lt;code&gt;TXC0&lt;/code&gt; and enables the USART data register empty (DRE) interrupt. Bytes will be sent out when the DRE interrupt triggers. However, since you are currently in interrupt context, this will not happen until your ISR returns. &lt;code&gt;flush()&lt;/code&gt; spins until &lt;code&gt;TXC0&lt;/code&gt; is set, but since the DRE interrupt never triggers, it spins infinitely. I am basing this on &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/HardwareSerial.cpp#L455&quot; rel=&quot;nofollow&quot;&gt;this code&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4715" LastActivityDate="2014-11-07T14:53:36.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4910" PostTypeId="2" ParentId="4479" CreationDate="2014-11-07T22:10:02.810" Score="1" Body="&lt;p&gt;Firstly, let's look into documentation for &lt;a href=&quot;http://www.rubydoc.info/stdlib/core/IO:gets&quot; rel=&quot;nofollow&quot;&gt;Ruby IO#gets&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reads the next &quot;line&quot; from the I/O stream; lines are separated by sep ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Secondly, look into documentation for &lt;a href=&quot;http://arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial.print&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Prints data to the serial port as human-readable ASCII text ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Finally, you don't print new line char &lt;code&gt;\n&lt;/code&gt; in your &quot;arduino sketch&quot; above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you to use &lt;code&gt;Serial.println&lt;/code&gt; in the last line from your sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  // ... do some gyro stuff here&#xA;}&#xA;&#xA;void loop() {&#xA;  gyro.read();&#xA;&#xA;  Serial.print((int)gyro.g.x);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print((int)gyro.g.y);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.println((int)gyro.g.z);&#xA;&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4568" LastActivityDate="2014-11-07T22:10:02.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4912" PostTypeId="2" ParentId="3680" CreationDate="2014-11-08T00:32:48.593" Score="5" Body="&lt;p&gt;You can add an alias for each. Then you know which is which. Here is a nice &lt;a href=&quot;http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt; on how to set this up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a snippet that I wrote based on the tutorial. In the below example, I am using a FTDI RS232RL USB to Serial adapter, which I believe is what the Arduino uses too. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In order to assign an alias to a USB-Serial device, we need to find some info on the device&lt;/li&gt;&#xA;&lt;li&gt;Plug in the usb. This assumes you have already install the drivers for this use be device and the device is visible when typing:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;lsusb&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;We are going to need the following&#xA;a.    The vendor id&#xA;b.    The product id&#xA;c.    The device serial number&lt;/li&gt;&#xA;&lt;li&gt;To do this, it takes a little bit of hunting. All your devices log entries in '/var/log/messages'. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Therefore we can read this file and find the correct USB:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;grep &quot;ftdi&quot; /var/log/messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &quot;usb&quot;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;This is find all messages tagged with ftdi:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Next to ftdi_sio, there is a number like 1-1.2. This is the USB device&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;grep &quot;usb 1-1.2&quot; /var/log/messages&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dmesg | grep &quot;usb 1-1.3&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;7&quot;&gt;&#xA;&lt;li&gt;This gives us all the info we need:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/D0LTA.png&quot; alt=&quot;USB Alias&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;8&quot;&gt;&#xA;&lt;li&gt;Now with the list of serial numbers in hand let’s create a UDEV ruleset that’ll make a nice symbolic link for each of these devices. UDEV rules are usually scattered into many files in /etc/udev/rules.d. Create a new file called 99-usb-serial.rules and put the following lines in there:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this example my alias is called 'lcdbox'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEM==&quot;tty&quot;, ATTRS{idVendor}==&quot;0403&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{serial}==&quot;A601ERJJ&quot;, SYMLINK+=&quot;lcdbox&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;9&quot;&gt;&#xA;&lt;li&gt;SYMLINK is the name of your alias. In this case my alias is lcdbox.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Save the file and type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sudo udevadm control --reload-rules&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ls –l /dev/lcdbox&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;lrwxrwxrwx 1 root root 7 Jan  1  1970 /dev/lcdbox -&gt; ttyUSB0&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;12&quot;&gt;&#xA;&lt;li&gt;This shows that my lcdbox alias is mapped to ttyUSB0&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2014-11-08T00:39:45.997" LastActivityDate="2014-11-08T00:39:45.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4913" PostTypeId="1" AcceptedAnswerId="4920" CreationDate="2014-11-08T04:17:10.630" Score="0" ViewCount="513" Body="&lt;p&gt;I plan on purchasing &lt;a href=&quot;http://www.ebay.com/itm/3PCS-Nano-V3-0-ATmega328-controller-Board-5V-16M-CH340G-USB-Driver-For-Arduino-/381019048475?pt=LH_DefaultDomain_0&amp;amp;hash=item58b6814a1b&quot; rel=&quot;nofollow&quot;&gt;a Nano clone&lt;/a&gt;, an Ethernet shield &lt;a href=&quot;http://www.ebay.com/itm/New-ENC28J60-Ethernet-LAN-Network-Module-For-Arduino-SPI-AVR-PIC-LPC-STM32-BDRG-/301354703227?pt=LH_DefaultDomain_0&amp;amp;hash=item462a23d97b&quot; rel=&quot;nofollow&quot;&gt;(ENC28J60)&lt;/a&gt;, an LCD and a DHT22 humidity + temperature sensor. This will be used in a wine cellar to monitor relative humidity and temperature. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DHT sensor, LCD and Nano all operate on 5V logic. The Ethernet shield does not operate at 5V, but rather at 3.3V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the Nano have a way to connect the two, will they work anyway (probably not), or should I use a CD4050 that is recommended on adafruit? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance is appreciated; I'm still amazed in what $10 in parts can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in regards to the DHT22 sensor, what do I need in terms of a resistor? I've seen some people say you absolutely need a 4.7K resistor on the data pin for &quot;pull up&quot;, and  others who say it's unnecessary. Can someone give a definite answer, either way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit, wrong link on my nano clone.&lt;/p&gt;&#xA;" OwnerUserId="4722" LastEditorUserId="84" LastEditDate="2014-11-08T06:29:23.500" LastActivityDate="2014-11-08T15:09:18.443" Title="Arduino Nano and a 3.3v Ethernet shield" Tags="|sensors|shields|lcd|arduino-nano|ethernet|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4914" PostTypeId="1" CreationDate="2014-11-08T05:23:26.013" Score="0" ViewCount="3698" Body="&lt;p&gt;I'm using an Arduino pro mini to receive the analog signals from three sensors. I was wondering what sampling rate I should sample at in order to properly represent these signals. I know it should be twice the highest analog frequency, but I'm not sure what frequency theses sensors operate in. They're an ECG, a 3 axis accelerometer, and a stretch resistor respectively. To my knowledge, Arduino defaults at a sampling rate of 10kHz, which I believe should be more than enough to quantize the sensor signals. I'm then sending these signals out using bluetooth mate to an android phone. Is there a specific baudrate I should send the data at? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the initialization of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  bluetooth.begin(115200);&#xA;  bluetooth.print(&quot;$$$&quot;);&#xA;  delay(100);&#xA;  bluetooth.println(&quot;U,9600,N&quot;);&#xA;  bluetooth.begin(9600);&#xA;  setTime(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks so much&lt;/p&gt;&#xA;" OwnerUserId="4723" LastEditorUserId="84" LastEditDate="2014-11-08T06:26:14.150" LastActivityDate="2015-05-19T01:34:48.410" Title="Necessary sampling rate" Tags="|programming|sensors|bluetooth|arduino-pro-mini|signal-processing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4915" PostTypeId="1" CreationDate="2014-11-08T05:25:40.717" Score="2" ViewCount="365" Body="&lt;p&gt;SparkFun sells an FM Tuner Board (&lt;a href=&quot;https://www.sparkfun.com/products/11083&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) and provides code to work it.  However, neither libraries that I found in other places, nor the example code that they provided, worked.  I have checked the wiring multiple times and I am nearly certain that the fault is in the code but I can't find it.  Thanks...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ECC&lt;/p&gt;&#xA;" OwnerUserId="4281" LastActivityDate="2015-10-23T18:05:33.863" Title="Attaching an Si4703 to an Arduino" Tags="|arduino-uno|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4917" PostTypeId="2" ParentId="4896" CreationDate="2014-11-08T08:04:21.410" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First: you must find the COMx used for your &quot;Arduino Leonardo&quot; in the &quot;Device Manager&quot; of Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second: make double click to see the properties of the device, and go to the &quot;Port configuration tab&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third: enter in &quot;Avanced Options&quot; and deactivate &quot;Use FIFO buffers&quot;, and accept all changes.&lt;/p&gt;&#xA;" OwnerUserId="3772" LastActivityDate="2014-11-08T08:04:21.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4918" PostTypeId="2" ParentId="1160" CreationDate="2014-11-08T11:59:41.000" Score="3" Body="&lt;p&gt;Easiest way I've found to do this purely from the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -f /dev/cu.usbmodemfa121 1200;stty stop /dev/cu.usbmodemfa121;./bossac -i -d --port=tty.usbmodemfa121 -U false -e -w -v -b Blink.cpp.bin -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Swap out the serial device for whatever /dev you are using; in Linux you may have to sudo to get direct access to the device.&#xA;This is assuming you are in the directory where bossac lives and your .bin file is there too. Adjust to suit your needs.&#xA;If using the native USB port you should change -U to &lt;em&gt;true&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4727" LastActivityDate="2014-11-08T11:59:41.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4919" PostTypeId="1" CreationDate="2014-11-08T14:59:27.670" Score="6" ViewCount="9058" Body="&lt;p&gt;The &lt;a href=&quot;http://www.ti.com/product/ads1256&quot;&gt;ADS1256 chip&lt;/a&gt; is a high precision 24bit, 8 channel, analog digital converter based on SPI communication that is suitable for biomedical applications and perfect for sensing ECG and EEG signals. I want to hook it up to an arduino, e.g., an arduino mega or an arduino due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar ADCs from analog devices are: ADS1248, ADS1251, ADS1252, ADS1252U, ADS1253, ADS1255, ADS1259, ADS1278, ADS1298, ADS1299, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It’s nice that there are [tiny, coin sized breakout boards]  available for the ADS1256 that include basic components like an 8mhz quartz crystal and cost only around 25 USD.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several people have in the past struggled to get ADC readings using Arduino. Working only with the data sheet it took them several days or even weeks. I have a logic analyzer, multi channel oscilloscope and &lt;a href=&quot;http://dangerousprototypes.com/docs/Bus_Pirate&quot;&gt;bus pirate&lt;/a&gt; ready, but I still would prefer adapting an existing library or working with a good tutorial as a starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched for code and tutorial not only for the ADS1256 but also for similar analog devices ADC chips. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the tutorials, libraries and information I found so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Main Links (working solution):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- &lt;a href=&quot;http://arduino.cc/forum/index.php?action=dlattach;topic=53063.0;attach=15873&quot;&gt;ADS1213 Arduino library&lt;/a&gt; (seems to be working!!!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--  &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=q3dffkh8l0t6i89mljk3fcj603&amp;amp;topic=53063.0&quot;&gt;ADS1213 Arduino tutorial&lt;/a&gt; (includes above library)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Further Information:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/adamfeuer/ADS129x-tools&quot;&gt;Arduino due ADS129X tools(ADS1299, ADS1298, ADS1294, ADS1296)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=57873.0&quot;&gt;ADS1252 Arduino Tutorial&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/272825.aspx&quot;&gt;ADS1252 Troubleshooting information&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/272825.aspx&quot;&gt;ADS1255 Troubleshooting information&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/168648.aspx&quot;&gt;ADS 1298 Troubleshooting information&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.mikrocontroller.net/topic/302404&quot;&gt;ADS 1248 and arduino (german)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt;&lt;br&gt;&#xA;Is there a working library for the ADS1256 (or similar chip) and is there a current, up-to-date tutorial available for arduino?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(Update with my notes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Next steps&lt;/strong&gt; (to get a working library that should be put on github):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Search for more relevant Information online (existing libraries, etc.)&lt;/li&gt;&#xA;&lt;li&gt;Ask in AVR specific forum, if question is unanswered here. Possibly contact people via e-mail that could know more &lt;/li&gt;&#xA;&lt;li&gt;Get familiar with Chip and Datasheet&lt;/li&gt;&#xA;&lt;li&gt;Decide on available codebase as the starting point&lt;/li&gt;&#xA;&lt;li&gt;Define the minimalistic testcase (This would check that some for of communication works with the chip, i.e., write register that changes the logic level of a bin of the ADC chip)&lt;/li&gt;&#xA;&lt;li&gt;Implement the minimalistic testcase (i.e., possibly use different codebase as starting point if it fails to implement)&lt;/li&gt;&#xA;&lt;li&gt;Expand and test the code to get a full implementation &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Risks:&lt;/strong&gt; Eittle experience with electronic design the microcontroller at hand, might miss important details that costs a lot of time. Can't be sure that my chip/PCB actually works, can be faulty hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Time Estimate&lt;/strong&gt;: 3 days of work doing 8 hours a day (total 24 hours). Exremly high variance (could be a matter of a few hours in the best case to a few weeks worst case).&lt;/p&gt;&#xA;" OwnerUserId="4728" LastEditorUserId="4728" LastEditDate="2014-11-09T22:22:49.773" LastActivityDate="2016-02-04T21:48:18.580" Title="References (e.g, libraries and tutorials) for connecting the 24-bit ADS1256 ADC to arduino" Tags="|serial|arduino-mega|arduino-due|spi|analogread|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4920" PostTypeId="2" ParentId="4913" CreationDate="2014-11-08T15:09:18.443" Score="0" Body="&lt;p&gt;Just get &lt;a href=&quot;http://www.ebay.com/itm/3-3V-5V-ENC28J60-LAN-Ethernet-Network-Module-Dual-MOS-For-Arduino-MCU-AVR-51-LPC-/171310795997?pt=LH_DefaultDomain_0&amp;amp;hash=item27e2eb4cdd&quot; rel=&quot;nofollow&quot;&gt;one with a 3.3v regulator on it&lt;/a&gt;. PS logic levels are allowed to be 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DHT22 and LCD will also work fine on 3.3v so, alternatively, you could also get a 3.3v Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistor value for the DHT22 depends on the length of wire between the DHT and Nano. Just buy them to be sure, or get a breakout board that already has them on the board (along with a capacitor, which is nice).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-08T15:09:18.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4921" PostTypeId="2" ParentId="1585" CreationDate="2014-11-08T15:42:15.913" Score="3" Body="&lt;p&gt;I solved this problem by connecting &lt;strong&gt;DTR&lt;/strong&gt; signal from USB-converter to the pin which says &lt;strong&gt;GRN&lt;/strong&gt; on the board (the one aside TXD). It was not obvious to find, but seen on ebay some arduino-dedicated-usb-programmer which seemed to be connected this way - so I took the chance. I do not get this error anymore and uploading works every time!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="4729" LastActivityDate="2014-11-08T15:42:15.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4922" PostTypeId="2" ParentId="4095" CreationDate="2014-11-08T16:01:13.770" Score="2" Body="&lt;p&gt;The 2 values SERVOMIN and SERVOMAX define the pulse length, which tells the servo what angle to go to.  The example uses 150 for SERVOMIN and 600 for SERVOMAX.  When running the code, the servos travel 180 deg.  I changed the code to read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SERVOMIN  262 // this is the 'minimum' pulse length count (out of 4096)&#xA;#define SERVOMAX  488 // this is the 'maximum' pulse length count (out of 4096)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the servo now moved only 90 deg. centered at the same place as the original code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the tutorial provided by Adafruit describes a way to define the movement by angle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;found here:  &lt;a href=&quot;https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hope this helps&lt;/p&gt;&#xA;" OwnerUserId="4730" LastActivityDate="2014-11-08T16:01:13.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4923" PostTypeId="1" CreationDate="2014-11-08T19:27:17.943" Score="0" ViewCount="768" Body="&lt;p&gt;Is it possible to use more than 1 device that needs to use SDA for I2C with a mini?&#xA;Would you use a different analogue pin with a 10k pull up resistor and tie all of the devices to the SCL?&lt;/p&gt;&#xA;" OwnerUserId="4731" LastActivityDate="2014-11-08T19:34:40.993" Title="Connect multiple I2C to an Uno" Tags="|i2c|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4924" PostTypeId="2" ParentId="4923" CreationDate="2014-11-08T19:34:40.993" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to use more than 1 device that needs to use SDA for I2C with a mini?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, provided they have unique I&lt;sup&gt;2&lt;/sup&gt;C addresses.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Would you use a different analogue pin with a 10k pull up resistor and tie all of the devices to the SCL?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. All of the devices must be tied to both SDA and SCL. You may need a smaller resistor depending on how many devices there are; see NXP document UM10204 for details.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-08T19:34:40.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4925" PostTypeId="1" CreationDate="2014-11-08T22:24:54.770" Score="7" ViewCount="10215" Body="&lt;p&gt;I bought a Sainsmart LCD2004 from Amazon to use with my Arduino Uno.&#xA;I understand that since this LCD uses I2C a new library needs to be downloaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the sainsmart website I dowloaded the LCD 2004 rar&#xA;&lt;a href=&quot;http://www.sainsmart.com/arduino/arduino-shields/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html&quot;&gt;http://www.sainsmart.com/arduino/arduino-shields/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to compile the example titled helloworld I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;In file included from HelloWorld.pde:3:&#xA;C:\Users\r_yob_000\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:81: error: conflicting return type specified for 'virtual void LiquidCrystal_I2C::write(uint8_t)'&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seems to be a conflict between two functions returning different types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried searching the issue and found a lot of posts with similar errors.&#xA;The solution suggested is usually that a new version of the LiquidCrytal_I2C needs to downloaded. Or that one should use Arduino IDE version 1.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have downloaded tons of LiquidCrytal_I2C libraries and tried them all on IDE version 1.0 and 1.0.6 and I still get the same error message. I've even tried changing the LiquidCrytal_I2C.h file so that it returns the correct type and still have no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I please get some help with this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerDisplayName="Caesar" LastActivityDate="2018-09-03T12:22:57.230" Title="Sainsmart LCD 2004 - LiquidCrytal_I2C library issue unable to compile" Tags="|i2c|lcd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4927" PostTypeId="1" CreationDate="2014-11-09T13:00:10.567" Score="0" ViewCount="4531" Body="&lt;p&gt;I have Arduino UNO with 0.96&quot; OLED display with 128(width)*32(height). It is said that I have to edit Adafruit_SSD1306.h for my 128*32 OLED, okey I did it from 128*64 to 128*32 but I still get the compiler error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssd1306_128x32_i2c.ino:54:2: error: #error (&quot;Height incorrect, please&#xA;fix Adafruit_SSD1306.h!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes, I fixed the Adafruit_SSD1306.h file, &lt;strong&gt;but now,&lt;/strong&gt; it is still gives me a compiler error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\OB\Documents\Arduino\libraries\Wire\utility/twi.h: In member&#xA;function 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)':&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\utility/twi.h:47: error:&#xA;too many arguments to function 'uint8_t twi_readFrom(uint8_t,&#xA;uint8_t*, uint8_t)'&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\Wire.cpp:85: error: at&#xA;this point in file&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\utility/twi.h: In member&#xA;function 'uint8_t TwoWire::endTransmission(uint8_t)':&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\utility/twi.h:48: error:&#xA;too many arguments to function 'uint8_t twi_writeTo(uint8_t, uint8_t*,&#xA;uint8_t, uint8_t)'&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\Wire.cpp:140: error: at&#xA;this point in file&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\Wire.cpp: In member&#xA;function 'virtual size_t TwoWire::write(const uint8_t*, size_t)':&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\Wire.cpp:195: error:&#xA;invalid conversion from 'const uint8_t*' to 'uint8_t*'&#xA;C:\Users\OB\Documents\Arduino\libraries\Wire\Wire.cpp:195: error:  &#xA;initializing argument 1 of 'uint8_t twi_transmit(uint8_t*, uint8_t)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/A6Wbj.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/zAblZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use my four-pin OLED display with no errors?&lt;/p&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="10794" LastEditDate="2016-02-13T21:25:41.327" LastActivityDate="2016-07-13T01:58:36.433" Title="0.96&quot; OLED and Arduino UNO usage error" Tags="|arduino-uno|arduino-ide|compile|display|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="4928" PostTypeId="1" CreationDate="2014-11-09T14:31:27.267" Score="0" ViewCount="165" Body="&lt;p&gt;The best way to explain my problem is in form of code...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    const int ringerPin = A0;&#xA;    const int offhook = A4;&#xA;    const int onhook = A5;&#xA;&#xA;    void setup(){&#xA;    pinMode(ringerPin, OUTPUT);&#xA;    pinMode(offhook, INPUT);&#xA;    pinMode(onhook, INPUT);&#xA;    randomSeed(analogRead(0));&#xA;&#xA;  }&#xA;&#xA;  int randCall = random(60000, 3600000); // generate a random number between 1 min and 60 min&#xA;&#xA;//ring every 1 to 60 minutes if the phone is down (hookon) and dont ring if the phone is picked up (no hookon)&#xA;void loop()&#xA;{&#xA;  if (digitalRead(hookon) == HIGH)&#xA;&#xA;void loop(){&#xA;delay(randCall);&#xA;&#xA;      //i dont know how to let this loop below here run for 30 seconds.&#xA; void loop()&#xA;    {&#xA;      //turn audio off - i dont know how to.&#xA;    for(int x = 0; x &amp;lt; 15; x++){&#xA;      digitalWrite(ringerPin, HIGH);   &#xA;      delay(50);                           &#xA;      digitalWrite(ringerPin, LOW);   &#xA;      delay(80); &#xA;    }&#xA;    delay(2500);&#xA;    }&#xA;  else&#xA;    //play one randomly choosen audiofile out of 10 - i dont know how to&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe you can give me some suggestions to my coding problems.?&#xA;I wrote them inside the code descriptions.&lt;/p&gt;&#xA;" OwnerUserId="4738" LastActivityDate="2016-05-06T01:50:55.633" Title="Lily Pad mp3, nested loops with timing and play randomly choosen mp3, coding problem" Tags="|programming|sketch|timing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4929" PostTypeId="1" CreationDate="2014-11-09T14:48:39.377" Score="2" ViewCount="926" Body="&lt;p&gt;I would just like to start off by saying that I am new to Arduino so my code and approach to the wanted outcome are probably not the best. Anyway, I had the idea of using an ultrasonic sensor and my hand to act as a potentiometer to control the position of a servo. So, I wired everything up and wrote the code but the Servo just jitters around and doesn't move the way I wanted it to. The serial readings are fine, it is just that the servo isn't responding the way I hoped. Here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo\Servo.h&amp;gt;&#xA;#define echoPin 7&#xA;#define trigPin 8&#xA;&#xA;int maximumRange = 400;&#xA;int minimumRange = 0;&#xA;int angle;&#xA;long duration, distance;&#xA;Servo myServo;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(echoPin, INPUT);&#xA;    pinMode(trigPin, OUTPUT);&#xA;    myServo.attach(9);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(trigPin, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(trigPin, HIGH);&#xA;    delayMicroseconds(10);&#xA;&#xA;    digitalWrite(trigPin, LOW);&#xA;    duration = pulseIn(echoPin, HIGH);&#xA;&#xA;    distance = duration / 58.2;&#xA;&#xA;    angle = map(distance, minimumRange, maximumRange, 0, 179);&#xA;    Serial.print(&quot;Distance = &quot;);&#xA;    Serial.print(distance);&#xA;    Serial.print(&quot; Angle = &quot;);&#xA;    Serial.println(angle);&#xA;    myServo.write(angle);&#xA;    delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If anyone can help, it would be appreciated if you could post what is wrong with my code and how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;Note: I'm using Visual Studio instead of the Arduino IDE, so that is why it says #include &lt;code&gt;&amp;lt;Servo\Servo.h&amp;gt;&lt;/code&gt; at the top.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4740" LastEditorUserId="37" LastEditDate="2014-11-10T12:44:01.410" LastActivityDate="2014-11-10T12:44:01.410" Title="Using an ultrasonic sensor to act as a potentiometer for a Servo?" Tags="|arduino-uno|sensors|servo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4930" PostTypeId="1" AcceptedAnswerId="4988" CreationDate="2014-11-09T16:27:23.450" Score="0" ViewCount="162" Body="&lt;p&gt;I followed the instructions in &lt;a href=&quot;https://github.com/WeAreLeka/Bare-Arduino-Project/blob/master/INSTALL.md&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, including to use arduino IDE v 1.0.5, but when I tried to &lt;code&gt;make upload&lt;/code&gt; it stuck. I can upload it when using Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  mkdir -p /Users/bagustrihatmaja/Documents/Projects/MyAwesomeProject/bin/mega328/mySecondProject&#xA; /Applications/Xcode.app/Contents/Developer/usr/bin/make reset&#xA; /Users/bagustrihatmaja/Documents/Projects/MyAwesomeProject/Arduino-Makefile/bin/ard-reset-arduino  /dev/cu.usbmodem1421&#xA; /Applications/Xcode.app/Contents/Developer/usr/bin/make do_upload&#xA; /usr/local/bin/avrdude -q -V -D -p atmega328p -c arduino -b 57600 -P /dev/cu.usbmodem1421 \&#xA;        -U flash:w:/Users/bagustrihatmaja/Documents/Projects/MyAwesomeProject/bin/mega328/mySecondProject/mySecondProject.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What did I miss?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use: Bare-Arduino-Project, OSX 10.10, XCode 6.1, Arduino Uno, &lt;a href=&quot;http://pastebin.com/cR79Sqqz&quot; rel=&quot;nofollow&quot;&gt;my Makefile&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4741" LastActivityDate="2014-11-14T13:16:28.587" Title="Make upload stuck on osx 10.10 bare-arduino-project" Tags="|arduino-uno|avrdude|osx|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4931" PostTypeId="1" CreationDate="2014-11-09T21:14:22.373" Score="3" ViewCount="1305" Body="&lt;p&gt;I would like to exchange data via &lt;strong&gt;Xbee&lt;/strong&gt;. I've set up a communication based on strings between the Arduino and a Matlab software. &#xA;Unfortunately this kind of communication isn't enough robust and sometimes messages aren't delivered correctly. So I decided to move to the &lt;strong&gt;binary communication&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not able to send &lt;strong&gt;binary data&lt;/strong&gt; from the Arduino to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we want to send the decimal value 17 which is &lt;strong&gt;0x11&lt;/strong&gt; in hex if we receive 16 from Matlab.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;[...]&#xA;SoftwareSerial xbee(pinRx, pinTx); &#xA;void setup()&#xA;{&#xA;  Serial.begin(BaudRateSerial);&#xA;  xbee.begin( BaudRateXbee );&#xA;}&#xA;[...]&#xA;void loop()&#xA;{&#xA; while(xbee.available())&#xA;  {&#xA;    getData = xbee.read(); &#xA;    Serial.println();&#xA;    Serial.print(&quot;Received: &quot;);&#xA;    Serial.print(getData,HEX);&#xA;    Serial.println(); &#xA;    if(getData == 16)&#xA;    {           &#xA;      // First attempt   &#xA;      //uint8_t s = 17; &#xA;      //xbee.write(s);  -&amp;gt; Fail&#xA;      // Second attempt&#xA;      //xbee.write(0x11);  -&amp;gt; Fail&#xA;      // Third attempt&#xA;      byte message[] = {0x11, 0x11};&#xA;      xbee.write(message, sizeof(message)); &#xA;    } &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the third attempt I tried sending an &lt;strong&gt;array of bytes&lt;/strong&gt; and noticed that the received values were different. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;byte message[] = {0x11, 0x11};&#xA;&#xA;xbee.write(message, sizeof(message));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Matlab software sends data correctly. I used the &lt;a href=&quot;http://www.mathworks.it/help/matlab/ref/serial.fwrite.html?searchHighlight=fwrite&quot; rel=&quot;nofollow noreferrer&quot;&gt;fwrite&lt;/a&gt; function as follows &lt;code&gt;fwrite(xbee,hex2dec('10'));&lt;/code&gt; and the &lt;a href=&quot;http://www.mathworks.it/help/matlab/ref/serial.fread.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;fread&lt;/a&gt; function to receive the ack which:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;reads binary data from the device connected to the serial port object,&#xA;  obj, and returns the data&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Matlab relevant code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;fwrite(xbee,hex2dec('10')); &#xA;disp('Ack Requested...')&#xA;ack = fread(xbee);&#xA;disp(ack);&#xA;if (ack == 17) &#xA;     % communication established&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried using XC-TU to monitor traffic on Serial port (blu values are sent from the PC, red ones are received from the Arduino) and as you can see red values are different and none of them is equivalent to 17! What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mC7BE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="37523" LastEditDate="2019-05-17T07:48:13.760" LastActivityDate="2019-05-17T07:48:13.760" Title="Sending binary data to Matlab via serial" Tags="|serial|arduino-mega|xbee|softwareserial|matlab|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="4932" PostTypeId="1" AcceptedAnswerId="12498" CreationDate="2014-11-09T21:20:09.047" Score="0" ViewCount="1913" Body="&lt;p&gt;I connected my Arduino Uno to my raspberry via USB serial. I'm able to read out both digital and analog pins of my Arduino using the Python nanpy library (v.0.8).&#xA;However, I can't find support for the pulseIn() function. It seems nanpy doesn't support pulseIn() at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to measure PWM signals with the Arduino and forward the results to the Raspberry Pi? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to measure PWM using the Arduino GUI, however I would to take PWM samples at fixed time intervals over a long period of time and combine this data with other measurements that my Raspberry is making.I also tried pyFirmata, but it doesn't support pulseIn() measurements either.&lt;/p&gt;&#xA;" OwnerUserId="4744" LastActivityDate="2015-07-09T03:24:15.073" Title="What is the best way to measure PWM signals ( pulseIn ) with the Arduino via a Raspberry Pi?" Tags="|arduino-uno|pwm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4933" PostTypeId="1" AcceptedAnswerId="4953" CreationDate="2014-11-09T21:52:21.973" Score="0" ViewCount="494" Body="&lt;p&gt;How can I sense distance with Bare Conductive's Touch Board, like they suggest in &lt;a href=&quot;https://www.youtube.com/watch?v=Y3eSrUQTesg&amp;amp;t=27s&quot; rel=&quot;nofollow&quot;&gt;their product video&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how I can set the touch and release thresholds, so my Touch Board is more sensitive and triggers before I touch a sensor. What I want to do is get the information how near I am. Not in centimeters or so, but a simple value telling me when I'm nearer to or farther from the sensor like in the video.&lt;/p&gt;&#xA;" OwnerUserId="4746" LastEditorUserId="37" LastEditDate="2014-11-12T14:19:07.053" LastActivityDate="2014-11-12T14:19:07.053" Title="Sense distance with Bare Conductive's Touch Board" Tags="|sensors|bare-conductive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4934" PostTypeId="2" ParentId="4830" CreationDate="2014-11-10T00:08:25.877" Score="1" Body="&lt;p&gt;Spark.io boards are also very nice for OTA programmable Arduino-like devices. I have one and have found it to be fairly easy to work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.spark.io/&quot; rel=&quot;nofollow&quot;&gt;https://www.spark.io/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3004" LastActivityDate="2014-11-10T00:08:25.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4935" PostTypeId="2" ParentId="4830" CreationDate="2014-11-10T05:09:03.343" Score="4" Body="&lt;p&gt;We have implemented remote updates on a Arduino Pro Mini (ATMega328P) by putting a &quot;boot&quot; command into the normal firmware. How it works is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The host sends the command &quot;boot&quot; to the remote Arduino.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino jumps to the boot loader (program address 0x3C00 for the Pro Mini)&lt;/li&gt;&#xA;&lt;li&gt;The host sends the new firmware over the link using avrdude (AVR109 protocol)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This doesn't require a new boot loader or hardware. It is not a good solution for commercial devices though, as if the uploaded firmware is corrupted the board will not be able to be put into boot loader mode without a hard reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some wireless comms devices, such as XBees, have GPIO that can be toggled remotely. Connecting this to the Arduino reset pin will allow the board to be reset into the boot loader instead.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastActivityDate="2014-11-10T05:09:03.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4938" PostTypeId="1" AcceptedAnswerId="4940" CreationDate="2014-11-10T14:19:13.297" Score="0" ViewCount="451" Body="&lt;p&gt;I'm trying to get a sensor to activate if a push button is clicked. And deactivate when a certain condition is met and reactivate when the push button is pressed again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt; // Included for SFE_LSM9DS0 library&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SFE_LSM9DS0.h&amp;gt;&#xA;&#xA;#define LSM9DS0_XM  0x1D // Would be 0x1E if SDO_XM is LOW&#xA;#define LSM9DS0_G   0x6B // Would be 0x6A if SDO_G is LOW&#xA;// Create an instance of the LSM9DS0 library called `dof` the&#xA;// parameters for this constructor are:&#xA;// [SPI or I2C Mode declaration], [gyro I2C address], [xm I2C address]&#xA;LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM);&#xA;&#xA;const byte INT1XM = 4; // INT1XM tells us when accel data is ready&#xA;//const byte INT2XM = 8; // INT2XM tells us when mag data is ready&#xA;//const byte DRDYG = 7;  // DRDYG tells us when gyro data is ready&#xA;const int buttonPin = 15;     // the number of the pushbutton pin&#xA;&#xA;int buttonState = 0;&#xA;&#xA;&#xA;double X;&#xA;double Y;&#xA;double Z;&#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(INT1XM, INPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;&#xA;&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600); // Start serial at 115200 bps&#xA;  // Use the begin() function to initialize the LSM9DS0 library.&#xA;  // You can either call it with no parameters (the easy way):&#xA;&#xA;  uint16_t status = dof.begin();&#xA;  // Or call it with declarations for sensor scales and data rates:  &#xA;  //uint16_t status = dof.begin(dof.G_SCALE_2000DPS, dof.A_SCALE_6G, dof.M_SCALE_2GS);&#xA;&#xA;  // begin() returns a 16-bit value which includes both the gyro and&#xA;  // accelerometers WHO_AM_I response. You can check this to make sure&#xA;  // communication was successful.&#xA;  // Serial.println(status, HEX);&#xA;  setODR();&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  buttonState = digitalRead(buttonPin); //Read push button logic.&#xA;&#xA; // Serial.println(buttonState);&#xA;&#xA;  if (buttonState == 1) {   //if push button is pressed&#xA;&#xA;    printAccel(); //print sensor data&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void printAccel()&#xA;{&#xA;  // Only read from the accelerometer if the accel interrupts,&#xA;  // which means that new data is ready.&#xA;  if (digitalRead(INT1XM))&#xA;  {&#xA;    // Use the readAccel() function to get new data from the accel.&#xA;    // After calling this function, new values will be stored in&#xA;    // the ax, ay, and az variables.&#xA;    dof.readAccel();&#xA;&#xA;    //Serial.print(&quot;A: &quot;);&#xA;&#xA;    // Using the calcAccel helper function, we can get the&#xA;    // accelerometer readings in g's.&#xA;    X=dof.calcAccel(dof.ax);&#xA;    Y=dof.calcAccel(dof.ay);&#xA;    Z=dof.calcAccel(dof.az);&#xA;&#xA;    Serial.print(X);&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(Y);&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.println(Z); &#xA;&#xA;    // Serial1.println(Z);   &#xA;&#xA;    fall(); //jump to check condition&#xA;&#xA;  }&#xA;}&#xA;&#xA;void setODR(){&#xA;&#xA;  dof.setAccelODR(dof.A_ODR_25);&#xA;  dof.setAccelScale(dof.A_SCALE_16G);&#xA;}&#xA;&#xA;void fall(){&#xA;&#xA;  if(-0.08&amp;lt;X &amp;amp;&amp;amp; X&amp;lt;0.08){&#xA;    if(-0.08&amp;lt;Y &amp;amp;&amp;amp; Y&amp;lt;0.08){&#xA;      if(-0.08&amp;lt;Z &amp;amp;&amp;amp; Z&amp;lt;0.08){&#xA;&#xA;        Serial1.println(&quot;N&quot;);&#xA;        Serial.println(&quot;Fallen!&quot;);&#xA;&#xA;        loop(); //if condition is met, jump to loop to wait for push button to be pressed again.&#xA;&#xA;        }&#xA;      }&#xA;    }&#xA;  //else{&#xA;&#xA;    printAccel(); //else continue printing sensor data&#xA;&#xA;  //}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I am having some trouble getting it to work, above is what I have worked out thus far.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2014-11-10T16:54:49.410" Title="Getting Push Button Logic To Stick?" Tags="|programming|button|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4939" PostTypeId="2" ParentId="994" CreationDate="2014-11-10T16:25:03.370" Score="5" Body="&lt;p&gt;The Atmel ATmega328 datasheet, section 24.6.1, recommends that you drive the analog input pin with an output impedance of 10 KOhm or less. Also, it recommends that you remove high-frequency components with a low-pass filter. (That low-pass is sometimes called an antialiasing filter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest possible low-pass filter is a resistor and a capacitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  +5V                        +5V&#xA;   |                          |&#xA;(sensor)---resistor---+---(Arduino)&#xA;   |                  |          |&#xA;   |            capacitor        |&#xA;   |                  |          |&#xA;  GND----------------GND--------GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Contrary to popular belief, it is not possible to make an antialiasing filter in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an initial low-resolution prototype, a quick rule of thumb is to pick the RC time constant at least 10 times as long as the time between samples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you are sampling at around 1000 Samples/second (i.e., a sampling interval of 1 millisecond), then 100 Ohms of resistance and (roughly) 100 uF ceramic capacitor may be adequate.&#xA;(The RC time constant here is RC == 100 Ohms x 100 uF = 10 milliseconds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many joysticks already have a relatively high output impedance; you'll need to use a resistor with that much less resistance to compensate.&#xA;(Sometimes you don't need any additional resistance; but you still need that capacitor between the Arduino analog input pin and the Arduino ground pin).&#xA;(Many sensors have an output impedance more than 10 KOhm; people who use them are pretty much forced to use an op-amp chip to get clean signals).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Entire books have been written on signal filtering.&#xA;In addition, there are many other techniques for getting higher resolution analog signals, higher speed data collection, and trading off between them --&#xA;but they are probably overkill for reading the position of a joystick.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-11-10T16:25:03.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4940" PostTypeId="2" ParentId="4938" CreationDate="2014-11-10T16:54:49.410" Score="3" Body="&lt;p&gt;You'll need to store whether the button has been pressed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool buttonActivated = false;&#xA;&#xA;...&#xA;&#xA;void loop(){&#xA;&#xA;  buttonState = digitalRead(buttonPin); //Read push button logic.&#xA;  if (buttonState == 1 ) {&#xA;    buttonActivated = true;&#xA;  }&#xA;&#xA;  if( buttonActivated ) {&#xA;    printAccel(); //print sensor data&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to deactivate, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonActivated = false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-10T16:54:49.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4941" PostTypeId="2" ParentId="4932" CreationDate="2014-11-10T17:00:20.747" Score="0" Body="&lt;p&gt;Nanpy seems to have a &lt;a href=&quot;https://github.com/nanpy/nanpy-firmware/blob/master/Nanpy/CounterClass.cpp&quot; rel=&quot;nofollow&quot;&gt;CounterClass&lt;/a&gt; that does frequency measurements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do you want to measure the PWM duty-cycle?&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-10T17:00:20.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4942" PostTypeId="1" CreationDate="2014-11-10T17:08:14.503" Score="-1" ViewCount="433" Body="&lt;p&gt;I am currently coding on a Seeeduino Stalker v2.3 - water proof kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Seeeduino_Stalker_-_Waterproof_Solar_Kit&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.seeedstudio.com/wiki/Seeeduino_Stalker_-_Waterproof_Solar_Kit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is sold with a solar panel to recharge the battery. Unfortunately, I will not have a lot of light where my sensor will be installed and I would like to power the board with a charger from 110V-220V plug and keep the battery only for potential power shortage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the best option for connection and charger?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a previous Arduino Uno charger (9V-1A). Would it work with some linear regulator? What wiring should I use?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Any recommendation for a Li-Ion battery that could I buy and that would last longer than this 3.7 V at 1000mA?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help :)&lt;/p&gt;&#xA;" OwnerUserId="4760" LastEditorUserId="4628" LastEditDate="2017-02-20T05:09:02.107" LastActivityDate="2017-02-20T05:09:02.107" Title="How to power a Seeeduino Stalker v2.3 - water proof with charger instead of solar panel" Tags="|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4943" PostTypeId="1" CreationDate="2014-11-10T17:13:01.680" Score="2" ViewCount="6267" Body="&lt;p&gt;I am starting to use a Seeeduino GPRS shield (please see note), which is essentially an Arduino Leonardo that, among other things, can be used as a mobile 'phone for sending and receiving texts. I have successfully tried the &quot;blink an led&quot; and &quot;fade an led&quot; sketches, so the compiling and uploading are ok&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a desktop computer with Linux Fedora 20.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to go on to use the cell phone network to communicate with my mobile 'phone. However I am puzzled by something I assume everybody else understands already, and that is the references to &quot;select either software serial port or hardware serial port to be connected to GPRS Shield&quot;. Please could someone explain what &quot;software or hardware serial port&quot; is, in simple terms, or point me to a web site that does so? Do I need any wired connection with my PC other than the USB link I use for uploading sketches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I bought a discounted GPRS shield labelled version 1.0a2. All the information on the 'net is of version 1.0 or 2.0 (with no &quot;a2&quot;) and photos and diagrams do not correspond with what I have. I am awaiting official documentation, but meanwhile treating it as an Arduino Leonardo seems to be working.&lt;/p&gt;&#xA;" OwnerUserId="1631" LastActivityDate="2014-11-11T03:52:12.627" Title="Explanation please, of hardware and software serial links" Tags="|arduino-leonardo|softwareserial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4944" PostTypeId="2" ParentId="4943" CreationDate="2014-11-10T18:32:29.487" Score="1" Body="&lt;p&gt;The hardware serial port is the serial port which connects to the computer this takes up pins 1 and 2 I believe. You can read about this here &lt;a href=&quot;http://arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/reference/serial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software serial ports are only on digital IO pins. You can read more about this here &#xA;&lt;a href=&quot;http://arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/softwareSerial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should not need anything other the USB connection port.&lt;/p&gt;&#xA;" OwnerUserId="3818" LastActivityDate="2014-11-10T18:32:29.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4945" PostTypeId="2" ParentId="4943" CreationDate="2014-11-10T18:32:40.360" Score="1" Body="&lt;p&gt;A &lt;code&gt;SoftwareSerial&lt;/code&gt; connection is created using the &lt;code&gt;UART&lt;/code&gt; pins 7 and 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having the device in &lt;code&gt;HardwareSerial&lt;/code&gt; mode allows the device to connect to pins 0 and 1, allowing direct control from the serial connection to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;SoftwareSerial&lt;/code&gt;, you can communicate with the Arduino Via serial, and the Arduino controls the GPRS shield via uart.&lt;/p&gt;&#xA;" OwnerUserId="407" LastActivityDate="2014-11-10T18:32:40.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4946" PostTypeId="2" ParentId="4711" CreationDate="2014-11-10T18:36:35.250" Score="2" Body="&lt;p&gt;You have defined your pin as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorPin = A0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which should be replaced with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define sensorPin = A0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in your code, you need to read the value from  the pin in your &lt;code&gt;if&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (digitalRead(sensorPin) == HIGH) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="407" LastActivityDate="2014-11-10T18:36:35.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4947" PostTypeId="2" ParentId="4914" CreationDate="2014-11-10T19:11:12.960" Score="1" Body="&lt;p&gt;The sampling frequency you are referring to (twice the highest frequency) is for capturing waves, but is not really a concern for the sensors you are using and the types of data they are used to measure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to analyse the magnitude of a 40kHz vibration in a structure, you should worry about sampling rates on your accelerometer; however, if you want to measure the accelerometers current angle to the ground (assuming its not accelerating), you only need to take one sample.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the ECG, there will be a signal among all the analog voltages you read of a heartbeat (I'm assuming its hooked up to a person). This signal will never get much over 200 beats per minute, or 3.3 Hz. To capture a 3.3Hz signal you need a minimum sampling rate of 6.6Hz, which as still incredibly slow. The same goes for capturing a gait with your accelerometer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you capture the analog voltage of your sensors output with analogRead 100 times a second, you should have a very clear and well defined view of the very low frequency signals you are trying to track, and should not have any issues with transferring that much information over serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;5, 16 bit values can theoretically be sent at 120Hz over 9600 baud, and its very easy to use faster speeds then that if you want more information.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-11-10T19:11:12.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4948" PostTypeId="2" ParentId="4942" CreationDate="2014-11-10T19:24:32.140" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can charge the battery and power the board, via USB. The CN3063 requires between 4.4V to 6V, so not a huge range of options besides a 5v wall-wart&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No. 9V would be too high.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How many mains power failures / brownouts do you get, where you live?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="186" LastEditDate="2015-11-06T14:38:55.187" LastActivityDate="2015-11-06T14:38:55.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4949" PostTypeId="2" ParentId="4943" CreationDate="2014-11-10T20:25:50.160" Score="3" Body="&lt;p&gt;Most small micro controllers, AVR's included, have dedicated hardware for communicating with different serial devices. In arduino these are referenced with &quot;Serial&quot;, &quot;Serial1&quot;, &quot;Serial2&quot; and so on, depending on how many hardware serial ports your particular arduino has. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Leonardo's are an exception, the first hardware port is &quot;Serial1&quot; and &quot;Serial&quot; refers to the PC's usb connection. On the other arduinos that I know of &quot;Serial&quot; is hardware serial used for PC comms, so using it for other hardware requires sacraficing your PC link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software serial ports use the processors more generic pin-change interrupt system to communicate on any pins that support said interrupts, but they have a higher processing overhead and often cannot support the same high speeds as the hardware serial. There are different libraries for Software Serial that have different approaches giving different advantages and drawbacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use a software Serial port you will need to make one to be used in your code, which will look something like this, depending on the type name the library you include uses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial softSerial( txPinNumber, rxPinNumber);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in short, your processor has dedicated hardware for communicating over serial that should be used first, but if you need more ports the processor can simulate some extras which is referred to as &quot;Software Serial&quot;. The documentation to your GPRS shield implies that either will work just fine. You should look at the arduino documentation for your board to see how many ports you have and which pins can be used for serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation does not imply you will need any special link to your computer outside of the USB connection.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-11-11T03:52:12.627" LastActivityDate="2014-11-11T03:52:12.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4950" PostTypeId="1" AcceptedAnswerId="34266" CreationDate="2014-11-11T13:00:00.863" Score="4" ViewCount="7590" Body="&lt;p&gt;I want to run the 5V board at 3.3V because I can get the 5V version cheaper than the 3.3V version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that you can power the Arduino Pro Mini with a battery by connecting the battery to the 5V pin, bypassing the regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somewhere else I read that the only difference between a 3.3V and 5V Pro Mini is the regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are these assumptions correct? If yes, can I use a 5V Pro Mini like a 3.3V by powering it with a 3V Battery on the 5V pin?&lt;/p&gt;&#xA;" OwnerUserId="4661" LastEditorUserId="6452" LastEditDate="2015-02-27T17:21:01.147" LastActivityDate="2020-03-26T21:38:53.220" Title="Powering a 5V Arduino Pro Mini with 3.3V" Tags="|arduino-pro-mini|voltage-level|battery|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4952" PostTypeId="1" AcceptedAnswerId="4995" CreationDate="2014-11-11T14:32:28.540" Score="5" ViewCount="3016" Body="&lt;p&gt;So I am trying to test what will eventually be a Arduino controlling 3 110V motors that are currently controlled by an analog pot. But more on that later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to test out using a digital pot (never have before) and am running into some issues with tutorials I have found online. For now, I want to control a LED with the digital pot (&lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/22060b.pdf&quot; rel=&quot;noreferrer&quot;&gt;Spec Sheet&lt;/a&gt;) so that the LED fades in and fades out in a continuos loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the &lt;a href=&quot;http://www.instructables.com/id/Digital-Potentiometer-MCP41100-and-Arduino/?ALLSTEPS&quot; rel=&quot;noreferrer&quot;&gt;tutorial I followed&lt;/a&gt;. It uses a different chip model but it seems from the pot I am using that the pins are the same. (I could be wrong?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I double and triple checked the wiring and it matches below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/urSnK.jpg&quot; alt=&quot;Wiring Diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I am running (slightly modified from the tutorial, also tried the tutorial code)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;byte address = 0x11;&#xA;int CS= 10;&#xA;int i=0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode (CS, OUTPUT);&#xA;  SPI.begin();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    for (i = 0; i &amp;lt;= 128; i++)&#xA;    {&#xA;      digitalPotWrite(i);&#xA;      delay(10);&#xA;    }&#xA;    delay(500);&#xA;    for (i = 128; i &amp;gt;= 0; i--)&#xA;    {&#xA;      digitalPotWrite(i);&#xA;      delay(10);&#xA;    }&#xA;}&#xA;&#xA;int digitalPotWrite(int value)&#xA;{&#xA;  digitalWrite(CS, LOW);&#xA;  SPI.transfer(address);&#xA;  SPI.transfer(value);&#xA;  digitalWrite(CS, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a result of the two above, I have an LED that stays lit (at about 50% it seems) and does not fade in/out at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being relatively new to wiring and EE in general, is there a better way to replicate an analog pot without using a digital pot? Can I just use PWM to control it? Why would the LED be just staying lit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4772" LastActivityDate="2014-11-15T09:24:18.233" Title="Digital Potentiometer not fading LED" Tags="|arduino-uno|spi|potentiometer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4953" PostTypeId="2" ParentId="4933" CreationDate="2014-11-11T20:41:03.673" Score="0" Body="&lt;p&gt;As a member of the Bare Conductive team, I can tell you that looking at the &lt;a href=&quot;https://github.com/BareConductive/mpr121-grapher&quot; rel=&quot;nofollow&quot;&gt;grapher&lt;/a&gt; will be helpful to you. The grapher is a processing sketch that requires the Touch Board to be running the &lt;a href=&quot;https://github.com/BareConductive/mpr121/tree/public/MPR121/Examples/DataStream&quot; rel=&quot;nofollow&quot;&gt;Datastream&lt;/a&gt; code. Datastream will give you the sort of raw electrode data that you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="4776" LastEditorUserId="37" LastEditDate="2014-11-12T14:17:31.997" LastActivityDate="2014-11-12T14:17:31.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4955" PostTypeId="2" ParentId="4928" CreationDate="2014-11-12T11:53:35.193" Score="1" Body="&lt;p&gt;Halo, thank you for ansering anything.. I got the loop loop loop thing now runin..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So its about playing an Audiofile if hookon == LOW ........ check it out :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code now looks like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ringerPin = A0;&#xA;const int offhook = A4;&#xA;const int onhook = A5;&#xA;double beginRing = -40000;&#xA;&#xA;void setup(){&#xA;    pinMode(ringerPin, OUTPUT);&#xA;    pinMode(offhook, INPUT);&#xA;    pinMode(onhook, INPUT);&#xA;    randomSeed(analogRead(0)); // this starts Arduino's random number generator&#xA;}&#xA;&#xA;int randCall = random(60000, 3600000); // generate a random number between 1 min and 60 min&#xA;&#xA;//ring every 1 to 60 minutes if the phone is down (hookon) and dont ring if the phone is picked up (no hookon)&#xA;void loop()&#xA;{&#xA;  if (digitalRead(hookon) == HIGH){&#xA;    delay (randCall);&#xA;    beginRing = Time.elapsedTime;&#xA;    while(Time.elapsedTime - beginRing &amp;lt;= 30000 &amp;amp;&amp;amp; digitalRead(hookon) == HIGH){&#xA;      //turn any audio off???&#xA;      for(int x = 0; x &amp;lt; 15; x++){&#xA;        digitalWrite(ringerPin, HIGH);   // turn the solenoid on (HIGH is the voltage level)&#xA;        delay(50);                           // wait for 50 msec&#xA;        digitalWrite(ringerPin, LOW);    // turn the solenoid off by making the voltage LOW&#xA;        delay(80);                          // wait for 50 msec&#xA;      }&#xA;      delay(2500);&#xA;    }&#xA;  }&#xA;  if(Time.elapsedTime - beginRing &amp;lt;= 30000){&#xA;    //play one randomly choosen audiofile out of 10&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, now its about to stop any sound if the hookon is HIGH and to play the randomly choosen file 1 out of 10 if the hookon is LOW (its in the code as description...there i need the right comands)&lt;/p&gt;&#xA;" OwnerUserId="4738" LastActivityDate="2014-11-12T11:53:35.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4956" PostTypeId="1" AcceptedAnswerId="4962" CreationDate="2014-11-12T18:27:48.117" Score="1" ViewCount="83" Body="&lt;p&gt;I have a demo that spins a motor, but the leads on my motor broke. I happen to have another motor lying around that I'd like to swap in, but it's of a different type. Here's my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ccBRT.png&quot; alt=&quot;Spin Motor Spin from Node-Ardx&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the old (broken) motor: &lt;a href=&quot;https://www.sparkfun.com/products/11696&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/11696&lt;/a&gt;. It has an operating voltage range of 1.0 to 3.0V DC and a no load speed of 6600±10% RPM (@1.0V DC, 110mA). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The new motor that I'd like to use is part of this kit: &lt;a href=&quot;https://www.sparkfun.com/products/12866&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/12866&lt;/a&gt;. It's a 6VDC motor with a No Load Speed of 90±10rpm and a No Load Current of 190mA(max.250mA). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running this off a Sparkfun Redboard, which is UNO R3 compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I swap in the new motor without any circuit changes? Will I have to add additional power for the new motor? Or should I change the circuit with a larger resistor or something else?&lt;/p&gt;&#xA;" OwnerUserId="1333" LastActivityDate="2014-11-13T06:17:54.650" Title="Can I use this replacement motor without modifying the circuit?" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4957" PostTypeId="1" AcceptedAnswerId="4959" CreationDate="2014-11-12T18:53:59.497" Score="9" ViewCount="13626" Body="&lt;p&gt;I am making a tiny game, and want to store high-scores. I made a Highscore-class in the top of the sketch file, like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Highscore {&#xA;public:&#xA;  String name;&#xA;  int score;&#xA;&#xA;  String toString() {&#xA;    return this-&amp;gt;name + &quot; - &quot; + (String)score;&#xA;  }&#xA;&#xA;  Highscore(String name, int score) {&#xA;    this-&amp;gt;name = name;&#xA;    this-&amp;gt;score = score;&#xA;  }&#xA;};&#xA;&#xA;setup() { // etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now. Near the bottom of the sketch, I have a function I want to take a Highscore-object as a parameter, but the compiler will not let me. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeHighscore(Highscore hs) {&#xA;  File f = SD.open(&quot;high.txt&quot;, FILE_WRITE);&#xA;  // Do stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The complation error is as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sketch.ino:19:21: error: variable or field ‘writeHighscore’ declared void&lt;br&gt;&#xA;  sketch.ino:19:21: error: ‘Highscore’ was not declared in this scope&lt;br&gt;&#xA;  sketch.ino: In function ‘void setup()’:&lt;br&gt;&#xA;  sketch.ino:64:20: error: ‘writeHighscore’ was not declared in this scope&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After changing parameter type to String, int or whatever, all the errors go away. I am able to create Highscore-objects INSIDE the &lt;code&gt;writeHighscore()&lt;/code&gt; function, but how can I pass objects to it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1 - Object creation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Highscore hs = Highscore(&quot;John&quot;, 975);&#xA;Serial.println(hs.toString()); // Prints &quot;John - 975&quot; as expected&#xA;writeHighscore(hs); // Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4783" LastEditorUserId="4783" LastEditDate="2014-11-12T19:37:05.933" LastActivityDate="2015-07-06T22:14:16.873" Title="How can I pass an object as a parameter to a function?" Tags="|c++|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="4958" PostTypeId="1" CreationDate="2014-11-12T19:11:55.617" Score="1" ViewCount="448" Body="&lt;p&gt;I'm trying to get my LED matrix to run Conway's Game of Life. After 4 different pin configurations, I've finally been able to run a separate test code, that lights all the LED's in order, and then turns them off in order (Code Below). I've written the entirety of GoL in C#, but the Arduino language is just different enough to where I can write sort of ok in it, but not enough to understand what's going wrong. I got a Game of Life code from &lt;a href=&quot;http://brownsofa.org/blog/2010/12/30/arduino-8x8-game-of-life/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and it won't even light my LEDs, or when it does, it's incredibly dim, unlike my test code. I'll show my pin layout in the code. I've tried changing the pins in the GoL code, copying the setup from one to the other, and  but for the life of me, I can't seem to figure out why one would light up the LED's without a hitch, and the other is struggling. Can anybody see the changes I'd need to make that would make the GoL code at that link, work like this test code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my Test code that works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int speed = 4; //the delay time in milliseconds&#xA;&#xA;int pauseDelay = 1;    //the number of milliseconds to display each scanned line&#xA;&#xA;//Pin Definitions&#xA;int rowA[] = {14,15,16,17,2,3,4,5};          //An Array defining which pin each row is attached to&#xA;                                     //(rows are common anode (drive HIGH))&#xA;int colA[] = {6,7,8,9,10,11,12,13};  //An Array defining which pin each column is attached to&#xA;                                     //(columns are common cathode (drive LOW))&#xA;&#xA;//The array used to hold a bitmap of the display &#xA;//(if you wish to do something other than scrolling marque change the data in this&#xA;//variable then display)&#xA;byte data[] = {0,0,0,0,0,0,0,0};    &#xA;&#xA;&#xA;//Setup runs once when power is applied&#xA;void setup()&#xA;{ &#xA;  Serial.begin(9600);         //Open the Serial port for debugging&#xA;  for(int i = 0; i &amp;lt;8; i++){  //Set the 16 pins used to control the array as OUTPUTs&#xA;    pinMode(rowA[i], OUTPUT);&#xA;    pinMode(colA[i], OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;//repeats   &#xA;void loop()&#xA;{&#xA; //Example #1 - test pattern&#xA; //Run a small test program which lights up each light in time&#xA;  test();&#xA;&#xA; //Example #2 - static image&#xA; //Display a defined bitmap&#xA;/* &#xA;  data[0] = B10101010; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[1] = B01010101; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[2] = B10101010; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[3] = B01010101; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[4] = B10101010; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[5] = B01010101; //row 1s bit mask (1 LED is on 0 LED is off)&#xA;  data[6] = B10101010; //row 1s bit mask (1 LED is on 0 LED is off)  &#xA;  data[7] = B01010101; //row 1s bit mask (1 LED is on 0 LED is off)  &#xA;  showSprite(speed);&#xA;*/ &#xA; }&#xA;&#xA;//An array to store power values to act as bit masks&#xA;const int powers[] = {1,2,4,8,16,32,64,128};&#xA;&#xA;//Runs a pattern where each LED is lit one after another&#xA;void test(){&#xA;  for(int i = 0; i &amp;lt; 8; i++){&#xA;for(int ii = 0; ii&amp;lt; 8; ii++){&#xA;data[i] = data[i]+ powers[ii];   //Goes through each row of lights lighting each column one after another&#xA;showSprite(speed);&#xA;}&#xA;  }&#xA;&#xA;  for(int i = 0; i &amp;lt; 8; i++){&#xA;   for(int ii = 0; ii&amp;lt; 8; ii++){&#xA;data[i] = data[i] - powers[ii];   //Goes through each row of lights turning off each column one after another&#xA;   showSprite(speed);&#xA;    }&#xA;  }  &#xA;}&#xA;&#xA;void showSprite(int speed2){&#xA; for(int iii = 0; iii &amp;lt; speed2; iii++){                 //show the current frame speed2 times&#xA;  for(int column = 0; column &amp;lt; 8; column++){            //iterate through each column&#xA;       for(int i = 0; i &amp;lt; 8; i++){                          &#xA;           digitalWrite(rowA[i], LOW);                      //turn off all row pins  &#xA;   }&#xA;   for(int i = 0; i &amp;lt; 8; i++){ //Set only the one pin&#xA;     if(i == column){     digitalWrite(colA[i], LOW);}  //turns the current row on&#xA;     else{                digitalWrite(colA[i], HIGH); }//turns the rest of the rows off&#xA;   }&#xA;&#xA;   for(int row = 0; row &amp;lt; 8; row++){                    //iterate through each pixel in the current column&#xA;    int bit = (data[column] &amp;gt;&amp;gt; row) &amp;amp; 1;&#xA;    if(bit == 1){ &#xA;       digitalWrite(rowA[row], HIGH);                   //if the bit in the data array is set turn the LED on&#xA;    }&#xA;&#xA;   }&#xA;   delay(pauseDelay);                       //leave the column on for pauseDelay microseconds (too high a delay causes flicker)&#xA;  } &#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4784" LastEditorUserId="37" LastEditDate="2014-11-12T21:00:01.693" LastActivityDate="2014-11-13T21:29:33.607" Title="What in the example code is different from my test code? LED matrix lights up differently" Tags="|programming|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4959" PostTypeId="2" ParentId="4957" CreationDate="2014-11-12T20:35:40.133" Score="6" Body="&lt;p&gt;You are doing everything right, but you need to move the class outside of your .ino file for this to work. &lt;del&gt; I'm not sure why the arduino IDE makes you do this &lt;/del&gt; (see edit) , but it is something I've run into before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just tested this, and moving the class declaration outside the ino and into a header file in the project folder makes it compile correctly. Just remember to include the header you make in the ino and to &lt;code&gt;#include &quot;Arduino.h&quot;&lt;/code&gt; in the header to get access to &quot;String&quot; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically, only a forward declaration of the class needs to be in a different file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm relatively sure what is happening is the IDE is generating forward declarations for all your functions but not the class, which are placed before your class definition. &#xA;This means that breaking the function regex the IDE uses with a dummy &quot;throw()&quot; fixes your problem. for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeHighscore(Highscore hs) throw() { ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should work just fine (it worked for me)&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-11-13T00:38:31.537" LastActivityDate="2014-11-13T00:38:31.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4960" PostTypeId="1" CreationDate="2014-11-12T22:42:12.590" Score="0" ViewCount="14893" Body="&lt;p&gt;Would it be possible to have an Arduino write directly to a MySQL database?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a web programmer, so I'm familiar with how to get records from a MySQL database. I have MAMP installed on my mac, so I have the ability to build an interface, directly in the web browser, that retrives the records from a MySQL database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm thinking is to connect the Arduino directly to my computer via USB, and write data from the sensors, or the pins, directly to my MySQL database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using two phototransistor to record whenever something blocks the light. Each sensor records individually a timestamp for when the blocking occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="4824" OwnerDisplayName="ThomasK" LastEditorUserId="42" LastEditDate="2015-04-10T16:27:41.870" LastActivityDate="2015-04-10T16:27:41.870" Title="Have Arduino write data to a MySQL database?" Tags="|datalogging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4961" PostTypeId="2" ParentId="4960" CreationDate="2014-11-12T22:47:51.607" Score="4" Body="&lt;p&gt;It's possible if you forget about the Arduino directly writing to the database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply put, the Arduino is restricted to a serial connection.  To directly communicate with MySQL you would need a network connection, and then implement the MySQL protocol - a huuuge amount of work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal way is to have an adapter program running on the PC which receives data from the Arduino over the serial connection, then performs any insert, select, etc instructions on the MySQL for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &quot;MySQL Connector&quot; available* (&lt;a href=&quot;https://launchpad.net/mysql-arduino&quot; rel=&quot;nofollow&quot;&gt;https://launchpad.net/mysql-arduino&lt;/a&gt;) but of course that requires you to have an active network connection of some form to your Arduino.  Remember that the Arduino (certainly the Uno) is very limited on memory and program space, so having the Arduino connect direct, and doing anything else, might be mutually exclusive.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;*Nice find, @SomeHardwareGuy...&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-11-12T22:47:51.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4962" PostTypeId="2" ParentId="4956" CreationDate="2014-11-13T06:17:54.650" Score="2" Body="&lt;p&gt;Regarding voltage, I think there should be no problem as the datasheet for your replacement motor specifies a &quot;suggested voltage 4.5V DC&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, be careful that there is another important value in motor datasheets: the &lt;strong&gt;stall current&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply stated, this is the current consumed by the motor when it tries to rotate but is unable to, due to its too low torque in comparison with the effort needed for rotation, e.g. if it tries to rotate the wheel of a robot that is too heavy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original motor has a stall current of 0.8A according to its datasheet (you can get it from the link you provided).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your replacement motor has 1A according to the link you provided. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These 200mA can make a big difference for the transistor used in your circuit, a &lt;strong&gt;P2N2222A&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, that transistor is &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Components/General/P2N2222A-D.PDF&quot; rel=&quot;nofollow&quot;&gt;specified&lt;/a&gt; to switch a maximum of &lt;strong&gt;600mA&lt;/strong&gt; current at the collector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in the best case, the motor will run correctly without load, but if you provide some load that makes it stall, then the transistor will raise temperature (you could sense that by approaching your finger) and ultimately would get toasted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please also note that some poorly designed motors may consume a current near the stall current, due to internal friction (I have already almost grilled a transistor this way...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my answer is: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you can do it for a simple experiment with no load on the motor&lt;/li&gt;&#xA;&lt;li&gt;if you really want to do something with the motor, take another transistor with a higher &lt;em&gt;Ic&lt;/em&gt; current&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-11-13T06:17:54.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4964" PostTypeId="2" ParentId="4960" CreationDate="2014-11-13T08:11:24.457" Score="3" Body="&lt;p&gt;You can do that using an Arduino Yun: the Yun has a linux cpu paired with the ATMega32U4, so you can delegate things like accessing a mysql database, either local or remote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at this &lt;a href=&quot;http://www.instructables.com/id/Control-Access-of-Arduino-Y%C3%9AN-with-MySQL-PHP5-and-/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;instructable&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are different ways for delegating logging sensors readings to the linux side and have them stored on a mysql: the easiest is to code a short python script and call it from the sketch using &lt;a href=&quot;http://arduino.cc/en/Tutorial/Process&quot; rel=&quot;nofollow&quot;&gt;Process&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-11-13T08:11:24.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4967" PostTypeId="2" ParentId="4199" CreationDate="2014-11-13T12:45:36.527" Score="0" Body="&lt;p&gt;The genuine Arduino boards feature a digital (temperature based) fuse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When shorting an Arduino, it will heat up the fuse on the Arduino. When the fuse gets to a certain temperature, it will automatically cut off the power from the USB connection to the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the fuse cools down, it will conduct again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motherboards of most computers these days also work with these digital fuses, so you might have heated up both. It wouldn't hurt to reboot the PC and disconnect the Arduino and give it a minute to cool down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it still doesn't work, you might have fried the Arduino or the specific USB port.&#xA;Try a USB port that is likely not connected to the same USB controller in the PC. Meaning, don't just try the first USB port next to the one you used, but try a USB port on the other side of the PC / laptop, they are likely to be connected to different USB controllers.&lt;/p&gt;&#xA;" OwnerUserId="4710" LastActivityDate="2014-11-13T12:45:36.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4971" PostTypeId="1" CreationDate="2014-11-13T18:07:56.867" Score="1" ViewCount="755" Body="&lt;p&gt;Can the Arduino Mega2560 use the &lt;a href=&quot;http://www.newhavendisplay.com/nhd0420d3znswbbwv3-p-5745.html&quot; rel=&quot;nofollow&quot;&gt;New Haven NHD-0420D3Z-NSW-BBW-V3&lt;/a&gt; LCD panel by controlling it with the &lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal&quot; rel=&quot;nofollow&quot;&gt;New LiquidCrystal library&lt;/a&gt;? What cable will you use to connect the LCD to Arduino, are there screw terminals on the LCD board to secure the connections? It seems like only 4 connections are needed, for &lt;code&gt;GND&lt;/code&gt;, &lt;code&gt;VCC&lt;/code&gt;, &lt;code&gt;SDA&lt;/code&gt;, &lt;code&gt;SCL&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="639" OwnerDisplayName="Nyxynyx" LastActivityDate="2014-11-13T18:45:28.320" Title="Can the Arduino use this i2c LCD Panel" Tags="|i2c|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4972" PostTypeId="2" ParentId="4971" CreationDate="2014-11-13T18:20:21.390" Score="3" Body="&lt;p&gt;Unfortunately you cannot control that display using that library; the library expects to be connected to a HD44780-compatible driver but the display uses a fully custom control scheme. You may be able to adapt the library to the scheme, but I have not looked at that specifically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I&lt;sup&gt;2&lt;/sup&gt;C itself only requires 3 connections: SDA, serial data; SCL serial clock; GND, ground reference. Since the display is not powered separately it also requires power, in this case 5V. Since the display can only communicate at 100kHz you don't need to be &lt;em&gt;too&lt;/em&gt; terribly concerned about cable quality; Cat3 or even telephone cable is acceptable as long as you don't exceed a few feet in length. &lt;a href=&quot;https://electronics.stackexchange.com/questions/102611/what-happens-if-i-omit-the-pullup-resistors-on-i2c-lines&quot;&gt;Don't forget the external pullup resistors&lt;/a&gt; though, on SDA and SCL.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-13T18:20:21.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4973" PostTypeId="1" CreationDate="2014-11-13T19:06:01.983" Score="2" ViewCount="189" Body="&lt;p&gt;I want to know if there is a way to install/use the &lt;a href=&quot;http://crypto.stanford.edu/pbc/&quot; rel=&quot;nofollow&quot;&gt;PBC library&lt;/a&gt; on Arduino UNO. I want to implement some cryptographic primitives using PBC library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4801" LastActivityDate="2023-11-01T09:50:25.413" Title="Using PBC library on Arduino" Tags="|arduino-uno|library|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="4974" PostTypeId="2" ParentId="1471" CreationDate="2014-11-13T19:07:41.817" Score="3" Body="&lt;p&gt;Just hook up the serial pins from the bluetooth module to the corresponding Pro Micro pins: TX to RX and RX to TX. I hope this can help someone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then look for data like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){ &#xA;   Serial1.begin(9600); // Init Hardware Serial port on pins 0 and 1 - Bluetooth&#xA;   Serial.begin(9600); // Init Virtual Serial Port - Machine&#xA;&#xA;   Keyboard.begin(); // Init HID - Keyboard&#xA;}&#xA;&#xA;void loop(){&#xA;   if (Serial1.available() &amp;gt; 0) {&#xA;&#xA;     char myData = Serial1.read()&#xA;&#xA;     // Send data from Bluetooth/Sensor to the Machine - Virtual Serial Port &#xA;     Serial.println(myData); &#xA;&#xA;     // Emulate HID Device - Keyboard&#xA;     if ( myData == 0x7F ) { // Detect code of android backspace key         &#xA;        Keyboard.write(0xB2); //  Convert received code char to PC/Linux ascii keycode for the backspace key. This can change between different OS!      &#xA;     }&#xA;&#xA;     else {&#xA;        Keyboard.write(myData); &#xA;     }&#xA;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3626" LastActivityDate="2014-11-13T19:07:41.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4975" PostTypeId="2" ParentId="4958" CreationDate="2014-11-13T21:29:33.607" Score="2" Body="&lt;p&gt;I ended up using a different PIN layout, and the GoL code had the pins As anodes where they were Cathodes in the other code. Switched rows pins to Columns pins in the code and Problem solved.&lt;/p&gt;&#xA;" OwnerUserId="4784" LastActivityDate="2014-11-13T21:29:33.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4976" PostTypeId="1" CreationDate="2014-11-13T21:33:21.637" Score="0" ViewCount="1894" Body="&lt;p&gt;I've been trying to get an Arduino (I have a Mega and Uno lying around) to read values from a small array of 3 &lt;a href=&quot;http://www.parallax.com/product/28380&quot; rel=&quot;nofollow&quot;&gt;ColorPal 20380&lt;/a&gt;, which individually, work as intended with some reflective material. The &lt;a href=&quot;http://learn.parallax.com/colorpal-arduino-demo&quot; rel=&quot;nofollow&quot;&gt;demo&lt;/a&gt; gives no problem, but I am confused as to how to approach activating all the 3 sensors and reading the 3 different sets of values so that I can analyze them in a program on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I get all three sensors to output data to my program in parallel?&lt;/strong&gt; I want to use the values at the same point in time on all three sensors to do some calculations in my program. Should I approach something like a state machine? Or at least near-parallel (a few ms delay is fine too)? How would an example look like?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most confusing thing for me is the non-inverted, open-drain protocol it uses. From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because of the open-drain protocol, the pin used to communicate with the ColorPAL should always be configured as an input, except when being driven low. Also, when starting up, you should wait for this pin to be pulled high by the ColorPAL before trying to send it any commands.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried modifying the demo to something silly in sequence like this just to see how it would work in the Arduino but I got nothing (pins 2, 4 and 6 are the data pins):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* ColorPal Sensor Example for Arduino&#xA;  Author: Martin Heermance, with some assistance from Gordon McComb&#xA;  This program drives the Parallax ColorPAL color sensor and provides&#xA;  serial RGB data in a format compatible with the PC-hosted &#xA;  TCS230_ColorPAL_match.exe color matching program.&#xA;*/&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int sio = 0;            &#xA;const int unused = 255;         // Non-existant pin # for SoftwareSerial&#xA;const int sioBaud = 4800;&#xA;const int waitDelay = 10;&#xA;&#xA;// Received RGB values from ColorPAL&#xA;int red;&#xA;int grn;&#xA;int blu;&#xA;&#xA;// Set up two software serials on the same pin.&#xA;SoftwareSerial serin = SoftwareSerial(sio, unused);&#xA;SoftwareSerial serout = SoftwareSerial(unused, sio);&#xA;&#xA;void setup() {&#xA;&#xA;  // Unoptimized setup&#xA;&#xA;      sio = 2;&#xA;      serin = SoftwareSerial(2, unused);&#xA;      serout = SoftwareSerial(unused, 2);&#xA;      Serial.begin(9600);&#xA;      reset();                // Send reset to ColorPal&#xA;      serout.begin(sioBaud);&#xA;      pinMode(2, OUTPUT);&#xA;      serout.print(&quot;= (00 $ m) !&quot;);       // Loop print values, see ColorPAL documentation&#xA;      serout.end();           // Discontinue serial port for transmitting&#xA;&#xA;      serin.begin(sioBaud);           // Set up serial port for receiving&#xA;      pinMode(2, INPUT);&#xA;&#xA;      sio = 4;&#xA;      serin = SoftwareSerial(4, unused);&#xA;      serout = SoftwareSerial(unused, 4);&#xA;      Serial.begin(9600);&#xA;      reset();                &#xA;      serout.begin(sioBaud);&#xA;      pinMode(4, OUTPUT);&#xA;      serout.print(&quot;= (00 $ m) !&quot;); &#xA;      serout.end();          &#xA;&#xA;      serin.begin(sioBaud);    &#xA;      pinMode(4, INPUT);&#xA;&#xA;      sio = 6;&#xA;      serin = SoftwareSerial(6, unused);&#xA;      serout = SoftwareSerial(unused, 6);&#xA;      Serial.begin(9600);&#xA;      reset();               &#xA;      serout.begin(sioBaud);&#xA;      pinMode(6, OUTPUT);&#xA;      serout.print(&quot;= (00 $ m) !&quot;); &#xA;      serout.end();         &#xA;&#xA;      serin.begin(sioBaud);     &#xA;      pinMode(6, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  sio = 2;&#xA;  serin = SoftwareSerial(sio, unused);&#xA;  serout = SoftwareSerial(unused, sio);&#xA;  readData();&#xA;&#xA;  sio = sio + 2;&#xA;  serin = SoftwareSerial(sio, unused);&#xA;  serout = SoftwareSerial(unused, sio);&#xA;  readData();&#xA;&#xA;  sio = sio + 2;&#xA;  serin = SoftwareSerial(sio, unused);&#xA;  serout = SoftwareSerial(unused, sio);&#xA;  readData();&#xA;}  &#xA;&#xA;// Reset ColorPAL; see ColorPAL documentation for sequence&#xA;void reset() {&#xA;  delay(200);&#xA;  pinMode(sio, OUTPUT);&#xA;  digitalWrite(sio, LOW);&#xA;  pinMode(sio, INPUT);&#xA;  while (digitalRead(sio) != HIGH);&#xA;  pinMode(sio, OUTPUT);&#xA;  digitalWrite(sio, LOW);&#xA;  delay(80);&#xA;  pinMode(sio, INPUT);&#xA;  delay(waitDelay);&#xA;}&#xA;&#xA;void readData() {&#xA;  char buffer[32];&#xA;&#xA;  if (serin.available() &amp;gt; 0) {&#xA;    // Wait for a $ character, then read three 3 digit hex numbers&#xA;    buffer[0] = serin.read();&#xA;    if (buffer[0] == '$') {&#xA;      for(int i = 0; i &amp;lt; 9; i++) {&#xA;        while (serin.available() == 0);     // Wait for next input character&#xA;        buffer[i] = serin.read();&#xA;        if (buffer[i] == '$')               // Return early if $ character encountered&#xA;          return;&#xA;      }&#xA;      parseAndPrint(buffer);&#xA;      delay(10);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;// Parse the hex data into integers&#xA;void parseAndPrint(char * data) {&#xA;  sscanf (data, &quot;%3x%3x%3x&quot;, &amp;amp;red, &amp;amp;grn, &amp;amp;blu);&#xA;  char buffer[32];&#xA;  sprintf(buffer, &quot;R%4.4d G%4.4d B%4.4d&quot;, red, grn, blu);&#xA;  Serial.println(buffer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1692" LastActivityDate="2016-06-07T01:10:22.280" Title="Read data from 3 ColorPal 28380 simultaneously on Uno/Mega" Tags="|arduino-uno|arduino-mega|c|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4977" PostTypeId="1" AcceptedAnswerId="4992" CreationDate="2014-11-13T22:23:41.270" Score="5" ViewCount="1620" Body="&lt;p&gt;Basic question: How far do I have to go to assure that integer math is done correctly? For example, this is probably overdone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long burnTime = 0UL;&#xA;unsigned long curBurnTime = 0UL;&#xA;// Do some stuff that sets the above variables to millis() at various times&#xA;// Later on...&#xA;unsigned long adjustedBurnTime = (unsigned long) ((burnTime + curBurnTime) / 1000UL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would the math be done correctly if I went to a more minimal last statement (since all the elements of the equation are unsigned longs)? Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long adjustedBurnTime = ((burnTime + curBurnTime) / 1000UL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long adjustedBurnTime = ((burnTime + curBurnTime) / 1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4807" LastEditorUserId="4807" LastEditDate="2014-11-14T00:58:17.067" LastActivityDate="2014-11-23T14:23:41.930" Title="Assuring an unsigned long int?" Tags="|variables|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="4978" PostTypeId="2" ParentId="4976" CreationDate="2014-11-13T23:02:23.313" Score="1" Body="&lt;p&gt;I'm doing something similar with you right now. I'm troubleshooting this right now so we can collaborate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, even though you have setup 3 pins, you're only telling the Arduino to read only 1 sensor because they're using the same variable (pin6 since it's the last one you set up). You have to declare each pin with a different variable then create 2 more readData() functions to read each pin as a start. But even after I set it up with that, it only read one colorpal. Reading up a little more on the Uno board, it seems that only pin 2 and 3 can do serial interrupt which we need to use to communicate with the ColorPal. I'm not 100% sure as I'm a novice still, but from what my analysis and research shows, that's the problem right now. I'll update if I find anything.&lt;/p&gt;&#xA;" OwnerUserId="4808" LastActivityDate="2014-11-13T23:02:23.313" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4979" PostTypeId="1" AcceptedAnswerId="4991" CreationDate="2014-11-14T01:49:19.487" Score="0" ViewCount="6294" Body="&lt;p&gt;I am creating a tiny game on my Arduino UNO with an Adafruit ST7735 1.8&quot; TFT / SD breakout. I am performing screen operations using the built-in TFT-library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is screen flickering. Even though I take care to prepare data and minimize the time between clearing the screen and writing the new stuff to it, the screen &quot;refresh()&quot; is significant. I heard someone mention something called double buffering, so I read a bit up on it, but I am frankly clueless on how to implement it on an Arduino UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to implement double buffering on an Arduino UNO to prevent screen flickering, and if so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Libraries used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TFT.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;The screen is &quot;cleared&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screen.background(0,0,0);  // Clear it&#xA;screen.text(buf, 10, 25);  // Write new stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4783" LastEditorUserId="4783" LastEditDate="2016-09-05T10:00:52.720" LastActivityDate="2016-09-05T13:16:36.327" Title="How can I implement double buffering with an Arduino UNO?" Tags="|arduino-uno|display|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4981" PostTypeId="2" ParentId="4782" CreationDate="2014-11-14T04:09:08.357" Score="0" Body="&lt;p&gt;try using this example instead of iostream you can use iostream.h too..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;using namespace std;&#xA;&#xA;int sum (int a, int b)&#xA;{&#xA;  return a+b;&#xA;}&#xA;&#xA;double sum (double a, double b)&#xA;{&#xA;  return a+b;&#xA;}&#xA;&#xA;int main ()&#xA;{&#xA;  cout &amp;lt;&amp;lt; sum (10,20) &amp;lt;&amp;lt; '\n';&#xA;  cout &amp;lt;&amp;lt; sum (1.0,1.5) &amp;lt;&amp;lt; '\n';&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4813" LastActivityDate="2014-11-14T04:09:08.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4982" PostTypeId="1" AcceptedAnswerId="4985" CreationDate="2014-11-14T05:55:10.493" Score="0" ViewCount="6353" Body="&lt;p&gt;I want to split this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* value = &quot;12;32;blue&quot;;&#xA;or&#xA;string value = &quot;12;32;blue&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into this vars:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TV = 12;&#xA;AR = 32;&#xA;LED = &quot;blue&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is it possible?&lt;/p&gt;&#xA;" OwnerUserId="3313" LastEditorUserId="3313" LastEditDate="2014-11-14T06:28:56.087" LastActivityDate="2014-11-16T11:15:28.957" Title="How to split in string" Tags="|arduino-mega|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4983" PostTypeId="1" AcceptedAnswerId="4989" CreationDate="2014-11-14T06:28:10.037" Score="0" ViewCount="1220" Body="&lt;p&gt;I have a water flow sensor with Arduino Megs 2560 board. I am trying to conceptualize the concept to calculate amount of water getting dispensed esp. in 1,2,3,4 and 5 liters quantity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Water flow sensor specification:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would connect the sensor input to any pin from 22-53 pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose I connect to ping 23 so in my setup() function I would add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(23, pulseCounter, FALLING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where pulseCounter is an interrupt function triggered on each signal generated from sensor and increments a variable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void pulseCounter()&#xA;{&#xA;  // Increment the pulse counter&#xA;  pulseCount++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now how do I calculate the flowrate and water dispensed in milliliters using this information?  How do I know the freqz of the MCU (which is required as water dispensed per pulse is different for different MCUs)?&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2014-11-14T08:27:12.363" LastActivityDate="2014-11-15T11:43:23.033" Title="Measure Water Flow in literes using Arduino Mega 2560 Board and Water Flow Sensor" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4984" PostTypeId="2" ParentId="4982" CreationDate="2014-11-14T07:34:54.273" Score="3" Body="&lt;p&gt;Scan function should do the job.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int tv, ar;&#xA;char color[10];&#xA;sscanf(value, &quot;%d;%d;%s&quot;, &amp;amp;tv, &amp;amp;ar, color);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3825" LastEditorUserId="3825" LastEditDate="2014-11-16T11:15:28.957" LastActivityDate="2014-11-16T11:15:28.957" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="4985" PostTypeId="2" ParentId="4982" CreationDate="2014-11-14T07:45:39.233" Score="2" Body="&lt;p&gt;For C-strings (&lt;code&gt;char*&lt;/code&gt;), your best option (in terms of performance and memory consumption) is to use &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strtok/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;strtok&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* value = &quot;12;32;blue&quot;;&#xA;char* token = strtok(value, &quot;;&quot;);&#xA;int TV = atoi(token);&#xA;token= strtok(0, &quot;;&quot;);&#xA;int AR = atoi(token);&#xA;token = strtok(0, &quot;;&quot;);&#xA;char* LED = token;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 1&lt;/strong&gt;: the code above takes it for granted that &lt;code&gt;value&lt;/code&gt; is properly formatted, i.e. contains 3 parts split by &lt;code&gt;;&lt;/code&gt;. If it is not sure, then you should add additional checks on &lt;code&gt;token&lt;/code&gt; value returned by &lt;code&gt;strtok&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 2&lt;/strong&gt;: &lt;code&gt;strtok&lt;/code&gt; is modifiying its &lt;code&gt;value&lt;/code&gt; argument, so that at the end of the code above, &lt;code&gt;value&lt;/code&gt; will not be equal to &lt;code&gt;12;32;blue&lt;/code&gt; any longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note 3&lt;/strong&gt;: &lt;code&gt;LED&lt;/code&gt; variable above will point directly to the character &lt;code&gt;b&lt;/code&gt; inside &lt;code&gt;value&lt;/code&gt;, which means that if &lt;code&gt;value&lt;/code&gt; is modified afterwards, &lt;code&gt;LED&lt;/code&gt; might be modified as well.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-11-14T07:45:39.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4988" PostTypeId="2" ParentId="4930" CreationDate="2014-11-14T13:16:28.587" Score="2" Body="&lt;p&gt;I'm the maintainer of the Bare-Arduino-Project, thanks for using it :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you installed &lt;code&gt;pyserial&lt;/code&gt; and &lt;code&gt;avrdude&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install &lt;code&gt;avrdude&lt;/code&gt; just run &lt;code&gt;brew install avrdude&lt;/code&gt; and to install &lt;code&gt;pyserial&lt;/code&gt;, you need &lt;code&gt;python installed&lt;/code&gt;, then you can run &lt;code&gt;pip install pyserial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/WeAreLeka/Bare-Arduino-Project/blob/master/INSTALL.md#3-install-pyserial&quot; rel=&quot;nofollow&quot;&gt;https://github.com/WeAreLeka/Bare-Arduino-Project/blob/master/INSTALL.md#3-install-pyserial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next time, feel free to open an issue in the Github repo as it might also help others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; my bad, I did not read your Makefile carefully!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the problem is with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BOARD_TAG         = mega328&#xA;# it should be&#xA;BOARD_TAG         = uno&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3547" LastActivityDate="2014-11-14T13:16:28.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4989" PostTypeId="2" ParentId="4983" CreationDate="2014-11-14T13:20:58.643" Score="0" Body="&lt;p&gt;the pulse rate can be derived without knowledge of the CPU clock speed. To achieve the pulse rate from your sensor input you can do two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;count the pulses &lt;strong&gt;dn&lt;/strong&gt; within a certain (i.e. fixed) interval &lt;strong&gt;T&lt;/strong&gt; of time) or&lt;/li&gt;&#xA;&lt;li&gt;measure the time &lt;strong&gt;dt&lt;/strong&gt; between two pulses.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'll come back later on this concerning accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To measure time, you can use the function millis(). This function returns you the milliseconds since bootup as an integer upon calling it. Method 2 is rather simple to implement. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setup three global integers &lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt; and &lt;em&gt;c&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;At the end of setup set &lt;em&gt;a&lt;/em&gt; to current millis();&lt;/li&gt;&#xA;&lt;li&gt;In your ISR set b to current millis();&lt;/li&gt;&#xA;&lt;li&gt;Also in ISR: set a=b;&lt;/li&gt;&#xA;&lt;li&gt;calculate &lt;em&gt;c=b-a&lt;/em&gt; (i.e. your &lt;strong&gt;dt&lt;/strong&gt;);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;c holds your current full wave pulse length in milliseconds, which is updated every pulse. You can derive your flow then from it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first method uses a counter as demonstrated in your suggestion. You then need a timer outside your ISR, two variables &lt;em&gt;d&lt;/em&gt; and &lt;em&gt;e&lt;/em&gt;. Either you poll millis() in your main &quot;loop()&quot; or you install a timer interrupt, both will work here. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;At the end of setup set &lt;em&gt;d&lt;/em&gt; to current millis();&lt;/li&gt;&#xA;&lt;li&gt;If your predefined time &lt;strong&gt;T&lt;/strong&gt; is passed (by comparing &lt;em&gt;d&lt;/em&gt; with millis(), &lt;/li&gt;&#xA;&lt;li&gt;save your counted pulses to &lt;em&gt;e=pulseCount&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;reset: &lt;em&gt;pulseCount=0&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;e&lt;/em&gt; holds your pulse count during interval &lt;strong&gt;T&lt;/strong&gt;, from which you can derive your pulse rate.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Accuracy&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Method 1's accuracy increases with higher &lt;strong&gt;T&lt;/strong&gt; and higher flow speeds. Therefore the update rate of your measurement is low. By changing &lt;strong&gt;T&lt;/strong&gt; you can easily increase accuracy on cost of responsiveness. This is perhaps a good idea, if you have pulsating flows in your tubings, or the sensor is a bit rattling. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Method 2's accuracy increases with lower flow speeds. It is best to measure very low flow speeds. Update frequency is minimal (1/&lt;strong&gt;dt&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding this sensor you should calibrate it yourself. It is a cheap and rugged device (I'm using it, too), but its output depends on several parameters like mounting position, fluid viscosity and so on. Make sure, there are no bubbles, foam or contaminants in your fluid systems as they garble the results effectively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;n.b.: make sure to take care of an overflow of millis(). &lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2014-11-15T11:43:23.033" LastActivityDate="2014-11-15T11:43:23.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4990" PostTypeId="2" ParentId="3700" CreationDate="2014-11-14T18:16:18.613" Score="4" Body="&lt;p&gt;I used a terminal command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ln -s /dev/tty.wch\ ch341\ USB\=\&amp;gt;RS232\ 1450 /dev/tty.USB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;/dev/tty.wch\ ch341\ USB\=\&amp;gt;RS232\ 1450&lt;/code&gt; is the original name not recognized by Arduino; and &lt;code&gt;/dev/tty.USB0&lt;/code&gt; is the new port name.&lt;/p&gt;&#xA;" OwnerUserId="4818" LastEditorUserId="6936" LastEditDate="2015-07-20T21:40:17.950" LastActivityDate="2015-07-20T21:40:17.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4991" PostTypeId="2" ParentId="4979" CreationDate="2014-11-14T21:52:30.980" Score="4" Body="&lt;p&gt;If you're already preparing the next screen's-worth of data before you clear the screen, then double buffering won't help. In that case, the time taken to re-write the screen data is what causes the flicker, and the only way to improve it is to write the screen faster. If the software is to blame, it will be in screen.text(). If the software is already driving the hardware as fast as the hardware will go, then that's the best you can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Double-buffering would let you prepare the next screen while the currently-prepared one is loading (and will require interrupt-driven I/O to do it). The result would be more screen refreshes per unit time, but it doesn't sound like that is your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One easy experiment to try is to not clear the screen before you re-write it, if that is possible to do. Then your next screen will overlay the current screen with (we hope...) no blanking period. That might prevent the blinking.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-11-14T21:52:30.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4992" PostTypeId="2" ParentId="4977" CreationDate="2014-11-14T21:58:46.453" Score="3" Body="&lt;p&gt;Any good C manual will tell you the result type for each basic math operation on given types. But briefly, the basic math operators return a result as wide as the widest operand, with the narrower operand being widened to match the wider one, if they differ. The same with assignment: assigning a result of a given type to a variable of the same type will not involve any conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr: No, you're not missing anything. You don't need any casts in your example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: One thing you do need to be aware of is whether any of your intermediate results will overflow the arithmetic type you're using. For example, the final result may be not exceed an unsigned long but the expressions &lt;code&gt;(burnTime + curBurnTime)&lt;/code&gt; must also not exceed it. This is a greater concern with smaller data-types, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS: Good on you for tackling fixed point arithmetic rather than just reaching for the floating-point library!&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-11-23T14:23:41.930" LastActivityDate="2014-11-23T14:23:41.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="4993" PostTypeId="2" ParentId="3179" CreationDate="2014-11-14T22:54:26.460" Score="2" Body="&lt;p&gt;Its possible you may have disabled the &lt;code&gt;SPIEN&lt;/code&gt; or the &lt;code&gt;RSTDISBL&lt;/code&gt; fuses. The only way to check and fix is to use a High Voltage Programmer like the STK500, STK600 or AVR Dragon and see. I have the AVR Dragon and it saved me a few times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, do a search for &lt;a href=&quot;http://mdiy.pl/atmega-fusebit-doctor-hvpp/?lang=en&quot; rel=&quot;nofollow&quot;&gt;AVR Fuse Doctor&lt;/a&gt;. Its a homemade fuse repair device. Pretty cool. But save yourself some time and invest in a programmer/debugger that has HVPP (high voltage parallel programming) and HVSP (high voltage serial programming). You won't regret it.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2014-11-14T22:54:26.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4995" PostTypeId="2" ParentId="4952" CreationDate="2014-11-15T09:24:18.233" Score="1" Body="&lt;p&gt;After studying the datasheet differences between &lt;strong&gt;MCP41100&lt;/strong&gt; (digital pot used in the tutorial) and &lt;strong&gt;MCP4131&lt;/strong&gt; (the one you get), I found &lt;strong&gt;two major differences&lt;/strong&gt; between both:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Difference in &lt;strong&gt;resolution&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MCP41100 has &lt;strong&gt;257 steps&lt;/strong&gt; resolution (8 bits + 1): you can see that at the beginning of &lt;a href=&quot;http://www.futurlec.com/SFMicrochip/MCP41100.shtml&quot; rel=&quot;nofollow&quot;&gt;its datasheet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;MCP4131 has only &lt;strong&gt;129 steps&lt;/strong&gt; resolution (7 bits + 1): you can get this information on page 2 of &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/22060b.pdf&quot; rel=&quot;nofollow&quot;&gt;its datasheet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Difference in &lt;strong&gt;commands formats&lt;/strong&gt; sent through SPI; both use one &quot;command byte&quot; followed by a &quot;data byte&quot;, but have a diffrent format for their command byte:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MCP41100 command byte is &lt;code&gt;X X C1 C0 X X P1 P0&lt;/code&gt; where &lt;code&gt;X is unused&lt;/code&gt;, &lt;code&gt;C1 C0&lt;/code&gt; is one of 4 possible commands,  only 2 being valid commands actually: &lt;code&gt;01&lt;/code&gt; (Write data), &lt;code&gt;10&lt;/code&gt; (Shutdown), finally &lt;code&gt;P1 P0&lt;/code&gt; should be always &lt;code&gt;01&lt;/code&gt; for an MCP41100&lt;/li&gt;&#xA;&lt;li&gt;MCP4131 command byte is &lt;code&gt;AD3 AD2 AD1 AD0 C1 C0 D9 D8&lt;/code&gt;, where &lt;code&gt;AD3-AD0&lt;/code&gt; is the address of the &quot;register&quot; on which to perfom a command. For the MCP4131, the most important address is &lt;code&gt;00&lt;/code&gt; which means &quot;volatile wiper 0&quot; (this is what allows you to change the resistance value of the pot), &lt;code&gt;C1 C0&lt;/code&gt; is one of 4 possible commands (read data, write data, increment, decrement), in your example the command should be &lt;code&gt;00&lt;/code&gt; (write data); finally &lt;code&gt;D9 D8&lt;/code&gt; are the high order bits of the value to write to the register, but &lt;code&gt;D9&lt;/code&gt; is unused and should always be &lt;code&gt;0&lt;/code&gt;. For 257-steps pots, &lt;code&gt;D8&lt;/code&gt;is used to have the full resistance scale, otherwise it should be &lt;code&gt;0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now that we know aht your MCP4131 expects as commands passed through SPI, we can take a look at what the tutorial program passes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00010001 value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first byte can be broken down as such:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0001&lt;/code&gt; address of the pot &lt;strong&gt;wiper register 1&lt;/strong&gt; (&lt;strong&gt;not 0&lt;/strong&gt;): this wiper does not exist on MCP4131 hecne writing to it will have no impact...&lt;/li&gt;&#xA;&lt;li&gt;00 command bits meaning &quot;Write to register specified in previous address&quot;&lt;/li&gt;&#xA;&lt;li&gt;01 high order bits (D9-D8) of the value to write to the wiper register.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Although I don't have an MCP4131 at hand, I think you should adapt the program as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte address = 0x00;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that should be fine! Indeed, now your program passes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000000 value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which means &quot;write &lt;code&gt;value&lt;/code&gt; (between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;128&lt;/code&gt; which matches exactly the 129 steps resolution) to the wiper register 0 of the port&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the MCP4131 has more features than the MCP41100 in terms of commands, for instance you could use the special commands &quot;increment&quot; and &quot;decrement&quot;, with the advantage they need only one byte (the command byte), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    for (i = 0; i &amp;lt;= 128; i++)&#xA;    {&#xA;      digitalPotIncrement();&#xA;      delay(10);&#xA;    }&#xA;    delay(500);&#xA;    for (i = 128; i &amp;gt;= 0; i--)&#xA;    {&#xA;      digitalPotDecrement();&#xA;      delay(10);&#xA;    }&#xA;}&#xA;&#xA;void digitalPotIncrement()&#xA;{&#xA;  digitalWrite(CS, LOW);&#xA;  SPI.transfer(0x04);&#xA;  digitalWrite(CS, HIGH);&#xA;}&#xA;&#xA;void digitalPotDecrement()&#xA;{&#xA;  digitalWrite(CS, LOW);&#xA;  SPI.transfer(0x08);&#xA;  digitalWrite(CS, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-11-15T09:24:18.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="4997" PostTypeId="1" AcceptedAnswerId="4999" CreationDate="2014-11-15T12:03:06.363" Score="0" ViewCount="53" Body="&lt;p&gt;I want to use a proto shield (brand is unimportant) and solder some components to it, to make something more premanent than using a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is can the components be soldered directly to the middle area where there are a lot of small holes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would assume this is possible, but everywhere I look people add mini breadboards to their proto shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's possible, then I assume components and wires can't just be connected in a row like on a breadboard and would instead need some solder between 2 holes where for example a component and seperate wire are connected?&lt;/p&gt;&#xA;" OwnerUserId="4175" LastEditorUserId="4175" LastEditDate="2014-11-15T12:08:22.673" LastActivityDate="2014-11-15T16:26:47.583" Title="Proto Shields wthout breadboard?" Tags="|prototype|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4998" PostTypeId="1" CreationDate="2014-11-15T12:53:22.517" Score="2" ViewCount="402" Body="&lt;p&gt;I'm using an Arduino Uno with Funduino I2C 1602 LCD display. The LCD display is connected as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LCD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCL--&gt; A5&#xA;SDA --&gt;A4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to measure the temperature, pressure and the velocity of a duct flow. So I connected a BMP180 to my arduino with the following connection&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCL--&gt; A5&#xA;SDA --&gt;A4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, both of them are connected to same pins. The connection works fine just for BMP180 but when I add a rotary encoder and print its value on LCD, I'm getting delayed and wrong data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using this BMP180 library &#xA;&lt;a href=&quot;https://github.com/adafruit/Adafruit_BMP085_Unified&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_BMP085_Unified&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD uses this library (v1.2.0)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can I change bmp180 or LCD analog pins in these libraries?&lt;/p&gt;&#xA;" OwnerUserId="4826" LastActivityDate="2014-11-15T12:53:22.517" Title="Custom Library Pin Change" Tags="|pins|library|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="4999" PostTypeId="2" ParentId="4997" CreationDate="2014-11-15T16:26:47.583" Score="1" Body="&lt;p&gt;There are many different types of photo-shields, sometimes they have interconnected rows or they just have individual solder holes or even breadboards.  What you get all depends on what you are doing.  My personal favorite are the interlocked rows so I buy that and use a breadboard while I am developing my project then take off the breadboard and solder everything into place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00K992NTI&quot; rel=&quot;nofollow&quot;&gt;Example of non interlocked rows&lt;/a&gt;  and an &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B006SJSBBM&quot; rel=&quot;nofollow&quot;&gt;My favorite proto-shield, it has a little of both kinds&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1192" LastActivityDate="2014-11-15T16:26:47.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5000" PostTypeId="2" ParentId="4603" CreationDate="2014-11-15T16:40:22.590" Score="0" Body="&lt;p&gt;You should consider bringing the voltage down to 5v thats very important, when a car is running as stated above the voltage will increase because the battery is no longer running the electronics, the alternator powers everything and charges the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of trying to control this strait from the Arduino, use a transistor such as the TIP 120 darlington in order to control the existing light or you can put in a new one if you want.  This gives you the ability to add more powerful lights or add more lights to the circuit, which the Arduino would not be able to power via pwm.&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="1192" LastEditDate="2015-04-29T01:28:00.047" LastActivityDate="2015-04-29T01:28:00.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5001" PostTypeId="1" CreationDate="2014-11-15T17:11:29.433" Score="0" ViewCount="1487" Body="&lt;p&gt;Is it possible to use an Arduino, connected to a 3 axis accelerometer, to estimate a platform's continuous change in position and orientation? I have a small mobile robot, and given an initial position and velocity vector and sequence of acceleration changes, I'd like to calculate the current position and velocity vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://electronics.stackexchange.com/questions/110506/dead-reckoning-with-accelerometer-gyro-possible&quot;&gt;this question&lt;/a&gt;, it sounds possible, but I can't find any reference to projects or code to accomplish it with an Arduino. I understand the main problem will be the build-up of errors over time, but that's ok, as a rough estimate is acceptable. I'm also using wheel encoders to calculate the same values, and I want to use the accelerometer to account for errors in the encoders, like slippage. e.g. If the encoders say we're accelerating at 1cm/sec but the accelerometer says we're at a constant speed, then I know to ignore the encoders because the wheels are probably slipping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the math behind this, so the problem is how to write it in C to run on an Arduino. Is anyone aware of existing open source code for something like this? I'd like to avoid reinventing the wheel in-case anyone's implemented a similar system.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-16T18:38:28.073" Title="Dead reckoning with an accelerometer" Tags="|arduino-uno|sensors|accelerometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5002" PostTypeId="1" CreationDate="2014-11-15T19:47:03.567" Score="1" ViewCount="2654" Body="&lt;p&gt;I am trying to run a test of the speed of an Arduino, and how it's affected by different temperatures. Does the following code assess this properly? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long num = 0;&#xA;long startTime = 0;&#xA;long endTime = 0;&#xA;int duration = 0;&#xA;String buffer;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  startTime = millis();&#xA;  benchmark();&#xA;  endTime = millis();&#xA;  duration = endTime - startTime;&#xA;  Serial.print(startTime);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(endTime);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.println(duration); &#xA;}&#xA;&#xA;void benchmark() {&#xA;  num = 0;&#xA;  for(num = 0; num &amp;lt; 1000000; num++);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using an Uno, if that matters.&lt;/p&gt;&#xA;" OwnerUserId="4830" LastActivityDate="2014-11-18T05:56:22.977" Title="How do you benchmark an Arduino?" Tags="|arduino-uno|serial|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5003" PostTypeId="2" ParentId="5002" CreationDate="2014-11-15T20:23:39.660" Score="2" Body="&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is because millis will be equally affected by any frequency change (due to temperature) as the benchmark code. You would need an external clock source that is precise enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that temperature doesn't have that big an impact on crystal oscillators. Somewhere around 10ppm between -20 and +20 degrees C. The crystal itself is probably already 50ppm precision to start with (higher precision ones are more expensive).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-15T20:23:39.660" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5004" PostTypeId="2" ParentId="4925" CreationDate="2014-11-16T00:22:47.767" Score="1" Body="&lt;p&gt;I just bought 3 of these that work well with this library&#xA; &lt;a href=&quot;http://arduino-info.wikispaces.com/file/detail/LiquidCrystal_I2C2004V1.zip&quot; rel=&quot;nofollow&quot;&gt;LiquidCrystal_I2C2004V1.zip&lt;/a&gt;&lt;br&gt;&#xA;(&lt;em&gt;License: CC BY-NC 2012 &lt;a href=&quot;http://www.wikispaces.com/user/view/TerryKing&quot; rel=&quot;nofollow&quot;&gt;http://www.wikispaces.com/user/view/TerryKing&lt;/a&gt;&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When installing this library in Arduino IDE (version 1.6 or later), use menu item &lt;strong&gt;Sketch | Include&amp;nbsp;Library | Add&amp;nbsp;.ZIP&amp;nbsp;Library...&lt;/strong&gt;, navigate to the folder where LiquidCrystal_I2C2004V1.zip was downloaded, and then open the zip file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the I2C address in the example &quot;HelloWorld&quot; supplied with LiquidCrystal_I2C2004V1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//YWROBOT&#xA;//Compatible with the Arduino IDE 1.0&#xA;//Library version:1.1&#xA;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.init();                      // initialize the lcd &#xA;  lcd.init();&#xA;  // Print a message to the LCD.&#xA;  lcd.backlight();&#xA;  lcd.setCursor(3,0);&#xA;  lcd.print(&quot;Hello, world!&quot;);&#xA;  lcd.setCursor(2,1);&#xA;  lcd.print(&quot;Ywrobot Arduino!&quot;);&#xA;   lcd.setCursor(0,2);&#xA;  lcd.print(&quot;Arduino LCM IIC 2004&quot;);&#xA;   lcd.setCursor(2,3);&#xA;  lcd.print(&quot;Power By Ec-yuan!&quot;);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not change the other library directory name; this one is compatible with the existing library. Just add it as a contributed library.&lt;/p&gt;&#xA;" OwnerUserId="4832" LastEditorUserId="10794" LastEditDate="2016-01-28T06:36:17.920" LastActivityDate="2016-01-28T06:36:17.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5005" PostTypeId="1" CreationDate="2014-11-16T00:24:12.097" Score="0" ViewCount="299" Body="&lt;p&gt;How can we increase the Arduino's ADC sampling rate to 1 MHz while maintaining a 10 bit resolution? Can we change the prescaler to 16 to get 1 MHz ADC clock?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, what alternatives are there? Another Atmel chip that works with the Arduino library? Or any external ADC?&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2014-11-16T00:55:13.620" Title="MHz Sampling Rate for Arduino" Tags="|arduino-uno|library|analogread|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5007" PostTypeId="2" ParentId="5005" CreationDate="2014-11-16T00:55:13.620" Score="3" Body="&lt;p&gt;The problem with driving the ADC faster is that the S+H circuit won't have enough time to reach the final value before the conversion is performed, meaning that precision will be lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best thing to do would be to use an external ADC from e.g. TI or Microchip that has the capabilities you're looking for.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-16T00:55:13.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5008" PostTypeId="1" CreationDate="2014-11-16T02:21:35.250" Score="1" ViewCount="5971" Body="&lt;p&gt;I am using an Arduino Mega and an Arduino GSM shield. I am using the receive SMS example under GSM in the Arduino IDE. My GSM shield's hardware IP is set correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sketch:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; SMS receiver&#xA;&#xA; This sketch, for the Arduino GSM shield, waits for a SMS message&#xA; and displays it through the Serial port.&#xA;&#xA; Circuit:&#xA; * GSM shield attached to and Arduino&#xA; * SIM card that can receive SMS messages&#xA;&#xA; created 25 Feb 2012&#xA; by Javier Zorzano / TD&#xA;&#xA; This example is in the public domain.&#xA;&#xA; http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS&#xA;&#xA;*/&#xA;&#xA;// include the GSM library&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;// PIN Number for the SIM&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// initialize the library instances&#xA;GSM gsmAccess;&#xA;GSM_SMS sms;&#xA;&#xA;// Array to hold the number a SMS is retreived from&#xA;char senderNumber[20];&#xA;&#xA;void setup() {&#xA;  // initialize serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;&#xA;  // Start GSM connection&#xA;  while (notConnected) {&#xA;    if (gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;      notConnected = false;&#xA;    else {&#xA;      Serial.println(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(&quot;GSM initialized&quot;);&#xA;  Serial.println(&quot;Waiting for messages&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  char c;&#xA;&#xA;  // If there are any SMSs available()&#xA;  if (sms.available()) {&#xA;    Serial.println(&quot;Message received from:&quot;);&#xA;    // Get remote number&#xA;    sms.remoteNumber(senderNumber, 20);&#xA;    Serial.println(senderNumber);&#xA;    // An example of message disposal&#xA;    // Any messages starting with # should be discarded&#xA;    if (sms.peek() == '#') {&#xA;      Serial.println(&quot;Discarded SMS&quot;);&#xA;      sms.flush();&#xA;    }&#xA;&#xA;    // Read message bytes and print them&#xA;    while (c = sms.read())&#xA;      Serial.print(c);&#xA;    Serial.println(&quot;\nEND OF MESSAGE&quot;);&#xA;&#xA;    // Delete message from modem memory&#xA;    sms.flush();&#xA;    Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is this line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if (gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial monitor outputs everything until that line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It just never gets past it, so I assume it cannot connect? The SIM has no pin code: I have tried it with my phone. The SIM has full signal strength when in my phone. I have tried my other SIM card also but the same thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seem to be the same question, yet no answer:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=270551.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=270551.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4834" LastEditorUserId="37523" LastEditDate="2019-08-16T17:21:31.270" LastActivityDate="2019-09-15T18:01:45.207" Title="Arduino GSM shield GSM_READY not ready ever" Tags="|arduino-mega|shields|gsm|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="5010" PostTypeId="2" ParentId="5001" CreationDate="2014-11-16T18:38:28.073" Score="3" Body="&lt;pre&gt;&lt;code&gt;for each accelerometer:&#xA;   sample the accelerometer;&#xA;   low-pass filter its values (current and recent history) to remove noise;&#xA;   multiply by the sample interval to get the velocity increment;&#xA;   add the increment to a running sum to get velocity;&#xA;&#xA;   sample the velocity (the running sum you just updated);&#xA;   maybe low-pass filter, as above;&#xA;   multiply by the sample interval, as above, to get the position increment;&#xA;   add the increment to a running sum to get position;&#xA;end;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Noise, the artifacts created by filtering, and the double summation all work against your accuracy. That said, if your problem is to sense traction or loss of it, how about sensing real velocity more directly such as by dragging an encoded but otherwise free fifth wheel? Or if circumstances allow, optically sense the velocity of the surface underneath you as an optical mouse does?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-11-16T18:38:28.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5011" PostTypeId="2" ParentId="5002" CreationDate="2014-11-16T22:13:32.637" Score="0" Body="&lt;p&gt;First of all, compiler will just remove your loop, unless you disable compiler optimization, witch will invalidate your test.&#xA;Also don't worry about clock drift; as clock also run instruction, a faster clock will also mean a faster instruction cicle, so in the end if you calculate instruction/s the value will be valid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also serial communication slowness is not a problem as you calculate the value BEFORE sending anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, exactly what you want benchmark? In your case, you should put some instruction the for, like a variable++, and then print that sum (if you don't use it, again compiler will optimize all away)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the you are bancharking for and ++. You may use a NOP() instruction, and then a float, a bitshift, a function call, and so on; you will find very different result, sometimes, sometimes compilator will trick your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then when you'll have banchamark, against what will you compare your result?&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-11-16T22:13:32.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5012" PostTypeId="1" CreationDate="2014-11-17T00:39:13.510" Score="0" ViewCount="960" Body="&lt;p&gt;At first I am sorry for my bad English.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am making robot which can do a lot of things... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect arduino on my robot with PC via USB, the robot works properly. If I use external power supply (9V battery) the robot is doing almost nothing.. The diodes are little bit blinking and sometimes dc motors make motion... And thats all. Batteries are charged. Where's the problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything I want is make into motion dc motors.. With 5V USB it works. With external power supply not (9V battery).&lt;/p&gt;&#xA;" OwnerUserId="1718" LastEditorUserId="3336" LastEditDate="2015-07-30T12:04:34.820" LastActivityDate="2015-08-25T04:34:44.163" Title="Arduino works bad when powered by 9V battery" Tags="|arduino-mega|power|motor|battery|usb|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5014" PostTypeId="1" CreationDate="2014-11-17T03:20:06.910" Score="5" ViewCount="9130" Body="&lt;p&gt;I'm successfully running a stepper from my Arduino via a ULN2003A and a secondary power supply. It uses the first four of the seven Darlington Pairs on the chip, leaving three spare.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A) Is there any reason I wouldn't be able to use one of the remaining pairs to drive a standard DC hobby motor? (For the sake of helping future visitors .. what about running three motors off the remaining three pairs?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B) Do I need anything other than to connect the motor to the chip? (The chip's board has LEDs and resistors on each of pins 1 - 4, but I don't believe they're in series and thus my guess is they can be left off.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C) The DC motor is on a PWM Pin. Is that the correct way to control its speed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The image attached shows the setup in case I haven't been clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JdOsN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(I could probably just build it and see, but I'm new to Arduino and still scared of the blue smoke if I get something wrong!)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4843" LastEditorUserId="4843" LastEditDate="2014-12-07T15:47:43.437" LastActivityDate="2014-12-07T15:47:43.437" Title="Can I use a spare Darlington Pair on my ULN2003A to drive a DC motor?" Tags="|motor|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5020" PostTypeId="2" ParentId="1421" CreationDate="2014-11-17T17:53:50.700" Score="1" Body="&lt;p&gt;If you have your Arduino on tcp/ip your answer can be found in O'Reilly's Arduino Cookbook: &lt;a href=&quot;https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-15/recipe-15-4&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Recipe 15-4&quot;&gt;Recipe 15-4&lt;/a&gt;.  As Sourcery mentioned you need to make a new page on the PHP side that spits out just the data you are looking for and then use a web client on the Arduino side to download that data.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have your Arduino on the network then you have to stick the data over the serial line.  One way would be to bake it into your source and recompile/reburn the Arduino.  A smaller hammer would be to build-in something to your Arduino sketch that can deal with getting the data via USB serial and have a shim on the computer side to pull the data from PHP and send it to the Arduino.  &lt;a href=&quot;http://www.varesano.net/blog/fabio/serial-communication-arduino-and-processing-simple-examples-and-arduino-based-gamepad-int&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial communication with Arduino and Processing&lt;/a&gt; shows something similar where he is running Processing on the computer which is passing data to the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4854" LastEditorUserId="4854" LastEditDate="2020-06-03T22:09:43.987" LastActivityDate="2020-06-03T22:09:43.987" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5021" PostTypeId="2" ParentId="5014" CreationDate="2014-11-17T19:01:05.347" Score="4" Body="&lt;p&gt;Should work just fine. But you'd have to connect the motor to the positive rail, and since the ULN2003 can only sink current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally when connecting a motor, you'd add a flyback diode. But the ULN2003 already has those inside the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PWM is the easiest way to (somewhat) control the speed of a DC motor.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-17T19:01:05.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5022" PostTypeId="1" CreationDate="2014-11-17T19:05:18.297" Score="-1" ViewCount="1471" Body="&lt;p&gt;I had problems with Arduino uno and reseted firmware. Followed this &lt;a href=&quot;http://bartruffle.blogspot.fr/2013/09/dfu-programming-atmega16u2-on-arduino.html&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;. Now I can't upload my code Arduino IDE says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried loop-back mode, everything is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firmware was located in this location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/hardware/arduino/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4856" LastEditorUserId="220" LastEditDate="2015-08-03T22:57:05.300" LastActivityDate="2016-01-31T04:45:51.530" Title="Not in sync: resp=0x00" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ClosedDate="2018-02-09T01:23:58.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="5023" PostTypeId="1" AcceptedAnswerId="5035" CreationDate="2014-11-17T19:46:37.903" Score="1" ViewCount="672" Body="&lt;p&gt;I have a simple sketch running on a BE Leonardo-compatible board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It reads input from a potentiometer, and outputs to two RGB LEDs which change colour over time - in a different pattern if certain inputs are received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, the only code is serial I/O for debug purposes.  (It's disabled using a #define in the running version, to prevent serial buffer overflow when not connected.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the board is powered by USB, everything works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the board is powered by 9V battery, after about 4 minutes it hangs - the LEDs go off, and the L13 light on the board starts glowing at varying strength.  (There is nothing connected to pin 13.)  Even the reset button doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the board is then connected to the computer's USB port, after a few seconds the hang clears and the program resumes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone offer a possible explanation for (and solution to) this fault?&lt;/p&gt;&#xA;" OwnerUserId="4858" LastActivityDate="2014-11-18T00:28:52.387" Title="Arduino hangs after 3-4 minutes on battery power, but not on USB" Tags="|arduino-leonardo|debugging|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5025" PostTypeId="1" CreationDate="2014-11-17T18:43:57.297" Score="1" ViewCount="1089" Body="&lt;p&gt;I am trying to write one code that takes data from serial &#xA;ie. &lt;code&gt;0x4E&lt;/code&gt;, &lt;code&gt;0x20&lt;/code&gt;, &lt;code&gt;0x--&lt;/code&gt;, &lt;code&gt;0x0D&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0x--&lt;/code&gt; may be any hex in &lt;code&gt;--&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The user will input these hex one by one and raspi will take all of them in buffer.&#xA;Whenever 1st, 2nd and 4th data is matched, the 3rd one will be printed in serial &#xA;ie.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(3rd); //Decimal value&#xA;else Serial.print() // may be 00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was trying with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte buffer[4];&#xA;int cnt = 0;&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; Serial.println(&quot;Start&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;&#xA; // read max 12 bytes&#xA; if ((cnt &amp;lt;= 4) &amp;amp;&amp;amp; Serial.available()) buffer[cnt++] = Serial.read();&#xA;&#xA; if (cnt == 4)  // all bytes read...&#xA; {&#xA;   // assume the arrays are the same&#xA;   boolean same = true;&#xA;&#xA;   // the ans array holds the right answer&#xA;   byte ans[]={0x4E,0x20,0x01,0x0D};&#xA;&#xA;   for (int i=0; (i&amp;lt;= 4) &amp;amp;&amp;amp; same; i++) same = (buffer[i] == ans[i]);&#xA;&#xA;   if (same)&#xA;   {&#xA;     Serial.println(&quot;Yes&quot;);&#xA;   } else {&#xA;     Serial.println(&quot;Enter another number&quot;);&#xA;   }&#xA;   Serial.flush();&#xA;   cnt = 0;&#xA; }&#xA;  //Serial.print(&quot;Done&quot;);&#xA; // do something  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I was not able to do it. Anyone have a suggestion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: I have tried this state machine in Arduino :&lt;/strong&gt;&#xA;It accepts those data and according to it, it should bi color LED light. But not working properly. Not lighting up anything&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//int currState;&#xA;//int reChk, data, confirm;&#xA;const int pingPin = 13;&#xA;int inPin = 12;&#xA;&#xA;void setup()  &#xA;{&#xA;  Serial.begin(9600);&#xA;    // initialize digital pin 13 as an output.&#xA;  pinMode(32, OUTPUT);&#xA;  pinMode(34, OUTPUT); &#xA;&#xA;  digitalWrite(32, LOW);   &#xA;  digitalWrite(34, LOW);&#xA;  //currState = 0;&#xA;  //reChk = 0;&#xA;  //confirm = -1;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  static int currState = 0, reChk = 0, confirm = -1;&#xA;  int data;&#xA;  if(reChk == 0)&#xA;  {&#xA;    //ultrasonic();&#xA;    if(Serial.available())&#xA;    data = Serial.read();&#xA;    else&#xA;    currState = 5;&#xA;  }&#xA;&#xA;  switch(currState)&#xA;  {&#xA;&#xA;    case 0:&#xA;    reChk = 0;&#xA;    if(data == 78)&#xA;      currState = 1;&#xA;    else&#xA;      currState = 0;&#xA;    break;&#xA;&#xA;&#xA;    case 1:&#xA;    reChk = 0;&#xA;    if(data == 32)&#xA;    currState = 2;&#xA;    else&#xA;    {&#xA;      currState = 0;&#xA;      reChk = 1;&#xA;    }&#xA;    break;&#xA;&#xA;&#xA;    case 2:&#xA;    reChk = 0;&#xA;    switch(confirm)&#xA;    {&#xA;      case -1 :&#xA;      confirm = data;&#xA;      currState = 3;&#xA;      break;&#xA;      case 0 :&#xA;            digitalWrite(32, LOW);   &#xA;            digitalWrite(34, LOW);&#xA;            delay(10); &#xA;      confirm = -1;&#xA;      currState = 0;&#xA;      break;&#xA;      case 1 :&#xA;            digitalWrite(34, HIGH);   &#xA;            digitalWrite(32, LOW);&#xA;            delay(10);&#xA;      confirm = -1;&#xA;      currState = 0;&#xA;      break;&#xA;      case 2 :&#xA;            digitalWrite(32, HIGH);   &#xA;            digitalWrite(34, LOW);&#xA;            delay(10); &#xA;      confirm = -1;&#xA;      currState = 0;&#xA;      break;&#xA;      default :&#xA;      confirm = -1;&#xA;      reChk = 1;&#xA;      currState = 0;&#xA;    }&#xA;&#xA;&#xA;    case 3:&#xA;    reChk = 0;&#xA;    if(data == 20)&#xA;    {&#xA;      reChk = 1;&#xA;      currState = 2;&#xA;    }&#xA;    else&#xA;    {&#xA;      confirm = -1;&#xA;      currState = 0;&#xA;    }&#xA;    break;&#xA;&#xA;    default:&#xA;    reChk = 0;&#xA;    currState = 0;&#xA;    confirm = -1;&#xA;  }&#xA;  delay(10);&#xA;}&#xA;&#xA;void ultrasonic () //ultrasonic&#xA;{&#xA;      const int pingPin = 13;&#xA;      int inPin = 12;&#xA;      //raw duration in milliseconds, cm is the&#xA;      //converted amount into a distance&#xA;      long duration, cm;&#xA;&#xA;      //initializing the pin states&#xA;      pinMode(pingPin, OUTPUT);&#xA;      //pinMode(greenLed, OUTPUT);&#xA;      //pinMode(redLed, OUTPUT); &#xA;&#xA;      //sending the signal, starting with LOW for a clean signal&#xA;      digitalWrite(pingPin, LOW);&#xA;      delayMicroseconds(2);&#xA;      digitalWrite(pingPin, HIGH);&#xA;      delayMicroseconds(5);&#xA;      digitalWrite(pingPin, LOW);&#xA;&#xA;      //setting up the input pin, and receiving the duration in&#xA;      //microseconds for the sound to bounce off the object infront&#xA;      pinMode(inPin, INPUT);&#xA;      duration = pulseIn(inPin, HIGH);&#xA;&#xA;      // convert the time into a distance&#xA;      cm = microsecondsToCentimeters(duration);&#xA;&#xA;      if(cm &amp;gt; 50)&#xA;      {&#xA;      //printing the current readings to ther serial display&#xA;      Serial.print(&quot;5&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;      Serial.print(&quot;0&quot;);&#xA;      }&#xA;      //Serial.print(&quot;cm&quot;);&#xA;      //Serial.println();&#xA;&#xA;      //checking if anything is within the safezone, if not, keep&#xA;      //green LED on if safezone violated, activate red LED instead&#xA;      //if (cm &amp;gt; safeZone)&#xA;      //{&#xA;      //  digitalWrite(greenLed, HIGH);&#xA;      //  digitalWrite(redLed, LOW);&#xA;      //}&#xA;      //else&#xA;      //{&#xA;      //  digitalWrite(redLed, HIGH);&#xA;      //  digitalWrite(greenLed, LOW);&#xA;      //}&#xA;&#xA;delay(1000);&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;// The speed of sound is 340 m/s or 29 microseconds per centimeter.&#xA;// The ping travels out and back, so to find the distance of the&#xA;// object we take half of the distance travelled.&#xA;   return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4855" OwnerDisplayName="anupam_on" LastEditorUserId="4855" LastEditDate="2014-11-18T13:12:21.963" LastActivityDate="2015-01-17T13:52:45.000" Title="Arduino Serial buffer" Tags="|serial|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5026" PostTypeId="2" ParentId="5025" CreationDate="2014-11-17T19:16:34.860" Score="1" Body="&lt;p&gt;It's unclear how the users input the hex numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i assume a simple serially attached terminal the user doesn't enter hex numbers but characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example when the user types &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, &lt;code&gt;E&lt;/code&gt; the user has only typed one hex number but already four bytes or characters. Instead the user has to type &lt;code&gt;N&lt;/code&gt;, &lt;code&gt;&lt;/code&gt;, &lt;code&gt;whatever letter&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;. (Depending on the OS or terminal you will get &quot;CR&quot;, &quot;LF&quot; or &quot;CR+LF&quot; when you press enter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with C, but your code seems to have also a coding flaw: The 3rd byte will be checked for equality too. You would need something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean same = true;&#xA;&#xA;if (buffer[0] == ans[0]) { same = false }&#xA;if (buffer[1] == ans[1]) { same = false }&#xA;if (buffer[3] == ans[3]) { same = false }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only three tests not four.&lt;/p&gt;&#xA;" OwnerDisplayName="Kitana" LastActivityDate="2014-11-17T19:16:34.860" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5028" PostTypeId="1" CreationDate="2014-11-17T20:44:21.130" Score="0" ViewCount="200" Body="&lt;p&gt;I'm using an Atmega168 in a project that involve using the ISRs from multiple sources. I have an ISR hooked up to an external button and a timer, to use it as a reset button after a predetermined hold time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also using an ISR hooked upto UART. The UART is connected to an external Linux based SoC. Upon receiving specific commands from the linux machine, the atmel will perform certain functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In very rare occasions, the linux hangs up during tranmission and is always sending out the UART commands. This saturates the ISR and it also prevents the reset button ISR to function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this happens rarely, I would like to take measures for this. As far as I know, there are no way to set priority in avr ISRs. So what can I do if the UART ISR is always called and prevents the rest of the board from functioning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I think the problem arises when the linux machine sends an empty string to the atmel.&#xA;the UART_receive() on the atmel gets stuck at: &lt;code&gt;while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) );&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way I can avoid this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char USART_Receive_string(unsigned char *x, unsigned char size)&#xA;{&#xA;unsigned char i = 0;&#xA;&#xA;if (size == 0) return 0;            // return 0 if no space&#xA;&#xA;while (i &amp;lt; size - 1) {              // check space is available (including additional null char at end)&#xA;    unsigned char c;&#xA;    while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) );  // wait for another char - WARNING this will wait forever if nothing is received&#xA;    c = UDR0;&#xA;    if (c == '\0') break;           // break on NULL character&#xA;    x[i] = c;                       // write into the supplied buffer&#xA;    i++;&#xA;}&#xA;x[i] = 0;                           // ensure string is null terminated&#xA;&#xA;return i + 1;                       // return number of characters written&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastEditorUserId="3925" LastEditDate="2014-11-19T18:49:37.790" LastActivityDate="2016-09-17T14:46:04.430" Title="Atmega168 interrupt error handling" Tags="|atmega328|uart|isr|atmel-studio|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5030" PostTypeId="1" CreationDate="2014-11-17T21:48:16.093" Score="2" ViewCount="1730" Body="&lt;p&gt;I've been working on a project where I want to transmit data from one arduino to another using an Xbee network and then parse it to update some PWM outputs accordingly (Building a system which controls some LED lamps).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is I wanted to debug the receiver using a number of Serial.print() but it appears a lot of them are &quot;ignored&quot; by the Serial Monitor. For instance, if you take a look at the image below you will notice there is a &quot;Zone:&quot; that should be displayed somewhere on screen. It isn't. I also got a Serial.print(&quot;Coucou&quot;) in the loop() that is never displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone ever encountered a bug of this kind ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TdWuB.png&quot; alt=&quot;Strange Bug&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As asked, the code that is producing the output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;Dispositif.h&amp;gt; // Custom class i wrote.&#xA;&#xA;// how much serial data we expect before a newline&#xA;const uint8_t MAX_INPUT = 196;&#xA;&#xA;//zone = 1, id = 1, idNode = 2&#xA;Dispositif dispositif;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin(9600);&#xA;  //delay(1000);&#xA;  Serial.println(&quot;Cool&quot;);&#xA;} // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data, unsigned int input_pos)&#xA;{&#xA;  uint8_t value = 0;&#xA;  uint8_t i = 1;&#xA;  uint8_t currentZone;&#xA;  char c;&#xA;&#xA;  if(data[0] != '&amp;lt;')&#xA;  {&#xA;    i = peekNextP(data);&#xA;  }&#xA;  while (data[i] != '&amp;gt;' &amp;amp;&amp;amp; i &amp;lt; input_pos - 3)&#xA;  {&#xA;    // zone&#xA;    value = 0;&#xA;    i = peekNextDigit(data, i);&#xA;    do{&#xA;      c = data[i];&#xA;      i++;&#xA;      if(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9')        // is c a digit?&#xA;        value = value * 10 + c - '0';&#xA;    } while(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9');&#xA;    currentZone = value;&#xA;    Serial.print(currentZone);&#xA;    Serial.print(F(&quot;(&quot;));&#xA;&#xA;    // 1st order&#xA;    value = 0;&#xA;    i = peekNextDigit(data, i);&#xA;    do{&#xA;      c = data[i];&#xA;      i++;&#xA;      if(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9')        // is c a digit?&#xA;        value = value * 10 + c - '0';&#xA;    } while(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9');&#xA;    Serial.print(value);&#xA;    Serial.print(F(&quot;,&quot;));&#xA;&#xA;    if (currentZone == dispositif.zone) {&#xA;      dispositif.setBrightness(0, value);&#xA;    }&#xA;    // 2nd order&#xA;    value = 0;&#xA;    i = peekNextDigit(data, i);&#xA;    do{&#xA;      c = data[i];&#xA;      ++i;&#xA;      if(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9')        // is c a digit?&#xA;        value = value * 10 + c - '0';&#xA;    } while(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9');&#xA;    Serial.print(value);&#xA;    Serial.print(F(&quot;,&quot;));&#xA;&#xA;    Serial.print(F(&quot;Zone:&quot;));&#xA;    Serial.print(dispositif.zone);&#xA;    if (currentZone == dispositif.zone)&#xA;      dispositif.setBrightness(1, value);&#xA;&#xA;    // 3nd order&#xA;    value = 0;&#xA;    i = peekNextDigit(data, i);&#xA;    do{&#xA;      c = data[i];&#xA;      ++i;&#xA;      if(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9')        // is c a digit?&#xA;        value = value * 10 + c - '0';&#xA;    } while(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9');&#xA;    Serial.print(value);&#xA;    Serial.println(F(&quot;)&quot;));&#xA;&#xA;    if (currentZone == dispositif.zone)&#xA;      dispositif.setBrightness(2, value);&#xA;  }&#xA;&#xA;}  // end of process_data&#xA;&#xA;uint8_t peekNextDigit(const char* data, uint8_t i)&#xA;{&#xA;  int c;&#xA;  while (1) {&#xA;    c = data[i];&#xA;    if (c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9') return i;&#xA;    ++i;&#xA;  }&#xA;}&#xA;&#xA;uint8_t peekNextP(const char* data)&#xA;{&#xA;  uint8_t c;&#xA;  uint8_t i = 0;&#xA;  while (1) {&#xA;    c = data[i];&#xA;    ++i;&#xA;    if (c == ')') return i;&#xA;  }&#xA;}&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;{&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte)&#xA;  {&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;      // terminator reached! process input_line here ...&#xA;      process_data (input_line, input_pos);&#xA;&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;  }  // end of switch&#xA;&#xA;} // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  Serial.println(&quot;Coucou&quot;);&#xA;  // if serial data available, process it&#xA;  if (Serial.available () &amp;gt; 0)&#xA;    processIncomingByte (Serial.read ());&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Serial output is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;o&amp;gt;1(255,255,255)&amp;lt;o&amp;gt;&#xA;&amp;lt;o&amp;gt;1(0,0,0)&amp;lt;o&amp;gt;&#xA;&amp;lt;o&amp;gt;1(255,255,255)&amp;lt;o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I am aiming for :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Cool&#xA;Coucou&#xA;&amp;lt;o&amp;gt;1(255,255,Zone:1255)&amp;lt;o&amp;gt;&#xA;Coucou&#xA;&amp;lt;o&amp;gt;1(0,0,Zone:10)&amp;lt;o&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My library :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Dispositif.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;#define pin1 5&#xA;#define pin2 6&#xA;#define pin3 9&#xA;&#xA;Dispositif::Dispositif()&#xA;{&#xA;  pinMode(pin1, OUTPUT); // absolutely necessary because we use a custom PWM&#xA;  pinMode(pin2, OUTPUT);&#xA;  pinMode(pin3, OUTPUT);&#xA;&#xA;  setBrightness(0, 50);&#xA;  setBrightness(1, 50);&#xA;  setBrightness(2, 50);&#xA;&#xA;  last_value[0] = 50;&#xA;  last_value[1] = 50;&#xA;  last_value[2] = 50;&#xA;&#xA;  zone = EEPROM.read(0);&#xA;  id = EEPROM.read(1);&#xA;  idNode = EEPROM.read(2);&#xA;}&#xA;&#xA;Dispositif::Dispositif(uint8_t zone, uint8_t id, uint8_t idNode)&#xA;{&#xA;  zone = zone;&#xA;  id = id;&#xA;  idNode = idNode;&#xA;&#xA;  pinMode(pin1, OUTPUT);&#xA;  pinMode(pin2, OUTPUT);&#xA;  pinMode(pin3, OUTPUT);&#xA;&#xA;  setBrightness(0, 50);&#xA;  setBrightness(1, 50);&#xA;  setBrightness(2, 50);&#xA;&#xA;  last_value[0] = 50;&#xA;  last_value[1] = 50;&#xA;  last_value[2] = 50;&#xA;&#xA;  EEPROM.write(0, zone);&#xA;  EEPROM.write(1, id);&#xA;  EEPROM.write(2, idNode);&#xA;}&#xA;&#xA;void Dispositif::setBrightness(uint8_t number, uint8_t value)&#xA;{&#xA;    if (!Serial)&#xA;      Serial.begin(9600);&#xA;    unsigned long currentMillis = millis();&#xA;    unsigned long lastMillis = 0;&#xA;&#xA;    while(value - last_value[number] &amp;gt; 25)&#xA;    {&#xA;      currentMillis = millis();&#xA;      if (currentMillis - lastMillis &amp;gt; 1000)&#xA;      {&#xA;        Serial.println(&quot;At least i'm here&quot;);&#xA;        Serial.println(last_value[number]);&#xA;        last_value[number] += 25;&#xA;        setPWM(number, last_value[number]);&#xA;        lastMillis = currentMillis;&#xA;      }&#xA;    }&#xA;    setPWM(number, value);&#xA;    last_value[number] = value;&#xA;}&#xA;&#xA;void Dispositif::setPWM(uint8_t number, uint8_t val)&#xA;{&#xA;    if (1 == number) // pin 6&#xA;    {&#xA;      sbi(TCCR0A, COM0A1);&#xA;      OCR0A = val; // set pwm duty&#xA;    }&#xA;    else if (2 == number) // pin 9&#xA;    {&#xA;      sbi(TCCR1A, COM1A1);&#xA;      OCR1A = val; // set pwm duty&#xA;    }&#xA;    else // pin 5&#xA;    {&#xA;      sbi(TCCR0A, COM0B1);&#xA;      OCR0B = val; // set pwm duty&#xA;    }&#xA;}&#xA;&#xA;void Dispositif::changeZone(uint8_t newZone)&#xA;{&#xA;  zone = newZone;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is not really pretty, because at one point I was using the SD library and had to reduce program space.&lt;/p&gt;&#xA;" OwnerUserId="4861" LastEditorUserId="4861" LastEditDate="2014-11-18T11:36:08.473" LastActivityDate="2014-11-18T11:36:08.473" Title="Serial.prints ignored" Tags="|arduino-uno|serial|xbee|atmega328|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5031" PostTypeId="2" ParentId="5008" CreationDate="2014-11-17T21:57:01.713" Score="1" Body="&lt;p&gt;You could always try setting a pin code and then retry&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMToolsPinManagement&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/GSMToolsPinManagement&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What version of the Arduino IDE are you using ? Also, are you sure you are suppying the board correctly ? &quot;It is recommended that the board be powered with an external power supply that can provide between 700mA and 1000mA. Powering an Arduino and the GSM shield from a USB connection is not recommended, as USB cannot provide the required current for when the modem is in heavy use.&quot;&lt;/p&gt;&#xA;" OwnerUserId="4861" LastActivityDate="2014-11-17T21:57:01.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5032" PostTypeId="2" ParentId="4837" CreationDate="2014-11-17T22:13:12.483" Score="0" Body="&lt;p&gt;by the looks of it you need to close the brackets of the &lt;em&gt;sprintf()&lt;/em&gt; statement shown below if you had copied the code from Ariser: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(gl_senstr1, &quot;%d&quot;, digitalRead(6);&#xA;sprintf(gl_senstr2, &quot;%d&quot;, digitalRead(7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;replace it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(gl_senstr1, &quot;%d&quot;, digitalRead(6));&#xA;sprintf(gl_senstr2, &quot;%d&quot;, digitalRead(7));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the error you are seeing because of &lt;em&gt;sprintf()&lt;/em&gt; not seeing a close to its statement  ;) &lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2014-11-18T16:38:39.963" LastActivityDate="2014-11-18T16:38:39.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5035" PostTypeId="2" ParentId="5023" CreationDate="2014-11-18T00:28:52.387" Score="4" Body="&lt;p&gt;As somebody else suggested, 9V batteries are pretty weak. They only provide a very small number of mAh (milliamp/hours) before their voltage starts to drop. Once the voltage drops to around 7 volts, the regulator in the Arduino can't keep providing 5 volts, so your Arduino resets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire up 6 AA batteries in series. That will provide a much &quot;stiffer&quot; 9 volt supply (more instantaneous current) plus a lot more mAh of total power. If you REALLY want long life, wire up 6 C or D batteries in series, or an external 9V supply through a &quot;wall wart&quot; power supply.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-11-18T00:28:52.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5036" PostTypeId="1" CreationDate="2014-11-18T01:45:52.467" Score="3" ViewCount="17581" Body="&lt;p&gt;I'm totally new to Arduino, and microcontrollers for that matter, so I'm having a hard time figuring out how to connect LEDs to multiple pins, but using a common external power supply...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created a starting light that's connected to pin A0-A4 + A5 (turn all LEDs on). I hooked each LED to its own pin directly (A0-A4) for the countdown part (&quot;5, 4, 3, 2, 1, ...&quot;), and then 5 additional LEDs to pin A5 (&quot;GO!&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the countdown part, when only one LED is on at a time, there's enough power. But if I were to light them all up at the same time, there won't be. So I figured that I should put a relay into the mix for that part, and have them draw power from an external 12 V power supply.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did manage to make the relay work in the circuit - switching all LEDs on/off, and getting power from the external power supply, but only through one pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how to have the start lights use an external power supply, and at the same time get signals from multiple pins. How do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry if my description is unclear. So please let me know if you need more information.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The LEDs are 3.4 V 20 mA. &lt;/li&gt;&#xA;&lt;li&gt;The power supply I'm planning to use is 12 V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm planning to have this start light - which is built in its own casing - use its own power supply, while the Arduino is running of the power from USB. So all I want to do, is to have the signals sent over to this starting light unit, and not power and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a quick overview of how I'm testing this whole thing at the moment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dK6ft.jpg&quot; alt=&quot;Friting diagram of Arduino and LEDs&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 5 red countdown LEDs (red) is getting powered by the board itself through the pins, while the 5 &quot;GO!&quot; LEDs (green) are getting powered from a 12 V power supply since they're all are going to be turned on simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how I can get both the 5 red LEDs, that uses separate pins, to get powered from the external power supply as well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since all the LEDs are built in its own casing, apart from the microcontroller because that also handles other stuff...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did that make any more sense at all?&lt;/p&gt;&#xA;" OwnerUserId="4824" LastEditorUserId="26916" LastEditDate="2017-11-04T19:03:31.800" LastActivityDate="2017-11-04T19:03:31.800" Title="Using external power supply to power leds on multiple pins (A0-A5)" Tags="|arduino-uno|led|relay|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5037" PostTypeId="1" AcceptedAnswerId="5038" CreationDate="2014-11-18T04:02:41.497" Score="1" ViewCount="129" Body="&lt;p&gt;I just began following the projects in the Arduino Projects Book included in the Arduino Starter Kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While using LEDs, as in the first few examples of the book, I am having a difficult time keeping them in contact with the breadboard. I can usually move the LED around until it turns on, but even a push of a button can make it lose contact with the board. I haven't used much more than switches, jumpers, LEDs and resistors, so I don't know if any of the other components behave the same. For the more complex projects, it seems like it would be hard to tell if you have it setup properly if you can't be sure the components are making a connection with the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a particular way to get all the components to sit nicely in the breadboard, or to modify them to do so?&lt;/p&gt;&#xA;" OwnerUserId="4868" LastActivityDate="2014-11-18T05:30:52.747" Title="How to ensure electronic components make good connection with breadboard" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5038" PostTypeId="2" ParentId="5037" CreationDate="2014-11-18T05:30:52.747" Score="4" Body="&lt;p&gt;Sounds like you may not be pushing the leads into the board,I find long nose pliers handy for components with thicker leads.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2014-11-18T05:30:52.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5039" PostTypeId="2" ParentId="5002" CreationDate="2014-11-18T05:56:22.977" Score="1" Body="&lt;p&gt;Quite simply, you cannot measure the stability of a device using routines that themselves depend on the device clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this properly you need an external measuring device that has a clock source at least 10 times more stable than the Arduino xtal. Most frequency counters would qualify.&#xA;Just set up a timer to provide a constant output frequency, and attach the counter to the pin.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-11-18T05:56:22.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5040" PostTypeId="1" CreationDate="2014-11-18T05:57:05.460" Score="0" ViewCount="197" Body="&lt;p&gt;I'm using an 3 axis Accelerometer(GY-521) to get the acceleration data and also the gyroscope to get the gyro data. I want to segment the signals at the idle points so that i can get the segmented signal at the idle points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rvm34.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any algorithm or example code that i could use to segment this kind of signal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You.&lt;/p&gt;&#xA;" OwnerUserId="3339" LastActivityDate="2014-11-19T17:07:56.460" Title="How to Segment Accelerometer Signal at idle points" Tags="|arduino-ide|accelerometer|signal-processing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5041" PostTypeId="2" ParentId="5036" CreationDate="2014-11-18T05:58:27.003" Score="3" Body="&lt;p&gt;&lt;strong&gt;Caveat: I too am new to this. The answer below is my understanding and I need an expert to confirm.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current in your Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A single digital pin on a Uno will provide 40mA -- and could conceivably power two of your LEDs.&lt;/li&gt;&#xA;&lt;li&gt;The VCC pin outputs 200mA and could therefore conceivably power ten. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So all you need to do is power your LEDs from your VCC, but use your digital pin as a switch. One idea, which you had, was to use a relay. But a relay is an inductor so don't connect it directly to the Arduino. Make sure it's on a shield. But that shield will essentially do exactly what you need to do, but to drive the relay rather than drive your LEDs: It will use the digital pin to switch the VCC and activate the relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily this isn't hard. All you need is the most magical of all components: the transistor. A transistor can be used as a switch to turn on a higher current. In your case, the transistor can switch the VCC connection to the LED array when the digital pin is high.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This question was &lt;a href=&quot;https://electronics.stackexchange.com/questions/65996/turning-on-multiple-leds-with-arduino-using-transistor&quot;&gt;answered nicely over at the electronics stack exchange&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Here's a &lt;a href=&quot;https://www.techhouse.org/~dmorris/projects/tutorials/transistor.switches.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF tutorial on using transistors as switches&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Found a nice &lt;a href=&quot;http://www.sqlskills.com/blogs/paulselec/post/arduino-figuring-out-transistors-and-associated-resistors.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference on figuring out the transistor / resistor relationship&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's the circuit I believe you need based on my understanding. Note that the values of the resistors and transistors are just made up. Read the docs above to get the correct values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NAsTa.png&quot; alt=&quot;Power five LEDs from one digital pin&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4843" LastActivityDate="2014-11-18T05:58:27.003" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5042" PostTypeId="2" ParentId="5036" CreationDate="2014-11-18T06:26:47.767" Score="3" Body="&lt;p&gt;I think one of the best way for you would be to use 74HC595 chip. You will learn a lot while developing board with this chip. It is well documented &lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;Serial to Parallel Shifting-Out with a 74HC595&lt;/a&gt;. Using 3 pins you will be able to turn on &amp;amp; off as many LED's as you wish, use external power supply and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also there is MAX7219 chip. &lt;a href=&quot;http://playground.arduino.cc/Main/MAX72XXHardware&quot; rel=&quot;nofollow&quot;&gt;The MAX7219 and MAX7221 Led drivers&lt;/a&gt;. And there are a lot more ways to do this.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-11-18T06:35:45.493" LastActivityDate="2014-11-18T06:35:45.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5044" PostTypeId="1" CreationDate="2014-11-18T18:47:45.333" Score="1" ViewCount="9852" Body="&lt;p&gt;I am trying to learn how to make a shift register work. I have been working off of the &lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftOut&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino ShiftOut tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that the shift register isn't working when the circuit is powered and I am not sure what is wrong. I suspect the issue is with pins 10-13 on the 74HC595?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done this with an actual board and the 123d.circuits.io simulator with the same result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://123d.circuits.io/circuits/444111-shift-register&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://123d.circuits.io/circuits/444111-shift-register&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fsCkh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is very simple and taken from &lt;a href=&quot;http://arduino.cc/en/Tutorial/ShftOut12&quot; rel=&quot;nofollow noreferrer&quot;&gt;the tutorial&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// SH_CP; 11&#xA;const int clockPin = 9;&#xA;// DS; 15&#xA;const int dataPin = 8;&#xA;// ST_CP; 12&#xA;const int latchPin = 10;&#xA;&#xA;void setup() {&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;  pinMode(latchPin, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;reset&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int number = 0; number &amp;lt; 256; number++) {&#xA;    Serial.println(number);&#xA;    digitalWrite(latchPin, LOW);&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, number);&#xA;    digitalWrite(latchPin, HIGH);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4874" LastActivityDate="2016-03-12T19:40:01.673" Title="Shift Register 74HC595 not working" Tags="|shift-register|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5045" PostTypeId="1" CreationDate="2014-11-18T19:24:49.813" Score="2" ViewCount="10087" Body="&lt;p&gt;I don't know what wires to get for my first Arduino project. I am planning on getting a pre-made light strip that I would control with an Arduino from across my room. Is there any specific type of wire to get? It needs to be about 15 feet. There are so many choices, but I don't know what I need. Does anyone else know?&lt;/p&gt;&#xA;" OwnerUserId="4875" LastEditorUserId="220" LastEditDate="2014-11-19T02:12:36.360" LastActivityDate="2014-11-20T01:22:15.820" Title="Arduino Wire Types?" Tags="|arduino-nano|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5046" PostTypeId="2" ParentId="5044" CreationDate="2014-11-18T19:47:12.193" Score="2" Body="&lt;p&gt;Solution: Remove ground from Q0 as Gerben correctly pointed out in comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also: rotate LEDs 90 degrees so that the anode and cathode are on different rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What was tripping me up is in the Arduino tutorial diagram is a little unclear on this (I now understand why their way is correct and my way (in the question) was wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JYzEK.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4874" LastActivityDate="2014-11-18T19:47:12.193" CommentCount="2" CommunityOwnedDate="2014-11-18T19:47:12.193" ContentLicense="CC BY-SA 3.0" />
  <row Id="5047" PostTypeId="2" ParentId="5045" CreationDate="2014-11-18T19:55:03.043" Score="4" Body="&lt;p&gt;Choosing wire all depends on what you're going to do with it, and most of the choice is based on how much current it will carry and how durable it needs to be. Generally, you're going to use insulated copper wire - aside from that, your answers are mostly here: &lt;a href=&quot;https://electronics.stackexchange.com/questions/16948/choosing-the-right-type-of-wire&quot;&gt;https://electronics.stackexchange.com/questions/16948/choosing-the-right-type-of-wire&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For experimentation - which you will need to do a lot of before attempting your goal project - you can use the little wires which come in the Arduino starter kit. They are &quot;jumper wires&quot; designed for use on a bread board - they can not carry large amounts of electricity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This product here: &lt;a href=&quot;https://www.sparkfun.com/products/8431&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/8431&lt;/a&gt; - these have &quot;male&quot; ends designed to be stuck into the holes in the breadboard, and connect to the holes on the headers of the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of a project laid out on a breadboard:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/cEdMB.jpg&quot; alt=&quot;Compass Project&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of those wires carry a lot of current. If you're hooking up 50 LEDs that might be almost a full 1-AMP of current, so I would use thicker wire. Do yourself a favor and start with a kit like in this video, learn the basics, then attempt a 'real' project. Every Arduino user should be able to do all the experiments in the training book and understand them. You will be lost if you jump in deep right away...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=pf4qosqpv3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=pf4qosqpv3A&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-18T19:55:03.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5048" PostTypeId="2" ParentId="5036" CreationDate="2014-11-18T22:01:42.667" Score="1" Body="&lt;p&gt;If you really want an external power supply, you can use ULN2003 / ULN2803, which are 7/8 darlington 500 mA each transistor&lt;/p&gt;&#xA;" OwnerUserId="4880" LastActivityDate="2014-11-18T22:01:42.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5050" PostTypeId="2" ParentId="5040" CreationDate="2014-11-19T02:20:01.710" Score="2" Body="&lt;p&gt;There are many algorithms you can use. I would advise you to look carefully at the data and the &quot;idle state&quot; and see what is always different. Try everything you can think of and see what works best, or if one does everything you need just stop there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be that you can just calculate if the accelerometer values go over a certain threshold, but that requires that either the orientation be know or the threshold being over 1g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also calculate the rate at which the accerometer value is changing by subtracting the last value (the derivative if you are up on your calculus) and threshold that value, which might produce better results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also calculate a running average and then compare the current value with that. If the numbers match (or are very close) then you can say the accelerometer has been idle. This has the effect of making a changing threshold relative to the most recent activity tuned by the average's response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt any of these will be perfect, so you might require the algorithm to say &quot;idle&quot; multiple times in a row before changing state from &quot;active&quot; to &quot;idle&quot;, or something to that effect.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-11-19T17:07:56.460" LastActivityDate="2014-11-19T17:07:56.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5053" PostTypeId="1" AcceptedAnswerId="5055" CreationDate="2014-11-19T09:10:48.537" Score="0" ViewCount="405" Body="&lt;p&gt;Is it possible to create a infrared based interruption counter with an Arduino Uno? If yes, then what additional hardware would be necessary?&lt;/p&gt;&#xA;" OwnerUserId="3108" LastEditorUserId="11529" LastEditDate="2016-02-25T08:16:19.583" LastActivityDate="2016-02-25T08:16:19.583" Title="Infrared interruption counter" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5054" PostTypeId="1" CreationDate="2014-11-19T10:35:42.167" Score="1" ViewCount="842" Body="&lt;p&gt;I'm working on a small project for a presentation. My goal is to read the UID of multiple Mifare Classic cards and compare it to a hardcoded list for different actions. All is well (the reading and comparing part that is) but 2 small problems that I have encountered are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The first (maybe up to three, since the reader is a little bit on the fast side) read after uploading my code will return a UID of just 0s and a wrong PICC type.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After reading a PICC and then trying to read another, the reader prints the UID / PICC Type of the reader before, which is kinda not helpful when trying to light LEDs based on UID.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is my sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;HEADER TEXT&#xA;GOES HERE&#xA;*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#define SS_PIN 10&#xA;#define RST_PIN 9&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  // Serielles Interface initialisieren&#xA;  Serial.begin(9600);&#xA;  // SPI initialisieren&#xA;  SPI.begin();&#xA;&#xA;  mfrc522.PCD_Init();&#xA;&#xA;  // Für später&#xA;  // pinMode (2, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Eigene UID bilden. Dazu nehmen wir die 4(7)Byte Hex UID aus Block 0 und quetschen sie in einen schönen String.&#xA;  String uID = String(mfrc522.uid.uidByte[0],HEX)+String(mfrc522.uid.uidByte[1],HEX)+String(mfrc522.uid.uidByte[2],HEX)+String(mfrc522.uid.uidByte[3],HEX);&#xA;&#xA;  // PICC Typen&#xA;  byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);&#xA;&#xA;  // Nach neuen Karten suchen.&#xA;  delay(250);&#xA;  if ( mfrc522.PICC_IsNewCardPresent())&#xA;  {&#xA;    delay(250);&#xA;    mfrc522.PICC_ReadCardSerial();&#xA;&#xA;    // Debug Ausgabe&#xA;    Serial.println();&#xA;    Serial.print(&quot;Die Kartennummer lautet: &quot;);&#xA;    Serial.print(uID);&#xA;    Serial.println();&#xA;    Serial.print(&quot;Picc Type: &quot;);&#xA;    Serial.println(mfrc522.PICC_GetTypeName(piccType));&#xA;    Serial.println();&#xA;&#xA;    // Überprüfe auf unterstützten PICC Typ und noch mehr Debug Kram&#xA;    if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI &amp;amp;&amp;amp; piccType != MFRC522::PICC_TYPE_MIFARE_1K&amp;amp;&amp;amp; piccType != MFRC522::PICC_TYPE_MIFARE_1K) {&#xA;      Serial.println(&quot;Diese Tech-Demo benötigt MIFARE Classic Karten.&quot;);&#xA;      return;&#xA;    }&#xA;&#xA;    // Den UID String Verglichen und eine entsprechende Aktion ausführen&#xA;    if(uID==&quot;myUIDforStuff&quot;) {&#xA;      Serial.println(&quot;Access granted&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4886" LastEditorUserId="84" LastEditDate="2014-11-19T21:18:04.850" LastActivityDate="2014-12-24T10:12:39.743" Title="MFRC522 minor problems" Tags="|arduino-uno|programming|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5055" PostTypeId="2" ParentId="5053" CreationDate="2014-11-19T11:13:19.153" Score="0" Body="&lt;p&gt;You can use photo any transmissive or reflective photo interrupter (wire or TH) ideally with integrated Schmitt trigger and connect to IRQ driven AVR input to have quick trigger reaction. For production is cheaper photo interrupter with external Schmitt but for prototyping it does not matter.&#xA;Don't forget serial resistor to limit current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search e.g. &quot;photo interrupter Schmitt&quot; at Farnell.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-11-19T11:13:19.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5056" PostTypeId="1" AcceptedAnswerId="5057" CreationDate="2014-11-19T11:35:55.307" Score="0" ViewCount="1386" Body="&lt;p&gt;I have just got the &lt;a href=&quot;http://redbearlab.com/blendmicro/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blend Micro&lt;/a&gt; board.&#xA;After following the &lt;a href=&quot;http://redbearlab.com/getting-started-blendmicro&quot; rel=&quot;nofollow noreferrer&quot;&gt;getting started tutorial&lt;/a&gt; I can't manage to upload sketches on the board. Now, in Arduino v. 1.0.6 I see the voices&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Blend&lt;/li&gt;&#xA;&lt;li&gt;Blend Micro 3.3V/8Mhz&lt;/li&gt;&#xA;&lt;li&gt;Blend Micro 3.3V/16Mhz (Overclock) as in this picture:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pzKcF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the L Led is switch on if I upload the sketch the TX and RX leds stay off. The modified Arduino IDE says &quot;Done uploading&quot;. As port I choose /dev/tty.Bluetooth-Serial-1 and I don't see any other port and I think this is critical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I open the Android BLE application BLE Controller, after tried to upload the &lt;strong&gt;BLEControllerSketch&lt;/strong&gt; (from RBL_nRF8001 libraries) it finds the board but print the error &lt;strong&gt;No Response from the BLE Controller sketch&lt;/strong&gt;. If I try with &lt;strong&gt;SimpleChat&lt;/strong&gt; example and the SimpleChat Android application if finds the board but prints only &quot;Hello World&quot; and nothing else if I send strings from the android app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any kind of advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on a Mac 1.8.5. I have tried also with Codebender, but anything change: I can't see the &lt;code&gt;/dev/tty.usb*&lt;/code&gt; in the listed ports&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2014-11-19T19:44:37.970" LastActivityDate="2017-01-23T00:43:11.260" Title="Blend Micro uploading sketch" Tags="|serial|uploading|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5057" PostTypeId="2" ParentId="5056" CreationDate="2014-11-19T12:41:30.950" Score="1" Body="&lt;p&gt;Did you follow the setup exactly? In particular, did you modify &lt;code&gt;main.cpp&lt;/code&gt; to have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(BLEND_MICRO_8MHZ)&#xA;    // As the F_CPU = 8000000UL, the USB core make the PLLCSR = 0x02&#xA;    // But the external xtal is 16000000Hz, so correct it here.&#xA;    PLLCSR |= 0x10;             // Need 16 MHz xtal&#xA;    while (!(PLLCSR &amp;amp; (1&amp;lt;&amp;lt;PLOCK)));     // wait for lock pll&#xA;#elif defined(BLEND_MICRO_16MHZ)&#xA;    // The CPU clock in bootloader is 8MHz, change to 16MHz for sketches to run (i.e. overclock running at 3.3v).&#xA;    CLKPR = 0x80;&#xA;    CLKPR = 0;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If not, what happens is once the sketch starts the USB stops working and you can't see the serial port due to the clock speed being incorrect. This is why you can only see &lt;code&gt;/dev/tty.Bluetooth-Serial-1&lt;/code&gt; in the port list.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Modify &lt;code&gt;main.cpp&lt;/code&gt; according to &lt;a href=&quot;http://redbearlab.com/getting-started-blendmicro&quot; rel=&quot;nofollow&quot;&gt;http://redbearlab.com/getting-started-blendmicro&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Press the reset button on the Blend Micro, then quickly select &lt;em&gt;Tools&lt;/em&gt; -&gt; &lt;em&gt;Serial Port&lt;/em&gt; in the Arduino IDE. The Blend Micro serial port should be there because the boot loader is still running. It will be named like &lt;code&gt;/dev/tty.usb????????&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Select that serial port. Compile your code. Now press reset at the same time as pressing upload. Your sketch will upload and the serial port should now be present when the sketch is running.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update: The Timing Tricks&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Blend Micro is basically the same as Arduino Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the timing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The reset button is pressed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The ATMega32u4 restarts. It jumps to the bootstrap loader code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The bootstrap loader starts up the USB as a CDC device (serial port) and waits for firmware upload instructions. (Pulsing L LED)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If no upload instructions are received within a certain time (8 seconds?), it jumps to the application code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The application code starts up the USB as a CDC device again.However, since the oscillator (clock) on the Blend Micro is different to the Leonardo, it requires the modifications above, otherwise the USB clock will wrong, and the USB won't work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the modifications above were not done, Step 3 is the only time when the USB is working and the serial port can be selected in the Arduino software.&lt;/p&gt;&#xA;" OwnerUserId="1566" LastEditorUserId="1566" LastEditDate="2014-11-19T22:26:34.520" LastActivityDate="2014-11-19T22:26:34.520" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5058" PostTypeId="1" CreationDate="2014-11-19T12:55:39.030" Score="1" ViewCount="843" Body="&lt;p&gt;Actually I'm using the RF24 Library mantained by TMRh20 (&lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24&lt;/a&gt;).&#xA;I'm trying to get some type of direct communication between multiple modules working, but I don't want to use the RF24Network Library (&lt;a href=&quot;https://github.com/TMRh20/RF24Network&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24Network&lt;/a&gt;) which creates a mesh of connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have several arduinos that have to communicate between them. Every arduino has its own address starting from 0x0001 (0x0000 is for a main module that manages everything) and finishing to 0xFFFF. &#xA;I want to directly communicate between the two NRF24L01+ modules without any intermediator, because I don't have problems of distance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main thing that I want to be able to do is communicate directly not with just one module, but choose if I want to broadcast to all the modules in an area (I know that it can be done with range power modifications in the code) or talk with just one module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to do this type of communication?&lt;/p&gt;&#xA;" OwnerUserId="4887" LastActivityDate="2016-08-04T13:29:32.833" Title="NRF24L01 Direct Communication Library Logics" Tags="|arduino-uno|rf|nrf24l01+|communication|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5060" PostTypeId="1" AcceptedAnswerId="5062" CreationDate="2014-11-19T13:00:20.677" Score="2" ViewCount="13665" Body="&#xA;&#xA;&lt;p&gt;I come to you again because I have a problem with the Arduino SoftwareSerial library. With a basic example I fail to see results in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic code example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11);&#xA;void setup() {&#xA;  mySerial.begin(4800);&#xA;}&#xA;void loop() {&#xA;    mySerial.println(&quot;HELLO&quot;);&#xA;    delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess it should show the string &quot;HELLO&quot; on the serial port, but nothing appears. I have found that the baud setting is correct. The hardware is simple. Only an Arduino Uno v3 without any connected component.&lt;/p&gt;&#xA;" OwnerUserId="4889" LastEditorUserId="10794" LastEditDate="2015-08-19T09:25:46.170" LastActivityDate="2017-08-30T07:11:13.937" Title="Arduino SoftwareSerial library basic example doesn't work" Tags="|arduino-uno|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5062" PostTypeId="2" ParentId="5060" CreationDate="2014-11-19T13:15:29.463" Score="1" Body="&lt;p&gt;If your Arduino is connected via the built-in USB port then you need to use the hardware serial port (pins 0 and 1). To do that, call &lt;code&gt;Serial.begin(..)&lt;/code&gt; and &lt;code&gt;Serial.println(..)&lt;/code&gt;, instead of &lt;code&gt;mySerial...&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SoftwareSerial&lt;/code&gt; is used when you want to connect via serial on some other pins. It allows your program to emulate serial input/output in software instead of relying on dedicated hardware. In this case, your program is trying to setup software serial on pins 10 and 11. That won't show up on the serial monitor because it's not connected to those pins.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-19T13:15:29.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5063" PostTypeId="2" ParentId="5060" CreationDate="2014-11-19T13:29:38.843" Score="1" Body="&lt;p&gt;Addition to &lt;code&gt;Peter R. Blommfield&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is your problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect your device, run this sketch and you are good to go :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* TEST */&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;/* Connect device Rx - 10, Tx - 11 */&#xA;SoftwareSerial mySerial(10, 11);&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);   // This will communicate with PC via USB&#xA;  mySerial.begin(4800); // This will communicate with device via 10,11 pins with 4800 baud rate&#xA;}&#xA;void loop() {&#xA;    Serial.println(&quot;HELLO&quot;);   // Sends string to PC to Serial Monitor&#xA;    mySerial.println(&quot;HELLO&quot;); // Sends string to device&#xA;    delay(100);                // Waits here 100ms and then goes on&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2014-11-19T13:29:38.843" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="5064" PostTypeId="1" AcceptedAnswerId="5065" CreationDate="2014-11-19T14:21:06.737" Score="1" ViewCount="397" Body="&lt;p&gt;I have been following &lt;a href=&quot;http://arduino.cc/en/Tutorial/Fade&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/Fade&lt;/a&gt; to fade and LED. But I don't know why they are using a 220 Ohm resistor. &#xA;According to Ohms law if LED is of 2.2 V and it runs on 0.025Amps and is connected to 5V pin of Arduino then the resistor should be of 120 Ohms but why we are using 120 Ohm resistor ?&#xA;One more thing. How can I collect value of resistor to be used with different output and input devices ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="4857" LastActivityDate="2014-11-19T15:08:14.557" Title="how to calculate correct resistor value to use with LEDs Potentiometer and other devices?" Tags="|arduino-uno|led|resistor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5065" PostTypeId="2" ParentId="5064" CreationDate="2014-11-19T15:08:14.557" Score="2" Body="&lt;p&gt;If the LED has a forward voltage of 2.2V and is rated for 25 mA, then you're correct that a 120 Ohm resistor should be OK. It's theoretically calculated as the voltage across the resistor divided by the desired current in the LED. (In practice, it's often more complicated than that, but that's a good starting point.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's important to note that not all LEDs are rated the same though. I imagine the 220 Ohm resistor was selected for the tutorial to provide a bit of a safety margin, as that should be OK for most LEDs a hobbyist is likely to use. If you don't have access to the full specifications then it's probably better to under-drive it. The LED might be a little dim, but at least it's unlikely to be destroyed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a useful online tool for calculating theoretical resistor values for one or more LEDs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://led.linear1.org/led.wiz&quot; rel=&quot;nofollow&quot;&gt;http://led.linear1.org/led.wiz&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For other devices, the resistor values required can depend on a huge number of factors. The best thing to do is to check the datasheets. For some components (such as ICs), you'll often find an &quot;Applications&quot; section towards the back which shows various ways you might want to connect the item to an external circuit. If things like capacitors and resistors are required, it will often explain how to select the correct ones for a given situation.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-19T15:08:14.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5067" PostTypeId="1" CreationDate="2014-11-19T21:05:22.687" Score="1" ViewCount="1478" Body="&lt;p&gt;I bought the &lt;a href=&quot;http://arduino.cc/en/Main/GTFT&quot; rel=&quot;nofollow noreferrer&quot;&gt;standard 1.77&quot; TFT screen&lt;/a&gt; months ago and It has never worked. I follow the wiring diagram shown for Uno on &lt;a href=&quot;http://arduino.cc/en/Guide/TFTtoBoards&quot; rel=&quot;nofollow noreferrer&quot;&gt;the guide on the Arduino website&lt;/a&gt; and the best result I have ever got is it seeming like the screen itself is broken. I must have rewired the whole thing many times now and quadruple checked each time.&#xA;As I have never used this screen before I do not know what is correct any further than the tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2e2p3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I say that because it seems to understand instructions but does not display them correctly.&lt;br /&gt;&#xA;I have tried multiple examples and tests on it that all yield weird results.&lt;br /&gt;&#xA;The tests I have tried are: &lt;br /&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The SD demo that loads the Arduino icon off SD and fills the screen&#xA;with it. The serial connection says that it has successfully read the&#xA;image but just displays black lines&lt;/li&gt;&#xA;&lt;li&gt;Setting the background colour with random colours which seems to work fine apart from the black bars&lt;/li&gt;&#xA;&lt;li&gt;Drawing random colour, positioned and sized rectangles. Result is image below. Colours seems to prefer pink, purple and white.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6VZkD.jpg&quot; alt=&quot;Random rectangles test&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see it looks like the image is 1D, no rectangles stop across the x axis so I did a test for that, it just draws a 1x1 pixel red dot going down the screen's left side, if it drew a red line moving down then my thought that it was stretching the first column would be correct, it didn't, just white and black bars still, so I modified it to test every column in case it wasn't column 0, same result...weirdly only when I made the 1x1px rectangle 5x5 my idea was correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ux51n.jpg&quot; alt=&quot;Another completely different test looks the same&amp;gt; Black lines not changed&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see on both the images, the black bars are a persistent factor, their colour cannot be changed and they appear once TFT.begin has been called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After looking around the only help I could find is someone mentioned that Arduino the company updated the TFT library but not the software but he/she didn't provide a download link. In the time I've had this I'm sure I'm redownloaded/updated the Arduino software a few times too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the glitches normal for wrong pin connections? Is there some pin wrong on the website?&lt;/p&gt;&#xA;" OwnerDisplayName="user4892" LastEditorDisplayName="user4892" LastEditDate="2014-11-20T17:28:29.693" LastActivityDate="2022-11-23T05:02:55.347" Title="Is my TFT screen defective?" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="5071" PostTypeId="2" ParentId="501" CreationDate="2014-11-20T03:38:13.377" Score="5" Body="&lt;p&gt;I know you asked this a few months ago .. but sometimes with something technical the project never gets completed, or at least not in short order. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So while you're building your new-world-order with an Arduino, can I suggest you put a pipe down the dip hole and insert a floating dip stick? 1.5&quot; pipe. 1/4&quot; dowel glued to a ping-pong ball. Flag on top of the dowel. Now you'll see the level any time you walk past.&lt;/p&gt;&#xA;" OwnerUserId="4843" LastActivityDate="2014-11-20T03:38:13.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5072" PostTypeId="1" AcceptedAnswerId="42912" CreationDate="2014-10-20T19:23:45.320" Score="8" ViewCount="11250" Body="&lt;p&gt;I want to use all six I/O pins of an ATtiny85, that means also using the reset pin as an I/O pin, however, I found out that if I disable the RESET pin, I can no longer program the ATtiny using an ISP programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I found out that there are bootloaders for ATtiny which, as far as I understand, allow me to program the ATtiny through USB, without the need of the RESET pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question is&lt;/strong&gt;: How do I burn such a bootloader (such as &lt;a href=&quot;https://github.com/micronucleus/micronucleus&quot; rel=&quot;noreferrer&quot;&gt;micronucleus&lt;/a&gt; for example) to the ATtiny85? And how do I need to connect the ATtiny to USB after that (like &lt;a href=&quot;http://littlewire.cc/downloads.html&quot; rel=&quot;noreferrer&quot;&gt;this?&lt;/a&gt;)? How do I program it after that? Keep in mind that in terms of burning bootloaders and modifying fuses, I am a complete newbie.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm using the ArduinoISP sketch as my ISP programmer since I don't have a real ISP programmer, but as far as I read, that won't be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I do have this thing I bought for a couple dollars on eBay, which I don't know how and if I need to to use: &lt;img src=&quot;https://i.stack.imgur.com/5U8Nr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4566" OwnerDisplayName="Calin" LastActivityDate="2017-07-23T11:36:24.060" Title="ATtiny85. How do I burn a bootloader? What is the process?" Tags="|usb|attiny|bootloader|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5073" PostTypeId="2" ParentId="5072" CreationDate="2014-10-20T21:04:19.123" Score="1" Body="&lt;p&gt;True, if you use the reset pin as IO then you need &lt;strike&gt;a special programmer that I believe provide high voltage (12v if i remember) or something like that&lt;/strike&gt; to apply a 12v source to that pin to force it into programming mode then program using a normal programmer (or another arduino). However, what you are looking for is something like what is being done in the Arduino. The arduino is programmed with a special bootloader through ISP so when you power the microcontroller that bootloader will execute first and for few milliseconds will check the UART pins for activities and if it sees something valid it switched into programming mode where it waits for the new code to come through UART (not ISP) and write that into the program location, otherwise the bootloader will simply hand the code execution to the existing program if any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is a simple explanation of how it works:&lt;/strong&gt;&#xA;Let say your microcontroller flash size is 1KB, and the bootloader is 100B so your program can be stored at location 101B+, and its max size is (1KB-100B).&#xA;So when the bootloader starts and there is no activitiy on the UART pins it jumps to the location of your program (at 101B) while if programming activity is detected it starts reading the new code and overwrites the flash starting at 101B (so it won't over write itself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you will need the USBASP to program the bootloader for the first time. And you don't program the ATtiny85 through usb since that chip doesn't support USB, however, you use a USB to serial chip/module that emulates serial protocol over the USB. Some atmel microcontrollers have built in serial support and others can be done through software emulation.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;And as Chris suggested, don't disable the reset pin until you test and validate that your bootloader works.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4906" OwnerDisplayName="FAD" LastEditorUserId="4906" LastEditDate="2014-11-20T16:23:18.460" LastActivityDate="2014-11-20T16:23:18.460" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5074" PostTypeId="1" AcceptedAnswerId="5075" CreationDate="2014-11-20T08:35:24.137" Score="0" ViewCount="1946" Body="&lt;p&gt;Currently I'm working on a project using an &lt;a href=&quot;http://www.tme.eu/en/details/mikroe-229/atmel-development-kits/mikroelektronika/mcu-card-atmega2560/#&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega 2560 microcontroller card&lt;/a&gt; with a 10&amp;nbsp;MHz crystal. My main goal is to use the Arduino IDE to upload sketches to this chip to run my bread board circuit. In the beginning I had planned to use Atmel Studio to upload Arduino Sketches, but I decided to go with the more direct route. I am using two programmers, the Atmel ICE, and the Atmel AVR ISP MKii.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, here is my issue. I tried to use the Arduino IDE and the MKii to burn the bootloader to the chip. However, it did not work. It uploaded, but I was at that point no longer able to communicate with the device. When I switched to Atmel Studio, and used the ICE programmer, my chip could not be read and recognized (whereas before it could). I can't even program it. (I had bought two.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then figured I would try and read the fuse bits on the other programmer and burn the bootloader using Atmel Studio (since the Arduino IDE has no information on this), and I looked up &lt;a href=&quot;http://www.avr-developers.com/bootloaderdocs/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;the proper bits to change&lt;/a&gt; and then burned the bootloader. It worked fine, and I then changed the fuse bits which resulted in an error and now I again could talk to the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am guessing that something is going wrong with the suggested fuse bits, but I do not know how to change them or how to fix this. The original fuse bits that I read from the device are listed below (before I messed it up).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked my wiring a billion times and it is all perfect. I just need suggestions to fix this mess, thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BODLEVEL = DISABLED&#xA;OCDEN = [ ]&#xA;JTAGEN = [X]&#xA;SPIEN = [X]&#xA;WDTON = [ ]&#xA;EESAVE = [ ]&#xA;BOOTSZ = 4096W_1F000&#xA;BOOTRST = [X]&#xA;CKDIV8 = [ ]&#xA;CKOUT = [ ]&#xA;SUT_CKSEL = INTRCOSC_6CK_0MS&#xA;EXTENDED = 0xFF (valid)&#xA;HIGH = 0x98 (valid)&#xA;LOW = 0xC2 (valid)&#xA;LB = NO_LOCK&#xA;BLB0 = NO_LOCK&#xA;BLB1 = NO_LOCK&#xA;&#xA;LOCKBIT = 0xFF (valid)&#xA;&#xA;Detected device&#xA;Device name       ATmega2560&#xA;Device signature  0x1E9801&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4896" LastEditorUserId="84" LastEditDate="2016-11-06T10:17:05.513" LastActivityDate="2021-03-14T21:51:50.570" Title="How do I change fuse bits - not communicating?" Tags="|arduino-mega|isp|atmel-studio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5075" PostTypeId="2" ParentId="5074" CreationDate="2014-11-20T09:08:48.960" Score="0" Body="&lt;p&gt;If AVR is bricked because of wrong fuses I suppose it's typically non-working external oscillator you need provide signal to particular AVR pin to get programmer working again. Thread related to unbricking &lt;a href=&quot;http://www.avrfreaks.net/forum/locked-out-atmega-328p-possible-clocklow-fuse-byte-issue&quot; rel=&quot;nofollow&quot;&gt;http://www.avrfreaks.net/forum/locked-out-atmega-328p-possible-clocklow-fuse-byte-issue&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-11-20T09:08:48.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5076" PostTypeId="1" CreationDate="2014-11-20T10:08:37.003" Score="5" ViewCount="195" Body="&lt;p&gt;Tried to upload my Arduino Uno sketch that writes to serial UART at 9600 baud rate onto my ATtiny2313 running at 1MHz. Not getting the signal on the ATtiny, does this have to do with my clock frequency of the MCUs being 16 vs 1MHz? &lt;/p&gt;&#xA;" OwnerUserId="4695" LastEditorUserId="6936" LastEditDate="2015-08-01T14:40:23.843" LastActivityDate="2015-08-01T14:40:23.843" Title="Does porting code to different MCU clock frequency affect serial baud rate?" Tags="|arduino-uno|serial|avrdude|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5077" PostTypeId="2" ParentId="5076" CreationDate="2014-11-20T10:17:02.663" Score="3" Body="&lt;p&gt;Yes, it does. As can be seen in the &quot;USART&quot; section of the datasheet the baud rate is generated directly from both &lt;em&gt;fosc&lt;/em&gt; (aka &lt;code&gt;FCPU&lt;/code&gt;) and the value contained in UBRR. The tables at the end of the section gives the appropriate value for UBRR for a given CPU frequency, desired bit rate, and state of the USART clock doubler.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-20T10:17:02.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5079" PostTypeId="1" AcceptedAnswerId="5086" CreationDate="2014-11-20T13:06:55.613" Score="1" ViewCount="5954" Body="&lt;p&gt;Today I ordered a 2x16 character LCD with white characters on black background. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am wondering if I can change the backlight LED, which I guess is white for the characters, with a RGB LED to change the character color. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did anyone do this before? &#xA;Is it even possible that way? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen RGB negative LCDs from Adafruit and Sparkfun.&lt;/p&gt;&#xA;" OwnerUserId="4901" LastEditorUserId="84" LastEditDate="2016-09-18T14:14:27.427" LastActivityDate="2016-09-18T14:14:27.427" Title="Change the backlight of 2x16 LCD" Tags="|led|lcd|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5080" PostTypeId="2" ParentId="5079" CreationDate="2014-11-20T14:51:02.093" Score="0" Body="&lt;p&gt;The product you linked looks like a fairly standard LCD module, so it's probably very difficult to swap the backlight LED. Like most electronics, they're not designed to be modified by hand. It would likely need some precision re-soldering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you see LCDs with other types/colours of backlight, it's usually because they were originally manufactured that way.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-20T14:51:02.093" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5082" PostTypeId="1" AcceptedAnswerId="5084" CreationDate="2014-11-20T15:41:14.250" Score="0" ViewCount="3104" Body="&lt;p&gt;I'm about to buy Arduino Pro Mini (&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardProMini&lt;/a&gt;).&#xA;As far as I can see it requires FTDI or similar circuit to program it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should FTDI be present for communication with PC after sketch is uploaded to chip or there is a way to connect Arduino Pro Mini DIRECTLY to USB cable and PC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this also case with Arduino Pro Micro? (&lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12640&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&#xA;Petar&lt;/p&gt;&#xA;" OwnerUserId="4908" OwnerDisplayName="cyberbrain" LastActivityDate="2014-11-20T16:41:13.980" Title="How to connect Arduino Pro Mini with PC?" Tags="|usb|communication|ftdi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5083" PostTypeId="1" AcceptedAnswerId="5101" CreationDate="2014-11-20T15:49:42.547" Score="0" ViewCount="441" Body="&lt;p&gt;I'm doing a program who get a line from the SD and shows it, this function is called &lt;em&gt;getData()&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FULL CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;File myFile;&#xA;int stringIndex = 0;&#xA;int cursorPosition = 0;&#xA;char inputString [25];&#xA;char inputChar;&#xA;boolean endOfLine;&#xA;char fullPath[11];&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.print(&quot;Initializing SD card.&quot;);&#xA;  pinMode(10, OUTPUT);&#xA;  digitalWrite(10, HIGH);&#xA;&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;initialization done.&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  Serial.println(getDataSD());&#xA;&#xA;  Serial.print(&quot;freeMemory()=&quot;);&#xA;  Serial.println(freeMemory());&#xA;}&#xA;&#xA;String getDataSD(){&#xA;&#xA;  memset(inputString, 0, sizeof(inputString));&#xA;&#xA;  getFileNameSD();&#xA;&#xA;  myFile = SD.open(fullPath);&#xA;&#xA;  if(myFile){&#xA;    myFile.seek(cursorPosition);&#xA;&#xA;    endOfLine = false;    &#xA;&#xA;    while(myFile.available() &amp;amp;&amp;amp; endOfLine == false){&#xA;      inputChar = myFile.read();&#xA;&#xA;      if(inputChar == '*'){&#xA;        while(inputChar != '\n'){&#xA;          inputChar = myFile.read();&#xA;        }&#xA;      }else{&#xA;        cursorPosition = myFile.position()-1;&#xA;&#xA;        if(inputChar == 10 || inputChar == ' ') inputChar = myFile.read();&#xA;&#xA;        while(inputChar != '\n'){&#xA;          if(stringIndex &amp;lt; 25){          &#xA;            inputString[stringIndex] = inputChar;&#xA;            stringIndex++;&#xA;            inputChar = myFile.read();&#xA;          }&#xA;        }&#xA;        inputString[stringIndex-1] = '\0';        &#xA;        stringIndex    = 0;&#xA;        endOfLine      = true;        &#xA;      }      &#xA;    }&#xA;    myFile.close();    &#xA;  }&#xA;  return inputString;&#xA;}&#xA;&#xA;void getFileNameSD (){&#xA;&#xA;  char folder[] = &quot;/ACC&quot;;&#xA;&#xA;  checkFolderSD(folder);  &#xA;&#xA;  myFile = SD.open(folder);&#xA;  myFile = myFile.openNextFile();&#xA;&#xA;  if(!myFile) myFile.rewindDirectory();&#xA;&#xA;  if(myFile){&#xA;&#xA;    strcpy(fullPath,folder);&#xA;    strcat(fullPath,&quot;/&quot;);&#xA;    strcat(fullPath,myFile.name());&#xA;&#xA;    myFile.close();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have problem with this function(getDataSD). To get the name of the file, I've created another function who looks for a file in a specific folder, this function is called &lt;em&gt;getFileNameSD()&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having problem with this last function, it's not releasing or overwriting some data, so every time it's called, it is stored new data in memory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included the &lt;a href=&quot;http://github.com/maniacbug/MemoryFree&quot; rel=&quot;nofollow&quot;&gt;memory Free library&lt;/a&gt; to see where is the problem. When I call the &lt;em&gt;getDataSD&lt;/em&gt; and write the file manually I dont have problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile = SD.open(&quot;/ACC/11001&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial monitor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;freeMemory()=6592&#xA;/-27/-26/-56/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the memory always is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but not when I call the &lt;em&gt;getFileNameSD()&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile = SD.open(getFileNameSD());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial monitor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;freeMemory()=6571&#xA;/-27/-26/-56/&#xA;freeMemory()=6540&#xA;/-27/-26/-56/&#xA;freeMemory()=6509&#xA;/-27/-26/-56/&#xA;freeMemory()=6478&#xA;/-27/-26/-56/&#xA;freeMemory()=6447&#xA;/-27/-26/-56/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I'm doing something wrong with &lt;em&gt;getFileName()&lt;/em&gt; but I don't know what is, can anybody help/explain me?&lt;/p&gt;&#xA;" OwnerUserId="3966" LastEditorUserId="3966" LastEditDate="2014-11-20T23:44:24.070" LastActivityDate="2014-11-21T01:27:47.133" Title="releasing memory in sub-function" Tags="|programming|sd-card|memory-usage|code-optimization|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5084" PostTypeId="2" ParentId="5082" CreationDate="2014-11-20T15:53:26.083" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow&quot;&gt;V-USB&lt;/a&gt; can be used to create a low-speed USB device in software, but you will need to program the chip before you can use it. It also has a number of caveats that must be adhered to regarding electrical and software specifications, so it not the best choice for an absolute beginner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A USB-UART bridge (not necessarily a FTDI chip, although that is (was?) the most popular solution) will allow you to program and communicate with the chip over its serial port, but any AVR ISP programmer can also be used to program it without requiring a preexisting bootloader in place.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-20T15:53:26.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5085" PostTypeId="2" ParentId="5082" CreationDate="2014-11-20T16:41:13.980" Score="2" Body="&lt;p&gt;The &quot;Arduino Pro Micro&quot; has its own USB interface so you don't need extra stuff for it to work. However, a number of existing libraries that deals with Arduino shields do not support the new chip inside the Arduino Pro Micro (ATmega32U4) so check first to make sure it will work with what you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &quot;Arduino Pro Mini&quot; (which I use a lot since it is very very cheap, about $3 from ebay) to program it I use &quot;USPASP&quot; (also cheap ~$3) so I have three of them but you only need one to program as many Pro Minis as you like. And for communication I use a &quot;USB to TTL UART&quot; (based on the &quot;CP2102&quot; chip which works with Linux, Windows and Mac) they are also super cheap (about $2) and you connect it to the serial pins on your Pro Mini. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Just search ebay for the terms I put in quotes and you will find many of them at low prices, they ship from china so it will take about a month to get to you which is why I ordered more than I need for future projects, or for a little extra you might find local sellers with same products)&lt;/p&gt;&#xA;" OwnerUserId="4906" LastActivityDate="2014-11-20T16:41:13.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5086" PostTypeId="2" ParentId="5079" CreationDate="2014-11-20T17:29:45.877" Score="0" Body="&lt;p&gt;The backlight led (&lt;a href=&quot;http://www.adafruit.com/product/1622&quot; rel=&quot;nofollow&quot;&gt;sample&lt;/a&gt;) is just a simple led with a large transparent panel, the size of the lcd, attached to it. This panel is diffused on the top in such a way that it distributes the light evenly. If you get a rgb led, file the top flat, and glue it to the side of this panel (where the leads get out of the plastic) you should get a pretty good effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it on my white-on-blue lcd, by holding and led to the side of this panel, and it worked. Just note that you need a very bright led. Mine was pretty bright but the letters didn't light up that much.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-20T17:29:45.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5088" PostTypeId="2" ParentId="1304" CreationDate="2014-11-20T19:01:32.293" Score="0" Body="&lt;p&gt;Got the same problem using this lib with a 8 MHz Trinket, but managed to solve it by adding &lt;code&gt;#define __AVR_ATtinyX5__&lt;/code&gt; to the file hardware/attiny/variants/tiny8/pins_arduino.h. I'm using the Adafruit support package for ATtiny. Perhaps a bit of a hack, but I can still build for the UNO, by selecting board in Arduino IDE 1.0.5.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2014-11-20T19:01:32.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5089" PostTypeId="2" ParentId="5072" CreationDate="2014-11-20T19:20:35.500" Score="2" Body="&lt;ul&gt;&#xA;&lt;li&gt;Yes, there are USB interfaces for ATtiny85. Just look at one of the open hardware designs out there, e.g. &lt;a href=&quot;http://digistump.com&quot; rel=&quot;nofollow&quot;&gt;Digispark&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;An USB interface is going to require two pins, so using one to save one pin doesn’t strike me as cost effective.&lt;/li&gt;&#xA;&lt;li&gt;I agree with @FAD, that you don’t really need an USB stack, and simply could do a time-delay-at-boot thing with the UART pins.&lt;/li&gt;&#xA;&lt;li&gt;HVSP (the high voltage programming) is not hard to do. If you’re already comfortable with ArduinoISP, you can try &lt;a href=&quot;http://microtherion.github.io/ScratchMonkey/index.html&quot; rel=&quot;nofollow&quot;&gt;ScratchMonkey&lt;/a&gt;, which uses the same approach (with a 12V power supply and one transistor) to do HVSP programming. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-11-20T19:20:35.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5090" PostTypeId="1" AcceptedAnswerId="5091" CreationDate="2014-11-20T20:19:41.760" Score="0" ViewCount="7633" Body="&lt;p&gt;I am trying to send a floating point number from a python script to an Arduino.  I am not sure how to do this, especially in a pythonic way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little bit of research brought me to this very similar question:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3753/how-to-send-numbers-to-arduino-uno-via-python-3-and-the-module-serial&quot;&gt;How to send numbers to Arduino UNO via Python 3 and the module serial&lt;/a&gt;&#xA;I vaguely understand why this would work for an int but don't know how to modify it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) In this question it makes sense to convert to a char, send, and then convert back to a int by casting on the Arduino, I can't think how to do that for a float.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Why do they convert to a Char anyway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) What code do I run on the arduino to get this back into a float?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Can I use bitwise operators on floating point numbers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to python and also to low level programming. I am also aware that python and low level don't mix to well. I am using Linux but ideally I need a cross platform solution. Although I would prefer to get it working then worry about cross platform later.&lt;/p&gt;&#xA;" OwnerUserId="4911" LastEditorUserId="220" LastEditDate="2014-11-20T23:50:31.930" LastActivityDate="2019-11-26T13:59:15.890" Title="Sending a floating point number from python to arduino" Tags="|serial|python|float|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5091" PostTypeId="2" ParentId="5090" CreationDate="2014-11-20T20:32:44.417" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;In this question it makes sense to convert to a char, send, and then convert back to a int by casting on the Arduino, I can't think how to do that for a float.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Instead of using a format specifier of &lt;code&gt;B&lt;/code&gt; for an unsigned byte, use &lt;code&gt;f&lt;/code&gt; for a single-precision float. AVR-GCC doesn't support double-precision floats, so don't bother with &lt;code&gt;d&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why do they convert to a Char anyway?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't. You convert it to bytes (hence the &lt;code&gt;b&lt;/code&gt; prefix on the representation of the value) so that the byte-oriented serial protocol can transmit it. On Python 2.x &lt;code&gt;str&lt;/code&gt; is already bytes, so no prefix is required there.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What code do I run on the arduino to get this back into a float?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;code&gt;Serial.readBytes()&lt;/code&gt; to dump the bytes from the serial connection into a &lt;code&gt;float&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float f;&#xA; ...&#xA;if (Serial.readBytes((char*)&amp;amp;f, sizeof(f)) != sizeof(f)) {&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use bitwise operators on floating point numbers?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;... Well... no... because they may not necessarily remain valid floating point numbers afterwards.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-20T20:32:44.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5092" PostTypeId="1" AcceptedAnswerId="5093" CreationDate="2014-11-20T21:33:05.793" Score="5" ViewCount="351" Body="&lt;p&gt;I am using I2C to communicate between a collection of ATtiny85s that are acting as controllers for various parts of a system and the &quot;Main Brain&quot; -- a RaspberryPi. Most of the ATtiny85s only have a couple of free pins left (usually Pins 1 and 2 -- the reset and the pin that can't be used for PWM) so I can't use something like a DIP switch to directly set device IDs. I'd rather not hardcode the device IDs when I push code to the tinys but I can't think of a good, simple, and reliable way to do it otherwise. Anyone here have a suggestion?&lt;/p&gt;&#xA;" OwnerUserId="3688" LastActivityDate="2014-11-20T22:08:24.610" Title="Ideas for setting I2C device IDs" Tags="|i2c|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5093" PostTypeId="2" ParentId="5092" CreationDate="2014-11-20T22:01:45.150" Score="1" Body="&lt;p&gt;You could use the analog input on pin 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a table in your code to map voltage thresholds to I2C IDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then build a voltage divider circuit as input that you can adjust with switches or by installing different resistors.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-11-20T22:01:45.150" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5094" PostTypeId="2" ParentId="5083" CreationDate="2014-11-20T22:04:17.137" Score="1" Body="&lt;p&gt;Ok,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know, why your memory is leaking, but anyway, your program won't work safely. &#xA;You defined an array (fullPath) inside the local scope of your function. You return it, which means, you return a pointer to this array. But at the same time, this array gets invalid, because you leave the local scope of your function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better define that string outside the function and give it as a parameter to the function. Then you aren't in danger of accessing an invalid pointer. Furthermore your memory leak won't appear.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2014-11-20T22:04:17.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5095" PostTypeId="2" ParentId="5092" CreationDate="2014-11-20T22:08:24.610" Score="6" Body="&lt;p&gt;Put the address in EEPROM. It's still &quot;on the chip&quot; but it can be programmed independent of the flash, and can be changed on the fly if deemed appropriate.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-20T22:08:24.610" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5096" PostTypeId="1" CreationDate="2014-11-20T22:48:22.123" Score="2" ViewCount="5449" Body="&lt;p&gt;I am trying to use this example code from the &lt;a href=&quot;https://github.com/sui77/rc-switch&quot; rel=&quot;nofollow&quot;&gt;RCSwitch library&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Simple example for receiving&#xA;&#xA;  https://github.com/sui77/rc-switch&#xA;*/&#xA;&#xA;#include &amp;lt;RCSwitch.h&amp;gt;&#xA;&#xA;RCSwitch mySwitch = RCSwitch();&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 =&amp;gt; that is pin #2&#xA;}&#xA;&#xA;void loop() {&#xA;  if (mySwitch.available()) {&#xA;    Serial.print(&quot;Is avail&quot;);&#xA;    int value = mySwitch.getReceivedValue();&#xA;&#xA;    if (value == 0) {&#xA;      Serial.print(&quot;Unknown encoding&quot;);&#xA;    } else {&#xA;      Serial.print(&quot;Received &quot;);&#xA;      Serial.print( mySwitch.getReceivedValue() );&#xA;      Serial.print(&quot; / &quot;);&#xA;      Serial.print( mySwitch.getReceivedBitlength() );&#xA;      Serial.print(&quot;bit &quot;);&#xA;      Serial.print(&quot;Protocol: &quot;);&#xA;      Serial.println( mySwitch.getReceivedProtocol() );&#xA;    }&#xA;&#xA;    mySwitch.resetAvailable();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like the mySwitch.available() is returning false, but since there seems to be no documentation for the library I don't know what it means.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to use this code on a A-Star 32U4 Micro, which supports Arduino code.&lt;/p&gt;&#xA;" OwnerUserId="4912" LastEditorUserId="10003" LastEditDate="2015-08-19T13:33:36.807" LastActivityDate="2020-03-22T10:32:20.460" Title="Why does the RCSwitch.available return false?" Tags="|library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5097" PostTypeId="1" AcceptedAnswerId="5098" CreationDate="2014-11-20T18:14:48.210" Score="6" ViewCount="32192" Body="&lt;p&gt;I have an &lt;a href=&quot;http://www.analog.com/static/imported-files/data_sheets/AD5686R_5685R_5684R.pdf&quot; rel=&quot;noreferrer&quot;&gt;AD5685R DAC&lt;/a&gt; that I am trying to communicate with over SPI. Per the datasheet,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...These [24] bits are transferred to the input register on the 24 falling edges of &lt;code&gt;SCLK&lt;/code&gt; and are updated on the rising edge of &lt;code&gt;/SYNC&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;/SYNC&lt;/code&gt; is used as chip-select.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe Arduino's &lt;a href=&quot;http://arduino.cc/en/Reference/SPITransfer&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;SPI.transfer&lt;/code&gt;&lt;/a&gt; waits to receive 8 bits after sending 8 bits. But for this particular DAC, I need to send 24 straight bits on 24 clock edges before releasing the chip-select. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="4759" OwnerDisplayName="Dang Khoa" LastActivityDate="2021-12-08T10:59:57.450" Title="How do I transfer more than 1 byte at once via SPI bus?" Tags="|spi|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5098" PostTypeId="2" ParentId="5097" CreationDate="2014-11-20T18:26:52.663" Score="11" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I believe Arduino's &lt;code&gt;SPI.transfer&lt;/code&gt; waits to receive 8 bits after sending 8 bits.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Incorrect. With SPI, a byte is clocked in &lt;em&gt;at the same time&lt;/em&gt; as a byte is clocked out. It may be that this byte is simply a dummy byte though, if the slave has nothing to say.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for 24 bits, simply clock out 3 bytes without deasserting the select. Since SPI is a synchronous protocol there should be no issue with having a delay in between bytes provided the select is maintained.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-11-20T18:26:52.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5099" PostTypeId="2" ParentId="5097" CreationDate="2014-11-20T18:27:47.590" Score="4" Body="&lt;p&gt;Looks like it just set cs low and do three byte transfers then bring it high.   Here's someone's example on how to do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.reigndesign.com/blog/controlling-a-10-bit-digital-potentiometer-via-spi-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.reigndesign.com/blog/controlling-a-10-bit-digital-potentiometer-via-spi-with-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code below taken from above page.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt; &#xA;&#xA;const int csPin = 10;&#xA;&#xA;void setup() {&#xA;&#xA; SPI.begin();&#xA; SPI.setBitOrder(MSBFIRST); //We know this from the Data Sheet&#xA;&#xA; pinMode(csPin,OUTPUT);&#xA; digitalWrite(csPin, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA; for(int i=0; i&amp;lt;1023; i++) { &#xA;  digitalPotWrite(0,i);&#xA;  delay(10);&#xA; } &#xA;}&#xA;&#xA;void digitalPotWrite(int address, int value) {&#xA; digitalWrite(csPin, LOW); //select slave&#xA; byte command = 0xB0; //0xB0 = 10110000 &#xA; command += address; &#xA; SPI.transfer(command); &#xA; byte byte1 = (value &amp;gt;&amp;gt; 8);&#xA; byte byte0 = (value &amp;amp; 0xFF); //0xFF = B11111111&#xA; SPI.transfer(byte1);&#xA; SPI.transfer(byte0);&#xA; digitalWrite(csPin, HIGH); //de-select slave&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Some Hardware Guy" LastActivityDate="2014-11-20T18:27:47.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5100" PostTypeId="2" ParentId="5097" CreationDate="2014-11-20T18:29:09.047" Score="7" Body="&lt;p&gt;In the SPI protocol, you get one byte back for every one you send.  If you are not interested in the response from a device, you can just ignore the return bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI has no handshaking.  You just must send no faster than the slave device can handle.  In the case of the AD5685R, that is 50 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For multibyte transfer, you keep the chip select asserted (low) between every byte by setting the transferMode to SPI_CONTINUE in the SPI.transfer call.  For the last byte, you will deassert the chip select (set it high) by setting the transferMode parameter to SPI_LAST in the SPI.transfer call..&lt;/p&gt;&#xA;" OwnerUserId="396" OwnerDisplayName="tcrosley" LastActivityDate="2014-11-20T18:29:09.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5101" PostTypeId="2" ParentId="5083" CreationDate="2014-11-21T01:02:46.280" Score="1" Body="&lt;p&gt;Well, finally someone found where was the problem.&#xA;In the &lt;em&gt;getFileName()&lt;/em&gt; function, I open two instances of the file but I close just one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the answer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;File myFile;&#xA;int stringIndex = 0;&#xA;int cursorPosition = 0;&#xA;char inputString [25];&#xA;char inputChar;&#xA;boolean endOfLine;&#xA;char fullPath[11];&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.print(&quot;Initializing SD card.&quot;);&#xA;  pinMode(10, OUTPUT);&#xA;  digitalWrite(10, HIGH);&#xA;&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;initialization done.&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  Serial.println(getDataSD());&#xA;&#xA;  Serial.print(&quot;freeMemory()=&quot;);&#xA;  Serial.println(freeMemory());&#xA;}&#xA;&#xA;void getDataSD(){&#xA;&#xA;  memset(inputString, 0, sizeof(inputString));&#xA;&#xA;  getFileNameSD();&#xA;&#xA;  myFile = SD.open(fullPath);&#xA;&#xA;  if(myFile){&#xA;    myFile.seek(cursorPosition);&#xA;&#xA;    endOfLine = false;    &#xA;&#xA;    while(myFile.available() &amp;amp;&amp;amp; endOfLine == false){&#xA;      inputChar = myFile.read();&#xA;&#xA;      if(inputChar == '*'){&#xA;        while(inputChar != '\n'){&#xA;          inputChar = myFile.read();&#xA;        }&#xA;      }else{&#xA;        cursorPosition = myFile.position()-1;&#xA;&#xA;        if(inputChar == 10 || inputChar == ' ') inputChar = myFile.read();&#xA;&#xA;        while(inputChar != '\n'){&#xA;          if(stringIndex &amp;lt; 25){          &#xA;            inputString[stringIndex] = inputChar;&#xA;            stringIndex++;&#xA;            inputChar = myFile.read();&#xA;          }&#xA;        }&#xA;        inputString[stringIndex-1] = '\0';        &#xA;        stringIndex    = 0;&#xA;        endOfLine      = true;        &#xA;      }      &#xA;    }&#xA;    myFile.close();    &#xA;  }&#xA;}&#xA;&#xA;void getFileNameSD (){&#xA;&#xA;  char folder[] = &quot;/ACC&quot;;&#xA;  File myDir = SD.open(folder);&#xA;&#xA;  memset(fullPath, 0, sizeof(fullPath));&#xA;&#xA;  if (myDir){&#xA;    myFile = myDir.openNextFile();&#xA;&#xA;    if(myFile){&#xA;      strcpy(fullPath,folder);&#xA;      strcat(fullPath,&quot;/&quot;);&#xA;      strcat(fullPath,myFile.name());&#xA;      myFile.close();&#xA;      myDir.close();&#xA;    }else{&#xA;      // Handle file not found&#xA;      myDir.close();&#xA;      fullPath[0] = '0';&#xA;    }&#xA;  }else{&#xA;    // Handle directory not opened&#xA;    fullPath[0] = '0';&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3966" LastEditorUserId="3966" LastEditDate="2014-11-21T01:27:47.133" LastActivityDate="2014-11-21T01:27:47.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5102" PostTypeId="1" CreationDate="2014-11-21T01:48:34.940" Score="5" ViewCount="827" Body="&lt;p&gt;I am planning to build a LED polar clock, so it will need about 181 LEDs (12 Month, 31 Day, 7 Day-of-week, 12 Hour, 60 Minute, 59 Second) and I need to control each one individually. I will be buying everything from scratch so I ask for help on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Which arduino to use&lt;/li&gt;&#xA;&lt;li&gt;How to make it keep time&lt;/li&gt;&#xA;&lt;li&gt;How to control the LEDs&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The LEDs need to stay on once they're lit, e.g. at 5 o'clock, the 1-5 LEDs would be on.&#xA;This is why I don't know that multiplexing or charlieplexing will work, as I read that it is better if the LEDs wont be remaining on/only a few are on. The most that could be on is 179 (Friday, December 31, 11:59:59 [Won't happen until 2021]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="4914" LastActivityDate="2014-12-29T15:49:06.840" Title="Individually control ~200 LEDs" Tags="|led|time|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5104" PostTypeId="1" CreationDate="2014-11-21T09:13:52.163" Score="-2" ViewCount="3827" Body="&lt;p&gt;I have connected mc to a pc using USB. I need data on hyperterminal through serial to USB connection, hence I connected TX, RX and gnd pins of the Leonardo to the rs232 pins and one other side of rs232 to USB to pc. However, the data is still transmitting on serial monitor, but not on hyperterminal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(3,INPUT); // This is the pin to which we have connected the button&#xA;  attachInterrupt(0, IRsensor, CHANGE);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) {&#xA;    /* read the most recent byte */&#xA;    /*ECHO the value that was read, back to the serial port. */&#xA;    Serial.write(count);&#xA;  }&#xA;}&#xA;&#xA;void IRsensor() {&#xA;  if(digitalRead(3) == 1) {&#xA;    count++;&#xA;    Serial.println(count);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4918" LastEditorUserId="37" LastEditDate="2014-11-21T15:29:35.963" LastActivityDate="2014-11-21T15:29:35.963" Title="how to serially communicate the arduino leonardo to pc through hyperterminal" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5105" PostTypeId="2" ParentId="5104" CreationDate="2014-11-21T09:25:38.613" Score="3" Body="&lt;p&gt;To be sure, please add code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use usb on Arduino to communicate with pc. You don't need RS232/USB converter. Just open hyperterminal with the port of arduino. Arduino port can be found in:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino IDE Tools&gt;Port&lt;/li&gt;&#xA;&lt;li&gt;My Computer&gt;Properties&gt;Device manager&gt;Ports&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you really need &lt;code&gt;SoftwareSerial&lt;/code&gt; then connect Rx,Tx and don't forget GND! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To communicate with RS232/USB converter you have to add RS232/TTL converter to Arduino side. The schematic would look like PC &amp;lt;-&gt; USB/RS232 &amp;lt;-&gt; RS232/TTL &amp;lt;-&gt; Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;PC - your computer&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11304&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB/RS232&lt;/a&gt; to convert from usb to RS232. On RS232 side the voltage is -5V to +5V&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ti.com/lit/ds/symlink/max232.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAX232&lt;/a&gt; RS232/TTL. To convert the voltage&lt;/li&gt;&#xA;&lt;li&gt;Arduino - your MCU&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i said, connect your arduino to PC like you do while programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PG9JV.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;Next, upload this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available()){&#xA;   Serial.print(&quot;\nReceived: &quot;);&#xA;   Serial.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Open HyperTerminal: choose port with Arduino, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fA2Pp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect to arduino, &lt;strong&gt;Serial Monitor has to be closed&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L1moo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="3866" LastEditDate="2014-11-21T10:37:45.917" LastActivityDate="2014-11-21T10:37:45.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5106" PostTypeId="1" AcceptedAnswerId="5107" CreationDate="2014-11-21T09:40:41.107" Score="3" ViewCount="233" Body="&lt;p&gt;I use simple LED blinking code on an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino MEGA 2560&lt;/a&gt;. I simulate it in Proteus. But pin number 9 doesn't power up. What is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Set up the DATA direction&#xA;void setup()&#xA;{&#xA;  for(int i = 1; i&amp;lt;9; i++)&#xA;    pinMode (i, OUTPUT);&#xA;}&#xA;&#xA;// The main program&#xA;void loop()&#xA;{&#xA;  for(int j=2; j&amp;lt;=10; j++)&#xA;  {&#xA;    digitalWrite(j, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(j, LOW);&#xA;  }&#xA;&#xA;  for(int j=9; j&amp;gt;=2; j--)&#xA;  {&#xA;    digitalWrite(j, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(j, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the circuit is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DeHzm.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4869" LastEditorUserId="510" LastEditDate="2015-12-24T22:24:53.003" LastActivityDate="2015-12-24T22:24:53.003" Title="Why doesn't pin 9 blink?" Tags="|arduino-mega|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5107" PostTypeId="2" ParentId="5106" CreationDate="2014-11-21T10:00:43.977" Score="4" Body="&lt;p&gt;It looks like your main problem is the loop in &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 1; i&amp;lt;9; i++)&#xA;    pinMode (i, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call &lt;code&gt;pinMode()&lt;/code&gt; with values 1 to 8 (inclusive), and then stop. That means you aren't configuring pin 9 as an output. You need to change the loop condition to &lt;strong&gt;&lt;code&gt;i&amp;lt;=9&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if your circuit diagram is accurate then you will have another problem. When implementing the circuit for real, you absolutely &lt;strong&gt;must&lt;/strong&gt; have a suitable resistor in series with each LED (maybe something around 200 Ohms, depending on the exact specifications). If not, you seriously risk destroying the LEDs and maybe damaging your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-21T10:00:43.977" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5109" PostTypeId="2" ParentId="5096" CreationDate="2014-11-21T14:01:26.837" Score="1" Body="&lt;p&gt;I think that the value of available just determine if there is a message to receive or not. &lt;/p&gt;&#xA;" OwnerUserId="4912" LastActivityDate="2014-11-21T14:01:26.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5110" PostTypeId="2" ParentId="5102" CreationDate="2014-11-21T16:54:58.310" Score="0" Body="&lt;p&gt;Multiplexing will work fine in this case (Charlieplexing isn't practical here). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You create an array of leds, and light up only one row at a time. If you rotate through all the rows at more than 50 times a second your eyes won't notice it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of 181 leds, you'd need and array of e.g. 13x14. This will mean you need a minimum of 27 IO-pins. More than the regular Arduinos provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you probably need some additional ICs. You could use simple shift registers, or dedicated led-matrix drivers like the max7219 or some other IC. The Max7219 is probably the easiest, as you don't have to do the multiplexing yourself. The can light upto 64 leds (8x8), so you'd need 3 of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I get a different number though; 12 (month) + 31 (day) + 7 (weekday) + 23 (hours) + 59 (min) + 59 (sec)= 191&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-21T16:54:58.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5111" PostTypeId="1" AcceptedAnswerId="5113" CreationDate="2014-11-21T19:35:12.353" Score="1" ViewCount="384" Body="&lt;p&gt;I am using an amazing code to send/read infrared pulses without any external library. The code is fine and I took about 1 hour to fully understand it. The only thing I didnt understand is the variable RESOLUTION. I believe it should be 0 not 20. I think it should be as low as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the code at:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/ir-sensor/using-an-ir-sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/ir-sensor/using-an-ir-sensor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Raw IR decoder sketch!&#xA;This sketch/program uses the Arduino and a PNA4602 to&#xA;decode IR received. This can be used to make a IR receiver&#xA;(by looking for a particular code)&#xA;or transmitter (by pulsing an IR LED at ~38KHz for the&#xA;durations detected&#xA;Code is public domain, check out www.ladyada.net and adafruit.com&#xA;for more tutorials!&#xA;*/&#xA;&#xA;// We need to use the 'raw' pin reading methods&#xA;// because timing is very important here and the digitalRead()&#xA;// procedure is slower!&#xA;//uint8_t IRpin = 2;&#xA;// Digital pin #2 is the same as Pin D2 see&#xA;// http://arduino.cc/en/Hacking/PinMapping168 for the 'raw' pin mapping&#xA;#define IRpin_PIN PIND&#xA;#define IRpin 2&#xA;// for MEGA use these!&#xA;//#define IRpin_PIN PINE&#xA;//#define IRpin 4&#xA;&#xA;// the maximum pulse we'll listen for - 65 milliseconds is a long time&#xA;#define MAXPULSE 65000&#xA;&#xA;// what our timing resolution should be, larger is better&#xA;// as its more 'precise' - but too large and you wont get&#xA;// accurate timing&#xA;#define RESOLUTION 20&#xA;&#xA;// we will store up to 100 pulse pairs (this is -a lot-)&#xA;uint16_t pulses[100][2]; // pair is high and low pulse&#xA;uint8_t currentpulse = 0; // index for pulses we're storing&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Ready to decode IR!&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  uint16_t highpulse, lowpulse; // temporary storage timing&#xA;  highpulse = lowpulse = 0; // start out with no pulse length&#xA;&#xA;&#xA;// while (digitalRead(IRpin)) { // this is too slow!&#xA;    while (IRpin_PIN &amp;amp; (1 &amp;lt;&amp;lt; IRpin)) {&#xA;     // pin is still HIGH&#xA;&#xA;     // count off another few microseconds&#xA;     highpulse++;&#xA;     delayMicroseconds(RESOLUTION);&#xA;&#xA;     // If the pulse is too long, we 'timed out' - either nothing&#xA;     // was received or the code is finished, so print what&#xA;     // we've grabbed so far, and then reset&#xA;     if ((highpulse &amp;gt;= MAXPULSE) &amp;amp;&amp;amp; (currentpulse != 0)) {&#xA;       printpulses();&#xA;       currentpulse=0;&#xA;       return;&#xA;     }&#xA;  }&#xA;  // we didn't time out so lets stash the reading&#xA;  pulses[currentpulse][0] = highpulse;&#xA;&#xA;  // same as above&#xA;  while (! (IRpin_PIN &amp;amp; _BV(IRpin))) {&#xA;     // pin is still LOW&#xA;     lowpulse++;&#xA;     delayMicroseconds(RESOLUTION);&#xA;     if ((lowpulse &amp;gt;= MAXPULSE) &amp;amp;&amp;amp; (currentpulse != 0)) {&#xA;       printpulses();&#xA;       currentpulse=0;&#xA;       return;&#xA;     }&#xA;  }&#xA;  pulses[currentpulse][1] = lowpulse;&#xA;&#xA;  // we read one high-low pulse successfully, continue!&#xA;  currentpulse++;&#xA;}&#xA;&#xA;void printpulses(void) {&#xA;  Serial.println(&quot;\n\r\n\rReceived: \n\rOFF \tON&quot;);&#xA;  for (uint8_t i = 0; i &amp;lt; currentpulse; i++) {&#xA;    Serial.print(pulses&#xA;* RESOLUTION, DEC);&#xA;&#xA;    Serial.print(&quot; usec, &quot;);&#xA;    Serial.print(pulses[1] * RESOLUTION, DEC);&#xA;    Serial.println(&quot; usec&quot;);&#xA;  }&#xA;&#xA;  // print it in a 'array' format&#xA;  Serial.println(&quot;int IRsignal[] = {&quot;);&#xA;  Serial.println(&quot;// ON, OFF (in 10's of microseconds)&quot;);&#xA;  for (uint8_t i = 0; i &amp;lt; currentpulse-1; i++) {&#xA;    Serial.print(&quot;\t&quot;); // tab&#xA;    Serial.print(pulses[1] * RESOLUTION / 10, DEC);&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(pulses[i+1][0] * RESOLUTION / 10, DEC);&#xA;    Serial.println(&quot;,&quot;);&#xA;  }&#xA;  Serial.print(&quot;\t&quot;); // tab&#xA;  Serial.print(pulses[currentpulse-1][1] * RESOLUTION / 10, DEC);&#xA;  Serial.print(&quot;, 0};&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4924" LastEditorUserId="26916" LastEditDate="2017-11-04T17:51:53.323" LastActivityDate="2017-11-04T17:51:53.323" Title="Why is resolution 20?" Tags="|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5112" PostTypeId="1" AcceptedAnswerId="5114" CreationDate="2014-11-21T19:46:23.093" Score="0" ViewCount="84" Body="&lt;p&gt;I have a code that sends 384 pulses at 38kHz with an infrared LED. It's very easy to understand it. At the beggining the code sends the pulses using the LED and in the middle of the code I check the sensor if it has any signal coming. So far so good, yes? Please, take a look:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i=0;i&amp;lt;384;i++) {&#xA;  digitalWrite(IRledPin,HIGH);&#xA;  delayMicroseconds(13);&#xA;  digitalWrite(IRledPin,LOW);&#xA;  delayMicroseconds(13);&#xA;}&#xA;&#xA;if (digitalRead(IRsensorPin) == LOW){&#xA;  digitalWrite(D13ledPin,HIGH);&#xA;} else {&#xA;  digitalWrite(D13ledPin,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is this: I first send the pulses, so when I reach the line &lt;code&gt;if (digitalRead(IRsensorPin) == LOW){&lt;/code&gt; the pulse should already have passed the sensor. So why does it work? It should not work cause I first send the pulse and then I check for the pulse but as I understand the 384 pulses should already have passed the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea why this code works. I would be glad to listen smarter people to help me understand this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4924" LastEditorDisplayName="user4892" LastEditDate="2014-11-21T21:05:24.393" LastActivityDate="2014-11-21T21:05:24.393" Title="How this smal infrared work" Tags="|ir|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5113" PostTypeId="2" ParentId="5111" CreationDate="2014-11-21T20:45:08.617" Score="2" Body="&lt;p&gt;Most IR remotes send pulses that are at least 400 micro seconds long. E.g. on a NEC IR remote you get pulses that are 560 or 2240 microseconds long (depending on whether it's sending a 1 or a 0). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with a RESOLUTION of 20 you get at least 20 'pulse counts' for a &lt;code&gt;0&lt;/code&gt; and 80 for a &lt;code&gt;1&lt;/code&gt;. Because remotes aren't that precise in you'll get somewhere between e.g. 18 and 22 or 78 and 82. Those values are different enough to easily detect whether a 0 or 1 was send. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing this RESOLUTION to e.g. 2 will give you 200 or 800 pulsecounts. You'll get a more precise timings from a still imprecise source. But this better precision is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS setting it to 0 could break the code, as the highpulse and lowpulse are only 16 bit integers so they will overflow after 65536, which will happen pretty fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps somewhat. Just let me know is anything is still unclear.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-11-24T14:16:15.047" LastActivityDate="2014-11-24T14:16:15.047" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5114" PostTypeId="2" ParentId="5112" CreationDate="2014-11-21T20:58:10.580" Score="0" Body="&lt;p&gt;The IR receiver does some filtering on the signal. It doesn't signal a LOW immediately if it lost a single pulse of light. A speck of dust, hanging in the air, might just be blocking the IR phototransitor. Or some brief flash of light, making two pulses seem like one or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These IR receivers a specifically build to filter out the 'noise' coming from other light sources and light obstructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Identically, you would want this receiver to give you a HIGH if it detect only 2 pulses of light 13uS apart. I could just be some sunlight reflected from a puddle, accidentally matching 38kHz.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-21T20:58:10.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5116" PostTypeId="1" CreationDate="2014-11-21T22:22:20.323" Score="1" ViewCount="1919" Body="&lt;p&gt;I've been trying to work with an &lt;a href=&quot;http://www.analog.com/static/imported-files/data_sheets/AD5686R_5685R_5684R.pdf&quot; rel=&quot;nofollow&quot;&gt;AD5685R DAC&lt;/a&gt;. Per that datasheet, to get &lt;code&gt;DAC1&lt;/code&gt; to output max voltage (5V), I would perform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.begin();&#xA;SPI.setBitOrder(MSBFIRST);&#xA;SPI.setDataMode(SPI_MODE3); // DAC uses CPHA=1, CPOL=1&#xA;&#xA;digitalWrite(CS, LOW);&#xA;SPI.transfer(0x31); // upper nibble sends a &quot;write and update&quot; command, lower nibble says &quot;DAC1&quot;&#xA;SPI.transfer(0xFF);&#xA;SPI.transfer(0xFC); // 14-bit DAC, last 2 bits are dontcares, make them 0&#xA;digitalWrite(CS, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace &lt;code&gt;0xFFFC&lt;/code&gt; with &lt;code&gt;0x0000&lt;/code&gt; to get 0 volts out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sending this command as written somehow writes to &lt;code&gt;DAC4&lt;/code&gt; instead of &lt;code&gt;DAC1&lt;/code&gt;! and while 5V will come out when I write &lt;code&gt;0xFFFC&lt;/code&gt;, I get to 2.5V when writing &lt;code&gt;0x0000&lt;/code&gt; instead of 0V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I command this with a Bus Pirate and directly write the bytes out, it works exactly as desired. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the Bus Pirate to sniff the SPI traffic and it turns out I'm not getting what I've commanded. Rather than &lt;code&gt;0x31 0x00 0x00&lt;/code&gt; for instance, I get &lt;code&gt;0x18 0x80 0x00&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we break this out into bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x310000: 0011 0001 0000 0000 0000 0000 // commanded&#xA;0x188000: 0001 1000 1000 0000 0000 0000 // actually sent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the command actually sent out is shifted by 1 bit!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the bit pattern for 16383 counts (i.e., 2^14-1):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x31FFFC: 0011 0001 1111 1111 1111 1100 // commanded&#xA;0x18FFFE: 0001 1000 1111 1111 1111 1110 // actually sent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The opcode corresponding to &lt;code&gt;0x18&lt;/code&gt; is &quot;write to input register 4&quot; (the output occurs because I've pulled the &lt;code&gt;/LDAC&lt;/code&gt; pin permanently low, see the datasheet), which explains why I'm getting an output on &lt;code&gt;DAC4&lt;/code&gt; instead of &lt;code&gt;DAC1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This occurs with both a Sparkfun Pro Micro and an Arduino Mega 2560. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going on here? Why is the Arduino not sending out what I've actually commanded? Again, writing the hex codes directly to the DAC using a Bus Pirate works perfectly.&lt;/p&gt;&#xA;" OwnerUserId="4759" LastActivityDate="2015-07-03T05:57:29.793" Title="Why is the output on the MOSI line shifted 1 bit over from what I commanded?" Tags="|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5118" PostTypeId="1" AcceptedAnswerId="5124" CreationDate="2014-11-22T10:47:10.340" Score="2" ViewCount="802" Body="&lt;p&gt;I'm just starting to discover Arduino. Currently, I've done 2 lessons from Arduino book and I have few questions about second circuit.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/QfxUh.jpg&quot; alt=&quot;schema of second circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why we need to add 10kOm resistors after wire to 2 pin?&lt;/li&gt;&#xA;&lt;li&gt;Why we need to add resistors after LED?&lt;/li&gt;&#xA;&lt;li&gt;And why 3, 5, 6, 9, 10, 11 pins with &quot;wave&quot; symbol?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4930" LastActivityDate="2014-11-22T15:38:41.487" Title="Lessons 2: Spaceship interface" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5119" PostTypeId="1" AcceptedAnswerId="5120" CreationDate="2014-11-22T11:59:04.293" Score="16" ViewCount="20453" Body="&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Nano connected via a USB cable (Type A to Mini Type B) to my MacBook Air (Mid 2013 Model). The PWR LED is on while the arduino is connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Opening the Arduino software, pulling down the &lt;code&gt;Tools &amp;gt; Serial Port&lt;/code&gt; menu does not show me a valid serial port. All I see is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.Bluetooth-Incoming-Port&#xA;/dev/cu.Bluetooth-Incoming-Port&#xA;/dev/tty.Bluetooth-Modem&#xA;/dev/cu.Bluetooth-Modem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;What I've tried and did not work&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have installed the correct FTDI driver (v2.2.18). x64 for my MacBook Air's Corei5, file &lt;code&gt;FTDIUSBSerialDriver_10_4_10_5_10_6_10_7.mpkg&lt;/code&gt;. Restarted after installation.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Tried connecting arduino to both USB ports on my Air.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;More Info&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Running Mac OSX 10.10 Yosemite&lt;/li&gt;&#xA;&lt;li&gt;Same arduino and cable work when connected to a Windows machine or a Raspberry Pi.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If it helps, I can see the USB Serial in my &lt;code&gt;Apple Logo &amp;gt; About This Mac &amp;gt; System Report&lt;/code&gt; under &lt;code&gt;Hardware &amp;gt; USB&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USB2.0-Serial:&#xA;&#xA;  Product ID:               0x7523&#xA;  Vendor ID:                0x1a86&#xA;  Version:                  2.54&#xA;  Speed:                    Up to 12 Mb/sec&#xA;  Location ID:              0x14100000 / 8&#xA;  Current Available (mA):   500&#xA;  Current Required (mA):    Unknown (Device has not been configured)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm out of ideas and options. Any help would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance :)&lt;/p&gt;&#xA;" OwnerUserId="4931" LastActivityDate="2016-07-15T01:34:55.197" Title="Arduino Nano no serial port for MacBook Air 2013" Tags="|serial|arduino-nano|usb|mac-os|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5120" PostTypeId="2" ParentId="5119" CreationDate="2014-11-22T12:38:06.830" Score="13" Body="&lt;p&gt;This solved it for me.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download &lt;a href=&quot;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=178&quot; rel=&quot;nofollow&quot;&gt;this driver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Install it&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Serial ports now showed up in the Arduino IDE and also when I used &lt;code&gt;ls -1 /dev/tty*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopes this helps someone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=261375.0&quot; rel=&quot;nofollow&quot;&gt;This thread&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4931" LastEditorUserId="11763" LastEditDate="2016-07-15T01:34:55.197" LastActivityDate="2016-07-15T01:34:55.197" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="5123" PostTypeId="2" ParentId="4426" CreationDate="2014-11-22T15:35:36.257" Score="1" Body="&lt;p&gt;I'm working on the same project (with the same hardware) and I have an identical problem.&#xA;Seems like an HTTP request blows up your serial monitor, but is not true in my view. &#xA;In fact, if you use the TinyGPS++ library will not have this problem anymore.&#xA;Take as reference the GsmWebClient example, you can add a few lines of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is all you need for parse with tinyGPS:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;&#xA;TinyGPSPlus gps;&#xA;&#xA;AltSoftSerial ss;&#xA;&#xA;//Add this to your sketch, in loop() or setup()&#xA;&#xA;ss.begin(9600);&#xA;&#xA;while (ss.available() &amp;gt; 0)&#xA;&#xA;    if (gps.encode(ss.read())) {&#xA;        gps.location.lat(); //return latitude as a double&#xA;        gps.location.lng(); //return longitude as a double&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4933" LastEditorUserId="220" LastEditDate="2014-11-25T01:52:24.310" LastActivityDate="2014-11-25T01:52:24.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5124" PostTypeId="2" ParentId="5118" CreationDate="2014-11-22T15:38:41.487" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why we need to add 10kOm resistors after wire to 2 pin?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Due to some weird electronic properties, the state of the input to the Arduino is &quot;undefined&quot; when there is nothing connected. When the button isn't pressed down, it is neither connected to 5V or GND; it is left &lt;em&gt;floating&lt;/em&gt;. When floating, the input isn't reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make sure that the input always has some sort of signal, we connect it to ground. However, there is a problem with directly connecting the input to ground. When you would push the button, you would create a short circuit by allowing current to flow directly from 5V to GND without any current limiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to add a resistor to limit the current between 5V and GND. When the button isn't pushed, the input is grounded to allow it to read LOW. When the button is pushed, the 5V rushes in and, since the 5V doesn't use a resistor, &quot;the 5V is stronger,&quot; making the input HIGH.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why we need to add resistors after LED?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An overly simplified explanation: A LED will theoretically pull infinite power (as current) from your power source without a resistor. With too much power, the LED will be destroyed from heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the LED has &lt;em&gt;some&lt;/em&gt; resistance, it will pull up to a finite amount of power, but that usually is much more than the LED can handle (and sometimes what the power supply can supply). We need a resistor there to ensure that the LED can only draw as much power as it can handle.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And why 3, 5, 6, 9, 10, 11 pins with &quot;wave&quot; symbol?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you look at an Arduino board, it will say &lt;code&gt;DIGITAL (PWM~)&lt;/code&gt;. That &lt;code&gt;(PWM~)&lt;/code&gt; means that any pins with the &quot;~&quot; symbol are &lt;em&gt;PWM&lt;/em&gt; pins... pins that can turn on and off their output very fast, in this case to create an illusion that the LED is dimming because the state changes faster than the human eye can detect.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8eLah.jpg&quot; alt=&quot;Arduino Uno&quot;&gt;&#xA;  &lt;em&gt;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/ArduinoUnoFront240.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/uploads/Main/ArduinoUnoFront240.jpg&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;More explanation for PWM here: &lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino docs&lt;/a&gt;, &lt;a href=&quot;https://electronics.stackexchange.com/questions/67116/why-do-some-pins-have-signs-next-to-their-numbers&quot;&gt;an answer [of mine]&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-22T15:38:41.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5125" PostTypeId="1" AcceptedAnswerId="5126" CreationDate="2014-11-22T15:59:18.623" Score="1" ViewCount="3507" Body="&lt;p&gt;So I just got an Arduino and thought I would play around a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However not five minutes in I already ran into a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried programming a simple SOS blinking light sequence. To get rid of code duplication I refactored the on and off turning of the LED into functions and then again refactored a short blink and a long blink function which are expected to turn the LED on for a short time and then for a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the delay in those functions is completely ignored. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;&#xA;void on()&#xA;{&#xA; digitalWrite(ledPin,HIGH); &#xA;}&#xA;&#xA;void off()&#xA;{&#xA; digitalWrite(ledPin,LOW);&#xA;}&#xA;&#xA;&#xA;void shortB()&#xA;{&#xA; on();&#xA; delay(1000);&#xA; off();&#xA;} &#xA;&#xA;void longB()&#xA;{&#xA; on();&#xA; delay(2000);&#xA; off(); &#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledPin, OUTPUT); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; shortB();&#xA; shortB();&#xA; shortB();&#xA; shortB();&#xA; longB();&#xA; longB();&#xA; longB();&#xA; shortB();&#xA; shortB();&#xA; shortB();  &#xA; delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My expected behavior would be that it does an SOS and then waits 5 seconds and repeats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What really happens however is that it stay continuously lit for a second or so then turns off for 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;on();&#xA;delay(1000);&#xA;off();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the main loop works so I guess it simply ignores the delays that are put into the other functions. My question would be why and ho do I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I can use other timer function constructs however I really think this is something that should work by default.&lt;/p&gt;&#xA;" OwnerUserId="4934" LastActivityDate="2015-07-04T02:10:58.620" Title="Delay not working in function other than loop" Tags="|programming|led|time|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5126" PostTypeId="2" ParentId="5125" CreationDate="2014-11-22T16:03:59.940" Score="1" Body="&lt;p&gt;You have no delay in between turning the LED off and turning it back on. Add one.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-22T16:03:59.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5127" PostTypeId="1" AcceptedAnswerId="5128" CreationDate="2014-11-22T16:21:56.487" Score="0" ViewCount="145" Body="&lt;p&gt;I have a very simple circuit: 5v -&gt; LED (5mm, forward voltage of 2 V and max. current of 20mA) -&gt; 1k ohm resistor -&gt; GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know how much current is flowing in my circuit. I am using this formula:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;U = R x I&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since U = 5, and R = 1000 the current is (according to the formula): 5/1000 = 0.005A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far so good. The problem is when I try to check the voltage drop over the resistor and the LED. For calculating the voltage drop in the resistor I would use the same formula where I is my current (0.005A) and R is the resistor 1k ohm. The result is: 5 V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something very weird is happening here cause the voltage drop around my resistor should not be 5 V cause I know there must be another voltage drop around the LED. If 5V is in the resistor it would mean that 0v is around the LED (and it should not light up but it does).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you helping me with this basic calculus.&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-11-22T16:33:08.837" Title="How much current and voltage has my resistor + LED" Tags="|current|resistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5128" PostTypeId="2" ParentId="5127" CreationDate="2014-11-22T16:33:08.837" Score="0" Body="&lt;p&gt;The problem is that if you're trying to measure the current directly, you're going to get the wrong answer. Whether it's due to burden voltage or the (in)accuracy of the meter, it's a hopeless situation. The 0.005A your meter is showing is actually closer to 3mA in reality, but your meter can't distinguish between the two well enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to measure current this small then the only way to do so accurately is to use a very low-value shunt resistor and an amplifier. This is the method the &lt;a href=&quot;http://www.eevblog.com/projects/ucurrent/&quot; rel=&quot;nofollow&quot;&gt;µCurrent&lt;/a&gt; uses, and it's essentially the defacto gold standard for measuring current in small circuits.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-22T16:33:08.837" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5129" PostTypeId="1" AcceptedAnswerId="5132" CreationDate="2014-11-22T16:50:56.007" Score="2" ViewCount="406" Body="&lt;p&gt;I have a source power with 2 V and 100mA. I have an LED that has a forward voltage of 2 V and a max current of 20mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I use a resistor to reduce the current? I see many formulas in the internet saying the the resistor value should be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Source Voltage - LED forwared voltage)/LED max current&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This formula always worked fine for me, but now that I have a 2 V source power this formula tells me that the resistor should be 0 ohm. Of course this would damage my LED cause the 100mA provided by my source power is way above the 20mA current limit of the lED.&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-11-22T17:16:45.233" Title="Source power with 2 V and LED with forward voltage of 2 V" Tags="|led|resistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5130" PostTypeId="2" ParentId="5129" CreationDate="2014-11-22T17:06:19.227" Score="1" Body="&lt;p&gt;You most likely will not be able to use that power supply with that LED properly. The resistance graph of an diode is quite peculiar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.chromausa.com/applications/led-driver-testing-meeting-industry-needs.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tzqkq.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, there isn't a &quot;hard&quot; forward voltage, but rather a smooth curve that changes depending on what current is passing through the diode. You can try to use a value of, say 1.95V for the LED, but then you won't pass the same amount of current that you used in your calculations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extended reading: &lt;a href=&quot;http://en.wikipedia.org/wiki/Load_line_%28electronics%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;Load line (Wikipedia)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-22T17:06:19.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5132" PostTypeId="2" ParentId="5129" CreationDate="2014-11-22T17:16:45.233" Score="2" Body="&lt;p&gt;No, it would not damage your led. The forward voltage of a led is, the voltage at which the led 'conducts' the maximum current it can handle. Since diodes have a (exponential) curve, the current though a diode depends on the voltage across it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you give the led 2V, it will use only 20mA. However if the voltage goes to e.g. 2.1V the current might be 25mA (since the curve is exponential), which is a bit too high, and will reduce the leds lifespan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for safely I'd add some resistors. E.g. a 10Ohm resistor will limit the current to 20mA max, as long as the voltage doesn't go over 2.2V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS note that led Christmas lights use the same method to limit current, without a single resistor. I have here a 24v string of leds, grouped into 10 leds connected in series. So the voltage across each led is 2.4V. They are white leds, so they probably have a forward voltage of around 3.2v. But since they only get 2.4v, they will probably use only 5mA or less.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-22T17:16:45.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5133" PostTypeId="1" CreationDate="2014-11-22T17:57:08.063" Score="4" ViewCount="5394" Body="&lt;p&gt;I was wondering why there is a 15 ms delay between each iteration of a the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;:&#xA;The following code shows the execution time expressed in microsec between each loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println();&#xA;  Serial.print(&quot;Start: &quot;);&#xA;  Serial.print(micros());&#xA;  Serial.print(&quot;/////////////////////&quot;);&#xA;  Serial.print(&quot;End:&quot;);&#xA;  Serial.print(micros()); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start: 789452/////////////////////End:821692&#xA;Start: 837292/////////////////////End:869532&#xA;Start: 885132/////////////////////End:917372&#xA;Start: 932972/////////////////////End:965212&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino needs 32,240 msec to print the messages to serial and to call the micros() function twice. And this it's fine. Now, considering the difference between the values of the End and the following Start, one question arises:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does Arduino do between each loop?&lt;/p&gt;&#xA;" OwnerUserId="4396" LastActivityDate="2017-06-21T11:39:32.007" Title="What does Arduino do in 15ms?" Tags="|arduino-uno|serial|arduino-mega|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5136" PostTypeId="2" ParentId="5133" CreationDate="2014-11-22T18:09:17.273" Score="4" Body="&lt;p&gt;Your code is slightly off if you want to accurately time this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;End:&quot;);&#xA;Serial.print(micros()); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will get micros() before printing to serial, and then take the time to print it. You also print some text before taking the time at the top of the loop. Your 15 ms is the time to print these to serial between reading micros. For example, change the loop code to something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t time, endTime;&#xA;...&#xA;void loop(){&#xA;    time = micros();&#xA;&#xA;    Serial.print(endTime);&#xA;    Serial.print('\t');&#xA;    Serial.print(time);&#xA;    Serial.print('\n');&#xA;&#xA;    endTime = micros();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you should only see a small difference. It showed a 4 microsecond difference when I ran it. The only other thing that runs outside the loop is the serial event handlers, but if you don't use one it obviously doesn't take long. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-11-22T18:09:17.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5137" PostTypeId="1" AcceptedAnswerId="5139" CreationDate="2014-11-22T18:18:13.543" Score="0" ViewCount="489" Body="&lt;p&gt;I have a simple project with a close deadline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to light up 5 LEDs as part of the project. The first 4 light up in sequence fine, and if I light up just the last one it lights up fine, but if all 5 are lit at once the very last LED is very dim. I swapped out cables, the pin on the Arduino, resistor, LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would explain that? Input amperage? Too strong a resistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a 330 ohm resistor in between each LED and ground. I am using one of the neat resistors from SparkFun that packages up the 5 330 ohm resistors together, with a common ground wire. I bought two and tried swapping it out with no change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QZ4qU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/QZ4qU.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Blink without Delay&#xA; http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&#xA; */&#xA;&#xA;const int startButtonPin = 6;&#xA;const int reedSwitchPin = 7;&#xA;const int ledPins[] = {8,9,10,11,13};&#xA;const int numLeds = 5;&#xA;const long interval = 1000;           // interval at which to blink (milliseconds)&#xA;const int revolutionsPerStage = 15;&#xA;&#xA;int debounceDelay = 500; // for switches--interval to ignore short button presses/reed switch open/close&#xA;long lastDebounce = 0;&#xA;int buttonState = LOW;&#xA;int mapStage = 0;&#xA;&#xA;unsigned long previousMillis = 0;        // will store last time LED was updated&#xA;&#xA;void setup() {&#xA;  // set pin modes&#xA;  for (int thisPin = 0; thisPin &amp;lt; (sizeof(ledPins)/sizeof(int)) - 1; thisPin++)  {&#xA;    pinMode(ledPins[thisPin], OUTPUT);      &#xA;  }&#xA;  pinMode(startButtonPin, INPUT);&#xA;  pinMode(reedSwitchPin,INPUT);&#xA;&#xA;  digitalWrite(reedSwitchPin,HIGH); // activate the pull-up resistor&#xA;}&#xA;&#xA;// Main program loop&#xA;void loop()&#xA;{&#xA;  buttonState = digitalRead(startButtonPin);&#xA;  //digitalWrite(8,HIGH);&#xA;&#xA;  // wait for button press to begin program proper. we won't get back to this state except on first boot or if program finishes&#xA;  if (buttonState == HIGH) {&#xA;      digitalWrite(8,HIGH);&#xA;      chasingLEDs();&#xA;      //trackProgress();&#xA;  }&#xA;}&#xA;&#xA;void trackProgress() {&#xA;  int blinkState = LOW;&#xA;  unsigned long currentMillis = millis();&#xA;  unsigned int numRevolutions = 0;&#xA;&#xA;  do {&#xA;    digitalWrite(ledPins[mapStage], HIGH);&#xA;&#xA;    // blink the current goal LED at constant interval specified earlier&#xA;    if(currentMillis - previousMillis &amp;gt;= interval) {&#xA;      // save the last time you blinked the LED&#xA;      previousMillis = currentMillis;  &#xA;      blinkState = !blinkState;&#xA;      digitalWrite(ledPins[mapStage], blinkState);&#xA;    }&#xA;  } while (mapStage &amp;lt; numLeds);&#xA;}&#xA;&#xA;// perform a simple welcome sequence to indicate we are ready to start pedalling&#xA;void chasingLEDs() {&#xA;   // turn LEDs on in sequence, then back off&#xA;   for (int i = 0; i &amp;lt; numLeds; i++){&#xA;     digitalWrite(ledPins[i], HIGH);&#xA;     delay(333);&#xA;   }&#xA;&#xA;   for (int j = numLeds; j &amp;gt; 0; j--) {&#xA;     digitalWrite(ledPins[j], LOW);&#xA;     delay(333);&#xA;   }&#xA;&#xA;   // flash the LEDs twice&#xA;   for (int k = 0; k &amp;lt; 2; k++) {&#xA;     for (int l = 0; l &amp;lt; numLeds; l++) {&#xA;         digitalWrite(ledPins[l], HIGH);&#xA;     }&#xA;     delay(500);&#xA;     for (int m = 0; m &amp;lt; numLeds; m++) {&#xA;         digitalWrite(ledPins[m], LOW);&#xA;     }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4937" LastEditorUserId="84" LastEditDate="2014-11-22T20:58:41.400" LastActivityDate="2014-11-22T20:58:41.400" Title="Lighting 5 leds...the last one lit is always dim" Tags="|arduino-uno|led|resistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5139" PostTypeId="2" ParentId="5137" CreationDate="2014-11-22T19:36:44.290" Score="0" Body="&lt;p&gt;I found the problem, it was a bug in my code. I had found code to read the array size online but it was off by 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int thisPin = 0; thisPin &amp;lt; (sizeof(ledPins)/sizeof(int)) - 1; thisPin++)  {&#xA;    pinMode(ledPins[thisPin], OUTPUT);      &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I changed it to thisPin &amp;lt; numLeds, it worked correctly. The last pin was simply set to be an input pin instead of an output pin.&lt;/p&gt;&#xA;" OwnerUserId="4937" LastActivityDate="2014-11-22T19:36:44.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5140" PostTypeId="1" AcceptedAnswerId="5142" CreationDate="2014-11-22T20:43:48.510" Score="0" ViewCount="538" Body="&lt;p&gt;I am trying to understand 2 sensors that I have here. One says that is &quot;infrared sensor of 38kHz&quot; and the other is &quot;infrared optical reflexive sensor -&gt; &lt;a href=&quot;http://www.robosoftsystems.co.in/wikidocs/index.php?title=TCRT_5000_Reflective_Optical_Sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.robosoftsystems.co.in/wikidocs/index.php?title=TCRT_5000_Reflective_Optical_Sensor&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that infrared sensor would tell me if an infrared light is passing on it. Infrared light has a wavelenght, right? Can infrared light be emited in different frequencies? Or the frequency of infrared light is the same to all infrared lights?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-11-23T18:20:41.550" Title="Infrared sensor has a frequency to activate it?" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5141" PostTypeId="1" AcceptedAnswerId="5143" CreationDate="2014-11-22T21:37:13.623" Score="0" ViewCount="334" Body="&lt;p&gt;I have a potentiometer of 10k and I connected it this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5v -&gt; potentiometer -&gt; analog input pin of Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I turn the potentiometer I change the resistance of the circuit but in the Arduino documentation they say that an analog pin in INPUT mode will have 1 megaohm resistance. So, for example, if I turn the potentiometer to the middle it will generate 5k of resistance + 1 megaohm of the analog pin it will result in a tiny, very tiny current. If I use U = R x I across the potentiometer it will be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;U = 5000 x 0.0000001&lt;/p&gt;&#xA;&#xA;&lt;p&gt;U ~ 0 across the potentiometer. So U will be 5 V at the analog input because there was no drop of voltage in the circuit. If turn the potentiometer all way up to 10k resistance the voltage in the analog input will also be 5 V because the voltage drop across the potentiometer is still really small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that an analog pin in INPUT mode will read 0 V as 0 and 5 V as 1023. But as I showed you it should always read 5 V even when I turn the potentiometer all way up because the voltage is not being changed. I know I am wrong cause when I log the input pin it shows different values as I turn the potentiometer. So how does this work?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastEditorUserId="26916" LastEditDate="2017-09-10T00:32:49.767" LastActivityDate="2017-09-10T00:32:49.767" Title="How does an analog input pin work?" Tags="|current|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5142" PostTypeId="2" ParentId="5140" CreationDate="2014-11-22T21:44:18.727" Score="1" Body="&lt;p&gt;The 38kHz sensor (such as the Vishay series e.g TSOP1838) are designed for use with IR remotes and IR barrier type applications. They are designed to work with IR emitters that oscillate the IR at 38Khz and additionally modulate that frequency with lower frequency pulses. The sensor (receiver) is designed to have high gain at 38Khz and demodulates the signal. The demodulated output signal pulses can be directly decoded by a microprocessor. The main benefit is reliable functioning even in disturbed ambient light thus protecting against uncontrolled output pulses.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2014-11-22T21:44:18.727" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5143" PostTypeId="2" ParentId="5141" CreationDate="2014-11-22T21:54:33.023" Score="1" Body="&lt;p&gt;The potentiometer and the internal resistance form a voltage divider. The voltage created by this voltage divider is essentially indistinguishable from 5V regardless of what the pot is set to because the internal resistance is so high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want to do is to create an &lt;em&gt;external&lt;/em&gt; voltage divider that will cause the voltage to vary full scale between 5V and 0V. You do so by connecting one end of the pot to 5V and the other end to 0V, and drawing the voltage from the wiper.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-22T21:54:33.023" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5147" PostTypeId="2" ParentId="653" CreationDate="2014-11-23T05:57:42.630" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;is there a more efficient way of calculating a moving average with&#xA;  ... 28 days and 7 days?&#xA;  ...&#xA;  needing to remember 27 days of history ... ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You might get close enough storing 11 values rather than 28 values,&#xA;perhaps something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// untested code&#xA;// static variables&#xA;uint16_t daily_energy[7]; // perhaps in units of 0.01 kWh ?&#xA;uint16_t weekly_energy[4]; // perhaps in units of 0.1 kWh ?&#xA;&#xA;void print_week_status(){&#xA;    Serial.print( F(&quot;last week's total energy :&quot;) );&#xA;    Serial.println( weekly_energy[0] );&#xA;    int sum = 0;&#xA;    for( int i=0; i&amp;lt;4; i++ ){&#xA;        sum += weekly_energy[i];&#xA;    };&#xA;    Serial.print( F(&quot;Total energy over last 4 complete weeks :&quot;) );&#xA;    Serial.println( sum );&#xA;    int average_weekly_energy = sum/4;&#xA;    int average_daily_energy = average_weekly_energy/7;&#xA;    Serial.print( F(&quot;Average daily energy over last 4 weeks :&quot;) );&#xA;    Serial.println( average_daily_energy );&#xA;}&#xA;void print_day_status(){&#xA;    Serial.print( F(&quot;Yesterday's energy :&quot;) );&#xA;    Serial.println( daily_energy[0] );&#xA;    Serial.print( F(&quot;average daily energy over the last 7 complete days: &quot;) );&#xA;    int sum = 0;&#xA;    for( int i=0; i&amp;lt;7; i++ ){&#xA;        sum += daily_energy[i];&#xA;    };&#xA;    int average = sum/7;&#xA;    Serial.println( average );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, rather than storing every detail of every day for the last 27 days,&#xA;(a) store 7 or so values of detailed daily information for the past 7 or so days, and also&#xA;(b) store 4 or so &quot;summarized&quot; values of total or average information for each of the past 4 or so weeks.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2014-11-23T05:57:42.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5148" PostTypeId="1" AcceptedAnswerId="5154" CreationDate="2014-11-23T10:32:12.403" Score="1" ViewCount="93" Body="&lt;p&gt;I have a circuit with a blue led, 470ohm resistor and one IR led. I want the led to be switched off when the IR led has a digitalRead value of LOW(i move my hand over it). So I wrote the code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;// initialize digital pin 13 as an output.&#xA;pinMode(13, OUTPUT); // this is the blue led&#xA;pinMode(10, INPUT);  // this is the IR sensor's O/P &#xA;&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;digitalWrite(13, HIGH); // first I give HIGH voltage to the blue LED&#xA;&#xA;if(digitalRead(10) == LOW){  // when the voltage of the IR sensor decreases&#xA;digitalWrite(13, LOW); // the blue LED should switch off or have 0 Voltage&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the blue LED just dims and doesn't switch off. Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="4943" LastActivityDate="2014-11-23T15:52:32.310" Title="Blue LED not switching off" Tags="|ir|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5150" PostTypeId="1" CreationDate="2014-11-23T08:06:53.967" Score="2" ViewCount="522" Body="&lt;p&gt;I am trying to connect an LCD panel (RioRand (TM) IIC/I2C/TWI Serial 2004 20x4 LCD Module Shield For Arduino UNO MEGA R30) to a Lilypad Arduino.  How can I get them to talk to each other?   I cannot figure out how to connect them.&lt;/p&gt;&#xA;" OwnerUserId="4952" OwnerDisplayName="Deb Sterling Chittur" LastActivityDate="2014-11-23T12:00:11.733" Title="Connect Lilypad to LCD" Tags="|lcd|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5152" PostTypeId="1" AcceptedAnswerId="5153" CreationDate="2014-11-23T15:13:08.303" Score="-2" ViewCount="232" Body="&lt;p&gt;I am having a difficult time to understand how an infrared sensor and led work. I have an infrared LED (like the ones you buy anywhere), does it mean that the infrared LED has the frequency os 38khz?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that infrared light has a wavelegnth, but does it also have a frequency?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-11-23T15:50:22.347" Title="Infrared led and sensor: how it work" Tags="|current|" AnswerCount="1" CommentCount="3" ClosedDate="2014-12-08T17:53:51.733" ContentLicense="CC BY-SA 3.0" />
  <row Id="5153" PostTypeId="2" ParentId="5152" CreationDate="2014-11-23T15:50:22.347" Score="2" Body="&lt;p&gt;An infrared LED just emits its light (primarily) in the infrared range as described by this &lt;a href=&quot;https://en.wikipedia.org/wiki/Infrared&quot; rel=&quot;nofollow&quot;&gt;Wikipedia article&lt;/a&gt;. Any emitted radiated signal (including sound) has both a frequency and a wavelength. The frequency = the velocity of the signal through space divided by its wavelength (F = V / W), or vice-versa: (W = V / F). The natural frequency of light, infrared or visible is far, far higher than 38 KHz; around 4 x 10^14 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;38 KHz is simply a convenient chopping frequency for switching the LED on and off so the sensor can distinguish between infrared in sunlight, for instance, which is relatively constant - from that emitted by the LED. Your circuitry would have to create the 38KHz chopping signal.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-11-23T15:50:22.347" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5154" PostTypeId="2" ParentId="5148" CreationDate="2014-11-23T15:52:32.310" Score="7" Body="&lt;p&gt;Every time through your loop, the LED is being set to HIGH voltage. This may or may not be followed by setting it to LOW voltage, but since the loop runs again immediately, it's immediately set back to high voltage. This happens so fast that the LED essentially &quot;feels&quot; half voltage and it will dim. Your code needs to be more like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if(digitalRead(10) == LOW) {  &#xA;    digitalWrite(13, LOW);&#xA;  } else {&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OR... even like this...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  digitalWrite(13, digitalRead(10));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="228" LastActivityDate="2014-11-23T15:52:32.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5155" PostTypeId="1" CreationDate="2014-11-23T17:14:38.647" Score="0" ViewCount="388" Body="&lt;p&gt;What do you guys use for project designing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just found out about AutoDesk's 123D Circuits, which is nice but I wonder if there is something with more components, tools, etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I can add an accelerometer to my project there but no signs of a LCD. I have been learning hardware recently and I feel there should be more complete tools out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this question may be opinion based but I could not find anywhere to ask. Thanks,&lt;/p&gt;&#xA;" OwnerUserId="4949" LastActivityDate="2021-10-20T16:59:06.457" Title="What project design tools are available?" Tags="|arduino-uno|project|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5156" PostTypeId="2" ParentId="5140" CreationDate="2014-11-23T18:20:41.550" Score="0" Body="&lt;p&gt;38Khz is not the frequency of the IR light but the frequency it is pulsed on and off at, the receiver is designed to accept that frequency and reject others so as to avoid interference from sunlight etc. I see you have asked the question again in a slightly different way and received a similar answer.&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/5152/infrared-led-and-sensor-how-it-work&quot;&gt;Infrared led and sensor: how it work&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="521" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2014-11-23T18:20:41.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5157" PostTypeId="2" ParentId="5133" CreationDate="2014-11-23T19:34:09.723" Score="5" Body="&lt;p&gt;Just check &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/main.cpp#L42-L45&quot; rel=&quot;noreferrer&quot;&gt;the sourcecode&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (;;) {&#xA;    loop();&#xA;    if (serialEventRun) serialEventRun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it does a check if serialEventRun is True, and then a jump back to the beginning of the for-loop. And then a call to &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that Serial.print is blocking if the TX-buffer is full. So you might want to add a delay somewhere to ensure the buffer is never full.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-23T19:34:09.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5163" PostTypeId="1" AcceptedAnswerId="9588" CreationDate="2014-11-24T11:38:04.123" Score="1" ViewCount="1291" Body="&lt;p&gt;let's suppose I have folder called AES, in this folder is file &quot;AES.ino&quot; where is code and folder &quot;AESLib&quot; what is library. In &quot;AESLib&quot; is file called &quot;AESLib.h&quot;, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;now when I try to include AESLib.h with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;AESLib/AESLib.h&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in my AES.ino, then Arduino command line tool complain that its not able to find &quot;AESLib.h&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where could be the catch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="4959" LastActivityDate="2015-05-24T15:40:43.180" Title="Include my header files" Tags="|c++|library|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5165" PostTypeId="1" CreationDate="2014-11-24T03:07:29.443" Score="1" ViewCount="2475" Body="&lt;p&gt;Hey all this would be my first encounter needing to burn the Arduino IDE bootloader onto a blank ATMega32u4 that I bought from Digikey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What all do I need to buy in order to program the bootloader for that chip? In the manual for the 32u4 it says it comes with a bootloader but I'm guessing its not the arduino bootloader?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the pinout for the ISP all that I would need in order to upload the Arduino bootloader?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen this post:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TU6F4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but I wont be using the through-hole design.. its going to be the surface mount SMD kind so i wouldn't be able to put that on a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So would it be as simple as breaking out the ISP pins on the 32u4 and just hooking those up to a Arduino Duemilanove board even if its not the same ATmega chip (As in copying the atmega32u4 arduino to the Duemilanove and then transferring that to the 32u4?)?&lt;/p&gt;&#xA;" OwnerUserId="5133" OwnerDisplayName="StealthRT" LastActivityDate="2014-11-24T17:52:18.987" Title="ATmega32u4 bootloader" Tags="|avr|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5166" PostTypeId="2" ParentId="5165" CreationDate="2014-11-24T04:34:33.447" Score="2" Body="&lt;p&gt;The ATmega32U4 already comes programmed with a bootloader that allows programming via USB; once you've added the basic hardware for a USB connection you should be able to use AVRDUDE, FLIP, etc. to upload firmware to the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, putting an ISP connection as per &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR042&lt;/a&gt; is highly recommended regardless.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-11-24T04:58:51.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5167" PostTypeId="1" CreationDate="2014-11-25T00:22:18.603" Score="3" ViewCount="5511" Body="&lt;p&gt;Socket programming question here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My interface comprises of an Android device(client), A wireless module hosting an access point, and an Arduino Uno(server).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Android client class works when 1 user connects and sends commands to my Arduino server class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make my program friendly to many users at the same time.  My server will only read in values from 1 connected client at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some research I've found that Arduino does not allow multithreading naturally, which is why i've decided to look into a number of libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino library that I've decided to use for this specific issue is &lt;code&gt;protothreads&lt;/code&gt;.  Unfortunately, i've been unable to find any examples of creating a server with Arduino to accept a client's commands.  Furthermore I'm having a lot of trouble figuring out how to make this library work in my favor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for my question,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How exactly can I allow my Arduino server to constantly listen for&#xA;  incoming messages from more than 1 client device?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or is there something I can do on the client side that would make this communication possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of work is handled by my Wifly Module.&#xA;I was able to telnet in and set my ipaddress/port#/etc..&#xA;Anything sent over IP goes straight through my Module and straight to my arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &#xA;&lt;a href=&quot;https://github.com/EbenezerGH/WiflyClient/blob/master/app/src/main/java/com/led/androidled/MainActivity.java&quot; rel=&quot;nofollow&quot;&gt;Client Code&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Server:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WiFlySerial wifi(rxPin ,txPin);&#xA;&#xA;void setup() {&#xA;  pinMode(rxPin, INPUT);&#xA;  pinMode(txPin, OUTPUT);&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  //Serial.println(&quot;I'm in the LOOP!!&quot;);&#xA;  androidLed();&#xA;  serialLed();&#xA;&#xA;}&#xA;&#xA;void androidLed()&#xA;{&#xA;  if(wifi.available() &amp;gt; 0){&#xA;    data = wifi.read();&#xA;    Serial.println(wifi.getDeviceStatus());&#xA;    Serial.println(data);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="4735" LastEditDate="2014-11-25T05:00:40.513" LastActivityDate="2015-02-10T03:34:33.817" Title="Arduino server to read from multiple clients" Tags="|arduino-uno|c|android|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5168" PostTypeId="1" AcceptedAnswerId="5170" CreationDate="2014-11-25T00:57:00.283" Score="-1" ViewCount="1115" Body="&lt;p&gt;I'm working on a project and I need to print serial to a LCD but only if the first letter of the serial is &quot;:&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the serial being stored in a char and a if statement reading the first letter of the char to see if it is &quot;:&quot; From there I can't get it to print to the LCD without the first letter. I also don't know how to clear the char.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;char inData[20];&#xA;char inChar;&#xA;byte index = 0;&#xA;&#xA;void setup(){&#xA; lcd.begin(16, 2);&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  while(Serial.available() &amp;gt; 0) &#xA;  {&#xA;      if(index &amp;lt; 19)&#xA;      {&#xA;      inChar = Serial.read();&#xA;      inData[index] = inChar;&#xA;      index++;&#xA;      inData[index] = '\0';&#xA;  }&#xA; if(inData[0] == ':') {&#xA;   lcd.print(inData);&#xA;   }&#xA;&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4966" LastEditorUserId="220" LastEditDate="2014-11-25T01:55:14.183" LastActivityDate="2014-11-25T02:00:03.007" Title="serial char read first letter if it is &quot;;&quot; print char without fists letter" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5169" PostTypeId="1" CreationDate="2014-11-25T01:04:09.880" Score="0" ViewCount="1000" Body="&lt;p&gt;I am fairly new to Arduino programming and I have been set with the task of scrolling my name across a &lt;a href=&quot;http://jimmieprodgers.com/kits/lolshield/&quot; rel=&quot;nofollow&quot;&gt;LoL shield&lt;/a&gt; with a potentiometer. I really don't have any idea how to do this and when I tried to look it up online there is nothing for such a task. I did look at the library references on the LoL shield website but I couldn't make sense of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did find was a &lt;a href=&quot;http://sequoia.github.io/LSS/&quot; rel=&quot;nofollow&quot;&gt;LoL shield sequencer&lt;/a&gt; to allow animation on the LoL shield and I figured that might help but I don't know how to use that code to create a scrolling effect with a potentiometer.&lt;/p&gt;&#xA;" OwnerUserId="4967" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:44.993" LastActivityDate="2016-12-14T23:37:16.920" Title="How would I go about scrolling a name across a LoL shield with a potentiometer?" Tags="|led|shields|potentiometer|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5170" PostTypeId="2" ParentId="5168" CreationDate="2014-11-25T01:38:06.463" Score="1" Body="&lt;p&gt;Tell it to print starting from the second character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(inData + 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-25T01:38:06.463" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5172" PostTypeId="2" ParentId="5167" CreationDate="2014-11-25T02:08:20.597" Score="6" Body="&lt;p&gt;&lt;em&gt;Without knowing your exact implementation details...&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be OK as long as you don't have &lt;em&gt;multiple&lt;/em&gt; clients connected at the same time. You may think that there are multiple clients connected to your server, but the connection is closed after the resource is obtained by the client over a protocol.*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard flow of a server on Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A client connects to the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino code realizes this connection and reads the data provided by the client.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino then sends some data back to the client.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino closes the connection and waits for another client to connect.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This happens relatively fast so multiple people can connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you call a function like &lt;code&gt;.close();&lt;/code&gt; after you send data to your client, you should be okay. &lt;strong&gt;If you don't, redesign your code to have this element&lt;/strong&gt; (avoid loops and blocking functions) and make sure to have your client reconnect every time it sends a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't mess with this and Protothreads because I'm not sure that the Arduino hardware is designed to be able to handle multiple connections at the same time. &lt;sup&gt;&lt;em&gt;[Citation needed]&lt;/em&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-11-25T02:08:20.597" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5173" PostTypeId="1" AcceptedAnswerId="5174" CreationDate="2014-11-25T03:39:07.400" Score="7" ViewCount="338" Body="&lt;p&gt;I have been thinking of a million things to do with my Arduino, but those things are extremely simple and it would leave my Arduino as a $25 waste. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, programming Arduino to control my living room lights with my smartphone ... I was thinking of connecting the Arduino in the wall, onto the light switch wires. I am looking for a &quot;permanent&quot; solution, but I figure this would leave me with a $25 waste of circuitry inside my wall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any &quot;Arduino&quot; types of electronics that perhaps have many less ports, JUST enough to get a single task done?&lt;/p&gt;&#xA;" OwnerUserId="4970" LastActivityDate="2014-11-26T02:03:14.787" Title="Extremely cheap &quot;Arduino&quot; for single tasks?" Tags="|arduino-uno|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5174" PostTypeId="2" ParentId="5173" CreationDate="2014-11-25T04:46:37.433" Score="6" Body="&lt;p&gt;&lt;a href=&quot;http://digistump.com/products/1&quot;&gt;Digispark&lt;/a&gt; comes to mind, or any of the &lt;a href=&quot;https://www.tindie.com/products/bot_thoughts/eezeetiny841/&quot;&gt;ATTiny&lt;/a&gt; &lt;a href=&quot;https://www.tindie.com/products/bot_thoughts/eezee-tiny-breakout-programming-board-kit/&quot;&gt;breakout&lt;/a&gt; &lt;a href=&quot;https://www.tindie.com/search/?q=attiny&quot;&gt;boards&lt;/a&gt; at Tindie. Or, make your own PCBs, I just now finished soldering a few ATMega328p circuits to &lt;a href=&quot;https://www.tindie.com/products/ptudor/jemma-clock/&quot;&gt;boards I designed&lt;/a&gt;. Microcontroller is $1.50, PCBs range from $2 to $8 each, time is &quot;free.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider &lt;a href=&quot;http://www.ardueasy.com/2014/10/different-varieties-of-arduino-nano.html&quot;&gt;&quot;compatible with&quot; designs&lt;/a&gt;; while you're not directly supporting the ecosystem, if you've already paid full price once and your conscience is clear, eBay has plenty.&lt;/p&gt;&#xA;" OwnerUserId="4969" LastEditorUserId="4969" LastEditDate="2014-11-25T04:55:16.303" LastActivityDate="2014-11-25T04:55:16.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5175" PostTypeId="1" AcceptedAnswerId="5176" CreationDate="2014-11-25T05:05:16.617" Score="0" ViewCount="386" Body="&lt;p&gt;So I'm trying to read 4 different analog values and store each one to a variable.  I imagine doing this by first initializing the ADC registers and each time it enters the ADC ISR checking which port it read from and saving it to the corresponding variable.  Then setting the ADMUX to the next ADC port and repeating the whole process.  Unfortunately something goes wonky and I just can't figure out what it is.  If I get rid of the switch case and just read from one port it all works fine, but if I put the switch case back in and try to cycle through them it stops working.  Please ignore the rest of code as this is not complete.  I just included everything I could.  Eventually this will take in 4 values.  Then use them for error checking and a PID loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Throttle_by_Wire.c&#xA; *&#xA; * Basic throttle by wire controller&#xA; * for the 2015 Formula Hybrid car&#xA; *&#xA; *  Created on: Nov 24, 2014&#xA; *  Author: Austin R. Bartz&#xA; *&#xA; *  Pin Connections:&#xA; *      PB2 - Motor Speed (Enable pin) (PWM)&#xA; *      PB4 - Direction control (Counter-Clockwise)&#xA; *      PB5 - Direction control (Clockwise)&#xA; *      PC0 - Throttle Pedal Sensor A (TPA) (Shallower Slope)&#xA; *      PC1 - Throttle Pedal Sensor B (TPB) (Steeper Slope)&#xA; *      PC2 - Throttle Valve Sensor A (TPSA) (Negative Slope)&#xA; *      PC3 - Throttle Valve Sensor B (TPSB) (Positive Slope)&#xA; */&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;inttypes.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;uint16_t TPA = 0;&#xA;uint16_t TPB = 0;&#xA;uint16_t TPSA = 0;&#xA;uint16_t TPSB = 0;&#xA;uint16_t analogpin = 0;&#xA;&#xA;long map(long x, long in_min, long in_max, long out_min, long out_max);&#xA;&#xA;int main(void)&#xA;{&#xA;    //Configure ADC for single shot conversion&#xA;    ADMUX |= (1&amp;lt;&amp;lt;REFS0);&#xA;    ADCSRA = (1&amp;lt;&amp;lt;ADEN)|(1&amp;lt;&amp;lt;ADSC)|(1&amp;lt;&amp;lt;ADIE)|(1&amp;lt;&amp;lt;ADPS2)|(1&amp;lt;&amp;lt;ADPS1)|(1&amp;lt;&amp;lt;ADPS0);&#xA;    DIDR0 = (1&amp;lt;&amp;lt;ADC4D)|(1&amp;lt;&amp;lt;ADC3D)|(1&amp;lt;&amp;lt;ADC2D)|(1&amp;lt;&amp;lt;ADC1D)|(1&amp;lt;&amp;lt;ADC0D);&#xA;    //Configure timer/counter1 for FastPWM&#xA;    TCCR1A = (1&amp;lt;&amp;lt;COM1B1)|(1&amp;lt;&amp;lt;WGM11)|(1&amp;lt;&amp;lt;WGM10);&#xA;    TCCR1B = (1&amp;lt;&amp;lt;WGM13)|(1&amp;lt;&amp;lt;WGM12)|(1&amp;lt;&amp;lt;CS10);&#xA;    OCR1A = 800;    //20kHz&#xA;    //Set motor control pins as outputs&#xA;    DDRB = (1&amp;lt;&amp;lt;PB2)|(1&amp;lt;&amp;lt;PB4)|(1&amp;lt;&amp;lt;PB5);&#xA;    PORTB |= (1&amp;lt;&amp;lt;PB5);&#xA;    //Enable global variables and interrupts&#xA;    sei();&#xA;&#xA;    while(1)&#xA;    {&#xA;        //Control PWM % to motor&#xA;        OCR1B = map(TPA, 0, 1023, 0, OCR1A);&#xA;    }&#xA;}&#xA;&#xA;long map(long x, long in_min, long in_max, long out_min, long out_max)&#xA;{&#xA;  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;&#xA;}&#xA;&#xA;ISR(ADC_vect)&#xA;{&#xA;    //Save current conversion's ADC value&#xA;    analogpin = ADMUX &amp;amp; 0b00001111;&#xA;    switch (analogpin)&#xA;    {&#xA;    case 0:&#xA;        TPA = ADCW;&#xA;        //Increment ADC port to ADC1&#xA;        ADMUX |= (1&amp;lt;&amp;lt;MUX0);&#xA;        break;&#xA;    case 1:&#xA;        TPB = ADCW;&#xA;        //Increment ADC port ADC2&#xA;        ADMUX &amp;amp;= ~0b00001111;&#xA;        ADMUX |= (1&amp;lt;&amp;lt;MUX1);&#xA;        break;&#xA;    case 2:&#xA;        TPSA = ADCW;&#xA;        //Increment ADC port to ADC3&#xA;        ADMUX &amp;amp;= 0b00001111;&#xA;        ADMUX = (1&amp;lt;&amp;lt;MUX0)|(1&amp;lt;&amp;lt;MUX1);&#xA;        break;&#xA;    case 3:&#xA;        TPSB = ADCW;&#xA;        //Reset ADC Port to ADC0&#xA;        ADMUX &amp;amp;= ~0b00001111;&#xA;        break;&#xA;    }&#xA;    //Start next conversion&#xA;    ADCSRA |= (1&amp;lt;&amp;lt;ADSC);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4203" LastEditorUserId="6452" LastEditDate="2015-04-10T15:26:31.543" LastActivityDate="2015-04-10T15:26:31.543" Title="Trouble reading from multiple analog ports" Tags="|motor|analogread|arduino-uno-smd|eclipse|pid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5176" PostTypeId="2" ParentId="5175" CreationDate="2014-11-25T06:42:24.360" Score="1" Body="&lt;p&gt;Case 2 is missing the ~ and does not clear off the low 4 bits&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ADMUX &amp;amp;= 0b00001111;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;should be this to clear off the MUX selection bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ADMUX &amp;amp;= ~0b00001111;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, you have no default case.  I would agree that by design the bits can only contain the values 0-3, but what happens if it ends up 4?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bit manipulation is hard to follow.  I would implement like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(ADC_vect) {&#xA;  uint8_t nextMux;&#xA;&#xA;  //Save current conversion's ADC value&#xA;  analogpin = ADMUX &amp;amp; 0b00001111;&#xA;  switch (analogpin) {&#xA;    case 0:&#xA;      TPA = ADCW;&#xA;      nextMux = (1&amp;lt;&amp;lt;MUX0);  &#xA;      break;&#xA;    case 1:&#xA;      TPB = ADCW;&#xA;      nextMux = (1&amp;lt;&amp;lt;MUX1);&#xA;      break;&#xA;    case 2:&#xA;      TPSA = ADCW;&#xA;      nextMux = (1&amp;lt;&amp;lt;MUX0)|(1&amp;lt;&amp;lt;MUX1);&#xA;      break;&#xA;    case 3:&#xA;      TPSB = ADCW;&#xA;    default:&#xA;      nextMux = 0;&#xA;  }&#xA;  // set mux for next conversion&#xA;  ADMUX &amp;amp;= 0b11110000;&#xA;  ADMUX |= nextMux;&#xA;&#xA;  //Start next conversion&#xA;  ADCSRA |= (1&amp;lt;&amp;lt;ADSC);&#xA;&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I like the consistent pattern of this because it makes errors easy to see.  With respect to code space, a few bytes should be saved.  Execution time wise, it adds one |= to the case 3.  &lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-11-25T06:42:24.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5177" PostTypeId="2" ParentId="5173" CreationDate="2014-11-25T08:20:05.090" Score="2" Body="&lt;p&gt;This is a typical scenario for an &lt;a href=&quot;http://store.arduino.cc/index.php?main_page=product_info&amp;amp;products_code=A000066&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno&lt;/a&gt; board: you buy one and use it for prototyping your project. Once done, you design your own PCB, as small as possible, connecting only the required wires to the ATMega328p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the next project, you buy another ATMega328p (just the MCU), plug it on the Uno and start again.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-11-25T08:20:05.090" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5178" PostTypeId="1" CreationDate="2014-11-25T07:38:09.377" Score="1" ViewCount="7031" Body="&lt;p&gt;My Arduino Leonardo was working properly but for the last two hours when I connect it to a PC via a USB cable, it is reporting something like &lt;code&gt;USB is not recognized&lt;/code&gt; and even in device manager it is not showing. However, when I press the restart button on the Arduino, the PC will detect it as an &lt;code&gt;Arduino Leonardo bootloader(com 7)&lt;/code&gt; but after few seconds it disappears. What do I have to do? I tried to restart the PC, changed USB cable but the same issue occurs. I checked the USB by connecting another device - it works fine but the Arduino is not recognised.&#xA;I tried other PCs also but the same problem continued. What do I have to do?&lt;/p&gt;&#xA;" OwnerDisplayName="Surisetty Sruthi S" LastEditorUserId="6936" LastEditDate="2015-02-13T19:13:52.953" LastActivityDate="2015-12-09T09:32:39.090" Title="Arduino Leonardo is not recognized by usb cable in Windows 8" Tags="|arduino-leonardo|usb|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5179" PostTypeId="2" ParentId="5173" CreationDate="2014-11-25T11:38:33.343" Score="2" Body="&lt;p&gt;I've had the same exact problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I like developing using the Arduino IDE I've created an how to assemble a board using just Thru Hole Components to replace the Official board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please visit the following link for further information &lt;a href=&quot;http://jpralves.net/cseduino&quot; rel=&quot;nofollow&quot;&gt;http://jpralves.net/cseduino&lt;/a&gt;&#xA;All the components will cost about 5 USD.&lt;/p&gt;&#xA;" OwnerUserId="4971" LastActivityDate="2014-11-25T11:38:33.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5180" PostTypeId="1" CreationDate="2014-11-25T12:28:29.337" Score="0" ViewCount="5848" Body="&lt;p&gt;I am working on project that my team need to detect the presence of the people. At first, we tried with motion sensor but it wasn't the way that we want it to work. We want to detect presence of the people even they don't move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We decide to go with Omron Thermal Sensor D6T-44-L06. However, there lacking of tutorial or simple code online that actually show how to connect that Omron thermal sensor with Arduino. How can I interface this with Arduino?&lt;/p&gt;&#xA;" OwnerUserId="4973" LastEditorUserId="220" LastEditDate="2014-11-25T22:57:24.240" LastActivityDate="2023-04-24T10:22:34.657" Title="How to make MEMS IR Thermal Sensor - D6T-44-L06 work with Arduino?" Tags="|sensors|arduino-yun|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5181" PostTypeId="2" ParentId="5163" CreationDate="2014-11-25T12:31:09.703" Score="0" Body="&lt;p&gt;I have the same problem using the Arduino IDE 1.5.6 beta.&#xA;Adding the library(s) using the menu (Sketch-&gt;include library-&gt;something) makes it work until the IDE is closed.&lt;/p&gt;&#xA;" OwnerUserId="4531" LastActivityDate="2014-11-25T12:31:09.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5183" PostTypeId="1" CreationDate="2014-11-25T12:52:37.320" Score="-3" ViewCount="5144" Body="&lt;p&gt;I am building my own arduino.Here is my code Below. I found code working for Digital Ios like blink example ; analog reading, Problem i am facing in Serial Monitor.Whenever i open Serial monitor i get trash values.I have choose proper crystal &amp;amp; proper values.  Please let me know possibility for getting trash values&lt;img src=&quot;https://i.stack.imgur.com/WnnrQ.jpg&quot; alt=&quot;Serial Out&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 2;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);&#xA;Serial.begin(9600);  &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  Serial.println(&quot;Welcome:&quot;);&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(100);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(100);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastActivityDate="2018-01-16T04:12:29.067" Title="Garbage value Serial Monitor" Tags="|arduino-uno|serial|programming|bootloader|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5184" PostTypeId="2" ParentId="5183" CreationDate="2014-11-25T13:51:31.877" Score="5" Body="&lt;p&gt;One of my projects does this too. I leave it connected to a USB port for power so it can control a room fan. Every 4 seconds it writes a line of data to the serial output. When I open a serial terminal on the computer, I immediately see a short stream of garbage, followed by the next, and all subsequent log outputs, properly displayed. It looks as if the serial-to-USB chip has some data buffered in it which it delivers, but out of sync, as soon as the terminal connection is made, but this is just a guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried resetting your chip while the terminal is connected? When I do this, there are no sync issues and the displayed data is all valid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;If you only ever get garbage from your terminal, then it's likely the terminal and the Arduino aren't matched for one or both of baud-rate or frame-size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino serial hardware uses an 8N1 frame: 8 data bits, No parity bit, 1 stop bit. Your serial monitor must be set to match this (and it probably is, since this is the most common convention, but worth checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, the baud rates must match. You've set the Arduino for 9600 baud and your serial monitor program must be also (from your screenshot, it looks like it is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You said you are using a crystal so it quite unlikely that Arduino's 9600 baud is inaccurate, but this could happen if you were using its internal clock source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, in the lower left corner of your serial monitor screen shot, it looks like you have selected &quot;No line endings&quot;. Serial.println() ends every line with CR/LF. See if that is an available line-ending setting. It is sometimes named &quot;OD OA&quot; (the hex values for Carriage-Return and Line-Feed). Try that setting if it is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial protocol is one of the oldest communication protocols but it has many variations. (Did someone say &quot;standard&quot;? :-)  Everyone gets bitten by it, eventually.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-11-26T19:08:20.930" LastActivityDate="2014-11-26T19:08:20.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5185" PostTypeId="1" CreationDate="2014-11-25T13:11:48.680" Score="1" ViewCount="1145" Body="&lt;p&gt;My datalogging system which consits of the Flora, RTC, SD card breakout board, LSM9DS0 sensor is shown in the picture below;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/s/d8pwcn59nq11lzs/2014-11-25%2012.26.56.jpg?dl=0&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/d8pwcn59nq11lzs/2014-11-25%2012.26.56.jpg?dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sampling rate/s is capped at 30 when writing into the sd card. If I disable the sensor and only save the time it goes up to 65. Writing into the serial interface rather than the sd card makes the rate goes up even higher at 127. for my application I need at least 100 samples/s. I am thinking the sd card is the problem after making the tests mentioned. The flora clock at 16Mhz is surely able to provide a higher sampling frequency. After checking the sensor datasheet and library I haven't found any limitation either. any input on this issue?&lt;/p&gt;&#xA;" OwnerUserId="7390" OwnerDisplayName="user49395" LastEditorUserId="6452" LastEditDate="2015-02-24T18:22:43.733" LastActivityDate="2015-02-24T18:22:43.733" Title="datalogging sampling frequency bottleneck" Tags="|sd-card|datalogging|rtc|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5186" PostTypeId="2" ParentId="4881" CreationDate="2014-11-25T13:57:02.383" Score="-1" Body="&lt;p&gt;i think the RFID is a other baud rate e.g 115200.. i dont know the device, i dont know if this is the problem, but test it :)&lt;/p&gt;&#xA;" OwnerUserId="4975" LastActivityDate="2014-11-25T13:57:02.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5187" PostTypeId="1" CreationDate="2014-11-25T15:58:33.603" Score="1" ViewCount="789" Body="&lt;p&gt;Do all Arduino Mega2560's have the same VID/PID identification numbers when seen by a PC as a device? I am planning on designing I specific driver to work with the 2560 and wondering if I will be able to use the same driver for multiple Arduino. Can anyone confirm this? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4423" LastEditorUserId="4423" LastEditDate="2014-11-25T16:03:35.437" LastActivityDate="2015-07-24T03:30:31.723" Title="Arduino Mega2560 Hardware ID" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5188" PostTypeId="2" ParentId="5173" CreationDate="2014-11-25T16:17:31.257" Score="1" Body="&lt;p&gt;There are good instructions here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/Standalone&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can go for an &lt;em&gt;Arduino mini&lt;/em&gt; &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardMini&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardMini&lt;/a&gt; or a corresponding Chinese clone.&lt;/p&gt;&#xA;" OwnerUserId="710" LastActivityDate="2014-11-25T16:17:31.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5189" PostTypeId="1" AcceptedAnswerId="5191" CreationDate="2014-11-25T16:39:37.210" Score="1" ViewCount="169" Body="&lt;p&gt;I am using small dc motors connected to the 5V of the arduino which is known to provide 200mA without damaging it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor I am using is a very common one found in toys -&gt; &lt;a href=&quot;https://www.sparkfun.com/datasheets/Robotics/ROB-09608.jpg&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Robotics/ROB-09608.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I see the maximum current of this motor is 170mA. Does it mean that the motor will not drain more current than that or it means that I need to use a resistor in series with my 5V in order to make sure the current will not pass 170mA?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-11-25T17:26:56.873" Title="Can a DC motor use more current than its datasheet?" Tags="|motor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5190" PostTypeId="2" ParentId="5185" CreationDate="2014-11-25T16:56:23.927" Score="1" Body="&lt;p&gt;First, based on my experience with similar hardware, something about the sd card I/O stinks: it should be plenty fast enough. Using a class 4 (cheapo) sd card I've seen a 16mhz AVR do a FAT filesystem open for appending, write a new record of maybe 70 characters and close the file, all a few hundred times per second. This was with the Arduino &quot;SD&quot; library apparently written by Sparkfun in 2010 and improved by Adafruit sometime later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the I/O library you're using is dog slow? Another possibility is that your SD card has a lot of files on it and something about directory (folder) traversal during an open is the bottleneck? (my experience is with just a few files on a given sd card)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could try buffering N samples so each sd card write records N samples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do this, don't forget to &quot;flush&quot; any remaining samples when you go from &quot;sampling&quot; to &quot;not sampling&quot; modes, if that's possible. That is, if something is telling the thing 'start', then 'stop', part of the response to 'stop' is to get the N-m buffered samples written out to the sd card.&lt;/p&gt;&#xA;" OwnerUserId="4977" LastEditorUserId="4977" LastEditDate="2014-11-26T00:15:34.653" LastActivityDate="2014-11-26T00:15:34.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5191" PostTypeId="2" ParentId="5189" CreationDate="2014-11-25T17:26:56.873" Score="1" Body="&lt;p&gt;YES (typically resulting in melting the coils). The current used by standard or brushless motors is related to the voltage applied and the load applied. As you approach the load limit, current rises over the limit. There are many ways to control this but controlling the load is the easiest way. DO NOT run the motor through the Arduino even if you think it will be under the 200mA limit. Motors produce a lot of spikes and back-flow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a tutorial on safely running a motor and controlling the speed: &lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/z7O3z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="228" LastActivityDate="2014-11-25T17:26:56.873" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5193" PostTypeId="2" ParentId="5187" CreationDate="2014-11-25T18:15:39.267" Score="1" Body="&lt;p&gt;VIP/PID is realized by Atmega16u2 driver which implements USB device driver. Probably all revisions of *Arduino Atmega2560*s has implicitely the same VID/PID. Each piece has unique serial number. But you can upload own firmware into 16u2 to modify USB as you wish (ideally using LUFA library). It's clean solution for production hardware because you cannot use Arduino VID because of USB rules.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-11-25T18:15:39.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5194" PostTypeId="1" CreationDate="2014-11-25T18:46:21.943" Score="0" ViewCount="549" Body="&lt;p&gt;Is it possible to use &lt;strong&gt;RXC Interrupt vector&lt;/strong&gt; with the factory programmed &lt;strong&gt;bootloader&lt;/strong&gt; still &lt;strong&gt;existing&lt;/strong&gt; in the &lt;strong&gt;arduino pro mini&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written a simple echo program using RXC interrupt vector, the program prints &quot;&lt;em&gt;READY&lt;/em&gt;&quot; on startup but as soon the chip receives the first character it goes into a &lt;strong&gt;repetitive reset loop&lt;/strong&gt; i.e. I keep receiving &lt;code&gt;READY READY READY..&lt;/code&gt; so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked the program multiple times and I think its the bootloader, I think the bootloader has shifted the interrupt table to the boot section before executing the application. Is that so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="537" LastEditorUserId="537" LastEditDate="2014-11-25T18:57:52.333" LastActivityDate="2015-08-21T23:26:45.183" Title="USART RX Interrupt on an ARDUINO PRO MINI containing factory bootloader" Tags="|bootloader|interrupt|arduino-pro-mini|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5195" PostTypeId="2" ParentId="5169" CreationDate="2014-11-25T18:59:43.297" Score="4" Body="&lt;p&gt;You know how wide the display is. You know how wide the text is. You know the position of the potentiometer. With those you can determine where in the text (if the text is wider) or display (if the display is wider) you need to start drawing from and where you need to stop drawing. Subtracting the text width from the display width will give you the range for performing linear interpolation with the pot position.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-25T18:59:43.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5196" PostTypeId="1" AcceptedAnswerId="5203" CreationDate="2014-11-25T20:26:11.050" Score="0" ViewCount="1197" Body="&lt;p&gt;I'm trying to send 60 float values via serial. Numbers are provided by an accelerometer and saved in a 240 bytes-long array. The array is sent to a function and these values are then copied in a structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&#xA;The content of the array is still correct when the function is called. Then, when I copy it in the structure, something wrong happens and data are modified after the 26th float. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where does the modification of an array of floats take place?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendBuffAcc(float a[])&#xA;{&#xA;  int stepCont = 1;&#xA;&#xA;  // Prints the content of the globally defined array buffXAccToSend&#xA;  Serial.println();      &#xA;  for (int i=0;i&amp;lt;sizeBuffAcc;i++)    &#xA;  {  &#xA;    Serial.print(&quot;val: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;    &quot;);&#xA;    Serial.println(buffXAccToSend[i]);&#xA;  }&#xA;  Serial.println();           &#xA;&#xA;  MyShortCommand * pMyCmdShort = (MyShortCommand *)(&amp;amp;bufferAcc[sizeof(MyControlHdr)]);&#xA;&#xA;  for (int i=0;i&amp;lt;sizeBuffAcc;i++)    &#xA;  {&#xA;    Serial.print(&quot;val: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;| Global Array:&quot;);&#xA;    Serial.println(buffXAccToSend[i]);&#xA;&#xA;    numFilterValuesToSend++;    &#xA;&#xA;    pMyCmdShort-&amp;gt;cmd = accValuesID;  &#xA;    pMyCmdShort-&amp;gt;param1 = a[i];  &#xA;    pMyCmdShort-&amp;gt;param2 = 0;&#xA;    pMyCmdShort-&amp;gt;param3 = 0;&#xA;    pMyCmdShort-&amp;gt;param4 = 0;&#xA;&#xA;    Serial.print(&quot;|   Param: &quot;);&#xA;    Serial.print(pMyCmdShort-&amp;gt;param1);&#xA;    Serial.print(&quot;|   Array:&quot;);&#xA;    Serial.println(a[i]);&#xA;&#xA;    // Move the pointer to save data in next positions&#xA;    pMyCmdShort++;&#xA;  }&#xA;  stepCont++;&#xA; }&#xA; storeAccData = false;&#xA; contBuffAcc=1;      &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, the content of the global array &lt;code&gt;buffXAccToSend&lt;/code&gt; is printed via serial, then the i-th elements of a[i] and the value assigned to the pMyCmdShort-&gt;param1. This is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val: 0    -0.00&#xA;val: 1    -0.00&#xA;val: 2    0.01&#xA;val: 3    -0.01&#xA;val: 4    0.04&#xA;val: 5    0.00&#xA;val: 6    0.01&#xA;val: 7    0.03&#xA;val: 8    0.01&#xA;val: 9    -0.00&#xA;val: 10    0.00&#xA;val: 11    -0.01&#xA;val: 12    -0.00&#xA;val: 13    0.01&#xA;val: 14    -0.02&#xA;val: 15    0.03&#xA;val: 16    0.00&#xA;val: 17    0.02&#xA;val: 18    -0.01&#xA;val: 19    0.00&#xA;val: 20    0.00&#xA;val: 21    -0.00&#xA;val: 22    -0.01&#xA;val: 23    -0.01&#xA;val: 24    0.01&#xA;val: 25    0.01&#xA;val: 26    -0.00&#xA;val: 27    0.03&#xA;val: 28    -0.01&#xA;val: 29    -0.00&#xA;val: 30    0.04&#xA;val: 31    -0.01&#xA;val: 32    0.01&#xA;&#xA;val: 0| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 1| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 2| Global Array: -0.01|  Param: -0.01|  Array: -0.01&#xA;val: 3| Global Array: -0.02|  Param: -0.02|  Array: -0.02&#xA;val: 4| Global Array: 0.02|  Param: 0.02|  Array: 0.02&#xA;val: 5| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 6| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 7| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 8| Global Array: 0.04|  Param: 0.04|  Array: 0.04&#xA;val: 9| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 10| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 11| Global Array: -0.00|  Param: -0.00|  Array: -0.00&#xA;val: 12| Global Array: -0.01|  Param: -0.01|  Array: -0.01&#xA;val: 13| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 14| Global Array: -0.02|  Param: -0.02|  Array: -0.02&#xA;val: 15| Global Array: -0.02|  Param: -0.02|  Array: -0.02&#xA;val: 16| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 17| Global Array: -0.02|  Param: -0.02|  Array: -0.02&#xA;val: 18| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 19| Global Array: 0.03|  Param: 0.03|  Array: 0.03&#xA;val: 20| Global Array: -0.01|  Param: -0.01|  Array: -0.01&#xA;val: 21| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 22| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 23| Global Array: 0.01|  Param: 0.01|  Array: 0.01&#xA;val: 24| Global Array: -0.01|  Param: -0.01|  Array: -0.01&#xA;val: 25| Global Array: -0.02|  Param: -0.02|  Array: -0.02&#xA;val: 26| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 27| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 28| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 29| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 30| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 31| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;val: 32| Global Array: 0.00|  Param: 0.00|  Array: 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output of avr-size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   text    data     bss     dec     hex&#xA;  55828    3906    2978   62712    f4f8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it a memory related problem? &lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="630" LastEditDate="2015-01-26T16:34:36.047" LastActivityDate="2015-12-23T02:38:47.467" Title="Saving data in a globally declared float array" Tags="|serial|arduino-mega|float|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5198" PostTypeId="1" AcceptedAnswerId="5221" CreationDate="2014-11-25T21:43:20.960" Score="0" ViewCount="1420" Body="&lt;p&gt;I have followed this tutorial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Automatically-water-your-small-indoor-plant-using-/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Automatically-water-your-small-indoor-plant-using-/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time i try to run my circuit, My transistor gets very hot and breaks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have exactly the same parts as the tutorial. I have also tested the circuit with 3.3V Power supply and a diode instead of an engine, this works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am super thankfull for any answers.&lt;/p&gt;&#xA;" OwnerUserId="4985" LastActivityDate="2014-11-27T22:26:30.820" Title="Why is my transistor getting very hot when controlling a 12V peristalic pump?" Tags="|arduino-uno|motor|transistor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5199" PostTypeId="1" AcceptedAnswerId="5266" CreationDate="2014-11-25T22:16:49.890" Score="0" ViewCount="1025" Body="&lt;p&gt;I have been working on a project for work ( I'm a waiter :/ ) I was tasked to build a food wait time display that receives input from the kitchen and echoes the time via bluetooth to another display.&#xA;So that we are all on the same page I will describe what I have built and where I am stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Before I do, I would like to state that I have:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;been planning and prototyping this thing for over a month&lt;/li&gt;&#xA;&lt;li&gt;googled/crawled all over the web looking for answers&lt;/li&gt;&#xA;&lt;li&gt;read the entire manual on the HC05 module&lt;/li&gt;&#xA;&lt;li&gt;Bound both of the bluetooth modules via AT commands One as Master the  other as Slave&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now with that out out the way here is what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2x Arduino uno R3&lt;/li&gt;&#xA;&lt;li&gt;2x 16x2 LCD Display&lt;/li&gt;&#xA;&lt;li&gt;2x HC05 Bluetooth Modules (1 set as Master the other as Slave &amp;amp; bound using AT Commands)&lt;/li&gt;&#xA;&lt;li&gt;2x 10K Potentiometers for adjusting the contrast&lt;/li&gt;&#xA;&lt;li&gt;3x Momentary push Button switches on Master with pull-up resistors (timeUp, timeDown, sendButton)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is where I am stuck. &lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to get the master and slave to communicate. RX and TX on master were crossed... SMH! However now the issue is that the slave is &lt;em&gt;writing&lt;/em&gt; both digits it receives on top of itself. First writing one digit then clearing it and then the second digit...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enough with the prologue here is the a code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Master&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //sets up LCD pins&#xA;int waitTime = 10; //if food comes quicker than there is no need for a display ;)&#xA;const int timeUp = 6; &#xA;const int timeDown = 7;&#xA;const int sendButton = 8;&#xA;int timeUpState = 0;&#xA;int timeDownState = 0;&#xA;int sendButtonState = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(timeUp, INPUT);&#xA;  pinMode(timeDown, INPUT);&#xA;  pinMode(sendButton, INPUT);&#xA;  lcd.begin(16, 2);&#xA;  lcd.print(&quot;  Sam Kullman's&quot;); //Splash screen on start up&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;      Diner&quot;); //Splash Screen&#xA;  delay(2000);        // Delay intended to allow the device to pair prior to use.&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Essen Dauert:&quot;); //German for &quot;Food takes&quot;:&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;   Minuten&quot;); // xx minutes&#xA;  }&#xA;&#xA;void loop(){&#xA;  lcd.setCursor(0,1);&#xA;  timeUpState = digitalRead(timeUp);&#xA;  timeDownState = digitalRead(timeDown);&#xA;  sendButtonState = digitalRead(sendButton);&#xA;  if (timeUpState == LOW) {&#xA;  waitTime += 5;&#xA;  delay(500);  //debounce button&#xA;  lcd.print(waitTime);&#xA;  }&#xA;&#xA;  if(waitTime &amp;gt; 90){ // Max limit for wait time&#xA;    waitTime = 10;   //default wait time&#xA;    lcd.clear();&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;Essen Dauert:&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;   Minuten&quot;);   &#xA;   }&#xA;&#xA; if (timeDownState == LOW){&#xA;  waitTime -= 5;&#xA;  delay(500);&#xA;  lcd.print(waitTime);&#xA;  }&#xA;&#xA;  if(waitTime &amp;lt; 10){ //Min value waiting time&#xA;    waitTime = 10;&#xA;    lcd.clear();&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;Essen Dauert:&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;   Minuten&quot;);&#xA;   }&#xA;&#xA;  if(Serial.available()){  // **This is where I am stuck** &#xA;   if(sendButtonState == LOW){&#xA;   Serial.write(waitTime);&#xA;   delay(500);&#xA;  } &#xA; }  &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.flush();&#xA;  lcd.begin(16, 2);&#xA;  lcd.print(&quot;  Sam Kullman's&quot;);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;      Diner&quot;);&#xA;  }&#xA;&#xA;void loop(){&#xA;&#xA;  if (Serial.available()) {&#xA;   int waitTime = Serial.read();&#xA;    delay(200);&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Essen Dauert:&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.write(waitTime);&#xA;    lcd.print(&quot; Minuten&quot;);&#xA;     }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&#xA;Jonathan&lt;/p&gt;&#xA;" OwnerUserId="4986" LastEditorUserId="4986" LastEditDate="2014-11-28T13:51:23.967" LastActivityDate="2014-12-01T10:04:25.007" Title="Arduino to Arduino Communication using HC05" Tags="|arduino-uno|serial|bluetooth|communication|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5200" PostTypeId="2" ParentId="5155" CreationDate="2014-11-26T01:04:37.167" Score="1" Body="&lt;p&gt;I think &lt;a href=&quot;http://fritzing.org/home/&quot; rel=&quot;nofollow&quot;&gt;Fritzing&lt;/a&gt; is used quite a lot. I have used it myself a couple of times, and I felt it was quite comprehensive. But I haven't used it enough to say whether this is &lt;em&gt;the&lt;/em&gt; tool to choose.&lt;/p&gt;&#xA;" OwnerUserId="3031" LastActivityDate="2014-11-26T01:04:37.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5201" PostTypeId="2" ParentId="5133" CreationDate="2014-11-26T01:18:32.147" Score="7" Body="&lt;p&gt;Your serial connection is set to 9600 baud, which is 9600 &lt;em&gt;actual data&lt;/em&gt; bits per second. The communication consists &lt;em&gt;(*)&lt;/em&gt; of 8 bit characters and every bit is useful data (no parity), so you would be able to achieve at most 9600 / 8 = 1200 characters per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a message of 46 characters including the line break, which brings you to 1200 / 46 = 26 iterations per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1000 milliseconds / 26 iterations = about 39 milliseconds per iterations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the theoretic maximum you would get if you would send the data over serial without any other overhead. Pretty close to the 32 + 15 = 47 milliseconds you measured.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you print a part of the message (Enter + 'Start:') between the end of the previous iteration and the start of the next (if you take the call to &lt;code&gt;micros()&lt;/code&gt; as the start and end), it makes sense that a part of the time is in between there as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the actual overhead you are looking at is about 8ms per iteration. This delay is spread out over the loop and the call overhead of the various functions you use. After all, when you call Serial.print, a &lt;em&gt;lot&lt;/em&gt; of work needs to be done before the data can actually be sent to the serial port. You would probably gain more speed/less overhead if you would construct one big string, and send it with a single print command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino itself is slow, but still much faster than this. It should be able to do a big(ger) number of iterations per second, but you basically limited it by initialising the serial connection to such a slow speed. You can partially eliminate this by picking a higher number. I think both your Arduino and any modern serial port should be able to handle 115200 baud. Nevertheless, you will always have a relatively big overhead when you are sending data over serial. Use your bandwidth wisely, and reduce the number of calls to Serial.print as much as you reasonably can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*&#xA;&lt;em&gt;) 8 bit, no parity is the de facto default. See &lt;a href=&quot;http://arduino.cc/en/Serial/begin&quot; rel=&quot;noreferrer&quot;&gt;Serial.begin()&lt;/a&gt; for more information about initializing the serial connection.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3031" LastEditorUserId="3031" LastEditDate="2014-11-26T15:21:38.357" LastActivityDate="2014-11-26T15:21:38.357" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5202" PostTypeId="2" ParentId="5173" CreationDate="2014-11-26T02:03:14.787" Score="3" Body="&lt;p&gt;You can embed a bootloaded ATMega328 (or any of the other compatible ATMega processors) &lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/Standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/pmwiki.php?n=Main/Standalone&lt;/a&gt; in your project. That way, you will only need the processor and a couple of components, setting you back only a couple of dollars &lt;em&gt;and&lt;/em&gt; saving quite a lot of space:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/Standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/pmwiki.php?n=Main/Standalone&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is one bridge to far, you can have a look at the Arduino Pro or &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Pro Mini&lt;/a&gt;. Those boards are complete boards, only smaller and cheaper, and specifically designed for a more definitive use in projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need even more space and cost reduction, you can switch to a stand-alone ATTiny processor. The better models of those can also contain an Arduino program. &lt;em&gt;Instructables&lt;/em&gt; has this &lt;a href=&quot;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;great tutorial&lt;/a&gt; that shows you how to use an ATTiny85 or ATTiny45 as a lightweight 'Arduino'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently, I have &lt;a href=&quot;https://electronics.stackexchange.com/questions/136919/attiny-project-resets-when-plugging-in-phone&quot;&gt;tried to use an ATTiny13A&lt;/a&gt; for a project, but that one only has 1KB of flash memory, which leaves you with hardly any space for the Arduino bootloader, let alone your program, so therefor I chose to program it directly using AVR Studio, at which point I think you cannot in any way call it an Arduino project anymore. :) Still, it's not that different. You only miss out on some of the library functions, and the implied application loop.&lt;/p&gt;&#xA;" OwnerUserId="3031" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-26T02:03:14.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5203" PostTypeId="2" ParentId="5196" CreationDate="2014-11-26T02:16:02.047" Score="2" Body="&lt;p&gt;The ATmega328P has 2kiB of SRAM. Your program uses almost 3kiB. Move strings and constant values &lt;a href=&quot;http://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;into flash&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-26T02:16:02.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5207" PostTypeId="2" ParentId="646" CreationDate="2014-11-26T16:07:50.410" Score="1" Body="&lt;p&gt;Try setting the baud rate to 9600 in the Serial Monitor. You need a working serial port to open the Serial Monitor. Or go to &gt;File &gt;Preferences&gt; and edit the preferences.txt (must close Arduino IDE before editing) &quot;serial.debug_rate=9600&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several Arduino boards and had the exact same issue with the boards that use the Atmel mega8U2 as the USB - serial bridge. The boards with the FTDI USB bridge (SparkFun Red board, Pro mini) did not show the same problem. Setting the baud rate solved my problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a firmware upgrade for 8U2 that might fix it but I didn't want to risk making bricks. ;-)&lt;/p&gt;&#xA;" OwnerUserId="4996" LastActivityDate="2014-11-26T16:07:50.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5208" PostTypeId="1" CreationDate="2014-11-26T16:30:23.230" Score="2" ViewCount="460" Body="&lt;p&gt;I have a MAX5724 8 channel 10 bit DAC's connected to a due, i believe i have it wired up correctly, however when  i try to write a value to it doesn't seem to output anything. Either i misunderstood the datasheet in the wiring or im writing incorrectly to it. Since i have the LDAC connected to GND i think i can just use the CODEn command on page 21 of the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A link to the datasheet:&#xA;&lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/MAX5723-MAX5725.pdf&quot; rel=&quot;nofollow&quot;&gt;http://datasheets.maximintegrated.com/en/ds/MAX5723-MAX5725.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here the code i use to write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define CS 52&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Serial.begin(115200);&#xA;  SPI.begin(CS);&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  SPI.setDataMode(CS, 1);&#xA;  SPI.setClockDivider(CS, 3); // 28MHz&#xA;  pinMode(CS, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(CS, HIGH);&#xA;  digitalWrite(CS, LOW);&#xA;  &#xA;&#xA; byte msg1 = 0b11000010; &#xA; byte msg2 = 0b11111111;&#xA; byte msg3 = 0b11111111;&#xA;&#xA;&#xA; SPI.transfer(CS,msg1,SPI_CONTINUE);&#xA; SPI.transfer(CS,msg2,SPI_CONTINUE);&#xA; SPI.transfer(CS,msg3,SPI_LAST);&#xA; delay(4000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;wiring:&#xA;1 = 5V,&#xA;2 - 9 = OUTPUT,&#xA;10 = 5V,&#xA;11 = 5V,&#xA;12 = MOSI (middle pins),&#xA;13 = MISO (middle pins),&#xA;14 = SCK (middle pins),&#xA;15 = PIN 52,&#xA;16 = OUTPUT,&#xA;17 = 5V,&#xA;18 = GND,&#xA;19 = GND,&#xA;20 = GND,&lt;/p&gt;&#xA;" OwnerUserId="4998" LastActivityDate="2014-11-26T16:30:23.230" Title="Interfacing arduino due to MAX5724 DAC" Tags="|arduino-due|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5209" PostTypeId="1" CreationDate="2014-11-26T19:38:24.643" Score="0" ViewCount="1197" Body="&lt;p&gt;I have an Arduino board which is controlling a servo. I think I read that I could only supply about 100 mA through the Arduino's 5v pin. Because of that the power supply I use is able to deliver about 2A I would like to split the power before the Arduino. How do I do that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to take some safety for the Aduino in concern or could I just split the wire?&lt;/p&gt;&#xA;" OwnerUserId="4912" LastActivityDate="2018-03-21T15:58:56.173" Title="Splitting the power source between an arduino and a servo" Tags="|power|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5210" PostTypeId="1" AcceptedAnswerId="5211" CreationDate="2014-11-26T23:00:58.797" Score="1" ViewCount="2849" Body="&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/sc/ur5f8b10ifdtuhz/AADK7fM8EeLWgxXQ0I42VrGoa&quot; rel=&quot;nofollow&quot;&gt;Click here to see my program running&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created a 2D array (see my full code below), and each row contains one state of a battery here is  a schematic :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;row [0] : &quot;▯▢▢▷&quot; // this row represents an empty AAA battery &#xA;row [1] : &quot;▮▩▢▷&quot;&#xA;row [2] : &quot;▮▩▩▷&quot;&#xA;row [3] : &quot;▮▩▩ ▶&quot;  // this row represents a Full AAA battery    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each &quot;▩&quot; character is a custom made character with this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.createChar(0, customLcdfont_squareONE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you saw in my video it works at the end, but it's absolutely not the way I want it to work. The code that works is a mess!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I think the problem is that the Raw n°1 ([0]) starts with a 0, (try it out it's very strange). If we replace&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char batteryFonts [10][5] = {&#xA;  { 0, 1, 1, 2 }, // you see { this &quot;0&quot;, 1, 1, 2 }, is a problem I think &#xA;  { 3, 1, 1, 2 },&#xA;  {etc}, }&#xA;lcd.print( batteryFonts[0]);  // this sentence does not work&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;with&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want &#xA;  {etc}, &#xA;  {etc}, }&#xA; lcd.print( batteryFonts[0]);  // this sentence behind does work, but only with a row that does not start with a 0. Why?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my full code. Just connect the pins 12, 13, 7, 4, 3, 2 to the LCD.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//This is a simple program that charges alkaline batteries &#xA;//Copyleft&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(12, 13, 7, 4, 3, 2); // why pin 13 and not 12 ? because I love the led attached to it &amp;lt;3&#xA;&#xA;&#xA;// the empty battery - end &#xA;byte customLcdfont_A [8] = { // B stand for &quot;Binary&quot; and then the pixel ... &#xA;B01111,&#xA;B11000,&#xA;B10101,&#xA;B10100,&#xA;B10100,&#xA;B10100,&#xA;B11000,&#xA;B01111&#xA;&#xA;// the empty battery body with fancy graphics enabled&#xA;&#xA;};&#xA;byte customLcdfont_B [8] = { // B stand for &quot;Binary&quot; and then the pixel ... &#xA;B11111,&#xA;B00000,&#xA;B11001,&#xA;B00000,&#xA;B00000,&#xA;B00000,&#xA;B00000,&#xA;B11111&#xA;};&#xA;&#xA;&#xA;// the empty battery + end&#xA;&#xA;byte customLcdfont_C [8] = { // B stand for &quot;Binary&quot; and then the pixel ... &#xA;B11100,&#xA;B00100,&#xA;B10111,&#xA;B00101, &#xA;B00111,&#xA;B00111,&#xA;B00100,&#xA;B11100&#xA;};&#xA;&#xA;&#xA;// the full battery - end&#xA;&#xA;byte customLcdfont_D [8] = { // B stand for &quot;Binary&quot; and then the pixel ... &#xA;B1111,&#xA;B11111,&#xA;B10110,&#xA;B10111,&#xA;B10111,&#xA;B10111,&#xA;B11111,&#xA;B1111&#xA;};&#xA;&#xA;&#xA;// the FULL battery + end&#xA;byte customLcdfont_E [8] = { // B stand for &quot;Binary&quot; and then the pixel ... &#xA;B11100,&#xA;B11100,&#xA;B01111,&#xA;B11101,&#xA;B11111,&#xA;B11111,&#xA;B11100,&#xA;B11100&#xA;};&#xA;&#xA;// the full battery  body&#xA;&#xA;byte customLcdfont_F [8] = {&#xA;B11111,&#xA;B11111,&#xA;B00110,&#xA;B11111,&#xA;B11111,&#xA;B11111,&#xA;B11111,&#xA;B11111&#xA;};&#xA;&#xA;// the 1/3 battery body &#xA;&#xA;byte customLcdfont_G [8] = {&#xA;B11111,&#xA;B11000,&#xA;B00001,&#xA;B11000,&#xA;B11000,&#xA;B11000,&#xA;B11000,&#xA;B11111&#xA;};&#xA;// the 2/3 battery body &#xA;&#xA;byte customLcdfont_H [8] = {&#xA;B11111,&#xA;B11110,&#xA;B00111,&#xA;B11110,&#xA;B11110,&#xA;B11110,&#xA;B11110,&#xA;B11111&#xA;};&#xA;&#xA;&#xA;&#xA;/**************************************************************************/&#xA;void setup() {&#xA;  int i = 0 ; &#xA;  // initialize serial communications at 9600 bps:&#xA;  lcd.createChar(0, customLcdfont_A);&#xA;  lcd.createChar(1, customLcdfont_B);&#xA;  lcd.createChar(2, customLcdfont_C); &#xA;  lcd.createChar(3, customLcdfont_D);&#xA;  lcd.createChar(4, customLcdfont_E);&#xA;  lcd.createChar(5, customLcdfont_F);&#xA;  lcd.createChar(6, customLcdfont_G);&#xA;  lcd.createChar(7, customLcdfont_H);&#xA;&#xA;  lcd.begin(16, 2); &#xA;&#xA;// WATCH HERE IS THE PROBLEM !!!!&#xA;&#xA;//the char table behind creates my different battery states as shown in the video ;) &#xA;&#xA; char batteryFonts [10][5]={&#xA;&#xA; { 0, 1, 1, 2 }, // this is an empty one  f%*# this does not work !!!&#xA; { 3, 1, 1, 2 },&#xA; { 3, 6, 1, 2 },&#xA; { 3, 7, 1, 2 },// this is a 50 % full charged battery ! &#xA;&#xA; { 3, 5, 1, 2 },&#xA; { 3, 5, 6, 2 },&#xA; { 3, 5, 7, 2 }, &#xA; { 3, 5, 5, 2 },&#xA; { 3, 5, 5, 4 },// this is nice full one  &#xA; };&#xA;&#xA;&#xA;&#xA; // this sentence behind does not work !!! but only with the raw [0]&#xA;&#xA; lcd.print( batteryFonts[0]);    // I F***ing want this to display the first raw !!!! &#xA; lcd.setCursor(0,1 );&#xA;&#xA;  lcd.print(&quot; not working &quot;);&#xA; lcd.setCursor(0,0 );&#xA;&#xA;&#xA;&#xA;&#xA;        delay(9300); // this make a short pause  for us so that we can see the result&#xA;lcd.setCursor(0,1 );&#xA;&#xA;  lcd.print(&quot;    working      &quot;);&#xA; lcd.setCursor(0,0 );&#xA;      for (i=0; i=10 ; i+=1 ){&#xA;       delay(300);&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;&#xA;  lcd.write(byte(0));   lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));&#xA;    delay(700); //  batterry 0/8 empty aka discharged&#xA;&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;  lcd.write(byte(3));   lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));&#xA;    delay(1000); //batterry 1 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;  lcd.write(byte(3));   lcd.write(byte(6)); lcd.write(byte(1)); lcd.write(byte(2));&#xA;   delay(1000);//batterry 2 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;   lcd.write(byte(3));   lcd.write(byte(7)); lcd.write(byte(1)); lcd.write(byte(2)); //batery 3 /8&#xA;&#xA;  delay(1000);&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;   lcd.write(byte(3));   lcd.write(byte(5)); lcd.write(byte(1)); lcd.write(byte(2));&#xA;  delay(1000); //batery 4 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;        lcd.write(byte(3));  lcd.write(byte(5));     lcd.write(byte(6));   lcd.write(byte(2));&#xA;  delay(1000); //batery 5 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;      lcd.write(byte(3));  lcd.write(byte(5));   lcd.write(byte(7));  lcd.write(byte(2));&#xA;        delay(1000); //batery 6 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;      lcd.write(byte(3));  lcd.write(byte(5));   lcd.write(byte(5));  lcd.write(byte(2));&#xA;      delay(1000); //batery 7 /8&#xA;&#xA;  lcd.setCursor(6,0 );&#xA;    lcd.write(byte(3));  lcd.write(byte(5));     lcd.write(byte(5));    lcd.write(byte(4)); //batery 8 /8&#xA;&#xA;    delay(1000); &#xA;&#xA;      }&#xA;&#xA;&#xA;    lcd.setCursor(15, 1);&#xA;&#xA;    delay(115000);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;/**************************************************************************/&#xA;void loop() {&#xA;&#xA;//This is not interesting here &#xA;  lcd.print(&quot; ~ The end of the code ... thank you for reading ;) ~ &quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4951" LastEditorUserId="4951" LastEditDate="2014-12-01T19:16:13.240" LastActivityDate="2014-12-01T19:16:13.240" Title="lcd.print and 2D arrays" Tags="|arduino-uno|programming|library|lcd|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5211" PostTypeId="2" ParentId="5210" CreationDate="2014-11-27T00:08:26.460" Score="2" Body="&lt;p&gt;You are correct; in C a NUL (0x00) is used to indicate the end of a &lt;code&gt;char*&lt;/code&gt;. You will need to use &lt;code&gt;LiquidCrystal::write()&lt;/code&gt; in order to send the character data byte by byte instead of depending on &lt;code&gt;LiquidCrystal::print()&lt;/code&gt; to handle it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, consider moving all of that static data &lt;a href=&quot;http://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;into flash&lt;/a&gt;; you're going to need to handle it manually so you may as well do it right in the first place.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-27T00:08:26.460" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5213" PostTypeId="1" AcceptedAnswerId="5216" CreationDate="2014-11-27T06:53:15.400" Score="2" ViewCount="297" Body="&lt;p&gt;How can I port these structures to arduino ide, I also get error when I define pointers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// pointer to classes example&#xA;#include &amp;lt;iostream&amp;gt;&#xA;using namespace std;&#xA;&#xA;class Rectangle {&#xA;  int width, height;&#xA;public:&#xA;  Rectangle(int x, int y) : width(x), height(y) {}&#xA;  int area(void) { return width * height; }&#xA;};&#xA;&#xA;&#xA;int main() {&#xA;  Rectangle obj (3, 4);&#xA;  Rectangle * foo, * bar, * baz;&#xA;  foo = &amp;amp;obj;&#xA;  bar = new Rectangle (5, 6);&#xA;  baz = new Rectangle[2] { {2,5}, {3,6} };&#xA;  cout &amp;lt;&amp;lt; &quot;obj's area: &quot; &amp;lt;&amp;lt; obj.area() &amp;lt;&amp;lt; '\n';&#xA;  cout &amp;lt;&amp;lt; &quot;*foo's area: &quot; &amp;lt;&amp;lt; foo-&amp;gt;area() &amp;lt;&amp;lt; '\n';&#xA;  cout &amp;lt;&amp;lt; &quot;*bar's area: &quot; &amp;lt;&amp;lt; bar-&amp;gt;area() &amp;lt;&amp;lt; '\n';&#xA;  cout &amp;lt;&amp;lt; &quot;baz[0]'s area:&quot; &amp;lt;&amp;lt; baz[0].area() &amp;lt;&amp;lt; '\n';&#xA;  cout &amp;lt;&amp;lt; &quot;baz[1]'s area:&quot; &amp;lt;&amp;lt; baz[1].area() &amp;lt;&amp;lt; '\n';       &#xA;  delete bar;&#xA;  delete[] baz;&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/classes/&quot; rel=&quot;nofollow&quot;&gt;CPP shell&lt;/a&gt; it works&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to put it like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Rectangle {&#xA;  int width, height;&#xA;public:&#xA;  Rectangle(int x, int y) : width(x), height(y) {}&#xA;  int area(void) { return width * height; }&#xA;};&#xA;&#xA;  Rectangle obj (3, 4);&#xA;  Rectangle * foo, * bar, * baz;&#xA;  foo = &amp;amp;obj;&#xA;  bar = new Rectangle (5, 6);&#xA;  baz = new Rectangle[2] { {2,5}, {3,6} };&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get an error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_nov27a.ino:10:3: error: 'foo' does not name a type&#xA;sketch_nov27a.ino:11:3: error: 'bar' does not name a type&#xA;sketch_nov27a.ino:12:3: error: 'baz' does not name a type&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5003" LastEditorUserId="84" LastEditDate="2014-11-27T19:18:40.907" LastActivityDate="2014-11-27T19:18:40.907" Title="How to prepare data structures and classes?" Tags="|c++|arduino-ide|class|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5214" PostTypeId="2" ParentId="5213" CreationDate="2014-11-27T07:44:36.867" Score="0" Body="&lt;p&gt;You put a bunch of code in a place where you can't have it. Move the assignments into a function body.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-27T07:44:36.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5216" PostTypeId="2" ParentId="5213" CreationDate="2014-11-27T12:48:30.397" Score="2" Body="&lt;p&gt;The problem is that the lines saying &lt;code&gt;foo = ...&lt;/code&gt; etc. are assignment operations. C++ lets you declare and immediately initialise variables at global scope, but after that you can only assign to them inside a function. In your original program, all your declarations/assignments were inside &lt;code&gt;main()&lt;/code&gt;, which is why it worked there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your Arduino program, you could change the assignments to initialisations instead (in global scope):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rectangle obj (3, 4);&#xA;Rectangle * foo = &amp;amp;obj;&#xA;Rectangle * bar = new Rectangle (5, 6);&#xA;Rectangle * baz = new Rectangle[2] { {2,5}, {3,6} };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could leave the declarations in global scope and move the assignments into &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rectangle obj (3, 4);&#xA;Rectangle * foo, * bar, * baz;&#xA;&#xA;void setup() {&#xA;    foo = &amp;amp;obj;&#xA;    bar = new Rectangle (5, 6);&#xA;    baz = new Rectangle[2] { {2,5}, {3,6} };&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-11-27T12:48:30.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5217" PostTypeId="1" CreationDate="2014-11-27T15:51:57.230" Score="0" ViewCount="884" Body="&lt;p&gt;How do you determine if an Arduino shield uses 3.3V or 5V on their pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I thought all Arduino shields used 5V, since that's what most  Arduinos use. However, I've been researching Arduino-compatible single-board computers like the PCDuino and Galileo, but these all seem to use 3.3V. More confusingly, they're vague about what types of Arduino shields they support. The PCDuino claims to only support 3.3V shields, but has an adapter shield to convert 5V. The Galileo has a jumper to support either 3.3V or 5V shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem is how do you determine what voltage level Arduino shields use? I have a Seeedstudio motor shield and a Sain Smart sensor shield, and while they both take 5V power input, the docs don't mention anything about logic voltage level. How do I determine this?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2014-12-27T18:06:40.900" Title="Determine difference between 3.3V and 5V shields" Tags="|arduino-uno|shields|voltage-level|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5218" PostTypeId="2" ParentId="5217" CreationDate="2014-11-27T16:08:22.973" Score="1" Body="&lt;p&gt;You read the schematics and datasheets. The former will tell you what power supplies are connected and how, and the latter will tell you what voltages are acceptable to the devices.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-11-27T16:08:22.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5219" PostTypeId="1" CreationDate="2014-11-27T16:12:36.607" Score="0" ViewCount="980" Body="&lt;p&gt;Is it possible to use the &lt;a href=&quot;http://www.radioshack.com/radioshack-ultrasonic-range-sensor/2760342.html&quot; rel=&quot;nofollow&quot;&gt;2760342 ultrasonic range sensor&lt;/a&gt; with an Arduino Due? The docs say it takes a 5V input, but doesn't specify the output, but I'm assuming it also outputs a 5V signal. Does this make it incompatible with the Due?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested it with an Uno, it it works flawlessly. I've been researching using a Due and some other ARM based single-board computers, but they all seem to use 3.3V, while almost all Arduino shields and sensors use 5V. I'm hesitant to &quot;upgrade&quot; to these boards if I have to purchase an entire new set of shields and sensors. And I have no interest in hacking in some clunky custom voltage level shifter. Why isn't everything standardized on 5V?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-05-28T01:38:09.673" Title="Wiring 5V ultrasonic sensor to Arduino Due" Tags="|sensors|shields|arduino-due|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5220" PostTypeId="2" ParentId="5178" CreationDate="2014-11-27T20:41:24.113" Score="0" Body="&lt;p&gt;It could be the settings of the serial port (you mentioned com 7). Try going on your Arduino Integrated Development Environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to Tools &gt; Serial Port &gt; (and try putting this setting on different serial ports)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Serial Port is grayed out and you cant press it, try restarting the Arduino with the restart button, and hopefully you will have an opportunity to change the Serial Port in those few seconds that the Arduino is recognized. Try all the different Serial Ports your computer has.&lt;/p&gt;&#xA;" OwnerUserId="5009" LastActivityDate="2014-11-27T20:41:24.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5221" PostTypeId="2" ParentId="5198" CreationDate="2014-11-27T22:26:30.820" Score="0" Body="&lt;p&gt;Measure the Current through the motor, the PN2222 can pass a maximum of 600mA.&#xA;I would guess that just over half an amp would be enough for the motor but you can check what you motor is trying to pull by connecting it to 12 V direct and measure the supply current.&#xA;The only thing that will make the transistor hot is excess current&lt;/p&gt;&#xA;" OwnerUserId="5010" LastActivityDate="2014-11-27T22:26:30.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5222" PostTypeId="1" CreationDate="2014-11-27T23:02:49.847" Score="2" ViewCount="15924" Body="&lt;pre&gt;&lt;code&gt;#define pingTrig 6 &#xA;#define pingEcho 7 &#xA;&#xA;#include &#xA;&#xA;Servo myservo;&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(pingTrig, OUTPUT);&#xA;pinMode(pingEcho, INPUT);&#xA;myservo.attach(9);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;long duration, inches, cm;&#xA;&#xA;digitalWrite(pingTrig, LOW);&#xA;digitalWrite(pingTrig, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(pingTrig, LOW);&#xA;&#xA;duration = pulseIn(pingEcho, HIGH);&#xA;&#xA;cm = duration / 29 / 2;&#xA;&#xA;if(cm &amp;lt; 10 ){&#xA;myservo.write(90);&#xA;delay(100);&#xA;}else{&#xA;myservo.write(0);&#xA;}&#xA;delay(2000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5011" LastEditorUserId="5011" LastEditDate="2014-11-27T23:09:04.090" LastActivityDate="2020-11-27T08:07:04.567" Title="Why does it say &quot;Servo&quot; does not name a type" Tags="|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5223" PostTypeId="1" CreationDate="2014-11-28T00:03:34.450" Score="2" ViewCount="1068" Body="&lt;p&gt;I have been trying for some time to get documentation on using Java and a Firmata client library for the communication between a PC and an Arduino. Please note I want to use Java only, i.e., not Processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Up to now I used the excellent Haskell library &lt;a href=&quot;https://hackage.Haskell.org/package/hArduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;hArduino&lt;/a&gt; for Firmata communication with Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am teaching a Java course at the university as a PhD student. Therefore I need to use Java. However, compared to Haskell there are no centralized libraries, packages, documentation as with Haskell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I used Google to find more information on using Firmata client libraries for Java. Unfortunately, the search results are polluted with irrelevant results about Processing and Javascript. Therefore I ask here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the Firmata &lt;a href=&quot;https://github.com/Firmata/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;client library page&lt;/a&gt;, there are two Java client libraries. However, only &lt;a href=&quot;https://github.com/4ntoine/Firmata&quot; rel=&quot;nofollow noreferrer&quot;&gt;4ntoine&lt;/a&gt; seems to be up to date, while the &lt;a href=&quot;https://github.com/shigeodayo/Javarduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Javarduino&lt;/a&gt; project seems abandoned. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I guess the standard way is to use the &lt;a href=&quot;https://github.com/4ntoine/Firmata&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;4ntoine&quot;&lt;/a&gt; Java client library. Or are there other options?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am not interested in Processing or Javascript.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Question: Where do I find up-to-date documentation and example code on using Firmata client libraries for Java?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4728" LastEditorUserId="4628" LastEditDate="2017-11-27T11:51:00.383" LastActivityDate="2018-06-25T17:22:07.907" Title="Example code and documentation on using Firmata communication in native Java" Tags="|serial|library|communication|firmata|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5224" PostTypeId="2" ParentId="5222" CreationDate="2014-11-28T01:11:43.197" Score="3" Body="&lt;p&gt;Your include statement seems to be incomplete; add &quot;Servo.h&quot; to your include to make it look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Servo.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without including &quot;Servo.h&quot;, the compiler doesn't know what a servo is, and thus &quot;Servo does not name a type&quot;.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-11-28T01:11:43.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5227" PostTypeId="2" ParentId="5102" CreationDate="2014-11-28T08:02:10.447" Score="3" Body="&lt;p&gt;Instead of a multiplexer you can use a &quot;shift register&quot;; the difference is that it keep the last state of the pin, while the multiplexer goes unconnected (and this is because you need at least 30fps, and even so you'll get low light as you are PWMing the leds).&#xA;This is why shift register are also called &quot;led driver&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Official tutorial can be found here &lt;a href=&quot;http://arduino.cc/en/Tutorial/LEDDriver&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/LEDDriver&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2014-11-28T08:02:10.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5228" PostTypeId="1" AcceptedAnswerId="5229" CreationDate="2014-11-28T08:25:29.243" Score="1" ViewCount="8404" Body="&lt;p&gt;I connect Arduino Yun to my Computer with WiFi. I was able to get the IP address of my Arduino Yun. However, when I try to print something. It seems to not work at all. The following code is the one that I try:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA; Serial.begin(9600);       &#xA;}&#xA;&#xA;void loop() {  &#xA; // print labels &#xA; Serial.print(&quot;NO FORMAT&quot;);  &#xA; delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did not get any kind of error. However, when I open the Serial Monitor, it shows nothing at all. I try to use the same code with Arduino Uno. It works fine. &lt;/p&gt;&#xA;" OwnerUserId="4973" LastEditorUserId="26916" LastEditDate="2017-11-04T06:21:01.350" LastActivityDate="2017-11-04T06:21:01.350" Title="Cannot communicate with Serial Monitor - Arduino Yun" Tags="|serial|arduino-yun|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5229" PostTypeId="2" ParentId="5228" CreationDate="2014-11-28T09:35:52.093" Score="3" Body="&lt;p&gt;When using the Yun over wifi, you cannot user Serial, you need to use Bridge &lt;a href=&quot;http://arduino.cc/en/Reference/YunConsoleConstructor&quot; rel=&quot;nofollow&quot;&gt;Console&lt;/a&gt; object. Serial is bound to the usb cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give a spin to &lt;a href=&quot;http://arduino.cc/en/Tutorial/ConsoleRead&quot; rel=&quot;nofollow&quot;&gt;ConsoleRead&lt;/a&gt; example.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-11-28T09:35:52.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5231" PostTypeId="1" CreationDate="2014-11-28T10:01:51.623" Score="1" ViewCount="360" Body="&lt;p&gt;I am using an ArduinoFio and a BC127 (&lt;a href=&quot;http://bluecreation.com/userfiles/DataSheet-BC127-latest4.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;). I'm having troubles getting the serial connection working properly from the Arduino to the BC127 and viceversa. I wasn't able to communicate with the BC127 and I don't know if is because isn't correctly powered on or something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I've connected pin 0 of the BC127 to GND, pin 33 to 3V3 and pin 41,42 (RX, TX) to the TX, RX arduino's pins.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested with the tester that all wires are connected, but the BC127 seems dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated :|&lt;/p&gt;&#xA;" OwnerUserId="5013" LastActivityDate="2017-01-24T12:50:23.113" Title="Arduino Fio and BC127 communication" Tags="|power|pins|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5232" PostTypeId="2" ParentId="5199" CreationDate="2014-11-28T14:40:13.307" Score="0" Body="&lt;pre&gt;&lt;code&gt;lcd.write(waitTime);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line prints a single byte, whose (ASCII) value is the number in waitTime. You probably should write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(waitTime);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead, which prints the number in waitTime using one ore more digits as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't 100% explain the &quot;both digits end up in the same place&quot; symptom, since I'd expect random junk to be printed instead. But I'm pretty certain this is a problem, perhaps there's more problems :-)&lt;/p&gt;&#xA;" OwnerUserId="5018" LastActivityDate="2014-11-28T14:40:13.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5233" PostTypeId="2" ParentId="5231" CreationDate="2014-11-28T14:49:03.397" Score="1" Body="&lt;p&gt;There's a couple of things I would try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First: Don't use the native Arduino TX/RX pins, they should be left alone to talk to the computer. Use &lt;a href=&quot;http://arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; instead in start a separate serial connection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second: Check that Arduino TX pin (that you declared in softwareSerial) is connected to the BC127 RX and vice versa. Unlike just about every other connection in electronics, serial connections need to have their pins reversed so that TX talks to RX. It's an easy mistake to make and one I've made when not paying attention to what I was doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third: &lt;a href=&quot;http://www.moxa.com/resource_file/509820091121333.pdf&quot; rel=&quot;nofollow&quot;&gt;Flow control&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the BC127 sends data when the Arduino isn't listening the data could be lost, to prevent this the BC127 won't send until the Arduino signals it is ready through flow control.&#xA;See the BC127 datasheet page 8, pins 40 and 43. Trying tying UART_CTS to 3V3 and UART_RTS to Ground. That should cause the BC127 to be in a constant 'send' state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly I'd hook up a couple of LEDs to pins 37 and 38. They should give you some sort of status indication that could be useful in debugging future problems.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastEditorUserId="4385" LastEditDate="2014-11-29T14:26:41.757" LastActivityDate="2014-11-29T14:26:41.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5234" PostTypeId="1" CreationDate="2014-11-28T19:01:33.780" Score="0" ViewCount="226" Body="&lt;p&gt;I am trying to send and receive data from a PIC16F88 to an Arduino Uno. My problem is that the serial communication stops when the Arduino is not connected to the USB cable. For my application I need the Arduino to still perform its operations with a battery. I have tried both software and hardware serial. Is it possible for the Arduino to send/recieve data when not plugged into the USB cable? &lt;/p&gt;&#xA;" OwnerUserId="5021" LastActivityDate="2016-01-29T10:17:52.727" Title="Arduino UNO serial send and receive issue" Tags="|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5236" PostTypeId="1" CreationDate="2014-11-28T10:28:11.813" Score="1" ViewCount="246" Body="&lt;p&gt;I would like to know how I can identify a fake or counterfeit Arduino board.  For example &lt;a href=&quot;https://www.techshopbd.com/product-categories/boards/1253/arduino-uno-r3-china-techshop-bangladesh&quot; rel=&quot;nofollow noreferrer&quot;&gt;this product&lt;/a&gt;, which is shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/euLjh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am concerned that it is cheap (about $12 when converted) and I was wondering if it is like a 'legal cheap version' or is it an unauthentic one?  If it is not authentic, would it be legal to purchase it?&lt;/p&gt;&#xA;" OwnerUserId="5025" OwnerDisplayName="user6837" LastEditorUserId="42" LastEditDate="2015-04-10T16:28:10.750" LastActivityDate="2015-04-10T16:28:10.750" Title="Identifying a counterfeit or authentic Arduino" Tags="|counterfeit|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5237" PostTypeId="2" ParentId="5236" CreationDate="2014-11-28T10:41:23.363" Score="7" Body="&lt;p&gt;It looks like an R3 Uno, but then pictures can be misleading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino is open source - anyone can make one&lt;/li&gt;&#xA;&lt;li&gt;Because of that there are many many &quot;clones&quot; of the Arduino&lt;/li&gt;&#xA;&lt;li&gt;A clone, as long as it's got the right circuitry (and an Arduino is incredibly simple) is as good as the &quot;real thing&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The only problem Arduino have with clones is the use of the Arduino name and logo.  IIRC they don't mind you claiming &quot;Arduino Compatible&quot;, but trying to &lt;em&gt;be&lt;/em&gt; an Arduino they don't much like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's just their reference designs re-printed (which you can download for free from the Arduino Uno web page) and no further design work has been done, then although it isn't made in Italy by Arduino, it's still an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the beauty / curse of open source - anyone can make one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that specific one looks like it fits into the &quot;claiming to be an Arduino&quot; category.  It uses Arduino artwork and logos, and tries to make it look like it's an Arduino made by Arduino in Italy, when in fact it isn't.  Legally speaking, they are ripping off the Arduino brand.  Practically speaking, since it's all open source, the actual device (assuming the components aren't counterfeit) should be perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they were to change the artwork, so it didn't look quite so much like an Arduino, and had something like &quot;Arduino Uno Compatible&quot; on it, then it would be categorized as a clone, and would be fine - you'd know where you were standing.  As it is though, the artwork on it is breaking copyright laws.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The image shown is too low quality to give much information about it, but the two big pointers that it's not made by Arduino are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The PCB is too blue (real Arduinos are teal)&lt;/li&gt;&#xA;&lt;li&gt;The polyfuse is the wrong colour (green instead of grey/gold)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-11-28T14:16:01.923" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5238" PostTypeId="2" ParentId="5236" CreationDate="2014-11-28T11:12:35.243" Score="2" Body="&lt;p&gt;No, it's a counterfeit. See here - particularly the 'components' section:&lt;br&gt;&#xA;&lt;a href=&quot;http://arduino.cc/en/Products/Counterfeit&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Products/Counterfeit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as far as I'm aware, Arduino boards are not produced in China but in Italy.&lt;/p&gt;&#xA;" OwnerUserId="1307" OwnerDisplayName="RJR" LastActivityDate="2014-11-28T11:12:35.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5239" PostTypeId="1" CreationDate="2014-11-28T20:32:15.850" Score="2" ViewCount="1113" Body="&lt;p&gt;I try to test Grove - Infrared Temperature Sensor on Arduino Yun with the sample code but it does not work. In the console it shows that the object temperature is out of range all the time. However, when I try to test it on Arduino Uno, it works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;#include&amp;lt;Console.h&amp;gt;&#xA;//#include &amp;lt;NewSoftSerial.h&amp;gt;       //if display in LCD(seeed serial LCD driver)&#xA;//#include &amp;lt;SerialLCD.h&amp;gt;           //if display in LCD(seeed serial LCD driver)&#xA;//#include &quot;temp.h&quot;&#xA;&#xA;const int temp_analog_in = A0;  // Analog input pin connect to temperature sensor SUR pin&#xA;const int objt_analog_in = A1;  // Analog input pin connect to temperature sensor OBJ pin&#xA;float temp_calibration = 0;     //this parameter was used to calibrate the temperature&#xA;//float objt_calibration=0.000; //this parameter was used to calibrate the object temperature&#xA;float temperature_range = 10;  //we make a map of temperature-voltage according to sensor datasheet. 10 is the temperature step when sensor and&#xA;//object distance is 9CM.&#xA;float offset_vol = 0.014;      //this parameter was used to set the mid level voltage,when put the sensor in normal environment after 10 min,&#xA;//the sensor output 0.For example,the surrounding temperature is 29℃，but the result is 27℃ via the sensor,&#xA;//you should set the reerence to 0.520 or more,according to your sensor to change.&#xA;//the unit is V&#xA;&#xA;//SerialLCD slcd(11,12);&#xA;float tempValue = 0;&#xA;float objtValue = 0;&#xA;float current_temp = 0;&#xA;float temp = 0;&#xA;float temp1 = 0;&#xA;float temp2 = 0;&#xA;unsigned int temp3 = 0;&#xA;const float reference_vol = 0.500;&#xA;unsigned char clear_num = 0; //when use lcd to display&#xA;float R = 0;&#xA;float voltage = 0;&#xA;&#xA;&#xA;long res[100] = {&#xA;  318300, 302903, 288329, 274533, 261471, 249100, 237381, 226276, 215750, 205768,&#xA;  196300, 187316, 178788, 170691, 163002, 155700, 148766, 142183, 135936, 130012,&#xA;  124400, 119038, 113928, 109059, 104420, 100000, 95788, 91775, 87950, 84305,&#xA;  80830, 77517, 74357, 71342, 68466, 65720, 63098, 60595, 58202, 55916,&#xA;  53730, 51645, 49652, 47746, 45924, 44180, 42511, 40912, 39380, 37910,&#xA;  36500, 35155, 33866, 32631, 31446, 30311, 29222, 28177, 27175, 26213,&#xA;  25290, 24403, 23554, 22738, 21955, 21202, 20479, 19783, 19115, 18472,&#xA;  17260, 16688, 16138, 15608, 15098, 14608, 14135, 13680, 13242, 12819,&#xA;  12412, 12020, 11642, 11278, 10926, 10587, 10260, 9945, 9641, 9347,&#xA;  9063, 8789, 8525, 8270, 8023, 7785, 7555, 7333, 7118, 6911&#xA;};&#xA;&#xA;float obj [13][12] = {&#xA;  /*0*/             { 0, -0.274, -0.58, -0.922, -1.301, -1.721, -2.183, -2.691, -3.247, -3.854, -4.516, -5.236}, //&#xA;  /*1*/             { 0.271, 0, -0.303, -0.642, -1.018, -1.434, -1.894, -2.398, -2.951, -3.556, -4.215, -4.931}, //→surrounding temperature,from -10,0,10,...100&#xA;  /*2*/             { 0.567, 0.3, 0, -0.335, -0.708, -1.121, -1.577, -2.078, -2.628, -3.229, -3.884, -4.597}, //↓object temperature,from -10,0,10,...110&#xA;  /*3*/             { 0.891, 0.628, 0.331, 0, -0.369, -0.778, -1.23, -1.728, -2.274, -2.871, -3.523, -4.232},&#xA;  /*4*/             { 1.244, 0.985, 0.692, 0.365, 0, -0.405, -0.853, -1.347, -1.889, -2.482, -3.13, -3.835},&#xA;  /*5*/             { 1.628, 1.372, 1.084, 0.761, 0.401, 0, -0.444, -0.933, -1.47, -2.059, -2.702, -3.403},&#xA;  /*6*/             { 2.043, 1.792, 1.509, 1.191, 0.835, 0.439, 0, -0.484, -1.017, -1.601, -2.24, -2.936},&#xA;  /*7*/             { 2.491, 2.246, 1.968, 1.655, 1.304, 0.913, 0.479, 0, -0.528, -1.107, -1.74, -2.431},&#xA;  /*8*/             { 2.975, 2.735, 2.462, 2.155, 1.809, 1.424, 0.996, 0.522, 0, -0.573, -1.201, -1.887},&#xA;  /*9*/             { 3.495, 3.261, 2.994, 2.692, 2.353, 1.974, 1.552, 1.084, 0.568, 0, -0.622, -1.301},&#xA;  /*10*/            { 4.053, 3.825, 3.565, 3.27, 2.937, 2.564, 2.148, 1.687, 1.177, 0.616, 0, -0.673},&#xA;  /*11*/            { 4.651, 4.43, 4.177, 3.888, 3.562, 3.196, 2.787, 2.332, 1.829, 1.275, 0.666, 0},&#xA;  /*12*/            { 5.29, 5.076, 4.83, 4.549, 4.231, 3.872, 3.47, 3.023, 2.527, 1.98, 1.379, 0.72}&#xA;};&#xA;&#xA;float binsearch(long x)// this function used for measure the surrounding temperature&#xA;{&#xA;  int low, mid, high;&#xA;  low = 0;&#xA;  //mid=0;&#xA;  high = 100;&#xA;  while (low &amp;lt;= high)&#xA;  {&#xA;    mid = (low + high) / 2;&#xA;    if (x &amp;lt; res[mid])&#xA;      low = mid + 1;&#xA;    else//(x&amp;gt;res[mid])&#xA;      high = mid - 1;&#xA;  }&#xA;  return mid;&#xA;}&#xA;&#xA;float arraysearch(float x, float y) //x is the surrounding temperature,y is the object temperature&#xA;{&#xA;  int i = 0;&#xA;  float tem_coefficient = 100;&#xA;  i = (x / 10) + 1;&#xA;  voltage = (float)y / tem_coefficient;&#xA;  //Serial.print(&quot;sensor voltage:\t&quot;);&#xA;  //Serial.print(voltage,5);&#xA;  //Serial.print(&quot;V&quot;);&#xA;  for (temp3 = 0; temp3 &amp;lt; 13; temp3++)&#xA;  {&#xA;    if ((voltage &amp;gt; obj[temp3][i]) &amp;amp;&amp;amp; (voltage &amp;lt; obj[temp3 + 1][i]))&#xA;    {&#xA;      return temp3;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;float temp_measure()&#xA;{&#xA;  unsigned char i = 0;&#xA;  float current_temp1 = 0;&#xA;  int signal = 0;&#xA;  tempValue = 0;&#xA;&#xA;  for (i = 0; i &amp;lt; 10; i++) //&#xA;  {&#xA;    tempValue += analogRead(temp_analog_in);&#xA;    delay(10);&#xA;  }&#xA;  tempValue = tempValue / 10;&#xA;  temp = tempValue * 1.1 / 1023;&#xA;  R = 2000000 * temp / (2.50 - temp);&#xA;  signal = binsearch(R);&#xA;  current_temp = signal - 1 + temp_calibration + (res[signal - 1] - R) / (res[signal - 1] - res[signal]);&#xA;  //current_temp1=current_temp;&#xA;  //slcd.setCursor(0,1);&#xA;  //slcd.print(&quot;sur T:&quot;);&#xA;  //slcd.print((int)current_temp1,DEC);&#xA;  Console.print(&quot;Surrounding temperature:&quot;);&#xA;  Console.print(current_temp);&#xA;  return current_temp;&#xA;}&#xA;&#xA;float objt_measure()&#xA;{&#xA;  unsigned char i = 0;&#xA;  unsigned char j = 0;&#xA;  float sur_temp = 0;&#xA;  unsigned int array_temp = 0;&#xA;  float temp1, temp2;&#xA;  float final_temp = 0;&#xA;  objtValue = 0;&#xA;  for (i = 0; i &amp;lt; 10; i++)&#xA;  {&#xA;    objtValue += analogRead(objt_analog_in);&#xA;    delay(10);&#xA;  }&#xA;  objtValue = objtValue / 10;&#xA;  temp1 = objtValue * 1.1 / 1023; //+objt_calibration;&#xA;  sur_temp = temp1 - (reference_vol + offset_vol);&#xA;  Console.print(&quot;\t Sensor voltage:&quot;);&#xA;  Console.print(sur_temp, 3);&#xA;  Console.print(&quot;V&quot;);&#xA;  //slcd.setCursor(11,1);&#xA;  //slcd.print((int)(temp1*10000),DEC);&#xA;  array_temp = arraysearch(current_temp, sur_temp * 1000);&#xA;  temp2 = current_temp;&#xA;  temp1 = (temperature_range * voltage) / (obj[array_temp + 1][(int)(temp2 / 10) + 1] - obj[array_temp][(int)(temp2 / 10) + 1]);&#xA;  final_temp = temp2 + temp1;&#xA;  if ((final_temp &amp;gt; 100) || (final_temp &amp;lt;= -10))&#xA;  {&#xA;    Console.println (&quot;\t out of range!&quot;);&#xA;  }&#xA;  else&#xA;  {&#xA;    Console.print(&quot;\t object temperature:&quot;);&#xA;    Console.println(final_temp, 2);&#xA;    //Serial.println(&quot;℃&quot;);&#xA;  }&#xA;  ////////////////////////////////////////////////////&#xA;  //The fllowing code is used for display by serialLCD&#xA;  /*&#xA;    slcd.setCursor(0,0);&#xA;    slcd.print(&quot;obj T:&quot;);&#xA;    if((final_temp&amp;gt;=0)&amp;amp;&amp;amp;(final_temp&amp;lt;=100))&#xA;    {&#xA;      slcd.print(final_temp,DEC);&#xA;    }&#xA;    else if((final_temp&amp;lt;0)&amp;amp;&amp;amp;(final_temp&amp;gt;=-10))&#xA;    {&#xA;      slcd.setCursor(10,0);&#xA;      slcd.print('-');&#xA;      slcd.print(abs(final_temp),DEC);&#xA;    }&#xA;    else&#xA;      {&#xA;        slcd.setCursor(5,0);&#xA;        slcd.print(&quot;out of range&quot;);&#xA;        }*/&#xA;  //////////////////////////////////////////&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Bridge.begin();&#xA;  Console.begin();&#xA;  while (!Console);&#xA;  Console.println(&quot;Hi, what's your name?&quot;);// initialize serial communications at 9600 bps:&#xA;  //slcd.begin();//Add while using LCD to display&#xA;  //slcd.backlight();//Turn on the backlight of LCD while using LCD to display&#xA;  analogReference(INTERNAL);//set the refenrence voltage 1.1V,the distinguishability can up to 1mV.&#xA;  //analogReference(INTERNAL1V1);//(mega only)set the refenrence voltage 1.1V,the distinguishability can up to 1mV.&#xA;}&#xA;//If use LCD to display, adding below code to clear the screen in time&#xA;void loop()&#xA;{&#xA;  temp_measure();&#xA;  objt_measure();&#xA;&#xA;  /*&#xA;    if(clear_num==10)&#xA;      {&#xA;        slcd.clear();&#xA;        clear_num=0;&#xA;        }&#xA;    else&#xA;      clear_num++;&#xA;  */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am sure that I connected the wires properly. The exact same wiring configuration is used with Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="4973" LastEditorUserId="26916" LastEditDate="2017-11-04T06:30:07.043" LastActivityDate="2017-11-04T06:30:07.043" Title="Grove temperature sensor with Arduino Yun" Tags="|arduino-uno|sensors|arduino-yun|temperature-sensor|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5240" PostTypeId="1" AcceptedAnswerId="5244" CreationDate="2014-11-28T20:49:30.183" Score="2" ViewCount="2755" Body="&lt;p&gt;I downloaded a Library called &quot;Morse&quot; which I got from the Arduino website:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(all the way at the bottom of the page there is a link called Morse.zip)&#xA;And basically added the library. Then when I import the library, it is included to the sketch. However when I try verifying it, the following error message appears:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FnDKq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;to see the image clearer you can right click it and click on &quot;Open image in new tab&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In file included from sketch_nov28a.ino:1:&#xA;C:\Users\Marko\Documents\Arduino\libraries\Morse/Morse.h:10:22: error: WProgram.h: No such file or directory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I tried reinstalling the Arduino IDE, I tried adding the library again as well as using the manual method that was stated in that first link above, and the error persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did notice was that in that second line of the error message, something caught my eye: &quot;...\Morse/Morse.h:10:22:...&quot;&#xA;There is a forward slash!(/) Now it seems weird to me that with would happen, especially given that all the other examples I saw of this error online have a backslash (\). This could be the problem.... but even if it is, how do I fix it? I tried going to preferences... does anyone know?&lt;/p&gt;&#xA;" OwnerUserId="5009" LastActivityDate="2016-04-18T07:21:30.613" Title="Issue with adding a library: No such file or directory" Tags="|library|ide|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5241" PostTypeId="2" ParentId="5219" CreationDate="2014-11-28T21:56:59.733" Score="1" Body="&lt;p&gt;Is this too clunky?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/products/735&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/735&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breadboard Friendly 8-bit Logic Level Shifter, $1.50.&lt;/p&gt;&#xA;" OwnerUserId="6" LastActivityDate="2014-11-28T21:56:59.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5242" PostTypeId="1" AcceptedAnswerId="5310" CreationDate="2014-11-29T08:48:24.317" Score="0" ViewCount="2707" Body="&lt;p&gt;I've stumbled upon what I've later found it's quite common error, but there seems not to be simple troubleshooting way and solution (people often try various things, sometimes they succeed, sometimes not).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;a href=&quot;http://www.dawnrobotics.co.uk/dagu-arduino-mini-driver-board/&quot; rel=&quot;nofollow&quot;&gt;DAGU mini driver&lt;/a&gt;, I was able to load sketch as described &lt;a href=&quot;http://blog.dawnrobotics.co.uk/2013/11/getting-started-with-the-dagu-arduino-mini-driver-board/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; - chose Arduino NG ATMega8 as board, connect to my PC via USB (with the driver listed on the &lt;a href=&quot;http://www.dawnrobotics.co.uk/dagu-arduino-mini-driver-board/&quot; rel=&quot;nofollow&quot;&gt;product page&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later on I've plugged RedBot wheel encoders sensor and write some simplistic program to check whether it works at all. I've summarized the steps in a github &lt;a href=&quot;https://github.com/BartAdv/rowboat/issues/1&quot; rel=&quot;nofollow&quot;&gt;issue&lt;/a&gt;, so that it's easy to reference it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried to upload the sketch I've receiced &lt;code&gt;stk500_initialize(): (a) protocol error, expect=0x14, resp=0x42&lt;/code&gt;, &lt;code&gt;stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41&lt;/code&gt;. The full log is included in comment on that github issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The D13 diode is making series of 3-blink bursts - 8 bursts after start. More diagnostic I did in the github issue as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question (apart from obvious 'how to fix it!?!' ;) ) is whether there is some kind of documentation for this protocol? On the various topics I've found people seem to have somewhat different problems (the numbers and messages were different). I just want to know why the first few messages are exchanged OK (avrdude receives some basic info from the chip), but later ones (namely &lt;code&gt;Send: A [41] . [81]   [20]&lt;/code&gt;) are producing protocol errors.&lt;/p&gt;&#xA;" OwnerUserId="5007" LastEditorUserId="5007" LastEditDate="2014-11-29T12:16:20.123" LastActivityDate="2014-12-03T19:43:13.193" Title="Unable to load sketch: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41" Tags="|uploading|bootloader|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5243" PostTypeId="1" AcceptedAnswerId="5245" CreationDate="2014-11-29T14:53:14.670" Score="0" ViewCount="1970" Body="&lt;p&gt;I am trying to send data from my Arduino to my database but it seems that the process is not successfully beginning. Here is my code for Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Process.h&amp;gt;&#xA;#include &amp;lt;Bridge.h&amp;gt;&#xA;int temperature;&#xA;void setup() {&#xA;  Bridge.begin();  // Initialize Bridge&#xA;}&#xA;void loop() {&#xA;  int temperature = random(0, 100);&#xA;  Process p;               &#xA;  p.begin(&quot;143.248.181.36/db.php&quot;);// 143.248.181.36 address of localhost.&#xA;  p.addParameter(String(temperature));&#xA;  p.run();&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using xampp and I put db.php inside the htcocs folder. Can anyone point out why it does not work?&lt;/p&gt;&#xA;" OwnerUserId="4973" LastEditorUserId="4973" LastEditDate="2014-12-11T11:28:03.463" LastActivityDate="2014-12-11T11:28:03.463" Title="How to make Arduino communicate with MySQL?" Tags="|programming|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5244" PostTypeId="2" ParentId="5240" CreationDate="2014-11-29T15:54:30.677" Score="1" Body="&lt;p&gt;That library is for the older version of the Arduino ide. To fix this you need to open &lt;code&gt;Morse.h&lt;/code&gt; and change &lt;code&gt;WProgram.h&lt;/code&gt; to &lt;code&gt;Arduino.h&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-11-29T15:54:30.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5245" PostTypeId="2" ParentId="5243" CreationDate="2014-11-29T19:41:07.660" Score="1" Body="&lt;p&gt;I'm not familiar with those libraries, but a quick look gives me the impression that Bridge and Process are used together to make system calls over serial connection on the host system. Based on that..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, looking at &lt;a href=&quot;http://arduino.cc/en/Tutorial/Process&quot; rel=&quot;nofollow&quot;&gt;Arduino Process Tutorial&lt;/a&gt; Process.begin() should call the process that you want to call. Maybe something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p.begin(&quot;curl&quot;); // Assuming you have curl installed on your host system&#xA;p.addParameter(&quot;http://143.248.181.36/db.php?temperature=SOMEVALUE&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, your PHP script is broken. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/ check connection&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;^ That comment is missing a second slash /&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should definitely get the PHP/MySQL part working standalone before attempting to integrate Arduino in the process. I'm a bit doubtful that $argv gets populated unless you're running the script from command line. If you're making a GET HTTP request (as you would with curl) you might wanna try instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$temperature = $_GET['temperature'];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the above works as a workaround, you should get an entry into your MySQL table if you visit the URL below with your browser. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;http://143.248.181.36/db.php?temperature=100&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In any case, get the PHP script working first in your browser. One step at a time.&lt;/p&gt;&#xA;" OwnerUserId="5027" LastActivityDate="2014-11-29T19:41:07.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5246" PostTypeId="1" AcceptedAnswerId="5247" CreationDate="2014-11-29T22:18:21.047" Score="7" ViewCount="1617" Body="&lt;p&gt;I am using an Arduino Uno R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not clear on the schematic whether there are pullups on the A4 and A5 I2C pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there hardwired pullups or do I have to add them myself?&lt;/p&gt;&#xA;" OwnerUserId="4594" LastEditorUserId="4628" LastEditDate="2014-11-30T15:29:49.310" LastActivityDate="2014-11-30T15:29:49.310" Title="Is there a pullup on I2C?" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5247" PostTypeId="2" ParentId="5246" CreationDate="2014-11-29T22:21:15.387" Score="5" Body="&lt;p&gt;There are very weak internal pullups, but they are &lt;a href=&quot;https://electronics.stackexchange.com/questions/102611/what-happens-if-i-omit-the-pullup-resistors-on-i2c-lines&quot;&gt;not strong enough&lt;/a&gt; to be considered compliant with I&lt;sup&gt;2&lt;/sup&gt;C specs. Supply your own external 2.2k-10kohm pullup resistors.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-11-29T22:21:15.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5249" PostTypeId="1" AcceptedAnswerId="5284" CreationDate="2014-11-30T04:22:06.570" Score="0" ViewCount="279" Body="&lt;p&gt;I have a USB 2 Serial adapter and the device is working fine. I see the device perfectly configured in my System.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected the TX0 pin of Arduino to DB 2 pin (read pin) of the adapter. Below is my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i = 0;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for(i=0;i&amp;lt;6;i++)&#xA;  {&#xA;  Serial.write('H');&#xA;  delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to read thru terminal software of data received at my COM port I see some junk character incoming. I am pretty sure that I am using same baud rate / flow setting both side. Why am I facing this issue - do I need to connect any other pins also as I just need to receive data at system side?&lt;/p&gt;&#xA;" OwnerUserId="4655" LastActivityDate="2014-12-02T18:04:53.167" Title="Serial Communication over Desktop to Arduino" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5251" PostTypeId="1" AcceptedAnswerId="5254" CreationDate="2014-11-30T05:40:51.367" Score="0" ViewCount="962" Body="&lt;p&gt;Can I use an Arduino Uno-style Shield with the Arduino Mega, Tre, or Zero? How about the Intel Edison?&lt;/p&gt;&#xA;" OwnerUserId="5031" LastEditorUserId="5031" LastEditDate="2014-12-02T04:35:24.543" LastActivityDate="2014-12-02T04:35:24.543" Title="Can I use an Arduino Uno-style Shield with the Arduino Mega, Tre, or Zero? How about the Intel Edison?" Tags="|arduino-galileo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5253" PostTypeId="1" AcceptedAnswerId="5256" CreationDate="2014-11-30T09:25:15.087" Score="3" ViewCount="1679" Body="&lt;p&gt;I'm looking to achieve the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USB HID Mouse (or Keyboard) -&amp;gt; [ Arduino device ] -&amp;gt; PC&#xA;                                       |&#xA;                                        `-&amp;gt; Internet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to connect a keyboard or mouse to an Arduino device, do some processing, send some data over the internet and then pass-through the USB data to the PC as if the Arduino wasn't even there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is twofold: what hardware should I use? Right now I'm looking at the following peripherals:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11224&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno R3 SMD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9026&quot; rel=&quot;nofollow&quot;&gt;Arduino Ethernet Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9947&quot; rel=&quot;nofollow&quot;&gt;SparkFun USB Host Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since I'm a complete neophyte when it comes to Arduino, I wanted to double-check and make sure my parts will fit together as well as work towards my goal. I was also contemplating the Arduino Leonardo (since it seems to provide mouse/keyboard out-of-the-box without reflashing the firmware), but I'm not sure I understand what that decision might entail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which brings me to my second question: is this feasible software-wise? I found &lt;a href=&quot;http://hunt.net.nz/users/darran/blog/?tag=mouse&quot; rel=&quot;nofollow&quot;&gt;this blog&lt;/a&gt; which has some information about pass-through connections, but the mouse library seems to be unfinished. I'd hate to invest 150+ dollars into a project that is doomed from the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="5035" LastActivityDate="2014-12-30T10:58:08.507" Title="USB mouse/keyboard passthrough feasible?" Tags="|ethernet|usb|arduino-uno-smd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5254" PostTypeId="2" ParentId="5251" CreationDate="2014-11-30T09:48:34.937" Score="1" Body="&lt;p&gt;Zero, Mega and Tre all have the same basic pinout layout as Uno, which provides at least physical compatibility for the pins. &lt;a href=&quot;https://www.sparkfun.com/products/13097&quot; rel=&quot;nofollow&quot;&gt;Sparkfun has a breakout board for the Intel Edison&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mini, Micro &amp;amp; Nano obviously have a different pin layout. I would consider them mainly for projects that have challenging space requirements, since their main advantage is their small size. The Micro should be the easiest to plug'n'play (native USB COM serial). Nano is still stuck with FTDI drivers, so it's going to require separate drivers from the Uno/Mega family. And finally Mini doesn't have USB at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe take a look at Wikipedia &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems&quot; rel=&quot;nofollow&quot;&gt;list of Arduino boards and compatible systems&lt;/a&gt; to evaluate better what suits your needs best.&lt;/p&gt;&#xA;" OwnerUserId="5027" LastActivityDate="2014-11-30T09:48:34.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5255" PostTypeId="2" ParentId="5246" CreationDate="2014-11-30T10:05:44.683" Score="0" Body="&lt;p&gt;No. There are potential internal pullups, but not AFIK activated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can quite safely connect I²C to Raspberry P1 (3.3V).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-11-30T10:05:44.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5256" PostTypeId="2" ParentId="5253" CreationDate="2014-11-30T10:15:33.240" Score="2" Body="&lt;p&gt;To connect an external USB device to AVR you need &lt;strong&gt;USB Host&lt;/strong&gt; supported on AVR side. Overhelming majority of AVR chips supports &lt;strong&gt;USB device only&lt;/strong&gt;. There is e.g. AT90USB1287 chip exception. It even exists an &lt;strong&gt;AVR USB Key 2&lt;/strong&gt; device which can be used instead of normal Arduino unless you want make own PCBs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino UNO Mouse HID&lt;/strong&gt; emulates USB mouse internally in Arduino. Implementing is easy when you have USB device AVR chip using LUFA library. But it's not case using external mouse. On the other side you can use legacy serial mouse or PS/2 keyboard as workaround.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-11-30T10:15:33.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5257" PostTypeId="1" CreationDate="2014-11-30T11:31:54.290" Score="0" ViewCount="929" Body="&lt;p&gt;I have to use multiple timers (for example, to blink different LEDs) with different frequency (for example, 7.3 Hz). Cannot you tell me, what is the preferred way to implement it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just now I use one simple TimerOne timer and just check what LEDs should be inverted and what are not, but I don't think it's a good idea.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;#define PIN_RED 52&#xA;#define PIN_GREEN 50&#xA;#define PIN_BLUE 48&#xA;#define PIN_YELLOW 46&#xA;&#xA;#define N_LEDS 4&#xA;&#xA;float freqs[N_LEDS] = {1, 2, 3, 4};&#xA;int pins[N_LEDS] = {PIN_RED, PIN_GREEN, PIN_BLUE, PIN_YELLOW};&#xA;&#xA;long int usec_to_invert[N_LEDS];&#xA;long int full_usec_to_invert[N_LEDS];&#xA;&#xA;boolean led_states[N_LEDS];&#xA;&#xA;int who_is_next()&#xA;{&#xA;  int next_to_invert = 0;&#xA;  for(int i = 0; i &amp;lt; N_LEDS; i++)&#xA;  {&#xA;    if(usec_to_invert[i] &amp;lt; usec_to_invert[next_to_invert])&#xA;    {&#xA;      next_to_invert = i;&#xA;    }&#xA;  }&#xA;  return next_to_invert;&#xA;}&#xA;&#xA;void process_timer()&#xA;{&#xA;  int to_invert_now = who_is_next(); // Смотрим, кого надо инвертировать на этот раз&#xA;  long int time_past = usec_to_invert[to_invert_now];&#xA;&#xA;  for(int i = 0; i &amp;lt; N_LEDS; i++)&#xA;  {&#xA;    usec_to_invert[i] -= time_past;&#xA;  }&#xA;  led_states[to_invert_now] = !led_states[to_invert_now];&#xA;  digitalWrite(pins[to_invert_now], led_states[to_invert_now]);&#xA;  usec_to_invert[to_invert_now] = full_usec_to_invert[to_invert_now];&#xA;&#xA;&#xA;  int next_to_invert = who_is_next();&#xA;  long int time_to_pass = usec_to_invert[next_to_invert];&#xA;  if(time_to_pass &amp;lt;= 200)&#xA;  {  // The interrupt processor should finish work&#xA;    Timer1.setPeriod(200);&#xA;  }&#xA;  else&#xA;  {&#xA;    Timer1.setPeriod(time_to_pass);&#xA;  }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  for(int i = 0; i &amp;lt; N_LEDS; i++)&#xA;  {&#xA;    pinMode(pins[i], OUTPUT);&#xA;    led_states[i] = false;&#xA;    full_usec_to_invert[i] = (long int)(1000000. / freqs[i] / 2.);&#xA;    usec_to_invert[i] = full_usec_to_invert[i];&#xA;  }&#xA;&#xA;  int next_to_invert = who_is_next();&#xA;  Timer1.initialize(usec_to_invert[next_to_invert]);&#xA;  Timer1.attachInterrupt(process_timer);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5036" LastEditorUserId="37" LastEditDate="2014-11-30T14:11:12.583" LastActivityDate="2015-02-01T18:24:12.333" Title="Multiple timers with different frequencies" Tags="|programming|timers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5258" PostTypeId="1" AcceptedAnswerId="5261" CreationDate="2014-11-30T13:49:08.537" Score="0" ViewCount="280" Body="&lt;p&gt;My scheme is very basic: I use RGB LED with Arduino Uno. 5v is connected to anode, and pins 9-11 are connected to cathodes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using following sketch, my LED is producing white colour, which red, green and blue components are on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int redPin = 9;&#xA;int greenPin = 10;&#xA;int bluePin = 11;&#xA;&#xA;void setup(){}&#xA;&#xA;void loop(){&#xA;  analogWrite(redPin, 0);&#xA;  analogWrite(greenPin, 0);&#xA;  analogWrite(bluePin, 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I refer to &lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow&quot;&gt;docs&lt;/a&gt; for PWM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I write &lt;code&gt;0&lt;/code&gt; to all pins, I expect led to be off. What am I missing?&lt;/p&gt;&#xA;" OwnerDisplayName="Mighter" LastActivityDate="2014-12-03T06:26:42.920" Title="Arduino Uno PWM" Tags="|led|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5259" PostTypeId="2" ParentId="5258" CreationDate="2014-11-30T13:56:08.603" Score="1" Body="&lt;p&gt;Your LEDs are connected to the supply voltage. The output must be low to allow the LED to shine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Output 0 ==&amp;gt; LED on&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Kitana" LastActivityDate="2014-11-30T13:56:08.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5260" PostTypeId="2" ParentId="5258" CreationDate="2014-11-30T13:56:49.803" Score="4" Body="&lt;p&gt;Since you've connected to the cathodes the pins are &lt;em&gt;sinking&lt;/em&gt; current. As such the LEDS are active &lt;em&gt;low&lt;/em&gt; with 0 being almost fully on and 255 being fully off.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-11-30T13:56:49.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5261" PostTypeId="2" ParentId="5258" CreationDate="2014-11-30T14:05:16.893" Score="7" Body="&lt;p&gt;With your LEDs connected to +5V (AKA &quot;Common Anode&quot;), the PWM signal is reversed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When the output is &quot;on&quot;, the voltage on the pin is 5v.&lt;/li&gt;&#xA;&lt;li&gt;When the output is &quot;off&quot;, the voltage on the pin is 0V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The difference in voltage between +5V and the pin for those two different states is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&quot;On&quot; = 5V - 5V = 0V&lt;/li&gt;&#xA;&lt;li&gt;&quot;Off&quot; = 5V - 0V = 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you can see than when the output is off the LED will on because it causes a difference in voltage from one side of the LED to the other, so current can flow.  When the output is on the voltages either side of the LED are the same, so no current will flow.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-11-30T14:05:16.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5263" PostTypeId="1" CreationDate="2014-11-30T23:48:55.503" Score="2" ViewCount="542" Body="&lt;p&gt;I use official Arduino GSM Shield with Uno R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded web server examples from official GSM library. I use a simple python script to make TCP/IP connections to my GSM Shield web server. I send simple requests from my computer to shield, and it responses back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first, this worked like a charm. I even connected a led to arduino uno, and started turn it on and off. But after some time, I get timeout errors from my script. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I turned on debug mode of gsm shield. At first, it displayed normal stuff. When connection gone between my computer and shield, it doesn't showed anything on serial window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought there is something wrong with shield, but when I send a request from my computer; light of the shield indicates that there is a transmission incoming; but nothing shows on serial window. I think after some time, connection between arduino and gsm shield gets broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be done to make this web server more stable? I don't want it stop working after half an hour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Other than loop function, my code is same as web server example in the Arduino examples.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// I connected leds to D11 and D12 to see what happens during program.&#xA;void loop(){&#xA;  GSMClient client = server.available();&#xA;&#xA;  digitalWrite (11, HIGH);&#xA;&#xA;  if (client) {&#xA;    while (client.connected())&#xA;    {&#xA;      if (client.available())&#xA;      {&#xA;        char c = client.read();&#xA;&#xA;        // when it receives 1, D12 pin is high for 3 seconds.&#xA;        if (c == '1') {&#xA;          digitalWrite (12, HIGH);&#xA;          delay(1000);&#xA;          client.stop();&#xA;          delay(2000);&#xA;          digitalWrite (12, LOW);&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4196" LastEditorUserId="4196" LastEditDate="2014-12-02T12:15:41.667" LastActivityDate="2014-12-02T12:15:41.667" Title="Arduino GSM Shield web server hangs" Tags="|arduino-uno|serial|gsm|web-server|softwareserial|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5264" PostTypeId="1" CreationDate="2014-12-01T03:18:37.203" Score="2" ViewCount="456" Body="&lt;p&gt;I wrote a code to handle an ISR triggered by UART input. I'm looking for 2 characters or more. I can handle extra characters and garbage values, but problem arises when I get less than 2 chars, specially when an empty string is sent to the atmel. The UART_receive() on the atmel gets stuck at: &lt;code&gt;while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) );&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can break out of this? The code is posted below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char USART_Receive_string(unsigned char *x, unsigned char size)&#xA;{&#xA;unsigned char i = 0;&#xA;&#xA;if (size == 0) return 0;            // return 0 if no space&#xA;&#xA;while (i &amp;lt; size - 1) {              // check space is available (including additional null char at end)&#xA;    unsigned char c;&#xA;    while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) );  // wait for another char - WARNING this will wait forever if nothing is received&#xA;    c = UDR0;&#xA;    if (c == '\0') break;           // break on NULL character&#xA;    x[i] = c;                       // write into the supplied buffer&#xA;    i++;&#xA;}&#xA;x[i] = 0;                           // ensure string is null terminated&#xA;&#xA;return i + 1;                       // return number of characters written&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual ISR in question is posted below. It reads the value, sets a flag, and exits as soon as possible.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(USART_RX_vect)&#xA;{&#xA;    len = USART_Receive_string(uart_string,4); //makes space for 2 character and &quot;\0&quot; &#xA;    UART_flag = 1;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The the buffer is set up in main()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char uart_string[20];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastEditorUserId="3925" LastEditDate="2014-12-01T15:52:50.470" LastActivityDate="2015-05-01T09:51:16.987" Title="Atmega168 breaking out of ISR" Tags="|atmega328|uart|isr|atmel-studio|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="5266" PostTypeId="2" ParentId="5199" CreationDate="2014-12-01T10:04:25.007" Score="0" Body="&lt;p&gt;The problem was how I was reading the incoming serial data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After changing &lt;code&gt;int waitTime = Serial.read()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;int waitTime = Serial.parseInt()&lt;/code&gt;&#xA;the code works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thanks to everyone for all your help and tips!&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4986" LastActivityDate="2014-12-01T10:04:25.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5267" PostTypeId="1" CreationDate="2014-12-01T15:06:55.343" Score="2" ViewCount="122" Body="&lt;p&gt;Can I use an ultrasonic sensor, ir sensor, serial communication with MATLAB on computer and i2c communication with a D6T MEMS thermal sensor simultaneously in Arduino UNO ?&lt;/p&gt;&#xA;" OwnerUserId="5049" LastActivityDate="2014-12-01T18:56:23.097" Title="Arduino UNO R3 possibility" Tags="|arduino-uno|serial|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5268" PostTypeId="1" AcceptedAnswerId="5322" CreationDate="2014-12-01T15:47:19.443" Score="1" ViewCount="3844" Body="&lt;p&gt;I am making an RGB LED project right now using the Arduino UNO board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point everything is working fine so I would like to transfer this onto a small microcontroller circuit to be put inside the enclosure. Since the enclosure is small, I cannot fit the UNO board inside it, hence I want to make a small circuit on perfboard with minimal components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that you can burn the arduino bootloader on a standalone AVR (hooked up to power, filter caps and 16Mhz crystal) which can then execute Arduino code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how can I do this? Also can I do this on an ATmega8l AVR, since my code is small enough to fit in one? No point wasting a 328 if 8L can do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="5050" LastEditorUserId="4628" LastEditDate="2014-12-02T11:53:38.140" LastActivityDate="2015-06-11T13:48:28.287" Title="Burn Arduino Bootloader - Atmega8L" Tags="|bootloader|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5269" PostTypeId="2" ParentId="5268" CreationDate="2014-12-01T16:31:45.430" Score="0" Body="&lt;p&gt;You can program the 8u2 by either using a ISP programmer such as &lt;a href=&quot;https://www.sparkfun.com/products/9825&quot; rel=&quot;nofollow&quot;&gt;Pocket AVR Programmer&lt;/a&gt; or directly over USB using the FLIPS software as &lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;documented&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In reference to: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;hence I want to make a small circuit on perfboard with minimal&#xA;  components&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would recommend getting &lt;a href=&quot;https://www.sparkfun.com/products/11801&quot; rel=&quot;nofollow&quot;&gt;Tiny AVR Programmer&lt;/a&gt; or alike to program ATtiny's and at use the ATtiny's directly for small specific tasks. Hence you can avoid the cost of the whole UNO if not needed. You can even emulate limited USB connection as done with the &lt;a href=&quot;http://digistump.com/category/1&quot; rel=&quot;nofollow&quot;&gt;DigiSpark&lt;/a&gt;. They even support internal oscillator. So they often need now external parts. They can be often applied without PCB.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2014-12-02T13:09:13.180" LastActivityDate="2014-12-02T13:09:13.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5270" PostTypeId="2" ParentId="5267" CreationDate="2014-12-01T18:56:23.097" Score="1" Body="&lt;p&gt;Yes, it is possible for the arduino handle communicating over serial and I2C in real time, I've done it frequently. The IR sensor should not pose a problem either. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ultrasonic sensor might use a timed pulse to send its information that can take a relatively long time, and the basic ultrasound code will just wait for it to finish without doing anything else. The delay itself will not cause you problems but if a lot of data is being sent to the arduino very quickly over serial it might miss some. These delays can be worked around with interrupts/some clever coding but I doubt it will ever be a problem.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-12-01T18:56:23.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5271" PostTypeId="1" CreationDate="2014-12-01T18:57:37.370" Score="0" ViewCount="1047" Body="&lt;p&gt;I'm wondering if it's possible to flash the arduino sketch into a AVR, without using a bootloader - over ISP. I'd use the BSD programmer, which is basically parallel port with some resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I use the Arduino IDE, try to upload with &quot;verbose&quot; (no actual arduino is attached) - it shows path to the hex in the verbose output, and I &quot;steal&quot; the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'd flash it using avrdude onto a blank 328 via ISP - would that work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume there needs to be a 16Mhz crystal, is that it? Any other pitfalls I have to be careful about?&lt;/p&gt;&#xA;" OwnerUserId="5052" LastEditorUserId="5052" LastEditDate="2014-12-01T19:02:45.967" LastActivityDate="2015-01-30T20:55:59.950" Title="Flash &quot;sketch&quot; hex over ISP, without bootloader - possible?" Tags="|bootloader|avrdude|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5272" PostTypeId="2" ParentId="5271" CreationDate="2014-12-01T19:25:39.027" Score="1" Body="&lt;p&gt;You don't need the arduino bootloader on the chip, if you are programming it using ISP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like BSD is no longer supported by avrdude. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino 1.5 IDE you can add programmers, so you can do the uploading right from the IDE, instead of 'stealing' the hex file and manually uploading from the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the chips are blank you probably need to change the fuses first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need a 16mhz crystal. The atmega328 has an internal 8mHz oscillator inside.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-01T19:25:39.027" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5273" PostTypeId="2" ParentId="4634" CreationDate="2014-12-01T20:02:07.837" Score="1" Body="&lt;p&gt;Did you figure this out yet? If not, you have the +5 volts going to the GND on the breadboard, causing a short.&lt;/p&gt;&#xA;" OwnerUserId="5053" LastEditorUserId="220" LastEditDate="2014-12-05T22:43:10.730" LastActivityDate="2014-12-05T22:43:10.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5274" PostTypeId="1" CreationDate="2014-12-01T20:25:11.093" Score="0" ViewCount="8469" Body="&lt;p&gt;I would like to establish a communication between my C# program and my Arduino Duemilanove. I tried lot of different tutorials, but none of them were the same, and I'm a little bit confused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually my code is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C#&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using System;&#xA;using System.Collections.Generic;&#xA;using System.ComponentModel;&#xA;using System.Data;&#xA;using System.Drawing;&#xA;using System.IO.Ports;&#xA;using System.Linq;&#xA;using System.Text;&#xA;using System.Threading.Tasks;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace InterfaceArduinoWindowsFOrm {&#xA;  public partial class Form1 : Form {&#xA;    public Form1() {&#xA;      InitializeComponent();&#xA;      serialPort1.PortName = &quot;COM3&quot;;&#xA;      serialPort1.BaudRate = 9600;&#xA;      serialPort1.Open();&#xA;    }&#xA;&#xA;    private void pictureBox1_Click(object sender, EventArgs e) {&#xA;    }&#xA;&#xA;    private void tabPage2_Click(object sender, EventArgs e) {&#xA;    }&#xA;&#xA;    private void listBox1_SelectedIndexChanged(object sender, EventArgs e) {&#xA;    }&#xA;&#xA;    private void toolTip1_Popup(object sender, PopupEventArgs e) {&#xA;    }&#xA;&#xA;    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) {&#xA;      Console.WriteLine(&quot;test&quot;);&#xA;    }&#xA;&#xA;    private void button1_Click_1(object sender, EventArgs e) {&#xA;      serialPort1.Write(&quot;5&quot;);&#xA;      Console.WriteLine(serialPort1.IsOpen);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Sweep&#xA;  by BARRAGAN &amp;lt;http://barraganstudio.com&amp;gt;&#xA;  This example code is in the public domain.&#xA;  modified 8 Nov 2013&#xA;  by Scott Fitzgerald&#xA;  http://arduino.cc/en/Tutorial/Sweep&#xA;*/&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;  // Create servo object to control a servo.&#xA;// Twelve servo objects can be created on most boards.&#xA;int pos = 0;&#xA;int message = 0; // This will hold one byte of the serial message&#xA;                 // variable to store the servo position.&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  myservo.attach(9);  // Attaches the servo on pin 9 to the servo object&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) {&#xA;&#xA;    // Check to see if there is a new message&#xA;    message = Serial.read();&#xA;&#xA;    // Put the serial input into the message&#xA;    Serial.print(message);&#xA;&#xA;    if (message == '5') {&#xA;      Serial.print(&quot;test&quot;);&#xA;      for(pos = 0; pos &amp;lt;= 180; pos += 1) {&#xA;        // Goes from 0 degrees to 180 degrees&#xA;        // in steps of 1 degree&#xA;&#xA;        myservo.write(pos);&#xA;        // Tell servo to go to position in variable 'pos'&#xA;&#xA;        delay(15);&#xA;        // Waits 15 ms for the servo to reach the position&#xA;      }&#xA;&#xA;      for(pos = 180; pos&amp;gt;=0; pos-=1) {&#xA;        // Goes from 180 degrees to 0 degrees&#xA;&#xA;        myservo.write(pos);&#xA;        // Tell servo to go to position in variable 'pos'&#xA;&#xA;        delay(15);&#xA;        // Waits 15 ms for the servo to reach the position&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, when I click my button, nothing happens, but obviously if I remove the &lt;code&gt;if&lt;/code&gt; statement, the servo motor code works.&lt;/p&gt;&#xA;" OwnerUserId="5054" LastEditorUserId="510" LastEditDate="2015-09-14T12:12:21.157" LastActivityDate="2015-09-14T12:12:21.157" Title="C# and Arduino problem with serial port" Tags="|serial|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5275" PostTypeId="2" ParentId="5264" CreationDate="2014-12-01T22:25:45.997" Score="0" Body="&lt;p&gt;I think I may have a very simple solution. Completely overlooked this while I was messing with the timers. I took the hint from a I2C routine in some threads in the the forum here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works with empty strings as well as large strings with garbage values. It doesn't seem to hold the system anymore, so it works for my purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything I should add here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count_for_break = 0;&#xA;while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) )     // wait for another char - Waits for 200 cycles.&#xA;        {&#xA;            count_for_break++;&#xA;            if(count_for_break &amp;gt; 200)&#xA;                break;&#xA;        }&#xA;//then reset the counter upon break or char receive.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastActivityDate="2014-12-01T22:25:45.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5276" PostTypeId="1" AcceptedAnswerId="5280" CreationDate="2014-12-01T22:56:20.787" Score="0" ViewCount="817" Body="&lt;p&gt;I have a problem in calibration an LDR sensor. I want to let the sensor goes all day long and I'm using the LDR sensor as a presence sensor. The calibration values (min and max) changes all the day, and I need to detect only the peaks, or continuously change the min and the max values. Are there some defined pattern or algorithms to use?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2014-12-02T11:42:37.853" Title="How to continuously calibrate sensor" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5277" PostTypeId="2" ParentId="604" CreationDate="2014-12-02T00:05:27.220" Score="1" Body="&lt;p&gt;You can use Thinkerkit pins(out ~5 and ~6) for controlling servos. Just need to do a bit of tweaking here. Hobby servo motors have got 3 pins orange(signal) , red(live+) in the middle, and brown(gnd-). But, the motor shield rev3 uses the middle pin for signal. To overcome this problem, swap the middle wire with the orange one on the servo plug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three small latches that prevent wires coming out of the plug, use the tip of a needle and with little force slightly lift them up then pull out the wires from the servo plug, they should come off easily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember to attach pin 5 or 6 in the arduino code. I used servo.h library. &lt;/p&gt;&#xA;" OwnerUserId="5055" LastActivityDate="2014-12-02T00:05:27.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5278" PostTypeId="1" AcceptedAnswerId="5279" CreationDate="2014-12-02T04:36:37.713" Score="0" ViewCount="273" Body="&lt;p&gt;Also, what about the micro/nano/mini arduinos? Are they easily plug'n'play like the uno?&#xA;(This is an edit from another of my questions)&lt;/p&gt;&#xA;" OwnerUserId="5031" LastActivityDate="2014-12-02T05:06:23.397" Title="Are the Arduino Micro, Mini, etc plug'n play?" Tags="|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5279" PostTypeId="2" ParentId="5278" CreationDate="2014-12-02T05:06:23.397" Score="2" Body="&lt;p&gt;The ones that have a USB connector are plug-and-play with a USB host. The ones that don't need a USB-to-UART bridge.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-02T05:06:23.397" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5280" PostTypeId="2" ParentId="5276" CreationDate="2014-12-02T11:42:37.853" Score="2" Body="&lt;p&gt;In this situation, it may be useful to look at the differential of the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to do this is to store the value, wait some time and read another value. You can then do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dv = current_value - last_value&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you have some time metric (Perhaps clock ticks, or a rtc):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dv = (current_value - last_value) / (current_time - last_time)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would then want to only count significantly large changes in &lt;code&gt;dv&lt;/code&gt;. As the day progresses the light value will only change at a small rate but if someone were to block the light then there will be a large difference between &lt;code&gt;current_value&lt;/code&gt; and &lt;code&gt;last_value&lt;/code&gt;, causing &lt;code&gt;dv&lt;/code&gt; to be largely negative (Indicating a loss of a lot of light) and when they no longer block the light you will get the opposite, indicating there is no longer an obstruction. (Or rather, less of an obstruction.)&lt;/p&gt;&#xA;" OwnerUserId="5061" LastActivityDate="2014-12-02T11:42:37.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5281" PostTypeId="1" CreationDate="2014-12-02T10:13:43.630" Score="2" ViewCount="1351" Body="&lt;p&gt;I'm having trouble getting the atmega328p chip to upload sketches using my ftdi. It always comes up with an error saying not in sync.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an 8Mhz crystal with 22pf capacitors. The weird thing is I could flash the bootloader using my avrispmkII @ 3.3v. AFAIK this tells me the chip is running. I have an led connected to pin7. It doesn't flash when turn the power on.  However it does flash when powered from 5v and everything is working fine. I could upload sketches using the ftdi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the ftdi on a breakout to pin headers. I have the reset pin wired up to the DTR via a 100nf capacitor. The reset has a 10k pull up. CTS pin is grounded. The usart is as follows tx (atmega) ---&gt; rx(ftdi)  and rx(atmega) to tx(ftdi). I have also switch between 3.3v and 5v logic using the vccio pin on the ftdi. I.e. vccio = 5v if atmega is 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the programmer need to know what voltage am using, how critical is it, since I don't have a 3.3v regulator to hand. I used a lm338 and it's coming out as around 3.2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I selected arduino pro/mini @ 8mhz 3.3v atmega328p when I flashed the bootloader &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;##############################################################&#xA;&#xA;pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328&#xA;&#xA;pro328.upload.protocol=arduino&#xA;pro328.upload.maximum_size=30720&#xA;pro328.upload.speed=57600&#xA;&#xA;pro328.bootloader.low_fuses=0xFF&#xA;pro328.bootloader.high_fuses=0xDA&#xA;pro328.bootloader.extended_fuses=0x05&#xA;pro328.bootloader.path=atmega&#xA;pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex&#xA;pro328.bootloader.unlock_bits=0x3F&#xA;pro328.bootloader.lock_bits=0x0F&#xA;&#xA;pro328.build.mcu=atmega328p&#xA;pro328.build.f_cpu=8000000L&#xA;pro328.build.core=arduino&#xA;pro328.build.variant=standard&#xA;&#xA;##############################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;output from avrdude&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.02s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as DA&#xA;avrdude: safemode: efuse reads as 5&#xA;&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as DA&#xA;avrdude: safemode: efuse reads as 5&#xA;avrdude: safemode: Fuses OK&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5064" OwnerDisplayName="Ageis" LastEditorUserId="6452" LastEditDate="2015-01-21T22:21:40.560" LastActivityDate="2015-01-21T22:21:40.560" Title="atmega328p on breadboard using ftdi to upload sketches @8mhz 3.3v" Tags="|atmega328|ftdi|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5283" PostTypeId="2" ParentId="5281" CreationDate="2014-12-02T13:19:08.533" Score="1" Body="&lt;p&gt;I would suspect that the 328P's fuses were not programmed as defined in the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/boards.txt&quot; rel=&quot;nofollow&quot;&gt;boards.txt&lt;/a&gt; This needs to be explicitly done.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.bootloader.low_fuses=0xff&#xA;uno.bootloader.high_fuses=0xde&#xA;uno.bootloader.extended_fuses=0x05&#xA;uno.bootloader.path=optiboot&#xA;uno.bootloader.file=optiboot_atmega328.hex&#xA;uno.bootloader.unlock_bits=0x3F&#xA;uno.bootloader.lock_bits=0x0F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if not done. several things can go wrong.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;oscillator won't start on external crystal &lt;/li&gt;&#xA;&lt;li&gt;oscillator will be at wrong speed code &lt;/li&gt;&#xA;&lt;li&gt;wont start at bootloader&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-12-02T13:19:08.533" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5284" PostTypeId="2" ParentId="5249" CreationDate="2014-12-02T18:04:53.167" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have a USB 2 Serial adapter...I have connected the TX0 pin of Arduino to DB 2 pin (read pin) of the adapter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You &lt;strong&gt;must not&lt;/strong&gt; connect Arduino pins directly to a D-SUB connector of a USB-Serial adapter, as those connectors traditionally carry higher voltage, opposite sense RS232 signals.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The voltage is too high, and likely to cause damage to your Arduino's processor&lt;/li&gt;&#xA;&lt;li&gt;The signal is inverted in sense from the logic-level signaling used by your Arduino's processor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you actually needed to make this connection, you would need to either use a &quot;logic level&quot; USB serial adapter (sometimes informally called a USB-TTL adapter).  These terminate in various types of connections such as bare wires or header pins/sockets - but basically &lt;em&gt;never&lt;/em&gt; in an D-SUB connector.  Or you can use an inverting line driver and receiver such as the MAX2232 type devices, or even an old 1488/1489 pair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's not clear that you should be doing this at all - &lt;strong&gt;an Arduino Mega already has a USB-serial converter onboard&lt;/strong&gt; - that is the interface you use to program it, and it would ordinarily be simplest to use that for runtime communication as well.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2014-12-02T18:04:53.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5286" PostTypeId="1" AcceptedAnswerId="5409" CreationDate="2014-12-01T21:28:27.547" Score="0" ViewCount="380" Body="&lt;p&gt;I'm working with Arduino Uno, Adafruit PN532 NFC/RFID Shield and along with other modules. I'm posting this test program because I found there's conflict with the serial output while writing code to integrate all the modules together. I tried troubleshooting by running this code. The result wasn't what I'd expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Arduino, as far as I know, setup() only runs once after starting the program and then loop() will be executed repeatedly. I ran the example sketch called &lt;em&gt;readMiFare&lt;/em&gt; provided by Adafruit alone and it was fine. This code can be found at &lt;a href=&quot;https://github.com/adafruit/Adafruit_NFCShield_I2C/blob/master/examples/readMifare/readMifare.pde&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/Adafruit_NFCShield_I2C/blob/master/examples/readMifare/readMifare.pde&lt;/a&gt;. However, when I did the following in main,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;  Serial.begin(115200);&#xA;  nfctestsetup();&#xA;}&#xA;&#xA;void loop(void) &#xA;{&#xA;  nfctestloop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the following conflict showed up. When happened was that whenever I scanned a card to the reader it executed the loop() partially and exited the loop. Even worse, it executed the setup() again and again whenever I scanned a card.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lIVAG.png&quot; alt=&quot;Serial output&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In nfctestsetup(), I just commented out    &lt;code&gt;Serial.begin(115200);&lt;/code&gt; from readMiFare.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My hardware setup was a no brainer since I'm using I2C. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/KS2jd.jpg&quot; alt=&quot;Uno and PN532 Shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Appreciate the help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After spending a good amount of hours on troubleshooting, I found something interesting. When I commented out all other files except NFC and main, it worked like a charm. So I suspect there could be redefinitions on the pins that the NFC shield uses on other files. I suspect the following code in the other file gave me the problem because I commented out the rest of the code in this file and ran this block of code together with NFC and main. In fact, it's the last line of code in this block that gave me the problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I probed on the RESET pin (see the readMiFare link above). It generated a high-low-high pulse whenever I scanned a card. Is this related to the problem? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;Adafruit_BLE_UART.h&quot;&#xA;&#xA;// Connect CLK/MISO/MOSI to hardware SPI&#xA;// e.g. On UNO &amp;amp; compatible: CLK = 13, MISO = 12, MOSI = 11&#xA;#define ADAFRUITBLE_REQ 10&#xA;#define ADAFRUITBLE_RDY 3     // This should be an interrupt pin, on Uno thats #2 or #3&#xA;#define ADAFRUITBLE_RST 9&#xA;&#xA;Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any thought is appreciated. &lt;/p&gt;&#xA;" OwnerUserId="5073" OwnerDisplayName="VequalsIR" LastEditorUserId="5073" LastEditDate="2014-12-02T22:21:21.743" LastActivityDate="2015-01-08T16:35:02.233" Title="Arduino: The program exited the loop early and execute setup() repeatedly" Tags="|bluetooth|rfid|adafruit|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5287" PostTypeId="1" AcceptedAnswerId="13005" CreationDate="2014-12-02T19:07:57.090" Score="6" ViewCount="824" Body="&lt;p&gt;I am working on a simple project using an Arduino Mega 2560 that involves reading a 12-bit binary encoder signal and which is used to cycle a digital pin high and low (depending on the angular location of the encoder).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that when the digital output pin is told to go low, it only goes down to about 4V. I also noticed that it would occasionally dip down to ground, instead of just 4V. Much to my surprise, when I unplug the Arduino, the digital output pin is still reading 4V. When I turned off power to my encoder which is connected up the the Arduino through 12 digital input pins, the output pin dropped down to 0V. When I turn the encoder back on it goes back up to about 4V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried connecting the output pin to ground and obviously the voltage goes to 0, but as soon as I remove the connection to ground the voltage springs back up to around 4V. It appears as though somehow the voltage being fed to the digital input pins (in the form of a ~5V digital input signal) is preventing the digital output pin from going to ground. I have no idea why this is the case, I have searched all over and could not find any similar complaints. My code is posted below, any help is greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long CamAngle = 0;       // Variable to store encoder value&#xA;unsigned long PrevCamAngle = 0;   // Variable to store previous encoder value&#xA;int i = 0;                        // Cycle index&#xA;int BDC[] = {683,2048,3413};      // BDC angle (12-bit encoder value)&#xA;int TDC[] = {0,1365,2731};        // TDC angle (12-bit encoder value)&#xA;&#xA;boolean TDCycle = false;          // TDC Cycle&#xA;boolean BDCycle = false;          // BDC Cycle&#xA;boolean Cycle = true;             // Encoder rollover cycle (replaces TDC cycle 0)&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(37, INPUT);           // Encoder bit 0 (PORTC-0)&#xA;  pinMode(36, INPUT);           // Encoder bit 1 (PORTC-1)&#xA;  pinMode(35, INPUT);           // Encoder bit 2 (PORTC-2)&#xA;  pinMode(34, INPUT);           // Encoder bit 3 (PORTC-3)&#xA;  pinMode(22, INPUT);           // Encoder bit 4 (PORTA-0)&#xA;  pinMode(23, INPUT);           // Encoder bit 5 (PORTA-1)&#xA;  pinMode(24, INPUT);           // Encoder bit 6 (PORTA-2)&#xA;  pinMode(25, INPUT);           // Encoder bit 7 (PORTA-3)&#xA;  pinMode(26, INPUT);           // Encoder bit 8 (PORTA-4)&#xA;  pinMode(27, INPUT);           // Encoder bit 9 (PORTA-5)&#xA;  pinMode(28, INPUT);           // Encoder bit 10 (PORTA-6)&#xA;  pinMode(29, INPUT);           // Encoder bit 11 (PORTA-7)&#xA;&#xA;  pinMode(30, OUTPUT);          // Set PORTC pin 8 to output (stop pin float)&#xA;  pinMode(31, OUTPUT);          // Set PORTC pin 7 to output (stop pin float)&#xA;  pinMode(32, OUTPUT);          // Set PORTC pin 6 to output (stop pin float)&#xA;  pinMode(33, OUTPUT);          // Set PORTC pin 5 to output (stop pin float)&#xA;&#xA;  digitalWrite(30, LOW);        // Set PORTC pin 8 low (stop pin float)&#xA;  digitalWrite(31, LOW);        // Set PORTC pin 7 low (stop pin float)&#xA;  digitalWrite(32, LOW);        // Set PORTC pin 6 low (stop pin float)&#xA;  digitalWrite(33, LOW);        // Set PORTC pin 5 low (stop pin float)&#xA;&#xA;  pinMode(53, OUTPUT);          // Set pin 53 (PORTB-0) as digital output&#xA;  digitalWrite(53, LOW);        // Set pin 53 (PORTB-0) LOW&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  // Cam Angle Update&#xA;  PrevCamAngle = CamAngle;      // Set variable to previous encoder value&#xA;  CamAngle = (PINA &amp;lt;&amp;lt; 4) + PINC;    // Read encoder, set variable to value&#xA;&#xA;  if (TDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= TDC[i])  // Wait for encoder to reach angle if cycle active&#xA;  {&#xA;    PORTB = 0;                                  // Set digital pin 53 LOW&#xA;    TDCycle = false;&#xA;    BDCycle = true;&#xA;  }&#xA;&#xA;  if (BDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= BDC[i])  // Wait for encoder to reach angle if cycle active&#xA;  {&#xA;    PORTB = 1;                                  // Set digital pin 53 HIGH&#xA;    TDCycle = false;&#xA;    BDCycle = true;&#xA;    i++;&#xA;    if (i &amp;gt; 2)                                  // Reset every 3 cycles (3 cycles per revolution)&#xA;    {&#xA;      i = 0;&#xA;      BDCycle = false;&#xA;      Cycle = true;&#xA;    }&#xA;  }&#xA;&#xA;  if (Cycle == true &amp;amp;&amp;amp; CamAngle &amp;lt; (PrevCamAngle + 1))  // Wait for encoder to cycle back to 0&#xA;  {&#xA;    PORTB = 0;                                  // Set digital pin 53 LOW&#xA;    BDCycle = true;&#xA;    Cycle = false;&#xA;  }      &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see I am utilizing direct port manipulation, however I have the same issues when I use the Arduino library commands as well.  I'm fairly certain this is some sort of hardware issue, however I could be wrong.&lt;/p&gt;&#xA;" OwnerUserId="5070" LastEditorUserId="13840" LastEditDate="2015-10-28T10:29:33.330" LastActivityDate="2015-12-27T18:54:29.473" Title="Arduino Digital Input Causing Output Problems" Tags="|arduino-mega|c++|pins|digital|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5288" PostTypeId="2" ParentId="5234" CreationDate="2014-12-02T19:15:31.027" Score="1" Body="&lt;p&gt;You need a common ground between the Arduino and the PIC. Connect both grounds one to each other. &lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-02T19:15:31.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5289" PostTypeId="2" ParentId="1491" CreationDate="2014-12-02T21:25:17.423" Score="1" Body="&lt;p&gt;Stepper motors are nice and all but they actually make less than adequate servos for this purpose. the best way that I can see is with linear actuators that have position sensors in them and feed the Voltage divider outputs from those sensors to the Atmega chip. If you write the code to compare the signals from the light detectors with the voltage from the pos sensors it should be a lot better. Also, limit switches should be used in this arrangement too. They would be as a fail safe. The other benefit is that linear actuators usually hold a lot better without loosing their position due to outside stresses. Steppers can be used for prototyping, but it would still be better to start with small servos with sensors and get the system working first. I myself am trying to get a working system and I am having troubles with the coding also, but I am not good at coding. One other thing, I have looked at a lot of different codes to find something that might help me with my project and I have seen this. Stepper motor systems are written with minimal code which as I see it leaves room for much error. Atmega has plenty of room for code storage and plenty of ports for sensors in this use. Everyone knows that old phrase keep it simple but some times that is not always the best advice. You are working with something that needs to be somewhat complicated, to be less likely to fail. The more engineering you put into something the more likely something is to go wrong but less engineering gives you the same results. So consider all the posibilities and address them. Adding components and sub systems will in the end make your work better. &lt;/p&gt;&#xA;" OwnerUserId="5072" LastEditorUserId="5072" LastEditDate="2014-12-02T21:34:54.500" LastActivityDate="2014-12-02T21:34:54.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5290" PostTypeId="1" AcceptedAnswerId="5300" CreationDate="2014-12-02T23:22:51.313" Score="2" ViewCount="597" Body="&lt;p&gt;I had an infrared 38khz sensor that I used to read my TV remote control commands. It worked fine but I burned it. I had not another 38khz IR sensor so I tried to use my infrared reflective optic sensor like the one below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HnGi6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I press my TV remote control button and when I try to read the HIGHs and LOWs it does not work. The sensor shows in my Serial that it received the infrared light but it does not sense the lows/high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, this sensor is not 38khz, it listens in all frequencies that are infrared. So why it does not work? It should work cause it listens in all frequencies. Why it can detect the HIGHs/LOWs that the remote control sends?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-12-03T13:27:44.593" Title="Simple IR sensor" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5291" PostTypeId="1" AcceptedAnswerId="5296" CreationDate="2014-12-03T05:11:20.130" Score="7" ViewCount="9936" Body="&lt;p&gt;What would be the (very) minimum &lt;em&gt;schematic&lt;/em&gt; to make a ATtiny85 blink a led?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restrictions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There must be a C program compiled and uploaded to it, just like an Arduino board would have. The code would use a simple &quot;delay&quot; to wait a little bit before changing the LED state.&lt;/li&gt;&#xA;&lt;li&gt;The LED must be controlled by a &quot;digital output port&quot; just like an Arduino board would be.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is the main question. Although I thought to ask a similar question with the restriction of &quot;blinking exactly once per second&quot;, that would change completely the schema (not being a MINIMAL after all). So lets restrain to the main question. Maybe some day we can discuss the version 2.0!&lt;/p&gt;&#xA;" OwnerUserId="5077" LastEditorUserId="5077" LastEditDate="2014-12-07T05:42:51.367" LastActivityDate="2015-02-20T21:33:34.723" Title="ATtiny85 minimum setup to blink led" Tags="|sketch|c|attiny|prototype|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5292" PostTypeId="1" CreationDate="2014-12-03T05:15:35.657" Score="3" ViewCount="189" Body="&lt;p&gt;My first experience with Arduino ended in a tragedy. I bought a Leonardo from ebay and upon arrival, attached it to my laptop. Programmed a simple blink demo with the onboard LED. It started working. Then detached it from USB and plugged in a 9v adapter. The board started smoking and it doesn't work anymore. I measured the voltage of the adapter and it reads 9.7v. So, what is the reason of this tragedy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the smoke was from a component close to the processor. Right now, when I attach a 9v battery to the board, both the ON LED and the L LED remains on. The processor also warm.&lt;/p&gt;&#xA;" OwnerUserId="5081" OwnerDisplayName="Mohsen" LastEditorUserId="612" LastEditDate="2015-01-22T23:27:54.703" LastActivityDate="2015-01-22T23:27:54.703" Title="9v adapter burned out Leonardo style board" Tags="|arduino-leonardo|safety|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="5293" PostTypeId="1" AcceptedAnswerId="5297" CreationDate="2014-12-03T05:23:46.933" Score="1" ViewCount="783" Body="&lt;p&gt;So I am not new to arduino, however, I am new with web servers. I am working on a project that can control a robotic arm that is at one location and I can be at my house. I know basic HTML, Basic CSS, Basic JavaScript, and a tiny bit of JQuery. Only reason I say basic is because I self taught all these languages to myself using codeacademy. So I have a few questions since I done research on the matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can a project like this be done with just the languages I know? All the tutorials I have looked at say you have to know AJAX and JSON. I have no idea what these are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, for the interface, I need to be able to take the value of the encoders on the robot and view them. I also need a button that will record the value at that point in time of the encoders so I can configure the points and maybe even name them. A box where I can see the points and their coordinates, and finally a box where i can place points in and then execute a sequence. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How tough should this be?&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2014-12-18T19:53:20.030" Title="Using a web server with Arduino" Tags="|arduino-uno|ethernet|web-server|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5294" PostTypeId="2" ParentId="5291" CreationDate="2014-12-03T05:39:44.773" Score="5" Body="&lt;p&gt;Here is the absolute minimal schematic required to blink a LED beyond power and decoupling:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VHNbc.png&quot; alt=&quot;Minimal LED schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refer to &lt;a href=&quot;https://electronics.stackexchange.com/questions/123863/which-resistor-to-use-for-this-led&quot;&gt;&quot;Which resistor to use for this LED&quot;&lt;/a&gt; to calculate the appropriate value for R1.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-12-03T05:39:44.773" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5295" PostTypeId="2" ParentId="5258" CreationDate="2014-12-03T06:26:42.920" Score="0" Body="&lt;p&gt;When you set the pin value to 0 you are making that pin act as ground. Since the LED had a single anode that receives 5V. When the difference between the anode and cathode is high (Anode - 5V &amp;amp; Cathode - 0V) the LED turns on. When the difference between the anode and cathode is low (Anode - 5V &amp;amp; Cathode - 5V) the LED is off. The larger the difference between the two the brighter the LED. In your code use &lt;code&gt;analogWrite(redPin, ~0);&lt;/code&gt; then everything should work. Change 0 above to whatever value you want, less than 255, and it should work. Also do the same for the green and plus pins too.&lt;/p&gt;&#xA;" OwnerUserId="1710" LastActivityDate="2014-12-03T06:26:42.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5296" PostTypeId="2" ParentId="5291" CreationDate="2014-12-03T07:44:42.203" Score="9" Body="&lt;p&gt;This schematic shows a complete connection of a blinking led.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Red cable = +5V (pin 8)&lt;/li&gt;&#xA;&lt;li&gt;White cable = Ground (pin 4)&lt;/li&gt;&#xA;&lt;li&gt;Resistor = 1 end at pin 5 (IO 0) and the other in the LED anode (+)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Led anode (+) in the resistor, cathode (-) (small leg) in the ground&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Resistor = 330 Ohms&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The arduino in the picture is not necessary, just used to give power. But in the video linked below its used to burn the ATtiny85. The resistor can be a 330 ohms for a simple project like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2aAfG.png&quot; alt=&quot;Snapshot of the video linked below&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://youtu.be/i9WOwDrpRKs&quot; rel=&quot;noreferrer&quot;&gt;Youtube Video with a simple explanation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this explanation will enlighten who wants to start on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to record your ATtiny85 using Arduino UNO as ISP, then you will also need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;10 uF electrolytic capacitor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here a picture of the pins:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/QL6Sg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5077" LastEditorUserId="4951" LastEditDate="2015-02-20T21:33:34.723" LastActivityDate="2015-02-20T21:33:34.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5297" PostTypeId="2" ParentId="5293" CreationDate="2014-12-03T08:24:10.233" Score="3" Body="&lt;p&gt;You can use an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun?from=Products.ArduinoYUN&quot; rel=&quot;nofollow&quot;&gt;Arduino Yun&lt;/a&gt;: it has a 32u4 microcontroller coupled with a cpu running linux. The linux side already has a webserver: together with the &lt;a href=&quot;http://arduino.cc/en/Reference/YunBridgeLibrary&quot; rel=&quot;nofollow&quot;&gt;Bridge library&lt;/a&gt;, you can use &lt;a href=&quot;http://arduino.cc/en/Tutorial/Bridge&quot; rel=&quot;nofollow&quot;&gt;REST-like APIs&lt;/a&gt; to control a sketch, or build a web app that uses that APIs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example of remotely control an Arduino (although using an Android app instead of html+js) &lt;a href=&quot;https://www.youtube.com/watch?v=F-oRrcYfv8o&quot; rel=&quot;nofollow&quot;&gt;is this&lt;/a&gt;. Here is its &lt;a href=&quot;https://github.com/Vadorequest/AAD1&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-12-03T08:24:10.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5298" PostTypeId="2" ParentId="5291" CreationDate="2014-12-03T09:33:55.887" Score="6" Body="&lt;p&gt;Ignacio Vazquez-Abrams has already outlined the schematics.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There must be a C program compiled and uploaded to it, just like an Arduino board would have. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are however some differences between a fully equipped Arduino board with an ATMega328P and a bare ATtiny85 you would have to care for in your code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A bare ATtiny85 runs at 1 MHz (8 MHz internal oscillator, &lt;em&gt;CKDIV8&lt;/em&gt;). Define &lt;strong&gt;F_CPU&lt;/strong&gt; accordingly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The ATtiny85 only has one hardware port, &lt;strong&gt;PB&lt;/strong&gt;. There's a reason Ignacio used &lt;strong&gt;PBx&lt;/strong&gt; in his scheme ;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;On the plus side, the ATtiny85 allows to toggle a pin by setting the corresponding bit in &lt;strong&gt;PINB&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;PINB |= (1 &amp;lt;&amp;lt; PB0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-12-03T09:33:55.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5300" PostTypeId="2" ParentId="5290" CreationDate="2014-12-03T13:27:44.593" Score="3" Body="&lt;p&gt;You didn't post the code that used to work with the standard 38Khz IR sensor, but I believe you used &lt;strong&gt;digitalRead&lt;/strong&gt; to determine a HIGH or LOW value, by thus determine if there is an IR emitting in place. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reflective optic sensor works differently, the output is analog, and changes according to the amount of IR light it sens. In addition, it has a built-in IR led next to the IR sensor, so if you want to use this as the IR detection sensor you had, first you need to disable the IR led to prevent interference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second step would be to use &lt;strong&gt;analogRead&lt;/strong&gt;, and compare the result to a pre-defined threshold. For example, since analogRead returns result in the range of 0...1023, you can treat everything from, say, 512 and above as logic 'HIGH'. If you are working with libraries that detects the IR signal, you will need to alter them accordingly.  &lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-03T13:27:44.593" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5301" PostTypeId="1" CreationDate="2014-12-03T16:54:21.853" Score="0" ViewCount="1460" Body="&lt;p&gt;I am &lt;strong&gt;&lt;em&gt;really&lt;/em&gt;&lt;/strong&gt; despaired. I have spent a full day to understand this, and it seems that I still don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino UNO, with an ATMega328, for which I wrote a great piece of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later, I have built a circuit on a bread board, where I want to use that same ATMega328, in a 3.3V configuration, and hence 8MHz oscillator .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I understood that I have to write a new boot loader to it (is that correct?) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I follow many guides available, including the &lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;Arduino Standalone&lt;/a&gt;, and then I understood that I don't have another chip (ATMega328), in order to use the UNO as a boot loader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I was trying to connect the ATMega328 directly from the bread board to the UNO's serial data, change the &lt;code&gt;boards.txt&lt;/code&gt; file to add &lt;code&gt;&quot;ATMega on bread board 8MHz&quot;&lt;/code&gt;, and tried to boot-loading it, without success. I get the error that it &lt;code&gt;can't connect with the board&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have been told that &lt;strong&gt;I can't&lt;/strong&gt; connect the ATMega328 directly to the UNO serial to boot load it, so my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do I really need to go over this hell in order to work with the same&#xA;chip that worked with 16MHz, but now on 8MHz at 3.3V? (why&#xA;in &lt;code&gt;microchip&lt;/code&gt; I could just switch xtal? )&lt;/li&gt;&#xA;&lt;li&gt;If I do have to boot loading it, and I have &lt;strong&gt;one&lt;/strong&gt; chip, and&#xA;an UNO, how can I do that?&lt;/li&gt;&#xA;&lt;li&gt;How you do that in mass production?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4989" LastEditorUserId="6936" LastEditDate="2015-04-20T21:50:31.743" LastActivityDate="2015-04-20T21:50:31.743" Title="Using the ATMega328, from an Arduino UNO in a Standalone configuration, and bootloader - I am really lost" Tags="|arduino-uno|bootloader|arduino-ide|atmega328|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5302" PostTypeId="2" ParentId="5257" CreationDate="2014-12-03T16:56:15.427" Score="1" Body="&lt;p&gt;My suggestions would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Implement a class that handles the queue and timer settings and uses callbacks.&lt;/li&gt;&#xA;&lt;li&gt;If you do not need perfect accuracy, remove the loop making the program wait and do that part just setting the timer.&lt;/li&gt;&#xA;&lt;li&gt;digitalRead() on an output pin returns the value it was last set to, therefore you do not need to waste that extra RAM.&lt;/li&gt;&#xA;&lt;li&gt;DO NOT wait in the ISR &quot;process_timer()&quot;, since you might lose other interrupts! (for the Serial communication, for example)&lt;/li&gt;&#xA;&lt;li&gt;is it neccessary to have only values above 200? if not, then don't prevent them from going below that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;--or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;use a total overkill system for this situation, such as my multitasking-library &lt;a href=&quot;https://launchpad.net/arduos&quot; rel=&quot;nofollow&quot;&gt;arduOS&lt;/a&gt; that also covers a some other things.&lt;/p&gt;&#xA;" OwnerUserId="4531" LastActivityDate="2014-12-03T16:56:15.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5304" PostTypeId="2" ParentId="5301" CreationDate="2014-12-03T18:11:39.657" Score="2" Body="&lt;p&gt;So do I understand you correctly that you want to lift the ATmega328 IC from the Uno board and use it on a breadboard? That strikes me as an unnecessarily risky proposition just to save a dollar or two for a separate ATmega328p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you technically might not have to write a new boot loader to the chip, if you don’t intend to reprogram it while it’s on the breadboard, but you definitely need different fuse settings, and the two changes are closely related in the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, bootloaders on ATmega are incapable of modifying themselves, so if you want to write a new bootloader, you always need a programmer (which can e.g. be your Arduino UNO running the ArduinoISP sketch or &lt;a href=&quot;http://microtherion.github.io/ScratchMonkey/index.html&quot; rel=&quot;nofollow&quot;&gt;ScratchMonkey&lt;/a&gt;); I don’t think your single-microcontroller idea would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For mass production, you’d just use a programmer. Bootloaders tend not to be used for this, which can lead to situations like this year’s &lt;a href=&quot;https://www.sparkfun.com/news/1575?_ga=1.55332589.776570698.1363272950&quot; rel=&quot;nofollow&quot;&gt;mishap at SparkFun&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-12-03T18:11:39.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5306" PostTypeId="2" ParentId="5301" CreationDate="2014-12-03T18:16:13.967" Score="1" Body="&lt;p&gt;There is a &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/3-3v-conversion&quot; rel=&quot;nofollow&quot;&gt;very nice tutorial by Adafruit&lt;/a&gt;, which explains how to get the Arduino Uno run at 3.3v, with minimum hussle and while keeping it's speed at 16Mhz, despite it's a bit out of specs (they claim it shouldn't pose a problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main idea is to replace the voltage regulator and the fuse on the Uno board. This involves some soldering, but will probably give you the fastest results for &lt;em&gt;prototyping&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would not choose the Arduino Uno for mass production anyway, since there are plenty of Arduino compatible boards that runs at 3.3v (like Arduino Due, Lilypad, and Arduino Pro Mini to name a few. Full list can be found on &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/3-3v-conversion&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;). As a side note, for mass production, I would probably go with a custom made PCB, and not an off-the-shelf product, considering its high cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link you provided explains how to recreate the Arduino  around the Atmega328p on a breadboard. For that, you will need a USB to serial converter such as the suggested FT232, but please note that this tutorial &lt;strong&gt;does not&lt;/strong&gt; address the issue on stake, which is running the chip at 3.3v (note the specs of the voltage regulator they offer, which is a 5v regulator).&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-03T18:16:13.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5307" PostTypeId="2" ParentId="4854" CreationDate="2014-12-03T18:54:17.040" Score="0" Body="&lt;p&gt;If the circuit worked perfectly, as is, and suddenly stopped working, without changing any hardware configuration, it must be a hardware related problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming your Arduino Uno is functioning properly and the pins behave accordingly (you can test blink.ino on the pin in doubt), it's either the IR sensor went bad or a the IR LED stopped working properly. Test each component individually. For the IR sensor, you could use any remote control to emit IR light on it and see if values change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to test bad pins are to switch from A0 to A1 and from PB2 to PB3 or similar.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-03T18:54:17.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5308" PostTypeId="1" AcceptedAnswerId="5309" CreationDate="2014-12-03T19:14:00.157" Score="2" ViewCount="7971" Body="&lt;p&gt;I have a code that reads the value of a sensor and because it needs to be very fast it does not use digitalRead but a strange form of reading. In the top of the code it shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define IRSENSOR PIND&#xA;int irpin = 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea why this PIND referes to my arduino pin 2, but it only work if my sensor is in pin 2. If I want to change to pin 9 and only change the irpin varialbe it does not work. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read the sensor I use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (IRSENSOR &amp;amp; (1 &amp;lt;&amp;lt; irpin )) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have no idea why this work. Does anyone know this kind of programming with arduino?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-12-03T20:41:27.637" Title="What is this PIND command" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5309" PostTypeId="2" ParentId="5308" CreationDate="2014-12-03T19:21:08.800" Score="6" Body="&lt;p&gt;PIND refers to the arduino's IO register for input in port D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without arduino, one has to refer to pins by specific bits in 3 different sets of registers for each port (PIN*, DDR*, and PORT*; B,C, and D). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino code makes it simpler to pick out a single pin by hiding all of this, but it does make reading a pin take much longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code, the specific pin is being selected by masking off all but the &quot;irpin&quot; bit in PIND, so changing irpin will pick a different bit and thus a different pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 9 is actually bit 1 of port B, not D, so see if this works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define IRSENSOR PINB&#xA;int irpin = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;alternatly, using a reference instead of define,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile uint8_t&amp;amp; IRSENSOR = PINB;&#xA;int irpin = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-03T20:41:27.637" LastActivityDate="2014-12-03T20:41:27.637" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5310" PostTypeId="2" ParentId="5242" CreationDate="2014-12-03T19:43:13.193" Score="0" Body="&lt;p&gt;AVR programmer helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meaning the bootloader somewhat got corrupted and I had to burn new one.&lt;/p&gt;&#xA;" OwnerUserId="5007" LastActivityDate="2014-12-03T19:43:13.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5311" PostTypeId="2" ParentId="5308" CreationDate="2014-12-03T20:13:53.330" Score="1" Body="&lt;p&gt;Reason explained by @BrettM. To be more perfect use macros everywhere, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define IRSENSOR PIND&#xA;#define IRSENSOR_PIN PD2&#xA;&#xA;while (IRSENSOR &amp;amp; _BV(IRSENSOR_PIN)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino's &lt;em&gt;digitalWrite(),digitalRead(),pinMode()&lt;/em&gt; functions are useless for more serious coding because they are 1) slow 2) you cannot address pins not connected to headers (e.g. at &lt;em&gt;Arduino2560&lt;/em&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3825" LastEditorUserId="3825" LastEditDate="2014-12-03T20:20:14.670" LastActivityDate="2014-12-03T20:20:14.670" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5312" PostTypeId="1" CreationDate="2014-12-04T03:14:06.337" Score="0" ViewCount="217" Body="&lt;p&gt;I am trying to read my ultrasonic sensor. It sends a pulse in the trigger pin and the echo pin receives the pulse. Using pulseIn I can know exactly the time it took to the pulse go and back. But I need to use port register which is much faster and I need it to be fast in this specific case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is very simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;    Serial.begin(9600); &#xA;    //pin 12 as output&#xA;    DDRB = B00010000;&#xA;    //pin 12 as low&#xA;    PORTB = B00000000;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    //pin 12 as high&#xA;    PORTB = B00010000;&#xA;    delayMicroseconds(10);&#xA;    //pin 12 as low&#xA;    PORTB = B00000000;&#xA;&#xA;    long start_time = micros();&#xA;&#xA;    //While reading high in pin 13 keep running the loop&#xA;    while (PINB &amp;amp; B00100000)) {&#xA;&#xA;&#xA;    }&#xA;&#xA;    Serial.println(micros() - start_time);&#xA;&#xA;    delay(1000);&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that it does not work, I mean, the while loop is not being processed so the serial is always printing a very small number. It doesnt matter if I move the ultrasonic sensor to distant walls the while loop still does not work. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastActivityDate="2014-12-04T17:00:45.723" Title="Port register not working" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5313" PostTypeId="2" ParentId="5312" CreationDate="2014-12-04T03:44:54.707" Score="2" Body="&lt;p&gt;According to anything I could find, the Echo output is normally &lt;em&gt;low&lt;/em&gt; and then goes &lt;em&gt;high&lt;/em&gt; for a duration equal to the range. Your initial while condition is inverted, and you need to check for &lt;em&gt;both&lt;/em&gt; edges.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long up, down;&#xA;&#xA;// trigger pulse&#xA;while (!(PINB &amp;amp; _BV(PB5)))&#xA;  ; // wait for leading edge&#xA;up = millis();&#xA;while (PINB &amp;amp; _BV(PB5))&#xA;  ; // wait for trailing edge&#xA;down = millis();&#xA;Serial.println(down - up);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-12-04T17:00:45.723" LastActivityDate="2014-12-04T17:00:45.723" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5314" PostTypeId="1" AcceptedAnswerId="5321" CreationDate="2014-12-04T04:10:49.383" Score="1" ViewCount="620" Body="&lt;p&gt;I got an Ethermega, and learned that Pin 13 already has a LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there other digital pins with special circuitry or already allocated to a specific function? (like usb,serial,ethernet,sd, etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need about 30 inputs so I can skip some if that would avoid headaches.&lt;/p&gt;&#xA;" OwnerUserId="5093" LastActivityDate="2014-12-04T17:08:24.133" Title="Arduino Mega: which Digital pins are already used for something?" Tags="|arduino-mega|pins|digital|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5315" PostTypeId="1" CreationDate="2014-12-04T06:05:55.807" Score="0" ViewCount="723" Body="&lt;p&gt;running a very short program on a mega, just to generate a 8 microsecond wide clock pulse on pin 18, every 250 microseconds-&#xA;closest 'delay' values I can get are delayMicroseconds(3), and (83) off, gives a 7.5 microsecond wide pulse every 249 microseconds- any suggestions on a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is whats running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i=0;&#xA;int req=18;&#xA;&#xA;void setup(){&#xA;Serial.begin(115200);&#xA; DDRD = DDRD | B10000010;&#xA; interrupts();&#xA;pinMode(req,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;i=1;&#xA;digitalWrite(req, HIGH);&#xA;delayMicroseconds(3); //gives 7.5 microsecond pulse?&#xA;digitalWrite(req, LOW);&#xA;&#xA;while(i&amp;lt;83){//gives 249 microseconds start of pulse to start of next pulse?&#xA; delayMicroseconds(1);&#xA; i=(i+1);}&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4598" LastActivityDate="2018-12-30T18:16:30.430" Title="delayMicroseconds- error?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5316" PostTypeId="2" ParentId="5314" CreationDate="2014-12-04T08:10:49.713" Score="2" Body="&lt;p&gt;Don't worry about the led on pin 13, it just sits there but doesn't block anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can still use the pin as a normal IO pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You didn't mention whether your 30 inputs are digital or analog, so let's have a look at digital input first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never used the &lt;strong&gt;MCP23017&lt;/strong&gt; mentioned by &lt;em&gt;Martynas&lt;/em&gt;, but the linked article looks very interesting and I'll definitely order one of these amazing chips!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option might be using 8 bit PISO (&lt;em&gt;parallel in - serial out&lt;/em&gt; shift registers, such as the &lt;strong&gt;74HC165&lt;/strong&gt;. Consider this as the complement to the 75HC595 for output. These shift registers are dirt cheap (around 0.3 €), are available as DIP (important for breadboarding) and can be run via &lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advantages: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;it's fast to read in 8 digital lines into a byte (why would one want to use more than a bit for the state of a digital input?)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the shift registers can be &lt;em&gt;daisychained&lt;/em&gt;, subsequent calls of &lt;a href=&quot;http://arduino.cc/en/Reference/ShiftIn&quot; rel=&quot;nofollow&quot;&gt;ShiftIn&lt;/a&gt; allows to read all (digital) input states into a corresponding data structure (array of bytes, etc.) using just &lt;strong&gt;three pins&lt;/strong&gt; on your Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-12-04T08:10:49.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5317" PostTypeId="2" ParentId="5315" CreationDate="2014-12-04T08:22:14.447" Score="1" Body="&lt;p&gt;Unless you want program PWM timer as suggested in comment then for short delays you need calculate how many instruction cycles are needed to make such a delay based on clock/crystal frequency and make that delay in inline assembler to have code under control. To manipulate digital output use writing data to PINx (which is equal to xoring PORTx). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To satisfy exact 250ms you need compensate errors because of rounding. Arduino's delay/tick functions do it. For the long delays you need a simple scheduler not to spend all the CPU time for pulse generating. &lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-12-04T08:22:14.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5318" PostTypeId="1" CreationDate="2014-12-04T08:40:50.367" Score="0" ViewCount="302" Body="&lt;p&gt;I am working on a project involving the Uno, and I would like to benchmark the power requirements of Arduino. I am using the external 9V supply option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, the Uno will be in to states,&lt;code&gt;power-intensive&lt;/code&gt; and &lt;code&gt;power-save&lt;/code&gt;. In the first mode, I am doing some heavy processing tasks (RF and some sensors are the only external loads), and the Arduino typically runs &lt;code&gt;loop()&lt;/code&gt; without any delays. In the second mode, &lt;code&gt;loop()&lt;/code&gt; is execued about every 10-40 seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am interested in benchmarking how much power is consumed in both states (I need this to estimate the size of the battery required for the 9V supply).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, googling yielded me solutions that involved measuring current using chips in series with the supply (I probably can pull this off with a multimeter). What I am wondering is whether there exists an elegant solution for this, with (highly) accurate results (I would most likely quote the power values, so accuracy is a must for me)? Something I can dynamically measure on the Uno itself?&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="10794" LastEditDate="2015-09-06T08:55:17.767" LastActivityDate="2015-11-05T09:13:48.513" Title="Measuring power consumption on Arduino off of DC supply" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5321" PostTypeId="2" ParentId="5314" CreationDate="2014-12-04T17:08:24.133" Score="1" Body="&lt;p&gt;D4: ChipSelect for the SD card reader (can be used if no SD is present)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D0 and D1 are Serial RX and TX (just like any other arduino)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D10: Ethernet enable line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D13: led. Led is connected via a mosfet, so it doesn't interfer (like on the uno)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D50, D51, D52: SPI for the ethernet chip and SD card&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this was found in the &lt;a href=&quot;https://github.com/freetronics/EtherMega/raw/master/EtherMega.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-04T17:08:24.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5322" PostTypeId="2" ParentId="5268" CreationDate="2014-12-04T17:11:33.790" Score="1" Body="&lt;h3&gt;The Bootlader&lt;/h3&gt;&#xA;&lt;p&gt;If you want to burn the bootloader to the standalone AVR that you will be using, you can do so using a programmer like the &lt;code&gt;USBasp&lt;/code&gt;. Or, you can simply use the &lt;em&gt;Arduino&lt;/em&gt;  itself to do this.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open the &lt;code&gt;ArduinoISP&lt;/code&gt; sketch from &lt;em&gt;File&lt;/em&gt; &amp;gt; &lt;em&gt;Examples&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Upload it.&lt;/li&gt;&#xA;&lt;li&gt;Push &lt;code&gt;reset&lt;/code&gt; on the Arduino.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Wire it up&lt;/h3&gt;&#xA;&lt;p&gt;Next, wire up the AVR on a breadboard as shown here: &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino ISP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you are using a variant/derivative, use a crystal that matches the crystal on your board. You might have &lt;code&gt;not_in_sync()&lt;/code&gt; trouble if you don't.&lt;/li&gt;&#xA;&lt;li&gt;Add a 10uF capacitor between &lt;code&gt;RESET&lt;/code&gt; and &lt;code&gt;GROUND&lt;/code&gt; on the Arduino, if you are using Uno, or something similar.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3&gt;Burning the Bootloader&lt;/h3&gt;&#xA;&lt;p&gt;Then select &lt;code&gt;Arduino as ISP&lt;/code&gt; as the programmer.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Goto &lt;em&gt;Tools&lt;/em&gt; &amp;gt; &lt;em&gt;Programmer&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Select &lt;em&gt;Arduino as ISP&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now click on &lt;em&gt;Tools&lt;/em&gt; &amp;gt; &lt;em&gt;Burn Bootloader&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Verifying it all works&lt;/h3&gt;&#xA;&lt;p&gt;Once that is done, open the Blink LED example and try uploading it to the AVR. You have to use the &lt;code&gt;Upload using Programmer&lt;/code&gt; option from &lt;em&gt;File&lt;/em&gt; &amp;gt; &lt;em&gt;Upload using Programmer&lt;/em&gt;. You can verify if it is successful, by connecting an LED to &lt;code&gt;pin 19&lt;/code&gt; of the AVR, and checking if it blinks.&lt;/p&gt;&#xA;&lt;h3&gt;Notes:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt; that the pins on an AVR don't map to the corresponding pins on the Arduino, even if they are both the same chips. Search for &amp;quot;AVR to Arduino pin mapping&amp;quot; for your chip on Google. Here's the &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATMega8 to Arduino pin mapping&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't forget to connect the ground lines of the AVR and the Arduino.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This worked for me using an ATMega8A-PU. It should work with the 8L too.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Post here if you have any problems. Glad to help &lt;code&gt;:)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1462" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-12-04T17:53:42.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5325" PostTypeId="1" CreationDate="2014-12-05T01:43:44.520" Score="3" ViewCount="17198" Body="&lt;p&gt;I have an Arduino Uno. I've been reading about pin change interrupts, and one vector covers the analog pins. However, is it possible to trigger interrupts using analog pins as analog inputs (not digital)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually want to analogRead() a potentiometer inside the ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code so far, &lt;a href=&quot;http://pastebin.com/ykpp78GB&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://pastebin.com/ykpp78GB&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my circuit is just two potentiometers connected to pin A0 and A1.&lt;/p&gt;&#xA;" OwnerUserId="5103" LastEditorUserId="510" LastEditDate="2017-04-25T07:49:04.633" LastActivityDate="2017-04-25T07:49:04.633" Title="Interrupts for analog inputs" Tags="|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5326" PostTypeId="2" ParentId="5325" CreationDate="2014-12-05T01:59:38.710" Score="5" Body="&lt;p&gt;It is not possible to trigger an interrupt when an analog input has reached a threshold on any tinyAVR or megaAVR. It is possible to trigger an interrupt when an analog input of an AVR XMEGA with the event system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use the built-in analog comparator on the ATmegaXX8 and ATmegaXXU4 in the Uno, Leonardo, and comparable boards to trigger an interrupt when an internal or external threshold has been met. It is only possible to compare to an internal threshold on the Mega, Mega 2560, or comparable boards since the pin for the external threshold is not broken out, although actual breakout boards for the ATmegaXXX0/1 will have the pin broken out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all cases, examine the appropriate datasheet (in particular the &quot;Analog Comparator&quot; section) as well as the pin mappings on the Arduino website for full details.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-05T01:59:38.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5327" PostTypeId="1" CreationDate="2014-12-05T03:31:56.567" Score="5" ViewCount="165" Body="&lt;p&gt;I'm working on using my Raspberry Pi (Raspbian) to upload sketches. However, I'm not sure which package is appropriate for command line usage (like described &lt;a href=&quot;https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc&quot; rel=&quot;noreferrer&quot;&gt;here on Github&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like &lt;code&gt;sudo apt-get install arduino&lt;/code&gt; would install the whole IDE, not just the command line. It seems like &lt;code&gt;arduino-core&lt;/code&gt; would be more fitted for this purpose. However, the repository has a note online to use a package called &lt;code&gt;arduino-mk&lt;/code&gt; for a CLI, which is what I want. However, this concerns me &lt;a href=&quot;https://packages.debian.org/wheezy/arduino-mk&quot; rel=&quot;noreferrer&quot;&gt;in the repository's page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This package will install a &lt;strong&gt;Makefile&lt;/strong&gt; to allow for CLI programming of the Arduino platform.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Emphasis mine)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What exactly does this mean? What are the differences between the three packages available?&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-05-08T22:11:19.947" Title="Different Arduino packages on Raspbian" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5328" PostTypeId="1" CreationDate="2014-12-05T03:51:59.013" Score="0" ViewCount="144" Body="&lt;p&gt;I have written a code for my Arduino which spans multiple files, In the file containing the main task, i have a Global Array like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;addr_t childAddr[NUM_CHILDS] = { CHILD1_I2C_ADDR, CHILD2_I2C_ADDR };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NUM_CHILDS  0x02&#xA;#define CHILD1_I2C_ADDR         0x10&#xA;#define CHILD2_I2C_ADDR         0x02&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to debug my issue, in my Task i do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(childAddr[0]);&#xA;Serial.print(childAddr[1]); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All i receive is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I looked at the issue online, someone pointed it towards overshooting the RAM, I am working on a Pro Mini with ATmega328P with 2K RAM.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/xovDm.png&quot; alt=&quot;This is my Output for analyzing the eld with &amp;quot;avr-size&amp;quot;  utility&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5069" LastActivityDate="2015-07-06T06:44:05.580" Title="Global Arrays read as Zero" Tags="|c++|i2c|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5329" PostTypeId="1" AcceptedAnswerId="5334" CreationDate="2014-12-05T04:13:50.430" Score="0" ViewCount="999" Body="&lt;p&gt;Shift registers need 3 digital pins in order to work (data, clock and latch), but Attiny45/85 chips provides 2 digital and 2 analog pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would I use 1 analog pin as digital pin? How?&lt;/p&gt;&#xA;" OwnerUserId="5103" LastActivityDate="2014-12-05T08:56:33.673" Title="Shift register on Attiny85 programmed by Arduino" Tags="|arduino-uno|attiny|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5330" PostTypeId="2" ParentId="5291" CreationDate="2014-12-05T04:51:34.757" Score="3" Body="&lt;p&gt;My setup would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a 10k resistor between Vcc and reset pin (pull-up) &lt;/li&gt;&#xA;&lt;li&gt;a 330k put in serial with a led,  connected between, e. g. PB0 and gnd. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That's all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For programming, I use an ISP programmer.  I use a cheap Arduino Nano clone board for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can run my ATtiny85 at 16Mhz internal oscillator,  but important: I remarked that I had better results after having burnt the bootloader onto the ATtiny85, even if it is not needed because there is no USB serial chip besides the MCU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But perhaps using avrdude to program the ATtiny85 fuses bits could avoid to burn this useless bootloader (taking 1/4 of flash memory). If someone has a solution, he is welcome.&lt;/p&gt;&#xA;" OwnerUserId="5074" LastEditorUserId="84" LastEditDate="2014-12-06T15:28:55.610" LastActivityDate="2014-12-06T15:28:55.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5332" PostTypeId="2" ParentId="5327" CreationDate="2014-12-05T05:18:48.667" Score="1" Body="&lt;p&gt;I have not actually interacted with the debian packages, but If I'm reading this right, this how they are organized:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;arduino&lt;/strong&gt;: The whole java IDE and avr code libraries&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;arduino-core&lt;/strong&gt;: the libraries and code that comes with arduino to be compiled for avr&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;arduino-mk&lt;/strong&gt;: a makefile for compiling arduino code without the IDE (but no code)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal arduino package has a command line interface, but the code for this is (currently) very closely tied to the java GUI code and cannot be used without the whole thing being installed. To make using the raw atmel avr tools easier, the makefile is available; However, the makefile does not include all of the cpp libraries that come packaged with the arduino installation that a normal arduino sketch would reference (Arduino.h, Servo, SPI, etc). The arduino-core package exists to bring in all this supporting code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine it is done with these three packages so if you already have arduino installed, the makefile will not bring a second copy of all the libraries with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The makefile is a configuration for the &lt;a href=&quot;https://www.gnu.org/software/make/&quot; rel=&quot;nofollow&quot;&gt;gnu make&lt;/a&gt; software. There is some information on the specific usage of the arduino makefile on its github page &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-05T05:27:07.833" LastActivityDate="2014-12-05T05:27:07.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5333" PostTypeId="1" AcceptedAnswerId="5335" CreationDate="2014-12-05T07:35:16.087" Score="0" ViewCount="352" Body="&lt;p&gt;I am looking for a way to control an LED on a circuit board using audio input for learning purposes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written my own speech recognition system using dynamic time warping in Python, but I would like to know if (and maybe what models if not all can do) Arduino can possibly handle the processing of a 70 by 70 O(n^2) matrix traversal with &lt;strong&gt;fft&lt;/strong&gt; or &lt;strong&gt;dct&lt;/strong&gt; operations on audio input divided into 10ms frames.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5107" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:12.357" LastActivityDate="2015-08-07T12:17:12.357" Title="Using Arduino audio to control an LED light" Tags="|led|remote-control|audio|signal-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5334" PostTypeId="2" ParentId="5329" CreationDate="2014-12-05T08:14:26.497" Score="1" Body="&lt;p&gt;The ATtinyX5 does not have &lt;em&gt;any&lt;/em&gt; analog-only pins; all 5 pins are usable as digital I/O (all 6 if you know what you're doing, but if you need to ask how then you're not ready to do so).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-05T08:14:26.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5335" PostTypeId="2" ParentId="5333" CreationDate="2014-12-05T08:18:29.430" Score="0" Body="&lt;p&gt;The Due or Tre may have enough power for this. The Yún may be able to offload it to the more powerful CPU. Every other Arduino will struggle with it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-05T08:18:29.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5336" PostTypeId="2" ParentId="5328" CreationDate="2014-12-05T08:40:56.980" Score="2" Body="&lt;p&gt;Since &lt;code&gt;addr_t&lt;/code&gt; is a character type, I suspect &lt;code&gt;Serial.print()&lt;/code&gt; is trying to output the ASCII character representation of your two values. ASCII codes 0x10 and 0x02 are non-printing characters, so it might just be outputting 0's for lack of anything better to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To output the data as actual numbers, try casting them to integers:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print( static_cast&amp;lt;unsigned int&amp;gt;(childAddr[0]) );&#xA;Serial.print( static_cast&amp;lt;unsigned int&amp;gt;(childAddr[1]) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-05T08:40:56.980" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5337" PostTypeId="2" ParentId="5329" CreationDate="2014-12-05T08:56:33.673" Score="0" Body="&lt;p&gt;As &lt;em&gt;Ingnacio has already pointed out&lt;/em&gt;, &lt;strong&gt;PB0&lt;/strong&gt; to &lt;strong&gt;PB4&lt;/strong&gt; can be used as digital IO ports &lt;strong&gt;without problems&lt;/strong&gt;. It night be a good idea though not to touch &lt;strong&gt;PB6&lt;/strong&gt;, the &lt;code&gt;RESET&lt;/code&gt; pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, this isn't different from an Arduino, where all so-called &lt;em&gt;analog pins&lt;/em&gt; can be used for digital output as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to drive shift registers from an ATtiny85 using SPI, you might want to have a look at the &lt;a href=&quot;https://github.com/JChristensen/tinySPI&quot; rel=&quot;nofollow&quot;&gt;tinySPI&lt;/a&gt; library written by &lt;strong&gt;Jack Christensen&lt;/strong&gt;. &lt;em&gt;Please note that I haven't used this library personally!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-12-05T08:56:33.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5339" PostTypeId="1" CreationDate="2014-12-05T10:15:41.687" Score="5" ViewCount="10954" Body="&lt;p&gt;I have written a code that transmits data over the I2C channel, The device ID and every other stuff is working fine. The only issue being that my code gets stuck at Wire.endTrasnmission().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the issue using Serial debug messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strange thing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i disconnect the SCL line (A5 on arduino Pro Mini), the hang disappears and the code starts to function again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A search brought me to this forum&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=66353.0&quot; rel=&quot;noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=66353.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where a guy talks about the code snippet &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(hang)&#xA;unfreeze();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is this possible, if yes where do i place it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Observation:  The hang goes away if i disconnect the SCL line on either of the arduinos communicating, the sam edoes not happen if i disconnect the SDA.&lt;/p&gt;&#xA;" OwnerUserId="5069" LastEditorUserId="5069" LastEditDate="2014-12-06T04:01:15.753" LastActivityDate="2020-10-21T06:28:48.167" Title="Wire.endTransmission() Hangs" Tags="|i2c|arduino-pro-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5340" PostTypeId="1" CreationDate="2014-12-05T13:35:17.217" Score="0" ViewCount="62" Body="&lt;p&gt;Hi I have this ultrasonic sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.micropik.com/PDF/HCSR04.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.micropik.com/PDF/HCSR04.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this code to read distances:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(5);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigPin, LOW);&#xA;long time = pulseIn(echoPin,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is this: in the datasheet says that the sensor will send 8 pulses at 40khz. Every pulse will take 0.000025 seconds so 8 pulses would be 200 usec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why the delay is only 10 usec if it should be 200usec?&lt;/p&gt;&#xA;" OwnerUserId="4924" LastEditorUserId="42" LastEditDate="2014-12-05T13:52:52.580" LastActivityDate="2017-11-15T11:59:16.673" Title="Ultrassonic sensor" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5341" PostTypeId="1" CreationDate="2014-12-05T15:23:23.317" Score="2" ViewCount="2567" Body="&lt;p&gt;Is it possible to use the galileo's ethernet port through arduino IDE? Or should I buy an arduino ethernet shield? Will I be able to use galileo as a server to which arduino board can send data to?&lt;/p&gt;&#xA;" OwnerUserId="5113" LastEditorUserId="5172" LastEditDate="2014-12-09T17:28:01.273" LastActivityDate="2023-07-06T08:27:12.163" Title="Using Intel Galileo Ethernet Port" Tags="|ethernet|arduino-galileo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5342" PostTypeId="2" ParentId="5340" CreationDate="2014-12-05T15:43:00.053" Score="1" Body="&lt;p&gt;The 10us delay is just your trigger pulse HIGH phase. Refer to the timing diagram on bottom of page two in your datasheet.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-12-05T15:43:00.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5343" PostTypeId="2" ParentId="3880" CreationDate="2014-12-05T18:04:36.500" Score="1" Body="&lt;p&gt;I struggled with this too until I realized this&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Parameters&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;xVal: amount to move along the x-axis - signed char&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;yVal: amount to move along the y-axis - signed char &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;wheel: amount to move scroll wheel - signed char&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note it says signed char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means the value you pass to the Mouse.move is a signed 8-bit. (-128 to 127)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My work around is this below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void moveMouse(int x, int y, int w){&#xA;  x = (int)x / 1.59; //Adjust these two values accordingly. I found out that 100, 100 does &#xA;  y = (int)y / 1.58; //not move 100, 100. It moves 159, 158 for me.&#xA;&#xA;  while(x!=0 || y!=0 || w!=0){&#xA;    int moveX, moveY, moveW;&#xA;    if(x &amp;gt; 0){&#xA;      if(x &amp;gt;= 100){&#xA;        moveX = 100;&#xA;      }else{&#xA;        moveX = x;&#xA;      }&#xA;    }else if (x &amp;lt; 0){&#xA;      if(x &amp;lt;= -100){&#xA;        moveX = -100;&#xA;      }else{&#xA;        moveX = x;&#xA;      }&#xA;    }else{&#xA;      moveX = 0;&#xA;    }&#xA;&#xA;    if(y &amp;gt; 0){&#xA;      if(y &amp;gt;= 100){&#xA;        moveY = 100;&#xA;      }else{&#xA;        moveY = y;&#xA;      }&#xA;    }else if (y &amp;lt; 0){&#xA;      if(y &amp;lt;= -100){&#xA;        moveY = -100;&#xA;      }else{&#xA;        moveY = y;&#xA;      }&#xA;    }else{&#xA;      moveY = 0;&#xA;    }&#xA;&#xA;    if(w &amp;gt; 0){&#xA;      if(w &amp;gt;= 127){&#xA;        moveW = 127;&#xA;      }else{&#xA;        moveW = w;&#xA;      }&#xA;    }else if (w &amp;lt; 0){&#xA;      if(w &amp;lt;= -128){&#xA;        moveW = -128;&#xA;      }else{&#xA;        moveW = w;&#xA;      }&#xA;    }else{&#xA;      moveW = 0;&#xA;    }&#xA;&#xA;    x = x - moveX;&#xA;    y = y - moveY;&#xA;    w = w - moveW;&#xA;&#xA;    Mouse.move(moveX, moveY, moveW);&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5116" LastActivityDate="2014-12-05T18:04:36.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5345" PostTypeId="1" AcceptedAnswerId="5346" CreationDate="2014-12-05T23:12:48.683" Score="0" ViewCount="82" Body="&lt;p&gt;Building a data logging and transmission system here. I've a RedBearLab Blend with built-in BLE capabilities and a (cheap) SD / Data logging shield that looks very suspiciously like it's copied from the Adafruit one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a Stock Arduino Uno board, the Data logging shield works out of the box - both RTC TimeSet and cardinfo come back successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stacking the shield on the Blend, both examples lead nowhere. The TimeSet states that no connection could be made, and the cardinfo says it can't find the card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume it's a pin conflict of some sort, but I'm really unsure what I should do to debug/fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit] As I found out below, the SD Module works now - but I still face the problem of not getting the RTC to work. Neither on the shield nor a Tiny RTC module. Again, both work fine on the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit2] I had basically the same problem for the RTC module as well - see the answer below.&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="26916" LastEditDate="2017-09-08T23:10:33.210" LastActivityDate="2017-09-08T23:10:33.210" Title="Blend with SD Shield" Tags="|pins|bluetooth|arduino-leonardo|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5346" PostTypeId="2" ParentId="5345" CreationDate="2014-12-05T23:20:03.283" Score="0" Body="&lt;p&gt;Sometimes it helps just adding the tags.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Blend is a Arduino Leonardo Chip - &#xA;and as Lady Ada helpfully points out, you need a special SD Library to use this. The advice on &lt;a href=&quot;https://learn.adafruit.com/adafruit-data-logger-shield/for-the-mega-and-leonardo&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-data-logger-shield/for-the-mega-and-leonardo&lt;/a&gt; is everything I needed to get the cardinfo working, especially the     &lt;code&gt;while (!card.init(SPI_HALF_SPEED, 10, 11, 12, 13)) {&lt;/code&gt;&#xA;part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the I2C Pins for the RTC Clock are not the &quot;standard&quot; Analog Pins 4 and 5, but D2 and D3 (see &lt;a href=&quot;http://arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/Wire&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="4603" LastEditorUserId="4603" LastEditDate="2014-12-06T00:06:13.163" LastActivityDate="2014-12-06T00:06:13.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5348" PostTypeId="1" CreationDate="2014-12-06T02:08:29.370" Score="2" ViewCount="162" Body="&lt;p&gt;I am reading Accelerometer signals connected to Arduino board through a serial interface. I am using the RxTx library and following is the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private void initializeSerial() {&#xA;    CommPortIdentifier portId = null;&#xA;    Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();&#xA;&#xA;    while (portEnum.hasMoreElements()) {&#xA;        CommPortIdentifier currentPortIdentifier = (CommPortIdentifier) portEnum.nextElement();&#xA;        for (String portName : PORT_NAMES) {&#xA;            if (currentPortIdentifier.getName().equals(portName)) {&#xA;                portId = currentPortIdentifier;&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    if (portId == null) {&#xA;        System.out.println(&quot;Port not found&quot;);&#xA;        return;&#xA;    }&#xA;&#xA;    try {&#xA;&#xA;        serialPort = (SerialPort) portId.open(this.getClass().getName(), 2000);&#xA;        serialPort&#xA;                .setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);&#xA;&#xA;        input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));&#xA;        output = serialPort.getOutputStream();&#xA;&#xA;        serialPort.addEventListener(this);&#xA;        serialPort.notifyOnDataAvailable(true);&#xA;&#xA;    } catch (Exception e) {&#xA;        System.err.println(&quot;Initialization failed : &quot; + e.toString());&#xA;    }&#xA;}&#xA;&#xA;@Override&#xA;public void serialEvent(SerialPortEvent event) {&#xA;    if (event.getEventType() == SerialPortEvent.DATA_AVAILABLE) {&#xA;        try {&#xA;            String inputLine = input.readLine();&#xA;            String[] inputValues = inputLine.split(&quot;,&quot;);&#xA;            System.out.println(inputLine);&#xA;&#xA;            if (inputValues.length == 10 &amp;amp;&amp;amp; inputValues[0].equals(&quot;STX&quot;)&#xA;                    &amp;amp;&amp;amp; inputValues[inputValues.length - 1].equals(&quot;ETX&quot;)) {&#xA;&#xA;                double classid = 0;&#xA;                double accx = 0;&#xA;                double accy = 0;&#xA;                double accz = 0;&#xA;                boolean num_error = false;&#xA;&#xA;                try {&#xA;&#xA;                    classid = Integer.parseInt(txtClassID.getText());&#xA;                    accx = Double.parseDouble(inputValues[2]);&#xA;                    accy = Double.parseDouble(inputValues[4]);&#xA;                    accz = Double.parseDouble(inputValues[6]);&#xA;                    num_error = false;&#xA;&#xA;                } catch (NumberFormatException numex) {&#xA;                    num_error = true;&#xA;                }&#xA;&#xA;                if (recording) {&#xA;&#xA;                    if (!num_error) {&#xA;                        gestureList.add(new double[] { classid, accx, accy, accz });&#xA;                        System.out.println(&quot;ClassID : &quot; + classid + &quot; \tAdding : &quot;+ accx +&quot;,&quot;+ accy+&quot;,&quot;+ accz);&#xA;                    }&#xA;&#xA;                    System.out.println(&quot;ClassID : &quot; + classid + &quot; \tAdding : &quot; + accx + accy + accz);&#xA;                } else {&#xA;                    if (gestureList.size() &amp;gt; 0) {&#xA;                        gestureCollection.add(gestureList);&#xA;                        System.out.println(&quot;Segment :&quot; + (gestureCollection.size()) + &quot;   Items : &quot;&#xA;                                + gestureList.size());&#xA;                        txtSegments.append(&quot;Segment &quot; + (gestureCollection.size()) + &quot;\tItems : &quot;&#xA;                                + gestureList.size() + &quot;\n&quot;);&#xA;&#xA;                        // comboSegments.addItem(gestureCollection.size());&#xA;&#xA;                        gestureList = new ArrayList&amp;lt;&amp;gt;();&#xA;                    }&#xA;                }&#xA;&#xA;                txtRawData.append(inputLine + &quot;\n&quot;);&#xA;            }&#xA;        } catch (Exception ex) {&#xA;            ex.printStackTrace();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I have is that, I'm reading the values in Windows environment perfectly, without any issues. But in Ubuntu I get data that is damaged and partially read. Here is the Java console output when I did this in ubuntu. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are correct readings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;STX,16564.00,16565.65,-352.00,-431.09,-17840.00,-17941.79,-178.64,-42.72,ETX&#xA;STX,16524.00,16562.53,-440.00,-431.76,-17848.00,-17934.75,-178.63,-42.73,ETX&#xA;STX,16572.00,16563.24,-420.00,-430.88,-17992.00,-17939.05,-178.64,-42.72,ETX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I get readings like this too. (In a considerable amount)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;STX,16580.00,16551.27,-432.00,-438.85,-17936.00,-17922.1724.00,16548.94,-380.00,-439.41,-17880.00,-17921.05,-178.61,-42.71,ETX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9-178.56,-42.75,ETX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.,-454.82,-17944.00,-17916.45,-178.54,-42.72,ETX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;STX,16584.00,16558.19,-464.00,-465.68,-18007416.00,-446.99,-18008.00,-17935.43,-178.56,-42.71,ETX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen, where I can read perfectly in Windows and Not in Ubuntu. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help please? Thank You. &lt;/p&gt;&#xA;" OwnerUserId="3339" LastActivityDate="2014-12-06T02:08:29.370" Title="Incorrectly Reading Serial Using RXTX in Ubuntu" Tags="|serial|arduino-mega|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5349" PostTypeId="1" AcceptedAnswerId="5358" CreationDate="2014-12-06T04:23:45.317" Score="5" ViewCount="1804" Body="&lt;p&gt;I'm working on a line-following robot with my son. We've found a sensor array on Robot Shop that will help us but .. there's two and I'm not sure which will be the best for us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between them, as described in &lt;a href=&quot;https://secure.robotshop.com/media/files/pdf/pololu-qtr-8x-reflectance-sensor-array-user-guide.pdf&quot; rel=&quot;noreferrer&quot;&gt;this PDF&lt;/a&gt; is &quot;The QTR-8A uses a voltage divider for each sensor’s output while the QTR-8RC uses an RC circuit.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is detect which sensor the followed line is triggering. All I need is a yes/no. But I'm too new to this to decide which of these two sensors would be best for me.&lt;/p&gt;&#xA;" OwnerUserId="4843" LastActivityDate="2014-12-06T15:35:44.380" Title="Which reflectance sensor array for a line following robot?" Tags="|sensors|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5350" PostTypeId="1" CreationDate="2014-12-06T05:52:35.957" Score="1" ViewCount="1152" Body="&lt;p&gt;In my design, one arduino pulls a line high on other arduino, the other arduino polls this pin and if that is high sends the data on I2C bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first arduino holds the line high for 100ms using the delay() method, the other arduino is sending the data during this time, but the I2C receive interrupt is not being triggered.&lt;img src=&quot;https://i.stack.imgur.com/S13pj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attached a sequence diagram for a better explanation for what is happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that the delay() method somehow is disabling the I2C ISR from triggering.&lt;/p&gt;&#xA;" OwnerUserId="5069" LastActivityDate="2014-12-06T11:17:18.173" Title="Delay() function and I2C interrupt" Tags="|i2c|arduino-pro-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5351" PostTypeId="1" AcceptedAnswerId="5357" CreationDate="2014-12-06T07:53:35.010" Score="1" ViewCount="15676" Body="&lt;p&gt;I've seen this &lt;a href=&quot;https://www.youtube.com/watch?v=issW8aeM5tY&quot; rel=&quot;nofollow&quot;&gt;video&lt;/a&gt; so I think I can connect it through my wifi router to any device. How can I scan for and discover wifi hotspots and then connect to it? Or is there a way to create wifi hotspot of it's own?&lt;/p&gt;&#xA;" OwnerUserId="3030" LastActivityDate="2017-09-20T12:37:10.260" Title="NRF24L01+ scanning and connecting to wifi hotspots or creating one" Tags="|arduino-mega|wifi|nrf24l01+|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5352" PostTypeId="2" ParentId="5351" CreationDate="2014-12-06T10:00:22.057" Score="2" Body="&lt;p&gt;I believe nRF2401 is low level tx/rx chip working in 2.4GHz band. But it's not WiFi module. To use it as WiFi you probably need implement WiFi stack. I think guy in video set up channel and counting receved data only. &lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-12-06T10:00:22.057" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5354" PostTypeId="2" ParentId="5350" CreationDate="2014-12-06T11:17:18.173" Score="2" Body="&lt;p&gt;Sorry guys, I made a very silly mistake here, i was using Serial.print here in ISR, following the Slave_Receiver example in the Arduino examples. I got a bit carried away with the use of those Serial debug messages and added lots of them, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got this info from &#xA;&lt;a href=&quot;https://stackoverflow.com/questions/17985830/arduino-using-interrupts-freezes-processing-and-serial-output&quot;&gt;https://stackoverflow.com/questions/17985830/arduino-using-interrupts-freezes-processing-and-serial-output&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;checkout answer by &lt;strong&gt;elias&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code does not freeze now. Sorry for the troubles, i hope this helps someone else in return.&lt;/p&gt;&#xA;" OwnerUserId="5069" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-12-06T11:17:18.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5357" PostTypeId="2" ParentId="5351" CreationDate="2014-12-06T15:14:12.963" Score="5" Body="&lt;p&gt;It does seem possible, check out &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=54795.0&quot;&gt;this thread&lt;/a&gt; on Arduino forums, where cpixip worked directly with the NRF24 SPI interface to accomplish that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code he published, in case the link won't be available:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// Poor Man's Wireless 2.4GHz Scanner&#xA;//&#xA;// uses an nRF24L01p connected to an Arduino&#xA;// &#xA;// Cables are:&#xA;//     SS       -&amp;gt; 10&#xA;//     MOSI     -&amp;gt; 11&#xA;//     MISO     -&amp;gt; 12&#xA;//     SCK      -&amp;gt; 13&#xA;// &#xA;// and CE       -&amp;gt;  9&#xA;//&#xA;// created March 2011 by Rolf Henkel&#xA;//&#xA;&#xA;#define CE  9&#xA;&#xA;// Array to hold Channel data&#xA;#define CHANNELS  64&#xA;int channel[CHANNELS];&#xA;&#xA;// greyscale mapping &#xA;int  line;&#xA;char grey[] = &quot; .:-=+*aRW&quot;;&#xA;&#xA;// nRF24L01P registers we need&#xA;#define _NRF24_CONFIG      0x00&#xA;#define _NRF24_EN_AA       0x01&#xA;#define _NRF24_RF_CH       0x05&#xA;#define _NRF24_RF_SETUP    0x06&#xA;#define _NRF24_RPD         0x09&#xA;&#xA;// get the value of a nRF24L01p register&#xA;byte getRegister(byte r)&#xA;{&#xA; byte c;&#xA;&#xA; PORTB &amp;amp;=~_BV(2);&#xA; c = SPI.transfer(r&amp;amp;0x1F);&#xA; c = SPI.transfer(0);  &#xA; PORTB |= _BV(2);&#xA;&#xA; return(c);&#xA;}&#xA;&#xA;// set the value of a nRF24L01p register&#xA;void setRegister(byte r, byte v)&#xA;{&#xA; PORTB &amp;amp;=~_BV(2);&#xA; SPI.transfer((r&amp;amp;0x1F)|0x20);&#xA; SPI.transfer(v);&#xA; PORTB |= _BV(2);&#xA;}&#xA;&#xA;// power up the nRF24L01p chip&#xA;void powerUp(void)&#xA;{&#xA; setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)|0x02);&#xA; delayMicroseconds(130);&#xA;}&#xA;&#xA;// switch nRF24L01p off&#xA;void powerDown(void)&#xA;{&#xA; setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)&amp;amp;~0x02);&#xA;}&#xA;&#xA;// enable RX &#xA;void enable(void)&#xA;{&#xA;   PORTB |= _BV(1);&#xA;}&#xA;&#xA;// disable RX&#xA;void disable(void)&#xA;{&#xA;   PORTB &amp;amp;=~_BV(1);&#xA;}&#xA;&#xA;// setup RX-Mode of nRF24L01p&#xA;void setRX(void)&#xA;{&#xA; setRegister(_NRF24_CONFIG,getRegister(_NRF24_CONFIG)|0x01);&#xA; enable();&#xA; // this is slightly shorter than&#xA; // the recommended delay of 130 usec&#xA; // - but it works for me and speeds things up a little...&#xA; delayMicroseconds(100);&#xA;}&#xA;&#xA;// scanning all channels in the 2.4GHz band&#xA;void scanChannels(void)&#xA;{&#xA; disable();&#xA; for( int j=0 ; j&amp;lt;200  ; j++)&#xA; {&#xA;   for( int i=0 ; i&amp;lt;CHANNELS ; i++)&#xA;   {&#xA;     // select a new channel&#xA;     setRegister(_NRF24_RF_CH,(128*i)/CHANNELS);&#xA;&#xA;     // switch on RX&#xA;     setRX();&#xA;&#xA;     // wait enough for RX-things to settle&#xA;     delayMicroseconds(40);&#xA;&#xA;     // this is actually the point where the RPD-flag&#xA;     // is set, when CE goes low&#xA;     disable();&#xA;&#xA;     // read out RPD flag; set to 1 if &#xA;     // received power &amp;gt; -64dBm&#xA;     if( getRegister(_NRF24_RPD)&amp;gt;0 )   channel[i]++;&#xA;   }&#xA; }&#xA;}&#xA;&#xA;// outputs channel data as a simple grey map&#xA;void outputChannels(void)&#xA;{&#xA; int norm = 0;&#xA;&#xA; // find the maximal count in channel array&#xA; for( int i=0 ; i&amp;lt;CHANNELS ; i++)&#xA;   if( channel[i]&amp;gt;norm ) norm = channel[i];&#xA;&#xA; // now output the data&#xA; Serial.print('|');&#xA; for( int i=0 ; i&amp;lt;CHANNELS ; i++)&#xA; {&#xA;   int pos;&#xA;&#xA;   // calculate grey value position&#xA;   if( norm!=0 ) pos = (channel[i]*10)/norm;&#xA;   else          pos = 0;&#xA;&#xA;   // boost low values&#xA;   if( pos==0 &amp;amp;&amp;amp; channel[i]&amp;gt;0 ) pos++;&#xA;&#xA;   // clamp large values&#xA;   if( pos&amp;gt;9 ) pos = 9;&#xA;&#xA;   // print it out&#xA;   Serial.print(grey[pos]);&#xA;   channel[i] = 0;&#xA; }&#xA;&#xA; // indicate overall power&#xA; Serial.print(&quot;| &quot;);&#xA; Serial.println(norm);&#xA;}&#xA;&#xA;// give a visual reference between WLAN-channels and displayed data&#xA;void printChannels(void)&#xA;{&#xA; // output approximate positions of WLAN-channels&#xA; Serial.println(&quot;&amp;gt;      1 2  3 4  5  6 7 8  9 10 11 12 13  14                     &amp;lt;&quot;);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(57600);&#xA;&#xA; Serial.println(&quot;Starting Poor Man's Wireless 2.4GHz Scanner ...&quot;);&#xA; Serial.println();&#xA;&#xA; // Channel Layout&#xA; // 0         1         2         3         4         5         6&#xA; // 0123456789012345678901234567890123456789012345678901234567890123&#xA; //       1 2  3 4  5  6 7 8  9 10 11 12 13  14                     | &#xA; //&#xA; Serial.println(&quot;Channel Layout&quot;);&#xA; printChannels();&#xA;&#xA; // Setup SPI&#xA; SPI.begin();&#xA; SPI.setDataMode(SPI_MODE0);&#xA; SPI.setClockDivider(SPI_CLOCK_DIV2);&#xA; SPI.setBitOrder(MSBFIRST);&#xA;&#xA; // Activate Chip Enable&#xA; pinMode(CE,OUTPUT);&#xA; disable();&#xA;&#xA; // now start receiver&#xA; powerUp();&#xA;&#xA; // switch off Shockburst&#xA; setRegister(_NRF24_EN_AA,0x0);&#xA;&#xA; // make sure RF-section is set properly &#xA; // - just write default value... &#xA; setRegister(_NRF24_RF_SETUP,0x0F); &#xA;&#xA; // reset line counter&#xA; line = 0;&#xA;}&#xA;&#xA;void loop() &#xA;{ &#xA; // do the scan&#xA; scanChannels();&#xA;&#xA; // output the result&#xA; outputChannels();&#xA;&#xA; // output WLAN-channel reference every 12th line&#xA; if( line++&amp;gt;12 )&#xA; {&#xA;   printChannels();&#xA;   line = 0;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pinout seems to match the NRF24 library pinout.&#xA;Please note that it seems this project does not implement the WiFi stack, but only check a high enough signal ( &gt; -64dBm) for a given channel. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to create a WiFi hotspot, implementing the 802.11 stack is inevitable, and it seems like the Arduino core chip (atmega328) is not suitable for implementing it using software and bit-banging, so a dedicated hardware will be necessary. &lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-06T15:14:12.963" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5358" PostTypeId="2" ParentId="5349" CreationDate="2014-12-06T15:35:44.380" Score="3" Body="&lt;p&gt;The main difference between the two models, as stated in the PDF you provided, is the output they provide to the MCU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The QTR-8A will provide an &lt;strong&gt;Analog&lt;/strong&gt; output, requiring a corresponding analog pin on the microcontroller. The QTR-8RC will provide a &lt;strong&gt;Digital&lt;/strong&gt; output, but will allow the same accuracy of the QTA-8A by measuring the discharge time of the capacitor (HIGH to LOW time), with the advantage of higher accuracy due to the use of RC circuit instead of a voltage divider.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both seems pretty straight forward, but for your needs, the QTR-8RC might seem more compatible, considering the Arduino Uno has 6 analog I/O pins (you didn't mention which Arduino is going to be used, the Arduino Nano has 8 and the Arduino Mega has 16), and that the QTR sensor provides 8 outputs. The way you could accomplish that with QTR-8RC and 8 &lt;strong&gt;digital&lt;/strong&gt; I/O pins is described in the PDF:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Turn on IR LEDs (optional)&lt;/li&gt;&#xA;  &lt;li&gt;Set the I/O line to an output and drive it high&lt;/li&gt;&#xA;  &lt;li&gt;Allow at least 10 us for the 10 nF capacitor to charge&lt;/li&gt;&#xA;  &lt;li&gt;Make the I/O line an input (high impedance)&lt;/li&gt;&#xA;  &lt;li&gt;Measure the time for the capacitor to discharge by waiting for the I/O line to go low&lt;/li&gt;&#xA;  &lt;li&gt;Turn off IR LEDs (optional)&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-06T15:35:44.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5359" PostTypeId="2" ParentId="5274" CreationDate="2014-12-06T15:43:58.033" Score="1" Body="&lt;p&gt;Since you are sending from the Arduino the received serial data back to the C# application (&lt;code&gt;Serial.print(message);&lt;/code&gt;), I would advise to check what you receive on the C# side.&#xA;Register to the DataReceived event of the SerialPort as so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serialPort1.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add an event handler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)&#xA;{&#xA;    SerialPort port = (SerialPort)sender;&#xA;    string data= port.ReadExisting();&#xA;    // check here what data you received, if any&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you could confirm that the Arduino gets the data properly from the C# side to begin with. Next step would be to understand if this &lt;strong&gt;if&lt;/strong&gt; statement treats the data properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (message == '5')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But starting from examination of what you get from the C# side will help you decide where exactly is the problem.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-06T15:43:58.033" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="5360" PostTypeId="1" AcceptedAnswerId="5361" CreationDate="2014-12-06T15:22:50.793" Score="0" ViewCount="5098" Body="&lt;p&gt;I have a SIM900 board which has a serial interface. I'm trying to control it using Arduino Uno. I've tried using SoftwareSerial on pins 10 (RX) and 11 (TX) to talk to my board. It works OK with different baud rates (SIM900 has auto-bauding). I'm connecting pin 10 directly to my board, but pin 11 is connected through a voltage divider in order to lower voltage from 5 V to 2.8 V (SIM900 uses 2.8 V CMOS logic levels).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I want to use Arduino's hardware UART to talk to SIM900. I'm using pins 0 and 1 with similar design as above (also using voltage divider). I just can't get it to work. No matter what I do I can't see any communication. I've tried different baud rates, but it just doesn't work. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600); &#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;&#xA;  delay(10000);&#xA;  Serial.write(&quot;AT\r&quot;);&#xA;  delay(1000);&#xA;  if (Serial.available())&#xA;  {&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I should see a LED light up but nothing happens (SIM900 responds with &quot;\r\nOK\r\n&quot; to &quot;AT\r&quot;). What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="5130" OwnerDisplayName="rubix_addict" LastEditorUserId="26916" LastEditDate="2017-09-10T13:55:13.800" LastActivityDate="2017-09-10T13:55:13.800" Title="Using Arduino's hardware serial to control SIM900" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5361" PostTypeId="2" ParentId="5360" CreationDate="2014-12-06T16:38:07.353" Score="0" Body="&lt;p&gt;2.8V is not high enough to register as a high on an AVR input. You will need to use a level converter to raise the TX line of the SIM900 from 2.8V to 5V.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-06T16:38:07.353" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5362" PostTypeId="1" AcceptedAnswerId="5363" CreationDate="2014-12-06T18:54:44.893" Score="1" ViewCount="3235" Body="&lt;p&gt;I'm working on an Arduino powered Tetris game. To keep track of the pieces that have fallen and become fixed I have an array of bytes &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte theGrid[] = {   &#xA;B00000000,&#xA;B00000000,  &#xA;B00000000,&#xA;B00000000,&#xA;B00000000,&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works great when the well is only 8 LEDs wide, but I need it to be 16 wide. Is there a way to perform bitwise operations on a 16 bit number, like a short? I tried just declaring theGrid as a short, but I'm getting this error no matter what I do.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tetris:62: error: 'B0000000000000000' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason I was using byte is so I could use bitread and bitset. So if an L piece comes down and lands, I can bitset the appropriate bits like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bitSet(theGrid[pixelY], 15-pixelX); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and end up with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;B1000000000000000, B1110000000000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5132" LastEditorUserId="5132" LastEditDate="2014-12-06T19:19:28.390" LastActivityDate="2014-12-06T19:23:35.410" Title="How to use bitset/read on 16bit numbers (Arduino)" Tags="|programming|sketch|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5363" PostTypeId="2" ParentId="5362" CreationDate="2014-12-06T19:23:35.410" Score="3" Body="&lt;p&gt;The main problem that you're having is that &lt;em&gt;binary literals don't exist in C&lt;/em&gt;; the Arduino libraries get around this by having &lt;strong&gt;every single binary value&lt;/strong&gt; from &lt;a href=&quot;http://www.asic-world.com/verilog/syntax1.html#Integer_Numbers&quot; rel=&quot;nofollow&quot;&gt;1'b0&lt;/a&gt; to 8'b1111_1111 defined as a macro in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/binary.h&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;cores/arduino/binary.h&lt;/code&gt;&lt;/a&gt;. The obvious workaround is to use octal, decimal, or hexadecimal literals instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned short theGrid[] = {&#xA;00,&#xA;0,&#xA;0x0,&#xA; ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bitwise operations work as normal.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;theGrid[pixelY] |= _BV(15 - pixelX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-06T19:23:35.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5364" PostTypeId="1" CreationDate="2014-12-06T16:50:05.593" Score="1" ViewCount="767" Body="&lt;p&gt;I got an Arduino UNO which I started using with microc for avr to add more customizations.&#xA;I'm wondering if it is possible to use the Arduino UNO programmer to program other AVR microcontrollers (I know that it is possible using ATmega 328p and 168).&lt;/p&gt;&#xA;" OwnerUserId="7328" OwnerDisplayName="Med.ali" LastEditorUserId="1736" LastEditDate="2014-12-07T07:56:47.733" LastActivityDate="2017-04-27T20:56:37.327" Title="Is it possible to use Arduino UNO programmer for other AVR microcontrollers?" Tags="|avr|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5365" PostTypeId="1" CreationDate="2014-12-06T20:26:03.217" Score="0" ViewCount="742" Body="&lt;p&gt;I hope to find some answers or pointers to a boggling task of mine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having an Arduino DUE that I want to push to its serial limits, I came up with the idea of hooking it up to my rPi via serial at least at 921600 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically both seem capable of that. A loopback test with the rPi was successful up to 921600 and I've managed to get a &quot;good&quot; quality transmission up to 576000 bps already (error-rate should be around 1,3%), but anything higher gets problematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;DebugConsole, CuteCom and minicom don't have support for any speeds in-between, so either 921600 works or it doesn't&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;minicom supports 1.000.000 baud, but this would still mean a ~5% error-rate, which is according to my calculations and tests, but they are in question here as well ...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From the Atmel Doc I've got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BaudRate = MCK ⁄ CD × 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From that I've derived that with the 84MHz Due a baudrate of 1.050.000 would be the actual rate I should aim for, as CD must(?) be an INT.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1050000 = 84000000 / 5 * 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is my assumption of an optimal 1.050.000 baudrate right? &lt;/li&gt;&#xA;&lt;li&gt;Is it possible to use a different clock for the baudrate generator than the 84MHz?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Remarks:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Clock of 14,7456MHz should be optimal as it is equal to 921600 * 16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using TXD/RXD1 on the Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Due is transmitting on 921600 but the data is scrambled due to the errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case somebody is wondering, my hope is that it is easier to adjust the arduino to 921600 baud than it is to setup a tool and configure the rPi to support 1050000 baud - but I am working both ways, only that with the rPi I know what to do ..&lt;/p&gt;&#xA;" OwnerUserId="5097" LastEditorUserId="84" LastEditDate="2014-12-07T07:53:29.100" LastActivityDate="2016-09-26T19:03:21.487" Title="Is the used clock for the Baudrate generator adjustable on an arduino due?" Tags="|serial|arduino-due|uart|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5366" PostTypeId="2" ParentId="5364" CreationDate="2014-12-06T20:41:25.147" Score="2" Body="&lt;p&gt;The AVR microcontrollers that support ISP are all tinyAVRs other than the 4/5/9/10/20/40, and all megaAVRs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATtiny4/5/9/10/20/40 requires TPI (Tiny Programming Interface). AVR XMEGA devices require the use of PDI (Program and Debug Interface). Neither can be programmed using ArduinoISP.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-12-09T18:44:11.320" LastActivityDate="2014-12-09T18:44:11.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5367" PostTypeId="2" ParentId="5365" CreationDate="2014-12-06T21:13:39.297" Score="2" Body="&lt;p&gt;The clock of the transmitter and receiver have to be matched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In theory&lt;/strong&gt;, the worst case error tolerable is 1/2 bit per byte.  For the 10 bit byte (1 start, 8 data, 1 stop) that leads to a +/- 5% clock error tolerance that you will find reported.  Note that this actually depends on the specific UART implementation, either chip or internal.  There are various methods of sampling that make some UART's better than others.  It is common to sample in the middle, but some chips have methods to improve noise rejection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the receiver side, do not rely on what the terminal program is showing you.  Few applications would manipulate the clock directly; they commonly just call an API with an enumerator for the speed.  You need to know exactly what hardware the receiver side has and its clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In practice&lt;/strong&gt;, the theoretical limit is not going to work.  At high data rates, the noise on the cable will eat away at that safe margin.  More common recommendations will say +/- 1% which allows for noise on the edges of the bit transitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The noise on the signal is important at these data rates.  You indicate you are using TXD/RXD which is just logic level.  You cannot connect logic level any significant distance.  If the two are directly next to each other with excellent attention to wiring, you might have a chance.  Adding transceivers will help your chances significantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note that changing to 7 bits helps.  Do you need 8 bit data?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in summary:&#xA;- The receiver is more important than the transmitter, but they both have to match.  If you can't find a match of clocks to 1%, you will have data errors.&#xA;- At these speeds, the cabling and connection is critical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This article at Maxim is a good starter &lt;a href=&quot;http://www.maximintegrated.com/en/app-notes/index.mvp/id/2141&quot; rel=&quot;nofollow&quot;&gt;Maxim &quot;Determining Clock Accuracy Requirements for UART Communications&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2014-12-06T21:13:39.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5368" PostTypeId="1" CreationDate="2014-12-06T21:16:59.380" Score="0" ViewCount="152" Body="&lt;p&gt;I'm doing my first baby-steps to build tools using Arduino. I'd like to know if there is a way to write python scripts to build programs for Arduino. Most of IDEs I found are non-supported IDEs. Is there any &quot;recommended&quot; IDEs that I should use.&lt;/p&gt;&#xA;" OwnerUserId="5134" LastActivityDate="2014-12-07T09:42:56.527" Title="Which IDE should I use to write Pythonic-programs for Arduino" Tags="|arduino-uno|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5369" PostTypeId="2" ParentId="5368" CreationDate="2014-12-06T23:24:37.933" Score="1" Body="&lt;p&gt;The recommended IDE for writing &lt;strong&gt;C/C++&lt;/strong&gt; for Arduino for beginners is the formal Arduino IDE, of which you can read more on the &lt;a href=&quot;http://arduino.cc/en/main/software&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduino.cc website&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; is an interpreter language, and as such, require an interpreter running on the target machine. Unfortunately, the Arduino does not natively support running an Python interpreter, although some efforts has been made in that direction, for example the &lt;a href=&quot;https://code.google.com/p/python-on-a-chip/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python on a chip project&lt;/a&gt;, or the &lt;a href=&quot;https://github.com/vascop/Python-Arduino-Proto-API-v2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Python Arduino Proto API v2&lt;/a&gt;. &#xA;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/105/programming-an-arduino-using-python-rather-than-c-c&quot;&gt;this SO question&lt;/a&gt; for more details. If you go with any of these options, the IDE you would use would be your favorite Python IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that both projects have their downsides, and actually there is no real alternative equivalent to running compiled C/C++ code on the Arduino. If you have strong Python programming abilities, this shouldn't be too hard for you as well :) &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2014-12-07T09:42:56.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5370" PostTypeId="1" CreationDate="2014-12-07T06:35:24.550" Score="1" ViewCount="849" Body="&lt;p&gt;I'm playing around with an IR receiver and an RGB led.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had it up and running, until I changed around some code. The remote seeming stopped working, but after looking at the values in the Serial Monitor it appeared that the values that were being printed out weren't the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After playing around a bit I found that if analogWrite is run on pin 11, the value changes. Why is this so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int ir_recv_pin = 2;&#xA;&#xA;IRrecv irrecv(ir_recv_pin);&#xA;&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    irrecv.enableIRIn(); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (irrecv.decode(&amp;amp;results)) &#xA;    {&#xA;        //Serial.println(results.value);&#xA;        Serial.println(results.value == CH_MINUS);&#xA;        Serial.println(results.value);&#xA;        Serial.println(CH_MINUS);&#xA;&#xA;        analogWrite(11, 125);&#xA;        irrecv.resume();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output is as such when pressing the button twice in a row (without holding the button down):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;16753245&#xA;16753245&#xA;0&#xA;3810010651&#xA;16753245&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Initially the values come out as expected (16753245), but after the analogWrite, the value changes (3810010651).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the &lt;a href=&quot;http://arduino.cc/en/Reference/analogWrite&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; it says that pin 11 runs at 980Hz. Is this why the value changes? If so, why?&lt;/p&gt;&#xA;" OwnerUserId="5062" LastActivityDate="2014-12-07T08:04:05.057" Title="analogWrite causes value from IR receiver to change" Tags="|analogwrite|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5371" PostTypeId="1" CreationDate="2014-12-07T07:04:37.713" Score="0" ViewCount="4252" Body="&lt;p&gt;Is it possible to use &lt;a href=&quot;https://www.techshopbd.com/product-categories/sensors-9925/875/640x480-cmos-camera-techshop-bangladesh&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; with Arduino to record and store videos on memory card?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if someone has already done it, a tutorial link would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="5025" LastActivityDate="2014-12-07T08:14:41.460" Title="Record video with CMOS camera using Arduino" Tags="|arduino-uno|sensors|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5372" PostTypeId="2" ParentId="5370" CreationDate="2014-12-07T08:04:05.057" Score="3" Body="&lt;p&gt;Because IRremote uses timer 2 by default, and the PWM output on pin 11 is generated via OC2A. Either edit &lt;code&gt;IRremoteInt.h&lt;/code&gt; to use timer 1, use a pin on timer 1 for PWM, or frob OCR2A directly instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-07T08:04:05.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5373" PostTypeId="2" ParentId="5371" CreationDate="2014-12-07T08:14:41.460" Score="3" Body="&lt;p&gt;Arduinos have two major drawbacks:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Not enough memory.&lt;/li&gt;&#xA;&lt;li&gt;Way too slow.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There's a shield to help you do that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://nootropicdesign.com/ve/&quot; rel=&quot;nofollow&quot;&gt;http://nootropicdesign.com/ve/&lt;/a&gt;&#xA;&lt;a href=&quot;http://blog.arduino.cc/2011/03/24/arduino-computer-vision-with-video-experimenter-shield/&quot; rel=&quot;nofollow&quot;&gt;http://blog.arduino.cc/2011/03/24/arduino-computer-vision-with-video-experimenter-shield/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2014-12-07T08:14:41.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5374" PostTypeId="1" CreationDate="2014-12-07T11:11:00.013" Score="2" ViewCount="3188" Body="&lt;p&gt;So I was going to make a project with the &lt;a href=&quot;http://drcharlesbell.blogspot.se/2013/04/introducing-mysql-connectorarduino_6.html&quot; rel=&quot;nofollow&quot;&gt;MySQL Connector/Arduino&lt;/a&gt;; a temperature log. I started out by experimenting with the example code from the website linked above. Not once did I manage to actually connect to the server; the mysql_connect() function always returns false. After several hours of intense googling, innumerable irritated noises and more, I decided to ask here on Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SPI.h&quot;&#xA;#include &quot;Ethernet.h&quot;&#xA;#include &quot;sha1.h&quot;&#xA;#include &quot;mysql.h&quot;&#xA;&#xA;byte mac_addr[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x69, 0xAC };&#xA;byte ip_addr[] = { 192, 168, 10, 127 };&#xA;byte dns_addr[] = { 192, 168, 10, 1 };&#xA;byte gateway_addr[] = { 192, 168, 10, 1 };&#xA;byte netmask[] = { 255, 255, 255, 0 };&#xA;IPAddress server_addr(192, 168, 2, 100);&#xA;&#xA;Connector my_conn; // The Connector/Arduino reference&#xA;&#xA;char user[] = &quot;&quot;;&#xA;char password[] = &quot;&quot;; //the credentials are correct in my code&#xA;char INSERT_SQL[] = &quot;INSERT INTO test_arduino.hello VALUES ('Hello, MySQL!');&quot;;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Ethernet.begin(mac_addr, ip_addr, dns_addr, gateway_addr, netmask);     //Yes, I know this is way more than necessary, but just to play it safe&#xA;  delay(1000);&#xA;  Serial.print(&quot;IP: &quot;);&#xA;  Serial.println(Ethernet.localIP()); // debugging&#xA;  Serial.println(&quot;Connecting...&quot;);&#xA;  if (my_conn.mysql_connect(server_addr, 3306, user, password)) //connect to database&#xA;  {&#xA;     delay(500);&#xA;     my_conn.cmd_query(INSERT_SQL);&#xA;     Serial.println(&quot;Query Success!&quot;);&#xA;  }&#xA;  else&#xA;    Serial.println(&quot;Connection failed.&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is &lt;strong&gt;greatly&lt;/strong&gt; appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rasmus &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Looks like I'm not even getting through to reaching the server and attempting to log in. I enabled the general query logs, yet I get nothing when trying to connect. Also, I can ping both the Arduino and the MySQL server from this computer. I guess that rules out a faulty shield and network setup.&lt;/p&gt;&#xA;" OwnerUserId="1414" LastEditorUserId="1414" LastEditDate="2014-12-07T13:57:20.597" LastActivityDate="2017-05-30T16:23:30.830" Title="MySQL Connector/Arduino issues - not connecting" Tags="|arduino-uno|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5375" PostTypeId="1" CreationDate="2014-12-07T11:29:35.643" Score="1" ViewCount="230" Body="&lt;p&gt;Okay, so I'm using an Arduino Uno R3 and I wanted to start of my own home automation project. I have a 4 channel 12V relay board and I normally connect it to a 12V 500mA adapter. What is the maximum wattage bulb (or CFL) that I can power with this configuration?&lt;/p&gt;&#xA;" OwnerUserId="5141" LastActivityDate="2015-01-06T12:09:26.117" Title="Using a relay to control a lamp" Tags="|arduino-uno|relay|automatization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5376" PostTypeId="2" ParentId="5375" CreationDate="2014-12-07T11:38:03.860" Score="1" Body="&lt;p&gt;Unless you feel like starting a fire, none. Find a 220V 2A relay with a 5V coil and use that instead, switching the hot wire and not the neutral.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-07T11:38:03.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5377" PostTypeId="1" CreationDate="2014-12-07T17:30:17.263" Score="3" ViewCount="1532" Body="&lt;p&gt;I'm working on arduino based RGB LED strip controller.&lt;br&gt;&#xA;This simple schematic was used to control 12V channels via 5V PWM signal from arduino:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wcaaj.gif&quot; alt=&quot;https://learn.adafruit.com/system/assets/assets/000/002/692/medium800/led_strips_ledstripfet.gif?1396785823&quot;&gt;&lt;br&gt;&#xA;I have also connected an HC-05 bluetooth module to be able to control it using android phone.&lt;br&gt;&#xA;Android application, created for this project, is sending 4 bytes to set mode, red, green and blue colors. It looks like {0,255,0,0} to set static red color, {1,0,0,0} to start fade mode and {2,0,0,0} to start blink mode.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my first demo video of this project:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=_UuVex4Qkn8&quot; rel=&quot;nofollow noreferrer&quot;&gt;click here&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that my code works perfectly on Arduino Mega 1280, but when I use Arduino Nano it works only with manual mode and blink mode. If I send {1,0,0,0} to turn on fade mode, LED strip starts to increase random color brightness and stops, before it gets to max value. In a moment LED strip turns off and doesn't react to bluetooth commands. Reset button helps in this situation.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure, but I think there is not enough SRAM (only 2KB) on Arduino Nano to process fade mode data.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Source code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(12, 13);&#xA;&#xA;#define REDPIN 6&#xA;#define GREENPIN 3&#xA;#define BLUEPIN 9&#xA;&#xA;#define FADESPEED 10&#xA;#define PANICSPEED 425&#xA;&#xA;//0 - red&#xA;//1 - green&#xA;//2 - blue&#xA;int fadeColor = 0;&#xA;int panicColor = 0;&#xA;&#xA;//values (brightness) for red, green and blue colors [0; 255]&#xA;int colors[] = {0, 0, 0};&#xA;&#xA;long previousTime = 0;&#xA;&#xA;//0 - manual, 1 - fade, 2 - blink&#xA;int ledMode = 0;&#xA;&#xA;int fadeAmount = 1;&#xA;&#xA;//if color is selected, it'll change brightness;&#xA;//when we got 0 or 255 brightness we'll change&#xA;//this flag and select next color in loop()&#xA;boolean fadeColorSelected = false;&#xA;&#xA;void setup() {&#xA;  pinMode(REDPIN, OUTPUT);&#xA;  pinMode(GREENPIN, OUTPUT);&#xA;  pinMode(BLUEPIN, OUTPUT);&#xA;  mySerial.begin(9600);&#xA;&#xA;  randomSeed(0);&#xA;}&#xA;&#xA;void loop() {&#xA;  long currentTime = millis();&#xA;&#xA;  //data format - 4 bytes {mode, red, green, blue}&#xA;  if (mySerial.available() &amp;gt; 3) {&#xA;    ledMode = mySerial.read();&#xA;    int red = mySerial.read();&#xA;    int green = mySerial.read();&#xA;    int blue = mySerial.read();&#xA;    colors[0] = constrain(red, 0, 255);&#xA;    colors[1] = constrain(green, 0, 255);&#xA;    colors[2] = constrain(blue, 0, 255);&#xA;  }&#xA;&#xA;  switch (ledMode) {&#xA;    //manual mode - just set received color on the led strip&#xA;    case 0:&#xA;      setColor();&#xA;      break;&#xA;    //fade mode - if color is selected, we'll &#xA;    //increase/decrease it's brightness by fadeAmount&#xA;    case 1:&#xA;      if (currentTime - previousTime &amp;gt; FADESPEED) {&#xA;        //change color (we can't choose the same color as previous &#xA;        //and we can't choose the color, if it's the last one,&#xA;        //because at least 1 color should be always ON&#xA;        if (!fadeColorSelected) {&#xA;          int randomColor = fadeColor;&#xA;          while (randomColor == fadeColor || isColorAlone(randomColor)) {&#xA;            randomColor = random(3);&#xA;          }&#xA;          fadeColor = randomColor;&#xA;          fadeColorSelected = true;&#xA;        }&#xA;        //depending on current brightness of selected color&#xA;        //we'll either increase, or decrease it's brightness&#xA;        if (colors[fadeColor] == 0) {&#xA;          fadeAmount = abs(fadeAmount);&#xA;        } else if (colors[fadeColor] == 255) {&#xA;          fadeAmount = -abs(fadeAmount);&#xA;        }&#xA;        colors[fadeColor] += fadeAmount;&#xA;        setColor();&#xA;        //when we got to max/min brightness, we should change current fadeColor&#xA;        if (colors[fadeColor] == 0 || colors[fadeColor] == 255) {&#xA;          fadeColorSelected = false;&#xA;        }&#xA;        previousTime = currentTime;&#xA;      }&#xA;      break;&#xA;    case 2:&#xA;      if (currentTime - previousTime &amp;gt; PANICSPEED) {&#xA;        int randomColor = panicColor;&#xA;        while (randomColor == panicColor || isColorAlone(randomColor)) {&#xA;          randomColor = random(3);&#xA;        }&#xA;        panicColor = randomColor;&#xA;        if (colors[panicColor] == 0) {&#xA;          colors[panicColor] = 255;&#xA;        } else {&#xA;          colors[panicColor] = 0;&#xA;        }&#xA;        setColor();&#xA;        previousTime = currentTime;&#xA;      }&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;void setColor(int r, int g, int b) {&#xA;  analogWrite(REDPIN, r);&#xA;  analogWrite(GREENPIN, g);&#xA;  analogWrite(BLUEPIN, b);&#xA;}&#xA;&#xA;void setColor() {&#xA;  analogWrite(REDPIN, colors[0]);&#xA;  analogWrite(GREENPIN, colors[1]);&#xA;  analogWrite(BLUEPIN, colors[2]);&#xA;}&#xA;&#xA;boolean isColorAlone(int colorNumber) {&#xA;  if (colors[colorNumber] == 0)&#xA;    return false;&#xA;  for (int i = 0; i &amp;lt; 3; i++) {&#xA;    if (i != colorNumber &amp;amp;&amp;amp; colors[i] &amp;gt; 0) {&#xA;      return false;&#xA;    }&#xA;  }&#xA;  return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any ideas why it happens?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is not enough SRAM, how can I optimize this code to solve the problem?  &lt;/p&gt;&#xA;" OwnerUserId="5006" LastEditorUserId="4131" LastEditDate="2015-08-04T13:31:53.680" LastActivityDate="2015-08-04T13:31:53.680" Title="Arduino sketch works on ATmega1280, but doesn't work on ATmega328 (Arduino Nano)" Tags="|led|bluetooth|android|sram|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5378" PostTypeId="1" AcceptedAnswerId="14453" CreationDate="2014-12-07T19:59:33.423" Score="1" ViewCount="240" Body="&lt;p&gt;I built my own Arduino UNO for a project at school. I think I have got the USB bootloader and Windows drivers all situated as the UNO shows up as an UNO in the device manager. When I try to load a sketch I get the error: avrdude: stk500_getsync(): not in sync: resp=0x10. (previously I received the same message with the message ending with resp=0x00)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I loaded a serial echo program using the ICSP and sent the message &quot;serial test&quot; to the UNO. I received this message back: {u{m}o¿wu{w&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me troubleshoot this problem as I have ran out of things to test or look into. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Added requested pictures of TX and RX. These were taken at Pin 0 and 1 of the headers. The scope showed the same results at the pins of the 328P but I couldn't operate the scope and hold the probe at the same time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vvzet.jpg&quot; alt=&quot;Pin 0&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PyJS5.jpg&quot; alt=&quot;Pin 1&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5145" LastEditorUserId="5145" LastEditDate="2014-12-07T21:33:39.253" LastActivityDate="2020-05-13T21:55:26.467" Title="Garbled serial on custom arduino UNO" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="5380" PostTypeId="1" CreationDate="2014-12-07T23:30:32.193" Score="1" ViewCount="1845" Body="&lt;p&gt;I am currently in an introductory assembly language class.&#xA;My assignment is to use a sparkfun joystick shield kit to do something with an arduino uno. I figure turning on LEDs is the easiest. We must program it in AVR assembly(note: we have only used nasm assembly all semester).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really know how this needs to be done, but I would like the lights to turn on when a button is pressed (one LED per button). I also want to use the analog pins to have the joystick LEDs fade in and out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;below is the code I have right now, and don't have the equipment to test it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I on the right track, or is it a horrible mess?&#xA;The professor was referring to the arduino pins with hex, but I couldn't find a mapping of the pins and their hex values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.include &quot;/usr/local/include/atmega32u4.def&quot;&#xA;&#xA;        .global  main&#xA;&#xA;        .section .text&#xA;&#xA;&#xA;main:&#xA;&#xA;        cbi     PortD, 2            ; joystick button&#xA;        cbi     PortD, 3            ; right button&#xA;        cbi     PortD, 4            ; up button&#xA;        cbi     PortD, 5            ; down button&#xA;        cbi     PortD, 6            ; left button&#xA;&#xA;        cbi     PortC, 0            ; joystick vertical output&#xA;        cbi     PortC, 1            ; joystick horizontal output&#xA;&#xA;&#xA;        ldi     r16, 0x7c           ; select pins 2-6 for button input mask&#xA;        in      ddrd, r16           ; set digital button pins as input&#xA;        ldi     r17, 0x03           ; select pins 0 &amp;amp; 1 for joystick input&#xA;        in      ddrc, r17           ; set analog joystick pins as input&#xA;&#xA;        ldi     r18, 0x1f           ; select pins 8-12 for button LED output&#xA;        out     ddrb, r18           ; set digital button LED pins as output&#xA;        ldi     r18, 0x0c           ; select pins 2 &amp;amp; 3 for joystick LED ouput&#xA;        out     ddrc, r18           ; set analog joystick LED pins as output&#xA;&#xA;loop:&#xA;&#xA;        ldi     r20, PortD          ; read in from digital pins 0-7&#xA;        and     r20, r16            ; apply button input mask&#xA;        mov     r20, r20 &amp;gt;&amp;gt; 2       ; shift left twice&#xA;        sts     PortB, r20          ; turn on LEDs of pushed buttons&#xA;&#xA;        ldi     r20, PortC          ; read in from analog pins&#xA;        and     r20, r17            ; apply joystick input mask&#xA;        mov     r20, r20 &amp;gt;&amp;gt; 2       ; shift left twice&#xA;        sts     PortC, r20          ; turn on LEDs of joystick movement&#xA;        rjmp    loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5150" LastEditorUserId="2881" LastEditDate="2014-12-08T16:46:02.473" LastActivityDate="2019-09-16T11:12:19.640" Title="Arduino uno AVR assembly with LEDs" Tags="|arduino-uno|led|shields|assembly|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="5381" PostTypeId="1" AcceptedAnswerId="5382" CreationDate="2014-12-08T04:38:32.513" Score="2" ViewCount="350" Body="&lt;p&gt;I know little about electronics in general. I wanted to connect Arduino, and play a tone using tone() through my home speakers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used a 1/8'' audio jack and connect ground to ground and left/right to pin 2. Run it and it was too loud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I read the specification and it says,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input impedance = 20 kOhm &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input sensibility = 400mV +/- 50mV&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino sends 5V so that should be a lot. Did I damage my speaker? They still work.&lt;/p&gt;&#xA;" OwnerUserId="5103" LastActivityDate="2014-12-08T04:43:19.633" Title="Arduino to Home Speakers" Tags="|audio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5382" PostTypeId="2" ParentId="5381" CreationDate="2014-12-08T04:43:19.633" Score="2" Body="&lt;p&gt;It's probably not damaged, but you shouldn't do it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the 5V signal down to 400mV you need to create a voltage divider. As such you will need a:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5V / (400mV / 20kohm) − 20kohm = 230kohm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;resistor between the pin and the input. 220kohm should be close enough.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-08T04:43:19.633" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5383" PostTypeId="1" CreationDate="2014-12-08T05:30:55.967" Score="1" ViewCount="356" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CIrQN.jpg&quot; alt=&quot;77 bit serial waveform at 1.024Mbaud&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading a 1.024m baud rate 77 bit stream from a serial encoder- &lt;code&gt;begin.serial1(1024000);&lt;/code&gt; is accepted - but no idea if UART can actually run there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the screen grab, channel 7 is a 8 microsecond clock pulse generated by the Arduino, channel 6 is the encoder response - always begins 13 microseconds after rising edge of clock pulse, first part is always 10101101, after that it's pretty random as encoder rotates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried unsuccessfully to read the pins at that speed, no way, then tried reading the repeating data at synchronous microseconds +1 to try reading one bit at a time through sequential 77 bit words while not rotating - but clocking varies in Arduino program by up to 8 microseconds over the 2 millisecond repeating patterns though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the serial read through serial1 port, getting some data, but random... with no terminator to rely on, wondering if anyone has a suggestion as to how to clear/load serial buffer after a long pause (long being almost two milliseconds) followed by the 10101101 that always starts the next read (but could possibly repeat inside of it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a newbie to these things, just tinkering around thought decoding a serial encoder would be fun... many many many hours later, have learned a bit about them and more so learned how little I know about them :)&lt;/p&gt;&#xA;" OwnerUserId="4598" LastEditorUserId="10794" LastEditDate="2015-10-03T04:20:42.163" LastActivityDate="2016-03-01T08:09:41.680" Title="Arduino Mega read of serial encoder read at 1,024,000 baudrate?" Tags="|serial|hardware|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5384" PostTypeId="2" ParentId="4877" CreationDate="2014-12-08T08:22:36.530" Score="2" Body="&lt;p&gt;Change first line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // Set PB1/2 as outputs.&#xA;    DDRB |= (1 &amp;lt;&amp;lt; DDB1) | (1 &amp;lt;&amp;lt; DDB2);`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     // Set PB5/6 as outputs. [**Digital pin 11,12 on Arduino Mega!**]&#xA;    DDRB |= (1 &amp;lt;&amp;lt; DDB5) | (1 &amp;lt;&amp;lt; DDB6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now your PWM should work, but on digital pins 11 &amp;amp; 12 [Arduino Mega].&lt;/p&gt;&#xA;" OwnerUserId="5124" LastEditorUserId="5124" LastEditDate="2014-12-08T08:30:37.460" LastActivityDate="2014-12-08T08:30:37.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5386" PostTypeId="1" AcceptedAnswerId="5394" CreationDate="2014-12-08T11:48:00.287" Score="2" ViewCount="5322" Body="&lt;p&gt;I've been playing with a GY521 breakout recently with the MPU6050 chip on it, though i've hit a bit of a problem that I can't quite work out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know when I rotated the board I rotated ~90 degrees about the Y axis, and using the sensitivity numbers from the datasheet (131) and integrating i've managed to get something that looks believable from the gyroscope, but am having problems with the accelerometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a number of sources, &lt;a href=&quot;http://www.geekmomprojects.com/gyroscopes-and-accelerometers-on-a-chip/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this being one of them&lt;/a&gt;, I've managed to get the three equations seen on here, however when I apply them to either the raw or scaled data (as they're scalers is shouldn't make a difference?) I get a set of data that varies from 0 to 90, but only on the X and Z axes, while nothing happens to the Y.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Updated to include code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050.h&quot;&#xA;#include &quot;Wire.h&quot;&#xA;&#xA;MPU6050 accelgyro;&#xA;&#xA;int16_t ax, ay, az, gx, gy, gz;&#xA;&#xA;double timeStep, time, timePrev;&#xA;double arx, ary, arz, grx, gry, grz, gsx, gsy, gsz, rx, ry, rz;&#xA;&#xA;int i;&#xA;double gyroScale = 131;&#xA;&#xA;void setup() {&#xA;&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  accelgyro.initialize();&#xA;&#xA;  time = millis();&#xA;&#xA;  i = 1;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // set up time for integration&#xA;  timePrev = time;&#xA;  time = millis();&#xA;  timeStep = (time - timePrev) / 1000; // time-step in s&#xA;&#xA;  // collect readings&#xA;  accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;  // apply gyro scale from datasheet&#xA;  gsx = gx/gyroScale;   gsy = gy/gyroScale;   gsz = gz/gyroScale;&#xA;&#xA;  // calculate accelerometer angles&#xA;  arx = (180/3.141592) * atan(ax / sqrt(square(ay) + square(az))); &#xA;  ary = (180/3.141592) * atan(ay / sqrt(square(ax) + square(az)));&#xA;  arz = (180/3.141592) * atan(sqrt(square(ay) + square(ax)) / az);&#xA;&#xA;  // set initial values equal to accel values&#xA;  if (i == 1) {&#xA;    grx = arx;&#xA;    gry = ary;&#xA;    grz = arz;&#xA;  }&#xA;  // integrate to find the gyro angle&#xA;  else{&#xA;    grx = grx + (timeStep * gsx);&#xA;    gry = gry + (timeStep * gsy);&#xA;    grz = grz + (timeStep * gsz);&#xA;  }  &#xA;&#xA;  // apply filter&#xA;  rx = (0.1 * arx) + (0.9 * grx);&#xA;  ry = (0.1 * ary) + (0.9 * gry);&#xA;  rz = (0.1 * arz) + (0.9 * grz);&#xA;&#xA;  // print result&#xA;  Serial.print(i);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(timePrev);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(time);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(timeStep, 5);   Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(ax);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(ay);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(az);   Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(gx);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(gy);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(gz);   Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(arx);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(ary);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(arz);   Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(grx);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(gry);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(grz);   Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(rx);   Serial.print(&quot;\t&quot;);&#xA;  Serial.print(ry);   Serial.print(&quot;\t&quot;);&#xA;  Serial.println(rz);&#xA;&#xA;  i = i + 1;&#xA;  delay(50);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jssg5.png&quot; alt=&quot;plottedResults&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strikes me as a little odd, as I was expecting only a rotational change in Y.  Any suggestions? &lt;/p&gt;&#xA;" OwnerUserId="4265" LastEditorUserId="4265" LastEditDate="2014-12-08T23:20:13.723" LastActivityDate="2014-12-09T00:57:07.487" Title="Calculating Angles from MPU6050" Tags="|arduino-uno|accelerometer|gyroscope|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5388" PostTypeId="1" CreationDate="2014-12-08T17:03:29.630" Score="0" ViewCount="1265" Body="&lt;p&gt;HW:&#xA;2 Arduino ProMini 16Mhz, 5V&#xA;Software serial directly connected using male jumpers on bredboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have creates a software serial port for communication between two arduinos, &lt;strong&gt;Parent&lt;/strong&gt; and &lt;strong&gt;child&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as per the documentation &#xA;&lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerialAvailable&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SoftwareSerialAvailable&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mySerial.available()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should return the number of bytes available in the buffer.&#xA;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mySerial.read(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should give me the byte or return -1 (255) on error.&#xA;&lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerialRead&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SoftwareSerialRead&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my code snippet where i read the values &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(child1.available() &amp;gt; 0){&#xA;    Serial.print(&quot;ParentReceived Something from child 1\n&quot;);&#xA;    while(child1.available()){&#xA;      recvBuffer1[i] = child1.read();&#xA;      Serial.print(recvBuffer1[i], DEC); Serial.print(&quot; &quot;);&#xA;      Serial.print(i, DEC); Serial.print(&quot; &quot;);&#xA;      i++;&#xA;      if(i == FRAME_SIZE) break;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the Serial outputs are for debugging, &#xA;The condition for while is true. we go inside.&#xA;Now what i receive with child1.read() is the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ParentReceived Something from child 2&#xA;255 0 255 1 255 2 255 3 255 4 255 5 255 6 255 7 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;all i see is 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what i did:&#xA;     I first suspected the child of sending these data, but i used a TTL to USB converter to directly read the values being sent by the child and they are received correctly as they should be. even if i TAP the serial ports to another&#xA;TTL to USB converter i get 255 on my arduino Serial monitor and the correct data on the sniffer.&lt;/p&gt;&#xA;" OwnerUserId="5069" LastActivityDate="2017-01-08T13:49:10.100" Title="Ambiguity in Software Serial" Tags="|arduino-pro-mini|softwareserial|uart|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5389" PostTypeId="1" CreationDate="2014-12-08T10:15:37.377" Score="1" ViewCount="8385" Body="&lt;p&gt;Does anybody know where to find an updated scematics of Arduino Nano V3? All the Nano drawings I found (even in the Arduino official site) are based on ATMEGA 168 , no one including ATMEGA 328!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mike&lt;/p&gt;&#xA;" OwnerDisplayName="Mike Dan" LastEditorUserId="42" LastEditDate="2015-04-10T16:29:47.523" LastActivityDate="2019-07-12T06:28:36.630" Title="arduino nano V3 updated schematics" Tags="|arduino-nano|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="5393" PostTypeId="1" CreationDate="2014-12-08T22:13:56.970" Score="1" ViewCount="289" Body="&lt;p&gt;Or at least that's what I believe is the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to add a bipolar LED library to my sketch to get them to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it is now I only have it activated by a specified bit so it can properly drive yellow. Green and Red were working fine (the flickering problem not withstanding) without the bipolar library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have no sensors enabled in the software (java model railroad interface) I'm using with the sketch, then the bipolar LEDs work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second I add a sensor, then the arduino starts polling the inputs, at which time the bipolar LEDs (all colors) go all wonky. Their flickering coincides with the flickering of the tx/rx lights on the board, so I'm assuming that the polling of the sensors is what is causing it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the bipolars are the only LEDs attached to another output pin instead of the ground. It's almost like it's polling any pin that's low at the time, which we obviously don't need/want with the pins for the LEDs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I even changed the order of the sketch which seemed to slightly effect the flickering, but not enough not to be annoying. Keep in mind my level of understanding programming this is at the level of being able to combine sketches...which conflict led us here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;CMRI.h&amp;gt;&#xA;#include &amp;lt;CrossingFlasher.h&amp;gt;&#xA;#include &amp;lt;BiColorLED.h&amp;gt;&#xA;&#xA;CMRI cmri; // defaults to a SMINI with address 0. SMINI = 24 inputs, 48 outputs&#xA;CrossingFlasher crossing(10, 11); // crossbucks&#xA;BiColorLED led=BiColorLED(46,47); // (pin 1, pin 2) &#xA;BiColorLED led2=BiColorLED(48,49); // (pin 1, pin 2)&#xA;BiColorLED led3=BiColorLED(50,51); // (pin 1, pin 2)&#xA;BiColorLED led4=BiColorLED(52,53); // (pin 1, pin 2)&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); // make sure this matches your speed set in JMRI&#xA;  for (int i=34; i&amp;lt;=53; i++) { pinMode(i, OUTPUT); }&#xA;  for (int i=22; i&amp;lt;=33; i++) { pinMode(i, INPUT); digitalWrite(i, HIGH); }&#xA;  for (int i=10; i&amp;lt;=11; i++) { pinMode(i, OUTPUT); }&#xA;}&#xA;&#xA;void loop() {&#xA;  // 1: build up a packet&#xA;  cmri.process();&#xA;&#xA;  // 4: update crossing lights. Reads bit 0&#xA;  if (cmri.get_bit(0) == true)&#xA;    crossing.on();&#xA;  else&#xA;    crossing.off();&#xA;&#xA;  // 5: update crossing lights&#xA;  crossing.update();&#xA;&#xA;  // 6: update Yellow lights. Reads bit 1&#xA;  if (cmri.get_bit(1) == true)&#xA;    led.setColor(3);&#xA;  else&#xA;    led.setColor(0);&#xA;&#xA;  led.drive();&#xA;&#xA;  // 7: update Yellow lights. Reads bit 2&#xA;  if (cmri.get_bit(2) == true)&#xA;    led2.setColor(3);&#xA;  else&#xA;    led2.setColor(0);&#xA;&#xA;  led.drive();&#xA;&#xA;  // 8: update Yellow lights. &#xA;  if (cmri.get_bit(3) == true)&#xA;    led3.setColor(3);&#xA;  else&#xA;    led3.setColor(0);&#xA;&#xA;  led.drive();&#xA;&#xA;  // 9: update Yellow lights. &#xA;  if (cmri.get_bit(4) == true)&#xA;    led4.setColor(3);&#xA;  else&#xA;    led4.setColor(0);&#xA;&#xA;  led.drive();&#xA;&#xA;  // 2: update outputs&#xA;  digitalWrite(34, cmri.get_bit(5));&#xA;  digitalWrite(35, cmri.get_bit(6));&#xA;  digitalWrite(36, cmri.get_bit(7));&#xA;  digitalWrite(37, cmri.get_bit(8));&#xA;  digitalWrite(38, cmri.get_bit(9));&#xA;  digitalWrite(39, cmri.get_bit(10));&#xA;  digitalWrite(40, cmri.get_bit(11));&#xA;  digitalWrite(41, cmri.get_bit(12));&#xA;  digitalWrite(42, cmri.get_bit(13));&#xA;  digitalWrite(43, cmri.get_bit(14));&#xA;  digitalWrite(44, cmri.get_bit(15));&#xA;  digitalWrite(45, cmri.get_bit(16));&#xA;  digitalWrite(46, cmri.get_bit(17));&#xA;  digitalWrite(47, cmri.get_bit(18));&#xA;  digitalWrite(48, cmri.get_bit(19));&#xA;  digitalWrite(49, cmri.get_bit(20));&#xA;  digitalWrite(50, cmri.get_bit(21));&#xA;  digitalWrite(51, cmri.get_bit(22));&#xA;  digitalWrite(52, cmri.get_bit(23));&#xA;  digitalWrite(53, cmri.get_bit(24));&#xA;&#xA;  // 3: update inputs (invert digitalRead due to the pullups)&#xA;  cmri.set_bit(0, !digitalRead(22));&#xA;  cmri.set_bit(1, !digitalRead(23));&#xA;  cmri.set_bit(2, !digitalRead(24));&#xA;  cmri.set_bit(3, !digitalRead(25));&#xA;  cmri.set_bit(4, !digitalRead(26));&#xA;  cmri.set_bit(5, !digitalRead(27));&#xA;  cmri.set_bit(6, !digitalRead(28));&#xA;  cmri.set_bit(7, !digitalRead(29));&#xA;  cmri.set_bit(8, !digitalRead(30));&#xA;  cmri.set_bit(9, !digitalRead(31));&#xA;  cmri.set_bit(10, !digitalRead(32));&#xA;  cmri.set_bit(11, !digitalRead(33));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried all the suggestions and more, same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My uneducated guess is the problem is probably with the CMRI.h library.&#xA;Because I FINALLY managed to actually get the native support for yellow in the software I was using (JMRI) &#xA;working without any extra bipolar libraries, and guess what? STILL flickers, though this native JMRI &#xA;support tends to make it more orange/red in color than the bipolar library did (I prefer the later). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cmri library is actually attempting to make the arduino emulate another piece of hardware, so for all &#xA;I know it might not even be possible to get it to act right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included both cpp and h scripts.&#xA;If no one actually figures this out, thanks anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CMRI.cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;CMRI - a small library for Arduino to interface with the C/MRI&#xA;computer control system for model railroads&#xA;Copyright (C) 2012 Michael Adams (www.michael.net.nz)&#xA;All rights reserved.&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a &#xA;copy of this software and associated documentation files (the &quot;Software&quot;), &#xA;to deal in the Software without restriction, including without limitation &#xA;the rights to use, copy, modify, merge, publish, distribute, sublicense, &#xA;and/or sell copies of the Software, and to permit persons to whom the &#xA;Software is furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included &#xA;in all copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS &#xA;OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, &#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE &#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER &#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, &#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE &#xA;SOFTWARE.&#xA;*/&#xA;&#xA;#include &quot;CMRI.h&quot;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;CMRI::CMRI(unsigned int address, unsigned int input_bits, unsigned int output_bits, Stream &amp;amp;serial_class)&#xA;    // store details&#xA;: _address(address)&#xA;, _rx_length((output_bits + 7) / 8)&#xA;, _tx_length((input_bits + 7) / 8)&#xA;, _serial(serial_class)&#xA;&#xA;    // set state&#xA;, _rx_buffer((char *) malloc(_rx_length))&#xA;, _tx_buffer((char *) malloc(_tx_length))&#xA;&#xA;    // parsing state&#xA;, _mode(PREAMBLE_1)&#xA;, _rx_index(0)&#xA;&#xA;{&#xA;    // clear to zero&#xA;    for(int i=0; i&amp;lt;_rx_length; i++)&#xA;        _rx_buffer[i] = 0;&#xA;    for(int i=0; i&amp;lt;_tx_length; i++)&#xA;        _tx_buffer[i] = 0;&#xA;}&#xA;&#xA;void CMRI::set_address(unsigned int address)&#xA;{&#xA;    _address = address;&#xA;}&#xA;&#xA;// reads in serial data, decodes packets&#xA;// automatically responds to POLL requests&#xA;// returns packet type so if we got a SET request you know to update your outputs&#xA;bool CMRI::process()&#xA;{&#xA;    while (_serial.available() &amp;gt; 0)&#xA;    {&#xA;        if (process_char(_serial.read()))&#xA;        {&#xA;            return true;&#xA;        }&#xA;    }&#xA;    return false;&#xA;}&#xA;&#xA;bool CMRI::process_char(char c)&#xA;{&#xA;    // if it's a SET that's fine do nothing&#xA;    // if it's an INIT that's also fine, we don't really care&#xA;    // if it's a GET, well, do nothing since it must be someone else replying&#xA;    // if it's a POLL then reply straight away with our data&#xA;    switch (_decode(c))&#xA;    {&#xA;        case POLL:&#xA;            transmit();&#xA;            return true;&#xA;&#xA;        case SET:&#xA;            return true;&#xA;&#xA;        default:&#xA;            return false;&#xA;    }&#xA;}&#xA;&#xA;&#xA;&#xA;// public methods&#xA;&#xA;bool CMRI::get_bit(int pos)&#xA;{&#xA;    // 1: divide index by 8 to get byte offset&#xA;    char c = get_byte(pos / 8);&#xA;    // 2: return bit at that location&#xA;    return (bool) ((c &amp;gt;&amp;gt; (pos % 8)) &amp;amp; 0x01);&#xA;}&#xA;&#xA;char CMRI::get_byte(int pos)&#xA;{&#xA;    if (pos &amp;gt; _rx_length)&#xA;        return 0; // out of bounds&#xA;    else&#xA;        return _rx_buffer[pos];&#xA;}&#xA;&#xA;bool CMRI::set_bit(int pos, bool bit)&#xA;{&#xA;    if ((pos + 7) / 8 &amp;gt; _tx_length)&#xA;        return false; // out of bounds&#xA;    else&#xA;    {&#xA;        int index = pos / 8;&#xA;        _tx_buffer[index] = bit&#xA;            ? _tx_buffer[index] | 1 &amp;lt;&amp;lt; pos % 8      // if bit=1, then OR it&#xA;            : _tx_buffer[index] &amp;amp; ~(1 &amp;lt;&amp;lt; pos % 8) // if bit=0, then NAND it&#xA;        ;&#xA;        return true;&#xA;    }&#xA;}&#xA;&#xA;bool CMRI::set_byte(int pos, char b)&#xA;{&#xA;    if (pos &amp;gt; _tx_length)&#xA;        return false; // out of bounds&#xA;    else&#xA;    {&#xA;        _tx_buffer[pos] = b;&#xA;        return true;&#xA;    }&#xA;}&#xA;&#xA;&#xA;void CMRI::transmit()&#xA;{&#xA;    delay(50); // tiny delay to let things recover&#xA;    _serial.write(255);&#xA;    _serial.write(255);&#xA;    _serial.write(STX);&#xA;    _serial.write(65 + _address);&#xA;    _serial.write(GET);&#xA;    for (int i=0; i&amp;lt;_tx_length; i++)&#xA;    {&#xA;        if (_tx_buffer[i] == ETX)&#xA;            _serial.write(ESC); // escape because this looks like an STX bit (very basic protocol)&#xA;        if (_tx_buffer[i] == ESC)&#xA;            _serial.write(ESC); // escape because this looks like an escape bit (very basic protocol)&#xA;        _serial.write(_tx_buffer[i]);&#xA;    }&#xA;    _serial.write(ETX);&#xA;    _serial.flush();&#xA;}&#xA;&#xA;// Private methods&#xA;uint8_t CMRI::_decode(uint8_t c)&#xA;{&#xA;    switch(_mode)&#xA;    {&#xA;        case PREAMBLE_1:&#xA;            _rx_index = 0;&#xA;            if (c == 0xFF)&#xA;                _mode = PREAMBLE_2;&#xA;            break;&#xA;&#xA;        case PREAMBLE_2:&#xA;            if (c == 0xFF)&#xA;                _mode = PREAMBLE_3;&#xA;            else&#xA;                _mode = PREAMBLE_1;&#xA;            break;&#xA;&#xA;        case PREAMBLE_3:&#xA;            if (c == STX)&#xA;                _mode = DECODE_ADDR;&#xA;            else&#xA;                _mode = PREAMBLE_1;&#xA;            break;&#xA;&#xA;        case DECODE_ADDR:&#xA;            if (c == 'A' + _address)&#xA;                _mode = DECODE_CMD;&#xA;            else if (c &amp;gt;= 'A')&#xA;                _mode = IGNORE_CMD;&#xA;            else&#xA;                _mode = PREAMBLE_1;&#xA;            break;&#xA;&#xA;        case DECODE_CMD:&#xA;            if (c == SET)&#xA;                _mode = DECODE_DATA;&#xA;            else if (c == POLL)&#xA;                goto POSTAMBLE_POLL;&#xA;            else&#xA;                _mode = POSTAMBLE_OTHER;&#xA;            break;&#xA;&#xA;        case IGNORE_CMD:&#xA;            _mode = IGNORE_DATA;&#xA;            break;&#xA;&#xA;        case DECODE_DATA:&#xA;            if (c == ESC)&#xA;                _mode = DECODE_ESC_DATA;&#xA;            else if (c == ETX)&#xA;                goto POSTAMBLE_SET;&#xA;            else if (_rx_index &amp;gt;= _rx_length)&#xA;                { }&#xA;            else&#xA;                _rx_buffer[_rx_index++] = c;&#xA;            break;&#xA;&#xA;        case DECODE_ESC_DATA:&#xA;            if (_rx_index &amp;gt;= _rx_length)&#xA;                { }&#xA;            else&#xA;                _rx_buffer[_rx_index++] = c;&#xA;            _mode = DECODE_DATA;&#xA;            break;&#xA;&#xA;        case IGNORE_DATA:&#xA;            if (c == ESC)&#xA;                _mode = IGNORE_ESC_DATA;&#xA;            else if (c == ETX)&#xA;                goto POSTAMBLE_IGNORE;&#xA;            break;&#xA;&#xA;        case IGNORE_ESC_DATA:&#xA;            _mode = IGNORE_DATA;&#xA;            break;&#xA;&#xA;        case POSTAMBLE_OTHER:&#xA;            _mode = PREAMBLE_1;&#xA;            break;&#xA;    }&#xA;    return NULL;&#xA;&#xA;POSTAMBLE_SET:&#xA;        _mode = PREAMBLE_1;&#xA;        return SET;&#xA;&#xA;POSTAMBLE_POLL:&#xA;        _mode = PREAMBLE_1;&#xA;        return POLL;&#xA;&#xA;POSTAMBLE_IGNORE:&#xA;        _mode = PREAMBLE_1;&#xA;        return NULL;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The CMRI.h file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;    CMRI - a small library for Arduino to interface with the C/MRI&#xA;    computer control system for model railroads&#xA;    Copyright (C) 2012 Michael Adams (www.michael.net.nz)&#xA;    All rights reserved.&#xA;&#xA;    Permission is hereby granted, free of charge, to any person obtaining a &#xA;    copy of this software and associated documentation files (the &quot;Software&quot;), &#xA;    to deal in the Software without restriction, including without limitation &#xA;    the rights to use, copy, modify, merge, publish, distribute, sublicense, &#xA;    and/or sell copies of the Software, and to permit persons to whom the &#xA;    Software is furnished to do so, subject to the following conditions:&#xA;&#xA;    The above copyright notice and this permission notice shall be included &#xA;    in all copies or substantial portions of the Software.&#xA;&#xA;    THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS &#xA;    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, &#xA;    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE &#xA;    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER &#xA;    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, &#xA;    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE &#xA;    SOFTWARE.&#xA;*/&#xA;&#xA;#ifndef CMRI_h&#xA;#define CMRI_h&#xA;&#xA;#define _CMRI_VERSION 1.5 // version of this library&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class CMRI&#xA;{&#xA;    public:&#xA;        CMRI(unsigned int address = 0, unsigned int input_bits = 24, unsigned int output_bits = 48, Stream&amp;amp; serial_class = Serial);&#xA;        void set_address(unsigned int address);&#xA;&#xA;        bool process();&#xA;        bool process_char(char c);&#xA;        void transmit();&#xA;&#xA;        bool get_bit(int n);&#xA;        char get_byte(int n);&#xA;&#xA;        bool set_bit(int n, bool b);&#xA;        bool set_byte(int n, char b);&#xA;&#xA;        enum {&#xA;            MAX  = 258, // max packet length in bytes (64 i/o cards @ 32 bits each + packet type and address bytes)&#xA;            INIT = 'I', // PC is telling us stuff we don't really care about&#xA;            SET  = 'T', // as in TX from the PC =&amp;gt; Arduino, PC is SETing our status&#xA;            GET  = 'R', // as in TX from Arduino =&amp;gt; PC, PC is GETing our status&#xA;            POLL = 'P', // PC wants to know our status&#xA;            STX  = 0x02, // start byte&#xA;            ETX  = 0x03, // end byte&#xA;            ESC  = 0x10, // escape byte&#xA;        };&#xA;&#xA;private:&#xA;        enum {PREAMBLE_1,PREAMBLE_2,PREAMBLE_3,DECODE_ADDR,DECODE_CMD,DECODE_DATA,DECODE_ESC_DATA,IGNORE_CMD,IGNORE_DATA,IGNORE_ESC_DATA,POSTAMBLE_SET,POSTAMBLE_POLL,POSTAMBLE_OTHER};&#xA;&#xA;        int   _address;&#xA;        int   _rx_length;&#xA;        int   _tx_length;&#xA;        char    _rx_packet_type;&#xA;        char* _tx_buffer;&#xA;        char* _rx_buffer;&#xA;&#xA;        Stream&amp;amp; _serial;&#xA;&#xA;        // parsing state variables&#xA;        int     _mode;&#xA;        int     _rx_index;&#xA;&#xA;        uint8_t    _decode(uint8_t c); // process one character received from serial port&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5160" LastEditorUserId="5160" LastEditDate="2014-12-10T18:07:55.930" LastActivityDate="2015-01-09T19:58:55.890" Title="Bipolar LEDs flicker when sensors are polled" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5394" PostTypeId="2" ParentId="5386" CreationDate="2014-12-09T00:57:07.487" Score="2" Body="&lt;p&gt;If I understand your question, the main issues are that the axis don't match up, and z from the accel is not accurate?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with respect to the axis: just swap the values. Rotation math is self-consistent and &quot;correct&quot; in many different permutations. What makes it correct is the set of equations, not any single equation; So, copying equations from one reference frame to another will yield incorrect results even if they were correct originally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;your link addresses this difference:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Interpreting the diagram at left is a little tricky, since the tilt&#xA;  of the X-axis actually shows rotation around the Y-axis, and the&#xA;  angling of the Y-axis shows (negative) rotation around the X-axis.&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ary = -(180/3.141592) * atan(ax / sqrt(square(ay) + square(az))); &#xA;  arx =  (180/3.141592) * atan(ay / sqrt(square(ax) + square(az)));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should work better for you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the second point: accelerometers can't measure yaw, the &quot;z&quot; equation can safely be ignored. that isn't yaw it calculates. Calculating z from the gyro alone should fix your second issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other considerations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The gyroscope tracking can be made more accurate by using the midpoint rule in your integration&lt;/li&gt;&#xA;&lt;li&gt;Your code is not integrating the gyroscope's signal with the best estimate of its last position (rx, ry, rz), instead it integrates the gyro with separate numbers (grx, gry, grz). In effect information from the accelerometer is discarded each loop and gyro drift is not corrected for.&lt;/li&gt;&#xA;&lt;li&gt;Thanks for including those graphs with your code samples =] rotation math is extremely tricky, and graphs help a lot&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-12-09T00:57:07.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5395" PostTypeId="1" CreationDate="2014-12-09T01:26:03.360" Score="2" ViewCount="387" Body="&lt;p&gt;I connected SIM300cz module's GSM board with Arduino Mega. The GSM board has the pins VCC, GND, RXD, TXD, GND, RI, DTR, STATUS, PWKEY and GND. I connected the GNDs with Arduino's GND, VCC to Arduinos 5V (took power from Arduino), RXD to pin 5, TXD to pin 6 (because of using software serial) and PWKEY to pin 53. My code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial GPRS(5, 6);&#xA;&#xA;int inputPinTempSensor = 0;&#xA;float tempCelsius = 0 ;&#xA;float thresholdTemp = 45;&#xA;&#xA;void setup()&#xA;{&#xA;  GPRS.begin(9600);               // the GPRS baud rate&#xA;  Serial.begin(9600);  // the Serial port of Arduino baud rate.&#xA;  pinMode(53, OUTPUT);&#xA;  digitalWrite(53, HIGH);&#xA;  delay(100);&#xA;}&#xA;&#xA;void loop() {&#xA;  GPRS.print(&quot;AT+CREG/r&quot;);&#xA;  Serial.print(GPRS.read());&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The AT command response should be something like &quot;ok&quot; but it's returning -1 for every loop waiting 2 seconds. Why and what could be the solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the mistakes. I was trying different ways with carriage return and new line characters to make it work. Now the code is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial GPRS(5, 6);&#xA;&#xA;void setup()&#xA;{&#xA;  GPRS.begin(9600);               // the GPRS baud rate&#xA;  Serial.begin(9600);  // the Serial port of Arduino baud rate.&#xA;  pinMode(53, OUTPUT);&#xA;  digitalWrite(53, HIGH);&#xA;  delay(2000);&#xA;  GPRS.println(&quot;AT+CREG&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  while(GPRS.available()){&#xA;    Serial.print(GPRS.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it gives no responses at all. Actually after buying the module I was trying with &lt;a href=&quot;https://github.com/Arduino-IN/demos/tree/master/GSM%2BArduino/Arduino-Code&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; examples and they were not working either. So, I thought to test if the AT commands were working properly. I could be a problem with my wiring too.&lt;/p&gt;&#xA;" OwnerUserId="3030" LastEditorUserId="4131" LastEditDate="2015-12-09T21:28:04.997" LastActivityDate="2016-10-06T07:23:54.730" Title="SIM300cz AT command returns -1" Tags="|arduino-mega|gsm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5396" PostTypeId="1" AcceptedAnswerId="5432" CreationDate="2014-12-09T02:20:08.713" Score="10" ViewCount="4384" Body="&lt;p&gt;I would like to set up a timer in order to call a function 800 times per second. I'm using the Arduino Mega and Timer3 with a prescaler of 1024. To choose the prescaler factor I've considered the following steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CPU freq: 16MHz&lt;/li&gt;&#xA;&lt;li&gt;Timer resolution: 65536 (16 bits)&lt;/li&gt;&#xA;&lt;li&gt;Divide CPU freq by the chosen prescaler:&#xA;16x10^6/&lt;strong&gt;1024&lt;/strong&gt;=15625&lt;/li&gt;&#xA;&lt;li&gt;Divide the rest through the desired freq&#xA;62500/800=&lt;strong&gt;19&lt;/strong&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Put the result + 1 in OCR3 register.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've used the following table to set registers of TCCR3B:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z3H7p.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The error&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is impossible to compile the code. This is the error returned by the compiler:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Servo\Servo.cpp.o: In function '__vector_32': C:\Program Files&#xA;  (x86)\Arduino\libraries\Servo/Servo.cpp:110: multiple definition of&#xA;  '__vector_32' AccelPart1_35.cpp.o:C:\Program Files&#xA;  (x86)\Arduino/AccelPart1_35.ino:457: first defined here c:/program&#xA;  files&#xA;  (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe:&#xA;  Disabling relaxation: it will not work with multiple definitions&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cont = 0;&#xA;unsigned long aCont = 0;&#xA;void setup()&#xA;{&#xA; [...]&#xA;  // initialize Timer3&#xA;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count: 800 Hz&#xA;  OCR3A = 20;&#xA;  // turn on CTC mode:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3A);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; // Print every second the number of ISR invoked -&amp;gt; should be 100&#xA; if ( millis() % 1000 == 0)&#xA; {&#xA;   Serial.println();&#xA;   Serial.print(&quot; tick: &quot;);&#xA;   Serial.println(contatore);&#xA;   contatore = 0;&#xA; }&#xA;}&#xA;&#xA;[...]&#xA;&#xA;// This is the 457-th line&#xA;ISR(TIMER3_COMPA_vect)&#xA;{&#xA;    accRoutine();&#xA;    contatore++;&#xA;}&#xA;&#xA;void accRoutine()&#xA;{&#xA;  // reads analog values&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to solve the conflict with the servo library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLUTION&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conflict solved using the following code. It compiles but the counter associated with the 800Hz timer doesn't increment its value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cont = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  // Initialize Timer&#xA;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count: 800 Hz&#xA;  OCR3B = 20;&#xA;  // turn on CTC mode:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;&#xA;  Serial.println(&quot;Setup completed&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (millis() % 1000 == 0)&#xA;  {&#xA;    Serial.print(&quot; tick: &quot;);&#xA;    Serial.println(cont);&#xA;    cont = 0;&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the main problem has been solved, I've created another question &lt;a href=&quot;https://arduino.stackexchange.com/questions/5431/how-to-update-a-variable-in-an-isr-using-timers&quot;&gt;here&lt;/a&gt; related to the problem of the counter incrementation.&lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="37523" LastEditDate="2019-12-05T16:02:19.127" LastActivityDate="2019-12-05T16:02:19.127" Title="Setting timer3 in CTC mode - conflict with servo library" Tags="|arduino-mega|timers|compile|avr-gcc|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="5397" PostTypeId="1" AcceptedAnswerId="5412" CreationDate="2014-12-09T04:41:04.553" Score="0" ViewCount="4501" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;The problem was the cable I was using (see answer below).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have a MacBook Pro running OS X Yosemite (10.10.1). I connected my Arduino Leonardo to my computer for the first time today (using a Micro USB to USB cable), but my computer isn't detecting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I opened the Arduino IDE I selected Tools &gt; Board &gt; &quot;Arduino Leonardo&quot;, but when I try to choose a Serial Port the only options are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-Incoming-Port&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-Incoming-Port&lt;/li&gt;&#xA;&lt;li&gt;/dev/tty.Bluetooth-Modem&lt;/li&gt;&#xA;&lt;li&gt;/dev/cu.Bluetooth-Modem&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/r8DwE.png&quot; alt=&quot;screenshot of available serial ports&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried closing and relaunching the Arduino IDE, disconnecting and reconnecting my Arduino Leonardo, and restarting my computer, but I still only see the four Bluetooth ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;System Information (aka System Profiler) doesn't show anything connected to any of my USB ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="5164" LastEditorUserId="5164" LastEditDate="2014-12-09T18:18:48.873" LastActivityDate="2019-01-06T13:50:42.687" Title="Mac won't detect Serial Port for Leonardo" Tags="|serial|arduino-leonardo|usb|mac-os|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5398" PostTypeId="2" ParentId="5395" CreationDate="2014-12-09T05:43:54.080" Score="1" Body="&lt;p&gt;I think there are 2 mistakes in your code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you should ensure that the 3AT3 commands are termintaed by a new line character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GPRS.print(&quot;AT+CREG/r&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be changed into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GPRS.println(&quot;AT+CREG/r&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GPRS.print(&quot;AT+CREG/r\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nite that I am not sure why you added &lt;code&gt;/r&lt;/code&gt; at the end of the AT command, is that supposed to be part of the command? If your intention was to force a new line, then you meant &lt;code&gt;\r&lt;/code&gt; not &lt;code&gt;/r&lt;/code&gt;, which is not really a new line character but a carriage return (that might be interpreted the same by yur GSM module, but not necessarily).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The the second mistake in your code, is directly calling &lt;code&gt;GPRS.read()&lt;/code&gt; &lt;strong&gt;without&lt;/strong&gt; first waiting for a character to be available; in this situation, &lt;code&gt;GPRS.read()&lt;/code&gt; will always return &lt;code&gt;-1&lt;/code&gt; as a specific value meaning &quot;no available character to read&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you should change your code to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// 1st wait for a character to be available&#xA;while (!GPRS.available()) {&#xA;}&#xA;// Then read all available characters and log them to Serial&#xA;while (GPRS.available()) {&#xA;    Serial.print(GPRS.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-12-09T05:43:54.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5399" PostTypeId="1" CreationDate="2014-12-09T08:59:32.980" Score="0" ViewCount="593" Body="&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;LCD12864RSPI.h&amp;quot;&#xA;#include &amp;quot;DFrobot_bmp.h&amp;quot;&#xA;#include &amp;quot;DFrobot_char.h&amp;quot;&#xA;&#xA;#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )&#xA;unsigned char wangzhi[]=&amp;quot; www.DFRobot.com &amp;quot;;&#xA;unsigned char fused[1024];&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(11, OUTPUT);     &#xA;  for(int i=0;i&amp;lt;4;i++){&#xA;  digitalWrite(11,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(11,LOW);&#xA;  delay(1000);&#xA;  }&#xA;  LCDA.initDriverPin(2,7,10); &#xA;  LCDA.Initialise(); // INIT SCREEN  &#xA;}&#xA;unsigned char* fuse3(unsigned char* a ,unsigned char* b,unsigned char* c){&#xA;&#xA;  int i=0;&#xA;  int ac=0;//a counter &#xA;  int bc=0; //b counter &#xA;  int cc=0;//c counter &#xA;&#xA;  for(int n=0;n&amp;lt;64;n++){&#xA;    for(int k=0;k&amp;lt;5;k++){&#xA;      fused[i]=a[ac];&#xA;       ac++;&#xA;       i++;&#xA;    }&#xA;       for(int k=0;k&amp;lt;5;k++){&#xA;        fused[i]=b[bc];&#xA;       bc++;&#xA;        i++;&#xA;    }&#xA;        for(int k=0;k&amp;lt;5;k++){&#xA;            fused[i]=c[cc];&#xA;            cc++;&#xA;             i++;&#xA;    }&#xA;    fused[i]=0x00;&#xA;    i++;&#xA;  }&#xA;  &#xA;  return fused;&#xA;}&#xA;unsigned char* getMatch(int input){&#xA;  input = input &amp;amp; 0x000f;&#xA;  switch (input){&#xA;   case 0: return g0;&#xA;   case 1: return g1;&#xA;   case 2: return g2;&#xA;   case 3: return g3;&#xA;   case 4: return g4;&#xA;   case 5: return g5;&#xA;   case 6: return g6;&#xA;   case 7: return g7;&#xA;   case 8: return g8;&#xA;   case 9: return g9;&#xA;   case 10: return plus;&#xA;   case 11: return minus;&#xA;   case 12: return times;&#xA;   case 13: return g1;&#xA;   case 14: return g1;&#xA;   case 15: return g1;&#xA;   default: return g1;&#xA;  }&#xA;  &#xA;}&#xA;void displayfuse(int number){&#xA;// LCDA.DrawFullScreen(fuse3(getMatch(1),getMatch(2),getMatch(3)));&#xA;}&#xA;void loop(){&#xA;  displayfuse(0x1234);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This code is a stripped version of the code I need to run to get a bigger project working. But if it somewhat works than the setup should begin by flashing a LED 4 times before continuing. Currently this works. However as you can see I have commented out the line &lt;code&gt;LCDA.DrawFullScreen(fuse3(getMatch(1),getMatch(2),getMatch(3)));&lt;/code&gt;. uncommenting this line causes the LED's to flash continuously rather then just 4 times. The library I'm using can be found &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. Does anybody know what is going on? To me the first few lines of a program can be affected by a change somewhere this deep inside the code is a form of dark magic.&lt;/p&gt;&#xA;&lt;p&gt;Weirdly when I change the setup to the following:&#xA;void setup()&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  pinMode(11, OUTPUT);     &#xA;  for(int i=0;i&amp;lt;15;i++){&#xA;  digitalWrite(11,HIGH);&#xA;  delay(100);&#xA;  digitalWrite(11,LOW);&#xA;  delay(100);&#xA;  }&#xA;  for(int i=0;i&amp;lt;4;i++){&#xA;  digitalWrite(11,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(11,LOW);&#xA;  delay(1000);&#xA;  }&#xA;  LCDA.initDriverPin(2,7,10); &#xA;  LCDA.Initialise(); // INIT SCREEN  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it stops flashing completely.&lt;/p&gt;&#xA;&lt;p&gt;Edit having just reuploaded the code again this time the led just remains on all the time.&lt;/p&gt;&#xA;&lt;p&gt;edit edit&#xA;Now with the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;LCD12864RSPI.h&amp;quot;&#xA;#include &amp;quot;DFrobot_bmp.h&amp;quot;&#xA;#include &amp;quot;DFrobot_char.h&amp;quot;&#xA;&#xA;unsigned char fuse[1024];&#xA;void setup()&#xA;{&#xA;&#xA;  LCDA.initDriverPin(2,7,10); &#xA;&#xA;  LCDA.Initialise(); // INIT SCREEN  &#xA;  pinMode(11, OUTPUT); &#xA;  digitalWrite(11,HIGH);  &#xA;  &#xA;}&#xA;unsigned char* fuse3(unsigned char* a ,unsigned char* b,unsigned char* c){&#xA; unsigned char* fused =(unsigned char*)malloc(sizeof(char)*1024);&#xA;&#xA;  int i=0;&#xA;  int ac=0;//a counter &#xA;  int bc=0; //b counter &#xA;  int cc=0;//c counter &#xA;&#xA;  for(int n=0;n&amp;lt;64;n++){&#xA;    for(int k=0;k&amp;lt;5;k++){&#xA;      fused[i]=a[ac];&#xA;      ac++;&#xA;       i++;&#xA;    }&#xA;        for(int k=0;k&amp;lt;5;k++){&#xA;      fused[i]=b[bc];&#xA;      bc++;&#xA;       i++;&#xA;    }&#xA;        for(int k=0;k&amp;lt;5;k++){&#xA;      fused[i]=c[cc];&#xA;      cc++;&#xA;       i++;&#xA;    }&#xA;    fused[i]=0x00;&#xA;    i++;&#xA;  }&#xA;  return fused;&#xA;}&#xA;unsigned char* getMatch(int input){&#xA;&#xA;  input = input &amp;amp; 0x000f;&#xA;&#xA;  switch (input){&#xA;   case 0: return g0;&#xA;   case 1: return g1;&#xA;   case 2: return g2;&#xA;   case 3: return g3;&#xA;   case 4: return g4;&#xA;   case 5: return g5;&#xA;   case 6: return g6;&#xA;   case 7: return g7;&#xA;   case 8: return g8;&#xA;   case 9: return g9;&#xA;   case 10: return plus;&#xA;   case 11: return minus;&#xA;   case 12: return times;&#xA;   case 13: return g1;&#xA;   case 14: return g1;&#xA;   case 15: return g1;&#xA;   default: return g1;&#xA;  }&#xA;}&#xA;void displayfuse(int number){&#xA; LCDA.CLEAR();&#xA;   delay(100);&#xA;&#xA; &#xA; int mask1 = 0xF000;&#xA; int mask2 = 0x0F00;&#xA; int mask3 = 0x00F0;&#xA;&#xA; int firstnumber = number&amp;amp;mask1&amp;gt;&amp;gt;12;&#xA; int operation = number&amp;amp;mask2&amp;gt;&amp;gt;8;&#xA; int secondnumber= number&amp;amp;mask3&amp;gt;&amp;gt;4;&#xA;  &#xA;  LCDA.DrawFullScreen(fuse3(getMatch(firstnumber),getMatch(operation),getMatch(secondnumber)));&#xA;  delay(5000);&#xA;}&#xA;void loop(){&#xA;  displayfuse(0x1234);&#xA;  delay(1000)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This causes the led to not turn on but moving the lines where I make pin 11 output and high one up (beyond the  &lt;code&gt;LCDA.Initialise(); // INIT SCREEN&lt;/code&gt; ) then the led will turn on. It can also be turned on by commenting out the       &lt;code&gt;LCDA.DrawFullScreen(fuse3(getMatch(firstnumber),getMatch(operation),getMatch(secondnumber)));&lt;/code&gt; line.&#xA;Magic is happening...&lt;/p&gt;&#xA;" OwnerUserId="5165" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2014-12-09T12:52:44.487" Title="Assigning values to char array causes program to not run" Tags="|programming|led|c++|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5400" PostTypeId="1" AcceptedAnswerId="5405" CreationDate="2014-12-09T09:22:58.347" Score="8" ViewCount="7587" Body="&lt;p&gt;I'm working on an embedded project, where I use arduinos as a &quot;sensor shield&quot; for RaspberryPi (I have model B).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, that the RaspberryPi's USB port is not powerfull enough to drive WiFi adapter and arduino with sensors. The solution is easy, I will power the sensors externally, not through the RPi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I was wondering, &lt;strong&gt;is it possible to power whole Arduino externally (through Vin) and use the USB only for serial communication.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, I know how to solve my problem - use some other mean of communication, than USB - GPIO serial, I2C, wireless, etc... I'm just interested if the whole thing will work, with USB cable which has 5V lead cut, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main issue I can see with this is, that the USB&amp;lt;-&gt;Serial chip is powered through USB only, then it will now work.&lt;/p&gt;&#xA;" OwnerUserId="5167" LastActivityDate="2019-04-17T12:59:33.840" Title="How to stop Arduino from drawing power through USB" Tags="|power|usb|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5401" PostTypeId="1" AcceptedAnswerId="5402" CreationDate="2014-12-09T09:26:10.440" Score="1" ViewCount="1230" Body="&lt;p&gt;I got a breadboard with 10 LEDs, 4 of them fade, to be specific:&#xA;3, 5, 6 and 9 are working. 0, 1, 2, 4, 7, 8 are not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using LEDs and resistors on all spots, they're all the same. Tried changing things around but the problem doesn't seem to be the resistors or the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following code (I'll highlight the parts for the fading, by marking it between &lt;code&gt;//**&lt;/code&gt; comments).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a way to fix this? Or see any problem?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int inButton = 13;&#xA;int buttonPushCounter = 0;&#xA;int buttonState = 0;&#xA;int lastButtonState = 0;&#xA;int delayTime = 100;&#xA;int brightness = 0;&#xA;int fadeAmount = 5;&#xA;&#xA;void setup() {&#xA;  //**&#xA;  pinMode(inButton, INPUT);&#xA;  for (int out = 0; out &amp;lt; 10; out++){&#xA;    pinMode(out, OUTPUT);&#xA;  }&#xA;  //**&#xA;&#xA;  pinMode(testLed, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  buttonState = digitalRead(inButton);&#xA;  if (buttonState != lastButtonState){&#xA;    if (buttonState == 1){&#xA;      buttonPushCounter++;&#xA;    }&#xA;  }&#xA;&#xA;  lastButtonState = buttonState;&#xA;&#xA;  if (buttonPushCounter % 5 == 0){&#xA;    for (int i = 0; i &amp;lt; 10; i++){&#xA;      digitalWrite(i, 1);&#xA;      delay(delayTime / 2);&#xA;      digitalWrite(i, 0);   &#xA;    }&#xA;  }&#xA;  else if (buttonPushCounter % 5 == 1){&#xA;    for (int i = 0, j = 9; i &amp;lt; 10, j &amp;gt;= 0; i++, j--){    &#xA;      digitalWrite (i, 1);&#xA;      digitalWrite (j, 1);&#xA;      delay(delayTime / 2);&#xA;      digitalWrite (i, 0);&#xA;      digitalWrite (j, 0);&#xA;    } &#xA;  }&#xA;  else if (buttonPushCounter % 5 == 2){   &#xA;    for (int i = 0; i &amp;lt; 10; i+=2){&#xA;      digitalWrite(i, 1);&#xA;    } &#xA;    delay(delayTime);&#xA;    for (int i = 0; i &amp;lt; 10; i+=2){&#xA;      digitalWrite(i, 0);&#xA;    }&#xA;    delay(delayTime);&#xA;    for (int i = 1; i &amp;lt; 10; i+=2){&#xA;      digitalWrite(i, 1);&#xA;    }&#xA;    delay(delayTime);&#xA;    for (int i = 1; i &amp;lt; 10; i+=2){&#xA;      digitalWrite(i, 0);&#xA;    }&#xA;  } &#xA;  else if (buttonPushCounter % 5 == 3){&#xA;    for (int i = 0 ; i &amp;lt; 10 ; i++){&#xA;      analogWrite(i, brightness);&#xA;    }&#xA;    brightness = brightness + fadeAmount;&#xA;    if (brightness == 0 || brightness == 255){&#xA;      fadeAmount = -fadeAmount; &#xA;    }&#xA;    delay(25);      &#xA;  }&#xA;  else {&#xA;    int R1 = random(10);&#xA;    int R2 = random(10);&#xA;    int R3 = random(10);&#xA;    int R4 = random(10);&#xA;    digitalWrite(R1, 1);&#xA;    digitalWrite(R2, 1);&#xA;    digitalWrite(R3, 1);&#xA;    digitalWrite(R4, 1);&#xA;    delay(delayTime);&#xA;    digitalWrite(R1, 0);&#xA;    digitalWrite(R2, 0);&#xA;    digitalWrite(R3, 0);&#xA;    digitalWrite(R4, 0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5166" LastEditorUserId="84" LastEditDate="2014-12-09T18:50:35.897" LastActivityDate="2014-12-09T18:50:35.897" Title="Problem with fading LEDs" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5402" PostTypeId="2" ParentId="5401" CreationDate="2014-12-09T09:37:21.967" Score="4" Body="&lt;p&gt;Only pins that support PWM support &lt;code&gt;analogWrite()&lt;/code&gt; fully. 3, 5, 6, 9, 10, and 11 do. The rest do not.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-09T09:37:21.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5404" PostTypeId="2" ParentId="5399" CreationDate="2014-12-09T09:46:43.920" Score="1" Body="&lt;p&gt;The 'dark magic' is going to be your program rebooting every time it gets to that line. I would imagine (this isn't a library I know) that you're exceeding an array bound &amp;amp; generating a 'segfault', although it could be that you light up your LCD array &amp;amp; the power draw causes a reboot..&#xA;Because the LED flash is at the start of setup, it executes quickly, so generating the appearance of continual flashing when  it re-enters repeatedly.&#xA;Your code is going to assign g1[0] when the line in question executes - is g1[] defined to point somewhere valid?&lt;/p&gt;&#xA;" OwnerUserId="5168" LastEditorUserId="5168" LastEditDate="2014-12-09T10:15:08.740" LastActivityDate="2014-12-09T10:15:08.740" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="5405" PostTypeId="2" ParentId="5400" CreationDate="2014-12-09T10:17:52.497" Score="8" Body="&lt;p&gt;If you provide power to the Arduino through &lt;code&gt;Vin&lt;/code&gt; this will disconnect USB power through the MOSFET switch.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-12-09T10:17:52.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5406" PostTypeId="2" ParentId="5401" CreationDate="2014-12-09T11:27:39.153" Score="2" Body="&lt;p&gt;To add to @ignacio-vazquez-abrams answer, the pins that support &lt;code&gt;analogWrite()&lt;/code&gt; have &lt;code&gt;~&lt;/code&gt; sign next to their number (on my Uno board they are &lt;code&gt;9~&lt;/code&gt;, &lt;code&gt;10~&lt;/code&gt;, &lt;code&gt;11~&lt;/code&gt; e.g.);&lt;/p&gt;&#xA;" OwnerUserId="5170" LastActivityDate="2014-12-09T11:27:39.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5407" PostTypeId="2" ParentId="105" CreationDate="2014-12-09T15:00:44.523" Score="4" Body="&lt;p&gt;I have used pyserial with great success in controlling the pins on the arduino.  Your workstation (laptop, etc) runs a python script that then communicates in real time to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not quite the same as running the script directly on the arduino but I was doing quite a bit more than I thought the arduino could handle (some music analysis, hitting a REST api, etc).&lt;/p&gt;&#xA;" OwnerUserId="5173" LastActivityDate="2014-12-09T15:00:44.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5408" PostTypeId="1" CreationDate="2014-12-09T15:51:27.937" Score="0" ViewCount="1260" Body="&lt;p&gt;For a program that I'm working on, I want to get an accurate reading from a noisy pressure sensor.  So, the idea that I have is to do a thousand AnalogRead commands on the same port very quickly and then average them.  The pressure readings become very precise, however, the program that I am running becomes very slow.  I need my program to be orders of magnitude faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure that there's a faster way to do AnalogRead commands, especially because I am requesting the same port over and over.  Maybe there's a way that I can take lower resolutions of readings and then average those?  I don't know.  Can anyone help me?  I am an amateur Arduino user looking to learn.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done a little bit of research on my own and had trouble finding concrete examples.&lt;/p&gt;&#xA;" OwnerUserId="4335" LastActivityDate="2014-12-12T21:09:47.263" Title="AnalogRead too slow... Faster alternative?" Tags="|arduino-due|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5409" PostTypeId="2" ParentId="5286" CreationDate="2014-12-09T16:21:42.933" Score="1" Body="&lt;p&gt;This can happen when your sketch uses too much memory - the board can no longer assign addresses so it resets leading to an endless loop. Try reducing the amount of memory you are allocating.&lt;/p&gt;&#xA;" OwnerUserId="5175" LastActivityDate="2014-12-09T16:21:42.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5410" PostTypeId="2" ParentId="5393" CreationDate="2014-12-09T17:00:51.587" Score="3" Body="&lt;p&gt;The yellow color is make by very quickly alternating between red and green. If you do this fast enough your eyes won't notice. This alternating is done inside &lt;code&gt;led.drive();&lt;/code&gt;. If you are polling the sensors, &lt;code&gt;led.drive();&lt;/code&gt; isn't called and the leds aren't alternating for a moment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best way would be to use a timer to call &lt;code&gt;led.drive();&lt;/code&gt; every 9ms or less. You could use the &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;timerOne library&lt;/a&gt;. I've never used that library, but I think you should use the following code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;&#xA;...&#xA;&#xA;void setup {&#xA;    Timer1.initialize(9000);// call every 9ms&#xA;    Timer1.attachInterrupt(callback);&#xA;&#xA;...&#xA;&#xA;void callback()&#xA;{&#xA;    led.drive();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;remove all other led.drive calls&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-09T17:00:51.587" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="5411" PostTypeId="1" CreationDate="2014-12-09T18:01:33.490" Score="4" ViewCount="15459" Body="&lt;p&gt;Id like to make my 5v pro mini use 3.3 v instead of 5 because i want to use it in an existing piece of electronics that uses 3v throughout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the specs for the pro mini it says the 3.3v version can accept higher voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a regulator i can bypass/bridge that will convert my 5v version to a 3.3v version? or am i wasting my time?&lt;/p&gt;&#xA;" OwnerUserId="5180" OwnerDisplayName="S Rosam" LastEditorUserId="4143" LastEditDate="2014-12-09T18:53:03.377" LastActivityDate="2016-01-23T12:02:50.987" Title="Convert Arduino Pro Mini 5v to use 3.3v" Tags="|voltage-level|arduino-pro-mini|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5412" PostTypeId="2" ParentId="5397" CreationDate="2014-12-09T18:15:26.837" Score="1" Body="&lt;p&gt;@IgnacioVazquez-Abrams's comment made me realize that the problem was the Micro USB cable I was using. It gave the Arduino 5V power from my computer, but didn't support any data connection. I'm buying a new cable.&lt;/p&gt;&#xA;" OwnerUserId="5164" LastActivityDate="2014-12-09T18:15:26.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5413" PostTypeId="2" ParentId="5411" CreationDate="2014-12-09T18:18:37.543" Score="10" Body="&lt;p&gt;I have good news, and I have bad news.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good news is that only &lt;strong&gt;two changes&lt;/strong&gt; to the board are required to change it from a 5V board to a 3.3V (or any voltage within spec) board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bad news is that there's &lt;em&gt;no way in hell&lt;/em&gt; you'll be able to do them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we work around them and get the board up and running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first is obvious: a 3.3V board should be running off of 3.3V. Since we can't replace the SOT23-5 regulator on the board (the little 5-pin device towards the end) we need a voltage regulator to supply this, directly to the VCC pin. Find yourself a linear or switching regulator that provides this voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second is that the microcontroller, an Atmel ATmega168/P, is not specced to run at 16MHz when the supply voltage is only 3.3V; the maximum speed is 12MHz. Since we can't replace the crystal on the board (the little silver package next to the MCU itself) we need to perform some trickery to tell the MCU divide the frequency down to something way below safe, and then boost it up after. Use a programmer (see some of my other answers for more info about this) to set the CKDIV8 fuse and then use the routines in &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html&quot;&gt;&lt;code&gt;avr/power.h&lt;/code&gt;&lt;/a&gt; in your code to &quot;reduce&quot; the divisor to 2, bringing the clock speed back up to 8MHz. While you're at it, check the BOD fuses to make sure they're not set to something useless like 0b100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As always, see the datasheet.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-12-09T18:37:12.390" LastActivityDate="2014-12-09T18:37:12.390" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5414" PostTypeId="2" ParentId="5411" CreationDate="2014-12-09T18:48:56.807" Score="4" Body="&lt;p&gt;See &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/3-3v-conversion&quot; rel=&quot;nofollow noreferrer&quot;&gt;this nice article&lt;/a&gt; by Adafruit, which explains how to run an Arduino &lt;strong&gt;Uno&lt;/strong&gt; at 16Mhz with 3.3v. Both the Arduino Pro Mini and the Uno use the same ATmega328p chip, and they claim that even though running at 16Mhz is out of specs, it &lt;em&gt;should&lt;/em&gt; work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;strong&gt;Ignacio&lt;/strong&gt; mentioned in &lt;a href=&quot;https://arduino.stackexchange.com/a/5413/630&quot;&gt;his answer&lt;/a&gt;, there will be no alternative to downclocking the Mini Pro if you want to play it safe and stay &lt;strong&gt;within the specs&lt;/strong&gt;. If you are willing to take the chance, remove the 5v regulator as suggested, and connect a regulated 3.3v to Vin. Consider the hazards; they might include device resets, misbehaving code or malfunctioning I/O pins. &#xA;If you are using an unregulated 3v voltage source, you will need to step up the voltage - using DC DC step up converter such as &lt;a href=&quot;http://www.ebay.com/itm/DC-DC-Input-0-8-3-3V-Output-3-3V-Step-UP-Boost-Voltage-Converter-Module-/171569922743?pt=LH_DefaultDomain_0&amp;amp;hash=item27f25d42b7&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;. (By the way - you could also find a &lt;a href=&quot;http://www.ebay.com/itm/DC-DC-Boost-Converter-Step-Up-Module-1-5V-to-5V-500mA-Power-Module-New-TR-/400819011062?pt=AU_Gadgets&amp;amp;hash=item5d52acbdf6&quot; rel=&quot;nofollow noreferrer&quot;&gt;step up converter to 5v&lt;/a&gt; - hence problem solved...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, see &lt;a href=&quot;https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz&quot;&gt;this SO answer&lt;/a&gt; for more details. The &lt;em&gt;safe&lt;/em&gt; clock speed for the ATmega328p operating at 3.3v would be &lt;strong&gt;13.33Mhz&lt;/strong&gt;. For reference, here is the Safe Operating Area graph from the datasheet supplied in the answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/98hvi.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-02-16T11:01:57.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5415" PostTypeId="2" ParentId="5341" CreationDate="2014-12-09T19:04:56.060" Score="0" Body="&lt;p&gt;The Galileo board is Arduino compatible; meaning that you can run Arduino sketches on it, and use its I/O pins the same way you would with, say, Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefor you can communicate between Galileo and Arduino the same way you would with two Arduino devices. This can be done using your favorite communication channel - Serial, I2C, OneWire, RF or even Infrared - it all depends what exactly are your needs, knowledge and timing requirements. Of course, doing it this way, would require you to have code running on both the Galileo and the Arduino, in charge of the inter-communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By doing so, you could utilize the Galileo as a 'server' as you say, that will receive commands from the Arduino, send them over the network and reply to the Arduino with the response.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-09T19:04:56.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5416" PostTypeId="1" AcceptedAnswerId="5421" CreationDate="2014-12-10T01:31:43.440" Score="5" ViewCount="34660" Body="&lt;p&gt;I'm trying to store a state in my data logger. I can read/write fine to SD, but I can't wrap my head around reading/writing a &lt;code&gt;long&lt;/code&gt; value correctly - I've build it down to converting it to char array and back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best try so far has been &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long temp = 1418172669L;&#xA;unsigned char buf[4];&#xA;buf[0] = temp         &amp;amp; 0xFF;&#xA;buf[1] = (temp &amp;gt;&amp;gt;  8) &amp;amp; 0xFF;&#xA;buf[2] = (temp &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;&#xA;buf[3] = (temp &amp;gt;&amp;gt; 24) &amp;amp; 0xFF;&#xA;&#xA;long  l = buf[0] | (buf[1] &amp;lt;&amp;lt; 8) | (buf[2] &amp;lt;&amp;lt; 16) | (buf[3] &amp;lt;&amp;lt; 24);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;l&lt;/code&gt; is very different from &lt;code&gt;temp&lt;/code&gt; - currently the output is &lt;code&gt;-26371&lt;/code&gt;. Am I making an obvious mistake?&lt;/p&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2020-08-01T16:47:46.433" Title="Convert long to char array and back" Tags="|programming|variables|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5418" PostTypeId="1" CreationDate="2014-12-10T02:33:37.103" Score="0" ViewCount="604" Body="&lt;p&gt;Hello Arduino Community,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am encountering an issue trying to retrieve a heart rate reading from an op-amp and instrumentation amplifier and sending it via Bluetooth.  I used this website as a basis of my design:  &lt;a href=&quot;http://www.instructables.com/id/Electrocardiograph-Heart-Rate-Monitor/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Electrocardiograph-Heart-Rate-Monitor/?ALLSTEPS&lt;/a&gt;.  I would appreciate it if you could take a look at that.  Here are a couple of pictures of my design.&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/CkH3w.jpg&quot; alt=&quot;1&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/j9rFB.jpg&quot; alt=&quot;2&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/y91vh.jpg&quot; alt=&quot;3&quot;&gt;&#xA;Here is the code that I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    const int  signal = 7;    // Pin connected to the filtered signal from the circuit&#xA;    unsigned long time;   &#xA;    unsigned long frequency;&#xA;&#xA;    // Internal variables&#xA;    int period = 2000;&#xA;    int starttime = 2000;&#xA;    int input = 0;&#xA;    int lastinput = 0;&#xA;    unsigned long death = 0;&#xA;&#xA;         void setup() {&#xA;           pinMode(signal, INPUT);&#xA;           Serial.begin(9600);&#xA;         }&#xA;&#xA;     void loop() {&#xA;       delay(1000);&#xA;&#xA;       time = millis();&#xA;       input = digitalRead(signal);&#xA;&#xA;       if ((input != lastinput)&amp;amp;&amp;amp;(input == HIGH)) {&#xA;       // If the pin state has just changed from low to high (edge detector)&#xA;       period = time - starttime; // Compute the time between the previous beat and the one that has just been detected&#xA;       starttime = time; // Define the new time reference for the next period computing&#xA;       death = time;&#xA;      }&#xA;      lastinput = input; // Save the current pin state for comparison at the next loop iteration&#xA;&#xA;      if (period &amp;lt; 0) {&#xA;      frequency = 0;&#xA;      }&#xA;      else {&#xA;      frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds&#xA;      }&#xA;&#xA;&#xA;      if ((time - death) &amp;gt; 2000) { // Detect if there is no beat after more than 2 seconds&#xA;      Serial.println(&quot;dead&quot;);&#xA;      }&#xA;&#xA;      else {&#xA;      char freq[3];&#xA;&#xA;      if (frequency/100 == 0) {&#xA;       freq[0] = 32; // Print a space to the first character if the frequency is below 100 bpm&#xA;      } &#xA;      else {&#xA;       freq[0] = frequency/100+48; // Sort the hundreds character and convert it in ASCII&#xA;      }&#xA;       freq[1] = (frequency/10)%10+48; // Sort the thents character and convert it in ASCII&#xA;       freq[2] = frequency%10+48; // Sort the units character and convert it in ASCII&#xA;&#xA;      Serial.print(freq);&#xA;      Serial.print(&quot;alive! &quot;);&#xA;      }&#xA;&#xA;      }`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But all I'm getting as output is 'dead'.  I am really starting to lose it here since I am a complete amateur with Arduino and circuitry.  For reference, I copied the design from this image from the website (this is just an enlarged version): &lt;a href=&quot;http://www.instructables.com/file/FVBC6TYHOW0HQ7H/?size=ORIGINAL&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/file/FVBC6TYHOW0HQ7H/?size=ORIGINAL&lt;/a&gt;.  I would appreciate it if anyone could provide some extra guidance.&lt;/p&gt;&#xA;" OwnerUserId="4941" LastEditorUserId="11529" LastEditDate="2017-03-17T20:42:53.330" LastActivityDate="2017-03-17T20:42:53.330" Title="Unable to retrieve heart rate reading and send to JY-MCU Bluetooth" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5419" PostTypeId="2" ParentId="5416" CreationDate="2014-12-10T05:43:15.720" Score="1" Body="&lt;p&gt;I think the last expression is performed exclusively as an &lt;code&gt;int&lt;/code&gt; expression and converted to &lt;code&gt;long&lt;/code&gt; only at the end, i.e. before assignment to &lt;code&gt;l&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long  l = buf[0] | (buf[1] &amp;lt;&amp;lt; 8) | (buf[2] &amp;lt;&amp;lt; 16) | (buf[3] &amp;lt;&amp;lt; 24);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the compiler calculates &lt;code&gt;buf[0] | (buf[1] &amp;lt;&amp;lt; 8) | (buf[2] &amp;lt;&amp;lt; 16) | (buf[3] &amp;lt;&amp;lt; 24)&lt;/code&gt; as an &lt;code&gt;int&lt;/code&gt; only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you give a hint to the compiler by telling it you want &lt;code&gt;long&lt;/code&gt; expressions used, then it should work. The easiest way to do so is to replace the number of bits to be shifted as &lt;strong&gt;long literals&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long  l = buf[0] | (buf[1] &amp;lt;&amp;lt; 8L) | (buf[2] &amp;lt;&amp;lt; 16L) | (buf[3] &amp;lt;&amp;lt; 24L);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should be enough for the compiler to perform the whole operation as &lt;code&gt;long&lt;/code&gt; and not loose precision.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-12-10T09:50:18.403" LastActivityDate="2014-12-10T09:50:18.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5420" PostTypeId="1" CreationDate="2014-12-10T08:45:41.730" Score="3" ViewCount="1129" Body="&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=257168.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Forum post&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to ask if someone has this shield fully working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My biggest problem is the touch screen that i couldn't manage to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code i am using:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// ic: ili9327  &#xA;#define LCD_RD   A0&#xA;#define LCD_WR   A1     &#xA;#define LCD_RS   A2        &#xA;#define LCD_CS   A3       &#xA;#define LCD_REST A4&#xA;&#xA;void Lcd_Writ_Bus(char VH)&#xA;{&#xA; unsigned char i,temp,data; &#xA; data=VH;&#xA; for(i=8;i&amp;lt;=9;i++)&#xA; {&#xA;   temp=(data&amp;amp;0x01);&#xA;   if(temp)&#xA;     digitalWrite(i,HIGH);&#xA;   else&#xA;     digitalWrite(i,LOW);&#xA;   data=data&amp;gt;&amp;gt;1;&#xA; } &#xA; for(i=2;i&amp;lt;=7;i++)&#xA; {&#xA;   temp=(data&amp;amp;0x01);&#xA;   if(temp)&#xA;     digitalWrite(i,HIGH);&#xA;   else&#xA;     digitalWrite(i,LOW);&#xA;   data=data&amp;gt;&amp;gt;1;&#xA; } &#xA;&#xA; digitalWrite(LCD_WR,LOW);&#xA; digitalWrite(LCD_WR,HIGH);&#xA;}&#xA;&#xA;&#xA;void Lcd_Write_Com(char VH)  &#xA;{   &#xA; digitalWrite(LCD_RS,LOW);&#xA; Lcd_Writ_Bus(VH);&#xA;}&#xA;&#xA;void Lcd_Write_Data(char VH)&#xA;{&#xA; digitalWrite(LCD_RS,HIGH);&#xA; Lcd_Writ_Bus(VH);&#xA;}&#xA;&#xA;void Lcd_Write_Com_Data(int com,int dat)&#xA;{&#xA; Lcd_Write_Com(com);&#xA; Lcd_Write_Data(dat);&#xA;}&#xA;&#xA;void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)&#xA;{&#xA; Lcd_Write_Com(0x2a); // Set_column_address 4 parameters&#xA; Lcd_Write_Data(x1&amp;gt;&amp;gt;8);&#xA; Lcd_Write_Data(x1);&#xA; Lcd_Write_Data(x2&amp;gt;&amp;gt;8);&#xA; Lcd_Write_Data(x2);&#xA;&#xA; Lcd_Write_Com(0x2b); // Set_page_address 4 parameters&#xA; Lcd_Write_Data(y1&amp;gt;&amp;gt;8);&#xA; Lcd_Write_Data(y1);&#xA; Lcd_Write_Data(y2&amp;gt;&amp;gt;8);&#xA; Lcd_Write_Data(y2);&#xA;&#xA; Lcd_Write_Com(0x2c); // Write_memory_start &#xA;}&#xA;&#xA;void Lcd_Init(void)&#xA;{&#xA; digitalWrite(LCD_REST,HIGH);&#xA; delay(5); &#xA; digitalWrite(LCD_REST,LOW);&#xA; delay(15);&#xA; digitalWrite(LCD_REST,HIGH);&#xA; delay(15);&#xA;&#xA; digitalWrite(LCD_CS,HIGH);&#xA; digitalWrite(LCD_WR,HIGH);&#xA; digitalWrite(LCD_CS,LOW);  //CS&#xA;&#xA; Lcd_Write_Com(0xE9);&#xA; Lcd_Write_Data(0x20);&#xA;&#xA; Lcd_Write_Com(0x11); //Exit Sleep&#xA; delay(100);&#xA;&#xA; Lcd_Write_Com(0xD1);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x71);&#xA; Lcd_Write_Data(0x19);&#xA;&#xA; Lcd_Write_Com(0xD0);&#xA; Lcd_Write_Data(0x07);&#xA; Lcd_Write_Data(0x01);&#xA; Lcd_Write_Data(0x08);&#xA;&#xA; Lcd_Write_Com(0x36);&#xA; Lcd_Write_Data(0x48);&#xA;&#xA; Lcd_Write_Com(0x3A);&#xA; Lcd_Write_Data(0x05);&#xA;&#xA; Lcd_Write_Com(0xC1);&#xA; Lcd_Write_Data(0x10);&#xA; Lcd_Write_Data(0x10);&#xA; Lcd_Write_Data(0x02);&#xA; Lcd_Write_Data(0x02);&#xA;&#xA; Lcd_Write_Com(0xC0); //Set Default Gamma&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x35);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x01);&#xA; Lcd_Write_Data(0x02);&#xA;&#xA; Lcd_Write_Com(0xC5); //Set frame rate&#xA; Lcd_Write_Data(0x04);&#xA;&#xA; Lcd_Write_Com(0xD2); //power setting&#xA; Lcd_Write_Data(0x01);&#xA; Lcd_Write_Data(0x44);&#xA;&#xA; Lcd_Write_Com(0xC8); //Set Gamma&#xA; Lcd_Write_Data(0x04);&#xA; Lcd_Write_Data(0x67);&#xA; Lcd_Write_Data(0x35);&#xA; Lcd_Write_Data(0x04);&#xA; Lcd_Write_Data(0x08);&#xA; Lcd_Write_Data(0x06);&#xA; Lcd_Write_Data(0x24);&#xA; Lcd_Write_Data(0x01);&#xA; Lcd_Write_Data(0x37);&#xA; Lcd_Write_Data(0x40);&#xA; Lcd_Write_Data(0x03);&#xA; Lcd_Write_Data(0x10);&#xA; Lcd_Write_Data(0x08);&#xA; Lcd_Write_Data(0x80);&#xA; Lcd_Write_Data(0x00);&#xA;&#xA; Lcd_Write_Com(0x2A); &#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0xeF);&#xA;&#xA; Lcd_Write_Com(0x2B); &#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x00);&#xA; Lcd_Write_Data(0x01);&#xA; //  Lcd_Write_Data(0x3F);&#xA; Lcd_Write_Data(0x8F); // on internet&#xA;&#xA; Lcd_Write_Com(0x29); //display on      &#xA;&#xA; Lcd_Write_Com(0x2C); //display on &#xA;&#xA; digitalWrite(LCD_CS,HIGH);&#xA;}&#xA;&#xA;void H_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   &#xA;{ &#xA; unsigned int i,j;&#xA; Lcd_Write_Com(0x02c); //write_memory_start&#xA; digitalWrite(LCD_RS,HIGH);&#xA; digitalWrite(LCD_CS,LOW);&#xA; l=l+x;&#xA; Address_set(x,y,l,y);&#xA; j=l*2;&#xA; for(i=1;i&amp;lt;=j;i++)&#xA; {&#xA;   Lcd_Write_Data(c);&#xA; }&#xA; digitalWrite(LCD_CS,HIGH);   &#xA;}&#xA;&#xA;void V_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)                   &#xA;{ &#xA; unsigned int i,j;&#xA; Lcd_Write_Com(0x02c); //write_memory_start&#xA; digitalWrite(LCD_RS,HIGH);&#xA; digitalWrite(LCD_CS,LOW);&#xA; l=l+y;&#xA; Address_set(x,y,x,l);&#xA; j=l*2;&#xA; for(i=1;i&amp;lt;=j;i++)&#xA; {&#xA;   Lcd_Write_Data(c);&#xA; }&#xA; digitalWrite(LCD_CS,HIGH);   &#xA;}&#xA;&#xA;void Rect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)&#xA;{&#xA; H_line(x  , y  , w, c);&#xA; H_line(x  , y+h, w, c);&#xA; V_line(x  , y  , h, c);&#xA; V_line(x+w, y  , h, c);&#xA;}&#xA;&#xA;void Rectf(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)&#xA;{&#xA; unsigned int i;&#xA; for(i=0;i&amp;lt;h;i++)&#xA; {&#xA;   H_line(x  , y  , w, c);&#xA;   H_line(x  , y+i, w, c);&#xA; }&#xA;}&#xA;&#xA;void LCD_Clear(unsigned int j)                   &#xA;{ &#xA; unsigned int i,m;&#xA; Lcd_Write_Com(0x02c); //write_memory_start&#xA; digitalWrite(LCD_RS,HIGH);&#xA; digitalWrite(LCD_CS,LOW);&#xA; Address_set(0,0,479,399);&#xA;&#xA; for(i=0;i&amp;lt;480;i++)&#xA;   for(m=0;m&amp;lt;400;m++)&#xA;   {&#xA;     Lcd_Write_Data(j);&#xA;   }&#xA; digitalWrite(LCD_CS,HIGH);   &#xA;}&#xA;&#xA;void setup()&#xA;{&#xA; for(int p=2;p&amp;lt;10;p++)&#xA; {&#xA;   pinMode(p,OUTPUT);&#xA; }&#xA; pinMode(A0,OUTPUT);&#xA; pinMode(A1,OUTPUT);&#xA; pinMode(A2,OUTPUT);&#xA; pinMode(A3,OUTPUT);&#xA; pinMode(A4,OUTPUT);&#xA; digitalWrite(A0, HIGH);&#xA; digitalWrite(A1, HIGH);&#xA; digitalWrite(A2, HIGH);&#xA; digitalWrite(A3, HIGH);&#xA; digitalWrite(A4, HIGH);&#xA; Lcd_Init();&#xA; LCD_Clear(0x00);&#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;&#xA; for(int i=0;i&amp;lt;1000;i++)&#xA; {&#xA;   Rect(random(300),random(300),random(300),random(300),random(65535)); // rectangle at x, y, with, hight, color&#xA; }&#xA; LCD_Clear(0x00);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are some pictures:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://imageshack.com/a/img908/7546/YEctM8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;1 http://imageshack.com/a/img908/7546/YEctM8.jpg&lt;/a&gt;&#xA;&lt;a href=&quot;http://imageshack.com/a/img537/5378/GIWz2x.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;3 http://imageshack.com/a/img537/5378/GIWz2x.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="5179" LastEditorUserId="37523" LastEditDate="2019-05-16T17:54:58.930" LastActivityDate="2024-01-11T22:06:45.800" Title="3.5 inch TFT LCD connection diagram with mega r3" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="5421" PostTypeId="2" ParentId="5416" CreationDate="2014-12-10T11:59:49.233" Score="9" Body="&lt;p&gt;I suggest using a union:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union {&#xA;    char myByte[4];&#xA;    long mylong;&#xA;} foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Char to Long:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can just add the bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo myUnion;&#xA;myUnion.myByte[0] = buf[0];&#xA;myUnion.myByte[1] = buf[1];&#xA;myUnion.myByte[2] = buf[2];&#xA;myUnion.myByte[3] = buf[3];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can access the long as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myUnion.myLong;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long to Char:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same if you want to go the other way from long to char array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo myUnion&#xA;myUnion.myLong = 1234L;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To access bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myUnion.myByte[0];&#xA;myUnion.myByte[1];&#xA;myUnion.myByte[2];&#xA;myUnion.myByte[3];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2778" LastEditorUserId="4603" LastEditDate="2014-12-10T22:23:06.697" LastActivityDate="2014-12-10T22:23:06.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5422" PostTypeId="1" CreationDate="2014-12-10T12:41:12.340" Score="2" ViewCount="1134" Body="&lt;p&gt;I got an Arduino Uno Rev3 and Adafruits Motor Shield V2. I also got two RepRap stepper motors: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Frame size 42 x 42mm - NEMA 17&#xA;1.8 degree step angle&#xA;Length 47mm&#xA;Holding torque 44 N.cm (4.4kg.cm, 62oz.in)&#xA;Voltage 2.8V&#xA;Current/Phase 1.68A&#xA;Resistance/Phase 1.65ohm&#xA;Inductance/Phase 2.8mH&#xA;Inertia 68g.cm&#xA;Bipolar, 4-wire&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I was going to be able to run the steppers with the motor shield, but when I tried run one of the steppers it jumps (runs little bit, then stops, then runs etc) until it reach  x steps. I'm driving the the motor shield with 12v 3A power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read somewhere that the Adafruit steppers should be at-least 5V. Is that correct? Do I need to buy new steppers or any suggestions of stepper driver (shield)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many amps do I need to run both steppers at the same time? 1.68 x 2 = 3.36A?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm building two of these: &lt;a href=&quot;https://www.youtube.com/watch?v=C15yPENQ074&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=C15yPENQ074&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions/help is appreciated! :)&lt;/p&gt;&#xA;" OwnerUserId="5183" LastEditorUserId="5183" LastEditDate="2014-12-10T16:30:49.893" LastActivityDate="2014-12-10T16:30:49.893" Title="Driving stepper motors adafruit motor shield v2" Tags="|arduino-uno|power|hardware|arduino-motor-shield|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="5423" PostTypeId="2" ParentId="5341" CreationDate="2014-12-10T15:44:37.877" Score="-1" Body="&lt;p&gt;Yup - the Galileo Ethernet port works the same way as any other Arduino. For some sketch examples have a look at&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;File &gt; Examples &gt; Ethernet&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="5175" LastEditorUserId="28084" LastEditDate="2016-11-20T12:29:44.950" LastActivityDate="2016-11-20T12:29:44.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5426" PostTypeId="2" ParentId="5416" CreationDate="2014-12-10T19:20:55.060" Score="0" Body="&lt;p&gt;Just for completeness, after posting this, I've found another way around it, but @Phataas solution is much more elegant.&#xA;Using the &lt;code&gt;ltoa&lt;/code&gt; and &lt;code&gt;atol&lt;/code&gt; functions, long to char array and vice-verse can be done like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp[10];&#xA;ltoa(669L,temp,10);&#xA;long result = atol(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4603" LastActivityDate="2014-12-10T19:20:55.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5427" PostTypeId="2" ParentId="5393" CreationDate="2014-12-10T19:39:44.883" Score="1" Body="&lt;p&gt;You have your LED's across one of the serial I/O lines (Pin 1). Use different pins.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2014-12-10T19:39:44.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5429" PostTypeId="2" ParentId="5223" CreationDate="2014-12-10T22:21:39.640" Score="0" Body="&lt;p&gt;Maybe &lt;a href=&quot;https://github.com/SINTEF-9012/JArduino&quot; rel=&quot;nofollow&quot;&gt;JArduino&lt;/a&gt; can give you some useful information.&#xA;Check the native code in jardunio.core. &lt;/p&gt;&#xA;" OwnerUserId="5192" LastEditorUserId="5192" LastEditDate="2014-12-11T01:01:41.460" LastActivityDate="2014-12-11T01:01:41.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5430" PostTypeId="1" AcceptedAnswerId="28123" CreationDate="2014-12-10T22:35:20.863" Score="2" ViewCount="4718" Body="&lt;p&gt;I am using an Arduino UNO and an &lt;a href=&quot;http://i.ebayimg.com/00/s/NzUwWDc1MA==/z/wucAAOxy0x1TRKey/$_57.JPG&quot; rel=&quot;nofollow noreferrer&quot;&gt;RXb6&lt;/a&gt; (I would link to the data sheet if I could find one) to try to decode a RF Signal that controls a remote outlet. I have the devices connected as you would assume 5V+ to 5v, Gnd to Gnd, Antenna is not connected as I think it would only exacerbate my problem, and data is connected to the A0 pin on my UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am having is with all the noise that I am getting with my signal.I hooked it up to my o-scope to give a better idea of whats happening. When no signal is being transmitted this is the noise I am seeing:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/1Qvs8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just lots of static. When I press the remote button I can see a clean signal come through (note that it is cutoff):&lt;img src=&quot;https://i.stack.imgur.com/u3V1n.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to export a CSV of the wave and manually clean it up but it was just such a pain trying to translate it back to highs and lows for the arduino to send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I reduce signal noise on my 433MHz receiver so the arduino can read the actual signal instead of noise?&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="5191" LastActivityDate="2017-10-22T19:07:11.443" Title="Sniffing RF signals" Tags="|arduino-uno|rf|signal-processing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="5431" PostTypeId="1" AcceptedAnswerId="6447" CreationDate="2014-12-11T00:03:14.787" Score="9" ViewCount="3538" Body="&lt;p&gt;I'm trying to check the frequency of Timer3 using a counter. The value of the counter, declared as volatile, is incremented in the ISR and every second the sum is shown in the main loop and the value reset to zero. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer has been set up correctly. (If I choose a 3Hz timer I can see the led blinking)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The counter isn't incremented. Here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setup Completed&#xA;tick: 1&#xA;tick: 0&#xA;tick: 0&#xA;tick: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cont = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  // Initialize Timer&#xA;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count: 800 Hz&#xA;  OCR3B = 20; // 800Hz 5; // 3 Hz&#xA;  // turn on CTC mode:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;&#xA;  Serial.println(&quot;Setup completed&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (millis() % 1000 == 0)&#xA;  {&#xA;    Serial.print(&quot; tick: &quot;);&#xA;    Serial.println(cont);&#xA;    cont = 0;&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{&#xA;  //digitalWrite(13, digitalRead(13) ^ 1);&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;This timer is used to read an anlog value from an accelerometer and store it in an array of float. But at the moment I'm stuck on this update issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLUTION 1&lt;/strong&gt;&#xA;Thanks to Gerben&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cont = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  // Initialize Timer&#xA;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count: 800 Hz&#xA;  OCR3A = 20; // 20; //800Hz 5; // 3 Hz&#xA;  // turn on CTC mode:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;  Serial.println(&quot;Setup completed&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(1000);&#xA;  Serial.println(cont);&#xA;  cont = 0;&#xA;}&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLUTION 2&lt;/strong&gt;&#xA;Thanks to BrettM&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int cont = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  // Initialize Timer&#xA;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count: 800 Hz&#xA;  OCR3B =  20; //800Hz 5; // 3 Hz&#xA;  // turn on CTC mode:&#xA;  //TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;  Serial.println(&quot;Setup completed&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(cont); &#xA;  cont = 0;&#xA;  delay(1000);&#xA;&#xA;}&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{&#xA;  TCNT3 = 0;&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="4396" LastEditDate="2014-12-11T22:54:42.450" LastActivityDate="2014-12-12T14:01:07.847" Title="How to update a variable in an ISR using Timers" Tags="|arduino-mega|interrupt|timers|variables|isr|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="5432" PostTypeId="2" ParentId="5396" CreationDate="2014-12-11T00:46:17.657" Score="3" Body="&lt;p&gt;Unfortunately, The Servo library reserves output compare A (OCR*A) on timers 1,3,4, and 5 when loaded on an arduino mega. Each can only have one ISR, so you will not be able to define your own TIMER*_COMPA_vect while you use Servo without modifying the library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, each hardware timer is equipped with 2 output compare registers. Servo does not claim any TIMER*_COMPB_vect interrupts, so those are free to use, and work exactly the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should watch out for the Servo libraries activities, it could change the configuration of your timer. The default order is on megas is 5,1,3,4 and to give each 12 servos. It only configures the timer once it needs it, so you should be fine using timer 3 until you add that 25th servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change your code, use OCR3B instead of OCR3A (the Output Compare Registers) and set bit OCIE3B instead of OCIE3A in TIMSK3 (the Output Compare Interrupt Enable bits). Then you to change your ISR function to  &lt;code&gt;ISR(TIMER3_COMPB_vect){}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CTC mode only works with OCR3A, but if you set TCNT3 to 0 in your interrupt function you can get similar behavior. Remember to remove the line that turns CTC mode on using WGM12.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-11T19:06:21.967" LastActivityDate="2014-12-11T19:06:21.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="5433" PostTypeId="1" AcceptedAnswerId="6438" CreationDate="2014-12-11T01:12:39.730" Score="3" ViewCount="569" Body="&lt;p&gt;I got this &lt;a href=&quot;http://www.icstation.com/product_info.php?products_id=1503&quot; rel=&quot;nofollow noreferrer&quot;&gt;color sensor&lt;/a&gt; last week, I've been able to get the sensor to recognize blue and red, but not green. still working on this.&#xA;I use the code in the product page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so anybody have any idea about this issue? Pretty thanks.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/f69jM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5193" LastEditorUserId="42" LastEditDate="2014-12-11T16:50:17.850" LastActivityDate="2014-12-11T16:50:17.850" Title="Why can this color sensor not recognize green?" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="5434" PostTypeId="1" CreationDate="2014-12-11T05:30:41.190" Score="0" ViewCount="496" Body="&lt;p&gt;I am a newbie to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am going to do is to change my roll to roll printer to flatbed printer.&#xA;Rather using print roller, I decided to move the bed from a stepper motor.I know how to run the stepper motor for specific distance using arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I need to cheat printer to think that its roller is working and media is going through it.But actually what I am going to do is to monitor the printer motor running or not from arduino input and if the printer motor is running stepper motor will turn or if motor stops stepper motor must stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What my problem is how can I read that the dc servo motor status? How would I need to wire arduino input to servo motor to get the status.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please show me some light on this.Sorry if this is a newbie question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you. &lt;/p&gt;&#xA;" OwnerUserId="5195" LastEditorUserId="5195" LastEditDate="2014-12-12T03:57:12.627" LastActivityDate="2016-05-06T20:59:00.960" Title="How to detect high/low signal from a DC servo motor using arduino?" Tags="|arduino-uno|pwm|arduino-motor-shield|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6434" PostTypeId="1" AcceptedAnswerId="6449" CreationDate="2014-12-11T05:44:29.527" Score="0" ViewCount="949" Body="&lt;p&gt;I have a circuit with a shift register which controls 8 LEDs: &lt;a href=&quot;http://node-ardx.org/exercises/5&quot; rel=&quot;nofollow&quot;&gt;http://node-ardx.org/exercises/5&lt;/a&gt;. In code, I created a function &lt;code&gt;cycle()&lt;/code&gt; cycle through each LED one at a time, but this occurs too quickly on the board. How can I add a delay inside the loop so that each LED stays on for 500ms?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var five = require(&quot;johnny-five&quot;), board, shiftRegister;&#xA;&#xA;board = new five.Board();&#xA;&#xA;board.on(&quot;ready&quot;, function() {&#xA;  shiftRegister = new five.ShiftRegister({&#xA;    pins: {&#xA;      data: 2,&#xA;      clock: 3,&#xA;      latch: 4&#xA;    }&#xA;  });&#xA;&#xA;  var bytes = [&#xA;    00000001,&#xA;    00000010,&#xA;    00000100,&#xA;    00001000,&#xA;    00010000,&#xA;    00100000,&#xA;    01000000,&#xA;    10000000,&#xA;    00000000&#xA;  ];&#xA;&#xA;  function cycle() {&#xA;      for ( var i = 0; i &amp;lt; bytes.length; i++ ) {&#xA;          console.log(bytes[i]);&#xA;          shiftRegister.send(bytes[i]);&#xA;      }&#xA;    }&#xA;&#xA;  this.repl.inject({&#xA;    sr: shiftRegister&#xA;  });&#xA;&#xA;  cycle();&#xA;&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1333" LastEditorUserId="1333" LastEditDate="2014-12-12T05:27:36.150" LastActivityDate="2014-12-12T05:27:36.150" Title="How to delay so that LED stays on a bit longer?" Tags="|arduino-uno|johnny-five|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6436" PostTypeId="1" CreationDate="2014-12-11T09:07:46.763" Score="0" ViewCount="1103" Body="&lt;p&gt;Does anyone know the location of the assembler file for strcpy and strcat for the Arduino?  I wish to modify it.&lt;/p&gt;&#xA;" OwnerUserId="6194" LastActivityDate="2014-12-11T09:52:23.157" Title="Source Code for strcpy and strcat" Tags="|core-libraries|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6437" PostTypeId="2" ParentId="6436" CreationDate="2014-12-11T09:52:23.157" Score="5" Body="&lt;p&gt;The Arduino IDE doesn't ship with the source/assembly for a lot of the core functionality. It comes pre-compiled in object/library files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you could download the source code for AVR Libc from this site:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc&quot; rel=&quot;noreferrer&quot;&gt;http://www.nongnu.org/avr-libc&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Obviously there's no guarantee that the files you download will exactly match what comes with the Arduino IDE, but it's useful if you're interested in how they're implemented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you've downloaded and extracted the source code, look in the &lt;code&gt;libc/string&lt;/code&gt; folder. you should find assembly files called &lt;code&gt;strcat.S&lt;/code&gt; and &lt;code&gt;strcpy.S&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As jfpoilpret says in the comments, attempting to modify core library functions is generally not a good idea. They may be getting called by other parts of the core, so any changes you make could break something else.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-11T09:52:23.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6438" PostTypeId="2" ParentId="5433" CreationDate="2014-12-11T10:07:51.347" Score="4" Body="&lt;p&gt;Check that you've connected all the Arduino pins correctly to the sensor. In particular, make sure pin 4 on the Arduino is connected to S2 on the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the combination of signals on S2 and S3 which determines which colour is being detected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S2    S3    Colour&#xA;----  ----  ------&#xA;Low   Low   Red&#xA;Low   High  Blue&#xA;High  Low   Clear&#xA;High  High  Green&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If S2 is always low then you can only detect red and blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the connections are definitely correct, then ensure you haven't made any code modifications which could interfere with it. You may also want to test pin 4 on your Arduino (e.g. using a multimeter) to make sure it's working properly. If necessary, you could use a different pin instead. However, you'll need to modify the &lt;code&gt;#define S2&lt;/code&gt; line in the code to match.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-11T10:07:51.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6439" PostTypeId="2" ParentId="6434" CreationDate="2014-12-11T10:22:42.963" Score="2" Body="&lt;p&gt;Insert a delay of 500ms?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function cycle() {&#xA;    for ( var i = 0; i &amp;lt; bytes.length; i++ ) {&#xA;        console.log(bytes[i]);&#xA;        sr.send(bits[i]);&#xA;        delay(500);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2014-12-11T10:22:42.963" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6441" PostTypeId="2" ParentId="5434" CreationDate="2014-12-11T12:51:09.207" Score="1" Body="&lt;p&gt;Do you need to check if it is stalled? Or simply running?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, you could check the voltage with an analogue input, compare against a threshold (empirically set) &amp;amp; use that. Take the voltage reading from the non-commoned side of the motor, after any driver circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want stalled, a small resistance would help, if just running then you could get away with a digital input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the voltages aren't matched then a resistance divider chain would be necessary.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2014-12-11T12:51:09.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6442" PostTypeId="1" AcceptedAnswerId="6443" CreationDate="2014-12-11T13:05:41.360" Score="2" ViewCount="742" Body="&lt;p&gt;I have the following memory allocation: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char g1[]={&#xA;  0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ....0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; &#xA;g2[]={&#xA;  0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ....0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; &#xA;... &#xA;&#xA; unsigned char* index[10] = {g1,g2,g3,g4,g5,g6,g7,g8,g9,g0}; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is accessed in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char* getMatch(int input){&#xA;  return index[input];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is then futher acces using the method of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char store[1024]&#xA;unsigned char* temp = getMatch(n);&#xA;for(int i=0;i &amp;lt;50;i++){&#xA; store[i]=temp[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and store is then modified and send to an external device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As my program is randomly failing I think it might be running low on SRAM and was wondering if there is any way to force this memory to be placed in flash. Anybody got an idea?&lt;/p&gt;&#xA;" OwnerUserId="5165" LastEditorUserId="5165" LastEditDate="2014-12-11T13:58:28.790" LastActivityDate="2014-12-11T13:58:28.790" Title="Are my arrays stored in sram or in Flash?" Tags="|arduino-uno|c++|memory-usage|sram|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6443" PostTypeId="2" ParentId="6442" CreationDate="2014-12-11T13:34:22.717" Score="5" Body="&lt;p&gt;It's stored in both the FLASH and SRAM because it's initialized array. To store in FLASH only you need use PROGMEM attribute.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned PROGMEM char g1[]= ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You cannot access directly but using &lt;em&gt;memcpy_P()&lt;/em&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2014-12-11T13:34:22.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6444" PostTypeId="2" ParentId="5408" CreationDate="2014-12-11T14:09:42.673" Score="3" Body="&lt;p&gt;Ignacio's proposal is surely a good one if you really need higher sample rates, but I would try another approach: &lt;br&gt;&#xA;Average your signal before sampling it! This can be done by connecting a simple &lt;a href=&quot;http://hyperphysics.phy-astr.gsu.edu/hbase/electric/filcap2.html#c2&quot; rel=&quot;nofollow&quot;&gt;RC lowpass&lt;/a&gt; to your AD input. &lt;br&gt;&#xA;With that you get rid off those high frequency noise you don't need, but without wasting CPU time.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2014-12-11T14:09:42.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6447" PostTypeId="2" ParentId="5431" CreationDate="2014-12-11T16:47:57.687" Score="5" Body="&lt;p&gt;In CTC mode the top is &lt;code&gt;OCR3A&lt;/code&gt;, not &lt;code&gt;OCR3B&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that &lt;code&gt;TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&lt;/code&gt; should also be changed to &lt;code&gt;TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3A);&lt;/code&gt;, and &lt;code&gt;ISR(TIMER3_COMPB_vect)&lt;/code&gt; to &lt;code&gt;ISR(TIMER3_COMPA_vect)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 3Hz, &lt;code&gt;OCR3A&lt;/code&gt; should be 5208, not 20.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically &lt;code&gt;TCCR3B |= (1 &amp;lt;&amp;lt; WGM12);&lt;/code&gt; should be &lt;code&gt;TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-12-12T14:01:07.847" LastActivityDate="2014-12-12T14:01:07.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6448" PostTypeId="2" ParentId="5418" CreationDate="2014-12-11T16:54:01.893" Score="1" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PVy3v.png&quot; alt=&quot;enter image description here&quot;&gt;assuming your circuit works, your code has some serious issues. I rewrote the code for you and also provided a simplified circuit that I have tested and know works.  Instead of getting the pulse from the heartbeat detector circuit, we will simulate it on the Arduino by pulsing pin 2 periodically. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int  signal = 7;    // Pin connected to the filtered signal from the circuit&#xA;unsigned long currentBeatTime;   &#xA;unsigned long previousBeatTime;&#xA;&#xA;unsigned long frequency;&#xA;&#xA;unsigned long myBeatFreq;&#xA;unsigned long myBeat;&#xA;&#xA;// Internal variables&#xA;unsigned long period = 0;&#xA;int input = 0;&#xA;int lastinput = 0;&#xA;&#xA;&#xA;void setup() {&#xA;    pinMode(signal, INPUT);&#xA;    pinMode(2, OUTPUT);&#xA;    Serial.begin(9600);&#xA;&#xA;    previousBeatTime = millis();&#xA;    myBeat = previousBeatTime;&#xA;}&#xA;&#xA;void loop() {&#xA;    if ( millis()-myBeat &amp;gt; myBeatFreq ) &#xA;    {&#xA;      digitalWrite(2, HIGH);&#xA;      myBeat=millis();&#xA;    }&#xA;    else&#xA;    {&#xA;      digitalWrite(2, LOW);&#xA;    }&#xA;&#xA;    input = digitalRead(signal);&#xA;&#xA;    if ((input != lastinput) &amp;amp;&amp;amp; (input == HIGH)) {&#xA;        // If the pin state has just changed from low to high (edge detector)&#xA;        currentBeatTime = millis();&#xA;&#xA;        period = currentBeatTime - previousBeatTime; // Compute the time between the previous beat and the one that has just been detected&#xA;        previousBeatTime = currentBeatTime; // Define the new time reference for the next period computing&#xA;    }&#xA;&#xA;    lastinput = input; // Save the current pin state for comparison at the next loop iteration&#xA;&#xA;    // Detect if there is no beat after more than 2 seconds&#xA;    if ( (millis() - previousBeatTime) &amp;gt; 2000 ) &#xA;    { &#xA;        Serial.println(&quot;dead&quot;);&#xA;    }&#xA;    else &#xA;    {&#xA;        if (period &amp;lt;= 0) &#xA;        {&#xA;            frequency = 0;&#xA;        }&#xA;        else &#xA;        {&#xA;            frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds&#xA;        }&#xA;&#xA;        Serial.print(frequency);&#xA;        Serial.println(&quot; : alive! &quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="497" LastEditorUserId="497" LastEditDate="2014-12-25T04:43:18.580" LastActivityDate="2014-12-25T04:43:18.580" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6449" PostTypeId="2" ParentId="6434" CreationDate="2014-12-11T16:59:00.107" Score="1" Body="&lt;p&gt;The answer is already provided in the article.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  var i = 0; &#xA;  function cycle() {&#xA;    console.log(bytes[i]);&#xA;    sr.send(bits[i]);&#xA;    i++;&#xA;    if( i&amp;lt;bytes.length )&#xA;      setTimeout(cycle, 300);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-12-11T19:17:01.153" LastActivityDate="2014-12-11T19:17:01.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6450" PostTypeId="1" AcceptedAnswerId="6451" CreationDate="2014-12-11T13:44:13.547" Score="0" ViewCount="58" Body="&lt;p&gt;my first post here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway I'm working on a Simon Says game.&#xA;I have a weird bug with the function that reads button input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int deBounce(int count){&#xA;  int pressed=-1;&#xA;  int laastButtons[3]; // save the previous deBounce read.&#xA;  for(int x; x&amp;lt;4; x++)&#xA;  {&#xA;    laastButtons[x] = lastButtons[x];&#xA;    lastButtons[x] = !digitalRead(button[x]);&#xA;    if(lastButtons[x] == true)&#xA;    {&#xA;      delay(50);&#xA;      lastButtons[x] = !digitalRead(button[x]);&#xA;      if(lastButtons[x] == 1){ pressed = x;}&#xA;      nt(&quot;Pressed!, Button ID: &quot;);nt(x); nt(&quot; pressed:  &quot;);nt(pressed); nt(&quot; state &quot;); ntln(lastButtons[x]);&#xA;    }&#xA;  }&#xA;  if((lastButtons[0] + lastButtons[1] + lastButtons[2] + lastButtons[3]) &amp;gt; 1)&#xA;  {&#xA;    ntln(&quot;ERROR: dont press more than one button at a time. &quot;);&#xA;  }&#xA;  if( ((lastButtons[0] + lastButtons[1] + lastButtons[2] + lastButtons[3]) == 1 ) &amp;amp;&amp;amp; !laastButtons[pressed] &amp;amp;&amp;amp; (pressed != -1) ) { &#xA;    pressButtons[count] = pressed;&#xA;    nt(&quot;Pressed!, ID: &quot;);nt(count); nt(&quot; Button ID &quot;);ntln(pressed);&#xA;    return count++;&#xA;  }else return count;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I recieve in the Serial Monitor if I press one of the buttons.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pressed!, Button ID: 3 pressed: -1 state 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How is that possible? Note the lines where that line is printed and the line above it.&#xA;Seems like that if should run, but the line pressed = x; doesn't function.&#xA;Note that, nt and ntln are just a short for Serial.print.&#xA;I have this weird bug and sometimes it seems like the chip is glitching!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another question is- I tried attaching interrupt and it didn't worked,&#xA;Is it possible that my board is not compatiable with them? (It's not original).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After Majenko helped me figure it out,&#xA;The thing that created the bug was that I expected a x==0, but I didn't define it in the for loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int x; x&amp;lt;4; x++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int x=0; x&amp;lt;4; x++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks again Majenko!&lt;/p&gt;&#xA;" OwnerUserId="6201" OwnerDisplayName="user2054911" LastEditorUserId="6201" LastEditDate="2014-12-11T17:28:57.553" LastActivityDate="2014-12-11T17:28:57.553" Title="Arduino - Progamming issue" Tags="|serial|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6451" PostTypeId="2" ParentId="6450" CreationDate="2014-12-11T13:47:56.227" Score="6" Body="&lt;pre&gt;&lt;code&gt;int laastButtons[3]; // save the previous deBounce read.&#xA;for(int x; x&amp;lt;4; x++)&#xA;{&#xA;   laastButtons[x] = lastButtons[x];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, there's a common bug right away.  An array with three slices, numbered 0, 1 and 2, and you're accessing them with a loop that counts from 0 to 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spot the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in the for loop, what number does it start counting from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now for your &quot;bug&quot;.  This block of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(lastButtons[x] == true)&#xA;{&#xA;  delay(50);&#xA;  lastButtons[x] = !digitalRead(button[x]);&#xA;  if(lastButtons[x] == 1){ pressed = x;}&#xA;  nt(&quot;Pressed!, Button ID: &quot;);nt(x); nt(&quot; pressed:  &quot;);nt(pressed); nt(&quot; state &quot;); ntln(lastButtons[x]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you have it slightly wrong.  Let's convert it into plain english:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If button is pressed:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Delay 50 ms&lt;/li&gt;&#xA;&lt;li&gt;Read button again&lt;/li&gt;&#xA;&lt;li&gt;If button is pressed:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set &lt;em&gt;pressed&lt;/em&gt; to the button number&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Print the button message&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note the indenting, which highlights what gets executed for what IF statement.  The print is going to happen regardless of the setting of the &lt;em&gt;pressed&lt;/em&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the structure you wanted is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If button is pressed:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Delay 50 ms&lt;/li&gt;&#xA;&lt;li&gt;Read button again&lt;/li&gt;&#xA;&lt;li&gt;If button is pressed:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set &lt;em&gt;pressed&lt;/em&gt; to the button number&lt;/li&gt;&#xA;&lt;li&gt;Print the button message&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In that layout the second If is controlling both the setting of the &lt;em&gt;pressed&lt;/em&gt; variable as well as whether or not to print the Pressed! message.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(lastButtons[x] == 1){ pressed = x;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line is saying &quot;If last buttons X is 1, then set pressed to X. That is all it is doing. Nothing more, nothing less.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-12-11T14:38:34.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6454" PostTypeId="1" CreationDate="2014-12-11T18:29:54.493" Score="2" ViewCount="711" Body="&lt;p&gt;I am trying to control 4 motors using 2 joysticks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to send continuous analog values of 2 joysticks (x &amp;amp; y both). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using bluetooth HC-05. I am using the basic logic that is sending a character before each analog value and thus sending all 4 values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem here is at the reception end, data is not received correctly. Error rate is very high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is their any other way or improved program to do that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//this is my part of the code at the transmitter side&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;int a,b,c,d;&#xA;int ry = A0; // forward backward&#xA;int rx = A1;//rotate&#xA;int lx = A3; //right left&#xA;int ly = A4;&#xA;SoftwareSerial blu(10, 11); // TX,RX&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  blu.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;   a = analogRead(ry)/4;&#xA;   d = analogRead(rx)/4;&#xA;   c= analogRead(ly)/4&#xA;   b = analogRead(lx)/4;&#xA;&#xA;   blu.write(&quot;w&quot;);&#xA;   blu.write(a);&#xA;   blu.write(&quot;x&quot;);&#xA;   blu.write(b);   &#xA;   blu.write(&quot;y&quot;);&#xA;   blu.write(c); &#xA;   blu.write(&quot;z&quot;);&#xA;   blu.write(d); &#xA;      }&#xA;&#xA;}&#xA;&#xA;// Code at the reciever side&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(12,13); // tx,rx&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  digitalWrite(gnd1 , LOW);&#xA;  digitalWrite(gnd2 , LOW);&#xA;&#xA;  pinMode(motor1, OUTPUT);&#xA;  pinMode(motor2, OUTPUT);&#xA;&#xA;  pinMode(dir1, OUTPUT);&#xA;  pinMode(dir2, OUTPUT);&#xA;  pinMode(dir_1, OUTPUT);&#xA;  pinMode(dir_2, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (mySerial.available())&#xA;  {&#xA;    a=mySerial.read();&#xA;        if(a=='w' || z=='x' || a=='y' || a=='z')&#xA;        {&#xA;          if(a=='w')&#xA;        c_b=mySerial.read();&#xA;        b=map(c_b,0,255,-255,255);&#xA;        motorspeed1(b);&#xA;      }&#xA;   if(a=='x'){&#xA;&#xA;            int c_c=mySerial.read();&#xA;            b=map(c_c,0,255,-255,255);&#xA;            motorspeed2(c);&#xA;&#xA;          }&#xA;if(a=='y'){&#xA; int c_d=mySerial.read();&#xA;            d=map(c_d,0,255,-255,255);&#xA;            motorspeed3(d);&#xA;  } &#xA;if(a=='z'){&#xA; int c_e=mySerial.read();&#xA;            e=map(c_e,0,255,-255,255);&#xA;            motorspeed3(e);&#xA;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//motor speed function takes care of the direction and the pwm. my problem is at the receiving end the values are not proper . error is very high mySerial.read() gives false values&lt;/p&gt;&#xA;" OwnerUserId="6204" LastEditorUserId="6204" LastEditDate="2014-12-12T18:27:55.510" LastActivityDate="2014-12-12T18:27:55.510" Title="Wireless serial communication. Sending 4 different continuous values" Tags="|serial|bluetooth|arduino-duemilanove|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6455" PostTypeId="2" ParentId="5431" CreationDate="2014-12-11T19:16:57.073" Score="3" Body="&lt;p&gt;It seems my answer to &lt;a href=&quot;https://arduino.stackexchange.com/questions/5396/setting-timer3-in-ctc-mode-conflict-with-servo-library/5432#5432&quot;&gt;this question&lt;/a&gt; was previously incomplete, thanks for pointing out that CTC mode only works with OCR3A Gerben. I apologize for not testing an answer before I post it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the information only in this question Gerben's answer is complete, but since your other question implies that you cannot use OCR3A due to the Servo library I'll add a bit. (I've also edited that answer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can emulate the behavior of CTC mode by setting TCNT3 to 0 in your interrupt routine. Remember to remove the line that turns on CTC mode in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested your code with this ISR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER3_COMPB_vect)&#xA;{&#xA;  TCNT3 = 0;&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this configuration of the timer registers &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OCR3B = 5208; // 800Hz 5; // 3 Hz&#xA;// Set CS10 and CS12 bits for 1024 prescaler:&#xA;TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;// enable timer compare interrupt:&#xA;TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This might be a bit less accurate at high frequencies than CTC, I'm not sure, but at 3Hz it worked perfectly. Notice that 5208 was the correct OCR value, not 20 (again thanks to Gerben). &lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-11T22:08:49.133" LastActivityDate="2014-12-11T22:08:49.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6456" PostTypeId="1" CreationDate="2014-12-11T21:12:35.697" Score="1" ViewCount="6208" Body="&lt;p&gt;I have set up a system using 4 arduino clones, each wired to an NRF24L01+ radio. I am using the RF24 library by maniacbug (&lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/maniacbug/RF24&lt;/a&gt;) and have set-up the nodes with 1 base node as a receiver and 3 child nodes that transmits continuously to the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is to send the read and analog value wirelessly from the child nodes to the base node as fast as possible. I used the starping example as a guide and it looks almost realtime when only 1 child node is active. When I turn on another child node, most of the time the update stops for a while then continue on, with randomly updating either child 1 or child 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing there's a collision that's causing the delays. How do I lessen these delays? I'm thinking of having some sort of scheduling system for the children to send their messages (like, child2 will send only after child1, etc.) I also tried &lt;code&gt;radio.setAutoAck(false)&lt;/code&gt; in an attempt to lessen the delays but that made all my readings stop altogether. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;base node&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &quot;Timer.h&quot;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &quot;nRF24L01.h&quot;&#xA;    #include &quot;RF24.h&quot;&#xA;    #include &quot;printf.h&quot;&#xA;&#xA;    RF24 radio(9,10);&#xA;    Timer t;&#xA;&#xA;    const uint64_t pipes[5] = { 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL, 0xF0F0F0F0B4LL, 0xF0F0F0F0A5LL, 0xF0F0F0F096LL };&#xA;    unsigned int values[3] = {0,0,0};&#xA;    void setup(void)&#xA;    {&#xA;&#xA;&#xA;      Serial.begin(115200);&#xA;      printf_begin();&#xA;      //printf(&quot;Receiver Node Active\n\r&quot;);&#xA;&#xA;      radio.begin();&#xA;&#xA;        radio.openReadingPipe(1,pipes[0]);&#xA;        radio.openReadingPipe(2,pipes[1]);&#xA;        radio.openReadingPipe(3,pipes[2]);&#xA;        radio.openReadingPipe(4,pipes[3]);&#xA;        radio.openReadingPipe(5,pipes[4]);&#xA;&#xA;      radio.startListening();&#xA;      radio.printDetails();&#xA;      t.every(1, print_values); //call print_values() every 1ms&#xA;&#xA;    }&#xA;&#xA;    void loop(void)&#xA;    {&#xA;        int sender_id;&#xA;        uint8_t pipe_num;&#xA;        if ( radio.available(&amp;amp;pipe_num) )&#xA;        {&#xA;          unsigned int message;&#xA;          bool done = false;&#xA;            while (!done)&#xA;            {&#xA;                done = radio.read( &amp;amp;message, sizeof(message) );         &#xA;            }&#xA;          sender_id = pipe_num - 1;&#xA;          values[sender_id-1] = message;&#xA;        }&#xA;        delay(1);&#xA;        t.update();&#xA;&#xA;     }&#xA;&#xA;     void print_values(){&#xA;       //formatted for arduinoscope&#xA;       printf(&quot;%d %d %d 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n&quot;, values[0], values[1], values[2]);&#xA;     }&#xA;    // vim:ai:ci sts=2 sw=2 ft=cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;child node:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &quot;nRF24L01.h&quot;&#xA;    #include &quot;RF24.h&quot;&#xA;&#xA;&#xA;    RF24 radio(0,1);&#xA;&#xA;    const int SW01 = 18;&#xA;    const int SW02 = 19;&#xA;&#xA;    const uint64_t pipes[5] = { 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL, 0xF0F0F0F0B4LL, 0xF0F0F0F0A5LL, 0xF0F0F0F096LL };&#xA;    int node_id;&#xA;&#xA;    void setup(void)&#xA;    {&#xA;      node_id=3; //hard coded id&#xA;      radio.begin();&#xA;      radio.openWritingPipe(pipes[node_id]);&#xA;    }&#xA;&#xA;    void loop(void)&#xA;    {&#xA;        unsigned int val = analogRead(A0);&#xA;        radio.write( &amp;amp;val, sizeof(val) );&#xA;        //delay(1);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4958" LastEditorUserId="4958" LastEditDate="2014-12-11T21:18:47.730" LastActivityDate="2017-05-12T16:14:00.813" Title="Delay on multiple NRF24L01+ (RF24.h) and Arduino nodes" Tags="|nrf24l01+|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6457" PostTypeId="1" AcceptedAnswerId="6459" CreationDate="2014-12-11T22:49:45.790" Score="1" ViewCount="144" Body="&lt;p&gt;I want to set one pin's output value, and then set a different pin's output value so that the two pins change value one after the other.&#xA;However, the compiler optimises the two calls to change both pins in one go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;PORTD |= _BV(0);    //set pd0 to high&#xA;PORTD |= _BV(1);    //set pd1 to high&#xA;PORTD &amp;amp;= ~(_BV(1)); //set pd1 to low&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two pins go high simultaneously. I tried inserting a NOP between these but it doesn't change behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I originally intended to include an oscilloscope screengrab to show what was happening - that's how I knew (or got the wrong impression) that the two pins were changing at the same time. But the photo wasn't shifting from my Nexus 7 for me to access it from my laptop.)&lt;/p&gt;&#xA;" OwnerUserId="6215" OwnerDisplayName="mackenir" LastEditorUserId="58951" LastEditDate="2019-10-25T13:55:06.453" LastActivityDate="2019-10-25T13:55:06.453" Title="How to prevent Arduino compiler from merging changing of port pin outputs into a single operation" Tags="|c|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="6459" PostTypeId="2" ParentId="6457" CreationDate="2014-12-12T00:37:41.337" Score="7" Body="&lt;p&gt;I certainly can't duplicate what you are saying.  The small code snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    PORTD |= _BV(0);&#xA;    PORTD |= _BV(1);&#xA;    PORTD &amp;amp;= ~(_BV(1));&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;compiles into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000000a6 &amp;lt;setup&amp;gt;:&#xA;  a6:   58 9a           sbi 0x0b, 0 ; 11&#xA;  a8:   59 9a           sbi 0x0b, 1 ; 11&#xA;  aa:   59 98           cbi 0x0b, 1 ; 11&#xA;  ac:   08 95           ret&#xA;&#xA;000000ae &amp;lt;loop&amp;gt;:&#xA;  ae:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is clearly two separate bit sets followed by a bit clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using UECIDE that is set to use GCC 4.3.2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I switch to GCC 4.8.1 instead, the code generated is identical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even turning on full -O3 optimization I still get the same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how are you determining that it's happening at the same time?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2014-12-12T00:45:49.837" LastActivityDate="2014-12-12T00:45:49.837" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6460" PostTypeId="1" AcceptedAnswerId="6461" CreationDate="2014-12-12T03:51:09.900" Score="2" ViewCount="13719" Body="&lt;p&gt;As it says in the title. I have been searching but I cant seem to find the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the difference between void setup() and void setup(void) as well as void loop() and void loop(void)?&lt;/p&gt;&#xA;" OwnerUserId="6205" LastActivityDate="2020-06-26T05:59:02.903" Title="Difference between void setup() and void setup(void)" Tags="|programming|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6461" PostTypeId="2" ParentId="6460" CreationDate="2014-12-12T03:54:40.087" Score="8" Body="&lt;p&gt;Absolutely nothing, in modern versions of C and C++. Specifying no arguments is the same as specifying &lt;code&gt;void&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In old versions of C a function with no arguments took a single implicit &lt;code&gt;int&lt;/code&gt; argument or allowed you to specify the arguments on a separate line, but no one uses anything like that nowadays.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-12T03:54:40.087" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6462" PostTypeId="2" ParentId="3642" CreationDate="2014-12-12T07:36:36.940" Score="1" Body="&lt;p&gt;Try moving the &quot;Cores&quot; folder from the avi directory to the attiny director. The path was wrong for me and I was getting the same error. Had the same issue with the bootloader file. Moved it out of the avi folder as well and all worked ok then.&lt;/p&gt;&#xA;" OwnerUserId="6209" LastActivityDate="2014-12-12T07:36:36.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6463" PostTypeId="1" AcceptedAnswerId="6465" CreationDate="2014-12-12T07:07:34.213" Score="1" ViewCount="3786" Body="&lt;p&gt;I am having trouble opening the Arduino software on my mac, since I have updated Java to version 8 the Arduino software won't open. It does not give an error just closes instantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried getting the newest version of the Arduino.cc site but no change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me how to open Arduino using an older version of Java?&lt;/p&gt;&#xA;" OwnerUserId="6211" OwnerDisplayName="Ashley Hughes" LastEditorUserId="220" LastEditDate="2015-01-22T14:12:13.050" LastActivityDate="2019-03-16T00:50:46.370" Title="Arduino software won't open in Mac OSX 10.10.1" Tags="|arduino-ide|mac-os|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6464" PostTypeId="1" CreationDate="2014-12-12T08:02:56.127" Score="3" ViewCount="2925" Body="&lt;p&gt;I have an Arduino uno board and I have a soil moisture sensor&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;connected the digital output pin of the sensor to Arduino input pin &lt;/li&gt;&#xA;&lt;li&gt;connected an output pin of Arduino to the INPUT pin of the relay board &lt;/li&gt;&#xA;&lt;li&gt;programmed the Arduino such that if input is HIGH then the OUTPUT should be HIGH as well &lt;/li&gt;&#xA;&lt;li&gt;connected 5 v pin of Arduino to vcc of the relay board&lt;/li&gt;&#xA;&lt;li&gt;connected gnd pin of Arduino to gnd of the relay board &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When my sensor outputs a HIGH DO (digital output), the relay only creates a feeble click sound and does not get activated. The Relay board LED does light up but the relay itself does not work (NC remains closed and NO remains open).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to supply an external VCC to the relay board? If yes then how should I set up the circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A picture of the relay board is attached. You are right ... it is a 12 v relay. Do I need a 12 v external power source with IN1 coming from Arduino? Any help will be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MIIck.jpg&quot; alt=&quot;Relay&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6210" LastEditorUserId="6257" LastEditDate="2014-12-15T22:24:32.253" LastActivityDate="2014-12-15T22:24:32.253" Title="Feeble click in relay but it doesn't get activated when connected to Arduino circuit" Tags="|arduino-uno|relay|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6465" PostTypeId="2" ParentId="6463" CreationDate="2014-12-12T08:16:50.427" Score="2" Body="&lt;p&gt;Download and install the Apple version of Java (6): &lt;a href=&quot;http://support.apple.com/kb/DL1572&quot; rel=&quot;nofollow&quot;&gt;http://support.apple.com/kb/DL1572&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need Java 8 SDK for some reason, the two can coexist because the Arduino IDE will explicitly ask for the (Apple Version) of Java 1.6 using 'JavaApplicationStub':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ./JavaApplicationStub&#xA;[JavaAppLauncher] Requested [1.5*], launching in [1.6] instead.&#xA;Experimental:  JNI_OnLoad called.&#xA;Stable Library&#xA;=========================================&#xA;Native lib Version = RXTX-2.1-7&#xA;Java lib Version   = RXTX-2.1-7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note however that if you have both Apple Java and Oracle installed, running 'java' or 'javac' form the command line will run the Oracle version.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ java -version&#xA;java version &quot;1.8.0_25&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to switch the 'command line' version, change the symlinks in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/System/Library/Frameworks/JavaVM.framework/Versions/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;'JavaApplicationStub' will use the Apple version located in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such, 'normal' java programs will generally use the Oracle version, while applications running in your browser or using JavaApplicationStub explicitly (like Arduino) will use the 'Apple' version.&lt;/p&gt;&#xA;" OwnerUserId="1307" LastEditorUserId="1307" LastEditDate="2014-12-12T08:38:11.187" LastActivityDate="2014-12-12T08:38:11.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6467" PostTypeId="1" AcceptedAnswerId="6470" CreationDate="2014-12-12T12:42:56.277" Score="0" ViewCount="62" Body="&lt;p&gt;I used to work with PIC micro-controller so i know what it needs to work from operating circuit to crystal oscillators needed and other components to power it up , my question here where can i find the operating circuit for ATmega32p-pu and other AVR models . or all i need to do is to give it +5v and gnd and it will work ? &lt;/p&gt;&#xA;" OwnerUserId="3936" LastActivityDate="2014-12-12T13:49:37.650" Title="AVR ATmega328p-pu operating circuit?" Tags="|avr|arduino-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6468" PostTypeId="1" CreationDate="2014-12-12T13:00:52.377" Score="5" ViewCount="5819" Body="&lt;p&gt;I am working on a project with Arduino and I need an Ethernet shield. but after searching in some electronics shops I found there isn't only one but a lot. I don't know which one is better and what are the differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=502&amp;amp;search=ethernet+&amp;amp;description=true&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Ethernet with PoE module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;search=ethernet%20&amp;amp;description=true&amp;amp;product_id=497&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ethernet Pro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ethernet Shield for Arduino - W5200&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Ethernet Rev3 Without PoE Module&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ethernet Shield W5100 For Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in DFRobot Online Shop.&lt;/p&gt;&#xA;" OwnerUserId="6212" LastEditorUserId="26916" LastEditDate="2017-09-09T23:53:27.563" LastActivityDate="2017-09-09T23:53:27.563" Title="What's the difference between different Ethernet Shields?" Tags="|shields|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6470" PostTypeId="2" ParentId="6467" CreationDate="2014-12-12T13:49:37.650" Score="1" Body="&lt;p&gt;You're looking for &lt;a href=&quot;http://arduino.cc/en/main/standalone&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; I think? How to set up an Arduino on a breadboard.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2014-12-12T13:49:37.650" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6471" PostTypeId="1" CreationDate="2014-12-07T12:39:14.120" Score="2" ViewCount="634" Body="&lt;p&gt;I want have 2 74HC595N shift registers in series. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I built this schematic&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/izHwV.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I send a value to the first register, it is sent to the second one. I have same value on both. I change them (master/slave) but the result is the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected pin 9 on the first SR first with pin 14 on the second. I am using Johnny Five on Galileo Gen 1 with &lt;code&gt;shiftRegister.send(25)&lt;/code&gt; to send the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong because several days ago I made it and it worked?&lt;/p&gt;&#xA;" OwnerDisplayName="Val Valli" LastEditorUserId="220" LastEditDate="2015-01-21T21:59:58.483" LastActivityDate="2015-02-20T22:31:43.480" Title="74HC595N in series error" Tags="|arduino-galileo|shift-register|johnny-five|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6472" PostTypeId="1" CreationDate="2014-12-12T14:00:27.473" Score="2" ViewCount="1630" Body="&lt;p&gt;I'm using an RC522 RFID reader with an Arduino UNO. There is a function?? (or whatever it's called :)) in Miguel Balboa's new MFRC522.h library which is mfrc522.uid.uidByte[i] that prints the bytes of the unique ID. The repetition of the function results in 8 piece of HEX digits that are from the 2 numbers that each function outputs (2+2+2+2=8). Whenever I use the line of codes that are commented out, the serial monitor outputs them successfully. So for example, 12345678 is the unique id, each array displayed 12, then 34, then, 56, then 78 which is 12345678 in the serial. which is fast and unnoticeable besides that there are no spaces included when on output. The thing is, I want to output all of these into a single variable.(Please help me also on how to concatenate) How can I do this? An attempt was done below (not commented out) but it outputs only the number 16, consistently, which is I think due to a data type problem. The variables are initialized as int. The &quot;function&quot; which I found in the library is initialized as byte (correct me If I'm wrong). But when the variables are initialized as byte, I cannot upload the sketch since there are errors. Please help. :( (The reason I need it to be saved into a single variable is because I am placing it in the GET method of an Ethernet Client. I don't think the bare function can do that. (Or if it can, can you please help with the code? :)) Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;pre&gt; &lt;code&gt;&#xA;// Dump UID&#xA;        //Serial.print(&quot;Card UID:&quot;);&lt;/p&gt;&#xA;&#xA;            //Serial.print(mfrc522.uid.uidByte[0], HEX);&#xA;            //Serial.print(mfrc522.uid.uidByte[1], HEX);&#xA;            //Serial.print(mfrc522.uid.uidByte[2], HEX);&#xA;            //Serial.print(mfrc522.uid.uidByte[3], HEX);&#xA;&#xA;&#xA;            serNum0={mfrc522.uid.uidByte[0], HEX};&#xA;            serNum1={mfrc522.uid.uidByte[1], HEX};&#xA;            serNum2={mfrc522.uid.uidByte[2], HEX};&#xA;            serNum3={mfrc522.uid.uidByte[3], HEX};&#xA;            Serial.print(serNum0);&#xA;            Serial.print(serNum1);&#xA;            Serial.print(serNum2);&#xA;            Serial.print(serNum3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4609" LastEditorUserId="4609" LastEditDate="2014-12-12T14:12:13.540" LastActivityDate="2015-03-07T16:46:46.217" Title="How to pass value of a function from the RFID-RC522 library into a variable then be sent into either serial or ethernet?" Tags="|variables|rfid|data-type|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6473" PostTypeId="2" ParentId="6464" CreationDate="2014-12-12T18:35:11.200" Score="6" Body="&lt;p&gt;You need to join the ground of the external supply to the ground being supplied from the Arduino.  The 12V supply must be capable of at least 100ma&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There appears to be a transistor and resistor on the board.  This is probably to drive the relay coil from the Arduino.  However, I would need to look at the circuit diagram of the board to be certain.  Can you supply images of the copper side and component side of the board to see what the connections are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally the circuit diagram from the manufacturer would be even better.&lt;/p&gt;&#xA;" OwnerUserId="6194" LastActivityDate="2014-12-12T18:35:11.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6474" PostTypeId="1" CreationDate="2014-12-12T18:40:18.227" Score="1" ViewCount="3655" Body="&lt;p&gt;I would like to use three timers in CTC mode to launch three Interrupt Service Routines at different frequencies. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this application I need to use the servo library, millis() and micros() functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Timer3&lt;/strong&gt; (Working)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to this &lt;a href=&quot;https://arduino.stackexchange.com/questions/5431/how-to-update-a-variable-in-an-isr-using-timers/6447#6447&quot;&gt;question&lt;/a&gt;, Timer3 has been set up in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  cli();          // disable global interrupts&#xA;  TCCR3A = 0;     // set entire TCCR3A register to 0&#xA;  TCCR3B = 0;     // same for TCCR3B&#xA;&#xA;  // set compare match register to desired timer count:  @~744 Hz&#xA;  OCR3A = 20; &#xA;  // turn on CTC mode:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei();&#xA;&#xA;  ISR(TIMER3_COMPB_vect)&#xA;  {&#xA;     cont++;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Timer4&lt;/strong&gt;&#xA;I've tried with this configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cli();          // disable global interrupts&#xA;TCCR4A = 0;     // set entire TCCR3A register to 0&#xA;TCCR4B = 0;     // same for TCCR3B&#xA;&#xA;// set compare match register to desired timer count: @ ~744 Hz&#xA;OCR4A = 20; &#xA;// turn on CTC mode:&#xA;TCCR4B |= (1 &amp;lt;&amp;lt; WGM42);&#xA;// Set CS10 and CS12 bits for 1024 prescaler:&#xA;TCCR4B |= (1 &amp;lt;&amp;lt; CS40) | (1 &amp;lt;&amp;lt; CS42);&#xA;// enable timer compare interrupt:&#xA;TIMSK4 |= (1 &amp;lt;&amp;lt; OCIE4B);&#xA;//TIMSK4 |= (1 &amp;lt;&amp;lt; OCIE4A); same issue&#xA;// enable global interrupts:&#xA;sei();&#xA;&#xA;ISR(TIMER4_COMPB_vect) //TIMER4_COMPA_vect same issue&#xA;{&#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the compiler returns an error caused by the servo library conflict:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Servo\Servo.cpp.o: In function '__vector_42': C:\Program Files&#xA;  (x86)\Arduino\libraries\Servo/Servo.cpp:117: multiple definition of&#xA;  '__vector_42' Timer4B_800Hz.cpp.o:C:\Program Files&#xA;  (x86)\Arduino/Timer4B_800Hz.ino:49: first defined here c:/program&#xA;  files&#xA;  (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe:&#xA;  Disabling relaxation: it will not work with multiple definitions&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As Gerben suggested in a comment in this &lt;a href=&quot;https://arduino.stackexchange.com/questions/5396/setting-timer3-in-ctc-mode-conflict-with-servo-library/5432#5432&quot;&gt;question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;They are just hogging all timers. I guess you have to alter the&#xA;  library slightly by removing the #define _useTimer3 line, or try&#xA;  putting a #undef _useTimer3 right after the include. –  Gerben&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would avoid changing the servo library since motors play a critcal role in the application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Timer 5&lt;/strong&gt; Same issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which timers and output compare registers can I use to set up the three ISR correctly? &lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-02-11T20:49:52.100" Title="Using multiple timers and avoiding conflicts" Tags="|arduino-mega|library|interrupt|timers|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6475" PostTypeId="2" ParentId="5434" CreationDate="2014-12-12T18:44:52.730" Score="1" Body="&lt;p&gt;I would definitely use an Opto-Isolator between the motor and the Arduino for these reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have a problems with the grounds as the motor reverses.&#xA;The 24V supply.  If you get something slightly wrong then it will take out the Arduino and the PC connected to it.&#xA;The motor will generate large voltage spikes( circa 50..300Volts) under certain condions.  The Arduino and the PC connected to it will complain, but not for long!&lt;/p&gt;&#xA;" OwnerUserId="6194" LastActivityDate="2014-12-12T18:44:52.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6476" PostTypeId="2" ParentId="5408" CreationDate="2014-12-12T18:55:20.887" Score="0" Body="&lt;p&gt;The ADC is rated at up to 15K samples per second.  So reading a 1000 is not a problem.&#xA;However, care must be taken in the Vcc used for the ADC (AVcc).  It must be noise free otherwise it will introduce noise into the digital readings, when it actually isn't there in the analogue signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See page 256 on the Atmel 328 datasheet for further information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RC Lowpass filter should also be used on the AVcc supply, as well as the pressure sensor signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just thought!   Are you using a Serial.print() after each analogRead()???&#xA;If so, the serial port will drastically slow down the sample rate.&#xA;If this is the case perform a number of analogRead()s then use Serial.print() after some form of processing.&lt;/p&gt;&#xA;" OwnerUserId="6194" LastEditorUserId="6194" LastEditDate="2014-12-12T21:09:47.263" LastActivityDate="2014-12-12T21:09:47.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6479" PostTypeId="1" CreationDate="2014-12-13T06:37:08.730" Score="2" ViewCount="1277" Body="&lt;p&gt;I'm trying to turn on LEDs based on delays entered by keypad and the same for turning them off, but the LEDs are not responding. Here is the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Keypad.h&amp;gt;&#xA;&#xA;const byte ROWS = 4;//four Rows&#xA;const byte COLS = 3;//three columns&#xA;char keys[ROWS][COLS] = {&#xA;  {'1','2','3'},&#xA;  {'4','5','6'},&#xA;  {'7','8','9'},&#xA;  {'*','0','#'}&#xA;};&#xA;byte rowPins[ROWS] = {13,10,9,8}; //connect to the row pinouts of the keypad&#xA;byte colPins[COLS] = {7,6,1}; //connect to the column pinouts of the keypad&#xA;Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );&#xA;&#xA;&#xA;int x;&#xA;int y;&#xA;int z;&#xA;int e ; &#xA;int w;&#xA;int r;&#xA;int Pin1 = A0;&#xA;int Pin2 = A1;&#xA;int Pin3 = A2;&#xA;&#xA;&#xA;void setup() {&#xA;  // initialize pins A0,A1 and A2 as an output.&#xA;  pinMode(A0, OUTPUT);&#xA;  pinMode(A1, OUTPUT);&#xA;  pinMode(A2, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  char key = kpd.getKey();&#xA;&#xA;l1:  if (key)  // Check for a valid key.&#xA;  {&#xA;    switch(key)&#xA;    {&#xA;      case '1':&#xA;      w=1;&#xA;      break;&#xA;      case '2':&#xA;      w=2;&#xA;      break;&#xA;      case '3':&#xA;      w=3;&#xA;      break;&#xA;      case'4':&#xA;      w=4;&#xA;      break;&#xA;      case '5':&#xA;      w=5;&#xA;      break;&#xA;      case '6':&#xA;      w=6;&#xA;      break;&#xA;      case '7':&#xA;      w=7;&#xA;      break;&#xA;      case '8':&#xA;      w=8;&#xA;      break;&#xA;      case '9':&#xA;      w=9;&#xA;      break;&#xA;    }&#xA;  }&#xA;  else { goto l1;} // To guarantee that a key is pressed before moving on with the rest of code&#xA;&#xA;  delay(w*1000*60); //To reach the time specified by the user before moving on&#xA;  digitalWrite(A2,HIGH);&#xA;&#xA;l2: if (key)&#xA;{&#xA;  switch (key)&#xA;  {&#xA;    case '1':&#xA;        r=1;&#xA;        break;&#xA;        case '2':&#xA;        r=2;&#xA;        break;&#xA;        case '3':&#xA;        r=3;&#xA;        break;&#xA;        case '4':&#xA;        r=4;&#xA;        break;&#xA;        case '5':&#xA;        r=5;&#xA;        break;&#xA;        case '6':&#xA;        r=6;&#xA;        break;&#xA;        case '7':&#xA;        r=7;&#xA;        break;&#xA;        case '8':&#xA;        r=8;&#xA;        break;&#xA;        case '9':&#xA;        r=9;&#xA;        break;&#xA;      }&#xA;}&#xA;else {goto l2;} // To guarantee that a key is pressed before moving n with the rest of code&#xA;&#xA;delay ((r-w)*1000*60); //To reach the time specified by the user before moving on&#xA;digitalWrite (A2,LOW);&#xA;&#xA;l3: if (key)&#xA;{&#xA;  switch(key)&#xA;  {&#xA;    case '1':&#xA;        x=1;&#xA;        break;&#xA;        case '2':&#xA;        x=2;&#xA;        break;&#xA;        case '3':&#xA;        x=3;&#xA;        break;&#xA;        case '4':&#xA;        x=4;&#xA;        break;&#xA;        case '5':&#xA;        x=5;&#xA;        break;&#xA;        case '6':&#xA;        x=6;&#xA;        break;&#xA;        case '7':&#xA;        x=7;&#xA;        break;&#xA;        case '8':&#xA;        x=8;&#xA;        break;&#xA;        case '9':&#xA;        x=9;&#xA;        break;&#xA;      }&#xA;}&#xA;&#xA;else { goto l3;} // To guarantee that a key is pressed before moving n with the rest of code&#xA;delay ((x-r)*1000*60);//To reach the time specified by the user before moving on&#xA;digitalWrite (A0,HIGH);&#xA;&#xA;l4: if (key)&#xA;{&#xA;  switch (key)&#xA;  {&#xA;    case '1':&#xA;        y=1;&#xA;        break;&#xA;        case '2':&#xA;        y=2;&#xA;        break;&#xA;        case '3':&#xA;        y=3;&#xA;        break;&#xA;        case '4':&#xA;        y=4;&#xA;        break;&#xA;        case '5':&#xA;        y=5;&#xA;        break;&#xA;        case '6':&#xA;        y=6;&#xA;        break;&#xA;        case '7':&#xA;        y=7;&#xA;        break;&#xA;        case '8':&#xA;        y=8;&#xA;        break;&#xA;        case '9':&#xA;        y=9;&#xA;        break;&#xA;      }&#xA;}&#xA;else {goto l4;} // To guarantee that a key is pressed before moving n with the rest of code&#xA;delay((y-x)*1000*60); //To reach the time specified by the user before moving on&#xA;digitalWrite (A0, LOW );&#xA;&#xA;l5:&#xA;if(key)&#xA;{&#xA;  switch(key)&#xA;  {&#xA;    case '1':&#xA;      z=1;&#xA;      break;&#xA;      case '2':&#xA;      z=2;&#xA;      break;&#xA;      case '3':&#xA;      z=3;&#xA;      break;&#xA;      case'4':&#xA;      z=4;&#xA;      break;&#xA;      case '5':&#xA;      z=5;&#xA;      break;&#xA;      case '6':&#xA;      z=6;&#xA;      break;&#xA;      case '7':&#xA;      z=7;&#xA;      break;&#xA;      case '8':&#xA;      z=8;&#xA;      break;&#xA;      case '9':&#xA;      z=9;&#xA;      break;&#xA;    }&#xA;}&#xA;else {goto l5;}// To guarantee that a key is pressed before moving n with the rest of code&#xA;delay ((z-y)*1000*60); //To reach the time specified by the user before moving on&#xA;digitalWrite(A1,HIGH);&#xA;&#xA;l6: if (key)&#xA;{&#xA;  switch(key)&#xA;  {&#xA;    case '1':&#xA;        e=1;&#xA;        break;&#xA;        case '2':&#xA;        e=2;&#xA;        break;&#xA;        case '3':&#xA;        e=3;&#xA;        break;&#xA;        case '4':&#xA;        e=4;&#xA;        break;&#xA;        case '5':&#xA;        e=5;&#xA;        break;&#xA;        case '6':&#xA;        e=6;&#xA;        break;&#xA;        case '7':&#xA;        e=7;&#xA;        break;&#xA;        case '8':&#xA;        e=8;&#xA;        break;&#xA;        case '9':&#xA;        e=9;&#xA;        break;&#xA;  }&#xA;}&#xA;else{goto l6;}// To guarantee that a key is pressed before moving n with the rest of code&#xA;delay((e-z)*1000*60); //To reach the time specified by the user before moving on&#xA;digitalWrite (A1, LOW );&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6224" OwnerDisplayName="A.M.H" LastEditorUserId="6452" LastEditDate="2015-01-21T22:20:11.357" LastActivityDate="2015-01-21T22:20:11.357" Title="Controlling LED delays via keypad" Tags="|led|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6481" PostTypeId="1" AcceptedAnswerId="6486" CreationDate="2014-12-13T09:15:52.180" Score="2" ViewCount="4619" Body="&lt;p&gt;I'm using the Arduino software to create a Morse code decoder using the  serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I enter a Morse code such as &lt;code&gt;.-&lt;/code&gt; as a text string and it's displayed in the LCD as a alphanumeric text. So if I enter &lt;code&gt;.-&lt;/code&gt; into the serial Monitor, &lt;code&gt;A&lt;/code&gt; is displayed on the LCD. But it only works for single symbols, not the dot and dash together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to make the if statement as seen below accept both the dots and dashes together?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.begin(16, 2);&#xA;&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  char schar;&#xA;&#xA;  if (Serial.available())&#xA;  {&#xA;    schar = Serial.read();&#xA;&#xA;    Serial.write(schar);&#xA;&#xA;    if (schar== '.-' ){&#xA;      Serial.write('A');&#xA;      lcd.print('a');&#xA;    }   &#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6226" LastEditorUserId="84" LastEditDate="2014-12-16T05:26:50.317" LastActivityDate="2014-12-16T05:26:50.317" Title="Comparing a char with the symbols '.-'" Tags="|c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6482" PostTypeId="2" ParentId="6481" CreationDate="2014-12-13T09:59:45.627" Score="1" Body="&lt;p&gt;&lt;code&gt;schar&lt;/code&gt; is a &lt;code&gt;char&lt;/code&gt; variable of size 1. It makes no sense to compare it with &lt;code&gt;'.-'&lt;/code&gt;, which is supposed to be a string. Declare a &lt;code&gt;char[3]&lt;/code&gt; array, fill it as string and use the &lt;code&gt;strcmp&lt;/code&gt; function. It's elementary C knowledge.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastEditorUserId="1585" LastEditDate="2014-12-16T02:15:18.277" LastActivityDate="2014-12-16T02:15:18.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6483" PostTypeId="1" AcceptedAnswerId="6484" CreationDate="2014-12-13T12:20:37.900" Score="0" ViewCount="104" Body="&lt;p&gt;I am working with 8 dual color LED's and 2 shift registers. My connections are in place. But I do not understand how to work with 2 shift registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am trying to make this: turn the first led on, turn the first led of, go to the next led, turn it on, turn in off, etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know how to jump from the first shift register to the second shift register when the last LED of the first shift register is turned off.&lt;/p&gt;&#xA;" OwnerUserId="6227" LastActivityDate="2014-12-13T14:39:25.347" Title="Sweep with two shift registers" Tags="|arduino-uno|programming|c|code-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6484" PostTypeId="2" ParentId="6483" CreationDate="2014-12-13T14:39:25.347" Score="2" Body="&lt;p&gt;Exactly the same as when you're trying to keep them dark when lighting an LED with the first register: shift two bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first byte shifts into the first register to begin with, and then &lt;em&gt;out&lt;/em&gt; of the first register and &lt;em&gt;into&lt;/em&gt; the second register when you shift the second byte into the first register. Just make sure only the appropriate bits are set in both bytes and you're good to go.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-13T14:39:25.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6486" PostTypeId="2" ParentId="6481" CreationDate="2014-12-13T19:16:18.257" Score="4" Body="&lt;p&gt;Your first problem is that there is no way for schar to contain two characters in the first place; Since schar is declared as a char, it can only contain one character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to make a String out of the serial input. &lt;code&gt;Serial.read()&lt;/code&gt; only returns one character at a time, so you will need to make sure you iterate over all the input. Then you can compare the whole String with another, and see if both characters match at once. Just look at this code to see different ways of manipulating Strings: &lt;a href=&quot;http://arduino.cc/en/Tutorial/StringComparisonOperators&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/StringComparisonOperators&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that string literals use double quotes, not single quotes like characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, be aware of the fact that &lt;code&gt;string&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt; are different things. lowercase 's' is an &lt;a href=&quot;http://arduino.cc/en/Reference/string&quot; rel=&quot;nofollow&quot;&gt;array of characters&lt;/a&gt;, capitol 'S' is the &lt;a href=&quot;http://arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;class that has those useful string comparison member functions&lt;/a&gt;. The class is more resource intensive, but I think in your case the readability and convenience are worth it.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-16T02:12:37.110" LastActivityDate="2014-12-16T02:12:37.110" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6487" PostTypeId="1" AcceptedAnswerId="6488" CreationDate="2014-12-14T03:44:14.020" Score="6" ViewCount="6798" Body="&lt;p&gt;I'm an automotive enthusiast and I want to build some gauges by myself using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was taking a look at this &lt;a href=&quot;http://www.ebay.com/itm/Pressure-transducer-or-sender-100-psi-stainless-steel-for-oil-fuel-air-water-/271576977896?pt=Motors_Car_Truck_Parts_Accessories&amp;amp;hash=item3f3b3fd1e8&amp;amp;vxp=mtr&quot; rel=&quot;nofollow noreferrer&quot;&gt;pressure transducer or sender, 100 psi, stainless steel, for oil, fuel, air, water&lt;/a&gt; and I was thinking if I can use this sensor to do all of the these tasks: Water, Boost and Oil Pressure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at the Signal output vs read PSI chart of the sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Yy1T.png&quot; alt=&quot; Signal output vs read PSI chart of the sensor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came out with this equation for the PSI calculation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it is a &lt;code&gt;Y = bx + a&lt;/code&gt;, where: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = 0.5 &#xA;b = y2 - y1 / x2 - x1 = (4.5 - 0.5 ) / (100 - 0) = 4/100 = 0.04&#xA;x = PSI&#xA;y = Signal's Voltage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltage Reading = 0.04PSI + 0.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we have :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PSI = (Voltage Reading - 0.5 ) / 0.04 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct? Can I use this sensor?&lt;/p&gt;&#xA;" OwnerUserId="6235" LastEditorUserId="6936" LastEditDate="2015-08-01T14:44:03.040" LastActivityDate="2017-11-20T15:21:43.507" Title="Oil Pressure / Water Pressure / Boost Pressure ( Turbo Engine )" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6488" PostTypeId="2" ParentId="6487" CreationDate="2014-12-14T06:00:34.340" Score="3" Body="&lt;p&gt;You math checks you to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you code it, You will probably read a voltage using an analog pin (or external ADC) that will return an integer between 0 being 0 volts, and 1024 = vin volts. vin will be 5 if you don't wire up the vin pin, and 1024 could be different if you use an external ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway you should be aware that the raw readings will probably not be 0-5, and they dont have decimal points. You will need to first convert the reading into the voltage with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltage = ((float)reading)/1024.f;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;notice that the datatype float is used (enables decimal points) and that the constant being divided by is also a float so that the calculations will definitly happen between floating point numbers.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-12-14T06:00:34.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6489" PostTypeId="1" CreationDate="2014-12-14T07:55:36.577" Score="0" ViewCount="5436" Body="&lt;p&gt;Recently bought a arduino device which already have program,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it is model AR-293D and I have already connect it with my PC(windows 7) through usb&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I open the IDE , It seems there is no function that read the uploaded program? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And after searching a while , like some beginner tutorial , it only tell you how to upload the program but not how to get the uploadded program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.forefront.io/a/beginners-guide-to-arduino&quot; rel=&quot;nofollow&quot;&gt;http://www.forefront.io/a/beginners-guide-to-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I wonder how to get the code? Thanks a lot for helping, I worried erase the uploadded program so I need to take caution about this&lt;/p&gt;&#xA;" OwnerUserId="7692" OwnerDisplayName="user782104" LastActivityDate="2016-02-05T20:57:56.937" Title="Get the uploaded code from arduino by using arduino IDE 1.0.6" Tags="|programming|programmer|" AnswerCount="1" CommentCount="4" ClosedDate="2019-09-19T18:49:47.143" ContentLicense="CC BY-SA 3.0" />
  <row Id="6490" PostTypeId="1" CreationDate="2014-12-14T08:28:44.230" Score="0" ViewCount="979" Body="&lt;p&gt;Right now I have an RC car program for Arduino. The code is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  distance = Dist.getDistanceCentimeter();&#xA;  if(distance&amp;lt;=5 &amp;amp; distance&amp;gt;1)&#xA;  if(Serial.available()) {&#xA;    lkf = Serial.read();&#xA;  switch(lkf) {&#xA;  case 'a':&#xA;     forward();&#xA;     servoX.write(90);&#xA;     lkf=0; &#xA;     break;    &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wrote a TCPclient that can order the RC car to move forward by connecting through TCP and sending the message &quot;a&quot; to the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is how to return the distance to the cilent? Is it simply &lt;code&gt;return distance;&lt;/code&gt; or something like &lt;code&gt;system.println(distance);&lt;/code&gt;? Thanks for helping.&lt;/p&gt;&#xA;" OwnerUserId="7692" OwnerDisplayName="user782104" LastEditorUserId="4628" LastEditDate="2014-12-14T17:08:21.143" LastActivityDate="2016-01-22T10:48:09.360" Title="How to return the value in Arduino function (that can be read by the connected device)?" Tags="|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6491" PostTypeId="1" AcceptedAnswerId="6507" CreationDate="2014-12-14T09:03:41.843" Score="0" ViewCount="191" Body="&lt;p&gt;I made a circuit which in my intentions would allow me to toggle a LED dimming loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is that once I push the button the first time pushing it a second time doesn't toggle the LED loop off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LED = 9; // the pin for the LED&#xA;const int BUTTON = 7;&#xA;&#xA;&#xA;int val = LOW;&#xA;&#xA;int old_val = LOW;&#xA;int state = 0;&#xA;int i = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(LED, OUTPUT);&#xA;  pinMode(BUTTON, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  val = digitalRead(BUTTON);&#xA;&#xA;  if ((val == HIGH) &amp;amp;&amp;amp; (old_val==LOW))&#xA;  {&#xA;    state = 1 - state;&#xA;    delay(10);&#xA;  }&#xA;&#xA;  old_val = val;&#xA;&#xA;  if (state == 1)&#xA;  {&#xA;    for (i = 0; i &amp;lt; 255; i++)  // loop from 0 to 254 (fade in)&#xA;    {&#xA;      analogWrite(LED, i); // set the LED brightness&#xA;      delay(10);           // Wait 10ms because analogWrite&#xA;      // is instantaneous and we would&#xA;      // not see any change&#xA;    }&#xA;&#xA;    for (i = 255; i &amp;gt; 0; i--) // loop from 255 to 1 (fade out)&#xA;    { &#xA;      analogWrite(LED, i); // set the LED brightness&#xA;      delay(10);           // Wait 10ms  &#xA;    }&#xA;  } else&#xA;  {&#xA;    analogWrite(LED, 0);&#xA;  }&#xA;&#xA;  if ((val == LOW) &amp;amp;&amp;amp; (old_val == HIGH)) &#xA;  {&#xA;    delay(10);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the circuit scheme:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ap6j4.png&quot; alt=&quot;circuit schematics&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be interested both in learning what the problem is AND learning any mental methods I can apply to debug in such situations.&lt;/p&gt;&#xA;" OwnerUserId="6237" LastEditorUserId="6237" LastEditDate="2014-12-14T09:21:47.990" LastActivityDate="2014-12-15T15:45:31.310" Title="Button reading not going off" Tags="|arduino-uno|led|button|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6494" PostTypeId="1" CreationDate="2014-12-14T16:06:27.373" Score="1" ViewCount="187" Body="&lt;p&gt;i am tring to enter a series of numbers using &quot;keypad&quot; to different variables..when simulate the code on proteus it only took the first &quot;getkey()&quot; function and ignored the rest .. &#xA;SO,&#xA;How can i block an arduino code until a key is pressed by keypad, in other words prevent the rest of code from being executed before a key is pressed &lt;/p&gt;&#xA;" OwnerUserId="6224" LastActivityDate="2014-12-14T18:59:14.553" Title="how to block Arduino code until a certain event?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6495" PostTypeId="1" CreationDate="2014-12-14T17:21:20.383" Score="0" ViewCount="392" Body="&lt;p&gt;So I found a code I would like to use and not sure how to edit the code properly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Debounce.h&amp;gt;&#xA;&#xA;void matrix(char matrix[7]) {&#xA;  int map[10];&#xA;  map[0] = 2;&#xA;  map[1] = 3;&#xA;  map[2] = 4;&#xA;  map[3] = 5;&#xA;  map[4] = 6;&#xA;  map[5] = 7;&#xA;  map[6] = 8;&#xA;  map[7] = 9;  &#xA;&#xA;  int i=0;&#xA;  for(i=0;i&amp;lt;=7; i++) {&#xA;   if(matrix[i] == 0x30) { // 0x31=1, 0x30=0&#xA;      Serial.println(map[i]);&#xA;      digitalWrite(map[i],LOW);&#xA;   }&#xA;   else digitalWrite(map[i],HIGH);&#xA;  }&#xA;}&#xA;&#xA;void show(int number) {&#xA;  switch(number) {&#xA;    case 0:&#xA;      matrix(&quot;11111100&quot;);&#xA;      break;&#xA;    case 1:&#xA;      matrix(&quot;01100000&quot;);&#xA;      break;&#xA;    case 2:&#xA;      matrix(&quot;11011010&quot;);&#xA;      break;&#xA;    case 3:&#xA;      matrix(&quot;11110010&quot;);&#xA;      break;&#xA;    case 4:&#xA;      matrix(&quot;01100110&quot;);&#xA;      break;&#xA;    case 5:&#xA;      matrix(&quot;10110110&quot;);&#xA;      break;&#xA;    case 6:&#xA;      matrix(&quot;10111110&quot;);&#xA;      break;&#xA;    case 7:&#xA;      matrix(&quot;11100000&quot;);&#xA;      break;&#xA;    case 8:&#xA;      matrix(&quot;11111110&quot;);&#xA;      break;&#xA;    case 9:&#xA;      matrix(&quot;11110110&quot;);&#xA;      break;&#xA;    default:&#xA;      matrix(&quot;00000010&quot;);&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;#define t1 13&#xA;#define t2 12&#xA;&#xA;Debounce debouncert1 = Debounce( 20 , t1 ); &#xA;Debounce debouncert2 = Debounce( 20 , t2 ); &#xA;&#xA;void setup()   {&#xA;  Serial.begin(9600); &#xA;&#xA;  // initialize the digital pin as an output:&#xA;  pinMode(13, INPUT);&#xA;  pinMode(12, INPUT);&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;  pinMode(6, OUTPUT);&#xA;  pinMode(7, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;int setCountPlus(int count){&#xA;  if(count == 9){&#xA;    count = 1;&#xA;  }&#xA;  else{&#xA;    count++;&#xA;    count %= 10;&#xA;  }&#xA;  return count;&#xA;}&#xA;&#xA;int setCountMinus(int count){&#xA;  if(count==1){&#xA;    count = 9;&#xA;  }&#xA;  else{&#xA;  count--;&#xA;  count %= 10;&#xA;  }&#xA;  return count;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int i=-1;&#xA;  show(i);&#xA;  while(1){&#xA;    debouncert1.update();&#xA;    debouncert2.update();&#xA;    if(debouncert1.read()){&#xA;      i=setCountPlus(i);&#xA;    }&#xA;    if(debouncert2.read()){&#xA;      i=setCountMinus(i);&#xA;    }&#xA;    if(i==10){&#xA;      i=1;&#xA;    }&#xA;    show(i);&#xA;    delay(250);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as for the errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sketch 65: error: 'Debounce' does not name a type &lt;br&gt;&#xA;sketch 66: error: 'Debounce' does not name a type &lt;br&gt;&#xA;sketch .ino: In function 'void loop()': &lt;br&gt;&#xA;sketch 108: error: 'debouncert1' was not declared in this scope &lt;br&gt;&#xA;sketch 109: error: 'debouncert2' was not declared in this scope &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great on fixing the code to stop getting errors.&lt;/p&gt;&#xA;" OwnerUserId="6242" LastEditorUserId="89" LastEditDate="2014-12-15T14:25:00.340" LastActivityDate="2015-01-15T15:37:25.713" Title="Newbie needing help with debounce errors in arduino" Tags="|library|debounce|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6497" PostTypeId="2" ParentId="6494" CreationDate="2014-12-14T18:59:14.553" Score="1" Body="&lt;p&gt;It depends on how the &quot;keypad&quot; is implemented. If you've got it hooked up to a hardware interrupt, then you only need to add an interrupt handler for that event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the more &quot;straight-forward&quot; implementation is that you have to poll the pins to see if a key was pressed.  Simply do that in a loop until you see a key press, call your event-handler method, and then continue to loop.&lt;/p&gt;&#xA;" OwnerUserId="496" LastActivityDate="2014-12-14T18:59:14.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6498" PostTypeId="2" ParentId="6495" CreationDate="2014-12-15T06:44:14.783" Score="1" Body="&lt;p&gt;In the description of &lt;a href=&quot;http://playground.arduino.cc/Code/Debounce&quot; rel=&quot;nofollow&quot;&gt;Debounce&lt;/a&gt;, you'll find the hint that this library is &lt;strong&gt;outdated&lt;/strong&gt; and no longer maintained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its successors, &lt;strong&gt;Bounce1&lt;/strong&gt; and, more recently, &lt;strong&gt;Bounce2&lt;/strong&gt; are available from a &lt;strong&gt;github&lt;/strong&gt; repository by Thomas Fredericks, &lt;a href=&quot;https://github.com/thomasfredericks/Bounce-Arduino-Wiring&quot; rel=&quot;nofollow&quot;&gt;Bounce-Arduino-Wiring&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of simply downloading and unzipping the archive to &lt;code&gt;${HOME}/sketchbook/libraries&lt;/code&gt;, you might want to consider that this is the right moment to get familiar with git repositories as an easily updatable source for third-party libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supposed that you're on a GNU/Linux system with &lt;code&gt;git&lt;/code&gt; installed, you would&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /${HOME}/sketchbook/libraries&#xA;git clone https://github.com/thomasfredericks/Bounce-Arduino-Wiring.git&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to obtain a clone of the necessary data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the name of the directory of the library contains dashes (&lt;code&gt;-&lt;/code&gt;), you'll have to change this name: remove the dashes or replace them with underscores (&lt;code&gt;_&lt;/code&gt;). Names with dashes aren't valid! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once in a while, you would change to the directory of the respective library and simply run &lt;code&gt;git pull&lt;/code&gt; to update your local copy to the latest version of the repository.&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="89" LastEditDate="2014-12-15T07:00:59.750" LastActivityDate="2014-12-15T07:00:59.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6500" PostTypeId="1" AcceptedAnswerId="6504" CreationDate="2014-12-15T12:37:03.877" Score="0" ViewCount="87" Body="&lt;p&gt;I'm very new to Arduino and came to a point where I'm interested in playing with shields, such as LCDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I really like the looks of &quot;LCD 1602 with keypad&quot; module, but it seems to be using a lot of pins.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;By looking at a module / shield, how can I tell (or at least estimate) which pins will be used and which ones I will have left if I stack them with my Uno or Mega without printed schematics?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2014-12-18T21:02:21.240" Title="How can I tell which pins I will have left available by looking at a shield?" Tags="|arduino-uno|arduino-mega|pins|shields|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6501" PostTypeId="2" ParentId="4610" CreationDate="2014-12-15T13:01:10.003" Score="3" Body="&lt;p&gt;It might help to use a capacitor to smooth your PWM signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://ww1.microchip.com/downloads/en/AppNotes/00771b.pdf&quot; rel=&quot;nofollow&quot;&gt;http://ww1.microchip.com/downloads/en/AppNotes/00771b.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5174" LastActivityDate="2014-12-15T13:01:10.003" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6502" PostTypeId="1" AcceptedAnswerId="6505" CreationDate="2014-12-15T14:02:55.873" Score="3" ViewCount="12473" Body="&lt;p&gt;I would like to know where I can see the output when I use the command &lt;code&gt;printf&lt;/code&gt;. I am programming using the Arduino interface.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I'll add a few lines of code for better understanding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    printf(&quot;Hello World&quot;);&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6250" LastEditorUserId="6250" LastEditDate="2014-12-15T14:18:22.920" LastActivityDate="2014-12-15T14:39:33.543" Title="Where can I see the output of printf?" Tags="|arduino-uno|c|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6503" PostTypeId="2" ParentId="6502" CreationDate="2014-12-15T14:12:52.693" Score="2" Body="&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt;, start serial and choose your speed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wherever you want to write to serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(&quot;write this&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wherever you want a newline:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;example&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  Serial.write(&quot;Hello World&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6227" LastEditorUserId="6227" LastEditDate="2014-12-15T14:22:04.110" LastActivityDate="2014-12-15T14:22:04.110" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6504" PostTypeId="2" ParentId="6500" CreationDate="2014-12-15T14:27:29.410" Score="1" Body="&lt;p&gt;If you look in the 'Tutorials' section of &lt;a href=&quot;http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; you can see the pins used. All of the buttons come through in one analogue input and you'll need a further 7 digital I/O pins. So 8 in total which would leave 5 analogue and 4 digital (I think) pins on an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for how to tell which ones, does it matter in advance? I would just map the I/O in the sketch to suit. If you need to plan that far in advance though, it seems that J5 in this &lt;a href=&quot;http://sainsmart.com/zen/documents/20-011-901/schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt; shows which pins travel through the shield (i.e. are available to use in conjunction with the shield). Also J6 shows the 5 remaining analogue pins.&lt;/p&gt;&#xA;" OwnerUserId="3506" LastActivityDate="2014-12-15T14:27:29.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6505" PostTypeId="2" ParentId="6502" CreationDate="2014-12-15T14:39:33.543" Score="7" Body="&lt;p&gt;If you're working with the standard Arduino environment and libraries then &lt;code&gt;printf()&lt;/code&gt; won't display anything anywhere. The reason is that microcontrollers could be connected to any number of different output/communication devices in any way. &lt;code&gt;stdio&lt;/code&gt; would have no idea how or where to send the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most common approach to outputting text from an Arduino (particularly during development) is to send it to the primary UART port using &lt;a href=&quot;http://arduino.cc/en/Serial/Begin&quot;&gt;&lt;code&gt;Serial.begin()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://arduino.cc/en/Serial/Print&quot;&gt;&lt;code&gt;Serial.print()&lt;/code&gt;&lt;/a&gt;. If the Arduino is connected to your computer via USB then the Arduino IDE's serial monitor should display the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;really&lt;/em&gt; want to use &lt;code&gt;printf()&lt;/code&gt; though then it is possible to make it work (or implement similar functionality). A full explanation is on this page:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/Printf&quot;&gt;http://playground.arduino.cc/Main/Printf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-15T14:39:33.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6506" PostTypeId="1" CreationDate="2014-12-15T14:52:48.343" Score="0" ViewCount="3343" Body="&lt;p&gt;I have a RTC module DS1307 (MR005-001.2) on my Arduino Uno.&#xA;I use the Wire.h / Time.h / DS1307RTC.h libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The date and time returned is completely wrong (&quot;17:18:9 2 4 2036&quot;) ... What do I do wrong ??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my partial code for setup() :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    setSyncProvider(RTC.get);&#xA;  if(timeStatus()!= timeSet) &#xA;     Serial.println(&quot;Unable to sync with the RTC&quot;);&#xA;  else&#xA;     Serial.println(&quot;RTC has set the system time&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This writes &quot;RTC has set the system time&quot;, so I guess something is happening right...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my partial code for loop() :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Serial.print(hour());&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(minute());&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(second());&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(day());&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(month());&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(year()); &#xA;  Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just as in the example ... and the date/time returned is &quot;17:18:9 2 4 2036&quot;&lt;/p&gt;&#xA;" OwnerUserId="6251" LastActivityDate="2022-07-26T00:08:55.847" Title="Why my RTC module doesn't return the right date/time?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6507" PostTypeId="2" ParentId="6491" CreationDate="2014-12-15T15:45:31.310" Score="0" Body="&lt;p&gt;While the led is fading in and out (which takes 5 seconds), the state of the button is never checked. So you'd need to have the button released for at least 5 seconds (so old_val becomes LOW), and then pressed exactly we the led is faded out (again, 5 seconds later). So try keeping the button pressed for at least 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to rewrite your code, so the button is more 'responsive'. Below I added an example of how to do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LED = 9; // the pin for the LED&#xA;const int BUTTON = 7;&#xA;&#xA;&#xA;int val = LOW;&#xA;int old_val = LOW;&#xA;&#xA;bool fadeLed = false;&#xA;int brightness = 0;//current pwm value&#xA;int direction = 1;// 1 is brightness is increasing, -1 if brightness is decreasing &#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(LED, OUTPUT);&#xA;  pinMode(BUTTON, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  /* check the button */&#xA;  val = digitalRead(BUTTON);&#xA;  if ((val == HIGH) &amp;amp;&amp;amp; (old_val==LOW))&#xA;  {&#xA;    // button pressed ( called only once per press )&#xA;    fadeLed = !fadeLed;// invert boolean&#xA;  }&#xA;  old_val = val;&#xA;&#xA;  /* update the leds brightness */&#xA;  if( fadeLed )&#xA;  {&#xA;    // fade led in and out&#xA;    if( brightness==0 )&#xA;      direction = 1;//change direction is minimum value reached&#xA;    if( brightness==255 )&#xA;      direction = -1;//change direction is maximum value reached&#xA;    brightness += direction;// increase/decrease brightness&#xA;  }&#xA;  else&#xA;  {&#xA;    // fadeLed is disabled, so only decrease brightness till it reaches zero&#xA;    if( brightness&amp;gt;0 )&#xA;      brightness--;&#xA;  }&#xA;&#xA;  analogWrite(LED, brightness); // set the LED brightness&#xA;  delay(10);           // Wait 10ms because analogWrite&#xA;                       // is instantaneous and we would&#xA;                       // not see any change&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any questions about the code; just let me know.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-15T15:45:31.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6508" PostTypeId="2" ParentId="455" CreationDate="2014-12-15T17:16:35.040" Score="2" Body="&lt;p&gt;I was having the same problem under Windows 7 x64 and had already removed all com ports and unknown devices as suggested above. For me, the solution was to rename &quot;ListComPorts.exe&quot; in the &lt;strong&gt;hardware\tools&lt;/strong&gt; subfolder to &quot;ListComPorts.exe.xxx&quot; - this prevents the Arduino IDE from using this file and appearently it reverts to using the internal COM port detection mechanism (using DEVICE_ARRIVAL/DEVICE_REMOVAL messages??) . The tool menu now opens immediately every time.&lt;/p&gt;&#xA;" OwnerUserId="6254" LastActivityDate="2014-12-15T17:16:35.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6512" PostTypeId="1" CreationDate="2014-12-15T18:43:30.383" Score="2" ViewCount="5506" Body="&lt;p&gt;I am able to control one shift register with this shift function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shift (int pin) {&#xA;  shiftOut(ds,shcp,MSBFIRST,pin);  &#xA;  digitalWrite(stcp,HIGH);        &#xA;  delay(100);&#xA;  digitalWrite(stcp,LOW);         &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when I move to 2 shift registers it does not add up.. how do I need to adapt this method to make it work with 2 shift registers when I am going from 8 leds to 16 leds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second register now just copies the first register.. I want the second register to continue instead of repeat&lt;/p&gt;&#xA;" OwnerUserId="6227" LastActivityDate="2014-12-16T15:15:31.897" Title="Going from one shift register to two shift registers" Tags="|arduino-uno|shift-register|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6513" PostTypeId="2" ParentId="6512" CreationDate="2014-12-15T18:52:02.723" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;Configure SPI&lt;/li&gt;&#xA;&lt;li&gt;Hook up your shift registers&#xA;&lt;ul&gt;&#xA;&lt;li&gt;common &lt;code&gt;SS&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;common &lt;code&gt;CLK&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;QH*&lt;/code&gt; of the first shift register to &lt;code&gt;SER&lt;/code&gt; of the next&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In order to transfer the bytes&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pull &lt;code&gt;SS&lt;/code&gt; low&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ShiftOut&lt;/code&gt; first byte&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ShiftOut&lt;/code&gt; next byte&lt;/li&gt;&#xA;&lt;li&gt;Pull &lt;code&gt;SS&lt;/code&gt; high again to finish the SPI transfer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This is untested, just out of memory!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SPI.h&amp;gt;&#xA;// note that the pins for CLK and MOSI are defined here&#xA;&#xA;unsigned int ledPattern = 0b1111000011110000;&#xA;// store the state for 16 LEDs here&#xA;&#xA;void setup(void)&#xA;{&#xA;    pinMode(SS, OUTPUT);&#xA;    digitalWrite(SS, HIGH);&#xA;    SPI.setDataMode(3);&#xA;    SPI.setClockDivider(4);  &#xA;    SPI.setBitOrder(MSBFIRST);&#xA;&#xA;    // let's transfer 2 bytes&#xA;    digitalWrite(SS, LOW);&#xA;    SPI.transfer(ledPattern &amp;amp; 0xff00;) // high byte&#xA;    SPI.transfer(ledPattern &amp;amp; 0x00ff;) // low byte&#xA;    digitalWrite(SS, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;HR&gt;&#xA;&lt;strong&gt;UPDATE II&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are by no means limited to 2 shift registers! In 2013, we did a 8x11 LED display for an upcycling art project. Eleven 74HC595 were chained to display some patterns. Each 'pixel' consisted of 3 12V SMD LEDs on a stripe. Consequently, each shift register was connected to an &lt;code&gt;ULN2803&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just uploaded a &lt;a href=&quot;https://www.youtube.com/watch?v=jObemcticOo&quot; rel=&quot;nofollow&quot;&gt;video&lt;/a&gt; from the construction phase, showing a test pattern. &lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="89" LastEditDate="2014-12-15T19:49:07.783" LastActivityDate="2014-12-15T19:49:07.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6514" PostTypeId="2" ParentId="6512" CreationDate="2014-12-15T19:01:14.583" Score="5" Body="&lt;p&gt;It sounds like the primary issue is how you've connected the two shift registers.  You just need the bit shifting out of the first one to shift into the second one so they act, together, as one longer shift register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VEEl6.gif&quot; alt=&quot;Two serial shift registers&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example pictured is described in full here, under the heading &quot;Example 2&quot;:&#xA;&lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftOut&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/tutorial/ShiftOut&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Klaus mentioned, you want to first &lt;code&gt;ShiftOut&lt;/code&gt; the byte you intend to wind up in the second resister, then &lt;code&gt;ShiftOut&lt;/code&gt; the byte for the first register.  This will push your first byte through to the second register.&lt;/p&gt;&#xA;" OwnerUserId="5131" LastEditorUserId="5131" LastEditDate="2014-12-15T19:40:54.490" LastActivityDate="2014-12-15T19:40:54.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6515" PostTypeId="2" ParentId="6512" CreationDate="2014-12-15T19:02:15.853" Score="1" Body="&lt;p&gt;split the data into 2 bytes, and then send those, one after the other&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shift (int pin) {&#xA;  byte data1 = 0;//shift register 1&#xA;  byte data2 = 0;//shift register 2&#xA;  if( pin&amp;lt;8 )&#xA;    data1 = (1&amp;lt;&amp;lt;pin);&#xA;  else&#xA;    data2 = (1&amp;lt;&amp;lt;(pin-8));&#xA;  shiftOut(ds,shcp,MSBFIRST,data2);//note that you send the data for shift register 2 first&#xA;  shiftOut(ds,shcp,MSBFIRST,data1);&#xA;  digitalWrite(stcp,HIGH);        &#xA;  delay(100);//why wait this long?&#xA;  digitalWrite(stcp,LOW);         &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-15T19:02:15.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6516" PostTypeId="1" CreationDate="2014-12-15T21:59:35.240" Score="2" ViewCount="464" Body="&lt;p&gt;I made a soil moisture sensor out of two metal poles, adjustable resistor, for a project I am making. The first run with the project the sensor worked amazing and gave clear and concise readings, 0-800 depending on water. I then unhooked the sensor and left it in the soil while I fine tuned the code (added warnings to the areas that would read to low), and while testing the code without the sensor being hooked up my arduino uno (Sparkfun Pro Mini) would read a value of 330(area). I thought this strange but didnt worry about it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well I hooked up my sensor (just power, ground, and to the A1 pin) and now my readout for the readings jump from 0 to 800, 0 to 512, 0 to another random number. I commented out everything in the code BUT the part that sets up the pin and displays the analog reading and its still the same issue. I also checked all my wires, changed the resistor setting, changed to a 10k single resistor, nothing changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea on what could be wrong?&lt;/p&gt;&#xA;" OwnerUserId="6258" LastActivityDate="2015-02-11T09:46:47.317" Title="Homemade soil moisture analog value reading jumping from 0 to max" Tags="|programming|sensors|analogread|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6517" PostTypeId="1" AcceptedAnswerId="6518" CreationDate="2014-12-15T23:50:23.323" Score="5" ViewCount="1559" Body="&lt;p&gt;I'm able to set a time and to read it back without any problems but it doesn’t tick up. It stays the same. Even if I restart the serial monitor and thereby resets the buffer(?). So it seems to me that I'm able to set the registers but somehow the oscillator isn't working, do I have to tell it to use the external oscillator? &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/20002292B.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Datasheet&lt;/a&gt;.&#xA;Using Uno Rev3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected it like this:&lt;img src=&quot;https://i.stack.imgur.com/VbAhL.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Never mind the BAT54 diode and the &quot;RTC+MCU_VCC&quot; node, its all just backup power from a capacitor. The supply voltage is alright.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I've been using is a modified version of &lt;a href=&quot;http://www.instructables.com/id/Setting-the-DS1307-Real-Time-Clock-using-the-Seria/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// SDA analog pin 4&#xA;// SCL analog pin 5&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;const int MCP7940 = 0x6F; // Address of MCP7940 see data sheets&#xA;const char* days[] =&#xA;{&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;};&#xA;const char* months[] =&#xA;{&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;, &quot;July&quot;, &quot;August&quot;,&quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot;};&#xA;&#xA;// Initializes all values: &#xA;byte second = 0;&#xA;byte minute = 0;&#xA;byte hour = 0;&#xA;byte weekday = 0;&#xA;byte monthday = 0;&#xA;byte month = 0;&#xA;byte year = 0;&#xA;&#xA;void setup() {&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  delay(2000); // This delay allows the MCU to read the current date and time.&#xA;&#xA;  Serial.print(&quot;The current date and time is: &quot;);&#xA;  printTime();&#xA;  Serial.println(&quot;Please change to newline ending the settings on the lower right of the Serial Monitor&quot;);&#xA;  Serial.println(&quot;Would you like to set the date and time now? Y/N&quot;);&#xA;&#xA;  while (!Serial.available()) delay(10);&#xA;  if (Serial.read() == 'y' || Serial.read() == 'Y')&#xA;&#xA;  // This set of functions allows the user to change the date and time&#xA;  {&#xA;    Serial.read();&#xA;    setTime();&#xA;    Serial.print(&quot;The current date and time is now: &quot;);&#xA;    printTime();&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Thank you.&quot;);&#xA;}&#xA;&#xA;// Continuous function for converting bytes to decimals and vice versa&#xA;void loop() {&#xA;}&#xA;byte decToBcd(byte val) {&#xA;  return ((val/10*16) + (val%10));&#xA;}&#xA;byte bcdToDec(byte val) {&#xA;  return ((val/16*10) + (val%16));&#xA;}&#xA;&#xA;&#xA;// This set of codes is allows input of data&#xA;void setTime() {&#xA;  Serial.print(&quot;Please enter the current year, 00-99. - &quot;);&#xA;  year = readByte();&#xA;  Serial.println(year);&#xA;  Serial.print(&quot;Please enter the current month, 1-12. - &quot;);&#xA;  month = readByte();&#xA;  Serial.println(months[month-1]);&#xA;  Serial.print(&quot;Please enter the current day of the month, 1-31. - &quot;);&#xA;  monthday = readByte();&#xA;  Serial.println(monthday);&#xA;  Serial.println(&quot;Please enter the current day of the week, 1-7.&quot;);&#xA;  Serial.print(&quot;1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat - &quot;);&#xA;  weekday = readByte();&#xA;  Serial.println(days[weekday-1]);&#xA;  Serial.print(&quot;Please enter the current hour in 24hr format, 0-23. - &quot;);&#xA;  hour = readByte();&#xA;  Serial.println(hour);&#xA;  Serial.print(&quot;Please enter the current minute, 0-59. - &quot;);&#xA;  minute = readByte();&#xA;  Serial.println(minute);&#xA;  second = 0;&#xA;  Serial.println(&quot;The data has been entered.&quot;);&#xA;&#xA;  // The following codes transmits the data to the RTC&#xA;  Wire.beginTransmission(MCP7940);&#xA;  Wire.write(byte(0));&#xA;  Wire.write(decToBcd(second));&#xA;  Wire.write(decToBcd(minute));&#xA;  Wire.write(decToBcd(hour));&#xA;  Wire.write(decToBcd(weekday));&#xA;  Wire.write(decToBcd(monthday));&#xA;  Wire.write(decToBcd(month));&#xA;  Wire.write(decToBcd(year));&#xA;  Wire.write(byte(0));&#xA;  Wire.endTransmission();&#xA;  // Ends transmission of data&#xA;}&#xA;&#xA;&#xA;byte readByte() {&#xA;  while (!Serial.available()) delay(10);&#xA;  byte reading = 0;&#xA;  byte incomingByte = Serial.read();&#xA;  while (incomingByte != '\n') {&#xA;    if (incomingByte &amp;gt;= '0' &amp;amp;&amp;amp; incomingByte &amp;lt;= '9')&#xA;      reading = reading * 10 + (incomingByte - '0');&#xA;    else;&#xA;    incomingByte = Serial.read();&#xA;  }&#xA;  Serial.flush();&#xA;  return reading;&#xA;}&#xA;&#xA;&#xA;void printTime() {&#xA;  char buffer[3];&#xA;  const char* AMPM = 0;&#xA;  readTime();&#xA;  Serial.print(days[weekday-1]);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(months[month-1]);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(monthday);&#xA;  Serial.print(&quot;, 20&quot;);&#xA;  Serial.print(year);&#xA;  Serial.print(&quot; &quot;);&#xA;&#xA;  Serial.print(hour);&#xA;  Serial.print(&quot;:&quot;);&#xA;&#xA; Serial.print(minute);&#xA; Serial.println();&#xA;}&#xA;&#xA;&#xA;void readTime() {&#xA;  Wire.beginTransmission(MCP7940);&#xA;  Wire.write(byte(0));&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(MCP7940, 7);&#xA;  second = bcdToDec(Wire.read());&#xA;  minute = bcdToDec(Wire.read());&#xA;  hour = bcdToDec(Wire.read());&#xA;  weekday = bcdToDec(Wire.read());&#xA;  monthday = bcdToDec(Wire.read());&#xA;  month = bcdToDec(Wire.read());&#xA;  year = bcdToDec(Wire.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6262" LastActivityDate="2015-03-26T21:31:19.140" Title="RTC MCP7940M not counting up" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6518" PostTypeId="2" ParentId="6517" CreationDate="2014-12-16T01:02:35.687" Score="6" Body="&lt;p&gt;Okey, I've been very tired when doing this but I think the problem was with bit 7 at adress 00h. The &quot;seconds byte&quot;. That bit is called ST and turns on or off the oscillator. Doing a bitwise OR like this: &lt;code&gt;Wire.write(decToBcd(second) | 128);&lt;/code&gt; sets it to &quot;1&quot; (128 = B10000000) and it's running now.&lt;/p&gt;&#xA;" OwnerUserId="6262" LastActivityDate="2014-12-16T01:02:35.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6519" PostTypeId="1" AcceptedAnswerId="6523" CreationDate="2014-12-16T01:09:18.523" Score="5" ViewCount="403" Body="&lt;p&gt;I am controlling 4 motors using the PWM ports on an Arduino Uno (3,9,10,11). For some reason, the motor hooked up to port 11 doesn't move with my current code. I know it's a code issue because I can create a new basic code that just moves the motor and it works fine, but for some reason it doesn't in this code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;  &#xA;#include &amp;lt;Pixy.h&amp;gt;&#xA;&#xA;Pixy pixy;&#xA;&#xA;int personX = 0;&#xA;int offCount = 0;&#xA;&#xA;void setup() &#xA;{ &#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  while (! Serial);&#xA;  pixy.init();&#xA;}  &#xA;&#xA;void loop() &#xA;{  &#xA;  static int i = 0;&#xA;  int j;&#xA;  uint16_t blocks;&#xA;  char buf[32]; &#xA;&#xA;  blocks = pixy.getBlocks();&#xA;&#xA;  if (blocks)&#xA;  {&#xA;    personX = pixy.blocks[0].x;&#xA;  }&#xA;&#xA;  if (blocks){&#xA;    Serial.println(personX);&#xA;    if (personX &amp;lt; 110){&#xA;      analogWrite(11, 130);&#xA;      analogWrite(3, 130);&#xA;      analogWrite(9, 250);&#xA;      analogWrite(10, 250);&#xA;    } else if (personX &amp;gt; 190){&#xA;      analogWrite(11, 250);&#xA;      analogWrite(3, 250);&#xA;      analogWrite(9, 130);&#xA;      analogWrite(10, 130);&#xA;    } else {&#xA;      analogWrite(11, 190);&#xA;      analogWrite(3, 190);&#xA;      analogWrite(9, 190);&#xA;      analogWrite(10, 190);&#xA;    }&#xA;    offCount = 0;&#xA;  } else {&#xA;    if (offCount &amp;lt; 1000){&#xA;      offCount = offCount + 1;&#xA;    } else {&#xA;      analogWrite(11, 190);&#xA;      analogWrite(3, 190);&#xA;      analogWrite(9, 190);&#xA;      analogWrite(10, 190);&#xA;    }&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, when I take the motor and swap it with another, the old one works in the new PWM port, but the new one stops working once I put it in port 11.&lt;/p&gt;&#xA;" OwnerUserId="6263" LastActivityDate="2014-12-16T02:29:14.143" Title="Arduino PWM malfunctioning" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6520" PostTypeId="2" ParentId="6481" CreationDate="2014-12-16T01:15:34.800" Score="2" Body="&lt;p&gt;You could use C strings, (type &lt;code&gt;char*&lt;/code&gt;) or C++ String objects (type &lt;code&gt;String&lt;/code&gt;). Both would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use C strings, you'll need to use functions like &lt;code&gt;strcmp()&lt;/code&gt; from the C library to see if your input string matches a particular morse sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use C++ String objects, you'll need to use the methods of that class. I'm less familiar with that class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have single Morse characters, matching them up is pretty easy. If you have a continuous stream of dots and dashes, though, it's a much thornier problem. You need a way to figure out the boundary between characters. Morse characters can be sequences of between 1 and 5 dots and dashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless there are extra delays between the dots/dashes for a character, I'm not sure how you figure out where the boundaries are. There are already computer Morse code readers, though, so this must be a &quot;solved problem&quot;. I'd do some googling.&lt;/p&gt;&#xA;" OwnerUserId="2967" LastActivityDate="2014-12-16T01:15:34.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6521" PostTypeId="1" CreationDate="2014-12-16T02:02:02.073" Score="0" ViewCount="75" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  char* ss= (char*)TrueRandom.random(111111111,999999999);&#xA;  char* finalss;&#xA;  Serial.begin(9600);&#xA;  finalss[0] = ss[0];&#xA;  finalss[1] = ss[1];&#xA;  finalss[2] = ss[2];&#xA;  finalss[3] = '-';&#xA;  finalss[4] = ss[3]; &#xA;  finalss[5] = ss[4]; &#xA;  finalss[6] = '-';&#xA;  finalss[7] = ss[5]; &#xA;  finalss[8] = ss[6];&#xA;  finalss[9] = ss[7]; &#xA;  finalss[10] = ss[8];&#xA;  Serial.println (finalss);&#xA;}&#xA;&#xA;void loop() {&#xA;  ; // Do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is supposed to output a randomly generated number in this format nnn-nn-nnnn.&#xA;Updated Code (Doesn't seem to output anything):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  String ss;&#xA;  ss = (String)TrueRandom.random(111111111,999999999);&#xA;  String finalss;&#xA;  Serial.begin(9600);&#xA;  finalss[0] = ss[0];&#xA;  finalss[1] = ss[1];&#xA;  finalss[2] = ss[2];&#xA;  finalss[3] = '-';&#xA;  finalss[4] = ss[3]; &#xA;  finalss[5] = ss[4]; &#xA;  finalss[6] = '-';&#xA;  finalss[7] = ss[5]; &#xA;  finalss[8] = ss[6];&#xA;  finalss[9] = ss[7]; &#xA;  finalss[10] = ss[8];&#xA;  Serial.println (finalss);&#xA;}&#xA;&#xA;void loop() {&#xA;  ; // Do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6264" LastEditorUserId="84" LastEditDate="2014-12-16T05:28:41.547" LastActivityDate="2014-12-17T20:25:04.170" Title="Why is this spitting giberish instead of serial numbers?" Tags="|debugging|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6522" PostTypeId="2" ParentId="6521" CreationDate="2014-12-16T02:24:55.593" Score="4" Body="&lt;p&gt;Casting a number to a &lt;code&gt;char*&lt;/code&gt; doesn't convert the number to a string. Instead it converts the number to a pointer and starts reading &lt;code&gt;char&lt;/code&gt;s from that location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either pass the number to a &lt;a href=&quot;http://arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;String&lt;/code&gt;&lt;/a&gt; constructor, or pass it through &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga5a3fce5fbd20140584619ba9aed09f75&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ltoa()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String ss(...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ss[11];&#xA;ltoa(..., ss, 10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, don't forget to allocate memory for &lt;code&gt;finalss&lt;/code&gt; and NUL-terminate it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char finalss[12];&#xA; ...&#xA;finalss[11] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2014-12-16T02:54:36.967" LastActivityDate="2014-12-16T02:54:36.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6523" PostTypeId="2" ParentId="6519" CreationDate="2014-12-16T02:29:14.143" Score="9" Body="&lt;p&gt;Pin 11 is shared between both PWM and SPI. By activating SPI you've disabled PWM from working on that pin. Either use another PWM pin instead, or switch to software SPI on different pins.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-16T02:29:14.143" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6524" PostTypeId="2" ParentId="1652" CreationDate="2014-12-16T03:57:28.120" Score="0" Body="&lt;p&gt;I recommmend you this one: &lt;a href=&quot;http://www.icstation.com/product_info.php?products_id=3515#.VI-s8clGTQs&quot; rel=&quot;nofollow&quot;&gt;Beginner Learning Kit for Arduino&lt;/a&gt;, but they do not add the code here.&lt;/p&gt;&#xA;" OwnerUserId="5193" LastActivityDate="2014-12-16T03:57:28.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6525" PostTypeId="1" AcceptedAnswerId="6526" CreationDate="2014-12-16T04:16:34.243" Score="0" ViewCount="48" Body="&lt;p&gt;Hello Internet Arduino enthusiasts!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm totally new to Arduino and as my first project, I'd like to make a controller connected to computer A (the master) and computers B and C as 'slaves'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The master would simply send commands as USB mouse and USB keyboard inputs to slave computers through an Arduino controller. Think of it as a hardware KVM switch (without the V(ideo)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I'm planning to work on that during the Christmas vacations, so I need to order the parts now to receive them in time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking I could use these parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino Due (because it has the capability to send keyboard and mouse input) &lt;/li&gt;&#xA;&lt;li&gt;2 SparkFun FTDI Basic Breakout - 5V, one for the mouse, one for the keyboard (per target computer) (&lt;a href=&quot;https://www.sparkfun.com/products/9716&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9716&lt;/a&gt;) (because I can convert it to a 3.3v, what the Due is using)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The price is not really an issue for now.  &lt;/li&gt;&#xA;&lt;li&gt;I'm not worried to much about the programming. &lt;/li&gt;&#xA;&lt;li&gt;I'll figure out how to make it work once I have the time and the items. &lt;/li&gt;&#xA;&lt;li&gt;I know someone who has a starter kit from SparkFun, and there is an electronic store closeby, so I'm not worried about the wires.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Will I be able to make what I'd like with those basic parts, or am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="6261" LastActivityDate="2014-12-16T04:56:27.487" Title="Is this set up appropriate?" Tags="|arduino-due|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6526" PostTypeId="2" ParentId="6525" CreationDate="2014-12-16T04:56:27.487" Score="0" Body="&lt;p&gt;You need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;two MCUs that can act as USB devices (one per slave),&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;some way of getting the commands from the master to the MCUs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That means two Arduino Dues (or Arduino Leonardos, or SparkFun ATmega32U4 breakout boards, etc.) and one USB device of some sort that you can talk to and have send commands to the MCUs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And perhaps something to transport the commands from the master to the slaves, but you need to think about the programming for that first since the transport and the programming will be very closely connected.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-16T04:56:27.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6527" PostTypeId="1" CreationDate="2014-12-16T06:52:07.043" Score="1" ViewCount="141" Body="&lt;p&gt;I'm currently writing a tool that automatically detects connected arduinos and provides a one-button solution for flashing new firmware.&#xA;I've got a couple of arduinos at home (Diecimilla, Uno R3 SMD and some nanos from china) and each type presents with a different serial port name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can someone explain where these port names come from?&lt;/li&gt;&#xA;&lt;li&gt;Can I assume that &lt;code&gt;/dev/cu.usbserial-A9UPDRZB&lt;/code&gt; is, atleast in most cases, an arduino nano?&lt;/li&gt;&#xA;&lt;li&gt;Are there other ways to identify the type of the board?&lt;/li&gt;&#xA;&lt;li&gt;Is the name of the serial port some kind of hash generated from informations retrieved from the device?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6267" LastEditorUserId="6267" LastEditDate="2014-12-16T07:29:58.723" LastActivityDate="2014-12-16T08:21:44.217" Title="Where do serialport names come from?" Tags="|serial|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6529" PostTypeId="2" ParentId="6527" CreationDate="2014-12-16T08:21:44.217" Score="4" Body="&lt;p&gt;You cannot assume anything about serial port names. It's a choice of the operating system, and even if you find the algorithm, there's no guarantee it won't change in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a reference implementation, the &lt;a href=&quot;http://arduino.cc/en/Main/Software#toc3&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE 1.5.x&lt;/a&gt; uses VID (Vendor ID) and PID (Product ID) to identify a board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because accessing such information depends on the underlying operating system, the IDE uses three strategies: on windows, it runs a program called ListComPorts.exe, on macosx it uses CLI tool &lt;code&gt;/usr/sbin/system_profiler&lt;/code&gt;, on linux CLI tool &lt;code&gt;udevadm&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-12-16T08:21:44.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6530" PostTypeId="2" ParentId="3295" CreationDate="2014-12-16T11:37:58.327" Score="1" Body="&lt;p&gt;There is bug related to watchdog in original old Arduino bootloader. You can switch to different bootloader, e.g. &quot;Optiboot&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation of issue from &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega48A/PA/88A/PA/168A/PA/328/P datasheet&lt;/a&gt;, section &lt;strong&gt;10.10.5 Watchdog Timer&lt;/strong&gt;, page 48:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the Watchdog is accidentally enabled, for example by a runaway pointer or brown-out condition, the&#xA;  device will be reset and the Watchdog Timer will stay enabled. If the code is not set up to handle the Watchdog,&#xA;  this might lead to an eternal loop of time-out resets. To avoid this situation, the application software should&#xA;  always clear the Watchdog System Reset Flag (WDRF) and the WDE control bit in the initialization routine,&#xA;  even if the Watchdog is not in use.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Reset from button is not helping, only power off/on reset give device change to boot again (and flash new software). Explanation of this, from &lt;strong&gt;11.9.1 MCUSR – MCU Status Register&lt;/strong&gt;, page 54:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Bit 3 – WDRF: Watchdog System Reset Flag&#xA;  This bit is set if a Watchdog System Reset occurs. The bit is reset by a Power-on Reset, or by writing a logic&#xA;  zero to the flag.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6272" LastEditorUserId="6936" LastEditDate="2018-10-19T18:58:52.867" LastActivityDate="2018-10-19T18:58:52.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="6531" PostTypeId="2" ParentId="6495" CreationDate="2014-12-16T14:59:50.540" Score="1" Body="&lt;p&gt;Depending on the switch type:&#xA;-SPDT (SIngle Pole Double Throw) - You would use a Cross Coupled NAND Gates (Flip Flop, Set Reset) This will set true to the side it sees power at from the switch and if it bounces it can't change state until the switch touch the other contact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-SPST (Single Pole Single Throw) - You can use a software debounce where you would detect a signal and then wait for 10ms then read again and if there is a signal still, it is a debounced signal.  --OR--  You can use capacitors to help extend the life of a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so debounce code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool sw13=false;&#xA;bool sw12=false;&#xA;while(1){&#xA;if(digitalRead(13)==HIGH &amp;amp;&amp;amp; !sw13){&#xA;  delay(20); //Delay For 20ms&#xA;  if(digitalRead(13)==HIGH){&#xA;    i=setCountPlus(i);&#xA;    sw13=true;&#xA;  }&#xA;}else{&#xA;    sw13=false;&#xA;}&#xA;if(digitalRead(12)==HIGH &amp;amp;&amp;amp; !sw12){&#xA;  delay(20); &#xA;  if(digitalRead(12)==HIGH){&#xA;    i=setCountMinus(i);&#xA;    sw12=true;&#xA;  }&#xA;}else{&#xA;    sw12=false;&#xA;}&#xA;if(i==10){&#xA;  i=1;&#xA;}&#xA;//show(i);&#xA;delay(250);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5116" LastActivityDate="2014-12-16T14:59:50.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6532" PostTypeId="2" ParentId="6512" CreationDate="2014-12-16T15:15:31.897" Score="0" Body="&lt;pre&gt;&lt;code&gt;void shift(int pin) {&#xA;  digitalWrite(stcp, LOW);&#xA;&#xA;  // shift the bits out:&#xA;  shiftOut(ds, shcp, MSBFIRST, pin &amp;gt;&amp;gt; 8);&#xA;  shiftOut(ds, shcp, MSBFIRST, pin);&#xA;  // turn on the output so the LEDs can light up:&#xA;  digitalWrite(stcp, HIGH);&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6227" LastActivityDate="2014-12-16T15:15:31.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6534" PostTypeId="1" CreationDate="2014-12-16T17:41:44.667" Score="1" ViewCount="48" Body="&lt;p&gt;Can I ping or “hello world” an Arduino.&lt;br&gt;&#xA;Background:  My son and I bought a 3-D printer kit.&#xA;&lt;a href=&quot;https://www.phoenix3dprinter.com/&quot; rel=&quot;nofollow&quot;&gt;(EZ-3D)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are having some issues talking with it.  (Well we can't talk at all.)  So we thought to upload the &lt;a href=&quot;https://ez3d.freshdesk.com/support/solutions/articles/1000080546-uploading-firmware&quot; rel=&quot;nofollow&quot;&gt;firmware&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It’s an Arduino Mega 2560, and when we upload the Arduino times out… but it takes a minute or two.  Can I try some simpler program just to try and talk to the Arduino?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m almost a “virgin” Arduino user so be gentle.  &lt;/p&gt;&#xA;" OwnerUserId="6276" LastActivityDate="2014-12-16T18:00:26.210" Title="Checking connection/ communication" Tags="|arduino-mega|communication|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6535" PostTypeId="2" ParentId="6534" CreationDate="2014-12-16T18:00:26.210" Score="1" Body="&lt;p&gt;Adafruit has a good set of guides to getting started with arduino:&#xA;&lt;a href=&quot;https://learn.adafruit.com/series/learn-arduino&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/series/learn-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-1-blink&quot; rel=&quot;nofollow&quot;&gt;Blink&lt;/a&gt;&quot; program is the equivalent of &quot;hello world&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When testing you probably should disconnect the Arduino from the 3D printer.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-12-16T18:00:26.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6537" PostTypeId="1" CreationDate="2014-12-16T21:35:01.540" Score="2" ViewCount="1946" Body="&lt;p&gt;I just received my new Intel Edison with Arduino Breakout Kit and after hours trying to connec to it, I just can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected two USB cables to my computer, the switch between the power suply and the nearest usb cable is set to be near the usb cable as explained here : &lt;a href=&quot;https://software.intel.com/en-us/articles/startup-guide-for-linux-intel-edison-users&quot; rel=&quot;nofollow&quot;&gt;https://software.intel.com/en-us/articles/startup-guide-for-linux-intel-edison-users&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when I connect the two cables, here's &lt;code&gt;dmesg&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  +1,675635] usb 2-1.2: new high-speed USB device number 24 using ehci-pci&#xA;[  +0,098861] usb 2-1.2: New USB device found, idVendor=8086, idProduct=e005&#xA;[  +0,000008] usb 2-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3&#xA;[  +0,000005] usb 2-1.2: Product: MERRIFIELD&#xA;[  +0,000003] usb 2-1.2: Manufacturer: INTEL&#xA;[  +0,000004] usb 2-1.2: SerialNumber: 10692CA2BC827B2B148DBA29FF184150&#xA;[  +9,018609] usb 2-1.2: USB disconnect, device number 24&#xA;[  +0,769033] usb 2-1.2: new high-speed USB device number 25 using ehci-pci&#xA;[  +0,100256] usb 2-1.2: New USB device found, idVendor=8086, idProduct=e005&#xA;[  +0,000010] usb 2-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=3&#xA;[  +0,000005] usb 2-1.2: Product: MERRIFIELD&#xA;[  +0,000005] usb 2-1.2: Manufacturer: INTEL&#xA;[  +0,000004] usb 2-1.2: SerialNumber: 10692CA2BC827B2B148DBA29FF184150&#xA;[  +0,082352] usb 2-1.2: USB disconnect, device number 25&#xA;[  +2,538308] usb 2-1.2: new high-speed USB device number 26 using ehci-pci&#xA;[  +0,086453] usb 2-1.2: New USB device found, idVendor=8087, idProduct=0a99&#xA;[  +0,000012] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3&#xA;[  +0,000006] usb 2-1.2: Product: USB download gadget&#xA;[  +0,000005] usb 2-1.2: Manufacturer: Intel&#xA;[  +2,657426] usb 2-1.2: USB disconnect, device number 26&#xA;[déc.16 21:14] usb 2-1.2: new high-speed USB device number 27 using ehci-pci&#xA;[  +0,087183] usb 2-1.2: New USB device found, idVendor=8087, idProduct=0a9e&#xA;[  +0,000010] usb 2-1.2: New USB device strings: Mfr=2, Product=3, SerialNumber=4&#xA;[  +0,000005] usb 2-1.2: Product: Multifunction Composite Gadget&#xA;[  +0,000005] usb 2-1.2: Manufacturer: Linux 3.10.17-poky-edison+ with dwc3-gadget&#xA;[  +0,000004] usb 2-1.2: SerialNumber: 6c1877a6e8f1f5671214d752ae622b8a&#xA;[  +0,004451] rndis_host 2-1.2:1.0 usb0: register 'rndis_host' at usb-0000:00:1d.0-1.2, RNDIS device, 96:16:2c:fe:eb:a3&#xA;[  +0,001898] cdc_acm 2-1.2:1.2: This device cannot do calls on its own. It is not a modem.&#xA;[  +0,000085] cdc_acm 2-1.2:1.2: ttyACM0: USB ACM device&#xA;[  +0,002327] usb-storage 2-1.2:1.4: USB Mass Storage device detected&#xA;[  +0,000287] scsi host13: usb-storage 2-1.2:1.4&#xA;[  +0,057754] rndis_host 2-1.2:1.0 enp0s29u1u2: renamed from usb0&#xA;[  +0,008595] systemd-udevd[11838]: renamed network interface usb0 to enp0s29u1u2&#xA;[  +0,937753] scsi 13:0:0:0: Direct-Access     Linux    File-CD Gadget   0310 PQ: 0 ANSI: 2&#xA;[  +0,001719] sd 13:0:0:0: Attached scsi generic sg1 type 0&#xA;[  +0,013953] sd 13:0:0:0: [sdb] 1572864 512-byte logical blocks: (805 MB/768 MiB)&#xA;[  +0,001413] sd 13:0:0:0: [sdb] Write Protect is off&#xA;[  +0,000009] sd 13:0:0:0: [sdb] Mode Sense: 0f 00 00 00&#xA;[  +0,001013] sd 13:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA&#xA;[  +0,005279]  sdb: sdb1&#xA;[  +0,008088] sd 13:0:0:0: [sdb] Attached SCSI disk&#xA;[  +0,391987] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.&#xA;[  +0,000018] SELinux: initialized (dev sdb1, type vfat), uses genfs_contexts&#xA;[  +3,143835] rndis_host 2-1.2:1.0 enp0s29u1u2: unregister 'rndis_host' usb-0000:00:1d.0-1.2, RNDIS device&#xA;[  +0,031230] sd 13:0:0:0: [sdb] Synchronizing SCSI cache&#xA;[  +0,025797] usb 2-1.2: USB disconnect, device number 27&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, there is first something that bothers me :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Volume was not properly unmounted. Some data may be corrupt. Please run fsck.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is this &quot;normal&quot; ? When running fcsk it talks about the dirty bit, I assumed it was a specific reason for Intel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the dmesg, I can see that the module will be available at ttyACM0, so I try to conenct using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screen /dev/ttyACM0 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing, a blank screen. I can try to hit enter one, two or millions times, nothing changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm stuck here for the moment, I don't know what to do more.&#xA;For information I'm using Fedora 20 64bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="6279" OwnerDisplayName="Cyril N." LastEditorUserId="83" LastEditDate="2015-01-15T18:33:13.850" LastActivityDate="2015-10-02T02:03:28.443" Title="Unable to connect to Intel Edison Arduino kit" Tags="|hardware|edison|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6538" PostTypeId="2" ParentId="6521" CreationDate="2014-12-17T04:35:31.613" Score="1" Body="&lt;p&gt;I am really assuming you are doing this on a arduino, do you have the serial terminal switched on, you are putting that entire code in setup, means it executes only once and that maybe before you can get your serial terminal on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you are putting it on setup, you need to push the reset button to get a number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;check the code at -&#xA;&lt;a href=&quot;https://code.google.com/p/tinkerit/wiki/TrueRandom&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/tinkerit/wiki/TrueRandom&lt;/a&gt; and see if that works&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better way to write your code may be - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TrueRandom.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.print(TrueRandom.random(111,999));&#xA;  Serial.print('-');&#xA;  Serial.print(TrueRandom.random(11,99));&#xA;  Serial.print('-');&#xA;  Serial.println(TrueRandom.random(1111,9999));&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  ; // Do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6268" LastActivityDate="2014-12-17T04:35:31.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6539" PostTypeId="1" AcceptedAnswerId="6540" CreationDate="2014-12-17T07:41:19.377" Score="0" ViewCount="375" Body="&lt;p&gt;I know how to create my own arduino library and use it. I am using Xcode to create a c++ project. I have the arduino library files(Servo, Wire, Keypad, etc). If I want to include the Servo.h library file in my created library, how do I go about linking that? For some reason, I can't just add the Servo.h/.cpp files in my project because then I get other linking file problems that Servo.h references and are not linked in my project. Has anyone done this before?&lt;/p&gt;&#xA;" OwnerUserId="6288" OwnerDisplayName="JEB" LastActivityDate="2014-12-17T09:23:53.637" Title="Creating arduino library linking question" Tags="|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6540" PostTypeId="2" ParentId="6539" CreationDate="2014-12-17T09:23:53.637" Score="0" Body="&lt;p&gt;I can't speak for Xcode, but in general with Arduino IDEs (UECIDE excepting) if you use a library within another library, that library also has to be #included in the main sketch.  That is the only way most IDEs determine which libraries need to be compiled into the finished program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's one of the first targets I had for UECIDE - to enable fully recursive library compilation.  Any libraries found within the master header of a library will also be included for compilation - and any found in those libraries, etc.  It took a lot of work (and it's by no means 100% perfect), which is why so few others do it and leave it up to the programmer to ensure the inclusion of the right sub-libraries in their sketch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-12-17T09:23:53.637" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6541" PostTypeId="1" AcceptedAnswerId="6548" CreationDate="2014-12-17T11:01:28.533" Score="15" ViewCount="36542" Body="&lt;p&gt;I'm a beginner to microcontrollers and electronics, albeit not really to computers and programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting out with the Arduino, I came to a point whereby I'm really interested in getting my prototype to talk to a mobile device or a computer to send and receive data (for example, send sensor data or receive commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking out, I've found out that there are different bluetooth modules with varying pricing points. Further research into differences did not reveal much to me as being a beginner, I am struggling to understand what to look out for or how to choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question here is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the fundemental differences of different Bluetooth modules for beginners, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;HC-05&lt;/li&gt;&#xA;&lt;li&gt;HC-06&lt;/li&gt;&#xA;&lt;li&gt;HC-07&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And what should one look for when buying a simple Bluetooth module for Arduino?&lt;/p&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2016-11-26T04:20:26.850" Title="What are the fundemental differences of different Bluetooth modules for beginners?" Tags="|arduino-uno|arduino-mega|bluetooth|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6542" PostTypeId="1" AcceptedAnswerId="6544" CreationDate="2014-12-17T12:47:13.387" Score="2" ViewCount="5081" Body="&lt;p&gt;I'm using an Arduino Due board with an optocoupler 4N25 to simulate a button pressed.&#xA;I have to open and close a circuit that drive an actuator. In that circuit, when connected, with the tester I'm measuring 6V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connect the anode to the pin 12 and the cathode in series with a 150-ohm resistor to ground, and Collector and Emitter from optocopupler to the circuit (and a normal Blink example with the pin 12).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When optocoupler is fired on and off respectively with a tester I measure 0V and 1.7V in the arduino part, and 4V and 6V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not enough and the actuator is always run. I'd like to read 0-6V instad of 4V-6V. Does this depends on how much current goes to the anode/cathode of the optocoupler? Do I have to change the resistor in the arduino part? Any kind of advice? What can I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to use relay because I have read that in respect to a relay they are faster, smaller, longer-lived and quieter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tMwJq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2014-12-17T13:15:55.787" LastActivityDate="2014-12-17T16:17:47.573" Title="Arduino DUE and optocoupler 4N25" Tags="|arduino-due|voltage-level|relay|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6543" PostTypeId="1" AcceptedAnswerId="6550" CreationDate="2014-12-17T16:05:54.857" Score="6" ViewCount="15725" Body="&lt;p&gt;I'm looking forward to getting an accurate humidity and temperature sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right when I decided to go with a DHT22 module, I saw AM230x (AM2301, for example).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do I choose between DHT22 and AM2301?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2019-02-05T09:30:46.153" Title="How to choose between AM230x and DHT22 temperature and humidity sensors?" Tags="|arduino-uno|arduino-mega|sensors|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6544" PostTypeId="2" ParentId="6542" CreationDate="2014-12-17T16:12:11.190" Score="2" Body="&lt;p&gt;It sounds like the 4N25 opto-coupler on its own can't do what you need because it's not designed to directly make/break a connection between a power source and its load (i.e. it isn't functionally equivalent to a relay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally, the switching functionality is provided by an NPN photo-transistor. A typical open collector usage would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WYr1d.png&quot; alt=&quot;Example of an opto-coupler circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;&lt;em&gt;(Image copyright Lewis Loflin: &lt;a href=&quot;http://www.bristolwatch.com/ele/opto_isolated.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.bristolwatch.com/ele/opto_isolated.htm&lt;/a&gt;)&lt;/em&gt;&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The switch (&lt;code&gt;S1&lt;/code&gt;) and the power source (&lt;code&gt;Vi&lt;/code&gt;) on the left would be your Arduino. All the connections on the right would be part of your device (the actuator).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, you need 3 connections on the right: voltage source (&lt;code&gt;Vcc&lt;/code&gt;), ground, and the output (&lt;code&gt;Vo&lt;/code&gt;, which goes to your device). The circuit basically works by pulling the output (&lt;code&gt;Vo&lt;/code&gt;) either up to &lt;code&gt;Vcc&lt;/code&gt; to turn it on, or down to ground to turn it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like all you have is &lt;code&gt;Vcc&lt;/code&gt; and &lt;code&gt;Vo&lt;/code&gt;, so this kind of configuration won't work. (Don't try to use the ground from your Arduino instead. That could cause various other problems.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be possible to setup additional circuitry to act more like a Solid State Relay, but without a ground reference point it can be harder than it sounds. A mechanical relay might be the easiest option.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2014-12-17T16:17:47.573" LastActivityDate="2014-12-17T16:17:47.573" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6545" PostTypeId="1" AcceptedAnswerId="6546" CreationDate="2014-12-17T16:43:21.947" Score="1" ViewCount="1710" Body="&lt;p&gt;I have seen commercial Xbee / Zigbee clones using HC-05 integrated inside.&#xA;Are they any different than regular HC-05 bluetooth modules?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is differences in usage between a HC-05 bluetooth module and a Zigbee HC-05 module?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2014-12-17T19:48:48.903" Title="What is differences in usage between a HC-05 bluetooth module and a Zigbee HC-05 module?" Tags="|bluetooth|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6546" PostTypeId="2" ParentId="6545" CreationDate="2014-12-17T19:48:48.903" Score="3" Body="&lt;p&gt;Bluetooth and Zigbee are two different communication protocols. The Xbee clones you are talking about a called &lt;a href=&quot;http://www.elecfreaks.com/store/bluetooth-bee-hc05-btbeehc05-p-171.html&quot; rel=&quot;nofollow&quot;&gt;BTbee&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as im aware the BTbee modules are the same hardware/firmware wise as the hc05/hc06 modules. The only difference being the BTbee modules are in the Xbee footprint, allowing you to plug them into Xbee/Zigbee sockets.&lt;/p&gt;&#xA;" OwnerUserId="6290" LastActivityDate="2014-12-17T19:48:48.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6547" PostTypeId="2" ParentId="6541" CreationDate="2014-12-17T19:52:23.327" Score="2" Body="&lt;p&gt;I don't really know the differences but I've used the HC-06 modules. They are slave-mode only but that is what you need to replace a hard-wired terminal to your Arduino, such as your PC and and a USB cable, with a Bluetooth terminal. That probably covers 99% of cases where an Arduino or other MCU-based device needs to communicate to a PC or tablet that already has Bluetooth built in. For device to device communication, one of them would have to be a master, and I think that requires an HC-05.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2014-12-18T18:31:15.680" LastActivityDate="2014-12-18T18:31:15.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6548" PostTypeId="2" ParentId="6541" CreationDate="2014-12-17T19:57:00.653" Score="9" Body="&lt;p&gt;As far as simplicity is concerned, HC05 would be the way to go. It is by far the most popular and there are a tonne of tutorials on using it (just a quick google search).&#xA;As for the differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The HC-05 module can build a connection to other modules. E.g. a Robot being a master and connecting to slave bluetooth module. Or in slave mode to make a wireless bridge to a notebook.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The HC-06 module only can be a slave. This makes it only useful for say connecting a notebook as a master to a robot with a slave module e.g. for a wireless serial bridge.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As for the HC07, support seems low so I would recommend sticking with HC05 or HC06&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At the end of the day it comes down to your requirements. If you are only wanting to talk between the phone and your arduino than the HC06 would work fine, however if at some point in time you want to talk to another arduino, than hc05 would be the way to go.&lt;/p&gt;&#xA;" OwnerUserId="6290" LastActivityDate="2014-12-17T19:57:00.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6549" PostTypeId="2" ParentId="6521" CreationDate="2014-12-17T20:25:04.170" Score="1" Body="&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  long longrand = TrueRandom.random(111111111,999999999);&#xA;  char ss[9+1], finalss[13+1];&#xA;&#xA;  Serial.begin(9600);&#xA;  (void)ltoa(longrand, ss, 10);&#xA;&#xA;  finalss[0] = ss[0];&#xA;  finalss[1] = ss[1];&#xA;  finalss[2] = ss[2];&#xA;  finalss[3] = '-';&#xA;  finalss[4] = ss[3]; &#xA;  finalss[5] = ss[4]; &#xA;  finalss[6] = '-';&#xA;  finalss[7] = ss[5]; &#xA;  finalss[8] = ss[6];&#xA;  finalss[9] = ss[7]; &#xA;  finalss[10] = ss[8];&#xA;  finalss[10] = '\0';&#xA;&#xA;  Serial.println (finalss);&#xA;}&#xA;&#xA;void loop() {&#xA;  ; // Do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;TrueRandom.random()&lt;/code&gt; returns a long, not a string, so you need to assign the value to a long variable while you translate it.&lt;/li&gt;&#xA;&lt;li&gt;Your code didn't allocate any memory for the arrays you tried to use, so the third statement does that. I made them larger than the number of characters you used because the range you gave to &lt;code&gt;TrueRandom.random()&lt;/code&gt; is a set of 9-digit numbers. I don't know how you need to punctuate your numbers so I allocated &lt;code&gt;finalss[]&lt;/code&gt; larger yet. You should confirm that the array sizes will be sufficient for your needs.&lt;/li&gt;&#xA;&lt;li&gt;The fifth statement, ltoa() converts a long to an ascii string in the &lt;code&gt;ss[]&lt;/code&gt; array.&lt;/li&gt;&#xA;&lt;li&gt;I left your &lt;code&gt;finalss[x] = ss[x];' statements alone except to add the necessary NUL terminator at the end of&lt;/code&gt;finalss[]`.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I haven't tested this but it compiled with no errors other than my not having &lt;code&gt;TrueRandom.h&lt;/code&gt;. But it should get you a lot closer to (what it looks to me as if) you intended.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-12-17T20:25:04.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6550" PostTypeId="2" ParentId="6543" CreationDate="2014-12-17T20:33:12.623" Score="8" Body="&lt;p&gt;The AM2301 and the DHT22(AM2303) are similar in a number of ways, both in price, specs, ranges and power consumption. They are usually cased a bit of a differently, with the DHT22/AM2303 being packaged with four pins (only three are in use), and the AM2301 (formerly called DHT21) is packaged with three cables and a small plug inside of the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would choose based on the usage, if I'm going to use the sensor on a breadboard or a socket (going for the DHT22 pinned version), or if I'm going to have it standalone (the cabled one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are links to the datasheets:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://kropochev.com/downloads/humidity/AM2301.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://kropochev.com/downloads/humidity/AM2301.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/datasheets/DHT22.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/datasheets/DHT22.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6292" LastEditorUserId="53509" LastEditDate="2019-02-05T09:30:46.153" LastActivityDate="2019-02-05T09:30:46.153" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="6551" PostTypeId="1" AcceptedAnswerId="6552" CreationDate="2014-12-17T23:42:34.857" Score="1" ViewCount="233" Body="&lt;p&gt;I had my sketch uplaoded and everything was working fine when I tried connecting one of the input pins(pre-configured as digital INPUT) to 12V, just to see if this was being read as a HIGH as well.&#xA;It seems to have done something and the board stopped working. Moreover, all pins seem to be stuck at HIGH! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far Ive tried the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reset button: doesnt help&lt;/li&gt;&#xA;&lt;li&gt;re-upload: doesn't work - it says not in sync&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Physically nothing seems to be burnt/blown. What am I missing? Have I fried my board? I hope not. PS: It was connected to a 12V external power source&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="6294" LastEditorUserId="46" LastEditDate="2014-12-18T16:04:24.347" LastActivityDate="2014-12-18T16:04:24.347" Title="Did I accidentally short something? My Arduino UNO board does not communicate with the computer anymore" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6552" PostTypeId="2" ParentId="6551" CreationDate="2014-12-18T00:34:05.480" Score="1" Body="&lt;p&gt;Unfortunately, the arduino's input pins are not tolerant of 12 volts, You have likely caused permanent damage to the chip =(. There is a regulator that makes it capable of being &lt;em&gt;powered&lt;/em&gt; by 12 volts, but the input pins are different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at table 30-1 on the datasheet for the Uno's controller &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; you can see the input characteristics. The arduino is powered at 5v, so the max digital input voltage is 5.5v&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-12-18T00:34:05.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6553" PostTypeId="1" AcceptedAnswerId="6582" CreationDate="2014-12-18T03:51:41.783" Score="0" ViewCount="6874" Body="&lt;p&gt;I need an Arduino Mega 2560 (that is the one that has more pins). I went to eBay and there are a lot of different boards. I'm thinking of buying an &lt;a href=&quot;http://www.ebay.com/itm/201197139954&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega2560-16AU CH340G MEGA 2560 R3 Board + Free USB Cable for Arduino&#xA;&lt;/a&gt;. Is this one good? I mean, does it do the work? Is it compatible with the Arduino IDE? Anything I need to know?&lt;/p&gt;&#xA;" OwnerUserId="6235" LastEditorUserId="4628" LastEditDate="2017-11-07T04:34:05.680" LastActivityDate="2017-11-07T04:35:37.163" Title="Which Arduino board to buy?" Tags="|arduino-mega|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6555" PostTypeId="2" ParentId="6553" CreationDate="2014-12-18T08:09:59.387" Score="0" Body="&lt;p&gt;It's a counterfeit, and counterfeits are never a good choice. &lt;a href=&quot;http://arduino.cc/en/Products/Counterfeit&quot; rel=&quot;nofollow&quot;&gt;Scroll this down&lt;/a&gt; to the Pricing paragraph to see where your money goes when you buy an &lt;a href=&quot;http://arduino.cc/en/Main/Buy&quot; rel=&quot;nofollow&quot;&gt;official board&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-12-18T08:09:59.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6556" PostTypeId="2" ParentId="3680" CreationDate="2014-12-18T09:04:29.850" Score="2" Body="&lt;p&gt;You can always make some kind of id print via serial in void setup(). After the certain board is connected it will send this id to your USB interface (which you are listening with some kind of daemon app on your linux box). Once you receive id you can map it to it's path&#xA; 'Arduino1' : '/dev/ttyACM0', &#xA; 'Arduino2' : '/dev/ttyACM1',&#xA; 'Arduino3' : '/dev/ttyACM2'...etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that when device is disconnected for some reason it can change it's physical path so you might have to remap all of them. For this case it might be good to write separate function ex: get_id() which you can call any time (not only on startup).&lt;/p&gt;&#xA;" OwnerUserId="4908" LastActivityDate="2014-12-18T09:04:29.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6557" PostTypeId="1" AcceptedAnswerId="6562" CreationDate="2014-12-18T11:23:36.557" Score="1" ViewCount="937" Body="&lt;p&gt;I need to use two stepper motors to move microscope positioning knobs in the X/Y direction. The stepper motors I have are unipolar and are 6V rated (I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's possible to drive a unipolar stepper motor via a ULN2003 using an Arduino Uno. I know I can wire it using the 2-wire or 4-wire method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to drive 2 of them? What are the modifications I will need to make to the circuit? Will this harm my Arduino? Do I need a stepper motor shield?&lt;/p&gt;&#xA;" OwnerUserId="6298" LastActivityDate="2014-12-19T15:23:00.223" Title="Arduino Uno to drive 2 unipolar stepper motors" Tags="|arduino-uno|motor|shields|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6558" PostTypeId="2" ParentId="6557" CreationDate="2014-12-18T11:42:35.340" Score="0" Body="&lt;p&gt;I'd suggest to have a look at the &lt;a href=&quot;http://www.schmalzhaus.com/EasyDriver/index.html&quot; rel=&quot;nofollow&quot;&gt;EasyDriver&lt;/a&gt; stepper motor drivers developed by Brian Schmalz. They are easy to set up and do support &lt;strong&gt;microstepping&lt;/strong&gt;, which might be interesting for a more fine control of the microscope. &lt;/p&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-12-18T11:42:35.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6559" PostTypeId="1" CreationDate="2014-12-18T14:03:17.323" Score="-1" ViewCount="343" Body="&lt;p&gt;So I am trying to make an audio visualizer from this tutorial listed &lt;a href=&quot;https://learn.adafruit.com/piccolo/overview&quot; rel=&quot;nofollow&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I downloaded all the files needed, and downloaded the code. But when I try to verify it, I get this Error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope&#xA;core.a(main.cpp.o): In function `main':&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've looked this up before, and couldn't find anything on it. So I came here for a last resort.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Any ideas?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;EDIT: So I reinstalled the folders, and renamed the LED folder but now I get a new error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Piccolo:112: error: 'Adafruit_BicolorMatrix' does not name a type&#xA;Piccolo.pde: In function 'void setup()':&#xA;Piccolo:130: error: 'matrix' was not declared in this scope&#xA;Piccolo.pde: In function 'void loop()':&#xA;Piccolo:168: error: 'matrix' was not declared in this scope&#xA;Piccolo:168: error: 'LED_RED' was not declared in this scope&#xA;Piccolo:169: error: 'LED_YELLOW' was not declared in this scope&#xA;Piccolo:170: error: 'LED_GREEN' was not declared in this scope&#xA;Piccolo:207: error: 'LED_OFF' was not declared in this scope&#xA;Piccolo:210: error: 'LED_OFF' was not declared in this scope&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: Deleted Robot_Control and got this error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In file included from Piccolo.pde:34:&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:94: error: expected class-name before '{' token&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:103: error: expected class-name before '{' token&#xA;C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:112: error: expected class-name before '{' token&#xA;Piccolo.pde: In function 'void loop()':&#xA;Piccolo:168: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'&#xA;Piccolo:169: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'&#xA;Piccolo:170: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'&#xA;Piccolo:207: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'&#xA;Piccolo:210: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'&lt;/p&gt;&#xA;" OwnerUserId="6300" LastEditorUserId="368" LastEditDate="2014-12-18T15:44:59.770" LastActivityDate="2023-01-14T10:04:20.507" Title="Arduino Piccolo Example Script Error" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6560" PostTypeId="2" ParentId="6559" CreationDate="2014-12-18T14:32:15.317" Score="0" Body="&lt;p&gt;As I mentioned in the comments, reinstalling/updating all your 3rd party libraries to the latest versions is probably the first thing to try. Updating the IDE itself may also help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that hasn't worked then a forum topic here seems to describe the same kind of issue: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=168854.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=168854.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the users seems to have tracked the problem down to a couple of Adafruit libraries. He suggests the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1) Delete the folder &quot;Robot_Control&quot; from Program&#xA;  Files\Arduino\libraries\&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;2) Make sure, that the two Adafruit folders in the same folder are&#xA;  named Adafruit_GFX and Adafruit_ST7735. I had them named &quot;AdafruitGFX&quot;&#xA;  and &quot;AdafruitST7735&quot;, but that was wrong.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Deleting the &lt;code&gt;Robot_Control&lt;/code&gt; folder doesn't sound like an ideal solution to me, but perhaps there's an incompatibility which can't be easily fixed. Unfortunately, the Arduino IDE handles libraries in a slightly strange way, so weird problems can happen from time to time.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-18T14:32:15.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6562" PostTypeId="2" ParentId="6557" CreationDate="2014-12-18T16:16:54.233" Score="1" Body="&lt;p&gt;No problem. Just use two ULN2003 chips, one for each stepper. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;No need for a motor/stepper shield on these unipolar steppers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will not harm the arduino (if wired correctly).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2014-12-19T15:23:00.223" LastActivityDate="2014-12-19T15:23:00.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6564" PostTypeId="2" ParentId="6553" CreationDate="2014-12-18T17:40:49.263" Score="2" Body="&lt;p&gt;There is no way to know the quality of the Arduino clones on eBay. They may be fine but you never know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend buying an official Arduino from one of the &lt;a href=&quot;http://arduino.cc/en/Main/Buy&quot; rel=&quot;nofollow&quot;&gt;official distributors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are good quality Arduino compatible boards like the SparkFun Redboard or the Adafruit Trinket. But these are not made to look like official Arduino boards. (Neither of these would work for you since they don't have as many pins as the Mega)&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-12-18T17:40:49.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6565" PostTypeId="2" ParentId="5293" CreationDate="2014-12-18T19:53:20.030" Score="1" Body="&lt;p&gt;There is an example of using the ethernet shield as a simple web server on the arduino website:&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WebServer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit has another tutorial using an SDCard to hold the web application's files:&#xA;&lt;a href=&quot;http://www.ladyada.net/learn/arduino/ethfiles.html&quot; rel=&quot;nofollow&quot;&gt;http://www.ladyada.net/learn/arduino/ethfiles.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be possible to use the aforementioned techniques to host a simple web application.&#xA;Since the browser only understands HTML, CSS and JavaScript (browser plugins not withstanding), the application will have to be written using these languages.&#xA;The HTML file will describe the structure of the UI (text, buttons, etc.), the CSS will apply styles if necessary and the JavaScript will add the interaction code (e.g. what happens when you press a button). The JavaScript could request data from the arduino+ethernet shield using AJAX request and should be able to send data back the same way. Using jQuery, this should be pretty straightforward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, it might be easier to use a full fledged network stack such as the one you can find on Linux (using a raspberry pi for example) and to communicate using the serial port with Linux. I have an example on GitHub (the documentation is lacking but I could update it if need be): &lt;a href=&quot;https://github.com/ddm/arduino-express&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ddm/arduino-express&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in that case you don't get to use the ethernet shield which you may have already bought...&lt;/p&gt;&#xA;" OwnerUserId="3384" LastActivityDate="2014-12-18T19:53:20.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6566" PostTypeId="2" ParentId="6500" CreationDate="2014-12-18T21:02:21.240" Score="1" Body="&lt;p&gt;why dont you use an i2c adapter for this type of display?&#xA;search for i2c display module.&#xA;i2c only needs 2 wires for data and clock and 2 for power.&#xA;you can also easily locate the SDA and SCL pins on your arduino&lt;/p&gt;&#xA;" OwnerUserId="6305" LastActivityDate="2014-12-18T21:02:21.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6567" PostTypeId="1" AcceptedAnswerId="6585" CreationDate="2014-12-18T21:27:33.720" Score="1" ViewCount="763" Body="&lt;p&gt;I have not used the Arduino in over 2 years and have forgotten a bunch of stuff I was wondering if someone could help me out. I have two analog sensors both the same connected to the appropriate analog pins. I am getting a read on the serial monitor and when i test the sensors the values are changing so i know the circuit is correct and everything is in the right place. I just have an issue with my code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  // read the input on analog pin 0:&#xA;  int sensorValue1 = analogRead(A0);&#xA;&#xA;  // print out the value you read:&#xA;  Serial.println(sensorValue1);&#xA;   //Serial.print(&quot;val1 = &quot; );&#xA;  Serial.print(sensorValue1);&#xA;  Serial.print(&quot; &quot;);&#xA;&#xA;  delay(1000);        // delay in between reads for stability&#xA;&#xA;&#xA;   // read the input on analog pin 1:&#xA;  int sensorValue2 = analogRead(A1);&#xA;&#xA;  // print out the value you read:&#xA;  Serial.println(sensorValue2);&#xA;  //Serial.print(&quot;val2 = &quot; );&#xA;  Serial.print(sensorValue2);&#xA;  Serial.print(&quot; &quot;);&#xA;  delay(1000);        // delay in between reads for stability&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;once i view this in the serial monitor it is not organized and the sensorvalue1 is skipping over to the next line. I would appreciate the help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/u5ipi.png&quot; alt=&quot;This is the serial output on the serial monitor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two sensors so there should be two values but in the picture the values are all messed up i would ideally like it to give me a two seperate values one for each sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val1= sensorvalue1&#xA;val2= sensorvalue2&lt;/p&gt;&#xA;" OwnerUserId="6306" LastEditorUserId="6306" LastEditDate="2014-12-19T16:34:36.340" LastActivityDate="2015-03-16T20:01:09.913" Title="analog serial read values are not equal" Tags="|serial|analogread|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6568" PostTypeId="1" AcceptedAnswerId="6580" CreationDate="2014-12-18T22:15:01.290" Score="2" ViewCount="438" Body="&lt;p&gt;When I've come back to Arduino programming after a spell doing other things, I keep forgetting that I last experimented with a different type of board and get a &quot;avrdude: stk500_getsync(): not in sync: resp=0x00&quot; error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have one sketch which will always be compiled and uploaded against a specific piece of hardware. Therefore, I would like to specify the board type and preferably COM port as well, in my sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can it be done?&lt;/p&gt;&#xA;" OwnerUserId="4672" LastActivityDate="2014-12-19T07:33:13.320" Title="Can I set the Arduino board type in code" Tags="|uploading|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6570" PostTypeId="1" AcceptedAnswerId="6583" CreationDate="2014-12-18T22:37:08.723" Score="3" ViewCount="668" Body="&lt;p&gt;I discovered that there are multiple types &amp;amp; versions of &lt;code&gt;ESP8266&lt;/code&gt; modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Build my application around one type (eg ESP-03) and in future swap the module with another (ESP-07), continuing to use the same library and code?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Given the lack of information online, I couldn't find an answer for this online.&lt;/p&gt;&#xA;" OwnerUserId="6249" LastEditorUserId="653" LastEditDate="2015-10-03T16:37:24.150" LastActivityDate="2015-10-03T16:37:24.150" Title="Is it possible to use ESP8266 modules interchangeably?" Tags="|wifi|esp8266|networking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6571" PostTypeId="1" AcceptedAnswerId="6575" CreationDate="2014-12-18T22:46:20.867" Score="0" ViewCount="55" Body="&lt;p&gt;I need to power an OpAmp based circuit that will be connected to my Arduino Uno input. Since I have a 12V adapter for the Arduino board, I want to draw power from it for this opamp(LM358).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know if there is any way I can do this from the Arduino board(pins?)is as opposed to having to solder wires directly to the bottom of the DC jack?&lt;/p&gt;&#xA;" OwnerUserId="6294" LastActivityDate="2014-12-19T01:18:33.947" Title="Is the supply voltage made available anywhere on the Arduino Uno Board?" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6572" PostTypeId="1" AcceptedAnswerId="6577" CreationDate="2014-12-19T01:12:34.610" Score="1" ViewCount="750" Body="&lt;p&gt;My Extech EX330 multimeter is reading 3.439Mhz on the pin 13 on my Arduino Uno running the following code. Is the reading correct? If the divider is 2, shouldn't I get 8 Mhz (16Mhz / 2)? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt; &#xA;void setup()&#xA;{&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  digitalWrite(13, HIGH);&#xA;  SPI.begin();&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV2);    &#xA;&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;  byte pot = B0;                &#xA;  SPI.transfer(pot);                        //  Do SPI transfer of variable pot&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6309" OwnerDisplayName="b1gtuna" LastActivityDate="2014-12-19T01:24:29.397" Title="What should the frequency reading of the SPI clock be with this code?" Tags="|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6573" PostTypeId="1" CreationDate="2014-12-19T01:12:27.200" Score="0" ViewCount="6694" Body="&lt;p&gt;Hi I'm new at this and can't figure out why I get this error &quot;void does not name a type&quot; on lines 3,5,8,26&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// _2-5 set Debounce Button&#xA;const int BUTTON=2;&#xA;const int LED=9;&#xA;boolean lastButton = LOW;&#xA;boolean currentButton = LOW;&#xA;boolean ledOn = false;&#xA;&#xA;Void setup()&#xA;{&#xA;  pinMode (LED, OUTPUT);&#xA;  pinMode (BUTTON, INPUT);&#xA;}&#xA;&#xA;boolean debounce(boolean last)&#xA;&#xA;{ &#xA;  boolean current = digitalRead(BUTTON);&#xA;  if (last != current)&#xA;  {&#xA;    delay(5);&#xA;    current = digitalRead(BUTTON);&#xA;  }&#xA;  return current;&#xA;}&#xA;&#xA;Void loop()&#xA;{&#xA;  currentButton = debounce(lastButton);&#xA;  if (lastButton == LOW &amp;amp;&amp;amp; currentButton == HIGH)&#xA;  {&#xA;    ledOn = !ledOn;&#xA;  } &#xA;&#xA;  lastButton = currentButton;&#xA;  digitalWrite(LED, ledOn);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="130green" LastEditorUserId="42" LastEditDate="2014-12-19T12:16:55.647" LastActivityDate="2014-12-19T12:16:55.647" Title="&quot;void does not name a type&quot;" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6574" PostTypeId="2" ParentId="6573" CreationDate="2014-12-19T01:14:34.843" Score="7" Body="&lt;p&gt;I thing the problem is not &quot;void does not name a type&quot;, but &quot;Void does not name a type&quot;.  Subtle difference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Void setup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Void loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Watch those caps - C is case sensitive.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-12-19T01:14:34.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6575" PostTypeId="2" ParentId="6571" CreationDate="2014-12-19T01:18:33.947" Score="2" Body="&lt;p&gt;The &lt;code&gt;Vin&lt;/code&gt; pin is available (next to &lt;code&gt;Gnd&lt;/code&gt;) pins.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-12-19T01:18:33.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6576" PostTypeId="2" ParentId="6572" CreationDate="2014-12-19T01:20:25.963" Score="1" Body="&lt;p&gt;No, because neither the allocation and assignment of &lt;code&gt;pot&lt;/code&gt; nor the call to &lt;code&gt;SPI.transfer()&lt;/code&gt; come for free. And the time taken by both slows the average frequency down to about the measured value.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-19T01:20:25.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6577" PostTypeId="2" ParentId="6572" CreationDate="2014-12-19T01:24:29.397" Score="4" Body="&lt;p&gt;Yes, the clock speed should be (and most probably is) 8 MHz.  However, you're not generating an 8 MHz clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are in fact generating is 8 clock pulses of 8 MHz, then you have a delay while it deals with the rest of your code, and then it generates another 8 clock cycles of 8MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The overall frequency is evidently sensed as 3.439 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To generate a pure 8 MHz clock you would have to use a different transfer method. I don't know if the 328P has DMA available, but if it does, that would give you much faster transfers.  Also, you could write a more non-blocking version of SPI.transfer().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal SPI.transfer() first starts the transfer, then waits for the transfer to finish, and returns the results of the transfer.  If you're only interested in transmitting, and not receiving, or the transmitted and received data don't need to c correlate completely, you can instead change the order of how it works:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Wait for there to be no transfer in operation&lt;/li&gt;&#xA;&lt;li&gt;Store the result of the last transfer&lt;/li&gt;&#xA;&lt;li&gt;Start the new transfer&lt;/li&gt;&#xA;&lt;li&gt;Return the results of the last transfer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That way it runs much smoother as it's doing the current transfer at the same time as running your other code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2014-12-19T01:24:29.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6578" PostTypeId="1" CreationDate="2014-12-19T05:37:45.463" Score="3" ViewCount="883" Body="&lt;p&gt;I want my YUN to act as a server in a client/server architecture so students can control their wifi robots via their desktops. I can plug the YUN directly into an ethernet port on our network and want to have robots communicate with it through a client/server architecture. Can somebody steer me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="6312" LastEditorUserId="213" LastEditDate="2015-03-20T14:47:29.933" LastActivityDate="2015-03-20T14:47:29.933" Title="Yun as a Conventional Wireless Access Point" Tags="|wifi|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6579" PostTypeId="2" ParentId="6568" CreationDate="2014-12-19T07:25:03.367" Score="0" Body="&lt;p&gt;Yes you could do this, but you won't get much support from the Arduino libraries. From what I have used, the board type is evaluated at library compile time.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you are willing to delve through the datasheets for all the boards you want to support, then writing a board-agnostic driver should not be impossible.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2014-12-19T07:25:03.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6580" PostTypeId="2" ParentId="6568" CreationDate="2014-12-19T07:33:13.320" Score="3" Body="&lt;p&gt;No, it cannot. Neither the compiler invocation nor the subsequent upload examine the code for the hardware in use, so there is no way of doing what you are asking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is to create entries in a new &lt;code&gt;boards.txt&lt;/code&gt; and &lt;code&gt;programmers.txt&lt;/code&gt; using an existing core that specify all the parameters, and all you would have to do is select them in the IDE for everything to be set at once. See &lt;a href=&quot;https://code.google.com/p/arduino/wiki/Platforms&quot; rel=&quot;nofollow&quot;&gt;Google Code/Arduino/Platforms&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-19T07:33:13.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6581" PostTypeId="2" ParentId="6578" CreationDate="2014-12-19T08:06:05.813" Score="1" Body="&lt;p&gt;Check out &lt;a href=&quot;https://github.com/Vadorequest/AAD1&quot; rel=&quot;nofollow&quot;&gt;this project&lt;/a&gt;, made by @Vadorequest the early days of the Yun: he hacked a car to control it via his smartphone. There's a &lt;a href=&quot;https://www.youtube.com/watch?v=amPQWXRpA-A&quot; rel=&quot;nofollow&quot;&gt;nice video&lt;/a&gt; on youtube.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2014-12-19T08:06:05.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6582" PostTypeId="2" ParentId="6553" CreationDate="2014-12-19T09:38:45.993" Score="4" Body="&lt;p&gt;The Chinese boards generally work just fine with the official Arduino IDE. One thing to be careful for though is the bootloader. Most the time the Chinese vendor had written a custom bootloader, which may make certain pins behave funny. e.g. a common thing is for pin 13 (the default LED) is permanently high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be very cautious ordering these boards though. Most if not all of these breech the terms of the open source license which Arduino is released under. Besides that, ordering these boards you are supporting the Chinese slave labour gone into manufacturing this board for extremely low prices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not purchase the official Arduino boards? Not only do you get quality boards, but you are also supporting the open source community, and ethically manufactured electronics.&lt;/p&gt;&#xA;" OwnerUserId="6290" LastEditorUserId="4628" LastEditDate="2017-11-07T04:35:37.163" LastActivityDate="2017-11-07T04:35:37.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6583" PostTypeId="2" ParentId="6570" CreationDate="2014-12-19T11:10:09.837" Score="4" Body="&lt;p&gt;yes they are interchangeable since they all use the same chip (esp 8266). However the pin outs of the different modules can (and will be) laid out different. So you have to watch out that your wires are connected to the correct pads on the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also mind that different esp8266 modules can be (stock) loaded with different firmware. If you are using the AT firmware in your current arduino project it can be necessary to flash your new esp8266 module with the same firmware. If you are not sure how to do this you might have a look to the &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;esp8266&lt;/a&gt; forum&lt;/p&gt;&#xA;" OwnerUserId="6314" LastEditorUserId="6314" LastEditDate="2014-12-19T11:15:27.983" LastActivityDate="2014-12-19T11:15:27.983" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6584" PostTypeId="1" CreationDate="2014-12-19T12:33:13.670" Score="3" ViewCount="732" Body="&lt;p&gt;I have a &lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Teensy&lt;/a&gt; board and would like to know if there's a way to get a serial number (or any other kind of ID that is preferably unique) of the &lt;strong&gt;host&lt;/strong&gt; controller that I plug my Teensy into. E.g. can I get any unique identification numbers of my Macbook's USB controller when I plug my Teensy into it? C/C++ code examples for Teensy would be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="4338" LastEditorUserId="4338" LastEditDate="2018-05-28T09:33:39.920" LastActivityDate="2022-01-17T08:02:25.280" Title="Get USB host controller serial number or ID using Teensy or other HID devices" Tags="|usb|teensy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6585" PostTypeId="2" ParentId="6567" CreationDate="2014-12-19T17:06:08.797" Score="2" Body="&lt;p&gt;Try something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // read the input on analog pin 0 and 1 with delays for stability:&#xA;  delay(1000);       &#xA;  int sensorValue1 = analogRead(A0);&#xA;  delay(1000);        &#xA;  int sensorValue2 = analogRead(A1);&#xA;&#xA;  // print out the value you read:&#xA;  Serial.print(&quot;val1 = &quot; );&#xA;  Serial.print(sensorValue1);&#xA;  Serial.print(&quot; val2 = &quot; );&#xA;  Serial.println(sensorValue2);&#xA;&#xA;&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3671" LastActivityDate="2014-12-19T17:06:08.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6586" PostTypeId="1" CreationDate="2014-12-19T17:48:08.570" Score="1" ViewCount="492" Body="&lt;p&gt;This may seem a little stupid, i apologize  if so as i'm new to electronics/arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 4, 4-pin ping sensors. I'm running out of available pins on my UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a ponder &amp;amp; wondered if it was possible to link all 4 sensor's trig pins to a single digital pin, with the echo pins assigned to their own pin. In my head, on each sensor call (sorry i'm used to programming terms) all 4 sensors would send a pulse, then only the sensor (or echo pin) in question would be read. Is that plausible? each ping sensor is about 20-30 cm separated, but facing internally, in a spiral downwards.&lt;/p&gt;&#xA;" OwnerUserId="6318" LastActivityDate="2016-12-19T20:01:21.023" Title="Ultrasonic PING: multiple trig on single dig. pin" Tags="|arduino-uno|sensors|pins|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6587" PostTypeId="1" AcceptedAnswerId="6588" CreationDate="2014-12-19T20:15:40.317" Score="1" ViewCount="150" Body="&lt;p&gt;im using arduino and im out of pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need something like a decoder but the problem is that the decoders only change one output pin I.E. for 0011 the output will be 0001000000000000 what i need is to have the first outputs on I.E for 1000 the output will be 111111111000000000 i basically need to light up to 16leds and im out of pins so i was wondering is there is any IC that does this for me if i have 1111 it will output 16 ones.&lt;/p&gt;&#xA;" OwnerUserId="6235" LastEditorUserId="83" LastEditDate="2015-01-15T18:32:33.907" LastActivityDate="2015-01-15T18:32:33.907" Title="4 bit to Decimal Converter IC" Tags="|arduino-mega|led|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6588" PostTypeId="2" ParentId="6587" CreationDate="2014-12-19T20:22:45.807" Score="6" Body="&lt;p&gt;You can use one (or more, daisy-chained) &lt;strong&gt;shift register&lt;/strong&gt; for that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will normally take you 3 pins and provide 8 outputs, or 8n where n is the number of chained shift registers still using only 3 Arduino pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example of a shift register that fits your situation is the &lt;strong&gt;74HC595&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino, you can use &lt;code&gt;shiftOut&lt;/code&gt; function to help handle those ICs.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-12-19T20:22:45.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6589" PostTypeId="2" ParentId="6587" CreationDate="2014-12-19T22:32:33.770" Score="2" Body="&lt;p&gt;You could use the MCP23017 an i2c 16 input/output port expander. (&lt;a href=&quot;http://www.adafruit.com/datasheets/mcp23017.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It allows you to control 16 I/O pins via a simple I2C interface (only 2 pins needed).  And an &lt;a href=&quot;https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library&quot; rel=&quot;nofollow&quot;&gt;Arduino library&lt;/a&gt; exists for it.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2014-12-19T22:32:33.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6590" PostTypeId="2" ParentId="6567" CreationDate="2014-12-19T23:10:20.143" Score="0" Body="&lt;p&gt;The problem here seems like you are writing the value with a println(), and then again the value without new line but space. Then you write value2 with an ending newline and again value2 without newline. In your output there is also a string that does not match up anywhere in the code you posted. Double check what you are uploading and check if it has error.&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="7924" LastEditDate="2015-03-16T20:01:09.913" LastActivityDate="2015-03-16T20:01:09.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6591" PostTypeId="1" AcceptedAnswerId="6605" CreationDate="2014-12-20T00:08:14.640" Score="0" ViewCount="98" Body="&lt;p&gt;Does anybody know if there is any documentation available online on basic information about using displays with Arduino Uno? I've never used displays before and would very much appreciate some basic information on the different types etc.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any information that can help me choose what display I want to buy for my next project will be helpful. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;for ex: Right now I don't even know what a shield is in context to a display and whether or not I should look for one in my purchasing my display.&lt;/p&gt;&#xA;" OwnerUserId="6294" LastActivityDate="2014-12-20T20:00:09.153" Title="Using displays with Arduino Uno" Tags="|arduino-uno|display|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6592" PostTypeId="2" ParentId="3680" CreationDate="2014-12-20T03:45:45.107" Score="3" Body="&lt;p&gt;I would have used a script to make an alias under &lt;code&gt;/dev/&lt;/code&gt; and also set group and rights on it with &lt;code&gt;udev&lt;/code&gt; like the other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I didn't have &lt;code&gt;udev&lt;/code&gt; I would pipe &lt;code&gt;lsusb&lt;/code&gt; into &lt;code&gt;grep&lt;/code&gt; or &lt;code&gt;awk&lt;/code&gt;, like &lt;code&gt;lsusb|grep -e &quot;idProduct&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, with &lt;code&gt;udev&lt;/code&gt; rules or with &lt;code&gt;lsusb&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; to identify USB devices, use &lt;code&gt;idVendor&lt;/code&gt;, &lt;code&gt;idProduct&lt;/code&gt; and &lt;code&gt;iSerial&lt;/code&gt; in &lt;code&gt;Device descriptor&lt;/code&gt; part of &lt;code&gt;lsusb&lt;/code&gt; to make the proper idenification.  The &lt;code&gt;idVendor&lt;/code&gt; tells you the manufaturer, &lt;code&gt;idProduct&lt;/code&gt; should indentify the product from the manufacturer but sometimes they use the same product id for more than one product.  Lastly, if needed, the &lt;code&gt;iSerial&lt;/code&gt; should be a unique id for each example of that product.&lt;/p&gt;&#xA;" OwnerUserId="6322" LastActivityDate="2014-12-20T03:45:45.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6593" PostTypeId="1" CreationDate="2014-12-20T04:45:43.080" Score="0" ViewCount="1626" Body="&lt;p&gt;I am playing with 3,5&quot; (400x240) TFT display which is placed into Arduino Mega 2560 R3 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My final &lt;em&gt;goal&lt;/em&gt; is taking .raw data from SD card and drawing it on display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; My &lt;strong&gt;drawing&lt;/strong&gt; method in the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void LoadImage(File&amp;amp; file)&#xA;{&#xA;    for (int y = 0; y &amp;lt; SCREEN_HEIGHT &amp;amp;&amp;amp; file.available(); y++) {&#xA;        uint16_t buf[SCREEN_WIDTH];&#xA;        for (int x = SCREEN_WIDTH - 1; x &amp;gt;= 0; x--) {&#xA;            byte l = file.read();&#xA;            byte h = file.read();&#xA;            buf[x] = ((uint16_t)h &amp;lt;&amp;lt; 8) | l;&#xA;        }&#xA;        myGLCD.drawPixelLine(0, y, SCREEN_WIDTH, buf);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; For reference &lt;strong&gt;drawPixelLine&lt;/strong&gt; method's implementation from UTFT library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void UTFT::drawPixelLine(int x, int y, int sx, uint16_t* data)&#xA;{&#xA;    unsigned int col;&#xA;    cbi(P_CS, B_CS);&#xA;    setXY(x, y, x+sx-1, y);&#xA;    for (int tc=0; tc&amp;lt;sx; tc++)&#xA;    {&#xA;        char* p = (char*)&amp;amp;data[tc];&#xA;        LCD_Write_DATA(*(p + 1), *p);&#xA;    }&#xA;    sbi(P_CS, B_CS);&#xA;}&#xA;void UTFT::setXY(word x1, word y1, word x2, word y2)&#xA;{&#xA;    if (orient==LANDSCAPE)&#xA;    {&#xA;        swap(word, x1, y1);&#xA;        swap(word, x2, y2)&#xA;        y1=disp_y_size-y1;&#xA;        y2=disp_y_size-y2;&#xA;        swap(word, y1, y2)&#xA;    }&#xA;        LCD_Write_COM(0x2a);&#xA;        LCD_Write_DATA(x1&amp;gt;&amp;gt;8);&#xA;        LCD_Write_DATA(x1);&#xA;        LCD_Write_DATA(x2&amp;gt;&amp;gt;8);&#xA;        LCD_Write_DATA(x2);&#xA;        LCD_Write_COM(0x2b);&#xA;        LCD_Write_DATA(y1&amp;gt;&amp;gt;8);&#xA;        LCD_Write_DATA(y1);&#xA;        LCD_Write_DATA(y2&amp;gt;&amp;gt;8);&#xA;        LCD_Write_DATA(y2);&#xA;        LCD_Write_COM(0x2c);                             &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My current rendering:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/V82Vh.jpg&quot; alt=&quot;current result&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Desired image:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iVXZg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;TFT Lcd and Mega Board&lt;/em&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/eAa2P.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran henningan test from utft library, drawing sin/cos graph and simple squares&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5bZe0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is attempt to render yellow square 100x100 raw data&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/F5k4J.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6323" LastEditorUserId="6323" LastEditDate="2014-12-20T16:47:58.537" LastActivityDate="2015-04-16T14:04:45.860" Title="Arduino LCD Display drawing image issue" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6596" PostTypeId="1" CreationDate="2014-12-20T06:48:50.447" Score="1" ViewCount="2848" Body="&lt;p&gt;So I am designing a simple project where my Arduino reads analog values from a potentiometer, or rotation sensor, as it is called on EBay, and uses that value to determine how many relays to close. I am connecting 4 digital pins to the relay module, and powering it with a constant digital signal from pin 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//set up the pins for activating each relay on the module&#xA;#define in1 13&#xA;#define in2 11&#xA;#define in3 10&#xA;#define in4 9&#xA;#define power 2      //set up the power pin for the module&#xA;&#xA;void setup(){&#xA; Serial.begin(9600);&#xA; pinMode(in1, OUTPUT);&#xA; pinMode(in2, OUTPUT);&#xA; pinMode(in3, OUTPUT);&#xA; pinMode(in4, OUTPUT);&#xA; pinMode(power, OUTPUT);&#xA; digitalWrite(power, HIGH);        //for power to the relay module&#xA;}&#xA;&#xA;void loop(){&#xA; float rotationValue = analogRead(A0);          //read raw value from potentiometer&#xA; float percentValue = rotationValue / 10.23;       //convert the value to 0%-100%&#xA; Serial.println(percentValue);                  //print it out on screen&#xA; if(percentValue &amp;gt;= 0.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 1.00){         //all relays off&#xA;  digitalWrite(in1, LOW);&#xA;  digitalWrite(in2, LOW);&#xA;  digitalWrite(in3, LOW);&#xA;  digitalWrite(in4, LOW); &#xA; }&#xA; else if(percentValue &amp;gt; 1.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 25.00){        //relay #1 on&#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, LOW);&#xA;  digitalWrite(in3, LOW);&#xA;  digitalWrite(in4, LOW); &#xA; }&#xA; else if(percentValue &amp;gt; 25.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 50.00){           //relay #1, #2 on&#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, HIGH);&#xA;  digitalWrite(in3, LOW);&#xA;  digitalWrite(in4, LOW); &#xA; }&#xA; else if(percentValue &amp;gt; 50.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 75.00){     //relay #1, #2, #3 on   &#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, HIGH);&#xA;  digitalWrite(in3, HIGH);&#xA;  digitalWrite(in4, LOW); &#xA; }&#xA; else if(percentValue &amp;gt; 75.00){             //all relays on&#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, HIGH);&#xA;  digitalWrite(in3, HIGH);&#xA;  digitalWrite(in4, HIGH); &#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok, here's the problematic part. After I upload the program onto the board, when I set the potentiometer to the 0 position, all relays are on. And when I twist it to the 100 position, which is maximum, all relays are off. Although it is usable, what's weird is that when I start from 100 and twist it back toward 0, the relays will activate, but in the opposite order. So relay #4 will activate, then #3, then #2, and then #1, and all four are on when I reach 0. Is it something wrong with my code? I've checked and rechecked, and even checked with a different project where I connect the pins to LED's. And they work normally. But when I connect up the relay module, it's reversed. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relay module: &lt;a href=&quot;http://www.miniinthebox.com/4-channel-relay-module-with-optocoupler-5v_p903429.html?currency=USD&amp;amp;litb_from=paid_adwords_shopping&amp;amp;gclid=Cj0KEQiAts-kBRCbgrXc1rnXw7MBEiQAnFqTdph_qI5n7rrpW7gZaxafVVkeWitQlN8FUSUJzdsV2JwaAlBA8P8HAQ&quot; rel=&quot;nofollow&quot;&gt;http://www.miniinthebox.com/4-channel-relay-module-with-optocoupler-5v_p903429.html?currency=USD&amp;amp;litb_from=paid_adwords_shopping&amp;amp;gclid=Cj0KEQiAts-kBRCbgrXc1rnXw7MBEiQAnFqTdph_qI5n7rrpW7gZaxafVVkeWitQlN8FUSUJzdsV2JwaAlBA8P8HAQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the potentiometer: &lt;a href=&quot;http://www.ebay.com/itm/Potentiometer-Sensor-module-Rotation-Angle-Sensor-Arduino-competible-/251656942542&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/Potentiometer-Sensor-module-Rotation-Angle-Sensor-Arduino-competible-/251656942542&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean, right now I'm even thinking that the relay module may be labeled incorrectly, that the numbers are printed the wrong way. But it could be my fault, most likely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2014-12-20T08:41:28.343" Title="4 channel relay module reversed? Or is it my code?" Tags="|arduino-uno|analogread|relay|potentiometer|digital|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6598" PostTypeId="2" ParentId="6596" CreationDate="2014-12-20T08:41:28.343" Score="3" Body="&lt;p&gt;All the relay boards I've come across are 'active low' i.e. as you've discovered bringing the control pin down to earth activates the relay. As an aside just be careful that the arduino has enough juice to power the relays, a separate supply is normally required if these are coil rather than ssr type relays&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2014-12-20T08:41:28.343" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6599" PostTypeId="2" ParentId="4668" CreationDate="2014-12-20T14:41:26.793" Score="2" Body="&lt;p&gt;The important thing to know for PROGMEM is that &lt;a href=&quot;https://en.wikipedia.org/wiki/ATmega328#Family&quot; rel=&quot;nofollow noreferrer&quot;&gt;the AVR chip&lt;/a&gt; you’re using does not have a single flat address space. I.e., it does not use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Von_Neumann_architecture&quot; rel=&quot;nofollow noreferrer&quot;&gt;von Neumann architecture&lt;/a&gt;; instead, it uses a specific version of what is known as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Harvard_architecture&quot; rel=&quot;nofollow noreferrer&quot;&gt;Harvard architecture&lt;/a&gt;: it has separate address spaces for RAM, program memory, and EEPROM. All of them start at 0. Which means that while dereferencing a null pointer is technically still undefined behavior in C++, it can be (and often is) perfectly valid in Arduino code.&lt;/p&gt;&#xA;&lt;p&gt;The short version is: If you have a PROGMEM pointer, whatever function you pass it to must work on PROGMEM pointers. &lt;code&gt;lcd.print&lt;/code&gt; does not, and as far as I can tell there isn't any way the function could possibly detect this is not a RAM pointer. You have to call a different function, assuming there is one in the first place.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;em&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow noreferrer&quot;&gt;PROGMEM&lt;/a&gt;&lt;/em&gt; (Arduino reference) for examples on how to use PROGMEM data.&lt;/p&gt;&#xA;" OwnerUserId="1323" LastEditorUserId="510" LastEditDate="2023-09-16T15:02:00.640" LastActivityDate="2023-09-16T15:02:00.640" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6600" PostTypeId="1" AcceptedAnswerId="6604" CreationDate="2014-12-20T16:59:23.877" Score="6" ViewCount="1753" Body="&lt;p&gt;&lt;em&gt;This may sound like a very dumb question and I apologise in advance.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've gone through reading about PWM and working on some example sketches to control PC fan speeds using PWM and Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all documents I read, it is mentioned that &quot;PWM is a signal&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is PWM &lt;strong&gt;really&lt;/strong&gt; a signal? To me, it looks like an electric current turned on and kept on for a certain time, then off for a while repeatedly. What makes this a &quot;signal&quot;?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If PWM is a signal, why do we need to connect the Ground from Arduino to the ground of the device to which &quot;PWM signal&quot; is being sent to?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is confusing me because in my mind, for example, radio signals do not need a ground connection. The signal comes and gets read.&lt;/p&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2019-05-06T20:40:54.023" Title="PWM signaling with Arduinos: What is the reason for the ground connection?" Tags="|arduino-uno|arduino-mega|pwm|current|signal-processing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6601" PostTypeId="1" AcceptedAnswerId="6678" CreationDate="2014-12-20T17:07:03.730" Score="1" ViewCount="1660" Body="&lt;p&gt;I have am using an Arduino Uno R2 and &lt;a href=&quot;http://playground.arduino.cc/Learning/TLC5940&quot; rel=&quot;nofollow&quot;&gt;TLC5940&lt;/a&gt; to control a bunch of RGB LEDs. I want to add an Ethernet Shield R3 so that I can control the LEDs over a web-interface. However, the ethernet shield and TLC5940 use many of the same pins. Can I use them together? How?&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-12-24T21:33:31.113" Title="Using an Ethernet Shield and a tlc5940 together" Tags="|arduino-uno|ethernet|tlc5940|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6602" PostTypeId="5" CreationDate="2014-12-20T17:15:10.093" Score="0" Body="&lt;p&gt;From the &lt;a href=&quot;http://playground.arduino.cc/Learning/TLC5940&quot; rel=&quot;nofollow&quot;&gt;Arduino website&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The TLC5940 is a 16 channel PWM unit with 12 bit duty cycle control (0 - 4095), 6 bit current limit control (0 - 63), and a daisy chainable serial interface. It is handy for expanding the number of PWM outputs available. The datasheet is available at &lt;a href=&quot;http://www.ti.com/lit/gpn/tlc5940&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/lit/gpn/tlc5940&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="33" LastEditorUserId="33" LastEditDate="2014-12-20T20:14:06.967" LastActivityDate="2014-12-20T20:14:06.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6603" PostTypeId="4" CreationDate="2014-12-20T17:15:10.093" Score="0" Body="The TLC5940 is a 16 channel PWM controller from Texas Instruments. It is useful for for expanding the number of PWM outputs available." OwnerUserId="33" LastEditorUserId="33" LastEditDate="2014-12-20T20:14:11.060" LastActivityDate="2014-12-20T20:14:11.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6604" PostTypeId="2" ParentId="6600" CreationDate="2014-12-20T18:52:33.290" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is PWM &lt;strong&gt;really&lt;/strong&gt; a signal? To me, it looks like an electric current turned on and kept on for a certain time, then off for a while repeatedly. What makes this a &quot;signal&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;At the most basic, it is a signal because we call it such. Even a constant voltage can be a signal, signalling that e.g. a window has not been broken. A PWM signal indicates that we want to apply a certain fraction of full power to a load.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If PWM is a signal, why do we need to connect the Ground from Arduino to the ground of the device to which &quot;PWM signal&quot; is being sent to?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because it is a voltage-based signal, and ground serves as the reference for this voltage. Voltage only exists &lt;em&gt;between&lt;/em&gt; two points.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is confusing me because in my mind, for example, radio signals do not need a ground connection. The signal comes and gets read.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Radio signals are photon-based; the oscillation of photons at a given frequency being broadcast from a location are what define the signal. Since frequencies are absolute, they can be discriminated without a (relative) reference.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-20T18:52:33.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6605" PostTypeId="2" ParentId="6591" CreationDate="2014-12-20T20:00:09.153" Score="1" Body="&lt;p&gt;The Arduino website has a &lt;a href=&quot;http://playground.arduino.cc/Code/LCD&quot; rel=&quot;nofollow&quot;&gt;list of LCD displays&lt;/a&gt; and link with more information about each one. For controlling the display you may want to look at Arduino's &lt;a href=&quot;http://www.arduino.cc/en/Reference/LiquidCrystal&quot; rel=&quot;nofollow&quot;&gt;LiquidCrystal Library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for a step by step guide for using a lcd display with the Arduino, there is a &lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-11-lcd-displays-1/&quot; rel=&quot;nofollow&quot;&gt;nice guide on Adafruit&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-12-20T20:00:09.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6606" PostTypeId="2" ParentId="6553" CreationDate="2014-12-20T22:42:30.507" Score="5" Body="&lt;p&gt;The Arduino creators have spelled out their position on clones in a fairly lucid &lt;a href=&quot;http://blog.arduino.cc/2013/07/10/send-in-the-clones/&quot; rel=&quot;nofollow&quot;&gt;blog post&lt;/a&gt; a few years ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your board comes pretty close to being a legitimate clone, but the claims about being manufactured in Italy are almost certainly false and possibly illegal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought a CH340G based board myself, and apart from needing to install a different driver, it's pretty close to the original (There are a few projects that reprogram the 16U2 on a real Arduino board, but the vast majority of projects use the 16U2 as a straight serial converter, and the CH340G seems to do that job OK).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As other answers have pointed out, clone makers don't contribute to the community, so consider buying a real board occasionally. On the other hand, Arduino Mega clones are literally 25% the price of the original, so for that board, going with a clone is certainly tempting.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-12-20T22:42:30.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6607" PostTypeId="1" AcceptedAnswerId="6608" CreationDate="2014-12-21T00:42:10.453" Score="6" ViewCount="385" Body="&lt;p&gt;I'm using an Uno to control NeoPixels LED strips (60 per metre). These are powered with a 5V DC supply. Now, when using USB to power the Arduino it works lovely. However I want to move the Arduino into a standalone &quot;installation&quot; where I'll only want one power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already got a 5V DC supply which outputs about 5.2V. What is the best way to power both the Arduino and the LEDs? I understand the need for at least 7V at the Arduino's voltage regulator input. Would my best bet be to get a 12V supply (or similar) and use a buck converter to power the LEDs? The total current draw &lt;em&gt;could&lt;/em&gt; reach 3.6A but will be 400mA for the majority of the time.&lt;/p&gt;&#xA;" OwnerUserId="6331" LastActivityDate="2014-12-21T03:08:42.113" Title="Powering 5V Accesories" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6608" PostTypeId="2" ParentId="6607" CreationDate="2014-12-21T03:08:42.113" Score="3" Body="&lt;p&gt;If your supply is regulated (put a 47ohm resistor across it and measure the AC voltage with a DMM; it should be almost nothing if properly regulated) then you can use it for both the Uno and the NeoPixels. The ATmega328P has a maximum input voltage of 5.5V, and the WS2812B has a maximum voltage of 5.3V, putting the supply within the proper range to run them.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-21T03:08:42.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6610" PostTypeId="2" ParentId="6553" CreationDate="2014-12-21T05:04:12.280" Score="1" Body="&lt;p&gt;You could buy an official board, but if you're worried about the price, I wouldn't go for the EBay ones. There are other better clones out there. For example, I know that SparkFun makes their own Arduino Uno board, and while it's not called the Uno, it works exactly like it's supposed to, without any surprises. From what I remember, it's cheaper than the official Uno too.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2014-12-21T05:04:12.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6613" PostTypeId="1" CreationDate="2014-12-21T08:35:53.457" Score="2" ViewCount="685" Body="&lt;p&gt;I'm trying to connect two BMP180s to an arduino uno by using a multiplexer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code that a guy has written before:&#xA;I imported SFE_BMP180 library but didn't do anything with the &quot;typedef.h&quot; thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm getting &quot;Data does not name a type&quot; error at the line 9.&#xA;How can  I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     #include &amp;lt;SFE_BMP180.h&amp;gt;&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &quot;typedef.h&quot;&#xA;&#xA;    #define SELECT_PIN 9&#xA;    #define ALTITUDE 510.0&#xA;&#xA;#define P1_ACTIVE digitalWrite(SELECT_PIN,HIGH); //delay(10);&#xA;#define P2_ACTIVE digitalWrite(SELECT_PIN,LOW);  //delay(10);&#xA;&#xA;SFE_BMP180 bmp1,bmp2;&#xA;boolean readSensors(Data *data1, Data *data2);&#xA;&#xA;Data newData(char id)&#xA;{&#xA;  Data d ; &#xA;  d._id = id ;&#xA;  return d ;&#xA;}&#xA;void setup()&#xA;{&#xA;    boolean failed = false ;&#xA;    pinMode(SELECT_PIN, OUTPUT);&#xA;&#xA;    Serial.begin(9600);&#xA;&#xA;    P1_ACTIVE&#xA;&#xA;    if(bmp1.begin()){&#xA;        Serial.println(&quot;BMP #1 init success.&quot;);&#xA;    }&#xA;    else &#xA;          failed = true ;&#xA;&#xA;&#xA;    P2_ACTIVE&#xA;    if(bmp2.begin()){&#xA;          Serial.println(&quot;BMP #2 init success.&quot;);&#xA;    }&#xA;    else &#xA;        failed = true ;&#xA;&#xA;    if(failed){&#xA;        Serial.println(&quot;Error in BMP180 init.&quot;);&#xA;        while (1);&#xA;    }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Data d1 = newData('1');&#xA;  Data d2 = newData('2');&#xA;&#xA;  boolean read = readSensors(&amp;amp;d1,&amp;amp;d2);&#xA;&#xA;&#xA;  if(read){&#xA;          /* print the value to serial terminal */&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4826" LastActivityDate="2015-04-22T22:31:17.613" Title="Connecting two pressure sensors with one uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6614" PostTypeId="1" AcceptedAnswerId="6615" CreationDate="2014-12-21T08:41:53.130" Score="0" ViewCount="230" Body="&lt;p&gt;I tried to run a sketch that tests my AVR's interrupts,&#xA;I have an UNoriginal Arduino Uno, and I've checked pins 2 and 3 like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- at void setup()&#xA;attachInterrupt(2, inter, CHANGE);&#xA;- at void inter()&#xA;Serial.println(&quot;Interrupt pin 2&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did the same on pin 3, I checked them by attaching the pins to a button with a Pull-Up,&#xA;When I click the button it goes from HIGH to LOW.&#xA;But yet, the arduino doesn't run the 'inter'.&#xA;Is it possible that because my Arduino is not original it won't work?&#xA;And this type of interrupts are software not hardware right?&lt;/p&gt;&#xA;" OwnerUserId="6201" LastActivityDate="2014-12-29T05:51:16.007" Title="Interrupts don't work" Tags="|c++|sketch|interrupt|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6615" PostTypeId="2" ParentId="6614" CreationDate="2014-12-21T09:01:30.630" Score="2" Body="&lt;p&gt;On all Arduino boards except the DUE, &lt;code&gt;attachInterrupt()&lt;/code&gt; does not use the pin number as first argument but the interrupt number, which is different:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void attachInterrupt(uint8_t interrupt, void (*ISR)(void), int mode);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As documented on &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;Arduino reference&lt;/a&gt;, for an Arduino UNO, the mapping is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Interrupt 0 -&gt; Pin 2&lt;/li&gt;&#xA;&lt;li&gt;Interrupt 1 -&gt; Pin 3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So just change the code in &lt;code&gt;setup()&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, inter, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that should work for pin 2.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-12-29T05:51:16.007" LastActivityDate="2014-12-29T05:51:16.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6616" PostTypeId="2" ParentId="6601" CreationDate="2014-12-21T11:16:26.817" Score="0" Body="&lt;p&gt;When using multiple SPI devices the normal way to have them share a bus is to assign them distinct slave select lines. The problem here is that although the '5940 libraries use SPI to send data to it, the '5940 is not actually a proper SPI device and so lacks any sort of slave select line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All is not lost, however. Since the '5940 responds only to SCLK (and GSCLK of course, but you should be running that one separately) all you need to do is inhibit it while nSS for the Ethernet module is active. This can be done with just a little bit of external circuitry. Since nSS must be high in order for the Ethernet module to be inactive, we can AND SCK with nSS to derive SCLK from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a 74HC08 for this would work, although it leaves 3 of the gates unused. A 74HC02 will let you do it with no wasted gates, but with a slightly higher propagation delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course, the requirement to clock in the grayscale data before the grayscale cycle completes is still there; properly interleaving this with the Ethernet communications is left as an exercise for the reader.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-21T11:16:26.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6617" PostTypeId="1" AcceptedAnswerId="31958" CreationDate="2014-12-21T12:22:13.607" Score="10" ViewCount="18611" Body="&lt;p&gt;Reading &lt;a href=&quot;http://playground.arduino.cc/Linux/Udev&quot; rel=&quot;noreferrer&quot;&gt;http://playground.arduino.cc/Linux/Udev&lt;/a&gt; there appears to be a way to write out to a FTDI USB-Serial EEPROM to set a given SerialNumber, allowing you to identify a given nano/other arduino to handle it specifically in UDEV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a nano-style boad with a QinHeng Electronics HL-340 USB-Serial adapter, which clearly isn't an FTDI chip, and the FTDI programmer therefore doesn't work. Does anyone know of an alternative utility/where I can find information to do the same with this chip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently the device identifies itself with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 6850.608080] usb 2-1.2: new full-speed USB device number 7 using ehci-pci&#xA;[ 6850.701496] usb 2-1.2: New USB device found, idVendor=1a86, idProduct=7523&#xA;[ 6850.701505] usb 2-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0&#xA;[ 6850.701510] usb 2-1.2: Product: USB2.0-Serial&#xA;[ 6850.702201] ch341 2-1.2:1.0: ch341-uart converter detected&#xA;[ 6850.704210] usb 2-1.2: ch341-uart converter now attached to ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is essentially useless, as I can't identify the given board attached (when I attach two, their details are the same).&lt;/p&gt;&#xA;" OwnerUserId="6337" LastEditorUserId="653" LastEditDate="2016-03-21T11:38:29.670" LastActivityDate="2021-12-28T14:32:19.350" Title="Setting serial number on CH340 USB-Serial device" Tags="|arduino-nano|ch340|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6618" PostTypeId="1" AcceptedAnswerId="6620" CreationDate="2014-12-21T17:55:19.963" Score="10" ViewCount="5715" Body="&lt;p&gt;I've been reading a bit about moving from Arduino to PCB and it seems a bit daunting. For now, all I really want to do is take something I've built, and make a few changes so that I can actually create a casing for it and make sure everything stays connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached a photo of my project. What I am trying to do is create a box, where 4 pushbuttons sit in a box, with LEDs next to them. I will probably create foamboard cutouts for the spaces where the pushbuttons and leds sit. The wiring for the push buttons and the LEDs need to be hidden below the foam board, along with the arduino itself and the servo motor - which is where I get stuck. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to do to essentially &quot;lengthen&quot; the wires for the pushbuttons and LEDs, and make sure all the components stay secure in the breadboard (the push buttons in particular like to pop out)? Is there a way to do this without making a PCB? I understand the concept of soldering components into protoboard, but as far as cutting / printing the circuits or whatever, it is really confusing to me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any guidance. If you see anything wrong with my wiring setup too, I'd love a learning experience on that as well. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zuw5E.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZfWWo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6341" LastActivityDate="2014-12-23T20:47:40.490" Title="How to move from arduino to physical prototype" Tags="|arduino-uno|sensors|wires|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6619" PostTypeId="2" ParentId="6618" CreationDate="2014-12-21T19:48:17.960" Score="3" Body="&lt;p&gt;Using a &lt;strong&gt;stripboard&lt;/strong&gt; is perfectly convenient to create a circuit that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;will last longer than a breadboard prototype&lt;/li&gt;&#xA;&lt;li&gt;will cost less than wasting a breadboard for a long time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Stripboards can be found in any good electronics retailer (I buy mines at Conrad).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need a soldering iron (and the skills that are needed for it, but that is not so difficult as some people think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even go one step further and create an Arduino on the same stripboard (many components from the UNO are not required for a circuit you want to build and keep &quot;forever&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, just a little bit more expensive, would consist in affording a &lt;strong&gt;prototype shield&lt;/strong&gt; for Arduino, solder you circuit onto it and directly plug it onto your Arduino. The principles are the same as for a stripboard, except the prototype are has typically no strip, only holes on which you can solder components and wires.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-12-21T19:48:17.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6620" PostTypeId="2" ParentId="6618" CreationDate="2014-12-21T19:49:20.850" Score="10" Body="&lt;p&gt;The best thing to do is, of course, to use a PCB. But it doesn't need to be a custom PCB; there are plenty of pre-made PCBs that are usable for approximately 98% of designs. Here are just a few:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/products/591&quot;&gt;Adafruit Perma-Proto boards&lt;/a&gt; are connected just like breadboards, so direct transfer is possible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://busboard.com/prototypingboards&quot;&gt;BusBoard proto boards&lt;/a&gt; come in a &lt;em&gt;ridiculous&lt;/em&gt; variety of configurations, including &lt;a href=&quot;http://busboard.com/enclosures#kits&quot;&gt;enclosure kits&lt;/a&gt;, and they even have SMD boards if you're up to it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For switches just use a panel mount form. They come in everything from &lt;a href=&quot;https://www.sparkfun.com/products/11996&quot;&gt;simple&lt;/a&gt; to &lt;a href=&quot;https://www.sparkfun.com/products/9341&quot;&gt;robust&lt;/a&gt; to &lt;a href=&quot;https://www.sparkfun.com/products/11970&quot;&gt;ridiculous&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDs can also be &lt;a href=&quot;https://www.sparkfun.com/products/11147&quot;&gt;panel mount&lt;/a&gt;, or you can use a &lt;a href=&quot;https://www.sparkfun.com/products/10691&quot;&gt;light pipe&lt;/a&gt; to make a LED on the PCB visible from the outside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For power you can use a USB connection or a separate power jack with a voltage regulator. If you also need a serial connection then you should consider a pre-made serial module, and either use its built-in USB jack or a separate panel mount USB jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo can be mounted inside the case if appropriate, or can be connected to a PCB mount or panel mount connector instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally the MCU itself should also be placed in a socket directly on the PCB. &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf&quot;&gt;Don't forget the decoupling, the oscillator, and the ISP connector.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the circuit itself, you can get rid of the pullup resistors on the switches if you use internal pullups instead. And 100ohm is &lt;em&gt;way&lt;/em&gt; too low a value for switch pullups regardless.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-21T19:49:20.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6621" PostTypeId="1" CreationDate="2014-12-22T00:47:50.270" Score="0" ViewCount="585" Body="&lt;p&gt;For the past couple of weeks, I have not been able to find a solution to my problem.  My problem is that I cannot retrieve the data from my homemade ECG that I created from Arduino.  I am a total amateur at this, but I'm pretty sure it's a circuitry issue.  Here is what my circuit looks like now.  (Note: the thing that says 'Dual O' on the far left is the instrumentation amplifier, not an operational amplifier like the one near the middle)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int  signal = 5;    // Pin connected to the filtered signal from the circuit&#xA;unsigned long currentBeatTime;   &#xA;unsigned long previousBeatTime;&#xA;&#xA;unsigned long frequency;&#xA;&#xA;// Internal variables&#xA;unsigned long period = 0;&#xA;int input = 0;&#xA;int lastinput = 0;&#xA;&#xA;&#xA;void setup() {&#xA;pinMode(signal, INPUT);&#xA;Serial.begin(9600);&#xA;&#xA;previousBeatTime = millis();&#xA;}&#xA;&#xA;void loop() {&#xA;delay(500);&#xA;input = digitalRead(signal);&#xA;&#xA;if ((input != lastinput) &amp;amp;&amp;amp; (input == HIGH)) {&#xA;    // If the pin state has just changed from low to high (edge detector)&#xA;    currentBeatTime = millis();&#xA;&#xA;    period = currentBeatTime - previousBeatTime; // Compute the time between the previous beat and the one that has just been detected&#xA;    previousBeatTime = currentBeatTime; // Define the new time reference for the next period computing&#xA;}&#xA;&#xA;lastinput = input; // Save the current pin state for comparison at the next loop iteration&#xA;&#xA;// Detect if there is no beat after more than 2 seconds&#xA;if ( (millis() - previousBeatTime) &amp;gt; 2000 ) &#xA;{ &#xA;    Serial.println(&quot;dead&quot;);&#xA;}&#xA;else &#xA;{&#xA;    if (period &amp;lt;= 0) &#xA;    {&#xA;        frequency = 0;&#xA;    }&#xA;    else &#xA;    {&#xA;        frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds&#xA;    }&#xA;&#xA;    Serial.print(frequency);&#xA;    Serial.println(&quot; : alive! &quot;);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would appreciate if someone could get back to me as soon as possible.  Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Here's a schematic.  I used Fritzing, and since I am a total beginner at this, it looks like a complete mess.  Anyways, here it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dhuXF.jpg&quot; alt=&quot;2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="4941" LastEditorUserId="13432" LastEditDate="2018-12-26T15:53:05.800" LastActivityDate="2018-12-26T15:53:05.800" Title="Cannot retrieve data from homemade ECG" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="6623" PostTypeId="1" AcceptedAnswerId="6624" CreationDate="2014-12-22T13:26:28.287" Score="0" ViewCount="1954" Body="&lt;p&gt;Sorry I'm new to electronics while I've some experience in coding. This let me very curious about the Arduino Due board: it is super powerful and I can run some C++ code that I can not with the normal Arduino Uno. But I lack in electronic theory, sorry if the question is a little bit dumb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I drive &lt;a href=&quot;http://www.ebay.com/itm/8-Channel-5V-Relay-Module-Board-Shield-for-Arduino-PIC-AVR-MCU-DSP-ARM-US-Stock-/360717697832&quot; rel=&quot;nofollow&quot;&gt;this shield&lt;/a&gt; with an Arduino Due? The Due board is at 3.3V while &lt;a href=&quot;https://www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf&quot; rel=&quot;nofollow&quot;&gt;the relays&lt;/a&gt; in the shield are at 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to make them run smoothly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually I'd like to run 5 of those shield with only one Arduino Due board. Do I have some problem with power supply?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2014-12-22T13:45:29.607" LastActivityDate="2014-12-22T15:01:14.043" Title="Can I drive this relay shield with an Arduino Due?" Tags="|shields|arduino-due|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6624" PostTypeId="2" ParentId="6623" CreationDate="2014-12-22T15:01:14.043" Score="1" Body="&lt;p&gt;You'd have to remove the yellow jumper. Connect 3.3v to the VCC and 5v to the JDVCC. But please double check that JDVCC is connected to one side of all the relays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way the opto-couplers are activated by 3.3v signals, which in turn activate the transistor (5v) used to engage the relay.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-22T15:01:14.043" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6627" PostTypeId="1" CreationDate="2014-12-22T19:25:24.353" Score="1" ViewCount="258" Body="&lt;p&gt;I have this code, which I am using with a potentiometer to control the speed of a automotive fuel injector. In it, I have specified how long the injector shall stay open by using the delay functions. However, whenever the code runs into a delay call, it pauses the whole code for that amount of time. Although it's not significantly long, it would still be better if it could keeping running analogInput and at the same time run through the if statements, without any interference from either. So basically run two different process simultaneously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remember reading somewhere that this is possible with threading? But do you need a library for that? I know Python has a threading library built in, and you can actually use it pretty easily, but what about Arduino? How could I run these two process at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define in1 12&#xA;&#xA;void setup(){&#xA; Serial.begin(9600);&#xA; pinMode(in1, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA; float rotationValue = analogRead(A1);            //read raw input from potentiometer&#xA; float percentValue = rotationValue / 10.23;      //convert to percent 0-100&#xA; Serial.println(percentValue);                    //print it to screen&#xA; if(percentValue &amp;gt;= 0.0 &amp;amp;&amp;amp; percentValue &amp;lt;= 1.0){&#xA;  digitalWrite(in1, LOW);                         //injector 1 off&#xA; }&#xA; else if(percentValue &amp;gt; 1.0 &amp;amp;&amp;amp; percentValue &amp;lt;= 25.00){    //cycle at 100 millisec.&#xA;  digitalWrite(in1, HIGH);&#xA;  delay(100);&#xA;  digitalWrite(in1, LOW);&#xA;  delay(100); &#xA; }&#xA; else if(percentValue &amp;gt; 25.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 50.00){    //cycle at 50 millis.&#xA;  digitalWrite(in1, HIGH);&#xA;  delay(50);&#xA;  digitalWrite(in1, LOW);&#xA;  delay(50);&#xA; }&#xA; else if(percentValue &amp;gt; 50.00 &amp;amp;&amp;amp; percentValue &amp;lt;= 75.00){      //cycle at 25 millis.&#xA;  digitalWrite(in1, HIGH);&#xA;  delay(25);&#xA;  digitalWrite(in1, LOW);&#xA;  delay(25);&#xA; }&#xA; else{              //cycle at 10 millis.&#xA;  digitalWrite(in1, HIGH);&#xA;  delay(10);&#xA;  digitalWrite(in1, LOW);&#xA;  delay(10);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2014-12-25T04:29:19.863" Title="How to avoid the code interrupting itself?" Tags="|arduino-uno|programming|analogread|threads|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6629" PostTypeId="1" CreationDate="2014-12-22T21:40:42.110" Score="0" ViewCount="321" Body="&lt;p&gt;I am trying to control an Arduino Leonardo R3 to run some code when &quot;triggered&quot; from a Raspberry Pi. This would be in a loop so that it can be run multiple times. I have set up the Raspberry Pi and tested it with an LED and the output is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then connected this to the Arduino and checked for a HIGH input from the RPi using an if statement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(7,INPUT);&#xA;  if(digitalRead(7)==HIGH) {&#xA;    // CODE IN HERE&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found that this did not work as the if statement was always true because of pullup resistors not being used. I would greatly appreciate some guidance on this.&lt;/p&gt;&#xA;" OwnerUserId="6353" LastEditorUserId="4628" LastEditDate="2017-01-07T11:22:20.103" LastActivityDate="2017-01-07T11:24:37.507" Title="Controlling Arduino from Raspberry Pi" Tags="|programming|pins|arduino-leonardo|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="6630" PostTypeId="2" ParentId="6618" CreationDate="2014-12-22T22:04:45.097" Score="4" Body="&lt;p&gt;Learning to design a PCB can be a challenge. First, there's software choices, there's file formats, and then actually laying out a good board. That's before production and assembly, each with its own struggles along the way. It's no different than the first time you open Xcode and learn about Storyboards and Frameworks and Simulators and all that, or for that matter, learning any new skill, which at first is a daunting experience but through both setbacks and success eventually becomes easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I agree with everyone that suggests perfboards and variants. But I also want to show, as perhaps motivation, where you could be in a few months. I tend to see Arduinos as the development tool, not the final product, but I understand others are content to just use a standalone Nano or Pro Mini and forever dedicate it to their project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are three variants of the same device, it combines an Arduino/ATMega, a GPS, a serial port, and an RGB LCD. I first created it in on a breadboard, then moved to a perfboard, thought &quot;that is ugly&quot; and made a simple PCB. Pleased with that experience, I kept refining the schematic and layout until I finally called the project &quot;done.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L9tFI.jpg&quot; alt=&quot;perfboard project&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ccGK8.jpg&quot; alt=&quot;primitive PCB&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wUeOj.jpg&quot; alt=&quot;Final PCB&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also might consider making tiny PCBs just for specific components, like these two boards I make for buttons and lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nAmXO.jpg&quot; alt=&quot;hardware switch denouncer and LED breakout boards&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The very first PCB I ordered from OSHPark was an amazing experience, opening the envelope and holding it like some religious relic. But since then it's become routine. If you do later go the PCB route, you might appreciate &lt;a href=&quot;http://www.ardueasy.com/2014/11/manufacturing-printed-circuit-board.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;my summary&lt;/a&gt; of low-volume shops I've ordered from.&lt;/p&gt;&#xA;" OwnerUserId="4969" LastActivityDate="2014-12-22T22:04:45.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6631" PostTypeId="1" CreationDate="2014-12-22T22:45:12.397" Score="5" ViewCount="2587" Body="&lt;p&gt;I was unable to find this question anywhere but I want to use my Arduino Uno to capture the output of a Code 39 signal coming out of a separate device. Currently, my setup is similar to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0oF2Q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://us.allegion.com/Products/biometrics/handkey2/Pages/default.aspx&quot; rel=&quot;noreferrer&quot;&gt;biometric hand reader&lt;/a&gt; that outputs a Code 39 signal along D1 while D0 stays at a constant 0 which can be seen here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7tRb3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately, I want to use the Arduino Uno to take the input from the data line and convert the Code 39 signal to ASCII. The process should functions like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;User enters their code into the hand reader and hand reader measures their hand&lt;/li&gt;&#xA;&lt;li&gt;Reader &lt;em&gt;outputs&lt;/em&gt; Code 39 signal to Arduino and software on Arduino converts barcode format to ASCII.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Note: I believe the Code 39 signal will represent something similar to this &lt;code&gt;*12345*&lt;/code&gt;. The user ID code will &lt;strong&gt;always&lt;/strong&gt; be five digits. &lt;code&gt;*&lt;/code&gt; represent the start and stop characters for Code 39 barcode format&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino sends ASCII code to computer which checks remote database to ensure user is valid&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have my correct pins set as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define D1 3&#xA;#define D0 2&#xA;&#xA;void setup() {&#xA;    pinMode(D1, INPUT);&#xA;    pinMode(D0, INPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to either print out the binary representation of the signal via the Serial console or write to a file that I can view later on? My idea is to use the &lt;code&gt;loop&lt;/code&gt; function to listen for the signals via &lt;code&gt;digitalRead()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    digitalRead(D1);&#xA;    digitalRead(D0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last part is the thing I'm having an issue with since I can't seem to get the information printed to the serial console or written to a file. I tried this but it didn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    foo();&#xA;}&#xA;&#xA;void foo() {&#xA;    digitalRead(D1) == HIGH ? Serial.print(&quot;0&quot;) : Serial.print(&quot;1&quot;);&#xA;    Serial.println(&quot;&quot;);&#xA;    digitalRead(D0) == HIGH ? Serial.print(&quot;0&quot;) : Serial.print(&quot;1&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to make this happen or is it impossible? I want to see the output of device so I can verify it's outputting what I think it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, I am using Visual Studio with the Visual Micro plugin so I can attempt to debug my code. I also have a OS X machine that has the Arduino IDE installed on it if I need a Mac for anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Addendum:&lt;/strong&gt; I don't have ready access to an oscilloscope. However, I have tested this device on an oscilloscope and I did have output that seemed all wrong. I want to see what the arduino says it is to verify things before I continue with this project.&lt;/p&gt;&#xA;" OwnerUserId="6354" LastEditorUserId="6354" LastEditDate="2014-12-23T05:31:34.660" LastActivityDate="2014-12-30T20:15:19.703" Title="Capture output from external device using Arduino Uno" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6632" PostTypeId="1" CreationDate="2014-12-22T22:57:34.243" Score="1" ViewCount="1195" Body="&lt;p&gt;So I am using this code here and I do get text written on my LCD screen. Problem is that text is almost invisible. I tried with background light on or off and it did not help. LCD is connected to 5v and backlight is connected to 3.3V. Backlight is connected through potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to control text contrast? To have more contrast?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PIN_SCE   7&#xA;#define PIN_RESET 6&#xA;#define PIN_DC    5&#xA;#define PIN_SDIN  4&#xA;#define PIN_SCLK  3&#xA;&#xA;#define LCD_C     LOW&#xA;#define LCD_D     HIGH&#xA;&#xA;#define LCD_X     84&#xA;#define LCD_Y     48&#xA;&#xA;static const byte ASCII[][5] =&#xA;{&#xA; {0x00, 0x00, 0x00, 0x00, 0x00} // 20  &#xA;,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 !&#xA;,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 &quot;&#xA;,{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 #&#xA;,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $&#xA;,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 %&#xA;,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 &amp;amp;&#xA;,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 '&#xA;,{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 (&#xA;,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 )&#xA;,{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a *&#xA;,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b +&#xA;,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c ,&#xA;,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d -&#xA;,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e .&#xA;,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f /&#xA;,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0&#xA;,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1&#xA;,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2&#xA;,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3&#xA;,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4&#xA;,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5&#xA;,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6&#xA;,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7&#xA;,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8&#xA;,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9&#xA;,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a :&#xA;,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ;&#xA;,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c &amp;lt;&#xA;,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d =&#xA;,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e &amp;gt;&#xA;,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ?&#xA;,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @&#xA;,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A&#xA;,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B&#xA;,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C&#xA;,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D&#xA;,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E&#xA;,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F&#xA;,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G&#xA;,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H&#xA;,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I&#xA;,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J&#xA;,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K&#xA;,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L&#xA;,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M&#xA;,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N&#xA;,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O&#xA;,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P&#xA;,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q&#xA;,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R&#xA;,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S&#xA;,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T&#xA;,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U&#xA;,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V&#xA;,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W&#xA;,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X&#xA;,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y&#xA;,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z&#xA;,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [&#xA;,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥&#xA;,{0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ]&#xA;,{0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^&#xA;,{0x40, 0x40, 0x40, 0x40, 0x40} // 5f _&#xA;,{0x00, 0x01, 0x02, 0x04, 0x00} // 60 `&#xA;,{0x20, 0x54, 0x54, 0x54, 0x78} // 61 a&#xA;,{0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b&#xA;,{0x38, 0x44, 0x44, 0x44, 0x20} // 63 c&#xA;,{0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d&#xA;,{0x38, 0x54, 0x54, 0x54, 0x18} // 65 e&#xA;,{0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f&#xA;,{0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g&#xA;,{0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h&#xA;,{0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i&#xA;,{0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j &#xA;,{0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k&#xA;,{0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l&#xA;,{0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m&#xA;,{0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n&#xA;,{0x38, 0x44, 0x44, 0x44, 0x38} // 6f o&#xA;,{0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p&#xA;,{0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q&#xA;,{0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r&#xA;,{0x48, 0x54, 0x54, 0x54, 0x20} // 73 s&#xA;,{0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t&#xA;,{0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u&#xA;,{0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v&#xA;,{0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w&#xA;,{0x44, 0x28, 0x10, 0x28, 0x44} // 78 x&#xA;,{0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y&#xA;,{0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z&#xA;,{0x00, 0x08, 0x36, 0x41, 0x00} // 7b {&#xA;,{0x00, 0x00, 0x7f, 0x00, 0x00} // 7c |&#xA;,{0x00, 0x41, 0x36, 0x08, 0x00} // 7d }&#xA;,{0x10, 0x08, 0x08, 0x10, 0x08} // 7e ←&#xA;,{0x78, 0x46, 0x41, 0x46, 0x78} // 7f →&#xA;};&#xA;&#xA;void LcdCharacter(char character)&#xA;{&#xA;  LcdWrite(LCD_D, 0x00);&#xA;  for (int index = 0; index &amp;lt; 5; index++)&#xA;  {&#xA;    LcdWrite(LCD_D, ASCII[character - 0x20][index]);&#xA;  }&#xA;  LcdWrite(LCD_D, 0x00);&#xA;}&#xA;&#xA;void LcdClear(void)&#xA;{&#xA;  for (int index = 0; index &amp;lt; LCD_X * LCD_Y / 8; index++)&#xA;  {&#xA;    LcdWrite(LCD_D, 0x00);&#xA;  }&#xA;}&#xA;&#xA;void LcdInitialise(void)&#xA;{&#xA;  pinMode(PIN_SCE, OUTPUT);&#xA;  pinMode(PIN_RESET, OUTPUT);&#xA;  pinMode(PIN_DC, OUTPUT);&#xA;  pinMode(PIN_SDIN, OUTPUT);&#xA;  pinMode(PIN_SCLK, OUTPUT);&#xA;  digitalWrite(PIN_RESET, LOW);&#xA;  digitalWrite(PIN_RESET, HIGH);&#xA;  LcdWrite(LCD_C, 0x21 );  // LCD Extended Commands.&#xA;  LcdWrite(LCD_C, 0xB1 );  // Set LCD Vop (Contrast). &#xA;  LcdWrite(LCD_C, 0x04 );  // Set Temp coefficent. //0x04&#xA;  LcdWrite(LCD_C, 0x14 );  // LCD bias mode 1:48. //0x13&#xA;  LcdWrite(LCD_C, 0x20 );  // LCD Basic Commands&#xA;  LcdWrite(LCD_C, 0x0C );  // LCD in normal mode.&#xA;}&#xA;&#xA;void LcdString(char *characters)&#xA;{&#xA;  while (*characters)&#xA;  {&#xA;    LcdCharacter(*characters++);&#xA;  }&#xA;}&#xA;&#xA;void LcdWrite(byte dc, byte data)&#xA;{&#xA;  digitalWrite(PIN_DC, dc);&#xA;  digitalWrite(PIN_SCE, LOW);&#xA;  shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);&#xA;  digitalWrite(PIN_SCE, HIGH);&#xA;}&#xA;&#xA;void setup(void)&#xA;{&#xA;  LcdInitialise();&#xA;  LcdClear();&#xA;  LcdString(&quot;Hello World!&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6355" LastActivityDate="2018-12-02T21:19:35.887" Title="Determining contrast on LCD" Tags="|arduino-uno|lcd|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6633" PostTypeId="1" CreationDate="2014-12-22T23:45:22.943" Score="0" ViewCount="1040" Body="&lt;p&gt;I am moving my Arduino project to another platform, operating at 3.3V. (5V from USB not useable due to some 3.3V-only chips in the design) Having read about this it seems that 12MHz is a good speed to use, and my stock USB to UART converter, CH340G does call for a 12MHz crystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what is the best way to share this 12MHz clock between CH340 and ATmega328P, eliminating an extra crystal? Can I tap off XO pin from CH340 with crystal attached, and carry it to the XTAL1 pin of the ATmega?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If sharing clock requires some fine tuning, what about building a reference clock out of &lt;code&gt;74LVC1G04&lt;/code&gt; and &lt;code&gt;74LVC1G06&lt;/code&gt; chips and clock both chips from this?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastEditorUserId="4775" LastEditDate="2014-12-23T15:09:05.373" LastActivityDate="2014-12-23T15:09:05.373" Title="ATmega328P and other chip sharing clock" Tags="|oscillator-clock|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6634" PostTypeId="1" CreationDate="2014-12-23T01:19:34.760" Score="1" ViewCount="7349" Body="&lt;p&gt;When I use the Mega 2560 additional serial ports, I realize that it is active low, active high. I know that TTL is active high and the serial port is obviously stated in arduino serial port page.&#xA;I also found out that the receive pin flashed (put an LED) when I typed in to the serial monitor. Is this a mistake or problem? &lt;/p&gt;&#xA;" OwnerUserId="4463" LastActivityDate="2015-03-23T16:05:52.993" Title="Serial: active low or active high?" Tags="|serial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6635" PostTypeId="1" CreationDate="2014-12-22T20:56:16.430" Score="1" ViewCount="55" Body="&lt;p&gt;I am trying to simply send a digital output from the Raspberry Pi to trigger some code on an Arduino. I have setup the Pi with the digital output working fine (tested using LED) however, I cant seem to get the Arduino (Leonardo) to read this output. I mean, all the details about the Pull Up resistor and logic having to be low to be high is confusing me and I really dont want to use any other electronic components (ie transistors or switches, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way of just reading the output and triggering the code on the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="6353" OwnerDisplayName="Rahul Khosla" LastActivityDate="2014-12-23T02:32:54.183" Title="Controlling Arduino from Raspberry Pi" Tags="|programming|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2014-12-30T10:43:38.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="6636" PostTypeId="2" ParentId="6629" CreationDate="2014-12-22T21:04:56.380" Score="2" Body="&lt;p&gt;You have to verify, at least: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A. if the 3.3V of the RPi can be read as high on the Atmega, if so you can connect them without any resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B. if not, you have to use a voltage adapter (yes, other components and many possible solutions), otherwise you RPi GPIO will be ruined if using a pullup on the 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pullup and pulldown, in this case, should be used when you are in A and the peripheral support the higher voltage. This is not the case.&lt;/p&gt;&#xA;" OwnerUserId="6365" OwnerDisplayName="thexeno" LastActivityDate="2014-12-22T21:04:56.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6637" PostTypeId="2" ParentId="6629" CreationDate="2014-12-22T22:07:56.817" Score="1" Body="&lt;p&gt;I don't have much experience about Arduino boards connected to the Pi, never tried anything other than Arduino Due, but I do have some experiences with ATmega328P directly attached to the Pi. The ATmega is clocked at 12MHz instead of 16 to guarantee a stable state at 3.3V supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Physical connection takes 5 signal wires besides the 3.3V power rail, with the ATmega talking with the Pi over SPI as a slave device, using both slave select lines, one at the SS pin and the other at RESET pin. This allows communication over proper hardware interfaces while eliminates the need of a programmer or preprogrammed chips as the ATmega use its SPI interface as ICSP, this setup essentially keep ICSP properly wired to the Pi at all times. An additional pin can be used as a IRQ pin from the ATmega to the Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the protocol that part is up to yourself. There are endless possibilities and you can implement anything that fits your need and easy to use.&lt;/p&gt;&#xA;" OwnerUserId="4775" OwnerDisplayName="Maxthon Chan" LastActivityDate="2014-12-22T22:07:56.817" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6638" PostTypeId="2" ParentId="6633" CreationDate="2014-12-23T02:57:08.313" Score="4" Body="&lt;p&gt;Sharing a crystal between multiple devices is a very bad idea. The crystal is only a piece of the oscillator, the rest of it being a small bit of circuitry within the IC itself. Having multiple ICs connected to the same crystal will cause them to fight over who is driving it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the CH340T/R, which I was able to find in English, says the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When CH340 chip is working normally, the outside must supply 12MHz clock signal to XI pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This seems to imply that you can feed an external 12MHz clock into the chip and it will work. So we take the clock from the '328P and pass it to the '340G.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming the CKOUT fuse on the '328P will cause the internal clock to be output on CLKO, which we then connect to XI of the '340G. This means that that you will lose PB0/D8, but no longer need a second crystal. This also means that you will be unable to use the prescaler since doing so will affect the clock output.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-23T02:57:08.313" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6639" PostTypeId="2" ParentId="4076" CreationDate="2014-12-23T04:49:33.847" Score="2" Body="&lt;p&gt;I had the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured out that simply adding &lt;code&gt;myservo.write(90); delay(4000);&lt;/code&gt; helps to stop motor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;  // create servo object to control a servo &#xA;                // twelve servo objects can be created on most boards&#xA;&#xA;int pos =0;    // variable to store the servo position &#xA;&#xA;void setup() &#xA;{ &#xA;&#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;} &#xA;&#xA;void loop() &#xA;&#xA;{ &#xA;  myservo.write(180);             &#xA;    delay(8000); ////stops motor for 8 seconds &#xA;  for(pos = 180; pos&amp;gt;=90; pos-=1)// goes from 180 degrees to 0 degrees&#xA;  {                                &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15); // waits 15ms for the servo to reach the position &#xA;&#xA;  } &#xA;&#xA;    myservo.write(90);              &#xA;    delay(4000); //stops motor for 4 seconds   &#xA;  for(pos = 90; pos &amp;lt;= 180; pos +=1) // goes from 0 degrees to 180 degrees &#xA;  {                                  // in steps of 1 degree &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);      // waits 15ms for the servo to reach the position&#xA;&#xA;  } &#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6360" LastEditorUserId="84" LastEditDate="2014-12-23T08:33:42.447" LastActivityDate="2014-12-23T08:33:42.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6640" PostTypeId="1" CreationDate="2014-12-23T07:10:44.583" Score="0" ViewCount="895" Body="&lt;p&gt;I'm trying to get a XBEE shield to operate on an Arduino Leonardo. Usually i use the AltSerialLibrary to emulate an extra serial for the xbee. However since the Leonardo comes with two sets of serial, i figured I use that instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;&#xA;//AltSoftSerial XBee(5,13); // RX, TX&#xA;&#xA;void setup() {&#xA;&#xA;  Serial1.begin(9600);&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Serial.println(&quot;Odds&quot;);&#xA;  Serial1.println(&quot;Ends&quot;);&#xA;&#xA;  delay(1000);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above aims to write values to both the serial monitor (serial) and xbee (serial1). However in the Xbee's XCTU program, the remote xbee does not recieve any data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any feedback on how I might fix this will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2016-12-22T00:20:22.097" Title="Leonardo with xbee shield?" Tags="|serial|programming|xbee|arduino-leonardo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6641" PostTypeId="2" ParentId="4076" CreationDate="2014-12-23T14:25:22.040" Score="1" Body="&lt;p&gt;A servo, by nature, is used to hold a position in the presence of disturbances trying to disturb that position. If you just need to move a mechanism that won't try to (or can't) back-drive the motor, your application ay be better served by a geared motor with a shaft encoder or position switches. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-12-23T14:25:22.040" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6642" PostTypeId="2" ParentId="6633" CreationDate="2014-12-23T14:33:44.287" Score="1" Body="&lt;p&gt;Often is is possible. The range of the crystals signals' max swing are small. Where the XI pin needs to accept these small AC signal. Hence on the FUSE on the ATmega. Which also enables the XO as a Hard clamp to excite the crystal. The crystal dominates the voltage making it small. Additionally, it is important to have the proper parallel capacitance on both the input and output of the crystal. When the XO(0) is tied to the XI(1) along with the crystal and its parallel capacitor, noting that it is in the range of 10-40pf, the total parallel capacitance will be significantly increased. Where it may be possible to reduce the XO(0)'s parallel capacitor, if XI(1) does not add too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone attempting this should really inspect the signal on an Oscilloscope to ensure the nature of the wave form is stable and stress its tolerances. Likely by changing the parallel capacitors to find the min and max's before failure. And varying VCC of both chips across is allowed ranges. As to determine the ranges is not unacceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said the datasheets refer to a version with a suffix T that have an CKO or Clock output on pin 1. That would be best and change the ATmega's FUSE for TTL input. Where Ignacio's answer is very valid and stable. Just the opposite direction.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would point out that you will have the issue that 12MgHz is not a typically supported F_CPU speed in the code. I have toy'ed with changing the speed in the past, as to do just what you are attempting here, but with a different clock source. And found it requiring so many changes to the Arduino libraries, which are typically #IF'ed to either 8 or 16 so many places not using a nice formula, it was not worth its cost savings versus cost in maintenance. As a starter you may want to refer to &lt;a href=&quot;https://stackoverflow.com/questions/20868853/arduino-at-11-0592mhz-modify-timer0-delaymicroseconds&quot;&gt;SE: &quot;Arduino at 11.0592MHz&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2014-12-23T14:33:44.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6644" PostTypeId="2" ParentId="6634" CreationDate="2014-12-23T14:54:15.577" Score="2" Body="&lt;p&gt;The Serial Class of the Arduino uses Typical usage of the Serial Ports is the USART in Async mode. Which is hard coded to IDLE state of HIGH or 1 or VCC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HpHfZ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://midas.psi.ch/mscb/hardware/bits.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://midas.psi.ch/mscb/hardware/bits.gif&lt;/a&gt;&#xA;(picture wont add - so here is a link to it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to drive the TTL inverted from its traditional values, the Serial Class can not do this. However, you can use the SoftwareSerial Class and enable the inversion in the constructor &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for why would someone want to invert the TTL UART. In some cases it is possible to drive RS232 directly. As RS232 converters inverts the TTL to +12V/-12V. 5V = -12V and 0V = +12V. So depending upon the RS232 receiver, it may actually trip its TTL output  at 2.5V and not 0V. If so then using the SoftwareSerial Class with inverse logic may drive the RS232 input of another device, without requiring a RS232 transmitter on the Arduino's TXout pin.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-12-23T14:54:15.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6645" PostTypeId="2" ParentId="6632" CreationDate="2014-12-23T16:09:28.367" Score="1" Body="&lt;p&gt;Have you even read your own code? Notably line 141; &lt;code&gt;LcdWrite(LCD_C, 0xB1 );  // Set LCD Vop (Contrast).&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try sending a different value. Note that the first bit should always be 1 so the value should be between 0x80 and 0xFF&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-23T16:09:28.367" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6646" PostTypeId="1" AcceptedAnswerId="6657" CreationDate="2014-12-23T16:39:30.463" Score="8" ViewCount="14895" Body="&lt;p&gt;I am trying to use the two temperature sensors TMP36 (from Sparkfun Inventor's kit) and KEYES LM35.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In read TMP36 Sensor and I convert the result to Celsius using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// TMP36 input sensor -&amp;gt; degrees Celsius calculation&#xA;TM36reading = analogRead(TM36sensor);  &#xA;TM36voltage = (TM36reading/1024.0)*5.0;&#xA;//converting from 10mv per degree with 500 mV offset&#xA;//             (TMP36 voltage - 500mV) times 100)&#xA;TM36degreesC = (TM36voltage - 0.5) * 100; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In read LM35 Sensor and I convert the result to Celsius using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// LM35 input sensor -&amp;gt; degrees Celsius calculation&#xA;LM35reading=analogRead(LM35sensor);    // reads the LM35 output&#xA;LM35voltage = (LM35reading/1024.0)*5.0;&#xA;LM35degreesC=LM35voltage*100.0;    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have connected also a LCD display to monitor visually the values of these two sensors. Here is my &lt;a href=&quot;http://pastebin.com/0W7hn9rg&quot; rel=&quot;noreferrer&quot;&gt;full code&lt;/a&gt;. I use also a serial log. Here is a sample from this serial log (as you can see there is a difference/offset between 0.5 to 0.9 Celsius).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TM36: 17.38, LM35: 16.60 diff -&amp;gt; 0.78&#xA;TM36: 16.89, LM35: 16.11 diff -&amp;gt; 0.78&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 17.87, LM35: 16.60 diff -&amp;gt; 1.27&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 17.09 diff -&amp;gt; 0.20&#xA;TM36: 17.38, LM35: 17.09 diff -&amp;gt; 0.29&#xA;mean difference between sensors: 0.48&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 17.38, LM35: 16.60 diff -&amp;gt; 0.78&#xA;TM36: 16.41, LM35: 17.58 diff -&amp;gt; 1.17&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 17.09 diff -&amp;gt; 0.20&#xA;mean difference between sensors: 0.71&#xA;TM36: 17.38, LM35: 16.60 diff -&amp;gt; 0.78&#xA;TM36: 16.89, LM35: 16.60 diff -&amp;gt; 0.29&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 17.38, LM35: 16.60 diff -&amp;gt; 0.78&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 17.38, LM35: 16.11 diff -&amp;gt; 1.27&#xA;TM36: 17.38, LM35: 17.09 diff -&amp;gt; 0.29&#xA;TM36: 16.89, LM35: 16.11 diff -&amp;gt; 0.78&#xA;mean difference between sensors: 0.93&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I power the Arduino from the computer using the USB cable. When the computer is ON we have the offset that I already demonstrated above. When the computer is turned off (after computer shutdown), immediately the sensor of TMP36 falls around 1 Celsius.. And then both sensors have similar temperature.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/LyDT6.jpg&quot; alt=&quot;Arduino powered by USB and Computer ON versus Computer off (LM35 and TMP36 temperature sensors)&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why there is this temperature difference between TMP36 and LM35 sensors? How can we &quot;fine tune&quot; these sensors to monitor the real temperature?&lt;/p&gt;&#xA;" OwnerUserId="1061" LastEditorUserId="1061" LastEditDate="2014-12-23T16:48:11.707" LastActivityDate="2014-12-23T23:55:05.343" Title="Temperature sensors TMP36 and LM35 have temperature diff. (offset) in the same circuit" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6647" PostTypeId="1" AcceptedAnswerId="6688" CreationDate="2014-12-23T16:42:27.397" Score="5" ViewCount="29235" Body="&lt;p&gt;I have three devices for making a motion activated security camera system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this is the camera : &lt;a href=&quot;http://urun.gittigidiyor.com/ev-elektronigi/arduino-pic-kamera-modulu-ov7660-134509055&quot; rel=&quot;nofollow&quot;&gt;LINK&lt;/a&gt;  OV 7670  &lt;/li&gt;&#xA;&lt;li&gt;this is the SD Card module: &lt;a href=&quot;http://urun.gittigidiyor.com/ev-elektronigi/arduino-sd-kart-modulu-140174113?opi=132220334&quot; rel=&quot;nofollow&quot;&gt;LINK&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;and a basic motion Sensor: PIR with 3 pin &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino UNO and an Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can connect the SD card and sensor, they work fine but I cannot connect the camera as there are not enough pins for it on UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a chance to connect all of them without any additional device? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw some working project with additional device (arducam) but I do not have much money to spend on this project.&lt;/p&gt;&#xA;" OwnerUserId="6367" LastEditorUserId="84" LastEditDate="2014-12-23T17:12:20.487" LastActivityDate="2017-09-18T07:25:02.593" Title="ov7670 + Sd Card + arduino" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6648" PostTypeId="2" ParentId="6471" CreationDate="2014-12-23T19:49:15.713" Score="1" Body="&lt;p&gt;If you had it working and it has changed, I would suggest trying a few changes to track down the issue. The schematic seems OK so assuming that all connections are sound, I would look towards proving the code. Maybe try a simple pure Arduino sketch designed for the 74HC595N and see if the results are the same. If not, the culprit is almost certainly Johnny Five.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps try &lt;a href=&quot;http://arduino.cc/en/Tutorial/ShftOut22&quot; rel=&quot;nofollow&quot;&gt;this sketch&lt;/a&gt; which should work with your schematic (remap the I/O though to your 2,3,4 configuration). If the problem persists, throughly examine your connections because there is very little else which would prevent it from working - especially given that it did work a few days ago. Also, have you got another Leonardo to test with?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the schematic for the Arduino-only example shows a cap on the latch line - presumably for debouncing - which is missing from your schematic. I don't think you've damaged your registers but I wouldn't rule it out.&lt;/p&gt;&#xA;" OwnerUserId="3506" LastActivityDate="2014-12-23T19:49:15.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6649" PostTypeId="2" ParentId="6618" CreationDate="2014-12-23T20:47:40.490" Score="3" Body="&lt;p&gt;You can use Arduino proto shield. It's a prototyping board shaped the way it can be plugged into the Arduino. There are over 9000 of them from different manufacturers. Then just solder the stuff you need on the proto shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tzgva.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6372" LastActivityDate="2014-12-23T20:47:40.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6650" PostTypeId="2" ParentId="6646" CreationDate="2014-12-23T21:09:00.297" Score="3" Body="&lt;p&gt;There are many things, first different sensors have different accuracy or they may not have been calibrated from the factory. In addition both are analog and analog reading is susceptible to noise. My guess is there is a high frequency noise on power line coming from the computer interfering with your readings. Try putting a small (100nF) capacitor between AREF and GND pin. You can always just take median of the measured values as the actual temperature.&lt;/p&gt;&#xA;" OwnerUserId="6372" LastActivityDate="2014-12-23T21:09:00.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6651" PostTypeId="2" ParentId="6613" CreationDate="2014-12-23T21:14:08.637" Score="1" Body="&lt;p&gt;You can try my &lt;a href=&quot;https://github.com/cano64/Arduino-BMP085-Library-no-pow&quot; rel=&quot;nofollow&quot;&gt;BMP080/BMP180 Arduino library&lt;/a&gt;&#xA;My library doesn't require use of floats of math library, making your sketch very small and fast.&lt;/p&gt;&#xA;" OwnerUserId="6372" LastActivityDate="2014-12-23T21:14:08.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6652" PostTypeId="1" AcceptedAnswerId="6673" CreationDate="2014-12-23T21:18:03.333" Score="-1" ViewCount="3376" Body="&lt;p&gt;i need to read all Read all Digital input in arduino once time; example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to receive state of all digital pin in one times from my app build with delphi&lt;/p&gt;&#xA;" OwnerUserId="6373" LastActivityDate="2014-12-24T18:38:00.317" Title="Read all Digital input in arduino once time and sent theme to serial" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6653" PostTypeId="1" AcceptedAnswerId="6656" CreationDate="2014-12-23T21:34:47.287" Score="0" ViewCount="73" Body="&lt;p&gt;I have an Arduino micro &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/arduinoBoardMicro&lt;/a&gt; I was looking to know which is the lowest version of the IDE that support it. Actually on the IDE 0023 is not present in &lt;code&gt;Tools &amp;gt; Board&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6374" LastActivityDate="2014-12-23T23:00:40.363" Title="IDE support for Arduino micro" Tags="|ide|arduino-micro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6655" PostTypeId="2" ParentId="6652" CreationDate="2014-12-23T22:00:21.950" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;http://arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow&quot;&gt;the pin mapping&lt;/a&gt;, D0-D13 and A0-A5 are mapped to ports B, C, and D. So simply read the raw ports as bytes, send the values, and decode them on the other side.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(PINB);&#xA;Serial.write(PINC);&#xA;Serial.write(PIND);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that A6 and A7 (on boards that have them) are not mapped to digital pins and so cannot be read in this way.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-23T22:00:21.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6656" PostTypeId="2" ParentId="6653" CreationDate="2014-12-23T23:00:40.363" Score="2" Body="&lt;p&gt;According to the &lt;a href=&quot;http://arduino.cc/en/Main/ReleaseNotes&quot; rel=&quot;nofollow&quot;&gt;Arduino Software Release Notes&lt;/a&gt;, support for the Arduino Micro was added in 1.0.2.&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-12-23T23:00:40.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6657" PostTypeId="2" ParentId="6646" CreationDate="2014-12-23T23:14:52.920" Score="5" Body="&lt;p&gt;The sensors have different accuracy, according to their datasheets.&#xA;The &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Temp/TMP35_36_37.pdf&quot; rel=&quot;noreferrer&quot;&gt;TMP36&lt;/a&gt; has &lt;strong&gt;±2°C typical accuracy&lt;/strong&gt;, while the the &lt;a href=&quot;http://www.biltek.tubitak.gov.tr/gelisim/elektronik/dosyalar/5/LM35.pdf&quot; rel=&quot;noreferrer&quot;&gt;LM35&lt;/a&gt; has &lt;strong&gt;0.5°C typical accuracy&lt;/strong&gt; (over 25°C).&#xA;Read the datasheet carefully and pay attention to the characteristics, more specifically to the accuracy error graphs for each sensor. At your measured temperature (~17°C), you should expect the following error (the red line is not super accurate, but should give a general clue):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;LM35:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yt0rY.png&quot; alt=&quot;LM35 Accuracy Error characteristics as per datasheet&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TMP36:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bzWWw.png&quot; alt=&quot;TMP36 Accuracy Error characteristics as per datasheet&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, as &lt;strong&gt;Michal&lt;/strong&gt; stated, you might have noise in your circuit, and you are not connecting the TMP36 as per the datasheet suggests (note the capacitor between +V and Ground):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EzVTX.png&quot; alt=&quot;TMP36 typical application as per datasheet&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-23T23:55:05.343" LastActivityDate="2014-12-23T23:55:05.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6658" PostTypeId="2" ParentId="6627" CreationDate="2014-12-24T01:01:48.253" Score="2" Body="&lt;p&gt;You can't use threads on an arduino, they don't exist. you can get some pseudo multitasking going with interrupts, but that is not necessary in your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to refactor your code to avoid using delays without much work. The arduino library provides &lt;code&gt;millis()&lt;/code&gt; to keep tract of the time since the arduino was powered on in milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;something like this could replace all the delays in your code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static boolean state;&#xA;static uint32_t time;&#xA;if(time &amp;lt; millis()){&#xA;    time += delayFromPercent(percentValue);&#xA;&#xA;    state = !state;&#xA;    if(percentage &amp;lt; 1.0) state = false;&#xA;    digitalWrite(in1, state);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, somewhere else place&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t delayFromPercent(float percent){&#xA;    if(percent &amp;lt; 25) return 100;&#xA;    if(percent &amp;lt; 50) return 50;&#xA;    if(percent &amp;lt; 75) return 25;&#xA;    return 10;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;alternately, if you don't really want the discrete steps, you could use this instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t delayFromPercent(float percent){&#xA;    return max(10, 100-percent); // don't return less than 10ms&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you could change it to react a bit quicker by comparing the time plus calculated delay now rather than when it last set the pin, but that strays farther from what your initial implementation would have done. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, this code will should be able to switch pin in1 without making the rest of your code slow down, as long as the other code does not use delays either.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2014-12-25T04:29:19.863" LastActivityDate="2014-12-25T04:29:19.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6660" PostTypeId="1" AcceptedAnswerId="6664" CreationDate="2014-12-24T03:46:44.240" Score="0" ViewCount="9004" Body="&lt;p&gt;This is my first time to try program arduino, and I am clueless. I have a friend who told me about things work, and he told me the programming language is C (or similar to C) which we have learned in our class. I just program as my friend examples, but it doesn't work and return error codes about expected ; before ( or ) before ; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why this wont work. This is the hardware (simulated) I going to make.&#xA;     &lt;img src=&quot;https://i.stack.imgur.com/HnyKf.jpg&quot; alt=&quot;hw-planned&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define dw 8; //buttons down&#xA;#define ri 9; //buttons right&#xA;#define le 10; //buttons left&#xA;#define up 11; //buttons up&#xA;#define ok 12; //buttons ok&#xA;#define mn 13; //buttons menu&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(6,5,4,3,2,1);&#xA;int i=0;&#xA;char input[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(dw, INPUT);&#xA;  pinMode(ri, INPUT);&#xA;  pinMode(le, INPUT);&#xA;  pinMode(up, INPUT);&#xA;  pinMode(ok, INPUT);&#xA;  pinMode(mn, INPUT);  &#xA;}&#xA;void intext()&#xA;{&#xA;  int c=0, lim=16;&#xA;  for(i=0;i&amp;lt;lim;)&#xA;  {&#xA;    lcd.setCursor(c,1);&#xA;    input[i]=97;&#xA;    if(dw=HIGH)&#xA;    {&#xA;      if(input[i]&amp;gt;122)&#xA;        input[i]=97;&#xA;      input[i]=input[i]+1;&#xA;      lcd.print(input[i]);&#xA;    }&#xA;    if(up=HIGH)&#xA;    {&#xA;      if(input[i]&amp;gt;97)&#xA;        input[i]=122;&#xA;      input[i]=input[i]-1;&#xA;      lcd.print(input[i]);&#xA;    }&#xA;    if(ri=HIGH)&#xA;    {&#xA;      c=c+1;&#xA;      lcd.setCursor(c,1);&#xA;      lcd.print(input[i]);      &#xA;    }&#xA;    if(le=HIGH)&#xA;    {&#xA;      c=c-1;&#xA;      lcd.setCursor(c,1);&#xA;      lcd.print(input[i]);&#xA;    }&#xA;    if(ok=HIGH)&#xA;    {&#xA;      lim=i+1;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  lcd.begin(16,2);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Masukan kata:&quot;);&#xA;  intext();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea why it wouldn't work. I'm sorry if I'm too stupid to understand.&#xA;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: oh yeah, the errors, here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;Arduino: 1.0.6 (Windows NT (unknown)), Board: &quot;Arduino Uno&quot;&#xA;programyuhu.ino: In function 'void setup()':&#xA;programyuhu:14: error: expected `)' before ';' token&#xA;programyuhu:14: error: expected primary-expression before ',' token&#xA;programyuhu:14: error: expected `;' before ')' token&#xA;programyuhu:15: error: expected `)' before ';' token&#xA;programyuhu:15: error: expected primary-expression before ',' token&#xA;programyuhu:15: error: expected `;' before ')' token&#xA;programyuhu:16: error: expected `)' before ';' token&#xA;programyuhu:16: error: expected primary-expression before ',' token&#xA;programyuhu:16: error: expected `;' before ')' token&#xA;programyuhu:17: error: expected `)' before ';' token&#xA;programyuhu:17: error: expected primary-expression before ',' token&#xA;programyuhu:17: error: expected `;' before ')' token&#xA;programyuhu:18: error: expected `)' before ';' token&#xA;programyuhu:18: error: expected primary-expression before ',' token&#xA;programyuhu:18: error: expected `;' before ')' token&#xA;programyuhu:19: error: expected `)' before ';' token&#xA;programyuhu:19: error: expected primary-expression before ',' token&#xA;programyuhu:19: error: expected `;' before ')' token&#xA;programyuhu.ino: In function 'void intext()':&#xA;programyuhu:28: error: expected `)' before ';' token&#xA;programyuhu:28: error: expected primary-expression before '=' token&#xA;programyuhu:28: error: expected `;' before ')' token&#xA;programyuhu:35: error: expected `)' before ';' token&#xA;programyuhu:35: error: expected primary-expression before '=' token&#xA;programyuhu:35: error: expected `;' before ')' token&#xA;programyuhu:42: error: expected `)' before ';' token&#xA;programyuhu:42: error: expected primary-expression before '=' token&#xA;programyuhu:42: error: expected `;' before ')' token&#xA;programyuhu:48: error: expected `)' before ';' token&#xA;programyuhu:48: error: expected primary-expression before '=' token&#xA;programyuhu:48: error: expected `;' before ')' token&#xA;programyuhu:54: error: expected `)' before ';' token&#xA;programyuhu:54: error: expected primary-expression before '=' token&#xA;programyuhu:54: error: expected `;' before ')' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6379" LastEditorUserId="368" LastEditDate="2014-12-24T04:15:37.280" LastActivityDate="2014-12-24T10:14:37.810" Title="Program got so many errors about expected ) or ; before either" Tags="|programming|display|string|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6661" PostTypeId="2" ParentId="6660" CreationDate="2014-12-24T04:13:26.713" Score="6" Body="&lt;p&gt;Here's the first line of your code:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define dw 8; //buttons down&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the first error line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(dw, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Let's put them together and see what we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(8; //buttons down, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's not valid C++. Using the output I've shown you, modify the input until it looks correct. And then keep doing it until the code compiles.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-24T04:13:26.713" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6662" PostTypeId="2" ParentId="5054" CreationDate="2014-12-24T05:53:40.247" Score="-1" Body="&lt;pre&gt;&lt;code&gt;/*&#xA;HEADER TEXT&#xA;GOES HERE&#xA;*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#define SS_PIN 10&#xA;#define RST_PIN 9&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  // Serielles Interface initialisieren&#xA;  Serial.begin(9600);&#xA;  // SPI initialisieren&#xA;  SPI.begin();&#xA;&#xA;  mfrc522.PCD_Init();&#xA;&#xA;  // Für später&#xA;  // pinMode (2, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Eigene UID bilden. Dazu nehmen wir die 4(7)Byte Hex UID aus Block 0 und quetschen sie in einen schönen String.&#xA;// String uID = String(mfrc522.uid.uidByte[0],HEX)+String(mfrc522.uid.uidByte[1],HEX)+String(mfrc522.uid.uidByte[2],HEX)+String(mfrc522.uid.uidByte[3],HEX);&#xA;&#xA;  // PICC Typen&#xA;// byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);&#xA;&#xA;  // Nach neuen Karten suchen.&#xA;  delay(250);&#xA;  if ( mfrc522.PICC_IsNewCardPresent())&#xA;  {&#xA;    delay(250);&#xA;    mfrc522.PICC_ReadCardSerial();&#xA;     // Eigene UID bilden. Dazu nehmen wir die 4(7)Byte Hex UID aus Block 0 und quetschen sie in einen schönen String.&#xA; String uID = String(mfrc522.uid.uidByte[0],HEX)+String(mfrc522.uid.uidByte[1],HEX)+String(mfrc522.uid.uidByte[2],HEX)+String(mfrc522.uid.uidByte[3],HEX);&#xA;&#xA;  // PICC Typen&#xA; byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);&#xA;&#xA;&#xA;    // Debug Ausgabe&#xA;    Serial.println();&#xA;    Serial.print(&quot;Die Kartennummer lautet: &quot;);&#xA;    Serial.print(uID);&#xA;    Serial.println();&#xA;    Serial.print(&quot;Picc Type: &quot;);&#xA;    Serial.println(mfrc522.PICC_GetTypeName(piccType));&#xA;    Serial.println();&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;    // Überprüfe auf unterstützten PICC Typ und noch mehr Debug Kram&#xA;    if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI &amp;amp;&amp;amp; piccType != MFRC522::PICC_TYPE_MIFARE_1K&amp;amp;&amp;amp; piccType != MFRC522::PICC_TYPE_MIFARE_1K) {&#xA;      Serial.println(&quot;Diese Tech-Demo benötigt MIFARE Classic Karten.&quot;);&#xA;      return;&#xA;    }&#xA;&#xA;    // Den UID String Verglichen und eine entsprechende Aktion ausführen&#xA;    if(uID==&quot;myUIDforStuff&quot;) {&#xA;      Serial.println(&quot;Access granted&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6381" LastEditorUserId="84" LastEditDate="2014-12-24T10:12:39.743" LastActivityDate="2014-12-24T10:12:39.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6663" PostTypeId="2" ParentId="6660" CreationDate="2014-12-24T06:22:16.257" Score="2" Body="&lt;p&gt;The errors are in your &lt;code&gt;#define&lt;/code&gt; statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These should not have &lt;code&gt;;&lt;/code&gt; as they are not executable statements&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2014-12-24T06:22:16.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6664" PostTypeId="2" ParentId="6660" CreationDate="2014-12-24T06:37:01.893" Score="2" Body="&lt;p&gt;In C and in C++, &lt;code&gt;#define&lt;/code&gt; is not an instruction of the language, but a directive of the &lt;strong&gt;pre-processor&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it does is define a &quot;macro&quot; which will be replaced everywhere it appears later on in the source file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DUMMY 152&#xA;&#xA;int x = x + DUMMY;&#xA;myfunction(DUMMY);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be changed, before compilation, into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x = x + 152;&#xA;myfuntion(152);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the example above, &lt;code&gt;DUMMY&lt;/code&gt; is replaced everywhere by what follows it in the  &lt;code&gt;#define&lt;/code&gt; line, i.e. 152.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pre-processor directive is not an instruction, it shall not be ended by &lt;code&gt;;&lt;/code&gt;. If you add &lt;code&gt;;&lt;/code&gt; at the end of a &lt;code&gt;#define&lt;/code&gt;, then it will be part of the replacement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DUMMY 152;&#xA;&#xA;int x = x + 152;;&#xA;myfuntion(152;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see now, &lt;code&gt;DUMMY&lt;/code&gt; is replaced by &lt;code&gt;152;&lt;/code&gt;, not just &lt;code&gt;152&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the solution in you example is to remove all &lt;code&gt;;&lt;/code&gt; that are at the end of &lt;code&gt;#define&lt;/code&gt; lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//buttons down&#xA;#define dw 8&#xA;//buttons right&#xA;#define ri 9&#xA;//buttons left&#xA;#define le 10&#xA;//buttons up&#xA;#define up 11&#xA;//buttons ok&#xA;#define ok 12&#xA;//buttons menu&#xA;#define mn 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that comments should also be removed from the &lt;code&gt;#define&lt;/code&gt; otherwise they would also appear everywhere the replacements are done.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2014-12-24T10:14:37.810" LastActivityDate="2014-12-24T10:14:37.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6665" PostTypeId="2" ParentId="4705" CreationDate="2014-12-24T08:37:21.180" Score="1" Body="&lt;p&gt;To add to BrettM answer, Bluetooth is the &lt;em&gt;RF&lt;/em&gt; standard on which many protocols can &lt;em&gt;stack up&lt;/em&gt;; each such protocol is called a 'Bluetooth Profile'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Bluetooth model you purchased comes only with the &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Serial_Port_Profile_.28SPP.29&quot; rel=&quot;nofollow&quot;&gt;Serial Port Profile&lt;/a&gt; (&lt;strong&gt;SPP&lt;/strong&gt;) profile implemented in the firmware. This mean that you can use it for establishing serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As serial protocol will probably be too slow for stereo Audio over Bluetooth, Audio usually use a different profile called &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Advanced_Audio_Distribution_Profile_.28A2DP.29&quot; rel=&quot;nofollow&quot;&gt;Advanced Audio Distribution Profile&lt;/a&gt; (&lt;strong&gt;A2DP&lt;/strong&gt;). Unfortunately, the HC-05 does not come with this protocol stack implemented in its firmware. If your primary goal is to send stereo Audio over Bluetooth, consider purchasing a dedicated chip, such as &lt;strong&gt;XS3868&lt;/strong&gt; or Sparkfun's &lt;strong&gt;RN-52&lt;/strong&gt;. For beginners, it is recommended to get one with a breakout board for easy integration with Arduino projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For completeness, there are many other Bluetooth profiles, each is optimized for different task. See Wikipedia for the full list: &#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Bluetooth_profiles&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/List_of_Bluetooth_profiles&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-24T09:19:26.433" LastActivityDate="2014-12-24T09:19:26.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6666" PostTypeId="1" CreationDate="2014-12-24T08:45:43.033" Score="1" ViewCount="3900" Body="&lt;p&gt;This is the hardware set-up at home, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Raspberry Pi GPIO -&gt; Logic Level Converter -&gt; Arduino -&gt; Multiple Relays&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/J8Ja4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running Raspbian and NodeJS on the Pi while the Arduino is loaded with StandardFirmata.&#xA;I connect NodeJS to the Arduino with the &lt;code&gt;johnny-five&lt;/code&gt; package and it works well after it's started. But after extended periods, a few hours? The Arduino stops responding. Whatever command that I send to the Arduino won't be acted on. It's as though as the Arduino hung.&#xA;Both the Raspberry Pi and Arduino are being powered indenpendently with a 1A Nokia USB Adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why this is happening?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/rwaldron/johnny-five&quot; rel=&quot;nofollow noreferrer&quot;&gt;johnny-five&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/firmata/arduino/blob/master/examples/StandardFirmata/StandardFirmata.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;StandardFirmata&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://gist.github.com/zanechua/f52a3d72946d7214f7cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;NodeJS Server Code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6384" OwnerDisplayName="Zane" LastEditorUserId="41407" LastEditDate="2018-08-19T17:38:33.340" LastActivityDate="2021-08-04T11:03:10.233" Title="Raspberry Pi with Arduino, Serial connection stops working" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="6667" PostTypeId="1" CreationDate="2014-12-24T10:57:24.537" Score="2" ViewCount="2138" Body="&lt;p&gt;I want to open the window to let the cat enter or go out, but the mecanism of the window may me think that the best way should be to use a jack/cylinder (I don't know what term is more appropriate in english for that) to open and close the door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will use rfid or another wireless think to know it the cat is in the place and then open the wondow but I want to close the window and let the wndow close event if there is little bit of wind, so I need domething robust.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know a good hardware with (this would be the best) piece of code that can help me for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="3299" LastActivityDate="2014-12-24T14:42:23.757" Title="control a jack/cylinder to open/close a window" Tags="|hardware|communication|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6668" PostTypeId="2" ParentId="1401" CreationDate="2014-12-24T11:02:34.150" Score="1" Body="&lt;p&gt;I used some time ago the TMRPCM library that the tutorial you linked used and I was very satisfied.&lt;/p&gt;&#xA;&lt;p&gt;It doesn't take too much space and it has some really unique and neat features like the possibility to use two speakers instead of one to reproduce stereo audio (Unfortunately you need a more powerful AVR IC, surely not an UNO board/328 IC for this feature if you don't want to occur in bad reproduction)&lt;/p&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub's wiki&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;All 328 based boards: Arduino Uno, Nano, Duemilanove, etc&lt;/p&gt;&#xA;&lt;p&gt;Mega Types: 1280, 2560, etc&lt;/p&gt;&#xA;&lt;p&gt;No Due support currently.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You can only have WAV files on the SD but they can be very large (other libraries limit you to a specific maximum size/duration) and you need to connect the SD to the arduino via SPI (as far as I know it is the only way to communicate directly with an SD card).&lt;/p&gt;&#xA;&lt;p&gt;Also, you will need to convert the files to 8 bit WAV (so it's faster and easier for the arduino to reproduce the sound) with sample rate from 8 to 32khz, mono audio.&lt;/p&gt;&#xA;&lt;p&gt;Be careful just because you'll need to power the SD with 3.3 volts otherwise you'll fry the entire card.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Most of the extra features require more memory, more program space, and in some cases, more processing power for playback Some of them are still being fine tuned. Please keep this in mind when enabling these features.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you want to take a look, &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki/Advanced-Features&quot; rel=&quot;nofollow noreferrer&quot;&gt;go to this page&lt;/a&gt; for more informations on the advanced features&lt;/p&gt;&#xA;&lt;p&gt;A last thing that I have to say is that the functions are really straightforward:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TMRpcm audio;&#xA;audio.play(&amp;quot;filename&amp;quot;);    plays a file&#xA;audio.play(&amp;quot;filename&amp;quot;,30); plays a file starting at 30 seconds into the track&#xA;audio.speakerPin = 11;     set to 5,6,11 or 46 for Mega, 9 for Uno, Nano, etc.&#xA;audio.disable();           disables the timer on output pin and stops the music&#xA;audio.stopPlayback();      stops the music, but leaves the timer running&#xA;audio.isPlaying();         returns 1 if music playing, 0 if not&#xA;audio.pause();             pauses/unpauses playback&#xA;audio.quality(1);          Set 1 for 2x oversampling&#xA;audio.volume(0);           1(up) or 0(down) to control volume&#xA;audio.setVolume(0);        0 to 7. Set volume level&#xA;audio.loop(1);             0 or 1. Can be changed during playback for full control of looping. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4887" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-02T17:02:59.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6669" PostTypeId="2" ParentId="6667" CreationDate="2014-12-24T11:24:14.640" Score="1" Body="&lt;p&gt;Check out &lt;a href=&quot;http://www.instructables.com/id/Arduino-controlled-window-for-cat/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this instructable&lt;/a&gt; - for opening a window for a cat :)&#xA;The guy used a servo, &lt;a href=&quot;http://www.servodatabase.com/servo/towerpro/mg995&quot; rel=&quot;nofollow noreferrer&quot;&gt;Towerpro MG995&lt;/a&gt; with 10 kg torque for opening/closing the window, and a 10cm distance sensor for sensing the cat (he used &lt;a href=&quot;http://www.pololu.com/product/1134&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pololu Carrier with Sharp GP2Y0D810Z0F Digital Distance Sensor&lt;/a&gt;, but I believe that any proximity sensor will do). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a pictrure of the mechanism, seems quite robust:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/RT0EL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-24T14:42:23.757" LastActivityDate="2014-12-24T14:42:23.757" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6670" PostTypeId="1" CreationDate="2014-12-24T14:08:15.577" Score="0" ViewCount="3326" Body="&lt;p&gt;I am getting the above error message uploading the ADDAC VCC, and the only thing that's changed I think is the patch is bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a fix for this or will I have to send it back? Hope my formatting is OK&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Binary sketch size: 12,330 bytes (of a 258,048 byte maximum)&#xA;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/build953252908946386724.tmp/comps.cpp.hex:i &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] &#xA;&#xA;avrdude: Version 6.0.1, compiled on Oct 21 2013 at 17:07:18&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/luke/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyUSB0&#xA;         Using Programmer              : wiring&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: wiring_open(): releasing DTR/RTS&#xA;avrdude: wiring_open(): asserting DTR/RTS&#xA;avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6383" LastEditorUserId="6452" LastEditDate="2015-03-19T16:45:05.223" LastActivityDate="2015-03-19T16:45:05.223" Title="avrdude: stk500v2_ReceiveMessage(): timeout with ADDAC VCC" Tags="|bootloader|avrdude|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6671" PostTypeId="1" AcceptedAnswerId="6672" CreationDate="2014-12-24T17:39:12.230" Score="1" ViewCount="109" Body="&lt;p&gt;I'm trying to develop something that requires accurate distance measurement of objects around the center of the contraption. However, I cannot find any way to achieve this other than using a bunch of infrared distance sensors. Really, I'm looking for something that costs at most $200 and is compatible either with arduino, PC, or raspberry pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may not be the place for this, if not, please inform me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="6388" LastActivityDate="2014-12-24T17:50:40.413" Title="Is there a radar - like sensor that can tell me the distances of multiple things around the sensor?" Tags="|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6672" PostTypeId="2" ParentId="6671" CreationDate="2014-12-24T17:50:40.413" Score="2" Body="&lt;p&gt;What you're looking for is called &lt;a href=&quot;http://en.wikipedia.org/wiki/Lidar&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;lidar&lt;/strong&gt;&lt;/a&gt; - but it's not cheap. &lt;a href=&quot;http://rplidar.robopeak.com/&quot; rel=&quot;nofollow&quot;&gt;RPLIDAR&lt;/a&gt; is the current price leader for non-hacky solutions, and I haven't seen it for much less than $400 anywhere.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-24T17:50:40.413" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6673" PostTypeId="2" ParentId="6652" CreationDate="2014-12-24T18:38:00.317" Score="1" Body="&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.print(&quot;&amp;lt;&quot;);&#xA;  for (int p = 0; p &amp;lt; 14; p++)&#xA;  {&#xA;    Serial.print(digitalRead(p));&#xA;  }&#xA;  Serial.println(&quot;&amp;gt;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6373" LastActivityDate="2014-12-24T18:38:00.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6674" PostTypeId="2" ParentId="6666" CreationDate="2014-12-24T19:46:11.607" Score="1" Body="&lt;p&gt;If none of the code is yours, and all code from the Firmata library, then the most possible cause that comes to mind after reviewing the library code is memory leak, which makes the next allocation to fail and by thus breaking the code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Firmata library does perform dynamic memory allocation, checkout Firmata.c, so it is realistic - I would suggest to take it with the Library's author. &lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-24T19:46:11.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6675" PostTypeId="1" AcceptedAnswerId="6677" CreationDate="2014-12-24T20:50:15.200" Score="2" ViewCount="195" Body="&lt;p&gt;I plan to build functioning reaction wheels, controlled by an Arduino Micro. Ideally, I'd like to have the reaction wheels, and the micro, be a single unit which would receive external commands from another microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know you can link Arduino microcontrollers, and every time I've seen it done it has been with a RC module such as XBee. Is it possible to link units using something like the micro-usb on the Arduino Micro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is possible, is it as simple as connecting the micro-usb ports on my microcontrollers, and then working out the programming?&lt;/p&gt;&#xA;" OwnerUserId="6390" OwnerDisplayName="CoilKid" LastEditorUserId="10794" LastEditDate="2016-03-17T21:36:02.257" LastActivityDate="2016-03-17T21:36:02.257" Title="Can an Arduino Micro receive commands from another microcontroller when hardwired together?" Tags="|serial|i2c|usb|communication|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6676" PostTypeId="2" ParentId="6675" CreationDate="2014-12-24T21:03:33.623" Score="1" Body="&lt;p&gt;Usually the RF links (xbee included) just replace a set of wires connecting two serial ports. You can very easily connect the serial ports on two arduino's and communicate between them without any special hardware in between. You will only need 4 wires (power, ground, transmit, receive). &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2014-12-24T21:03:33.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6677" PostTypeId="2" ParentId="6675" CreationDate="2014-12-24T21:20:59.010" Score="4" Body="&lt;p&gt;You cannot do this with the micro USB ports.  You will need to use I/O pins.  Either serial or I2C would be good options.  It might be advisable to use I2C if you want to control multiple 'slave' microcontrollers as they can all sit on the same bus.  Using the serial port would require multiple transmit and receive pins on the master controller, likely requiring software serial ports (high overhead).  Also, if you don't use the serial port for comms, then you can use it for debugging.  &lt;/p&gt;&#xA;" OwnerUserId="3832" LastActivityDate="2014-12-24T21:20:59.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6678" PostTypeId="2" ParentId="6601" CreationDate="2014-12-24T21:33:31.113" Score="0" Body="&lt;p&gt;You can do this with out any additional hardware by putting the TLC5940 to BITBANG mode instead of SPI mode and making the Ethernet Shield use D8 pin instead of D10 pin.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Software Changes&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;On line 61 of &lt;code&gt;sketchbook/libraries/Tlc5940/tlc_config.h&lt;/code&gt; replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DATA_TRANSFER_MODE    TLC_SPI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DATA_TRANSFER_MODE    TLC_BITBANG&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On lines 339 - 341 of &lt;code&gt;arduino/libraries/Ethernet/utility/w5100.h&lt;/code&gt; replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; inline static void initSS()    { DDRB  |=  _BV(2); };  &#xA; inline static void setSS()     { PORTB &amp;amp;= ~_BV(2); };&#xA; inline static void resetSS()   { PORTB |=  _BV(2); };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; inline static void initSS()    { DDRB  |=  _BV(0); };  &#xA; inline static void setSS()     { PORTB &amp;amp;= ~_BV(0); };&#xA; inline static void resetSS()   { PORTB |=  _BV(0); };&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Hardware Changes&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Bend leg of the D10 pin on the Ethernet Shield so it doesn’t connect to the D10 pin on the Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect D10 pin of Ethernet Shield to D8 pin on the Ethernet Shield&#xA;&lt;img src=&quot;https://i.stack.imgur.com/QnHfh.jpg&quot; alt=&quot;D10 pin connected to D8 pin&quot;&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect the TLC5940 using the following pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-------------                                  ---u----&#xA;Ethernet   13|                           OUT1 |1     28| OUT channel 0&#xA;Shield     12|                           OUT2 |2     27|-&amp;gt; GND (VPRG)&#xA;           11|                           OUT3 |3     26|-&amp;gt; SIN (pin 7)&#xA;10,underneath|-&amp;gt; BLANK (pin 23)          OUT4 |4     25|-&amp;gt; SCLK (pin 4)&#xA;            9|-&amp;gt; XLAT (pin 24)             .  |5     24|-&amp;gt; XLAT (pin 9)&#xA;            8|-&amp;gt; to pin 10 on shield       .  |6     23|-&amp;gt; BLANK (pin 10 underneath shield)&#xA;            7|-&amp;gt; SIN (pin 26)              .  |7     22|-&amp;gt; GND&#xA;            6|                             .  |8     21|-&amp;gt; VCC (+5V)&#xA;            5|                             .  |9     20|-&amp;gt; 2K Resistor -&amp;gt; GND&#xA;            4|-&amp;gt; SCLK (pin 25)             .  |10    19|-&amp;gt; +5V (DCPRG)&#xA;            3|-&amp;gt; GSCLK (pin 18)            .  |11    18|-&amp;gt; GSCLK (pin 3)&#xA;            2|                             .  |12    17|-&amp;gt; SOUT&#xA;            1|                             .  |13    16|-&amp;gt; XERR&#xA;            0|                           OUT14|14    15| OUT channel 15&#xA;-------------                                  --------&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Tested with Arduino 1.0.5 on Linux Mint 17 with r14 of the &lt;a href=&quot;https://code.google.com/p/tlc5940arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tlc5940arduino&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References:&lt;br&gt;&#xA;&lt;a href=&quot;http://blog.andrewwei.mu/?p=19&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://blog.andrewwei.mu/?p=19&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,22111.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php/topic,22111.0.html&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,142977.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php/topic,142977.0.html&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,118265.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php/topic,118265.0.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2014-12-24T21:33:31.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6679" PostTypeId="1" CreationDate="2014-12-24T22:11:39.157" Score="1" ViewCount="785" Body="&lt;p&gt;I just got my arduino and servo. But my servo may be acting strangely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I tell the servo to go somewhere it keeps going to 0 than to that position and stops after 10-15 seconds or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code used in this video&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;    Servo myservo;&#xA;&#xA;    void setup() &#xA;    { &#xA;      myservo.attach(11);&#xA;      myservo.write(50);&#xA;    } &#xA;&#xA;    void loop() &#xA;    { &#xA;    }     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=rsikknT7z6g&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=rsikknT7z6g&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is connected like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground from Arduino to breadboard row 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground from external power supply to breadboard row 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground from SERVO to breadboard row 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power supply positive to servo VCC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo signal to pin 11&lt;/p&gt;&#xA;" OwnerUserId="6391" LastActivityDate="2014-12-25T22:46:43.283" Title="Servo motor swinging back to 0°" Tags="|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6680" PostTypeId="2" ParentId="6675" CreationDate="2014-12-24T23:45:38.270" Score="2" Body="&lt;p&gt;It might be worth explaining WHY you can't &quot;just connect the micro-usb ports&quot;. There are two issues here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;USB is not symmetric, and an Arduino micro is only designed to act as a client. One of your microcontrollers would need to have USB OTG support to act as a host.&lt;/li&gt;&#xA;&lt;li&gt;Even though there are microcontrollers that do have USB OTG support, you'd still have a nontrivial hurdle writing the software for them (Pretty sure the Arduino USB code is client specific as well, though I'm not familiar with the details of the serial over USB protocol).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short, your basic idea is not physically or technically impossible, but would be fairly difficult to execute, while there are much simpler solutions available.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2014-12-24T23:45:38.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6681" PostTypeId="1" AcceptedAnswerId="6682" CreationDate="2014-12-25T01:16:00.593" Score="2" ViewCount="7910" Body="&lt;p&gt;I would like to use my Attiny85 as an remote controlled relay switch.&#xA;I have already tested the sketch on my Atmega328 and it worked.&#xA;Now I wanted to burn the sketch on my Attiny85 using ArduinoISP but I get the following error in the ArduinoIDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_dec25a.ino: In function ‘void setup()’:&#xA;sketch_dec25a:13: error: ‘class RCSwitch’ has no member named ‘enableReceive’&#xA;sketch_dec25a.ino: In function ‘void loop()’:&#xA;sketch_dec25a:20: error: ‘class RCSwitch’ has no member named ‘available’&#xA;sketch_dec25a:21: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’&#xA;sketch_dec25a:22: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’&#xA;sketch_dec25a:25: error: ‘class RCSwitch’ has no member named ‘resetAvailable’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;RCSwitch.h&amp;gt;&#xA;&#xA;int RELAY_PIN = 2;&#xA;&#xA;RCSwitch mySwitch = RCSwitch();&#xA;SoftwareSerial mySerial(1, 3); // RX, TX&#xA;&#xA;void setup()  &#xA;{&#xA;  pinMode(RELAY_PIN, OUTPUT);&#xA;  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 =&amp;gt; that is pin #2&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySwitch.available()) {&#xA;    Serial.println(mySwitch.getReceivedValue());&#xA;    if(mySwitch.getReceivedValue() == 1234567){&#xA;      digitalWrite(RELAY_PIN, HIGH);&#xA;    }&#xA;    mySwitch.resetAvailable();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using these cores: &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-tiny/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the SoftwareSerial just for debugging.&#xA;Sorry for my bad english and thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="4452" LastActivityDate="2019-05-10T00:29:30.067" Title="RCSwitch on Attiny85" Tags="|attiny|virtualwire|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6682" PostTypeId="2" ParentId="6681" CreationDate="2014-12-25T07:59:25.520" Score="4" Body="&lt;p&gt;The issue you face is that RCSwitch does not seem to support receive mode for ATtiny.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what you can find in &lt;code&gt;RCSwitch.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// At least for the ATTiny X4/X5, receiving has to be disabled due to&#xA;// missing libm depencies (udivmodhi4)&#xA;#if defined( __AVR_ATtinyX5__ ) or defined ( __AVR_ATtinyX4__ )&#xA;#define RCSwitchDisableReceiving&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then all methods related to receptions are not defined in &lt;code&gt;RCSwitch&lt;/code&gt; class for ATtiny MCUs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if not defined( RCSwitchDisableReceiving )&#xA;void enableReceive(int interrupt);&#xA;void enableReceive();&#xA;void disableReceive();&#xA;bool available();&#xA;void resetAvailable();&#xA;&#xA;unsigned long getReceivedValue();&#xA;unsigned int getReceivedBitlength();&#xA;unsigned int getReceivedDelay();&#xA;unsigned int getReceivedProtocol();&#xA;unsigned int* getReceivedRawdata();&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am really not sure if there is a way to work around it, I have not looked at the code in &lt;code&gt;RCSwitch.cpp&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you best option would be to find another RC library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you can use Infra-Red RC, then there are libraries out there that could work for ATtiny:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/shirriff/Arduino-IRremote&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-12-25T07:59:25.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6683" PostTypeId="1" AcceptedAnswerId="6684" CreationDate="2014-12-25T08:21:06.967" Score="2" ViewCount="420" Body="&lt;p&gt;I've got this quite basic code running on an Arduino Mega 2560, and the output is looking like I have the serial settings wrong, though I can't work out what to change.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()  &#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;test123&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;test&quot; + millis());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ð¦·Z©÷&#xA;×ï¾üÿ7ß^|ïüûÿVÏuØëo~ìÿÓûzëýÿ{ßþ©×xñ×¤¿ïßûÏûýoÏ¿îãõI&#xA;õfwi÷`p¬½Ïª»QáÀª»¦·ð¦·Z©÷&#xA;test123&#xA;D&#xA;&#xA;&#xA;&#xA;4ñjü¯÷~µÞMz¹Ý~¼&#xA;Ûþ}iû}ÒÖ­¦Ç¿÷ÿÂï½Õ¾;îö&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the inbuilt &quot;Serial Monitor&quot; in the Arduino suite with settings 9600 baud and no line endings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that the first println in &lt;code&gt;setup()&lt;/code&gt; is sending the data as expected but all other comms are coming through as nonsense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions of what to do?&lt;/p&gt;&#xA;" OwnerUserId="6394" LastActivityDate="2014-12-29T08:04:02.113" Title="Serial debug output looking messy" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6684" PostTypeId="2" ParentId="6683" CreationDate="2014-12-25T08:51:58.727" Score="8" Body="&lt;p&gt;This is unfortunately not valid in C++:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;test&quot; + millis()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rather than concatenating two strings, it's actually doing pointer arithmetic. It's taking the memory address where &lt;code&gt;&quot;test&quot;&lt;/code&gt; is stored, and offsetting by the value retrieved from &lt;code&gt;millis()&lt;/code&gt;. The result is a totally arbitrary memory location which gets treated like a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, it's arguably best to avoid string concatenation on Arduino anyway unless absolutely necessary. The reason is that it can use more memory than you might expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simpler approach would simply be to do the serial output as a sequence of individual operations, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print( &quot;test&quot; );&#xA;Serial.println( millis() );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the difference between &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;println()&lt;/code&gt;. The first one doesn't add a line break at the end, but the second one does.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-25T08:51:58.727" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6686" PostTypeId="1" AcceptedAnswerId="6687" CreationDate="2014-12-25T11:38:54.017" Score="1" ViewCount="2127" Body="&lt;p&gt;I understand that A-B plug used to be common but they could have switched to micro without issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why does Arduino use USB A-B plug, instead of A to micro USB plug?&lt;/li&gt;&#xA;&lt;li&gt;What are the challenged Arduino would be facing if they switched to micro USB?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note:&#xA;By &quot;Arduino&quot; I'm referring to Arduino models that do not come with a micro USB port such as the most common Uno &amp;amp; Mega.&lt;/p&gt;&#xA;" OwnerUserId="6249" LastEditorUserId="6249" LastEditDate="2014-12-26T11:25:56.420" LastActivityDate="2014-12-26T11:25:56.420" Title="Why does Arduino use USB A-B plug, instead of A to micro USB plug?" Tags="|usb|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6687" PostTypeId="2" ParentId="6686" CreationDate="2014-12-25T15:05:46.160" Score="2" Body="&lt;p&gt;&lt;em&gt;Please note that this answer is based on speculation and some common sense rather than on insider information&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take look at the &lt;a href=&quot;http://arduino.cc/en/Main/Boards&quot; rel=&quot;nofollow&quot;&gt;hardware index&lt;/a&gt;, you'll notice that significant parts of the layout (drill holes, pin spacing, and position and &lt;strong&gt;type of the USB jack&lt;/strong&gt;) haven't changed between the &lt;em&gt;Arduino Extreme&lt;/em&gt; and the current &lt;em&gt;Arduino UNO R3&lt;/em&gt;), while other improvements have been made. For changes between the UNO R2 and R3, please see &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-uno-faq&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO FAQ at adafruit&lt;/a&gt; (link provided by &lt;strong&gt;jfpoilpret&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is thus reasonable to me that keeping the USB jack was a deliberate design decision: Improve if possible, but keep the layout changes to a minimum and allow for maximum backwards compaptibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;But again, this is just the guess of a user!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="89" LastEditorUserId="89" LastEditDate="2014-12-25T18:02:02.613" LastActivityDate="2014-12-25T18:02:02.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6688" PostTypeId="2" ParentId="6647" CreationDate="2014-12-25T15:07:24.330" Score="5" Body="&lt;p&gt;This camera module requires the use of additional hardware, as the camera and Arduino operating frequencies differ, which can result in loss of synchronization and changes to the image, and other connection problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, we must use an integrated circuit intermediary, making the connection between the camera and the Arduino. The function of this chip is to receive the camera information, store them and then send them to the Arduino using the digital doors, much faster than if we used the serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of an integrated circuit that could be used is AL422, suitable for treating a video signal, which also is embedded in &lt;strong&gt;some&lt;/strong&gt; OV7670 modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking like the connection pins behave in 7670, your module should be equal to it. So spare pins to be able to make other necessary connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/c40y9.jpg&quot; alt=&quot;7670 with AL422 pin&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would better check the connection through the datasheets:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.openimpulse.com/blog/document-viewer/?pdf_file=OV7670-CMOS-VGA-Camera-Datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;7670 datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.openimpulse.com/blog/document-viewer/?pdf_file=AL422-FIFO-Datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;AL422 datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://nicolasfley.fast-page.org/?page_id=35&quot; rel=&quot;noreferrer&quot;&gt;An example of project&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to answer your question; You'll need to purchase a piece more if you don't have AL442.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&lt;/p&gt;&#xA;" OwnerUserId="6301" LastActivityDate="2014-12-25T15:07:24.330" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6689" PostTypeId="1" CreationDate="2014-12-25T21:24:41.277" Score="3" ViewCount="528" Body="&lt;p&gt;I'm new in robotics. I bought a mini robot ( &lt;a href=&quot;http://www.jameco.com/Jameco/Products/ProdDS/2150619.pdf&quot; rel=&quot;nofollow&quot;&gt;Link&lt;/a&gt; ), which i rebuilt a little. Now it has legs and arms. This little robot has 4 little servos (&lt;a href=&quot;http://www.jameco.com/1/1/3861-rs001a-dagu-micro-servomotor-8g-1-5kg-cm.html&quot; rel=&quot;nofollow&quot;&gt;Link&lt;/a&gt;). There are two wheels attached to two of these servos. I'd like to spin them, so the robot will &quot;roll&quot;, but unfortinatly it is trickier than i tought. The servos can rotate in 360 degrees(i can manually turn them), no problem with that. The problem is, that no matter how i try, the servo will turn only 180 degrees. So obviously i am making something wrong. If i write &lt;code&gt;myServo.write(0)&lt;/code&gt; the servo rotates 180 degrees, and if i write &lt;code&gt;myServo.write(180)&lt;/code&gt;, the servo rotates 180 degrees but in the other direction. How can i make it spin in only one direcvtion(360 degrees, more than 360 degrees)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="6401" LastActivityDate="2014-12-25T21:24:41.277" Title="How to rotate a servo continuously?" Tags="|arduino-mega|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6690" PostTypeId="1" AcceptedAnswerId="6691" CreationDate="2014-12-25T21:50:25.157" Score="6" ViewCount="2923" Body="&lt;p&gt;On an embedded system we use global variables often to keep dynamic memory consumption on heap and stack low. But global variables are also considered bad programming practice if they aren't used in a global sense, i.e. they are used only inside one or two functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I really want to make use of the possibilites to protect my code from myself. Of course, the instantiation mechanism of c++ is to avoid on an embedded system with low resources, like an arduino. So I write classes with static members (and member functions) only. Many of the libraries shipped with arduino seem to work this way, too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm curious if there's a single drawback of moving static variables or even const arrays (designed for deposit in progmem) from global namespace to a class namespace and making them private? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm primarily interested in drawbacks arising from the combination of OOP with the arduino platform (using an arduino uno) with avr-gcc. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="37523" LastEditDate="2019-11-26T20:11:41.140" LastActivityDate="2019-11-26T20:11:41.140" Title="What are the benfits of global variables over static class members?" Tags="|programming|c++|variables|progmem|avr-gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6691" PostTypeId="2" ParentId="6690" CreationDate="2014-12-25T22:06:17.890" Score="3" Body="&lt;p&gt;I can see no specific drawback in using static class members instead of global variables on Arduino. They will be managed the same in the end program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference I can see may arise based on how you design your classes (if design is correct, then no special problem shall arise):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's suppose you decale a class A:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class A {&#xA;    public:&#xA;    void f();&#xA;    void g();&#xA;    ...&#xA;    static void z();&#xA;&#xA;    private:&#xA;    static int myStaticField;&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you need an instance of &lt;code&gt;A&lt;/code&gt; for method &lt;code&gt;f()&lt;/code&gt;, which does not need &lt;code&gt;myStaticField&lt;/code&gt;, then that field exists anyway in your SRAM space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is a corner-case, as in good OOD, &lt;code&gt;myStaticField&lt;/code&gt; should be needed as soon as you need to work with class A (whatever method youwant to use).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2014-12-25T22:06:17.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6692" PostTypeId="1" CreationDate="2014-12-25T22:32:52.967" Score="0" ViewCount="4186" Body="&lt;p&gt;I am using a SEEED SD Card Shield. Everytime I attempt to write the card, I get&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Using File&gt; Examples&gt; SD &gt; CardInfo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;initialization failed. Things to check:&#xA;* is a card is inserted?&#xA;* Is your wiring correct?&#xA;* did you change the chipSelect pin to match your shield or module?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or when using File&gt;Examples&gt; SD&gt; Files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Initializing SD card...initialization failed!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I even tried SdFat (IDE couldn't find anything), the &quot;SD Library&quot; by Adafruit (No change), and other things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a Funduino MEGA 2560. Could that be the problem?!&lt;/p&gt;&#xA;" OwnerUserId="4755" LastActivityDate="2017-01-29T06:17:57.333" Title="SD Initialization Failing" Tags="|arduino-mega|shields|sd-card|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6694" PostTypeId="2" ParentId="6679" CreationDate="2014-12-25T22:46:43.283" Score="1" Body="&lt;p&gt;Try with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;    Servo myservo;&#xA;&#xA;    void setup() &#xA;    { &#xA;      myservo.attach(11);&#xA;&#xA;    } &#xA;&#xA;    void loop() &#xA;    { &#xA;        delay(2000);&#xA;        myservo.write(50);&#xA;        while(1);&#xA;    }  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and let us know.&#xA;But more important: disconnect the servo +5V wire from Arduino and use another power supplier!!!&lt;/p&gt;&#xA;" OwnerUserId="6330" LastActivityDate="2014-12-25T22:46:43.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6696" PostTypeId="1" AcceptedAnswerId="6699" CreationDate="2014-12-26T11:18:28.207" Score="4" ViewCount="15937" Body="&lt;p&gt;I am trying to make the photoresistor work in a simple project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The project is as follows:&#xA;The LED light should light up brighter and brighter as the photoresistor reads less light in the room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem:&#xA;The reading is fixed on 1023. Therefore the LED never lights up. I cannot understand why.. Sometimes if I cover the sensor the readings go down to 900- 950 but never less even though it is completely dark around the sensor. Is there something wrong in the code? What could have gone wrong?&#xA;Please note that the resistor connected to the sensor is 10k Ohm as is the one connected to the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int photoPin = 0;&#xA;int pReading; // analog readings&#xA;&#xA;int LED = 11; // red LED connected to pin 11&#xA;int LEDbrightness; //&#xA;&#xA;void setup() &#xA;{&#xA;  //set up the serial connection&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  pReading = analogRead(photoPin);&#xA;  Serial.print(&quot;Photocell reading = &quot;);&#xA;  Serial.println(pReading); // Analog reading&#xA;&#xA;  pReading = 1023 - pReading;&#xA;  //map 0-1023 to 0-255&#xA;  LEDbrightness = map(pReading, 0, 1023, 0, 255);&#xA;&#xA;  analogWrite(LED, LEDbrightness);&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the connections&#xA;&lt;img src=&quot;https://i.stack.imgur.com/cQpgX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you!&lt;/p&gt;&#xA;" OwnerUserId="3546" LastActivityDate="2014-12-26T11:45:14.507" Title="Photoresistor is not working, is there something wrong in the code?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6697" PostTypeId="1" AcceptedAnswerId="6708" CreationDate="2014-12-26T11:34:31.170" Score="2" ViewCount="3160" Body="&lt;p&gt;I have tried to use Arduino Uno with RFID-RC522 module. It is good work[1] and read rfid cards. But Arduino Yun doesn't work with RFID-RC522 module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is diffrent Uno and Yun?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- &lt;a href=&quot;http://www.grantgibson.co.uk/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.grantgibson.co.uk/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6405" LastActivityDate="2015-12-09T20:26:33.260" Title="Arduino Yun RFID-RC522 module not working" Tags="|arduino-uno|arduino-yun|rfid|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6698" PostTypeId="2" ParentId="6696" CreationDate="2014-12-26T11:44:42.277" Score="0" Body="&lt;p&gt;Your wiring is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Analog inputs are high impedance and probably the impedance isn't really linear. So what voltage do you expect on your analog input, if its inner impedance is one or more orders of magnitude greater than that of your sensor and series resistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The inner impedance builds up the lower part of a voltage divider and your sensor and series resistor the upper part. The voltage measured will almost anytime almost 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this?&#xA;You will have to make a suitable voltage divider outside your arduino. Simly connect your input via another resistor to ground. So, how to determine the right value of the additional resistor? It strongly depends on your sensor and the brightness range you want to perceive. I recommend starting with 1kΩ. Let us know, &#xA;what your readings are for full light and darkness. Then we can give some more hints. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2014-12-26T11:44:42.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6699" PostTypeId="2" ParentId="6696" CreationDate="2014-12-26T11:45:14.507" Score="8" Body="&lt;p&gt;The code looks OK. It looks like it's your circuit which is the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main role of a photoresistor is to restrict the amount of &lt;strong&gt;current&lt;/strong&gt; flowing through it when the light level is reduced. It won't directly affect voltage the way you're expecting (the analog pins respond to voltage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it's pretty easy to make it affect voltage with a slightly different circuit. Try creating a &lt;strong&gt;voltage divider&lt;/strong&gt; circuit, such that the supply voltage (5V) goes through the photoresistor, then through another resistor, and then to ground. The Arduino's analog pin should be connected between the photoresistor and resistor. (See the image below, although the resistor on the output probably isn't necessary in this case.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should cause the voltage on the analog pin to decrease when the light level decreases. You may need to experiment a little to find a suitable resistor value on the ground connection, although 2K Ohms is probably a good starting point. It basically affects the sensitivity of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GpQSC.jpg&quot; alt=&quot;Photoresistor circuit diagram&quot;&gt;&#xA;&lt;sub&gt;Image credit: Morteza Lahijanian (&lt;a href=&quot;http://www.bu.edu/gk12/morteza/lesson3.html&quot; rel=&quot;noreferrer&quot;&gt;source&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2014-12-26T11:45:14.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6700" PostTypeId="1" CreationDate="2014-12-26T09:34:35.870" Score="-1" ViewCount="1737" Body="&lt;p&gt;I'm using an HLK-RM04 WIFI shield and arduino uno R3 board. whenever I mount my shield on the uno board and connect it to the pc using a usb only the power led(red) of my wifi shield glows. I tried to upload the example code on wifi(provided by arduino)but whenever I run the code it shows &quot;wifi shield not present&quot;. Looking into the previous discussions on this website I even tried to connect my arduino with usb+9v supply. In that case my trackpad of the laptop ceases to work. whenever I power my system(arduino+shield) using a 9v external supply all the 3 leds(power,link,wan led) on my wifi shield glow but still the same error of &quot;wifi shield not present&quot; persists. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone configured an HLK-rm04 wifi shield with uno r3 before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;" OwnerDisplayName="bel project" LastActivityDate="2015-03-21T17:05:25.010" Title="arduino wifi shield not present error" Tags="|wifi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6701" PostTypeId="2" ParentId="6692" CreationDate="2014-12-26T14:41:34.613" Score="2" Body="&lt;p&gt;I also use a Seeed Studio SD Shield, and used to have the same problem. To rectify this I have to insert the SD card into my PC and Format it. This almost always helped. If you have a card that has too large of storage, the Arduino will take too much time to check the full memory for information stored on it (initialize). Some SD card readers require a card of 2 gigabytes or less to work. Check the Data Sheet for this limit (if there is one). That should do it for you.&lt;/p&gt;&#xA;" OwnerUserId="6406" LastActivityDate="2014-12-26T14:41:34.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6702" PostTypeId="1" CreationDate="2014-12-26T15:23:37.673" Score="4" ViewCount="42577" Body="&lt;p&gt;I have an Arduino Pro Micro clone that seems to be in some sort of reset loop. The RX LED is flickering very fast and very dim. The power LED also seems to flicker at the same frequency but has normal brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is not recognized by the PC at all anymore. It was working fine before. It doesn't matter if I try to go into the bootloader, by pressing reset twice, or not. Nothing happens. It feels like it is constantly resetting. The flickering stops if the reset pin stays connected to GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another clone from the same shipment is still working fine. Both running the blink sketch. Just this one started to malfunction all of the sudden - after probing the pin I set in the blink sketch with my multimeter to see if the flashing was a success.&lt;/p&gt;&#xA;" OwnerUserId="6408" LastEditorUserId="6408" LastEditDate="2017-02-04T22:09:48.690" LastActivityDate="2017-02-20T23:23:18.130" Title="Arduino Pro Micro clone not recognized, flickering RX LED" Tags="|arduino-pro-micro|reset|" AnswerCount="7" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="6704" PostTypeId="2" ParentId="6631" CreationDate="2014-12-26T16:00:19.340" Score="1" Body="&lt;p&gt;First, let's find, what's wrong with your method. You try to poll the signal pins continously and write them out to serial. Default serial rate is 9600. Which means, that you can transmit approx. 900 characters per second. Looking at your oscillogram we can tell, that the signal you want to analyse has a base clock of roughly 2.5 kHz. Which means you definitely won't be able to sample every change of level with your method. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can in fact use the &lt;code&gt;loop()&lt;/code&gt; function to listen for changes, i.e. poll the signal, when you increase your serial baud rate. But I suggest using interrupts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is a three step process.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;get the signal thoroughly recorded with all relevant information about the signal. This includes transmission to your PC via serial interface.&lt;/li&gt;&#xA;&lt;li&gt;Analyse the signal offline. i.e. after having it received on your PC&lt;/li&gt;&#xA;&lt;li&gt;Adapt your arduino code to decode it further before transmitting it to your PC&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;let's get to part 1):&#xA;read &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;Arduino documentation on interrupts&lt;/a&gt;&#xA;the interrupt allows you to prevent interference of your two tasks (reading the inputs and writing to serial).&#xA;What is the interesting information? I think it's the waveform (i.e. the signal in best resolution you can deliver). You can sample your waveform at a high rate, but the resulting data volume will overwhelm your serial output. Fortunately your signal has some obvious characteristics. Which are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;obeys some timing (i.e. a clock)&lt;/li&gt;&#xA;&lt;li&gt;has a limited transmission length (protocol frame)&lt;/li&gt;&#xA;&lt;li&gt;has a limited transmission rate (as can be seen from oscillograph)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The best way to keep as much of the signal information by reducing the amount of serial transmission is to record the time of every level change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updates: buffer used, buffered output after receiving timeout&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RECVTIMEOUT 2000 // we think, more than 2000 usec is end of transmission&#xA;#define MAXEVENTS 100    &#xA;&#xA;uint8_t inpin=2;&#xA;volatile unsigned long timestart=0;&#xA;uint8_t transmitLevel=LOW;&#xA;&#xA;volatile uint8_t state=0; // little state machine: 0=nothing happened yet, 1=receiving data, 2=receiving timeout&#xA;volatile uint16_t tstamps[MAXEVENTS]; // we store timestamps of received symbols here&#xA;volatile uint16_t levels[MAXEVENTS]; // we store levels of received symbols here&#xA;volatile uint8_t index=0; // we save index of data here.&#xA;uint8_t count=0; // counter for later use.&#xA;&#xA;volatile bool conflict=false; // will be set, if transmission conflicts with receive function.&#xA;&#xA;void pinchange() // the ISR (interrupt service routine)&#xA;{&#xA;    switch(state)&#xA;    {&#xA;    case 0:       &#xA;       timestart=micros();&#xA;       tstamps[index]=0;&#xA;       levels[index]=digitalRead(inpin);&#xA;       state=1;&#xA;       ++index;&#xA;    break;&#xA;    case 1:&#xA;       tstamps[index]=micros()-timestart;&#xA;       levels[index]=digitalRead(inpin);&#xA;       ++index;&#xA;    break;&#xA;    case 2:&#xA;       conflict=true;&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(115200); // high serial rate. don't forget to set the same in your IDE&#xA;    attachInterrupt(0, &amp;amp;pinchange, CHANGE); // the controller needs to know, where your ISR is.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    switch(state)&#xA;    {&#xA;    case 1:&#xA;       if (index &amp;gt; 20)&#xA;       {&#xA;          if (micros()-timestart &amp;gt; RECVTIMEOUT)&#xA;          {&#xA;             state=2;&#xA;          }&#xA;       }&#xA;       if (index &amp;gt;= MAXEVENTS)&#xA;       {&#xA;          state=2;&#xA;       }&#xA;&#xA;    break;&#xA;    case 2:   &#xA;       for (count=0; count&amp;lt;index; ++count)&#xA;       {&#xA;         Serial.print(tstamps[count]);&#xA;         Serial.print(&quot;;&quot;);&#xA;         Serial.println(levels[count]);&#xA;       }&#xA;       if (conflict)&#xA;       {&#xA;         Serial.println(&quot;too less time to send data&quot;);&#xA;       }&#xA;       index=0;&#xA;       conflict=0;&#xA;       state=0;&#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should output a fine csv with all your signal edges in microseconds, which you can paste directly to your favourite spreadsheet application. This is only for one signal. For analysing both, you have to enhance it accordingly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;part 2)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;from the gained data of our previous code version (snippet for brevity)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time signal timedifference&#xA;2614592 0   468&#xA;2615056 1   464&#xA;2615524 0   468&#xA;2616496 0   972&#xA;2616960 1   464&#xA;2617956 0   996&#xA;2618960 1   1004&#xA;2620424 1   1464&#xA;2621352 1   928&#xA;2622324 1   972&#xA;2623320 0   996&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;we can see two things.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The code in my first version of the answer didn't work properly. Every 1 should be followed by a 0 in column 2 and vice versa. This is apparently not true, which leads us to the conlusion, that we missed some events. &lt;/li&gt;&#xA;&lt;li&gt;time differences seem to be multiples of roughly 470 μs. We can consider this as the length of a symbol.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So what's wrong with the code? I used noInterrupts() to stop Interrupts for copying the data. I hoped, there won't be level changes in this short period of time, but apparently this was not true. How to fix it? We better find another way to register the events and transfer them. &#xA;I recommend sticking to the interrupt technique, but changing the way we store the events and reading it out. Let's use a buffer big enough for all events of a transmission. After a transmission we can send all data without hassle via serial to the PC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can we expect? 0s and 1s should be transmitted alternating, with reasonable timings. If we can prove this, we can change the main loop again for decoding code 39.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;part 3)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write code which stores a word of code 39 in a buffer&lt;/li&gt;&#xA;&lt;li&gt;another code which decodes that word into a byte when the buffer is full&lt;/li&gt;&#xA;&lt;li&gt;transmit that byte via serial&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(many improvements possible).&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2014-12-30T20:15:19.703" LastActivityDate="2014-12-30T20:15:19.703" CommentCount="8" CommunityOwnedDate="2014-12-29T23:40:09.253" ContentLicense="CC BY-SA 3.0" />
  <row Id="6705" PostTypeId="1" CreationDate="2014-12-26T16:36:19.267" Score="3" ViewCount="5268" Body="&lt;p&gt;I have &lt;a href=&quot;http://www.dx.com/p/433mhz-wireless-transmitter-module-superregeneration-for-arduino-green-149254#.VJ2MwF4AQ&quot; rel=&quot;nofollow&quot;&gt;this cheap RF link&lt;/a&gt; that I had working with the Arduni UNO, but I wanted to make it smaller and ATTiny85 should do the trick. The RF module is connected (data pin) to PB3 on the ATTiny. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am having some problems. It does not work, and I don't know why. My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;// PINS&#xA;#define SERIAL_TX PB3&#xA;&#xA;SoftwareSerial mySerial(-1, SERIAL_TX);&#xA;&#xA;void setup() {&#xA;  pinMode(SERIAL_TX, OUTPUT);&#xA;  mySerial.begin( 1200 );&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  mySerial.write(0xAA);&#xA;  mySerial.write(0xAA);&#xA;  mySerial.write(0xAA);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2964" LastEditorUserId="630" LastEditDate="2014-12-26T19:43:05.143" LastActivityDate="2014-12-26T19:43:05.143" Title="Attiny85 and 433Mhz RF" Tags="|attiny|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6706" PostTypeId="2" ParentId="6705" CreationDate="2014-12-26T17:00:20.617" Score="2" Body="&lt;p&gt;The code you presented does not fit for working with the RF 433Mhz. I'm not sure what you think this code should do, but this is not the way to go with a 433Mhz transmitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using a dedicated library for transmitting information using the 433. There are many libraries out there for doing that; two popular libraries would be the &lt;a href=&quot;https://github.com/cano64/ManchesterRF&quot; rel=&quot;nofollow&quot;&gt;ManchesterRF&lt;/a&gt; and the &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/VirtualWire/&quot; rel=&quot;nofollow&quot;&gt;VirtualWire&lt;/a&gt;, both includes code samples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;a href=&quot;https://github.com/cano64/ManchesterRF/blob/master/examples/ManchesterTX_Byte/ManchesterTX_Byte.ino&quot; rel=&quot;nofollow&quot;&gt;sending data with ManchesterRF&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ManchesterRF.h&quot; //https://github.com/cano64/ManchesterRF&#xA;&#xA;#define TX_PIN 3 //any pin can transmit&#xA;#define LED_PIN 13&#xA;&#xA;ManchesterRF rf(MAN_4800); //link speed, try also MAN_300, MAN_600, MAN_1200, MAN_2400, MAN_4800, MAN_9600, MAN_19200, MAN_38400&#xA;&#xA;uint8_t data = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(LED_PIN, OUTPUT);  &#xA;  digitalWrite(LED_PIN, HIGH);&#xA;  rf.TXInit(TX_PIN);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  rf.transmitByte(++data, data*data);&#xA;  digitalWrite(LED_PIN, digitalRead(LED_PIN)); //blink the LED on receive&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, &lt;a href=&quot;http://nerdralph.blogspot.co.il/2014/04/attiny85-as-433mhz-transmitter-fail.html&quot; rel=&quot;nofollow&quot;&gt;there&lt;/a&gt; &lt;a href=&quot;http://pidome.wordpress.com/manual-howtos/pidome-hardware/attiny85-433mhz-transmitter-with-i%C2%B2c/&quot; rel=&quot;nofollow&quot;&gt;are&lt;/a&gt; &lt;a href=&quot;http://labalec.fr/erwan/?p=1520&quot; rel=&quot;nofollow&quot;&gt;many&lt;/a&gt; other blogs around going step-by-step how to use 433Mhz Tx/Rx with ATtiny85, google is your friend :)&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-26T17:00:20.617" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6707" PostTypeId="1" AcceptedAnswerId="6719" CreationDate="2014-12-26T17:53:50.320" Score="0" ViewCount="254" Body="&lt;p&gt;I am thinking about buying a gps module for Arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to install it on a self-build RC-car which is also controlled by Arduino.&#xA;The problem is, I cannot install the gps module on the top of the car (on the surface), only the bottom and or/middle space is &quot;free&quot;. &#xA;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)Is there a module which can overcome a small layer of steel (max 2cm thick) and some plastic and still get a good signal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)It would be nice to be able to store the data into a memory card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3)It would be a great plus to be able to gather data real-time through some kind of connection. Sadly I do not know how to do here. Is there some place where I can look up any of this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think that this &lt;a href=&quot;http://www.adafruit.com/products/1272&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/1272&lt;/a&gt; is what I need?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you&lt;/p&gt;&#xA;" OwnerUserId="3546" LastActivityDate="2014-12-28T00:34:28.613" Title="Arduino UNO GPS module" Tags="|arduino-uno|gsm|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6708" PostTypeId="2" ParentId="6697" CreationDate="2014-12-26T18:20:51.980" Score="4" Body="&lt;p&gt;According to the link you provided, we can see that the RFID-RC522 uses SPI to communicate with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino UNO, the SPI pins are located as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pin 11: MOSI,&lt;/li&gt;&#xA;&lt;li&gt;pin 12: MISO, &lt;/li&gt;&#xA;&lt;li&gt;pin 13: SCK&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the Arduino YUN, this is different though; as stated &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow noreferrer&quot;&gt;there&lt;/a&gt; (bold highlight is mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SPI: on the ICSP header. These pins support SPI communication using&#xA;  the SPI library. &lt;strong&gt;Note that the SPI pins are not connected to any of&lt;/strong&gt;&#xA;  &lt;strong&gt;the digital I/O pins as they are on the Uno&lt;/strong&gt;, They are only available&#xA;  on the ICSP connector. This means that if you have a shield that uses&#xA;  SPI, but does NOT have a 6-pin ICSP connector that connects to the&#xA;  Yún's 6-pin ICSP header, the shield will not work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hence you can not wire the RFID-RC522 module the same on UNO and Yun.&#xA;For the Yun, you'll have to follow this wiring picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1WZQo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 1 in image above is the pin that is marked with a dot on the Yun PCB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see the ISP-header layout, at the lower-right corner of the &lt;a href=&quot;http://www.element14.com/community/servlet/JiveServlet/showImage/38-18269-212515/yun_by_pighixxx-d6qvbq4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;yun_by_pighi&lt;/a&gt; Yun pinout diagram.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="3917" LastEditDate="2015-12-09T20:26:33.260" LastActivityDate="2015-12-09T20:26:33.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6709" PostTypeId="1" CreationDate="2014-12-26T12:43:19.303" Score="2" ViewCount="807" Body="&lt;p&gt;I'm designing a shield for Arduino which drives two stepper motors. They are small and require 5V but their max combined current is around 1A, way too much for the USB supply. Therefore I will have external 5V power supply connected to my shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entire device will usually operate being connected to a PC through USB, but still I'd like to have a possibility to run it separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is: how to power Arduino itself?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;From my external PSU through the pins: Sounds as the simplest solution but I'm bit worried about the onboard regulator of Arduino while reverse powered.&lt;/li&gt;&#xA;&lt;li&gt;Separate power circuits for electronics and motor: My L293D chips allow for separate power and even different voltage for the motors. It could even be an advantage for my shield, as I could use other motors and different power for them in the future. I will, however, lose the possibility of running the device without USB connection.&lt;/li&gt;&#xA;&lt;li&gt;Same as above with additional barrel jack power connection to supply Arduino when USB is disconnected. This, however, could fail with 5V supply, because of the voltage drop of the regulator which handles power coming from barrel jack.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerDisplayName="emes" LastEditorUserId="83" LastEditDate="2015-01-15T18:32:18.507" LastActivityDate="2015-08-05T02:13:39.040" Title="Powering Arduino from a shield" Tags="|power|shields|hardware|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6710" PostTypeId="2" ParentId="6709" CreationDate="2014-12-26T13:25:15.033" Score="2" Body="&lt;p&gt;Option 1 is by far the simplest. Just have one 5V power supply for everything.  Make sure you have enough capacitance on there to absorb the noise of the motors - maybe separate the digital side from the drive side with an inductor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add a diode connected backwards between the 5V and VIN pins to bypass the regulator when reverse powered.  That is, anode to 5V and cathode to VIN.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2014-12-26T13:25:15.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6711" PostTypeId="1" CreationDate="2014-12-27T05:41:30.250" Score="2" ViewCount="245" Body="&lt;p&gt;I have two Arduino Due boards. I would like to connect one to my computer through the programming port as USB Serial so that I can send it commands, but I would like it to also be able to communicate to a second Arduino Due as the host on the native USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see in the manual that it has drivers for acting as a host to USB Mice and Keyboards, but is having it load appropriate drivers for communicating with another Due doable? I've done plenty with the USB ports, but never as a host so I'm not really sure how to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to have one &quot;master&quot; Due connected to the computer that controls a complicated piece of equipment with a lot of supporting electronics, and a second &quot;peripheral&quot; Due that acts as an interface for the user. The master would accept commands either from the computer, or from the peripheral. Reason is that the peripheral has to have fast interrupts to handle rotary encoders and the like (the &quot;master&quot; Due is quite busy so those interrupts can be troublesome) and be physically located in a different place.&lt;/p&gt;&#xA;" OwnerUserId="6416" LastActivityDate="2014-12-27T05:41:30.250" Title="Daisy Chaining USB Communication over Arduino Due" Tags="|arduino-due|usb|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6712" PostTypeId="1" AcceptedAnswerId="6713" CreationDate="2014-12-27T08:55:41.453" Score="8" ViewCount="17840" Body="&lt;p&gt;I want to use SoftwareSerial with my ATTiny85 and when I google it several projects claim that they are using it... I downloaded the hardware from &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot;&gt;https://code.google.com/p/arduino-tiny/&lt;/a&gt;, but when I try to add SoftwareSerial and compile I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fatal error: SoftwareSerial.h: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Switching the board to UNO makes the problem go away, so did they leave it out? How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="2964" LastEditorUserId="2964" LastEditDate="2014-12-27T10:42:37.230" LastActivityDate="2018-03-06T12:06:14.857" Title="Is SoftwareSerial left out for the ATTiny85/84?" Tags="|serial|attiny|softwareserial|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6713" PostTypeId="2" ParentId="6712" CreationDate="2014-12-27T10:54:08.693" Score="6" Body="&lt;p&gt;Short answer - no. It's not left out, on the contrary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But before addressing to the compiler error you mentioned, a small clarification:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I downloaded the hardware from &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-tiny/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The link you provided is not &lt;em&gt;hardware&lt;/em&gt;, but &lt;em&gt;software&lt;/em&gt; called the &lt;strong&gt;ATtiny core files&lt;/strong&gt;. It contains the necessary files that will help you compile and upload code from Arduino IDE to the ATtiny (even when using ArduinoISP as programmer). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;SoftwareSerial&lt;/strong&gt; is a library that comes with the Arduino IDE zip/installation. If you have downloaded the latest version of Arduino IDE from the &lt;a href=&quot;http://arduino.cc/en/main/software&quot; rel=&quot;nofollow&quot;&gt;Arduino Website&lt;/a&gt;, you should be able to find the SoftwareSerial library files located at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Path to Arduino installation folder]\libraries\SoftwareSerial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example for SoftwareSerial library files you should expect to find there are &lt;strong&gt;SoftwareSerial.cpp&lt;/strong&gt; and &lt;strong&gt;SoftwareSerial.h&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fatal error: SoftwareSerial.h: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The compiler error you receive seems to imply that the compiler cannot find the header file (SoftwareSerial.h) for SoftwareSerial library. This indeed seems quite odd, since this library does not require any special installation, and as mentioned, is part of the libraries that are built into the Arduino IDE installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to mitigate this, I would recommend that you will:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure the library folder exists in the location mentioned above&lt;/li&gt;&#xA;&lt;li&gt;If it doesn't, then you should probably re-download the Arduino IDE installation, and after that install the ATtiny core files as per the instructions (important!). Installation instructions are located in the &lt;strong&gt;README&lt;/strong&gt; file inside the ATTiny core zip file &#xA;(tiny\avr\README).&lt;/li&gt;&#xA;&lt;li&gt;If it does exist, and you still get this compiler error, then you must have a corrupted installation (perhaps the compiler include folders is messed up). I would still recommend following the re-installation as mentioned in the previous bullet. &lt;/li&gt;&#xA;&lt;li&gt;Make sure that you can find the &lt;strong&gt;ATtiny 85&lt;/strong&gt; in the board list, at Tools-&gt;Board and that it is selected.&lt;/li&gt;&#xA;&lt;li&gt;Another angle that might shed more light on this error, would be to turn on the verbose output for the compiler (you can do it in the Arduino IDE, by choosing File-&gt;Preferences-&gt; &quot;Show verbose output during&quot; and checking &quot;compilation&quot;). Verbose output can help you track down any compiler command line errors, like missing include folders. &lt;/li&gt;&#xA;&lt;li&gt;Last but not least, if the SoftwareSerial folder exist, you could use the Arduino IDE to check if the IDE can identify its existance, by going to Sketch-&gt;Import Library, and looking for &lt;em&gt;SoftwareSerial&lt;/em&gt;. If it's not there, then the folder is not located properly under the 'libraries', verify the path as mentioned above (did you move it?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally, when you will be able to compile your code, try using the SoftwareSerial example that comes with the library to check it. Note that it is not going to work 'out-of-the-box' as with the Arduino Uno; The ATtiny does not have the same FTDI hardware for communicating directly with USB, so for sending and receiving serial messages using the ATtiny you will have to either use the Arduino Uno as a proxy (using the Uno's pins 0 &amp;amp; 1) or to use dedicated USB to Serial hardware similar to &lt;a href=&quot;https://www.sparkfun.com/products/9716&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Switching the board to UNO makes the problem go away&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As a side note, switching to the Uno will make most ATtiny problems 'go away' since the Uno is much more equipped than ATtiny85/4, both on the MCU level and on the breakout board level, which you get with the Uno (and which you don't get when working directly with a chip like ATtiny). Also, most of the code base out there is targeting the Uno and not ATTiny.&#xA;So if you are doing your first steps with the ATtiny, be prepared that many things that 'just worked' with the Uno will require extra/different code before they could work with the ATtiny (and some won't work at all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use my simple Analog to Serial code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;Takes an input on the AtTiny85 from the VERY TRICKY analogue input pin 2 (as labeled in HLT tutorial)&#xA; and outputs these with Software serial to the arduino uno, or Duemillanove&#xA; Hookup&#xA; ATTINY85 pin 3 -&amp;gt; Arduino Uno pin 0&#xA; ATTINY85 pin 4 -&amp;gt; Arduino Uno pin 1&#xA;&#xA;http://www.instructables.com/id/Easy-ATTiny-Serial-Communication-with-Tiny-AVR-Pro/&#xA; */&#xA;&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// Definitions&#xA;#define rxPin 4&#xA;#define txPin 3&#xA;SoftwareSerial mySerial(rxPin, txPin);&#xA;int sensorPin = 7; //ACTUALLY PIN LABELED AS &quot;2&quot; on the HLT tutorial&#xA;int sensorVal = -1;&#xA;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  pinMode(sensorPin, INPUT);&#xA;  mySerial.begin(9600);&#xA;analogWrite(0,1); // This is kind a heart beat to show the ATTINY is &quot;alive&quot;&#xA;}&#xA;&#xA;// the loop routine runs over and over asensorpingain forever:&#xA;void loop() {&#xA;  sensorVal = analogRead(sensorPin);&#xA;  mySerial.print(&quot;Input Val: &quot;);&#xA;  mySerial.print(sensorVal);&#xA;  mySerial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="4951" LastEditDate="2015-02-20T21:34:20.540" LastActivityDate="2015-02-20T21:34:20.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6714" PostTypeId="1" AcceptedAnswerId="6717" CreationDate="2014-12-27T12:11:19.427" Score="1" ViewCount="81" Body="&lt;p&gt;Im starting to get into Arduino a little. Ive got a Small project to start me off,&#xA;To keep it simple its: 5 level Switches, 1 flow switch and 3 solenoid valves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question is for the Level Switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now Im wanting to save Pins as I'm using a Arduino UNO. &#xA;So would I be right to use the method ive seen around here a few times of Making a Resistance  ladder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question is. 1- Will the method of using the same value of resistors (2k2) work? I dont think so..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As multiple &quot;buttons&quot; ie the flot switches will be pressed at once it will end up having no idea whats happening correct?, I need to be able to Identify each one (0%,25% etc etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I was to use different vales of resistance would that make a difference ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="6420" LastActivityDate="2014-12-27T15:36:59.227" Title="5 Switches 1 AI pin" Tags="|serial|voltage-level|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6715" PostTypeId="1" AcceptedAnswerId="6725" CreationDate="2014-12-27T12:26:25.227" Score="8" ViewCount="13110" Body="&lt;p&gt;For DIY, how to program Arduino Mini Pro to act as an &lt;strong&gt;Audio Frequency White Noise generator&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Presumably, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) using one Digital Output pin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) feed to a simple passive RC low pass filter to reduce out of band signal &lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) feed to a simple class-D IC chip audio amplifier and speaker &lt;/p&gt;&#xA;&#xA;&lt;p&gt;d) since it is DIY and noise, lo-fi (not hi-fi) is good enough. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specific questions,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) How to program?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Wonder if it is better to use to chip act a Pulse Width Modulated 'digital to analogue converter'?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) How to calculate value for RC filter (assume amplifier has high input impedance)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many years ago, I have programmed a hardware sound generator chip as part of a game machine. It has two registers for amplitude and 'frequency' control (band of 'white' noise). It worked very well. I once looked at the output using oscilloscope and it was square wave. I believe that it works, basically, using the above principles. Since I do not have the chip now, I cannot verify it. Now, I would like to duplicate its function using Arduino in software.&lt;/p&gt;&#xA;" OwnerUserId="3219" LastEditorUserId="3219" LastEditDate="2014-12-27T12:38:08.527" LastActivityDate="2022-01-04T18:25:48.673" Title="Audio Frequency White Noise generation using Arduino Mini Pro" Tags="|arduino-pro-mini|audio|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6716" PostTypeId="1" AcceptedAnswerId="6718" CreationDate="2014-12-27T14:44:08.337" Score="0" ViewCount="1418" Body="&lt;p&gt;When I put &quot;c&quot; inside &lt;code&gt;setColor(c);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it tells me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: too few arguments to function 'void setColor(int, int, int)'.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that I should put 3 arguments. What I don't understand is that the serial is correctly displaying the 3 arguments (255, 000, 000) so why it keeps telling me this error. What am I doing wrong ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rPin = 11;&#xA;int gPin = 9;&#xA;int bPin = 10;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(rPin, OUTPUT);&#xA;    pinMode(gPin, OUTPUT);&#xA;    pinMode(bPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;            delay(100);&#xA;            while (Serial.available() &amp;gt; 0) {&#xA;                char c = Serial.read(); // serial will display an rgb code, for exemple: 255, 000, 000 (red color) &#xA;                setColor(c);&#xA;            }&#xA;        }&#xA;}&#xA;&#xA;void setColor(int red, int green, int blue) {&#xA;    analogWrite(rPin, red);&#xA;    analogWrite(gPin, green);&#xA;    analogWrite(bPin, blue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6423" LastActivityDate="2014-12-28T10:01:10.933" Title="too few arguments to function 'void setColor(int, int, int)'" Tags="|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6717" PostTypeId="2" ParentId="6714" CreationDate="2014-12-27T15:36:59.227" Score="2" Body="&lt;p&gt;Just look at &lt;a href=&quot;https://electronics.stackexchange.com/a/99419&quot;&gt;this answer&lt;/a&gt;. When you press the LEFT switch, the SELECT button has no effect when pressed (i.e. it doesn't get detected, but also doesn't hinder detecting the LEFT button press). So in your case, you aren't really interested in the 0% button, when the 25% is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't use same value resistors, as the resulting voltages would be non-linear, making it difficult to differentiate between the button at the far end ladder. If you'd use 2k2 everywhere, the voltages would be&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;100% 0.00v&lt;/li&gt;&#xA;&lt;li&gt;75% 2.50v&lt;/li&gt;&#xA;&lt;li&gt;50% 3.33v&lt;/li&gt;&#xA;&lt;li&gt;25% 3.75v&lt;/li&gt;&#xA;&lt;li&gt;0% 4.00v&lt;/li&gt;&#xA;&lt;li&gt;no value: 5v&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the answer provided above, voltages would be: 0, 0.71, 1.61, 2.47, 3.62, 5v&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-12-27T15:36:59.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6718" PostTypeId="2" ParentId="6716" CreationDate="2014-12-27T18:48:57.203" Score="2" Body="&lt;p&gt;In the context of C/C++, the type &lt;code&gt;char&lt;/code&gt; refers to a primitive type that can contain exactly one byte of information, or 8 bits if you like.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the serial is correctly displaying the 3 arguments (255, 000, 000) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your question, you do not specify how you verify that this is indeed the information that returns from Serial.read. &lt;a href=&quot;http://arduino.cc/en/Serial/read&quot; rel=&quot;nofollow&quot;&gt;Serial.read&lt;/a&gt; returns one byte, which can be cast or parsed to an Integer but cannot be interpreted as the triplet (255,000,000) in no way. If you keep calling it repeatedly, however, as long as there is data (meaning that the result is greater than -1 or &lt;code&gt;Serial.available&lt;/code&gt; returns a number greater than 0) - you can accumulate the characters to a meaningful string, which you can later split to three different &lt;code&gt;int&lt;/code&gt; values. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String incomingData = &quot;&quot;;&#xA;&#xA;void loop() &#xA;{&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;         delay(100);&#xA;         while (Serial.available() &amp;gt; 0) {&#xA;             char c = Serial.read(); &#xA;             incomingData.concat(c);&#xA;         }&#xA;&#xA;         // now, the string incomingData will contain &quot;255,000,000&quot; which you can split into 3 different integers and send to setColor. &#xA;         // so, assuming the format &quot;ddd,ddd,ddd&quot;:&#xA;&#xA;         int color1 = incomingData.substring(0,3).toInt();&#xA;         int color2 = incomingData.substring(4,7).toInt();&#xA;         int color3 = incomingData.substring(8).toInt();&#xA;         setColor(color1, color2, color3);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-28T10:01:10.933" LastActivityDate="2014-12-28T10:01:10.933" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6719" PostTypeId="2" ParentId="6707" CreationDate="2014-12-28T00:34:28.613" Score="0" Body="&lt;p&gt;1) Just break out the headers on the GPS module to make for connections to the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Add a SD expansion slot on top of the GPS Module and break out the pins for those as the required pins for those as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) I am not sure what you are asking exactly, but it seems to me that you want to analyze the data real-time.  Get a network shield and make sure you can SSH into it through another computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: When I say &quot;break out the pins&quot;, I am simply saying either solder on some extra headers, or wires.&lt;/p&gt;&#xA;" OwnerUserId="6427" LastActivityDate="2014-12-28T00:34:28.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6720" PostTypeId="1" CreationDate="2014-12-28T00:48:44.277" Score="2" ViewCount="8021" Body="&lt;p&gt;I understand there are 3 timers on the Arduino UNO.  What specific registers do I need to use to access them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to use these timers to poll different sensors I am using with a ms period. Are there any pre-made libraries out there to do this?  &lt;/p&gt;&#xA;" OwnerUserId="6428" LastEditorDisplayName="user6430" LastEditDate="2014-12-28T14:12:21.330" LastActivityDate="2014-12-28T14:12:21.330" Title="How to attach interrupts to Arduino UNO timers?" Tags="|arduino-uno|interrupt|timers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6721" PostTypeId="2" ParentId="6700" CreationDate="2014-12-28T00:53:14.377" Score="0" Body="&lt;p&gt;I DON'T have experience with the shield you are mentioning, but it sounds to me that no data is being sent from the WiFi shield to the Arduino.  I suggest you do a bit of debugging with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Print Statements&#xA;2) A multimeter (better yet, an oscilloscope)&#xA;3) Check that the pins you are connecting the shield to are not blown&lt;/p&gt;&#xA;" OwnerUserId="6428" LastActivityDate="2014-12-28T00:53:14.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6722" PostTypeId="2" ParentId="6720" CreationDate="2014-12-28T01:34:15.133" Score="1" Body="&lt;p&gt;Timer 0 is use'd by the arduino core libraries for functions like millis(). It is best left alone. Leaving timer1 and 3 are available for general use. Both 1 and 3 have well established libraries, for simple implementation, without the need to know the mechanics under the hood, about the registers and such. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find links and general explanations at &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;timer1&lt;/a&gt;. I always recommend the github versions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you are still wanting to know the details the source is quite readible.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note you don't need 3 timers to read 3 sensors. One timer on a multiple of the the 3, should suffice which can then implement a statemachine to sample at the correct periods.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-12-28T01:34:15.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6723" PostTypeId="1" CreationDate="2014-12-28T03:40:48.887" Score="1" ViewCount="475" Body="&lt;p&gt;I'm trying to create arduino base mind reader... And for that I thought that EEG electrode connected to arduino and then the data send to arduino in 01 form .. But I facing problem in how to convert this or which wave (alpha, beta,delta)give very high or acutrate result.&lt;/p&gt;&#xA;" OwnerUserId="3608" LastActivityDate="2014-12-28T08:14:37.657" Title="how to make arduino as mind thought reader?" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6724" PostTypeId="2" ParentId="6720" CreationDate="2014-12-28T05:55:20.477" Score="2" Body="&lt;p&gt;For the UNO, use Timer1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of the way you can use it is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download the TimerOne library: &lt;a href=&quot;https://code.google.com/p/arduino-timerone/downloads/list&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-timerone/downloads/list&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Timer1 library example&#xA; */&#xA;&#xA;#include &quot;TimerOne.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(10, OUTPUT);&#xA;  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period&#xA;  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle&#xA;  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;  digitalWrite(10, digitalRead(10) ^ 1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // your program here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6429" LastActivityDate="2014-12-28T05:55:20.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6725" PostTypeId="2" ParentId="6715" CreationDate="2014-12-28T06:03:40.830" Score="6" Body="&lt;p&gt;I don't know that you need all that - just an Arduino and a piezo speaker and a pot if you want to play with the volume.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;byte speakerPin = 1;&#xA;&#xA;void generateNoise() {&#xA;  static unsigned long int reg = 0x12345678; //seed&#xA;  unsigned long int newr;&#xA;  unsigned char lobit;&#xA;  unsigned char b31, b29, b25, b24;&#xA;  b31 = (reg &amp;amp; (1L &amp;lt;&amp;lt; 31)) &amp;gt;&amp;gt; 31;&#xA;  b29 = (reg &amp;amp; (1L &amp;lt;&amp;lt; 29)) &amp;gt;&amp;gt; 29;&#xA;  b25 = (reg &amp;amp; (1L &amp;lt;&amp;lt; 25)) &amp;gt;&amp;gt; 25;&#xA;  b24 = (reg &amp;amp; (1L &amp;lt;&amp;lt; 24)) &amp;gt;&amp;gt; 24;&#xA;  lobit = b31 ^ b29 ^ b25 ^ b24;&#xA;  newr = (reg &amp;lt;&amp;lt; 1) | lobit;&#xA;  reg = newr;&#xA;  digitalWrite (speakerPin, reg &amp;amp; 1);&#xA;  delayMicroseconds (50);  // Changing this value changes the frequency.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6429" LastEditorUserId="6628" LastEditDate="2022-01-04T14:23:15.463" LastActivityDate="2022-01-04T14:23:15.463" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="6726" PostTypeId="2" ParentId="6723" CreationDate="2014-12-28T06:09:44.110" Score="3" Body="&lt;p&gt;You could hack an existing device like the Mattel Mind Flex ($20-50 on Ebay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There have been a number of projects that do exactly what you have described - there's even an arduino library: &lt;a href=&quot;https://github.com/kitschpatrol/Brain&quot; rel=&quot;nofollow&quot;&gt;https://github.com/kitschpatrol/Brain&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://frontiernerds.com/brain-hack&quot; rel=&quot;nofollow&quot;&gt;http://frontiernerds.com/brain-hack&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6429" LastActivityDate="2014-12-28T06:09:44.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6727" PostTypeId="2" ParentId="4695" CreationDate="2014-12-28T06:15:36.740" Score="7" Body="&lt;p&gt;I have never found a single pattern repository, however FunkBoxing has a fantastic sketch with 30 or so patterns well documented. &lt;a href=&quot;http://funkboxing.com/wordpress/?p=2154&quot; rel=&quot;noreferrer&quot;&gt;http://funkboxing.com/wordpress/?p=2154&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He uses the Fast_SPI (now FastLED) library, which is truly exceptional!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://plus.google.com/u/0/communities/109127054924227823508&quot; rel=&quot;noreferrer&quot;&gt;https://plus.google.com/u/0/communities/109127054924227823508&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6429" LastActivityDate="2014-12-28T06:15:36.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6728" PostTypeId="1" AcceptedAnswerId="6740" CreationDate="2014-12-28T06:23:29.607" Score="2" ViewCount="480" Body="&lt;p&gt;I have built two parallel H-bridges from &quot;Design 1&quot; &lt;a href=&quot;http://www.talkingelectronics.com/projects/H-Bridge/H-Bridge-1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;on this page&lt;/a&gt; as you can see in the attached schematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I apply the external power (VCC1 in the center of the diagram) the two motors do not spin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using my multimeter, I can see that the entire circuit is working: the motor is getting a 'forward' and 'backward' current as the Arduino sets the pins high. The multimeter is reading +/- 5.54V with the motor replaced by the multimeter. (Across the motor this drops to 0.13V)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I measure the current by putting my multimeter both in series with the motors and replacing the motors. There's only 40mA available! Looking around the web I found the suggestion to reduce the 220Ω resistors at R2, R3, R5 and R6. So I switched in (randomly) 27Ω resistors and the output current is still only 40mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else should I try to bring up the current enough to drive the motors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; So my uneducated guess is that it's likely that the limitation is coming from the transistors. The Ns are BC549 and the Ps are BC559. The datasheets list &quot;low current&quot; as a feature, but I figured that was the collector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2:&lt;/strong&gt; The motor is &lt;a href=&quot;http://www.icstation.com/product_info.php?products_id=2535&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; which requires 70mA when running (and presumably more during startup)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/A3TDL.png&quot; alt=&quot;Schematic of two H-bridges controlled by Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 3:&lt;/strong&gt; Code driving the Arduino:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pin setup&#xA;int pinLeftMotorFwd   = 5;&#xA;int pinLeftMotorBck   = 6;&#xA;int pinRightMotorFwd  = 10;&#xA;int pinRightMotorBck  = 11;&#xA;&#xA;// Directions for the {left, right} motors to achieve the four directions&#xA;int FORWARD[]   = {  1,  1 };&#xA;int BACKWARD[]  = { -1, -1 };&#xA;int RIGHT[]     = { -1,  1 };&#xA;int LEFT[]      = {  1, -1 };&#xA;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;    pinMode(pinLeftMotorFwd,  OUTPUT);&#xA;    pinMode(pinLeftMotorBck,  OUTPUT);&#xA;    pinMode(pinRightMotorFwd, OUTPUT);&#xA;    pinMode(pinRightMotorBck, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    go( FORWARD, 10 );&#xA;    go( RIGHT,    3 );&#xA;    go( FORWARD, 10 );&#xA;    go( LEFT,     6 );  &#xA;}&#xA;&#xA;// Move the bot in a particular direction from the array above for a given number of seconds&#xA;void go ( int dir[], int dur ){&#xA;    leftMotor(  dir[0] );&#xA;    rightMotor( dir[1] ); &#xA;    delay( dur * 1000 );&#xA;}&#xA;&#xA;// Sill both motors (OK, so stop both motors. But stop is a keyword in C)&#xA;void still(){&#xA;    leftMotor(  0 );&#xA;    rightMotor( 0 );&#xA;}&#xA;&#xA;// Set the left motor to Backward (-1), Forward (1), or Stop (0)&#xA;void leftMotor( int dir ){&#xA;    // Pull both pins low&#xA;    digitalWrite(pinLeftMotorFwd, LOW );&#xA;    Serial.println(&quot;pinLeftMotorFwd LOW&quot;);&#xA;    digitalWrite(pinLeftMotorBck, LOW );&#xA;    Serial.println(&quot;pinLeftMotorBck LOW&quot;);&#xA;&#xA;    // If we're going forward, pull the Fwd pin high&#xA;    if( dir == 1 ){&#xA;        digitalWrite(pinLeftMotorFwd, HIGH);&#xA;        Serial.println(&quot;pinLeftMotorFwd HIGH&quot;);&#xA;    }&#xA;&#xA;    // otherwise, pull the Bck pin high&#xA;    else if( dir == -1 ) {&#xA;        digitalWrite(pinLeftMotorBck, HIGH);&#xA;        Serial.println(&quot;pinLeftMotorBck HIGH&quot;);&#xA;    }&#xA;}  &#xA;&#xA;// Set the right motor to Backward (-1), Forward (1), or Stop (0)&#xA;void rightMotor( int dir ){&#xA;    // Pull both pins low&#xA;    digitalWrite(pinRightMotorFwd, LOW );&#xA;    Serial.println(&quot;pinRightMotorFwd LOW&quot;);&#xA;    digitalWrite(pinRightMotorBck, LOW );&#xA;    Serial.println(&quot;pinRightMotorBck LOW&quot;);&#xA;&#xA;    // If we're going forward, pull the Fwd pin high&#xA;    if( dir == 1 ){&#xA;        digitalWrite(pinRightMotorFwd, HIGH);&#xA;        Serial.println(&quot;pinRightMotorFwd HIGH&quot;);&#xA;    }&#xA;&#xA;    // otherwise, pull the Bck pin high&#xA;    else if( dir == -1 ) {&#xA;        digitalWrite(pinRightMotorBck, HIGH);&#xA;        Serial.println(&quot;pinRightMotorBck HIGH&quot;);&#xA;    }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4843" LastEditorUserId="4843" LastEditDate="2014-12-28T22:55:23.287" LastActivityDate="2014-12-28T22:55:23.287" Title="Discrete H-Bridge very low current output" Tags="|motor|current|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6729" PostTypeId="2" ParentId="6468" CreationDate="2014-12-28T06:24:09.247" Score="2" Body="&lt;p&gt;Clearly the 'best' one is the one that meets your requirements (or is the most expensive - that's always the best, right?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say you need an ethernet shield - can you explain why? Without that information, it's almost impossible to tell you which is the most suitable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking at IoT applications, it may be that an Ethernet shield isn't the 'best' thing for you. If you just want access to the local IP network, you could use any of those. If you want the 'best' library of functions to support your application, that may affect which module you use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For me, I think the best module is the cheapest one that gives me connectivity: &lt;a href=&quot;http://www.aliexpress.com/item/Hot-Sale-ENC28J60-Ethernet-LAN-Network-Module-For-Arduino-51-AVR-STM32-LPC/32254842414.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/Hot-Sale-ENC28J60-Ethernet-LAN-Network-Module-For-Arduino-51-AVR-STM32-LPC/32254842414.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The W5100 is also a good choice, but only if it is under $7&lt;/p&gt;&#xA;" OwnerUserId="6429" LastActivityDate="2014-12-28T06:24:09.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6733" PostTypeId="2" ParentId="2887" CreationDate="2014-12-28T07:18:23.653" Score="1" Body="&lt;p&gt;In your first sketch, you have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;int rcvPin = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you mean both those to be assigned to the hardware LED on the Nano? (Pin 13 is the on-board LED). If so, why? With all the pins available to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other thing I don't understand is your use of: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages&#xA;byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will always just be one byte, won't it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not use available()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Serial/available&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Serial/available&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see this was posted six months ago - no doubt you have already solved it.&lt;/p&gt;&#xA;" OwnerUserId="6429" LastActivityDate="2014-12-28T07:18:23.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6734" PostTypeId="2" ParentId="6723" CreationDate="2014-12-28T08:14:37.657" Score="5" Body="&lt;p&gt;Even if the answer provided by Mike is really doable and can be implemented you should really think about what you want to reach and what is your goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The big difference between EEG and mind readers is that the process of thinking, even if you can record all that waves: alpha, gamma,... can be never decoded to get useful informations. I mean: you can record and get a confirm that you have more gamma waves when you are doing meditation. Or that aplha and beta wave are going to be much more present when waking up or in particular hours of the days, but you never get an image of what the person is thinking or what are its emotions... That because you can get some waves coming from the brain but you cannot reconstruct the billion of processes that are happening &lt;em&gt;inside&lt;/em&gt; the brain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of researcher are trying to decoder those informations to move as an example an arm or a leg. But it is the front edge of the reasearch really not doable with an Arduino....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway good luck!&lt;/p&gt;&#xA;" OwnerUserId="6330" LastActivityDate="2014-12-28T08:14:37.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6736" PostTypeId="1" CreationDate="2014-12-28T11:58:38.177" Score="3" ViewCount="5790" Body="&lt;p&gt;I'm trying to read the temperature of a DS18B20 with my ATTiny85 - but I'm getting rubbish data :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should have gotten ~22 degrees, but I'm getting 129! I &lt;a href=&quot;http://www.hobbytronics.co.uk/ds18b20-arduino&quot; rel=&quot;nofollow&quot;&gt;followed this tutorial&lt;/a&gt; i found here, but maybe there is something funky with the ATTiny85?&lt;/p&gt;&#xA;" OwnerUserId="2964" LastActivityDate="2021-08-01T00:06:45.613" Title="Read temperature (DS18B20) with the ATTiny85" Tags="|sensors|attiny|temperature-sensor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6737" PostTypeId="1" CreationDate="2014-12-28T14:24:53.520" Score="2" ViewCount="4629" Body="&lt;p&gt;In the normal case the setup() function will be run once automatically and and then the loop() function will run many times. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to initialize several modules in the setup() function and then in the loop() I want to read values from them periodically. But if the period between usage is long I want to power off the modules. After defined time the modules will be powered on again and need to be initialized. Can I use the already existing setup() function inside the loop() to initialize the modules or I have to write another similar function? Is there any other better way to power off/on sensors and modules during the execution of code.&lt;/p&gt;&#xA;" OwnerUserId="6387" LastActivityDate="2015-12-26T07:20:48.057" Title="Can I use the setup() function inside the loop() function" Tags="|system-design|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6738" PostTypeId="2" ParentId="6737" CreationDate="2014-12-28T15:20:09.283" Score="12" Body="&lt;p&gt;It could be possible, since it is going simply to call the same function &lt;strong&gt;BUT&lt;/strong&gt; it is really a very bad design*.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually the main purpose for a microcontroller is just sitting there and run a procedure or main function repeatedly until the end of the world. And during one loop just to check if some conditions are met.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should never stop or influence your &lt;code&gt;loop()&lt;/code&gt; function and never mess up the default design of the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In you case (but it depends on your code and your application), you just want to run the &lt;code&gt;loop()&lt;/code&gt; once all sensors have been already started (in the &lt;code&gt;setup()&lt;/code&gt; function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your run, you check periodically the sensor and start a timer (better if interrupted). If an amount of time has expired and the sensor should be turned off, then the timer will call another function, which has the only target to switch sensors off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;loop()&lt;/code&gt; runs again and again and if the original condition is met, then you can start your sensors again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save up time and code typing, I suggest you write only ONE function for switching on the sensors and call this function in &lt;code&gt;setup()&lt;/code&gt; and in your &lt;code&gt;loop()&lt;/code&gt;, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void startSensors();&#xA;void stopSensors();&#xA;&#xA;void setup() { &#xA;  startSensors();  // I start all sensors here&#xA;}&#xA;&#xA;void loop() {&#xA;  if( condition?!?! )&#xA;     {&#xA;       ...&#xA;       stopSensors();&#xA;       ...&#xA;     } else {&#xA;       ...&#xA;       startSensors();  // I call the same function here&#xA;       ...&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;*: for istance you define in your &lt;code&gt;setup()&lt;/code&gt; the connection through serial port. This means that your object &quot;serial port&quot; is going to be recreated each time you call &lt;code&gt;setup()&lt;/code&gt; whit undefeined behavior in case it is outputting datas or has same data in the FIFO Buffer. Simply...&lt;code&gt;setup()&lt;/code&gt; has that name because needs to setup things once. Everything that must be done more than once, then must be called from &lt;code&gt;run()&lt;/code&gt; too.&lt;/p&gt;&#xA;" OwnerUserId="6330" LastEditorUserId="6330" LastEditDate="2014-12-28T17:32:15.407" LastActivityDate="2014-12-28T17:32:15.407" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6740" PostTypeId="2" ParentId="6728" CreationDate="2014-12-28T15:41:30.210" Score="1" Body="&lt;p&gt;Design 1 wouldn't be my first thought on how to do this either! The transistors aren't a great choice, but are cheap &amp;amp; common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The layout &lt;a href=&quot;http://www.robotroom.com/BipolarHBridge.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; is more conventional, and you can physically link 1-2, &amp;amp; 3-4 to connect to your arduino without the risk of short circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect your code may be setting both lines high together - the only advantage I can see to the posted circuit is that this does not necessarily cause smoke (but may well do as you describe). This is why posting the code is recommended!&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2014-12-28T15:41:30.210" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6741" PostTypeId="1" AcceptedAnswerId="6743" CreationDate="2014-12-28T17:03:47.590" Score="0" ViewCount="1495" Body="&lt;p&gt;I'm trying to write a library for Arduino using the Wire library.&#xA;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PiCom.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef PiCom_h&#xA;#define PiCom_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;class PiCom&#xA;{&#xA;public:&#xA;    PiCom(int address, int* integers[], double* doubles[]);&#xA;    static void onReceiveCallback(int numbytes);&#xA;    static void onRequestCallback();&#xA;private:&#xA;    //Actually arrays of pointers to the data to be sent, has to be declared that way cause the size of the array isn't known at compile time&#xA;    int** _integers;&#xA;    double** _doubles;&#xA;&#xA;    void onReceive(int numbytes);&#xA;    void onRequest();&#xA;&#xA;    static PiCom instance;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PiCom.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;PiCom.h&quot;&#xA;&#xA;&#xA;static void onReceiveCallback(int numbytes)&#xA;{&#xA;&#xA;}&#xA;&#xA;PiCom::PiCom(int address, int* integers[], double* doubles[])&#xA;{&#xA;    _integers = integers;&#xA;    _doubles = doubles;&#xA;&#xA;    Wire.begin(address);&#xA;    void (*receiveFunction) (int);&#xA;    receiveFunction = &amp;amp;PiCom::onReceiveCallback;&#xA;    Wire.onReceive(receiveFunction);//Here i get an error&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the  constructor to be created when a new instance is created. A mehtod in this object should be called when data is requested or received. When trying to pass onRequest(int) directly to Wire.onRequest(void (*) (int)) an error is thrown. Same happend when saving it to receiveFunction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem was solved by using a static function (onReceiveCallback(int). I wanted this static function to call onRequest(int) in the object saved into PiCom::instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now i'm getting another error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PiCom\PiCom.cpp.o: In function `PiCom':&#xA;C:\Program Files\Arduino\libraries\PiCom/PiCom.cpp:26: undefined reference to `PiCom::onReceiveCallback(int)'&#xA;C:\Program Files\Arduino\libraries\PiCom/PiCom.cpp:26: undefined reference to `PiCom::onReceiveCallback(int)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6435" LastActivityDate="2014-12-28T23:03:46.427" Title="Compilation error when trying to give pointer to a function to another function" Tags="|library|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6743" PostTypeId="2" ParentId="6741" CreationDate="2014-12-28T22:55:10.980" Score="1" Body="&lt;p&gt;Pointer to a member function is &lt;a href=&quot;http://sphaleron.blogspot.co.il/2012/01/evil-c-5-member-function-pointer.html&quot; rel=&quot;nofollow&quot;&gt;a painful corner of C++&lt;/a&gt; until C++11. This is why when you try to pass an instance method pointer to &lt;code&gt;Wire.onReceive&lt;/code&gt; (without the &lt;code&gt;static&lt;/code&gt; keyword), you will get an error similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say '&amp;amp;PiCom::onReceiveCallback'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, you can't argue with the C++ ISO standard... changing the function to a static one (with external linkage, as they say) is indeed a workaround, as you have found out.&#xA;For this workaround to compile properly you just need to omit the &lt;code&gt;static&lt;/code&gt; keyword from your &lt;strong&gt;definition&lt;/strong&gt; (where it is implemented), and leave your &lt;strong&gt;declaration&lt;/strong&gt; (in the header file) as is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PiCom.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;static void onReceiveCallback(int numbytes);&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PiCom.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void PiCom::onReceiveCallback(int numbytes)&#xA;{&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By doing this you can pass it to Wire.onReceive without any problem, from the PiCom constructor, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PiCom::PiCom(int address, int* integers[], double* doubles[])&#xA;{&#xA;    ...&#xA;    Wire.onReceive(&amp;amp;PiCom::onReceiveCallback);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-28T23:03:46.427" LastActivityDate="2014-12-28T23:03:46.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6745" PostTypeId="2" ParentId="5219" CreationDate="2014-12-28T23:30:00.057" Score="0" Body="&lt;p&gt;If your question is &quot;Why isn't everything standardized on 5v?&quot;, see this good SO answer:&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/135841/voltage-standards-like-3-3v-5v-etc&quot;&gt;https://electronics.stackexchange.com/questions/135841/voltage-standards-like-3-3v-5v-etc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line is that the voltage drops as the electronics' technology advances (12v to 5v to 3.3v). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concretely to your problem, I honestly do not think that a level shifter is somewhat &quot;clunky&quot; solution to your problem, as suggested by mikeY (and as rejected by you). This is the way things are done in the electronics world - when a hardware mismatch arises, there is a hardware adapter to rescue.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2014-12-28T23:30:00.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6746" PostTypeId="1" CreationDate="2014-12-29T06:01:49.737" Score="2" ViewCount="73" Body="&lt;p&gt;I hooked up a Memsic2125 accelerometer to a Arduino Uno.  X and Y values are returning fine, but the T value is returning -4000 every time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// these constants won't change:&#xA;const int xPin = 2;     // X output of the accelerometer&#xA;const int yPin = 3;     // Y output of the accelerometer&#xA;const int tPin = 4;     // Y output of the accelerometer&#xA;&#xA;void setup() {&#xA;  // initialize serial communications:&#xA;  Serial.begin(9600);&#xA;  // initialize the pins connected to the accelerometer&#xA;  // as inputs:&#xA;  pinMode(xPin, INPUT);&#xA;  pinMode(yPin, INPUT);&#xA;  pinMode(tPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // variables to read the pulse widths:&#xA;  int pulseX, pulseY, pulseT;&#xA;  // variables to contain the resulting accelerations&#xA;  int accelerationX, accelerationY, accelerationT;&#xA;&#xA;  // read pulse from x- and y-axes:&#xA;  pulseX = pulseIn(xPin,HIGH);  &#xA;  pulseY = pulseIn(yPin,HIGH);&#xA;  pulseT = pulseIn(tPin,HIGH);&#xA;  // convert the pulse width into acceleration&#xA;  // accelerationX and accelerationY are in milli-g's: &#xA;  // earth's gravity is 1000 milli-g's, or 1g.&#xA;  accelerationX = ((pulseX / 10) - 500) * 8;&#xA;  accelerationY = ((pulseY / 10) - 500) * 8;&#xA;  accelerationT = ((pulseT / 10) - 500) * 8;&#xA;&#xA;  // print the acceleration&#xA;  Serial.print(accelerationX);&#xA;  // print a tab character:&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(accelerationY);&#xA;  // print a tab character:&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(accelerationT);&#xA;  Serial.println();&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output looks like this...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-104    -24 -4000&#xA;-96 -24 -4000&#xA;-96 -24 -4000&#xA;-104    -24 -4000&#xA;-96 -24 -4000&#xA;-104    -24 -4000&#xA;40  -216    -4000&#xA;120 -184    -4000&#xA;72  -200    -4000&#xA;-80 -376    -4000&#xA;456 672 -4000&#xA;-8  -40 -4000&#xA;-112    0   -4000&#xA;-112    0   -4000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to get the -4000 fixed?&lt;/p&gt;&#xA;" OwnerUserId="6444" LastActivityDate="2014-12-29T06:01:49.737" Title="Memsic Accelerometer not returning T value" Tags="|arduino-uno|accelerometer|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6747" PostTypeId="2" ParentId="6683" CreationDate="2014-12-29T08:04:02.113" Score="2" Body="&lt;p&gt;Just as a minor addition to Peter's excellent answer and comments on concatenation and implicit typecasting with &lt;code&gt;String&lt;/code&gt; objects:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatives to construct the message (as a &lt;code&gt;char[]&lt;/code&gt;) to be send might be: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use &lt;code&gt;sprintf()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[80];  // for the complete output&#xA;char value[4];    // for millis(), which returns an unsigned long&#xA;&#xA;sprintf(buffer, &quot;I'm running for %u ms now&quot;, millis());&#xA;Serial.println(buffer);       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that &lt;code&gt;sprintf()&lt;/code&gt; uses quite some memory!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;build the message 'manually':&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; char buffer[80] = &quot;I'm running for &quot;; &#xA;&#xA; itoa(millis(), value, 10);  &#xA; strcat(buffer, value);&#xA; strcat(buffer, &quot; ms&quot;);&#xA; Serial.println(buffer);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="89" LastActivityDate="2014-12-29T08:04:02.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6748" PostTypeId="2" ParentId="6736" CreationDate="2014-12-29T09:55:06.120" Score="-1" Body="&lt;p&gt;I would suggest it has to be the clock speed or memory. Whilst you can program the ATTiny85 with the Arduino IDE, it will take up quite a lot of its flash memory. There is a thread on the Arduino form &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=14394.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; which might help pinpointing the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution is to write it in AVR-C but I don't know if there is an easy way (or a library) for the 1-wire. I think you'll have to do it with the 1-Wire library alone as the DallasTemperature library is too much for the 8Kb of memory you have to play with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please feedback any breakthroughs you make as this is a nice project, the ATTiny is an awesome little chip...&lt;/p&gt;&#xA;" OwnerUserId="3506" LastEditorUserId="3506" LastEditDate="2014-12-29T10:03:15.613" LastActivityDate="2014-12-29T10:03:15.613" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6749" PostTypeId="2" ParentId="5102" CreationDate="2014-12-29T10:04:46.833" Score="1" Body="&lt;p&gt;Check out the TLC5916. It has two advantages over the HC595:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it can sink a lot of current&lt;/li&gt;&#xA;&lt;li&gt;it only needs one resistor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I use it with seven-segment displays. Basically, you tell it &quot;I'm about to send a command.&quot; Then you send it, say, &quot;01010101&quot; to turn on every other light. Then you say &quot;okay, make that live.&quot; You can chain them together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many use the MAX7219 but for me the cost is a drawback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I might come back and edit this post later to add a Github link to demonstrate...&lt;/p&gt;&#xA;" OwnerUserId="4969" LastActivityDate="2014-12-29T10:04:46.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6750" PostTypeId="1" AcceptedAnswerId="6751" CreationDate="2014-12-29T10:20:10.033" Score="2" ViewCount="63" Body="&lt;p&gt;I want to create a small position reporter for cars. I found some good GPS Modules with which i could collect data. But i'm unsure with what technology i should send the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possibility would be to setup a service in the www which is feeded by the arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to track the data live. so i think GPRS should be the right choice ?&#xA;Or more better are there any shields which make this GPRS LOG and SEND as a package ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which GPRS hardware would you use ?&#xA;Would you use something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any hints are very welcome&lt;/p&gt;&#xA;" OwnerUserId="6447" LastActivityDate="2014-12-29T11:09:55.643" Title="Data Report Which Technology" Tags="|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6751" PostTypeId="2" ParentId="6750" CreationDate="2014-12-29T11:09:55.643" Score="3" Body="&lt;p&gt;You can actually find all the information for what you want to do on the formal Arduino.cc website. &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;They suggest a GSM shield&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fncge.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course you can find many other GSM shields for purchase. Most of them works the same. Arduino.cc also offer a &lt;a href=&quot;http://arduino.cc/en/Reference/GSM&quot; rel=&quot;nofollow noreferrer&quot;&gt;nice GSM Library&lt;/a&gt;, with which you &lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMExamplesWebClient&quot; rel=&quot;nofollow noreferrer&quot;&gt;can perform HTTP GET/POST&lt;/a&gt; queries to a remote webserver (visible over the web).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can select whatever web server technology you prefer for receiving the data. Using NodeJS, PHP, MVC.NET or any other, you could expose a REST API to perform the update from the Arduino+GSM Shield side using HTTP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The web server then could analyze the incoming data and display it in any way you like.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2014-12-29T11:09:55.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6752" PostTypeId="1" AcceptedAnswerId="6768" CreationDate="2014-12-29T12:54:58.010" Score="4" ViewCount="3865" Body="&lt;p&gt;I have this Arduino &lt;a href=&quot;http://www.ebay.com/itm/161276647817&quot; rel=&quot;nofollow noreferrer&quot;&gt;motor shield&lt;/a&gt; which is hooked up with two DC motors. The board is the same &lt;a href=&quot;https://learn.sparkfun.com/tutorials/ardumoto-shield-hookup-guide&quot; rel=&quot;nofollow noreferrer&quot;&gt;as this one&lt;/a&gt; from Sparkfun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A PWM output controls the speed of the motor, and a digital out controls the direction. The problem is that it only works in one direction, namely if the direction pin is high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the direction pin HIGH and 255 is written to the PWM pin, Vout on the terminals is similar to Vin. If I reverse the direction by setting the direction pin LOW I would expect Vout to be -Vin, ie. the polarity reversed. But not so. I get a little more than zero volt across the terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the same for both channels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: The setup is powered from a 9V power adaptor through the barrel jack on Arduino.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EznN2.jpg&quot; alt=&quot;Photo of the DC motor connected to the driver board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the board defective, or am I misunderstanding something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SOLUTION: Thanks to the edited post (especially #3) in the accepted answer, I not only looked at the schematic (again), I actually understood it. I had already noticed the jumper called V-LOGIC which on the picture from Sparkfun was set to 5V where it on my shield was not set. I really didn't know what it was used for, but I set it to 5V so it was the same. But by looking at the schematic and the inverters, I realized that the inverter was fed from V-LOGIC which was connected to 5V. And bingo: I had not connected the 5V pin on the shield, only vIN which I assumed would be sufficient. The thing is, I am awaiting a set of stackable headers instead of the ones supplied, so I only connected the minimum numbers of pins because I will need to desolder them when I get the new headers.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="3464" LastEditDate="2015-01-02T00:18:13.310" LastActivityDate="2015-01-02T00:18:13.310" Title="Arduino motor shield will only work in one direction" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6753" PostTypeId="1" AcceptedAnswerId="6755" CreationDate="2014-12-29T15:17:37.860" Score="6" ViewCount="617" Body="&lt;p&gt;I'm planning on building an LED clock, but I want it to be lit only when I press the POWER button on my remote control. Using an IR receiver, which Arduino sleep mode should I use to reduce the current consumption but still be able to receive this interrupt?&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-09-22T12:06:14.027" Title="Choosing right Sleep state" Tags="|arduino-uno|led|sleep|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6754" PostTypeId="2" ParentId="5102" CreationDate="2014-12-29T15:49:06.840" Score="1" Body="&lt;p&gt;If the cost is allowed to be moderately higher, your simplest solution could be to use WS2012b individually-addressable LEDs. Since longer chains sometimes have timing problems with the serial communication, I’d probably split them into three groups, attached to three digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiplexing probably requires some flip-flops or other buffers; else, the LEDs may not be bright enough.&lt;/p&gt;&#xA;" OwnerUserId="1323" LastActivityDate="2014-12-29T15:49:06.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6755" PostTypeId="2" ParentId="6753" CreationDate="2014-12-29T16:13:04.423" Score="0" Body="&lt;p&gt;I recommend reading &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;ArduinoSleepCode&lt;/a&gt;. Where it demonstrates placing the avr into a sleep state and using an interrupt to awake from the sleep state. In your case you can connect the output of your IR demodulator to the interrupt  pin, to simular awake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ken Shirriff's IR library allows you to use any pin as a receive input, so that you can use INT0 or 1 on D2 or D3. If you need to use a different pin, the Microtheron's github fork uses Pin Change interrupts. (I am not sure if stock sleep.h will awake from PCint, like int0 or 1 will, without tweek. Section 10.1 of data sheet says it will.) &lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="13370" LastEditDate="2015-09-22T12:06:14.027" LastActivityDate="2015-09-22T12:06:14.027" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6756" PostTypeId="1" AcceptedAnswerId="6757" CreationDate="2014-12-29T16:19:41.143" Score="1" ViewCount="301" Body="&lt;p&gt;In a project, I’m using an EIA485 bus to send encrypted data packets. That works with Arduino’s buffered serial, but it is kind of awkward, and I’m using none of the more complex stuff in that class anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do not use &lt;code&gt;Serial&lt;/code&gt; anywhere in my Arduino sketch, is it safe to create my own interrupt handlers for &lt;code&gt;USART_RXC&lt;/code&gt; etc. and to directly manipulate the USART registers?&lt;/p&gt;&#xA;" OwnerUserId="1323" LastActivityDate="2014-12-29T19:19:03.767" Title="Serial interrupts?" Tags="|serial|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6757" PostTypeId="2" ParentId="6756" CreationDate="2014-12-29T19:19:03.767" Score="1" Body="&lt;p&gt;Absolutely. The only interrupt that Arduino takes for itself unilaterally is the timer 0 overflow interrupt, used for timing purposes (&lt;code&gt;delay()&lt;/code&gt;, &lt;code&gt;milliseconds()&lt;/code&gt;, et alia).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-29T19:19:03.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6759" PostTypeId="2" ParentId="6570" CreationDate="2014-12-30T01:09:51.670" Score="2" Body="&lt;p&gt;Well...&lt;br&gt;&#xA;Yes, but... &lt;strong&gt;mostly&lt;/strong&gt; only if you are using the simple serial lines(rx and tx) to communicate with it and only using the AT flash image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as a for-instance:&lt;br&gt;&#xA;The ESP8266-01 and ESP8266-02 have three and two IO pins (respectively) that are reprogrammable.&lt;br&gt;&#xA;The ESP8266-03 has seven IO pins.&lt;br&gt;&#xA;The others have different amounts of pins found on this page:&lt;br&gt;&#xA;&lt;a href=&quot;http://hackerspace.pbworks.com/w/page/88183850/ESP8266&quot; rel=&quot;nofollow&quot;&gt;http://hackerspace.pbworks.com/w/page/88183850/ESP8266&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if the program you use to flash the module uses more pins then you have to use the module that has the proper amount of IO pins or rewrite the flash image. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instructions for compiling a toolchain to write and flash your own flash images to the ESP8266-XX module are found on this page:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/esp8266/esp8266-wiki/wiki/Hardware_versions&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/esp8266-wiki/wiki/Hardware_versions&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6459" LastActivityDate="2014-12-30T01:09:51.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6760" PostTypeId="1" CreationDate="2014-12-30T02:21:30.293" Score="3" ViewCount="10669" Body="&lt;p&gt;The Photon from &lt;a href=&quot;https://www.spark.io/&quot; rel=&quot;nofollow&quot;&gt;Spark IO looks&lt;/a&gt; super small. Are there smaller wifi enabled microcontrollers available that can be programmed with the Arduino IDE?&lt;/p&gt;&#xA;" OwnerUserId="6460" LastActivityDate="2014-12-30T08:59:31.557" Title="What's the smallest Arduino board with wifi capabilities?" Tags="|wifi|" AnswerCount="1" CommentCount="2" ClosedDate="2014-12-30T10:48:08.950" ContentLicense="CC BY-SA 3.0" />
  <row Id="6761" PostTypeId="1" CreationDate="2014-12-30T08:38:47.407" Score="2" ViewCount="313" Body="&lt;p&gt;So I have a project I'm working on where I have about 6 arduino boards communicating with one another through cables. I've been testing them using a regulated DC PSU and at some point I caused a short and since then I can't upload any sketches onto the arduino. On some of them, the TX pin will light up while trying but RX won't and the IDE tends to freeze after around 90% of the upload process is complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how badly I screwed up? How do I avoid this next time? Is there an easy fix?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="6462" LastActivityDate="2014-12-30T08:38:47.407" Title="Arduino serial communication broken. Possible due to short circuit" Tags="|serial|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6762" PostTypeId="2" ParentId="6760" CreationDate="2014-12-30T08:47:58.653" Score="5" Body="&lt;p&gt;From your question it implies that &lt;em&gt;the Spark IO use the Arduino IDE - &lt;strong&gt;it's not&lt;/strong&gt;.&lt;/em&gt; It has two different IDE's, one is web based and the other is &lt;a href=&quot;https://www.spark.io/dev&quot;&gt;downloadable&lt;/a&gt;. In addition, it's not an Arduino per-se. It is based on the Wiring library, which is similar to the Arduino library but not exactly the same. And of course the MCU is not Atmel, but that is also the case with Intel's Galileo board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the size question in hand - my believe is that the Arduino products are designed for prototyping, so the size of the product is less important. This is the case for several reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Costs&lt;/strong&gt; -  the different Arduino products are pretty expensive for mass production.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Peripherals&lt;/strong&gt; - the Arduino boards come with different peripherals (such as the FTDI chip) which will probably be omitted in an end-user product, and which makes its size larger.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Pins&lt;/strong&gt; - almost every (official?) Arduino product comes with pre-built male/female header pins, which are excellent for prototyping but not for production, because of the large vertical space they take.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are many more reasons, but you get the point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When moving to production with an Internet of Things product, it makes sense to fabricate your own PCB, and design it with a small Atmel chip you used for prototyping (such as ATtiny85) and small Wifi chip, such as the &lt;a href=&quot;http://www.mikrocontroller.net/attachment/231858/0A-ESP8266_Specifications_v4.pdf&quot;&gt;ESP8266&lt;/a&gt;. &lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=8&amp;amp;t=390&quot;&gt;This is an example&lt;/a&gt; for such fabricated PCB, although the size is not the 'smallest' possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for beginners, or a one-time project, it would absolutely make sense to use a pre-fabricated Arduino product, in a small scale that could provide both easy coding capabilities, various libraries and a WiFi included. For that purpose, the Spark IO seems to be at the bleeding edge at the moment - but you never know what will be there tomorrow...&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2014-12-30T08:59:31.557" LastActivityDate="2014-12-30T08:59:31.557" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6763" PostTypeId="1" AcceptedAnswerId="6765" CreationDate="2014-12-30T10:39:02.060" Score="1" ViewCount="973" Body="&lt;p&gt;The product in question - &lt;a href=&quot;https://www.sparkfun.com/products/9825&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9825&lt;/a&gt; - operating at 5 V (and can also supply it to the device being programmed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to program the bootloader onto a 3.3 V ATmega328p and don't have any level shifters immediately available. Thus the question. The &quot;Hookup Guide&quot; for the product (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide&lt;/a&gt;) seems to suggest that it will work fine as long as the 3.3 V device being programmed isn't powered by the programmer. I wouldn't have thought it's the best idea in the world, but maybe I'm wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So any practical experience?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the over voltage tolerances for input lines on Atmel devices good enough to handle the extra voltage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the output level from the device being programmed would be high enough to be buffered up to 5.0 V?&lt;/p&gt;&#xA;" OwnerUserId="5117" LastEditorUserId="5117" LastEditDate="2014-12-30T11:25:25.393" LastActivityDate="2014-12-30T14:31:32.217" Title="Can the Sparkfun AVR pocket programmer bootload/program a 3.3 V ATmega328p" Tags="|bootloader|uploading|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6764" PostTypeId="2" ParentId="6763" CreationDate="2014-12-30T11:15:55.180" Score="0" Body="&lt;p&gt;ATmega328p Operating Voltage is 1.8v-5.5v, as stated in the second page of the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet (PDF)&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dOffE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there should be no problem feeding it with a regulated 5v VCC while programming it, and then supplying it with 3.3v on normal use. Just make sure you do not leave any 3.3v devices (which are not 5v tolerant) connected to the ATmega328p during the programming of the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the Sparkfun's Pro Mini 328 3.3v/8Mhz, you can read in the comments section of the Pro Mini page that customers successfully managed to power it with 5v without any issue. You can see &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;from the schematics&lt;/a&gt; that the voltage regulator in use (&lt;a href=&quot;http://www.micrel.com/_PDF/mic5205.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MIC5205&lt;/a&gt;) has a max input voltage of 20v, so 5v should not pose a problem to power it up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: &lt;a href=&quot;https://arduino.stackexchange.com/a/6765/630&quot;&gt;See Ignacio's answer&lt;/a&gt;. My answer apply for &lt;strong&gt;powering up&lt;/strong&gt; the Pro Mini &lt;strong&gt;not for programming it with 5v signals and 3.3v VCC&lt;/strong&gt;. The &lt;strong&gt;SJ1&lt;/strong&gt; jumper will need to be removed in order for the MIC5205 regulator to supply 5v instead of 3.3v. &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2014-12-30T12:10:53.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6765" PostTypeId="2" ParentId="6763" CreationDate="2014-12-30T11:44:25.487" Score="1" Body="&lt;p&gt;With that combination of programmer and Arduino you have two possible options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Cut JP1 on the programmer and power the programmer from the Arduino. With this you will have to make sure that the Arduino is connected and powered up before you connect the programmer to USB.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Cut SJ1 on the Arduino and allow it to be powered by the programmer at 5V. The Arduino itself isn't &lt;em&gt;required&lt;/em&gt; to be powered at 3.3V, that's simply what the on-board regulator provides, so we cut SJ1 in order to isolate the regulator from the MCU. Note that any devices connected to the Arduino will need to support 5V operation in order to this to be safe.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is not safe to put 5V at the output of the regulator, so you must make sure that does not happen.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-30T11:44:25.487" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6766" PostTypeId="2" ParentId="6763" CreationDate="2014-12-30T14:31:32.217" Score="1" Body="&lt;p&gt;The Pocket AVR Programmer has a logic level shifting (74ACT125) on board, specifically for this situation. There is nothing wrong with powering the target with a separate power supply that the programmer. Why else would there be a &quot;power target&quot;/&quot;No power&quot; switch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see why other people would suggest cutting traces, when all you need to do is toggle a switch.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-30T14:31:32.217" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6768" PostTypeId="2" ParentId="6752" CreationDate="2014-12-30T19:58:12.563" Score="2" Body="&lt;p&gt;I think you may be having an issue with how you are powering the shield.  Are you trying to do it with just your USB connection?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your photo, I do not see a connection to your Arduino's barrel jack or to the Vin connector of the shield itself.  According to the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/ardumoto-shield-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;SparkFun&lt;/a&gt; site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Ardumoto Shield should be powered through one of two power supply inputs. Pick one or the other:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;The &lt;strong&gt;barrel jack&lt;/strong&gt; input on the Arduino.&lt;/li&gt;&#xA;  &lt;li&gt;The &lt;strong&gt;Vin input&lt;/strong&gt; on the shield&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;If you don’t want to use the Arduino’s barrel jack input, you can use the &lt;strong&gt;Vin input on the shield&lt;/strong&gt; instead. This voltage input will supply &lt;strong&gt;both the shield and the Arduino&lt;/strong&gt;. Like the motor outputs, this connection is broken out to both a 3.5mm screw terminal and a 0.1&quot;-pitch header.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Do not supply power to both the Arduino barrel jack input and Vin on the shield!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I hope this helps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT BASED ON COMMENTS&lt;/strong&gt;&lt;br&gt;&#xA;Since you are properly powering the shield, I would recommend the following (see the &lt;a href=&quot;https://www.sparkfun.com/datasheets/DevTools/Arduino/Ardumoto_v13.pdf?_ga=1.206814291.1113379437.1408059991&quot; rel=&quot;nofollow&quot;&gt;shield's schematic&lt;/a&gt; for specifics):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maintaining the connection shown above (with the addition of the 9V power supply connected to the barrel jack) ensure that you are able to properly set the DIRA input.  You can check this with a multimeter on pin 7 of the LN298 whenever you are trying to switch directions.  &lt;/li&gt;&#xA;&lt;li&gt;If you are getting the expected results on pin 7 (pin goes HI when your code wants the motor to go one direction and pin goes LOW for the other) - check pin 9... the value here should always be the opposite of what you are setting for DIRA on pin 7.  If that is all good, then you probably have an issue with the LN298.  &lt;/li&gt;&#xA;&lt;li&gt;If you are not getting the expected results at pin 9, but pin 7 looks good, then you are having a problem with the 74HC1G04 IC (although I would doubt this since you are having problems with both the A and B motor outputs).&lt;/li&gt;&#xA;&lt;li&gt;If you are not getting the expected results at pin 7, then double check the code to make sure you have set and cleared the correct output pin.  I would also check the solder joints of the connectors on the shield - you can set a multimeter to do a resistance check from the shield's connector (pin 12) to the direction input on the LN298 (pin 7).  If the continuity is measuring close to 0 ohms then there is probably an issue with your code.&lt;/li&gt;&#xA;&lt;li&gt;If your code looks good, I have also had issues with bad outputs on the Arduino - you can check to see if you are properly toggling the direction pin (pin 12) on the Arduino without the shield connected.  Then, if the pin is not toggling, there is probably an issue with your Arduino - try toggling a different (unused) pin and jumpering it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="5067" LastEditorUserId="5067" LastEditDate="2014-12-31T00:32:16.267" LastActivityDate="2014-12-31T00:32:16.267" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6769" PostTypeId="1" AcceptedAnswerId="6770" CreationDate="2014-12-30T06:07:33.733" Score="6" ViewCount="12919" Body="&lt;p&gt;Ordered an arduino starter kit from aliexpress &lt;a href=&quot;http://www.aliexpress.com/item/UNO-KIT-Upgraded-version-of-the-For-Starter-Kit-the-RFID-learn-Suite-Stepper-Motor-ULN2003/1042001423.html&quot; rel=&quot;noreferrer&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parts list they provide (as a jpg on the order page) is vague and not very descriptive, I've gone through most of the parts and am down to three they did not list.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Capacitor? -- Looks to be a capacitor, labeled HDX and nothing else, rattles when I shake it.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/4oTnn.jpg&quot; alt=&quot;Unknown part #1 - HDX capacitor?&quot;&gt;&lt;/li&gt;&#xA;&lt;li&gt;Black LED -- I think this is a flame sensor; if it is, what's the difference between this and an infrared receiver (like a 1838B) or photoresistor?&#xA;&lt;img src=&quot;https://i.stack.imgur.com/OA9f2.jpg&quot; alt=&quot;Unknown part #2 - flame sensor LED?&quot;&gt;&lt;/li&gt;&#xA;&lt;li&gt;They also list something as 'a digital control' near the bottom of the list, not sure what that is? Every other part from the list is matched up and I don't see anything different in the first picture (not parts list picture) from what I have received in the order.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6709" OwnerDisplayName="PGT" LastEditorUserId="83" LastEditDate="2015-01-15T18:31:12.253" LastActivityDate="2019-04-01T13:43:34.497" Title="Help with parts identification from arduino starter kit from aliexpress" Tags="|hardware|components|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6770" PostTypeId="2" ParentId="6769" CreationDate="2014-12-30T07:31:03.847" Score="8" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Those are tilt sensors. The rattling is a metal ball that contacts two pins inside, closing the connection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The 1838B is a full module that partially decodes the received IR so that a MCU can fully decode the rest easily. What you have there is a bare phototransistor with an IR window on the top. You would use it for proximity or presence sensing. Instead of varying its resistance, it varies the amount of current it will pass.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Probably the single-digit 7-segment display, as opposed to the 4-digit display they have listed as &quot;4 digital tube&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2014-12-30T07:31:03.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6772" PostTypeId="1" CreationDate="2014-12-31T00:49:47.800" Score="0" ViewCount="940" Body="&lt;p&gt;I have an EFCom GPRS/GSM Shield &#xA;&lt;a href=&quot;http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield&lt;/a&gt;&#xA;and I am using it with a mega 2560. The problem is that the code in the wiki page &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Serial Relay - Arduino will patch a  &#xA;//serial link between the computer and the GPRS Shield &#xA;//at 19200 bps 8-N-1 &#xA;//Computer is connected to Hardware UART &#xA;//GPRS Shield is connected to the Software UART &#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;   &#xA;SoftwareSerial mySerial(2, 3);   &#xA;void setup() {   &#xA;  mySerial.begin(19200);               // the GPRS baud rate&#xA;  Serial.begin(19200);                 // the GPRS baud rate    &#xA;}   &#xA;&#xA;void loop() {   &#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());   &#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read()); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;makes use of software serial but mega 2560 cannot use software serial on pin 2, as in the arduino reference, thus I changed the pins to 50 and 51 and used external female-male headers to connect s_tx to pin 50 &quot;rx&quot; , and s_rx to pin 51 &quot;tx&quot;, still no response with the AT command...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;code after update is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;   &#xA;SoftwareSerial mySerial(50, 51);   &#xA;void setup() {   &#xA;  mySerial.begin(19200);               // the GPRS baud rate   &#xA;  Serial.begin(19200);                 // the GPRS baud rate   &#xA;}&#xA;&#xA;void loop() {  &#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());   &#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I am using the Arduino IDE serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="6471" LastEditorUserId="84" LastEditDate="2014-12-31T08:43:52.507" LastActivityDate="2018-05-08T05:47:20.200" Title="EFCom GPRS/GSM Shield" Tags="|arduino-mega|shields|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6774" PostTypeId="2" ParentId="3993" CreationDate="2014-12-31T05:11:00.530" Score="1" Body="&lt;p&gt;Sorry for late Siddharth,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;try to get response of only &lt;code&gt;at+cstt=?&lt;/code&gt;&#xA;Its return a exec  syntax and by following it you can make your frame of &lt;code&gt;at+cstt&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;some below point may it will help&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;//TCP connection profile AT+CSTT?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;+CSTT: &quot;CMNET&quot;,&quot;&quot;,&quot;&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK APN-&gt;&quot;CMNET&quot; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;USER-&gt;&quot;&quot;  &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;PASSWORD-&gt;&quot;&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+CSTT=&quot;CMNET&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;at+cstt=?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;+CSTT: &quot;APN&quot;,&quot;USER&quot;,&quot;PWD&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It may help you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;regards&lt;/p&gt;&#xA;" OwnerUserId="3206" LastActivityDate="2014-12-31T05:11:00.530" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6775" PostTypeId="1" AcceptedAnswerId="6776" CreationDate="2014-12-31T15:22:41.780" Score="0" ViewCount="48" Body="&lt;p&gt;I have a small office with wireless network, is it possible to make a wireless doorbell?&lt;br&gt;&#xA;Practical example:&lt;br&gt;&#xA;Arduino is connected to the main wireless network and has a static ip,&#xA;i have a website that connects through arduino using ftp to activate the &quot;open door&quot; function.&lt;br&gt;&#xA;note: &quot;open door&quot; activates a motor to press the button, or i will hack the current doorbell to connect wires :D&lt;/p&gt;&#xA;" OwnerUserId="6476" LastActivityDate="2014-12-31T15:43:29.630" Title="Use website to communicate with Arduino WirelessProtoShield" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6776" PostTypeId="2" ParentId="6775" CreationDate="2014-12-31T15:43:29.630" Score="0" Body="&lt;p&gt;Arduino wifi web server: &lt;a href=&quot;http://arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WiFiWebServer&lt;/a&gt; just modify the webserver to show a &quot;open&quot; button and to receive a post request and open the door.&lt;/p&gt;&#xA;" OwnerUserId="6477" LastActivityDate="2014-12-31T15:43:29.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6777" PostTypeId="1" AcceptedAnswerId="6784" CreationDate="2014-12-31T16:53:35.957" Score="1" ViewCount="1448" Body="&lt;p&gt;I'm working on a project to output the temperature from a DS18B20 to a 16x2 LCD while logging the temperature to a CSV file using the Adafruit Data Logging Shield. I keep getting this error when verifying the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RTClib-master/RTClib.cpp.o: In function `RTC_DS1307::now()':&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to 'Wire'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:252: undefined reference to &#xA;'TwoWire::beginTransmission(int)'RTClib-master/RTClib.cpp.o: In function 'TwoWire::write(int)':&#xA;/Applications/Arduino.app/Contents/Resources/Java/libraries/Wire/Wire.h:72: undefined reference to 'TwoWire::write(unsigned char)'&#xA;RTClib-master/RTClib.cpp.o: In function 'RTC_DS1307::now()':&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:254: undefined reference to 'TwoWire::endTransmission()'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:256: undefined reference to 'TwoWire::requestFrom(int, int)'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:257: undefined reference to 'TwoWire::read()'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:258: undefined reference to 'TwoWire::read()'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:259: undefined reference to 'TwoWire::read()'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:260: undefined reference to 'TwoWire::read()'&#xA;/Users/g/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:261: undefined reference to 'TwoWire::read()' RTClib-master/RTClib.cpp.o:/Users/grafton/Documents/Arduino/libraries/RTClib-master/RTClib.cpp:262: more undefined references to 'TwoWire::read()' follow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I comment &lt;code&gt;RTC_DS1307 RTC;&lt;/code&gt; in the code (below) these errors go away, but of course I get errors related to an undefined RTC. I'm a newbie cobbling together code from various sources, so any help is greatly appreciated. Code follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#define ONE_WIRE_BUS 2&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;const int chipSelect = 10;&#xA;File tempLog;&#xA;RTC_DS1307 RTC;&#xA;&#xA;LiquidCrystal lcd(6, 7, 8, 9, 11, 12);&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA;   while (!Serial) {&#xA;    ; &#xA;  lcd.begin(16, 2);&#xA;  //         ----------------  &#xA;  lcd.print(&quot;Current temp (F)&quot;);&#xA;   sensors.begin();&#xA;   }&#xA;&#xA;Serial.print(&quot;Initializing SD card...&quot;);&#xA;  pinMode(SS, OUTPUT);&#xA;&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&quot;Initialization failed!&quot;);&#xA;    while (1);&#xA;  }&#xA;  Serial.println(&quot;Initialization done.&quot;);&#xA;&#xA;tempLog = SD.open(&quot;templog.txt&quot;, FILE_WRITE);  &#xA;if (! tempLog) {&#xA;  Serial.println(&quot;Error opening templog.txt&quot;);&#xA;  while(1);&#xA;}&#xA;char filename[] = &quot;LOGGER00.CSV&quot;;&#xA;  for (uint8_t i = 0; i &amp;lt; 100; i++) {&#xA;    filename[6] = i/10 + '0';&#xA;    filename[7] = i%10 + '0';&#xA;    if (! SD.exists(filename)) {&#xA;      // only open a new file if it doesn't exist&#xA;      tempLog = SD.open(filename, FILE_WRITE);&#xA;      break;  // leave the loop!&#xA;    }&#xA;&#xA;  Serial.print(&quot;Writing to: &quot;);&#xA;  Serial.println(filename);&#xA;  tempLog.println(&quot;Data Logging File&quot;);&#xA;  tempLog.println(&quot;Date,Temp(F)&quot;);&#xA;  } &#xA;} &#xA;&#xA;void loop() {&#xA;  sensors.requestTemperatures();&#xA;  float temperature = sensors.getTempFByIndex(0);&#xA;  lcd.setCursor(6, 1);&#xA;  lcd.print(temperature);&#xA;  Serial.println(temperature);&#xA;  //-----------------------------------------------------------&#xA;&#xA;String dataString = &quot;&quot;;&#xA;&#xA;//date time stuff-------------------------------------------&#xA;&#xA;DateTime now = RTC.now();&#xA;  // log time&#xA;// tempLog.print(now.unixtime()); // seconds since 1/1/1970&#xA;//  tempLog.print(&quot;, &quot;);&#xA;  tempLog.print('&quot;');&#xA;  tempLog.print(now.year(), DEC);&#xA;  tempLog.print(&quot;/&quot;);&#xA;  tempLog.print(now.month(), DEC);&#xA;  tempLog.print(&quot;/&quot;);&#xA;  tempLog.print(now.day(), DEC);&#xA;  tempLog.print(&quot; &quot;);&#xA;  tempLog.print(now.hour(), DEC);&#xA;  tempLog.print(&quot;:&quot;);&#xA;  tempLog.print(now.minute(), DEC);&#xA;  tempLog.print(&quot;:&quot;);&#xA;  tempLog.print(now.second(), DEC);&#xA;  tempLog.print('&quot;');&#xA;&#xA;  tempLog.print(&quot;,&quot;);&#xA;  tempLog.print(temperature);&#xA;  tempLog.print(&quot;,&quot;);&#xA;  delay(500);&#xA;&#xA;tempLog.println(dataString);&#xA;tempLog.flush();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6236" LastActivityDate="2014-12-31T21:14:40.147" Title="DS1307 RTC conflicts with DS18B20" Tags="|shields|lcd|sd-card|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6778" PostTypeId="2" ParentId="6621" CreationDate="2014-12-31T17:01:08.493" Score="2" Body="&lt;p&gt;Has any part of it ever worked? What have you done to it since?&#xA;My approach to debugging this would be to&#xA; - Temorarily replace the Bluetooth with wired serial communication;&#xA; - Comment out, or stub out(*), anything you aren't utterly and completely confident in.&#xA; - Get some minimum amount of hardware and software working.&#xA; - Add back one piece of hardware or one section of code at a time, fixing whatever you have to to get it working again.&#xA; - Repeat, until everything is back together and playing nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) Stubbing is the technique of replacing a function or a section of code with something trivial (and therefore hard to get it wrong!) that lets the rest of the code mostly work.&lt;br&gt;&#xA;Suppose you had written a digitalRead() function. (I know it's a library function and we have total confidence in it, but for a moment, just suppose....) You might replace the contents of your digitalRead() with a single statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int digitalRead(uint8_t pin){&#xA;   // untested code commented out here&#xA;   // ...&#xA;   return(4);  // any value that means something to the calling code &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can work on the code that calls your digitalRead() without having a working digitalRead(). The caller will only ever get the same value every time it calls, but that may be enough get some part of it working until you can come back and fix your digitalRead() function.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2014-12-31T17:01:08.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6779" PostTypeId="1" AcceptedAnswerId="6780" CreationDate="2014-12-31T17:02:30.820" Score="0" ViewCount="5009" Body="&lt;p&gt;I had an idea to create a control panel using an arduino and some buttons. How would I go about making the arduino emulate an input device so that when I press a button connected to the arduino, it would cause the same effect as when a keyboard key was pressed? (I'm using arduino UNO, if it helps.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="6481" LastActivityDate="2014-12-31T19:02:47.740" Title="Using an Arduino as an input device" Tags="|arduino-uno|emulation|" AnswerCount="2" CommentCount="2" ClosedDate="2014-12-31T21:40:14.760" ContentLicense="CC BY-SA 3.0" />
  <row Id="6780" PostTypeId="2" ParentId="6779" CreationDate="2014-12-31T17:22:03.267" Score="1" Body="&lt;p&gt;The easy answer is to use a Leonardo, Micro, or Due instead. They already support USB HID functionality via &lt;a href=&quot;http://arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Mouse&lt;/code&gt; and &lt;code&gt;Keyboard&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on using an Uno &lt;strong&gt;R3&lt;/strong&gt; then you will need to reprogram the on-board ATmega16U2 to accept serial commands from the ATmega328P and generate the appropriate USB HID events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using an Uno or clone that doesn't have an ATmega16U2 as well then you're SOL and will have to write a program that runs on the computer that receives the commands via serial and translates them into HID events.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-31T17:22:03.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6781" PostTypeId="2" ParentId="6779" CreationDate="2014-12-31T19:02:47.740" Score="2" Body="&lt;p&gt;I have successfully reprogrammed the UNO's R3 8U2 to support keyboard emulation, as to just this. Making dedicated user inputs for kiosks to Computers. I recommend &lt;a href=&quot;https://github.com/NicoHood/HID&quot; rel=&quot;nofollow&quot;&gt;NicoHood's GitHub&lt;/a&gt; as it allows simultaneous Arduino Bootloader and Keyboard functionality, making it easy to reprogram the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This along with using &lt;a href=&quot;https://www.sparkfun.com/products/9695&quot; rel=&quot;nofollow&quot;&gt;Capacitive Touch Sensor&lt;/a&gt; connected to Copper tap under clear acrylic protecting printed graphics of buttons is very quick and easy to make. Very little machining.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of such code is found at &lt;a href=&quot;https://github.com/wreality/artemis-firmwares/tree/master/ConsoleFirmwares&quot; rel=&quot;nofollow&quot;&gt;artemis-firmwares&lt;/a&gt; it was initially created with a different 8U2 method. Where next time we will use NicoHood's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the stock keyboard send key command for the Arduino is limited. Where the above methods allows the code to send complete virtual keys supporting full emulation. &lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2014-12-31T19:02:47.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6782" PostTypeId="1" CreationDate="2014-12-31T19:05:30.963" Score="9" ViewCount="61581" Body="&lt;p&gt;I have a 1602 LCD screen that works fine on its own. However I wanted to free some pins by using an I2C / IIC LCD controller I purchased separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the controller seems to be communicating with my Arduino UNO on the right address, I cannot get text to display. By default (no code) it seems the LCD will have 1 line of 16 solid &quot;squares&quot;. When using address 27 in my code, the LCD will change to 2 lines of 16 squares (see photo below). The code also calls for the backlight to flash 3 times, which works. However I cannot get anything but 2 lines of squares. (Full code is at the bottom of this question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the &lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads&quot; rel=&quot;noreferrer&quot;&gt;LiquidCrystal_I2C library&lt;/a&gt; by F Malpartida, which seems to be commonly used.&lt;br&gt;&#xA;Is there a better library I should be using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering whether it's just the wrong pins being used in the code. All sketches I see online use the following pins:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//                    addr,en,rw,rs,d4,d5,d6,d7,bl,blpol&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;// Set the LCD I2C address&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But all of the 1602 LCDs I see online have the same pins as mine, as you can see in my photo below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TIBSe.jpg&quot; alt=&quot;I2C LCD Controller&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These pins seem to be standard:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/z1JTTm.jpg&quot; alt=&quot;1602 LCD Pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To further confuse me, the pins on the LCD board start with 1 on the left, yet the default code's pins seem to start with 0! So I tried changing the code's pins to the numbers on the LCD board. The LCD no longer changes to 2 lines of squares and no longer blinks the backlight. I then tried subtracting 1 from each pin (to start from 0), same result. I then tried used the default pins minus 1, same result. Thus the default pins are somehow more correct?! What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone else gotten one of these I2C controllers to work for them, and if so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* YourDuino.com Example Software Sketch&#xA; 16 character 2 line I2C Display&#xA; Backpack Interface labelled &quot;YwRobot Arduino LCM1602 IIC V1&quot;&#xA; terry@yourduino.com */&#xA;&#xA;/*-----( Import needed libraries )-----*/&#xA;#include &amp;lt;Wire.h&amp;gt;  // Comes with Arduino IDE&#xA;// Get the LCD I2C Library here: &#xA;// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;/*-----( Declare objects )-----*/&#xA;// set the LCD address to 0x27 for a 20 chars 2 line display&#xA;// Set the pins on the I2C chip used for LCD connections:&#xA;//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address&#xA;&#xA;void setup()   /*----( SETUP: RUNS ONCE )----*/&#xA;{&#xA;  Serial.begin(9600);  // Used to type in characters&#xA;  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight&#xA;&#xA;// ------- Quick 3 blinks of backlight  -------------&#xA;  for(int i = 0; i&amp;lt; 3; i++) {&#xA;    lcd.backlight();&#xA;    delay(250);&#xA;    lcd.noBacklight();&#xA;    delay(250);&#xA;  }&#xA;  lcd.backlight(); // finish with backlight on  &#xA;&#xA;//-------- Write characters on the display ------------------&#xA;// NOTE: Cursor Position: (CHAR, LINE) start at 0  &#xA;  lcd.setCursor(0,0); //Start at character 4 on line 0&#xA;  lcd.print(&quot;Hello, world!&quot;);&#xA;  delay(1000);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;HI!YourDuino.com&quot;);&#xA;  delay(8000);  &#xA;&#xA;// Wait and then tell user they can start the Serial Monitor and type in characters to&#xA;// Display. (Set Serial Monitor option to &quot;No Line Ending&quot;)&#xA;  lcd.clear();&#xA;  lcd.setCursor(0,0); //Start at character 0 on line 0&#xA;  lcd.print(&quot;Use Serial Mon&quot;);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;Type to display&quot;);  &#xA;&#xA;}/*--(end setup )---*/&#xA;&#xA;void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/&#xA;{&#xA;  {&#xA;    // when characters arrive over the serial port...&#xA;    if (Serial.available()) {&#xA;      // wait a bit for the entire message to arrive&#xA;      delay(100);&#xA;      // clear the screen&#xA;      lcd.clear();&#xA;      // read all the available characters&#xA;      while (Serial.available() &amp;gt; 0) {&#xA;        // display each character to the LCD&#xA;        lcd.write(Serial.read());&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;}/* --(end main loop )-- */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4455" LastEditorUserId="4455" LastEditDate="2015-01-01T08:35:50.337" LastActivityDate="2018-01-12T10:45:24.813" Title="I2C LCD Serial Interface Board not displaying text (wrong pins?)" Tags="|i2c|lcd|" AnswerCount="3" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="6784" PostTypeId="2" ParentId="6777" CreationDate="2014-12-31T21:14:40.147" Score="1" Body="&lt;p&gt;The RTC library requires the &lt;code&gt;Wire&lt;/code&gt; library. Just put &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt; in front of the line &lt;code&gt;#include &quot;RTClib.h&quot;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-31T21:14:40.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6785" PostTypeId="1" CreationDate="2014-12-31T21:34:16.670" Score="2" ViewCount="2663" Body="&lt;p&gt;So I've taken apart an old microwave oven with a touch-sensitive LCD screen. I understand that I could die from playing around with this, so I've disconnected the high-voltage transformer and the magnetron. I'm also not going to remove any of the safety switches like the door switch. My question is, how is the microwave controlled? I'm thinking there is a computer chip somewhere in the circuit, and I'm looking to replace it with an Arduino board plus some extras, like AC relays and such. I'm curious as to how the microwave oven controls its functions, like power level, cooking time, and the beeping. Any advise as to how I could get started interfacing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the power level controlled by PWM by any chance? Can you PWM alternating current?&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2018-12-23T22:12:11.810" Title="Arduino board to control microwave oven?" Tags="|arduino-uno|lcd|electronics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6786" PostTypeId="2" ParentId="6785" CreationDate="2014-12-31T21:39:46.717" Score="2" Body="&lt;p&gt;It's pretty much all proprietary. It can be done, but you'd have to replace all the circuitry with the Arduino, interfacing with the existing magnetic and mechanical devices and doing everything in your own code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power level is controlled by PWM, but it's &lt;em&gt;extremely&lt;/em&gt; low frequency PWM, on the order of 0.05Hz (20s period). That's why there are two different sounds that come from the microwave when it's not at full power; one when the magnetron is active, and one when it is off.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2014-12-31T21:39:46.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6787" PostTypeId="2" ParentId="6785" CreationDate="2014-12-31T21:44:16.477" Score="2" Body="&lt;p&gt;There is no power level in a microwave. It's just on or off. They lower the power by turning on the magnetron for a few seconds, and then off for a few second. You can actually hear this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably turned on by a relay, triac, or solid state relay. The magnetron is just requires a high voltage to work; nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The programmes, timing, and handling of the buttons is done by some microcontroller, similar to an arduino.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2014-12-31T21:44:16.477" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6788" PostTypeId="2" ParentId="6782" CreationDate="2014-12-31T21:50:47.007" Score="3" Body="&lt;p&gt;First of all, it looks like these wires aren't properly connected:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hkcog.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I haven't disassembled a female jumper before, so that might not be the issue. However, it seems likely that this could be a cause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you &lt;strong&gt;need&lt;/strong&gt; to adjust the contrast by turning that trimmer (the blue thing that looks kinda like it has a screw in it). LCDs will either display nothing, a washed out version of the text, or blue boxes if the contrast is not set correctly. This is probably the cause.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2014-12-31T21:50:47.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6789" PostTypeId="1" CreationDate="2014-12-31T23:05:08.893" Score="0" ViewCount="139" Body="&lt;p&gt;I'm pretty interested in arduino and the things I can learn from it. Being that I'm new into this I wanted to know which model I should get that would be easiest to learn on and why. What does this model come with, how much, and reputable place where one can purchase this. &lt;/p&gt;&#xA;" OwnerUserId="6483" LastActivityDate="2015-01-01T02:28:23.597" Title="Which arduino should I start on to learn about it?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ClosedDate="2015-01-01T23:11:52.963" ContentLicense="CC BY-SA 3.0" />
  <row Id="6790" PostTypeId="2" ParentId="6789" CreationDate="2015-01-01T02:28:23.597" Score="2" Body="&lt;p&gt;I would simply say: buy a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00MO9L5WC&quot; rel=&quot;nofollow&quot;&gt;startkit&lt;/a&gt; like this one.At the end it is not important which Arduino board you'll start. They are (almost) the same*. At the very beginning you can start with &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Uno&lt;/a&gt; or &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Nano&lt;/a&gt; and even &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Leonardo&lt;/a&gt; could be very good. Those boards are very similar and you can program them in the same. Even the pins location and designation is not really different.&#xA;The most important thing about Arduino is to understand how to work and program and interface such a board with the sensors. In this sense I would choose a Uno board (or even 2009) which is less expensive and very easy to find overall. I don't really know how much experience you have, but it is likely, at the beginning, that you invert polarities of batteries, you drain too much power, or you invert some pins and damage the microcontroller. In that case doesn't make sense to buy the last powerful mega expensive board on the mark. If you get a Uno you can do almost everything and have for the next month a lot to learn. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change from Uno or Nano to the other board it is not very difficult. Once you understand the basis you can switch to every board you want. If you need more power and memory you can buy a Mega. If you need much more power you can buy a Due/Tre/etc...you need just an &lt;em&gt;upgrade&lt;/em&gt; not everything from scratch to learn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really new to Arduino the best way is to buy such a learn package as I showed you above. That have everything you need to understand basic of programming till to RC-Servo movement and motor drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy new year.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*: stay away for the moment from the Arduino Due/Tre/Zero/Yuan/.. series. they are too expansive and require a lot of attention (3.3V, max drain current from the pins, pull up, pull down...etc..). Here is the risk to get your board damaged within few time very high. And you'll spend a lot of time thinking that the board has some problems.&lt;/p&gt;&#xA;" OwnerUserId="6330" LastActivityDate="2015-01-01T02:28:23.597" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6791" PostTypeId="1" AcceptedAnswerId="6792" CreationDate="2015-01-01T05:28:38.890" Score="1" ViewCount="419" Body="&lt;p&gt;I was reproducing the Girino (the &lt;a href=&quot;http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instructable&lt;/a&gt; by Caffeinomane) bundled with the Girinoscope (the &lt;a href=&quot;https://github.com/Chatanga/Girinoscope&quot; rel=&quot;nofollow noreferrer&quot;&gt;Java GUI&lt;/a&gt; by Chatanga). The results worked well and I went on to see if the oscilloscope can go up to higher kS/s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, originally only upto prescaler 8 works. I removed PWM pin and it works upto 4 but prescaler 2 strangely behaves. Here are the details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a preliminary test on prescaler 32 (~38.5kHz). Settings as follows and the same in other tests.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The signal (the same hereafter) is generated by a 555 timer astable multivibrator running at 4.5V (3 AA batteries).&lt;/li&gt;&#xA;&lt;li&gt;The circuitry was simply omitted. I just tied 3.3V of Arduino NANO / ATmega328 to digital pin 6 as the trigger level.&lt;/li&gt;&#xA;&lt;li&gt;There is no +2.5V offset done by the original Girino. (The scale should be 0~5V and the signal is 0~4V)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/egXFy.png&quot; alt=&quot;Prescaler 32 works&quot;&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So then I wanted to try if it can speed up more. The code optimization quoted by Chatanga allowed prescaler 8 and 16 (76.9kHz and 151.8 kHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to push it the poor Arduino to the limits, I disabled PWM pin in the original Girino which sets the trigger level with duty cycles (PWM from pin ~3 being fed into pin 6). It's because I simply used a fixed 3.3V trigger level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prescaler 4 is unlocked.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/uRUCs.png&quot; alt=&quot;Prescaler 4 works with code optimization and disabled PWM&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ambitious I go on to test prescaler 2. The GUI did not provide this option so I simply set it in the Arduino code.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/RDuTS.png&quot; alt=&quot;Prescaler 2 strangely behaves (all full scale deflection)&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it did not work. I noticed if the prescaler is exceeding the Arduino's capability, TXRX simply does not blink. But this time the TXRX is just blinking! To verify this, I shifted the wait duration.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/hHCqG.png&quot; alt=&quot;Prescaler 2 strangely behaves (all full scale deflection)&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In previous screenshots, the leftmost green line is dashed (probably because it's below fullscale deflection). But in the last two, be it offset or not, the line is solid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The debug output is like this: (8bits 0~255 given by ADC)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;many 0 then suddenly 255 thereafter. (matches the GUI output)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I suspect it's due to slow TXRX? How to solve this? Or anything I overlooked?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that this overdetailed question does not sicken you.&lt;/p&gt;&#xA;" OwnerUserId="6485" LastEditorUserId="6485" LastEditDate="2015-01-01T05:34:23.687" LastActivityDate="2015-01-01T06:00:27.073" Title="Speeding up Girino gives strange readouts" Tags="|serial|arduino-nano|analogread|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6792" PostTypeId="2" ParentId="6791" CreationDate="2015-01-01T06:00:27.073" Score="0" Body="&lt;p&gt;From the ATmega328P datasheet, section 29.8, &quot;ADC Characteristics&quot;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Clock Frequency — Min.: 50kHz, Max: 1000kHz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With a 16MHz system clock this means that a /16 prescaler is the most the ADC is considered reliable under for a reasonable 10 bit result (for a &lt;em&gt;full&lt;/em&gt; 10 bit result the maximum frequency is 200kHz, which corresponds to a prescaler of /80). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the frequency increases the sample-and-hold circuitry of the ADC gets less time to do the &quot;sample&quot; part before conversion begins. As such any correctness goes out the window, certainly at the lower bits. The fact that you got any sort of result that you did at /4 is luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; The ADC is too slow.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-01T06:00:27.073" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6793" PostTypeId="2" ParentId="4376" CreationDate="2015-01-01T07:34:27.183" Score="0" Body="&lt;p&gt;1.Use two arduino's and have them talk to each other via serial or i2c.&#xA;Probably the simplest option (but not the cheapest - though you can get clone arduinos from US$4 ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.Find a light sensor that updates faster. Tried an ldr(light dependent resistor)/photocell ?  Then could use analog read. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could also switch from using arduino to c, but thats a lot more work and you are still going to hit similar problems.&lt;/p&gt;&#xA;" OwnerUserId="6247" LastActivityDate="2015-01-01T07:34:27.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6794" PostTypeId="2" ParentId="812" CreationDate="2015-01-01T07:47:16.403" Score="0" Body="&lt;p&gt;To be safe use a device like the power tail from spark fun(basically a sealed relay unit, ready for you to connect to the arduino)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much easier and safer if you don't have any experience working with 120V/240V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;uses a 3-12 input to switch 120v up to 15A&#xA;&lt;a href=&quot;https://www.sparkfun.com/products/10747&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10747&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6247" LastActivityDate="2015-01-01T07:47:16.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6795" PostTypeId="2" ParentId="6785" CreationDate="2015-01-01T08:09:17.947" Score="0" Body="&lt;p&gt;If you want to learn more about AC power circuits start with relays (start with 5v or 12v dc as a lot safer , cheaper and easier) something like the spark fun power tail if you really do want to control 120V devices note its only on/off control, not different power levels. &lt;a href=&quot;https://www.sparkfun.com/products/10747&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10747&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can generate AC from DC by using pwm at a lower voltage and driving a transformer&#xA;or a digital inverter. Can use an arduino to do it if you wanted to.&#xA;Use pwm function, then via optocouplers (to protect the arduino) to power mosfets or an h-bridge to drive a transformer. Can fairly easily produce 120V/240V output&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Time to grab a good basic electronics book like Art of Electronics (should be able to find a pdf version) &#xA;3rd edition is finally getting published in 2015&lt;/p&gt;&#xA;" OwnerUserId="6247" LastActivityDate="2015-01-01T08:09:17.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6796" PostTypeId="2" ParentId="432" CreationDate="2015-01-01T10:23:12.177" Score="4" Body="&lt;p&gt;ESP8266 is a cheap 5$ wifi module with UART, SPI connectivity. This can be integrated with Arduino seamlessly either through the stock firmware using AT commands, or by writing custom firmware using the SDK provided and GIPO available. For more reference &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.esp8266.com/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4340" LastActivityDate="2015-01-01T10:23:12.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6797" PostTypeId="2" ParentId="432" CreationDate="2015-01-01T10:32:18.047" Score="0" Body="&lt;p&gt;Check ESP8266 wifi module , it's a cheap module and can be controlled using any microcontroller by AT commands , also it's Soc so you can use it standalone . &lt;/p&gt;&#xA;" OwnerUserId="6487" LastActivityDate="2015-01-01T10:32:18.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6798" PostTypeId="1" CreationDate="2015-01-01T14:23:49.887" Score="0" ViewCount="319" Body="&lt;p&gt;I've just cracked out my Franzis Arduino Tutorial Kit (Best Xmas Present EVER!) and I'm already stuck on my second program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I successfully wrote and executed a basic 'blink' program, however when I wrote out the second program provided in the manual I get an 'Error Compiling' when trying to check the syntax or run the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the obvious of unplugging the board and plugging it back in but this didn't work. When I search for help most forum posts refer to the error message, however I have no message, just the orange warning bar stating 'Error Compiling'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Franzis Arduino&#xA;// My second Arduino program&#xA;&#xA;int ledPin = 13; //LED is connected with digital pin 13&#xA;&#xA;// The setup routine configures the digital port&#xA;// This routine is executed only once at program start!&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.printIn(&quot;Our second Arduino program&quot;);&#xA;  Serial.printIn();&#xA;}&#xA;&#xA;// The main program is an infinate loop&#xA;void loop()&#xA;{&#xA;  Serial.print(&quot;5 + 188 yields&quot;);&#xA;  Serial.print(5+188);&#xA;  while(true)&#xA;  {&#xA;    digitalWrite(ledPin, HIGH); // Turn on LED&#xA;    delay(2000);                 // Wait for a second&#xA;    digitalWrite(ledPin, LOW);   // Turn off LED&#xA;    delay(2000);                 // Wait for a second&#xA;    continue;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's a screenshot of the error message (or lack of);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BJhrl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6489" LastActivityDate="2015-01-01T14:37:04.263" Title="Error Compiling on raspberry Pi - no error details provided in IDE" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6799" PostTypeId="2" ParentId="6798" CreationDate="2015-01-01T14:37:04.263" Score="1" Body="&lt;p&gt;It's not &lt;code&gt;printIn&lt;/code&gt;, but &lt;code&gt;println&lt;/code&gt; (as in &quot;print line&quot;).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-01T14:37:04.263" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6801" PostTypeId="1" AcceptedAnswerId="6824" CreationDate="2015-01-01T21:48:51.583" Score="4" ViewCount="1894" Body="&lt;p&gt;My prototype contains below components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno R3&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth LE nRF8001 Break-out (&lt;a href=&quot;https://www.adafruit.com/products/1697&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1697&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;MicroSD Break-out (&lt;a href=&quot;https://www.adafruit.com/products/254&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/254&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;ADXL335 triple-axis Accelerometer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think It's OK on paper (and presumably on a breadboard too). I'm trying to wrap my head around on how to convert it to a finished product that sits inside a plastic box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What are my options?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, can I create a single PCB that contains all the components? If not, how can I connect these multiple break-out boards together? Is soldering some wires on both boards to connect them is a viable option?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ultimate goal is to create a product that is for sale. So I mean something that can be mass-produced and can meet regulatory requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why I was thinking about a single PCB. Arduino (or should I say ATMegaXXX?) is fairly simple to place on a custom PCB. So I was thinking perhaps I could &quot;re-create&quot; my break-outs (see above) on this PCB thus creating a single piece including all components and the microcontroller. For some reason this makes sense to me but I don't know how hard it is or if it is even possible.&lt;/p&gt;&#xA;" OwnerUserId="6494" LastEditorUserId="6494" LastEditDate="2015-01-01T22:43:23.707" LastActivityDate="2016-10-20T06:19:51.300" Title="How to convert this prototype to finished product?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6802" PostTypeId="2" ParentId="6801" CreationDate="2015-01-01T22:24:27.217" Score="0" Body="&lt;p&gt;By &quot;product&quot;, do you mean for sale? Giveaways to friends? One for yourself? How many do you expect to make? It isn't (monetarily) worth creating a board for one or five pieces unless you want to for reasons of aesthetics, reliability, demonstrating your skills to a potential employer, etc. OTOH, if you sell a product, it will to meet regulatory requirements in the jurisdiction(s) in which you intend to sell it. So the - admittedly unsatisfying - answer is: it depends. :)  (In other words, we need more information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chinese board houses advertise they can do small runs for quite reasonable prices, but expect to spin the board several times unless it's a pretty simple one. Not dissing their abilities or skills as I have no experience with any of them, but as a practical matter of communicating exactly what you want, the first time, to a business half a planet away, a business you might not be familar with yet, and someone with whom you might not share a native language. Even with those obstacles out of the way, boards can take several- to many spins to get to a first production revision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a small handful of boards (depending the size of a &quot;handful&quot;), hand-wiring on hobby PCBs or strip-boards can be effective and not too expensive. &lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-01-02T21:37:03.090" LastActivityDate="2015-01-02T21:37:03.090" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6803" PostTypeId="2" ParentId="6801" CreationDate="2015-01-01T22:27:47.107" Score="-1" Body="&lt;p&gt;Single PCB is not viable, as some chips are near impossible to solder by hand. Also, you'd have to get your PCB checked for FCC compliance (because of the bluetooth), which you don't want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could design a PCB that contains the Arduino micro controller (ATMega328), and that all the other board plug into. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wires could also be a solution, by you probably need to find a way to securely mount all the boards inside the enclosure (no rattling).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I'd suggest something like an &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano&lt;/a&gt; as it's smaller, and you can remove the header pins and solder wires directly to PCB.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-01T22:27:47.107" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6804" PostTypeId="1" AcceptedAnswerId="6805" CreationDate="2015-01-02T01:00:22.307" Score="2" ViewCount="4052" Body="&lt;p&gt;How does an arduino microprocessor compare to some of the older computers in RAM, and computational speed? Like how does it compare to the Intel 400 or the original IBM PC. I'm interested in both the Atmega328 and the 2560. Just how much better/worse is the arduino compared to an old computer?&lt;/p&gt;&#xA;" OwnerUserId="4883" LastActivityDate="2021-02-03T20:02:40.673" Title="Arduino vs Old Computers" Tags="|atmega328|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6805" PostTypeId="2" ParentId="6804" CreationDate="2015-01-02T03:52:08.523" Score="1" Body="&lt;p&gt;Similar capability in turns of processing power if you compare back 10 -20 years. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;arduino is a micrcontroller not a microprocessor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good example is the pdp11 minicomputer and the ti msp430 micro controllers. They share the same instruction set (approx 90%) . Both can (or could) do realtime event handling but pdp11 was more for data processing. Though pdp11 didn't have integrated peripherals&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see bottom of this page &lt;a href=&quot;http://www.cpushack.com/CPU/cpu4.html&quot; rel=&quot;nofollow&quot;&gt;http://www.cpushack.com/CPU/cpu4.html&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6247" LastActivityDate="2015-01-02T03:52:08.523" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="6806" PostTypeId="1" AcceptedAnswerId="6837" CreationDate="2015-01-02T04:49:33.167" Score="0" ViewCount="777" Body="&lt;p&gt;I am attempting to program my arduino in plain C, and I've come across some very strange behavior. If I load the following code from the Arduino IDE, it works as expected and toggles Pin 6 every 100ms. However, if I compile it with avr-gcc and then load it with avrdude, no interrupts are run.&#xA;Here is the C code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;int main();&#xA;void timer1_init();&#xA;&#xA;int main()&#xA;{&#xA;    // connect led to pin PD6&#xA;    DDRD |= (1 &amp;lt;&amp;lt; 6);&#xA;    PORTD |= (1 &amp;lt;&amp;lt; 6);&#xA;&#xA;    // initialize timer&#xA;    timer1_init();&#xA;&#xA;    // loop forever&#xA;    while(1)&#xA;    {&#xA;        // do nothing&#xA;        // whenever a match occurs, ISR is fired&#xA;        // toggle the led in the ISR itself&#xA;        // no need to keep track of any flag bits here&#xA;        // done!&#xA;    }&#xA;}&#xA;&#xA;// initialize timer, interrupt and variable&#xA;void timer1_init()&#xA;{&#xA;    /*cli();*/&#xA;    /*TCCR1A = 0;*/&#xA;    /*TCCR1B = 0;*/&#xA;    /*TCNT1 = 0;*/&#xA;    OCR1A = 24999;&#xA;    TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10);&#xA;    TIMSK1 |= _BV(OCIE1A);&#xA;    sei();&#xA;}&#xA;&#xA;ISR (TIMER1_COMPA_vect)&#xA;{&#xA;    // toggle led here&#xA;    PORTD ^= (1 &amp;lt;&amp;lt; 6);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the Makefile I'm using to load it onto the arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CC = avr-gcc&#xA;CFLAGS = -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;&#xA;SOURCE = test&#xA;&#xA;all: load&#xA;&#xA;$(SOURCE): $(SOURCE).o&#xA;    $(CC) $(SOURCE).o -o $(SOURCE)&#xA;&#xA;hex: $(SOURCE)&#xA;    avr-objcopy -O ihex -R .eeprom $(SOURCE) $(SOURCE).hex&#xA;&#xA;load: hex&#xA;    avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:$(SOURCE).hex&#xA;&#xA;clean:&#xA;    rm -f *.o *.hex&#xA;    rm -f `find . -perm 755 | perl -pe 's/\.\n//g' | perl -pe 's/\.\/(\w+)\n/\1 /g'`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something that the arduino ide automatically adds to it that makes it work? What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here is the make output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -g -O0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106   -c -o test.o test.c&#xA;avr-gcc test.o -o test&#xA;avr-objcopy -O ihex -R .eeprom test test.hex&#xA;avrdude -F -V -c arduino -p ATMEGA328P -P /dev/tty.usbmodem1411 -b 115200 -U flash:w:test.hex&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.01s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: NOTE: &quot;flash&quot; memory has been specified, an erase cycle will be performed&#xA;         To disable this feature, specify the -D option.&#xA;         avrdude: erasing chip&#xA;         avrdude: reading input file &quot;test.hex&quot;&#xA;         avrdude: input file test.hex auto detected as Intel Hex&#xA;         avrdude: writing flash (196 bytes):&#xA;&#xA;         Writing | ################################################## | 100% 0.04s&#xA;&#xA;         avrdude: 196 bytes of flash written&#xA;&#xA;         avrdude: safemode: Fuses OK (E:00, H:00, L:00)&#xA;&#xA;         avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6498" LastEditorUserId="37523" LastEditDate="2019-11-06T17:25:46.043" LastActivityDate="2019-11-06T17:25:46.043" Title="TIMER1 CTC Interrupts not working with avr-gcc" Tags="|arduino-uno|interrupt|timers|avr-gcc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6807" PostTypeId="1" CreationDate="2015-01-02T09:04:53.430" Score="2" ViewCount="1801" Body="&lt;p&gt;I want to control several (undecided) cut strips of these led lights:&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00HSF65MC&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to turn the LEDs on and off from the arduino, but I know that the voltage is too high to work with with the arduino and I don't want to fry my arduino. I've looked into relay modules, but I'm a software guy and I don't understand even the difference between voltage and amperage (I think I have the idea down, but I get the two mixed up sometimes). I also don't know how much voltage or amperage I should be giving each strip or how to control that. I have all my code set up to control my arduino with my simple C# form I've made, but I'm dumbfounded when it comes to hardware, can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm not well into money so I'd like to avoid spending money on some relays if possible.&lt;/p&gt;&#xA;" OwnerUserId="6501" LastActivityDate="2015-01-02T09:04:53.430" Title="Controlling multiple LED strips with arduino" Tags="|arduino-uno|led|power|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6808" PostTypeId="1" CreationDate="2015-01-02T09:58:32.720" Score="1" ViewCount="4051" Body="&lt;p&gt;I'm working on an arduino project that uses the GSM Shield and the eHealthSensor from Cooking Hacks. However I ran into an issue in which the interrupt vectors from the header/cpp files used are being defined multiple time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I know where the definitions are, I am unsure as to how to circumvent this issue either by Arduino programming or modifying the files since I'm not too experienced in this field. Below are the code for the conflicting files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are the vectors that are in conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PinChangeInt.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #ifndef NO_PORTA_PINCHANGES&#xA;    ISR(PCINT0_vect) {&#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='A';&#xA;        #endif&#xA;        PCintPort::curr = portA.portInputReg;&#xA;        portA.PCint();&#xA;    }&#xA;    #define PORTBVECT PCINT1_vect&#xA;    #define PORTCVECT PCINT2_vect&#xA;    #define PORTDVECT PCINT3_vect&#xA;    #else&#xA;    #define PORTBVECT PCINT0_vect&#xA;    #define PORTCVECT PCINT1_vect&#xA;    #define PORTDVECT PCINT2_vect&#xA;    #endif&#xA;&#xA;    #ifndef NO_PORTB_PINCHANGES&#xA;    ISR(PORTBVECT) {&#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='B';&#xA;        #endif&#xA;        PCintPort::curr = portB.portInputReg;&#xA;        portB.PCint();&#xA;    }&#xA;    #endif&#xA;&#xA;    #ifndef NO_PORTC_PINCHANGES&#xA;    ISR(PORTCVECT) {&#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='C';&#xA;        #endif&#xA;        PCintPort::curr = portC.portInputReg;&#xA;        portC.PCint();&#xA;    }&#xA;    #endif&#xA;&#xA;    #ifndef NO_PORTD_PINCHANGES&#xA;    ISR(PORTDVECT){ &#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='D';&#xA;        #endif&#xA;        PCintPort::curr = portD.portInputReg;&#xA;        portD.PCint();&#xA;    }&#xA;    #endif&#xA;&#xA;    #ifdef __USE_PORT_JK&#xA;    #ifndef NO_PORTJ_PINCHANGES&#xA;    ISR(PCINT1_vect) {&#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='J';&#xA;        #endif&#xA;        PCintPort::curr = portJ.portInputReg;&#xA;        portJ.PCint();&#xA;    }&#xA;    #endif&#xA;&#xA;    #ifndef NO_PORTK_PINCHANGES&#xA;    ISR(PCINT2_vect){ &#xA;        #ifdef PINMODE&#xA;        PCintPort::s_PORT='K';&#xA;        #endif&#xA;        PCintPort::curr = portK.portInputReg;&#xA;        portK.PCint();&#xA;    }&#xA;    #endif&#xA;&#xA;    #endif // __USE_PORT_JK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;GSM3SoftSerial.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This is here to avoid problems with Arduino compiler&#xA;void GSM3SoftSerialMgr::manageMsg(byte from, byte to){};&#xA;&#xA;//#define PCINT1_vect _VECTOR(2)&#xA;//#undef PCINT1_vect&#xA;&#xA;#if defined(PCINT0_vect)&#xA;ISR(PCINT0_vect)&#xA;{&#xA;  GSM3SoftSerial::handle_interrupt();&#xA;}&#xA;#endif&#xA;&#xA;#if defined(PCINT1_vect)&#xA;ISR(PCINT1_vect)&#xA;{&#xA;  GSM3SoftSerial::handle_interrupt();&#xA;}&#xA;#endif&#xA;&#xA;#if defined(PCINT2_vect)&#xA;ISR(PCINT2_vect)&#xA;{&#xA;  GSM3SoftSerial::handle_interrupt();&#xA;}&#xA;#endif&#xA;&#xA;#if defined(PCINT3_vect)&#xA;ISR(PCINT3_vect)&#xA;{&#xA;  GSM3SoftSerial::handle_interrupt();&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any advice on how to fix this will be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, I am using an Arduino Mega 2560.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastActivityDate="2016-01-28T11:02:36.520" Title="Multiple Definition of &quot;_Vectors&quot;?" Tags="|programming|arduino-mega|c++|pins|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6810" PostTypeId="1" AcceptedAnswerId="34057" CreationDate="2015-01-02T14:55:22.673" Score="2" ViewCount="370" Body="&lt;p&gt;I was hoping to create a cheap security system by connecting an Arduino to the phone line output of a base station.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the base station should call a phone number if the alarm is tripped I wouldn't have to do much hardware hacking so long as I can read/parse the output from the base station.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is can I read serial output from a phone line like this?&lt;/p&gt;&#xA;" OwnerDisplayName="user3596" LastActivityDate="2017-01-30T22:04:01.193" Title="Serial Connection to Phone Line" Tags="|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6813" PostTypeId="1" AcceptedAnswerId="6814" CreationDate="2015-01-02T18:12:09.757" Score="1" ViewCount="95" Body="&lt;p&gt;I want to use the VCNL4000 Proximity/Light sensor s.&#xA;&lt;a href=&quot;http://www.adafruit.com/products/466?&amp;amp;main_page=product_info&amp;amp;products_id=466&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.adafruit.com/products/466?&amp;amp;main_page=product_info&amp;amp;products_id=466&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the package i've this 6 pin connector but the VCNL has 5 pins (i now i can connect it by myself with male jumper) but  what am i missing here? &lt;img src=&quot;https://i.stack.imgur.com/pidtP.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;I assume that it is not an &quot;accident&quot; that the thing has one more pin then the sensor ; )&lt;/p&gt;&#xA;" OwnerUserId="6447" LastActivityDate="2015-01-02T18:32:08.013" Title="VCNL4000 Proximity/Light sensor" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6814" PostTypeId="2" ParentId="6813" CreationDate="2015-01-02T18:32:08.013" Score="3" Body="&lt;p&gt;You can just cut off the extra pin. Adafruit probably just had a bunch of 6 pin headers in their stock. &lt;/p&gt;&#xA;" OwnerUserId="33" LastActivityDate="2015-01-02T18:32:08.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6815" PostTypeId="1" CreationDate="2015-01-02T18:43:12.467" Score="0" ViewCount="776" Body="&lt;p&gt;I was looking for wiring the VCNL 4000 Proximity Sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this one &lt;a href=&quot;http://bildr.org/2012/11/vcnl4000-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://bildr.org/2012/11/vcnl4000-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but there is used a sensor on a red board, which has other pins like mine (which has a blue board) see &lt;a href=&quot;http://www.adafruit.com/products/466?&amp;amp;main_page=product_info&amp;amp;products_id=466&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/466?&amp;amp;main_page=product_info&amp;amp;products_id=466&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as I see SCL,DSA,GRND on both&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the red has IR+ which is connected to the 5V . mine (blue one) has VIN. Is this meant to be the same and should it be connected to the 5V ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any hints?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following wiring but the following call does not finish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3,3V TO 3,3V POWER&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCL TO SCL (Last pin on the digital side)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SDA to SDA (Beside SCL)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND TO GND on the Analog side&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin to 5V&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; readVCNLByte(0x81); is called&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i used the example code from adafruiut&lt;/p&gt;&#xA;" OwnerUserId="6447" LastEditorUserId="6447" LastEditDate="2015-01-02T19:19:06.410" LastActivityDate="2015-01-04T11:01:32.997" Title="Wiring VCNL 4000 Proximity Sensor" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6816" PostTypeId="1" CreationDate="2014-12-31T05:02:59.447" Score="2" ViewCount="593" Body="&lt;p&gt;I'm working on an Arduino project involving an UNO. &#xA;I'm powering a 20x4 LCD screen and I am using all the ports on the Arduino, to the last. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All but four of them are pulled high at any given time, so by the time I'm done with pulling them all up the screen is going dim when powering via USB. &#xA;So I tried powering via an external 9V 600mA adapter, but that makes the Arduino overheat and eventually shut down.&#xA;I then tried another, 12V 500mA adapter, and that one doesn't even get my UNO to the end of the setup function, and it reboots repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone got good advice? Ideas?&lt;/p&gt;&#xA;" OwnerDisplayName="Quitty" LastEditorUserId="7120" LastEditDate="2015-02-03T21:59:11.417" LastActivityDate="2015-02-04T00:17:40.463" Title="Arduino power consumption issues" Tags="|power|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6817" PostTypeId="2" ParentId="6816" CreationDate="2014-12-31T10:00:47.013" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;The official arduino uno schematic&lt;/a&gt; uses a &lt;a href=&quot;http://www.onsemi.com/PowerSolutions/product.do?id=NCP1117&quot; rel=&quot;nofollow&quot;&gt;NPC1117&lt;/a&gt; voltage regulator. This is a linear one. This means that if you put 12V on it, and if your system requises 0.5A, you Will leak 0.5A on the 12V, and, if there is 5V on the output, 12V on the input, there is a 7V drop on the regulator, 7V * 0.5A = 3.5W that turns into heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid overheating, the solution isn't to increase the input voltage, but to decrease it. If you have a 6.2V power supply, this will minimize overheating. At least 6.2V are required for the NPC1117 to provide a stable 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An other option is to use a USB 5V power supply with an output current greater than 0.5A. This is often used with smartphones. This allows to bypass the NPC1117, but the power supply shall be exactly 5V (where exactly stands for less than 10% of over or undervoltage). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, please note:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino does not recommend bypass[ing the] Vin supply to directly supply 5V rail on the board as it will damage the NPC1117. See the first two line on page # 3 from the document link below. &lt;a href=&quot;http://media.digikey.com/pdf/Data%20Sheets/Arduino%20PDFs/ArduinoEthernet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://media.digikey.com/pdf/Data%20Sheets/Arduino%20PDFs/ArduinoEthernet.pdf&lt;/a&gt;&#xA;  You can either do the soldering and remove NPC1117 chip before you apply 5V directly onto the board or find a higher current capability power supply with the output voltage between 7v-12V.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6513" OwnerDisplayName="Jacen" LastEditorUserId="220" LastEditDate="2015-02-04T00:17:40.463" LastActivityDate="2015-02-04T00:17:40.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6818" PostTypeId="2" ParentId="6808" CreationDate="2015-01-02T19:03:42.490" Score="2" Body="&lt;p&gt;It's linking problem. More .o files included in linking declares identical global symbol eg. &lt;code&gt;ISR(PCINT1_vect)&lt;/code&gt;. Ideally write own &lt;em&gt;makefile&lt;/em&gt; and compile via standard &lt;em&gt;make&lt;/em&gt;. As hack you can loook in &lt;em&gt;PinChangeInt.h&lt;/em&gt; conditional parts and make global definitions not to avoid *ISR()*s, e.g. &lt;code&gt;#define __USE_PORT_JK&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-01-02T19:03:42.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6819" PostTypeId="1" CreationDate="2015-01-02T19:06:25.187" Score="0" ViewCount="199" Body="&lt;p&gt;I've used the arduino uno with the python serial library months ago and some packets got lost in the way. I've been searching about serial communication for arduino and I've been thinking that I could use some parity systems and other things to guarantee that my packets will arrive. First of all, if I use the parity system of the arduino's serial library, how good it will be? I need to send packets like &quot;this button was touched&quot;, but ALL packets must arrive, so if some packet fails, I need to send it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make it possible? I'm thinking about using the parity system of the arduino's library, but I don't think if it's gonna work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody point me some good text about it?&lt;/p&gt;&#xA;" OwnerUserId="6511" LastEditorUserId="2881" LastEditDate="2015-01-02T22:05:41.887" LastActivityDate="2015-01-02T22:05:41.887" Title="About arduino serial communication" Tags="|serial|i2c|communication|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6820" PostTypeId="2" ParentId="6819" CreationDate="2015-01-02T19:19:16.987" Score="1" Body="&lt;p&gt;There is no way to &lt;em&gt;guarantee&lt;/em&gt; that all packets will arrive. The best you can do is to have the receiving system acknowledge receipt of all packets, with enough data within to verify the correctness of the packets.&lt;/p&gt;&#xA;&lt;p&gt;UART parity is not a good method to verify correctness since it can only detect single-bit errors within a byte; two bit errors will verify correctly, and of course the entire byte may get dropped before it can even get to the receiver.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc916&quot; rel=&quot;nofollow noreferrer&quot;&gt;RFC 916&lt;/a&gt;, &amp;quot;RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)&amp;quot;, describes a TCP/IP-like method of sending data reliably over an asynchronous medium. It's more wordy than just sending a byte containing status changes, but if you need reliability then you need more than that.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2021-10-07T07:34:52.683" LastActivityDate="2015-01-02T19:19:16.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6821" PostTypeId="1" AcceptedAnswerId="6822" CreationDate="2015-01-01T20:00:32.827" Score="0" ViewCount="408" Body="&lt;p&gt;I need to make circuit in which orange LED will light only when yellow and red are disconnected. When one of buttons is pushed orange LED should turn off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my attempt at it below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to electronics so your help is very appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/N75Z5.png&quot; alt=&quot;Fritzing diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After many atemps I managed to build this circuit as on left side of schematic (tested on live breadboard)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/A31Fw.png&quot; alt=&quot;schematics&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but my primary goal is to make this work with RGB LED. I took Common Anode RGB LED for this and build circuit on right side of schematic. I do not have such RGB LED to test it live so I ask you to review if that schematic will work as it has few changes to one with 3 LED's. Thank you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLUTION:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to Bruce's help my circuit now works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 separate LEDs emulate common anode RGB LED (as I do not have one to test circuit)&lt;br&gt;&#xA;Q2 is BC 560B transistor with CBE type pinout&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ig8uq.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8BtrL.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(2,INPUT);&#xA;  pinMode(4,INPUT);&#xA;  Serial.begin(9600);&#xA;  digitalWrite(2,HIGH);&#xA;  digitalWrite(4,HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(digitalRead(2));&#xA;  Serial.println(digitalRead(4));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="485" OwnerDisplayName="nysander" LastActivityDate="2015-01-02T21:16:26.417" Title="Light LED when 2 others are disconnected" Tags="|led|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6822" PostTypeId="2" ParentId="6821" CreationDate="2015-01-02T05:34:20.160" Score="1" Body="&lt;p&gt;You want the green LED to be on &lt;em&gt;only&lt;/em&gt; when the red and blue LEDs are both off. In other words, you want the voltage on the green LED to be LOW only when the voltages on the red and blue LEDs are both HIGH. That is a logical NAND function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your right-hand circuit with the RGB LED won't work because the transistor's collector is connected to the wrong place - it's shorting out the battery! Another problem is that the Arduino can only switch to Ground or +5V, so it can't replace a 'floating' switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a configuration that produces a logical NAND function. Your left-hand circuit is doing it, but won't work with a common anode RGB LED. So swap the transistor to a PNP  type, and add a couple of resistors to switch it on when either input goes low, like this:-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xK7ud.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="30199" OwnerDisplayName="Bruce Abbott" LastActivityDate="2015-01-02T05:34:20.160" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6823" PostTypeId="1" AcceptedAnswerId="6825" CreationDate="2015-01-03T01:39:16.483" Score="0" ViewCount="1194" Body="&lt;p&gt;I am attempting to send data from my Arduino to my computer using the WiFi shield.  However, my code is erroring out on UDP.endPacket(), and I do not understand why.  Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiUDP.h&amp;gt;&#xA;&#xA;int status = WL_IDLE_STATUS;&#xA;char ssid[] = &quot;NETGEAR31&quot;; //  your network SSID (name)&#xA;char pass[] = &quot;oddearth926&quot;;    // your network password (use for WPA, or use as key for WEP)&#xA;&#xA;char  ReplyBuffer[] = &quot;acknowledged&quot;;       // a string to send back&#xA;&#xA;WiFiUDP Udp;&#xA;&#xA;void setup()&#xA;{&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) &#xA;  {&#xA;    Serial.println(&quot;WiFi shield not present&quot;);&#xA;    // don't continue:&#xA;    while (true);&#xA;  }&#xA;  // attempt to connect to Wifi network:&#xA;  while ( status != WL_CONNECTED)&#xA;  {&#xA;    Serial.print(&quot;Attempting to connect to SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;  }&#xA;  Serial.println(&quot;Connected to wifi&quot;);&#xA;  printWifiStatus();&#xA;  Serial.println(&quot;\nStarting connection to server...&quot;);&#xA;  if(!Udp.begin(8765))&#xA;  {&#xA;    Serial.println(F(&quot;failed&quot;));&#xA;  }&#xA;&#xA;  // if you get a connection, report back via serial:&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  IPAddress ip(10,0,0,5);&#xA;  int port = 8766;&#xA;    // send a reply, to the IP address and port that sent us the packet we received&#xA;    if(!Udp.beginPacket(ip, port))&#xA;    {&#xA;      Serial.println(F(&quot;Failed beginning packet&quot;));&#xA;    }&#xA;    Udp.print(ReplyBuffer);&#xA;&#xA;    if(!Udp.endPacket())&#xA;    {&#xA;      Serial.println(F(&quot;Failed ending packet&quot;)); &#xA;    }&#xA;}&#xA;&#xA;&#xA;void printWifiStatus() {&#xA;  // print the SSID of the network you're attached to:&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;&#xA;  // print your WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Address: &quot;);&#xA;  Serial.println(ip);&#xA;&#xA;  // print the received signal strength:&#xA;  long rssi = WiFi.RSSI();&#xA;  Serial.print(&quot;signal strength (RSSI):&quot;);&#xA;  Serial.print(rssi);&#xA;  Serial.println(&quot; dBm&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Attempting to connect to SSID: NETGEAR31&#xA;Connected to wifi&#xA;SSID: NETGEAR31&#xA;IP Address: 10.0.0.34&#xA;signal strength (RSSI):-63 dBm&#xA;&#xA;Starting connection to server...&#xA;Failed ending packet&#xA;Failed ending packet&#xA;Failed ending packet&#xA;Failed ending packet&#xA;Failed ending packet&#xA;Failed ending packet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will continue to spit out &quot;Failed ending packet&quot; until I stop it.  Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6514" LastActivityDate="2015-01-03T04:11:06.210" Title="WiFi UDP.endPacket() continuously fails" Tags="|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6824" PostTypeId="2" ParentId="6801" CreationDate="2015-01-03T02:40:13.270" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/6436/how-to-go-from-newbie-to-manufactured&quot;&gt;First, you should read this this question here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reasonable answer here varies a lot depending on how involved you want to get, and what volumes you want to sell at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately, you're not using any breakouts with truly exotic parts. The nRF8001 is just a QFN part, which can be soldered by hand without too much trouble. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaking loosely, the process would look like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Design a PCB layout that contains everything.&lt;/li&gt;&#xA;&lt;li&gt;(Optional) - Figure out if you want to put it in a enclosure of some sort.&lt;/li&gt;&#xA;&lt;li&gt;(Optional) - Determine how you're going to have the enclosures produced or modified from an existing product. You can have a contract machine-shop do the work, but again, $$$$.&lt;/li&gt;&#xA;&lt;li&gt;Send out to have PCB prototypes manufactured. I like &lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OSHPark&lt;/a&gt;, but there are &lt;a href=&quot;https://electronics.stackexchange.com/questions/7003/best-one-off-diy-pcb-creation-technique/7014#7014&quot;&gt;LOTS of options&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Assemble your boards.&lt;/li&gt;&#xA;&lt;li&gt;Find out your prototype doesn't work.&lt;/li&gt;&#xA;&lt;li&gt;Go back to step 1 (expect this to happen a few times)&lt;/li&gt;&#xA;&lt;li&gt;Rent/Beg/Borrow some equipment to do EMC pre-qualification testing (for FCC).&lt;/li&gt;&#xA;&lt;li&gt;Realize you have an EMC disaster.&lt;/li&gt;&#xA;&lt;li&gt;Respin boards a few more times (e.g. go back to 1 again) to fix the pre-qualification EMC issues.&lt;/li&gt;&#xA;&lt;li&gt;Feel like you have a decent layout, have it FCC tested.&lt;/li&gt;&#xA;&lt;li&gt;Pay $10K+ for FCC testing.&lt;/li&gt;&#xA;&lt;li&gt;If you're lucky, you passed, you now have a proper, FCC certified product.&lt;/li&gt;&#xA;&lt;li&gt;Nope, go back to 1 again if you failed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do lot assembly, either manually (major time investment), or contract out (expensive!).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sell your widget!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that you can contract out the prototype assembly, but doing so is &lt;em&gt;expensive&lt;/em&gt;, even if you do it in china. The magic (or cursed, really) term here is &quot;NRE&quot;, or non-reoccurring expenses/engineering. Colloquially, it's the &quot;setup cost&quot; of doing a production run. Sure, you may only pay $5-50 per-widget to have them assembled, but there will be a $1000+ base charge. This reflects the fact that the primary time-cost on the part of an assembly house to build your widget is setting up the production line, working up and debugging a pick-and-place routine, building test-setups, etc... Once everything is up and running, the actual per-unit cost is fairly marginal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also why commercial electronic devices can be so cheap. They're made in truly enormous volumes, and that lets the companies amortize the NREs across the entire production run. NREs are basically the bane of any small electronics business. They're also basically &lt;em&gt;the&lt;/em&gt; reason specialty widgets are so expensive. Places like spark-fun can get away with fairly cheap products because they have their own complete assembly line in-house, and even there, you're often paying 4X+ the cost of parts for just the IC on a PCB with a few cents worth of passives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you seem to be new to PCB design, this is possibly not a great first project. It's doable, but expect it to cost 4X+ what you expect, and take 2X+ the time you planned. There are a LOT of facets to designing a proper product, and they each contain an entire field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'd probably be better off to start out with some simpler boards, maybe a through-hole-only arduino clone, or similar (though SOIC can be soldered without a hot-air station or anything). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some assumptions I'm making:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you're serious, you will &lt;em&gt;have&lt;/em&gt; to lean SMT assembly practices. Through-hole only is not a viable stance anymore.&lt;/li&gt;&#xA;&lt;li&gt;Expect to buy a lot of tools, and burn a lot of money in failed prototypes.&lt;/li&gt;&#xA;&lt;li&gt;Expect 3 board revisions. &lt;strong&gt;At minimum&lt;/strong&gt;, before you have something you can get tested. I could maybe do it in 2, if I got really, &lt;em&gt;really&lt;/em&gt; lucky, but I doubt that would happen, and this sort of thing is my day-job.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://danluu.com/hardware-unforgiving/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hardware&lt;/a&gt; is &lt;a href=&quot;http://lemnoslabs.com/2014/01/why-hardware-is-hard/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HARD&lt;/a&gt;, and worse, it's completely unforgiving. If you're coming from a software engineering background, you basically have to discard all your assumptions, as they will actively hurt you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine a software project where &quot;compiling&quot; can take 4 weeks. That's hardware development.&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-03T11:43:58.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6825" PostTypeId="2" ParentId="6823" CreationDate="2015-01-03T04:11:06.210" Score="0" Body="&lt;p&gt;Fixed by updating firmware on Wifi Shield.&lt;/p&gt;&#xA;" OwnerUserId="6514" LastActivityDate="2015-01-03T04:11:06.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6826" PostTypeId="1" CreationDate="2015-01-03T05:00:10.927" Score="1" ViewCount="2971" Body="&lt;p&gt;So, I've gotten my module working pretty well. It logs data from the DHT22 and sends it to a 192 address on my LAN. However, I'd like to log and graph the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured thingspeak is a decent platform for that. However, I have no experience doing so, and I'm not sure where to start. All the examples use the &quot;official&quot; arduino shield. I've only found ONE example bit of code, but it uses the Dallas One Wire temp module. &lt;a href=&quot;https://xa.yimg.com/kq/groups/65275256/1011665768/name/Blank_Thingspeak_Ethercard.ino&quot; rel=&quot;nofollow&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm in over my head, and have no idea how to switch from the One wire to the DHT22. Thanks for the help! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a clone arduino pro mini, 5V 16mhz, 328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's a better platform than thingspeak, I'm open. All I want to do is graph and visualize the DHT22 sensor readings.&lt;/p&gt;&#xA;" OwnerUserId="4722" LastActivityDate="2016-11-21T06:28:38.510" Title="Uploading Temperature data (DHT22) to Thingspeak with an ENC28J60" Tags="|sensors|arduino-pro-mini|ethernet|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6829" PostTypeId="2" ParentId="4812" CreationDate="2015-01-03T08:40:13.980" Score="1" Body="&lt;p&gt;Adafruit GPS breakout has their own library setup.&lt;br&gt;&#xA;Below is the code I use for my telemetry. Notice I'm using HardwareSerial though.&lt;br&gt;&#xA;You can just change that into SoftwareSerial.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GPS.h&amp;gt;&#xA;#define GPSECHO false // Disables GPS breakout debug&#xA;&#xA;boolean usingInterrupt = false;&#xA;&#xA;HardwareSerial gpsSerial = Serial1;&#xA;Adafruit_GPS GPS(&amp;amp;Serial1);&#xA;&#xA;SoftwareSerial XBee(2, 3); // For wireless&#xA;&#xA;unsigned int REFRESH = 20;&#xA;&#xA;double lat_deg, lon_deg, lat_min, lon_min;&#xA;char lat, lon;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;&#xA;  GPS.begin(115200);&#xA;  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);&#xA;  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ); // Either 1HZ or 5HZ&#xA;  GPS.sendCommand(PMTK_API_SET_FIX_CTL_5HZ);&#xA;  GPS.sendCommand(PGCMD_ANTENNA);&#xA;&#xA;  useInterrupt(true);&#xA;}&#xA;&#xA;SIGNAL(TIMER0_COMPA_vect)&#xA;{&#xA;  char c = GPS.read();&#xA;#ifdef UDR0&#xA;  if (GPSECHO)&#xA;    if (c) UDR0 = c;&#xA;#endif&#xA;}&#xA;&#xA;void useInterrupt(boolean v)&#xA;{&#xA;  if(v)&#xA;  {&#xA;    OCR0A = 0xAF;&#xA;    TIMSK0 |= _BV(OCIE0A);&#xA;    usingInterrupt = true;&#xA;  }&#xA;  else&#xA;  {&#xA;    TIMSK0 &amp;amp;= ~_BV(OCIE0A);&#xA;    usingInterrupt = false;&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(GPS.newNMEAreceived())&#xA;  {&#xA;    if(!GPS.parse(GPS.lastNMEA()))&#xA;    {&#xA;      writeData(1, true);&#xA;      Serial.print(GPS.hour, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.minute, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.seconds, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print((int)GPS.fix); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print((int)GPS.fixquality); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;)); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;)); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;)); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;)); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;)); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(F(&quot;-999&quot;));&#xA;    }&#xA;    else if(GPS.fix)&#xA;    {&#xA;      writeData(1, true);&#xA;      parseGPS(GPS.latitude, GPS.longitude);&#xA;      Serial.print(GPS.hour, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.minute, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.seconds, DEC); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print((int)GPS.fix); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print((int)GPS.fixquality); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(lat_dd, 8); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(lon_dd, 8); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.speed); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.angle); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.altitude); Serial.print(F(&quot;,&quot;));&#xA;      Serial.print(GPS.satellites);&#xA;    }&#xA;  }&#xA;  delay(REFRESH);&#xA;}&#xA;&#xA;void parseGPS(float _latitude, float _longitude)&#xA;{&#xA;  lat_deg = (int) (_latitude / 100);&#xA;  lon_deg = (int) (_longitude / 100);&#xA;&#xA;  lat_min = _latitude - (lat_deg * 100);&#xA;  lon_min = _longitude - (lon_deg * 100);&#xA;&#xA;  lat_dd = (double) lat_deg + ((double) lat_min / 60);&#xA;  lon_dd = (double) lon_deg + ((double) lon_min / 60);&#xA;&#xA;  lat = GPS.lat; lon = GPS.lon;&#xA;&#xA;  if (lat == 'S') lat_dd = -lat_dd;&#xA;  if (lon == 'W') lon_dd = -lon_dd;&#xA;}&#xA;&#xA;void writeData(float data, boolean next)&#xA;{&#xA;  Serial.print(data);&#xA;  if (next) Serial.print(F(&quot;,&quot;));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6516" LastActivityDate="2015-01-03T08:40:13.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6831" PostTypeId="1" AcceptedAnswerId="6833" CreationDate="2015-01-03T13:28:00.080" Score="2" ViewCount="988" Body="&lt;p&gt;I just started to use the unusual part of Arduino language (avr) like interrupts, accessing registers, etc in Arduino IDE. I wrote a program to calculate the frequency of a digital signal using external interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code is to calculate timeperiod of a digital signal, the output of the color sensor (TCS3200) which depends on the color filter choosen via S2 and S3 pins, as in the code. That is, color sensor produces 50% duty cycle square pulses of frequency dependent on the power of the light incident on it. So when sensor faces red color, output signal's frequency in red color mode (by setting S2, S3 pins) is more than the frequency in blue and green modes. Thus we can detect the likeliness of the color which it faces w.r.t  R,G,B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this code is uploaded in the Arduino, it failed to print the values as expected in the serial monitor i.e. its stuck in while loops. But when &lt;code&gt;Serial.print(e)&lt;/code&gt; statement in the while loops are uncommented, it is able to print the required time periods. I am unable to figure out the problem here, which is making Arduino to be inside the while loop when no statements are in it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// INT0 interupt is used i.e. digital pin 2&#xA;int ti=0,tim=0,e=0,S2=4,S3=5;&#xA;&#xA;void Interruptinit() //initializing interrupt INT0&#xA;{&#xA;  cli();&#xA;  EICRA =  0x02; //Control register&#xA;  EIMSK =  0x01; //Mask register&#xA;  sei();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(2,INPUT);&#xA;  digitalWrite(2,HIGH); //enabling pull up register&#xA;  pinMode(S2,OUTPUT);&#xA;  pinMode(S3,OUTPUT);&#xA;  Interruptinit();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;ISR(INT0_vect)&#xA;{&#xA;  tim=micros()-ti;&#xA;  ti=micros();&#xA;  e++;&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;  digitalWrite(S2,0); digitalWrite(S3,0); //switching over red filtered photodiodes&#xA;  e=0;&#xA;  while(e&amp;lt;2)&#xA;  //Serial.print(e) //waiting till interrupt is addressed 2 times     &#xA;  ;&#xA;  Serial.print(&quot;red:&quot;);&#xA;  Serial.print(tim);&#xA;&#xA;  digitalWrite(S2,0); digitalWrite(S3,1); //switching over blue filtered photodiodes&#xA;  e=0;&#xA;  while(e&amp;lt;2)&#xA;  //Serial.print(e)&#xA;  ;&#xA;  Serial.print(&quot; blue:&quot;);&#xA;  Serial.print(tim);&#xA;&#xA;  digitalWrite(S2,1); digitalWrite(S3,1); //switching over green filtered photodiodes&#xA;  e=0;&#xA;  while(e&amp;lt;2)&#xA;  //Serial.print(e)&#xA;  ;&#xA;  Serial.print(&quot; green:&quot;);&#xA;  Serial.println(tim);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1711" LastEditorUserId="1711" LastEditDate="2015-01-04T17:57:45.043" LastActivityDate="2015-01-04T17:57:45.043" Title="Problem with while loops while detecting frequency of a signal" Tags="|arduino-uno|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6832" PostTypeId="1" AcceptedAnswerId="19103" CreationDate="2015-01-03T14:14:02.763" Score="0" ViewCount="1662" Body="&lt;p&gt;I'm looking for a storage solution for small files that would be moved into a small sensor running arduino-like processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally the single memory unit would be cheap (in 1-10 cents range), but the memory can be very limited (several megabytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest I've got so far is small SD Memory card, but the smallest 4GB ones cost several dollars (at least bought in quantities &amp;lt; 100). Anything else I should be looking at?&lt;/p&gt;&#xA;" OwnerUserId="6519" LastEditorUserId="4628" LastEditDate="2015-07-03T12:36:37.397" LastActivityDate="2015-12-30T21:21:15.027" Title="Cheap 2-5mb memory to use with arduino" Tags="|flash|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6833" PostTypeId="2" ParentId="6831" CreationDate="2015-01-03T15:14:20.647" Score="3" Body="&lt;p&gt;Whenever you modify non-local variables in an ISR, it's important that they are declared as &lt;code&gt;volatile&lt;/code&gt;. This tells the compiler that the contents may change unexpectedly, ensuring it doesn't use out-of-date cached copies somewhere else. If you don't do this, the code can behave in unpredictable ways, such as outputting the wrong value under some circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the variables are bigger than 1 byte, it's also necessary to disable interrupts around non-ISR code which uses them (e.g. in &lt;code&gt;loop()&lt;/code&gt;). This is because interrupts could be triggered at any time, potentially half way through an operation which reads/writes them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;noInterrupts()&lt;/code&gt; and &lt;code&gt;interrupts()&lt;/code&gt; to disable/enable interrupt handling.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-03T15:14:20.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6834" PostTypeId="1" AcceptedAnswerId="6838" CreationDate="2015-01-03T18:04:55.177" Score="0" ViewCount="3161" Body="&lt;p&gt;I know that I can program Arduino with python but is it possible to make every project, which can be completed by normal IDE?&lt;/p&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="4628" LastEditDate="2015-01-04T17:00:27.263" LastActivityDate="2015-01-05T10:09:03.837" Title="Can I program Arduino with Python?" Tags="|programming|arduino-ide|c|python|" AnswerCount="3" CommentCount="9" ClosedDate="2015-01-05T18:58:13.917" ContentLicense="CC BY-SA 3.0" />
  <row Id="6835" PostTypeId="1" CreationDate="2015-01-03T19:26:37.927" Score="6" ViewCount="1020" Body="&lt;p&gt;I'm very new to using Arduino!  I'll be using Ocean Controls KTA 259 thermocouple multiplexing shield AND a Sparkfun microSD shield on my UNO--to log temperature data for a study I'm doing.  The KTA 259 has a library and the integral SD library should work for the SD shield.&lt;br&gt;&#xA;Q1:  I believe they &lt;em&gt;physically&lt;/em&gt; connect no problem, but how can I be sure there are no pin conflicts, disastrous or otherwise?  In other words--what conditions &lt;strong&gt;MUST&lt;/strong&gt; I avoid using shields and multiple shields?&lt;br&gt;&#xA;Q2:  Can (or must) a single data pin be used by both shields, eg from thermo as output to SD as input, or does Arduino juggle all that?&#xA;Q3:  Can (or must) a single function, eg CS, be mapped onto the same pin on BOTH shields, or do they have to be separate allowing Arduino to handle that?&#xA;Thank you; I appreciate the help!    &lt;/p&gt;&#xA;" OwnerUserId="6524" LastActivityDate="2015-02-03T00:00:01.687" Title="Using MULTIPLE shields on Arduino Uno R3" Tags="|shields|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6836" PostTypeId="2" ParentId="6834" CreationDate="2015-01-03T21:31:29.553" Score="0" Body="&lt;p&gt;Not really, since python is an interpreted programming language.&#xA;If you are not new to the microcontrollers' world and have same experience, maybe &lt;a href=&quot;https://micropython.org/&quot; rel=&quot;nofollow&quot;&gt;this Board&lt;/a&gt; is you what you want. More powerful than Arduino and completely programble using Python 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=192552.0&quot; rel=&quot;nofollow&quot;&gt;Topic: Can I use Python to program Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6330" LastEditorUserId="6330" LastEditDate="2015-01-04T20:28:02.910" LastActivityDate="2015-01-04T20:28:02.910" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="6837" PostTypeId="2" ParentId="6806" CreationDate="2015-01-04T00:11:23.603" Score="0" Body="&lt;p&gt;I just tried using arduino-mk &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sudar/Arduino-Makefile&lt;/a&gt;, and it worked, so I guess I'm just going to stick with that.&lt;/p&gt;&#xA;" OwnerUserId="6498" LastActivityDate="2015-01-04T00:11:23.603" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6838" PostTypeId="2" ParentId="6834" CreationDate="2015-01-04T01:14:16.533" Score="3" Body="&lt;p&gt;I imagine you want to use python because you are already familiar with it, know your way around the syntax, etc. But I would advice against this line of thinking, because microcontrollers need a little more of &quot;low-level&quot; thinking (given the limited resources they generally have) and because of that, it's probably best if you learn some C/C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino programming framework provides some not-so-low-level libraries and tools (like the arduino IDE itself) to make it easy for non-C programmers to learn C-like programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you want to use python as a proof of concept or anything else, sorry about the misunderstanding! :)&lt;/p&gt;&#xA;" OwnerUserId="6525" LastActivityDate="2015-01-04T01:14:16.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6839" PostTypeId="1" AcceptedAnswerId="6851" CreationDate="2015-01-04T03:04:04.010" Score="1" ViewCount="5843" Body="&lt;p&gt;So, this question might sound a bit silly at first glance (no, I know, it sounds flat out insane), but not all that silly at second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have heard once about a guy who transformed some (presumably old-ish) washing machine into his own personal home-brewing apparatus. It is quite some idea if you think about it. Washing machine can easily solve most issues people have with homebrewing. It can carefully control and adjust temperature throughout the long and complicated process of brewing, it can stir, it can pump in fresh water.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main question is, how to control washing machine to do what I want it to do.  Most automatic washing machines already have some controllers, but I don't see much chance in trying to simply reprogram them (Am I wrong?). &lt;strong&gt;Arduino seems like best choice for its simplicity and expandability. However I am still fairly new to Arduino and have trouble imagining how would connecting everything from washing machine (motor, pump, maybe water and temperature sensors) to Arduino actually look like.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;So is it even possible? Are there any projects to &quot;bounce of&quot;?&lt;/em&gt; (I couldn't find any, but maybe I looked for wrong projects) &lt;em&gt;Should I expect any major problems?&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="6526" LastActivityDate="2015-01-04T22:46:59.090" Title="Washing machine controlled by Arduino for homebrewing" Tags="|system-design|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6840" PostTypeId="1" AcceptedAnswerId="6844" CreationDate="2015-01-04T09:54:25.217" Score="2" ViewCount="1766" Body="&lt;p&gt;i have some data logging to do. And i want some what accurate time meaning accuracy has to be +/- 1 minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have considered a RTC, but then i thought. When i was 10 i got a watch that kept time from this radio clock. And if it is possible 20 years ago to make a clock that updates automatically in such as small form factor, then i should be able to do it with my arduino today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know of a guide/solution with components where i can read this atomic radio clock?&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-01-04T12:04:54.827" Title="Reading atomic radio clock" Tags="|time|datalogging|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6841" PostTypeId="2" ParentId="6815" CreationDate="2015-01-04T11:01:32.997" Score="1" Body="&lt;p&gt;There seems to be a big difference between the Sparkfun and the Adafruit breakouts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sparkfun breadkout needs 3.3V and 5V power as &lt;strong&gt;inputs&lt;/strong&gt; as shown in their wiring circuit (in the first link you mentioned)&lt;/li&gt;&#xA;&lt;li&gt;Adafruit breakout needs only 5V as input but has a 3.3V regulator on it that provides the 3.3V to all its internal circuits that need it; it also has a 3.3V pin which is an &lt;strong&gt;output&lt;/strong&gt; not an input as for the Sparkfun&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hence your wiring is wrong. The expected wiring is described in &lt;a href=&quot;https://github.com/adafruit/VCNL4000/blob/master/vcnl4000.pde&quot; rel=&quot;nofollow&quot;&gt;Adafruit sample sketch&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example sketch for talking to the VCNL4000 i2c proximity/light sensor&#xA;// Written by Adafruit! Public domain.&#xA;// To use: Connect VCC to 3.3-5V (5V is best if it is available), GND to&#xA;//         ground, SCL to i2c clock (on classic arduinos, Analog 5), SDA&#xA;//         to i2c data (on classic arduinos Analog 4). The 3.3v pin is&#xA;//         an ouptut if you need 3.3V&#xA;// This sensor is 5V compliant so you can use it with 3.3 or 5V micros&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In comments, &lt;code&gt;VCC&lt;/code&gt; should read as &lt;code&gt;Vin&lt;/code&gt; on the breakout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the comments mention &lt;code&gt;SDA&lt;/code&gt; and &lt;code&gt;SCL&lt;/code&gt; pins on &lt;code&gt;A4&lt;/code&gt; and &lt;code&gt;A5&lt;/code&gt; respectively, this is correct on Arduino UNO, but your wiring on the 2 leftmost pins of the digital pin header is also correct, as these pins are now replicated there on UNO and Leonardo. On Leonardo, the real pins for SDA/SCL are pins 2 and 3. If you don't have a UNO or Leonardo though, you should check where SDA and SCL can be found (that's generally described on &lt;a href=&quot;http://arduino.cc/en/Main/Products&quot; rel=&quot;nofollow&quot;&gt;Arduino Product page&lt;/a&gt; for your board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although wiring SDA/SCL on these 2 replicate pins is correct, I would rather recommend using A4 and A5 instead, so that you don't get the illusion that you can both use SDA/SCL and A4/A5 for something else at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit uses &lt;strong&gt;I2C&lt;/strong&gt; which means you should normally add pullup resistors to SDA and SCL wires; however, it seems that the Adafruit breakout already integrates them, so no problem here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up, and provided that you have a UNO or Leonardo, &lt;strong&gt;your wiring is correct except that you should remove the wire between both 3.3V pins&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is shown below for UNO (I used the real pins for SDA and SCL so that you don't use them for something else later):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino UNO 5V  ---&gt; Breakout Vin&lt;/li&gt;&#xA;&lt;li&gt;Arduino UNO GND ---&gt; Breakout GND&lt;/li&gt;&#xA;&lt;li&gt;Arduino UNO A4  ---&gt; Breakout SDA&lt;/li&gt;&#xA;&lt;li&gt;Arduino UNO A5  ---&gt; Breakout SCL&lt;/li&gt;&#xA;&lt;li&gt;Breakout 3.3V left unconnected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For Leonardo it would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Leonardo 5V  ---&gt; Breakout Vin&lt;/li&gt;&#xA;&lt;li&gt;Arduino Leonardo GND ---&gt; Breakout GND&lt;/li&gt;&#xA;&lt;li&gt;Arduino Leonardo D2  ---&gt; Breakout SDA&lt;/li&gt;&#xA;&lt;li&gt;Arduino Leonardo D3  ---&gt; Breakout SCL&lt;/li&gt;&#xA;&lt;li&gt;Breakout 3.3V left unconnected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I show you both UNO and Leonardo since you did not mention which board you use.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-04T11:01:32.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6842" PostTypeId="2" ParentId="4875" CreationDate="2015-01-04T11:49:35.723" Score="0" Body="&lt;p&gt;I wrote a communication protocol for arduino to node.js over Serial. I sent a buffer of bytes using &lt;code&gt;Serial.write()&lt;/code&gt; and read it into a buffer. This allows you to send as many numbers as you want. To send long (16 bit) numbers, you simple need to loop over two at a time combining:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C++:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long int a = 0x9A44;&#xA;uint_8t b = ( a &amp;amp; 0xFF00 ) &amp;gt;&amp;gt; 8;&#xA;uint_8t c = a &amp;amp; 0x00FF;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = ( b &amp;lt;&amp;lt; 8 ) &amp;amp; 0xFF00 | c &amp;amp; 0x00FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="297" LastActivityDate="2015-01-04T11:49:35.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6844" PostTypeId="2" ParentId="6840" CreationDate="2015-01-04T12:04:54.827" Score="6" Body="&lt;p&gt;So, the first consideration goes to the radio propagation aspect. Every country does things a little different with their radio clocks. And you might only have good signal a few times a day. For a nice overview, check out a solution for the &lt;a href=&quot;http://blog.blinkenlight.net/experiments/dcf77/the-clock/&quot; rel=&quot;noreferrer&quot;&gt;German DCF77&lt;/a&gt;. If you're totally set on using a radio clock, time-nuts has discussed in the past ripping open a $10ish clock to get at the fun parts of a &lt;a href=&quot;http://comments.gmane.org/gmane.comp.time.nuts/38831&quot; rel=&quot;noreferrer&quot;&gt;WWVB receiver&lt;/a&gt;, so that's one overview of the pool you're diving into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For myself I've skipped past the terrestrial time keeping and went straight to GPS. Find a receiver that provides a pulse-per-second and attach that to an interrupt and process it alongside the timestamp; you can see how I've gone about that in both &lt;a href=&quot;https://github.com/ptudor/jemma-clock&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt; and &lt;a href=&quot;https://www.tindie.com/products/ptudor/jemma-clock/&quot; rel=&quot;noreferrer&quot;&gt;final product&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think GPS is both easier and more precise than the alternatives, assuming you're above ground and can pick up satellites. I think of RTCs as something to tell me the day and the year, while GPS can tell me the second. But you could consider ripping the antenna out of a cheap bedside radio-controlled clock and using that to set an RTC, careful to consider whether you want a cheap RTC (DS1307) that drifts a minute per day or a slightly more expensive RTC (DS3231 or ISL1220) that drifts a minute per month. (Rough numbers of course.)&lt;/p&gt;&#xA;" OwnerUserId="4969" LastActivityDate="2015-01-04T12:04:54.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6845" PostTypeId="2" ParentId="2938" CreationDate="2015-01-04T13:45:48.623" Score="1" Body="&lt;p&gt;As long as I checked, this way of uploading data to Xively only works for up to tree pairs of name,data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try with more pairs at the same time the response is &quot;Done&quot;, but nothing happens. I finally divide the upload in groups of 3 parameters, and everything is Ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw your question yesterday when I was looking for a way to upload data to Xively from Yun. It was really helpful for me. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6533" LastActivityDate="2015-01-04T13:45:48.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6846" PostTypeId="1" CreationDate="2015-01-04T14:21:06.243" Score="1" ViewCount="1194" Body="&lt;p&gt;I'm making a project where my plan is to take sensor input from the Arduino, and then pass that info (by serial/usb connection) through either a laptop or a Raspberry Pi and convert it to Json and send it to a webservice in asp.net c#, where it gets stored in a database, and then the data can be shown on a website, so the visitor can see live data from the Arduino sensor on the site and also be able to see what the sensor measured yesterday, last month, or the average for a extended period of time, or a graph.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be easier to illustrate what I'm talking about:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QCzYu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PC / RPI part is optional, it can be using either one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few options, as I see it, as to which methods could work. But I am unsure about how to implement them and what programs to use for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First one is to log data to a file on the PC/RPI and then have some shell script either listen for changes and then combine a Json string with the newly added info to the file and send it of to the webservice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second one is to somehow take the Serial data from the Arduino and have some shell script or program listen for any data coming from the Arduino and converting it to Json, and sending it of to the webservice. The pro's by this method would be omitting the extra &quot;file-step&quot;, but it would make the system more vulnerable to any interruptions in the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have experience with doing something like this? Or maybe have an idea how I can do what I'm trying to do ? Or just a nudge in the right direction, as to which approach you think is best, or what programs I could/should use.&#xA;Any help is very much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards&#xA;Daniel&lt;/p&gt;&#xA;" OwnerUserId="6534" LastEditorUserId="6534" LastEditDate="2015-01-04T15:12:27.843" LastActivityDate="2015-01-06T18:04:24.600" Title="How to send Json to a webservice from pc/RPI with live data from Arduino(serial)" Tags="|arduino-uno|serial|sensors|web-service|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6847" PostTypeId="1" CreationDate="2015-01-04T14:49:47.450" Score="0" ViewCount="1611" Body="&lt;p&gt;I'm using a sonar sensor to detect proximity, and need to control the brightness of an LED strip in direct relationship to the distance detected. For example, as someone moves toward the sonar, the strip needs to dim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using map() to do it now crudely but it's way too abrupt and I'm not sure how best to achieve the effect I'm looking for. Ideally, as the person moves toward the light, it very smoothly fades out in relationship to the person's movement/pace. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial thoughts / questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- Can I use a more refined number type to set the LED brightness other than int?&#xA;-- Do I need to do something more complex where I detect the delta in the person's movement and use the loop to fade the LED from one value to another? Seems complicated...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help / ideas on this would be much appreciated! Existing code is below if it helps.&#xA;Claudia&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//variables needed to store values&#xA;long pulse, inches, cm;&#xA;&#xA;//LED VARIABLES&#xA;int frontPin = 6;    // front strip connected to PWN pin 5&#xA;long interval = 8000; // interval at which to do something (milliseconds)&#xA;int val;&#xA;&#xA;void setup() {&#xA;  //This opens up a serial connection to shoot the results back to the PC console&#xA;  pinMode(frontPin, OUTPUT);&#xA;  pinMode(pwPin, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    //Used to read in the pulse that is being sent by the MaxSonar device.&#xA;  //Pulse Width representation with a scale factor of 147 uS per Inch.&#xA;&#xA;  pulse = pulseIn(pwPin, HIGH);&#xA;  //147uS per inch&#xA;  inches = pulse/147;&#xA;  //change inches to centimetres&#xA;  cm = inches * 2.54;&#xA;&#xA;  if (inches &amp;lt; 36){&#xA;    detect();&#xA;  }&#xA;}&#xA;&#xA;&#xA;void detect(){&#xA;  Serial.print(inches);&#xA;  Serial.print(&quot;in, &quot;);&#xA;  Serial.println();&#xA;&#xA;  val = inches;&#xA;  val = map(val, 6, 36, 0, 255);&#xA;&#xA;  analogWrite(frontPin, val);&#xA;  Serial.print(&quot;mapped value is &quot;);&#xA;  Serial.print(val);&#xA;&#xA;  delay(500); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6536" LastActivityDate="2015-01-04T15:05:54.753" Title="Fade LED strip using proximity and map() function" Tags="|led|proximity|map|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6848" PostTypeId="2" ParentId="6847" CreationDate="2015-01-04T15:05:54.753" Score="1" Body="&lt;p&gt;The biggest problem is that by forcing the code to use integral inches you've restricted it to 31 discrete values. And since &lt;a href=&quot;https://electronics.stackexchange.com/questions/1983/correcting-for-non-linear-brightness-in-leds-when-using-pwm&quot;&gt;the brightness response of a PWMed LED is non-linear&lt;/a&gt; you effectively have &lt;em&gt;very&lt;/em&gt; large steps in brightness when the LED is dim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pulseIn()&lt;/code&gt; has &lt;em&gt;much&lt;/em&gt; more flexibility with regards to its range so use the raw value directly instead of converting it to &quot;pretty&quot; values.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val = map(pulse, ..., ..., 0, 255);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-04T15:05:54.753" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6849" PostTypeId="1" CreationDate="2015-01-04T18:17:10.157" Score="0" ViewCount="1417" Body="&lt;p&gt;I am trying to communicate with a client(PC) from my arduino (set up as a server with a sim900 module connected via UART). I have successfully got it to register its IP address with a dynamic DNS provider (no-ip.com) and set up a TCP server using the AT+CIPSERVER command for the sim900. All this is done in setup(). After that in loop() it waits for a client to connect. The moment a client connects the problem arises. The code is:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  while(Serial.available() &amp;lt;= 0);&#xA;  int x=0;&#xA;  char server_recv_string[30];&#xA;  while(Serial.available()&amp;gt;0)&#xA;  {&#xA;    server_recv_string[x] =  Serial.read();&#xA;    delay(10);&#xA;  }&#xA;  Serial.println(server_recv_string);&#xA;  sendATcommand2(&quot;AT+CIPSEND&quot;,&quot;&amp;gt;&quot;,&quot;ERROR&quot;,1000);&#xA;  sendATcommand2(&quot;I hear you\x1A&quot;,&quot;SEND OK&quot;,&quot;ERROR&quot;,5000);&#xA;  while(Serial.available()&amp;gt;0)  // I dropped this in to clear out the input buffer. &#xA;  {                            // Doesn't help&#xA;    Serial.read();&#xA;    delay(10);&#xA;  }&#xA;  Serial.flush();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sendATcommand2 is a function as given below. I don't think that has any fault in it because it seems to work fine for all the other commands in setup. However this is the code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t sendATcommand2(char* ATcommand, char* expected_answer1, &#xA;    char* expected_answer2, unsigned int timeout){&#xA;&#xA;    uint8_t x=0,  answer=0;&#xA;    char response[100];&#xA;    unsigned long previous;&#xA;&#xA;    memset(response, '\0', 100);    // Initialize the string&#xA;&#xA;    delay(100);&#xA;&#xA;    while( Serial.available() &amp;gt; 0) Serial.read();    // Clean the input buffer&#xA;&#xA;    Serial.println(ATcommand);    // Send the AT command &#xA;&#xA;    x = 0;&#xA;    previous = millis();&#xA;&#xA;    // this loop waits for the answer&#xA;    do{&#xA;        // if there are data in the UART input buffer, reads it and checks for the answer&#xA;        if(Serial.available() != 0 &amp;amp;&amp;amp; x &amp;lt; 100){    &#xA;            response[x] = Serial.read();&#xA;            x++;&#xA;            // check if the desired answer 1  is in the response of the module&#xA;            if (strstr(response, expected_answer1) != NULL)    &#xA;            {&#xA;                answer = 1;&#xA;            }&#xA;            // check if the desired answer 2 is in the response of the module&#xA;            else if (strstr(response, expected_answer2) != NULL)    &#xA;            {&#xA;                answer = 2;&#xA;            }&#xA;        }&#xA;    }&#xA;    // Waits for the asnwer with time out&#xA;    while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));    &#xA;&#xA;    return answer;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The when I monitor it on the serial terminal I get infinite sends to my client. Its like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; AT+CIPSEND&#xA; I hear you&#xA;&#xA;&#xA; AT+CIPSEND&#xA; I hear you&#xA;&#xA;&#xA; AT+CIPSEND&#xA; I hear you&#xA;&#xA;&#xA; AT+CIPSEND&#xA; I hear you&#xA;&#xA; // And on and on and on.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea why this is happening? If you guys need any more information, please do tell me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taz&lt;/p&gt;&#xA;" OwnerUserId="6538" LastActivityDate="2015-01-05T16:26:57.743" Title="How to send data to sim900 only once in loop()" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6850" PostTypeId="2" ParentId="6834" CreationDate="2015-01-04T22:14:36.480" Score="1" Body="&lt;p&gt;The direct answer is almost certainly not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some auspicious developments so that you might be able to adapt a specific open source Python package, but the resulting software would require a special Arduino board with an MCU chip with much more SRAM and a higher clock speed than we usually see on Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Discussion&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked several times and have never found anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did find a &quot;stripped down&quot; implementation of a Python 3.3 interpreter called &lt;a href=&quot;http://micropython.org&quot; rel=&quot;nofollow&quot;&gt;Micro Python&lt;/a&gt;. The software was developed hand in hand with MicroPy, an ARM-based single board computer (also described at the MicroPython website). MicroPy is closer to a Raspberry Pi or Beaglebone than an Arduino. However, the software environment is less complex because the MicroPy doesn't require a Linux-based or other operating system.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The base Micro Python package software package seems to require about 110KB of SRAM to boot up and expects a 1 MB SD chip with a boot record and MicroPython on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Micro Python software was released under the MIT open source license so, in theory, a clever person could adapt it for the Arduino if they built a board with a really powerful chip SD socket. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although the Micro Python/MicroPy package is very appealing, I don't think I would head down the path. I would rather be programming for hardware that is available from more than one source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another potential issue is that the Micro Python implementation uses a mark and sweep garbage collector which might tie up the processor for 4 msec at time. Depending on your application a 4 msec busy period might not be acceptable.&lt;/p&gt;&#xA;" OwnerUserId="6539" LastEditorUserId="3271" LastEditDate="2015-01-05T10:09:03.837" LastActivityDate="2015-01-05T10:09:03.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6851" PostTypeId="2" ParentId="6839" CreationDate="2015-01-04T22:36:21.187" Score="3" Body="&lt;p&gt;There is &lt;a href=&quot;http://blog.atmel.com/2013/10/17/let-arduino-control-your-dishwasher-or-washing-machine/&quot; rel=&quot;nofollow&quot;&gt;an article by Atmel&lt;/a&gt;, talking exactly about this (not for homebrewing, though). They provide a &lt;a href=&quot;http://grietinfo.in/projects/MAIN/EEE2013/cd-3-projectdocumentationpdf.pdf&quot; rel=&quot;nofollow&quot;&gt;link to a PDF file&lt;/a&gt; that describe in detail a project involving Arduino and a re-created washing machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it seems to be some kind of Bachelor graduation project, and that the students seem to build an entire washing machine. They control the rotor using an Arduino, and even provide the code (and a brief history about washing machines..).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from building the entire machine, there are two main directions here as I see it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Manipulate the existing washing machine's control board using Arduino. The bad news are the it would require some reverse engineering of the existing controller, because, per my understanding (and I'm not an expert on the subject) there is no one standard and any manufacturer seems to use it's own propriety control board (similar to Microwaves or Dishwashers). The good news are that an expert could probably do it, either by dumping the controller memory and examining the hex code or by using JTag. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another way to go here is interfacing the electrical hardware itself; &lt;a href=&quot;http://www.instructables.com/id/Washing-machine-countdown-timer-Arduino/&quot; rel=&quot;nofollow&quot;&gt;see this instructable&lt;/a&gt; where the guy connected the Arduino in parallel to the start button, by thus allowing an alternative way to start. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As for a beginner, it would make more sense to go for the latter; in-parallel connection with an existing hardware button should be a fairly comprehensible task. Consider the hazards of working with a high voltage/power device such as washing machines. I must say that on first glance such a project doesn't seem fit a novice, but I would be the last one to hold an enthusiast's back. And if you know any, I would suggest asking supervision from someone with a strong EE background.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-04T22:46:59.090" LastActivityDate="2015-01-04T22:46:59.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6852" PostTypeId="1" CreationDate="2015-01-05T00:23:44.240" Score="0" ViewCount="1743" Body="&lt;p&gt;I'm using Serial.read(); to read keyboard input from the serial monitor. &#xA;It only sends the characters after hitting enter or clicking the &quot;send&quot; button.&#xA;Is there a way to read keyboard input without having to use &quot;enter&quot;?&lt;/p&gt;&#xA;" OwnerUserId="6460" LastActivityDate="2015-01-05T02:04:59.443" Title="Reading keyboard input" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6853" PostTypeId="2" ParentId="4861" CreationDate="2015-01-05T01:59:54.483" Score="1" Body="&lt;p&gt;&lt;em&gt;Note: I haven't tried this myself so YMMV; this is just from my general experience and reading; all information comes with citations.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To start, I would recommend opening &lt;a href=&quot;https://github.com/aporto/mariamole/issues&quot; rel=&quot;nofollow&quot;&gt;an issue on GitHub&lt;/a&gt; to ask for detailed instructions. I noticed that the &lt;a href=&quot;http://dalpix.com/mariamole-download&quot; rel=&quot;nofollow&quot;&gt;website&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Linux and Mac distributions are still experimental, but MariaMole is working fine on both systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;so they should have a known recipe for how to do it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the mean time, here's how I would proceed. Given that there's a file called &lt;a href=&quot;https://github.com/aporto/mariamole/blob/master/CMakeLists.txt&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CMakeLists.txt&lt;/code&gt;&lt;/a&gt; in the root directory, you need to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;download and install &lt;a href=&quot;http://www.cmake.org/&quot; rel=&quot;nofollow&quot;&gt;CMake&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, install the &lt;a href=&quot;https://github.com/aporto/mariamole/wiki/Compiling-MariaMole&quot; rel=&quot;nofollow&quot;&gt;dependencies listed on the wiki&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Qt 5.2&lt;/li&gt;&#xA;&lt;li&gt;QScintilla 2&lt;/li&gt;&#xA;&lt;li&gt;QSerial&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After that, I presume just cloning the repo and running &lt;code&gt;cmake&lt;/code&gt; in the root directory should do the trick. If you have any further questions, please open an issue on GitHub with your compilation error message for further assistance.&lt;/p&gt;&#xA;" OwnerUserId="3271" LastActivityDate="2015-01-05T01:59:54.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6854" PostTypeId="2" ParentId="6852" CreationDate="2015-01-05T02:04:59.443" Score="1" Body="&lt;p&gt;Not with the Serial Monitor built into the Arduino IDE. It is possible to use an external terminal program with buffering disabled though.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-05T02:04:59.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6855" PostTypeId="2" ParentId="6835" CreationDate="2015-01-05T02:56:17.153" Score="0" Body="&lt;p&gt;Q1: If its a well established source of Arduino compatible boards you can be pretty confident (in my experience) that there are no design flaws regarding pin use.  A search on comments by other developers will also help confirm that for you further.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you go to multiple shields you would need to look at fanout (driving more than one input from an output).  The reverse problem is even more of an issue: driving one input from several outputs.  In other words, an input on the Arduino would be connected to output pins on two shields providing different signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2: The answer relates to how I ended in Q1.  By avoiding the use of certain pins on a shield the conflicting inputs could be avoided.  The headers would simply pass through the signal.  I don't think there is any rule that a shield has to use or touch every pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q3: I'm not quite sure what you are asking in this question.&lt;/p&gt;&#xA;" OwnerUserId="6512" LastEditorUserId="6512" LastEditDate="2015-01-05T19:22:31.507" LastActivityDate="2015-01-05T19:22:31.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6856" PostTypeId="1" CreationDate="2015-01-05T03:05:30.717" Score="1" ViewCount="3516" Body="&lt;p&gt;I purchased a ACS711 Hall effect-based linear current sensor (&lt;a href=&quot;http://www.pololu.com/product/2197&quot; rel=&quot;nofollow&quot;&gt;http://www.pololu.com/product/2197&lt;/a&gt;) and when i read the input it's basically always the same. After doing some research I think it's because there is only a 10bit AD converter and since the current is only changing a little bit it's not enough to catch the change. For my situation I'm pulling around 40-90ma idle and when the motor turns on it jumps up so I want this sensor to see that but it only jumps up to about 120ma. Any tips on how to fix this? Maybe a different sensor? Can I use an amplifier to boost the analog signal?&lt;/p&gt;&#xA;" OwnerUserId="6544" LastActivityDate="2015-02-10T05:59:13.290" Title="How can I increase resolution for current sensor?" Tags="|sensors|current|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6857" PostTypeId="1" AcceptedAnswerId="6867" CreationDate="2015-01-05T03:17:37.373" Score="1" ViewCount="84" Body="&lt;p&gt;I'm working on a project were we are trying to attach accelerometers to soccer players and capture various aspects of movement data.  Breadboarded circuits are coming along nicely and I'm now looking for how to best protect sensors we can mount on players.  (All wire at the moment unfortunately - BT next.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I can find ways to protect the sensor for sensor damaging impact (we are essentially interested in player impacts with the ball or ground) there are other aspects of protection I'm not sure about.  Any recommendations on how to protect from moisture without increasing bulk too much, minimizing cushioning which could affect the data and of course avoid adding anything that could injure the player?  I have come across other examples of movement studies, but they have been by musicians or other situations that do not include outdoor weather and sweaty bodies.&lt;/p&gt;&#xA;" OwnerUserId="6512" LastActivityDate="2015-01-05T18:50:42.563" Title="How to protect sensors used on atheletes?" Tags="|sensors|accelerometer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6858" PostTypeId="1" AcceptedAnswerId="6859" CreationDate="2015-01-05T03:55:16.390" Score="0" ViewCount="1640" Body="&lt;p&gt;I recently purchases and make a Arduino RBBB with a BUB II from Modern Device. I ordered the package found &lt;a href=&quot;http://moderndevice.com/product/rbbb-bundle/&quot; rel=&quot;nofollow noreferrer&quot;&gt;HERE&lt;/a&gt;. I built everything according to the instructions, but when I connect it to my laptop (running Ubuntu 14.10), I get the following in dmesg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[63415.213391] usb 3-1: new full-speed USB device number 63 using xhci_hcd&#xA;[63415.381403] usb 3-1: device descriptor read/64, error -71&#xA;[63415.485225] xhci_hcd 0000:00:14.0: Setup ERROR: setup context command for slot 26.&#xA;[63415.485240] usb 3-1: hub failed to enable device, error -22&#xA;[63415.597236] usb 3-1: new full-speed USB device number 64 using xhci_hcd&#xA;[63415.709154] usb 3-1: device descriptor read/64, error -71&#xA;[63415.813102] xhci_hcd 0000:00:14.0: Setup ERROR: setup context command for slot 27.&#xA;[63415.813116] usb 3-1: hub failed to enable device, error -22&#xA;[63415.925108] usb 3-1: new full-speed USB device number 65 using xhci_hcd&#xA;[63415.925270] usb 3-1: Device not responding to setup address.&#xA;[63416.129120] usb 3-1: Device not responding to setup address.&#xA;[63416.332902] usb 3-1: device not accepting address 65, error -71&#xA;[63416.444973] usb 3-1: new full-speed USB device number 66 using xhci_hcd&#xA;[63416.445174] usb 3-1: Device not responding to setup address.&#xA;[63416.649008] usb 3-1: Device not responding to setup address.&#xA;[63416.852734] usb 3-1: device not accepting address 66, error -71&#xA;[63416.852813] usb usb3-port1: unable to enumerate USB device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is repeatable every time I insert. lsusb does not register it. I have read that I should switch out the cable, but it is brand new (and I don't have another to test with. I was wondering if there is something evidently wrong with my circuitry. I posted pictures&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/z1911.jpg&quot; alt=&quot;Top Down&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/fVuSE.jpg&quot; alt=&quot;Side&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/XI3Iq.jpg&quot; alt=&quot;Bottom&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/RNRVh.jpg&quot; alt=&quot;Side&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6545" LastEditorUserId="653" LastEditDate="2015-04-05T20:25:14.500" LastActivityDate="2015-10-03T03:07:45.053" Title="Arduino RBBB - Device not accepting address" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6859" PostTypeId="2" ParentId="6858" CreationDate="2015-01-05T07:10:09.307" Score="1" Body="&lt;p&gt;I fixed it. Here is how I did it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I tried connecting just the BUB II to via the USB. Same error, thus I ruled out the Arduino RBBB as the source. I then decided that perhaps it was the voltage jumpers (black things on the pins sticking out in the first picture). After removing them, it works under dmesg, yielding the below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  214.044563] ftdi_sio 3-1:1.0: FTDI USB Serial Device converter detected&#xA;[  214.044687] usb 3-1: Detected FT232RL&#xA;[  214.044696] usb 3-1: Number of endpoints 2&#xA;[  214.044704] usb 3-1: Endpoint 1 MaxPacketSize 64&#xA;[  214.044712] usb 3-1: Endpoint 2 MaxPacketSize 64&#xA;[  214.044718] usb 3-1: Setting MaxPacketSize 64&#xA;[  214.045209] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus I wanted to put them back on so I wouldn't lose them. I proceeded to try various combinations till it worked. Ultimately, I ended with 5V for VOUT and VL for LGLV. If that is a bad idea, someone please comment, but it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May this help someone else.&lt;/p&gt;&#xA;" OwnerDisplayName="user6545" LastActivityDate="2015-01-05T07:10:09.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6860" PostTypeId="1" AcceptedAnswerId="9375" CreationDate="2015-01-05T08:31:17.850" Score="0" ViewCount="22882" Body="&lt;p&gt;I want to make a timer library. The cpp file I have written is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;avr/interrupt.h&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;#include &quot;AllTimer.h&quot;&#xA;&#xA;AllTimer::AllTimer()&#xA;{}&#xA;&#xA;void AllTimer::dofun(void)&#xA;{&#xA;    TIFR1 |= _BV(OCF1A);&#xA;    TCCR1B = 0X00;&#xA;    digitalWrite(13,!digitalRead(13));&#xA;}&#xA;&#xA;void AllTimer::setTimer(void)&#xA;{&#xA;    TCNT1 = 0x0BDC;&#xA;    TCCR1A = 0x00;&#xA;    TCCR1B = 0x00;&#xA;    TCCR1B |= (1&amp;lt;&amp;lt;CS12) &amp;amp;&amp;amp; (1&amp;lt;&amp;lt;CS10);&#xA;    TIMSK1 |= (1&amp;lt;&amp;lt;TOIE1);&#xA;    sei();&#xA;}&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;{&#xA;    dofun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef AllTimer_h&#xA;#define AllTimer_h&#xA;&#xA;class AllTimer{&#xA;public:&#xA;    AllTimer();&#xA;    void setTimer(void);&#xA;&#xA;private:&#xA;    void dofun(void);&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While compiling the file i am getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_jan05a.cpp: In function ‘void __vector_13()’:&#xA;sketch_jan05a.cpp:34:9: error: ‘dofun’ was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="84" LastEditDate="2015-01-05T18:00:39.670" LastActivityDate="2015-03-16T09:10:37.643" Title="Error: Function not declared in the scope" Tags="|programming|c++|library|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6861" PostTypeId="2" ParentId="6860" CreationDate="2015-01-05T08:45:37.083" Score="4" Body="&lt;p&gt;Because in the call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; dofun();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you should put from which class you are calling that function.&#xA;In your case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AllTimer::dofun();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in that case your function must be declared as static method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Thanks to the comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not pretty sure if your code reflects what you want to do. Because you can create your timer after defining the class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Alltimer mytimer;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call the method as a normal function (it must be declared as &lt;strong&gt;&lt;em&gt;public&lt;/em&gt;&lt;/strong&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR (TIMER1_OVF_vect)&#xA;{&#xA;    mytimer.dofun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is hard to say since I m not sure what you want to do.&lt;/p&gt;&#xA;" OwnerUserId="6330" LastEditorUserId="6330" LastEditDate="2015-01-05T11:16:40.393" LastActivityDate="2015-01-05T11:16:40.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6862" PostTypeId="2" ParentId="6860" CreationDate="2015-01-05T10:12:28.117" Score="1" Body="&lt;p&gt;&lt;code&gt;dofun()&lt;/code&gt; is currently declared as a private member function, meaning you can't call it directly. It can only be called internally by an instance of the &lt;code&gt;AllTimer&lt;/code&gt; class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you probably want to declare it as a public static function instead. To do that, remove the &lt;code&gt;private&lt;/code&gt; specifier from the class declaration, and put &lt;code&gt;static&lt;/code&gt; before the function declaration. Your header should look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class AllTimer&#xA;{&#xA;public:&#xA;    AllTimer();&#xA;    void setTimer(void);&#xA;    static void dofun(void);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will then need to change the ISR to include the class name in the call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR (TIMER1_OVF_vect)&#xA;{&#xA;    AllTimer::dofun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-01-05T11:33:32.570" LastActivityDate="2015-01-05T11:33:32.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6863" PostTypeId="1" CreationDate="2015-01-05T12:49:54.403" Score="2" ViewCount="14267" Body="&lt;p&gt;what is the fastest serial read the Mega can do?&#xA;begin.Serial1(1024000) is accepted for compiling, but reading jibberish&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any suggestions on a faster device?&lt;/p&gt;&#xA;" OwnerUserId="5095" LastActivityDate="2021-08-24T05:12:25.947" Title="what is fastest allowable serial baudrate?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6864" PostTypeId="2" ParentId="6863" CreationDate="2015-01-05T13:31:57.507" Score="1" Body="&lt;p&gt;It depends mainly on CPU frequency, see &lt;em&gt;USART/Baud rate settings&lt;/em&gt; in datasheet. For example at 16MHz it might go up to 2Mbps. But you need also consider error in baudrate which is important if communication with &quot;3rd party&quot; device.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-01-05T13:31:57.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6865" PostTypeId="2" ParentId="6863" CreationDate="2015-01-05T15:18:10.487" Score="6" Body="&lt;p&gt;The Arduino Mega 2560 runs at 16 MHz. There are online calculators making this easy, as the calculation is not a straight and simple formula.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://wormfood.net/avrbaudcalc.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://wormfood.net/avrbaudcalc.php&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;which shows using 16 MHz&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;Baud Rate&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;UBRR(dec)&lt;/th&gt;&#xA;&lt;th style=&quot;text-align: right;&quot;&gt;UBRR(hex)&lt;/th&gt;&#xA;&lt;th&gt;% of error&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;300&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3332&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0D04&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;600&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;1666&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0682&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;1200&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;832&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0340&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;2400&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;416&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x01A0&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;4800&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;207&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x00CF&lt;/td&gt;&#xA;&lt;td&gt;0.2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;9600&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;103&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0067&lt;/td&gt;&#xA;&lt;td&gt;0.2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;14400&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;68&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0044&lt;/td&gt;&#xA;&lt;td&gt;0.6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;19200&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;51&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0033&lt;/td&gt;&#xA;&lt;td&gt;0.2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;28800&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;34&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0022&lt;/td&gt;&#xA;&lt;td&gt;0.8&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;38400&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;25&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0019&lt;/td&gt;&#xA;&lt;td&gt;0.2&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;57600&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;16&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0010&lt;/td&gt;&#xA;&lt;td&gt;2.1 - Barely OK&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;76800&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;12&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x000C&lt;/td&gt;&#xA;&lt;td&gt;0.2 - GOOD&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;115200&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;8&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0008&lt;/td&gt;&#xA;&lt;td&gt;3.7 - BAD&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;230400&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0003&lt;/td&gt;&#xA;&lt;td&gt;7.8 - BAD&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;250000&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;3&lt;/td&gt;&#xA;&lt;td style=&quot;text-align: right;&quot;&gt;0x0003&lt;/td&gt;&#xA;&lt;td&gt;0.0&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Where it is noticeable that the Mega's Arduino boot loader uses&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;mega.menu.cpu.atmega2560.upload.speed=115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which is above the acceptable 1% error rate.&lt;/p&gt;&#xA;&lt;p&gt;While it is possible to support different baud rates than stated above, it is not advisable, as the above values are the standard values. Values in between are very atypical and likely not trustworthy on the corresponding other side of the connection.&lt;/p&gt;&#xA;&lt;p&gt;As I see your above example is 1024000, it is also worth noting that HardwareSerial.cpp implements a method to convert the requested baud rate to configuration of the USART, and I would not necessarily trust it for non-standard baud rates, especially on older version of the Arduino IDE. You may want to try the latest 1.5.8+ and verify the rate.&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="69714" LastEditDate="2021-08-24T05:12:25.947" LastActivityDate="2021-08-24T05:12:25.947" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="6866" PostTypeId="1" AcceptedAnswerId="6879" CreationDate="2015-01-05T16:12:01.117" Score="2" ViewCount="2223" Body="&lt;p&gt;I'm attempting to write data over a serial line to the arduino, however I don't want to use the arduino IDE but rather use the command line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do this I have the following commands: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&#xA;$echo s123 &amp;gt; /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code on the receiving end checks whatever or not the input is s123 and if it is starts blinking. I have tested this using the arduino IDE and it worked, however this did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void loop(){&#xA;     if(Serial.available()==4){&#xA;       byte b1,b2,b3,b4; &#xA;      b1=Serial.read();&#xA;      b2=Serial.read();&#xA;      b3=Serial.read();&#xA;      b4=Serial.read();     &#xA;        if(b1=='s'){&#xA;               digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;               delay(1000);               // wait for a second&#xA;               digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;               delay(1000);               // wait for a second&#xA;               digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;               Serial.println(&quot;the cow has landed&quot;);&#xA;          }&#xA;     }&#xA;&#xA;&#xA;    void setup(){ //////////////SETUP////////////////////////&#xA;        Serial.begin(9600);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the output of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -F /dev/ttyACM0 -a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;was :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;speed 9600 baud; rows 0; columns 0; line = 0;&#xA;intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = &amp;lt;undef&amp;gt;; eol2 = &amp;lt;undef&amp;gt;; swtch = &amp;lt;undef&amp;gt;; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;&#xA;lnext = ^V; flush = ^O; min = 0; time = 0;&#xA;-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts&#xA;ignbrk -brkint -ignpar -parmrk inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8&#xA;-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0&#xA;-isig -icanon -iexten -echo -echoe -echok -echonl noflsh -xcase -tostop -echoprt -echoctl -echoke&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="5165" LastEditorUserId="5165" LastEditDate="2015-01-05T16:55:28.630" LastActivityDate="2015-01-07T14:20:05.250" Title="communicating with arduino over serial via terminal" Tags="|serial|usb|linux|ubuntu|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="6867" PostTypeId="2" ParentId="6857" CreationDate="2015-01-05T16:12:56.993" Score="1" Body="&lt;p&gt;The only way this is ever done is with some kind of product casing. You can buy pre-fab cases for electronic projects, but to get something really slick and appropriate for your purpose, you're gonna have to make something yourself. You might look into 3D printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this might work: &lt;a href=&quot;https://www.sparkfun.com/products/8601&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8601&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For protection from salt-water, this product is worth a look: &lt;a href=&quot;http://www.corrosionx.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.corrosionx.com/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's some different products there, but I've seen a demo of that product, where we ran an entire RC airplane system, servos, motors, and receiver, UNDER WATER.&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2015-01-05T18:50:42.563" LastActivityDate="2015-01-05T18:50:42.563" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6868" PostTypeId="2" ParentId="6849" CreationDate="2015-01-05T16:26:57.743" Score="1" Body="&lt;p&gt;You can use a boolean variable to decide if you are going to execute the send command. You can set the variable to true in the setup and to false after the command is executed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you introduce the send call inside an &lt;em&gt;if (your boolean variable == true)&lt;/em&gt;, it will only be executed in one loop iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can execute it again anytime you like setting the variable to true at any moment.&lt;/p&gt;&#xA;" OwnerUserId="6533" LastActivityDate="2015-01-05T16:26:57.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6870" PostTypeId="2" ParentId="6835" CreationDate="2015-01-05T23:55:54.083" Score="2" Body="&lt;p&gt;You will have to consult a source like this one: &lt;a href=&quot;http://shieldlist.org&quot; rel=&quot;nofollow&quot;&gt;http://shieldlist.org&lt;/a&gt;&#xA;There are no simple rules for which pin conflicts are OK and which ones are not, it all depends on the concrete protocol (i.e. I2C is designed for all bus participants to share lines, while in SPI, each participant needs their own select line, while the other lines are shared).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your concrete case, both shields you want to use are addressed by SPI, which means D13 (SCK) and D12 (MISO) are shared between the shields by design, while they MUST have different slave select pins. In your case, the SS pin for the microSD shield is fixed as D8, while the one for the KTA shield seems to be selectable, so either D9 or D10 should be OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Peripherals generally don't have facilities to become an SPI master, so all data has to be transferred through the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2015-01-05T23:55:54.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6871" PostTypeId="1" CreationDate="2015-01-06T00:02:31.310" Score="0" ViewCount="913" Body="&lt;p&gt;I'm working on a kite-related project where I'm using Arduino + accelerometer to track data while a kite is in the air. I am struggling a little with the best approach - help on the following questions / issues would be a huge help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-- how best to grab data only while the kite is in the air? just detect with numbers, use a switch? other ideas?&#xA;-- how best to collect the data and transfer to computer for visualization (likely with processing but looking at other options). i'm using this project in workshops with kids in low-income neighborhoods in brazil, so will have limited resources. a laptop will be available -but use of mobile also ideal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&#xA;Claudia&lt;/p&gt;&#xA;" OwnerUserId="6536" LastActivityDate="2015-01-06T17:44:10.200" Title="collecting &amp; visualizing sensor data - best approach?" Tags="|accelerometer|communication|datalogging|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6872" PostTypeId="1" CreationDate="2015-01-05T23:30:07.990" Score="0" ViewCount="265" Body="&lt;p&gt;I have been trying to find any Arduino or similar prototyping board that uses this MCU&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BWNi2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.pcmag.com/article2/0,2817,2453987,00.asp&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.pcmag.com/article2/0,2817,2453987,00.asp&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the smallest and more robust ones I have been able to find are Microduino and Espruino pico, none of which use this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any prototyping boards that use these?&lt;/p&gt;&#xA;" OwnerUserId="6559" OwnerDisplayName="dukeofgaming" LastEditorUserId="83" LastEditDate="2015-01-15T18:30:30.590" LastActivityDate="2021-07-31T23:01:50.163" Title="Are there any KL03 &quot;arduinos&quot;?" Tags="|hardware|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6873" PostTypeId="2" ParentId="6872" CreationDate="2015-01-06T04:01:53.403" Score="1" Body="&lt;p&gt;This development board uses a chip from the KL03 family:&#xA;&lt;a href=&quot;http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL03Z&quot; rel=&quot;nofollow&quot;&gt;http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL03Z&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as you can see, it uses the arduino uno form factor (like all their other freedom boards), so it's probably not what you were expecting with respect of size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for a dev board that you can prototype with (easy access to pins and all that) I doubt you can get anything significantly smaller than a teensy (&lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/&lt;/a&gt;), which also uses a more powerful ARM M4 core. There has been quite a few kickstarters with tiny arduino-compatible boards, but I am not quite sure how many you can actually buy at the moment.&lt;/p&gt;&#xA;" OwnerUserId="6414" LastEditorUserId="6414" LastEditDate="2015-01-06T04:11:04.763" LastActivityDate="2015-01-06T04:11:04.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6874" PostTypeId="1" AcceptedAnswerId="8737" CreationDate="2015-01-06T04:15:05.403" Score="0" ViewCount="111" Body="&lt;p&gt;I'm attempting to hook up an arduino uno with a Sparkfun Oled. I downloaded the example program and made these changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PIN_RESET 3  // Connect RST to pin 3&#xA;#define PIN_DC    4  // Connect DC to pin 4&#xA;#define PIN_CS    10 // Connect CS to pin 10&#xA;#define DC_JUMPER 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I connected everything according to Sparfun's walkthrough. I also wired accordingly. However, I cannot seem to get the Oled to do, well, much of anything. I have tried switching the MOSI and MISO to see if that makes a difference, but it doesn't seem to have any effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using:&#xA;pin 13 - clock (in the picture I was trying pin 8 for the clock but I have tried both)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pin 12 - MISO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pin 11 - MOSI&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pin 10 - CS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pin 4 - DC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pin 3 - RESET&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what's going wrong? I've tried to figure it out for a good long while now and I can't make the display do anything productive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fPHgg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4638" LastActivityDate="2015-04-20T02:49:10.470" Title="Wiring Issues with Sparkfun Oled" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="6875" PostTypeId="1" AcceptedAnswerId="8612" CreationDate="2015-01-06T04:23:25.653" Score="1" ViewCount="5348" Body="&lt;p&gt;I have a black Thermistor with the number 503 on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I would need a 50k resistor as a voltage divider. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't get to convert the number I am getting. I get the number 340 when my house is at 64*F. &#xA;I bought a kit on Amazon and it came with it and there is no documentation.A test with multimeter has shown at 17*C I get 30k ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it is wired:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Ground] -- [50k-resistor] -- | -- [(503)thermistor] --[Vcc (5v)]&#xA;                              |&#xA;                         Analog Pin 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5119" LastEditorUserId="6452" LastEditDate="2015-02-13T19:12:05.750" LastActivityDate="2015-02-13T19:12:05.750" Title="How to use 503 Thermistors for temperature?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="6879" PostTypeId="2" ParentId="6866" CreationDate="2015-01-06T09:08:35.857" Score="0" Body="&lt;p&gt;This was fixed this morning after a reboot and upgrade command, still don't know which one of these fixed it but it seems to work now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ah figured it out we were using the 0 and 1 rx gates to communicate over serial rather then usb and as the used power supply turned out to be only 5V rather then 9-12V it didn't quite work as intended.&lt;/p&gt;&#xA;" OwnerUserId="5165" LastEditorUserId="5165" LastEditDate="2015-01-07T14:20:05.250" LastActivityDate="2015-01-07T14:20:05.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6880" PostTypeId="2" ParentId="5067" CreationDate="2015-01-06T10:15:40.690" Score="-1" Body="&lt;p&gt;I ran into the same problem, looked around the net a bit.&#xA;Someone found a solution from the Italian forums translated + posted how to help this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short there was something wrong with the TFT library&#xA;&lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=25&amp;amp;t=45289#p228908&quot; rel=&quot;nofollow&quot;&gt;https://forums.adafruit.com/viewtopic.php?f=25&amp;amp;t=45289#p228908&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed the nightly build, currently 1.6.0 and the screen is working now.&lt;/p&gt;&#xA;" OwnerUserId="6561" LastActivityDate="2015-01-06T10:15:40.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6881" PostTypeId="1" CreationDate="2015-01-06T10:32:21.987" Score="2" ViewCount="196" Body="&lt;p&gt;I've been playing with &lt;a href=&quot;http://www.seeedstudio.com/wiki/index.php?title=Grove_BLE_v1&amp;amp;uselang=en&quot; rel=&quot;nofollow&quot;&gt;Groove Bluetooth Module&lt;/a&gt; (HM-11) and for some reason my computer can see it, but none of my cell phones can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried two Huawei P7 (BL 4.0 + BLE) as well as some Samsung Galaxy &amp;amp; some older sony with Bluetooth 2.0. None of the cell phones can see the device. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6466" LastActivityDate="2015-01-06T10:32:21.987" Title="Bluetooth module discovered by computer and not smartphones" Tags="|bluetooth|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="6882" PostTypeId="1" CreationDate="2015-01-06T15:09:09.913" Score="0" ViewCount="920" Body="&lt;p&gt;I wrote a simple program for controlling an LED using mobile. So, I bought the HC-05 bluetooth module configured it and then connected it to  the arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that I wrote for it.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin1=13;&#xA;int state;&#xA;int flag=0;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(ledPin1, OUTPUT);&#xA;    digitalWrite(0,HIGH);&#xA;&#xA;    second:&#xA;    Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if(Serial.available() &amp;gt;0)&#xA;    {&#xA;        state = Serial.read();&#xA;        flag=0;&#xA;    }  &#xA;    if (state == '0') &#xA;    {&#xA;        digitalWrite(ledPin1, LOW);&#xA;        if(flag == 0){ &#xA;            Serial.println(&quot;led off&quot;);&#xA;            flag=1;&#xA;        }&#xA;    }   &#xA;    if (state == '1')&#xA;    {         &#xA;        digitalWrite(ledPin1, HIGH);&#xA;        if(flag == 0){ &#xA;            Serial.println(&quot;led on&quot;);&#xA;            flag=1;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything is working cool with the serial monitor. But, I'm not able to control it using my mobile. I gave an input 1 in serial monitor and if showed &quot;led on&quot;. the same thing appears on the commanding interface of the app used in the mobile. So, the bluetooth is transmitting information from the arduino to mobile but I'm not able to send commands from the mobile and control the led. I tried using various apps like  Blueterm, Ardudroid etc but, the situation remains the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? Is there something wrong with the code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="6566" LastEditorUserId="42" LastEditDate="2015-01-06T15:39:15.193" LastActivityDate="2019-10-04T14:16:56.540" Title="Problem with hc-05 bluettoth module" Tags="|arduino-uno|led|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6883" PostTypeId="1" AcceptedAnswerId="6891" CreationDate="2015-01-06T17:15:25.757" Score="2" ViewCount="140" Body="&lt;p&gt;I have no idea why this is happening, but after I open COM port to talk with my Arduino (I click &quot;Open&quot; in RealTerm), the state of some pins goes from high to low for about 2 seconds and then goes back to high. Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  pinMode(5, OUTPUT);&#xA;  digitalWrite(5, HIGH);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case pin 5 will behave this way. I've checked it also for pin 6 and pin 8 and they behave in the same manner. I suppose more pins act like that. Why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="5130" LastActivityDate="2015-01-08T19:32:59.037" Title="When I open a COM port some pins on Arduino Uno goes low for about 2 seconds" Tags="|serial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="6884" PostTypeId="2" ParentId="6871" CreationDate="2015-01-06T17:44:10.200" Score="1" Body="&lt;p&gt;Several possibilities; Both at little cost, but since you have an accelerometer, I know your budget is not 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) use a shield with an SD card on the arduino to log the information to a file on the SD card.  Open it later from a laptop or PC.  Hopefully it will have enough room to store data that you can ignore later for pre-flight, post-flight time.  If not, simply add some fixed delay to the start of your program (loop 5 times; wait 1 minute;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) some form of remote, like an XBee, or even a wireless WiFi Shield. The setup can be complicated but that would be ideal for real time visualization on a laptop at the flying site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) probably the easiest/least expensive - a cheap bluetooth transmitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/16Gte.jpg&quot; alt=&quot;eBay Bluetooth $3 USD&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/Wireless-Bluetooth-RF-Transceiver-Module-serial-RS232-TTL-HC-06-for-Arduino-/231441772518&quot; rel=&quot;nofollow noreferrer&quot;&gt;eBay&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method would allow a bluetooth mobile to collect and visualize the data. This device connects to the serial lines on an arduino, (pin 0&amp;amp;1) and standard Serial.Write() function can be used.  Any terminal program for your mobile will be able to receive the data. You could also get fancy and write your own if you want to visualize it. You may be able to find something already existing, like &lt;a href=&quot;http://www.tigoe.com/pcomp/code/arduinowiring/140/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4UA1c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In cases 2 &amp;amp; 3 you will need a way to xmit the data. I use MQTT. A protocol just for this, but it is TCP only. I also use it with JSON (eg &lt;a href=&quot;https://github.com/interactive-matter/aJson&quot; rel=&quot;nofollow noreferrer&quot;&gt;Json for Arduino&lt;/a&gt; to manage the data.  You will need to find the same. Look at MQTT-SN as a possibility, or you can just write your own serialization protocol based around JSON without too much difficulty.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-01-06T17:44:10.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="6885" PostTypeId="2" ParentId="6846" CreationDate="2015-01-06T18:04:24.600" Score="1" Body="&lt;p&gt;I'm kind of tackling the same thing at the moment.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using MQTT for a while for things like this. Including on an Netduino, an Arduino, and today a LEGO NXT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is TCP based. I have been wanting to use serial, not TCP (ethernet) for a while, and when the need came for the NXT, it was time to write my own bridge to existing code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I runs on the same host as the MQTT broker, but listens to a serial port, and mirrors the data to a TCP MQTT broker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is turning out to be much simpler than I expected, I should have done this months ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nxt Side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (true)&#xA;{&#xA;    float x, y, z;&#xA;    DIMUreadGyroAxes(IMU, x, y, z);&#xA;&#xA;    char json[128];&#xA;    sprintf(json, &quot;PUBnxt/Gyro,{\&quot;x\&quot;:%f,\&quot;y\&quot;:%f,\&quot;z\&quot;:%f}\n&quot;, x, y, z);&#xA;    nxtWriteRawHS(json, strlen(json), 0); // wireless serial over xbee&#xA;    wait1Msec(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PC side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)&#xA;    {&#xA;        SerialPort p = sender as SerialPort;&#xA;        while (p.BytesToRead &amp;gt; 0)&#xA;        {&#xA;            string line;&#xA;            try&#xA;            {&#xA;                line = p.ReadLine();&#xA;            }&#xA;            catch (IOException)&#xA;            {&#xA;                throw;  // +++timeout&#xA;            }&#xA;            // parse it, it should be CMDtopic[,payload]&#xA;            if (line.Substring(0, 3).Equals(&quot;PUB&quot;))&#xA;            {&#xA;                int commaIdx = line.IndexOf(',', 3);&#xA;                string topic = line.Substring(3, commaIdx - 3);&#xA;                string payload = line.Substring(commaIdx + 1);&#xA;                Console.WriteLine(&quot;{3}: {0}, publish topic({1}) payload({2})&quot;, p.PortName, topic, payload, DateTime.Now.ToLongTimeString());&#xA;                Mqtt.Publish(topic, System.Text.Encoding.UTF8.GetBytes(payload));&#xA;&#xA;            }&#xA;            else if (line.Substring(0, 3).Equals(&quot;SUB&quot;))&#xA;            {&#xA;                string topic = line.Substring(3);&#xA;                Console.WriteLine(&quot;{0}, subscribe topic({1})&quot;, p.PortName, topic);&#xA;                throw new NotImplementedException(&quot;MQTT Subscribe not implemented yet&quot;);&#xA;            }&#xA;            else&#xA;            {&#xA;                //Debugger.Break();   // ignore it, framing error&#xA;                Console.WriteLine(&quot;{0}, Data dropped&quot;, p.PortName);&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might also want to look at &lt;a href=&quot;https://data.sparkfun.com/&quot; rel=&quot;nofollow&quot;&gt;data.sparkfun.com&lt;/a&gt;. A similar, complete concept, already existing.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-01-06T18:04:24.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6886" PostTypeId="1" CreationDate="2015-01-06T19:03:03.987" Score="1" ViewCount="1287" Body="&lt;p&gt;Currently I am trying to get a Mindwave Mobile device to operate with an Arduino Uno. I'm following the guide &lt;a href=&quot;https://learn.sparkfun.com/tutorials/hackers-in-residence---hacking-mindwave-mobile&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the sample code given doesn't work very well. I have been trying to get a more consistent output but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MindWave Code :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;     // library for software serial&#xA;SoftwareSerial mySerial(5, 6);  // RX, TX&#xA;int BAUDRATE = 57600;&#xA;&#xA;// checksum variables&#xA;byte payloadChecksum = 0;&#xA;byte CalculatedChecksum;&#xA;byte checksum = 0;              //data type byte stores an 8-bit unsigned number, from 0 to 255&#xA;int payloadLength = 0;&#xA;byte payloadData[64] = {0};&#xA;byte poorQuality = 0;&#xA;byte attention = 0;&#xA;byte meditation = 0;&#xA;&#xA;// system variables&#xA;long lastReceivedPacket = 0;&#xA;boolean bigPacket = false;&#xA;boolean brainwave = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(57600);       // Bluetooth&#xA;  delay(500);&#xA;  mySerial.begin(4800);      // software serialz&#xA;  delay(500);&#xA;  Serial.print(&quot;Communicating... &quot;);&#xA;  mySerial.print(&quot;Communicating... &quot;);&#xA;  mySerial.println();&#xA;}&#xA;&#xA;byte ReadOneByte() {&#xA;  int ByteRead;&#xA;  // Wait until there is data&#xA;  while (!Serial.available());&#xA;  //Get the number of bytes (characters) available for reading from the serial port.&#xA;  //This is data that's already arrived and stored in the serial receive buffer (which holds 64 bytes)&#xA;  ByteRead = Serial.read();&#xA;  return ByteRead; // read incoming serial data&#xA;}&#xA;&#xA;unsigned int delta_wave = 0;&#xA;unsigned int theta_wave = 0;&#xA;unsigned int low_alpha_wave = 0;&#xA;unsigned int high_alpha_wave = 0;&#xA;unsigned int low_beta_wave = 0;&#xA;unsigned int high_beta_wave = 0;&#xA;unsigned int low_gamma_wave = 0;&#xA;unsigned int mid_gamma_wave = 0;&#xA;&#xA;void read_waves(int i) {&#xA;  delta_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  theta_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  low_alpha_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  high_alpha_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  low_beta_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  high_beta_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  low_gamma_wave = read_3byte_int(i);&#xA;  i += 3;&#xA;  mid_gamma_wave = read_3byte_int(i);&#xA;}&#xA;&#xA;int read_3byte_int(int i) {&#xA;  return ((payloadData[i] &amp;lt;&amp;lt; 16) + (payloadData[i + 1] &amp;lt;&amp;lt; 8) + payloadData[i + 2]);&#xA;}&#xA;&#xA;void loop() {&#xA;  // Look for sync bytes&#xA;  // Byte order: 0xAA, 0xAA, payloadLength, payloadData,&#xA;  // Checksum (sum all the bytes of payload, take lowest 8 bits, then bit inverse on lowest&#xA;  if (ReadOneByte() == 0xAA) {&#xA;    if (ReadOneByte() == 0xAA) {&#xA;      payloadLength = ReadOneByte();&#xA;      if (payloadLength &amp;gt; 169) //Payload length can not be greater than 169&#xA;        return;&#xA;      payloadChecksum = 0;&#xA;      for (int i = 0; i &amp;lt; payloadLength; i++) {     //loop until payload length is complete&#xA;        payloadData[i] = ReadOneByte();             //Read payload&#xA;        payloadChecksum += payloadData[i];&#xA;      }&#xA;      checksum = ReadOneByte();                     //Read checksum byte from stream&#xA;      payloadChecksum = 255 - payloadChecksum;      //Take one’s compliment of generated checksum&#xA;      if (checksum == payloadChecksum) {&#xA;        poorQuality = 200;&#xA;        attention = 0;&#xA;        meditation = 0;&#xA;      }&#xA;      brainwave = false;&#xA;      for (int i = 0; i &amp;lt; payloadLength; i++) { // Parse the payload&#xA;        switch (payloadData[i]) {&#xA;          case 02:&#xA;            i++;&#xA;            poorQuality = payloadData[i];&#xA;            bigPacket = true;&#xA;            break;&#xA;          case 04:&#xA;            i++;&#xA;            attention = payloadData[i];&#xA;            break;&#xA;          case 05:&#xA;            i++;&#xA;            meditation = payloadData[i];&#xA;            break;&#xA;          case 0x80:&#xA;            i = i + 3;&#xA;            break;&#xA;          case 0x83:                         // ASIC EEG POWER INT&#xA;            i++;&#xA;            brainwave = true;&#xA;            byte vlen = payloadData[i];&#xA;            //mySerial.print(vlen, DEC);&#xA;            //mySerial.println();&#xA;            read_waves(i + 1);&#xA;            i += vlen; // i = i + vlen&#xA;            break;&#xA;        }                                 // switch&#xA;      }                                   // for loop&#xA;&#xA;/*&#xA;      if (bigPacket) {&#xA;        if (poorQuality == 0) {&#xA;        }&#xA;        else {                            // do nothing&#xA;        }&#xA;      }&#xA;*/&#xA;      if (brainwave &amp;amp;&amp;amp; attention &amp;gt; 0 &amp;amp;&amp;amp; attention &amp;lt; 100) {&#xA;        mySerial.print(attention, DEC);&#xA;        mySerial.println();&#xA;&#xA;        Serial.print(attention, DEC);&#xA;        Serial.println();&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Often, the serial monitor stops display new values that stems from the Mindwave. Any suggestions on how I could modify the code to get it to run more smoothly will be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="3210" LastEditorUserId="26916" LastEditDate="2016-12-22T06:07:51.430" LastActivityDate="2019-04-12T18:56:23.780" Title="Enabling quicker and more accurate MindWave Mobile detection?" Tags="|serial|programming|c++|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6887" PostTypeId="2" ParentId="6882" CreationDate="2015-01-06T19:47:29.933" Score="2" Body="&lt;p&gt;Your android app might be sending extra characters like &quot;end of line&quot;, which will cause the return value of &lt;code&gt;Serial.read()&lt;/code&gt; to be other than &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt; after the first byte. Nevertheless, it looks like it should still turn on or off the LED as soon as it reads the first byte, and do nothing when it reads the following bytes. I have used the &quot;hyperterminal rs232&quot; app successfully to send single characters, maybe give that I try to see if it helps and ensure it is configured at the correct baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to send back to the serial stream the characters read, to ensure they have been received correctly, so I would change this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available() &amp;gt;0)&#xA;{&#xA;    state = Serial.read();&#xA;    flag=0;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available() &amp;gt;0)&#xA;{&#xA;    state = Serial.read();&#xA;    Serial.print(state);&#xA;    flag=0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just realised this in &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(0,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are setting the receive pin of the UART peripheral to hight, so that is probably why you are not reading data from your phone.&lt;/p&gt;&#xA;" OwnerUserId="6414" LastEditorUserId="6414" LastEditDate="2015-01-06T19:58:35.790" LastActivityDate="2015-01-06T19:58:35.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6889" PostTypeId="2" ParentId="3014" CreationDate="2015-01-06T22:07:34.893" Score="1" Body="&lt;p&gt;If the LED is blinking, the device is waiting to pair with another Bluetooth transceiver (your phone). Once paired, the LED will stay lit. The factory-set pairing code is usually 1234. I can't tell from the photograph how the HC-05 Rx &amp;amp; Tx are wired to your ATmega328, but note that it must be cross-connected; that is Rx -&gt; Tx and Tx -&gt; Rx.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-01-06T22:07:34.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="6890" PostTypeId="2" ParentId="6875" CreationDate="2015-01-06T22:12:54.687" Score="-1" Body="&lt;p&gt;Here is a &lt;a href=&quot;http://www.jameco.com/1/1/1127-ntc-503-r-negative-temperature-coefficient-ntc-thermistor.html&quot; rel=&quot;nofollow&quot;&gt;link to Jameco&lt;/a&gt;, one supplier of a 503 thermistor - it is a negative-coefficient thermistor. They have a link to a data-sheet for it. I can't say for sure that this is your device, but a simple experiment with your ohm-meter should confirm it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-01-06T22:12:54.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6891" PostTypeId="2" ParentId="6883" CreationDate="2015-01-06T22:26:51.923" Score="3" Body="&lt;p&gt;What you see is expected: that's because opening the USB connection to the UNO will automatically trigger a reset of the ATmega chip of the board, hence your sketch will be executed from scratch, ie &lt;code&gt;setup()&lt;/code&gt; will be called again then your &lt;code&gt;loop()&lt;/code&gt; repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence what you observe in detail:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open USB connection from PC&lt;/li&gt;&#xA;&lt;li&gt;open USB connection on Arduino UNO&lt;/li&gt;&#xA;&lt;li&gt;UNO USB chip (an ATmega16u2) triggers a RESET of the MCU (an ATmega328P-PU)&lt;/li&gt;&#xA;&lt;li&gt;On reset, the MCU sets all pins to INPUT, i.e. high impedence, &lt;strong&gt;hence no voltage can be measured on any pin&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then the bootloader starts, performs some intialization and starts your sketch&lt;/li&gt;&#xA;&lt;li&gt;Your sketch executes first &lt;code&gt;setup()&lt;/code&gt;, so your pin is put in OUTPUT mode and set to HIGH: &lt;strong&gt;its voltage is thus measurable (5V)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;your sketch &lt;code&gt;loop()&lt;/code&gt; gets executed &quot;forever&quot; i.e.until a new reset or power supply disconnection&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-06T22:26:51.923" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="6892" PostTypeId="1" CreationDate="2015-01-07T01:31:10.930" Score="1" ViewCount="828" Body="&lt;p&gt;I'm brand new to arduino but I'm trying to figure out how to set up a WASD steering system for my robot I made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the physical setup all ready but I don't know the code to use that would allow me to use my computers keyboard. I would like to still have my keyboard attached to my computer while I do this. &lt;em&gt;I.E. I don't want to manually plug the keyboard into arduino&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I asked this on &lt;a href=&quot;https://robotics.stackexchange.com/questions/5302/code-control-your-arduino-with-keybaord&quot;&gt;Robotics stack exchange&lt;/a&gt; but they said to ask here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A list of functions/blocks Iof code that is applicable would be the best answer, but I'll take anything that'll get my bot moving :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; I'm using a wireless keyboard, but my arduino is connected via USB.&lt;/p&gt;&#xA;" OwnerUserId="6578" LastEditorUserId="-1" LastEditDate="2017-04-13T12:49:17.743" LastActivityDate="2020-03-01T16:39:17.550" Title="Control arduino with keybaord via computer" Tags="|robotics|code-optimization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7893" PostTypeId="1" AcceptedAnswerId="7894" CreationDate="2015-01-07T09:58:53.043" Score="2" ViewCount="669" Body="&lt;p&gt;We have two labs - one in 1st floor and other at 2nd floor. We are connected by intercom - both the labs has one device each. The issue is that the person who sits near the intercom is busy through out day answering the intercom and reaching out to the person for whom the call is made for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is very tiresome and hence I wish to automate this. I have an Arduino Mega 2560 board. My plan is to make Arduino receive the call ask for the person whom the caller is reaching out and play the name loudly over speaker in all rooms of labs (to attended the phone). If the user does not turns up even after 3 repeated times of calling - disconnect the call. If the user answers the phone by picking up the receiver then turn the conversation speaker mode off until call has not ended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Arduino Mega 2560 board which has 4 serial ports but I am not user what would be the circuit to make this functionality workable? What are the extra h/w required and concept of its implementation.&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2015-01-07T11:49:35.903" LastActivityDate="2017-09-10T01:18:39.127" Title="Self answering a Intercom and playing louldy for person to response" Tags="|arduino-mega|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7894" PostTypeId="2" ParentId="7893" CreationDate="2015-01-07T13:01:26.037" Score="1" Body="&lt;p&gt;Let's try to break it down to several components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Interfacing with POTS&lt;/strong&gt; (Plain Old Telephony System):&#xA;There is &lt;a href=&quot;http://ww.joes.com/intercom/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;a nice article&lt;/a&gt; by Joe Doll describing how to interface an Arduino and POTS. POTS involves high voltage during both idle and ringing time (48 V DC, superimposed 90 V AC) and the circuit itself is &lt;a href=&quot;http://www.joes.com/intercom/circuit.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;mostly analog&lt;/a&gt;. You can find the required parts and their values in his article, which goes down into the nasty details in a spectacular fashion. Here is the analog circuit, involving the Arduino, from his post:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iEReN.jpg&quot; alt=&quot;Arduino interfacing POTS from Joe Doll&amp;#39;s website&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider that there are other projects performing similar task in a different manner, like &lt;a href=&quot;http://brohogan.blogspot.co.il/2009/12/telephone-interface.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;, and &lt;a href=&quot;http://blog.andrewstella.com/2013/12/new-project-arduino-rotary-phone.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; which specifically explains how to record sound from an old rotary phone.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Play/Record sound from Arduino Mega 2650:&lt;/strong&gt;&#xA;There are many projects that describe how to &lt;a href=&quot;http://www.instructables.com/id/Arduino-playing-wav-files/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Play&lt;/a&gt; or &lt;a href=&quot;http://www.instructables.com/id/Arduino-Mega-Audio-File-logging/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Record&lt;/a&gt; sound using Arduino. Most involve a SD card to store the wav files. There is also the option of an MP3 shield, that comes with a pre-built SD card slot, such as &lt;a href=&quot;https://www.sparkfun.com/products/10628&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;. They are fully documented and are easy to interface with. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code that encapsulates the Logic&lt;/strong&gt;:&#xA;Here you could decide how many times the Arduino should play the recorded name, and what happens if the user won't answer. The disconnection will be done utilizing the POTS interface you created in bullet #1. In addition, you should handle the logic of what happens when the user does answer. It is not clear what you mean by 'receiver', but if you plan to have a remote extension or similar, some extra work will be required.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a side note, it might be easier to create/re-use a walkie-talkie kind of wireless communicator, accompanied by an Arduino, to signal or broadcast the names of the people called. This might not include reuse or interfacing with the current intercom device, but by thus I believe it will make development easier and faster.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="26916" LastEditDate="2017-09-10T01:18:39.127" LastActivityDate="2017-09-10T01:18:39.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7896" PostTypeId="1" CreationDate="2015-01-07T16:49:41.097" Score="1" ViewCount="2635" Body="&lt;p&gt;I have a popular bluetooth module JY-MCU version 1.06 (picture below). Before i insert it to my arduino project I want to configure the name, bound speed and the pass code using usb-to-serial link. But I am facing a problem where the device does not respond to commands. Please let me explain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I send the module to programming mode by applying +5V on 'key'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I send commands using CoolTerm program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+NAMEmyArduinoProject&#xA;&amp;gt; OKyour set name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok. setting the name works as expected. But that is the only thing that worked for me. Other commands give no response:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&#xA;AT+BAUD2&#xA;&#xA;AT+VERSION&#xA;&#xA;AT+VERSION?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe you had this happen to you? I am I sending wrong commands or doing something wrong? Please help me to figure out how to control this module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WV4cV.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6584" LastActivityDate="2015-06-08T19:02:53.697" Title="Programming bluetooth module JY-MCU v1.06" Tags="|serial|bluetooth|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7897" PostTypeId="2" ParentId="6875" CreationDate="2015-01-07T21:19:31.520" Score="1" Body="&lt;p&gt;First of, &lt;strong&gt;503&lt;/strong&gt; means 50 x 10^3, ie &lt;strong&gt;50K Ohm&lt;/strong&gt;: that is the maximum resistance of this thermistor (the higher resistance occurs for lower temperatures). However, having just that without any precise reference may prove difficult to find a relevant datasheet that could help you calculate the temperature from the measured voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what could work well is just simple calibration by establishing a mapping between&#xA;the value returned by &lt;code&gt;analogRead()&lt;/code&gt; and the temperature measured by a real, good precision, thermometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Establighing the mapping for 2 extreme temperatures would provide a &lt;strong&gt;first approximation&lt;/strong&gt; on computing any temperature from the read value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, such an approximation would not be very accurate because thermistors are &lt;strong&gt;not linear&lt;/strong&gt;, ie their resitance don't vary linearly with temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can try to do then, is to increase the number of mapped &lt;em&gt;value&amp;lt;-&gt;temperature&lt;/em&gt; with regular intervals of temperatures; then you can use linear approximation between two consecutive mapped values, which would provide better results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty here is to &quot;produce&quot; the temperatures for which you want to find the mapped value: if you can spend one year for that, then just let the chqanging seasons operate that for you :-) otherwise use what you can find at home: fridge, oven, fan, heater...&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-07T21:19:31.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7899" PostTypeId="1" CreationDate="2015-01-07T22:25:06.793" Score="2" ViewCount="1366" Body="&lt;p&gt;Is it possible to connect two Ethernet shields to arduino? And if yes, how can I distinguish them in the code?&lt;/p&gt;&#xA;" OwnerUserId="6589" OwnerDisplayName="Windys" LastEditorUserId="4628" LastEditDate="2017-01-25T05:39:43.460" LastActivityDate="2017-04-23T19:17:50.260" Title="Arduino two Ethernet shields" Tags="|ethernet|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7900" PostTypeId="1" CreationDate="2015-01-08T02:42:55.900" Score="0" ViewCount="173" Body="&lt;p&gt;I accidentally misconnected a USB BUB II to a Arduino RBBB (atmega 328), and it no longer uploads code. Here are the symptoms, I think the BUB II is fried. I am using Ubuntu 14.10.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Code won't upload with error &lt;code&gt;ser_recv(): programmer is not responding&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The RBBB board will reset is I hit the button. Evidenced by the LED flashing in port 13&lt;/li&gt;&#xA;&lt;li&gt;Prior code runs as expected&lt;/li&gt;&#xA;&lt;li&gt;dmesg behaves normally upon USB connection&lt;/li&gt;&#xA;&lt;li&gt;When I short the Rx and Tx terminals of the BUB II, I can send instant reply messages via the Serial Monitor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Does this sound like the USB BUB II is broken? Or is is possible that some component on the RBBB board is fried?&lt;/p&gt;&#xA;" OwnerDisplayName="user6545" LastEditorDisplayName="user6545" LastEditDate="2015-01-08T03:29:17.620" LastActivityDate="2016-03-03T11:04:10.397" Title="USB BUB II - Misconnection and no longer uploads" Tags="|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7901" PostTypeId="2" ParentId="7900" CreationDate="2015-01-08T03:36:22.630" Score="1" Body="&lt;p&gt;Well, I asked too soon. I tend to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to switch the board configuration to Arduino Uno and it worked&lt;/p&gt;&#xA;" OwnerDisplayName="user6545" LastActivityDate="2015-01-08T03:36:22.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7903" PostTypeId="2" ParentId="6892" CreationDate="2015-01-08T07:34:45.633" Score="1" Body="&lt;p&gt;The problem with using the keyboard is the device would have to be tethered to your computer. If you mean for this &quot;robot&quot; to be an explorer, that limits its choices. If it's an arm or something that stays in place, you're fine using the typical serial libraries to monitor your keyboard for input like Chris suggests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I don't know of any way to simply plug in the USB keyboard and take in keys. Usually, serial communication is processed between two systems much like two people texting each other. When you see the light blinking on your phone, you know you have a text and how to open it to retrieve the message. In the case of the Arduino, it's checking for a flag bit called RX for the received message and flags a bit for transmitting a message (TX). Each system then pulls down its message and interprets it. In the case of your sketch, you'll be looking for this flag and schedule an action whenever it's checked. &lt;a href=&quot;http://arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;Read about Serial communications here and work through the examples to get a feel for it.&lt;/a&gt; Because you probably want a real-time response, it might be worth your while to check out interrupts, as well. These are sudden events that get flagged (such as receiving your text) and get handled immediately instead of waiting for the program to refresh and search for the values manually. As a final note, baud rates are the calculated time frames you and your recipient agree on. It would be difficult to receive a full message if you kept cutting off your friend, so it is with computers. This stuff can kind of be tricky at first, but keep at it. Nothing is more ridiculously satisfying than getting that response character from your device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a neat tutorial for getting your Arduino to work through your iPhone &lt;a href=&quot;http://www.instructables.com/id/Control-Arduino-Board-Wirelessly-With-iPhone-iPad/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, but it requires an ethernet board, which means a router and wireless board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without knowing what you intend to do with it, it's hard to say how to help, but I hope this gets you into it.&lt;/p&gt;&#xA;" OwnerUserId="6596" LastActivityDate="2015-01-08T07:34:45.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7904" PostTypeId="2" ParentId="6856" CreationDate="2015-01-08T09:06:51.507" Score="2" Body="&lt;p&gt;In default configuration, the Arduino's ADC has a range of 0v-Vcc (5v or 3.3v depending on the model). If you are sure your input voltages will always be way lower than Vcc, spreading the ADC's resolution over that range is a waste of accuracy. What you need to do is to &lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/AnalogReference/&quot; rel=&quot;nofollow&quot;&gt;properly configure your analog reference voltage&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, this is a way of telling your Arduino &quot;instead of spreading your ADC's bits over a range of 0v to Vcc, just cram all that accuracy between 0v and &lt;code&gt;[refVoltage]&lt;/code&gt;.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Measure the highest analog output your sensor will give.&lt;/li&gt;&#xA;&lt;li&gt;Setup a voltage divider to output a little more than that&lt;/li&gt;&#xA;&lt;li&gt;Connect the voltage divider's output to the AREF pin&lt;/li&gt;&#xA;&lt;li&gt;in &lt;code&gt;setup()&lt;/code&gt;, declare &lt;code&gt;analogReference(EXTERNAL);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And that's basically it. As noted, in this specific case you'd probably be better off buying another sensor altogether. However, you won't always have that luxury, and knowing how to set the analog voltage reference always comes in handy.&lt;/p&gt;&#xA;" OwnerUserId="1429" LastActivityDate="2015-01-08T09:06:51.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7905" PostTypeId="1" AcceptedAnswerId="7907" CreationDate="2015-01-08T12:55:09.053" Score="0" ViewCount="269" Body="&lt;p&gt;I'm new to electronics. Professionally I'm a software developer. I want to know whether it is possible to program Atmel AVR 8-bit and 32-bit Microcontrollers using Arduino IDE. If yes could any one guide me on the process or direct me to any site where I can learn about it.&lt;/p&gt;&#xA;" OwnerUserId="6599" LastEditorUserId="46" LastEditDate="2015-01-16T17:19:37.273" LastActivityDate="2015-01-16T17:19:37.273" Title="Programming Arduino" Tags="|programming|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7906" PostTypeId="2" ParentId="7896" CreationDate="2015-01-08T14:13:35.297" Score="1" Body="&lt;p&gt;OK, I figured it out. It looks like CoolTerm was sending wrong line endings. Thus the only command that worked was name change as it interpreted the extra symbols as part of the name specification. Now I am using in built Arduino serial communication and it works like a charm!&lt;/p&gt;&#xA;" OwnerUserId="6584" LastActivityDate="2015-01-08T14:13:35.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7907" PostTypeId="2" ParentId="7905" CreationDate="2015-01-08T14:18:35.053" Score="2" Body="&lt;p&gt;Yes, it is possible. In fact, this is how the whole 'Arduino' concept works - programming 8/32 bit AVR microcontrollers with the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;program Atmel AVR 8-bit and 32-bit Microcontrollers using Aurdino IDE&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This has two parts actually:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Generate compiled HEX targeting AVR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the Arduino IDE you could utilize the Arduino libraries (aka working with assist utility functions like &lt;code&gt;digitalWrite&lt;/code&gt; for example), which are built on top of the AVR tool-chain. The official Arduino IDE comes with pre-built support for several 8-bit/32-bit Atmel AVR micro-controllers, the full list of supported boards can be found on the Arduino official website or in &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems&quot; rel=&quot;nofollow&quot;&gt;this Wikipedia page&lt;/a&gt;. &#xA;&lt;strong&gt;You did not specify a specific MCU&lt;/strong&gt;, therefor you should check if the MCU you would like to work with is in that list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Uploading an Arduino sketch to a compatible AVR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino IDE uses &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow&quot;&gt;avrdude&lt;/a&gt; under the hood. avrdude is &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;an utility to download/upload/manipulate the ROM and EEPROM contents&#xA;  of AVR microcontrollers using the in-system programming technique&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(From their website).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best place to start is the official Arduino.cc website, in the &lt;a href=&quot;http://arduino.cc/en/Guide/HomePage&quot; rel=&quot;nofollow&quot;&gt;'Getting Started' section&lt;/a&gt;. If you haven't picked any specific Atmel AVR chip yet, consider that each has slightly different features, size, I/O pins etc. so make sure to research a bit before purchasing one (reference the table in the Wikipedia link above to compare between the different kinds).&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-01-08T14:18:35.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7908" PostTypeId="1" AcceptedAnswerId="7910" CreationDate="2015-01-08T15:13:04.563" Score="0" ViewCount="637" Body="&lt;p&gt;I have the following setup and sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when I click the button it works sometimes, but other times it executes On Off straight after On as if it's executing twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is after pressing the button only 7 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Off&#xA;On&#xA;Off&#xA;On&#xA;Off&#xA;On&#xA;Off&#xA;On&#xA;Off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought that was the whole point of a state machine? That it continues to execute the next state (not multiple times at random).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very very confused with this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xcvLw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//http://www.arduino.cc/playground/uploads/Code/FSM.zip&#xA;#include &amp;lt;FiniteStateMachine.h&amp;gt;&#xA;//http://www.arduino.cc/playground/uploads/Code/Button.zip&#xA;#include &amp;lt;Button.h&amp;gt;&#xA;//http://www.arduino.cc/playground/uploads/Code/LED.zip&#xA;#include &amp;lt;LED.h&amp;gt;&#xA;&#xA;const byte NUMBER_OF_STATES = 2; //how many states are we cycling through?&#xA;&#xA;//initialize states&#xA;State On = State(ledOn);&#xA;State Off = State(ledOff); &#xA;&#xA;FSM ledStateMachine = FSM(On);     //initialize state machine, start in state: On&#xA;&#xA;Button button = Button(2, INPUT_PULLUP); //initialize the button (wire between pin 12 and ground)&#xA;LED led = LED(13);                 //initialize the LED&#xA;byte buttonPresses = 0;            //counter variable, hols number of button presses&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;//poor example, but then again; it's just an example&#xA;void loop(){&#xA;  if (button.uniquePress()){&#xA;    //increment buttonPresses and constrain it to [ 0, 1 ]&#xA;    buttonPresses = ++buttonPresses % NUMBER_OF_STATES;&#xA;    switch (buttonPresses){&#xA;      case 0: ledStateMachine.transitionTo(On); Serial.println(&quot;On&quot;); break;&#xA;      case 1: ledStateMachine.transitionTo(Off); Serial.println(&quot;Off&quot;); break;&#xA;    }&#xA;  }&#xA;  ledStateMachine.update();&#xA;}&#xA;&#xA;//utility functions&#xA;void ledOn(){ led.on(); }&#xA;void ledOff(){ led.off(); }&#xA;//end utility functions&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="983" LastActivityDate="2015-01-08T15:25:54.097" Title="SMlib State Machine Library not working as expected" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7909" PostTypeId="2" ParentId="7905" CreationDate="2015-01-08T15:21:00.313" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/&lt;/a&gt; is good place to start. It includes articles about how to get started, library references, and user forums. The Arduino IDE will certainly get you started, but as an experienced developer you'll most likely hit its limitations pretty quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later, or quite possibly sooner(!) you can use same toolset (compiler, loader, libraries) in several less limiting environments: Eclipse IDE, edit/make at the command line, and Atmel's AVR Studio. C and C++ are mainstream; I've seen references to the existence of (but never tried) AVR Forth and AVR python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though you'll see occasional references to an 'Arduino language' it's really nothing more than C++ with some attempt to be smart about detecting references to library packages and auto-inserting the relevant &lt;code&gt;#include&lt;/code&gt;s.&#xA;You probably won't want to take advantage of such shortcuts, and keep to good programming practices, if you think you'll ever want to move up from the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally use Eclipse (supplementing with a few command line tools) and I'd recommend it once you've tried the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-01-09T20:58:46.433" LastActivityDate="2015-01-09T20:58:46.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7910" PostTypeId="2" ParentId="7908" CreationDate="2015-01-08T15:23:37.807" Score="3" Body="&lt;p&gt;Maybe you need some sort of &lt;strong&gt;debouncing&lt;/strong&gt;? There's a &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; on the Arduino site that I think will sort your problem out.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-01-08T15:23:37.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7911" PostTypeId="2" ParentId="7908" CreationDate="2015-01-08T15:25:54.097" Score="1" Body="&lt;p&gt;It doesn't look like the state machine is a problem here. More likely it's a problem of the button bouncing, as you don't have any code or circuitry to guard against it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A button is typically a very simple component which doesn't necessarily make/break connections cleanly. Sometimes it will have a brief intermittent connection, making it look like it's been pressed/released multiple times. This is referred to as bouncing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's lots of material online about debouncing, whether in hardware or software. The top answer here may help:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/408/why-does-my-sketch-report-too-many-button-presses/411#411&quot;&gt;Why does my sketch report too many button presses?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-01-08T15:25:54.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7912" PostTypeId="1" AcceptedAnswerId="7913" CreationDate="2015-01-08T16:15:23.107" Score="5" ViewCount="2316" Body="&lt;p&gt;Okay 2 questions. If I am to replace the Arduino with an ATmega328 programmed with a standard blink on pin 13, is this configuration correct, do I still need oscillators and whatnot?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uaFJc.jpg&quot; alt=&quot;Simple breadboard circuit with LED on pin 13 of ATmega328&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second question is, what is the max voltage I can power the ATmega328 with without frying it? I have seen conflicting answers of this on the net. Some have said 5V while some say 6V can someone clarify?&lt;/p&gt;&#xA;" OwnerUserId="6205" LastEditorUserId="6936" LastEditDate="2015-08-01T14:45:27.787" LastActivityDate="2015-08-01T14:45:27.787" Title="Can I use an ATmega328 alone without anything and what is the max voltage I can power the atmega328 with" Tags="|atmega328|hardware|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7913" PostTypeId="2" ParentId="7912" CreationDate="2015-01-08T16:43:09.810" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; describes the electrical and clock requirements of the chip, and &lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR042&lt;/a&gt; describes the external hardware configuration required. Decoupling, analog voltages, external crystal or oscillator if required.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="228" LastEditDate="2015-01-08T18:23:00.597" LastActivityDate="2015-01-08T18:23:00.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7915" PostTypeId="2" ParentId="6883" CreationDate="2015-01-08T19:32:59.037" Score="0" Body="&lt;p&gt;The arduino is reseting because of the serial port initializing. If you want to avoid it, you can put a 120 ohm resistor between 5v and reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection&quot; rel=&quot;nofollow&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6605" LastActivityDate="2015-01-08T19:32:59.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7916" PostTypeId="2" ParentId="3422" CreationDate="2015-01-08T21:00:53.053" Score="0" Body="&lt;p&gt;I am looking for the same thing. The only thing I have come up with is that you can use the Bridge Library and use curl on the Linux side to read or write the pins&lt;/p&gt;&#xA;" OwnerUserId="6606" LastEditorUserId="10907" LastEditDate="2016-01-12T05:27:00.737" LastActivityDate="2016-01-12T05:27:00.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7917" PostTypeId="1" AcceptedAnswerId="7918" CreationDate="2015-01-08T22:23:11.357" Score="0" ViewCount="1957" Body="&lt;p&gt;The following link to the library defines arduino pin 5 for input pin for signal.&lt;br&gt; &#xA; &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_FreqCount.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.pjrc.com/teensy/td_libs_FreqCount.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is I'm using an 16x2 LCD display with the arduino pin 5. The display needs pin 5 to work. So the question can solved in two ways,to both of which I don't know the answer.&lt;br&gt;&#xA;1. Change LCD pin number to other pin. (Tried it was a failure. I've probably done it wrong)&lt;br&gt;&#xA;2. Change the input pin for the freqcount library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to get past this bottleneck?&lt;/p&gt;&#xA;" OwnerUserId="6613" OwnerDisplayName="Boggartfly" LastEditorUserId="31105" LastEditDate="2019-02-08T00:00:09.007" LastActivityDate="2019-02-08T00:00:09.007" Title="How to change input pin of FreqCounter Arduino Uno/Dumilanove library?" Tags="|lcd|frequency|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7918" PostTypeId="2" ParentId="7917" CreationDate="2015-01-08T22:29:49.100" Score="0" Body="&lt;p&gt;The library makes use of the hardware peripheral Timer 1 which has its input on pin 5 of the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can't be changed.  You have no choice in that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have to move the LCD to another pin instead.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2015-01-08T22:29:49.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7920" PostTypeId="1" AcceptedAnswerId="7924" CreationDate="2015-01-09T10:35:35.703" Score="1" ViewCount="2173" Body="&lt;p&gt;So I have to get this function done but I'm not so bright and got confused. &#xA;(excuse me! I'm total noob)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function is basically inputing text using five buttons, directional buttons and an ok button. The up and down buttons will be used to cycle through letters (a-z), and the left and right buttons will be used to control which array to cycle letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The control will be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;up button (up): ASCII-1 (z, y, x...)&lt;/li&gt;&#xA;&lt;li&gt;down button (dw): ASCII+1 (a, b, c...)&lt;/li&gt;&#xA;&lt;li&gt;right button (ri): array[i] ~&gt; i+1 (go to next character/array)&lt;/li&gt;&#xA;&lt;li&gt;left button (le): array[i] ~&gt; i-1 (go to previous character/array)&lt;/li&gt;&#xA;&lt;li&gt;ok button (ok): confirm text and changes the limit to stop function looping&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can't get it work with this code I write.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void intext()&#xA;{&#xA;  int lim=16;&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(input);&#xA;  for(i=0; i&amp;lt;lim ; )&#xA;  {&#xA;    if(digitalRead(dw)==HIGH)&#xA;    {&#xA;      if(input[i]&amp;lt;'a')&#xA;        input[i]='z';&#xA;      if(input[i]&amp;gt;'z')&#xA;        input[i]='a';&#xA;      input[i]=input[i]+1;&#xA;      delay(1000);&#xA;    }&#xA;    if(digitalRead(up)==HIGH)&#xA;    {&#xA;      if(input[i]&amp;lt;'a')&#xA;        input[i]='z';&#xA;      if(input[i]&amp;gt;'z')&#xA;        input[i]='a';&#xA;      input[i]=input[i]-1;&#xA;      delay(1000);      &#xA;    }&#xA;    if(digitalRead(ri)==HIGH)&#xA;    {&#xA;      delay(1000);    &#xA;      i=i+1;&#xA;    }&#xA;    if(digitalRead(le)==HIGH)&#xA;    {&#xA;      delay(1000); &#xA;      i=i+1;&#xA;    }&#xA;    if(digitalRead(ok)==HIGH)&#xA;    {&#xA;      lim=i+1;&#xA;      delay(1000); &#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  lcd.begin(16,2);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Type your text:&quot;);&#xA;  intext();&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Success!!&quot;);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(input);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result I wanted it to be is like this:&#xA;first you got the &quot;type your text:&quot; on the first row and blank in the second row.&#xA;our cursor is in the first column of the second row, so we can cycle through the alphabet letters. if you press right you can edit the next column of second row. you can get to the previous column in second row by pressing left. you can input up to 15 characters.&#xA;after done typing pressing ok will stop the typing and you will see &quot;Success!!&quot; in the first row and typed text in the second row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help. I'm stumped.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6379" LastEditorUserId="37523" LastEditDate="2019-08-03T14:30:20.817" LastActivityDate="2019-08-03T14:30:20.817" Title="Simple Text input using 5 buttons" Tags="|button|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="7921" PostTypeId="1" CreationDate="2015-01-09T11:16:30.507" Score="13" ViewCount="29697" Body="&lt;p&gt;A photoresistor is already a resistor and will limit the voltage in the circuit. Why can't this be connected to a pin and measured? Why is a second resistor needed to connect the photoresistor to ground?&lt;/p&gt;&#xA;" OwnerUserId="6620" LastEditorUserId="368" LastEditDate="2015-01-09T14:45:58.393" LastActivityDate="2023-05-13T23:45:12.240" Title="Why do you need a second resistor when using a photoresistor/LDR?" Tags="|photoresistor|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7922" PostTypeId="2" ParentId="7921" CreationDate="2015-01-09T12:01:11.943" Score="8" Body="&lt;p&gt;This isn't strictly an Arduino question, but I appreciate that things like photo-resistors are common early projects for Arduino users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resistors (and other components) don't really limit the voltage in the circuit as such. Rather, each component in a series circuit gets a proportion of the total voltage. That proportion is determined by its resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only have one component, then the entire voltage is dropped across it no matter what resistance it has. Changing the resistance in that situation would only affect the amount of current flowing through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need the second resistor as a fixed reference point. You know how much voltage it will get if both resistances are equal, and that the relationship between voltage and resistance is (hypothetically) linear. You can therefore use that to figure out what resistance the other component has, e.g. the photo-resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the second resistor can also play an important role for safety. Without it, you could potentially end up with a short-circuit if the other component's resistance goes too low.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-01-09T12:18:47.950" LastActivityDate="2015-01-09T12:18:47.950" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7923" PostTypeId="2" ParentId="7921" CreationDate="2015-01-09T12:09:16.433" Score="13" Body="&lt;p&gt;The simple answer is that &lt;strong&gt;voltage&lt;/strong&gt; is very easy for the Arduino to measure, while &lt;strong&gt;resistance&lt;/strong&gt; is not, and most sensors such as Photoresistor (LDR), flex sensor, thermistors and more - are actually a variable resistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason it's hard to measure resistance changes is that the Arduino (and most IC) contain a tiny system called &lt;strong&gt;Analog to Digital Converter (ADC)&lt;/strong&gt;. This system translates changes in &lt;strong&gt;analog voltage&lt;/strong&gt; to a series of 1's and 0's that can be in turn converted to an Integer for example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ADC is designed to read &lt;em&gt;voltage&lt;/em&gt; changes, and if we want to use the Arduino's &lt;strong&gt;analogRead&lt;/strong&gt; (which utilizes the ADC) to get the Photoresistor readings for example, we will need a way to convert the changes in &lt;em&gt;resistance&lt;/em&gt; to changes in &lt;em&gt;voltage&lt;/em&gt; - and a voltage divider is the easiest way to do it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is true that the sensor is already a resistor, and as such it should change the voltage across it. But you would have trouble measuring the voltage changes, since there is no reference point except for Vcc (5V) and Ground:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0sGbf.png&quot; alt=&quot;Circuit that contains only a photoresistor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrary, when using a voltage divider, you have a well defined reference point to measure the voltage changes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AdbgC.png&quot; alt=&quot;Circuit with photoresistor and voltage divider&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-09T18:53:56.397" LastActivityDate="2015-01-09T18:53:56.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7924" PostTypeId="2" ParentId="7920" CreationDate="2015-01-09T13:49:36.680" Score="1" Body="&lt;p&gt;Several issues in the code you posted:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Every change to the text you do inside the &lt;code&gt;for&lt;/code&gt; loop, will not be reflected to the LCD until the for loop will end (when &lt;code&gt;i&amp;lt;limit&lt;/code&gt; will no longer be a true statement). You might want to add an additional code, inside the &lt;code&gt;for&lt;/code&gt; loop and outside any of its conditional statements, that will repeatedly set the cursor and print &lt;code&gt;input&lt;/code&gt; to the LCD. Something similar to the code you have prior to the &lt;code&gt;for&lt;/code&gt; loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void intext() &#xA;{&#xA;  ... // rest of the code until the for loop&#xA;&#xA;  for (int i; i&amp;lt;limit; ) &#xA;  {&#xA;    ... // all the conditions for up/down/left/right/ok&#xA;&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(input);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another problem is that when the user clicks &lt;em&gt;left&lt;/em&gt;, the counter should be decremented, not incremented, and you should check for left boundary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(le)==HIGH &amp;amp;&amp;amp; i&amp;gt;0) // left boundary check added&#xA;{&#xA;   delay(1000); &#xA;   i=i-1; // and not i=i+1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After clicking &lt;em&gt;Ok&lt;/em&gt;, and since the &lt;code&gt;for&lt;/code&gt; loop does not increment &lt;code&gt;i&lt;/code&gt;, the condition in the &lt;code&gt;for&lt;/code&gt; loop (&lt;code&gt;i&amp;lt;limit&lt;/code&gt;) will stay true, and the loop will not end until the user will click &lt;em&gt;Right&lt;/em&gt; once more. To mitigate this, change the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(ok)==HIGH)&#xA;{&#xA;  lim=i; // and not: lim=i+1;&#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Otherwise, the user will have to click &lt;em&gt;Right&lt;/em&gt; for completion, to increment &lt;code&gt;i&lt;/code&gt; once more. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;jfpoilpret&lt;/strong&gt; comment about pull up/down is very important. Make sure you use pull up/pull down resistors in order to prevent &lt;a href=&quot;http://arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;input debounce&lt;/a&gt; (more details inside this link).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-09T14:23:37.683" LastActivityDate="2015-01-09T14:23:37.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7925" PostTypeId="1" CreationDate="2015-01-09T14:43:54.343" Score="2" ViewCount="574" Body="&lt;p&gt;I am working on a project for grade 10 computer science.  I am supposed to make a piano that has 7 keys using a capacitive sensor, and the piano is supposed to teach you songs like Twinkle Twinkle Little Star by illuminating the LED corresponding with that key and then playing that tone on the speaker.  There is also a &quot;random scales&quot; part where you are timed and have to press the keys as fast as you can as they light up.  Unfortunately, I have come into a few problems.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I ran out of outputs and have to use a shift register. I have no idea on how to control each of the outputs.&lt;/li&gt;&#xA;&lt;li&gt;When the game starts I want there to be 2 options a song and a random scales using &lt;code&gt;randomSeed&lt;/code&gt; however I have NOT found a way for them to pick which option. I think I can do user input by typing or by them just pressing a key but I am not sure.&lt;/li&gt;&#xA;&lt;li&gt;I am pretty new on Arduino so anything helps.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Finally I am using the Arduino Uno and that is why I am short pins because I have 1 gnd 1 speaker and the rest key inputs.&lt;/p&gt;&#xA;" OwnerUserId="6622" LastEditorUserId="52" LastEditDate="2015-01-09T17:03:23.867" LastActivityDate="2015-01-09T17:03:23.867" Title="7 Key Educational Piano with Capacitive Sensor" Tags="|arduino-uno|programming|led|shift-register|project|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7926" PostTypeId="1" AcceptedAnswerId="7927" CreationDate="2015-01-09T16:25:06.973" Score="1" ViewCount="55" Body="&lt;p&gt;Despite many articles on the topic of vehicle platforms, none of them seem to recommend the best one to start with. Later on I am sure I will seek an exact kind of chassis for autonomous vehicle construction, but now I am looking to learn the basics of this area of the Arduino world. If you could give me a simple recommendation for the general category of vehicle platform to use it would be much appreciated. I will be using an ultrasonic distance sensor coupled with a servo motor to detect obstacles, so it is a very simple project. Thank you so much.&lt;/p&gt;&#xA;" OwnerUserId="6612" LastActivityDate="2015-01-09T16:29:15.420" Title="What is the best vehicle platform to begin with (e.g. tracked, four-wheel drive)" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7927" PostTypeId="2" ParentId="7926" CreationDate="2015-01-09T16:29:15.420" Score="2" Body="&lt;p&gt;SparkFun's &lt;a href=&quot;https://www.sparkfun.com/products/12866&quot; rel=&quot;nofollow noreferrer&quot;&gt;Magician Chassis&lt;/a&gt; is a very simple, very flexible chassis for starting out. Also comes as part of the &lt;a href=&quot;https://www.sparkfun.com/products/12697&quot; rel=&quot;nofollow noreferrer&quot;&gt;RedBot Kit&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GUDrQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-09T16:29:15.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7928" PostTypeId="1" AcceptedAnswerId="7932" CreationDate="2015-01-09T16:46:38.533" Score="0" ViewCount="1455" Body="&lt;p&gt;I'm starting a decently sized project around arduino/ATMELavr, and I came to wonder if there are any commonly accepted C/C++ coding standards or style guidelines specifically aimed at embedded C++/arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've worked mostly with python recently, and came to love the PEP8 guidelines, and the associated pep tool (which checks syntax consistency with the style guide).&#xA;Similarly, I've used jslint and similar tools for javascript, as I find they help keeping your code base homogeneous, and avoid wasting time and commits on silly typos, and arguing over where the braces should go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any similar tools for C++ or more specifically arduino C++?&lt;/p&gt;&#xA;" OwnerUserId="6623" LastActivityDate="2015-01-09T18:18:50.550" Title="coding standards for bigger projects" Tags="|programming|c++|coding-standards|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7929" PostTypeId="2" ParentId="7921" CreationDate="2015-01-09T16:52:05.383" Score="1" Body="&lt;p&gt;also another big reason for it is if you have just in series, a power source, an LDR and say a bulb, then the bulb may come on as soon as the LDR resistance gets low enough, then it will get brighter as the resistance keeps decreasing.&#xA;If configured with more resistors in a potential divider with a transistor and the bulb at the collector side, then you can vary the resistors to define the exact amount of light that will allow approx 1.6V (?)(whatever voltage turns the base into a conductor anyway), and therefore the light at which the bulb will suddenly turn on with a constant power supply direct from the power source through a fixed resistor if needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in series an LDR will vary the current with light around the circuit, in a divider and transistor it functions as a light dependant switch&lt;/p&gt;&#xA;" OwnerUserId="6624" LastActivityDate="2015-01-09T16:52:05.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7930" PostTypeId="1" CreationDate="2015-01-09T17:37:15.347" Score="0" ViewCount="625" Body="&lt;p&gt;I have five accelrometer sensors (MMA 7361) connected to the analog channels of Arduino Duemilanove. I am using the following code to read the data. (I am reading from only one axis from each sensor.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;int sensorValue = 0; // value read from the pot&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(9600); // initialize serial communications at 9600 bps:&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    // read the analog values:&#xA;&#xA;    int i=1;&#xA;&#xA;    Serial.print(&quot;ACS#&quot;);&#xA;&#xA;    for(i=0;i&amp;lt;5;i++)&#xA;    {&#xA;&#xA;        sensorValue = analogRead(i);&#xA;        Serial.print(sensorValue);&#xA;        Serial.print(&quot;#&quot;);&#xA;&#xA;        delay(10);&#xA;    }&#xA;&#xA;    Serial.println(&quot;&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a delay of 10 after reading each sensor. What should the value of the delay I should be using after reading one sensor to get the correct values from the sensors?&lt;/p&gt;&#xA;" OwnerUserId="6630" OwnerDisplayName="ukg" LastEditorUserId="-1" LastEditDate="2015-01-09T19:08:54.660" LastActivityDate="2016-02-04T03:12:10.500" Title="What should be the delay to be given for reading accelerometer" Tags="|accelerometer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7931" PostTypeId="2" ParentId="7930" CreationDate="2015-01-09T17:43:05.920" Score="1" Body="&lt;p&gt;A delay is not needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be more beneficial, though, is making a dummy reading between each real reading.  This gives the ADC more of a chance to settle on the right reading without the Sample and Hold capacitor being influenced by the previous reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way is just to duplicate your &lt;code&gt;analogRead&lt;/code&gt; line so it's done twice.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2015-01-09T17:43:05.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7932" PostTypeId="2" ParentId="7928" CreationDate="2015-01-09T18:12:03.477" Score="0" Body="&lt;p&gt;In my experience (15 years in industry, 30 total), &lt;strong&gt;this does not matter&lt;/strong&gt;. What matters is having good developers who understand code written in ANY valid style. I currently work at a large bank, and there's 2 different bracket styles being used in our code, and nobody cares. Good developers don't care about this. We care a lot more about the code being valid, error-free, and efficient. If you do that, I don't care where your brackets are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, there are style guides for C++ but you don't need to use them. This is a good one though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://google-styleguide.googlecode.com/svn/trunk/cppguide.html&quot; rel=&quot;nofollow&quot;&gt;http://google-styleguide.googlecode.com/svn/trunk/cppguide.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not aware of any style tools that integrate into Arduino IDE. There are some style tools that integrate into Eclipse though - and if this is important to you and your team, I strongly suggest using Eclipse for development. The Arduino IDE isn't really for large projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://astyleclipse.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;http://astyleclipse.sourceforge.net/&lt;/a&gt; - but Eclipse doesn't really need this, it has a pretty good built-in formatter.&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2015-01-09T18:18:50.550" LastActivityDate="2015-01-09T18:18:50.550" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7933" PostTypeId="2" ParentId="421" CreationDate="2015-01-09T20:41:10.850" Score="0" Body="&lt;p&gt;You'll need to edit the library file, Servo.h.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the line...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#define REFRESH_INTERVAL    20000     // minumim time to refresh servos in microseconds&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And change the refresh interval - 20000us (20ms) is the standard 50Hz rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change it to 3003 to get 333Hz rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will permanently change the Servo library to 333Hz.  If you need 50Hz servos, it would be best to duplicate the Servo library to Servo333 or something.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will not be able to run both at the same time as they use the same timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is based on the standard Servo library in arduino 1.06)&lt;/p&gt;&#xA;" OwnerUserId="6634" LastActivityDate="2015-01-09T20:41:10.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7934" PostTypeId="2" ParentId="7905" CreationDate="2015-01-10T01:51:33.570" Score="0" Body="&lt;p&gt;Just to complement the other responses. You can program some AVR chips using the Arduino IDE, but for it to work out-of-the-box just by using a USB cable it needs to be an Arduino or &quot;Arduino compatible&quot; board, mostly because these come with the &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;Arduino Bootloader&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bootloader is a small piece of software that runs at power-up and is responsible to load your program into the chip (as well as other configuration stuff, for more info read the previous link). If the AVR chip does not have the bootloader already flashed, then you will have to use a programmer (connected to its ISP pins) to burn it first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it's not like you can just buy random AVR chips or development boards online and start using them. But taking in consideration the wide selection of official boards and &quot;Arduino compatible&quot; ones, you should be able to find something to fit your needs.&lt;/p&gt;&#xA;" OwnerUserId="6414" LastActivityDate="2015-01-10T01:51:33.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7935" PostTypeId="2" ParentId="6782" CreationDate="2015-01-10T07:14:05.233" Score="3" Body="&lt;p&gt;I bought the SainSmart 20x04 and I also had to change the address to &lt;code&gt;0x3F&lt;/code&gt;.  My backlight jumper was missing, that little header at the right of the I2C board provides the backlight power.  Some code I found included this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6640" LastEditorUserId="46" LastEditDate="2015-01-13T16:03:42.200" LastActivityDate="2015-01-13T16:03:42.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7936" PostTypeId="1" AcceptedAnswerId="9298" CreationDate="2015-01-10T17:34:07.307" Score="0" ViewCount="255" Body="&lt;p&gt;I just recently bought an Arduimu v3. Rather annoyingly they did not supply an FTDI cable. I'm going for an FTDI cable where the I/O pins are configured to operate at 5v. I assume this is the right but I don't want to fry this board. Is this cable OK?&lt;/p&gt;&#xA;" OwnerUserId="6768" OwnerDisplayName="Ozymandias" LastActivityDate="2015-07-12T06:34:59.930" Title="5V FTDI cable for Arduimu V3" Tags="|ftdi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7938" PostTypeId="1" CreationDate="2015-01-10T19:56:51.490" Score="0" ViewCount="477" Body="&lt;p&gt;For some purpose we need to communicate with Arduino using more that one SIM card, but still like to use an only GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the idea is to use several SIM holders, to commutate each of six SIM wires to the sim we currently use. But it is still the question&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How we should handle the gsm module itself? Is it okay for it if the SIM wire will be commutated to another SIM when it is in the middle of something? May be we should power off the module before, but it unclear how to do it programmatically when it is installed on the top of Arduina Mega 2560&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) should we commutate all six wires, or may be there are few signal ones and another shouldn't be never commutated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) what is the best way to do this commutation? Relays/transistor switches and so on?&lt;/p&gt;&#xA;" OwnerUserId="6648" LastActivityDate="2015-01-10T20:37:57.960" Title="Several SIM with Arduino GSM/GPRS shield" Tags="|arduino-mega|shields|gsm|electronics|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7939" PostTypeId="2" ParentId="3184" CreationDate="2015-01-10T20:04:45.283" Score="0" Body="&lt;p&gt;If it's not too much data, a textfile as a database should suffice, if you want something more scalable; I'm quite impressed with node.js: &lt;a href=&quot;http://weworkweplay.com/play/raspberry-pi-nodejs/&quot; rel=&quot;nofollow&quot;&gt;http://weworkweplay.com/play/raspberry-pi-nodejs/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="569" LastActivityDate="2015-01-10T20:04:45.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7940" PostTypeId="2" ParentId="7938" CreationDate="2015-01-10T20:37:57.960" Score="1" Body="&lt;p&gt;You should reset the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;shield&lt;/a&gt;, and keep reset, while switch sims. The reset is on pin 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-gsm-shield-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;the schematic&lt;/a&gt;, you can see there are only 3 lines, plus a GND and VDD. The GND and VDD you can probably share between the different sims. The SIM_RST, SIM_SCK and SIM_DATA need to be switched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Multiplexer&quot; rel=&quot;nofollow&quot;&gt;MUX&lt;/a&gt; for that, but that is not my area of expertise. Note that at least the DATA line is bi-directional.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-10T20:37:57.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7941" PostTypeId="1" CreationDate="2015-01-10T21:36:48.660" Score="3" ViewCount="317" Body="&lt;p&gt;I'm very new to arduino related stuff so this question might be really easy to answer.&#xA;I don't understand how multiple PWM outputs are supposed to work. Look at the pic.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/diOvR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first(1) case we are using short signal width which would be close to motor staying still. In this case, as can be seen, short pulses follow each other, so does the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;motor1.writeMicroseconds(shortWidth);&#xA;motor2.writeMicroseconds(shortWidth);&#xA;motor3.writeMicroseconds(shortWidth);&#xA;motor4.writeMicroseconds(shortWidth);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when motor4 ended it's output, motor1 starts it's pulse again causing non-problem consequent pulses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second(2) case pulse is wider which corresponds to setting motor speed close to maximum. After motor1 finishes generating width, it's time for motor2 to generate one. But when it does, motor1's period comes to end and it has to start generate width again, but arduino is busy generating pulse of motor2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does PWMs work in this case? &lt;/p&gt;&#xA;" OwnerUserId="6649" LastActivityDate="2015-01-10T21:36:48.660" Title="Help to understand multiple PWM working together" Tags="|arduino-mega|pwm|servo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7942" PostTypeId="1" CreationDate="2015-01-10T21:56:22.033" Score="2" ViewCount="1077" Body="&lt;p&gt;So I will admit that I am a noob to Arduino. I have some experience programming microcontrollers, and that was back in the day (about 4 years ago - such as the Freescale 68HC12) so up until this point I thought I was experienced enough to get this Arduino Mega2560 rocking with AVR C using Atmel Studio and avrdude by lunch...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I'm getting held up at what's possible...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I want to accomplish:&lt;/strong&gt; Write and compile a program in AVR C within Atmel studio. Use the hex file that was built and download that to the Mega. (Keep in mind I was planning on using USB and Arduino as my programmer between PC and ATMega2560 as per this gentleman's example... &lt;a href=&quot;https://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/&lt;/a&gt; -- however, I was not using his code and he was compiling using avr-gcc...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using avrdude when attempting to write the file I get this message... (and my blinking LED goes dark for a few seconds before returning to normal operation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VVpsh.png&quot; alt=&quot;avrdude error&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I searched the internet for this issue it was never related to avrdude, but rather a communications issue. I've verified my bootloader is still ok (uploaded other sketches with no issues).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's certain that I am missing something minor, but this is my first day using Arduino so go easy on me!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="6650" LastEditorUserId="37523" LastEditDate="2019-12-03T01:36:48.787" LastActivityDate="2019-12-03T01:36:48.787" Title="Cannot program Mega2560 using Atmel Studio 6.2 and avrdude" Tags="|arduino-mega|avrdude|atmel-studio|avr-gcc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7946" PostTypeId="1" CreationDate="2015-01-11T02:13:06.693" Score="0" ViewCount="88" Body="&lt;p&gt;I am trying to output something every one second with the following code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile uint64_t timerCounts = 0;&#xA;double timenow,pretime;&#xA;void setup()&#xA;  {&#xA;     Serial.begin(19600);&#xA;     noInterrupts();&#xA;     TCCR2A = TCCR2B = 0;&#xA;     TCNT2 = 0;&#xA;     OCR2A = 124; //Zero Relative 125&#xA;     TCCR2B = B00001101;  //prescaler = 1024&#xA;     TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;     interrupts();&#xA;&#xA;     Serial.print(&quot;Begin... \n&quot;);&#xA;  }&#xA;&#xA;  //**********************************************************************&#xA;  //  Timer2 Interrupt Service is invoked by hardware Timer 2 every 0.008s&#xA;  //  16Mhz / 125 / 1024 = 125 Hz    0.008s&#xA;&#xA;  ISR(TIMER2_COMPA_vect)&#xA;  {&#xA;     timerCounts++;&#xA;     if (timerCounts == 125){&#xA;        Serial.print(&quot;1s&quot;);&#xA;        timerCounts = 0;&#xA;     }&#xA;  }  // end of TIMER2_COMPA_vect&#xA;&#xA;  void loop()&#xA;  {&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above code, I have set the &lt;code&gt;OCR2A&lt;/code&gt;(output compare register) to 124``, which is well below &lt;code&gt;256&lt;/code&gt;(2^8). A user defined counter is also used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I execute the programme, the interval between consecutive outputs is less than 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I change it to timer 1, the interval becomes roughly 1 second.&#xA;When I change it to timer 0, the interval becomes longer than 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6651" LastActivityDate="2015-03-12T13:55:34.583" Title="Weird Arduino timer behaviour" Tags="|arduino-uno|pwm|timers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7947" PostTypeId="1" CreationDate="2015-01-11T05:12:38.943" Score="2" ViewCount="258" Body="&lt;pre&gt;&lt;code&gt;int val1 =(mfrc522.uid.uidByte[0]);&#xA;int val2 =(mfrc522.uid.uidByte[1]);&#xA;int val3 =(mfrc522.uid.uidByte[2]);&#xA;int val4 =(mfrc522.uid.uidByte[3]);&#xA;&#xA;String valA=String(val1);&#xA;String valB=String(val2);&#xA;String valC=String(val3);&#xA;String valD=String(val4);&#xA;uID=valA+valB+valC+valD;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function above with &lt;code&gt;mfrc522.uid.uidByte[x]&lt;/code&gt; is from the &lt;code&gt;MFRC522.h&lt;/code&gt; Library by Miguel Balboa and it is initialized as byte there. But when I initialize the val1 to val4 as byte, the desired number doesn't appear. I don't intend to print the uID to serial (as someone may suggest that to readily print to serial as it converts it automatically to some ASCII strings), but instead in the &lt;code&gt;client.print()&lt;/code&gt; of the Ethernet library along with other codes. I want to save it into another &quot;greater&quot; variable in terms of speed and memory allocation. The Arduino community warns about the use of &lt;code&gt;String&lt;/code&gt; as it uses additional decoding which is not needed as well as may crash Arduino and make Arduino run out of memory. And somehow, I experience some lagging or hanging in the serial, which I thought maybe due to the use of Strings variable. Please help me. I've read some &lt;code&gt;sprintf()&lt;/code&gt; concatenations and &lt;code&gt;free()&lt;/code&gt; but not well documented, I'm quite confused on their explanations. :)&lt;/p&gt;&#xA;" OwnerUserId="4609" LastEditorUserId="11086" LastEditDate="2015-08-11T12:07:32.913" LastActivityDate="2016-07-07T01:49:05.617" Title="Is there any way that the values here be converted to another variable and not string?" Tags="|arduino-uno|string|memory-usage|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7950" PostTypeId="1" CreationDate="2015-01-11T09:37:23.073" Score="0" ViewCount="4828" Body="&lt;p&gt;I'm attempting to read data from my SD card, but I have strange behavior and can't figure out why this is happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;strong&gt;CardInfo&lt;/strong&gt; from the Arduino example and am trying to read the data from my SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm faced with two different problems, but maybe they can be related:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1:&lt;/strong&gt;  If I format my SD card from my Mac (FAT32), if my card is still empty, the program can read my card and output the right information. But if I add data from my Mac to the SD Card, card.init never initialise, and my data are never read (because of the hidden files). If I remove those hidden files, but let only the expected files be, the program never find them, like if my card was still empty. I don't know how to handle this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2:&lt;/strong&gt; From my Arduino, if I feed the card from the 3.3&amp;nbsp;V output, I get the&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Card type: SD2 Could not find FAT16/FAT32 partition. Make sure you've&#xA;  formatted the card&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It only works on 5&amp;nbsp;V (but the card type becomes SDHC). So I've tried to feed my card with another 3.3&amp;nbsp;V/5&amp;nbsp;V supply (my Arduino is grounded to this supply as well), but this is only working on 5&amp;nbsp;V. On 3.3&amp;nbsp;V my card isn't detected. My wires to the SD card are about 15 inch. I don't know if it can affect it drastically, but this is the only 'weird' thing about this circuit. By the way I naively think my 3.3&amp;nbsp;V supply should handle that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my materials:&#xA;- Arduino Duemilanove&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For the SPI wiring I'm using pin 10 for SS.&lt;/li&gt;&#xA;&lt;li&gt;Using the Cardinfo from the Arduino library.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="Mr Bonjour" LastEditorUserId="510" LastEditDate="2015-02-06T22:01:21.333" LastActivityDate="2017-01-05T20:31:16.010" Title="Struggling with SD card read on Arduino" Tags="|sd-card|spi|mac-os|arduino-duemilanove|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7951" PostTypeId="1" CreationDate="2015-01-11T12:26:49.460" Score="1" ViewCount="1760" Body="&lt;p&gt;I am working for arduino websocket client with CC3000 wifi board from adafruit.&#xA;I have usde this websocket example as a reference and modified to work with cc3000 wifi board.&#xA;I am not able to connect to echo.websocket.org.&#xA;My code shows client is not connected and unavailable to communicate after sending the upgrade headers.&#xA;Here is the serial monitor response for the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo.websocket.org -&amp;gt; Errno: 1&#xA;174.129.224.73-------------------------------------&#xA;Client connected&#xA;Sending websocket upgrade headers&#xA;Analyzing response headers&#xA;client not connected&#xA;client not available&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the Arduino sckech:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;WebSocketClient.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;SPI_CLOCK_DIVIDER); // you can change this clock speed&#xA;&#xA;#define WLAN_SSID       &quot;UNSTOPPABLE&quot;           // cannot be longer than 32 characters!&#xA;#define WLAN_PASS       &quot;8878333344&quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data &#xA;// received before closing the connection.  If you know the server&#xA;// you're accessing is quick to respond, you can reduce this value.&#xA;&#xA;// What page to grab!&#xA;#define WEBSITE      &quot;echo.websocket.org&quot;&#xA;//#define WEBPAGE      &quot;/testwifi/index.html&quot;&#xA;&#xA;// Here we define a maximum framelength to 64 bytes. Default is 256.&#xA;#define MAX_FRAME_LENGTH 64&#xA;&#xA;// Define how many callback functions you have. Default is 1.&#xA;#define CALLBACK_FUNCTIONS 1&#xA;&#xA;&#xA;&#xA;Adafruit_CC3000_Client www;&#xA;WebSocketClient webSocketClient;&#xA;/**************************************************************************/&#xA;/*!&#xA; @brief  Sets up the HW and the CC3000 module (called automatically&#xA; on startup)&#xA; */&#xA;/**************************************************************************/&#xA;&#xA;uint32_t ip;&#xA;&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); &#xA;&#xA;  Serial.print(&quot;Free RAM: &quot;); &#xA;  Serial.println(getFreeRam(), DEC);&#xA;&#xA;  /* Initialise the module */&#xA;  Serial.println(F(&quot;\nInitializing...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  // Optional SSID scan&#xA;  // listSSIDResults();&#xA;&#xA;  Serial.print(F(&quot;\nAttempting to connect to &quot;)); &#xA;  Serial.println(WLAN_SSID);&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;&#xA;  /* Display the IP address DNS, Gateway, etc. */&#xA;  while (! displayConnectionDetails()) {&#xA;    delay(1000);&#xA;  }&#xA;&#xA;  ip = 0;&#xA;  // Try looking up the website's IP address&#xA;  Serial.print(WEBSITE); &#xA;  Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;  while (ip == 0) {&#xA;    if (! cc3000.getHostByName(WEBSITE, &amp;amp;ip)) {&#xA;      Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;&#xA;  // Optional: Do a ping test on the website&#xA;  /*&#xA;  Serial.print(F(&quot;\n\rPinging &quot;)); cc3000.printIPdotsRev(ip); Serial.print(&quot;...&quot;);  &#xA;   replies = cc3000.ping(ip, 5);&#xA;   Serial.print(replies); Serial.println(F(&quot; replies&quot;));&#xA;   */&#xA;&#xA;  /* Try connecting to the website.&#xA;   Note: HTTP/1.1 protocol is used to keep the server from closing the connection before all data is read.&#xA;   */&#xA;  www = cc3000.connectTCP(ip, 80);&#xA;  if (www.connected()) {&#xA;    /*    www.fastrprint(F(&quot;GET &quot;));&#xA;     www.fastrprint(WEBPAGE);&#xA;     www.fastrprint(F(&quot; HTTP/1.1\r\n&quot;));&#xA;     www.fastrprint(F(&quot;Host: &quot;)); www.fastrprint(WEBSITE); www.fastrprint(F(&quot;\r\n&quot;));&#xA;     www.fastrprint(F(&quot;\r\n&quot;));&#xA;     www.println();*/&#xA;  } &#xA;  else {&#xA;    Serial.println(F(&quot;Connection failed&quot;));    &#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;-------------------------------------&quot;));&#xA;&#xA;  /* Read data until either the connection is closed, or the idle timeout is reached. */&#xA;  /*  unsigned long lastRead = millis();&#xA;   while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;   while (www.available()) {&#xA;   char c = www.read();&#xA;   Serial.print(c);&#xA;   lastRead = millis();&#xA;   }&#xA;   }&#xA;   www.close();&#xA;   Serial.println(F(&quot;-------------------------------------&quot;));*/&#xA;&#xA;  /* You need to make sure to clean up after yourself or the CC3000 can freak out */&#xA;  /* the next time your try to connect ... */&#xA;  /*  Serial.println(F(&quot;\n\nDisconnecting&quot;));&#xA;   cc3000.disconnect();*/&#xA;  // Handshake with the server&#xA;  webSocketClient.path = &quot;/&quot;;&#xA;  webSocketClient.host = WEBSITE;&#xA;&#xA;  if (webSocketClient.handshake(www)) {&#xA;    Serial.println(&quot;Handshake successful&quot;);&#xA;  } &#xA;  else {&#xA;    Serial.println(&quot;Handshake failed.&quot;);&#xA;    while(1) {&#xA;      // Hang on failure&#xA;    }  &#xA;  }  &#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  String data; &#xA;  if (www.connected()) {&#xA;&#xA;    /*   data = webSocketClient.getData();&#xA;&#xA;     if (data.length() &amp;gt; 0) {&#xA;     Serial.print(&quot;Received data: &quot;);&#xA;     Serial.println(data);&#xA;     }*/&#xA;&#xA;    // capture the value of analog 1, send it along&#xA;    pinMode(1, INPUT);&#xA;    data = String(analogRead(1));&#xA;&#xA;    webSocketClient.sendData(data);&#xA;&#xA;  } &#xA;  else {&#xA;&#xA;    Serial.println(&quot;Client disconnected.&quot;);&#xA;    while (1) {&#xA;      // Hang on disconnect.&#xA;    }&#xA;  }&#xA;&#xA;  // wait to fully let the client disconnect&#xA;  delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If anybody can guide me where I am wrong then it would be great help.I have taken reference code from &lt;a href=&quot;https://github.com/brandenhall/Arduino-Websocket&quot; rel=&quot;nofollow&quot;&gt;brandenhall/Arduino-Websocket&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6656" LastEditorDisplayName="user31481" LastEditDate="2017-11-07T16:07:29.003" LastActivityDate="2020-08-25T05:05:10.423" Title="Arduino CC3000 websocket client" Tags="|arduino-uno|wifi|code-review|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7952" PostTypeId="2" ParentId="7946" CreationDate="2015-01-11T12:47:25.347" Score="1" Body="&lt;p&gt;OCR2A doesn't do anything because the timer is in 'normal' mode. In normal mode the timer will just count to 256, not 125. Which would mean the you get a serial.print every 2.05s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use CTC mode. Do this by setting the &lt;code&gt;WGM21&lt;/code&gt; bit to 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR2A = _BV(WGM21);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-11T12:47:25.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7953" PostTypeId="1" AcceptedAnswerId="7954" CreationDate="2015-01-11T13:13:35.077" Score="1" ViewCount="372" Body="&lt;p&gt;So i want to make arduino show my computer cpu usage with leds, for example if 10% then 1 led will light, if 50% then 5 leds, if 80% then 8 leds...&lt;/p&gt;&#xA;" OwnerUserId="6658" OwnerDisplayName="Arttu" LastActivityDate="2015-01-11T13:58:59.200" Title="How to make arduino show cpu usage with 10 leds?" Tags="|led|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7954" PostTypeId="2" ParentId="7953" CreationDate="2015-01-11T13:58:59.200" Score="3" Body="&lt;p&gt;There's three basic steps you need to cover:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the CPU usage of your computer&lt;/li&gt;&#xA;&lt;li&gt;Communicate that to the Arduino&lt;/li&gt;&#xA;&lt;li&gt;Have the Arduino respond to the data&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;We can't really help you with step 1.  That's outside our remit.   You should head over to &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;StackOverflow&lt;/a&gt; for that. How you would do it depends on your host OS since each one has its own way of reporting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For step 2 you would need to write software for your computer, incorporating what you have learned from step 1.  Once you have the correct data you need to send it over to the Arduino through its serial connection. You'd need to come up with a good way of doing that, but probably just sending the usage percentage as plain ASCII text separated by new-lines is probably simplest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 3 would entail reading in the data you sent in step 2, deciding what the numbers you have got mean, and then turning on the relevant LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, which might simplify things a little, might be to use something like &lt;a href=&quot;http://arduino.cc/en/reference/firmata&quot; rel=&quot;nofollow noreferrer&quot;&gt;Firmata&lt;/a&gt;, where your PC sends the instructions to turn the LEDs on and off, and the Arduino just becomes a kind of dumb interface that doesn't do much on its own.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-01-11T13:58:59.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7955" PostTypeId="1" CreationDate="2015-01-11T15:28:17.187" Score="0" ViewCount="474" Body="&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);        // Initialize serial communications with the PC&#xA;&#xA;    // disable SD SPI&#xA;    pinMode(4, OUTPUT);&#xA;    digitalWrite(4, HIGH);&#xA;&#xA;    // disable w5100 SPI&#xA;    pinMode(10, OUTPUT);&#xA;    digitalWrite(10, HIGH);&#xA;&#xA;    SPI.begin();                // Init SPI bus&#xA;    mfrc522.PCD_Init();        // Init MFRC522 card&#xA;    //Serial.println(&quot;Scan a MIFARE Classic PICC to demonstrate Value Blocks.&quot;);&#xA;&#xA;    Ethernet.begin(mac, ip); //we used a STATIC address to start ETHERNET&#xA;&#xA;    // print your local IP address:&#xA;    Serial.print(&quot;My IP address: &quot;);&#xA;    for (byte thisByte = 0; thisByte &amp;lt; 4; thisByte++) {&#xA;        // print the value of each byte of the IP address:&#xA;        Serial.print(Ethernet.localIP()[thisByte], DEC);&#xA;        Serial.print(&quot;.&quot;);&#xA;    }&#xA;    // give the Ethernet shield a second to initialize:&#xA;    delay(1000);&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.&#xA;    MFRC522::MIFARE_Key key;&#xA;            key.keyByte[0] = 0xFF;&#xA;            key.keyByte[1] = 0xFF;&#xA;            key.keyByte[2] = 0xFF;&#xA;            key.keyByte[3] = 0xFF;&#xA;            key.keyByte[4] = 0xFF;&#xA;            key.keyByte[5] = 0xFF;&#xA;&#xA;    // Look for new cards&#xA;    if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;        return;&#xA;    }&#xA;&#xA;    // Select one of the cards&#xA;    if ( ! mfrc522.PICC_ReadCardSerial()) {&#xA;        return;&#xA;    }&#xA;    // Now a card is selected. The UID and SAK is in mfrc522.uid.&#xA;&#xA;    // Dump UID&#xA;    //Serial.print(&quot;Card UID:&quot;);&#xA;    //Serial.print(mfrc522.uid.uidByte[i] &amp;lt; 0x10 ? &quot; 0&quot; : &quot;&quot;);&#xA;&#xA;    // In this sample we use the second sector (ie block 4-7). the first sector is = 0&#xA;    // scegliere settore di lettura da 0 = primo settore &#xA;    byte sector         = 0;&#xA;    // block sector 0-3(sector0) 4-7(sector1) 8-11(sector2)&#xA;    // blocchi di scrittura da 0-3(sector0) 4-7(sector1) 8-11(sector2)&#xA;    byte valueBlockA    = 0;&#xA;    byte valueBlockB    = 1;&#xA;    byte valueBlockC    = 2;&#xA;    byte trailerBlock   = 3;&#xA;    byte status;&#xA;    // Authenticate using key A.&#xA;    // avvio l'autentificazione A&#xA;    //Serial.println(&quot;Authenticating using key A...&quot;);&#xA;    status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &amp;amp;key, &amp;amp;(mfrc522.uid));&#xA;    if (status != MFRC522::STATUS_OK)&#xA;    {&#xA;        Serial.print(&quot;PCD_Authenticate() failed: &quot;);        &#xA;        Serial.println(mfrc522.GetStatusCodeName(status));&#xA;        return;&#xA;    }&#xA;&#xA;   //No KEY B Authentication              &#xA;   int val1 =(mfrc522.uid.uidByte[0]);&#xA;   int val2 =(mfrc522.uid.uidByte[1]);&#xA;   int val3 =(mfrc522.uid.uidByte[2]);&#xA;   int val4 =(mfrc522.uid.uidByte[3]);&#xA;&#xA;   String valA=String(val1);&#xA;   String valB=String(val2);&#xA;   String valC=String(val3);&#xA;   String valD=String(val4);&#xA;&#xA;   uID=valA+valB+valC+valD;&#xA;   Serial.print(uID);&#xA;   Serial.println();&#xA;   counter=counter+1;    &#xA;   Serial.print(counter); &#xA;   //} &#xA;   Serial.println();&#xA;&#xA;   // Halt PICC&#xA;   mfrc522.PICC_HaltA();&#xA;&#xA;   // Stop encryption on PCD&#xA;   mfrc522.PCD_StopCrypto1();&#xA;&#xA;   if (counter&amp;gt;first)&#xA;   {//delay ifs&#xA;       // enable w5100 SPI &#xA;       if (client.connect(server, 80)) { //start of IF&#xA;           Serial.println(&quot;connected&quot;);&#xA;           client.print(&quot;GET /accessdenyrfid.php?rfid=&quot;); //dont make these println &#xA;           client.print(uID);   //dont make these println&#xA;           client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;           client.print(&quot;ip=mech1&quot;);&#xA;&#xA;            //client.print( ip );&#xA;            //client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;            //client.print(&quot;ipkey=&quot;);&#xA;            //client.print( ipkey );&#xA;&#xA;            client.println(&quot; HTTP/1.1&quot;);   //println&#xA;            client.println(&quot;Host: &quot;);    //println&#xA;            client.print(server);//don't make println&#xA;            client.println(&quot;Connection: close&quot;);  //println&#xA;            client.println();   //terminates the query&#xA;            Serial.print(&quot;SENT&quot;);&#xA;            Serial.println();&#xA;            first++;&#xA;            Serial.print(first);&#xA;            Serial.println();&#xA;            // add this&#xA;            while(client.connected()) {&#xA;                while(client.available()) {&#xA;                    char ch = client.read();&#xA;                    Serial.write(ch);&#xA;                }&#xA;            }&#xA;&#xA;           client.stop();&#xA;           client.flush();&#xA;&#xA;       } //end OF IF&#xA;    }//delay ifs   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above works perfectly with another php. that either saves or denies a card into a database. The arduino sends and receives data back and forth from and to php in less than a second. But the problem is that whenever the function client.stop is called. It takes approx. 8 seconds before another data is sent in the loop function. I need the loop to continue with just 2 second interval, which is enough or even faster. I don't think that the mysql query in the php is the one that makes it longer cause all the queries are made before the delay starts. (The server has already sent it's response, before the delay starts, which i think is in the client.stop.) Please help me on other alternatives on stopping the client or any way I can do this faster. Thanks, I'm really in trouble right now. I'm using Arduino UNO. Data sent back and forth are just a couple of letters and numbers.&lt;/p&gt;&#xA;" OwnerUserId="4609" LastEditorUserId="1585" LastEditDate="2015-02-13T17:00:31.363" LastActivityDate="2016-02-10T12:27:52.413" Title="Why client.stop causes some significant delay to do another task in a loop?" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7958" PostTypeId="1" AcceptedAnswerId="7983" CreationDate="2015-01-11T18:42:57.077" Score="0" ViewCount="185" Body="&lt;p&gt;There are two files (that can be seen on my computer) on my sd card, &lt;code&gt;6.bmp&lt;/code&gt; and &lt;code&gt;example.txt&lt;/code&gt; (the latter written from my arduino). I have them connected to my arduino via LCSTUDIO breakout board (which surprisingly caused me no trouble at all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the example &quot;cardinfo&quot; sketch, the files it lists includes those two files along with tons of others, which I assume are just invisible from a personal computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I list only the files that can be seen from my computer (i.e. aren't inside any directory, but are just plain in the SD card)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using arduino UNO&lt;/p&gt;&#xA;" OwnerUserId="6662" LastActivityDate="2015-01-12T17:51:22.753" Title="Arduino Uno with SD, Cardinfo sketch how to list only visible files" Tags="|arduino-uno|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7959" PostTypeId="1" AcceptedAnswerId="7961" CreationDate="2015-01-11T16:47:54.417" Score="1" ViewCount="1320" Body="&lt;p&gt;I've been using an Arduino Leonardo on my Windows machine for a few days now without too much trouble but today the COM port disappeared. I've been able to successfully send sketches to the arduino and execute them so everything was working until recently. When I look in Device manager on the control panel there is no com port listed for the arduino. If I reset the device then a com port shows up briefly with &quot;Arduino Leonardo BootLoader&quot; but after a few seconds that disappears. I've tried USB2.0 and USB 3.0 ports on my PC and a different cable but to no avail. I don't have anything listed under &quot;Other Devices&quot; and I'm out of ideas for what could be the trouble.&#xA;I'm trying to get it recognised now as just the leonardo with nothing connected to any pin. Any ideas of what to try?&lt;/p&gt;&#xA;" OwnerUserId="6664" OwnerDisplayName="Jon" LastEditorUserId="6452" LastEditDate="2015-01-12T13:17:38.163" LastActivityDate="2022-09-15T08:12:27.523" Title="Arduino Leonardo on Win 8.1 COM port disappeared" Tags="|serial|arduino-leonardo|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7960" PostTypeId="2" ParentId="7959" CreationDate="2015-01-11T17:02:24.617" Score="0" Body="&lt;p&gt;Do note that on some example sketches the setup of the &quot;Serial.&quot; function requires that there is special check for the serial port to be recognized/enabled (for the Leonardo only).  Have you actually run a serial sketch to see if the com port comes back?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you load any other software or run virus checks that might have interfered with the special USB/Com driver?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try unloading and reloading the special driver used with the USB.  Be sure to use the one specifically for Win8.&lt;/p&gt;&#xA;" OwnerDisplayName="Nedd" LastActivityDate="2015-01-11T17:02:24.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7961" PostTypeId="2" ParentId="7959" CreationDate="2015-01-11T19:39:53.833" Score="1" Body="&lt;p&gt;Strange, it's resolved itself/I resolved it. I don't know whether what I did was actually responsible for solving this but I'm back in business:&#xA;* I reset the board so that the bootloader appeared as a com port&#xA;* I set the arduino IDE to use the port that appeared for the bootloader&#xA;* I uploaded a simple sketch and pressed reset during the &quot;upload phase&quot; so that the port appeared during the upload&#xA;* the upload completed successfully and the arduino was back in the com port list&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd still be interested to understand what I did that caused the problem in the first place but I suppose something was corrupted on the board?&lt;/p&gt;&#xA;" OwnerUserId="6664" LastActivityDate="2015-01-11T19:39:53.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7962" PostTypeId="1" CreationDate="2015-01-11T20:12:14.517" Score="2" ViewCount="101" Body="&lt;p&gt;I recently got the Arduino Robot and have been looking at the examples for the RobotLibrary. As I looked, I found something quite confusing (for me at least), a few of them describe connecting a sensor (like an &lt;a href=&quot;http://arduino.cc/en/Tutorial/RobotRemoteControl&quot; rel=&quot;nofollow noreferrer&quot;&gt;IR sensor&lt;/a&gt; or &lt;a href=&quot;http://arduino.cc/en/Tutorial/RobotRunawayRobot&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ultrasonic sensor&lt;/a&gt;) to a port with a cable that was provided with the robot. But I never received a cable. Which got me to question, what type of cable is this, because it is not the same cable you would use on an UNO, at least not according to the pictures. So does anyone know what type of cables these are and/or where I can get them? Thanks :smiley-mr-green: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the pictures btw:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/o4iVG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the next one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DNgmX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4509" LastEditorUserId="4509" LastEditDate="2015-01-11T21:30:56.323" LastActivityDate="2015-02-12T00:47:07.170" Title="The Arduino robot tutorials describe a cord comming with the official robot, now I'm confused" Tags="|hardware|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7963" PostTypeId="1" AcceptedAnswerId="7967" CreationDate="2015-01-12T01:59:54.837" Score="1" ViewCount="275" Body="&lt;p&gt;I'm working on a function to fade RGB LEDs smoothly from one color to the next, so I thought I'd use a for loop  to increment each RGB value according with the set value. I've made the for loop as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (redFadeCurrent, greenFadeCurrent, blueFadeCurrent;&#xA;   ((redFadeCurrent != redFadeTarget)&amp;amp;&amp;amp;&#xA;   (greenFadeCurrent != greenFadeTarget)&amp;amp;&amp;amp;&#xA;   (blueFadeCurrent != blueFadeTarget));&#xA;   redFadeCurrent = redFadeCurrent + redStep,&#xA;   greenFadeCurrent = greenFadeCurrent + greenStep, &#xA;   blueFadeCurrent = blueFadeCurrent + blueStep) {&#xA;&#xA;    analogWrite(ledRedPin, redFadeCurrent);&#xA;    analogWrite(ledGreenPin, greenFadeCurrent);&#xA;    analogWrite(ledBluePin, blueFadeCurrent);&#xA;    Serial.print(&quot;Red: &quot;); &#xA;    Serial.print(redFadeCurrent);&#xA;    Serial.print(&quot; Green: &quot;); &#xA;    Serial.print(greenFadeCurrent);&#xA;    Serial.print(&quot; Blue: &quot;); &#xA;    Serial.println(blueFadeCurrent);&#xA;    delay(3000);&#xA;&#xA;    if (redFadeCurrent&amp;gt;redFadeTarget) {&#xA;        redStep = -1;&#xA;    }&#xA;    else if (redFadeCurrent&amp;lt;redFadeTarget) {&#xA;        redStep = +1;&#xA;    }&#xA;    else {&#xA;        redStep = 0;&#xA;    }&#xA;&#xA;    if (greenFadeCurrent&amp;gt;greenFadeTarget) {&#xA;        greenStep = -1;&#xA;    }&#xA;    else if (greenFadeCurrent&amp;lt;greenFadeTarget) {&#xA;        greenStep = +1;&#xA;    }&#xA;    else {&#xA;        greenStep = 0;&#xA;    }&#xA;&#xA;    if (blueFadeCurrent&amp;gt;blueFadeTarget) {&#xA;        blueStep = -1;&#xA;    }&#xA;    else if (blueFadeCurrent&amp;lt;blueFadeTarget) {&#xA;        blueStep = +1;&#xA;    }&#xA;    else {&#xA;        blueStep = 0;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is, when one of the values hit the target the code leaves the for loop. &#xA;I'm guessing the condition &lt;code&gt;((redFadeCurrent != redFadeTarget)&amp;amp;&amp;amp;(greenFadeCurrent != greenFadeTarget)&amp;amp;&amp;amp;(blueFadeCurrent != blueFadeTarget))&lt;/code&gt; does not work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to work around this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks is advance.&lt;/p&gt;&#xA;" OwnerUserId="6666" LastEditorUserId="84" LastEditDate="2015-01-12T05:33:17.487" LastActivityDate="2015-01-12T09:08:17.303" Title="RGB fade program" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7964" PostTypeId="1" CreationDate="2015-01-12T04:00:25.287" Score="2" ViewCount="1845" Body="&lt;p&gt;I bought &lt;a href=&quot;https://www.sparkfun.com/products/12877&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; rgb's from Sparkfun, however I have no idea how to hook them up or how to program them. Obviously the &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Components/LED/COM-12877.pdf&quot; rel=&quot;nofollow&quot;&gt;data sheet&lt;/a&gt; was somewhat helpful, however I have no idea how the IC's in the LED's work themselves or how to control them separately, or even how to string them together. My best guess is currently going for what the led's appear as in the example picture by connecting the first and last pins and putting the respective Vcc and ground pins to Vcc and ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any good examples for hooking these up and coding them, or a basic understandable explanation for how they work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, I can't find a great resource yet.&lt;/p&gt;&#xA;" OwnerUserId="4638" LastActivityDate="2015-01-12T05:49:16.627" Title="Do addressable RGB's need to be programmed differently from normal RGB's?" Tags="|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7965" PostTypeId="2" ParentId="7964" CreationDate="2015-01-12T05:49:16.627" Score="3" Body="&lt;p&gt;These are much different than &quot;normal&quot; RGB LED: they use the &lt;strong&gt;&lt;a href=&quot;http://www.adafruit.com/datasheets/WS2812.pdf&quot; rel=&quot;nofollow&quot;&gt;WS2812&lt;/a&gt;&lt;/strong&gt; chip, which is the same as the chip used in famous Adafruit &quot;neopixels&quot; strips, rings... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring is simple. For all LEDs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GND to 0V&lt;/li&gt;&#xA;&lt;li&gt;VDD to 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the first LED (connected to Arduino):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DIN to any Arduino logical output pin&lt;/li&gt;&#xA;&lt;li&gt;DOUT to the 2nd LED you want to address (on its DIN pin)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For all but the first LED:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DIN to the previous LED DOUT&lt;/li&gt;&#xA;&lt;li&gt;DOUT to the next LED DIN (or left floating for the last LED)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Programming neopixel is quite hard because timing of sent commands must be very precise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I highly suggest to use &lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel&quot; rel=&quot;nofollow&quot;&gt;Adafruit libraries&lt;/a&gt; for that.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-12T05:49:16.627" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="7966" PostTypeId="1" AcceptedAnswerId="7971" CreationDate="2015-01-12T08:55:38.213" Score="5" ViewCount="1324" Body="&lt;p&gt;I was just playing around a bit and ran into a strange problem. LED 3, 5, 6, 9 and 10 are on, as intended. For some reason LED 0 and 1 are on as well. Can someone explain why this is happening?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPins[] = {3, 5, 6, 9, 10};&#xA;int pinCount = sizeof(ledPins);&#xA;&#xA;void setup(){&#xA;  for (int i = 0; i &amp;lt; pinCount; i++){&#xA;    pinMode(ledPins[i], OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA;   for (int i = 0; i &amp;lt; pinCount; i++){&#xA;     digitalWrite(ledPins[i], 1);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5166" LastActivityDate="2015-01-12T09:35:48.970" Title="Why are LED 0 and 1 on as well?" Tags="|led|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7967" PostTypeId="2" ParentId="7963" CreationDate="2015-01-12T09:08:17.303" Score="2" Body="&lt;p&gt;You are correct, the problem is the condition inside the &lt;code&gt;for&lt;/code&gt; statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's examine what happens when the &lt;em&gt;red&lt;/em&gt; LED hits its fading target, which is, say, 100 (for the sake of the example, I will fabricate the other values):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (...; (100 != 100) &amp;amp;&amp;amp; (90 != 100) &amp;amp;&amp;amp; (80 != 100) ; ... )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(100 != 100) -&gt; &lt;strong&gt;FALSE&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;li&gt;(90 != 100) -&gt; &lt;strong&gt;TRUE&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;(80 != 100) -&gt; &lt;strong&gt;TRUE&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;FALSE&lt;/strong&gt; &amp;amp;&amp;amp; &lt;strong&gt;TRUE&lt;/strong&gt; &amp;amp;&amp;amp; &lt;strong&gt;TRUE&lt;/strong&gt; -&gt; &lt;strong&gt;FALSE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The condition inside the &lt;code&gt;for&lt;/code&gt; evaluates to &lt;code&gt;FALSE&lt;/code&gt;, therefor the loop will exit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the loop to continue as long as there is at least one LED which hasn't hit the fading target, you should change the &lt;code&gt;AND&lt;/code&gt; to &lt;code&gt;OR&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;((redFadeCurrent != redFadeTarget) || (greenFadeCurrent != greenFadeTarget) ||&#xA;   (blueFadeCurrent != blueFadeTarget))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's examine what happens now with the same values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (...; (100!=100) || (90 != 100) || (80 != 100) ; ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(100 != 100) -&gt; FALSE&lt;/li&gt;&#xA;&lt;li&gt;(90 != 100) -&gt; TRUE&lt;/li&gt;&#xA;&lt;li&gt;(80 != 100) -&gt; TRUE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;FALSE&lt;/strong&gt; || &lt;strong&gt;TRUE&lt;/strong&gt; || &lt;strong&gt;TRUE&lt;/strong&gt; -&gt; &lt;strong&gt;TRUE&lt;/strong&gt; ==&gt; The loop will continue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what will happen when all the colors hit the fading targets?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (...; (100!=100) || (100 != 100) || (100 != 100) ; ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(100 != 100) -&gt; FALSE &lt;/li&gt;&#xA;&lt;li&gt;(100 != 100) -&gt; FALSE &lt;/li&gt;&#xA;&lt;li&gt;(100 != 100) -&gt; FALSE &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;FALSE&lt;/strong&gt; || &lt;strong&gt;FALSE&lt;/strong&gt; || &lt;strong&gt;FALSE&lt;/strong&gt; -&gt; &lt;strong&gt;FALSE&lt;/strong&gt; ==&gt; The loop will stop since the condition will not evaluate to &lt;code&gt;TRUE&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-01-12T09:08:17.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7968" PostTypeId="2" ParentId="7947" CreationDate="2015-01-12T09:13:04.403" Score="0" Body="&lt;p&gt;The UidByte[] is a 10 character array, loaded with the tag ID (this is an RFID reader) by the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code is attempting to put a character value into integer variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you mean to do (I think) is to read the string as a number - this would be &lt;code&gt;val=atoi(mfrc522.uid.uidByte)&lt;/code&gt; which relies on there being only numeric data in the ID string - or at least, will only read the leading numbers (if any). Also, there are 10 characters in the string - if you want to limit this to 4 you will need slightly more code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a tag on which you set the ID then this is usable, for your tags at least; but you can't rely on numeric uid's being universal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your intent is, as you say, to include it in a longer string, then the overhead of atoi is completely unnecessary and you should just handle it as a string. I think you have misunderstood the warnings about strings, there isn't a problem just handling short chunks of fixed-length data as strings, and I think you are inadvertently causing trouble by extra conversions.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-12T09:13:04.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7969" PostTypeId="2" ParentId="7966" CreationDate="2015-01-12T09:18:33.603" Score="4" Body="&lt;p&gt;You haven't initialised the other pins at all; or included your circuit, but clearly you have LEDs on more pins than those defined (5 defined, 7 on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other LEDs are, therefore, in an undefined state - and may well be attached to pins set 'on' by default in your circuit. You probably need to either move 0/1 off the serial interface or explicitly set them 'off'.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-12T09:18:33.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7970" PostTypeId="2" ParentId="6516" CreationDate="2015-01-12T09:26:45.400" Score="1" Body="&lt;p&gt;You are constantly running .5mA through 2 nails in wet earth. What are they made of, that won't undergo some electrolysis in 1/2 hour? Gerben appears to have hit the, er, nail on the head in one, above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can avoid this to an extent by using a.c. drive to the probes, which reverses the effect so they only tarnish at about the normal rate for metal X in soil. &lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-12T09:26:45.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7971" PostTypeId="2" ParentId="7966" CreationDate="2015-01-12T09:35:48.970" Score="12" Body="&lt;p&gt;The behaviour of your program is undefined because you're reading past the end of your array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C/C++, the &lt;code&gt;sizeof&lt;/code&gt; operator always gives you the size of something in &lt;strong&gt;bytes&lt;/strong&gt;. It doesn't directly tell you the number of items in an array. Since &lt;code&gt;int&lt;/code&gt; is usually 2 bytes for Arduino programming, the &lt;code&gt;pinCount&lt;/code&gt; variable is actually being initialised to &lt;strong&gt;10&lt;/strong&gt; (5 items x 2 bytes each).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is that each &lt;code&gt;for&lt;/code&gt; loop is actually doing 10 iterations. The first 5 iterations are OK, reading correctly from the &lt;code&gt;ledPins&lt;/code&gt; array. However, the rest of the iterations are reading whatever data happens to be in memory after that. This means it could be trying to initialise and switch on any pin, potentially including 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't guarantee that this is the source of the problem, but it's certainly very important to fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is quite easy though. Divide the total size of the array by the size of a single element:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pinCount = sizeof(ledPins) / sizeof(int);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-12T09:35:48.970" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="7972" PostTypeId="5" CreationDate="2015-01-12T10:21:43.063" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-01-12T10:21:43.063" LastActivityDate="2015-01-12T10:21:43.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7973" PostTypeId="4" CreationDate="2015-01-12T10:21:43.063" Score="0" Body="Light sensitive resistors whose resistance decreases with the amount of light they receive." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-01-12T14:26:03.357" LastActivityDate="2015-01-12T14:26:03.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7974" PostTypeId="5" CreationDate="2015-01-12T10:23:43.787" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-01-12T10:23:43.787" LastActivityDate="2015-01-12T10:23:43.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7975" PostTypeId="4" CreationDate="2015-01-12T10:23:43.787" Score="0" Body="An 8-bit, low power AVR microcontroller from Atmel." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-01-12T17:10:35.043" LastActivityDate="2015-01-12T17:10:35.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7976" PostTypeId="1" AcceptedAnswerId="8002" CreationDate="2015-01-12T11:14:01.863" Score="1" ViewCount="3550" Body="&lt;p&gt;I have an Arduino Mega with an MaxBotix (MB7066) sonar attached, the sonar has the ability to send serial data with it's reading. It uses a asynchronous RS232 format, except the voltages are 0-Vcc. The output should be a capital &quot;R&quot; (ASCII), followed by four digits(ASCII) and a carriage return (ASCII 13). The baud rate is 9600, 8 bits, no parity with one stop bit.&#xA;What I get from the device is as follows: (sonarSerial.read() while sonarSerial.available())&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;43&#xA;192&#xA;6&#xA;6&#xA;179&#xA;89&#xA;30&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I have to get to the information? Or is my sensor just retuning garbage? &#xA;Please see the code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define pin1 3&#xA;#define pin2 5 //pwm&#xA;#define pin3 6 //analog&#xA;#define pin4 10 //RX for sonar, TX for arduino&#xA;#define pin5 11 //TX for sonar, RX for arduino&#xA;&#xA;SoftwareSerial sonarPort(pin5,pin4);&#xA;&#xA;void setup(){&#xA;   Serial.begin (9600); &#xA;   pinMode(pin1, OUTPUT);&#xA;&#xA;   pinMode(pin4, OUTPUT);&#xA;   pinMode(pin5, INPUT);&#xA;   sonarPort.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  digitalWrite(pin1, HIGH);&#xA;&#xA;  digitalWrite(pin4, LOW);&#xA;  digitalWrite(pin4, HIGH);&#xA;  delayMicroseconds(20);&#xA;  digitalWrite(pin4, LOW);  &#xA;&#xA;  long pulse = pulseIn(pin2, HIGH)/58;&#xA;  Serial.print(&quot;PM Result: &quot;);&#xA;  Serial.println(pulse);  &#xA;&#xA;  String buffer = &quot;&quot;;&#xA;  sonarPort.listen();&#xA;  while(sonarPort.available() &amp;gt; 0){&#xA;      int inByte = sonarPort.read();&#xA;      buffer += inByte; buffer += &quot; &quot;;&#xA;      if(!sonarPort.available()){  &#xA;          Serial.print(&quot;Serial result: &quot;); &#xA;          Serial.println(buffer);&#xA;      }&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6646" LastEditorUserId="6646" LastEditDate="2015-01-13T09:13:55.567" LastActivityDate="2015-01-13T09:17:17.727" Title="Decoding a RS232 message in Arduino" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7977" PostTypeId="1" AcceptedAnswerId="7981" CreationDate="2015-01-12T12:08:48.483" Score="0" ViewCount="1636" Body="&lt;p&gt;I was trying to reset my Arduino Yun (WLAN button pressed for more than 30 seconds), but it just kept on blinking for about 10 minutes. Then I finally got impatient and restarted the Yun. After the restart, there was no WLAN (blue) or USB (white) LED blinking or glowing anymore. I am unable to connect through the Wifi network, the Yun does not create it's own Wifi network and unfortunately when connected via Ethernet, I can still not navigate to arduino.local or 192.168.240.1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have a feeling that somehow only the AVR is still functioning (because I can still upload sketches) and nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have updated the firmware to the latest version (OpenWrt-Yun 1.5.3). Is there a way to connect or reset, if the Ethernet does not work? Can I upload a sketch to check in the console if the Linino interface still functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="6670" LastActivityDate="2015-02-09T05:45:21.653" Title="Unable to connect to Linux Environment (Linino AR9331 Interface) in Arduino Yun" Tags="|arduino-yun|ethernet|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7978" PostTypeId="2" ParentId="7976" CreationDate="2015-01-12T12:19:03.287" Score="0" Body="&lt;p&gt;In the bitstream of your ASCII data the pattern for &quot;R&quot; (01010010b) does never occur.&lt;br&gt;&#xA;So obviously something is wrong in your system and/or setup.&#xA;Have you already considered the information given here &lt;a href=&quot;http://www.maxbotix.com/articles/034.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.maxbotix.com/articles/034.htm&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would connect the sensor to a PC to check whether it's working correctly using a standard terminal software.&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2015-01-12T12:19:03.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="7979" PostTypeId="1" AcceptedAnswerId="7982" CreationDate="2015-01-12T14:57:07.483" Score="1" ViewCount="469" Body="&lt;p&gt;I made project using atmel-328p. I want to run it over a year. I am using power_down mode &amp;amp; 5500 mAh li-ion battery still battery discharges in 1 day. I am using standard code as explain on arduino site.&#xA;code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String uniqueid;&#xA;char value;&#xA;volatile int NbTopsFan; //measuring the rising edges of the signal&#xA;uint32_t Calc;                               &#xA;int hallsensor = 2;    //The pin location of the sensor&#xA;int power = 4;&#xA;// ph sensor&#xA;define SensorPin 0          //pH meter Analog output to Arduino Analog Input 0&#xA;define Offset 0.00            //deviation compensate&#xA;unsigned long int avgValue;    //Store the average value of the sensor feedback&#xA;// temp sensor&#xA;OneWire  ds(8);     &#xA;byte i;&#xA;byte present = 0;&#xA;byte data[12];&#xA;byte addr[8];&#xA;int HighByte, LowByte, SignBit, Whole, Fract, TReading, Tc_100, FWhole;&#xA;&#xA;int wakePin = 3;                 // pin used for waking up&#xA;int sleepStatus = 0;             // variable to store a request for sleep&#xA;int countsleep = 0;                   // counter&#xA;&#xA;void wakeUpNow()        // here the interrupt is handled after wakeup&#xA;{// execute code here after wake-up before returning to the loop() function&#xA; }&#xA;void rpm ()     //This is the function that the interupt calls &#xA;{ &#xA; NbTopsFan++;  //This function measures the rising and falling edge of the &#xA;//hall effect sensors signal&#xA;} &#xA;void setup()&#xA;{&#xA; pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input&#xA;Serial.begin(9600); //This is the setup function where the serial port is &#xA;pinMode(power, OUTPUT);&#xA;//initialised,&#xA; attachInterrupt(0, rpm, RISING); //and the interrupt is attached&#xA;//initialised,&#xA;  //and the interrupt is attached&#xA;// temp sensor pin 8&#xA;        if ( !ds.search(addr)) &#xA;        {&#xA;           //       Serial.println(&quot;temp sensor is not connected&quot;);&#xA;        delay(1000);&#xA;        ds.reset_search();&#xA;        return;&#xA;        }&#xA;        if ( OneWire::crc8( addr, 7) != addr[7]) &#xA;        {&#xA;       //      Serial.println(&quot;CRC not valid!&quot;);&#xA;       delay(1000);&#xA;       return;&#xA;        }     &#xA;pinMode(wakePin, INPUT);&#xA;&#xA;  attachInterrupt(1, wakeUpNow, LOW); // use interrupt 1 (pin 3) and run function&#xA;&#xA;}&#xA;&#xA;void sleepNow()         // here we put the arduino to sleep&#xA;{&#xA;  countsleep = 0;&#xA;ADCSRA = 0;  &#xA;&#xA;   set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here&#xA;&#xA;    sleep_enable();          // enables the sleep bit in the mcucr register&#xA;                             // so sleep is possible. just a safety pin&#xA;  // turn off brown-out enable in software&#xA;  MCUCR = bit (BODS) | bit (BODSE);  // turn on brown-out enable select&#xA;  MCUCR = bit (BODS);        // this must be done within 4 clock cycles of above                          &#xA;&#xA; sleep_cpu ();  &#xA;&#xA;    attachInterrupt(1,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function&#xA;                                       // wakeUpNow when pin 2 gets LOW&#xA;&#xA;    sleep_mode();            // here the device is actually put to sleep!!&#xA;                             // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP&#xA;&#xA;    sleep_disable();         // first thing after waking from sleep:&#xA;                             // disable sleep...&#xA;    detachInterrupt(1);      // disables interrupt 0 on pin 2 so the&#xA;                             // wakeUpNow code will not be executed&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  countsleep++;&#xA;  delay(1000);                           // waits for a second&#xA;// compute the serial input&#xA;  if (Serial.available()) &#xA;  {&#xA;    String content = &quot;&quot;;&#xA;    char character;&#xA;// to read serial data coming&#xA;        while(Serial.available()&amp;gt;0) &#xA;          {&#xA;              character = Serial.read();&#xA;              content.concat(character);&#xA;          }&#xA;      String uniqueidread = content.substring(0,16);&#xA;      String parameter = content.substring(16,17);&#xA;      String checkuuid = content.substring(0,3);&#xA;      String putinsleep = content.substring(0,5);&#xA;       if (uniqueidread == uniqueid &amp;amp;&amp;amp; parameter == &quot;5&quot;)&#xA;{         //    Serial.flush();&#xA;digitalWrite(power,HIGH);&#xA; NbTopsFan = 0;      //Set NbTops to 0 ready for calculations&#xA; sei();            //Enables interrupts&#xA; delay (1000);      //Wait 1 second&#xA; cli();            //Disable interrupts&#xA; Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate &#xA;&#xA;  digitalWrite(power,LOW);&#xA;          getTemp();&#xA;          delay(1000);&#xA;          getTemp();&#xA;          //   printTemp();&#xA;      Serial.print(&quot;Temp is: &quot;);&#xA;           if (SignBit) &#xA;           {  &#xA;                Serial.print(&quot; - &quot;);&#xA;           }&#xA;           if( Whole == 0)&#xA;           {&#xA;              Serial.print(&quot;temp sensor is not connected&quot;);&#xA;           }&#xA;           else&#xA;           {&#xA;              Serial.print(Whole);&#xA;              Serial.print(&quot; C / &quot;);&#xA;              Serial.print(FWhole);&#xA;              Serial.print(&quot; F&quot;);&#xA;            }&#xA;              Serial.print(&quot;, Current Reading = &quot;);&#xA;     Serial.print (Calc, DEC); //Prints the number calculated above&#xA;            Serial.print(&quot; L/hour&quot;);&#xA;   phvalue();&#xA;            Serial.println(&quot;S=m&quot;);&#xA;              delay(100);&#xA;              sleepNow(); &#xA;}&#xA;&#xA;         if ( content == &quot;sleep&quot;) &#xA;         {&#xA;          Serial.println(&quot;S=m&quot;);&#xA;          delay(100);     // this delay is needed, the sleep &#xA;          sleepNow();     // sleep function called here&#xA;         }&#xA;}&#xA;&#xA;  if (countsleep &amp;gt;= 10) &#xA;  {&#xA;      Serial.println(&quot;T=m&quot;);&#xA;      delay(100);     // this delay is needed, the sleep &#xA;                      //function will provoke a Serial error otherwise!!&#xA;      sleepNow();     // sleep function called here&#xA;  }&#xA;}&#xA;      void getTemp() &#xA;          {&#xA;              int foo, bar;&#xA;&#xA;              ds.reset();&#xA;              ds.select(addr);&#xA;              ds.write(0x44,1);&#xA;&#xA;              present = ds.reset();&#xA;              ds.select(addr);    &#xA;              ds.write(0xBE);&#xA;&#xA;              for ( i = 0; i &amp;lt; 9; i++) {&#xA;                data[i] = ds.read();&#xA;              }&#xA;&#xA;              LowByte = data[0];&#xA;              HighByte = data[1];&#xA;              TReading = (HighByte &amp;lt;&amp;lt; 8) + LowByte;&#xA;              SignBit = TReading &amp;amp; 0x8000;  // test most sig bit&#xA;&#xA;              if (SignBit) {&#xA;                TReading = -TReading;&#xA;              }&#xA;              Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25&#xA;              Whole = Tc_100 / 100;          // separate off the whole and fractional portions&#xA;              Fract = Tc_100 % 100;&#xA;              if (Fract &amp;gt; 49) {&#xA;                if (SignBit) {&#xA;                  --Whole;&#xA;                } else {&#xA;                  ++Whole;&#xA;                }&#xA;              }&#xA;&#xA;              if (SignBit) {&#xA;                bar = -1;&#xA;              } else {&#xA;                bar = 1;&#xA;              }&#xA;              foo = ((Whole * bar) * 18);      // celsius to fahrenheit conversion section&#xA;              FWhole = (((Whole * bar) * 18) / 10) + 32;&#xA;              if ((foo % 10) &amp;gt; 4) {            // round up if needed&#xA;                   ++FWhole;&#xA;              }&#xA;            }&#xA;void printTemp(void) &#xA;{&#xA;         Serial.println(&quot;&quot;);&#xA;         Serial.print(&quot;Temp is: &quot;);&#xA;         if (SignBit) &#xA;         {  &#xA;              Serial.print(&quot; - &quot;);&#xA;         }&#xA;         Serial.print(Whole);&#xA;         Serial.print(&quot; C / &quot;);&#xA;         Serial.print(FWhole);&#xA;         Serial.print(&quot; F&quot;);&#xA;}&#xA;void phvalue()&#xA;{&#xA;    int buf[10];                //buffer for read analog&#xA;    for(int i=0;i&amp;lt;10;i++)       //Get 10 sample value from the sensor for smooth the value&#xA;    { &#xA;      buf[i]=analogRead(SensorPin);&#xA;      delay(10);&#xA;    }&#xA;    for(int i=0;i&amp;lt;9;i++)        //sort the analog from small to large&#xA;    {&#xA;      for(int j=i+1;j&amp;lt;10;j++)&#xA;      {&#xA;        if(buf[i]&amp;gt;buf[j])&#xA;        {&#xA;          int temp=buf[i];&#xA;          buf[i]=buf[j];&#xA;          buf[j]=temp;&#xA;        }&#xA;      }&#xA;    }&#xA;    avgValue=0;&#xA;    for(int i=2;i&amp;lt;8;i++)                      //take the average value of 6 center sample&#xA;      avgValue+=buf[i];&#xA;    float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt&#xA;    phValue=3.5*phValue+Offset;                      //convert the millivolt into pH value&#xA;    Serial.print(&quot; pH:&quot;);  &#xA;    Serial.print(phValue,2);&#xA;    Serial.print(&quot; &quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hrn0t.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6674" LastEditorUserId="2881" LastEditDate="2015-01-12T20:25:02.650" LastActivityDate="2015-01-13T15:52:37.147" Title="Power consumption issue. I made project using atmel-328p" Tags="|power|interrupt|atmega328|sleep|" AnswerCount="1" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7980" PostTypeId="1" CreationDate="2015-01-12T13:58:47.220" Score="1" ViewCount="900" Body="&lt;p&gt;I am using Arduino uno board with Atmega 328 for i2c.&#xA;The ic is not showing any clock signal on its SCL line on oscilloscope, The same code when used with different new atmega 328, and same code. It is showing a good clock signal on oscilloscope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ic whose i2c is not working can be still programmed and can be used for other purposes like serial communication , adc etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is there any way by which i can confirm and surely say that i2c of my atmega 328 is fried up. And what can be the possible methods by which it can be fried up.&lt;/p&gt;&#xA;" OwnerDisplayName="Aniket Bhushan" LastActivityDate="2015-08-05T18:26:21.593" Title="i2c of Atmega 328 on arduino uno not working" Tags="|i2c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7981" PostTypeId="2" ParentId="7977" CreationDate="2015-01-12T16:58:00.953" Score="0" Body="&lt;p&gt;Try uploading YunSerialTerminal example, opening the serial monitor and pressing the YUN RST button. You should see the linux side starting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it starts but it looks somehow bricked, you could try following the &lt;a href=&quot;http://arduino.cc/en/Tutorial/YunUBootReflash&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/YunUBootReflash&lt;/a&gt; tutorial.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-01-12T16:58:00.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7982" PostTypeId="2" ParentId="7979" CreationDate="2015-01-12T17:17:18.510" Score="4" Body="&lt;p&gt;You need to first check the individual current consumption of all elements: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pH sensor, &lt;/li&gt;&#xA;&lt;li&gt;temp sensor, &lt;/li&gt;&#xA;&lt;li&gt;water flow sensor&lt;/li&gt;&#xA;&lt;li&gt;xbee. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since many of these just have an output pin in addition to +V &amp;amp; GND, this means those have a permanent current consumption that, overall, may possibly drain your battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should then check the datasheets for all these components and see the minimum current consumption (and conditions for this consumption to be achieved).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the total minimum current for these components is too high for your system, then you can possibly:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use an available ATmel digital output pin to power them (and unpower them just before switching the ATmel to low power mode); that's possible only if you stay within current limitations of the MCU (there are current limitation per pin, 20mA IIRC, and total current for the whole MCU)&lt;/li&gt;&#xA;&lt;li&gt;if current consumption is above ATmel limits then you can still use the method above but add a MOSFET in-between so that you limit ATmel current consumption&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I strongly advise you &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;this link from Nick Gammon&lt;/a&gt;, which is comprehensive and complete.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="46" LastEditDate="2015-01-13T15:52:37.147" LastActivityDate="2015-01-13T15:52:37.147" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="7983" PostTypeId="2" ParentId="7958" CreationDate="2015-01-12T17:51:22.753" Score="0" Body="&lt;p&gt;Simple Answer: Don't think you can&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long Answer: Dont think you can, because, unlike an OS like windows, mac, linux, etc. The arduino just tales all the files. You could save those two files and format it as FAT16 though, then add the 2 files back on the sd and there you go.&lt;/p&gt;&#xA;" OwnerUserId="4509" LastActivityDate="2015-01-12T17:51:22.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7984" PostTypeId="2" ParentId="7936" CreationDate="2015-01-12T17:54:23.353" Score="0" Body="&lt;p&gt;Yes, as long as the board is 5V&lt;/p&gt;&#xA;" OwnerUserId="4509" LastActivityDate="2015-01-12T17:54:23.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7985" PostTypeId="1" CreationDate="2015-01-12T19:39:36.457" Score="5" ViewCount="2836" Body="&lt;p&gt;I wanted to check how much memory (RAM) is used by an &quot;empty&quot; sketch. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freeRam() &#xA;{&#xA;  extern int __heap_start, *__brkval; &#xA;  int v; &#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(freeRam());&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My result was that I have 1839 bytes of free RAM. I have an Arduino UNO, so there are 2048 bytes of RAM in total. Which means that 209 bytes are already taken. Wait, 209 bytes?! I started thinking and figured out that the Serial buffer must take some space. I've opened HardwareSerial.h and found this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if (RAMEND &amp;lt; 1000)&#xA;  #define SERIAL_BUFFER_SIZE 16&#xA;#else&#xA;  #define SERIAL_BUFFER_SIZE 64&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've changed SERIAL_BUFFER_SIZE to 16 to see what will happen. (I've tried decreasing it to 1, but then the serial communication didn't work properly and I wasn't able to display the amount of free RAM). After this modification my result is 1935. So now &quot;only&quot; 113 bytes are taken. But what is taking this memory? HardwareSerial has 2 buffers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ring_buffer&#xA;{&#xA;  unsigned char buffer[SERIAL_BUFFER_SIZE];&#xA;  volatile unsigned int head;&#xA;  volatile unsigned int tail;&#xA;};&#xA;&#xA;ring_buffer rx_buffer = { { 0 }, 0, 0};&#xA;ring_buffer tx_buffer = { { 0 }, 0, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when the SERIAL_BUFFER_SIZE is 16 they take exactly 40 bytes. What is taking the remaining bytes (113-40= &lt;strong&gt;73 bytes&lt;/strong&gt;)? I'm aware that stack frames take some memory - calling main() which calls setup() whichs calls freeRam() probably take a few bytes, but 73 still seems too much.&lt;/p&gt;&#xA;" OwnerUserId="5130" LastEditorUserId="10794" LastEditDate="2015-07-16T22:56:34.567" LastActivityDate="2015-07-16T22:56:34.567" Title="What's taking up so much RAM in an almost empty sketch?" Tags="|arduino-uno|serial|sketch|sram|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7986" PostTypeId="2" ParentId="7921" CreationDate="2015-01-12T20:56:29.753" Score="2" Body="&lt;p&gt;Accurate measurement of resistance requires a precise current source (&lt;a href=&quot;http://www.digikey.com/product-search/en/integrated-circuits-ics/pmic-current-regulation-management/2556448?k=current%20source&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com/product-search/en/integrated-circuits-ics/pmic-current-regulation-management/2556448?k=current%20source&lt;/a&gt;).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ohm's law, V=IR or  R=V/I states that for linear components, the value of resistance in the circuit can be estimated by the ratio of the applied voltage divided by the current.  With a simple voltage divider, as the resistance of the sensor changes so does the current in the circuit.  So measuring the voltage at the junction does not necessarily provide an accurate indication of the current in the circuit.  Both the imposed voltage and current should be controlled to obtain accurate measurements.&lt;/p&gt;&#xA;" OwnerUserId="6678" LastActivityDate="2015-01-12T20:56:29.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7988" PostTypeId="2" ParentId="1323" CreationDate="2015-01-12T21:32:54.230" Score="1" Body="&lt;p&gt;RFID protocols require either passive or active tags.  Depending on which you use, either the tag or reader regularly transmits pulses.  Check www.rfidreader.com for more info.  &lt;a href=&quot;https://www.rfidjournal.com&quot; rel=&quot;nofollow&quot;&gt;https://www.rfidjournal.com&lt;/a&gt; provides valuable resources as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many companies invest heavily in developing RFID technology.  You would be well advised not to reinvent wheels without reeeeally deeeeeep pockets.&lt;/p&gt;&#xA;" OwnerUserId="6678" LastActivityDate="2015-01-12T21:32:54.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7989" PostTypeId="2" ParentId="4530" CreationDate="2015-01-12T21:37:25.997" Score="2" Body="&lt;p&gt;Whether or not the serial data becomes available really does not matter.  If you flush the port before every read rather than consuming the data, let 'er rip.  If you are using interrupts, toggle interrupts on the serial pin.&lt;/p&gt;&#xA;" OwnerUserId="6678" LastActivityDate="2015-01-12T21:37:25.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7990" PostTypeId="2" ParentId="7985" CreationDate="2015-01-12T21:56:41.340" Score="11" Body="&lt;p&gt;First off, a sketch that uses &lt;code&gt;Serial&lt;/code&gt; &lt;strong&gt;cannot really be considered an empty sketch&lt;/strong&gt; as &lt;code&gt;Serial&lt;/code&gt; drags along a lot of function definitions, at least one &lt;code&gt;Serial&lt;/code&gt; class instance (more on Arduino Mega, for instance), plus probably some more global variables... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sizeof Serial&lt;/code&gt; may be interesting to display as &lt;code&gt;Serial&lt;/code&gt; is not limited to the TX and RX buffers, as you seem to believe. Its class also has a couple of &lt;strong&gt;additional data members&lt;/strong&gt; on its own, plus members inherited from its superclasses, &lt;code&gt;Stream&lt;/code&gt; and &lt;code&gt;Print&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, the Arduino IDE comes with the various &quot;utilities&quot; which you normally can't get rid of, like the &lt;strong&gt;millisecond timer&lt;/strong&gt; that uses at least 9 bytes (see reference in &lt;code&gt;wiring.c&lt;/code&gt; file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in the end, even an empty sketch (even without &lt;code&gt;Serial&lt;/code&gt;) takes some SRAM space for global variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think there is some way, with &lt;code&gt;avr-size&lt;/code&gt;, to check out, with fine details, the size of data (not accounting for the runtime stack) after the sketch has been fully built.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino IDE already displays some of this static memory information (at the end of &quot;verification&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on my IDE (1.5.8) for Arduino UNO, &lt;strong&gt;a really empty sketch, once compiled is mentioned to use 9 bytes of SRAM&lt;/strong&gt;. Actually those 9 bytes are for 3 global variables, used by the millisecond timer. This number, of course, does not account for runtime memory usage, in particular the stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;strong&gt;just adding &lt;code&gt;Serial.begin(9600);&lt;/code&gt; makes it use 182 bytes&lt;/strong&gt; (ie 173 more bytes than an empty sketch). So you get the culprit.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2015-01-13T21:11:21.760" LastActivityDate="2015-01-13T21:11:21.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7991" PostTypeId="1" AcceptedAnswerId="8001" CreationDate="2015-01-12T22:04:41.743" Score="2" ViewCount="5175" Body="&lt;p&gt;My project involves Android (Samsung Galaxy 2) to Arduino (Uno) communication via HC-05.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HC-05 is connected to Arduino on pins 10,11 using SoftwareSerial lib.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got this setup running for a while and was satisfied by the outcome - my bi-directional communication worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a change to the communication protocol and now messages sent from Android to Arduino get corrupted. It happens under particular circumstances - when Arduino writes (streams) packets of data to Android and, at the same time, monitors the input from Android for a particular message which signals the end of communication. This message, when read from SoftwareSerial buffer, gets corrupted. This corruption is not consistent - it corrupts the packet in (seemingly) random way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already run many tests and am pretty sure that this message is not corrupted on the Android side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there anything about HC-05 or SoftwareSerial lib which prevents&#xA;simultaneous bi-directional communication? &lt;/li&gt;&#xA;&lt;li&gt;Can it be that input/output buffers interfere in some way?&lt;/li&gt;&#xA;&lt;li&gt;How can I achieve reliable communication using the aforementioned HW and comm scheme?    &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;P.S. I got pretty much code and am not sure what parts of it might be relevant to this issue. Will provide relevant parts per your request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx&lt;/p&gt;&#xA;" OwnerUserId="6685" OwnerDisplayName="Vasiliy" LastActivityDate="2015-07-19T11:57:13.817" Title="Android &lt;-&gt; HC-05 &lt;-&gt; Arduino communication issue" Tags="|bluetooth|android|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7992" PostTypeId="2" ParentId="7991" CreationDate="2015-01-12T22:14:06.200" Score="0" Body="&lt;p&gt;Software serial ports are a hack and this is the result - random corruption, missed bytes, etc. The reason is that very precise timing is needed for both receive and transmit and it is very difficult to achieve this with the CPU, especially if you want to simultaneously receive and transmit. The problem is that the CPU has to either read the pin or update the pin at exactly the right moment, and the CPU can't do more than one thing at the same time. You can use interrupts, but it is still possible for the TX and the RX to conflict, and there is nothing you can do about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to either never run RX and TX at the same time, use a different serial protocol where this is not an issue (e.g. I2C), or use a hardware serial port. I would suggest using an Atmel XMEGA microcontroller - you can get these with 6 or more independent hardware serial ports.&lt;/p&gt;&#xA;" OwnerUserId="3832" OwnerDisplayName="alex.forencich" LastActivityDate="2015-01-12T22:14:06.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="7993" PostTypeId="2" ParentId="7962" CreationDate="2015-01-13T00:26:14.820" Score="1" Body="&lt;p&gt;Usually, Arduino gives you the minimal board and sends you on your way. Reading over the instructions, I think they mean a cable that would have come with the IR sensor. That three-tone cord you see in the pictures are actually just three wires. You connect them as described if they came with the sensors. More likely, if they did not, you can use your own wires to connect these. Just be sure that you understand which is the ground (GND), power (+5V or some other +V), and signal. Usually, ground is denoted by the darkest color: black or brown; power is usually red, and signals can be any light color. USUALLY (READ about your device before you plug it in) ground and power are side-by-side for IR sensors, and signal is on the outside. Take a few minutes to Google up your device before plugging it in if you don't have documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck!&lt;/p&gt;&#xA;" OwnerUserId="6596" LastActivityDate="2015-01-13T00:26:14.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7994" PostTypeId="1" CreationDate="2015-01-12T23:33:34.833" Score="2" ViewCount="4238" Body="&lt;p&gt;I want to run an Arduino autonomously - but although I apply a watchdog sometimes the systems hangs and can only be restarted by physically interrupting the power-supply (or hitting reset). So I need an external source to do that either after x hrs or based on a condition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using another Arduino with a MOSFET or relay I am asking myself if this couldn't be done smarter with a pure electronic component like a timer or a capacitor. I could set a pin of the Arduino on high while it is active and let this charge a capacitor or something similar - if the time/energy exceeds a certain amount (because it hangs) this would connect the reset-pin of the Arduino to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how this could be achieved and what component should be used? &lt;/p&gt;&#xA;" OwnerUserId="6888" OwnerDisplayName="Stephan Noller" LastEditorUserId="46" LastEditDate="2015-01-13T15:55:31.930" LastActivityDate="2016-03-09T11:55:03.927" Title="Resetting an Arduino with a timer" Tags="|reset|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="7995" PostTypeId="2" ParentId="7994" CreationDate="2015-01-13T01:42:32.560" Score="4" Body="&lt;p&gt;The following 555 circuit will produce a 170 ms low-going pulse every 24.2 hours.  You can adjust the values of the components using &lt;a href=&quot;http://www.csgnetwork.com/ne555timer2calc.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this calculator&lt;/a&gt; if you want different timing parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OQj6h.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the reset line of a microcontroller is configured for open-drain (meaning you can connect several inputs to it, which is a good thing since we are taking advantage of that), we need to drive it with a open-drain output.  That is what the buffer on the bottom of the circuit is for, to convert the push-pull output of the 555 to open-drain.  A typical buffer is one section of a 7407.&lt;/p&gt;&#xA;" OwnerUserId="396" LastEditorUserId="396" LastEditDate="2015-01-13T05:48:11.403" LastActivityDate="2015-01-13T05:48:11.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7997" PostTypeId="2" ParentId="7950" CreationDate="2015-01-13T07:33:58.837" Score="0" Body="&lt;p&gt;First of all, use 3.3&amp;nbsp;V. You need a logic-level converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have to understand SPI is not the main protocol used by SD cards, and that Arduino should use SDSC to be sure, as some libraries are SDSC only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you may have a hardware problem (from &lt;em&gt;&lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=31&amp;amp;t=8738&quot; rel=&quot;nofollow&quot;&gt;FAT32/SDHC library for Wave and other shields&lt;/a&gt;&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SDHC cards have a 3.3&amp;nbsp;V bus so most Adruino shields, like the Wave Shield, use a resistor voltage divider to shift bus levels from 5&amp;nbsp;V to 3.3&amp;nbsp;V. These voltage dividers can not meet the 10&amp;nbsp;ns rise time for most SDHC cards.&quot; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also using an external power source &lt;em&gt;may&lt;/em&gt; solve your trouble.&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="510" LastEditDate="2015-02-06T22:01:39.750" LastActivityDate="2015-02-06T22:01:39.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="7998" PostTypeId="2" ParentId="7955" CreationDate="2015-01-13T07:38:06.420" Score="1" Body="&lt;p&gt;I would bet the problem relies on&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (counter&amp;gt;first)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As seems like you never reset counter, there might be weird things going on&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="643" LastEditDate="2015-04-16T03:00:38.937" LastActivityDate="2015-04-16T03:00:38.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="7999" PostTypeId="2" ParentId="5180" CreationDate="2015-01-13T07:44:22.990" Score="1" Body="&lt;p&gt;Yes should be really easy to implement, as it work like almost all i2c sensor; this manual as also some code example, the chip address, and finally the registry address; that is all you need.&#xA;&lt;a href=&quot;http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-01-13T07:44:22.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8000" PostTypeId="2" ParentId="7994" CreationDate="2015-01-13T08:39:43.560" Score="4" Body="&lt;p&gt;Here is the circuit I use which depends on a heartbeat from the arduino and resets the arduino if 8 pulses are missed and also enables the arduino code to know that an external watchdog reset occured&#xA;&lt;img src=&quot;https://i.stack.imgur.com/CGfUo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;and the Arduino code which can be incorporated into your sketch&#xA;&#xA;//Watchdog&#xA;#define ResetDetect 8       // watchdog detect pin, HIGH if a watchdog reset has occured&#xA;#define heartbeat 9         // heartbeat pin&#xA;int pulseState = LOW;       // pulseState used to set the heartbeat pin&#xA;long lastbeat = 0;          // will store last time the heartbeat pin was updated&#xA;long HeartBeatFreq = 500;   // interval at which to blink (milliseconds)&#xA;boolean ResetHappened;      // Set to true if a watchdog reset has occurred&#xA;&#xA;void setup(){&#xA;  pinMode(ResetDetect, INPUT);    // set Watchdog Reset sensing pin as input&#xA;  digitalWrite(ResetDetect, HIGH);// and turn on pullup  &#xA;  pinMode(heartbeat, OUTPUT);     // set the heartbeat pin as output:&#xA;&#xA;    // Check if Restarting after Watchdog Reset&#xA;    // NB must come before heartbeat resets external counter&#xA;    int ResetSet = digitalRead(ResetDetect);&#xA;    if (ResetSet == HIGH){&#xA;      ResetHappened = true;&#xA;    }&#xA;    else {&#xA;      ResetHappened = false;&#xA;    }&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  // Heartbeat resets external watchdog when pin goes high&#xA;  if ((long)( millis() - (lastbeat + HeartBeatFreq)) &amp;gt;= 0) {    &#xA;    lastbeat = millis();    &#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (pulseState == LOW)&#xA;      pulseState = HIGH;&#xA;    else&#xA;      pulseState = LOW;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(heartbeat, pulseState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there are long running sections of code the 'heartbeat' could be put into a function and that function called in the appropriate places to avoid unintended timeouts/resets&lt;/p&gt;&#xA;" OwnerUserId="521" LastEditorUserId="521" LastEditDate="2015-01-13T09:02:57.177" LastActivityDate="2015-01-13T09:02:57.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8001" PostTypeId="2" ParentId="7991" CreationDate="2015-01-13T08:45:24.927" Score="3" Body="&lt;p&gt;As mentioned by @alex.forencich, SoftwareSerial is not designed to support simultaneous bi-directional communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a link to &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt; library on Arduino site, and this lib seems to work properly in my setup. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To convert from SoftwareSerial to AltSoftSerial you need to change the pins that HC-05 is connected to (on Arduino Uno these are pins 8,9), and to make this minor change in the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;//SoftwareSerial swSerial(10, 11);&#xA;&#xA;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;AltSoftSerial swSerial;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6685" LastActivityDate="2015-01-13T08:45:24.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8002" PostTypeId="2" ParentId="7976" CreationDate="2015-01-13T09:17:17.727" Score="1" Body="&lt;p&gt;I contacted MaxBotix with the problem and for my surprise their technical support is really great:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino is set up to natively read TTL serial data.The MB7066 outputs its serial data in the RS232 format. Do not worry; this problem can easily be fixed. You can use an inverter such as the MAX232. You can also follow the following tutorial to make your own &lt;a href=&quot;https://github.com/simonmonk/raspirobotboard/wiki/Rangefinder-Adapter&quot; rel=&quot;nofollow&quot;&gt;https://github.com/simonmonk/raspirobotboard/wiki/Rangefinder-Adapter&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Another option would be to test using this code section SoftwareSerial&#xA;  sonarSerial(rxPin, txPin, true); //define serial port for recieving&#xA;  data, output from maxSonar is inverted requiring true to be set.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6646" LastActivityDate="2015-01-13T09:17:17.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8004" PostTypeId="1" CreationDate="2015-01-13T11:30:52.803" Score="0" ViewCount="10585" Body="&lt;p&gt;I have two non constant char arrays. One is &quot;buff&quot; and other is &quot;buffa&quot;. I get values in buffa via rf transmitter of other Arduino and I want to append those data to the data inside of buff. Then I will send all data to other Arduino. So I don't want to send two different char arrays. I want to send them all at once as just one array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I TRIED SPRINTF BUT IT DOESNT WORK.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffa[144]; &#xA;    char buff[1000];&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;  uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;&#xA;  sprintf(buff,&quot;&amp;lt;status&amp;gt;\n&quot;);    &#xA;&#xA;&#xA;&#xA;    if (vw_get_message(buf, &amp;amp;buflen)) { // check to see if anything has been received&#xA;      int i;&#xA;      for (i = 0; i &amp;lt; buflen; i++) {&#xA;        buffa[i] = (char) buf[i];  // the received data is stored in buffer&#xA;&#xA;      }&#xA;    }&#xA;&#xA;&#xA;  distance1 = getDistance(initPin1, echoPin1);&#xA;  sendData(3, distance1);&#xA;&#xA;  sprintf(buff, &quot;%s&quot;, buffa);&#xA;&#xA;&#xA;&#xA;&#xA;delay(5000);&#xA; const char *msg0 = buff;&#xA;&#xA;&#xA; vw_send((uint8_t *)msg0, strlen(msg0)); // Send control character &#xA; vw_wait_tx();&#xA;&#xA; Serial.print(msg0);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6688" LastActivityDate="2015-01-13T23:26:30.693" Title="Concatenate two non constant char arrays in Arduino" Tags="|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8008" PostTypeId="1" CreationDate="2015-01-13T21:41:20.723" Score="0" ViewCount="467" Body="&lt;p&gt;Two goals:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make an LED turn on when a person touches two conductive pads (e.g. two square of aluminum foil)&lt;/li&gt;&#xA;&lt;li&gt;Make the RGB LED change color depending on how hard the pads are squeezed. I will figure out the color algorithm later. For now I just need to be able to sense variable conductivity/capacitance/current (one of those?).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino LilyPad. I know this can be done because I've seen it before (just don't remember the code or circuit). Example image:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yo5QN.jpg&quot; alt=&quot;Example image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the human body is conductive, so I'm not quite sure why the LED won't go on when I contact the conductive pads. My only hypothesis is that the resistance is too high, but that must mean &lt;em&gt;some&lt;/em&gt; current is going through, no?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6698" LastActivityDate="2015-01-14T09:40:14.573" Title="Variable current switch by human touch" Tags="|wires|potentiometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8009" PostTypeId="1" CreationDate="2015-01-13T22:08:02.907" Score="1" ViewCount="2529" Body="&lt;p&gt;This topic have been covered in various places, but I still think it hasn't been thoroughly explained anywhere. Doing google search on connecting Arduino to Raspberry Pi via i2c gives for example, this &lt;a href=&quot;http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/&quot; rel=&quot;nofollow&quot;&gt;page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While apparently this should work, there is a factual error there: on arduino side, pins used for i2c do have internal pull ups, and they are activated by &lt;code&gt;Wire&lt;/code&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digging &lt;a href=&quot;http://quick2wire.com/pi-and-arduino-linked-via-i2c/&quot; rel=&quot;nofollow&quot;&gt;further&lt;/a&gt;, I've found following information:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, it turns out that these are weak (high-resistance) pull-ups;&#xA;  the Pi has strong pull-ups which dominate those on the Arduino, making&#xA;  direct connection safe.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What does safe mean? And how weaker are those pullups compared to raspberry pi ones?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's check:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;rpi i2c pullup: 1K8&lt;/li&gt;&#xA;&lt;li&gt;arduino i2c pullup: 20K-50K from datasheet (if I'm looking correctly, I'm using ATmega8), though the above page states 10K.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What can I make of those values? My (intuition rather than) basic knowledge hints me something along the lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the i2c is floating, it means the 5V is connected with 3.3V and there are only those pullups along the way, so:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;calculate voltage drop between 5 and 3.3: 1.7V.&lt;/li&gt;&#xA;&lt;li&gt;calculate voltage drop across rpi pullup proportionally to voltage drop across arduino pullup:&#xA;1800 / 30000 = 0.06, meaning 0.102V across rpi pullup and 1.598 across arduino pullup, so the actual pulled up voltage is gonna be 3.3V + 0.102V = 5V - 1.598V = 3.402V?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Though I'm pretty sure I'm doing some terrible math here and someone is gonna have good laugh:)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is not whether it's safe (as it's been proved), but rather &lt;em&gt;why&lt;/em&gt; is it safe considering the internet resources are inaccurate on this matter.&lt;/p&gt;&#xA;" OwnerUserId="5007" LastEditorUserId="5007" LastEditDate="2015-01-14T06:18:23.897" LastActivityDate="2015-01-14T12:12:43.470" Title="Arduino and Raspberry Pi - 5V/3.3V I2C" Tags="|i2c|voltage-level|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8010" PostTypeId="2" ParentId="7994" CreationDate="2015-01-13T22:25:56.463" Score="1" Body="&lt;p&gt;Why not use the in-ship watchdog timer ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found in the Atmel ATmega328 (used for example in the official Arduino Uno board) official datasheet some references :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can find on page #5 two blocks named &quot;Watchdog Timer&quot; and &quot;Watchdog Oscillator&quot; on the upper left corner. No need of additional circuits, soldering or any connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These blocks are bad documented on the Arduino official website but usable (I did it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some docs with code examples :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://sysmagazine.com/posts/189744/&quot; rel=&quot;nofollow&quot;&gt;http://sysmagazine.com/posts/189744/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://tushev.org/articles/arduino/item/46-arduino-and-watchdog-timer&quot; rel=&quot;nofollow&quot;&gt;https://tushev.org/articles/arduino/item/46-arduino-and-watchdog-timer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Regards&lt;/p&gt;&#xA;" OwnerUserId="675" LastActivityDate="2015-01-13T22:25:56.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8011" PostTypeId="2" ParentId="8008" CreationDate="2015-01-13T22:58:08.903" Score="1" Body="&lt;p&gt;I am going to make this answer as simple as I can, the body is not THAT conductive, you gotta use something like a touch sensor.&lt;/p&gt;&#xA;" OwnerUserId="4509" LastActivityDate="2015-01-13T22:58:08.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8012" PostTypeId="2" ParentId="8004" CreationDate="2015-01-13T23:26:30.693" Score="3" Body="&lt;p&gt;Assuming the data in buffa is a c-style string (i.e. null-terminated), replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(buff, &quot;%s&quot;, buffa);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strcat( buff, buffa );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6701" LastActivityDate="2015-01-13T23:26:30.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8015" PostTypeId="1" AcceptedAnswerId="8016" CreationDate="2015-01-14T02:03:17.680" Score="1" ViewCount="2661" Body="&lt;p&gt;I am unable to get a button on my arduino board to control a servo. I'd like the servo to rotate 90 degrees on button push, but it is unresponsive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a flaw in my code or is it wiring?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;  // servo library&#xA;&#xA;const int button1Pin = 2;  // pushbutton 1 pin&#xA;Servo servo1; // servo control object&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(button1Pin, INPUT);&#xA;  servo1.attach(9);&#xA;&#xA;  // Set servo 1 to output?      &#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  int button1State;&#xA;int position;&#xA;&#xA;button1State = digitalRead(button1Pin);&#xA;&#xA;&#xA;if (button1State == LOW);&#xA;{&#xA;  servo1.write(90);  // move servo&#xA;}&#xA;&#xA;}        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6705" LastActivityDate="2015-01-14T02:45:40.337" Title="Cannot control servo with button." Tags="|arduino-uno|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8016" PostTypeId="2" ParentId="8015" CreationDate="2015-01-14T02:45:40.337" Score="1" Body="&lt;p&gt;The problem is that &lt;code&gt;servo1.write(90)&lt;/code&gt; does not do what you think it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;servo.write(angle)&lt;/code&gt; tells the servo to go to that position, not to move by that many degrees. What you need is to set one angle when the button is not pressed, and a different angle when the button is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal hobby servos can move about 180 degrees. Where 0 is depends on how the servo horn is positioned. Which direction of rotation is positive depends on the manufacturer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;try something like this to set one position when the button is pressed and a different one when it is not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (button1State == LOW);{&#xA;    servo1.write(45);  // move servo&#xA;}&#xA;else {&#xA;    servo1.write(135);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-01-14T02:45:40.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8019" PostTypeId="2" ParentId="7951" CreationDate="2015-01-14T07:39:28.357" Score="1" Body="&lt;p&gt;here the problem is i am not receiving anything from server. My client disconnected from the server after sending the Upgrade headers. that's why in wire-shark i am not getting anything from server I think so.&#xA;here is code which do handshake with server.The problem is i am not receiving anything from server. My client disconnected from the server after sending the Upgrade headers. that's why in wire shark i am not getting anything from server I think so.&#xA;here is code which do handshake with server:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;bool WebSocketClient::analyzeRequest() {&#xA;    String temp;&#xA;    int bite;&#xA;    bool foundupgrade = false;&#xA;    unsigned long intkey[2];&#xA;    String serverKey;&#xA;    char keyStart[17];&#xA;    char b64Key[25];&#xA;    String key = &quot;------------------------&quot;;&#xA;    randomSeed(analogRead(0));&#xA;    for (int i=0; i&amp;lt;16; ++i) {&#xA;        keyStart[i] = (char)random(1, 256);&#xA;    }&#xA;    base64_encode(b64Key, keyStart, 16);&#xA;    for (int i=0; i&amp;lt;24; ++i) {&#xA;        key[i] = b64Key[i];&#xA;    }&#xA;    Serial.println(F(&quot;Sending websocket upgrade headers&quot;));&#xA;    socket_client-&gt;print(F(&quot;GET &quot;));&#xA;    socket_client-&gt;print(path);&#xA;    socket_client-&gt;print(F(&quot; HTTP/1.1\r\n&quot;));&#xA;    socket_client-&gt;print(F(&quot;Upgrade: websocket\r\n&quot;));&#xA;    socket_client-&gt;print(F(&quot;Connection: Upgrade\r\n&quot;));&#xA;    socket_client-&gt;print(F(&quot;Host: &quot;));&#xA;    socket_client-&gt;print(host);&#xA;    socket_client-&gt;print(CRLF); &#xA;    socket_client-&gt;print(F(&quot;Sec-WebSocket-Key: &quot;));&#xA;    socket_client-&gt;print(key);&#xA;    socket_client-&gt;print(CRLF);&#xA;    socket_client-&gt;print(F(&quot;Sec-WebSocket-Protocol: &quot;));&#xA;    socket_client-&gt;print(protocol);&#xA;    socket_client-&gt;print(CRLF);&#xA;    socket_client-&gt;print(F(&quot;Sec-WebSocket-Version: 13\r\n&quot;));&#xA;    socket_client-&gt;print(CRLF);&#xA;    Serial.println(F(&quot;Analyzing response headers&quot;));&#xA;    //here it got disconnected&#xA;    while (socket_client-&gt;connected() &amp;amp;&amp;amp; !socket_client-&gt;available()) {&#xA;        delay(100);&#xA;        Serial.println(&quot;Waiting...&quot;);&#xA;    }&#xA;    // TODO: More robust string extraction&#xA;    while ((bite = socket_client-&gt;read()) != -1) &#xA;    {&#xA;        temp += (char)bite;&#xA;        if ((char)bite == '\n')&#xA;    {&#xA;     #ifdef DEBUGGING&#xA;            Serial.print(&quot;Got Header: &quot; + temp);&#xA;     #endif&#xA;            if (!foundupgrade &amp;amp;&amp;amp; temp.startsWith(&quot;Upgrade: websocket&quot;)) &#xA;            {&#xA;                foundupgrade = true;&#xA;            } &#xA;            else if (temp.startsWith(&quot;Sec-WebSocket-Accept: &quot;)) &#xA;            {&#xA;                serverKey = temp.substring(22,temp.length() - 2); // Don't save last CR+LF&#xA;            }&#xA;              temp = &quot;&quot;;&#xA;            }&#xA;if (!socket_client-&gt;available()) {&#xA;          delay(20);&#xA;        }&#xA;    }&#xA;key += &quot;258EAFA5-E914-47DA-95CA-C5AB0DC85B11&quot;;&#xA;    uint8_t *hash;&#xA;    char result[21];&#xA;    char b64Result[30];&#xA;    Sha1.init();&#xA;    Sha1.print(key);&#xA;    hash = Sha1.result();&#xA;    for (int i=0; i&amp;lt;20; ++i) {&#xA;        result[i] = (char)hash[i];&#xA;    }&#xA;    result[20] = '\0';&#xA;    base64_encode(b64Result, result, 20);&#xA;    // if the keys match, good to go&#xA;    return serverKey.equals(String(b64Result));&#xA;}&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6656" LastEditorUserId="6656" LastEditDate="2017-11-07T16:02:20.573" LastActivityDate="2017-11-07T16:02:20.573" CommentCount="0" CommunityOwnedDate="2017-11-07T16:02:20.573" ContentLicense="CC BY-SA 3.0" />
  <row Id="8020" PostTypeId="2" ParentId="8008" CreationDate="2015-01-14T09:40:14.573" Score="1" Body="&lt;p&gt;Okay; to start with, the Arduino Playground has a &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow&quot;&gt;how-to guide&lt;/a&gt;, the components are commonplace - either recycle a high-resistance resistor from junk or buy one from eg &lt;a href=&quot;http://www.maplin.co.uk/p/metal-film-06w-10m-ohm-resistor-m10m&quot; rel=&quot;nofollow&quot;&gt;Maplin&lt;/a&gt; at 38p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works as follows:&#xA;You charge the capacitor with one output, through a resistor. This charges the capacitor in RxC seconds - C is very small, typically 10^-11 or so, so a decent sized resistor helps make it slow, in computer terms. Ensure this is held on for long enough to charge fully. You can use one charge pin for many touch sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then drop the charge pin to 0, and see how fast the sense voltage drops; this will be affected by fingers etc, giving a time value reflecting the degree of contact; normally this is used as a threshold on/off, but does allow for some pressure sensitivity. You need one R/C/sense-pin per switch.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-14T09:40:14.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8021" PostTypeId="2" ParentId="8009" CreationDate="2015-01-14T12:12:43.470" Score="1" Body="&lt;p&gt;If you are sure to disable pull up on arduino side you are safe, as i2c works in open-drain mode, but the logic level &quot;high&quot; of arduino is about 3.2v, so it would be unstable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise i2c pin of rasp are NOT 5v tolerant, so you must be sure the voltage on the bus does not exceed operative limit; as you calculated ~3.5v should be good on raspi, but please check on datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you should check the total current on the bus, but as atmega resistor as so high,it should not pose a problem with raspi (but may give problem with passive i2c, that you can solve with a external pull up)&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-01-14T12:12:43.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8022" PostTypeId="1" CreationDate="2015-01-14T12:35:38.947" Score="-1" ViewCount="423" Body="&lt;p&gt;I want to build a wearable device for a dancer using the Lilypad and I need to first send the programme from my Mac to the Lilypad board and then transfer the data read by sensors back to my Mac. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know what is the best wireless solution to use here. I've seen various options such: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the Xbee or Bluetooth modules (&lt;a href=&quot;http://www.hobbytronics.co.uk/bluetooth-mate-silver&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/bluetooth-mate-silver&lt;/a&gt;) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6654" LastEditorUserId="10794" LastEditDate="2015-09-13T04:39:29.513" LastActivityDate="2022-11-23T23:02:20.400" Title="What is the best way to establish wireless communication between the Lilypad and a Mac?" Tags="|bluetooth|electronics|system-design|wireless|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8025" PostTypeId="1" AcceptedAnswerId="13240" CreationDate="2015-01-14T16:56:23.807" Score="2" ViewCount="6101" Body="&lt;p&gt;So I'm using the HC-SR04 modules to get the distance to objects, the problem is that if it's not a perpendicular surface I dont get any reading, and I assume that the reason is that the ultrasounds get reflected in another direction, so they don't come back to the sensor. What's the way to get over this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="6522" LastActivityDate="2016-09-07T15:47:12.433" Title="Get the distance to non perpendicular surface" Tags="|sensors|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8026" PostTypeId="1" AcceptedAnswerId="8037" CreationDate="2015-01-14T17:31:07.940" Score="0" ViewCount="231" Body="&lt;p&gt;I've the VCNL 4000 Proximity Sensor I use some sample code and at the very beginning&lt;/p&gt;&#xA;&lt;p&gt;the following code hangs (never finishes)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; readVCNLByte(0x81); is called&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Can this problem be caused because the contact of the pin isn't very good.&lt;/p&gt;&#xA;&lt;p&gt;I only but the part with pins in the sensor without to solder it.&lt;/p&gt;&#xA;&lt;p&gt;Is it likely that this may be the problem ? I have not many experince with solder and the sensor is really small so i'd like to avoid it for first tests ;)&lt;/p&gt;&#xA;&lt;p&gt;Here the code. The last output in the Serial window is &amp;quot;pre product&amp;quot;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println(&amp;quot;VCNL&amp;quot;);&#xA;  Wire.begin();&#xA;  Serial.println(&amp;quot;pre product&amp;quot;);&#xA;  uint8_t rev = read8(VCNL4000_PRODUCTID);&#xA;   Serial.println(&amp;quot;post product&amp;quot;);&#xA;  if ((rev &amp;amp; 0xF0) != 0x10) {&#xA;    Serial.println(&amp;quot;Sensor not found :(&amp;quot;);&#xA;    while (1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jcIwU.jpg&quot; alt=&quot;Before&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2MBZ0.jpg&quot; alt=&quot;After&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/prnZ1.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="6447" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-25T13:42:22.110" Title="Freeze with VCNL 4000 Proximity Sensor" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8027" PostTypeId="1" CreationDate="2015-01-14T18:34:57.827" Score="0" ViewCount="1242" Body="&lt;p&gt;I am experimenting with this idea: keep a DTCXO in sync with some frequency standard. I have all the parts I can afford, but I cannot figure out a way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parts I have: Arduino Leonardo, a &lt;code&gt;u-blox 6010&lt;/code&gt; based GPS module with PPS output, and a proto shield with &lt;code&gt;DS3231&lt;/code&gt; DTCXO chip mounted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My big idea is that &lt;code&gt;DS3231&lt;/code&gt; have aging registers that would affect the clock frequency. By keep counting the 8192Hz square wave output of &lt;code&gt;DS3231&lt;/code&gt; and keep it in sync with the 1Hz signal from the GPS module, I can keep the DTCXO in sync with a reference clock. This, in turn, would give me a relatively good 32768Hz clock reference that I can build a frequency counter on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both 8192Hz and PPS are interrupt driven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have an idea on how to do it? Does this spell Artificial Intelligence on AVR, as my instructor suggests?&lt;/p&gt;&#xA;" OwnerUserId="4775" LastActivityDate="2016-02-11T04:47:24.990" Title="DS3231 DTCXO and GPS" Tags="|gps|rtc|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="8029" PostTypeId="1" AcceptedAnswerId="8030" CreationDate="2015-01-14T21:29:43.517" Score="-1" ViewCount="2140" Body="&lt;p&gt;For some reason, my Arduino program has disappeared from my computer, and it was a really long, complex program. It is currently still on my arduino, and I HAVE to get it back. Please, someone help me. Arduino UNO, Macbook Pro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Perhaps I wasn't clear. I need the INO file back FROM MY ARDUINO.&lt;/p&gt;&#xA;" OwnerUserId="6662" LastEditorUserId="10794" LastEditDate="2015-09-06T08:53:03.733" LastActivityDate="2015-09-06T08:53:03.733" Title="Emergency! INO file disappeared on computer. Still on Arduino!" Tags="|arduino-uno|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8030" PostTypeId="2" ParentId="8029" CreationDate="2015-01-14T22:01:47.157" Score="5" Body="&lt;p&gt;The .ino file is lost, however, your Arduino IDE uses your &lt;code&gt;%temp%&lt;/code&gt; to store immediate data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look in &lt;code&gt;%temp%&lt;/code&gt;, folders akin to &lt;code&gt;build116193871148509168.tmp&lt;/code&gt; contain build files. The original ino is not there, but I remember the &lt;code&gt;cpp&lt;/code&gt; files generated by IDE should be there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some info about how to find the &lt;code&gt;temp&lt;/code&gt; on Mac: &lt;a href=&quot;https://stackoverflow.com/questions/11607834/where-are-the-hex-files-compiled-by-arduino&quot;&gt;https://stackoverflow.com/questions/11607834/where-are-the-hex-files-compiled-by-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5007" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-01-15T08:29:58.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8031" PostTypeId="2" ParentId="3700" CreationDate="2015-01-14T22:18:39.797" Score="3" Body="&lt;p&gt;For Yosemite you seem to need to run this command in the Terminal and then restart the computer to get it to work. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6720" LastEditorUserId="220" LastEditDate="2015-01-14T22:45:51.963" LastActivityDate="2015-01-14T22:45:51.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8032" PostTypeId="1" CreationDate="2015-01-15T00:29:35.270" Score="1" ViewCount="2787" Body="&lt;p&gt;i just set up 2 displays ( 3 digit 7 segments ), and the displays seems to be blinkin ( i know they are suppose to blink but so fast that the human eye cannot detect it ). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the SevSeg Library and this is how my code looks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;   byte numDigits = 3;&#xA;   byte digitPins[] = {2, 3, 4};&#xA;   byte segmentPins[] = {5, 6, 7, 8, 9, 10, 11, 12};&#xA;   sevseg1.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);&#xA;&#xA;   byte digitPins2[] = {14, 15, 16};&#xA;   byte segmentPins2[] = {17, 18, 19, 20, 21, 22, 23, 24};&#xA;   sevseg2.begin(COMMON_ANODE, numDigits, digitPins2, segmentPins2);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  while(true){&#xA;     sevseg1.setNumber(number,0);&#xA;     sevseg2.setNumber(number,1);&#xA;     sevseg1.refreshDisplay();  &#xA;     sevseg2.refreshDisplay();  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to add 2 more 3 digits 7 segment displays so i was wondering what is it that is causing the blinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im using Arduino Mega.&lt;/p&gt;&#xA;" OwnerUserId="6235" LastActivityDate="2016-01-07T20:32:57.117" Title="Multiple 7 segment displays blinking" Tags="|arduino-mega|led|display|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8034" PostTypeId="1" CreationDate="2015-01-15T09:07:13.727" Score="0" ViewCount="488" Body="&lt;p&gt;Please apologize my english.&#xA;I am working in a project using an original arduino uno, one generic servo (no factory marks) and one HC-SR04 sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I make a circuit like the one here: &lt;a href=&quot;http://s24.postimg.org/43jra5l9h/mycircuit_bb.png&quot; rel=&quot;nofollow&quot;&gt;http://s24.postimg.org/43jra5l9h/mycircuit_bb.png&lt;/a&gt; ([url=&lt;a href=&quot;http://postimg.org/image/lgu1p0gkh/][img]http://s24.postimg.org/lgu1p0gkh/mycircuit_bb.jpg[/img][/url]&quot; rel=&quot;nofollow&quot;&gt;http://postimg.org/image/lgu1p0gkh/][img]http://s24.postimg.org/lgu1p0gkh/mycircuit_bb.jpg[/img][/url]&lt;/a&gt;, sorry, upload of image not allowed due reputation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from the picture I accidentally connected green into Vin instead of GND. (If the image won't load, that means that my positive is connected to arduino 5V and the ground of the circuit is connected to arduino Vin)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my board turn on the lights but I am unable to execute the program already in the microcontroller as aslo I cannot upload a new program to it. (It gives some error message of failed to connect).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I burned the microcontroller(mc) by short circuiting 5V and Vin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I have three questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - Is there any way to find out if I really burned my board using just a low budget multimeter? And if I did, which parts I need to replace? &#xA;I have access to some spare ATMEL mc and I think I could replace and reprogram them by using another arduino board. However, I am affraid that I may have burned few other items and just by replacing the mc will not give me back all the funcionallities of a new board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - I have basic knowledge of electronics, could someone explain to a beginner like me which impact did that mistake could/have make in all components of the circuit? (Arduino board, the servo and the sensor)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 - Even before the accident, the circuit just work well for few minutes. I read tons of pages and tried a lot of suggestions, most of them related with power supply (capacitors to avoid flutuations, One battery just for the servo, one battery just for the sensor...) and none gave me good results.&#xA;I am wondering what are the alternatives to power up this simply circuit, in particular I am looking for this possibilities: Complete external power supply (by using AC to DC adapters), Complete internal power supply (Using just batteries) and a mix of those two (Using AC to DC and batteries). I have no access to a external DC power supply generator other than batteries.&lt;/p&gt;&#xA;" OwnerUserId="6724" LastActivityDate="2016-03-10T17:19:36.563" Title="Possible arduino burned (5V shorted to Vin), explanations and suggestions" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8035" PostTypeId="2" ParentId="8034" CreationDate="2015-01-15T12:20:06.927" Score="1" Body="&lt;p&gt;If you have another Uno then your best bet is either:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Swap the suspect processor into the known good board, test it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) to buy a replacement chip (ATMega 328-PU), use &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; to flash it, if it works you win, if not you can at least use the new processor again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done this myself &amp;amp; it worked well, it isn't easy to be sure any other way as the chip needn't fail in a predictable manner. The chances are it will take a large current if it's dead, until it burns out &amp;amp; goes open circuit. Once the magic smoke has come out you know it's dead... the Arduino power supply is reasonably capable of looking after itself so your chances are good.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-15T12:20:06.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8036" PostTypeId="2" ParentId="8032" CreationDate="2015-01-15T13:04:12.080" Score="1" Body="&lt;p&gt;First of all, you have a &lt;code&gt;while(true)&lt;/code&gt; in your loop, that makes no sense. The loop already loops for ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are also changing the number every time the &lt;code&gt;loop()&lt;/code&gt; is run, making it flicker. If you follow the Arduino library example, you can see they only use &lt;code&gt;setNumber&lt;/code&gt; every so often and use &lt;code&gt;refreshDisplay&lt;/code&gt; every time the code runs through the &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you didn't &lt;code&gt;setBrightness&lt;/code&gt;, which shouldn't be a problem since the library probably sets a default value, but I'd advise on including it in your code to eliminate unforeseen problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this code and let me know if it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SevSeg.h&quot;&#xA;&#xA;SevSeg sevseg1; //Instantiate a seven segment controller object&#xA;SevSeg sevseg2;&#xA;&#xA;void setup() {&#xA;  byte numDigits = 4;&#xA;  byte digitPins1[] = {2, 3, 4, 5};&#xA;  byte segmentPins1[] = {6, 7, 8, 9, 10, 11, 12, 13};&#xA;  byte digitPins2[] = {14, 15, 16};&#xA;  byte segmentPins2[] = {17, 18, 19, 20, 21, 22, 23, 24};&#xA;&#xA;  sevseg1.begin(COMMON_ANODE, numDigits, digitPins1, segmentPins1);&#xA;  sevseg1.setBrightness(90);&#xA;&#xA;  sevseg2.begin(COMMON_ANODE, numDigits, digitPins2, segmentPins2);&#xA;  sevseg2.setBrightness(90);&#xA;}&#xA;&#xA;void loop() {&#xA;  static unsigned long timer = millis();&#xA;  static int deciSeconds = 0;&#xA;&#xA;  if (millis() &amp;gt;= timer) {&#xA;    deciSeconds++; // 100 milliSeconds is equal to 1 deciSecond&#xA;    timer += 100; &#xA;    if (deciSeconds == 10000) { // Reset to 0 after counting for 1000 seconds.&#xA;      deciSeconds=0;&#xA;    }&#xA;    sevseg1.setNumber(deciSeconds, 1);&#xA;    sevseg2.setNumber(deciSeconds, 1);&#xA;  }&#xA;&#xA;  sevseg1.refreshDisplay(); // Must run repeatedly&#xA;  sevseg2.refreshDisplay(); // Must run repeatedly&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4710" LastEditorUserId="4710" LastEditDate="2015-01-21T09:40:33.890" LastActivityDate="2015-01-21T09:40:33.890" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8037" PostTypeId="2" ParentId="8026" CreationDate="2015-01-15T13:59:24.910" Score="1" Body="&lt;p&gt;You really can't expect this to work unsoldered. The contacts will be at best intermittent, and poor contact. Even a 'dry joint' where the pin is mostly surrounded by solder doesn't work well, these are the ultimate examples! You could however use an edge-connector, if you can find one; not something you see often nowadays.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-15T13:59:24.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8041" PostTypeId="1" CreationDate="2015-01-15T17:50:49.630" Score="1" ViewCount="216" Body="&lt;p&gt;I'm trying to stack the Adafruit Data Logger Shield &lt;a href=&quot;https://learn.adafruit.com/adafruit-data-logger-shield/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-data-logger-shield/overview&lt;/a&gt; onto a CuteDigi Sim900 GPRS Shield so that I can upload data (collected eventually by a GPS breakout) to a server at certain intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't seem to get the two shields to play nicely together. I'm a beginner with the Arduino and electronics in general, so hopefully this is just a noob issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I power on the GPRS Shield, the data logger stops outputting the Date/Time to the serial monitor. And when I turn the GPRS Shield off, the serial monitor continues again and shows the Date/Time from the data logger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They don't share any pins that I'm aware of, and I've tried connecting a 7.4V li-po for external power with no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="6735" OwnerDisplayName="Christopher Harris" LastEditorUserId="83" LastEditDate="2015-01-15T18:27:26.287" LastActivityDate="2015-01-15T18:27:26.287" Title="Problems stacking Arduino Shields" Tags="|shields|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8042" PostTypeId="2" ParentId="8041" CreationDate="2015-01-15T18:04:39.387" Score="1" Body="&lt;p&gt;Make sure you are using a software serial port for the GPRS shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you aren't using the software serial port, then you are probably running into an issue with trying to read data over the only UART (serial) port while two devices are tryiing to use it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like there are two jumpers next to D0/D1 on the GPRS shield, I can't tell but I think if you remove those, the shield will use software serial over D7/D8.  If you do this, you'll have to code your program to use a software serial.  &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;This wiki page on the GPRS shield&lt;/a&gt; if you need help with that.&lt;/p&gt;&#xA;" OwnerUserId="6732" LastActivityDate="2015-01-15T18:04:39.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8043" PostTypeId="1" CreationDate="2015-01-15T20:34:31.577" Score="0" ViewCount="707" Body="&lt;p&gt;My goal is to build an extremely low cost quadcopter, by using the sensors of my smartphone (it will be mounted on the quadcopter). The arduino will only control the speed of each motor, as received from the smartphone. What methods exist to transfer data from a smartphone to arduino? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first idea was to simply use USB, but it turns out that my smartphone doesn't support the USB host mode. Is it possible to send data over USB without USB host mode? What alternatives do I have? I thought of using the audio port: Can I directly connect an audio channel to analog in?&lt;/p&gt;&#xA;" OwnerUserId="6738" LastEditorUserId="5156" LastEditDate="2015-01-16T18:22:50.130" LastActivityDate="2015-03-17T20:58:25.563" Title="How to send data from a smartphone to Arduino" Tags="|communication|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8044" PostTypeId="2" ParentId="8043" CreationDate="2015-01-15T21:24:20.987" Score="1" Body="&lt;p&gt;I have been using a bluetooth module - they can be had for just a few dollars (depending on which country you're in). I've got an HC-06 which works great : &lt;a href=&quot;http://www.dx.com/s/hc-05&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/s/hc-05&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has 4 pins: VCC (connect to +5V on Arduino), GND, RX and TX (connected to RX and TX, digital pins 0 and 1 on the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably not be able to use Bluetooth and USB at the same time - both will be sending to the Arduino at the same time, and the communications will get garbled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an app called &quot;Bluetooth Serial Controller&quot;, which lets me send commands over bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If using this, think carefully about what will happen if your phone goes out of range of your arduino.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-15T21:24:20.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8045" PostTypeId="2" ParentId="8029" CreationDate="2015-01-15T21:29:39.863" Score="2" Body="&lt;p&gt;Your INO file is not (ever) on your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &quot;upload your sketch&quot; to the Arduino, it is first compiled. Your Arduino cannot interpret a sketch directly, and there are various processes which convert your sketch into machine code. This process is not practically reversible.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-15T21:29:39.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8046" PostTypeId="2" ParentId="8022" CreationDate="2015-01-15T21:49:12.777" Score="0" Body="&lt;p&gt;I have been using a hc-06 module very successfully. &lt;a href=&quot;http://www.dx.com/p/hc-06-wireless-bluetooth-serial-pass-through-module-for-arduino-works-with-official-arduino-board-238364#.VLg153WjlIc&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/hc-06-wireless-bluetooth-serial-pass-through-module-for-arduino-works-with-official-arduino-board-238364#.VLg153WjlIc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect pins to +5v, Gnd, and digital pins 0 and 1 (rx &amp;amp; tx). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do not try to connect to USB and this at the same time, as communication will get garbled.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-15T21:49:12.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8047" PostTypeId="2" ParentId="7991" CreationDate="2015-01-15T22:13:46.850" Score="0" Body="&lt;p&gt;An alternative to software serial is to use hardware serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use hardware serial (i.e. supported in hardware by the chip) using pins 0 &amp;amp; 1. You will NOT! be able to do serial communications (e.g. programming your arduino) at the same time - I always make sure I have EITHER usb OR bluetooth serial connected at any given time. USB for power is ok.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-15T22:13:46.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8049" PostTypeId="2" ParentId="7991" CreationDate="2015-01-16T00:23:45.330" Score="1" Body="&lt;p&gt;Another option is to use a separate chip to send and receive. An Attiny87 (picking a random example) has a UART and an SPI interface - it could receive the data via UART, send via SPI to the Arduino; then receive the data from the Arduino and send it via UART. Since the whole chain now has hardware support, you're going to have reliable communications. The data could be buffered on the AtTiny, and raise a signal to the Arduino to say when data is ready.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATTiny chips are cut-down versions of the ATMega chips used on Arduinos, and they can be programmed over ISP. They can be had for a few dollars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, this is a lot of extra work.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-16T00:23:45.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8051" PostTypeId="2" ParentId="5389" CreationDate="2015-01-16T04:15:02.293" Score="2" Body="&lt;p&gt;Go for the manufacturer of this board website i.e. &lt;a href=&quot;http://www.gravitech.us&quot; rel=&quot;nofollow&quot;&gt;www.gravitech.us&lt;/a&gt;. You can get the eagle files and all the data you need. Alternatively, you can download the eagle file of nanov3 directly using this link: &lt;a href=&quot;http://site.gravitech.us/Arduino/NANO30/ArduinoNano30_Eagle.zip&quot; rel=&quot;nofollow&quot;&gt;http://site.gravitech.us/Arduino/NANO30/ArduinoNano30_Eagle.zip&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6744" LastEditorUserId="33" LastEditDate="2015-01-20T17:04:06.027" LastActivityDate="2015-01-20T17:04:06.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8052" PostTypeId="1" AcceptedAnswerId="8055" CreationDate="2015-01-16T04:24:57.693" Score="1" ViewCount="1938" Body="&lt;p&gt;I know this is not a good question. But I am clueless with this error : invalid array assignment (at function convert). For extra information, I involved a lot of copying/pasting programs I haven't exactly understand from internet in the convert function (the strncpy ones) so.. yeah. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the program I've done (the menu/mn button currently not used):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#define WORD 11&#xA;#define LETTER 15&#xA;LiquidCrystal lcd(7,6,5,4,3,2);&#xA;int i=0;&#xA;char input[] = &quot;a&quot;;&#xA;char output[15];&#xA;const int dw = 8;&#xA;const int ri = 9;&#xA;const int le = 10;&#xA;const int up = 11;&#xA;const int ok = 12;&#xA;const int mn = 13;&#xA;int checker = 0;&#xA;int bounceCk = 0;&#xA;&#xA;int bdw=0, bri=0, ble=0, beu=0, beo=0, bem=0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(dw, INPUT);&#xA;  pinMode(ri, INPUT);&#xA;  pinMode(le, INPUT);&#xA;  pinMode(up, INPUT);&#xA;  pinMode(ok, INPUT);&#xA;  pinMode(mn, INPUT);  &#xA;}&#xA;void intext()&#xA;{&#xA;  int lim=16;&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(input);&#xA;  for(i=0; i&amp;lt;lim ; )&#xA;  {&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(input);  &#xA;    if(digitalRead(dw)==HIGH)&#xA;    {&#xA;      checker=digitalRead(dw);&#xA;      delay(100);&#xA;      bounceCk=digitalRead(dw);&#xA;      if(checker==bounceCk)&#xA;      {&#xA;        if(input[i]&amp;gt;'z')&#xA;          input[i]='a';&#xA;        input[i]=input[i]+1;&#xA;      }      &#xA;    }&#xA;    if(digitalRead(up)==HIGH)&#xA;    {&#xA;      checker=digitalRead(up);&#xA;      delay(100);&#xA;      bounceCk=digitalRead(up);&#xA;      if(checker==bounceCk)&#xA;      {&#xA;        if(input[i]&amp;lt;'a')&#xA;          input[i]='z';&#xA;        input[i]=input[i]-1;    &#xA;      }&#xA;    }&#xA;    if(digitalRead(ri)==HIGH &amp;amp;&amp;amp; i&amp;lt;16)&#xA;    {  &#xA;      checker=digitalRead(ri);&#xA;      delay(100);&#xA;      bounceCk=digitalRead(ri);&#xA;      if(checker==bounceCk)&#xA;      { &#xA;        i=i+1;&#xA;      }&#xA;    }&#xA;    if(digitalRead(le)==HIGH &amp;amp;&amp;amp; i&amp;gt;0)&#xA;    {&#xA;      checker=digitalRead(le);&#xA;      delay(100);&#xA;      bounceCk=digitalRead(le);&#xA;      if(checker==bounceCk)&#xA;      {      &#xA;        i=i-1;&#xA;      }&#xA;    }&#xA;    if(digitalRead(ok)==HIGH)&#xA;    {&#xA;      checker=digitalRead(ok);&#xA;      delay(100);&#xA;      bounceCk=digitalRead(ok);&#xA;      if(checker==bounceCk)&#xA;      {      &#xA;        lim=i;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;void convert()&#xA;{&#xA;   char sumber[WORD][LETTER] = {{0}};  /* declare a progmem unsigned static array of kata x huruf */&#xA;   char dasar[WORD][LETTER] = {{0}};  /* declare a progmem unsigned static array of kata x huruf */&#xA;&#xA;  /* copy various strings to statically declared storage SUMBER */&#xA;  strncpy (sumber[0],&quot;memakan&quot;, strlen(&quot;memakan&quot;)+1);&#xA;  strncpy (sumber[1],&quot;makanan&quot;, strlen(&quot;makanan&quot;)+1);&#xA;  strncpy (sumber[2],&quot;menyuci&quot;, strlen(&quot;menyuci&quot;)+1);&#xA;  strncpy (sumber[3],&quot;perubahan&quot;, strlen(&quot;perubahan&quot;)+1);&#xA;  strncpy (sumber[4],&quot;penulisan&quot;, strlen(&quot;penulisan&quot;)+1);&#xA;  strncpy (sumber[5],&quot;tercampurkan&quot;, strlen(&quot;tercampurkan&quot;)+1);&#xA;  strncpy (sumber[6],&quot;pengelompokan&quot;, strlen(&quot;pengelompokan&quot;)+1);&#xA;  strncpy (sumber[7],&quot;pengembangan&quot;, strlen(&quot;pengembangan&quot;)+1);&#xA;  strncpy (sumber[8],&quot;kehebatan&quot;, strlen(&quot;kehebatan&quot;)+1);&#xA;  strncpy (sumber[9],&quot;memotret&quot;, strlen(&quot;memotret&quot;)+1);&#xA;  strncpy (sumber[10],&quot;melakukan&quot;, strlen(&quot;melakukan&quot;)+1);&#xA;&#xA;  /* copy various strings to statically declared storage DASAR*/&#xA;  strncpy (dasar[0],&quot;makan&quot;, strlen(&quot;makan&quot;)+1);&#xA;  strncpy (dasar[1],&quot;makan&quot;, strlen(&quot;makan&quot;)+1);&#xA;  strncpy (dasar[2],&quot;cuci&quot;, strlen(&quot;cuci&quot;)+1);&#xA;  strncpy (dasar[3],&quot;ubah&quot;, strlen(&quot;ubah&quot;)+1);&#xA;  strncpy (dasar[4],&quot;tulis&quot;, strlen(&quot;tulis&quot;)+1);&#xA;  strncpy (dasar[5],&quot;campur&quot;, strlen(&quot;campur&quot;)+1);&#xA;  strncpy (dasar[6],&quot;kelompok&quot;, strlen(&quot;kelompok&quot;)+1);&#xA;  strncpy (dasar[7],&quot;kembang&quot;, strlen(&quot;kembang&quot;)+1);&#xA;  strncpy (dasar[8],&quot;hebat&quot;, strlen(&quot;hebat&quot;)+1);&#xA;  strncpy (dasar[9],&quot;potret&quot;, strlen(&quot;potret&quot;)+1);&#xA;  strncpy (dasar[10],&quot;laku&quot;, strlen(&quot;laku&quot;)+1);&#xA;&#xA;    /* mencari input pada sumber */&#xA;  int k=0, search=0, sel=9;&#xA;&#xA;  while(search==0)&#xA;  {&#xA;    sel=strcmp(input, sumber[k]);&#xA;    if(sel==0)&#xA;    {&#xA;      output[]=dasar[k]; //!!!!THE ERROR IS HERE!!! happen to either this or output=dasar[k]&#xA;      lcd.clear();&#xA;      lcd.setCursor(0,0);&#xA;      lcd.print(&quot;Base Word:&quot;);&#xA;      lcd.setCursor(0,1);&#xA;      lcd.print(output);      &#xA;      search=1;&#xA;    }&#xA;    else&#xA;    {&#xA;      k=k+1;&#xA;      if(k&amp;gt;=11)&#xA;      {&#xA;        lcd.clear();&#xA;        lcd.setCursor(0,0);&#xA;        lcd.print(&quot;Error:NF&quot;);&#xA;        lcd.setCursor(0,1);&#xA;        lcd.print(&quot;word n found&quot;);&#xA;        search=1;&#xA;      }&#xA;    }&#xA;  }&#xA;    /* &#xA;    //print the values &#xA;    while (*sumber[i])&#xA;        printf (&quot;  %s\n&quot;, sumber[i++]);&#xA;    */&#xA;&#xA;}  &#xA;void loop()&#xA;{&#xA;  lcd.begin(16,2);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Type your word:&quot;);&#xA;  intext();&#xA;  convert();&#xA;  delay(15000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found more errors before, I've fixed those, but can't fix this one. I think this problem is caused by the wrong instruction or wrong format. But can't found solution...yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is converting words to its basic word in Bahasa, you can compare it to English like this. You type &quot;eaten&quot; and it will return &quot;eat&quot;. You type &quot;understood&quot; it will return &quot;understand&quot;. When you type &quot;stunk&quot; it will return &quot;stink&quot;. Or something like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example in bahasa : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;memakan&quot; (eating) -&gt; &quot;makan&quot; (eat)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;makanan&quot; (food) -&gt; &quot;makan&quot; (eat)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;pengembangan&quot; (development) -&gt; &quot;kembang&quot; (becoming bigger/better)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope someone will give me a clear hint or two (I'm not too bright, but I still need to learn how not just copying things around),&#xA;Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="6379" LastActivityDate="2015-01-16T10:12:40.890" Title="Simple word translator, return error: invalid array assignment" Tags="|lcd|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8054" PostTypeId="2" ParentId="8052" CreationDate="2015-01-16T05:30:26.850" Score="0" Body="&lt;p&gt;Just replace the line in error with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strcpy(output, dasar[k]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-16T05:30:26.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8055" PostTypeId="2" ParentId="8052" CreationDate="2015-01-16T10:12:40.890" Score="0" Body="&lt;p&gt;It looks like you're trying to copy the contents of a particular sub-array in &lt;code&gt;dasar&lt;/code&gt; across to the &lt;code&gt;output&lt;/code&gt; array. However, this isn't valid in C/C++:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output[]=dasar[k];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To copy data from one array to another, you either need to copy each element one-by-one (e.g. in a loop), or use a block memory operation like &lt;code&gt;memcpy&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I would do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(output, dasar[k], sizeof(output));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work because arrays are basically just pointers in C/C++. It uses the start of &lt;code&gt;output&lt;/code&gt; as the destination of the copy, and uses the start of &lt;code&gt;dasar[k]&lt;/code&gt; as the source. The number of bytes it copies is taken from the total size of the &lt;code&gt;output&lt;/code&gt; array.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-16T10:12:40.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8057" PostTypeId="1" AcceptedAnswerId="8061" CreationDate="2015-01-16T15:26:55.133" Score="0" ViewCount="400" Body="&lt;p&gt;i want to read the audio signal from my smartphone. &#xA;Can i just cut a headphonewire and connect it to the analog in? (Arduino uno)&#xA;I sadly dont know much about electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;greetings&lt;/p&gt;&#xA;" OwnerUserId="6738" LastActivityDate="2015-01-16T23:03:18.610" Title="Reading the audio signal from a smartphone" Tags="|audio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8058" PostTypeId="1" CreationDate="2015-01-16T16:55:52.830" Score="17" ViewCount="5387" Body="&lt;p&gt;I'd like manage my Arduino source code (projects and libraries) under source control with continuous testing. How can I automatically compile the code with continuous integration tools, to make sure each version compiles cleanly? In the best case one should be able to configure builds for multiple processors, optionally run unit tests and check for maximum binary size.&lt;/p&gt;&#xA;" OwnerUserId="5156" LastActivityDate="2019-03-07T11:03:08.807" Title="How can Arduino source code be tested automatically (continuous integration)?" Tags="|programming|version-control|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8061" PostTypeId="2" ParentId="8057" CreationDate="2015-01-16T23:03:18.610" Score="2" Body="&lt;p&gt;No. It partly depends on the phone, but most put out a low voltage AC signal. This would drive the Arduino inputs negative. You can do this by biassing the input at the mid point (+2.5V) and feeding audio in via a capacitor. There are many projects which use similar to record audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I would not recommend cutting a headphone cord. The wires are very fine, and almost impossible to solder. If you want to do this make a custom cable.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-01-16T23:03:18.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8062" PostTypeId="1" CreationDate="2015-01-17T02:08:56.607" Score="0" ViewCount="136" Body="&lt;p&gt;I am following Jeremy Blum's tutorial for Holiday Lights: &lt;a href=&quot;http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds&quot; rel=&quot;nofollow&quot;&gt;http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am just trying to set up the circuit for one of the audio channels. I believe I followed the breadboard schematic. However, when I connect the Arduino the power, but without any audio input, the LED lights up. I would've thought that would not be the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me correct my understanding here? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image of my breadboard: &lt;a href=&quot;http://postimg.org/image/ibqfvezqp/&quot; rel=&quot;nofollow&quot;&gt;http://postimg.org/image/ibqfvezqp/&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6761" LastActivityDate="2015-04-18T01:26:01.463" Title="Op Amp Understanding + Holiday Lights Tutorial" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8063" PostTypeId="1" AcceptedAnswerId="8068" CreationDate="2015-01-17T02:38:14.447" Score="0" ViewCount="739" Body="&lt;p&gt;I have a need for a bill counter at my current job, but besides counting bills we also could use a machine to count admission cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to either buy a bill counter machine (like those that the Banks have), or make one from scratch by buying the parts.&#xA;Besides the bill counting feature i wanted to make it so that it also counts the certain number of cards, and check if they are either stamped or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, is it easier to just buy a arduino and use it with other parts (sensors, moving gears etc etc), or to buy a bill counter and just &quot;crack&quot; the OS?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I am a 1st year Computer Science student, but i have 0 experience in programming in Arduino&lt;/p&gt;&#xA;" OwnerUserId="6762" LastActivityDate="2015-01-17T19:11:51.843" Title="Question about viability of building a Bill Counter machine" Tags="|programming|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8066" PostTypeId="2" ParentId="602" CreationDate="2015-01-17T15:27:04.383" Score="0" Body="&lt;p&gt;This happened to me with a bare-bones Arduino. I disconnected everything and it still happens. I don't know what the cause is but you definitely will need to reflash the bootloader or replace the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It isn't a connection or power issue, and it isn't related to having devices connected to pins 0/1 (although that can also cause problems, it will give a different error).&lt;/p&gt;&#xA;" OwnerUserId="6770" LastActivityDate="2015-01-17T15:27:04.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8067" PostTypeId="1" CreationDate="2015-01-17T15:36:38.203" Score="1" ViewCount="1406" Body="&lt;p&gt;I am looking to utilize Pin 13 and an external LED to flicker as either the Rx or Tx LEDs do when Serial data is transferred through the Arduino. The existing code is all in real time to function with external buttons, so there can't be any delay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came across this link which seems useful, but I can't quite get it to read from Serial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advance&lt;/p&gt;&#xA;" OwnerUserId="4423" LastActivityDate="2015-02-07T21:17:45.437" Title="Serial Data through Pin 13 LED" Tags="|serial|arduino-mega|led|pins|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8068" PostTypeId="2" ParentId="8063" CreationDate="2015-01-17T19:11:51.843" Score="0" Body="&lt;p&gt;There are many more things to consider than just put some parts together if you try to build a counter from scratch. Automated currency handling has come a long way to today's bill counters or any vending machines. You may perfectly handle the computing part of task with an embedded system like the arduino, but paper handling is an art of itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you think of this task as a challenge to acquire and hone engineering skills, go ahead. It may be one of the best training tasks one can think of. But while you may learn a lot from this conundrum, you will propably end up without an usabale device. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to consider, there are subtasks in&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;mechanics&lt;/li&gt;&#xA;&lt;li&gt;electronics&lt;/li&gt;&#xA;&lt;li&gt;programming&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;which may include&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;paper handling (separation, traction, alignment)&lt;/li&gt;&#xA;&lt;li&gt;pattern recognition&lt;/li&gt;&#xA;&lt;li&gt;motor control&lt;/li&gt;&#xA;&lt;li&gt;high speed sensors&lt;/li&gt;&#xA;&lt;li&gt;signal detection and processing&lt;/li&gt;&#xA;&lt;li&gt;error and fault processing and handling&lt;/li&gt;&#xA;&lt;li&gt;motor and gear connection&lt;/li&gt;&#xA;&lt;li&gt;bearings and mechanical substructure&lt;/li&gt;&#xA;&lt;li&gt;user interface&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and many more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To modify an existing device solves a lot of mechanical problems in advance. But it may still be difficult to change the firmware of a bill counter to your needs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have to&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;break into the system (may be impossible)&lt;/li&gt;&#xA;&lt;li&gt;reverse engineer the firmware&lt;/li&gt;&#xA;&lt;li&gt;understand the mechanical constraints&lt;/li&gt;&#xA;&lt;li&gt;find a way to adapt the system to your needs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A third way, which in my eyes is rather intriguing, is to take an existing bill counter, rip out the controller and try to plug in your own controller, e.g. an arduino. This gives you a real chance to reach your goal while still having the opportunity to learn a lot. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-01-17T19:11:51.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8069" PostTypeId="2" ParentId="8062" CreationDate="2015-01-18T00:38:29.263" Score="1" Body="&lt;p&gt;Per Jeremy Blum:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the input doesn’t have a audio input plugged in, then it’s said to be “floating” and you &gt;can’t really count on the circuit to do what you would expect. The audio input connection &gt;introduces a known voltage (0 when no sound is playing) connection between the positive op-&gt;amp input and GND that we then amplify. Try connecting the input to GND and you should see &gt;the LED turn off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds/comment-page-2/#comment-1373392&quot; rel=&quot;nofollow&quot;&gt;http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds/comment-page-2/#comment-1373392&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6761" LastActivityDate="2015-01-18T00:38:29.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8070" PostTypeId="2" ParentId="1034" CreationDate="2015-01-18T00:53:52.213" Score="0" Body="&lt;p&gt;The jumper is only neccesary if your device is not R3 (revision 3)&#xA;Be carefully if you connect the shield and your computer does not&#xA;recognice the port. &#xA;You gonna need a driver in the link below there are all the steps&#xA;include other links to download software as Flip 3.4.7 who has &#xA;the executable batchisp which one you can made the changes &#xA;read the web site: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/community/?p=3760&quot; rel=&quot;nofollow&quot;&gt;http://www.dfrobot.com/community/?p=3760&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and extra information about that in official site of arduino&#xA;WiFi Shield Firmware Upgrading&lt;/p&gt;&#xA;&#xA;&lt;p&gt;there you gonna have an idea how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for me was more clear as in this site describe everything &#xA;and also teach to probe if there is an update&#xA;having sucess in the process to installing something it&#xA;could be as a question answered with non the specific&#xA;thing you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.binarytaskforce.com/Weblog/2013/09/21/arduino-wifi-firmware-update/&quot; rel=&quot;nofollow&quot;&gt;http://www.binarytaskforce.com/Weblog/2013/09/21/arduino-wifi-firmware-update/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also in the process to update my device if I will have success &#xA;I will write to how I do it. &#xA;At the moment reading a bunch of differents forums beacuse arduino team itself&#xA;appearently had some troubles to provided a guided how to do it sucessfully.&lt;/p&gt;&#xA;" OwnerUserId="6774" LastActivityDate="2015-01-18T00:53:52.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8071" PostTypeId="1" AcceptedAnswerId="8072" CreationDate="2015-01-18T03:49:02.973" Score="6" ViewCount="3460" Body="&lt;p&gt;I have a text file on an SD card, and I am trying to print the lines to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This Code Works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;File myFile;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;&#xA;  pinMode(10, OUTPUT);&#xA;&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;initialization done.&quot;);&#xA;&#xA;  myFile = SD.open(&quot;c.txt&quot;);&#xA;  if (myFile) {&#xA;    Serial.println(&quot;c.txt:&quot;);&#xA;&#xA;    while (myFile.available()) {&#xA;      Serial.write(myFile.read());  //THIS LINE RIGHT HERE&#xA;    }&#xA;    myFile.close();&#xA;  } else {&#xA;    // if the file didn't open, print an error:&#xA;    Serial.println(&quot;error opening c.txt&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I replace the line &lt;code&gt;Serial.write(myFile.read());&lt;/code&gt; with &lt;code&gt;Serial.println(myFile.read());&lt;/code&gt;, then the code doesn't return the correct lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should return numbers similar to this (albeit 3000 of them):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;564&#xA;564&#xA;564&#xA;564&#xA;564&#xA;564&#xA;564&#xA;464&#xA;564&#xA;664&#xA;564&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use &lt;code&gt;Serial.println&lt;/code&gt; it returns numbers like this (and it doesn't stop at 3000 lines):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;13&#xA;10&#xA;54&#xA;54&#xA;52&#xA;13&#xA;10&#xA;53&#xA;54&#xA;52&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if I try to do &lt;code&gt;int(myFile.read())&lt;/code&gt; then the integer becomes the wrong numbers (returned by &lt;code&gt;println&lt;/code&gt;), not the right ones (returned by &lt;code&gt;write&lt;/code&gt;).\&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get a number returned by &lt;code&gt;Serial.write(myFile.read());&lt;/code&gt; to be an integer?&lt;/p&gt;&#xA;" OwnerUserId="6662" LastActivityDate="2016-07-26T13:20:03.300" Title="Serial.write and Serial.println return different values? Cannot use correct ones" Tags="|serial|sd-card|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8072" PostTypeId="2" ParentId="8071" CreationDate="2015-01-18T04:38:11.790" Score="5" Body="&lt;p&gt;The text file contains the sequential ascii values that spell out the data, not binary data. &lt;code&gt;println&lt;/code&gt; in printing the numerical value of each byte. For example, the 10's &lt;code&gt;println&lt;/code&gt; prints are '\n' characters. &lt;code&gt;write&lt;/code&gt; is printing the ascii character associated with the binary value (the new line). You need to parse the ascii characters into numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily for you the SD library inherits from the &lt;code&gt;Stream&lt;/code&gt; class, so it will have the same &lt;code&gt;parseInt&lt;/code&gt; function most often used to parse ints from the serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably want to set &lt;code&gt;myFile.setTimeout(0)&lt;/code&gt; first because the file isn't slowly getting characters from the serial bus, so the timeout would just slow you down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you should be able to parse and print out the ascii integers with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = myFile.parseInt();&#xA;Serial.println(val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-01-18T04:38:11.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8073" PostTypeId="1" AcceptedAnswerId="75348" CreationDate="2015-01-18T15:06:21.840" Score="1" ViewCount="7910" Body="&lt;p&gt;I'm looking for a complete pinout of the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardEthernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Ethernet R3&lt;/a&gt;.&#xA;I've found one &lt;a href=&quot;http://f1mvp.perso.sfr.fr/Robotic/arduino.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; which is low quality, and seems not complete (where are the digital I/O pins?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9mk4A.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, it was not a good idea for Arduino to name this board &quot;Arduino Ethernet&quot;, as this is pretty useless for searching online :-(&lt;/p&gt;&#xA;" OwnerUserId="6781" LastEditorUserId="26916" LastEditDate="2017-11-04T06:34:59.180" LastActivityDate="2020-05-01T18:11:15.633" Title="Where can I find a better pinout diagram for &quot;Arduino Ethernet&quot; board?" Tags="|pins|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8074" PostTypeId="1" CreationDate="2015-01-18T15:29:12.437" Score="1" ViewCount="761" Body="&lt;p&gt;Can I replace Atmega8 with Atmega328 in my freeduino board?&#xA;If so, let me know the steps needed.&lt;/p&gt;&#xA;" OwnerUserId="6782" LastEditorUserId="9962" LastEditDate="2016-02-15T05:44:07.077" LastActivityDate="2016-02-15T05:44:07.077" Title="Can I replace Atmega8 with Atmega328 in my freeduino board?" Tags="|atmega328|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8075" PostTypeId="2" ParentId="8073" CreationDate="2015-01-18T15:51:25.387" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardEthernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;formal Arduino.cc website&lt;/a&gt; mentions, somewhat obscurely, that the Arduino Ethernet is pin compatible with Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Revision 3 of the board introduces the standardized 1.0 pinout&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Except for pins 10-13:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pins 10, 11, 12 and 13 are reserved for interfacing with the Ethernet&#xA;  module and should not be used otherwise. This reduces the number of&#xA;  available pins to 9, with 4 available as PWM outputs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The other difference is the onboard LED is connected to pin 9 rather than the Uno's pin 13:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On most other arduino boards, this LED is found on pin 13. It is on pin 9 on the Ethernet board because pin 13 is used as part of the SPI connection.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use any Arduino Uno pinout diagram as a reference, the &lt;a href=&quot;http://marcusjenkins.com/wp-content/uploads/2014/06/ARDUINO_V2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;one you have found&lt;/a&gt; seems to be pretty elaborated. &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="26916" LastEditDate="2017-11-04T06:37:27.653" LastActivityDate="2017-11-04T06:37:27.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8076" PostTypeId="1" AcceptedAnswerId="8078" CreationDate="2015-01-18T16:36:44.863" Score="0" ViewCount="208" Body="&lt;p&gt;I'm having a hard time debugging this piece of code, and i'm hoping someone can point out where i am making the mistake.&lt;br&gt;&#xA;&lt;br&gt;&#xA;My serial output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;connected&#xA;GetData()&#xA;got data...&#xA;next stage...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;I've tested with a simple network client that loops sending a hello world, and it works fine. Every time this code halts after attempting to send a value to the &lt;code&gt;client&lt;/code&gt;. I know that  &lt;code&gt;getData()&lt;/code&gt; is causing the issue, but i cannot work out why, or how to best resolve it.&#xA;(apologies for the code dump, i want to be thorough)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;dht11.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;dht11 DHT11;&#xA;#define DHT11PIN 8&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;&#xA;IPAddress server(192,168,1,100);&#xA;IPAddress ip(192,168,1,50);&#xA;EthernetClient client;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;const int trigPin = 6;&#xA;const int echoPinOne = 7;&#xA;const int echoPinTwo = 8;&#xA;const int echoPinThree = 9;&#xA;const int echoPinFour = 10;&#xA;&#xA;&#xA;&#xA;void setup() { &#xA;  lcd.begin(16, 2);&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;&#xA;  //Network&#xA; if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;DHCP FAIL&quot;);&#xA;    Ethernet.begin(mac, ip);&#xA;  }&#xA;  delay(1000);&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;connecting&quot;);&#xA;  connect();  &#xA;}&#xA;&#xA;void connect(){&#xA;&#xA;    if (client.connect(server, 8080)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;connected&quot;);&#xA;&#xA;    client.println(&quot;hello server&quot;);&#xA;    client.println();&#xA;    delay(500);&#xA;    lcd.clear();&#xA;  } &#xA;  else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;Connection Failure&quot;);&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;&#xA;   //network&#xA;  if(!client.available()){&#xA;    Serial.println(&quot;lost connection!-restart&quot;);&#xA;    lcd.println(&quot;Disconnection&quot;);&#xA;    client.stop();&#xA;    connect();&#xA;  }&#xA;  else {&#xA;&#xA;    int inp[5];   &#xA;    getData(inp);&#xA;    Serial.println(&quot;next stage...&quot;);&#xA;    char *output = (char *) &amp;amp;inp[0];   &#xA;    client.println(output);&#xA;&#xA;    client.println(&quot;first&quot;);&#xA;&#xA;    Serial.println(&quot;sent first...&quot;);&#xA;&#xA;    //here repeats the same process for the other sensors - omitted for clear reading &#xA;&#xA;  }&#xA;   //end network&#xA;&#xA;   delay(500);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void getData(){&#xA;&#xA;&#xA;Serial.println(&quot;GetData()&quot;);&#xA;long durationThree, inchesThree, cmThree = 0;&#xA;long durationOne, inchesOne, cmOne = 0;&#xA;long durationTwo, inchesTwo, cmTwo = 0;&#xA;long durationFour, inchesFour, cmFour = 0;&#xA;&#xA;&#xA;&#xA;//SENSOR ONE&#xA;pinMode(trigPin, OUTPUT);&#xA;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigPin, LOW);&#xA;&#xA;pinMode(echoPinOne, INPUT);&#xA;durationOne = pulseIn(echoPinOne, HIGH);&#xA;&#xA;&#xA;delay(100);&#xA;&#xA;//SENSOR TWO&#xA;pinMode(trigPin, OUTPUT);&#xA;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigPin, LOW);&#xA;&#xA;pinMode(echoPinTwo, INPUT);&#xA;durationTwo = pulseIn(echoPinTwo, HIGH);&#xA;&#xA;delay(100);&#xA;&#xA;//SENSOR THREE&#xA;pinMode(trigPin, OUTPUT);&#xA;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigPin, LOW);&#xA;&#xA;&#xA;pinMode(echoPinThree, INPUT);&#xA;durationThree = pulseIn(echoPinThree, HIGH);&#xA;&#xA;&#xA;delay(100);&#xA;&#xA;&#xA;//SENSOR FOUR&#xA;pinMode(trigPin, OUTPUT);&#xA;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigPin, LOW);&#xA;&#xA;&#xA;pinMode(echoPinFour, INPUT);&#xA;durationFour = pulseIn(echoPinFour, HIGH);&#xA;&#xA;&#xA;//DISTANCE CALCULATION&#xA;cmOne = microsecondsToCentimeters(durationOne);&#xA;cmTwo = microsecondsToCentimeters(durationTwo);&#xA;cmThree = microsecondsToCentimeters(durationThree);&#xA;cmFour = microsecondsToCentimeters(durationFour);&#xA;//Serial.println(&quot;sending...&quot;);&#xA;//char *out = (char *) &amp;amp;cmOne;&#xA;//Serial.println(out);&#xA;//client.println(out);&#xA;//Serial.println(&quot;sent!&quot;);      used this to test - same issue&#xA;&#xA;Serial.println(&quot;got data...&quot;);&#xA;inputBuf[0] = cmOne;&#xA;inputBuf[1] = cmTwo;&#xA;inputBuf[2] = cmThree;&#xA;inputBuf[3] = cmFour;&#xA;&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;return microseconds / 29 / 2;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6318" LastActivityDate="2015-01-19T09:42:38.950" Title="data type error on sensor data to ethernet client" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8078" PostTypeId="2" ParentId="8076" CreationDate="2015-01-18T17:55:38.810" Score="0" Body="&lt;p&gt;The code you posted is performing incompatible casts and by thus is sending garbage to &lt;code&gt;client.println&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no automatic conversion in C/C++ from an array of integers (&lt;code&gt;int inp[]&lt;/code&gt;) or longs, to a C style string &lt;code&gt;char *&lt;/code&gt;. A C Style string should end with null terminator &lt;code&gt;\0&lt;/code&gt;, and the one in your code doesn't. For example, in this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *output = (char *) &amp;amp;inp[0]; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;inp[0]&lt;/code&gt; contains the first integer. The expression &lt;code&gt;&amp;amp;inp[0]&lt;/code&gt; contains the address of that integer in memory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus the cast to &lt;code&gt;(char *)&lt;/code&gt; will yield a malformed C style string, since it will not end with a null terminator, and more important, will not contain the data you expect it would (this cast is saying - &quot;hey, compiler, note that the &lt;em&gt;address&lt;/em&gt; of that &lt;code&gt;int&lt;/code&gt; is actually the address of a C style string&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, however, utilize the &lt;code&gt;String&lt;/code&gt; type constructor that receives int/long, and send the duration in order, something similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        void getData() &#xA;        {&#xA;            ... // rest of the code here&#xA;            client.println(String(cmOne));&#xA;            client.println(String(cmTwo));&#xA;            ... // etc.&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-19T09:42:38.950" LastActivityDate="2015-01-19T09:42:38.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8079" PostTypeId="1" AcceptedAnswerId="8083" CreationDate="2015-01-18T20:16:21.100" Score="0" ViewCount="43" Body="&lt;p&gt;I am trying to do an experiment with Arduino Uno r3 board plus a 2-channel relay shield. What I need to do is to alternatively turn on and off the relay shields. So, it requires multiple compile and upload of the program to assign values to corresponding pins. What I have seen by now is that uploading the program to Arduino is a kind of painful process and it requires nothing to be connected to pins 0 and 1 to prevent synchronization errors. So, I was wondering how I can do my experiment without having to mount/unmount relay shield each time I want to upload a new program into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance &lt;/p&gt;&#xA;" OwnerUserId="6784" LastActivityDate="2015-01-19T02:06:56.480" Title="Multiple upload/ Synchronization problem" Tags="|uploading|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8082" PostTypeId="2" ParentId="8074" CreationDate="2015-01-18T21:04:31.037" Score="2" Body="&lt;p&gt;Shouldn't be a problem. Some later versions already have a ATMega168 instead of the ATMega8. All three are pin-compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the arduino IDE you should however select a different board (one with a 328, like the UNO). That way the compiler knows the target MCU is the 328, and not the 8.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-18T21:04:31.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8083" PostTypeId="2" ParentId="8079" CreationDate="2015-01-19T02:06:56.480" Score="0" Body="&lt;p&gt;Well, you can write a program that takes numbers out of Serial input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin1 = Serial.parseInt();&#xA;int pin2 = Serial.parseInt();&#xA;// etc., etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simple.&lt;/p&gt;&#xA;" OwnerUserId="2899" LastActivityDate="2015-01-19T02:06:56.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8084" PostTypeId="1" CreationDate="2015-01-19T01:05:56.227" Score="4" ViewCount="2863" Body="&lt;p&gt;When I upload the code, the DC motor makes a humming noise, but doesn't turn.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;//2-Way motor control&#xA;&#xA;int motorPin1 =  5;    // One motor wire connected to digital pin 5&#xA;int motorPin2 =  6;    // One motor wire connected to digital pin 6&#xA;&#xA;// The setup() method runs once, when the sketch starts&#xA;&#xA;void setup()   {                &#xA;  // initialize the digital pins as an output:&#xA;  pinMode(motorPin1, OUTPUT); &#xA;  pinMode(motorPin2, OUTPUT);  &#xA;}&#xA;&#xA;// the loop() method runs over and over again,&#xA;// as long as the Arduino has power&#xA;void loop()                     &#xA;{&#xA;  rotateLeft(150, 500);&#xA;  rotateRight(50, 1000);&#xA;  rotateRight(150, 1000);&#xA;  rotateRight(200, 1000);&#xA;  rotateLeft(255, 500);&#xA;  rotateRight(10, 1500);&#xA;}&#xA;&#xA;void rotateLeft(int speedOfRotate, int length){&#xA;  analogWrite(motorPin1, speedOfRotate); //rotates motor&#xA;  digitalWrite(motorPin2, LOW);    // set the Pin motorPin2 LOW&#xA;  delay(length); //waits&#xA;  digitalWrite(motorPin1, LOW);    // set the Pin motorPin1 LOW&#xA;}&#xA;&#xA;void rotateRight(int speedOfRotate, int length){&#xA;  analogWrite(motorPin2, speedOfRotate); //rotates motor&#xA;  digitalWrite(motorPin1, LOW);    // set the Pin motorPin1 LOW&#xA;  delay(length); //waits&#xA;  digitalWrite(motorPin2, LOW);    // set the Pin motorPin2 LOW&#xA;}&#xA;&#xA;void rotateLeftFull(int length){&#xA;  digitalWrite(motorPin1, HIGH); //rotates motor&#xA;  digitalWrite(motorPin2, LOW);    // set the Pin motorPin2 LOW&#xA;  delay(length); //waits&#xA;  digitalWrite(motorPin1, LOW);    // set the Pin motorPin1 LOW&#xA;}&#xA;&#xA;void rotateRightFull(int length){&#xA;  digitalWrite(motorPin2, HIGH); //rotates motor&#xA;  digitalWrite(motorPin1, LOW);    // set the Pin motorPin1 LOW&#xA;  delay(length); //waits&#xA;  digitalWrite(motorPin2, LOW);    // set the Pin motorPin2 LOW&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xadP9.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why doesn't this work?&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I plugged it into a different port (5v) as it is a 5v motor, but now it only turns left, not right. It just hums when it goes right.&lt;/p&gt;&#xA;" OwnerUserId="6591" OwnerDisplayName="Pyraminx" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-01-21T19:11:14.010" Title="Why doesn't this motor turn?" Tags="|motor|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8085" PostTypeId="2" ParentId="8084" CreationDate="2015-01-19T01:11:17.550" Score="4" Body="&lt;p&gt;The IO drivers of most common logic chips or microprocessors such as the ATmega on your Arduino are nowhere near strong enough to drive typical electromagnetic motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To drive a motor, you should use a higher current switching device - a standard solution for bidirectional control being an H bridge part such as a TB6612FNG, L293D, L298, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are commonly sold on &quot;motor shields&quot; which you can plug into your Arduino, if you want to experiment with the concept before building something (and if you do want to build something, reviewing such a working schematic first would be a good idea).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can in theory put an L293D or its DIP-packaged work-alikes on your breadboard, but you will need some care to get it right, especially if you use one of the other parts which requires external catch diodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you should not be powering most motors from the Arduino's onboard regulator or a USB port, but rather should use an external power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;=============&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Responding to your edit, by  changing connections to place the the motor between one pin and the 5v supply, you have done two things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) You have made it so that the voltage difference across the motor can be applied in one direction only, therefore it can only rotate in one direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) You have made it so that only the N-channel MOSFET in an output driver is involved in powering the motor.  That change is &lt;em&gt;almost&lt;/em&gt; a useful idea, as N-channel devices are in fact much more capable than P-channel devices of similar dimension (and practical capacitance, voltage rating, and other tradeoffs) due to the greater mobility of negative charger carriers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this is still not really a solution, as it is unlikely that your motor's current rating is within even the current sink rating of the N-channel side of the ATmega output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a simple, unidirectional motor control, you could pursue this idea using one external N-channel MOSFET (or even a biploar NPN power transistor, which will be less efficient but also less delicate) to connect the unpowered side of the motor to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want bidirectional control, you will need either + and - power supplies, or four external switching devices taking the roles of the low current N-FET and P-FET totem poles inside each of the two on-chip IO pin drivers you started with. &lt;/p&gt;&#xA;" OwnerUserId="612" OwnerDisplayName="Chris Stratton" LastActivityDate="2015-01-19T01:37:58.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8086" PostTypeId="2" ParentId="8084" CreationDate="2015-01-19T02:39:40.247" Score="2" Body="&lt;p&gt;This is a huge simplification of @Chris Stratton's post, for beginners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To put it simply, the power that runs your motor is going through your arduino. Your arduino is not made to carry that sort of power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is an H-Bridge - see &lt;a href=&quot;https://itp.nyu.edu/physcomp/labs/motors-and-transistors/dc-motor-control-using-an-h-bridge/&quot; rel=&quot;nofollow&quot;&gt;https://itp.nyu.edu/physcomp/labs/motors-and-transistors/dc-motor-control-using-an-h-bridge/&lt;/a&gt; - the H Bridge is specially made to carry the power needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this page is for a 9v motor, not a 5v motor like yours - you will need to find a more appropriate power supply than a 9v battery (or, you need to find a 9v motor). If you try to power it through USB, you will be drawing the power through your computer - you may damage it! &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-19T02:39:40.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8087" PostTypeId="1" CreationDate="2015-01-19T03:17:33.077" Score="0" ViewCount="124" Body="&lt;p&gt;I'm new to Arduino. I'm using Arduino Mega 2560 board &amp;amp; MATLAB Simulink-Arduino support package and trying to integrate Maxbotix Sonar and Sharp IR sensor for my class project. When I powered single US sensor from Arduino 5V output, the readings are fine. However, when I tried to power IR sensor in parallel with US sensor, IR readings are fine but US readings fluctuate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I tried powering the sensors using BEC (5V-3A). The readings for both sensors are fluctuating(extremely noisy). From the specification mentioned by manufacturers, Maxbotix US sensor draws 2mA of current, whereas IR sensor averagely draws 20mA. Is there any way to solve this problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6789" LastActivityDate="2015-04-19T20:49:05.687" Title="Powering Infrared and Sonar sensors using BEC" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8088" PostTypeId="1" CreationDate="2015-01-19T05:30:55.607" Score="3" ViewCount="325" Body="&lt;p&gt;I've been wondering for a long time what these pins, labeled &lt;code&gt;ICSP&lt;/code&gt; and blank, do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OmgVp.png&quot; alt=&quot;arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't seem to find a diagram that explains them, so I've been wondering:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What are they for?&lt;/li&gt;&#xA;&lt;li&gt;Are they GPIO, or do they do something special?&lt;/li&gt;&#xA;&lt;li&gt;How can you use them?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help.&lt;/p&gt;&#xA;" OwnerUserId="6591" LastActivityDate="2015-01-19T05:51:42.803" Title="What do these pins on the Uno do?" Tags="|arduino-uno|pins|icsp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8089" PostTypeId="2" ParentId="8088" CreationDate="2015-01-19T05:51:42.803" Score="6" Body="&lt;p&gt;They're for programming, as well as carrying the non-select signals for SPI. The right one is for programming the main MCU, the left for the USB communication MCU. You should almost never need to use them unless you need to write a bootloader to a new chip or change the fuse or lock settings on them.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-19T05:51:42.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8091" PostTypeId="1" CreationDate="2015-01-19T07:59:35.100" Score="0" ViewCount="1359" Body="&lt;p&gt;I'm trying to keep track of a timer, and the internal variables seem to be overrun by one another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want two instances of the Output class, which can keep track of the _elapsed_time so I can check if the time elapsed. It's a poor-man's real-time for a game. I know there are libraries available and I'm planning to use them, but I would really appreciate knowing what's going on here: I want a buzzer pin, and status led pin to 'blink' at different intervals. They both work individually, but when I have them both uncommented they work somewhat serially...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;#include &quot;MTC.h&quot;&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;   //Software Serial Port&#xA;&#xA;//HARDWARE SETTINGS&#xA;#define PIN_STATUS                  13&#xA;#define PIN_BUZZER                  A2&#xA;&#xA;Output *STATUS(0);&#xA;Output *BUZZER;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    STATUS = new Output();&#xA;    STATUS-&amp;gt;Begin(PIN_STATUS, STATE_OFF);&#xA;    BUZZER = new (Output) Output(3);&#xA;    BUZZER-&amp;gt;Begin(PIN_BUZZER, STATE_OFF);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    static bool run_once = true;&#xA;&#xA;    if (run_once == true)&#xA;    {&#xA;        run_once = false;&#xA;        Serial.print(&quot;Running&quot;);&#xA;        Serial.flush();&#xA;    }&#xA;    delay(250);&#xA;&#xA;    //Serial.println(&quot;still running&quot;);&#xA;&#xA;    STATUS-&amp;gt;SetStrobe(3000);&#xA;&#xA;    //BUZZER-&amp;gt;SetStrobe(4000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MTC_h&#xA;#define MTC_H&#xA;&#xA;&#xA;typedef int OUTPUT_STATE;&#xA;OUTPUT_STATE STATE_OFF = 0;&#xA;OUTPUT_STATE STATE_ON = 1;&#xA;OUTPUT_STATE STATE_STROBE = 2;&#xA;&#xA;class Output&#xA;{&#xA;private:&#xA;    int _pin;&#xA;    OUTPUT_STATE _last_state;&#xA;    unsigned long _cycle_duration;&#xA;        unsigned long _last_elapsed;&#xA;&#xA;public:&#xA;    Output();                                           //constructor: set pin data store&#xA;    void Begin(int pin, OUTPUT_STATE state);                                //set hardware to output and defaul state&#xA;    void Set(OUTPUT_STATE state);                               //toggle operability&#xA;    void SetStrobe(unsigned long duration);                     //strobe operability&#xA;};&#xA;&#xA;Output::Output()                                    //constructor: set pin data store&#xA;{&#xA;&#xA;}&#xA;&#xA;void Output::Begin(int pin, OUTPUT_STATE state)&#xA;{&#xA;    _pin = pin;&#xA;        _last_elapsed = millis();&#xA;    pinMode(_pin, OUTPUT);&#xA;    digitalWrite(_pin, state);&#xA;    _last_state = state;&#xA;}&#xA;&#xA;void Output::Set(OUTPUT_STATE state)&#xA;{&#xA;    if (_last_state != state)&#xA;    {&#xA;        digitalWrite(_pin, state);&#xA;        _last_state = state;&#xA;    }&#xA;}&#xA;&#xA;void Output::SetStrobe(unsigned long duration)&#xA;{&#xA;    static OUTPUT_STATE _last_strobe_state = STATE_OFF;&#xA;&#xA;    unsigned long elapsed = millis() - _last_elapsed;&#xA;    if (elapsed &amp;gt;= duration)&#xA;    {&#xA;        if (_last_strobe_state == STATE_OFF)&#xA;        {&#xA;            digitalWrite(_pin, STATE_ON);&#xA;            _last_strobe_state = STATE_ON;&#xA;        }&#xA;        else&#xA;        {&#xA;            digitalWrite(_pin, STATE_OFF);&#xA;            _last_strobe_state = STATE_OFF;&#xA;        }&#xA;        _last_state = STATE_STROBE;&#xA;        _last_elapsed = millis();&#xA;    }&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6795" LastActivityDate="2015-03-23T16:07:22.163" Title="object with multiple instances with internal data store separate for each instance" Tags="|library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8092" PostTypeId="2" ParentId="179" CreationDate="2015-01-19T08:15:03.160" Score="6" Body="&lt;p&gt;I think there is another way to do this, without extracting the code from the Arduino board. Remenber the date you create the sketch, and look for it in  C:\Users\User\AppData\Local\Temp\&#xA;(For example : C:\Users\User\AppData\Local\Temp\untitled4390292704786567977.tmp\sketch_jan19a ). You could find your unsaved code unless it was deleted by some &quot;freeing space program&quot;.&#xA;Good luck! &lt;/p&gt;&#xA;" OwnerUserId="6796" LastActivityDate="2015-01-19T08:15:03.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8093" PostTypeId="1" CreationDate="2015-01-19T09:13:12.743" Score="3" ViewCount="8644" Body="&lt;p&gt;Apologies if I have missed a relevant post somewhere, but have search for days to try figure this out...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written some C# code to send a Byte Array over Serial from my PC to an Arduino Nano board (Through a USB to Serial Converter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would I not receive the same HEX Values (in the Arduino serial monitor) as the Values I sent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The Values should be the HEX for numbers 0 - 9)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C# Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(!serialPort1.IsOpen)&#xA;    {&#xA;        serialPort1.BaudRate = 9600;&#xA;        serialPort1.DataBits = 8;&#xA;        serialPort1.StopBits = System.IO.Ports.StopBits.One;&#xA;        serialPort1.Parity = System.IO.Ports.Parity.None;&#xA;        serialPort1.PortName = &quot;COM&quot; + cbCOMPort.Text;&#xA;&#xA;        serialPort1.Open();&#xA;    }&#xA;&#xA;    byte[] ByteArr = new byte[10];&#xA;    ByteArr[0] = 0x30; &#xA;    ByteArr[1] = 0x31;&#xA;    ByteArr[2] = 0x32;  &#xA;    ByteArr[3] = 0x33;&#xA;    ByteArr[4] = 0x34;&#xA;    ByteArr[5] = 0x35;&#xA;    ByteArr[6] = 0x36;&#xA;    ByteArr[7] = 0x37;&#xA;    ByteArr[8] = 0x38;&#xA;    ByteArr[9] = 0x39;&#xA;&#xA;&#xA;    serialPort1.Write(ByteArr, 0, ByteArr.Length);&#xA;    serialPort1.Close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;while (Serial.available()) {&#xA;delay(250);&#xA;&#xA;byte thisByte = Serial.read(); &#xA;&#xA;Serial.print(thisByte,HEX); &#xA;Serial.print(&quot; | &quot;);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Values received in Arduino Serial Monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;D6 | B6 | 96 | 76 | 56 | 36 | 16 | F6 | 8D | 0 |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;COMPLETE ARDUINO CODE WITH BLINKING LED TEST CODE &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;// start serial port at 9600 bps:&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;while (Serial.available()) {&#xA;delay(250);&#xA;// get the new byte:&#xA;byte thisByte = Serial.read(); &#xA;// add it to the inputString:&#xA;//inputString += char(intChar);&#xA;&#xA;if(thisByte == 0x30 || thisByte == 0x39)&#xA;{  &#xA;digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;delay(50);             // wait for a second&#xA;digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;}&#xA;Serial.print(thisByte,HEX); &#xA;Serial.print(&quot; | &quot;);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6797" OwnerDisplayName="BFG" LastEditorUserId="6797" LastEditDate="2015-01-19T12:35:16.320" LastActivityDate="2015-01-19T12:35:16.320" Title="Arduino Serial Hex Values" Tags="|serial|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8094" PostTypeId="1" CreationDate="2015-01-19T05:25:25.010" Score="0" ViewCount="1683" Body="&lt;p&gt;We are planning to drive conveyor belts with Arduino Unos using stepper motors. We are planning to use easy drivers, so that we control at least 3 motors with one Uno. Currently we are still at an initial stage, we are designing and planning the setup of conveyor belts. But what I wanted to ask was, regarding the coding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I code so that say the belt moves forward for &lt;code&gt;x&lt;/code&gt; seconds, and then after time it moves backwards for &lt;code&gt;y&lt;/code&gt; seconds. Any basic idea on the code would be great thank you. I could do the basic code, but I just need help with timers part.&lt;/p&gt;&#xA;" OwnerUserId="6813" OwnerDisplayName="riju" LastEditorUserId="6936" LastEditDate="2015-08-07T12:16:43.710" LastActivityDate="2015-08-07T12:16:43.710" Title="Driving conveyor belts using Arduino Unos" Tags="|avr|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8095" PostTypeId="1" CreationDate="2015-01-19T13:34:18.367" Score="3" ViewCount="1132" Body="&lt;p&gt;I have a problem with powering my LCD Keypad Shield from a DC cable (4 AA batteries or 9V battery). Everything looks good, but the LCD screen doesn't display anything. When I used a USB cable, the screen works as it should. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the problem?&lt;/p&gt;&#xA;" OwnerUserId="6800" LastEditorUserId="220" LastEditDate="2015-01-19T15:59:01.917" LastActivityDate="2017-09-24T00:27:44.290" Title="Problem with LCD keypad shield and Arduino Uno R3" Tags="|arduino-uno|power|lcd|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8096" PostTypeId="1" AcceptedAnswerId="8099" CreationDate="2015-01-19T09:28:42.277" Score="6" ViewCount="3699" Body="&lt;p&gt;Assuming we wish to control a small toy car with an arduino - meaning spinning the right and left wheels forward and backward and being able to break and control the speed, where each wheel has it's own engine (but of course two engines on the same side will run on the same speed and direction).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We saw we have two main options - Buying and wiring up a H-Bridge or buying a motor shield (which is based on one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any advantages for using a motor shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="6804" OwnerDisplayName="Avenger" LastEditorUserId="6452" LastEditDate="2015-01-21T22:22:45.427" LastActivityDate="2015-01-21T22:22:45.427" Title="H-Bridge vs Motor shield for the arduino" Tags="|motor|shields|arduino-motor-shield|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8098" PostTypeId="1" AcceptedAnswerId="8107" CreationDate="2015-01-19T14:55:48.330" Score="2" ViewCount="2012" Body="&lt;p&gt;I have a mircocontroller that's looking to be powered by a 5v source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to 'cypher off' some of this power from a 25 pin serial port, which is being powered by a constant power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any pins that could give me that sort of voltage, or enough to power the board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T8GlS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note, I'm &lt;strong&gt;not an electrical person&lt;/strong&gt; at all, and so hope this is actually possible (otherwise my 3 months + program's work doesn't really add to anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried a 9v battery, but it didn't seem to hold its charge? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm reading these labels going &quot;what the ...&quot; so you can probably tell coding the board wasn't the easiest, either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit History&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;I would like to clarify this is an &lt;strong&gt;existing serial lead&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;I understand this may be deemed verging off topic,&lt;/em&gt; &lt;em&gt;but due to the need to 'power' a&lt;/em&gt; &lt;em&gt;microcontroller, I thought this could be answered here&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;If this isn't possible, (as an alternative, possibly) would a 9V/battery be able to power this board reliably for around 2-3 weeks?&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6801" LastEditorUserId="6801" LastEditDate="2015-01-20T09:38:39.983" LastActivityDate="2015-01-20T10:34:00.823" Title="where to syphon off voltage from a 25 pin serial?" Tags="|serial|power|" AnswerCount="2" CommentCount="8" ClosedDate="2015-01-21T23:57:30.757" ContentLicense="CC BY-SA 3.0" />
  <row Id="8099" PostTypeId="2" ParentId="8096" CreationDate="2015-01-19T15:22:04.127" Score="6" Body="&lt;p&gt;If I were a beginner, I'd go with the Motor shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm even personaly using the one from DfRobot, which as @Gerben said, is just plug and play.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also allows you to select the input power for the motors, which can be either from the 5V Arduino pin or from an external battery. This is pretty convenient if you need more than 5V to power up your motors. It can also support 2A of current draw, which is more than enough for small arduino toy cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the shield: &lt;a href=&quot;https://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=1180&amp;amp;search=2A&amp;amp;description=true&quot; rel=&quot;noreferrer&quot;&gt;https://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=1180&amp;amp;search=2A&amp;amp;description=true&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3547" LastActivityDate="2015-01-19T15:22:04.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8100" PostTypeId="1" AcceptedAnswerId="8134" CreationDate="2015-01-19T15:27:12.643" Score="2" ViewCount="2455" Body="&lt;p&gt;Is using PWM tones from Arduino amplified by a HiFi amplifier safe? Can I damage the amplifier or speakers because the PWM signal is not a &amp;quot;real&amp;quot; audio signal? Taken in consideration that I do not clip the signal and using a RC Low Pass Filter to filter out inaudible frequencies and using a LM386 amplifier chip to amplify and control the volume?&lt;/p&gt;&#xA;&lt;p&gt;I am developing a synth/sampler project based on the Arduino Uno r3. This is my first electronics project ever and because of that reason I have some questions which I can't find a definite answer for on internet.&lt;/p&gt;&#xA;&lt;p&gt;The synth has two function. It has a tone generator using the ToneAC library. With code I have mimicked LFO and VCO functions, using potentiometers I can adjust the frequency and LFO speed realtime. The other function is that I can trigger samples stored on a SD card using the TMRpcm library. The lowest frequency which can be played is 100hz and the highest 3100hz.&lt;/p&gt;&#xA;&lt;p&gt;The device will be used in nightclubs on high end sound-systems and PA. I am afraid I will damage the equipment with my device because I do not send a pure audio (AC?) signal.&lt;/p&gt;&#xA;&lt;p&gt;Currently the flow is like this:&lt;/p&gt;&#xA;&lt;p&gt;PWM output (pin 9, 10) -&amp;gt; voltage divider to 2.5v -&amp;gt; RC Low Pass Filter 15Khz -&amp;gt; LM386 amp with volume control -&amp;gt; mono jack output -&amp;gt; mixing desk -&amp;gt; amplifier -&amp;gt; speakers&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;(the TMRpcm and ToneAC library share the same pin (9), I have fixed this by disabling the TMRpcm when the ToneAC is playing and vice versa. The mono jack is wired as follow. pin 9 goes to plus side of mono jack output, pin 10 to negative side. The TMRpcm pin 9 also needs to go to plus side of mono jack output, and mono jack negative needs to go to ground. Because I disable the ToneAC at that time I consider port 10 grounded because it not generating any sound so there is no signal/voltage running out of it, aka the IO pin is set to LOW)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I am hoping that using the voltage divider I am within range of the Audio Line levels of a default mixers Line-IN (like Pioneer, Behringer, etc). The RC Low Pass Filter is used to filter of inaudible frequencies and clean up the sound a bit, the LM386 audio amp is used to amplify the signal and (hopefully) make it a real audio signal.&lt;/p&gt;&#xA;&lt;p&gt;Because I lack a lot of knowledge in this field and because I do not own a oscilloscope I can't say for sure if my output signal is harmful for the equipment and was hoping to get some guidance on my project on this forum.&lt;/p&gt;&#xA;" OwnerUserId="6803" LastEditorUserId="33608" LastEditDate="2020-10-12T08:44:06.717" LastActivityDate="2020-10-12T08:44:06.717" Title="Arduino Uno synthesizer - Line Level (audio) output to mixer/amplifier" Tags="|arduino-uno|audio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8102" PostTypeId="1" CreationDate="2015-01-19T17:29:08.027" Score="-1" ViewCount="927" Body="&lt;p&gt;I want to connect an Android Galaxy S2 phone to my UNO Arduino using USB OTG functionality.&#xA;I can upgrade/root the android to any version I want. My goal is to be able to communicate between the devices (send/receive data).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to search for whether that's possible but found conflicting answers whether Galaxy S2 and the Arduino UNO would be able to be connected this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows whether this is possible? If yes - Do I need to do anything special - such as rooting the device, flashing it to a certain rom or something like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="6804" LastActivityDate="2017-08-24T13:54:22.553" Title="Connect Arduino to Galaxy S2 using USB OTG" Tags="|arduino-uno|android|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8103" PostTypeId="2" ParentId="8094" CreationDate="2015-01-19T17:59:35.833" Score="1" Body="&lt;p&gt;In regards to time control use the mills() function.  You start by creating an:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastTime = millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then later in the program create another variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long currentTime = millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next Compare the two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long elapsedTime = currentTime - lastTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the most part I normally just shorten the last two lines into one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long elapsedTime = millis() - lastTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Stepper motors are not needed if you are just doing timed control, but the advantage of stepper motors are you can move them with pin point accuracy based on the number of steps per rotation.  If there are 60 steps per rotation then 360 degrees per rotation/ 60 steps per rotation and you get that each step is 6 degrees.  So in order to turn the motor 6 degrees you would turn it 6 steps.  This also allows you to keep track of angular velocity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I control motors I normally create an array of the different parts of the cycle then loop through the array.&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="7508" LastEditDate="2015-03-20T21:46:17.197" LastActivityDate="2015-03-20T21:46:17.197" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8104" PostTypeId="1" CreationDate="2015-01-19T19:15:11.647" Score="0" ViewCount="533" Body="&lt;p&gt;I'm using this &lt;a href=&quot;https://github.com/CNMAT/OSC&quot; rel=&quot;nofollow&quot;&gt;OSC library&lt;/a&gt; and &lt;a href=&quot;http://hexler.net/software/touchosc&quot; rel=&quot;nofollow&quot;&gt;TouchOSC&lt;/a&gt; to controls some motors.&#xA;Right now I'm receiving those two kind of messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/u/1       // move motor 1 of default steps&#xA;/u/2       // move motor 2 of default steps&#xA;&#xA;/u/1/5     // move motor 1 of 5 steps&#xA;/u/3/25    // move motor 1 of 25 steps&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I have this piece of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  OSCMsgReceive();&#xA;}&#xA;&#xA;void OSCMsgReceive() {&#xA;&#xA;  OSCMessage msgIN;&#xA;  int size;&#xA;  if ((size = Udp.parsePacket()) &amp;gt; 0) {&#xA;    //Serial.println(&quot;incoming message.. &quot;);&#xA;    while (size--) {&#xA;      byte n = Udp.read();&#xA;      msgIN.fill(n);&#xA;      Serial.print((char)n);&#xA;    }&#xA;    Serial.println();&#xA;    if (!msgIN.hasError()) {&#xA;      msgIN.route(&quot;/u&quot;, up);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void upValueExtraction(char *ca, int &amp;amp;num_motor, int &amp;amp;num_step) {&#xA;    String s = String(ca);&#xA;    String num_motor_s = &quot;&quot;;&#xA;    String num_step_s = &quot;-1&quot;;&#xA;    int n = 0;&#xA;    for(int i=0; i&amp;lt;s.length(); i++) {&#xA;      char c = s[i];&#xA;      if(c=='\\') {&#xA;        n++;  &#xA;      }&#xA;      if(n==0) num_motor_s += c;&#xA;      if(n==1) num_step_s += c;&#xA;    }&#xA;    Serial.print(&quot;num motor: &quot;); Serial.println(num_motor_s.toInt());&#xA;    Serial.print(&quot;num step: &quot;); Serial.println(num_step_s.toInt());&#xA;&#xA;    num_motor = num_motor_s.toInt();&#xA;    num_step = num_step_s.toInt();&#xA;}&#xA;&#xA;&#xA;void up(OSCMessage &amp;amp;msg, int addrOffset) {&#xA;  static boolean flag = false;&#xA;  if (!flag) {&#xA;    Serial.print(&quot;route: up &quot;); Serial.println(addrOffset);&#xA;&#xA;    char ca[200];&#xA;    msg.getAddress(ca, addrOffset+1);&#xA;&#xA;    int num_motor, num_step;&#xA;    upValueExtraction(ca, num_motor, num_step);&#xA;&#xA;    if(num_step==-1) {&#xA;      num_step = defaul_steps;&#xA;    }&#xA;&#xA;    Serial.print(&quot;Have to move motor n &quot;);&#xA;    Serial.print(num_motor);&#xA;    Serial.print(&quot; of step &quot;);&#xA;    Serial.println(num_step);&#xA;  }&#xA;  flag = !flag;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if it is working and even if I'm using an Arduino DUE (much more memory then the UNO) I think it can be optimised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it contains some leeks? How can I better use the OSC matching part of the library? Any kind of &quot;embedded c++&quot; guidelines? Can I do everything inline without a &lt;code&gt;ca&lt;/code&gt; char array and &lt;code&gt;s&lt;/code&gt; String variables? Is better to use Arduino Lib &lt;code&gt;String&lt;/code&gt; class or plain old C str* functions? Any kind of comment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="1335" LastEditDate="2015-01-19T19:21:55.403" LastActivityDate="2015-03-17T22:18:37.583" Title="OSC parsing code. Can it be optimised?" Tags="|c++|arduino-due|c|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8105" PostTypeId="2" ParentId="8087" CreationDate="2015-01-19T19:17:51.457" Score="1" Body="&lt;p&gt;I've managed to solve the problem. When external power supply is used to power multiple sensors, connect the GND of that supply with that of the Arduino GND input. For more details, refer to the link below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html&quot; rel=&quot;nofollow&quot;&gt;http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6789" LastActivityDate="2015-01-19T19:17:51.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8106" PostTypeId="2" ParentId="8102" CreationDate="2015-01-19T20:15:15.110" Score="1" Body="&lt;p&gt;If you use a bluetooth serial module - e.g. google hc 06 - you can do it wirelessly. I have a had good results with this - you can hook it up to pins 0 &amp;amp; 1, then use the stock arduino serial code. Probably not a good idea to hook up to both the bluetooth module and the USB (e.g. for programming) at the same time, they may interfere with each other.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-19T20:15:15.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8107" PostTypeId="2" ParentId="8098" CreationDate="2015-01-19T20:20:31.253" Score="0" Body="&lt;p&gt;You should be able to use pin 7 for negative, 9 as positive, this gives you 12 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YOU MUST NOT HOOK THIS UP DIRECTLY to the arduino, connect it to a plug for the power jack (right of the USB connection).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using a USB -&gt; serial adapter, then the voltage may be 5v, but don't count on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, USB is always going to be better!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS - if you draw more power than the serial port is rated for, you will probably destroy the card. In most cases, this will be the motherboard. You are unlikely to be able to find out what it is rated for (look for Amps or A, or milliAmps  mA, or microAmps uA). The Arduino (with NO inputs or outputs, and idle) running from a 9v battery will draw about 50 milliAmps. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-20T00:23:15.953" LastActivityDate="2015-01-20T00:23:15.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8108" PostTypeId="1" CreationDate="2015-01-19T19:56:27.400" Score="2" ViewCount="753" Body="&lt;p&gt;I'm Tom. I'm pretty new to electronics and programming but I've been getting better. So, recently I bought a 93lC46B EEPROM from Element 14 (It was $0.28! Why not!). I've been doing some research and reading the datasheet VERY carefully. But I still can't get the EEPROM to work right. I'm using an Arduino Uno to program the chip by using the Bit-Banging method. So what I've understood is that I need to cycle the clock, then pull the CS (Chip select) to high and then cycle the clock after each bit like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(CLK, LOW);&#xA;digitalWrite(DATAIN, VALUE);&#xA;digitalWrite(CLK, High);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But so far, that method hasn't been working right. I can't seem to read or write to the device properly. I'm using this set of bits to write 1 and 2 to the first address of the ROM: 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code so far (Sorry in advance on how bad it is):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DATAOUT 11//Comes from DO on chip MISO&#xA;#define DATAIN 13 //Goes to DI on chip    MOSI&#xA;#define CLK 10&#xA;#define CS 9&#xA;&#xA;int data[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};&#xA;int inst1[] = {1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,1,1,0,0,1,0};&#xA;int inst2[] = {1,1,0,0,0,0,0,0,0};&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); //Start serial coms&#xA;&#xA;  pinMode(CS, OUTPUT);&#xA;  pinMode(DATAOUT, OUTPUT);&#xA;  pinMode(DATAIN, INPUT);&#xA;  pinMode(CLK, OUTPUT);&#xA;  digitalWrite(CS, LOW);&#xA;&#xA;  //Write 12 to address 1&#xA;  digitalWrite(CS, HIGH); //Enable device&#xA;  //Write to memory&#xA;  for(int i=0;i&amp;lt;25;i++){&#xA;    Write(inst1[i]);&#xA;  }&#xA;  digitalWrite(CS, LOW); //Disable device&#xA;  delay(250); //TCSL Delay&#xA;  Serial.print(&quot;Memory sucessfully written\n&quot;);&#xA;&#xA;  //Read memory&#xA;  digitalWrite(CS,HIGH); //Enable device&#xA;  for(int i=0;i&amp;lt;9;i++){&#xA;    Write(inst2[i]);&#xA;  }&#xA;  Serial.print(&quot;Read instruction written\n&quot;);&#xA;  for(int i=0;i&amp;lt;16;i++){&#xA;    saveBit(i);&#xA;  }&#xA;  for(int i=0;i&amp;lt;16;i++){&#xA;    Serial.print(data[i]+&quot;\n&quot;);&#xA;  }&#xA;  digitalWrite(CS,LOW);&#xA;  delay(250);&#xA;  Serial.print(&quot;Read successful!\n&quot;);&#xA;}&#xA;&#xA;void Write(int Bit){&#xA;  digitalWrite(CLK, LOW);&#xA;  if(Bit==0){&#xA;    digitalWrite(DATAIN, LOW);&#xA;  }&#xA;  if(Bit==1){&#xA;    digitalWrite(DATAIN, HIGH);&#xA;  }&#xA;  digitalWrite(CLK, HIGH);&#xA;  delay(1);&#xA;}&#xA;&#xA;void saveBit(int outbit){&#xA;  digitalWrite(CLK, LOW);&#xA;  if(digitalRead(DATAOUT) == HIGH){&#xA;    data[outbit] = 1;&#xA;  }&#xA;  if(digitalRead(DATAOUT) == LOW){&#xA;    data[outbit] = 0;&#xA;  }&#xA;  digitalWrite(CLK, HIGH);&#xA;  delay(1);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user3726825" LastActivityDate="2015-01-19T20:32:07.100" Title="Program/Read 93LC46B with an Arduino with bit-banging" Tags="|serial|eeprom|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8109" PostTypeId="1" CreationDate="2015-01-19T23:02:14.633" Score="2" ViewCount="85" Body="&lt;p&gt;Im trying to program my Arduino Due and it seems that I have to disconnect the display from it every time. Is there a work around for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im using a 7&quot; TFT with a CTE TFT LCD/SD Shield with a arduino due board.&lt;/p&gt;&#xA;" OwnerUserId="6294" LastActivityDate="2015-01-19T23:02:14.633" Title="How to program your Arduino Due while its connected to a display?" Tags="|shields|arduino-due|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8110" PostTypeId="1" CreationDate="2015-01-20T00:59:02.607" Score="2" ViewCount="1900" Body="&lt;p&gt;i am having an issue where i am unsure how my device knows what pins its using. Version #1 is a timeclock which is simply declared with no pin numbers. Version #2 is a simple loop with a device on pin A0; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can i set / change the pins for the clock to use. Currently it is on A4 &amp;amp; A5. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i wanted to move the clock to say pins.. A1 and A2, how would i do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version #1-------------------------------------------------&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Date and time functions using a DS1307 RTC connected via I2C and Wire lib&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 RTC;&#xA;&#xA;void setup () {&#xA;    Serial.begin(9600);&#xA;    Wire.begin();&#xA;    RTC.begin();&#xA;&#xA;  if (! RTC.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA; //   RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop () {&#xA;&#xA;    DateTime now = RTC.now();&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;    delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Version #2---------------------------------------------------------&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int powerswitch1 = A0;&#xA;void setup() &#xA;{&#xA;pinMode(powerswitch1, OUTPUT);&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;&#xA;digitalWrite(powerswitch1, HIGH);&#xA;delay(500);&#xA;digitalWrite(powerswitch1, LOW);&#xA;delay(500);&#xA;digitalWrite(powerswitch1, HIGH);&#xA;delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6811" LastEditorUserId="1585" LastEditDate="2015-01-20T01:23:51.947" LastActivityDate="2015-01-20T01:36:53.800" Title="how to know which pin is being used, change pin?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8111" PostTypeId="2" ParentId="8110" CreationDate="2015-01-20T01:36:53.800" Score="3" Body="&lt;p&gt;Your confusion is over the multiple functions of analog pins A4 and A5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to being analog pins, they are also the pins configured internally for I2C/TWI serial, which is interfaced with using the Wire library on arduino. Since those are the only two pins Wire can use, there is no need to specify them, the sketch just calls &lt;code&gt;Wire.begin()&lt;/code&gt; to set everything up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a second I2C device you can simply connect them both up to A4 and A5 at the same time, the protocol is designed to support that kind of thing. If you need to use A4 and A5 for something else besides I2C, you can't continue to use the hardware I2C library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use a software implementation of I2C/TWI serial on other pins, but usually soft-serial implementation have some drawbacks compared to the hardware version. There is an implementation on the arduino playground here: &lt;a href=&quot;http://playground.arduino.cc/Main/SoftwareI2CLibrary&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/SoftwareI2CLibrary&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, the RTC library you are using seems to internally use the Wire library, so it would take some hacking to switch it to a different I2C implementation. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-01-20T01:36:53.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8112" PostTypeId="2" ParentId="810" CreationDate="2015-01-20T02:34:28.627" Score="2" Body="&lt;p&gt;When considering optimization, think carefully about what resource is most valuable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can optimize for code size; this will let you put more code onto your processor. What will the rest of the space be used for? If your code doesn't fit onto your arduino, and your alternative is buying a larger chip, then this is worth the effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can optimize for speed - you can run more code in the same amount of time. If you are sampling data once per second, and sleeping the rest of the time, then this won't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can optimize for power usage - very important if you're on a battery, less important if you are on mains. This might also not just be power consumed by the arduino, but also sensors &amp;amp; motors - can they be turned off for a while?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two optimizations that a lot of programmers forget - optimizing for development time, and optimizing for readability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any optimization for one thing will tend to de-optimize for at least one (often several) other things. If you don't know which optimization is going to be most useful, then go for readability, then development time (because today's readability = tomorrow's development time x 10!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, the most expensive thing is the development time (i.e. YOUR time, especially if you are on the clock for a customer). Most other optimization has a threshold - so long as you are over (under?) a specific threshold, further optimization doesn't help. Code size and execution speed (except when shared between competing tasks) are like this - if your code fits on the chip, then it is small enough. If it needs to do something else later, you can optimize it then. If your program can do all it needs to (assuming it is real-time; calculating Pi is a different case), then that's as fast as it needs to be.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-20T02:34:28.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8114" PostTypeId="2" ParentId="8102" CreationDate="2015-01-20T09:17:13.047" Score="1" Body="&lt;p&gt;&lt;strong&gt;Method 1.&lt;/strong&gt; Basically you do not need root permission to communicate over USB. I am making app for Android for my project and using this &lt;a href=&quot;https://github.com/ksksue/FTDriver&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTDriver&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 2.&lt;/strong&gt; If you are not programming in JAVA then you can try third party apps like: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.primavera.arduino.listener&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno Communicator&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Uno doesn't have FT232 chip so I found it a bit harder. So instead I have FT232 chip and use &lt;code&gt;SoftwareSerial&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 3.&lt;/strong&gt; To communicate with Arduino you can use Bluetooth with HC-06 module. There are lots of third party apps to connect and send/receive data. &lt;a href=&quot;https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal&amp;amp;hl=en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bluetooth Terminal&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="19409" LastEditDate="2017-08-24T13:54:22.553" LastActivityDate="2017-08-24T13:54:22.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8115" PostTypeId="2" ParentId="8098" CreationDate="2015-01-20T10:34:00.823" Score="0" Body="&lt;p&gt;In a lot of further research, I have discovered that 'It doesn't really matter' what the serial port diagram says, since in 25 pin serials (and 9 pin D-subs), it all depends on the circuit at the other end, showing which wires are actually '&lt;em&gt;connected&lt;/em&gt;', or '&lt;em&gt;used&lt;/em&gt;'.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I managed to get &lt;em&gt;some&lt;/em&gt; current from +pin 6 -pin 5 in which allowed me to draw &lt;em&gt;some&lt;/em&gt; current, but have chosen to go with a (PP3?) 9v battery instead due to its reliability.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, in conclusion to this question, there isn't a specific answer, since it all depends on how the serial at the other end is wired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that in my case, there were minimal wires actually connected, so I was forced to look for other means of connecting to a 'reliable' power source.&lt;/p&gt;&#xA;" OwnerUserId="6801" LastActivityDate="2015-01-20T10:34:00.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8117" PostTypeId="1" AcceptedAnswerId="8119" CreationDate="2015-01-20T14:45:43.223" Score="0" ViewCount="684" Body="&lt;p&gt;I am trying to store temperature data in a variable, so that I can use it for making a JSON object, but the problem is, that when I try to store the temperature in a variable, it prints out the wrong value. I'm using a DHT11 temperature/humidity sensor and a library for calculating the temperature.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Temperature (°C): &quot;);&#xA;Serial.println((float)DHT11.temperature, DEC);&#xA;int temp1 = ((float)DHT11.temperature, DEC);&#xA;Serial.println(temp1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These 4 lines is printing out this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Temperature (Â°C): 23.0000000000&#xA;10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one is correct, but the second line should also be saying &quot;23&quot;.&#xA;I have tried only loading the data in once with the library, as in outcommenting one line, but that does not work.&#xA;It's like I have some syntax wrong, but I can't figure out what.&lt;/p&gt;&#xA;" OwnerUserId="6534" LastActivityDate="2015-01-20T16:01:11.183" Title="Can't store temperature in variable ( for further processing)" Tags="|arduino-uno|variables|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8119" PostTypeId="2" ParentId="8117" CreationDate="2015-01-20T15:07:58.643" Score="3" Body="&lt;p&gt;This line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;int temp1 = ((float)DHT11.temperature, DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;casts &lt;code&gt;DHT11.temperature&lt;/code&gt; to an &lt;code&gt;float&lt;/code&gt;, throws away the value, then assigns &lt;code&gt;DEC&lt;/code&gt; to &lt;code&gt;temp1&lt;/code&gt;. That is not what you want.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;int temp1 = DHT11.temperature;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-01-20T16:01:11.183" LastActivityDate="2015-01-20T16:01:11.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8124" PostTypeId="2" ParentId="8102" CreationDate="2015-01-20T19:47:50.953" Score="-1" Body="&lt;p&gt;In my opinion, you have to use this shield to do this: &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoUSBHostShield&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoUSBHostShield&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can't plug in to use Flash Memorys into Android Phones micro USB via OTG Cable. I guess, tablets and maybe phablets can do that because these devices have &lt;em&gt;USB Host Circuits&lt;/em&gt; inside. On the link, there is USB Host library for examples. This shield can attach onto your Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit: I have already tried to do this by doing right like you. I couldn't find any solution then I get the shield, but I still can not do to make any control from both Arduino Uno and my Android phone. Anyway, I know this is about our phones not to have USB Host Component&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2015-01-20T19:47:50.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8125" PostTypeId="2" ParentId="8058" CreationDate="2015-01-20T23:37:13.547" Score="6" Body="&lt;p&gt;Newest version of Arduino ide has a command line interface to build and upload code. But you can obviously do it by makefile and avrdude.&#xA;Now, you have compiled your code BUT you need testing.&#xA;As simulator are complex,incomplete, expansive and.. Just a simulation, and because the chip are relatively cheap, building a board witch will make HW interaction AND check the results its the fastest and easiest way.&#xA;On that &quot;special&quot; board you may upload something like an interpreter witch take a test from the PC and execute it, something similar to firmata for arduino.&#xA;At least that is how I would build it.&#xA;And as far as I know there are no know implementation of this, even if I'm quite sure many industries should and probably do that.&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-01-20T23:37:13.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8126" PostTypeId="2" ParentId="4292" CreationDate="2015-01-20T23:40:10.030" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;can I use NFR905 based RF modules which is also 434 Mhz to clone any&#xA;  existing remote working on 434 MHz.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer is, inevitably, no, you cannot. Each such remote controlled device might have a different digital modulation scheme. Best if you could focus on one specific product and adjust your design to fit it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the two products you are referring to are both 433Mhz but &lt;strong&gt;differ by many other parameters&lt;/strong&gt;, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supply voltage (5v vs 1.9v-3.6v)&lt;/li&gt;&#xA;&lt;li&gt;Interface (single digital output vs SPI)&lt;/li&gt;&#xA;&lt;li&gt;Capabilities (receiver vs  transceiver), &lt;/li&gt;&#xA;&lt;li&gt;Presence of a crystal&lt;/li&gt;&#xA;&lt;li&gt;Power consumption &lt;/li&gt;&#xA;&lt;li&gt;Price &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This might affect your final design as well, and should be taken into consideration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, from my experience, if you will shrink your project into a ATtiny85 at some stage, you might not have enough I/O pins to satisfy the NRF905, but enough for the Sparkfun's product (or a similar one).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but the range I get it very less , just around 5-6 centimeters.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The maximum range I got with the Sparkfun's module using a half-wave antenna (34cm) was ~40 &lt;strong&gt;meters&lt;/strong&gt; inside a building and about 80 meters in open air. My testings with quarter-wave length was about ~30 meters inside a building. &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-20T23:53:48.193" LastActivityDate="2015-01-20T23:53:48.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8128" PostTypeId="1" AcceptedAnswerId="46074" CreationDate="2015-01-21T00:09:45.697" Score="0" ViewCount="781" Body="&lt;p&gt;I am trying to modify the example given in the &lt;a href=&quot;http://shanes.net/another-nrf24l01-sketch-string-sendreceive/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; to a basic throughput and BER test with two nRF24L01+ and Teensy 3.0 modules. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to modify the nrf24l01_send_string example in a way that I can remove the powerUp powerDown and delay and transmit the next packet purely based on the ACK received from the receiver. The problem is &lt;a href=&quot;http://maniacbug.github.io/RF24/classRF24.html&quot; rel=&quot;nofollow&quot;&gt;RF24 class&lt;/a&gt; does not seem to have a method to transmit ACK (not ACK+Payload) and the datasheet does give any information on the structure of the ACK message. The example works when powerUp and powerDown are removed, but I need to modify it to measure throughput by removing the delay. &lt;/p&gt;&#xA;" OwnerUserId="6759" LastActivityDate="2017-10-31T07:59:47.323" Title="Throughput and BER test with nRF24L01+ radio and Teensy microcontroller" Tags="|arduino-uno|nrf24l01+|teensy|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8129" PostTypeId="1" CreationDate="2015-01-21T00:34:51.500" Score="1" ViewCount="3683" Body="&lt;p&gt;It's about the RF24 library you can find here. &lt;a href=&quot;http://maniacbug.github.io/RF24/index.html&quot; rel=&quot;nofollow&quot;&gt;http://maniacbug.github.io/RF24/index.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I transmit data from one Arduino to another using NRF24L01 radios.&#xA;When I use the write-function on the transmitter arduino (joystick is an array) and after that I put in a delay higher then 10, the available function returns false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transmitter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.write( joystick, sizeof(joystick) );&#xA;delay(20);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(!available())&#xA;  print('No data'); // delay &amp;gt; 10 --&amp;gt; No data will be printed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is it working with a delay of 10 but not above? Has it something to do with timeouts which is mentioned in the docs of the library?: &lt;a href=&quot;http://maniacbug.github.io/RF24/classRF24.html#a4cd4c198a47704db20b6b5cf0731cd58&quot; rel=&quot;nofollow&quot;&gt;http://maniacbug.github.io/RF24/classRF24.html#a4cd4c198a47704db20b6b5cf0731cd58&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your answers.&lt;/p&gt;&#xA;" OwnerUserId="6827" LastActivityDate="2021-06-21T07:39:51.500" Title="Arduino RF24 library Delay after write function causes no byte availability" Tags="|nrf24l01+|" AnswerCount="5" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="8130" PostTypeId="1" AcceptedAnswerId="8131" CreationDate="2015-01-21T00:50:00.560" Score="0" ViewCount="174" Body="&lt;p&gt;I was messing around with my arduino uno r3 and servo today. The book I got said to run the servo through the arduino. Everything was fine. I started changing the code, and then things started to get bad. I noticed that if I did not put a delay in between the servo movements, the board would freeze, and I would have to get lucky. Well now I just can't communicate with the board. I plug the board in to my pc, windows 7 makes the connection sound, the board turns on the ON light, the L light flashes, then goes steady. In the arduino software, the COM3 port, which is where I'm plugging it in, is not coming up. Only COM1 is there. I'm not sure what to do. The board is still functioning, the servo moves. I tried to plug it in with a different port and with the servo disconnected but it still doesn't want to communicate with my pc. The code I'm using is below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo1;&#xA;&#xA;void setup()&#xA;{&#xA;  servo1.attach(9);&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;  servo1.write(50);&#xA;  delay(500);&#xA;  servo1.write(90);&#xA;  delay(500);&#xA;  servo1.write(140);&#xA;  delay(1000);&#xA;&#xA;  for(int i = 50;i&amp;lt;140;i+=10){&#xA;    servo1.write(i);&#xA;    delay(10);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also like to add that I understand that you shouldn't run the servos through an arduino. I was following the book, and began researching when things went down hill.&lt;/p&gt;&#xA;" OwnerUserId="6829" OwnerDisplayName="JacksonML" LastActivityDate="2015-01-21T03:12:27.990" Title="Arduino cannot communicate with PC after running servo" Tags="|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8131" PostTypeId="2" ParentId="8130" CreationDate="2015-01-21T02:20:13.490" Score="2" Body="&lt;p&gt;I've had some problems in the past reprogramming my Arduino Uno if it writes to the serial port - I don't know if the problem is the same, but here's how I got around it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1: Hold down the reset switch, then plug your Arduino into the USB port. Select the right COM port (if needed), compile your code (something ultra simple, e.g. blink led), and then, JUST BEFORE IT STARTS UPLOADING, release the reset switch. Wash, rinse, repeat, until you get it to work, through blind luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2: Get hold of a ICSP (such as the one I got, USBASP made by FreeTronics  &lt;a href=&quot;http://www.freetronics.com.au/products/usbasp-icsp-programmer-for-avr-arduino#.VL8Vv3WjlIc&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/products/usbasp-icsp-programmer-for-avr-arduino#.VL8Vv3WjlIc&lt;/a&gt; which I am v. happy with), plug it into the serial port, plug the other end onto your Arduino UNO ICSP header (6 pins, opposite end of the board from USB), then select Tools -&gt; Burn Bootloader. Overwrites any program, works 100% of the time. Now you can unplug your USBASP, and plug your Uno back in and program it normally. This is also a great tool if you end up using AtMega (or AtTiny) chips directly (AtMega is the chip used to do all the work on the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this, I have gotten into the habit of putting a 5 second delay as the first thing in the startup code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FOR FUTURE GENERATIONS: I got mine here in New Zealand, so that will probably not help most people. FreeTronics makes them, and I am very happy I got their one (they have a &quot;slow clock&quot; jumper that is very convenient when programming Atmel chips not on an Arduino board), I expect that any USBASP would do the trick too - in response to the question, Amazon has a couple under $4, and I expect that the price will not go up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search for &quot;USBASP&quot;. Make sure you get a ribbon cable. For Arduino Uno, you need a 6-pin ribbon cable. It is also possible to use these cables to communicated directly with a running Arduino over these same pins.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-21T03:12:27.990" LastActivityDate="2015-01-21T03:12:27.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8134" PostTypeId="2" ParentId="8100" CreationDate="2015-01-21T11:43:16.127" Score="3" Body="&lt;p&gt;In theory, the peak signal accepted from your amplifier should be 0.894V p2p if you want to rescpect the common -10dB signal strength/level. I don't know why you would want to have a 5V to 2.5V &quot;voltage divider&quot; in the first place, but in any case if you use that you already limit the current probably enough, it all depends on the resistor values used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the LM386 amplifier is also simply not required at all, since the Arduino is already providing more than enough power. If you want to tune the volume at that stage, simply combine all functions (volume, low pass and current limit) by connecting the 5V PWM output thru a resistor (eg. 4k7) to a POT (eg. 1k) in parallel with the capacitor (eg.2n2) would give you approximately what you want. Then to remove de DC component, add a series capacitor (eg. 1uF) and you're all set. You may still hear a &quot;click&quot; when you connect it to the amplifier though, so keep the faders low when connecting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you can adapt the values quite liberally, but these values are both safe and should be close to what is needed (cutoff 15kHz, Vpp 0.88V max).&lt;/p&gt;&#xA;" OwnerUserId="6835" LastEditorUserId="6835" LastEditDate="2015-01-21T11:51:30.140" LastActivityDate="2015-01-21T11:51:30.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8135" PostTypeId="1" CreationDate="2015-01-21T12:13:19.113" Score="0" ViewCount="363" Body="&lt;p&gt;I am making a basic project that will have 4 or 5 arduino nodes. Each arduino will have a bluetooth module attached. The thing I want is, I want to be able for each one of these arduinos to know the other is present in the room (let's say, 5 meters). For my experience in the cellphone, I don't even have to pair bluetooth devices to know about their presence, as long as they are in visible mode. Since I just need to know their presence, and no exchange of information will ever happen, I probably will never have to pair them right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this project I need a bluetooth (BT) module that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Enables me to change the ID of each arduino, so that, even if I use my cellphone to scan for BT devices I will see (Arduino1, Arduino2, etc...) instead of default-factory-names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Enables me to scan around for existing devices every time each X seconds, because I want each arduino to know if the others are in the room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this module do the trick? &lt;a href=&quot;http://www.ebay.co.uk/itm/Interface-Base-Board-Serial-Transceiver-Bluetooth-Module-For-Arduino-UNO-R3-/111482008102?pt=UK_BOI_Electrical_Components_Supplies_ET&amp;amp;hash=item19f4d87226&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/Interface-Base-Board-Serial-Transceiver-Bluetooth-Module-For-Arduino-UNO-R3-/111482008102?pt=UK_BOI_Electrical_Components_Supplies_ET&amp;amp;hash=item19f4d87226&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later I will probably hang around with batteries so I will want a low power BT module, having the same 2 capabilities mentioned. Will NRF8001 do the trick for me? &lt;a href=&quot;http://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF8001&quot; rel=&quot;nofollow&quot;&gt;http://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF8001&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="1496" OwnerDisplayName="nemewsys" LastActivityDate="2016-01-12T16:48:24.493" Title="Is this Bluetooth module cool for Arduino?" Tags="|rf|bluetooth|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8136" PostTypeId="1" CreationDate="2015-01-21T12:31:25.640" Score="5" ViewCount="12453" Body="&lt;p&gt;I have googled all around and I know about some tricks to make ATmega328 not being a power hog. I am using &lt;strong&gt;Arduino Nano V3.0&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I didn't find out what is the minimal consumption possible with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project consists of an Arduino that will wake up each 10 seconds and, by bluetooth (BT) will scan for existing devices, and if one specific device is not listed, it will lit a LED for 5 seconds and then go to sleep again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In sum:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Sleep for 10 secs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wake up&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Scan for BT devices&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If device ABC is in the list go to 1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Lit LED&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Delay 5 secs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to 1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For bluetooth I will use &lt;strong&gt;NRF8001&lt;/strong&gt;, because it is the most efficient BT module I know so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you give me some ideas of what tricks should I use to make this ATmega328 and BT module last like one year with a &lt;strong&gt;500mAh battery&lt;/strong&gt;? Has anyone tried this that can share his experience? Is ATmega328 the right uC for this? I am using it just because I already have code/libraries for it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Creating the new tag 'nrf8001' requires at least 150 reputation. Try something from the existing tags list instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="1496" LastEditorUserId="6936" LastEditDate="2016-02-18T12:30:11.417" LastActivityDate="2018-12-30T19:09:18.083" Title="Lowest power possible in Arduino" Tags="|power|bluetooth|arduino-nano|atmega328|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8137" PostTypeId="2" ParentId="8135" CreationDate="2015-01-21T12:34:12.707" Score="1" Body="&lt;p&gt;From skimming that post, I believe that your linked pcb is not a full bluetooth module (note how there is no bluetooth chip or antenna of any kind). This is simply a &quot;base board,&quot; which is why it is so cheap&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need &lt;a href=&quot;http://www.ebay.com/itm/Wireless-Serial-4-Pin-Bluetooth-RF-Transceiver-Module-Backplane-RS232-F-Arduino-/261024370087?pt=LH_DefaultDomain_0&amp;amp;hash=item3cc643cda7&quot; rel=&quot;nofollow&quot;&gt;something like this&lt;/a&gt; that actually has the components you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The bluetooth library for arduino sets the discoverale name to ARDUINOBT by default, but that can be changed in the setup() method.  &lt;/li&gt;&#xA;&lt;li&gt;&quot;scan around&quot; is a little ambiguous—AFAIK, bluetooth can only connect to one device at a time, but I'm not sure if that's totally true. You may want to look into using radios instead of BT, as they can communicate more freely with one another, are extremely cheap, and have extensive arduino libraries availible. I'm currently working on a project that uses the &lt;a href=&quot;http://www.ebay.com/itm/2PCS-Arduino-NRF24L01-2-4GHz-Wireless-Transceiver-Module-New-/170819064718?pt=LH_DefaultDomain_0&amp;amp;hash=item27c59c138e&quot; rel=&quot;nofollow&quot;&gt;nRF24L01&lt;/a&gt;, and I'd be happy to answer any questions you have about it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1: It also has a draw of 6v VCC, which is more than the Uno can output.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="6836" LastActivityDate="2015-01-21T12:34:12.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8138" PostTypeId="2" ParentId="8135" CreationDate="2015-01-21T12:42:17.477" Score="0" Body="&lt;p&gt;The first link is for a &lt;strong&gt;breakout board only&lt;/strong&gt; - it has a &lt;strong&gt;placeholder&lt;/strong&gt; for a BT module, similar to the &lt;a href=&quot;http://www.rcscomponents.kiev.ua/datasheets/hc_hc-05-user-instructions-bluetooth.pdf&quot; rel=&quot;nofollow&quot;&gt;HC Bluetooth models series&lt;/a&gt;, but it is n&lt;em&gt;ot a complete Bluetooth board&lt;/em&gt; (hence the &quot;Interface Base Board&quot; in the product's title). Please do not do that mistake - I did it already :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your purposes, it seems that something similar to the cheap &lt;a href=&quot;ftp://imall.iteadstudio.com/BLOG/2010_07/More_Powerful_Serial_Port_Bluetooth_Module_MasterSlave.pdf&quot; rel=&quot;nofollow&quot;&gt;HC-05&lt;/a&gt; can satisfy both requirements: You can change the device name, and perform inquiry to scan other Bluetooth devices' MAC address, both using AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has low operation voltage (1.8v-3.6v), but it operates as the good-old 2.1 Bluetooth standard, which waste a LOT of energy while running. If power consumption is a prime requirement, you might want to consider the more expensive Bluetooth low energy, such as a breakout board for the chip you suggested (the NRF8001).&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-21T12:50:43.747" LastActivityDate="2015-01-21T12:50:43.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8139" PostTypeId="1" CreationDate="2015-01-21T07:16:43.977" Score="1" ViewCount="262" Body="&lt;p&gt;I am starting with Arduinos, coming from the world of Linux (with the RPi as a bridge) and after having tested some setups I now wonder where to go next in implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to understand is whether it is recommended (time and cost-wise) &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup?&lt;/li&gt;&#xA;&lt;li&gt;or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I expect to build 5 or 6 of the same simple setups (to put in various places in my house).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: there is a &lt;a href=&quot;https://electronics.stackexchange.com/questions/64280/what-make-now-that-i-have-implemented-a-working-prototype-of-my-system&quot;&gt;similar question&lt;/a&gt; (with almost the same title) but it deals with the legal aspects of commercializing a setup.&lt;/p&gt;&#xA;" OwnerUserId="7889" OwnerDisplayName="WoJ" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-28T21:57:30.993" Title="How to &quot;implement&quot; an Arduino prototype?" Tags="|prototype|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8140" PostTypeId="1" AcceptedAnswerId="8141" CreationDate="2015-01-21T12:47:46.503" Score="0" ViewCount="1230" Body="&lt;p&gt;I have a working project on Arduino Uno.Now I want to shrink my project using an ATtiny85. Before purchasing an waiting for the shipment to arrive, I want to make sure that my whole code will run on ATtiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;specialy, will the map() function which is working on  an Arduino Uno ( ATMEGA328P-PU ),  work with a ATtiny85 Microcontroller?&lt;/p&gt;&#xA;" OwnerUserId="6837" LastActivityDate="2015-01-21T12:58:40.540" Title="Does the map() function works on an ATtiny85?" Tags="|attiny|map|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8141" PostTypeId="2" ParentId="8140" CreationDate="2015-01-21T12:58:40.540" Score="3" Body="&lt;p&gt;The &lt;code&gt;map&lt;/code&gt; function uses integer arithmetic, and since the ATmega series and the ATtiny series use the same 8-bit AVR instruction set, there should be no difference when using it, and you are good to go from that aspect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider that there are many other differences regarding I/O pins, storage etc. - that you might want to consider. &lt;a href=&quot;https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328&quot; rel=&quot;nofollow&quot;&gt;Here is a good source&lt;/a&gt; for a basic comparison between the ATmega based Arduino to ATtiny85.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-01-21T12:58:40.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8142" PostTypeId="2" ParentId="8136" CreationDate="2015-01-21T13:08:32.763" Score="1" Body="&lt;p&gt;Lowest possible power consumption for an Arduino is 0mA - just disconnect it's Vcc :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And seriously, when there are many factors involved, it is hard to include all of them into the proper equations, considering different factors that affect the current consumption such as temperature, humidity, quality and distance of the wires etc. Best would be to perform measurements of the power consumption for, say, several cycles of steps 1 to 7, and do the average. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that the ATmega chip will draw more current depending on the voltage, so you might want to keep voltage as low as possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://harizanov.com/2012/10/funky-as-remote-temperature-sensing-node-with-ds18b20/&quot; rel=&quot;nofollow&quot;&gt;Here is a nice project&lt;/a&gt; of an ATtiny (Arduino alike) that runs on a coin CR2032 battery (~200mAh) for &lt;strong&gt;220 days&lt;/strong&gt; until it died, while wirelessly broadcasting the results and the measurements of the battery discharge rate, so you could actually achieve pretty good results working with a 500mAh battery. &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-21T17:03:40.200" LastActivityDate="2015-01-21T17:03:40.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8143" PostTypeId="1" CreationDate="2015-01-21T13:24:20.337" Score="1" ViewCount="1333" Body="&lt;p&gt;I would like to do an HTTP POST to Carriots. I saw a few tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of them are using ethernet instead of WiFi. I realize the ways of using Arduino WiFi shield and WizFi Shield are a bit different. What do I need to do to run a basic server using the WizFi Shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/******************************************************************&#xA; WizFiShield Web Client Test Example&#xA;*****************************************************************/&#xA;&#xA;// WizFiShield communicates using SPI, so include the SPI library:&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WizFi2x0.h&amp;gt;&#xA;#include &amp;lt;WizFiClient.h&amp;gt;&#xA;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;#define SSID    &quot;EricLeong3&quot;        // SSID of your AP&#xA;#define Key     &quot;ericChoong91&quot;  // Key or Passphrase&#xA;// Wi-Fi security option (NO_SECURITY, WEP_SECURITY, WPA_SECURITY, WPA2PSK_SECURITY)&#xA;#define Security        WPA2PSK_SECURITY&#xA;#define APIKEY  &quot;xxxxxxxxx&quot; // Replace with your Carriots apikey&#xA;#define DEVICE  &quot;fypSensors@eric3231559.eric3231559&quot;&#xA;&#xA;WizFi2x0Class myWizFi;&#xA;WizFiClient myClient;&#xA;TimeoutClass ConnectInterval;&#xA;boolean Wifi_setup = false;&#xA;&#xA;///////////////////////////////&#xA;// 1msec Timer&#xA;void Timer1_ISR() {&#xA;  myWizFi.ReplyCheckTimer.CheckIsTimeout();&#xA;}&#xA;//&#xA;//////////////////////////////&#xA;&#xA;void setup() {&#xA;  byte retval;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;\r\nSerial Init&quot;);&#xA;  // initalize WizFi2x0 module:&#xA;  myWizFi.begin();&#xA;  ConnectInterval.init();&#xA;  // Socket Creation with Server IP address and Server Port num &#xA;  myClient =  WizFiClient(&quot;82,223,244,60&quot;, 80);&#xA;  // Timer1 Initialize&#xA;  Timer1.initialize(1000); // 1msec&#xA;  Timer1.attachInterrupt(Timer1_ISR);&#xA;  myWizFi.SendSync();&#xA;  myWizFi.ReplyCheckTimer.TimerStart(3000);&#xA;  Serial.println(&quot;Send Sync data&quot;);&#xA;  while(1) {&#xA;    if(myWizFi.CheckSyncReply()) {&#xA;      myWizFi.ReplyCheckTimer.TimerStop();&#xA;      Serial.println(&quot;Rcvd Sync data&quot;);&#xA;      break;&#xA;    }&#xA;    if(myWizFi.ReplyCheckTimer.GetIsTimeout()) {&#xA;      Serial.println(&quot;Rcving Sync Timeout!!&quot;);&#xA;      // Nothing to do forever;&#xA;      for(;;)&#xA;      ;&#xA;    }&#xA;  }&#xA;  ////////////////////////////////////////////////////////////////////////////&#xA;  // AP association  &#xA;  while(1) {&#xA;    retval = myWizFi.associate(SSID, Key, Security, true);&#xA;    if(retval == 1) {&#xA;      Serial.println(&quot;AP association Success&quot;);&#xA;      Wifi_setup = true;&#xA;      break;&#xA;    } else {&#xA;      Serial.println(&quot;AP association Failed&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;apleleee &quot;);&#xA;  uint8_t retval;&#xA;  retval = myClient.connect();&#xA;  if(retval == 1) {&#xA;    String json = &quot;{\&quot;protocol\&quot;:\&quot;v2\&quot;,\&quot;device\&quot;:\&quot;&quot;+String(DEVICE)+&quot;\&quot;,\&quot;at\&quot;:\&quot;now\&quot;,\&quot;data\&quot;:{\&quot;Air Temperature\&quot;:\&quot;58\&quot;,\&quot;Humidity\&quot;:\&quot;59\&quot;}}&quot;;&#xA;    Serial.println(&quot;Connected! &quot;);&#xA;    //myClient.write((byte *)&quot;GET /search?q=WizFi210 HTTP/1.0\r\n\r\n&quot;);&#xA;    myClient.write((byte *)&quot;POST /streams HTTP/1.1&quot;);&#xA;    myClient.write((byte *)&quot;Host: api.carriots.com&quot;);&#xA;    myClient.write((byte *)&quot;Accept: application/json&quot;);&#xA;    myClient.write((byte *)&quot;User-Agent: Arduino-Carriots&quot;);&#xA;    myClient.write((byte *)&quot;Content-Type: application/json&quot;);&#xA;    myClient.write((byte *)&quot;carriots.apikey: &quot;);&#xA;    myClient.write((byte *)APIKEY);&#xA;    myClient.write((byte *)&quot;Content-Length: &quot;);&#xA;    byte thisLength = json.length();&#xA;    myClient.write(thisLength);&#xA;    myClient.write((byte *)&quot;Connection: close&quot;);&#xA;    myClient.write((byte *)&quot;&quot;);&#xA;    myClient.write((byte *)&quot;{\&quot;protocol\&quot;:\&quot;v2\&quot;,\&quot;device\&quot;:\&quot;&quot;);&#xA;    myClient.write((byte *)DEVICE);&#xA;    myClient.write((byte *)&quot;\&quot;,\&quot;at\&quot;:\&quot;now\&quot;,\&quot;data\&quot;:{\&quot;Air Temperature\&quot;:&quot;);&#xA;    myClient.write((byte *)&quot;58&quot;);&#xA;    myClient.write((byte *)&quot;,\&quot;Humidity\&quot;:&quot;);&#xA;    myClient.write((byte *)&quot;59&quot;);&#xA;    myClient.write((byte *)&quot;}}&quot;);&#xA;  } else&#xA;    Serial.println(&quot;Connection Failed&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The response I get on the serial monitor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial Init&#xA;Send Sync data&#xA;Rcvd Sync data&#xA;AT&#xA;&#xA;Rcvd Reply: [ERROR]&#xA;[ERROR]&#xA;Timeout  with ERROR reply&#xA;AP association Failed&#xA;AT&#xA;&#xA;Rcvd Reply: õAT&#xA;õAT&#xA;-1&#xA;&#xA;Rcvd Reply: [ERROR: INVALID INPUT]&#xA;[ERROR&#xA;INVALID&#xA;INPUT]&#xA;-1&#xA;&#xA;Rcvd Reply: AT&#xA;AT&#xA;-1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;ATE0&#xA;&#xA;Rcvd Reply: ATE0&#xA;ATE0&#xA;-1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+XDUM=0&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+BDATA=1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+WD&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+WM=0&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+WPAPSK=EricLeong3,ericChoong91&#xA;&#xA;Rcvd Reply: Computing PSK from SSID and PassPhrase...&#xA;Computing&#xA;PSK&#xA;from&#xA;SSID&#xA;and&#xA;PassPhrase...&#xA;-1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+NDHCP=1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AT+WA=EricLeong3&#xA;&#xA;Rcvd Reply:     IP              SubNet         Gateway   &#xA;    IP              SubNet         Gateway   &#xA;IP&#xA;SubNet&#xA;Gateway&#xA;&#xA;Rcvd Reply:  192.168.1.42: 255.255.255.0: 192.168.1.1&#xA; 192.168.1.42: 255.255.255.0: 192.168.1.1&#xA;192.168.1.42&#xA;192.168.1.42&#xA;255.255.255.0&#xA;255.255.255.0&#xA;192.168.1.1&#xA;192.168.1.1&#xA;&#xA;Rcvd Reply: [OK]&#xA;[OK]&#xA;AP association Success&#xA;apleleee &#xA;AT+DNSLOOKUP=82,223,244,60,3,5&#xA;&#xA;Rcvd Reply: [ERROR: INVALID INPUT]&#xA;Token: [ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;May I know what's wrong with the code? Why does it show a token error instead of success? What I am trying to do is posting an HTTP POST request to Carriots, which is a place to do my m2m things. I am still wondering which part I am missing. I referred to few sources such as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.carriots.com/index.php/topic/61-wireless-gardening-with-arduino-cc3000-wifi-modules/page-2&quot; rel=&quot;nofollow&quot;&gt;http://forum.carriots.com/index.php/topic/61-wireless-gardening-with-arduino-cc3000-wifi-modules/page-2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Wiznet/WizFiShield&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Wiznet/WizFiShield&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6839" LastEditorUserId="4628" LastEditDate="2015-11-26T14:46:46.773" LastActivityDate="2015-12-26T19:43:16.717" Title="Arduino + WizFi 210 (WiFi) HTTP POST" Tags="|arduino-mega|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8144" PostTypeId="1" CreationDate="2015-01-21T13:35:54.023" Score="0" ViewCount="929" Body="&lt;p&gt;I'm trying to get the TinySine SIM900 GPRS Shield working to get data over the GPRS network, using Arduino MEGA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm Able to register my SIM with this Shield and even , but as soon as I sent the command AT+CIICR to Bring up the Wireless Coms, the Shiled powers down, all LEDs are OFF except the Red one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the source of the Problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="6840" LastActivityDate="2015-04-22T06:28:10.013" Title="SIM900 GRPS Shield Power down over issue AT+CIICR cmd(Bring Wireless Coms)" Tags="|arduino-mega|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8146" PostTypeId="2" ParentId="8136" CreationDate="2015-01-21T14:59:53.757" Score="6" Body="&lt;p&gt;The issues regarding efficiency of power are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The CPU speed&lt;/li&gt;&#xA;&lt;li&gt;The Voltage &lt;/li&gt;&#xA;&lt;li&gt;The Power Regulator (not supply)&lt;/li&gt;&#xA;&lt;li&gt;The Peripherals&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Address each one of these and don't over look any of them. Or any sub component. But note that some are more impacting than others.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;while it is possible to lower the speed, It is more practical to just sleep. As you have indicated you are going to do.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Running at 3V instead of 5V is a big savings. Note that the 328 can run as low as 1.8V&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;DON'T use Linear Regulators. Most all Arduino's have a 7-12V to 5V(or 3.3V) Linear Regulator. This just burns the difference between the supply (aka battery) and the VCC, used.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;pay attention to the peripherals. Likely this means getting rid of not needed devices. Example the USB to Serial chip that exists on the Nano. What is the lowest voltage can the radio run at? Must it run at a regulated voltage. Use the largest possible resistor values. Such as on pull ups. A 500K pull up will draw less current than a 10K. Where if too big any capacitance may slow it down. Which is likely acceptable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One of the biggest savings is running directly off of the Battery without a Linear Regulator. Where the ATmega328P can run from 3V down to 1.6V. It would be recommend to use the Brown Out detector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that ALL batteries have a self discharge rate.  This will determine the maximum possible life of the battery, then minus your devices consumption.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-01-21T14:59:53.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8148" PostTypeId="1" AcceptedAnswerId="8150" CreationDate="2015-01-21T16:33:39.377" Score="8" ViewCount="3360" Body="&lt;p&gt;Behold this insanity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum WhatArduinoIs {&#xA;  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed&#xA;};&#xA;&#xA;void TellMe(WhatArduinoIs pls) { }&#xA;&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm pretty good at C++, so I'm fairly sure that should compile. However I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sketch_jan21b.ino:3:13: error: variable or field 'TellMe' declared void&#xA;sketch_jan21b.ino:3:13: error: 'WhatArduinoIs' was not declared in this scope&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've encountered the Arduino &quot;IDE&quot;'s propensity for insane and totally unrobust modification of programs before. Specifically when you &lt;code&gt;#include&lt;/code&gt; libraries Arduino only magically adds the relevant C++ files if the &lt;code&gt;#include&lt;/code&gt; is in your main sketch. &lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;/code&gt; in another C++ file? Link errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect in this case it is Arduino magically trying to add function declarations to the start of the file so their order doesn't matter. I.e. it turns the file into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void TellMe(WhatArduinoIs pls);&#xA;&#xA;enum WhatArduinoIs {&#xA;  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed&#xA;};&#xA;&#xA;void TellMe(WhatArduinoIs pls) { }&#xA;&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That obviously doesn't work. How can I tell Arduino to leave my damn program alone?&lt;/p&gt;&#xA;" OwnerUserId="6770" LastActivityDate="2015-07-11T06:06:59.837" Title="Arduino screws up trivial program involving enum" Tags="|ide|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8149" PostTypeId="2" ParentId="8148" CreationDate="2015-01-21T16:54:46.913" Score="4" Body="&lt;p&gt;You seem to be correct about what the arduino IDE is doing to your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino will not preprocess any .h or .cpp files, so you could use a second file. you could also break the IDE's function locating regex with a dummy &lt;code&gt;throw()&lt;/code&gt; statement like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void TellMe(WhatArduinoIs pls) throw() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The dummy throw allows it to compile for me on 1.5.8&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-01-21T16:54:46.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8150" PostTypeId="2" ParentId="8148" CreationDate="2015-01-21T16:56:30.687" Score="6" Body="&lt;p&gt;You can workaround the issue by putting your &lt;code&gt;enum&lt;/code&gt; and function into a namespace. You can even take advantage of C++ unnamed namespaces if you like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace&#xA;{&#xA;  enum WhatArduinoIs {&#xA;    Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed&#xA;  };&#xA;&#xA;  void TellMe(WhatArduinoIs pls) { }&#xA;}&#xA;&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's annoying (as are many things in the Arduino IDE), but it seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're more experienced with programming then you might want to consider using a 3rd party IDE with an Arduino plugin, such as Eclipse. The Arduino IDE is really only designed for beginners.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-21T16:56:30.687" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8151" PostTypeId="2" ParentId="8139" CreationDate="2015-01-21T17:00:10.843" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;with the breadboard&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That phrase right there makes the solution a non-starter. Solderless breadboards are good for prototyping, but are too fragile for use in a final project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for whether or not you should use an actual Arduino or reduce the circuit to a minimum, that is between you and your wallet. It is possible to make a basic AVR board (including MCU) for under $6 in parts, but the time investment is not entirely trivial.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-21T17:00:10.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8152" PostTypeId="1" CreationDate="2015-01-21T18:01:33.000" Score="2" ViewCount="1019" Body="&lt;p&gt;I am interested in using an Arduino Uno to produce an analog signal by running PWM through an RC low-pass filter.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll be controlling a highly dynamic object and need a clean voltage signal to avoid instabilities.  Per &lt;a href=&quot;http://sim.okawa-denshi.jp/en/PWMtool.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;this calculator on RC designs&lt;/a&gt;, it's suggested that one strategy to reducing voltage ripple is to increase the PWM frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With PWM configured to a default of &lt;a href=&quot;https://arduino.stackexchange.com/questions/210/why-do-some-pins-have-a-different-pwm-frequency&quot;&gt;980Hz for pins 5 and 6, and PWM of 490Hz for the remaining pins&lt;/a&gt;, I've decided that this will create too much voltage ripple for my filter.  I've found &lt;a href=&quot;http://arduino-info.wikispaces.com/Arduino-PWM-Frequency&quot; rel=&quot;nofollow noreferrer&quot;&gt;resources&lt;/a&gt; that describe how to configure the registers to increase the PWM frequency rather drastically.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is very simple: Are there any disadvantages to using a higher frequency PWM?  Why is the default set to be so slow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="6846" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-01-21T18:56:28.127" Title="Arduino PWM Frequency - Pros and Cons of Modifying" Tags="|arduino-uno|pwm|analogwrite|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8153" PostTypeId="1" AcceptedAnswerId="14377" CreationDate="2015-01-21T18:39:58.143" Score="0" ViewCount="1264" Body="&lt;p&gt;I accidentally fried my Arduino. I found &lt;a href=&quot;http://www.instructables.com/id/Fix-a-fried-Arduino-Mega/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; Instructable. The symptoms are the same. The board not powering on connecting USB source and the over current protector was heating up. So I removed the voltage regulator as mentioned in the Instructable. But the problem is the pins 1 and 2 of where the regulator used to be are still shorted out. That is even after removing the regulator, the pins seem to be somehow internally shorted. I tried checking the continuity on another working Arduino and found it to be not shorted. What seems to be the problem?&lt;/p&gt;&#xA;" OwnerUserId="6862" OwnerDisplayName="Ray" LastEditorUserId="10794" LastEditDate="2015-08-20T23:08:45.573" LastActivityDate="2015-09-20T04:15:01.540" Title="Replacing the Voltage regulator of a fried Arduino" Tags="|hardware|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8154" PostTypeId="2" ParentId="8152" CreationDate="2015-01-21T18:56:28.127" Score="3" Body="&lt;p&gt;A PWM frequency of 490Hz means a period of approximately 2.041ms. This allows a high period of 2ms, which is the maximum pulse length required by a large number of inexpensive servos. Obviously if your design uses no servos then this is not a consideration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer 0 itself is used for the various Arduino timing functions (&lt;code&gt;delay()&lt;/code&gt;, &lt;code&gt;millis()&lt;/code&gt;, etc.), so if you change the frequency used for timer 0 then those functions will no longer have accurate results.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-21T18:56:28.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8155" PostTypeId="1" CreationDate="2015-01-21T19:11:11.560" Score="3" ViewCount="645" Body="&lt;p&gt;I have problem to send data from processing to arduino mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Processing Code :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;&#xA;Serial myPort;&#xA;&#xA;void setup()&#xA;{&#xA;println(Serial.list());&#xA;String arduinoPort = Serial.list()[0];&#xA;myPort = new Serial(this, arduinoPort, 9600)&#xA;}&#xA;&#xA;void draw()&#xA;{&#xA;byte a= 3;&#xA;myPort.write(char(a));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Code :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;Servo myservo1;&#xA;Servo myservo2;&#xA;&#xA;void setup()&#xA;{ &#xA;Serial.begin(9600);&#xA;myservo1.attach(9);  &#xA;myservo2.attach(10);&#xA;myservo1.write(90);&#xA;myservo2.write(90);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;if(Serial.available()&amp;gt;0){&#xA;myservo1.write(70);&#xA;myservo2.write(70);&#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code is really simple, processing send a value to trigger arduino mega turning 2 servo &#xA;motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it doesn't response at all..&#xA;Please help if anyone has any clue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks :))&lt;/p&gt;&#xA;" OwnerUserId="6850" LastEditorUserId="6850" LastEditDate="2015-01-21T19:16:49.037" LastActivityDate="2023-02-15T01:07:00.797" Title="Sending data from processing to arduino" Tags="|serial|arduino-mega|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8156" PostTypeId="1" CreationDate="2015-01-21T19:57:06.590" Score="0" ViewCount="1076" Body="&lt;p&gt;I am not experienced about I2C communications, but I do happen to have two HMC5883L magnetometer modules that I wish to connect to a single arduino. It uses I2C protocol, and hence the slave device will have a fixed address. Now Can I change the address of one of my sensors so that the Arduino can differentiate between the two? (I seem to find no way out by reading the datasheet)&#xA;Thanks in Advance&#xA;Siddharth Jha&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Can an MPU 6050 module be used to find angle of rotation in X-Y plane (Parallel to the ground)?&lt;/p&gt;&#xA;" OwnerUserId="6853" LastActivityDate="2015-02-20T22:22:26.313" Title="How do I connect two slaves of same type in I2C?" Tags="|arduino-mega|i2c|accelerometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8157" PostTypeId="2" ParentId="8156" CreationDate="2015-01-21T20:25:38.277" Score="0" Body="&lt;p&gt;You can't change the address. You could connect it to some other pins, and bit-bang the I2C protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or connect the vcc of the unit to an arduino pin, so you can turn it on and off.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-21T20:25:38.277" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8158" PostTypeId="1" CreationDate="2015-01-21T20:47:45.660" Score="1" ViewCount="108" Body="&lt;p&gt;I keep reading how Arduinos are &quot;open source&quot;, but my understanding of OSH is that all its components must be open source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino uses an Atmel 8-bit CPU - but Googling this shows the Atmel is proprietary!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I ask: how can Arduino be OSH if it's chief component - its Atmel CPU - is proprietary?!?&lt;/p&gt;&#xA;" OwnerUserId="6856" LastActivityDate="2015-01-21T21:53:23.413" Title="Are Arduino's truly OSH?" Tags="|hardware|" AnswerCount="1" CommentCount="3" ClosedDate="2015-01-22T17:15:33.220" ContentLicense="CC BY-SA 3.0" />
  <row Id="8159" PostTypeId="1" CreationDate="2015-01-21T20:47:47.667" Score="0" ViewCount="1141" Body="&lt;p&gt;I'm looking to build my a wirelessly controlled lamp and have a few questions. Would I be able to use the Adafruit HUZZAH CC3000 breakout board to receive commands from a website and control a connected lamp? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just set up a NodeJS server with webpage on my PC and using socket.io and Firmata I was able to communicate with the Arduino using the webpage over a serial connection. Could I set up similar implementation except instead of communicating over serial I'd communicate using Wifi? Would I need to host a web server on the Wifi board itself to communicate with the Arduino or is there some way to just use the wifi board as a communication between external site and Firmata?&lt;/p&gt;&#xA;" OwnerUserId="6857" LastEditorUserId="6857" LastEditDate="2015-01-25T05:57:45.547" LastActivityDate="2015-01-25T21:46:39.707" Title="Using NodeJS, socket.io and Adafruit HUZZAH CC3000 breakout board to control Arduino wirelessly?" Tags="|shields|wifi|remote-control|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8160" PostTypeId="1" AcceptedAnswerId="8163" CreationDate="2015-01-21T21:32:29.590" Score="2" ViewCount="497" Body="&lt;p&gt;I keep reading how Arduinos are &quot;open source&quot;, but my understanding of OSH is that all its components must be open source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino uses an &lt;a href=&quot;http://en.wikipedia.org/wiki/Atmel_AVR&quot; rel=&quot;nofollow&quot;&gt;Atmel AVR&lt;/a&gt; CPU - but Googling this shows the Atmel is proprietary!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I ask: &lt;strong&gt;how can Arduino be truly OSH if it's chief component - its Atmel CPU - is proprietary?!?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9842" OwnerDisplayName="smeeb" LastActivityDate="2018-02-10T21:23:00.220" Title="How are Arduino's OSH if Atmel AVR is proprietary?" Tags="|avr|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8161" PostTypeId="2" ParentId="8158" CreationDate="2015-01-21T21:53:23.413" Score="2" Body="&lt;p&gt;I just scanned over the &lt;a href=&quot;http://en.wikipedia.org/wiki/TAPR_Open_Hardware_License#Conditions&quot; rel=&quot;nofollow&quot;&gt;TAPR&lt;/a&gt; and &lt;a href=&quot;http://www.ohwr.org/documents/294&quot; rel=&quot;nofollow&quot;&gt;CERN&lt;/a&gt; open hardware licenses and I didn't see such a provision. My quick take on OHLs is that they are specifications for building the hardware - and therefore, information - not the hardware itself. And it only makes sense when we consider the incredibly expensive and complicated (from an experimenter's point of view) infrastructure that is a chip foundry necessary to create the kinds of hardware we take for granted and have reduced to commodity parts, CPUs, &amp;amp; MCUs being a prime example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus &quot;Arduino&quot; is an open source specification for building microcontroller boards or board-sets based on ATMEL MCU chips, as well as the products of the Italian company SmartProjects. That is why there are so-called Arduino clones, otherwise, why wouldn't any clone of an Arduino &lt;em&gt;be&lt;/em&gt; an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-01-21T21:53:23.413" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8162" PostTypeId="2" ParentId="8136" CreationDate="2015-01-21T22:34:10.140" Score="2" Body="&lt;p&gt;Read the link in @j-g-faustus 's comment - very thorough. &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt; - it starts with a stock board running at 50milliAmps and ends up at 0.002 milliAmps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also need to find out the power consumption for your BT module - this may dwarf the power arduino's power consumption. The same goes for the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal LEDs run at about (ballpark!) 20 milliamps - this means that on the coin battery mentioned by @Omer, 200milliAmp-hours/20 milliAmps = 10 hours of led light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can measure the power draw with a multimeter; stick your probes between the + of the battery and whatever the battery would normally connect to (you will have to disconnect the battery of course) - if using a 9v battery, plug in the negative, disconnect the positive, turning the snap connector 90 degrees; then you can put one probe on the battery, the other on the (open) snap connector. Measure Arduino awake + led on + BT connected and sending data. Measure again with everything off/idle/sleeping. Work out how much time it will spend in each state; this will give you an average number of milliamp-hours.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-22T03:32:56.823" LastActivityDate="2015-01-22T03:32:56.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8163" PostTypeId="2" ParentId="8160" CreationDate="2015-01-21T23:18:36.420" Score="5" Body="&lt;p&gt;The components are necessarily going to be proprietary.  There is no feasible way around this.  If you wanted to design a new open source microcontroller from scratch with no proprietary components, it would set you back several billion dollars.  The software used to design integrated circuits costs hundreds of thousands of dollars to license and represents billions of dollars of investment.  Production of the chips themselves takes place in wafer fabs that cost billions of dollars to build, and represent billions of dollars of investment in process technology and semiconductor physics research.  The equipment and process technologies are very closely held trade secrets.  If you are OK with proprietary production, then you can submit GDSII design files (developed with your own open source IC design software) to fabs such as TSMC for production, but the line setup costs will run in the hundreds of thousands of dollars.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line: you have to draw the line somewhere as to what is acceptable to be 'open' and what is not.  Open source hardware generally means the board-level design files and firmware sources are available, and generally nothing more.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, there are many open source CPU designs available.  Sun's OpenSPARC is an open design, you can download the RTL description of the CPU core and modify it.  However, convering RTL to a chip requires IC design software or implementation on a proprietary FPGA with a proprietary development environment.  &lt;/p&gt;&#xA;" OwnerUserId="3832" LastActivityDate="2015-01-21T23:18:36.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8164" PostTypeId="2" ParentId="8160" CreationDate="2015-01-21T23:25:17.123" Score="3" Body="&lt;p&gt;An 'Arduino' is open source in that you can see the schematics, go out and buy any required components (including the AVR), and change the design however you like. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AVR is not part of what Arduino owns, it is a simply a component which they have built their design around. You could if you so choose replace that component with something else like a PIC for example, or any other programmable microcontroller for that matter. Granted if you made such a change you would also have to change the software, but then if you change the hardware even to another AVR you would have to change the software so in that sense it isn't really a limiting factor.&lt;/p&gt;&#xA;" OwnerUserId="6860" LastActivityDate="2015-01-21T23:25:17.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8165" PostTypeId="2" ParentId="6772" CreationDate="2015-01-21T23:47:50.327" Score="1" Body="&lt;p&gt;Try to connect &quot;Pin RX on Mega to Pin RX on Shield&quot; an &quot;Pin TX on Mega to Pin TX on Shield&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pin 50 (Rx)  on Mega &amp;lt;==&gt; Pin 2 GSM Rx on Shield&lt;/li&gt;&#xA;&lt;li&gt;Pin 51 (Tx)  on Mega &amp;lt;==&gt; Pin 3 GSM Tx on Shield&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I use an Geeetech Shield with a Mega 2560 and connect RX to Rx and TX to TX. Works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution is to use Serial1 instead of using SoftwareSerial ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First connect:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pin 19 (Rx1)  on Mega &amp;lt;==&gt; Pin 2 GSM Rx on Shield &lt;/li&gt;&#xA;&lt;li&gt;Pin 18 (Tx1)  on&#xA;Mega &amp;lt;==&gt; Pin 3 GSM Tx on Shield&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;pre&gt;&#xA;    //Serial Relay&#xA;    unsigned char buffer[64];  // buffer array for data receive over serial port&#xA;    int count=0;               // counter for buffer array&lt;/p&gt;&#xA;&#xA;&lt;code&gt;void setup()&#xA;{&#xA;  Serial1.begin(19200);&#xA;  Serial.begin(19200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial1.available())&#xA;  {&#xA;    while(Serial1.available())&#xA;    {&#xA;      buffer[count++]=Serial1.read();&#xA;      if(count == 64)break;&#xA;    }&#xA;    Serial.write(buffer,count);&#xA;    clearBufferArray();&#xA;    count = 0;&#xA;  }&#xA;  if (Serial.available())&#xA;    Serial1.write(Serial.read());&#xA;}&#xA;&#xA;void clearBufferArray()&#xA;{&#xA;  for (int i=0; i&amp;lt;count;i++)&#xA;  {&#xA;    buffer[i]=NULL;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a Arduino IDE's Serial Monitor, &lt;a href=&quot;http://musicshield.googlecode.com/files/sscom32E.exe&quot; rel=&quot;nofollow&quot;&gt;Serial Terminals(sscom32)&lt;/a&gt; or &lt;a href=&quot;http://sites.google.com/site/terminalbpp/&quot; rel=&quot;nofollow&quot;&gt;Bray++ Terminal&lt;/a&gt; to send AT commands to the Shield, communicate with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this information is helpful. &lt;/p&gt;&#xA;" OwnerUserId="6845" LastActivityDate="2015-01-21T23:47:50.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8166" PostTypeId="1" AcceptedAnswerId="8183" CreationDate="2015-01-22T01:02:39.453" Score="2" ViewCount="2218" Body="&lt;p&gt;I am trying to find a 12 V input and 12 V output breadboard power supply but I can't find one. I am making an Arduino-controlled lock but the Arduino cannot power the lock strike by itself so I need to use a separate power supply. The link to make things clearer:&#xA;&lt;a href=&quot;http://www.instructables.com/id/Arduino-RFID-Door-Lock/#step0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-RFID-Door-Lock/#step0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="274" LastEditorUserId="40318" LastEditDate="2022-10-06T05:57:15.173" LastActivityDate="2022-10-06T05:57:15.173" Title="Where Can I Find a 12v Solder-less Breadboard Power Supply?" Tags="|power|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="8167" PostTypeId="1" AcceptedAnswerId="8168" CreationDate="2015-01-22T01:52:28.707" Score="-1" ViewCount="620" Body="&lt;p&gt;If Arduino is OSH that simply uses 8-bit Atmel AVR MCU as a design component, then can Arduino somehow be tweaked to work with a 64-bit CPU/MCU? If so, what might this entail?&lt;/p&gt;&#xA;" OwnerUserId="6856" LastActivityDate="2015-01-22T03:29:41.867" Title="Can Arduino's open design be &quot;scaled&quot; to 64-bit CPUs?" Tags="|atmega328|hardware|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8168" PostTypeId="2" ParentId="8167" CreationDate="2015-01-22T03:00:36.890" Score="1" Body="&lt;p&gt;It has already been ported to a 32-bit Arm - the Arduino Due - 84mhz, Cortex M3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To port it to a 64-bit CPU, someone would need to create a design for the PCB, and set up an appropriate build/compile system for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, a 32-bit CPU is an awful lot of power for this sort of thing - I suspect that if a 32-bit Arm isn't enough, then what you're really looking for is a full-blown PC. A Cortex M3 can handle 4GB of memory, and can run a version of Linux (uCLinux, since the M3 does not have a memory management unit, MMU, and the standard Linux kernel needs this). The Due would be unable to run even uCLinux, due to limited memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, the Raspberry Pi is also a (700mhz Cortex A8) 32-bit CPU; I imagine that a little bit of tweaking could make the Arduino IDE compile &amp;amp; upload for the Raspberry Pi. This would fall into the category of &quot;Because I can&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: The Raspberry Pi is not opensource, I know. Neither is the Arm in the Arduino Due, nor the AtMega that is at the heart of the Arduino Uno. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-22T03:29:41.867" LastActivityDate="2015-01-22T03:29:41.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8170" PostTypeId="2" ParentId="8139" CreationDate="2015-01-22T03:53:56.123" Score="1" Body="&lt;p&gt;I started using an Arduino (Uno), and a solderless breadboard, to do my prototyping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the 2nd project, I started programming the Arduino, then pulling the AtMega chip off the board (if you have a through-hole chip rather than a surface mount one) and plugging that into my breadboard (you will need some supporting circuitry for this - a clock and a powersupply e.g. batteries). The AtMega has a larger range of voltages than the Arduino, and can be run up to 20mhz. You will need to jiggle some constants for this, or be ready for your delays to run quicker too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have since bought an USBISP (see Google), which can be hooked up to the Arduino board (there is a 6 pin header made for this, on the opposite side to the USB), or can be hooked up to specific pins. With this, I have started programming AtTiny chips - smaller, easier to set up, fewer pins to interface with, and really, really cheap!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All my long-term projects are on veroboard (see Google) - solder everything on, then cut it to the size you need. It's worth spending time before you solder working out your layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to produce these in bulk, I would suggest getting some prototypes on veroboard first (you will, invariably, make changes once you start testing!), then when you're happy, you can copy the veroboard design (possibly tweaking it to optimize for greater flexibility), and order PCBs from a company that does this sort of thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-22T03:53:56.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8171" PostTypeId="2" ParentId="8144" CreationDate="2015-01-22T05:03:04.910" Score="1" Body="&lt;p&gt;The SIM9000 shield requires up to 2 Amperes to operate its wireless functions. Thus it must be powered from an external 9 Volt power supply, and the supply should be able to supply at least 2 Amperes, preferably more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield will thus not work if powered through the Arduino, or using a low current external supply. The current draw for initial setup is low, hence registration of the SIM might be fine. Enabling wireless pushes the current draw beyond what your supply can cope with. This is shutting your setup down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace (or use) a 2 Amperes or better 9 Volt DC power supply, feed this power to the shield, not the Arduino, and attempt your code again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there are some changes required in using an Arduino Mega instead of the Uno with the TinySine GPRS shield, which are described in the help files and on some example videos on YouTube.&lt;/p&gt;&#xA;" OwnerUserId="70" LastActivityDate="2015-01-22T05:03:04.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8172" PostTypeId="2" ParentId="8091" CreationDate="2015-01-22T05:42:10.367" Score="1" Body="&lt;p&gt;Your &lt;code&gt;Output::SetStrobe()&lt;/code&gt; is wrong, it uses a &lt;code&gt;static&lt;/code&gt; variable (&lt;code&gt;_lasr_strobe_state&lt;/code&gt;) that is thus shared between all instances of &lt;code&gt;OUTPUT&lt;/code&gt;, which is NOT what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to change it into a non-static member of class Output instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Output&#xA;{&#xA;private:&#xA;    int _pin;&#xA;    OUTPUT_STATE _last_state;&#xA;    // NEW member here!!!&#xA;    OUTPUT_STATE _last_strobe_state;&#xA;    unsigned long _cycle_duration;&#xA;        unsigned long _last_elapsed;&#xA;&#xA;public:&#xA;    Output();     //constructor: set pin data store&#xA;    void Begin(int pin, OUTPUT_STATE state);//set hardware to output and defaul state&#xA;    void Set(OUTPUT_STATE state);            //toggle operability&#xA;    void SetStrobe(unsigned long duration);  //strobe operability&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you initialize it in the constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Output::Output():_last_strobe_state(STATE_OFF)&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you remove it (static declaration) from method &lt;code&gt;SetProbe&lt;/code&gt; (the rest of the method does not change):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Output::SetStrobe(unsigned long duration)&#xA;{&#xA;    unsigned long elapsed = millis() - _last_elapsed;&#xA;    if (elapsed &amp;gt;= duration)&#xA;    {&#xA;        if (_last_strobe_state == STATE_OFF)&#xA;        {&#xA;            digitalWrite(_pin, STATE_ON);&#xA;            _last_strobe_state = STATE_ON;&#xA;        }&#xA;        else&#xA;        {&#xA;            digitalWrite(_pin, STATE_OFF);&#xA;            _last_strobe_state = STATE_OFF;&#xA;        }&#xA;        _last_state = STATE_STROBE;&#xA;        _last_elapsed = millis();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-22T05:42:10.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8176" PostTypeId="1" AcceptedAnswerId="20420" CreationDate="2015-01-22T14:07:27.970" Score="1" ViewCount="105" Body="&lt;p&gt;I have 3 arduinos that I want to program on, all of them with their own cable and I have tried to connect them to my laptop on several different usb ports, my usb ports work with mouses so that's unlikely to be the problem. However I just cannot connect to them they just don't appear under /dev/ttyACM* and the arduino IDE cannot find them either. I'm running ubuntu 14.04 any suggestions for finding out what is likely to be wrong with my system or the arduinos? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some odd reason they now all appear to be seen as /dev/ttyACM* but they now all give me a &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;error&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody have any idea how to fix? The arduino's do not have any wires in them except usb (nothing in reset or any other pin), I'm on ubuntu so the drivers shouldn't be an issue? And pin 13 flashes when I reset the arduino. &lt;/p&gt;&#xA;" OwnerUserId="5165" LastEditorUserId="5165" LastEditDate="2015-01-23T09:32:16.373" LastActivityDate="2016-02-07T21:58:44.670" Title="connection issues with 3 arduinos any suggestions?" Tags="|arduino-uno|usb|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8177" PostTypeId="2" ParentId="8166" CreationDate="2015-01-22T15:35:13.023" Score="0" Body="&lt;p&gt;They sell 5V/3.3V breadboard supplies on eBay for $3-$5 shipped from China. Buy one and rewire/modify it to bypass the voltage regulator&lt;/p&gt;&#xA;" OwnerUserId="497" LastActivityDate="2015-01-22T15:35:13.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8179" PostTypeId="1" CreationDate="2015-01-22T17:25:42.267" Score="0" ViewCount="628" Body="&lt;p&gt;I want to send one bit of a byte out per 'rising edge' received to an Arduino digital input. I am addressing the outputs using direct port manipulation (to achieve maximum speed), and I would like to do the same for input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm calling a function called bitBang in my main loop, sending the ready line high before moving into the function: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Send control&#xA;PORTB |= _BV(PORTB2);&#xA;bitBang(controlByte);&#xA;PORTB &amp;amp;= ~_BV(PORTB2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I would like to do upon entering the function is listen for a rising edge to appear on the digital input port using the direct port syntax and iterate through the byte setting the data line high or low depending on the bit's value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I achieve this in the most efficient way possible?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="276" LastActivityDate="2015-12-20T13:43:04.833" Title="Send one bit out per clock pulse received using direct port manipulation?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8180" PostTypeId="1" CreationDate="2015-01-22T17:31:25.583" Score="2" ViewCount="504" Body="&lt;p&gt;I'm desperately trying to get my openlog to work and write data out to a micro SD card with no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a battery-powered lilypad arduino simple board and have attached L-shaped female headers to to the openlog to plug it right in. I am also using an FTDI breakout with the lilypad to download code and that is working. I think i have matched the RX and TX properly by flipping the openlog over as it pictured in the images attached. I'm using the example code included on the sparkfun openlog page just to test:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sparkfun/OpenLog/blob/master/firmware/examples/OpenLog_Test_Sketch/OpenLog_Test_Sketch.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/sparkfun/OpenLog/blob/master/firmware/examples/OpenLog_Test_Sketch/OpenLog_Test_Sketch.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no lights lit on the openlog which might indicate a power issue - but it's super unclear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas or help very welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QB15O.jpg&quot; alt=&quot;enter image description here&quot;&gt; &#xA;&lt;img src=&quot;https://i.stack.imgur.com/5AMaF.jpg!&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6536" LastActivityDate="2015-01-22T17:31:25.583" Title="Openlog + Lilypad Simple board - not writing to SD card" Tags="|sd-card|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8181" PostTypeId="1" CreationDate="2015-01-22T19:08:01.043" Score="0" ViewCount="1582" Body="&lt;p&gt;I was trying to make my arduino uno r3 to work on my Linux machine (including the IDE), but it wouldn't. At first I thought it was a software problem. Added myself to different groups and did everything, people discussed on the forums. It didn't work. It wasn't recognized by the computer at all. I reinstalled. Nothing again. Thought it was a hardware problem of my computer. Tried with dad's (Windows 7 machine). Didn't work. Then I saw that the two leds (TX and RX) are not blinking, neither are lit. I started doing a research on the internet but everybody suggests doing the loopback test from the IDE. My Arduino Uno R3 is not recognized by the computer, therefore the IDE. Is there any way to check if it's dead or if it's a minor problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I read a lot on the case last night and I reach to the conclusion that my ATmega16u2 (the usb-serial chip, I'm sure it is 16u2 and not 8u2, it's written on the chip itself) might be dead. Tried to reflash the firmware but cannot get it in DFU mode (as it says in this article &lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;click here&lt;/a&gt;). dfu-programmer (the Linux application) throws the following error: &lt;code&gt;dfu-programmer: no device present&lt;/code&gt;. What to do?&lt;/p&gt;&#xA;" OwnerUserId="6874" OwnerDisplayName="Emil Avramov" LastEditorUserId="6874" LastEditDate="2015-01-23T19:15:30.940" LastActivityDate="2015-01-23T19:30:03.273" Title="Arduino Uno R3 not recognized by computer, TX and RX not blinking, neither are lit. Is it dead?" Tags="|arduino-uno|atmega328|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8182" PostTypeId="2" ParentId="8181" CreationDate="2015-01-22T19:36:56.043" Score="0" Body="&lt;p&gt;Before you can access serial TX/RX on Arduino make sure USB to serial converter on the board is working. To check it (on Linux) do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Open the terminal, type 'dmesg' and press 'enter'. You will see some output with timestamps (number in square brackets). Note the timestamp of the last line. Run dmesg several times to make sure nothing writes to it and you still see the last timestamp.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Plug your board into USB port and run dmesg once again. You should see something like the output below. The first line is the last line of dmesg prior to plugging in the Arduino, the second line is actual detection. The board I used in this example is 2560, UNO will give you similar output. If you can see this output your board is recognized just fine. If you can't see it then either the USB to serial chip (just another AVR MCU) on the Arduino or USB host in your PC or both are defective.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&#xA;    [279152.351690] systemd-logind[867]: New session c51 of user lightdm.&#xA;    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd&#xA;    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010&#xA;    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;    [280362.931282] usb 3-2: Product: Arduino Mega 2560&#xA;    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)&#xA;    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172&#xA;    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device&#xA;    [280362.988470] usbcore: registered new interface driver cdc_acm&#xA;    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters&#xA;    [280362.732094] usb 3-2: new full-speed USB device number 3 using uhci_hcd&#xA;    [280362.931266] usb 3-2: New USB device found, idVendor=2341, idProduct=0010&#xA;    [280362.931275] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;    [280362.931282] usb 3-2: Product: Arduino Mega 2560&#xA;    [280362.931288] usb 3-2: Manufacturer: Arduino (www.arduino.cc)&#xA;    [280362.931293] usb 3-2: SerialNumber: 64938323331351213172&#xA;    [280362.986579] cdc_acm 3-2:1.0: ttyACM0: USB ACM device&#xA;    [280362.988470] usbcore: registered new interface driver cdc_acm&#xA;    [280362.988473] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="6667" LastEditorUserId="6667" LastEditDate="2015-01-22T20:28:42.830" LastActivityDate="2015-01-22T20:28:42.830" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8183" PostTypeId="2" ParentId="8166" CreationDate="2015-01-22T19:45:14.593" Score="3" Body="&lt;p&gt;There is nothing special about a &quot;breadboard power adapter&quot; that isn't served by a normal regulated supply. Simply use wires or a barrel jack or some other connector to connect any regulated supply to the breadboard as desired.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-22T19:45:14.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8184" PostTypeId="2" ParentId="8181" CreationDate="2015-01-22T20:56:34.250" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Delete your Arduino IDE, but store your libraries if you need in future.&lt;/li&gt;&#xA;&lt;li&gt;Download Arduino ERW 1.0.5 from here: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=118440&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=118440&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;Try your steps again with your connections belong to your schematic.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2015-01-22T20:56:34.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8185" PostTypeId="1" AcceptedAnswerId="8189" CreationDate="2015-01-22T21:26:17.667" Score="8" ViewCount="13328" Body="&lt;p&gt;I tried to modify the example in the following page, by replacing the given string with a 56 bytes one after making all the suitable changes to read(), write() and max_payload_size(increased to 64 bytes), payload_size() parameters/methods in the RF24 library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://shanes.net/another-nrf24l01-sketch-string-sendreceive/&quot; rel=&quot;noreferrer&quot;&gt;http://shanes.net/another-nrf24l01-sketch-string-sendreceive/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the receiver truncates the string to 32 characters. Is 32 bytes a hard limitation for payload with the nrf24l01+ radio? If so how to I modify the receiver in above example problem to receive the entire string?&lt;/p&gt;&#xA;" OwnerUserId="6759" LastActivityDate="2015-01-23T07:16:47.453" Title="Increasing payload size above 32 bytes using nRF24L01+" Tags="|arduino-uno|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8186" PostTypeId="2" ParentId="3845" CreationDate="2015-01-22T22:02:24.117" Score="1" Body="&lt;p&gt;I have a similar display, and I found the wiring by inspection and trial and error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display consist of 8 pairs of digits (LB-202VL, common cathode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If contact points are numbered from 1 to 24 from left to right then&#xA;the common cathodes for the digits D1-D16 and the segments D.P. and 'a' - 'g' are noted below.&#xA;If you i.e. connect 1 to GND and 7 to + then segment 'c' of the first digit will be on. You have to multiplex the digits in order to use it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;D1&lt;/li&gt;&#xA;&lt;li&gt;D2&lt;/li&gt;&#xA;&lt;li&gt;D3&lt;/li&gt;&#xA;&lt;li&gt;D4&lt;/li&gt;&#xA;&lt;li&gt;D.P.&lt;/li&gt;&#xA;&lt;li&gt;D5&lt;/li&gt;&#xA;&lt;li&gt;c&lt;/li&gt;&#xA;&lt;li&gt;D6&lt;/li&gt;&#xA;&lt;li&gt;e&lt;/li&gt;&#xA;&lt;li&gt;D7&lt;/li&gt;&#xA;&lt;li&gt;a&lt;/li&gt;&#xA;&lt;li&gt;D8&lt;/li&gt;&#xA;&lt;li&gt;g&lt;/li&gt;&#xA;&lt;li&gt;D9&lt;/li&gt;&#xA;&lt;li&gt;d&lt;/li&gt;&#xA;&lt;li&gt;D10&lt;/li&gt;&#xA;&lt;li&gt;f&lt;/li&gt;&#xA;&lt;li&gt;D11&lt;/li&gt;&#xA;&lt;li&gt;b&lt;/li&gt;&#xA;&lt;li&gt;D12&lt;/li&gt;&#xA;&lt;li&gt;D13&lt;/li&gt;&#xA;&lt;li&gt;D14&lt;/li&gt;&#xA;&lt;li&gt;D15&lt;/li&gt;&#xA;&lt;li&gt;D16&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6875" LastActivityDate="2015-01-22T22:02:24.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8187" PostTypeId="1" CreationDate="2015-01-23T01:34:35.213" Score="1" ViewCount="8086" Body="&lt;p&gt;I want to transfer data from my smartphon to the Arduino by using the audio jack of my smartphone. For this I need verry high reading frequencys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bitClear(ADCSRA,ADPS0); &#xA;bitSet(ADCSRA,ADPS1); &#xA;bitClear(ADCSRA,ADPS2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to boost analogread to ~10microseconds, which would be enough. But somehow I am still wasting 5.4 ms at the beginning of the transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing between signal start and first analogread is a start of a for loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(analogRead(A0)&amp;lt;50) (true); //wait for start of transmission&#xA;for(i = 0; i&amp;lt;500;i++){&#xA;data[i]=analogRead(A0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But does starting a for loop take 5.4 ms? &#xA;Do you have any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6738" LastActivityDate="2015-01-23T22:12:48.023" Title="Increasing analogread speed on the Arduino Uno" Tags="|analogread|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8189" PostTypeId="2" ParentId="8185" CreationDate="2015-01-23T05:51:42.697" Score="7" Body="&lt;p&gt;If you look at the &lt;a href=&quot;https://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P&quot; rel=&quot;noreferrer&quot;&gt;specification or datasheet&lt;/a&gt; for the nRF24l01+, you will see that the 32 byte payload is the maximum that the device can handle.&lt;/p&gt;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QvWcG.png&quot; alt=&quot;spec&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you need to transmit anything larger than 32 bytes, you will need to develop a protocol that splits up your data into chunks of 32 bytes or less and sends the data in several packets.&lt;/p&gt;&#xA;&lt;p&gt;The actual protocol you design is up to you, but a simple technique might be using the first packet to send a count of the number of data packets to expect and then simply send those packets, each with a part of your data and reassemble it at the receiving end.&lt;/p&gt;&#xA;&lt;p&gt;You may need to design something more robust so you don't get confused by lost packets or bad data. The larger your payload, the more chance of transmission errors, so it might be an idea to experiemnt with the payload size to get the best throughput for your particular application.&lt;/p&gt;&#xA;" OwnerUserId="5063" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-01-23T07:16:47.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8190" PostTypeId="1" CreationDate="2015-01-23T09:00:06.377" Score="2" ViewCount="487" Body="&lt;p&gt;Please help me. There is a conflict when I put GSM and Bluetooth module in one MCU. The problem is when I use the GSM, the Bluetooth will not respond and vice-versa.&lt;/p&gt;&#xA;" OwnerUserId="6878" LastEditorUserId="313" LastEditDate="2015-01-23T18:59:09.347" LastActivityDate="2015-01-23T18:59:09.347" Title="integration of GSM module and Bluetooth using arduino" Tags="|bluetooth|gsm|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8192" PostTypeId="1" CreationDate="2015-01-23T13:30:12.493" Score="2" ViewCount="1215" Body="&lt;p&gt;I'm currently using an Arduino Uno (R3), but want to switch to Leonardo for the USB-ability. The Uno can work from the USB's 5V. Looking at the Leonardo's schematic it seems the only input to the voltage regulator is from the power connector. This makes sense as it's a 5V regulator which needs &gt; 5V in. But I don't see the MOSFET which connects the USB's 5V to the board's 5V, like there's one on the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, does the Leonardo need the separate power input connected?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-01-23T14:07:25.277" Title="Does Leonardo need a separate power supply?" Tags="|power|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8193" PostTypeId="1" AcceptedAnswerId="8194" CreationDate="2015-01-23T13:43:31.097" Score="0" ViewCount="3664" Body="&lt;p&gt;I want to collect data (both Humidity &amp;amp; Temperature) from 80 sensors. let's say I have 80 &quot;DHT 11 Humidity &amp;amp; Temperature&quot; sensors (for ex. in a warehouse) and one Arduino Uno R3 pack. It's clear that arduino has no so many pins to connect. I'm sorry that I don't know if it's possible. If so, what can I use to achieve this?&#xA;Thank you all for your suggestions.&lt;/p&gt;&#xA;" OwnerUserId="6338" LastActivityDate="2015-01-23T13:59:16.817" Title="Connecting multiple DHT 11 sensors" Tags="|sensors|temperature-sensor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8194" PostTypeId="2" ParentId="8193" CreationDate="2015-01-23T13:59:16.817" Score="0" Body="&lt;p&gt;Analog multiplexers are one way, but they tend to have a significant resistance when on, and this could cause the protocol not to work.&lt;br&gt;&#xA;For 80 channels you need 7 bits addressing. Say you have an 8-input multiplexer, then a 3-bit address indicates which of the 8 inputs is selected. Use 10 of these, all with the three address lines connected, and you have 10 outputs from 80 inputs.&#xA;Next, use a 16-input multiplexer to select which of the 10 inputs you want to use. For this multiplexer you need 4 address lines. Together with the other 3 address lines you have 7 address lines, enough to select 1 of up to 128 sensors. But I repeat, this approach may not work if the multiplexer's resistance is too high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more robust (albeit more expensive) is to use analog switches to connect/disconnect each sensor. Analog switches (Analog Devices has a lot of them) have on-resistances down to &amp;lt; 1 ohm, so the sure should be OK for the application.&lt;br&gt;&#xA;To control the long series of switches you could use a daisy chain of 74HC595 shift registers, which only requires a couple of I/Os on your controller, but gives you virtually unlimited outputs.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-01-23T13:59:16.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8195" PostTypeId="2" ParentId="8192" CreationDate="2015-01-23T14:07:25.277" Score="4" Body="&lt;p&gt;Power steering is performed by the assembly labelled &quot;+5V AUTO SELECTOR&quot; at the bottom of the page. The voltage at VIN is halved and then compared with the board's 3.3V output in order to determine whether or not to enable USB power via T1.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-23T14:07:25.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8196" PostTypeId="1" AcceptedAnswerId="8224" CreationDate="2015-01-23T19:20:22.717" Score="1" ViewCount="380" Body="&lt;p&gt;i am building an outdoor sensor with a combination of a custom Arduino board and a battery (+solar charging). I experience strange behavior when the temperature falls below a certain value (i can reproduce it by putting it in the freezer), regardless which type of battery i am using. The custom Arduino runs without power-regulation, straight from the 3.7volts the battery can provide. &#xA;How can i prevent this to happen? I guess a little heating would be not really a solution as i am trying to consume as less energy as possible.&#xA;Would a (step up) regulator possibly help? Any other ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;---Update---&#xA;Thanks to your comments here i figured out, that the AVR 328p should not be operated below a voltage of 3.7v if run at 16Mhz. As i am running with a 3.7v LiPo Battery that could easily explain my problem i guess. My first try to decrease the processor speed to 8Mhz with a Prescaler worked, but the GSM Fona does not seem to like it. So i would like to try something in between like 10Mhz or 12Mhz. As the prescaler does not support this, my question is: can i just use another crystal or would i have to modify something in the code/bootloader as well?&lt;/p&gt;&#xA;" OwnerUserId="6888" LastEditorUserId="6888" LastEditDate="2015-01-25T11:31:28.760" LastActivityDate="2015-01-25T13:30:28.113" Title="Arduino on battery getting unstable if temperature falls" Tags="|power|battery|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8197" PostTypeId="2" ParentId="8187" CreationDate="2015-01-23T19:21:32.437" Score="2" Body="&lt;p&gt;It sounds like you could benefit from interrupt handled free running sampling, doing that should get you sampling rates up to the maximum listed on the 328's datasheet, 76.9 kSPs. Although, that's at a reduced resolution. &lt;a href=&quot;http://meettechniek.info/embedded/arduino-analog.html&quot; rel=&quot;nofollow&quot;&gt;This site&lt;/a&gt; explains better, under the section &quot;Free running sampling&quot;.&lt;/p&gt;&#xA;" OwnerUserId="6886" LastActivityDate="2015-01-23T19:21:32.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8199" PostTypeId="2" ParentId="8181" CreationDate="2015-01-23T19:30:03.273" Score="1" Body="&lt;p&gt;There is a chance that your bootloader is not working anymore. You can burn a new bootloader to the device with another Uno, there are nice &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;guides on the Arduino-Website&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-23T19:30:03.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8200" PostTypeId="1" CreationDate="2015-01-23T19:34:25.493" Score="1" ViewCount="790" Body="&lt;p&gt;I was trying to interface my hex keypad with Arduino. I declared rows as input and columns as output. When I initialize three of the four columns as HIGH and one as LOW, and detect the button pressed as LOW in the corresponding row, it works fine. That is, it detects the button when its corresponding row and column is LOW. But, when I reverse the condition, i.e. when I try to detect the button pressed when its corresponding row and column is high while others are low, it does not work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really want to know why is this happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that works:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int row[]={6,7,8,9};&#xA;int col[]={10,11,12,13};&#xA;int i,j; &#xA;int col_scan;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   for(i=0;i&amp;lt;=3;i++)&#xA;   {&#xA;      pinMode(row[i],OUTPUT);&#xA;      pinMode(col[i],INPUT);&#xA;      digitalWrite(col[i],HIGH);&#xA;   } }&#xA;void loop()&#xA;{ &#xA;   for(i=0; i&amp;lt;=3; i++)&#xA;   {&#xA;      digitalWrite(row[0],HIGH);&#xA;      digitalWrite(row[1],HIGH);&#xA;      digitalWrite(row[2],HIGH);&#xA;      digitalWrite(row[3],HIGH);&#xA;      digitalWrite(row[i],LOW);&#xA;      for(j=0; j&amp;lt;=3; j++)&#xA;      {&#xA;     col_scan=digitalRead(col[j]);&#xA;     if(col_scan==LOW)&#xA;     {&#xA;        keypress(i,j);&#xA;        delay(300);&#xA;     }}&#xA;   }}&#xA;void keypress(int i, int j)&#xA;{&#xA;   if(i==0&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;1&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;2&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;3&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;A&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;4&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;5&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;6&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;B&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;7&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;8&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;9&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;C&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;*&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;0&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;#&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;D&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the code that doesn't work:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int row[]={6,7,8,9};&#xA;int col[]={10,11,12,13};&#xA;int i,j; &#xA;int col_scan;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   for(i=0;i&amp;lt;=3;i++)&#xA;   {&#xA;      pinMode(row[i],OUTPUT);&#xA;      pinMode(col[i],INPUT);&#xA;      digitalWrite(col[i],LOW);&#xA;   } }&#xA;void loop()&#xA;{ &#xA;   for(i=0; i&amp;lt;=3; i++)&#xA;   {&#xA;      digitalWrite(row[0],LOW);&#xA;      digitalWrite(row[1],LOW);&#xA;      digitalWrite(row[2],LOW);&#xA;      digitalWrite(row[3],LOW);&#xA;      digitalWrite(row[i],HIGH);&#xA;      for(j=0; j&amp;lt;=3; j++)&#xA;      {&#xA;     col_scan=digitalRead(col[j]);&#xA;     if(col_scan==HIGH)&#xA;     {&#xA;        keypress(i,j);&#xA;        delay(300);&#xA;     }}&#xA;   }}&#xA;void keypress(int i, int j)&#xA;{&#xA;   if(i==0&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;1&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;2&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;3&quot;);&#xA;   if(i==0&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;A&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;4&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;5&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;6&quot;);&#xA;   if(i==1&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;B&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;7&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;8&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;9&quot;);&#xA;   if(i==2&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;C&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==0)&#xA;      Serial.println(&quot;*&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==1)&#xA;      Serial.println(&quot;0&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==2)&#xA;      Serial.println(&quot;#&quot;);&#xA;   if(i==3&amp;amp;&amp;amp;j==3)&#xA;      Serial.println(&quot;D&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6890" LastEditorUserId="313" LastEditDate="2015-01-24T17:59:42.080" LastActivityDate="2015-01-24T17:59:42.080" Title="Interfacing Hex keypad with arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8201" PostTypeId="2" ParentId="3855" CreationDate="2015-01-23T19:40:41.103" Score="1" Body="&lt;p&gt;I could reproduce these power requirements - main thing is to get rid of the Arduino board and start with a Bareduino or sth similar. (find a detailed description &lt;a href=&quot;https://holadimake.wordpress.com/2015/01/02/building-a-cellular-tracker-part3-running-on-batteries-for-months/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-23T19:40:41.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8202" PostTypeId="1" CreationDate="2015-01-23T19:47:15.250" Score="1" ViewCount="730" Body="&lt;p&gt;I need to read 5 analog pins simultaneously , is it possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note that: &lt;br&gt;&#xA;analogRead(1); &lt;br&gt;&#xA;analogRead(2); &lt;br&gt;&#xA;analogRead(3); &lt;br&gt;&#xA;will not work this case&lt;/p&gt;&#xA;" OwnerUserId="6891" LastActivityDate="2015-01-23T19:49:33.303" Title="Simultaneous input output in arduino mega" Tags="|pins|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8203" PostTypeId="2" ParentId="8202" CreationDate="2015-01-23T19:49:33.303" Score="3" Body="&lt;p&gt;No, it is not. The ADC in the MCU is only capable of sampling a single analog channel at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you require sampling more than one channel at a time then you will need to use one or more external ADCs that are capable of sampling multiple channels, or multiple ADCs each dedicated to a single channel.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-23T19:49:33.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8204" PostTypeId="1" CreationDate="2015-01-23T21:27:06.493" Score="6" ViewCount="2618" Body="&lt;p&gt;I can't get the min,max range to function properly. Monitoring the serial, only gives out ~50 difference from the min. I then added truerandom.ino to try to fix, but no help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin = 13; // the number of the LED pin&#xA;// Variables will change:&#xA;int ledState = LOW; // ledState used to set the LED&#xA;long previousMillis = 0; // will store last time LED was updated&#xA;// the follow variables is a long because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;//long interval = random(800, 8000); // interval at which to blink (milliseconds)&#xA;void setup() {&#xA;// set the digital pin as output:&#xA;pinMode(ledPin, OUTPUT);&#xA;Serial.begin(9600);&#xA;}&#xA;void loop()&#xA;{&#xA;// here is where you'd put code that needs to be running all the time.&#xA;// check to see if it's time to blink the LED; that is, if the&#xA;// difference between the current time and last time you blinked&#xA;// the LED is bigger than the interval at which you want to&#xA;// blink the LED.&#xA;long interval = random(800,8000);&#xA;unsigned long currentMillis = millis();&#xA;if(currentMillis - previousMillis &amp;gt; interval) {&#xA;// save the last time you blinked the LED&#xA;previousMillis = currentMillis;&#xA;// if the LED is off turn it on and vice-versa:&#xA;if (ledState == LOW)&#xA;ledState = HIGH;&#xA;else&#xA;ledState = LOW;&#xA;// set the LED with the ledState of the variable:&#xA;digitalWrite(ledPin, ledState);&#xA;Serial.println(interval);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Added truerandom.ino still ~50 range:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// TrueRandomSeed.ino&#xA;//   This example sketch shows how to provide a truly random seed value to the built in &#xA;//   library pseudo random number generator.  This ensures that your sketch will be&#xA;//   using a different sequence of random numbers every time it runs.  Unlike the &#xA;//   usually suggested randomSeed(analogRead(0)) this method will provide a much more &#xA;//   uniform and varied seed value.  For more information about the basic technique used&#xA;//   here to produce a random number or if you need more than one such number you can &#xA;//   find a library, Entropy from the following web site along with documentation of how&#xA;//   the library has been tested to provide TRUE random numbers on a variety of AVR &#xA;//   chips and arduino environments. &#xA;//&#xA;//   https://sites.google.com/site/astudyofentropy/project-definition/&#xA;//           timer-jitter-entropy-sources/entropy-library&#xA;//&#xA;//   Copyright 2014 by Walter Anderson, wandrson01 at gmail dot com&#xA;//&#xA;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include &amp;lt;util/atomic.h&amp;gt;&#xA;// The following addresses a problem in version 1.0.5 and earlier of the Arduino IDE &#xA;// that prevents randomSeed from working properly.&#xA;//        https://github.com/arduino/Arduino/issues/575&#xA;#define randomSeed(s) srandom(s)&#xA;&#xA;volatile uint32_t seed;  // These two variables can be reused in your program after the&#xA;volatile int8_t nrot;    // function CreateTrulyRandomSeed()executes in the setup() &#xA;                         // function.&#xA;const int ledPin = 13; // the number of the LED pin&#xA;// Variables will change:&#xA;int ledState = LOW; // ledState used to set the LED&#xA;long previousMillis = 0; // will store last time LED was updated&#xA;&#xA;void CreateTrulyRandomSeed()&#xA;{&#xA;  seed = 0;&#xA;  nrot = 32; // Must be at least 4, but more increased the uniformity of the produced &#xA;             // seeds entropy.&#xA;&#xA;  // The following five lines of code turn on the watch dog timer interrupt to create&#xA;  // the seed value&#xA;  cli();                                             &#xA;  MCUSR = 0;                                         &#xA;  _WD_CONTROL_REG |= (1&amp;lt;&amp;lt;_WD_CHANGE_BIT) | (1&amp;lt;&amp;lt;WDE); &#xA;  _WD_CONTROL_REG = (1&amp;lt;&amp;lt;WDIE);                       &#xA;  sei();                                             &#xA;&#xA;  while (nrot &amp;gt; 0);  // wait here until seed is created&#xA;&#xA;  // The following five lines turn off the watch dog timer interrupt&#xA;  cli();                                             &#xA;  MCUSR = 0;                                         &#xA;  _WD_CONTROL_REG |= (1&amp;lt;&amp;lt;_WD_CHANGE_BIT) | (0&amp;lt;&amp;lt;WDE); &#xA;  _WD_CONTROL_REG = (0&amp;lt;&amp;lt; WDIE);                      &#xA;  sei();                                             &#xA;}&#xA;&#xA;ISR(WDT_vect)&#xA;{&#xA;  nrot--;&#xA;  seed = seed &amp;lt;&amp;lt; 8;&#xA;  seed = seed ^ TCNT1L;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  CreateTrulyRandomSeed();&#xA;  randomSeed(seed);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.begin(9600); &#xA;  // The preceeding two function calls will take approximately 0.5 second to execute if &#xA;  // nrot is set to 32 ... the rest of your setup code should FOLLOW from here.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  long interval = random(800,8000);&#xA;unsigned long currentMillis = millis();&#xA;if(currentMillis - previousMillis &amp;gt; interval) {&#xA;// save the last time you blinked the LED&#xA;previousMillis = currentMillis;&#xA;// if the LED is off turn it on and vice-versa:&#xA;if (ledState == LOW)&#xA;ledState = HIGH;&#xA;else&#xA;ledState = LOW;&#xA;// set the LED with the ledState of the variable:&#xA;digitalWrite(ledPin, ledState);&#xA;Serial.println(interval);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6893" LastEditorUserId="10794" LastEditDate="2015-09-06T08:52:42.000" LastActivityDate="2016-02-14T11:18:57.643" Title="Random(min,max) Function only giving ~50 range no matter what the values?" Tags="|arduino-uno|programming|library|sketch|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8205" PostTypeId="2" ParentId="8187" CreationDate="2015-01-23T22:12:48.023" Score="1" Body="&lt;p&gt;I did some further analysis on the signal and the problem was not the Arduino. It did everything quick and correct.&#xA;The problem was my smartphone. I used androids AudioTrack class and somehow it did cut off parts of the signal. This could be &quot;fixed&quot; by increasing the length of the signal. I just added 0's at the beginning and end.&lt;/p&gt;&#xA;" OwnerUserId="6738" LastActivityDate="2015-01-23T22:12:48.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8206" PostTypeId="1" AcceptedAnswerId="8210" CreationDate="2015-01-24T00:23:21.647" Score="1" ViewCount="5201" Body="&lt;p&gt;I am working on a project using an Arduino as a web server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;webFile = SD.open(&quot;index.htm&quot;);&#xA;if (webFile) {&#xA;  while(webFile.available()) {&#xA;    client.write(webFile.read());&#xA;  }&#xA;webFile.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sends data line by line, leading to a long time to load the webpage. Is there a faster way to load this page?&lt;/p&gt;&#xA;" OwnerUserId="6583" LastEditorUserId="42" LastEditDate="2015-01-24T00:58:37.437" LastActivityDate="2017-01-03T19:37:43.060" Title="How can I speed up reading of an SD card?" Tags="|arduino-uno|serial|arduino-mega|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8207" PostTypeId="2" ParentId="8204" CreationDate="2015-01-24T00:36:51.833" Score="2" Body="&lt;p&gt;I suspect it actually is generating other values and it's your program logic that's at fault.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I think you meant your program to do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Generate a random interval.&lt;/li&gt;&#xA;&lt;li&gt;Wait until that interval has elapsed.&lt;/li&gt;&#xA;&lt;li&gt;Start again with a new interval.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's what's actually happening:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Generate a random interval.&lt;/li&gt;&#xA;&lt;li&gt;Check if that interval has elapsed.&lt;/li&gt;&#xA;&lt;li&gt;Whether or not it has elapsed, generate a new random interval anyway.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that you're generating a new random interval &lt;strong&gt;every time round &lt;code&gt;loop()&lt;/code&gt;&lt;/strong&gt;. This means your condition just keeps trying new random intervals until one happens (by chance) to be less than the amount of time that's elapsed since the last interval. You're only outputting the interval when that occurs, and evidently it happens on average at least every 50ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test this theory by outputting &lt;code&gt;interval&lt;/code&gt; to serial as soon as you've generated it (i.e. before the &lt;code&gt;if&lt;/code&gt; statement). I think you'll find it will flood the serial monitor with a huge range of values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixing the problem should be pretty easy. Just generate your first &lt;code&gt;interval&lt;/code&gt; value during &lt;code&gt;setup()&lt;/code&gt;. After that, only generate a new random &lt;code&gt;interval&lt;/code&gt; value when the old interval has elapsed (i.e. inside the &lt;code&gt;if&lt;/code&gt; block). Don't do it every time round the main loop.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-24T00:36:51.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8208" PostTypeId="2" ParentId="8200" CreationDate="2015-01-24T01:56:21.353" Score="1" Body="&lt;p&gt;To use unipolar switches as inputs, you need pulling resistors to give the input pin a defined value when the switch is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATmega has software configurable internal pullups.  Even if these are not configured, implementation detail may (or may not) yield a very weak &lt;em&gt;unreliable&lt;/em&gt; pullup effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no configurable pulldown on the ATmega.  To operate in that direction (with a switch to high) you would need external pulldown resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few matrix keyboards include diodes, to combat some of the confusion which results when multiple keys are pressed in a simple matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you should add a tiny delay between driving and reading, in order to allow for capacitive delay.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-01-24T01:56:21.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8210" PostTypeId="2" ParentId="8206" CreationDate="2015-01-24T09:20:39.497" Score="1" Body="&lt;p&gt;Well I have two ideas on the SD card side, though neither really seem &lt;em&gt;great&lt;/em&gt; to me they could still help you. I read on the Arduino forum that the SD card R/W speeds generally come out to 600kB/s, I'm not really sure why, the Arduino SPI can go up to 8 MB/s and I didn't think there would be that much protocol/data-handling in SD. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Sector R/W - As Chris Stratton said, this is an obvious method, it's probably much faster to do sector reads. You may have to greatly change your code to implement it, but I imagine you'd see performance increase in the end. Apparently there's an &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=52871.0&quot; rel=&quot;nofollow&quot;&gt;unofficial library&lt;/a&gt; for it, though it seems to impart some potentially serious limitations.&lt;/li&gt;&#xA;&lt;li&gt;RAM - This is the second thing that came to mind when thinking about the problem is that you could use external RAM, when not handling network transfers (Idling, should be most of the time) the Arduino transfers data to external SRAM which you add. &lt;a href=&quot;http://www.mouser.com/ProductDetail/Microchip-Technology/23LC1024-I-P/?qs=sGAEpiMZZMt9mBA6nIyysHsFd6bhl6Edtfzw23Aiprk%3D&quot; rel=&quot;nofollow&quot;&gt;SPI RAM&lt;/a&gt; is most likely the easiest to implement, but not likely to be any faster than an SD card. &lt;a href=&quot;http://www.mouser.com/ProductDetail/Alliance-Memory/AS6C4008-55PCN/?qs=sGAEpiMZZMtm4RFapVkzrPhqi0UYYSDeBu6Rrbtf4UA%3D&quot; rel=&quot;nofollow&quot;&gt;Parallel RAM&lt;/a&gt; is going to be difficult to implement, you'll likely need to write your own class/library, but it could be much faster than SPI RAM or an SD card.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm not actually sure if either of these would be any faster, it's all just theory and I hope others will share their thoughts. If you have trouble finding the download link for the SD Card library, it's right &lt;a href=&quot;https://code.google.com/p/mysudoku/downloads/detail?name=SDCARDsectors.zip&amp;amp;can=2&amp;amp;q=&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. In that ZIP folder there's a file called &lt;em&gt;SDCARD&lt;/em&gt;, just move that folder into your Arduino libraries folder on your computer.&lt;/p&gt;&#xA;" OwnerUserId="6886" LastEditorUserId="6886" LastEditDate="2015-01-24T10:32:39.560" LastActivityDate="2015-01-24T10:32:39.560" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8211" PostTypeId="2" ParentId="8196" CreationDate="2015-01-24T10:28:27.310" Score="-1" Body="&lt;p&gt;It's most likely that the cold weather is messing with your batteries. I don't know what battery types you've tried, but &lt;a href=&quot;http://www.rei.com/learn/expert-advice/batteries.html&quot; rel=&quot;nofollow&quot;&gt;this site&lt;/a&gt; says that Lithium batteries (Not Li Ion, but standard single use, expensive, lithiums) hold up well in very cold and very hot environments. For rechargeable batteries the site recommends NiMH batteries. Of course, we all know that lead acid batteries hold up well in cold (Or else our cars wouldn't start!), so those are also a viable option. Lead acids can be purchased in somewhat small forms, but they may still be too big for your purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other part of your question, yes a regulator will help. It's rarely acceptable to run directly off a battery without a regulator. Since your application is low power you'll want to use an efficient switching regulator (Search for modules, not individual chips). Remember that a battery's output changes based on its charge level, temperature, current draw, and other things I'm likely forgetting. Using a regulator mitigates these effects as regulators are less affected by temperature and current draw than the battery that supplies it (Hopefully).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to summarize: Use Lithium batteries, or NiMH if you need to recharge, or Lead Acid if you need a ton of capacity and size isn't a limit. Then get a switching regulator module. Best of luck with your project!&lt;/p&gt;&#xA;" OwnerUserId="6886" LastActivityDate="2015-01-24T10:28:27.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8212" PostTypeId="2" ParentId="8196" CreationDate="2015-01-24T11:12:59.047" Score="-1" Body="&lt;p&gt;When using battery, always use a step-up converter, something like LTC3525 or NCP1402. A direct connection of unregulated battery voltage to an analog input can give you a good information on the remaining capacity while the step-up converter still provides stable 3.3V for operation.&lt;/p&gt;&#xA;" OwnerUserId="6901" LastActivityDate="2015-01-24T11:12:59.047" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8213" PostTypeId="2" ParentId="3324" CreationDate="2015-01-24T17:11:32.153" Score="5" Body="&lt;p&gt;just to add to the list - some cheaper boards use &lt;strong&gt;CH340&lt;/strong&gt; chipset &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is a blogpost on how to install the drivers on OSX&#xA;&lt;a href=&quot;http://javacolors.blogspot.ie/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html&quot; rel=&quot;noreferrer&quot;&gt;http://javacolors.blogspot.ie/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that post:&lt;br&gt;&#xA;You can find drivers for this chip on the web site of the chinese manufacturer, here :&#xA;&lt;br&gt;&lt;a href=&quot;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=5&quot; rel=&quot;noreferrer&quot;&gt;http://www.wch.cn/downloads.php?name=pro&amp;amp;proid=5&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6907" LastEditorUserId="313" LastEditDate="2015-01-24T18:07:03.870" LastActivityDate="2015-01-24T18:07:03.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8214" PostTypeId="1" CreationDate="2015-01-24T18:33:09.143" Score="0" ViewCount="1230" Body="&lt;p&gt;I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; but I got a little confused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?&lt;/p&gt;&#xA;" OwnerUserId="6782" LastActivityDate="2015-01-24T18:38:02.000" Title="How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="0" ClosedDate="2015-01-27T23:57:59.717" ContentLicense="CC BY-SA 3.0" />
  <row Id="8215" PostTypeId="2" ParentId="8214" CreationDate="2015-01-24T18:38:02.000" Score="3" Body="&lt;p&gt;Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-24T18:38:02.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8216" PostTypeId="1" CreationDate="2015-01-24T18:30:44.983" Score="0" ViewCount="256" Body="&lt;p&gt;I have an arduino UNO with atmega 328 whose microcontroller got burnt. I bought a new atmega328. I have another working arduino with atmega8. I followed the instructions in &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; but I got a little confused. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I burnt the bootloader into my new atmega328 using atmega8 arduino as described in the link above. Now, can I replace my old atmega328 with this new bootloaded atmega328 to upload sketches to it? Or should I follow the steps described in the link to upload sketches?&lt;/p&gt;&#xA;" OwnerUserId="6782" OwnerDisplayName="Varshith" LastEditorUserId="6452" LastEditDate="2015-01-26T16:33:11.097" LastActivityDate="2015-01-26T16:33:11.097" Title="How do I replace a burnt atmega328 with a new atmega328(bootloaded) in arduino?" Tags="|arduino-uno|bootloader|atmega328|safety|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8217" PostTypeId="2" ParentId="8216" CreationDate="2015-01-24T18:37:05.637" Score="2" Body="&lt;p&gt;Once the bootloader has been burned to it, the chip can replace the one that is currently on the Arduino board. Simply follow normal DIP removal and insertion procedures to replace it.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-01-24T18:37:05.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8218" PostTypeId="2" ParentId="8216" CreationDate="2015-01-24T18:42:27.707" Score="0" Body="&lt;p&gt;You can use the 328p as usual (for an Arduino), once the bootloader is burned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: You just used your Atmega8 as an ISP (In-System-Programmer) to get a bootloader onto your new 328p. The bootloader now enables the 328p to be programmed via serial port.  &lt;/p&gt;&#xA;" OwnerUserId="6914" OwnerDisplayName="Roland Mieslinger" LastActivityDate="2015-01-24T18:42:27.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8220" PostTypeId="2" ParentId="3642" CreationDate="2015-01-24T23:14:03.537" Score="3" Body="&lt;p&gt;Create an Arduino.h in ...\Arduino\hardware\attiny45_85\cores\attiny45_85 containing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;WProgram.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From here&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/87328/arduino-as-isp-for-attiny&quot;&gt;https://electronics.stackexchange.com/questions/87328/arduino-as-isp-for-attiny&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4702" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-24T23:14:03.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8221" PostTypeId="2" ParentId="8159" CreationDate="2015-01-24T23:56:33.130" Score="2" Body="&lt;p&gt;I happen to have received the CC3000 shield yesterday and have been playing with it today...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What do you mean by &quot;receive commands from a website&quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you mean &quot;can it serve a simple website and act upon HTTP requests&quot; (e.g. requests to &lt;a href=&quot;http://arduino.local/on&quot; rel=&quot;nofollow&quot;&gt;http://arduino.local/on&lt;/a&gt; would turn a lamp off and &lt;a href=&quot;http://arduino.local/off&quot; rel=&quot;nofollow&quot;&gt;http://arduino.local/off&lt;/a&gt; would turn if off), then yes it can. You make the HTTP requests using javascript's XMLHTTPRequest if you want to be able to communicate from within a web page without having to re-render a page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an example sketch of an HTTP server included in the CC3000 library that would get you started. Note that the example HTTP server sketch can only handle one HTTP request/response at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will obviously also need some way of controlling a relay of you want to control a lamp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Since you updated your question to include how you are currently communicating:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with socket.io or Firmata, but I'm guessing socket.io is a way of getting your web client (browser) to talk directly Firmata which talks to your Arduino over the USB-Serial connection? If so, then I'm not sure if it's possible to use the Firmata protocol over wireless, but it is possible for the CC3000 to act as a generic TCP server and act on data that it receives wirelessly, so it might be possible to communicate between socket.io and the TCP server. The EchoServer sketch shows how to set up a TCP server to receive raw data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're only turning a lamp on/off you basically only need to control 1 pin. Isn't Firmata a bit overkill for that? Be careful about sketch size. I'm not sure how big Firmata compiles to, but the wireless library with some kind or server is over 22,000 byes (of a possible 32,000) on an Uno, so you might struggle to fit both on.&lt;/p&gt;&#xA;" OwnerUserId="6916" LastEditorUserId="6916" LastEditDate="2015-01-25T11:04:25.843" LastActivityDate="2015-01-25T11:04:25.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8222" PostTypeId="1" CreationDate="2015-01-25T01:19:35.757" Score="2" ViewCount="1113" Body="&lt;p&gt;Im planning a project that involves sending data from a door phone to an android phone and vice versa using the &lt;a href=&quot;https://www.sparkfun.com/products/11678&quot; rel=&quot;nofollow&quot;&gt;RN-52&lt;/a&gt; chip from sparkfun. Because of the nature of the project it is necessary to be able to send and receive audio simultaneously, is this possible? I've done some googling and it seems to me impossible because of sink/source, since you cant have both at the same time (using A2DP). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done with another profile I don't know of?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if that were to work, can the chip handle two way communication? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this project feasible with BT, or should I be looking at WIFI-communication instead? &#xA;Ultimately it would be nice to be able to use BT because of costs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Can I use bluetooth hands free profile? This profile is (AFAIK) intended to send audio to and from a phone (amongst other functionality). The chip does support HFP/HSP, can this work?&lt;/p&gt;&#xA;" OwnerUserId="6741" LastEditorUserId="6741" LastEditDate="2015-01-30T11:51:39.343" LastActivityDate="2015-01-30T11:51:39.343" Title="RN-52 - Bluetooth Audio Module two way communication with Android" Tags="|arduino-uno|bluetooth|android|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8224" PostTypeId="2" ParentId="8196" CreationDate="2015-01-25T13:30:28.113" Score="3" Body="&lt;p&gt;To answer your modified question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running the ATmega328p at 16Mhz with 3.7v is out of spec - see &lt;a href=&quot;https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz&quot;&gt;this EESE answer&lt;/a&gt; for reference or the ATmega datasheet - so the obvious solution would be to lower its speed to 8Mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since you also mentioned that there is an additional GSM breakout board involved (Adafruit Fona), which expects UART (in auto-baud mode) Rx/Tx connection, it might not be that trivial. Further exploration of the Fona library's source code reveals that it has several hard-coded delays (see &lt;code&gt;Adafruit_FONA.cpp::begin&lt;/code&gt;, for example), but its core seems to be implemented inside the &lt;code&gt;Adafruit_FONA::readline&lt;/code&gt; method, which uses an underlying &lt;code&gt;Stream&lt;/code&gt;, which in turns comes from a Software/Hardware serial object, as shown in the &lt;code&gt;FONAtest.ino&lt;/code&gt; example that comes with the library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my experience, Software/Hardware serial should work fine on 8Mhz, except maybe when &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=212962.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;using high baud rates&lt;/a&gt;, which is solvable. &#xA;The hard-coded delays doesn't look like they should cause actual damage except for delay, but you could cut them in half just to see if you can make the library work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional aspect that you should consider is the comment from Adafruit's Fona product page, regarding pin &lt;strong&gt;Vio&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is the pin that you MUST drive with an external voltage from&#xA;  3V-5V to set the logic level converter&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, despite that from the datasheet, the Fona seems to have a voltage regulator, you might still want to consider adding a decoupling capacitor between Vcc and Gnd of your battery, to  mitigate transient current draws from any component in your circuit. &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-25T13:30:28.113" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8225" PostTypeId="1" CreationDate="2015-01-25T14:46:58.053" Score="1" ViewCount="2209" Body="&lt;p&gt;I would like to use a 555 circuit as an external watchdog for my Arduino project. The project is a cellular tracker that goes to sleep for an hour, wakes up and does some measurements, uploads them and then goes to sleep again. The 555 should take care that the active period does not take too long because the systems hangs, and in that case trigger a reset. My first thought was to power the 555 circuit with a PIN of the Arduino so that it only goes on when the system is awake and is turned off while sleeping. &#xA;But this does not work as the reset line has to stay high even while sleeping and if i turn the 555 off reset would also go low. Could a Mosfet help? Any other ideas?&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-25T23:38:58.050" Title="Using 555 as an external Watchdog" Tags="|reset|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8228" PostTypeId="1" CreationDate="2015-01-25T20:20:15.990" Score="0" ViewCount="1225" Body="&lt;p&gt;i have a climate control software which reports data back through the web browser.  Everything seems to be working however I am running into an issue where&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - after a bit it seems the page doesnt refresh completely and instead displays a long list of the same webpage, so i have like 30 pages of the same thing as you scroll down&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - when i woke up in the morning i could not load the page at all&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i am wondering is how can i get this to be stable and reliable so that the climate control software / sensors can run non-stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently as long as i dont use the ethernet shield reporting everything else seems to work great, i leave it on for 12 -20 hours and it still runs, but not with the ethernet reporting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any help wold be apreciated thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Define Start&#xA;#define NOTE_D2  73 //sound note for beep&#xA;#define DHTPIN 2 &#xA;#define DHTTYPE DHT22&#xA;#define DHT2PIN 3 &#xA;#define DHTTYPE2 DHT22 &#xA;#define MAGENTA //Define a color for screen &#xA;#define sclk 8 //screen pin&#xA;#define mosi 5 //screen pin&#xA;#define cs   6 //screen pin&#xA;#define dc   7 //screen pin&#xA;#define rst  rstpin  // you can also connect this to the Arduino reset&#xA;#define ANALOG_IN 0 // for cds light sensor&#xA;&#xA;//Define End&#xA;//Include start&#xA;#include &amp;lt;DHT.h&amp;gt;//dht sensor library&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &amp;lt;Adafruit_ST7735.h&amp;gt; // Hardware-specific library&#xA;#include &amp;lt;SPI.h&amp;gt;//needed to run screen&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;//Include end&#xA;//declare start&#xA;DHT dht2(DHT2PIN, DHTTYPE2);&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;int powerswitch1 = A0;&#xA;int powerswitch2 = A1;&#xA;const int ledPin =  A2;&#xA;const int ledPin2 =  A3;&#xA;Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk);&#xA;char* myString = { &quot;OFF&quot; };//relay1 on / off status&#xA;char* myString2 = { &quot;OFF&quot; };//relay2 on / off status&#xA;const int chipSelect = 4;&#xA;RTC_DS1307 RTC;&#xA;byte mac[] = {&#xA;  0x90, 0xA2, 0xDA, 0x00, 0x23, 0x36 }; //MAC address found on the back of your ethernet shield.&#xA;IPAddress ip(192,168,1,40);&#xA;//decalare end&#xA;EthernetServer server(80);&#xA;&#xA;&#xA;void setup() {&#xA;pinMode(ledPin, OUTPUT); &#xA;pinMode(ledPin2, OUTPUT);&#xA;tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab&#xA;tft.fillScreen(ST7735_RED);//make screen red&#xA;  pinMode(powerswitch1, OUTPUT);&#xA;  pinMode(powerswitch2, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  RTC.begin();&#xA;if (! RTC.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA; //   RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;&#xA;// get time to display &quot;sensor up time&quot;&#xA;  uint16_t time = millis();&#xA; // tft.fillScreen(ST7735_BLACK); //black screen&#xA;  time = millis() - time;&#xA;&#xA;Serial.println(time, DEC);&#xA;&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;void loop(){&#xA;  //Tone Start  &#xA;    tone(9, NOTE_D2);&#xA;    delay(65);&#xA;    noTone(9);&#xA;//Tone End  &#xA;&#xA;//clock start&#xA;  DateTime now = RTC.now();&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;&#xA; //hour conversion to 12 hour start&#xA;   int x;&#xA;   int timeresult;&#xA;   x = (now.hour());&#xA;   if (x &amp;gt; 12) {&#xA;   timeresult = x - 12;&#xA;   }&#xA;   else &#xA;   {&#xA;    timeresult = x;&#xA;   }&#xA;   Serial.println(timeresult);&#xA;    //hour conversion to 24 hour start&#xA;//clock end&#xA;//sensor 1 start&#xA;    //Serial.println(&quot;read DHT22 #1&quot;);&#xA;    float h = dht.readHumidity();&#xA;    float t = dht.readTemperature();&#xA;    float f = dht.readTemperature(true);&#xA;    //sensor 1 end&#xA;    //sensor 2 start&#xA;    //Serial.println(&quot;read DHT22 #2&quot;);&#xA;    float h2 = dht2.readHumidity();&#xA;    float t2 = dht2.readTemperature();&#xA;    float f2 = dht2.readTemperature(true);&#xA;    //sensor 2 end&#xA;    //temp average begin&#xA;    //Serial.println(&quot;average calculation&quot;);&#xA;    float havg = (h + h2) / 2;&#xA;    float favg = (f + f2) / 2;&#xA;    float tavg = (t + t2) / 2;&#xA;    //temp average end&#xA;&#xA;//Relay 1 Start&#xA;    if (h &amp;lt; 42) //top threshold&#xA;    {&#xA;        if (h &amp;lt; 39) //bottom threshhold&#xA;        {&#xA;            digitalWrite(powerswitch1, HIGH);&#xA;            // Turn the Powertail on&#xA;            Serial.println(&quot;Switch ON&quot;);&#xA;digitalWrite(ledPin, HIGH);&#xA;            myString = &quot;ON&quot;;&#xA;        }&#xA;&#xA;    }&#xA;    else&#xA;    {&#xA;                myString = &quot;OFF&quot;;&#xA;        digitalWrite(powerswitch1, LOW);    // turn the Powertail off&#xA;digitalWrite(ledPin, LOW);&#xA;        Serial.println(&quot;Switch OFF&quot;);&#xA;&#xA;    }&#xA;//Relay 1 End&#xA;//Relay 2 Start&#xA;    if (f &amp;lt; 60) //top threshold&#xA;    {&#xA;        if (h &amp;lt; 60) //bottom threshhold&#xA;        {&#xA;            digitalWrite(powerswitch2, HIGH);&#xA;            // Turn the Powertail on&#xA;            Serial.println(&quot;Switch ON&quot;);&#xA;digitalWrite(ledPin2, HIGH);&#xA;            myString2 = &quot;ON&quot;;&#xA;        }&#xA;&#xA;    }&#xA;    else&#xA;    {&#xA;                myString2 = &quot;OFF&quot;;&#xA;        digitalWrite(powerswitch2, LOW);    // turn the Powertail off&#xA;digitalWrite(ledPin2, LOW);&#xA;        Serial.println(&quot;Switch OFF&quot;);&#xA;&#xA;    }&#xA;//Relay 2 End&#xA;//Screen start&#xA;&#xA;delay(500);&#xA;&#xA;tft.fillRect(20,19,80,140, ST7735_RED);//clear text&#xA;//(left wall,top wall px from top,right wall,bottom wall px from top)&#xA;tft.drawRect(20,19,80,140, ST7735_RED);//cleartext&#xA;//active text&#xA;tft.setCursor(35, 20);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(f);&#xA;tft.setCursor(35, 40);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(t);&#xA;tft.setCursor(35, 60);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(h);&#xA;tft.setCursor(25, 120);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(timeresult);&#xA;tft.setCursor(50, 120);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(now.minute(), DEC);&#xA;tft.setCursor(75, 120);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(now.second(), DEC);&#xA;&#xA;//static text&#xA;&#xA;tft.setCursor(105, 20);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;F&quot;);&#xA;tft.setCursor(105, 40);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;C&quot;);&#xA;tft.setCursor(105, 60);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;%&quot;);&#xA;tft.setCursor(52, 80);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(myString);&#xA;tft.setCursor(105, 80);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;H&quot;);&#xA;tft.setCursor(52, 100);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(myString2);&#xA;tft.setCursor(105, 100);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;T&quot;);&#xA;tft.setCursor(52, 140);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(millis() / 1000);&#xA;tft.setCursor(105, 140);&#xA;tft.setTextSize(2);&#xA;tft.setTextColor(ST7735_WHITE);&#xA;tft.println(&quot;-&quot;);&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;tft.print(millis() / 1000);&#xA;//Screen end&#xA;&#xA;&#xA;&#xA;&#xA; EthernetClient client = server.available();&#xA;  if (client) {&#xA;    Serial.println(&quot;new client&quot;);&#xA;    // an http request ends with a blank line&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        Serial.write(c);&#xA;        // if you've gotten to the end of the line (received a newline&#xA;        // character) and the line is blank, the http request has ended,&#xA;        // so you can send a reply&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          // send a standard http response header&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println(&quot;Connection: close&quot;);  // the connection will be closed after completion of the response&#xA;   client.println(&quot;Refresh: 5&quot;);  // refresh the page automatically every 5 sec&#xA;          client.println();&#xA;          client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;          /////CSS&#xA;            client.println(&quot;&amp;lt;style&amp;gt;&quot;);&#xA;            client.println(&quot;#left {&quot;);&#xA;            client.println(&quot;float:left;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text1 {&quot;);&#xA;            client.println(&quot;color: #07BBF2;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text2 {&quot;);&#xA;            client.println(&quot;color: #FC5400;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text3 {&quot;);&#xA;            client.println(&quot;color: #02BA3C;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text4 {&quot;);&#xA;            client.println(&quot;color: #EBF700;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text5 {&quot;);&#xA;            client.println(&quot;color: #F7C600;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;text6 {&quot;);&#xA;            client.println(&quot;color: #000000;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            if (myString == &quot;ON&quot;) {&#xA;            client.println(&quot;humidifier {&quot;);&#xA;            client.println(&quot;color: #02F04E;&quot;);&#xA;            client.println(&quot;font-size: 100%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            }&#xA;            else {&#xA;              client.println(&quot;humidifier {&quot;);&#xA;            client.println(&quot;color: #FC5400;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            }&#xA;            if (myString2 == &quot;ON&quot;) {&#xA;            client.println(&quot;heater {&quot;);&#xA;            client.println(&quot;color: #02F04E;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            }&#xA;            else {&#xA;             client.println(&quot;heater {&quot;);&#xA;            client.println(&quot;color: #FC5400;&quot;);&#xA;            client.println(&quot;font-size: 200%;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            }&#xA;&#xA;             client.println(&quot;#right {&quot;);&#xA;            client.println(&quot;float:right;&quot;);&#xA;            //client.println(&quot;color:red;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            // client.println(&quot;#header {&quot;);&#xA;           // client.println(&quot;background-color:black;&quot;);&#xA;           // client.println(&quot;}&quot;);&#xA;&#xA;&#xA;&#xA;            client.println(&quot;#content {&quot;);&#xA;            client.println(&quot;background-color:grey;&quot;);&#xA;            client.println(&quot;width:500px;&quot;);&#xA;            client.println(&quot;height:200px;&quot;);&#xA;            client.println(&quot;}&quot;);&#xA;            client.println(&quot;&amp;lt;/style&amp;gt;&quot;);&#xA;          ///CSS&#xA;&#xA;          client.println(&quot;&amp;lt;div id = content&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;body bgcolor=&quot;&quot;#000000::&amp;gt;&quot;); //how to change color adruino version&#xA;&#xA;            client.println(&quot;&amp;lt;div id = left&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text4&amp;gt;&quot;);&#xA;            client.print(&quot;Sensor 1&quot;);&#xA;            client.println(&quot;&amp;lt;/text4&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text1&amp;gt;&quot;);&#xA;            client.print(h);&#xA;            client.print(&quot; %\t&quot;);&#xA;            client.println(&quot;&amp;lt;/text1&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;); &#xA;            client.println(&quot;&amp;lt;text2&amp;gt;&quot;);&#xA;            client.print(f);&#xA;            client.println(&quot; &amp;amp;#176;&quot;);&#xA;            client.println(&quot;F&quot;);&#xA;            client.println(&quot;&amp;lt;/text2&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text2&amp;gt;&quot;);&#xA;            client.print(t);&#xA;            client.println(&quot; &amp;amp;#176;&quot;);&#xA;            client.println(&quot;C&quot;);&#xA;            client.println(&quot;&amp;lt;/text2&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;/div&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;div id = right&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text4&amp;gt;&quot;);&#xA;            client.print(&quot;Sensor 2&quot;);&#xA;            client.println(&quot;&amp;lt;/text4&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text1&amp;gt;&quot;);&#xA;            client.print(h2);&#xA;            client.print(&quot; %\t&quot;);&#xA;            client.println(&quot;&amp;lt;/text1&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;); &#xA;            client.println(&quot;&amp;lt;text2&amp;gt;&quot;);&#xA;            client.print(f2);&#xA;            client.println(&quot; &amp;amp;#176;&quot;);&#xA;            client.println(&quot;F&quot;);&#xA;            client.println(&quot;&amp;lt;/text2&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text2&amp;gt;&quot;);&#xA;            client.print(t);&#xA;            client.println(&quot; &amp;amp;#176;&quot;);&#xA;            client.println(&quot;C&quot;);&#xA;            client.println(&quot;&amp;lt;/text2&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;/div&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;div align=center&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text5&amp;gt;&quot;);&#xA;            client.print(&quot;Humidifier: &quot;);&#xA;            client.println(&quot;&amp;lt;/text5&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;humidifier&amp;gt;&quot;);&#xA;            client.print(myString);&#xA;            client.println(&quot;&amp;lt;/humidifier&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text5&amp;gt;&quot;);&#xA;            client.print(&quot;Heater: &quot;);&#xA;            client.println(&quot;&amp;lt;/text5&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;heater&amp;gt;&quot;);&#xA;            client.print(myString2);&#xA;            client.println(&quot;&amp;lt;/heater&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text6&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;p /&amp;gt;&quot;);&#xA;            client.print(millis() / 1000);&#xA;            client.println(&quot;&amp;lt;/text6&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;text6&amp;gt;&quot;);&#xA;            client.print(timeresult);&#xA;            client.print(&quot;:&quot;);&#xA;            client.print(now.minute(), DEC);&#xA;            client.print(&quot;:&quot;);&#xA;            client.print(now.second(), DEC);&#xA;            client.println(&quot;&amp;lt;/text6&amp;gt;&quot;);&#xA;             client.println(&quot;&amp;lt;/div&amp;gt;&quot;); &#xA;              client.println(&quot;&amp;lt;/div&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;          break;&#xA;        }&#xA;        if (c == '\n') {&#xA;          // you're starting a new line&#xA;          currentLineIsBlank = true;&#xA;        }&#xA;        else if (c != '\r') {&#xA;          // you've gotten a character on the current line&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    // give the web browser time to receive the data&#xA;    delay(1);&#xA;    // close the connection:&#xA;    client.stop();&#xA;    Serial.println(&quot;client disonnected&quot;);&#xA;  }&#xA;&#xA;&#xA;delay(3000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6811" LastEditorUserId="6811" LastEditDate="2015-01-25T20:29:43.987" LastActivityDate="2015-05-26T23:23:00.023" Title="Arduino Uno + Ethernet shield stability question" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8229" PostTypeId="2" ParentId="8228" CreationDate="2015-01-25T21:00:06.107" Score="0" Body="&lt;p&gt;I would go for a memory issue - try to rewrite your code in a way that consumes less memory, the easiest first step is to avoid any Serial.printl(&quot;String&quot;); and replace that with Serial.println(F(&quot;String&quot;));. But in general you are using a lot of String objects which should be avoided if possible (try to use char() instead). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check memory consumption of your sketch you can use a function like this and log the values from specific points in the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freeRam () {&#xA;extern int __heap_start, *__brkval; &#xA;int v; &#xA;return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-25T21:00:06.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8230" PostTypeId="2" ParentId="8159" CreationDate="2015-01-25T21:46:39.707" Score="1" Body="&lt;p&gt;Have you heard of aREST.io? There is a wifi library that supports the CC3000 (&lt;a href=&quot;http://arest.io/wifi/&quot; rel=&quot;nofollow&quot;&gt;http://arest.io/wifi/&lt;/a&gt;) that sounds like it might do a similar thing to Firmata&lt;/p&gt;&#xA;" OwnerUserId="6916" LastActivityDate="2015-01-25T21:46:39.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8231" PostTypeId="2" ParentId="8228" CreationDate="2015-01-25T22:37:32.380" Score="0" Body="&lt;p&gt;I used to encounter weird issues, e.g. starting a new instance of a program with Arduino Yun. The issue in the end was power supply, a large capacitor before the voltage regulator has solved the problem. What do you use for power supply?&lt;/p&gt;&#xA;" OwnerUserId="6901" LastActivityDate="2015-01-25T22:37:32.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8232" PostTypeId="2" ParentId="8225" CreationDate="2015-01-25T23:38:58.050" Score="4" Body="&lt;p&gt;ok guys - found the answer: this post here at electronics-stackexchange gave the right hint: &lt;a href=&quot;https://electronics.stackexchange.com/questions/18/watch-dog-timer-arduino&quot;&gt;Watch-Dog Timer&lt;/a&gt;. And my gut feeling was right as well - i simply use a NPN-Mosfet that is being triggered by an Arduino-PIN (which easily can be done while sleeping as well as sleeping means waking up every 8seconds anyway) that connects the capacitor to ground and therefore discharges the guy. Awesome. &#xA;This solution can be used as a real fallback in case of whatever happens, while operating the system with built in watchdog-functions while everything is ok.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-01-25T23:38:58.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8233" PostTypeId="1" CreationDate="2015-01-26T00:20:25.913" Score="3" ViewCount="5169" Body="&lt;p&gt;From what I understand, the Pro Trinket has &quot;Optiboot&quot; which allows it to detect which boot loader you are trying to use, one for USB and one for FTDI. When it's in this &quot;bootloader state&quot; the red LED on pin 13 buses for 10 seconds before it starts to run the program I've programmed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I remove this Optiboot functionality? Would that entail permanently choosing a single boot loader/interface?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem I have with this is that along with the LED on 13, it causes the LED strip I have attached to pins 9, 10, 11 to blink. I would also really like to not have to wait 10 seconds to start running code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the page on Adafruit's site that talks about the &lt;a href=&quot;https://learn.adafruit.com/introducing-pro-trinket/starting-the-bootloader&quot; rel=&quot;nofollow&quot;&gt;bootloader[s] on the Pro Trinket&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="sam" LastEditorUserId="6936" LastEditDate="2015-01-26T09:25:31.640" LastActivityDate="2019-05-26T02:09:19.470" Title="How to remove Adafruit Pro Trinket bootloader flashing startup sequence" Tags="|bootloader|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8235" PostTypeId="1" CreationDate="2015-01-26T03:09:38.500" Score="2" ViewCount="1990" Body="&lt;p&gt;I'm currently working on a Arduino Mega (GPS + IMU + SD card logging + BT). I need the Mega for extra memory and serial port. &#xA;I would like to transition to something with a smaller form factor now. I need help with suggestions for a smaller form factor board/version of Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&#xA;I can't really find anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only small size yet meeting requirements (in terms of memory) option seems to be a &lt;a href=&quot;https://www.microduino.cc/module/view?id=53d7037cb6c69d00003ede53&quot; rel=&quot;nofollow&quot;&gt;Microduino&lt;/a&gt; - &#xA;but I'm not whether all the libraries (SDfat etc.) will work on this.&lt;/p&gt;&#xA;" OwnerUserId="6930" LastEditorUserId="6936" LastEditDate="2015-08-03T12:34:12.817" LastActivityDate="2015-08-03T12:34:12.817" Title="Smaller version of the Mega" Tags="|arduino-mega|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8236" PostTypeId="2" ParentId="8235" CreationDate="2015-01-26T03:55:02.040" Score="1" Body="&lt;p&gt;The ATmega1284P provides 128kB of flash, 16kB of SRAM, 4kB of EEPROM, and 2 USARTs in a 40/44/49-pin package. &lt;a href=&quot;https://github.com/maniacbug/mighty-1284p&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mighty 1284P&lt;/a&gt; provides Arduino support for the '1284P.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There aren't too many actual boards that feature it, but it &lt;a href=&quot;https://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/&quot; rel=&quot;nofollow noreferrer&quot;&gt;can be used very easily&lt;/a&gt; on a breadboard or custom PCB with a &lt;a href=&quot;https://arduino.stackexchange.com/questions/3906/how-do-i-write-an-arduino-program-to-an-avr-chip-without-the-arduino-bootloader&quot;&gt;programmer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-01-26T03:55:02.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8237" PostTypeId="1" CreationDate="2015-01-26T09:46:32.640" Score="0" ViewCount="286" Body="&lt;p&gt;I have a Freeduino USB 1.1 board with atmega 8l-8pu microcontroller on it. When I try to upload program, it shows error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude stk500_getsync() not in sync: resp 0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried reset and the red led blinks which I think suggest bootloader is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino IDE, I have set Arduino Uno and correct port which is shown in device manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One weird problem that I noticed is that no matter which USB port I connect to, it says COM9 on device manager. Is that something to look into?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6937" LastActivityDate="2015-02-01T05:29:21.900" Title="Freeduino avrdude stk500_getsync() not in sync" Tags="|arduino-ide|" AnswerCount="1" CommentCount="2" ClosedDate="2015-03-01T17:33:50.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="8238" PostTypeId="2" ParentId="8233" CreationDate="2015-01-26T09:59:12.777" Score="1" Body="&lt;p&gt;You could take the &lt;a href=&quot;https://github.com/adafruit/Adafruit_ProTrinket_Bootloader&quot; rel=&quot;nofollow&quot;&gt;Pro Trinket bootloader source code&lt;/a&gt; and tweak it to your needs, &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;burn it&lt;/a&gt;, and make sure you have patience and debugging skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the author's (Frank Zhao) source code, it seems that this is the 10 seconds loop you are referring to, located in &lt;strong&gt;main.c&lt;/strong&gt;, line #456:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( ((usbHasRxed != 0) &amp;amp;&amp;amp; (timeout &amp;gt; USBBOOTLOADER_TIMEOUT)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;USBBOOTLOADER_TIMEOUT&lt;/code&gt; variable which is defined to &lt;code&gt;10&lt;/code&gt; at the top of that file, line #70:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define USBBOOTLOADER_TIMEOUT 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and is progressed after 'roughly' 1 second, at line #496:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// roughly 1 second&#xA;#if (F_CPU == 12000000)&#xA;    if (t1ovf &amp;gt; 183) {&#xA;    #elif (F_CPU == 16000000)&#xA;    if (t1ovf &amp;gt; 244) {&#xA;    #endif&#xA;        t1ovf = 0;&#xA;        timeout++;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-01-26T20:28:53.957" LastActivityDate="2015-01-26T20:28:53.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8239" PostTypeId="2" ParentId="8233" CreationDate="2015-01-26T10:13:53.387" Score="0" Body="&lt;p&gt;I'd be careful to remove that section because these ten seconds are not only where the board detects which bootloader to use but also when it is accepting a new sketch at all. So if you'd get rid of that, you wouldn't be able to upload new sketches anymore i guess.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-26T10:13:53.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8240" PostTypeId="1" CreationDate="2015-01-26T10:16:43.060" Score="0" ViewCount="3829" Body="&lt;p&gt;I am using the Ethernet Shield on top of the Arduino Uno. I want to use this setup to access  webpages. But I am unable to access because the ethernet connection is present in a University which requires a proxy server with authentication. I am unsure of what extra code to include so as to get past the proxy which requires authentication.&#xA;Can anyone help in solving this problem?&lt;/p&gt;&#xA;" OwnerUserId="6938" LastActivityDate="2015-01-26T17:13:08.767" Title="Proxy and Authentication in Arduino Uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8242" PostTypeId="1" CreationDate="2015-01-26T13:38:08.413" Score="0" ViewCount="345" Body="&lt;p&gt;I found some code that works to transmit the required signal to an RX-2B RC receiver, the code works great from my Uno but when I tried to run it from my Yún nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code has definitely uploaded as I tested with an LED and the pin is getting a HIGH voltage written to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea what the issue might be? Code below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA;* Control Realtek RX2 (RX2 -G) RC Receiver with Arduino&#xA;*&#xA;* @author Mircea Diaconescu, Octomber 28, 2013&#xA;* @source https://github.com/dimircea/&#xA;* GPL v3 License&#xA;*   &#xA; * Many cheap RC toys are based on TX2 / RX2 transmitter / receiver ICs.&#xA; * This Arduino sketch allows to replace the TX2 based Remote Control with Arduino.&#xA; * Just one single pin is used from the Arduino board.&#xA; *   &#xA; * Connect Arduino pin 10 to the solder point where the toy antenna is connected or         to the toy antenna cable.&#xA; * One can replace pin 10 with other free digital pin available on the Arduino board.&#xA;     *&#xA; * TX-2B/RX-2B datasheet: http://www.datasheetarchive.com/dl/Datasheet-    035/DSA0017137.pdf&#xA; */&#xA;&#xA;/** Functions (aka W1) - as defined by the IC datasheet */&#xA;#define COMMAND_ENDCODE         4&#xA;#define COMMAND_FORWARD        10&#xA;#define COMMAND_FORWARD_TURBO  16&#xA;#define COMMAND_TURBO          22&#xA;#define COMMAND_FORWARD_LEFT   28&#xA;#define COMMAND_FORWARD_RIGHT  34&#xA;#define COMMAND_BACKWARD       40&#xA;#define COMMAND_BACKWARD_RIGHT 46&#xA;#define COMMAND_BACKWARD_LEFT  52&#xA;#define COMMAND_LEFT           58&#xA;#define COMMAND_RIGHT          64&#xA;&#xA;//output pins&#xA;#define ANTENNA_PIN 9&#xA;&#xA;/** Initialize the Arduino data and pin */&#xA;void setup() {&#xA; pinMode( ANTENNA_PIN, OUTPUT);&#xA;}&#xA;&#xA;/** Loop code */&#xA;void loop() {&#xA; // add here your commands to control the RX2 module...&#xA; // for test purposes, here a continuous forward command is sent&#xA;&#xA; sendCommand( COMMAND_FORWARD);&#xA;&#xA;}&#xA;&#xA;/** Send command to the RX2 IC */&#xA;void sendCommand( int command) {&#xA; int w1 = 0, w2 = 0;&#xA;&#xA; /** start code sequence 4 x W2, ~625Hz, Duty Cycle 75% */ &#xA; for ( w2 = 0; w2 &amp;lt; 4; w2++) {&#xA;   digitalWrite( ANTENNA_PIN, HIGH);&#xA;   delayMicroseconds( 1200);&#xA;   digitalWrite( ANTENNA_PIN, LOW);&#xA;   delayMicroseconds( 400);&#xA;  }&#xA;&#xA; /** function code sequence, n x W1, ~1.25KHz, Duty Cycle 50% */&#xA; for ( w1 = 0; w1 &amp;lt; command; w1++) {&#xA;   digitalWrite( ANTENNA_PIN, HIGH);&#xA;   delayMicroseconds( 400);&#xA;   digitalWrite( ANTENNA_PIN, LOW);&#xA;   delayMicroseconds( 400);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6941" LastActivityDate="2015-12-23T08:41:31.713" Title="Works on Uno but not on Yun" Tags="|arduino-uno|arduino-yun|pwm|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8243" PostTypeId="2" ParentId="8242" CreationDate="2015-01-26T14:23:45.617" Score="1" Body="&lt;p&gt;A Yun is like a Leonardo with a CPU running GNU/Linux at its side. If your sketch works with a Leonardo, it's likely to work with a Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uno has a different MCU and thus not every sketch will just work, especially those using the hardware serial. You'll have to convert them.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-01-26T14:23:45.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8244" PostTypeId="1" AcceptedAnswerId="8268" CreationDate="2015-01-26T15:15:54.333" Score="0" ViewCount="1141" Body="&lt;p&gt;I'm new in the Arduino Community and I'm facing a problem when I try to use a PS2 Keyboard and an LCD Display (16x2) on an Arduino Uno with a Wifi shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to write something with the keyboard and display it in the LCD before sending it to a webservice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I use the keyboard and the display on my Arduino WITHOUT the wifi shield --&gt; All is OK. I can write on the display the key that has been pressed.&lt;/li&gt;&#xA;&lt;li&gt;When I use the keyboard and the display on my Arduino WITH the wifi shield --&gt; All is OK until I write something on the display. As soon as I write on the display with the function lcd.print(), the keyboard does not work anymore (it detect the character '2' every time I press a key).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's very surprisingly because if I dont use lcd.print(), the keybord works without any problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a part of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;PS2Keyboard.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 11, 2, 5, 6, 8);&#xA;PS2Keyboard keyboard;&#xA;&#xA;const int DataPin = 9;&#xA;const int IRQpin = 3;&#xA;&#xA;void setup(){      &#xA;  keyboard.begin(DataPin, IRQpin);      &#xA;  lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop(){&#xA;  checkKeyboard();&#xA;}&#xA;&#xA;void checkKeyboard(){&#xA;  if (keyboard.available()) {&#xA;&#xA;    char c = keyboard.read();&#xA;&#xA;    // check for some of the special keys&#xA;    if (c == PS2_ENTER) {&#xA;      Serial.println();&#xA;    } else if (c == PS2_TAB) {&#xA;      Serial.print(&quot;[Tab]&quot;);&#xA;    } else if (c == PS2_ESC) {&#xA;      Serial.print(&quot;[ESC]&quot;);&#xA;    } else if (c == PS2_PAGEDOWN) {&#xA;      Serial.print(&quot;[PgDn]&quot;);&#xA;    } else if (c == PS2_PAGEUP) {&#xA;      Serial.print(&quot;[PgUp]&quot;);&#xA;    } else if (c == PS2_LEFTARROW) {&#xA;      Serial.print(&quot;[Left]&quot;);&#xA;    } else if (c == PS2_RIGHTARROW) {&#xA;      Serial.print(&quot;[Right]&quot;);&#xA;    } else if (c == PS2_UPARROW) {&#xA;      Serial.print(&quot;[Up]&quot;);&#xA;    } else if (c == PS2_DOWNARROW) {&#xA;      Serial.print(&quot;[Down]&quot;);&#xA;    } else if (c == PS2_DELETE) {&#xA;      Serial.print(&quot;[Del]&quot;);&#xA;    } else {&#xA;      Serial.print(c);&#xA;      displayText(c);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void displayText(char c){&#xA;  lcd.clear();&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Pressed key:&quot;);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(c);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does somebody know how to solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much in advance :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here are the pins that I use on the board :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino pin 2 -&gt; LCD pin 11&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 5 -&gt; LCD pin 12&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 6 -&gt; LCD pin 13&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 8 -&gt; LCD pin 14&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 11 -&gt; LCD pin 6&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 12 -&gt; LCD pin 4&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 3 -&gt; Keyboard IRQ&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 9 -&gt; Keyboard Data&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6943" LastEditorUserId="6943" LastEditDate="2015-01-26T16:13:02.663" LastActivityDate="2015-01-30T11:00:55.227" Title="Arduino Uno + Wifi Shield + PS2 Keyboard + LCD Display" Tags="|arduino-uno|wifi|lcd|display|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8245" PostTypeId="2" ParentId="8244" CreationDate="2015-01-26T15:44:02.357" Score="0" Body="&lt;p&gt;You must verify which pins the wifi shield is using and see if they aren't used also by the LCD.&#xA;Can you provide further details on the wifi shield ?&lt;/p&gt;&#xA;" OwnerUserId="4971" LastActivityDate="2015-01-26T15:44:02.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8246" PostTypeId="2" ParentId="8233" CreationDate="2015-01-26T16:21:04.267" Score="1" Body="&lt;p&gt;Just program the pro trinket using ISP. (not using the USB connector). For example by using an &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Arduino as a ISP-programmer&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are brave, you could change the bootloader to only run when the reset button was pressed, and not at power-up. I've done exactly that for the regular trinket (&lt;a href=&quot;https://github.com/beargun/Adafruit-Trinket-Gemma-Bootloader/commit/4451cecf7ebcce8abb9f5a1e9c8c9ab3fe591a3d&quot; rel=&quot;nofollow&quot;&gt;see my github&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-01-26T16:21:04.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8248" PostTypeId="2" ParentId="8240" CreationDate="2015-01-26T17:13:08.767" Score="2" Body="&lt;p&gt;Any semi-reputable authentication mechanism would be performed over HTTPS, which is an encrypted connection - this would require an SSL library to be installed for use along with the normal Ethernet and HTTP libraries, and I don't believe the arduino really has the processing capability to make connections like this feasible.&#xA;Unfortunately this is one of those cases where a more sophisticated device may be more appropriate.... (like a Beaglebone Black, or a Raspberry Pi.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that you could add headers into the HTTP connection packet to either bypass proxy authentication, or include a cookie that has already undergone authentication and is cached by the proxy. How you do this is almost entirely down to how your proxy works. You may also find this doesn't work unless you spoof the MAC address of your device to match that of the machine used to fulfill the authentication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is entirely possible to set up a system to share the internet connection (act as a router) between two adapters - so you end up making connection requests to webpages, but the authenticated proxy only sees requests coming from your system (this is kind of how mobile phone tethering works, when you access the internet on a laptop or tablet through your smartphone's internet connection).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If&lt;/strong&gt; the proxy supports unencrypted authentication, it may be possible to pass through username/password details in plaintext (or Base64 encoded) in &lt;a href=&quot;http://en.wikipedia.org/wiki/Basic_access_authentication&quot; rel=&quot;nofollow noreferrer&quot;&gt;Basic access authentication&lt;/a&gt;, which is what HTTP (and HTTPS) often uses - but this is unsafe on HTTP and is &lt;strong&gt;VERY&lt;/strong&gt; unsafe when any part of the connection is publicly transmitted - like when using wifi, for example. (Doesn't matter if the wifi is encrypted - as on a university network, everyone who can connect to the wifi can see your wifi traffic (typically).)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're going to be using your own personal university login credentials to do this, make sure you always use ethernet to do it, not wifi, and if possible, obtain a second username/password explicitly for connecting this way - you don't want to have to hard-code your own personal username and password into source code that you have to give to anyone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a few links to get you started:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/10023636/http-spec-proxy-authorization-and-authorization-headers&quot;&gt;HTTP Spec: Proxy-Authorization and Authorization headers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://superuser.com/questions/334912/how-to-use-authentication-in-an-http-proxy&quot;&gt;How to use authentication in an HTTP Proxy?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/X-Forwarded-For&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia: X-Forwarded-For&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6286" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-01-26T17:13:08.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8250" PostTypeId="2" ParentId="8235" CreationDate="2015-01-26T20:07:29.283" Score="0" Body="&lt;p&gt;The link uses the same chip that Ignacio recommended.  The libraries will need some minor edits, but many of the standard ones do have a 1284P fork.  It is mostly just redoing pin assignments, or adding the 1284P to the board definitions.  I am working on a similar project and have gotten the 1284P to work with SDfat, a bunch of standard GPS libraries, and TinyGPS++ .&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-01-26T20:07:29.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8251" PostTypeId="2" ParentId="8228" CreationDate="2015-01-26T20:16:10.267" Score="1" Body="&lt;p&gt;I have had to program in a reset for the network connection on quite a few of my ethernet projects.  I am not entirely sure the cause, but adding a close connection; open connection to run every x minutes seems to have helped prevent both the duplicating content and the timeout issues.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-01-26T20:16:10.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8252" PostTypeId="1" CreationDate="2015-01-26T20:20:51.763" Score="0" ViewCount="178" Body="&lt;p&gt;Would it be possible to instead of passing a state via a REST browser:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digital/13/1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to set an int value? For example, if in the sketch if I would name an int: 2, could I set this to 48 via REST?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how?&lt;/p&gt;&#xA;" OwnerUserId="6951" LastEditorUserId="220" LastEditDate="2015-01-28T02:56:20.120" LastActivityDate="2015-01-28T02:56:20.120" Title="Arduino Yun, pass int data true REST" Tags="|arduino-yun|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8254" PostTypeId="2" ParentId="4739" CreationDate="2015-01-27T00:22:57.223" Score="0" Body="&lt;p&gt;There is another possibility, which I have had in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My AVR was brand new, and it was set to use the internal resonator, at 1/8th speed, for a total of 1mhz. This was too slow to program using the default settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had an USBASP, and it very conveniently had &quot;SLOW SCK&quot; jumper option, to slow down the programming. This was enough to program it, and if I'd wanted to use an external crystal clock (which I didn't, and 1mhz was fast enough for the specific project), I could have changed the fuses Check out &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;http://www.engbedded.com/fusecalc/&lt;/a&gt; to calculate new fuse settings. Be careful, I managed to set one chip to the wrong fuses, and am no longer able to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. - I used AVRDUDE to program the fuses. You should be able to read the current values, before you start - again, at slow speed. AVRDUDE has the '-B' option to slow down the programming, if you do not have the &quot;SLOW SCK&quot; jumper option, option -B10 should be plenty (default = -B1 I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When checking what the current fuse settings are, I think the main ones that slow down the clock are: CKSEL and SUT (the top dropdown list on the calculator website), and CKDIV8 - divide clock by 8; the second tickbox on the list. The defaults for these for AtMega 168 should be: Internal RC Oscillator: 8mhz, and the &quot;Divide clock by 8&quot; option selected.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-27T00:31:19.617" LastActivityDate="2015-01-27T00:31:19.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8256" PostTypeId="1" AcceptedAnswerId="8294" CreationDate="2015-01-27T00:50:31.387" Score="0" ViewCount="4079" Body="&lt;p&gt;I just received my first &lt;a href=&quot;http://www.elecfreaks.com/wiki/index.php?title=NFC_Bridge&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino board&lt;/a&gt; which is essentially a Leonardo (ATmega32U4) customized to include a NFC reader (PN532).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug it in, the PWR LED comes on steady, the D13 LED flashes a few times, and then the STA LED blinks once and only the PWR LED is left on. I can upload a basic sketch to the correct Serial Port, but the Serial Monitor is always empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have noticed that, when uploading the sketch, the RX/TX LEDs stay off (which I thought was a sign of uploading/downloading data). I figured this was the root of my issue so I tried to look into it further. Running &lt;code&gt;lsusb&lt;/code&gt; does not find the device and &lt;code&gt;dmesg&lt;/code&gt; does not show any information when (un)plugging the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried on a Windows install, but couldn't install the Leonardo drivers since Device Manager wouldn't register any unknown USB/Arduino devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think my board is dead on arrival or am I doing something wrong?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just uploaded the Blink tutorial sketch and it uploaded &quot;successfully&quot; but I noticed no differences. Please note that I don't have an external LED attached, but am looking at the board's LED on pin 13. This pin already flashes a few times (as mentioned above) on a reset, so I modified the delay times and still noticed no change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bbb6n.png&quot; alt=&quot;uploaded sketch&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am uploading using board Leonardo, as recommended for my hardware, and the serial port /dev/ttyS0. I thought this was the right port because I remember not seeing it at first, but on second thought I had a permission issue at first (which is now resolved) causing me to not see the port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;So it looks like my board is&lt;/em&gt; &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;detected by my computer and I'm successfully uploading sketches to a meaningless port.&lt;/em&gt; Any troubleshooting options for me? I've tried different USB ports and am, as of recently, plugging my board into external power (9V). The only thing I can think of that on my end is that I'm using a Y-cable for my USB connection (I have a normal Mini-USB coming tomorrow via Amazon) since it is all I had. I can also confirm that this USB connection &lt;strong&gt;&lt;em&gt;does&lt;/em&gt;&lt;/strong&gt; power the board when plugged in.&lt;/p&gt;&#xA;" OwnerUserId="6957" LastEditorUserId="6957" LastEditDate="2015-01-27T15:52:13.423" LastActivityDate="2015-01-28T20:46:51.343" Title="Arduino board not recognized by Linux (dmesg, lsusb, etc.)" Tags="|arduino-leonardo|uploading|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8257" PostTypeId="1" AcceptedAnswerId="8258" CreationDate="2015-01-26T21:35:43.947" Score="3" ViewCount="900" Body="&lt;p&gt;I'm trying to use 3 pins as capacitive pins along side the &lt;a href=&quot;http://sensorium.github.io/Mozzi/&quot; rel=&quot;nofollow&quot;&gt;Mozzi&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had several attempts and so far the closest I had was using code from the &lt;a href=&quot;http://playground.arduino.cc/Code/ADCTouch&quot; rel=&quot;nofollow&quot;&gt;ADCTouch library&lt;/a&gt; straight into the main code, but with the current implementation (removing averaging and taking less samples to speed things up) it's only fast enough to process 1 pin and I'd like to use 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my implementation so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  Based on the Gain Example changing the gain of a sinewave,&#xA;    using Mozzi sonification library.&#xA;&#xA;    Demonstrates the use of a control variable to influence an&#xA;    audio signal.&#xA;&#xA;    Circuit: Audio output on digital pin 9 on a Uno or similar, or&#xA;    DAC/A14 on Teensy 3.0/3.1, or &#xA;    check the README or http://sensorium.github.com/Mozzi/&#xA;&#xA;    Mozzi help/discussion/announcements:&#xA;    https://groups.google.com/forum/#!forum/mozzi-users&#xA;&#xA;    Tim Barrass 2012, CC by-nc-sa.&#xA;*/&#xA;&#xA;#include &amp;lt;MozziGuts.h&amp;gt;&#xA;#include &amp;lt;Oscil.h&amp;gt; // oscillator template&#xA;#include &amp;lt;tables/sin2048_int8.h&amp;gt; // sine table for oscillator&#xA;&#xA;// use: Oscil &amp;lt;table_size, update_rate&amp;gt; oscilName (wavetable), look in .h file of table #included above&#xA;Oscil &amp;lt;SIN2048_NUM_CELLS, AUDIO_RATE&amp;gt; aSin(SIN2048_DATA);&#xA;&#xA;// control variable, use the smallest data size you can for anything used in audio&#xA;byte gain = 255;&#xA;&#xA;//ADC Touch setup&#xA;int sampleCount[3] = {0};&#xA;int values[3] = {0};&#xA;&#xA;void setup(){&#xA;  startMozzi(); // start with default control rate of 64&#xA;  aSin.setFreq(4200); // set the frequency&#xA;}&#xA;&#xA;void updateControl(){&#xA;  if(gain &amp;gt; 3){&#xA;    gain = gain - 3 ; &#xA;  }else{&#xA;    gain = 0;&#xA;  }&#xA;  //begin ADCTouch &#xA;  pinMode(A4, INPUT_PULLUP);&#xA;&#xA;  ADMUX |=   0b11111;&#xA;  ADCSRA |= (1&amp;lt;&amp;lt;ADSC); //start conversion&#xA;  ADCSRA |= (1&amp;lt;&amp;lt;ADIF); //reset the flag&#xA;&#xA;  pinMode(A4, INPUT);&#xA;&#xA;  values[0] = mozziAnalogRead(A4);&#xA;  sampleCount[0]++;&#xA;  //end ADCTouch &#xA;&#xA;  if(sampleCount[0] == 64){//wait for 64 samples&#xA;    if(values[0] &amp;gt; 500) {//did we get a touch with all these samples ?&#xA;      gain = 255;//amp it up&#xA;    }&#xA;    sampleCount[0] = 0;//reset count&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;int updateAudio(){&#xA;  return (aSin.next()* gain)&amp;gt;&amp;gt;8; // shift back to STANDARD audio range, like /256 but faster&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  audioHook(); // required here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is as soon as do the pinMode calls for the second pin I'd like to use (A5) so I'm guessing pinMode needs to work faster. To use &lt;code&gt;pinMode(INPUT_PULLUP)&lt;/code&gt; and &lt;code&gt;pinMode(INPUT)&lt;/code&gt; calls for pins A4,A5 and digital 10, now can I write this using direct port manipulation ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm new to avr/arduino internals and slowly getting the grips with this).&lt;/p&gt;&#xA;" OwnerUserId="3505" OwnerDisplayName="George Profenza" LastActivityDate="2015-01-27T01:15:18.720" Title="How can I make pinMode calls faster?" Tags="|avr|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8258" PostTypeId="2" ParentId="8257" CreationDate="2015-01-26T21:41:48.587" Score="7" Body="&lt;p&gt;First, &lt;a href=&quot;https://www.google.com/search?q=arduino+pin+mapping&quot;&gt;figure out which port and pin you're using&lt;/a&gt;. Then, manipulate them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRC &amp;amp;= ~_BV(PC5);&#xA;PORTC |= _BV(PC5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRF &amp;amp;= ~_BV(PF5);&#xA;PORTF |= _BV(PF5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRF &amp;amp;= ~_BV(PF0);&#xA;PORTF |= _BV(PF0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-01-26T21:41:48.587" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="8260" PostTypeId="2" ParentId="3960" CreationDate="2015-01-27T01:26:29.620" Score="0" Body="&lt;p&gt;If you want accurate data (i.e. not by dead reckoning) then possibly GPS is an option. I suspect you will need to surface for it to work, as GPS signals are fairly week at the best of times - on a previous car I had, the windscreen was enough to stop the signal.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-27T01:26:29.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8261" PostTypeId="1" CreationDate="2015-01-27T02:23:09.783" Score="0" ViewCount="1977" Body="&lt;p&gt;I recently purchased a W5100 based ethernet shield for my arduino Uno, and looks like &lt;a href=&quot;http://yourduino.com/sunshop2/images/products/large_243_Ethernet-W5100-3-1024.jpg&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. I had been following the guide &lt;a href=&quot;http://arduino-info.wikispaces.com/Ethernet&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, and connected the pins accordingly - 5V to 5V, GND to GND, MOSI to 11, MOSO to 12, SCK to 13, and SS to ten.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I booted up a default sketch (webServer, under Ethernet), and plugged in and ethernet cable. - PWR, LINK, SPD,and FDX all lit up, with Rx blinking for first 10 or so seconds. I then go to the IP specified on the arduino sketch, and nada. Also, my router doesn't show the shield under the attached devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I figure it's a problem with my connections. Can anyone help me? Googling has only brought my lots of info about shields, and little info on these modules. &lt;/p&gt;&#xA;" OwnerUserId="4722" LastActivityDate="2015-02-27T12:47:26.633" Title="W5100 module hookup help - Not a shield" Tags="|arduino-uno|pins|ethernet|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8263" PostTypeId="2" ParentId="8160" CreationDate="2015-01-27T05:37:16.953" Score="1" Body="&lt;p&gt;There is a good practical question and interesting issues raised here, but this part:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;my understanding of OSH is that all its components must be open source.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would say your understanding is wrong, where did you get that from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The design (i.e. how to arrange components) must be open source. Ideally the components would be Open Source too, but practicality dictates that components must be bought &quot;off the shelf&quot;. IOW, overall the design should aim for &quot;as Open Source as much as possible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing about hardware is that to realize a design components must be bought, and those components often contain proprietary IP. Of course, the same problem applies to Open Source Software, to run it I need to buy a CPU from Intel, AMD, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So while all open source designs must rely on some proprietary IP as a base platform, the practical question is how easily can the design be moved to another platform (portability), and how easily a component can be substituted (fungibility).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is only one source of AVR chips and that is Atmel. Other components, like a 3.3V regulator can be easily substituted with other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino core software does not rely solely on AVR architecture, in principle it is portable to any CPU platform, in practice any platform that is targeted by GCC. The fact that some Arduinos are not AVR e.g. Due, shows that.&lt;/p&gt;&#xA;" OwnerUserId="6960" LastActivityDate="2015-01-27T05:37:16.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8264" PostTypeId="2" ParentId="8252" CreationDate="2015-01-27T07:48:03.663" Score="1" Body="&lt;p&gt;Check out the &lt;a href=&quot;http://arduino.cc/en/Tutorial/TemperatureWebPanel&quot; rel=&quot;nofollow&quot;&gt;TemperatureWebPanel&lt;/a&gt; example: you'll see that you can make your own REST APIs and pass any values your sketch can handle.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-01-27T07:48:03.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8267" PostTypeId="1" CreationDate="2015-01-27T14:19:38.737" Score="2" ViewCount="645" Body="&lt;p&gt;I have a SparkFun Red board (Arduino Uno R3) with a SparkFun CC3000 shield attached. I am trying to post data to the &quot;data.sparkfun.com&quot; service in order to test a basic Wifi data logger. I am using the AdaFruit CC3000 library for the sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is am having is that immediately after a power off and reset, the HTTP Get is successful. However, when the loop runs again, the post fails. Usually on the 2nd attempt. I have had a few times where it has looped 2-3 time before failing. But it always fails. If I reset the board with the push button or by disconnecting the serial monitor and reconnecting, it still fails to send the HTTP request. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked my ram usage, and it doesn't appear to have any sort of leak in that regards. I have spent days looking online for similar issues, and can't seem to find anything related. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this all the more confusing, the board just seems to freeze, it doesn't give any sort of error on anything. And the freeze seems to happen at different places, nothing seems consistent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would someone mind checking my sketch code, seeing if there is anything glaring; maybe I have a bad board? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;    ////////////////////////////////////&#xA;    // CC3000 Shield Pins &amp;amp; Variables //&#xA;    ////////////////////////////////////&#xA;    // Don't change these unless you're using a breakout board.&#xA;    #define ADAFRUIT_CC3000_IRQ   2&#xA;    #define ADAFRUIT_CC3000_VBAT  7&#xA;    #define ADAFRUIT_CC3000_CS    10&#xA;    #define IP_ADDR_LEN     4   // Length of IP address in bytes&#xA;&#xA;    #define SensorPin A0&#xA;&#xA;    ////////////////////&#xA;    // WiFi Constants //&#xA;    ////////////////////&#xA;    #define WLAN_SSID &quot;Hayes&quot;&#xA;    #define WLAN_PASS &quot;123456&quot;&#xA;    #define WLAN_SECURITY WLAN_SEC_WPA2&#xA;    #define timeout 30000&#xA;    #define website &quot;data.sparkfun.com&quot;&#xA;    #define publicKey &quot;MGg93JbM8LFJAQxG3jK0&quot;&#xA;    #define privateKey &quot;nz9M8WZVaXU7WXz4VnlX&quot;&#xA;    #define NUM_FIELDS 1&#xA;&#xA;    // Initialize the CC3000 objects (shield and client):&#xA;    Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,&#xA;                             ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);&#xA;&#xA;    /////////////////&#xA;    // Phant Stuff //&#xA;    /////////////////&#xA;    const String fieldNames[1] = { &quot;value&quot; };&#xA;    String fieldData[1];&#xA;    uint32_t ip = 0;&#xA;&#xA;    //////////////////////&#xA;    // Input Pins, Misc //&#xA;    //////////////////////&#xA;&#xA;    void setup()&#xA;    {&#xA;      wdt_disable();&#xA;      Serial.flush();&#xA;      Serial.begin(115200);&#xA;      Serial.println(F(&quot;\nInitializing...&quot;));&#xA;      if (!cc3000.begin())&#xA;      {&#xA;        Serial.println(F(&quot;Couldn't being()! Check your wiring?&quot;));&#xA;        while (1);&#xA;      }&#xA;&#xA;      //Connect to WiFi network&#xA;      Serial.print(F(&quot;Connecting to WiFi network... &quot;));&#xA;      Serial.println(String(WLAN_SSID));&#xA;      cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY, 3);&#xA;      Serial.println(F(&quot;done!&quot;));&#xA;      while (!cc3000.checkDHCP())&#xA;      {&#xA;        delay(1000);&#xA;      }&#xA;      Serial.print(F(&quot;data.sparkfun.com -&amp;gt; &quot;));&#xA;      while (ip == 0)&#xA;      {&#xA;        if (!cc3000.getHostByName(&quot;data.sparkfun.com&quot;, &amp;amp;ip)) {&#xA;          Serial.println(F(&quot;Couldn't Resolve!&quot;));&#xA;          while (1) {}&#xA;        }&#xA;        delay(1000);&#xA;      }&#xA;    }&#xA;&#xA;    void loop()&#xA;    {&#xA;      cc3000.printIPdotsRev(ip);&#xA;      Serial.println(F(&quot;&quot;));&#xA;      float moisture = analogRead(SensorPin);&#xA;      fieldData[0] = String(moisture);&#xA;      Serial.println(&quot;Sensor Reading: &quot; + String(moisture));&#xA;      int t = millis();&#xA;      //wdt_enable(WDTO_8S);&#xA;      Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);&#xA;      if (client.connected()&amp;amp;&amp;amp;&#xA;        ((millis() - t) &amp;lt; timeout))&#xA;      {&#xA;        Serial.println(F(&quot;Connection to Sparkfun data server.&quot;));&#xA;        Serial.print(F(&quot;Sending Request...&quot;));&#xA;        client.print(&quot;GET /input/&quot;);&#xA;        client.print(publicKey);&#xA;        client.print(&quot;?private_key=&quot;);&#xA;        client.print(privateKey);&#xA;          client.print(&quot;&amp;amp;&quot;);&#xA;          client.print(fieldNames[0]);&#xA;          client.print(&quot;=&quot;);&#xA;          client.print(fieldData[0]);    &#xA;        client.println(&quot; HTTP/1.1&quot;);&#xA;        client.print(&quot;Host: &quot;);&#xA;        client.println(website);&#xA;        client.println(&quot;Connection: close&quot;);&#xA;        client.println();&#xA;        Serial.println(F(&quot;HTTP command posted, getting response.&quot;));&#xA;      }&#xA;      else {&#xA;          Serial.println(F(&quot;Connection to website failed.&quot;));    &#xA;        }&#xA;&#xA;    //  while (client.connected())&#xA;    //  {&#xA;    //    while (client.available())&#xA;    //    {&#xA;    //      char c = client.read();&#xA;    //      Serial.print(c);&#xA;    //    }&#xA;    //  }&#xA;      client.close();&#xA;      Serial.println(F(&quot;Posting Data Complete&quot;));&#xA;      //wdt_reset();&#xA;      //cc3000.disconnect();&#xA;&#xA;      //reset watchdog and disable&#xA;      //wdt_reset();&#xA;      wdt_disable();&#xA;&#xA;      delay(15000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6970" LastActivityDate="2015-01-27T14:19:38.737" Title="Sparkfun Red board and CC3000 shield not allowing multiple HTTP_GET requests." Tags="|arduino-uno|shields|wifi|adafruit|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8268" PostTypeId="2" ParentId="8244" CreationDate="2015-01-27T14:21:23.717" Score="0" Body="&lt;p&gt;As you say, I can't use pins 10, 11, 12, 13 because they are used for the SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; So, I tried to use the pins 4 and 7 instead of 11 and 12.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the pin 7 is used by the Wifi shield (Handshake) and I have no other free digital pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; So, I tried to use an analog pin instead of the pin 7 and ..... it works very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my final solution :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Pin 2 -&gt; LCD Pin 4 (RS)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 3 -&gt; Keyboard IRQ&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 4 -&gt; LCD Pin 11 (D4)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 5 -&gt; LCD Pin 12 (D5)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 6 -&gt; LCD Pin 13 (D6)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 7 -&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 8 -&gt; LCD Pin 14 (D7)&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 9 -&gt; Keyboard Data&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 10 -&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 11 -&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 12 -&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 13 -&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino Pin 14 (= Analog 1) -&gt; LCD Pin 6 (E)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6943" LastEditorUserId="6943" LastEditDate="2015-01-30T11:00:55.227" LastActivityDate="2015-01-30T11:00:55.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8269" PostTypeId="2" ParentId="8244" CreationDate="2015-01-27T17:00:59.910" Score="1" Body="&lt;p&gt;Sorry I do not have enough reputation to place a comment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Valentin from the link, you provided, to the wifi shield it states that it uses pins 11 ,12 and 13 on the UNO which will give you a conflict on pins 11 and 12 with the LCD. Not sure why that manifests as an apparent keyboard error though: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the linked page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino communicates with both the Wifi shield's processor and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Uno and pins 50, &gt;51, and 52 on the Mega. On both boards, pin 10 is used to select the HDG204 and pin 4 for &gt;the SD card. These pins cannot be used for general I/O. On the Mega, the hardware SS pin, &gt;53, is not used to select either the HDG204 or the SD card, but it must be kept as an output or the SPI interface won't work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again sorry this is not a full answer but thought it may help.&lt;/p&gt;&#xA;" OwnerUserId="6973" LastActivityDate="2015-01-27T17:00:59.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8271" PostTypeId="1" CreationDate="2015-01-27T18:20:26.620" Score="1" ViewCount="473" Body="&lt;p&gt;It appears to me that each Arduino has (should have?) a unique /dev/tty...USB... number assigned. Why this isn't explained anywhere (that I can find) is a mystery. When I plug my problem Nano into a USB port on my iMac no /dev/tty... for it appears. It used to work. Have I fried it? Can this be fixed?&lt;/p&gt;&#xA;" OwnerUserId="6976" LastActivityDate="2015-01-29T06:59:25.547" Title="Arduino Nano -- cannot download, no /dev/tty*** device" Tags="|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8273" PostTypeId="1" CreationDate="2015-01-27T20:04:00.237" Score="3" ViewCount="49702" Body="&lt;p&gt;I started recently working with a uBlox Neo 6M GPS module (data sheet &lt;a href=&quot;http://www.u-blox.com/images/downloads/Product_Docs/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.u-blox.com/images/downloads/Product_Docs/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf&lt;/a&gt;). I connected it to an Arduino Uno as shown:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS  Arduino&#xA;VCC-- 3.3V&#xA;RX -- D11&#xA;TX -- D10&#xA;GND-- GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this example code from TinyGps++ (of course, changing the pins and the gpsbaud to 9600, which is the gps' default).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;/*&#xA;   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.&#xA;   It requires the use of SoftwareSerial, and assumes that you have a&#xA;   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).&#xA;*/&#xA;static const int RXPin = 10, TXPin = 11;&#xA;static const uint32_t GPSBaud = 9600;&#xA;&#xA;// The TinyGPS++ object&#xA;TinyGPSPlus gps;&#xA;&#xA;// The serial connection to the GPS device&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  ss.begin(GPSBaud);&#xA;  Serial.println(F(&quot;DeviceExample.ino&quot;));&#xA;  Serial.println(F(&quot;A simple demonstration of TinyGPS++ with an attached GPS module&quot;));&#xA;  Serial.print(F(&quot;Testing TinyGPS++ library v. &quot;)); Serial.println(TinyGPSPlus::libraryVersion());&#xA;  Serial.println(F(&quot;by Mikal Hart&quot;));&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;  // This sketch displays information every time a new sentence is correctly encoded.&#xA;  while (ss.available() &amp;gt; 0)&#xA;    if (gps.encode(ss.read()))&#xA;      displayInfo();&#xA;  if (millis() &amp;gt; 5000 &amp;amp;&amp;amp; gps.charsProcessed() &amp;lt; 10) {&#xA;    Serial.println(F(&quot;No GPS detected: check wiring.&quot;));&#xA;    while(true);&#xA;  }&#xA;}&#xA;&#xA;void displayInfo() {&#xA;  Serial.print(F(&quot;Location: &quot;)); &#xA;  if (gps.location.isValid()) {&#xA;    Serial.print(gps.location.lat(), 6);&#xA;    Serial.print(F(&quot;,&quot;));&#xA;    Serial.print(gps.location.lng(), 6);&#xA;  } else {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;  Date/Time: &quot;));&#xA;  if (gps.date.isValid()) {&#xA;    Serial.print(gps.date.month());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.day());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.year());&#xA;  } else {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot; &quot;));&#xA;  if (gps.time.isValid()) {&#xA;    if (gps.time.hour() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.hour());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.minute() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.minute());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.second() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.second());&#xA;    Serial.print(F(&quot;.&quot;));&#xA;    if (gps.time.centisecond() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.centisecond());&#xA;  } else {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I do not get the GPS LED to blink, as well as my Arduino's RX LED, so the module is not transmitting any data. This is the output from the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A simple demonstration of TinyGPS++ with an attached GPS module&#xA;    Testing TinyGPS++ library v. 0.92&#xA;    by Mikal Hart&#xA;&#xA;    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00&#xA;    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="6979" LastEditorUserId="4628" LastEditDate="2017-08-02T07:29:00.317" LastActivityDate="2021-07-08T07:35:25.723" Title="uBlox Neo 6M GPS module not responding" Tags="|arduino-uno|tinygps|gps|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8274" PostTypeId="2" ParentId="1829" CreationDate="2015-01-27T20:33:05.063" Score="1" Body="&lt;p&gt;You really just need to scope the signals, even if it's with a DSO Nano-type scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without downloading the datasheets:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I would guess your pull-up is probably too small, but possibly too large (scope it)&lt;/li&gt;&#xA;&lt;li&gt;Slew rate may be either insufficient or too steep (scope it)&lt;/li&gt;&#xA;&lt;li&gt;Be aware that the ATTiny runs at &quot;8MHz&quot;, and not 8.00MHz. The timing error can be off enough to cause communication issues at high speeds while working well at lower speeds (scope it, and/or start at default and incrementally increase speed by 0.5MHz until it stops working)&lt;/li&gt;&#xA;&lt;li&gt;MMA may not support a typical protocol feature being used, i.e. 'repeated start', burst transfers, etc. (datasheet register/programming section)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit: Both the ATTiny and the MMA should have bypass capacitors near the power pins.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="220" LastEditDate="2015-01-28T02:52:03.070" LastActivityDate="2015-01-28T02:52:03.070" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8276" PostTypeId="1" AcceptedAnswerId="8281" CreationDate="2015-01-27T21:46:29.153" Score="5" ViewCount="3622" Body="&lt;p&gt;I am thinking about building a circuit that is literally going to take 11 of the 14 digital pins of an &lt;code&gt;UNO&lt;/code&gt; to communicate with an SD card and an external EEPROM chip (EEPROM programmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 4 shift registers and the SD card, I will have 1 digital pin left.  Well, I'm also reserving pins 0/1 for serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I need to read some external buttons and I have the 6 analog pins that I haven't touched.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will only need about 4-5 push buttons in my design so they should fit nicely on A0+.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is, will I run into any issues doing this?  Or, are the analog inputs better left for true analog reading?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2015-01-28T07:07:36.407" Title="Is it wise to use analog input pins to read digital buttons?" Tags="|arduino-uno|analogread|digital|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8277" PostTypeId="2" ParentId="8276" CreationDate="2015-01-27T22:58:43.717" Score="2" Body="&lt;p&gt;If you have no use for analog pins there is no problem. A5/A6 are used for I²C (on the Uno).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-01-27T22:58:43.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8278" PostTypeId="2" ParentId="8143" CreationDate="2015-01-28T00:22:00.103" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/Wiznet/WizFiShield/blob/master/Software/WizFiShield/examples/WizFiWebServerTest/WizFiWebServerTest.ino&quot; rel=&quot;nofollow&quot;&gt;The library provides an example for a server.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what it looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/******************************************************************&#xA; WizFiShield Web Server Test Example&#xA;&#xA; A simple web server that shows &quot;Hello World&quot; string &#xA;&#xA; Circuit:&#xA; WizFi2x0 connected to Arduino via SPI&#xA;&#xA; RST: pin 2  // Output&#xA; DRDY: pin 3  // Input&#xA; CSB: pin 4  // output&#xA; MOSI: pin 11  // output&#xA; MISO: pin 12  // input&#xA; SCK: pin 13  // out&#xA;&#xA; Created 27 Sep. 2012&#xA; by James YS Kim  (jameskim@wiznet.co.kr, javakys@gmail.com)&#xA;&#xA; Modified 27 May. 2013&#xA; by Jinbuhm Kim  (jbkim@wiznet.co.kr, jinbuhm.kim@gmail.com)&#xA;*****************************************************************/&#xA;&#xA;// WizFi210 communicates using SPI, so include the SPI library:&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WizFi2x0.h&amp;gt;&#xA;#include &amp;lt;WizFiClient.h&amp;gt;&#xA;#include &amp;lt;WizFiServer.h&amp;gt;&#xA;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;#define SSID    &quot;&quot;        // SSID of your AP&#xA;#define Key     &quot;&quot;  // Key or Passphrase&#xA;// Wi-Fi security option (NO_SECURITY, WEP_SECURITY, WPA_SECURITY, WPA2PSK_SECURITY)&#xA;//#define Security        WPA_SECURITY&#xA;&#xA;#define MAX_SOCK_NUM    4&#xA;&#xA;unsigned int SrcPort = 80;&#xA;&#xA;WizFi2x0Class myWizFi;&#xA;WizFiClient myClient[MAX_SOCK_NUM];//(SIP, ServerPort);&#xA;WizFiServer myServer(SrcPort);&#xA;&#xA;boolean Wifi_setup = false;&#xA;&#xA;///////////////////////////////&#xA;// 1msec Timer&#xA;void Timer1_ISR()&#xA;{&#xA;  myWizFi.ReplyCheckTimer.CheckIsTimeout();&#xA;}&#xA;//&#xA;//////////////////////////////&#xA;void setup() {&#xA;  byte retval, i;&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;\r\nSerial Init&quot;);&#xA;&#xA;  for(i=0; i&amp;lt;MAX_SOCK_NUM; i++)&#xA;    myClient[i] =  WizFiClient();&#xA;&#xA;  myWizFi.begin();&#xA;&#xA;  // Timer1 Initialize&#xA;  Timer1.initialize(1000); // 1msec&#xA;  Timer1.attachInterrupt(Timer1_ISR);&#xA;&#xA;  myWizFi.SendSync();&#xA;  myWizFi.ReplyCheckTimer.TimerStart(3000);&#xA;&#xA;  Serial.println(&quot;Send Sync data&quot;);&#xA;&#xA;  while(1)&#xA;  {&#xA;    if(myWizFi.CheckSyncReply())&#xA;    {&#xA;      myWizFi.ReplyCheckTimer.TimerStop();&#xA;      Serial.println(&quot;Rcvd Sync data&quot;);&#xA;      break;&#xA;    }&#xA;    if(myWizFi.ReplyCheckTimer.GetIsTimeout())&#xA;    {&#xA;      Serial.println(&quot;Rcving Sync Timeout!!&quot;);&#xA;      return;&#xA;    }&#xA;  }&#xA;&#xA;  ////////////////////////////////////////////////////////////////////////////&#xA;  // AP association  &#xA;  while(1)&#xA;  {&#xA;    byte tmpstr[32];&#xA;&#xA;    retval = myWizFi.associate(SSID, Key, Security, true);&#xA;&#xA;    if(retval == 1){&#xA;      myWizFi.GetSrcIPAddr(tmpstr);&#xA;      Serial.println(&quot;WizFi2xo AP Associated&quot;);&#xA;      Serial.print(&quot;MY IPAddress: &quot;);&#xA;      Serial.println((char *)tmpstr);&#xA;      Wifi_setup = true;&#xA;      break;&#xA;    }else{&#xA;      Serial.println(&quot;AP association Failed&quot;);&#xA;    }&#xA;  }&#xA;&#xA;  if(myServer.begin())&#xA;    Serial.println(&quot;Server Listen OK&quot;);&#xA;  else&#xA;    Serial.println(&quot;Server Listen Failed&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  uint8_t retval, i;&#xA;  byte rcvdBuf[129];&#xA;&#xA;  memset(rcvdBuf, 0, 129);&#xA;&#xA;  if(Wifi_setup)&#xA;  {  &#xA;    myWizFi.RcvPacket();&#xA;    for(i=0; i&amp;lt;MAX_SOCK_NUM; i++)&#xA;    {&#xA;      if(myClient[i].available()){    &#xA;         retval = myClient[i].read(rcvdBuf);   &#xA;         if(retval &amp;gt; 0)&#xA;         {&#xA;           Serial.print(&quot;CID[&quot;);&#xA;           Serial.print((char)myClient[i].GetCID());&#xA;           Serial.print(&quot;]&quot;);&#xA;           Serial.println((char *)rcvdBuf);&#xA;&#xA;           if((rcvdBuf[retval - 1] == 0x0A) &amp;amp;&amp;amp; (rcvdBuf[retval - 2] == 0x0D) &amp;amp;&amp;amp; (rcvdBuf[retval - 3] == 0x0A) &amp;amp;&amp;amp; (rcvdBuf[retval - 4] == 0x0D))&#xA;           {&#xA;             Serial.print(&quot;Receiving Completed&quot;);&#xA;             myClient[i].write((byte *)&quot;HTTP/1.1 200 OK\r\n&quot;);&#xA;             myClient[i].write((byte *)&quot;Content-Type: text/html\r\n&quot;);&#xA;             myClient[i].write((byte *)&quot;\r\n&quot;);&#xA;             myClient[i].write((byte *)&quot;Hello World !\r\n&quot;);&#xA;&#xA;             delay(100);&#xA;             myClient[i].disconnect();&#xA;           }&#xA;         }&#xA;       }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;code&gt;WizFiServer&lt;/code&gt; class, it seems to assign a &lt;code&gt;WizFiClient&lt;/code&gt; instance to each HTTP socket connection. It can then call &lt;code&gt;clientName.write( /* Data to be sent to client */ );&lt;/code&gt; and &lt;code&gt;clientName.read();&lt;/code&gt; to get values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once it is done with the client, it can free up resources by calling &lt;code&gt;clientName.disconnect();&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-01-28T00:22:00.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8279" PostTypeId="2" ParentId="8273" CreationDate="2015-01-28T00:26:31.380" Score="1" Body="&lt;p&gt;Try to connect your GPS module with an FTDI cable directly to the Serial-Port of your computer (and read it with screen or any other terminal program). Once that works, proceed with the Arduino.&#xA;And check what your GPS-module not blinking does mean. Usually it says there is no 'fix', which means it does not see enough satellites. The output you showed would fit into that theory. Which would mean everything is ok, except your module is not seeing the sky...&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-01-28T00:26:31.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8281" PostTypeId="2" ParentId="8276" CreationDate="2015-01-28T06:42:15.167" Score="8" Body="&lt;p&gt;The Analog pins are essentially identical in functionality to digital pins when used as digital I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If desired you could &quot;be clever&quot; and use an analog input in analog mode to read multiple keys using one pin. eg using 10k, 22k, 39k, 82k, 150k in series with 5 buttons from V+ to pin and a say 4k7 to ground would result in 5 voltages which were easily distinguished using an analog read. This is a very very old technique indeed and allows far more than 5 keys on one input pin. THere are limitations which can be discussed if required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1 ... R5 correspond to buttons 1...5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vout = V+ x Rb / (Rb + Rbutton)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example only  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rb = 39k&lt;br&gt;&#xA;R1 = 10k&lt;br&gt;&#xA;R2 = 22k&lt;br&gt;&#xA;R3 = 39k&lt;br&gt;&#xA;R4 = 82k&lt;br&gt;&#xA;R5 = 150k&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gives   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The % of V+ in column 2 when a button is pressed.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The voltage in column 3 with V+ = 5V &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Delta-V is the difference between that key and the one below - very ample clearance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/F9KCN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cq9kc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-01-28T07:07:36.407" LastActivityDate="2015-01-28T07:07:36.407" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8282" PostTypeId="2" ParentId="8261" CreationDate="2015-01-28T09:05:44.317" Score="2" Body="&lt;p&gt;First, if you cannot connect to arduino by ethernet, use Serial Monitor and add some Serial.println to your code to log what is going - what part of program Arduino is executing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;W5100 module has no automatic reset module as opposed to Ethernet shield.&#xA;So try to connect W5100 RST pin to for example D8 and reset module in setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you are example from my (working) project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int W5100_RESET_PIN = 8;&#xA;&#xA;void setup() {&#xA;  Serial.begin(SERIAL_SPEED);&#xA;  Serial.println();&#xA;  Serial.println(F(&quot;node starting...&quot;));&#xA;  pinMode(W5100_RESET_PIN, OUTPUT);&#xA;  digitalWrite(W5100_RESET_PIN, LOW);&#xA;  delay(100);&#xA;  digitalWrite(W5100_RESET_PIN, HIGH);&#xA;  // give the Ethernet shield a second to initialize:&#xA;  delay(3000);&#xA;#ifdef USE_DHCP&#xA;  Serial.println(F(&quot;DHCP...&quot;));&#xA;  while (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(F(&quot;DHCP failed.&quot;));&#xA;    delay(10000);&#xA;  }&#xA;#else&#xA;  Serial.print(F(&quot;static IP...&quot;));&#xA;  Ethernet.begin(mac, IPAddress(MY_IP));&#xA;#endif&#xA;  Serial.print(F(&quot;local IP:&quot;));&#xA;  Serial.println(Ethernet.localIP());&#xA;  Serial.println(F(&quot;node started.&quot;));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also after setup if your arduino lost ethernet connection and cannot get it again, you can try to reset w5100 and initialize Ethernet again.&lt;/p&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-28T09:05:44.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8283" PostTypeId="2" ParentId="4950" CreationDate="2015-01-28T09:26:34.077" Score="2" Body="&lt;p&gt;Pro Mini 5V has voltage regulator for 5V and 16MHz quartz.&#xA;Pro Mini 3.3V has voltage regulator for 3.3V and 12MHz quartz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to manufacturer specification Atmega328 chip powered by 3.3V cannot run 16MHz and needs at most about 13MHz. But it's official specification. Some chips are better than specification (faster) some are worse (slower). So you can try whether &lt;strong&gt;your&lt;/strong&gt; Pro Mini is better or not. Or you can change quartz to 12MHz, if you can solder SMD parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or better look for cheaper 3.3V clone, they are not much more expensive as 5V version...&lt;/p&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-28T09:26:34.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8284" PostTypeId="2" ParentId="6702" CreationDate="2015-01-28T09:31:29.107" Score="-1" Body="&lt;p&gt;It can be problem with bootloader.&#xA;You can try to burn bootloader again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://angryelectron.com/how-to-update-the-bootloader-on-arduino-pro-mini-328/&quot; rel=&quot;nofollow&quot;&gt;http://angryelectron.com/how-to-update-the-bootloader-on-arduino-pro-mini-328/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or use google&lt;/p&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-28T09:31:29.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8285" PostTypeId="1" AcceptedAnswerId="8286" CreationDate="2015-01-28T10:17:01.563" Score="3" ViewCount="1475" Body="&lt;p&gt;I am using Arduino IDE to program my ATmegas with bootloaders. I can directly manipulate ports, use timers, interrupts, PWM pins and timers, etc. Everything is working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this question arises: Does the Arduino IDE differ from AVR Studio in terms of using C or C++ on an ATmega chip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know AVR Studio has some features or something. My question is not about that. My question is that I am coding everything, not using extra libraries, features etc.&lt;/p&gt;&#xA;" OwnerUserId="6994" LastEditorUserId="19409" LastEditDate="2018-04-11T06:19:46.407" LastActivityDate="2018-04-11T06:19:46.407" Title="Is Arduino IDE enough to program with C or C++?" Tags="|arduino-ide|c|avr|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8286" PostTypeId="2" ParentId="8285" CreationDate="2015-01-28T10:57:18.043" Score="11" Body="&lt;p&gt;In terms of the core language features, there's virtually no difference. In the background, the Arduino IDE and Atmel/AVR Studio both use &lt;a href=&quot;https://gcc.gnu.org/&quot;&gt;GCC&lt;/a&gt; to compile the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GCC is an excellent toolset which supports all the core language features of C++. Admittedly, the version which currently comes with the Arduino IDE is a little old, so it doesn't support C++11 onwards. However, a lot of C++11 features are not very relevant or useful for microcontroller programming anyway (e.g. threading).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're also likely to use the same standard library for both, which is &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot;&gt;AVR Libc&lt;/a&gt;. It provides pretty much all the standard C functionality that you're likely to use in an AVR project. It doesn't include the C++ stuff though, such as streams, containers, and algorithms. These tend to be very resource-hungry though, so are best avoided anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The major difference is basically flexibility. Atmel/AVR Studio is designed to let you work on a wide range of projects and customize the build to suit very specific needs. You can also use alternative libraries with it more easily. In theory, the Arduino IDE can be modified in similar ways, but it's a major hassle because it provides no GUI to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also important to note that the Arduino IDE does a number of non-standard things, such as re-organising declarations and including libraries in strange ways. It's designed to be more user-friendly, but often ends up just getting in the way. There are usually ways to work around those issues though.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-28T10:57:18.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8287" PostTypeId="2" ParentId="8285" CreationDate="2015-01-28T11:09:43.803" Score="-1" Body="&lt;p&gt;It is unclear exactly what you are asking. The Arduino is different to most computers - it has NO OS (if you exclude the bootloader).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use a c/c++ compiler which translates your code to machine code. If you include libraries this may include machine code which someone else has compiled into a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could write 100% of your code in assembler and produce exactly the same result.&#xA;Even in the good (bad?) old days of the 1970s before we had compilers on microprocessors it was common to have prewritten code (libraries) for common functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't lived until you have written your own assembler (hand coded).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-01-28T11:09:43.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8288" PostTypeId="1" AcceptedAnswerId="8293" CreationDate="2015-01-28T12:58:26.580" Score="3" ViewCount="1159" Body="&lt;p&gt;I know and I can program any AVR microcontroller with Arduino IDE and Arduino Uno board. Can I use Arduino board with AVR Studio? Or I have to buy an AVR Development board?&lt;/p&gt;&#xA;" OwnerUserId="6994" LastEditorUserId="6994" LastEditDate="2015-01-28T13:06:20.393" LastActivityDate="2015-01-29T05:47:18.533" Title="Can I program AVR Microcontrollers using Arduino Development board with AVR Studio?" Tags="|arduino-uno|avr|atmel-studio|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8289" PostTypeId="2" ParentId="8136" CreationDate="2015-01-28T13:32:16.667" Score="2" Body="&lt;p&gt;These are essentially notes in support of other answers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One year = 8765 hours.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So average drain for 1 year life from 500 mAh&lt;br&gt;&#xA;= 500 mAh/8765h&lt;br&gt;&#xA;= 57 uA average.&lt;br&gt;&#xA;To get one year on a 500 mAh battery you need to have average drain under say 50 uA &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An efficient modern LED&lt;br&gt;&#xA;is usefully bright at 1 mA and&lt;br&gt;&#xA;probably very acceptable at 0.1 mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best LEDs are 30 Cd+ at 20 mA&lt;br&gt;&#xA;so 150 mCd mean at 0.1 mA&lt;br&gt;&#xA;and your eye-brain sees more like the peak.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;0.1 mA at 1% duty cycle for one year&lt;br&gt;&#xA;= 8765 x 0.1 x 1/100&lt;br&gt;&#xA;= 8.765 mAh&lt;br&gt;&#xA;or about 2% of your battery capacity. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-01-28T13:32:16.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8290" PostTypeId="2" ParentId="8139" CreationDate="2015-01-28T13:55:23.947" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What I am trying to understand is whether it is recommended (time and cost-wise) to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup? or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Given what is available in assembled form, using a complete commercial product per project would make most sense except where you are building in substantial volume.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using &lt;a href=&quot;http://www.aliexpress.com/store/product/Freeshipping-10PCS-LOT-Nano-3-0-controller-compatible-with-arduino-nano-NO-CABLE/213957_1511622386.html&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano 3s from China&lt;/a&gt; which cost me $US3 each in quantities of 10 with free postage (takes 2 to 3 weeks to arrive here at the bottom of the world) and I see that the same people are now charging $2.85 each in 10's. There are numerous suppliers of similar products and I am only mentioning these as I have had good results from them and the quality is acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would probably have trouble buying just the parts for the cost of a $3 assembled working Nano and you'd need to cost your time at $0/hour. Building your own for the experience, or if you are using many and you want a cut down subset and really must get the price well under $3 MAY make sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same people also sell an &lt;a href=&quot;http://www.aliexpress.com/store/product/10Pcs-Lot-Pro-Mini-Module-Atmega328-5V-16M-For-Arduino-Compatible-With-Nano/213957_1432639609.html&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Arduino Pro mini&lt;/strong&gt;&lt;/a&gt; for $US1.85 in 10s free postage (ie $18.50 for TEN). You need to use a plug in USB module to program these via USB. I bought some of these as well - also good, but the convenience of the always available USB makes the Nano preferable (to me). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: USB cables cost extra !!! :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Related:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people have expressed reservations about buying Asian source Arduinos and suggest people should support either US fronted companies or the Arduino's originators. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate the merit of supporting the people who have put the effort into the system, but the system is very very consciously open source in all respects - and in fact code samples that come with the IDE are expressly Public Domain. (Documentation is CC by SA ...). If open source is to be truly meaningful it needs to be able to survive being truly so. Unlike many other products where Asian copies may have suspect IP legacies, the Arduino products are wholly legitimate (as far as I know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not pored over them in detail (yet) but I note that the 5V voltage regulator on the Chinese ones is an LM1117 (LDO LM317-like) as opposed to the original LM2940. The USB bridge ICs are, as is well known, not &quot;genuine&quot; FTDI parts but Asian semi-equivalents which, with their own drivers, work well enough in this context. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can certainly buy low cost rubbish versions from Asian sources, and part of the open source tradeoff is deciding where you do and don't get value for money overall.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-01-28T20:15:38.517" LastActivityDate="2015-01-28T20:15:38.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8291" PostTypeId="1" CreationDate="2015-01-28T14:40:16.843" Score="2" ViewCount="1892" Body="&lt;p&gt;Im using a Arduino Mega 2560, and I tried to connect a us-100 ultrasonic sensor for distance measurement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected it as shown in the image &lt;img src=&quot;https://i.stack.imgur.com/SfgzB.jpg&quot; alt=&quot;connection&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I used was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int trigger=6;&#xA;const int echo=7;&#xA;float distance;&#xA;void setup(){&#xA;Serial.begin(9600);&#xA;pinMode(trigger,OUTPUT);&#xA;pinMode(echo,INPUT);&#xA;}&#xA;void loop(){&#xA;// Trigger US-100 to start measurement&#xA;// Set up trigger&#xA;digitalWrite(trigger,LOW);&#xA;delayMicroseconds(5);&#xA;// Start Measurement&#xA;digitalWrite(trigger,HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trigger,LOW);&#xA;// Acquire and convert to mtrs&#xA;distance=pulseIn(echo,HIGH);&#xA;distance=distance*0.0001657;&#xA;// send result to UART&#xA;Serial.println(distance);&#xA;delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But It won't work, as in the only output i get is 0.00 cm as shown in the image &lt;img src=&quot;https://i.stack.imgur.com/jjsjG.jpg&quot; alt=&quot;sm&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone tell me if I'm doing something wrong(also, i tried putting two probes between the vcc and one of the gnd pins, and a resistance was shown.This should mean the sensor isn't broken.yes?)? this is my first time using arduino and I greatly appreciate help to fix this.&lt;/p&gt;&#xA;" OwnerUserId="6998" LastActivityDate="2016-01-30T03:31:43.353" Title="US-100 Ultrasound sensor doesn't work on Arduino mega 2560" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="5" ClosedDate="2016-01-30T05:20:48.383" ContentLicense="CC BY-SA 3.0" />
  <row Id="8292" PostTypeId="1" CreationDate="2015-01-28T17:07:31.967" Score="3" ViewCount="408" Body="&lt;p&gt;In the process of trying to make a small system that will last a while on 4 AA batteries, I've reduced my Arduino project to a barebones system that when asleep draws a tiny amount of current from the batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to achieve this, I found it would be necessary to cut power to the two attached peripheral devices (connected to an ATMega328P-PU). One of them is an I2C device, and the other is a serial device, and both are attached to the hardware serial/I2C pins as appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of powering the peripherals, the bases of two transistors are connected to two of the digital pins, and power to them is controlled from code via these transistors. Both devices are 5V, and when the system is running the total current draw is around 200mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically this setup works, however I'm getting &quot;random&quot; system hanging and essentially an unreliable project. Sometimes when I power it up it will work as normal, but then hang and not sleep. Other times, it will sleep, but then freeze after waking or just get stuck during waking (which I can tell because the serial device powers up first and does nothing, but the I2C device remains off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best guess is the root of the cause is either something to do with the serial communication being interrupted by sleeping the MPU (I'm using the maximum power saving sleep, which is woken by an external interrupt on pin 2), or possibly some sort of power problem (sudden current draw from battery?) that occurs when the peripherals are powered on in code (though I don't know how I should test this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I've tried calling &lt;code&gt;Serial.end()&lt;/code&gt; before sleeping the MPU, and &lt;code&gt;Serial.being(9600)&lt;/code&gt; on waking, and have scattered &lt;code&gt;delay(1000)&lt;/code&gt;s throughout to ensure everything has enough time to get running, but the problem still remains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any pointers on things I could change/test, or an alternative approach I could take to make the same power savings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Some more details&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transitors used are TIP 120's. The connections are essentially an exact copy of the image here: &lt;a href=&quot;https://ctheds.files.wordpress.com/2007/10/tip120.jpg&quot; rel=&quot;nofollow&quot;&gt;https://ctheds.files.wordpress.com/2007/10/tip120.jpg&lt;/a&gt;, except the resistors used are 560 Ohms (just what I had to hand, no other reason, didn't think it would change anything). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The I2C peripheral is a 20x4 LCD (which I believe is HD44780 compliant). The serial device is an GT511C3 fingerprint sensor. I don't believe either of them have any automatic power saving features, though I haven't looked for such things in the documentation explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exact code I use to call sleep is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;sleep_enable();&#xA;sleep_mode();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I'm lead to believe is the lowest power mode, and aside from this problem works well for my system.&lt;/p&gt;&#xA;" OwnerUserId="6984" LastEditorUserId="6984" LastEditDate="2015-01-29T18:17:12.640" LastActivityDate="2016-05-20T17:52:09.940" Title="Unstable system when controlling power to serial peripheral devices and sleeping" Tags="|serial|power|i2c|interrupt|sleep|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="8293" PostTypeId="2" ParentId="8288" CreationDate="2015-01-28T18:09:07.910" Score="4" Body="&lt;p&gt;You can use Atmel Studio to write code for the MCU(s) on the Arduino boards. If the IDE itself does not support &lt;em&gt;uploading&lt;/em&gt; the code to the Arduino then it is still possible to use AVRDUDE or BOSSA to upload it via the command line.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-01-28T18:09:07.910" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8294" PostTypeId="2" ParentId="8256" CreationDate="2015-01-28T20:46:51.343" Score="1" Body="&lt;p&gt;So, to summarise the comments trail; the blinking lights at power-up are the normal boot sequence for the Leonardo,  indicating the processor is good, and that power is reaching the board; the device seen should be /dev/ttyACM0 or some other number; dmesg wasn't recording a plug-in event as the cable was not good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We still don't quite know why the IDE thought it had sent a program to /dev/ttyS0, but presumably the level of interaction is much less (ie, none) via RS232 serial? Which explains why it said it had uploaded a test program when, in fact, it hadn't!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And replacing the USB cable has solved the problem - excellent news!&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-28T20:46:51.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8297" PostTypeId="1" CreationDate="2015-01-29T05:36:59.580" Score="0" ViewCount="359" Body="&lt;p&gt;I am currently working on reading pressure values using a tekscan a201 sensor. The sensors I have are limited to 25lbs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan is to use eight on these sensors of them with a arduino Mega. Since I am measuring the resistance, I am thinking of making a 8 similar voltage divider circuits and grabbing the voltage reading via arduinos analog pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I am not sure how to convert these readings to engineering units. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="618" LastActivityDate="2015-01-30T17:47:38.417" Title="Pressure Sensor and Arduino" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8298" PostTypeId="2" ParentId="8288" CreationDate="2015-01-29T05:47:18.533" Score="1" Body="&lt;p&gt;There is an &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow&quot;&gt;Arduino plugin&lt;/a&gt; available for AVR Studio, which allows you to upload sketches to an Arduino, just like you would with the Arduino IDE. I think this also enables you to upload plain C/C++ files created with the standard AVR tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you have an AVR ISP programmer, you can use this to upload compiled C/C++ to the Arduino from AVR studio without needing the Arduino plugin.&lt;/p&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-01-29T05:47:18.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8299" PostTypeId="2" ParentId="8297" CreationDate="2015-01-29T06:17:28.870" Score="1" Body="&lt;p&gt;I have not previously met the Flexscan sensors but from the datasheet it appears that there are versions of the A201 rated at 100 pounds are you committed to the 25 lbf version?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.co.nz/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;ved=0CEkQFjAC&amp;amp;url=http%3A%2F%2Fwww.tekscan.com%2Fpdf%2FFLX-A201-force-sensor.pdf&amp;amp;ei=cszJVOrPJZLN8gWU_4Bw&amp;amp;usg=AFQjCNGNy5nCyCNgagOzaIMfsUIpSFlRGg&amp;amp;sig2=_D791hWWRz5tzqHSp0zcxg&amp;amp;bvm=bv.84607526,d.dGY&amp;amp;cad=rja&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;A201 datasheet here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a &lt;a href=&quot;https://www.google.co.nz/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=5&amp;amp;ved=0CFUQFjAE&amp;amp;url=http%3A%2F%2Fwww.tekscan.com%2Fpdf%2FFLX-FlexiForce-Sensors-Manual.pdf&amp;amp;ei=cszJVOrPJZLN8gWU_4Bw&amp;amp;usg=AFQjCNGCYZTma0vkXT0e2BsH7Y07yQ_tcw&amp;amp;sig2=ZMxG630bjh44caLTmokRJg&amp;amp;bvm=bv.84607526,d.dGY&amp;amp;cad=rja&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;15 page user manual&lt;/strong&gt;&lt;/a&gt; thatexplains how to produce a voltage output using a single opamp per sensor - bottom of page 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.co.nz/search?q=tekscan+a201&amp;amp;biw=1745&amp;amp;bih=977&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ei=cszJVOrPJZLN8gWU_4Bw&amp;amp;ved=0CAYQ_AUoAQ&quot; rel=&quot;nofollow&quot;&gt;Many idea starters &lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What is your application and why do you wish to use these sensors. These seem to be a low accuracy alternative to eg load cells and seem to be expensive for what you get. If you need 8 for your task a loadcell based solution may e cheaper. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-01-29T06:17:28.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8300" PostTypeId="2" ParentId="6593" CreationDate="2015-01-29T06:46:04.507" Score="1" Body="&lt;p&gt;I'have the same LCD from mcufriend and it doesn't work with original UTFT library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try modified version from &lt;a href=&quot;https://github.com/dgolda/UTFT&quot; rel=&quot;nofollow&quot;&gt;https://github.com/dgolda/UTFT&lt;/a&gt; and use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myGLCD(NIC35WS,38,39,40,41); //3.5&quot; TFTLCD for arduino 2560 from mcufriend.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-29T06:46:04.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8301" PostTypeId="2" ParentId="8271" CreationDate="2015-01-29T06:59:25.547" Score="1" Body="&lt;p&gt;This is probably a duplicate question and duplicate answer, but ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flip the board over, look at the bottom. If it says &quot;FTDI&quot; then this answer doesn't apply. But many cheap clones have moved to the CH340G chip for USB serial communication, it's a tenth of the cost with a tenth of the (unused) features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find CH340/341 drivers from the manufacturer at &lt;a href=&quot;http://WCH.CN&quot; rel=&quot;nofollow&quot;&gt;WCH.CN&lt;/a&gt; or linked at the bottom of &lt;a href=&quot;http://www.ardueasy.com/2014/10/different-varieties-of-arduino-nano.html&quot; rel=&quot;nofollow&quot;&gt;this post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, skip the USB altogether and search for &quot;ISP&quot; on &lt;a href=&quot;https://Tindie.com&quot; rel=&quot;nofollow&quot;&gt;Tindie&lt;/a&gt; and grab a USBASP or TinyISP programmer.&lt;/p&gt;&#xA;" OwnerUserId="4969" LastActivityDate="2015-01-29T06:59:25.547" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8302" PostTypeId="1" AcceptedAnswerId="8304" CreationDate="2015-01-29T10:41:56.350" Score="2" ViewCount="633" Body="&lt;p&gt;I am designing a board for my electronics project and i am using a number of ATTiny85 for it. The ATTiny's will be SMD so i will not be able to remove them for programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover all of the pins of my uCs will be used for connections (apart from reset). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible in this case to achieve that, any ideas and suggestions are welcome&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Well, Vcc and Ground will be common, i will be using an external oscillator for all of them, the reset pin will be free, the other three pins will be used for gpio communication between the attinys.&#xA;I am connecting about 10 attiny in a daisy chain kind of thing&lt;/p&gt;&#xA;" OwnerUserId="6268" LastEditorUserId="6268" LastEditDate="2015-01-29T10:52:27.380" LastActivityDate="2015-01-29T12:16:10.163" Title="Programming an Array of ATTiny" Tags="|programming|attiny|system-design|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8303" PostTypeId="2" ParentId="8302" CreationDate="2015-01-29T10:49:44.393" Score="-1" Body="&lt;p&gt;Well you need access to pins 0 &amp;amp; 1 to program them, so you either do it off-board, or design in a way to access them - perhaps a PCB hole you can wire to temporarily, or a link you can fit/remove that changes the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably need to program them before the rest of the board gets filled up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You havn't said what you will be connecting to these pins nor how many is an &quot;array&quot; which kind of limits how specific we can be here!&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-01-29T10:49:44.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8304" PostTypeId="2" ParentId="8302" CreationDate="2015-01-29T12:16:10.163" Score="3" Body="&lt;p&gt;As long as whatever you're connecting the MISO, MOSI, and SCK pins to doesn't mind being driven externally, you can still program the ATTiny in-circuit - just break out those pins with reset to a standard 6 pin header and program them that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one or more of those pins can't be driven externally (eg, because they're connected to another device that drives them and has no output disable), you'll need to add a tristate buffer IC between the MCU and the other device, or some jumpers you can remove when you want to program them.&lt;/p&gt;&#xA;" OwnerUserId="6302" LastActivityDate="2015-01-29T12:16:10.163" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8305" PostTypeId="1" AcceptedAnswerId="8306" CreationDate="2015-01-29T13:58:11.160" Score="5" ViewCount="317" Body="&lt;p&gt;(This might be more of a common C question)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to test several conditions in an IF-sentence&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(variable) {            // fastest check&#xA;  if(register) {          // a bit slower&#xA;    if(read_peripheral) { // very slow check&#xA;      // [do something]&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems obvious that I want to start with the fastest check, and move on to the slower ones afterwards, potentially avoiding to check them if the above was false. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now since I need to check quite a few conditions, I'd like to know if the following is the same, or if all conditions will be evaluated prior to making a decision?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(variable &amp;amp;&amp;amp; register &amp;amp;&amp;amp; read_peripheral) {&#xA;  // [do something]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7019" LastActivityDate="2015-01-29T15:32:46.110" Title="Chain of, or one big if sentence" Tags="|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8306" PostTypeId="2" ParentId="8305" CreationDate="2015-01-29T15:32:46.110" Score="8" Body="&lt;p&gt;Putting them all in a single condition like that is absolutely fine. C/C++ uses &quot;short circuit evaluation&quot; which means it will stop as soon as it's determined the outcome. If everything is combined using logical AND operators (&amp;amp;&amp;amp;) then that means it will stop as soon as one of them evaluates to false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (blah() &amp;amp;&amp;amp; foo()) { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;blah()&lt;/code&gt; returns false, it will never call &lt;code&gt;foo()&lt;/code&gt; at all because it already knows the overall outcome is false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reverse happens with the logical OR operator (||):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (blah() || foo()) { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;blah()&lt;/code&gt; returns &lt;em&gt;true&lt;/em&gt; in this case, it won't call &lt;code&gt;foo()&lt;/code&gt;. That's because it already knows the overall outcome is true.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-01-29T15:32:46.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8307" PostTypeId="1" AcceptedAnswerId="8316" CreationDate="2015-01-29T18:16:45.627" Score="2" ViewCount="14619" Body="&lt;p&gt;I bought a HC-06 Module for my Arduino Uno the other day, yesterday it arrived and I'm having trouble using it with the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set it up, connecting 5V, GND and RX/TX crossed. After a bit of searching, it shows up on the bluetooth settings on the macbook. When I click &quot;connect&quot;, it fails, after I click &quot;Options&quot;, then set the Pin to 1234 it says &quot;Connected&quot;. The LED on the HC-06 is still blinking (which is OK I guess, since I'm not yet communicating).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Sketch running on the Uno that prints out some text. When I open the serial monitor (after connecting like above) it works, displaying the values I expect. However, after closing the serial monitor the HC-06 changes to &quot;not connected&quot; on the mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I try to upload code via the Arduino IDE it states: &lt;code&gt;avrdude: ser_open(): can't open device &quot;/dev/tty.HC-06-DevB&quot;: Resource busy&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&lt;/code&gt; or throws a &lt;code&gt;processing.app.SerialException: Fehler beim Öffnen des seriellen Ports &quot;/dev/tty.HC-06-DevB&quot;.&lt;/code&gt; (German for &quot;Error while opening Serial Port &quot;/dev....&quot; &quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to configure the HC-06 or the Arduino IDE in any way to make this work, and, if so, how can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;I've also connected TX and RX uncrossed, though that alone doesn't solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for your Support!&lt;/p&gt;&#xA;" OwnerUserId="7022" LastEditorUserId="7022" LastEditDate="2015-01-29T22:31:23.407" LastActivityDate="2018-01-12T23:15:00.643" Title="Can't program Arduino via Bluetooth (HC-06) with a Mac" Tags="|arduino-uno|serial|programming|bluetooth|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8308" PostTypeId="2" ParentId="8307" CreationDate="2015-01-29T20:01:55.747" Score="1" Body="&lt;p&gt;If I remember correctly, you do not want to cross TX and RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually, you cross TX/RX because you are looking at it from the opposite side - the PC's TX is the Arduino's RX and vice-versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in the case of BlueTooth, the HC-06 has the same perspective as the Arduino - TX (transmit) is TX on the HC-06, since that is what the HC-06 transmits (over Bluetooth).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you are connect your Arduino via USB, the TX &amp;amp; RX are also connected via USB; I don't know if this would cause cross-talk. It shouldn't (so long as you don't send to your Arduino using Bluetooth AND USB at the same time), but it may. Also, as you're programming the Arduino using Bluetooth, you may get the Arduino's responses coming back to you via Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ADDITIONAL:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go read &lt;a href=&quot;http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&lt;/a&gt; - this is all about the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems from that that current bootloaders run at 19200, some older ones run at 9600. There are commands to program the speed on HC-06 - instructions can be found at &lt;a href=&quot;http://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/&lt;/a&gt; (this covers the hc-06 too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the bootloader tutorial, I think you have &quot;less than a second&quot; (only two specific boards are mentioned, so this is a best guess; I am amazed that it is this long, I expected a few milliseconds). If you have a USBISP, you could compile and upload a new firmware, with settings more to your liking - this is outside the scope of this article.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to create a completely separate uploader - an AtTiny could do it. Connect the AtTiny to the serial port, and then get the AtTiny to reset and program the board, or even program it via ICSP. This is a lot of work, and also outside the scope of this article.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-01-31T19:00:16.243" LastActivityDate="2015-01-31T19:00:16.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8310" PostTypeId="2" ParentId="3226" CreationDate="2015-01-29T20:51:08.973" Score="0" Body="&lt;p&gt;I have the same lcd shield from mcufriend. It has ILI9327 in 8 bit mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shield doesn't work with original UTFT library (it supports only 16-bit mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try modified version from &lt;a href=&quot;https://github.com/dgolda/UTFT&quot; rel=&quot;nofollow&quot;&gt;https://github.com/dgolda/UTFT&lt;/a&gt; and use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myGLCD(NIC35WS,38,39,40,41); //3.5&quot; TFTLCD for arduino 2560 from mcufriend.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-29T20:51:08.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8311" PostTypeId="2" ParentId="5209" CreationDate="2015-01-29T21:09:01.990" Score="2" Body="&lt;p&gt;If you have a 7V to 12V - 2A regulated supply, you can directly power your board using the 2.1mm connector. Do not go above 12V or you may destroy the voltage regulator on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a 5V to 6V - 2A regulated supply, you can supply your servo with this supply and rely on USB to supply the rest of the board (make sure you have a common ground for both the USB and the regulated supply).&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-01-29T21:09:01.990" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8312" PostTypeId="2" ParentId="8307" CreationDate="2015-01-29T23:16:04.213" Score="1" Body="&lt;p&gt;Regarding the ability to upload, that is correct - you won't be able to upload code via Bluetooth. In addition to providing a serial connection, the USB connection does something extra (hold reset, I think), when you upload via serial-over-usb.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-29T23:16:04.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8313" PostTypeId="1" CreationDate="2015-01-29T23:50:55.943" Score="2" ViewCount="193" Body="&lt;p&gt;I'd like to use an Arduino Yún in a somewhat outdoor environment (in a metal box on a truck).  I think I've seen that the temperature requirements of the Uno are -40 °C to +85 °C, but I can't find that information about the Yún.  It would be nice to know where to find information about the temperature and humidity safe working requirements for every Arduino model.&lt;/p&gt;&#xA;" OwnerUserId="7027" LastActivityDate="2015-01-30T00:51:48.283" Title="What are the environmental requirements of an Arduino?" Tags="|arduino-yun|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8314" PostTypeId="1" CreationDate="2015-01-30T00:08:32.097" Score="0" ViewCount="89" Body="&lt;p&gt;if I solder the jumper pads on the adafruit cc3000 for use with the Arduino Mega will it still work fine with the Uno?&lt;/p&gt;&#xA;" OwnerUserId="7028" LastActivityDate="2015-04-03T09:17:12.673" Title="Adafruit CC3000 jumper pads" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8315" PostTypeId="2" ParentId="8313" CreationDate="2015-01-30T00:51:48.283" Score="2" Body="&lt;p&gt;The AtMega32u4 (the chip that drives the Arduino Yun) has an operating requirement of -40 to +85, so if you go outside that range, you will definitely void warranty (which is not to say it will break, of course!). See datasheet at &lt;a href=&quot;http://www.atmel.com/devices/atmega32u4.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/devices/atmega32u4.aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A datasheet for the AR9331 seems to say that it only works down to 0°C ( &lt;a href=&quot;http://www.eeboard.com/wp-content/uploads/downloads/2013/08/AR9331.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.eeboard.com/wp-content/uploads/downloads/2013/08/AR9331.pdf&lt;/a&gt; page 305, &quot;Commercial Case Temperature&quot;) - this seems awfully high for a minimum temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While that does not mean that, inside that range, you are safe, I would &lt;em&gt;GUESS&lt;/em&gt; that you probably are - I would guess that the AtMega32u4 or AR9331 is going to be the most delicate part in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, to get a definitive answer, you (or someone) would have to check the specs on each part.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-01-30T00:51:48.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8316" PostTypeId="2" ParentId="8307" CreationDate="2015-01-30T02:49:50.500" Score="3" Body="&lt;p&gt;The on-board USB-to-serial pulses the reset line to start the bootloader. HC-0x don't have the extra signal available that USB uses for that so you'll have to manually reset the Arduino just as - or very slightly after - you click to start the upload on your Mac; you may need to experiment to get the timing right, but once you know it, it isn't hard to do. Keep Rx &amp;amp; Tx crossed as you do for Bluetooth terminal communication. And even with all that, I've never achieved anything like USB upload speeds (baud rate for baud rate) using Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;br&gt;&#xA;In brief, it could be timing, baud-rate, or pairing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find it easy to get the timing: hold reset / click (and let go) the upload button / release reset. It doesn't need to be so fast that it's a challenge to coordinate but do it faster than counting seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your HC-06's baud rate will have to match the baud-rate your boot-loader expects. It looks like Uno's bootloader's use 19200 baud (and there are some way older ones that used 9600). My bare, pre-programmed chips' boot-loaders from Adafruit.com use 57600 baud. Your &lt;code&gt;preferences.txt&lt;/code&gt; file should contain a line like 'atmega328o.upload.speed=115200'; assuming you're able to upload via USB, then use this baud rate for the HC-06. (The path to your preferences file is displayed on the Arduino IDE's preferences dialog.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 'Resource busy' message sounds like your Mac isn't paired with your HC-06. In the MacOS Bluetooth System Preferences pane, pair the Mac with the HC-06 and be sure HC-06's LED is on steady (not blinking).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-01-31T22:14:40.573" LastActivityDate="2015-01-31T22:14:40.573" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8317" PostTypeId="1" AcceptedAnswerId="8319" CreationDate="2015-01-30T03:40:40.320" Score="1" ViewCount="64" Body="&lt;p&gt;I am looking for the source and/or proper definition for the int() function.&#xA;I have searched through the source in Arduino.app, without much success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reference gives a terse explanation &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int(x)&#xA; x: a value of any type &#xA; Converts a value to the int data type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Passing 1, '1' or 49 returns the int 1. I haven't tested other types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be an Arduino specific function - it doesn't seem to be in any c/c++ library.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-01-30T05:44:51.063" Title="I am looking for the source and/or proper definition for the int() function" Tags="|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8318" PostTypeId="2" ParentId="8314" CreationDate="2015-01-30T03:51:51.387" Score="1" Body="&lt;p&gt;&lt;strong&gt;This module is designed to be &quot;plug in and go&quot;&lt;/strong&gt; without access to anything except the connector pads at the board edge. While there are a number of pads on the face of the board these are for &quot;experts only&quot; access and are unneeded for normal operation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only soldering required should be the addition of a 9 pin row of pins to allow the CC3000 module to be plugged into a solderless breadboard or a socket. If this is all you do then the module will work directly and interchangeably with  Arduino Uno, Leonardo/Micro &amp;amp; Mega. These are the only Arduino versions that a full library is available for so far. ADAFruit promise more versions will be supported &quot;sometime&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional information is available from&lt;br&gt;&#xA; &lt;a href=&quot;http://www.adafruit.com/product/1469&quot; rel=&quot;nofollow noreferrer&quot;&gt;WIRELESS / WIFI / ADAFRUIT HUZZAH CC3000 WIFI BREAKOUT WITH ONBOARD ANTENNA&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solder on connector and go ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9uoaZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Larger version of photo here&lt;/strong&gt; makes pin use clear - + see link above&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9uoaZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example use &lt;a href=&quot;https://learn.adafruit.com/wifi-weather-station-arduino-cc3000&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;weather station&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/low-power-wifi-datalogging&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Low power use tutorial&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example use &lt;a href=&quot;https://learn.adafruit.com/wireless-power-switch-with-arduino-and-the-cc3000-wifi-chip&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;wireless lamp&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Library&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-02T07:42:11.157" LastActivityDate="2015-02-02T07:42:11.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8319" PostTypeId="2" ParentId="8317" CreationDate="2015-01-30T05:44:51.063" Score="2" Body="&lt;p&gt;&lt;code&gt;int(x)&lt;/code&gt; is not a function but &lt;strong&gt;another way to perform an explicit cast&lt;/strong&gt; of &lt;code&gt;x&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt;. It is part of the C++ language itself, that is why you could not find it in a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not Arduino-specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C and C++ you can cast a value to an int by doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int y = (int) x;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C++&lt;/strong&gt; has extended this notation by allowing to do it this way, which is equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int y = int(x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find this &lt;a href=&quot;http://en.cppreference.com/w/cpp/language/explicit_cast&quot; rel=&quot;nofollow&quot;&gt;in more details&lt;/a&gt; in C++ language reference.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-01-30T05:44:51.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8320" PostTypeId="1" AcceptedAnswerId="8325" CreationDate="2015-01-30T05:47:43.173" Score="0" ViewCount="262" Body="&lt;p&gt;I am working on a project that needs to drive a relay board. I'm looking at the ETHERNET board with PoE and according to the documentation here (&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardEthernet&lt;/a&gt;) the output of the PoE module is 9V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that the voltage to expect out of the Vin pin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Relay board that I want to use (&lt;a href=&quot;http://numato.com/downloads/dl/file/id/29/product/47/user_manual.pdf&quot; rel=&quot;nofollow&quot;&gt;http://numato.com/downloads/dl/file/id/29/product/47/user_manual.pdf&lt;/a&gt;) specifies that it wants a 7-12V power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to confirm that this is the case so I can use the voltage out of the PoE and I don't need to add a separate DC power supply to this system.&lt;/p&gt;&#xA;" OwnerUserId="7032" LastActivityDate="2015-01-31T17:10:05.143" Title="What is Vin for the EthernetPOE board?" Tags="|power|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8321" PostTypeId="1" AcceptedAnswerId="8342" CreationDate="2015-01-30T07:52:19.773" Score="1" ViewCount="18888" Body="&lt;p&gt;I'm just starting off with using the Arduino and was learning about PWM&lt;br&gt;&#xA;(&lt;a href=&quot;http://arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Tutorial/PWM&lt;/a&gt;).&lt;br&gt;&#xA;Below is what my circuit looks like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MDY9x.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the very simple code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pinNine = 9;    // LED connected to digital pin 9&#xA;&#xA;void setup() {&#xA;  // initialize serial communications at 9600 bps:&#xA;  Serial.begin(9600); &#xA;  // set the digital pins as outputs&#xA;  pinMode(pinNine,OUTPUT);&#xA;}&#xA;&#xA;void loop() {      &#xA;  analogWrite(pinNine, 0); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was expecting my LED to not be lighted as its a 0% duty cycle. I even change the pinNine outputValue to (64, 127, etc) but for some reason the LED is always lighted. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="7034" LastEditorUserId="6959" LastEditDate="2015-01-30T15:35:38.667" LastActivityDate="2019-03-13T13:11:58.027" Title="Issue with PWM output pin" Tags="|pwm|analogwrite|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8322" PostTypeId="2" ParentId="8235" CreationDate="2015-01-30T09:26:31.637" Score="0" Body="&lt;p&gt;Look for &quot;Mega2560-CORE&quot; on ebay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some information:&#xA;&lt;a href=&quot;http://www.inhaos.com/product_info.php?products_id=88&quot; rel=&quot;nofollow&quot;&gt;http://www.inhaos.com/product_info.php?products_id=88&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4359" LastActivityDate="2015-01-30T09:26:31.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8323" PostTypeId="2" ParentId="8321" CreationDate="2015-01-30T10:12:21.407" Score="0" Body="&lt;p&gt;I have a few things you could try:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Remove &lt;code&gt;pinMode(pinNine, OUTPUT)&lt;/code&gt;, this is only used for digitalWrite(), the PWM controller might be affected by this.&lt;/li&gt;&#xA;&lt;li&gt;Did you select the correct Arduino Chip in the IDE? Arduino maps pin 9 to a hardware pin (PB1 for UNO), which is not consistent between different boards&lt;/li&gt;&#xA;&lt;li&gt;Try inserting a &lt;code&gt;delay(100)&lt;/code&gt; after &lt;code&gt;analogWrite(...)&lt;/code&gt;. I'm not sure if the analogWrite call restarts the PWM cycle, resulting in very fast switching that might be seen as 'always on'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Other than that, your sketch seems to be correct. I assume the black wire in the breadboard is wired to Ground, correct?&lt;/p&gt;&#xA;" OwnerUserId="7019" LastActivityDate="2015-01-30T10:12:21.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8324" PostTypeId="2" ParentId="8321" CreationDate="2015-01-30T10:19:46.460" Score="1" Body="&lt;p&gt;Added at top:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Your code runs correctly on a $US3 Arduino Nano&lt;/strong&gt; :-)&lt;/p&gt;&#xA;&lt;p&gt;It seems extremely likely that you have a hardware problem of some sort.&lt;/p&gt;&#xA;&lt;p&gt;If you have a voltmeter you can try these easy checks.&lt;br /&gt;&#xA;I carried these out to be sure that I got what was expected and the results are as you would expect them to me. Use a meter set to DC Volts - typical common meter circuitry averages the PWM well.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove LED etc connection to pin 9.&lt;br /&gt;&#xA;Measure the voltage from the 5V pin to ground. If powered from USB this will usually be slightly below 5V.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run your code with the analogWrite set to 128 ie&lt;/p&gt;&#xA;&lt;p&gt;analogWrite(pinNine, 128);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Measure the voltage on pin 9 relative to ground. It should be close tohalf the voltage on the 5V pin in 1. above. This is because the analogWrite value is controlled by PWM with values from 0 to 255. 128/255 ~= 50% so output is 50% of Vref = 5V by default. in a 5V system.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set analogWrite to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; analogWrite(pinNine, 25); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The voltage on pin9 should be about 10% of the voltage on the 5V pin.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;IF you get approximately the voltages shown in 3. and 5. your code is working OK and your hardware is OK.  If not then 'summat aglae'.&lt;/p&gt;&#xA;&lt;p&gt;Try another analog pin.&lt;/p&gt;&#xA;&lt;p&gt;Check that the red wire to the LED goes to UNO ground.&lt;/p&gt;&#xA;&lt;p&gt;The voltmeter is a surer way of checking that the LED is as you can see actual numeric values that result.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;OLDER:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;It always helps greatly if you show PIN IDs on photos so people can be confident re what you have done.&lt;/p&gt;&#xA;&lt;p&gt;If you view the whole UNO-R2-R3 connector with numbering it is obvious that the important pinouts are the same.&#xA;If however you view part of the connector with no numbering/ pin names shown,  then on the R3 there are additional pins on the ARef end of the connector which make comparisons'more difficult).&lt;/p&gt;&#xA;&lt;p&gt;You APPEAR to have an Arduino UNO R3&lt;br /&gt;&#xA;It would help if you gave actual model and weblink in future &amp;quot;just in case it matters&amp;quot;. .&lt;/p&gt;&#xA;&lt;p&gt;You appear to have connected to pin 9  (as you intended to)&#xA;Pin 9 has PWM capability, as required.&#xA;It seems that your code should work.&lt;/p&gt;&#xA;&lt;p&gt;Thusly&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lC2XS.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;IF the red wire connects to ground the circuit seems electrically correct.&lt;br /&gt;&#xA;Does it?&lt;/p&gt;&#xA;&lt;p&gt;Code LOOKS OK.&lt;/p&gt;&#xA;&lt;p&gt;Try digital write on / off on pin 9 to see if LED changes and that the port behaves as expected. A bad port pin is possible.&lt;/p&gt;&#xA;&lt;p&gt;What pin is serial on?&lt;/p&gt;&#xA;&lt;p&gt;Try another pin with PWM capability to see if it changes.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;ARDUINO UNO R3 from &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;UNO home page&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The connector pinouts vary widely between models of UNO.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ErT8E.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-01-30T13:50:42.703" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8325" PostTypeId="2" ParentId="8320" CreationDate="2015-01-30T10:28:15.133" Score="0" Body="&lt;p&gt;I wouldn't expect you to take any power from V-&lt;strong&gt;in&lt;/strong&gt;-, but it actually seems like you can!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take a look at the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-ethernet-R3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt; for the Rev.3 Arduino Ethernet, you can see the power rails from Ethernet is connected to Vin. (&lt;code&gt;V1+&lt;/code&gt;, &lt;code&gt;V1-&lt;/code&gt;, &lt;code&gt;V2+&lt;/code&gt;, &lt;code&gt;V2-&lt;/code&gt; --&gt; &lt;code&gt;Vin&lt;/code&gt; in the leftmost part of the schematic)&lt;/p&gt;&#xA;" OwnerUserId="7019" LastActivityDate="2015-01-30T10:28:15.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8326" PostTypeId="1" AcceptedAnswerId="8327" CreationDate="2015-01-30T10:29:20.837" Score="0" ViewCount="1291" Body="&lt;p&gt;As a programmer I am new and lack some knowledge in electronic and I will appreciate the help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish to connect 3 Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix (&lt;a href=&quot;https://www.adafruit.com/products/1487&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1487&lt;/a&gt;) can some one please provide me a scheme how to connect/tile 3 these NeoMatrix 8x8 to one Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot&lt;/p&gt;&#xA;" OwnerUserId="7040" LastActivityDate="2015-06-16T13:54:06.430" Title="Tile NeoPixel NeoMatrix 8x8" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8327" PostTypeId="2" ParentId="8326" CreationDate="2015-01-30T11:26:29.067" Score="5" Body="&lt;p&gt;On &lt;a href=&quot;https://www.adafruit.com/products/1487&quot;&gt;&lt;strong&gt;the page that you cite&lt;/strong&gt;&lt;/a&gt; they say&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, say, you need MORE blinky, &lt;strong&gt;you can chain these together.&lt;/strong&gt;   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For the second shield, connect the DIN connection to the first panel's DOUT.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also connect a ground pin together   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;and power with 5V. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There you go!   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can chain as many as you'd like although after 4 or more panels you may run low on RAM if you're using an UNO. Watch your power usage too, you may need a 5V 10A power supply for so many of these! &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Related:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They also say:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a single data line with a very timing-specific protocol. Since the protocol is very sensitive to timing, it requires a real-time microconroller such as an AVR, Arduino, PIC, mbed, etc. It cannot be used with a Linux-based microcomputer or interpreted microcontroller such as the netduino or Basic Stamp.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our wonderfully-written Neopixel library for Arduino supports these pixels! As it requires hand-tuned assembly it is only for AVR cores but others may have ported this chip driver code so please google around. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An 8MHz or faster processor is required. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-01-30T11:26:29.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8328" PostTypeId="1" CreationDate="2015-01-30T11:49:04.910" Score="0" ViewCount="1991" Body="&lt;p&gt;I am working on a project that involves sending motion sensing data wirelessly from an arduino to computer. Sensor readings have to be transmitted continuously (say every mili second). I am not sure if Xbee is my bet. I came across &lt;a href=&quot;http://www.faludi.com/projects/common-xbee-mistakes/p://&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt;&#xA;which suggest s that there should be atleast 10 ms delay between packets if you're using xbees. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are your experiences with xbees? I don't want to waste money. &lt;/p&gt;&#xA;" OwnerUserId="4669" LastActivityDate="2015-01-30T13:02:36.043" Title="Getting sensor data wirelessly from arduino to PC" Tags="|serial|xbee|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8329" PostTypeId="2" ParentId="8328" CreationDate="2015-01-30T13:02:36.043" Score="1" Body="&lt;p&gt;Xbee costs about 1000INR. They are really expensive. You should buy HC-05 module, which costs about 320INR.&#xA;You can easily interface them with Bluetooth of your Laptop using Processing Application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even use ESP8266 ESP-01 Wireless Module. They Cost about 3$.&#xA;Wireless module gets connected with your router. &lt;a href=&quot;http://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial will help you to start. You can by this module from &lt;a href=&quot;http://www.banggood.com/ESP8266-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-p-947259.html?p=IY04239401772014128X&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;nRF24l01+ modules can not be interfaced with Laptop...&lt;/p&gt;&#xA;" OwnerUserId="7045" LastActivityDate="2015-01-30T13:02:36.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8330" PostTypeId="2" ParentId="8326" CreationDate="2015-01-30T13:56:57.980" Score="2" Body="&lt;p&gt;On the products page, they link to the &lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide&quot; rel=&quot;nofollow&quot;&gt;Neopixel Uberguide&lt;/a&gt;, which should really contain what you need :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good thing about the NeoPixels is that they can be chained, since each pixel is supplied with VCC, GND, Data in and Data out. Data out of LED1 will be data in for LED2, and afaik you can make infinitely long chains this way&lt;/p&gt;&#xA;" OwnerUserId="7019" LastActivityDate="2015-01-30T13:56:57.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8331" PostTypeId="1" CreationDate="2015-01-30T14:46:37.747" Score="0" ViewCount="2725" Body="&lt;p&gt;I have a RFID module using NXP RC522 chipset.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/nnf3b.jpg&quot; alt=&quot;Chipset&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea that is it correct the module using 27.120 mHz&#xA;&lt;img src=&quot;https://i.stack.imgur.com/qSZxU.jpg&quot; alt=&quot;27.120 mHz&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have 4 IC card, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;A) 0005302176, (Blue color tag, come with the RFID module)&#xA;B) 0008846830 134,65006 (White card, come with the RFID module)&#xA;C) 0004189112 063,60344 (White card)&#xA;D) White card, no number print on the card. Only this card UID can be read.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cRJ2j.jpg&quot; alt=&quot;4 IC Cards&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the pinout&#xA;&lt;img src=&quot;https://i.stack.imgur.com/SkJaH.jpg&quot; alt=&quot;Pinout&quot;&gt;&#xA;Which I connected to Arduino UNO R3&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;     RFID         UNO R3&#xA;(Pin Name, Pin)    (Pin)&#xA;SDA        1        10&#xA;SCK        2        13&#xA;MOSI       3        11&#xA;MISO       4        12&#xA;IRQ        5        -No Connect-&#xA;GND        6        Ground&#xA;RST        7        9&#xA;3.3V       8        3.3V&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: I am using this &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot;&gt;library&lt;/a&gt;, and this &lt;a href=&quot;https://github.com/miguelbalboa/rfid/blob/master/examples/DumpInfo/DumpInfo.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: The serial return this information &lt;code&gt;MFRC522 Software Version: 0x91 = v1.0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4833" LastEditorUserId="42" LastEditDate="2015-01-30T14:52:08.757" LastActivityDate="2016-03-16T14:44:31.077" Title="Unable to read the IC Card UID" Tags="|arduino-uno|rfid|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8332" PostTypeId="2" ParentId="1541" CreationDate="2015-01-30T17:08:14.390" Score="-1" Body="&lt;p&gt;just trim the actual simcard, so its level with 'microsim insert' back edge. Its what i did on my Nokia 100/GPO 746 project, works fine, wont kill the phone&lt;/p&gt;&#xA;" OwnerUserId="7048" LastActivityDate="2015-01-30T17:08:14.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8333" PostTypeId="2" ParentId="1751" CreationDate="2015-01-30T17:27:31.813" Score="0" Body="&lt;pre&gt;&lt;code&gt;www.println(request);&#xA;www.println(F(&quot;User-agent: CompostMonitor/1.0\r\n&quot;));      &#xA;www.println(F(&quot;\r\n&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both &lt;code&gt;request&lt;/code&gt; and the other two strings end with &lt;code&gt;\r\n&lt;/code&gt;. You also use &lt;code&gt;println()&lt;/code&gt;, which adds &lt;code&gt;\r\n&lt;/code&gt; of itself. This means that you end every line with two CRLF sequences, which is not correct according to the &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2&quot; rel=&quot;nofollow&quot;&gt;HTTP standard&lt;/a&gt; (Sec 2.2, Basic Rules). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, use &lt;code&gt;print()&lt;/code&gt; which doesn't add anything, or don't add &lt;code&gt;\r\n&lt;/code&gt; to the strings yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servers may not complain about this but your code is not conform the standard and may not work on all servers / may stop working after a server update. It's also possible that some of the header fields are not being considered by the server because it treats them as body instead of headers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Besides that, you should considering use HTTP 1.1. There's no hard reason to change &lt;em&gt;now&lt;/em&gt;, but it's newer, includes more features, is supported by (almost) all server software, and will still work even when (&lt;em&gt;if&lt;/em&gt;) servers decide to start phasing out HTTP 1.0 support. You then need to change &lt;code&gt;1.0&lt;/code&gt; to &lt;code&gt;1.1&lt;/code&gt; in the &lt;code&gt;request&lt;/code&gt; string, and after that specify the Host field explicitly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;www.println(&quot;Host: myapp.herokuapp.com&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user6971" LastActivityDate="2015-01-30T17:27:31.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8334" PostTypeId="2" ParentId="8297" CreationDate="2015-01-30T17:47:38.417" Score="0" Body="&lt;p&gt;I decided go with the voltage divider approach as it seemed simple enough. The sensors themselves needed to be calibrated, which took me a while as I didn't have the required weights. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the calibration, I used the line of best fit approach to find an equation that translated voltage to force.&lt;/p&gt;&#xA;" OwnerUserId="618" LastActivityDate="2015-01-30T17:47:38.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8335" PostTypeId="2" ParentId="8321" CreationDate="2015-01-30T18:12:44.303" Score="1" Body="&lt;p&gt;Flat side of LED is &lt;code&gt;-&lt;/code&gt;. This means that your white wire is on &lt;code&gt;-&lt;/code&gt; side and your red wire on &lt;code&gt;+&lt;/code&gt; side. Therefore your power rail connection is reversed... and therefore your LED is ON when you send &lt;code&gt;0&lt;/code&gt; on PWM. By the way, you will set the LED OFF by writing &lt;code&gt;255&lt;/code&gt; on PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: connect power rails correctly and everything will be back to normal.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-01-30T18:12:44.303" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8337" PostTypeId="1" AcceptedAnswerId="8338" CreationDate="2015-01-30T21:32:23.823" Score="1" ViewCount="398" Body="&lt;p&gt;Situation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mac OS, Arduino IDE 1.5.6r2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a sketch with several files, all classic .cpp and .h source and header files except the main sketch file. As the project goes more complex I started to generate code automatically by another program. Now I have hard times integrating the generated code it into my sketch. The arduino IDE seems to load the code on opening the sketch. After that, the source files aren't beeing checked for external changes by the IDE (as I would expect it from a real editor like &lt;em&gt;vim&lt;/em&gt;). On top of that, when I verify my code the IDE seems to save the files from RAM into a temporary build directory ignoring the contents of the sketch directory further. So if I let my code generator change a source file while the sketch is opened in the IDE, the changes won't reach the build. I had to close the IDE and reopen it. The next thing I tried is to include my autogenerated file from an existing and opened code file inside the IDE. But the IDE ignores files, which aren't opened completely. Hence, the file is missing in the build directory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a trick to let the IDE take the code unknown to itself along into the build directory? Or how else can I deal with this situation? I don't want to close and open the IDE a hundred times a day.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-01-30T21:46:26.080" Title="Good way to get automatically generated code into a sketch" Tags="|arduino-ide|build|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8338" PostTypeId="2" ParentId="8337" CreationDate="2015-01-30T21:46:26.080" Score="2" Body="&lt;p&gt;According to the release notes starting with V1.5.2 of the IDE you can verify and upload from the command line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use your favorite editor and then use the command line to do the arduino build/upload instead of the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not used it so I can't say if it work well or not.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2015-01-30T21:46:26.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8339" PostTypeId="1" AcceptedAnswerId="8341" CreationDate="2015-01-31T00:49:07.557" Score="8" ViewCount="3207" Body="&lt;p&gt;I downloaded the RTClib library from &lt;a href=&quot;https://github.com/adafruit/RTClib&quot;&gt;https://github.com/adafruit/RTClib&lt;/a&gt;.  In every provided example, &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt; is written immediately above &lt;code&gt;#include &quot;RTClib.h&quot;&lt;/code&gt; at the top of the sketch.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this necessary?  I know the RTClib library requires the functionality of the Wire library but, if this is the case, why can't I just &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt; at the top of RTClib.h?  I have tried the latter, even using just the following sketch, but my sketch failed to compile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RTClib.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Code by JeeLabs http://news.jeelabs.org/code/&#xA;// Released to the public domain! Enjoy!&#xA;&#xA;#ifndef _RTCLIB_H_&#xA;#define _RTCLIB_H_&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;...&#xA;&#xA;#endif // _RTCLIB_H_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;RTClib.h&quot;&#xA;void setup() {}&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7053" LastActivityDate="2015-01-31T01:44:09.027" Title="RTClib library dependency on Wire library" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8340" PostTypeId="2" ParentId="1230" CreationDate="2015-01-31T01:34:02.890" Score="1" Body="&lt;p&gt;Before we start, note that it might not be the right pinout for the GSM shield to use a hardware serial port on the Mega. Beware of some nasty wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Poking around on Github, I found &lt;a href=&quot;https://github.com/arduino/Arduino/tree/db8cbf24c99dc930b9ccff1a43d018c81f178535/libraries/GSM&quot; rel=&quot;nofollow&quot;&gt;this is the directory for the GSM library&lt;/a&gt;. Ladies and gentlemen, it's time to &lt;strike&gt;break something important&lt;/strike&gt; get our hands dirty! Draw your  chairs close for a tale of touching code you shouldn't touch!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Click on the &lt;code&gt;src&lt;/code&gt; folder to open it up. When I first opened this up, I was somewhat scared by the number of files. However, I had a plan:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find the name of the SoftwareSerial instance. I'm guessing that they would use only one object to do this to prevent redundancy. In addition, I'm going to guess that most serial data is handles though a single file, but I'll have to confirm this.&lt;/li&gt;&#xA;&lt;li&gt;Remove instances of the SoftwareSerial Object.&lt;/li&gt;&#xA;&lt;li&gt;Clean up any remaining issues with the &quot;port&quot;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After more poking around, I noticed that the library actually uses &lt;a href=&quot;https://github.com/arduino/Arduino/blob/db8cbf24c99dc930b9ccff1a43d018c81f178535/libraries/GSM/src/GSM3SoftSerial.h&quot; rel=&quot;nofollow&quot;&gt;a unique version of the SoftwareSerial library&lt;/a&gt;, so it will be even &lt;em&gt;harder&lt;/em&gt; to do this. Yay us! On the upside, we know exactly what code to replace. Fasten your seatbelts, this is about to get pretty nasty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay, take a step back here and figure out &lt;em&gt;what&lt;/em&gt; we want to modify. First of all, it's a &lt;em&gt;terrible&lt;/em&gt; idea to modify the libraries directly in the directory that the Arduino IDE uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if you were to make a copy from the &lt;code&gt;src&lt;/code&gt; folder for the GSM library into the Arduino &quot;libraries&quot; folder, it wouldn't be enough. The Arduino IDE would get confused when there would be two identical header files to use. You will need to rename the &lt;em&gt;main header file&lt;/em&gt; and use just that one instead to include into your projects. In addition, most of the files in the library probably reference that file, so make sure to rename any references within the library to that one file. A quick CTRL + SHIFT + F on the Atom text editor will search the entire project I'm working on. I'm not entirely sure if a folder name would mess up the Arduino IDE, but it'd be a good idea to rename the folder to whatever your library is called, at least for readability purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before we continue, let's make sure that the library still compiles without us playing with the code. Import the new library into a basic GSM example sketch and see if it compiles and works normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It compiles? Great. Let's go on!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file that does serial is the &lt;code&gt;GSM3SoftSerial.cpp&lt;/code&gt; file. Without actually porting it, I can't give you a ton of advice here. Look through and see when variables are created, used, and modified. If you're not sure, &lt;a href=&quot;http://chat.stackexchange.com/rooms/8489/pin-13&quot;&gt;I'm in chat sometimes: feel free to ask there on minor questions and ping me with @AnnonomusPenguin&lt;/a&gt; or leave a comment on this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also advise to leave everything in there that you're not sure of, make sure it works with hardware serial, and line by line start removing that variable and see if anything breaks. A great too for this would be to use a tool like Git/Github (or other version control software) to help you revert changes that broke something or to see, overall, what you've changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, after replacing the code inside the functions (finalWrite, the ISRs, and the begin/clear seem like the ones you should touch), compile the code and see if it works!&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-01-31T01:34:02.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8341" PostTypeId="2" ParentId="8339" CreationDate="2015-01-31T01:36:27.300" Score="4" Body="&lt;p&gt;Not getting too formal here, The arduino IDE looks at which libraries are included in the top level sketch when deciding what libraries to include in the compilation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would make sense for only RTClib.h to include Wire.h yes, but the IDE does not get the information to add Wire to the compilation list that way. It is a quirk of the IDE that makes implementing libraries that use other libraries a bit more painful.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-01-31T01:44:09.027" LastActivityDate="2015-01-31T01:44:09.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8342" PostTypeId="2" ParentId="8321" CreationDate="2015-01-31T04:57:55.883" Score="0" Body="&lt;p&gt;Ok, it seems my understanding of the PWM was wrong. I tried the circuit and code from here (&lt;a href=&quot;http://arduino.cc/en/Tutorial/Fade&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/Fade&lt;/a&gt;) and it worked as expected (fade in and out).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually when i wrote my original code i was expecting the LED to blink. So, as i got closer to 255 i was expecting it to spend more time being 'lit', as compared to 0 where it should spend less time being 'lit'.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I even change the pinNine outputValue to (64, 127, etc) but for some&#xA;  reason the LED is always lighted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It being lighted makes sense. What i missed out was it being dimmer when the value was lower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for all your help..&lt;/p&gt;&#xA;" OwnerUserId="7034" LastActivityDate="2015-01-31T04:57:55.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8343" PostTypeId="1" CreationDate="2015-01-31T08:16:45.173" Score="0" ViewCount="377" Body="&lt;p&gt;Me and my friend recently built a Breadboard Arduino. It switches on fine, and the LED changes a bit. I have added a 5V FTDI cable, but it wouldn't upload, trying to fix this, I used my friends 5V FTDI Basic USB-To-Serial converter chip, thinking this would upload fine, as it was new, but it still wouldn't upload, giving the very long error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.5.8 (Windows XP), Board: &quot;Arduino Duemilanove or Diecimila, ATmega328&quot;&#xA;&#xA;Build options changed, rebuilding all&#xA;&#xA;&#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\hooks.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\hooks.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WInterrupts.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WInterrupts.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_analog.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_analog.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_digital.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_pulse.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_pulse.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_shift.c -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_shift.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\abi.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\abi.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\CDC.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial0.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial1.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial1.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial2.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial3.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial3.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HID.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HID.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\IPAddress.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\IPAddress.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\main.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\main.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\new.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\new.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Print.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Stream.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Stream.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Tone.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Tone.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\USBCore.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\USBCore.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WMath.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WString.cpp -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WString.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\hooks.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WInterrupts.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_analog.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_digital.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_pulse.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\wiring_shift.c.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\abi.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\CDC.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial0.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial1.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial2.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HardwareSerial3.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\HID.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\IPAddress.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\main.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\new.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Print.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Stream.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\Tone.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\USBCore.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WMath.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-ar rcs C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\WString.cpp.o &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp\sketch_jan31a.cpp.o C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/core.a -LC:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp -lm &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.eep &#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.elf C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.hex &#xA;&#xA;&#xA;&#xA;Sketch uses 450 bytes (1%) of program storage space. Maximum is 30,720 bytes.&#xA;&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;&#xA;C:\Program Files\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM8 -b57600 -D -Uflash:w:C:\DOCUME~1\George\LOCALS~1\Temp\build7021919583125132986.tmp/sketch_jan31a.cpp.hex:i &#xA;&#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr  3 2014 at 23:12:16&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM8&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x01&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x01&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The light on the USB-To-Serial board lights once for each failed upload, but the sketch won't upload. I am trying to upload the blink sketch. The chip I am using is an Atmel AtMega328P-PU. All answers greatly appreciated.&lt;/p&gt;&#xA;" OwnerDisplayName="user6867" LastActivityDate="2021-04-09T03:01:25.123" Title="Home-made Arduino not receiving data" Tags="|uploading|ftdi|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8345" PostTypeId="2" ParentId="8320" CreationDate="2015-01-31T17:10:05.143" Score="1" Body="&lt;p&gt;Your question is a little confusing, so let me give you a couple pieces of information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First things first - the VIn pin on the Arduino is strictly for power going to the Arduino board, you shouldn't be drawing power from this pin. The documentation in the link you sent is a little misleading on this - it's basically saying 9v is coming OUT of the PoE module, and going IN to the VIn on the Arduino itself. If you wanted to tap into this 9v power, you should connect to the PoE module VOut instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PoE by default can deliver 37-57 volts or 42-57 volts, depending on what type of PoE you're using (which 802.3 specification). &lt;a href=&quot;http://en.wikipedia.org/wiki/Power_over_Ethernet#Standard_implementation&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt; has a good overview of this information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, the Arduino Ethernet board you're using can't handle this voltage by itself - unless these boards have changed, they require an additional &lt;a href=&quot;http://store.arduino.cc/product/X000002&quot; rel=&quot;nofollow&quot;&gt;PoE module&lt;/a&gt;, which is basically just a DC-to-DC buck converter that will convert the high PoE voltage down to 9v or 12v. At this point, the Arduino's built-in converter can consume that 9 or 12v and distribute it at 5v across the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to your problem - you want to power a relay that requires 7-12v. You could theoretically connect the relay to the VOut of the PoE module, giving you 12v. However, if the relay draws too much power for too long, you will either get brownouts (and your Arduino will restart) or potentially damage the Arduino board. Unless the relay draws a lot of current or is being powered for extended periods, you should be fine. If you want to be more thorough, you could put a large capacitor between your PoE module and the relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should NOT try to connect the relay directly to the PoE VOut, as the voltage will be far too high. &lt;/p&gt;&#xA;" OwnerUserId="7057" LastActivityDate="2015-01-31T17:10:05.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8346" PostTypeId="2" ParentId="224" CreationDate="2015-01-31T17:45:53.533" Score="3" Body="&lt;p&gt;you can program with an SMD board, you dont link the reset line, hold down the reset on the uno throughout the whole process, and tap the reset on the mini soon as the ide says upload to upload the sketch, by holding the uno in reset it doesn't interfere with the serial comms&lt;/p&gt;&#xA;" OwnerUserId="7059" LastActivityDate="2015-01-31T17:45:53.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8347" PostTypeId="1" CreationDate="2015-01-31T20:05:22.797" Score="5" ViewCount="6650" Body="&lt;p&gt;I'm developing a low power project based on Atmega328p which among other things uses a DHT22 to measure air humidity. DHT22 spec says that it consumes 50uA when idle. This is too high for me (I'm aiming at sub 10uA consumption for the whole device when in sleep mode) so I've figured out that I'll just power it from one of Atmega328p pins. This will give me the ability to turn it off or on at software level. DHT22 consumes only 1.5mA during measurement so I should be fine (a single Atmega's pin can safely provide up to 20mA). I've set up a following test circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3AcJY.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red wire powers DHT22, the blue one is for data transfer, the black one is GND and the 4.7k is a pull-up resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that after I turn on the DHT22 using just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(4, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the Atmega either resets or hangs or... successfully turns on the DHT22 and keeps working, but that happens about 10% of the time. My suspicion is that there is some current spike in the moment of supplying power to the DHT22. Unfortunately I don't have an oscilloscope to confirm this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added a 220 ohm resistor between VCC pin of DHT22 and the pin 4 on the Arduino and it solved the problem. My question is: will it work like this reliably? Are humidity readings reliable when voltage is not stabilized (but stays within 3.3-5.5V range as required by the datasheet)? I could of course use a transistor to turn it on/off, but I'd like to keep it as simple as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why DHT22's datasheet doesn't mention this current spike? Here it is for reference: &lt;a href=&quot;http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5130" LastActivityDate="2015-12-29T08:07:09.640" Title="arduino resets or hangs after providing power to DHT22" Tags="|sensors|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8348" PostTypeId="1" AcceptedAnswerId="8403" CreationDate="2015-01-31T23:34:11.700" Score="1" ViewCount="527" Body="&lt;p&gt;Yes, you read that right.  An &lt;code&gt;Apple IIe&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have many retro computers and I was thinking that since the &lt;code&gt;Apple II&lt;/code&gt; line of computers (especially the &lt;code&gt;IIe&lt;/code&gt;) have pretty speedy serial ports that it should be somewhat simple to use an Arduino to send data to/from the Apple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that all of my every-day computers are USB based with no RS232 serial.  I guess I could boot up an old Linux laptop that has a serial port but that seems too cumbersome given my limited desk space.  :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I've Googled but I'm not finding anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since most &lt;code&gt;Apple IIe&lt;/code&gt; disk images are pretty small (&amp;lt;144k or so) they should fit pretty easily into, say, an Arduino DUE that I have.  Or better yet, using the DUE to mount as a USB device that could send over to the IIe would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is, does anyone know of any site that explains how this could be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, turns out it WAS pretty easy getting the Arduino DUE to send to the Apple IIe.  I simply connected 3 wires from TX1/TR1/GND to the Apple IIe serial port (SSC).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when I launch ADT Pro and start sending, the IIe is receiving garbage.  Bunch of &quot;9d9d9d9d&quot; all over the place. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ADT.ino&#xA;&#xA;int incomingByte = 0;&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(9600);&#xA;    Serial1.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    if(Serial.available() &amp;gt; 0) {&#xA;&#xA;        while(Serial.available() &amp;gt; 0) {&#xA;&#xA;            incomingByte = Serial.read();&#xA;&#xA;        }&#xA;&#xA;        Serial1.write(incomingByte);&#xA;        delay(100);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ADT Pro software is set to send the data over the USB port and it's obviously sending data to the IIe.  I'm just wondering if the formatting is wrong or something.&lt;/p&gt;&#xA;" OwnerUserId="6883" LastEditorUserId="6883" LastEditDate="2015-02-01T07:17:35.213" LastActivityDate="2015-02-03T16:00:43.337" Title="Has anyone used an Arduino to transfer software to an Apple IIe?" Tags="|serial|arduino-due|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8350" PostTypeId="2" ParentId="8237" CreationDate="2015-02-01T05:29:21.900" Score="0" Body="&lt;p&gt;There could be many reasons for the problem you have got.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Try to program your Board with any other device you have got. If you are trying to program it with PC try to do it using Laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Plug your board to any other port. Then Right Click My Computer and Select Manage--&gt; Device Manager and find the port where your Freeduino is connected. Then Select that port in  your Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution 1 worked for me!&lt;/p&gt;&#xA;" OwnerUserId="7045" LastActivityDate="2015-02-01T05:29:21.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8351" PostTypeId="2" ParentId="1585" CreationDate="2015-02-01T07:26:42.980" Score="0" Body="&lt;p&gt;I had the exact same problem. I tried installing the IDE on another laptop and uploaded the program from that laptop. Problem solved. Then I came back to my laptop, uninstalled the IDE and re-installed it. It works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I wasn't satisfied because I can't find the source of the problem... so I tried running everything again the same exact way.. I found the problem but am not sure if that can be the actual cause of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my project, I needed to carry out serial communication between Arduino and MATLAB (GUI). In order to see/verify the output(type) of MATLAB (GUI) serial data, I used HYPERTERMINAL and also VIRTUAL SERIAL PORT EMULATOR. I noticed that every time hyperterminal is running or VSPE is running while my serial monitor is on, it screws up the uploading feature of the program. I'm not sure if it's because of the VSPE or HYPERTERMINAL, but reinstalling the IDE worked for me. :-)&lt;/p&gt;&#xA;" OwnerUserId="7069" LastEditorUserId="42" LastEditDate="2015-02-01T09:31:08.930" LastActivityDate="2015-02-01T09:31:08.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8352" PostTypeId="2" ParentId="17" CreationDate="2015-02-01T07:29:56.967" Score="7" Body="&lt;p&gt;I had the exact same problem. I tried installing the IDE in another laptop and uploaded the program from that laptop. Problem solved. Then I came back to my laptop, uninstalled the IDE and re-install it.. it started working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I wasn't satisfied because I couldn't find the source of the problem... so I tried running everything again the same exact way... I found the problem but not sure if that can be the actual cause of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my project, I needed to carry out serial communication between arduino and MATLAB (GUI). In order to see/verify the output(type) of MATLAB (GUI) serial data, I used HYPERTERMINAL and also VIRTUAL SERIAL PORT EMULATOR. I noticed that every time when when hyperterminal is running or VSPE is running while my serial monitor is on it screws up the uploading feature of the program. I'm not sure if it's because of the VSPE or HYPERTERMINAL, but reinstalling the IDE worked for me.&lt;/p&gt;&#xA;" OwnerUserId="7069" LastEditorUserId="11529" LastEditDate="2015-11-30T15:04:52.420" LastActivityDate="2015-11-30T15:04:52.420" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8353" PostTypeId="1" AcceptedAnswerId="8354" CreationDate="2015-02-01T07:49:18.203" Score="1" ViewCount="162" Body="&lt;p&gt;I generally use sockets for AVRs in standalone circuits, but sometimes I sell my items and therefore I soldier the chip on the circuit. As you guess I can upgrade the code inside the chip with socket simply putting the chip out and putting it into the programmer board, but It doesn't work the same way with the ones which are soldiered on the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are some ISP devices like USBtinyISP etc., but I want to be more professional and know exactly how an in system programmer work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to use Avrdude If I design my own In system programmer? Isn't there any way that is more universal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched the internet for a long time and I found only hobbyist stuff. Can anyone explain or simply direct me to a good source that explains this topic? Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="6994" LastActivityDate="2015-02-02T00:57:05.547" Title="In system programming for avr?" Tags="|avr|avrdude|isp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8354" PostTypeId="2" ParentId="8353" CreationDate="2015-02-01T08:21:04.440" Score="1" Body="&lt;p&gt;ISP works by using a serial connection (usually via the SPI and nRESET pins) to the MCU. The programmer talks to the device using the low-level protocol that the device expects, and connects to the host using a different, high-level protocol. The host then directs the programmer to perform the various programming actions on the device, and in turn the programmer reports to the host about its current status.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of programming protocols that already exist, such as the one described in &lt;a href=&quot;http://www.atmel.com/Images/doc0943.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR910&lt;/a&gt;. As long as both the connection type and the protocol itself are supported by AVRDUDE it will work transparently once the hardware is assembled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further details about ISP are available in both AVR910 as well as the &quot;Serial Programming&quot; section of the datasheet for the device in question.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-01T08:21:04.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8355" PostTypeId="2" ParentId="8347" CreationDate="2015-02-01T08:41:56.633" Score="2" Body="&lt;p&gt;The sensor is a large capacitive load. You need to improve decoupling of the CPU power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 10 uF between 5V and GND will help for the current spike and the resistor in series with the sensor will not be an issue (50 uA on 250 Ohm makes only 12.5 mV voltage drop once the sensor is started).&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-01T08:41:56.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8356" PostTypeId="1" CreationDate="2015-02-01T11:37:30.293" Score="2" ViewCount="343" Body="&lt;p&gt;I want to design an Arduino shield with stackable headers, so it will allow other shields to be mounted on top of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/u7HYX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if these could be soldered automatically. Neither wave nor reflow soldering seems to be an option. Wave soldering would leave solder on the pins so they won't fit in sockets, and for reflow (pin-in-paste) the long pins will completely pull the paste from the holes. &#xA;Is hand-soldering the only way (making the board more expensive), or is there still another way? Would it be a good idea to supply the shield with the headers not mounted to save cost?&#xA;Or shouldn't I assume the average Arduino user has a soldering iron?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-02T17:48:19.873" Title="Can stackable Arduino headers be automatically soldered?" Tags="|shields|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8357" PostTypeId="1" AcceptedAnswerId="8363" CreationDate="2015-02-01T13:20:28.247" Score="4" ViewCount="11838" Body="&lt;p&gt;According to my current (poor) understanding, only the PWM pins (with the ~) among the digital pins (ignoring Analog pins) can be passed to &lt;code&gt;analogWrite()&lt;/code&gt;.  I understand the servo therefore - since interfaced by a variable voltage signal - must be connected to such a PWM pin.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Why is the humble Piezo Buzzer not bound to this condition?  &lt;/li&gt;&#xA;&lt;li&gt;Why can I connect the buzzer to a digital pin that is not PWM (and so should only be able to output binary LOW, HIGH voltage at some consistent frequency) and still achieve a varying sound by calls to the &lt;code&gt;tone()&lt;/code&gt; function?  &lt;/li&gt;&#xA;&lt;li&gt;Surely under the limitations of being digital and non-PWM, the pin could only cause some consistent buzzer frequency?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm reading online that the Piezeo Buzzer does indeed require a PWM digital pin, but I can connect it to any digital pin on my Galileo gen2 and have it function seemingly correctly (differing tones produced).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since slightly relevant; what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?&lt;/p&gt;&#xA;" OwnerUserId="6900" LastEditorUserId="6936" LastEditDate="2016-03-13T07:57:46.227" LastActivityDate="2016-03-13T07:57:46.227" Title="Why does a Piezo Buzzer not require a PWM digital pin (Gallileo Gen2)?" Tags="|pins|pwm|analogwrite|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8358" PostTypeId="1" AcceptedAnswerId="8360" CreationDate="2015-02-01T14:58:28.600" Score="1" ViewCount="630" Body="&lt;p&gt;I'm in the process of buying a receiver and transmitter for my quad copter project. Would it be possible to use this receiver or a similar one to control the quad. I'm trying to read the signals using Pulse in. I'm inexperienced in RC and I only found one tutorial on how to do this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the receiver will have to be wired up to the analog pins on the arduino however, the receiver has an operating voltage of 3.5V-10V and an operating current of 100mA which exceeds the 40mA of the arduino board. I have seen videos of people using silar 2.4Ghz receivers on arduino Nanos without problems. Has anyone on this board done something similar and if so, can thou guide me?&lt;/p&gt;&#xA;" OwnerUserId="6768" LastActivityDate="2015-02-01T17:43:37.557" Title="Is it possible to use FrSky D8R-II Plus 8ch 2.4Ghz ACCST Receiver with an arduino Uno?" Tags="|arduino-uno|analogread|pulsein|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8359" PostTypeId="2" ParentId="8347" CreationDate="2015-02-01T15:23:05.657" Score="0" Body="&lt;p&gt;The previous answers regarding adding decoupling capacitors are good.&lt;br&gt;&#xA;You don't have to be concerned about the voltage drop across your 220 ohm resistor. MAC's answer states that only 12.5mv drop at 50uA (when not measuring).&lt;br&gt;&#xA;&lt;strong&gt;During measurement&lt;/strong&gt;, 1.5mA will result in 0.33v drop across the 220 ohm resistor. This should be noted, but is not a problem. The DHT22 data sheet shows that it will accept any supply voltage between 3.3v and 6v.&lt;br&gt;&#xA;  Looks like you have a good design.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2015-02-01T15:23:05.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8360" PostTypeId="2" ParentId="8358" CreationDate="2015-02-01T17:43:37.557" Score="1" Body="&lt;p&gt;I've used plenty of receivers like this with arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operating current is not really an issue; It is drawing power off of the 5v line, not the digital pins, which is capable of 100mA. In any case they usually have an extra &quot;bat&quot; line that you could plug in to a BEC from one of your speed controllers, and then just connect signal and ground lines to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pulseIn works, but not ideally (especially for quadcopters). reading with pulseIn tends to have quite a bit of noise, and runs slow. Those receivers pulse around 50-60Hz, so reading those signals with pulseIn (which has to wait for the signal to finish) will take too long. I say &quot;too long&quot; because in all the open source quad copter programs I've looked at the sensor-read/stabilize update loop needs to run at 100 Hz or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to use is the interrupt functionality of the AVR. That way you can detect the time between changes in state of the input pulse without causing the rest of the program to stop. This can get somewhat complicated so I'm not going to write a tutorial here. I recommend you research it yourself and ask new, specific questions here if you have any.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't magically fix everything for you though; the Uno only has 2 external interrupts. I think most arduino based quads use arduino megas or Leonardos, which have more. I know the APM 2 board has a separate chip converting those 8 single channel PPM signals into a single 8 channel PPM signal that goes into the main controller, despite the fact that it is a mega. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look into Aeroquad and Multiwii for inspiration. ArduPilot is open source as well but their code is messier, which makes reading it much more difficult. I don't think it is impossible to use an Uno, but it will be difficult.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-02-01T17:43:37.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8362" PostTypeId="1" CreationDate="2015-02-01T20:55:47.660" Score="1" ViewCount="902" Body="&lt;p&gt;I'm working on a project with 4 inputs and 7 possible outputs on an Arduino Uno.  Based on any combination of those inputs, I need to run a specific &quot;loop&quot; that will repeat until there is a change in ANY of the 4 inputs.  Specifically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Input 1 = loop 1&lt;/li&gt;&#xA;&lt;li&gt;Input 2 = loop 2&lt;/li&gt;&#xA;&lt;li&gt;Input 3 = loop 3&lt;/li&gt;&#xA;&lt;li&gt;Input 4 = loop 4&lt;/li&gt;&#xA;&lt;li&gt;Input 2 and 3 = loop 5&lt;/li&gt;&#xA;&lt;li&gt;Input 2 and 4 = loop 6&lt;/li&gt;&#xA;&lt;li&gt;No input = do nothing&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I need to constantly read the 4 inputs and change output loops accordingly.  I have basic Arduino knowledge but am stumped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I've tried - I have 4 input pins and 8 output pins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int outPin = 0;&#xA;int inPin = 0;&#xA;int CAR = 0;&#xA;int pinRead = 0;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA; for (int outPin = 3; outPin &amp;lt; 11; outPin++);  {  //set pins 3 thru 10 as OUTPUT&#xA;   pinMode(outPin, OUTPUT);&#xA;  }&#xA;&#xA; for (int inPin = 9; inPin &amp;lt; 13; inPin++);  {    //set pins 9 thru 12 as INPUT&#xA;   pinMode(inPin, INPUT);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for (int CAR = 3; CAR &amp;lt;11; CAR++); {  //set all pins to LOW&#xA;   digitalWrite(CAR, LOW);&#xA;  }&#xA;&#xA;  // BRAKE&#xA;&#xA;    {while (digitalRead(9 == HIGH) &amp;amp;&amp;amp; digitalRead(10 == LOW) &amp;amp;&amp;amp; digitalRead (11 == LOW) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;    digitalWrite(3, HIGH);&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    digitalWrite(6, HIGH);&#xA;    digitalWrite(7, HIGH);&#xA;    digitalWrite(8, HIGH);&#xA;    digitalWrite(9, HIGH);&#xA;    digitalWrite(10, HIGH); &#xA;&#xA;  }} &#xA;&#xA;  // LEFT&#xA;&#xA;    {while (digitalRead(9 == LOW) &amp;amp;&amp;amp; digitalRead(10 == HIGH) &amp;amp;&amp;amp; digitalRead(11 == LOW) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;    digitalWrite(0, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(1, HIGH);&#xA;    digitalWrite(3, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(2, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(0, LOW);&#xA;    digitalWrite(1, LOW);&#xA;    digitalWrite(2, LOW);&#xA;    digitalWrite(3, LOW);&#xA;    delay (200);&#xA;&#xA;  // RIGHT&#xA;&#xA;  }}&#xA;&#xA;    {while (digitalRead(9 == LOW) &amp;amp;&amp;amp; digitalRead(10 == LOW) &amp;amp;&amp;amp; digitalRead(11 == HIGH) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;    digitalWrite(5, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(6, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(7, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(4, LOW);&#xA;    digitalWrite(5, LOW);&#xA;    digitalWrite(6, LOW);&#xA;    digitalWrite(7, LOW);&#xA;    delay (200);&#xA;&#xA;  // HAZARD&#xA;&#xA;  }}&#xA;&#xA;    {while (digitalRead(9 == LOW) &amp;amp;&amp;amp; digitalRead(10 == LOW) &amp;amp;&amp;amp; digitalRead(11 == LOW) &amp;amp;&amp;amp; digitalRead(12 == HIGH)) {&#xA;    digitalWrite(0, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(1, HIGH);&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    digitalWrite(6, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(2, HIGH);&#xA;    digitalWrite(7, HIGH);&#xA;    delay (200);&#xA;&#xA;      for (int CAR = 0; CAR &amp;lt; 8; CAR++); {  //set all pins to LOW&#xA;       digitalWrite(CAR, LOW);&#xA;    delay (200);}}&#xA;&#xA;  // BRAKELEFT&#xA;&#xA;  }&#xA;&#xA;    {while ( digitalRead(9 == HIGH) &amp;amp;&amp;amp; digitalRead(10 == HIGH) &amp;amp;&amp;amp; digitalRead(11 == LOW) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;    digitalWrite(0, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    digitalWrite(6, HIGH);&#xA;    digitalWrite(7, HIGH); &#xA;    delay (200);&#xA;    digitalWrite(1, HIGH);&#xA;    digitalWrite(3, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(2, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(0, LOW);&#xA;    digitalWrite(1, LOW);&#xA;    digitalWrite(2, LOW);&#xA;    digitalWrite(3, LOW);&#xA;    delay (200);&#xA;    }&#xA;  }&#xA;&#xA;  // BRAKERIGHT&#xA;&#xA;    {while (digitalRead(9 == HIGH) &amp;amp;&amp;amp; digitalRead(10 == LOW) &amp;amp;&amp;amp; digitalRead(11 == HIGH) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;    digitalWrite(0, HIGH);&#xA;    digitalWrite(1, HIGH);&#xA;    digitalWrite(2, HIGH);&#xA;    digitalWrite(5, HIGH); &#xA;    delay (200);&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(6, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(7, HIGH);&#xA;    delay (200);&#xA;    digitalWrite(4, LOW);&#xA;    digitalWrite(5, LOW);&#xA;    digitalWrite(6, LOW);&#xA;    digitalWrite(7, LOW);&#xA;    delay (200);&#xA;    }&#xA;  }&#xA;&#xA;  // NOTHING&#xA;&#xA;    {while (digitalRead(9 == LOW) &amp;amp;&amp;amp; digitalRead(10 == LOW) &amp;amp;&amp;amp; digitalRead(11 == LOW) &amp;amp;&amp;amp; digitalRead(12 == LOW)) {&#xA;&#xA;       for (int CAR = 0; CAR &amp;lt; 8; CAR++); {  //set all pins to LOW&#xA;         digitalWrite(CAR, LOW); }}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7079" LastEditorUserId="42" LastEditDate="2015-02-01T22:26:29.223" LastActivityDate="2015-02-01T22:50:07.810" Title="Imbedded loops based on inputs" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8363" PostTypeId="2" ParentId="8357" CreationDate="2015-02-01T21:13:08.230" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why does a Piezo Buzzer not require a PWM digital pin?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Tone() uses the microcontroller's hardware timers to control the related code function but do not use the hardware PWM features. The timer can be assigned to any pin that has a digital output capability.&lt;br&gt;&#xA;Tone() sends a &quot;rail to rail&quot; square wave (50% duty cycle) to the selected pin  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slightly more lower level information here under &lt;a href=&quot;https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation#Ugly_Details&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Ugly details&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;They say:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The library uses the hardware timers on the microcontroller to generate square-wave tones in the audible range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can output the tones on any pin (arbitrary). The number of tones that can be played simultaneously depends on the number of hardware timers (with CTC capability) available on the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATmega8: 2 (timers 2, and 1)&lt;br&gt;&#xA;ATmega168/328: 3 (timers 2, 1, and 0)&lt;br&gt;&#xA;ATmega1280: 6 (timers 2, 3, 4, 5, 1, 0)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer order given above is the order in which the timers are allocated. Timer 0 is a sensitive timer on the Arduino since it provides millis() and PWM functionality.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a misconception there.&lt;br&gt;&#xA;Analog pins are capable of Analog INPUT functionality .&lt;br&gt;&#xA;&quot;PWM&quot; output is known as &quot;analogWrite&quot; but is actually a purely digital function and is not related to whether a pin has analog read functionality.&lt;br&gt;&#xA;PWM out = analogWrite is available on pins which have associated PWM hardware.&lt;br&gt;&#xA;The actual signal is a &quot;rail to rail&quot; square wave with a mark:space (on:off)that varies.   Filtering the PWM produces DC at the average DC level. PWM range is 0 to 255 (8 bits)&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-01T21:18:35.607" LastActivityDate="2015-02-01T21:18:35.607" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="8365" PostTypeId="2" ParentId="8356" CreationDate="2015-02-01T21:32:07.623" Score="1" Body="&lt;p&gt;I would suggest using SMD headers on one side and through hole on the other side. One side with this: &lt;a href=&quot;http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/partdetails.aspx?Class=ASSMANN&amp;amp;ClsID=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&amp;amp;PartID=10-18062010-079808&quot; rel=&quot;nofollow&quot;&gt;http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/partdetails.aspx?Class=ASSMANN&amp;amp;ClsID=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&amp;amp;PartID=10-18062010-079808&lt;/a&gt;&#xA;and one side with this: &lt;a href=&quot;http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/PartDetails.aspx?Class=ASSMANN&amp;amp;clsid=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&amp;amp;ManID=ASSMANN&amp;amp;PartFamilyID=10-23062010-067691&amp;amp;PartID=10-23062010-067691&amp;amp;SrchRsltId=1&amp;amp;SrchRsltType=0&quot; rel=&quot;nofollow&quot;&gt;http://www.tracepartsonline.net/(S(30y0dp21y1rd0u3erv1mrrbw))/PartDetails.aspx?Class=ASSMANN&amp;amp;clsid=/F_ASSMANN/ASSMANN.010/ASSMANN.010.170/&amp;amp;ManID=ASSMANN&amp;amp;PartFamilyID=10-23062010-067691&amp;amp;PartID=10-23062010-067691&amp;amp;SrchRsltId=1&amp;amp;SrchRsltType=0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will shift upper side a few mm from bottom side, and use glue to have upper side set in place and then reflow for soldering on both sides.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-01T21:32:07.623" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8366" PostTypeId="2" ParentId="1585" CreationDate="2015-02-01T21:36:36.620" Score="0" Body="&lt;p&gt;This has happpened to me as well. I had a bluetooth/TTL unit wired to RX/TX, which are the same ports used by the usb connection to the computer (where transfer of the program happens), and all I had to do was disconnect RX to the BT unit when transferring the program.&lt;/p&gt;&#xA;" OwnerUserId="6741" LastActivityDate="2015-02-01T21:36:36.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8367" PostTypeId="2" ParentId="8362" CreationDate="2015-02-01T22:50:07.810" Score="2" Body="&lt;p&gt;When you need repeating behaviour in an Arduino program, putting loops within the &lt;code&gt;loop()&lt;/code&gt; function often isn't the best approach. It leads to a lot of confusing logic which is quite hard to get right, and becomes quite unwieldy to maintain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more effective approach would be something like a simple state machine. At the start of &lt;code&gt;loop()&lt;/code&gt; you would check the input values and figure out which behaviour (or state) you want to execute: BRAKE, LEFT, RIGHT etc.. You might want to store this information in a variable somewhere, e.g. state &lt;code&gt;0&lt;/code&gt; could be BRAKE, state &lt;code&gt;1&lt;/code&gt; could be LEFT, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, you simply check what the state value is, and execute the appropriate instructions &lt;strong&gt;once&lt;/strong&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (state)&#xA;{&#xA;    case 0:&#xA;        // BRAKE instructions here...&#xA;        break;&#xA;&#xA;    case 1:&#xA;        // LEFT instructions here...&#xA;        break;&#xA;&#xA;    // etc...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's no need for any &lt;code&gt;while&lt;/code&gt; loops because &lt;code&gt;loop()&lt;/code&gt; is going to get called all the time anyway. There are two big advantages of this approach. First, you only need all the input conditions in one place, which makes the code easier to manage. And second, it means you can easily have your program doing other things later in &lt;code&gt;loop()&lt;/code&gt; because it's no longer stuck in nested loops all the time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, it's very important to mention that lines like this are incorrect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalRead(9 == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you're doing here is comparing the number &lt;code&gt;9&lt;/code&gt; to &lt;code&gt;HIGH&lt;/code&gt;, and then passing the result (which is 0) to the &lt;code&gt;digitalRead()&lt;/code&gt; function. That means you're effectively only ever checking pin 0. What you actually want to do is pass &lt;code&gt;9&lt;/code&gt; to the function, and then compare the overall result to &lt;code&gt;HIGH&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalRead(9) == HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-01T22:50:07.810" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8368" PostTypeId="1" AcceptedAnswerId="8369" CreationDate="2015-02-01T23:55:05.653" Score="0" ViewCount="2526" Body="&lt;p&gt;I'm currently working on a project that requires to display images on a touchscreen on my arduino. These images are neither stored in arduino nor any memory card. I want to be able to send the images via Bluetooth from an app and display it on the touchscreen. The problem is I couldn't find a good and solid Bluetooth shield or module that provide file transfer via bluetooth from an iOS app to arduino. If you can name a few bluetooh shields or modules that'd be great. In the thread below, someone claimed hc-05 works. Can anyone support that claim? Thanks.&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=208306.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=208306.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="5073" LastActivityDate="2019-05-14T16:40:03.610" Title="Bluetooth shield/module for file transfer?" Tags="|bluetooth|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8369" PostTypeId="2" ParentId="8368" CreationDate="2015-02-02T00:38:00.163" Score="1" Body="&lt;p&gt;I would use an HC-05 (or HC-06 - there seems to be little difference) - You will need to do your own file transfer protocol - for small images, zmodem or xmodem (usual file-over-serial) are probably completely overly complex. You would also need your own app for the phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use a network (ethernet or wifi) addon on your arduino - I think I read the Arduino Yun has built in ethernet and wifi.&lt;a href=&quot;http://arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/WebServer&lt;/a&gt; has a webserver, this could be adapted to accept uploaded files. You can then use a webbrowser on your phone (or indeed anywhere else!) to send the files. If you want to send from outside your local network, you may need to set up port forwarding on your router (google: port forward) - the port you want to forwards is 80.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-02T00:38:00.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8370" PostTypeId="2" ParentId="8353" CreationDate="2015-02-02T00:57:05.547" Score="0" Body="&lt;p&gt;You can use an ISP using the Arduino UI - simply select your programmer (tools-&gt;programmer) then &quot;upload using programmer&quot; (under the file menu).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use a pre-programmed AVR to do the programming - see &lt;a href=&quot;http://www.atmel.com/images/doc0943.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/doc0943.pdf&lt;/a&gt; for the spec. I think an AtTiny would be enough, depending on how big your program is, you might need some external storage. You could set it up with a &quot;read&quot; and a &quot;write&quot; option, so you program your dev AVR normally, then use an AtTiny to suck the data off, then push it up to one of the others. This is left as an exercise to the reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you would just need access to the 6 pins - VCC(power), GND(ground), RST(reset), SCK(clock), MISO(master-&gt;slave) and MOSI (slave-&gt;master). Note that the RST pin has to go high/low at specific times during the programming, so if programming from another AVR, it will need to be a data pin.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-02T00:57:05.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8371" PostTypeId="1" AcceptedAnswerId="8373" CreationDate="2015-02-02T01:24:21.823" Score="0" ViewCount="1977" Body="&lt;p&gt;With a very simple connection of an LED (which can withstand 5V) to ground and to a pin on my Galileo gen2, I can never output a non-zero voltage from the pin via &lt;code&gt;analogWrite&lt;/code&gt;, regardless of whether the pin is digital or analog (although PWM digital works)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LED is in the correct bias and I'm calling &lt;code&gt;pinMode(pin, OUTPUT)&lt;/code&gt; before attempting to call &lt;code&gt;analogWrite(pin, 255)&lt;/code&gt; (or any 2nd parameter in-between), even though it's not even necessary.&lt;br&gt;&#xA;The LED glows if I call &lt;code&gt;digitalWrite(pin, HIGH)&lt;/code&gt; on both analog and digital pins, but does not glow at all for &lt;code&gt;analogWrite(pin, 255)&lt;/code&gt; with the same configuration and pins, nor does it for any 2nd param in [0, 255]. This holds for whether the call is attempted in &lt;code&gt;loop()&lt;/code&gt; or &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible way I can get the LED to receive any power from &lt;code&gt;analogWrite&lt;/code&gt; is through a digital PWM pin, but I know the other digital pins can still produce square-waves with timers and the analog pins should certainly be able to use PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(So far, I've been to scared of short-circuits to connect the analogWrite output straight into an analog input to read the voltage)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I don't understand about the underlying board, or am I experiencing some strange malfunction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;br&gt;&#xA;Tyson&lt;/p&gt;&#xA;" OwnerUserId="6900" LastActivityDate="2020-09-23T03:07:19.560" Title="analogWrite never outputs a non-zero voltage" Tags="|led|pwm|analogwrite|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8372" PostTypeId="2" ParentId="8371" CreationDate="2015-02-02T01:44:50.613" Score="0" Body="&lt;p&gt;I don't believe Galileo has a D/A converter, which is what it sounds like you're expecting. In the Arduino 'eco-system', analogWrite() sets a PWM duty cycle - that's kinda-sorta somewhat like an analog output, but not really. You could add external circuitry to low-pass filter the PWM and produce some sort of proportional DC but it might be a good trick get it clean enough for whatever you plan to put downstream.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-02-02T01:44:50.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8373" PostTypeId="2" ParentId="8371" CreationDate="2015-02-02T02:09:22.453" Score="1" Body="&lt;p&gt;On most boards, the standard implementation of Arduino's &lt;code&gt;analogWrite()&lt;/code&gt; will only ever produce PWM, and only on a specific set of (digital) pins. These are usually pins 3, 5, 6, 9, 10, and 11, although it's slightly different on some boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only official board which has 'true' analog output is the Due (pins DAC0 and DAC1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want any other behaviour (such as outputting PWM on non-standard pins), you'll either need to modify the Arduino implementation, or directly manipulate the microcontroller's special registers. Note though that modifying the chip's configuration could cause other standard Arduino functions not to work as expected.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-02T02:09:22.453" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8374" PostTypeId="1" CreationDate="2015-02-02T04:30:50.760" Score="1" ViewCount="609" Body="&lt;p&gt;I'm trying to send a large packet to an Arduino with an ethernet shield on it. I'm using the built-in RX buffer of the W5100 controller to store the data, but I need more memory (at least 16K of buffer space, the W5100 only has 8K of RX buffer space). I have control over the server side of things as I'm writing the server process myself, so I can take solutions on that side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some hack I can use in the TCP protocol to have the packet broken up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I'm using the SFML 2.1 network API on the server side.&lt;/p&gt;&#xA;" OwnerUserId="4883" LastEditorUserId="4628" LastEditDate="2016-12-22T16:21:58.343" LastActivityDate="2016-12-22T16:21:58.343" Title="How can I analyse large packets on an Arduino?" Tags="|ethernet|memory-usage|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8375" PostTypeId="1" AcceptedAnswerId="8376" CreationDate="2015-02-02T05:38:41.513" Score="0" ViewCount="3124" Body="&lt;p&gt;I wired my switch just like in the default button program. I know it works because it works fine on other pins, just not pin 18 or 19. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 18;     // the number of the pushbutton pin&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);     &#xA;}&#xA;&#xA;void loop(){&#xA;  // read the state of the pushbutton value:&#xA;  buttonState = digitalRead(buttonPin);&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (buttonState == HIGH) {     &#xA;    // turn LED on:    &#xA;    digitalWrite(ledPin, HIGH);  &#xA;  } &#xA;  else {&#xA;    // turn LED off:&#xA;    digitalWrite(ledPin, LOW); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4830" LastActivityDate="2015-02-05T01:30:29.113" Title="Why are pin 18 and 19 always HIGH?" Tags="|arduino-uno|button|digital|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8376" PostTypeId="2" ParentId="8375" CreationDate="2015-02-02T06:00:02.747" Score="6" Body="&lt;p&gt;The analog pins function as digital pins number 14 - 19, with 14 being A0 and 19 being A5. I had hooked it up backwards. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This time we're gonna get funky&#xA;Everybody check your pins&#xA;Check check check check your pins&#xA;Check check check check your pins&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zeUmI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4830" LastEditorUserId="4830" LastEditDate="2015-02-05T01:30:29.113" LastActivityDate="2015-02-05T01:30:29.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8379" PostTypeId="1" CreationDate="2015-02-02T12:50:00.273" Score="0" ViewCount="669" Body="&lt;p&gt;I am trying to build a robot, which needs motors to roll around. So I was trying to control two DC motors with H-Bridge that comes with Arduino StarterKit(H-bridge motor driver [L293D]). I used Sketch that looks something like that &lt;img src=&quot;https://i.stack.imgur.com/Jh66v.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did read that Arduino needs separate powering, but i did not use any only USB connection. I connected 5V that comes from arduino to where + pin from battery should have been connected and motors were controlled and working.&#xA;However when i tried using 9V battery and connecting it as seen on above picture ,H-bridge did not control mototrs and nothing was working.&#xA;There is also another aspect - when robot was touching the surface then wheels did not move aka motors did not rotate and when you picked it up motors accelerated to quite some speed. Also when robot was on the surface and connected via USB, the PC made these USB connecting sounds repeatedly.&#xA;I am not sure when RX and TX stopped working. Power LED and L13 LED do work correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Is it Fixable?&lt;/p&gt;&#xA;" OwnerUserId="7089" LastActivityDate="2015-10-31T16:42:13.110" Title="Arduino UNO does not get recognized by PC(no USB connecting sound), also TX and RX not blinking, neither are lit" Tags="|arduino-uno|programming|uploading|usb|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8380" PostTypeId="2" ParentId="8343" CreationDate="2015-02-02T13:03:51.060" Score="0" Body="&lt;p&gt;I solved this by using an empty Uno-Board as a 'bridge' between the PC and the Bareduino (empty means with no controller chip). Just connect this guy via USB to the PC and then connect RX/TX, Ground, and Reset to your Bareduino. Just works fine for me.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-02-02T13:03:51.060" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8381" PostTypeId="2" ParentId="8379" CreationDate="2015-02-02T14:01:04.913" Score="1" Body="&lt;p&gt;You should definitely avoid connecting anything else than 5v to these 5v(!) PINs. The Uno has regulators, but these only work when powered through the power-dc-connector (or USB). You can easily buy a 9v-block to dc-jack cable to connect power to the right point easily.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-02-02T14:01:04.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8382" PostTypeId="1" CreationDate="2015-02-02T15:15:27.250" Score="2" ViewCount="1586" Body="&lt;p&gt;What is the most accurate proximity sensor for a ping pong ball? I will be using this to calculate 3D positioning of a ping pong ball in flight. I only need to detect the ball within 0-5 feet (basically on one side of ping pong table). &lt;/p&gt;&#xA;" OwnerUserId="6509" LastEditorUserId="6509" LastEditDate="2015-02-02T15:20:48.667" LastActivityDate="2016-11-12T20:30:21.553" Title="What is the most accurate sensor for detecting ping pong ball?" Tags="|sensors|proximity|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8383" PostTypeId="1" CreationDate="2015-02-02T15:57:15.917" Score="3" ViewCount="3336" Body="&lt;p&gt;I'm have a &lt;a href=&quot;http://spellfoundry.com/products/sleepy-pi/&quot; rel=&quot;nofollow&quot;&gt;Sleepy Pi&lt;/a&gt; and am having extreme difficulties trying to program a wake/sleep cycle. Sleepy Pi is an Arduino board with a RTC. My ultimate goal is for a time-lapse project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the Raspberry Pi programmed and operational to take a picture on boot, my trouble is coming from trying to program the Arduino board to actually do it's job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the Sleepy Pi to wake at 8am, 9am, 10am, ..., 3pm, 4pm, and 5pm, each for 5 minutes, then go back to sleep. I've been working with the &lt;a href=&quot;https://github.com/SpellFoundry/SleepyPi&quot; rel=&quot;nofollow&quot;&gt;SleepyPi&lt;/a&gt;, &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_Time.html&quot; rel=&quot;nofollow&quot;&gt;Time&lt;/a&gt;, &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_TimeAlarms.html&quot; rel=&quot;nofollow&quot;&gt;TimeAlarms&lt;/a&gt;, &lt;a href=&quot;https://github.com/rocketscream/Low-Power&quot; rel=&quot;nofollow&quot;&gt;LowPower&lt;/a&gt;, and &lt;a href=&quot;https://github.com/SpellFoundry/DS1374RTC&quot; rel=&quot;nofollow&quot;&gt;DS1374RTC&lt;/a&gt; libraries in the Arduino IDE. However, I cannot find any examples on how to put everything to sleep until a specific time comes around. Also, in several of my tests, it seems that the clock actually stops when the Sleepy Pi is asleep!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I've been working with (and this is non-working). It's probably completely wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SleepyPi.h&quot;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;TimeAlarms.h&amp;gt;&#xA;#include &amp;lt;LowPower.h&amp;gt;&#xA;#include &amp;lt;DS1374RTC.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;// Set the status LED pin constant&#xA;const int LED_PIN = 13;&#xA;&#xA;void setup()&#xA;{&#xA;  // Configure &quot;Standard&quot; LED pin&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;  digitalWrite(LED_PIN,LOW); // Switch off LED&#xA;&#xA;  // Start with the Pi off&#xA;  SleepyPi.enablePiPower(false);&#xA;&#xA;  // Set our communication rate&#xA;  Serial.begin(9600);&#xA;&#xA;  // Set up our boot times&#xA;  Alarm.alarmRepeat(8,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(9,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(10,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(11,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(12,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(13,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(14,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(15,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(16,0,0, startPiUp);&#xA;  Alarm.alarmRepeat(17,0,0, startPiUp);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Tick the alarm clock every second&#xA;  SleepyPi.enableWakeupAlarm();&#xA;  Alarm.delay(1000);&#xA;&#xA;  // Cut Power if we detect Pi not running&#xA;  bool pi_running;&#xA;  pi_running = SleepyPi.checkPiStatus(true);&#xA;  if(pi_running == false){&#xA;    SleepyPi.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);&#xA;  }&#xA;&#xA;  // Flash the LED&#xA;  digitalWrite(LED_PIN,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LED_PIN,LOW);&#xA;}&#xA;&#xA;// Function to tell the Pi to boot up&#xA;void startPiUp()&#xA;{&#xA;  // Turn the Pi on&#xA;  SleepyPi.enablePiPower(true);&#xA;&#xA;  // Turn on the LED to signal we're here&#xA;  digitalWrite(LED_PIN,HIGH);&#xA;&#xA;  // Keep the Pi on for 5 minutes&#xA;  delay(300000);&#xA;&#xA;  // Start a shutdown&#xA;  digitalWrite(LED_PIN,LOW);&#xA;  SleepyPi.piShutdown(true);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also cannot find a good way to &quot;debug&quot; things. I've been trying to use the LED flashes as a &quot;I'm here&quot; echo, but have been unsuccessful with this as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I do not have enough reputation on this site yet to create new tags. Someone with over 150, please tag this with &lt;a href=&quot;/questions/tagged/raspberry-pi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'raspberry-pi'&quot; rel=&quot;tag&quot;&gt;raspberry-pi&lt;/a&gt; and &lt;a href=&quot;/questions/tagged/sleepy-pi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged 'sleepy-pi'&quot; rel=&quot;tag&quot;&gt;sleepy-pi&lt;/a&gt;. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="7094" LastEditorUserId="42" LastEditDate="2015-02-02T16:06:44.043" LastActivityDate="2016-01-27T12:41:02.347" Title="Waking Raspberry Pi on time schedule using Sleepy Pi" Tags="|programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8384" PostTypeId="1" CreationDate="2015-02-02T17:26:40.137" Score="2" ViewCount="82" Body="&lt;p&gt;I am new to all of this so anything is helpful. &lt;/p&gt;&#xA;" OwnerUserId="7092" LastActivityDate="2015-02-02T17:26:40.137" Title="Where can I find beginner tutorials for the Arduino?" Tags="|programming|" AnswerCount="0" CommentCount="2" ClosedDate="2015-02-02T17:29:16.913" ContentLicense="CC BY-SA 3.0" />
  <row Id="8385" PostTypeId="2" ParentId="8356" CreationDate="2015-02-02T17:48:19.873" Score="0" Body="&lt;p&gt;You might look at getting a solder stencil.  It is still hand soldering, but significantly faster than doing it completely by hand.  Another option would be a pick and place machine; there would be a significant upfront cost but it would be more automatic.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-02T17:48:19.873" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8387" PostTypeId="2" ParentId="8343" CreationDate="2015-02-02T17:57:59.343" Score="1" Body="&lt;p&gt;I would upload a blink sketch using the method Stephan suggested then plug it back into your breadboard.  If it runs the blink sketch then the problem is in your programming method, but  it is more likely there is something wrong in the setup.  Problems could be using the wrong crystal for your setup, mis-wired or loose connection, or having your chip turned around (happens more often than you think).  If it does run I would make sure that you are using all USB-to-Serial converter with all the wires used and having a resister on the reset pin.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-02T17:57:59.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8388" PostTypeId="2" ParentId="8357" CreationDate="2015-02-02T19:13:40.513" Score="0" Body="&lt;p&gt;The signals that you mention are of different nature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) The PWM signal is a digital signal (output voltage is either ground or supply) that is modulated in time. It has a fixed period and its duty cycle varies from 0% (always ground) for value 0, to 100% (always supply) for value 255, the middle value being a signal that switches between ground and supply with 50% of its period at ground and 50% of its period at supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) A servo is controlled by a signal that has a fixed period of 20 ms and a pulse of varying duration (between 0.5 to 2.5 ms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) A tone for a buzzer has a variable period (or variable frequency - both being linked by the equation frequency * period = 1). The period is audible if is is between 0.06 ms (15 kHz) and 60 ms (15 Hz) (the exact value change from person to person. If the frequency is higher than 15 kHz, you are entering ultra-sonic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All three signals are digital in their voltage and modulated in time. But the modulation is very different as indicated above and the Arduino driver is therefore different for each one.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-02T19:13:40.513" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8390" PostTypeId="1" AcceptedAnswerId="8391" CreationDate="2015-02-02T22:24:15.883" Score="1" ViewCount="2430" Body="&lt;p&gt;I bought one of &lt;a href=&quot;http://www.ebay.com/itm/171505106187?_trksid=p2059210.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow noreferrer&quot;&gt;these&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/04v2jm.jpg&quot; alt=&quot;1Pcs New Sound Detection Sensor Module Voice Sensor for Arduino Best&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 3 pins on it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5V&lt;/li&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;li&gt;OUT&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My guess is that OUT is an analogue signal that I can measure with my Arduino, am I right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the &quot;Analogue Output&quot; example code but I just get 5V all the time, it does not seems to change with the sound levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong? What am I adjusting with the blue square on the board? Should I maybe do that?&lt;/p&gt;&#xA;" OwnerUserId="4912" LastEditorUserId="7113" LastEditDate="2015-02-03T21:59:31.617" LastActivityDate="2015-02-03T21:59:31.617" Title="How do I use this sound sensor?" Tags="|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8391" PostTypeId="2" ParentId="8390" CreationDate="2015-02-02T23:23:41.800" Score="3" Body="&lt;p&gt;The wording on this particular eBay item is pretty poor but there are plenty of similar products with better descriptions that are photographically identical... &lt;a href=&quot;http://www.ebay.co.uk/itm/1x-Sound-Sensor-Detection-Module-LM393-Electret-Microphone-for-Arduino-/231034416834&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt; that make a little bit more sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I don't think this gives an analog value output, the LM393 is a comparator, so I think the blue dial sets the 'threshold level' and any sounds over that level cause a logic low. i.e. it compares the audio level and the dial and when one exceeds the other it gives a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The features also say &quot;The output effective signal is low level&quot; which is probably Chinglish for the signal is a logic low, i.e. when the sound is heard it goes to 0V rather than 5V which is what I think you were expecting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary: This device is is more like a Clapper, it detects a loud noise and sends a digital low signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try making a loud noise with the same setup you already have, and if not try adjusting the potentiometer by turning it, but not too far! It probably only turns 180-270º.&lt;/p&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-02-02T23:23:41.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8392" PostTypeId="2" ParentId="6832" CreationDate="2015-02-02T23:37:56.060" Score="0" Body="&lt;p&gt;On ebay you can buy 2nd hand Nokia SD cards from old mobile phones which are 128MB or so and very cheap.&lt;/p&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-02-02T23:37:56.060" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8393" PostTypeId="2" ParentId="5234" CreationDate="2015-02-02T23:39:42.590" Score="1" Body="&lt;p&gt;Is the Arduino running at all when on battery?  You could be trying to pull too much current from the battery and killing the circuit.  Another cause is that some programmers pull the reset pin to low when unplugged; took me a while to figure out that one.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-02T23:39:42.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8394" PostTypeId="2" ParentId="6835" CreationDate="2015-02-03T00:00:01.687" Score="1" Body="&lt;p&gt;I have used these &lt;strong&gt;&lt;em&gt;exact&lt;/em&gt; two shields&lt;/strong&gt; myself and can confirm they definitely work together. I can find my datalogger code to confirm if desired.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2015-02-03T00:00:01.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8395" PostTypeId="2" ParentId="8379" CreationDate="2015-02-03T00:04:39.847" Score="1" Body="&lt;p&gt;The &quot;5V&quot; pin takes only regulated 5V input.  Your schematic shows the the board powered here, and you mention 9V battery.  That's not a good idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have 7V-12V, then you can supply the board via the &quot;Vin&quot; pin.  It passes through the same regulation circuits that the DC jack does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardUno&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2015-02-03T00:04:39.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8396" PostTypeId="2" ParentId="4027" CreationDate="2015-02-03T06:40:18.610" Score="2" Body="&lt;p&gt;Your question doesn't specify speed, cost, accuracy, or size, and it skimps on electrical and physical details (referring merely to 50–100 resistors and “a lot of cables”) so perhaps can't be properly answered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ADC's (analog-digital converters) typically are high-impedance devices that measure voltages.  A resistor may be measured in many ways, a few of which are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Place a known voltage across it; measure current through it&lt;/li&gt;&#xA;&lt;li&gt;Drive a known current through it; measure voltage across it&lt;/li&gt;&#xA;&lt;li&gt;Drive some current through it; measure both voltage and current using &lt;a href=&quot;https://en.wikipedia.org/wiki/Four-terminal_sensing&quot; rel=&quot;nofollow noreferrer&quot;&gt;four-terminal sensing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Measure how long it takes a given capacitor to charge to a trip point, using a known voltage through the resistor under test&lt;/li&gt;&#xA;&lt;li&gt;Use known resistances to null a &lt;a href=&quot;https://en.wikipedia.org/wiki/Kelvin_bridge&quot; rel=&quot;nofollow noreferrer&quot;&gt;Kelvin bridge&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For some of the techniques listed above, measurement accuracy is little affected by multiplexer resistance; others might need to use a low-resistance MUX made with relays instead of a MUX ic like the &lt;a href=&quot;http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-analog-multiplexerdemultiplexer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC4067&lt;/a&gt;.  Some of the techniques are suitable for wide ranges of resistance, others not; and some for high accuracy, others not.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Suggested Approach&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Anyhow, those comments aside, circuits like the following might do the job.  If you have eight analog inputs on your Arduino, you could use up to eight multiplexers to measure up to 128 resistors.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HagJE.jpg&quot; alt=&quot;resistor mux pdf&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Figures 1 and 2 above, &lt;strong&gt;Rx&lt;/strong&gt; is a typical unknown resistance, and &lt;strong&gt;Rs&lt;/strong&gt; is a known standard resistor.  Both figures represent &lt;em&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;voltage divider&lt;/a&gt;&lt;/em&gt; circuits.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Effect of multiplexer transmission gate resistance&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let &lt;strong&gt;Rm&lt;/strong&gt; denote multiplexer transmission gate resistance.  &lt;strong&gt;Rm&lt;/strong&gt; is unimportant if the circuit of Figure 1 is used because &lt;strong&gt;Rm&lt;/strong&gt; is tiny compared to the input impedance of a unity-gain follower op amp stage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Rm&lt;/strong&gt; might or might not be important if the circuit of Figure 2 is used. (a) If &lt;strong&gt;Rm&lt;/strong&gt; differs somewhat from one multiplexer channel to another, Figure 2 may be unsuitable because calibration will be cumbersome.  (b) If &lt;strong&gt;Rm&lt;/strong&gt; is comparable to &lt;strong&gt;Rx&lt;/strong&gt;, Figure 2 is unlikely to produce high-accuracy results.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Whether unity-gain followers are necessary&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Whether you need unity-gain followers depends mostly on the size of resistors you are measuring.  Arduino analog inputs are high-impedance (10⁸Ω, but with about 14pF capacitance to &lt;strong&gt;Vcc&lt;/strong&gt;/2).  Atmel suggests analog source impedances of 10KΩ or less for best results.  [See (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=65134.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;https://electronics.stackexchange.com/questions/67171/input-impedance-of-arduino-uno-analog-pins&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;https://electronics.stackexchange.com/questions/36394/arduino-analog-input-example-clarification&quot;&gt;3&lt;/a&gt;) for additional discussion.]  Briefly:  If &lt;strong&gt;Rs&lt;/strong&gt;+&lt;strong&gt;Rx&lt;/strong&gt; is likely to exceed 20-40KΩ and you wish to measure quickly, use unity-gain followers. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Resistance Formulas&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let &lt;strong&gt;Vt&lt;/strong&gt; be the voltage at the lower end of &lt;strong&gt;Rs&lt;/strong&gt; in either figure.  &lt;strong&gt;Vt&lt;/strong&gt; is the voltage that will be measured at an analog input Aj.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Figure 1, because &lt;strong&gt;Vt = Vcc·Rx/(Rx+Rs)&lt;/strong&gt;, we have &lt;strong&gt;Rx&lt;/strong&gt; = &lt;strong&gt;Vt·Rs/(Vcc-Vt)&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the circuit in Figure 2, an additional resistance &lt;strong&gt;Rm&lt;/strong&gt; is in series with &lt;strong&gt;Rx&lt;/strong&gt;, so &lt;strong&gt;Vt = Vcc·(Rx+Rm)/(Rx+Rm+Rs)&lt;/strong&gt;, whence &lt;strong&gt;Rx = Vt·Rs/(Vcc-Vt)-Rm&lt;/strong&gt;.  If &lt;strong&gt;Rs&lt;/strong&gt; and &lt;strong&gt;Rx&lt;/strong&gt; are large (eg 40KΩ and 10KΩ) then ignoring &lt;strong&gt;Rm&lt;/strong&gt; may cause only a fraction of a percent of error.  But if &lt;strong&gt;Rm&lt;/strong&gt; is comparable to either of &lt;strong&gt;Rs&lt;/strong&gt; or &lt;strong&gt;Rx&lt;/strong&gt;, either use the circuit of Figure 1 or devote some inputs of each multiplexer to use as calibration inputs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Analog input reference voltage&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If &lt;strong&gt;Vcc&lt;/strong&gt; is 5 V and we choose &lt;strong&gt;Rs&lt;/strong&gt; four times as large as the largest resistance value that you intend to measure, then &lt;strong&gt;Vt&lt;/strong&gt; will be between 0 and 1 V.  You can use an &lt;a href=&quot;http://arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;analogReference()&lt;/code&gt;&lt;/a&gt; call like &lt;code&gt;analogReference(INTERNAL)&lt;/code&gt; [or &lt;code&gt;analogReference(INTERNAL1V1)&lt;/code&gt; on a Mega] to set the analog reference voltage at 1.1 V, to maximize accuracy of measurement and to minimize the amount of current required through &lt;strong&gt;Rx&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Advantages of Figure 2&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unless &lt;strong&gt;Rm&lt;/strong&gt; is a problem (as discussed above) the following advantages of Figure 2 suggest its use: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lower power requirements:  In Figure 1, all the resistors under test always have current going through them.  In Figure 2, only 1/16 of the resistors are powered at any given time.  Also, by raising \EN to shut down the 4067's (or 74HC4067's if used) all the resistors can be powered off.&lt;/li&gt;&#xA;&lt;li&gt;Less wiring and fewer parts:  At most eight &lt;strong&gt;Rs&lt;/strong&gt; parts are needed, rather than one &lt;strong&gt;Rs&lt;/strong&gt; per &lt;strong&gt;Rx&lt;/strong&gt;.  Each &lt;strong&gt;Rx&lt;/strong&gt; connects to ground and to one mux input, rather than to ground and to the junction of a mux input with an &lt;strong&gt;Rs&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Cable Note&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For either figure, seven or eight wires run from the Arduino to each 4067 subcircuit.  One wire from each subcircuit carries Vt back to an analog input.  The other wires connect to all subcircuits in parallel: four channel select lines (A, B, C, D in figures, or S0-S4 in datasheets); Vcc; ground; and \EN unless that line is wired to ground.  Each 4067 subcircuit should have a bypass capacitor, eg 10-100 nF, from Vcc to ground.  Boards like the “Geeetech CD74HC4067 Analog Digital MUX Breakout Board” shown below (about $5 on ebay) might be used, or you could design a custom board and have it made at &lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OSHPark&lt;/a&gt; or &lt;a href=&quot;http://www.seeedstudio.com/service/index.php?r=pcb&quot; rel=&quot;nofollow noreferrer&quot;&gt;Seeedstudio&lt;/a&gt;.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7F9en.jpg&quot; alt=&quot;Geeetech CD74HC4067 Analog Digital MUX Breakout Board&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-03T06:48:03.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8397" PostTypeId="1" AcceptedAnswerId="8400" CreationDate="2015-02-03T10:32:12.877" Score="5" ViewCount="7686" Body="&lt;p&gt;I recently read this piece of code and I dont know what is the use of &quot;&amp;lt;&amp;lt;=&quot; in the for loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (mask = 0x01; mask&amp;gt;0; mask &amp;lt;&amp;lt;= 1) {&#xA;    if (data &amp;amp; mask){ // choose bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the entire code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Created August 23 2006&#xA;//Heather Dewey-Hagborg&#xA;//http://www.arduino.cc&#xA;&#xA;#include &amp;lt;ctype.h&amp;gt;&#xA;&#xA;#define bit9600Delay 100  &#xA;#define halfBit9600Delay 500&#xA;#define bit4800Delay 188 &#xA;#define halfBit4800Delay 94 &#xA;&#xA;byte rx = 6;&#xA;byte tx = 7;&#xA;byte SWval;&#xA;&#xA;void setup() {&#xA;  pinMode(rx,INPUT);&#xA;  pinMode(tx,OUTPUT);&#xA;  digitalWrite(tx,HIGH);&#xA;  delay(2);&#xA;  digitalWrite(13,HIGH); //turn on debugging LED&#xA;  SWprint('h');  //debugging hello&#xA;  SWprint('i');&#xA;  SWprint(10); //carriage return&#xA;}&#xA;&#xA;void SWprint(int data)&#xA;{&#xA;  byte mask;&#xA;  //startbit&#xA;  digitalWrite(tx,LOW);&#xA;  delayMicroseconds(bit9600Delay);&#xA;  for (mask = 0x01; mask&amp;gt;0; mask &amp;lt;&amp;lt;= 1) {&#xA;    if (data &amp;amp; mask){ // choose bit&#xA;     digitalWrite(tx,HIGH); // send 1&#xA;    }&#xA;    else{&#xA;     digitalWrite(tx,LOW); // send 0&#xA;    }&#xA;    delayMicroseconds(bit9600Delay);&#xA;  }&#xA;  //stop bit&#xA;  digitalWrite(tx, HIGH);&#xA;  delayMicroseconds(bit9600Delay);&#xA;}&#xA;&#xA;int SWread()&#xA;{&#xA;  byte val = 0;&#xA;  while (digitalRead(rx));&#xA;  //wait for start bit&#xA;  if (digitalRead(rx) == LOW) {&#xA;    delayMicroseconds(halfBit9600Delay);&#xA;    for (int offset = 0; offset &amp;lt; 8; offset++) {&#xA;     delayMicroseconds(bit9600Delay);&#xA;     val |= digitalRead(rx) &amp;lt;&amp;lt; offset;&#xA;    }&#xA;    //wait for stop bit + extra&#xA;    delayMicroseconds(bit9600Delay); &#xA;    delayMicroseconds(bit9600Delay);&#xA;    return val;&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    SWval = SWread(); &#xA;    SWprint(toupper(SWval));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="42" LastEditDate="2015-02-03T10:49:59.237" LastActivityDate="2015-02-03T12:07:48.853" Title="what is the use of &quot;&lt;&lt;=&quot; operator?" Tags="|serial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8398" PostTypeId="2" ParentId="8397" CreationDate="2015-02-03T11:05:27.413" Score="4" Body="&lt;p&gt;&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is the left bit-shift operator. That means it takes the binary contents of a number and moves everything left by a certain number of binary places (1 place in this case). &lt;code&gt;&amp;lt;&amp;lt;=&lt;/code&gt; simply combines the left bit-shift with an assignment, so it takes the current value of &lt;code&gt;mask&lt;/code&gt;, shifts it left, and then stores the result back in &lt;code&gt;mask&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this situation, the &lt;code&gt;mask&lt;/code&gt; variable starts with a value of &lt;code&gt;1&lt;/code&gt;. The second time round the loop, it will be &lt;code&gt;10&lt;/code&gt; (binary). Next time, it will be &lt;code&gt;100&lt;/code&gt;, and so on. Since &lt;code&gt;mask&lt;/code&gt; is a byte (which is 8 bits), it will go all the way up to &lt;code&gt;10000000&lt;/code&gt; and then stop. After that, the 1 effectively falls-off the left and &lt;code&gt;mask&lt;/code&gt; ends up with a value of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of this in the code you provided is to test each individual bit within the &lt;code&gt;data&lt;/code&gt; parameter. It basically goes through from least- to most-significant and checks if each bit is 1 or 0. It will then pull an output pin HIGH or LOW (respectively) to match. This allows it to send the contents of the variable digitally to some other device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing low-level binary (aka bit-wise) operations like this is very common in microcontroller programming. If you're not familiar with it then I'd definitely recommend looking up some tutorials online. It opens up a huge range of new possibilities for your projects.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-02-03T12:07:48.853" LastActivityDate="2015-02-03T12:07:48.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8399" PostTypeId="2" ParentId="8397" CreationDate="2015-02-03T11:30:42.863" Score="7" Body="&lt;p&gt;In simpler terms &lt;code&gt;mask &amp;lt;&amp;lt;= 1&lt;/code&gt; is shorthand for &lt;code&gt;mask = mask &amp;lt;&amp;lt; 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable operator= operand&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the augmented assignment operator which means &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;variable = variable operator operand &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-03T11:30:42.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8400" PostTypeId="2" ParentId="8397" CreationDate="2015-02-03T12:01:19.090" Score="4" Body="&lt;p&gt;As stated in the other answers, the &lt;code&gt;&amp;lt;&amp;lt;=&lt;/code&gt; operator shifts the byte to the left; however, the number '1'  after it specifies how far to shift it - so, &lt;code&gt;2 &amp;lt;&amp;lt;= 2&lt;/code&gt; == 8.&#xA;Possibly clearer in binary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00000001 &amp;lt;&amp;lt;= 1&lt;/code&gt; == &lt;code&gt;00000010&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00000010 &amp;lt;&amp;lt;= 1&lt;/code&gt; == &lt;code&gt;00000100&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00000001 &amp;lt;&amp;lt;= 2&lt;/code&gt; == &lt;code&gt;00000100&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-02-03T12:01:19.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8401" PostTypeId="1" CreationDate="2015-02-03T14:30:07.470" Score="1" ViewCount="262" Body="&lt;p&gt;I want to power xbee s2 module through atmel 328p digital output pin. And I am powering atmel 328p IC using 3.7 li-ion cell 5500 mAh. In sleep mode atmel consume current in micro Amp but xbee consuming around 40 mA. I want to reduce it. I tried xbee in power down mode but its not working for me. Is der any way to switch xbee automatically with as atmel sleep &amp;amp; wake-up. Circuit works properly when I power xbee through 3.7 v li-ion cell but consume power continuously.&lt;/p&gt;&#xA;" OwnerUserId="6674" LastActivityDate="2015-08-04T05:44:37.267" Title="Xbee power issue" Tags="|power|xbee|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8402" PostTypeId="2" ParentId="8291" CreationDate="2015-02-03T15:59:28.957" Score="0" Body="&lt;p&gt;Have you removed the &quot;Serial Data Mode&quot; shunt to put the device in &quot;Pulse Width Mode&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, perhaps the &quot;Serial Data Mode&quot; would actually work better for your application?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I work, we have a coding style that strongly encourages&#xA;all &quot;magic numbers&quot; to be documented&#xA;with a link to the website it came from&#xA;or a reference to the book and page it came from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would something like this work for you?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;    // Trigger US-100 to start measurement&#xA;    // at least 50 us high, then set it low,&#xA;    // as recommended by&#xA;    // https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module&#xA;    digitalWrite(trigger,HIGH);&#xA;    delayMicroseconds(50);&#xA;    digitalWrite(trigger,LOW);&#xA;    // Acquire&#xA;    unsigned long echo_microseconds = pulseIn(echo,HIGH);&#xA;    // debugging&#xA;    serial.println( echo_microseconds );&#xA;    Serial.println(F(&quot; microseconds&quot;));&#xA;    // conversion factor from&#xA;    // https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module&#xA;    unsigned long distance_mm = echo_microseconds * 34 / 100 / 2;&#xA;    Serial.print(distance_mm);&#xA;    Serial.println(F(&quot; mm&quot;));&#xA;    delay(50);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might be easier to use the Ping library as described at&#xA;&lt;a href=&quot;http://arduino-info.wikispaces.com/UltraSonicDistance&quot; rel=&quot;nofollow&quot;&gt;Arduino-Info: UltraSonic Distance Measurement&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find the&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=130925.0&quot; rel=&quot;nofollow&quot;&gt;Arduino Forum: Measuring Distances with Ultrasonic Sensors&lt;/a&gt;&#xA;thread educational.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-02-03T15:59:28.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8403" PostTypeId="2" ParentId="8348" CreationDate="2015-02-03T16:00:43.337" Score="2" Body="&lt;p&gt;You need to adapt the levels. Arduino Due operates on 0 - 3.3 V. Apple IIe is either on 0 - 5 V or +/- 12 V (depends which port you are using). There are standard ICs to do the level adaptation.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-03T16:00:43.337" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8404" PostTypeId="2" ParentId="8401" CreationDate="2015-02-03T17:46:50.683" Score="1" Body="&lt;p&gt;The best solution would be to determine why your Xbee is not being switched into power down mode.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if you wish to turn the Xbee power off using the Arduino then there are many ways of doing this. One method is shown on the diagram below {&lt;a href=&quot;http://www.microchip.com/forums/m697820.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;from here&lt;/strong&gt;&lt;/a&gt;}. This requires two transistors and three resistors. Almost any small transistors would work. Good choices if buying new components would be BC337 / BC817 for T1 and BC327 / BC807 for T2. The first part number in each pair is a through hole part and the second number is the equivalent surface mount part. If buying these try to get the -40 suffix versions, although in this case any version would work OK.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit was drawn for use with a PIC processor controlling a 12V supply, but the Arduino works equally well controlling a 3.7V LiIon supply. The load is shown as a light bulb - that's where you'd connect the XBee. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ll7ah.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input low turns 1 off which turns T2 off. To enable/disable the XBee you have to raise / lower the input pin. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-03T17:46:50.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8405" PostTypeId="1" CreationDate="2015-02-03T19:19:59.157" Score="-1" ViewCount="1000" Body="&lt;p&gt;Without asking an open-ended question, i wish to find the best way (resourcefulness) to execute methods from an arduino based on time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in a nutshell, every 10 minutes i want functionA() to be called &amp;amp; every 30 minutes, functionB(). At this point i'm unable to specifiy whether a method would need to be called at a less frequent rate, however i wish to assume that one may. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My 2 ideas so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;encapsulate the functions a &amp;amp; b inside the NTP client, and execute based on the minutes in an hour&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;or&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use delay() or even the milli() counter with functions a &amp;amp; b below inside the loop.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My main worry of the 2nd option is that the arduino handles time keeping itself, in a long run (lets say 1 year), the arduino will end up with no memory left. Whats is the consensus with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Board wise, to be run on Uno &amp;amp; Mega.&lt;/p&gt;&#xA;" OwnerUserId="6318" LastActivityDate="2015-02-12T03:43:29.507" Title="Time based scheduling, NTP vs delay()" Tags="|arduino-uno|arduino-mega|millis|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8406" PostTypeId="1" CreationDate="2015-02-03T20:15:06.850" Score="4" ViewCount="24066" Body="&lt;p&gt;I'm trying to get students to experiment with Arduino. However, due to a lack of boards, two teams of students will collaborate on each board. They will push their own code (independent from each other) and use half the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;hardware&quot; part isn't really a concern: students will push their sketches on a server that uploads them on the board, or something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm worried about is the software part. &lt;strong&gt;How can I allow two sketches to run on the same board&lt;/strong&gt;, and &lt;strong&gt;allow the user to upload sketches without resetting the board&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As of my understanding, using the flash memory isn't an option, because the board must be reset before it can be written.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first idea was to compile the students' C code into custom-made &quot;assembly&quot;, and then push the assembly code to the board, which stores it into RAM and interprets it. However, my biggest problem would be implementing functions, I don't really have a clue of how I could do that. While common C functions could just be encoded in a fashion like &lt;code&gt;FUNC printf STRING %s VAR a&lt;/code&gt; for &lt;code&gt;printf(&quot;%s&quot;, a)&lt;/code&gt;, I don't know how to encode user-defined functions. Besides, I don't even think the RAM is sufficient for running the client, storing two small programs, and running them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I thought about running the C code on the computer, but replacing &lt;code&gt;digitalWrite&lt;/code&gt; with appropriate signals to the board. However, I'm worried about the performance of this, mostly when dealing with &quot;high&quot; speeds - say, using a custom-made library to print text on a LCD driver.&lt;/p&gt;&#xA;" OwnerUserId="3941" LastActivityDate="2016-12-09T16:12:01.027" Title="How can I run multiple programs on an Arduino?" Tags="|system-design|networking|" AnswerCount="5" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8407" PostTypeId="2" ParentId="8405" CreationDate="2015-02-03T20:31:48.147" Score="1" Body="&lt;p&gt;memory used by delay() and milli() (if any) will be recycled every time you call it, so it does not add up. You should be aware that milli rolls over (resets back to 0) after approximately 50 days - see &lt;a href=&quot;http://arduino.cc/en/Reference/Millis&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/Millis&lt;/a&gt; - you will need to keep track of how many times it has overflowed, and include that in your calculations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;delay will only be useful if you do NOTHING AT ALL during that time - if you want to do other stuff in that space, you should use milli(). Also, if you delay (without using milli()), your events will drift by the time it takes to run the code. delay() and milli() will also only be as accurate as the crystal on your arduino - it should be no more than 20 parts per million; this comes to 10 minutes per year. This may or may not be a problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NTP will use a lot more resources, and has to be polled. It is also potentially less reliable (i.e. NTP may be down for short periods).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need accurate timing, the best solution would be to use delay() to pass the time (approximately), milli() to keep the time, and adjust for drift with NTP.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-02-03T20:38:14.210" LastActivityDate="2015-02-03T20:38:14.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8408" PostTypeId="2" ParentId="8405" CreationDate="2015-02-03T20:43:53.090" Score="1" Body="&lt;p&gt;Connect a battery backed up Real-Time clock to your arduino and use that to keep track of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the same idea as NTP but minimal hardware is required and you can get an RTC with the long term accuracy you need.&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="337" LastEditDate="2015-02-11T15:43:25.373" LastActivityDate="2015-02-11T15:43:25.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8409" PostTypeId="2" ParentId="6782" CreationDate="2015-02-03T21:55:21.477" Score="-1" Body="&lt;p&gt;Change this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal_I2C lcd(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal_I2C lcd(0x26, 2, 1, 0, 4, 5, 6, 7, 8, POSITIVE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The argument before &quot;POSITIVE&quot; is changed from a 3 to an 8)&lt;/p&gt;&#xA;" OwnerUserId="7121" LastEditorUserId="220" LastEditDate="2015-02-03T23:49:49.410" LastActivityDate="2015-02-03T23:49:49.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8410" PostTypeId="2" ParentId="8406" CreationDate="2015-02-03T21:56:42.253" Score="0" Body="&lt;p&gt;There is a solution. It requires some programming discipline from your students, but it is feasible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Make sure each group uses different variable and function naming conventions (one starts all variable and functions with &lt;code&gt;a_&lt;/code&gt; and the other group with &lt;code&gt;b_&lt;/code&gt;). These functions will be written in separate include files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In the &lt;code&gt;setup()&lt;/code&gt; and in the &lt;code&gt;loop()&lt;/code&gt; functions, you will call either &lt;code&gt;a_setup()&lt;/code&gt; or &lt;code&gt;b_setup()&lt;/code&gt;, and either &lt;code&gt;a_loop()&lt;/code&gt; or &lt;code&gt;b_loop()&lt;/code&gt;. Each of the group setup and loop functions will call their functions and use their variables as the groups want to, but they are not allowed to call variables/functions from the other group. Other resources can also be allocated by you in advance for each team.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) During the &lt;code&gt;setup()&lt;/code&gt; function, start by reading a specific input that you will either connect to GND or to 5V. Use the result of this reading to execute either one version of the software, or the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not elegant, but it gets two program into each Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-03T21:56:42.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8411" PostTypeId="1" CreationDate="2015-02-03T22:16:52.823" Score="5" ViewCount="2189" Body="&lt;p&gt;I have the Arduino board connected to a USB port of my machine. But I cannot find it under /dev/ directory in my Ubuntu. Does anyone know how to deal with this issue? By the way, &quot;lsusb&quot;'s output proves that it has been recognized. Here is the output of this command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 002 Device 002: ID 8087:8000 Intel Corp. &#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 001 Device 002: ID 8087:8008 Intel Corp. &#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&#xA;Bus 003 Device 007: ID 413c:2105 Dell Computer Corp. Model L100 Keyboard&#xA;Bus 003 Device 013: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)&#xA;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the output of ls -l /dev/ttyACM*&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls: cannot access /dev/ttyACM*: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the dmesg output when disconnect and reconnect the device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[1653809.002715] usb 3-11: USB disconnect, device number 13&#xA;[1653832.188835] usb 3-11: new full-speed USB device number 14 using xhci_hcd&#xA;[1653832.211392] usb 3-11: New USB device found, idVendor=2341, idProduct=0043&#xA;[1653832.218400] usb 3-11: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[1653832.226003] usb 3-11: Manufacturer: Arduino (www.arduino.cc)&#xA;[1653832.231859] usb 3-11: SerialNumber: 85235353137351708191&#xA;[1653832.237468] usb 3-11: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6784" LastEditorUserId="6784" LastEditDate="2015-02-03T22:47:48.700" LastActivityDate="2016-06-29T05:03:02.290" Title="Cannot find Arduino under /dev Directory" Tags="|arduino-uno|ubuntu|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8412" PostTypeId="2" ParentId="8406" CreationDate="2015-02-03T22:52:13.270" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I allow two sketches to run on the same board, and allow the user to upload sketches without resetting the board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is &quot;easily&quot; dealt with as long as you can enforce certain minimum disciplines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Students must only use assigned pins.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Identifiers (functions, variables ...) defined by a group must always be unique to that group. This can be as simple as eg always starting with a group specific symbol or eg one group NEVER using a z in names and the other ALWAYS using Z etc. Annoying but easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Loop() contains calls to two non-terminating functions eg Group1() and Group2() &#xA;All code for Group1 is in Group1() and ....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One digital pin is assigned for Giulio's use.&lt;br&gt;&#xA;When GiuliosPin is low the system executes Group1() - and never exits it until restarted.&lt;br&gt;&#xA;When GiuliosPin is high the system executes Group2() - and never exits it until restarted.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uses a system very close to the Group1() / Group2() selection for my own purposes to allow multiple sketches to be compiled at once - but I use a constant which is set  as I compile to choose which to run. My concern is the ability to test multiple code fragments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Added:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading Mac's similar answer I see I missed mentioning Setup().&lt;br&gt;&#xA;Code from both users can be merged into the same Setup() as the identifiers are unique.&lt;br&gt;&#xA;Or the Setup() function for each Group can be carried out inside their unique Groupx() function with a &quot;run once&quot; function at the start of their code. This is a matter of programming discipline and not in any way hard per se. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-03T22:59:44.457" LastActivityDate="2015-02-03T22:59:44.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8414" PostTypeId="2" ParentId="8406" CreationDate="2015-02-04T00:15:19.677" Score="4" Body="&lt;p&gt;In addition to the other answers, I have a few ideas:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.) Instead of doing variable prefixes, have them wrap all of their code inside a namespace! Please note that you can't wrap &quot;setup&quot; or &quot;loop&quot; in that namespace. Example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup() {&#xA;  if(conditionIsTrue) {&#xA;    aGroup::setup();&#xA;  } else {&#xA;    bGroup::setup();    &#xA;  }&#xA;}&#xA;&#xA;loop() {&#xA;  if(conditionIsTrue) {&#xA;    aGroup::loop();&#xA;  } else {&#xA;    bGroup::loop();    &#xA;  }&#xA;}&#xA;&#xA;namespace aGroup {&#xA;setup() {&#xA;  // Code&#xA;}&#xA;&#xA;loop() {&#xA;  // Code&#xA;}&#xA;}&#xA;&#xA;namespace bGroup {&#xA;setup() {&#xA;  // Code&#xA;}&#xA;&#xA;loop() {&#xA;  // Code&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note you'll have issues with a student tries to access an analog pin and doesn't prefix it with &lt;code&gt;A&lt;/code&gt;. For example, if I wanted analog pin 5, I should do &lt;code&gt;analogRead(A5);&lt;/code&gt;, &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; &lt;code&gt;analogRead(5);&lt;/code&gt;. That could cause some major issues.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-02-04T00:15:19.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8415" PostTypeId="2" ParentId="4005" CreationDate="2015-02-04T00:32:04.747" Score="1" Body="&lt;p&gt;Such intermittent issue looks to me a hardware signal integrity problem, specifically around the I2C bus RTC chip. Did you experience any problem from any other device on the same I2C bus (e.g. when all the LEDs are on)? If not, then check on the noise level on RTC chip power and GND. Also, the I2C spec has limit on the bus capacitance load as max as 400 pF. When there are too many I2C device loads on the same bus, the bus may become vulnerable to the system noise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debug Suggestion: To narrow down if it is I2C load issue, add an I2C bus driver chip between the main Arduino board and your peripheral. For example, P82B96 from TI. See the spec here. &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/p82b96.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/lit/ds/symlink/p82b96.pdf&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="7120" LastActivityDate="2015-02-04T00:32:04.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8416" PostTypeId="2" ParentId="8406" CreationDate="2015-02-04T02:19:28.370" Score="2" Body="&lt;p&gt;There is no native multitasking on an Arduino. A few solutions have been suggested above, all of which depend on cooperative multitasking - each half has to play fair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative may be this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Buy some AtTiny chips - e.g. AtTiny 24a; they are about $2-3 each. Buy some VeroBoard. Solder the AtTiny on to the board, so each verboard strip has 2 pins on it (not the other way, where each veroboard strip has half of the pins on it). Solder on some pins, cut the track between the pairs of pins, and cut the board to size. You should be able to get a working board, with 12 usable pins per board, and you'll be paying less than $5 per board in your local currency. Buy a USBISP, and hook up the pins, whenever you need to program them - I suggest using the FreeTronics programmer, like this one here: &lt;a href=&quot;http://www.jaycar.com.au/productView.asp?ID=XC4237&quot; rel=&quot;nofollow&quot;&gt;http://www.jaycar.com.au/productView.asp?ID=XC4237&lt;/a&gt; - you can solder 2 pins for the &quot;slow clock&quot; option - you'll need this. Optionally, you could make an adapter board which plugs into all of the relevant pins in one go, to program it. You should only need one of these. To figure out which wires to connect where, compare the top diagram on &lt;a href=&quot;http://www.dz863.com/datasheet-8310956563-ATTINY24A-SSU_8-bit-Microcontroller-With-2k-4k-Bytes-In-system-Programmable-Flash/&quot; rel=&quot;nofollow&quot;&gt;http://www.dz863.com/datasheet-8310956563-ATTINY24A-SSU_8-bit-Microcontroller-With-2k-4k-Bytes-In-system-Programmable-Flash/&lt;/a&gt; with &lt;a href=&quot;https://www.olimex.com/Products/AVR/Programmers/AVR-ICSP/resources/AVR-ICSP.gif&quot; rel=&quot;nofollow&quot;&gt;https://www.olimex.com/Products/AVR/Programmers/AVR-ICSP/resources/AVR-ICSP.gif&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can power them with AA batteries or an external power supply - you could easily make one power supply that runs many boards. Check out the spec sheet for the voltage required - it varies, depending on the clock speed (default clock speed as described is 1&amp;nbsp;MHz, google &quot;avr fuses&quot; for how to set them to e.g. 8&amp;nbsp;MHz at no extra cost).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="7508" LastEditDate="2015-06-22T05:57:10.450" LastActivityDate="2015-06-22T05:57:10.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8417" PostTypeId="1" CreationDate="2015-02-04T02:28:19.927" Score="5" ViewCount="4897" Body="&lt;p&gt;I bought a SainSmart Arduino Mega 2560. I uploaded a small sketch to it, and it uploaded fine. When I upload a larger sketch though, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;verification error, first mismatch at byte 0x3895&#xA;         0xdf != 0x44&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So obviously there's nothing wrong with my bootloader because I can upload smaller files. Why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="7127" LastActivityDate="2017-08-16T21:03:42.557" Title="verification error, first mismatch at byte 0x3895 0xdf != 0x44?" Tags="|avrdude|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8419" PostTypeId="1" AcceptedAnswerId="8426" CreationDate="2015-02-04T06:53:23.777" Score="5" ViewCount="4417" Body="&lt;p&gt;I wanted to know if the reference voltage for the &lt;code&gt;digitalRead()&lt;/code&gt; function could be set to a particular voltage, either with an external reference or internally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino reference under the constants heading they have mentioned that they use 3V as reference for the boards I'm using (an Arduino Uno R3). But I want to change it to be a little lower. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible and if so how?&lt;/p&gt;&#xA;" OwnerUserId="7132" OwnerDisplayName="Suman Roy" LastEditorUserId="7132" LastEditDate="2015-02-04T09:22:40.073" LastActivityDate="2015-02-04T12:03:11.383" Title="Set Arduino digitalRead reference voltage" Tags="|arduino-uno|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8420" PostTypeId="1" CreationDate="2015-02-04T07:22:09.783" Score="1" ViewCount="3786" Body="&lt;p&gt;i would like to generate Chirp Signal (Frequency Sweep) using Arduino. i have searched a lot in internet but didn't find anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, any parameters is also ok. But the concept is what i am searching for.&#xA;The signal will be sent to the DAC of the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit&#xA;I would like to generate sine wave signal from 3kHz up to 100kHz sweep frequency with amplitude peak to peak 1.5 volt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for your support.&lt;/p&gt;&#xA;" OwnerUserId="1146" LastEditorUserId="10003" LastEditDate="2015-08-21T21:17:05.583" LastActivityDate="2017-01-11T02:36:43.620" Title="How to generate Chirp Signal using Arduino" Tags="|arduino-leonardo|signal-processing|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8422" PostTypeId="2" ParentId="8419" CreationDate="2015-02-04T08:34:31.593" Score="1" Body="&lt;p&gt;for a 5 volt Arduino anything over 2.7V will be considered as a digital HIGH whereas anything below 0.4V will be a digital LOW.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-02-04T08:34:31.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8425" PostTypeId="1" AcceptedAnswerId="8427" CreationDate="2015-02-04T11:48:56.320" Score="22" ViewCount="28276" Body="&lt;p&gt;I have worked on &lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot;&gt;SPI&lt;/a&gt; devices connected with an Arduino one at a time. How do I work with two different SPI devices at the same time?&lt;/p&gt;&#xA;" OwnerUserId="7136" LastEditorUserId="510" LastEditDate="2015-02-04T20:22:02.167" LastActivityDate="2016-12-21T12:09:09.087" Title="How to access multiple SPI interfaces on Arduino" Tags="|sd-card|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8426" PostTypeId="2" ParentId="8419" CreationDate="2015-02-04T12:03:11.383" Score="6" Body="&lt;p&gt;You could try not &lt;code&gt;digitalRead&lt;/code&gt;, but &lt;code&gt;analogReadVoltage&lt;/code&gt;. &lt;a href=&quot;http://arduino.cc/en/Tutorial/ReadAnalogVoltage&quot;&gt;Analog Read Voltage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Arduino examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  ReadAnalogVoltage&#xA;  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.&#xA;  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.&#xA;&#xA; This example code is in the public domain.&#xA; */&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  // read the input on analog pin 0:&#xA;  int sensorValue = analogRead(A0);&#xA;  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):&#xA;  float voltage = sensorValue * (5.0 / 1023.0);&#xA;  // print out the value you read:&#xA;  Serial.println(voltage);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-02-04T12:03:11.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8427" PostTypeId="2" ParentId="8425" CreationDate="2015-02-04T13:04:50.193" Score="24" Body="&lt;p&gt;Assuming you just want to connect two SPI slave devices to the SPI bus and use them in a mutually exclusive way under software control, with the Arduino as the master, then you just need to make sure you use a different pin for the slave select (SS) on each SPI device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you want to talk to one slave, you hold its SS low and drive the other high. Do the opposite to talk to the other slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some devils in the detail using multiple slaves, and &lt;a href=&quot;https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi&quot;&gt;these are explained in more depth here&lt;/a&gt;, but in general, it's quite common and OK to use more than one SPI device as a slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps&quot;&gt;This blog post&lt;/a&gt; will give you more information and is a good place to start reading.&lt;/p&gt;&#xA;" OwnerUserId="5063" LastActivityDate="2015-02-04T13:04:50.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8429" PostTypeId="1" CreationDate="2015-02-04T16:02:59.100" Score="0" ViewCount="698" Body="&lt;p&gt;I am wondering if anybody has ideas for developing an Arduino-based system that would use RFID to log occurrences when two people are in close proximity to each other (e.g., &amp;lt;= 1 meter).  Ideally, I would like to construct something that would operate in a manner very similar to the OpenBeacon system -- and, preferably, the events/data would be transmitted via wi-fi in real time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ideas are as follows, so any feedback or alternative solutions would be greatly appreciated.  (Please keep in mind that I am not an engineer!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking of using a wi-fi enable microprocessor (e.g., Arduino Yun) that would serve as the reader or detection system.  For beta-testing, this device could be set in an enclosed case and attached to a belt.  I presume it would require a fairly robust battery supply.  The other person would be wearing an RFID tag that has a range of &amp;lt;= 1 meter and would log the event.  Ideally, a reading would take place roughly every 30 seconds, and the captured event would be transmitted over wi-fi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few other things to keep in mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The people using the hardware should not have to do anything other than simply wear the constructed devices.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The reader itself should be as small as possible.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;My ultimate goal is the data logging of the proximal events.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am certainly open to other technologies, as my ultimate goal is simply the proximity detection with data logging (preferably via wi-fi).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&#xA;Brian&lt;/p&gt;&#xA;" OwnerUserId="2761" LastActivityDate="2015-02-05T17:47:07.253" Title="RFID system for proximity detection with data logging" Tags="|rfid|datalogging|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8430" PostTypeId="1" CreationDate="2015-02-04T17:37:04.743" Score="0" ViewCount="2450" Body="&lt;p&gt;Building a 9x9 LED matrix and facing following 2 problems in Arduino code,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current code displays 2 images (using byte arrays and then using bitRead) one by one, each for a certain duration of seconds. Persistence of vision is obtained by a delay of 300ms. There is a subroutine called upon in the main loop function with arguments of desired byte array and duration. I want to control the images by using 2 push buttons (push button1 and it displays 1st image until button2 is pressed, push button2 and second image is displayed until button1 is pressed). But the scanning algorithm exits the scan routine upon completion of the given input duration and restarts the routine with new argument (byte array of image2). I WANT THE IMAGE TO BE RETAINED ON THE MATRIX UNTIL BUTTON IS PRESSED. Can't figure out how to accomplish this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i nest the routine in a DO WHILE loop, then my problem is that how will the buttons be read from the main loop? Because I believe as long as the subroutine is being executed, main loop will be halted. (or I am totally wrong in this assumption?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference code which I intend to manipulate. (Here its for an 8x8 Matrix. Thats not an issue)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte bigHeart[] = {&#xA;    B01100110,&#xA;    B11111111,&#xA;    B11111111,&#xA;    B11111111,&#xA;    B01111110,&#xA;    B00111100,&#xA;    B00011000,&#xA;    B00000000};&#xA;&#xA;byte smallHeart[] = {&#xA;    B00000000,&#xA;    B00000000,&#xA;    B00010100,&#xA;    B00111110,&#xA;    B00111110,&#xA;    B00011100,&#xA;    B00001000,&#xA;    B00000000};&#xA;&#xA;const int columnPins[] = { 2, 3, 4, 5, 6, 7, 8, 9};&#xA;const int rowPins[] = { 10,11,12,15,16,17,18,19};&#xA;&#xA;void setup() {&#xA;    for (int i = 0; i &amp;lt; 8; i++)&#xA;    {&#xA;        pinMode(rowPins[i], OUTPUT); // make all the LED pins outputs&#xA;        pinMode(columnPins[i], OUTPUT);&#xA;        digitalWrite(columnPins[i], HIGH); // disconnect column pins from Ground&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;    int pulseDelay = 800 ; // milliseconds to wait between beats&#xA;    show(smallHeart, 80); // show the small heart image for 100 ms&#xA;    show(bigHeart, 160); // followed by the big heart for 200ms&#xA;    delay(pulseDelay); // show nothing between beats&#xA;}&#xA;&#xA;// routine to show a frame of an image stored in the array pointed to by the&#xA;// image parameter.&#xA;// the frame is repeated for the given duration in milliseconds&#xA;void show( byte * image, unsigned long duration)&#xA;{&#xA;    unsigned long start = millis(); // begin timing the animation&#xA;    while (start + duration &amp;gt; millis()) // loop until the duration period has passed&#xA;    {&#xA;        for(int row = 0; row &amp;lt; 8; row++)&#xA;        {&#xA;            digitalWrite(rowPins[row], HIGH); // connect row to +5 volts&#xA;            for(int column = 0; column &amp;lt; 8; column++)&#xA;            {&#xA;                boolean pixel = bitRead(image[row],column);&#xA;                if(pixel == 1)&#xA;                {&#xA;                    digitalWrite(columnPins[column], LOW); // connect column to Gnd&#xA;                }&#xA;                delayMicroseconds(300); // a small delay for each LED&#xA;                digitalWrite(columnPins[column], HIGH); // disconnect column from Gnd&#xA;            }&#xA;&#xA;            digitalWrite(rowPins[row], LOW); // disconnect LEDs&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7143" LastEditorUserId="84" LastEditDate="2015-02-05T17:54:43.680" LastActivityDate="2016-02-19T09:35:32.513" Title="Controlling image display on LED matrix by buttons" Tags="|led|button|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8431" PostTypeId="2" ParentId="4245" CreationDate="2015-02-05T00:38:07.220" Score="-1" Body="&lt;p&gt;It is a good idea to use a LightBlue Bean, only if you are using the Android SDK!&#xA; &lt;a href=&quot;https://bitbucket.org/littlerobots/beanlib&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/littlerobots/beanlib&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about the SDK, and get advice from people who are actually using it.&#xA;&lt;a href=&quot;http://beantalk.punchthrough.com/t/announcing-unofficial-android-sdk/394&quot; rel=&quot;nofollow&quot;&gt;http://beantalk.punchthrough.com/t/announcing-unofficial-android-sdk/394&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7151" LastActivityDate="2015-02-05T00:38:07.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8432" PostTypeId="2" ParentId="4245" CreationDate="2015-02-05T01:17:55.040" Score="1" Body="&lt;p&gt;Perhaps this is not exactly what you are looking for, but from your examples it seems like using navigational commands from the keayboard/mouse would accomplish a lot of what you are requesting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Android has USB HID support from honecomb, so you should be able to create a sketch to emulate a keyboard and mouse based on the IO data and it should work with your android device just by plugging the USB cable (if emulating a mouse, it will display the mouse cursor as soon as it is connected).&lt;/p&gt;&#xA;" OwnerUserId="6414" LastActivityDate="2015-02-05T01:17:55.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8436" PostTypeId="2" ParentId="8429" CreationDate="2015-02-05T08:30:10.110" Score="0" Body="&lt;p&gt;This is a cheapo 125khz reader from Seeed Studio (Shenzhen):&#xA;&lt;a href=&quot;http://www.seeedstudio.com/wiki/index.php?title=Electronic_brick_-_125Khz_RFID_Card_Reader&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/index.php?title=Electronic_brick_-_125Khz_RFID_Card_Reader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range on it is very limited and I'm not suggesting you buy that specific one. Instead, just notice the pinout, +,-,TX,RX. You will find many, many readers with that same pinout. When a tag is detected, the reader blindly transmits the ID via UART (serial). You will also find many WiFi modules with similar TX/RX pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your situation, the Arduino is actually wasteful since it's only purpose will be to mirror the reader's data from it's RX to it's TX. It's better to cut out the middle-man and just connect the (voltage-compatible) reader directly to the WiFi module to save power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many wireless modules are capable of automatically going low-power when there is nothing to do. Part of the receiver circuit will activate for transmitting, but since you are only transmitting sporadically from the belts, neither the receiver or transmitter needs to be powered constantly. I think you will be pleasantly surprised by the battery life.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastActivityDate="2015-02-05T08:30:10.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8437" PostTypeId="1" CreationDate="2015-02-05T08:47:41.400" Score="1" ViewCount="71" Body="&lt;p&gt;I have a prototyping shield for an Arduino Uno. I accidentally plugged the shield into my arduino so that the pins were all &quot;off by one&quot;. I didn't think this was possible, but it turns out that the extra pin just slips between the gaps in the pin headers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gfEkK.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I powered it on not realising. The arduino didn't show any LEDs, so I powered it down, saw my mistake, and plugged it all in again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now though A0-A5 are all reading high values (~900-1000 when I do &lt;code&gt;analogRead(A0)&lt;/code&gt;), even when I have pulldown resistors on them, and they still read like that when I unplug my shield all together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The digital writes all work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking that I've broken the Arduino. Is that possible, or could it be something else?&lt;/p&gt;&#xA;" OwnerUserId="7158" LastActivityDate="2015-02-05T12:04:54.763" Title="Plugged in shield off by one, now all analogues read high" Tags="|arduino-uno|shields|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8441" PostTypeId="1" AcceptedAnswerId="8462" CreationDate="2015-02-05T10:49:25.450" Score="3" ViewCount="1257" Body="&lt;p&gt;I came across something strange while reading the datasheet for the microcontroller in the Arduino Uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the (8) note in pg.296-297 of &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;this datasheet&lt;/a&gt;: what does WORDS mean in that context?&lt;/p&gt;&#xA;" OwnerUserId="7139" LastActivityDate="2015-02-06T17:31:46.013" Title="WORDS in ATmega328 datasheet note" Tags="|atmega328|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8442" PostTypeId="2" ParentId="8437" CreationDate="2015-02-05T12:04:54.763" Score="2" Body="&lt;p&gt;There is not (yet) enough information to be certain, but it seems likely that you have damaged the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If damage has occurred it's more likely to have been caused by what happened on the other side of the board, where pins carry power supply voltages. You do not say what your power source is or where it is connected (USB, 5V in, Vin, ...) but I'd guesstimate that the connection of UNO 5V to Shield 3V3 allowed back feed into the UNO by any of a number of possible paths. UNO Vin connects to shield ground and a second UNO ground connects to a second UNO ground - so if the UNO was powered via Vin you'd expect the power supply to have been shorted. This might damage some power supplies but usually not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please advise what voltage was connected and to what pin. And do shield pins all offset by 1 on the other side, as I've shown?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aqz5m.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-05T12:04:54.763" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8444" PostTypeId="2" ParentId="8441" CreationDate="2015-02-05T13:00:37.670" Score="3" Body="&lt;p&gt;&lt;strong&gt;See jwpat7's answer.&lt;/strong&gt;&lt;br&gt;&#xA;My answer is correct re address word BUT&lt;br&gt;&#xA;his points out that &quot;Words&quot; are being addressed and not bytes.  While my answer is not wrong, his is more likely to be what the writer meant in his excessively cryptic footnote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Byte is most usually used to refer to an 8 bit quantity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &quot;word&quot; is usually used to refer to a multi-Byte variable with the length depending on both processor type and context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, on page 296, table 28-19 information is given on the format of 4 byte Instructions. These instructions are NOT referred to as Words although in some other contexts they might be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However,  the &quot;Write Program memory page&quot; instruction contains the address of a memory page. This address is made up of a 16 bit field comprised of 2 Bytes - an MSB and an LSB.&lt;br&gt;&#xA;The notation &quot;Words&quot; is shown against the MSB and the LSB to denote (not very clearly) that a single 16 bit &quot;&lt;strong&gt;Address Word&lt;/strong&gt;&quot;is formed by the MSB + LSB combination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/byfyD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-06T11:20:00.263" LastActivityDate="2015-02-06T11:20:00.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8445" PostTypeId="2" ParentId="8420" CreationDate="2015-02-05T15:42:14.383" Score="2" Body="&lt;p&gt;Recommend to use a VCO PLL as external hardware device to get the wanted variable-frequency signal. The DAC output from Arduino can control the voltage to external VCO PLL module. Here is the link for an app note for VCO PLL from Vectron.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vectron.com/products/vcxo/vcxo.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.vectron.com/products/vcxo/vcxo.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="7120" LastActivityDate="2015-02-05T15:42:14.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8446" PostTypeId="1" AcceptedAnswerId="8477" CreationDate="2015-02-05T16:38:55.820" Score="0" ViewCount="612" Body="&lt;p&gt;I got a bit confused by Sparkfun's &lt;a href=&quot;https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;hookup guide&lt;/a&gt; for &lt;a href=&quot;https://www.sparkfun.com/products/12636&quot; rel=&quot;nofollow&quot;&gt;this 9DoF breakout&lt;/a&gt; module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says the VDD-in on the breakout &lt;em&gt;&quot;should [get voltage] regulated between 2.4V and 3.6V&quot;&lt;/em&gt;, yet in their example they do not hook it up to the Arduino's 3.3V pin, but instead they use the 5V and a bi-directional logic level converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to use the logic level converter, or can I just hook the module up to the 3.3V pin of my Arduino Uno without damaging the breakout module?&lt;/p&gt;&#xA;" OwnerUserId="7157" LastEditorUserId="7157" LastEditDate="2015-02-05T17:05:04.653" LastActivityDate="2015-02-06T10:17:20.040" Title="Connecting a LSM9DS0 9DoF module to Arduino Uno" Tags="|arduino-uno|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8447" PostTypeId="2" ParentId="8429" CreationDate="2015-02-05T17:38:50.640" Score="1" Body="&lt;p&gt;Consider using two basic XXMhz transceivers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-Master loops through used ID's and transmits them one at a time.&#xA;-If a belt receives an ID other than it's own, it remains quiet.&#xA;-If a belt receives it's own ID, it transmits &quot;Marco&quot; (quietly) to the other belts.&#xA;-For a receiver to hear the very quiet signal, it will need to be very close.&#xA;-The RSSI signal can be monitored for signal strength to determine close(enough) proximity.&#xA;-If sufficient proximity is detected, the event is reported to the Master.&#xA;-If it receives no response, it informs the Master.&#xA;-Master proceeds to the next ID.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this setup, you only need to provide networking (WiFi/Ethernet) to the master. (cheaper)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that each belt can identify the others, &quot;Marco&quot; could be the transmitter's ID, but you'll need to add some sort of &quot;protocol&quot; so the belts know if the ID they hear is from the Master or another belt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If ID is only 7 bits, the &quot;protocol&quot; could be as simple as a bitmask:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Server = Send(ID &amp;amp;  (1 &amp;lt;&amp;lt; 7)); //1XXXXXXX&#xA;  Belt = Send(ID &amp;amp; ~(1 &amp;lt;&amp;lt; 7)); //0XXXXXXX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Belts only reply to their ID if MSB is 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This example has excessive range for your purpose (250m); these radios will be screaming at each other and the RSSI signal is unlikely to provide meaningful data.&#xA;&lt;a href=&quot;http://www.seeedstudio.com/depot/nRF24L01Module-p-1394.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/nRF24L01Module-p-1394.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Using RFID, you are wanting (very)long range from an (intentionally) short-ranged system.&#xA;Using ISM, you are wanting (very)short range from an (intentionally) long-ranged system.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Neither is 100%, but both should work.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="6980" LastEditDate="2015-02-05T17:47:07.253" LastActivityDate="2015-02-05T17:47:07.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8449" PostTypeId="1" CreationDate="2015-02-05T18:56:50.513" Score="2" ViewCount="49808" Body="&lt;p&gt;What's the best/easiest software to make a PC-Arduino interface? Ideally, I need to create a .exe that shows up a simple graphic interface, where the user can display data acquired from sensors connected to the Arduino (eg. Voltage, current etc.) and from there he should be able to control Arduino outputs through graphical buttons/switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To say that I am not a programmer, so if there's some sort of 'graphical coding' or 'non coding' software to make such things it'd be great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image of how the user interface should look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zwsC9.jpg&quot; alt=&quot;Image of how the user interface should look like&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7167" LastEditorUserId="7167" LastEditDate="2015-02-05T20:52:57.230" LastActivityDate="2017-09-09T08:21:24.313" Title="Make a PC graphical interface for Arduino - Any easy software?" Tags="|arduino-uno|programming|communication|software|" AnswerCount="3" CommentCount="2" ClosedDate="2015-02-08T16:02:15.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="8450" PostTypeId="1" AcceptedAnswerId="10310" CreationDate="2015-02-05T19:14:31.827" Score="1" ViewCount="820" Body="&lt;p&gt;I am building a wireless system that has got an Arduino with a XBEE as the 'end user' and I need to acquire data/control that Arduino from a PC graphical interface. &#xA;As far as I'm aware there are two options to obtain the communication:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I could use another Arduino with XBEE (coordinator) that is connected to my PC (serial) to control the 'end user'. The code is stored in this Arduino which works as a bypass between PC and XBEE. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I could simply use a XBEE without Arduino (coordinator) connected to my PC to control the 'end user'. The code should be stored within the PC or the XBEE to establish communication and control data transmission to different end users (???)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As I am new to the Arduino world, would you please direct me to the best/easiest solution to obtain such thing?&lt;/p&gt;&#xA;" OwnerUserId="7167" LastActivityDate="2015-04-25T06:25:17.890" Title="XBEE coordinator WITH or WITHOUT Arduino?" Tags="|arduino-uno|serial|xbee|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8451" PostTypeId="2" ParentId="8449" CreationDate="2015-02-05T19:27:46.983" Score="2" Body="&lt;p&gt;Almost impossible to answer really. Questions with &quot;best&quot; are always going to yield opinions which probably won't apply to your situation. For example, I would do a C# desktop application because that's what I do, and nothing in that environment hinders communication with an Arduino. So, what's best for me is best because of &quot;familiar and will work&quot; and we can't decide what meets those criteria for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you will update your question to describe more about your application, details about your interface, users, and what skills you have, then I will update this answer, but as it stands &quot;the world is your oyster&quot; because almost any programming environment capable of making an application will be able to interface with Arduino in some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &quot;graphical&quot; programming look into LabView - I can think of a lot of reasons to not go that way though.  &lt;a href=&quot;http://www.ni.com/labview/&quot; rel=&quot;nofollow&quot;&gt;http://www.ni.com/labview/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a tutorial for interfacing a c# application with Arduino:&#xA;&lt;a href=&quot;http://www.codeproject.com/Articles/473828/Arduino-Csharp-and-Serial-Interface&quot; rel=&quot;nofollow&quot;&gt;http://www.codeproject.com/Articles/473828/Arduino-Csharp-and-Serial-Interface&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gist of it is this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Some version of Visual Studio up and running - you can use the free version mentioned in Jon's answer (Express version for desktops).&lt;/li&gt;&#xA;&lt;li&gt;A working Arduino connected to your computer with the USB.&lt;/li&gt;&#xA;&lt;li&gt;Create a new Windows Forms Application and drop whatever controls you need onto the form&lt;/li&gt;&#xA;&lt;li&gt;Write your Arduino-connecting code into the events of the controls&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That is the basic method of creating Windows Forms apps regardless of what you're doing. You create forms with controls and your custom code goes into the events of those controls. If you read the tutorial it explains how that code works, but here's a sample... (In the tutorial, they are doing a WPF app, which is slightly different from Windows Forms in how the controls are defined, but the code is basically the same). This is an event of the serial port - you respond to the event by displaying the received data into a text box. Very simple!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void mySerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) {&#xA;    string data = mySerialPort.ReadTo(&quot;\x03&quot;);&#xA;    myForm.myTextBox.Text = data;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2015-02-05T23:18:47.863" LastActivityDate="2015-02-05T23:18:47.863" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8453" PostTypeId="1" AcceptedAnswerId="8456" CreationDate="2015-02-05T20:20:10.917" Score="0" ViewCount="119" Body="&lt;p&gt;I am new to arduino programming. I want to sense temperature and send it to a server in my college. I am using Arduino Uno R3 board which has ATmega 328P micro-controller. I am able to get serial output on my PC but is there a way in which I can send temperature data to the server in a packet format using Arduino Programmer and not using Ethernet Shield ? Please answer in a less complex way.  &lt;/p&gt;&#xA;" OwnerUserId="7170" LastActivityDate="2015-02-06T09:06:40.107" Title="Arduino over a Network" Tags="|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8454" PostTypeId="2" ParentId="4444" CreationDate="2015-02-05T21:24:31.557" Score="1" Body="&lt;p&gt;There was a defective bootloader that shipped on some Arduino devices which caused the symptom you describe. See:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=51172.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=51172.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=74090.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=74090.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's the case, your options are to re-write the bootloader yourself (if you have the capability) or return to the manufacturer.&lt;/p&gt;&#xA;" OwnerUserId="7173" LastActivityDate="2015-02-05T21:24:31.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8455" PostTypeId="2" ParentId="8449" CreationDate="2015-02-05T21:49:21.463" Score="3" Body="&lt;p&gt;The &quot;best&quot; software for me is the free Visual Studio Express for Desktops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using C#, I would add a SerialPort component to the form, configure it for the same COM port as the Arduino/FTDI, then send commands to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XNkmg.jpg&quot; alt=&quot;VS&quot;&gt;&#xA;Visual Studio is &quot;stupid simple&quot; (I'm not implying anything :D). Double-click Button in the toolbox(1) and it creates one. Double click the button(2), and it outlines the code and attaches the Click event to it for you. Double click Components&gt;SerialPort(3) to create one. My code is highlighted in blue to the right and this took all of 1 minute to create.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To point you in the right direction on the Arduino side, here is the structure of the &quot;command&quot; I sent in the screenshot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;XXXYYYZZ&#xA;Where:&#xA;XXX = 000b for &quot;turn off&quot;, 001b for &quot;turn on&quot;, 010b for &quot;toggle&quot;, 011b for &quot;read pin&quot;&#xA;YYY = Pin number //Max = 111b = 7 (+ 0) = 8 uniquely addressable pins (using 3 bits)&#xA;//Pin number does not have to match the MCU port/pin designations&#xA;//MCU will convert logical pin #'s 0-7 into the correct physical port+pin&#xA;//For more pins, steal another bit from ZZ; Max for YYYY = 1111b = 15&#xA;ZZ = Spare bits //Tell the Arduino whether to acknowledge or not, etc.&#xA;&#xA;00100100b = &quot;Set pin 1 high&quot;&#xA;01001000b = &quot;Toggle pin 2&quot;&#xA;10000000b + 0xAA (two byte command) = &quot;Reply with contents of register 0xAA&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additional commands can be created to tell the Arduino to reply with a specific variable or status.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool isRegisterRead = false;&#xA;bool isMultiByte = false;&#xA;while (true)&#xA; if (wasByteReceived) //This flag is set in the RX interrupt and the byte is saved to byteReceived&#xA;  if (isMultiByte) //Second byte received&#xA;  {&#xA;    if (isRegisterRead)&#xA;    {&#xA;      //We need to read and send the value of the register at the address in byteReceived&#xA;      ReadAndSendRegisterValueAtAddress(byteReceived);&#xA;      isRegisterRead = false;&#xA;    }&#xA;    else DoSomethingWith(byteReceived);&#xA;    isMultiByte = false; //Start over&#xA;  }&#xA;  else //First or only byte received&#xA;  {&#xA;    //Consider using a ZZ bit to indicate more data instead of listing them explicitly&#xA;    if (byteReceived == 0x80) //A multi-byte &quot;read register&quot; command&#xA;    {&#xA;      isMultiByte = true; //Next byte received is money&#xA;      //For my example we need to set a flag somewhere to indicate that we are reading a register&#xA;      //isRegisterRead should be set to true by DoSomethingWith&#xA;    }&#xA;    //Is there any processing for the &quot;command&quot; byte? (i.e. extract and save the pin number)&#xA;    DoSomethingWith(byteReceived); //Process one-byte command or first of two-byte command&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="26916" LastEditDate="2017-09-09T08:21:24.313" LastActivityDate="2017-09-09T08:21:24.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8456" PostTypeId="2" ParentId="8453" CreationDate="2015-02-05T21:52:41.020" Score="0" Body="&lt;p&gt;Without an ethernet shield or some kind of other internet connectivity shield/circuitry you cannot communicate directly with the internet through the arduino. However, if having a computer as the internet communicator isn't a problem you could try a setup like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arduino-&gt;serial (usb)-&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;processing&lt;/a&gt;-&gt;&lt;a href=&quot;http://forum.processing.org/one/topic/how-to-access-internet-through-processing-application.html&quot; rel=&quot;nofollow&quot;&gt;internet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you create the internet packet in processing using the temperature information received through serial from arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see also &lt;a href=&quot;https://processing.org/&quot; rel=&quot;nofollow&quot;&gt;https://processing.org/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1281" LastActivityDate="2015-02-05T21:52:41.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8457" PostTypeId="1" AcceptedAnswerId="8460" CreationDate="2015-02-05T21:56:19.323" Score="3" ViewCount="45023" Body="&lt;p&gt;I'm trying to do some fairly simple serial communication and have things partially working, but am pretty confused about a couple results I'm getting.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a little background, I'm using an Arduino Mega 2560 to try to communicate with a Dynamixel servo (MX-64) over TTL (half-duplex, asynchronous) with Tx1 and Rx1.  Basically I construct some byte arrays as instructions, send them over to the servo (with &lt;code&gt;Serial1.write()&lt;/code&gt;), and then read back a reply.  I've actually gotten it to work pretty well if I use &lt;code&gt;Serial1.readBytes()&lt;/code&gt;, specifying the length of the buffer (number of bytes I'm expecting).  I'm also reading back what I originally sent (first) as well as the response (second), since I have Tx1 and Rx1 tied together (required in my setup because this servo only has one data wire).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I don't understand the difference between &lt;code&gt;Serial.readBytes()&lt;/code&gt; and &lt;code&gt;Serial.read()&lt;/code&gt;.  If I do &lt;code&gt;Serial.read()&lt;/code&gt; just prior to &lt;code&gt;Serial.readBytes()&lt;/code&gt;, it comes back with -1, meaning no bytes to read... but then &lt;code&gt;Serial.readBytes()&lt;/code&gt; gives me the byte stream I was expecting from the buffer!  What's going on here?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, &lt;code&gt;Serial.available()&lt;/code&gt; seems sort of broken in that it tells me there are no bytes to read (returns 0), but then I can read the bytes I'm expecting with &lt;code&gt;Serial.readBytes()&lt;/code&gt;. Additionally, I can do &lt;code&gt;Serial.readBytes()&lt;/code&gt; after there's nothing left (or rather, there shouldn't be any bytes left...) and it will give me some bytes, but they're total garbage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think maybe there's something I don't understand about the way the serial buffer works, but can't find a good resource on it and the Arduino reference pages are kind of useless.  Any clues about the difference in how these operate would be much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="7172" LastActivityDate="2015-12-18T02:38:06.500" Title="Serial.read() vs. Serial.readBytes()?" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8458" PostTypeId="1" CreationDate="2015-02-04T10:37:08.390" Score="0" ViewCount="313" Body="&lt;p&gt;I want to write my own debugger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow&quot;&gt;Visual Micro&lt;/a&gt; plugin for Visual Studio provides Arduino Debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, does anyone have ideas how it works?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just desire make the same plugin in Eclipse IDE.&lt;/p&gt;&#xA;" OwnerDisplayName="ztrn" LastActivityDate="2015-02-05T22:49:12.727" Title="How do I write a debugger for Arduino?" Tags="|debugging|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8459" PostTypeId="2" ParentId="8458" CreationDate="2015-02-04T21:30:02.673" Score="4" Body="&lt;p&gt;Assuming you have enough time and money to spend on this project. ($50 is a bargain for a debugger, believe me. About a decade ago I wrote an assembler/debugger suite for a very small niche market microcontroller, the Maxim Integrated MAX1464, using a combination of SciTe and Perl/Tk. Writing your own debugger is a great educational project, if you have the time and money to complete it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you already have all the standard Arduino debug tools, and just want to learn the process of making a debug tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you've used the standard Arduino debug tools before, and written enough programs (sorry, you Arduino guys call them &quot;sketches&quot; for some reason) so that you have some code you feel comfortable debugging on. Setting a breakpoint in a simple &quot;blinking LED&quot; program isn't very satisfying, better to set breakpoints in a test program that actually does something. You'll also want to have some branching logic pathways to test breakpoints, and some variables (counters perhaps) so you can test reading values through the debug interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you have a couple of spare Arduino boards, because very likely during development some bad debug commands may get sent. Ideally you should have a device programmer capable of restoring the Arduino bootloader image that normally resides in the Atmel AVR processor. Sending arbitrary commands to the debug interface could possibly erase or mess up the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you have access to customary EE lab tools: DMM, oscilloscope, soldering iron, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Research&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you already know how to make an Eclipse IDE plugin... (if you don't, that would be a question to research on Google or StackOverflow.) I'm treating this the same as if you were writing a plain command-line debugger or a gdb driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not really sure which debug protocol you need to implement. Sadly, &lt;code&gt;JTAG&lt;/code&gt; doesn't seem to be supported by Arduino. The &lt;code&gt;ICSP&lt;/code&gt; in-circuit system programming header might give debug access, though it would require attaching some hardware to the board that you're debugging. If I understand correctly, the Arduino IDE supports debugging through the USB port, which is a very attractive setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you plan to use Atmel's proprietary &lt;code&gt;DebugWIRE&lt;/code&gt; protocol, which someone else has kindly attempted to reverse-engineer here: &lt;a href=&quot;http://www.ruemohr.org/docs/debugwire.html&quot; rel=&quot;nofollow&quot;&gt;http://www.ruemohr.org/docs/debugwire.html&lt;/a&gt;  Ideally you'd get the real documentation from Atmel. The hazard of a reverse-engineered protocol like this (aside from possible IP infringement) is that the protocol could change without notice. Not having direct access to the team that designed the microcontroller, means you have to rely on whatever documentation you can find and whatever else you can discover experimentally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you can use the USB bridge chip's &lt;code&gt;DTR#&lt;/code&gt; to drive (and possibly sense) the RESET pin, to access DebugWire. If that USB bridge chip is an FTDIchip.com device, you'll want to use the bit-banging mode to drive and sense DTR#. (In normal &quot;RS232 mode&quot; this pin is not bidirectional.) Go to the FTDIchip.com website to get the D2XX programmer's guide and example code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since DebugWire is a protocol that uses one wire for all signalling, both directions, timing is absolutely critical. &lt;strong&gt;You must use an oscilloscope&lt;/strong&gt; to observe the DebugWire signals on the RESET pin, otherwise you're &quot;flying blind&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should be enough to get you started. Initially, you'll have to figure out how to discover an attached Arduino, enter debug mode, set a breakpoint, and reset the part back into free-running mode. The &quot;blinking LED&quot; test program is good enough to see some results for this early stage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="7174" OwnerDisplayName="MarkU" LastActivityDate="2015-02-04T21:30:02.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8460" PostTypeId="2" ParentId="8457" CreationDate="2015-02-05T22:57:40.437" Score="6" Body="&lt;p&gt;readBytes is blocking until the determined length has been read, or it times out (see Serial.setTimeout()). Where read grabs what has come, if it has come in. Hence available is used to query if it has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it takes time for a message to go out and to receive either the echo or response. So simply checking the RX buffer immediately after sending something, is expected to be empty for some time. That is where readBytes sites and waits. And I bet the default setTimeout of 1s is sufficient, to get the response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why you see the Serial.read() inside a while or if Serial.available. Hence I typically employ something like the following: Which emulates readBytes (for the most part).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define TIMEOUT = 3000;&#xA;    loop {&#xA;        char inData[20];&#xA;        unsigned long timeout = millis() + TIMEOUT;&#xA;        uint8_t inIndex = 0;&#xA;        while ( ((int32_t)(millis() - timeout) &amp;lt; 0) &amp;amp;&amp;amp; (inIndex &amp;lt; (sizeof(inData)/sizeof(inData[0])))) {&#xA;            if (Serial1.available() &amp;gt; 0) {&#xA;                // read the incoming byte:&#xA;                inData[inIndex] = Serial.read();&#xA;                if ((c == '\n') || (c == '\r')) {&#xA;                    break;&#xA;                }&#xA;                Serial.write(inData[inIndex++]);&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above code was quickly written and untested. But gets the idea across.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-02-05T22:57:40.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8461" PostTypeId="2" ParentId="4" CreationDate="2015-02-05T23:18:28.847" Score="8" Body="&lt;p&gt;I list this as an answer for the sake of having it linked here. It is not full https yet but he is working on it and it may be doable in the future &#xA;&lt;a href=&quot;http://evothings.com/is-it-possible-to-secure-micro-controllers-used-within-iot/&quot; rel=&quot;noreferrer&quot;&gt;http://evothings.com/is-it-possible-to-secure-micro-controllers-used-within-iot/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is a benchmark he did encrypting a message using a 1024 bit public key&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino UNO       16Mhz AVR               ==&amp;gt; 12596 ms*   8504 ms#&#xA;Arduino Leonardo  16Mhz AVR               ==&amp;gt; 12682 ms*   8563 ms#&#xA;Arduino Mega      16Mhz AVR               ==&amp;gt; 12596 ms*   8504 ms#&#xA;Arduino Due       84Mhz ARM               ==&amp;gt;  1032 ms*&#xA;Arduino Yún       16Mhz AVR + 400Mhz MIPS ==&amp;gt;   707 ms*&#xA;Intel Galileo     400Mhz x86              ==&amp;gt;   192 ms*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is as far as he has gone with it but is in the process of setting up a test server to work on seeing how close to a full ssl/https implementation he can pull off.&lt;/p&gt;&#xA;" OwnerUserId="7175" LastEditorUserId="7175" LastEditDate="2015-02-07T00:18:12.470" LastActivityDate="2015-02-07T00:18:12.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8462" PostTypeId="2" ParentId="8441" CreationDate="2015-02-05T23:26:00.590" Score="2" Body="&lt;p&gt;The notation is being used to indicate that the 16-bit address (as formed by the central bytes of a Write Program Memory Page instruction) is the address of a program-memory &lt;em&gt;word&lt;/em&gt;, rather than a  program-memory &lt;em&gt;byte&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The size of program memory is specified in bytes, but it often is addressed as words.  For example, the PC (program counter) register contains word addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some instructions, when the Z register is used to address program memory, it contains a word number and a byte selector:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Z-register in the Register File is used to access the Program memory. This 16 bits register pair is used as a 16 bits pointer to the Program memory. The 15 most significant bits selects the word address in Program memory. Because of this, the word address is multiplied by two before it is put in the Z-register. ... The least significant bit of the Z Address Register selects either Low byte (0) or High&#xA;  byte(1) of the Program memory word. — &lt;a href=&quot;http://www.atmel.com/Images/doc1233.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR108: Setup and Use of the LPM Instruction&lt;/a&gt;, page 1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; Some of the low bits of the word address in a “Write Program memory page” serial programming instruction are treated as don't-cares.  The number of don't-care bits depends on flash page size, which in Atmel AVR devices is 32, 64 or 128 words, depending on device series.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (as shown in Table 129 on page 304 of &lt;a href=&quot;http://www.atmel.com/images/doc2467.pdf&quot; rel=&quot;nofollow&quot;&gt;doc2467.pdf&lt;/a&gt;) the ATmega128 with 128-word (256-byte) flash pages has seven don't-care bits in the low byte of the address.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Table 129. SPI Serial Programming Instruction Set&#xA;                 -----------Instruction Format----------&#xA; Instruction       Byte 1    Byte 2    Byte 3    Byte 4    Operation&#xA;&#xA;Write Program    0100 1100 aaaa aaaa bxxx xxxx xxxx xxxx&#xA;Memory Page                                              Write Program Memory &#xA;                                                         Page at address a:b.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-02-06T17:31:46.013" LastActivityDate="2015-02-06T17:31:46.013" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8463" PostTypeId="2" ParentId="8449" CreationDate="2015-02-05T23:52:01.900" Score="1" Body="&lt;p&gt;3 votes for visual studio and a windows desktop, although I would chose WPF. Win32 (Winforms) is a slightly out of date architecture. WPF has a steeper learning curve, but worth it if you want to become proficient. If it is a one off application, don't bother, use winforms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll add a couple of points.  Debugging Arduino sucks. I am being kind.  The Arduino IDE deploys on com port 1, and prints debugging messages on com port 1, so if you need to communicate un-interrupted by debugging and deployment, what do you use? Not com port 1 for sure. Look at software serial in the beginning and assign ports around its requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, writing your own com stack is dumb, yet is done 99% of the time.  Look at MQTT if ethernet is available, MQTT-SN if it is not, &lt;a href=&quot;http://playground.arduino.cc/Code/CmdMessenger&quot; rel=&quot;nofollow&quot;&gt;CmdMessenger&lt;/a&gt; or &lt;a href=&quot;http://playground.arduino.cc/Code/SerialControl&quot; rel=&quot;nofollow&quot;&gt;CommandSerial&lt;/a&gt; or something similar or spend days designing, writing, re-writing and debugging your own, your choice.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-02-06T00:55:52.223" LastActivityDate="2015-02-06T00:55:52.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8464" PostTypeId="2" ParentId="8129" CreationDate="2015-02-06T00:25:37.457" Score="0" Body="&lt;p&gt;Please read this: &lt;a href=&quot;https://arduino.stackexchange.com/questions/4509/arduino-nrf24l01-arduino-to-netmf-transmit-issue?rq=1&quot;&gt;Arduino NRF24L01+ arduino to netmf transmit issue&lt;/a&gt;&lt;br&gt;&#xA;Although you are not using NETMF, @PhilVallone uses the library and chip together successfully, points out the samples are not asynchronous, and addresses time-out. The OP for that question is using delay(1000) and no answer has been accepted.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-02-07T22:50:10.087" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8465" PostTypeId="1" AcceptedAnswerId="8466" CreationDate="2015-02-06T03:22:19.837" Score="0" ViewCount="1371" Body="&lt;p&gt;I have Sparkfun Pro Micro (Leonardo compatible board). I got it because I plan to build my own array of controls for use in flight/racing sims.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My starting point is LeoJoy, and I didn't have any trouble getting this up and running. Installed just fine, and I have a programmable HID joystick available in windows. It seems to work by modifying the RAWHID code in the default libraries to spoof being a HID joystick. However, my board was now stuck in joystick mode, with no available COM ports for uploading new sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resetting the board (by grounding the RST pin), enables the COM port, but very, very briefly. Not enough time to send new sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After about an hour of trying different timing, I finally did upload an empty sketch to the board before it went into Joystick mode. So I'm good for now, but I'm a bit worried that I'm going to have to repeat this every time I want to make a change to my program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something completely noobish here? Is this the correct way to program a board that has been forced to act as a joystick? Is there a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps there's some code I can put into my sketch that will delay the change of USB behavior for a few seconds. That way, it will allow me to recompile and submit my sketches after a reset without having to rush the timing.&lt;/p&gt;&#xA;" OwnerUserId="7177" LastActivityDate="2015-02-06T19:15:16.330" Title="Uploading new sketch to Leonardo-type boards when you've changed the HID mode" Tags="|serial|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8466" PostTypeId="2" ParentId="8465" CreationDate="2015-02-06T04:21:36.053" Score="0" Body="&lt;p&gt;From Sparkfun's page &lt;a href=&quot;http://f&quot;&gt;Pro Micro Hook-upGuide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a Pro Micro is externally reset (by pulling the RST pin low), it’ll only briefly (&amp;lt;750ms) start the bootloader before continuing on to the sketch. If you need the bootloader to run longer, resetting twice quickly will get the Pro Micro to enter bootloader mode for eight seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps! If not there are some other procedures you might want to look into.&lt;/p&gt;&#xA;" OwnerUserId="3671" LastEditorUserId="3671" LastEditDate="2015-02-06T19:15:16.330" LastActivityDate="2015-02-06T19:15:16.330" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8467" PostTypeId="2" ParentId="6675" CreationDate="2015-02-06T07:49:08.787" Score="0" Body="&lt;p&gt;You can use a USB &lt;strong&gt;&lt;a href=&quot;http://www.digikey.com/product-detail/en/87520-0010BLF/609-1045-ND/1001359&quot; rel=&quot;nofollow&quot;&gt;connector&lt;/a&gt;&lt;/strong&gt; (&lt;a href=&quot;http://www.digikey.com/product-detail/en/0475890001/WM17143TR-ND/1832253&quot; rel=&quot;nofollow&quot;&gt;micro&lt;/a&gt;) (mounted on a custom PCB) for whatever you want and route the connector's pins to whichever Arduino pins you want. It will not be USB, but you could, at least, use USB cables for ease-of-connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is &lt;em&gt;un-wise&lt;/em&gt;, at best, because someone is, eventually, going to plug in a real USB cable.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="6980" LastEditDate="2015-02-06T07:54:59.347" LastActivityDate="2015-02-06T07:54:59.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8468" PostTypeId="1" AcceptedAnswerId="8474" CreationDate="2015-02-06T08:20:11.473" Score="1" ViewCount="2056" Body="&lt;p&gt;I am not entirely sure how a magnetometer works in IMU units, so I was wondering how a magnet near the sensor affects readings?&lt;/p&gt;&#xA;" OwnerUserId="7157" LastActivityDate="2016-12-05T12:39:03.783" Title="Will a magnetometer give distorted values if there is a magnet near?" Tags="|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8469" PostTypeId="2" ParentId="8453" CreationDate="2015-02-06T09:06:40.107" Score="0" Body="&lt;p&gt;Use an &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoYun&quot; rel=&quot;nofollow&quot;&gt;Arduino Yún&lt;/a&gt;: it's a Leonardo coupled with a CPU running GNU/Linux (a flavour of OpenWRT).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the Bridge library, your sketch can delegate tasks to the linux side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HttpClient example (Examples &gt; Bridge &gt; HttpClient) GETs a page from the Arduino web site, but the HttpClient class may POST whatever data to a server of choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a nice example called &lt;a href=&quot;https://www.temboo.com/arduino/yun/update-google-spreadsheet&quot; rel=&quot;nofollow&quot;&gt;SendDataToGoogleSpreadsheet&lt;/a&gt; (Examples &gt; Bridge &gt; Temboo &gt; SendDataToGoogleSpreadsheet): it accumulates sensor readings on a google spreadsheet. I've used something like that on a &lt;a href=&quot;https://github.com/ffissore/badger&quot; rel=&quot;nofollow&quot;&gt;project of mine&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-02-06T09:06:40.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8470" PostTypeId="1" CreationDate="2015-02-06T09:10:36.103" Score="-1" ViewCount="20151" Body="&lt;pre&gt;&lt;code&gt;#include &quot;pulse-sensor-arduino.h&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;#define PulseSensorbegin&#xA;&#xA;int pulsePin = 0;                &#xA;int blinkPin = 13;                &#xA;int fadePin = 5;                 &#xA;int fadeRate = 0;                 &#xA;volatile int BPM;                  &#xA;volatile int Signal;                &#xA;volatile int IBI = 600;            &#xA;&#xA;volatile boolean QS = false;        &#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(blinkPin,OUTPUT);   &#xA;  pinMode(fadePin,OUTPUT);          &#xA;  Serial.begin(115200);           &#xA;&#xA;  PulseSensorbegin();&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;   sendDataToProcessing('S', Signal);     &#xA;   if (QS == true) &#xA;   {        &#xA;       fadeRate = 255;                  &#xA;       sendDataToProcessing('B',BPM);   &#xA;       sendDataToProcessing('Q',IBI);  &#xA;       QS = false;                      &#xA;   }&#xA;&#xA;   ledFadeToBeat();&#xA;&#xA;   delay(5000);                             &#xA;}&#xA;&#xA;&#xA;void ledFadeToBeat(){&#xA;&#xA;    fadeRate -= 15;                         &#xA;    fadeRate = constrain(fadeRate,0,255);   &#xA;    analogWrite(fadePin,fadeRate);          &#xA;  }&#xA;&#xA;&#xA;void sendDataToProcessing(char symbol, int data ){&#xA;&#xA;    Serial.print(symbol);                &#xA;    Serial.println(data);                &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;/// my  ccp program &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;pulse-sensor-arduino.h&quot;&#xA;&#xA;volatile int rate[10];                        &#xA;volatile unsigned long sampleCounter = 0;     &#xA;volatile unsigned long lastBeatTime = 0;      &#xA;volatile int P =512;                         &#xA;volatile int T = 512;                        &#xA;volatile int thresh = 512;                    &#xA;volatile int amp = 100;                       &#xA;volatile boolean firstBeat = true;           &#xA;volatile boolean secondBeat = false;          &#xA;volatile boolean Pulse = false;              &#xA;volatile int pulsePin;&#xA;&#xA;volatile int PulseSensor::IBI = 600;          &#xA;volatile int PulseSensor::BPM;                &#xA;volatile int PulseSensor::Signal;             &#xA;volatile boolean PulseSensor::QS = false;     &#xA;void PulseSensor::begin(int pPin)&#xA;{&#xA;  pinMode(pulsePin, INPUT);&#xA;  pulsePin = pPin;&#xA;&#xA;&#xA;  TCCR1A = 0x00;&#xA;  TCCR1B = 0x0C;  &#xA;  OCR1A = 0x7C;  &#xA;  TIMSK1 = 0x02;&#xA;  sei();             &#xA;}&#xA;&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;&#xA;{                        &#xA;  cli();                                      &#xA;  PulseSensor::Signal = analogRead(pulsePin);             &#xA;  sampleCounter += 2;                         &#xA;  int N = sampleCounter - lastBeatTime;       &#xA;&#xA;&#xA;  if(PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; N &amp;gt; (PulseSensor::IBI/5)*3)&#xA;{       &#xA;    if (PulseSensor::Signal &amp;lt; T){                        &#xA;      T = PulseSensor::Signal;                         &#xA;    }&#xA;  }&#xA;&#xA;  if(PulseSensor::Signal &amp;gt; thresh &amp;amp;&amp;amp; PulseSensor::Signal &amp;gt; P)&#xA;{          &#xA;    P = PulseSensor::Signal;                             &#xA;  }                                       &#xA;&#xA;&#xA;  if (N &amp;gt; 250){                                  &#xA;    if ( (PulseSensor::Signal &amp;gt; thresh) &amp;amp;&amp;amp; (Pulse == false) &amp;amp;&amp;amp; (N &amp;gt; (PulseSensor::IBI/5)*3) )&#xA;    {        &#xA;      Pulse = true;                              &#xA;      PulseSensor::IBI = sampleCounter - lastBeatTime;        &#xA;      lastBeatTime = sampleCounter;              &#xA;&#xA;      if(secondBeat){                        &#xA;        secondBeat = false;                 &#xA;        for(int i=0; i&amp;lt;=9; i++){             &#xA;          rate[i] = PulseSensor::IBI;                      &#xA;        }&#xA;      }&#xA;&#xA;      if(firstBeat){                         &#xA;        firstBeat = false;                   &#xA;        secondBeat = true;                   &#xA;        sei();                               &#xA;        return;                              &#xA;      }   &#xA;&#xA;&#xA;&#xA;      word runningTotal = 0;                    &#xA;&#xA;      for(int i=0; i&amp;lt;=8; i++){                &#xA;        rate[i] = rate[i+1];                  &#xA;        runningTotal += rate[i];             &#xA;      }&#xA;&#xA;      rate[9] = PulseSensor::IBI;                          &#xA;      runningTotal += rate[9];               &#xA;      runningTotal /= 10;                      &#xA;      PulseSensor::BPM = 60000/runningTotal;              &#xA;      PulseSensor::QS = true;                              &#xA;    }                       &#xA;  }&#xA;&#xA;  if (PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; Pulse == true){   &#xA;    Pulse = false;                        &#xA;    amp = P - T;                           &#xA;    thresh = amp/2 + T;                    &#xA;    P = thresh;                          &#xA;    T = thresh;&#xA;  }&#xA;&#xA;  if (N &amp;gt; 2500){                           &#xA;    thresh = 512;                         &#xA;    P = 512;                              &#xA;    T = 512;                               &#xA;    lastBeatTime = sampleCounter;                &#xA;    firstBeat = true;                      &#xA;    secondBeat = false;                    &#xA;  }&#xA;&#xA;  sei();                                 &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//my header programing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef PULSE_SENSOR_ARDUINO_H&#xA;#define PULSE_SENSOR_ARDUINO_H&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;class PulseSensor&#xA;{&#xA;public:&#xA;  static void begin(int pulsePin);&#xA;&#xA;  static volatile int BPM;          &#xA;  static volatile int Signal;        &#xA;  static volatile int IBI;           &#xA;  static volatile boolean QS;        &#xA;};&#xA;&#xA;#endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7156" LastEditorUserId="630" LastEditDate="2015-02-06T12:25:17.977" LastActivityDate="2018-11-08T13:50:29.707" Title="arduino program got error expected //primary-expression before ')' token error: //expected ';' before '}' token E" Tags="|programming|sensors|arduino-yun|interrupt|string|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8473" PostTypeId="1" AcceptedAnswerId="8476" CreationDate="2015-02-06T09:29:49.943" Score="2" ViewCount="14971" Body="&lt;p&gt;I want to interface my barcode scanner with an Arduino using RS232. I have connected 2 (RX), 3 (TX) and 5 (GND) of the RS232 with the corresponding pins of MAX232. I am taking TTL outputs on Arduino pins 6 and 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code of the Arduino program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(6, 7); // RX, TX&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // run over and over&#xA;  if (mySerial.available()) {&#xA;    byte x = mySerial.read();&#xA;    Serial.println(x);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not getting any output on the serial monitor when I scan a product.&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="4628" LastEditDate="2016-03-17T18:13:51.970" LastActivityDate="2016-07-11T00:42:28.777" Title="How to get serial data in Arduino from a barcode scanner?" Tags="|serial|rs232|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8474" PostTypeId="2" ParentId="8468" CreationDate="2015-02-06T09:37:04.253" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Will a magnetometer give distorted values if there is a magnet near?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, effectively.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact no, as the reading it gives WILL BE the field at that point BUT the field will be distorted compared to what you would see when the magnet is absent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect of magnets at a distance is a somewhat complex subject - especially when there are several presnt and/or where ther are &quot;magnetic materials&quot; present but, as a guide.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;At a distance large compared with magnet dimensions the field falls as the cube (not square) of the distance.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Very rough but useful rule of thumb: A top-end rare earth magnet will produce a field of &lt;strong&gt;about&lt;/strong&gt; 1 Tesla at a distance of  1/2 it's thickness from the centre of its pole face. So eg a 20mm thick circular magnet will produce ABOUT 1 T at 10mm from the centre of its pole face. This is more useful in motor or alternator applications than when using magnetometers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-06T09:37:04.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8475" PostTypeId="2" ParentId="8025" CreationDate="2015-02-06T09:37:51.540" Score="1" Body="&lt;p&gt;You mean to say that you get proper reading when the surfaces are FLAT?&#xA;Ultrasonic sensors have this property that the waves emitted from then are only 15 degree from the line of sight, but this means that you can surely calculate distance of objects having a curved shape. The only condition is the object should be directly in a straight line&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-02-06T09:37:51.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8476" PostTypeId="2" ParentId="8473" CreationDate="2015-02-06T10:09:10.770" Score="7" Body="&lt;p&gt;Assuming your Arduino has only one hardware serial connection (it's something like an Uno rather than a Mega) you're quite right in using software serial, the Arduino will already be using pins 2 and 3 to communicate via USB to the Serial monitor so you can't use them to communicate with the scanner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However carefully look at your first line of code, you've asked software serial to use pins 6 &amp;amp; 7 yet hooked the barcode scanner to pins 2 &amp;amp; 3. Move those pins over to the one's you've specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly in your setup function you've begun communication with hardware Serial but not software serial. You'll need to add something like mySerial.begin(XXX) where XXX is the baud rate for the scanner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally you haven't told the Arduino what pinMode to use for 6 and 7. You'll want pinMode(6, INPUT) and pinMode(7, OUTPUT) in there too.&lt;/p&gt;&#xA;" OwnerUserId="7182" LastActivityDate="2015-02-06T10:09:10.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8477" PostTypeId="2" ParentId="8446" CreationDate="2015-02-06T10:17:20.040" Score="1" Body="&lt;p&gt;I might be missing the part of the hookup guide you're looking at but I can't see it being hooked up to 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &quot;Simple Hardware Hookup (I2C)&quot; section they show two possiblilities a 5V Arduino hooked up via a logic level converter and a 3.3V Arduino hooked up directly. The logic level converter will need a 5V &amp;amp; 3.3V connection from the Arduino, but not the IMU.&lt;/p&gt;&#xA;" OwnerUserId="7182" LastActivityDate="2015-02-06T10:17:20.040" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8478" PostTypeId="1" CreationDate="2015-02-06T12:00:18.283" Score="2" ViewCount="164" Body="&lt;p&gt;I have been tasked to find a way of communicating to a webservice from my microcontroller - yay!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With little-no real grasp on sms/etc (due to not ever 'using' it before), it appears that my knowledge of GPRS is, well, none existent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I've come here in hope that someone could tell me if there is such a way for a microcontroller to 'send data out' though, well, a 'sim card' via an sms message.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This has left me a little lost If i'm honest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project involves 'tracking' a vehicle (still working on finding a GPS module for that), and then sending the coordinates back to HQ at hourly intervals (via text message).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, My obvious question is this: &lt;em&gt;What GPRS sim card module will allow me to do this?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read &lt;a href=&quot;https://arduino.stackexchange.com/questions/1194/which-shield-to-use-for-gprs&quot;&gt;here&lt;/a&gt;, although the accepted answer there for a chip requires external power, and so is of no 'true' use to me as the whole unit needs to be powered and left 'unattended' for long hours at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;seeing as I also need to 'monitor current location' of the board, I am also in need to obtain a GPS location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking that mobile phones have both of these cababilitys - is this done with a 'sim card module', or is there a way of 'one module does both - send an sms AND can also gain current GPS location'?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Sorry if this is too broad, but I'm certainly not 'gifted' in knowing too much about these technologies (esp. when all these acronyms use similar letters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice / input here would be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="6801" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2017-12-08T03:11:47.083" Title="Board recommendations for GPRS/GSM for 'on the go'" Tags="|shields|gsm|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8479" PostTypeId="2" ParentId="8468" CreationDate="2015-02-06T12:51:24.923" Score="1" Body="&lt;p&gt;The IMU magnetometer is made to measure the magnetic filed of the earth, which magnitude is a few 10 - 60 uT (micro-Tesla). You cannot measure it near to a large magnet that may generate 1 T or more: the magnetometer will saturate.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-06T12:51:24.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8480" PostTypeId="1" AcceptedAnswerId="24680" CreationDate="2015-02-06T16:38:01.277" Score="-4" ViewCount="567" Body="&lt;p&gt;I want to connect 20 serial devices to the same Arduino Mega.How to do this?I know that multiplexing is the way but how to do that&lt;/p&gt;&#xA;" OwnerUserId="7136" LastActivityDate="2016-05-29T04:02:27.673" Title="How to connect twenty different serial devices to an Arduino Mega?" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8482" PostTypeId="2" ParentId="8470" CreationDate="2015-02-06T17:39:35.513" Score="4" Body="&lt;p&gt;At the top of your program you have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PulseSensorbegin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which defines &lt;code&gt;PulseSensorbegin&lt;/code&gt; as nothing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then later you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PulseSensorbegin();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which the pre-processor turns into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is where the error is occurring.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2015-02-06T17:39:35.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8483" PostTypeId="1" CreationDate="2015-02-06T18:33:53.193" Score="1" ViewCount="5326" Body="&lt;p&gt;Is it possible to connect 6 dc motors and 2 dc servo motors to an Arduino Uno? I intend to control the Uno with a Raspberry pi connected through USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming every motor to be bidirectional, how many L293 or L298 motor driver boards do I need? Is there any other better option than using multiple driver boards?&lt;/p&gt;&#xA;" OwnerUserId="7186" LastActivityDate="2021-08-11T20:03:10.303" Title="6 + 1 motors connected to an arduino uno?" Tags="|arduino-uno|motor|pins|servo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8486" PostTypeId="1" AcceptedAnswerId="8487" CreationDate="2015-02-07T01:02:41.993" Score="1" ViewCount="2145" Body="&lt;p&gt;I have developed a program and the idea is that when it receives serial data (any single character) it returns a single random number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it working but it returns 3 x random numbers one after another for each read that it does and I can't figure out why.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;char incomingByte = 10;&#xA;long randNumber;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);  &#xA; Serial.begin(9600);   &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;//  delay(1000);               // wait for a second&#xA;&#xA;   if (Serial.available() &amp;gt; 0) {&#xA;                // read the incoming byte:&#xA;                incomingByte = Serial.read();&#xA;                // say what you got:&#xA;              //  Serial.print(&quot;I received: &quot;);&#xA;&#xA;                randNumber = random(1, 2000);&#xA;                Serial.println('PL' + randNumber);&#xA;                  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;                  delay(1000);               // wait for a second&#xA;                  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1622" LastActivityDate="2015-02-07T01:07:07.787" Title="Writing serial data, just once after read" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8487" PostTypeId="2" ParentId="8486" CreationDate="2015-02-07T01:07:07.787" Score="5" Body="&lt;p&gt;When you enter a single character into the Serial Monitor and press Enter, three bytes are sent: the character, a carriage return, and a linefeed. &lt;code&gt;Serial.read()&lt;/code&gt; only reads a single byte, so data is available three times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either loop reading until no more bytes are available, check for and discard any CRs and LFs, or use a serial terminal that doesn't require pressing Enter to send data.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-07T01:07:07.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8490" PostTypeId="2" ParentId="8483" CreationDate="2015-02-07T10:14:53.613" Score="0" Body="&lt;p&gt;Normally a full H-bridge (for one motor in bi-directional mode) will need 3 ouput pins. You can potentially force the enable pin to a constant level but that means you will always draw current for your motors even when they don't move, which is probably not what you want. ou might also wire all 6 enable pins together to one Arduino pin just to control power of all motos altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, each servo will need one output pin (typically 9 and 10 for both servos). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence in the worst case, you would need 20 pins overall. You have them on Arduino UNO but this means you don't have anyhting else left, even Serial communication! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can wire all 6 enable pins together, then &lt;strong&gt;you will need &quot;only&quot; 15 pins&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note that if you want to &lt;strong&gt;control the speed of the DC motors&lt;/strong&gt;, you will need PWM pins, but then &lt;strong&gt;you won't get enough with a UNO&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding drivers ICs (&lt;strong&gt;L293 or L298&lt;/strong&gt;), each of them has 2 full H-bridges, hence can drive 2 DC motors in bi-directional mode, so &lt;strong&gt;you will need 3 of them overall&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-02-07T10:14:53.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8491" PostTypeId="2" ParentId="4767" CreationDate="2015-02-07T14:49:54.283" Score="1" Body="&lt;p&gt;A reed switch like this will not require any minimum voltage. It should work quite happily down to millivolt levels. If you want to switch on an LED from a 5V supply that is switched by the reed switch you will need a resistor that limits the current to no more than&#xA;20mA. The forward voltage drop over a red LED is around 2V so your resistor will drop 3V which means it needs to be at least about 150 ohms.&lt;/p&gt;&#xA;" OwnerUserId="7196" LastActivityDate="2015-02-07T14:49:54.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8492" PostTypeId="2" ParentId="4767" CreationDate="2015-02-07T17:46:05.850" Score="1" Body="&lt;p&gt;It says &quot;&lt;em&gt;maximum&lt;/em&gt; breakdown voltage: 250 V DC&quot;. That's maximum, not minimum. Above 250 V DC the arc which is created by an opening contact isn't guaranteed to extinguish. It's defined for DC voltage because then the arc remains; for AC the arc will extinguish automatically when the current crosses zero.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-07T17:46:05.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8493" PostTypeId="1" CreationDate="2015-02-07T19:31:58.373" Score="1" ViewCount="14617" Body="&lt;p&gt;I'm puzzled at the moment with which one to choose.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Form-factor plays a significant role in my project, so I prefer the smaller boards mentioned in the title to fuller boards like the UNO, MEGA, etc.&lt;/li&gt;&#xA;&lt;li&gt;I have an RC522 RFID read/write module and would like to use it without having to deal with level switching, as the RFID module requires 3.3V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What can you advise? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerDisplayName="elgolondrino" LastEditorUserId="10794" LastEditDate="2015-09-02T01:38:03.430" LastActivityDate="2015-09-02T01:38:03.430" Title="How to know which Arduino to choose: Nano, Micro or Pro Micro?" Tags="|arduino-nano|arduino-mini|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8494" PostTypeId="2" ParentId="8493" CreationDate="2015-02-07T19:46:02.283" Score="2" Body="&lt;p&gt;I'm currently using inexpensive Arduino Nano boards running GRBL for a couple of little CNC machines.  The version I have uses an ATmega328 running at 5V and they work &lt;em&gt;very&lt;/em&gt; well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They may be available with 3.3V regulator instead of 5V - I don't know and I preferred to have 5V anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nano boards that I have look to be a complete Arduino: one side of the board has the ATmega and voltage regulator, the other side of the board has the USB interface chip and some LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can purchase Chinese-made nano boards very inexpensively.  Look on eBay for sellers offering free International shipping.&lt;/p&gt;&#xA;" OwnerUserId="6854" LastActivityDate="2015-02-07T19:46:02.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8495" PostTypeId="2" ParentId="8067" CreationDate="2015-02-07T21:11:42.710" Score="1" Body="&lt;p&gt;If you are going to use an external LED, then using software to make the LED blink when the RX or TX line is busy is a waste of your CPU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, simply connect the LED to the RX or TX line using a transistor as a buffer to prevent the current draw from messing with the serial signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To borrow an image from &lt;a href=&quot;https://electronics.stackexchange.com/a/42589&quot;&gt;this answer&lt;/a&gt; to &lt;a href=&quot;https://electronics.stackexchange.com/questions/42581/attaching-a-led-to-pics-rx-pin&quot;&gt;a similar question&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/boiiA.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try omitting the transistor buffer, but the serial waveform will be altered, possibly to the point where data becomes corrupted. The transistor prevents the current draw of the LED and resistor from loading down the RX or TX lines.&lt;/p&gt;&#xA;" OwnerUserId="7199" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-07T21:17:45.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8496" PostTypeId="2" ParentId="4679" CreationDate="2015-02-07T21:30:35.787" Score="2" Body="&lt;p&gt;The wiring is correct, but &lt;code&gt;inPin&lt;/code&gt; in your code is set to &lt;code&gt;2&lt;/code&gt;, which is &lt;a href=&quot;http://arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;D4&lt;/code&gt; on the Nano&lt;/a&gt;, while you have your signal wires going to &lt;code&gt;D7&lt;/code&gt; and &lt;code&gt;D6&lt;/code&gt; in your schematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, &lt;code&gt;outPin&lt;/code&gt; is set to &lt;code&gt;13&lt;/code&gt; in your code, which is &lt;code&gt;D9&lt;/code&gt; on the Nano, but your schematic shows the LEDs connected to &lt;code&gt;D5&lt;/code&gt; and &lt;code&gt;D4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also put the resistor going from the other pin on the switch to 5V, having the digital input connected directly to GND, but I'm not sure if that will affect power consumption, so it's probably more just a matter of personal preference.&lt;/p&gt;&#xA;" OwnerUserId="7199" LastActivityDate="2015-02-07T21:30:35.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8497" PostTypeId="2" ParentId="8483" CreationDate="2015-02-07T22:23:37.167" Score="2" Body="&lt;p&gt;TI is only one of the many manufacturers who make some really nice motor control chips.  The  DRV8835 is one such device: it will drive two motors at voltages up to 11 Vdc at currents up to 1.2 Amps each.  Each channel requires two control lines: enable and direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.pololu.com/product/2135&quot; rel=&quot;nofollow&quot;&gt;Pololu&lt;/a&gt; sells this chip already mounted to a carrier board for a rational price.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need a total of (6 motors * 2 lines per motor) = 12 i/o lines PLUS two more lines to control your servos for a total of 14 i/o lines from your controller.&lt;/p&gt;&#xA;" OwnerUserId="6854" LastActivityDate="2015-02-07T22:23:37.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8498" PostTypeId="2" ParentId="804" CreationDate="2015-02-07T23:35:31.260" Score="2" Body="&lt;p&gt;I also had that error message. I think there are many possible causes, so I haste to specify my special case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a hackintosh with OS X Yosemite 10.10.2, Arduino software 1.0.6 and Funduino UNO. Uploading the example for Serial.write() succeeded the first time. Thereafter most uploads failed. Even when the upload succeeded the serial monitor would not always show output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seemed to me to be due to miscommunication on the USB port. I had to repeatedly reset the funduino, unplug and replug the USB cable or even restart the system. When replugging the USB cable sometimes my system would freeze.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By googling I found a solution to &quot;Inserting USB device causes Mavericks 10.9.1 to freeze&quot;.&#xA;Answer no 12 on tonymacx86.com basically instructs you to remove GenericUSBXHCI.kext from /System/Library/Extensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am happy to report that after removing this kext I have no problems uploading the example and monitoring the output. Because I don't need to replug the USB cable I don't know whether this solves my system freeze. I'm not even sure it was a system freeze, because my system may only have become unresponsive to my USB keyboard and mouse.&lt;/p&gt;&#xA;" OwnerUserId="7200" LastEditorUserId="7200" LastEditDate="2015-02-07T23:50:23.067" LastActivityDate="2015-02-07T23:50:23.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8499" PostTypeId="1" CreationDate="2015-02-07T23:54:12.950" Score="-1" ViewCount="716" Body="&lt;p&gt;The basic question - is BOSSA the right SOFTWARE  &quot;tool&quot; to use in ATmel Studio to &lt;strong&gt;connect / download to Arduino DUE AND NOT using VisualMicro&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot get BOSSA to AUtoScan for COM port.&#xA;Getting error &quot;Could not find a device&quot; &#xA;When I select my COM port ( COM4 ) which works in Arduino IDE&#xA;I get &quot;Could not connect to device on COM4&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tells me that ATmel Studio does not recognize my Due at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please advise me what did I missed in configuring the Studio?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can use Studio to run Arduino IDE (VisualMicro ) but I need to get away from Arduino IDE environment.&#xA;Thanks for your time. &lt;/p&gt;&#xA;" OwnerUserId="7201" LastActivityDate="2015-11-10T07:01:25.527" Title="Learning to use ATmel Studio - using BOSSA downloader" Tags="|atmel-studio|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8501" PostTypeId="1" CreationDate="2015-02-08T01:23:51.353" Score="2" ViewCount="177" Body="&lt;p&gt;Using Arduino IDE, how do I program the &lt;a href=&quot;http://www.seeedstudio.com/wiki/Bluetooth_Bee-Standalone&quot; rel=&quot;nofollow&quot;&gt;Bluetooth Bee Standalone&lt;/a&gt;?  I can't select that particular board from the list under &lt;code&gt;Tools -&amp;gt; Board&lt;/code&gt;.  The closest I see is Arduino Fio.&lt;/p&gt;&#xA;" OwnerUserId="7205" LastActivityDate="2015-02-08T01:23:51.353" Title="Use Arduino IDE to program Bluetooth Bee standalone" Tags="|bluetooth|arduino-ide|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8502" PostTypeId="1" AcceptedAnswerId="8529" CreationDate="2015-02-08T02:07:13.630" Score="0" ViewCount="2568" Body="&lt;p&gt;I'll be teaching a year 10 class on the Intel Galileo gen2 and there'll be a wide (but high-level) programming curriculum, which includes introduction to console printing, using &lt;code&gt;Serial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like the students to be able to write their printing code in &lt;code&gt;setup()&lt;/code&gt; so that it's only printed once and easily readable by them. However, it's impossible to be fast enough to upload a sketch and open the Serial Monitor (which flat out refuses to open before the sketch has started), and the Serial Monitor closes itself upon re-uploading code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without unnecessary (and potentially for the students, confusing) use of the &lt;code&gt;delay&lt;/code&gt; function in &lt;code&gt;setup()&lt;/code&gt;, it's impossible to read any output originating from &lt;code&gt;setup()&lt;/code&gt;; only things printed in &lt;code&gt;loop()&lt;/code&gt; (which are constantly re-printed) are ever discoverable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So; is there a way to somehow keep the Serial Monitor open, or make it capture output from before it's opened, or delay the entire running of the sketch (rather than chucking in delays)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'll be using the standard Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This script was run in one of two conditions...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  // ensure Serial is ready&#xA;  delay(1000);&#xA;&#xA;  for (int i=0; i &amp;lt; 10000; i++) {&#xA;    Serial.println(i);&#xA;  }&#xA;}&#xA;&#xA;void loop() {      &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the Serial Monitor was opened &lt;strong&gt;immediately&lt;/strong&gt; after upload, all numbers from and including 0 to 9999 were recorded in the monitor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the Serial Monitor was opened around 5s &lt;strong&gt;after&lt;/strong&gt; upload, only numbers upward of 2243 were observed. This suggests the sketch WAS being re-run (else no numbers would have been captured; the sketch runs in significantly less time than 5s) but that all numbers between 0 and 2243 were not captured by the monitor; as if opening the Serial Monitor late enough to cause a re-run causes some monitor overhead.&lt;br&gt;&#xA;This strange loss of numbers is NOT time dependent: increasing the initial delay from 1s to 4s (and waiting longer after upload before opening the Serial) did not at all vary the soonest number recorded, suggesting it is some 'line' based overhead&#xA;(but of course, how could anything fail for 2243 lines?!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that mystery aside, this negates the automatic re-running of the sketch upon Serial Monitor opening from being actually useful.&lt;/p&gt;&#xA;" OwnerUserId="6900" LastEditorUserId="6900" LastEditDate="2015-02-08T11:57:35.953" LastActivityDate="2015-02-09T16:47:56.257" Title="How to prevent the Serial Monitor from closing upon re-uploading sketch?" Tags="|serial|arduino-ide|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8503" PostTypeId="2" ParentId="525" CreationDate="2015-02-08T02:16:48.307" Score="0" Body="&lt;p&gt;I have several old mini-pci mini-pcie wifi cards laying around and the poster is correct: for some reason, they put the female end on the board whereas any wifi antenna you pull from a laptop, the cable will be female; all of my cards are the male version of the port on the YUN. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can actually snap my old wifi cards onto the YUN's antenna port and they snap together perfectly just like the cable does in the laptops they belong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For hobbyists, an old laptop wifi antennas are something we all have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why they did this I don't know.&lt;/p&gt;&#xA;" OwnerUserId="7206" LastEditorUserId="84" LastEditDate="2015-02-08T09:13:55.753" LastActivityDate="2015-02-08T09:13:55.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8504" PostTypeId="1" AcceptedAnswerId="8506" CreationDate="2015-02-08T03:15:01.573" Score="0" ViewCount="7868" Body="&lt;p&gt;I wish to use a MOSFET to drive a 12V rated LED strip from an Arduino.&lt;br&gt;&#xA;The negative side of the LED strip must be connected to ground, so that means that the driving MOSFET must be between +12V and the LED strip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have tried so far. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T4jlD.png&quot; alt=&quot;led strip mosfet arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;&lt;em&gt;load must be between&lt;/em&gt;&lt;/strong&gt; my &lt;strong&gt;&lt;em&gt;mosfet&lt;/em&gt;&lt;/strong&gt; and my car battery &lt;strong&gt;&lt;em&gt;GND&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7203" LastEditorUserId="6959" LastEditDate="2015-02-08T14:46:33.237" LastActivityDate="2015-02-09T07:06:12.903" Title="Using an Arduino to switching a grounded load powered by a 12 Volt supply" Tags="|mosfet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8505" PostTypeId="1" CreationDate="2015-02-08T03:13:33.900" Score="1" ViewCount="970" Body="&lt;p&gt;I am having a problem with Servo Buzz that I have ascertained is from the &lt;code&gt;millis()&lt;/code&gt; function using too much time for Arduino to generate a steady pulse for the servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at this thread but was unable to figure out a solution from the code (I'm a novice)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/77502/is-there-a-way-to-stop-servos-from-shaking?newreg=bc15727ab5ef45e38e50d8f02faf70de&quot;&gt;Stack Exchange Servo Buzz&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am including my code even though it is very large, the only time I &lt;strong&gt;need&lt;/strong&gt; to servos to run smoothly is in &lt;code&gt;case 4&lt;/code&gt; of my &lt;code&gt;switch/case&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt; //LIBRARY FOR MOTOR DRIVER SHIELD&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;#include &amp;lt;Servo.h&amp;gt; //LIBRARY FOR SERVOS&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); &#xA;Adafruit_StepperMotor *myStepper = AFMS.getStepper(200, 2);&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;#define WHITE 0x7&#xA;&#xA;&#xA;Servo pan;&#xA;Servo tilt;//DECLARE SERVOS&#xA;int yy = 0; //STEP COUNTER&#xA;//declares ints&#xA;uint8_t i=0; //BUTTON INPUTS&#xA;int x = 1; //case statement movement&#xA;int input_stage = 0;&#xA;int time = millis(); //time from when the thing turned on&#xA;&#xA;//user inputs&#xA;int total_hour = 0;&#xA;int total_minute = 0;&#xA;int slide_min = 0;&#xA;int slide_max = 0;&#xA;int pan_min = 800 ;&#xA;int pan_max = 2200;&#xA;int tilt_min = 800;&#xA;int tilt_max = 2200;&#xA;&#xA;&#xA;//Integers used for calculations for later&#xA;int total_steps = yy;&#xA;long total_time = 0;&#xA;long step_duration = 0;&#xA;int total_pan = 0;&#xA;int total_tilt = 0;&#xA;long pan_duration = 0;&#xA;long tilt_duration = 0;&#xA;long step_millis = 0;&#xA;long pan_millis = 0;&#xA;long tilt_millis = 0;&#xA;int step_percent = 0;&#xA;&#xA;// Integers for real time program sliding action&#xA;int cur_step = 0;&#xA;int pan_pos = 0;&#xA;int tilt_pos = 0;&#xA;long run_dur = 0;&#xA;long start_time = 0;&#xA;int total_slide = 0;&#xA;long display_refresh = millis();&#xA;long display_dur = 1000;&#xA;int d = 1;&#xA;long end_time = millis();&#xA;int m = 0;&#xA;&#xA;void setup(){  &#xA;  lcd.begin(16, 2);&#xA;  lcd.setBacklight(WHITE);&#xA;  lcd.print(&quot;Welcome to LapsR&quot;);//initialize&#xA;  delay(2000);&#xA;&#xA;  AFMS.begin();  //initialize motor shield&#xA;  pan.attach(10); //attach servos to pins&#xA;  tilt.attach(9);&#xA;&#xA;  myStepper-&amp;gt;setSpeed(30); // set speed&#xA;&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;By Doug E FresH!&quot;);&#xA;  delay(2500);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Thanks to: Dave&quot;);&#xA;  delay(2000);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Thanks to:  Max&quot;);&#xA;  delay(2000);&#xA;  pan.writeMicroseconds(1500); //set pan and tilt servos to centre ish&#xA;  tilt.writeMicroseconds(1500); &#xA;  delay(5000);&#xA;  pan.writeMicroseconds(1000); //Jitter Test&#xA;  tilt.writeMicroseconds(1000); &#xA;  delay(5000);&#xA;  pan.writeMicroseconds(2000); //Jitter Test&#xA;  tilt.writeMicroseconds(2000); &#xA;  delay(5000);&#xA;}&#xA;&#xA;void loop(){  &#xA;  uint8_t buttons = lcd.readButtons();  //read lcd buttons&#xA;  lcd.blink(); //set cursor to blink&#xA;  int limit1 = 4;  //declare limit switch&#xA;  pinMode(limit1, INPUT_PULLUP);  // sets pin mode to button&#xA;&#xA;&#xA;&#xA;  //begin case statement&#xA;  switch(x){&#xA;  case 1:&#xA;&#xA;   if(m==0){ //move slider backwards until it finds a limit switch&#xA;    if((digitalRead(limit1) == HIGH)){ // digital read reads the limit switch pin - HIGH means the switch is open &#xA;      myStepper-&amp;gt;step(2,BACKWARD,DOUBLE);&#xA;      lcd.clear();&#xA;      lcd.print(&quot;stage 1&quot;);&#xA;      delay(10);   &#xA;    }&#xA;    else{ //move to the next step&#xA;      myStepper-&amp;gt;release(); //release motor&#xA;      m = 1; //set program to 2nd stage&#xA;    }&#xA;  }&#xA;  if(m==1){ // moving ahead jus a bit so there is some pad for innacuracy&#xA;    yy = 50; //step counter is initialized&#xA;    lcd.clear();&#xA;    lcd.print(&quot;stage 2&quot;);&#xA;    delay(1000); &#xA;    myStepper-&amp;gt;step(50,FORWARD,SINGLE); //move forward 50 steps&#xA;    m = 2;//move to the next step&#xA;  } &#xA;  if(m==2){ //stage 3 dawg&#xA;    if((digitalRead(limit1) == HIGH)){//count steps til limit is hit&#xA;      myStepper-&amp;gt;step(1,FORWARD,SINGLE);//move forward 1 step&#xA;      lcd.clear();&#xA;      lcd.print(&quot;stage 3&quot;);   &#xA;      yy++; //step counter move up one&#xA;      delay(10); &#xA;    }&#xA;    else{  //display step percentage and total steps&#xA;      x=2;&#xA;      lcd.clear();&#xA;      lcd.print(&quot;step %&quot;);lcd.print((yy-100)/100);&#xA;      delay(5000);&#xA;      lcd.clear();&#xA;      lcd.print(&quot;total: &quot;);lcd.print(yy-100);&#xA;      delay(5000);&#xA;&#xA;      myStepper-&amp;gt;step((yy - 50),BACKWARD,SINGLE); // reset to start position (minus 50 steps for pad)&#xA;      myStepper-&amp;gt;release(); // release motor&#xA;      step_percent = (yy-100)/100; //make calculations&#xA;      total_steps = yy-100;&#xA;    }&#xA;  }  &#xA;&#xA;&#xA;break;&#xA;&#xA;  case 2:&#xA;&#xA;    if(input_stage == 0){ //enter duration&#xA;      if(d==1){&#xA;        lcd.clear();&#xA;        lcd.print(&quot;Total Duration?&quot;);//start asking for inputs - start with total overall duration hours&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;H: &quot;);&#xA;        lcd.print(total_hour);&#xA;        lcd.print(&quot;  M: &quot;);&#xA;        lcd.print(total_minute);&#xA;        lcd.setCursor(3,1);&#xA;        display_refresh = millis();&#xA;        d = 0;&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_UP) {  //sets hour up - slight debounce delay&#xA;        total_hour = total_hour++;&#xA;        delay(250);&#xA;        d=1;&#xA;      }  &#xA;      if (buttons &amp;amp; BUTTON_DOWN) { //sets hour down &#xA;        total_hour = total_hour--;&#xA;        delay(250);&#xA;        d = 1;&#xA;      }   &#xA;      if (buttons &amp;amp; BUTTON_SELECT){&#xA;        input_stage++;delay(250); //select button moves to next stage&#xA;        lcd.clear();&#xA;        d=1;&#xA;      }&#xA;    }  &#xA;    if(input_stage == 1){&#xA;      uint8_t buttons = lcd.readButtons();&#xA;      if(d==1){  //when d == 1 update display&#xA;        lcd.clear();&#xA;        lcd.print(&quot;Total Duration?&quot;);//ask for minutes&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;H: &quot;);&#xA;        lcd.print(total_hour);&#xA;        lcd.print(&quot;  M: &quot;);&#xA;        lcd.print(total_minute);&#xA;        lcd.setCursor(9,1);&#xA;        d=0;&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_UP) {&#xA;        total_minute = total_minute++;  //set minutes&#xA;        delay(100);&#xA;        d=1;&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_DOWN) {&#xA;        total_minute = total_minute--; //set minutes&#xA;        d=1;&#xA;        delay(100);&#xA;      }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){&#xA;       input_stage++; // select moves to next stage&#xA;       delay(250);&#xA;       lcd.clear();&#xA;       d=1;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--; //back moves to previous stage&#xA;       delay(250);&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 2){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.clear();&#xA;       lcd.print(&quot;Slide%start-fin&quot;);//ask for minimum slide percentage&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(slide_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(slide_max);&#xA;       lcd.setCursor(3,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP &amp;amp;&amp;amp; slide_min &amp;lt; 100) {&#xA;       slide_min = slide_min++; // select start position in percentgae&#xA;       d=1;&#xA;       delay(100);&#xA;       myStepper-&amp;gt;step(step_percent, FORWARD, DOUBLE); //move forward one percent - allows user to preview positions&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN &amp;amp;&amp;amp; slide_min &amp;gt; 1) { // do not allow motor to move below 0 percent&#xA;       slide_min = slide_min--;&#xA;       myStepper-&amp;gt;step(step_percent, BACKWARD, DOUBLE);//move forward one percent - allows user to preview positions&#xA;       d=1;&#xA;       delay(100);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){ //moves to next stage&#xA;       input_stage++;&#xA;       delay(250);&#xA;       lcd.clear();&#xA;       slide_max = slide_min; //sets ending position to set min position&#xA;       d=1;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--;delay(250); // previous stage&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 3){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.clear();&#xA;       lcd.print(&quot;Slide%start-fin&quot;);//ask for max slide percentage&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(slide_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(slide_max);&#xA;       lcd.setCursor(9,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP &amp;amp;&amp;amp; slide_max &amp;lt; 100) {&#xA;       slide_max = slide_max++;&#xA;       d=1;delay(100);&#xA;       myStepper-&amp;gt;step(step_percent, FORWARD, DOUBLE);  //shows set stepper position&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN  &amp;amp;&amp;amp; slide_max &amp;gt; 1) {&#xA;       slide_max = slide_max--;&#xA;       myStepper-&amp;gt;step(step_percent, BACKWARD, DOUBLE);&#xA;       d=1;&#xA;       delay(100);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){ //moves to next stage&#xA;       input_stage++;&#xA;       delay(250);&#xA;       lcd.clear();&#xA;       myStepper-&amp;gt;step((step_percent*slide_max), BACKWARD, DOUBLE); //sets platform back to home position&#xA;       d=1;&#xA;       myStepper-&amp;gt;release(); &#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--; //moves to previous stage&#xA;       delay(250);&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 4){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.clear();&#xA;       lcd.print(&quot;Pan start-fin&quot;);//ask for min pan&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(pan_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(pan_max);&#xA;       lcd.setCursor(3,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP) {&#xA;       pan_min = pan_min + 10;  //sets displays pan parameters&#xA;       pan.writeMicroseconds(pan_min);&#xA;       d=1;&#xA;       delay(10);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN) {&#xA;       pan_min = pan_min - 10;&#xA;       d=1;&#xA;       delay(10);&#xA;       pan.writeMicroseconds(pan_min);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){&#xA;       input_stage++;&#xA;       delay(50);      &#xA;       lcd.clear();&#xA;       pan_max=pan_min; //sets max to min to not cause a brownout&#xA;       d=1;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--;&#xA;       delay(50);&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 5){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.clear();&#xA;       lcd.print(&quot;Pan start-fin&quot;);//ask for max pan&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(pan_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(pan_max);&#xA;       lcd.setCursor(9,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP) {&#xA;       pan_max = pan_max + 10;&#xA;       d=1;&#xA;       delay(10);&#xA;       pan.writeMicroseconds(pan_max);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN) {&#xA;       pan_max = pan_max - 10;&#xA;       pan.writeMicroseconds(pan_max);&#xA;       d=1;&#xA;       delay(10);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){&#xA;       input_stage++;&#xA;       delay(250);&#xA;       lcd.clear();&#xA;       d=1;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--;&#xA;       delay(250);&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 6){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.clear();&#xA;       lcd.print(&quot;tilt start-fin&quot;);//ask for min tilt&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(tilt_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(tilt_max);&#xA;       lcd.setCursor(3,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP) {&#xA;       tilt_min = tilt_min + 10;&#xA;       d=1;&#xA;       delay(10);&#xA;       tilt.writeMicroseconds(tilt_min);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN) {&#xA;       tilt_min = tilt_min - 10;&#xA;       tilt.writeMicroseconds(tilt_min);&#xA;       d=1;&#xA;       delay(10);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_SELECT){&#xA;       input_stage++;&#xA;       delay(250);&#xA;       tilt_max=tilt_min;&#xA;       lcd.clear();&#xA;       d=1;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_LEFT){&#xA;       input_stage--;&#xA;       delay(250);&#xA;       d=1;&#xA;     }&#xA;   }&#xA;   if(input_stage == 7){&#xA;     uint8_t buttons = lcd.readButtons();&#xA;     if(d==1){&#xA;       lcd.print(&quot;tilt start-fin&quot;);//ask for max tilt&#xA;       lcd.setCursor(0, 1);&#xA;       lcd.print(&quot;S: &quot;);&#xA;       lcd.print(tilt_min);&#xA;       lcd.print(&quot;  F: &quot;);&#xA;       lcd.print(tilt_max);&#xA;       lcd.setCursor(9,1);&#xA;       d=0;&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_UP) {&#xA;       tilt_max = tilt_max + 10;&#xA;       tilt.writeMicroseconds(tilt_max);&#xA;       d=1;&#xA;       delay(10);&#xA;     }&#xA;     if (buttons &amp;amp; BUTTON_DOWN) {&#xA;       tilt_max = tilt_max - 10;&#xA;       delay(10);      &#xA;       tilt.writeMicroseconds(tilt_max);&#xA;       d=1;&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_SELECT){&#xA;        input_stage++;delay(250);&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_LEFT){&#xA;        input_stage--;delay(250);&#xA;      }&#xA;    }&#xA;    if(input_stage == 8){   //confirm parameters&#xA;      lcd.noBlink();&#xA;      uint8_t buttons = lcd.readButtons();&#xA;      lcd.clear();&#xA;      lcd.print(&quot;SL: &quot;);&#xA;      lcd.print(slide_min);&#xA;      lcd.print(&quot; - &quot;);&#xA;      lcd.print(slide_max);&#xA;      lcd.setCursor(0,1);&#xA;      lcd.print(&quot;PN: &quot;);&#xA;      lcd.print(pan_min);&#xA;      lcd.print(&quot; - &quot;);&#xA;      lcd.print(pan_max);&#xA;      delay(2500);&#xA;      lcd.clear();&#xA;      lcd.print(&quot;TI: &quot;);&#xA;      lcd.print(tilt_min);&#xA;      lcd.print(&quot; - &quot;);&#xA;      lcd.print(tilt_max);&#xA;      lcd.setCursor(0,1);&#xA;      lcd.print(&quot;Dur: &quot;);&#xA;      lcd.print(total_hour);&#xA;      lcd.print(&quot;:&quot;);&#xA;      lcd.print(total_minute);&#xA;      delay(2500);&#xA;      lcd.clear();&#xA;      lcd.print(&quot;Left for back&quot;);&#xA;      lcd.setCursor(0,1);&#xA;      lcd.print(&quot;Select to go&quot;);&#xA;      delay(2500);&#xA;      if (buttons &amp;amp; BUTTON_SELECT){&#xA;        x = 3; //if user is happy with set parametres - continue to run move program&#xA;      }&#xA;      if (buttons &amp;amp; BUTTON_LEFT){&#xA;        input_stage--;delay(50); // if user made a mistake they can press left to go back&#xA;      }&#xA;    }&#xA;&#xA;break;&#xA;&#xA;    case 3:&#xA;&#xA;    //calculate moving time durations&#xA;    total_time = total_hour*60;&#xA;    total_time = total_time + total_minute;&#xA;    total_time = total_time*60000;&#xA;    total_slide = slide_max - slide_min;&#xA;    step_duration = total_time/(total_slide*step_percent);&#xA;    total_pan = pan_max - pan_min;&#xA;    total_tilt = tilt_max - tilt_min;&#xA;    pan_duration = total_time/total_pan;&#xA;    tilt_duration = total_time/total_tilt;&#xA;&#xA;    //display values for debuging&#xA;    lcd.clear();&#xA;    lcd.print(&quot;total time&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(total_time);&#xA;    delay(5000);    &#xA;    lcd.clear();&#xA;    lcd.print(&quot;total slide&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(total_slide);&#xA;    delay(5000);    &#xA;    lcd.clear();&#xA;    lcd.print(&quot;step duration&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(step_duration);&#xA;    delay(5000);    &#xA;    lcd.clear();&#xA;    lcd.print(&quot;total pan&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(total_pan);&#xA;    delay(5000);    &#xA;    lcd.clear();&#xA;    lcd.print(&quot;total tilt&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(total_tilt);&#xA;    delay(5000);  &#xA;    lcd.clear();&#xA;    lcd.print(&quot;pan duration&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(pan_duration);&#xA;    delay(5000);    &#xA;    lcd.clear();&#xA;    lcd.print(&quot;tilt duration&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(tilt_duration);&#xA;    delay(5000); &#xA;    step_millis = millis();&#xA;    pan_millis = millis();&#xA;    tilt_millis = millis();&#xA;    pan_pos = pan_min;&#xA;    pan.write(pan_pos);&#xA;    tilt_pos = tilt_min;&#xA;    tilt.write(tilt_min);&#xA;&#xA;&#xA;    //sets pedestal to user input slide min position&#xA;    myStepper-&amp;gt;step((step_percent*slide_min), FORWARD, DOUBLE);&#xA;    x = 4;&#xA;    start_time = millis();&#xA;    end_time = millis() + total_time;&#xA;&#xA;break;&#xA;&#xA;    case 4:&#xA;    long remaining = end_time - millis(); //make a couple of run time calculations&#xA;    run_dur = millis() - start_time;&#xA;&#xA;    if(millis() - step_millis &amp;gt; step_duration){ //take one step after step duration&#xA;      myStepper-&amp;gt;step(1, FORWARD, SINGLE);&#xA;      cur_step++;&#xA;      step_millis = millis();  //resets step duration&#xA;      myStepper-&amp;gt;release(); &#xA;    }&#xA;    if(millis() - pan_millis &amp;gt; pan_duration){ //same as slide&#xA;      pan_pos++;&#xA;      pan.writeMicroseconds(pan_pos);&#xA;      pan_millis = millis();&#xA;    }&#xA;    if(millis() - tilt_millis &amp;gt; tilt_duration){//same as slide&#xA;      tilt_pos++;&#xA;      tilt.writeMicroseconds(tilt_pos);&#xA;      tilt_millis = millis();&#xA;    }&#xA;   if(run_dur &amp;gt; total_time){   //resets to top of user input once total duration runs out&#xA;     x = 0;&#xA;     input_stage = 0;&#xA;     myStepper-&amp;gt;step(cur_step, BACKWARD, DOUBLE); //sets motor back to home position&#xA;     myStepper-&amp;gt;release(); //release motor&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Doug Lenz" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-08T09:39:16.357" Title="Servo Buzz / millis()" Tags="|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8506" PostTypeId="2" ParentId="8504" CreationDate="2015-02-08T08:23:23.470" Score="2" Body="&lt;p&gt;In your existing arrangement.&lt;/p&gt;&#xA;&lt;p&gt;Swap to P Channel FET&lt;br /&gt;&#xA;Swap drain and source leads (right hand two).&lt;/p&gt;&#xA;&lt;p&gt;This will work for up to 5V feed to LEDs.&lt;/p&gt;&#xA;&lt;p&gt;To get 12v operation you will need to add a driver between the FET gate and the Arduino.&lt;br /&gt;&#xA;see circuit diagram below.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To operate with FET on the HIGH (V+) side when V+ is greater than the rduino's supply voltage, the FET must either&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Be P Channel with FET source to +12V and FET drain to load+ or&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;An N Channel with gate drive above V+.&lt;/p&gt;&#xA;&lt;p&gt;The gate drive to the FET must go to about +12V to turn it off.&lt;br /&gt;&#xA;The Arduino will only drive it to +5V.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you are unlikely to want to provide an extra high side drive the P channel option is preferred. This could be eg:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &amp;quot;jellybean&amp;quot; bipolar transistor or small FET worth a few cents) and a few resistors, or a small N Channel MOSFET and one resistor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An opto isolator.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Transistor driver:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Bipolar transistor NPN (BC337 / BC817 or similar)(ANYTHING NPN will work).&lt;br /&gt;&#xA;R1 = 10k resistor Arduino out to base.&lt;br /&gt;&#xA;R2 = 10k FET gate to +12.&lt;/p&gt;&#xA;&lt;p&gt;If an N Channel MOSFET is used for Q1 then R1 is not needed.&lt;/p&gt;&#xA;&lt;p&gt;This could be a  &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/EN6559-D.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;5LN01SP&lt;/a&gt; IF you can get them - no stock Digikey.These have a very low Vgsth (turn on voltage)&lt;/p&gt;&#xA;&lt;p&gt;Otherwise you can use a 2n2222, VN2222, BS108 or similar logic-gate N channel MOSFET.&lt;br /&gt;&#xA;eg &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/VN2222LL-D.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;VN2222&lt;/a&gt;. Many variants of these are widely available and low cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OQdAa.png&quot; alt=&quot;schematic&quot; /&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fOQdAa.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-02-09T07:06:12.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8507" PostTypeId="2" ParentId="8505" CreationDate="2015-02-08T09:39:16.357" Score="1" Body="&lt;p&gt;You're calling &lt;code&gt;millis()&lt;/code&gt; a lot in &lt;code&gt;case 4&lt;/code&gt;. A very simple improvement would be to call it once at the start of &lt;code&gt;loop()&lt;/code&gt;, storing the result in a variable. Throughout the rest of the function, simply use the value stored in that variable instead of calling &lt;code&gt;millis()&lt;/code&gt; directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt it will solve the problem entirely, but hopefully it will improve it a little.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-08T09:39:16.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8508" PostTypeId="1" CreationDate="2015-02-08T10:41:11.737" Score="5" ViewCount="9830" Body="&lt;p&gt;I started with building of the wireless temp/hygro/other values probes. I use 2 arduinos, both with nf24l01+ wireless transceivers, library used is rf24.h (&lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/maniacbug/RF24&lt;/a&gt;). Basically ping/pong test works for me - so each arduino communicates properly via nrf24l01+.&#xA;I added dht22 temperature sensor and just for testing I started with sending structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct{&#xA;  int A; // just counter to see if receiving new data&#xA;  float B; // temperature&#xA;} data;&#xA;&#xA;data payload;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I send it from Arduino1 like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.write( &amp;amp;payload, sizeof(payload) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other Arduino2 receives the payload:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.read( &amp;amp;payload, sizeof(payload) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This works perfectly and I am able to print the counter value as well as the temperature value&lt;/strong&gt; on the oled display o Arduino2. &lt;strong&gt;The problem is when I add float C to the struct for sending/receiving hygrometer values.&lt;/strong&gt; Then Arduino2 does not receive/display any valid hygro value, but there is just value of 0.00.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I know where my problem is - nrf24.h has possibility to set payload size for nrf24l01+ - both Arduinos have to use the same payload size (default is 16, min is 8, max is 32). I use 8 - as this looks to be the most reliable value when using larger distances between Arduinos.&#xA;When I tried to set payload size to 32 on both Arduinos:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.setPayloadSize(32);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it works and I can receive and display counter, temp, hygro values.&#xA;So it looks the nrf24l01+ sends a payload of either 8 or 32 bytes and when sending struct with INT, FLOAT, FLOAT - 8 bytes is not sufficient and 32 bytes of payload is needed. But when I will use many other values, I can reach also limit of 32 bytes payload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have much skills in C programming and also I do not fully understand how data packets are being transferred between nrf24l01+ modules- maybe I just need to adapt my send/receive code to handle sending of the larger structures. Maybe somebody could give me a hint.&lt;/p&gt;&#xA;" OwnerUserId="7209" LastEditorUserId="7209" LastEditDate="2015-02-08T10:54:50.850" LastActivityDate="2015-12-14T09:17:26.843" Title="Sending large structs via nrf24l01 leads to cliping of some structs members" Tags="|nrf24l01+|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8509" PostTypeId="1" CreationDate="2015-02-08T15:49:13.730" Score="2" ViewCount="2516" Body="&lt;p&gt;I'm trying to read a small file off the SD card installed in a Yun. Here's the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#include &amp;lt;FileIO.h&amp;gt;&#xA;&#xA;#define WIDTH 32&#xA;#define HEIGHT 1&#xA;#define NUM_LEDS (WIDTH * HEIGHT)&#xA;&#xA;#define DATA_PIN 9&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  FastLED.addLeds&amp;lt;WS2812B, DATA_PIN, GRB&amp;gt;(leds, NUM_LEDS);&#xA;  Bridge.begin();&#xA;  Serial.begin(115200);&#xA;  FileSystem.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  File f = FileSystem.open(&quot;/mnt/sd/single-line-testpattern.ppm&quot;, FILE_READ);&#xA;  f.seek(29); // seek past the header bytes&#xA;  Serial.print(&quot;position = &quot;); Serial.println(f.position());&#xA;  for (int i = 0; i &amp;lt; NUM_LEDS; i++) {&#xA;    uint8_t r = f.read();&#xA;    uint8_t g = f.read();&#xA;    uint8_t b = f.read();&#xA;    Serial.print(&quot;r = &quot;); Serial.print(r, HEX);&#xA;    Serial.print(&quot;, g = &quot;); Serial.print(g, HEX);&#xA;    Serial.print(&quot;, b = &quot;); Serial.println(b, HEX);    &#xA;    leds[i] = CRGB(r, g, b);&#xA;  }&#xA;  f.close();&#xA;  FastLED.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the contents of the PPM file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;50 36 0A 23 20 3A 20 62 79 20 54 6F 79 56 69 65 77 65 72 0A 33 32 20 31 20 32 35 35 0A FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks pretty straightforward to me, but the output I'm getting is absolutely baffling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;position = 5888&#xA;r = 6, g = A9, b = A&#xA;r = B9, g = 0, b = 5&#xA;r = 0, g = E9, b = 5&#xA;r = 0, g = 0, b = 4&#xA;r = 8, g = 21, b = 0&#xA;r = 0, g = 0, b = 0&#xA;r = 0, g = E5, b = A&#xA;r = E0, g = A, b = 0&#xA;r = 0, g = 0, b = 0&#xA;r = A, g = DA, b = 0&#xA;r = 0, g = 0, b = 0&#xA;r = 0, g = 0, b = A&#xA;r = E5, g = 0, b = 4&#xA;r = 2, g = 71, b = 5&#xA;r = 1, g = 32, b = 80&#xA;r = 9, g = 12, b = 58&#xA;r = 58, g = 31, b = 30&#xA;r = 30, g = 58, b = 58&#xA;r = 58, g = 58, b = 58&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;WAT?! Where are those numbers even coming from? What does file.read() think a byte is? How come it's trying to read from 5888 bytes into a 125 byte file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note this is the FileIO library from the Yun Bridge package to read from the SD card built into the Atheron side of the Yun. The &quot;normal&quot; Arduino SD card library isn't relevant here.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="3536" LastActivityDate="2015-02-08T15:49:13.730" Title="How do I read from an SD card on the Yun?" Tags="|arduino-yun|sd-card|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8510" PostTypeId="2" ParentId="8502" CreationDate="2015-02-08T16:01:29.077" Score="2" Body="&lt;p&gt;I assume you are uploading the code over USB - the same USB that you want to monitor for output from the sketch? If so, the serial monitor has to release the port for the uploader to be able to use it, and vice-versa, as your computer's OS will only assign a USB port to one application at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may seem like the IDE is one application containing an uploader and a serial monitor, but the IDE is not much more than a &quot;pretty face&quot; that runs separate compiler and uploader applications on your behalf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several work-arounds are possible (although I think a &lt;code&gt;delay()&lt;/code&gt; statement in &lt;code&gt;setup()&lt;/code&gt; is the clearest of the choices):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add a delay statement in the setup function. If you must this, you can put it in &lt;code&gt;main()&lt;/code&gt; just before the &lt;code&gt;setup()&lt;/code&gt; call, but you'd take away a learning opportunity.&lt;/li&gt;&#xA;&lt;li&gt;Use a separate hardware or software serial channel for the monitor which you could leave connected and wouldn't interfere with uploading;&lt;/li&gt;&#xA;&lt;li&gt;Use the &lt;code&gt;loop()&lt;/code&gt; function instead, and put a forever loop at the bottom to prevent it returning, thus making it a runs-once function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-02-08T16:01:29.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8511" PostTypeId="1" AcceptedAnswerId="8518" CreationDate="2015-02-08T21:56:31.960" Score="22" ViewCount="104912" Body="&lt;p&gt;I have many Arduino Mini Pro, every from different seller.&#xA;Few are 3.3v and most 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to clean table for Xmas and now I do not have any idea how to identify 3.3v Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They do not have any marks. I bought them on ebay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know 3.3v has 8mhz clock but only one my arduino has big crystal with 16.000-30.&lt;/p&gt;&#xA;" OwnerUserId="7216" LastActivityDate="2021-03-10T22:26:27.977" Title="How to identify Arduino Mini Pro 5v vs 3.3v" Tags="|voltage-level|" AnswerCount="10" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8512" PostTypeId="2" ParentId="8511" CreationDate="2015-02-08T22:01:21.993" Score="5" Body="&lt;p&gt;Plug it in and measure the voltage on pin 4 of the MCU.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-08T22:01:21.993" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8513" PostTypeId="2" ParentId="8511" CreationDate="2015-02-09T00:11:01.350" Score="3" Body="&lt;p&gt;The only difference would be the regulator and crystal (8MHz on 3.3V). As @IgnacioVazquez-Abrams suggest supply power to the &quot;raw&quot; and measure Vcc.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-09T00:11:01.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8514" PostTypeId="1" CreationDate="2015-02-09T00:53:46.000" Score="3" ViewCount="28000" Body="&lt;p&gt;I need to light up 19 RGB LED strips, which it seems would require 19*3=57 PWM outs and 57 transistors.  The transistors aren't an issue, but of course the 57 PWM's is.  Even if I hacked the digital IO ports to work as PWM, I still wouldn't have enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this more simply?  Is there some kind of device I can get that would let me just pass data to it, perhaps over I2C, and it would control many PWMs? Is there another solution I haven't considered?  Maybe whatever is used to control those 8x8 RGB LED dot matrixes?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.  Thank you!&lt;/p&gt;&#xA;" OwnerUserId="7218" LastActivityDate="2015-02-22T02:21:25.210" Title="How to control 19 RGB LED strips with one arduino?" Tags="|arduino-uno|led|pins|pwm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8515" PostTypeId="2" ParentId="8514" CreationDate="2015-02-09T01:24:37.860" Score="1" Body="&lt;p&gt;There are several ways you can do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1 - the easy way: You can use a serial-in-parallel out. Google &quot;Arduino SIPO&quot;, and you will find examples. You basically send out 8 bits at a time, to a SIPO chip, then &quot;enable&quot; the chip; this changes the 8 &quot;output&quot; pins of the sipo to combinations of high/low as per the 8 bits that went in. You can pwm the &quot;enable&quot; pin. The best part is that each SIPO chip has an overflow - if you put a ninth bit in, you will get the first bit out of the overflow pin, which you can hook up to the input pin of a second SIPO, and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This option uses about arduino 4 pins, for an unlimited number of output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also has the advantage that SIPO chips can normally carry much more power than an arduino. Check the spec sheet on the SIPO to see how many milliamps it can carry at once (maximum). An example of a SIP is 74HC595.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2 - Control the common pin for each strip.&#xA;Basically, you will be using e.g. 3 pins to select the colour, 19 to select which strip - I think some arduinos have that many pins? To light up red on strip 3, you would put the red pin high (and green &amp;amp; blue low); then you would put the pin for strip 3 low, and all the others high. You would step through each pin you want to light, or you could light them in groups - first red goes high (green/blue low), and all the strips you DONT want red on have their cathode high, and those you DO want red on would have their cathode low. drop red down; then do the same for green and blue. This does mean that you can't light up leds more than 1/3 of the time. This can be combined with the SIPO chip above - it may be easier. This does mean that you need to break out the &quot;common&quot; (cathode, normally to ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of these allow very fine-grained control like pwm - you can't just say &quot;led 3, green, 40%&quot;; you will have to do a lot more work. You may burn all your Arduino time just doing the LEDs; this may or may not be a problem. You have the option of offloading your work onto another AtMega chip, or even an AtTiny; I think I would use an AtTiny and three SIPOs - 4 pins of the AtTiny to control the SIPOs, and 4 for SPI to receive the new settings (e.g. send the AtTiny 57 half-bytes, would give you 12-bit colour depth). You would need to do your own &quot;fake pwm&quot;, but you could devote the entire AtTiny to running the light show. The AtTiny is programmed the same way as an Arduino; you would use a USBISP to send the program. Just hook up the power and away you go! An AtTiny will set you back around $2, depending on how many you get and where you get them from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ADDITIONAL! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about using something like a TLC5940? I haven't looked at the specs, but I found a reference to Arduino code. 16 Channel, 12 bit duty cycle per channel; you would need 4 of them. Apparently they can be daisy-chained as well. &lt;a href=&quot;http://playground.arduino.cc/Learning/TLC5940&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/TLC5940&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-02-09T02:25:42.303" LastActivityDate="2015-02-09T02:25:42.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8516" PostTypeId="2" ParentId="8514" CreationDate="2015-02-09T02:37:29.570" Score="4" Body="&lt;p&gt;You can use addressable LEDs that allow chaining from one LED to another using a serial protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this : &#xA;&lt;img src=&quot;https://i.stack.imgur.com/Iq1on.png&quot; alt=&quot;Fritzing, wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would alow you to set the first row blue, the second purple, each one can be controled independently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at Ada Fruit's &lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;neopixels&lt;/a&gt; to start. These are basically skillfully branded WS2811 &amp;amp; WS2812 LEDs, but they are very well documented and well built. They feature 8 bit per channel RGB color (24 bit color) and take care of PWM internally. You could even chain the end of one strip to another, allowing all control to come from two pins of an arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you go this route, consider the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You will need enough RAM to store the full array of pixels in memory, which is 3 bytes per pixel.  Alternatively, you can create a custom library with reduced bit depth, or one that stores pixels in clusters, because at the end of the day you are just operating a giant shift register. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You will need to supply enough &lt;strong&gt;current&lt;/strong&gt; (60mA per led), and supply it at several points along longer strips.  You will likely need to use external power sources.  You can drive a decent amount of LEDs from Vin (before the power regulator), but not anything near 19 strips.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now if you already have the strips, and they are analog strips, I think you can find similar drivers that output more power to drive strips, but still use a serial protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use my example code here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// NeoPixel Demo minimum &#xA;// By leo etchaas&#xA;// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library&#xA;&#xA;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;// Which pin on the Arduino is connected to the NeoPixels?&#xA;// On a Trinket or Gemma we suggest changing this to 1&#xA;#define PIN            6 &#xA;&#xA;// How many NeoPixels are attached to the Arduino?&#xA;#define NUMPIXELS      55&#xA;&#xA;// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.&#xA;// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest&#xA;// example for more information on possible values.&#xA;Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;int delayval = 500; // delay for half a second&#xA;&#xA;void setup() {&#xA;  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket&#xA;#if defined (__AVR_ATtiny85__)&#xA;if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;#endif&#xA;// End of trinket special code&#xA;&#xA;pixels.begin(); // This initializes the NeoPixel library.&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.&#xA;&#xA;for(int i=0;i&amp;lt;NUMPIXELS;i++){&#xA;&#xA;// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255&#xA;pixels.setPixelColor(i, pixels.Color(25,255,255)); // Moderately bright green color.&#xA;&#xA;pixels.show(); // This sends the updated pixel color to the hardware.&#xA;&#xA;delay(delayval); // Delay for a period of time (in milliseconds).&#xA;&#xA;}for(int i;i&amp;gt;0;i-=1){&#xA;&#xA;// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255&#xA;pixels.setPixelColor(i, pixels.Color(255,5,255)); // Moderately bright green color.&#xA;&#xA;pixels.show(); // This sends the updated pixel color to the hardware.&#xA;&#xA;delay(delayval); // Delay for a period of time (in milliseconds).&#xA;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7221" LastEditorUserId="4951" LastEditDate="2015-02-22T02:21:25.210" LastActivityDate="2015-02-22T02:21:25.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8517" PostTypeId="1" CreationDate="2015-02-09T02:43:51.467" Score="2" ViewCount="57" Body="&lt;p&gt;I want to output a chosen sound (e.g a singer singing a D, or E, or F note) which I have recorded.  I can change the filetype to whatever is neccessary, e.g mp3 or whatever.  The recording could be 10ms, or longer if that helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to switch between notes quickly (ideally 1ms delay), is this possible?  I read about using a WTV020-SD Mini but this has a gap of 20ms between tunes sadly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the very least I don't want a 20ms noiseless 'gap' as it switches between one note to the next.  If it plays the old noise that would be ok, but ideally i'd like it to be able to switch between the notes in a millisecond or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to accomplish this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, the solution would be narrow, to fit in a 10mm radius cylinder, up to 100mm in length, although ideally smaller.&lt;/p&gt;&#xA;" OwnerUserId="7220" LastEditorUserId="7220" LastEditDate="2015-02-09T02:51:21.383" LastActivityDate="2015-02-09T02:51:21.383" Title="Want to play short voice recordings, with fast switching between them" Tags="|audio|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8518" PostTypeId="2" ParentId="8511" CreationDate="2015-02-09T03:36:33.927" Score="23" Body="&lt;p&gt;The regulator should be marked K850(5.0V) or K833(3.3V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 5 volt part has a 16MHz resonator may be marked with &quot;A1&quot; or &quot;A'N&quot;&lt;br&gt;&#xA;A 3.3 volt part has a 8MHz resonator may be marked with &quot;80'0&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have indicated, you can apply up to 12V at the RAW pin, and measure the output of the regulator.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="63288" LastEditDate="2020-02-22T14:49:50.487" LastActivityDate="2020-02-22T14:49:50.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="8519" PostTypeId="1" AcceptedAnswerId="8537" CreationDate="2015-02-09T05:16:59.990" Score="2" ViewCount="3783" Body="&lt;p&gt;Is there a way to program the Ethernet Shield and Uno R3 to act as a firewall without using a huge chunk of the allowed bytes on the R3?  I plan on using a DC adapter to plug the R3 into a wall, and use the mini-SD card to keep logs while having the ethernet shield plugged into my router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it is possible to program it to do this but I want to know if there is a simple modification I can make to the web-client library or if I should use the web-server library and modify that?&lt;/p&gt;&#xA;" OwnerDisplayName="user7188" LastActivityDate="2015-02-09T19:56:35.930" Title="Arduino Ethernet and Uno R3 as a firewall" Tags="|arduino-uno|ethernet|sketch|web-server|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8520" PostTypeId="1" CreationDate="2015-02-09T05:23:44.443" Score="0" ViewCount="1702" Body="&lt;p&gt;I have small problem in setting device ID for Mosbus slave arduino. Here is simple example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Modus library; device ID being configure hardcode while program. This code works for Me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Modbus slave(1,0,0); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I wanted to recognise 0-255 device ID , I am using 8:1 digital Multiplexer &amp;amp; DIP switch to select the port. I am reading status of digital pin &amp;amp; depend on status of 8 DIP pin i come to know whats device ID. Below function return device ID. I have checked Serial it returns value properly. If i assign the value to Device ID it wont work . Please let me know how can i solve this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int ID_Check() {&#xA;      unsigned   int ID_value;&#xA;      for(int row=0;row&amp;lt;8;row++)&#xA;      {&#xA;        digitalWrite(SO_enable,array[row][0]);&#xA;        digitalWrite(S1_enable,array[row][1]);&#xA;        digitalWrite(S2_enable,array[row][2]);&#xA;        Status_Out[row]=digitalRead(Output_Read);&#xA;&#xA;      }&#xA;&#xA;  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];&#xA;  return(ID_value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is complete code.I tried to call function loop But it wont work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ModbusRtu.h&amp;gt;&#xA;int SO_enable=5;&#xA;int S1_enable=4;&#xA;int S2_enable=3;&#xA;int Status_Out[8];&#xA;int Output_Read=2;&#xA;Modbus slave(ID_Check(),0,0); // this is slave @1 and RS-232 or USB-FTDI&#xA;int array[8][3]={&#xA;  {    &#xA;    0,0,0    }&#xA;  ,&#xA;  {    &#xA;    0,0,1    }&#xA;  ,&#xA;  {    &#xA;    0,1,0    }&#xA;  ,  &#xA;  {    &#xA;    0,1,1    }&#xA;  ,&#xA;  {    &#xA;    1,0,0    }&#xA;  ,&#xA;  {    &#xA;    1,0,1    }&#xA;  ,&#xA;  {    &#xA;    1,1,0    }&#xA;  ,&#xA;  {    &#xA;    1,1,1    }&#xA;&#xA;&#xA;};&#xA;&#xA;unsigned int ID_Check() {&#xA;  unsigned   int ID_value;&#xA;  for(int row=0;row&amp;lt;8;row++)&#xA;  {&#xA;    digitalWrite(SO_enable,array[row][0]);&#xA;    digitalWrite(S1_enable,array[row][1]);&#xA;    digitalWrite(S2_enable,array[row][2]);&#xA;    Status_Out[row]=digitalRead(Output_Read);&#xA;&#xA;  }&#xA;&#xA;  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];&#xA;  return(ID_value);&#xA;}&#xA;&#xA;&#xA;uint16_t au16data[16] = &#xA;{&#xA;  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1&#xA;};&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  slave.begin( 9600 ); // baud-rate at 19200&#xA;  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino&#xA;  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino&#xA;  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino&#xA;  pinMode(Output_Read,INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  slave.poll( au16data, 16 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other way i tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Modbus_Setup()&#xA;{&#xA;  Device_ID=ID_Check();&#xA;     delay(100);&#xA;    Modbus slave(Device_ID, 0, 0); &#xA;     slave.begin(9600);&#xA;  //slave.setID(Device_ID);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="42" LastEditDate="2015-02-09T09:50:52.850" LastActivityDate="2015-02-09T11:49:52.733" Title="modbus slave ID setting" Tags="|arduino-uno|programming|c++|library|modbus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8522" PostTypeId="2" ParentId="8511" CreationDate="2015-02-09T08:17:06.300" Score="0" Body="&lt;p&gt;AVR isn't specified to work at 16MHz at a 3.3V supply; it only can work at this high frequency at 5V supply. So you'll be able to tell them apart from reading the crystal. (It's possible, but unlikely, that you have a 5V version working with an 8MHz crystal. In any case 16MHz is safe for 5V.)&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-09T08:17:06.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8523" PostTypeId="2" ParentId="8520" CreationDate="2015-02-09T09:55:31.083" Score="1" Body="&lt;p&gt;It looks like the problem may be initialisation order. In C/C++, global variables/objects are usually initialised in the order they are declared, and before any global functions run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, this means &lt;code&gt;ID_Check()&lt;/code&gt; gets called before &lt;code&gt;array&lt;/code&gt; is populated, and before &lt;code&gt;setup()&lt;/code&gt; runs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you need to make sure everything else is setup before your attempting to initialise the &lt;code&gt;Modbus&lt;/code&gt; object. I'm not familiar with the library, but perhaps there's a way to set the device ID after it's been constructed (i.e. not in the constructor)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, you could declare &lt;code&gt;slave&lt;/code&gt; as a global pointer, and then instantiate it using &lt;code&gt;new&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, I'm guessing your &lt;code&gt;Modbus_Setup()&lt;/code&gt; function didn't work because the &lt;code&gt;slave&lt;/code&gt; object in there is completely separate from the &lt;code&gt;slave&lt;/code&gt; object that's declared globally and used in &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-09T09:55:31.083" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8524" PostTypeId="1" AcceptedAnswerId="8527" CreationDate="2015-02-09T10:40:07.617" Score="1" ViewCount="873" Body="&lt;p&gt;Will the 3.3V regulator produce 3.3v when the Arduino is powered from the USB port?&lt;/p&gt;&#xA;" OwnerUserId="7227" LastActivityDate="2015-02-09T14:31:36.990" Title="Will the 3.3V regulator on an Arduino Leonardo work when powered from USB?" Tags="|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8526" PostTypeId="2" ParentId="8524" CreationDate="2015-02-09T12:34:27.353" Score="0" Body="&lt;p&gt;The 3.3V regulator is fed by the 5V, whatever that comes from. If you don't use a separate power supply like a wall-wart, the 5V switches automatically to the USB's 5V. That feeds the regulator for the 3.3V.&lt;br&gt;&#xA;So yes, it will produce 3.3V.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-09T12:34:27.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8527" PostTypeId="2" ParentId="8524" CreationDate="2015-02-09T12:37:52.870" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Will the 3.3V regulator on an Arduino Leonardo work when powered from USB?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, provided that &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;it is an &quot;official&quot; Leonardo or a competent clone and &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;as long as you do not load the power supply excessively with external loads.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Official circuit diagram here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB supply feeds the 3V3 regulator via MOSFET T1 at the bottom of the sheet and U3, an LP2985 LDO regulator. If your board has the same circuitry as this it should provide 3V3 from USB.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2EACG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-09T14:31:36.990" LastActivityDate="2015-02-09T14:31:36.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8528" PostTypeId="1" CreationDate="2015-02-09T14:49:17.627" Score="5" ViewCount="1268" Body="&lt;p&gt;My source files are *.ino, but after compilation there aren't any other files placed in the folder. Does the compiler generate intermediate assembler, and if so, where does it leave them? Or is the machine code available somewhere?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2021-07-02T00:47:21.883" Title="Does the compiler generate intermediate assembler?" Tags="|compile|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8529" PostTypeId="2" ParentId="8502" CreationDate="2015-02-09T16:47:56.257" Score="1" Body="&lt;p&gt;Have you tried hitting the reset button while the serial monitor is open?  I have done this on other Arduino boards to capture stuff in the setup loop that was occurring too fast.  Otherwise using Serial1 for output connected via a FTDI cable may be the way to go.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-09T16:47:56.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8530" PostTypeId="1" CreationDate="2015-02-09T18:20:08.467" Score="1" ViewCount="541" Body="&lt;p&gt;I want to create a growhouse sensor system. I have an Arduino UNO, wireless SD shield and I have just ordered a series 2 XBee XB24.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any info I find seems to revolve around having 2 Arduinos and 2 XBee modules, why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am presuming that once I connect the XBee to the shield that I can then connect to my Arduino on the network and send and receive data, am I wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a developer and sysadmin but a noob to Arduino so any help is much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7232" LastEditorUserId="26916" LastEditDate="2017-11-04T07:42:35.553" LastActivityDate="2017-11-04T07:42:35.553" Title="Can I connect to WiFi with an Arduino, &quot;wireless SD shield&quot; and XBee" Tags="|arduino-uno|xbee|sd-card|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8532" PostTypeId="1" AcceptedAnswerId="8540" CreationDate="2015-02-09T19:29:57.133" Score="0" ViewCount="5540" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/arOYe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a project which involves a photocell, an led, a push button, and a small hobby servo (&lt;a href=&quot;http://www.adafruit.com/product/155&quot; rel=&quot;nofollow noreferrer&quot;&gt;tower pro sg5010&lt;/a&gt;) - the project works as expected when the arduino is powered by usb, but when I switch to battery power (4 AA batteries) - it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When powered by batteries, the servo actually starts right up and moves to the correct angle, so I feel like it should be getting enough power, but when I push the push button, it doesn't move to the new angle. I can hear a clicking noise of the servo on a regular interval, like a clock, and my LED flickers on and off at about the same interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm doing something wrong, can anyone point it out? If it's just that the servo is not getting enough power, is there a way to add a transistor or something so that I don't have to add a separate power supply for the servo (I'm not sure there's room in my project's enclosure). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached a fritzing diagram as well as my project code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;const int buttonPin = 2;     // the number of the pushbutton pin&#xA;boolean buttonPushed = false;&#xA;&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;&#xA;const int servoPin = 9;&#xA;Servo servo;&#xA;int angle = 0;&#xA;int servoStartAngle = 90;&#xA;int servoEndAngle = 10;&#xA;&#xA;boolean servoActivated = false;&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;&#xA;int photoCellPin = 2;&#xA;int photoCellThreshold = 500;&#xA;int photoCellActivated = false;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);&#xA;&#xA;  servo.attach(servoPin);&#xA;  servo.write(servoStartAngle);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;  // read the state of the pushbutton value:&#xA;  buttonState = digitalRead(buttonPin);&#xA;&#xA;  int photoCellVal = analogRead(photoCellPin);&#xA;&#xA;  if (photoCellVal &amp;gt; photoCellThreshold){&#xA;   photoCellActivated = true; &#xA;  } else {&#xA;   photoCellActivated = false; &#xA;  }&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (buttonState == LOW &amp;amp;&amp;amp; buttonPushed == false) {     &#xA;    // turn LED on:    &#xA;    buttonPushed = true;&#xA;    Serial.println(&quot;button pushed&quot;);&#xA;  } else if (buttonState == LOW &amp;amp;&amp;amp; buttonPushed == true){&#xA;   buttonPushed = false;&#xA;   Serial.println('deactivate');&#xA;  } &#xA;&#xA;&#xA;&#xA;  if (buttonPushed == true){&#xA;   digitalWrite(ledPin, HIGH); &#xA;  } else {&#xA;   digitalWrite(ledPin, LOW); &#xA;  }&#xA;&#xA;  if (buttonPushed &amp;amp;&amp;amp; servoActivated == false &amp;amp;&amp;amp; photoCellActivated == true){&#xA;    servoActivated = true;&#xA;    Serial.println(&quot;activate motor&quot;);&#xA;&#xA;    for(angle = servoStartAngle; angle &amp;gt; servoEndAngle; angle--){                                  &#xA;      servo.write(angle);&#xA;      Serial.println(angle);&#xA;      delay(15);    &#xA;    } &#xA;  } else if (buttonPushed == false &amp;amp;&amp;amp; servoActivated == true){ //deactivate&#xA;    for(angle = servoEndAngle; angle &amp;lt; servoStartAngle; angle++){                                  &#xA;      servo.write(angle);&#xA;      Serial.println(angle);&#xA;      delay(15);    &#xA;    }&#xA;    delay(200);&#xA;    servoActivated = false; &#xA;&#xA;  }&#xA;&#xA;  delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6341" LastEditorUserId="6341" LastEditDate="2015-02-09T19:56:04.717" LastActivityDate="2015-02-10T11:25:41.803" Title="project not working when switching to battery power" Tags="|arduino-uno|led|power|servo|battery|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8533" PostTypeId="2" ParentId="8530" CreationDate="2015-02-09T19:31:31.093" Score="1" Body="&lt;p&gt;The xbee network and the wifi network are both wireless networks, but, they do not communicate with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two options. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Attach a second XBEE to your computer using one of these&#xA;&lt;a href=&quot;https://www.sparkfun.com/products/11812&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11812&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Get a WIFI shield &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoWiFiShield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3818" LastActivityDate="2015-02-09T19:31:31.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8534" PostTypeId="1" CreationDate="2015-02-08T17:54:01.220" Score="2" ViewCount="56" Body="&lt;p&gt;I'm doing a schematic for an arduino project-based and I can not proceed. I'm facing a problem which I have no idea how can I solve it so that's the reason I'm writing back to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is: I have three atmega 328 and I want to program them using a single ftdi or a USB-UART converter. I can not put the chip outside the board and program them one by one, so the ftdi should be in the PCB.&#xA;I was wondering if I can do it using a switch with three positions with the help of 3 MOSFETs but I found it impossible, is it? Do you have any idea how can I solve this clue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19878" OwnerDisplayName="scuba" LastActivityDate="2015-02-10T05:02:53.923" Title="One FTDI on Three Atmega" Tags="|usb|uart|ftdi|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8536" PostTypeId="1" CreationDate="2015-02-09T19:55:20.550" Score="1" ViewCount="980" Body="&lt;p&gt;I am trying log my sensor data (1 byte each) on my Arduino Uno Eeprom. I have an ATmega328 on it, so it should allow me to write up to 1Kb on it, however I've tried the Eeprom write command and it does not seem to write to more than 100 locations on it (the first 100 bytes!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Eepromex library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts on what's causing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the excerpts from my code related to Eeprom logging:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int addr1 = 0;&#xA;int addr2 = 256; &#xA;&#xA;&#xA;  // Store Data in EEPROM&#xA;&#xA;  EEPROM.write(addr1,FinalMoisture[0]);&#xA;&#xA;    delay(5);&#xA;&#xA;  EEPROM.write(addr2,FinalMoisture[1]); &#xA;&#xA;    delay(5);&#xA;  // advance index pointer to the next location.  There are 256 bytes assigned for each sensor in the EEPROM, so go back to 0 when we hit 255/511.&#xA;&#xA;  addr1 = addr1 + 1;&#xA;&#xA;  if (addr1 == 255)&#xA;    addr1 = 0;&#xA;&#xA;  //same for addr 2 :&#xA;&#xA;   addr2 = addr2 + 1;&#xA;&#xA;  if (addr2 == 511)&#xA;    addr2 = 256;&#xA;&#xA;  // delay until next measurement (msec)&#xA; Sleepy::loseSomeTime(30000); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: As mentioned earlier I've included the EepromEx library. Each sensor stores only first 50 locations. Also, I've noticed that if I run a single loop instead of storing data in two locations, I can write 100 straight entries. In any case it seems that the write function is limited to 100? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could this be a setting in the library? How to disable/modify it? I tried looking at the info on the lib author's postings but didn't help.&lt;/p&gt;&#xA;" OwnerUserId="6294" LastEditorUserId="42" LastEditDate="2015-02-12T20:06:21.843" LastActivityDate="2015-09-21T04:48:13.177" Title="Eeprom write function does not seem to write in more than 100 locations" Tags="|arduino-uno|eeprom|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8537" PostTypeId="2" ParentId="8519" CreationDate="2015-02-09T19:56:35.930" Score="0" Body="&lt;p&gt;As an entry level board, I wouldn't suggest trying this on the R3. You can do it to an extent on the Yun which comes with both a network port and wifi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that said, your internet speed will be severely hampered by the lack of resources on the yun. In which case, you might want to steer closer to the Intel Edison, which you can use with the arduino IDE. It is considerably more powerful. &lt;/p&gt;&#xA;" OwnerUserId="7238" LastActivityDate="2015-02-09T19:56:35.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8539" PostTypeId="1" CreationDate="2015-02-09T20:40:48.490" Score="1" ViewCount="541" Body="&lt;p&gt;I am new to stack overflow. I have a question regarding using the USB serial communication sending data from an OS X app to the Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is, when I have the Arduino running with the Serial monitor open, then I run the OS X app to send data, the Arduino does receive the data for a few seconds, then it stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the simplified Object-C code on the Mac side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-(IBAction)sendData:(id)sender{&#xA;    NSString *toSend=[NSString stringWithFormat:@&quot;echo %f &amp;gt; /dev/tty.usbmodem1a1341&quot; ,vector.x];&#xA;    //vector is the continuous data generated by the Mac&#xA;    const char *toCSend =[toSend UTF8String];&#xA;    //converting to c string&#xA;    printf(&quot;%s&quot;, toCSend);&#xA;    popen(toCSend, &quot;r&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the code on the Arduino side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Read Serial input:&#xA;void setup() {&#xA;  // Open Serial commurial1.beginnications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    // wait for Serial port to connect. Needed for Leonardo only&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // Read Serial input:&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    int inChar = Serial.read();&#xA;    if (inChar != '\n') {&#xA;      inString += (char)inChar;&#xA;      Serial.read();&#xA;    } else {&#xA;      // if you get a newline, print the string,&#xA;      // then the string's value as a float:&#xA;      Serial.println(inString.toFloat(), 6);&#xA;      // clear the string for new input:&#xA;      inString = &quot;&quot;;&#xA;    }//end of if else&#xA;  }//end of while (Serial.available() &amp;gt; 0)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure what the problem, could it be the OS X app send out too much data to quickly? Or could it be the Arduino serial buffer is overflowed? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really don't know much about serial communication so I don't know what I am missing. Any help will be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7240" LastEditorUserId="4628" LastEditDate="2015-12-04T14:39:19.677" LastActivityDate="2015-12-04T14:39:19.677" Title="Serial communIcation from OS X app to Arduino Mega" Tags="|serial|communication|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8540" PostTypeId="2" ParentId="8532" CreationDate="2015-02-09T20:46:26.413" Score="3" Body="&lt;p&gt;You may find that, with a high load on batteries, it's depleting the battery quickly; batteries often recover after a while, which may be confusing things further. Try using a multimeter to measure the voltage on the battery, when your program is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino (actually, the chip that runs the Arduino) has brown-out detection - if the voltage drops below a certain level, the Arduino will shut down; if the power comes back up, the Arduino will start up again - but reset. The chip has settings for 1.8v, 2.7v, and 4.3v brownout detection (or none at all!); something I read on the interweb (if you can trust that) said the default was 4.3v. It may be worth flashing an led on startup, so you can tell when the chip is reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you are powering the Arduino through the voltage regulator (using the power socket on the Arduino), then you need about 6-7 volt in just to get 5 volt at the Arduino - this causes further power loss. If using 4 AA batteries through the voltage regulator, you will get 6 volts (probably a little more when the batteries are fresh) going into the regulator - barely or not quite enough! - and the voltage on the Arduino is likely to be below the 5v it needs. Any load (in one of my projects, two large 7-segment displays) can cause the voltage to drop enough to trigger a reset. If you are using the voltage regulator, check the voltage between the 5V and GND pins.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-02-09T20:59:32.267" LastActivityDate="2015-02-09T20:59:32.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8541" PostTypeId="1" CreationDate="2015-02-09T21:23:43.587" Score="2" ViewCount="1027" Body="&lt;p&gt;I am using Xbee API library for Python to process the data received by the Xbee module. I am wondering how to construct the robust protocol for sending and receiving data. What I would like to build is&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;send the data request message to power monitoring uint (Xbee in remote).&lt;/li&gt;&#xA;&lt;li&gt;Receive the transmitted power monitoring data and process it in Python.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the aforementioned process works in just one time, it would be great, but sometimes it does not work. Thus, I would like to code autonomous acknowledging procedure into this communication. That is &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;send the data request message to power monitoring uint (Xbee in remote).&lt;/li&gt;&#xA;&lt;li&gt;If the dat is not received, go back to 1.&lt;/li&gt;&#xA;&lt;li&gt;If the data is received ok.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here are my code, but it does not work all the time. Would you please look at how can I improve the code further to make it this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def listeningAndClusterData(targetWT):&#xA;&#xA;#targetWT--&amp;gt;this will be used to construct the target address&#xA;targetAddress = struct.pack('b',0x00)+struct.pack('b',targetWT)&#xA;Data = struct.pack('h',0x0000) #prefix for requesting information&#xA;xbee.tx(dest_addr=targetAddress, data=Data)&#xA;ser.flush()&#xA;time.sleep(0.01)&#xA;response = xbee.wait_read_frame(100)#wait for data packet from Xbee, if packet is not recieved within 100ms, return 1&#xA;&#xA;watingData = 1;&#xA;while watingData:&#xA;    try:&#xA;&#xA;        if response != 1: # if the data is received&#xA;            sa = hex(response['source_addr'])&#xA;            rf = hex(response['rf_data'])&#xA;            datalength=len(rf)&#xA;            agentId = int(sa[2:4],24)&#xA;            # if datalength is compatible with two floats&#xA;            if datalength==16: &#xA;                voltage=struct.unpack('f',response['rf_data'][0:4])[0]&#xA;                current=struct.unpack('f',response['rf_data'][4:8])[0]&#xA;                power=voltage*current&#xA;                watingData = 0 # I received the average data and escape the loop&#xA;                ser.flush()&#xA;            else: #data is received but the format is not correct&#xA;                ser.flush()&#xA;&#xA;        if watingData != 0: #if the data is not received--&amp;gt; keep sending the request message to other xbee&#xA;            xbee.tx(dest_addr=targetAddress, data=Data)&#xA;            print(&quot;data is requested again&quot;)&#xA;            time.sleep(0.01)&#xA;            ser.flush()&#xA;            response = xbee.wait_read_frame(100)&#xA;&#xA;    except KeyboardInterrupt:&#xA;        break&#xA;&#xA;return  voltage, current, power&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4106" LastActivityDate="2015-02-09T21:23:43.587" Title="Robust communication between Xbee and Python" Tags="|xbee|python|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8542" PostTypeId="2" ParentId="8530" CreationDate="2015-02-09T21:45:56.040" Score="1" Body="&lt;p&gt;Do you remember the term mesh network? Xbee's create a mesh network or multipoint network using 802.15.4 (hurray for google) protocol. This is not compatible with 802.11, the wifi protocol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want everything to talk, you are either going to need to get an Xbee for everything, or wi-fi for everything (or wi-fi + ethernet for that matter). &lt;/p&gt;&#xA;" OwnerUserId="7238" LastActivityDate="2015-02-09T21:45:56.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8544" PostTypeId="2" ParentId="8528" CreationDate="2015-02-09T22:17:03.503" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My source files are *.ino, but after compilation there aren't any other files placed in the folder.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Correct. The Arduino IDE performs compilation in a separate temporary directory, whose location you can see if you enable verbose compilation in the IDE options.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does the compiler generate intermediate assembler, and if so, where does it leave them?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;By default GCC (which the Arduino IDE uses) does not leave intermediate assembly language files on disk. You must pass the &lt;code&gt;--save-temps&lt;/code&gt; argument to have it leave them in the current directory, or &lt;code&gt;--save-temps=obj&lt;/code&gt; to save them in the output directory.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Or is the machine code available somewhere?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The machine code is available in the .elf and .hex files generated in the temprary directory.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-09T22:17:03.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8545" PostTypeId="1" CreationDate="2015-02-10T01:21:53.630" Score="3" ViewCount="1160" Body="&lt;p&gt;If one could tell me where each of the pins on the back of the camera go to, that would be great. if someone added the code also that would be awesome.&lt;/p&gt;&#xA;" OwnerUserId="7244" LastActivityDate="2017-04-04T14:01:25.540" Title="How does one use (specically the wiring) the OV7670 camera with the Arduino Uno?" Tags="|arduino-uno|pins|wires|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8547" PostTypeId="1" CreationDate="2015-02-10T04:40:42.353" Score="1" ViewCount="114" Body="&lt;p&gt;Despite all my efforts and web crawling I can not install the necessary driver to connect my Arduino uno R3 to the GPRS shield from seeedstudio. I have attempted downloading the VCP driver from &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.ftdichip.com/Drivers/VCP.htm&lt;/a&gt; &#xA;I have tried the solution offered here &lt;a href=&quot;https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac&lt;/a&gt; for Yosemite and beyond through the AppleUSBFTDI driver as well as the solution offered by FTDI's script. Any help will be greatly appreciated. Please let me know if I can provide any more information.&lt;/p&gt;&#xA;" OwnerUserId="7248" LastActivityDate="2015-02-12T00:18:59.810" Title="unable to install usbserial driver for GPRS shield with mac air vs. 10.9" Tags="|serial|usb|ftdi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8548" PostTypeId="2" ParentId="6856" CreationDate="2015-02-10T05:59:13.290" Score="0" Body="&lt;p&gt;First, let's look at where you are now.  The sensor you have reports current changes at 110mV per amp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means 40mA =&gt; 4.4mv, 90mA =&gt; 9.9mv, and 120mA =&gt; 13.2mv -- all very small voltages and small changes in voltage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's work backward, tho.  A 5V Arduino in typical ADC mode has a resolution of about 5 mV (5 V / 1024 counts), whilea 3.3V Arduino would have a resolution of about 3.3 mv).  Divide those step sizes by 0.11V/A sensitivity and you'll see that a different of 1 count on the ADC will represent about 45ma (5V Vcc) or 30 ma (3.3V Vcc).  But there is always inaccuracy and noise, so it's going to be hard to reliably distinguish between 90mA and 120 mA (using your figures).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can improve that somewhat by switching to a sensor with higher sensitivity (and lower maximum range) like &lt;a href=&quot;https://www.pololu.com/product/1185&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/product/1185&lt;/a&gt; which improves the sensitivity to 185 mV per amp.  The step size of the ADC converters would translate to about 26 mA (@5V) or 17.5 mA (@3.3V).  That's still pretty tight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;strong&gt;might&lt;/strong&gt; be able to manage with the more sensitive sensor and a 3.3V Arduino - if you use capacitors to filter out the electrical noise on the sensor to ADC input, and you average multiple readings in your code to further smooth the values.  But it would be marginal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to amplify the sensor.  Yes, you could do that with an external amplifier, like an op Amp.  A transistor is more difficult because you need it to stay fairly linear which gets trickier, and you may need more than one stage - so an op amp is easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's another tricky factor - you need to compare the voltage from the sensor to some reference - Vcc/2 for your sensor, and 2.5V for the more sensitive one.  The current is proportional to the difference between the sensor reading and that reference (the current going one way for sensor output above reference, the other way for sensor output below reference).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll mention another option - you could use an Arduino Mega or Leonardo.  These chips offer the option of differential inputs (one pin goes to the signal, and one to the reference), and they have built in selectable amplifiers with up to 200x amplification.  That should give you plenty of resolution, without needing to use external active analog circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will still need to filter the sensor output to smooth spikes from the motor (current spikes translated to voltage spikes by the sensor).  You may need to also filter the Arduino Aref input with a cap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you were to use an Arduino Mega or Leonard with the sensor you have.  You'd want a Vcc/2 reference, which could simply be two identical resistors (say 10K ohm) between Vcc and Ground as a voltage divider (and maybe a cap to ground for filtering).  You would still probably need to calibrate by finding the ADC value for no current as your reference and subtract that from the reading you get when current is flowing.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2015-02-10T05:59:13.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8549" PostTypeId="1" CreationDate="2015-02-10T03:58:54.780" Score="8" ViewCount="27662" Body="&lt;p&gt;What I want to do is allow &lt;strong&gt;Arduino A&lt;/strong&gt; to send some constant value to &lt;strong&gt;Arduino B&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sense something inherently wrong with my approach, but I cant figure out what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in the diagram below you will see &lt;strong&gt;Arduino A&lt;/strong&gt; setting its Analog Pin 0 as &lt;em&gt;OUTPUT&lt;/em&gt; and write a value 2 every 500ms. On &lt;strong&gt;Arduino B&lt;/strong&gt; we have Analog Pin 0 set as &lt;em&gt;INPUT&lt;/em&gt; to receive and print data to Serial. The &lt;em&gt;GND&lt;/em&gt; pins of both Arduinos are also connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this setup is executed, &lt;strong&gt;Arduino B&lt;/strong&gt; is constantly receiving data in the form of a 3 digit number starting with 3XX. I am starting to believe this is voltage value? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is inherently wrong with this idea?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uCSiG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7250" OwnerDisplayName="lucidgold" LastEditorUserId="6452" LastEditDate="2015-02-10T15:43:04.130" LastActivityDate="2015-02-12T00:59:27.780" Title="Two Arduinos Send data via Analog Pin?" Tags="|serial|communication|analogwrite|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8550" PostTypeId="2" ParentId="8549" CreationDate="2015-02-10T04:02:09.340" Score="3" Body="&lt;p&gt;&lt;code&gt;analogWrite()&lt;/code&gt; on the Uno doesn't actually output an analog value. It outputs a PWM wave whose &lt;em&gt;average&lt;/em&gt; is equivalent to that value. If you want to turn it into a true analog value then you need to put it through a low-pass filter in order to remove the components that make it a PWM wave instead.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-02-10T04:02:09.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8552" PostTypeId="2" ParentId="8549" CreationDate="2015-02-10T05:53:03.360" Score="10" Body="&lt;p&gt;This answer provides both Arduino specific knowledge and general electrical knowledge - both are necessary for a good solution (unfortunately).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Summary&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;To carry out Arduino analog to analog transfer:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use analogWrite(pin, value) on a valid &lt;strong&gt;digital&lt;/strong&gt; pin (see below)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use analogRead(pin) on a valid analog input pin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect a series resistor between the two pins - say 10k.&lt;br&gt;&#xA;Place a capacitor from the analog input to ground, say 100 nF to 10 uF.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The R &amp;amp; C act as a low pass filter to convert the PWM to DC.&lt;br&gt;&#xA;Details below.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Arduino analog pins are ONLY for analog input, not for analog output.&lt;br&gt;&#xA;So trying to do analog out on an analog pin dooms your attempt to failure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino analogWrite(pin, value) only works on DIGITAL pins and then only on the subset of digital pins that have PWM capability. This is typically digital pins 3 5 6 9 10 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;analogWrite(pin, value)  produces as others have said - a PWM signal - rail to rail square waves with mark space ratio that varies so the mean DC value changes. For a 5V system  =&lt;br&gt;&#xA;V_DC_mean ~~= value/256 x 5V.&lt;br&gt;&#xA;Where 'value' comes from analogWrite(pin, value)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To convert the PWM to good-enough DC a low pass filter with a cutoff somewhat below the PWM frame rate is needed. AFAIK Arduino PWM frame rate is about 800 Hz -  so components are usually higher than that. A simple RC filter where R x C is usefully more than about 0.001S will start to work . Larger RC is smoother but with secondary effects. Using a 10 uF ceramic cap and a 10k resistor is probably OK. 10 uF x 10k = 0.1S. 1uF and 1k = 0.001 s = marginal. An electrolytic cap can be used but leakage current may slightly affect accuracy. So - &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From somewhere in Arduino land (unknown) I copied the material below.&lt;br&gt;&#xA;This is NOT in the basic reference, but should be. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz. Pins 3 and 11 on the Leonardo also run at 980 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due supports analogWrite() on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" OwnerDisplayName="Russell McMahon" LastEditorUserId="6959" LastEditDate="2015-02-10T08:41:51.827" LastActivityDate="2015-02-10T08:41:51.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8553" PostTypeId="2" ParentId="8549" CreationDate="2015-02-10T05:57:54.173" Score="0" Body="&lt;p&gt;As has been mentioned above, using analogWrite won't work. (I suppose you could sample the supposed analogue signal with a fast loop and measure the duty cycle...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not use &lt;code&gt;SoftwareSerial&lt;/code&gt; to send data between the two Arduinos?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a library which creates another serial port, entirely in software, so it's independent of the main UART on the USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's already part of the IDE and it's easy to use - in fact the demo code on the help page will already work for you, transferring any characters from the USB serial port to the software serial port.&lt;/p&gt;&#xA;" OwnerUserId="8422" OwnerDisplayName="tomnexus" LastActivityDate="2015-02-10T05:57:54.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8555" PostTypeId="2" ParentId="8532" CreationDate="2015-02-10T11:08:04.873" Score="2" Body="&lt;p&gt;I had an even simpler project only involving a TMP sensor and 433 MHz RF module. On a 9V (150 mAh) block battery it lasted only about 2,5 hours.&#xA;The Arduino is great for prototyping this sort of stuff, but when you want to build something for battery operation I found  that it draws 56 mA just looping without RF or motor!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Counting 2 digital outputs, 1 digital input and 1 analog input in your project, you can run that of an ATTiny85 or ATTiny45. It's the same family and after setup can be programmed with the Arduino environment. You can also opt for a lower speed bootloader 1 MHz or 8 MHz instead of 16 MHz for the Arduino to save energy, you don't seem to calculate that much. The ATTiny will draw about 10 mA looping this way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you'll find also that you can disable the brown out detection in the bootloader, so it just drains the battery until completion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Saving space in you enclosure by swapping Arduino board for ATTiny chip will allow you to put in more batteries, say 8 AA in two parallel packs of 6V each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When that doesn't help you'll discover about the sleep modes and disabling ADC when not in use, where you go to sleep for specific intervals and allow the chip to be woken up by interrupts. In sleep mode I found the ATTiny to consume only 0.03 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some more information&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&quot; rel=&quot;nofollow&quot;&gt;Program an ATtiny with Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;ATTiny files for Arduino IDE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7255" LastEditorUserId="7255" LastEditDate="2015-02-10T11:25:41.803" LastActivityDate="2015-02-10T11:25:41.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8556" PostTypeId="2" ParentId="6" CreationDate="2015-02-10T11:24:31.147" Score="8" Body="&lt;p&gt;Once your project is working and you need to deploy to &quot;production&quot; environment, you can opt to replace the Arduino with a bare meta ATMega328 or any of the ATTiny family chips. This will get rid of all the power eaters on the Arduino board you don't need.&#xA;I found: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino board of 9V block battery - 56 mA&lt;/li&gt;&#xA;&lt;li&gt;ATTiny85 bare on 8 MHz without sleep modes etc - 10 mA&lt;/li&gt;&#xA;&lt;li&gt;ATTiny85 bare on 8 MHz in sleep mode - 0.03 mA&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some more information&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&quot;&gt;Program an ATtiny with Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot;&gt;ATTiny files for Arduino IDE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7255" LastActivityDate="2015-02-10T11:24:31.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8557" PostTypeId="2" ParentId="8430" CreationDate="2015-02-10T12:23:43.193" Score="1" Body="&lt;p&gt;OK. Figured out a solution which is working for me. Upon reading a forum on Arduino.cc. That stated a nice analogy to handle this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have something to heat up on stove while also waiting for an important email which you have to respond to immediately. (You only have a PC in the farthest corner of house at which you have to monitor your outlook :D) How will you do both tasks simultaneously? Run the stove for 10seconds, go to PC to check email, return to stove, run it again for 10 seconds, then again go to PC to check email. Do this until you get the email or your food gets hot enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To implement this in our program. I read the states of 2 buttons at start of the main loop. Store their values in 2 variables. Then check the values to check if some button is pressed. if value A is 1 and B is 0, call function A, if A is 0 and B is 1 call function B. The called function comprises of the scan routine. So when called, it performs 1 scan and comes back to the main loop. If no button was pressed meanwhile, the variables have same values, so the same function is called again and it performs the 2nd scan. if a button was pressed meanwhile, then 2nd function is called instead of the 1st one. The speed of all this is enough so that the user does not experience any delays, neither Arduino misses a button pressed while executing the scan. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs started to flicker when I implemented this code. So I further reduced the delay in the scan routine (time for which each LED is lit before turning it off and lighting the next one) from 300 microsecond to 100 and all went fine. My matrix of 64 LEDs is working fine however I assume that if matrix goes beyond some 100 LEDs then problems like delay or flickering or reduced brightness may arise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the complete code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte img1[] = {&#xA;    B01100110,&#xA;    B11111111,&#xA;    B11111111,&#xA;    B11111111,&#xA;    B01111110,&#xA;    B00111100,&#xA;    B00011000,&#xA;    B00000000&#xA;};&#xA;&#xA;byte img2[] = {&#xA;    B00000000,&#xA;    B01100110,&#xA;    B01100110,&#xA;    B00000000,&#xA;    B00011000,&#xA;    B10000001,&#xA;    B01000010,&#xA;    B00111100&#xA;};&#xA;&#xA;const int rowPins[] = {13,12,11,10,9,8,7,6};&#xA;const int columnPins[] = {5,4,3,2,14,15,16,17};&#xA;&#xA;const int but1 = 18;&#xA;const int but2 = 19;&#xA;&#xA;int but1State = 0;&#xA;int but2State = 0;&#xA;int but1Now;&#xA;int but2Now;&#xA;&#xA;int value1;&#xA;int value2;&#xA;&#xA;void setup() {&#xA;&#xA;    for (int i = 0; i&amp;lt;8; i++){&#xA;        pinMode(rowPins[i], OUTPUT);&#xA;        pinMode(columnPins[i], OUTPUT);&#xA;        digitalWrite(columnPins[i], HIGH); &#xA;    }&#xA;&#xA;    pinMode(but1, INPUT);&#xA;    pinMode(but2, INPUT);&#xA;&#xA;    but1State = digitalRead(but1);&#xA;    but2State = digitalRead(but2);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    but1Now = digitalRead(but1);&#xA;    delay(5);&#xA;    int but1Now1 = digitalRead(but1);&#xA;&#xA;    if(but1Now == but1Now1) &#xA;    {&#xA;        if(but1Now != but1State)&#xA;        {&#xA;            value1 = 1;&#xA;            value2 = 0;&#xA;            //show(img2);&#xA;        }&#xA;&#xA;        but1State = but1Now;&#xA;    }&#xA;&#xA;    but2Now = digitalRead(but2);&#xA;    delay(5);&#xA;    int but2Now1 = digitalRead(but2);&#xA;&#xA;    if(but2Now == but2Now1) &#xA;    {&#xA;        if(but2Now != but2State)&#xA;        {&#xA;            value1 = 0;&#xA;            value2 = 1;&#xA;            //show(img2);&#xA;        }&#xA;&#xA;        but2State = but2Now;&#xA;    }&#xA;&#xA;    if(value1 == 1)&#xA;    {&#xA;        show(img1);&#xA;    }&#xA;&#xA;    if(value2 == 1)&#xA;    {&#xA;        show(img2);&#xA;    }&#xA;}&#xA;&#xA;void show(byte*image) {&#xA;&#xA;    for(int row = 0; row&amp;lt;8; row++) &#xA;    {&#xA;        digitalWrite(rowPins[row], HIGH);&#xA;&#xA;        for(int col=0; col&amp;lt;8; col++) &#xA;        { &#xA;            boolean pixel = bitRead(image[row],col);&#xA;&#xA;            if(pixel == 1) &#xA;            {&#xA;                digitalWrite(columnPins[col], LOW);&#xA;            }&#xA;&#xA;            delayMicroseconds(150);&#xA;            digitalWrite(columnPins[col], HIGH);&#xA;        }&#xA;&#xA;        digitalWrite(rowPins[row], LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7143" LastEditorUserId="84" LastEditDate="2015-05-12T19:15:34.697" LastActivityDate="2015-05-12T19:15:34.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8559" PostTypeId="1" CreationDate="2015-02-10T14:03:18.560" Score="6" ViewCount="24533" Body="&lt;p&gt;Compilation of even the simplest program (like Blink) is extremely slow, the progress bar often hangs halfway for nearly half a minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wbMQM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal? I understand that not all computers are equally fast, but there's a huge difference between 3 seconds and 30 seconds  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;&lt;br&gt;&#xA;It appears from the report that every time I switch programs they're built anew completely:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Build options changed, rebuilding all&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;even when nothing has been changed. How can I avoid a complete rebuild?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-02-10T14:28:04.680" LastActivityDate="2019-09-26T03:30:40.550" Title="Compiling is slow" Tags="|compile|" AnswerCount="6" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8560" PostTypeId="1" CreationDate="2015-02-10T15:04:17.940" Score="1" ViewCount="989" Body="&lt;p&gt;Are there Arduino UNO R3s which use a crystal instead of a ceramic resonator? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Frankly, I don't understand this cheapness: if you really want to save on component cost you can run both AVRs on the same crystal. The 16U2 always has a crystal.)&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-11T14:00:27.710" Title="Arduino Uno with crystal" Tags="|arduino-uno|frequency|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8561" PostTypeId="2" ParentId="8559" CreationDate="2015-02-10T16:49:08.017" Score="0" Body="&lt;p&gt;I would download the non-install version and try compiling the blink sketch in it.  This will let you know if it is a computer specific issue or something related to your install.  I experienced something similar with a library that wasn't updated correctly between versions which caused all sorts of buggy behavior.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-10T16:49:08.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8562" PostTypeId="2" ParentId="8560" CreationDate="2015-02-10T16:50:46.127" Score="3" Body="&lt;p&gt;Some of the &lt;a href=&quot;http://www.freeduino.org/about.html&quot; rel=&quot;nofollow&quot;&gt;Freeduino&lt;/a&gt; boards use crystals although the newer ones now use a cheaper USB to serial chip (the CH340) instead of the Atmel chip used on the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://shop.evilmadscientist.com/productsmenu/tinykitlist/180&quot; rel=&quot;nofollow&quot;&gt;diavolino&lt;/a&gt; is another build-it-yourself board that has a crystal. I am sure there are many others. The &lt;a href=&quot;http://www.ruggedcircuits.com/ruggeduino&quot; rel=&quot;nofollow&quot;&gt;ruggeduino&lt;/a&gt; is another that uses a crystal and also markets itself as being practically indestructible. Their &lt;a href=&quot;http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;&quot;How to Destroy an Arduino&quot;&lt;/a&gt; is well worth a read for things to avoid doing to your Uno.&lt;/p&gt;&#xA;" OwnerUserId="6703" LastActivityDate="2015-02-10T16:50:46.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8563" PostTypeId="1" AcceptedAnswerId="8650" CreationDate="2015-02-10T17:05:26.027" Score="1" ViewCount="606" Body="&lt;p&gt;I am experiencing a problem when programming Arduino Micro in OSX Mavericks. I have tried to reproduce this problem in XCode and Arduino IDE and it is persistent. I need to make a hard-reset at the same time as a click the &quot;program&quot; button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to use the new Leonardo bootloader to see if it solves my issue, but its still persistent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running avrdude 6.1, what is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stacktrace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---- Size ----&#xA;&#xA;Binary sketch size:   24162 bytes (of a 28672 byte maximum)&#xA;Estimated SRAM used:  733 bytes (of a 2560 byte maximum)&#xA;Elapsed time: 5.2 s&#xA;&#xA;---- Reset ---- &#xA;&#xA;screen -X kill&#xA;&#xA;No screen session found.&#xA;&#xA;make: [reset] Error 1 (ignored)&#xA;&#xA;sleep 1&#xA;&#xA;9.2-RESET:  &amp;lt;   micro   ./ ./   &#xA;&#xA;stty -f /dev/tty.usbmodem1411 1200&#xA;&#xA;---- Upload ---- &#xA;&#xA;10.6-UPLOAD:  &amp;lt;     micro   ./  &#xA;&#xA;&#xA;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -patmega32u4 -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -D -cavr109 -b57600 -P/dev/tty.usbmodem1411 -Uflash:w:Builds/embeddedcomputing.hex:i&#xA;&#xA;&#xA;Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7257" LastEditorUserId="7257" LastEditDate="2015-02-14T10:33:18.667" LastActivityDate="2015-02-14T21:09:42.203" Title="Cannot program Arduino Micro in OSX without hard resetting the board every time" Tags="|arduino-ide|avrdude|arduino-micro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8564" PostTypeId="1" AcceptedAnswerId="8656" CreationDate="2015-02-10T17:16:28.380" Score="1" ViewCount="3819" Body="&lt;p&gt;I am flashing a &lt;em&gt;naked&lt;/em&gt; ATmega32U4, but the process fails in the end where it is verifying.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c dragon_isp -p m32u4 -P usb -U flash:w:Caterina-Micro.hex -U lfuse:w:0xff:m -U hfuse:w:0xd8:m -U efuse:w:0xcb:m -U lock:w:0x2f:m -v -B 100&#xA;&#xA;avrdude: Version 6.1, compiled on Mar 23 2014 at 04:42:55&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2014 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/local/Cellar/avrdude/6.1/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/SomeUser/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : usb&#xA;         Using Programmer              : dragon_isp&#xA;         Setting bit clk period        : 100.0&#xA;avrdude: usbdev_open(): Found AVRDRAGON, serno: 00A200050468&#xA;JTAG ICE mkII sign-on message:&#xA;Communications protocol version: 1&#xA;M_MCU:&#xA;  boot-loader FW version:        255&#xA;  firmware version:              7.38&#xA;  hardware version:              1&#xA;S_MCU:&#xA;  boot-loader FW version:        255&#xA;  firmware version:              7.38&#xA;  hardware version:              7&#xA;Serial number:                   00:a2:00:05:04:68&#xA;Device ID:                       AVRDRAGON&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : DRAGON_ISP&#xA;         Description     : Atmel AVR Dragon in ISP mode&#xA;         Vtarget         : 5.0 V&#xA;         SCK period      : 100.37 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.16s&#xA;&#xA;avrdude: Device signature = 0x1e9587&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as D8&#xA;avrdude: safemode: efuse reads as CB&#xA;avrdude: NOTE: &quot;flash&quot; memory has been specified, an erase cycle will be performed&#xA;         To disable this feature, specify the -D option.&#xA;avrdude: erasing chip&#xA;avrdude: reading input file &quot;Caterina-Micro.hex&quot;&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: writing flash (32730 bytes):&#xA;&#xA;Writing | ################################################## | 100% 62.28s&#xA;&#xA;avrdude: 32730 bytes of flash written&#xA;avrdude: verifying flash memory against Caterina-Micro.hex:&#xA;avrdude: load data flash data from input file Caterina-Micro.hex:&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: input file Caterina-Micro.hex contains 32730 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 152.35s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x0002&#xA;         0x66 != 0x6e&#xA;avrdude: verification error; content mismatch&#xA;&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.&#xA;avrdude: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming mode&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get another verification error when i program without fuses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c dragon_isp -p atmega32u4 -P usb -U flash:w:Caterina-Micro.hex -u&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.16s&#xA;&#xA;avrdude: Device signature = 0x1e9587&#xA;avrdude: NOTE: &quot;flash&quot; memory has been specified, an erase cycle will be performed&#xA;         To disable this feature, specify the -D option.&#xA;avrdude: erasing chip&#xA;avrdude: reading input file &quot;Caterina-Micro.hex&quot;&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: writing flash (32730 bytes):&#xA;&#xA;Writing | ################################################## | 100% 69.60s&#xA;&#xA;avrdude: 32730 bytes of flash written&#xA;avrdude: verifying flash memory against Caterina-Micro.hex:&#xA;avrdude: load data flash data from input file Caterina-Micro.hex:&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: input file Caterina-Micro.hex contains 32730 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 178.10s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x0000&#xA;         0x04 != 0x0c&#xA;avrdude: verification error; content mismatch&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7257" LastEditorUserId="7257" LastEditDate="2015-02-11T11:07:42.917" LastActivityDate="2015-02-15T10:22:37.403" Title="Unable to flash bootloader on ATmega32U4 with AVR dragon" Tags="|avr|avrdude|arduino-micro|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="8565" PostTypeId="2" ParentId="8559" CreationDate="2015-02-10T19:30:58.947" Score="0" Body="&lt;p&gt;The occurrence of “Build options changed, rebuilding all” (as mentioned in edited question and shown in screen shot) probably is causing the large delay.  My belief (correct or not) is that lots of libraries are being rebuilt when that message appears.  Ordinarily, libraries should be rebuilt only upon initial install or when changing target board type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=271617.0&quot; rel=&quot;nofollow&quot;&gt;arduino.cc thread&lt;/a&gt;, “&quot;Build options changed, rebuilding all&quot; even when nothing changes ==&gt; very slow”, from 2014 treats the issue superficially, merely pointing out that Arduino 1.5.8 Beta is suitable for Yún and Arduino Due boards, not “regular Arduino” boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 2011 &lt;a href=&quot;https://code.google.com/p/arduino/issues/detail?id=638&quot; rel=&quot;nofollow&quot;&gt;Google code&lt;/a&gt; thread probably is mostly irrelevant, but it's worth trying some steps mentioned in posts #14 and 15  ‒ eg, starting arduino via a path with no spaces in names ‒ if your platform is MS Windows.  If the Arduino IDE cannot find its options or preference files it probably assumes it is starting from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, please edit the question to specify how you started the Arduino IDE running, where the IDE is installed on your system, what your op system is, and what your computer is.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-02-10T19:30:58.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8566" PostTypeId="1" AcceptedAnswerId="8579" CreationDate="2015-02-10T21:38:02.527" Score="0" ViewCount="2013" Body="&lt;p&gt;I have a project which runs a continuous loop and listens for the push of a button to light an led and activate a servo motor on an Arduino Uno (R2). The arduino is powered by 4 AA batteries, and the servo is powered by a 9V. I'm wondering how long I can leave this running off battery power. Does anyone know how to estimate this? As a side note, if anyone spots a way to improve battery life in my sketch / wiring, I'd love to know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code and attached is the wiring diagram for the project (minus the batteries).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;const int buttonPin = 2;     // the number of the pushbutton pin&#xA;boolean buttonPushed = false;&#xA;&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;&#xA;const int servoPin = 9;&#xA;Servo servo;&#xA;int angle = 0;&#xA;int servoStartAngle = 90;&#xA;int servoEndAngle = 10;&#xA;&#xA;boolean servoActivated = false;&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;&#xA;int photoCellPin = 2;&#xA;int photoCellThreshold = 500;&#xA;int photoCellActivated = false;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);&#xA;&#xA;  servo.attach(servoPin);&#xA;  servo.write(servoStartAngle);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;  // read the state of the pushbutton value:&#xA;  buttonState = digitalRead(buttonPin);&#xA;&#xA;  int photoCellVal = analogRead(photoCellPin);&#xA;&#xA;  if (photoCellVal &amp;gt; photoCellThreshold){&#xA;   photoCellActivated = true; &#xA;  } else {&#xA;   photoCellActivated = false; &#xA;  }&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (buttonState == LOW &amp;amp;&amp;amp; buttonPushed == false) {     &#xA;    // turn LED on:    &#xA;    buttonPushed = true;&#xA;    Serial.println(&quot;button pushed&quot;);&#xA;  } else if (buttonState == LOW &amp;amp;&amp;amp; buttonPushed == true){&#xA;   buttonPushed = false;&#xA;   Serial.println('deactivate');&#xA;  } &#xA;&#xA;&#xA;&#xA;  if (buttonPushed == true){&#xA;   digitalWrite(ledPin, HIGH); &#xA;  } else {&#xA;   digitalWrite(ledPin, LOW); &#xA;  }&#xA;&#xA;  if (buttonPushed &amp;amp;&amp;amp; servoActivated == false &amp;amp;&amp;amp; photoCellActivated == true){&#xA;    servoActivated = true;&#xA;    Serial.println(&quot;activate motor&quot;);&#xA;&#xA;    for(angle = servoStartAngle; angle &amp;gt; servoEndAngle; angle--){                                  &#xA;      servo.write(angle);&#xA;      Serial.println(angle);&#xA;      delay(15);    &#xA;    } &#xA;  } else if (buttonPushed == false &amp;amp;&amp;amp; servoActivated == true){ //deactivate&#xA;    for(angle = servoEndAngle; angle &amp;lt; servoStartAngle; angle++){                                  &#xA;      servo.write(angle);&#xA;      Serial.println(angle);&#xA;      delay(15);    &#xA;    }&#xA;    delay(200);&#xA;    servoActivated = false; &#xA;&#xA;  }&#xA;&#xA;  delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6341" LastActivityDate="2015-02-11T23:50:01.173" Title="estimating battery run time" Tags="|arduino-uno|power|battery|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8567" PostTypeId="2" ParentId="8549" CreationDate="2015-02-10T22:08:34.470" Score="3" Body="&lt;p&gt;If your aim is to send a constant value from Arduino A to Arduino B, then a really easy way is to use SoftwareSerial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you are using Arduino Uno - you can use pins 2 and 3 for SoftwareSerial (see which pins are supported for which device at &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SoftwareSerial&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cross connect pin 2 and 3 from Arduino A to pin 3 and 2 of Arduino B. You can send any random data between the two Arduinos by uploading a sketch like the following on to each. You can use a program like CoolTerm to have a &quot;SerialMonitor&quot; open to each Arduino (using the Arduino IDE, you can open only one monitor at a time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of this approach over using AnalogWrite/AnalogRead is that with AnalogRead, you can only get 1024 values, which is based on the voltage. With SoftwareSerial, you can send any arbitrary data. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the SoftwareSerial library so you can use its functions:&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define rxPin 2&#xA;#define txPin 3&#xA;&#xA;SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);&#xA;&#xA;void setup() {&#xA;    pinMode(rxPin, INPUT);&#xA;    pinMode(txPin, OUTPUT);&#xA;&#xA;    mySerial.begin(9600);&#xA;&#xA;    Serial.begin(9600);&#xA; }&#xA;&#xA;void loop() {&#xA;&#xA;    if ( mySerial.available() )&#xA;    {&#xA;         while ( mySerial.available() )&#xA;             Serial.write(mySerial.read());&#xA;&#xA;         Serial.println();&#xA;    }&#xA;&#xA;    if ( Serial.available() )&#xA;    {&#xA;        delay(5);&#xA;&#xA;        while ( Serial.available() )&#xA;            mySerial.write( Serial.read() );&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7262" LastActivityDate="2015-02-10T22:08:34.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8568" PostTypeId="1" CreationDate="2015-02-10T23:10:45.640" Score="1" ViewCount="593" Body="&lt;p&gt;I am developing a product, and to ease my job i am planning to use MCU inside the arduino with the library of Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since all the registers are already defined inside the library, and all required things to registers of corresponding MCU are done to &quot;make a pin input/output , enable interrupt , enable UART , enable I2C&quot;. I think that i can directly use the arduino coding enviroment even if i use MCU seperately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible and how?  (can i use it in commertial product, i have already prototyped it with arduino)&lt;/p&gt;&#xA;" OwnerUserId="7263" LastActivityDate="2015-02-12T12:57:08.550" Title="Can i use arduino code, without using arduino board but just using MCU included" Tags="|programming|bootloader|arduino-ide|compile|prototype|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8569" PostTypeId="2" ParentId="8568" CreationDate="2015-02-10T23:15:05.047" Score="1" Body="&lt;p&gt;Yes, you can. Once you have a .hex file for a specific MCU and environment you can &lt;a href=&quot;https://arduino.stackexchange.com/questions/3906/how-do-i-write-an-arduino-program-to-an-avr-chip-without-the-arduino-bootloader&quot;&gt;use a programmer&lt;/a&gt; to upload it to a discrete MCU.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-02-10T23:15:05.047" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8570" PostTypeId="2" ParentId="8549" CreationDate="2015-02-11T00:28:41.227" Score="0" Body="&lt;p&gt;As others have pointed out, your original suggestion will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use PWM output and a filter which may work (you will need quite a large capacitor and/or resistor). The input at the other end would only be an approximation of the output (you could calculate based on detailed knowledge of component values and frequencies). Depending on the rate at which the value changes you may get different values on each read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are better ways. As suggested, serial will work (either hardware or software depending on other factors), and is probably easiest. You could use any of the common communication protocols (I²C or SPI) or even send values via IP.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="3879" LastEditDate="2015-02-11T00:34:50.810" LastActivityDate="2015-02-11T00:34:50.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8571" PostTypeId="1" CreationDate="2015-02-11T01:01:28.693" Score="1" ViewCount="369" Body="&lt;p&gt;I'm intending to set up a digital delay using a circular buffer (in SRAM) with an Arduino Due (@84MHz). The lenth of the buffer determines the delay. I need about 1us resolution and the delay needs to be dynamically settable between 0 - 500us. I'll probably use most of the memory just for the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a very basic setup going (with a fixed delay, no buffer), that just updates a temporary variable with the current state of the input signal and then writes the whole word to another port in order to set the state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next up is designing the buffer so I can add some delay to the output of the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Filling the buffer using interrupts watching signals on the same port shouldn't be too difficult but I am wondering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) taking speed in consideration, which buffer method will have the least processing overhead? Memory stack or an array[], or someting else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) is there a way to read a port and set an output port in one clock cycle? I am now using &lt;code&gt;REG_PIOD_ODSR=outbyte;&lt;/code&gt; but ideally it needs to point to a memory address directly.&lt;/p&gt;&#xA;" OwnerUserId="7264" LastActivityDate="2015-04-20T22:04:10.813" Title="fast memory buffer and setting output state" Tags="|arduino-due|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8573" PostTypeId="2" ParentId="8480" CreationDate="2015-02-11T06:12:39.777" Score="1" Body="&lt;p&gt;You say that they are working on RS232 - which is an electrical standard.  You may mean that they use standard UART style asynchronous serial communications - perhaps at 0 to 5V electrical levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on how fast you need to communicate, and how continuously you need to communicate.   If you can choose when to communicate with each device, you may be able to use Soft Serial with multiple pins.  Be aware that it cannot both transmit and receive at the same time (one or the other), and it can only communicate with one port at a time.  So it might work for you if you can communicate with one device for a while, then ignore it while you check with other devices, one at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise maybe not.  For example, if you need to receive from many devices at times of their choosing so you need an always-on hardware UART for each device.  There are 4 hardware UARTs in the MEGA, so 4 would be your limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are things like external UART peripherals, but managing that would likely be very hard for you.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2015-02-11T06:12:39.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8574" PostTypeId="2" ParentId="8568" CreationDate="2015-02-11T07:18:51.577" Score="0" Body="&lt;p&gt;Ignacio said everything is needed. Just search on google :) You can use programmer like &lt;a href=&quot;http://khazama.com/project/programmer/&quot; rel=&quot;nofollow&quot;&gt;khazama&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you can use arduino board to program atmel chips.&#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Using an Arduino as an AVR ISP &lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now you need only .hex file to upload to your chip&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://alselectro.wordpress.com/2014/01/26/where-are-the-hex-files-compiled-by-arduino/&quot; rel=&quot;nofollow&quot;&gt;How to find .HEX&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to point out one thing. Do not play with lock bits:)&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="42" LastEditDate="2015-02-11T11:26:20.437" LastActivityDate="2015-02-11T11:26:20.437" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8575" PostTypeId="2" ParentId="8566" CreationDate="2015-02-11T08:07:58.223" Score="1" Body="&lt;p&gt;I can support what mheavers said in a comment above. Use a Bareduino or any kind of custom Board, use sleep-modes and avoid delay(). I wrote a blog-post about my experiences with this setup &lt;a href=&quot;https://holadimake.wordpress.com/2015/01/02/building-a-cellular-tracker-part3-running-on-batteries-for-months/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, if you get it right the ATmel can go down below 1mA in sleep. In your case an extreme scenario (depending on your usage pattern) could be to wake-up the Arduino with an interrupt triggered through the sensor and otherwise sleep completely. You will find example on the net where people used a setup like this for remote controls for instance.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-02-11T08:07:58.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8577" PostTypeId="1" CreationDate="2015-02-11T09:45:54.977" Score="2" ViewCount="360" Body="&lt;p&gt;so I'm using a promini running on solar power. For some reason, after sometime it gets stuck with the green led flashing and only by cutting power can I reset the promini. Even the reset button doesnt work. Exactly like in this post &quot;&lt;a href=&quot;https://arduino.stackexchange.com/questions/2922/watchdog-timer-stuck-in-restart-loop-green-led-flashing&quot;&gt;Watchdog timer stuck in restart loop? (green led flashing)&lt;/a&gt;&quot;. However, the strange thing is that I am not even using a watchdog timer. So what could be the cause of it? Could it be due to the lack of power from my solar panel?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;int green = 8;&#xA;int red = 6;&#xA;&#xA;// ce,csn pins&#xA;RF24 radio(9,10);&#xA;&#xA;// init data buffer to hold a sensor type byte and one uint16_t sensor data&#xA;unsigned char data[3] = {&#xA;  0};&#xA;unsigned long count=0;&#xA;&#xA;void(* resetFunc) (void) = 0;//declare reset function at address 0&#xA;void setup(void)&#xA;{&#xA;  pinMode(4, OUTPUT); &#xA;  digitalWrite(4,HIGH); &#xA;  pinMode(5, OUTPUT); &#xA;  pinMode(green, OUTPUT); &#xA;  pinMode(red, OUTPUT); &#xA;  pinMode(3, OUTPUT); &#xA;&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;**************V1 Send Sensor Data***********&quot;);&#xA;  radio.begin();&#xA;  radio.setPALevel(RF24_PA_MAX);&#xA;  radio.setChannel(0x4c);&#xA;&#xA;  // open pipe for writing&#xA;  radio.openWritingPipe(0xF0F0F0F0E1LL);&#xA;&#xA;  radio.enableDynamicPayloads();&#xA;  radio.setAutoAck(false);&#xA;    radio.setDataRate(RF24_1MBPS);&#xA;  radio.powerUp();&#xA;  Serial.println(&quot;...Sending&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  digitalWrite(5,HIGH); &#xA;  delay(50);&#xA;  uint16_t sensorValue = analogRead(0);&#xA;  digitalWrite(5,LOW); &#xA;&#xA;  Serial.println(sensorValue);&#xA;  if (sensorValue &amp;gt; 600){&#xA;    digitalWrite(red,LOW );&#xA;    digitalWrite(green,HIGH);&#xA;  }&#xA;  if (sensorValue &amp;gt;= 0 &amp;amp;&amp;amp; sensorValue &amp;lt;= 300){&#xA;    digitalWrite(red,HIGH);&#xA;    digitalWrite(green,LOW);&#xA;  }   &#xA;&#xA;  //assign identification to the node.&#xA;  // In use = A &amp;amp; B;&#xA;  data[0] = 'B';&#xA;  //do the bit shift to put uint16 into uint8 array&#xA;  data[1] = sensorValue &amp;gt;&amp;gt; 8;&#xA;  data[2] = sensorValue;&#xA;  Serial.print(count);&#xA;  Serial.print(&quot;   |   Identity: &quot;);&#xA;  Serial.print(data[0]);&#xA;  Serial.print(&quot;   |   &quot;);&#xA;  Serial.print(&quot; data[1]: &quot;);&#xA;  Serial.print(data[1]);&#xA;  Serial.print(&quot;  |  data[2]: &quot;);&#xA;  Serial.print(data[2]);&#xA;  digitalWrite(3,HIGH);&#xA;  // print and increment the counter&#xA;  radio.startWrite(data, sizeof(uint16_t)+1);&#xA;  Serial.print(&quot;  | Temperature sent:  &quot;);&#xA;  Serial.println(sensorValue);&#xA;  digitalWrite(3,LOW);&#xA;  // pause 5 seconds&#xA;  delay(5000);&#xA;  resetFunc();  //call reset&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you so much!&lt;/p&gt;&#xA;" OwnerUserId="6205" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-02-11T09:45:54.977" Title="Arduino ProMini green led flashing and unable to reset" Tags="|power|library|arduino-pro-mini|reset|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8578" PostTypeId="2" ParentId="8564" CreationDate="2015-02-11T10:30:22.510" Score="0" Body="&lt;p&gt;I think you need to pass the option &lt;code&gt;-u&lt;/code&gt; to disable safe mode, see the &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions&quot; rel=&quot;nofollow&quot;&gt;avrdude documentation&lt;/a&gt;. Under the &lt;code&gt;-u&lt;/code&gt; option the manual states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you want to change fuses you will need to specify this option&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-02-11T10:30:22.510" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8579" PostTypeId="2" ParentId="8566" CreationDate="2015-02-11T11:17:46.470" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm wondering how long I can leave this running off battery power. Does anyone know how to estimate this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your circuit draws 1A @ 12V, a 12V 1Ah battery will power it for approximately one hour. A 9V alkaline typically contains about 565mAh. You can use the datasheets to sum all the power consumption, but its probably easier just to measure it with a multimeter.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As a side note, if anyone spots a way to improve battery life in my&#xA;  sketch / wiring, I'd love to know.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;-Check out the ATTiny series (&lt;a href=&quot;http://www.atmel.com/v2PFResults.aspx#(actives:!(8238,8394,8362,8282,8431,8300,8358,8392,8378,8445,8236,8449,8474,8248,8264,8447,8256,8254,8286,8462,8429,8458,8466,8400,8302,8278),data:(area:&amp;#39;&amp;#39;,category:&amp;#39;34864[33180[33086]]&amp;#39;,pm:!((i:8238,v:!(1,7)),(i:8394,v:!(0,7)),(i:8362,v:!(5,12)),(i:8282,v:!(5)),(i:8431,v:!(1,8)),(i:8300,v:!(1,5)),(i:8358,v:!(1,19)),(i:8392,v:!(0,1)),(i:8378,v:!n),(i:8445,v:!(5,6,9)),(i:8236,v:!(0,9)),(i:8449,v:!(1,3)),(i:8474,v:!(0)),(i:8248,v:!(0,1)),(i:8264,v:!(1,2)),(i:8447,v:!(0,1)),(i:8256,v:!(1,4)),(i:8254,v:!(3,16)),(i:8286,v:!(0)),(i:8462,v:!(0,2)),(i:8429,v:!(1,2)),(i:8458,v:!(0,1)),(i:8466,v:!(4)),(i:8400,v:!(0,7)),(i:8302,v:!(0)),(i:8278,v:!(0))),view:table),sc:1)&quot; rel=&quot;nofollow&quot;&gt;parametric&lt;/a&gt;); they are tiny, low-power, and Arduino-compatible; perfect when you only need a couple of pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Use an interrupt to monitor the button's pin; the MCU can sleep until the interrupt fires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally:&lt;br&gt;&#xA;1) The interrupt will set a flag so main() knows that something happened, then wake the processor.&lt;br&gt;&#xA;2) Main() resumes, checks the flag, turns on/off the LED accordingly, tells the servo where to go, waits for the servo to get there (delay()), clears the flag, and then puts the MCU back to sleep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-As others have pointed out, delay() is bad. delay() tells the MCU to &lt;strong&gt;do nothing&lt;/strong&gt; (NO-OP) repeatedly, for a period of time. This is different from having &lt;strong&gt;nothing to do&lt;/strong&gt; because it's asleep.&lt;/p&gt;&#xA;" OwnerUserId="6980" LastEditorUserId="6980" LastEditDate="2015-02-11T23:50:01.173" LastActivityDate="2015-02-11T23:50:01.173" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8580" PostTypeId="1" AcceptedAnswerId="8746" CreationDate="2015-02-11T12:26:25.183" Score="1" ViewCount="4601" Body="&lt;p&gt;I'm working on data acquisition from a sensor attached to the Arduino : MPU6050 using a model in Ssimulink. I have installed the hardware support in Simulink but I don't know how to start building the model. The model must read the data from the Arduino by deploying it into the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My connection Arduino &amp;lt;=&gt; MPU6050 is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino    MPU 9150&#xA;3.3V       VCC&#xA;GND        GND&#xA;A5         SCL&#xA;A4         SDA&#xA;DIGITAL 2  INT&#xA;GND        AD0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;update : i have use a s-function but I get the following error:&#xA;_The call to realtime_make_rtw_hook, during the after_make hook generated the following error: Could not download the model to the target hardware. Verify the connection between the computer and target hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The build process will terminate as a result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caused by: Could not download the model to the target hardware. Verify the connection between the computer and target hardware._&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the target is definitely connected, and downloading others module (like led blinking ) with simulink is working fine. I've also tested this on a different PC with Windows 8 (64bits) with the same result. Can anyone give me a hint please?&lt;/p&gt;&#xA;" OwnerUserId="7270" LastEditorUserId="7270" LastEditDate="2015-02-22T23:32:26.923" LastActivityDate="2016-11-16T14:58:12.027" Title="Simulink with arduino : data acquisition" Tags="|serial|mpu6050|simulator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8582" PostTypeId="1" CreationDate="2015-01-23T22:11:10.100" Score="1" ViewCount="1331" Body="&lt;p&gt;I want my Attiny85 to communicate with another attiny85.&#xA;one attiny should send a message to my other attiny. When he receives the correct message he should turn one led on. Just a very simple test scatch.&#xA;I don't know why but the led never turns on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1st attiny85:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int clk_pin = 4,&#xA;    data_pin = 3,&#xA;    led = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(clk_pin, INPUT);&#xA;  pinMode(data_pin, INPUT);&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte incoming = shiftIn(data_pin, clk_pin, LSBFIRST);&#xA;&#xA;  if (incoming == 2)&#xA;  {&#xA;    digitalWrite(led, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(led, LOW);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2nd attiny:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int clk_pin = 0,&#xA;    data_pin = 1;&#xA;&#xA;void setup(){&#xA;  pinMode(clk_pin, OUTPUT);&#xA;  pinMode(data_pin, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  byte test = 2;&#xA;  shiftOut(data_pin, clk_pin, LSBFIRST, test);&#xA;&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think there might be something wrong with my shiftIn/shiftOut command. It's actually the first time I'm using this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for helping!&lt;/p&gt;&#xA;" OwnerDisplayName="user3025417" LastActivityDate="2015-02-11T13:32:35.357" Title="use shiftIn and shiftOut with attiny85" Tags="|c++|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8583" PostTypeId="2" ParentId="8582" CreationDate="2015-02-11T13:32:35.357" Score="2" Body="&lt;p&gt;&lt;code&gt;shiftIn()&lt;/code&gt; and &lt;code&gt;shiftOut()&lt;/code&gt; are designed for communicating with different types of shift registers. These are typically external components which don't run code themselves, such as the 74HC595.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't use &lt;code&gt;shiftIn()&lt;/code&gt; to read data that's been written using &lt;code&gt;shiftOut()&lt;/code&gt;. The reason is that both functions try to act as the host in the communication -- i.e. the one that controls the clock line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you call &lt;code&gt;shiftIn()&lt;/code&gt;, the clock line is pulsed each time it's ready to read a bit (i.e. it tells the shift register when to write). When you call &lt;code&gt;shiftOut()&lt;/code&gt;, the clock line is pulsed each time it writes a bit (i.e. it tells the shift register when to read). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither one will respond to a clock line provided externally. The result is that your ATTiny's aren't synchronised so they won't be reading/writing at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A much simpler approach would be to setup a conventional serial connection between the two microcontrollers. You could do that either using &lt;a href=&quot;http://arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;software&lt;/a&gt; or &lt;a href=&quot;http://arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;hardware&lt;/a&gt; serial. The only caveat is that the sender would need to ensure the receiver is up-and-running before it transmits anything. This could be done using some kind of handshake at startup -- one device repeatedly sends something until the other replies.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-11T13:32:35.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8584" PostTypeId="2" ParentId="8560" CreationDate="2015-02-11T14:00:27.710" Score="1" Body="&lt;p&gt;It appears that the Arduino Leonardo uses a crystal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/flmUx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Sparkfun site it's the same price as the Uno R3, so I think I'll go for the Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-11T14:00:27.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8585" PostTypeId="1" CreationDate="2015-02-11T14:12:25.447" Score="1" ViewCount="1323" Body="&lt;p&gt;I am currently doing the project in pulse measurement using an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;Arduino Yún&lt;/a&gt;. I am using the pulse sensor SEN-11574.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I verify the code I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.5.8 (Linux), Board: &quot;Arduino Yún&quot;&#xA;&#xA;pulse-sensor-arduino/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduino/pulse-sensor-arduino.cpp:39: multiple definition of `pulsePin'&#xA;sketch_feb10a.cpp.o:/home/system1/Downloads/arduino-1.5.8/sketch_feb10a.ino:18: first defined here&#xA;pulse-sensor-arduino/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduino/pulse-sensor-arduino.cpp:39: multiple definition of `Pulse'&#xA;sketch_feb10a.cpp.o:/home/system1/Downloads/arduino-1.5.8/sketch_feb10a.ino:18: first defined here&#xA;collect2: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;pulse-sensor-arduino.h&amp;gt;&#xA;&#xA;int pulsePin = 0;&#xA;int blinkPin = 13;&#xA;int fadePin = 5;&#xA;int fadeRate = 0;&#xA;&#xA;&#xA;volatile int BPM;&#xA;volatile int Signal;&#xA;volatile int IBI = 600;&#xA;volatile boolean Pulse = false;&#xA;volatile boolean QS = false;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;    pinMode(blinkPin, OUTPUT);&#xA;    pinMode(fadePin, OUTPUT);&#xA;    Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    sendDataToProcessing('S', Signal);&#xA;    if (QS == true) {&#xA;        fadeRate = 255;&#xA;        sendDataToProcessing('B',BPM);&#xA;        sendDataToProcessing('Q',IBI);&#xA;        QS = false;&#xA;    }&#xA;&#xA;    ledFadeToBeat();&#xA;&#xA;    delay(5000);&#xA;}&#xA;&#xA;&#xA;void ledFadeToBeat() {&#xA;    fadeRate -= 15;&#xA;    fadeRate = constrain(fadeRate,0,255);&#xA;    analogWrite(fadePin,fadeRate);&#xA;}&#xA;&#xA;&#xA;void sendDataToProcessing(char symbol, int data ) {&#xA;    Serial.print(symbol);&#xA;    Serial.println(data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my pulse Arduino cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;pulse-sensor-arduino.h&quot;&#xA;&#xA;volatile int rate[10];                        // Array to hold last ten IBI values&#xA;volatile unsigned long sampleCounter = 0;     // Used to determine pulse timing&#xA;volatile unsigned long lastBeatTime = 0;      // Used to find IBI&#xA;volatile int P =512;                          // Used to find peak in pulse wave, seeded&#xA;volatile int T = 512;                         // Used to find trough in pulse wave, seeded&#xA;volatile int thresh = 512;                    // Used to find instant moment of heart beat, seeded&#xA;volatile int amp = 100;                       // Used to hold amplitude of pulse waveform, seeded&#xA;volatile boolean firstBeat = true;            // Used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean secondBeat = false;          // Used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean Pulse = false;               // True when pulse wave is high, false when it's low&#xA;volatile int pulsePin;&#xA;&#xA;volatile int PulseSensor::IBI = 600;          // Holds the time between beats, must be seeded!&#xA;volatile int PulseSensor::BPM;                // Used to hold the pulse rate&#xA;volatile int PulseSensor::Signal;             // Holds the incoming raw data&#xA;volatile boolean PulseSensor::QS = false;     // Becomes true when Arduino finds a beat&#xA;&#xA;void PulseSensor::begin(int pPin)&#xA;{&#xA;  pinMode(pulsePin, INPUT);&#xA;  pulsePin = pPin;&#xA;&#xA;  // Initializes Timer1 to throw an interrupt every 2 ms.&#xA;  TCCR1A = 0x00;&#xA;  TCCR1B = 0x0C;  // CTC (Compare match mode) and ClockIO/256&#xA;  OCR1A = 0x7C;   // 2 ms&#xA;  TIMSK1 = 0x02;&#xA;  sei();          // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED&#xA;}&#xA;&#xA;// THIS IS THE TIMER 1 INTERRUPT SERVICE ROUTINE.&#xA;// Timer 1 makes sure that we take a reading every 2 miliseconds&#xA;ISR(TIMER1_COMPA_vect)&#xA;{                         // Triggered when Timer1 counts to 124&#xA;  cli();                                      // Disable interrupts while we do this&#xA;  PulseSensor::Signal = analogRead(pulsePin); // Read the Pulse Sensor&#xA;  sampleCounter += 2;                         // Keep track of the time in ms with this variable&#xA;  int N = sampleCounter - lastBeatTime;       // Monitor the time since the last beat to avoid noise&#xA;&#xA;  // Find the peak and trough of the pulse wave&#xA;  if(PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; N &amp;gt; (PulseSensor::IBI/5)*3){       // Avoid dichrotic noise by waiting 3/5 of last IBI&#xA;    if (PulseSensor::Signal &amp;lt; T){                        // T is the trough&#xA;      T = PulseSensor::Signal;                         // Keep track of lowest point in pulse wave&#xA;    }&#xA;  }&#xA;&#xA;  if(PulseSensor::Signal &amp;gt; thresh &amp;amp;&amp;amp; PulseSensor::Signal &amp;gt; P){          // Threshold condition helps avoid noise&#xA;    P = PulseSensor::Signal;                             // P is the peak&#xA;  }                                        // Keep track of highest point in pulse wave&#xA;&#xA;  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT&#xA;  //&#xA;  // The signal surges up in value every time there is a pulse&#xA;  if (N &amp;gt; 250){                                   // Avoid high-frequency noise&#xA;    if ( (PulseSensor::Signal &amp;gt; thresh) &amp;amp;&amp;amp; (Pulse == false) &amp;amp;&amp;amp; (N &amp;gt; (PulseSensor::IBI/5)*3) )&#xA;    {&#xA;      Pulse = true;                               // Set the Pulse flag when we think there is a pulse&#xA;      PulseSensor::IBI = sampleCounter - lastBeatTime;         // Measure time between beats in mS&#xA;      lastBeatTime = sampleCounter;               // Keep track of time for next pulse&#xA;&#xA;      if(secondBeat){                        // If this is the second beat, if secondBeat == TRUE&#xA;        secondBeat = false;                  // Clear secondBeat flag&#xA;        for(int i=0; i&amp;lt;=9; i++){             // Seed the running total to get a realisitic BPM at startup&#xA;          rate[i] = PulseSensor::IBI;&#xA;        }&#xA;      }&#xA;&#xA;      if(firstBeat){                         // If it's the first time we found a beat, if firstBeat == TRUE&#xA;        firstBeat = false;                   // Clear firstBeat flag&#xA;        secondBeat = true;                   // Set the second beat flag&#xA;        sei();                               // Enable interrupts again&#xA;        return;                              // IBI value is unreliable so discard it&#xA;      }&#xA;&#xA;&#xA;      // Keep a running total of the last 10 IBI values&#xA;      word runningTotal = 0;                  // Clear the runningTotal variable&#xA;&#xA;      for(int i=0; i&amp;lt;=8; i++){                // Shift data in the rate array&#xA;        rate[i] = rate[i+1];                  // And drop the oldest IBI value&#xA;        runningTotal += rate[i];              // Add up the 9 oldest IBI values&#xA;      }&#xA;&#xA;      rate[9] = PulseSensor::IBI;                          // add the latest IBI to the rate array&#xA;      runningTotal += rate[9];                // Add the latest IBI to runningTotal&#xA;      runningTotal /= 10;                     // Average the last 10 IBI values&#xA;      PulseSensor::BPM = 60000/runningTotal;               // How many beats can fit into a minute? that's BPM!&#xA;      PulseSensor::QS = true;                              // Set Quantified Self flag&#xA;      // QS FLAG IS NOT CLEARED INSIDE THIS ISR&#xA;    }&#xA;  }&#xA;&#xA;  if (PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; Pulse == true){   // When the values are going down, the beat is over&#xA;    Pulse = false;                         // Reset the Pulse flag so we can do it again&#xA;    amp = P - T;                           // Get amplitude of the pulse wave&#xA;    thresh = amp/2 + T;                    // Set thresh at 50% of the amplitude&#xA;    P = thresh;                            // Reset these for next time&#xA;    T = thresh;&#xA;  }&#xA;&#xA;  if (N &amp;gt; 2500){                           // If 2.5 seconds go by without a beat&#xA;    thresh = 512;                          // Set thresh default&#xA;    P = 512;                               // Set P default&#xA;    T = 512;                               // Set T default&#xA;    lastBeatTime = sampleCounter;          // Bring the lastBeatTime up to date&#xA;    firstBeat = true;                      // Set these to avoid noise&#xA;    secondBeat = false;                    // When we get the heartbeat back&#xA;  }&#xA;&#xA;  sei();                                   // Enable interrupts when youre done!&#xA;} // end ISR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my pulse Arduino header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef PULSE_SENSOR_ARDUINO_H&#xA;#define PULSE_SENSOR_ARDUINO_H&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;class PulseSensor&#xA;{&#xA;public:&#xA;  static void begin(int pulsePin);&#xA;&#xA;  static volatile int BPM;&#xA;  static volatile int Signal;&#xA;  static volatile int IBI;&#xA;  static volatile boolean QS;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I modified the program, but there is a new error present:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.5.8 (Linux), Board: &quot;Arduino Yún&quot;&#xA;&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `PulseSensor::begin(int)'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `pulsePin'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `__vector_17':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:54: multiple definition of `__vector_17'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:54: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `PulseSensor::Signal'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `sampleCounter'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `lastBeatTime'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data.thresh+0x0): multiple definition of `thresh'&#xA;pulsesensor.cpp.o:(.data.thresh+0x0): first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data._ZN11PulseSensor3IBIE+0x0): multiple definition of `PulseSensor::IBI'&#xA;pulsesensor.cpp.o:(.data._ZN11PulseSensor3IBIE+0x0): first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data.T+0x0): multiple definition of `T'&#xA;pulsesensor.cpp.o:(.data.T+0x0): first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data.P+0x0): multiple definition of `P'&#xA;pulsesensor.cpp.o:(.data.P+0x0): first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `Pulse'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `rate'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `PulseSensor::BPM'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `PulseSensor::QS'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data.firstBeat+0x0): multiple definition of `firstBeat'&#xA;pulsesensor.cpp.o:(.data.firstBeat+0x0): first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o: In function `PulseSensor::begin(int)':&#xA;/home/system1/Arduino/libraries/pulse-sensor-arduinom/pulse-sensor-arduino.cpp:39: multiple definition of `secondBeat'&#xA;pulsesensor.cpp.o:pulsesensor.cpp:39: first defined here&#xA;pulse-sensor-arduinom/pulse-sensor-arduino.cpp.o:(.data.amp+0x0): multiple definition of `amp'&#xA;pulsesensor.cpp.o:(.data.amp+0x0): first defined here&#xA;collect2: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my change code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;pulse-sensor-arduino.h&amp;gt;&#xA;&#xA;int blinkPin = 13;                // Pin to blink LED at each beat&#xA;int fadePin = 5;                  // Pin to do fancy classy fading blink at each beat&#xA;int fadeRate = 0;                 // Used to fade LED on with PWM on fadePin&#xA;&#xA;&#xA;void setup(){&#xA;  pinMode(blinkPin,OUTPUT);         // Pin that will blink to your heartbeat!&#xA;  pinMode(fadePin,OUTPUT);          // Pin that will fade to your heartbeat!&#xA;  Serial.begin(115200);             // We agree to talk fast!&#xA;&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  sendDataToProcessing('P', PulseSensor::Signal);     // Send Processing the raw Pulse Sensor data&#xA;  if (PulseSensor::QS == true){                       // Quantified Self flag is true when arduino finds a heartbeat&#xA;    fadeRate = 255;                  // Set 'fadeRate' Variable to 255 to fade LED with pulse&#xA;    sendDataToProcessing('B',PulseSensor::BPM);   // Send heart rate with a 'B' prefix&#xA;    sendDataToProcessing('Q',PulseSensor::IBI);   // Send time between beats with a 'Q' prefix&#xA;    PulseSensor::QS = false;                      // Reset the Quantified Self flag for next time&#xA;  }&#xA;&#xA;  ledFadeToBeat();&#xA;&#xA;  delay(5000);                             //  Take a break&#xA;}&#xA;&#xA;&#xA;void ledFadeToBeat(){&#xA;  fadeRate -= 15;                         //  Set LED fade value&#xA;  fadeRate = constrain(fadeRate,0,255);   //  Keep LED fade value from going into negative numbers!&#xA;  analogWrite(fadePin,fadeRate);          //  Fade LED&#xA;}&#xA;&#xA;&#xA;void sendDataToProcessing(char symbol, int data ){&#xA;    Serial.print(symbol);                // Symbol prefix tells Processing what type of data is coming&#xA;    Serial.println(data);                // The data to send culminating in a carriage return&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;pulse-sensor-arduino.h&quot;&#xA;&#xA;volatile int rate[10];                        // Array to hold last ten IBI values&#xA;volatile unsigned long sampleCounter = 0;     // Used to determine pulse timing&#xA;volatile unsigned long lastBeatTime = 0;      // Used to find IBI&#xA;volatile int P =512;                          // Used to find peak in pulse wave, seeded&#xA;volatile int T = 512;                         // Used to find trough in pulse wave, seeded&#xA;volatile int thresh = 512;                    // Used to find instant moment of heart beat, seeded&#xA;volatile int amp = 100;                       // Used to hold amplitude of pulse waveform, seeded&#xA;volatile boolean firstBeat = true;            // Used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean secondBeat = false;          // Used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean Pulse = false;               // True when pulse wave is high, false when it's low&#xA;volatile int pulsePin;&#xA;&#xA;volatile int PulseSensor::IBI = 600;          // Holds the time between beats, must be seeded!&#xA;volatile int PulseSensor::BPM;                // Used to hold the pulse rate&#xA;volatile int PulseSensor::Signal;             // Holds the incoming raw data&#xA;volatile boolean PulseSensor::QS = false;     // Becomes true when Arduino finds a beat&#xA;&#xA;void PulseSensor::begin(int pPin)&#xA;{&#xA;  pinMode(pulsePin, INPUT);&#xA;  pulsePin = pPin;&#xA;&#xA;  // Initializes Timer1 to throw an interrupt every 2 ms.&#xA;  TCCR1A = 0x00;&#xA;  TCCR1B = 0x0C;  // CTC (Compare match mode) and ClockIO/256&#xA;  OCR1A = 0x7C;   // 2 ms&#xA;  TIMSK1 = 0x02;&#xA;  sei();          // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED&#xA;}&#xA;&#xA;// THIS IS THE TIMER 1 INTERRUPT SERVICE ROUTINE.&#xA;// Timer 1 makes sure that we take a reading every 2 miliseconds&#xA;ISR(TIMER1_COMPA_vect)&#xA;{                         // Triggered when Timer1 counts to 124&#xA;  cli();                                      // Disable interrupts while we do this&#xA;  PulseSensor::Signal = analogRead(pulsePin);              // read the Pulse Sensor&#xA;  sampleCounter += 2;                         // Keep track of the time in ms with this variable&#xA;  int N = sampleCounter - lastBeatTime;       // Monitor the time since the last beat to avoid noise&#xA;&#xA;  //  Find the peak and trough of the pulse wave&#xA;  if(PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; N &amp;gt; (PulseSensor::IBI/5)*3){       // Avoid dichrotic noise by waiting 3/5 of last IBI&#xA;    if (PulseSensor::Signal &amp;lt; T){                        // T is the trough&#xA;      T = PulseSensor::Signal;                         // Keep track of lowest point in pulse wave&#xA;    }&#xA;  }&#xA;&#xA;  if(PulseSensor::Signal &amp;gt; thresh &amp;amp;&amp;amp; PulseSensor::Signal &amp;gt; P){          // Threshold condition helps avoid noise&#xA;    P = PulseSensor::Signal;                             // P is the peak&#xA;  }                                        // Keep track of highest point in pulse wave&#xA;&#xA;  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT&#xA;  // signal surges up in value every time there is a pulse&#xA;  if (N &amp;gt; 250){                                   // Avoid high frequency noise&#xA;    if ( (PulseSensor::Signal &amp;gt; thresh) &amp;amp;&amp;amp; (Pulse == false) &amp;amp;&amp;amp; (N &amp;gt; (PulseSensor::IBI/5)*3) )&#xA;    {&#xA;      Pulse = true;                               // Set the Pulse flag when we think there is a pulse&#xA;      PulseSensor::IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS&#xA;      lastBeatTime = sampleCounter;               // Keep track of time for next pulse&#xA;&#xA;      if(secondBeat){                        // If this is the second beat, if secondBeat == TRUE&#xA;        secondBeat = false;                  // Clear secondBeat flag&#xA;        for(int i=0; i&amp;lt;=9; i++){             // Seed the running total to get a realisitic BPM at startup&#xA;          rate[i] = PulseSensor::IBI;&#xA;        }&#xA;      }&#xA;&#xA;      if(firstBeat){                         // If it's the first time we found a beat, if firstBeat == TRUE&#xA;        firstBeat = false;                   // Clear firstBeat flag&#xA;        secondBeat = true;                   // Set the second beat flag&#xA;        sei();                               // Enable interrupts again&#xA;        return;                              // IBI value is unreliable so discard it&#xA;      }&#xA;&#xA;&#xA;      // Keep a running total of the last 10 IBI values&#xA;      word runningTotal = 0;                  // Clear the runningTotal variable&#xA;&#xA;      for(int i=0; i&amp;lt;=8; i++){                // Shift data in the rate array&#xA;        rate[i] = rate[i+1];                  // And drop the oldest IBI value&#xA;        runningTotal += rate[i];              // Add up the 9 oldest IBI values&#xA;      }&#xA;&#xA;      rate[9] = PulseSensor::IBI;                          // Add the latest IBI to the rate array&#xA;      runningTotal += rate[9];                // Add the latest IBI to runningTotal&#xA;      runningTotal /= 10;                     // Average the last 10 IBI values&#xA;      PulseSensor::BPM = 60000/runningTotal;               // How many beats can fit into a minute? that's BPM!&#xA;      PulseSensor::QS = true;                              // Set Quantified Self flag&#xA;      // QS FLAG IS NOT CLEARED INSIDE THIS ISR&#xA;    }&#xA;  }&#xA;&#xA;  if (PulseSensor::Signal &amp;lt; thresh &amp;amp;&amp;amp; Pulse == true){   // When the values are going down, the beat is over&#xA;    Pulse = false;                         // Reset the Pulse flag so we can do it again&#xA;    amp = P - T;                           // Get amplitude of the pulse wave&#xA;    thresh = amp/2 + T;                    // Set thresh at 50% of the amplitude&#xA;    P = thresh;                            // Reset these for next time&#xA;    T = thresh;&#xA;  }&#xA;&#xA;  if (N &amp;gt; 2500){                           // If 2.5 seconds go by without a beat&#xA;    thresh = 512;                          // Set thresh default&#xA;    P = 512;                               // Set P default&#xA;    T = 512;                               // Set T default&#xA;    lastBeatTime = sampleCounter;          // Bring the lastBeatTime up to date&#xA;    firstBeat = true;                      // Set these to avoid noise&#xA;    secondBeat = false;                    // When we get the heartbeat back&#xA;  }&#xA;&#xA;  sei();                                   // Enable interrupts when youre done!&#xA;} // end ISR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7156" LastEditorUserId="510" LastEditDate="2015-09-08T13:13:11.327" LastActivityDate="2015-09-08T13:13:11.327" Title="Pulse measurement" Tags="|programming|sensors|arduino-yun|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8586" PostTypeId="2" ParentId="8585" CreationDate="2015-02-11T14:49:34.867" Score="2" Body="&lt;p&gt;(1)The declaration&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; volatile boolean Pulse = false;     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;occurs in two locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that intended?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) Also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int PulseSensor::BPM;                // used to hold the pulse rate  &#xA;volatile int PulseSensor::IBI = 600;          // holds the time between beats, must be seeded!    &#xA;volatile int PulseSensor::Signal;             // holds the incoming raw data  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-11T23:17:01.527" LastActivityDate="2015-02-11T23:17:01.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8587" PostTypeId="1" AcceptedAnswerId="8592" CreationDate="2015-02-11T15:10:06.680" Score="2" ViewCount="2867" Body="&lt;p&gt;I have a arduino program that I wrote with my teammembers. We are working on a project and try to move a RC car. Here is our code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int forward =12 ; //assign to correlating pin attached to TP06&#xA;int backward = 11; //assign to correlating pin attached to TP07&#xA;int left = 10; //assign to correlating pin attached to (left steer)&#xA;int right = 9; //assign to correlating pin attached to (right steer)&#xA;&#xA;// TP09 &amp;amp; TP02 (don't remember which is left and right)&#xA;&#xA;void setup() {&#xA;pinMode(forward, OUTPUT);&#xA;pinMode(backward, OUTPUT); &#xA;pinMode(left, OUTPUT);&#xA;pinMode(right, OUTPUT);&#xA;}&#xA;&#xA;void move_Forward() {&#xA;digitalWrite(forward, HIGH);&#xA;digitalWrite(backward, LOW);&#xA;}&#xA;&#xA;void move_Backward() { &#xA;digitalWrite(backward, HIGH);&#xA;digitalWrite(forward, LOW);&#xA;}&#xA;&#xA;void turn_Left() {&#xA;digitalWrite(left, HIGH);&#xA;digitalWrite(right, LOW);&#xA;}&#xA;&#xA;void turn_Right() {&#xA;digitalWrite(right, HIGH);&#xA;digitalWrite(left, LOW);&#xA;}&#xA;&#xA;void stop_Completely() {&#xA;digitalWrite(forward, LOW);&#xA;digitalWrite(backward, LOW);&#xA;digitalWrite(right, LOW);&#xA;digitalWrite(left, LOW);&#xA;}&#xA;&#xA;// loop will keep going while arduino has power&#xA;void loop() {&#xA;move_Forward();&#xA;turn_Left(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When we run this code, for some reason forward pin and left pins are becoming deactivated, which are the pin numbers 12 and 10. Like it does not supply voltage anymore for some reason. However right pin and backward pins, which are pins 9 and 11, which was not included in loop, works! I can run the RC car with these pins. I dont understand why this is the case. Shouldn't the left and forward pins work? If they are not working, how come? Sorry I am new to arduino programming language and its been very challenging for me and my group. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="7272" LastActivityDate="2015-02-14T08:38:06.177" Title="Arduino program wont work properly for some reason" Tags="|arduino-nano|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8588" PostTypeId="1" AcceptedAnswerId="8589" CreationDate="2015-02-11T15:22:59.293" Score="4" ViewCount="298" Body="&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12,11,5,4,3,2);&#xA;int visitor=0;  //variable for counting visitor number&#xA;&#xA;unsigned long timer_1,timer_2;  //variables for recording time for ir_1 and ir_2&#xA;&#xA;void setup() {&#xA;   lcd.begin(20,4);&#xA;   pinMode(A0,INPUT);&#xA;   pinMode(A1,INPUT);&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA; lcd.setCursor(0,4);&#xA;   lcd.print(&quot;visitor=&quot;);&#xA;   lcd.setCursor(8, 4);&#xA;&#xA;   lcd.print(visitor);&#xA;&#xA;   if(digitalRead(A0)==1 &amp;amp;&amp;amp; digitalRead(A1)==0)&#xA;  {&#xA;    timer_1= millis();&#xA;  }&#xA;  if(digitalRead(A0)==0 &amp;amp;&amp;amp; digitalRead(A1)==1)&#xA;  {&#xA;    timer_2= millis();&#xA;  }&#xA;  if(timer_1&amp;gt;timer_2)&#xA;  {&#xA;   lcd.setCursor(8,4);&#xA;   visitor=visitor+1;&#xA;   lcd.print(visitor);&#xA;   delay(2000);&#xA;   timer_1=0;&#xA;   timer_2=0;&#xA;  } &#xA; else if(timer_1&amp;lt;timer_2)&#xA;  {&#xA;   lcd.setCursor(8,4);&#xA;   visitor=visitor-1;&#xA;    if (visitor&amp;lt;=0)&#xA;  { &#xA;    visitor=0;&#xA;  }&#xA;   lcd.print(visitor);&#xA;   delay(2000);&#xA;   timer_1=0;&#xA;   timer_2=0;&#xA;&#xA;  } &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Two IR sensors are placed in A0 and A1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the value of &lt;code&gt;visitor&lt;/code&gt; is decreasing from 10 to 9 the LCD is showing 90 because  the '0' of previous 10 is here. How can I remove it?&lt;/p&gt;&#xA;" OwnerUserId="7271" LastEditorUserId="42" LastEditDate="2015-04-15T15:49:55.643" LastActivityDate="2015-04-15T15:49:55.643" Title="Value of the counter collide on my lcd while decreasing. How can I remove it?" Tags="|lcd|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8589" PostTypeId="2" ParentId="8588" CreationDate="2015-02-11T16:15:43.687" Score="2" Body="&lt;p&gt;A simple option would be to call &lt;code&gt;lcd.clear()&lt;/code&gt; at the start of &lt;code&gt;loop()&lt;/code&gt;. That will clear the entire LCD display. Everything else should work fine because it looks like you're outputting the entire display contents every time round.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could remove the extra digit by printing a space over it, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (visitor &amp;lt; 10) print(&quot; &quot;);&#xA;lcd.print(visitor);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;visitor&lt;/code&gt; is a 1-digit number (i.e. less than 10), it will output a space at the start, getting rid of any underlying digits leftover from a previous iteration. If you want the number to be left-aligned then you could print the space after the number instead.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-11T16:15:43.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8591" PostTypeId="1" CreationDate="2015-02-11T19:18:04.613" Score="0" ViewCount="108" Body="&lt;p&gt;I need to create a interruption-proof power for a project of mine, very similar to the design &lt;a href=&quot;http://www.feirinhadigital.com.br/rbr/ham/projetos-usuarios/NO-BREAK/nobreak.htm&quot; rel=&quot;nofollow&quot;&gt;of this link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that I need to adjust the current delivered of the solar panel (21V, 1.2A) to 5V and simultaneously charge a battery 12V, 18Ah. If the solar panel does not supply power, the battery takes its place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know any circuit to do something? Or can someone give me a light as do something?&lt;/p&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-02-11T23:57:10.503" Title="create a interruption-proof power" Tags="|power|solar|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8592" PostTypeId="2" ParentId="8587" CreationDate="2015-02-11T19:31:30.470" Score="1" Body="&lt;p&gt;On many Arduinos, those pins (10-12) are shared with the ICSP header - are you programming/testing with it plugged in or unplugged? If plugged in, you might be affected by what you're plugged into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a useful pinout: &lt;a href=&quot;http://t.co/MKtmCILSdj&quot;&gt;http://t.co/MKtmCILSdj&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a Nano pinout: &lt;img src=&quot;https://i.stack.imgur.com/yykxv.png&quot; alt=&quot;Nano pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the ICSP is electrically connected to pins D11, D12 and D13 - so if you have something plugged into the ICSP header, you have something connected to those pins which might be causing your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're programming via serial port (TX/RX) and have nothing connected to ICSP, then this isn't your issue. If that's a case, it's possible to fry a few pins on a Nano and have it still appear to mostly work - trying another couple of pins might tell you more. (For instance, try D4 and D5 instead of D10 and D12.)&lt;/p&gt;&#xA;" OwnerUserId="7173" LastEditorUserId="7173" LastEditDate="2015-02-13T21:30:16.673" LastActivityDate="2015-02-13T21:30:16.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8593" PostTypeId="2" ParentId="6474" CreationDate="2015-02-11T20:49:52.100" Score="1" Body="&lt;p&gt;The problem is the Servo library. This library is claiming all the timers, so you can't use them yourself. What I do to fix this is edit the Servo.h (or ServoTimers.h) file. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;//#define _useTimer5&#xA;#define _useTimer1&#xA;#define _useTimer3&#xA;//#define _useTimer4&#xA;//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers }   timer16_Sequence_t;&#xA;typedef enum { _timer1, _timer3, _Nbr_16timers } timer16_Sequence_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will remove the 2 timers (4 and 5) for the Mega boards, but you can still attach 24 servo's. If you need more, you should edit this file again.&lt;/p&gt;&#xA;" OwnerUserId="7277" LastActivityDate="2015-02-11T20:49:52.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8594" PostTypeId="1" CreationDate="2015-02-11T20:57:12.533" Score="2" ViewCount="563" Body="&lt;p&gt;I am trying to measure a users 'hand steadiness' in order to control a video game character in UNITY3D. I am using a MinIMU-9 Gyro/Accelerometer/Compass linked with Arduino. I can measure pitch/roll etc in Arduino...and I have passed previous Arduino measurements into Unity via the serial command but I am l trying to do two things:&#xA;1. simplify &amp;amp; reduce noise in the data coming from the magnetometer reading before I pass it into Unity by taking an average of every 10 magnetometer readings.&#xA;2. Combining the three magnetometer values to get one overall variable or measurement that can be passed into unity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the demo Sketch I have but I'm not sure how to script the addition of the x,y,z magnetometer values:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LSM303.h&amp;gt;&#xA;LSM303 compass;&#xA;char report[80];&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  compass.init();&#xA;  compass.enableDefault();&#xA;}&#xA;void loop()&#xA;{&#xA;  compass.read();&#xA;  snprintf(report, sizeof(report), &quot;A: %6d %6d %6d    M: %6d %6d %6d&quot;,&#xA;    compass.a.x, compass.a.y, compass.a.z,&#xA;    compass.m.x, compass.m.y, compass.m.z);&#xA;  Serial.println(report);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the type of 'averaging script' I would like to add in somewhere but I'm not sure where exactly to place it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 10; i++){    //take ten readings in ~0.02 seconds&#xA;    reading[i] = compass.m.y;&#xA;    delay(2);&#xA;  }&#xA;  for(int i = 0; i &amp;lt; 10; i++){   //average the ten readings&#xA;    finalMagYreading += reading[i];&#xA;  }&#xA;   finalMagYreading&#xA; /= 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help with this would be great.&lt;/p&gt;&#xA;" OwnerUserId="7278" LastEditorUserId="42" LastEditDate="2015-04-15T15:51:36.303" LastActivityDate="2015-04-15T15:51:36.303" Title="Combining &amp; averaging magnetometer values" Tags="|arduino-uno|magnetometer|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8595" PostTypeId="2" ParentId="8591" CreationDate="2015-02-11T23:30:41.653" Score="1" Body="&lt;p&gt;Rough block diagrams below show two ways this can be achieved - &quot;Easiest&quot; costs least but is inefficient. &quot;Better&quot; uses PV panel output more efficiently. Details of either can be discussed if of interest. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;'Schottky diodes' should be used to minimise losses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) &quot;Easiest&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect PV panel to battery with diode.&lt;br&gt;&#xA;Panel is clamped to battery voltage (+ diode drop).&lt;br&gt;&#xA;This will not hurt the PV panel but wastes some of the available power.&lt;br&gt;&#xA;[What is the formal PV panel specification. Is it 21V O/C or loaded or .... Do you have a datasheet link for it?].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use 12V (nominal) to 5V converter to power load. &#xA;This could be &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A linear regulator - only about 40% efficient - very wasteful.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A buck converter (build or buy from eg ebay)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Vxlt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) &quot;Better&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a buck regulator to charge the battery - ideally an MPPT (maximum power point transfer) controller. Details can be discussed if you are interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a second buck regulator to power the load. This must be capable of (at least) 11V to 22V input. Power this from a Schottky diode from the PV panel AND a Schottky diode from the battery. When the panel voltage is &gt; battery voltage the panel will power the load. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T4GsC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-11T23:57:10.503" LastActivityDate="2015-02-11T23:57:10.503" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8596" PostTypeId="2" ParentId="8547" CreationDate="2015-02-12T00:18:59.810" Score="1" Body="&lt;p&gt;The USB serial connection is provided by the Arduino, not the shield, and the naming pattern for an Uno on OSX will not be tty.usbserial### but rather something else (tty.usbmodem### perhaps?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I recall correctly, an Uno does not require a driver on OSX though older/unofficial FTDI based boards (as well as unofficial boards based on yet other fixed function chips) do require drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(On Linux it is typically /dev/ttyUSB# for fixed function and /dev/ttyACM# for an Uno, both using kernel module drivers shipped with most distributions.  On Windows they are all COM# and drivers are typically required)&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-02-12T00:18:59.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8597" PostTypeId="2" ParentId="8549" CreationDate="2015-02-12T00:59:27.780" Score="0" Body="&lt;p&gt;The Analog In does exactly what it says - it only reads (samples) analog voltage levels. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using AnalogWrite(0,2) does not make pin A0 in Analog In to output the voltage of 2*AVCC/1024, but instead makes the pin D0 to do that instead. (Most D0 pins on Arduino boards do not have a PWM output associated with them, so the behaviour would be undefined.) In the mean time, your A0 is doing nothing. &#xA;(I suspect it's floating / not connected, hence the 3xx value. Could check the datasheet to be sure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what should we do instead? For a start, connect Arduino B's A0 to Arduino A's pwm pin. If you're using Uno, you can connect to any of the pins 11,10,9,6,5,3. Then you can use the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int PWMPin = 11;&#xA;int SignalLvl = 2;&#xA;analogWrite(PWMPin,SignalLvl);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give that a try. And you'll see that it works... sort of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then there's a problem. your readings will be close to what you want, but quite erratic. The reason is partly because analog signals are super unreliable and is filled with noise. But the main reason is really that Arduino's analogWrite is actually NOT designed as an analog signal output. It is a PWM, which outputs GND and AVcc levels at variable periods at a fast speed so that it approximates the voltage level you want when averaged. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to experiment with this, you can connect a resistor and capacitor to the output, creating  a low pass filter. (Here's more info: &lt;a href=&quot;http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/&quot; rel=&quot;nofollow&quot;&gt;http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said all that, I guess the question most of us would like to ask is: is there a reason why you want to send data via analog? Analog signals are prone to noise. If data fidelity is critical, your best best is to use serial communication as highlighted by most answers here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simplicity, I suggest I2c which uses only 2 wires to communicate. If speed is of essence (like, writing to 10,000 bytes of data every second) you could try SPI or even parallel communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps and good luck! &lt;/p&gt;&#xA;" OwnerUserId="7282" LastActivityDate="2015-02-12T00:59:27.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8599" PostTypeId="1" CreationDate="2015-02-12T01:58:21.100" Score="0" ViewCount="176" Body="&lt;p&gt;I want to make a universal remote.I have an ir receiver and transmiter. I.I can use it to control my tv and other equipment.I want to also control my dish network in the US. I checked and think that the dish uses 395mhz but i am not sure.&lt;strong&gt;How can i replicate a dish remote radio signal&lt;/strong&gt;.I know it is radio signal and not ir. &lt;strong&gt;What part do I need for the arduino?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="5119" LastActivityDate="2015-03-24T22:36:53.977" Title="I want to know how to record and play radio waves?" Tags="|remote-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8600" PostTypeId="2" ParentId="8405" CreationDate="2015-02-12T03:43:29.507" Score="1" Body="&lt;p&gt;Both NTP and milli() waste a lot of processing as it keeps the Arduino busy checking if the time is right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet is to use the Arduino timer. Set the timer to interrupt every 10 minutes. If you don't need to do anything aside from functions A and B, you can let your Arduino sleep and keep power draw to a minimum.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example code&#xA;void funcA(){&#xA;    // do stuff&#xA;}&#xA;void funcB(){&#xA;    // do stuff&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA;    // initialize Timer1&#xA;    cli();          // disable global interrupts&#xA;    TCCR1A = 0;     // clear TCCR1A&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;    // set compare match register to desired timer count:&#xA;    // 15624*1024/16000000 = 1sec at 16MHz&#xA;    OCR1A = 15624;   &#xA;    // turn on CTC mode:&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;    // use 1/1024 the speed of the clock:&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;    // enable timer compare interrupt:&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;    // enable global interrupts:&#xA;    sei();&#xA;}&#xA;&#xA;ISR(TIM1_COMPA_vect) &#xA;// Your task manager here&#xA;// This function decides when to execute the functions A and B&#xA;{&#xA;    static t1= 0;&#xA;    static t2= 0;&#xA;&#xA;    // increment your counter flags&#xA;    t1++;&#xA;    t2++;&#xA;&#xA;    if (t1==10) {//runs function every 10 sec&#xA;        funcA();&#xA;        t1=0;&#xA;    }&#xA;    if (t2==30) {//runs function every 30 sec&#xA;        funcB();&#xA;        t2=0;&#xA;    }&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;    // do stuff or sleep for even more power saving&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="7282" LastActivityDate="2015-02-12T03:43:29.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8601" PostTypeId="2" ParentId="1440" CreationDate="2015-02-12T03:50:54.313" Score="3" Body="&lt;p&gt;Looking at the &lt;a href=&quot;http://learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps-logger-shield.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;PDF for the Adafruit GPS shield&lt;/a&gt;, pin 7 is indeed hard wired to &lt;code&gt;Rx&lt;/code&gt; and pin 8 is hard wired to &lt;code&gt;Tx&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hSuip.png&quot; alt=&quot;Adafruit GPS shield PCB&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These can not be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;guide for the Arduino GSM shield&lt;/a&gt; pin 7 is indeed reserved for modem reset:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Digital pins 2, 3 and 7 are reserved for communication between the&#xA;  Arduino and modem and cannot be used by your sketches. Communication&#xA;  between the moden and Arduino is handled by the Software Serial&#xA;  library on pins 2 and 3. Pin 7 is used for the modem reset.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As this is the case, should you stack the two shields together, without modification, then the &lt;em&gt;overlap of the &lt;code&gt;Rx&lt;/code&gt; pin on the GPS shield will cause resets to the modem on the GSM shield&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it seems that your best option is to use the solution provided by RedGrittyBrick, to your previous question &lt;a href=&quot;http://Arduino%20shield%20stacking&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino shield stacking&lt;/a&gt;, the Go-Between Shield&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You hear it all the time in the Arduino community, “will this shield&#xA;  work with my other shield?.” I think we’ve all been disappointed to&#xA;  find that two of our favorite shields compete for control of a digital&#xA;  pin here or a serial pin there. While there are sometimes some clever&#xA;  workarounds from elegant code modifications to aggressive&#xA;  ‘greenwiring,’ Mayhew Labs may have come up with the simplest solution&#xA;  thus far: The Go-Between Shield.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Once you have used the Go-Between shield to reassign the &lt;code&gt;Rx&lt;/code&gt; pin to something that the GSM shield does not use, (as 2, 3 and 7 are already used, let's say you use pin 6), then in the &lt;strong&gt;File -&gt; Examples -&gt; Adafruit_GPS -&gt; Parsing&lt;/strong&gt; sketch, you will need to change the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(3,2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(8,6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(8,7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is recommended in the PDF. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that this answers your question(s). Let us know how you get on.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Addenum&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-gsm-shield-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic of the Arduino GSM shield&lt;/a&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7ttFF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps-logger-shield.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic of the Adafruit GPS shield&lt;/a&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/AyYlo.png&quot; alt=&quot;schematic of the Adafruit GPS shield&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-02-12T04:03:59.463" LastActivityDate="2015-02-12T04:03:59.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8604" PostTypeId="1" CreationDate="2015-02-12T10:07:45.800" Score="0" ViewCount="1735" Body="&lt;pre&gt;&lt;code&gt;// Tells the Arduino to read A2 and stores the value in “Vin”    &#xA;Vin = analogRead (tempSensor); &#xA;&#xA;// Converts the voltage value to temperature and stores it into the “TC” variable (in °C)&#xA;TC = 500.0 * (Vin / 1024.0); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The temperature shown is about 50.25°C, sometimes it is showing 36-38°C   degrees, but the actual temperature is about 25-26°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this is happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vin = analogRead (tempSensor);&#xA;TC=(500.0*Vin)/1023.0;&#xA;TF = ((9.0*TC)/5.0)+32.0;&#xA;lcd.setCursor(0, 1);&#xA;lcd.print(TF);&#xA;lcd.print((char)223);&#xA;lcd.print(&quot;F &quot;);&#xA;lcd.print (TC);&#xA;lcd.print((char)223);&#xA;lcd.print(&quot;C&quot;);&#xA;delay(1000); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7271" LastEditorUserId="220" LastEditDate="2015-02-19T22:52:36.957" LastActivityDate="2016-02-03T23:36:32.777" Title="Temperature sensor reading is higher than the actual temperature" Tags="|temperature-sensor|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8605" PostTypeId="2" ParentId="3308" CreationDate="2015-02-12T10:12:04.823" Score="0" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bring up a very simple sketch like blink or bare-minimum.&lt;/li&gt;&#xA;&lt;li&gt;Select the right board and serial port from the tools menu.&lt;/li&gt;&#xA;&lt;li&gt;Then click upload&lt;/li&gt;&#xA;&lt;li&gt;As soon as the IDE says 'Uploading' double tap the reset button on the board that you are&#xA;programming.&lt;/li&gt;&#xA;&lt;li&gt;Hopefully the sketch should upload.&lt;/li&gt;&#xA;&lt;li&gt;You should then be able to upload any other sketch to the Robot like wheel calibration or&#xA;line follow.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It works for me (since I had the same problem) for a few days until it stops working again. It's Just a design flaw with the ATMega32u4.&lt;/p&gt;&#xA;" OwnerUserId="7288" LastActivityDate="2015-02-12T10:12:04.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8606" PostTypeId="2" ParentId="8568" CreationDate="2015-02-12T12:46:43.617" Score="0" Body="&lt;p&gt;You can program an AVR microcontroller easily with an existing Arduino as the programmer. AFAIK there's no easy way around SMD packages. The last time I've gotten them, I have to solder programming wires on them before placing it on the board. If you have space, you can also wire the ISP pins to a connector on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, here are the steps to program your chip, whether DIP or SMD.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Upload the Arduino ISP Sketch to your Arduino board's MCU.&lt;/li&gt;&#xA;&lt;li&gt;Wire up the Vcc and GND, and the SPI pins (MOSI,MISO,SCL). (The wiring is actually described in the comment section of the sketch. As for the pin out on the ATmega328, go to &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;page 3&lt;/a&gt;. You can find similar datasheets if you're using other MCUs.)&lt;/li&gt;&#xA;&lt;li&gt;Write your code&lt;/li&gt;&#xA;&lt;li&gt;Click &quot;File&gt;Upload using programmer&quot; or just press Ctrl + Shift + U.&lt;/li&gt;&#xA;&lt;li&gt;Done!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think most AVR MCUs come with an internal calibrated resonator, but if you want to drive it at a higher speed (16MHz/20MHz...) you will need to connect the MCU to a crystal oscillator. As always, refer to the datasheet. ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another link you can refer to: &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="7282" LastEditDate="2015-02-12T12:57:08.550" LastActivityDate="2015-02-12T12:57:08.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8608" PostTypeId="2" ParentId="8604" CreationDate="2015-02-12T14:19:20.890" Score="0" Body="&lt;p&gt;It sounds like your voltage to temperature calculation is wrong. Assuming the temperature voltage relationship is linear you can work out the formula. Take two measurements at two known temperatures (quite far apart, perhaps outdoors and in) and note down the value Arduino measures for Vin. Lets call these VinA &amp;amp; VinB for TempA and TempB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can calculate measures per degree with... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MeasuresPerDeg = (TempB - TempA) /(VinB - VinA)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the a constant as...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constant = TempA - VinA*MeasuresPerDeg&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your equation to calculate temperature should now be&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TC=MeasuresPerDeg*(Vin/1024.0) + Constant;&lt;/p&gt;&#xA;" OwnerUserId="7182" LastActivityDate="2015-02-12T14:19:20.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8609" PostTypeId="1" CreationDate="2015-02-12T14:58:46.807" Score="1" ViewCount="4081" Body="&lt;p&gt;I came across a dev board around the Atmel Xmega controller. This an AVR like used on Arduino, but with a lot of extras. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UCSG3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was surprised to see that the board is hardly more expensive than an Arduino, despite:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;384kB of Flash (versus 32kB for Arduino)  &lt;/li&gt;&#xA;  &lt;li&gt;DMA  &lt;/li&gt;&#xA;  &lt;li&gt;Xmega can run at 32 MHz (16 MHz for Arduino)&lt;/li&gt;&#xA;  &lt;li&gt;on-board OLED display  &lt;/li&gt;&#xA;  &lt;li&gt;on-board light and temperature sensors  &lt;/li&gt;&#xA;  &lt;li&gt;on-board microSD socket&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For all these on-board features you'd need a shield or breakout board for Arduino. I seems to me that for a lower price than Arduino you could build a much more powerful system, which is Arduino-compatible.&lt;br&gt;&#xA;How hard would it be to port Arduino to the Xmega?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see also &lt;a href=&quot;http://www.element14.com/community/docs/DOC-71436&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.element14.com/community/docs/DOC-71436&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-13T16:25:34.423" Title="Arduino around the Xmega?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8610" PostTypeId="2" ParentId="8604" CreationDate="2015-02-12T15:21:06.060" Score="2" Body="&lt;p&gt;Any chance you're printing Vin, and not TC? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;500*(50.25/1024) = ~24.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, please post as much of your program as possible&lt;/p&gt;&#xA;" OwnerUserId="7292" LastActivityDate="2015-02-12T15:21:06.060" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8611" PostTypeId="2" ParentId="8609" CreationDate="2015-02-12T17:35:59.900" Score="1" Body="&lt;p&gt;There's an attempt to get the Atmel XMEGA boards working in Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/akafugu/Xmegaduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/akafugu/Xmegaduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not fully featured yet but appears to have to features to allow you to start hacking with this board.&lt;/p&gt;&#xA;" OwnerUserId="7182" LastEditorUserId="7182" LastEditDate="2015-02-13T16:25:34.423" LastActivityDate="2015-02-13T16:25:34.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8612" PostTypeId="2" ParentId="6875" CreationDate="2015-02-12T19:41:46.170" Score="0" Body="&lt;p&gt;I found some code for a 10k thermistor and modified it for a 50k and cut out the code to display Celcius.  I found this on the Arduino playground posted by: Milan Malesevic and Zoran Stupic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Origional code is found here: &lt;a href=&quot;http://playground.arduino.cc/ComponentLib/Thermistor2&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/ComponentLib/Thermistor2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I came up with and it returned the proper temp in F for a 503 Thermistor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;// enumerating 3 major temperature scales&#xA;enum {&#xA;  T_KELVIN=0,&#xA;  T_CELSIUS,&#xA;  T_FAHRENHEIT&#xA;};&#xA;&#xA;#define EPISCO_K164_10k 4300.0f,298.15f,50000.0f  // B,T0,R0  &#xA;&#xA;float Temperature(int AnalogInputNumber,int OutputUnit,float B,float T0,float R0,float R_Balance)&#xA;{&#xA;  float R,T;&#xA;&#xA;//  R=1024.0f*R_Balance/float(analogRead(AnalogInputNumber)))-R_Balance;&#xA;  R=R_Balance*(1024.0f/float(analogRead(AnalogInputNumber))-1);&#xA;&#xA;  T=1.0f/(1.0f/T0+(1.0f/B)*log(R/R0));&#xA;&#xA;  switch(OutputUnit) {&#xA;    case T_CELSIUS :&#xA;      T-=273.15f;&#xA;    break;&#xA;    case T_FAHRENHEIT :&#xA;      T=9.0f*(T-273.15f)/5.0f+32.0f;&#xA;    break;&#xA;    default:&#xA;    break;&#xA;  };&#xA;&#xA;  return T;&#xA;}&#xA;&#xA;//example of use #2&#xA;// using numbers instead of episco k164 definition&#xA;// this time reading from analog input 2&#xA;// getting result in fahrenheit&#xA;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA; Serial.println(&quot;********&quot;);&#xA; Serial.println(&quot;Temp&quot;);&#xA; Serial.println(Temperature(2,T_FAHRENHEIT,4300.0f,298.15f,50000.0f,10000.0f));&#xA; Serial.println(&quot;********&quot;);&#xA; Serial.println(&quot; &quot;);&#xA;&#xA; delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good luck!!!!&lt;/p&gt;&#xA;" OwnerUserId="7296" LastActivityDate="2015-02-12T19:41:46.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8613" PostTypeId="2" ParentId="8587" CreationDate="2015-02-12T20:08:50.080" Score="0" Body="&lt;p&gt;Have you tested this on more than one Arduino? My first Arduino board had a dead UART. Took me weeks and purchasing a second Arduino to figure it out. It worked well enough to not initially suspect the UART (I'm not a complete idiot). ;)&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-02-12T20:08:50.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8614" PostTypeId="1" AcceptedAnswerId="8629" CreationDate="2015-02-13T00:37:52.733" Score="0" ViewCount="92" Body="&lt;p&gt;I am looking to buy a range finder module for an obstacle avoidance robot. &#xA;Currently, two good options based on available libraries and compatibility with Arduino and rPI are HC-SR04 and parallax ping. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of form factor these seem the same. The only difference I can tell is 4 pins vs 3 pins. Also the price, with parallax being more than x4 the price. As I would rather not buy something cheaper which will need replacing, is anyone aware of further differences, that will make the parallax a better option? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;both need 5V&#xA;both have max range of 3-4m&#xA;Sensor angle HC- 15 degrees, parallax cant find..&lt;/p&gt;&#xA;" OwnerUserId="7301" LastActivityDate="2015-02-13T22:19:13.377" Title="Choosing rangefinder for obstacle-avoiding" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8615" PostTypeId="1" CreationDate="2015-02-13T00:47:47.177" Score="0" ViewCount="2330" Body="&lt;p&gt;I am doing some computations on Matlab and I need to send those values to an Arduino Leonardo through USB serial connection. I need to send 2 variables which can vary from -400 to +400. I'm saying their values because I was able to do this with small positive values (unsigned byte), but not larger and negative numbers. Please help! Thank you&lt;/p&gt;&#xA;" OwnerUserId="7303" LastActivityDate="2015-11-20T01:23:50.207" Title="Matlab to Arduino communication" Tags="|serial|arduino-leonardo|variables|matlab|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8616" PostTypeId="1" AcceptedAnswerId="8617" CreationDate="2015-02-13T10:16:23.407" Score="1" ViewCount="1635" Body="&lt;p&gt;I'm having a bit of a problem when sending IR Codes stored in variables. I swear I had this convered up already. I don't actually know the reason why I can't use variables in the first place. I receive data over Bluetooth Serial Com and I'm using an Arduino ProMicro as ISP for the Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to send data over Serial comm and then send an IR code to the end receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some of the code():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt; // IR Library - Encode/Decode&#xA;&#xA;void irSerial( char SerChar[] ) // Receive array of characters&#xA;&#xA;char IDChar[]={'s', 'i', 'u'}; // List of Serial Char to identify position&#xA;String HRD[]={&quot;Power&quot;, &quot;Input&quot;, &quot;ChaUp&quot;}; // Action referece &#xA;byte CodesIR[]={0x61A0F00F, 0x61A048B7, 0x61A050AF}; // IR Codes&#xA;int IRArray = 2; // Size Of The array&#xA;&#xA;if ( SerChar[0] == 's' ) { // Compare Array&#xA;  for (int CountIR = 0; CountIR &amp;lt;= IRArray; CountIR++){ // Loop through array&#xA;    if ( SerChar[0] == IDChar[CountIR]) {&#xA;       bluetooth.println(HRD[CountIR]); // Send String in array - Works&#xA;       SendIR.sendNEC(CodesIR[CountIR],32); // Send IR in array position&#xA;    }&#xA;  }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's not a problem with the current expression as it compiles normally and I can send serial data normally finishing the function. If I replace the array &lt;strong&gt;CodesIR[CountIR]&lt;/strong&gt; for example with &lt;strong&gt;0x61A0F00F&lt;/strong&gt; then it works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use a variable instead? Can anyone help? It is the &lt;strong&gt;byte CodesIR[]&lt;/strong&gt; ??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a &lt;strong&gt;Switch/Case&lt;/strong&gt; and it works but I prefer a variable/array and less useless coding. Thanks for understanding!&lt;/p&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2015-02-13T10:41:46.947" LastActivityDate="2015-02-16T07:51:54.380" Title="Send array of Infrared codes" Tags="|serial|bluetooth|arduino-nano|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8617" PostTypeId="2" ParentId="8616" CreationDate="2015-02-13T11:41:50.417" Score="4" Body="&lt;p&gt;Well as usual it was something stupid (-__-) I changed the &lt;strong&gt;byte&lt;/strong&gt; array for &lt;strong&gt;long&lt;/strong&gt; and it worked perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the complete code working(): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt; // IR Library - Encode/Decode&#xA;&#xA;void irSerial( char SerChar[] ) { // Receive array of characters&#xA;&#xA;    char IDChar[]={'s', 'i', 'u'}; // List of Serial Char to identify position&#xA;    String HRD[]={&quot;Power&quot;, &quot;Input&quot;, &quot;ChaUp&quot;}; // Action reference &#xA;    long CodesIR[]={0x61A0F00F, 0x61A048B7, 0x61A050AF}; // IR Codes&#xA;    int IRArray = 3; // Size Of The array # Edit&#xA;&#xA;    if ( SerChar[0] == 's' ) { // Compare Array&#xA;      for (int CountIR = 0; CountIR &amp;lt; IRArray; CountIR++){ // Loop through array # Edit&#xA;        if ( SerChar[0] == IDChar[CountIR]) {&#xA;           Serial.println(HRD[CountIR]); // Send String in array - Works&#xA;           SendIR.sendNEC(CodesIR[CountIR],32); // Send IR in array position&#xA;        }&#xA;      }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2015-02-16T07:51:54.380" LastActivityDate="2015-02-16T07:51:54.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8618" PostTypeId="1" CreationDate="2015-02-13T12:32:20.977" Score="1" ViewCount="112" Body="&lt;p&gt;I am interfacing a GSM modem via Arduino at Serial port 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen that responses fron GSM modem are subject to time. Sometime its response are fast and sometime it are slow. I  have a code like below which checks for response from GSM modem based upon a user configurable timeout value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sendATcommand(str_at_cmd, str_ok, 500);&#xA;&#xA;&#xA;int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout)&#xA;{&#xA;    uint8_t x=0;&#xA;    char response[100];&#xA;    unsigned long previous;&#xA;    int answer = 0;&#xA;    memset(response, '\0', 100);&#xA;    answer = 0;;&#xA;    delay(100);&#xA;    ClearSerialData(); // read and flush all data&#xA;    debug_println(ATcommand);&#xA;    Serial2.println(ATcommand);&#xA;    delay(200);&#xA;    x = 0;&#xA;    previous = millis();&#xA;    do {&#xA;       if(Serial2.available() &amp;gt; 0){    &#xA;       response[x] = Serial2.read();&#xA;       delay(100);&#xA;       debug_print(response[x]);&#xA;       response[++x] = '\0';&#xA;       if (strstr(response, expected_answer) != NULL)    &#xA;       {&#xA;           debug_print(&quot;\nAnswer Mathced&quot;);&#xA;           answer = 1;&#xA;       }&#xA;       }&#xA;    }while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));   &#xA;    debug_println(&quot;\nReturning from AT Command&quot;);&#xA;    return answer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was never able to set the correct timeout value - as at random test it failed once or twice and not received 100% success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question if I change the code like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial2.available() &amp;gt; 0){    &#xA;   response[x] = Serial2.read();&#xA;   delay(100);&#xA;   debug_print(response[x]);&#xA;   response[++x] = '\0';&#xA;   if (strstr(response, expected_answer) != NULL)    &#xA;   {&#xA;       debug_print(&quot;\nAnswer Mathced&quot;);&#xA;       answer = 1;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when does Serial2.available() method returns &amp;lt;= 0 value. Is my above code correct - this way I overcome the timeout issue and all my GSM responses are being read - are there scenarios that I will end up in infinite loop? &lt;/p&gt;&#xA;" OwnerUserId="4655" LastActivityDate="2015-08-25T05:42:48.560" Title="Data at Serial Port Avaliable" Tags="|serial|arduino-mega|gsm|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8620" PostTypeId="1" AcceptedAnswerId="8660" CreationDate="2015-02-13T12:53:23.170" Score="3" ViewCount="212" Body="&lt;p&gt;I'm trying to interface my Leonardo with a &quot;Mindsensors Magic Wand&quot; - 8 LEDs connected to a PCA8574AN chip.&#xA;On the manufacturer's page, they say it's compatible with Arduino, however no instructions or code are given.&#xA;&lt;a href=&quot;http://www.mindsensors.com/index.php?module=pagemaster&amp;amp;PAGE_user_op=view_page&amp;amp;PAGE_id=120&quot; rel=&quot;nofollow&quot;&gt;http://www.mindsensors.com/index.php?module=pagemaster&amp;amp;PAGE_user_op=view_page&amp;amp;PAGE_id=120&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected the SDA, SCL, 5v, and GND connectors on the arduino to the device, but have had no luck in communicating with it. None of the LEDs light up regardless of input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can verify that power is being supplied.&#xA;The i2c address of the device is 0x70.&#xA;Code is below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define TWBR=400000L&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA; Wire.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  delay(2000);&#xA;  Wire.beginTransmission(0x70);&#xA;  Wire.write(32);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7227" LastEditorUserId="42" LastEditDate="2015-02-13T13:05:19.067" LastActivityDate="2015-02-15T16:00:48.557" Title="Interfacing Arduino Leonardo with PCA8574AN" Tags="|i2c|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8621" PostTypeId="1" CreationDate="2015-02-13T15:46:17.147" Score="2" ViewCount="212" Body="&lt;p&gt;I am using SPI to communicate with a IMU device which is working perfectly, except the SPISpeed which is not being altered as it should:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int m_SPISpeed = 400000;&#xA;SPI.begin();&#xA;pinMode(m_SPISelect, OUTPUT);&#xA;m_SPISettings = SPISettings(m_SPISpeed, MSBFIRST, SPI_MODE0);&#xA;...&#xA;SPI.beginTransaction(m_SPISettings);&#xA;digitalWrite(m_SPISelect, LOW);&#xA;SPI.transfer(regAddr | 0x80);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;m_SPISpeed&lt;/code&gt; is 400000. No matter what i set this value to it is always operating at &lt;code&gt;125000Hz&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7257" LastEditorUserId="7257" LastEditDate="2015-02-13T20:11:31.110" LastActivityDate="2015-12-24T11:11:31.473" Title="Unable to alter SPI speed on Arduino Micro" Tags="|arduino-ide|spi|arduino-micro|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8623" PostTypeId="1" CreationDate="2015-02-13T16:24:50.373" Score="2" ViewCount="4581" Body="&lt;p&gt;What is maximum voltage PWM pins can give?&#xA;can i give a vcc to 14v?&lt;/p&gt;&#xA;" OwnerUserId="7313" LastEditorUserId="-1" LastEditDate="2017-11-16T10:15:56.507" LastActivityDate="2019-11-06T22:53:42.143" Title="can i give a vcc to 14v?" Tags="|pwm|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8624" PostTypeId="2" ParentId="8623" CreationDate="2015-02-13T16:26:42.060" Score="4" Body="&lt;p&gt;Since PWM pins are digital outputs, the maximum output voltage is V&lt;sub&gt;CC&lt;/sub&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-13T16:26:42.060" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8625" PostTypeId="2" ParentId="8623" CreationDate="2015-02-13T16:37:35.873" Score="2" Body="&lt;p&gt;On a typical Arduino board, PWM pins will theoretically only ever operate at ground (+0v) or &lt;code&gt;Vcc&lt;/code&gt; (typically +5v). PWM is a square wave, which means it alternates rapidly between those two values, aka &lt;code&gt;LOW&lt;/code&gt; and &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, if you run it with a 50% duty cycle, then the &lt;strong&gt;average&lt;/strong&gt; voltage over several cycles will work out as 50% of &lt;code&gt;Vcc&lt;/code&gt; (i.e. typically 2.5v). The same applies to other percentages. It's important to note that it's not equivalent to a 'true' analog signal though, and shouldn't be used as such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, there are some modified Arduino clones which have a voltage selection switch. These typically let the pins operate at either 3.3v or 5v, and should affect PWM (as far as I know).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-13T16:37:35.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8626" PostTypeId="1" CreationDate="2015-02-13T17:28:33.737" Score="2" ViewCount="285" Body="&lt;p&gt;I am building an electronic gadget eventually to sell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the Atmega IC is used in the arduino and could this be programmed as easily as the arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if I can use the chip and buy just what I need for my circuit, which would be cheaper as there would be no licensing obligations to the Arduino company&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers &#xA;Eamonn&lt;/p&gt;&#xA;" OwnerUserId="7423" OwnerDisplayName="Eamonn" LastEditorUserId="84" LastEditDate="2015-02-17T17:34:59.103" LastActivityDate="2015-02-20T09:36:10.973" Title="Should I use an Arduino or not?" Tags="|atmega328|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8628" PostTypeId="2" ParentId="8626" CreationDate="2015-02-13T19:13:36.133" Score="6" Body="&lt;p&gt;Short answer: Yes. After all, Arduinos are made by starting with an ATMega (or other AVR) IC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer answer: People - including myself - routinely build with a bare ATMega328p (or other MCU), programming them off-board on another system, or providing connections to allow programming them in place. Beyond that you only need the soldering skills for the chip you choose (if you're building the boards yourself). I use DIP ICs and off the shelf through-hole PCBs and hand-build one or a couple at a time. Quad Flat-Package or Surface-Mount chips are another step up in complexity for the hand-builder.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-02-14T16:42:26.563" LastActivityDate="2015-02-14T16:42:26.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8629" PostTypeId="2" ParentId="8614" CreationDate="2015-02-13T22:19:13.377" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Odds are pretty good they are real close. I've only used the sr04 with&#xA;  4 pins (too lazy to mod) and it was ok. cant say if the parallax is&#xA;  better or not. For 4 times the price you'd expect it to be, but so far&#xA;  in robotics, price seldom reflect performance in my experience. – &#xA;  Spiked3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've also used the SR (with 4 pins) and it worked great. &amp;lt;2$ on eBay&lt;/p&gt;&#xA;" OwnerUserId="6980" LastActivityDate="2015-02-13T22:19:13.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8630" PostTypeId="1" AcceptedAnswerId="8689" CreationDate="2015-02-14T02:01:24.867" Score="-2" ViewCount="6848" Body="&lt;p&gt;I am trying to connect an Arduino and Raspberry Pi over USB.  I would like to send serial commands, just like the serial monitor in the Arduino IDE.  I know how to do this on the Arduino end but I'm not sure how to send/receive serial communication on the Pi end.  Ideally the solution would utilize Python.&lt;/p&gt;&#xA;" OwnerUserId="7318" LastActivityDate="2015-02-17T03:55:20.670" Title="Arduino Raspberry Pi USB Communication" Tags="|arduino-uno|serial|usb|python|" AnswerCount="3" CommentCount="1" ClosedDate="2015-02-19T22:45:50.150" ContentLicense="CC BY-SA 3.0" />
  <row Id="8631" PostTypeId="2" ParentId="8630" CreationDate="2015-02-14T03:21:44.420" Score="1" Body="&lt;p&gt;You would be better to ask this on &lt;a href=&quot;http://raspberrypi.stackexchange.com&quot;&gt;http://raspberrypi.stackexchange.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use program &lt;code&gt;minicom&lt;/code&gt; on the Pi; this is a terminal program like the serial monitor in the Arduino IDE, and of course you can use Arduino IDE on the Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the Pi site you will see lots of Python serial communication programs.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-14T03:21:44.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8633" PostTypeId="1" CreationDate="2015-02-14T07:37:13.440" Score="0" ViewCount="1568" Body="&lt;pre&gt;&lt;code&gt;#include &quot;sha256.h&quot;&#xA;&#xA;uint8_t hmacKey1[]={&#xA;0x65,0x63,0x73,0x74,0x61,0x63,0x79&#xA;};&#xA;&#xA;&#xA;void printHash(uint8_t* hash) {&#xA;int i;&#xA; for (i=0; i&amp;lt;32; i++) {&#xA;   Serial.print(&quot;0123456789abcdef&quot;[hash[i]&amp;gt;&amp;gt;4]);&#xA;   Serial.print(&quot;0123456789abcdef&quot;[hash[i]&amp;amp;0xf]);&#xA;  }&#xA; Serial.println();&#xA;}&#xA;&#xA;void setup() {&#xA;   uint8_t* hash;&#xA;   uint32_t a;&#xA;&#xA; Serial.begin(9600);&#xA;&#xA; // HMAC tests&#xA;  Serial.println(&quot;Test: RFC4231 4.2&quot;);&#xA;&#xA;Serial.print(&quot;Result:&quot;);&#xA;Sha256.initHmac(hmacKey1,20);&#xA;Sha256.print(&quot;Hi There&quot;);&#xA; //My TRIAL ATTEMPT&#xA; int i;&#xA; for (i=0; i&amp;lt;32; i++) {&#xA; hash[i] =Sha256.resultHmac();&#xA; Serial.println(hash[i]);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I save the hashed result into a variable? I disregarded the Printhash function above and tried it with my own code but it displays &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; sketch_feb14a:32: error: invalid conversion from 'uint8_t*' to 'unsigned char'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't understand the printhash function above and found little to no documentation on the web. I'm thinking of using AES library but I guess it's more complicated over here. The above code is based on Spaniako's CryptoSuite &lt;a href=&quot;https://github.com/spaniakos/Cryptosuite&quot; rel=&quot;nofollow&quot; title=&quot;here&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Heading&lt;/h1&gt;&#xA;" OwnerUserId="4609" LastActivityDate="2015-02-22T21:45:52.147" Title="How to save the SHA256 with HMAC into a variable instead of serial print?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8636" PostTypeId="2" ParentId="8587" CreationDate="2015-02-14T08:38:06.177" Score="0" Body="&lt;p&gt;First: turn off the old direction before turning on the new one. Now you're doing it the other way around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, in your main loop you're repeating forward and left over and over. I guess you want to move forward for some time, then turn left, then move forward again, etc.&lt;br&gt;&#xA;But moving forward does deactivate the reverse, but doesn't change left or right. So you're always repeating commands which haven't been changed in the first place: forward will always be active, and so will left be. You'll go in a circle, I don't know if that is the idea.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go straight, you'll probably want to turn off both left and right? Then add a delay before turning; right now your commands occur within microseconds of each other.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-02-14T08:38:06.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8637" PostTypeId="1" CreationDate="2015-02-14T10:03:24.173" Score="1" ViewCount="21574" Body="&lt;p&gt;From what i've researched here is my thoughts on both&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;C++&#xA;I heard that you can create libraries using C++ in arduino. And you can use the Arduino IDE to do that stuff.  Here is the proof&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that it uses the C++ syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also see arduino projects on github written on C++&#xA;&lt;a href=&quot;https://github.com/search?l=C%2B%2B&amp;amp;q=Arduino&amp;amp;type=Repositories&amp;amp;utf8=%E2%9C%93&quot; rel=&quot;nofollow&quot;&gt;https://github.com/search?l=C%2B%2B&amp;amp;q=Arduino&amp;amp;type=Repositories&amp;amp;utf8=%E2%9C%93&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;C&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I heard that you can use AVR GCC and code it without the arduino ide. And I heard it's much faster than the arduino language because it's more closer to the metal. But I think it's harder to set up because you need a programmer into the Atmel chip, which is much more costlier compared to directly plugging in the arduino using the USB to printer cable. And you also need to download a bunch of stuff to get coding in pure avr gcc (win-Avr GCC, atmel studio etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which one should i learn C or C++? I prefer the easy to debug route. Or is it beneficial if i learn both?&lt;/p&gt;&#xA;" OwnerUserId="7320" LastEditorUserId="42" LastEditDate="2015-02-14T11:00:20.987" LastActivityDate="2015-02-18T04:04:29.850" Title="New to Arduino: Should I learn C, C++ or both (C &amp; C++)?" Tags="|arduino-uno|programming|c++|c|avr|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8638" PostTypeId="2" ParentId="8637" CreationDate="2015-02-14T10:22:09.120" Score="2" Body="&lt;p&gt;Arduino supports c++, but does not support many of the standard libraries.&#xA;The vast bulk of the functions in the Arduino IDE are c functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do almost everything in c, except for a few advanced items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the limited c++ libraries it will be difficult to learn c++ on Arduino; indeed it is not the ideal platform to learn c, as most of the tutorials will not work (because there is no I/O on Arduino).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-14T10:22:09.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8639" PostTypeId="2" ParentId="8637" CreationDate="2015-02-14T11:00:07.927" Score="5" Body="&lt;p&gt;The basic syntax of C and C++ is very similar, to the point that C code can typically be compiled directly as C++. You'll also find C standard functions (such as &lt;code&gt;printf&lt;/code&gt; and &lt;code&gt;malloc&lt;/code&gt;) can be used from C++ programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The major difference in the core language is that C++ has a lot of extra stuff such as classes and templates. Conventionally, C++ also has a huge standard library which doesn't work on C. However, that's not usually available (nor really appropriate) for Arduino programming, so you don't need to worry too much about it unless you migrate to e.g. desktop programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, it's probably sensible to learn C first, because the same knowledge works in C++. You can then move on to the C++-specific stuff, such as classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the Gnu Compiler Collection (GCC) actually covers both C and C++. It's what the Arduino IDE at Atmel Studio use under-the-hood for all their compilation. It's even possible to work directly with GCC but still upload programs to Arduino via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also worth noting that programs compiled within the Arduino IDE aren't necessarily going to run any slower than programs compiled some other way (whether C or C++). The main difference is whether or not you use the Arduino functions. Since they are general purpose, they're not necessarily doing things the most optimal way. You could get more efficiency in theory by manipulating the microcontroller's special registers directly, which is you can do from within the Arduino IDE as well. It's usually very tricky for a beginner though, so it's probably not something you want to attempt until you're more comfortable with C/C++.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-14T11:00:07.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8640" PostTypeId="1" CreationDate="2015-02-14T11:21:08.613" Score="3" ViewCount="1574" Body="&lt;p&gt;I am trying to connect SD card with arduino without using a shield. To convert to 3.3v, I have used voltage divider circuit as described in these two sites:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://garagelab.com/profiles/blogs/tutorial-how-to-use-sd-card-with-arduino&quot; rel=&quot;nofollow&quot;&gt;http://garagelab.com/profiles/blogs/tutorial-how-to-use-sd-card-with-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.martin-gardner.co.uk/how-to-connect-your-old-sd-card-to-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.martin-gardner.co.uk/how-to-connect-your-old-sd-card-to-an-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I uploaded the code i got the following error on serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initializing SD card...initialization done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;error opening test.txt&lt;br&gt;&#xA;error opening test.txt&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-02-14T11:21:08.613" Title="Interfacing SD card with arduino without shield" Tags="|arduino-uno|serial|sd-card|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8641" PostTypeId="2" ParentId="8626" CreationDate="2015-02-14T12:47:19.453" Score="1" Body="&lt;p&gt;That's what I do all the time. You might want to buy an ISP programmer to program the chips (e.g. USBASP or usbtinyisp). If you just want to try things out first, you can use your arduino board as an programmer by uploading the ArduinoISP sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno uses an ATMega328, but you could use other AVR chips too. E.g. the ATMega8, which is slightly cheaper. Or an ATTiny85, which only has a few pins, and is therefor a lot smaller (also cheaper). So you can choose a chip that best fits your needs.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-02-14T12:47:19.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8642" PostTypeId="1" CreationDate="2015-02-14T12:59:38.253" Score="0" ViewCount="6389" Body="&lt;p&gt;How can I fix error code 10 while installing the device driver for Arduino in Windows 8.1?&#xA;The LED on the board is blinking after connecting it to the laptop, so I don't think so that the board is damaged. What is the cause of this issue?&lt;/p&gt;&#xA;" OwnerUserId="7291" OwnerDisplayName="Lucky" LastEditorUserId="220" LastEditDate="2015-02-14T15:19:34.647" LastActivityDate="2017-01-16T12:01:57.320" Title="Error code 10 for arduino device driver" Tags="|arduino-ide|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8643" PostTypeId="2" ParentId="8642" CreationDate="2015-02-14T16:01:32.287" Score="1" Body="&lt;p&gt;First of all, test if you even need a new driver. On Windows, the Arduino drivers for my Uno and my Mega were installed automatically by Windows. I'd advise to restart your computer, &lt;strong&gt;&lt;em&gt;using the actual restart button, not manually shutting off and turning on... this is very important with Windows 8.1 and its Hybrid Boot default!!!&lt;/em&gt;&lt;/strong&gt; A normal reboot doesn't fully reload all of the drivers. Next, open the Arduino IDE, and then see if you can successfully upload the &quot;blink&quot; example sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work, let's try something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, open up Device Manager and find your device:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/v8Q0A.png&quot; alt=&quot;Device manager&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It should be under the &lt;em&gt;Ports (COM &amp;amp; LPT)&lt;/em&gt; section. After that, right click and click on &lt;em&gt;Properties&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RUPKR.png&quot; alt=&quot;Right click menu&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then, let's go to the &lt;em&gt;Driver&lt;/em&gt; tab and click on &lt;em&gt;Update Driver&lt;/em&gt;. Then, click on &lt;em&gt;Search Online Automatically for this Driver.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FHjqo.png&quot; alt=&quot;Properties Window&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, try seeing if an automatic update finds any drivers capable. If not, I've found previously that there's sometimes a &lt;em&gt;Reinstall&lt;/em&gt; or &lt;em&gt;Fix&lt;/em&gt; button somewhere if the driver isn't working correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, you can also update it manually using Device Manager. Instead of clicking on &lt;em&gt;Search Online Automatically for this Driver,&lt;/em&gt; click &lt;em&gt;Browse My Computer Manually.&lt;/em&gt; For me, there was a Mega driver under the &lt;em&gt;Let me pick from a list of compatible device drivers on my computer&lt;/em&gt; and there was a Mega driver for me (although I don't know if that's because I have it installed already).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use that same menu to point it to the location of the installation of the Arduino IDE and it will search for any compatible drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rolling back the driver is another option if the Arduino IDE tried to install a faulty driver that somehow got corrupt over a working driver installed by the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last thing I would suggest trying as a last resort is using the &lt;em&gt;Uninstall Driver&lt;/em&gt; button and then trying to reinstall the driver manually. I've never done this with an Arduino board, although there have been some times with other drivers that this has helped to remove the faulty driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If none of this works, it may be a faulty board.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-02-14T16:01:32.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8644" PostTypeId="1" CreationDate="2015-01-15T12:49:16.787" Score="0" ViewCount="2103" Body="&lt;p&gt;I am working on my project of home automation system using Arduino GSM SIM900 &amp;amp; four channel relay module. I am facing a problem in my code. Can any one help me on this, SMS is receiving but its not switching the relays?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;// EN: String buffer for the GPRS shield message&#xA;String msg = String(&quot;&quot;);&#xA;// EN: Set to 1 when the next GPRS shield message will contains the SMS message&#xA;int SmsContentFlag = 0;&#xA;//control pins of relay.&#xA;int relay_a=4;&#xA;int relay_b=5;&#xA;int relay_c=6;&#xA;int relay_d=7;&#xA;&#xA;// EN: Code PIN of the SIM card (if applied)&#xA;//String SIM_PIN_CODE = String( &quot;XXXX&quot; );&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(19200);                 // the GPRS baud rate&#xA;  // Initialize  PINs&#xA;  pinMode( 4, OUTPUT ); &#xA;  pinMode( 5, OUTPUT ); &#xA;  pinMode( 6, OUTPUT ); &#xA;  pinMode( 7, OUTPUT ); &#xA;  digitalWrite( 4, LOW ); &#xA;  digitalWrite( 5, LOW ); &#xA;  digitalWrite( 6, LOW );&#xA;  digitalWrite( 7, LOW );&#xA; Serial.println( &quot;AT+CMGF=1&quot; ); &#xA; delay(200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    char SerialInByte;&#xA;    if(Serial.available())&#xA;    {       &#xA;        SerialInByte = (unsigned char)Serial.read();&#xA;       delay(5);&#xA;&#xA;        // -------------------------------------------------------------------&#xA;        // EN: Program also listen to the GPRS shield message.&#xA;        // -------------------------------------------------------------------&#xA;       // EN: If the message ends with &amp;lt;CR&amp;gt; then process the message&#xA;        if( SerialInByte == 13 ){&#xA;          // EN: Store the char into the message buffer&#xA;          ProcessGprsMsg();&#xA;         }&#xA;         if( SerialInByte == 10 ){&#xA;            // EN: Skip Line feed&#xA;         }&#xA;         else {&#xA;           // EN: store the current character in the message string buffer&#xA;           msg += String(SerialInByte);&#xA;         }&#xA;     }   &#xA;}&#xA;// EN: Make action based on the content of the SMS. &#xA;//     Notice than SMS content is the result of the processing of several GPRS shield messages.&#xA;void ProcessSms( String sms ){&#xA;&#xA;  if( sms.indexOf(&quot;ona&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite( relay_a, HIGH );&#xA;  }&#xA;   if( sms.indexOf(&quot;onb&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_b, HIGH );&#xA;  }&#xA;   if( sms.indexOf(&quot;onc&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_c, HIGH );&#xA;  }&#xA;  if( sms.indexOf(&quot;ond&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_d, HIGH );&#xA;  }&#xA;  if( sms.indexOf(&quot;offa&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_a, LOW );&#xA;  }&#xA;  if( sms.indexOf(&quot;offb&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_b, LOW );&#xA;  }&#xA;  if( sms.indexOf(&quot;offc&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_c, LOW );&#xA;  }&#xA;  if( sms.indexOf(&quot;offd&quot;) &amp;gt;= 0 ){&#xA;    digitalWrite(  relay_d, LOW );&#xA;  }&#xA;}&#xA;// EN: Request Text Mode for SMS messaging&#xA;void GprsTextModeSMS(){&#xA;  Serial.println( &quot;AT+CMGF=1&quot; );&#xA;}&#xA;&#xA;void GprsReadSmsStore( String SmsStorePos ){&#xA;  Serial.print( &quot;AT+CMGR=&quot; );&#xA;  Serial.println( SmsStorePos );&#xA;}&#xA;&#xA;// EN: Clear the GPRS shield message buffer&#xA;void ClearGprsMsg(){&#xA;  msg = &quot;&quot;;&#xA;}&#xA;&#xA;// EN: interpret the GPRS shield message and act appropiately&#xA;void ProcessGprsMsg() {&#xA;  if( msg.indexOf( &quot;Call Ready&quot; ) &amp;gt;= 0 ){&#xA;   //  Serial.println( &quot;*** GPRS Shield registered on Mobile Network ***&quot; );&#xA;     GprsTextModeSMS();&#xA;  }&#xA;&#xA;  // EN: unsolicited message received when getting a SMS message&#xA;  if( msg.indexOf( &quot;+CMTI&quot; ) &amp;gt;= 0 ){&#xA;   //  Serial.println( &quot;*** SMS Received ***&quot; );&#xA;     // EN: Look for the coma in the full message (+CMTI: &quot;SM&quot;,6)&#xA;     //     In the sample, the SMS is stored at position 6&#xA;     int iPos = msg.indexOf( &quot;,&quot; );&#xA;     String SmsStorePos = msg.substring( iPos+1 );&#xA;   //  Serial.print( &quot;SMS stored at &quot; );&#xA;  //   Serial.println( SmsStorePos );     &#xA;     // EN: Ask to read the SMS store&#xA;     GprsReadSmsStore( SmsStorePos );&#xA;  }&#xA;&#xA;  // EN: SMS store readed through UART (result of GprsReadSmsStore request)  &#xA;  if( msg.indexOf( &quot;+CMGR:&quot; ) &amp;gt;= 0 ){&#xA;    // EN: Next message will contains the BODY of SMS&#xA;    SmsContentFlag = 1;&#xA;    // EN: Following lines are essentiel to not clear the flag!&#xA;    ClearGprsMsg();&#xA;    return;&#xA;  }&#xA;&#xA;  // EN: +CMGR message just before indicate that the following GRPS Shield message &#xA;  //     (this message) will contains the SMS body &#xA;  if( SmsContentFlag == 1 ){&#xA; //   Serial.println( &quot;*** SMS MESSAGE CONTENT ***&quot; );&#xA; //   Serial.println( msg );&#xA; //   Serial.println( &quot;*** END OF SMS MESSAGE ***&quot; );&#xA;    ProcessSms( msg );&#xA;  }&#xA;&#xA;  ClearGprsMsg();&#xA;  // EN: Always clear the flag&#xA;  SmsContentFlag = 0; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Ali IQrar" LastEditorUserId="6452" LastEditDate="2015-02-24T18:22:34.957" LastActivityDate="2021-08-11T07:07:25.717" Title="Arduino Based Home Automation System" Tags="|gsm|relay|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8645" PostTypeId="2" ParentId="8644" CreationDate="2015-01-15T13:24:27.137" Score="1" Body="&lt;p&gt;I think you'd want to include a call to &lt;code&gt;ClearGprsMsg()&lt;/code&gt; right before the line &lt;code&gt;GprsReadSmsStore( SmsStorePos );&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;msg += String(SerialInByte);&lt;/code&gt; is probably wrong, see for example &lt;a href=&quot;http://arduino.cc/en/Tutorial/StringConstructors&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/StringConstructors&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// using a constant integer:&#xA;stringOne =  String(13);        &#xA;Serial.println(stringOne);      // prints &quot;13&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8093" OwnerDisplayName="Hanno Binder" LastActivityDate="2015-01-15T13:24:27.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8647" PostTypeId="1" AcceptedAnswerId="8648" CreationDate="2015-02-14T19:58:04.153" Score="0" ViewCount="3506" Body="&lt;p&gt;There is a function on one of my programs I want to be switch on and off by pressing a button. The button is unbiased otherwise I would set the function to read the button's status of HIGH or LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I need to create variable named &quot;switch&quot; with an initial value of 0. Then I would create a function would read if buttonPin is HIGH change the value of &quot;switch&quot; by +1. Next time the buttonPin is HIGH change the value by -1 so that every time the button is pressed the value of &quot;switch&quot; alternates between 1 and 0. Now before my loop calls the function I want on or off it can compare the value of &quot;switch&quot; and run or not run the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to express this in the Arduino sketch. I'm am also open to alternate ways of achieving the same result. &lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-02-15T20:15:22.463" Title="Program button to switch between two values" Tags="|sketch|variables|code-optimization|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8648" PostTypeId="2" ParentId="8647" CreationDate="2015-02-14T20:25:38.697" Score="1" Body="&lt;p&gt;Pseudocode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value = 0&#xA;if button is pressed:&#xA;  value = 1 - value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-14T20:25:38.697" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8649" PostTypeId="1" CreationDate="2015-02-14T20:53:24.830" Score="2" ViewCount="2813" Body="&lt;p&gt;I have recklessly bought the &lt;a href=&quot;https://www.aliexpress.com/item/1432585134.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Baite Pro Mini&lt;/a&gt; and I find it difficult to upload any program. I use Ubuntu Linux, but out of frustration I am ready to install Windows, if it is necessary.&lt;/p&gt;&#xA;&lt;p&gt;I've read the information from the blog &lt;a href=&quot;http://nerdralph.blogspot.ca/2014/01/baite-pro-mini-review.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://nerdralph.blogspot.ca/2014/01/baite-pro-mini-review.html&lt;/a&gt; . Too bad, that the blog owner didn't put much details. Can anyone here fill some blanks for me?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How exactly should I connect the Arduino device to the computer?&#xA;I have a converter USB to serial pl2303HX: &lt;img src=&quot;https://i.stack.imgur.com/zARZh.jpg&quot; alt=&quot;PL2303HX&quot; /&gt; which I tried to connect with the Baite Pro Mini in almost any plausible permutation of the wires, but never got any result.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;edit:&lt;/p&gt;&#xA;&lt;p&gt;Here is the description of pins of the pl2303HX: &lt;a href=&quot;https://i.stack.imgur.com/FL8Xr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FL8Xr.jpg&quot; alt=&quot;Pin layout of PL2303HX device&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;https://img.fasttechcdn.com/123/1230400/1230400-3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;fasttechcdn.com&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;I did connect it the following way:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Baite Pro Mini      pl2303HX&#xA;GND  &#xA;GND  &amp;lt;------------&amp;gt; GND&#xA;VCC  &amp;lt;------------&amp;gt; +5V&#xA;RXI  &amp;lt;------------&amp;gt; TXD&#xA;TXC  &amp;lt;------------&amp;gt; RXD&#xA;DTR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried the permutation with different &lt;code&gt;GND&lt;/code&gt; pin. I also tried pressing the &lt;code&gt;reset&lt;/code&gt; button on the Baite Pro Mini around the time of hitting the &amp;quot;Upload&amp;quot; button on the Arduino standard compiler.&lt;/p&gt;&#xA;&lt;p&gt;I believe my failure might have something to do with the absence of &lt;code&gt;DTR&lt;/code&gt; pin on the converter that resets the board just before upload. Are my worries justified? Is there anything I can do?&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Which exactly &lt;a href=&quot;https://docs.arduino.cc/hacking/software/Bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino bootloader&lt;/a&gt; do I need?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How to connect USBASP to the Beite Pro Mini?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7329" LastEditorUserId="27346" LastEditDate="2022-12-20T17:42:13.573" LastActivityDate="2022-12-20T17:42:13.573" Title="How to get Baite Pro Mini working?" Tags="|arduino-pro-mini|linux|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8650" PostTypeId="2" ParentId="8563" CreationDate="2015-02-14T21:09:42.203" Score="1" Body="&lt;p&gt;This &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoLeonardoMicro&quot; rel=&quot;nofollow&quot;&gt;Arduino.cc article&lt;/a&gt; describes the differences between Leonard &amp;amp; Micro vs. other Arduinos, including the fact that Micro does not have a separate USB processor on board but creates a virtual USB with the main processor. There is no (or a very different) auto-reset mechanism. There is apparently a way for the IDE to open the Mac's USB at 1200 baud to cause the Micro to reset; then the IDE can wait for the virtual USB to re-appear. But it also says you may need to use the reset button suggesting the 1200 baud dance doesn't work all that reliably.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-02-14T21:09:42.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8651" PostTypeId="1" CreationDate="2015-02-14T21:19:03.793" Score="21" ViewCount="25628" Body="&lt;p&gt;I'm new to Arduino/C development (coming from a JavaScript/Ruby environment), but I was wondering if it was possible to include a library from a custom folder within a sketch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is my situation;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;project.ino&#xA;libs/&#xA;  MyNewLib/&#xA;    MyNewLib.h&#xA;    MyNewLib.ccp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now my question is: how can I include my custom library? I've tried several variations on this;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# project.ino&#xA;&#xA;#include &amp;lt;libs/MyNewLib/MyNewLib.h&amp;gt;&#xA;#include &quot;libs/MyNewLib/MyNewLib.h&quot;&#xA;#include &amp;lt;./libs/MyNewLib/MyNewLib.h&amp;gt;&#xA;#include &quot;./libs/MyNewLib/MyNewLib.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But none of them works. Can anyone tell me if this is possible? I've looked into this question around the web, but I can't find any satisfying answer. Hopefully you guys can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm aware you can put your libraries in your global libraries folder, but I want them in my local project folder. I want to share them through git with my team.&lt;/p&gt;&#xA;" OwnerUserId="7331" LastEditorUserId="4628" LastEditDate="2015-11-22T21:28:21.623" LastActivityDate="2017-01-11T03:12:43.943" Title="Loading local libraries" Tags="|library|sketch|system-design|" AnswerCount="7" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8652" PostTypeId="1" CreationDate="2015-02-14T23:10:59.593" Score="2" ViewCount="70" Body="&lt;p&gt;I am having an issue with removing temporarily files I am creating under the /www directory. I have a subdir, &quot;/www/csv&quot;,  where csv formatted files are being written based on sensor data. The files are created on-demand on the YUN, placed in the /www/csv dir, with the whole process driven by a REST call and an AJAX implementation in a browser.  The files are created with no problem with a Filesystem.open(path, FILE_WRITE); call. I can also use the Process calls from the bridge library to rename the file after it is full written. However, if I try to use Process calls (i.e. p.begin(&quot;rm&quot;);, etc, etc) to remove the files after use, the files are never deleted. I also tried the &quot;mv&quot; the files to /tmp so they would get cleaned up by the OS eventually, but that fails also. I have the rights to /www and /www/csv set to &quot;777&quot;. I am assuming this is an access rights issue, however I am unsure what user my REST calls are running as (it would be whatever the default is for a YUN as I have created no additional users on the system). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&#xA;Pete&lt;/p&gt;&#xA;" OwnerUserId="7334" LastActivityDate="2015-02-14T23:10:59.593" Title="Issue with removing files progrmatically created under &quot;/www/...&quot;" Tags="|arduino-yun|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8654" PostTypeId="2" ParentId="8604" CreationDate="2015-02-15T07:52:41.143" Score="1" Body="&lt;p&gt;I gave up on using a LM335, which is quite similar to your LM35. The problem is these devices self-heat due to the quiescent power they draw. The LM35 data sheet suggests you correct for this in software (footnote 5), and the LM335 datasheet dodges the bullet by quoting accuracy figures that can be achieved in an oil bath rather than free air.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the figures you are quoting suggest you have a bigger problem, as I am talking of a few degrees inaccuracy, not tens of degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed to a DS18B20 and never looked back - simple interface and self-heating is compensated for by the device.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-02-15T07:52:41.143" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8656" PostTypeId="2" ParentId="8564" CreationDate="2015-02-15T10:22:37.403" Score="0" Body="&lt;p&gt;I literally gave up and got myself a Atmel-ICE which solved all my problems.&lt;/p&gt;&#xA;" OwnerUserId="7257" LastActivityDate="2015-02-15T10:22:37.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8657" PostTypeId="2" ParentId="8649" CreationDate="2015-02-15T12:27:49.487" Score="2" Body="&lt;p&gt;I have several clone Pro Minis I got from several sources on ebay for ~ £2 ($3) each. I also use Ubuntu (10.04 on this old PC but it's fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with a USB converter similar to yours and it was a bit hit-and-miss choosing when to press the reset to upload. Once I got connections right and worked out when to press reset it became a more reliable procedure but still a pain. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realised that it would be better to use the auto-reset from DTR so I got a cheapo USB to serial from ebay which claimed to be FTDI (or compatible?) though I didn't know what that meant at the time. With a small converter board to make the right connections it works well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your connections look good so if you haven't damaged anything it's probably a matter of when to press reset. Windows won't help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must choose the correct board in the Tools menu of the Arduino IDE - Pro Mini with correct AVR chip, speed and voltage. I use programmer AVR ISP (I think)&lt;/p&gt;&#xA;" OwnerUserId="7340" LastEditorUserId="7340" LastEditDate="2015-02-15T12:36:48.880" LastActivityDate="2015-02-15T12:36:48.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8658" PostTypeId="1" CreationDate="2015-02-15T14:03:23.483" Score="2" ViewCount="711" Body="&lt;p&gt;I am using the RX LED pin as CS for my SPI connection and experiencing problems while debugging and communicating via SPI. Is it possible somehow to disable the RX blinking while using the serial monitor?&lt;/p&gt;&#xA;" OwnerUserId="7257" LastActivityDate="2015-02-15T14:03:23.483" Title="How to disable RX led on Arduino Micro" Tags="|spi|arduino-micro|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8659" PostTypeId="1" CreationDate="2015-02-15T14:55:25.753" Score="0" ViewCount="1980" Body="&lt;p&gt;So I have a Duemilanove board and am utilizing 7 output pins, I power a Pixy camera and pan/tilt servos from the ICSP header, i also power an HC-SR04 sonar snsor directly from the board.&lt;/p&gt;&#xA;&lt;p&gt;Of those 7 output pins, 4 are PWMs for the motors (don't ask why), 3 are for servo control (tower pro mg-995)&lt;/p&gt;&#xA;&lt;p&gt;when I try to output these 7 pins simultaneously things don't work, i get &amp;quot;components at a time&amp;quot; behavior. Like servos turn first, then the motors spin (servos stopped).&lt;/p&gt;&#xA;&lt;p&gt;Initially we thought it must be a power supply problem (8 1.2v NiMh bat series) which powers the l298n h bridges (two of them) and also powers the board and servos. But now im starting to fear that it's the board itself and that it can't handle simultaneous outputs.&lt;/p&gt;&#xA;&lt;p&gt;I've read from &lt;a href=&quot;http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here (method #10)&lt;/a&gt; that taxing the board more than 200mA is a problem. But what exactly happens if you do just that? And is my case exactly like this one? If so, how to fix it?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Edit +&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here's how the circuit looks.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ccwHt.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Yes i do think there is a need for decoupling capacitors but im not sure where to put them. They dont seem to work. The bounty goes to the best answer on the proper decoupling of this circuit.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here's some images on the Pixy camera&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DznXd.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Vhond.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Actually from the original problem I noted when I posted this question, things don't work as expected. WHen the big servos move, the pan/tilt camera don't move when they are supposed to, or the motors briefly stop. I'm wondering if is also an Arduino idiosyncrasy because when I don't run the &lt;code&gt;servo.attach(servo_pin)&lt;/code&gt;  code everything works fine.&lt;/p&gt;&#xA;" OwnerUserId="7343" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-10-08T01:58:51.617" Title="Measure total microcontroller current?" Tags="|battery|current|arduino-duemilanove|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8660" PostTypeId="2" ParentId="8620" CreationDate="2015-02-15T15:52:10.487" Score="2" Body="&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; It seems like you need to send a null bit (0) to terminate the communication with this board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the downloads section, I found a .nxc file, which I assume is a NXT code file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the main loop, they configure the I2C port and a &quot;touch sensor&quot; (I believe this is to figure out how to synchronize the text with the motor). In that, there is a main loop in which they call &lt;code&gt;DispLetter&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;code&gt;DispLetter&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void DispLetter (const byte &amp;amp; letter[])&#xA;{&#xA;  int nbytes;&#xA;  // Wait for the end of previously sent data&#xA;  while(I2CStatus(I2Cport, nbytes)==STAT_COMM_PENDING);&#xA;  // Write buffer to send to PCF8574&#xA;  byte WriteBuf[];&#xA;  ArrayBuild(WriteBuf, I2CAddr8574, letter);&#xA;  for(int i=1; i&amp;lt;ArrayLen(WriteBuf); i++)&#xA;  {&#xA;     WriteBuf[i] ^= 0xff;&#xA;  }&#xA;  I2CWrite(I2Cport, 0,  WriteBuf);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's read this code! First of all, it seems to make sure that the I2C port is connected, which we don't really have to worry about in our case since that's platform-specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, they create an array called &lt;code&gt;WriteBuf[]&lt;/code&gt; that will store the data to be sent to the controller. Then we come across a function called &lt;code&gt;ArrayBuild&lt;/code&gt;. Looking that up, it combines &lt;code&gt;I2CAddr8574&lt;/code&gt; and &lt;code&gt;letter&lt;/code&gt; and places it into the &lt;code&gt;WriteBuf&lt;/code&gt; array. (&lt;a href=&quot;http://bricxcc.sourceforge.net/nbc/nxcdoc/nxcapi/group___array_functions_gae8d75e08c670f09f01200a897d7ed2ba.html&quot; rel=&quot;nofollow&quot;&gt;Click here for documentation for that function.&lt;/a&gt;) Please note that the &lt;code&gt;I2CAddr8574&lt;/code&gt; is just a byte containing 0x70 (the address of the chip), so we will not have to do this step since the Arduino handles the address. So, you will just have to send the &lt;code&gt;letter&lt;/code&gt; array to the controller, ignoring the &lt;code&gt;WriteBuf&lt;/code&gt; and &lt;code&gt;ArrayBuild&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's figure out how &lt;code&gt;letter&lt;/code&gt; is passed. In the main loop, they had this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DispLetter(L_);&#xA;DispLetter(E_);&#xA;DispLetter(G_);&#xA;DispLetter(O_);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That must display &quot;LEGO.&quot; Let's figure out what &lt;code&gt;L_&lt;/code&gt; is defined as. At the beginning of the document, they have this defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Display patterns&#xA;// Each byte represents a column of dots&#xA;// Bit set to 1 means lit LED.&#xA;// Least significant bit is at top of column.&#xA;// Last byte must be all 0&#xA;// Maximum number of bytes par pattern: 15&#xA;&#xA;byte L_[] = {0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0};&#xA;byte E_[] = {0xff, 0x89, 0x89, 0x89, 0x89, 0x81, 0x81, 0};&#xA;byte G_[] = {0x7e, 0x00, 0x81, 0x81, 0x81, 0x81, 0x91, 0x90, 0x72, 0};&#xA;byte O_[] = {0x7e, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x7e, 0};&#xA;&#xA;byte La_[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0};&#xA;byte Ea_[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0};&#xA;byte Ga_[] = {0x72, 0x90, 0x91, 0x81, 0x81, 0x81, 0x81, 0x00, 0x7e, 0};&#xA;byte Oa_[] = {0x7e, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x00, 0x7e, 0};&#xA;&#xA;byte N_[] = {0xff, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xff, 0};&#xA;byte X_[] = {0x80, 0x41, 0x22, 0x14, 0x08, 0x14, 0x22, 0x41, 0x80, 0};&#xA;byte T_[] = {0x01, 0x01, 0x01, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, they listed out how the dots are configured. There's a max of 15 bytes (I assume including the null bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one more piece of code that we haven't talked about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i=1; i&amp;lt;ArrayLen(WriteBuf); i++)&#xA;{&#xA;   WriteBuf[i] ^= 0xff;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it goes through each bit, and does something to it. That is the shorthand for this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WriteBuf[i] = WriteBuf[i] ^ 0xff;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No, that is &lt;em&gt;not&lt;/em&gt; an exponent. That is an exclusive OR, a &lt;em&gt;bitwise&lt;/em&gt; operator. A bitwise operator is basically where it &quot;overlays&quot; the two binary sequences and it does a special computation on them. If the nth bit of each input number is 1 or the nth bit of each input number is 0, the nth output bit is 0. If the nth bit of one input number is 1 and the nth bit of the other input number is 0, then the nth bit of the output is 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since 0xff = B11111111, it will essentially reverse the values of each bit. You can avoid this if you say that a bit set to &lt;em&gt;0&lt;/em&gt; is on, instead of a bit set to &lt;em&gt;1&lt;/em&gt; (like they do in the example code). A minor adjustment that just makes your life a bit easier :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, you can write that array to the I2C bus and it should display the data!&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="220" LastEditDate="2015-02-15T16:00:48.557" LastActivityDate="2015-02-15T16:00:48.557" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8661" PostTypeId="1" AcceptedAnswerId="14469" CreationDate="2015-02-15T17:48:09.020" Score="2" ViewCount="1865" Body="&lt;p&gt;Can you use &lt;code&gt;clang&lt;/code&gt;, with &lt;code&gt;--mpu=arm&lt;/code&gt;, etc. and &lt;code&gt;avrdude&lt;/code&gt; to program an Arduino Due (Arm Cortex M3)?&lt;/p&gt;&#xA;" OwnerUserId="2899" LastEditorUserId="2899" LastEditDate="2015-04-25T15:39:21.487" LastActivityDate="2016-09-15T01:43:01.680" Title="Programming arduino with Objective-C" Tags="|programming|c++|sketch|c|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8662" PostTypeId="2" ParentId="8661" CreationDate="2015-02-15T18:48:29.813" Score="2" Body="&lt;p&gt;Theoretically, many things are possible. There is an easy way to code Arduino on Xcode with EmbedXCode (&lt;a href=&quot;http://playground.arduino.cc/Main/EmbedXcode&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/EmbedXcode&lt;/a&gt;), but in C and CPP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a compiler that will compile your Objective-C to for the AVR (if you are using an AVR-based Arduino), this may be difficult to find. Once your code is compiled, then you need to upload it to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in any reasonable means, it is at least very challenging.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-15T18:48:29.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8663" PostTypeId="2" ParentId="8659" CreationDate="2015-02-15T19:07:42.497" Score="-1" Body="&lt;p&gt;When power goes through a wire, it heats up the wire. The more current you draw, the more it heats up. The &quot;wires&quot; inside a chip such as the one that adjusts the power aresmall, which means it heats up more, and also it takes less to burn it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fuse is essentially a very thin wire. If you draw too much current (amps) through it, it will burn out (melt the wire). Wires inside a chip or on a PCB are much the same, It may recover when it cools down, or not. Some devices have protection, some do not - you may find the arduino shuts itself off to protect itself, to restart after a period. Or it may not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As has been suggested, you can bypass the board to power the h-bridge - there should be one or two pins to power the h-bridge separate from the signalling, specifically for this reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if the board is powered by batteries, the batteries may not be able to supply the current, causing one or more parts not getting enough power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do bypass the voltage regulator and use power directly from the power source, remember that you are using a different voltage - the voltage from the power source, not +5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are powering your board from USB, then be aware that there are limitations to the power able to be supplied via USB - the USB specs say 150milliamps; any higher power has to be negotiated with the host (PC), so you may get different answers for a laptop vs. a desktop vs. a mains power adapter.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-02-15T20:31:34.397" LastActivityDate="2015-02-15T20:31:34.397" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="8664" PostTypeId="2" ParentId="8647" CreationDate="2015-02-15T20:15:22.463" Score="0" Body="&lt;p&gt;It sounds like you are using a number as a boolean (true/false) value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might consider using a a boolean instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean value = false;&#xA;if button is pressed {&#xA;    value=!value&#xA;}&#xA;if value {&#xA;    // do something here.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can set it to &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;, or change it to it's opposite (with &lt;code&gt;value=!value&lt;/code&gt; as shown above). You can also do &lt;code&gt;if value&lt;/code&gt; or &lt;code&gt;if !value&lt;/code&gt; (&quot;if not value&quot;) - these are equivalent to &lt;code&gt;if value=true&lt;/code&gt; or &lt;code&gt;if value=false&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-15T20:15:22.463" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8665" PostTypeId="2" ParentId="8649" CreationDate="2015-02-16T00:10:56.650" Score="2" Body="&lt;p&gt;Your connections are incorrect if you are &quot;straight through&quot; connecting.&lt;br&gt;&#xA;Gnd &amp;amp; Vcc are adjacent on the processor board and separated by 2 pins on your converter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find Gnd, Vcc, TX, RX on USB module and processor then you should&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect Gnd to Gnd&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect Vcc to Vcc&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect ........TXD to RXD and&lt;br&gt;&#xA; ........................RXD to TXD &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ensure that you have the correct USB converter drivers loaded. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A reset does not seem to be needed when using the Baite processor AND Baite USB module.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have a number of Baite Pro Minis working perfectly.&lt;br&gt;&#xA;In my experience (3 or 4 sales so far) Baite's products are usually of acceptable quality . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting &quot;almost any plausible permutation of the wires&quot; is a fine way to attempt to destroy the converter and/or the BPM. Logical connection should work - if you have not damaged something. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect as Ignacio says.&lt;br&gt;&#xA;Note that you connect &lt;strong&gt;BPM-TX to USB-converter-RX&lt;/strong&gt;, and RX to TX and **NOT RX to RX). The BPM has connections shown on the PCB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XWl8i.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Baite provide this diagram&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Acic3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your converter module has a different pinout which needs to be allowed for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BsLyx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must also have drivers on your system for the USB to serial bridge IC used on your converter. The Baite converter uses a CH340G IC. Your may or may not. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-16T12:59:47.177" LastActivityDate="2015-02-16T12:59:47.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8666" PostTypeId="1" AcceptedAnswerId="8667" CreationDate="2015-02-16T00:32:24.947" Score="5" ViewCount="234" Body="&lt;p&gt;I can only find info relating to the wifi shield, but I want to send an email without the wifi shield. For now, I just plan on leaving my arduino plugged into a computer, so I just want to use the computer's network connection. Is there a library or something I can grab for this?&lt;/p&gt;&#xA;" OwnerUserId="7349" LastEditorUserId="7349" LastEditDate="2015-02-16T00:39:39.603" LastActivityDate="2015-02-16T00:51:42.640" Title="How Do I Send An Email WITHOUT An Ethernet or WiFi Shield" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8667" PostTypeId="2" ParentId="8666" CreationDate="2015-02-16T00:51:42.640" Score="4" Body="&lt;p&gt;If you mean plugged-in via USB, then no. There's nothing you can do on the Arduino that would let you use the computer's network connection directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to have a program running on the computer which would communicate with the Arduino via serial. It would effectively act as an intermediary, sending the email on behalf of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I suspect you'd have to write the program yourself. It's possible that something similar already exists, but at the very least you'd probably have to modify it to suit your needs.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-16T00:51:42.640" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8668" PostTypeId="1" CreationDate="2015-02-16T03:34:24.803" Score="1" ViewCount="1728" Body="&lt;p&gt;I am trying to implement a function queue scheduling system. INT1 is connected to a button and int1task causes an LED to flash.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void (*funcptr)(void);&#xA;TPrioQueue *queue = NULL;&#xA;&#xA;void int1ISR() {&#xA;  if (debounce(&amp;amp;int1time)) // Checks if the interrupt is caused by switch bouncing&#xA;    enq(queue, (void*) int1task, 1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, I execute the function in loop() by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void (*funcptr)(void);&#xA;&#xA;void loop(){&#xA;  funcptr func = (funcptr) deq(queue);&#xA;  if (func != NULL)&#xA;    (*func)(); // Stuck in a loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, the LED keeps flashing even though I have not pressed the button. Why does this happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I remove the line below, the ISR works properly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enq(queue, (void*) int1task, 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The relevant sections of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int debounce(unsigned long *debTimer) {&#xA;  unsigned long tmp = *debTimer;&#xA;  unsigned long currTime = millis();&#xA;&#xA;  if ((currTime-tmp) &amp;gt; 500){&#xA;    *debTimer = currTime;&#xA;    return 1;&#xA;  }&#xA;  else&#xA;    return 0;&#xA;}&#xA;&#xA;// Flashes LED at pin 6 five times at 2 Hz&#xA;void int1task(){&#xA;  for(int i=0; i&amp;lt;5; i++){&#xA;    digitalWrite(6, HIGH);&#xA;    delay(250);&#xA;    digitalWrite(6, LOW);&#xA;    delay(250);&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA;  pinMode(6, OUTPUT);&#xA;  attachInterrupt(1, int1ISR, RISING);&#xA;  Serial.begin(115200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/sh/l6byqdd4r32rapd/AAD8Pxj7iiSoRjQvksr_U3o8a?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Code I used for the queue&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the &lt;a href=&quot;https://www.dropbox.com/s/51f8174815zycrg/schematic.pdf?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt; I am using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WJRhr.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7351" LastEditorUserId="510" LastEditDate="2015-04-08T19:02:44.960" LastActivityDate="2015-04-08T19:02:44.960" Title="ISR executes even though an interrupt is not triggered" Tags="|arduino-uno|interrupt|c|isr|pointer|" AnswerCount="3" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="8669" PostTypeId="2" ParentId="8668" CreationDate="2015-02-16T03:39:31.183" Score="0" Body="&lt;p&gt;ISRs have flags, typically an enable flag and a pending flag.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The enable flag needs to be set true for the interrupt to occur at all.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pending flag is set when the interrupt event occurs.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within the interrupt function, the pending flag must be cleared, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;otherwise the the interrupt function will immediately be executed again (and again and again and ...)&lt;/p&gt;&#xA;" OwnerUserId="7352" LastActivityDate="2015-02-16T03:39:31.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8670" PostTypeId="2" ParentId="8633" CreationDate="2015-02-16T06:56:53.480" Score="0" Body="&lt;p&gt;The hash is a series of binary digits. They are usually represented in hexadecimal form for readibility. You are just printing out the raw bytes, which will give a series of random ASCII characters. Some of these may be control characters which interfere with serial port communication.&lt;/p&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-02-16T06:56:53.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8671" PostTypeId="1" AcceptedAnswerId="8680" CreationDate="2015-02-16T07:53:41.223" Score="4" ViewCount="13760" Body="&lt;p&gt;I'm trying to work out the best way to generate a stable frequency with my Uno R3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using interrupts to generate an approximately 40KHz frequency which drives some ICs/MOSFETs to effectively generate 40KHz AC which powers a transducer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to receive the frequency at a second transducer and calculate any frequency shifts.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem is that the generated frequency drifts a little bit off of 40KHz. Is there a way to lock it in at 40KHz via software? I'm receiving approximately 40KHz output (as measured using PicoScope software) with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LEDPIN 13&#xA;void setup()&#xA;{&#xA;pinMode(LEDPIN, OUTPUT);&#xA;// initialize Timer1&#xA;cli();          // disable global interrupts&#xA;TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;TCCR1B = 0;     // same for TCCR1B&#xA;// set compare match register to desired timer count:&#xA;OCR1A = 24;&#xA;// turn on CTC mode:&#xA;TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;// Set CS11 for 8-bit prescaler:&#xA;TCCR1B |= (1 &amp;lt;&amp;lt; CS11);&#xA;// enable timer compare interrupt:&#xA;TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;// enable global interrupts:&#xA;sei();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;// main program&#xA;}&#xA;&#xA; ISR(TIMER1_COMPA_vect)&#xA;{&#xA;digitalWrite(LEDPIN, !digitalRead(LEDPIN));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If there isn't a way to lock it in, is there atleast a way for the Uno to accurately display/store the frequency of the signal it generated at a given time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is this not plausible because the Uno would &quot;think&quot; it is generating 40KHz?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks for  any hints or suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; @RussellMcMahon pointed me in the right direction for this, so I accepted his answer. However, I wanted to share my final code and my misconceptions I encountered. Hopefully this will assist someone else in the future. I'm obviously by no means an expert, and I will try to not give any misleading information here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My original goal was, although poorly stated, to generate as clean a 40KHz PWM with 50% duty cycle as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems with my original code above were:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using an 8-bit pre-scaler&lt;/li&gt;&#xA;&lt;li&gt;Using an interrupt&lt;/li&gt;&#xA;&lt;li&gt;Using digitalWrite()&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;8-Bit Pre-Scaler&lt;/strong&gt; &lt;br&gt;&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The problem here was that the counter only ticked over once every 8 clock cycles. &lt;em&gt;16MHz clock / 8 (pre-scaler) = 2MHz clock&lt;/em&gt; When I asked one of my professors about this he stated something along the lines of &quot;a cycle could be missed due to an interrupt, and would cause it to wait 7 more cycles to 'tick'&quot;. Indeed I was originally using interrupts, and when we did the calculations it seemed like it could plausibly cause up to a a 1KHz swing at 40KHz.&lt;br&gt;&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To rectify this I took out the pre-scaler, and ran straight at the base clock speed to increase resolution.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Using an interrupt&lt;/strong&gt;&lt;br&gt;&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Essentially the interrupt could cause clock cycles to not be counted, further complicated by using an 8-bit pre-scaler. If one clock cycle was missed, with a 2MHz clock (after pre-scale), you add 5E-7 seconds to the counter, changing the output frequency.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Using digitalWrite()&lt;/strong&gt;&lt;br&gt;&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The digitalWrite function is pretty slow. I'm not a guru, but I read this in multiple places and there seems to be a good comparison of methods here: &lt;a href=&quot;http://www.billporter.info/2010/08/18/ready-set-oscillate-the-fastest-way-to-change-arduino-pins/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Digital Pin Oscillation&lt;/a&gt; To get around this problem it had been suggested I toggle a single bit, which is what I set out to do in my final code. (It is worth noting, now that I've completed this project, that the previous link also makes reference to a &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,46896.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;library addition&lt;/a&gt; for faster digitalWrite/Read/etc....)&#xA;&lt;Br&gt;&lt;br&gt;&#xA;I went through a few variations and scrounged code from all over, and made a couple working examples but they didn't do it the way I wished. I believe part of the project I based this version off of was a melding between a previous version I had working and a class example I found online.&lt;br&gt;&lt;br&gt;&#xA;Without further ado, I present the code that took me an embarrassing amount of time to write from numerous sources... I really should tinker with this stuff more often:&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;void setup()&#xA;{&#xA;//Disable interrupts&#xA;cli();&#xA;// Clear Timer1 registers&#xA;TCCR1A = 0;&#xA;TCCR1B = 0;&#xA;// Set OCR1A (TOP): 16MHz/40KHz /2 = 200 steps. &#xA;// Divide 200 by 2 = 100 because waveforms are centered around OCR1A (because toggle)&#xA;OCR1A = 100;&#xA;// Configure Timer/Counter 1&#xA;// Select P &amp;amp; F Correct PWM Mode, and OCR1A as TOP. Use WGM Bits 10 and 13.&#xA;// WGM Bits are in TCCR1A and TCCR1B. Any previous settings are cleared.&#xA;&#xA;// Enable COM1A0 to toggle OC1A on compare match&#xA;TCCR1A = _BV(WGM10) | _BV(COM1A0);&#xA;// CS10 to enable base clock without pre-scale &#xA;TCCR1B = _BV(WGM13) | _BV(CS10);&#xA;&#xA;//Set OC1A (Digital Pin 9 / Port B Pin 1) to output&#xA;DDRB |= _BV(1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt; For reference, here is the clock frequency formula. In this instance, I had to divide the result by 2 again since I am toggling.&lt;Br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/g1u6n.png&quot; alt=&quot;Clock frequency formula&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resultant output verified by PicoScope:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/NdgbK.png&quot; alt=&quot;Picoscope Oscilloscope Trace&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;In closing, you will notice that it isn't exactly 40KHz. Research turned up that the Arduino Uno makes use of a less accurate ceramic resonator to clock the ATMEGA328P (although a 16MHz crystal oscillator is onboard to clock the USB). To further increase accuracy in a generated signal will require the Arduino to be driven with an external clock source.&lt;/p&gt;&#xA;" OwnerUserId="7317" LastEditorUserId="7317" LastEditDate="2015-02-21T05:38:47.387" LastActivityDate="2019-08-22T15:36:20.980" Title="Stable frequency generation" Tags="|arduino-uno|atmega328|timers|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8672" PostTypeId="1" CreationDate="2015-02-16T09:23:32.793" Score="1" ViewCount="767" Body="&lt;p&gt;I am encountering problems with I2C when trying to attach a 9DoF Sensor to my Arduino Uno. Following &lt;a href=&quot;https://learn.sparkfun.com/tutorials/lsm9ds0-hookup-guide#basic-arduino-example&quot; rel=&quot;nofollow&quot;&gt;these instructions (the hardware setup I have is like in the schematic)&lt;/a&gt; I noticed the basic example not working. I've since debugged different aspects and when I use the &quot;I2C Scanner&quot; example from &lt;a href=&quot;http://www.gammon.com.au/i2c-summary&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; it seems something basic with I2C must be wrong. The code from there I am using is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// I2C Scanner&#xA;// Written by Nick Gammon&#xA;// Date: 20th April 2011&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin (115200);&#xA;&#xA;  // Leonardo: wait for serial port to connect&#xA;  while (!Serial) &#xA;    {&#xA;    }&#xA;&#xA;  Serial.println ();&#xA;  Serial.println (&quot;I2C scanner. Scanning ...&quot;);&#xA;  byte count = 0;&#xA;&#xA;  Wire.begin();&#xA;  for (byte i = 8; i &amp;lt; 120; i++)&#xA;  {&#xA;    Wire.beginTransmission (i);&#xA;    if (Wire.endTransmission () == 0)&#xA;      {&#xA;      Serial.print (&quot;Found address: &quot;);&#xA;      Serial.print (i, DEC);&#xA;      Serial.print (&quot; (0x&quot;);&#xA;      Serial.print (i, HEX);&#xA;      Serial.println (&quot;)&quot;);&#xA;      count++;&#xA;      delay (1);  // maybe unneeded?&#xA;      } // end of good response&#xA;  } // end of for loop&#xA;  Serial.println (&quot;Done.&quot;);&#xA;  Serial.print (&quot;Found &quot;);&#xA;  Serial.print (count, DEC);&#xA;  Serial.println (&quot; device(s).&quot;);&#xA;}  // end of setup&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of this suggested sample output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I2C scanner. Scanning ...&#xA;Found address: 42 (0x2A)&#xA;Done.&#xA;Found 1 device(s).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output I am getting is in Serial monitor on the correct baud rate is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ù&#xA;I2C s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With other examples I have tried I have similar results. As soon as something calls &lt;code&gt;Wire.endTransmission()&lt;/code&gt; things start to crash and burn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what this could be or how to debug it?&lt;/p&gt;&#xA;" OwnerUserId="7157" LastActivityDate="2015-09-11T06:53:35.573" Title="I2C hookup - sketch just crashes" Tags="|arduino-uno|serial|i2c|debugging|wire-library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8673" PostTypeId="1" CreationDate="2015-02-16T09:38:22.597" Score="0" ViewCount="887" Body="&lt;p&gt;I've bought one of those cheap 2.4&quot; TFT LCD resistive touchscreens, one of these: &lt;img src=&quot;https://i.stack.imgur.com/aBGLH.jpg&quot; alt=&quot;2.4&amp;quot; TFT LCD resistive touchscreens.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works great on my Arduino Uno, using the code from &lt;a href=&quot;https://github.com/johnmccombs/arduino-libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;this github repository&lt;/a&gt;.  Now I'm trying to get this to work on my Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino Uno, the LCD controller data lines are configured as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data[0:7] = PORTB[0:1] | PORTD[2:7]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ie. data pins 8, 9, 2, 3, 4, 5, 6, 7 make up the LCD controller data lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Mega, the pin numbers are the same but the ports are configured differently, so that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data[0:7] = ((PORTH &amp;gt;&amp;gt; 5) &amp;amp; 0x03)&#xA;   | ((PORTH &amp;lt;&amp;lt; 3) &amp;amp; 0xc0)&#xA;   | ((PORTG &amp;gt;&amp;gt; 1) &amp;amp; 0x10)&#xA;   | ((PORTE &amp;gt;&amp;gt; 2) &amp;amp; 0x0C)&#xA;   | ((PORTE &amp;lt;&amp;lt; 2) &amp;amp; 0x20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've rewritten the &lt;code&gt;TFTLCD::read8&lt;/code&gt; and &lt;code&gt;TFTLCD::write8&lt;/code&gt; functions accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The screen doesn't work, though.  I've cut example code down to just resetting the LCD controller and reading the chip ID register, ie:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tft.writeData(0);&#xA;Tft.writeData(0);&#xA;Tft.writeData(0);&#xA;Tft.writeData(0);&#xA;&#xA;Tft.writeCommand(0);&#xA;unsigned id = Tft.readData();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, 9 times out of ten, this obtains the correct device ID, &lt;code&gt;0x9325&lt;/code&gt;.  But the other time, it obtains the device ID of &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I initially suspected that this was due to the Mega running somewhat faster, but liberally sprinkling &lt;code&gt;delayMicroseconds(10)&lt;/code&gt; through the &lt;code&gt;writeData&lt;/code&gt;, &lt;code&gt;writeCommand&lt;/code&gt; and &lt;code&gt;readData&lt;/code&gt; functions doesn't seem to make any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something that I'm missing that is messing with the use of the PWM lines on the Arduino Mega as ordinary digital port pins?&lt;/p&gt;&#xA;" OwnerUserId="7358" LastActivityDate="2015-02-17T02:41:47.460" Title="PWM pins weird on Arduino Mega, works on Arduino Uno" Tags="|arduino-mega|pwm|digital|timing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8674" PostTypeId="1" CreationDate="2015-02-16T09:52:21.547" Score="1" ViewCount="1075" Body="&lt;p&gt;I have an arduino web server running from a mega 2560 and a wiznet ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It serves the single page just fine (and very fast) to the LAN (192.168.1.50), but serves the same page very, very, slowly when accessed from the  WAN/Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have port forwarding set-up on the modem router so that the Arduino web page  can be accessed from the outside world, and it does work, I can see the page from anywhere, but it's page serve rate is impractically slow. The page takes 30 - 45 seconds to load up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have the RaspPi with Apache set-up, also in the house, using the exact same port forwarding settings - with a different port - and it serves pages to the WAN/Internet very fast).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone any ideas what might be wrong ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you &lt;/p&gt;&#xA;" OwnerUserId="7360" LastActivityDate="2016-01-01T01:44:07.080" Title="arduino webserver serves single web page to WAN/Internet very very slowly" Tags="|web-server|lan|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8677" PostTypeId="1" CreationDate="2015-02-16T17:14:56.893" Score="1" ViewCount="1679" Body="&lt;p&gt;I am really new to Arduino so please bear with me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running an Arduino Uno with several sensors to capture some data related to a fish tank. Here is basically what it does:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Capture data (light, temperature, etc.)&lt;/li&gt;&#xA;&lt;li&gt;Display data on an LCD screen when a button is pressed&lt;/li&gt;&#xA;&lt;li&gt;Upload data to thingspeak every 5 minutes, using a ESP8266&lt;/li&gt;&#xA;&lt;li&gt;Feed the fish every 4 hours through a servo&lt;/li&gt;&#xA;&lt;li&gt;An RGB led blinks at various colors to let me see what's happening (e.g. red when connecting to wifi).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Everything is working reasonably well. That being said, my code is super messy and I am not sure I have the right approach. With the code I have:&#xA; - Nothing can be done while the Arduino uploads the wifi&#xA; - Nothing can be done when the fish are fed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not so much about the servo, it is more about the wifi problem. How would you suggest that I rewrite my code so that (1) I can run the wifi more than once every 5 minutes and (2) it does not block my sensors and LCD display while I am doing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the poor quality of the code. Newbie here.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;//Include LCD Libraries&#xA;    #include &amp;lt;Wire.h&amp;gt; &#xA;    #include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;    #include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;//Include Water Probe library&#xA;    #include &amp;lt;OneWire.h&amp;gt; &#xA;&#xA;//Include DHT11 Libraries&#xA;    #include &amp;lt;dht11.h&amp;gt;&#xA;&#xA;//Include Servo Libraries&#xA;    #include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;//Set Peripherals&#xA;    dht11 DHT11;&#xA;    LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display&#xA;    Servo myservo;  // create servo object to control a servo  &#xA;&#xA;//Pins for LCD are SDA=A4 and SCL=A5&#xA;&#xA;//Variables for sensors&#xA;    String sunlight;&#xA;    String watertemp;&#xA;    float airtemp;&#xA;    float airhumid;&#xA;    OneWire  ds(10); //water temperature, pin 10&#xA;&#xA;//Variables for LCD button&#xA;    #define BUTTON_PIN A3    // Set pin Buttons for Backlight LCD.&#xA;    unsigned int currentLcdLightOnTime = 0; // For calculating the lcd light on time.&#xA;    unsigned long lcdLightOn_StartMillis;&#xA;    boolean isLcdLightOn;&#xA;    int buttonState = 0;// For checking push-button state.&#xA;&#xA;// Variables for Status LED&#xA;    int ledState = LOW;             // ledState used to set the LED&#xA;    long previousMillis = 0; &#xA;    long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;&#xA;//Variables to display LCD Numbers&#xA;    char bufferhours[5]; //Output of the itoa function for hours&#xA;    char bufferminutes[5]; //Output of the itoa function for minutes&#xA;    // We don't care for seconds. It's irrelevant.&#xA;    int moisture;&#xA;&#xA;//Variables for Wifi Update&#xA;    //long DELAYWIFI = 10000; //For test purposes&#xA;    long DELAYWIFI = 300000; //Every 5 minutes&#xA;    long endtimewifi; &#xA;    long nowwifi;&#xA;&#xA;//Variables for Servo&#xA;    long FEEDINGDELAY = 14400000; // Feed every 4 hours&#xA;    //long FEEDINGDELAY = 30000; //For test purposes&#xA;    int pos = 0;    // variable to store the servo position &#xA;    long endtime; &#xA;    long now;&#xA;    long timeuntilfeeding;&#xA;&#xA;//Variables for Sunlight&#xA;    float percent; //transform number above into a percent  &#xA;&#xA;// Variables for Wifi Updates&#xA;&#xA;    #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;    //Hardware Serial&#xA;    #define _baudrate 9600&#xA;&#xA;    //Software Serial&#xA;    #define _rxpin      0&#xA;    #define _txpin      1&#xA;    SoftwareSerial esp8266( _rxpin, _txpin ); // RX, TX&#xA;&#xA;    //Thingspeak and Wifi Information&#xA;    #define SSID &quot;xxx&quot;&#xA;    #define PASS &quot;yyy&quot;&#xA;    #define IP &quot;zzz&quot; // ThingSpeak IP Address: 184.106.153.149&#xA;&#xA;    // GET /update?key=[THINGSPEAK_KEY]&amp;amp;field1=[data 1]&amp;amp;filed2=[data 2]...;&#xA;    String GET = &quot;GET /update?key=www&quot;;&#xA;&#xA;// Initiates special characters. http://omerk.github.io/lcdchargen/&#xA;&#xA;byte thermometer[8] = //icon for thermometer&#xA;{&#xA;    B00100,&#xA;    B01010,&#xA;    B01010,&#xA;    B01110,&#xA;    B01110,&#xA;    B11111,&#xA;    B11111,&#xA;    B01110&#xA;};&#xA;&#xA;byte droplet[8] = //icon for water droplet&#xA;{&#xA;    B00100,&#xA;    B00100,&#xA;    B01010,&#xA;    B01010,&#xA;    B10001,&#xA;    B10001,&#xA;    B10001,&#xA;    B01110,&#xA;};&#xA;&#xA;&#xA;byte degree[8] = { // degree centigrade&#xA;  B01000,&#xA;  B10100,&#xA;  B01000,&#xA;  B00011,&#xA;  B00100,&#xA;  B00100,&#xA;  B00011,&#xA;  B00000&#xA;};&#xA;&#xA;byte sun[8] = {&#xA;    0b00100,&#xA;    0b10001,&#xA;    0b01110,&#xA;    0b11111,&#xA;    0b11111,&#xA;    0b01110,&#xA;    0b10001,&#xA;    0b00100&#xA;};&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.init();// initialize the lcd &#xA;&#xA;//Initialize DHT/&#xA;    DHT11.attach(2);&#xA;&#xA;// set the digital pin as output for LED:&#xA;    pinMode(13, OUTPUT); &#xA;    pinMode(12, OUTPUT); &#xA;    pinMode(11, OUTPUT);&#xA;&#xA;//Connect to Wifi&#xA;    Serial.begin(9600);&#xA;    esp8266.begin(9600);&#xA;    boolean wifi_connected=false; //not connected yet...&#xA;&#xA;    sendesp8266(&quot;AT&quot;);&#xA;    delay(2000);&#xA;    for(int i=0;i&amp;lt;5;i++) //attempt 5 times to connect to wifi - this is a good idea&#xA;    {&#xA;    if(connectWiFi()) //are we connected?&#xA;    {&#xA;    wifi_connected = true; //yes&#xA;    break; //get outta here!&#xA;    }&#xA;    }&#xA;&#xA;//Initiate characters&#xA;    lcd.createChar(0, thermometer);&#xA;    lcd.createChar(1, droplet);&#xA;    lcd.createChar(2, degree);&#xA;    lcd.createChar(3, sun);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;    now = millis();&#xA;    endtime = now + FEEDINGDELAY;&#xA;&#xA;    while(now &amp;lt; endtime) {   // While loop for the feeding&#xA;    timeuntilfeeding = endtime - millis();&#xA;    now = millis();&#xA;&#xA;    nowwifi = millis();&#xA;    endtimewifi = nowwifi + DELAYWIFI;&#xA;&#xA;    while(nowwifi &amp;lt; endtimewifi) {   // While loop for wifi update&#xA;    nowwifi = millis();&#xA;&#xA;//We capture sensors&#xA;&#xA;    //Sunlight&#xA;    float value_sunlight = analogRead(A2);&#xA;    percent = value_sunlight / 1024.0 * 100;  //Convert dryness score into moisture percentage&#xA;    String sunlight =String(percent);// turn integer to string&#xA;&#xA;    //Water Temperature&#xA;    float value_watertemp = getTemp();&#xA;    String watertemp= String(value_watertemp);// turn integer to string&#xA;&#xA;    //Air Temperature and Humidity&#xA;    int chk = DHT11.read(); //Read DHT11 Sensor&#xA;    float airtemp=float(DHT11.temperature);// turn integer to string    &#xA;    float airhumid=float(DHT11.humidity);// turn integer to string  &#xA;&#xA;    // LED Blinking&#xA;    unsigned long currentMillis = millis();&#xA;    if(currentLcdLightOnTime == 0){ //We only blink when LCD is not on&#xA;    if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(11, ledState);&#xA;    }}&#xA;&#xA;  buttonState = digitalRead(BUTTON_PIN);// Check the state of the push-button.&#xA;&#xA;  if (buttonState == HIGH){// Button pressed.&#xA;&#xA;      digitalWrite(11, LOW);&#xA;&#xA;    lcdLightOn_StartMillis = millis();&#xA;    currentLcdLightOnTime = 0;&#xA;    isLcdLightOn = true;&#xA;    lcd.setBacklight(1); // switch on the backlight&#xA;&#xA;    //Screen 0 Presentation&#xA;&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot; Aquaponics Bot &quot;);&#xA;&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;  Version 1.0      &quot;);&#xA;  }&#xA;&#xA;  else{&#xA;    // Button not pressed.&#xA;&#xA;    //Serial.println(&quot;Button not pressed - LOW&quot;);&#xA;&#xA;    if(isLcdLightOn){&#xA;      currentLcdLightOnTime = millis() - lcdLightOn_StartMillis;&#xA;&#xA;        //Screen 2&#xA;        if(currentLcdLightOnTime &amp;gt; 3000 &amp;amp;&amp;amp; currentLcdLightOnTime &amp;lt;= 6000){&#xA;&#xA;    //Screen 2 - Air Temperature &amp;amp; Humidity&#xA;&#xA;    //Line 1&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;  Air Sensors  &quot;);&#xA;&#xA;    //Line 2&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.write(0);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.println(airtemp);&#xA;    lcd.setCursor(5, 1);&#xA;    lcd.write(2);&#xA;&#xA;    lcd.print(&quot; - &quot;);&#xA;    lcd.write(1);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.print(airhumid);&#xA;    lcd.setCursor(14, 1);&#xA;    lcd.print(&quot;%   &quot;);&#xA;&#xA;&#xA;&#xA;        }  &#xA;&#xA;        //Screen 3&#xA;        if(currentLcdLightOnTime &amp;gt; 6000 &amp;amp;&amp;amp; currentLcdLightOnTime &amp;lt; 9000){&#xA;&#xA;     //Screen 3 - Water Data&#xA;&#xA;    //Line 1&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot; Water Sensors &quot;);&#xA;&#xA;    //Line 2&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.write(0);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.println(watertemp);&#xA;    lcd.setCursor(5, 1);&#xA;    lcd.write(2);&#xA;&#xA;    lcd.print(&quot; -  soon   &quot;);&#xA;&#xA;   }   &#xA;&#xA;    //Screen 4&#xA;&#xA;        if(currentLcdLightOnTime &amp;gt; 9000 &amp;amp;&amp;amp; currentLcdLightOnTime &amp;lt; 12000){ &#xA;&#xA;   //Screen 4 - Light Sensors&#xA;&#xA;    //Line 1&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot; Light Sensors  &quot;);&#xA;&#xA;    //Line 2&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.write(3);&#xA;    lcd.print(&quot;: &quot;);&#xA;    lcd.println(sunlight);&#xA;    lcd.setCursor(5, 1);&#xA;    lcd.print(&quot;% - soon   &quot;);&#xA;&#xA;&#xA;      }  &#xA;&#xA;            if(currentLcdLightOnTime &amp;gt; 12000 &amp;amp;&amp;amp; currentLcdLightOnTime &amp;lt; 15000){&#xA;&#xA;     //Screen 5 - Next Feeding&#xA;&#xA;                long hours=0;&#xA;                long mins=0;&#xA;                long secs=0;&#xA;&#xA;                secs = timeuntilfeeding/1000; //convect milliseconds to seconds&#xA;                mins=secs/60; //convert seconds to minutes&#xA;                hours=mins/60; //convert minutes to hours&#xA;                secs=secs-(mins*60); //subtract the coverted seconds to minutes in order to display 59 secs max &#xA;                mins=mins-(hours*60); //subtract the coverted minutes to hours in order to display 59 minutes max&#xA;                //Display results&#xA;                itoa(hours, bufferhours, 10);//Convert the number of hours into readable by LCD&#xA;                itoa(mins, bufferminutes, 10);//Convert the number of minutes into readable by LCD&#xA;                lcd.setCursor(0, 0);&#xA;                lcd.print(&quot;Fish Feeding: &quot;);&#xA;                lcd.setCursor(0, 1);&#xA;                lcd.print(bufferhours);&#xA;                lcd.print(&quot; hours &quot;);&#xA;                lcd.print(bufferminutes);&#xA;                lcd.print(&quot; min.   &quot;);&#xA;&#xA;&#xA;   }       &#xA;&#xA;&#xA;        // Turn Off the Screen      &#xA;      if(currentLcdLightOnTime &amp;gt; 15000){&#xA;        lcd.clear();&#xA;        isLcdLightOn = false;&#xA;        lcd.setBacklight(0); // switch off the backlight&#xA;&#xA;        currentLcdLightOnTime = 0; //So that the blinking can start again.&#xA;        ledState = LOW; &#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;    } // End of the while wifi loop&#xA;&#xA;    // Make sure we are still connected to the internet&#xA;&#xA;    esp8266.begin(9600);&#xA;    boolean wifi_connected=false; //not connected yet...&#xA;&#xA;    sendesp8266(&quot;AT&quot;);&#xA;    delay(2000);&#xA;    for(int i=0;i&amp;lt;5;i++) //attempt 5 times to connect to wifi - this is a good idea&#xA;    {&#xA;    if(connectWiFi()) //are we connected?&#xA;    {&#xA;    wifi_connected = true; //yes&#xA;    break; //get outta here!&#xA;    }&#xA;    }&#xA;&#xA;    digitalWrite(13, HIGH);&#xA;&#xA;    //We capture sensors again to send the value&#xA;&#xA;    //Sunlight&#xA;    float value_sunlight = analogRead(A2);&#xA;    percent = value_sunlight / 1024.0 * 100;  //Convert dryness score into moisture percentage&#xA;    String sunlight =String(percent);// turn integer to string&#xA;&#xA;    //Water Temperature&#xA;    float value_watertemp = getTemp();&#xA;    String watertemp= String(value_watertemp);// turn integer to string&#xA;&#xA;    //Air Temperature and Humidity&#xA;    int chk = DHT11.read(); //Read DHT11 Sensor&#xA;    String airtemp=String(DHT11.temperature);// turn integer to string  &#xA;    String airhumid=String(DHT11.humidity);// turn integer to string    &#xA;&#xA;    updateTS(sunlight,watertemp, airtemp, airhumid);&#xA;    delay(3000); //&#xA;    digitalWrite(13, LOW);&#xA;&#xA;&#xA;  } // End of the while feeding loop&#xA;&#xA;  // Double Swipe to Feed the Fish&#xA;&#xA;&#xA;    //Intialize Servo&#xA;    myservo.attach(3);  // attaches the servo on pin 3 to the servo object  &#xA;    //Display that the fish is being fed.&#xA;    digitalWrite(13, HIGH);&#xA;&#xA;    for(pos = 0; pos &amp;lt; 180; pos += 5)  // goes from 0 degrees to 180 degrees &#xA;      {                                  // in steps of 1 degree &#xA;        myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;        delay(15);                       // waits 15ms for the servo to reach the position &#xA;       } &#xA;&#xA;    for(pos = 180; pos&amp;gt;=0; pos-=5)     // goes from 180 degrees to 0 degrees &#xA;       {                                &#xA;         myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;         delay(15);                       // waits 15ms for the servo to reach the position &#xA;       } &#xA;&#xA;    myservo.detach();  // detattaches the servo from pin 3&#xA;    //Clears display&#xA;    digitalWrite(13, LOW);&#xA;&#xA;    // SEND AN EMAIL OR UPDATE A DATABASE..&#xA;&#xA;    }&#xA;&#xA;&#xA;    //----- update the  Thingspeak string with 4 values&#xA;    void updateTS( String L, String W , String T, String H)&#xA;    {&#xA;    // ESP8266 Client&#xA;    String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;// Setup TCP connection&#xA;    cmd += IP;&#xA;     cmd += &quot;\&quot;,80&quot;;&#xA;    sendesp8266(cmd);&#xA;      delay(2000);&#xA;    if( Serial.find( &quot;Error&quot; ) )&#xA;    {&#xA;      esp8266.print( &quot;RECEIVED: Error\nExit1&quot; );&#xA;    return;&#xA;    }&#xA;&#xA;     cmd = GET + &quot;&amp;amp;field1=&quot; + L +&quot;&amp;amp;field2=&quot;+ W + &quot;&amp;amp;field3=&quot; + T + &quot;&amp;amp;field4=&quot; + H +&quot;\r\n&quot;;&#xA;     Serial.print( &quot;AT+CIPSEND=&quot; );&#xA;     Serial.println( cmd.length() );&#xA;     if(Serial.find( &quot;&amp;gt;&quot; ) )&#xA;     {&#xA;     esp8266.print(&quot;&amp;gt;&quot;);&#xA;     esp8266.print(cmd);&#xA;     Serial.print(cmd);&#xA;     }&#xA;     else&#xA;     {&#xA;     sendesp8266( &quot;AT+CIPCLOSE&quot; );//close TCP connection&#xA;     }&#xA;     if( Serial.find(&quot;OK&quot;) )&#xA;     {&#xA;     esp8266.println( &quot;RECEIVED: OK&quot; );&#xA;    }&#xA;    else&#xA;    {&#xA;    esp8266.println( &quot;RECEIVED: Error\nExit2&quot; );&#xA;     }&#xA;     }&#xA;&#xA;    void sendesp8266(String cmd) //Send info to esp8266&#xA;     {&#xA;    esp8266.print(&quot;SEND: &quot;);&#xA;     esp8266.println(cmd);&#xA;     Serial.println(cmd);&#xA;     }&#xA;&#xA;     boolean connectWiFi()&#xA;      {&#xA;     digitalWrite(11, LOW);&#xA;     digitalWrite(12, HIGH);&#xA;     Serial.println(&quot;AT+CWMODE=1&quot;);//WiFi STA mode - if '3' it is both client and AP&#xA;     delay(5000);&#xA;     //Connect to Router with AT+CWJAP=&quot;SSID&quot;,&quot;Password&quot;;&#xA;     // Check if connected with AT+CWJAP?&#xA;     String cmd=&quot;AT+CWJAP=\&quot;&quot;; // Join accespoint&#xA;     cmd+=SSID;&#xA;     cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;     cmd+=PASS;&#xA;     cmd+=&quot;\&quot;&quot;;&#xA;     sendesp8266(cmd);&#xA;     delay(15000);&#xA;&#xA;     digitalWrite(12, LOW);&#xA;&#xA;     if(Serial.find(&quot;OK&quot;))&#xA;     {&#xA;      esp8266.println(&quot;RECEIVED: OK&quot;);&#xA;      return true;&#xA;     }&#xA;     else&#xA;     {&#xA;       esp8266.println(&quot;RECEIVED: Error&quot;);&#xA;       return false;&#xA;     }&#xA;&#xA;     cmd = &quot;AT+CIPMUX=0&quot;;// Set Single connection&#xA;     sendesp8266( cmd );&#xA;     if( Serial.find( &quot;Error&quot;) )&#xA;     {&#xA;     esp8266.print( &quot;RECEIVED: Error&quot; );&#xA;      return false;&#xA;     }&#xA;   }&#xA;&#xA;   float getTemp(){ //Get the water temperature&#xA;    //returns the temperature from one DS18S20 in DEG Celsius&#xA;&#xA;    byte data[12];&#xA;    byte addr[8];&#xA;&#xA;     if ( !ds.search(addr)) {&#xA;      //no more sensors on chain, reset search&#xA;      ds.reset_search();&#xA;      return -1000;&#xA;     }&#xA;&#xA;    if ( OneWire::crc8( addr, 7) != addr[7]) {&#xA;     Serial.println(&quot;CRC is not valid!&quot;);&#xA;     return -1000;&#xA;    }&#xA;&#xA;    if ( addr[0] != 0x10 &amp;amp;&amp;amp; addr[0] != 0x28) {&#xA;     Serial.print(&quot;Device is not recognized&quot;);&#xA;      return -1000;&#xA;    }&#xA;&#xA;    ds.reset();&#xA;    ds.select(addr);&#xA;    ds.write(0x44,1); // start conversion, with parasite power on at the end&#xA;&#xA;     byte present = ds.reset();&#xA;    ds.select(addr);  &#xA;    ds.write(0xBE); // Read Scratchpad&#xA;&#xA;&#xA;    for (int i = 0; i &amp;lt; 9; i++) { // we need 9 bytes&#xA;     data[i] = ds.read();&#xA;    }&#xA;&#xA;    ds.reset_search();&#xA;&#xA;    byte MSB = data[1];&#xA;    byte LSB = data[0];&#xA;&#xA;    float tempRead = ((MSB &amp;lt;&amp;lt; 8) | LSB); //using two's compliment&#xA;    float TemperatureSum = tempRead / 16;&#xA;&#xA;    return TemperatureSum;&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7367" LastEditorUserId="37523" LastEditDate="2019-08-23T09:13:16.457" LastActivityDate="2021-05-14T16:04:40.350" Title="Wifi Data Logger without Delay" Tags="|arduino-uno|esp8266|sensors|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="8678" PostTypeId="1" AcceptedAnswerId="8685" CreationDate="2015-02-16T17:32:34.990" Score="0" ViewCount="690" Body="&lt;p&gt;I am making a project that requires bluetooth communication between a Raspberry Pi(equipped with a bluetooth dongle) and a standalone atmega168 circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to transfer information serially between the two devices over bluetooth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have selected the hc-06 for the arduino and some usb bluetooth dongle for the PI. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if connecting the hc-06's TX and RX pins to the RX and TX (respectively) pins of my atmega will work or not. If not, I would like to know how to achieve that (bluetooth on a standalone arduino-powered microcontroller)&lt;/p&gt;&#xA;" OwnerUserId="7370" LastActivityDate="2015-02-16T20:55:07.760" Title="Bluetooth hc-06 and Standalone Atmega168(possible?)" Tags="|arduino-uno|serial|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8679" PostTypeId="1" AcceptedAnswerId="8693" CreationDate="2015-02-16T18:19:01.043" Score="0" ViewCount="156" Body="&lt;p&gt;I have the following line of code in my Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static double *temps = new double[arraySize];  //Declare array to hold tempratures, place the array on the heap where it will not be deleted and keep the pointer as a static&#xA;//double temps[arraySize];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I compile with the Arduino IDE on Ubuntu it compiles just fine. However, when I compile on the Raspberry Pi, it throws up the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xxx.cpp.o: In function `last Function in file()':&#xA;xxx.cpp:[last line in file]: undefined referance to `operator new[] (unsigned int)'&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a bug? If so, how do I report it? If not, why is it throwing this error or how else can I declare a static array of doubles (needs to be static, I calculate an average of some incoming data over several function calls)?&lt;/p&gt;&#xA;" OwnerUserId="4911" LastEditorUserId="84" LastEditDate="2015-02-18T18:31:14.730" LastActivityDate="2015-02-19T04:01:09.417" Title="Compile problem when using keyword 'new' on Raspberry Pi" Tags="|c++|linux|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8680" PostTypeId="2" ParentId="8671" CreationDate="2015-02-16T19:21:30.647" Score="3" Body="&lt;p&gt;You can use a timer/counter to output a square wave signal of your choosing without processor intervention or use of interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In data sheet&lt;br&gt;&#xA;&lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;&quot;ATmega48A/PA/88A/PA/168A/PA/328/P&quot;Atmel-8271I-AVR- ATmega-Datasheet_10/2014&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;page 142  it says&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The double buffered Output Compare Register (OCR2A and OCR2B) are compared with the Timer/Counter value at all times. &lt;strong&gt;The result of the compare can be used by the Waveform Generator to generate a&lt;/strong&gt; PWM or &lt;strong&gt;variable frequency output on the Output Compare pins (OC2A and OC2B).&lt;/strong&gt; See ”Output Compare Unit” on page 143 for details. The compare match event will also set the Compare Flag (OCF2A or OCF2B) which &lt;strong&gt;can&lt;/strong&gt; be used to generate an Output Compare interrupt request.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The interrupt CAN be generated and used but is optional.&lt;br&gt;&#xA;It looks like relevant material extends as far as page 159. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-16T19:21:30.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8681" PostTypeId="1" AcceptedAnswerId="8684" CreationDate="2015-02-16T19:51:56.820" Score="2" ViewCount="498" Body="&lt;p&gt;Going through the &quot;timeouts&quot; example of the elapsedMillis library (&lt;a href=&quot;https://github.com/pfeerick/elapsedMillis&quot; rel=&quot;nofollow&quot;&gt;https://github.com/pfeerick/elapsedMillis&lt;/a&gt;) I found the following statement:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;digitalWrite(LEDPIN, flashPattern[ledIndex++] ? ledBrightness : !ledBrightness);&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;flashpattern is an array of boolean variables  (boolean flashPattern[] = { 1,1,1,1,1,1,1,0,1,1,0 };)&lt;/li&gt;&#xA;&lt;li&gt;ledBrightness is a boolean as well. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What does the &quot;?&quot; and the &quot;:&quot; do there? are these boolean operators? &lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-02-16T20:41:42.607" Title="What do these operators do?" Tags="|programming|sketch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8682" PostTypeId="2" ParentId="8681" CreationDate="2015-02-16T19:56:42.807" Score="5" Body="&lt;p&gt;They are the &lt;a href=&quot;http://en.wikipedia.org/wiki/%3F:&quot;&gt;conditional operator&lt;/a&gt;. If the expression before the &lt;code&gt;?&lt;/code&gt; is true then the result is the expression before the &lt;code&gt;:&lt;/code&gt;, otherwise it is the expression after.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-16T19:56:42.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8683" PostTypeId="2" ParentId="8630" CreationDate="2015-02-16T20:24:26.443" Score="1" Body="&lt;p&gt;Why do you want to use the USB port on the Pi? Isn't it easier to connect the Arduino directly to the UART pins (Pins 8 and 10) on the PI and then read out the UART in your python programme? &lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-02-16T20:24:26.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8684" PostTypeId="2" ParentId="8681" CreationDate="2015-02-16T20:41:42.607" Score="-1" Body="&lt;pre&gt;&lt;code&gt;A ? B : C;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is shorthand for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(A) {&#xA;    B;&#xA;} else {&#xA;    C;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7255" LastActivityDate="2015-02-16T20:41:42.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8685" PostTypeId="2" ParentId="8678" CreationDate="2015-02-16T20:55:07.760" Score="1" Body="&lt;p&gt;The HC-0x Bluetooth transceivers are a drop-in replacement for a serial connection. Once the transceiver is configured (with baud-rate, device name, and pairing PIN #) you can plug it in in place of a serial line and expect to communicate. The device will take care of pairing and accepting a connection from the master device with no need for any code support from the AVR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a separate program on an Arduino or a breadboarded AVR to configure my HC-06es. They retain their configuration across a power-down, and in fact, there is no hardware support for resetting them to a standard configuration; you need a program that figures out their current baud-rate in order to reconfigure them. It can save a bunch of hassle if you write down their configurations whenever you change them.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-02-16T20:55:07.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8686" PostTypeId="1" CreationDate="2015-02-16T22:44:28.433" Score="1" ViewCount="5714" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kjlvF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to understand and adapt this tutorial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips/current-draw&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/rgb-led-strips/current-draw&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to my own use. I am doing essentially the same thing, except I have this &lt;a href=&quot;https://www.adafruit.com/products/887&quot; rel=&quot;nofollow noreferrer&quot;&gt;single color LED strip&lt;/a&gt;, and I don't fully understand how to power both the arduino and the led strip from the same power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to wire it using the diagram above, and something started smoking (I think the IR transmitter). I don't know much about circuits, but I'm pretty sure that's not good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this diagram, the 9v represents DC power, the IR sensor on the left represents the transmitter, the IR on the right is the receiver, and the white LED is the LED strip, with two outputs (+ - )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the fritzing diagram for that tutorial, they have the + from the LED strip going straight in to Vin on the uno, but they don't show how either the LED strip or the uno themselves are being powered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need two power sources?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need a mosfet considering I'm only using a one color LED strip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got the IR sensors working, so I don't need help with that, and I can connect one of these &lt;a href=&quot;https://www.adafruit.com/products/352&quot; rel=&quot;nofollow noreferrer&quot;&gt;12V switching power supplies&lt;/a&gt; to one of these &lt;a href=&quot;https://www.adafruit.com/products/368&quot; rel=&quot;nofollow noreferrer&quot;&gt;DC power screw terminals&lt;/a&gt; to power the lights without any arduino control, so all I'm missing is how to turn the lights on and off with arduino, IE, how to go from the power supply to the arduino to the LED strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't need to PWM the LED strip - just shut it off and on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone can help me correct the fritzing diagram or explain what I'm doing wrong / what I should be doing instead, I'd greatly appreciate it.&lt;/p&gt;&#xA;" OwnerUserId="6341" LastEditorUserId="6341" LastEditDate="2015-02-17T00:17:00.007" LastActivityDate="2020-01-07T14:39:41.077" Title="How to power both arduino and 1 color led strip from single power source" Tags="|arduino-uno|led|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8687" PostTypeId="2" ParentId="8686" CreationDate="2015-02-17T00:29:55.610" Score="2" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KcJSH.png&quot; alt=&quot;enter image description here&quot;&gt;Note that VIN pin and the 2.5mm DC Jack are connected. So in the tutorial one of these is getting power from a +12Vdc source and the other is supplying +12V to the +12v labeled pin on the LED string. Where the R G and B pins of the strip should be connected to Collectors of NPN's. Each of the NPN's bases are driven by Arduino Output pin and all the Emitters are connected to Ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So +12V supplies the DC Jack (aka Vin) the Arduino's local regulator converts that to Ground. The +12V via Vin supplies the LED's. And the Digital Outputs drive the base's of the NPN's. Which in turn act like a relay closing the perspective LED's to Ground, so they can illuminate. Where a Digital ONE or HIGH or TRUE on the BASE results in 5V above ground, which causes it to have low resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/y5hCW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2015-02-17T00:45:14.577" LastActivityDate="2015-02-17T00:45:14.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8688" PostTypeId="2" ParentId="8673" CreationDate="2015-02-17T02:41:47.460" Score="1" Body="&lt;p&gt;Never mind; this was me making a mess of the bit masking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/tomkcook/arduino-libraries&quot; rel=&quot;nofollow&quot;&gt;this github repository&lt;/a&gt; for working code with Arduino Mega.&lt;/p&gt;&#xA;" OwnerUserId="7358" LastActivityDate="2015-02-17T02:41:47.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8689" PostTypeId="2" ParentId="8630" CreationDate="2015-02-17T03:55:20.670" Score="2" Body="&lt;p&gt;You will need PySerial to accomplish this. A tutorial on interfacing Arduino and the RPi using a usb can be found &lt;a href=&quot;http://blog.oscarliang.net/connect-raspberry-pi-and-arduino-usb-cable/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7193" LastActivityDate="2015-02-17T03:55:20.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8690" PostTypeId="1" CreationDate="2015-02-17T07:10:42.910" Score="2" ViewCount="269" Body="&lt;p&gt;I have an Arduino Megs 2560 board and using Serial 2 for communication with SIM9000A GSM Modem. I send over a HTTP get request by using appropriate AT command strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GSM modem TX/RX pins are crossed with Arduino's Serial 2 port while the GSM modem card which also has DB9 pins is connected to a Hyper terminal - to see what it is receiving / rendering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is when I have to read after I get a response for my HTTP Get request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Read(String message)&#xA;{&#xA;      char temp = '\0';&#xA;      int i=0;&#xA;      numbytes = 0; &#xA;      message= &quot;&quot;;&#xA;      int endCnt = 0;&#xA;      debug_println(&quot;Reading Data!&quot;);&#xA;      Serial2.println(&quot;AT+HTTPREAD&quot;);&#xA;      delay(200);&#xA;      while(endCnt &amp;lt; 4) { &#xA;      while((Serial2.available())&amp;gt;0) {&#xA;          temp = Serial2.read();&#xA;          Serial.print(temp);&#xA;          switch(temp) {&#xA;            case '\r' : endCnt = 1; break;&#xA;            case '\n' : if(endCnt == 1) endCnt = 2; else endCnt = 0; break; &#xA;            case 'O'  : if(endCnt == 2) endCnt = 3; else endCnt = 0; break;&#xA;            case 'K'  : if(endCnt == 3) endCnt = 4; else endCnt = 0; break;&#xA;            default   : endCnt = 0; break;&#xA;          }&#xA;          if(endCnt == 4) break;&#xA;&#xA;        }&#xA;     }&#xA;     debug_println(&quot;Read Data Ret: &quot;);&#xA;     return i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the Terminal shows me correctly when a HTTPREAD command is passed to GSM modem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+HTTPACTION: 0,200,286&#xA;&#xA;&#xA;&#xA;+HTTPREAD: 286&#xA;&#xA;{&quot;first_name&quot;:&quot;dddddddddddddd&quot;,&quot;last_name&quot;:&quot;dddddddddddddddd&quot;,&quot;start_date&quot;:&quot;2000-12-31&quot;,&quot;chargeamt&quot;:&quot;09.80&quot;,&quot;status&quot;:&quot;ok&quot;,&quot;id&quot;:&quot;68&quot;}&#xA;&#xA;&amp;lt;!-- Hosting24 Analytics Code --&amp;gt;&#xA;&#xA;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://stats.hosting24.com/count.php&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&#xA;&amp;lt;!-- End Of Analytics Code --&amp;gt;&#xA;&#xA;&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But Serial port printing shows me :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Reading Data!&#xA;&#xA;+HTTPREAD: 286&#xA;{&quot;first_name&quot;:&quot;dddddddddddddd&quot;,&quot;last_name&quot;:&quot;ds Code --&amp;gt;&#xA;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://stats.hosting24.com/count.php&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&amp;lt;!-- End Of Analytics Code --&amp;gt;&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after reading 45-46 th character at Serial2 port I am loosing data. I have tried all ways but unable to understand why my data at serial port is lost / overwritten?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know how can I resolve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;====UPDATE====&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After struggling a lot I was able to resolve the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code &lt;strong&gt;&quot;delay(200);&quot;&lt;/strong&gt; after Serial2.println(&quot;AT+HTTPREAD&quot;); was causing the issue. When I reduced the time I got the response as required.&lt;/p&gt;&#xA;" OwnerUserId="4655" LastEditorUserId="4655" LastEditDate="2015-02-17T09:49:45.813" LastActivityDate="2015-02-17T09:49:45.813" Title="Data Loss over Serial Communication thru GSM SIM9000A Modem" Tags="|serial|arduino-mega|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8691" PostTypeId="2" ParentId="815" CreationDate="2015-02-17T14:48:07.003" Score="4" Body="&lt;p&gt;An obvious answer has been omitted which is: transformerless power supply.&#xA;If your average power requirements are low (&amp;lt;10mA) then this is the most compact way to achieve the desired voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an in-depth study see: &lt;a href=&quot;http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf&quot; rel=&quot;nofollow&quot;&gt;http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution: jeelabs.org /2011/11/27/ultra-low-power-supply/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some limitations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;safety - NONE&lt;/strong&gt; - your circuit might now be floating at line voltage&lt;/li&gt;&#xA;&lt;li&gt;heat dissipation - calculate here: www. daycounter.com/Circuits/Transformerless-Power-Supplies/Transformerless-Power-Supplies.phtml&lt;/li&gt;&#xA;&lt;li&gt;low current - no servos or relays&lt;/li&gt;&#xA;&lt;li&gt;voltage fluctuations on the line might affect the circuit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7382" LastActivityDate="2015-02-17T14:48:07.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8692" PostTypeId="1" CreationDate="2015-02-17T14:59:16.567" Score="2" ViewCount="898" Body="&lt;p&gt;I am building my first 4wd vehicle with Adafruit motor shield with one Ultrasonic sensor and one small servo to move sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am facing some problems. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Bought 4 motors (2 GM9 and 2 GM3), found the difference when start running and GM9 were running double the speed of GM3. Tried to slow down th eGM9 with speed in code but now one of the motor stop many times while other run.&lt;/li&gt;&#xA;&lt;li&gt;Running spearate power for Arduino (now USB) and 9v batteries for motorshield. Should I remove the jumper on motor shield as found that after removing 9v battery, its getting some volts from Arduino and motors running very slowly.&lt;/li&gt;&#xA;&lt;li&gt;Servo motor is not running at all. While its pins are according to the circuit.&lt;/li&gt;&#xA;&lt;li&gt;Should 9v batteries will be OK to run 4 GM9/GM3 motors + 1 small Servo? if not please recommend any other.&lt;/li&gt;&#xA;&lt;li&gt;When running I feel small smell from boards, nothing is hot, is it a problem?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Too many questions but tried to put in one place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2015-02-17T14:59:16.567" Title="Motor Shield with 4 DC motors + small servo, which battery is suitable?" Tags="|motor|servo|battery|arduino-motor-shield|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8693" PostTypeId="2" ParentId="8679" CreationDate="2015-02-17T17:10:49.110" Score="3" Body="&lt;p&gt;The Arduino uses &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;AVR libc&lt;/a&gt; which does not provide a complete C++ environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among other things AVR libc does not support &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt;. See the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus&quot; rel=&quot;nofollow&quot;&gt;FAQ&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some versions of the Arduino libraries may provide new and delete but they are just wrappers around &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt;. I suggest not using new and delete on arduino because they do not have the same behavior as C++. For example destructors will not be called on the arduino when delete is called.&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="337" LastEditDate="2015-02-17T17:17:18.910" LastActivityDate="2015-02-17T17:17:18.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8694" PostTypeId="2" ParentId="815" CreationDate="2015-02-17T18:43:27.963" Score="4" Body="&lt;p&gt;wanted to do a similar thing and I found and just ordered these:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://uk.farnell.com/recom-power/rac03-05scr-277/conv-ac-dc-3w-90-305v-in-5v-out/dp/2289701&quot; rel=&quot;nofollow&quot;&gt;http://uk.farnell.com/recom-power/rac03-05scr-277/conv-ac-dc-3w-90-305v-in-5v-out/dp/2289701&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fully sealed power supply, disk-shaped, 5cm diameter and 11mm thick. THey are available in 3.3V, 5V, and 12V. They are designed to be put inside walls or behind switches. &lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-02-17T18:43:27.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8695" PostTypeId="2" ParentId="8626" CreationDate="2015-02-17T19:29:38.170" Score="2" Body="&lt;p&gt;I'd like to second the other posts - if you are familiar with Arduino, going to a stand-alone chip is very easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You miss out on the following things: programming via USB, 7-12volts through the power jack, and/or power through USB, reset button, led on pin 13, and the clock. Depending on where you get your Atmel chip, you may also need to set the fuses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is exactly the same, even if you go down to a smaller chip (or larger - whatever suits your project best!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming: I use a FreeTronics ICSP (ISP) to program the chips, and have the 6-pin ICSP header on all my projects for easy reprogramming. This particular programmer has a &quot;slow clock&quot; jumper, because when you get the chip from the Atmel factory, their internal clock runs at 1mhz, too slow to program with the Arduino IDE default settings. You can leave it at 1mhz, if your project doesn't need any more, or change the fuses. You will need an ICSP to set the fuses (see further down). By using an ISP rather than usb, you also save a little memory - you don't need a bootloader (which is pre-programmed on Arduinos, but not when you buy the chips from the factory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to sort out your own power - this depends on what you need, and what you have. You can use a 5-volt AC-DC power supply (&quot;Wall wart&quot;) and plug it into mains. Or, you can power it off USB - if you only use USB for power, you can solder the socket directly on your board. You can use a regulator (which is what the Arduino uses for the 7-12v power socket), or, if running it off a 12v power supply, it might be easier/cheaper to buy a car phone charger from the dollar store, and a lot of the work will be done for you. Also, the power supply doesn't have to be 5v - depending on your application, you might run it from 5.5v to as little as 1.8v, depending on your clock speed. Find the data sheet for the chip you use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A reset button is very easy to add, if you need it - all it takes is a resistor and a pushbutton. Weather you need it or not, depends on your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same applies to the led on pin 13 - it depends on your project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the clock. The Arduino has a 16mhz quartz clock. You can do the same, it only takes 3 components (you will have to set the fuses, see further down). You can use a clock up to 20mhz, giving you a 25% speed boost if you need it (you may need to change some settings, because timing functions like delay depend on the clock speed - your delays will be 25% shorter). Or, you can use the internal 8mhz clock (either at full speed, or as from factory, at 1/8 speed, so you get 1mhz). At 4mhz or less, you can run the Atmega at 1.8 volt, or 0.7 volt for the &quot;pico power&quot; chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I have mentioned, you may need to set the fuses to the correct value. The best idea is to go to &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;http://www.engbedded.com/fusecalc/&lt;/a&gt; to work out what fuse settings you want. Specific things to look for: the clock source (internal or external? what speed?), divide clock by 8 internally, and brown-out detection (Arduino chips turn themselves off when the power goes below 4.3v). Warning: setting wrong fuses may set your chip so it is very difficult to fix. You can set the fuses using an ISP; if the clock speed is very slow (I think &amp;lt; 4mhz? which it is when it comes from the factory), then you will have to &quot;slow program&quot; - some ISPs have a &quot;slow program&quot; jumper, but you can use an option to avrdude to do the same - I think it's -B e.g. -B10).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-17T19:29:38.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8696" PostTypeId="2" ParentId="8626" CreationDate="2015-02-17T21:34:07.510" Score="0" Body="&lt;p&gt;Arduino of course started as a prototyping platform. Build this first, get it working, then move to a circuit board of your own design with the same chip and go from there. However, as the cost of all the components and really the boards themselves drops, I frequently find my self thinking, why not just use the board. Obviously if you are going to market something, having a full arduino in there might be a bit much, but if its just for your own application, I don't see any reason why you wouldn't just buy boards and use them as necessary. &lt;/p&gt;&#xA;" OwnerUserId="7238" LastActivityDate="2015-02-17T21:34:07.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8697" PostTypeId="1" CreationDate="2015-02-17T22:00:15.587" Score="6" ViewCount="17898" Body="&lt;p&gt;I'm trying to add some additional example files to the Arduino IDE in Ubuntu 14.04. However, I can't for the life of me find where the examples are stored in my system. I checked the Arduino website, but can't find any information there. Does anyone know where I need to put my additional files?&lt;/p&gt;&#xA;" OwnerUserId="7388" LastEditorUserId="37622" LastEditDate="2022-04-24T09:37:21.763" LastActivityDate="2022-04-24T09:37:21.763" Title="Location of examples folder in Ubuntu" Tags="|arduino-ide|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="8698" PostTypeId="2" ParentId="8637" CreationDate="2015-02-17T22:01:14.620" Score="1" Body="&lt;p&gt;For starting out? I would say neither. The arduino IDE is based on a programming language called processing. Which you can look at. Honestly, if you have done any programming in the past you will be fine for the basics. The advanced stuff might make you look at working with c++ files. But there is nothinging overly complex there. A lot of the add-on hardware that you can purchase comes with existing arduino libraries. Use these as a baseline.&lt;/p&gt;&#xA;" OwnerUserId="7238" LastActivityDate="2015-02-17T22:01:14.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8699" PostTypeId="2" ParentId="8697" CreationDate="2015-02-17T22:20:24.567" Score="8" Body="&lt;p&gt;After some more searching I found it in /usr/share/arduino/examples.&lt;/p&gt;&#xA;" OwnerUserId="7388" LastActivityDate="2015-02-17T22:20:24.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8700" PostTypeId="1" CreationDate="2015-02-17T23:16:59.997" Score="0" ViewCount="897" Body="&lt;p&gt;I would like the sensor values to be updated each 10ms(100Hz) and then run the algorithm and repeat the same process. However, after timing the algorithm it is taking only 2ms, I think the data_ready interrupt is not working as expected. Physical hardware connection is from INT1 of ADXL345 to pin2 of the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have configured the accelerometer to have a data rate of 100Hz. I have set up an interrupt with data_ready to run the algorithm present in the loop each time a new sample comes that is each 10ms. However each sample is coming every 2ms which shows the interrupt is not working and I would like to know why. I have timed the interrupt with the millis(); function before and after calling the interrupt, also I have stored the samples in an array and printed it on the serial interface and the samples were repeated as it was updated every 2ms instead of 10ms. The algorithm I have developed needs the sampling rate to be 100Hz.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_ADXL345_U.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;&#xA;#define F_CPU 16000000UL&#xA;&#xA;&#xA;volatile int sensor_update=0;&#xA;&#xA;&#xA;//-----------------------------------------------------------------------------------     -----------&#xA;//Write to ADXL345 registers&#xA;void writeTo(int device, byte address, byte val) {&#xA;Wire.beginTransmission(device); //start transmission to device&#xA;Wire.write(address);        // send register address&#xA;Wire.write(val);        // send value to write&#xA;Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;&#xA;&#xA;//----------------------------------------------------------------------------------------------&#xA;&#xA;/////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;//ISR function&#xA;&#xA;void interrupt(void){&#xA;sensor_update=1;&#xA;&#xA;}&#xA;&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;&#xA;&#xA;void buzz(int targetPin, long frequency, long length) {&#xA;long delayValue = 1000000/frequency/2; // calculate the delay value between     transitions&#xA;//// 1 second's worth of microseconds, divided by the frequency, then split in half since&#xA;&#xA;  //// there are two phases to each cycle&#xA;  //// calculate the number of cycles for proper timing&#xA;  long numCycles = frequency * length/ 1000; &#xA;&#xA;  //// multiply frequency, which is really cycles per second, by &#xA;  //// the number of seconds to get the total number of cycles to produce&#xA;  for (long i=0; i &amp;lt; numCycles; i++){ // for the calculated length of time...&#xA;    digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram&#xA;    delayMicroseconds(delayValue); // wait for the calculated delay value&#xA;    digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram&#xA;    delayMicroseconds(delayValue); // wait againf or the calculated delay value&#xA;  }&#xA;}&#xA;&#xA;&#xA;/* Assign a unique ID to this sensor at the same time */&#xA;Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);&#xA;&#xA;void setup(void)&#xA;{&#xA;  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;  Serial.begin(9600);&#xA;  //Serial.println(&quot;Accelerometer Test&quot;); Serial.println(&quot;&quot;);&#xA;&#xA;  pinMode(4, OUTPUT);// buzzer output pin&#xA;&#xA;  /* Initialise the sensor */&#xA;  if(!accel.begin())&#xA;  {&#xA;    /* There was a problem detecting the ADXL345 ... check your connections */&#xA;    //Serial.println(&quot;Ooops, no ADXL345 detected ... Check your wiring!&quot;);&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Set the range to whatever is appropriate for your project */&#xA;  accel.setRange(ADXL345_RANGE_16_G);&#xA;  accel.setDataRate(ADXL345_DATARATE_100_HZ);&#xA;  // displaySetRange(ADXL345_RANGE_8_G);&#xA;  // displaySetRange(ADXL345_RANGE_4_G);&#xA;  // displaySetRange(ADXL345_RANGE_2_G);&#xA;&#xA;  //Create an interrupt that will trigger when a tap is detected.&#xA;  attachInterrupt(0, interrupt, RISING);&#xA;&#xA;  writeTo(0x1D, 0x2E, 0);&#xA;  writeTo(0x1D, 0x2F, 0);&#xA;  writeTo(0x1D, 0x2E, 128);&#xA;  writeTo(0x1D, 0x2F, 127);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;&#xA;&#xA;  if(sensor_update==1 ){&#xA;    //When sensor_update is set to 1 in the ISR,the algorithm process the data from the accelerometer being updated every 10ms(100Hz)&#xA;     sensor_update=0;//reset&#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7390" LastEditorUserId="42" LastEditDate="2015-04-18T09:29:35.863" LastActivityDate="2019-11-26T16:23:19.873" Title="ADXL345 Arduino UNO data_ready interrupt" Tags="|arduino-uno|interrupt|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8701" PostTypeId="2" ParentId="8674" CreationDate="2015-02-17T23:37:10.827" Score="1" Body="&lt;p&gt;I haven't used the ethernet library for a while, but I remember that it served up tiny packets - basically each write call went in its own TCP packet. It sounds like you may have latency issues across the WAN. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try using your Apache instance to proxy the Arduino pages. Details are at &lt;a href=&quot;http://httpd.apache.org/docs/current/mod/mod_proxy.html&quot; rel=&quot;nofollow&quot;&gt;http://httpd.apache.org/docs/current/mod/mod_proxy.html&lt;/a&gt; I have this running but all my pages are small so I'm not sure how it would behave on larger pages.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-02-17T23:37:10.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8702" PostTypeId="1" CreationDate="2015-02-17T23:40:55.170" Score="0" ViewCount="1835" Body="&lt;p&gt;I've written up this very simply code to control transistors in an inverter circuit. The editor is flagging up errors which I can't see myself. I'm pretty new to Arduino programming but it's very simple code and can't see why it's being shown as having errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first glance, what am I missing? I've pasted a section below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Phase1pos = 13;&#xA;int Phase2pos = 12;&#xA;int Phase3pos = 11;&#xA;int Phase1neg = 10;&#xA;int Phase2neg = 9;&#xA;int Phase3neg = 8;&#xA;&#xA;void setup() {&#xA;pinMode(Phase1pos, OUTPUT);&#xA;pinMode(Phase2pos, OUTPUT);&#xA;pinMode(Phase3pos, OUTPUT);&#xA;pinMode(Phase1neg, OUTPUT);&#xA;pinMode(Phase2neg, OUTPUT);&#xA;pinMode(Phase3neg, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(208);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    digitalWrite(16);&#xA;&#xA;    delayMicroseconds(28);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(180);&#xA;    delayMicroseconds(180);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(28);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(208);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(28);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(180);&#xA;    delayMicroseconds(180);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(28);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(208);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(28);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(180);&#xA;    delayMicroseconds(180);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(28);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(208);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(28);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(180);&#xA;    delayMicroseconds(180);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(28);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(208);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(104);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(159);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(47);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(80);&#xA;    digitalWrite(Phase2neg, LOW);&#xA;    delayMicroseconds(2);&#xA;&#xA;    delayMicroseconds(7);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(108);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(93);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(7);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3pos, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3pos, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(16);&#xA;&#xA;    delayMicroseconds(28);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(180);&#xA;    delayMicroseconds(180);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(28);&#xA;&#xA;    delayMicroseconds(16);&#xA;    digitalWrite(Phase2pos, HIGH);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase1neg, HIGH);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase3neg, HIGH);&#xA;    delayMicroseconds(54);&#xA;    digitalWrite(Phase3neg, LOW);&#xA;    delayMicroseconds(138);&#xA;    digitalWrite(Phase1neg, LOW);&#xA;    delayMicroseconds(27);&#xA;    digitalWrite(Phase2pos, LOW);&#xA;    delayMicroseconds(16);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7391" LastEditorUserId="1585" LastEditDate="2015-02-18T00:45:31.740" LastActivityDate="2015-02-18T00:45:31.740" Title="Can't figure out the error to this code" Tags="|programming|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8703" PostTypeId="2" ParentId="8702" CreationDate="2015-02-18T00:05:22.760" Score="5" Body="&lt;p&gt;Here's line 109:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; digitalWrite(16);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the error message says, there aren't enough arguments. It looks like you meant to call &lt;code&gt;delayMicroseconds()&lt;/code&gt; there instead of &lt;code&gt;digitalWrite()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-18T00:05:22.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8704" PostTypeId="1" AcceptedAnswerId="8705" CreationDate="2015-02-18T02:40:11.170" Score="2" ViewCount="4433" Body="&lt;p&gt;I just started using Arduino and so far I've used both &lt;code&gt;delay()&lt;/code&gt; and &lt;code&gt;delayMicroseconds()&lt;/code&gt;. I was wondering what the difference between these two is, because it seems to me that they're the same.&lt;/p&gt;&#xA;" OwnerUserId="7394" LastActivityDate="2015-02-18T02:42:06.303" Title="delay() vs delayMicroseconds()" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8705" PostTypeId="2" ParentId="8704" CreationDate="2015-02-18T02:42:06.303" Score="3" Body="&lt;p&gt;From &lt;a href=&quot;http://arduino.cc/en/reference/delay&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h1&gt;delay()&lt;/h1&gt;&#xA;  &#xA;  &lt;h2&gt;Description&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a second.) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So... milliseconds vs. microseconds.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-18T02:42:06.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8706" PostTypeId="1" AcceptedAnswerId="8749" CreationDate="2015-02-18T03:13:12.053" Score="0" ViewCount="636" Body="&lt;p&gt;I have an Arduino &lt;code&gt;DUE&lt;/code&gt; and just got a &lt;code&gt;Micro OLED&lt;/code&gt; display from SparkFun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using their library, when I try to compile I get the error below.  Other example code works just fine and I've programmed this thing a million times with my code.  So it's clearly in the SparkFun code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the SparkFun tutorial page with a description of the product:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/micro-oled-breakout-hookup-guide?_ga=1.19136059.2055231411.1404437767&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/micro-oled-breakout-hookup-guide?_ga=1.19136059.2055231411.1404437767&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the library I am using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the error I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;&#xA;/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::spiSetup()':&#xA;&#xA;/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:46:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment&#xA;    ssport  = portOutputRegister(digitalPinToPort(csPin));&#xA;            ^&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:48:51: error: 'portModeRegister' was not declared in this scope&#xA;    ssreg  = portModeRegister(digitalPinToPort(csPin));&#xA;                                                     ^&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::i2cSetup()':&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:84:2: error: 'TWBR' was not declared in this scope&#xA;    TWBR = ((F_CPU / I2C_FREQ) - 16) / 2;&#xA;    ^&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::parallelSetup()':&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:109:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment&#xA;    ssport  = portOutputRegister(digitalPinToPort(csPin));&#xA;            ^&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:111:51: error: 'portModeRegister' was not declared in this scope&#xA;    ssreg  = portModeRegister(digitalPinToPort(csPin));&#xA;                                                     ^&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:114:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment&#xA;    wrport  = portOutputRegister(digitalPinToPort(wrPin));&#xA;            ^&#xA;&#xA;/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:119:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment&#xA;    rdport  = portOutputRegister(digitalPinToPort(rdPin));&#xA;            ^&#xA;  Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2015-02-19T14:26:09.333" Title="Why doesn't the Micro OLED library compile on my DUE?" Tags="|arduino-due|library|compile|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8707" PostTypeId="2" ParentId="8637" CreationDate="2015-02-18T03:56:08.817" Score="1" Body="&lt;p&gt;@ConnorWolf Way too kind. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is based on Wiring, which is based on Processing, which is a kludge of Java, resembling C++ running on an embedded prototyping platform ill suited for learning programming by any Definition.  Many libraries half written and confusing, implementing only as much as the original author needed, not the entire spec (SPI being a great example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get a Pi for the same price, at least it is an end user computer for poor people. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, if you have something that can run the Ardunino IDE why are you learning to program on an Arduino? You need to be proficient in C or C++ before you attempt anything for real on an Arduino. Blinking lights is fine, beyond that, good luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Learn C or C++ (preferred as it is newer) on what you have, then start using the Arduino. Eclipse or Microsoft Visual Studio Community are both free and support both languages. (Both also support Arduino development when the time comes, avoid the Arduino IDE it is terrible). There are enough samples for either to keep you busy for a long time. Embedded programming REQUIRES understanding of low level hardware and IS NOT suitable for learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forget modern debugging. Paid engineers grumble when they have to do it and it cost a decent price for the enabling hardware. Stick to the old fashioned printf debugging style.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-02-18T04:04:29.850" LastActivityDate="2015-02-18T04:04:29.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8708" PostTypeId="1" CreationDate="2015-02-18T04:15:31.050" Score="1" ViewCount="9785" Body="&lt;p&gt;I'm new to the world of Arduino and I'm working on a wireless charging project that needs a 5.7MHz sine wave. I've tried using a Due and changing the PWM and DAC, but I can't get a clean sine wave at that frequency using anything I've found online. My signal is either way too low, or too high and horribly distorted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated. I have access to a Mega, Due, Uno, and Mini. &lt;/p&gt;&#xA;" OwnerUserId="7395" LastActivityDate="2017-01-11T13:07:38.917" Title="High Frequency Sine Wave Generation" Tags="|arduino-uno|arduino-mega|arduino-due|arduino-pro-mini|frequency|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8709" PostTypeId="2" ParentId="1836" CreationDate="2015-02-18T06:49:10.437" Score="1" Body="&lt;p&gt;If you have AREF pin pulled out onto the shield board not connected to anything, and you don't declare analogReference in your code (thus keeping it as the default internal 5V), it could still cause you to have the 1023 symptom you are describing. My suggestion: cut the AREF connecting pin, or put a constant 5v onto the AREF line. &lt;/p&gt;&#xA;" OwnerUserId="7398" LastActivityDate="2015-02-18T06:49:10.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8710" PostTypeId="2" ParentId="8677" CreationDate="2015-02-18T07:41:05.360" Score="0" Body="&lt;p&gt;Instead of using a delay, you may use some variable (maybe a struct or an object) to keep the status of your transmission or reading; every things that need a delay became a new state in this state-machine, every loop, based on witch status you have, you check if there are the information to execute the next step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have multiple thing with status, but if they share a resource you'll need to add an abstraction layer on that resource to take care of that. (Like an event system or a message router or an output buffer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you may have a status in witch you wait for a status in another state machine.&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-02-18T07:41:05.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8711" PostTypeId="1" AcceptedAnswerId="8713" CreationDate="2015-02-18T08:37:27.117" Score="5" ViewCount="34190" Body="&lt;p&gt;I want to avoid using the big USB B connector to program my Arduino Mega. Since there are those RX TX Pins I thought, it would be possible, to connect my USB - Wires from my PC directly to those RX TX Pins. &lt;code&gt;D+ -&amp;gt; TX and D- RX&lt;/code&gt;. &lt;a href=&quot;https://arduino.stackexchange.com/questions/3772/can-tx-and-rx-pins-on-the-uno-be-used-like-regular-digital-pins&quot;&gt;This Post on Arduino Stackexchange&lt;/a&gt; says, those wires are just connected, while &lt;a href=&quot;https://arduino.stackexchange.com/questions/4652/usb-d-d-to-arduino-mega-rx-tx&quot;&gt;this post&lt;/a&gt; says the exact opposite. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm confused. Is it possible or would I damage my board when connecting USB wireq to RX / TX pins on my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="7225" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-02-18T18:27:11.013" Title="Connect Arduino via TX RX Pins to Computer's USB Port" Tags="|serial|programming|usb|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8712" PostTypeId="2" ParentId="8711" CreationDate="2015-02-18T09:02:11.363" Score="0" Body="&lt;p&gt;Strictly Serial interfaces use ±15V, although this is uncommon these days (but then so are PCs with serial ports). ±12V, ±5V or even 0/+5V also exist. Connecting a ±15V interface to the Pi would destroy it. There are RS232 adapters to ensure safety.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are talking about connecting USB data lines to serial forget it. The voltages are the least of your worries, the USB serial encapsulates the data in a protocol. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-18T09:02:11.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8713" PostTypeId="2" ParentId="8711" CreationDate="2015-02-18T09:12:42.517" Score="3" Body="&lt;p&gt;The first answer that you cite that you say says it is possible is in fact not talking about  what you are referring to  - it is discussing the use of the RX &amp;amp; TX pins directly when they are not being used for USB connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second answer you cite is technically incorrect but &quot;correct enough&quot; in the context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to your question  is &quot;It can be done but it requires a different boot loader, its slower, its technically inferior, it's less standard, it requires a degree of understanding (on someone's part) to get it going, and &lt;strong&gt;it can be done&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It IS possible to access USB directly from digital I/O pins. As TX &amp;amp; RX are also standard digital I/O pins they could be used for this purpose BUT you need dedicated bootloader code to do this and it has inferior performance if a USB to serial converter is available. The eg ADAFruit Arduino Trinket uses this system.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is how the (or a)  &lt;a href=&quot;http://www.embedded-creations.com/projects/attiny85-usb-bootloader-overview/details&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;ADAFRUIT Trinket Bootloader&lt;/strong&gt;&lt;/a&gt; works. (The Trinket is not mentioned here but I'm told that this is what it uses. If not, it works in functionally the same manner). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is in turn based on the &lt;a href=&quot;http://www.obdev.at/products/vusb/usbasploader.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;USBaspLoader&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A (very) simple &quot;more or less Arduino compatible&quot; development board which can use this system is &lt;a href=&quot;https://metalab.at/wiki/Metaboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Metaboard&lt;/a&gt;. It's circuit diagram is shown below. As can be seen - it uses an ATMega168 and the USB connection is made to two standard digital I/O pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ScLWt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Metaboard&quot; using ATMega168&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;note USB connection to pins PD2 &amp;amp; PD4 - NOT via RXD on PD0 and TXD on PD1 via a serial to USB converter, as is more usual. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;AND another version:  &lt;a href=&quot;http://www.fischl.de/avrusbboot/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;AVRUSBBOOT&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uMRel.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And &lt;strong&gt;again&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.obdev.at/products/vusb/bootloadhid.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;BootloadHID&lt;/strong&gt;&lt;/a&gt;   They say  -&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;BootloadHID is a USB boot loader for AVR microcontrollers. The uploader tool requires no kernel level driver on Windows and can therefore be run without installing any DLLs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BootloadHID is a USB boot loader for AVR microcontrollers. It can be used on all AVRs with at least 2 kB of boot loader section, e.g. the popular ATMega8. The firmware is flashed into the upper 2 kB of the flash memory and takes control immediately after reset. If a certain hardware condition is met (this condition can be configured, e.g. a jumper), the boot loader waits for data on the USB interface and loads it into the remaining part of the flash memory. If the condition is not met, control is passed to the loaded firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This boot loader is similar to Thomas Fischl’s avrusbboot, except that it is built on top of the HID device class. This implementation is more user friendly on Windows, since no kernel level drivers need to be installed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-18T09:39:55.940" LastActivityDate="2015-02-18T09:39:55.940" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8714" PostTypeId="1" CreationDate="2015-02-18T10:11:52.217" Score="-1" ViewCount="1372" Body="&lt;p&gt;I'm using this simple code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;YunServer server;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Bridge.begin();&#xA;  server.listenOnLocalhost();&#xA;  server.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  YunClient client = server.accept();&#xA;  if (client) {&#xA;    Serial.println(&quot;client&quot;);&#xA;    process(client);&#xA;    client.stop();&#xA;   } else {&#xA;     Serial.println(&quot;no client&quot;);&#xA;   }&#xA;   delay(50); &#xA;}&#xA;&#xA;void process(YunClient client) {&#xA;  String command = client.readStringUntil('/');&#xA;  Serial.println(command);&#xA;  if (command == &quot;turnLeft&quot;) {&#xA;    Serial.println(&quot;Gira a sinistra&quot;);&#xA;  }&#xA;  if (command == &quot;turnRight&quot;) {&#xA;    Serial.println(&quot;Gira a destra&quot;);&#xA;  }&#xA;  if (command == &quot;goTo&quot;) {&#xA;    String value = client.readStringUntil('/goTo/');&#xA;    Serial.println(value);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it seems to have problem with bridge (or server, or client, i cannot understand) because it only write &quot;no client&quot; on the serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can not understand what is wrong. &lt;/p&gt;&#xA;" OwnerUserId="7402" LastEditorUserId="9962" LastEditDate="2016-02-23T12:28:44.277" LastActivityDate="2016-02-23T12:28:44.277" Title="Arduino Yun - Problem with bridge and client" Tags="|arduino-yun|web-server|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8715" PostTypeId="1" CreationDate="2015-02-18T12:09:33.160" Score="2" ViewCount="1462" Body="&lt;p&gt;I have a Uno (third party) that I connect to my Dell laptop with no problems at all. But I've just received a Nano (also third party) that I just can't get to upload. After lots of interneting, I hit Windows normally-useless troubleshooting tool. That tells me that the USB device (the Nano) doesn't understand USB3 and I should plug it into a USB2 port. Unfortunately, being a new machine there IS no USB2 port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is Windows Troubleshooting lying? Is there a problem interfacing with a Nano via USB3?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Error message is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4843" LastActivityDate="2017-02-03T06:08:44.337" Title="Connecting to Nano via USB3" Tags="|uploading|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8717" PostTypeId="2" ParentId="193" CreationDate="2015-02-18T13:17:30.770" Score="0" Body="&lt;p&gt;@annonomus penguin, sure we can&#xA;Although the code compiles into 1180 bytes flash + 13 bytes RAM for an uno on my computer, we can improve on it :) so golf challenge accepted and also a few usefull tips since we are in the business of learning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1: decrease variable requirements. &#xA;Using an int for a led port seems a bit overkill, we certainly don't have 65535 addressable IO ports on the arduino :) So we change it to a byte just for the fun of it. We will change it over to a #define later on, but to show the impact of using too large variable types.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte led = 13;&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  blink();&#xA;  val = digitalRead(10);&#xA;}&#xA;&#xA;void blink() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compiles into 1172 bytes + 13 byte RAM. This saves 8 bytes of flash due to fewer needed operations for the byte instead of a integer. I would expect 12 bytes of ram, but okay. Not that much, but every byte saved is good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 2: change over variable into defines when it makes sense.&#xA;For example, the led byte is not needed, the pin won't unsolder itself.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED 13&#xA;int val;&#xA;&#xA;void setup() {                &#xA;  pinMode(LED, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  blink();&#xA;  val = digitalRead(10);&#xA;}&#xA;&#xA;void blink() {&#xA;  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compiles into 1142 bytesflash + 11 bytes ram. Already 38 bytes saved. This is due to fewer register operations needed to fetch the int value. Also we saved 2 bytes from RAM. (still wondering why the byte didn't compile into 1 less byte of ram.....)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 3: optimize code.&#xA;I see 2 delays. I wonder if i change it to 1 delay it would save space, but i have to figure out the value of the LED pin and toggle (invert) it. We can do that with digitalRead(), but will it save space?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED 13&#xA;int val;&#xA;void setup() {                &#xA;  pinMode(LED, OUTPUT);     &#xA;}&#xA;void loop() {&#xA;  blink();&#xA;  val = digitalRead(10);&#xA;}&#xA;void blink() {&#xA;  digitalWrite(LED, !digitalRead(LED));   // toggle the led based on read value&#xA;  delay(1000);               // wait for a second and spare yourself the other delay&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compiles into 1134 bytes + 11 bytes ram. Yay! another 8 bytes. That makes a total of 46 bytes and 2 fewer lines of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also another general tip on decreasing codesize. Don't use the String class. It's HUGE, learn how to deal with char arrays, strcpy(), strcmp(). If all you have are some basic string operations, the usage of the String class is mostly just wasting space on both flash and RAM.&lt;/p&gt;&#xA;" OwnerUserId="7404" LastActivityDate="2015-02-18T13:17:30.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8718" PostTypeId="1" CreationDate="2015-02-18T13:26:01.250" Score="2" ViewCount="214" Body="&lt;p&gt;I want to interface a GLCD with arduino uno. The GLCD is JHD12864E.   The connections are as shown in this image &lt;img src=&quot;https://i.ytimg.com/vi/OmMnzDh4HAg/maxresdefault.jpg&quot; alt=&quot;GLCD Connections&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded the OpenGLCD library and uploaded HelloWorld program from it.&#xA;I got the error:&lt;br&gt;&#xA;        stk500_recv() : programmer is not responding  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I googled it and also tried to upload using ISP using another arduino. The program uploaded successfully, but i did not get any output on GLCD.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not getting this error when uploading any other sketches. Can anyone explain to me why do we get this error? And what is the solution to it?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.390" LastActivityDate="2015-02-23T17:08:46.770" Title="Why does avrdude error appear when interfacing GLCD with arduino uno in ubuntu" Tags="|arduino-uno|lcd|uploading|avrdude|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8719" PostTypeId="1" AcceptedAnswerId="8724" CreationDate="2015-02-18T14:04:06.627" Score="1" ViewCount="15399" Body="&lt;p&gt;My Ethernet shield dont have any MAC address, please tell me how to find the MAC address, I'm stucked! Here is the link from where I bought the Ethernet shield.&lt;br&gt;&#xA;&lt;a href=&quot;http://www.amazon.in/gp/product/B00AXVX5D0?ie=UTF8&amp;amp;at=&amp;amp;force-full-site=1&amp;amp;ref_=aw_bottom_links&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.in/gp/product/B00AXVX5D0?ie=UTF8&amp;amp;at=&amp;amp;force-full-site=1&amp;amp;ref_=aw_bottom_links&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7405" LastEditorUserId="653" LastEditDate="2015-08-12T13:38:40.007" LastActivityDate="2015-08-12T13:38:40.007" Title="Didn't have MAC address on Wiznet based ethernet shield (cloned)" Tags="|shields|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8720" PostTypeId="1" CreationDate="2015-02-18T14:04:46.067" Score="0" ViewCount="107" Body="&lt;p&gt;My question isn't specific to Arduino but can concern Raspberry Pi and all Internet of Things homemake projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm preparing a personal projet with sensors, data storage and visualisation/reporting web page (not yet Android app) I'm looking about Internet of Things platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems all that I can find are cloud related system. I would prefer a home localized solution but I'm not able to find one (and maybe open source) where datas don't go outside home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal is to be able to :&#xA;    &lt;li&gt;send datas from my Arduino to a home storage server&lt;/li&gt;&#xA;    &lt;li&gt;store these data into database for later query (may be MySql)&lt;/li&gt;&#xA;    &lt;li&gt;trigger some computation or aggregation job over datas&lt;/li&gt;&#xA;    &lt;li&gt;prepare some graphs&lt;/li&gt;&#xA;    &lt;li&gt;generate some html page from template&lt;/li&gt;&#xA;    &lt;li&gt;option: allow Android client to connect and get datas/graphs&lt;/li&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before starting thinking how to create my own (non standardized) system is anyone can give me some advice ? some name of such existing system ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thomas&lt;/p&gt;&#xA;" OwnerUserId="675" LastEditorUserId="675" LastEditDate="2015-02-18T14:14:22.397" LastActivityDate="2015-02-18T16:24:27.903" Title="Internet of Things at home only" Tags="|programming|datalogging|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8722" PostTypeId="2" ParentId="8720" CreationDate="2015-02-18T15:56:54.267" Score="1" Body="&lt;p&gt;I recently worked extensively on a Home Automation Project and here's what I would recommend based off of that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use Arduino for hardware interfacing.&lt;/li&gt;&#xA;&lt;li&gt;Use Raspberry Pi for hosting your server.&lt;/li&gt;&#xA;&lt;li&gt;Write your server using Node.js (or Python if you wish).&lt;/li&gt;&#xA;&lt;li&gt;Use Express, Socket.io (or Python simple server). Google these.&lt;/li&gt;&#xA;&lt;li&gt;Use Serial (USB) for communication between Arduino and Raspberry Pi &lt;/li&gt;&#xA;&lt;li&gt;Use RF/BLE if you want to go wireless.&lt;/li&gt;&#xA;&lt;li&gt;Use Redis or MySQL for database.&lt;/li&gt;&#xA;&lt;li&gt;Use a graph JS API for charting.&lt;/li&gt;&#xA;&lt;li&gt;To build an android app, send http requests (or a Socket.io link), for communication.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is a simple to implement, but you'll need to put some time. Good luck.&#xA;All of the above steps are abstracted from each other. This means that if you want to incorporate additional features, you can change any stage without affecting the whole.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2015-02-18T15:56:54.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8723" PostTypeId="2" ParentId="8720" CreationDate="2015-02-18T16:24:27.903" Score="0" Body="&lt;p&gt;Setting up a basic webserver on the Raspberry Pi is fairly straightforward, and as long as you have a firewall and aren't port-forwarding the data will be restricted to your home network.  You can also setup the firewall on the Pi to allow only local access fairly easily.  I did a similar project, and here was my process.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the Arduino to output the data in a standard way.  I used CSV format, but as long as it easy to parse you should be fine.  &lt;/li&gt;&#xA;&lt;li&gt;Get the Arduino to make the data available.  I ended up using the webserver sketch to generate a page with all of my values, but you could just as easily have it send data instead.  &lt;/li&gt;&#xA;&lt;li&gt;Insert the data into a database.  I had a cron job that every x minutes would pull the webpage, parse the data, and insert it into the database.&lt;/li&gt;&#xA;&lt;li&gt;Make the webpage.  There are a ton of open source graphing projects, and I chose a PHP based one as that is the language I am most comfortable with.  Javascript, Python, and CSS can also do it if you prefer.&lt;/li&gt;&#xA;&lt;li&gt;Since I used PHP it was fairly easy to setup a template system.  Basically it had some standard include statements, then worked off of $_GET variables to call a variety of graphs.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-18T16:24:27.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8724" PostTypeId="2" ParentId="8719" CreationDate="2015-02-18T16:28:37.033" Score="1" Body="&lt;p&gt;You can set the Mac address to whatever you want.  Many of the example sketches will have one already present, but as long you follow the standard mac format it should be happy (I am using the same shield).  In the Examples menu, you should see Ethernet then Webserver where you can find the following example.  You can change it a bit, but most of the time I just leave it alone.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte mac[] = { &#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-18T16:28:37.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8725" PostTypeId="2" ParentId="8719" CreationDate="2015-02-18T17:51:50.750" Score="3" Body="&lt;p&gt;Ethernet will work as long as two different machine in the LAN don't have the same MAC address, as @Nathan wrote in his answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MAC address &lt;a href=&quot;http://en.wikipedia.org/wiki/MAC_address#Address_details&quot; rel=&quot;nofollow&quot;&gt;is built by two parts&lt;/a&gt;, a prefix which are given to manufacturers of network devices and is called &lt;em&gt;OUI&lt;/em&gt;, and a suffix that is the node part that manufacturers can use as they wish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to build an MAC address yourself, use a &lt;em&gt;Locally administered&lt;/em&gt; address.  Universally administered and locally administered addresses are distinguished by &lt;a href=&quot;http://en.wikipedia.org/wiki/MAC_address#Address_details&quot; rel=&quot;nofollow&quot;&gt;setting the second-least-significant bit of the most significant byte of the address&lt;/a&gt;.&#xA;That will make this address to not use any OUI prefix, as that bit is zero on OUI, which minimize the risk of two or more devices have the same MAC address in same LAN. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get the same MAC addresses you will get very strange results if they happen to be in the same LAN, I tell you.  Been there, done that, and it wasn't fun to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a &lt;a href=&quot;http://www.macvendorlookup.com/&quot; rel=&quot;nofollow&quot;&gt;site that looks up MAC addresses&lt;/a&gt; (and generate random ones).  But if you want to see which manufacturer have that MAC address, &lt;a href=&quot;http://standards.ieee.org/develop/regauth/oui/public.html&quot; rel=&quot;nofollow&quot;&gt;you read it from IEEE and their list&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="6322" LastActivityDate="2015-02-18T17:51:50.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8726" PostTypeId="2" ParentId="4645" CreationDate="2015-02-18T18:01:47.973" Score="3" Body="&lt;h2&gt;upstream slow blinking&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The simplest approach:&#xA;Use a relay to turn the lights on and off. Control that relay with an Arduino.&#xA;(&quot;How to turn a relay on and off with an Arduino?&quot; is a separate question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cut either one of the wires feeding power into the EL inverter (&quot;upstream of the inverter&quot;),&#xA;and connect the 2 cut ends of the (formerly) one wire to the contacts of the relay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;power source ---- (relay contacts) ---- EL inverter ---- (EL wire)&#xA;           +--------------------------------+    +---------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;downstream slow blinking&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Alternative approach:&#xA;Use at least 2 pieces of EL wire.&#xA;Wire one always-on;&#xA;use a relay to connect or disconnect the other wire (&quot;downstream of the inverter&quot;). (The relay and controlled wire can be either directly connected to the inverter, or end-to-end connected to the always-on wire -- it doesn't matter for this application).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                                   always on&#xA;power source ---- EL inverter ---- (EL wire) ---- (relay contacts) ---- (EL wire)&#xA;           +----------+    +---------+   +-------------------------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Control that relay to &lt;a href=&quot;http://www.instructables.com/id/Control-EL-Wire-with-an-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;control the EL wire with an Arduino&lt;/a&gt;, same as before.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;dimming and PWM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Many low-cost relays are rated for only about 10,000 operations, so if you use them to blink for a long or short part of each second, they're only guaranteed to last for about 3 hours.&#xA;If you want to blink faster than that (and most people dim EL lights by blinking them &lt;em&gt;much&lt;/em&gt; faster than that), you'll have to use something other than a relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, most people seem to want to do the switching &quot;downstream&quot; of the inverter, so they can &quot;share&quot; a single EL inverter and use it to power lots of independently controlled pieces of EL wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the simplest approach is to use an off-the-shelf zero-crossing solid-state relay (SSR).&#xA;(&lt;a href=&quot;https://arduino.stackexchange.com/questions/4545/how-do-you-wire-a-ssr-relay-to-a-arduino-nano&quot;&gt;&quot;How to wire a SSR to an Arduino?&quot;&lt;/a&gt; is a separate question).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;power source ---- EL inverter&#xA;          +-----------+   | |&#xA;                          +----- EL wire (always on)&#xA;                          | +-----+&#xA;                          | |&#xA;                          +----(SSR)-- EL wire&#xA;                          | +-----------+&#xA;                          | |&#xA;                          +----(SSR)-- EL wire&#xA;                          | +-----------+&#xA;                          | |&#xA;                          +----(SSR)-- EL wire&#xA;                          | +-----------+&#xA;                          | |&#xA;                          +----(SSR)-- EL wire&#xA;                          | +-----------+&#xA;                          | |&#xA;                          ... etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because most SSRs are overkill for this application -- most of them have heatsinks bonded to high-power triacs designed to handle far more current than we need to light up a EL wire --&#xA;some people save a few dollars by assembling their own SSRs out of zero-crossing optocouplers, triacs, etc.&#xA;(A lower-cost, low-power triac is more than adequate for controlling EL wire, even without a heatsink).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SparkFun EL Escudo Dos Arduino shield for controlling electroluminescent wire&lt;a href=&quot;https://www.sparkfun.com/products/10878&quot; rel=&quot;nofollow noreferrer&quot;&gt;(c)&lt;/a&gt;&lt;a href=&quot;http://rylaangimby.com/holographic-fortune-teller-arduino-el-wire-unity/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(d)&lt;/a&gt;;&#xA;Diana's SparkFun EL Sequencer&lt;a href=&quot;https://www.sparkfun.com/products/11323&quot; rel=&quot;nofollow noreferrer&quot;&gt;(e)&lt;/a&gt;&lt;a href=&quot;http://makezine.com/2010/04/27/programming-el-wire-fashion/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(f)&lt;/a&gt;&lt;a href=&quot;http://www.kobakant.at/DIY/?p=2992&quot; rel=&quot;nofollow noreferrer&quot;&gt;(g)&lt;/a&gt;;&#xA;the seeedstudio EL Shield&lt;a href=&quot;http://www.seeedstudio.com/depot/EL-Shield-p-1287.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;(h)&lt;/a&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/EL_Shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;(i)&lt;/a&gt;&lt;a href=&quot;http://www.bajdi.com/trying-out-the-new-seeedstudio-el-shield/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(j)&lt;/a&gt;&lt;a href=&quot;http://www.robotshop.com/en/el-shield-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;(k)&lt;/a&gt;;&#xA;Tully Gehan's Cool Neon Arduino Shield&lt;a href=&quot;http://shopping.netsuite.com/s.nl/c.ACCT88394/it.A/id.1071/.f?sc=2&amp;amp;category=1678&quot; rel=&quot;nofollow noreferrer&quot;&gt;(m)&lt;/a&gt;&#xA;etc.&#xA;uses such zero-crossing optocouplers, triacs, etc.&#xA;(requires a separate EL inverter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to some people on the Arduino forums talking about EL wire&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=50534.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;(n)&lt;/a&gt;&lt;a href=&quot;http://dorkbotpdx.org/blog/paul/sparkfun_el_sequencer_trouble&quot; rel=&quot;nofollow noreferrer&quot;&gt;(p)&lt;/a&gt;,&#xA;some people save a few pennies by using normal optocouplers rather than zero-crossing optocouplers. Non-zero-crossing optocouplers seem to work fine for short pieces of EL wire but seems to destroy the triacs (failing &quot;always on&quot;) with a few dozen feet of EL wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some people save a few more pennies by skipping the optocoupler,&#xA;wiring the Arduino directly to the control gate of the triac, and the VCC pin of the Arduino directly to the MT1 pin of the triac.&#xA;&lt;a href=&quot;https://kavasmlikon.wordpress.com/2011/11/21/how-to-make-el-wire-blink/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(q)&lt;/a&gt; &lt;a href=&quot;https://electronics.stackexchange.com/questions/25295/arduino-triggering-a-triac-for-el-wire-no-optoisolator&quot;&gt;(r)&lt;/a&gt; &lt;a href=&quot;http://celestialaudio.com/catchall/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(s)&lt;/a&gt; &lt;a href=&quot;http://www.opencircuits.com/Russ_Hensel&amp;#39;s_EL_Wire_Project&quot; rel=&quot;nofollow noreferrer&quot;&gt;(t)&lt;/a&gt;&#xA;If there were some way to only turn the triac on near the zero-crossing, this could work great; but without zero-crossing control, this has the same problems as the above normal non-zero-crossing optocouplers.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;always-on&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &quot;extra&quot; always-on bit of EL wire is because some people say&#xA;&quot;never run the inverter without at least 1 foot of EL attached&quot;&lt;a href=&quot;https://learn.adafruit.com/el-wire&quot; rel=&quot;nofollow noreferrer&quot;&gt;(a)&lt;/a&gt; because running some EL inverters with no load &quot;can damage the inverter&quot;&lt;a href=&quot;https://learn.adafruit.com/el-wire/using-el-wire&quot; rel=&quot;nofollow noreferrer&quot;&gt;(b)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-02-18T18:01:47.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8728" PostTypeId="1" CreationDate="2015-02-18T08:41:45.967" Score="0" ViewCount="105" Body="&lt;p&gt;Are there any &lt;em&gt;Arduino-like&lt;/em&gt; board designs that are &lt;strong&gt;&lt;em&gt;NOT&lt;/em&gt;&lt;/strong&gt; using an AVR chip, but perhaps a chip like the Z80 or the 6502?&lt;/p&gt;&#xA;" OwnerDisplayName="Jonas Gorauskas" LastActivityDate="2015-02-18T18:31:53.793" Title="Arduino-like boards with other microcontrollers" Tags="|avr|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8729" PostTypeId="2" ParentId="8728" CreationDate="2015-02-18T09:17:37.663" Score="1" Body="&lt;p&gt;You have to define what you mean by &quot;Arduino-like&quot; beyond just not using an AVR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's the Arduino Galileo using an Intel chip and supports the Arduino development tools, as well as the Arduino Due which is an Arm-based chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's the Netduino which uses ARM chips (STMicro's) and is pin compatible with Arduino shields, but I don't know what the development framework is (other than it being in .NET), though this doesn't necessarily say much because not even all Arduino boards have the same pin compatibility (Nano boards are much smaller, LilyPad Arduinos which are round and semi-flexible, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there are related boards, but don't support the Arduino environment or any pin compatibility (TI Launchpad springs immediately to mind, but pretty much every manufacturer has some sort of demo board or development board for their MCU's).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a huge list of Arduino-like boards &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (split into levels of compatibility, includes the official Arduino boards).&lt;/p&gt;&#xA;" OwnerDisplayName="helloworld922" LastActivityDate="2015-02-18T09:17:37.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8730" PostTypeId="1" AcceptedAnswerId="8731" CreationDate="2015-02-18T18:36:04.007" Score="0" ViewCount="709" Body="&lt;p&gt;are there any USB to TTL with switchable 5v and 3.3v &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i need to use it for raspberry pi and arduino&lt;/p&gt;&#xA;" OwnerUserId="7412" LastActivityDate="2015-02-18T19:23:21.427" Title="USB to TTL with switchable 5v and 3.3v in one" Tags="|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8731" PostTypeId="2" ParentId="8730" CreationDate="2015-02-18T19:23:21.427" Score="1" Body="&lt;p&gt;Many 3.3V FTDI based devices are 5V tolerant and will work with both:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/product/284&quot; rel=&quot;nofollow&quot;&gt;Adafruit's FTDI friend&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11736&quot; rel=&quot;nofollow&quot;&gt;Sparkfun FT231X Breakout&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is general information about logic levels: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/logic-levels&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/logic-levels&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2015-02-18T19:23:21.427" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8732" PostTypeId="1" AcceptedAnswerId="8744" CreationDate="2015-02-18T20:16:32.153" Score="0" ViewCount="2211" Body="&lt;p&gt;my Adafruit motorshield is getting current from Arduino board even after disconnected from battery. I was planning to give separate dc power from 6 AA cells to motor shield but not sure if extra current will enter into Arduino and damage it. I have Ultrasonic sensor connected to motorshield which is getting +5v from board (may be Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest how to solve this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2015-11-16T11:37:09.313" Title="Adafruit motorshield disconnected but getting current from Arduino" Tags="|arduino-motor-shield|adafruit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8733" PostTypeId="1" AcceptedAnswerId="8735" CreationDate="2015-02-18T22:58:16.930" Score="8" ViewCount="8749" Body="&lt;p&gt;I'm working on a custom arduino that will run at 3.3 V with no regulators or USB chips (for power consumption).  I've heard that overclocking the chip at 16 MHz/3.3 V is generally fine, but I'd like to stay within spec anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First: to run at 8 MHz, do I just need to replace the crystal?  Or is there anything else I have to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second: Do I need to make any code changes to reflect the new speed?  I'm using serial, SPI, and I2C connections in this project, along with the NilRTOS operating system and millis/delay functions.  Will any of these be broken?  Will the code run noticeably slower?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third: How can I program the chip?  Is it ok to program it in an Arduino Uno at 16 MHz, then transplant it to the custom arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth: Will power consumption change at 8 MHz?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7419" LastActivityDate="2015-06-25T21:31:21.363" Title="What are the implications of running an ATmega328P at 8 MHz and 3.3 V with the Arduino system?" Tags="|atmega328|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8734" PostTypeId="2" ParentId="4645" CreationDate="2015-02-18T23:40:06.973" Score="0" Body="&lt;p&gt;For a simpler option, there are Arduino shields for controlling El Wire.  Sparkfun makes a couple and they have some sample code and projects.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10878&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10878&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-18T23:40:06.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8735" PostTypeId="2" ParentId="8733" CreationDate="2015-02-19T00:32:19.243" Score="7" Body="&lt;p&gt;The formula seems to be volt*5.9-6.6=mhz (valid between 1.8v and 4.5v), so at 3.3v, this would give 12.8mhz. Be aware that, if you are running at 12.8mhz, ANY drop below 3.3v MAY cause problems (and very hard to diagnose, too!) or you MAY get away with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Arduino Atmega328p chips have a &quot;brown-out&quot; detection set at 4.3v - any drop below that, the chip shuts down. You can get an ISP (AKA ICSP) to change the fuses - go to &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;noreferrer&quot;&gt;http://www.engbedded.com/fusecalc/&lt;/a&gt; to work out what to set fuses to. You can also use the ISP to read the current fuses, or indeed reprogram the chip without an Arduino board - all my projects have a 6-pin header. If you do this, before reprogramming using the Arduino board, you will have to &quot;Burn Bootloader&quot; (in the tools menu). Note that programming can still be done via Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you want to go &quot;light&quot; (and have an ISP), you can change the fuses to use the internal 8mhz clock - this frees up 2 extra pins, too! Be aware, however, that the internal clock may drift 1.2 hours per day (=5%), compared to 1.7 seconds per day (=20 parts per million) on a typical quartz crystal. If you don't use it for timekeeping, this probably doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to make changes to the timing, for your code - you need to add a boards.txt with correct settings for your chip/clockspeed etc - you can copy the settings from the entry for the board, change the name, and change the setting &quot;build.f_cpu&quot;; restart (or start) your Arduino IDE, go to &quot;Tools-&gt;Board&quot; and select the board you added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can move the chip on/off the board, and reprogram it there (note that the board selected in Tools-&gt;Board is the FINAL board, not the programming board). Be careful plugging/unplugging it - eventually, you WILL bend the pins! Alternatively, you can use ISP (ICSP), as mentioned above - much recommended. ISP programming will also work if the chip is factory default, so long as it has a working clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much power is used by the chip depends hugely on what you do with it - not just clock speeds, clock source, etc but also sleep modes. If you are sleeping a lot, it may draw less when running faster than running slower - if almost all your time is asleep, then the power consumption should be counted per clock cycle, not per second - if your clock is half the speed, and half current, then you draw the same current per instruction. Since the rest of your time is spent asleep, you get no benefit. See &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;noreferrer&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt; for a very good breakdown of power usage, tips on how to save power, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you slow your clock down too much, serial and i2c may become unreliable (unless you slow down the speed), but I would expect to be able to go down to  1mhz before this to be a problem - a 1mhz chip trying to do 9600bps has 104 instructions per bit of data transferred. i2c runs at 100khz, so you get 10 instructions per bit (at 1mhz) - possibly pushing it. 8mhz should be fine. Test, test, test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&#xA;There are 3 possible settings for the brown-out detection - there are 3 possible values for the AtMega328p: disabled, 1.8v, 2.7v, and 4.3v. I was under the impression (above) that Arduinos were normally set to 4.3v; apparently that is not the case (see comment below). I recall seeing somewhere that there was brownout detection. This is something to keep in mind, if your arduino resets, especially when putting larger loads on the battery (running motors, multiple leds etc).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-02-22T20:35:00.470" LastActivityDate="2015-02-22T20:35:00.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8736" PostTypeId="1" CreationDate="2015-02-19T01:28:30.293" Score="1" ViewCount="3847" Body="&lt;p&gt;I have installed an &lt;a href=&quot;http://playground.arduino.cc/Learning/MFRC522&quot; rel=&quot;nofollow&quot;&gt;MFRC522 RFID reader&lt;/a&gt; in my house. The main use so far is to tell the house I've arrived using an RFID keychain, by leaving it in the key holder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also like for the house to detect when I'm gone, and I was thinking that, if I can detect when a tag is present, I should also be able to detect when it is not. &#xA;However, this poses some challenges like the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Should I be constantly reading the tag until it disappears from range? (when I take it from the key holder).&lt;/li&gt;&#xA;&lt;li&gt;What if I have more than one RFID Keychain/Tag in the range of the reader? (because there could be other keychains in the same key holder). Would I get multiple readings or could one tag interfere with another in some way?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I realize that maybe this is not the typical RFID scenario when the tag is scanned and then moved away from the reader. I've been searching about &quot;RFID tag absence detection&quot; but I've only found what seemed to me like very theoretical papers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any advice or experience in implementing something like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="6525" LastActivityDate="2017-01-29T12:43:03.610" Title="How to detect the absence of an RFID tag?" Tags="|rfid|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8737" PostTypeId="2" ParentId="6874" CreationDate="2015-02-19T01:52:57.630" Score="1" Body="&lt;p&gt;Have you connected the &lt;code&gt;GND&lt;/code&gt; pin from the &lt;code&gt;UNO&lt;/code&gt; to the breadboard?  I can't hardly tell.  But it looks like you are also using 5V to power it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are you powering the &lt;code&gt;UNO&lt;/code&gt;?  Is it just 3.3V?  I'm powering mine with a 5V but have level converters connected.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mine:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/K8Lth.jpg&quot; alt=&quot;UNO with OLED&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6883" LastEditorUserId="6883" LastEditDate="2015-02-19T01:58:38.480" LastActivityDate="2015-02-19T01:58:38.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8738" PostTypeId="1" AcceptedAnswerId="8742" CreationDate="2015-02-19T02:21:32.660" Score="3" ViewCount="478" Body="&lt;p&gt;I am looking at the following code and getting confused by a few elements in it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Why is there a writeto function being performed to the memory locations x053,0x31,x09 for accelerometer and 0x68,0x16 and 0x1A for gyro? We are only reading incoming values so what is the purpose of these functions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) the bitwise operation being performed in the getGyrscopeReadings and getAccelerometerReadings... are these operations to define how many bits data we will be reading?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Wire.h&amp;gt; //The I2C library&#xA;&#xA;int gyroResult[3], accelResult[3];&#xA;&#xA;//Function for writing a byte to an address on an I2C device&#xA;void writeTo(byte device, byte toAddress, byte val) {&#xA;  Wire.beginTransmission(device);  &#xA;  Wire.write(toAddress);        &#xA;  Wire.write(val);        &#xA;  Wire.endTransmission();&#xA;}&#xA;&#xA;//Function for reading num bytes from addresses on an I2C device&#xA;void readFrom(byte device, byte fromAddress, int num, byte result[]) {&#xA;  Wire.beginTransmission(device);&#xA;  Wire.write(fromAddress);&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom((int)device, num);&#xA;  int i = 0;&#xA;  while(Wire.available()) {&#xA;    result[i] = Wire.read();&#xA;    i++;&#xA;  }&#xA;}&#xA;&#xA;//Function for reading the gyros.&#xA;void getGyroscopeReadings(int gyroResult[]) {&#xA;  byte buffer[6];&#xA;  readFrom(0x68,0x1D,6,buffer);&#xA;  gyroResult[0] = (((int)buffer[0]) &amp;lt;&amp;lt; 8 ) | buffer[1]; //Combine two bytes into one int&#xA;  gyroResult[1] = (((int)buffer[2]) &amp;lt;&amp;lt; 8 ) | buffer[3];&#xA;  gyroResult[2] = (((int)buffer[4]) &amp;lt;&amp;lt; 8 ) | buffer[5];&#xA;} &#xA;&#xA;//Function for reading the accelerometers&#xA;void getAccelerometerReadings(int accelResult[]) {&#xA;  byte buffer[6];&#xA;  readFrom(0x53,0x32,6,buffer);&#xA;  accelResult[0] = (((int)buffer[1]) &amp;lt;&amp;lt; 8 ) | buffer[0]; //Yes, byte order different from gyros'&#xA;  accelResult[1] = (((int)buffer[3]) &amp;lt;&amp;lt; 8 ) | buffer[2];&#xA;  accelResult[2] = (((int)buffer[5]) &amp;lt;&amp;lt; 8 ) | buffer[4];&#xA;}&#xA;&#xA;void setup() {&#xA;  Wire.begin();            //Open I2C communications as master&#xA;  Serial.begin(9600);    //Open serial communications to the PC to see what's happening&#xA;&#xA;  writeTo(0x53,0x31,0x09); //Set accelerometer to 11bit, +/-4g&#xA;  writeTo(0x53,0x2D,0x08); //Set accelerometer to measure mode&#xA;  writeTo(0x68,0x16,0x1A); //Set gyro to +/-2000deg/sec and 98Hz low pass filter&#xA;  writeTo(0x68,0x15,0x09); //Set gyro to 100Hz sample rate&#xA;}&#xA;&#xA;void loop() {&#xA;  getGyroscopeReadings(gyroResult);&#xA;  getAccelerometerReadings(accelResult);&#xA;&#xA;  Serial.print(gyroResult[0]);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(gyroResult[1]);&#xA;  Serial.print(&quot;\t&quot;); &#xA;  Serial.print(gyroResult[2]);&#xA;  Serial.print(&quot;\t\t&quot;);&#xA;  Serial.print(accelResult[0]);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(accelResult[1]);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(accelResult[2]);&#xA;  Serial.print(&quot;\n&quot;);&#xA;&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;any help would be greatly appreciated! &lt;/p&gt;&#xA;" OwnerUserId="7422" LastActivityDate="2015-02-19T05:00:32.733" Title="Understanding Digital IMU 6DOF sketch" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8739" PostTypeId="2" ParentId="8626" CreationDate="2015-02-19T02:25:00.070" Score="0" Body="&lt;p&gt;Thanks for all the replys. I have a lot to learn as I only heard of arduino a month ago.&#xA;Didn't have a reason before.&#xA;My arduino hasn't arrived yet so I made my basic circuit with components on a breadboard.&#xA;I think I will need the arduino as I need some monitoring in the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks again much appreciated.&#xA;Eamonn&lt;/p&gt;&#xA;" OwnerUserId="7423" LastActivityDate="2015-02-19T02:25:00.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8740" PostTypeId="1" CreationDate="2015-02-19T03:07:52.263" Score="3" ViewCount="429" Body="&lt;p&gt;How can I open simultaneously two socket connections with a GSM shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that when I try to open the second connection, it is not opened, and additionally the first connection is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;#define PINNUMBER      &quot;&quot;&#xA;#define GPRS_APN       &quot;sm2ms.movilforum.es&quot;&#xA;#define GPRS_LOGIN     &quot;&quot;   &#xA;#define GPRS_PASSWORD  &quot;&quot;&#xA;&#xA;#define SERVER &quot;www.abv.bg&quot;    // some server&#xA;#define PORT   80              // some port&#xA;&#xA;static GSM gsm;&#xA;static GPRS gprs;&#xA;static GSMClient clientControl;    // first connection&#xA;static GSMClient clientData;       // second connection&#xA;&#xA;void setup()&#xA;{&#xA;    // initialize serial communications&#xA;    Serial.begin(9600);&#xA;&#xA;    Serial.println(&quot;GSM not initialized&quot;);&#xA;&#xA;    while (true)&#xA;    {&#xA;        if (gsm.begin(PINNUMBER) == GSM_READY)&#xA;        {&#xA;            Serial.println(&quot;GSM initialized&quot;);&#xA;&#xA;            while (true)&#xA;            {&#xA;                GSM3_NetworkStatus_t eErrorCode;&#xA;&#xA;                delay(1000);&#xA;&#xA;                eErrorCode = gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);&#xA;                if (eErrorCode == GPRS_READY)&#xA;                {&#xA;                    Serial.println(&quot;GPRS initialized&quot;);&#xA;&#xA;                    return;&#xA;                }&#xA;                Serial.print(&quot;Not connected to GPRS, error code = &quot;);&#xA;                Serial.println(eErrorCode, 1);&#xA;            }&#xA;        }&#xA;&#xA;        Serial.println(&quot;Not connected to GSM&quot;);&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    delay(1000);&#xA;&#xA;    Serial.println((clientControl.connect(SERVER, PORT))&#xA;                   ? (&quot;Connected&quot;) : (&quot;Couldn't connect&quot;));&#xA;&#xA;    delay(1000);&#xA;&#xA;    Serial.println((clientData.connect(SERVER, PORT))&#xA;                   ? (&quot;Second connection succeeded&quot;) &#xA;                   : (&quot;Second connection failed&quot;));&#xA;&#xA;    Serial.println(&quot;Do something here&quot;);&#xA;&#xA;    // close the stuff here!!!&#xA;    for (;;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial dumps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GSM not initialized&#xA;GSM initialized&#xA;GPRS initialized&#xA;Connected&#xA;Second connection failed&#xA;Do something here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With other clients I don't have problem supporting two simultaneous connections. Here the first connection succeeds, the second fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Boyan&lt;/p&gt;&#xA;" OwnerUserId="7425" LastEditorUserId="7425" LastEditDate="2015-02-19T16:24:53.163" LastActivityDate="2015-02-19T16:24:53.163" Title="How can I open simultaneously 2 client socket connections with GSM shield?" Tags="|arduino-uno|shields|gsm|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8741" PostTypeId="2" ParentId="8679" CreationDate="2015-02-19T04:01:09.417" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how else can I declare a static array of doubles (needs to be static,&#xA;  I calculate an average of some incoming data over several function&#xA;  calls)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you find a bug in the Arduino software, please do report it to the appropriate place -- &lt;a href=&quot;http://arduino.cc/en/Main/ContactUs&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ContactUs&lt;/a&gt; has the contact details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to declare a static array of doubles is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double boxcar_average(double new_sample) {&#xA;  const int arraySize = 3;&#xA;  static double old_sample[ arraySize ] = {0};&#xA;  double sum = new_sample;&#xA;  for(int i=0; i&amp;lt;arraySize; i++){&#xA;    sum += old_sample[i];&#xA;  }&#xA;  old_sample[0] = old_sample[1];&#xA;  old_sample[1] = old_sample[2];&#xA;  old_sample[2] = new_sample;&#xA;  return( sum / 4 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-02-19T04:01:09.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8742" PostTypeId="2" ParentId="8738" CreationDate="2015-02-19T05:00:32.733" Score="2" Body="&lt;p&gt;&lt;strong&gt;The &lt;code&gt;writeTo&lt;/code&gt; functions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accelerometer and gyro both have some memory inside that is used to store the configuration. The specific locations and values can be read from the datasheet, but for now I'll trust the comments. These writeTo functions seem to set the device modes and configure the scale used for the sensors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that they only happen once, right when the program starts. Maybe the devices have a way of storing persistent settings onboard, but setting them once at each startup is safe and easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Bitwise ops&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These don't set the number of bits we are reading &lt;em&gt;per se&lt;/em&gt;, They reconstruct larger than 8-bit values. The I2C serial protocol is set up to use 8-bit data segments, so to send any value larger than 8-bits they must be broken down, sent, and then &quot;stitched&quot; back together in chucks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(((int)buffer[0]) &amp;lt;&amp;lt; 8 ) | buffer[1];&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whats happening here is that &lt;code&gt;buffer[0]&lt;/code&gt; is converted to int (a 16 bit value), then shifted over by 8 bits. This means the 8 bits in the original &lt;code&gt;buffer[0]&lt;/code&gt; are now located in the top 8-bits of the integer, and the lower 8 bits are zeros. Finally the lower 8 bits are set by the bitwise-or operator &lt;code&gt;|&lt;/code&gt;, which will turn on any bits that were set in &lt;code&gt;buffer[1]&lt;/code&gt; in the result. Since the bottom 8-bits were 0's from the shift, this just copies &lt;code&gt;buffer[1]&lt;/code&gt; in exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The net effect is a 16 bit value that contains the bits of both 8-bit buffer values and can be interpreted as a single number. &lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-02-19T05:00:32.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8743" PostTypeId="1" AcceptedAnswerId="8745" CreationDate="2015-02-19T06:58:11.943" Score="2" ViewCount="9727" Body="&lt;p&gt;I'm wondering where the pin setting is manifested in the library.&#xA;I want to use the RC522 with other digital pins than the default 50-53 pins, because I am using a shield for a display on theese ports. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can I change the used ports?&#xA;why are two ports user-defineable &lt;code&gt;#define RFID_SS  10 #define RFID_RST 5&lt;/code&gt; while the rest is not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am with this &lt;a href=&quot;http://playground.arduino.cc/Learning/MFRC522&quot; rel=&quot;nofollow&quot;&gt;Playground-Guide&lt;/a&gt; using this &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;library from Github&lt;/a&gt; on my Arduino Mega&lt;/p&gt;&#xA;" OwnerUserId="7225" LastActivityDate="2020-11-04T14:45:02.713" Title="Use RFID-RC522 with other Pins" Tags="|arduino-mega|pins|rfid|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8744" PostTypeId="2" ParentId="8732" CreationDate="2015-02-19T07:36:35.947" Score="2" Body="&lt;p&gt;If all else fails, read &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-motor-shield.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;The Manual&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The manual indicates that it is intended that the MS electronics may be operated by the Arduino power supply while using a separate external supply for the motor.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pages 37 to 39 explain about powering options.&lt;br&gt;&#xA;The Arduino and the shield interconnect all of : 3V, 5V, Vin.&lt;br&gt;&#xA;3V may not be used by the shield.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Vin to MS V+ is broken by jumper &quot;PWRJMP&quot; - purple rectangle in diagram below.&lt;br&gt;&#xA;Arduino 5V to MS Vcc is not interrupted by a jumper - See labels in red squares below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/LF9QF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You did not say what version shield you had or which Arduino or what you mean by &quot;disconnected from battery&quot; or supply any links to relevant documents. ALL of these things will help people to help you better. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming latest MS version, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/product/81&quot; rel=&quot;nofollow noreferrer&quot;&gt;adafruit motor shield v1.2&lt;/a&gt;  - discontinued.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://raw.githubusercontent.com/adafruit/Adafruit-Motor-Shield-for-Arduino/master/mshieldv12schem.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;github v1.2 schematic&lt;/a&gt; this appears to be pre V2 BUT is linked to from a ference in the V2 manual so is probably &quot;more or less correct&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-motor-shield-v2-for-arduino.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;adafruit motor shield v2 manual&lt;/strong&gt;&lt;/a&gt; - &lt;strong&gt;probably what you have&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/use-it&quot; rel=&quot;nofollow noreferrer&quot;&gt;adafruit current MS page&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This probably tells you what you need to know.  Manual page 37-38&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;How to set up the Arduino + Shield for powering motors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servos are powered off of the same regulated 5V that the Arduino uses. This&#xA;is OK for the small hobby servos suggested. If you want something beefier, cut the trace&#xA;going to + on the servo connectors and wire up your own 5-6V supply!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The DC motors are powered off of a 'high voltage supply' and NOT the regulated 5V.&lt;/strong&gt;&lt;br&gt;&#xA;Don't connect the motor power supply to the 5V line. This is a very very very bad idea unless you are sure you know what you're doing!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two places you can get your motor 'high voltage supply' from. One is the DC jack on the Arduino board and the other is the 2-terminal block on the shield that is&#xA;labeled EXT_PWR. The DC Jack on the Arduino has a protection diode so you won't be able&#xA;to mess things up too bad if you plug in the wrong kind of power. However the EXT_PWR&#xA;terminals on the shield do not have a protection diode (for a fairly good&#xA;reason). Be utterly careful not to plug it in backwards or you will destroy the motor&#xA;shield and/or your Arduino!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-19T07:36:35.947" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8745" PostTypeId="2" ParentId="8743" CreationDate="2015-02-19T10:23:23.250" Score="1" Body="&lt;pre&gt;&lt;code&gt;#define RFID_SS  10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;stands for Slave Select on port 10, the SPI is a serial interface, meaning you can connect all kinds of SPI devices to the same wires, as long as slaves have different IO ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also the reason you don't need to define the other ports because they need to be connected to your SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you make yourself familiar with this page: &lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SPI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum it up. You can change the reset and Slave Select pin out, (those set in the variables) but not the SPI Pins. But you can use the ISCP pins in the middle of the board.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-02-19T10:23:23.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8746" PostTypeId="2" ParentId="8580" CreationDate="2015-02-19T10:27:35.570" Score="3" Body="&lt;p&gt;I just made my GY-521(MPU6050) work with Simulink using s-function.&#xA;I wish this would be helpful for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino MEGA 2650 board. The sensor data is read in in real time.&#xA;Note that currently only Arduino MEGA 2650, Arduino MEGA 2650 ADK, and Arduino DUE support the real time windows target. &#xA;If you are using other types of board, this answer may not applied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your hardware connection looks correct. But if you have some troubles you can refer to mine for checking:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5v VCC&#xA;GND GND&#xA;SCL SCL(check the register map of your board)&#xA;SDA SDA(check the register map of your board)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above four connections are adequate if you just read raw sensor data.&#xA;INT is needed if you are going to read fused data. But I did not try that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you may write a small program in Arduino IDE to ensure everything works.&#xA;You can refer to the Arduino MPU6050 examples.&#xA;The code written here will be used to construct your Simulink s-function later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can start to build your Simulink block using s-function builder.&#xA;If you did not do this before, here is a good tutorial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://m.youtube.com/watch?v=_OLctOFjjYQ&quot; rel=&quot;nofollow&quot;&gt;https://m.youtube.com/watch?v=_OLctOFjjYQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our case, you need to copy Wire.h, twi.h and their .c counterparts in your current working directory where your s-function resides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And do not forget to rename generated .c file to .cpp, and add external &quot;C&quot; declaration. All of these are illustrated in above video tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After all of above are done, you turn your simulation mode to external, and run.&#xA;You can view your sensor data in scope if everything goes right.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Source code and configuration used in my function:&#xA;I include all headers in the &lt;code&gt;Libraries&lt;/code&gt; panel of S-Function Builder,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MATLAB_MEX_FILE&#xA;#define ARDUINO 100&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Wire.cpp&amp;gt;&#xA;#include &amp;lt;twi.h&amp;gt;&#xA;#include &amp;lt;twi.c&amp;gt;&#xA;#define MPU 0x68&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wire.* and twi.* files are copied from Arduino IDE's directory. I put these files along with my S-Function block file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The address of I2C is 0x68 here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, the code for sensor outputs are placed in &lt;code&gt;Outputs&lt;/code&gt; panel. And do not forget to add ports in &lt;code&gt;Data Properties&lt;/code&gt; panel.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MATLAB_MEX_FILE&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x3B);&#xA;Wire.endTransmission(false);&#xA;Wire.requestFrom(MPU, 14, true);&#xA;&#xA;int raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;ax[0] = (float)raw / 8192.0f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;ay[0] = (float)raw / 8192.0f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;az[0] = (float)raw / 8192.0f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;temp[0] = (float)raw / 340.0f + 36.53f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;gx[0] = (float)raw / 131.0f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;gy[0] = (float)raw / 131.0f;&#xA;&#xA;raw = Wire.read() &amp;lt;&amp;lt; 8;&#xA;raw = raw | Wire.read();&#xA;gz[0] = (float)raw / 131.0f;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, initialization and configuration are done in &lt;code&gt;Discrete Update&lt;/code&gt; panel.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MATLAB_MEX_FILE&#xA;if (xD[0] != 1) {&#xA;    Wire.begin();&#xA;&#xA;    /* Do not sleep */&#xA;    Wire.beginTransmission(MPU);&#xA;    Wire.write(0x6B);&#xA;    Wire.write(0);&#xA;    Wire.endTransmission(true);&#xA;&#xA;    /* Gyroscope full scale range: 250 degs/s */&#xA;    Wire.beginTransmission(MPU);&#xA;    Wire.write(0x1B);&#xA;    Wire.write(0);&#xA;    Wire.endTransmission(true);&#xA;&#xA;    /* Accelerometer full scale range: 4g */&#xA;    Wire.beginTransmission(MPU);&#xA;    Wire.write(0x1C);&#xA;    Wire.write(8);&#xA;    Wire.endTransmission(true);&#xA;&#xA;    xD[0] = 1;&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please refer to your board's datasheet for specific address and LSB scales. I am using GY-521 here.&lt;/p&gt;&#xA;" OwnerUserId="7088" LastEditorUserId="7088" LastEditDate="2015-02-26T04:49:38.603" LastActivityDate="2015-02-26T04:49:38.603" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8747" PostTypeId="2" ParentId="804" CreationDate="2015-02-19T12:51:22.577" Score="5" Body="&lt;p&gt;Having a similar issue with my &lt;code&gt;Sainsmart Nano&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under &lt;code&gt;Preferences&lt;/code&gt; check &quot;Show verbose output during [x] upload, then when uploading, you should get a red trace like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/johannes/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/tty.usbserial-A403MRTP&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll notice a little &quot;pause&quot; just before the first line of &lt;code&gt;avrdude: Send: 0 [30]   [20]&lt;/code&gt;. Try uploading again and have you finger ready on the physical reset button of your &lt;code&gt;Nano&lt;/code&gt;. &lt;em&gt;Just the moment before the first &lt;code&gt;avrdude: ...&lt;/code&gt; appears, press the reset button.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you succeed, you'll see the screen filling with all sort of gibberish, and ending something like this after a few seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[78] . [00] S [53] h [68] o [6f] u [75] l [6c] d [64]   [20] b [62] e [65]   [20] 0 [30] x [78] 4 [34] 9 [39] D [44] 4 [34] . [00] . [01] . [00] . [00] . [00] . [02] . [00] . [03] . [00] . [04] . [00] . [00] . [00] . [00] . [00] . [e6] . [06] . [b5] . [06] n [6e] . [06] w [77] . [06] . [8c] . [06] . [9d] . [06] . [00] . [00] . [00] . [00] . [02] . [0d] . [aa] . [0d] . [95] . [0c] . [c9] . [0c] . [a9] . [0c] . [f2] . [0c] . [00] &#xA;avrdude: Recv: . [10] &#xA;# | 100% 3.71s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 8824 bytes of flash verified&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7157" LastEditorUserId="7157" LastEditDate="2015-02-19T12:57:44.777" LastActivityDate="2015-02-19T12:57:44.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8749" PostTypeId="2" ParentId="8706" CreationDate="2015-02-19T14:26:09.333" Score="1" Body="&lt;p&gt;That library is uses some AVR specific methods, that aren't implemented for the ARM processor in the Due. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see a real easy way to port those methods.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-02-19T14:26:09.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8750" PostTypeId="1" CreationDate="2015-02-19T16:54:39.213" Score="2" ViewCount="775" Body="&lt;p&gt;A brief description of what I'm doing here. I wanna make a pet project, basically a device (be it Arduino or raspberry pi) that I can connect to via bluetooth / wifi (both preferably), that will be connected to a stereo system and allow me to play music. I essentially want to make a wireless sound system in my house.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, is raspberry pi more adequate for my needs? Or would arduino get the job done? I know that raspberry pis are essentially mini computers, so I feel that the raspberry pi would be too much, since all I really need to do is design a bluetooth / wifi interface and send the signal to the aux cable connected to the stereo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be really useful here. I've never worked with either/or, and this is my first project with Arduino / Raspberry pi (hello world). Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: In response to comments below, a greater idea of what I want to do:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to design an item that will appear on local wifi as a sound device. i.e. on an imac / macbook I'd be able to right click on the speaker icon in the upper right and select it there). From there, I'm hoping to stream audio to the device, and have it play to a stereo that the arduino / raspberry pi would be connected to. I'd love to make this universal (i.e. possible to connect via your android phone / a windows machine), but I can imagine that part being a lot more difficult. I'd also like to add bluetooth functionality at some point, but that'd be in the future. Hopefully this gives everybody more of an idea of what I'd like to achieve here! I appreciate all the help so far.&lt;/p&gt;&#xA;" OwnerUserId="7432" LastEditorUserId="7432" LastEditDate="2015-02-19T23:15:41.333" LastActivityDate="2015-03-12T20:39:04.457" Title="Arduino or Raspberry Pi for my project" Tags="|bluetooth|wifi|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8752" PostTypeId="1" AcceptedAnswerId="8755" CreationDate="2015-02-19T18:24:18.813" Score="0" ViewCount="493" Body="&lt;p&gt;I tried my first project with Arduino Uno. But I can't upload any code. Power green LED is working and orange LED is always on, not blinking, and IC also getting hot. What can I do to fix this problem?&lt;/p&gt;&#xA;" OwnerUserId="7435" LastEditorUserId="4628" LastEditDate="2015-08-19T13:33:16.560" LastActivityDate="2016-05-15T18:34:46.427" Title="How to check whether my Arduino is working? And how to fix this?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8753" PostTypeId="2" ParentId="8743" CreationDate="2015-02-19T18:38:52.480" Score="2" Body="&lt;p&gt;SPI &#xA;The RFID_SS pin is the slave select pin.&#xA;So you can have another arduino pin for a LCD_SS select.&#xA;Having RfID_SS =low - talk to RFID.&#xA;Having LCD_SS =low talk to LCD via MISO.&#xA;Note: Drive other slave select High otherwise they'll both get the data.&#xA;Having only one device in communication at a time.&#xA;Cheers&#xA;Nik V&lt;/p&gt;&#xA;" OwnerUserId="7434" LastActivityDate="2015-02-19T18:38:52.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8754" PostTypeId="1" AcceptedAnswerId="8757" CreationDate="2015-02-19T19:05:43.037" Score="1" ViewCount="950" Body="&lt;p&gt;I'm trying to use &lt;a href=&quot;https://github.com/adafruit/Adafruit-LED-Backpack-Library&quot; rel=&quot;nofollow&quot;&gt;Adafruit's LED Backpack library&lt;/a&gt; within a custom class. When I use the Adafruit library directly within a sketch, it compiles fine. When I use an example sketch provided with the library, it compiles fine. However when I create an instance of my custom class with the Adafruit object within it, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In file included from sketch_feb18a.ino:6:&#xA;  /Users/lawnmowerlatte/Documents/Arduino/libraries/Bargraph/bargraph.h:18: error: 'Adafruit_24bargraph' does not name a type&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All the reasons I've seen for this error stem from the library being missing or otherwise incorrectly installed. However, since I can use it directly, I think something else must be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Working&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_LEDBackpack.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;Adafruit_24bargraph bar = Adafruit_24bargraph();&#xA;&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not Working&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;bargraph.h&amp;gt;&#xA;Bargraph bargraph = Bargraph(&quot;Test&quot;, &quot;api&quot;, 0);&#xA;&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bargraph.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef Bargraph_h&#xA;#define Bargraph_h&#xA;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;Adafruit_LEDBackpack.h&amp;gt;&#xA;&#xA;#if (ARDUINO &amp;gt;= 100)&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA;#include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&#xA;class Bargraph {&#xA;  public :&#xA;    String name;&#xA;    String api;&#xA;    Adafruit_24bargraph bar;&#xA;&#xA;    Bargraph(String _name, String _api, int _device,&#xA;        String _type=&quot;Default&quot;);&#xA;&#xA;    void set(String _value);&#xA;    void setMax(String _max);&#xA;    void update();&#xA;    void print();&#xA;&#xA;  private :&#xA;    int display[24];&#xA;&#xA;    long max;&#xA;    long value;&#xA;    int device;&#xA;    int size;&#xA;    String type;&#xA;&#xA;    void format();&#xA;    void write();&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bargraph.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define OFF 0&#xA;#define RED 1&#xA;#define YELLOW 2&#xA;#define GREEN 3&#xA;&#xA;#include &amp;lt;bargraph.h&amp;gt;&#xA;&#xA;#if (ARDUINO &amp;gt;= 100)&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA;#include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&#xA;Bargraph::Bargraph(String _name, String _api, int _device, String _type) : bar() {&#xA;    name        = _name;&#xA;    api         = _api;&#xA;    max         = _max.toLong();&#xA;    device      = _device;&#xA;    type        = _type;&#xA;    value       = 0;&#xA;&#xA;    for (int i=0; i&amp;lt;24; i++) {&#xA;        display[i] = OFF;&#xA;    }&#xA;&#xA;    bar.begin(0x70+device);&#xA;}&#xA;&#xA;**Methods Omitted for Brevity**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain what's going on here? I'm pretty certain my class syntax is correct as I have other object-in-object relationships working. I can post code to GitHub if anyone would like to see more context.&lt;/p&gt;&#xA;" OwnerUserId="7436" LastActivityDate="2017-02-28T16:06:20.417" Title="error: 'CLASS' does not name a type only when creating object inside another object" Tags="|arduino-mega|library|compile|adafruit|class|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8755" PostTypeId="2" ParentId="8752" CreationDate="2015-02-19T19:13:36.293" Score="1" Body="&lt;p&gt;My suggestion is to find someone else with an arduino, and get them to test (with their computer, known to be working) uploading to your Arduino. That way, you can tell if the problem is with your computer or the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't mentioned what your first project was. The most common mistake #1 is to light up an LED without a resistor. If you do that for a split second, you might (OR MIGHT NOT!) get away with it. If you leave it running for a few seconds, you are almost certainly going to burn out your AtMega (the IC on the board). This might very well result in the symptoms you describe. If this has happened, and your chip (IC) is removable (some are, some aren't), you should be able to buy a new chip of the same kind. An Arduino Uno has an AtMega 328, you will want a DIP package (they are the removable ones), and you will want one with an Arduino Bootloader pre-programmed. Replacing the chip may OR MAY NOT fix the problem. Make sure you note down the orientation of the broken chip before you pull it out - it will fit in, but won't work (and could burn out!) if you put it in the wrong way. There should be a little dimple at one end of the chip, right on the end. It should look like this (possibly without the pin labeling sticker): &lt;a href=&quot;http://www.jaycar.co.nz/productView.asp?ID=ZZ8726&amp;amp;w=atmega328&amp;amp;form=KEYWORD&quot; rel=&quot;nofollow&quot;&gt;http://www.jaycar.co.nz/productView.asp?ID=ZZ8726&amp;amp;w=atmega328&amp;amp;form=KEYWORD&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your chip is not removable, or replacing the chip doesn't help, then you will need to get a new Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-19T19:13:36.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8756" PostTypeId="2" ParentId="8571" CreationDate="2015-02-19T19:54:06.603" Score="1" Body="&lt;p&gt;I would use an array, they're about as simple as it gets. 84 clock cycles per sample is very tight, but definitely possible. I'm guessing that's too close to the line to do any sort time testing - you will probably have to set up your loop to take exactly 84 instructions. This means you will probably need to hand-code in assembler. Be very mindful of branching instructions - both branches will need to take the same number of clock cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno (AtMega328) runs most (all?) instructions in one clock cycle, I don't know if the same applies to the Due. You would need to hand-code the assembler, check out how many cycles each instruction takes, and pad it out (there is a do nothing &quot;NOP&quot; instruction, which typically takes one cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HOWEVER -&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get all this work done for you by using a chip made for this purpose. This is called a Digital Delay Line, &lt;a href=&quot;http://en.wikipedia.org/wiki/Digital_delay_line&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Digital_delay_line&lt;/a&gt; (or Analog Delay Line if you want analog values, e.g. for sound playback).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-19T19:54:06.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8757" PostTypeId="2" ParentId="8754" CreationDate="2015-02-19T19:54:28.660" Score="3" Body="&lt;p&gt;I think these lines still need to be in your main sketch file (in addition to being in your custom class file):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_LEDBackpack.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remember the Arduino IDE quirks correctly, it uses the &lt;code&gt;#include&lt;/code&gt; directives in the main sketch file to determine which libraries to actually link. It's one of those annoying features that was intended to be beginner-friendly but sometimes just makes things more confusing.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-02-19T19:54:28.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8758" PostTypeId="1" CreationDate="2015-02-19T23:33:25.110" Score="9" ViewCount="6895" Body="&lt;p&gt;I use the interrupt function to fill an array with values received from &lt;code&gt;digitalRead()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(115200);&#xA;    attachInterrupt(0, test_func, CHANGE);&#xA;}&#xA;&#xA;void test_func() {&#xA;    if (digitalRead(pin) == HIGH) {&#xA;        test_array[x] = 1;&#xA;    } else if(digitalRead(pin) == LOW) {&#xA;        test_array[x] = 0;&#xA;    }&#xA;    x = x + 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That problem is that when I print &lt;code&gt;test_array&lt;/code&gt; there are values like: &lt;code&gt;111&lt;/code&gt; or &lt;code&gt;000&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As I understand it, if I use the &lt;code&gt;CHANGE&lt;/code&gt; option in the &lt;code&gt;attachInterrupt()&lt;/code&gt; function, then the data sequence should always be &lt;code&gt;0101010101&lt;/code&gt; without repeating.&lt;/p&gt;&#xA;&lt;p&gt;The data changes quite fast since it comes from a radio module.&lt;/p&gt;&#xA;" OwnerUserId="7440" LastEditorUserId="7508" LastEditDate="2022-08-22T20:33:43.883" LastActivityDate="2022-08-22T20:33:43.883" Title="Arduino interruption (on pin change)" Tags="|arduino-uno|c|isr|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="8759" PostTypeId="1" CreationDate="2015-02-20T01:13:37.250" Score="2" ViewCount="179" Body="&lt;p&gt;I am planning to build a calculator using Arduino as the base. I already know C and I love low-level stuff, so I guess the software part won't be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've been stuck with Arduino. What I need is something capable of doing math (as I'm not even sure if Arduino has a FPU), and it to have enough inputs for more than the basic 0-9 &lt;code&gt;+ - / *&lt;/code&gt; keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a &lt;em&gt;real newbie&lt;/em&gt; when it comes to hardware. I don't even have the slightest clue where to start. I barely understand Arduino's specifications, which is why I'm asking here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to do something &lt;em&gt;more&lt;/em&gt; than the classic calculator, because the software part is not a problem. I just need help on which hardware should I choose; both on the 'which Arduino' and 'which accesories for the Arduino' parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I have some experience with x86 assembly; does that mean that 86duino or Intel Galileo are better for me?&lt;/p&gt;&#xA;" OwnerUserId="7322" LastActivityDate="2015-02-21T22:37:10.973" Title="What kind of Arduino should I pick for a calculator?" Tags="|build|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8760" PostTypeId="2" ParentId="8759" CreationDate="2015-02-20T01:21:12.947" Score="5" Body="&lt;p&gt;Start with the biggest (AVR) Arduino you can afford, and worry about miniaturizing it once you have the basics in place. You may find that you don't actually want an Arduino in the end, but something like the &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA169PA.aspx&quot; rel=&quot;noreferrer&quot;&gt;ATmega169PA&lt;/a&gt; instead so that you have native LCD support (instead of having to use a discrete LCD module).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;P.S. I have some experience with x86 assembly; does that mean that 86duino or Intel Galileo are better for me?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Doesn't matter. Most of your x86 assembly experience will easily transfer to AVR (but not all, since the AVR core is simpler than x86).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-20T01:21:12.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8761" PostTypeId="2" ParentId="8759" CreationDate="2015-02-20T01:50:53.543" Score="5" Body="&lt;p&gt;For the most part, none of the AVR based arduinos are any better at number crunching than any others. They all have a single AVR core running at 16Mhz. None have an FPU, but the software floating point code is very efficient and at the time scales you care about for a calculator, it really doesn't make much of a difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest differences between models are memory and available IO, so the decision between AVR models should probably come from what kind of peripherals you want to plug in, not what you want to calculate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, if you want to do a lot of high precision, numerical calculations (like numerical integration or something), you will probably want something with more memory, and floating point types larger than 32-bits. I don't have much experience with those models, but I'm pretty sure that a Yun or a Zero would be better suited for those kinds of calculations. They don't use AVR based main CPUs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For IO there are too many options to enumerate here. Take a look at the usual suspect's pages (sparkfun, adafruit, etc...) for displays and buttons. These sites have good descriptions and example code for everything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When picking devices, remember that you can have multiple I2C devices plugged in at once, but only one UART serial per port (uno/leonardo 1 port, mega 4). Software serial can give you more UARTs for low speed comms if need be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a lot of different individual buttons, there are ways to get more than 1 button per pin, but it would be a bit easier electrically to pick an arduino with as many pins as buttons. Some of the keypads available already have a special wiring scheme to get higher than 1-to-1 pin ratios and descriptions of how to use them, so they might be a good pick to get yourself started.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-02-21T22:37:10.973" LastActivityDate="2015-02-21T22:37:10.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8762" PostTypeId="1" CreationDate="2015-02-20T04:25:03.937" Score="2" ViewCount="2725" Body="&lt;p&gt;I have attached photo of the clone Uno board recently acquired, and I am working on a Mac OS X 10.7.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have sourced the solution from&#xA;&lt;a href=&quot;http://javacolors.blogspot.com/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://javacolors.blogspot.com/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which suggests to install 340/341CH drivers and run a sudo code. When I plug in the Uno board, the Arduino IDE still does not show under port selection, the &quot;dev.tty.usbserial&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and as such I cannot contact or upload any command to the Uno board. Been trying for a whole day.. please help if you know a possible solution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the board:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/AV3ks.jpg&quot; alt=&quot;Uno board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought the board from this site:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.aliexpress.com/item/UNO-KIT-Upgraded-version-of-the-For-Starter-Kit-the-RFID-learn-Suite-Stepper-Motor-ULN2003/1207142899.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.aliexpress.com/item/UNO-KIT-Upgraded-version-of-the-For-Starter-Kit-the-RFID-learn-Suite-Stepper-Motor-ULN2003/1207142899.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;screenshot from the IDE does now show any usbserial&#xA;&lt;img src=&quot;https://i.stack.imgur.com/YYyRK.png&quot; alt=&quot;IDE screenshot&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7442" LastActivityDate="2017-08-28T21:53:58.103" Title="Issue with usbserial for arduino clone" Tags="|serial|usb|mac-os|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8763" PostTypeId="2" ParentId="8762" CreationDate="2015-02-20T05:55:20.230" Score="0" Body="&lt;p&gt;This may be better asked on &lt;a href=&quot;http://apple.stackexchange.com&quot;&gt;http://apple.stackexchange.com&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the terminal run &lt;code&gt;ioreg -p IOUSB&lt;/code&gt; then plug in the Arduino and see what changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my Mac the setting is serial.port=/dev/tty.usbmodemfa131&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-02-20T05:55:20.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8764" PostTypeId="1" CreationDate="2015-02-20T06:14:44.333" Score="0" ViewCount="624" Body="&lt;p&gt;I am trying to do some experiments with conductive sheet (velostat). When I apply a force on the sheet it should change the value of resistance(output). I taking the output of the sheet by connecting to analog input Ao of Arduino. But I am not getting constant readings from arduino, even if no pressure is applied. Do I need to build any extra circuitry to stabilize the output value? Can anyone please tell how to stabilize the output value of Arduino?&lt;/p&gt;&#xA;" OwnerUserId="7443" LastActivityDate="2015-04-23T15:37:37.370" Title="Stabilizing output values of conductive sheet(Velostat) connected to analog pin A0 of Arduino" Tags="|arduino-uno|analogread|analogwrite|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8765" PostTypeId="1" AcceptedAnswerId="8771" CreationDate="2015-02-20T07:30:53.807" Score="2" ViewCount="424" Body="&lt;p&gt;I have an Arduino Yún running Openwrt-Yún 1.5.3 (which is the latest version, as I upgraded yesterday), and I am trying to obtain a .hex (compiled sketch), so that I can upload a sketch directly into the Yún. I know about compiled sketches, but there are no build directories in &quot;C:\Documents and Settings\MY_USERNAME\Local Settings\Temp&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can I obtain the .hex of any file I have compiled, and how?&lt;/p&gt;&#xA;" OwnerDisplayName="user6867" LastActivityDate="2015-02-20T17:09:36.607" Title="How can I obtain the .hex of a file" Tags="|arduino-yun|compile|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8766" PostTypeId="2" ParentId="8626" CreationDate="2015-02-20T09:36:10.973" Score="0" Body="&lt;p&gt;Since you are already using Arduino, I think you not should use atmega, but must! To prevent future headaches, since you look new to electronics, I HIGHLY recommend to check for app notes by Atmel. Just type it &quot;Atmel app notes&quot; at google and you will find a lot of useful tips. Some of them are start to routing by crystal resonator, them GND and Vcc. Use, if possible, on each IC a 100nF ceramic SMT capacitor nearest as possible and another one of 10uF (can be electrolytic) on most robust ones (like microcontroler). Always route opposite signals (like Vcc and GND) tied together with the same size to low its impedance... If you are doing with high inductance loads you should use another sorce (and maybe also a diode as rectifier or an optocoupler).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a lot of good practices and if you want to sell your work, you really have to study them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck! Also look for the electronics SE&lt;/p&gt;&#xA;" OwnerUserId="7445" LastActivityDate="2015-02-20T09:36:10.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8767" PostTypeId="2" ParentId="4680" CreationDate="2015-02-20T10:33:33.227" Score="0" Body="&lt;p&gt;One of the best ways to controll a motor is to look in to the motor shields from the arduino. You can buy seperate motor controllers with different throughput, some advanced with breaking and some without.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But motorshield is about the best way to get started.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-02-20T10:33:33.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8769" PostTypeId="2" ParentId="8764" CreationDate="2015-02-20T13:49:28.607" Score="1" Body="&lt;p&gt;You need to use a matching resistance to create a voltage divider.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-02-20T13:49:28.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8770" PostTypeId="2" ParentId="8758" CreationDate="2015-02-20T14:41:28.197" Score="6" Body="&lt;p&gt;The interrupt is being set to fire on a change, and your test_func is set as the Interrupt Service Routine (ISR), called to service that interrupt. The ISR then prints the value of the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first glance you would expect the output to be as you have said, and alternating set of high lows, as it only gets to the ISR on a change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what we're missing is that there is a certain amount of time that it takes for the CPU to service an interrupt and branch to the ISR.&#xA;During this time the voltage on the pin may have changed again. Particularly if the pin is not stabilised by hardware de-bouncing or similar. Because the interrupt is already flagged and hasn't been serviced yet, this extra change (or many of them, because a pins level can change very quickly relative to the clock speed if it has low parasitic capacitance) will be missed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in essence without some form of de-bouncing, we have no guarantee that when the input changes, and the interrupt gets marked for servicing, that the input will still be at the same value when we get to reading its value in the ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a generic example the &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;ATmega328&quot;&gt;ATmega328 Datasheet&lt;/a&gt;  used on the Arduino Uno details interrupt times in section 6.7.1 - &quot;Interrupt Response Time&quot;. It states for this microcontroller the minimum time to branch to an ISR for servicing is 4 clock cycles, but can be more (extra if executing multi-cycle instruction at interrupt or 8 + sleep wake time if the MCU is in sleep.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @EdgarBonet mentioned in comments, the pin could also similarly change during ISR execution. Because the ISR reads from the pin twice, it would not add anything to the test_array if it encountered a LOW on the first read and a HIGH on the second. But x would still increment, leaving that slot in the array unchanged (possibly as uninitialised data depending on what was done to the array earlier).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;His one line ISR of &lt;code&gt;test_array[x++] = digitalRead(pin);&lt;/code&gt; is a perfect solution to this.&lt;/p&gt;&#xA;" OwnerUserId="7450" LastEditorUserId="3821" LastEditDate="2019-02-23T00:41:22.323" LastActivityDate="2019-02-23T00:41:22.323" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8771" PostTypeId="2" ParentId="8765" CreationDate="2015-02-20T17:09:36.607" Score="1" Body="&lt;p&gt;As noted in comments, enable verbose compilation and look at the output to find the temporary-directory location. (Click File, Preferences, verbose compilation.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, after you click File, Preferences and the preferences window appears with its half-dozen items, you should also see a note about directly editing preferences in the preferences.txt file.  Edit that file (using a plain-text editor, not a word processor) when the arduino IDE is not running.  Change the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;preproc.save_build_files=false&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;preproc.save_build_files=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so the .hex files in the temporary directory have a better chance of sticking around.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm not able to test this suggestion on an MS-Windows system.  On my Linux system most build files stick around anyway in /tmp/)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-02-20T17:09:36.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8772" PostTypeId="2" ParentId="8659" CreationDate="2015-02-20T17:29:50.250" Score="2" Body="&lt;p&gt;My experience of high power draw from an Arduino is that it endlessly re-boots so maybe not the issue for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Servo library and PWM pins are probably sharing the same timer therefore motors stop while servos are running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try a different Servo library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;https://stackoverflow.com/questions/18705363/arduino-uno-pwm-pins-conflict&quot;&gt;article&lt;/a&gt; is useful to understand the timer/pwm/pin relationships&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-02-22T22:55:59.853" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8773" PostTypeId="1" CreationDate="2015-02-20T18:22:51.357" Score="1" ViewCount="169" Body="&lt;p&gt;Do you know an IDE that is Arduino compatible, with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Black background; white hurts my eyes.&lt;/li&gt;&#xA;&lt;li&gt;Some auto completion features maybe?&lt;/li&gt;&#xA;&lt;li&gt;And also one that lets you minimise brackets. Xcode like.&lt;/li&gt;&#xA;&lt;li&gt;A better console...&lt;/li&gt;&#xA;&lt;li&gt;Something to clear the serial console.&lt;/li&gt;&#xA;&lt;li&gt;A &lt;strong&gt;breadboard view&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Something fancy!&lt;/p&gt;&#xA;" OwnerUserId="4951" LastEditorUserId="4951" LastEditDate="2019-01-29T17:10:12.167" LastActivityDate="2019-01-29T17:10:12.167" Title="Fancy Arduino IDE" Tags="|programming|ide|" AnswerCount="2" CommentCount="1" ClosedDate="2015-02-22T03:34:40.417" ContentLicense="CC BY-SA 4.0" />
  <row Id="8774" PostTypeId="2" ParentId="3148" CreationDate="2015-02-20T18:34:05.507" Score="1" Body="&lt;p&gt;Because pins 0 and 1 (physical 5,6) are PWM's you should keep them for later ...&#xA;and you still have A3 and A2 for analogWrite so,&#xA;you should use Pin 2 (Physical 7, next to +5V) like this : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;add this in the setup function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(2, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add this in your loop function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(2,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GwRJ9.png&quot; alt=&quot;In case you forget&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference : &#xA;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints&quot; rel=&quot;nofollow noreferrer&quot;&gt;SparkFun's Help guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember : Physical pin &quot;1&quot;, reset, has a dot  marked on it. &lt;/p&gt;&#xA;" OwnerUserId="4951" LastEditorUserId="4951" LastEditDate="2015-02-20T18:39:41.323" LastActivityDate="2015-02-20T18:39:41.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8775" PostTypeId="1" CreationDate="2015-02-20T19:12:33.793" Score="2" ViewCount="298" Body="&lt;p&gt;I spent the last week working with the CylonJS framework on my edison using a Maxbotix sensor.&#xA;Everyting works with a web client on the front end.&#xA;However at the last moment I can't get the edison to talk to an existing AIR client which I must use.&#xA;Something to do with how socketIO is implemented in Cylon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following simple socketIO server works for me. What I need to do is incorporate support for the mraa library and get analogue input from the Maxbotix sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone please help? I'm up against a deadline!!!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var express = require('express');&#xA;    var app = express();&#xA;    var server = require('http').createServer(app);&#xA;    var io = require('socket.io').listen(server,{transports:['flashsocket', 'websocket', 'htmlfile', 'xhr-polling', 'jsonp-polling']});&#xA;     var port = Number(8080);&#xA;    server.listen(port);&#xA;     app.use(express.static(__dirname + '/'));&#xA;     var temp;&#xA;     var _this = this;&#xA;     io.on('connection', function (socket) {&#xA;      console.log('connection '+socket)&#xA;     socket.on(&quot;data&quot;,function(d){console.log('data from flash: ',d);});&#xA;      socket.emit(&quot;message&quot;,&quot;wtfwtwftwftwf hello from server&quot;);&#xA;      socket.on('disconnect', function (socket) {&#xA;      console.log(&quot;disconnect&quot;);&#xA;  });&#xA;&#xA;  console.log('_this ='+_this);&#xA;  _this.socket=socket;&#xA;&#xA;&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7454" LastActivityDate="2015-02-20T19:12:33.793" Title="getting simple socketIO server to work with MRAA library on Edison" Tags="|node.js|edison|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8778" PostTypeId="2" ParentId="8773" CreationDate="2015-02-20T20:05:52.580" Score="3" Body="&lt;p&gt;Have a look at Fritzing. I don't know how much you can customize there, but it has a whole suite where you can design hardware, write code, and even order PCB if you want to.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="4628" LastEditDate="2017-04-20T15:24:17.843" LastActivityDate="2017-04-20T15:24:17.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8779" PostTypeId="1" AcceptedAnswerId="8789" CreationDate="2015-02-20T20:22:22.787" Score="1" ViewCount="98" Body="&lt;p&gt;I bought Ethernet Shield for Arduino Uno! from AliExpress. It is good work but I scanned my network with &lt;a href=&quot;https://i.stack.imgur.com/K4G8Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fing&lt;/a&gt; and device Vendor name is null.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I change/set device Vendor?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  &#xA;byte ip[] = { 10, 0, 0, 106 };    &#xA;&#xA;void setup()&#xA;{&#xA;  Ethernet.begin(mac, ip);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6405" LastActivityDate="2015-02-21T07:31:36.827" Title="Arduino Ethernet Shield vendor is null" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8780" PostTypeId="2" ParentId="8773" CreationDate="2015-02-20T21:03:06.377" Score="2" Body="&lt;p&gt;I believe Eclipse can do everything you mentioned except for showing hardware layouts. The appearance of editor windows is customizable. If, by minimizing brackets, you mean collapsing them (&quot;just indicate that something is here; I don't want to see the content&quot;), Eclipse does that too. You can clear the console, but I don't know what &quot;better&quot; features you mean so I can't answer that part. It can take some setting up to get it working for you but it's far and away more powerful and feature-filled than the basic Arduino IDE. It is probably the most used IDE by people who look to upgrade from the basic one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;While it doesn't directly show hardware layouts, it does know about opening files with their default applications. If you put a Fritzing file in your project folder, when you click on it, Eclipse will launch Fritzing. If you put an image file such as a screenshot of the board layout, it will even open that within the IDE.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2017-04-20T12:53:06.143" LastActivityDate="2017-04-20T12:53:06.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8781" PostTypeId="1" CreationDate="2015-02-20T22:10:42.130" Score="4" ViewCount="6766" Body="&lt;p&gt;I'm working on a project that uses an Arduino Uno to listen for a bell ring and then uploads to a web server the exact time the bell was rung using a WiFi Shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know how I can listen for the bell ring (a three second long high pitch tone) and be able to detect that that's what the Arduino heard. I think the best way may be to pre-record the sound and then the Arduino will constantly try to match the incoming sounds to the prerecorded sound. I'm wondering how I could go about doing this (or are there better methods).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bell sounds kind of like this: &lt;a href=&quot;http://onlinetonegenerator.com/?waveform=square&amp;amp;freq=332&quot; rel=&quot;nofollow&quot;&gt;bell sound&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7456" LastEditorUserId="7456" LastEditDate="2015-02-22T00:08:21.387" LastActivityDate="2015-02-22T07:03:20.080" Title="How do I listen for a sound that matches a pre-recorded sound?" Tags="|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8782" PostTypeId="1" CreationDate="2015-02-20T22:10:56.660" Score="3" ViewCount="12433" Body="&lt;p&gt;I'd like to use Timer1 to measure the time between rising edges of two input signals.  Specifically, use Tn to start the timer counter and IPCn to latch the elapsed time since the rising edge of the Tn input signal.  The goal is to measure the time between the rising edges of two input signals.   Is there a Timer1 library out there that alread does this?  Code suggestions welcomed. &lt;/p&gt;&#xA;" OwnerUserId="7457" LastActivityDate="2021-05-21T13:29:49.787" Title="How to use Timer1 (AT328Mega) to measure the time between rising edges of two input signals" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8783" PostTypeId="2" ParentId="8156" CreationDate="2015-02-20T22:22:26.313" Score="1" Body="&lt;p&gt;The problem is with the magnetometer: &#xA;&quot;The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller!&quot;&#xA;&lt;a href=&quot;https://learn.adafruit.com/adafruit-hmc5883l-breakout-triple-axis-magnetometer-compass-sensor/wiring-and-test&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wiring and Test&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it says it in the specs on page 2:&#xA; I2C Address &#xA;8-bit read address 0x3D&#xA;8-bit write address 0x3C&#xA;&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;3-Axis Digital Compass IC HMC5883L&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Low cost magnetometers appear to have fixed I2C addresses. One solution would be to get a different one in addition to yours. For example, the MAG3110 has I2C address 0x0E and the FXMS3110CDR1 has I2C address 0x0F. &#xA;&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Sensors/Magneto/MAG3110_v9.2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Xtrinsic MAG3110 Three-Axis, Digital&#xA;Magnetometer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information on this page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/130235/how-to-connect-multiple-of-the-same-device-to-an-arduino-using-i2c&quot;&gt;How to connect multiple of the same device to an Arduino using I2C?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. You are more likely to get an answer to your second question by posting it separately (and help others in the process). &lt;/p&gt;&#xA;" OwnerUserId="7458" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-20T22:22:26.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8784" PostTypeId="1" CreationDate="2015-02-20T23:15:47.770" Score="0" ViewCount="510" Body="&lt;p&gt;I'm new so I might be making a stupid mistake, but I'm declaring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;char dollars;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;at the begging of file, afterwards I'm reading a data from a web page, printing it to my serial. That part work well. The data returned from the web page is a number, 55 for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number get's printed correctly to the serial. But when I try to save the complete number it changes. for instance, when I get 0 from the server. The printed result is 10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the important part of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastRead = millis();&#xA;  while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    while (www.available()) {&#xA;      char c = www.read();&#xA;      Serial.print(c);&#xA;      dollars = www.read();&#xA;      lastRead = millis();&#xA;    }&#xA;  }&#xA;&#xA;  www.close();&#xA;  Serial.println(dollars);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;while the www.read is repeating each of the returned characters it works fine &lt;code&gt;Serial.print(c);&lt;/code&gt; but when I save it to the dollars char var, it get garbled up into something different. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm planning to show that number from the web page onto my 4 digit screen at the end.&lt;/p&gt;&#xA;" OwnerUserId="7460" LastActivityDate="2015-07-26T08:51:21.253" Title="Arduino UNO + CC3000 Wifi Shield, Reading webpage data" Tags="|arduino-uno|serial|wifi|variables|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8785" PostTypeId="2" ParentId="8782" CreationDate="2015-02-20T23:40:16.440" Score="2" Body="&lt;p&gt;It is not perfect for your simpler task, but here is a link to a &lt;a href=&quot;https://gist.github.com/mpflaga/4404996&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; that I have used to record pulses, using the Timer1 Input Capture. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short setup the Interrupt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void initTimer(void) {&#xA;&#xA;  // Input Capture setup&#xA;  // ICNC1: Enable Input Capture Noise Canceler&#xA;  // ICES1: =1 for trigger on rising edge&#xA;  // CS10: =1 set prescaler to 1x system clock (F_CPU)&#xA;  TCCR1A = 0;&#xA;  TCCR1B = (0&amp;lt;&amp;lt;ICNC1) | (0&amp;lt;&amp;lt;ICES1) | (1&amp;lt;&amp;lt;CS10);&#xA;  TCCR1C = 0;&#xA;&#xA;  //catchFallingEdge(); // initialize to catch&#xA;  { TCCR1B &amp;amp;= ~(1&amp;lt;&amp;lt;ICES1); TIFR1 |= (1&amp;lt;&amp;lt;ICF1); rising = 0; }&#xA;&#xA;  // Interrupt setup&#xA;  // ICIE1: Input capture&#xA;  // TOIE1: Timer1 overflow&#xA;  TIFR1 = (1&amp;lt;&amp;lt;ICF1) | (1&amp;lt;&amp;lt;TOV1);        // clear pending&#xA;  TIMSK1 = (1&amp;lt;&amp;lt;ICIE1) | (1&amp;lt;&amp;lt;TOIE1); // and enable&#xA;&#xA;  // Set up the Input Capture pin, ICP1, which corresponds to Arduino D8&#xA;  pinMode(8, INPUT);&#xA;  digitalWrite(8, 0);       // leave floating to count 60 Hz etc.&#xA;  //digitalWrite(8, 1);         // or enable the pullup&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then service it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_CAPT_vect) {&#xA;  union twobyte {&#xA;    uint32_t word;&#xA;    uint8_t  byte[2];&#xA;  } timevalue;&#xA;&#xA;  timevalue.byte[0] = ICR1L;        // grab captured timer value&#xA;  timevalue.byte[1] = ICR1H;        // grab captured timer value&#xA;&#xA;  // watch for the other edge to catch the half-pulse width&#xA;  //rising ? catchFallingEdge() : catchRisingEdge();&#xA;  if (rising) {&#xA;    TCCR1B &amp;amp;= ~(1&amp;lt;&amp;lt;ICES1);&#xA;    TIFR1 |= (1&amp;lt;&amp;lt;ICF1);&#xA;    rising = 0;&#xA;  }&#xA;  else {&#xA;    TCCR1B |= (1&amp;lt;&amp;lt;ICES1);&#xA;    TIFR1 |= (1&amp;lt;&amp;lt;ICF1);&#xA;    rising = 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-02-20T23:40:16.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8786" PostTypeId="2" ParentId="812" CreationDate="2015-02-21T00:03:08.140" Score="0" Body="&lt;p&gt;The following will work and meets the requirement that the heater does not auto turn on when powered up. You need to turn the heater on manually, so no different from existing, and this then allow you to either &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Power it down at a preselected time of day, provided the Arduino is able to keep track of time, or &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Arduino will turn it off a set period after it has started to heat. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latter is easier to do and meets the need well enough.&lt;br&gt;&#xA;The only technical requirements are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Able to sense current drawn by heater.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Able to turn a heater control relay on/off &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Able to set or select a time delay on Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of these, the current detection is hardest and even then, not very hard. Possible means include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Current transformer connected to heater lead.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Opto isolator with LED in series with lead with suitable parallel resistor across opto LED to drop enough voltage to trigger opto on voltage peaks when heater is on,  and backwards diode across opto LED for reverse mains cycles. This provides a series of pulses to Arduino when heater is on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Equipment:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino controlled external relay or solid state relay.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some means of detecting that heater is drawing current - timer mode only.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino cct can:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Detect current draw.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn relay off/on &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Be programmed to either stop time or run time. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Drives external relay or solid state relay. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Optional: Relay defaults on. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Then:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set external Arduino timer to desired time.&lt;br&gt;&#xA;Arduino sets relay ON.&lt;br&gt;&#xA;Set heater to desired start time.&lt;br&gt;&#xA;When heater start Arduino sees current and starts timing, or in time of day mode just turns off power at correct time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This keeps all circuitry external.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-21T05:12:46.163" LastActivityDate="2015-02-21T05:12:46.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8787" PostTypeId="1" CreationDate="2015-02-21T01:23:17.597" Score="2" ViewCount="1165" Body="&lt;p&gt;I'm attempting to drive 300 TM1803 RGB LEDs from an Arduino Uno using the FastLED library. My code works fine for 100 LEDs, but when I go to 150, the arrays that store LED values and my sensor data get corrupted, causing the LEDs to flash colors randomly every few seconds. From what I've read these are exactly the symptoms of running out of RAM, leading to something overwriting the RAM that contains my arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with 150 LEDs, the MemoryFree library says I'm only using 920 bytes of RAM, no matter where in my code I measure, and the IDE says 880. Does anybody know what's going on? Is there something using 1100 bytes of RAM for a very short amount of time, so that I can't measure it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;FastLED.h&quot;&#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;const byte ledsPin = 3;&#xA;const byte sensorPin = A1;&#xA;&#xA;const int numLeds = 300;&#xA;const int ledTime = 1000;&#xA;&#xA;const int sensorMin = 0;&#xA;const int sensorMax = 512;&#xA;&#xA;const CRGB correction = CRGB(80,255,70); // Cool white&#xA;//const CRGB correction = CRGB(160,255,20); // Warm white&#xA;const byte hOffset = 170; // baseline hue value&#xA;const int8_t hDirection = -1; // 1 or -1, direction of rainbow&#xA;const byte s = 255; // saturation (colorfulness)&#xA;const byte v = 255; // value (brightness)&#xA;&#xA;const unsigned int arrayLength = numLeds+1;&#xA;byte hues[arrayLength];&#xA;&#xA;CRGB leds[numLeds];&#xA;byte h = 0; // hue (color)&#xA;&#xA;unsigned long sensorSum;&#xA;unsigned int loopCounter;&#xA;unsigned int arrayCounterLed;&#xA;unsigned int updatesPerLed;&#xA;char sp = ' ';&#xA;int arrayCounter;&#xA;&#xA;unsigned long time;&#xA;unsigned long timeNextLed;&#xA;unsigned long timeLeft;&#xA;unsigned long time1;&#xA;byte route;&#xA;&#xA;void setup() {&#xA;  FastLED.addLeds&amp;lt;TM1803, ledsPin, RBG&amp;gt;(leds, numLeds).setCorrection(correction);&#xA;  FastLED.setDither(0);&#xA;  pinMode(ledsPin, OUTPUT);&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(10);&#xA;  time=millis();&#xA;  sensorSum += analogRead(sensorPin);&#xA;  loopCounter++;&#xA;  if(time &amp;gt;= timeNextLed) {&#xA;    timeNextLed = (time/ledTime+1)*ledTime;&#xA;    arrayCounter = (arrayCounter +1) % (arrayLength);&#xA;    hues[arrayCounter] = (constrain(map(hDirection*sensorSum/loopCounter, sensorMin, sensorMax, 0, 239), 0, 239)+hOffset)%256;&#xA;    updatesPerLed = loopCounter;&#xA;    loopCounter=0;&#xA;    sensorSum = 0;&#xA;  }&#xA;  for(int led = 0; led &amp;lt; numLeds; led++) {&#xA;    time1=micros();&#xA;    arrayCounterLed = pseudoMod(arrayCounter - led -1, arrayLength);&#xA;    timeLeft = timeNextLed-time;&#xA;    byte dist = abs(hues[arrayCounterLed]-hues[(arrayCounterLed+1)%(arrayLength)]);&#xA;    if(abs(hues[arrayCounterLed]-hues[(arrayCounterLed+1)%(arrayLength)])&amp;lt;=128) { // if it doesn't cross through 0&#xA;      h = (hues[arrayCounterLed]*timeLeft + hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft))/ledTime;&#xA;    }&#xA;    else if(hues[arrayCounterLed] &amp;gt; hues[(arrayCounterLed+1)%(arrayLength)]) { // if it crosses through 0 forwards&#xA;      h = ((hues[arrayCounterLed]*timeLeft + (hues[(arrayCounterLed+1)%(arrayLength)]+256)*(ledTime-timeLeft))/ledTime)%256; // Causing flashing on red pixels?&#xA;    }&#xA;    else { // if it crosses through 0 backwards&#xA;      h = (((hues[arrayCounterLed]+256)*timeLeft + hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft))/ledTime)%256;&#xA;    }&#xA;    time1 = micros() - time1;&#xA;    if(led == 0) {&#xA;      Serial.print(dist);&#xA;      Serial.print(sp);&#xA;      Serial.print(route);&#xA;      Serial.print(sp);&#xA;      Serial.print(timeLeft);&#xA;      Serial.print(sp);&#xA;      Serial.print(hues[arrayCounterLed]);&#xA;      Serial.print(sp);&#xA;      Serial.print(hues[(arrayCounterLed+1)%(arrayLength)]);&#xA;      Serial.print(sp);&#xA;      Serial.print(hues[arrayCounterLed]*timeLeft);&#xA;      Serial.print(sp);&#xA;      Serial.print(hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft));&#xA;      Serial.print(sp);&#xA;      Serial.println(h);&#xA;    }&#xA;    leds[led] = CHSV(h, s, v);&#xA;  }&#xA;  FastLED.show();&#xA;  Serial.print(updatesPerLed);&#xA;  Serial.print(time1);&#xA;  Serial.println();&#xA;}&#xA;&#xA;int pseudoMod(int a, int b) {&#xA;  if(a&amp;lt;0) {&#xA;    return a+b;&#xA;  } &#xA;  else {&#xA;    return a;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="819" LastEditorUserId="220" LastEditDate="2015-02-22T03:15:04.130" LastActivityDate="2015-02-22T03:15:04.130" Title="Am I Running Out of RAM Or Not?" Tags="|arduino-uno|debugging|memory-usage|sram|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8788" PostTypeId="2" ParentId="8781" CreationDate="2015-02-21T05:31:20.973" Score="3" Body="&lt;p&gt;About the simplest starting point is to use an FFT (&lt;a href=&quot;http://en.wikipedia.org/wiki/Fast_Fourier_transform&quot; rel=&quot;nofollow noreferrer&quot;&gt;fast Fourier transform&lt;/a&gt;) library (like &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArduinoFFT&lt;/a&gt; at openmusiclabs.com) to characterize the spectrum of an audio stream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;em&gt;Edit:&lt;/em&gt; An alternative method (digital bandpass filter) is mentioned below.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Audio typically is made up of many frequencies of many amplitudes and phases, mixed together.  FFT sorts some of that out; it estimates the amplitudes of the various frequencies that make up a bit of audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general idea is to use an Arduino ADC to take readings of an audio voltage for a fraction of a second, then use FFT to convert the large set of readings to a small set of numbers, in eg a set of 32 or 64 frequency-bins, to represent amplitudes in given frequency ranges.  For example, if the sound during a sample is a mix of five sine waves at five frequencies, the bins those five frequencies are in should have large numbers assigned, while other bins should have small numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The approach would amount to sampling at 10KHz for 0.1 second or so, computing an FFT with 32, 64, etc. bins in the next 0.1 second, and comparing bin counts to a training pattern.  Whenever bin count patterns match reasonably well, start a three-second timer; if several seconds of matching samples occur, declare a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the bell is electronically generated and mostly a mix of pure sine waves, then its sound will have an easily recognized spectrum.  But if the sound source is buzzy and there is background noise, it may be difficult to compare spectra.  See eg&lt;br&gt;&#xA;• &lt;a href=&quot;https://dsp.stackexchange.com/q/15105/comparing-an-audio-signal-with-a-previous-taught-profiled-signal&quot;&gt;Comparing an audio signal with a previous 'taught/profiled' signal&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;https://dsp.stackexchange.com/q/14827&quot;&gt;How do I compare chords played on a guitar with a known sample?&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;https://dsp.stackexchange.com/q/1867&quot;&gt;How do I compare 2 audio files, returning a percentage of difference&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;https://dsp.stackexchange.com/q/15239/what-does-the-phase-of-a-fft-bin-of-an-audio-signal-represent&quot;&gt;What does the phase of a FFT bin of an audio signal represent?&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;http://developer.nokia.com/community/wiki/Sound_pattern_matching_using_Fast_Fourier_Transform_in_Windows_Phone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sound pattern matching using Fast Fourier Transform in Windows Phone&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;https://dsp.stackexchange.com/q/9358&quot;&gt;How do I go about detecting whistles, pops and other sounds in live audio input?&lt;/a&gt;&lt;br&gt;&#xA;• &lt;a href=&quot;http://music.columbia.edu/cmc/musicandcomputers/chapter3/03_04.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;The Frequency Domain&#xA;Section 3.4: The DFT, FFT, and IFFT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;An alternative: digital bandpass filter&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital bandpass filters are based on processing a signal in a way that detects the amplitude of the signal's frequency component within designated limits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For theoretical background see wikipedia's &lt;em&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Digital_filter&quot; rel=&quot;nofollow noreferrer&quot;&gt;Digital filter&lt;/a&gt;&lt;/em&gt; article.  Also see &lt;a href=&quot;http://dea.brunel.ac.uk/cmsp/Home_Saeed_Vaseghi/Chapter05-DigitalFilters.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vaseghi, Chapter 5, Digital Filters&lt;/a&gt;, (eg section 4.6.6, Design of Band-Pass FIR Filters) pdf file and&#xA;&lt;a href=&quot;https://engineering.purdue.edu/~ece438/lecture_notes/legacy_notes/module_1/1.7_dig_filter_design/1.7.3_iir_filter_design.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ECE438 digital filter design lecture notes&lt;/a&gt;&#xA;pdf file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use MatLab or Octave to do most of the work of designing a filter.  For example, if you have the Signal package installed and loaded into Octave, commands like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;v=cl2bp(30, 0.48*pi, 0.52*pi, [0.02, 1.02, 0.02], [-0.02, 0.98, -0.02], 2^11);&#xA;freqz(v);&#xA;v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will compute coefficients for a &lt;a href=&quot;http://octave.sourceforge.net/signal/function/cl2bp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Constrained L2 bandpass FIR filter&lt;/a&gt;, plot the freqency response (as below), and display the 60 coefficients.  To use the filter, copy the 30 non-zero coefficients into a program, set up a rolling array of readings, and at each sample compute a new filtered value.  If at some point high filtered values occur, and if they recur for about three seconds at the bell's frequency or twice its frequency, then the bell is ringing.  Note, there are other kinds of bandpass filters; the Constrained L2 bandpass FIR filter is shown for convenience, but other kinds may be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kzq1M.jpg&quot; alt=&quot;Octave graph of freqz&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are unfamiliar with signal processing, you might need to try the following approach:&lt;br&gt;&#xA;1, On your development system, obtain a few seconds of audio to use for tests. (Eg, allocate two buffers of several dozen bytes each; fill one buffer while using the other buffer to send data from the Uno to your development system.  Use (eg) &lt;a href=&quot;http://arduino.cc/en/Serial/write&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial.write(buf, len)&lt;/a&gt; and a high data rate, eg 115200 bps, to send binary data, with three ADC readings packed per four bytes.)&lt;br&gt;&#xA;2, Use Octave or similar software to try out several different FFT or filter approaches.  You would use FFT to determine the bell's fundamental frequency and then could try out digital bandpass filters while developing a recognizer.  You can also use &lt;a href=&quot;http://www-users.cs.york.ac.uk/~fisher/mkfilter/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mkfilter&lt;/a&gt; to design filters to try out in C programs on your system, and should be able to iterate more quickly while developing your approach than if you were developing it using the Uno.  When you get satisfactory results on your development system, you then can code a sketch to test the technique on your Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, for a given filter order, filters implemented using fixed-point integer arithmetic on an Uno can handle more samples per second than those implemented using floating arithmetic.  An Uno might support 50000 to 100000 floating multiplies and adds per second (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=40901.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;https://gist.github.com/projectgus/8279947&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;http://www.engblaze.com/faster-code-fridays-understand-division-and-speed-of-operations/&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;,&lt;a href=&quot;https://robotics.stackexchange.com/questions/535/how-computationally-powerful-is-an-arduino-uno-board&quot;&gt;4&lt;/a&gt;), vs. two to four times as many fixed-point operations per second.  If your filter uses a dozen floating point ops per sample, your sample rate probably would have to be under 5000 samples per second.  If it uses half as many floating ops or uses fixed point instead of floating point, your sample rate could be twice as much.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:49:17.743" LastActivityDate="2015-02-22T07:03:20.080" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8789" PostTypeId="2" ParentId="8779" CreationDate="2015-02-21T07:31:36.827" Score="3" Body="&lt;p&gt;The vendor name is not stored on the device, rather it is indicated only by the first three octets or OUI part of the MAC address which is either stored on the device, or in your case set up by software.  Turning this back into a name on another computer which sees its traffic is done by the help of a local or network-sourced OUI lookup table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently the table your computer is consulting doesn't have an entry for the OUI 0xDE, 0xAD, 0xBE.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's not surprising as this is clearly a dummy value put in as a placeholder - read all 6 octets as if they were a word and you'll see it says &quot;dead beef feed&quot; - a variation on a classic magic &quot;illegal&quot; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically, this is actually a legal value for use on a local network as the 2's bit of the leading octet is turned on, indicating that it is a &quot;locally administered&quot; address, rather than one guaranteed to be unique in all the world as you would expect a proper piece of network hardware to have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find the table your computer is doing OUI lookups in, you could add a DE:AD:BE entry to it.  &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-02-21T07:31:36.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8790" PostTypeId="2" ParentId="8659" CreationDate="2015-02-21T07:50:28.973" Score="1" Body="&lt;p&gt;Here are a few suggestions that might help:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Provide its own power supply to Arduino UNO&lt;/strong&gt;, so that no voltage drop can occur on the board itself due to high energy consumers as servos and DC motors. As someone suggested in an answer, a voltage drop on Arduino MCU may trigger the Brown-Out Detection (BOD) which will stop the MCU until voltage rises up again, above a given threshold. You could for instance power the UNO with a 9V battery (or the equivalent 7.2V rechargeable pack). Those batteries don't have much energy but it should be OK as long as they are not used for powering motors. Of course, then you'll have to remove the &lt;code&gt;Vin&lt;/code&gt; wire to your 8-batteries pack.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add decoupling caps&lt;/strong&gt; (between &lt;strong&gt;V+&lt;/strong&gt; and &lt;strong&gt;GND&lt;/strong&gt;) as near as possible to every energy consumer: that means adding decoupling for each &lt;strong&gt;motor driver&lt;/strong&gt; power-in pins, for each &lt;strong&gt;servo&lt;/strong&gt; power pins, and ALSO for the &lt;strong&gt;HC-SR04&lt;/strong&gt; sonar sensor (in my experience, it can drop voltage a lot, more than you could expect); note that you may also need decoupling for the &lt;strong&gt;camera&lt;/strong&gt;, but I'm not sure on this one, because I have never used one yet.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note on decoupling caps&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of caps to use depend on many factors, which would be too long to explain here (and I admit that I don't necessarily understand each of these); but typically, you would use &lt;strong&gt;a small cap (100nF)&lt;/strong&gt; when you expect &lt;strong&gt;fast (and short) voltage drops&lt;/strong&gt;, and &lt;strong&gt;a bigger cap (&gt;=10uF)&lt;/strong&gt; when you expect &lt;strong&gt;longer voltage drops&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you don't know, you can just experiment and see what works best. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using both kinds of caps at the same time (in parallel) does no harm (I have done this in several situations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For higher caps, you will have to use an &lt;strong&gt;electrolytic cap&lt;/strong&gt;, which is polarized: &lt;strong&gt;do make sure that you wire them correctly (+/+, -/-) otherwise they may blow up&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, choose a &lt;strong&gt;breakdown voltage&lt;/strong&gt; for the cap that is much above (I'd say 50% above is fine) your power voltage; &lt;strong&gt;16V&lt;/strong&gt; is a common value that would fit your needs; of course, you can use higher breakdown voltages as well.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-02-21T07:50:28.973" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8791" PostTypeId="1" CreationDate="2015-02-21T12:48:33.490" Score="0" ViewCount="229" Body="&lt;p&gt;I community! I need put ATcommand to my XBee from my atmega using a &quot;xbee library&quot; and a function that I have found in internet. I think the ATComand is &quot;ATD50&quot; to change the DIO5 to value &quot;0&quot; (disabled). My intention is to turn off a led connected into DIO5 (digital input/output 5 (associated led)) after X second/minutes of turning on the device (so that it doesn't turn one again after initial check). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a part of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;XBee xbee = XBee();&#xA;uint8_t atdCmd[] = {'A','T','D','5','0'}; //&amp;lt;---command to put DIO5 to &quot;0&quot; (disabled)&#xA;AtCommandRequest atRequest = AtCommandRequest();&#xA;AtCommandResponse atResponse = AtCommandResponse();  &#xA;void setup()&#xA;{ &#xA;delay(30000); &#xA;atRequest.setCommand(atdCmd);&#xA;xbee.send(atRequest);&#xA;}&#xA;void loop()&#xA;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but it doesn't work!&#xA;Thanks guys!&lt;/p&gt;&#xA;" OwnerUserId="4889" LastEditorUserId="4889" LastEditDate="2015-02-21T17:16:46.607" LastActivityDate="2016-08-17T00:49:18.197" Title="AT command XBee from atmega to disable DIO5 (associated led)" Tags="|arduino-uno|xbee|atmega328|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8795" PostTypeId="1" CreationDate="2015-02-21T18:05:36.923" Score="2" ViewCount="228" Body="&lt;p&gt;I'm trying to send data from an ATtiny84 [1mhz] to Arduino Uno using a 433Mhz rf module and Manchester lib.&#xA;Now I came across a weird problem, no matter what value I transmit, When I receive it on the arduino and to the Serial monitor, it always shows value of 806,No matter what I have really transmitted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATtiny side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84&#xA;  man.setupTransmit(transmit_pin, MAN_1200);&#xA;}&#xA;&#xA;// And how I transmit&#xA;// RGBread is int, I also tried man.transmit((uint16_t)RGBread[i]); same result.&#xA;  for(int i=0; i&amp;lt;3; i++)&#xA;  {&#xA;    man.transmit(RGBread[i]);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Uno&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  man.setupReceive(reciever_pin, MAN_1200);&#xA;  man.beginReceive();&#xA;}&#xA;&#xA;  if (man.receiveComplete()) {&#xA;    Serial.println(man.getMessage());&#xA;    man.beginReceive(); //start listening for next message right after you retrieve the message&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks to all helpers.&lt;/p&gt;&#xA;" OwnerUserId="6201" LastActivityDate="2015-02-21T18:05:36.923" Title="Arduino and ATtiny84 w/RF" Tags="|attiny|rf|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8796" PostTypeId="2" ParentId="8668" CreationDate="2015-02-21T19:04:38.863" Score="2" Body="&lt;p&gt;After checking the queue functions that you use in your sketch, I see there is no protection against concurrent accesses in the &lt;code&gt;enq&lt;/code&gt; and &lt;code&gt;deq&lt;/code&gt; functions, which is a &lt;strong&gt;must-have&lt;/strong&gt; if you use any of these functions from &lt;strong&gt;within an ISR&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest the simplest changes to these functions as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void enq(TPrioQueue *queue, void *item, int priority)&#xA;{&#xA;    TPrioQEntry *newEntry=(TPrioQEntry *) malloc(sizeof(TPrioQEntry));&#xA;&#xA;    if(newEntry != NULL)&#xA;    {&#xA;        newEntry-&amp;gt;item=item;&#xA;        newEntry-&amp;gt;prio=priority;&#xA;        newEntry-&amp;gt;prev=NULL;&#xA;        newEntry-&amp;gt;next=NULL;&#xA;&#xA;        // Protect against concurrent accesses starting here&#xA;        uint8_t sreg = SREG;&#xA;        cli(); &#xA;        if(queue-&amp;gt;head==NULL)&#xA;            queue-&amp;gt;head=newEntry;&#xA;        else&#xA;        {&#xA;            // Find insertion point.&#xA;&#xA;            // First special case: Item at head has lower priority&#xA;            if(queue-&amp;gt;head-&amp;gt;prio &amp;gt; newEntry-&amp;gt;prio)&#xA;            {&#xA;                // Insert item at the start of the queue.&#xA;                newEntry-&amp;gt;next=queue-&amp;gt;head;&#xA;                queue-&amp;gt;head-&amp;gt;prev=newEntry;&#xA;                queue-&amp;gt;head=newEntry;&#xA;            }&#xA;            else&#xA;            {&#xA;                // Find your insertion point&#xA;                TPrioQEntry *trav= queue-&amp;gt;head;&#xA;&#xA;                while(trav-&amp;gt;next!=NULL &amp;amp;&amp;amp; trav-&amp;gt;prio &amp;lt; newEntry-&amp;gt;prio)&#xA;                    trav=trav-&amp;gt;next;&#xA;&#xA;                newEntry-&amp;gt;prev=trav;&#xA;                newEntry-&amp;gt;next=trav-&amp;gt;next;&#xA;                if(trav-&amp;gt;next != NULL)&#xA;                    trav-&amp;gt;next-&amp;gt;prev=newEntry;&#xA;&#xA;                trav-&amp;gt;next=newEntry;&#xA;            }&#xA;        }&#xA;&#xA;        queue-&amp;gt;itemCount++;&#xA;        // Protect against concurrent accesses stops here&#xA;        SREG = sreg;&#xA;    }   &#xA;}&#xA;&#xA;void *deq(TPrioQueue *queue)&#xA;{&#xA;    // Protect against concurrent accesses starting here&#xA;    uint8_t sreg = SREG;&#xA;    cli(); &#xA;    // Return NULL if queue is empty&#xA;    if(queue-&amp;gt;head == NULL)&#xA;    {&#xA;        // Protect against concurrent accesses stops here&#xA;        SREG = sreg;&#xA;        return NULL;&#xA;    }&#xA;&#xA;    void *ret=queue-&amp;gt;head-&amp;gt;item;&#xA;    TPrioQEntry *tmp=queue-&amp;gt;head;&#xA;&#xA;    if(queue-&amp;gt;head-&amp;gt;next!=NULL)&#xA;        queue-&amp;gt;head-&amp;gt;next-&amp;gt;prev=NULL;&#xA;&#xA;    queue-&amp;gt;head=queue-&amp;gt;head-&amp;gt;next;&#xA;    free(tmp);&#xA;&#xA;    queue-&amp;gt;itemCount--;&#xA;&#xA;    // Protect against concurrent accesses stops here&#xA;    SREG = sreg;&#xA;&#xA;    return ret;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-02-21T19:04:38.863" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8797" PostTypeId="2" ParentId="8759" CreationDate="2015-02-21T20:34:04.377" Score="2" Body="&lt;p&gt;Any Arduino (I would start with the UNO) will be sufficient to make a calculator similar to the regular HP or TI calculator product line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the keypad, you will need to buy an I2C compatible keypad and connect it to the I2C lines. For the screen there is an LCD shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will not need to code anything in assembly. You can write cpp code using the libraries provided with the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6540" LastActivityDate="2015-02-21T20:34:04.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8798" PostTypeId="1" CreationDate="2015-02-21T09:03:03.133" Score="1" ViewCount="1371" Body="&lt;p&gt;Ok, i know professionals generally hate Arduinos, but I would like to know if it would be possible to program Atmel ARM chips using the Arduino IDE. By which I mean, not needing to modify the source code, just add another entry into the &quot;hardware&quot; folder and that's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We already know the Atmel ATSAM3X8EA (Arduino DUE) is compattible, but how about a similar chip, like the Atmel ATSAM3X8CA. Or maybe a Cortex-M4 one, like the Atmel ATSAM4E16EA or the Atmel ATSAM4S8CA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmel ATSAM3X8CA is the closest one to the Atmel ATSAM3X8EA the Arduino Due uses, a bit smaller and with less I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it isn't possible without much source code modding, I would like to know what would it take to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your answers.&lt;/p&gt;&#xA;" OwnerDisplayName="Silviu Stroe" LastActivityDate="2015-02-21T22:44:28.750" Title="Programing other Atmel ARM chips using Arduino" Tags="|ide|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8799" PostTypeId="2" ParentId="8798" CreationDate="2015-02-21T14:29:34.457" Score="3" Body="&lt;p&gt;Yes it is possible. IDE 1.5.+ support different platforms, as they call it. Where the AVR and sam are provided by stock. Others are possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is fairly involved setup. In short; within each platform there are the following files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;boards.txt, defines the individual boards using the similar processor.&lt;/li&gt;&#xA;&lt;li&gt;platform.txt, defines the compiler arguments&lt;/li&gt;&#xA;&lt;li&gt;programmers.txt, defines how to program it.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With corresponding sub directories to match, under the variants/ folder.&#xA;I have not found an complete tutorial on the matter. However, their &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE 1.5 3rd party Hardware specification&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/arduino/wiki/Platforms1&quot; rel=&quot;nofollow&quot;&gt;An overview of the platform architecture proposed for Arduino 1.5&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;are a great place to start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not done much with SAM. I do notice that programmers.txt is empty. So it must be done another way. &lt;/p&gt;&#xA;" OwnerUserId="60" OwnerDisplayName="mpflaga" LastActivityDate="2015-02-21T14:29:34.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8800" PostTypeId="2" ParentId="8787" CreationDate="2015-02-21T23:46:15.907" Score="4" Body="&lt;p&gt;I found it! I was returning an int8_t variable from my mod function, causing me to not be able to iterate over more than 126 LEDs. Now this little Arduino Uno is maxing out it's RAM at 409 LEDs!&lt;/p&gt;&#xA;" OwnerUserId="819" LastEditorUserId="819" LastEditDate="2015-02-22T00:00:54.733" LastActivityDate="2015-02-22T00:00:54.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8804" PostTypeId="2" ParentId="8633" CreationDate="2015-02-22T18:57:02.633" Score="1" Body="&lt;p&gt;My solution was making a new function that returns a String with the hash&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String GetHash256(uint8_t* hash) {&#xA;    char tmp[16];&#xA;    String sHash256 = &quot;&quot;;&#xA;&#xA;    int i;&#xA;    for (i=0; i&amp;lt;32; i++) {&#xA;        sprintf(tmp, &quot;%.2X&quot;,hash[i]);&#xA;        sHash256.concat(tmp);&#xA;    }&#xA;&#xA;    return sHash256 ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7491" LastEditorUserId="84" LastEditDate="2015-02-22T21:45:52.147" LastActivityDate="2015-02-22T21:45:52.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8806" PostTypeId="1" AcceptedAnswerId="8812" CreationDate="2015-02-22T21:04:19.150" Score="2" ViewCount="5270" Body="&lt;p&gt;I want to use one an push button with an led in middle, similar to this &lt;a href=&quot;http://www.ebay.com/itm/16mm-12V-Blue-LED-Power-Push-Button-Switch-Black-Aluminum-Metal-Latching-/231234288662?pt=LH_DefaultDomain_0&amp;amp;hash=item35d6a33c16&quot; rel=&quot;nofollow&quot;&gt;one&lt;/a&gt; on eBay. &#xA;The push button has a 12v input I want to hook it up to an Aduino Uno or Nano. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to hook it up and receive the signal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifications from the eBay page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Latching type, push it—on, push it again — off&lt;/li&gt;&#xA;  &lt;li&gt;Switch Rating: 3A/250VAC&lt;/li&gt;&#xA;  &lt;li&gt;LED voltage: 12V only&lt;/li&gt;&#xA;  &lt;li&gt;Contact Configuration: 1NO1NC&lt;/li&gt;&#xA;  &lt;li&gt;Pin Number: 5&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7496" LastEditorUserId="220" LastEditDate="2015-02-26T02:31:39.873" LastActivityDate="2015-02-26T02:31:39.873" Title="Hooking up 12v Push button to arduino uno/nano" Tags="|button|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8808" PostTypeId="1" CreationDate="2015-02-22T21:47:09.310" Score="2" ViewCount="754" Body="&lt;p&gt;I have DATA_READY, Activity and Inactivity interrupts mapped from INT1 to INT0 on the arduino. DATA_READY works fine, the problem is Activity and Inactivity are always set to 0 in the INT_SOURCE register. I have set up the threshold for activity and inactivity and the time of inactivity. I would like the algorithm to run when DATA_READY and Activity interrupts are 1 and do nothing when Inactivity is 1 (activity is 0). When Activity is 0 the accelerometer should go automatically in sleep mode and wakes up if activity is detected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_ADXL345_U.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;&#xA;#define F_CPU 16000000UL &#xA;&#xA;&#xA;&#xA;int state=0; //0--active detecting; 1--sleeping&#xA;int state_count=0; //sleeping trigger between 2 states&#xA;double mag[40];&#xA;int i=0;&#xA;double acc_rate[39];&#xA;int hunt_sub=0;&#xA;int exit_marker=-10,trough_marker=-30,peak_marker=-10;&#xA;volatile int sensor_update=0, active_mode=0;//active_mode=0, inactive; 1--active;      sensor_update=0, no new data; 1--new data comes&#xA;byte buff[1] ;&#xA;&#xA;&#xA;volatile unsigned long time=0, time0=0,time_dis=0,time_array[40]={0};&#xA;&#xA;//----------------------------------------------------------------------------------------------&#xA;&#xA;//Read ADXL345 registers&#xA;void readFrom(int device, byte address, int num, byte buff[]) {&#xA;Wire.beginTransmission(device); //start transmission to device &#xA;Wire.write(address);        //sends address to read from&#xA;Wire.endTransmission(); //end transmission&#xA;&#xA;Wire.beginTransmission(device); //start transmission to device (initiate again)&#xA;Wire.requestFrom(device, num);    // request 1 byte from device&#xA;&#xA;int i = 0;&#xA;while(Wire.available())    //device may send less than requested (abnormal)&#xA;{ &#xA;buff[i] = Wire.read(); // receive a byte&#xA;i++;&#xA;}&#xA;Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;//Write to ADXL345 registers&#xA;void writeTo(int device, byte address, byte val) {&#xA;Wire.beginTransmission(device); //start transmission to device &#xA;Wire.write(address);        // send register address&#xA;Wire.write(val);        // send value to write&#xA;Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;&#xA;&#xA;//----------------------------------------------------------------------------------------------&#xA;&#xA;/////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;//ISR function&#xA;&#xA;&#xA;&#xA;void interrupt(void){&#xA;&#xA;readFrom(0x53, 0x30, 1, buff); &#xA;&#xA;if(buff &amp;amp; 0b00010000){&#xA;  active_mode=1;//active state&#xA;}&#xA;if(buff &amp;amp; 0b00001000){ &#xA;  active_mode=0;//inactivity state&#xA;}&#xA;&#xA;if(buff &amp;amp; 0b10000000){&#xA;sensor_update=1;//DATA_READY each 10ms  &#xA;}&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;/* Assign a unique ID to this sensor at the same time */&#xA;Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void setup(void) &#xA;{&#xA;if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;Serial.begin(9600);&#xA;//Serial.println(&quot;Accelerometer Test&quot;); Serial.println(&quot;&quot;);&#xA;&#xA;pinMode(4, OUTPUT);// buzzer output pin&#xA;pinMode(2, INPUT);&#xA;&#xA;/* Initialise the sensor */&#xA;if(!accel.begin())&#xA;{&#xA;/* There was a problem detecting the ADXL345 ... check your connections */&#xA;//Serial.println(&quot;Ooops, no ADXL345 detected ... Check your wiring!&quot;);&#xA;while(1);&#xA;}&#xA;&#xA;/* Set the range to whatever is appropriate for your project */&#xA;accel.setRange(ADXL345_RANGE_8_G);&#xA;accel.setDataRate(ADXL345_DATARATE_100_HZ);&#xA;// displaySetRange(ADXL345_RANGE_8_G);&#xA;// displaySetRange(ADXL345_RANGE_4_G);&#xA;// displaySetRange(ADXL345_RANGE_2_G);&#xA;&#xA;/* Display some basic information on this sensor */&#xA;//displaySensorDetails();&#xA;&#xA;/* Display additional settings (outside the scope of sensor_t) */&#xA;//displayDataRate();&#xA;//displayRange();&#xA;//Serial.println(&quot;&quot;);&#xA;&#xA;//Create an interrupt that will trigger when a tap is detected.&#xA;&#xA;writeTo(0x53, 0x2D, 59);//POWER_CTL  auto sleep, link, 1hz rate&#xA;writeTo(0x53, 0x2C, 10);//BW_RATE low power mode off rate 100Hz&#xA;writeTo(0x53, 0x2E, 0);// disable interrupt&#xA;&#xA;attachInterrupt(0, interrupt, RISING);&#xA;&#xA;writeTo(0x53, 0x2F, 0); //map to to INT1&#xA;writeTo(0x53, 0x2E, 152); //enable data_ready, activity, inactivity&#xA;writeTo(0x53, 0x25, 18); //THRESH_INACT  ((11/9.8)*1000)/62.5&#xA;writeTo(0x53, 0x26, 60); //TIME_INACT    one minute&#xA;writeTo(0x53, 0x24, 21); //THRESH_ACT    ((13/9.8)*1000)/62.5&#xA;writeTo(0x53, 0x27, 0); //ACT_INACT_CTL   dc coupled, use only magnitude.&#xA;&#xA;&#xA;}&#xA;&#xA;void loop(void) &#xA;{&#xA;&#xA;readFrom(0x53, 0x30, 1, buff);&#xA;Serial.print(&quot;buff: &quot;); Serial.print(buff); Serial.print(&quot;  &quot;);&#xA;&#xA;sensors_event_t event; &#xA;do{ //clear DATA_READY&#xA;accel.getEvent(&amp;amp;event);&#xA;readFrom(0x53, 0x30, 1, buff);&#xA;}while(buff &amp;amp; 0b10000000);&#xA;&#xA;&#xA;&#xA;&#xA;if(sensor_update==1 &amp;amp;&amp;amp; active_mode==1){&#xA;//When sensor_update is set to 1 in the ISR,the algorithm process the data from the accelerometer being updated every 10ms(100Hz)&#xA;//rest of algorithm is here&#xA; sensor_update=0;//reset&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have modified the program to check in the loop whether the different flags are set and only the DATA_READY is. Activity and Inactivity are never set.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_ADXL345_U.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;&#xA;#define F_CPU 16000000UL &#xA;&#xA;&#xA;&#xA;int state=0; //0--active detecting; 1--sleeping&#xA;int state_count=0; //sleeping trigger between 2 states&#xA;double mag[40];&#xA;int i=0;&#xA;double acc_rate[39];&#xA;int hunt_sub=0;&#xA;int exit_marker=-10,trough_marker=-30,peak_marker=-10;&#xA;volatile int sensor_update=0, active_mode=0;//active_mode=0, inactive; 1--active;     sensor_update=0, no new data; 1--new data comes&#xA;byte buff[1] ;&#xA;&#xA;&#xA;volatile unsigned long time=0, time0=0,time_dis=0,time_array[40]={0};&#xA;&#xA;//----------------------------------------------------------------------------------------------&#xA;&#xA;//Read ADXL345 registers&#xA;void readFrom(int device, byte address, int num, byte buff[]) {&#xA;Wire.beginTransmission(device); //start transmission to device &#xA;Wire.write(address);        //sends address to read from&#xA;Wire.endTransmission(); //end transmission&#xA;&#xA;Wire.beginTransmission(device); //start transmission to device (initiate again)&#xA;Wire.requestFrom(device, num);    // request 1 byte from device&#xA;&#xA;int i = 0;&#xA;while(Wire.available())    //device may send less than requested (abnormal)&#xA;{ &#xA;buff[i] = Wire.read(); // receive a byte&#xA;i++;&#xA;}&#xA;Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;//Write to ADXL345 registers&#xA;void writeTo(int device, byte address, byte val) {&#xA;Wire.beginTransmission(device); //start transmission to device &#xA;Wire.write(address);        // send register address&#xA;Wire.write(val);        // send value to write&#xA;Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;&#xA;&#xA;//----------------------------------------------------------------------------------------------&#xA;&#xA;/////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;//ISR function&#xA;&#xA;&#xA;&#xA;void interrupt(void){&#xA;&#xA;&#xA;//    &#xA;//    if(buff &amp;amp; 0b00010000){&#xA;//      active_mode=1;//active state&#xA;//    }&#xA;//    if(buff &amp;amp; 0b00001000){ &#xA;//      active_mode=0;//inactivity state&#xA;//    }&#xA;//    &#xA;//    if(buff &amp;amp; 0b10000000){&#xA;//    sensor_update=1;//DATA_READY each 10ms  &#xA;//    }&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;/* Assign a unique ID to this sensor at the same time */&#xA;Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void setup(void) &#xA;{&#xA;if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;Serial.begin(9600);&#xA;//Serial.println(&quot;Accelerometer Test&quot;); Serial.println(&quot;&quot;);&#xA;&#xA;pinMode(4, OUTPUT);// buzzer output pin&#xA;pinMode(2, INPUT);&#xA;&#xA;/* Initialise the sensor */&#xA;if(!accel.begin())&#xA;{&#xA;/* There was a problem detecting the ADXL345 ... check your connections */&#xA;//Serial.println(&quot;Ooops, no ADXL345 detected ... Check your wiring!&quot;);&#xA;while(1);&#xA;}&#xA;&#xA;/* Set the range to whatever is appropriate for your project */&#xA;accel.setRange(ADXL345_RANGE_8_G);&#xA;accel.setDataRate(ADXL345_DATARATE_100_HZ);&#xA;&#xA;//Create an interrupt that will trigger when a tap is detected.&#xA;&#xA;&#xA;  writeTo(0x53, 0x2D, 59);//POWER_CTL  auto sleep, link, 1hz rate&#xA;  writeTo(0x53, 0x2C, 10);//BW_RATE low power mode off rate 100Hz&#xA;  writeTo(0x53, 0x2E, 0);// disable interrupt&#xA;&#xA;  attachInterrupt(0, interrupt, RISING);&#xA;&#xA;  writeTo(0x53, 0x2F, 0); //map to to INT1&#xA;  writeTo(0x53, 0x2E, 152); //enable data_ready, activity, inactivity&#xA;  // writeTo(0x53, 0x25, 18); //THRESH_INACT  ((11/9.8)*1000)/62.5&#xA;  writeTo(0x53, 0x27, 119); //ACT_INACT_CTL   dc coupled, use only magnitude.&#xA;  writeTo(0x53, 0x25, 5); //THRESH_INACT  ((3.0625/9.8)*1000)/62.5&#xA;  writeTo(0x53, 0x26, 1); //TIME_INACT    one minute&#xA;  writeTo(0x53, 0x24, 21); //THRESH_ACT    ((12.8625/9.8)*1000)/62.5&#xA;&#xA;  }&#xA;&#xA;  void loop(void) &#xA;  {&#xA;&#xA;  if(digitalRead(2)) {&#xA;&#xA;  readFrom(0x53, 0x30, 1, buff);&#xA;&#xA;  //Serial.print(&quot;### &quot;);&#xA;&#xA;  //Serial.println(interruptSource, BIN);&#xA;&#xA;&#xA;  if(buff[0] &amp;amp; 0b10000000) {&#xA;&#xA;  Serial.println(&quot;### DATA_READY&quot;);&#xA;&#xA;  }&#xA;&#xA;&#xA;  if(buff[0] &amp;amp; 0b00001000) {&#xA;&#xA;  Serial.println(&quot;### Inacitivity&quot;);&#xA;&#xA;  }&#xA;&#xA;  if(buff[0] &amp;amp; 0b00010000) {&#xA;&#xA;  Serial.println(&quot;### activity&quot;);&#xA;&#xA;  // we don't need to put the device in sleep because we set the AUTO_SLEEP bit to 1 in R_POWER_CTL&#xA;&#xA;  // set the LOW_POWER bit to 1 in R_BW_RATE: with this we get worst measurements but we save power&#xA;&#xA;}&#xA;&#xA;&#xA;delay(150);&#xA;&#xA;}&#xA;&#xA;&#xA;sensors_event_t event; &#xA;do{ //clear DATA_READY&#xA;accel.getEvent(&amp;amp;event);&#xA;readFrom(0x53, 0x30, 1, buff);&#xA;}while(buff &amp;amp; 0b10000000);&#xA;&#xA;&#xA;&#xA;&#xA;if(sensor_update==1 &amp;amp;&amp;amp; active_mode==1){&#xA;//When sensor_update is set to 1 in the ISR,the algorithm process the data from the accelerometer being updated every 10ms(100Hz)&#xA;//rest of algorithm is here&#xA; sensor_update=0;//reset&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7390" LastEditorUserId="7390" LastEditDate="2015-02-23T21:09:33.753" LastActivityDate="2015-02-23T21:09:33.753" Title="ADXL345 Arduino UNO Activity Inactivity interrupt" Tags="|interrupt|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8811" PostTypeId="1" AcceptedAnswerId="8862" CreationDate="2015-02-22T22:44:08.043" Score="1" ViewCount="903" Body="&lt;p&gt;For my next project I'd like to use a battery pack to power my Arduino.&#xA;I would also like to get a small solar panel and charging module to charge these batteries when possible (during the day).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the right type of battery for this kind of application?&lt;/li&gt;&#xA;&lt;li&gt;What are the differences given this context?&lt;/li&gt;&#xA;&lt;li&gt;What are the factors I need to consider when choosing a rechargeable battery for this application?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6249" LastActivityDate="2015-02-25T03:54:42.500" Title="How to choose between Lithium-ion vs NiMH batteries to power Arduino on the go." Tags="|power|voltage-level|battery|current|solar|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8812" PostTypeId="2" ParentId="8806" CreationDate="2015-02-23T00:56:21.627" Score="2" Body="&lt;p&gt;Most likely, there will be a push button, and on separate wires, there is a light. If this is the case, you can hook the push button part up to the arduino. You can test this - find two random wires, test the resistance with a multimeter, then press the button and see if the resistance changes. Keep trying until you find two wires that change when you press the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you find the pair, you can hook one of those two to a digil pin on the Arduino, and via a resister (large, anything 10kilo-ohm or larger is fine) to ground (GND). Then, connect the other side of your pushbutton to 5V. See &lt;a href=&quot;http://arduino.cc/en/tutorial/button&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/tutorial/button&lt;/a&gt; for photos and a circuit diagram - their wiring is more complicated than it needs to be, and their button has 4 pins in two pairs (left pair, and right pair in the picture with the breadboard; the left-top and left-bottom are permanently connected, and the right-top and right-bottom are permanently connected). Have a look at the circuit diagram - that's a lot simpler. The zig-zag at the top is the resistor, and the disconnected looking thing is the switch (open). There is sample code there too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that push buttons typically &quot;bounce&quot; - that is, when you push them, they will go (starting off) on-off-on-off-on-off-on, so if you're counting the number of pushes you will get a result which is way too high. If you delay long enough in between (10ms?) then you won't get these. The code I linked to already has debounce built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other part is the light. This is a little more tricky. The light will probably use too much current for the arduino to supply directly. You will need a transistor and a resistor (again, at least 10 kiloOhm is good).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transistor should be an NPN transistor, and should look like the top one in &lt;a href=&quot;http://www.reprise.com/host/circuits/transistor_pinouts.asp&quot; rel=&quot;nofollow&quot;&gt;http://www.reprise.com/host/circuits/transistor_pinouts.asp&lt;/a&gt;. The easiest one is the base - this is the middle one. Connect this via your resistor to another digital pin on your arduino (pin 13 is great for testing this, because it will also light up the led on the Arduino). Next, connect your emitter to ground (GND). Then, IF YOUR POWER SUPPLY IS NO MORE THAN 12 VOLT! you can connect VIN to the + side of the light, and the - side of the light to the collector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, load a sketch - the &quot;blink&quot; sketch is good to test this. Adjust the pin as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, these switches have a resistor already built in to the light; if you want to do the same with an ordinary led, you will have to add one yourself. Check out &lt;a href=&quot;http://ledcalc.com/&quot; rel=&quot;nofollow&quot;&gt;http://ledcalc.com/&lt;/a&gt; to tell you which resistor you need. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-23T00:56:21.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8813" PostTypeId="1" CreationDate="2015-02-23T01:08:58.767" Score="3" ViewCount="171" Body="&lt;p&gt;I'm looking to drive two DC motors (on a toy RC car) using a Seeeduino and Seeed Motor Shield V2, but can't manage to get the power scheme right. Right now, a 9V battery connected to the shield powers everything (i.e. LEDs are illuminated on the shield and seeeduino), but when I try running the motors everything flickers and the motors don't move (I assume this is because there isn't enough current). I've managed to get them working when plugging a USB and 9V battery (at the same time) into the seeeduino, as well as when plugging a 9V into the seeeduino and another into the shield (at the same time). Both of these configurations leave me feeling uneasy, as I'm not sure how the power sources will interact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, there is a jumper (MB_EN) on the shield which, according to my research, should isolate the shield from the seeeduino when removed. The documentation (&lt;a href=&quot;http://www.seeedstudio.com/wiki/Motor_Shield_V2.0&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Motor_Shield_V2.0&lt;/a&gt;) alludes to the fact that this jumper doesn't work, however. Indeed, when I try removing it, power is lost altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found conflicting answers to this problem, none of which seems definitive. I've also found tutorials where people did exactly the same thing (with a proper arduino, mind you...) by plugging a single 9V battery to the shield. This should be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've exhausted just about every resource I can think of, and have spent innumerable hours searching up a solution -- nothing yet. Any help would be great.&lt;/p&gt;&#xA;" OwnerUserId="7499" LastActivityDate="2015-02-23T01:08:58.767" Title="Seeeduino Motor Shield Power Supply" Tags="|arduino-motor-shield|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8815" PostTypeId="1" AcceptedAnswerId="8974" CreationDate="2015-02-23T05:58:15.833" Score="0" ViewCount="2329" Body="&lt;p&gt;Is there any reason why is my &lt;code&gt;/dev/cu&lt;/code&gt; port always busy? How can I fix that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It happened on both Uno clone and Spark Core.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, I'm having issues doing serial communication. Where (as a programmer) I'm seeing something like dropped packets with &lt;code&gt;/dev/tty&lt;/code&gt; port. I did a quick test running it on Win 7 (a loaner PC), it works fine...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code for now is extremely simple. It waits for a command, and write a response.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str = String(30);&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    str = &quot;&quot;;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;        char inChar = Serial.read();&#xA;        if ((inChar == '\n') || (inChar == '\r') || (inChar == 'z')) {&#xA;            str.trim();&#xA;            if(str == &quot;READ&quot;) {&#xA;                String x = String(random(27, 45)) + &quot;,&quot; + String(random(45, 300)) + &quot;,&quot; + String(random(35, 250));&#xA;                Serial.println(x);&#xA;            }&#xA;            str = &quot;&quot;;&#xA;        }&#xA;        else {&#xA;            if (str.length() &amp;lt; 30) {&#xA;                str += inChar;&#xA;            }&#xA;            else {&#xA;                str = &quot;&quot;;&#xA;                str += inChar;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7500" LastActivityDate="2016-11-05T22:49:52.660" Title="/dev/cu port resource always busy on OS X 10.10" Tags="|arduino-uno|serial|mac-os|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8819" PostTypeId="1" AcceptedAnswerId="8822" CreationDate="2015-02-23T11:30:25.433" Score="2" ViewCount="1680" Body="&lt;p&gt;Is it possible to delay a task inside a function that is called only once (meaning, it's not inside the loop) without using delay()? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/kslstn/cozir&quot; rel=&quot;nofollow&quot;&gt;This library&lt;/a&gt; I'm using, for reading sensor measurements via serial has a delay() in it. I want to get rid of it, but I don't how to do it, because the library's function is not looped. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the simple solution would be to move the library functions inside the loop, so I can do a simple check with millis() and run the delayed part as soon as 250 ms have passed. I would like to improve this library though and do a simple, single call for sensor data that doesn't not hold up the entire program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the function with the delay:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;uint16_t COZIR::Request(char* s)&#xA;{&#xA;  Command(s);&#xA;  // empty buffer&#xA;  buffer[0] = '\0';&#xA;  // read answer; there may be a 100ms delay!&#xA;  // TODO: PROPER TIMEOUT CODE.&#xA;  delay(250);  &#xA;  int idx = 0;&#xA;  while(CZR_Serial.available())&#xA;  {&#xA;    buffer[idx++] = CZR_Serial.read();&#xA;  }&#xA;  buffer[idx] = '\0';&#xA;  uint16_t rv = 0;&#xA;&#xA;  switch(buffer[1])&#xA;  {&#xA;    case 'T' :&#xA;            rv = atoi(&amp;amp;buffer[5]);&#xA;            if (buffer[4] == 1) rv += 1000;&#xA;            break;&#xA;    default :&#xA;            rv = atoi(&amp;amp;buffer[2]);&#xA;            break;&#xA;  }&#xA;  return rv;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've had a look at the SoftTimer library, but it requires sketches to be written very differently (without a loop). I'm also not sure if I can even pass arguments to delayed tasks with that library.&lt;/p&gt;&#xA;" OwnerUserId="7503" LastEditorUserId="7508" LastEditDate="2015-02-24T18:23:02.520" LastActivityDate="2015-02-24T18:23:02.520" Title="How to wait outside the loop without delay()?" Tags="|serial|timing|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8820" PostTypeId="2" ParentId="8791" CreationDate="2015-02-23T12:15:14.160" Score="1" Body="&lt;p&gt;finally I solved the problem with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t atdCmd[]={'D','5'};&#xA;uint8_t value[]={4};///pongo DIO5 a output LOW&#xA;uint8_t length=1;&#xA;AtCommandRequest atRequest = AtCommandRequest(atdCmd, value, length);&#xA;xbee.send(atRequest);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem was that I tried to put command with 5 caracters,... and only accepts 2 caracters for &quot;AT command&quot;&lt;/p&gt;&#xA;" OwnerUserId="4889" LastActivityDate="2015-02-23T12:15:14.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8821" PostTypeId="1" CreationDate="2015-02-23T14:29:46.237" Score="1" ViewCount="976" Body="&lt;p&gt;I have created my own custom Arduino Micro, but I am experiencing problems when I attempt to upload an sketch via USB in Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I program the Arduino Micro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude  -c atmelice_isp  -p m32u4 -P usb -u -v -e -U flash:w:Caterina-Micro.hex &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ avrdude  -c atmelice_isp  -p m32u4 -P usb -v -e -U flash:w:Caterina-Micro.hex &#xA;avrdude: Version 6.1, compiled on Mar 23 2014 at 04:42:55&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2014 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/local/Cellar/avrdude/6.1/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/aUser/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : usb&#xA;         Using Programmer              : atmelice_isp&#xA;avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J41800023270&#xA;avrdude: Found CMSIS-DAP compliant device, using EDBG protocol&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : JTAG3_ISP&#xA;         Description     : Atmel-ICE (ARM/AVR) in ISP mode&#xA;         Vtarget         : 4.9 V&#xA;         SCK period      : 125.00 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.02s&#xA;&#xA;avrdude: Device signature = 0x1e9587&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as D8&#xA;avrdude: safemode: efuse reads as CB&#xA;avrdude: erasing chip&#xA;avrdude: reading input file &quot;Caterina-Micro.hex&quot;&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: writing flash (32730 bytes):&#xA;&#xA;Writing | ################################################## | 100% 38.80s&#xA;&#xA;avrdude: 32730 bytes of flash written&#xA;avrdude: verifying flash memory against Caterina-Micro.hex:&#xA;avrdude: load data flash data from input file Caterina-Micro.hex:&#xA;avrdude: input file Caterina-Micro.hex auto detected as Intel Hex&#xA;avrdude: input file Caterina-Micro.hex contains 32730 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 133.93s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 32730 bytes of flash verified&#xA;&#xA;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as D8&#xA;avrdude: safemode: efuse reads as CB&#xA;avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF)&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error in Arduino IDE when flashing sketch via USB:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 23.994 bytes (83%) of program storage space. Maximum is 28.672 bytes.&#xA;Global variables use 1.145 bytes (44%) of dynamic memory, leaving 1.415 bytes for local variables. Maximum is 2.560 bytes.&#xA;Forcing reset using 1200bps open/close on port /dev/tty.usbmodem1411&#xA;PORTS {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.Bluetooth-Modem, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.Bluetooth-Modem, /dev/tty.usbmodem1411, } / {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.Bluetooth-Modem, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.Bluetooth-Modem, /dev/tty.usbmodem1411, } =&amp;gt; {}&#xA;PORTS {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.Bluetooth-Modem, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.Bluetooth-Modem, /dev/tty.usbmodem1411, } / {/dev/cu.Bluetooth-Incoming-Port, /dev/cu.Bluetooth-Modem, /dev/cu.usbmodem1411, /dev/tty.Bluetooth-Incoming-Port, /dev/tty.Bluetooth-Modem, /dev/tty.usbmodem1411, } =&amp;gt; {}&#xA;Uploading using selected port: /dev/tty.usbmodem1411&#xA;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/tty.usbmodem1411 -b57600 -D -Uflash:w:/var/folders/64/6n0yv9515hz1n6z3bdzcwv6h0000gn/T/build2162381950044145986.tmp/IMUNode.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr  3 2014 at 22:00:33&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/aUser/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/tty.usbmodem1411&#xA;         Using Programmer              : avr109&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : butterfly&#xA;         Description     : Atmel AppNote AVR109 Boot Loader&#xA;&#xA;Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7257" LastEditorUserId="19409" LastEditDate="2018-12-13T12:27:22.193" LastActivityDate="2020-05-07T01:51:48.790" Title="Unable to upload sketch after bootloader has been flashed on Arduino Micro" Tags="|arduino-ide|usb|isp|flash|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8822" PostTypeId="2" ParentId="8819" CreationDate="2015-02-23T14:41:22.427" Score="3" Body="&lt;p&gt;You could split &lt;code&gt;Request()&lt;/code&gt; into two separate functions: You call &lt;code&gt;sendRequest()&lt;/code&gt;, then go do other stuff, then, some time later, you call &lt;code&gt;getResponse()&lt;/code&gt;. If you get &lt;code&gt;RESPONSE_NOT_READY&lt;/code&gt;, then you know you have to call it later:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define REQ_WAIT_DELAY     250  // Wait for 250 ms&#xA;#define RESPONSE_NOT_READY ((uint16_t) -1)&#xA;&#xA;uint32_t time_request_sent;&#xA;&#xA;void COZIR::sendRequest(char* s)&#xA;{&#xA;  Command(s);&#xA;  time_request_sent = millis();&#xA;}&#xA;&#xA;uint16_t COZIR::getResponse()&#xA;{&#xA;  if (millis() - time_request_sent &amp;lt; REQ_WAIT_DELAY)&#xA;      return RESPONSE_NOT_READY;&#xA;  buffer[0] = '\0';  // empty buffer&#xA;  int idx = 0;&#xA;  // From here, same as original COZIR::Request()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that &lt;code&gt;RESPONSE_NOT_READY&lt;/code&gt; (&lt;code&gt;0xffff&lt;/code&gt;) is not an otherwise valid response. If all 2^16 values of an &lt;code&gt;uint16_t&lt;/code&gt; may be valid, then you need another way for the library to signal that the response is not ready. Also, make sure you never compare timestamps, because of the &lt;code&gt;millis()&lt;/code&gt; rollover problem. Taking the difference between two timestamps and comparing this with a specified delay (as in the example above) is rollover-safe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Here is an example of how this could be used:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;COZIR cozir(some_serial_connection);&#xA;&#xA;void loop()&#xA;{&#xA;    static bool waiting_for_a_cozir_response = false;&#xA;&#xA;    if (time_to_get_another_cozir_reading()) {&#xA;        if (waiting_for_a_cozir_response) {&#xA;            report_something_is_wrong(&quot;This COZIR is too slow!&quot;);&#xA;        }&#xA;        else {&#xA;            cozir.sendRequest(&quot;Hi Cozir! Pliz send me another reading.&quot;);&#xA;            waiting_for_a_cozir_response = true;&#xA;            /* We won't get the response on this iteration. *&#xA;             * We will ask next time.                       */&#xA;        }&#xA;    }&#xA;    else if (waiting_for_a_cozir_response) {&#xA;        uint16_t response = cozir.getResponse();&#xA;        if (response == RESPONSE_NOT_READY) {&#xA;            /* Nothing to do now, really. We will just try again *&#xA;             * at the next loop() iteration.                     */&#xA;        }&#xA;        else {&#xA;            waiting_for_a_cozir_response = false;&#xA;            do_something_with_the_cozir_response(response);&#xA;        }&#xA;    }&#xA;    do_whatever_else_has_to_be_done_in_the_loop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-02-24T09:27:40.180" LastActivityDate="2015-02-24T09:27:40.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8823" PostTypeId="1" CreationDate="2015-02-23T15:21:04.040" Score="-1" ViewCount="1808" Body="&lt;p&gt;Is anyone out there building serious metal detectors with the Arduino? By &quot;serious&quot; I mean metal detectors with phase sensitivity to discriminate between ferrous and non-ferrous metals, etc.  Seems like the Uno is a good platform for a smart metal detector project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: &#xA;Arduino allows me to control phase discrimination which allows ferrous metals to be rejected.&#xA;I already know it can be done with an analog phase shift circuit.&#xA;Also Arduino can perform target ID function with readout to 16x2 LCD display.&lt;/p&gt;&#xA;" OwnerUserId="7486" LastEditorUserId="313" LastEditDate="2015-03-26T18:53:37.687" LastActivityDate="2022-07-17T08:07:15.753" Title="Metal detector using Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8824" PostTypeId="2" ParentId="8819" CreationDate="2015-02-23T16:25:05.857" Score="0" Body="&lt;p&gt;You can look at the BlinkWithoutDelay example sketch (under Digital).  Basically you store the current millis as a variable, then have an if statement to check that it has been more than x milliseconds.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-23T16:25:05.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8825" PostTypeId="2" ParentId="1180" CreationDate="2015-02-23T16:40:09.227" Score="25" Body="&lt;p&gt;There are some good applications for visualizing the serial data, including:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.megunolink.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MegunoLink&lt;/a&gt; ($39.95; &lt;a href=&quot;https://www.megunolink.com/megunolink-lite/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Lite&lt;/a&gt; free) - plotting, logging, programming, reporting and more.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.megunolink.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YLakU.png&quot; alt=&quot;MegunoLink&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://electricui.com/features&quot; rel=&quot;nofollow noreferrer&quot;&gt;Electric UI&lt;/a&gt; ($80; free for students) - cross platform, fully featured code based GUI framework for hardware.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://electricui.com/features&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://electricui.com/web_static/plot_examples.gif&quot; alt=&quot;Electric UI&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.makerplot.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MakerPlot&lt;/a&gt; ($59) - digital &amp;amp; analog plotting, monitoring, custom interfaces and more.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.makerplot.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nsmeb.jpg&quot; alt=&quot;MakerPlot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/gregpinero/ArduinoPlot&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArduinoPlot&lt;/a&gt; (free) - simple plotting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/gregpinero/ArduinoPlot&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jdTmK.png&quot; alt=&quot;ArduinoPlot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/devinaconley/arduino-plotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduino-plotter&lt;/a&gt; (free) - easy, light-weight plotting with support for all primitive types&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/devinaconley/arduino-plotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://www.dropbox.com/s/2mtg5ig7lyrrffi/plotter_preview.gif?raw=1&quot; alt=&quot;arduino-plotter&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.infineon.com/cms/en/design-support/tools/programming-testing/psoc-programming-solutions/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bridge Control Panel&lt;/a&gt; (free) - logging, plotting, and more.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.infineon.com/cms/en/design-support/tools/programming-testing/psoc-programming-solutions/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rQjHY.jpg&quot; alt=&quot;Bridge Control Panel&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sebnil/RealtimePlotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;RealtimePlotter&lt;/a&gt; (free) - 6 channels data plotting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/sebnil/RealtimePlotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3okhi.png&quot; alt=&quot;RealtimePlotter&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/infomaniac50/projectsimplot/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;SimPlot&lt;/a&gt; (free) - 4 channel plotting.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/infomaniac50/projectsimplot/releases&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YqoOn.jpg&quot; alt=&quot;SimPlot&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino Serial Plotter (free) - built in &lt;a href=&quot;https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Editor&lt;/a&gt; under &lt;em&gt;Tools &amp;gt; Serial Plotter&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://docs.arduino.cc/f155cf7066d171d7b88b80f3c921e7b1/potentiometer_plotter.gif&quot; alt=&quot;Arduino Serial Plotter&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;(This is a community wiki, you can expand the list.)&lt;/p&gt;&#xA;" OwnerUserId="3281" LastEditorUserId="87684" LastEditDate="2022-11-26T00:40:53.693" LastActivityDate="2022-11-26T00:40:53.693" CommentCount="2" CommunityOwnedDate="2015-02-23T16:40:09.227" ContentLicense="CC BY-SA 4.0" />
  <row Id="8826" PostTypeId="2" ParentId="8659" CreationDate="2015-02-23T17:02:44.013" Score="1" Body="&lt;p&gt;From the &lt;a href=&quot;http://arduino.cc/en/reference/servo&quot; rel=&quot;nofollow&quot;&gt;Servo library documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is, as has been suggested, because of conflicting usage of the timers. You should just move your DC motors to other PWM-capable pins.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-02-23T17:02:44.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8827" PostTypeId="1" AcceptedAnswerId="8887" CreationDate="2015-02-23T17:35:53.150" Score="0" ViewCount="1611" Body="&lt;p&gt;Any one know a &lt;strong&gt;component library&lt;/strong&gt; for Arduino UNO (&lt;strong&gt;Atmega328&lt;/strong&gt;, etc) for &lt;strong&gt;Protel 99 SE&lt;/strong&gt; PCB design software? &lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2015-02-25T21:49:07.787" Title="Atmega328 component library for Protel 99 SE" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8828" PostTypeId="1" AcceptedAnswerId="8830" CreationDate="2015-02-23T19:12:34.417" Score="0" ViewCount="303" Body="&lt;p&gt;So I just bought my first Arduino (an Uno r3), and dove right in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I have currently is the base board (I didn't want to invest too heavily and then realize arduinos weren't for me), so I made a quick script that translates input letters to morse via the LED on the top.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that I'm done with that, I figured I'd come here to ask: do you guys have any random ideas for things I can make with JUST the uno? I understand that I should probably just start buying kits and shields, but I'm just curious as to what I can make with the most minimal of items. I consider it a test :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance guys!&lt;/p&gt;&#xA;" OwnerUserId="7432" LastActivityDate="2015-02-23T19:25:19.780" Title="Arduino Uno - What can I make with just the base board" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="1" ClosedDate="2015-02-23T23:52:59.070" ContentLicense="CC BY-SA 3.0" />
  <row Id="8830" PostTypeId="2" ParentId="8828" CreationDate="2015-02-23T19:25:19.780" Score="0" Body="&lt;p&gt;Well,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your question is very broad. But the Arduino essentially needs controlling gadgteers to make things easy ( and funny ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you know a bit of electronics, then you may be able to use the IN/OUT analog ports and build other interfaces to control, for example the lights of your home, or even better. You can measure and control priate things should be linked. Increasing the power of your home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have interest in cars, then you can perform to connect the on-board computer of your car to the Arduino, like &lt;a href=&quot;http://arduinodev.com/connect-arduino-to-a-car-through-obd-ii-port/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, there are numerous ideas, none of these I'm saying is new and there are even libraries ready to be used in these segments mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Andrew Paes&lt;/p&gt;&#xA;" OwnerUserId="6301" LastActivityDate="2015-02-23T19:25:19.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8831" PostTypeId="1" AcceptedAnswerId="8837" CreationDate="2015-02-23T22:23:30.313" Score="0" ViewCount="5442" Body="&lt;p&gt;On an Arduino Uno, the PWM pin 3 is connected to the &lt;code&gt;gate&lt;/code&gt; pin of an &lt;a href=&quot;http://www.farnell.com/datasheets/1690175.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;N-channel MOSFET STP16NF06L&lt;/a&gt;. The source pin is connected to ground of a 12 V power supply and drain pin connected to a multimeter. The other end of the multimeter is connected to the positive terminal of the power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; When Arduino varies its PWM output from 0 to 255, the multimeter reading goes from 11.50 V to 12.10 V. Why isn't it 0 to 12 V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the FET gate is connected to the Arduino pin that outputs either 0 V or 5 V, the multimeter reading is as expected at 0 V and 12 V respectively.&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="26916" LastEditDate="2017-09-09T23:48:27.527" LastActivityDate="2017-09-09T23:48:27.527" Title="Arduino PWM output cannot drive MOSFET 0-12V" Tags="|arduino-uno|pwm|mosfet|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8832" PostTypeId="2" ParentId="501" CreationDate="2015-02-23T22:23:46.377" Score="3" Body="&lt;p&gt;I've been using the Ultrasonic method for close to a year and the biggest problem is the sensor failing due to water infiltration(condensation). My latest attempt lasted for about two weeks. I used plastic spray like the stuff you use on tool handles. I also used the wireless shield to make a website that displayed the level on any device connected to my router. I would like to get it to email me when the level is below 10% but can't get it to work....It's not bad but still needs work for stability...&lt;/p&gt;&#xA;" OwnerUserId="7514" LastActivityDate="2015-02-23T22:23:46.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8836" PostTypeId="2" ParentId="8831" CreationDate="2015-02-24T01:47:52.920" Score="0" Body="&lt;p&gt;When the FET is saturated (pin 3 is high), I would expect the instantaneous voltage to be the full 12 v. When pin 3 is at 0v, there should be no connection across the FET; I would expect the voltage to fluctuate randomly. you might see the same if you measure voltage with nothing touching the probes, especially if the probes move relative to each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm fairly new to FETs, so I may be on completely the wrong track.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-02-24T01:47:52.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8837" PostTypeId="2" ParentId="8831" CreationDate="2015-02-24T01:59:28.870" Score="1" Body="&lt;p&gt;Assuming you have a suitable FET You should have a circuit in line the following.&#xA;&lt;a href=&quot;http://elinux.org/RPi_GPIO_Interface_Circuits#Using_a_FET&quot; rel=&quot;nofollow&quot;&gt;http://elinux.org/RPi_GPIO_Interface_Circuits#Using_a_FET&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should have some kind of load (a multimeter will have too high an impedance). Use a resistor 4.7k or smaller. You should also have a resistor on the gate&lt;/p&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="3879" LastEditDate="2015-02-24T06:28:22.237" LastActivityDate="2015-02-24T06:28:22.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8838" PostTypeId="1" CreationDate="2015-02-24T02:45:52.567" Score="2" ViewCount="898" Body="&lt;p&gt;I have a project that turns a LED strip on and off using capacitive touch.  The project uses an &lt;a href=&quot;https://www.adafruit.com/products/1315&quot; rel=&quot;nofollow&quot;&gt;Arduino Micro&lt;/a&gt; as the brain and a &lt;a href=&quot;https://www.adafruit.com/products/352&quot; rel=&quot;nofollow&quot;&gt;12v wall wart&lt;/a&gt; to power everything.  I have the Arduino ground and negative from the power supply running to a common ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything works as expected during testing and the Arduino is connected via USB to my computer; however, when I unplug the USB and connect the circuit to the light installation, the lights just flicker on and off.  When I touch my finger to the negative/ground (and presumably provide common ground), everything works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems obvious to me that I have a grounding issue, but really do not know how to proceed. Is there a specific technique for grounding from a wall wart? Do I need to somehow pull the ground/negative down? I feel like there is something obvious that I am missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any and all help.&lt;/p&gt;&#xA;" OwnerUserId="7520" LastActivityDate="2015-02-24T05:41:04.907" Title="Arduino Grounding Issue" Tags="|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8839" PostTypeId="2" ParentId="5155" CreationDate="2015-02-24T03:11:49.103" Score="1" Body="&lt;p&gt;So, as the other users said, tou can use FRITZING, it is totally free and it does have LCD and a lot of other Shields. But the thing is, if you want a more complete design tool, PROTEUS 8.1 is a very used tool and by far more easy to use than any other design tool (as a complete designer solution). You can even simulate your lcd in software to test if everything is ok before start mounting your Circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Proteus Site: &lt;a href=&quot;http://www.labcenter.com/index.cfm&quot; rel=&quot;nofollow&quot;&gt;http://www.labcenter.com/index.cfm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Proteus is not free but you can use a lot it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some images of arduinos in Proteus (The site in portuguese but you just need to see the pictures): &#xA;&lt;a href=&quot;http://microcontrolandos.blogspot.com.br/2013/04/proteus-8-professional.html&quot; rel=&quot;nofollow&quot;&gt;http://microcontrolandos.blogspot.com.br/2013/04/proteus-8-professional.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7522" LastEditorUserId="7522" LastEditDate="2015-02-24T03:17:31.880" LastActivityDate="2015-02-24T03:17:31.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8840" PostTypeId="2" ParentId="8838" CreationDate="2015-02-24T05:41:04.907" Score="1" Body="&lt;p&gt;Seems like there is a problem in your wall wart, actually some people are having problems using wall wart with arduino. The problem is with the circuit of thre arduino regulator and with sime ripple variances with de wall wart, i sugest you to setup in your project a regulator (7805) and see if the problem is gone. This is by far problem not just with grounding, but with the power suply in general. I was used to make PIC projects and once it was happening exatly the same that happaned to you but the microcontroller started to work when i put my hand or finger close without even touching it :x. Crazy thing. If the power supply isn't well suited, the arduino enter in continous reset looping because of supply noise. So just put an external regulator, an maybe an extra capacitor (generally 10 nF) in arduino micro power supply rais (VCC-GND). Here's my tip. Good look man, tell me if it worked :)&lt;/p&gt;&#xA;" OwnerUserId="7522" LastActivityDate="2015-02-24T05:41:04.907" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8841" PostTypeId="2" ParentId="8831" CreationDate="2015-02-24T05:47:22.790" Score="0" Body="&lt;p&gt;Also put a LED with a resistor connected trough drain, then you read the voltage across the resistor and also have visual feedback with the LED. Resistor should be with 0V when your pin is LOW. It's easier to work with transistor knowing if there is current or not.&lt;/p&gt;&#xA;" OwnerUserId="7522" LastActivityDate="2015-02-24T05:47:22.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8842" PostTypeId="1" CreationDate="2015-02-24T06:28:30.963" Score="9" ViewCount="4732" Body="&lt;p&gt;I'm building a project that will connect to users' phones (Android at first, but iPhone too, if there's enough interest) via USB. Of course, this means that I need a USB host in the project. The total size of the device has to be about the size of the phone, so answers that seriously suggest shields aren't going to be helpful - they'd put me over my size budget by at least a factor of 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also rather not require an adapter to go from the USB Mini B connector type to the Micro B connector type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gravitech has a USB Host board for the Nano 3 that has a USB Type A connector, and the combination of a Nano and Gravitech Host is about the right size (maybe a little thick, once the whole thing is soldered to my own board), but the USB host is $25. I can get the Nano for about $4 each and would like to keep the USB host in the neighborhood of $8 each. Are the solder fumes getting to me, or is there such a specimen out there and I'm just not finding it?&lt;/p&gt;&#xA;" OwnerUserId="1369" LastActivityDate="2016-01-31T13:48:57.010" Title="What's the smallest (cheap) USB Host solution for Arduino?" Tags="|usb|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8843" PostTypeId="2" ParentId="8827" CreationDate="2015-02-24T07:02:38.060" Score="1" Body="&lt;p&gt;All arduino design schematics are available from the Arduino website, e.g. for the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip&quot; rel=&quot;nofollow&quot;&gt;Uno&lt;/a&gt;. However, these are in EAGLE format, I don't know if it's possible to convert.&lt;/p&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-02-24T07:02:38.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8845" PostTypeId="2" ParentId="1395" CreationDate="2015-02-24T10:34:02.103" Score="2" Body="&lt;p&gt;The first question already got a perfectly good answer. I am answering the other ones.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;i couldn't find any function call to the one for UART.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are no &quot;UART functions&quot; in the MCU. The UART is controlled by reading and writing into special registers. These come by names like &lt;code&gt;UCSR0A&lt;/code&gt;, &lt;code&gt;UCSR0B&lt;/code&gt;, &lt;code&gt;UCSR0C&lt;/code&gt; (USART 0 Control and Status Registers A, B and C), &lt;code&gt;UBRR0L&lt;/code&gt;, &lt;code&gt;UBRR0H&lt;/code&gt; (Low and High bytes of the USART 0 Baud Rate Register) and &lt;code&gt;UDR0&lt;/code&gt; (USART 0 Data Register). These registers are all referenced in HardwareSerial.cpp. You can check the datasheet for their meaning.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;where is the definition of this Serial?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In HardwareSerial.cpp, by the end of the file, right after the comment &quot;Preinstantiate Objects&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There seem to have ring buffer for serial buffer. So, when data is being sent then, what and who fill the data into this buffer inside Hardware.cpp?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are actually &lt;em&gt;two&lt;/em&gt; ring buffers: the receive buffer (&lt;code&gt;_rx_buffer&lt;/code&gt;) is filled by an interrupt service routine and is emptied by you calling &lt;code&gt;Serial.read()&lt;/code&gt;. The transmit buffer (&lt;code&gt;_tx_buffer&lt;/code&gt;) is filled by you calling &lt;code&gt;Serial.write()&lt;/code&gt;, &lt;code&gt;Serial.print()&lt;/code&gt; or &lt;code&gt;Serial.println()&lt;/code&gt; (the line &lt;code&gt;_tx_buffer-&amp;gt;buffer[_tx_buffer-&amp;gt;head] = c;&lt;/code&gt; in &lt;code&gt;HardwareSerial::write()&lt;/code&gt;), and is emptied by an interrupt service routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These interrupt service routines are defined in HardwareSerial.cpp. They start with lines like &lt;code&gt;ISR(SOMETHING_vect)&lt;/code&gt;. They are triggered by the hardware UART. The transmit ISR is triggered when the UART is ready to accept a new byte to transmit (when it is done transmitting byte &lt;em&gt;n&lt;/em&gt;, it starts transmitting byte &lt;em&gt;n&lt;/em&gt;+1 and is ready to accept byte &lt;em&gt;n&lt;/em&gt;+2 in its TX buffer). The receive ISR is triggered when a new byte has been received.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when does it get initialised?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you call &lt;code&gt;Serial.begin()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-02-24T10:34:02.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8846" PostTypeId="1" CreationDate="2015-02-24T13:58:27.777" Score="0" ViewCount="1625" Body="&lt;p&gt;I am using a Arduino Due. I am doing a project on Visible Light Communication. I need to convert a binary data into a PWM Signal. Can anyone suggest me a method of generating that PWM Signal based on the binary data given? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You. &lt;/p&gt;&#xA;" OwnerUserId="7530" LastEditorUserId="186" LastEditDate="2015-02-24T23:11:03.543" LastActivityDate="2019-04-17T21:53:42.600" Title="Converting Random Binary Data to PWM Signal" Tags="|arduino-due|pwm|communication|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8847" PostTypeId="1" CreationDate="2015-02-24T14:07:25.167" Score="2" ViewCount="21882" Body="&lt;p&gt;I recently bought an Arduino Pro Mini(3.3V 328p, 8MHz) along with a CP2102 USB to TTL UART convertor. When I try to upload a sketch to the Pro Mini using it, I get a &lt;code&gt;avrdude:stk500_recv(): programmer is not responding&lt;/code&gt; error. My connection was like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino pro mini                CP2102&#xA;TXO  ----------------------------&amp;gt; TXD&#xA;RXI  ----------------------------&amp;gt; RXD&#xA;VCC  ----------------------------&amp;gt; 3V3&#xA;GND  ----------------------------&amp;gt; GND&#xA;DTR  ----------------------------&amp;gt; DTR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried inter-connecting the TXO and RXI pins and had no luck. Also pressing and releasing the reset button on the Pro Mini doesn't seem to work either.  I also tried programming it with my Arduino Uno, by removing the 328 and connecting correspondingly. Still no use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any one have any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7531" LastEditorUserId="6936" LastEditDate="2016-01-24T21:24:00.073" LastActivityDate="2020-12-17T04:23:26.557" Title="Getting &quot;avrdude:stk500_recv(): programmer is not responding&quot; while uploading sketch to Arduino Pro Mini" Tags="|arduino-ide|arduino-pro-mini|" AnswerCount="8" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="8848" PostTypeId="2" ParentId="8846" CreationDate="2015-02-24T14:16:47.460" Score="1" Body="&lt;p&gt;Count the amount of time a signal is high over a certain period, and use the ratio of on time to period as the duty cycle for the PWM signal.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-24T14:16:47.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8849" PostTypeId="1" CreationDate="2015-02-21T21:59:23.923" Score="1" ViewCount="2303" Body="&lt;p&gt;Just starting with Arduino and have gotten stuck at the first hurdle: trying to connect an Arduino Nano with my Mac Book Pro which runs 10.10. I can't seem to find the right port as all suggestions have bluetooth in the name and none with USB anything. Also the post list does not change when I plug/unplug the Arduino. Looking at &lt;a href=&quot;http://arduino.cc/en/guide/macOSX#toc3&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/guide/macOSX#toc3&lt;/a&gt; it says that I need to install FTDI software to get the USB port to show, however, having done this it still does not work. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Calum&lt;/p&gt;&#xA;" OwnerDisplayName="Calum Mclellan" LastActivityDate="2015-04-08T17:23:10.133" Title="Installing Ports for Arduino Nano on Mac OS X Yosemite" Tags="|osx|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8850" PostTypeId="2" ParentId="8849" CreationDate="2015-02-22T11:37:45.060" Score="2" Body="&lt;p&gt;Had exactly the same problem. Also using 10.10 and just got an Arduino. What worked for me was using a different cable. The one that came with my Arduino Uno only provided power not data. If you have a printer, it might have the right cable, just test it quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: In addition, whilst trying to find solutions, I also installed 64bit mac FTDIUSBSerialDriver_v2_2_18.dmg. I'm not sure if it made a difference. As after installing it and using the original cable the problem persisted. &lt;/p&gt;&#xA;" OwnerDisplayName="tiisetso" LastActivityDate="2015-02-22T11:37:45.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8851" PostTypeId="2" ParentId="8846" CreationDate="2015-02-24T16:20:38.170" Score="2" Body="&lt;p&gt;So, if you simplu has to convert the binary data to PWM signal there are few things you need to cover:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If the binary data that you are receiving from the sensor is linear or non linear.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the size of binary byte. Ex: int(16 bits),char(8 bits),long (32 bits).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If it is linear, then if the data is multiplied by some number it will output a value betwen 0-255.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the data is not linear than you just need to create an giant array with the pwm intensite value direct without any particular mathematical function. Ex: array[1024] = {0,1,1,2,3,4,5,5,6,6,10,9,...}; (1024 values because if you are using analog input. Then you can direct output the values from array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(3,array[x]); //x being your data&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's the linear Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   //map(value, fromLow, fromHigh, toLow, toHigh);&#xA;    y = map(x, 0, 1023, 0, 255);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing this, y will receive a value from 0 to 255. You just need to first do a simple serial program that prints you through arduino serial window the binary data and see if the data increases or decreases conform your light project.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I don't know about your programming levels or if you are using a digital sensor or analog sensor, but if you are using a digital sensor, so you are probaly using SPI communication or i2c. Then you just need to read that binary data and take where the values bits are with bit wize manipulation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y=(x &amp;amp; (0xfff&amp;lt;&amp;lt;3))&amp;gt;&amp;gt;3;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Tell me more about the source of data, how this data is and how is the behavior of the data so i can help you a lot more. Thanks&lt;/p&gt;&#xA;" OwnerUserId="7522" LastActivityDate="2015-02-24T16:20:38.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8852" PostTypeId="2" ParentId="5185" CreationDate="2015-02-24T16:34:35.317" Score="0" Body="&lt;p&gt;I have used Sparkfun's OpenLog as I have also found the SD library slow when writing many small samples.  It lets you log directly from the Serial connection, so you should be able to get at least the 127 samples per second.  You may also try increasing the baud rate, especially if you are using outputting to Serial.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-02-24T16:34:35.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8854" PostTypeId="1" CreationDate="2015-02-24T18:26:54.860" Score="2" ViewCount="286" Body="&lt;p&gt;I am having problems uploading my code to my Arduino Uno. The code that's already up, is running normally. The error code I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ioctl(&quot;TIOCMSET&quot;): Connection timed out&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;ioctl(&quot;TIOCMSET&quot;): Connection timed out&#xA;[Stino - Error 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7534" LastEditorUserId="220" LastEditDate="2015-02-26T02:23:31.383" LastActivityDate="2015-02-26T02:23:31.383" Title="Problem uploading code to Arduino Uno using stino" Tags="|arduino-uno|uploading|ubuntu|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8855" PostTypeId="2" ParentId="8846" CreationDate="2015-02-24T18:32:12.007" Score="1" Body="&lt;p&gt;Rather than completely build everything from scratch,&#xA;perhaps you can use some already tested and debugged Arduino library designed for free-space optical communication, such as&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ken Shirriff. &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;A Multi-Protocol Infrared Remote Library for the Arduino&quot;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A1RONZO at Sparkfun. &lt;a href=&quot;https://learn.sparkfun.com/tutorials/ir-communication&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;IR Communication tutorial&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Dave. &lt;a href=&quot;http://www.youtube.com/watch?v=BUvFGTxZBG8&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;EEVblog #506 - IR Remote Control Arduino Protocol Tutorial&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/MultiIR&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Multitasked IR transmission&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/UniversalRemote/UniversalRemote&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Arduino universal remote&quot;&lt;/a&gt; (has 2-way communication, both send and receive)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sbprojects.com/knowledge/ir/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;IR Remote Control Theory&quot;&lt;/a&gt; (links to many different &quot;standard&quot; infrared protocols)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Practically all of these systems convert expand arbitrary binary data to structured &quot;frames&quot; or &quot;packets&quot; of information including some sort of checksum.&#xA;Each packet is repeated several times; hopefully the receiver catches at least one of them.&#xA;Each bit of the packet is expanded to either the &quot;pattern representing a 0 bit&quot; (typically turning the LED off for the full bit time) or the &quot;pattern representing a 1 bit&quot; (typically blinking the LED at 38 KHz for the full bit time, typically using a PWM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the hardware and the software simpler and cheaper, most of these systems transmit only a few dozen bits per second.&#xA;A few free-space optical communication systems are designed to run much faster, such as &lt;a href=&quot;http://en.wikipedia.org/wiki/RONJA&quot; rel=&quot;nofollow noreferrer&quot;&gt;RONJA&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="27346" LastEditDate="2019-04-17T21:53:42.600" LastActivityDate="2019-04-17T21:53:42.600" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8856" PostTypeId="1" CreationDate="2015-02-24T19:31:35.047" Score="3" ViewCount="868" Body="&lt;p&gt;I'm using Arduino UNO, and today I upgraded my IDE from 1.0.6 to 1.6, just to upgrade, nothing special.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got my libraries again but I got an error with a code that was working OK. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223:0,&#xA;                 from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.h:53,&#xA;                 from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:32:&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h: In member function 'HardwareSerial&amp;amp; HardwareSerial::operator=(const HardwareSerial&amp;amp;)':&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrh', can't use default assignment operator&#xA; class HardwareSerial : public Stream&#xA;       ^&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrl', can't use default assignment operator&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsra', can't use default assignment operator&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrb', can't use default assignment operator&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrc', can't use default assignment operator&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_udr', can't use default assignment operator&#xA;C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp: In member function 'void ModbusMaster::begin(uint16_t)':&#xA;C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:139:16: note: synthesized method 'HardwareSerial&amp;amp; HardwareSerial::operator=(const HardwareSerial&amp;amp;)' first required here &#xA;       MBSerial = Serial;&#xA;                ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I couldn't find the real error, can someone help me?&lt;/p&gt;&#xA;" OwnerUserId="7168" LastEditorUserId="19409" LastEditDate="2017-06-15T12:12:50.887" LastActivityDate="2017-08-14T23:46:08.760" Title="Arduino Upgrading from 1.0.6 to 1.6, code doesn't work anymore" Tags="|arduino-ide|compile|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8857" PostTypeId="1" AcceptedAnswerId="13916" CreationDate="2015-02-24T20:28:32.767" Score="0" ViewCount="2660" Body="&lt;p&gt;I have 4 rotary encoders connected to an MCP23017 which in turn is connected to interrupt port 0 on the arduino (and to I2C of course). Everything works fine: I get interrupts for all 4 rotary encoders, can read the values for them and even store these values in the EEPROM and load them in setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RVWWC.png&quot; alt=&quot;Fritzing schematic of the (initially) working setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I connect a WS2812 LED to the arduino (with a resistor and a capacitator in front of it). I connect the UNO and the led lights up. I attach the serial console (resetting the UNO) and it stops working (LED does not light up). This could just be simple wiring mistake and is not my real problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I remove the LED (and the capacitor) from the board and start everything up again. I can see via the serial console that the UNO works, however it does not receive any interrupts anymore. I exchange the MCP23017 thinking I fried it somehow but that doesn't change anything either...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some sort of state the UNO has I could have affected?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or could I have fried the interrupt &quot;sub-system&quot; on the UNO (again: all the other stuff still works)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The code is here: &lt;a href=&quot;https://github.com/qollin/Liting/blob/master/src/Liting.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/qollin/Liting/blob/master/src/Liting.cpp&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7536" LastEditorUserId="7536" LastEditDate="2015-02-24T21:01:54.890" LastActivityDate="2015-08-03T18:54:30.863" Title="What could cause interrupts from MCP23017 suddenly stop working?" Tags="|arduino-uno|interrupt|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8858" PostTypeId="2" ParentId="8842" CreationDate="2015-02-24T22:55:32.700" Score="2" Body="&lt;p&gt;The Arduino Due and Arduino Mega ADK can both serve as a USB Host. You can also use the &lt;a href=&quot;http://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3421E.html&quot; rel=&quot;nofollow&quot;&gt;chip that the Mega&lt;/a&gt; uses yourself &lt;/p&gt;&#xA;" OwnerUserId="7537" LastEditorUserId="1585" LastEditDate="2015-03-06T21:29:11.367" LastActivityDate="2015-03-06T21:29:11.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8859" PostTypeId="1" CreationDate="2015-02-25T00:57:27.243" Score="2" ViewCount="986" Body="&lt;p&gt;I'm trying to transfer data beetween the two scripts. I'm already using the YunMesseger library (&lt;a href=&quot;https://github.com/plotly/YunMessenger&quot; rel=&quot;nofollow&quot;&gt;https://github.com/plotly/YunMessenger&lt;/a&gt;). But it only make the &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino -&gt; Python&lt;/p&gt;&#xA;&#xA;&lt;p&gt;communication.&#xA;I would like to know how to make the reverse way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to point that I'm search for a solution that doesn't involve the use of the Bridge, because I don't want to have concurrency problems. &lt;/p&gt;&#xA;" OwnerUserId="7540" LastActivityDate="2015-02-25T06:24:22.727" Title="Communication between python script and Arduino sketch" Tags="|arduino-yun|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8860" PostTypeId="1" AcceptedAnswerId="8893" CreationDate="2015-02-25T02:57:41.330" Score="0" ViewCount="1880" Body="&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking into automation and I have realized that many of the devices I have around my house transmit 315mhz to their specific controllers.  I know this from reading the labels on the back that say 315mhz&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can use a 315mhz receiver with an arduino to view the signals and log the data based on what happens and mimic certain actions with the transmitter?  In other words can I program the reciever to display every bit passed through 315mhz that is in range?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the virtual wire library parses the data before I receive it, but I don't know to what extent?  If I just dedicate the arduino to watch that pin and print results will that tell me what is being sent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Very Much,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Joel&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="1192" LastEditDate="2015-02-25T03:03:06.713" LastActivityDate="2015-02-26T15:07:05.563" Title="How to access 315mhz signals from household devices, with an arduino 315mhz kit?" Tags="|sensors|rf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8861" PostTypeId="2" ParentId="5380" CreationDate="2015-02-25T03:01:41.263" Score="2" Body="&lt;p&gt;Did you know that the Arduino Uno uses the &lt;a href=&quot;http://www.atmel.com/devices/atmega328.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmel ATmega328P processor&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;using the ADC for analog input in assembly language&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You may want to skim through Chapter &quot;24. Analog-to-Digital Converter&quot; of the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328P datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to read application note &lt;a href=&quot;http://www.atmel.com/Images/doc8444.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;AVR126: ADC of megaAVR in Single Ended Mode&quot;&lt;/a&gt; and browse through the corresponding &lt;a href=&quot;http://www.atmel.com/images/AVR126.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR126 example software&lt;/a&gt;.&#xA;(It's in the C language, but it mentions all the registers you'll need to read the ADC in your assembly language program).&#xA;(As you can tell from the ATmega328 datasheet, the ATmega88 has exactly the same ADC as the ATmega328).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.avr-asm-tutorial.net/avr_en/ADC8.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Assembler source code for the conversion of an analogue voltage to an 8-bit-number&quot;&lt;/a&gt;,&#xA;&lt;a href=&quot;https://sites.google.com/site/avrasmintro/home/usisng-the-adc&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;AVR ASM Introduction: A moron's guide to ADC&quot;&lt;/a&gt;&#xA;and&#xA;&lt;a href=&quot;http://www.avrbeginners.net/architecture/adc/m8_adc_example.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;ATmega8 ADC Example&quot;&lt;/a&gt;&#xA;have a pure assembly language program for reading the ADC on a Atmel AVR chip&#xA;-- alas, on a slightly different chip that may have slightly different registers than the ATmega328P.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="49301" LastEditDate="2019-09-16T11:12:19.640" LastActivityDate="2019-09-16T11:12:19.640" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8862" PostTypeId="2" ParentId="8811" CreationDate="2015-02-25T03:54:42.500" Score="3" Body="&lt;p&gt;Look at &lt;a href=&quot;http://www.batteryuniversity.com/&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Battery University&lt;/strong&gt;&lt;/a&gt; for many good ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both NimH and LiIon are viable for your application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LiIon are easier to manage well &lt;strong&gt;if&lt;/strong&gt; managed well.&lt;br&gt;&#xA;ie do it right and they are easy to manage, but cut corners and they are easier to destroy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NimH can be abused more with a slow degradation in capacity - although complete destruction is possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a LiIOn cell has a ~= 3.0V to 4.2V range you'd probably probably need a step up inverter with 1 cell, or a buck regulator with 2 cells, which is 'annoying'. If you are prepared to use the cell over say a 3.4V to 4.2V range with an LDO regulator for a 3.3V system then you lose a significant amount of available capacity but increase battery cycle life substantially. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nimh give 1.0 - 1.2 V/cell so eg   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;6 cells give 6 - 7.2V for a 5V system,  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;5 cells give say 5.25V - 7V if run down to 1.05V for a 5V system with a suitable LDO regulator, and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 cells give 4 - 4.8V for a 3V3 system.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;NimH are easier overall to build half well and get half good results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LiIon are slightly harder to get going with in most cases, work very well if treated well, and are VERY unforgiving of bad treatment past a certain point. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-25T03:54:42.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8863" PostTypeId="1" CreationDate="2015-02-25T04:33:03.373" Score="2" ViewCount="546" Body="&lt;p&gt;I'm trying to interface with a serial device utilizing Serial1 (pins 18,19) on the Arduino Due. The normal serial port (Serial) is working just fine and is acting as a debug port at the moment - It's also able to communicate with the serial device without a problem when using the normal port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that within the libraries for the Arduino hardware, the avr directory contains HardwareSerial files for the Mega's multiple serial lines, but the header file under the sam director does not. Simply a declaration of the HardwareSerial class with no elaboration on Serial1,Serial2 or Serial3 like the Mega's header contains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone modified the libraries to set up the Arduino Due's multiple serial lines? Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="1406" LastActivityDate="2015-02-25T04:33:03.373" Title="Arduino Due - Multiple Serial Lines" Tags="|serial|arduino-due|avr|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8864" PostTypeId="2" ParentId="17" CreationDate="2015-02-25T05:05:12.797" Score="10" Body="&lt;p&gt;I've had the same message. Every time it has been solved by selecting the right port ie USB under the menu Tools then Ports. Its a simple step but I always forget. I'll unplug the Arduino to stop the current program, plug it in again to my computer to upload the new program and get the error, panic, curse, and only then, remember.&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-02-25T05:05:12.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8865" PostTypeId="2" ParentId="8859" CreationDate="2015-02-25T06:24:22.727" Score="1" Body="&lt;p&gt;One option is to use &lt;a href=&quot;http://docs.spacebrew.cc/&quot; rel=&quot;nofollow&quot;&gt;spacebrew&lt;/a&gt;. This is a cloud-based service, however you can run your own &lt;a href=&quot;https://github.com/spacebrew/spacebrew&quot; rel=&quot;nofollow&quot;&gt;server&lt;/a&gt; which is based on node.js, so it should work on the Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Arduino can then send or receive data using &lt;a href=&quot;https://github.com/julioterra/yunSpacebrew&quot; rel=&quot;nofollow&quot;&gt;yunSpacebrew&lt;/a&gt;, and you can connect it to python using &lt;a href=&quot;https://github.com/Spacebrew/pySpacebrew&quot; rel=&quot;nofollow&quot;&gt;pySpacebrew&lt;/a&gt;. This is a pure python library, so it ought to run fine on the Yun.&lt;/p&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-02-25T06:24:22.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8866" PostTypeId="1" CreationDate="2015-02-25T09:13:59.123" Score="2" ViewCount="2860" Body="&lt;p&gt;In this forum thread on arduino.cc &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=107375.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=107375.0&lt;/a&gt; they talk about it not being possible to get 800 x 600 video in color with the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My case is a bit different:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't care about color, it can be black and white / grayscale.&lt;/li&gt;&#xA;&lt;li&gt;I don't need 800 x 600 just 640 x 480.&lt;/li&gt;&#xA;&lt;li&gt;I can do with something like 2-5 frames per second.&lt;/li&gt;&#xA;&lt;li&gt;I don't need it to be processed by the arduino, just transmitted through an ethernet shield.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In other words, it is possible to transmit simple video (just enough to handle eg. bios) remote?&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2016-08-03T14:18:06.840" Title="Is it possible to read VGA with an arduino" Tags="|arduino-uno|ethernet|display|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8867" PostTypeId="2" ParentId="8866" CreationDate="2015-02-25T11:32:43.313" Score="1" Body="&lt;p&gt;Well, it's very possible, but actually you'll stress the arduino. You can use it perfectly but the problem is, it takes a lot of time of Arduino. The reason is actually simple: Horizontal syncronization takes each 32uS of arduino, so the code is interrupted a lot, and if you use other codes the screen may flick. But i have a solution for you. I found software libraries:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=102181.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=102181.0&lt;/a&gt;&#xA;or:&#xA;&lt;a href=&quot;http://labdegaragem.com/profiles/blogs/gerando-sinal-vga-colorido-com-arduino-completo&quot; rel=&quot;nofollow&quot;&gt;http://labdegaragem.com/profiles/blogs/gerando-sinal-vga-colorido-com-arduino-completo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last link is in portuguese but you can always ask me anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, what people do is to use for example 2 arduinos to aliviate de stress, you can buy a arduino bare metal chip and put it in a protoboard to reduce costs. Buuut, ther's another very very easy way to work with vga in arduino. Using a isolated hardware:&#xA;&lt;a href=&quot;http://www.hobbytronics.co.uk/serial-vga&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/serial-vga&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need to send serial commands to the vga driver and it will do whatever you want. It comes with a library so you can use in arduino. It's perfect, aliviates the arduino, so you can use your ethernet communication and the price is great (for you, here in Brazil the fees kill a lot of children every day :-( ).&lt;/p&gt;&#xA;" OwnerUserId="7522" LastActivityDate="2015-02-25T11:32:43.313" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8868" PostTypeId="2" ParentId="8762" CreationDate="2015-02-25T12:18:11.087" Score="2" Body="&lt;p&gt;You will need to allow the use of unverified drivers for this version of the Arduino. Unlike the genuine Arduino this board needs the ch340 and ch341 drivers and because they are not verified you will need to run the following command in order for them to work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just got a handful of these clones (so cheap) and once I installed the drivers and then set the nvram kernel extensions to dev mode all was OK.&lt;/p&gt;&#xA;" OwnerUserId="7548" LastActivityDate="2015-02-25T12:18:11.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8871" PostTypeId="1" CreationDate="2015-02-25T12:49:58.937" Score="0" ViewCount="1179" Body="&lt;p&gt;So far, I have connected plus to VIN and minus to GND, but I am curious what would happen if I do it the other way around. And I am not going to try in case I break someting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what will happen?&lt;/p&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2016-03-06T18:12:14.620" Title="What happens if I connect an external power supply, plus to GND and minus to VIN?" Tags="|power|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="8872" PostTypeId="1" AcceptedAnswerId="8933" CreationDate="2015-02-25T13:42:04.910" Score="0" ViewCount="291" Body="&lt;p&gt;I have some code that generates random numbers on the Arduino, it then sends these random numbers firstly, using &lt;code&gt;Serial.print(float data,int lenght)&lt;/code&gt; and as a floating point number using the following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send_float (float arg)&#xA;{&#xA;  // get access to the float as a byte-array:&#xA;  byte * data = (byte *) &amp;amp;arg; &#xA;&#xA;  // write the data to the serial&#xA;  Serial.write (data, sizeof (arg));&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then receive this data using python, take the absolute difference of the two values, discard any differences less than the length with which I send the string and output the rest to the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I observe two things, a) Fluctuations of the order with which I send the data (ie. if I send to 6 decimal places then I see fluctuations of ~1e-6), this is reasonable and b) I see fluctuations of absolute value 1e-8 or lower &lt;strong&gt;independent&lt;/strong&gt; of what accuracy I send the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I send the string to 11 decimal places, when I compare against the float I see fluctuations up to but not above 1e-8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why? This doesn't make any sense. My full code is actually the answer to an old &lt;a href=&quot;https://stackoverflow.com/questions/12664826/sending-float-type-data-from-arduino-to-python/28719607#28719607&quot;&gt;unanswered stack exchange question&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4911" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-02-28T12:07:27.307" Title="Serial, Numbers sent as Floating Point and Characters are different at 1e-8 level" Tags="|serial|python|float|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8873" PostTypeId="1" CreationDate="2015-02-25T13:50:23.567" Score="0" ViewCount="4133" Body="&lt;p&gt;How do I send SMS from an Ethernet shield via SMS Gateway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The site &lt;a href=&quot;https://www.clickatell.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Clickatell&lt;/a&gt; provides free SMS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to do this or is there some other way to do it?&lt;/p&gt;&#xA;" OwnerUserId="6583" LastEditorUserId="4628" LastEditDate="2016-12-29T15:01:57.187" LastActivityDate="2016-12-29T15:01:59.427" Title="How to send SMS from an Ethernet shield via SMS Gateway?" Tags="|arduino-uno|arduino-mega|ethernet|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8874" PostTypeId="2" ParentId="8873" CreationDate="2015-02-25T14:23:29.973" Score="2" Body="&lt;p&gt;First contact Clickatel's support and ask them how to use their API, make yourself familiar with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then when you know that you connect your Arduino to your ethernet shield, I'm just gonna assume you got Arduino's original shield, because you want to support the arduino foundation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardEthernet&lt;/a&gt; if you have the standalone board.&#xA;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardEthernet&lt;/a&gt; if you have the shield board.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="4628" LastEditDate="2016-12-29T15:01:59.427" LastActivityDate="2016-12-29T15:01:59.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8875" PostTypeId="1" CreationDate="2015-02-25T14:31:59.760" Score="1" ViewCount="1144" Body="&lt;p&gt;I am working on home automation project. A network consists of one master device and many (maybe 10-20) slave devices, all communicating via these &lt;a href=&quot;http://cdn.instructables.com/F4L/W6X0/HM8DG3PI/F4LW6X0HM8DG3PI.LARGE.jpg&quot; rel=&quot;nofollow&quot;&gt;RF modules&lt;/a&gt;. I am using arduino in slave devices. Master will be based on raspberry Pi (most probably). Slave nodes can be sensors or switches(to control household electronics). To and fro communication will include data such as : a) Turn off bulb 1, b) Turn on TV, c) Set the bulb brightness to 34%, d) Temperature reading is 23 degree Celsius etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From security point of view, imagine there are similar other networks in the range and one network must not interfere with another. As such, I need to implement some sort of authentication whenever each data transfer takes place between master &amp;lt;---&gt; slave. &lt;strong&gt;What logic do you suggest for this process?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There can be cases when data has not been received successfully by the receiving end. In such cases, I am planning to use some sort of checksum and acknowledgement system. If acknowledgement is not received, data will be resend in time intervals of 1s, 5s, 10s, 30s, 30s. If these 5 resends fail, the slave/master will be considered as unavailable/powered down. &lt;strong&gt;Your opinions/suggestions on this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slave arduino will be busy controlling appliances/sensors connected to it (real busy when controlling appliances). As such, it won't have much time for communication. Less time required for communication == Awesome. &lt;strong&gt;How much time do you think the arduino will take to complete one such data transfer?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution I could think of was using two arduinos connected via i2c in each slave module. One arduino will be busy controlling the lights/sensors. Other one will take care of RF communication. If it receives some valuable info which was meant for this particular module, it will transfer the same to the other one using i2c bus. &lt;strong&gt;Is this a feasible backup plan?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Am I doing wrong by selecting RF modules for this purpose? Should I switch to Zigbees?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks guys for reading. Any constructive suggestions from your side will be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="7553" LastActivityDate="2015-07-01T05:54:22.797" Title="RF network using Arduino" Tags="|arduino-uno|rf|networking|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="8876" PostTypeId="1" CreationDate="2015-02-25T14:46:21.643" Score="2" ViewCount="546" Body="&lt;p&gt;I know that it's fairly easy to change the emulate keyboard and mouse by Arduino. But I'm quite specific about the goal I would like to achieve hence I would appreciate if you could advise me which components (Arduino compatible) I am going to need to have such a built:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Physical usb keyboard --&gt; Arduino via usb IN --&gt; keys remapping (for example pressing q will return ctrl+3 or more advanced action) --&gt; Arduino USB OUT (which I can directly plug in to my computer and receive modified keyboard commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up I  just want Arduino to work as intermediary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will simple Arduino Uno + USB shield do the work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you a lot for your support!&lt;/p&gt;&#xA;" OwnerUserId="7565" OwnerDisplayName="Kamil" LastEditorUserId="7565" LastEditDate="2015-02-26T08:12:47.060" LastActivityDate="2015-02-26T08:12:47.060" Title="Which components to built remapping keyboard via USB in + out (remapped)" Tags="|usb|signal-processing|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8878" PostTypeId="2" ParentId="8871" CreationDate="2015-02-25T15:08:48.937" Score="1" Body="&lt;p&gt;Some systems have protection against people connecting things in reverse.&lt;br&gt;&#xA;Some don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On unprotected systems you MAY destroy the powered system and/or you MAY destroy the power supply - both these depend on happenstance, system design and luck.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly worse - you may damage the target system in an inobvious way so that it subsequently behaves incorrectly or damages other equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Systems which are designed to be protected may not be protected in all cases. eg if you have a &quot;shield&quot; connected that accesses the Vin pin outside the protection diode the reverse polarity voltage may damage the shield AND current may travel via the shield circuitry back into the Arduino via other connections.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Advice on You tube may just sometimes very very occasionally be wrong. Or more often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;a href=&quot;http://www.google.co.nz/imgres?imgurl=https://electrosome.com/wp-content/uploads/2014/07/Arduino-Uno-R3-Schematic-Diagram.jpg&amp;amp;imgrefurl=https://electrosome.com/arduino-uno/&amp;amp;h=1739&amp;amp;w=3144&amp;amp;tbnid=_4QHyB6a-usdPM:&amp;amp;zoom=1&amp;amp;docid=DagWDjCRj--l2M&amp;amp;ei=3eHtVITPL4XZ8gWW_IK4DA&amp;amp;tbm=isch&amp;amp;ved=0CCEQMygFMAU&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;this &quot;Reference Schematic&quot;&lt;/strong&gt;&lt;/a&gt;  is correct (as you'd hope it was) then Vin is connected to the &quot;inside&quot; of protection diode D1 - so D1 does not protect against reversed polarity. See lines and boxes in red.&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3gNVF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Larger version of diagram &lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D1 does protect against reversed polarity on &quot;PWRIN&quot;.&lt;br&gt;&#xA;How PWRIN relates to shield feeding I know not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3gNVF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-25T15:08:48.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8879" PostTypeId="1" AcceptedAnswerId="8884" CreationDate="2015-02-25T15:59:26.787" Score="2" ViewCount="12633" Body="&lt;p&gt;How to get a One-Wire address of a given WS2812B pixel? I bought several of these, and I cannot make them light. On the other hand, when I connect the addressable LED strip made of these diodes, I have no problem controlling it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my set-up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YtYR3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried many programs, e.g. AdaFruit_NeoPixel -&gt; simple, setting number of LEDS to 1, but no effect. No blinks, nothing - as if the diodes were dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If every One-Wire device is identifiable by 64 bit ID, how does the Arduino know the correct &quot;order&quot; of the LEDS on the ribbon? How to tell the Arduino the new sequence of the LEDS on the strip that would result if I replace one (broken) LED with another?&lt;/p&gt;&#xA;" OwnerUserId="7329" LastEditorUserId="7329" LastEditDate="2015-02-26T16:32:47.587" LastActivityDate="2016-05-07T23:58:27.577" Title="ws2812b NeoPixel - how to address it? How Arduino knows the correct order of LEDS on the stripe?" Tags="|led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8880" PostTypeId="1" CreationDate="2015-02-25T16:51:44.207" Score="0" ViewCount="7184" Body="&lt;p&gt;I need to modify the WiFiWebServer &lt;a href=&quot;http://arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt; on the Arduino website but I am having some trouble understanding the code. I am hoping to get some advice from the community on the client-server relationship in this example so I can better modify it to suit my needs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am having is the jump between server commands and client commands. Initially I see server commands; server.begin() in setup and server.available() in the loop. The commands quickly shift, however, as nearly all the other commands in the loop become client.println()'s. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the initial client commands that deal with whether the client is available and whether it is still connected. The part I don't understand, however, are the client.read and client.println commands. Even client.read makes some sense to me since I want some communication from the client side but why does the example use client.print? The &lt;a href=&quot;http://arduino.cc/en/Reference/WiFiClientPrintln&quot; rel=&quot;nofollow&quot;&gt;Arduino webpage&lt;/a&gt; defines the WiFiClientPrintln as data you write from the client to the server that it is connected to. Wouldn't I want to use server.print since the Arduino in this example is the server and the client is the computer I use to view the webpage that I built on the server?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the WiFIWebServer example as a template for my project. The goal is to have the Arduino take sensor readings and post them on a webpage it hosts by acting on the server. This is quite similar to the example but I notice that I have slow update/transmission speeds and errors when a different client connects to the server. For example, if I view the website on my computer, I get the data fairly consistently If somewhat slow. If I try to view the same website off my mobile device, however, I have problems connecting, may need to refresh several times and the webpage crashes on the computer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to troubleshoot the issue but going through the code I can't figure out the reason for the client.println()'s instead of server.println(). Even if that isn't the cause of my multi-client issue, I would like a better understanding of the code before going forward so would appreciate any guidance you can provide. &lt;/p&gt;&#xA;" OwnerUserId="7554" LastEditorUserId="9962" LastEditDate="2016-02-25T08:19:11.350" LastActivityDate="2016-12-21T16:17:39.653" Title="Arduino WiFIWebSever - why client.println()?" Tags="|wifi|web-server|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8881" PostTypeId="2" ParentId="8880" CreationDate="2015-02-25T18:00:47.993" Score="0" Body="&lt;p&gt;client.println() is sending data to a specific client.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;server.println() is sending data to every client that is connected to the server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, i believe that the arduino keeps sending data to the client instead of stopping the request. You should have some javascript that updates the value say... every 5 seconds or so... Or you could have a&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;meta http-equiv=&quot;refresh&quot; content=&quot;5&quot;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inside the  part which would tell the browser to refresh the page every 5 seconds instead of using the header&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://tentencraft.net/demo1.php&quot; rel=&quot;nofollow&quot;&gt;http://tentencraft.net/demo1.php&lt;/a&gt; vs &lt;a href=&quot;http://tentencraft.net/demo2.php&quot; rel=&quot;nofollow&quot;&gt;http://tentencraft.net/demo2.php&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7555" LastEditorUserId="7555" LastEditDate="2015-03-01T15:16:14.733" LastActivityDate="2015-03-01T15:16:14.733" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8882" PostTypeId="1" AcceptedAnswerId="8883" CreationDate="2015-02-25T19:02:09.827" Score="0" ViewCount="469" Body="&lt;p&gt;I am using an Arduino Uno R3 with the MPU 6050 to get motion data. Different example codes use different baud rates, without any proper explanation as to why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do I know which baud rate is perfect for my project?&lt;/p&gt;&#xA;" OwnerUserId="4305" LastActivityDate="2015-02-25T19:42:04.397" Title="Decide on baud rate for a project using Arduino Uno R3" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8883" PostTypeId="2" ParentId="8882" CreationDate="2015-02-25T19:42:04.397" Score="5" Body="&lt;p&gt;I most cases it doesn't matter!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases the highest possible is preferred, as it prevents delays. That is when the buffer is full (when sending large amounts of data through the serial connection). As &lt;code&gt;Serial.write&lt;/code&gt; will block until there is room in the buffer. In most cases this won't be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running your arduino at slower speeds, you have to select a lower baudrate, or the micro-controller can't keep up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When connection to other devices (e.g. GSM shield) using serial, that device may require a specific baudrate.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-02-25T19:42:04.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8884" PostTypeId="2" ParentId="8879" CreationDate="2015-02-25T20:20:03.483" Score="4" Body="&lt;p&gt;The WS2811/2812/2812B is not a 1-Wire device but is in fact a timing-based shift register with 3 LEDs (external in the case of the WS2811) connected to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as valid bit pulses are sent to the input of one of these devices it will shift the data through it and subsequently out of its data output. Connecting this output to the input of another device will shift data into that device as well, with the latest data sent being transmitted towards the furthest device in the chain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Provided 24 bits per device are sent before the latch signal, The first 24 bits will be shifted into the first device, the second 24 bits into the second device, and so on until the last 24 bits into the last device in the chain. Once the latch signal is received, the devices will switch to the color indicated by the 24 bits currently shifted into them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since all of the devices use the same signaling (the only differences being supply level and the presence of a built-in RGB LED), they can be replaced freely with devices of the same or different make between the three.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2016-05-07T23:58:27.577" LastActivityDate="2016-05-07T23:58:27.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8886" PostTypeId="1" CreationDate="2015-02-25T21:41:19.787" Score="2" ViewCount="93" Body="&lt;p&gt;I have GPRS(GPRS_Shield_V1.0), weather shield and arduino uno R3. When I use Arduino and GPRS it works perfectly and when I used Weather Shield it also worked perfectly. But weather shield needs wire library, to use sensors. And when I use GPRS library with wire library, my program prints the same string many times. How I can use these two shields together?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are some pics of my connected shields:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://puu.sh/gcvk3/85595c38c7.jpg&quot; rel=&quot;nofollow&quot;&gt;http://puu.sh/gcvk3/85595c38c7.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://puu.sh/gcvpc/22185212d3.jpg&quot; rel=&quot;nofollow&quot;&gt;http://puu.sh/gcvpc/22185212d3.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, I'm not using A0,A1,A2,A3,A4,A5 pins for GPRS Shield. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="7561" LastEditorUserId="7561" LastEditDate="2015-02-25T22:07:09.387" LastActivityDate="2015-02-25T22:07:09.387" Title="GPRS and Weather Shields" Tags="|arduino-uno|wire-library|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8887" PostTypeId="2" ParentId="8827" CreationDate="2015-02-25T21:49:07.787" Score="0" Body="&lt;p&gt;Found it here with 94 chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The author states, &quot;I have made a little library for Protel 99SE with schematic sybols of AVR chips.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.avrfreaks.net/forum/avr-8bit-microcontrollers-protel-99-library&quot; rel=&quot;nofollow&quot;&gt;http://www.avrfreaks.net/forum/avr-8bit-microcontrollers-protel-99-library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3219" LastActivityDate="2015-02-25T21:49:07.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8888" PostTypeId="2" ParentId="8866" CreationDate="2015-02-25T22:17:05.410" Score="4" Body="&lt;p&gt;Trying to &lt;em&gt;capture&lt;/em&gt; analog video such as VGA and transmit it over Ethernet is going to be technically challenging, and of questionable wisdom (at least without compression).  A conventional ATmega-based Arduino is just about the &lt;em&gt;worst&lt;/em&gt; contemporary platform you could choose for this job - even aside from the VGA issue, it is a poor choice for Ethernet requiring an expensive add-on.  But just for the sake of &quot;can it be done&quot; ....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can threshold your signal to a digital level (assuming a high contrast image) this probably can be done, crudely, but will be quite tricky.  The display is likely to be very blurred horizontally - really, it would only be worth doing for bragging points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to realize is that the standard VGA 640x480x60 mode has a pixel clock of 25.175 MHz, and most others will be even faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach would be to try to write a program which samples a digital pin (directly, no Arduino abstractions) to memory as fast as possible.  This would not capture every pixel, but rather something like every 10th.  You would then have to send these over the network before you fill up your available memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky part is that you then have to go back, and scan another frame of video with a slight offset, so that by getting every 10th pixel again, you effectively get the pixel adjacent to the first.   And then you do it again, and again, until you have collectively transmitted the entire screen, which hopefully hasn't changed much as you did it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's going to be tricky as you will have to work your delays from the sync signals, and you really want a delay which is a fraction of ATmega's clock - which won't happen without external circuitry (programmable delay buffer, etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole project would be a lot more feasible on an 80+ MHz ARM Cortex part, as you could then use a counter/timer to generate pixel-or-less-adjustable starting delays relative to the sync pulse.  An FPGA would likely be an even better choice.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-08-03T14:18:06.840" LastActivityDate="2016-08-03T14:18:06.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8889" PostTypeId="2" ParentId="8784" CreationDate="2015-02-25T23:03:52.387" Score="1" Body="&lt;p&gt;Webpages usually return data in text format with new line characters at the end.&lt;br&gt;&#xA;In case of 55 you would get &quot;55\r\n&quot; or [53, 53, 13, 10] in bytes.&lt;br&gt;&#xA;You need to parse the characters, like &lt;a href=&quot;http://arduino.cc/en/Reference/ParseInt&quot; rel=&quot;nofollow&quot;&gt;Serial.parseInt()&lt;/a&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are also only sending every second byte back to the serial monitor and only saving the last byte from the other every second byte.&lt;br&gt;&#xA;After you read a byte with Serial.read() you can't read the same byte again, you get the next one.&lt;br&gt;&#xA;In case of 55 you would send back &quot;5\r&quot; to the serial monitor and only store &quot;\n&quot; or 10 into dollars.&lt;br&gt;&#xA;In case of 0 you would send back &quot;0\n&quot; to the serial monitor and store some unknown value into dollars, because you read more bytes that was sent.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-02-25T23:03:52.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8891" PostTypeId="2" ParentId="8847" CreationDate="2015-02-26T12:06:45.673" Score="0" Body="&lt;p&gt;If this is a cheap clone it may be that there is no bootloader installed. You might try using a programmer or an &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Arduino as ISP&lt;/a&gt; to reprogram the device if this is the case. Using ISP programming will avoid any problem with serial connections as it is using SPI wiring instead and the Arduino IDE allows you to load the necessary bootloader using this method to enable programming over serial. You will need either an ISP programmer or another Arduino however.&lt;/p&gt;&#xA;" OwnerUserId="6703" LastActivityDate="2015-02-26T12:06:45.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8892" PostTypeId="2" ParentId="6468" CreationDate="2015-02-26T13:38:40.167" Score="2" Body="&lt;p&gt;What one that is the best is highly subjective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though my &lt;strong&gt;personal&lt;/strong&gt; experience is that arduinos original is the one with the best support. Where you can find alot of documentation about the other ones, you might need to do some legwork updating the code to the latest version of the arduino ide or use an older ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that some Arduinos has integrated ethernet, and others are SHIELDS, you recognize the arduinos with ethernet by the power-connector, and the shields by the distinct name containing &quot;Shield&quot;, though shields require an arduino to work. The arduino with integrated ethernet does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also be aware that not all shields fits arduinos boxes if you want to encase it. And of cause, buying arduinos original products, cost a bit more - but you support the arduino foundation, and further development of the products.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="3638" LastEditDate="2015-02-26T13:52:30.310" LastActivityDate="2015-02-26T13:52:30.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8893" PostTypeId="2" ParentId="8860" CreationDate="2015-02-26T14:46:17.400" Score="3" Body="&lt;p&gt;&lt;strong&gt;The Short Answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory it is possible to do what you are asking.&#xA;There are examples of using an Arduino to send and receive messages at 315 MHz. Such as &lt;a href=&quot;http://www.buildcircuit.com/how-to-use-rf-module-with-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although these devices might not even be compatible with the ones you are using. They may be modulating their signal differently or framing their data differently or at different baud rates or encoding bits differently or a number of other fundamental differences that would make them incompatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Long Not Quite An Answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is more to the problem than just being able to get bits at 315 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For one you would need to know how the bits are encoded. See some of the answers on &lt;a href=&quot;https://electronics.stackexchange.com/questions/81399/reverse-engeneering-a-home-automation-rf-315mhz-transimtter&quot;&gt;this&lt;/a&gt; post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if it was a simple high low stream of even width bits. You also need to know what baud rate the bits are being transmitted at so you can sync with it. (Consider 4800 vs 9600 baud, slow I know but just an example. You just got a bit stream, was it 1010 at 4800 baud or 11001100 sent at twice the speed of 9600.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not to mention that the lowest level of data is probably not just a stream of bits, but is probably framed in some way and grouped into a byte/bytes. Or has a leader to help lock onto the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even once you are getting reliable data you would need to know the data structure. Is the data arranged in packets? Do they have a packet header? Does the header contain these packet destination address? Where in the header is this data? How is  the data apart from the header structured? What does it mean?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Knowing the answers to these questions defines, or is defined by, the protocol that is being used by the transmitter (as others are saying in comments.) But these are only a few simple questions that &lt;strong&gt;start&lt;/strong&gt; to define a protocol. Often this information is difficult to come by. Often in the case of proprietary protocols it is very very difficult.&lt;/p&gt;&#xA;" OwnerUserId="7450" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-02-26T15:07:05.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8894" PostTypeId="1" AcceptedAnswerId="10009" CreationDate="2015-02-26T15:09:54.307" Score="0" ViewCount="642" Body="&lt;p&gt;I went &amp;amp; impulse-bought a Maplin &lt;a href=&quot;http://www.maplin.co.uk/search?text=Bluetooth+Shield+for+Arduino&quot; rel=&quot;nofollow&quot;&gt;Bluetooth shield&lt;/a&gt; yesterday.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It comes with a little tiny book containing &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=Bluetooth_Shield_for_Arduino&quot; rel=&quot;nofollow&quot;&gt;examples&lt;/a&gt;, and uses the softwareserial library in these; I can load them, and get the Arduino &amp;lt;-&gt; PC communication going OK, however there appears not to be a response from the bluetooth part of the device. The LED lights much as the booklet says it should. I did see it return some odd characters one time, just the once..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the system appears to be alive, I don't want to give up &amp;amp; take it back; however the output from Google is not promising, and my trial to date isn't either - so I'm looking for positive news that this product does actually work for someone somewhere?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the built-in serial in the IDE to talk to it, not X-CTU as they suggest (as they don't do a Linux version).&lt;/p&gt;&#xA;" OwnerUserId="5168" LastEditorUserId="5168" LastEditDate="2015-02-27T15:35:23.370" LastActivityDate="2015-04-11T19:02:28.267" Title="Anyone have the Maplin N97DG bluetooth shield working?" Tags="|arduino-uno|bluetooth|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8895" PostTypeId="1" CreationDate="2015-02-26T16:47:17.133" Score="3" ViewCount="11259" Body="&lt;p&gt;I have a project that requires 4 different RFID-RC522 readers.  The RFID-RC522 has the following pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SDA&lt;/li&gt;&#xA;&lt;li&gt;SCK&lt;/li&gt;&#xA;&lt;li&gt;MOSI&lt;/li&gt;&#xA;&lt;li&gt;MISO&lt;/li&gt;&#xA;&lt;li&gt;IRQ&lt;/li&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;li&gt;RST&lt;/li&gt;&#xA;&lt;li&gt;3.3V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have read that the SDA pin is used for selecting the active device, So I'm thinking that these devices can share data pins.  Is it possible to connect multiple RFID-RC522 readers to the same 3.3V, RST, GND, IRQ, MISO, MOSI and SCK pins if you use a different pin for each SDA?  If so, this would save me a lot of pins.  So far, I have only seen direction on how to connect one RFID-RC522 to an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the MFRC522 library.  It appears to only support one reader because it only allows one SS pin to be identified in the constructor, and offers no way to change it later.  An I missing something or do I need another library?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-02-28T14:56:35.830" LastActivityDate="2015-08-16T18:16:48.117" Title="Connect multiple RFID-RC522 cards?" Tags="|rfid|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8896" PostTypeId="2" ParentId="8895" CreationDate="2015-02-26T18:00:55.573" Score="1" Body="&lt;p&gt;Connect everyone to the MOSI / MISO / SCK and ground, then define every SDA all the way around. and set respectively high low depending on where you want to write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How ever im not sure if you need to set high or low if you want to read. But since you got multiple you can play around with that your self. Feel free to add to this question with the result for future googlers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;#define RST_PIN           7          // Configurable, see typical pin layout above&#xA;#define RST_PIN2           8          // Configurable, see typical pin layout above&#xA;#define SS_PIN           9          // Configurable, see typical pin layout above&#xA;#define SS_PIN2          10          // Configurable, see typical pin layout above&#xA;&#xA;....&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.&#xA;MFRC522 mfrc522_2(SS_PIN2, RST_PIN2);   // Create MFRC522 instance.&#xA;&#xA;....&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); // Initialize serial communications with the PC&#xA;  SPI.begin();        // Init SPI bus&#xA;  mfrc522.PCD_Init(); // Init MFRC522 card&#xA;  mfrc522_2.PCD_Init(); // Init MFRC522 card&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3638" LastEditorUserId="3638" LastEditDate="2015-03-09T08:30:53.923" LastActivityDate="2015-03-09T08:30:53.923" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8898" PostTypeId="1" CreationDate="2015-02-26T20:17:33.227" Score="1" ViewCount="11428" Body="&lt;p&gt;I've been trying to write a very simple program using Arduino to tell a servo to go to a specific angle when a button is pressed, and to another specific angle when it is released. I find that, even though my sketch is but the simplest possible if then else statement without anything added to it, the servo goes to the right angle when the button is pressed, but when it is released, the servo oscillates between the two specified angles at a regular rate (about once every second). What's even stranger is that when i add delay time to the end of the loop in my sketch, the oscillation becomes more like twitching, and the more delay i add the weirder and less predictable the twitching becomes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;added info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;Servo Servo1;&#xA;int const switchPin = 4;&#xA;int switchState = 0;&#xA;void setup() &#xA;{ &#xA;    Servo1.attach(11); &#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;    switchState = digitalRead(switchPin);&#xA;    if (switchState == HIGH) { &#xA;        Servo1.write(40); &#xA;    } else { &#xA;        Servo1.write(70); &#xA;        delay(39); &#xA;    } &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the power supply is the regular usb connector plugged from the board to my computer. The circuit is virtually similar to the &quot;mood cue&quot; project on the arduino projects book, except there is a button connected to digital pin 4 instead of a potentiometer.&lt;/p&gt;&#xA;" OwnerUserId="7577" LastEditorUserId="2881" LastEditDate="2015-02-27T13:45:57.827" LastActivityDate="2015-07-28T05:56:13.610" Title="Why does my servo twitch and turn on its own?" Tags="|arduino-uno|servo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8899" PostTypeId="1" AcceptedAnswerId="8901" CreationDate="2015-02-26T22:02:19.373" Score="1" ViewCount="657" Body="&lt;p&gt;I want to control my fog machine with an Arduino.  Has a simple button that is used to activate the machine.  I want to press this button using an Arduino digital output pin, but the fog machine is operating on its own electrical circuit.  How do I use the Arduino to activate this machine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I a few other machines with buttons that I want to wire into an Arduino, so is there a generic solution?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-02-27T03:05:28.473" Title="Fog machine Arduino integration" Tags="|button|relay|transistor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8900" PostTypeId="1" AcceptedAnswerId="8902" CreationDate="2015-02-26T22:07:34.067" Score="0" ViewCount="1394" Body="&lt;p&gt;I have a tv remote that I want to connect to an Arduino so that I can send a series of commands to the TV using the remote.  I would like to open the remote and solder transistors or a Transistor Array in place of the buttons.  I have never done this before, so what do I need to be aware of?  I think that I will need to power the remote using the Arduino's power supply, but I am a bit foggy on the details.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-02-28T18:11:02.260" Title="Tv remote connection to an Arduino" Tags="|power|ir|transistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8901" PostTypeId="2" ParentId="8899" CreationDate="2015-02-26T23:02:21.347" Score="2" Body="&lt;p&gt;You can interface with the fog machine's button by:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use a Relay (this will isolate the fog machine's circuit from your Arduino's)&lt;/li&gt;&#xA;&lt;li&gt;Use a Servo to physically press the button on the fog machine&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I believe those would be the simplest and most generic.&lt;/p&gt;&#xA;" OwnerUserId="7292" LastEditorUserId="7292" LastEditDate="2015-02-26T23:10:55.583" LastActivityDate="2015-02-26T23:10:55.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8902" PostTypeId="2" ParentId="8900" CreationDate="2015-02-26T23:42:51.973" Score="3" Body="&lt;p&gt;If you're just running lines to the buttons, you won't need to power the remote from the arduino.  You could just let it keep the internal batteries.  But it would be possible to wire it up for power as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a learning project, you could just take it apart and see if you can access the button contacts.  See if the contacts are split.  If so, shorting one side to the other should count as a button press.  But the details have nothing to do with an arduino.  They would depend on your specific remote and how it's constructed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your purpose is really to control the TV (rather than learning about the remote and fiddling with it), it will be much easier (and probably cheaper) to blast the IR without involving the remote at all.  A single IR transmitter and a library would work in most cases.  As an example: &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow&quot;&gt;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.  By coincidence, Adafruit just posted an updated guide to IR library use on Arduino.  &lt;a href=&quot;https://learn.adafruit.com/using-an-infrared-library/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/using-an-infrared-library/overview&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3500" LastEditorUserId="3500" LastEditDate="2015-02-27T17:05:43.717" LastActivityDate="2015-02-27T17:05:43.717" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8903" PostTypeId="2" ParentId="1748" CreationDate="2015-02-27T00:35:53.703" Score="2" Body="&lt;p&gt;Yes, I work for an engineering design house and we use Arduino frequently to prototype ideas for clients.  It significantly speeds up the time to get a proof-of-concept device in the hands of the client and their potential investors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have found though that there is significant work to get from an Arduino-based prototype to a commercially-ready product.  Essentially you have to start again and design a completely custom printed circuit board, which is a relatively expensive exercise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are now developing a platform that is compatible with the Arduino IDE, but uses surface-mount modules rather than the Arduino shield system, allowing it to be manufactured in an automated surface-mount facility.  Check it out if you are interested at duinopro.cc.  We are in development stages at the moment, but already have hardware and are mainly working on our website, and designing new modules.&lt;/p&gt;&#xA;" OwnerUserId="7581" LastActivityDate="2015-02-27T00:35:53.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8904" PostTypeId="1" AcceptedAnswerId="8906" CreationDate="2015-02-27T00:59:10.040" Score="2" ViewCount="425" Body="&lt;p&gt;I have a kind of theoretical question. Let's have an Arduino Uno connected through USB that does a lot of Serial.print-ing. Then I disconnect it and I don't see anything on the Serial monitor, but the Arduino is still working. I can judge by the blinking lamps and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I see that all printing goes through HardwareSerial::write from the Arduino core. There is this statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // If the output buffer is full, there's nothing for it other than to &#xA;  // wait for the interrupt handler to empty it a bit&#xA;  // ???: return 0 here instead?&#xA;  while (i == _tx_buffer-&amp;gt;tail)&#xA;    ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It means that if the output buffer is full, the Serial.print will hang there eternally. However this doesn't happen. I guess somebody is consuming the data and to be more precise in ISR(USART_UDRE_vect). It seems as the only place where within interrupt _tx_buffer-&gt;tail can be changed. Otherwise the code would loop endlessly in HardwareSerial::write. This interrupt USART_UDRE_vect should be raised only when the Data Register is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is - who is consuming the sent data? Is that done by some USART_to_USB drivers? Or am I missing some part of the picture?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Boyan&lt;/p&gt;&#xA;" OwnerUserId="7425" LastActivityDate="2015-02-27T03:22:20.893" Title="Why is Serial.print working when nobody receives the data?" Tags="|arduino-uno|serial|usb|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8905" PostTypeId="2" ParentId="8904" CreationDate="2015-02-27T01:23:28.533" Score="2" Body="&lt;p&gt;The USB-UART bridge is, if it can. And if it can't, no one cares. A UART is &lt;em&gt;asynchronous&lt;/em&gt;, hence it doesn't care if anyone consumes it; as long as it has sent the data, that's all it cares about. There can be additional checks to see if the other side is able to &lt;em&gt;receive&lt;/em&gt; data, but that is not implemented on the Uno.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-27T01:23:28.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8906" PostTypeId="2" ParentId="8904" CreationDate="2015-02-27T02:25:17.917" Score="1" Body="&lt;p&gt;atmega 328p datasheet, section 20.6.3:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The Data Register Empty (UDREn) Flag indicates whether the transmit&#xA;buffer is ready to receive new data. This bit is set when the transmit&#xA;buffer is empty, and cleared when the transmit buffer contains data to&#xA;be transmitted that has not yet been moved into the Shift Register&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;When interrupt-driven data transmission is used, the Data Register&#xA;Empty interrupt routine must either write new data to UDRn in order to&#xA;clear UDREn or disable the Data Register Empty interrupt, otherwise a&#xA;new interrupt will occur once the interrupt routine terminates.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;the USART Data Register Empty vector is run when the hardware for USART serial has taken the byte in the register and sent it, not when a receiving device has polled and &amp;quot;taken&amp;quot; it. Once copied into the shift register and sent out of the chip nothing knows if there was another device to &amp;quot;hear&amp;quot; it or not. Some systems may have hardware flow control and wait for a CTS (clear to send) signal on a different wire, but the arduino does not.&lt;/p&gt;&#xA;&lt;p&gt;You may also notice that if interrupts are not currently enabled (preventing USART_UDRE_vect from ever occuring) the HardwareSerial::write routine will manually poll the correct condition and run the interrupt handler when appropriate to cycle data through and prevent a deadlock.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-02-27T03:22:20.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8907" PostTypeId="2" ParentId="8899" CreationDate="2015-02-27T03:05:28.473" Score="2" Body="&lt;p&gt;Please do not upvote this answer.&lt;br&gt;&#xA;This is an expansion of @Krol's answer. &#xA;Krol may incorporate this material in his answer if he wishes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The image below shows a typical relay module which is able to be driven by logic level / GPIO signals from typical microcontrollers.&lt;br&gt;&#xA;The relays have 5V coils and there are optocouplers and drive transistors between the input and the relay.&lt;br&gt;&#xA;Inputs are active LOW - ground to turn on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are available by mail from China for under $2/relay (under $1/relay if you buy 10 modules with several relays in). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are &lt;strong&gt;NOTIONALLY&lt;/strong&gt; opto-isolated as well as having relay isolation between input and contacts. &lt;strong&gt;BUT&lt;/strong&gt; the PCB layout and relay design is such that mains to input clearances are poor. They will &lt;strong&gt;PROBABLY NOT&lt;/strong&gt; kill you or your controller but they may - as is the case with much other items manufactured afar off at ludicrously low prices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found the seller/manufacturer whose logo appears on that photo to be a reliable supplier of well made products. (Being well made does not overcome &quot;dangerous design&quot; as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the above warning applies to most buffered relays you can buy on the hobbyist market and also top consumer products that have not been put through formal testing (UL etc). This relay board would fail UL testing - as would most others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HWO2D.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-27T03:05:28.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8908" PostTypeId="1" CreationDate="2015-02-27T03:44:54.800" Score="2" ViewCount="328" Body="&lt;p&gt;I'm building an audio circuit that will play &lt;code&gt;VGM&lt;/code&gt; files (Video Game Music).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it working with two different &quot;vintage&quot; IC's such as the &lt;code&gt;SN76489&lt;/code&gt; and the &lt;code&gt;AY-3-8912&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, my design is using an &lt;code&gt;Arduino Micro&lt;/code&gt; and two shift registers for the data buses and direct pins for the control pins on the audio IC's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On average, an audio IC has &lt;code&gt;8 pins&lt;/code&gt; for the data bus and &lt;code&gt;4 pins&lt;/code&gt; for the control or address bus.  This varies per IC.  Some might be 3, some 4, some 6, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line, even with the 20 IO pins on the Arduino, I will quickly run out of pins.  I thought about serializing many shift registers and basically pass 64 or 128 bit numbers to spread out to the multiple IC's but this sounds ugly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to support maybe 6 IC's which could be 60-80 pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have an &lt;code&gt;Arduino DUE&lt;/code&gt; which has many more IO pins.  But then I have to deal with the 3.3v limit and I only have 4 level shifters (16 pins).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on how to handle this?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2015-02-27T23:29:31.637" Title="How can I send data to many IC's without using tons of shift registers?" Tags="|pins|audio|arduino-micro|shift-register|atmega32u4|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8909" PostTypeId="1" AcceptedAnswerId="8915" CreationDate="2015-02-27T04:53:23.397" Score="0" ViewCount="170" Body="&lt;p&gt;I want to install several Arduino controlled relays which are use to turn on/off some lights, a fog machine and some door locks in a building.  What do I need to do to insure that the power relays don't violate building code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do components need to be put in a box or can they be mounted to a 2x4?&#xA;Are there requirements regarding the points were the bear wire is screwed into the relay?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming that if anyone as ever wired an Arduino into a garage door opener, these questions may have come up.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-03-07T15:46:10.210" LastActivityDate="2015-03-07T15:46:10.210" Title="Arduino, relays and building code" Tags="|relay|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8910" PostTypeId="2" ParentId="8908" CreationDate="2015-02-27T06:14:57.037" Score="1" Body="&lt;p&gt;There are other ways,but for a brute force many pin driver solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back at the beginning of time when steam driven IC's were all the vogue there was the awesome &lt;strong&gt;MM5450.&lt;/strong&gt;  40 pin DIP. 34 on/off outputs. 3 pin control. Or the really keen could do it with 1` pin control and some basic RC timing. I was. I did.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its day has passed. but, fortunately. neither Micrel or Digikey know this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.micrel.com/_PDF/mm5450.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;MM5450 datasheet&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://www.digikey.com/product-detail/en/MM5450YN/576-1341-ND/771810&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;In stock Digikey $5.46/1&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a very benign beat to drive once you get to know it. There is no reset (inless you buy bare dies) so you have to start off getting it synchronised  - it's not hard, just not quite usual. Works well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For single GPIO pin control the pin acts as data out and clock with some RC timing.&lt;br&gt;&#xA;Fot ICs with clock/data/load you can do all 3 with RC timing on one pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And there is a &lt;a href=&quot;http://www.digikey.com/product-detail/en/MM5450YV%20TR/576-1342-1-ND/771935&quot; rel=&quot;nofollow&quot;&gt;44 pin PLCC pkg version&lt;/a&gt; available.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;AND!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SN74LS673 16 bit SR, 24 pins&#xA;&lt;a href=&quot;http://www.ti.com/product/sn74ls673&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/product/sn74ls673&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ICM7243&#xA;&lt;a href=&quot;http://www.ebay.com/itm/ICM7243BIPL-HARRIS-40-Pin-DIP-LED-DISPLAY-DRIVER-ICM7243-7243A-/390402848376&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/ICM7243BIPL-HARRIS-40-Pin-DIP-LED-DISPLAY-DRIVER-ICM7243-7243A-/390402848376&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And others&#xA;&lt;a href=&quot;http://www.ebay.tv/sch/i.html?_sop=7&amp;amp;_nkw=led+driver+ic&amp;amp;_frs=1&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.tv/sch/i.html?_sop=7&amp;amp;_nkw=led+driver+ic&amp;amp;_frs=1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-02-27T23:29:31.637" LastActivityDate="2015-02-27T23:29:31.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8911" PostTypeId="1" CreationDate="2015-02-27T04:29:57.330" Score="0" ViewCount="4370" Body="&lt;p&gt;I am trying to add an on and off power switch to my arduino project.  My project is running off a 9v battery and I would like to save as much power as I can.  There might be a better why that I don’t know.  I added SLEEP_MODE_PWR_DOWN to my project and from what I can tell, the arduino enters sleep mode.  I am having a hard time getting the arduino to wake from sleep mode.  Am I able to do this from a full power down?  I have been reading this link. &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11497&lt;/a&gt;  and others. &lt;/p&gt;&#xA;" OwnerUserId="7593" OwnerDisplayName="user1277281" LastActivityDate="2015-06-19T03:43:14.817" Title="Need help with on off switch to power arduino." Tags="|power|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8912" PostTypeId="2" ParentId="8911" CreationDate="2015-02-27T05:10:23.373" Score="4" Body="&lt;p&gt;Since you are using an Arduino Uno board, putting the MCU (the ATmega328P-PU) to sleep won't save you much battery juice. Putting the MCU to sleep won't make a difference because the voltage regulator on the Uno will waste a lot more power than anything else on the board. The ON LED will also draw significant amount of current on that board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To really save power you should look into getting an Arduino board that has a more efficient voltage regulator, or use no regulator at all by changing your 9V battery by, say, 4 NiMH AA cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some more information about the issue for you to look at: &lt;a href=&quot;https://arduino.stackexchange.com/q/6/46&quot;&gt;What are (or how do I use) the power saving options of the Arduino to extend battery life?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" OwnerDisplayName="Ricardo" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-02-27T05:10:23.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8913" PostTypeId="1" AcceptedAnswerId="8914" CreationDate="2015-02-27T08:14:47.200" Score="0" ViewCount="1715" Body="&lt;p&gt;I am looking for a thermal sensor with a distance of 10 meters . In my plan , I would like to recognize objects based on the heat. for example car.&lt;/p&gt;&#xA;" OwnerUserId="7586" LastEditorUserId="7586" LastEditDate="2015-02-27T08:19:59.957" LastActivityDate="2019-08-21T20:37:23.490" Title="Is there a thermal sensor with a distance of 10 meters for Arduino" Tags="|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8914" PostTypeId="2" ParentId="8913" CreationDate="2015-02-27T08:36:53.230" Score="3" Body="&lt;p&gt;How about &lt;a href=&quot;https://www.sparkfun.com/products/9570&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; at £20?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range depends on what lens you put in front of it - this has to be plastic as IR doesn't penetrate glass, but you can set your own range, like a focus adjustment. Commercial IR remote thermometers generally have aiming dots (laser) so you can see the optimum range - there's a fixed lens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual sensor won't have a defined range, because of this.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-02-27T08:36:53.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8915" PostTypeId="2" ParentId="8909" CreationDate="2015-02-27T10:24:09.803" Score="1" Body="&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt;   IANAL nor US regulations expert.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few standard certifications that will essentially guarantee that a part will meet US regulatory requirements. Usually more of the form &quot;your building burned down and you have no insurance because ...&quot; rather than prosecuting you for non compliance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relays with UL rating bought via a reputable US supplier will usually quality.&lt;br&gt;&#xA;eg if Digikey sell it it is PROBABLY Kosher.&lt;br&gt;&#xA;Also if made by reputable manufacturers the same applies, as long as its genuine. eg (1 of many) Omron - they don't make no junk largely and even their junk is certified :-). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HOWEVER&lt;/strong&gt; if you are building something using such parts the whole unit will need to be certified. For small volume applications it may be easier and cheaper to buy comething COTS (commercial off the shelf) which has the relevant certifications. That said,be sure these are legitimate. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;As a guide:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.sensorcentral.com/worldsupport/standards03.php&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;US standards&lt;/strong&gt;&lt;/a&gt; a useful introduction&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.technick.net/public/code/cp_dpage.php?aiocp_dp=guide_safetymarks&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Extensive international standards summary&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/UL_(safety_organization)&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Wikipedia on UL&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.metlabs.com/Services/Product-Safety-Testing.aspx&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;MET Labs strut their stuff&lt;/strong&gt;&lt;/a&gt; comparison with UL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.intertek.com/marks/etl/&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Intertek test labs bow in&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.watertechonline.com/articles/understanding-electrical-certification&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Useful - Understanding electrical certification&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.med.govt.nz/energysafety/forms/certification/electrical-certification-templates&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Possibly useful templates&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-02-27T10:24:09.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8916" PostTypeId="1" AcceptedAnswerId="9061" CreationDate="2015-02-27T10:31:39.400" Score="5" ViewCount="831" Body="&lt;p&gt;So, I have a 5V Arduino Pro Mini, which is running the logic behind a multi-DHT22 sensor array, and using that input to control a 12v 24mm fan (12v, 0.16 A).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is currently a working board on an Arduino Nano with two separate power supplies (1 to USB, 1 to fan). I want to simplify it and make a more permanent installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm keen to do is something like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wall Wart (12v, 500mA) ------------------------&amp;gt; Relay -&amp;gt; Fan&#xA;                \ (1) -&amp;gt; Arduino Pro Mini @5V -&amp;gt; /&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to power the Arduino efficiently at 5V, and avoid drawing power all the time (i.e. when the Arduino is asleep), is the best way to apply a Linear (or Switching) Regulator with minimal burn when idle at &lt;code&gt;(1)&lt;/code&gt; in the diagram, and power the Pro via its VCC line, or is it better to just run via the internal regulators and RAW?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this actually just generate a high burn whenever the arduino is on to convert the 12v-5v? What is the most power efficient approach here?&lt;/p&gt;&#xA;" OwnerUserId="6337" LastEditorUserId="6337" LastEditDate="2015-02-27T10:54:08.960" LastActivityDate="2015-03-06T01:20:49.240" Title="Powering fans and arduino pro mini from single 12v supply" Tags="|power|arduino-pro-mini|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8917" PostTypeId="1" CreationDate="2015-02-27T12:07:30.153" Score="2" ViewCount="1157" Body="&lt;p&gt;I purchased this CO2 sensor a while back: &lt;a href=&quot;http://www.sainsmart.com/sensors/eco/sainsmart-mg811-gas-co2-carbon-dioxide-sensor-module-sensor-module.html&quot; rel=&quot;nofollow&quot;&gt;SainSmart MG811 Gas CO2 Carbon Dioxide Sensor Module Sensor Module for Arduino UNO R3 Raspberry Pi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The module has four pins, Vin, GND, Dout and Aout. I assume Dout and Aout are digital output and analog output, respectively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, the sensor came with no datasheet, instructions, or tutorial. I also searched online but fail to find anything useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going simple for now, just hooking up the sensor module to Arduino board. I know I can probably connect the output pins to the analog pins, and analogRead them, but what I am looking for is how to convert the raw data readings into CO2 levels in PPM. Like a formula.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm curious as to how the digital output works...&lt;/p&gt;&#xA;" OwnerUserId="6324" LastEditorUserId="6936" LastEditDate="2016-02-02T06:38:20.920" LastActivityDate="2016-02-02T11:01:00.213" Title="SainSmart CO2 sensor module use?" Tags="|sensors|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8918" PostTypeId="2" ParentId="4433" CreationDate="2015-02-27T12:16:51.257" Score="1" Body="&lt;p&gt;Try to play with this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int forwardSpeed = constrain(400 - (size/256), -100, 400);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By changing the value of 256 and 400, not at the same time though, you better use 2 potentiometer to change those values. That's a trial and error though, I hope this will give you an idea.&lt;/p&gt;&#xA;" OwnerUserId="7588" LastEditorUserId="6452" LastEditDate="2015-02-27T16:58:45.713" LastActivityDate="2015-02-27T16:58:45.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8920" PostTypeId="1" AcceptedAnswerId="8990" CreationDate="2015-02-27T12:49:22.910" Score="2" ViewCount="126" Body="&lt;p&gt;I'm currently trying to make 3 arduinos talking to each other with ZigBee, and it's kinda working.&#xA;But I currently use AT mode on the Bees and it's a little bit harsh when I have to switch the destination address in the Coordinator of the network (1 Coordinator and 2 Routers)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I put the Coordinator in API mode (to make it easier to switch addresses with xbee-api for Arduino) but still be able to communicate with the AT routers and be able to send/receive data from them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your answer :)&lt;/p&gt;&#xA;" OwnerUserId="7589" LastActivityDate="2015-03-03T11:16:05.890" Title="Can ZigBee API and ZigBee AT work together in the same network?" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8921" PostTypeId="1" AcceptedAnswerId="8923" CreationDate="2015-02-27T14:21:13.893" Score="4" ViewCount="2678" Body="&lt;p&gt;I have an Uno, and I can play all I want with it, just using a USB cable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I got two Nano clones, and they both show the same behavior:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connect it to the USB cable (which leads to my PC) it blinks a few times, then seemingly does nothing. I am also not able to connect to it via the Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I then connect an external power source to Vin and Gnd, it wakes up and blinks forever, and I am able to connect to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this just because I got a cheap clone? Or is this really the accepted / expected behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7UBfE.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2017-05-29T03:17:22.697" Title="Does Nano not get sufficient power via USB?" Tags="|power|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8922" PostTypeId="2" ParentId="8898" CreationDate="2015-02-27T15:12:14.970" Score="1" Body="&lt;p&gt;I'm assuming you do not have a potentiometer hanging out of the servo motor its self.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 things i could see here, without seeing the actual circuit itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- The inputs are left floating therefore the input is thinking it sees a high state when you never push the button due to electrical noise. To fix this add a 10k Resister to ground on pin 4 while the switch is wired to 5v/3.3v on one side and the other side going into pin 4. This will fix noise going into pin 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- Power supply on board is overheating or lack of power since computer usb port has a max power of 500mA. Use an external power supply to the servo and connect power supply ground to the board's ground to have a common ground.&lt;/p&gt;&#xA;" OwnerUserId="5116" LastActivityDate="2015-02-27T15:12:14.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8923" PostTypeId="2" ParentId="8921" CreationDate="2015-02-27T15:20:21.767" Score="6" Body="&lt;p&gt;I have a few clones but have not seen this behaviour so I guess it could be one of three things (in order of most likely to least):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;They have a fault related to taking power from the USB connector.&lt;/li&gt;&#xA;&lt;li&gt;The USB lead is not able to supply enough power ie. it is cheap and extremely thin and cannot carry much current. Have you already tried other cables?&lt;/li&gt;&#xA;&lt;li&gt;Your USB port cannot supply enough power. Given that the spec says 500mA from a USB 2 port, this seems unlikely unless the port is faulty. Have you tried other ports / another PC?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3107" LastActivityDate="2015-02-27T15:20:21.767" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8924" PostTypeId="2" ParentId="8900" CreationDate="2015-02-27T18:54:52.953" Score="3" Body="&lt;p&gt;Using an IR library as mentioned in a previous answer is likely to be about the best approach.  However, if you decide to use electronic switches to jumper across the remote's switch contacts, consider using CMOS analog switch chips for the purpose.  If each button on the remote connects one contact to a common net, inexpensive chips like 74HC4051 and CD74HCT4067 would serve for 8 or 16 buttons each, respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a reference for an affordable many-SPST-contacts CMOS switch.  Inexpensive chips with a few such contacts are available.  The 74HC4053, for example, contains three SPDT CMOS switches.  Handling a dozen buttons would use four 4053 chips.  A CD4007 probably could provide three SPST switches also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hyBNX.jpg&quot; alt=&quot;PS4051/52/53 pinouts&quot;&gt;&#xA;&lt;em&gt;Edit:&lt;/em&gt; The figure above shows pinouts of CD4051/52/53 devices.  To use a CD4053 as three separate switches, connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and each of COMA,B,C to one circuit contact to be switched.  With NCA, NCB, NCC connected to the other contacts of circuits A, B, C, raise ADDA, B, or C and drop INH to close circuit A, B, or C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your remote has dozens of buttons, it's likely that they are arranged in rows and columns for multiplexed scanning.  In this case, follow the printed circuit tracks to identify which buttons attach to which rows and which columns.  Suppose there are eight or fewer of one or the other; eg, suppose there are 5 columns and 8 rows.  In this case, you would hook up 5 CD4051 chips: connect V- and GND to Arduino ground, V+ to +5V or +3.3V, and the COM of each 4051 to a different column line.  Connect NO0–7 to row lines 0 to 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To close circuit &lt;em&gt;j&lt;/em&gt; in column &lt;em&gt;k&lt;/em&gt;, put &lt;em&gt;j&lt;/em&gt; in binary on ADDA,B,C of all 4051s and drop INH on 4051 #&lt;em&gt;k&lt;/em&gt;.  (Either use one DIO line per INH, or use a DM74LS138 or MM74HC138 (etc.) and put &lt;em&gt;k&lt;/em&gt; in binary on the A,B,C select lines of the '138.)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-02-28T18:11:02.260" LastActivityDate="2015-02-28T18:11:02.260" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8925" PostTypeId="1" CreationDate="2015-02-27T20:31:12.453" Score="2" ViewCount="364" Body="&lt;p&gt;I'm new to electronics and unsure whether my design below will work as intended. XBee Series 2 and Arduino Pro Mini 5V are used. There are 4 LEDs, each with the following roles:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;LED1&lt;/code&gt;: Flicker when transferring data to XBee&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LED2&lt;/code&gt;: Flicker when transferring data to Arduino&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LED3&lt;/code&gt;: Turns on when XBee is powered on&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LED4&lt;/code&gt;: Turns on when Arduino is powered on&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/THiAi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, will it suffice to use 3.3V LEDs for &lt;code&gt;LED1&lt;/code&gt;, &lt;code&gt;LED2&lt;/code&gt;, &lt;code&gt;LED3&lt;/code&gt; and 5V LEDs for &lt;code&gt;LED4&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="639" LastEditorUserId="639" LastEditDate="2015-02-27T20:41:11.140" LastActivityDate="2015-02-27T20:41:11.140" Title="Connecting Indicator LEDs to Arduino Pro Mini" Tags="|led|xbee|arduino-pro-mini|voltage-level|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8926" PostTypeId="2" ParentId="8758" CreationDate="2015-02-27T20:59:05.313" Score="29" Body="&#xA;&lt;p&gt;&lt;strong&gt;As a sort of prologue&lt;/strong&gt; to this overly long answer...&lt;/p&gt;&#xA;&lt;p&gt;This question got me deeply captivated with the problem of interrupt&#xA;latency, to the point of losing sleep in counting cycles instead of&#xA;sheep. I am writing this response more for sharing my findings&#xA;than for just answering the question: most of this material may actually&#xA;not be at a level suitable for a proper answer. I hope it will be&#xA;useful, however, for readers that land here in search of solutions for&#xA;latency problems. The first few sections are expected to be useful to a&#xA;wide audience, including the original poster. Then, it gets hairy along&#xA;the way.&lt;/p&gt;&#xA;&lt;p&gt;Clayton Mills already explained in his answer that there is some latency&#xA;in responding to interrupts. Here I will focus on quantifying the&#xA;latency (which is &lt;em&gt;huge&lt;/em&gt; when using the Arduino libraries), and on the&#xA;means to minimize it. Most of what follows is specific to the hardware&#xA;of the Arduino Uno and similar boards.&lt;/p&gt;&#xA;&lt;h1&gt;Minimizing the interrupt latency on the Arduino&lt;/h1&gt;&#xA;&lt;p&gt;(or how to get from 99 down to 5 cycles)&lt;/p&gt;&#xA;&lt;p&gt;I will use the original question as a working example, and restate the&#xA;problem in terms of interrupt latency. We have some external event that&#xA;triggers an interrupt (here: INT0 on pin change). We need to take some&#xA;action when the interrupt is triggered (here: read a digital input). The&#xA;problem is: there is some delay between the interrupt being triggered&#xA;and our taking the appropriate action. We call this delay &amp;quot;&lt;em&gt;interrupt&#xA;latency&lt;/em&gt;&amp;quot;. A long latency is detrimental in many situations. In this&#xA;particular example, the input signal may change during the delay, in&#xA;which case we get a faulty reading. There is nothing we can do to avoid&#xA;the delay: it is intrinsic to the way interrupts work. We can, however,&#xA;try to make it as short as possible, which should hopefully minimize the&#xA;bad consequences.&lt;/p&gt;&#xA;&lt;p&gt;The first obvious thing we can do is take the time-critical action,&#xA;inside the interrupt handler, as soon as possible. This means calling&#xA;&lt;code&gt;digitalRead()&lt;/code&gt; once (and only once) at the very beginning of the&#xA;handler. Here is the zeroth version of the program upon which we will&#xA;build:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define INT_NUMBER 0&#xA;#define PIN_NUMBER 2    // interrupt 0 is on pin 2&#xA;#define MAX_COUNT  200&#xA;&#xA;volatile uint8_t count_edges;  // count of signal edges&#xA;volatile uint8_t count_high;   // count of high levels&#xA;&#xA;/* Interrupt handler. */&#xA;void read_pin()&#xA;{&#xA;    int pin_state = digitalRead(PIN_NUMBER);  // do this first!&#xA;    if (count_edges &amp;gt;= MAX_COUNT) return;     // we are done&#xA;    count_edges++;&#xA;    if (pin_state == HIGH) count_high++;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    attachInterrupt(INT_NUMBER, read_pin, CHANGE);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    /* Wait for the interrupt handler to count MAX_COUNT edges. */&#xA;    while (count_edges &amp;lt; MAX_COUNT) { /* wait */ }&#xA;&#xA;    /* Report result. */&#xA;    Serial.print(&amp;quot;Counted &amp;quot;);&#xA;    Serial.print(count_high);&#xA;    Serial.print(&amp;quot; HIGH levels for &amp;quot;);&#xA;    Serial.print(count_edges);&#xA;    Serial.println(&amp;quot; edges&amp;quot;);&#xA;&#xA;    /* Count again. */&#xA;    count_high = 0;&#xA;    count_edges = 0;  // do this last to avoid race condition&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tested this program, and the subsequent versions, by sending it trains&#xA;of pulses of varying widths. There is enough spacing between the pulses&#xA;to ensure that no edge is missed: even if the falling edge is received&#xA;before the previous interrupt is done, the second interrupt request will&#xA;be put on hold and eventually serviced. If a pulse is shorter than the&#xA;interrupt latency, the program reads 0 on both edges. The reported&#xA;number of HIGH levels is then the percentage of correctly read pulses.&lt;/p&gt;&#xA;&lt;h2&gt;What happens when the interrupt is triggered?&lt;/h2&gt;&#xA;&lt;p&gt;Before trying to improve the code above, we will take a look at the&#xA;events that unfold right after the interrupt is triggered. The hardware&#xA;part of the story is told by the Atmel documentation. The software part,&#xA;by disassembling the binary.&lt;/p&gt;&#xA;&lt;p&gt;Most of the time, the incoming interrupt is serviced right away. It may&#xA;happen, however, that the MCU (meaning &amp;quot;microcontroller&amp;quot;) is in the&#xA;middle of some time-critical task, where interrupt servicing is&#xA;disabled. This is typically the case when it is already servicing&#xA;another interrupt. When this happens, the incoming interrupt request is&#xA;put on hold and serviced only when that time-critical section is done.&#xA;This situation is hard to avoid completely, because there are quite a&#xA;few of those critical sections in the Arduino core library (which I will&#xA;call &amp;quot;&lt;em&gt;libcore&lt;/em&gt;&amp;quot; in the following). Fortunately, these sections are&#xA;short and run only every so often. Thus, most of the time, our interrupt&#xA;request will be serviced right away. In the following, I will assume&#xA;that we do not care about those few instances when this is not the case.&lt;/p&gt;&#xA;&lt;p&gt;Then, our request is serviced immediately. This still involves a lot of&#xA;stuff that can take quite a while. First, there is a hardwired sequence.&#xA;The MCU will finish executing the current instruction. Fortunately, most&#xA;instructions are single-cycle, but some can take up to four cycles.&#xA;Then, the MCU clears an internal flag that disables further servicing of&#xA;interrupts. This is intended to prevent nested interrupts. Then, the PC&#xA;is saved into the stack. The stack is an area of RAM reserved for this&#xA;kind of temporary storage. The PC (meaning &amp;quot;&lt;em&gt;Program Counter&lt;/em&gt;&amp;quot;) is an&#xA;internal register holding the address of the next instruction the MCU is&#xA;about to execute. This is what allows the MCU to know what to do next,&#xA;and saving it is essential because it will have to be restored in order&#xA;for the main program to resume from where it was interrupted. The PC is&#xA;then loaded with a hardwired address specific to the request received,&#xA;and this is the end of the hardwired sequence, the rest being&#xA;software-controlled.&lt;/p&gt;&#xA;&lt;p&gt;The MCU now executes the instruction from that hardwired address. This&#xA;instruction is called an &amp;quot;&lt;em&gt;interrupt vector&lt;/em&gt;&amp;quot;, and is generally a &amp;quot;jump&amp;quot;&#xA;instruction that will bring us to a special routine called an ISR&#xA;(&amp;quot;&lt;em&gt;Interrupt Service Routine&lt;/em&gt;&amp;quot;). In this case, the ISR is called&#xA;&amp;quot;__vector_1&amp;quot;, a.k.a. &amp;quot;INT0_vect&amp;quot;, which is a misnomer because it is&#xA;an ISR, not a vector. This particular ISR comes from libcore. Like any&#xA;ISR, it starts with a &lt;em&gt;prologue&lt;/em&gt; that saves a bunch of internal CPU&#xA;registers on the stack. This will allow it to use those registers and,&#xA;when it is done, restore them to their previous values in order not to&#xA;disturb the main program. Then, it will look for the interrupt handler&#xA;that was registered with &lt;code&gt;attachInterrupt()&lt;/code&gt;, and it will call that&#xA;handler, which is our &lt;code&gt;read_pin()&lt;/code&gt; function above. Our function will&#xA;then call &lt;code&gt;digitalRead()&lt;/code&gt; from libcore. &lt;code&gt;digitalRead()&lt;/code&gt; will look into&#xA;some tables in order to map the Arduino port number to the hardware I/O&#xA;port it has to read and the associated bit number to test. It will also&#xA;check whether there is a PWM channel on that pin that would need to be&#xA;disabled. It will then read the I/O port... and we are done. Well, we&#xA;are not really done servicing the interrupt, but the time-critical task&#xA;(reading the I/O port) is done, and it is all that matters when we are&#xA;looking at latency.&lt;/p&gt;&#xA;&lt;p&gt;Here is a short summary of all the above, together with the associated&#xA;delays in CPU cycles:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;hardwired sequence: finish current instruction, prevent nested&#xA;interrupts, save PC, load address of vector (≥ 4 cycles)&lt;/li&gt;&#xA;&lt;li&gt;execute interrupt vector: jump to ISR (3 cycles)&lt;/li&gt;&#xA;&lt;li&gt;ISR prologue: save registers (32 cycles)&lt;/li&gt;&#xA;&lt;li&gt;ISR main body: locate and call user-registered function (13 cycles)&lt;/li&gt;&#xA;&lt;li&gt;read_pin: call digitalRead (5 cycles)&lt;/li&gt;&#xA;&lt;li&gt;digitalRead: find the relevant port and bit to test (41 cycles)&lt;/li&gt;&#xA;&lt;li&gt;digitalRead: read the I/O port (1 cycle)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;We will assume the best case scenario, with 4 cycles for the&#xA;hardwired sequence. This gives us a total latency of 99 cycles, or&#xA;about 6.2 µs with a 16 MHz clock. In the following, I will&#xA;explore some tricks that can be used to lower this latency. They come&#xA;roughly in increasing order of complexity, but they all need us to&#xA;somehow dig into the internals of the MCU.&lt;/p&gt;&#xA;&lt;h2&gt;Use direct port access&lt;/h2&gt;&#xA;&lt;p&gt;The obvious first target for shortening the latency is &lt;code&gt;digitalRead()&lt;/code&gt;.&#xA;This function provides a nice abstraction to the MCU hardware, but it is&#xA;too inefficient for time-critical work. Getting rid of this one is&#xA;actually trivial: we just have to replace it with &lt;code&gt;digitalReadFast()&lt;/code&gt;,&#xA;from the &lt;a href=&quot;https://code.google.com/p/digitalwritefast/&quot; rel=&quot;noreferrer&quot;&gt;digitalwritefast&lt;/a&gt;&#xA;library. This cuts the latency almost by half at the cost of a small&#xA;download!&lt;/p&gt;&#xA;&lt;p&gt;Well, that was too easy to be any fun, I will rather show you how to do&#xA;it the hard way. The purpose is to get us started into low-level stuff.&#xA;The method is called &amp;quot;&lt;em&gt;direct port access&lt;/em&gt;&amp;quot; and is nicely documented on&#xA;the Arduino reference at the page on &lt;a href=&quot;http://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;noreferrer&quot;&gt;Port&#xA;Registers&lt;/a&gt;. At this&#xA;point, it is a good idea to download and take a look at the &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega328P&#xA;datasheet&lt;/a&gt;.&#xA;This 650-page document may seem somewhat daunting at first look. It is,&#xA;however, well organised into sections specific to each of the MCU&#xA;peripherals and features. And we only need to check the sections&#xA;relevant to what we are doing. In this case, it is the section named&#xA;&lt;em&gt;I/O ports&lt;/em&gt;. Here is a summary of what we learn from those readings:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino pin 2 is actually called PD2 (i.e. port D, bit 2) on the&#xA;AVR chip.&lt;/li&gt;&#xA;&lt;li&gt;We get the whole port D at once by reading a special MCU register called&#xA;&amp;quot;PIND&amp;quot;.&lt;/li&gt;&#xA;&lt;li&gt;We then check bit number 2 by doing a &lt;em&gt;bitwise logical and&lt;/em&gt; (the C ‘&amp;amp;’&#xA;operator) with &lt;code&gt;1 &amp;lt;&amp;lt; 2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So, here is our modified interrupt handler:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define PIN_REG    PIND  // interrupt 0 is on AVR pin PD2&#xA;#define PIN_BIT    2&#xA;&#xA;/* Interrupt handler. */&#xA;void read_pin()&#xA;{&#xA;    uint8_t sampled_pin = PIN_REG;            // do this first!&#xA;    if (count_edges &amp;gt;= MAX_COUNT) return;     // we are done&#xA;    count_edges++;&#xA;    if (sampled_pin &amp;amp; (1 &amp;lt;&amp;lt; PIN_BIT)) count_high++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, our handler will read the I/O register as soon as it is called. The&#xA;latency is 53 CPU cycles. This simple trick saved us 46 cycles!&lt;/p&gt;&#xA;&lt;h2&gt;Write your own ISR&lt;/h2&gt;&#xA;&lt;p&gt;The next target for cycle-trimming is the INT0_vect ISR. This ISR is&#xA;needed for providing the functionality of &lt;code&gt;attachInterrupt()&lt;/code&gt;: we can&#xA;change interrupt handlers at any time during program execution. However,&#xA;although nice to have, this is not really useful for our purpose. Thus,&#xA;instead of having the libcore's ISR locate and call our interrupt&#xA;handler, we will save a few cycles by &lt;em&gt;replacing&lt;/em&gt; the ISR by our&#xA;handler.&lt;/p&gt;&#xA;&lt;p&gt;This is not as hard as it sounds. ISRs can be written like normal&#xA;functions, we just have to be aware of their specific names, and define&#xA;them using a special &lt;code&gt;ISR()&lt;/code&gt; macro from avr-libc. At this point it would&#xA;be good to have a look at the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&quot; rel=&quot;noreferrer&quot;&gt;avr-libc's documentation on&#xA;interrupts&lt;/a&gt;,&#xA;and at the datasheet section named &lt;em&gt;External Interrupts&lt;/em&gt;. Here is the&#xA;short summary:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We have to write a bit in a special hardware register called EICRA&#xA;(&lt;em&gt;External Interrupt Control Register A&lt;/em&gt;) in order to configure the&#xA;interrupt to be triggered on any change of the pin value. This will be&#xA;done in &lt;code&gt;setup()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We have to write a bit in another hardware register called EIMSK&#xA;(&lt;em&gt;External Interrupt MaSK register&lt;/em&gt;) in order to enable the INT0&#xA;interrupt. This will also be done in &lt;code&gt;setup()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;We have to define the ISR with the syntax &lt;code&gt;ISR(INT0_vect) { ... }&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here is the code for the ISR and &lt;code&gt;setup()&lt;/code&gt;, everything else is&#xA;unchanged:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/* Interrupt service routine for INT0. */&#xA;ISR(INT0_vect)&#xA;{&#xA;    uint8_t sampled_pin = PIN_REG;            // do this first!&#xA;    if (count_edges &amp;gt;= MAX_COUNT) return;     // we are done&#xA;    count_edges++;&#xA;    if (sampled_pin &amp;amp; (1 &amp;lt;&amp;lt; PIN_BIT)) count_high++;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    EICRA = 1 &amp;lt;&amp;lt; ISC00;  // sense any change on the INT0 pin&#xA;    EIMSK = 1 &amp;lt;&amp;lt; INT0;   // enable INT0 interrupt&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This comes with a free bonus: since this ISR is simpler than the one it&#xA;replaces, it needs less registers to do its job, then the&#xA;register-saving prologue is shorter. Now we are down to a latency of 20&#xA;cycles. Not bad considering that we started close to 100!&lt;/p&gt;&#xA;&lt;p&gt;At this point I would say we are done. Mission accomplished. What&#xA;follows is only for those who are not afraid of getting their hands&#xA;dirty with some AVR assembly. Otherwise you can stop reading here, and&#xA;thank-you for getting so far.&lt;/p&gt;&#xA;&lt;h2&gt;Write a naked ISR&lt;/h2&gt;&#xA;&lt;p&gt;Still here? Good! For proceeding further, it would be helpful to have at&#xA;least some very basic idea of how assembly works, and to take a look at&#xA;the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/inline_asm.html&quot; rel=&quot;noreferrer&quot;&gt;Inline Assembler&#xA;Cookbook&lt;/a&gt;&#xA;from the avr-libc documentation. At this point, our interrupt entry&#xA;sequence looks like this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;hardwired sequence (4 cycles)&lt;/li&gt;&#xA;&lt;li&gt;interrupt vector: jump to ISR (3 cycles)&lt;/li&gt;&#xA;&lt;li&gt;ISR prologue: save regs (12 cycles)&lt;/li&gt;&#xA;&lt;li&gt;first thing in the ISR body: read the IO port (1 cycle)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;If we want to do better, we have to move the reading of the port into&#xA;the prologue. The idea is the following: reading the PIND register will&#xA;clobber one CPU register, thus we need to save at least one register&#xA;before doing that, but the other registers can wait. We then need to&#xA;write a custom prologue that reads the I/O port right after saving the&#xA;first register. You have already seen in the avr-libc interrupt&#xA;documentation (you have read it, right?) that an ISR can be made&#xA;&lt;em&gt;naked&lt;/em&gt;, in which case the compiler will emit no prologue or epilogue,&#xA;allowing us to write our own custom version.&lt;/p&gt;&#xA;&lt;p&gt;The problem with this approach is that we will probably end up writing&#xA;the whole ISR in assembly. Not a big deal, but I would rather have the&#xA;compiler write those boring prologues and epilogues for me. So, here is&#xA;the dirty trick: we will split the ISR in two parts:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the first part will be a short assembly fragment that will&#xA;&lt;ul&gt;&#xA;&lt;li&gt;save a single register to the stack&lt;/li&gt;&#xA;&lt;li&gt;read PIND into that register&lt;/li&gt;&#xA;&lt;li&gt;store that value into a global variable&lt;/li&gt;&#xA;&lt;li&gt;restore the register from the stack&lt;/li&gt;&#xA;&lt;li&gt;jump to the second part&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;the second part will be regular C code with compiler-generated&#xA;prologue and epilogue&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Our previous INT0 ISR is then replaced by this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;volatile uint8_t sampled_pin;    // this is now a global variable&#xA;&#xA;/* Interrupt service routine for INT0. */&#xA;ISR(INT0_vect, ISR_NAKED)&#xA;{&#xA;    asm volatile(&#xA;    &amp;quot;    push r0                \n&amp;quot;  // save register r0&#xA;    &amp;quot;    in r0, %[pin]          \n&amp;quot;  // read PIND into r0&#xA;    &amp;quot;    sts sampled_pin, r0    \n&amp;quot;  // store r0 in a global&#xA;    &amp;quot;    pop r0                 \n&amp;quot;  // restore previous r0&#xA;    &amp;quot;    rjmp INT0_vect_part_2  \n&amp;quot;  // go to part 2&#xA;    :: [pin] &amp;quot;I&amp;quot; (_SFR_IO_ADDR(PIND)));&#xA;}&#xA;&#xA;ISR(INT0_vect_part_2)&#xA;{&#xA;    if (count_edges &amp;gt;= MAX_COUNT) return;     // we are done&#xA;    count_edges++;&#xA;    if (sampled_pin &amp;amp; (1 &amp;lt;&amp;lt; PIN_BIT)) count_high++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here we are using the ISR() macro to have the compiler instrument&#xA;&lt;code&gt;INT0_vect_part_2&lt;/code&gt; with the required prologue and epilogue. The compiler&#xA;will complain that &amp;quot;‘INT0_vect_part_2’ appears to be a misspelled&#xA;signal handler&amp;quot;, but the warning can be safely ignored. Now the ISR has&#xA;a single 2-cycle instruction before the actual port read, and the total&#xA;latency is only 10 cycles.&lt;/p&gt;&#xA;&lt;h2&gt;Use the GPIOR0 register&lt;/h2&gt;&#xA;&lt;p&gt;What if we could have a register reserved for this specific job? Then,&#xA;we would not need save anything before reading the port. We can actually&#xA;ask the compiler to &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Global-Reg-Vars.html&quot; rel=&quot;noreferrer&quot;&gt;bind a global variable to a&#xA;register&lt;/a&gt;.&#xA;This, however, would require us to recompile the whole Arduino core and&#xA;libc in order to make sure the register is always reserved. Not really&#xA;convenient. On the other hand, the ATmega328P happens to have three&#xA;registers that are not used by the compiler nor any library, and are&#xA;available for storing whatever we want. They are called GPIOR0, GPIOR1&#xA;and GPIOR2 (&lt;em&gt;General Purpose I/O Registers&lt;/em&gt;). Although they are mapped&#xA;in the I/O address space of the MCU, these are actually &lt;em&gt;not&lt;/em&gt; I/O&#xA;registers: they are just plain memory, like three bytes of RAM that&#xA;somehow got lost in a bus and ended up in the wrong address space. These&#xA;are not as capable as the internal CPU registers, and we cannot copy&#xA;PIND into one of these with the &lt;code&gt;in&lt;/code&gt; instruction. GPIOR0 is interesting,&#xA;though, in that it is &lt;em&gt;bit-addressable&lt;/em&gt;, just like PIND. This will allow&#xA;us to transfer the information without clobbering any internal CPU&#xA;register.&lt;/p&gt;&#xA;&lt;p&gt;Here is the trick: we will make sure that GPIOR0 is initially zero (it&#xA;is actually cleared by hardware at boot time), then we will use the&#xA;&lt;code&gt;sbic&lt;/code&gt; (Skip next instruction if some Bit in some I/o register is Clear)&#xA;and the &lt;code&gt;sbi&lt;/code&gt; (Set to 1 some Bit in some I/o register) instructions as&#xA;follows:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;sbic PIND, 2   ; skip the following if bit 2 of PIND is clear&#xA;sbi GPIOR0, 0  ; set to 1 bit 0 of GPIOR0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This way, GPIOR0 will end up being 0 or 1 depending on the bit we wanted&#xA;to read from PIND. The sbic instruction takes 1 or 2 cycles to execute&#xA;depending on whether the condition is false or true. Obviously, the PIND&#xA;bit is accessed on the first cycle. In this new version of the code, the&#xA;global variable &lt;code&gt;sampled_pin&lt;/code&gt; is not useful anymore, since it is&#xA;basically replaced by GPIOR0:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/* Interrupt service routine for INT0. */&#xA;ISR(INT0_vect, ISR_NAKED)&#xA;{&#xA;    asm volatile(&#xA;    &amp;quot;    sbic %[pin], %[bit]    \n&amp;quot;&#xA;    &amp;quot;    sbi %[gpio], 0         \n&amp;quot;&#xA;    &amp;quot;    rjmp INT0_vect_part_2  \n&amp;quot;&#xA;    :: [pin]  &amp;quot;I&amp;quot; (_SFR_IO_ADDR(PIND)),&#xA;       [bit]  &amp;quot;I&amp;quot; (PIN_BIT),&#xA;       [gpio] &amp;quot;I&amp;quot; (_SFR_IO_ADDR(GPIOR0)));&#xA;}&#xA;&#xA;ISR(INT0_vect_part_2)&#xA;{&#xA;    if (count_edges &amp;lt; MAX_COUNT) {&#xA;        count_edges++;&#xA;        if (GPIOR0) count_high++;&#xA;    }&#xA;    GPIOR0 = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It should be noted that GPIOR0 has to always be reset in the ISR.&lt;/p&gt;&#xA;&lt;p&gt;Now, the sampling of the PIND I/O register is the very first thing done&#xA;inside the ISR. Total latency is 8 cycles. This is about the best we can&#xA;do before getting stained with terribly sinful kludges. This is again a&#xA;good opportunity to stop reading...&lt;/p&gt;&#xA;&lt;h2&gt;Put the time-critical code in the vector table&lt;/h2&gt;&#xA;&lt;p&gt;For those still here, here is our current situation:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;hardwired sequence (4 cycles)&lt;/li&gt;&#xA;&lt;li&gt;interrupt vector: jump to ISR (3 cycles)&lt;/li&gt;&#xA;&lt;li&gt;ISR body: read the IO port (on 1st cycle)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;There is obviously little room for improvement. The only way we could&#xA;shorten the latency at this point is by &lt;em&gt;replacing the interrupt vector&#xA;itself&lt;/em&gt; by our code. Be warned that this should be immensely distasteful&#xA;to anyone who values clean software design. But it is possible, and I&#xA;will show you how.&lt;/p&gt;&#xA;&lt;p&gt;The layout of the ATmega328P vector table can be found in the datasheet,&#xA;section &lt;em&gt;Interrupts&lt;/em&gt;, subsection &lt;em&gt;Interrupt Vectors in ATmega328 and&#xA;ATmega328P&lt;/em&gt;. Or by disassembling any program for this chip. Here is how&#xA;it looks like. I am using avr-gcc and avr-libc's conventions (__init&#xA;is vector 0, addresses are in bytes) which are different from Atmel's.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;address │ instruction     │ comment&#xA;────────┼─────────────────┼──────────────────────&#xA; 0x0000 │ jmp __init      │ reset vector &#xA; 0x0004 │ jmp __vector_1  │ a.k.a. INT0_vect&#xA; 0x0008 │ jmp __vector_2  │ a.k.a. INT1_vect&#xA; 0x000c │ jmp __vector_3  │ a.k.a. PCINT0_vect&#xA;  ...&#xA; 0x0064 │ jmp __vector_25 │ a.k.a. SPM_READY_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Each vector has a 4-byte slot, filled with a single &lt;code&gt;jmp&lt;/code&gt; instruction.&#xA;This is a 32-bit instruction, unlike most AVR instructions which are&#xA;16-bit. But a 32-bit slot is too small to hold the first part of our&#xA;ISR: we can fit the &lt;code&gt;sbic&lt;/code&gt; and &lt;code&gt;sbi&lt;/code&gt; instructions, but not the &lt;code&gt;rjmp&lt;/code&gt;.&#xA;If we do that, the vector table ends up looking like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;address │ instruction     │ comment&#xA;────────┼─────────────────┼──────────────────────&#xA; 0x0000 │ jmp __init      │ reset vector &#xA; 0x0004 │ sbic PIND, 2    │ the first part...&#xA; 0x0006 │ sbi GPIOR0, 0   │ ...of our ISR&#xA; 0x0008 │ jmp __vector_2  │ a.k.a. INT1_vect&#xA; 0x000c │ jmp __vector_3  │ a.k.a. PCINT0_vect&#xA;  ...&#xA; 0x0064 │ jmp __vector_25 │ a.k.a. SPM_READY_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When INT0 fires, PIND will be read, the relevant bit will be copied into&#xA;GPIOR0, and then the execution will fall through to the next vector.&#xA;Then, the ISR for INT1 will be called, instead of the ISR for INT0. This&#xA;is creepy, but since we are not using INT1 anyway, we will just &amp;quot;hijack&amp;quot;&#xA;its vector for servicing INT0.&lt;/p&gt;&#xA;&lt;p&gt;Now, we just have to write our own custom vector table to override the&#xA;default one. It turns out it is not so easy. The default vector table is&#xA;provided by the avr-libc distribution, in an object file called&#xA;crtm328p.o that is automatically linked with any program we build.&#xA;Unlike library code, object-file code is not meant to be overridden:&#xA;trying to do that will give a linker error about the table being defined&#xA;twice. This means we have to replace the whole crtm328p.o with our&#xA;custom version. One option is to &lt;a href=&quot;http://download.savannah.gnu.org/releases/avr-libc/&quot; rel=&quot;noreferrer&quot;&gt;download the full avr-libc source&#xA;code&lt;/a&gt;, do our&#xA;custom modifications in&#xA;&lt;a href=&quot;http://svn.savannah.nongnu.org/viewvc/*checkout*/trunk/avr-libc/crt1/gcrt1.S?root=avr-libc&quot; rel=&quot;noreferrer&quot;&gt;gcrt1.S&lt;/a&gt;,&#xA;then build this as a custom libc.&lt;/p&gt;&#xA;&lt;p&gt;Here I went for a lighter, alternative approach. I wrote a custom&#xA;crt.S, which is a simplified version of the original from avr-libc. It&#xA;lacks a few rarely used features, like the ability to define a &amp;quot;catch&#xA;all&amp;quot; ISR, or to be able to terminate the program (i.e. freeze the&#xA;Arduino) by calling &lt;code&gt;exit()&lt;/code&gt;. Here is the code. I trimmed the repetitive&#xA;part of the vector table in order to minimize scrolling:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;&#xA;.weak __heap_end&#xA;.set  __heap_end, 0&#xA;&#xA;.macro vector name&#xA;    .weak \name&#xA;    .set \name, __vectors&#xA;    jmp \name&#xA;.endm&#xA;&#xA;.section .vectors&#xA;__vectors:&#xA;    jmp __init&#xA;    sbic _SFR_IO_ADDR(PIND), 2   ; these 2 lines...&#xA;    sbi _SFR_IO_ADDR(GPIOR0), 0  ; ...replace vector_1&#xA;    vector __vector_2&#xA;    vector __vector_3&#xA;    [...and so forth until...]&#xA;    vector __vector_25&#xA;&#xA;.section .init2&#xA;__init:&#xA;    clr r1&#xA;    out _SFR_IO_ADDR(SREG), r1&#xA;    ldi r28, lo8(RAMEND)&#xA;    ldi r29, hi8(RAMEND)&#xA;    out _SFR_IO_ADDR(SPL), r28&#xA;    out _SFR_IO_ADDR(SPH), r29&#xA;&#xA;.section .init9&#xA;    jmp main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It can be compiled with the following command line:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;avr-gcc -c -mmcu=atmega328p silly-crt.S&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The sketch is identical to the previous one except that there is no&#xA;INT0_vect, and INT0_vect_part_2 is replaced by INT1_vect:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/* Interrupt service routine for INT1 hijacked to service INT0. */&#xA;ISR(INT1_vect)&#xA;{&#xA;    if (count_edges &amp;lt; MAX_COUNT) {&#xA;        count_edges++;&#xA;        if (GPIOR0) count_high++;&#xA;    }&#xA;    GPIOR0 = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To compile the sketch, we need a custom compile command. If you have&#xA;followed so far, you probably know how to compile from the command line.&#xA;You have to explicitly request silly-crt.o to be linked to your program,&#xA;and add the &lt;code&gt;-nostartfiles&lt;/code&gt; option to avoid linking in the original&#xA;crtm328p.o.&lt;/p&gt;&#xA;&lt;p&gt;Now, the reading of the I/O port is the very first instruction executed&#xA;after the interrupt triggers. I tested this version by sending it short&#xA;pulses from another Arduino, and it can catch (although not reliably)&#xA;the high level of pulses as short as 5 cycles. There is nothing more we&#xA;can do to shorten the interrupt latency on this hardware.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2022-08-22T20:30:55.007" LastActivityDate="2022-08-22T20:30:55.007" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8927" PostTypeId="2" ParentId="8898" CreationDate="2015-02-27T22:03:09.230" Score="1" Body="&lt;p&gt;I see two potential issues in your code.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no button debouncing in your code: this means everytime you push the button down or up, the &lt;code&gt;digitalRead()&lt;/code&gt; call will return &lt;code&gt;HIGH&lt;/code&gt; and &lt;code&gt;LOW&lt;/code&gt; several times until the signal is stabilized; that could make the servo twitch as you observed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For any call to &lt;code&gt;servo.write()&lt;/code&gt;, you need to give time to the servo to reach the desired position, typically a few dozen milliseconds.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For the first problem, google for arduino button debouncing and you'll find various solutions for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the second issue, you just need to add &lt;code&gt;delay()&lt;/code&gt; after every call to &lt;code&gt;servo.write()&lt;/code&gt;; note that in your code you added &lt;code&gt;delay(39);&lt;/code&gt; but only for one call to &lt;code&gt;servo.write()&lt;/code&gt; not for both calls.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-02-27T22:03:09.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8928" PostTypeId="1" AcceptedAnswerId="8929" CreationDate="2015-02-27T16:08:26.173" Score="2" ViewCount="4202" Body="&lt;p&gt;I've searched high and low for something to get me on the right track, it's making me think it might not be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to create a cheap SSD using Arduino (or another microcontroller if it is too weak). I know I would have to implement the SATA protocol on the device and an OS driver for the disk drive. Assuming I could jump those two hurdles, what else would bar me from implementing a rudimentary SSD? I'm not even talking about full production quality, just a SATA wire coming from a mother board plugged into a socket on a breadboard. Do I need flash storage or would I need another kind of chip to handle the data needs?&lt;/p&gt;&#xA;" OwnerUserId="7537" OwnerDisplayName="Mike Brown" LastEditorUserId="6452" LastEditDate="2015-04-14T22:37:52.503" LastActivityDate="2015-04-14T22:37:52.503" Title="Arduino Based Solid State Drive" Tags="|system-design|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="8929" PostTypeId="2" ParentId="8928" CreationDate="2015-02-27T16:58:44.370" Score="4" Body="&lt;p&gt;The good news is that SATA drivers are fairly generic so you don't have to write the OS side. The bad news is everything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;just a SATA wire coming from a mother board plugged into a socket on a breadboard&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me stop you there. The minimum data rate for SATA is sufficiently high that you need a PCB. If you try and do this with wires or breadboards it will simply not get through; it will be lost to parasitic capacitance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Many years ago as a student I tried to do something vaguely similar with a wire-wrap board. At just 20MHz you could see a clean signal go in one side and a noisy unreadable mess come out the other side. Actually seeing it on a scope drove home the importance of shielding.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Do I need flash storage or would I need another kind of chip to handle the data needs&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where would you put the data otherwise? It might be an entertaining first step to create a read-only drive with constant contents, but it's not very useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a chip with a SATA interface. This will almost certainly be an ARM and almost certainly &lt;em&gt;not&lt;/em&gt; in DIP. I can't remember at the moment whether SATA master and slave &quot;PHY&quot; interfaces are different or whether it's all defined in software, someone else can answer that.&lt;/p&gt;&#xA;" OwnerUserId="4269" OwnerDisplayName="pjc50" LastActivityDate="2015-02-27T16:58:44.370" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8930" PostTypeId="1" AcceptedAnswerId="8935" CreationDate="2015-02-28T02:36:04.017" Score="0" ViewCount="658" Body="&lt;p&gt;I am using Arduino Uno R3 with MPU 6050 for a personal project. MPU 6050 is being powered by the 3.3V supply pin in the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to make the sensor mobile, I ordered &lt;a href=&quot;http://www.amazon.ca/gp/product/B00MEC4NP0?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o00_s00&quot; rel=&quot;nofollow&quot;&gt;this battery&lt;/a&gt;, which has one power output of 5V 1Amp that I plan on plugging into the Uno's USB Power/Data Outlet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that when plugged into the computer via the same USB port, around 5V 500 mA is supplied. I was wondering if someone could tell me, &lt;strong&gt;whether the 1A battery that I ordered would burn my board or not&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also, is there a built in fuse inside this board?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4305" LastActivityDate="2015-02-28T20:33:58.003" Title="Powering Arduino Uno R3 with battery packs" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8931" PostTypeId="2" ParentId="8668" CreationDate="2015-02-28T08:14:26.787" Score="1" Body="&lt;p&gt;Although you did not clearly mention nor show your wiring, it is possible the problem comes from here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Barring &lt;strong&gt;real concurrency issues&lt;/strong&gt; with your queue implementation, which I already mentioned in another answer, for which fixes have to be implemented anyway, there are two potential wiring problems in your circuit:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You use &lt;strong&gt;INT1&lt;/strong&gt; interrupt; that means you must connect your button to &lt;strong&gt;PIN 3&lt;/strong&gt; for a UNO, any other pin won't work.&lt;/li&gt;&#xA;&lt;li&gt;You did not specify &lt;code&gt;pinMode(3, INPUT_PULLUP)&lt;/code&gt; in your &lt;code&gt;setup()&lt;/code&gt;, which means &lt;strong&gt;you MUST use an external pullup resistor&lt;/strong&gt; to force a &lt;code&gt;HIGH&lt;/code&gt; value, and connect the other pin of the button to &lt;code&gt;GND&lt;/code&gt; (or conversely: put a pulldown resistor and wire the other pin to &lt;code&gt;5V&lt;/code&gt;); otherwise, while the button is left unpressed, you will have a &lt;strong&gt;floating input&lt;/strong&gt;, which means its value will vary randomly between HIGH and LOW, triggering your &lt;code&gt;int1ISR&lt;/code&gt; many times when you don't expect it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The simplest way to solve point 2 (floating input) is to use internal pullup resistors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {  &#xA;  pinMode(3, INPUT_PULLUP);&#xA;  pinMode(6, OUTPUT);&#xA;  attachInterrupt(1, int1ISR, RISING);   &#xA;  Serial.begin(115200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and connect one button pin to Arduino PIN 3, and the other button pin to &lt;code&gt;GND&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will remove floating input and its consequences.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-02-28T08:14:26.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8932" PostTypeId="2" ParentId="8930" CreationDate="2015-02-28T11:55:08.123" Score="1" Body="&lt;p&gt;The battery will be fine; the 1A rating is just a maximum, if your device only wants up to 500mA then it's got spare capacity, is all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The battery appears to have in-built short protection etc, so better than a fuse..&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-02-28T11:55:08.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8933" PostTypeId="2" ParentId="8872" CreationDate="2015-02-28T12:07:27.307" Score="1" Body="&lt;p&gt;This is a somewhat dumb question but, in case anyone else searches it as pointed out:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The precision of a float is around 7.2 decimal digits. en.wikipedia.org/wiki/Single-precision_floating-point_format –  BrettAM &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in python the number goes float -&gt; double -&gt; decmial, whereas on the arduino the number goes float -&gt; decimal. The additional step of the double in the case of python causes the discrepancies. But anything after the 7th decimal place is nonesense anyway.&lt;/p&gt;&#xA;" OwnerUserId="4911" LastActivityDate="2015-02-28T12:07:27.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8934" PostTypeId="1" CreationDate="2015-02-28T12:13:41.267" Score="3" ViewCount="14978" Body="&lt;p&gt;I have an Arduino Pro Micro (ATMega32u4) that I want to use as an IR receiver for a media PC and need to send codes like Volume Up, Media Home, Play, etc. But when I look up the scan codes for those and send them to Keyboard.press() it just prints out '0' every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any way to send those keyboard commands?&lt;/p&gt;&#xA;" OwnerUserId="600" LastActivityDate="2023-08-28T18:11:21.520" Title="Send Keyboard Media Keys with Keyboard Library" Tags="|arduino-leonardo|arduino-pro-micro|keyboard|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8935" PostTypeId="2" ParentId="8930" CreationDate="2015-02-28T14:10:52.633" Score="4" Body="&lt;p&gt;Power sources like batteries and wall warts are &lt;strong&gt;voltage sources&lt;/strong&gt;: they will deliver a fixed voltage, more or less. The current that they supply will be determined by the load you attach to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;Amps&quot; listed on a power supply is not how much current it &lt;strong&gt;will&lt;/strong&gt; put out, it is the &lt;strong&gt;maximum&lt;/strong&gt; current that the manufacturer has decided it &lt;strong&gt;can&lt;/strong&gt; put out safely, without acting funny or overheating. So when you read that the USB port on a computer supplies 5V and 500mA, that means that it will supply 5V and &lt;strong&gt;up to&lt;/strong&gt; 500mA. If you draw more than a 500mA current from your USB port, you would exceed the max current rating of the USB port. USB ports usually have an emergency shut-off mechanism built in, so they would just turn off if you drew more than 500mA out of them. I wouldn't try it though :). Your battery seems to have pretty similar safety features: &quot;Super protection: overshoot, over-discharge, short circuit, over voltage, leakage, and many other protective functions&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had a 5V 20 Amp power supply, it will act the same as the USB port power supply, except it will be able to handle putting out much more current. As long as you don't exceed a voltage source's max current rating, &lt;strong&gt;the amount of current that a voltage source puts out depends on how much current the load draws, not on the voltage source.&lt;/strong&gt; For example, a resistor will draw a current in Amps equal to the voltage supplied to it divided by the resistance (I=V/R), via Ohm's Law. For microcontrollers, you can often find their current draw on their datasheet: your MPU 6050 with the Gyro + Accel running has an operating current of &lt;a href=&quot;http://www.invensense.com/mems/gyro/mpu6050.html&quot; rel=&quot;nofollow&quot;&gt;3.8mA&lt;/a&gt; when you give it ~3.3V. An Arduino Uno draws about &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=135872.0&quot; rel=&quot;nofollow&quot;&gt;80mA&lt;/a&gt; by itself, though I don't think this includes the 3.3V power regulator on the 3V3 pin. So you're looking at somewhere a little over 84mA (=0.084A) in total. Your battery can supply 2.5A or 1A depending on which of its ports you use, so you are nowhere near exceeding the battery's max current rating, which is a good thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no fuses built in to the Arduino Uno R3. If you exceed its &lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow&quot;&gt;maximum current limitations&lt;/a&gt;, you will mess it up. There's a &lt;a href=&quot;http://www.ruggedcircuits.com/ruggeduino/&quot; rel=&quot;nofollow&quot;&gt;ruggedino&lt;/a&gt; available with more safety features if you're worried about frying your arduino. But as long as you're careful you should be fine with a standard R3.&lt;/p&gt;&#xA;" OwnerUserId="7333" LastEditorUserId="7333" LastEditDate="2015-02-28T20:33:58.003" LastActivityDate="2015-02-28T20:33:58.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8937" PostTypeId="2" ParentId="8934" CreationDate="2015-02-28T18:25:48.517" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/KeyboardPress&quot; rel=&quot;nofollow&quot;&gt;Keyboard.press()&lt;/a&gt; presses a key and “holds it down” until a &lt;a href=&quot;http://arduino.cc/en/Reference/KeyboardRelease&quot; rel=&quot;nofollow&quot;&gt;Keyboard.release()&lt;/a&gt; or releaseAll() is issued.  That is, Keyboard.press() isn't appropriate for simulation of just tapping and releasing a key, unless you follow it with a delay and a release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://arduino.cc/en/Reference/KeyboardWrite&quot; rel=&quot;nofollow&quot;&gt;Keyboard.write()&lt;/a&gt;.  But note the following, from Keyboard.write()'s documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only ASCII characters that are on the keyboard are supported. For example, ASCII 8 (backspace) would work, but ASCII 25 (Substitution) would not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On my linux system, &lt;code&gt;xev&lt;/code&gt; (used via &lt;code&gt;xev -event keyboard&lt;/code&gt;) shows the following data for media keys labeled as shown.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Excerpt from info displayed by xev           Picture&#xA;keycode 180 (keysym 0x1008ff18, XF86HomePage)   house&#xA;keycode 179 (keysym 0x1008ff81, XF86Tools)   quarter-notes&#xA;keycode 163 (keysym 0x1008ff19, XF86Mail)      envelope&#xA;keycode 172 (keysym 0x1008ff14, XF86AudioPlay)  &amp;gt;/||&#xA;keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume)  speaker&#xA;keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume)  speaker&#xA;keycode 121 (keysym 0x1008ff12, XF86AudioMute)  x'd-speaker&#xA;keycode 148 (keysym 0x1008ff1d, XF86Calculator)  Calculator&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-03-02T19:02:27.983" LastActivityDate="2015-03-02T19:02:27.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8938" PostTypeId="1" AcceptedAnswerId="8960" CreationDate="2015-02-28T22:16:58.440" Score="2" ViewCount="1800" Body="&lt;p&gt;I'm new to Arduino and still learning the basics.&#xA;I tried reading water level by using &lt;a href=&quot;http://www.emartee.com/Images/websites/emartee.com/Water%20Sensor.jpg&quot; rel=&quot;nofollow&quot;&gt;this sensor&lt;/a&gt; I left it in the water for about 5 minutes then I noticed it changing color (some parts darker than other)like the water is still over it .&#xA;So my question is do Water sensors really rust ? or is it my own imagination?&lt;/p&gt;&#xA;" OwnerUserId="7612" LastActivityDate="2015-03-02T15:26:02.617" Title="Do Water sensors Rust?" Tags="|sensors|hardware|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8939" PostTypeId="2" ParentId="8938" CreationDate="2015-02-28T22:22:37.873" Score="4" Body="&lt;p&gt;Most metals will tarnish, rust, or corrode when left in water, especially in the presence of an electric current. To be safe, a water sensor should either be gold-plated or made of a conductive, insoluble, non-metallic substance.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-02-28T22:22:37.873" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8940" PostTypeId="1" AcceptedAnswerId="8941" CreationDate="2015-03-01T04:16:43.627" Score="0" ViewCount="453" Body="&lt;p&gt;I'm still fairly new to Arduino projects, and am only just now getting into building circuits where I want to cut and place my own hookup wire instead of using the precut jumper wires. I inherited some supplies from a friend who abandoned the hobby, and about half of the wire he gave me is 22awg and the other half is 26awg. All of it is solid core copper. Is it ok to mix wire gauges like this in the same circuit/project?&lt;/p&gt;&#xA;" OwnerUserId="4401" LastActivityDate="2015-03-01T04:21:13.407" Title="Can I mix 22awg and 26awg hookup wire in the same circuit?" Tags="|arduino-uno|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8941" PostTypeId="2" ParentId="8940" CreationDate="2015-03-01T04:21:13.407" Score="1" Body="&lt;p&gt;Assuming you won't ever put more current through it than the 26AWG wire can handle, you'll be safe.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-01T04:21:13.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8942" PostTypeId="1" CreationDate="2015-03-01T05:10:02.823" Score="2" ViewCount="113" Body="&lt;p&gt;I know this has been asked several times already, but I've nevered seen it asked with an error included on launch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the message that comes up in the terminal when I launch arduino (with root privileges if thats relevant):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(java:9042): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to compile the code, it gives me the standard, &quot;COM1 NOT FOUND&quot; and a bunch of other errors. I can post the entire error message here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions? &lt;/p&gt;&#xA;" OwnerUserId="7617" LastActivityDate="2015-03-01T05:10:02.823" Title="Serial port field greyed out with error on launch (Ubuntu 14,04)" Tags="|serial|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8943" PostTypeId="1" CreationDate="2015-03-01T06:02:58.587" Score="0" ViewCount="200" Body="&lt;p&gt;I want to use a wifi shield, as well as a 2.8 inch touch LCD shield; both would fit the arduino uno V3 nicely.  Is that the best microcontroller to use&lt;/p&gt;&#xA;" OwnerUserId="7618" LastActivityDate="2015-05-31T15:39:27.820" Title="Which Microcontroller to use" Tags="|shields|wifi|lcd|sd-card|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="8945" PostTypeId="1" AcceptedAnswerId="20421" CreationDate="2015-03-01T07:27:11.347" Score="0" ViewCount="3567" Body="&lt;p&gt;I'm following a guide on storing sensor data to MySQL:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/#step1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guide&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;My POST request isn't getting any results to my server. For now, I'm only storing temperature.&lt;/p&gt;&#xA;&lt;p&gt;Here is my code for saving data:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void sendData(double input) {&#xA;  String data = &amp;quot;sensorid=3000000&amp;amp;temp=&amp;quot; + doubleToString(input, 2) + &amp;quot;&amp;amp;hum=1.2&amp;quot;;&#xA;  &#xA;  if (client.connect(&amp;quot;192.168.1.50&amp;quot;, 80)) {&#xA;    client.println(&amp;quot;POST /arduino/add.php HTTP/1.1&amp;quot;);&#xA;    client.println(&amp;quot;Host: 192.168.1.50&amp;quot;);&#xA;    // client.println(&amp;quot;User-Agent: Arduino/1.0&amp;quot;);&#xA;    // client.println(&amp;quot;Connection: close&amp;quot;);&#xA;    client.println(&amp;quot;Content-Type: application/x-www-form-urlencoded&amp;quot;);&#xA;    client.print(&amp;quot;Content-Length: &amp;quot;);&#xA;    client.print(data.length());&#xA;    client.println();&#xA;    client.print(data);&#xA;&#xA;    Serial.println(&amp;quot;Sent data: &amp;quot; + data);&#xA;  }&#xA;  &#xA;  if (client.connected()) {&#xA;    client.stop(); &#xA;  }&#xA;&#xA;  delay(300000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've commented out two headers since it did not give any other results. My &lt;code&gt;Serial.println&lt;/code&gt; gives: Sent data: sensorid=3000000&amp;amp;temp=24.00&amp;amp;hum=1.2, which means that the Arduino is connected to the given IP-adress and that my request data is as I want. They are also working perfectly when I'm testing with &lt;a href=&quot;http://requestmaker.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Requestmaker&lt;/a&gt;, so I'm pretty sure my error comes from the way I'm doing the request here.&lt;/p&gt;&#xA;&lt;p&gt;Do you have any idea how I can solve or debug this?&lt;/p&gt;&#xA;" OwnerUserId="3047" LastEditorUserId="61722" LastEditDate="2024-03-11T01:49:09.413" LastActivityDate="2024-03-11T01:50:16.460" Title="POST request not working" Tags="|ethernet|datalogging|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="8946" PostTypeId="1" AcceptedAnswerId="8948" CreationDate="2015-03-01T13:43:57.623" Score="0" ViewCount="305" Body="&lt;p&gt;Recently I bought a BT module from eBay which was very cheap. I didn't really noticed the image and I just bought it. When it came I couldn't find any holes to solder the headers. Also the specific module is pretty rare and I couldn't find anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Dz4RR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dz4RR.jpg&quot; alt=&quot;BlueTooth Module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I wire up this chip?&lt;/p&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="6936" LastEditDate="2015-11-13T18:35:28.843" LastActivityDate="2015-11-13T18:35:28.843" Title="Arduino weird bluetooth module" Tags="|arduino-uno|bluetooth|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8947" PostTypeId="2" ParentId="682" CreationDate="2015-03-01T13:51:44.670" Score="21" Body="&lt;p&gt;I have taken a look at the algorithm used by &lt;code&gt;malloc()&lt;/code&gt;, from avr-libc,&#xA;and there seems&#xA;to be a few usage patterns that are safe from the point of view of heap&#xA;fragmentation:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1. Allocate only long-lived buffers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;By this I mean: allocate all you need at the beginning of the program,&#xA;and never free it. Of course, in this case, you could as well use static&#xA;buffers...&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2. Allocate only short-lived buffers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Meaning: you free the buffer before allocating anything else. A&#xA;reasonable example might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo()&#xA;{&#xA;    size_t size = figure_out_needs();&#xA;    char * buffer = malloc(size);&#xA;    if (!buffer) fail();&#xA;    do_whatever_with(buffer);&#xA;    free(buffer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there is no malloc inside &lt;code&gt;do_whatever_with()&lt;/code&gt;, or if that function&#xA;frees whatever it allocates, then you are safe from fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3. Always free the last allocated buffer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a generalization of the two previous cases. If you use the heap&#xA;like a stack (last in is first out), then it will behave like a stack&#xA;and not fragment. It should be noted that in this case it is safe to&#xA;resize the last allocated buffer with &lt;code&gt;realloc()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;4. Always allocate the same size&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This will not prevent fragmentation, but it is safe in the sense that&#xA;the heap will not grow larger than the maximum &lt;em&gt;used&lt;/em&gt; size. If all your&#xA;buffers have the same size, you can be sure that, whenever you free one&#xA;of them, the slot will be available for subsequent allocations.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-01T14:49:05.903" LastActivityDate="2015-03-01T14:49:05.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8948" PostTypeId="2" ParentId="8946" CreationDate="2015-03-01T15:26:34.303" Score="2" Body="&lt;p&gt;From the picture you posted, i was able to google and find something called a BC04-B Bluetooth serial module. It looks almost exactly like yours, and I found a diagram on how to hook it up.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/kRMZH.jpg&quot; alt=&quot;BC04-B Bluetooth serial module&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also believe that these are the serial commands you can use with it...&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ureCG.jpg&quot; alt=&quot;Bluetooth module serial commands&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7555" LastActivityDate="2015-03-01T15:26:34.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8949" PostTypeId="1" AcceptedAnswerId="8952" CreationDate="2015-03-01T17:01:45.800" Score="1" ViewCount="838" Body="&lt;p&gt;I am trying to access my Yun externally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the below code working internally and now trying to adapt this to work for external (adapted from &lt;a href=&quot;http://arduino.cc/en/Tutorial/TemperatureWebPanel&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Tutorial/TemperatureWebPanel&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To access the Arduino Yun over the network I type:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;http://XXX.XXX.XXX.XXX:XXXXX/arduino/on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When using this script locally, i.e. &lt;code&gt;myArduinoName.local/arduino/on&lt;/code&gt;, the onboard light turns on (and off if URL changed accordingly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adapting this working code, I have changed to &quot;&lt;code&gt;noListenOnLocalhost&lt;/code&gt;&quot; and put in my port number (XXXXX).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is reached (see below for the response).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt; &#xA;&#xA;// Listen on default port 5555, the webserver on the Yun&#xA;// will forward there all the HTTP requests for us.&#xA;YunServer server(XXXXX);&#xA;String startString;&#xA;long hits = 0;&#xA;&#xA;void setup() {&#xA;  //Serial.begin(9600);&#xA;&#xA;  // Bridge startup&#xA;  pinMode(13,OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;  digitalWrite(13, HIGH);&#xA;&#xA;&#xA;  Bridge.begin();&#xA;  Console.begin();&#xA;&#xA;&#xA;  // Listen for incoming connection only from localhost&#xA;  // (no one from the external network could connect)&#xA;  //server.listenOnLocalhost();&#xA;  server.noListenOnLocalhost();&#xA;  server.begin();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Get clients coming from server&#xA;  YunClient client = server.accept();&#xA;&#xA;  client.println(&quot;hello&quot;);&#xA;&#xA;  // There is a new client?&#xA;  if (client) {&#xA;    // read the command&#xA;    String command = client.readString();&#xA;&#xA;    command.trim();        //kill whitespace&#xA;&#xA;    client.println(command); // why does this return a full GET request instead of &quot;on&quot;?&#xA;&#xA;    if (command == &quot;on&quot;) {&#xA;      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;      delay(1000);   &#xA;    }&#xA;&#xA;    if (command == &quot;off&quot;) {&#xA;      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;      delay(1000);              // wait for a second&#xA;    }&#xA;&#xA;&#xA;    // Close connection and free resources.&#xA;    client.stop();&#xA;    hits++;&#xA;  }&#xA;&#xA;  delay(50); // Poll every 50ms&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The response I get is (I have replaced my IP and port with X's):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;hello&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX&#xA;  Connection: keep-alive Pragma: no-cache Cache-Control: no-cache&#xA;  Accept:&#xA;  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,&lt;em&gt;/&lt;/em&gt;;q=0.8&#xA;  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36&#xA;  (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36&#xA;  Accept-Encoding: gzip, deflate, sdch Accept-Language:&#xA;  en-GB,en-US;q=0.8,en;q=0.6&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I expected&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;hello &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;on&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then tried to restart the device and also a uhttpd restart i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;/etc/init.d/uhttpd restart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have attempted to access the URL using my mobile phone (i.e. not on the same network).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas why my request is not being treated as HTTP?&lt;/p&gt;&#xA;" OwnerUserId="7623" LastEditorUserId="26916" LastEditDate="2017-11-04T08:09:56.133" LastActivityDate="2017-11-04T08:09:56.133" Title="External access to Yun - request not recognised as HTML" Tags="|wifi|arduino-yun|remote-control|h-bridge|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8950" PostTypeId="1" AcceptedAnswerId="8955" CreationDate="2015-03-01T17:05:40.853" Score="5" ViewCount="5974" Body="&lt;p&gt;Having developed and tested a project using an Arduino Uno, I would now like to upload it to an &lt;a href=&quot;http://www.amazon.co.uk/dp/B007YQZUEE&quot; rel=&quot;noreferrer&quot;&gt;Arduino Pro Mini&lt;/a&gt; (5V, 328, 16MHz) for semi-permanent, long-term use, but I can't get any sign of life from the Pro Mini.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the latest Arduino IDE (v1.6.0 with Java 6, on Mac OS X Mavericks), and I've got a &lt;a href=&quot;http://www.amazon.co.uk/gp/product/B00AFRXKFU&quot; rel=&quot;noreferrer&quot;&gt;USB 2.0 to TTL UART 6PIN CP2102 Module Serial Converter&lt;/a&gt; to connect the Pro Mini to the Mac, and I've selected Tools —&gt; Board —&gt; Arduino Pro or Pro Mini (5V, 16MHz) w/ ATmega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I don't see a suitable serial port in the list. When I plug in the Arduino Uno, &quot;/dev/tty.usbmodem1421&quot; immediately pops up in the Tools —&gt; Serial Port menu, but I don't see anything similar with the Mini Pro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is probably in the connection between the USB/TTL converter and the Mini Pro, so my question is: which pins should connect to which?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nAxLG.jpg&quot; alt=&quot;USB/TTL converter face to face with Arduino Pro Mini&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW the USB/TTL converter was supplied with a 5-core (not 6-core) cable to connect its 6 pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So do I connect Tx—&gt;Tx and Rx-&gt;Rx, or should they be crossed over? It's fairly clear that &quot;5V&quot; connects to &quot;Vcc&quot; and &quot;GND&quot; goes to &quot;GND&quot;, but what about CTS and DTR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also FWIW, I have googled this, and I have read a number of other posts and answers on StackExchange, but the fact that I'm here writing my question means that I'm still stuck. Any and all constructive suggestions will be appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7624" LastActivityDate="2020-08-20T07:44:15.400" Title="Having difficulty uploading sketch to an Arduino Pro Mini" Tags="|pins|uploading|arduino-pro-mini|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8952" PostTypeId="2" ParentId="8949" CreationDate="2015-03-01T17:34:32.207" Score="1" Body="&lt;p&gt;It works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The changes to the uhttpd must have done the trick to listen for http traffic on a given IP/port (other than 0.0.0.0:80).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of supplying a port number for the server in the code, I would surmise that the change to the config takes care of it so this, so the port number in code is no longer needed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;YunServer server(XXXXX);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;should be changed back to &lt;/p&gt;&#xA;&#xA;&lt;p&gt;YunServer server;&lt;/p&gt;&#xA;" OwnerUserId="7623" LastActivityDate="2015-03-01T17:34:32.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8953" PostTypeId="2" ParentId="8946" CreationDate="2015-03-01T18:02:38.833" Score="2" Body="&lt;p&gt;These Bluetooth modules are typically mounted onto another substrate, either the product board or a small PCB backplane which provides the pinouts and any additional circuitry like the pairing LED, and power- &amp;amp; signal-level management.&#xA;They are readily available as HC-05 (master/slave) or HC-06 (slave only) with signals brought to through-holes or pins at the edge of the backplane.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-03-01T18:02:38.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8954" PostTypeId="1" CreationDate="2015-03-01T18:07:30.763" Score="1" ViewCount="276" Body="&lt;p&gt;I'm using an Arduino Uno R3 along with an Ethernet shield as well as the linker base shield for interfacing with three linker modules, light, temperature and some LEDs as I believed this would be simpler than using a breadboard and look neater. Are there any problems I'm likely to run into regarding compatibility or power consumption? It's a prototype for a hydroponic garden automation system. As a secondary, are there any c02 sensors under $60 available on the market?&lt;/p&gt;&#xA;" OwnerUserId="7626" LastEditorUserId="7626" LastEditDate="2015-03-01T18:12:43.963" LastActivityDate="2016-01-27T09:32:06.570" Title="Multiple shields on one Arduino/Linker base shield" Tags="|arduino-uno|sensors|power|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8955" PostTypeId="2" ParentId="8950" CreationDate="2015-03-01T18:56:06.547" Score="5" Body="&lt;p&gt;You need to hook it up with the Arduino TX --&gt; FTDI RX, and vise versa, so crossed over.  If you take the FTDI and hook it up to the Ardiono pin to pin as you have it pictured it should work, provided the FTDI works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No to your note about not having a serial port, you should have that as soon as you plug the FTDI into your computer, the Arduino is not necessary for this.  First things first, check you drivers, and check your USB connection.  You won't get anywhere until that Serial port is recognized on your computer.&lt;/p&gt;&#xA;" OwnerUserId="7628" LastActivityDate="2015-03-01T18:56:06.547" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8956" PostTypeId="1" AcceptedAnswerId="8961" CreationDate="2015-03-01T19:26:23.130" Score="4" ViewCount="13839" Body="&lt;p&gt;I have a working project built around ATTiny85 on a breadboard running at 5V. Now I want to move this prototype on a PCB where it will be powered from batteries. All components used are capable of running 3.3V so I want to run the ATTiny85 at 3.3V as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a programmer so I use ArduinoISP to program the ATTiny. If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?&lt;/p&gt;&#xA;" OwnerUserId="5167" LastActivityDate="2015-03-02T16:54:34.473" Title="How to program ATTiny85 running 3.3V" Tags="|programming|voltage-level|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8957" PostTypeId="1" AcceptedAnswerId="8959" CreationDate="2015-03-01T19:36:33.453" Score="8" ViewCount="1002" Body="&lt;p&gt;First things first, if there was an ESP8266 StackExchange, I would post this there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am setting up a web server that will programmaticly be controlled from an external Python script, and I am currently able to send this server data using this script, but I don't receive an HTTP response back when I do, so the external script crashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have googled around and not found much on this, so the question is How do I, From the Arduino, using an ESP8266 send an HTML response code?&lt;/p&gt;&#xA;" OwnerUserId="7628" LastEditorUserId="7628" LastEditDate="2015-03-02T18:00:05.473" LastActivityDate="2018-10-16T13:22:51.860" Title="Arduino and ESP8266 Web server" Tags="|networking|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8958" PostTypeId="2" ParentId="8938" CreationDate="2015-03-01T19:42:35.373" Score="1" Body="&lt;p&gt;I have that same sensor, and found a couple things to help with this issue.  The first thing that I did with min was tin the contacts with solder (All 10 'sensor contacts' all the way down) and also, using the GPIO, only power it on about 1 second before I read it, and turn it off immediately after.  By reducing the amount of time current is running through it, you reduce the tarnish, and the solder i tined everything with is less likely to corrode than the raw contacts.&lt;/p&gt;&#xA;" OwnerUserId="7628" LastActivityDate="2015-03-01T19:42:35.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8959" PostTypeId="2" ParentId="8957" CreationDate="2015-03-01T20:49:11.647" Score="7" Body="&lt;p&gt;After countless Trial/error attempts, I was able to put together the proper sequence.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CIPSEND=0,40  \\Set this for your current connection ID and payload length.&#xA;HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n  &#xA;AT+CIPCLOSE=0  \\Set this for your current connection ID&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Send these commands with the arduino, and it should exit successfully.  You can also flush out the HTTP line with any other information you would like to include, as defined in the &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6&quot; rel=&quot;noreferrer&quot;&gt;rfc2616 (HTTP/1.1) standard&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7628" LastActivityDate="2015-03-01T20:49:11.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8960" PostTypeId="2" ParentId="8938" CreationDate="2015-03-01T21:18:20.127" Score="3" Body="&lt;p&gt;The color change you observed is probably caused a galvanic reaction between metals in the sensor and other metals that are present, such as the tank, piping, or dissolved metals in the water. Do not modify the parallel strips of metal on the sensor. This will render the sensor useless. To reduce the effects of galvanic corrosion, you can:&#xA;1) Reduce the current passing through the sensor. To do this, sample the sensor less frequently. For, example, sample it once every second. &#xA;2) If possible, remove sources of metal from the water. For example, replace metal pipes with PVC, and replace screws with plastic zip-ties. &#xA;3) Move the sensor further away from sources of metal. &#xA;4) Place a grounded sacrificial zinc in the water, close any other metal sources. If the water is circulating, place the zinc near the inflow opening.&#xA;5) Remove stray or electrical currents from the water. Connect the &quot;-&quot; pin (GND) and the water to the same ground.&lt;/p&gt;&#xA;" OwnerUserId="7631" LastEditorUserId="7631" LastEditDate="2015-03-02T15:26:02.617" LastActivityDate="2015-03-02T15:26:02.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8961" PostTypeId="2" ParentId="8956" CreationDate="2015-03-01T22:25:39.200" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. But if there are &lt;em&gt;any&lt;/em&gt; components on the board that &lt;em&gt;can't&lt;/em&gt; run at 5V then you must provide some way of protecting them from the excessive voltage.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are no fuses required to change the actual operating voltage of the device. There is the BOD threshold, but you can still operate the device at a higher voltage without issue regardless.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-01T22:25:39.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8962" PostTypeId="1" AcceptedAnswerId="8963" CreationDate="2015-03-02T00:23:24.347" Score="9" ViewCount="650" Body="&lt;p&gt;Is there some code I can use to find out what the a chosen serial port's speed is running at ?&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-03-02T04:34:29.967" Title="Can you query the current serial port's speed?" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8963" PostTypeId="2" ParentId="8962" CreationDate="2015-03-02T01:00:52.137" Score="7" Body="&lt;p&gt;There is not a top level, easy to use way. Sorry. It is probably easier to just store your chosen baud rate in a variable when you setup the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, What you can try to do for the AVR-based, hardware UARTs is undo what &lt;code&gt;Serial.begin&lt;/code&gt; does to set up a particular baud rate, but its a bit of a pain. This is the code for setting the baud rate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // Try u2x mode first&#xA;  uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;&#xA;  *_ucsra = 1 &amp;lt;&amp;lt; U2X0;&#xA;&#xA;  // hardcoded exception for 57600 for compatibility with the bootloader&#xA;  // shipped with the Duemilanove and previous boards and the firmware&#xA;  // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot&#xA;  // be &amp;gt; 4095, so switch back to non-u2x mode if the baud rate is too&#xA;  // low.&#xA;  if (((F_CPU == 16000000UL) &amp;amp;&amp;amp; (baud == 57600)) || (baud_setting &amp;gt;4095))&#xA;  {&#xA;    *_ucsra = 0;&#xA;    baud_setting = (F_CPU / 8 / baud - 1) / 2;&#xA;  }&#xA;&#xA;  // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)&#xA;  *_ubrrh = baud_setting &amp;gt;&amp;gt; 8;&#xA;  *_ubrrl = baud_setting;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find the results of this by reading the right UCSRA, UBRRH, and UBRRL registers. On an uno those are the correct register names, on an mega its UCSR0A, UBRR0H, UBRR0L for Serial, UCRS1A ... for serial1 and so on. Non-avr boards (and &lt;code&gt;Serial&lt;/code&gt; on a leonardo) will be totally different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There will be a single state for those three registers on an AVR hardware serial port for a particular board (and frequency of that board) at each baud rate. You can try and make an equation to get the original baud rate out, but I recommend just comparing the direct values with a lookup of some kind because the integer arithmetic rounding errors will make it a huge mess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on my mega UBBR0H, UBBR0L, and UCSR0A are 0, 207, 2 at 9600 baud, but they are 0, 51, 2 at 38400 baud and 0, 16, 0 at 57600 baud.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-03-02T04:34:29.967" LastActivityDate="2015-03-02T04:34:29.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8964" PostTypeId="2" ParentId="182" CreationDate="2015-03-02T02:04:45.440" Score="0" Body="&lt;p&gt;Like you said, Ethernet shields are expensive, but you don't have to use the shield.  Check out the &lt;a href=&quot;https://www.google.com/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=enc28j60&quot; rel=&quot;nofollow&quot;&gt;enc28j60&lt;/a&gt; for wired networking, or the &lt;a href=&quot;https://www.google.com/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#safe=off&amp;amp;q=esp8266&quot; rel=&quot;nofollow&quot;&gt;ESP8266&lt;/a&gt; if you would prefer wireless.  Both are about $4USD.  I am using the ESP8266 now and have about 8 devices talking to each other and a Raspberry Pi.  It is a really great little chip!  I cannot speak personally to the ENC28j60, as they are still sitting in the package on my desk.&lt;/p&gt;&#xA;" OwnerUserId="7628" LastActivityDate="2015-03-02T02:04:45.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8965" PostTypeId="1" AcceptedAnswerId="8977" CreationDate="2015-03-02T02:42:36.453" Score="-10" ViewCount="5608" Body="&lt;p&gt;I want to Use LEONARDO PRO MICRO and A4988 Stepper Motor DRIVER to control Nema 17 Stepper Motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/43w75.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/pklWd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know how to hookup these together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please give me a circuit for this type of assembly with Arduino code.&lt;/p&gt;&#xA;" OwnerUserId="7642" OwnerDisplayName="ANKIT JAIN" LastEditorUserId="-1" LastEditDate="2015-03-02T13:42:24.833" LastActivityDate="2017-03-17T20:47:25.663" Title="STEPPER MOTOR CONTROLLER Using LEONARDO PRO MICRO" Tags="|motor|arduino-leonardo|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8966" PostTypeId="1" CreationDate="2015-03-02T05:48:49.150" Score="2" ViewCount="2476" Body="&lt;p&gt;I have logged  some data in my sdcard/FAT32 (format).&#xA;I can read and display them on the serial monitor but additionally I want to use these data as float.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       byte index = 0;&#xA;&#xA;       Tfile = SD.open(&quot;DATALOG.TXT&quot;,FILE_READ); &#xA;&#xA;       while (Tfile.available()) {&#xA;&#xA;         x[index++] = Tfile.read();&#xA;         x[index] = '\0'; // NULL terminate the array&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Printing the data using: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Serial.print(fileContents);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I receive  the following float values that are correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   .63&#xA;   15.63&#xA;   16.60&#xA;   16.60&#xA;   16.60&#xA;   16.60&#xA;   etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I want to work with values so i need to store them on a double index:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    double dtemp[320];&#xA;    for(index = 0, i=0; index &amp;lt; 320; index++, i++) {&#xA;       dtemp[i] =  fileContents[index];&#xA;       Serial.println(dtemp[i]); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but i receive fault values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      46.00&#xA;      54.00&#xA;      51.00&#xA;      13.00&#xA;      10.00&#xA;      49.00&#xA;      53.00&#xA;      etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any comment is welcomed !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance !&lt;/p&gt;&#xA;" OwnerUserId="7636" LastEditorUserId="6452" LastEditDate="2015-03-02T09:56:48.783" LastActivityDate="2015-03-02T12:13:47.630" Title="Read data from SD" Tags="|serial|sd-card|float|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8968" PostTypeId="2" ParentId="8966" CreationDate="2015-03-02T09:23:50.637" Score="2" Body="&lt;p&gt;You have to &lt;em&gt;parse&lt;/em&gt; the character array in order to convert it to&#xA;floats. There is no fast way to do this: since the Arduino has no FPU,&#xA;&lt;em&gt;anything&lt;/em&gt; involving floats is slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you really have to, I would not recommend slurping the whole file&#xA;into RAM. You will save memory by parsing the file on the fly. This&#xA;should be as simple as calling the &lt;code&gt;parseFloat()&lt;/code&gt; method of the &lt;code&gt;File&lt;/code&gt;&#xA;object:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;double dtemp[320];&#xA;int i;&#xA;for (i = 0; Tfile.avalable() &amp;amp;&amp;amp; i &amp;lt; 320; i++) {&#xA;    dtemp[i] = Tfile.parseFloat();&#xA;    Serial.println(dtemp[i]);&#xA;}&#xA;if (i &amp;lt; 320)&#xA;    Serial.println(&quot;WARNING: Premature end of file.&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-02T12:13:47.630" LastActivityDate="2015-03-02T12:13:47.630" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8969" PostTypeId="1" CreationDate="2015-03-02T09:54:28.413" Score="1" ViewCount="554" Body="&lt;p&gt;In the project of guiding a sight disabled person in a known environment, we need to have a precise way of figuring out where the user is. Our current solution is to use WPS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is however our first project with Arduino, and we're not quite sure if we're going the right way about this. We're thinking of getting a compass component and such, but is there something we should know before advancing further in the project? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Additional information. &#xA;The system is placed on the user, most probably strapped to the arm. The communication to the Wi-Fi beacons will be done from there, as well as the calculations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The environment is supposed to be as complex as an exposition hall, but we can aim higher. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Budget range is around $100, Arduino itself excluded. A UNO is already provided to us. &lt;/p&gt;&#xA;" OwnerUserId="7637" LastEditorUserId="7637" LastEditDate="2015-03-02T10:32:31.270" LastActivityDate="2016-06-15T11:38:28.590" Title="Feasibility of a Wi-Fi Positioning System" Tags="|wifi|components|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8970" PostTypeId="2" ParentId="8943" CreationDate="2015-03-02T12:25:30.510" Score="1" Body="&lt;p&gt;To answer your first question, regarding stacking a WiFi Arduino Shield on top of a LCD Shield:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;can I stack them simultaneously&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The obvious answer is - &lt;strong&gt;it depends on the shields&lt;/strong&gt;. Each shield might use a different set of Arduino I/O pins, making them unavailable to the next shield stacked on top of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for example, this &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;formal Arduino WiFi shield&lt;/a&gt; makes &lt;strong&gt;I/O pins 10, 11, 12, 13 and 7&lt;/strong&gt; (on Arduino Uno) unavailable to the next top shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, this &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/LCD_KeyPad_Shield_For_Arduino_SKU:_DFR0009&quot; rel=&quot;nofollow&quot;&gt;LCD KeyPad shield&lt;/a&gt; needs pins 7 and 10 available (among others) in order to function properly. This makes it incompatible for stacking on top of the WiFi shield mentioned above (or vice versa).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't mean that there is no way that &lt;strong&gt;any&lt;/strong&gt; LCD shield could be stacked on top of a WiFi shield, but to be honest, I couldn't easily find any LCD shield that won't collide with a WiFI shield pins. You might want to change approach and send the WiFi data using the built-in Serial to a computer.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is that the best microcontroller to use&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If there would have been a manifest to this website, I'm sure that &quot;The best product is the one that meet your needs best&quot; would be it's first sentence. In order for someone with experience to answer what is best, (s)he would need to know your exact needs. Since you are still not sure what they are, and just want to play around a bit, I imagine that the classic Arduino Uno R3 could help you find your way, especially if you are doing your first steps with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-03-02T12:25:30.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8972" PostTypeId="1" AcceptedAnswerId="8973" CreationDate="2015-03-02T15:52:58.197" Score="1" ViewCount="442" Body="&lt;p&gt;I am writing a simple Conway's Game of Life implementation just to get to grips with the &quot;Nokia 3310&quot; LCD and I am having problems with boolean arrays. I am using an (unofficial) Arduino Pro Micro 5V/16MHz&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code that is causing me trouble:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean buffer[84][48];&#xA;&#xA;void setup(){  &#xA;  for(int i = 0; i &amp;lt; 84; i++){&#xA;    for(int j = 0; j &amp;lt; 48; j++){&#xA;      buffer[i][j] = true;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I upload this to the Arduino, it seemingly freezes up with the RX led on and its COM port stops working. If I want to upload any other sketch, I have to manually pull the RST pin LOW (since the Pro Micro doesn't have a reset button).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been playing around with the code and found out that the source of problems is this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buffer[i][j] = true;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It also doesn't matter if I use &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried debugging with Serial to the computer, but the Serial communication doesn't work at all, so I tried using an LED to find out where the problem is. I don't have any &quot;regular&quot; LEDs on me, so I had to try with an Adafruit NeoPixel. The outcome was quite interesting. When I comment out the problematic line, everything runs just fine, the led goes red for 500ms then it blinks white every time the problematic line would run and then it goes green and stays that way. With the problematic line in place, the LED won't do anything, even turn red, which I put much earlier in the code than the source of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody have any insights that might be useful? (Also, I really hope it is not some stupid typo, I swear I read it through about twenty times) &lt;/p&gt;&#xA;" OwnerUserId="7644" LastActivityDate="2015-03-02T18:08:38.057" Title="Problems with (somewhat) large boolean arrays" Tags="|arduino-pro-micro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8973" PostTypeId="2" ParentId="8972" CreationDate="2015-03-02T16:03:10.193" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Reference/BooleanVariables&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/pmwiki.php?n=Reference/BooleanVariables&lt;/a&gt;, &quot;Each boolean variable occupies one byte of memory.&quot; Meaning you are trying to use 4032 Bytes of RAM with your array which I assume you do not have (whatever this unofficial Arduino is -- it's likely to be less than that: the ATmega328 of the Arduino Mini has 2 kB of SRAM, the ATmega32u4 of the Micro has 2.5 kB). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try with a quarter of the field size for a start and see if that makes your problems go away.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-02T16:24:03.320" LastActivityDate="2015-03-02T16:24:03.320" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8974" PostTypeId="2" ParentId="8815" CreationDate="2015-03-02T16:19:23.147" Score="0" Body="&lt;p&gt;Finally figured it out. I need to call &lt;a href=&quot;http://arduino.cc/en/Serial/Flush&quot; rel=&quot;nofollow&quot;&gt;Serial.flush()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Waits for the transmission of outgoing serial data to complete.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7500" LastActivityDate="2015-03-02T16:19:23.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8975" PostTypeId="2" ParentId="182" CreationDate="2015-03-02T16:26:50.350" Score="0" Body="&lt;p&gt;You could use a Ethernet breakout board ($2 at Sparkfun).  This lets you use the Ethernet cables but you don't have to use a full TCP/IP protocol, instead you can just hook up data pins to the breakout board, use the Ethernet to connect them, and then have them talk using serial.  I use this quite a bit to place one wire sensors further from the Arduino for a strong yet cheap connection.&lt;/p&gt;&#xA;" OwnerUserId="6950" LastActivityDate="2015-03-02T16:26:50.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8976" PostTypeId="2" ParentId="8956" CreationDate="2015-03-02T16:54:34.473" Score="0" Body="&lt;p&gt;Most ideal would be to use a buffer chip (like there is on the &lt;a href=&quot;https://www.sparkfun.com/products/9825&quot; rel=&quot;nofollow&quot;&gt;AVR Pocket Programmer&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in your case you could get away with just placing some resistors (1k or something) on the ISP lines. This is because if the chip is powered by 3v and you put a 5v signal on one of the pins it's clamping diodes will redirect the higher voltage to VCC, raising VCC to 5v. In your case the 5v is not necessarily a problem. But if you circuit is using e.g. 100mA, that means 100mA will go through the clamping diode. It's not designed for that.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-02T16:54:34.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8977" PostTypeId="2" ParentId="8965" CreationDate="2015-03-02T17:27:48.993" Score="2" Body="&lt;p&gt;You can simply make a google search;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7W4Th.png&quot; alt=&quot;Wiring instructions&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some code to get you started&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Declaration of variables&#xA;#define Step 7     // Pin that transmits the &quot;step&quot; order to the board&#xA;#define Dir  6     // Pin that indicates the direction of the rotation&#xA;int vit  =   10 ;   // Speed of the rotation (smaller means faster rotation)&#xA;int sens =   1  ;  // Rotation direction (0 or 1)&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode( Step  , OUTPUT );&#xA;  pinMode( Dir   , OUTPUT );&#xA;}&#xA;void loop()&#xA;{&#xA;    digitalWrite( Dir   , sens);&#xA;    digitalWrite( Step  , LOW);&#xA;    // Fabrication d'un &quot;Pas&quot;&#xA;    digitalWrite( Step, HIGH );&#xA;    delay(vit);&#xA;    digitalWrite( Step, LOW );&#xA;    delay(vit);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just a google search and I got on [this site][2] which had the code I gave you.&#xA;I think you can also find some libraries that can do the work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in case that you need to wait less than a millisecond, &lt;code&gt;millis()&lt;/code&gt; won't be useful for you; instead, use &lt;code&gt;delayMicroseconds()&lt;/code&gt; which will make you wait a thousandth (at minimum) of a millisecond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For what you asked you have to first get the voltage: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltage = analogRead ( 0 )  * (3.0 / 1023.0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You just have to adapt your speed relatively to the voltage.&#xA;To do this, I suggest you the &lt;a href=&quot;http://arduino.cc/en/reference/map&quot; rel=&quot;nofollow noreferrer&quot;&gt;map function&lt;/a&gt; directly from Arduino site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful just because whatever you are doing, analogRead takes &lt;strong&gt;100 microseconds&lt;/strong&gt; to get the voltage, so if you need to go very fast you can't.  I suggest you to work with a different type of communication, like Serial, SPI or I2c. &lt;/p&gt;&#xA;" OwnerUserId="4887" LastEditorUserId="11529" LastEditDate="2017-03-17T20:47:25.663" LastActivityDate="2017-03-17T20:47:25.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8978" PostTypeId="2" ParentId="8972" CreationDate="2015-03-02T18:08:38.057" Score="2" Body="&lt;p&gt;Well, if each boolean takes a full byte, as fuenfundachtzig says, then you might try some bitwise hacking to fit 8 bools per byte on your own.  Maybe something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int16 buffer[84][3];  //16 bits * 3 = 48 bits, per the original example&#xA;&#xA;void init_buffer()&#xA;{&#xA;    for(int i = 0; i &amp;lt; 84; i++)&#xA;    {&#xA;        for(int j = 0; j &amp;lt; 3; j++)&#xA;        {&#xA;            buffer[i][j] = 0xFFFF;  //all TRUE: each F is hexadecimal for 0b1111 in binary&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;bool get_buffer(unsigned int8 i, unsigned int8 j)&#xA;{&#xA;    unsigned int16 k = 0;&#xA;    while(j &amp;gt;= 16)&#xA;    {&#xA;        j -= 16;  //I can do this because i and j are passed by value and are therefore separate copies inside this function&#xA;        k++;&#xA;    }&#xA;    //now k is the array index and j is the bit position inside that element&#xA;    if(buffer[i][k] &amp;amp; (1 &amp;lt;&amp;lt; j))  //(bitwise AND with 1 shifted left by j positions, so we only care about that bit)&#xA;    {&#xA;        return TRUE;&#xA;    }&#xA;    else&#xA;    {&#xA;        return FALSE;&#xA;    }&#xA;    //or, if your compiler supports it, you might replace the if/else with:&#xA;    return (buffer[i][k] &amp;amp; (1 &amp;lt;&amp;lt; j));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the stylistic differences between my example and yours:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I like to completely specify my datatypes if I can.  Don't rely on the compiler to do what you expect because it may have options to that effect that are set differently than you think.&lt;/li&gt;&#xA;&lt;li&gt;I like to use brackets for everything, even single statements, and make them obvious.  That way, there's no confusion later or additional bugs because a second statement was added to what used to be a bracketless single without adding the brackets.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The only exception to that is when I'm writing a series of almost-identical if's and I put both the if and the action on the same line, all aligned so that the subtle differences line up and become obvious.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7647" LastActivityDate="2015-03-02T18:08:38.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8979" PostTypeId="1" AcceptedAnswerId="8980" CreationDate="2015-03-02T18:24:57.273" Score="8" ViewCount="3312" Body="&lt;p&gt;I'm not sure this is right place for this question, but does anyone have any idea how a 7 segment display is projected or embedded in wood for products like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/neWtv.jpg&quot; alt=&quot;amazon wood clock&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full product info at &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00D6DI0LE&quot; rel=&quot;noreferrer&quot;&gt;http://www.amazon.com/Cube-Wood-LED-Alarm-Clock/dp/B00D6DI0LE&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/x3VBV.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From: &lt;a href=&quot;http://www.selectism.com/2013/11/27/a-wooden-led-alarm-clock-and-wireless-bluetooth-speaker-from-gogroove/&quot; rel=&quot;noreferrer&quot;&gt;http://www.selectism.com/2013/11/27/a-wooden-led-alarm-clock-and-wireless-bluetooth-speaker-from-gogroove/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7648" LastEditorUserId="7648" LastEditDate="2015-03-02T18:31:54.607" LastActivityDate="2015-03-02T19:05:08.823" Title="7 segment LEDs on wood face" Tags="|led|display|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8980" PostTypeId="2" ParentId="8979" CreationDate="2015-03-02T18:50:25.857" Score="10" Body="&lt;p&gt;This is done by carefully placing a layer of wood veneer over the 7-segment displays. The veneer is thin enough to let the light pass through. I wouldn't be surprised if some manufacturers use brighter than normal LEDs to make the display easier to see. &lt;a href=&quot;https://www.youtube.com/watch?v=2P-8-zd7sXg&quot;&gt;Here is a video detailing an example.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to simply drill out the wood to make it very thin where the 7-segment displays go. &lt;a href=&quot;http://www.instructables.com/id/Solid-Wood-Digital-Clock/&quot;&gt;Here is an example of drilling the solid wood to be very thin.&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="7292" LastEditorUserId="7292" LastEditDate="2015-03-02T19:05:08.823" LastActivityDate="2015-03-02T19:05:08.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8982" PostTypeId="2" ParentId="8058" CreationDate="2015-03-02T20:57:48.253" Score="3" Body="&lt;p&gt;One example of setting up Jenkins continuous integration for Arduino project can be found here: &lt;a href=&quot;http://jperala.fi/2015/02/20/setting-up-continuous-integration-for-embedded-systems/&quot; rel=&quot;nofollow&quot;&gt;Continuous integration for embedded systems&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example shows how to build and upload image to Arduino and execute Selenium web tests (the system under test is Arduino-based web-server).&lt;/p&gt;&#xA;" OwnerUserId="7652" LastEditorUserId="26430" LastEditDate="2016-09-07T15:47:21.300" LastActivityDate="2016-09-07T15:47:21.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8984" PostTypeId="2" ParentId="8954" CreationDate="2015-03-03T01:30:24.760" Score="2" Body="&lt;p&gt;I would recommend looking up the power consumption specs on the datasheets for each shield. Then determine whether the current used by all of the shields exceeds the limits for any given pin and for the board as a whole. I highly recommend the following article: &lt;a href=&quot;http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7631" LastActivityDate="2015-03-03T01:30:24.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8985" PostTypeId="1" CreationDate="2015-03-03T03:34:28.243" Score="2" ViewCount="84" Body="&lt;p&gt;I'm using GPIO api and configure it as input pull down. It reads value 0. However, when I use power meter, and connect this gpio and ground, it shows 3.3V. Is it normal or maybe some other peripheral module actually pull this gpio high? To reduce power consumption, should I connect this gpio to 3V3 and configure it as input pull high? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7656" LastActivityDate="2015-03-03T03:34:28.243" Title="gpio input read 0, but voltage is 3V3" Tags="|power|pins|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="8986" PostTypeId="1" CreationDate="2015-03-03T04:25:30.987" Score="2" ViewCount="243" Body="&lt;p&gt;I am trying to use the RedBear Blend Micro to send data captured by my SparkFun 6 DOF IMU.  I am completely lost, and if anyone has any documentation I can read, or even tutorials that work for this specific IMU, I would highly appreciate it. &lt;/p&gt;&#xA;" OwnerUserId="7659" LastActivityDate="2015-03-03T04:25:30.987" Title="Streaming IMU data over BLE using Sparkfun 6 DOF and Blend Micro" Tags="|accelerometer|arduino-micro|gyroscope|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8987" PostTypeId="1" CreationDate="2015-03-03T06:06:52.860" Score="2" ViewCount="4513" Body="&lt;p&gt;Can someone explain, step by step, along with all software I must use for using Windows command prompt to build an Arduino sketch (.ino file )? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've followed &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=37813.45&quot; rel=&quot;nofollow&quot;&gt;these steps&lt;/a&gt; but I can't.&lt;/p&gt;&#xA;" OwnerUserId="7661" LastEditorUserId="10794" LastEditDate="2015-09-06T08:52:29.260" LastActivityDate="2015-09-06T08:52:29.260" Title="Build arduino with windows command line" Tags="|arduino-uno|led|arduino-ide|compile|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="8988" PostTypeId="2" ParentId="8987" CreationDate="2015-03-03T08:01:58.337" Score="4" Body="&lt;p&gt;The command line interface of the Arduino IDE is described in this document&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this command will compile and upload the Blink example to my Arduino Leonardo&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./arduino --upload --board arduino:avr:leonardo --port /dev/ttyACM0 --verbose examples/01.Basics/Blink/Blink.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Foot note: with IDE 1.6.0, there is an experimental version of the IDE for recent MacOSXs. It doesn't yet support the command line. If you need the command line on Mac, use the recommended version. This will be fixed with 1.6.1&lt;/p&gt;&#xA;" OwnerUserId="27" LastEditorUserId="27" LastEditDate="2015-03-04T08:19:39.413" LastActivityDate="2015-03-04T08:19:39.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8989" PostTypeId="1" CreationDate="2015-03-03T10:43:50.557" Score="-3" ViewCount="488" Body="&lt;p&gt;This is the Arduino code for a four road junction. In the below code, the &lt;code&gt;if&lt;/code&gt; case must be tested after every road without delay. Can any one guide me?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int redLed1 = 7; &#xA;int yellowLed1 = 6; &#xA;int greenLed1 = 5;&#xA;int redLed2 = 4; &#xA;int yellowLed2 = 3; &#xA;int greenLed2 = 2;&#xA;int redLed3 =8 ; &#xA;int yellowLed3 =9; &#xA;int greenLed3 =10;&#xA;int redLed4 = 14; &#xA;int yellowLed4 = 15; &#xA;int greenLed4 =16;&#xA;int THRESHOLD=700;&#xA;int soundvalue=0;&#xA;void setup()&#xA;{ &#xA;    pinMode(redLed1, OUTPUT);&#xA;    pinMode(yellowLed1, OUTPUT); &#xA;    pinMode(greenLed1, OUTPUT); &#xA;    pinMode(redLed2, OUTPUT);&#xA;    pinMode(yellowLed2, OUTPUT); &#xA;    pinMode(greenLed2, OUTPUT); &#xA;    pinMode(redLed3, OUTPUT);&#xA;    pinMode(yellowLed3, OUTPUT); &#xA;    pinMode(greenLed3, OUTPUT);&#xA;    pinMode(redLed4, OUTPUT);&#xA;    pinMode(yellowLed4, OUTPUT); &#xA;    pinMode(greenLed4, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;    digitalWrite(redLed2,HIGH);&#xA;    digitalWrite(redLed3,HIGH);&#xA;    digitalWrite(redLed4,HIGH);&#xA;    digitalWrite(redLed1,HIGH);&#xA;    digitalWrite(yellowLed1,HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(redLed1,LOW);&#xA;    digitalWrite(yellowLed1,LOW);&#xA;    digitalWrite(greenLed1,HIGH);&#xA;    if(analogRead(A0)&amp;gt;=THRESHOLD)&#xA;    {&#xA;        digitalWrite(greenLed2,LOW);&#xA;        digitalWrite(greenLed1,HIGH);&#xA;        delay(10000);&#xA;        digitalWrite(greenLed1,LOW);&#xA;    }&#xA;    delay(30000);&#xA;    digitalWrite(greenLed1,LOW);&#xA;    digitalWrite(redLed1,HIGH);&#xA;    digitalWrite(yellowLed2,HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(redLed2,LOW);&#xA;    digitalWrite(yellowLed2,LOW);&#xA;    digitalWrite(greenLed2,HIGH);&#xA;&#xA;    delay(30000);&#xA;    digitalWrite(greenLed2,LOW);&#xA;    digitalWrite(redLed2,HIGH);&#xA;    digitalWrite(yellowLed3,HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(redLed3,LOW);&#xA;    digitalWrite(yellowLed3,LOW);&#xA;    digitalWrite(greenLed3,HIGH);&#xA;&#xA;    delay(30000);&#xA;    digitalWrite(greenLed3,LOW);&#xA;    digitalWrite(redLed3,HIGH);&#xA;    digitalWrite(yellowLed4,HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(redLed4,LOW);&#xA;    digitalWrite(yellowLed4,LOW);&#xA;    digitalWrite(greenLed4,HIGH);&#xA;    delay(30000);&#xA;    digitalWrite(greenled4,LOW);&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7664" LastEditorUserId="42" LastEditDate="2015-03-03T11:15:08.173" LastActivityDate="2015-03-04T19:17:12.857" Title="Code for four road junction" Tags="|arduino-mega|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="8990" PostTypeId="2" ParentId="8920" CreationDate="2015-03-03T11:16:05.890" Score="0" Body="&lt;p&gt;My question has been answered on Stack Overflow, if you ask&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/28765288/can-zigbee-api-and-zigbee-at-modules-work-together-in-the-same-network&quot;&gt;https://stackoverflow.com/questions/28765288/can-zigbee-api-and-zigbee-at-modules-work-together-in-the-same-network&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7589" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-03T11:16:05.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8991" PostTypeId="1" CreationDate="2015-03-03T14:30:23.450" Score="1" ViewCount="451" Body="&lt;p&gt;After serveral attempts, I can't make my arduino UNO to program an attiny85, no matter what I do. I've tried under windows 7 and also under ubuntu 14.04, to no avail. I've followed instructions on hi low tech site and similar ones on arduino site. Even some youtube video. Nothing. The wiring of my arduino is as described in those sites, so it should be correct. I'm using the 10uF capacitor too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output running avrdude manually, extra verbose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    zop@mikasa:~$ sudo /usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf  -q -pattiny85 -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/build2861466093518309047.tmp/Fade.cpp.hex:i -v -v -v -v -v -v -v -v  &#xA;&#xA;    avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32&#xA;             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;             Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;             System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;             User configuration file is &quot;/home/zop/.avrduderc&quot;&#xA;             User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;             Using Port                    : /dev/ttyACM0&#xA;             Using Programmer              : stk500v1&#xA;             Overriding Baud Rate          : 19200&#xA;    avrdude: Send: 0 [30]   [20] &#xA;    avrdude: Send: 0 [30]   [20] &#xA;    avrdude: Send: 0 [30]   [20] &#xA;    avrdude: Send: 0 [30]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [10] &#xA;             AVR Part                      : ATtiny85&#xA;             Chip Erase delay              : 4500 us&#xA;             PAGEL                         : P00&#xA;             BS2                           : P00&#xA;             RESET disposition             : possible i/o&#xA;             RETRY pulse                   : SCK&#xA;             serial program mode           : yes&#xA;             parallel program mode         : yes&#xA;             Timeout                       : 200&#xA;             StabDelay                     : 100&#xA;             CmdexeDelay                   : 25&#xA;             SyncLoops                     : 32&#xA;             ByteDelay                     : 0&#xA;             PollIndex                     : 3&#xA;             PollValue                     : 0x53&#xA;             Memory Detail                 :&#xA;&#xA;                                      Block Poll               Page                       Polled&#xA;               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;               eeprom        65     6     4    0 no        512    4      0  4000  4500 0xff 0xff&#xA;                 Memory Ops:&#xA;                   Oeration     Inst Bit  Bit Type  Bitno  Value&#xA;                   -----------  --------  --------  -----  -----&#xA;                   READ               31     VALUE      7      1&#xA;                                      30     VALUE      6      0&#xA;                                      29     VALUE      5      1&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7    OUTPUT      7      0&#xA;                                       6    OUTPUT      6      0&#xA;                                       5    OUTPUT      5      0&#xA;                                       4    OUTPUT      4      0&#xA;                                       3    OUTPUT      3      0&#xA;                                       2    OUTPUT      2      0&#xA;                                       1    OUTPUT      1      0&#xA;                                       0    OUTPUT      0      0&#xA;                   WRITE              31     VALUE      7      1&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7     INPUT      7      0&#xA;                                       6     INPUT      6      0&#xA;                                       5     INPUT      5      0&#xA;                                       4     INPUT      4      0&#xA;                                       3     INPUT      3      0&#xA;                                       2     INPUT      2      0&#xA;                                       1     INPUT      1      0&#xA;                                       0     INPUT      0      0&#xA;                   LOADPAGE_LO        31     VALUE      7      1&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      1&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20     VALUE      4      0&#xA;                                      19     VALUE      3      0&#xA;                                      18     VALUE      2      0&#xA;                                      17     VALUE      1      0&#xA;                                      16     VALUE      0      0&#xA;                                      15     VALUE      7      0&#xA;                                      14     VALUE      6      0&#xA;                                      13     VALUE      5      0&#xA;                                      12     VALUE      4      0&#xA;                                      11     VALUE      3      0&#xA;                                      10     VALUE      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7     INPUT      7      0&#xA;                                       6     INPUT      6      0&#xA;                                       5     INPUT      5      0&#xA;                                       4     INPUT      4      0&#xA;                                       3     INPUT      3      0&#xA;                                       2     INPUT      2      0&#xA;                                       1     INPUT      1      0&#xA;                                       0     INPUT      0      0&#xA;                   WRITEPAGE          31     VALUE      7      1&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      1&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21    IGNORE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9     VALUE      1      0&#xA;                                       8     VALUE      0      0&#xA;                                       7    IGNORE      7      0&#xA;                                       6    IGNORE      6      0&#xA;                                       5    IGNORE      5      0&#xA;                                       4    IGNORE      4      0&#xA;                                       3    IGNORE      3      0&#xA;                                       2    IGNORE      2      0&#xA;                                       1    IGNORE      1      0&#xA;                                       0    IGNORE      0      0&#xA;                                      Block Poll               Page                       Polled&#xA;               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;               flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff&#xA;                 Memory Ops:&#xA;                   Oeration     Inst Bit  Bit Type  Bitno  Value&#xA;                   -----------  --------  --------  -----  -----&#xA;                   READ_LO            31     VALUE      7      0&#xA;                                      30     VALUE      6      0&#xA;                                      29     VALUE      5      1&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20     VALUE      4      0&#xA;                                      19   ADDRESS     11      0&#xA;                                      18   ADDRESS     10      0&#xA;                                      17   ADDRESS      9      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7    OUTPUT      7      0&#xA;                                       6    OUTPUT      6      0&#xA;                                       5    OUTPUT      5      0&#xA;                                       4    OUTPUT      4      0&#xA;                                       3    OUTPUT      3      0&#xA;                                       2    OUTPUT      2      0&#xA;                                       1    OUTPUT      1      0&#xA;                                       0    OUTPUT      0      0&#xA;                   READ_HI            31     VALUE      7      0&#xA;                                      30     VALUE      6      0&#xA;                                      29     VALUE      5      1&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      1&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20     VALUE      4      0&#xA;                                      19   ADDRESS     11      0&#xA;                                      18   ADDRESS     10      0&#xA;                                      17   ADDRESS      9      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7    OUTPUT      7      0&#xA;                                       6    OUTPUT      6      0&#xA;                                       5    OUTPUT      5      0&#xA;                                       4    OUTPUT      4      0&#xA;                                       3    OUTPUT      3      0&#xA;                                       2    OUTPUT      2      0&#xA;                                       1    OUTPUT      1      0&#xA;                                       0    OUTPUT      0      0&#xA;                   LOADPAGE_LO        31     VALUE      7      0&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16    IGNORE      0      0&#xA;                                      15    IGNORE      7      0&#xA;                                      14    IGNORE      6      0&#xA;                                      13    IGNORE      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7     INPUT      7      0&#xA;                                       6     INPUT      6      0&#xA;                                       5     INPUT      5      0&#xA;                                       4     INPUT      4      0&#xA;                                       3     INPUT      3      0&#xA;                                       2     INPUT      2      0&#xA;                                       1     INPUT      1      0&#xA;                                       0     INPUT      0      0&#xA;                   LOADPAGE_HI        31     VALUE      7      0&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      1&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16    IGNORE      0      0&#xA;                                      15    IGNORE      7      0&#xA;                                      14    IGNORE      6      0&#xA;                                      13    IGNORE      5      0&#xA;                                      12   ADDRESS      4      0&#xA;                                      11   ADDRESS      3      0&#xA;                                      10   ADDRESS      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7     INPUT      7      0&#xA;                                       6     INPUT      6      0&#xA;                                       5     INPUT      5      0&#xA;                                       4     INPUT      4      0&#xA;                                       3     INPUT      3      0&#xA;                                       2     INPUT      2      0&#xA;                                       1     INPUT      1      0&#xA;                                       0     INPUT      0      0&#xA;                   WRITEPAGE          31     VALUE      7      0&#xA;                                      30     VALUE      6      1&#xA;                                      29     VALUE      5      0&#xA;                                      28     VALUE      4      0&#xA;                                      27     VALUE      3      1&#xA;                                      26     VALUE      2      1&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20     VALUE      4      0&#xA;                                      19   ADDRESS     11      0&#xA;                                      18   ADDRESS     10      0&#xA;                                      17   ADDRESS      9      0&#xA;                                      16   ADDRESS      8      0&#xA;                                      15   ADDRESS      7      0&#xA;                                      14   ADDRESS      6      0&#xA;                                      13   ADDRESS      5      0&#xA;                                      12    IGNORE      4      0&#xA;                                      11    IGNORE      3      0&#xA;                                      10    IGNORE      2      0&#xA;                                       9    IGNORE      1      0&#xA;                                       8    IGNORE      0      0&#xA;                                       7    IGNORE      7      0&#xA;                                       6    IGNORE      6      0&#xA;                                       5    IGNORE      5      0&#xA;                                       4    IGNORE      4      0&#xA;                                       3    IGNORE      3      0&#xA;                                       2    IGNORE      2      0&#xA;                                       1    IGNORE      1      0&#xA;                                       0    IGNORE      0      0&#xA;                                      Block Poll               Page                       Polled&#xA;               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;                 Memory Ops:&#xA;                   Oeration     Inst Bit  Bit Type  Bitno  Value&#xA;                   -----------  --------  --------  -----  -----&#xA;                   READ               31     VALUE      7      0&#xA;                                      30     VALUE      6      0&#xA;                                      29     VALUE      5      1&#xA;                                      28     VALUE      4      1&#xA;                                      27     VALUE      3      0&#xA;                                      26     VALUE      2      0&#xA;                                      25     VALUE      1      0&#xA;                                      24     VALUE      0      0&#xA;                                      23     VALUE      7      0&#xA;                                      22     VALUE      6      0&#xA;                                      21     VALUE      5      0&#xA;                                      20    IGNORE      4      0&#xA;                                      19    IGNORE      3      0&#xA;                                      18    IGNORE      2      0&#xA;                                      17    IGNORE      1      0&#xA;                                      16    IGNORE      0      0&#xA;                                      15    IGNORE      7      0&#xA;                                      14    IGNORE      6      0&#xA;                                      13    IGNORE      5      0&#xA;                                      12    IGNORE      4      0&#xA;                                      11    IGNORE      3      0&#xA;                                      10    IGNORE      2      0&#xA;                                       9   ADDRESS      1      0&#xA;                                       8   ADDRESS      0      0&#xA;                                       7    OUTPUT      7      0&#xA;                                       6    OUTPUT      6      0&#xA;                                       5    OUTPUT      5      0&#xA;                                       4    OUTPUT      4      0&#xA;                                       3    OUTPUT      3      0&#xA;                                       2    OUTPUT      2      0&#xA;                                       1    OUTPUT      1      0&#xA;                                       0    OUTPUT      0      0&#xA;                                      Block&#xA;&#xA;&#xA;             Programmer Type : STK500&#xA;             Description     : Atmel STK500 Version 1.x firmware&#xA;    avrdude: Send: A [41] . [80]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [02] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [81]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [01] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [82]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [12] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [98]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;             Hardware Version: 2&#xA;             Firmware Version: 1.18&#xA;             Topcard         : Unknown&#xA;    avrdude: Send: A [41] . [84]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [85]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [86]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [87]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [89]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [00] &#xA;    avrdude: Recv: . [10] &#xA;             Vtarget         : 0.0 V&#xA;             Varef           : 0.0 V&#xA;             Oscillator      : Off&#xA;             SCK period      : 0.1 us&#xA;&#xA;    avrdude: Send: A [41] . [81]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [01] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: A [41] . [82]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [12] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: B [42] . [14] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] @ [40] . [02] . [00] . [00] . [00]   [20] . [00]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: PAGEL and BS2 signals not defined in the configuration file for part ATtiny85, using dummy values&#xA;    avrdude: Send: E [45] . [05] . [04] . [d7] . [a0] . [01]   [20] &#xA;    avrdude: Recv: . [14] &#xA;    avrdude: Recv: . [10] &#xA;    avrdude: Send: P [50]   [20] &#xA;    avrdude: ser_recv(): programmer is not responding&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;zop@mikasa:~$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what else to try, so suggestions are very welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I had to strip out some of the output text because it was bigger than 30000 chars, I hope the info is good enough.&lt;/p&gt;&#xA;" OwnerUserId="7668" LastEditorUserId="7670" LastEditDate="2015-03-03T16:16:54.163" LastActivityDate="2015-03-12T08:58:47.117" Title="Attiny85 with arduino as ISP" Tags="|arduino-uno|attiny|isp|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="8992" PostTypeId="2" ParentId="4019" CreationDate="2015-03-03T16:12:32.513" Score="1" Body="&lt;h2&gt;possible problem: level mismatch&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I speculate that maybe some output on this Arduino is trying to push close to 5.0 V into your gyro, which is well outside the specifications of your gyro.&#xA;You are lucky that anything worked at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to page 12 of &lt;a href=&quot;http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf&quot; rel=&quot;nofollow&quot;&gt;the MPU-6050 gyroscope datasheet&lt;/a&gt;,&#xA;the gyroscope is designed to operate from a power supply of VDD = 2.375V to 3.46V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might think that is already taken care of by the 3.3V regulator on your breakout board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, a VDD of 3.3 also implies that the gyro expects all of its inputs to be in the range 0 V to 3.3 V, and the gyro will drive its outputs in the range 0 V to 3.3 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Page 358 of the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega32u4 datasheet&lt;/a&gt; says that the ATmega32u4 is designed work with any power supply in the range 2.7V to 5.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 3.3V regulator on the Arduino Leonardo and another one on the &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;GY-521 breakout board&lt;/a&gt;.&#xA;So the GY-521 breakout board &lt;em&gt;should&lt;/em&gt; have its VCC connected to 5V and its GND connected to the Arduino GND so that regulator can power the gyro chip with 3.3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately for you, the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo&lt;/a&gt; is designed to power the ATmega32u4 with VCC = 5.0 V.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What to do about level mismatch&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Perhaps it would work better if we connect things the way they were designed to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were you, I would try to keep signal levels within specifications by any one of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a level converter, perhaps a &lt;a href=&quot;http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&quot; rel=&quot;nofollow&quot;&gt;I2C-compatible level converter&lt;/a&gt; for each data connection between the 3.3V I/O pins of the gyro and the 5.0V I/O pins of the Arduino Leonardo. &lt;a href=&quot;http://www.adafruit.com/product/757&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt; &lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt; &lt;a href=&quot;https://www.sparkfun.com/products/11771&quot; rel=&quot;nofollow&quot;&gt;(c)&lt;/a&gt; Or,&lt;/li&gt;&#xA;&lt;li&gt;Somehow tweak the Arduino Leonardo to connect 3.3 V to the VCC pin of the ATmega32u4. (Does this require cutting traces on the PCB?). Or,&lt;/li&gt;&#xA;&lt;li&gt;Use some other Arduino configured to run the processor at 3.3V (LilyPad Arduino USB; Arduino Fio; Arduino Zero; Arduino Due; Arduino TRE; some versions of Arduino Pro Mini; some versions of Arduino Pro; etc.) or easily connected to 3.3V (LilyPad Arduino SimpleSnap;  LilyPad Arduino Simple; LilyPad Arduino; etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-03-03T16:12:32.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8993" PostTypeId="2" ParentId="4019" CreationDate="2015-03-03T17:30:28.937" Score="2" Body="&lt;h2&gt;Possible problem: pin interference&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But as soon as I connect INT to anything (pins 0 through 3), the&#xA;  sketches do not find the MPU6050 any more. (They report &quot;&quot;MPU6050&#xA;  connection failed&quot;).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Is my wiring off, or is my chip defective, and even more important,&#xA;  how could I figure that out on my own in the future? =)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I'm reading the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardPro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Leonardo&lt;/a&gt; &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt; correctly,&#xA;Arduino D0 is Rx, Arduino D1 is Tx,&#xA;Arduino D2 is the I2C_SDA, and Arduino D3 is the I2C_SCL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're already using the I2C_SDA and I2C_SCL as bidirectional I2C communication;&#xA;connecting some other output pin (such as the MPU6050 INT pin) to either of those pins is going to disrupt that communication and then things won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On most Arduinos, Serial.println() and Serial.read() and the reprogramming process use the Rx and Tx pins.&#xA;Perhaps connecting the MPU6050 INT pin to either of those pins also causes some sort of problem leading to things that don't work.&#xA;(Although the Arduino Leonardo actually uses its USB_D- and USB_D+ pins for both Serial.println() and reprogramming, so maybe it isn't really a problem for the Leonardo?).&#xA;I would avoid using those pins for anything other than serial communication, even though I'm not at all sure that would actually cause a problem on the Arduino Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The example source code says&#xA;  ... this sketch depends on the MPU-6050's INT pin being connected to&#xA;  the Arduino's external interrupt #0 pin. ...&#xA;  The example does nothing (that I can see) to configure this pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I assume you're using &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino&lt;/a&gt; , right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are configured a little differently than I/O.&#xA;(In particular, &quot;volatile&quot; is critical to getting interrupts working right).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part that configures that interrupt is in the setup() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    // ...&#xA;&#xA;        // enable Arduino interrupt detection&#xA;        Serial.println(F(&quot;Enabling interrupt detection (Arduino external interrupt 0)...&quot;));&#xA;        attachInterrupt(0, dmpDataReady, RISING);&#xA;    // ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;attachInterrupt(0, dmpDataReady, RISING)&quot; line&#xA;configures the interrupt vector table and the configuration bits so that when something drives Arduino pin D2 (i.e., external interrupt source 0) from a low to a high, no matter what the Arduino is in the middle of doing, the Arduino puts that on hold, executes the dmpDataReady() function, and then the Arduino resumes where it left off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see how that ever worked, since &quot;external interrupt 0&quot; comes from pin D2, which on the Arduino Leonardo is connected to I2C_SDA, which we're using for I2C communication, so we can't use it for watching the gyro interrupt pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since the &quot;&lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow noreferrer&quot;&gt;attachInterrupt()&lt;/a&gt;&quot; gets run long &lt;em&gt;after&lt;/em&gt; the &quot;MPU6050 connection failed&quot; message gets printed out on your screen, a software bug in how the example code uses attachInterrupt() doesn't explain why you get that &quot;fail&quot; message printed on your screen.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;what to do about pin interference&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would try either using some other pin, or try getting it to work without hooking that pin to the Arduino at all.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Using some other pin&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I would try to assign a dedicated pin on the Arduino to the MPU6050 INT pin.&#xA;Maybe D9 would work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing on the Arduino Leonardo, the interrupt should be set up something more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// warning: untested code.&#xA;#include &amp;lt;PinChangeInt.h&amp;gt;&#xA;#include &amp;lt;PinChangeIntConfig.h&amp;gt;&#xA;&#xA;// connect MPU6050 interrupt to Arduino D9&#xA;#define MPU6050_INT D9&#xA;&#xA;void setup(){&#xA;    // ...&#xA;    // pin change interrupt&#xA;    pinMode(MPU6050_INT, INPUT);&#xA;    PCintPort::attachInterrupt(MPU6050_INT, dmpDataReady, RISING);&#xA;    // ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Getting it to work without hooking INT to the Arduino&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It's not at all clear that the Arduino really &lt;em&gt;needs&lt;/em&gt; to be connected to the MPU6050 INT pin.&#xA;It appears that another option is for the Arduino to occasionally use the I2C communication to read the status of the MPU6050, which includes the current state of that pin.&#xA;That simplifies the hardware -- simply leave the MPU6050 INT pin unconnected.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="27346" LastEditDate="2019-04-21T19:45:50.827" LastActivityDate="2019-04-21T19:45:50.827" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="8994" PostTypeId="2" ParentId="8989" CreationDate="2015-03-03T17:42:17.683" Score="1" Body="&lt;p&gt;I'm not sure what a “road” condition is, so I don't know where the “after every road” points in your code are located.  However, you can write a properly-parameterized function to do tests, or a subroutine to do tests and perform actions.  Then place a function or subroutine call whereever you need to perform the test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the first 14 lines of your code (which define 14 variables that you probably should have defined as constants) could be replaced by an &lt;code&gt;enum&lt;/code&gt; statement (which defines integer constants) like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { redLed1=7, yellowLed1=6, greenLed1=5, redLed2=4, yellowLed2=3, greenLed2=2, redLed3=8, yellowLed3=9, greenLed3=10, redLed4=14, yellowLed4=15, greenLed4=16, THRESHOLD=700, soundvalue=0 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or (because &lt;code&gt;enum&lt;/code&gt; will advance by 1 unit when a value isn't specified) you could say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { greenLed2=2, yellowLed2, redLed2, greenLed1, yellowLed1, redLed1, redLed3, yellowLed3, greenLed3, redLed4=14, yellowLed4, greenLed4, THRESHOLD=700, soundvalue=0 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a short sketch like this, the compiler can detect that some of your variables actually are constants, but in general using constants as constants and variables as variables will produce smaller and safer code.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-03-03T17:42:17.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8995" PostTypeId="2" ParentId="8991" CreationDate="2015-03-03T18:02:00.430" Score="3" Body="&lt;p&gt;Your log demonstrates that &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your programmer settings were correct.&lt;/li&gt;&#xA;&lt;li&gt;You have the right sketch loaded on the Arduino&lt;/li&gt;&#xA;&lt;li&gt;You have the Arduino auto-reset properly disabled.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The failure occurs at the point at which you're trying to enter programming mode. The two most likely error sources are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your ATtiny85 is not wired up correctly (e.g. you misidentified pin 5 as pin 1, you used a wrong pin on the Arduino, you crossed two signals, etc).&lt;/li&gt;&#xA;&lt;li&gt;Your ATtiny85 is in a mode that prevents ISP reprogramming (programming the &lt;code&gt;RSTDIBL&lt;/code&gt; fuse is the toughest of these mode, but merely setting the clock source to something odd will also cause this). Does your chip have a past, or is it fresh out of the box?  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="353" LastActivityDate="2015-03-03T18:02:00.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8996" PostTypeId="1" CreationDate="2015-03-03T22:10:43.447" Score="2" ViewCount="194" Body="&lt;p&gt;Until yesterday I had 2 arduino nanos (atmega328, 16Mhz, 5V), and they worked fine,when  I changed the cable and was able to upload code to them. Then I tried to make a breadboard arduino, but my PC (win8.1) was unable to see my FDTI 232RL USB2Serial converter as a COMPORT, so I tried to download drivers but nothing worked out.Anyway I decided to reinstall windows and now one of my Nano works just fine, but the Other appears as a FT232 USB UART at the device manager,so I stepped back... Can anyone help me with that?&lt;/p&gt;&#xA;" OwnerUserId="7676" LastActivityDate="2015-03-03T22:10:43.447" Title="Device manager sees my nano as FT232 USB UART not as COM port" Tags="|arduino-nano|ide|ftdi|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="8997" PostTypeId="2" ParentId="8991" CreationDate="2015-03-04T00:44:07.183" Score="0" Body="&lt;p&gt;I spent days with exactly the same problem (well, trying to program a 328p). Then I purchased a USBISP (aka USBICSP), and all my problems went away. I got one which had a &quot;program slowly&quot; jumper - setting this jumper will do the equivalent of -b19200, but without needing to explicitly set it, so you can do it from the Arduino IDE. Just my 2c worth.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-04T00:44:07.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8998" PostTypeId="1" AcceptedAnswerId="8999" CreationDate="2015-02-24T18:48:48.107" Score="3" ViewCount="4043" Body="&lt;p&gt;Reading over the datasheet it appears the longest it can shutdown for is 8s so should I just keep a counter in the loop method that checks if it's run 38 times and then execute the code I want? Would this wakeup every 8s hurt battery life much if it's doing nothing but incrementing a counter?&lt;/p&gt;&#xA;" OwnerUserId="6544" OwnerDisplayName="Ryan Detzel" LastEditorUserId="6452" LastEditDate="2015-03-04T18:56:34.697" LastActivityDate="2015-03-07T19:34:48.503" Title="How best to power down an Arduino for ~5 minutes at a time?" Tags="|battery|sleep|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="8999" PostTypeId="2" ParentId="8998" CreationDate="2015-02-24T19:23:30.023" Score="10" Body="&lt;p&gt;Yes, if you want to wake an ATMEGA (the chip in the Arduino) spontaneously (no outside trigger) from Power Down mode at periodic intervals, the you will need to rely on an interrupt generated by the watchdog timer, which has a maxim timeout of 8s. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your goal should be to wake, increment and check the timer, and get back to sleep as quickly as possible since the amount of time you are awake will dominate your average power usage while asleep. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things to keep in mind...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The arduino uses a power regulator which always draws current. If you are going for long battery life, you will need to replace or eliminate this regulator. Much better to have an ATMEGA connected &lt;em&gt;directly&lt;/em&gt; to a battery. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn off as much of the chip as possible before going to sleep. Take a look at the power control registers. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you are not driving any unnecessary loads with the GPIO pins when sleeping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;BTW, common wisdom has been that it is best to wake up and run at as fast a clock speed as possible to get your work done and get back to sleep as quickly as possible. However, Jack Ganssle recently published an article that makes a great case for doing the opposite. You will actually get longer battery life if you wake up to a slow clock speed, since this means you can run down the battery to lower voltage (this assumes you don'y need higher voltages for some other part of your circuit). Lots of other great info for designing long running battery-powered systems here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ganssle.com/tem/tem275.html&quot;&gt;http://www.ganssle.com/tem/tem275.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another relevant article about long running Arduinos...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.openhomeautomation.net/arduino-battery/&quot;&gt;http://www.openhomeautomation.net/arduino-battery/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7859" OwnerDisplayName="bigjosh" LastActivityDate="2015-02-24T19:31:53.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9001" PostTypeId="1" CreationDate="2015-03-04T06:21:51.543" Score="2" ViewCount="534" Body="&lt;p&gt;I have connected the Ethernet Shield to the Arduino Uno Board and do get the following error when I execute the &lt;a href=&quot;http://arduino.cc/en/Tutorial/WebClient&quot; rel=&quot;nofollow&quot;&gt;WebClient&lt;/a&gt; program. Look like it's getting connected to the internet, because I am getting a response back. But, this is not the response I was expecting in the Serial console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;connecting...&#xA;connected&#xA;HTTP/1.0 302 Found&#xA;Location: http://www.google.co.in/search?q=arduino&amp;amp;gws_rd=cr&amp;amp;ei=ap_2VJL0JqW_mwWc7IG4DQ&#xA;Cache-Control: private&#xA;Content-Type: text/html; charset=UTF-8&#xA;Set-Cookie: PREF=ID=8d5e7471bdf891d2:FF=0:TM=1425448810:LM=1425448810:S=-gaX4w3RUPOn7YjK; expires=Fri, 03-Mar-2017 06:00:10 GMT; path=/; domain=.google.com&#xA;Set-Cookie: NID=67=WNjkn45lMWxFTVOlW_qv6YQonIaJjd3_Aakemy7ddZ7_JqmPgaZPv_aGdqE8OptRIeV2vrYlFZRo1us7JgmnSJlmO0mfGdSNxEckDkAsqXcL7r-S7jU04eiH_zl8Q39_; expires=Thu, 03-Sep-2015 06:00:10 GMT; path=/; domain=.google.com; HttpOnly&#xA;P3P: CP=&quot;This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&amp;amp;answer=151657 for more info.&quot;&#xA;Date: Wed, 04 Mar 2015 06:00:10 GMT&#xA;Server: gws&#xA;Content-Length: 281&#xA;X-XSS-Protection: 1; mode=block&#xA;X-Frame-Options: SAMEORIGIN&#xA;Alternate-Protocol: 80:quic,p=0.08&#xA;&#xA;&amp;lt;HTML&amp;gt;&amp;lt;HEAD&amp;gt;&amp;lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html;charset=utf-8&quot;&amp;gt;&#xA;&amp;lt;TITLE&amp;gt;302 Moved&amp;lt;/TITLE&amp;gt;&amp;lt;/HEAD&amp;gt;&amp;lt;BODY&amp;gt;&#xA;&amp;lt;H1&amp;gt;302 Moved&amp;lt;/H1&amp;gt;&#xA;The document has moved&#xA;&amp;lt;A HREF=&quot;http://www.google.co.in/search?q=arduino&amp;amp;amp;gws_rd=cr&amp;amp;amp;ei=ap_2VJL0JqW_mwWc7IG4DQ&quot;&amp;gt;here&amp;lt;/A&amp;gt;.&#xA;&amp;lt;/BODY&amp;gt;&amp;lt;/HTML&amp;gt;&#xA;&#xA;disconnecting.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7679" LastActivityDate="2015-03-04T06:21:51.543" Title="Arduino Uno WebClient program not returning the exepected output" Tags="|arduino-uno|ethernet|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9002" PostTypeId="1" CreationDate="2015-03-04T08:04:58.243" Score="0" ViewCount="1239" Body="&lt;p&gt;The code used for interfacing the gsm module with arduino for sending a message is as follows :-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// initialize the library instance&#xA;GSM gsmAccess; // include a 'true' parameter for debug enabled&#xA;GSM_SMS sms;&#xA;&#xA;// char array of the telephone number to send SMS&#xA;// change the number 1-212-555-1212 to a number&#xA;// you have access to&#xA;char remoteNumber[20]= &quot;12125551212&quot;;  &#xA;&#xA;// char array of the message&#xA;char txtMsg[200]=&quot;Test&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;  // initialize serial communications&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.println(&quot;SMS Messages Sender&quot;);&#xA;&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;&#xA;  // Start GSM shield&#xA;  // If your SIM has PIN, pass it as a parameter of begin() in quotes&#xA;  while(notConnected)&#xA;  {&#xA;    if(gsmAccess.begin(PINNUMBER)==GSM_READY)&#xA;      notConnected = false;&#xA;    else&#xA;    {&#xA;      Serial.println(&quot;Not connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;GSM initialized&quot;);&#xA;  sendSMS();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;// nothing to see here&#xA;}&#xA;&#xA;void sendSMS(){&#xA;&#xA;  Serial.print(&quot;Message to mobile number: &quot;);&#xA;  Serial.println(remoteNumber);&#xA;&#xA;  // sms text&#xA;  Serial.println(&quot;SENDING&quot;);&#xA;  Serial.println();&#xA;  Serial.println(&quot;Message:&quot;);&#xA;  Serial.println(txtMsg);&#xA;&#xA;  // send the message&#xA;  sms.beginSMS(remoteNumber);&#xA;  sms.print(txtMsg);&#xA;  sms.endSMS(); &#xA;  Serial.println(&quot;\nCOMPLETE!\n&quot;);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the error is found on the 3rd line&#xA;    GSM_SMS sms;&#xA;as GSM_SMS is not a name type.&#xA;what point am i missing here...??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you in advance. &lt;/p&gt;&#xA;" OwnerUserId="7680" LastActivityDate="2015-03-04T10:54:14.490" Title="Error while sending message using gsm sim900a module interfaced with arduino uno" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9003" PostTypeId="1" CreationDate="2015-03-04T08:10:03.020" Score="0" ViewCount="1423" Body="&lt;p&gt;I hope that this is not a silly question. I may be hoplelessly optimistic in asking, but is there any way to power &amp;amp; display information onto a LCD Display from an Arduino Uno.... Without the breadboard? I am working on a hardware project that has very strict space constraints, and the breadboard is simply not an option. &lt;/p&gt;&#xA;" OwnerUserId="7681" LastEditorUserId="42" LastEditDate="2015-03-04T09:13:27.337" LastActivityDate="2015-03-04T09:13:27.337" Title="Powering LCD Displays without a Breadboard" Tags="|lcd|hardware|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9004" PostTypeId="2" ParentId="994" CreationDate="2015-03-04T08:19:10.287" Score="-1" Body="&lt;p&gt;The noise from your joystick pots will drown out any resolution over eight bits regardless.  They were designed for the very crude game port on a pc and use a copper wiper on a slab of carbon.  Not a terrible recipe for a noise generator.   &lt;/p&gt;&#xA;" OwnerUserId="7682" LastActivityDate="2015-03-04T08:19:10.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9006" PostTypeId="2" ParentId="9003" CreationDate="2015-03-04T08:48:29.847" Score="2" Body="&lt;p&gt;I presume you're looking at &lt;a href=&quot;http://arduino.cc/en/Tutorial/LiquidCrystal&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; - the breadboard is merely a convenience, you can just hard-wire the LCD directly - most don't even come with that header plug soldered on.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-03-04T08:48:29.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9007" PostTypeId="2" ParentId="9002" CreationDate="2015-03-04T10:54:14.490" Score="1" Body="&lt;p&gt;Update your IDE software. You need IDE 1.0.4 or later. &#xA;I copied your code into my 1.0.5 IDE and compiled it without any error. So it is most probably your version of the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="1357" LastActivityDate="2015-03-04T10:54:14.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9008" PostTypeId="1" CreationDate="2015-03-04T13:20:13.423" Score="0" ViewCount="844" Body="&lt;p&gt;I use a &lt;a href=&quot;https://learn.adafruit.com/adafruit-shield-compatibility/2-dot-8-tft-touch-shield&quot; rel=&quot;nofollow&quot;&gt;2.8&quot; TFT Touch Shield v1&lt;/a&gt; and I want to read some data that were stred in sd and plot them with the tft.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the following code is ordered, to access the data. TFT freezes.... but the code's execution is continued...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    pinMode(SS, OUTPUT);&#xA;    // see if the card is present and can be initialized:&#xA;    if (!SD.begin(chipSelect)) {&#xA;       Serial.println(&quot;Card failed, or not present&quot;);&#xA;    // don't do anything more:&#xA;       while (1) ;&#xA;    }&#xA;&#xA;    Tempfile = SD.open(&quot;DATALOG.TXT&quot;,FILE_READ);&#xA;    if (! Tempfile) {&#xA;       Serial.println(&quot;error opening datalog.txt&quot;);&#xA;    // Wait forever since we cant write data&#xA;       while (1) ;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested the code on the example of the tft graphics test... and the result was a freezed tft...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried also to run the example: tftbmp but the tft remains black. Once again the code is executed in the loop as i receive results from the Serial monitor but tft is black...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use an Arduino Uno R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tip is welcomed&lt;/p&gt;&#xA;" OwnerUserId="7636" LastEditorUserId="7636" LastEditDate="2015-03-04T13:48:25.220" LastActivityDate="2022-12-30T03:05:54.253" Title="TFT and SD don't work together" Tags="|arduino-uno|shields|sd-card|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9009" PostTypeId="1" CreationDate="2015-03-04T13:29:28.957" Score="1" ViewCount="587" Body="&lt;p&gt;I want to give my project a simple web GUI to change config options. I know I could get a shield and write some horrible HTML in C but I'm wondering if there is a better way. Is there another IC I could get to help with this? What's the recommended solution for an embedded web server?&lt;/p&gt;&#xA;" OwnerUserId="6544" LastEditorUserId="10907" LastEditDate="2016-01-12T05:25:18.057" LastActivityDate="2016-01-12T05:25:18.057" Title="Web Server Options" Tags="|web-server|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9010" PostTypeId="2" ParentId="9009" CreationDate="2015-03-04T13:57:24.857" Score="0" Body="&lt;p&gt;You can buy an ethernet shield of any kind, ENC28J60, wifi module etc etc, and NOT do the html on the chip, just set it up as a server (usually specific the the shield/module you use). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can actually create a local html file on your computer, or even use any webserver on your network or even online. As long as you send the commands to the local address of your arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if your Arduino ethernet module has the IP-address: 192.168.1.123 then the following form will send a command to the arduino that you can handle in the arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;form action=&quot;http://192.168.1.123/acommand=1&quot;&amp;gt;&#xA;&amp;lt;input type=&quot;submit&quot; value=&quot;click to send command&quot;&amp;gt;&#xA;&amp;lt;/form&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you create a simple web form to send a command to the arduino you can put this page anywhere, as long as the action is pointing at your arduino IP-address. If you want to go into the whole jquery standard it might be a bit different, unsure how asyncronious submits are handled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to point out that IF you put your simple html page online you dont need to and SHOULDNT open anything in your firewall or router. The code will work as long as the device you are accessing the page from is on the same network as your arduino.&lt;/p&gt;&#xA;" OwnerUserId="1357" LastEditorUserId="6286" LastEditDate="2015-03-05T18:22:05.007" LastActivityDate="2015-03-05T18:22:05.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9011" PostTypeId="2" ParentId="4423" CreationDate="2015-03-04T14:21:31.387" Score="0" Body="&lt;p&gt;Unsure what you need help with, but this might help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe that the 28BYJ-48 has a lot more steps per rotation, around 4000 I think. I had a few problems myself getting this to work. It also has four steps to cycle through, not 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at this library which has the 28BYJ-48 set to default. &lt;a href=&quot;http://playground.arduino.cc/Main/CustomStepper&quot; rel=&quot;nofollow&quot;&gt;CustomStepper&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1357" LastActivityDate="2015-03-04T14:21:31.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9012" PostTypeId="2" ParentId="8934" CreationDate="2015-03-04T14:29:15.017" Score="3" Body="&lt;p&gt;You have to do some tweaks to the usbkeyboard libraries that comes with the IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a video tutorial, take a look at this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=ubORsI4uWuo&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo as a multimedia keyboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which uses the information from this site, if you prefer text only:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://stefanjones.ca/blog/arduino-leonardo-remote-multimedia-keys/&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo multimedia keys&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Leonardo and ProMicro both use the ATMega32u4 and should both work with theses tweaks. If you need more functionality than the ones that this tweak gives you, you have to dig down into usb descriptors on usb.org for the commands you need.&lt;/p&gt;&#xA;" OwnerUserId="1357" LastActivityDate="2015-03-04T14:29:15.017" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9013" PostTypeId="1" CreationDate="2015-03-04T14:48:53.690" Score="2" ViewCount="84" Body="&lt;p&gt;I have downloaded the arduino Environment on my windows XP and also set the driver properly.&#xA;I discovered the arduino uno device on the device manager display list disappeared whenever I unplugged the arduino UNO. I want to know if there are extra things needed to set up the device as none of my sketches has ever gotten flashed to the board.&#xA;Someone told me I need Java (Compiler and Runtime) to use arduino is this true?&#xA;I only have JVR&lt;/p&gt;&#xA;" OwnerUserId="7686" LastActivityDate="2015-03-04T14:48:53.690" Title="Arduino Requirements" Tags="|arduino-uno|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9015" PostTypeId="1" AcceptedAnswerId="34484" CreationDate="2015-03-04T15:59:03.240" Score="1" ViewCount="307" Body="&lt;p&gt;I recently bought Freescale's &lt;a href=&quot;http://uk.farnell.com/freescale-semiconductor/frdm-fxs-multi-b/dev-board-xtrinsic-sensor-kinetis/dp/2443150&quot; rel=&quot;nofollow&quot;&gt;FRDM-FXS-MULTI-B&lt;/a&gt;, and have been trying to integrate it with an Arduino UNO. The board descriptions say that it has the shield layout that matches that of an Arduino shield. So in theory, I should be able to integrate it fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem comes when I plug it in and try to program the Arduino. As soon as I plug it in, the board resets and hangs. If I try to upload a simple code (just reading the analogue signal from the light sensor), the IDE hangs when uploading. Sometimes, I can fix it by removing the shield and pressing the reset button, but sometimes that doesn't work: the computer doesn't recognise the Arduino on the port, and the IDE removes the port from the Port Selection option. When I do remove it and it resumes functioning normally, and I re-attach the shield, the board resets and hangs again, until I go into the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this board, I realised the Bluetooth module is connected to the Serial Receive pin, which explains the hang in the IDE, but I cannot understand why it resets and hangs when I plug it in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any experience with this board, and can help me out? Why can I not find any tutorials online? With the multitude of sensors on this shield, I'm guessing you can access them via normal I2C and SPI communications, right? How do you use the Bluetooth module on the board?&lt;/p&gt;&#xA;" OwnerUserId="7689" LastActivityDate="2017-02-11T17:26:11.410" Title="Integrating Freescale Multi Sensor board with Arduino" Tags="|sensors|shields|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9016" PostTypeId="2" ParentId="105" CreationDate="2015-03-04T16:57:30.200" Score="1" Body="&lt;p&gt;We know this is an open issue in Arduino programming and in the embedded world in general.&#xA;There are various solutions available on the market like MicroPython but most of them are dedicated to specific boards and don't allow to keep the system real-time.&#xA;We are working on a solution!&#xA;VIPER is a Python Virtual Machine for Arduino DUE and all ARM 32 bit architectures that runs on top of a real-time operating system.&#xA;This means that you can develop Python scripts that can be exexuted by Arduino DUE, UDOO, Spark (all boards) and also on the new ST nucleo boards.&#xA;Moreover if you need high performances and you re skilled in C you can develop real-time modules for VIPER that can be called and managed by the Python scripts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see VIPER in action here &lt;a href=&quot;http://bit.ly/kickviper&quot; rel=&quot;nofollow&quot;&gt;http://bit.ly/kickviper&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7691" LastActivityDate="2015-03-04T16:57:30.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9017" PostTypeId="1" CreationDate="2015-03-03T07:53:10.717" Score="1" ViewCount="1715" Body="&lt;p&gt;I am working on a project using my Arduino mega2560 that triggers a solenoid (maximum of three solenoids), my camera and my flash (maximum of two flashes). The core routine is there, and working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to refine this by adding a menu and 16x2 LCD with 6 buttons (up/down/left/right/select/reset). This is meant to be so the user can change the default values for:&lt;br&gt;&#xA;- the amount of solenoids to be used (max 3),&lt;br&gt;&#xA;- the amount of drops per solenoid (max 3),&lt;br&gt;&#xA;- the time between drops and&lt;br&gt;&#xA;- the time between active solenoids.&lt;br&gt;&#xA;The layout of the menu is there, but not yet coded. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array. Through the menu the default values will be presented to the user. He can accept (select button) or change the value within certain limits using the up/down buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, what is an easy (for a beginner like me) to program way to accept user input and store this in the array, overwriting the presented default value? I also would like to have the possibility for the user to back out of a menu option and leave the default setting of the specific submenu value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of creating a shadow array with blanks, to be filled in by the user and copy all the values to the array that will be used by the core routine. Another line of thinking leads me to just abandoning the array and making use of a bunch of variables. As you will probably see, I need some advice here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much for reading and your advice, happy to answer questions that may help clarify the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards, Kiezel&lt;/p&gt;&#xA;" OwnerUserId="7794" OwnerDisplayName="Kiezel" LastEditorUserId="6452" LastEditDate="2015-03-05T17:32:17.997" LastActivityDate="2015-03-05T17:32:17.997" Title="How to accept user input (array, variables,...)" Tags="|arduino-mega|lcd|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9018" PostTypeId="1" AcceptedAnswerId="9035" CreationDate="2015-03-04T18:03:40.177" Score="0" ViewCount="38026" Body="&lt;p&gt;I'm using an Arduino Uno to make a motor car. And I successfully made it move forward / backward / left / right.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void forward(void) {&#xA;  analogWrite(EA, 254); //speed 0 - 255&#xA;  analogWrite(EB, 255); //speed 0 - 255&#xA;  digitalWrite(EN2, LOW);&#xA;  digitalWrite(EN3, HIGH);&#xA;  digitalWrite(EN4, LOW);&#xA;  digitalWrite(EN5, HIGH);&#xA;}&#xA;&#xA;void backward(void) {&#xA;  analogWrite(EA, 255); //speed 0 - 255&#xA;  analogWrite(EB, 255); //speed 0 - 255&#xA;  digitalWrite(EN2, HIGH);&#xA;  digitalWrite(EN3, LOW);&#xA;  digitalWrite(EN4, HIGH);&#xA;  digitalWrite(EN5, LOW);&#xA;}&#xA;&#xA;void left(void) {&#xA;  analogWrite(EA, 180); //speed 0 - 255&#xA;  analogWrite(EB, 180); //speed 0 - 255&#xA;  digitalWrite(EN2, LOW);&#xA;  digitalWrite(EN3, HIGH);&#xA;  digitalWrite(EN4, HIGH);&#xA;  digitalWrite(EN5, LOW);&#xA;}&#xA;&#xA;void right(void) {&#xA;  analogWrite(EA, 180); //speed 0 - 255&#xA;  analogWrite(EB, 180); //speed 0 - 255&#xA;  digitalWrite(EN2, HIGH);&#xA;  digitalWrite(EN3, LOW);&#xA;  digitalWrite(EN4, LOW);&#xA;  digitalWrite(EN5, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, I found it is quite strange if I need to first press left/ right and press forward to turn around. I would like to make 4 extra buttons for left-forward / left-backward/ right-forward/ right-backward. Any ideas to create 4 extra functions for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for helping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update: Connection&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int EN2 = 14;  &#xA;int EN3 = 15;&#xA;int EN4 = 16;&#xA;int EN5 = 17;&#xA;int EA = 3;&#xA;int EB = 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update: Attempted code and hardware connection&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void left_top(void) {&#xA;  analogWrite(EA, 128); //speed 0 - 255&#xA;  analogWrite(EB, 255); //speed 0 - 255&#xA;  digitalWrite(EN2, LOW);&#xA;  digitalWrite(EN3, HIGH);&#xA;  digitalWrite(EN4, LOW);&#xA;  digitalWrite(EN5, HIGH);&#xA;}&#xA;&#xA;void right_top(void) {&#xA;  analogWrite(EA, 255); //speed 0 - 255&#xA;  analogWrite(EB, 128); //speed 0 - 255&#xA;  digitalWrite(EN2, LOW);&#xA;  digitalWrite(EN3, HIGH);&#xA;  digitalWrite(EN4, LOW);&#xA;  digitalWrite(EN5, HIGH);&#xA;}&#xA;&#xA;void left_down(void) {&#xA;  analogWrite(EA, 128); //speed 0 - 255&#xA;  analogWrite(EB, 255); //speed 0 - 255&#xA;  digitalWrite(EN2, HIGH);&#xA;  digitalWrite(EN3, LOW);&#xA;  digitalWrite(EN4, HIGH);&#xA;  digitalWrite(EN5, LOW);&#xA;}&#xA;&#xA;void right_down(void) {&#xA;  analogWrite(EA, 255); //speed 0 - 255&#xA;  analogWrite(EB, 128); //speed 0 - 255&#xA;  digitalWrite(EN2, HIGH);&#xA;  digitalWrite(EN3, LOW);&#xA;  digitalWrite(EN4, HIGH);&#xA;  digitalWrite(EN5, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Left top / right top seem not to move at all, and right top / down is just similar to right / left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And for hardware, I am using&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino  AR 293d&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6TtmL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the motor connection, it's like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/V397E.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7692" LastEditorUserId="4628" LastEditDate="2017-08-11T10:22:08.150" LastActivityDate="2017-08-11T10:22:08.150" Title="How to make the motor car move left-forward / left-backward/ right-forward/ right-backward" Tags="|arduino-uno|programming|motor|analogwrite|digital|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9019" PostTypeId="1" AcceptedAnswerId="9027" CreationDate="2015-03-04T18:12:43.590" Score="0" ViewCount="230" Body="&lt;p&gt;I am working on a communication between Android and Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Android makes a TCP connection with the board and successfully sends some strings to the board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, there is an int in my Arduino code (e.g. &lt;code&gt;int distance&lt;/code&gt;) and I would like to pass that back to my Android device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have handled the Android side already, but I do not know how to return a message from Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;in = new BufferedReader(new InputStreamReader(socket.getInputStream()));&#xA;&#xA;                //in this while the client listens for the messages sent by the server&#xA;                while (mRun) {&#xA;                    serverMessage = in.readLine();&#xA;&#xA;                    if (serverMessage != null &amp;amp;&amp;amp; mMessageListener != null) {&#xA;                        //call the method messageReceived from MyActivity class&#xA;                        mMessageListener.messageReceived(serverMessage);&#xA;                    }&#xA;                    serverMessage = null;&#xA;&#xA;                }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the Android side code but I think that it is not a specific Android problem, there should be some way for Arduino to make a response of an integer variable (without concern what is the source device)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I should do in Arduino for making that response?&lt;/p&gt;&#xA;" OwnerUserId="7692" LastEditorUserId="26916" LastEditDate="2017-11-04T08:04:15.033" LastActivityDate="2017-11-04T08:04:15.033" Title="How to return a message when calling by a TCP connection?" Tags="|arduino-uno|programming|string|networking|tcpip|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9020" PostTypeId="1" CreationDate="2015-03-04T18:47:57.023" Score="0" ViewCount="192" Body="&lt;p&gt;Flow goes something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read sensors&#xA;Send data&#xA;If send fails store the data in eeprom/flash/sd&#xA;If sent check if any previous ones have failed and send those&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is what's the best storage option to save the data? Is there an easy way to save strings or am I going to have to write it byte by byte?&lt;/p&gt;&#xA;" OwnerUserId="6544" LastActivityDate="2016-01-29T07:16:26.813" Title="Storing data (strings) if ethernet fails to send it" Tags="|ethernet|flash|eeprom|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9021" PostTypeId="1" CreationDate="2015-03-04T19:13:41.327" Score="2" ViewCount="310" Body="&lt;p&gt;I'm a new to all things electronics and I'm having trouble using a DFRobot Bluno V2 with a DFRobot Relay Shield for Arduino V2.1. For testing purposes I've done the exact same circuit as represented in this diagram:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/A2xym.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Relay_Shield_for_Arduino_V2.1_(SKU:DFR0144)#Connection_Diagram&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.dfrobot.com/wiki/index.php/Relay_Shield_for_Arduino_V2.1_(SKU:DFR0144)#Connection_Diagram&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is not working. If I send HIGH signal to D10 or press the S4 button on the shield, the circuit does not close and the LED doesn't turn on (even though the LED4 next to the relay on the shield lights up). If I do same circuit connecting the LED to D10 directly (ie., without using the relay) it works fine. I've also tested this with the other relays on the shield and the results were the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what might be the issue? What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="7694" LastEditorUserId="220" LastEditDate="2015-03-04T22:46:59.187" LastActivityDate="2015-11-17T05:40:50.907" Title="DFRobot Bluno + Relay Shield" Tags="|arduino-uno|shields|bluetooth|relay|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9022" PostTypeId="2" ParentId="8989" CreationDate="2015-03-04T19:17:12.857" Score="1" Body="&lt;p&gt;NOTE: all the code below is thrown together; it is there to show you what to do. It will probably require some fixing before it works. The intent should be clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I read in your code, mostly what you are doing is setting the traffic lights in particular combinations, several times over, with delays in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, any time you do the same thing, conceptually, several times, it should either be in a loop, or in a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, the first thing that (to me) looks like it belongs in a function is: &lt;code&gt;set all the lights in a particular pattern, and wait for a while&lt;/code&gt;. I would call this function something like &lt;code&gt;set_lights_and_delay&lt;/code&gt; (or, perhaps &lt;code&gt;setLightsAndDelay&lt;/code&gt; depending on your coding style). It would take 5 parameters: the state of each light (red, green, or yellow/red, which I would just call yellow), and the time to delay (which may be 0). In this function, you would set ALL the pins, high or low, as appropriate (since your function shouldn't assume the previous state), then delay the appropriate amount of time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum colors {yellow, red, green, yellowred};&#xA;&#xA;void loop()&#xA;{ &#xA;    set_lights_and_delay(yellow,red,red,red,5000);&#xA;    if(analogRead(A0)&amp;gt;=THRESHOLD)&#xA;    {&#xA;      set_lights_and_delay(green,red,red,red,40000);&#xA;    } else {&#xA;      set_lights_and_delay(green,red,red,yellowred,30000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and so forth (or whatever light combinations you want).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, how would you write this function? This function does the same thing for each light, so it sounds to me like you would want to make a function that takes a color, and the 3 pins to use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setLightsAndDelay(color northlight, eastlight, westlight, southlight; int delaytime)&#xA;{&#xA;    setOneLight(northlight, redLed1, yellowLed1, greenLed1);&#xA;    setOneLight(eastlight, redLed2, yellowLed2, greenLed2);&#xA;    setOneLight(westlight, redLed3, yellowLed3, greenLed3);&#xA;    setOneLight(southlight, redLed4, yellowLed4, greenLed4);&#xA;    delay(delaytime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, setOneLight is pretty simple to write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setOneLight(color thisLight; int redled, yellowled, greenled)&#xA;{&#xA;    if (thisLight==green) // always do the easiest one first.&#xA;    {&#xA;        digitalWrite(greenled,HIGH);&#xA;    } else {&#xA;        digitalWrite(greenled,LOW);&#xA;    }&#xA;&#xA;    if (thisLight==yellow) || (thislight==yellowred)&#xA;    {&#xA;        digitalWrite(yellowled,HIGH);&#xA;    } else {&#xA;        digitalWrite(yellowled,LOW);&#xA;    }&#xA;&#xA;    if (thisLight==red) || (thisLight==yellowred)&#xA;    {&#xA;        digitalWrite(redled,HIGH);&#xA;    } else {&#xA;        digitalWrite(redled,LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In practice, there would be a lot of other things I'd do: I'd put all the things I know about a single traffic light into a struct; this means I could pass the struct to a function, in one go. I'd put the four traffic lights in an array; this means I could go through them in a loop, rather than calling the same function 4 times individually (great when your city ends up with 1,000 traffic lights!). I would probably put the pattern of lights (green/30000, yellow/10000, red/30000, yellowred/10000) into an array (made a little more difficult by the sensor).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-04T19:17:12.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9023" PostTypeId="2" ParentId="3612" CreationDate="2015-03-04T19:52:45.523" Score="1" Body="&lt;p&gt;the virtual wire library has been obsoleted, and you should now use the &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/RadioHead/&quot; rel=&quot;nofollow&quot;&gt;RadioHead&lt;/a&gt; library. In this RadioHead Library, you can edit the RH_ASK.cpp file, and uncomment the #define RH_ASK_ARDUINO_USE_TIMER2 near the top. &lt;/p&gt;&#xA;" OwnerUserId="7696" LastActivityDate="2015-03-04T19:52:45.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9024" PostTypeId="1" CreationDate="2015-03-04T20:39:26.050" Score="3" ViewCount="334" Body="&lt;p&gt;&lt;strong&gt;Hello,&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Yun and I brew beer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to log the temperature of the beer at all time during the fermentation process (final stage).  This means the thermometer would have to remain in the beer during this time (10 days).  The temperature would be &amp;lt; 40 degrees Celsius (probably around the 20 degree mark).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question: What temperature sensor would be best suited to this task?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It must be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Food grade&lt;/li&gt;&#xA;&lt;li&gt;Can be used in alcohol for extended periods&lt;/li&gt;&#xA;&lt;li&gt;Can be hooked up to Arduino (i.e. add a library and ready to go)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thanks, Dan.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7623" LastActivityDate="2022-04-29T01:06:40.693" Title="Which thermometer for home brewing" Tags="|wifi|arduino-yun|temperature-sensor|datalogging|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9025" PostTypeId="2" ParentId="9020" CreationDate="2015-03-04T20:42:35.307" Score="1" Body="&lt;p&gt;In my opinion SD would be the best way because it is cheap, small, relatively fast and easily portable on a PC, using FAT (but it uses a lot of resources) or even raw; but then you have to use some more trick to get to the raw data from a OS, its not just &quot;plug n read&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SD library uses FAT under the hood, and it gives you a nice and easy interface. Just remember that SD works at 3.3V, and connecting them directly to arduino will break them fast, even if often not immediately.&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-03-04T20:42:35.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9026" PostTypeId="2" ParentId="9024" CreationDate="2015-03-04T20:55:28.370" Score="0" Body="&lt;p&gt;You are looking for a thermocouple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They need some specific chip to be read, so you'll probably want to spend a bit more and get a chip with a digital interface, there are some witch has arduino library, like MAX6675 (output at 1Hz, 0.25° precision).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this chip read &quot;C type&quot; thermocouple, you just have to find the right probe for your needing, with probably can be found in many specialized store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may even buy a normal k probe, and then wrap it up in some protective case. Obviously that case should be designed to let the heat flow easily, but without short circuiting the probe; a food plastic bag;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or just spend a little more money and buy a stainless steel probe&lt;/p&gt;&#xA;" OwnerUserId="643" LastActivityDate="2015-03-04T20:55:28.370" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9027" PostTypeId="2" ParentId="9019" CreationDate="2015-03-04T21:24:18.547" Score="1" Body="&lt;p&gt;I'm assuming that you are using an Ethernet shield, as nothing about this is stated. But solution is really similar between many network solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once a TCP connection has been established, it can be used like you would use the Serial;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you'll probably end up having something similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EthernetClient client = server.available(); //accept a new connection&#xA;if (client) { //if valid connection&#xA;  client.print(distanceValue);&#xA;  client.close(); //close connection&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;look at the &lt;a href=&quot;http://arduino.cc/en/reference/ethernet&quot; rel=&quot;nofollow&quot;&gt;official API reference&lt;/a&gt; for a more detailed list of available command.&lt;/p&gt;&#xA;" OwnerUserId="643" LastEditorUserId="972" LastEditDate="2015-03-05T18:22:20.420" LastActivityDate="2015-03-05T18:22:20.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9028" PostTypeId="2" ParentId="9017" CreationDate="2015-03-04T21:24:27.590" Score="1" Body="&lt;p&gt;Your hardware side for the user to use can be based on an ADC type keypad pictured below, this only uses one pin and is pretty reliable. Note that not all code is given or design as it would be useless for learning and I also put effort into the code this came from, logic helps with the rest of each part...&#xA;&lt;img src=&quot;https://i.stack.imgur.com/veCjf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is pretty simple:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would write a function like so~&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char keypad(int in){&#xA;&#xA;if(in &amp;lt; 949){&#xA;    if(in &amp;gt; 935){&#xA;        return 's'; //select&#xA;    }&#xA;}&#xA;&#xA;//......&#xA;&#xA;else return = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next would be the code for the menu, you could hold the default values in an array and then modify them in the code, with set positions for defaults, considering&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Example from one of my projects&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Menu levels&#xA;#define level0 0&#xA;#define level1 1&#xA;#define level2 2&#xA;//master level of current point&#xA;#define mlevel 6        &#xA;#define msub_level 7&#xA;//\\\\\\\\\\\\\\\\\\\\  &#xA;#define sub_level1 0&#xA;#define sub_level2 1&#xA;#define sub_level3 2&#xA;#define sub_level4 3&#xA;#define sub_level5 4&#xA;// default level on boot&#xA;uint8_t current_level = mlevel;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next would be to push the data to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int navigate(char key){&#xA;if(key == 'u'){&#xA;        if(current_level == mlevel){&#xA;        if(count == 3){ //roll-over&#xA;&#xA;            count = 0;&#xA;            //update LCD....&#xA;        }&#xA;        else count++;&#xA;        //update LCD....&#xA;    }&#xA;&#xA;    if(current_level == msub_level){&#xA;&#xA;        if(count == 5){//roll-over&#xA;&#xA;            count = 0;&#xA;            //update LCD....&#xA;        }&#xA;        else count++;&#xA;        //update LCD....&#xA;    }&#xA;}&#xA;&#xA;//..... other ones here&#xA;&#xA;    return count;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would use the returned count to find the relative place in your array. e.g:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int default[n] ={x,y,z,...};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;get the key &gt; put into &lt;code&gt;navigate()&lt;/code&gt; &gt; put into dafault[&lt;code&gt;count&lt;/code&gt;];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You would also change the default after&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It has been changed or,&lt;/li&gt;&#xA;&lt;li&gt;The key has been debounced, i.e. use logic to determine if the key has changed state or,&lt;/li&gt;&#xA;&lt;li&gt;The user has chosen 'accept'&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Update of the LCD can be done at the points you want it done&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2015-03-05T14:06:04.930" LastActivityDate="2015-03-05T14:06:04.930" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9029" PostTypeId="2" ParentId="9020" CreationDate="2015-03-04T22:47:12.730" Score="0" Body="&lt;p&gt;Other than SD (see @lesto's answer), you can also store the data locally on your Arduino's EEPROM. You can store a byte at a time. The amount of storage varies from chip to chip, the AtMega328p that powers Arduino UNOs has 1kb. The eeprom is persistent over resets, I suspect not if you're reprogramming it, so think how you're going to get the data off before you start storing valuable info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 1kb, size is at a premium, so you probably don't want to use text strings, just the raw data. Remember that, if your chip resets, you will lose any memory variables with info about e.g. where you're up to. I would probably include some sort of checksum of each record, to test if the data is yours or not. I would include a counter or timestamp, so when you are starting up, you can read all memory to find the newest (valid) record; the next record is one greater, and at the next memory address. When you get to the end of the memory, restart at 0. If you store a one-byte counter, a one byte checksum, and 2 bytes of data, you can store 256 records. You could mark records off as you send them, or keep a counter in memory of which ones you have already sent - if your chip is reset, it may resend old records (very rarely), which your server would need then need to handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If using eeprom, try to spread your writes - you get a certain number of writes PER MEMORY LOCATION, so if you always write to address 15, then 15 will wear out before the others. I think I saw a reference to &quot;100,000 writes&quot;, but am unable to find that now to confirm. 100,000 writes at 1 write per second to the same address will have your eeprom fail after about 27 hours; 4 writes per second spread over 1K will cause a fail after about 10 months. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test what happens when you write past the end of memory - some possible scenarios include failed write, write to a different location (e.g. trying to write to address 1024+1 will write to address 1024), not writing at all and reading it back will return 0, 255, or another number (consistent or otherwise)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/EEPROM&lt;/a&gt; on how to write to eeprom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find out how many bytes of memory your EEPROM has, use E2END. Addresses run from 0 to E2END, so E2END might be 1023 (0 to 1023=1024 bytes).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-04T22:47:12.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9030" PostTypeId="1" AcceptedAnswerId="18583" CreationDate="2015-03-04T23:12:29.703" Score="23" ViewCount="27630" Body="&lt;p&gt;What type of connector does &lt;a href=&quot;http://wiki.seeed.cc/Grove_System/&quot; rel=&quot;noreferrer&quot;&gt;GROVE&lt;/a&gt; use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interested in wiring some old sensors so they're compatible with GROVE, so I first need to identify the connector so I can buy the housing and pins to crimp. It looks to be some type of JST connector, but there are &lt;a href=&quot;http://en.wikipedia.org/wiki/JST_connector&quot; rel=&quot;noreferrer&quot;&gt;many different sizes&lt;/a&gt;, each with incompatible pitches and a lot of retailers often advertise them incorrectly. Unfortunately, I can't find any documentation of the connector on Seeedstudio's site.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="34397" LastEditDate="2018-03-11T10:03:00.307" LastActivityDate="2023-11-08T08:30:44.240" Title="What type of connector does the GROVE system use?" Tags="|sensors|pins|wires|" AnswerCount="12" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9031" PostTypeId="1" CreationDate="2015-03-04T23:44:16.710" Score="2" ViewCount="372" Body="&lt;p&gt;I am trying to connet a tri axis accelerometer LSM303DLH to arduino UNO using the libraries taken from the following links (&lt;a href=&quot;https://github.com/adafruit/Adafruit_LSM303DLHC&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_LSM303DLHC&lt;/a&gt; and/or &lt;a href=&quot;https://github.com/ryantm/LSM303DLH&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ryantm/LSM303DLH&lt;/a&gt;) but none of them work. &#xA;Using the following connection: &#xA;SCL on A5, &#xA;SDA on A4, &#xA;Vin on 5V, &#xA;Gng on Gnd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should be able to see the values of the accelerometer but the serial monitor is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried inserting a few print in the libraries to understand where the execution stops, basically after a Wire.endTrasmission() the program doesn't go forward.&#xA;How can I connect the accelerometer using I2C?&lt;/p&gt;&#xA;" OwnerUserId="7700" LastEditorUserId="7700" LastEditDate="2015-03-05T00:02:51.663" LastActivityDate="2016-07-07T15:03:00.237" Title="Interfacing accelerometer LSM303DLH with Arduino UNO using I2C" Tags="|arduino-uno|i2c|accelerometer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9032" PostTypeId="2" ParentId="105" CreationDate="2015-03-05T02:05:48.893" Score="2" Body="&lt;p&gt;Another option to consider is the &lt;a href=&quot;http://arduino.cc/en/Products/ArduinoYUN&quot; rel=&quot;nofollow&quot;&gt;Arduino Yun&lt;/a&gt;. In addition to the AVR chip which most Arduinos have, it also includes a MIPS chip running Linux. Since it's linux, you can easily run python code, and any pure-python package can be easily installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, all the interesting input/output capability is on the AVR chip, not on the MIPS chip. Projects such as Autobahn and &lt;a href=&quot;http://www.linino.org/&quot; rel=&quot;nofollow&quot;&gt;LininoIO&lt;/a&gt; solve this problem by running a special program on the AVR chip which performs I/O operations under instruction from the MIPS chip.&lt;/p&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-03-05T02:05:48.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9035" PostTypeId="2" ParentId="9018" CreationDate="2015-03-05T04:23:55.380" Score="1" Body="&lt;p&gt;Regarding the pins - I wanted to find out the physical (hardware) connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pending an updated answer I presume the EA and EB will set the speed for two motors and EN2/EN3 and EN4/EN5 control the direction of the motors. If that's the case you could make the car turn sideways but changing the speed of only one of the motors. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void forwardLeft(void) { &#xA;  analogWrite(EA,128); //speed 0 - 255&#xA;  analogWrite(EB,255); //speed 0 - 255&#xA;  digitalWrite(EN2,LOW);&#xA;  digitalWrite(EN3,HIGH);&#xA;  digitalWrite(EN4,LOW);&#xA;  digitalWrite(EN5,HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume that EA is the left motor and EB is the right motor. This will make the right one rotate twice as fast as the left one so the car should go forward, but also turn left. If you keep this running the car should end up going in a circle. By making the &lt;code&gt;128&lt;/code&gt; lower you will change how fast the car is turning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other functions should be similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Caveat emptor&lt;/strong&gt; - of course this will mean nothing if the beginning assumptions are incorrect.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;br&gt;&#xA;Can't figure out why it doesn't work without having the thing in my hands. Have not found a schematic for that board, but intuitively it should work as described above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things you can do to try to figure out - try different numbers instead of 128, the speed of the motors might not vary linearly with the voltage. What you need to obtain is to have one motor go twice as fast as the other one and in the same direction. That should turn the car around.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastEditorUserId="7699" LastEditDate="2015-03-05T22:22:04.423" LastActivityDate="2015-03-05T22:22:04.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9037" PostTypeId="2" ParentId="9030" CreationDate="2015-03-05T06:19:16.807" Score="1" Body="&lt;p&gt;It's definitely not a jst-connector - please have a look at them here &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00BB0I7V2&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Seeedstudio-20-pack-Grove-Connectors/dp/B00BB0I7V2&lt;/a&gt; (the seeed website seems to be down at the moment). I Eagle you would search for a TWIG-4P-2.0. &#xA;These guys have 4PINs which are connected to ground and VCC + the data lines depending on the sensor you want to use.&lt;/p&gt;&#xA;" OwnerUserId="6888" LastActivityDate="2015-03-05T06:19:16.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9039" PostTypeId="2" ParentId="27" CreationDate="2015-03-05T11:25:15.090" Score="16" Body="&lt;p&gt;You do not need an RTC to build a clock: the ATmega chip has all the&#xA;hardware needed to perform the duties of the RTC itself. Here is how:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get a 32768&amp;nbsp;Hz watch crystal: either buy it or disassemble an&#xA;old clock. These crystals, specifically designed for time keeping,&#xA;have an &lt;em&gt;extremely&lt;/em&gt; small temperature drift. You would also need one&#xA;of those if you wanted to use an RTC chip.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Configure the fuses of your ATmega to run off the 8&amp;nbsp;MHz RC&#xA;oscillator. This will make your &lt;code&gt;millis()&lt;/code&gt; function horribly&#xA;inaccurate, and also free the XTAL1 and XTAL2 pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect the watch crystal to the TOSC1 and TOSC2 pins. These are the&#xA;same pins as XTAL1 and XTAL2 (9 and 10 on the 328P). The different&#xA;names are used to mean different functions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Configure the Timer/Counter 2 for asynchronous operation, normal&#xA;counting mode, prescaler set to 128, and enable the timer overflow&#xA;interrupt.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now you will get a TIMER2_OVF interrupt at a very steady rate of once&#xA;per second. You only need to advance the clock display by one second in&#xA;the ISR. In between the interrupts, you can put the MCU in very deep&#xA;sleep (power-save sleep mode: nothing runs but Timer/Counter 2) and run&#xA;for years on a couple of AA cells. Unless the display is power-hungry,&#xA;obviously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did exactly this to build my &lt;a href=&quot;http://unsecure.logre.eu/wiki/Horloge_analogique_24h/en&quot;&gt;24-hour one handed wall&#xA;clock&lt;/a&gt;.&#xA;This link points now to the English translation of the original&#xA;documentation in French.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Quartz calibration&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you do not calibrate your quartz, you can expect a significant drift,&#xA;typically &lt;strong&gt;a few seconds per week&lt;/strong&gt;. The drift rate depends on the&#xA;stray capacitance of the traces that connect the crystal to the MCU. In&#xA;principle, it could be removed by adding some extra, finely tuned&#xA;capacitance. It is worth noting that you would have &lt;em&gt;the same drift&#xA;problem&lt;/em&gt; with an RTC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are satisfied with this kind of accuracy, then live with it and&#xA;be happy. However, if you care to measure the drift, you will notice&#xA;that it is very stable. You can then easily compensate for it in&#xA;software, and achieve an accuracy of &lt;strong&gt;a few seconds per year&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The algorithm for correcting the drift is very simple. From the measured&#xA;drift, you figure out the precise delay between the interrupts, which&#xA;should be very close to 10&lt;sup&gt;9&lt;/sup&gt;&amp;nbsp;nanoseconds, then:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define ONE_SECOND    1000000000  // in nanoseconds&#xA;#define ONE_INTERRUPT  999993482  // for example&#xA;&#xA;ISR(TIMER2_OVF_vect)&#xA;{&#xA;    static uint32_t unaccounted_time;&#xA;&#xA;    unaccounted_time += ONE_INTERRUPT;&#xA;    while (unaccounted_time &amp;gt;= ONE_SECOND) {&#xA;        advance_display_by_one_second();&#xA;        unaccounted_time -= ONE_SECOND;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above example, the quartz is slightly too fast, and the software&#xA;compensates by “missing” a tick every few days. If the quartz was too&#xA;slow, the same code would instead double-tick once every few days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This kind of calibration could also be done for an RTC, but it would be&#xA;significantly more complex because the RTC reports the time in a&#xA;broken-down form that does not naturally lend itself to arithmetic&#xA;operations.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-10T19:41:24.107" LastActivityDate="2015-03-10T19:41:24.107" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9044" PostTypeId="1" AcceptedAnswerId="9049" CreationDate="2015-02-20T01:42:14.743" Score="2" ViewCount="502" Body="&lt;p&gt;I have an Arduino device and I'm trying to read two voltages. The first one is the Arduino Vcc by using the bandgap value 1.1V (this requires raw access to registers since it's not implemented in analogRead). The other one is checking the battery voltage using the badgap as a reference. I want both of them because I'm doing a study on the battery life when using a step-up converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using these pieces of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Read bandgap with Vcc as reference - this will give use the Vcc&#xA;ADMUX = DEFAULT &amp;lt;&amp;lt; 6 | 14;&#xA;delayMicroseconds(250);&#xA;bitSet(ADCSRA, ADSC);&#xA;while(bit_is_set(ADCSRA, ADSC))&#xA;    ;&#xA;word x = ADC;&#xA;Serial.println(x);&#xA;&#xA;&#xA;// Read A1 with 1.1V bandgap as reference - this will give battery voltage&#xA;ADMUX = INTERNAL &amp;lt;&amp;lt; 6 | 1;&#xA;delayMicroseconds(250);&#xA;bitSet(ADCSRA, ADSC);&#xA;while(bit_is_set(ADCSRA, ADSC))&#xA;    ;&#xA;word x = ADC;&#xA;Serial.println(x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem that I have is that separately they seem to work well, however when using them together the first piece of code ruins the reading for the second one. The culprit is the line &lt;code&gt;ADMUX = DEFAULT &amp;lt;&amp;lt; 6 | 14&lt;/code&gt;. This sets up the default reference (chip voltage) and reads channel 14 (which is the 1.1V). I can't figure out why after using this line changing back with &lt;code&gt;ADMUX = INTERNAL &amp;lt;&amp;lt; 6 | 1&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="7699" OwnerDisplayName="rslite" LastEditorUserId="6452" LastEditDate="2015-03-08T14:29:52.000" LastActivityDate="2015-03-08T14:29:52.000" Title="Arduino ADC read bad value" Tags="|voltage-level|analogread|battery|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9046" PostTypeId="2" ParentId="5315" CreationDate="2015-03-05T15:32:31.280" Score="2" Body="&lt;p&gt;This a very partial answer. I do not know your requirements, whether or&#xA;not PWM can do the job, etc... I just wanted to point out that you can&#xA;make a pulse exactly 8&amp;nbsp;µs long with this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;util/delay.h&amp;gt;&#xA;#include &amp;lt;util/atomic.h&amp;gt;&#xA;&#xA;// Pulse PD3 (digital 18 on Mega 2560)&#xA;// for exactly 8 us (128 clock cycles @ 16 MHz)&#xA;static void pulse() {&#xA;    ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {&#xA;        PORTD |= 1 &amp;lt;&amp;lt; 3;&#xA;        _delay_us(8 - 0.125);&#xA;        PORTD &amp;amp;= ~(1 &amp;lt;&amp;lt; 3);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;_delay_us()&lt;/code&gt; function from avr-libc is actually cycle-accurate&#xA;inline assembly. The 0.125&amp;nbsp;µs I subtracted is the time needed by&#xA;the actual port writes: both the sbi and cbi instructions take two cycles&#xA;(0.125&amp;nbsp;µs), but that delay should only be counted once.&#xA;&lt;code&gt;digitalWrite()&lt;/code&gt; should always be avoided in time-critical code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 242&amp;nbsp;µs delay between pulses would be harder to generate without&#xA;PWM. A timer interrupt at 4&amp;nbsp;kHz seems like the simplest option, but&#xA;it is not cycle-accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: here is the scope trace, showing a quite accurate timing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ekEE.png&quot; alt=&quot;oscilloscope trace&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="27346" LastEditDate="2018-12-30T18:16:30.430" LastActivityDate="2018-12-30T18:16:30.430" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9047" PostTypeId="1" CreationDate="2015-03-05T16:14:11.697" Score="1" ViewCount="245" Body="&lt;p&gt;I have two continuous servos connected to my Uno, and I'm running this code on it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leftServo.write(91);&#xA;rightServo.write(102);&#xA;delay(3000);&#xA;&#xA;leftServo.write(112);&#xA;rightServo.write(81);&#xA;delay(3000);&#xA;&#xA;leftServo.write(91);&#xA;rightServo.write(102);&#xA;delay(3000);&#xA;&#xA;int i;&#xA;while(1) {&#xA;  i++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the code, the wheels stop for three seconds (91 and 102 are the zero values for these servos) then they spin for three seconds, then the left servo stops, but the right one only slows down about half way, it doesn't stop, even though the exact same number is used as before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out why this is?&lt;/p&gt;&#xA;" OwnerUserId="7721" LastEditorUserId="61722" LastEditDate="2022-07-06T18:01:03.023" LastActivityDate="2022-07-06T18:01:03.023" Title="Continuous servo not setting speed correctly" Tags="|arduino-uno|continuous-servo|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="9048" PostTypeId="1" CreationDate="2015-03-05T17:15:58.047" Score="-1" ViewCount="7328" Body="&lt;p&gt;Running the code below, when I send any character in the Serial arduino is not printing &quot;a&quot; back. I think it's something wrong with the timer1 code but it should work cause this code was given by my teacher in C class.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_COMPA_vect){&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(115200);&#xA;&#xA;    //http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS&#xA;    noInterrupts();&#xA;    TCCR1A = 0;// set entire TCCR1A register to 0&#xA;    TCCR1B = 0;// same for TCCR1B&#xA;    TCNT1  = 0;//initialize counter value to 0&#xA;    // set compare match register for 1000000hz increments with 8 bits prescaler&#xA;    OCR1A = 1;// = (16*10^6) / (1000000*8) - 1 (must be &amp;lt;65536)&#xA;    // turn on CTC mode&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;    // Set CS11 bit for 8 prescaler. Each timer has a different bit code to each prescaler&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; CS11);  &#xA;    // enable timer compare interrupt&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;    interrupts();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    if (Serial.available()) {&#xA;&#xA;     Serial.println(&quot;a&quot;);&#xA;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6661" LastActivityDate="2015-09-04T02:19:19.043" Title="Timer1 arduino makes Serial not work" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9049" PostTypeId="2" ParentId="9044" CreationDate="2015-03-05T17:25:33.110" Score="3" Body="&lt;p&gt;The datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The first ADC conversion result after switching reference voltage&#xA;  source may be inaccurate, and the user is advised to discard this&#xA;  result.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then you could try to take each reading twice, looping over four ADC&#xA;readings:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read bandgap with Vcc as reference, discard the value.&lt;/li&gt;&#xA;&lt;li&gt;Re-take the same, keep the value.&lt;/li&gt;&#xA;&lt;li&gt;Read A1 with 1.1V bandgap as reference, discard the value.&lt;/li&gt;&#xA;&lt;li&gt;Re-take the same, keep the value.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-03-05T17:25:33.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9051" PostTypeId="1" AcceptedAnswerId="9052" CreationDate="2015-03-05T19:07:32.147" Score="1" ViewCount="280" Body="&lt;p&gt;When compiling for Arduino via the Stino plugin line numbers are not represented correctly in the output. For example, I have an error on line 117 however the output is: &lt;code&gt;sketch_name.ino.cpp:136:1: error:&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7725" LastEditorUserId="37523" LastEditDate="2019-11-15T18:29:10.053" LastActivityDate="2019-11-15T18:29:10.053" Title="How to fix error line number offset in Sublime Text when compiling for Arduino" Tags="|debugging|gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9052" PostTypeId="2" ParentId="9051" CreationDate="2015-03-05T19:17:14.390" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;#line&lt;/code&gt; preprocessor directive&lt;/a&gt; is used to tell GCC both what the next line should be numbered as and what filename should be reported, and the plugin is not generating them properly. This is therefore a Stino bug.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-05T19:17:14.390" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9053" PostTypeId="2" ParentId="9047" CreationDate="2015-03-05T20:18:16.377" Score="2" Body="&lt;p&gt;Issue was fixed by adding a delay of 100ms between servo writes, smaller values may work, but I haven't tried yet&lt;/p&gt;&#xA;" OwnerUserId="7721" LastActivityDate="2015-03-05T20:18:16.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9055" PostTypeId="1" AcceptedAnswerId="9059" CreationDate="2015-03-05T20:35:21.740" Score="10" ViewCount="12037" Body="&lt;p&gt;Copied from the &lt;a href=&quot;http://arduino.cc/en/Reference/Millis&quot; rel=&quot;noreferrer&quot;&gt;Arduino reference - millis()&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Tip&lt;/strong&gt;: Note that the parameter for millis is an unsigned long, errors may be generated if a programmer tries to do math with other&#xA;  datatypes such as ints.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What kind of math? What kind of other type of processing is excluded while working with millis? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone clarify this statement and/or give some example? &lt;/p&gt;&#xA;" OwnerUserId="7728" OwnerDisplayName="user3060854" LastEditorUserId="6936" LastEditDate="2015-07-30T18:45:05.640" LastActivityDate="2020-05-16T17:55:42.207" Title="arduino - millis()" Tags="|millis|data-type|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9057" PostTypeId="2" ParentId="9055" CreationDate="2015-03-05T20:52:51.250" Score="2" Body="&lt;p&gt;When you want to do stuff with millis() just remember to initialize your variable with type &quot;uint32_t&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So do something like &quot;uint32_t last_millis&quot; where you will store the output of the &quot;millis()&quot; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise like the others said, it would overflow when going past 31,000 which will happen pretty quickly.&lt;/p&gt;&#xA;" OwnerUserId="7701" OwnerDisplayName="nemik" LastActivityDate="2015-03-05T20:52:51.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9058" PostTypeId="2" ParentId="9055" CreationDate="2015-03-05T21:11:52.057" Score="7" Body="&lt;p&gt;&lt;code&gt;millis()&lt;/code&gt; returns a &lt;code&gt;unsigned long&lt;/code&gt;, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like &lt;code&gt;unsigned int time = millis() - 1000&lt;/code&gt;, you try to store that in a 16-bit unsigned integer &lt;code&gt;unsigned int&lt;/code&gt;. A 16-bit integer can never hold a 32-bit value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;C specification&lt;/a&gt;, paragraph 6.3.1.3, the upper 16 bits are discarded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, keep the &lt;code&gt;millis()&lt;/code&gt; output in a &lt;code&gt;unsigned long&lt;/code&gt; and only use data types with less bits when you're absolutely sure you will not lose bits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's more information on explicit casts in C here: &lt;a href=&quot;https://stackoverflow.com/a/13652624/1544337&quot;&gt;https://stackoverflow.com/a/13652624/1544337&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6971" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-06T09:41:39.263" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9059" PostTypeId="2" ParentId="9055" CreationDate="2015-03-05T22:09:33.283" Score="8" Body="&lt;p&gt;Whenever you write an equation in C/C++, the data types being operated on have a very real effect on the equation's output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each type like &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, and &lt;code&gt;unsigned long&lt;/code&gt; have different behaviors, and take a certain amount of space in memory to store. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int&lt;/code&gt; (on arduino) is store in 16 bits, with half of its values being given to negative numbers, half-1 given to positive values, and one value given to 0. That gives it a range of -2^15 (-32,768) to +2^15-1 (32,767).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;unsigned long&lt;/code&gt; (on arduino) is 32 bits, but none are designated as negative. its range is then 0 to 2^32-1 (4294967295).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What kind of math? What kind of other type of processing is excluded&#xA;  while working with millis?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The crux of the issue is that it the time millis returns ever got past 32767 and you tried to store it in an int, the arduino couldn't do it, because an &lt;code&gt;int&lt;/code&gt; can't hold that big of a number. The type of math this is off limits is math happening to smaller data types, not any specific operations. Maybe these examples will help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int i = 32767;&#xA;  Serial.println(i);&#xA;  //No problems here; it fits just fine&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;32767&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  i = 32767 + 1;&#xA;  Serial.println(i);&#xA;  //Oh no, the value didn't fit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-32768&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  unsigned long fake_millis = 42000;&#xA;  i = fake_millis;&#xA;  Serial.println(i);&#xA;  //This is an example of millis going past an int&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-23536&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  i = -10;&#xA;  unsigned int j = i;&#xA;  Serial.println(j);&#xA;  //no way to put a negative number in an unsigned value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;65526&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  uint32_t k = fake_millis;&#xA;  Serial.println(k);&#xA;  //unsigned long is a uint32_t on arduino; this works great!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;42000&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The way this is implemented is really quite genius; If you are interested in where these numbers come from and why they spill over in the way they do you should look into same explanations of two's complement number representations.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-05T22:09:33.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9061" PostTypeId="2" ParentId="8916" CreationDate="2015-03-06T01:20:49.240" Score="2" Body="&lt;p&gt;If you want to minimize power usage, the best thing would be to start with &lt;strong&gt;devices that use more power!&lt;/strong&gt; :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's time for math! I'm going to use the &lt;a href=&quot;http://www.mouser.com/ProductDetail/STMicroelectronics/L7805CV/?qs=9NrABl3fj%2FqplZAHiYUxWg%3D%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;generic L7805CV&lt;/a&gt; 5V, 1A linear regulator. Poking in the &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000444.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;, we find that the quiescent (standby) current is max of 6 mA. I'm assuming this power drawn is 12V, not 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since a linear regulator is basically a variable resistor, we can figure out that the efficiency is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout / Vin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...thus, our efficiency in this application is...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5V / 12V = 0.416666667% efficiency&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... &lt;a href=&quot;https://electronics.stackexchange.com/a/21135/18442&quot;&gt;Read more here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, we can use the inverse of the efficiency function (&lt;code&gt;Vout / Vin&lt;/code&gt; → &lt;code&gt;Vin / Vout&lt;/code&gt;) to establish the amount of power it'll use. Final equation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Power Used (W) = (12V / 5V) * Current Draw + (0.006A * 12V)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which simplifies to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Power Used (W) = 2.4 * Current Draw + 0.072 W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, all we need to find is the power consumption of the Arduino. &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot; rel=&quot;nofollow noreferrer&quot;&gt;This forum post&lt;/a&gt; states the power consumption of different sleep modes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SLEEP_MODE_IDLE: 15 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_ADC: 6.5 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_PWR_SAVE: 1.62 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_EXT_STANDBY: 1.62 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_STANDBY : 0.84 mA&lt;/li&gt;&#xA;&lt;li&gt;SLEEP_MODE_PWR_DOWN : 0.36 mA&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Let's give the Arduino a generous 15mA to sleep:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Power Used (W) = 2.4 * 0.025 + 0.072 W = 0.132 W&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, 132 milliwatts, idle. A bit further, we can calculate that, if your wall wart has an efficiency of 10%, it will actually draw 1.32 W from your wall socket. Using a general cost per killawatt hour ($0.125), we can calculate that it will cost you about $1.45 a year for that Arduino to be ran in sleep mode 24/7 (given that we used the maximums for everything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's pretty cheap, so I wouldn't worry about that power. A good switching regulator will cost more than to run it for a few years with a linear regulator. I'd use the onboard one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to optimize things, the wall wart or the fan should be looked at first. Consider getting a switching wall wart instead; this will give you a higher return on your investment since both the fan and the logic use this.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-03-06T01:20:49.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9063" PostTypeId="1" CreationDate="2015-03-06T13:38:21.963" Score="2" ViewCount="367" Body="&lt;p&gt;hey there I'm new to arduino. I'm working on a project that needs to send an sms to get a response and forward the response to another mobile. &#xA;What is the easiest way to do so&lt;/p&gt;&#xA;" OwnerUserId="7738" LastActivityDate="2015-03-06T13:38:21.963" Title="How to forward sms using arduino uno + gsm shield" Tags="|gsm|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9064" PostTypeId="1" CreationDate="2015-03-06T15:28:08.770" Score="2" ViewCount="3317" Body="&lt;p&gt;In reading various code I stumble across symbols that seem to be the result&#xA;of #define or other macro like symbols that I cannot find just by tracking&#xA;through the code ( including its chain, if any, of includes ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone offer some reasonably simple, but complete, guidance on how the&#xA;arduino ide works with especially emphasis on automatically included files &#xA;( and their location ) and any other automagically appearing stuff.&lt;/p&gt;&#xA;" OwnerUserId="7739" LastActivityDate="2015-03-08T10:21:07.523" Title="Trying to track down macro or #define values, possibly in arduino preprocessor" Tags="|programming|ide|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9065" PostTypeId="2" ParentId="8651" CreationDate="2015-03-06T15:36:21.767" Score="2" Body="&lt;p&gt;I am just back to using the arduino after some time away and am somewhat bewildered&#xA;by similar issues and confused by different info from different sites and for different&#xA;versions of the ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have found is that if you have a sketch in a directory, then shut down the Ide you can drop .h, .cpp... files in the directory and the ide, when restarted, will open them with the sketch.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Include them by using simple quotes on the file names, no path, no angle brackets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure this is only part of the full answer, but it has gotten me started.&lt;/p&gt;&#xA;" OwnerUserId="7739" LastActivityDate="2015-03-06T15:36:21.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9066" PostTypeId="1" CreationDate="2015-03-06T15:44:12.700" Score="3" ViewCount="793" Body="&lt;p&gt;I just purchased an Adafruit Wifi Shield CC3300 and strapped it onto my Arduino Uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running this basic sketch that I found to test the functionality of the Wifi Shield: &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoWiFiShield#toc1&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Guide/ArduinoWiFiShield#toc1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course in my home I have Wifi, so I expected this sketch to show my Wifi name. However it doesn't. Instead I get this output on my serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Init...&#xA;** Scan Networks **&#xA;Initializing Wifi...&#xA;MAC: 0:0:0:0:0:0&#xA;Scanning available networks...&#xA;** Scan Networks **&#xA;number of available networks:0&#xA;Scanning available networks...&#xA;** Scan Networks **&#xA;number of available networks:0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just keeps going forever detecting zero networks.&#xA;I even took the Arduino and stood 3 feet away from my Wifi router. Still nothing.&#xA;I even tried making my cell phone a Wifi hotspot and holding it right next to the Arduino. Still nothing. And why does it say the MAC Address 0:0:0:0:0:0?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest a fix?&#xA;FYI, here is a photo of what my setup looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/STZnU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7619" LastActivityDate="2015-03-06T15:44:12.700" Title="Why won't Wifi Shield detect any networks? Even really close" Tags="|arduino-uno|wifi|adafruit|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9067" PostTypeId="1" AcceptedAnswerId="9068" CreationDate="2015-03-06T16:36:27.983" Score="2" ViewCount="2814" Body="&lt;p&gt;I want to access the following page on my local using my Arduino with ethernet shield&quot;  192.168.1.2/zombie/arduino.php.  My arduino is conencted to a PC through a router. The system keeps timing out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;byte ip[] = { 192,168,1,3 };&#xA;char server[] = &quot;192.168.1.2/zombie/arduino.php&quot;;&#xA;&#xA;EthernetClient client;&#xA;&#xA;void setup()&#xA;{&#xA;  Ethernet.begin(mac, ip);&#xA;  Serial.begin(9600);&#xA;&#xA;  delay(1000);&#xA;&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  int res = client.connect(server, 80);&#xA;&#xA;  Serial.println(res);&#xA;&#xA;  if (res) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    client.println();&#xA;  } else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.println(&quot;data:&quot;);&#xA;    Serial.println(c);&#xA;  }else{&#xA;    Serial.println(&quot;NA&quot;);&#xA;  }&#xA;&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;    for(;;)&#xA;      ;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="612" LastEditDate="2015-03-06T19:41:42.703" LastActivityDate="2015-03-06T19:41:42.703" Title="Using ethernet, how do I navigate to a page on my local server" Tags="|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9068" PostTypeId="2" ParentId="9067" CreationDate="2015-03-06T16:56:55.450" Score="1" Body="&lt;p&gt;I discovered the answer after some testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The server var:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char server[] = &quot;192.168.1.2/zombie/arduino.php&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should only contain the ip address.  So it should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte server[] = { 192,168,1,2 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The additional URL elements should be added using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;GET /zombie/arduino.php&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after a connection has been established&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final code should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;byte ip[] = { 192,168,1,3 };&#xA;byte server[] = { 192,168,1,2 };&#xA;&#xA;EthernetClient client;&#xA;&#xA;void setup()&#xA;{&#xA;  Ethernet.begin(mac, ip);&#xA;  Serial.begin(9600);&#xA;&#xA;  delay(1000);&#xA;&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  int res = client.connect(server, 80);&#xA;&#xA;  Serial.println(res);&#xA;&#xA;  if (res) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    client.println(&quot;GET /zombie/arduino.php&quot;);&#xA;    client.println();&#xA;  } else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.println(&quot;data:&quot;);&#xA;    Serial.println(c);&#xA;  }else{&#xA;    Serial.println(&quot;NA&quot;);&#xA;  }&#xA;&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;    for(;;)&#xA;      ;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-03-06T16:56:55.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9069" PostTypeId="1" CreationDate="2015-03-06T17:23:14.227" Score="3" ViewCount="28961" Body="&lt;p&gt;&lt;strong&gt;I am making a robot with arduino mega r3. I want to power the arduino with a usb power bank. How should I do that?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7740" LastActivityDate="2016-11-14T09:54:42.353" Title="Powering an Arduino Mega with external USB Power Bank?" Tags="|arduino-mega|power|usb|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9070" PostTypeId="2" ParentId="9069" CreationDate="2015-03-06T18:38:28.653" Score="0" Body="&lt;p&gt;Not clear what a usb power bank is. I assume you actually have a battery, perhaps with a regulator. The data sheet &#xA;&lt;a href=&quot;http://www.arduino.cc/en/Main/arduinoBoardMega&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/arduinoBoardMega&lt;/a&gt; at says: Microcontroller ATmega1280 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V Digital I/O Pins 54 (of which 15 provide PWM output) Analog Input Pins 16 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega can be powered via the USB connection or with an external power supply. The power source is selected automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the usb connector, use the correct pins an make sure you have it regulated to 5 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this answers the question, if not please comment.&lt;/p&gt;&#xA;" OwnerUserId="7739" LastActivityDate="2015-03-06T18:38:28.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9071" PostTypeId="1" AcceptedAnswerId="9072" CreationDate="2015-03-06T20:17:45.693" Score="5" ViewCount="28675" Body="&lt;p&gt;I want to write an Arduino program that simply recieves a string (via the I2C wire library) from a master Arduino, then waits for a request, and sends that string back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin(4); &#xA;  Wire.onReceive(receiveEvent); &#xA;  Wire.onRequest(requestEvent);&#xA;}&#xA;&#xA;String data = &quot;&quot;;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&#xA;void receiveEvent(int howMany)&#xA;{&#xA;  data = &quot;&quot;;&#xA;  while( Wire.available()){&#xA;    data += (char)Wire.read();&#xA;  }&#xA;}&#xA;&#xA;void requestEvent()&#xA;{&#xA;    Wire.write(data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I read in the API that the write() function accepts a string, but I keep getting a &quot;No matching function for call&quot; error.  I tried to simply replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.write(data);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.write(&quot;test&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that worked without error.  Why is this the case? &lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2018-08-31T19:25:34.353" Title="How do I send a string to master using i2c" Tags="|i2c|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9072" PostTypeId="2" ParentId="9071" CreationDate="2015-03-06T20:19:53.663" Score="12" Body="&lt;p&gt;&lt;code&gt;data&lt;/code&gt; is a &lt;a href=&quot;http://arduino.cc/en/Reference/StringObject&quot;&gt;&lt;code&gt;String&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;&quot;test&quot;&lt;/code&gt; is a &lt;a href=&quot;http://arduino.cc/en/Reference/string&quot;&gt;&lt;code&gt;char*&lt;/code&gt;&lt;/a&gt;. &lt;a href=&quot;http://arduino.cc/en/Reference/WireWrite&quot;&gt;&lt;code&gt;Wire.write()&lt;/code&gt;&lt;/a&gt; has no prototype that takes a &lt;code&gt;String&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.write(data.c_str());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-06T20:19:53.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9073" PostTypeId="1" AcceptedAnswerId="9079" CreationDate="2015-03-06T20:32:47.623" Score="1" ViewCount="3902" Body="&lt;p&gt;I have been working with the wire library (I2C) to send data from one Arduino to another.  I read that the Arduino can only send 6 bytes per cycle, but I have been able to transfer much larger strings.  This code works without error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Wire.beginTransmission(4); // transmit to device #4&#xA;&#xA;  for(int i = 0; i &amp;lt; 20; i ++){&#xA;    char rand = random(65, 100);&#xA;    Wire.write(rand); &#xA;  }&#xA;&#xA;  Wire.endTransmission();    // stop transmitting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How is this possible?  It seams that 32 characters can be sent without trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read this here: &lt;a href=&quot;http://arduino.cc/en/Tutorial/MasterReader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/MasterReader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino 1, the Master, is programmed to request, and then read, 6 bytes of data sent from the uniquely addressed Slave Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now that I look at this again (after reading the responses) I think that the limit was set in the code sample.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-03-07T15:36:57.757" LastActivityDate="2017-10-11T11:53:17.390" Title="How does the Arduino send more than 6 bytes via I2C" Tags="|i2c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9074" PostTypeId="1" AcceptedAnswerId="20117" CreationDate="2015-03-06T21:03:48.060" Score="2" ViewCount="300" Body="&lt;p&gt;I am making a bike alarm for my bike. I haven't started yet.&#xA;Basically, I'm thinking of a pin to be connected to the metal post (to which the bike is locked.) I want to detect if that connection (to the ground via the metal post) is broken.&#xA;Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="7743" LastActivityDate="2016-01-30T03:42:17.623" Title="Detect external ground on an input pin" Tags="|programming|pins|arduino-micro|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9077" PostTypeId="2" ParentId="9069" CreationDate="2015-03-06T23:33:50.913" Score="6" Body="&lt;p&gt;I have a &quot;USB power bank&quot; with two USB ports, which I use to power some projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have discovered that my bank (i.e. your mileage may vary!) shuts off unless my project draws at least 50mA. If your project does draw at least that at ALL times, you should just be able to plug a USB cable directly from the powerbank to the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some other projects, I have bought a USB cable (USB A to USB A) which I cut in half, stripped the wires, then used a multimeter set to &quot;Volts&quot; to work out which wire was +5V and which was GND; I connect these straight to the 5V/GND on my project. To make sure at least 50mA was drawn at all times, I put a 100 Ohm resistor from +5V to GND (at LEAST 1/4 watt!!). This obviously wastes a lot of power (turning it into 1/4 watt of heat), but it keeps the power bank &quot;awake&quot;. By using a USB A to USB A, I now have two cables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My power bank also has a &quot;torch&quot; (led) integrated; if the torch is on, it also stays awake.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-06T23:33:50.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9078" PostTypeId="2" ParentId="8651" CreationDate="2015-03-07T01:13:48.127" Score="3" Body="&lt;p&gt;The Arduino plugin for Visual Studio supports local libraries you can find the plugin &lt;a href=&quot;http://www.visualmicro.com&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-10-22T23:39:05.757" LastActivityDate="2015-10-22T23:39:05.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9079" PostTypeId="2" ParentId="9073" CreationDate="2015-03-07T02:47:49.910" Score="3" Body="&lt;p&gt;There is no reason to believe there is a 6 byte limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Arduino Reference&lt;/a&gt; makes no mention of a 6 byte limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/Wire.cpp&quot; rel=&quot;nofollow&quot;&gt;Wire.cpp&lt;/a&gt; defines 'txBuffer[BUFFER_LENGTH];' where &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/Wire.h&quot; rel=&quot;nofollow&quot;&gt;BUFFER_LENGTH = 32 (defined in Wire.h)&lt;/a&gt;. The maximum is 32 bytes, just as you noticed.&lt;/p&gt;&#xA;" OwnerUserId="7292" LastActivityDate="2015-03-07T02:47:49.910" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9080" PostTypeId="2" ParentId="1618" CreationDate="2015-03-07T07:49:57.340" Score="1" Body="&lt;p&gt;The baud rate depends on model of arduino you are using. For Pro-Micro; Pro-Mini and Nano that I use I had to change to 57600 baud as that is what the dll (downlineloader) avrdude forces this baud rate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36&#xA;     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;     Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;     System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;     Using Port                    : \\.\COM40&#xA;     Using Programmer              : arduino&#xA;     Overriding Baud Rate          : 57600&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Mega the overriding Baud Rate is 115200.&lt;/p&gt;&#xA;" OwnerUserId="7750" LastEditorUserId="220" LastEditDate="2015-03-07T14:09:23.347" LastActivityDate="2015-03-07T14:09:23.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9081" PostTypeId="2" ParentId="9064" CreationDate="2015-03-07T10:02:16.250" Score="4" Body="&lt;p&gt;It might help to point out the use of &lt;code&gt;-D&lt;/code&gt; switches of &lt;code&gt;gcc&lt;/code&gt; here.&#xA;If you turn on verbose output of the Arduino IDE (I am using a pretty old version):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/d9ZPg.png&quot; alt=&quot;Arduino IDE preferences&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you will see, when you compile a sketch, that the compiler is not only called with a switch &lt;code&gt;-m&lt;/code&gt; (e.g.  &lt;code&gt;-mmcu=atmega328p&lt;/code&gt;) which describes the target (i.e. the ATMEL AVR instruction set or MCU type) for which the code is compiled, but also with a number of &lt;code&gt;-D&lt;/code&gt; switches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;-D&lt;/code&gt; switches predefine a name as a macro and also that depend on the target. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might see for example &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DF_CPU=16000000L -DARDUINO=100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;F_CPU&lt;/code&gt; is used to pass information about the target's clock speed (16 MHz in this case) to code that depends on this, e.g. the &lt;code&gt;delay&lt;/code&gt; function or the &lt;code&gt;Serial&lt;/code&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;3 ways to define macros&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In general, the confusion might come from the fact that including files in the Arduino build chain depends a lot on compiler flags, and there are several ways to define these:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;#define&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;using &lt;code&gt;-D&lt;/code&gt; switches&lt;/li&gt;&#xA;&lt;li&gt;from the target specification (compiler built-in, &lt;code&gt;-m&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The last point means that the above mentioned &lt;code&gt;-matmega328p&lt;/code&gt; defines the macro &lt;code&gt;__AVR_ATmega328P__&lt;/code&gt; which is e.g. used in &lt;code&gt;io.h&lt;/code&gt; to include the appropriate file with pin mappings, RAM sizes etc. (Google for &lt;code&gt;avr-mcus.def&lt;/code&gt; to find a full list of these predefined macros for AVR targets.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, note that the Arduino IDE also sets include paths depending on the target. The appropriate set of pin definitions is selected by passing an include path like this to &lt;code&gt;avr-g++&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-I/usr/share/arduino/hardware/arduino/variants/standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;standard&lt;/code&gt; is replaced by &lt;code&gt;leonardo&lt;/code&gt;, &lt;code&gt;micro&lt;/code&gt;, &lt;code&gt;mega&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Short answer / summary / how to debug&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, to &lt;strong&gt;generate a list of the current &lt;code&gt;#define&lt;/code&gt; directives&lt;/strong&gt;, use the &lt;code&gt;-dM&lt;/code&gt; option like this (compiling an empty program that is specified to be C with &lt;code&gt;-x c&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo | avr-gcc -x c -E -dM -mmcu=atmega328p - | sort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change &lt;code&gt;-mmcu=atmega328p&lt;/code&gt; to your needs (you can also leave it out).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you can use the option &lt;code&gt;-g3&lt;/code&gt; to include the macro definitions in the output. Keep the intermediate files by using &lt;code&gt;-save-temps&lt;/code&gt;. You can append these to the compiler call by the IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega168 -DF_CPU=8000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /tmp/build5017602110288.tmp/SerialManual.cpp -o/tmp/build5017602110288.tmp/SerialManual.cpp.o -save-temps -g3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will create a long output file &lt;code&gt;*.ii&lt;/code&gt; (here &lt;code&gt;SerialManual.ii&lt;/code&gt;) that lists among others the &lt;code&gt;define&lt;/code&gt;s and &lt;code&gt;typedef&lt;/code&gt;s and, most importantly, &lt;strong&gt;from which files they come&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# 1 &quot;/tmp/build501760211028815624.tmp/SerialManual.cpp&quot;&#xA;# 1 &quot;/tmp/1//&quot;&#xA;# 1 &quot;&amp;lt;built-in&amp;gt;&quot;&#xA;#define __STDC__ 1&#xA;#define __cplusplus 1&#xA;#define __AVR_ATmega168__ 1&#xA;#define __CHAR16_TYPE__ short unsigned int&#xA;...&#xA;# 1 &quot;&amp;lt;command-line&amp;gt;&quot;&#xA;#define F_CPU 8000000L&#xA;#define ARDUINO 100&#xA;...&#xA;# 1 &quot;/usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/iom168.h&quot; 1 3&#xA;# 34 &quot;/usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/iom168.h&quot; 3&#xA;#define _AVR_IOM168_H_ 1&#xA;#define SPM_PAGESIZE 128&#xA;#define RAMSTART (0x100)&#xA;#define RAMEND 0x4FF&#xA;#define XRAMEND RAMEND&#xA;#define E2END 0x1FF&#xA;#define E2PAGESIZE 4&#xA;#define FLASHEND 0x3FFF&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-08T10:21:07.523" LastActivityDate="2015-03-08T10:21:07.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9082" PostTypeId="1" AcceptedAnswerId="26844" CreationDate="2015-03-07T10:39:14.627" Score="1" ViewCount="12329" Body="&lt;p&gt;We've got an Arduino KY-032 obstacle avoidance sensor, and have spent a decent time searching and researching to find a detailed data sheet/manual to figure out how it works; but there aren't any detailed information on the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZAHF0.png&quot; alt=&quot;Arduino KY-032&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the few instructions &lt;a href=&quot;https://tkkrlab.nl/wiki/Arduino_KY-032_Obstacle_avoidance_sensor_module&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; says that the potentiometers on the chip are used to adjust the distance, but I've tried all different settings and the maximum I can get is 10 centimeters. I've tried different surfaces with different reflectivity levels, but it doesn't really differ much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to increase the distance on this? Anything to do with the enable jumper?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Here's the related code to the obstacle detection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // check the network connection once every 10 seconds:&#xA;  val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val&#xA;  if(full==1 &amp;amp;&amp;amp; val==LOW) {&#xA;    Serial.print(&quot;Bin Full&quot;);&#xA;    delay(5000);&#xA;  } else {&#xA;    if (val == LOW) {&#xA;      // When the obstacle avoidance sensor detects a signal, LED flashes&#xA;      digitalWrite (Led, HIGH);&#xA;      delay(2000);&#xA;      if(digitalRead(buttonpin)==LOW) {&#xA;        delay(2000);&#xA;        if(digitalRead(buttonpin)==LOW) {&#xA;          full = 1;&#xA;        }&#xA;      }&#xA;      count++;&#xA;      //printCurrentNet();&#xA;      sendData();&#xA;    } else {&#xA;      digitalWrite (Led, LOW);&#xA;      if(full==1) {&#xA;          count = 0;&#xA;      }&#xA;      full = 0;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7752" LastEditorUserId="4628" LastEditDate="2017-12-28T06:49:31.903" LastActivityDate="2020-12-22T00:14:23.210" Title="How to increase the detection distance on Arduino KY-032 obstacle Avoidance sensor?" Tags="|sensors|ir|proximity|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9083" PostTypeId="1" AcceptedAnswerId="9090" CreationDate="2015-03-07T11:10:52.217" Score="0" ViewCount="300" Body="&lt;p&gt;Before going in details I need to say I am trying to program Arduino Nano board with atmega328p.&#xA;Here is my code in Atmel Studio;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;int received;&#xA;int pinState = 0;&#xA;&#xA;ISR(USART_RX_vect)&#xA;{&#xA;    //cli();&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0))){};&#xA;     //clear the USART interrupt  &#xA;    received = UDR0;&#xA;    UDR0 = received;&#xA;    //sei();&#xA;}&#xA;&#xA;int main(void)&#xA;{&#xA;    //DDRB |= (1 &amp;lt;&amp;lt; PORTB3);&#xA;    //DDRD |= (1 &amp;lt;&amp;lt; PORTD3);&#xA;&#xA;    DDRD = 0xFF;&#xA;    DDRB= 0xFF;&#xA;&#xA;    #define F_CPU 16000000&#xA;&#xA;    TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;    TCCR2B = _BV(CS22);&#xA;&#xA;    TCCR0A |= _BV(WGM00) | _BV(WGM01) | _BV(COM0A1);&#xA;    TCCR0B |= _BV(CS02);&#xA;&#xA;    #define USART_BAUDRATE 9600&#xA;    #define UBRR_VALUE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)&#xA;    UBRR0H = (uint8_t)(UBRR_VALUE&amp;gt;&amp;gt;8);&#xA;    UBRR0L = (uint8_t)UBRR_VALUE;&#xA;    UCSR0B |= (1 &amp;lt;&amp;lt; RXEN0) | (1 &amp;lt;&amp;lt; TXEN0) | (1 &amp;lt;&amp;lt; RXCIE0);   // Turn on the transmission, reception, and Receive interrupt&#xA;    UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;    //DDRB |= (1 &amp;lt;&amp;lt; DDB1)|(1 &amp;lt;&amp;lt; DDB2);&#xA;&#xA;    sei();&#xA;        while(1)&#xA;    {&#xA;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the code in Arduino IDE;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;int received;&#xA;int pinState = 0;&#xA;ISR(USART_RX_vect)&#xA;{&#xA;    //cli();&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0))){};&#xA;     //clear the USART interrupt  &#xA;    received = UDR0;&#xA;    UDR0 = received;&#xA;    //sei();&#xA;}&#xA;void setup() {&#xA; DDRD = 0xFF;&#xA;    DDRB= 0xFF;&#xA;&#xA;    #define F_CPU 16000000&#xA;&#xA;    TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;    TCCR2B = _BV(CS22);&#xA;&#xA;    TCCR0A |= _BV(WGM00) | _BV(WGM01) | _BV(COM0A1);&#xA;    TCCR0B |= _BV(CS02);&#xA;&#xA;    #define USART_BAUDRATE 9600&#xA;    #define UBRR_VALUE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)&#xA;    UBRR0H = (uint8_t)(UBRR_VALUE&amp;gt;&amp;gt;8);&#xA;    UBRR0L = (uint8_t)UBRR_VALUE;&#xA;    UCSR0B |= (1 &amp;lt;&amp;lt; RXEN0) | (1 &amp;lt;&amp;lt; TXEN0) | (1 &amp;lt;&amp;lt; RXCIE0);   // Turn on the transmission, reception, and Receive interrupt&#xA;    UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;    //DDRB |= (1 &amp;lt;&amp;lt; DDB1)|(1 &amp;lt;&amp;lt; DDB2);&#xA;&#xA;    sei();&#xA;}&#xA;&#xA;void loop() {&#xA;           // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see these codes are exactly the same (except the setup-loop format)&#xA;Now I am using exact same parameters for AVRdude;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;-CF:\arduino-1.0.6\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\.\COM9 -b57600 -D -Uflash:w:&lt;/strong&gt; and following the hex file that is created after compile. But when I examine the verbose output of avrdude.exe they are different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino program works but the program uploaded using Atmel Studio does not. For more information everything about avrdude and parameters are working and it uploads and doesnt give any errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I chose atmega328p in Atmel Studio which is correct because I am using arduino nano board.&lt;/p&gt;&#xA;" OwnerUserId="6994" LastActivityDate="2015-03-07T16:46:06.673" Title="Atmel Studio and Arduino IDE compiles the same code different" Tags="|arduino-nano|avrdude|atmel-studio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9084" PostTypeId="1" CreationDate="2015-03-07T11:40:47.577" Score="0" ViewCount="1425" Body="&lt;p&gt;I am starting simple, but for some reason I cannot find any examples online and I stuck with my task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a usb midi keyboard, Arduino Yun, and a synthesiser that can accept midi via usb. The problem is that the synth doesn't send a voltage through its usb and the keyboard has only one usb that is used to send midi data and it's powered via it at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to use my Yun's USB host (which sends voltage too) to power my midi keyboard and grab all incoming midi data from the keyboard, then simply pass it unchanged through to my synth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where do I start? Do I need some python code for it or everything can be done with sketch code? I've done few arduino projects but I am new to usb host functionality  . This is my first step, later I would like to also convert usb-midi to 5-din-midi (old school connection), but that's different story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you guys help me and point into the right direction? Anyone done something similar on Yun? I've seen some examples done on different boards, but it's all overcomplicated, I need simple read/pass usb solution. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="939" LastActivityDate="2016-02-02T15:53:15.567" Title="Arduino Yun USB host - reading usb MIDI data and passing forward to another device" Tags="|arduino-yun|usb|midi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9085" PostTypeId="2" ParentId="6472" CreationDate="2015-03-07T13:31:06.790" Score="2" Body="&lt;p&gt;As far as I can understand, you expect to receive byte data from the RFID reader, you would like to store this data into a single variable, and eventually print its content, or manipulate it in some way. You could do this maintaining a byte array (or uint8_t array).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's suppose, for example, to receive a unique ID of length 4 from the RFID reader. In this case you could simply store it into a &lt;strong&gt;serNum[serNum_size]&lt;/strong&gt; array, where &lt;strong&gt;serNum_size&lt;/strong&gt; is just the number of data you are expecting to receive, and later access its content for whatever manipulation you would like to do.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int serNum_size = 4;        // reader data size&#xA;byte serNum[serNum_size];   // reader data content&#xA;&#xA;for(int i = 0; i &amp;lt; serNum_size; i++){&#xA; serNum[i] = mfrc522.uid.uidByte[i]; // store reader data block&#xA; Serial.print(serNum[i], HEX);       // hexadecimal form&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as the print is concerned, you can simply print the byte entry and apply the HEX format. In this way, the stored value will be considered as its hexadecimal value.&lt;/p&gt;&#xA;" OwnerUserId="7741" LastEditorUserId="7741" LastEditDate="2015-03-07T16:46:46.217" LastActivityDate="2015-03-07T16:46:46.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9086" PostTypeId="2" ParentId="9084" CreationDate="2015-03-07T13:34:54.390" Score="1" Body="&lt;p&gt;You need the USB Audio kernel driver and the &lt;code&gt;aconnect&lt;/code&gt; utility:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ opkg update&#xA;$ opkg install kmod-usb-audio&#xA;$ opkg install alsa-utils-aconnect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just connect the ports:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ aconnect -lio&#xA;client 0: 'System' [type=kernel]&#xA;    0 'Timer           '&#xA;    1 'Announce        '&#xA;client 14: 'Midi Through' [type=kernel]&#xA;    0 'Midi Through Port-0'&#xA;client 40: 'SC-8820' [type=kernel]&#xA;    0 'SC-8820 Part A  '&#xA;    1 'SC-8820 Part B  '&#xA;    2 'SC-8820 MIDI    '&#xA;client 44: 'My Little Keyboard' [type=kernel]&#xA;    0 'My Little Keyboard MIDI 1'&#xA;$ aconnect &quot;My Little Keyboard&quot; SC-8820&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(This is plain Linux and does not need to run anything on the ATmega.)&lt;/p&gt;&#xA;" OwnerUserId="6802" LastEditorUserId="6802" LastEditDate="2015-03-09T10:02:24.430" LastActivityDate="2015-03-09T10:02:24.430" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9087" PostTypeId="1" CreationDate="2015-03-07T13:50:27.977" Score="0" ViewCount="597" Body="&lt;p&gt;I am trying to send analog data, from a LM35, using an XBee (series 1 - XB24).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Transmitting Module: XBee with USB explorer+Arduino+LM35 (temperature sensor)&lt;/li&gt;&#xA;&lt;li&gt;Receiving Module: XBee with XBee shield+Arduino&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I read analog data using the Arduino and send it through the XBee in the USB explorer, then the receiving XBee module receives it and shows it in the serial monitor of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried many ways but I can't reach it and I have figured out that my problem lies in the Arduino code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, please can anyone help with some demo code for this project?&lt;/p&gt;&#xA;" OwnerUserId="7756" LastEditorUserId="6936" LastEditDate="2016-01-03T16:44:09.440" LastActivityDate="2016-01-03T16:44:09.440" Title="Arduino code for XBee" Tags="|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9088" PostTypeId="2" ParentId="8750" CreationDate="2015-03-07T14:20:11.257" Score="2" Body="&lt;p&gt;As mentioned in the comments, a Raspberry Pi would be superior here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard AVR (not Due/Galileo/Yun) Arduino is superior to the Pi in only one area: IO. It has a 5V logic that's more compatible than the Pi's 3.3V (although you can use a &lt;em&gt;logic level shifter&lt;/em&gt;). The Arduino also features more PWM pins and an ADC, along with interrupts. An Arduino also is a lot simpler to use for basic projects, but it becomes impractical when you need more computing power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Pi excels at the data-crunching side of things. It can handle a lot more data than the Arduino could ever dream of, and then some! Just to put things in perspective, the Pi has a clock speed of 700 MHz by default and the Arduino Uno has one of 16 MHz (with a less powerful architecture).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your purpose, the Pi's audio jack and ethernet port are unmatched on the Arduino. &lt;em&gt;Sure&lt;/em&gt;, you can get shields that replicate these behaviors, but the Pi's built in functionality doesn't cost extra and it's more powerful.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-07T14:20:11.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9089" PostTypeId="1" AcceptedAnswerId="9091" CreationDate="2015-03-07T14:50:07.447" Score="0" ViewCount="2274" Body="&lt;p&gt;For my project, I have 3 ultrasonic sensors and 3 vibrating motors; the motors need to buzz for a small amount of time, then wait for a specific time that corresponds whith the range of the ultrasonic sensor, then muzz again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having is that I used delays at first but that would cause the third motor only to buzz after the first two already waited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I basically need something like &quot;digitalWrite(motorPin_1, HIGH) for X amount of time;&quot;&#xA;and at the same moment it has to start &quot;digitalWrite(motorPin_2, HIGH) for X amount of time;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly I can't get the motors to vibrate any softer or harder, so I use these intervals.&lt;/p&gt;&#xA;" OwnerUserId="7758" LastEditorUserId="84" LastEditDate="2015-03-07T18:57:32.280" LastActivityDate="2015-03-07T19:08:28.137" Title="Vibrating motors with different intervals" Tags="|programming|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9090" PostTypeId="2" ParentId="9083" CreationDate="2015-03-07T16:46:06.673" Score="1" Body="&lt;p&gt;I found the solution (or what the problem is). Avrdude not only requires MCU model but also programmer parameter. If you are using any of Arduino based boards you need to add &lt;strong&gt;-c programmer id&lt;/strong&gt; do avrdude input parameters.&lt;/p&gt;&#xA;" OwnerUserId="6994" LastActivityDate="2015-03-07T16:46:06.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9091" PostTypeId="2" ParentId="9089" CreationDate="2015-03-07T18:08:37.420" Score="0" Body="&lt;p&gt;Like Edgar commented, you need to check out Blink Without Delay (&lt;a href=&quot;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt;). Learn what they are doing and you will get this just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I recommend you learn to use libraries. This library can do exactly what you are asking for: &lt;a href=&quot;http://playground.arduino.cc/Main/LibraryList#Timing&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/LibraryList#Timing&lt;/a&gt; --&gt; click on the &quot;Timer&quot; library by Simon Monk &amp;amp; J Christensen. Follow the examples there. This library works great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a complete set of code to answer your question. It should work perfectly for you. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;buzz3Motors.ino&#xA;By Gabriel Staples&#xA;http://electricrcaircraftguy.blogspot.com/&#xA;7 March 2015&#xA;&#xA;To help this person here: http://arduino.stackexchange.com/questions/9089/vibriting-motors-with-different-intervals&#xA;*/&#xA;&#xA;#include &quot;Timer.h&quot;&#xA;&#xA;Timer t;&#xA;&#xA;boolean buzzMotor1Now = false, buzzMotor2Now = false, buzzMotor3Now = false;&#xA;unsigned int buzzTime = 1000; //ms&#xA;byte buzzPin1 = 11;&#xA;byte buzzPin2 = 12;&#xA;byte buzzPin3 = 13;&#xA;&#xA;void setup()&#xA;{&#xA;  //set pins to outputs&#xA;  pinMode(buzzPin1, OUTPUT);&#xA;  pinMode(buzzPin2, OUTPUT);&#xA;  pinMode(buzzPin3, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  //UPDATE YOUR BUZZMOTOR BOOLEANS HERE, and set to true if necessary&#xA;&#xA;&#xA;  /**&#xA;   * This method will generate a pulse of pulseValue, starting immediately and of&#xA;   * length period. The pin will be left in the !pulseValue state&#xA;   */&#xA;  //Function format: int8_t pulseImmediate(uint8_t pin, unsigned long period, uint8_t pulseValue);&#xA;  //see here: https://github.com/JChristensen/Timer/blob/master/Timer.h&#xA;&#xA;  if (buzzMotor1Now==true)&#xA;  {&#xA;    buzzMotor1Now = false; //reset&#xA;    t.pulseImmediate(buzzPin1,buzzTime,HIGH);&#xA;  }&#xA;  if (buzzMotor2Now==true)&#xA;  {&#xA;    buzzMotor2Now = false; //reset&#xA;    t.pulseImmediate(buzzPin2,buzzTime,HIGH);&#xA;  }&#xA;  if (buzzMotor3Now==true)&#xA;  {&#xA;    buzzMotor3Now = false; //reset&#xA;    t.pulseImmediate(buzzPin3,buzzTime,HIGH);&#xA;  }&#xA;&#xA;  t.update(); //update all timer events&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that only 10 timer events can be ongoing at any given time. If you want to have more you must increase the MAX_NUMBER_OF_EVENTS value in the Timer.h (&lt;a href=&quot;https://github.com/JChristensen/Timer/blob/master/Timer.h&quot; rel=&quot;nofollow&quot;&gt;https://github.com/JChristensen/Timer/blob/master/Timer.h&lt;/a&gt;) file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. Also look into the &quot;oscillate&quot;, &quot;after&quot;, &quot;every&quot;, and &quot;pulse&quot; functions, that the library also supports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If this answer meets your needs please mark the green check beside it to indicate accepted answer. Thanks.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="7727" LastEditDate="2015-03-07T19:08:28.137" LastActivityDate="2015-03-07T19:08:28.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9092" PostTypeId="1" AcceptedAnswerId="9094" CreationDate="2015-03-07T19:01:25.357" Score="1" ViewCount="1413" Body="&lt;p&gt;I have a C++ class constructor like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Motors(int p1=0, int p2=0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I attempt to instantiate it with &lt;a href=&quot;http://en.wikipedia.org/wiki/Named_parameter&quot; rel=&quot;nofollow&quot;&gt;named parameters&lt;/a&gt; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Motors motors(p1=123, p2=456);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the Arduino C/C++ compiler gives me the errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src/motors.ino:3: error: ‘p1’ was not declared in this scope&#xA;src/motors.ino:3: error: ‘p2’ was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The compiler doesn't seem to support named parameters and thinks I'm referring to variables. I thought named parameters was a pretty widely supported feature, even in C++. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-03-08T12:50:38.050" Title="How do you call a class method with named parameters?" Tags="|c++|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9093" PostTypeId="2" ParentId="9048" CreationDate="2015-03-07T19:17:08.423" Score="2" Body="&lt;p&gt;This is a more complicated question than the standard Arduino questions, so I took a lot of time to look into it and find out the exact answer--since I was also curious. &lt;strong&gt;I have posted a very thorough answer to your question here on Stack Exchange, so please look there: &lt;a href=&quot;https://stackoverflow.com/questions/28880226/timer1-arduino-makes-serial-not-work/28887781#28887781&quot;&gt;https://stackoverflow.com/questions/28880226/timer1-arduino-makes-serial-not-work/28887781#28887781&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also note that Gerben's comment is spot-on. I recommend a value no less than 20, since you configured the counter to increment once per 0.5us. This way, a value of 20 only calls the ISR every 10us, which should keep the ISR from occurring so often that it locks up your code.  As you'll see in my link above, the other main problem is you forgot to define your ISR function that is required when you enable the interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If this meets your needs, please put a green check next to my answer to mark it as correct.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-07T19:17:08.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9094" PostTypeId="2" ParentId="9092" CreationDate="2015-03-07T19:17:54.647" Score="5" Body="&lt;p&gt;C++ doesn't support named parameters, and I doubt it ever will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has strict calling conventions which mean you couldn't re-order the parameters at call-time without adding an unnecessary layer of data duplication/indirection (which would hurt performance). It would also need a significant change to compiler architecture, as variable/parameter names are usually stripped out long before the linker is invoked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to achieve a similar effect though, you could use comment blocks instead, e.g.:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Motors motors(/*p1*/ 123, /*p2*/ 456);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T12:50:38.050" LastActivityDate="2015-03-08T12:50:38.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9095" PostTypeId="1" CreationDate="2015-03-07T19:32:36.437" Score="3" ViewCount="34392" Body="&lt;p&gt;I tried to upload example code form arduino software and got error below. Two arduino attach with my computer running windows8.1. And These arduino using port 3 and port 4. The arduino using Port 3 is cordinator and arduino using port 4 is router.&#xA;I doesn't understand why error show COM1 is not available. I am not using COM1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.0 (Windows 8), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;&#xA;C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM1 -b115200 -D -Uflash:w:C:\Users\Jiya\AppData\Local\Temp\build1135139715306090793.tmp/Blink.cpp.hex:i &#xA;&#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr  3 2014 at 23:12:16&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM1&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: ser_open(): can't open device &quot;\\.\COM1&quot;: The system cannot find the file specified.&#xA;&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&#xA;Board at COM1 is not available&#xA;Board at COM1 is not available&#xA;Board at COM1 is not available&#xA;Board at COM1 is not available&#xA;Board at COM1 is not available&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7759" LastEditorUserId="42" LastEditDate="2015-03-09T16:33:26.193" LastActivityDate="2019-05-12T21:09:52.013" Title="Problem to upload code" Tags="|arduino-uno|uploading|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9096" PostTypeId="2" ParentId="8998" CreationDate="2015-03-07T19:34:48.503" Score="1" Body="&lt;p&gt;Looks like you've got some great answers already. For a great deal more info and details on the matter, check out what Nick Gammon has written here too: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11497&lt;/a&gt; - Power saving techniques for microprocessors&lt;/p&gt;&#xA;" OwnerUserId="7727" LastActivityDate="2015-03-07T19:34:48.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9098" PostTypeId="2" ParentId="8782" CreationDate="2015-03-07T20:05:05.930" Score="0" Body="&lt;p&gt;For more help and info, and many examples of various detailed aspects of timers, check out Nick Gammon's articles here: &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/interrupts&lt;/a&gt;&#xA;and here: &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/timers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under the first link, do a search for &lt;strong&gt;&quot;The sketch below times intervals between RISING interrupts,&quot;&lt;/strong&gt; for example, to find one code segment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now, important question: what is the minimum time you need to measure between events?&lt;/strong&gt;  Are we talking milliseconds, microseconds, or nanoseconds?  For the former, you can use pin polling, external interrupts, or pin change interrupts, and the millis() or micros() Arduino functions to grab timestamps. For microseconds resolution, it depends. Even the micros() function only has a 4us resolution, so you'd have to custom-configure the timer if you want better than 4us resolution time-stamps, or you could use the timer2_counter library (&lt;a href=&quot;http://electricrcaircraftguy.blogspot.com/2014/02/Timer2Counter-more-precise-Arduino-micros-function.html&quot; rel=&quot;nofollow&quot;&gt;http://electricrcaircraftguy.blogspot.com/2014/02/Timer2Counter-more-precise-Arduino-micros-function.html&lt;/a&gt;), or your own custom timer solution, for 0.5us resolution timestamps.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For nanosecond resolution (down to 62.5ns time steps), youd prob. need to use Timer1's input capture, as the other answer shows. You can also do a search for &lt;strong&gt;&quot;Timing an interval using the input capture unit&quot;&lt;/strong&gt; under the 2nd link above, for another code segment on that.&lt;/p&gt;&#xA;" OwnerUserId="7727" LastActivityDate="2015-03-07T20:05:05.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9099" PostTypeId="1" AcceptedAnswerId="9110" CreationDate="2015-03-07T21:45:38.540" Score="1" ViewCount="109" Body="&lt;p&gt;I am trying to build a random horoscope printer. I have a series of strings in an array which I am storing in program memory. I then pick a random number and print that index concatenated with a title. But it often (but not always) only runs 4 or 5 times.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;const char string_0[] PROGMEM = &quot;You have a great need for other people to like and admire you. &quot;;&#xA;const char string_1[] PROGMEM = &quot;You have a tendency to be critical of yourself. &quot;;&#xA;const char string_2[] PROGMEM = &quot;You have a great deal of unused capacity which you have not turned to your advantage. &quot;;&#xA;const char string_3[] PROGMEM = &quot;While you have some personality weaknesses, you are generally able to compensate for them. &quot;;&#xA;const char string_4[] PROGMEM = &quot;Your sexual adjustment has presented problems for you. &quot;;&#xA;const char string_5[] PROGMEM = &quot;Disciplined and self-controlled outside, you tend to be worrisome and insecure inside. &quot;;&#xA;const char string_6[] PROGMEM = &quot;At times you have serious doubts as to whether you have made the right decision or done the right thing. &quot;;&#xA;const char string_7[] PROGMEM = &quot;You prefer a certain amount of change and variety and become dissatisfied when hemmed in by restrictions and limitations. &quot;;&#xA;const char string_8[] PROGMEM =  &quot;You pride yourself as an independent thinker and do not accept others' statements without satisfactory proof. &quot;;&#xA;const char string_9[] PROGMEM = &quot;You have found it unwise to be too frank in revealing yourself to others. &quot;;&#xA;const char string_10[] PROGMEM = &quot;At times you are extroverted, affable, sociable, while at other times you are introverted, wary, reserved. &quot;;&#xA;const char string_11[] PROGMEM = &quot;Some of your aspirations tend to be pretty unrealistic. &quot;;&#xA;const char string_12[] PROGMEM = &quot;Security is one of your major goals in life. &quot;;&#xA;&#xA;const char* const string_table[] PROGMEM = {string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10, string_11, string_12};&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); &#xA;  randomSeed(analogRead(2));   &#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;WE GOING TO LOOP NOW&quot;);&#xA;    char buffer[50];&#xA;    int rand = random(0,12);&#xA;    Serial.println(rand);&#xA;    strcpy_P(buffer, (char*)pgm_read_word(&amp;amp;(string_table[rand]))); // Necessary casts and dereferencing, just copy.&#xA;    char text[15] = &quot;Your horoscope&quot;;&#xA;    String output;&#xA;    output = strcat(text, buffer);&#xA;    Serial.println(output);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also sometimes don't seem to get very clean results, but I'm not sure why. I.e. printing WWWW... and missing the first part of the string in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWE GWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWE GOING TO LOOP NOW&#xA;1&#xA;Your horoscopeYou have a tendency to be critical of yourself. &#xA;WE GOING TO LOOP NOW&#xA;3&#xA;or them. While you have some personality weaknesses, you are generally able to compensate for them. &#xA;WE GOING TO LOOP NOW&#xA;4&#xA;Your horoscopeYour sexual adjustment has presented problems for you. &#xA;WE GOING TO LOOP NOW&#xA;2&#xA;ge. You have a great deal of unused capacity which you have not turned to your advantage. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4446" LastActivityDate="2015-03-08T10:43:11.600" Title="Sketch stops printing after writing a few times" Tags="|progmem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9100" PostTypeId="1" CreationDate="2015-03-07T22:36:12.973" Score="0" ViewCount="2026" Body="&lt;p&gt;I am using an Arduino Mega and I would like to connect a rc52 RFID reader and a network shield.  My problem is that both are set to use the same set of pins: 50 - 53.  Can I redefine the pins used so that I can use both at the same time?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2023-08-28T20:57:29.640" Title="Use an ethernet shield and RFID rc522 together on a mega?" Tags="|arduino-mega|ethernet|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9101" PostTypeId="2" ParentId="4194" CreationDate="2015-03-07T23:20:19.420" Score="5" Body="&lt;p&gt;The teensy series from pjrc.com allows USB MIDI natively (full USB speed!).  It works well and does not require any firmware tomfoolery.  It can also do HID keyboard/mouse/joystick natively as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's the 2.0, which is 32u4, and the 2.0++ which has more pins and memory.  If you want to step off the Atmel reservation the teensy 3.0 and 3.1 have more speed and memory; in a couple of weeks they are coming out with a Teensy LC which is a 3 with less bells and whistles for cheaper.&lt;/p&gt;&#xA;" OwnerUserId="7760" LastActivityDate="2015-03-07T23:20:19.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9103" PostTypeId="1" CreationDate="2015-03-08T00:20:36.353" Score="2" ViewCount="666" Body="&lt;p&gt;I am trying to create a server - node connection with NRF24L01+ chip and Mirf library with interrupts. It seem to work, but server does not seem to get reply from node. If I put it in the loop it receives. Can you check what is wrong with my code?&#xA;Server:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;&#xA;typedef struct{&#xA;  long int packet;&#xA;  byte address[5];&#xA;}&#xA;Test;&#xA;Test Toolkit;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Configuring NRF24L01+ module ...&quot;);&#xA;  Mirf.cePin = 9;&#xA;  Mirf.csnPin = 10;&#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;&#xA;  Mirf.init();&#xA;  Mirf.setRADDR((byte *)&quot;clie1&quot;);&#xA;  Mirf.setTADDR((byte *)&quot;serv1&quot;);&#xA;  Mirf.payload = sizeof(Test);&#xA;  Mirf.config();&#xA;  Serial.println(&quot;Configuring internal script variables ...&quot;);&#xA;  Serial.println(&quot;Setting system interrupts ...&quot;);&#xA;  Toolkit.packet = 9;&#xA;  attachInterrupt(0,wakeupFunction,FALLING);&#xA;}&#xA;&#xA;void loop(){&#xA;  strcpy((char *)Toolkit.address,&quot;CLI&quot;);&#xA;  Mirf.send((byte *)&amp;amp;Toolkit);&#xA;  while(Mirf.isSending()) { }&#xA;  //Mirf.setRADDR((byte *)&quot;clie1&quot;);&#xA;  /*if(Mirf.dataReady()) {&#xA;    Mirf.getData((byte *)&amp;amp;Toolkit);&#xA;&#xA;    Serial.println(&quot;Got data!&quot;);&#xA;    Serial.print(&quot;Packet number: &quot;);&#xA;    Serial.println(Toolkit.packet);&#xA;  } else Serial.println(&quot;NO DATA&quot;);*/&#xA;  delay(1000);&#xA;} &#xA;void wakeupFunction() {&#xA;  //while(Mirf.isSending()) { }&#xA;  if(Mirf.dataReady()) {&#xA;    Mirf.getData((byte *)&amp;amp;Toolkit);&#xA;    Toolkit.packet = random(300);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is client&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;&#xA;typedef struct{&#xA;  long int packet;&#xA;  byte address[5];&#xA;}&#xA;Test;&#xA;Test Toolkit;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Mirf.cePin = 9;&#xA;  Mirf.csnPin = 10;&#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;&#xA;  Mirf.init();&#xA;  Mirf.setRADDR((byte *)&quot;serv1&quot;);&#xA;  Mirf.setTADDR((byte *)&quot;clie1&quot;);&#xA;  Mirf.payload = sizeof(Test);&#xA;  Mirf.config();&#xA;  Serial.println(&quot;Listening...&quot;); &#xA;}&#xA;&#xA;void loop(){&#xA;  if(!Mirf.isSending() &amp;amp;&amp;amp; Mirf.dataReady()){&#xA;    Serial.println(&quot;Got packet&quot;);&#xA;    Mirf.getData((byte *)&amp;amp;Toolkit);&#xA;    Serial.println(&quot;Packet number:&quot;);&#xA;    Serial.println(Toolkit.packet);&#xA;    Serial.println((char *)Toolkit.address);&#xA;    //Sending&#xA;    delay(50);&#xA;    Mirf.setTADDR((byte *)&quot;clie1&quot;);&#xA;    Mirf.send((byte *)&amp;amp;Toolkit);&#xA;    while(Mirf.isSending()) Serial.println(&quot;Sending&quot;);&#xA;    Serial.println(&quot;Reply sent.&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7761" LastEditorUserId="7761" LastEditDate="2015-03-08T11:36:16.780" LastActivityDate="2017-03-29T22:29:18.150" Title="Mirf not sending reply" Tags="|rf|nrf24l01+|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9104" PostTypeId="1" CreationDate="2015-03-08T02:19:26.550" Score="1" ViewCount="2753" Body="&lt;p&gt;I'm trying to control an Arduino-powered motorized toy with a differential drive. However, I want to code it the motor movements with a direction vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(1,0) = forward&#xA;(-1,0) = backward&#xA;(0,1) = turn left, pivoting on center axis&#xA;(0,-1) = turn right, pivoting on center axis&#xA;(1,1) = forward-left, pivoting on left wheel&#xA;(1,-1) = forward-left, pivoting on right wheel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought the equation to convert these to the literal motor signals was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float mag = sqrt(dirX*dirX + dirY*dirY);&#xA;float left = dirX - dirY;&#xA;float right = dirX + dirY;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work for the first 4 cases, but fails for the last two, where it results in an un-normalized vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One potential fix would be to simple wrap &lt;code&gt;left&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt; in min() to stop it from going over 1.0, but that feels like a hack, and would possibly lose resolution. Is there a more elegant fix?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-04-07T17:28:36.713" Title="Differential steering drive equation" Tags="|motor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9105" PostTypeId="2" ParentId="9104" CreationDate="2015-03-08T03:45:50.217" Score="0" Body="&lt;p&gt;Part of the problem is that &quot;direction vector&quot; is a bit vague in this context. Here are two popular ways of doing this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(x = right speed, y = left speed)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is like &quot;tank drive&quot;, where two joystick's up/down axis are used to drive; you don't really need to do any math to get motor outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;(m = output magnitude, d = left/right balance)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've heard this called &quot;arcade drive&quot;, where one joystick's up/down is m and left/right is d.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your equations are correct; the bounds check is unavoidable. Linear vector spaces just are not going to arbitrarily bound themselves at 1 for you. you could make it so &quot;full speed ahead&quot; doesn't actually max out the motor speeds; then when you turn it could still speed up one side a bit, but that is obviously still suboptimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try normalizing left and right, then multiplying by &quot;m&quot; again. The magnitude would be constant so you wouldn't have to do any bounds checking, but you would lose the pivoting on the center behavior you want, and full forward would be slower. You could also try making &quot;d&quot; an angle, and then choosing left and right with sine and cosine, probably shifted 45 degrees. That has the same problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like to try driving it a bunch of different ways and see what handles best.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-03-08T16:55:14.667" LastActivityDate="2015-03-08T16:55:14.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9106" PostTypeId="1" AcceptedAnswerId="9109" CreationDate="2015-03-08T03:58:15.527" Score="1" ViewCount="4527" Body="&lt;p&gt;I'd like to connect 12 mpu9250 sensors to one arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find documentation on how to change the addresses of mpu9250 boards. (i read through &lt;a href=&quot;http://www.invensense.com/mems/gyro/documents/PS-MPU-9250A-01.pdf&quot; rel=&quot;nofollow&quot;&gt;the reference&lt;/a&gt; ). Some tutorials talk about changing addresses for &lt;a href=&quot;http://tronixstuff.com/2010/10/29/tutorial-arduino-and-the-i2c-bus-part-two/&quot; rel=&quot;nofollow&quot;&gt;other device&lt;/a&gt; so i assume it is possible for mpu9250. I found &lt;a href=&quot;http://www.invensense.com/mems/gyro/documents/RM-MPU-9250A-00.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; map of registers but can't figure out how to change the address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that mpu9250 might be too specific, so general guidance on how to solve these problems would be highly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;mpu9250 is similar to more popular mpu9150 and mpu6050. It is also known as GY-9250&lt;/p&gt;&#xA;" OwnerUserId="7764" LastEditorUserId="7764" LastEditDate="2015-03-08T04:30:11.617" LastActivityDate="2015-10-17T05:25:14.610" Title="How to change i2c address for mpu9250?" Tags="|i2c|communication|accelerometer|mpu6050|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9107" PostTypeId="1" AcceptedAnswerId="9114" CreationDate="2015-03-08T08:21:04.860" Score="0" ViewCount="3685" Body="&lt;p&gt;I am using ESP8266 module with Arduino Uno.I don't know how to get the signal strength of the network with which ESP8266 is connected.Please help..&lt;/p&gt;&#xA;" OwnerUserId="7136" LastActivityDate="2015-03-08T14:11:15.843" Title="How to get the signal strength of the network connected with the ESP8266" Tags="|wifi|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9108" PostTypeId="2" ParentId="1396" CreationDate="2015-03-08T08:38:54.563" Score="0" Body="&lt;p&gt;This answer does not directly address the pin conflict issue, but rather skirts around it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been looking into this same issue for over a month now and have come to the conclusion that the best option is to either &lt;a href=&quot;http://www.ebay.com/itm/GSM-Phone-Module-GSM-GSM-GPRS-Arduino-Shield-Based-on-Quad-band-SIM908-Module-/251665851830&quot; rel=&quot;nofollow noreferrer&quot;&gt;purchase&lt;/a&gt;, for around $30:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1yOw5.jpg&quot; alt=&quot;SIM908 Shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or &lt;a href=&quot;http://www.open-electronics.org/gsm-gps-shield-for-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;make&lt;/a&gt;, for around $20 (+$60 for the modules)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sEc4n.jpg&quot; alt=&quot;Modular SIM908/900 shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a shield that uses the &lt;a href=&quot;http://wm.sim.com/producten.aspx?id=1024&quot; rel=&quot;nofollow noreferrer&quot;&gt;SIM908&lt;/a&gt;. The SIM908 comes with both GPRS/GSM functionality, and GPS functionality, whereas the SIM900 only has GPRS/GSM. Now, there is no longer an issue with pin conflicts, as instead of two separate shields, only one is required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only disadvantage is that if you already have a GPRS/GSM shield, then that purchase will become redundant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside there is an alternative of a &lt;em&gt;3G&lt;/em&gt; (&lt;strong&gt;WCDMA&lt;/strong&gt; and &lt;strong&gt;HSPA&lt;/strong&gt;) and GPS, using both assisted-mobile (A-GPS) and mobile-based (S-GPS) modes, combined shield, from &lt;a href=&quot;http://www.cooking-hacks.com/documentation/tutorials/arduino-3g-gprs-gsm-gps&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cooking Hacks&lt;/a&gt;. A bit more pricey though, at $160.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-03-08T12:49:13.780" LastActivityDate="2015-03-08T12:49:13.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9109" PostTypeId="2" ParentId="9106" CreationDate="2015-03-08T10:34:46.703" Score="2" Body="&lt;p&gt;Page 23 of the manual you linked: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The MPU-9250 always acts as a slave when communicating to the system processor.&#xA;  The LSB of the of the I2C slave address is set by pin 9 (AD0).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems you can only choose between two addresses as listed in the table on page 12.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-03-08T10:34:46.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9110" PostTypeId="2" ParentId="9099" CreationDate="2015-03-08T10:43:11.600" Score="1" Body="&lt;p&gt;What you see is undefined behavior. You define your buffer to have a length of 50 bytes:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;char buffer[50];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is too short for most of the strings you want copy into it and you will thus overwrite other variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution is to increase the buffer size so that the longest string fits (e.g. 150). You will see that it then works as you expect. Take a look at &lt;a href=&quot;http://linux.dd.com.au/wiki/Arduino_Static_Strings&quot; rel=&quot;nofollow&quot;&gt;http://linux.dd.com.au/wiki/Arduino_Static_Strings&lt;/a&gt; for hints how to avoid wasting RAM for the buffer.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-03-08T10:43:11.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9111" PostTypeId="1" CreationDate="2015-03-08T11:34:39.743" Score="0" ViewCount="2292" Body="&lt;p&gt;To write text on a dot-matrix or LC display with an Arduino you need to have a pixel font in byte format (i.e. typically 1 bit = 1 pixel). &#xA;On the Internet I have found surprisingly few resources for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the results when searching for pixel fonts return true-type fonts (or similar) which are rather complicated to convert to obtain a satisfying result. &#xA;Also, most of the fonts are rather high resolution.&#xA;Any good resources I have missed?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="10794" LastEditDate="2015-09-02T01:40:55.040" LastActivityDate="2018-08-17T07:32:40.950" Title="Pixel font resources in byte format" Tags="|display|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9112" PostTypeId="2" ParentId="9100" CreationDate="2015-03-08T12:42:23.907" Score="1" Body="&lt;p&gt;Yes, I do think so. according to &lt;a href=&quot;https://arduino.stackexchange.com/questions/8743/use-rfid-rc522-with-other-pins&quot;&gt;my Question&lt;/a&gt; with RFID and display it turned out that those pins are for serial communiacation. So I think it should work. &#xA;I can verify&#xA; that it will work if you do use the ICSP headers MOSI/MISO/SCLK pins. Connecting those three with the RC552 as well as GND and 3V3. Also connect two other pins to SS and RST. This pins can be adjusted in the sketch on the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="7225" LastActivityDate="2015-03-08T12:42:23.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9114" PostTypeId="2" ParentId="9107" CreationDate="2015-03-08T14:11:15.843" Score="3" Body="&lt;p&gt;The page &lt;a href=&quot;http://tomeko.net/other/ESP8266/&quot; rel=&quot;nofollow&quot;&gt;http://tomeko.net/other/ESP8266/&lt;/a&gt; names the following command:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+CWLAP     // list available access points&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to the example given there, this returns a list of items looking like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+CWLAP:(3,&quot;UPC784xxx&quot;,-75,&quot;70:54:d2:xx:xx:xx&quot;,1)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;where &lt;em&gt;&quot;APs are sorted by channel and values are: (security, &quot;name&quot;, &lt;strong&gt;signal strength&lt;/strong&gt;, MAC, channel) where for security: 0 = open, 1 = WEP, 3 = WPA, 4 = WPA2&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you can use &lt;code&gt;AT+CWJAP?&lt;/code&gt; to obtain the name of the network you're connected to and get the signal strength from the respective item in the list provided by &lt;code&gt;AT+CWLAP&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module&quot; rel=&quot;nofollow&quot;&gt;http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module&lt;/a&gt; for a reference of commands.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-03-08T14:11:15.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9115" PostTypeId="1" CreationDate="2015-03-08T14:31:19.330" Score="7" ViewCount="34823" Body="&lt;p&gt;This code compares the analog input value against two thresholds, having three voltage regions. Then it will turn on an LED according to what region the read voltage is in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when the voltage read is very close to the threshold, the noise will disturb the output, resulting in an uncontrolled switching between LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would need to add some sort of HYSTERESIS around my thresholds to avoid the uncontrolled switching, but I have no idea how to write this into the code language. Would anyone be able to help me writing the threshold bit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// these constant won't change:&#xA;const int BatteryVoltagePin = 14;   // the pin that battery voltage is attached to&#xA;const int GreenLedPin = 3;           // the pin that the green LED (On charge) is attached to&#xA;const int OrangeLedPin = 4;          // the pin that the orange LED (no risk) is attached to&#xA;const int RedLedPin = 5;             // the pin that the red LED (low battery) is attached to&#xA;&#xA;// Variables will change:&#xA;int currentVoltage ;         // current voltage value&#xA;int previousVoltage ;     // previous voltage value    &#xA;&#xA;void setup() {&#xA;  // initialize the battery voltage pin as a input:&#xA;  pinMode(BatteryVoltagePin, INPUT);&#xA;  // initialize the green LED as an output:&#xA;  pinMode(GreenLedPin, OUTPUT);&#xA;  // initialize the orange LED as an output:&#xA;  pinMode(OrangeLedPin, OUTPUT);&#xA;  // initialize the red LED as an output:&#xA;  pinMode(RedLedPin, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // read the voltage across the battery voltage pin:&#xA;  currentVoltage = digitalRead(BatteryVoltagePin);&#xA;&#xA;  // compare the current voltage value to its previous value&#xA; if (currentVoltage != previousVoltage) &#xA;&#xA; delay(10);&#xA;&#xA;    // value above maximum threshold&#xA;    {&#xA;     if ((( ( analogRead(BatteryVoltagePin) ) &amp;gt; ( 699 ) ))   &#xA;        {&#xA;        digitalWrite(GreenLedPin, HIGH);&#xA;        }&#xA;        else&#xA;        {&#xA;          digitalWrite(GreenLedPin, LOW );&#xA;        }&#xA;    }&#xA;&#xA;    //value between two thresholds (middle region)&#xA;    {&#xA;     if (( ( ( analogRead(BatteryVoltagePin) ) &amp;lt;= ( 699 ) ) &amp;amp;&amp;amp; ( ( analogRead(BatteryVoltagePin) ) &amp;gt;= ( 628 ) ) ))          &#xA;        {       &#xA;        digitalWrite(OrangeLedPin, HIGH );&#xA;        }&#xA;        else&#xA;        {&#xA;          digitalWrite(OrangeLedPin, LOW );&#xA;        }&#xA;    }&#xA;&#xA;    // value below minimum threshold&#xA;    {&#xA;     if (( ( analogRead(BatteryVoltagePin) ) &amp;lt; ( 628 ) ))   &#xA;        {&#xA;        digitalWrite(RedLedPin, HIGH);&#xA;        }&#xA;        else&#xA;        {&#xA;          digitalWrite(RedLedPin, LOW );&#xA;        }&#xA;     }&#xA;&#xA;&#xA;  // save the current state as the last state, &#xA;  //for next time through the loop&#xA;  previousVoltage = currentVoltage;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7167" LastEditorUserId="7021" LastEditDate="2018-05-18T12:05:11.937" LastActivityDate="2018-05-18T12:05:11.937" Title="How to add hysteresis to threshold values?" Tags="|arduino-uno|programming|sketch|analogread|compile|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9116" PostTypeId="2" ParentId="9115" CreationDate="2015-03-08T17:13:44.820" Score="7" Body="&lt;p&gt;Adding hysteresis behavior to your code is not difficult. You just need to store the state you're in and make the thresholds for transitioning into another state dependent on that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use an enum to store the state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum BatteryStates {&#xA;  Red, Orange, Green&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, instead of defining and checking against one threshold value, define two thresholds for each transition, separated by so much that you don't observe the undesired flip-flopping behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when transitioning from Green to Orange you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((state == Green) &amp;amp;&amp;amp; (battery &amp;lt; 690))&#xA;  state = Orange;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the other direction would use a slightly higher threshold&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((state == Orange) &amp;amp;&amp;amp; (battery &amp;gt; 700))&#xA;  state = Green;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that small fluctuations of the voltage do not cause flip-flopping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that my code assumes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int battery = analogRead(BatteryVoltagePin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable &lt;code&gt;state&lt;/code&gt; should be declared and initialized like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum BatteryStates state = Green;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of an &lt;code&gt;enum&lt;/code&gt; you could use a simple &lt;code&gt;int&lt;/code&gt; and map each state to a number (e.g. red = 1, orange = 2, green = 3), but using &lt;code&gt;enum&lt;/code&gt; makes the code easier to read and write. (In fact &lt;code&gt;enum&lt;/code&gt; does use integer numbers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I might also use a &lt;code&gt;switch&lt;/code&gt; statement instead of an &lt;code&gt;if&lt;/code&gt; chain to implement the transitions, but that's a matter of taste.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-09T05:29:04.683" LastActivityDate="2015-03-09T05:29:04.683" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9117" PostTypeId="1" AcceptedAnswerId="12584" CreationDate="2015-03-08T17:45:10.143" Score="11" ViewCount="20435" Body="&lt;p&gt;How do the IO registers of Arduino Due work?&#xA;On Arduino Uno just set &lt;code&gt;DDRx&lt;/code&gt;, then &lt;code&gt;PINx&lt;/code&gt; to read, &lt;code&gt;PORTx&lt;/code&gt; to write, I'd like to do the same thing with an Arduino Due, but it has many more registers, such as &lt;code&gt;PIO_OWER&lt;/code&gt;, &lt;code&gt;PIO_OSER&lt;/code&gt;, &lt;code&gt;PIO_CODR&lt;/code&gt;, &lt;code&gt;PIO_SODR&lt;/code&gt;, etc. I find no correspondence between Arduino Uno and Arduino Due registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also some useful functions such as &lt;code&gt;pio_clear&lt;/code&gt;, &lt;code&gt;pio_set&lt;/code&gt;, &lt;code&gt;pio_get&lt;/code&gt;, and others, all explained here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://asf.atmel.com/docs/3.19.0/sam3x/html/group__sam__drivers__pio__group.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://asf.atmel.com/docs/3.19.0/sam3x/html/group__sam__drivers__pio__group.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I think I've understood what the three mentioned functions do, but not others, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;pio_configure (Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask, const uint32_t ul_attribute)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't figure out what &lt;code&gt;ul_attribute&lt;/code&gt; and &lt;code&gt;ul_type&lt;/code&gt; are.&lt;/p&gt;&#xA;" OwnerUserId="4847" LastEditorUserId="26916" LastEditDate="2017-11-04T08:32:31.270" LastActivityDate="2022-09-20T10:00:00.247" Title="SAM3X8E (Arduino Due) Pin IO registers" Tags="|arduino-due|c|port-mapping|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9118" PostTypeId="1" AcceptedAnswerId="9169" CreationDate="2015-03-08T18:02:43.140" Score="-1" ViewCount="4174" Body="&lt;p&gt;I am trying to communicate Arduino Uno with an android phone. What I trying to is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Android device post a string to Arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino post a integer to Android&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So far I can post message from Android, received in Arduino board, but I &lt;strong&gt;can not post a integer to Android, nothing receive at Android&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Code&lt;/strong&gt; (Which can receive character &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, and for case &quot;z&quot;, I would like to send back the distance which is an &lt;code&gt;int&lt;/code&gt;)  : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{ &#xA;  distance = Dist.getDistanceCentimeter();&#xA;  if(distance&amp;lt;=5 &amp;amp; distance&amp;gt;1)&#xA;  {&#xA;    back();&#xA;    delay(100);&#xA;    ting();&#xA;    distance=0;&#xA;  } &#xA;  if(Serial.available())&#xA;  {&#xA;    lkf = Serial.read();&#xA;  switch(lkf)&#xA;  {&#xA;  case 'a':&#xA;     front();&#xA;     servoX.write(90);&#xA;     lkf=0;  &#xA;     break;   &#xA;   case 'b':&#xA;     back();&#xA;     lkf=0;&#xA;     break;     &#xA;   case 'c':&#xA;     left();&#xA;     lkf=0;&#xA;     break;&#xA;   case 'd':&#xA;     right();&#xA;     lkf=0;&#xA;     break; &#xA;  case 'z':&#xA;    Serial.write(distance);&#xA;    break; &#xA;    }&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Android Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In Main Activity&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;@Override&#xA;protected TCPClient doInBackground(String... message) {&#xA;&#xA;    //create TCPClient object &#xA;    mTcpClient = new TCPClient(new TCPClient.OnMessageReceived() {&#xA;        @Override&#xA;        //check whether server return message&#xA;        public void messageReceived(String message) {&#xA;            f_sensor.setText(message);&#xA;            Log.d(&quot;test1&quot;,&quot;msg rece&quot; + message);&#xA;            //publishProgress(message);&#xA;        }&#xA;    });&#xA;    mTcpClient.run();&#xA;&#xA;    return null;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TCP Cilent&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class TCPClient {&#xA;&#xA;    private String serverMessage;&#xA;    public static final String SERVERIP = &quot;192.168.8.1&quot;; //your computer IP address&#xA;    public static final int SERVERPORT = 2001;&#xA;    private OnMessageReceived mMessageListener = null;&#xA;    private boolean mRun = false;&#xA;&#xA;    PrintWriter out;&#xA;    BufferedReader in;&#xA;&#xA;    /**&#xA;     *  Constructor of the class. OnMessagedReceived listens for the messages received from server&#xA;     */&#xA;    public TCPClient(OnMessageReceived listener) {&#xA;        mMessageListener = listener;&#xA;    }&#xA;&#xA;    /**&#xA;     * Sends the message entered by client to the server&#xA;     * @param message text entered by client&#xA;     */&#xA;    public void sendMessage(String message){&#xA;        if (out != null &amp;amp;&amp;amp; !out.checkError()) {&#xA;            out.println(message);&#xA;            out.flush();&#xA;        }&#xA;    }&#xA;&#xA;    public void stopClient(){&#xA;        mRun = false;&#xA;    }&#xA;&#xA;    public void run() {&#xA;&#xA;        mRun = true;&#xA;&#xA;        try {&#xA;            //here you must put your computer's IP address.&#xA;            InetAddress serverAddr = InetAddress.getByName(SERVERIP);&#xA;&#xA;            Log.e(&quot;TCP Client&quot;, &quot;C: Connecting...&quot;);&#xA;&#xA;            //create a socket to make the connection with the server&#xA;            Socket socket = new Socket(serverAddr, SERVERPORT);&#xA;&#xA;            try {&#xA;&#xA;                //send the message to the server&#xA;                out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);&#xA;&#xA;                Log.e(&quot;TCP Client&quot;, &quot;C: Sent.&quot;);&#xA;&#xA;                Log.e(&quot;TCP Client&quot;, &quot;C: Done.&quot;);&#xA;&#xA;                //receive the message which the server sends back&#xA;                in = new BufferedReader(new InputStreamReader(socket.getInputStream()));&#xA;&#xA;                //in this while the client listens for the messages sent by the server&#xA;                while (mRun) {&#xA;                    serverMessage = in.readLine();&#xA;&#xA;                    if (serverMessage != null &amp;amp;&amp;amp; mMessageListener != null) {&#xA;                        //call the method messageReceived from MyActivity class&#xA;                        mMessageListener.messageReceived(serverMessage);&#xA;                    }&#xA;                    serverMessage = null;&#xA;&#xA;                }&#xA;&#xA;                Log.d(&quot;test1&quot;,serverMessage);&#xA;                Log.e(&quot;RESPONSE FROM SERVER&quot;, &quot;S: Received Message: '&quot; + serverMessage + &quot;'&quot;);&#xA;&#xA;            } catch (Exception e) {&#xA;&#xA;                Log.e(&quot;TCP&quot;, &quot;S: Error&quot;, e);&#xA;&#xA;            } finally {&#xA;                //the socket must be closed. It is not possible to reconnect to this socket&#xA;                // after it is closed, which means a new socket instance has to be created.&#xA;                socket.close();&#xA;            }&#xA;&#xA;        } catch (Exception e) {&#xA;&#xA;            Log.e(&quot;TCP&quot;, &quot;C: Error&quot;, e);&#xA;&#xA;        }&#xA;&#xA;    }&#xA;&#xA;    //Declare the interface. The method messageReceived(String message) will must be implemented in the MyActivity&#xA;    //class at on asynckTask doInBackground&#xA;    public interface OnMessageReceived {&#xA;        public void messageReceived(String message);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7692" LastEditorUserId="6936" LastEditDate="2016-02-21T11:34:48.510" LastActivityDate="2016-11-29T13:34:25.243" Title="Arduino TCP communication with Android phone" Tags="|arduino-uno|serial|programming|networking|tcpip|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9119" PostTypeId="1" AcceptedAnswerId="9142" CreationDate="2015-03-08T18:59:31.437" Score="0" ViewCount="641" Body="&lt;p&gt;I am connecting an RFID reader to my Arduino mega.  The directions that I have found say that I need to use pins 50-53.  I also noticed that the ICSP header contains (what looks like) a secondary connection to these pins: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SPI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I connect my RFID reader to the ICSP header:&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-03-08T20:03:02.663" Title="Can I connect an RFID reader to the ICSP header?" Tags="|arduino-mega|rfid|icsp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9120" PostTypeId="5" CreationDate="2015-03-08T19:17:32.020" Score="0" Body="&lt;p&gt;USB (Universal Serial Bus) can be used for connecting a wide range of devices to a host computer. On Arduino boards, a USB connection is commonly used for providing a power supply, loading programs (sketches) into Flash memory, and for sending/receiving other data via serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases, such as the Arduino Micro, the microcontroller can be programmed to mimic a USB input device such as a mouse or keyboard.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:17:32.020" LastActivityDate="2015-03-08T19:17:32.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9121" PostTypeId="4" CreationDate="2015-03-08T19:17:32.020" Score="0" Body="Widely used standard for connecting computers to other devices, such as printers and keyboards." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:17:32.020" LastActivityDate="2015-03-08T19:17:32.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9122" PostTypeId="5" CreationDate="2015-03-08T19:26:14.140" Score="0" Body="&lt;p&gt;Calling &lt;code&gt;analogRead(x)&lt;/code&gt; (where &lt;code&gt;x&lt;/code&gt; is a pin number) allows the Arduino to measure the approximate voltage on its analog pins. This is performed using a 10-bit ADC (Analog to Digital Converter), which takes approximately 100 microseconds.&lt;/p&gt;&#xA;&lt;p&gt;It returns an integer value between 0 and 1023, which will usually represent the range +0v to +5v. However, the voltage range will be different if the board runs at a different voltage, or if the program has selected a different range by calling &lt;code&gt;analogReference()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="87707" LastEditDate="2023-08-06T10:37:00.007" LastActivityDate="2023-08-06T10:37:00.007" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9123" PostTypeId="4" CreationDate="2015-03-08T19:26:14.140" Score="0" Body="A standard Arduino function for measuring the voltage on an analog pin via ADC." OwnerUserId="42" LastEditorUserId="87707" LastEditDate="2023-07-28T08:15:44.760" LastActivityDate="2023-07-28T08:15:44.760" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9124" PostTypeId="5" CreationDate="2015-03-08T19:33:06.420" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:33:06.420" LastActivityDate="2015-03-08T19:33:06.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9125" PostTypeId="4" CreationDate="2015-03-08T19:33:06.420" Score="0" Body="A component which measures G-force to detect which direction it is moved or tilted in." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:33:06.420" LastActivityDate="2015-03-08T19:33:06.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9126" PostTypeId="5" CreationDate="2015-03-08T19:37:11.957" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:37:11.957" LastActivityDate="2015-03-08T19:37:11.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9127" PostTypeId="4" CreationDate="2015-03-08T19:37:11.957" Score="0" Body="Passive electronic component which reduces current flow in a circuit, dissipating power as heat." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:37:11.957" LastActivityDate="2015-03-08T19:37:11.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9128" PostTypeId="5" CreationDate="2015-03-08T19:38:56.253" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:38:56.253" LastActivityDate="2015-03-08T19:38:56.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9129" PostTypeId="4" CreationDate="2015-03-08T19:38:56.253" Score="0" Body="Global Positioning System. Uses satellites to determine geographic location." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:38:56.253" LastActivityDate="2015-03-08T19:38:56.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9130" PostTypeId="5" CreationDate="2015-03-08T19:43:35.627" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:43:35.627" LastActivityDate="2015-03-08T19:43:35.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9131" PostTypeId="4" CreationDate="2015-03-08T19:43:35.627" Score="0" Body="Volatile memory used by Arduino programs for storing variables and other data at runtime." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:43:35.627" LastActivityDate="2015-03-08T19:43:35.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9132" PostTypeId="5" CreationDate="2015-03-08T19:50:32.447" Score="0" Body="&lt;p&gt;Real-Time Clock. Keeps track of current date/time.  Some have batteries like the DS3231, and the DS3231 also has programmable alarms that can interrupt an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="26717" LastEditDate="2017-06-06T09:17:09.167" LastActivityDate="2017-06-06T09:17:09.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9133" PostTypeId="4" CreationDate="2015-03-08T19:50:32.447" Score="0" Body="Real-Time Clock. Keeps track of current date/time.  Some have batteries like the DS3231, and the DS3231 also has programmable alarms that can interrupt an Arduino." OwnerUserId="42" LastEditorUserId="26717" LastEditDate="2017-05-31T16:43:46.603" LastActivityDate="2017-05-31T16:43:46.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9134" PostTypeId="5" CreationDate="2015-03-08T19:52:11.630" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:52:11.630" LastActivityDate="2015-03-08T19:52:11.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9135" PostTypeId="4" CreationDate="2015-03-08T19:52:11.630" Score="0" Body="A free and open source IDE (Integrated Development Environment) for programming in a variety of languages. Supports Arduino programming via plug-ins." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:52:11.630" LastActivityDate="2015-03-08T19:52:11.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9136" PostTypeId="5" CreationDate="2015-03-08T19:54:59.253" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:54:59.253" LastActivityDate="2015-03-08T19:54:59.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9137" PostTypeId="4" CreationDate="2015-03-08T19:54:59.253" Score="0" Body="Local Area Network. A connection between multiple computers or other devices over a limited geographic area. Typically implemented via Ethernet or Wi-Fi." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:54:59.253" LastActivityDate="2015-03-08T19:54:59.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9138" PostTypeId="5" CreationDate="2015-03-08T19:57:39.833" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:57:39.833" LastActivityDate="2015-03-08T19:57:39.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9139" PostTypeId="4" CreationDate="2015-03-08T19:57:39.833" Score="0" Body="A circuit which allows voltage to be applied in either direction across a load. A common application is switching the drive direction of a motor." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:57:39.833" LastActivityDate="2015-03-08T19:57:39.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9140" PostTypeId="5" CreationDate="2015-03-08T19:59:52.210" Score="0" Body="&lt;p&gt;Interrupts are widely used on processors to manage asynchronous events - that is, events that happen in an unpredictable way, such as someone closing a switch, receiving incoming serial data, a timer overflowing and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmega328P processor, used in the Arduino Uno, Duemilanove, Pro Mini, Nano, and others, has 25 possible interrupt events, in addition to Reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1  Reset &#xA; 2  External Interrupt Request 0  (pin D2)          (INT0_vect)&#xA; 3  External Interrupt Request 1  (pin D3)          (INT1_vect)&#xA; 4  Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)&#xA; 5  Pin Change Interrupt Request 1 (pins A0 to A5)  (PCINT1_vect)&#xA; 6  Pin Change Interrupt Request 2 (pins D0 to D7)  (PCINT2_vect)&#xA; 7  Watchdog Time-out Interrupt                     (WDT_vect)&#xA; 8  Timer/Counter2 Compare Match A                  (TIMER2_COMPA_vect)&#xA; 9  Timer/Counter2 Compare Match B                  (TIMER2_COMPB_vect)&#xA;10  Timer/Counter2 Overflow                         (TIMER2_OVF_vect)&#xA;11  Timer/Counter1 Capture Event                    (TIMER1_CAPT_vect)&#xA;12  Timer/Counter1 Compare Match A                  (TIMER1_COMPA_vect)&#xA;13  Timer/Counter1 Compare Match B                  (TIMER1_COMPB_vect)&#xA;14  Timer/Counter1 Overflow                         (TIMER1_OVF_vect)&#xA;15  Timer/Counter0 Compare Match A                  (TIMER0_COMPA_vect)&#xA;16  Timer/Counter0 Compare Match B                  (TIMER0_COMPB_vect)&#xA;17  Timer/Counter0 Overflow                         (TIMER0_OVF_vect)&#xA;18  SPI Serial Transfer Complete                    (SPI_STC_vect)&#xA;19  USART Rx Complete                               (USART_RX_vect)&#xA;20  USART, Data Register Empty                      (USART_UDRE_vect)&#xA;21  USART, Tx Complete                              (USART_TX_vect)&#xA;22  ADC Conversion Complete                         (ADC_vect)&#xA;23  EEPROM Ready                                    (EE_READY_vect)&#xA;24  Analog Comparator                               (ANALOG_COMP_vect)&#xA;25  2-wire Serial Interface  (I2C)                  (TWI_vect)&#xA;26  Store Program Memory Ready                      (SPM_READY_vect)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The name of the &lt;em&gt;interrupt handler vector&lt;/em&gt; is in parentheses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If an interrupt event occurs (for example, Timer 0 overflows), and that particular interrupt is enabled, &lt;strong&gt;and&lt;/strong&gt; interrupts are currently globally enabled, then the processor will jump to the appropriate interrupt vector in that list, at the completion of the current instruction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are not serviced in the middle of an instruction. If multiple interrupt events have occurred, the higher priority one (higher up the above list) will be serviced first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the processor jumps to service an interrupt, further interrupts are globally disabled. They are enabled again automatically when the Interrupt Service Routine (ISR) returns. &lt;em&gt;(These remarks apply to the AVR range of processors, SAM/ARM and Intel ones may behave slightly differently)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some interrupts are already handled by libraries (eg. The &lt;code&gt;millis&lt;/code&gt; library for TIMER0_OVF_vect and the &lt;code&gt;HardwareSerial&lt;/code&gt; library for USART_RX_vect, USART_UDRE_vect and USART_TX_vect). However if you write your own they typically look like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR(WDT_vect)&#xA;  {&#xA;  // interrupt handling code here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;General tips for writing ISRs&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Keep the ISR code short&lt;/li&gt;&#xA;&lt;li&gt;Don't use &lt;code&gt;delay()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Don't do serial prints&lt;/li&gt;&#xA;&lt;li&gt;Make variables shared with the main code &lt;code&gt;volatile&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Variables shared with main code may need to be protected by &quot;critical sections&quot; &lt;/li&gt;&#xA;&lt;li&gt;Don't try to turn interrupts off or on inside an ISR&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:32.977" LastActivityDate="2015-08-30T20:37:32.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9141" PostTypeId="4" CreationDate="2015-03-08T19:59:52.210" Score="0" Body="Interrupt Service Routine. A function which gets called in response to an interrupt signal." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-08T19:59:52.210" LastActivityDate="2015-03-08T19:59:52.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9142" PostTypeId="2" ParentId="9119" CreationDate="2015-03-08T20:03:02.663" Score="1" Body="&lt;p&gt;Yes you can. However the SS isn't present on that header. You can however use any pin you want for SS (if the library you use supports it, that is)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-08T20:03:02.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9143" PostTypeId="1" AcceptedAnswerId="9144" CreationDate="2015-03-08T20:15:43.150" Score="1" ViewCount="2349" Body="&lt;p&gt;I have a system that uses two Arduino boards.  One is used to control several different functions, and the other is dedicated to driving a 45 second countdown display (comprised of two large 7 segment displays.)  All this second Arduino needs is a single signal to tell it when to start.  I would like to simply connect an output pin (on #1) to an input pin (on #2) and and send a single pulse to get the clock started.  Fo something this simple, I wanted to avoid using I2C.  Can I do this?  If so, is there anything else I need to be aware of (like connecting ground to ground?)&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-03-08T20:31:10.833" Title="Can you connect an output pin from one Arduino to the input pin of another?" Tags="|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9144" PostTypeId="2" ParentId="9143" CreationDate="2015-03-08T20:31:10.833" Score="1" Body="&lt;p&gt;Yes, you can. That is indeed the most easy way of communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And like you said, you have to connect the grounds of both arduino's. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optionally you could add a pull-up of pull-down resistor, so the countdown doesn't accidentally start if the first arduino is still starting up, or is disconnected.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-08T20:31:10.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9145" PostTypeId="1" CreationDate="2015-03-08T20:31:45.810" Score="0" ViewCount="1409" Body="&lt;p&gt;I am using two motors ( from old two drill machines - same kind, these are 3.6v motors ), connected to arduino + arduino motor shield seeed studio v2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I measured the both motors (indvidually) using a multimeter in series with your motor and an about 3.6V power supply, I found that the both are varying from 1.46A-1.47A, (I supposed it as 1.5A)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use 18v/1.2a battery that was laying at home (from old machine ) what I have noticed is that motors are running for 3-5 seconds than stop, one of the red lights start blinking in the motor shield, then it stops for 3-5 seconds then it works again and loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes: &#xA;- The motors are working when I connect them directly to 4.5 or 6v battery. But when I try to assemle everything , it doesn't work (I am adding this just to say that motors are in good health).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I tried 14v battery I noticed the same thing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The drill machine is small one (as big as a human hand). Motors from electric drills are designed as high-speed high-torque motors, but I don't think it's too high in my case to be a huge problem. It's 200 RPM DC motor&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I spent a week looking for answer before posting this thread, I tried every single solution I came across on the web.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What are things that I should consider here, any thoughts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I miss? And what kind of battery should I use ??&lt;/p&gt;&#xA;" OwnerUserId="5134" LastActivityDate="2015-05-07T23:30:02.887" Title="Which battery should I use to power arduino+motor shield + two 200 RPM (3.6V/1.5A)motors" Tags="|arduino-uno|motor|battery|arduino-motor-shield|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9146" PostTypeId="1" AcceptedAnswerId="9147" CreationDate="2015-03-08T21:43:19.307" Score="2" ViewCount="560" Body="&lt;p&gt;I have to admit that I can't really use this function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to format some json but it crashing all the time my arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char response[300];&#xA;tmp = &quot;123&quot;;&#xA;snprintf(response, 300, &quot;[{Name:'Furnace',Value=%s,Alarm={MinValue=%s,MaxValue=%s}},{Name:'Room',Value=%s,Alarm={MinValue=%s,MaxValue=%s}}]&quot;, tmp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How should I use this function properly?&lt;/p&gt;&#xA;" OwnerUserId="7779" LastEditorUserId="10794" LastEditDate="2015-08-14T01:05:17.357" LastActivityDate="2015-08-14T01:05:17.357" Title="snprintf crashing my program" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9147" PostTypeId="2" ParentId="9146" CreationDate="2015-03-08T21:54:55.253" Score="2" Body="&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char response[300];&#xA;tmp = &quot;123&quot;;&#xA;snprintf(response, 300,&#xA;    &quot;[{Name:'Furnace',Value=%s,Alarm={MinValue=%s,MaxValue=%s}},&quot;&#xA;    &quot;{Name:'Room',Value=%s,Alarm={MinValue=%s,MaxValue=%s}}]&quot;,&#xA;    tmp, tmp, tmp, tmp, tmp, tmp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, you should add, after the format string, as many extra&#xA;parameters as there are %s in the format string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: This looks like JSON, but it is not really valid JSON.&#xA;The format below should give valid JSON:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;&quot;[{\&quot;Name\&quot;:\&quot;Furnace\&quot;,\&quot;Value\&quot;:%s,&quot;&#xA;&quot;\&quot;Alarm\&quot;:{\&quot;MinValue\&quot;:%s,\&quot;MaxValue\&quot;:%s}},&quot;&#xA;&quot;{\&quot;Name\&quot;:\&quot;Room\&quot;,\&quot;Value\&quot;:%s,&quot;&#xA;&quot;\&quot;Alarm\&quot;:{\&quot;MinValue\&quot;:%s,\&quot;MaxValue\&quot;:%s}}]&quot;,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-08T22:00:27.987" LastActivityDate="2015-03-08T22:00:27.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9148" PostTypeId="2" ParentId="9145" CreationDate="2015-03-08T22:33:45.570" Score="1" Body="&lt;p&gt;I have run into similar weirdness myself, and the solution that worked for me is to have separate batteries for the Arduino and the motors. This is more important if your motors run at a different voltage (e.g. 6v or 12v motors), but is useful in any case. This means that, when the motors draw to much from the batteries, the motors will slow down. If the same battery is used for the motors as for the Arduino, then the voltage drop from the motors will also apply to the Arduino; if the voltage drops in the Arduino, it will turn off (and turn back on when the voltage is restored). This is likely what you are seeing.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-08T22:33:45.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9149" PostTypeId="1" CreationDate="2015-03-09T01:59:46.087" Score="0" ViewCount="2541" Body="&lt;p&gt;I'm creating a library driver for AdaFruit's GFX library. During Constructor initialization, all the variables (set in another .cpp) are returned as zero. This code has several modular files to separate graphics functions from graphics primitives from device interfacing. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino sketch I call the class constructor: MB_GFX_SPI (in file MB_GFX_SPI.cpp).&#xA;In the Constructor I'm call a function: mbR.SetMatrixSize (in another file raster.cpp).&#xA;Also in the Constructor I call a function: clearScreen (in the same file MB_GFX_SPI.cpp).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test variable  mbR.r_totNumChannels set in clearScreen is returned with 99.&#xA;All the variables set in mbR.SetMatrixSize return zero.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Test Sketch&#xA;//Initialize both the Adafruit library and the current library.&#xA;//Instantiate an object mbGFX so all Adafruit GFX and MB_GFX add-on functions are addressed as mbGFX.xxx(); &#xA;MB_GFX_SPI mbGFX = MB_GFX_SPI(Period, numCathodeLeds, numAnodeLeds, CathodeSSPin, AnodeSSPin);&#xA;&#xA;&#xA;//In file MB_GFX_SPI.cpp&#xA;&#xA;MB_GFX_SPI::MB_GFX_SPI(int Period, int numCathodeLEDS, int numAnodeLEDS,&#xA;      int CathodeSSPin, int AnodeSSPin) &#xA;      : Adafruit_GFX(numCathodeLEDS, numAnodeLEDS) {&#xA;&#xA;  mbR.SetMatrixSize(numCathodeLEDS, numAnodeLEDS);&#xA;  clearScreen(0);&#xA;}&#xA;void MB_GFX_SPI::clearScreen(uint16_t color) {&#xA;   mbR.r_totNumChannels = 99;   //test set value&#xA;}&#xA;&#xA;&#xA;//In file mb_raster.cpp&#xA;&#xA;void mbRasterClass::SetMatrixSize(int numCathodeLeds, int numAnodeLeds){&#xA;//cathodes require 1 byte per channel&#xA;//anodes require 1 bit per channel&#xA;&#xA;    int numAnodeChannels = numAnodeLeds;&#xA;    int numCathodeChannels = mbX.pin2pin * numCathodeLeds; //times 1 or 3   &#xA;&#xA;    r_numCathodeRegisters = (int)((numCathodeChannels+7)/8);   //select next higher number of registers&#xA;    r_numCathodes = 8 * r_numCathodeRegisters;  //must be whole 8 bit registers - is every single chatode pin&#xA;    r_numAnodeRegisters = (numAnodeChannels+7)/8;       //round up to next register number&#xA;    r_numAnodes = 8 * r_numAnodeRegisters; //must be whole 8 bit registers&#xA;    r_PWMBufferSize = r_totNumChannels = r_numAnodes * r_numCathodes;&#xA;&#xA;    r_PWMBuffer = (uint8_t *) realloc(r_PWMBuffer, r_totNumChannels); //resize array for PWMBuffer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3655" LastEditorUserId="4131" LastEditDate="2016-01-19T17:18:00.907" LastActivityDate="2016-11-15T00:03:36.340" Title="Variables not initialized in Class Constructor" Tags="|c++|class|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9152" PostTypeId="1" CreationDate="2015-03-09T06:10:05.243" Score="2" ViewCount="22570" Body="&lt;p&gt;I am trying to make a wifi repeater. My router's signals don't come to my study and instead of buying a proper wifi repeater I prefer making one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to learn how to make a simple wifi repeater that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;repeats/boosts my existing home wifi network by connecting to it.&lt;/li&gt;&#xA;&lt;li&gt;Has some kind of a GUI or something that allows me to connect to it first (from some smartphone or PC) to configure it to my home network. It should find and show wifi networks around and then connect to the one I want it to upon my command.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am new to electronics. Arduino is my preferred platform. If there are other easy to do alternatives that shall work too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any kind of help will be appreciated...tutorials, blogs, etc.&lt;/p&gt;&#xA;" OwnerUserId="5142" LastActivityDate="2019-02-06T04:42:24.797" Title="How to make an arduino wifi repeater?" Tags="|arduino-uno|wifi|arduino-yun|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9153" PostTypeId="1" CreationDate="2015-03-09T07:22:20.417" Score="2" ViewCount="512" Body="&lt;p&gt;&lt;em&gt;Datasheets&lt;/em&gt;   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LED Matrix (p2): &lt;a href=&quot;https://www.circuitspecialists.com/products/pdf/M105057CHR1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.circuitspecialists.com/products/pdf/M105057CHR1.pdf&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;MAX7221: &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/General/COM-09622-MAX7219-MAX7221.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/datasheets/Components/General/COM-09622-MAX7219-MAX7221.pdf&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Convention&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(Row, Col) Designates an LED at a particular row and column, following the convention set by the datasheet  &lt;/li&gt;&#xA;&lt;li&gt;{Anode, Cathode} Designates a anode/cathode pair to light an LED in the array  &lt;/li&gt;&#xA;&lt;li&gt;Assume that I've connected:&lt;br&gt;&#xA;SEG_DP to pin 13&lt;br&gt;&#xA;SEG_A to 3&lt;br&gt;&#xA;SEG_B to 11&lt;br&gt;&#xA;SEG_C to 10&lt;br&gt;&#xA;SEG_D to 6&lt;br&gt;&#xA;DIG_0 to 9&lt;br&gt;&#xA;DIG_1 to 14&lt;br&gt;&#xA;...&lt;br&gt;&#xA;DIG_6 to 2 &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Question:&lt;br&gt;&#xA;Suppose I'm interested in lighting (1,1). By the convention, I would have to source current to pin 13 and sink current from pin 9. What two bytes should I send to the MAX7221 to achieve this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Attempt:&lt;br&gt;&#xA;I think it should be 0x01 and 0x80 (0000|0001|1000|0000) with MSB (D15 as it is referred to in the datasheet for MAX7221) on the far left. Code I tried using is below as an image. I checked the signals with a logic analyzer and verified that the SPI protocol was followed (I forgot to take a screenshot but I will provide one when I get a chance). The LED array did not behave as I had anticipated. All LEDs in the matrix were lit! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gzfrp.png&quot; alt=&quot;Program&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7798" OwnerDisplayName="Minh Tran" LastEditorUserId="6452" LastEditDate="2015-03-09T18:30:30.973" LastActivityDate="2015-03-09T18:30:30.973" Title="What bytes do I send to the MAX7221 to light an LED (in an led Matrix)?" Tags="|led|spi|digital|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9154" PostTypeId="2" ParentId="9152" CreationDate="2015-03-09T08:38:57.627" Score="4" Body="&lt;p&gt;An arduino wifi repeater would in theory be very slow. Since you need to record the bit stream to the internal memory, then switch the spi to the transmitter, and send the bit stream, im unsure about what would happen if you miss a few bits in the process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11287&quot; rel=&quot;nofollow&quot;&gt;Arduino Wifi Shield&lt;/a&gt; - the price of a wifi shield 85 usd&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/US-Plug-v2-300Mbps-Wi-Fi-Wireless-AP-Network-Router-Repeater-Booster-Tenda-N301-/291360018585?pt=LH_DefaultDomain_0&amp;amp;hash=item43d6691099&quot; rel=&quot;nofollow&quot;&gt;Wifi repeater ebay&lt;/a&gt; the price of a wifi repeater 22 usd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes me question why one would go through the troubble of making a wifi repeater of an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even investing in a raspberry pi and a wifi dongle would be less expensive.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-03-09T08:38:57.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9155" PostTypeId="1" CreationDate="2015-03-09T09:42:15.547" Score="5" ViewCount="8173" Body="&lt;p&gt;I have been working a lot with the Arduino platform over the last year. Arduino makes it very easy for beginners (in my opinion) to get started and has a large community and a lot of libraries for all kinds of peripherals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I am considering to have a look at mbed, too. &#xA;What are the main differences I would face, both practical and conceptually?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="27346" LastEditDate="2018-12-12T15:11:16.780" LastActivityDate="2020-01-13T23:10:59.783" Title="What are the main differences between Arduino and mbed?" Tags="|mbed|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9156" PostTypeId="1" AcceptedAnswerId="9157" CreationDate="2015-03-09T13:27:54.187" Score="1" ViewCount="3127" Body="&lt;p&gt;I bought some cheap Arduino Nanos from ebay, but the watchdog does not work in them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I removed their old bootloader and burnt a new Nano bootloader from the Arduino IDE. Same problem, the watchdog didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I burned a Uno bootloader to the Arduino Nano and now the watchdog works properly. The only issue here is that in Arduino IDE I now have to tell it that I am programming an Arduino Uno instead of a Nano. So far everything seems to work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there other problems that may arise from using a Uno bootloader in a Nano? I notice that there are some extra analog pins in Arduino Nano, but I will still be able to use them with the Arduino Uno bootloader right?&lt;/p&gt;&#xA;" OwnerUserId="1496" LastEditorUserId="4628" LastEditDate="2018-04-17T16:03:57.893" LastActivityDate="2018-04-17T16:03:57.893" Title="Burning a Uno bootloader into a Nano" Tags="|arduino-uno|bootloader|arduino-nano|isp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9157" PostTypeId="2" ParentId="9156" CreationDate="2015-03-09T13:44:41.247" Score="2" Body="&lt;p&gt;Assuming they're based on the more recent Arduino Nano 3.x series or later, the microcontroller in your Nanos is probably an ATmega328 running at 16 MHz. That's the same as the Uno, so there should be no major problems hopefully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be worth checking that you've got the latest version of the Arduino IDE though. I seem to remember there was a problem in some older bootloaders which prevented the watchdog from working properly.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-09T13:44:41.247" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9158" PostTypeId="1" CreationDate="2015-03-09T13:45:03.313" Score="1" ViewCount="106" Body="&lt;p&gt;I want to create a game using the individual LED &quot;pixels&quot; in a Neopixels 8x8 panel as a game pieces. Any ideas how I could add a touch event to each pixel?&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-03-09T14:54:40.727" Title="Touch the Neopixels" Tags="|arduino-uno|led|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9159" PostTypeId="2" ParentId="9155" CreationDate="2015-03-09T14:07:56.237" Score="8" Body="&lt;p&gt;As both an Mbed user and an Arduino user, this is my perspective on the differences between the platforms.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The IDEs are completely different. The Mbed IDE is an in-browser compiler that allows you to easily import other people's source code. It is a full c/c++ IDE that saves your code to your online Mbed account. You must be signed in to do any development work (requires internet access). Code completion exists, but is clunky. Project format more closely mirrors c/c++ programming than does Arduino's environment.&lt;/li&gt;&#xA;&lt;li&gt;Programming the board is different. The Mbed uses a custom boot loader. The Mbed shows up as a flash drive when you plug it into your computer via USB. You compile your code using the online IDE, download the .hex file, and copy it to the Mbed. It's actually pretty neat, but more time consuming than clicking the 'Upload' button in the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;The Hardware is different. This means different pinouts, as well as different capabilities. Take a look at the &lt;a href=&quot;https://developer.mbed.org/platforms/&quot; rel=&quot;noreferrer&quot;&gt;Mbed platforms&lt;/a&gt; and compare them to the Arduinos. Mbeds are generally more powerful than Arduinos (cpu speed, mem size, build in capabilities).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I use my Mbed when my Arduino isn't powerful enough or fast enough. It would replace Arduinos for me if it wasn't for the online IDE. The IDE is a little awkward to use, and it takes too long to program the board (downloading/copying and pasting is much more inconvenient).&lt;/p&gt;&#xA;&lt;p&gt;I'm able to use all my same sensors and peripherals that I purchased for the Arduino with my Mbed (Except for shields due to the physical layout differences). I sometimes have to rewrite code to get it to work on the Mbed, but that's a good learning exercise.&lt;/p&gt;&#xA;" OwnerUserId="7292" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-09T14:07:56.237" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9160" PostTypeId="2" ParentId="9158" CreationDate="2015-03-09T14:54:40.727" Score="1" Body="&lt;p&gt;Use a &lt;a href=&quot;https://learn.adafruit.com/adafruit-trellis-diy-open-source-led-keypad/overview&quot; rel=&quot;nofollow&quot;&gt;trellis&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or put a resistive touch panel on top of the neopixels. You can connect those using 2 analog and 2 digital pins.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-09T14:54:40.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9161" PostTypeId="1" AcceptedAnswerId="9162" CreationDate="2015-03-09T15:40:44.420" Score="0" ViewCount="95" Body="&lt;p&gt;I am building a project that includes an analog Input and several digital Inputs and Outputs.  All of them connect to ground in some way.  Do I need to worry about voltage, coming from the digital outputs, going to ground, and effecting readings on the analog input?  If so, how do I deal with this?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="42" LastEditDate="2015-03-09T15:49:48.103" LastActivityDate="2020-09-20T03:57:14.500" Title="Do I need to worry about voltage, coming from ground, and effecting an analog input?" Tags="|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9162" PostTypeId="2" ParentId="9161" CreationDate="2015-03-09T16:01:03.667" Score="1" Body="&lt;p&gt;The arduino has build in pull up resistors, it is not a residue voltage coming from ground more than a &quot;not 100% 0 volt&quot; resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though there is built in pull-up resistors one can add additional resistance to the arduino to make sure it will not show a false positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what i have learned, you cannot experience voltage comming from ground (if everything is properly wired), if you want to make sure. Place a diod in the direction of the power flow, to prevent this. &lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-03-09T16:01:03.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9163" PostTypeId="1" AcceptedAnswerId="9185" CreationDate="2015-03-09T16:18:58.043" Score="7" ViewCount="1312" Body="&lt;p&gt;I was wondering if the Arduino is applicable for Industrial monitoring, I want to make a real time status of the presses in our company. I haven't seen or read much about people using Arduino at an Industrial level, most of what I have seen or read are prototype projects.&#xA;I'm new in electronics and don't know if there is a better way of doing this rather than using Arduino. I was thinking of using Arduino Uno and Arduino Ethernet Shield or Wifi Shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on some information on how to start on this is helpful.&lt;/p&gt;&#xA;" OwnerUserId="7787" LastActivityDate="2018-09-11T01:48:22.673" Title="Using Arduino for Industrial process" Tags="|arduino-uno|wifi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9164" PostTypeId="2" ParentId="9095" CreationDate="2015-03-09T16:31:42.363" Score="4" Body="&lt;p&gt;(I'm assuming you're using the official Arduino IDE here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before uploading a sketch, you need to select which port you want to upload to. Within the Arduino IDE, click on the &lt;strong&gt;Tools&lt;/strong&gt; menu and open the &lt;strong&gt;Port&lt;/strong&gt; submenu. Click on the port your Arduino is connected to, such as COM3 or COM4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to ensure the appropriate board type is selected in &lt;strong&gt;Tools -&gt; Board&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should then be able to and upload the sketch.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-09T16:31:42.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9165" PostTypeId="1" AcceptedAnswerId="9166" CreationDate="2015-03-09T16:09:50.237" Score="0" ViewCount="280" Body="&lt;p&gt;I'm trying to communicate with my arduino uno but it seems to have troubles to understand characters. For example, printing things with Serial display weird things, changes characters, removes some. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For exemple printing &quot;test !&quot; every two seconds results in that : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aLxDB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every characters have been removed except &quot;!&quot;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my arduino broken ?  Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="7791" OwnerDisplayName="Michaël Villeneuve" LastActivityDate="2015-03-09T16:47:15.813" Title="Arduino Sainsmart uno communication problem" Tags="|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9166" PostTypeId="2" ParentId="9165" CreationDate="2015-03-09T16:26:08.967" Score="1" Body="&lt;p&gt;You are doing 2 things wrong in your program:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First is using serial.write(), which writes bytes rather than ASCII.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second is you are declaring a string literal as a char instead, you must declare a string using  double quotation marks (which is &quot;) so that your program should read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Test!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you declare 'Test !'  you are doing it wrong, and it will only take the last char in the string, which is '!' - using single quote marks is for a single char declaration, like '!' or 'T', and you can make an array of chars into a string if you wanted, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char array[] = {'T', 'E', 'S', 'T', '!' };&#xA;Serial.write(array, 5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but why would you when the earlier one works better?&lt;/p&gt;&#xA;" OwnerUserId="4179" OwnerDisplayName="KyranF" LastEditorUserId="4179" LastEditDate="2015-03-09T16:47:15.813" LastActivityDate="2015-03-09T16:47:15.813" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9167" PostTypeId="1" AcceptedAnswerId="9168" CreationDate="2015-03-09T16:39:41.733" Score="1" ViewCount="113" Body="&lt;p&gt;I have this function in my code and works fine (it returns a valid value, I put this value into a int variable outside function), but when end the function (or continue the code), my sketch stop/die...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;///FUNCION PARA RSSI XBEE///&#xA;byte rss() {  ///PARA RSSI&#xA;union {byte B; char C;} atCmd[3];&#xA;AtCommandRequest atCmdReq;&#xA;AtCommandResponse atResp;&#xA;byte respLen, *resp, dBm;&#xA;strcpy(&amp;amp;atCmd[0].C, &quot;DB&quot;);&#xA;atCmdReq = AtCommandRequest(&amp;amp;atCmd[0].B);&#xA;atResp = AtCommandResponse();&#xA;xbee.send(atCmdReq);&#xA;if (xbee.readPacket(5000)) {&#xA;   if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {&#xA;       xbee.getResponse().getAtCommandResponse(atResp);&#xA;       if (atResp.isOk()) {&#xA;           respLen = atResp.getValueLength();&#xA;           if (respLen == 1) {&#xA;               resp = atResp.getValue();&#xA;               dBm = resp[0];&#xA;                  return dBm; &#xA;           }&#xA;           else {&#xA;             //  Serial.println(&quot;Unexpected response&quot;);&#xA;           }&#xA;       }&#xA;       else {&#xA;         //  Serial.println(&quot;ERROR&quot;);&#xA;       }&#xA;   }&#xA;   else {&#xA;     //  Serial.println(&quot;Unknown response&quot;);&#xA;   }&#xA;}&#xA;else {&#xA; //  Serial.println(&quot;No response&quot;);&#xA;}&#xA;}///fin rss()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;¿Any tips?&lt;/p&gt;&#xA;" OwnerUserId="4889" LastActivityDate="2015-03-09T16:54:15.347" Title="RSSI stop sketch on a gboard (atmega)" Tags="|arduino-uno|xbee|atmega328|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9168" PostTypeId="2" ParentId="9167" CreationDate="2015-03-09T16:54:15.347" Score="1" Body="&lt;p&gt;Your function is only returning a value when everything works OK. If an error occurs, the problem is reported to serial but it doesn't return anything. It seems likely that this could cause stack corruption which could make the program stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple solution would be to put &lt;code&gt;return 0;&lt;/code&gt; (or some other number) just before the end of the function.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-09T16:54:15.347" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9169" PostTypeId="2" ParentId="9118" CreationDate="2015-03-09T16:56:10.233" Score="0" Body="&lt;p&gt;Using &lt;code&gt;serial.println&lt;/code&gt; instead of &lt;code&gt;serial.write&lt;/code&gt; fixes the issue.&lt;/p&gt;&#xA;" OwnerUserId="7692" LastEditorUserId="6936" LastEditDate="2016-02-21T08:12:55.410" LastActivityDate="2016-02-21T08:12:55.410" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9170" PostTypeId="2" ParentId="1013" CreationDate="2015-03-09T17:07:25.063" Score="4" Body="&lt;pre&gt;&lt;code&gt;String getValue(String data, char separator, int index)&#xA;{&#xA;    int maxIndex = data.length() - 1;&#xA;    int j = 0;&#xA;    String chunkVal = &quot;&quot;;&#xA;&#xA;    for (int i = 0; i &amp;lt;= maxIndex &amp;amp;&amp;amp; j &amp;lt;= index; i++)&#xA;    {&#xA;        chunkVal.concat(data[i]);&#xA;&#xA;        if (data[i] == separator)&#xA;        {&#xA;            j++;&#xA;&#xA;            if (j &amp;gt; index)&#xA;            {&#xA;                chunkVal.trim();&#xA;                return chunkVal;&#xA;            }&#xA;&#xA;            chunkVal = &quot;&quot;;&#xA;        }&#xA;        else if ((i == maxIndex) &amp;amp;&amp;amp; (j &amp;lt; index)) {&#xA;            chunkVal = &quot;&quot;;&#xA;            return chunkVal;&#xA;        }&#xA;    }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7788" LastEditorUserId="23448" LastEditDate="2016-07-19T18:16:23.100" LastActivityDate="2016-07-19T18:16:23.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9171" PostTypeId="1" AcceptedAnswerId="9172" CreationDate="2015-03-09T17:11:26.910" Score="1" ViewCount="698" Body="&lt;p&gt;I am making an RC car , have combined the &lt;strong&gt;Arduino UNO R3&lt;/strong&gt; with the &lt;strong&gt;AR 293d&lt;/strong&gt;, and pluged in the HC-SR04 sensor to the SRO4 hole at the left top corner in the below graph. However, besides one sensor  I &lt;strong&gt;would like to add three more HC-SR04 sensor&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference:&#xA;&lt;a href=&quot;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6TtmL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problems are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) is the board sufficient to plug three more sensor ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) or what extra board I need if not sufficient and how to combine those board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) also, can I plug in other hole?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for helping&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update: breadboard connection&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have to get a stuff like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.tandyonline.co.uk/small-solderless-breadboard.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.tandyonline.co.uk/small-solderless-breadboard.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and one more question, sorry for begin newbie, there are many holes on breadboard, which hole I should connect those three sensor on it, and the hold I should connect the breadboard with the AR-293D board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for programming, is there any way to get the pin at the breadboard as I have read some program before, the pin is assign with a number? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks again for helping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hni7b.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7692" LastEditorUserId="7692" LastEditDate="2015-03-10T02:20:31.163" LastActivityDate="2015-03-10T14:27:57.503" Title="How to add Ultrasonic Sensor to the board?" Tags="|arduino-uno|serial|sensors|pins|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9172" PostTypeId="2" ParentId="9171" CreationDate="2015-03-09T17:20:47.193" Score="3" Body="&lt;p&gt;1) Not really. You have so little space and you have to selder them. Try using wires&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If you want it to be flexible use a sandard solderless breadoard on the center of the car and then with male-female jumperwires try connecting them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) The board has traces. That means some holes have a very specific purpose.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Updated:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;On every breadboard the holes are connected verticaly. For example, in the image from your breadboard you posted 1A, 1B, 1C, 1D and 1E are connected together.&#xA;If you would like to have all of the 3 sensors better use wires and then atach them on to your breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture: &#xA;&lt;a href=&quot;https://www.dropbox.com/s/3ij4w6eytio8p08/Screen%2016-25-31.png?dl=0&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/3ij4w6eytio8p08/Screen%2016-25-31.png?dl=0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="6969" LastEditDate="2015-03-10T14:27:57.503" LastActivityDate="2015-03-10T14:27:57.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9174" PostTypeId="1" AcceptedAnswerId="9178" CreationDate="2015-03-09T18:01:04.697" Score="8" ViewCount="22707" Body="&lt;p&gt;How can I print to the serial monitor a string or just single character followed by a variable like &quot;L 55&quot;&lt;/p&gt;&#xA;" OwnerUserId="7790" LastActivityDate="2018-01-08T21:40:30.433" Title="Serial Print, String And Variable On Same Line" Tags="|serial|softwareserial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9175" PostTypeId="1" AcceptedAnswerId="9186" CreationDate="2015-03-09T18:23:24.873" Score="12" ViewCount="9998" Body="&lt;p&gt;im planing to make my very own arduino design based on the Arduino PRO mini. I picked this board instead of the UNO mostly because it's way more simpler compared with the UNO since the USB-to-Serial part is missing. As many of you know the MINI uses the 328P-AU which is the SMD version of the 328P however since the AU version is too small for me i would like to use the PU (UNO's chip) instead. From the datasheets the only difference is a small change in the pins position. And the one million dollar question is: Is there any difference on those 2 chips? If i try to use the same design just with the PU model is it gonna work?&lt;/p&gt;&#xA;" OwnerUserId="6969" OwnerDisplayName="Meletis Flevarakis" LastEditorUserId="6452" LastEditDate="2015-03-10T14:17:38.550" LastActivityDate="2015-03-10T14:17:38.550" Title="ATMega328P-PU and 328P-AU" Tags="|pins|atmega328|system-design|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9176" PostTypeId="2" ParentId="9175" CreationDate="2015-03-09T18:31:28.797" Score="0" Body="&lt;p&gt;I would go with the PU version because you can work on a breadboard with it for testing. If you are going to make a surface mount this to a PCB then use the AU. Regarding the actual difference forgetting about form factor, there is none.&lt;/p&gt;&#xA;" OwnerUserId="7790" LastActivityDate="2015-03-09T18:31:28.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9177" PostTypeId="2" ParentId="9175" CreationDate="2015-03-09T18:41:48.650" Score="5" Body="&lt;p&gt;There is no difference as far as Arduino is concerned. I think the AU has a couple extra pins (analog ins), that you might want to route to header locations in a surface mount design, but if your design is based on an Uno, them you can also just leave those pins disconnected with no impact.&lt;/p&gt;&#xA;" OwnerUserId="4805" LastActivityDate="2015-03-09T18:41:48.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9178" PostTypeId="2" ParentId="9174" CreationDate="2015-03-09T18:51:46.177" Score="10" Body="&lt;pre&gt;&lt;code&gt;int Var = 55;&#xA;//Do it in 2 lines e.g.&#xA;Serial.print(&quot;L &quot;);     // String&#xA;Serial.println(Var);    // Print Variable on same line then send a line feed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-03-09T18:51:46.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9179" PostTypeId="1" CreationDate="2015-03-09T20:52:11.550" Score="2" ViewCount="891" Body="&lt;p&gt;I'm using the ModbusMaster.h library on a project, with arduino-uno and a TTL/RS-485 converter, and the function has to identify the slave that it is communicating. The slaves goes from 1 to 16. After I've begun the connection,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ModbusMaster node(1);&#xA;node.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to send a message, and if this massage returns an error, I have to change the slave number, until I got an valid answer. But I didn't find any functions to close this connection, or to delete it, I even have tried,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete &amp;amp;node;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it didn't work. I'm trying to close this connection so I could begin another one with another node, because I didn't find a function to change the slave number.&lt;/p&gt;&#xA;" OwnerUserId="7168" LastActivityDate="2018-09-28T21:46:38.780" Title="ModbusMaster.h - changing node" Tags="|arduino-uno|modbus|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9180" PostTypeId="1" CreationDate="2015-03-09T20:57:20.873" Score="1" ViewCount="245" Body="&lt;p&gt;...and whack a stripped usb cable straight into a prototype board? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;by bypass having to use an arduino I mean any kind of sheild? polulu would be perfect but im trying to avoid needing any of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue for finding tutorials and documentation on the subject is not quite knowing what keywords to search for, could someone point me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="7796" LastActivityDate="2015-12-08T20:23:51.687" Title="I want a couple of servos to listen for P.C. input (data from OSC protocol), can I bypass having to use an Arduino?" Tags="|programming|servo|usb|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9181" PostTypeId="1" CreationDate="2015-03-02T22:19:57.937" Score="7" ViewCount="36752" Body="&lt;p&gt;We have many Arduinos and we will be putting each of them in a cubicle. All of them are connected to only one PC. The PC will stand as a server were you can control your Arduino there.&lt;/p&gt;&#xA;" OwnerDisplayName="Ashley Templado" LastEditorUserId="220" LastEditDate="2015-03-09T23:56:18.930" LastActivityDate="2019-08-30T15:45:07.873" Title="Is it possible to connect many arduino uno in one pc?" Tags="|serial|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9182" PostTypeId="2" ParentId="9181" CreationDate="2015-03-03T06:04:09.780" Score="8" Body="&lt;p&gt;Yes, you can connect multiple Arduino UNO (USB) boards to a single PC. There's a simple way and a more advanced way to manage it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple way is, having multiple boards plugged in, but using only one &lt;code&gt;Arduino Software&lt;/code&gt; IDE to control one board at a time. (&lt;em&gt;IDE = Integrated Development Environment. Some elements of the Arduino system use non-standard technical terms.&lt;/em&gt;) &lt;strong&gt;Use the &lt;code&gt;Tools &amp;gt; Port&lt;/code&gt; menu to select which one of the attached boards to control.&lt;/strong&gt; The selected board type and port appear in the lower right status bar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more advanced way to manage multiple boards, is to open multiple Arduino Software IDE instances -- each instance has its own independent &lt;code&gt;Tools &amp;gt; Port&lt;/code&gt; setting. You could then edit, verify, and upload two different &quot;sketches&quot; (&lt;em&gt;programs&lt;/em&gt;) to two different boards, without losing your place and without having to constantly change the Tools &gt; Port setting. This would be convenient if you were developing a communications protocol between two or more boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This multiple-ports technique won't work unless you launch another instance of the Arduino Software IDE, without closing the first one.&lt;/strong&gt; It isn't enough to use the &lt;code&gt;File&lt;/code&gt; menu to open another window, because then you just get another window that shares the same &lt;code&gt;Tools &amp;gt; Ports&lt;/code&gt; setting. Changing the ports setting on one window, changes the setting on all of the windows that belong to that instance. To support multiple boards at the same time, you have to actually launch the Arduino Software IDE again, without closing the first one, to create a second instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually you'd expect each window would represent a unique document, and they'd all be related to the application. But Arduino Software IDE has a hidden dependency between its windows. Whenever you restart the IDE, that opens a new and invisible &lt;em&gt;instance&lt;/em&gt; of the IDE, where it remembers the board and port settings. If you use the File menu to open a new window, that new window is still part of the same IDE. So changing the &lt;code&gt;Tools &amp;gt; Port&lt;/code&gt; setting on one window, changes that setting for all of the windows that belong to that instance of the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you restart the Arduino Software IDE (e.g. Windows Start Menu &gt; Arduino-1.6.0), without closing the previously opened IDE, then you get a second instance. If you pay attention to the port setting visible on the lower right status bar of each window, you can distinguish which windows belong to which IDE instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time you launch the Arduino Software IDE, you start a new &lt;em&gt;instance&lt;/em&gt; of the software, that can talk to one board. Each instance of the IDE can have an unlimited number of windows, but they all share the same Tools &gt; Port setting. If you re-launch the Arduino Software IDE again without closing it first, then you get a second instance that can have a different Tools &gt; Port setting, and thus control another board at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Verified on Windows 7, Arduino Software IDE 1.6.0, with two Arduino UNO revision R2 boards (firmware rev 0001), Arduino device driver 1.0.0.0.&lt;/p&gt;&#xA;" OwnerUserId="7174" OwnerDisplayName="MarkU" LastActivityDate="2015-03-03T06:04:09.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9183" PostTypeId="1" AcceptedAnswerId="9187" CreationDate="2015-03-09T22:26:29.240" Score="3" ViewCount="1087" Body="&lt;p&gt;I am working with relays and I noticed that connecting the trigger pin to ground (or a digital pin set to LOW) is not the same as having the trigger connected to anything.  For the digital output pins, how is LOW different than no connection?  Is there actually a current flowing into the LOW pin, or is there a tiny current flowing into the relay?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is Ground and LOW the same voltage?  &lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-03-12T00:03:03.337" Title="For the digital output pins, how is LOW different than no connection?" Tags="|digital|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9184" PostTypeId="2" ParentId="9183" CreationDate="2015-03-09T22:31:59.923" Score="0" Body="&lt;p&gt;Ground and LOW are very, very close in voltage. They are the same when no current is being sunk into the output (LOW sinks current from higher voltages, HIGH sources current to lower voltages), but the voltage rises as the current does (the output has a resistance of about 25ohm).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-09T22:31:59.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9185" PostTypeId="2" ParentId="9163" CreationDate="2015-03-09T22:35:22.823" Score="7" Body="&lt;p&gt;I wouldn't use the Arduino in an industrial environment, as I wouldn't trust its PCB to be able to handle much noise. Use the Arduino and shields to prototype your application, and then move to a circuit board that uses proper techniques suited to an industrial environment.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-09T22:35:22.823" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9186" PostTypeId="2" ParentId="9175" CreationDate="2015-03-09T22:56:19.027" Score="10" Body="&lt;p&gt;The &lt;code&gt;-AU&lt;/code&gt; and &lt;code&gt;-PU&lt;/code&gt; suffixes on the part name indicate different packages. The former is used for the &quot;32A&quot; package (32-lead TQFP), and the latter is used for the &quot;28P3&quot; package (28-lead DIP). In plain English, the &lt;code&gt;-AU&lt;/code&gt; is a surface-mount part, and the &lt;code&gt;-PU&lt;/code&gt; is a breadboard-friendly chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as functionality, there is virtually no difference. The 32A package exposes pins for ADC6 and ADC7, which are not available on the 28P3 package, but they are otherwise identical. (Note that these pins are &lt;em&gt;only&lt;/em&gt; used for the ADCs; they are not a member of any port, and thus cannot be used for digital I/O.)&lt;/p&gt;&#xA;" OwnerDisplayName="user7800" LastActivityDate="2015-03-09T22:56:19.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9187" PostTypeId="2" ParentId="9183" CreationDate="2015-03-09T23:00:59.780" Score="3" Body="&lt;p&gt;&lt;em&gt;(Edit for clarification: I've assumed in this answer that you're asking about the difference between connecting the relay to ground/LOW vs. connecting the relay to nothing at all. I've also assumed by the word &quot;trigger&quot; that your relay has some kind of digital actuation built-in, such as a transistor, or that it's simply a Solid State Relay.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If something is unconnected, it is described as 'floating'. This means there could be random voltage spikes in it caused by nearby electromagnetic fields, making it appear to be switching on/off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting something to ground or LOW can stop this from happening by drawing away any induced currents.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-10T09:20:41.110" LastActivityDate="2015-03-10T09:20:41.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9188" PostTypeId="2" ParentId="9095" CreationDate="2015-03-10T00:00:27.623" Score="1" Body="&lt;p&gt;Did you try with code bender. In my experience, uploading through the code bender works all the time even if it fails with Arduino IDE&lt;/p&gt;&#xA;" OwnerUserId="7802" LastActivityDate="2015-03-10T00:00:27.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9189" PostTypeId="1" AcceptedAnswerId="9380" CreationDate="2015-03-10T05:30:00.517" Score="3" ViewCount="338" Body="&lt;p&gt;I've done some basic apps with NodeJS firmata where I can connect to my Arduino Uno and do the basics like reading a pin or doing a servo write. I'd like to go further and play with some different sensors from vendors like Adafruit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many such sensors appear to come with their own Arduino libraries. Using NodeJS firmata to communicate with my Uno, could I somehow use the sensor libraries? Maybe by including their header files in the Standard Firmata sketch before uploading or...? But then I don't know how I'd get at their methods from my NodeJS app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better, I'd love a little direction on how to go about using an Arduino sensor library in a sketch, and use Galileo-IO to interact with the sensor that way, if possible.&lt;/p&gt;&#xA;" OwnerUserId="4401" LastEditorUserId="4401" LastEditDate="2015-03-16T02:45:41.737" LastActivityDate="2015-03-16T11:05:03.507" Title="NodeJS (Galileo-IO) + Arduino sensor library" Tags="|sensors|library|arduino-galileo|node.js|johnny-five|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9190" PostTypeId="2" ParentId="3422" CreationDate="2015-03-10T05:44:38.480" Score="1" Body="&lt;p&gt;There are several libraries which will do this for you. Basically, you should upload a special sketch onto the Arduino, which listens to the serial port, and performs the I/O that the Linux chip requests. Libraries which can do this are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/Firmata&quot; rel=&quot;nofollow&quot;&gt;Firmata&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://tavendo.com/blog/post/arduino-yun-with-autobahn/&quot; rel=&quot;nofollow&quot;&gt;Autobahn&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.linino.org/&quot; rel=&quot;nofollow&quot;&gt;LininoIO&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7012" LastActivityDate="2015-03-10T05:44:38.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9192" PostTypeId="1" AcceptedAnswerId="9376" CreationDate="2015-03-10T09:46:43.117" Score="0" ViewCount="2314" Body="&lt;p&gt;Im using arduino (R2) uno board and my pc is running 64bit ubuntu 14.4.&#xA;I was previously using arduino on ubuntu 10.04 for a long time and got no error. I recently moved to 14.4 from 10.4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed arduino using this command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install arduino arduino-core&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;later arduino appeared, but was not working. According to &lt;a href=&quot;http://vishnuvarkala.blogspot.in/2012/07/arduino-ide-not-detecting-serial-port.html&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt;, i was able to launch the IDE on mouse click. I then tried to upload servo examples, i get following errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Binary sketch size: 1,056 bytes (of a 32,256 byte maximum)&#xA;ioctl(&quot;TIOCMSET&quot;): Broken pipe&#xA;ioctl(&quot;TIOCMGET&quot;): Input/output error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the same error for even an Led blinking program too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 1:&lt;/strong&gt; (after Edgar's comment)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on terminal i get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~$ /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/Servo /tmp/build4933543797518254688.tmp/Sweep.cpp -o /tmp/build4933543797518254688.tmp/Sweep.cpp.o&#xA;avr-g++: error: /tmp/build4933543797518254688.tmp/Sweep.cpp: No such file or directory&#xA;avr-g++: fatal error: no input files&#xA;compilation terminated.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But on the IDE, after enabling verbos i get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/Servo /tmp/build4933543797518254688.tmp/Sweep.cpp -o /tmp/build4933543797518254688.tmp/Sweep.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/Servo -I/usr/share/arduino/libraries/Servo/utility /usr/share/arduino/libraries/Servo/Servo.cpp -o /tmp/build4933543797518254688.tmp/Servo/Servo.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/wiring_analog.c -o /tmp/build4933543797518254688.tmp/wiring_analog.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/avr-libc/malloc.c -o /tmp/build4933543797518254688.tmp/malloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/avr-libc/realloc.c -o /tmp/build4933543797518254688.tmp/realloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c -o /tmp/build4933543797518254688.tmp/wiring_digital.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/wiring_pulse.c -o /tmp/build4933543797518254688.tmp/wiring_pulse.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/wiring.c -o /tmp/build4933543797518254688.tmp/wiring.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/wiring_shift.c -o /tmp/build4933543797518254688.tmp/wiring_shift.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/WInterrupts.c -o /tmp/build4933543797518254688.tmp/WInterrupts.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/Stream.cpp -o /tmp/build4933543797518254688.tmp/Stream.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/HID.cpp -o /tmp/build4933543797518254688.tmp/HID.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/Print.cpp -o /tmp/build4933543797518254688.tmp/Print.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/WMath.cpp -o /tmp/build4933543797518254688.tmp/WMath.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/CDC.cpp -o /tmp/build4933543797518254688.tmp/CDC.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/new.cpp -o /tmp/build4933543797518254688.tmp/new.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp -o /tmp/build4933543797518254688.tmp/HardwareSerial.cpp.o &#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function ‘void store_char(unsigned char, ring_buffer*)’:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp:100:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]&#xA;   if (i != buffer-&amp;gt;tail) {&#xA;                    ^&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function ‘void __vector_18()’:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp:129:21: warning: unused variable ‘c’ [-Wunused-variable]&#xA;       unsigned char c = UDR0;&#xA;                     ^&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function ‘void HardwareSerial::begin(long unsigned int, byte)’:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp:370:11: warning: unused variable ‘current_config’ [-Wunused-variable]&#xA;   uint8_t current_config;&#xA;           ^&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function ‘virtual size_t HardwareSerial::write(uint8_t)’:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp:469:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]&#xA;   while (i == _tx_buffer-&amp;gt;tail)&#xA;                           ^&#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/main.cpp -o /tmp/build4933543797518254688.tmp/main.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp -o /tmp/build4933543797518254688.tmp/Tone.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/IPAddress.cpp -o /tmp/build4933543797518254688.tmp/IPAddress.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/USBCore.cpp -o /tmp/build4933543797518254688.tmp/USBCore.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /usr/share/arduino/hardware/arduino/cores/arduino/WString.cpp -o /tmp/build4933543797518254688.tmp/WString.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/wiring_analog.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/malloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/realloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/wiring_digital.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/wiring_pulse.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/wiring.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/wiring_shift.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/WInterrupts.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/Stream.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/HID.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/Print.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/WMath.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/CDC.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/new.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/HardwareSerial.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/main.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/Tone.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/IPAddress.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/USBCore.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4933543797518254688.tmp/core.a /tmp/build4933543797518254688.tmp/WString.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build4933543797518254688.tmp/Sweep.cpp.elf /tmp/build4933543797518254688.tmp/Sweep.cpp.o /tmp/build4933543797518254688.tmp/Servo/Servo.cpp.o /tmp/build4933543797518254688.tmp/core.a -L/tmp/build4933543797518254688.tmp -lm &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build4933543797518254688.tmp/Sweep.cpp.elf /tmp/build4933543797518254688.tmp/Sweep.cpp.eep &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build4933543797518254688.tmp/Sweep.cpp.elf /tmp/build4933543797518254688.tmp/Sweep.cpp.hex &#xA;Binary sketch size: 2,554 bytes (of a 32,256 byte maximum)&#xA;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build4933543797518254688.tmp/Sweep.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/username/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: ser_open(): can't open device &quot;/dev/ttyACM0&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; (tried again, this time i get &quot;broken pipe&quot;. Led 13 blinks like crazy and my servo sounds different, no movement but continues sound)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;.&#xA;.&#xA;avrdude: avr_read(): skipping page 253: no interesting data&#xA;avrdude: avr_read(): skipping page 254: no interesting data&#xA;avrdude: avr_read(): skipping page 255: no interesting data&#xA;avrdude: verifying ...&#xA;avrdude: 2554 bytes of flash verified&#xA;avrdude: Send: Q [51]   [20] &#xA;avrdude: Recv: . [14] &#xA;avrdude: Recv: . [10] &#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__ -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/Servo /tmp/build4258280580047414287.tmp/Sweep.cpp -o /tmp/build4258280580047414287.tmp/Sweep.cpp.o &#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/Servo/Servo.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/wiring_analog.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/malloc.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/realloc.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/wiring_digital.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/wiring_pulse.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/wiring.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/wiring_shift.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/WInterrupts.c.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/Stream.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/HID.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/Print.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/WMath.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/CDC.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/new.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/HardwareSerial.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/main.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/Tone.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/IPAddress.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/USBCore.cpp.o&#xA;  Using previously compiled: /tmp/build4258280580047414287.tmp/WString.cpp.o&#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/wiring_analog.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/malloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/realloc.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/wiring_digital.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/wiring_pulse.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/wiring.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/wiring_shift.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/WInterrupts.c.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/Stream.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/HID.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/Print.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/WMath.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/CDC.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/new.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/HardwareSerial.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/main.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/Tone.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/IPAddress.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/USBCore.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-ar rcs /tmp/build4258280580047414287.tmp/core.a /tmp/build4258280580047414287.tmp/WString.cpp.o &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build4258280580047414287.tmp/Sweep.cpp.elf /tmp/build4258280580047414287.tmp/Sweep.cpp.o /tmp/build4258280580047414287.tmp/Servo/Servo.cpp.o /tmp/build4258280580047414287.tmp/core.a -L/tmp/build4258280580047414287.tmp -lm &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build4258280580047414287.tmp/Sweep.cpp.elf /tmp/build4258280580047414287.tmp/Sweep.cpp.eep &#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build4258280580047414287.tmp/Sweep.cpp.elf /tmp/build4258280580047414287.tmp/Sweep.cpp.hex &#xA;Binary sketch size: 2,554 bytes (of a 32,256 byte maximum)&#xA;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build4258280580047414287.tmp/Sweep.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/username/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;ioctl(&quot;TIOCMSET&quot;): Broken pipe&#xA;ioctl(&quot;TIOCMGET&quot;): Input/output error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6565" LastEditorUserId="6565" LastEditDate="2015-03-13T04:22:51.420" LastActivityDate="2015-03-16T09:14:15.973" Title="Arduino on ubuntu 14.4 gives &quot;Broken pipe&quot; and &quot;Input/output error&quot;" Tags="|arduino-uno|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="9193" PostTypeId="1" AcceptedAnswerId="9221" CreationDate="2015-03-10T12:08:44.220" Score="1" ViewCount="1490" Body="&lt;p&gt;I am working on an Arduino Uno and CC3000 WiFi shield. I interfaced it over my Arduino and added the SparkFun library &lt;code&gt;SFE_CC3000_Library&lt;/code&gt;. Then I opened the TestBoard example, but it hangs on setup in the first command &lt;code&gt;wifi.init()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem, and how can I enable debug mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000.h&amp;gt;&#xA;#include &amp;lt;utility/netapp.h&amp;gt;&#xA;&#xA;#define DEBUG     1&#xA;// Pins&#xA;#define CC3000_INT      2   // Needs to be an interrupt pin (D2/D3)&#xA;#define CC3000_EN       7   // Can be any digital pin&#xA;#define CC3000_CS       10  // Preferred is pin 10 on Uno&#xA;&#xA;// Constants&#xA;#define FW_VER_LEN      2   // Length of firmware version in bytes&#xA;#define MAC_ADDR_LEN    6   // Length of MAC address in bytes&#xA;&#xA;// Global Variables&#xA;SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);&#xA;&#xA;void setup() {&#xA;&#xA;  int i;&#xA;  unsigned char fw_ver[FW_VER_LEN];&#xA;  unsigned char mac_addr[MAC_ADDR_LEN];&#xA;&#xA;  // Initialize Serial port&#xA;  Serial.begin(115200);&#xA;  Serial.println();&#xA;  Serial.println(&quot;----------------------------&quot;);&#xA;  Serial.println(&quot;SparkFun CC3000 - Board Test&quot;);&#xA;  Serial.println(&quot;----------------------------&quot;);&#xA;&#xA;  // Initialize CC3000 (configure SPI communications)&#xA;  if ( wifi.init() ) {&#xA;    digitalWrite(13, HIGH);&#xA;    Serial.println(&quot;CC3000 initialization complete&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Something went wrong during CC3000 init!&quot;);&#xA;  }&#xA;&#xA;  // Read and display CC3000 firmware version&#xA;  if ( wifi.getFirmwareVersion(fw_ver) ) {&#xA;    Serial.print(&quot;Firmware version: &quot;);&#xA;    Serial.print(fw_ver[0], DEC);&#xA;    Serial.print(&quot;.&quot;);&#xA;    Serial.print(fw_ver[1], DEC);&#xA;    Serial.println();&#xA;  } else {&#xA;    Serial.println(&quot;Could not read firmware version from CC3000&quot;);&#xA;  }    &#xA;&#xA;  // Read and display CC3000 MAC address&#xA;  if ( wifi.getMacAddress(mac_addr) ) {&#xA;    Serial.print(&quot;MAC address: &quot;);&#xA;    for ( i = 0; i &amp;lt; MAC_ADDR_LEN; i++ ) {&#xA;      if ( mac_addr[i] &amp;lt; 0x10 ) {&#xA;        Serial.print(&quot;0&quot;);&#xA;      }&#xA;      Serial.print(mac_addr[i], HEX);&#xA;      if ( i &amp;lt; MAC_ADDR_LEN - 1 ) {&#xA;        Serial.print(&quot;:&quot;);&#xA;      }&#xA;    }&#xA;    Serial.println();&#xA;  } else {&#xA;    Serial.println(&quot;Could not read MAC address from CC3000&quot;);&#xA;  } &#xA;&#xA;  // Done!&#xA;  Serial.println(&quot;Finished board test&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Do nothing&#xA;  delay(1000);&#xA;  Serial.println(&quot;Loop_Problem&quot;);&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7807" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:19.237" LastActivityDate="2017-02-11T11:15:13.877" Title="Arduino Uno with CC3000 WiFi Shield cannot be initialized" Tags="|arduino-uno|c++|wifi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9194" PostTypeId="1" CreationDate="2015-03-10T14:38:57.117" Score="1" ViewCount="41" Body="&lt;p&gt;I would like to add three more HC-SR04 sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have combined the Arduino UNO R3 with the AR 293d(refer to below graph), and pluged in one HC-SR04 sensor to the SRO4 hole at the left top corner. &lt;strong&gt;So I need to find the holes for t3 more sensor&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oKwcg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6TtmL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done some research already , for the connection , found more document&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HC-SR04 Arduino&#xA;Vcc     +5V&#xA;Trig    GPIO&#xA;Echo    GPIO&#xA;GND     GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ULEWo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The questions are ,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) From the above graph, is that mean I can only add two more sensor to the board , since there are only 2 more 5V, GND , 12 , 13 pins (at the top and bottom holes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How can I connect them separately ? That means, what I need to connect from sensor to the board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) If I need other board eg. breadboard to connect them, How should I connect sensor to breadboard and how can I connect it with the main board(AR 293d)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot for helping. Any answer is useful for me&lt;/p&gt;&#xA;" OwnerUserId="7692" LastActivityDate="2015-03-10T14:38:57.117" Title="Adding HC-SR04 ultrasonic sensor to the board" Tags="|arduino-uno|sensors|pins|wires|" AnswerCount="0" CommentCount="3" ClosedDate="2015-03-11T01:13:08.183" ContentLicense="CC BY-SA 3.0" />
  <row Id="9196" PostTypeId="2" ParentId="4835" CreationDate="2015-03-10T21:30:39.493" Score="-1" Body="&lt;p&gt;Bluetooth support on OpenWRT is broken, simply does not work.&lt;/p&gt;&#xA;" OwnerUserId="7810" LastActivityDate="2015-03-10T21:30:39.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9197" PostTypeId="2" ParentId="9163" CreationDate="2015-03-10T23:44:14.973" Score="12" Body="&lt;p&gt;I don't see any reason &lt;em&gt;not&lt;/em&gt; to use Arduino in an industrial, engineering, or laboratory environment, if it meets your needs and does the job well. It is highly recommended, however, that you provide &lt;em&gt;some&lt;/em&gt; sort of pin protection to keep industrial noise or voltage spikes from frying pins. Minimum pin protection could consist of using &lt;a href=&quot;http://www.electricrcaircraftguy.com/2015/06/arduino-quick-tip-io-pin-overvoltage-protection-w-single-resistor.html&quot; rel=&quot;noreferrer&quot;&gt;current-limiting resistors&lt;/a&gt; (or better yet, the other, &lt;a href=&quot;http://www.scienceprog.com/using-current-limiting-resistors-on-avr-io-pins/&quot; rel=&quot;noreferrer&quot;&gt;more robust techniques shown here&lt;/a&gt;) on pins used for output and input signals. Optical isolation is also a good option, especially if potentially dangerous voltages are being used. Lastly, after you prototype and test your Arduino setup you should solder the wires to the Arduino and provide a protective case. You don't want to accidentally fry the Arduino or a pin via accidental static discharge (hence the case, and pin protection above), and you don't want jumper wires vibrating loose and connections slowly oxidizing over time and loosing electrical connectivity in any type of industrial or laboratory application that is expected to be used regularly (hence replacing your jumper wires with soldered wires). Shields, however, are prob. ok for low-humidity and room-temperature environments, as they are generally much more secure and solidly connected than individual jumper wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can solder wires to &lt;em&gt;any&lt;/em&gt; Arduino, even the Uno, Leonardo, or Mega, for example, simply by soldering to the exposed portions of the pins on the bottom of the board. You can also cut off and desolder the female headers and either solder directly to the holes, or solder on male headers that you then solder to other PCBs. I especially like the &lt;a href=&quot;http://www.mouser.com/search/refine.aspx?Ntk=P_MarCom&amp;amp;Ntt=142053320&quot; rel=&quot;noreferrer&quot;&gt;Arduino Nano&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/products/11113&quot; rel=&quot;noreferrer&quot;&gt;Pro Mini&lt;/a&gt;, and &lt;a href=&quot;https://www.adafruit.com/products/1086&quot; rel=&quot;noreferrer&quot;&gt;Micro&lt;/a&gt; since they are small, have exposed holes or male pin headers, and can easily be soldered onto a professionally-manufactured circuit board or cheap protoboard, for better mounting in a final application. Keep reading below for more details on this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am an aerospace research engineer and use Arduino in my line of work regularly to solve problems. Here are some examples of current applications in use today, that I implemented, that are based on and using Arduino boards:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;sensorless brushless motor RPM sensor, motor commander, and data acquisition device&lt;/strong&gt; for bench-top testing&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;linear actuator closed-loop controller&lt;/strong&gt; (linear stepping resolution is 0.01mm [10um], full moving range is 0 to 15mm); the Arduino commands the actuator driver board via a custom PWM signal using the Timer1 library (&lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;noreferrer&quot;&gt;http://playground.arduino.cc/code/timer1&lt;/a&gt;); position is read via a custom quadrature encoder reader algorithm on the arduino; the actuator is used for very precise aiming of certain instruments; the $30 Arduino is taking the place of a $500 board that the actuator manufacturer makes, and the Arduino gives us much more functionality than the $500 board would give us. The Arduino and actuator will be used to precisely aim a laser for experiments in a wind tunnel.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;flight controller interfaces&lt;/strong&gt; between MATLAB and off-the-shelf Radio Control transmitter (read and write RC PWM &amp;amp; PPM communication signals)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Professional film studio communication interface on robotic, drivable camera system&lt;/strong&gt; (&lt;a href=&quot;http://bit.ly/HollywoodWirelessCtrlBoardOverview&quot; rel=&quot;noreferrer&quot;&gt;info sheet &amp;amp; video&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Those are just a few cases. If it works, do it.  Once you prototype with a solderless breadboard, however, it is recommended that you at least hand-solder the final configuration to a permanent prototyping board, to make it more durable and noise-resistant (ie--primarily: so that it will have solid connections that can't corrode, break, come apart, or vibrate free easily).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a soldering article I wrote (&lt;a href=&quot;http://electricrcaircraftguy.blogspot.com/2014/08/recommended-soldering-kit.html#.VP-JCPzF-So&quot; rel=&quot;noreferrer&quot;&gt;http://electricrcaircraftguy.blogspot.com/2014/08/recommended-soldering-kit.html#.VP-JCPzF-So&lt;/a&gt;). see the links at the bottom for recommended soldering tutorials. The one about how to make &quot;solder tracks&quot; was especially useful to me once I got past the breadboard stage and started prototyping things on double-sided perf board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some double-sided prototyping boards (or &quot;perf boards&quot;) to look into once you get to this stage: (Ebay search for &quot;double sided pcb&quot;) &lt;a href=&quot;http://www.ebay.com/sch/i.html?_from=R40&amp;amp;ghostText=&amp;amp;_sacat=0&amp;amp;_nkw=double+sided+pcb&amp;amp;rt=nc&amp;amp;LH_BIN=1&quot; rel=&quot;noreferrer&quot;&gt;http://www.ebay.com/sch/i.html?_from=R40&amp;amp;ghostText=&amp;amp;_sacat=0&amp;amp;_nkw=double+sided+pcb&amp;amp;rt=nc&amp;amp;LH_BIN=1&lt;/a&gt; -- get the ones with all the little holes in them. You can put the whole thing in a plastic case if you want too. You can permanently solder an Arduino (esp. the Nanos or Micros more easily) to one of these perf boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another example of double-sized perf board. (image source: &lt;a href=&quot;http://www.elecfreaks.com/store/doublesided-protoboard-8cm-x-12cm-p-410.html&quot; rel=&quot;noreferrer&quot;&gt;http://www.elecfreaks.com/store/doublesided-protoboard-8cm-x-12cm-p-410.html&lt;/a&gt;)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/cktGU.jpg&quot; alt=&quot;Here&amp;#39;s an example of double-sized perf board &quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Professional PCBs:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to make more than a few of some device, hand-soldering wires and pieces all over a perfboard can get to be VERY tedious. In this case, you need to design a more professional PCB with custom traces and pads and layout and all for your project. If you don't have PCB-designing skills yet with a professional tool like Eagle or KiCad, you can use Fritzing (&lt;a href=&quot;http://fritzing.org/home/&quot; rel=&quot;noreferrer&quot;&gt;http://fritzing.org/home/&lt;/a&gt;) to design a PCB, and then send it off to a company like OshPark (&lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;noreferrer&quot;&gt;https://oshpark.com/&lt;/a&gt;) for high-quality, reasonably-priced, low-quantity US-based manufacturing---or send it off to the Fritzing Fab lab in Germany for high-quality PCB manufacturing that supports the Fritzing project. Lastly, for a couple really inexpensive Chinese options, look at ITEAD Studio and Seeedstudio. Fritzing and any other PCB CAD software tool can output the necessary Gerber files for manufacturing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Quick tip&lt;/em&gt;: when designing a PCB, don't use &lt;em&gt;any&lt;/em&gt; 90 deg corners for your traces. They can act as antennas (sending &lt;em&gt;or&lt;/em&gt; receiving) and cause electromagnetic (including radio) interference and noise. Use multiple 45 deg edges and corners instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get your boards back, solder your Arduino to them, and solder any extra parts or hardware to them you need as well. Now you have quite a professional product, even if it has an Arduino soldered right to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In summary, yes I think Arduino is great. Without it, I wouldn't know how to even blink an LED or load a single code to a microcontroller, because getting into using microcontrollers was just to enigmatic, difficult, and complicated for someone not professionally trained in it, such as an Aeronautical engineer like myself.  With Arduino, however, I learned to build up my skills and solve real-world problems in professional environments.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I am very grateful to Massimo Banzi, David A. Mellis, and others who have made Arduino possible. It has changed my life and my ability to &lt;em&gt;be&lt;/em&gt; useful in this life.  My favorite part about it is that even though it is a tool meant to get the non-programmer or lay-person to do basic stuff like blink a light using poorly-written blocking code, it has opened up my world beyond what I ever imagined before, and it is a fully-capable microcontroller that doesn't permanently hide away the low-level stuff. The low-level AVR functions, registers, etc are ALL STILL THERE AND ACCESSIBLE once you get to a level where you need them!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&lt;br&gt;&#xA;Gabriel Staples  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: To see many of the very helpful links which I've referenced as I've built up my Arduino and ATmega328 microcontroller skillset, please see this article here, esp. all of the links at the bottom: &lt;a href=&quot;http://electricrcaircraftguy.blogspot.com/2014/01/the-power-of-arduino.html&quot; rel=&quot;noreferrer&quot;&gt;http://electricrcaircraftguy.blogspot.com/2014/01/the-power-of-arduino.html&lt;/a&gt;  &lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="7727" LastEditDate="2015-09-25T03:07:15.500" LastActivityDate="2015-09-25T03:07:15.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9198" PostTypeId="2" ParentId="4914" CreationDate="2015-03-11T01:04:05.250" Score="1" Body="&lt;p&gt;Since I think BrettAM already gave a pretty good answer, I'm going to expound just a little upon that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First off: I think you're misunderstanding sample rate. The sample rate here is simply the number of analog readings per second that you are doing of a given signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know the &lt;strong&gt;maximum&lt;/strong&gt; sample rate of the Arduino, you simply have to take a ton of samples as fast as you can and see how many you were able to take in a given second. For the Arduino with default settings, that's ~9600 per second &lt;em&gt;maximum&lt;/em&gt;. If you just take 1 single sample though, your sample rate is......I don't know.....how often do you do this!? If you take 1 sample and then stop your sketch for an hour, your sample rate for that one sample was 1 sample per hour. Now, what are you sampling? If what your're sampling is &lt;em&gt;changing&lt;/em&gt; faster than one noticeable change (ADC resolution step) per hour, then you need to sample faster than once per hour. If your signal (what you're sampling) is changing at 100 times per second (100Hz), however, then you need to sample at &lt;em&gt;at least&lt;/em&gt; 200 Hz to even detect it's changing at 100Hz, and at &lt;em&gt;approximately 1000Hz or higher&lt;/em&gt; to actually plot what that 100Hz signal looks like. Note: sampling at 2x the rate of the sampl&lt;strong&gt;ed&lt;/strong&gt; signal is the minimum sample rate required to detect the frequency of the sampl&lt;strong&gt;ed&lt;/strong&gt; signal, and is called the &lt;a href=&quot;http://en.wikipedia.org/wiki/Nyquist_frequency&quot; rel=&quot;nofollow&quot;&gt;Nyquist Frequency&lt;/a&gt;. Sampling at 10x the sampl&lt;strong&gt;ed&lt;/strong&gt; signal is the generally-accepted rule-of-thumb for minimum sample rate required to capture the &lt;em&gt;waveform,&lt;/em&gt; or &lt;em&gt;shape&lt;/em&gt; of the sampl&lt;strong&gt;ed&lt;/strong&gt; signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, let's look into data smoothing. If you just take a single sample, it might bounce around. How do you stop this? One method, is to take many samples and average the result. A library I wrote does this, among many other things, so I'll present it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking many samples in a row then using the average of the samples in any calculations helps to remove the noise component from your signal. I have written an oversampling library that among other things, does just that. An (outdated..will be updated eventually) page on it is here: &lt;a href=&quot;http://www.electricrcaircraftguy.com/2014/05/using-arduino-unos-built-in-16-bit-adc.html#.VVqTlPlViko&quot; rel=&quot;nofollow&quot;&gt;Using the Arduino Uno’s built-in 10-bit to 21-bit ADC (Analog to Digital Converter)&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current version of the code is V2.1 alpha, and the download link is currently highlighted in yellow at the link above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you need to take faster samples, you can also speed up the ADC sample rate to 50+ kHz, using my library...as opposed to settling on the default 9600Hz of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Play around with sampling and smoothing and stuff.  One technique is to speed up the ADC (so you don't waste too much time sampling), then take the avg. of many samples in order to help remove noise from your sensors. This may be unnecessary, if noise is minimal or changes over time on the signal are slow, but for the sake of learning I'll present this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//include the library&#xA;#include &amp;lt;eRCaGuy_NewAnalogRead.h&amp;gt;&#xA;&#xA;//Global Vars&#xA;byte pin = A0;&#xA;byte bitsOfResolution = 10; //commanded oversampled resolution&#xA;unsigned long numSamplesToAvg = 50; //number of samples AT THE OVERSAMPLED RESOLUTION that you want to take and average&#xA;&#xA;void setup() &#xA;{  &#xA;  //Configure the adc how you want it&#xA;  adc.setADCSpeed(ADC_PRESCALER_16_CLOCK_1MHZ); //this speeds up the ADC clock by a factor of 8&#xA;}&#xA;&#xA;void loop() &#xA;{ &#xA;  //local variables&#xA;  unsigned long analogReading;&#xA;&#xA;  //take a reading on the analog pin&#xA; analogReading = adc.newAnalogRead(pin,bitsOfResolution,numSamplesToAvg);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll see that I am speeding up the ADC and taking and averaging 50 samples to smooth the data. I have yet to test the speed, but I estimate this could prob. run at 500Hz or so max sample rate (returning an average value each time)...assuming that's all you did. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing this and taking a single sample is fine for what you need I believe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, for baud rate. Baud rate is essentially &quot;bits of data sent per second.&quot; It's how fast your communication signal is. Lower baud rates are generally less susceptible to electrical noise, and the data is less likely to get corrupted, but higher baud rates send the data values much more quickly and waste less of your code time sitting around transferring data. I recommend you speed it up to maximum, unless you have data transfer problems or dropouts, in which case you should slow it down a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: for more detailed examples on the library download it and look in the examples folder.&lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="7727" LastEditDate="2015-05-19T01:34:48.410" LastActivityDate="2015-05-19T01:34:48.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9201" PostTypeId="1" CreationDate="2015-03-11T02:53:19.100" Score="0" ViewCount="1741" Body="&lt;p&gt;I have a pair of nRF24L01s connected to a pair of Arduino Unos and I'm using the RF24 library from here: &lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;nofollow noreferrer&quot;&gt;RF24 library&lt;/a&gt;. When I run the pingpair example sketch, the radios transmit and receive back and forth just fine. So I tried to program my own very simple example but I'm running into a problem where the first message transmits successfully (and is received successfully), however, subsequent messages fail to send. The call to radio.write() returns false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following code on the 'sender':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24 radio(9,10);&#xA;const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };&#xA;uint8_t payload[1];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  radio.begin();&#xA;  radio.setRetries(15, 15);&#xA;  radio.setPayloadSize(1);&#xA;  radio.openWritingPipe(pipes[0]);&#xA;}&#xA;&#xA;void loop() {&#xA;  payload[0] = 1;&#xA;  bool ok = radio.write(payload, 1);&#xA;  Serial.println(&quot;Status: &quot; + (String) ok);&#xA;  delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following on the 'receiver':&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24 radio(9,10);&#xA;const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };&#xA;uint8_t payload[1];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  radio.begin();&#xA;  radio.setRetries(15, 15);&#xA;  radio.setPayloadSize(1);&#xA;  radio.openReadingPipe(1, pipes[0]);&#xA;  radio.startListening();&#xA;  Serial.println(&quot;Listening: &quot; );&#xA;}&#xA;&#xA;void loop() {&#xA;  if (radio.available()) {&#xA;    bool done = false;&#xA;    while (!done) {&#xA;      done = radio.read(payload, 1);&#xA;      Serial.println(&quot;Got payload: &quot; + (String) payload[0]);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm guessing the problem has to be with my code because the example sketches work, but I can't figure out what the problem is. Again to summarize, when I reset the Arduino, the first call to &lt;code&gt;radio.write()&lt;/code&gt; returns true and the message is transmitted. After that, subsequent calls to &lt;code&gt;radio.write()&lt;/code&gt; return false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that I did try adding a 10uF capacitor across +3.3V and Ground but it did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="7817" LastEditorUserId="4628" LastEditorDisplayName="user31481" LastEditDate="2018-03-17T14:37:36.333" LastActivityDate="2018-04-16T15:23:39.640" Title="Pair of nRF24L01s ping/pong example sketch works, but using my own code fails after first successful transmit" Tags="|arduino-uno|nrf24l01+|code-review|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9202" PostTypeId="2" ParentId="9193" CreationDate="2015-03-11T10:10:59.183" Score="-1" Body="&lt;p&gt;I was having the same problem with the ethernet shield (and i still have it). In my case it was caused by the network router. When my modem/router couldn't connect to the net (bad weather etc...) the shield couldn't take an IP and the initialaization was failing every time just because i was disconnected from the internet. The library works almost the same way. Basicaly you have to make sure it can connect. &lt;/p&gt;&#xA;" OwnerUserId="6969" LastActivityDate="2015-03-11T10:10:59.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9205" PostTypeId="1" AcceptedAnswerId="9210" CreationDate="2015-03-11T12:16:20.317" Score="2" ViewCount="4043" Body="&lt;p&gt;I'm wanting to power a USB device from an Arduino Uno. Forgetting about the two data pins, it just requires power. Using a power meter, I can detect the 5v pin at about 4.95 volts, however I don't have access to any resistors at the moment so cannot test the amperage because it just shorts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB device I want to power requires ~300mA (can't remember specifically). First of all, does the Arduino get 100mA or 500mA when getting power from the USB? Is this changeable depending on the setting on the USB Host (High 500mA, or Low 100mA)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, how much would actually be usable? I assume the Arduino itself would require some of that current? Even more if a program where running on it at the same time? (I have no idea how computers utilize power) I would like to just hook up my usb device to ground and 5V with whatever resistors (and any other electrical components) in between to bring it down from 500mA to the required ~300mA.&lt;/p&gt;&#xA;" OwnerUserId="7824" LastActivityDate="2015-03-11T19:32:24.997" Title="Powering USB device from arduino uno?" Tags="|arduino-uno|power|usb|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9206" PostTypeId="2" ParentId="9205" CreationDate="2015-03-11T13:48:17.583" Score="0" Body="&lt;p&gt;You'd have to test this but there's a chance you could supply the Arduino using a DC power supply on it's 5V pin. In this case DO NOT TURN YPUR SUPPLY HIGHER THAN 5V, as I don't believe there is any protection and will send the full voltage to the USB.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A safer option would be the Vin pin. Normally you'd want to put 7-12 Volts to this pin but you may want to start at 5V and work your way up just to be safe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone please corrects if I am wrong, but if you never apply more than an external 5V your worst case scenario would be burning out the Arduino but not the USB device.&lt;/p&gt;&#xA;" OwnerUserId="7816" LastActivityDate="2015-03-11T13:48:17.583" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9207" PostTypeId="1" AcceptedAnswerId="9211" CreationDate="2015-03-11T15:41:24.920" Score="3" ViewCount="3137" Body="&lt;p&gt;I am working with a ArduinoUNO - 2100 mA battery, and a solar Charger shield. I use a temperature reader that sends info &lt;strong&gt;every half hour with GPS-GSM shield&lt;/strong&gt; called LONET (&lt;a href=&quot;http://www.seeedstudio.com/wiki/LoNet_-_GSM/GPRS/GPS_Breakout&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/LoNet_-_GSM/GPRS/GPS_Breakout&lt;/a&gt; for more info).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to save all the energy i can, i am trying to put Arduino UNO and LONET on Sleep mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LONE has its own mode via “AT+CSCLK=1”. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for Arduino UNO i haven seen a library called Narcoleptic (&lt;a href=&quot;https://code.google.com/p/narcoleptic/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/narcoleptic/&lt;/a&gt; for more info) wich can solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other method that can help me to save Battery with Arduino uno? is it a good approach to use Narcoleptic or there is another method to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time/help and sorry for my English.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any feedback could be welcome.&lt;/p&gt;&#xA;" OwnerUserId="7831" LastEditorUserId="7831" LastEditDate="2015-03-11T16:29:15.203" LastActivityDate="2015-03-12T20:20:49.897" Title="which is the most efficient way to save power with battery using Arduino UNO?" Tags="|arduino-uno|battery|temperature-sensor|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9209" PostTypeId="2" ParentId="9207" CreationDate="2015-03-11T19:02:14.033" Score="2" Body="&lt;p&gt;There's a great article on that topic: &lt;a href=&quot;https://www.openhomeautomation.net/arduino-battery/&quot; rel=&quot;nofollow&quot;&gt;https://www.openhomeautomation.net/arduino-battery/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7631" LastActivityDate="2015-03-11T19:02:14.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9210" PostTypeId="2" ParentId="9205" CreationDate="2015-03-11T19:27:03.180" Score="0" Body="&lt;p&gt;The Arduino receives 500mA max from USB power.  That is per the USB specification, and the Arduino has a 500mA resettable fuse on the USB power to protect your computer's USB port from 'accidents'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the question of whether it is configurable between 500mA/100mA, generally no it's not. I believe that part of the USB negotiation that occurs when the Arduino connects to your PC is that the Arduino describes itself to the computer, and it reports that it is a 500mA device. Bottom line is, you won't need to do anything special in this regard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, how much of the power is needed for the Arduino, and how much is left over - well that depends on what else the Arduino is doing and what else it's powering (LEDs, etc.). If the Arduino is not doing much else, than 200mA should be plenty of headroom for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you power the Arduino through the PWR Jack (or the Vin), then the voltage should be a minimum of 7V. That is because it is feeding into a 5v regulator, which has some voltage drop, so it needs about 7V to be able to consistently supply 5V output.  If you power the Arduino manually (through the 5V pin), you want to give it 5V. Anything less than 5V would be considered overclocking. (The ATMEGA328P needs 5V to operate at 16mHz, but can run at lower voltages when clocked at lower speeds.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, keep in mind that the USB port on the Arduino is a USB 'client', not a USB host or USB OTG. Therefore, the port can not be used to supply outbound power. You can power your extra device from the Arduino's 5V and GND pins.&lt;/p&gt;&#xA;" OwnerUserId="7815" LastEditorUserId="7815" LastEditDate="2015-03-11T19:32:24.997" LastActivityDate="2015-03-11T19:32:24.997" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9211" PostTypeId="2" ParentId="9207" CreationDate="2015-03-11T20:27:11.973" Score="5" Body="&lt;p&gt;There is an even greater article on this topic: &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It shows how to reduce your power usage for the Uno from about 50mA to 350nA (0.000350mA) - at this point, you need to factor in the natural drain of batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have had good success with a project that was activated by a pushbutton, by using a latch - the push button turned the power on; once the power is on, it latched. Then the Arduino can switch itself off, using one of it's pins. As far as I can tell from a simulator, there is no leakage (while it is off, to within the accuracy of the simulator, assuming a perfectly spherical transistor in a vacuum ;) ). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just in case anyone is interested, my latch circuit can be seen at: &lt;a href=&quot;https://i.stack.imgur.com/Uf9sX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/Uf9sX.png&lt;/a&gt; - the two resistors and the switch at the bottom represent the Arduino - +5V coming in the top, GND at the bottom, and one of the pin to switch it off is the switch - this pin should be INPUT to keep the power on; when you are ready to switch of, set it to output -&gt; high. You should get switched off immediately. The switch at the top will switch it on. In the startup part of your sketch, set the pin to INPUT first.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-03-12T20:20:49.897" LastActivityDate="2015-03-12T20:20:49.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9213" PostTypeId="2" ParentId="9180" CreationDate="2015-03-12T00:19:14.450" Score="1" Body="&lt;p&gt;If I understand your question correctly you're asking if you can control servos with OSC and no microcontroller.&lt;br&gt;&#xA;OSC is a protocol used for networking and communication between synthesizers, similar to midi in that, but totally different in the way OSC sends data which looks a bit like XML. &lt;br&gt;&lt;br&gt;&#xA;There's a couple of problems here:&lt;br&gt;&#xA;&lt;strong&gt;1.&lt;/strong&gt; &lt;em&gt;Servos will not respond to OSC-signals. You could use MAX/MSP to generate servo-pulses from the OSC. The problem arises whan you are going to send this to the servos using usb.&lt;/em&gt; &lt;br&gt;&#xA;&lt;strong&gt;2.&lt;/strong&gt; &lt;em&gt;USB, a fast data-transmission technology, is not suitable to be connected straight into a servomotor.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino uses an atmega16u to transform the data from usb to serial (called a usb to serial programmer) for programming and communication. Then the microcontroller (atmega168/328) takes this and creates a pulse and a signal for the servo-motors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To control servos without a micro-controller using USB is impossible.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is be possible to control electronics using the serial-port and low-level coding. Used to do stuff like that on a Commodore 64 a time ago. Before these affordable, stable, reliable avr, arm and pic programming cards came out.  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;A tip&lt;/em&gt;: It is possible to load a program onto an atmega168/328 using a Arduino UNO or similar. Take the chip off of the programming card(ie. the Arduino UNO) and create a stripped down version, containing the micro-controller chip, 16kHz crystal, some capacitors and an usb to serial converter/ftdi-cable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards&lt;br&gt;&#xA;Krister Borge&lt;/p&gt;&#xA;" OwnerUserId="201" LastEditorUserId="201" LastEditDate="2015-03-12T22:03:16.390" LastActivityDate="2015-03-12T22:03:16.390" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9214" PostTypeId="1" CreationDate="2015-03-12T01:22:19.910" Score="0" ViewCount="165" Body="&lt;p&gt;I'm using an Arduino Due with various sensors. At the moment, I'm using the majority of the pins along the width (the double width pins). I want to make the setup more permanent, however I can't seem to find any ribbon cables with 36-conductors. What do you use for long term connections on the Due, especially if you occasionally need to unplug all the connections? Would a 40-pin ribbon cable work as they're easy to come by.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="6331" LastActivityDate="2015-11-07T15:34:49.997" Title="Connecting hardware to the Arduino" Tags="|arduino-due|hardware|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9215" PostTypeId="2" ParentId="9214" CreationDate="2015-03-12T01:45:35.517" Score="1" Body="&lt;p&gt;I have used 40 pin cables for this purpose, specifically, IDE cables (beware: on high speed, &quot;80 conductor&quot; cables, but still with 40 pin connectors, some pins are permanently connected, to indicate to to the controller that this is a high speed cable!). The connectors are cheap, the cables are free if you ask around (probably less so now). In my case, I connected two extra-large 7-segment displays, and it worked great. More pins than you rarely hurts. In my case, it was especially useful since I needed some pins at the top, and some pins at the bottom of the display; my ide cable had three connectors (motherboard &amp;amp; two drives); I used the top row on one ide connector to the top of of my displays, and the bottom row of pins on the other connector to the bottom of the displays.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-12T01:45:35.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9216" PostTypeId="2" ParentId="9214" CreationDate="2015-03-12T02:10:26.460" Score="0" Body="&lt;p&gt;You can also make your own IDC ribbon cables pretty easily. A 36-pin cable might be pretty hard to find a connector for, but you could use a 20-pin and a 16-pin side by side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;a href=&quot;http://www.mouser.com/ProductDetail/Kobiconn/164-9008-E/?qs=sGAEpiMZZMs%252bGHln7q6pm2gjsa6Tcy%2fkwHR%252bX1kBnDU%3d&quot; rel=&quot;nofollow&quot;&gt;Kobicon 164-9008-E&lt;/a&gt; and &lt;a href=&quot;http://www.mouser.com/ProductDetail/Kobiconn/164-9001-E/?qs=sGAEpiMZZMs%252bGHln7q6pm2gjsa6Tcy%2fkhD4TEkl7%252bnc%3d&quot; rel=&quot;nofollow&quot;&gt;Kobicon 164-9001-E&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get creative and mix and match different pin counts, depending on your project. Buy a few meters of 40-conductor .05&quot; pitch ribbon cable, and you can peel off the 4 outermost conductors to make it 36-conductor, as well as separating the end of the cable into your connector groups.&lt;/p&gt;&#xA;" OwnerUserId="7815" LastActivityDate="2015-03-12T02:10:26.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9217" PostTypeId="1" CreationDate="2015-03-12T02:41:04.227" Score="2" ViewCount="435" Body="&lt;p&gt;IS there a way for me to use cell towers to triangulate my location with an Arduino Uno and GSM breakout board? if so how?&lt;/p&gt;&#xA;" OwnerUserId="7837" LastActivityDate="2015-03-12T02:41:04.227" Title="Can I use an Arduino and GSM breakout board for triangulation?" Tags="|arduino-uno|gsm|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9219" PostTypeId="1" AcceptedAnswerId="9220" CreationDate="2015-03-12T09:55:32.013" Score="4" ViewCount="12230" Body="&lt;p&gt;I am reading some sample code and they use this method of mapping data from IR sensors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  sensor1 = analogRead(0); &#xA;  adj_1 = map(sensor1, s1_min, s1_max, 0, 255);&#xA;  adj_1 = constrain(adj_1, 0, 255);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the point of using &lt;code&gt;constrain&lt;/code&gt; here if &lt;code&gt;adj_1&lt;/code&gt; is already getting a value 0-255 from the &lt;code&gt;map&lt;/code&gt; function?&lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2017-02-05T15:33:02.663" Title="Why is the constrain function used after the map function?" Tags="|sensors|map|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9220" PostTypeId="2" ParentId="9219" CreationDate="2015-03-12T10:47:48.837" Score="7" Body="&lt;p&gt;From &lt;a href=&quot;http://arduino.cc/en/reference/map&quot;&gt;the official Arduino site&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[The map function] does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The constrain() function may be used either before or after this function, if limits to the ranges are desired.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;EDIT: Example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try this by yourself with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = 20;&#xA;val = map(val, 0, 10, 0, 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although you set the upper bound of the value's range to 10, you passed an higher value than that and the function will linearly map it accordingly, resulting in an output of 200.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-12T11:17:31.313" LastActivityDate="2015-03-12T11:17:31.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9221" PostTypeId="2" ParentId="9193" CreationDate="2015-03-12T11:18:50.783" Score="2" Body="&lt;p&gt;Solved it, the problem was because the SparkFun library was not working with my shield. I replaced it using the &lt;code&gt;Adafruit_CC3000_Library&lt;/code&gt; and now it works fine.&lt;/p&gt;&#xA;" OwnerUserId="7807" LastEditorUserId="6936" LastEditDate="2015-08-07T12:16:54.367" LastActivityDate="2015-08-07T12:16:54.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9222" PostTypeId="1" CreationDate="2015-03-12T03:21:51.653" Score="0" ViewCount="95" Body="&lt;p&gt;I am having problems uploading my program. I have been using the verify button aka the &quot;checkmark&quot; to upload my programs. I assumed that this was the correct button but now I am having problems uploading. When I attempt to use the &quot;upload&quot; button I get the error &quot;can not open device&quot;. What am I doing wrong? How can I fix this error code? &lt;/p&gt;&#xA;" OwnerDisplayName="Danielle Diggs" LastEditorUserId="46" LastEditDate="2015-03-12T13:17:57.427" LastActivityDate="2015-05-12T01:09:16.643" Title="How to upload program to board using Arduino sketch ver 1.6?" Tags="|uploading|sketch|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9223" PostTypeId="1" CreationDate="2015-03-12T14:28:53.520" Score="2" ViewCount="1709" Body="&lt;p&gt;Has anyone tried to program an ATmega2560 with an FTDI chip as is done in the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Nano&lt;/a&gt; (this is for a custom design).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will it work?&lt;/p&gt;&#xA;" OwnerUserId="7849" LastEditorUserId="6936" LastEditDate="2017-01-16T20:38:58.990" LastActivityDate="2017-08-15T15:50:13.170" Title="Programming ATmega2560 processor with FTDI instead of ATmega32" Tags="|arduino-nano|ftdi|atmega2560|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9225" PostTypeId="2" ParentId="9223" CreationDate="2015-03-12T14:42:26.667" Score="0" Body="&lt;p&gt;The Arduino Mega already has a built-in USB-UART bridge, so there's no need for a separate chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATmega1280 on the other hand is just a bare AVR MCU and does require either a separate USB-UART bridge for serial programming (provided it is programmed with an appropriate bootloader) or an ISP programmer for ISP programming.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-12T14:42:26.667" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9226" PostTypeId="1" CreationDate="2015-03-12T15:15:38.837" Score="0" ViewCount="944" Body="&lt;p&gt;I am looking for the boards.txt, platform.txt and core files needed for the programming of the ATtiny13 with the Arduino Uno. Those I find on the internet probably only works with Arduino 1.0 and not with 1.6. &lt;/p&gt;&#xA;" OwnerUserId="7845" LastActivityDate="2015-03-12T16:38:18.560" Title="Program attiny13 with Arduino uno 1.6" Tags="|core-libraries|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9227" PostTypeId="2" ParentId="9222" CreationDate="2015-03-12T15:26:24.927" Score="2" Body="&lt;p&gt;The checkmark button is used to compile your program (which &quot;verifies&quot; your code), but does not upload it to the board. The &quot;arrow&quot; button is used to compile and upload your program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you cannot connect to the device, make sure the correct COM port is selected on the Tools-&gt;Ports menu, and make sure you have the correct board selected on Tools-&gt;Board (usually an Arduino UNO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have not installed the drivers yet, you will not have a port present for your Arduino. If that is the case, here is a great tutorial that will help you get everything installed and set up correctly: &lt;a href=&quot;https://learn.adafruit.com/lesson-0-getting-started&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/lesson-0-getting-started&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7815" LastActivityDate="2015-03-12T15:26:24.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9228" PostTypeId="2" ParentId="9226" CreationDate="2015-03-12T16:38:18.560" Score="1" Body="&lt;p&gt;You can use the library for IDE 1.6 &lt;a href=&quot;https://github.com/damellis/attiny/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/damellis/attiny/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="27" LastActivityDate="2015-03-12T16:38:18.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9229" PostTypeId="1" CreationDate="2015-03-12T17:20:31.953" Score="-1" ViewCount="1153" Body="&lt;p&gt;Fairly new to arduino, what is the best and simplest way to connect an LM35 temperature sensor, a GL5528 photoresistor and some LEDs as well as the required resistors to an arduino for recording values? Any tutorials with wiring diagrams for something similar would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="7853" LastActivityDate="2015-03-12T19:01:30.957" Title="Connecting light and temperature sensors and LEDs to an Arduino" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9230" PostTypeId="1" AcceptedAnswerId="9245" CreationDate="2015-03-12T18:23:47.323" Score="2" ViewCount="1960" Body="&lt;p&gt;I have an arduino uno with atmega328p controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the code to deal with some specific uart protocol, named mdb: &lt;a href=&quot;https://github.com/Bouni/MateDealer/tree/master/arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Bouni/MateDealer/tree/master/arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's compiled just for atmega2560 controller: &lt;a href=&quot;https://github.com/Bouni/MateDealer/blob/master/arduino/makefile#L42&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Bouni/MateDealer/blob/master/arduino/makefile#L42&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I replace it by &lt;code&gt;atmega328p&lt;/code&gt; or &lt;code&gt;atmega328&lt;/code&gt;, I get the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;asiniy@misha:~/projects/MateDealer/arduino$ make all&#xA;&#xA;-------- begin --------&#xA;avr-gcc (GCC) 4.8.2&#xA;Copyright (C) 2013 Free Software Foundation, Inc.&#xA;This is free software; see the source for copying conditions.  There is NO&#xA;warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#xA;&#xA;&#xA;Compiling: main.c&#xA;avr-gcc -c -mmcu=atmega328 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/main.o.d main.c -o main.o&#xA;&#xA;Compiling: usart.c&#xA;avr-gcc -c -mmcu=atmega328 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=usart.lst  -std=gnu99 -DF_OSC=16000000 -MD -MP -MF .dep/usart.o.d usart.c -o usart.o&#xA;usart.c:25:40: error: ‘UBRR1H’ undeclared here (not in a function)&#xA;     { { { {}, 0, 0 }, { {}, 0, 0 } }, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1B, &amp;amp;UCSR1C },&#xA;                                        ^&#xA;usart.c:25:49: error: ‘UBRR1L’ undeclared here (not in a function)&#xA;     { { { {}, 0, 0 }, { {}, 0, 0 } }, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1B, &amp;amp;UCSR1C },&#xA;                                                 ^&#xA;usart.c:25:58: error: ‘UCSR1B’ undeclared here (not in a function)&#xA;     { { { {}, 0, 0 }, { {}, 0, 0 } }, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1B, &amp;amp;UCSR1C },&#xA;                                                          ^&#xA;usart.c:25:67: error: ‘UCSR1C’ undeclared here (not in a function)&#xA;     { { { {}, 0, 0 }, { {}, 0, 0 } }, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1B, &amp;amp;UCSR1C },&#xA;                                                                   ^&#xA;In file included from usart.c:14:0:&#xA;usart.c: In function ‘USART0_RX_vect’:&#xA;usart.c:185:5: warning: ‘USART0_RX_vect’ appears to be a misspelled signal handler [enabled by default]&#xA; ISR(USART0_RX_vect){&#xA;     ^&#xA;usart.c: In function ‘USART1_RX_vect’:&#xA;usart.c:197:5: warning: ‘USART1_RX_vect’ appears to be a misspelled signal handler [enabled by default]&#xA; ISR(USART1_RX_vect){&#xA;     ^&#xA;usart.c:203:12: error: ‘UDR1’ undeclared (first use in this function)&#xA;     data = UDR1;&#xA;            ^&#xA;usart.c:203:12: note: each undeclared identifier is reported only once for each function it appears in&#xA;In file included from usart.c:14:0:&#xA;usart.c: In function ‘USART0_UDRE_vect’:&#xA;usart.c:233:5: warning: ‘USART0_UDRE_vect’ appears to be a misspelled signal handler [enabled by default]&#xA; ISR(USART0_UDRE_vect){&#xA;     ^&#xA;usart.c: In function ‘USART1_UDRE_vect’:&#xA;usart.c:253:5: warning: ‘USART1_UDRE_vect’ appears to be a misspelled signal handler [enabled by default]&#xA; ISR(USART1_UDRE_vect){&#xA;     ^&#xA;usart.c:261:31: error: ‘TXB81’ undeclared (first use in this function)&#xA;                 UCSR1B |= (1&amp;lt;&amp;lt;TXB81);&#xA;                               ^&#xA;usart.c:266:9: error: ‘UDR1’ undeclared (first use in this function)&#xA;         UDR1 = data;&#xA;         ^&#xA;usart.c:269:20: error: ‘UDRIE1’ undeclared (first use in this function)&#xA;     UCSR1B &amp;amp;= ~(1&amp;lt;&amp;lt;UDRIE1);&#xA;                    ^&#xA;make: *** [usart.o] Error 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to play with compilers (default is gnu99) and so on, but with no success. Why I have this trouble? How can I compile this code for upload it to arduino?&lt;/p&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-03-13T09:00:21.893" Title="Difficult between atmega328 &amp; atmega2560 when coding &amp; compiling in a pure c" Tags="|arduino-uno|arduino-mega|atmega328|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9231" PostTypeId="2" ParentId="9230" CreationDate="2015-03-12T18:33:07.213" Score="1" Body="&lt;p&gt;The '328 only has a single USART. You will need to remove all references to USARTs beyond the first as well as the numeric suffix from the USART register names in order to get it to compile.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-12T18:33:07.213" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9232" PostTypeId="1" CreationDate="2015-03-12T18:41:20.940" Score="2" ViewCount="144" Body="&lt;p&gt;I am working on a project involving 14 sections of EL tape. This is a circular array that incorporates a chaser effect with two lights lit on either side. originally I had found a small diy LED sequencer board that controlled both speed and brightness from 2 POTs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am attempting to adapt this to activate 7 relays (in place of the LEDs) which will in turn divert the power of the EL inverter to the tape sections.&#xA;Each relay is the connection of 2 EL panels to the (+) of the sole EL inverter while its (-) is hardwired in parallel among all the panels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are all small panels cut from a 3m length and have worked using this inverter independently both full length and cut. through some trial/error as well as some brightness and speed tweaking I have made this system work for a panel or 2, sometimes more, but other times the inverter and relays are working by the sound of it but the lights are not lighting or when they do they are skipping. It's intermittent too sometimes swapping panels works but at times it looks like the socket may be bad and the light is good other times it's the opposite even with the same pieces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have considered the sparkfun sequencer and it would most certainly save the day except that along with space being an issue my device also incorporates a few other Arduino devices including 2 servos, a sound module and a push button to start the sequence. however the sequencer doesn't seem capable to run 7 el connections as well as 4-6 other operations. is there a simpler way?&#xA;Am I missing components between my relays and lights? &#xA;Could I use my Uno in place of the sequencer? or can I expand the number of pins on the sequencer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to avoid daisy-chaining arduinos/boards as much as possible and even break down the number of separate boards I already have. I am trying to run this off of a single 9v and maybe a pair of button batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I can no longer find the exact sequencer I am using but there are many 8 channel led chasers (w/o Brightness control) similar to mine on ebay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help, insight, coding, recommendations anyone can offer would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="7854" LastEditorUserId="7854" LastEditDate="2016-05-24T18:12:44.263" LastActivityDate="2016-05-24T18:12:44.263" Title="Home-Made EL Tape chaser" Tags="|arduino-uno|programming|sensors|pins|" AnswerCount="0" CommentCount="7" ClosedDate="2017-10-27T12:15:49.960" ContentLicense="CC BY-SA 3.0" />
  <row Id="9233" PostTypeId="2" ParentId="9229" CreationDate="2015-03-12T19:01:30.957" Score="1" Body="&lt;p&gt;The LM35 is a very common temperature sensor. It has 3 pins - Vs, Vout, and Gnd. Connect Vs to the Arduino's Vs pin. Connect the Gnd pin to one of the Arduino's GND pins. The Vout pin should be connected to an Analog input pin. If you google your board, you should find the pinout on Arduino's website. The LM35 pin diagram and information on how to calculate the temperature from voltage is found in the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm35.pdf&quot; rel=&quot;nofollow&quot;&gt;LM35's Datasheet.&lt;/a&gt; &lt;a href=&quot;https://learn.adafruit.com/tmp36-temperature-sensor&quot; rel=&quot;nofollow&quot;&gt;Here is LadyAda's Temerature Sensor tutorial&lt;/a&gt; (note: the tutorial specifies the TMP36, however the two sensors are comparable). &lt;a href=&quot;http://www.instructables.com/id/ARDUINO-TEMPERATURE-SENSOR-LM35/&quot; rel=&quot;nofollow&quot;&gt;Here is an instructable for the LM35&lt;/a&gt; (includes diagrams and source code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GL5528 is a photoresistor. That means its resistance changes proportional to how much light strikes its sensor surface. Because of this trait, we can build a &lt;a href=&quot;http://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;Voltage Divider&lt;/a&gt;. This will allow us to read in values (again, analog values). &lt;a href=&quot;https://learn.adafruit.com/photocells&quot; rel=&quot;nofollow&quot;&gt;AdaFruit's tutorial is very comprehensive&lt;/a&gt; and includes diagrams. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDs are generally considered output displays (we program to use LEDs as a visual display of state). A good starting place for Arduino LEDs is the &lt;a href=&quot;http://arduino.cc/en/Tutorial/Blink?from=Tutorial.BlinkingLED&quot; rel=&quot;nofollow&quot;&gt;Blink Example.&lt;/a&gt; we connect an LED and resistor in series with an Arduino output pin and GND or 5v. This allows us to 'write' to the Arduino pin HIGH or LOW, turning the LED on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found these results by googling 'Arduino LM35', 'Arduino GL5528', and 'Arduino LED' respectively. &lt;/p&gt;&#xA;" OwnerUserId="7292" LastActivityDate="2015-03-12T19:01:30.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9235" PostTypeId="2" ParentId="8750" CreationDate="2015-03-12T20:39:04.457" Score="-1" Body="&lt;p&gt;While it might be an interesting project, the overall quality of the sound generated by such do-it-yourself contraption, is likely to be highly disappointing, because of the not-stellar quality of the final analog stage in the audio output.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-03-12T20:39:04.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9236" PostTypeId="1" AcceptedAnswerId="9239" CreationDate="2015-03-12T21:06:00.240" Score="3" ViewCount="315" Body="&lt;p&gt;I have this GSM module I got for my arduino project and I am trying to access the call feature, but the function makes no sense.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  boolean Adafruit_FONA::callPhone(char *number) {&#xA;  char sendbuff[35] = &quot;ATD&quot;;&#xA;  strncpy(sendbuff+3, number, min(30, strlen(number)));&#xA;  uint8_t x = strlen(sendbuff);&#xA;  sendbuff[x] = ';';&#xA;  sendbuff[x+1] = 0;&#xA;  //Serial.println(sendbuff);&#xA;&#xA;  return sendCheckReply(sendbuff, &quot;OK&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the function however how is char being used to display a phone number in the parameter? &lt;/p&gt;&#xA;" OwnerUserId="7837" LastEditorUserId="368" LastEditDate="2015-03-12T22:16:07.897" LastActivityDate="2015-03-12T22:54:38.833" Title="Can I have help interperting this code? char variable somehow storing big numbers" Tags="|c++|data-type|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9238" PostTypeId="1" CreationDate="2015-03-12T21:39:49.707" Score="10" ViewCount="11973" Body="&lt;p&gt;What I want to do is make a ATTiny IC become a slave on the 1-wire bus, with its own S/N and command list for its specific functions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is if I can use the &lt;a href=&quot;http://playground.arduino.cc/Learning/OneWire&quot; rel=&quot;noreferrer&quot;&gt;one wire library&lt;/a&gt; from the arduino site to send data as a slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can have a slave in one room with multiple types of sensors which would report to the master on requested information, or the master can tell it to control something like blinds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&#xA;Would I have to monitor the bus line and respond to a request from the master and also take into consideration the way a normal sensor would send data? What frequency should I run the slave at to get the best functionality? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I won't use parasitic power, as a note.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2023-12-17T02:24:47.783" Title="Emulating 1-wire device(s)" Tags="|sensors|library|attiny|1-wire|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9239" PostTypeId="2" ParentId="9236" CreationDate="2015-03-12T21:52:46.747" Score="3" Body="&lt;p&gt;It's passed as a &lt;code&gt;char*&lt;/code&gt;. This can be derived from either a string literal (e.g. &lt;code&gt;&quot;212555121&quot;&lt;/code&gt;) or from a &lt;code&gt;String&lt;/code&gt; via its &lt;code&gt;c_str()&lt;/code&gt; method.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-12T21:52:46.747" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9240" PostTypeId="2" ParentId="9236" CreationDate="2015-03-12T22:54:38.833" Score="2" Body="&lt;p&gt;Keeping it simple:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;char *number;&lt;/code&gt; a variable pointing to a character (or string of them).&lt;br&gt;&#xA;&lt;code&gt;char sendbuff[35];&lt;/code&gt; 35 characters in a row, making a string.&lt;br&gt;&#xA;The first 3 chars at locatiion sendbuff are initialised to &quot;A&quot;, &quot;T&quot;, &amp;amp; &quot;D&quot;, then the string at &quot;number&quot; is copied to it (to a maximum of 30 characters, by taking the lesser of the length of &quot;number&quot; or 30. This is important to avoid over-running the space allocated.&lt;br&gt;&#xA;This string of characters gets sent out; &amp;amp; a check is made for an &quot;O&quot; &amp;amp; a &quot;K&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't 'get' pointers, you need to look it up, as it's pretty central stuff.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-03-12T22:54:38.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9242" PostTypeId="1" AcceptedAnswerId="9345" CreationDate="2015-03-13T00:59:50.187" Score="3" ViewCount="7820" Body="&lt;p&gt;I would like to use an inertial sensor to measure acceleration and send the results to an Android app using a serial communication with a &lt;strong&gt;bluetooth Mate Gold&lt;/strong&gt; module. The sensor provides a data ready interrupt which notifies &lt;strong&gt;Arduino-Mega&lt;/strong&gt; that a new value is stored in a register of the module. The output data rate can be modified during the configuration of the sensor.&#xA;I want the information to be sent at a 10 Hz rate to the bluetooth module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is an interrupt at 400Hz capable of compromising the integrity of a 50 bytes long message sent at 10 Hz with a baudrate of 9600? &#xA;If yes, which approach would you recommend to correctly send the data?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&#xA;I'm using the following formula to compute the amount of time required to send N chars.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bytes x bits_per_character / bits_per_second&#xA;N x (8+2) / 9600 = N/960 secs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For N = 52:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;52/960 = 0.054 secs = 54 ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So theoretically, I can send a 54 char-long message at 18Hz with a baudrate of 9600. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit2&lt;/strong&gt;&#xA;I can use the hardware serial or the Software Serial interface.&lt;/p&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="4396" LastEditDate="2015-03-14T23:10:46.940" LastActivityDate="2017-07-20T23:10:13.613" Title="What happens if an interrupt is triggered while sending data via serial?" Tags="|serial|arduino-mega|sensors|interrupt|" AnswerCount="3" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="9243" PostTypeId="1" CreationDate="2015-03-13T03:45:05.087" Score="1" ViewCount="2375" Body="&lt;p&gt;I currently have a setup where I take serial output from Arduino 1 and push it through a transmitter to the receiver of Arduino 2 where it is fed back into the serial input and further processed. I want to ensure that there is as little error as possible and recover the data wherever possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have come across the syndrome decoding technique which seems to be the ideal one for me, but I am confused as to how I would go about implementing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the Arduino Serial transfers data byte by byte, each being 8 bits, but do not know how this data is sent over the serial connection (i.e. how the start &amp;amp; stop bits &amp;amp; parity is implemented).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would assume that a solution to this could either involve modifying the data in the buffer or reading it from the buffer and then operating upon it. I could also use adjacent bytes of data for error correction, but this seems wasteful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I proceed with this?&lt;/p&gt;&#xA;" OwnerUserId="7865" LastActivityDate="2017-07-25T17:12:44.000" Title="Serial Error Correction" Tags="|arduino-uno|serial|communication|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9244" PostTypeId="1" AcceptedAnswerId="9305" CreationDate="2015-03-13T05:40:31.453" Score="4" ViewCount="6418" Body="&lt;p&gt;I keep receiving the following error in myATTiny85-Slave code below:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;sketch_mar12a.ino: In function 'void setup()':&lt;/p&gt;&#xA;&lt;p&gt;sketch_mar12a:19: error: 'class USI_TWI_S' has no member named 'onRequest'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have downloaded &lt;strong&gt;&lt;a href=&quot;https://github.com/rambo/TinyWire/tree/master/TinyWireS&quot; rel=&quot;nofollow noreferrer&quot;&gt;TinyWireS&lt;/a&gt;&lt;/strong&gt; and &lt;em&gt;TinyWireS.h&lt;/em&gt; clearly has a public function &lt;strong&gt;onRequest&lt;/strong&gt;. I opened the .ZIP file (downloaded from &lt;a href=&quot;https://github.com/rambo/TinyWire&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/rambo/TinyWire&lt;/a&gt;) and drag-dropped TinyWireS folder into the Arduino libraries folder. This is how I install ALL libraries.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I am using Arduino 1.0.6&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&lt;h2&gt;ATTiny85-Slave Code:&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;TinyWireS.h&amp;quot;                  // wrapper class for I2C slave routines&#xA;#define I2C_SLAVE_ADDR  0x26            // i2c slave address (38)&#xA;&#xA;byte t=10;&#xA;&#xA;void setup()&#xA;{ &#xA;   TinyWireS.begin(I2C_SLAVE_ADDR);      // init I2C Slave mode&#xA;   TinyWireS.onRequest(requestEvent);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&#xA;void requestEvent()&#xA;{  &#xA;   TinyWireS.send(t);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2&gt;Arduino Uno-Master Code:&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Wire.h&amp;gt;&#xA; #define I2C_SLAVE_ADDR  0x26            // i2c slave address (38)&#xA;&#xA; void setup() &#xA; {&#xA;     Wire.begin();&#xA;     Serial.begin(9600);&#xA; }&#xA;&#xA; void loop() &#xA; {&#xA;      byte num;&#xA;&#xA;     // read 1 byte, from address 0x26&#xA;     Wire.requestFrom(I2C_SLAVE_ADDR, 1);&#xA;&#xA;     while(Wire.available()) {&#xA;          num = Wire.read();&#xA;     }&#xA;     &#xA;     Serial.print(&amp;quot;num = &amp;quot;);&#xA;     Serial.println(num,DEC);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7250" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-18T11:56:27.123" Title="I²C between ATTiny85 (8MHz) and Arduino Uno" Tags="|arduino-uno|i2c|attiny|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9245" PostTypeId="2" ParentId="9230" CreationDate="2015-03-13T09:00:21.893" Score="2" Body="&lt;p&gt;I'm the author of the MateDealer project and I never had the intention to port it to other boards than the Arduino Mega2560! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ignacio Vazquez-Abrams is absolutely right, the Arduino Mega2560 is the only board with more than 1 serial port (Yes there is the Due and the Leonardo, but those would require major changes to the code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fastest way to get the code running is by using a Mega2560, but be warned, the code might be bugy as hell ;-)&lt;/p&gt;&#xA;" OwnerUserId="7867" LastActivityDate="2015-03-13T09:00:21.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9246" PostTypeId="5" CreationDate="2015-03-13T10:43:14.133" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T10:43:14.133" LastActivityDate="2015-03-13T10:43:14.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9247" PostTypeId="4" CreationDate="2015-03-13T10:43:14.133" Score="0" Body="A method of communicating with one or more devices over a bus system using only data and ground connections. It is designed for small devices which do not require high data speeds or large amounts of power." OwnerUserId="42" LastEditorUserId="27346" LastEditDate="2018-10-22T15:35:20.853" LastActivityDate="2018-10-22T15:35:20.853" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9248" PostTypeId="5" CreationDate="2015-03-13T10:47:18.023" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T10:47:18.023" LastActivityDate="2015-03-13T10:47:18.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9249" PostTypeId="4" CreationDate="2015-03-13T10:47:18.023" Score="0" Body="The physical circuitry and other components of a machine or device. This is distinct from the program code running on a device, which may be called software or firmware." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T10:47:18.023" LastActivityDate="2015-03-13T10:47:18.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9250" PostTypeId="5" CreationDate="2015-03-13T11:06:06.430" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:06:06.430" LastActivityDate="2015-03-13T11:06:06.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9251" PostTypeId="4" CreationDate="2015-03-13T11:06:06.430" Score="0" Body="An extension board for Arduino which provides functionality for controlling DC/stepper motors and other inductive loads (such as relays and solenoids)." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:06:06.430" LastActivityDate="2015-03-13T11:06:06.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9252" PostTypeId="5" CreationDate="2015-03-13T11:09:12.020" Score="0" Body="&lt;p&gt;SPI (Serial Peripheral Interface) is used to communicate bi-directionally with other peripherals. The SPI interface normally has the following signals:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SCK - serial clock, sometimes called CLK - this provides the clock data which controls the rate of data transfer&lt;/li&gt;&#xA;&lt;li&gt;MOSI - Master Out, Slave In, sometimes called DO (Data Out) - this is the data from the master to the slave&lt;/li&gt;&#xA;&lt;li&gt;MISO - Master In, Slave Out, sometimes called DI (Data In) - this is the data from the slave to the master&lt;/li&gt;&#xA;&lt;li&gt;SS - Slave Select - when asserted the slave knows it is being communicated with. When SS is not asserted the slave keeps all signals at high-impedance, so other devices can use the same SCK/MOSI/MISO lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The signals SCK/MOSI/SS are outputs on the master end. The MISO signal is an output on the slave side, &lt;strong&gt;if&lt;/strong&gt; SS is asserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The signals SCK/MOSI/MISO can be shared between multiple peripheral devices. The &quot;active&quot; one at a particular moment is the one which has SS asserted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some peripherals (eg. LED strips, output shift registers) are one-direction only. In that case the MISO signal is not used.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot; rel=&quot;nofollow&quot;&gt;Wikipedia: Serial Peripheral Interface Bus&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;Arduino reference: SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:51.740" LastActivityDate="2015-08-30T20:37:51.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9253" PostTypeId="4" CreationDate="2015-03-13T11:09:12.020" Score="0" Body="Serial Peripheral Interface. Allows full-duplex serial communication from a master device to one or more slave devices arranged on a bus. Sometimes referred to as a 4-wire bus." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:09:12.020" LastActivityDate="2015-03-13T11:09:12.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9254" PostTypeId="5" CreationDate="2015-03-13T11:18:40.330" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:18:40.330" LastActivityDate="2015-03-13T11:18:40.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9255" PostTypeId="4" CreationDate="2015-03-13T11:18:40.330" Score="0" Body="Radio Frequency. Typically used to refer to the radio portion of the electromagnetic spectrum which is used for wireless communication. Strictly speaking though, RF can refer to any oscillation (electrical or otherwise) at the associated frequency." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:18:40.330" LastActivityDate="2015-03-13T11:18:40.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9256" PostTypeId="5" CreationDate="2015-03-13T11:21:46.567" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:21:46.567" LastActivityDate="2015-03-13T11:21:46.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9257" PostTypeId="4" CreationDate="2015-03-13T11:21:46.567" Score="0" Body="A component which measures heat." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:21:46.567" LastActivityDate="2015-03-13T11:21:46.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9258" PostTypeId="5" CreationDate="2015-03-13T11:25:44.103" Score="0" Body="&lt;p&gt;These radio modules are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cheap (1-2£)&lt;/li&gt;&#xA;&lt;li&gt;Have relatively long range (some versions have ~1km range)&lt;/li&gt;&#xA;&lt;li&gt;Ultra low power (no problem powering these modules for really long periods of time from batteries or even coin cells)&lt;/li&gt;&#xA;&lt;li&gt;Easy to use SPI interface if one does not wish to use a library&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are considering or using nRF24L01(+) modules then the most popular library is &lt;a href=&quot;http://tmrh20.github.io/RF24&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. This library is also available for download through the IDE's built-in library manager so that if you have installed it, it won't be hard to keep it up to date. If this barebones library is too complicated then there is also RF24Mesh and RF24Network libraries, each making the communication even simpler.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="11529" LastEditDate="2016-02-06T12:24:02.207" LastActivityDate="2016-02-06T12:24:02.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9259" PostTypeId="4" CreationDate="2015-03-13T11:25:44.103" Score="0" Body="An ultra low-power transceiver for radio communication in the 2.4GHz ISM band (Industrial, Scientific, and Medical). Commonly used by tinkerers because of its low cost and its easy to use SPI interface." OwnerUserId="42" LastEditorUserId="11529" LastEditDate="2015-08-17T11:14:26.783" LastActivityDate="2015-08-17T11:14:26.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9260" PostTypeId="5" CreationDate="2015-03-13T11:26:50.033" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:26:50.033" LastActivityDate="2015-03-13T11:26:50.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9261" PostTypeId="4" CreationDate="2015-03-13T11:26:50.033" Score="0" Body="The process of finding and resolving problems ('bugs') in a hardware and/or software system." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:26:50.033" LastActivityDate="2015-03-13T11:26:50.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9262" PostTypeId="5" CreationDate="2015-03-13T11:29:07.240" Score="0" Body="&lt;p&gt;The MPU-6050 is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Gyroscope&quot; rel=&quot;nofollow noreferrer&quot;&gt;gyroscope&lt;/a&gt; / &lt;a href=&quot;https://en.wikipedia.org/wiki/Accelerometer&quot; rel=&quot;nofollow noreferrer&quot;&gt;accelerometer&lt;/a&gt; IC made by &lt;a href=&quot;https://www.invensense.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;InvenSense&lt;/a&gt;. It can measure movement in 6 axes, 3 of acceleration and 3 of rotation. You can use it as an accelerometer and a gyroscope at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C&lt;/a&gt; protocol which makes it easy to combine this sensor with many other I2C using sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important: Notice that this IC runs on &lt;strong&gt;3.3V&lt;/strong&gt; which means 5V will burn it out.  However, some breakouts, like the &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/B008BOPN40&quot; rel=&quot;nofollow noreferrer&quot;&gt;GY-521&lt;/a&gt;, have all that you need to connect an MPU-60X0 directly to your Arduino.  The GY-521 has a voltage regulator so it's ok with 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&quot; rel=&quot;nofollow noreferrer&quot;&gt;There is a good library on GitHub that is quite popular for this sensor.&lt;/a&gt;  With detailed and understandable examples, beginners can use it too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Datasheet from InvenSense&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="27346" LastEditDate="2018-11-17T14:24:47.867" LastActivityDate="2018-11-17T14:24:47.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9263" PostTypeId="4" CreationDate="2015-03-13T11:29:07.240" Score="0" Body="The MPU-6050 is a 6DOF. In other words it has 6 Degrees Of Freedom, 3 axes of acceleration (x, y, z) and 3 axes of rotational movement (yaw, pitch, roll). It uses the I2C protocol." OwnerUserId="42" LastEditorUserId="27157" LastEditDate="2016-12-23T15:47:49.567" LastActivityDate="2016-12-23T15:47:49.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9264" PostTypeId="5" CreationDate="2015-03-13T11:32:37.587" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:32:37.587" LastActivityDate="2015-03-13T11:32:37.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9265" PostTypeId="4" CreationDate="2015-03-13T11:32:37.587" Score="0" Body="Typically refers to a specific type of device which allows raw serial communication with a PC via USB." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:32:37.587" LastActivityDate="2015-03-13T11:32:37.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9266" PostTypeId="5" CreationDate="2015-03-13T11:33:54.730" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:33:54.730" LastActivityDate="2015-03-13T11:33:54.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9267" PostTypeId="4" CreationDate="2015-03-13T11:33:54.730" Score="0" Body="The process of improving the efficiency of a program such that is uses less memory and/or less computational time." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:33:54.730" LastActivityDate="2015-03-13T11:33:54.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9268" PostTypeId="5" CreationDate="2015-03-13T11:36:28.700" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:36:28.700" LastActivityDate="2015-03-13T11:36:28.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9269" PostTypeId="4" CreationDate="2015-03-13T11:36:28.700" Score="0" Body="Identifies the size and nature of information held by a variable in a program. It is language-dependent. Examples for C/C++ include: `int`, `float`, and `char`." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:36:28.700" LastActivityDate="2015-03-13T11:36:28.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9270" PostTypeId="5" CreationDate="2015-03-13T11:39:56.657" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:39:56.657" LastActivityDate="2015-03-13T11:39:56.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9271" PostTypeId="4" CreationDate="2015-03-13T11:39:56.657" Score="0" Body="The program code stored/running on an embedded device. The term is sometimes used interchangeably with &quot;software&quot;." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:39:56.657" LastActivityDate="2015-03-13T11:39:56.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9272" PostTypeId="5" CreationDate="2015-03-13T11:40:44.563" Score="0" Body="&lt;p&gt;A transistor is a semiconductor device used to amplify and switch electronic signals and electrical power. It is composed of semiconductor material with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor's terminals changes the current through another pair of terminals. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Transistor&quot; rel=&quot;nofollow&quot;&gt;Transistor - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;See also &lt;a href=&quot;/questions/tagged/mosfet&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;mosfet&amp;#39;&quot; rel=&quot;tag&quot;&gt;mosfet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-06T03:22:41.803" LastActivityDate="2015-09-06T03:22:41.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9273" PostTypeId="4" CreationDate="2015-03-13T11:40:44.563" Score="0" Body="A semiconductor component used for amplifying or switching electrical signals. Use this tag for discussing transistor circuits." OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-06T03:23:19.747" LastActivityDate="2015-09-06T03:23:19.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9274" PostTypeId="5" CreationDate="2015-03-13T11:43:42.100" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:43:42.100" LastActivityDate="2015-03-13T11:43:42.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9275" PostTypeId="4" CreationDate="2015-03-13T11:43:42.100" Score="0" Body="Typically refers to a device which measures orientation." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:43:42.100" LastActivityDate="2015-03-13T11:43:42.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9276" PostTypeId="5" CreationDate="2015-03-13T11:44:55.120" Score="0" Body="&lt;p&gt;The &lt;strong&gt;m&lt;/strong&gt;etal–&lt;strong&gt;o&lt;/strong&gt;xide–&lt;strong&gt;s&lt;/strong&gt;emiconductor &lt;strong&gt;f&lt;/strong&gt;ield-&lt;strong&gt;e&lt;/strong&gt;ffect &lt;strong&gt;t&lt;/strong&gt;ransistor (MOSFET, MOS-FET, or MOS FET) is a type of transistor used for amplifying or switching electronic signals.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/MOSFET&quot; rel=&quot;nofollow&quot;&gt;MOSFET - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;/questions/tagged/transistor&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;transistor&amp;#39;&quot; rel=&quot;tag&quot;&gt;transistor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-06T03:21:29.020" LastActivityDate="2015-09-06T03:21:29.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9277" PostTypeId="4" CreationDate="2015-03-13T11:44:55.120" Score="0" Body="A type of field-effect transistor. Use this tag for discussing MOSFET circuits." OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-06T03:21:29.020" LastActivityDate="2015-09-06T03:21:29.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9278" PostTypeId="5" CreationDate="2015-03-13T11:46:25.270" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:46:25.270" LastActivityDate="2015-03-13T11:46:25.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9279" PostTypeId="4" CreationDate="2015-03-13T11:46:25.270" Score="0" Body="A distribution of the Linux operating system. Use this tag for issues which are specific to working with Arduino in an Ubuntu environment (e.g. uploading a program to an Arduino board from a computer running Ubuntu)." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:46:25.270" LastActivityDate="2015-03-13T11:46:25.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9280" PostTypeId="5" CreationDate="2015-03-13T11:47:52.773" Score="0" Body="&lt;h3&gt;There's an old programmer's saying:&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;The problem with C is that it is too easy to shoot yourself in the foot.&lt;br&gt;&#xA;   With C++ it is much harder - but when you do, you lose your whole leg!&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most of the problems have to do with C/C++ pointers, and people not fully understanding how to use them.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Links&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.stackexchange.com/a/25317/22924&quot;&gt;Here&lt;/a&gt;'s a basic description on pointers, going to the very beginning.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="22924" LastEditDate="2016-06-22T13:35:57.497" LastActivityDate="2016-06-22T13:35:57.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9281" PostTypeId="4" CreationDate="2015-03-13T11:47:52.773" Score="0" Body="A variable in C/C++ which stores the type and location of data in memory." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:47:52.773" LastActivityDate="2015-03-13T11:47:52.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9282" PostTypeId="5" CreationDate="2015-03-13T11:48:42.850" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:48:42.850" LastActivityDate="2015-03-13T11:48:42.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9283" PostTypeId="4" CreationDate="2015-03-13T11:48:42.850" Score="0" Body="An electro-mechanical device for detecting angular position and/or motion." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-13T11:48:42.850" LastActivityDate="2015-03-13T11:48:42.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9285" PostTypeId="1" CreationDate="2015-03-13T15:20:17.580" Score="0" ViewCount="3452" Body="&lt;p&gt;I've looted this speaker from my old PC and trying to understand how to connect it to Arduino to produce simple sound notification (and not fry anything in the process).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand this is a piezo speaker, there is no markings on it. Here is how it looks:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WCLKq.jpg&quot; alt=&quot;speaker front&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/BfWNK.jpg&quot; alt=&quot;speaker back&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I connect\control it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I connect it to PWM pin? If so, what are the safe values to output on PWM pin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I use resistor when connecting speaker? What resistor should I use?&lt;/p&gt;&#xA;" OwnerUserId="7848" LastActivityDate="2015-03-13T15:50:53.203" Title="Connecting PC speaker to Arduino" Tags="|pwm|audio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9286" PostTypeId="2" ParentId="9285" CreationDate="2015-03-13T15:50:53.203" Score="2" Body="&lt;p&gt;No need for a resistor. Just connect black to ground, and red to a IO pin. Use the &lt;a href=&quot;http://arduino.cc/en/reference/tone&quot; rel=&quot;nofollow&quot;&gt;tone&lt;/a&gt; function to specify a frequency.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-13T15:50:53.203" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9287" PostTypeId="1" AcceptedAnswerId="9288" CreationDate="2015-03-13T16:40:30.567" Score="0" ViewCount="491" Body="&lt;p&gt;I am trying to stop servo motor from rotating when I enter 0 in serial. The code is below. Can someone please help?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;  // create servo object to control a servo&#xA;// twelve servo objects can be created on most boards&#xA;int state;&#xA;int pos = 0;    // variable to store the servo position&#xA;&#xA;void setup()&#xA;{&#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object&#xA;  Serial.begin (9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial.available () &amp;gt; 0)&#xA;  {&#xA;    state = Serial.read ();&#xA;    if (state == '1')&#xA;    {&#xA;      for (pos = 0; pos &amp;lt;= 180; pos += 1)&#xA;      {&#xA;        myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;        delay(15);&#xA;      }&#xA;      for (pos = 180; pos &amp;gt;= 0; pos -= 1)&#xA;      {&#xA;        myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;        delay(15);      // waits 15ms for the servo to reach the position&#xA;      }&#xA;      if (Serial.available () &amp;gt; 0)&#xA;      {&#xA;        state = Serial.read ();&#xA;        if (state == '0')&#xA;        {&#xA;          myservo.write ('90');&#xA;          delay (300);&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7875" LastEditorUserId="42" LastEditDate="2015-03-13T18:21:09.267" LastActivityDate="2015-03-13T18:21:09.267" Title="Stop servo when enter 0" Tags="|arduino-uno|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9288" PostTypeId="2" ParentId="9287" CreationDate="2015-03-13T17:16:10.553" Score="1" Body="&lt;p&gt;From the code you posted it looks like you have the right idea but you've nested the 'IF' statements causing the check for '0' to only happen if you send two bytes and it will only go to 90deg when you send '10'.  The loop section should look more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available()){&#xA;    state = Serial.read();&#xA;    if(state == '1'){&#xA;           Make motor move;&#xA;    }else if(state == '0'){&#xA;           Make motor stop;&#xA;    }//end of elseif&#xA;}//end of if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7876" LastActivityDate="2015-03-13T17:16:10.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9290" PostTypeId="2" ParentId="9243" CreationDate="2015-03-13T18:10:46.593" Score="0" Body="&lt;p&gt;In my case i used a buffer and a delimiter. Specificaly: The reading is placed on the byte array untill the delimiter is reached.&lt;/p&gt;&#xA;&lt;h2&gt;For example&lt;/h2&gt;&#xA;&lt;p&gt;From the arduino IDE serial monitor im sending this: &lt;code&gt;CAT;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Each letter will be placed inside the byte array and this will stop when the &lt;code&gt;;&lt;/code&gt; sign is entered. This migh be usefull because you can send the bytes whenever you can and they will remain in the array.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;if(Serial.available() &amp;gt; 0) {&#xA; &#xA; char rec = Serial.read();&#xA;&#xA; if(rec == '.'){&#xA;    Serial.print(&amp;quot;Here: &amp;quot;);&#xA;    for(int i = 0; i &amp;lt; sizeof(attitude); i++){&#xA;       Serial.print(attitude[i]); //print&#xA;       attitude[i] = (char)0;&#xA;    }&#xA;    attitudePointer = 0;&#xA;    Serial.println();&#xA;    &#xA; }else{&#xA;   if(attitudePointer &amp;lt;= sizeof(attitude)){&#xA;      attitude[attitudePointer] = rec;&#xA;      attitudePointer++;&#xA;    }&#xA;  }&#xA;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-13T18:10:46.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9292" PostTypeId="1" CreationDate="2015-03-13T20:27:33.257" Score="0" ViewCount="242" Body="&lt;p&gt;I want to control a phone using an arduino board by connecting each pin of the arduino to a button on the phone using relays to simulate a button being pressed or release by switching a relay (on/off). I am using relays because from what I have seen (&lt;a href=&quot;https://www.youtube.com/watch?v=tuOrH9sSykk&quot; rel=&quot;nofollow&quot;&gt;Use Arduino to Switch Power On and Off! &lt;/a&gt;) relays are controlled swiches and I am using SSR because I want to use the less space possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to buy a relay at &lt;a href=&quot;http://www2.mouser.com/Electromechanical/Relays/Solid-State-Relays/Solid-State-Relays-PCB-Mount/_/N-ay0uc/&quot; rel=&quot;nofollow&quot;&gt;mouser.com&lt;/a&gt; but I don't know what are the values I should look for, for those parameters (Control Voltage Range, Load Voltage Rating, Load Current Rating, Input Current).&lt;/p&gt;&#xA;" OwnerUserId="7883" LastActivityDate="2016-02-19T14:53:18.543" Title="What info should I look for when choosing a solid state relay for arduino?" Tags="|arduino-uno|relay|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9295" PostTypeId="2" ParentId="9292" CreationDate="2015-03-13T21:22:27.363" Score="0" Body="&lt;p&gt;If you're only controlling a button, the load current and load voltage are pretty much irrelevant since I'd be surprised if you even used 5% of it's rating in either category. I can't tell you how much you'll need here since I don't know the voltage that the relay will be operated on and the resistance of the path for the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you do need to look at is the voltage and current of the input/control/logic signal. It should allow a 5V control voltage and the current draw for that logic signal should be no more than 40mA, although it's ideal to stick to a lower number (say, 30mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, manually picking out a relay manually isn't ideal for a beginner since it requires a bit of extra components to properly run. A &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00G9TQH8U&quot; rel=&quot;nofollow&quot;&gt;relay module &lt;strong&gt;(Amazon)&lt;/strong&gt;&lt;/a&gt; allows you just hook up your wires to the jumpers and terminals of the relay module without any extra soldering (as far as I know they aren't breadboard compatible, thus requiring a custom PCB or having it &quot;flop&quot;) or parts.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-13T21:22:27.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9296" PostTypeId="1" AcceptedAnswerId="9303" CreationDate="2015-03-13T21:50:33.323" Score="1" ViewCount="17226" Body="&lt;p&gt;I am writing a class for a project which will take care of handling any LCD updates for my project. The way I want to handle this is to initialize the LCD object in my main file, and then pass the LCD object on to my own class when initializing it.&#xA;The LCD object should be declared a private object in my class so several member functions can access it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is I can't find how to initialize the object correctly in the .h file.&#xA;Below is what I currently have, but when I try to build it, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LCDController.h:_Clcd1' should be initialized&#xA;LCDController.h:_Clcd2' should be initialized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;main .ino file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  //LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0);&#xA;  LiquidCrystal lcd(12, 11, 7, 6, 5, 4);  //declare two LCD's&#xA;  LiquidCrystal lcd2(12, 10, 7, 6, 5, 4); // Ths is the second&#xA;&#xA;  LCDController.init(lcd, lcd2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;LCDController.h file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// LCDController.h&#xA;&#xA;#ifndef _LCDCONTROLLER_h&#xA;#define _LCDCONTROLLER_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;    #include &quot;Arduino.h&quot;&#xA;#else&#xA;    #include &quot;WProgram.h&quot;&#xA;#endif&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;class LCDControllerClass&#xA;{&#xA; protected:&#xA;&#xA;&#xA; public:&#xA;    void init(LiquidCrystal&amp;amp; Clcd1, LiquidCrystal&amp;amp; Clcd2);&#xA;private:&#xA;   void _UpdateLCD(int iLine, int iPosition, String cText);&#xA;   LiquidCrystal&amp;amp; _Clcd1;&#xA;   LiquidCrystal&amp;amp; _Clcd2;&#xA;};&#xA;&#xA;extern LCDControllerClass LCDController;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;LCDController.cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;LCDController.h&quot;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;void LCDControllerClass::init(LiquidCrystal&amp;amp; Clcd1, LiquidCrystal&amp;amp; Clcd2)&#xA;{&#xA;   _Clcd1 = Clcd1;&#xA;   _Clcd1.begin(40, 2);&#xA;   _Clcd1.clear();&#xA;&#xA;   _Clcd2 = Clcd2;&#xA;   _Clcd2.begin(40, 2);&#xA;   _Clcd2.clear();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6635" LastEditorUserId="84" LastEditDate="2015-03-14T07:53:39.797" LastActivityDate="2016-06-23T14:51:10.037" Title="Use object of other class within class" Tags="|programming|c++|lcd|class|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9297" PostTypeId="1" CreationDate="2015-03-14T01:16:08.817" Score="2" ViewCount="172" Body="&lt;p&gt;I'm looking at this specification page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/ArduinoBoardMega2560&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says there are 54 digital input pins. How many of those can be used at the same time to measure pulse input frequency? I've seen examples of a couple pins being used at the same time, but can it handle measuring frequency on say 12 pins at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I am looking at this bluetooth shield:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://redbearlab.com/bleshield/&quot; rel=&quot;nofollow&quot;&gt;http://redbearlab.com/bleshield/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would there be a limit on the number of simultaneous frequency measuring pulse pins when then this is added?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I use an IOIO board and can monitor 9 pulseInput pins (at least it seems like it is simultaneous, but probably not, it has a PIC24FJ256GB206 microcontroller that has 9 input capture modules when used as single precision.) It works well with my around 15-30 Hz signals updated every 250 milliseconds. I'm wanting to move it to arduino for supported connectivity to many other devices. What are the capabilities of the arduino mega?&lt;/p&gt;&#xA;" OwnerUserId="7887" OwnerDisplayName="coconuts4eva" LastEditorUserId="7887" LastEditDate="2015-03-14T15:18:28.820" LastActivityDate="2015-03-14T15:18:28.820" Title="arduino mega number of simultaneous pulse inputs" Tags="|arduino-mega|frequency|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9298" PostTypeId="2" ParentId="7936" CreationDate="2015-03-14T04:17:36.410" Score="0" Body="&lt;p&gt;A 5V cable would be fine, or for about the same price, I would recommend an &lt;a href=&quot;http://www.adafruit.com/product/284&quot; rel=&quot;nofollow&quot;&gt;Adafruit FTDI Friend&lt;/a&gt; which is configurable between 5V and 3.3V.&lt;/p&gt;&#xA;" OwnerUserId="7815" LastActivityDate="2015-03-14T04:17:36.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9299" PostTypeId="2" ParentId="9292" CreationDate="2015-03-14T05:03:11.350" Score="1" Body="&lt;p&gt;I would tread carefully. A solid-state relay may or may not be suitable for the relatively low-level signals present across the phone buttons. Check the datasheet, buy just one, and try it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But do you need to control a physical phone? An Arduino can connect to a standard modem which has inbuilt commands to dial numbers and generally supervise a phone line.&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-03-14T05:03:11.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9300" PostTypeId="1" CreationDate="2015-03-14T05:14:36.597" Score="0" ViewCount="2413" Body="&lt;p&gt;I am relatively new to both Arduino and Processing and I have been working on a code that utilizes serial communication between the two. My Arduino code is reading and printing values from a piezo sensor and then sending the values to Processing, which sketches certain shapes based on the values. The code has worked previously, but for some reason it is no longer working. Everything compiles, but when I run the Processing code the sketch window is empty and remains empty. A few times the &quot;error, disabling serialEvent()&quot; showed up, but I just unplugged my Arduino board, closed out the programs, and restarted everything. The error no longer shows up, but my Processing sketch is still not displaying on the screen. Can someone please let me know what is wrong with my code? I really appreciate the help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;int knockSensor = A0;&#xA;byte val = 0;         &#xA;int statePin = LOW;   &#xA;int THRESHOLD = 5;  &#xA;int sensorReading = 0;&#xA;&#xA;void setup() {&#xA; pinMode(ledPin, OUTPUT); &#xA; Serial.begin(9600);       &#xA;}&#xA;&#xA;void loop() {&#xA; sensorReading = analogRead(knockSensor);    &#xA;&#xA;  if(sensorReading &amp;gt; 0){&#xA;   Serial.println(sensorReading, DEC);&#xA;   delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Processing Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;&#xA;Serial port;&#xA;&#xA;int centerX = 550;&#xA;int centerY = 400;&#xA;&#xA;float val;&#xA;float ellipseX;&#xA;float ellipseY;&#xA;float ellipseW;&#xA;float ellipseH;&#xA;float ellipseXX;&#xA;float ellipseYY;&#xA;float ellipseWW;&#xA;float ellipseHH;&#xA;float lineX;&#xA;float lineY;&#xA;float lineXX;&#xA;float lineYY;&#xA;&#xA;void setup(){&#xA;  background(255);&#xA;  size(1100,800); &#xA;  frameRate(10);&#xA;  smooth();&#xA;&#xA;  String portname = &quot;/dev/tty.usbmodem1411&quot;; &#xA;&#xA;  //String portname = Serial.list()[0];&#xA;  port = new Serial(this, portname, 9600);&#xA;  println(Serial.list());&#xA;  //port.bufferUntil('\n');&#xA;}&#xA;&#xA;void drawEllipse(float val)&#xA;{&#xA;  if(val &amp;gt; 0 &amp;amp;&amp;amp; val &amp;lt; 50)&#xA;  {&#xA;    ellipseX = random(540,560); &#xA;    ellipseY = random(390,410);&#xA;    ellipseW = val + 10;&#xA;    ellipseH = val + 10;&#xA;&#xA;    stroke(0);&#xA;    fill(random(255), random(200,255));&#xA;  }&#xA;}&#xA;&#xA;void drawLines(float val)&#xA;{&#xA;  if(val &amp;gt; 50 &amp;amp;&amp;amp; val &amp;lt; 70)&#xA;  {&#xA;    lineX = random(500, 600);&#xA;    lineY = random(360, 440);&#xA;    lineXX = random(500, 600);&#xA;    lineYY = random(360, 440);&#xA;&#xA;    stroke(0);&#xA;  }&#xA;}&#xA;&#xA;void drawEllipse2(float val)&#xA;{&#xA;  if(val &amp;gt; 70 &amp;amp;&amp;amp; val &amp;lt; 120)&#xA;  {&#xA;    ellipseXX = random(460, 640); &#xA;    ellipseYY = random(330, 470);&#xA;    ellipseWW = val + random(20);&#xA;    ellipseHH = val + 10;&#xA;&#xA;    stroke(0);&#xA;    fill(random(50, 100), random(50, 100), random(50, 100), random(220, 255));&#xA;  }&#xA;}&#xA;&#xA;void serialEvent(Serial port) &#xA;{&#xA;  String inString = port.readStringUntil('\n');&#xA;&#xA;  if (inString != null)&#xA;  {&#xA;      val = Float.parseFloat(inString);&#xA;  }&#xA;&#xA;  drawEllipse(val);&#xA;  drawLines(val);&#xA;  drawEllipse2(val);&#xA;  println(val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7888" LastActivityDate="2015-11-16T12:37:19.123" Title="Error with Arduino/Processing Serial Communication" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9301" PostTypeId="2" ParentId="9300" CreationDate="2015-03-14T06:19:07.060" Score="1" Body="&lt;p&gt;It seems like you need to do some basic debugging:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Put a println() in setup. If this does not appear, you have a major problem talking to the Arduino board.&lt;/li&gt;&#xA;&lt;li&gt;Put a println() statement in the loop() that prints out the sensor reading. That should separate hardware problems from software defects.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-03-14T06:19:07.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9302" PostTypeId="1" AcceptedAnswerId="9309" CreationDate="2015-03-14T08:09:15.340" Score="2" ViewCount="1028" Body="&lt;p&gt;I would like to know what the exact difference is between the Uno and Mega boards and the older boards (Duemilanove, Diecimila, etc.).  Why do I need to install a FTDI driver for the older boards, and not for the Uno/Mega boards?  I was in a class the other day, using the Nano, and the lecturer recommended the FTDI drivers. &lt;strike&gt;The Nano is a newer type board, so why does that require a driver?&lt;/strike&gt; I've just discovered that the Nano is old tech from 2008, after reading &lt;a href=&quot;https://arduino.stackexchange.com/questions/4480/are-there-any-reasons-to-pick-nano-over-micro/4489#4489&quot;&gt;Are there any reasons to pick Nano over Micro?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is it about the Uno and Mega boards that don't require the FTDI to be separately installed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that the &lt;a href=&quot;http://www.arduino.cc/en/Guide/MacOSX&quot; rel=&quot;nofollow noreferrer&quot;&gt;Getting Started w/ Arduino on Mac OS X&lt;/a&gt; page states that the older boards use the FTDI chip. Does that imply that the Uno/Mega boards do not? If they do not, then what do they use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a vague notion that some USB sticks, keyboards, mouse and other various USB devices may contain a driver within the circuitry/firmware(?) of the device, which when connected to a PC for the first time, can be used to install the driver without the PC needing to access the web for the driver. Is this what the difference is between the UNO/Mega and the older devices? If so, is it possible to modify, or flash the firmware of the older boards so that they can connect without the need for an FTDI driver?&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-03-15T07:58:54.910" Title="Regarding the USB port, what is the difference between Uno/Mega and the older boards?" Tags="|usb|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9303" PostTypeId="2" ParentId="9296" CreationDate="2015-03-14T08:32:18.843" Score="4" Body="&lt;p&gt;In C++, a class that holds reference members (in your sample, &lt;code&gt;LiquidCrystal&amp;amp; _Clcd1;&lt;/code&gt; and &lt;code&gt;LiquidCrystal&amp;amp; _Clcd2;&lt;/code&gt;) must ensure these references are initialized at construction time, not later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means your &lt;code&gt;void init(LiquidCrystal&amp;amp; Clcd1, LiquidCrystal&amp;amp; Clcd2);&lt;/code&gt; method is not the right way to initialize &lt;code&gt;_Clcd1&lt;/code&gt; and &lt;code&gt;_Clcd2&lt;/code&gt; because it will be called &lt;strong&gt;after construction time&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 2 ways to solve this issue,t hat I will detail further below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HOWEVER&lt;/strong&gt;, before we discuss the solutions, you must be aware that your sample code has &lt;strong&gt;a huge defect in &lt;code&gt;setup()&lt;/code&gt; method code&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    //LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0);&#xA;    LiquidCrystal lcd(12, 11, 7, 6, 5, 4);  //declare two LCD's&#xA;    LiquidCrystal lcd2(12, 10, 7, 6, 5, 4); // Ths is the second&#xA;&#xA;    LCDController.init(lcd, lcd2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, you create &lt;code&gt;lcd&lt;/code&gt; and &lt;code&gt;lcd2&lt;/code&gt; in your &lt;code&gt;setup&lt;/code&gt; method, but their life ends at the end of &lt;code&gt;setup()&lt;/code&gt;, because they have been allocated &lt;strong&gt;on the stack&lt;/strong&gt;. Using these outside &lt;code&gt;setup()&lt;/code&gt; will most likely cause your program to crash as soon as your &lt;code&gt;loop()&lt;/code&gt; tries to access &lt;code&gt;lcd&lt;/code&gt; or &lt;code&gt;lcd2&lt;/code&gt;, indirectly through &lt;code&gt;LCDController&lt;/code&gt; method calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To remove this defect, you must declare these variables outside &lt;code&gt;setup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0);&#xA;LiquidCrystal lcd(12, 11, 7, 6, 5, 4);  //declare two LCD's&#xA;LiquidCrystal lcd2(12, 10, 7, 6, 5, 4); // Ths is the second&#xA;&#xA;void setup()&#xA;{&#xA;    LCDController.init(lcd, lcd2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use them anywhere in your program, you are sure they are present and &quot;alive&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we can go to the solutions of the original compilation problem.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;1. Initialize references at construction by adding a constructor&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class LCDControllerClass&#xA;{&#xA;    public:&#xA;    LCDControllerClass(LiquidCrystal&amp;amp; Clcd1, LiquidCrystal&amp;amp; Clcd2)&#xA;    : _Clcd1(Clcd1), _Clcd2(Clcd2) {}&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can still keep an &lt;code&gt;void init()&lt;/code&gt; method to complete the initialization if you don't want it to occur right at construction time, or you can fully integrate the current &lt;code&gt;init()&lt;/code&gt; content into the constructor and re,voe &lt;code&gt;init()&lt;/code&gt; altogether:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class LCDControllerClass&#xA;{&#xA;    public:&#xA;    LCDControllerClass(LiquidCrystal&amp;amp; Clcd1, LiquidCrystal&amp;amp; Clcd2)&#xA;    : _Clcd1(Clcd1), _Clcd2(Clcd2)&#xA;    {&#xA;        _Clcd1.begin(40, 2);&#xA;        _Clcd1.clear();&#xA;&#xA;        _Clcd2.begin(40, 2);&#xA;        _Clcd2.clear();&#xA;    }&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In anycase, you will have to change the way you instantiate your &lt;code&gt;LCDControllerClass LCDController&lt;/code&gt; which you did not show in your sample code, that would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal lcd(...);&#xA;LiquidCrystal lcd2(...);&#xA;LCDControllerClass LCDController(lcd, lcd2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That obviously requires that you can instantitate &lt;code&gt;lcd&lt;/code&gt; and &lt;code&gt;lcd2&lt;/code&gt; &lt;strong&gt;before&lt;/strong&gt; creating &lt;code&gt;LCDController&lt;/code&gt;. If that is not possible for you, then  you'll have to use the second way.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;2. Replace references with pointers&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;As mentioned before, in a class reference members MUST be initialized at construction time (moreover, they cannot be changed afterwards, to point somewhere else). This is not the case for pointers however:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class LCDControllerClass&#xA;{&#xA;    public:&#xA;    void init(LiquidCrystal* Clcd1, LiquidCrystal* Clcd2);&#xA;&#xA;    private:&#xA;    void _UpdateLCD(int iLine, int iPosition, String cText);&#xA;    LiquidCrystal* _Clcd1;&#xA;    LiquidCrystal* _Clcd2;&#xA;};&#xA;&#xA;void LCDControllerClass::init(LiquidCrystal* Clcd1, LiquidCrystal* Clcd2)&#xA;{&#xA;   _Clcd1 = Clcd1;&#xA;   _Clcd1-&amp;gt;begin(40, 2);&#xA;   _Clcd1-&amp;gt;clear();&#xA;&#xA;   _Clcd2 = Clcd2;&#xA;   _Clcd2-&amp;gt;begin(40, 2);&#xA;   _Clcd2-&amp;gt;clear();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that now, you need to use the arrow notation &lt;code&gt;-&amp;gt;&lt;/code&gt; to access &lt;code&gt;_Clcd1&lt;/code&gt; and &lt;code&gt;_Clcd2&lt;/code&gt; members (dot notation cannot work for pointers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of the code should be slightly modified to reflect this change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0);&#xA;LiquidCrystal lcd(12, 11, 7, 6, 5, 4);  //declare two LCD's&#xA;LiquidCrystal lcd2(12, 10, 7, 6, 5, 4); // Ths is the second&#xA;&#xA;void setup()&#xA;{&#xA;    LCDController.init(&amp;amp;lcd, &amp;amp;lcd2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that we now have to pass &lt;strong&gt;the address&lt;/strong&gt; of &lt;code&gt;lcd&lt;/code&gt; and &lt;code&gt;lcd2&lt;/code&gt; to &lt;code&gt;init()&lt;/code&gt;, by using &lt;code&gt;&amp;amp;&lt;/code&gt; before their names.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-03-14T08:32:18.843" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9304" PostTypeId="2" ParentId="4019" CreationDate="2015-03-14T08:51:56.033" Score="-1" Body="&lt;p&gt;the interrupt pin in the attachInterrupt command should be kept to #4 which is pin D7 as stated here &quot;&lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/AttachInterrupt&lt;/a&gt;&quot; since we can't use pins D0-D3 the only left out option is D7 but the problem still persists. Somebody please solve this !!&lt;/p&gt;&#xA;" OwnerUserId="7892" LastActivityDate="2015-03-14T08:51:56.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9305" PostTypeId="2" ParentId="9244" CreationDate="2015-03-14T09:02:01.607" Score="0" Body="&lt;p&gt;I was able to compile your code &quot;ATTiny85-Slave Code&quot; without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try to extract the contents of the ZIP archive (i.e. the library) directly to the directory where your sketch is stored. &lt;code&gt;#include &quot;TinyWireS.h&quot;&lt;/code&gt; should then pick up that version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also switch on verbose output for the compilation to have a look at the directory in which the code is compiled. Here you would find (at least in my older Arduino IDE version) copies of the included files. (&lt;code&gt;/tmp/build...&lt;/code&gt; on Linux systems.) You can then make sure the proper version of the files is used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also search your drives for other copies of &lt;code&gt;TinyWireS.h&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-03-14T09:02:01.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9306" PostTypeId="1" CreationDate="2015-03-14T09:04:26.977" Score="0" ViewCount="2086" Body="&lt;p&gt;I want to control my Arduino using my wireless Xbox 360 controller. I've been looking up tutorials, and they all seem to recommend using a &lt;a href=&quot;https://i.stack.imgur.com/qhGKS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB shield&lt;/a&gt; and the &lt;a href=&quot;https://i.stack.imgur.com/6l1Ys.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Xbox 360 wireless receiver&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't own either of those things, but I do own a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E594ZX0&quot; rel=&quot;nofollow noreferrer&quot;&gt;2.4 GHz wireless transceiver&lt;/a&gt;. Can I use it to listen to what buttons are being pressed on the controller? For example, if I press the A button on the controller, can I make an LED turn on?&lt;/p&gt;&#xA;" OwnerUserId="7891" LastActivityDate="2015-03-15T00:08:05.387" Title="Can I control my Arduino using just a 2.4GHz Wireless Transceiver and a wireless Xbox 360 controller?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9307" PostTypeId="2" ParentId="9306" CreationDate="2015-03-14T10:26:42.297" Score="1" Body="&lt;p&gt;From the hardware side it should be possible but from the software it may not be easy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you find some documentation on the protocol that is used for communication between controller and receiver, you will need to decode the protocol (handshaking, commands, idle signals etc.) yourself. &#xA;Depending on the complexity of the protocol that could be rather frustrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to do some research on the Internet first and see if there is material describing the protocol so you don't have to start from scratch.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-03-14T10:26:42.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9308" PostTypeId="1" AcceptedAnswerId="9346" CreationDate="2015-03-14T13:53:06.893" Score="0" ViewCount="1209" Body="&lt;p&gt;I have made a simple server using the YUN SERVER and CLIENT Libraries./&#xA;The server runs on a loop and waits for a client to connect. After connection it sends the client a simple message and then disconnects the client.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;YunServer.h&amp;gt;&#xA;#include &amp;lt;YunClient.h&amp;gt;&#xA;&#xA;#define PORT 6666&#xA;YunServer server(PORT);&#xA;int pin =13;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Bridge.begin();&#xA;  server.noListenOnLocalhost();&#xA;  server.begin();&#xA;}&#xA;void loop() {&#xA;  YunClient client = server.accept();&#xA;  if(client.connected())&#xA;  {&#xA;    digitalWrite(pin,HIGH);&#xA;    //startup&#xA;    startup_msg(client);&#xA;  }&#xA;  else  &#xA;    digitalWrite(pin,LOW);&#xA;    delay(500);&#xA;}&#xA;void startup_msg(YunClient client)&#xA;{&#xA;    client.print(&quot;SAndTerm&quot;);&#xA;    client.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well this code runs smoothly for few hours. But after that, it stops responding to any client request. I guess the server crashes.&#xA;I have to restart the YUN to get it working again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway I can run this without it getting to crash?&#xA;Well I want it to be running just like a normal server would.&lt;/p&gt;&#xA;" OwnerUserId="7811" LastActivityDate="2015-03-15T04:20:08.080" Title="Arduino YUN server crashes after few hours!" Tags="|arduino-yun|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9309" PostTypeId="2" ParentId="9302" CreationDate="2015-03-14T15:34:14.877" Score="4" Body="&lt;p&gt;The older Arduino boards used an FTDI FT232R chip to handle the USB port. This chip is a special purpose, USB to serial UART interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the current Arduino boards, the USB to serial conversion is handled by dedicated &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA8U2.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Atmega8u2&lt;/a&gt; processor. This is a processor that is similar to the main ATmega328p processor, but the added benefit of having built-in USB capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, why the change? Well, first, it's cheaper than the FTDI chip, and second, it can do much more. Being that it's an actual microprocessor, you can actually reprogram this chip to behave like different USB devices. For example, you can reprogram it to make your Arduino look like a keyboard, a joystick, a thumb drive, a MIDI instrument - anything that you can do via USB. The FTDI chip does not have this capability, and so it can only ever look like a serial COM port to your PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why have 2 microprocessors on the Arduino? By having a dedicated processor to handle the USB communication, it keeps the main processor free to run your sketches. Plus, the Arduino team felt that this design keeps the Arduino more &quot;hackable&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wouldn't it be cheaper to make a board using just the one processor that has built-in USB? Yes! That is exactly what the Arduino Leonardo is. It uses the Atmega32U2, the big brother to the Atmega8U2.&lt;/p&gt;&#xA;" OwnerUserId="7815" LastEditorUserId="84" LastEditDate="2015-03-15T07:58:54.910" LastActivityDate="2015-03-15T07:58:54.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9312" PostTypeId="2" ParentId="9306" CreationDate="2015-03-14T17:54:48.630" Score="2" Body="&lt;p&gt;I don't know much about the engineering that goes into these kind of radios, but just being 2.4Ghz does not make them potentially compatible. xbox 360 controllers coexist with wifi and bluetooth without interfering, but they are all in the 2.4Ghz spectrum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The xbox 360 controllers have some kind of proprietary frequency hopping system to avoid interference that you would first have find and reverse engineer before you could even get to the part about decoding the data, and your 2.4Ghz receiver probably can't match the 360 controllers even if you did know the pattern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm relativly confident that it is practically impossible for that receiver to read 360 controller signals.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-14T17:54:48.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9313" PostTypeId="1" CreationDate="2015-03-14T18:45:38.567" Score="2" ViewCount="660" Body="&lt;p&gt;It will be simple. I started to look at the sketch of the Arduino Robot and just tried one, Disco_Bot, and uploaded it one the top board. The Arduino started to play some music and the name was on de LCD screen but he wasn't moving. Then i tried then sketch Wheel_Calibration. The information was on the screen but the Robot was supposed to move so that i could calibrate the speed. I was lost so I went on the Arduino page for the Arduino Robot (&lt;a href=&quot;http://arduino.cc/en/Guide/Robot&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Guide/Robot&lt;/a&gt;) and found nothing that could explain my problem . So now I ask you, can you please help me because iI have no idea on what i should do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chris&lt;/p&gt;&#xA;" OwnerUserId="7898" LastActivityDate="2015-03-14T18:45:38.567" Title="My Arduino Robot doesn't move, and it's the only thing that doesn't work" Tags="|motor|sketch|robotics|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9314" PostTypeId="2" ParentId="1013" CreationDate="2015-03-14T18:58:17.687" Score="4" Body="&lt;p&gt;&lt;strong&gt;See example at:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://github.com/BenTommyE/Arduino_getStringPartByNr&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/BenTommyE/Arduino_getStringPartByNr&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// splitting a string and return the part nr index split by separator&#xA;String getStringPartByNr(String data, char separator, int index) {&#xA;    int stringData = 0;        //variable to count data part nr &#xA;    String dataPart = &quot;&quot;;      //variable to hole the return text&#xA;&#xA;    for(int i = 0; i&amp;lt;data.length()-1; i++) {    //Walk through the text one letter at a time&#xA;        if(data[i]==separator) {&#xA;            //Count the number of times separator character appears in the text&#xA;            stringData++;&#xA;        } else if(stringData==index) {&#xA;            //get the text when separator is the rignt one&#xA;            dataPart.concat(data[i]);&#xA;        } else if(stringData&amp;gt;index) {&#xA;            //return text and stop if the next separator appears - to save CPU-time&#xA;            return dataPart;&#xA;            break;&#xA;        }&#xA;    }&#xA;    //return text if this is the last part&#xA;    return dataPart;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7899" LastEditorUserId="4628" LastEditDate="2017-01-17T17:16:04.683" LastActivityDate="2017-01-17T17:16:04.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9315" PostTypeId="1" AcceptedAnswerId="9316" CreationDate="2015-03-14T19:57:06.557" Score="1" ViewCount="335" Body="&lt;p&gt;I would like to connect my custom-made Arduino with an Ethernet shield but I'm not so sure I can.&lt;/p&gt;&#xA;&lt;h2&gt;The problem&lt;/h2&gt;&#xA;&lt;p&gt;My board is using the design from the Arduino Mini which lacks the &lt;code&gt;ATmega16U2&lt;/code&gt; which does the USB-to-serial conversion and adds the &lt;code&gt;ICSP&lt;/code&gt; pins. I think you get the point... I have only the &lt;code&gt;ATmega328P&lt;/code&gt; on the board. Nothing else.&lt;/p&gt;&#xA;&lt;p&gt;Is it even possible to work my way around it without adding the &lt;code&gt;ATmega16U2&lt;/code&gt;? I can't find the chip anywhere on Ebay.&lt;/p&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-16T00:22:44.347" Title="Ethernet Shield on Arduino Mini" Tags="|shields|ethernet|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9316" PostTypeId="2" ParentId="9315" CreationDate="2015-03-14T20:52:21.340" Score="2" Body="&lt;p&gt;You can just connect the pins used on the shield the the corresponding pins on your custom board. Check the &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-06-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Schematic&lt;/a&gt; to see what pins are used for what (and which can be left unconnected)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;The only thing you need to lookout for is, that the ethernets shield seems to require 3.3v&lt;/strike&gt; (the shield has it's own 3.3v regulator, so you only need to connect 5v)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That 16u2 doesn't do anything but usb-to-serial. It's not needed for the ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ISP header is just 5v, GND, and the 3 SPI pins and reset. But those SPI pins are also broken out to the pins 11, 12 and 13.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-03-15T12:28:44.110" LastActivityDate="2015-03-15T12:28:44.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9317" PostTypeId="2" ParentId="9292" CreationDate="2015-03-14T22:03:24.047" Score="1" Body="&lt;p&gt;An SSR is not a good choice for your application.  The common use of an SSR is for switching on and off an &lt;strong&gt;AC&lt;/strong&gt; load.  If the data sheet mentions SCR or Triac, then it is meant for only switching AC and will not function for controlling DC.  So keep this in mind when looking for components: if it says &quot;24-220 VAC&quot; on the data sheet that does not mean it will work for DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second common use of SSR and microcontrollers is the opto-coupled input type.  That input method provides a safe scheme for a low voltage low current control signal to switch a large load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a button on a phone, you are switching a near zero current DC load.  You should be able to control that with a transistor, but that would require some reverse engineering of how the phone keypads where being scanned.  You would need to trace out what the voltage was, how much voltage drop could be accommodated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A certain easy method is to use a small reed relay.  Parts are available that have a coil that only draws ~10 mA so can be driven directly from an output pin.  The relays are packaged in a DIP so easy to prototype on a breadboard.  Many list the coil resistance and voltage for specs, for example a 5V and 500 ohm resistance coil would draw 10 mA.  You will find many for 1 - 2 $US.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When working with a relay, you need to take care of the back EMF (aka flyback voltage) that occurs when you turn off.  That is handled with a single diode which you will see in every schematic for driving a relay.  For a beginner, an alternate/sure success route is to use a driver chip such as a ULN2003 that will drive inductive loads such as small relays.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-03-14T22:03:24.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9318" PostTypeId="2" ParentId="9306" CreationDate="2015-03-15T00:08:05.387" Score="3" Body="&lt;p&gt;Short answer is no, unless you have the machine and tools to do reverse engineering on the xbox controller proprietary 2.4Ghz protocol and you must have xbox 360 itself to see what goes on between Xbox 360 and the xBox controller. The time and money spent on these tools(hardware and software) aren't worth it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way to do this is to buy the xbox controller receiver, Arduino USB shield and you can easily use your xbox 360 controller with your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7904" LastActivityDate="2015-03-15T00:08:05.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9319" PostTypeId="1" AcceptedAnswerId="9320" CreationDate="2015-03-15T00:30:40.163" Score="1" ViewCount="1518" Body="&lt;p&gt;I have a 40x4 LCD which internally consists of 2 40x2 LCDs.&#xA;To control this LCD I have to create 2 &lt;code&gt;LiquidCrystal&lt;/code&gt; objects and than later on in code decide which one to use depending on which of the 4 lines I want to change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the size of my project, I split all the LCD handling off to a separate class.&#xA;To make my code as readable and easy as possible, I want to create a member method of this class, to which I can just pass line number 1-4, and have this method take care of deciding which &lt;code&gt;LiquidCrystal&lt;/code&gt; object to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LCDController.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;class LCDControllerClass&#xA;{&#xA; protected:&#xA;&#xA; public:&#xA;        void init(LiquidCrystal* Clcd1, LiquidCrystal* Clcd2);&#xA; private:&#xA;   void _UpdateLCD(int _iLine, int _iPosition, String _strText, int _iFieldLength);&#xA;   LiquidCrystal* _Clcd1;&#xA;   LiquidCrystal* _Clcd2;&#xA;};&#xA;extern LCDControllerClass LCDController;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My 2 &lt;code&gt;LiquidCrystal&lt;/code&gt; objects are initialized in my main .ino file like so (before the &lt;code&gt;setup()&lt;/code&gt; loop)&#xA;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal lcd(12, 11, 7, 6, 5, 4);  //declare two LCD's&#xA;LiquidCrystal lcd2(12, 10, 7, 6, 5, 4); // Ths is the second&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These two objects are then passed as pointers to my &lt;code&gt;LCDControllerClass&lt;/code&gt; like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LCDController.init(&amp;amp;lcd, &amp;amp;lcd2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;init()&lt;/code&gt; member method of my &lt;code&gt;LCDControllerClass&lt;/code&gt; then puts these pointers in private variables like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void LCDControllerClass::init(LiquidCrystal* Clcd1, LiquidCrystal* Clcd2)&#xA;{&#xA;   _Clcd1 = Clcd1;&#xA;   _Clcd1-&amp;gt;begin(40, 2);&#xA;   _Clcd1-&amp;gt;clear();&#xA;&#xA;   _Clcd2 = Clcd2;&#xA;   _Clcd2-&amp;gt;begin(40, 2);&#xA;   _Clcd2-&amp;gt;clear();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I have another private member method which should take care of updating the correct LCD object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void LCDControllerClass::_UpdateLCD(int _iLine, int _iPosition, String _strText, int _iFieldLength)&#xA;{&#xA;   LiquidCrystal* CActiveLCD;&#xA;   if (_iLine &amp;gt; 2)&#xA;   {&#xA;      //DisplayLine is higher than 2, this means we need to update the 2nd LCD&#xA;      LiquidCrystal** CActiveLCD = &amp;amp;_Clcd2;&#xA;      _iLine = _iLine - 2; //Convert line number to correct line number for 2nd display&#xA;   }&#xA;   else&#xA;   {&#xA;      //LiquidCrystal** CActiveLCD = &amp;amp;_Clcd1;&#xA;   }&#xA;   /* we have to convert this number&#xA;      to a real display line (0-1) by substracting 1 again&#xA;   */&#xA;   _iLine = _iLine - 1;&#xA;&#xA;   CActiveLCD-&amp;gt;setCursor(_iPosition, _iLine);&#xA;   CActiveLCD-&amp;gt;print(_strText);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in this last member mehthor my code goes into the woods for some reason. The LCD is not updated at all and it seems the arduino is freezing as well since I put a small &lt;code&gt;Serial.print()&lt;/code&gt; test in the main loop and it's not printing anything...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the correct way to pass the correct &lt;code&gt;LiquidCrystal&lt;/code&gt; object to the &lt;code&gt;CActiveLCD&lt;/code&gt; &#xA;object?&lt;/p&gt;&#xA;" OwnerUserId="6635" LastActivityDate="2015-03-15T01:05:30.047" Title="How to dynamically switch between between 2 objects?" Tags="|c++|class|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9320" PostTypeId="2" ParentId="9319" CreationDate="2015-03-15T01:05:30.047" Score="2" Body="&lt;p&gt;The problem is that you're declaring multiple pointer variables called &lt;code&gt;CActiveLCD&lt;/code&gt; in the &lt;code&gt;_UpdateLCD()&lt;/code&gt; function. You do it once at the start of the function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal* CActiveLCD;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You then declare a new and &lt;strong&gt;totally separate&lt;/strong&gt; pointer inside the &lt;code&gt;if&lt;/code&gt; block like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal** CActiveLCD = &amp;amp;_Clcd2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is called masking. The original pointer you declared at the start of the function still exists, but you can't access it because it's temporarily replaced by the new one. When the &lt;code&gt;if&lt;/code&gt; block finishes, that new pointer is destroyed (it goes out of scope) and the old one is available again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of that means you never actually store a value in the original pointer variable. The result is that it contains an arbitrary memory address, so attempting to use it at the end of the function results in undefined behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you are assigning to the pointer inside your &lt;code&gt;if&lt;/code&gt; block, you need to do it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CActiveLCD = _Clcd2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that this doesn't declare a new &lt;code&gt;CActiveLCD&lt;/code&gt; pointer. It simply copies &lt;code&gt;_Clcd2&lt;/code&gt; into the existing one. Additionally, it's important not to use the address-of operator here (&lt;code&gt;&amp;amp;&lt;/code&gt;). Adding that in this context gives you a pointer-to-a-pointer. It is technically legitimate in C++, and sometimes does serve a useful purpose, but it's not what you want to do here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, when declaring a pointer variable it's usually a good idea to initialise it to something. If you're not assigning an actual address to it right away then initialise it to &lt;code&gt;0&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal* CActiveLCD = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means you can check the pointer later on before using it. If it's &lt;code&gt;0&lt;/code&gt; then you know it's not got a valid address yet so it's not safe to use. This isn't always strictly necessary, but it can help avoid some frustrating bugs.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-15T01:05:30.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9322" PostTypeId="2" ParentId="9242" CreationDate="2015-03-15T01:45:01.297" Score="1" Body="&lt;p&gt;What you are looking for is a way to safely interleave transmitting characters while at same time responding to the interrupts.  You can wrap the sending of bytes with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noInterrupts();&#xA;swSerial.write(&quot;somethinglongyaddayadda&quot;); // takes 50-60 ms&#xA;interrupts();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will protect the write() operation from being interrupted and ruined by you sensor interrupt handler.  But as you note, that will block the ability to process the the sensor every 2.5 ms.  During the noInterrupts() period you would miss readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve the interleave of both operations, you should transmit the message one character at a time.  Implement a transmit queue to hold the outbound string.  When it has characters, send them 1 at a time, wrapping each interrupt protection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...inside loop...&#xA;if(txQueue is not empty) {&#xA;  // do not need noInterrupts() or cli() as these are inside write();&#xA;  swSerial.write(one character from Q); // takes ~1 ms&#xA;  txPointerHead += 1;&#xA;}&#xA;// at this point the interrupts are enabled &#xA;// and the sensor will be processed if available&#xA;// if the interrupt occurred in the middle of the above, &#xA;// the level is still set and the interrupt handler will be invoked&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 1 ms is ideal and not accounting for overhead, but it is unlikely the 1 character write time could stretch out to 2.5 ms.  As long as the write time stays under 2.5 ms, you will never drop a sensor reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this interleave means that the characters will have larger inter-character delay.  The serial ports will not care about that.  But if the processing of the sensor data takes too much time, you will not be able to keep up with your 10 messages per second goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some options I see to improve:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a higher baud rate.  The baudrate of the serial port is not related to the bluetooth data rate, so you might as well use the 115.2k.  That will reduce the blocking time.  The baud rate doesn't even need to be the same on both ends.  The BT module isn't a simple modem; it is packetizing characters wrapping them in encryption and transmitting.  The receiver unbundles the packets and pushes out its serial port at the receivers baud rate.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use hardware serial.  Using a hardware serial port greatly reduces the time because all write() does is put one character into a register.  The time for that is microsecond domain.  After the byte is put in the transmit register, the UART handles the clocking of the bits so the microcontroller is free to do other tasks.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3742" LastEditorUserId="3742" LastEditDate="2015-03-17T06:24:19.753" LastActivityDate="2015-03-17T06:24:19.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9323" PostTypeId="5" CreationDate="2015-03-15T02:23:39.117" Score="0" Body="&lt;h2&gt;Introduction&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial uses interrupts and carefully timed sequences to provide aynsc serial communications on ports other than those supported by the hardware serial (HardwareSerial class).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should &lt;strong&gt;not&lt;/strong&gt; use SoftwareSerial if HardwareSerial is available on the same pins. Hardware serial is more robust, and can send and receive in the background. SoftwareSerial cannot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Supported pins&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;On the Atmega328P-based Arduinos (eg. Uno, Pro, Nano, Mini) you can use SoftwareSerial on any pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Mega2560 you can only use it for &lt;strong&gt;receiving&lt;/strong&gt; on pins 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Leonardo and Micro you can only use it for &lt;strong&gt;receiving&lt;/strong&gt; on pins 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because SoftwareSerial requires pin-change interrupts to detect receiving a new byte, and pin-change interrupts are only supported on the pins mentioned above. You do not need pin-change interrupts to transmit, so you can choose any pin for transmitting.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Limitations&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;For timing reasons, SoftwareSerial disables interrupts once a byte has started to be received (until it has been completely received). It also disables interrupts whilst sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you cannot both send, and receive, at the same time, using SoftwareSerial.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;SoftwareSerial only deals with 8-bit bytes. HardwareSerial can read and write from 5 to 9 bits.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;SoftwareSerial only reads/writes with no parity and one stop bit. HardwareSerial can write with none/even/odd parity, and use one or two stop bits.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Because interrupts are turned off during sending and receiving you cannot do as much background processing whilst sending/receiving.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Enhancements&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SoftwareSerial has an &quot;inverted logic&quot; mode on the constructor, which lets you read/write with the normal logic inverted. That is, +5V is a 0-bit, and 0V is a 1-bit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Usefulness&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;It is handy to use SoftwareSerial where you need to access multiple serial devices, such as a GPS and a printer at the same time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Alternatives&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;On the Mega2560 you have four hardware serial ports, so you can use those instead of SoftwareSerial.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is another library: &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial Library&lt;/a&gt;. This removes some of the above limitations, and adds some of its own.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-12T04:32:35.930" LastActivityDate="2015-09-12T04:32:35.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9324" PostTypeId="4" CreationDate="2015-03-15T02:23:39.117" Score="0" Body="A library for emulating UART functionality in software on any available digital IO pins. Use this tag for questions regarding SoftwareSerial." OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-09-12T04:32:35.930" LastActivityDate="2015-09-12T04:32:35.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9325" PostTypeId="5" CreationDate="2015-03-15T02:25:40.657" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:25:40.657" LastActivityDate="2015-03-15T02:25:40.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9326" PostTypeId="4" CreationDate="2015-03-15T02:25:40.657" Score="0" Body="A visual output device typically capable of displaying text and/or graphics. Can include various technologies, such as LCD, OLED, and TFT." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:25:40.657" LastActivityDate="2015-03-15T02:25:40.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9327" PostTypeId="5" CreationDate="2015-03-15T02:28:50.533" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:28:50.533" LastActivityDate="2015-03-15T02:28:50.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9328" PostTypeId="4" CreationDate="2015-03-15T02:28:50.533" Score="0" Body="An Integrated Development Platform for programming and debugging various Atmel microcontrollers including AVRs (which are used in many Arduino boards)." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:28:50.533" LastActivityDate="2015-03-15T02:28:50.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9329" PostTypeId="5" CreationDate="2015-03-15T02:32:14.273" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:32:14.273" LastActivityDate="2015-03-15T02:32:14.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9330" PostTypeId="4" CreationDate="2015-03-15T02:32:14.273" Score="0" Body="A custom structure in C++ (and various other languages) which can contain member data and functions. An instance of a class is called an object." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:32:14.273" LastActivityDate="2015-03-15T02:32:14.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9331" PostTypeId="5" CreationDate="2015-03-15T02:35:04.037" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:35:04.037" LastActivityDate="2015-03-15T02:35:04.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9332" PostTypeId="4" CreationDate="2015-03-15T02:35:04.037" Score="0" Body="Defines how often something occurs, such as pulses in a digital signal, or oscillations in a radio wave." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:35:04.037" LastActivityDate="2015-03-15T02:35:04.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9333" PostTypeId="5" CreationDate="2015-03-15T02:35:57.677" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:35:57.677" LastActivityDate="2015-03-15T02:35:57.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9334" PostTypeId="4" CreationDate="2015-03-15T02:35:57.677" Score="0" Body="Refers to the Arduino-specific library code which is included as standard with the official Arduino IDE." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:35:57.677" LastActivityDate="2015-03-15T02:35:57.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9335" PostTypeId="5" CreationDate="2015-03-15T02:36:56.973" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:36:56.973" LastActivityDate="2015-03-15T02:36:56.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9336" PostTypeId="4" CreationDate="2015-03-15T02:36:56.973" Score="0" Body="A datatype in C/C++ which stores a single-precision floating point number." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:36:56.973" LastActivityDate="2015-03-15T02:36:56.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9337" PostTypeId="5" CreationDate="2015-03-15T02:37:33.967" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:37:33.967" LastActivityDate="2015-03-15T02:37:33.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9338" PostTypeId="4" CreationDate="2015-03-15T02:37:33.967" Score="0" Body="Musical Instrument Digital Interface." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:37:33.967" LastActivityDate="2015-03-15T02:37:33.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9339" PostTypeId="5" CreationDate="2015-03-15T02:38:50.943" Score="0" Body="&lt;p&gt;Most (if not all) of the chips used by the Arduino series can use ICSP (In-Circuit Serial Programming) to reprogram the chip. This is accomplished by sending serial commands to the chip using the SPI interface (Serial Peripheral Interface). Doing this saves the inconvenience (or virtual impossibility, in the case of surface mounted processors) of removing the chip and placing it into a programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, the ICSP interface consists of 6 signals to the target chip:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MOSI - Master Out Slave In&lt;/li&gt;&#xA;&lt;li&gt;MISO - Master In Slave Out&lt;/li&gt;&#xA;&lt;li&gt;SCK - Serial clock&lt;/li&gt;&#xA;&lt;li&gt;Reset&lt;/li&gt;&#xA;&lt;li&gt;V&lt;sub&gt;CC&lt;/sub&gt;&lt;/li&gt;&#xA;&lt;li&gt;Ground&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To program the target chip the programmer holds &lt;code&gt;/RESET&lt;/code&gt; low (ie. at zero volts) and then issues very specific commands via the SPI interface (MOSI/MISO/SCK). This enters &quot;serial programming&quot; mode, in which the processor responds to &quot;commands&quot; sent via SPI as documented in the relevant datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;/RESET&lt;/code&gt; is low, any code already on the chip does not execute.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Contrast to &lt;a href=&quot;/questions/tagged/bootloader&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;bootloader&amp;#39;&quot; rel=&quot;tag&quot;&gt;bootloader&lt;/a&gt; which uses code already installed on the chip (quite possibly by ICSP) and does not require extra hardware.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;/questions/tagged/spi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;spi&amp;#39;&quot; rel=&quot;tag&quot;&gt;spi&lt;/a&gt; &lt;a href=&quot;/questions/tagged/bootloader&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;bootloader&amp;#39;&quot; rel=&quot;tag&quot;&gt;bootloader&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="10794" LastEditDate="2015-08-27T22:38:15.717" LastActivityDate="2015-08-27T22:38:15.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9340" PostTypeId="4" CreationDate="2015-03-15T02:38:50.943" Score="0" Body="In-Circuit Serial Programming, when you program the chip without having to physically remove it and place it in a programmer." OwnerUserId="42" LastEditorUserId="220" LastEditDate="2015-08-27T22:34:22.807" LastActivityDate="2015-08-27T22:34:22.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9341" PostTypeId="5" CreationDate="2015-03-15T02:41:02.087" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:41:02.087" LastActivityDate="2015-03-15T02:41:02.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9342" PostTypeId="4" CreationDate="2015-03-15T02:41:02.087" Score="0" Body="The operating system typically used on Mac computers. Use this tag for questions about using Arduino alongside a Mac environment, such as uploading a program from a Mac." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-15T02:41:02.087" LastActivityDate="2015-03-15T02:41:02.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9343" PostTypeId="1" CreationDate="2015-03-15T02:33:13.257" Score="0" ViewCount="223" Body="&lt;p&gt;I am working on a project using 5 pins of ADC, 5 pins for PWM, and LCD. I need to use Atmega164pa. I would like to know how I can transfer it to Arduino. Is there any Arduino compatible with this chip?&lt;/p&gt;&#xA;" OwnerUserId="7906" OwnerDisplayName="barej" LastActivityDate="2016-01-09T08:13:03.980" Title="Which Arduino is compatible for atmega164pa" Tags="|avr|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9344" PostTypeId="2" ParentId="9343" CreationDate="2015-03-15T03:08:57.807" Score="1" Body="&lt;p&gt;There is an Arduino core for the &lt;a href=&quot;https://github.com/maniacbug/mighty-1284p&quot; rel=&quot;nofollow&quot;&gt;'1284A&lt;/a&gt;, but it can be adapted to the '164A.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-15T03:08:57.807" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9345" PostTypeId="2" ParentId="9242" CreationDate="2015-03-15T03:20:23.243" Score="5" Body="&lt;p&gt;If you are on the ardruino platform, and are using the hardware serial port, you basically don't have to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Serial&lt;/code&gt; library interface already uses a outgoing data-buffer (it's varies between versions, 1.5.5 has it set to 64 bytes. The arduino people keep changing it's size for no reason), where the call to &lt;code&gt;Serial.print()&lt;/code&gt; or &lt;code&gt;Serial.write()&lt;/code&gt; only places the bytes in question into the outgoing buffer, and the buffer is then emptied asynchronously in the background by the TX-ready (&lt;code&gt;UDRE&lt;/code&gt;) interrupt (which is then disabled when the buffer is emptied).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, all you have to do is ensure that you're not placing data into the transmit buffer from both an interrupt and the main &lt;code&gt;loop()&lt;/code&gt;, because it's then possible for the message from the interrupt to be inserted into the middle of the message from the main loop thread.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be easily enough done by either guarding the call to &lt;code&gt;Serial.print()&lt;/code&gt; with &lt;code&gt;cli()&lt;/code&gt; &lt;code&gt;sei()&lt;/code&gt; &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;interrupt guards&lt;/a&gt; in the main &lt;code&gt;loop()&lt;/code&gt; section (or the useless arduino analog: &lt;code&gt;noInterrupts()&lt;/code&gt; and &lt;code&gt;interrupts()&lt;/code&gt;, which are just named proxies for &lt;code&gt;cli()&lt;/code&gt; &lt;code&gt;sei()&lt;/code&gt;, which exists for no good reason), or simply not printing from an interrupt (which is a good idea anyways, string formatting can be slow).&lt;/p&gt;&#xA;" OwnerUserId="86" LastEditorUserId="86" LastEditDate="2017-07-20T23:10:13.613" LastActivityDate="2017-07-20T23:10:13.613" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9346" PostTypeId="2" ParentId="9308" CreationDate="2015-03-15T04:20:08.080" Score="0" Body="&lt;p&gt;Updating your YUN might solve this problem. It is recommended to update it after you buy it because they usually come with old firmware. Make sure its up to date. &#xA;&lt;a href=&quot;http://arduino.cc/en/Tutorial/YunSysupgrade&quot; rel=&quot;nofollow&quot;&gt;Here a link on how to do this&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing to try is to add &lt;code&gt;delay(50);&lt;/code&gt; at the end of the &lt;code&gt;loop()&lt;/code&gt; function. It prevents the processor from doing lots of work.&lt;/p&gt;&#xA;" OwnerUserId="7904" LastActivityDate="2015-03-15T04:20:08.080" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9348" PostTypeId="2" ParentId="9242" CreationDate="2015-03-15T06:37:05.250" Score="2" Body="&lt;p&gt;You want to send a 50 byte (or 52 byte?) sequence every 100 ms (10 Hz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For hardware serial, that will go into a buffer which is emptied via serial interrupts; it should be emptied well before the next 100 ms tic (as you have calculated).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will get about 40 sensor interrupts during that 100 ms.  With hardware serial, that need not be a problem - &lt;strong&gt;so long as you don't send bytes from within a sensor interrupt&lt;/strong&gt;.  If your sensor interrupt just accumulates results and the main loop (non-interrupt) uses those results to periodically send the 50 byte message, you should be good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you were averaging each of the sensor readings.  In the sensor interrupt you might add 1 to the count and add the reading to a sum value.  In the main loop, test if it has it has been 100 msec since the last send, and if so turn off interrupts, divide the sum by the count and store that average in a new variable, zero the sum and count, turn on interrupts.  Then use the computed average to format and send the 50 byte package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's just an example.  The main thing is to make the sensor interrupt quick and simple; and to format and send the packet in the main loop (inhibiting interrupts temporarily while fetching and clearing the variables which get updated during the sensor interrupt).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to use &quot;volatile&quot; for the variables used by both the sensor interrupt and the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial should take care of itself if you use hardware serial, and might even be OK for software serial.  In the latter case, a sensor interrupt in the middle of sending the bits of a single character/byte would mess up the bit timing, but software serial should inhibit interrupts during that time - so your sensor interrupt might be delayed up to a millisecond.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2015-03-15T06:37:05.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9349" PostTypeId="1" CreationDate="2015-03-15T08:03:11.213" Score="4" ViewCount="7061" Body="&lt;p&gt;Is it possible to store a variable directly in EEPROM and retrieve it &lt;em&gt;without&lt;/em&gt; needing to use a library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm building a project that can change the colour of an RGB LED and I want to store the colour in a non-volatile memory space, but I was wondering if I could avoid using one of the EEPROM libraries and have a global variable stored in nonvolatile memory, but still accessed directly, without needing to call a function.&lt;/p&gt;&#xA;" OwnerUserId="7901" LastActivityDate="2016-02-07T17:15:51.850" Title="Possible to store variables directly in EEPROM?" Tags="|eeprom|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9350" PostTypeId="2" ParentId="9349" CreationDate="2015-03-15T08:57:39.070" Score="3" Body="&lt;p&gt;Writing and reading EEPROM is possible to do without a library. Take a look at the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot; title=&quot;datasheet of the ATmega 328p&quot;&gt;datasheet of the ATmega328P&lt;/a&gt; to find an example: On page 25 / 26 there are example codes for reading and writing both in assembler and C. They do wrap it in a function but as I said in a comment if you only have place in your code where you would like to access EEPROM you can put the code there without duplication. These functions write and read one byte at a time, so if you want to store larger datatypes (a 16-bit integer for example) you already need to call the routines more than once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the EEPROM has a limited life cycle of at least 100,000 write/erase cycles (cells must be erased before they can be written, reads are unlimited) and it is considerably slower than SRAM (typ. 3.3 ms for writing a byte). You also need to make sure no interrupts interfere with the write process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in the sense of the question it seems this is not what you want: You cannot just create a global variable and have it magically being written to EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-15T09:14:39.337" LastActivityDate="2015-03-15T09:14:39.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9351" PostTypeId="1" CreationDate="2015-03-15T09:24:40.327" Score="6" ViewCount="2702" Body="&lt;p&gt;I would like to estimate the effective (minimum) endurance of the EEPROM of the Arduino in terms of single-byte writes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;noreferrer&quot; title=&quot;datasheet of the ATmega 328p&quot;&gt;datasheet of the ATmega&lt;/a&gt; used on many Arduino boards says (page 20):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The ATmega48A/PA/88A/PA/168A/PA/328/P contains 256/512/512/1Kbytes of data EEPROM memory. It is organized as a separate data space, in which single bytes can be read and written. The EEPROM has an endurance of at least 100,000 write/erase cycles. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Consider the ATmega328P with 1 kB of EEPROM. As I can write single bytes, if I loop through the EEPROM, writing every byte position the same number of times, that would make 1024 * 100,000 writes (assuming the nominal endurance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as far as I know not single bytes are erased before a write, but pages / cells. On page 285 / table 28.12 of the datasheet, the page size is specified to be 4 bytes. Does that mean the specified minimum endurance amounts to 1024 * 100,000 / 4 single-byte writes?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-15T10:00:32.963" LastActivityDate="2019-01-14T17:05:23.490" Title="EEPROM endurance and page size" Tags="|eeprom|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9352" PostTypeId="1" AcceptedAnswerId="9360" CreationDate="2015-03-15T10:17:04.817" Score="1" ViewCount="3221" Body="&lt;p&gt;I have recently started working with arduino UNO and the &quot;write&quot; function in sd Card library is not working. Below is my code. I have tried with &quot;println&quot; which is working fine. Any help regarding this is welcome.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;     byte b=10;&#xA;     File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;    if (dataFile) &#xA;    {&#xA;        dataFile.write(b);&#xA;     }&#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7909" LastActivityDate="2016-11-18T01:03:26.747" Title="&quot;write&quot; function in sd card is not working" Tags="|arduino-uno|sd-card|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9353" PostTypeId="1" AcceptedAnswerId="9358" CreationDate="2015-03-15T10:24:35.403" Score="1" ViewCount="1496" Body="&lt;p&gt;I bought a &lt;a href=&quot;http://www.16hertz.com/product/uno-r3-kit-ultimate-arduino-compatible/&quot; rel=&quot;nofollow&quot;&gt;16Hertz Uno R3 Board&lt;/a&gt;. When I installed the driver and the Arduino IDE,  in the IDE`s menu I saw:            &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Board -&gt; Arduino Uno&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;was selected by default which is great, but...     &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Port -&gt; COM3(Arduino Mega or Mega 2560)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;was selected by default which I think might be some kind of misunderstanding... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I chose: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Board -&gt; Arduino Mega or Mega 2560&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On that tools menu appeared new menu &quot;Processor&quot; with two options:   &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Processor -&gt; ATmega2560 (Mega 2560)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which was selected by default and there was another option&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tools -&gt; Processor -&gt; ATmega1280&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I restore Tools -&gt; Board settings back to &quot;Arduino Uno&quot; the &quot;Processor&quot; menu with the two options disappeared and Tools -&gt; Port setting did not changed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take my board and look at the Microcontroller there is written: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ATMEGA328P-PU&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also on that board is written: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;16HzUNO&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I need to know:   &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What does 16Hz mean? Does it mean the clock or frequency of this&#xA;Microcontroller? I think it does not, if I try to find out details of my Microcontroller on the &lt;a href=&quot;http://ie.rs-online.com/web/p/microcontrollers/6962260/&quot; rel=&quot;nofollow&quot;&gt;rs-online site&lt;/a&gt;, there is written:     &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ATMEGA328P-PU, 8 bit AVR Microcontroller 20MHz 1 kB, 32 kB Flash, 2&#xA;  kB RAM, I2C 28-Pin PDIP&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Why was there &quot;COM3(Arduino Mega or Mega 2560)&quot; written on the&#xA;Port's menu?&lt;/li&gt;&#xA;&lt;li&gt;Is my 16Hz Uno R3 and the Arduino Uno R3 board the same? Which one&#xA;is better? When one of those is better?&lt;/li&gt;&#xA;&lt;li&gt;Does the standard Arduino Uno R3 board have the same ATMEGA328P-PU&#xA;Microcontroller?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7908" LastEditorUserId="84" LastEditDate="2015-03-15T22:35:07.747" LastActivityDate="2019-11-20T05:17:39.260" Title="16Hertz Uno R3 Board vs Arduino Uno R3 Board" Tags="|arduino-uno|serial|arduino-mega|atmega328|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9354" PostTypeId="2" ParentId="9353" CreationDate="2015-03-15T11:12:06.730" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Every Arduino is using a quartz crystal in order to get the frequency needed. ATmega328 can handle up to 20 MHz&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;??&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes. You can't run the microcontroller by itself. It has an internal oscillator but none is using it. So basically you will have a 16 MHz crystal.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Pretty much the Arduino Uno, Nano, Mini and few others have the ATmega328P.&#xA;Note that the &lt;code&gt;-PU&lt;/code&gt; &lt;code&gt;-AU&lt;/code&gt; at the end defines the package. So they're the same.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Arduino Mega, Leonardo, Micro, Due use other chips.&lt;/p&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="6936" LastEditDate="2019-06-16T20:14:11.223" LastActivityDate="2019-06-16T20:14:11.223" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9357" PostTypeId="2" ParentId="9352" CreationDate="2015-03-15T14:50:37.150" Score="0" Body="&lt;p&gt;It is typical of file devices that an output file must be closed when the application is through writing to it - &lt;code&gt;datafile.close()&lt;/code&gt;, using your variable names. Their drivers or libraries typically buffer output data in memory and may not write it to the device until the buffer fills or the application flushes the buffers or closes the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://arduino.cc/en/Tutorial/ReadWrite&quot; rel=&quot;nofollow&quot;&gt;read/write SD card example&lt;/a&gt; at the Arduino site. Especially note the uses of the calls to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;begin&#xA;open&#xA;print or write, ...&#xA;close&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Failing to close an output fail might leave unwritten data in memory buffers rather than flushing the last few bytes (&lt;strong&gt;all&lt;/strong&gt; of the data, in the case of your one-byte-write example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible that there is another fault - incorrect mapping of I/O pins to the card reader/writer, incorrect wiring, faulty device or card, but I think the programming sequence is the most likely culprit.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-03-15T14:50:37.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9358" PostTypeId="2" ParentId="9353" CreationDate="2015-03-15T16:03:41.943" Score="3" Body="&lt;p&gt;You need to have a look at the &lt;a href=&quot;http://arduino.cc/en/Products.Compare&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino comparison table&lt;/a&gt;. This shows that &lt;em&gt;all&lt;/em&gt; Arduino Uno boards run at 16&amp;nbsp;MHz. It seems that you have fallen for the marketing on the &lt;a href=&quot;https://web.archive.org/web/20150104015236/http://www.16hertz.com/product/uno-r3-kit-ultimate-arduino-compatible/&quot; rel=&quot;nofollow noreferrer&quot;&gt;page for the Uno kit&lt;/a&gt; that you provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, which version of the IDE are you running? You should upgrade to the latest version, which is currently, at the time of writing, version 1.6.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your questions in turn:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&quot;&lt;strong&gt;16Hz&lt;/strong&gt;&quot; is the &lt;em&gt;brand name&lt;/em&gt; and has nothing whatsoever to do&#xA;with the speed, which is actually 16 &lt;strong&gt;Mega&lt;/strong&gt; Hertz. &quot;Clock&quot; and&#xA;&quot;Frequency&quot; refer to the same thing. 16 MHz is the clock frequency&#xA;of the board, and is the speed at which the &lt;strong&gt;ATmega328&lt;/strong&gt; runs at.&#xA;The RS Online link does indeed state 20&amp;nbsp;MHz, but that is merely the&#xA;&lt;em&gt;maximum&lt;/em&gt; speed at which the &lt;strong&gt;ATmega328&lt;/strong&gt; can run at. The Uno under clocks it at 16 MHz.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Ports&lt;/strong&gt; menu will show you a number of possible devices, &lt;strong&gt;Arduino Uno&lt;/strong&gt; should be one of them (which is the one you should select) and three items below that will be &lt;strong&gt;Arduino Mega or Mega 2560&lt;/strong&gt; (which you should ignore, you do not have a Mega board&lt;sup&gt;1&lt;/sup&gt;). Unfortunately the Arduino site only shows the Mac menu, even on &lt;a href=&quot;http://www.arduino.cc/en/Guide/Windows#toc7&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Windows guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ikeJV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ikeJV.png&quot; alt=&quot;Mac Arduino Tools menu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which is no help to you, assuming that you are running the Arduino IDE on Windows. You should actually see this in the &lt;strong&gt;Board&lt;/strong&gt; menu:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qttd5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qttd5.png&quot; alt=&quot;Windows Arduino Tools Board menu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and this in the &lt;strong&gt;Port&lt;/strong&gt; menu:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BrjgA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BrjgA.png&quot; alt=&quot;Windows Arduino Tools Port menu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you can see, there should be no mention of the microcontroller in the &lt;strong&gt;Port&lt;/strong&gt; menu.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The 16Hz branded Uno and the Arduino Uno are to all intents and purposes the same and as I state in the first line, the 16 MHz Uno is &lt;em&gt;exactly&lt;/em&gt; the same as a regular Uno, it is just marketing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Both the 16Hz and the Arduino Uno have a &lt;strong&gt;ATmega328&lt;/strong&gt; and the Mega board has a &lt;strong&gt;ATmega2560&lt;/strong&gt;. Again, check the &lt;a href=&quot;http://arduino.cc/en/Products.Compare&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino comparison table&lt;/a&gt; to see the variety of the boards and their respective microcontrollers.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I hope that answers your questions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; If you &lt;em&gt;do&lt;/em&gt; chose the &lt;strong&gt;Arduino Mega or Mega 2560&lt;/strong&gt; option, in the &lt;strong&gt;Board&lt;/strong&gt; menu, then indeed there will be an additional &lt;strong&gt;Processor&lt;/strong&gt; menu. However, this is irrelevant in your case, as you do not have a Mega board, and so you need to chose the Uno in the &lt;strong&gt;Board&lt;/strong&gt; menu. If you do so, then the &lt;strong&gt;Processor&lt;/strong&gt; menu will disappear, as it is not needed for the Uno. &lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2019-06-16T20:11:16.880" LastActivityDate="2019-06-16T20:11:16.880" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9359" PostTypeId="1" CreationDate="2015-03-15T13:13:16.853" Score="3" ViewCount="11889" Body="&lt;p&gt;As soon as I unplug my Arduino from USB and only use the VIN pin with my 9&amp;nbsp;V power supply, the analog readings from my Arduino start to get unstable, which means the value fluctuates much more than with USB connected. When I reconnect USB again, the readings are stable again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to build a load scale using a load cell, an INA125P and the Arduino, using this setup here: &lt;a href=&quot;https://learn.adafruit.com/smart-cocktail-shaker/calibration&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instrument Amplifier Calibration&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I need stable readings. For example, I wrote some code to convert the &lt;code&gt;analogRead()&lt;/code&gt; value to grams. While USB and VIN (9&amp;nbsp;V) connected, I get a stable reading of about 8.3 to 8.7 grams when I put a weight of 8.5 grams on the scale. As soon as I unplug USB, the LCD shows values from 7.8 grams up to 9 grams.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I don't have any other power supply which I could use to test. I've already tried to use a 9&amp;nbsp;V battery with the same results. Do I maybe need some additional de-coupling capacitors?&lt;/p&gt;&#xA;" OwnerUserId="94828" OwnerDisplayName="user1320304" LastEditorUserId="6936" LastEditDate="2017-06-05T01:54:14.543" LastActivityDate="2017-06-06T13:12:40.267" Title="Arduino unstable analog reading when using power supply" Tags="|power|analogread|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9360" PostTypeId="2" ParentId="9352" CreationDate="2015-03-15T17:24:30.317" Score="0" Body="&lt;p&gt;The problem is that &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;write()&lt;/code&gt; behave differently when you give them numerical data, such as a byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you pass your byte to &lt;code&gt;print()&lt;/code&gt;, it converts it to text which is convenient for humans to read. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte b = 10;&#xA;dataFile.print(b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will result in the following ASCII characters being written to the file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's actually two bytes: one byte with the value 49, which represents ASCII character &lt;code&gt;1&lt;/code&gt;, followed by a byte with the value 48 representing character &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;write()&lt;/code&gt; does &lt;strong&gt;not&lt;/strong&gt; convert numbers into text. It writes them in their raw binary form. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte b = 10;&#xA;dataFile.write(b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you do this, it doesn't write a &quot;1&quot; and a &quot;0&quot; to the file. It literally writes a binary byte with the value 10. When you try to open this as a text file, your computer interprets that byte as a single ASCII character. It so happens that ASCII value 10 is the newline character, meaning your file basically contains a blank line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For comparison, try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte b = 65;&#xA;dataFile.write(b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ASCII value 65 corresponds to the letter &lt;code&gt;A&lt;/code&gt; (uppercase), so that's what you should see in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;write()&lt;/code&gt; functions are useful for writing raw data to file in the most efficient form for another machine to read (as opposed to being human-readable). This is why they allow you to write arrays -- it acts like one big block of raw data with a fixed format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, &lt;code&gt;print()&lt;/code&gt; is more appropriate. That means for outputting arrays of numbers, you will need to use loops. That functionality isn't built-in to the &lt;code&gt;print()&lt;/code&gt; functions because different projects might need different formatting. For example, some people might want one number per line, whereas others might want numbers separated by commas, and so on.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-15T17:24:30.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9361" PostTypeId="2" ParentId="6700" CreationDate="2015-03-15T17:51:05.453" Score="0" Body="&lt;p&gt;Might be because of a non-compatible version of the Arduino IDE? (latest version isn't always the fittest, apparently).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found evidence for this weird behavior in various forums around the web - even when using the Uno R3 board with its official WiFi shield, I had to go back to version 1.0.3 of the Arduino IDE (and to flush its compatible firmware version for the WiFi shield) in order to get the sample code to work. Later versions just didn't work!&lt;/p&gt;&#xA;" OwnerUserId="7913" LastEditorUserId="7913" LastEditDate="2015-03-21T17:05:25.010" LastActivityDate="2015-03-21T17:05:25.010" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9362" PostTypeId="1" CreationDate="2015-03-15T17:52:42.447" Score="0" ViewCount="7950" Body="&lt;p&gt;I am just running the below DHCPAddressPrinter sketch in Arduino example to setup EthernetShield with MAC and IP&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address for your controller below.&#xA;// Newer Ethernet shields have a MAC address printed on a sticker on the shield&#xA;byte mac[] = {&#xA;  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02&#xA;};&#xA;&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server&#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  // this check is only needed on the Leonardo:&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;&#xA;  // start the Ethernet connection:&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    for (;;)&#xA;      ;&#xA;  }&#xA;  // print your local IP address:&#xA;  Serial.print(&quot;My IP address: &quot;);&#xA;  for (byte thisByte = 0; thisByte &amp;lt; 4; thisByte++) {&#xA;    // print the value of each byte of the IP address:&#xA;    Serial.print(Ethernet.localIP()[thisByte], DEC);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;After uploading the sketch to arduino,below is the output shown in console&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 13,614 bytes (42%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 539 bytes (26%) of dynamic memory, leaving 1,509 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And there is nothing shown in Serial monitor&lt;/strong&gt;&#xA;This is the image of Ethernetshield's some leds glowing after connecting to Router.&#xA;My router is Binatone Wireless ADSL2+ Router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cp90K.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/U7mgM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I checked arp -a&lt;/strong&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\Radhamani&amp;gt;arp -a&#xA;&#xA;Interface: 192.168.1.6 --- 0x3&#xA;  Internet Address      Physical Address      Type&#xA;  192.168.1.1           6c-fd-b9-24-c6-fe     dynamic&#xA;  192.168.1.255         ff-ff-ff-ff-ff-ff     static&#xA;  224.0.0.22            01-00-5e-00-00-16     static&#xA;  224.0.0.251           01-00-5e-00-00-fb     static&#xA;  224.0.0.252           01-00-5e-00-00-fc     static&#xA;  239.255.255.250       01-00-5e-7f-ff-fa     static&#xA;  255.255.255.255       ff-ff-ff-ff-ff-ff     static&#xA;&#xA;&#xA;Interface: 192.168.198.1 --- 0xe&#xA;  Internet Address      Physical Address      Type&#xA;  192.168.198.255       ff-ff-ff-ff-ff-ff     static&#xA;  224.0.0.22            01-00-5e-00-00-16     static&#xA;  224.0.0.251           01-00-5e-00-00-fb     static&#xA;  224.0.0.252           01-00-5e-00-00-fc     static&#xA;  239.255.255.250       01-00-5e-7f-ff-fa     static&#xA;&#xA;&#xA;Interface: 192.168.234.1 --- 0xf&#xA;  Internet Address      Physical Address      Type&#xA;  192.168.234.255       ff-ff-ff-ff-ff-ff     static&#xA;  224.0.0.22            01-00-5e-00-00-16     static&#xA;  224.0.0.251           01-00-5e-00-00-fb     static&#xA;  224.0.0.252           01-00-5e-00-00-fc     static&#xA;  239.255.255.250       01-00-5e-7f-ff-fa     static&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Complete result of ipconfig:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wireless LAN adapter Wi-Fi:&#xA;   Connection-specific DNS Suffix  . :&#xA;   Link-local IPv6 Address . . . . . : fe80::901:3297:48ad:9e7d%3&#xA;   IPv4 Address. . . . . . . . . . . : 192.168.1.6&#xA;   Subnet Mask . . . . . . . . . . . : 255.255.255.0&#xA;   Default Gateway . . . . . . . . . : 192.168.1.1&#xA;Ethernet adapter VMware Network Adapter VMnet1:&#xA;   Connection-specific DNS Suffix  . :&#xA;   Link-local IPv6 Address . . . . . : fe80::c954:40b2:c8c1:de0%14&#xA;   IPv4 Address. . . . . . . . . . . : 192.168.198.1&#xA;   Subnet Mask . . . . . . . . . . . : 255.255.255.0&#xA;   Default Gateway . . . . . . . . . :&#xA;Ethernet adapter VMware Network Adapter VMnet8:&#xA;   Connection-specific DNS Suffix  . :&#xA;   Link-local IPv6 Address . . . . . : fe80::2837:7e01:c799:d627%15&#xA;   IPv4 Address. . . . . . . . . . . : 192.168.234.1&#xA;   Subnet Mask . . . . . . . . . . . : 255.255.255.0&#xA;   Default Gateway . . . . . . . . . :&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial.println in the program is not printing anything.Looks like Ethernet shield is not getting IP.I am not sure where I am wrong.Please help me to fix this issue&lt;/p&gt;&#xA;" OwnerUserId="18419" OwnerDisplayName="Rad4" LastActivityDate="2020-05-25T18:54:54.717" Title="Ethernet shield not getting IP" Tags="|ethernet|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9363" PostTypeId="1" CreationDate="2015-03-15T18:11:21.547" Score="0" ViewCount="1548" Body="&lt;p&gt;I am working on a small project where I have to read data from different hardware and display it on android app. I am using arduino Uno to get the values from a sensor and a motor and I use a bluetooth module to send the data to the android device. I know how to read data from motor only but not from motor AND sensor. The data displayed on the arduino can be assumed as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motor: 132&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor: 258&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motor: 259&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor: 992&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first, we will read the value of the motor then the sensor then the motor and so on. Here is part of the code where I used handler and string builder to read data from the motor. How to modify the code in order to read from BOTH the motor and sensor and keep the updating the values?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Handler mHandler = new Handler()&#xA;    {&#xA;        public void handleMessage(android.os.Message msg) {&#xA;            switch (msg.what) {&#xA;                case 1:                                                 &#xA;                    byte[] readBuf = (byte[]) msg.obj;&#xA;                    String strIncom = new String(readBuf, 0, msg.arg1);                 &#xA;                    sb.append(strIncom);                                                &#xA;                    int endOfLineIndex = sb.indexOf(&quot;\r\n&quot;);                            &#xA;                    if (endOfLineIndex &amp;gt; 0) {                                           &#xA;                        String sbprint = sb.substring(0, endOfLineIndex);               &#xA;                        sb.delete(0, sb.length());                                      &#xA;                        motor.setText(sbprint);             // update TextView&#xA;                    }&#xA;&#xA;                    break;&#xA;            }&#xA;        };&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7875" LastActivityDate="2019-12-26T15:16:50.393" Title="Receive multiple data from arduino using String builder" Tags="|arduino-uno|android|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9364" PostTypeId="1" CreationDate="2015-03-15T18:22:52.783" Score="2" ViewCount="1096" Body="&lt;p&gt;Arduino Uno user here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building a project with 4 analog inputs A0 dose not work. A1 A2 and A3 work perfectly fine! But for last input when I connect to A4 or A5, then they do not go to zero. They are stuck between 400 to 900. Even when connected to arduino ground it gives 400 instead of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here cause the circuit for A4 connected to A3 gives perfect input value. They both work fine as output. Same situation with A5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way to get one more Analog Input without multiplex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="7914" LastActivityDate="2015-03-15T18:22:52.783" Title="Analog Input not going to Zero" Tags="|arduino-uno|pins|" AnswerCount="0" CommentCount="10" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9366" PostTypeId="1" AcceptedAnswerId="9401" CreationDate="2015-03-16T03:35:51.157" Score="0" ViewCount="1413" Body="&lt;p&gt;I am using a port of the Arduino libraries on an AtTiny85 (1MHz) to drive a 4-digit 7-segment LED (common cathode, 12-pin). I'm just counting from 0 to 9 and alternating between the first two digits (pin 12 and 9) as a test. I am driving from two 74HC595N shift registers in series, the first of which will trigger S9018 NPN BJT transistors to turn on/off the digit I want and the other to light the segments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code seems to work fine, functionally, to alternate the two digits, but they don't alternate fast enough to make the LED show two solid digits, instead you can clearly see them flashing/alternating. Not sure what the bottleneck is but here's the code (please ignore my wiring for the 7 segments)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// CONFIGURATION&#xA;// Pins&#xA;const int latchPin = 2;&#xA;const int clockPin = 4;&#xA;const int dataPin = 3;&#xA;&#xA;// Timers&#xA;const long output_interval = 10000; // Time to change each output &#xA;const int T_digit = 2; //period on one digit (4 digit 7-segment only)&#xA;const int duty_digit = 1; // duty cyle of a digit shown&#xA;&#xA;// States&#xA;unsigned long outputT_last = 0; // Holds the last time output change was checked&#xA;unsigned long outputT_now = 0;&#xA;bool fourDigit7Segment_enable = true; // set if we are using 4 digit 7 segment led&#xA;&#xA;// States&#xA;byte leds = 0;&#xA;byte digits = 0;&#xA;&#xA;int output_count=0;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);  &#xA;  pinMode(clockPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  checkOutput();&#xA;}&#xA;&#xA;void updateShiftRegister()&#xA;{&#xA;  digitalWrite(latchPin, LOW); // Gets latch ready by setting to low since we need a rising edge to trigger&#xA;  if(fourDigit7Segment_enable){&#xA;    int digitON = (int)(outputT_now - outputT_last);&#xA;    digits = 0;&#xA;    if(digitON%T_digit &amp;lt; duty_digit){&#xA;      //bitwrite led 0&#xA;      bitWrite(digits, 0, 1);&#xA;    }&#xA;    else{&#xA;      //bitwrite led 1&#xA;      bitWrite(digits, 1, 1);&#xA;    }&#xA;    //shift out digit control first in LSB&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, digits); // shiftOut will write to dataPin and trigger a rising on clickPin at same time while writing byte value from leds var&#xA;  }&#xA;  shiftOut(dataPin, clockPin, MSBFIRST, leds); // shiftOut will write to dataPin and trigger a rising on clickPin at same time while writing byte value from leds var&#xA;  digitalWrite(latchPin, HIGH); // Trigger with rising edge&#xA;}&#xA;&#xA;void clearMemory(){&#xA;  leds = 0;&#xA;  updateShiftRegister();&#xA;}&#xA;&#xA;void checkOutput(){&#xA;  outputT_now = millis();&#xA;  float timeleft = (int)((outputT_now - outputT_last)/1000);&#xA;  if (outputT_now - outputT_last &amp;gt;= output_interval){&#xA;    outputT_last = outputT_now; // output_interval set to 10000, because LED counts 0 to 9, and then needs to reset&#xA;  }&#xA;    // clearMemory(); // Uncomment this if you want 1 LED lit at time, all others turned off&#xA;    leds = sevenSegment1D(timeleft);&#xA;    updateShiftRegister();&#xA;    // output_count++;&#xA;  // }&#xA;  // Check if we reach the end, then do 1 more iteration for 0x0 (all turned off)&#xA;  // if(output_count &amp;gt; 8){&#xA;    // output_count=0;&#xA;    // clearMemory();&#xA;  // }&#xA;}&#xA;&#xA;byte sevenSegment1D(int i){&#xA;  switch (i) {&#xA;      case 0:&#xA;        return 0x7E; //01111110&#xA;        break;&#xA;      case 1:&#xA;        return 0x48; //01001000&#xA;        break;&#xA;      case 2:&#xA;        return 0x3D; //00111101&#xA;        break;&#xA;      case 3:&#xA;        return 0x6D; //01101101&#xA;        break;&#xA;      case 4:&#xA;        return 0x4B; //01001011&#xA;        break;&#xA;      case 5:&#xA;        return 0x67; //01100111&#xA;        break;&#xA;      case 6:&#xA;        return 0x77; //01110111&#xA;        break;&#xA;      case 7:&#xA;        return 0x4C; //01001100&#xA;        break;&#xA;      case 8:&#xA;        return 0x7F; //01111111&#xA;        break;&#xA;      case 9:&#xA;        return 0x6F; //01101111&#xA;        break;   &#xA;      default:&#xA;        return 0x0; //Arduino doesn't handle bytes in binary&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to mod a float but it seems to require an int, so that's why I stopped at 2%1. I also converted the code from a single-digit 7-segment LED so please ignore anything that doesn't make sense in lighting up the segments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure if the bottleneck is my code, the 1MHz AtTiny85, or the shift register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: switched over to &lt;code&gt;micros()&lt;/code&gt; instead of using &lt;code&gt;millis()&lt;/code&gt; for more resolution. Still not solid.&lt;/p&gt;&#xA;" OwnerUserId="6709" LastEditorUserId="4131" LastEditDate="2015-08-14T07:22:55.200" LastActivityDate="2016-01-11T13:08:26.057" Title="Arduino on attiny85 driving 4-digit 7-segment using two 74HC595N shift register not alternating fast enough" Tags="|led|attiny|shift-register|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9367" PostTypeId="1" CreationDate="2015-03-16T03:52:55.957" Score="1" ViewCount="393" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.switchdoc.com/ds3231-real-time-clock-module/&quot; rel=&quot;nofollow&quot;&gt;SwitchDoc Labs DS3231 Real Time Clock Module&lt;/a&gt; that I am using with an Arduino Mega.  It's connected to 3.3V and the SDA(20)/SDL(21) pins.  I'm also using SwitchDoc's RTC_SDL_DS3231_ARDUINO library (see link to the example sketch below).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can compile and run the example provided with the library just fine.  However, I'm running into a very bizarre compilation problem when I remove the Clock set function calls in the setup.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than take up the space and copy the code that works I'll just link to it on github: &lt;a href=&quot;https://github.com/switchdoclabs/RTC_SDL_DS3231_ARDUINO/blob/master/DS3231/Examples/DS3231_TEST/DS3231_TEST.ino&quot; rel=&quot;nofollow&quot;&gt;100% working for me example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am running into happens when I remove (or comment out) the section in the setup function that sets the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Start the I2C interface&#xA;  Wire.begin();&#xA;  // Removed code&#xA;  // Start the serial interface &#xA;  Serial.begin(9600);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I get the following error when I try to compile/verify the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Applications/Arduino/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../&#xA;lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':&#xA;(.vectors+0x90): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_36'&#xA;defined in .text.__vector_36 section in core.a(HardwareSerial.cpp.o)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I add back just one single clock set call it will compile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Start the I2C interface&#xA;  Wire.begin();&#xA;  Clock.setYear(15);  //Set the year (Last two digits of the year) &#xA;  // Start the serial interface &#xA;  Serial.begin(9600);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the truly strange thing is that if I simply add a Serial.println() line to the setup function, the sketch compiles too!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Start the I2C interface&#xA;  Wire.begin();&#xA;  // Start the serial interface &#xA;  Serial.begin(9600);&#xA;  // Adding the following line allows the sketch to compile&#xA;  Serial.println(&quot;Why does this work now???&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="7817" LastActivityDate="2015-03-18T15:23:37.263" Title="Bizarre compilation problem -- only compiles with the addition of a single Serial.println() line?" Tags="|arduino-mega|i2c|compile|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9368" PostTypeId="1" CreationDate="2015-03-15T17:31:48.777" Score="1" ViewCount="61" Body="&lt;p&gt;Arduino Uno user here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building a project with 4 analog inputs A0 dose not work. A1 A2 and A3 work perfectly fine! But for last input when I connect to A4 or A5, then they do not go to zero. They are stuck between 400 to 900. Even when connected to arduino ground it gives 400 instead of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here cause the circuit for A4 connected to A3 gives perfect input value. They both work fine as output.  Same situation with A5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way to get one more Analog Input without multiplex?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="7914" OwnerDisplayName="Abhishrant Majhi" LastEditorUserId="6452" LastEditDate="2015-03-16T13:28:25.003" LastActivityDate="2015-03-16T13:28:25.003" Title="Analog Input not going zero" Tags="|arduino-uno|analogread|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2015-03-16T15:23:18.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="9370" PostTypeId="2" ParentId="8714" CreationDate="2015-03-16T05:09:48.540" Score="1" Body="&lt;p&gt;Probably too late to answer your question. Your problem is on line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (client) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change it to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(client.connected())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which actually returns true when client is connected. &lt;/p&gt;&#xA;" OwnerUserId="7904" LastActivityDate="2015-03-16T05:09:48.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9371" PostTypeId="1" CreationDate="2015-03-16T06:16:12.403" Score="1" ViewCount="2108" Body="&lt;p&gt;There are many software timer libraries available in Arduino.&lt;br&gt;&#xA;A library called SimpleTimer &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/SimpleTimer&lt;/a&gt; is really good with many functions, but it uses polling.&lt;br&gt;&#xA;If anyone is familiar with a really good library that uses Timer ISR of Atmega instead of polling, please suggest me as i am using ultrasonic sensors and i can't afford polling.&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-04-15T08:01:32.207" Title="Can anyone suggest me a software timer library that does not use polling but timer ISR instead?" Tags="|library|timers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9372" PostTypeId="2" ParentId="9371" CreationDate="2015-03-16T06:44:59.833" Score="1" Body="&lt;p&gt;Yeah, I have the same problem.&#xA;The only solution I found is to rewrite  a lot of the code. Still ongoing, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For you, Timer1 is probably the best candidate, unless you have already some use for it, like in my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick hack is to free Timer0: it is currently (ab)used by the wire library, which provides the typical arduino timing.&#xA;But you can remove/rename the file wiring.cpp to something that will not be identified as source (ex: wiring._cpp) and comment out the init() function call from the main() function in the main.c file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normal Arduino stile time functions will not work, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunatelly Arduino SW really lacks the structured design that would allow it to be useful in more complex cases and most of the libraries make exclusive use of resources that could be shared, timer being the most prominent example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Port ISRs is another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, if you happen to use a SW serial library, it's already game over, as it busy loops inbetween bits, in interrupt context (!), rather than using a timer.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-03-16T07:03:14.990" LastActivityDate="2015-03-16T07:03:14.990" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9374" PostTypeId="1" CreationDate="2015-03-16T08:09:05.947" Score="5" ViewCount="10356" Body="&lt;p&gt;I have really been suffering with my simulation! Tried connecting my arduino mega 2560 to COMPIM (used as GSM Module) in my circuit and also loaded sample code but damn! In vain! I wanted to view the data sent in virtual terminal but am getting nothing! and its also complaining of excessive CPU usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the circuit as seen below in Proteus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZnXU2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And thereafter, the log messages are displayed as shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/crkuK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone please help me out. Am I making a mistake oh? Infact the arduino code for displaying in the simulation is also giving me hard time. The one am using is as shown below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    mySerial.println(&quot;Hello, world?&quot;);&#xA;  if (Serial.available())&#xA;    mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will b every grateful for any help offered.&lt;/p&gt;&#xA;" OwnerUserId="7920" LastActivityDate="2022-03-23T12:34:25.797" Title="Simulation of Arduino Mega 2560 with GSM Module using Proteus" Tags="|arduino-mega|gsm|simulator|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9375" PostTypeId="2" ParentId="6860" CreationDate="2015-03-16T09:10:37.643" Score="0" Body="&lt;p&gt;Answering here because I do not have enough rep to comment.&#xA;At each iteration, the value in the timer counter must be reloaded.&#xA;Either the ISR or dofun are responsible to reload TCNT1.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-03-16T09:10:37.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9376" PostTypeId="2" ParentId="9192" CreationDate="2015-03-16T09:14:15.973" Score="1" Body="&lt;p&gt;Please use the last IDE version released here: arduino.cc/en/Main/Software The version 1.6.1 has many improvements about serial devices detection and sketches upload. It will solve your issues about older Arduino UNO version and Arduino Yun. &lt;/p&gt;&#xA;" OwnerUserId="6315" LastActivityDate="2015-03-16T09:14:15.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9377" PostTypeId="1" AcceptedAnswerId="9379" CreationDate="2015-03-16T10:12:08.810" Score="4" ViewCount="344" Body="&lt;p&gt;This is my code which I have written as a library  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;avr/interrupt.h&quot;  &#xA;#include &quot;Arduino.h&quot;&#xA;#include &quot;AllTimer.h&quot;&#xA;&#xA;AllTimer::AllTimer()&#xA;{}&#xA;&#xA;void AllTimer::dofun(void)&#xA;{&#xA;     //TIFR1 |= _BV(OCF1A);&#xA;&#xA;    TCCR1B = 0X00;&#xA;    //TIFR1 = 0X01;&#xA;    digitalWrite(13,!digitalRead(13));&#xA;    Serial.print(&quot;I printed&quot;);&#xA;    TCNT1 = 0X0000;&#xA;    TCCR1B |= (1&amp;lt;&amp;lt;CS12) &amp;amp;&amp;amp; (1&amp;lt;&amp;lt;CS10);&#xA;    //sei();&#xA;}&#xA;&#xA; void AllTimer::setTimer(void)&#xA; {&#xA;    TCNT1 = 0x0000;&#xA;    TCCR1A = 0x00;&#xA;    TCCR1B = 0x00;&#xA;    TCCR1B |= (1&amp;lt;&amp;lt;CS12) &amp;amp;&amp;amp; (1&amp;lt;&amp;lt;CS10);&#xA;    TIMSK1 |= (1&amp;lt;&amp;lt;TOIE1);&#xA;    sei();&#xA; }&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;{&#xA;     AllTimer::dofun();&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code in Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;AllTimer.h&amp;gt;&#xA;&#xA; AllTimer mytimer;&#xA;&#xA; void setup()&#xA; {&#xA;     pinMode(13,OUTPUT);&#xA;     Serial.begin(9600);&#xA; }&#xA;&#xA; void loop()&#xA; {  &#xA;     mytimer.setTimer();&#xA;    //delay(200);   &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am not getting anything on the serial monitor. What is the error I have made?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="6549" LastEditDate="2015-03-16T15:03:53.877" LastActivityDate="2015-03-16T15:03:53.877" Title="Why does timer ISR not execute?" Tags="|timers|isr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9378" PostTypeId="2" ParentId="9367" CreationDate="2015-03-16T10:43:54.643" Score="4" Body="&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: This seems to be a linker bug. Quick fix: upgrade your&#xA;Arduino installation. See the end of this answer for details. What&#xA;follows is the first version of this answer, with a detailed explanation&#xA;of the error message.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You have a problem linking the interrupt vector table with your program.&#xA;I quite understand what the error message means, but I do not understand&#xA;how in the world you can possibly have this error. This should not&#xA;happen. I will try to explain the error anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega is based on an AVR chip. The AVR instruction set has&#xA;“jump” and “call” instruction that come in two flavors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;“absolute” jumps and calls (opcodes: &lt;code&gt;jmp&lt;/code&gt; and &lt;code&gt;call&lt;/code&gt;) can address the&#xA;whole flash memory, which means you can branch from any part of the&#xA;program to any other part, without restrictions.&lt;/li&gt;&#xA;&lt;li&gt;“relative” (a.k.a. “PC-relative”) jumps and calls (opcodes: &lt;code&gt;rjmp&lt;/code&gt; and&#xA;&lt;code&gt;rcall&lt;/code&gt;) have limited range: they can only bring you to nearby places,&#xA;no more than 4&amp;nbsp;K from your starting point.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The relative flavors take less space and execute faster, they are thus&#xA;better &lt;em&gt;if&lt;/em&gt; the destination is close enough. On the smaller AVR chips&#xA;(up to 8&amp;nbsp;K of flash), they can access the whole flash, then these&#xA;chips lack the absolute flavors.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;How the vector table is normally linked&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Every program you build for an AVR starts with an “interrupt vector&#xA;table”. This is a series of jump instructions that are automatically&#xA;executed whenever an interrupt triggers: if the &lt;em&gt;n&lt;/em&gt;-th supported&#xA;interrupt triggers, then the hardware automatically loads and executes&#xA;the &lt;em&gt;n&lt;/em&gt;-th jump instruction, which will jump the execution of the&#xA;program to the corresponding ISR (&lt;em&gt;interrupt service routine&lt;/em&gt;). The&#xA;table is chip-specific: on the smaller AVRs (up to 8&amp;nbsp;K), it's a&#xA;table of &lt;code&gt;rjmp&lt;/code&gt;, whereas on the bigger ones it's a table of &lt;code&gt;jmp&lt;/code&gt;. This&#xA;table is part of the CRT (&lt;em&gt;C run time&lt;/em&gt;) provided by the avr-libc library&#xA;in a file named crtXXX.o, where XXX is a code identifying the chip. The&#xA;Arduino Mega being based on the ATmega2560 chip, it's CRT is crtm2560.o.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disassembled my own copy of crtm2560.o and found this vector table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000000 &amp;lt;__vectors&amp;gt;:&#xA;   0:   0c 94 00 00     jmp 0&#xA;   4:   0c 94 00 00     jmp 0&#xA;   8:   0c 94 00 00     jmp 0&#xA;   ...&#xA;  e0:   0c 94 00 00     jmp 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see these are all &lt;code&gt;jmp&lt;/code&gt; instructions (absolute flavor), as&#xA;expected for any AVR with more than 8&amp;nbsp;K of flash. The address of&#xA;the jump, however, is always 0, which is obviously wrong. This is&#xA;because the proper addresses cannot be known until the program is fully&#xA;built. When you build your program, the linker will put all the pieces&#xA;together. It will then know where the ISRs are, and it will patch the&#xA;vector table to make it correct. This kind of patching is known as&#xA;“relocation”, and the linker performs this based on some “relocation&#xA;records” included in the CRT. Here are the relevant records from my copy&#xA;of crtm2560.o:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RELOCATION RECORDS FOR [.vectors]:&#xA;OFFSET   TYPE              VALUE &#xA;00000000 R_AVR_CALL        __init&#xA;00000004 R_AVR_CALL        __vector_1&#xA;00000008 R_AVR_CALL        __vector_2&#xA;...&#xA;00000090 R_AVR_CALL        __vector_36  [*]&#xA;...&#xA;000000e0 R_AVR_CALL        __vector_56&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The record I marked with [*] means: “at offset 0x90 into the vector&#xA;table there is an absolute jump or call instruction, and the instruction&#xA;should be modified to point to __vector_36”. This tells the linker&#xA;how to fix the table when building the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I instead disassemble a CRT for a smaller chip, I get a smaller table&#xA;made of &lt;code&gt;rjmp&lt;/code&gt; (instead of &lt;code&gt;jmp&lt;/code&gt;) instructions, and the relocation&#xA;records look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RELOCATION RECORDS FOR [.vectors]:&#xA;OFFSET   TYPE              VALUE &#xA;00000000 R_AVR_13_PCREL    __init&#xA;00000002 R_AVR_13_PCREL    __vector_1&#xA;00000004 R_AVR_13_PCREL    __vector_2&#xA;...&#xA;00000032 R_AVR_13_PCREL    __vector_25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These records mean “at offset XXX into the vector table there is a&#xA;PC-relative jump or call instruction, and the instruction should be&#xA;modified to point to __vector_XXX”.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Your error message&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Your error message provides the following information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;“crtm2560.o”: this is your CRT, where the vector table and the&#xA;relocation records live.&lt;/li&gt;&#xA;&lt;li&gt;“.vectors+0x90”: this means the problem is at offset 0x90 into the&#xA;vector table.&lt;/li&gt;&#xA;&lt;li&gt;“R_AVR_13_PCREL against symbol `__vector_36'”: this means there&#xA;is a relocation record of type R_AVR_13_PCREL (PC-relative jump or&#xA;call) referencing __vector_36. &lt;strong&gt;Here seems to be the problem&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;“defined in [...] core.a(HardwareSerial.cpp.o)”: this __vector_36&#xA;is part of the serial port code from the Arduino core library.&lt;/li&gt;&#xA;&lt;li&gt;“relocation truncated to fit”: __vector_36 is too far to be reached&#xA;by a PC-relative jump, thus the linker could not relocate properly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem seems to be that the relocation record is of type&#xA;R_AVR_13_PCREL, which is what you expect on smaller chips but not on&#xA;your ATmega2560. You normally expect R_AVR_CALL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, about the strange behavior: the exact point where the ISR lands&#xA;when the program is built is difficult to predict. Add or remove a few&#xA;lines in your code and the linker may bring the pieces together in a&#xA;different order. Then, the infamous __vector_36 may end up being in&#xA;range or out of range of a relative jump. Given the nature of the error,&#xA;the behavior you find “strange” is actually quite normal.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Further debugging&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The root of the problem seems to be an incorrect relocation record in&#xA;your CRT. You can try to disassemble the CRT to see what is wrong:&#xA;search your computer for a file named crtm2560.o, probably in&#xA;/Applications/Arduino/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/lib/avr6&#xA;or a similar place. The tool needed for disassembling is called&#xA;“avr-objdump” and should be hidden somewhere in your Arduino&#xA;installation folder. Once you find the files, start a terminal and type&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/path/to/avr-objdump -d /path/to/crtm2560.o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with “/path/to” replaced by the actual paths. You should see something&#xA;very much like the first listing of my answer, with lots of &lt;code&gt;jmp&lt;/code&gt;&#xA;instructions. If you have &lt;code&gt;rjmp&lt;/code&gt; instructions instead, then something is&#xA;already wrong at this level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see the relocation records, type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/path/to/avr-objdump -r /path/to/crtm2560.o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output should look like my second listing, with lots of &lt;code&gt;R_AVR_CALL&lt;/code&gt;&#xA;records. If you have &lt;code&gt;R_AVR_13_PCREL&lt;/code&gt; instead, the records are wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the problem, then the obvious fix would be to replace the&#xA;broken CRT with a sane one. You may try to reinstall the whole Arduino&#xA;package. If you still have a corrupted CRT, you should report the error&#xA;to the Arduino folks. Then you may try to fetch a fresh copy of the&#xA;&lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;avr-libc&lt;/a&gt; and replace the relevant&#xA;parts of your Arduino installation. Replacing just the CRT may or may&#xA;not work: I don't know whether the last version of the CRT has&#xA;incompatibilities with older versions of the rest of the libc.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Update: this is a linker bug&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I did some research, and I now believe you have hit a linker bug. There&#xA;is a gcc option called &lt;code&gt;-mrelax&lt;/code&gt; that allows some link-time&#xA;optimizations. One if them is to have the linker replace some absolute&#xA;jumps and calls by the smaller and faster relative ones. Obviously, this&#xA;is only possible if the target address is within reach of the relative&#xA;jumps or calls. There was a bug in old versions of the GNU linker (up to&#xA;2.22) where, under some obscure circumstances, it would erroneously&#xA;believe the target was reachable, only to find out later that it was&#xA;not. This bug mainly affected the interrupt vector table, producing the&#xA;kind of error message you are seeing now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a partial timeline of this bug and its fix:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;November 2011: this is filed as&#xA;&lt;a href=&quot;https://sourceware.org/bugzilla/show_bug.cgi?id=13410&quot; rel=&quot;nofollow noreferrer&quot;&gt;bug 13410&lt;/a&gt;&#xA;on the bug tracker for the GNU binutils package.&lt;/li&gt;&#xA;&lt;li&gt;January 2012: Vidya Praveen, from Atmel, publishes a fix.&lt;/li&gt;&#xA;&lt;li&gt;February 2012: the fix is committed to the development version of&#xA;binutils.&lt;/li&gt;&#xA;&lt;li&gt;October 2012: GNU binutils 2.23 is released, including the fix.&#xA;The same month, the bug is reported again as&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/issues/1071&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue 1071&lt;/a&gt;&#xA;on the Arduino issue tracker.&lt;/li&gt;&#xA;&lt;li&gt;June 2013: Paul Stoffregen links this new issue to the old bug.&lt;/li&gt;&#xA;&lt;li&gt;June 2014: Arduino &lt;a href=&quot;https://github.com/arduino/Arduino/commit/98c3080d2a6065013f40c3656ce593e765b3bdb1&quot; rel=&quot;nofollow noreferrer&quot;&gt;gets an updated&#xA;toolchain&lt;/a&gt;&#xA;including binutils 2.23.2, which fixes the bug in the development&#xA;version of Arduino.&lt;/li&gt;&#xA;&lt;li&gt;July 2014: &lt;a href=&quot;http://arduino.cc/en/Main/ReleaseNotes&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino 1.5.7 beta is&#xA;released&lt;/a&gt; including the&#xA;updated toolchain.&lt;/li&gt;&#xA;&lt;li&gt;September 2014: Arduino 1.0.6 is released &lt;em&gt;with the old toolchain&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://stackoverflow.com/a/18062480&quot;&gt;workaround for the bug&lt;/a&gt; has been&#xA;published by Mark Anderson on stackoverflow. The real fix, however,&#xA;would be to upgrade to the latest Arduino package (1.6.1 as of this&#xA;writing).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-18T15:23:37.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9379" PostTypeId="2" ParentId="9377" CreationDate="2015-03-16T10:49:46.177" Score="6" Body="&lt;p&gt;The Arduino &lt;code&gt;main()&lt;/code&gt; calls &lt;code&gt;loop()&lt;/code&gt; continuously, in a tight loop. Thus&#xA;your &lt;code&gt;AllTimer::setTimer()&lt;/code&gt; is called continuously, and each time it&#xA;resets the counter (&lt;code&gt;TCNT1 = 0x0000;&lt;/code&gt;). Thus the counter can never&#xA;overflow.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-03-16T10:49:46.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9380" PostTypeId="2" ParentId="9189" CreationDate="2015-03-16T11:05:03.507" Score="1" Body="&lt;p&gt;Including the header files for the libraries in the standard Firmata&#xA;sketch is only the first step. You will have to also modify the sketch in&#xA;order to actually &lt;em&gt;use&lt;/em&gt; the libraries. You will have to figure out a way&#xA;of interacting with the libraries through the Firmata protocol and&#xA;implement this in your modified version of the sketch. You will then&#xA;have to modify the JavaScript side to enable these new interactions.&#xA;That's where you will write the missing methods&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-03-16T11:05:03.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9381" PostTypeId="1" CreationDate="2015-03-16T11:40:37.153" Score="2" ViewCount="635" Body="&lt;p&gt;I am using the &lt;a href=&quot;http://store.arduino.cc/product/T010010&quot; rel=&quot;nofollow&quot;&gt;TinkerKit Relay Module&lt;/a&gt; and recently they changed the relay mounted on the board from a white one with &lt;code&gt;10A250V~&lt;/code&gt; to a black one with &lt;code&gt;10A125V~&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my country the voltage is &lt;code&gt;220V~&lt;/code&gt;. Can I use the black relay in my application, safely? May be there problems that I have to be careful?&lt;/p&gt;&#xA;" OwnerUserId="1015" LastEditorUserId="1015" LastEditDate="2015-03-16T12:38:03.007" LastActivityDate="2018-01-26T17:25:27.933" Title="Can I use relays with 10A125V~ for my 220V~ applications, safely?" Tags="|voltage-level|relay|current|safety|electricity|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9382" PostTypeId="1" AcceptedAnswerId="9409" CreationDate="2015-03-16T12:00:04.533" Score="1" ViewCount="2528" Body="&lt;p&gt;I have a problem with my Arduino Uno board. It's not mounting in my Linux machine, but its power is &lt;em&gt;on&lt;/em&gt; and the LED light is glowing. It was working before. After I tested buttons with an 12&amp;nbsp;V external supply, I am facing this scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;lsusb&lt;/code&gt; and I checked &lt;code&gt;/dev/ ports&lt;/code&gt;. Also, I couldn't find `ttyACM. I tried with another Arduino board and it's working. I think the board is gone, and I need help to fix this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it was a bootloader problem, and I got a &lt;em&gt;new ATmega328P chip board&lt;/em&gt;. It is getting power on and the LED is blinking, but the port is not mounted. I tried with &lt;code&gt;lsusb&lt;/code&gt; and also &lt;code&gt;ls /dev/ttyACM*&lt;/code&gt; with no result.&lt;/p&gt;&#xA;" OwnerUserId="7922" LastEditorUserId="510" LastEditDate="2020-04-06T05:04:56.753" LastActivityDate="2020-04-06T05:04:56.753" Title="Arduino Uno R3 USB is not working" Tags="|arduino-uno|atmega328|linux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9384" PostTypeId="1" CreationDate="2015-03-16T13:50:55.373" Score="5" ViewCount="6442" Body="&lt;p&gt;My loop code is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// read the input on analog pin 0:&#xA;int sensorValue = analogRead(A0);&#xA;// print out the value you read:&#xA;Serial.println(float(sensorValue*5000.0/1023));&#xA;delay(1);        // delay in between reads for stability&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I read 5V it gives 5000 mV. When I read 3.3V pin it gives 3211 mV. When I read 1442 mV battery it gives 1392. What do you think about this situation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: There is no any additive circuit. Just wires.&lt;/p&gt;&#xA;" OwnerUserId="7924" LastEditorUserId="7924" LastEditDate="2015-03-16T14:11:52.257" LastActivityDate="2015-03-17T18:06:36.287" Title="UNO analog input voltage reading not accurate" Tags="|arduino-uno|analogread|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9385" PostTypeId="1" AcceptedAnswerId="36558" CreationDate="2015-03-16T14:25:20.167" Score="3" ViewCount="3047" Body="&lt;p&gt;I have an original Arduino Uno R3. According to the &lt;a href=&quot;http://www.arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;specifications&lt;/a&gt; the recommended input voltage is 7 to 12 Volt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have a laptop adapter of 19V that I want to use to power my arduino because it offers more current than the 9V adapter I have as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to damage the Arduino or the &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=69&quot; rel=&quot;nofollow&quot;&gt;DFRobot 2A Motor Shield&lt;/a&gt; I'm using. Can I safely plug in the adapter and will it still work correctly?&lt;/p&gt;&#xA;" OwnerUserId="7090" LastActivityDate="2017-09-09T14:35:59.227" Title="Can I safely connect my original Arduino Uno to a 19V adapter?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9386" PostTypeId="2" ParentId="9385" CreationDate="2015-03-16T14:59:17.970" Score="4" Body="&lt;p&gt;According to the page you linked:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, yes. You can use the 19V external power supply to power the board. However, be aware that the voltage regulator can overheat over time and damage the board.&lt;/p&gt;&#xA;" OwnerUserId="7292" LastActivityDate="2015-03-16T14:59:17.970" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9388" PostTypeId="1" AcceptedAnswerId="9393" CreationDate="2015-03-16T15:43:18.597" Score="3" ViewCount="11164" Body="&lt;p&gt;I would like to read a sensor connected via I2C using Timer3 and Arduino Mega. Values are read from the sensor in the interrupt service routine and timer3 is set to trigger an interrupt at 200Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step I: testing the timer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the timer using a counter and incrementing its value in the ISR. The output is displayed every second. It works!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;200&#xA;201&#xA;200&#xA;201&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Timer variable&#xA;volatile int cont=0;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(115200);       &#xA;&#xA;  setupL3G4200D(2000); // Configure L3G4200  - 250, 500 or 2000 deg/sec&#xA;  delay(1500); //wait for the sensor to be ready   &#xA;&#xA;  // Initialize Timer&#xA;  cli();&#xA;  TCCR3A = 0;&#xA;  TCCR3B = 0;&#xA;&#xA;  // Set compare match register to the desired timer count&#xA;  OCR3A=77; //16*10^6/(200Hz*1024)-1 = 77 -&amp;gt; 200 Hz &#xA;  //OCR3A=193; //16*10^6/(80Hz*1024)-1 = 194 -&amp;gt; 80 Hz &#xA;&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;  // enable global interrupts:&#xA;  sei(); &#xA;&#xA;  k = micros();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(1000);&#xA;  Serial.println(cont);&#xA;  cont=0; &#xA;}&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{  &#xA;  cont++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step II: Reading values from the sensor in the ISR&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I add the I2C function in the Interrupt Service Routine, but the program is blocked after the calcBias() function which reads from the sensor, measures and saves the acquisition time in the samplingTime variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Timer variables&#xA;volatile float phi=0;&#xA;volatile float theta=0;&#xA;volatile float psi=0;&#xA;volatile int x = 0;&#xA;volatile int y = 0;&#xA;volatile int z = 0;&#xA;volatile int cont=0;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(115200);&#xA;&#xA;  setupL3G4200D(2000); // Configure L3G4200  - 250, 500 or 2000 deg/sec&#xA;  delay(1500); //wait for the sensor to be ready   &#xA;&#xA;  calcBias():&#xA;  Serial.print(&quot;Readings take: (us)&quot;);&#xA;  Serial.println(samplingTime);&#xA;&#xA;  // Initialize Timer&#xA;  cli();&#xA;  TCCR3A = 0;&#xA;  TCCR3B = 0;&#xA;&#xA;  // Set compare match register to the desired timer count&#xA;  OCR3A=77; //16*10^6/(200Hz*1024)-1 = 77 -&amp;gt; 200 Hz &#xA;  //OCR3A=193; //16*10^6/(80Hz*1024)-1 = 194 -&amp;gt; 80 Hz &#xA;&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; WGM32);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR3B |= (1 &amp;lt;&amp;lt; CS30) | (1 &amp;lt;&amp;lt; CS32);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK3 |= (1 &amp;lt;&amp;lt; OCIE3B);&#xA;&#xA;  Serial.println(&quot;Enabling interrupts..&quot;);&#xA;  // enable global interrupts:&#xA;  sei(); &#xA;&#xA;  k = micros();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(1000);&#xA;  Serial.println(cont);&#xA;  Serial.println(z);&#xA;  cont=0; &#xA;}&#xA;&#xA;&#xA;ISR(TIMER3_COMPB_vect)&#xA;{  &#xA;  // Update x, y, and z with new values 2.5ms     &#xA;  getGyroValues(); &#xA;  cont++;&#xA;}&#xA;&#xA;void getGyroValues()&#xA;{   &#xA;&#xA;  //starting samplingTimer&#xA;  samplingTime = micros();  &#xA;&#xA;  // Gets the angular velocity from the sensor&#xA;  byte zMSB = readRegister(L3G4200D_Address, 0x2D);&#xA;  byte zLSB = readRegister(L3G4200D_Address, 0x2C);&#xA;  z = ((zMSB &amp;lt;&amp;lt; 8) | zLSB);&#xA;&#xA;  samplingTime = micros()- samplingTime;&#xA;}&#xA;&#xA;void calcBias()&#xA;{  &#xA;  Serial.println(&quot;Bias&quot;);&#xA;&#xA;  // Reads sensors and display three values&#xA;  getGyroValues(); &#xA;&#xA;  [...]      &#xA;&#xA;  Serial.println(bx);&#xA;  Serial.println(by);&#xA;  Serial.println(bz);        &#xA;}&#xA;&#xA;void writeRegister(int deviceAddress, byte address, byte val) &#xA;{&#xA;    Wire.beginTransmission(deviceAddress); // start transmission to device &#xA;    Wire.write(address);       // send register address&#xA;    Wire.write(val);         // send value to write&#xA;    Wire.endTransmission();     // end transmission&#xA;}&#xA;&#xA;int readRegister(int deviceAddress, byte address)&#xA;{&#xA;    int v;&#xA;    Wire.beginTransmission(deviceAddress);&#xA;    Wire.write(address); // register to read&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.requestFrom(deviceAddress, 1); // read a byte&#xA;&#xA;    while(!Wire.available()) &#xA;    {&#xA;        // waiting&#xA;       // Serial.println(&quot;No Data&quot;);&#xA;    }&#xA;&#xA;    v = Wire.read();&#xA;    return v;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought that the interrupt frequency was to high and I tried with 80 Hz and 20 Hz. Same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;starting up L3G4200D&#xA;Bias&#xA;4.00&#xA;0.00&#xA;-3.00&#xA;Read&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="4396" LastEditDate="2015-03-16T16:30:23.733" LastActivityDate="2015-07-01T21:09:40.277" Title="Reading I2C sensors with a timer interrupt" Tags="|serial|arduino-mega|i2c|interrupt|timers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9389" PostTypeId="2" ParentId="9384" CreationDate="2015-03-16T19:15:42.480" Score="3" Body="&lt;p&gt;Both your measurement (e.g. using a voltmeter) and the ADC of the Arduino have a limited accuracy (cf. table 28.7 in the &lt;a href=&quot;http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet of the ATmega328&lt;/a&gt;). Therefore you should never expect them to agree to all given digits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the points raised in your comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All comments are true but it gives 5V correctly, why? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;analogRead&lt;/code&gt; returns a value between 0 and 1023. For all voltages above an (unknown) threshold close to 5 V, it will saturate and always return 1023, no matter what the actual input voltage is. This value is then converted to 5.000 V in your code. What you are probably seeing is just the maximum value your code can return, not an accurate measurement of a 5 V input voltage.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And my voltmeter is not corrupted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It doesn't have to be corrupted. It will still be off. Have a look at the manual to find the nominal accuracy. (Also note that &lt;a href=&quot;https://en.wikipedia.org/wiki/Accuracy_and_precision&quot; rel=&quot;nofollow&quot;&gt;accuracy and precision&lt;/a&gt; are two different things and different from the number of digits of the display, assuming your voltmeter is digital.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-17T18:06:36.287" LastActivityDate="2015-03-17T18:06:36.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9390" PostTypeId="1" CreationDate="2015-03-16T19:36:05.287" Score="7" ViewCount="17777" Body="&lt;p&gt;I need debouncing/stateChange for a push button configuration. Is there a good library for debouncing/stateChange buttons in Arduino (without delay)?  &lt;/p&gt;&#xA;" OwnerUserId="7556" LastEditorUserId="4628" LastEditDate="2017-08-14T08:11:28.480" LastActivityDate="2021-02-09T19:37:18.660" Title="Good button debouncing/stateChange library" Tags="|arduino-uno|button|debounce|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9393" PostTypeId="2" ParentId="9388" CreationDate="2015-03-16T19:51:47.820" Score="5" Body="&lt;p&gt;Try putting &lt;code&gt;sei();&lt;/code&gt; at the start of the ISR. I think I2C needs interrupts enabled to work.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-16T19:51:47.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9394" PostTypeId="1" CreationDate="2015-03-16T19:58:09.413" Score="0" ViewCount="605" Body="&lt;p&gt;Consider this scenario, I have a single byte of data; I have to use the 8 bits it is composed of to generate 4 extra bits from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, my problem is that I have to store this data somewhere while I operate on it and then return the final answer in byte form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg. 1 byte of 8 bits becomes 12 bits. Thus 2 bytes results in 24 bits which I want to transfer in packets of 3 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01001101 becomes this with added bits: _ _ 0 _ 1 0 0 _ 1 1 0 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the most efficient way to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="7865" OwnerDisplayName="thirdattempt" LastActivityDate="2015-03-16T22:47:09.437" Title="Arduino/C++ byte manipulation" Tags="|communication|c++|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9395" PostTypeId="2" ParentId="9394" CreationDate="2015-03-16T20:28:34.890" Score="0" Body="&lt;p&gt;Assuming the incoming bytes are guaranteed to come in even numbers, and&#xA;your output is in little-endian order, you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void process_and_send_bytes(uint8_t data_in)&#xA;{&#xA;    uint16_t some_12_bit_function(uint8_t);  // processing function&#xA;    void send_byte(uint8_t);                 // sending function&#xA;    static uint8_t data_on_old = 0;&#xA;    static bool has_data_on_old = false;&#xA;    uint16_t processed_data = some_12_bit_function(data_in);&#xA;    if (has_data_on_old) {&#xA;        send_byte(processed_data &amp;lt;&amp;lt; 4 | data_on_old);  // two pieces&#xA;        send_byte(processed_data &amp;gt;&amp;gt; 4);      // high 8 bits&#xA;        has_data_on_old = false;&#xA;    }&#xA;    else {&#xA;        send_byte(processed_data);           // send low 8 bits&#xA;        data_on_old = processed_data &amp;gt;&amp;gt; 8;   // save higher 4 bits&#xA;        has_data_on_old = true;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, when you get the first byte, this function outputs one byte&#xA;and keeps 4&amp;nbsp;bits on hold. When you get the next byte, this outputs the&#xA;4&amp;nbsp;bits that where on hold, together with the new 12 bits, as two&#xA;8-bit packets.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-16T20:40:34.100" LastActivityDate="2015-03-16T20:40:34.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9396" PostTypeId="2" ParentId="4695" CreationDate="2015-03-16T20:29:22.707" Score="6" Body="&lt;p&gt;Thake a look at &lt;a href=&quot;http://yaab-arduino.blogspot.com/p/ala.html&quot; rel=&quot;noreferrer&quot;&gt;this library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://www.youtube.com/watch?v=w2nSKQxpV_I&quot; rel=&quot;noreferrer&quot;&gt;this video&lt;/a&gt; you can see some of the many animations available.&lt;/p&gt;&#xA;" OwnerUserId="7930" LastActivityDate="2015-03-16T20:29:22.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9397" PostTypeId="2" ParentId="9394" CreationDate="2015-03-16T20:35:58.783" Score="2" Body="&lt;p&gt;Sometimes the brute-force way is also the most efficient. Just copy the bits one at a time from the corresponding source variable to the destination variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int merge_bits (int old_bits, int new_bits)&#xA;{&#xA;   int retval = 0;&#xA;   if (old_bits &amp;amp; 0x01) retval |= 0x001;&#xA;   if (old_bits &amp;amp; 0x02) retval |= 0x002;&#xA;   if (old_bits &amp;amp; 0x04) retval |= 0x004;&#xA;   if (old_bits &amp;amp; 0x08) retval |= 0x008;&#xA;   if (new_bits &amp;amp; 0x01) retval |= 0x010;&#xA;   if (old_bits &amp;amp; 0x10) retval |= 0x020;&#xA;   if (old_bits &amp;amp; 0x20) retval |= 0x040;&#xA;   if (old_bits &amp;amp; 0x40) retval |= 0x080;&#xA;   if (new_bits &amp;amp; 0x02) retval |= 0x100;&#xA;   if (old_bits &amp;amp; 0x80) retval |= 0x200;&#xA;   if (new_bits &amp;amp; 0x04) retval |= 0x400;&#xA;   if (new_bits &amp;amp; 0x08) retval |= 0x800;&#xA;   return retval;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On most microprocessors, this will compile into just a few instructions per statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also arguably more maintainable than a complex series of shift and mask operations.&lt;/p&gt;&#xA;" OwnerUserId="614" LastActivityDate="2015-03-16T20:35:58.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9398" PostTypeId="2" ParentId="9394" CreationDate="2015-03-16T22:47:09.437" Score="0" Body="&lt;p&gt;I haven't tested this in any way whatsoever, but you could use a 32-bit integer as a buffer to store the bytes as you process them.  Then, any multiples of 8 bytes that end up in the buffer can be passed on to wherever they are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first byte that comes in you process and push all 12 bits into the 32-bit integer - increment a counter by 12.  You now have 12 bits in the buffer variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then while the number of bits in the buffer is at least 8 bits you grab the upper-most 8 bits and pass them on to wherever they are going.  Decrement the counter by 8 for each iteration.  You have now sent 1 byte and you have 4 bits left in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next byte that comes in you push the new 12 bits into the buffer.  The counter, increased by 12, is now 16.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;16 is greater than or equal to 8, so send out the upper 8 bits of the 16 and decrement the counter by 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8 is greater than or equal to 8, so send out the upper 8 bits of the 8 and decrement the counter by 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Counter is now 0, so nothing else to send.  Back to the beginning again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void processByte(uint8_t in) {&#xA;    static uint32_t buffer = 0;&#xA;    static uint8_t validBits = 0;&#xA;    buffer &amp;lt;&amp;lt;= 12; // Make room for 12 new bits.&#xA;    buffer |= (first processed bit &amp;lt;&amp;lt; 11);&#xA;    buffer |= (second processed bit &amp;lt;&amp;lt; 10);&#xA;    buffer |= ((in &amp;amp; 0x80) &amp;lt;&amp;lt; 2);&#xA;    buffer |= (third processed bit &amp;lt;&amp;lt; 7);&#xA;    buffer |= ((in &amp;amp; 0x70) &amp;lt;&amp;lt; 1);&#xA;    buffer |= (fourth processed bit &amp;lt;&amp;lt; 4);&#xA;    buffer |= (in &amp;amp; 0x0F);&#xA;    validBits += 12;&#xA;&#xA;    while (validBits &amp;gt;= 8)&#xA;        validBits -= 8;&#xA;        executeByte((buffer &amp;gt;&amp;gt; validBits) &amp;amp; 0xFF);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-03-16T22:47:09.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9399" PostTypeId="2" ParentId="9390" CreationDate="2015-03-17T00:01:28.160" Score="1" Body="&lt;p&gt;I can receommend the following library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://log.liminastudio.com/itp/physical-computing/arduino-a-new-improved-button-library-with-some-handy-features&quot; rel=&quot;nofollow&quot;&gt;http://log.liminastudio.com/itp/physical-computing/arduino-a-new-improved-button-library-with-some-handy-features&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/virgildisgr4ce/Button&quot; rel=&quot;nofollow&quot;&gt;https://github.com/virgildisgr4ce/Button&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the website you will find some examples on how to use it. I have implemented this library already in several sketches and it works very reliably.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-03-17T00:01:28.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9400" PostTypeId="2" ParentId="9390" CreationDate="2015-03-17T01:01:41.940" Score="5" Body="&lt;p&gt;I think what you need is an interrupt-based detection of the button. This way, your Arduino can do what it needs to do without stalling for the delay function. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example code usage&#xA;&#xA;int pin = 13; // LED on board&#xA;int interrupt0pin = 2; // pin attached to int0 if you're using Uno&#xA;int buttonState;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(pin, OUTPUT);&#xA;  pinMode(interrupt0pin, INPUT);&#xA;  attachInterrupt(0, buttonUpdate, CHANGE); // calls buttonUpdate() when button input changes (you can also use high-to-low or low-to-high)&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (buttonState)&#xA;        digitalWrite(pin, HIGH);&#xA;    else&#xA;        digitalWrite(pin, LOW);&#xA;}&#xA;&#xA;void buttonUpdate()&#xA;{&#xA;  buttonState = digitalRead(interrupt0pin);&#xA;  delay(50); // 50ms works for most switches - adjustable&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Find out more here: &lt;a href=&quot;http://arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;noreferrer&quot;&gt;http://arduino.cc/en/Reference/AttachInterrupt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="7282" LastEditDate="2015-03-17T01:08:46.947" LastActivityDate="2015-03-17T01:08:46.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9401" PostTypeId="2" ParentId="9366" CreationDate="2015-03-17T01:52:29.597" Score="0" Body="&lt;p&gt;The original idea was to divide up a specific period into segments where each digit on the 4-digit 7-segment would light up. I would use a mod(%) and divide it up to make the function call more generic for future extensibility (and also make it more asynchronous). What I learned is that it would probably take more work doing the calculations then just calling a function to reset and light up the next digit one after another. Here's the updated code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// CONFIGURATION&#xA;// Pins&#xA;const int latchPin = 2;&#xA;const int clockPin = 4;&#xA;const int dataPin = 3;&#xA;&#xA;// Timers&#xA;const int countdown = 60; // amount of time to countdown from in seconds&#xA;const long reset_interval = countdown*1000000; // interval before reset in microseconds, i.e. if countdown is set to 60s, every 60 seconds will reset display to countdown start&#xA;&#xA;// States&#xA;unsigned long last_display_update_time = 0; // Holds the last time output change was checked&#xA;unsigned long curr_time = 0;&#xA;bool fourDigit7Segment_enable = true; // set if we are using 4 digit 7 segment led&#xA;&#xA;// States&#xA;byte leds = 0;&#xA;byte digits = 0;&#xA;&#xA;int output_count=0;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);  &#xA;  pinMode(clockPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  updateResetTimer(); // checks what the countdown is at&#xA;  int timeleft = countdown - (curr_time - last_display_update_time)/1000000;&#xA;  leds = getSevenSegmentFormation(timeleft/10);&#xA;  updateShiftRegister(0);&#xA;  leds = getSevenSegmentFormation(timeleft%10);&#xA;  updateShiftRegister(1);&#xA;}&#xA;&#xA;void updateShiftRegister(int digit)&#xA;{&#xA;  digitalWrite(latchPin, LOW); // Gets latch ready by setting to low since we need a rising edge to trigger&#xA;  if(fourDigit7Segment_enable){&#xA;    int digitON = micros();&#xA;    digits = 0;&#xA;    bitWrite(digits, digit, 1);&#xA;    //shift out digit control first in LSB&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, digits); // shiftOut will write to dataPin and trigger a rising on clickPin at same time while writing byte value from leds var&#xA;  }&#xA;  shiftOut(dataPin, clockPin, MSBFIRST, leds); // shiftOut will write to dataPin and trigger a rising on clickPin at same time while writing byte value from leds var&#xA;  digitalWrite(latchPin, HIGH); // Trigger with rising edge&#xA;}&#xA;&#xA;//Turns off all 7 segments of a digit, will need to specify digits 0 to n&#xA;void clearMemory(int i){&#xA;  leds = 0;&#xA;  updateShiftRegister(i);&#xA;}&#xA;&#xA;//Updating timer for resetting countdown&#xA;//Will take absolute current time and compare it to the last time checked, if it is greater than countdown value, we reset&#xA;void updateResetTimer(){&#xA;  curr_time = micros();&#xA;  if (curr_time - last_display_update_time &amp;gt;= reset_interval){&#xA;    last_display_update_time = curr_time; // reset_interval set to 10000000, because LED counts 0 to 9, and then needs to reset // actually set to 60*1000000 to countdown 1 minute&#xA;  }&#xA;}&#xA;&#xA;byte getSevenSegmentFormation(int i){&#xA;  switch (i) {&#xA;      case 0:&#xA;        return 0x7E; //01111110&#xA;        break;&#xA;      case 1:&#xA;        return 0x48; //01001000&#xA;        break;&#xA;      case 2:&#xA;        return 0x3D; //00111101&#xA;        break;&#xA;      case 3:&#xA;        return 0x6D; //01101101&#xA;        break;&#xA;      case 4:&#xA;        return 0x4B; //01001011&#xA;        break;&#xA;      case 5:&#xA;        return 0x67; //01100111&#xA;        break;&#xA;      case 6:&#xA;        return 0x77; //01110111&#xA;        break;&#xA;      case 7:&#xA;        return 0x4C; //01001100&#xA;        break;&#xA;      case 8:&#xA;        return 0x7F; //01111111&#xA;        break;&#xA;      case 9:&#xA;        return 0x6F; //01101111&#xA;        break;   &#xA;      default:&#xA;        return 0x0; //Arduino doesn't handle bytes in binary&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6709" LastActivityDate="2015-03-17T01:52:29.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9402" PostTypeId="2" ParentId="9390" CreationDate="2015-03-17T02:44:13.107" Score="1" Body="&lt;p&gt;You can put a capacitor in parallel with the switch - 100nf should do the trick. Some capacitors have a minus on the packaging, next to one of the pins - if so, make sure that side is to negative (ground).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-17T02:44:13.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9403" PostTypeId="2" ParentId="8499" CreationDate="2015-03-17T03:20:42.557" Score="1" Body="&lt;p&gt;The Arduino Due needs a patched version of Bossa, not the 1.2.1 version available on SourceForge. Supposedly the patched version is available on GitHub, or you can copy the version in the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the Due USB port must be put into bootloader mode. Open then close the serial port at 1200 baud, and it will re-instantiate as a Bossa programming port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To return to serial port mode, the only way I have found is to power cycle the Due.&lt;/p&gt;&#xA;" OwnerUserId="7935" LastEditorUserId="42" LastEditDate="2015-03-17T10:15:07.067" LastActivityDate="2015-03-17T10:15:07.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9405" PostTypeId="2" ParentId="9384" CreationDate="2015-03-17T06:08:20.483" Score="5" Body="&lt;p&gt;Your question contains a number of errors and misconceptions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly the maximum output of a successive approximation ADC (here 0x3ff) corresponds to Vref - 1 LSB&#xA;The voltage will thus be &lt;code&gt;sensorValue*5000.0/1024&lt;/code&gt;. Note this error is less than the error of ±2LSB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Measuring your 5V is futile, as this is the default analog reference, so the result must be 0x3ff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Measuring the 3.3V pin will give a relative value to the 5V reference. Both are produced from commercial grade regulators with a accuracy of ±5%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are also confusing the precision of the reading (10 bit) with accuracy which is a best ±5% ±2LSB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to measure voltage you should use the internal 1.1V bandgap reference. You would of course need to reduce the 5V and 3.3V to less than 1.1V. This introduces another potential error (even if you use 1% resistors), but would give more accurate results which are directly comparable. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-03-17T06:08:20.483" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9406" PostTypeId="1" AcceptedAnswerId="9418" CreationDate="2015-03-17T07:43:45.227" Score="0" ViewCount="536" Body="&lt;p&gt;I wish to connect 2 simple 5V DC Brushless Fan (80x80x15mm, &lt;a href=&quot;https://www.sparkfun.com/products/9649&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9649&lt;/a&gt;) to Ardumoto (&lt;a href=&quot;https://www.sparkfun.com/products/9815&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9815&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, how to I turn on/off the fan as I do not know how to address it? Do I need to connect a power supply to the Ardumoto, to the Arduino board or 2 separate power supplies to each one of them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7936" LastActivityDate="2015-03-17T15:39:05.150" Title="Connect 5V DC Fan to Ardumoto" Tags="|arduino-motor-shield|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9407" PostTypeId="2" ParentId="9390" CreationDate="2015-03-17T08:08:01.677" Score="7" Body="&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/code/Button&quot; rel=&quot;noreferrer&quot;&gt;Button library&lt;/a&gt; in the Arduino playground works perfectly.&lt;/p&gt;&#xA;" OwnerUserId="7938" LastActivityDate="2015-03-17T08:08:01.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9408" PostTypeId="1" CreationDate="2015-03-17T08:50:14.627" Score="5" ViewCount="36545" Body="&#xA;&#xA;&lt;p&gt;I need to obtain a PWM frequency of at least 125&amp;nbsp;kHz. I plan to drive a pair of MOSFETs using this PWM as the driver signal. The below code gives a 1&amp;nbsp;kHz frequency. Can I just change the delay values to obtain a lower time period, and thereby a higher frequency?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(13, HIGH);&#xA;  delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz&#xA;  digitalWrite(13, LOW);  // Can I change the delay to 1 and 9 for a totaL T=10 µsec and hence f = 100 kHz?&#xA;  delayMicroseconds(900);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On looking up the answers provided, I stumbled across a few tutorials. I used the code below and it resulted in 125&amp;nbsp;kHz and 1.6&amp;nbsp;MHz (measured with a CRO, not simulation). But the code was supposed to provide 250&amp;nbsp;kHz and 8&amp;nbsp;MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My requirement of 125&amp;nbsp;kHz is satisfied, but I am just curious to know why the &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Sketch&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; not working as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// A sketch that creates an 8 MHz, 50% duty cycle PWM and a 250 kHz,&#xA;// 6-bit resolution PWM with varying duty cycle (changes every 5µs&#xA;// or about every period.&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;  pinMode(3, OUTPUT); // Output pin for OCR2B&#xA;  pinMode(5, OUTPUT); // Output pin for OCR0B&#xA;&#xA;  // Set up the 250 kHz output (but cro measures only 125 kHz)&#xA;   TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;   TCCR2B = _BV(WGM22) | _BV(CS20);&#xA;   OCR2A = 63;&#xA;   OCR2B = 0;&#xA;&#xA;  // Set up the 8 MHz output&#xA;   TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00);&#xA;   TCCR0B = _BV(WGM02) | _BV(CS00);&#xA;   OCR0A = 1;&#xA;   OCR0B = 0;&#xA;&#xA;&#xA;  // Make the 250 kHz rolling&#xA;  while (1) {&#xA;    _delay_us(5);&#xA;    if (OCR2B &amp;lt; 63)&#xA;      OCR2B += 5;&#xA;    else&#xA;      OCR2B = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7939" LastEditorUserId="510" LastEditDate="2015-08-08T09:25:01.573" LastActivityDate="2019-11-18T18:07:12.150" Title="Generating a PWM frequency greater than 125 kHz using Arduino Uno" Tags="|arduino-uno|pwm|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9409" PostTypeId="2" ParentId="9382" CreationDate="2015-03-17T09:37:58.983" Score="3" Body="&lt;p&gt;You could try to flash the firmware of the USB controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;General steps for Arduino R3 are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the Arduino in DFU mode (the R3 does &lt;em&gt;not&lt;/em&gt; require soldering for that)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Flash the firmware using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dfu-programmer atmega16u2 erase&#xA;dfu-programmer atmega16u2 flash Arduino-usbserial-atmega16u2-Uno-Rev3.hex&#xA;dfu-programmer atmega16u2 reset&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The package &quot;dfu-programmer&quot; is most likely available for your distribution.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you have to build it from source, because your DFU programmer does not know the ATmega16U2 yet, you will need to install libusb-dev (on Debian-based systems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Useful links for that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;https://github.com/leocadiotine/Dvorany/wiki/Resetting-your-Uno-R3%27s-default-firmware&quot; rel=&quot;nofollow noreferrer&quot;&gt;Resetting your Uno R3's default firmware&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Updating the Atmega8U2 and 16U2 on an Uno or Mega2560 using DFU&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A useful search term for that is &lt;code&gt;Arduino R3 DFU-programmer&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4531" LastEditorUserId="510" LastEditDate="2020-04-06T05:04:52.130" LastActivityDate="2020-04-06T05:04:52.130" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9410" PostTypeId="1" AcceptedAnswerId="75102" CreationDate="2015-03-17T10:34:58.837" Score="0" ViewCount="1101" Body="&lt;p&gt;I am new with Arduino, and i cant find documentation about how to connect Arduino with Watermark successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to connect my Arduino UNO with a watermark like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://guideimg.alibaba.com/images/shop/72/08/19/4/watermark-soil-moisture-sensor-w-15-cable_3234944.jpg&quot; rel=&quot;nofollow&quot;&gt;http://guideimg.alibaba.com/images/shop/72/08/19/4/watermark-soil-moisture-sensor-w-15-cable_3234944.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know any schema or documentation about how to do it? Have anyone tried it before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found this: &lt;a href=&quot;https://oceancontrols.com.au/datasheet/davis/ECS-014_07395-158_IM_06440_6470.pdf&quot; rel=&quot;nofollow&quot;&gt;https://oceancontrols.com.au/datasheet/davis/ECS-014_07395-158_IM_06440_6470.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but still not clear how to do it in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks you for your time.&lt;/p&gt;&#xA;" OwnerUserId="7831" LastActivityDate="2020-05-23T06:01:45.180" Title="How to: soil moisture measurement with WaterMark?" Tags="|sensors|" AnswerCount="1" CommentCount="1" ClosedDate="2020-05-23T15:40:21.890" ContentLicense="CC BY-SA 3.0" />
  <row Id="9411" PostTypeId="2" ParentId="9408" CreationDate="2015-03-17T11:05:20.057" Score="4" Body="&lt;p&gt;It's a bit beyond the normal Arduino capabilites so you need to delve into setting some of the registers for your ATMEGA chip directly. See the &quot;Using the ATmega PWM registers directly&quot; &lt;a href=&quot;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7182" LastActivityDate="2015-03-17T11:05:20.057" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9412" PostTypeId="1" CreationDate="2015-03-17T11:56:02.387" Score="0" ViewCount="187" Body="&lt;p&gt;I'm newbie to the world of arduino and environmental sensing. I have been searching for a while about how can I measure the heart pulse rate, I came through the following tutorial:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://medicarduino.net/?page_id=204.&quot; rel=&quot;nofollow&quot;&gt;Click Here&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00KMMF7AO&quot; rel=&quot;nofollow&quot;&gt;Arduino IR Receiver with metal shell module&lt;/a&gt; that I want to use as the previous tutorial suggesting, but, the IR receiver used in the tutorial has no metal shell, so, my question is if they are both functioning the same way?&lt;br&gt;&#xA;Can I position my IR Receiver exactly as the one in the tutorial or do I need some workaround to reach my goal based on the fact that it has a metal shell?&lt;br&gt;&#xA;Thanks in advance.  &lt;/p&gt;&#xA;" OwnerUserId="7941" LastActivityDate="2021-12-09T09:06:15.617" Title="Question about infrared receiver with metal shell to detect heart pulse rate?" Tags="|arduino-uno|sensors|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9413" PostTypeId="1" CreationDate="2015-03-17T12:40:47.860" Score="3" ViewCount="168" Body="&lt;p&gt;I'm trying to understand the auto reset process and why a capacitor hooked up between DTR and Reset works so I ran it through my logic analyzer and I'm seeing the chip reset three times during the programming process. Does anyone know why it's done three times and not just once?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see in the picture the top pin is the DTR and the bottom two are attached to reset (digital/analog). When DTR drops low the reset pin does too for between 200-500us but it does it three times in around 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6G3RW.png&quot; alt=&quot;Auto Reset&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6544" LastActivityDate="2016-01-12T18:38:04.643" Title="Why is the atmega chip reset three times during programming?" Tags="|reset|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9414" PostTypeId="2" ParentId="9412" CreationDate="2015-03-17T12:44:19.893" Score="1" Body="&lt;p&gt;&quot;Proper&quot; oxygen meters use a bimodal LED - red + IR - so there will be limitations to this. They also have a piece of copper foil wrapped around the sensor &amp;amp; heavily earthed, so your shielded sensor has, already, an advantage!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to use your receiver exactly the same way. If you can ground the shield, do so.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-03-17T12:44:19.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9415" PostTypeId="1" CreationDate="2015-03-17T15:24:59.603" Score="2" ViewCount="491" Body="&lt;p&gt;I'm doing a project using an Arduino pro mini 3.3v and Adafruit's Neopixel. &#xA;I've flashed an example (strand example) from the Adafruit Neopixel's library sketch into the Arduino using the FTDI Basic Breakout 3.3v and everything went fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I disconnected the FTDI Basic Breakout from my laptop, the LEDs stop working. They light up with some different color and the animation stops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with other example sketches and everything seemed to work fine. I never experienced anything like this and I had no success searching for this issues in forums or google. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might be the problem and how can I solve it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7945" LastActivityDate="2015-03-17T15:24:59.603" Title="Pro Mini 3.3v + Neopixel not working when disconnected from USB" Tags="|led|power|arduino-pro-mini|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9416" PostTypeId="1" AcceptedAnswerId="9417" CreationDate="2015-03-17T15:32:14.893" Score="3" ViewCount="728" Body="&lt;p&gt;I'm trying to manipulate the ports of Arduino using C code. I have attached an LED to pin 8 and a tact switch to pin 13 (with a pull down resistor). The code works fine, and the results are printed on the screen. So, when the button is pressed, the byte &lt;code&gt;PINB &amp;amp; (1 &amp;lt;&amp;lt; PB5)&lt;/code&gt; equals 32, or &lt;code&gt;0b00100000&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I try to use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if( PINB &amp;amp;(1&amp;lt;&amp;lt;PB5) == 32){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if( PINB &amp;amp;(1&amp;lt;&amp;lt;PB5) == 0b00100000){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the LED doesn't respond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  DDRB |= 0b00011111; &#xA;  Serial.begin(9600);&#xA;  }&#xA;&#xA;void loop() {&#xA;  Serial.print(&quot;PINB &amp;amp;(1&amp;lt;&amp;lt;PB5)&quot;);&#xA;  Serial.println(PINB &amp;amp;(1&amp;lt;&amp;lt;PB5));&#xA;&#xA;  if( PINB &amp;amp;(1&amp;lt;&amp;lt;PB5) ){&#xA;    PORTB |= (1&amp;lt;&amp;lt;PB0);&#xA;    }&#xA;  else{&#xA;    PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB0);    &#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="6936" LastEditDate="2015-03-19T16:44:51.637" LastActivityDate="2015-03-19T16:44:51.637" Title="Port manipulation using C code" Tags="|programming|c|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9417" PostTypeId="2" ParentId="9416" CreationDate="2015-03-17T15:38:31.413" Score="5" Body="&lt;p&gt;&lt;code&gt;==&lt;/code&gt; has higher precedence than &lt;code&gt;&amp;amp;&lt;/code&gt;, which means that your comparison will be performed incorrectly. But that doesn't matter, since you don't need to check if the port has a &lt;em&gt;specific&lt;/em&gt; value, just if the appropriate bit is set.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-17T15:38:31.413" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9418" PostTypeId="2" ParentId="9406" CreationDate="2015-03-17T15:39:05.150" Score="1" Body="&lt;p&gt;If you look at the &lt;a href=&quot;https://www.sparkfun.com/datasheets/DevTools/Arduino/Ardumoto_v13.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt; on the product page it shows that the &lt;code&gt;Vin&lt;/code&gt; from the arduino is connected to the same Vin on the shield and the Vin to the motor driver. So it is either or where you want to connect power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With regards to controlling the fan, brushless fans are polarized because of the internal control circuitry, this means that &lt;strong&gt;it cannot be made to reverse&lt;/strong&gt;, therefore you should always give the direction pin a high signal. The &lt;a href=&quot;https://learn.sparkfun.com/tutohttps://learn.sparkfun.com/tutorials/ardumoto-shield-hookup-guiderials/ardumoto-shield-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;Sparkfun hookup guide&lt;/a&gt; has a example code which shows how to control the motor shield, and some explination.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-03-17T15:39:05.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9419" PostTypeId="1" CreationDate="2015-03-17T16:25:08.423" Score="1" ViewCount="652" Body="&lt;p&gt;I have been trying use the &lt;a href=&quot;http://www.seeedstudio.com/depot/Wifi-Shield-p-1220.html&quot; rel=&quot;nofollow&quot;&gt;Seeedstudio wifi shield v1.1&lt;/a&gt; with Arduino Mega 2560 as part of my project but I could not make the WiFly library provided on the &lt;a href=&quot;http://www.seeedstudio.com/wiki/Wifi_Shield_V1.1&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt; work with the Mega. I tried to run the example sketch wifly_test but it did not work I tried some troubleshooting and found that the write commands to the shield were not successful. After a few hours of searching on the internet, I found out the problem and was able to solve it. I am posting my solution below. Anyone is welcome to add to my solution.&lt;/p&gt;&#xA;" OwnerUserId="7948" OwnerDisplayName="Waqas" LastActivityDate="2017-05-12T08:48:20.183" Title="Seeedstudio Wifi shield v1.1 Not working with Arduino Mega 2560" Tags="|wifi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9421" PostTypeId="1" CreationDate="2015-03-17T17:24:45.093" Score="1" ViewCount="931" Body="&lt;p&gt;I'm using three PWM outputs from an Arduino Mini Pro to drive the R/G/B parts of some strips of LEDs. The circuit is basically this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/GWrfB.gif&quot; alt=&quot;circuit diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a single 12V power supply, rated at 200W, to light the LEDs and to power the Arduino via the RAW pin, and there are 5 metres of 60LEDs/m RGB LEDs, i.e. a total of 300 LEDs, which should be drawing ~72W according to the spec sheet (14.4W/m).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that even when the sketch says &lt;strong&gt;&lt;code&gt;digitalWrite(9, 255); digitalWrite(10, 255); digitalWrite(11,255)&lt;/code&gt;&lt;/strong&gt;, the LEDs are considerably dimmer than when connected directly to the 12V supply. My cheap, digital volt meter measures ~8.1V &lt;del&gt;between GND and the PWM pins&lt;/del&gt; across the LEDs, not the 12V that the transformer is supplying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong? Does the MOSFET really cause such a large drop in voltage? Is there anything I can do to mitigate it? (It's important to get as much brightness as possible from the LEDs for this project).&lt;/p&gt;&#xA;" OwnerUserId="7624" LastEditorUserId="7624" LastEditDate="2015-03-18T11:33:37.730" LastActivityDate="2015-09-21T23:43:24.517" Title="Why are MOSFETs only giving 8.1V for LEDs, not 12V?" Tags="|led|voltage-level|mosfet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9422" PostTypeId="2" ParentId="9419" CreationDate="2015-03-17T17:40:39.967" Score="1" Body="&lt;p&gt;The WiFly library provided at the Seeedstudio wiki uses the software serial to communicate with the WiFi shield. All the example files provided by the WiFly library use pins 2 and 3 as the Rx and Tx of the software serial. Moreover, the Wifi shield only allows pins 0-7 to be chosen as Rx and Tx by using different jumper combinations.&#xA;The &lt;a href=&quot;http://arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; library, on the other hand, has the following limitation for the Arduino Mega&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, as a workaround, I jumped pin 2 of the shiled with pin 10 (Rx of Software Serial) and pin 3 with pin 11 (Tx of Software Serial) using connecting wires and used the jumper setting given on the wiki. Finally I made the following changes in the example code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pins' connection&#xA;// Arduino       WiFly&#xA;//  10    &amp;lt;----&amp;gt;    TX (via connecting pin 2 to 10 on wifi shield)&#xA;//  11    &amp;lt;----&amp;gt;    RX (via connecting pin 3 to 11 on wifi shield)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;SoftwareSerial uart(10, 11); //change software serial pins for Mega&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allowed the Mega to communicate with the Wifi shield successfully using the WiFly library.&lt;/p&gt;&#xA;" OwnerUserId="7948" LastActivityDate="2015-03-17T17:40:39.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9425" PostTypeId="1" AcceptedAnswerId="9980" CreationDate="2015-03-17T18:41:46.257" Score="5" ViewCount="25703" Body="&lt;p&gt;Leading on from the question &lt;a href=&quot;https://arduino.stackexchange.com/questions/4364/can-i-change-font-color-and-or-type-for-ide-1-5-6r2&quot;&gt;Can I change font Color and/or Type for IDE 1.5.6r2?&lt;/a&gt;, in 1.6.0, or 1.6.1&lt;sup&gt;1&lt;/sup&gt; it does not seem to be possible to change &lt;code&gt;console.color&lt;/code&gt; or &lt;code&gt;console.error.color&lt;/code&gt;. To be precise, you can change the settings in the &lt;code&gt;preferences.txt&lt;/code&gt;&lt;sup&gt;2&lt;/sup&gt; file, but they appear to be ignored when the IDE is restarted. Have these become hard coded?  I see from the &lt;a href=&quot;https://code.google.com/p/arduino/source/browse/trunk/build/shared/lib/preferences.txt?r=71&quot; rel=&quot;nofollow noreferrer&quot;&gt;preference.txt example file&lt;/a&gt; that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Some colors have been hardcoded into the source in app/ in order to ensure&#xA;# consistency with the images distributed and stored with the application.&#xA;# They have been commented out below so that users who install an old&#xA;# version of the software will not get incorrect colors left-over from this&#xA;# config file.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the settings to which I refer are not commented out, and so would led me to believe that they can be changed. Orange text on black is just horrific to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;console.error.color=#FFF000&#xA;console.color=#FFCCCC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I still get white/orange(red?) text for the output and error messages respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am making the edits while the Arduino IDE is not running. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; In 1.6.3 the ignored &lt;code&gt;console.color&lt;/code&gt; etc. lines appear to have been removed from the &lt;code&gt;preferences.txt&lt;/code&gt; file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;2&lt;/sup&gt; &lt;code&gt;C:\Users\username\AppData\Roaming\Arduino15\preferences.txt&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2018-09-13T09:01:01.723" Title="How do I change the Console colour of Arduino IDE?" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9427" PostTypeId="2" ParentId="8661" CreationDate="2015-03-17T21:34:22.833" Score="4" Body="&lt;p&gt;Simple version: No, you cannot program Arduino using Objective-C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long version:&#xA;The Arduino IDE uses avr-gcc as it's compiler, and avr-gcc is a C/C++ compiler, not an Object-C compiler. The Arduino libraries are written in C/C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other compilers that exist for &lt;em&gt;AVR&lt;/em&gt; processors, and so it is possible to use other languages for the &lt;em&gt;AVR&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you switch to a different compiler for your code, you will not be able to use the Arduino libraries with it, because they are written in C/C++ for the avr-gcc compiler. (It may be possible to compile the Arduino libraries with avr-gcc, and then link them to your code using external language linking methods, but that could be a significant challenge.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I do not know of any existing Objective-C compilers for AVR; it's possible one may exist, but after a quick web search, I didn't find any.&lt;/p&gt;&#xA;" OwnerUserId="7815" LastActivityDate="2015-03-17T21:34:22.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9428" PostTypeId="1" CreationDate="2015-03-17T21:43:44.660" Score="0" ViewCount="1699" Body="&lt;p&gt;What's the safest way to determine a lithium-ion polymer battery's discharge and charging state using an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see a ton of 12 V LiPo batteries like &lt;a href=&quot;http://www.ebay.com/itm/12V-4000mAh-Lithium-ion-Super-Rechargeable-Battery-Pack-AC-Charger-SPC-2369-US-/370921997007&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt; being sold on eBay and elsewhere. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UfGIR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have a built-in charger, and I'd like to use one to power an Arduino, but the Arduino needs to know &quot;when&quot; the battery needs to be charged, and &quot;when&quot; the battery is fully charged. Unfortunately, the battery doesn't expose any pins or LEDs or other outputs that I could tap into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a few LiPo charging circuits specifically designed for the Arduino, but they all can only handle 3.7 V cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to avoid having to disassemble the battery or modify it to allow me to monitor its state. Is there an easier way, like connecting a battery lead to an analog pin and measuring voltage, or using a coulomb counter?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="26916" LastEditDate="2017-11-04T19:00:41.120" LastActivityDate="2017-11-04T21:43:31.477" Title="How to monitor 12 V LiPo charging from Arduino" Tags="|arduino-uno|battery|" AnswerCount="2" CommentCount="20" ContentLicense="CC BY-SA 3.0" />
  <row Id="9429" PostTypeId="2" ParentId="6670" CreationDate="2015-03-17T22:03:06.750" Score="3" Body="&lt;p&gt;Your log is showing that communication is failing right away (avrdude never gets a proper response). This can mean that &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the VCC is not resetting&lt;/li&gt;&#xA;&lt;li&gt;there is no bootloader installed &lt;/li&gt;&#xA;&lt;li&gt;there is some other defect&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can test case is by manually hitting the reset switch around the time that avrdude starts. If the necessary pins are available, you can exclude case 2 by installing a new boot loader with a programmer, which also tests scenario 3 a bit. &lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2015-03-17T22:03:06.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9430" PostTypeId="2" ParentId="8104" CreationDate="2015-03-17T22:18:37.583" Score="1" Body="&lt;p&gt;OSC is such a simple format that I ended up ditching libraries entirely, and just parsing the UDP packets directly with a state machine.  Just learn the wire format of the bytes and parse the state machine explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's just a trivial function calling format.  The message starts with a 32-bit padded zero terminated string (important!) for the method name.  I am not sure if the type tag is mandatory but it was always being sent (ie: &quot;,iff&quot;), then the binary values corresponding to what type tag says - like bigendian int32,float32,float32.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was related to OSC generated by ChucK, SuperCollider, and CSound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Real optimizations would come just from the design of the protocol itself.  You will need to assume that any UDP packet can be dropped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are sending motor changes as diffs from current position, so you need to handle packet drops somehow.  (ie: Do you have a TCP-like mechanism?  Do you change the design to send absolute motor positions so that position reports are idempotent and subject to re-broadcast?  Do you ack message receipt individually, or do you periodically poll the device for its current state?)&lt;/p&gt;&#xA;" OwnerUserId="7957" LastActivityDate="2015-03-17T22:18:37.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9431" PostTypeId="2" ParentId="9408" CreationDate="2015-03-17T22:45:35.317" Score="0" Body="&lt;p&gt;Yes, you can reduce the delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This function works very accurately in the range 3 microseconds and up. We cannot assure that &lt;code&gt;delayMicroseconds&lt;/code&gt; will perform precisely for smaller delay-times.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that, there are a few cycles between the delays, so as you get shorter timeperiods, you will get less and less accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could hand-code the delay. I would imagine you could get up to 1&amp;nbsp;MHz, but with little control over the duty cycle (at that frequency).You would need to disable interrupts, and you could do nothing else at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want still more, you could set a fuse on the ATmega, and get your native clock speed out on of pin 14 CKO (this shows up as digital pin 8 on the Arduino board) - I would expect a 50% duty cycle; you will have NO control over - you can't switch it on or off, or affect the duty cycle. It can be used to run multiple chips off the same clock.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="510" LastEditDate="2015-09-17T20:41:06.433" LastActivityDate="2015-09-17T20:41:06.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9432" PostTypeId="1" AcceptedAnswerId="9433" CreationDate="2015-03-17T23:40:35.750" Score="1" ViewCount="356" Body="&lt;p&gt;I'm trying to implement a shift register(s) into my circuitry and program to control two seven segment LEDs that would count up from 00 - 99. So far I have a fairly straightforward code (at least, I think. It's my first time experimenting with creating my own void functions) that controls the 7 segs in this manner, but I end up using every single digital pin on my Uno. Here it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int led1a = 13;&#xA;const int led1b = 12;&#xA;const int led1c = 11;&#xA;const int led1d = 10;&#xA;const int led1e = 9;&#xA;const int led1f = 8;&#xA;const int led1g = 7;&#xA;const int led2a = 6;&#xA;const int led2b = 5;&#xA;const int led2c = 4;&#xA;const int led2d = 3;&#xA;const int led2e = 2;&#xA;const int led2f = 1;&#xA;const int led2g = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(led1a, OUTPUT);&#xA;    pinMode(led1b, OUTPUT);&#xA;    pinMode(led1c, OUTPUT);&#xA;    pinMode(led1d, OUTPUT);&#xA;    pinMode(led1e, OUTPUT);&#xA;    pinMode(led1f, OUTPUT);&#xA;    pinMode(led1g, OUTPUT);&#xA;    pinMode(led2a, OUTPUT);&#xA;    pinMode(led2b, OUTPUT);&#xA;    pinMode(led2c, OUTPUT);&#xA;    pinMode(led2d, OUTPUT);&#xA;    pinMode(led2e, OUTPUT);&#xA;    pinMode(led2f, OUTPUT);&#xA;    pinMode(led2g, OUTPUT);&#xA;}&#xA;&#xA;void loop () {&#xA;    led1_0();&#xA;    led2_run();&#xA;    led1_1();&#xA;    led2_run();&#xA;    led1_2();&#xA;    led2_run();&#xA;    led1_3();&#xA;    led2_run();&#xA;    led1_4();&#xA;    led2_run();&#xA;    led1_5();&#xA;    led2_run();&#xA;    led1_6();&#xA;    led2_run();&#xA;    led1_7();&#xA;    led2_run();&#xA;    led1_8();&#xA;    led2_run();&#xA;    led1_9();&#xA;    led2_run();&#xA;}&#xA;&#xA;void led1_0() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1e, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;    digitalWrite(led1f, LOW);&#xA;}&#xA;void led1_1() {&#xA;    digitalWrite(led1a, LOW);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, LOW);&#xA;    digitalWrite(led1e, LOW);&#xA;    digitalWrite(led1f, LOW);&#xA;    digitalWrite(led1g, LOW);&#xA;}&#xA;void led1_2() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1e, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1c, LOW);&#xA;    digitalWrite(led1g, LOW);&#xA;}&#xA;void led1_3() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1e, LOW);&#xA;    digitalWrite(led1g, LOW);&#xA;}&#xA;void led1_4() {&#xA;    digitalWrite(led1a, LOW);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;    digitalWrite(led1e, LOW);&#xA;    digitalWrite(led1d, LOW);&#xA;}&#xA;void led1_5() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1b, LOW);&#xA;    digitalWrite(led1e, LOW);&#xA;}&#xA;void led1_6() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1e, HIGH);&#xA;    digitalWrite(led1b, LOW);&#xA;}&#xA;void led1_7() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, LOW);&#xA;    digitalWrite(led1e, LOW);&#xA;    digitalWrite(led1f, LOW);&#xA;    digitalWrite(led1g, LOW);&#xA;}&#xA;void led1_8() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1e, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;}&#xA;void led1_9() {&#xA;    digitalWrite(led1a, HIGH);&#xA;    digitalWrite(led1b, HIGH);&#xA;    digitalWrite(led1c, HIGH);&#xA;    digitalWrite(led1d, HIGH);&#xA;    digitalWrite(led1g, HIGH);&#xA;    digitalWrite(led1f, HIGH);&#xA;    digitalWrite(led1e, LOW);&#xA;}&#xA;void led2_0() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2e, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;    digitalWrite(led2f, LOW);&#xA;}&#xA;void led2_1() {&#xA;    digitalWrite(led2a, LOW);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, LOW);&#xA;    digitalWrite(led2e, LOW);&#xA;    digitalWrite(led2f, LOW);&#xA;    digitalWrite(led2g, LOW);&#xA;}&#xA;void led2_2() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2e, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2c, LOW);&#xA;    digitalWrite(led2g, LOW);&#xA;}&#xA;void led2_3() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2e, LOW);&#xA;    digitalWrite(led2g, LOW);&#xA;}&#xA;void led2_4() {&#xA;    digitalWrite(led2a, LOW);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;    digitalWrite(led2e, LOW);&#xA;    digitalWrite(led2d, LOW);&#xA;}&#xA;void led2_5() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2b, LOW);&#xA;    digitalWrite(led2e, LOW);&#xA;}&#xA;void led2_6() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2e, HIGH);&#xA;    digitalWrite(led2b, LOW);&#xA;}&#xA;void led2_7() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, LOW);&#xA;    digitalWrite(led2e, LOW);&#xA;    digitalWrite(led2f, LOW);&#xA;    digitalWrite(led2g, LOW);&#xA;}    &#xA;void led2_8() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2e, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;}&#xA;void led2_9() {&#xA;    digitalWrite(led2a, HIGH);&#xA;    digitalWrite(led2b, HIGH);&#xA;    digitalWrite(led2c, HIGH);&#xA;    digitalWrite(led2d, HIGH);&#xA;    digitalWrite(led2g, HIGH);&#xA;    digitalWrite(led2f, HIGH);&#xA;    digitalWrite(led2e, LOW);&#xA;}&#xA;void led2_run() {&#xA;    led2_0();&#xA;    delay(1000);&#xA;    led2_1();&#xA;    delay(1000);&#xA;    led2_2();&#xA;    delay(1000);&#xA;    led2_3();&#xA;    delay(1000);&#xA;    led2_4();&#xA;    delay(1000);&#xA;    led2_5();&#xA;    delay(1000);&#xA;    led2_6();&#xA;    delay(1000);&#xA;    led2_7();&#xA;    delay(1000);&#xA;    led2_8();&#xA;    delay(1000);&#xA;    led2_9();&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how would I reduce the amount of pins used while still keeping functionality? I have two 74HC595N shift registers at my disposal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2015-03-18T21:03:25.280" Title="Integrating Shift Registers into 7 Segment LED Circuit" Tags="|led|sketch|shift-register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9433" PostTypeId="2" ParentId="9432" CreationDate="2015-03-18T01:44:48.087" Score="4" Body="&lt;p&gt;I have done exactly this, to great effect.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int clockPin = 4;&#xA;int dataPin  = 2;&#xA;int oePin    = 3;&#xA;&#xA;// Here are the digits from 0 to 9, as bitmaps.&#xA;// You will need to work out which segments are which,&#xA;// according to your wiring, and make your own.&#xA;unsigned char digitmaps[]={0x7b,0x11,0xe3,0xb3,0x99,0xba,0xfa,0x13,0xfb,0xbb};&#xA;&#xA;void setup() {&#xA;  pinMode(clockPin,OUTPUT);&#xA;  pinMode(dataPin,OUTPUT);&#xA;  pinMode(oePin,OUTPUT);&#xA;}&#xA;&#xA;&#xA;void sendnumber(unsigned int number, int oePin,int dataPin,int clockPin) {&#xA;   digitalWrite(oePin,LOW);&#xA;   shiftOut(dataPin,clockPin,MSBFIRST, digitmaps[(number/10)%10]);&#xA;   shiftOut(dataPin,clockPin,MSBFIRST, digitmaps[number%10]);&#xA;   digitalWrite(oePin,HIGH);&#xA; }&#xA;&#xA;void loop() {&#xA;  for (int i=0; i&amp;lt;100; i++) {&#xA;    sendnumber(i,oePin,dataPin,clockPin);&#xA;    delay(1000);&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The crux of the matter is shiftOut, which shifts 8 bits out the dataPin, toggling the clockPin as it goes, high bit first (MSBFIRST), looking up the pattern in the table. dataPin goes to serial in on the FIRST shift register, clockpin to BOTH clocks, oePin to BOTH OE and another one, I think store register? Q7' or QH' (depending on your docs - it's the overflow pin) of the first goes to the serial in of the second, and +5v &amp;amp; GND, as per normal, and the 8 parallel out Q0-Q7 go to the pins on the 7-segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's anything unclear, or anything I've missed, let me know. My example shows 2 digits, but any number will work, up to the available power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things might be clearer if I convert the digitmaps to binary. The below compiles to the same thing as the one above.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char digitmaps[]={&#xA;   B01111011, // 0&#xA;   B00010001, // 1&#xA;   B11100011, // 2&#xA;   B10110011, // 3&#xA;   B10011001, // 4&#xA;   B10111010, // 5&#xA;   B11111010, // 6&#xA;   B00010011, // 7&#xA;   B11111011, // 8&#xA;   B10111011}; // 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because, in my wiring, from left to right the bits represent in the 8 on my display: center,bottom left,bottom,right bottom,top left,decimal point/not used,top,right top. You can see that the digit &quot;1&quot; has 2 1's in it: the 4th (right bottom) and the last (right top). An 8 has all of the bits set to 1, except position 6 - because that's the decimal point. Send individual bits (e.g. B00010000) to see which segments shows up, make a map, and then combine them.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-03-18T21:03:25.280" LastActivityDate="2015-03-18T21:03:25.280" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9434" PostTypeId="1" AcceptedAnswerId="23605" CreationDate="2015-03-18T03:01:22.933" Score="2" ViewCount="163" Body="&lt;p&gt;I have a Pro Mini wired up to an LCD via an I2C board. At &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoBoardProMini&lt;/a&gt; it says the pro mini can accept up to 12v on the RAW pin as it has a voltage regulator on board. When I plug a 12v power supply into the raw pin, the LCD works fine initially, then slowly degrades into flickering more and more. It also does this with a 9v power supply. At 5v it works perfectly. Any ideas what's going on?&lt;/p&gt;&#xA;" OwnerUserId="7648" LastActivityDate="2016-04-27T02:31:34.460" Title="Flickering LCD when using &gt; 5v power supply on a Pro Mini" Tags="|lcd|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9435" PostTypeId="2" ParentId="9428" CreationDate="2015-03-18T03:30:11.623" Score="1" Body="&lt;p&gt;If you want to buy something off the shelf that will provide power for an Arduino, try a power bank - they have USB out, and are also charged via USB. I found that I had to put a 100 Ohm resistor to stop mine going to sleep, but it's +5V native.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 100 ohm resistor (0.25 watt at least!) draws 50mA, so a 5200mAH powerbank like &lt;a href=&quot;http://www.dx.com/p/universal-5200mah-external-li-ion-battery-charger-power-bank-w-led-indicator-usb-cable-pink-362725#.VQneCnWjlIc&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/universal-5200mah-external-li-ion-battery-charger-power-bank-w-led-indicator-usb-cable-pink-362725#.VQneCnWjlIc&lt;/a&gt; would leak it empty in 104 hours. If you use at least 50mA at all times, then this isn't needed - I think an Arduino draws 35mA already, so you should get away with a 300 Ohm resistor, drawing 16mA. Some experimentation might be needed.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-03-18T20:21:15.363" LastActivityDate="2015-03-18T20:21:15.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9436" PostTypeId="1" CreationDate="2015-03-18T10:49:57.057" Score="3" ViewCount="14306" Body="&lt;p&gt;I need to integrate an analog signal using my Arduino Uno. I am sampling the input signal at 1&amp;nbsp;KHz using a delay command in my &lt;code&gt;void loop()&lt;/code&gt; and adding up the values at the analog read at that specific time. Then I multiply my added output with 0.001&amp;nbsp;s to get my integration. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since, I am new to Arduino Uno, I want some review on the code to check whether I am correct or not. Kindly help, I'll be indebted.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int a=13; //my output pin&#xA;const int c=A0; //my input pin&#xA;int d=0; //my summation variable&#xA;int e=0; //my integration variable(integration as a summation)&#xA;void setup()&#xA;{&#xA;  pinMode(a, OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  int b=analogRead(c);&#xA;  d=d+b; //my summation&#xA;  e=d*10^-3; //my integration as a summation, by sampling my signal at 1ms&#xA;  analogWrite(a,e); //writing my integration into my output pin&#xA;&#xA;  //print the results to the serial monitor&#xA;  Serial.print(&quot;input=&quot;);&#xA;  Serial.print(b);&#xA;  Serial.print(&quot;\t output=&quot;);&#xA;  Serial.println(e);&#xA;&#xA;  delay(1); //wait for 1ms as I want it sampled at that rate&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7964" LastEditorUserId="6936" LastEditDate="2017-07-01T04:57:51.313" LastActivityDate="2017-07-01T04:57:51.313" Title="Integrating an analog signal using Arduino Uno SMD" Tags="|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9437" PostTypeId="2" ParentId="9436" CreationDate="2015-03-18T11:14:23.330" Score="0" Body="&lt;p&gt;I'm not entirely clear on what you're trying to achieve mathematically. However, I can see a number of issues in your code which I'll try to address briefly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arithmetic&lt;/strong&gt;&lt;br&gt;&#xA;I suspect this line isn't doing what you intended:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;e=d*10^-3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;^&lt;/code&gt; operator in C/C++ is actually a bitwise XOR (exclusive-or). There is no arithmetic raise-to-the-power operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a function called &lt;code&gt;pow()&lt;/code&gt; for calculating exponents. However, there's no point using it for a fixed value. It would be better to explicitly write the number, i.e. 0.001.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Precision&lt;/strong&gt;&lt;br&gt;&#xA;The power issue notwithstanding, it's important to note that you're working with integers here, and the result of &lt;code&gt;analogRead()&lt;/code&gt; is only in the range 0 to 1023. Dividing that by 1000 and storing the result as an integer will destroy your data -- most readings will effectively be 0. (That's not to mention the fact that an &lt;code&gt;int&lt;/code&gt; has a limited range and will overflow quite quickly if you don't reset it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple solution would be to store the data using the &lt;code&gt;float&lt;/code&gt; data type (floating point). You would need to declare variables &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; as &lt;code&gt;float&lt;/code&gt; instead of &lt;code&gt;int&lt;/code&gt;. That should let you divide down by 1000 without losing significant precision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output range&lt;/strong&gt;&lt;br&gt;&#xA;The &lt;code&gt;analogWrite()&lt;/code&gt; function has a very specific output range. It will only accept values 0 to 255 (inclusive). I'm not entirely sure what you're hoping to do with it, but I suspect you'll need some way to map your integration calculation onto that output range, or possibly reset your summation periodically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't do that, you'll probably find that &lt;code&gt;e&lt;/code&gt; ends up over 255 very quickly (within a couple of seconds). The result is that you won't see any change on the output PWM.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-18T11:14:23.330" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9438" PostTypeId="2" ParentId="9436" CreationDate="2015-03-18T11:23:50.437" Score="3" Body="&lt;p&gt;There are a couple of issues with your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, &lt;code&gt;10^-3&lt;/code&gt; is not a valid constant in C/C++ code. The correct syntax would be &lt;code&gt;1e-3&lt;/code&gt;, which means 1 &amp;times; 10&lt;sup&gt;-3&lt;/sup&gt;. But you have the further problem that you're working with integer variables, and 0.001 rounded to the nearest integer is just zero. You'll probably want to use &lt;code&gt;float&lt;/code&gt; variables for this math.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the values you get from &lt;code&gt;AnalogRead()&lt;/code&gt; are all non-negative integers, so your summation will quickly overflow unless you subtract a constant from each reading in order to get both positive and negative values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second issue is about the &lt;code&gt;delay()&lt;/code&gt; function, and trying to use it to determine the sample rate of your system. The &lt;code&gt;delay()&lt;/code&gt; function is not all that precise. It really is just guaranteed to produce a delay of &lt;em&gt;at least&lt;/em&gt; the number of milliseconds specified, but it can be more &amp;mdash; sometimes much more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the other operations in your loop take much longer than 1 ms anyway. For example, you're printing on the order of 25 to 30 characters to a serial port on every iteration, which is an overall rate of 25,000 to 30,000 characters per second. Unless you're running your serial port at an insane baud rate (430.8 kbaud or more), it simply won't be able to keep up, and it will end up increasing the period of your loop to whatever time it needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this means that the sample period of your loop is NOT 1 ms as you want, and in fact, it can vary quite a lot based on other things that are going on in the system, such as interrupts. For doing this kind of DSP, you will want to learn how to use a timer interrupt to control the sampling of the analog input, and you'll need to trim the amount of data transmitted for each sample to an amount your serial link can handle.&lt;/p&gt;&#xA;" OwnerUserId="614" LastActivityDate="2015-03-18T11:23:50.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9439" PostTypeId="1" AcceptedAnswerId="9440" CreationDate="2015-03-18T11:50:29.233" Score="0" ViewCount="405" Body="&lt;p&gt;I have GSM modem that has MAX232 interface for RX/TX/GND on three pins.&#xA;Is it possible to interface Arduino in some way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tnx for help.&lt;/p&gt;&#xA;" OwnerDisplayName="user505160" LastEditorUserId="6452" LastEditDate="2015-03-19T18:38:38.247" LastActivityDate="2015-03-19T18:38:38.247" Title="GSM Modem with MAX232 to Arduino Serial?" Tags="|gsm|max232|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9440" PostTypeId="2" ParentId="9439" CreationDate="2015-03-18T11:58:21.427" Score="1" Body="&lt;p&gt;Yes, with another MAX232, or bypass the MAX232 somehow.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2015-03-18T11:58:21.427" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9441" PostTypeId="1" CreationDate="2015-03-18T12:40:30.663" Score="0" ViewCount="20058" Body="&lt;p&gt;I'm pretty clueless about electronics so everything has to be explained in simple terms to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino with a program which provides a value via the Analog output, so that is anything from 0-5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other side I have a PLC (programmable logic controller) with an IO card which allows to connect to a (4-20mA) current loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I convert from lets say 1-5V to the 4-20mA in a somewhat cheap and safe way (I don't want to destroy the PLC [and possibly the Arduino])?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course the Arduino and the PLC have separate power sources.&lt;/p&gt;&#xA;" OwnerUserId="7968" LastEditorUserId="2881" LastEditDate="2015-03-18T14:02:26.877" LastActivityDate="2017-11-20T22:39:10.763" Title="How to convert the 0-5V to a 4-20mA current loop?" Tags="|voltage-level|current|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9442" PostTypeId="1" AcceptedAnswerId="9443" CreationDate="2015-03-18T13:40:24.340" Score="2" ViewCount="1107" Body="&lt;p&gt;I'm designing a circuit that will use a 2.5v reference for the AREF. Should AVCC be powered from 5V or 2.5V?&lt;/p&gt;&#xA;" OwnerUserId="276" LastActivityDate="2015-03-18T14:05:57.753" Title="AVCC and AREF when using a reference voltage lower than 5V?" Tags="|analogread|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9443" PostTypeId="2" ParentId="9442" CreationDate="2015-03-18T14:05:57.753" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that PC6...4 use digital supply voltage, VCC.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it should be connected to 5V.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-18T14:05:57.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9444" PostTypeId="1" CreationDate="2015-03-18T07:28:54.720" Score="4" ViewCount="1685" Body="&lt;p&gt;I used the code below to save output from an Arduino Uno to a text file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is whenever I run the code the old data in the text file is deleted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want the old data to be deleted, what should I change?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial mySerial;&#xA;PrintWriter output;&#xA;void setup() {&#xA;   mySerial = new Serial( this, Serial.list()[0], 9600 );&#xA;   output = createWriter( &quot;data.txt&quot; );&#xA;}&#xA;void draw() {&#xA;    if (mySerial.available() &amp;gt; 0 ) {&#xA;         String value = mySerial.readString();&#xA;         if ( value != null ) {&#xA;              output.println( value );&#xA;         }&#xA;    }&#xA;}&#xA;&#xA;void keyPressed() {&#xA;    output.flush();  // Writes the remaining data to the file&#xA;    output.close();  // Finishes the file&#xA;    exit();  // Stops the program&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7995" OwnerDisplayName="Santosh Rokhade" LastEditorUserId="368" LastEditDate="2015-03-19T14:23:29.760" LastActivityDate="2021-05-26T16:04:48.857" Title="Saving Arduino output to a text file in append mode" Tags="|processing-lang|" AnswerCount="1" CommentCount="2" ClosedDate="2023-03-11T09:55:28.160" ContentLicense="CC BY-SA 3.0" />
  <row Id="9446" PostTypeId="1" CreationDate="2015-03-18T15:24:28.910" Score="3" ViewCount="642" Body="&lt;p&gt;What's an inexpensive ultrasonic range sensor that's reasonable waterproof or weatherproof that also interfaces easily with an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used &lt;a href=&quot;http://www.seeedstudio.com/wiki/Ultra_Sonic_range_measurement_module&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; kinds of ultrasonic range sensors, which are cheap and trivial to wire to an Arduino, but they're not very robust and are easily damaged since you can't cover them without that covering obstructing the soundwave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maxbotix sells a &quot;Weather-Resistant&quot; ultrasonic range sensor, but it's around $100, which is a little out of my price range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've researched those &quot;parking sensors&quot; used on cars, but I haven't seen anyone successfully interface them with an Arduino. It's also hard to tell how they're controlled. Some sites sell batches of the sensor for $3/each, but I don't think this includes the control electronics. Ebay listings that include what appears to be a bulky controller board seem to go for around $50-$100, which makes them a little pricey.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-03-18T19:29:15.740" Title="Cheap weatherproof ultrasonic range sensor?" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9447" PostTypeId="1" AcceptedAnswerId="9451" CreationDate="2015-03-18T16:25:28.040" Score="1" ViewCount="73" Body="&lt;p&gt;I just bought This IMU a while ago, and when I reached the point where I wanna connect it, I noticed that one of the capacitors have been removed by accedint, and since it took too long to check the product, I won't get to replace it or get any refund, so my question, how can I replace that SMD capacitor?&#xA;P.S. I have some Ultrasonic sensors might have the same SMD capacitors that I can take off and replace with if anyone can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/08bCC.jpg&quot; alt=&quot;The circled capacitor is the one&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7971" LastActivityDate="2015-03-19T20:15:12.587" Title="Razor 9DOF SMD Capacitor replacing" Tags="|sensors|electronics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9448" PostTypeId="2" ParentId="9447" CreationDate="2015-03-18T17:39:43.723" Score="0" Body="&lt;p&gt;You are on a tough road. I hope someone can give you specifics.  Normally you would able to identify the capacitor from its parts designation, but that board does not have any. So you will have to match the schematic (assuming spark fun provides one) to the board layout to figure out what it is.  The cost of the part is probably over a penny, maybe even 2 cents. In other words, not an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will require hot air to desolder one from another board and to solder this one on. Someone might be able to do it with a fine tip solder  pencil, but not likely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom line; find someone who has experience repairing boards, or order another one. Amazon has breakout boards for the 6050 for $6. But I see this one has Serial, and a magnetometer, so it is not quite the same. But depending on what you plan to do with it, it could work.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-03-18T17:39:43.723" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9450" PostTypeId="2" ParentId="9446" CreationDate="2015-03-18T19:29:15.740" Score="1" Body="&lt;p&gt;Those modules are just the ultrasonic transducers. You can see the two pin connector. You can probably get those cheap boards, de-solder the two transducers, and connect the wires from two of the water-proof ones.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-18T19:29:15.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9451" PostTypeId="2" ParentId="9447" CreationDate="2015-03-18T19:42:34.043" Score="0" Body="&lt;p&gt;You are looking for C22,  0.1uF capacitor, connected to smooth the 3.3v from the regulator. If you are not using the battery connector, you can probably just leave it out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could just get a capacitor with leads and connect it somewhere between 3.3v and ground. You can use the ISP header (2x3 holes on the right) for this. I think it's the top-right and bottom-right pin.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-18T19:42:34.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9453" PostTypeId="1" AcceptedAnswerId="9455" CreationDate="2015-03-19T02:30:21.827" Score="2" ViewCount="1778" Body="&lt;p&gt;I've salvaged a 4 Ohm, 1.5 Watt speaker from an old computer, and I was wondering how I'd go about getting it to work with my Arduino. I've heard of various amplifier circuits such as opamps, but I do not know which would be the best for my situation. I've also heard that using the speaker in certain ways (such as directly connected to a pin from the Arduino) could damage both the speaker and the output pin, so that is definitely something I'd like to avoid. I'm not looking for anything complicated; I'm just trying to get a feel for the general circuitry, programming, and speaker volume. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2015-03-19T08:48:54.733" Title="Using A 4 Ohm Speaker With Arduino" Tags="|programming|c++|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9454" PostTypeId="2" ParentId="9441" CreationDate="2015-03-19T02:58:40.467" Score="1" Body="&lt;p&gt;If all you need is analog 4-20mA loop transmitter, then you need an op-amp, the transistors that its output drives, a sense resistor, and a few other resistors. Note that these are at least 1% resistors. &lt;strong&gt;This needs to be built on a printed circuit board, not a solderless breadboard.&lt;/strong&gt;  Two of my coworkers at Maxim Integrated wrote an applications note about a 4-20mA current-loop transmitter: &lt;a href=&quot;http://www.maximintegrated.com/en/app-notes/index.mvp/id/5610&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.maximintegrated.com/en/app-notes/index.mvp/id/5610&lt;/a&gt;  see this figure:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xiTwx.png&quot; alt=&quot;4-20mA circuit from Maxim Integrated app note 5610&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are already using a PWM (hopefully with an RC low-pass filter), you just need everything after the DAC output. (&lt;em&gt;Performance will not be as good with an Arduino PWM as it would be with a 16-bit voltage-output DAC, but the general idea would still work.&lt;/em&gt;) For your purpose, you can also ignore all of the stuff about the HART modem -- that's an extra feature for sending digital information along the same loop. Only relevant if your PLC receiver was expecting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also numerous prebuilt 4-20mA transmitter boards available, this has been around many decades in the industrial control market. Since Maxim Integrated makes precision DAC chips, we don't make reference designs that take 0-5V (especially from a PWM!) and convert to 4-20mA -- but we do sell reference design boards that include the DAC. Such as our Monterey system board (MAXREFDES15#). &lt;a href=&quot;http://www.maximintegrated.com/en/app-notes/index.mvp/id/5683&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.maximintegrated.com/en/app-notes/index.mvp/id/5683&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also a &lt;code&gt;4-20mA Current-Loop Transmitter&lt;/code&gt; from ti.com, XTR117: &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/xtr117.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ti.com/lit/ds/symlink/xtr117.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also a board from mikroElektronika, MIKROE-1296 (available through mouser.com) that uses an Analog Devices DAC (through SPI interface) to drive the 4-20mA transmit circuit. Again, this is an idea that's been around many decades, so a search for &lt;code&gt;4-20mA transmitter&lt;/code&gt; should yield lots of useful information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your best bet is probably to purchase one of these prebuilt 4-20mA transmitter boards, which most likely will include its own precision DAC. You'll have to modify your Arduino code to drive the SPI interface, specific to whichever DAC you end up using. Or, if you really want to use the PWM to drive 4-20mA (at reduced performance), be sure to at least use an RC low-pass filter to get it as close as possible to a stable DC level.&lt;/p&gt;&#xA;" OwnerUserId="7174" LastActivityDate="2015-03-19T02:58:40.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9455" PostTypeId="2" ParentId="9453" CreationDate="2015-03-19T08:48:54.733" Score="0" Body="&lt;p&gt;5v, 4ohm, &gt;1amp from a pin rated for 0.04amps; this isn't safe!&lt;br&gt;&#xA;You would need a driver, but it would suffice to add a small transistor &amp;amp; a couple of resistors to drive it; &lt;a href=&quot;http://hackaweek.com/hacks/?p=327&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; is a slightly more complex layout, there are many examples on the web.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-03-19T08:48:54.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9457" PostTypeId="1" AcceptedAnswerId="9463" CreationDate="2015-03-19T10:26:12.730" Score="1" ViewCount="295" Body="&lt;p&gt;First of all, let me begin by saying that I'm still pretty much a rookie. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a project with a dht21, an LDR and an ultrasonic distance sensor. I have 3 different arduino uno boards, namely: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A (supposedly) original arduino uno r3.&lt;/li&gt;&#xA;&lt;li&gt;A chinese nhduino, arduino uno r3 clone.&lt;/li&gt;&#xA;&lt;li&gt;And &lt;a href=&quot;http://www.banana-pi.net/index.php/en/product/banana-pi/modules/banana-pi-bpiduino-uno-module-detail&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; one, sitting on top of &lt;a href=&quot;http://www.bananapi.org/p/product.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've been playing around with the three boards for the last couple of months, testing a variety of sensors and having the same results with the three boards, as expected. But then, with the aforementioned setup, I'm getting very different readings on the DHT21 sensor. If I use the &quot;regular&quot; (first two) arduinos plugged in my laptop, the readings are consistent. But if I use the banana pi(duino), I get the temperature reading correct, but getting weird humidity readings... pretty most of the time a 5% humidity value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything tested on the same room, same sensors and same protoboard. No external power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm totally clueless here, any ideas of what could be the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7670" LastActivityDate="2015-03-19T16:20:37.787" Title="Different dht21 readings on different arduinos" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9460" PostTypeId="2" ParentId="9436" CreationDate="2015-03-19T13:42:35.470" Score="0" Body="&lt;p&gt;Here is an edited version of your code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Integrate a signal read on analog input 0.&#xA; * Print the result every 2 seconds on the serial port.&#xA; */&#xA;&#xA;const int input_pin = A0;&#xA;unsigned long last_time_sampled = 0;&#xA;unsigned long last_time_printed = 0;&#xA;&#xA;// The integral is in units of DN*us, 1 DN being the ADC step.&#xA;float integral = 0;&#xA;&#xA;// Convert from DN*us to V*s, assuming a 5 V reference.&#xA;const float conversion = 5.0 / 1024 * 1e-6;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int sample = analogRead(input_pin);&#xA;    unsigned long now = micros();&#xA;&#xA;    // Approximate the signal as a constant equal to the current sample&#xA;    // from the time of the previous sample until now.&#xA;    integral += sample * (now - last_time_sampled);&#xA;    last_time_sampled = now;&#xA;&#xA;    // Print the results every 2 seconds.&#xA;    if (now - last_time_printed &amp;gt;= 2000000) {&#xA;        Serial.print(&quot;input = &quot;);&#xA;        Serial.print(sample);&#xA;        Serial.print(&quot;, output = &quot;);&#xA;        Serial.println(integral * conversion);&#xA;        last_time_printed = now;&#xA;    }&#xA;&#xA;    // Limit the sampling rate to no more than 1000/s.&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main changes I did are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I renamed the variables to give them more meaningful names. This&#xA;single change makes the code a lot more readable.&lt;/li&gt;&#xA;&lt;li&gt;I removed those comments made redundant by the better variable names.&lt;/li&gt;&#xA;&lt;li&gt;I removed &lt;code&gt;analogWrite()&lt;/code&gt;, since I couldn't make any sense out of it.&lt;/li&gt;&#xA;&lt;li&gt;I compute the time between samples as time differences. Unless you&#xA;take your samples on some kind of timer interrupt, the delay between&#xA;samples will never be 1&amp;nbsp;ms.&lt;/li&gt;&#xA;&lt;li&gt;I stored the integral as a float to avoid overflows.&lt;/li&gt;&#xA;&lt;li&gt;I removed the summation variable, as it was redundant with the&#xA;integration variable. Instead, there is a conversion factor for&#xA;converting the integral from its “natural” unit (DN⋅µs) into a more&#xA;human-friendly unit (V⋅s).&lt;/li&gt;&#xA;&lt;li&gt;I print the results only every 2 seconds, as nobody will read&#xA;something printed every millisecond.&lt;/li&gt;&#xA;&lt;li&gt;I added some comments, most importantly for making explicit the&#xA;approximation used in computing the integral.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There is still one caveat with this code: once the integral is roughly&#xA;10&lt;sup&gt;7&lt;/sup&gt; times larger than the samples, which should happen after&#xA;only a few hours, the integral is not incremented any more, due to loss&#xA;of precision.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-03-19T13:42:35.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9461" PostTypeId="1" CreationDate="2015-03-19T14:51:20.567" Score="2" ViewCount="1210" Body="&lt;p&gt;The manual of olimex ekg/emg shield provides a link for ShieldEkgEmgDemo code, it can show ecg in realtime in a software ElecGuru. The link to software is also provided in the manual. I need to get the numerical value of heart rate in bpm as well as the ecg. I want to implement this in a larger program where I can use something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(heartRate &amp;gt; 90){&#xA;        //do something&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino UNO board and an Olimex ekg/emg shield with electrodes. I tested the shield with demo code and it worked fine. I got a clean ECG on ElecGuru.&lt;/p&gt;&#xA;" OwnerUserId="7989" LastActivityDate="2017-04-23T15:42:11.523" Title="Arduino Program for Olimex ekg/emg shield to detect heart rate in bpm as well as show ECG in ElecGuru software" Tags="|arduino-uno|shields|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9463" PostTypeId="2" ParentId="9457" CreationDate="2015-03-19T16:20:37.787" Score="0" Body="&lt;p&gt;Problem solved. Using a ywrobot breadboard PSU and now it works. I haven't tested current in the circuit but looks like it was just too low. I wish I'd had datasheet for the board to look at. In a language different from chinese would have been ok, I guess.&lt;/p&gt;&#xA;" OwnerUserId="7670" LastActivityDate="2015-03-19T16:20:37.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9464" PostTypeId="1" AcceptedAnswerId="9495" CreationDate="2015-03-19T16:45:14.327" Score="8" ViewCount="6972" Body="&lt;p&gt;I've already searched a lot and didn't found the answer. Also, I don't have an o'scope. Anyone can help me?&lt;/p&gt;&#xA;" OwnerUserId="7445" LastActivityDate="2022-12-04T00:24:26.977" Title="What is the rise time of an output pin of atmega328 changing its state?" Tags="|arduino-uno|atmega328|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9465" PostTypeId="1" AcceptedAnswerId="9482" CreationDate="2015-03-19T17:36:23.283" Score="0" ViewCount="878" Body="&lt;p&gt;I've been trying to use interrupts to control a quadrotor with a tx/rx to no success. I'm using an arduino mega as my control board. I have successfully read a singe channel using attach interrupt and PulseIn. I have also successfully read multiple channels with pulse but failed to do so with attach interrupt and pinchange int. Should I just go ahead and use PulseIn&lt;/p&gt;&#xA;" OwnerUserId="6768" LastEditorUserId="6768" LastEditDate="2015-03-20T20:50:08.573" LastActivityDate="2015-03-21T01:12:56.553" Title="Is PulseIn fast enough for Quadcopter?" Tags="|arduino-mega|interrupt|pulsein|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9467" PostTypeId="1" AcceptedAnswerId="9473" CreationDate="2015-03-19T18:56:41.700" Score="2" ViewCount="1648" Body="&lt;p&gt;When I flash this simple code (using &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;Arduino-Makefile&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void init_io(void) {&#xA;&#xA;    // open serial port&#xA;    Serial.begin(9600);&#xA;    while (!Serial);&#xA;    Serial.println(&quot;Comm-link online&quot;);&#xA;&#xA;}//END: init_io&#xA;&#xA;int main(void) {&#xA;&#xA;    init_io();&#xA;&#xA;    while (1) {&#xA;&#xA;        // send data only when you receive data:&#xA;        if (Serial.available() &amp;gt; 0) {&#xA;&#xA;            // read the incoming byte:&#xA;            int incomingByte = Serial.read();&#xA;&#xA;            // say what you got:&#xA;            Serial.print(&quot;I received: &quot;);&#xA;            Serial.println(incomingByte, DEC);&#xA;&#xA;        } else {&#xA;&#xA;            //  Serial.println(&quot;No serial &quot;);&#xA;&#xA;        }&#xA;&#xA;    }//END: loop&#xA;&#xA;    return 0;&#xA;}//END: main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only see first two chars printed in the serial output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;~$&gt; Co&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The input also does not work as intended - tested on two independent microcontrolers, Mega and Uno. I'm not sure what's the cause of this behaviour. Here's the Makefile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BOARD_TAG    = uno # megaADK uno&#xA;MONITOR_PORT  = /dev/ttyACM0&#xA;ARDUINO_LIBS = &#xA;&#xA;include $(ARDMK_DIR)/Arduino.mk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's definitely not a hardware problem, I've used serial i/o before in other projects.&lt;/p&gt;&#xA;" OwnerUserId="7986" LastActivityDate="2015-03-19T21:24:27.723" Title="Serial communication and Arduino program in C" Tags="|serial|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9468" PostTypeId="1" CreationDate="2015-03-19T19:06:39.273" Score="0" ViewCount="2064" Body="&lt;p&gt;As I understand it, the Arduino comes with a TFT library which uses SPI to drive LCD TFTs. I recently bought a TFT labelled &quot;HY-32.TFT&quot; on the front and &quot;HY-TFT320_262k heyaodz111211&quot; on the back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses an XPT2046 touch screen controller, but I'm more interested in just getting something on the screen currently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the Arduino library, I need to connect pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SCLK&lt;/li&gt;&#xA;&lt;li&gt;MOSI&lt;/li&gt;&#xA;&lt;li&gt;CS&lt;/li&gt;&#xA;&lt;li&gt;DC&lt;/li&gt;&#xA;&lt;li&gt;RESET&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I can't see these apart from some similarly named ones associated with TP (touchpad?) and SD (sd card), as the photo shows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XsNFr.jpg&quot; alt=&quot;back&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/U4geV.jpg&quot; alt=&quot;front&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to drive this with my Arduino? If so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: It looks like the datasheet for the controller and the board can be downloaded from &lt;a href=&quot;http://www.icstation.com/module-display-touch-panel-adapter-p-2292.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;3.0&quot; 3&quot; TFT LCD Module Display + Touch Panel + PCB adapter&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="7992" OwnerDisplayName="Ell" LastEditorUserId="6936" LastEditDate="2015-03-21T17:08:07.950" LastActivityDate="2015-12-22T18:34:36.757" Title="How can I drive this LCD TFT with an Arduino?" Tags="|spi|lcd|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9469" PostTypeId="1" AcceptedAnswerId="9480" CreationDate="2015-03-19T19:45:31.347" Score="1" ViewCount="819" Body="&lt;p&gt;Lately I've been fooling around with a project for my Microsoft Sidewinder Force Feedback Pro Joystick. I've found out that there is a project currently for it &lt;a href=&quot;https://code.google.com/p/adapt-ffb-joy/&quot; rel=&quot;nofollow&quot;&gt;built for the Teensy 2.0&lt;/a&gt;. On the page for the Teensy 2.0 there is a link for an &lt;a href=&quot;https://code.google.com/p/sidewinder-arduino/&quot; rel=&quot;nofollow&quot;&gt;Arduino Library&lt;/a&gt; for the very same project that was (I guess) converted. There isn't much documentation for it, and I don't think there is much progress being made on it anymore. However when I grab the files and try to upload it to my Arduino Uno it spits out an Unsupported device. Doing some digging around I found where it shows what devices are supported in the includes.h.. Which happen to be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__)&#xA; #define __AVR_AT90USBX2__&#xA;#elif defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)&#xA; #define __AVR_ATmegaXU4__&#xA;#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)&#xA; #define __AVR_AT90USBX6__&#xA;#else&#xA; #error &quot;Unsupported device&quot;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which ends up being the red arduino, arduino micro, arduino leonardo, and I think a few teensys. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is if you can upload this code onto a UNO. I'm not really wanting to purchase a teensy just to check if this will work or not.&lt;/p&gt;&#xA;" OwnerUserId="7990" LastEditorUserId="213" LastEditDate="2015-03-20T14:48:02.910" LastActivityDate="2015-03-21T09:16:51.827" Title="How big of a difference is there between an Arduino Uno and the rest?" Tags="|arduino-uno|programming|arduino-leonardo|arduino-micro|teensy|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9470" PostTypeId="2" ParentId="9469" CreationDate="2015-03-19T19:59:11.220" Score="0" Body="&lt;p&gt;Generally, the differences between the different chips are mostly: amount of memory (sram, eeprom), number of pins (analog, digital, pwm), numbering of pins, and hardware support for protocols (serial, SPI, 2 wire etc)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you would have to go through the code wherever you find &lt;code&gt;#IFDEF __AVR_AT90USBX2__&lt;/code&gt; or &lt;code&gt;#IFNDEF __AVR_AT90USBX2__&lt;/code&gt; and the others - you would need to work out what it is doing differently for each, and work out how you would do the same thing on the Arduino Uno (which runs on an Atmega328).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-19T19:59:11.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9471" PostTypeId="2" ParentId="9447" CreationDate="2015-03-19T20:15:12.587" Score="0" Body="&lt;p&gt;Try using two soldering pencils, one in each hand. makes it easy to remove the capacitor from the donor board.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-03-19T20:15:12.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9472" PostTypeId="2" ParentId="9469" CreationDate="2015-03-19T20:17:01.257" Score="1" Body="&lt;p&gt;That program will make the arduino board act like a keyboard to the PC it's plugged in. This can't be done on the Uno, since it doesn't have USB support. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-19T20:17:01.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9473" PostTypeId="2" ParentId="9467" CreationDate="2015-03-19T20:36:39.117" Score="2" Body="&lt;p&gt;When using the Arduino core library, you normally do not write a&#xA;&lt;code&gt;main()&lt;/code&gt; function. Instead, you write &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; and rely on&#xA;libcore's provided &lt;code&gt;main()&lt;/code&gt; for calling them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you nevertheless want to provide your own &lt;code&gt;main()&lt;/code&gt;, then you should&#xA;call &lt;code&gt;init();&lt;/code&gt; (with no arguments) before you try to use the library.&#xA;Adding this single call makes your program work on my Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since it does not seem to be officially documented, this trick&#xA;may not be safe against upgrades in the core library. Writing &lt;code&gt;setup()&lt;/code&gt;&#xA;and &lt;code&gt;loop()&lt;/code&gt; should be more future-proof.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-19T21:24:27.723" LastActivityDate="2015-03-19T21:24:27.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9476" PostTypeId="1" CreationDate="2015-03-20T03:42:05.640" Score="4" ViewCount="981" Body="&lt;p&gt;Specifically, I want to know if the KY-022 module and KY-005 module can be used for heart beat detecting according to this &lt;a href=&quot;http://medicarduino.net/?page_id=204&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;KY-005:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7R0Ej.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7R0Ej.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;KY-022:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LKYUQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LKYUQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, can you please explain to me how can I achieve such thing with respect to the following:&lt;br&gt;&#xA;1- Is there any kind of synchronization between transmitter/receiver?&lt;br&gt;&#xA;2- How to get a stable analog value from the receiver?&lt;br&gt;&#xA;3- The Correlation between Heart beat rate and the obtained values?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;providing circuit sketch will be very helpful but not necessary.&lt;br&gt;&#xA;Thanks in advance. &lt;/p&gt;&#xA;" OwnerUserId="7941" LastEditorUserId="27157" LastEditDate="2016-10-10T00:46:21.620" LastActivityDate="2016-11-09T01:58:53.170" Title="Can I use IR Transmitter/Receiver for heart beat detecting?" Tags="|arduino-uno|sensors|ir|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9479" PostTypeId="1" AcceptedAnswerId="9551" CreationDate="2015-03-20T22:17:38.640" Score="0" ViewCount="3823" Body="&lt;p&gt;I use a simple serial connection to tell the Due what to output into an analog output pin. However, the outputs are offset about 550mV (as seen on an oscilloscope) and the maximum value of 255 gives ~2.7V. What am I missing? Why can't the DAC output 0V - 3.3V mapped onto 0 - 255 values?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int output = DAC1; // analog output pin&#xA;String inData;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    char value = Serial.read();&#xA;    inData += value;&#xA;    if(value == '\n'){&#xA;      val = inData.toInt(); // 0..255&#xA;      analogWrite(output, val);&#xA;      Serial.println(val);&#xA;      inData = &quot;&quot;;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7615" LastEditorUserId="6936" LastEditDate="2015-03-21T02:30:08.580" LastActivityDate="2020-08-11T21:20:19.287" Title="Arduino Due analog output has 500mV offset" Tags="|arduino-due|analogwrite|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9480" PostTypeId="2" ParentId="9469" CreationDate="2015-03-20T23:34:06.167" Score="1" Body="&lt;p&gt;The code won't work as a traditional project when uploaded on an Uno, because the Uno does not talk directly to the Host, it only speaks UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But good news is that the Uno uses another atmega chip, an Atmega8u2 on the older models or Atmega16u2 on the others. That IC handles directly the USB connection with the host on behalf of the Atmega328. And that code below is actually (close enough) support for that IC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#elif defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)&#xA; #define __AVR_ATmegaXU4__&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means you should be able to upload the code (or a similar one) on that 'frontend' IC, so it acts as a HID device, and connects to the main 328 for any I/O you might need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do the upload on that other chip, you can use an ISP programmer on the 6pins header close to USB, or you can use the DFU programmation mode over USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry for not giving external references or code, but I'm answering from my phone!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: after a short browse over the code, it's definitely &lt;em&gt;possible&lt;/em&gt; to implement that using an uno, but you'll need to split the code between the two chips: the USB interface to behave like ah HID device and the main I/O chip to talk midi, and implement comms between both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit #2: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a few resources that might help to work out USB and Midi using Arduino, but it looks like none is a cooked in USB on atmegaXu2 to Midi on atmega328:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://unojoy.tumblr.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://unojoy.tumblr.com/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,111.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php/topic,111.0.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hunt.net.nz/users/darran/weblog/15f92/Arduino_UNO_Big_Joystick_HID_firmware.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hunt.net.nz/users/darran/weblog/15f92/Arduino_UNO_Big_Joystick_HID_firmware.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/16710701/joystick-usb-definition-for-use-with-arduino&quot;&gt;https://stackoverflow.com/questions/16710701/joystick-usb-definition-for-use-with-arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hackaday.com/2011/03/28/hiduino-the-only-limit-is-yourself/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hackaday.com/2011/03/28/hiduino-the-only-limit-is-yourself/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Hacking/DFUProgramming8U2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/tutorial/midi&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/tutorial/midi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://sites.google.com/site/bharatbhushankonka/home/diy-midi-over-usb-using-arduino-uno&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://sites.google.com/site/bharatbhushankonka/home/diy-midi-over-usb-using-arduino-uno&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Turn-your-Arduino-Uno-into-an-USB-HID-Mididevice/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Turn-your-Arduino-Uno-into-an-USB-HID-Mididevice/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And if you're not at ease with AVR development, it's gonna be &lt;strong&gt;HARD&lt;/strong&gt;. You'd better get a teensy2 or a leonardo where that code should compile and work with little effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-21T09:16:51.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9481" PostTypeId="1" AcceptedAnswerId="14053" CreationDate="2015-03-21T00:09:16.153" Score="2" ViewCount="9144" Body="&lt;h3&gt;Background&lt;/h3&gt;&#xA;&lt;p&gt;I'm trying to write code to read signals from a six-channel RC receiver on an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mega 2560&lt;/a&gt;. Currently I am keeping the code to just read one channel to make things easy to troubleshoot. The problem is my shared variable is not updating, leading me to believe that my interrupt service routine is not detecting any rising edges.&lt;/p&gt;&#xA;&lt;p&gt;I thought my receiver was broken, so I tested it using &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow noreferrer&quot;&gt;the standard Arduino attach interrupt function&lt;/a&gt;. It worked perfectly, so my receiver is fine.&lt;/p&gt;&#xA;&lt;p&gt;I used &lt;a href=&quot;https://www.arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial.print()&lt;/a&gt; to see if my volatile channel variable was updating (that is, change its value to the channel 1 flag value). It was not updating, so my &lt;a href=&quot;https://en.wikipedia.org/wiki/Interrupt_handler&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISR&lt;/a&gt; must be wrong. You can find the original code in the blog post.&lt;/p&gt;&#xA;&lt;p&gt;What's wrong? I'm out of ideas.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PinChangeInt.h&amp;gt;&#xA;&#xA;//Pin assignment&#xA;#define channel1PIN 10&#xA;&#xA;//Bit flags&#xA;#define Channel1FLAG 1&#xA;&#xA;//Flag holder&#xA;volatile uint8_t bFLAGUPDATESHARED;&#xA;&#xA;//Shared variables: Accessed by the interrupt service routine and read in 'void loop'.&#xA;volatile uint16_t unCHANNEL1SHARED;&#xA;&#xA;//Start time variables: These are used to set the start time of the rising edge of&#xA;//a pulse. They are only accessed by the ISR, and thus they are unsigned integers and&#xA;//not volatiles.&#xA;&#xA;uint32_t ulCHANNEL1START;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.print(&amp;quot;RC Channel PWM Read Interrupt Test&amp;quot;);&#xA;&#xA;  //PinChangInt library function. Used to set attach interrupts.&#xA;  PCintPort::attachInterrupt(channel1PIN, calcCHANNEL1, CHANGE);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //In-loop variables to hold local copies of channel inputs.&#xA;  //This is static so it retains values between call loops.&#xA;  static uint16_t unCHANNEL1IN;&#xA;&#xA;  //The in-loop copy of the bSHAREDFLAGUPDATE volatile flag holder&#xA;  static uint8_t bFLAGUPDATELOCAL;&#xA;&#xA;  //Check to see if any channels have received signals. If so, copy&#xA;  //shared variables to local in loop variables.&#xA;  if (bFLAGUPDATESHARED)&#xA;  {&#xA;    //Switch off interrupts when I copy shared variables to local variables&#xA;    noInterrupts();&#xA;&#xA;    bFLAGUPDATELOCAL = bFLAGUPDATESHARED;&#xA;&#xA;    if (bFLAGUPDATELOCAL &amp;amp; Channel1FLAG)&#xA;    {&#xA;      unCHANNEL1IN = unCHANNEL1SHARED;&#xA;    }&#xA;&#xA;    bFLAGUPDATESHARED = 0;&#xA;    interrupts();&#xA;  }&#xA;&#xA;  Serial.println(unCHANNEL1IN);&#xA;&#xA;  //Clear local update flags copy as all values have been copied to local variables&#xA;  bFLAGUPDATELOCAL = 0;&#xA;}&#xA;&#xA;void calcCHANNEL1()&#xA;{&#xA;  if (digitalRead(channel1PIN) == HIGH)&#xA;  {&#xA;    //If pin goes high, start timer and set ulCHANNEL1START to timer start&#xA;    ulCHANNEL1START = micros();&#xA;  }&#xA;  else&#xA;  {&#xA;    //If it is not rising, it must be falling so set shared&#xA;    //variable to current time-start time&#xA;    unCHANNEL1SHARED = (uint16_t)(micros() - ulCHANNEL1START);&#xA;&#xA;    //Tell that channel 1 has received a signal&#xA;    bFLAGUPDATESHARED |= Channel1FLAG;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6768" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-06-18T12:55:30.170" Title="Why is my interrupt code not working?" Tags="|arduino-mega|pins|pwm|interrupt|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="9482" PostTypeId="2" ParentId="9465" CreationDate="2015-03-21T01:12:56.553" Score="1" Body="&lt;p&gt;You should avoid pulseIn for a quadcopter, the main reason being that pulseIn takes too long to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pulseIn waits for a pulse to start, then waits until that pulse finishes, and then returns how long it took to finish. Standard RC signals pulse at 50-60Hz, with the &quot;high&quot; part of the signals being between 1 and 2 milliseconds. 60Hz is one pulse per 16 milliseconds or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What that amounts to is pulseIn taking at most 18 milliseconds, but never less that 1 millisecond to execute per channel. lets say you want to measure 4 channels (throttle, pitch, yaw, roll); the average time would be around 40 milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general 40 milliseconds isn't so long, but your quad will need to read the accelerometer and gyroscope and stabilize itself more often then that in the air. A loop that takes 40 ms is running at 25Hz, but the stabilize loop in all the quadcopter implementations I'm familiar with is run at 100Hz or higher (thats areoquad, multiWii, and ardupilot).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use interrupts to read the values, because interrupts are non blocking, and give higher quality readings. Some specialized quadcopter boards have other processors read the actual RC signals and send the result back to the main processor to cut down on the number of interrupts they have to use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;FYI, The standard servo output library sends new signals at 50Hz. Those open source quadcopters use their own implementations that run at higher output frequencies, since brushless ESCs support that. There is a pull request with code to add support for different refresh intervals to the arduino servo library &lt;a href=&quot;https://github.com/arduino/Arduino/pull/2446&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; that I have tested; You could try appling it as a patch to your installation if the output rate gives you trouble down the road.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-21T01:12:56.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9483" PostTypeId="1" AcceptedAnswerId="9539" CreationDate="2015-03-21T02:54:14.663" Score="4" ViewCount="61036" Body="&lt;p&gt;I have a problem. I bought a SIM900 board, but I can not connect there with the Arduino. To send AT commands on the serial the SIM900 doesn't respond, but the LED indicating that the network is on. I've tried to change the baud rate of 9600 to 19200 in the firmware of the Arduino, but it still fails. I think I'm having a problem with the connections of the SIM900, since this board strikes me as obscure (could not find the schematic on the Internet)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board I have is identical to this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/IwIem.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm 90% sure that I am connecting to the wrong pins. But I tried to reverse the jumpers and even some soldered pins on UART.&lt;/p&gt;&#xA;" OwnerUserId="595" OwnerDisplayName="Avelino" LastEditorUserId="6936" LastEditDate="2015-03-21T18:44:49.533" LastActivityDate="2017-04-26T20:13:05.300" Title="How to communicate the Arduino board with SIM900?" Tags="|gsm|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9484" PostTypeId="1" CreationDate="2015-03-21T03:38:27.647" Score="1" ViewCount="1973" Body="&lt;p&gt;How do you convert an unsigned long to a &lt;code&gt;uint8_t&lt;/code&gt; array? I am interested in sending an unsigned long integer from an ATTiny85 to an Arduino Uno via I2C. The issue is with &lt;code&gt;TinyWireS.Send()&lt;/code&gt; which can only send a var of type &lt;code&gt;uint8_t&lt;/code&gt;. I believe the solution would be to use &lt;code&gt;TinyWireS.Send()&lt;/code&gt; in an array?&lt;/p&gt;&#xA;" OwnerUserId="7250" LastEditorUserId="6936" LastEditDate="2015-03-21T18:17:41.500" LastActivityDate="2015-07-08T15:16:58.290" Title="I2C TinyWireS SEND: How to convert unsigned long to uint8_t array?" Tags="|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9487" PostTypeId="2" ParentId="9484" CreationDate="2015-03-21T07:44:23.290" Score="1" Body="&lt;p&gt;This might not be politically correct code, but it is pretty simple to just cast a pointer to uint8_t like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long data = 5;&#xA;uint8_t *rx = (uint8_t*) &amp;amp;data;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can still use array subscripts even though its a pointer, and you can pass it to a function like an array. Just don't go past &lt;code&gt;rx[3]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, you could also make a union like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union{ long data; uint8_t bytes[4]; } convert;&#xA;convert.data = 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then use &lt;code&gt;convert.bytes&lt;/code&gt; as your array to send.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-03-21T18:44:56.400" LastActivityDate="2015-03-21T18:44:56.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9488" PostTypeId="2" ParentId="9464" CreationDate="2015-03-21T08:21:18.373" Score="4" Body="&lt;p&gt;Last time I measured on a circuit (it was an i2c network master and with a 2560), it was about 0.3us, so that gives you a high value for that. Also, I believe it cannot be faster than one/half of a CPU cycle which takes: 1/(16E6)=62.5ns/2 = 31.25ns, so here's the lower boundary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And there you got a possible range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the rise time will definitely depend on the configuration of the circuit. It might be less or more depending on pull ups, capacitance attached at the pin out exit. It might also depend on the configuration of the pin (PWM? Internal Pull-up?…)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I believe there should some nominal values given in the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Useful knowledge from the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;, but there's no definitive answer for &lt;em&gt;any&lt;/em&gt; pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P311: &lt;strong&gt;29.4.3 External Clock Drive&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| Symbol | Parameter | Min | Max   | Min | Max   | Min | Max   |&#xA;| ------ | --------- | --- | ----- | --- | ---   | --- | ----- |&#xA;| tCLCH  | Rise Time |     | 2.0µs |     | 1.6µs |     | 0.5µs |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P313: &lt;strong&gt;29.6 SPI Timing Characteristics&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| Description    | Mode      | Min | Typ   | Max    |&#xA;| -------------- | --------- | --- | ----- | ------ |&#xA;| Rise/Fall time | Master    |     | 3.6ns |        |&#xA;| Rise/Fall time | Slave     |     |       | 1600ns |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P315: &lt;strong&gt;29.7 Two-wire Serial Interface Characteristics&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;| Symbol | Parameter                      | Condition | Min        | Max   |&#xA;| ------ | ------------------------------ | --------- | ---------- | ----- |&#xA;| tr     | Rise Time for both SDA and SCL |           | 20 + 0.1Cb | 300ns |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" LastEditorUserId="13432" LastEditDate="2018-05-18T14:44:08.290" LastActivityDate="2018-05-18T14:44:08.290" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="9489" PostTypeId="1" AcceptedAnswerId="9493" CreationDate="2015-03-21T09:10:53.343" Score="1" ViewCount="5377" Body="&lt;p&gt;I have a problem with the Arduino Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to use a 4x3 keypad and 16x2 LCD together with an Arduino Uno. As 4x3 keypad requires 7 pins, I have defined pins 2, 3, 4, 5, 6, 7 and 8 to it. A 16x2 LCD requires 6 pins but only 5 pins remain (9, 10, 11, 12 and 13). Pins 0 and 1 are used for serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest a probable solution.&lt;/p&gt;&#xA;" OwnerUserId="8002" LastEditorUserId="6936" LastEditDate="2015-03-22T00:54:52.793" LastActivityDate="2016-06-29T12:58:10.003" Title="Arduino Uno - combined LCD and keypad interfacing problem" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9490" PostTypeId="1" AcceptedAnswerId="9497" CreationDate="2015-03-21T11:27:16.910" Score="3" ViewCount="4140" Body="&lt;p&gt;What I'm trying to do is pretty basic: I have a global variable and I'm trying to store some value in it (specifically, the SP_H and SP_L values).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The variable is an array of structs and I'm trying to access one of those structs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I am doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct_t { uint8_t sp_h, sp_l; } struct_t;    &#xA;&#xA;struct_t arr[MAX_STRUCTS];&#xA;&#xA;void some_inline_assembly_function()&#xA;{&#xA;  volatile asm(&#xA;&#xA;  // Determine where to store the new SP_H and SP_L register&#xA;&#xA;  &quot;lds r26, ???                \n\t&quot; // &amp;lt;-- How do I store the address&#xA;                                            of arr[0].sp_h or arr[0].sp_l&#xA;                                            in the X registers (r26,27)&#xA;  &quot;lds r27, ???                \n\t&quot;&#xA;&#xA;  // This part stores the stack pointer low and high byte indirectly&#xA;     using the X registers (r26,27), which is what I want.&#xA;&#xA;  &quot;in    r0, __SP_L__          \n\t&quot; &#xA;  &quot;st    x+, r0                \n\t&quot; &#xA;  &quot;in    r0, __SP_H__          \n\t&quot;&#xA;  &quot;st    x+, r0                \n\t&quot;&#xA;  ::);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this looks familiar, it is because it probably is. I'm trying to implement simple context switching (pushing the entire task context into the stack and retrieving another one). What I'm trying to accomplish is storing the current PC_H and PC_L to a global variable so that the &quot;shceduler&quot; knows where to start popping the registers and restore the context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I know FreeRTOS does this. I need to know how to do this myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a bunch.&lt;/p&gt;&#xA;" OwnerUserId="8006" LastActivityDate="2015-03-22T19:04:43.313" Title="Storing in a global variable using inline assembly" Tags="|avr|assembly|avr-toolchain|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9492" PostTypeId="1" CreationDate="2015-03-21T13:46:57.713" Score="2" ViewCount="350" Body="&lt;p&gt;Ok, utthpd is running on port 80 and lighttpd on port 81...both give access to the luci control panel...all well and good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the /data access to the yun data store only works from uhttpd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lighttpd returns error 404 (page not found).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what the solution might be..?&lt;/p&gt;&#xA;" OwnerUserId="8005" LastActivityDate="2015-03-21T13:46:57.713" Title="Yun - replaced uhttpd with lighttpd - luci works but not /data access..?" Tags="|arduino-yun|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9493" PostTypeId="2" ParentId="9489" CreationDate="2015-03-21T16:01:07.950" Score="1" Body="&lt;p&gt;You could use a shift register to read the switches as outlined by the excellent tutorial &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ShiftIn&quot; rel=&quot;nofollow&quot;&gt;Parallel to Serial Shifting-In with a CD4021BE&lt;/a&gt;. Quoting the summary:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sometimes you'll end up needing more digital input than the 13 pins on&#xA;  your Arduino board can readily handle. Using a parallel to serial&#xA;  shift register allows you collect information from 8 or more switches&#xA;  while only using 3 of the pins on your Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you would only use 3 pins to read the seven switches, which would leave you with 9 pins to play with, for the LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, you could use a similar method for the LCD, using a shift-out register, and use just 3 pins for the 6 inputs of the LCD. A tutorial for that is &lt;a href=&quot;http://www.electroschematics.com/11155/alphanumeric-lcd-shift-register-arduino-part-1/&quot; rel=&quot;nofollow&quot;&gt;Alphanumeric LCD with Shift Register on Arduino – part 1&lt;/a&gt;, using the &lt;a href=&quot;http://www.electroschematics.com/wp-content/uploads/2015/01/AlphaLCD.zip&quot; rel=&quot;nofollow&quot;&gt;AlphaLCD library&lt;/a&gt; or &lt;a href=&quot;http://www.electronics-lab.com/projects/mcu/015/&quot; rel=&quot;nofollow&quot;&gt;3-Wire Serial LCD using a Shift Register&lt;/a&gt;, which has no library, but provides code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would leave you with 6 pins free (out of the total 12 pins, if you exclude pins 0 and 1 for serial), after both the switches and LCD are wired up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this solution requires you to purchase one or two shift (in and/or out) registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE may come with a built-in library that use shift registers, but I am not sure about that. Maybe someone can confirm, or refute, this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that this helps.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-03-22T05:20:53.917" LastActivityDate="2015-03-22T05:20:53.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9494" PostTypeId="1" AcceptedAnswerId="9496" CreationDate="2015-03-21T17:24:56.890" Score="2" ViewCount="184" Body="&lt;p&gt;I'm using a ATMega328P-PU on a breadboard as an arduino. How do you start a code after say 20 seconds have elapsed since startup?&#xA;Example code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(condition)&#xA;{&#xA;     //Start sending morse code!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My current code uses &lt;code&gt;millis()&lt;/code&gt; and fails miserably. The speaker does not get activated. I'm using the standard circuit mentioned at the &lt;a href=&quot;http://arduino.cc/en/main/standalone&quot; rel=&quot;nofollow&quot;&gt;Arduino website&lt;/a&gt;&#xA;My current code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time = millis();&#xA;  if(time&amp;gt;=20000)&#xA;      txEnable=true;&#xA;      val = analogRead(analogPin);&#xA;  if(val!=0)&#xA;  {&#xA;    standby=false;&#xA;&#xA;  }&#xA;  else&#xA;  standby=true;&#xA;  if(txEnable==true &amp;amp;&amp;amp; standby==true)&#xA; {&#xA;&#xA;  if(!callsignSender-&amp;gt;continueSending())&#xA;    {&#xA;        callsignSender-&amp;gt;startSending();&#xA;    }&#xA;&#xA; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6613" LastActivityDate="2015-03-21T18:48:43.750" Title="How to start a block of code after a certain time?" Tags="|arduino-uno|time|millis|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9495" PostTypeId="2" ParentId="9464" CreationDate="2015-03-21T17:56:53.597" Score="5" Body="&lt;p&gt;I just measured on my Uno with a pocket scope and a cheap 1× probe. I got something around 40&amp;nbsp;ns, but it was at the bandwidth limit of this basic scope, and I believe this probe has quite high capacitive load. A faster scope and a better probe would probably give a shorter rise time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I tried again with a better scope (an Hameg HM-305) and a decent 10× probe, the observed rise time was somewhere in the 10&amp;nbsp;ns range, which is about the rise time of the internal amplifier of the scope. Then the higher boundary would be about 10&amp;nbsp;ns.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-11T18:27:54.390" LastActivityDate="2015-06-11T18:27:54.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9496" PostTypeId="2" ParentId="9494" CreationDate="2015-03-21T18:26:58.070" Score="1" Body="&lt;p&gt;The following bare-minimum code will switch pin 13 to high after 20 seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {                &#xA;  // assuming pin 13 has a LED connected (as on most Arduino boards)&#xA;  pinMode(13, OUTPUT); &#xA;  digitalWrite(13, LOW); // would also work without this line&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long time = millis();&#xA;  if (time &amp;gt;= 20000) {&#xA;    digitalWrite(13, HIGH);   // set the LED on&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try if this works for you, i.e. if a LED connected to that pin will light up 20 seconds after reboot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not you will need to find the problem: Is your ATmega running at the correct speed? Is your code executed at all? Are the peripherals working?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-21T18:48:43.750" LastActivityDate="2015-03-21T18:48:43.750" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9497" PostTypeId="2" ParentId="9490" CreationDate="2015-03-21T18:37:46.873" Score="3" Body="&lt;p&gt;The address you are looking for is a symbol known by the linker. Then&#xA;you can have the linker put the &lt;em&gt;value&lt;/em&gt; of the symbol straight into your&#xA;code: no need to load from memory. In other words, you use the &lt;code&gt;ldi&lt;/code&gt;&#xA;instruction to load the required address as an &lt;em&gt;immediate&lt;/em&gt; value. You&#xA;should also reverse the order of the struct definition, since you are&#xA;storing SPL at the lowest address.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;typedef struct { uint8_t sp_l, sp_h; } struct_t;    &#xA;&#xA;struct_t arr[MAX_STRUCTS];&#xA;&#xA;void some_inline_assembly_function()&#xA;{&#xA;  asm volatile(&#xA;    // Determine where to store the new SP_H and SP_L register&#xA;    &quot;ldi r26, lo8(arr)     \n\t&quot;  // X is loaded with the symbol arr&#xA;    &quot;ldi r27, hi8(arr)     \n\t&quot;  // which is the address of arr[0].sp_l&#xA;    // Here you may want to add 2 * an array index.&#xA;&#xA;    // This part stores the stack pointer low and high byte indirectly&#xA;    // using the X registers (r26,27), which is what I want.&#xA;    &quot;in    r0, __SP_L__    \n\t&quot; &#xA;    &quot;st    x+, r0          \n\t&quot; &#xA;    &quot;in    r0, __SP_H__    \n\t&quot;&#xA;    &quot;st    x+, r0          \n\t&quot;&#xA;  ::);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the &lt;code&gt;lo8()&lt;/code&gt; and &lt;code&gt;hi8()&lt;/code&gt; assembler macros: they split the address&#xA;into low and high bytes. Actually the assembler translates them into&#xA;R_AVR_LO8_LDI and R_AVR_HI8_LDI relocations records, and the&#xA;linker does the real job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I think I just realized why you were thinking of using &lt;code&gt;lds&lt;/code&gt;&#xA;in the first place...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using array indices, you may want to access the array through&#xA;a pointer (declared &lt;code&gt;struct_t *pointer&lt;/code&gt;). When programming in C or C++,&#xA;a pointer identifier behaves, for most purposes, just like an array&#xA;identifier. However, at the assembly level, using a pointer involves an&#xA;extra indirection, as you have to read the contents of the pointer from&#xA;RAM. In this case you would indeed be using &lt;code&gt;lds&lt;/code&gt; instructions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; Copy the global 'pointer' into the X pointer register.&#xA;lds r26, pointer    ; low byte&#xA;lds r27, pointer+1  ; high byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, if you are programming in C++, then you have to declare&#xA;&lt;code&gt;extern &quot;C&quot;&lt;/code&gt; any identifier that you want to use both in C++ and in&#xA;assembly. Otherwise the C++ compiler will&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Name_mangling&quot; rel=&quot;nofollow&quot;&gt;mangle its name&lt;/a&gt; and you&#xA;would need to use the mangled name in the assembly source.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-03-22T19:04:43.313" LastActivityDate="2015-03-22T19:04:43.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9498" PostTypeId="1" CreationDate="2015-03-21T20:24:59.463" Score="2" ViewCount="1134" Body="&lt;p&gt;I'm currently playing around with a &lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPRS shield&lt;/a&gt; on an Arduino Uno, for which I have to write raw AT commands over the &lt;code&gt;SoftwareSerial&lt;/code&gt;. At the moment, I just want to be able to talk to the GPRS from my PC, so I've written a really basic program to send serial in two directions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial GPRS(7, 8);&#xA;&#xA;void setup()&#xA;{&#xA;  GPRS.begin(19200);&#xA;  Serial.begin(19200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (GPRS.available())&#xA;  {&#xA;    Serial.write(GPRS.read());&#xA;  }&#xA;&#xA;  if (Serial.available())&#xA;  {&#xA;    GPRS.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the communication looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         HW               SW           &#xA;+----+ Serial +-------+ Serial +------+&#xA;|    |        |       |        |      |&#xA;|    +--------&amp;gt;       +--------&amp;gt;      |&#xA;| PC |        |Arduino|        | GPRS |&#xA;|    &amp;lt;--------+       &amp;lt;--------+      |&#xA;|    |        |       |        |      |&#xA;+----+        +-------+        +------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to work fine for shorter commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CPIN?&#xA;&#xA;+CPIN: READY&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm really interested in doing a &lt;a href=&quot;http://signusx.com/sim900-scanning-all-visible-cell-towers-from-all-gsm-operators/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;NETSCAN&lt;/code&gt;&lt;/a&gt; to see what networks are available. When I try it, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CNETSCAN&#xA;&#xA;------MOST SUITABLE CELL------&#xA;Operator:&quot;YES OPTUS&quot;,MCC:505,75&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that's all. I pulled out a logic analyser to spy on the serial pins themselves, and it appears that the complete message is being sent back to the Arduino from the GPRS module perfectly okay - but for some reason, it gets cut off before it reaches my PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what the logic analyser sees over the SW (top two tracks) and HW (bottom tracks) serial lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gYbyQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it appears that the entire GPRS response is being read by the Arduino before it starts to send anything back to the PC, and I assume that some sort of buffer has been overrun and I only get the start of the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So - how should I go about passing through long strings between serial ports like this? I assumed that using &lt;code&gt;if (X.available())&lt;/code&gt; instead of &lt;code&gt;while&lt;/code&gt; would alleviate any issues with long strings (because it appears that this way the two serial ports should take turns with one byte at a time), but is that assumption incorrect?&lt;/p&gt;&#xA;" OwnerUserId="8011" LastEditorUserId="8011" LastEditDate="2015-03-22T21:31:44.290" LastActivityDate="2015-03-22T21:31:44.290" Title="Passing a long string from SoftwareSerial to Serial" Tags="|serial|gsm|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9499" PostTypeId="1" CreationDate="2015-03-21T21:24:35.837" Score="1" ViewCount="1673" Body="&lt;p&gt;I built a basic LED blinker to serve as a car theft deterrent. Originally I was using a 9V battery and delay() but I've refined my approach to consume less power. Here's my code, utilizing the JeeLib library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;JeeLib.h&amp;gt;&#xA;&#xA;int led = 13;&#xA;ISR(WDT_vect) { Sleepy::watchdogEvent(); }&#xA;&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;void loop() {&#xA;  blink_quick();&#xA;  blink_quick();&#xA;  Sleepy::loseSomeTime(8000);&#xA;}&#xA;void blink_quick() {&#xA;  digitalWrite(led, HIGH); &#xA;  Sleepy::loseSomeTime(250);&#xA;  digitalWrite(led, LOW);    &#xA;  Sleepy::loseSomeTime(250);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just blinks twice every 8 seconds. I also used 4 AA batteries as they have a higher amperage rating. How long should this system work before I need to replace the batteries?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thinking is that AA batteries offer 2000mAh and an Arduino typically consumes about 45mA on average. If I were running the above code with delay() instead of the JeeLib functions, it would last for 44 hours. Let's call one cycle the two blinks and the following 8 seconds of rest. I am confused about how long I should factor in for the digitalWrite(led, HIGH) and the corresponding 'low' call, because the rest of the time, the circuit is using JeeLib. I am just interested in figuring out how long I can let this run without changing the batteries, and admittedly I am not experienced enough to tell definitively. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="Mark Lyons" LastEditorUserId="6452" LastEditDate="2015-03-23T12:22:31.233" LastActivityDate="2015-07-16T07:15:23.633" Title="Determining power consumption with Arduino and JeeLib" Tags="|led|power|battery|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9500" PostTypeId="1" CreationDate="2015-03-21T23:07:10.180" Score="4" ViewCount="879" Body="&lt;p&gt;I'm building a project which needs to fit in a wallet. I have an Arduino Micro hooked up to a &lt;a href=&quot;http://www.adafruit.com/product/1697&quot; rel=&quot;nofollow noreferrer&quot;&gt;nRF8001&lt;/a&gt;. I attempted three button cells wired in series, which provided a solid 7.5 volts, but only &lt;code&gt;20mA&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 9V battery successfully powers it, but that's too big to fit in a wallet. I was considering using an &lt;code&gt;A27&lt;/code&gt; battery, but even that's thicker than I would like. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any battery I can use that's a reasonable thickness, and won't explode on me? Thanks!...&lt;/p&gt;&#xA;" OwnerUserId="8012" LastEditorUserId="28134" LastEditDate="2016-11-12T18:29:58.770" LastActivityDate="2019-12-17T16:02:45.390" Title="Thin battery to power arduino micro with nRF8001?" Tags="|battery|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9501" PostTypeId="2" ParentId="9500" CreationDate="2015-03-22T03:07:18.423" Score="0" Body="&lt;p&gt;Either of these two are pretty good depending on how long you want it to live and how much current your device draws:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/731&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/731&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10718&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10718&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can still probably power the micro from these even though they're 3.7v. When charged they'll be closer to 4.2v and it will still probably run down to 3.5v anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could just put two in series to increase the voltage&lt;/p&gt;&#xA;" OwnerUserId="8015" LastActivityDate="2015-03-22T03:07:18.423" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9503" PostTypeId="1" CreationDate="2015-03-22T07:56:50.170" Score="2" ViewCount="385" Body="&lt;p&gt;This is my simple program:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int led = 13;&#xA;void setup()&#xA;{&#xA;    pinMode(led, OUTPUT);&#xA;  /* add setup code here */&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(led, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(led, LOW);&#xA;    delay(1000);&#xA;  /* add main program code here */&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to upload it using Visual Studio 2013 using a plugin &lt;strong&gt;Visual Micro&lt;/strong&gt; for &lt;strong&gt;Arduino&lt;/strong&gt;. But it resulted in this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Compiling 'bb' for 'Intel® Galileo Gen2'&#xA;Binary sketch size: 83,455 bytes (used 1% of a 10,000,000 byte maximum) (0.17 secs)&#xA;Compiling debug version of 'bb' for 'Intel® Galileo Gen2'&#xA;Binary sketch size: 85,056 bytes (used 1% of a 10,000,000 byte maximum) (2.81 secs)&#xA;Uploading to I/O board using 'COM3'&#xA;starting download script&#xA;Args to shell: C:\arduino-1.5.3-Intel.1.0.4/hardware/tools/x86/bin C:\Users\Shiran Abbasi\AppData\Local\V.Micro\Arduino\Builds\bb\izmir_fg/bb.elf COM3&#xA;COM PORT Abbasi\AppData\Local\V.Micro\Arduino\Builds\bb\izmir_fg/bb.elf&#xA;Converted COM Port Abbasi\AppData\Local\V.Micro\Arduino\Builds\bb\izmir_fg/bb.elf to tty port&#xA;Sending Command String to move to download if not already in download mode&#xA;Deleting existing sketch on target&#xA;Moving downloaded file to /sketch/sketch.elf on target&#xA;&#xA;#!/bin/sh&#xA;&#xA;echo &quot;starting download script&quot;&#xA;echo &quot;Args to shell:&quot; $*&#xA;&#xA;# ARG 1: Path to lsz executable.&#xA;# ARG 2: Elf File to download&#xA;# ARG 3: COM port to use.&#xA;&#xA;#path contains \ need to change all to /&#xA;path_to_exe=$1&#xA;fixed_path=${path_to_exe//\\/\/}&#xA;&#xA;#COM ports are not always setup to be addressed via COM for redirect.&#xA;#/dev/ttySx are present. Howwever, COMy -&gt; /dev/ttySx where x = y - 1&#xA;&#xA;com_port_arg=$3&#xA;com_port_id=${com_port_arg/COM/}&#xA;echo &quot;COM PORT&quot; $com_port_id&#xA;tty_port_id=/dev/ttyS$((com_port_id-1))&#xA;C:\arduino-1.5.3-Intel.1.0.4/hardware/arduino/x86/tools/izmir/clupload_win.sh: line 20: Abbasi\AppData\Local\V.Micro\Arduino\Builds\bb\izmir_fg/bb.elf: syntax error: invalid arithmetic operator (error token is &quot;\AppData\Local\V.Micro\Arduino\Builds\bb\izmir_fg/bb.elf&quot;)&#xA;echo &quot;Converted COM Port&quot; $com_port_arg &quot;to tty port&quot; $tty_port_id&#xA;&#xA;echo &quot;Sending Command String to move to download if not already in download mode&quot;&#xA;echo &quot;~sketch download&quot; &gt; $tty_port_id&#xA;C:\arduino-1.5.3-Intel.1.0.4/hardware/arduino/x86/tools/izmir/clupload_win.sh: line 24: $tty_port_id: ambiguous redirect&#xA;&#xA;#Move the existing sketch on target.&#xA;echo &quot;Deleting existing sketch on target&quot;&#xA;$fixed_path/lsz.exe --escape -c &quot;mv -f /sketch/sketch.elf /sketch/sketch.elf.old&quot;  $tty_port_id 1&gt;&amp;0&#xA;C:\arduino-1.5.3-Intel.1.0.4/hardware/arduino/x86/tools/izmir/clupload_win.sh: line 28: $tty_port_id: ambiguous redirect&#xA;&#xA;# Execute the target download command&#xA;&#xA;#Download the file.&#xA;host_file_name=$2&#xA;$fixed_path/lsz.exe --escape --binary --overwrite $host_file_name  $tty_port_id 1&gt;&amp;0&#xA;C:\arduino-1.5.3-Intel.1.0.4/hardware/arduino/x86/tools/izmir/clupload_win.sh: line 34: $tty_port_id: ambiguous redirect&#xA;&#xA;#mv the downloaded file to /sketch/sketch.elf &#xA;target_download_name=&quot;${host_file_name##*/}&quot; &#xA;echo &quot;Moving downloaded file to /sketch/sketch.elf on target&quot;&#xA;#$fixed_path/lsz.exe --escape -c &quot;cp sketch /sketch/sketch.elf&quot;  $tty_port_id 1&gt;&amp;0&#xA;$fixed_path/lsz.exe --escape -c &quot;mv $target_download_name /sketch/sketch.elf; chmod +x /sketch/sketch.elf&quot;  $tty_port_id 1&gt;&amp;0&#xA;C:\arduino-1.5.3-Intel.1.0.4/hardware/arduino/x86/tools/izmir/clupload_win.sh: line 40: $tty_port_id: ambiguous redirect&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;Any help would be appreciated.&lt;/b&gt;&lt;/p&gt;&#xA;" OwnerUserId="8019" LastEditorUserId="37523" LastEditDate="2019-12-27T20:54:43.273" LastActivityDate="2019-12-27T20:54:43.273" Title="Problem in Uploading through Visual Studio" Tags="|compile|arduino-galileo|visualstudio|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="9504" PostTypeId="1" CreationDate="2015-03-22T08:14:00.563" Score="0" ViewCount="76" Body="&lt;p&gt;To be able to switch 220 volt stuff on and off using arduino, I need a relay (I assume). Is there really no nice extention cable with built in relay so you dont need to cut and connect high voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine a Power strip With a simple input port that can be controlled from the andruino, just like a relay board. When I Google this I get a lot of USB controlled and remote controlled, but none that works with an andruino project.&lt;/p&gt;&#xA;" OwnerUserId="8013" LastActivityDate="2015-03-22T13:04:36.683" Title="Relay built in to cable with arduino interface" Tags="|power|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9505" PostTypeId="2" ParentId="9498" CreationDate="2015-03-22T10:54:27.640" Score="1" Body="&lt;p&gt;The output of the logic analyser is pretty clear. The problem will be a buffer overflow. One question is whether it is the receive buffer or the send buffer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best guess is the receive buffer: What could go wrong with your code is that the interrupts used by SoftwareSerial take precedence over the ones used by HardwareSerial. So &lt;em&gt;maybe&lt;/em&gt; that's the reason why nothing is sent before the full message is received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;SoftwareSerial&lt;/code&gt; library has a debug flag (&lt;code&gt;_DEBUG&lt;/code&gt;) which you can enable to pulse a pin as an overflow indictator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would try is to swap Software- and HardwareSerial (i.e. use SoftwareSerial for the communication with the PC). If the problem is as described above it should then vanish because the HardwareSerial does not block interrupts (nor the program flow) while receiving a byte.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-03-22T11:02:55.503" LastActivityDate="2015-03-22T11:02:55.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9506" PostTypeId="2" ParentId="9504" CreationDate="2015-03-22T13:04:36.683" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.powerswitchtail.com/Pages/default.aspx&quot; rel=&quot;nofollow&quot;&gt;PowerSwitch Tail&lt;/a&gt; is what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-22T13:04:36.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9507" PostTypeId="2" ParentId="9500" CreationDate="2015-03-22T13:16:24.443" Score="0" Body="&lt;p&gt;I run my projects directly from a 3v CR2032 lithium cell. Bypassing any voltage regulator. You could use something like a I'd get a 3.3v arduino, something like a Arduino Pro Mini. (You can also use your micro, but you'd have to &quot;underclock&quot; them, as the ATMega32u4 isn't necessarily capable of running 16Mhz at 3V.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By bypassing the voltage regulator, you don't get any of the losses.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-22T13:16:24.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9508" PostTypeId="2" ParentId="9499" CreationDate="2015-03-22T13:36:59.397" Score="1" Body="&lt;p&gt;What board are you using? For example, the Uno has a lot of other components that will consume power, even if you sleep the main processor. Instead use something like a Pro Mini. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can bypass the voltage regulator, and just supply 4.5v by using 3 AA batteries. You can even use just 2 AAs if you have the 3.3v version. The lower the voltage the less current the ATMega uses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most importantly, measuring the power consumption using a multimeter. Measure the current the led uses. Disconnect the led, and measure how much the arduino uses. Use this handy &lt;a href=&quot;http://oregonembedded.com/batterycalc.htm&quot; rel=&quot;nofollow&quot;&gt;Battery Life Calculator&lt;/a&gt;, and just fill in those numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the led with the lowest current, where the led is still visible enough. Running a power-led at just 1mA will still give a decent amount of light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your situation, if coded correctly, power usage of the ATMega is negligible. The only real power user is the led. If you run the led at 1mA, and use a set of AA batteries, you get around 3.5 years of running time, no problem.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-03-22T13:36:59.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9509" PostTypeId="1" CreationDate="2015-03-22T17:03:25.760" Score="0" ViewCount="3341" Body="&lt;p&gt;For a project in progress, I have an Arduino UNO sending a message when a condition occurs, and a Raspberry Pi that listens to it. Both are fitted with NRF24L01+ modules with antennas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works perfectly when the Arduino is powered from a wall socket, for instance using a 9V / 1A power supply. But when I try it with a &lt;a href=&quot;http://data.energizer.com/PDFs/6LR61PL_EU.pdf&quot; rel=&quot;nofollow&quot;&gt;9V battery&lt;/a&gt; (which is supposed to supply 600 mAh), the Raspberry Pi receives only 1/10 of the messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you tell me:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why this happens&lt;/li&gt;&#xA;&lt;li&gt;How I can solve this problem (software / wiring / capacitor / ...)&lt;/li&gt;&#xA;&lt;li&gt;What would be the best way to power an Arduino whose only job is to detect that a switch closes, and emit a message over the air&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/S0BvhiMr&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is the code of the emitter (Arduino). And &lt;a href=&quot;http://pastebin.com/PgcCYxNc&quot; rel=&quot;nofollow&quot;&gt;there&lt;/a&gt; is the code of the receiver (Raspberry Pi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="8024" LastEditorUserId="8024" LastEditDate="2015-03-22T17:31:25.493" LastActivityDate="2023-11-09T18:47:05.553" Title="nrf24l01+ does not work with a battery, or very unreliably" Tags="|power|battery|nrf24l01+|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9510" PostTypeId="1" CreationDate="2015-03-22T18:25:10.453" Score="2" ViewCount="5710" Body="&lt;p&gt;Is there an Arduino Simulator or Emulator or cross-compiler to native Mac executable that runs directly under Mac OS X, and does &lt;strong&gt;NOT&lt;/strong&gt; require a Windows or Linux VM or an active internet connection for running in the cloud?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There &lt;strong&gt;are&lt;/strong&gt; previous questions here on similar topics, but they do not seem to address exactly this particular use case subset.&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2021-04-02T12:29:26.103" Title="Is there an Arduino Simulator or Emulator that runs on OS X?" Tags="|emulation|simulator|osx|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9511" PostTypeId="1" CreationDate="2015-03-22T18:31:43.593" Score="2" ViewCount="1708" Body="&lt;p&gt;What is a summary the main differences between the Arduino 1.0.x and 1.6.x IDEs?  Why do some Arduino products, such as the LightBlue Bean, still require use of the 1.0.6 IDE?&lt;/p&gt;&#xA;" OwnerUserId="651" LastEditorUserId="651" LastEditDate="2015-03-22T21:22:46.693" LastActivityDate="2015-03-24T20:53:31.053" Title="What are the differences between the 1.0.x and 1.6.x IDEs?" Tags="|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9512" PostTypeId="1" CreationDate="2015-03-22T18:38:44.870" Score="0" ViewCount="375" Body="&lt;p&gt;How does an AVR-based Arduino's CPU performance compare to a vintage PC (Apple II, PC-XT, TRS-80, et.al.)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many megaflops of number crunching can one get out of an AVR-based Arduino?&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2015-05-22T00:00:51.963" Title="Comparison of an Arduino's performance?" Tags="|performance|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9513" PostTypeId="1" CreationDate="2015-03-22T19:37:25.657" Score="0" ViewCount="391" Body="&lt;p&gt;So I got a pro micro and 2 pro minis and I was wondering if I could use the pro micro to program my minis? Anyone has any links or guides on how to do this, if at all possible?&lt;/p&gt;&#xA;" OwnerUserId="8025" LastActivityDate="2015-09-23T01:42:54.553" Title="Use Arduino pro micro to program pro mini?" Tags="|arduino-pro-mini|arduino-pro-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9514" PostTypeId="1" AcceptedAnswerId="9519" CreationDate="2015-03-22T20:59:21.043" Score="1" ViewCount="821" Body="&lt;p&gt;I have a project and wish to choose the correct battery back for it such that it will last the required amount of time between each recharge of the battery pack. I am using an Arduino Duemilanove with various attachements and shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can measure that the draw on the project at the point the USB connects from my PC to the Arduino board (by attaching the multimeter to the Vcc and GND solder points on my Arduino board) which reads 5V DC as expected. Is there a way I can meausre the current (without any additional equipment) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect somehow using Ohms law and measuring the resistance between two points would be the answer (knowing the voltage is 5V) but I can't work it out (as in where to measure) with my lack of any electrical knowledge.&lt;/p&gt;&#xA;" OwnerUserId="7805" LastActivityDate="2015-03-23T10:00:40.030" Title="Can I measure the current (mA) of my project with just a multi meter?" Tags="|current|arduino-duemilanove|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9515" PostTypeId="2" ParentId="9512" CreationDate="2015-03-22T21:46:49.577" Score="1" Body="&lt;p&gt;OK, so I just ran some &lt;strong&gt;really&lt;/strong&gt; old benchmarks on a LightBlue Bean (AVR 328p Arduino at 16 MHz).  The Bean ran the Byte Sieve benchmark slightly slower than a VAX 11/780.  The Bean also ran some of my old floating point computations about 2X faster than the 11/750 (this VAX model has no FPU to be fair to the AVR).  That puts the Bean's math performance at somewhere around 70 kFLOPs (with few divides in the mix).  A DEC VAX is several times faster than vintage 8-bit personal computers, an IBM PC-XT being roughly 1/3 to 1/2 a VAX &quot;MIP&quot; in benchmark performance, with an Apple II being slower still.&lt;/p&gt;&#xA;" OwnerUserId="651" LastEditorUserId="651" LastEditDate="2015-03-22T21:53:00.600" LastActivityDate="2015-03-22T21:53:00.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9516" PostTypeId="2" ParentId="1048" CreationDate="2015-03-22T22:00:24.060" Score="0" Body="&lt;p&gt;The Arduino tools and ecosystem supports processors other than just Atmel AVR chips.  For instance the Arduino Due uses an ARM Cortex-M3 processor.&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2015-03-22T22:00:24.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9517" PostTypeId="1" AcceptedAnswerId="9518" CreationDate="2015-03-22T22:10:18.903" Score="1" ViewCount="404" Body="&lt;p&gt;I'm using an arduino uno with a thermal printer and the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_Thermal.h&quot;&#xA;#include &quot;skull.h&quot;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;int printer_TX_Pin = 8;  // This is the yellow wire&#xA;int printer_RX_Pin = 9;  // This is the green wire&#xA;Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);&#xA;&#xA;void setupPrinter() {&#xA;  printer.begin();&#xA;};&#xA;&#xA;void doPrint(char* output) {&#xA;  Serial.print(&quot;Will print: &quot;);&#xA;  Serial.print(output);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  printer.println(output);&#xA;  printer.feed(2);&#xA;}&#xA;&#xA;void setup() {&#xA;  setupPrinter();&#xA;  doPrint(&quot;This is a test to see if it will print only from power supply&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That code works fine if the arduino and printer are plugged into 5v and the arduino is also plugged in to a computer with USB. Once I remove the USB cable it starts printing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This is a test to see if it will&#xA;This is a test to see if it will&#xA;This is a test to see if it will&#xA;This is a test to see if it will&#xA;This is a test to see if it will&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;over and over infinitely. In other programs it prints a slightly garbled first line then stops. When I remove the serial.print lines, this doesn't occur. Why would that be?&lt;/p&gt;&#xA;" OwnerUserId="4446" LastEditorUserId="42" LastEditDate="2015-03-23T16:38:55.750" LastActivityDate="2015-03-23T16:38:55.750" Title="Erratic behaviour using Serial.print() when powering only from power supply" Tags="|arduino-uno|serial|power|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9518" PostTypeId="2" ParentId="9517" CreationDate="2015-03-22T23:46:04.007" Score="3" Body="&lt;p&gt;It seems likely that your Arduino is repeatedly resetting, which means it's starting the program again from the beginning all the time. This can be caused by insufficient power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the standard 5v Arduino boards, the minimum recommended voltage for an external power supply is usually 7v. An on-board regulator brings it down to 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Technically, you &lt;em&gt;can&lt;/em&gt; run them directly from an external 5v supply. However, you have to ensure that it's properly regulated, and that you bypass the on-board regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously you also have to ensure your external supply is capable of sourcing sufficient current. If you're just running an Arduino and a small thermal printer then it's probably OK, but it's certainly worth checking.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-22T23:46:04.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9519" PostTypeId="2" ParentId="9514" CreationDate="2015-03-22T23:50:36.657" Score="4" Body="&lt;p&gt;No, you won't get the right result measuring resistance. Integrated circuits contain lots of semiconductors which are inherently non-linear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to somehow put your multimeter in series with the power supply, set to the mA range. The easiest way I can think of is to use an external battery (7v or higher) and make up a custom cable with standard barrel jacks. As your board appears to have a linear voltage regulator, the current measured will be very close to the current consumed when powered from the USB port.&lt;/p&gt;&#xA;" OwnerUserId="881" LastEditorUserId="881" LastEditDate="2015-03-22T23:56:46.813" LastActivityDate="2015-03-22T23:56:46.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9520" PostTypeId="1" CreationDate="2015-03-23T07:07:05.013" Score="0" ViewCount="1245" Body="&lt;p&gt;I am using the following code and when I am probing pin 13(SCK), I can't see any clock signal in the oscilloscope.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;int SCS=10;&#xA;int SI=11;&#xA;int SCLK=13;&#xA;int EXTCOMIN=4;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA; pinMode(SCS,OUTPUT);&#xA; pinMode(EXTCOMIN,OUTPUT);&#xA; pinMode(SCLK,OUTPUT);&#xA; digitalWrite(SCS,HIGH);&#xA; tone(EXTCOMIN,50);&#xA; SPI.setClockDivider(SPI_CLOCK_DIV16);&#xA; SPI.begin();&#xA;}&#xA;&#xA;void loop()&#xA; {&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7909" LastActivityDate="2015-03-23T21:35:29.393" Title="Unable to see SPI clock in oscilloscope" Tags="|arduino-uno|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9521" PostTypeId="5" CreationDate="2015-03-23T07:49:50.050" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-23T07:49:50.050" LastActivityDate="2015-03-23T07:49:50.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9522" PostTypeId="4" CreationDate="2015-03-23T07:49:50.050" Score="0" Body="An IC that converts signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-23T12:22:54.300" LastActivityDate="2015-03-23T12:22:54.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9523" PostTypeId="5" CreationDate="2015-03-23T07:53:29.807" Score="0" Body="&lt;p&gt;Arduino support in &lt;a href=&quot;https://www.processing.org/&quot; rel=&quot;nofollow&quot;&gt;Processing&lt;/a&gt; IDE is added by installing the extra &lt;a href=&quot;http://playground.arduino.cc/Interfacing/Processing&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library allows you to control an Arduino board from Processing without writing code for the Arduino. Instead, you upload standard firmware (program) to the board and communicate with it using the library. The firmware is called Firmata, and is included in the Arduino software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://en.wikipedia.org/wiki/Processing_(programming_language)&quot; rel=&quot;nofollow&quot;&gt;Processing&lt;/a&gt; on Wikipedia.&lt;/p&gt;&#xA;" OwnerUserId="14181" LastEditorUserId="10794" LastEditDate="2015-10-22T21:05:57.037" LastActivityDate="2015-10-22T21:05:57.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9524" PostTypeId="4" CreationDate="2015-03-23T07:53:29.807" Score="0" Body="A programming language and an IDE based on Java, but with simplified syntax and graphics programming model." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-23T12:22:15.207" LastActivityDate="2015-03-23T12:22:15.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9525" PostTypeId="5" CreationDate="2015-03-23T09:58:21.297" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-23T09:58:21.297" LastActivityDate="2015-03-23T09:58:21.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9526" PostTypeId="4" CreationDate="2015-03-23T09:58:21.297" Score="0" Body="A microcontroller board based on the ATmega32u4 with built-in USB communication." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-23T12:23:03.280" LastActivityDate="2015-03-23T12:23:03.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9527" PostTypeId="5" CreationDate="2015-03-23T09:59:26.440" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000005735.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Galileo board&lt;/a&gt; was based on the Intel Quark SoC X1000 Application Processor, a 32-bit Intel Pentium-class system on a chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital pins 0 to 13 (and the adjacent AREF and GND pins), Analog inputs 0 to 5, the power header, ICSP header, and the UART port pins (0 and 1), are all in the same locations as on the Arduino Uno R3. This is also known as the Arduino 1.0 pinout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Galileo is designed to support shields that operate at either 3.3V or 5V. The core operating voltage of Galileo is 3.3V. However, a jumper on the board enables voltage translation to 5V at the I/O pins. This provides support for 5V Uno shields and is the default behavior. By switching the jumper position, the voltage translation can be disabled to provide 3.3V operation at the I/O pins.&lt;/p&gt;&#xA;" OwnerUserId="33608" LastEditorUserId="33608" LastEditDate="2017-08-28T17:27:46.570" LastActivityDate="2017-08-28T17:27:46.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9528" PostTypeId="4" CreationDate="2015-03-23T09:59:26.440" Score="0" Body="A microcontroller board based on the Intel Quark SoC X1000 Application Processor, a 32-bit Intel Pentium-class system on a chip, designed to be hardware and software pin-compatible with shields designed for the Arduino Uno R3.." OwnerUserId="6452" LastEditorUserId="33608" LastEditDate="2017-08-28T17:28:04.057" LastActivityDate="2017-08-28T17:28:04.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9529" PostTypeId="2" ParentId="9514" CreationDate="2015-03-23T10:00:40.030" Score="1" Body="&lt;p&gt;A reasonable method is to place a small value resistor in series with the supply, connect a capacitor from the Arduino side of the resistor to ground and then measure the voltage drop across the resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you set the resistor value such that the highest current drawn drops less than about 0.1 Volts then it will have minimal effect on most circuits.&lt;br&gt;&#xA;For example if max current is 100 mA then as R = V/I, Rmax &amp;lt;= V/I = 0.1/100 ma = 0.1V/0.1A = 1 Ohm.&lt;br&gt;&#xA;So generally&lt;br&gt;&#xA;Rseries &amp;lt;= Vdrop_max / Imax_A  (I in Amps) or&#xA;Rseries = Vdropmax x 1000 / Imax_mA   (I in milliAmps) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I_ma = Vmeter x 1000  / R&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Max current = 350 mA.&lt;br&gt;&#xA;R &amp;lt;= V/I = 0.1V /0.350  A = &amp;lt;= 0.286 Ohm.&#xA;A 0.1 Ohm - which is a readily available standard value, will probably be good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then if meter reads say 0.033 volt (33 millivolts) then&lt;br&gt;&#xA;ImA = V_mv / R   = 33/0.1 = 330 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A larger resistor value, giving a larger voltage drop, can be used if the circuit will tolerate the resultant lower supply voltage. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Measure the drop with a meter set to 0.2 V (200 millivolts). Nit all meters have a 0.2 V range but even some reasonably cheap ones do have and it is worth having a meter with this range for various purposes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect a capacitor from Arduino 5Vin to ground - the more uF the better. 100 uF probably OK, 1000 uF better ... . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method will smooth out short current peaks and give you an average current. This aspect can be expanded on if of interest.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-03-23T10:00:40.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9530" PostTypeId="5" CreationDate="2015-03-23T10:00:52.863" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-03-23T10:00:52.863" LastActivityDate="2015-03-23T10:00:52.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9531" PostTypeId="4" CreationDate="2015-03-23T10:00:52.863" Score="0" Body="A microcontroller board based on the ATmega168 or ATmega328." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-23T12:22:58.537" LastActivityDate="2015-03-23T12:22:58.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9532" PostTypeId="1" CreationDate="2015-03-23T10:34:14.230" Score="8" ViewCount="312" Body="&lt;p&gt;From the reference design of the Arduino UNO r3, I find that USBVCC will be connected to +5V via mosfet T1 if Vin is below 6.6V.&#xA;Doesn't this short the two sources if Vin is just below 6.6V?&#xA;The datasheet for regulator U1 (NCP1117) mentions input range as low as 6.5V for the 5V version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question came to mind when researching if I can simultaneously power the arduino with USB and the 5V-pin. There are many warnings not to do so, and some say its ok anyway. I realise that this will short the USB 5V with my external 5V if Vin/PWRIN is not connected or less than 6.6V/~7.3V, but how bad is that considering that this may happen anyway by design (if the theory above is correct)?&lt;/p&gt;&#xA;" OwnerUserId="8028" LastActivityDate="2015-06-24T07:47:23.657" Title="Will the arduino power autoselection logic short the regulated 5V and the USB 5V?" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9533" PostTypeId="1" CreationDate="2015-03-23T12:29:13.263" Score="3" ViewCount="2748" Body="&lt;p&gt;I am trying to write to Sharp memory LCD &quot;LS027B7DH01&quot; which isn't going well for me. I didn't find any useful information for beginners. I just want to display any character on the LCD. Here's my code: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;int SCS=10;&#xA;int SI=11;&#xA;int SCLK=13;&#xA;int EXTCOMIN=4;&#xA;&#xA; void setup()&#xA; {&#xA;   pinMode(SCS,OUTPUT);&#xA;   pinMode(EXTCOMIN,OUTPUT);&#xA;   pinMode(SCLK,OUTPUT);&#xA;   pinMode(SI,OUTPUT);&#xA;   digitalWrite(SCS,HIGH);&#xA;   tone(EXTCOMIN,40);&#xA;   SPI.setClockDivider(SPI_CLOCK_DIV16);&#xA;   SPI.setBitOrder(MSBFIRST);&#xA;   SPI.setDataMode(SPI_MODE0);&#xA;   SPI.begin();&#xA;   SPI.transfer(0×20);&#xA;   delay(3000);&#xA;}&#xA;&#xA;void loop()&#xA; {&#xA;   SPI.transfer(0×80);&#xA;   delay(3000);&#xA;   for (byte i=0; i&amp;lt;30;i++)&#xA;    {&#xA;       SPI.transfer(i+1);&#xA;       delay(3000);&#xA;      for(int j=0; j&amp;lt;50;j++)&#xA;       {&#xA;         SPI.transfer(0x0F);&#xA;         delay(3000);&#xA;       }&#xA;       delay(3000);&#xA;       SPI.transfer(0×00);&#xA;    }&#xA;    delay(3000);&#xA;    SPI.transfer(0×00);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7909" LastEditorUserId="4131" LastEditDate="2015-08-24T11:55:40.047" LastActivityDate="2017-03-17T02:43:44.377" Title="Operating Sharp memory LCD with Arduino" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9534" PostTypeId="2" ParentId="9510" CreationDate="2015-03-23T12:44:07.187" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/provideyourown/CodeBlocks-Arduino/&quot; rel=&quot;nofollow&quot;&gt;Arduino CodeBlocks&lt;/a&gt; plug-in has an Arduino simulator. Be carefull when setting it up and use full paths, it's easy to mess up, but works beautifully once done.&lt;/p&gt;&#xA;" OwnerUserId="7986" LastActivityDate="2015-03-23T12:44:07.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9535" PostTypeId="2" ParentId="8091" CreationDate="2015-03-23T16:07:22.163" Score="0" Body="&lt;p&gt;This is not a real answer, as @jfpoilpret already gave a perfectly valid&#xA;one. Just a few observations and suggestions from looking at your code.&#xA;I write is as an answer only because it is too long to fit in a comment.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The member variable &lt;code&gt;_cycle_duration&lt;/code&gt; is not used. You could remove&#xA;it and save a couple of bytes per Output instance.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;if (run_once == true)&lt;/code&gt; is equivalent to &lt;code&gt;if ((run_once == true) ==&#xA;true)&lt;/code&gt;. They are both considered bad style. Preferred style is to&#xA;just write &lt;code&gt;if (run_once)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;On the Arduino, it is generally good practice to avoid dynamic&#xA;allocation whenever possible. Of course, it is not always possible,&#xA;but in this instance it is quite easy: declare STATUS and BUZZER as&#xA;objects instead of pointers (as in &lt;code&gt;Output STATUS;&lt;/code&gt;), then replace&#xA;&lt;code&gt;-&amp;gt;&lt;/code&gt; by a single dot (&lt;code&gt;.&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-03-23T16:07:22.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9536" PostTypeId="1" CreationDate="2015-03-23T15:52:10.790" Score="2" ViewCount="2105" Body="&lt;p&gt;I am trying to create an Arduino program that combines a pulse sensor (that measures the Beats Per Minutes) and a music shield. I am experiencing some difficulties with the coding because the pulse sensor has an extensive interrupt routine that occurs every 2ms while the music shield has its own interrupt. &#xA;    Through research I have found that the Arduino Uno cannot have two interrupt routines at&#xA;    the same time. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to code around this issue in order to have both the interrupt &#xA;           routines worK? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am attaching the code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Include Music Shield Library&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_VS1053.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;// Define everything needed for the Music Shield &#xA;#define BREAKOUT_RESET  9     // VS1053 reset pin (output)&#xA;#define BREAKOUT_CS     10    // VS1053 chip select pin (output)&#xA;#define BREAKOUT_DCS    8     // VS1053 Data/command select pin (output)&#xA;#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)&#xA;#define SHIELD_CS     7       // VS1053 chip select pin (output)&#xA;#define SHIELD_DCS    6       // VS1053 Data/command select pin (output)&#xA;#define CARDCS 4              // Card chip select pin&#xA;#define DREQ 3                // VS1053 Data request, ideally an Interrupt pin&#xA;&#xA;//Explain what musicplayer means&#xA;Adafruit_VS1053_FilePlayer musicPlayer = &#xA;  // create breakout-example object!&#xA;  //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);&#xA;  // create shield-example object!&#xA;  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&#xA;//Variables for the Pulse Sensor &#xA;int pulsePin = 0;                   // Pulse Sensor purple wire connected to analog pin 0&#xA;//These variables are volatile because they are used during the interrupt service routine!&#xA;volatile int BPM;                   // used to hold the pulse rate&#xA;volatile int Signal;                // holds the incoming raw data&#xA;volatile int IBI = 600;             // holds the time between beats, must be seeded! &#xA;volatile boolean Pulse = false;     // true when pulse wave is high, false when it's low&#xA;volatile boolean QS = false;        // becomes true when Arduoino finds a beat.&#xA;&#xA;//Define integer range for the switchcase map function &#xA;const int sensorMin = 70;           // sensor minimum, dicovered through research MAY CHANGE&#xA;const int sensorMax = 230;          // sensor maximum, discovered through research MAY CHANGE&#xA;&#xA;//Now we are going to set up the sensor and the shield. &#xA;//The swtichcase does not need setup because we are not using the serial monitor for it.&#xA;void setup(){&#xA;Serial.begin(115200);&#xA;  Serial.println(&quot;Adafruit VS1053 Simple Test&quot;);&#xA;  interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS &#xA;//Now we setup the rest of the shield. &#xA;&#xA;  if (! musicPlayer.begin()) {      // initialise the music player&#xA;     Serial.println(F(&quot;Couldn't find VS1053, do you have the right pins defined?&quot;));&#xA;     while (1);&#xA;  }&#xA;  Serial.println(F(&quot;VS1053 found&quot;));&#xA;&#xA;  SD.begin(CARDCS);    // initialise the SD card&#xA;&#xA;  // Set volume for left, right channels. lower numbers == louder volume!&#xA;  musicPlayer.setVolume(05,05);&#xA;&#xA;  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int&#xA;&#xA;}                  &#xA;//Void setup is done, now we tell the arduino what to do with all this information. &#xA;&#xA;void loop(){&#xA;   // read the sensor:&#xA;  int sensorReading = analogRead(A0);&#xA;  //A0 should be BPM&#xA;  // map the sensor range to a range of four options:&#xA;  int range = map(sensorReading, sensorMin, sensorMax, 0, 4);&#xA;&#xA;//In our map range 0=70-110, 1=110-150, 2=150-190, 3=190-230, 4=end(DEAD)&#xA;// do something different depending on the &#xA;// range value:&#xA;//Track 1 is resting music, track 2 is medium beat, track 3 is fast beat, and track 4 is continous beeps. &#xA;  switch (range) {&#xA;  case 0:    // 70BPM - 110 BPM&#xA;    Serial.println(F(&quot;Playing track 001&quot;));&#xA;    musicPlayer.playFullFile(&quot;track001.mp3&quot;); &#xA;  case 1:    // 110 BPM - 150 BPM&#xA;    Serial.println(F(&quot;Playing track 002&quot;));&#xA;    musicPlayer.startPlayingFile(&quot;track002.mp3&quot;);&#xA;  case 2:    // 150 BPM - 190 BPM&#xA;    Serial.println(F(&quot;Playing track 003&quot;));&#xA;    musicPlayer.startPlayingFile(&quot;track003.mp3&quot;);&#xA;  case 3:    // 190 BPM - 230 BPM &#xA;    Serial.println(F(&quot;Dangerous&quot;));&#xA;    musicPlayer.startPlayingFile(&quot;track004.mp3&quot;);&#xA;  case 4:    // DEAD&#xA;    Serial.println(F(&quot;DEAD&quot;));&#xA;    musicPlayer.startPlayingFile(&quot;track005.mp3&quot;);&#xA;    break;&#xA;  } &#xA;  delay(1);        //This is the delay of the switchcase. &#xA;                   //The Music Shield Requests 100, so this MAY CHANGE&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;volatile int rate[10];                    // array to hold last ten IBI values&#xA;volatile unsigned long sampleCounter = 0;          // used to determine pulse timing&#xA;volatile unsigned long lastBeatTime = 0;           // used to find IBI&#xA;volatile int P =512;                      // used to find peak in pulse wave, seeded&#xA;volatile int T = 512;                     // used to find trough in pulse wave, seeded&#xA;volatile int thresh = 512;                // used to find instant moment of heart beat, seeded&#xA;volatile int amp = 100;                   // used to hold amplitude of pulse waveform, seeded&#xA;volatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM&#xA;&#xA;&#xA;void interruptSetup(){     &#xA;  // Initializes Timer2 to throw an interrupt every 2mS.&#xA;  TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE&#xA;  TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER &#xA;  OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE&#xA;  TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A&#xA;  sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED      &#xA;} &#xA;&#xA;&#xA;// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE. &#xA;// Timer 2 makes sure that we take a reading every 2 miliseconds&#xA;ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124&#xA;  cli();                                      // disable interrupts while we do this&#xA;  Signal = analogRead(pulsePin);              // read the Pulse Sensor &#xA;  sampleCounter += 2;                         // keep track of the time in mS with this variable&#xA;  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise&#xA;&#xA;    //  find the peak and trough of the pulse wave&#xA;  if(Signal &amp;lt; thresh &amp;amp;&amp;amp; N &amp;gt; (IBI/5)*3){       // avoid dichrotic noise by waiting 3/5 of last IBI&#xA;    if (Signal &amp;lt; T){                        // T is the trough&#xA;      T = Signal;                         // keep track of lowest point in pulse wave &#xA;    }&#xA;  }&#xA;&#xA;  if(Signal &amp;gt; thresh &amp;amp;&amp;amp; Signal &amp;gt; P){          // thresh condition helps avoid noise&#xA;    P = Signal;                             // P is the peak&#xA;  }                                        // keep track of highest point in pulse wave&#xA;&#xA;  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT&#xA;  // signal surges up in value every time there is a pulse&#xA;  if (N &amp;gt; 250){                                   // avoid high frequency noise&#xA;    if ( (Signal &amp;gt; thresh) &amp;amp;&amp;amp; (Pulse == false) &amp;amp;&amp;amp; (N &amp;gt; (IBI/5)*3) ){        &#xA;      Pulse = true;                               // set the Pulse flag when we think there is a pulse&#xA;      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS&#xA;      lastBeatTime = sampleCounter;               // keep track of time for next pulse&#xA;&#xA;      if(secondBeat){                        // if this is the second beat, if secondBeat == TRUE&#xA;        secondBeat = false;                  // clear secondBeat flag&#xA;        for(int i=0; i&amp;lt;=9; i++){             // seed the running total to get a realisitic BPM at startup&#xA;          rate[i] = IBI;                      &#xA;        }&#xA;      }&#xA;&#xA;      if(firstBeat){                         // if it's the first time we found a beat, if firstBeat == TRUE&#xA;        firstBeat = false;                   // clear firstBeat flag&#xA;        secondBeat = true;                   // set the second beat flag&#xA;        sei();                               // enable interrupts again&#xA;        return;                              // IBI value is unreliable so discard it&#xA;      }   &#xA;&#xA;&#xA;      // keep a running total of the last 10 IBI values&#xA;      word runningTotal = 0;                  // clear the runningTotal variable    &#xA;&#xA;      for(int i=0; i&amp;lt;=8; i++){                // shift data in the rate array&#xA;        rate[i] = rate[i+1];                  // and drop the oldest IBI value &#xA;        runningTotal += rate[i];              // add up the 9 oldest IBI values&#xA;      }&#xA;&#xA;      rate[9] = IBI;                          // add the latest IBI to the rate array&#xA;      runningTotal += rate[9];                // add the latest IBI to runningTotal&#xA;      runningTotal /= 10;                     // average the last 10 IBI values &#xA;      BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM!&#xA;      QS = true;                              // set Quantified Self flag &#xA;      // QS FLAG IS NOT CLEARED INSIDE THIS ISR&#xA;    }                       &#xA;  }&#xA;&#xA;  if (Signal &amp;lt; thresh &amp;amp;&amp;amp; Pulse == true){   // when the values are going down, the beat is over&#xA;    Pulse = false;                         // reset the Pulse flag so we can do it again&#xA;    amp = P - T;                           // get amplitude of the pulse wave&#xA;    thresh = amp/2 + T;                    // set thresh at 50% of the amplitude&#xA;    P = thresh;                            // reset these for next time&#xA;    T = thresh;&#xA;  }&#xA;&#xA;  if (N &amp;gt; 2500){                           // if 2.5 seconds go by without a beat&#xA;    thresh = 512;                          // set thresh default&#xA;    P = 512;                               // set P default&#xA;    T = 512;                               // set T default&#xA;    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date        &#xA;    firstBeat = true;                      // set these to avoid noise&#xA;    secondBeat = false;                    // when we get the heartbeat back&#xA;  }&#xA;&#xA;  sei();                                   // enable interrupts when youre done!&#xA;}// end isr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8049" OwnerDisplayName="Stem5" LastEditorUserId="6452" LastEditDate="2015-03-23T16:45:15.490" LastActivityDate="2015-04-22T18:31:00.043" Title="Multiple interrupts in same sketch" Tags="|shields|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9537" PostTypeId="2" ParentId="9536" CreationDate="2015-03-23T17:37:05.997" Score="2" Body="&lt;p&gt;I wrote most of the SFEMP3Shield library. Where it appears that AdaFruit based much of theirs on. That said I have used Timer1 library with mine just fine to invoke the filling of the VS1053. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where I am suspicious that AdaFruit's Library's did not Interrupt lock out the SPI packets. As I did on the SFEMP3Shield library, as to keep other things from messing up the frame. Where a brief skim of your code, initially looks fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have not described your symptoms.&#xA;Where as using 2ms IRQ's and noting the VS1053 library reads the SdCard in 500byte chunks I image these reads are blocking and corrupting your 2ms ISR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try to slow them down, just to see if they stop getting messed up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try to using the polling method of the VS1053, instead of interrupts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try to use the more feature mature &lt;a href=&quot;https://github.com/mpflaga/Sparkfun-MP3-Player-Shield-Arduino-Library&quot; rel=&quot;nofollow&quot;&gt;SFEMP3Shield library&lt;/a&gt; and its &lt;a href=&quot;http://mpflaga.github.io/Sparkfun-MP3-Player-Shield-Arduino-Library/&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; noting that it also uses the more mature SdFat. As the stock SD library may be part of your problem.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-03-23T17:37:05.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9538" PostTypeId="1" AcceptedAnswerId="9540" CreationDate="2015-03-23T18:22:18.400" Score="3" ViewCount="2045" Body="&lt;p&gt;I think the arduino board is awesome.&#xA;Though I'm not interested in the library and IDE at all...&#xA;Is there a way, to use an AVR 328p, as you normally would, on an arduino board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like how arduino's can be programmed through serial, can get powered through serial and I often use serial as a debugging option. Making my own board (with ICSP programmer) would not be able to do this (withouth bootloader).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to use all the stuff from arduino?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can I use my own compiler for an arduino board? (GNU-GCC / AVR)&lt;/li&gt;&#xA;&lt;li&gt;Can I use my own IDE for an arduino board? (Eclipse / Atmel Studio)&lt;/li&gt;&#xA;&lt;li&gt;Can I still program through serial then? (Does the bootloader care which compiler I used? Does Eclipse/AVR studio have the options to program through serial?)&lt;/li&gt;&#xA;&lt;li&gt;Other stuff I should take in mind. (Annoying things like AVR studio not having a COM port window, though that's an easy fix.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit: We've programmed an AVR 328P (GNU-GCC / Eclipse / ICSP) in school, so I know it takes quite some work to get the compiler set up, working with Eclipse. You don't have to completely describe the proces :) Just to avoid someone spending hours on an answer that's easily found on the internet.&#xA;(On my search for this subject I could only find people doing the other way around, getting an 328p chip to work with arduino)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="37523" LastEditDate="2019-11-17T06:09:21.103" LastActivityDate="2019-11-17T06:09:21.103" Title="Using an Arduino board to program an AVR" Tags="|atmega328|eclipse|avr-gcc|gcc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9539" PostTypeId="2" ParentId="9483" CreationDate="2015-03-23T19:52:41.093" Score="4" Body="&lt;p&gt;I'll tell you what worked for me, because I didn't find the schematics of this board. But your board may work differently, so it is always good to check the datasheet and the schematic (if you have one).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Power&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Be sure to use an external 5V source that can supply up to 2A without dipping significantly. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial GPRS(7, 8);         //7 = TX, 8 = RX&#xA;unsigned char buffer[64]; port&#xA;int count=0;     &#xA;int i = 1;                         //if i = 0, send SMS.&#xA;void setup(){&#xA;  //delay(10000);&#xA;  GPRS.begin(19200);               // the GPRS baud rate   &#xA;  Serial.begin(19200);             // the Serial port of Arduino baud rate.&#xA;  Serial.print(&quot;I'm ready&quot;);&#xA;  Serial.print(&quot;Hello?&quot;); &#xA;}&#xA;&#xA;void loop(){&#xA;  if (GPRS.available()){         // if date is comming from softwareserial port ==&amp;gt; data is comming from gprs shield&#xA;&#xA;    while(GPRS.available()){          // reading data into char array &#xA;      buffer[count++]=GPRS.read();     // writing data into array&#xA;      if(count == 64)break;&#xA;    }&#xA;  Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port&#xA;  clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array&#xA;  count = 0;                       // set counter of while loop to zero&#xA;}&#xA;&#xA;if (Serial.available())            // if data is available on hardwareserial port ==&amp;gt; data is comming from PC or notebook&#xA;  GPRS.write(Serial.read());       // write it to the GPRS shield&#xA;  if(i == 0){&#xA;    GPRS.print(&quot;AT+CMGF=1\r&quot;); //sending SMS in text mode&#xA;    Serial.println(&quot;AT+CMGF=1\r&quot;); &#xA;    delay(1000);&#xA;    GPRS.print(&quot;AT+CMGS=\&quot;+554988063979\&quot;\r&quot;); // phone number&#xA;    Serial.println(&quot;AT+CMGS=\&quot;+554988063979\&quot;\r&quot;); &#xA;    delay(1000);&#xA;    GPRS.print(&quot;Test\r&quot;); // message&#xA;    Serial.println(&quot;Test\r&quot;); &#xA;    delay(1000);&#xA;    GPRS.write(0x1A); //send a Ctrl+Z(end of the message)&#xA;    delay(1000);&#xA;    Serial.println(&quot;SMS sent successfully&quot;);&#xA;    i++;&#xA;  }   &#xA;}&#xA;&#xA;void clearBufferArray(){              // function to clear buffer array&#xA;  for (int i=0; i&amp;lt;count;i++){&#xA;    buffer[i]=NULL;                  // clear all index of array with command NULL&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Connection&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PfIu8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Testing...&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Open the serial monitor Arduino, set the baud rate in 19200 in &quot;Both NL &amp;amp; CR&quot;. If not work, set to &quot;Carriage Return&quot;. Type &quot;AT&quot; and wait for an OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YaamU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Help&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you need help, these links were useful to me:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="595" LastEditorUserId="4628" LastEditDate="2017-01-30T09:49:08.233" LastActivityDate="2017-01-30T09:49:08.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9540" PostTypeId="2" ParentId="9538" CreationDate="2015-03-23T20:19:57.003" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;Do I have to use all the stuff from arduino?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;A = No!&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Can I use my own compiler for an arduino board? (GNU-GCC / AVR)&lt;/li&gt;&#xA;&lt;li&gt;Can I use my own IDE for an arduino board? (Eclipse / Atmel Studio)&lt;/li&gt;&#xA;&lt;li&gt;Can I still program through serial then? (Does the bootloader care which&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Of Course! I use &lt;code&gt;Eclipse IDE&lt;/code&gt; and I programming boards with Arduino bootloader directly in &lt;code&gt;C/C++&lt;/code&gt; using avr-gcc and avrdude.&lt;/p&gt;&#xA;&lt;h2&gt;&lt;strong&gt;Configuring Eclipse&lt;/strong&gt;&lt;/h2&gt;&#xA;&lt;p&gt;First, let's download a plug-in for integrating &lt;code&gt;AVR GCC&lt;/code&gt; and &lt;code&gt;Avrdude&lt;/code&gt; + &lt;code&gt;Eclipse IDE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;To install the plug-in, point to the menu &amp;quot;Help&amp;gt; Install new software&amp;quot;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gPhH1.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;We will set a new location to download the plugin. Click the &amp;quot;Add ...&amp;quot; and type: AVR - Eclipse and the URL: &lt;a href=&quot;http://avr-eclipse.sourceforge.net/updatesite&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://avr-eclipse.sourceforge.net/updatesite&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cuc1E.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now select the plugin that appeared in the list and click &amp;quot;Next&amp;quot;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MTTEJ.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, next, &amp;quot;I Acept the terms...&amp;quot;, restart...&lt;/p&gt;&#xA;&lt;p&gt;Now we install the plug-in, we will set it up. Point to the menu &amp;quot;Window&amp;gt; Preferences.&amp;quot; Click in &amp;quot;AVRDUDE&amp;quot;. The following screen:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lQy8i.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;On the next screen &amp;quot;AVR DUDE&amp;quot; let's set our recorder. Click &amp;quot;Add&amp;quot; to &amp;quot;Programmer configuration&amp;quot;. Search for &amp;quot;Arduino&amp;quot;.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HLsHL.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Or, if you prefer, you can program making use of avr libraries in own Arduino IDE. Try to upload the following code into an Arduino board! While a blink costs almost 1,056 bytes of memory using an Arduino Uno, the following code uses only 164 bytes and does the same thing :)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL    &#xA;#include &amp;lt;avr/io.h&amp;gt;         &#xA;#include &amp;lt;util/delay.h&amp;gt;     &#xA;&#xA;#define set_bit(Y,bit_x) (Y|=(1&amp;lt;&amp;lt;bit_x))    &#xA;#define clr_bit(Y,bit_x) (Y&amp;amp;=~(1&amp;lt;&amp;lt;bit_x))   &#xA;#define tst_bit(Y,bit_x) (Y&amp;amp;(1&amp;lt;&amp;lt;bit_x))     &#xA;#define cpl_bit(Y,bit_x) (Y^=(1&amp;lt;&amp;lt;bit_x))    &#xA;&#xA;#define LED PB5         &#xA;&#xA;int main( ){&#xA;    DDRB = 0xFF;        &#xA;&#xA;    while(1){               &#xA;        cpl_bit(PORTB,LED); &#xA;        _delay_ms(200);     &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you use Linux, you can take a &lt;code&gt;sudo cat/dev/ttyACM0&lt;/code&gt; to detect what lies serial and &lt;code&gt;echo &amp;quot;string&amp;quot; &amp;gt;&amp;gt; /dev/ttyACM0&lt;/code&gt; to send data.&lt;/p&gt;&#xA;" OwnerUserId="595" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-23T20:27:36.743" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9541" PostTypeId="2" ParentId="6632" CreationDate="2015-03-23T21:22:44.257" Score="0" Body="&lt;p&gt;&lt;code&gt;Backlight is connected through potentiometer.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should try to turn the potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work, there might be something wrong with the connection from the potentiometer to the &lt;code&gt;Backlight&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Check out this video: &lt;a href=&quot;https://www.youtube.com/watch?v=XR8ede6V6eA&amp;amp;t=65&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=XR8ede6V6eA&amp;amp;t=65&lt;/a&gt;&#xA;Where the led would be replaced with the BL (black-light) pin.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-03-23T21:22:44.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9542" PostTypeId="2" ParentId="9520" CreationDate="2015-03-23T21:35:29.393" Score="2" Body="&lt;p&gt;(META: This question has been answered in the comment section of the question itself. (And I'm also unable to comment to say that he should answer his own question...) That's why I'm putting this answer here.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to look into the basics of SPI, the clock will only oscillate when there is an actual data transaction in progress. (This will prevent desynchronisation by a bit. And will make both sides know when data is being send. Often along with a SS)&#xA;You can check this by continiously sending something in your code and then probe the clock pin with an ossciloscope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to accept this as an answer, so that nobody it's clear this question is already answered.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-03-23T21:35:29.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9543" PostTypeId="1" CreationDate="2015-03-24T02:43:19.827" Score="2" ViewCount="160" Body="&lt;p&gt;I have a group of four Arduino boards connected via I2C.  One is the master, which sends and receives values from all of the others.  I noticed that the Master will stop executing its loop if power is removed from one of the other Arduino boards.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can one Arduino in a I2C group cause the rest to freeze?&#xA;Is there a way to prevent this?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using one of the Arduino boards to connect to a server via network shield and I don't want the other Arduino boards to be effected if the networked Arduino freezes.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7718" LastEditDate="2015-05-18T22:33:51.190" LastActivityDate="2015-06-23T05:36:54.987" Title="If I have a group of Arduinos connected via I2C, can one Arduino cause the rest to freeze?" Tags="|i2c|networking|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9544" PostTypeId="1" AcceptedAnswerId="9545" CreationDate="2015-03-24T02:58:54.903" Score="0" ViewCount="1155" Body="&lt;p&gt;I want to customize an RC car that I have because the controller is gone. I'm going to use an Arduino with a custom motor controller but I have no idea what to use for the transmitter/receiver. I've seen some IR sensors being used but I want something that uses a frequency channel. Has anyone had experience doing this? What is the easiest way to go about accomplishing a remote controlled Arduino car? &lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-03-24T22:26:35.917" Title="What is the best transmitter/receiver to use with an Arduino RC?" Tags="|motor|remote-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9545" PostTypeId="2" ParentId="9544" CreationDate="2015-03-24T03:48:59.290" Score="1" Body="&lt;p&gt;That depends largely what is controlling it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some options include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;wifi, if you have an expansion board, from a PC or phone (spec says: 66ft/20m)&lt;/li&gt;&#xA;&lt;li&gt;bluetooth works great, directly from your phone (spec says: 32ft/10m - 320ft/100m)&lt;/li&gt;&#xA;&lt;li&gt;433mhz ASK transmitter/receiver from another Arduino or other hand-designed circuit (spec says: 100m/320ft)&lt;/li&gt;&#xA;&lt;li&gt;Infrared receiver - from a TV remote! (range unknown, depends on remote &amp;amp; conditions; would not trust it 10m outside without testing).&lt;/li&gt;&#xA;&lt;li&gt;Cellphone network - longest range (nationwide!). If you get a cheap android to do some of the work, you can use the phone's compass &amp;amp; gps &amp;amp; extra processing power, as well as the camera(s)!&lt;/li&gt;&#xA;&lt;li&gt;Remote control. I know you said you lost yours, but in case someone else is looking here, you can hook up an rc receiver to an Arduino fairly easily. &lt;a href=&quot;https://www.sparkfun.com/tutorials/348&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/tutorials/348&lt;/a&gt; for more info.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Many of these ranges specified will depend on the antenna. If your car can tell it's lost signal, then it can stop; otherwise you have to outrun it, or wait for it to hit a wall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited to include cellphone network, and added ranges to options&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-03-24T22:26:35.917" LastActivityDate="2015-03-24T22:26:35.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9546" PostTypeId="2" ParentId="9544" CreationDate="2015-03-24T03:50:37.440" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E594ZX0&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a link to a pair of Arduino compatible wireless transceivers. One of the listed applications in the description is &quot;remote control systems such as RC vehicles,&quot; so I think this product would suit your project well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the reviews / answers to questions on Amazon, the transceivers have an reliable range of just around 120 feet, so this component would be entirely appropriate in a remote-controlled build.&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2015-03-24T03:50:37.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9547" PostTypeId="1" CreationDate="2015-03-24T03:55:50.873" Score="5" ViewCount="12468" Body="&lt;p&gt;I had a Prusa I3 3D Printer which use Arduino Mega 2560, Ramps 1.4 and Pololu - A4988 Stepper Motor Driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/pecNu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to convert my 3D printer to CNC Router using my Dremel with Flexible shaft like this.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZoGcp.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/KvhPF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the one project on instructables.com at here&#xA;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Controlled-CNC-3D-Printer&quot; rel=&quot;noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-Controlled-CNC-3D-Printer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They give config for Mega 2560 as CNC router.&#xA;But i don't know how to generate g-code for these cnc router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me to generate g-code from STL, DXF and Image(PNG or SVG) files to use with this type of cnc router.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastActivityDate="2019-02-23T23:47:20.163" Title="How to generate gcode for Arduino Mega 2560 and Ramps 1.4 CNC Router" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ClosedDate="2019-02-26T09:20:11.610" ContentLicense="CC BY-SA 3.0" />
  <row Id="9548" PostTypeId="1" AcceptedAnswerId="9636" CreationDate="2015-03-24T04:02:25.773" Score="2" ViewCount="577" Body="&lt;p&gt;Okay so I have an UNO that has an nrf24l01+ attached. I want it to be completely wireless so free of the 5v USB power and the 12V wall plug. In this case what can I use? I do not wish to plug the power directly into the Vin as I am relatively new and afraid that it might fry the board. So I wish to plug it into the barrel jack. So I have read that using a 9v battery to power UNO is a waste of power as most of the power is translated into heat. Also, using 4 AA batteries seem to be a good solution except that I'm not sure if it has enough power for nrf24l01+ as I've read that an arduino with nrf24l01+ on batteries creates an unstable wireless node. I would like some help on what I can power the UNO with.&lt;/p&gt;&#xA;" OwnerUserId="6205" LastEditorUserId="6205" LastEditDate="2015-03-24T04:11:45.243" LastActivityDate="2015-03-29T22:58:40.040" Title="Portable power for an UNO with a nrf24l01+ attached?" Tags="|arduino-uno|power|battery|nrf24l01+|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9549" PostTypeId="1" CreationDate="2015-03-24T06:02:34.273" Score="2" ViewCount="185" Body="&lt;p&gt;I have &lt;a href=&quot;http://www.thingiverse.com/thing:570797&quot; rel=&quot;nofollow&quot;&gt;designed and 3d printed a clock&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am controlling the clock using a Arduino sketch running on a Attiny2313. The stepper motor I am using is a 12v 1:12 ratio stepper. The total number of steps per revolution are 288.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing is that I am unable to get the time right. I have got the steps per revolution of the minute ring bang on, but some how the motor gains 10/11 minutes every 24 hours. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used a lot of the code from the stepper motor library. I am not using the stepper motor library as the code gets larger than what can fit into the 2k attiny memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int number_of_steps = 288;&#xA;int motor_pin_1 = 9;&#xA;int motor_pin_2 = 10;&#xA;int motor_pin_3 = 11;&#xA;int motor_pin_4 = 12;&#xA;int ledpin = 13;&#xA;int delayTime = 4;&#xA;int buttonPin = 4;&#xA;int buttonState = 0; &#xA;int enablepin = 8;&#xA;int whatspeed = 40;&#xA;int last_step_time =0;&#xA;int step_number = 0;&#xA;[color=red]int blinkDelay = 939; [/color]&#xA;int step_delay = 60L * 1000L / number_of_steps / whatspeed;&#xA;int step_direction = 0;&#xA;void setup() {&#xA;&#xA;&#xA; pinMode(motor_pin_1, OUTPUT);&#xA; pinMode(motor_pin_2, OUTPUT);&#xA; pinMode(motor_pin_3, OUTPUT);&#xA; pinMode(motor_pin_4, OUTPUT);&#xA; pinMode(buttonPin,INPUT);&#xA; pinMode(ledpin, OUTPUT);&#xA; pinMode(enablepin,OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA; buttonState = digitalRead(buttonPin);&#xA; if (buttonState ==HIGH){&#xA;   enablemotor();&#xA;   movestep(20);&#xA;   digitalWrite(ledpin,HIGH);&#xA; }&#xA; else{&#xA;   digitalWrite(ledpin,LOW);&#xA;&#xA;   for (int xx = 0; xx&amp;lt;59;xx ++){&#xA;&#xA;     enablemotor();&#xA;     movestep(42);&#xA;     //delay(100);&#xA;     motoroff();&#xA;     blinkk();&#xA;   }&#xA;   enablemotor();&#xA;   movestep(89);//85;&#xA;&#xA;   motoroff();&#xA;   blinkk();&#xA;  //delay(3000);&#xA; }&#xA;}&#xA;&#xA;&#xA;&#xA;void enablemotor(){&#xA; digitalWrite(enablepin,HIGH);&#xA;}&#xA;&#xA;&#xA;void movestep(int steps_to_move){&#xA; int steps_left = abs(steps_to_move);&#xA;&#xA; if (steps_to_move &amp;gt; 0) { &#xA;   step_direction = 1;&#xA; }&#xA; if (steps_to_move &amp;lt; 0) { &#xA;   step_direction = 0;&#xA; }&#xA;&#xA;&#xA; while(steps_left &amp;gt; 0) {&#xA;   // if (millis() - last_step_time &amp;gt;= step_delay ) {&#xA;   //last_step_time = millis();&#xA;   if ( step_direction == 1 ){&#xA;     step_number++;&#xA;     delay(step_delay);&#xA;     if (step_number == number_of_steps) {&#xA;       step_number = 0;&#xA;     }&#xA;   }&#xA;   else {&#xA;     if (step_number ==0){&#xA;       step_number = number_of_steps;&#xA;     }&#xA;     step_number--;&#xA;   }&#xA;   steps_left--;&#xA;&#xA;&#xA;   stepmotor(step_number % 4);&#xA;&#xA;&#xA;   //} &#xA; }&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void stepmotor(int thisStep){&#xA;&#xA; switch (thisStep) {&#xA; case 0:    // 1010&#xA;   digitalWrite(motor_pin_1, HIGH);&#xA;   digitalWrite(motor_pin_2, LOW);&#xA;   digitalWrite(motor_pin_3, HIGH);&#xA;   digitalWrite(motor_pin_4, LOW);&#xA;   break;&#xA; case 1:    // 0110&#xA;   digitalWrite(motor_pin_1, LOW);&#xA;   digitalWrite(motor_pin_2, HIGH);&#xA;   digitalWrite(motor_pin_3, HIGH);&#xA;   digitalWrite(motor_pin_4, LOW);&#xA;   break;&#xA; case 2:    //0101&#xA;   digitalWrite(motor_pin_1, LOW);&#xA;   digitalWrite(motor_pin_2, HIGH);&#xA;   digitalWrite(motor_pin_3, LOW);&#xA;   digitalWrite(motor_pin_4, HIGH);&#xA;   break;&#xA; case 3:    //1001&#xA;   digitalWrite(motor_pin_1, HIGH);&#xA;   digitalWrite(motor_pin_2, LOW);&#xA;   digitalWrite(motor_pin_3, LOW);&#xA;   digitalWrite(motor_pin_4, HIGH);&#xA;   break;&#xA; } &#xA;&#xA;}&#xA;&#xA;void blinkk(){&#xA; for (int i = 0 ; i&amp;lt;30;i++){&#xA;   buttonState = digitalRead(buttonPin);&#xA;   if (buttonState ==HIGH){&#xA;     break;&#xA;   }&#xA;   else{&#xA;     digitalWrite(ledpin, HIGH);   // set the LED on&#xA;     delay(blinkDelay);  // 968           // wait for a second&#xA;     digitalWrite(ledpin, LOW);    // set the LED off&#xA;     delay(blinkDelay); //968&#xA;   } &#xA; }&#xA;}&#xA;&#xA;void motoroff(){&#xA; digitalWrite(enablepin,LOW);&#xA; digitalWrite(motor_pin_1, LOW);&#xA; digitalWrite(motor_pin_2, LOW);&#xA; digitalWrite(motor_pin_3, LOW);&#xA; digitalWrite(motor_pin_4, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8036" LastEditorUserId="6452" LastEditDate="2015-03-24T20:00:36.533" LastActivityDate="2015-09-23T11:50:43.257" Title="time error in controlling a clock" Tags="|motor|attiny|oscillator-clock|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9551" PostTypeId="2" ParentId="9479" CreationDate="2015-03-24T09:01:07.903" Score="2" Body="&lt;p&gt;I don't know how old this thread is, anyway I thought it doesn't hurt to give some insight because I experienced the same problem. Look at: &#xA;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-42187-ATSAM3X-and-ATSAM3A-Series-Checklist_AP-Note_AT03462.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/Images/Atmel-42187-ATSAM3X-and-ATSAM3A-Series-Checklist_AP-Note_AT03462.pdf&lt;/a&gt; &#xA;page 13: DAC0 and 1 voltage lays between 1/6 ADVREF and 5/6 ADVREF which corresponds to approximately ADVREF=3.2v; Span is (4/6)*3.2 = 2.1v&#xA;for periodic signals, Offset can be removed by using a small decoupling capacitor which will act as a high pass filter. &#xA;Hope this helps&lt;/p&gt;&#xA;" OwnerUserId="8040" LastActivityDate="2015-03-24T09:01:07.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9552" PostTypeId="1" CreationDate="2015-03-24T09:05:59.673" Score="9" ViewCount="18633" Body="&lt;p&gt;I am building a project in which two Arduinos will be linked by three wires: TX an RX for serial communication and a common GND. What would be the maximum length of the wires here before communication gets affected?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino Mega R3 on one side and an Arduino Mini on the other one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no particular requirement for the Baud rate, I could use the lowest one if this helps in any way.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastEditorUserId="1612" LastEditDate="2015-03-24T09:36:56.887" LastActivityDate="2021-05-15T17:22:00.590" Title="What is the maximum wire length for serial communication between two Arduinos?" Tags="|serial|arduino-mega|arduino-mini|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9553" PostTypeId="1" CreationDate="2015-03-24T10:18:39.867" Score="2" ViewCount="4065" Body="&lt;p&gt;I googled for this problem many times and ended up with no results, so I decided to post it here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can we use a GSM Dongle (usb dongle) instead of a GSM shield (like SIM900 module) to send and receive SMS in Arduino? If so how it is possible? &lt;/p&gt;&#xA;" OwnerUserId="8041" LastEditorUserId="42" LastEditDate="2015-03-30T08:24:54.073" LastActivityDate="2015-03-30T08:24:54.073" Title="GSM dongle instead of GSM shield?" Tags="|arduino-uno|gsm|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9554" PostTypeId="2" ParentId="9553" CreationDate="2015-03-24T10:36:47.237" Score="1" Body="&lt;p&gt;Not directly. The standard Arduino Uno doesn't have the hardware/software necessary to act as a USB host, which means it can't talk directly to other USB devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; be able to get it work via a &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoUSBHostShield&quot; rel=&quot;nofollow&quot;&gt;USB Host Shield&lt;/a&gt;. I don't know how compatible that is with GSM dongles though because I assume you can't install drivers on it. Additionally, if you're using a shield anyway, you might as well use a GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're able to get an alternative board then another possibility might be the &lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;Arduino Yún&lt;/a&gt;. It has a USB host built-in which is operated by the Linux part of the board. I don't know for certain that it would handle a GSM dongle, but it may be worth looking into.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-03-25T19:45:06.750" LastActivityDate="2015-03-25T19:45:06.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9555" PostTypeId="2" ParentId="9553" CreationDate="2015-03-24T11:16:33.870" Score="0" Body="&lt;p&gt;You can search for, or create your own 'breakout' board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could actually get an sim900 chip running on a breadboard.&#xA;I think  this might be most usefull to you: &lt;a href=&quot;http://img01.cp.aliimg.com/imgextra/i2/87365807/T267qSXa4aXXXXXXXX_!!87365807.jpg&quot; rel=&quot;nofollow&quot;&gt;http://img01.cp.aliimg.com/imgextra/i2/87365807/T267qSXa4aXXXXXXXX_!!87365807.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.aliexpress.com/store/product/Gprs-module-gsm-gprs-module-sim900-development-board-mini-v2-module/124015_1030035160.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/store/product/Gprs-module-gsm-gprs-module-sim900-development-board-mini-v2-module/124015_1030035160.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though this one is quite expensive. (As it doesn't even has a SIM900 on it?)&#xA;There is no reason the SIM900 can't work withouth arduino board..&#xA;But the reason it's used with an 'shield' is because it's easier to connect and enables to draw power from the arduino. (You do need a good supply for the sim900, it can have peak-power levels, which might reset your arduino)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So yes, you could make your own dongle based on a SIM900! Which works great for Embedded/Realtime (UNO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But also, you might want to use a board that has Linux (But bear in mind that this is 'completely' different from the UNO. Check the other answer in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited, Chris explained me you simply can't use an usb device withouth a USB host with USB driving software.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-03-24T20:00:34.373" LastActivityDate="2015-03-24T20:00:34.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9556" PostTypeId="2" ParentId="9552" CreationDate="2015-03-24T12:01:18.330" Score="4" Body="&lt;p&gt;You need to specify &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The order of range you are interested in - is it in the order of metres, tens of metres, kilometers or interstate ?:-) . ALL are possible with suitable compromise.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How you intend to connect to the circuit - direct Arduino pins, high/low buffer, differential drivers, ...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you use 5V/0V &quot;unipolar&quot; then at say 9600 baud you can get many metres with suitable drivers. If you use an Arduino pin directly wire resistance and inductance will start to matter as range increases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 300 baud you can achiever hundreds of metres with twisted pair cables. As range increases aspects like cross-talk from the other circuit and external noise increase in importance. At longer ranges having 4 wires with signal + ground twisted together in each case helps BUT it is likely that at ranges of interest 2 wires plus ground will work OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are prepared to use enough voltage and slow enough signalling you can signal over thousands of miles - as was done with very early telegraph cables. The thousands of volts needed and signalling speeds of perhaps a few bits per second will be a disincentive in most cases. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-03-24T12:01:18.330" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9557" PostTypeId="1" AcceptedAnswerId="9559" CreationDate="2015-03-24T15:19:28.980" Score="1" ViewCount="78" Body="&lt;p&gt;so that there a 2 wires rather than 3 to connect between the two for purposes of serial communication.  And the same question for 3 arduino megas on a common rail and using serial connections?&lt;/p&gt;&#xA;" OwnerUserId="8004" LastEditorUserId="2881" LastEditDate="2015-03-24T19:20:08.440" LastActivityDate="2015-03-24T19:20:08.440" Title="do two arduinos that are linked to a common 9v rail and ground still need a common negative connection for a serial tx rx connection?" Tags="|serial|arduino-mega|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9558" PostTypeId="1" AcceptedAnswerId="9564" CreationDate="2015-03-24T15:20:49.483" Score="0" ViewCount="453" Body="&lt;p&gt;My question is about the arduino Nano or Micro and the smallest and cheapest way to control a bigger power source. I would wire it with a socket so that I could send a command from the board and a light would turn on for example.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-03-25T18:25:02.223" Title="Arduino Nano For Home Automation" Tags="|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9559" PostTypeId="2" ParentId="9557" CreationDate="2015-03-24T15:24:35.403" Score="3" Body="&lt;p&gt;All voltages are ground referenced, hence the ground is the only (supply) connection required. Remote modules can be self-powered and signals will still be discriminated as long as ground is connected.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-24T15:24:35.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9560" PostTypeId="2" ParentId="9509" CreationDate="2015-03-24T15:29:06.470" Score="1" Body="&lt;p&gt;According to the &lt;a href=&quot;http://data.energizer.com/PDFs/522.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; of another 9V battery, I should not expect more than 30 - 50 mA of constant current. This is probably the reason why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long story made short: One can not power a NRFL01+ reliably with a 9V battery.&#xA;I'd be better off using 2xAA batteries.&lt;/p&gt;&#xA;" OwnerUserId="8024" LastActivityDate="2015-03-24T15:29:06.470" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9561" PostTypeId="2" ParentId="9533" CreationDate="2015-03-24T15:42:20.780" Score="1" Body="&lt;p&gt;As the page &lt;a href=&quot;http://kuzyatech.com/sharp-memory-lcd-breakout-a2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sharp Memory LCD Breakout A2&lt;/a&gt; shows, it seems that you need some additional circuitry to drive the display, such as capacitors and resistors. This is why breakout boards are usually employed. Quoting the page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a simple breakout board for Sharp’s new Memory LCD displays (&#xA;  LS013B4DN02 and LS013B4DN04). It brings all pins to a 0.1″ header and&#xA;  provides necessary caps and resistors. The new revision A2 also adds&#xA;  an optional boost converter for those wanting to run 5V display from&#xA;  sub 3.3V supply.The footprints are there, but parts are not populated&#xA;  to save cost. I’ve also added silk labels to the header pins on the&#xA;  back. This is an open design under CC BY SA license.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course, you can always make your own breakout circuit. For example, you could reproduce the breakout board using a breadboard and some resistors and capacitors. The schematics are provided on that page for &lt;a href=&quot;http://kuzyatech.com/wp-content/uploads/2012/08/SharpLCD_BreakOutA1.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0bKxA.png&quot; alt=&quot;Sharp LCD Breakout A1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and &lt;a href=&quot;http://kuzyatech.com/wp-content/uploads/2012/09/DipTrace-Schematic-072012_SharpLCD_BreakOut_A2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;A2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EFj6b.png&quot; alt=&quot;Sharp LCD Breakout A2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in short, either purchase a breakout board, or make one. Once you have done that , you can use the &lt;a href=&quot;http://code.google.com/p/arduino-sharp-memory-lcd-gfx-library/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CraftyCoders Arduino Library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-03-24T15:52:40.857" LastActivityDate="2015-03-24T15:52:40.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9562" PostTypeId="2" ParentId="9558" CreationDate="2015-03-24T17:39:16.570" Score="0" Body="&lt;p&gt;So your question is: &quot;How to control a bigger power source using the Arduino Nano or Micro&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This tutorial on youtube gives an explanation:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=sOz41WQF7wE&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=sOz41WQF7wE&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's about a motor, but the answer is the same.&#xA;You should use a relais/mosfet&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one is actually pretty great also:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=Te5YYVZiOKs&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=Te5YYVZiOKs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-03-25T18:25:02.223" LastActivityDate="2015-03-25T18:25:02.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9563" PostTypeId="1" CreationDate="2015-03-24T19:17:43.060" Score="2" ViewCount="88" Body="&lt;p&gt;I know that the Arduino Nano cannot source more than 40ma per pin. My question is there any type of motor or continuous rotation servo that I could use four of to make a robot without making the Nano shutdown. I would prefer the price to not exceed $10 in total.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-11-21T00:19:17.747" Title="Arduino Nano Max Current Draw best Motors" Tags="|arduino-nano|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9564" PostTypeId="2" ParentId="9558" CreationDate="2015-03-24T20:18:06.140" Score="1" Body="&lt;p&gt;A relay is a common way to allow a smaller power source to safely control a larger one. A relay is like a switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some &lt;a href=&quot;https://learn.adafruit.com/adafruits-raspberry-pi-lesson-13-power-control/hardware&quot; rel=&quot;nofollow&quot;&gt;reference material&lt;/a&gt; about using a relay with a microcontroller. You shouldn't have much trouble finding more material now that you know what you're looking for. &lt;/p&gt;&#xA;" OwnerUserId="3671" LastActivityDate="2015-03-24T20:18:06.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9565" PostTypeId="2" ParentId="9547" CreationDate="2015-03-24T20:51:51.210" Score="4" Body="&lt;p&gt;For generating g-code from an SVG, you could try to parse the SVG into a set of relative commands, and using the relative commands to generate G-code. Since you were originally using the frame as a 3d printer and now you want to use this as a CNC machine, you could try to invert the data. But, for generating the code I would go read up on how to parse the various file formats, and read the specs on each of the formats. However, most of the file formats you listed are proprietary, and you won't be able to find an open spec for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the formats that you listed, it would probably be the easiest to parse the SVG, as it's an open spec, and is a lot like XML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is going to be really difficult to actually do, because you're essentially reimplementing a full CNC controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would start with getting 2 dimensional stuff down like drawing shapes and setting routing depth.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Some Resources&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Here are some resources that might help you with parsing the various file formats. I only listed the ones that have an open standard.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.w3schools.com/svg/default.asp&quot; rel=&quot;nofollow&quot;&gt;http://www.w3schools.com/svg/default.asp&lt;/a&gt;&lt;br&gt;&#xA;This link describes the SVG format, and it does a fairly decent job at it.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/G-code&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/G-code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/STL_%28file_format%29&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/STL_%28file_format%29&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4883" LastActivityDate="2015-03-24T20:51:51.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9566" PostTypeId="2" ParentId="9511" CreationDate="2015-03-24T20:53:31.053" Score="1" Body="&lt;p&gt;I think Arduino's version history is a bit confusing. I'm not an expert but I think this explanation will help. First let's note that version 1.6 was released 2015.02.09. However, back in 2012, version 1.5 BETA was created and it remained in beta for several years. Meanwhile, the 1.0.X version evolved independently here's an excerpt from the changelog&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ARDUINO 1.0.6 - 2014.09.16&lt;/li&gt;&#xA;&lt;li&gt;ARDUINO 1.0.5-r2 - 2014.01.08&lt;/li&gt;&#xA;&lt;li&gt;ARDUINO 1.0.5 - 2013.05.15&lt;/li&gt;&#xA;&lt;li&gt;ARDUINO 1.0.4 - 2013.03.11&lt;/li&gt;&#xA;&lt;li&gt;ARDUINO 1.0.3 - 2012.12.10&lt;/li&gt;&#xA;&lt;li&gt;ARDUINO 1.0.2 - 2012.11.05&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you can see that 1.0.6 isn't as old as one may think. Many vendors probably chose not to develop their products against the 1.5 version (or branch) because of its beta status. 1.5 being in beta for as long as it did lends to a confusing version history. I did get the impression that LightBlue Bean is working on compatibility with 1.6.x because their getting started page mentions&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Download and extract the Arduino app, version 1.0.5. We currently do not support newer versions of the Arduino IDE.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3671" LastActivityDate="2015-03-24T20:53:31.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9567" PostTypeId="1" AcceptedAnswerId="9584" CreationDate="2015-03-24T21:13:29.383" Score="2" ViewCount="641" Body="&lt;p&gt;If I had four of these &lt;a href=&quot;http://www.ebay.com/itm/10pcs-Nidec-1-5V-DC-20-200mA-Micro-DC-motor-High-speed-Low-noise-Mini-dc-motor-/221718326366&quot; rel=&quot;nofollow&quot;&gt;motors&lt;/a&gt; and attached them to the Arduino Nano on four separate digital pins or analog pins without transistors and a 9v power supply attached to the regular power supply input would that work? &lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-03-25T09:00:41.407" Title="Arduino Nano Motor" Tags="|motor|arduino-nano|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9568" PostTypeId="2" ParentId="9549" CreationDate="2015-03-24T22:05:10.230" Score="1" Body="&lt;p&gt;It is very difficult to accurately control timings with &lt;code&gt;delay()&lt;/code&gt;,&#xA;because you have to account for the time needed to execute the rest of&#xA;the code, including interrupts. You can easily have better accuracy by&#xA;using &lt;code&gt;millis()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;static unsigned long last_step_time;&#xA;unsigned long now = millis();&#xA;if (now - last_step_time &amp;gt;= step_delay) {&#xA;    do_one_step();&#xA;    last_step_time += step_delay;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is almost what you have commented out in your own code, except that&#xA;&lt;code&gt;millis()&lt;/code&gt; should be called only once per iteration, hence the &lt;code&gt;now&lt;/code&gt;&#xA;variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may still have less than perfect accuracy due to your clock source.&#xA;If your Arduino is clocked from a quartz you should be able to get&#xA;decent timing accuracy. If it is clocked from a ceramic oscillator you&#xA;are out of luck. In any case, you can always improve the accuracy by&#xA;calibrating your clock: you measure its drift and correct for it in&#xA;software. Then you have only to worry about thermal fluctuations of the&#xA;clock frequency, which should not be an issue with a quarts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For best accuracy, you can use either an RTC or a watch crystal&#xA;connected directly to your ATmega chip. This last solution is only&#xA;possible if you go for a bare microcontroller, without the Arduino&#xA;board. See &lt;a href=&quot;https://arduino.stackexchange.com/a/9039&quot;&gt;this answer&lt;/a&gt;&#xA;for more details about this option, as well as the way to correct&#xA;for the drift in software.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-03-25T09:16:43.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9569" PostTypeId="2" ParentId="8599" CreationDate="2015-03-24T22:36:53.977" Score="1" Body="&lt;p&gt;This is only a partial answer, but should be enough to get you started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parts are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Build a receiver &lt;a href=&quot;http://www.somerset.net/arm/fm_only_lowtech.html&quot; rel=&quot;nofollow&quot;&gt;http://www.somerset.net/arm/fm_only_lowtech.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tune it to the right frequency&lt;/li&gt;&#xA;&lt;li&gt;Use it to detect the codes sent from your remote&lt;/li&gt;&#xA;&lt;li&gt;Build a transmitter &lt;a href=&quot;http://makezine.com/projects/super-simple-fm-transmitter/&quot; rel=&quot;nofollow&quot;&gt;http://makezine.com/projects/super-simple-fm-transmitter/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tune it to the right frequency&lt;/li&gt;&#xA;&lt;li&gt;Transmit the codes&lt;/li&gt;&#xA;&lt;li&gt;Success!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Step 3 is probably best done with a scope - you should find someone who has one, who can operate it, because they can be damaged.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-24T22:36:53.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9570" PostTypeId="1" CreationDate="2015-03-24T23:05:43.773" Score="5" ViewCount="6294" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2kYvA.jpg&quot; alt=&quot;enter image description here&quot;&gt;I would like to make a sensor that detects when my car is clear of a certain point. So, when backing in my car to my garage, I would have a beam and sensor. When the beam is broken, an LED light would turn on and then when the beam gets through, the light turns off and I know that the car will clear the garage door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pretty sure I have to use either an Arduino or Raspberry Pi, but I'm completely new to home automation. There are a few other things I'd like to do but this is a good starter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know where to start.&lt;/p&gt;&#xA;" OwnerUserId="8054" LastEditorUserId="26717" LastEditDate="2017-05-13T11:13:31.600" LastActivityDate="2017-05-13T11:13:31.600" Title="How can I make a garage door laser sensor?" Tags="|sensors|led|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9571" PostTypeId="1" CreationDate="2015-03-24T23:13:23.127" Score="1" ViewCount="27204" Body="&lt;p&gt;I'm trying to get the ESP8266 up and running without a FTDI chip, just my Arduino Uno. But it seems really difficult. What I did:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;attach the ESPs VCC directly to Arduino Uno 3.3V; RX-&gt;TX; TX-&gt;RX &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Result: surprisingly worked for 2 mins, however the AT commands returned ERROR sometimes. (baud rate: 9600)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;attach the ESPs VCC to 3.3V 500mA power supply; RX-&gt;TX; TX-&gt;RX&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Result: AT commands don't work anymore, nothing is displayed in the serial monitor, not even my input; red LED constantly on.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;attach the ESPs VCC to 3.3V 500mA power supply; TX-&gt;TX; RX-&gt;RX&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Result: blue LED constantly on, no response, same as before&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;change back RX/TX connection, experimenting with baud rate (300 - 115200)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Result: blue LED flashes on start, flashes when something is sent (no matter what the baud rate is), however still no output at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suddenly, I was also getting this error while uploading:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ser_recv(): programmer is not responding&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Detaching the TX connection solved the problem. Btw, I am also using a voltage divider between TX of the Arduino and RX of the ESP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Afterwards, the blue LED was on constantly again, even though I haven't changed the wiring... (really weird)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me it looks like the Arduino Serial monitor isn't sending anything, because I don't even see my input. However, the Arduino can output stuff, therefore I assume a connection between Arduino and PC is existing. Maybe it has to do with the connection between TX -&gt; RX, but I see no shorts, just an ordinary voltage divider (100 Ohm and 200 Ohm resistors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you might see, I spent a lot of time trying to figure this out. I'm kind of stuck now, as I'm not sure what else to try. If you have any ideas, tips or advice please leave an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for my English, it's not my native language. If you don't understand something, feel free to ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope you can help me!&lt;/p&gt;&#xA;" OwnerUserId="8053" LastActivityDate="2017-06-03T08:02:13.583" Title="ESP8266 + Arduino Uno: Can't send AT Commands" Tags="|arduino-uno|serial|wifi|esp8266|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9572" PostTypeId="2" ParentId="9570" CreationDate="2015-03-24T23:37:30.933" Score="1" Body="&lt;p&gt;I am pretty sure that Arduino would be enough for this project since the proper computation should not be that complex. Arduino Uno seems to be the simplest to start, at the same time not being too big for your application domain. However, you could also consider some smaller Arduino model, there would not be any &quot;computational power&quot; problem probably. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use an &lt;a href=&quot;https://www.sparkfun.com/products/8958&quot; rel=&quot;nofollow&quot;&gt;Infrared Proximity Sensor&lt;/a&gt; to check whether a car is present or not, here is a link that could be useful for this: &lt;a href=&quot;http://arduinomega.blogspot.it/2011/05/infrared-long-range-sensor-gift-of.html&quot; rel=&quot;nofollow&quot;&gt;http://arduinomega.blogspot.it/2011/05/infrared-long-range-sensor-gift-of.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this way, the system would light ON one or more LED(s) whenever the measured distance turns out to be less than some threshold value that you decide (maybe using a test-driven approach), and then light it/them OFF once the distance returns over the fixed threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="7741" LastActivityDate="2015-03-24T23:37:30.933" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9573" PostTypeId="2" ParentId="9570" CreationDate="2015-03-25T00:13:53.400" Score="0" Body="&lt;p&gt;You want a light sensor like at &lt;a href=&quot;http://rookieelectronics.com/light-sensor-using-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://rookieelectronics.com/light-sensor-using-arduino/&lt;/a&gt; - the usual way is infrared (same as remote controls), so you can't see it. You might want to blink the light, to get a more accurate signal (i.e. turn the led on; test the brightness; turn it off; test the brightness; find the difference) in different light conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would probably use a &lt;a href=&quot;http://www.dx.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696#.VRH9k3WjlIc&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696#.VRH9k3WjlIc&lt;/a&gt; Ultrasonic distance sensor - but there are lots of ways to accomplish this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not an Arduino answer, but.... a friend of mine put his car in the exact place it should be, then hung a tennis ball from the roof, at the right place so it just touches the windscreen. Now, when he pulls into the car, he moves forward until the tennis ball touches his windscreen, and he knows he's in exactly the right place.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-25T00:13:53.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9574" PostTypeId="2" ParentId="1546" CreationDate="2015-03-25T02:00:34.173" Score="0" Body="&lt;p&gt;I have a similar circuit (running a 7-segment display); I don't use reset, and for something like this (since the only state it keeps is reset on sending of new data, which is every frame).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For debugging, I would suggest seeing if there are any patterns. For example, if it doesn't happen on LEDs controlled by the first shift register, then it's likely to be due to the connection between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try seeing if a pulldown resister (try &gt;10kOhm) between the data pin and ground has an effect, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get really desperate, it might be worth getting an oscilloscope - see what is actually happening on the wire.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-25T02:00:34.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9575" PostTypeId="2" ParentId="8651" CreationDate="2015-03-25T02:04:00.540" Score="2" Body="&lt;p&gt;As far as I know, you can include your libraries from a custom location by using their absolute path. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since absolute paths could be boring from a code-portability point of view, you could define some macros to get the absolute path from a given relative one. In this way, you would just have to fix the 'project root' path when passing from a device to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Define your project's root folder : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define PROJECT_ROOT C:\path\to\your\project\folder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Define a relative-to-absolute macro 'transformation' : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define TO_STRING(s) #s&#xA;    #define ABSOLUTE_PATH(root, relative_path) TO_STRING(root\relative_path)&#xA;    #define RELATIVE_PATH(library) ABSOLUTE_PATH(PROJECT_ROOT, library)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Include your files using the relative path :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include RELATIVE_PATH(some\file\relative\path.h)&#xA;    #include RELATIVE_PATH(another\file\relative\path.h)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope it will be useful.&lt;/p&gt;&#xA;" OwnerUserId="7741" LastActivityDate="2015-03-25T02:04:00.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9576" PostTypeId="2" ParentId="9553" CreationDate="2015-03-25T02:36:43.780" Score="0" Body="&lt;p&gt;Usually, these usb dongles consist of two parts: the usb part, and the gsm part. If you can find the spec on the gsm chip, you might be able to bypass the usb part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, these circuits are usually surface mount - tiny pins, tiny traces, and lots of them. Soldering them will probably be tricky.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-25T02:36:43.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9577" PostTypeId="2" ParentId="9570" CreationDate="2015-03-25T02:46:17.950" Score="5" Body="&lt;p&gt;I would recommend using laser and &lt;a href=&quot;http://en.wikipedia.org/wiki/Photoresistor&quot;&gt;LDR&lt;/a&gt;. This will be very efficient and will not cause any problem due to light or ultrasonic deflecting. It will be precise by mm if you do thing right way. I made a simple porject back in 2005 using laser, LDR and relay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here what you need to do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get a laser, any laser will work. www.ebay.com/itm/6mm-650nm-DC-5V-5mW-Mini-Laser-Dot-shaped-Diode-Module-WL-Red-Copper-Head-Tube-/291089398593?pt=LH_DefaultDomain_2&amp;amp;hash=item43c647bb41&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get a PhotoResgister www.ebay.com/itm/Reliable-Hot-New-20-PCS-Photoresistor-GL5528-LDR-Photo-Resistors-Light-Dependent-/161434780484?pt=LH_DefaultDomain_2&amp;amp;hash=item2596434344&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put ldr in the dark box and drill a hole in it so that no other light can enter 2mm diameter hole will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the LRD to your board. Fire laser and change status of indicator led by the value of ldr. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check this link for refrence www.instructables.com/id/Arduino-Laser-Tripwire/?ALLSTEPS&lt;/p&gt;&#xA;" OwnerUserId="8058" LastActivityDate="2015-03-25T02:46:17.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9578" PostTypeId="1" CreationDate="2015-03-25T02:59:14.530" Score="0" ViewCount="185" Body="&lt;p&gt;My robot uses an Arduino Mega 2560. It has 6 IR receiver modules connected to its 6 external pins namely 2, 3, 18, 19, 20, and 21.I have connected the Pololu MC33926 dual motor driver arduino shield to my arduino(here is the connections diagram : &lt;a href=&quot;https://www.pololu.com/docs/0J55/3.c&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/docs/0J55/3.c&lt;/a&gt; ). I generate a 56KHz IR signal with an LED from another Arduino. The IR receiver modules convert the 56KHz signal into a active low digital signal. My signal consists of a signature bit followed by 32 bits of data. a binary 1 is represented by a signal of length 1200 uS and a binary 0 is represented by a 600uS signal with intervals of 600uS. I employed a state machine in my code which checks the duration of time between falling edge and rising edge. and vice versa and compares it to the duration expected. If anything is not expected it discards as noise and goes back to the idle state. If the duration is as expected it goes to the next state and then takes in the entire 32 bits and converts this binary format into a decimal value. I print this value on a 7 segment display on my robot. It works perfectly when the motor's are not running.&#xA;      Now this is the case when the motors are running. It does not receive the signal. I have tested every component individually and these are the results:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The receivers still receive the signal perfectly, and their output to the Arduino is also as expected. No problem there.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Earlier the Arduino was being powered through the Motor driver. Just to make sure that was not the problem I separated the Arduino's power supply from that of the motor driver. Still the same issue, i.e. the robot does not receive a valid signal(at this point i realized the arduino receives a valid signal but isnt able to decode it accurately).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We then printed out the values of time differences between each rising and falling edge on the interrupt pins. These values seem correct and within the tolerance range when the motors are switched off. But when the motors are switched on these values are not right. Of the 32 duration's measured, atleast two are not right(for eg. instead of 300 uS it calculated 88uS) due to which the signal is being discarded as invalid.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I thought that the PWM being generated to control the speed of the motors on digital pin 9 and digital pin 10(OC2B AND OC2A). Even though the PWM signals were being generated(without the motors connected) the signal was still being read as valid and the robot was receiving the signal. So its not that either.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The only anomaly I have found are the readings of the durations of the interrupt intervals. Can somebody please tell me what connection I have done wrong. Its mostly not with the program since it works otherwise. Something with the motor is making the Arduino act weirdly. Any help will be greatly appreciated. I have to scale up these robots to build a swarm and I am still stuck in the first step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;" OwnerUserId="8059" LastActivityDate="2016-01-20T08:07:21.987" Title="motor affecting time calculation between hardware interrupts" Tags="|motor|hardware|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9579" PostTypeId="2" ParentId="1546" CreationDate="2015-03-25T04:22:09.937" Score="1" Body="&lt;p&gt;I have had a similar issues when building &lt;a href=&quot;http://www.instructables.com/id/Led-Cube-8x8x8/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this instructable&lt;/a&gt;, a 8x8x8 LED cube. Lighting up some of the LEDs caused wrong LEDs to light up simultaneously, even though according to the circuit diagram they where not suppose to. The wrong LEDs that lighted up seemed to be random, though it was reproducible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The root cause was, after some debugging using a Multimeter's continuity test, that some of the LEDs legs where touching in places they shouldn't, and so the current was flowing where it was not supposed to flow. I strongly recommend to investigate that direction, verifying that Ground paths and Vcc paths are properly isolated from each other. This should be easier to do with a 5x5x5 cube.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the delay - I suggest you'll take a look at the Arduino code in that instructable - it seems that between the different layers, the code does not use any delay, only between effects. The final result seems to works great.&lt;/p&gt;&#xA;" OwnerUserId="630" LastActivityDate="2015-03-25T04:22:09.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9580" PostTypeId="2" ParentId="9578" CreationDate="2015-03-25T06:03:57.900" Score="1" Body="&lt;p&gt;Noise from electromagnetic sources is always an important issue that must be addressed. The aims are to minimise noise generation at source, reduce transmission of noise between source and the &quot;target&quot; affected circuitry and reduce noise impact at the target. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.pololu.com/file/download/dual_mc33926_shield_schematic.pdf?file_id=0J559&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Motor controller circuit diagram here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield power supply link MUST have been removed.&lt;br&gt;&#xA;Shield must have all own powering.&lt;br&gt;&#xA;Coupling via a common eg 5V supply has a high chance of being problematic.&lt;br&gt;&#xA;The two 5V supplies (arduino &amp;amp; shield) could have a common higher voltage source but need separate regulators and proper noise removal in each supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Placing extra capacitance across the arduino Vin or main power source MAY help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that the motors are driven in either direction during operation. If not then a reverse diode across the motors should help.&lt;br&gt;&#xA;If bidirectional,  try reversed diodes from each motor lead to Vout (= V+ motor drive voltage).   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield's Vout filter capacitors C7 &amp;amp; C8 care 47 uF each.&lt;br&gt;&#xA;Vout could usefully have 1000 or so uF added somewhere on the board.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know how much motor current is drawn and exact control strategy. This MAY interfere with motor drive but probably not: Identify one motor which &quot;has issues&quot;. Add a small series resistance in each lead with a capacitor across the leads on the motor side. Here &quot;small&quot; means &quot;does not noticeably affect performance&quot;. eg 1 Ohm if Imotor &amp;lt; to &amp;lt;&amp;lt; 1 amp. Capacitor needs to be biplar for bidirectional motor control - eg a 1 uF ceramic or plastic (polyester, mylar, ...) cap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;'If all else fails'[tm] opto coupling the driver interface is possible BUT should not be needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try above.&lt;br&gt;&#xA;Report.&lt;br&gt;&#xA;Ask more questions if needed. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-03-25T06:03:57.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9581" PostTypeId="1" AcceptedAnswerId="17622" CreationDate="2015-03-25T08:12:37.753" Score="3" ViewCount="1561" Body="&lt;p&gt;I am trying to solve the following scenario:&#xA;Lilypad USB connected to WIFI through ESP8266 Serial WiFi Module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardLilyPadUSB&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardLilyPadUSB&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the wiki:&#xA;I should connect to TX RX pins. None of them are present as &quot;selectable pins&quot;, because they are built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This post &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=245169.0&quot; rel=&quot;nofollow&quot;&gt;Using LilyPad Arduino USB with LilyPad Xbee Shield &lt;/a&gt; talks about using SoftwareSerial something that is new to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone explain how should I proceed with the wiring and if possible a sample sketch just to connect the lilypad usb with the WIFI module to my personal WIFI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following &lt;a href=&quot;http://www.prometec.net/arduino-wifi/&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; (spanish one but easy to follow...) where they use the Arduino UNO. I tried the example with the software serial and it worked. &#xA;I saw in that tutorial sometimes the pin RST is needed. So I tried to do the same with the lilypad USB, but still didn't work.&lt;/p&gt;&#xA;" OwnerUserId="3840" LastEditorUserId="653" LastEditDate="2015-10-03T05:02:21.150" LastActivityDate="2018-07-09T16:33:34.303" Title="Wiring Lilypad USB + ESP8266 Serial WiFi Module" Tags="|wifi|wires|esp8266|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9584" PostTypeId="2" ParentId="9567" CreationDate="2015-03-25T09:00:41.407" Score="1" Body="&lt;p&gt;Yes, but don't expect to win any races.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;analogWrite(HIGH)&lt;/code&gt; on your digital pins (3, 5, 9, 10, and 11) your motors should receive 40 mA max at 5V (see &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/arduinoBoardNano&lt;/a&gt;). So the motors will run, just not very fast. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/&quot; rel=&quot;nofollow&quot;&gt;switching transistor&lt;/a&gt; would be a very simple addition that would allow you to achieve higher current input to the motors and get their full potential. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to reverse the direction of the motors you'll need to investigate getting a &lt;a href=&quot;https://www.pololu.com/product/2130&quot; rel=&quot;nofollow&quot;&gt;cheap motor driver board&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4385" LastActivityDate="2015-03-25T09:00:41.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9585" PostTypeId="2" ParentId="455" CreationDate="2015-03-25T12:07:36.683" Score="0" Body="&lt;p&gt;I had the same issue on my laptop (win 7, 64). Renaming file ListComPorts.exe to ListComPorts.exe.xxx as mentioned above worked. I also had to switch to a standard USB port (not 2.0) for sketch to load properly. &lt;/p&gt;&#xA;" OwnerUserId="8068" LastActivityDate="2015-03-25T12:07:36.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9586" PostTypeId="1" AcceptedAnswerId="9615" CreationDate="2015-03-25T12:54:07.843" Score="0" ViewCount="233" Body="&lt;p&gt;I created a function that saves the timestamp in a text file, but it saves unreadable. Full of invalid characters, example: &lt;strong&gt;Ÿ@Â   O   ƒº!¥ Ÿ@Â   O   ƒº!¥ Ÿ@Â   O   ƒº!¥ Ÿ&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_Millis rtc;&#xA;File txt;&#xA;const char * getCurrentTimestamp()&#xA;{&#xA;    char dateBuffer[40];&#xA;    DateTime now = rtc.now();&#xA;    sprintf(dateBuffer,&quot;%02u-%02u-%04u %02u:%02u:%02u&quot;, now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second());&#xA;    return dateBuffer;&#xA;}&#xA;&#xA;void saveLog()&#xA;{&#xA;  txt = SD.open(&quot;dados.txt&quot;, FILE_WRITE);&#xA;  txt.print(getCurrentTimestamp());&#xA;  txt.close();&#xA;}&#xA;&#xA;void setup() {&#xA;  pinMode(53, OUTPUT);&#xA;  SD.begin(4); &#xA;  Serial.begin(9600);&#xA;  rtc.begin(DateTime(F(__DATE__), F(__TIME__)));&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(getCurrentTimestamp());&#xA;  saveLog();&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My code is very simple, do not understand where I went wrong. if I copy the following code snippet for &lt;strong&gt;saveData()&lt;/strong&gt; function and save the &lt;strong&gt;dateBuffer&lt;/strong&gt; variable, everything works normally.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char dateBuffer[40];&#xA;DateTime now = rtc.now();&#xA;sprintf(dateBuffer,&quot;%02u-%02u-%04u %02u:%02u:%02u&quot;, now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how to save the timestamp correctly in the file through the function &lt;strong&gt;getCurrentTimestamp()&lt;/strong&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-03-26T15:17:55.300" Title="Error while saving data in text file" Tags="|arduino-mega|sd-card|rtc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9587" PostTypeId="1" AcceptedAnswerId="12142" CreationDate="2015-03-25T13:39:07.620" Score="1" ViewCount="992" Body="&lt;p&gt;I was thinking about building a video circuit that uses two Arduinos (maybe more) to generate video using &lt;code&gt;NTSC&lt;/code&gt; and the &lt;code&gt;AD725&lt;/code&gt;.  Although, VGA might be nice if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the idea is to use one Arduino as the background layer and the other one as the sprite layer (overlay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, instead of masking the sprite data and having more cpu time, I was thinking of running the signals through a mux.  So that when drawing background data and no sprites (per scanline) then pipe the signal to the AD725.  But when there is a sprite mid-line, then the &gt;0v signal of the sprite Arduino would cause the mux to pipe its contents through to the AD725.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, something similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe many arcade boards from the 80's did this.  Many of them had entire &quot;sprite boards&quot; attached and the signals would mix.  Each layer would have it's own RAM and not be aware of the other layer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to do this, I would have to keep the Arduinos sync'd perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's my question.  How I can do this?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, my Arduino of choice in the beginning would be the UNO but I have others (DUE, Teensy3.1, etc.) if that would be a better fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="6883" LastActivityDate="2015-05-26T03:17:05.110" Title="How can I run two Arduinos in sync for video generation?" Tags="|arduino-uno|timing|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9588" PostTypeId="2" ParentId="5163" CreationDate="2015-03-25T14:41:44.547" Score="0" Body="&lt;p&gt;Maybe this similar post is what you are looking for. In your case, you should use the path to the sketch folder as 'PROJECT_ROOT'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the link:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/a/9575/7741&quot;&gt;https://arduino.stackexchange.com/a/9575/7741&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="7741" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-03-25T14:41:44.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9589" PostTypeId="1" CreationDate="2015-03-25T16:32:38.707" Score="1" ViewCount="6817" Body="&lt;p&gt;I'm making a project and i'm trying to send bits from an Arduino to another Arduino with the digital pins. So my setup are 2 Arduino's connected with a jumper.&#xA;I connected the grounds and they have both a different power supply.&#xA;Now I tried this set-up and as soon as I connect the output pin to the input pin from the other Arduino the voltage lowers from 5V to 2.6V so we can't detect our bits.&#xA;Anybody an idea how to solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kind regards,&#xA;Manu&lt;/p&gt;&#xA;" OwnerUserId="8126" OwnerDisplayName="Manu Pepermans" LastActivityDate="2015-05-27T18:31:41.353" Title="Connect the output of an Arduino to the input from another Arduino" Tags="|communication|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9591" PostTypeId="2" ParentId="9589" CreationDate="2015-03-25T20:13:00.963" Score="0" Body="&lt;p&gt;I would suggest sticking a transistor in between - use a layout like &lt;a href=&quot;http://en.wikipedia.org/wiki/Transistor#/media/File:Transistor_Simple_Circuit_Diagram_with_NPN_Labels.svg&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Transistor#/media/File:Transistor_Simple_Circuit_Diagram_with_NPN_Labels.svg&lt;/a&gt; (from the wiki page on transistor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Vout should be connected to the input pin on one arduino, and Vin should connect, via a resistor, to the output pin on the other arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to confirm, the labels are reversed from what you will expect them to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2 resistors can be anything &gt; 1kOhm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This still depends on the common ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that common ground may not be a good idea if they are generated from the same power source - I've found ground from two USB ports on the same laptop to be at different levels, so current will flow out from one port, and in the other, probably damaging the laptop, if the two grounds are connected.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-25T20:13:00.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9592" PostTypeId="1" AcceptedAnswerId="9594" CreationDate="2015-03-25T20:25:44.453" Score="1" ViewCount="194" Body="&lt;p&gt;I could define myself as a &quot;nerdy cyclist&quot;, so while my interest in Arduino is steadily growing (have not bought or used yet), my first idea for a project would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Instrument a bicycle with some sensors (accelerometer, reed switch, etc) and an Arduino;&lt;/li&gt;&#xA;&lt;li&gt;Ride long distances (that is, four hours or more, sometimes non-stop);&lt;/li&gt;&#xA;&lt;li&gt;When at home, download some sort of &quot;data file&quot; (from SD card, I think);&lt;/li&gt;&#xA;&lt;li&gt;Analyze results with Python/Matlab/whatever.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So my questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is any model of Arduino suitable for this purpose?&lt;/li&gt;&#xA;&lt;li&gt;What is the expected sample rate vs number of channels? 100Hz per channel would be excellent for my purposes, for example.&lt;/li&gt;&#xA;&lt;li&gt;Can I keep incrementally saving to SD &quot;forever&quot; (that is, while battery and card space are available)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="10794" LastEditDate="2015-09-06T08:58:44.827" LastActivityDate="2015-09-06T08:58:44.827" Title="Possibilities and limitations for onboard data acquisition" Tags="|datalogging|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9593" PostTypeId="2" ParentId="9587" CreationDate="2015-03-25T20:44:46.113" Score="0" Body="&lt;p&gt;You would need to use interrupts on the &quot;sprite arduinos&quot; to get the timing very exact - the &quot;background&quot; arduino would need to send signals sync signals (horizontal and vertical) to the sprite arduinos. The sprite arduinos would then need to keep track of which line it is on, and time exactly how far along the line it is. You will need a circuit to either allow the incoming signal through (I believe the arduino will be too slow to pass it read it, then write it); &lt;/p&gt;&#xA;&#xA;&lt;p&gt;alternatively, have multiple (still synchronized) sources, each indicating if they want to be on the screen; then one that takes the &quot;I want to be on the screen&quot; signals, make a decision, and connect the appropriate one (via a transistor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A basic tutorial on TV out is found at:&#xA;&lt;a href=&quot;http://playground.arduino.cc/Main/TVout&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/TVout&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-03-25T20:44:46.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9594" PostTypeId="2" ParentId="9592" CreationDate="2015-03-25T21:19:18.093" Score="1" Body="&lt;p&gt;First of all your idea project is feasible. And to answer to your questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;There is no right Arduino for your project simply because theoretically every Arduino board can do the job. But as you said it has to be portable you might use Arduino nano/mini or even Uno if you have enough room or space.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The acquisition rate depends on the on the type of sensor you have. So if you have let's say one analog reading you can use the built in function in Arduino which is capable of making about 10000 readings at time. So if you have multiple outs you can easily for the calculation. There are also sensors which has a digital output in this case in order to read your value you communicate with Tue sensor board through Two wire interface or I2C communication interface, for this there is a library you can use. Usually the speed at which this communication work s very high, at 100kHz( if I'm not wrong).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3.Yes you can save data on the SD card until you don't exceed the memory or the battery doesn't die.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have a suggestion for your project, as you're going to acquire some sort of data and then analyze it on your computer, do less calculations on your Arduino board and let the PC handle the hard work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Useful links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reference to the two wire communication: &lt;a href=&quot;http://arduino.cc/en/reference/wire&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/reference/wire&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reference to the SD card reading on Arduino: &lt;a href=&quot;http://arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/SD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8075" LastEditorUserId="5168" LastEditDate="2015-03-26T19:59:37.913" LastActivityDate="2015-03-26T19:59:37.913" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9595" PostTypeId="2" ParentId="9589" CreationDate="2015-03-25T22:02:11.397" Score="2" Body="&lt;p&gt;As you are trying to communicate with two arduinos I will suggest you to use some sort of standard communication protocol such as Two wire interface or I2c. There is the Wire.h library you can use and it has also a reference on the main Arduino site. If you have different necessity and want to carry on with you're methods you need to specify in more depth the connections you have made. As for now I can guess that the output is being connected to ground or some sort of load and that might be the reason you are seeing a drop out of voltage. But it might be also the case that you're output pin is changing so fast that the multimeter is not capable of reading the high state correctly&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-25T22:02:11.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9596" PostTypeId="2" ParentId="9570" CreationDate="2015-03-25T22:27:08.217" Score="1" Body="&lt;p&gt;I cant make out from the picture if you have consider this thought.&#xA;Install sensor at height so car tail breaks the beam.&#xA;Also It might not be ideal solution if you have multiple car lets say one Range rover SUV and another hatchback. &#xA;You might want to consider having multiple sensor from ground to around 4-5 feet.&lt;/p&gt;&#xA;" OwnerUserId="8076" LastActivityDate="2015-03-25T22:27:08.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9597" PostTypeId="2" ParentId="9592" CreationDate="2015-03-25T22:33:19.643" Score="0" Body="&lt;p&gt;Another idea - &#xA;I believe if you are making electronics you must be using some smart phone?&#xA;If I am correct why don't u utilize your smart phone with Arduino?&#xA;1) Connect sensors to Arduino&#xA;2) Use Bluetooth or WiFi shield &#xA;3) Store data locally until memory available&#xA;4) Transfer to your phone or to web via phone network every hour or 5 hours.&#xA;This will make battery consumption less and also make device Compaq. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Pathik SHAH&lt;/p&gt;&#xA;" OwnerUserId="8076" LastActivityDate="2015-03-25T22:33:19.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9598" PostTypeId="2" ParentId="9587" CreationDate="2015-03-25T22:43:45.310" Score="1" Body="&lt;p&gt;I would take a look at MREtv which seems to promise all that you want to do, with just one arduino. This might not be the answer you're looking for, but getting threads to sync is a pain in the rear end, see &lt;a href=&quot;http://thecodelesscode.com/case/121?topic=threads&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; for explanation of why threads are a pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now back on topic, it seems like MRETV might off what you want to do, and it can do some pretty impressive things from what I read in the arduino. You might need to modify the library a bit, but it offers already implemented encoding, so that is a plus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/MRETV-Video-Stereo-Sound-and-much-more-from-a-s/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/MRETV-Video-Stereo-Sound-and-much-more-from-a-s/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4883" LastActivityDate="2015-03-25T22:43:45.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9599" PostTypeId="2" ParentId="9589" CreationDate="2015-03-25T23:04:36.403" Score="1" Body="&lt;p&gt;As Harry mentioned better to use some communication lines like UART or I2C or SPI.&#xA;If you dont have them available then use digital i/os but make sure their pull up and pull down resistors are correctly configured. If it is input just set as pull up and for output set as output pin. &#xA;Regards,&#xA;Pathik&lt;/p&gt;&#xA;" OwnerUserId="8076" LastActivityDate="2015-03-25T23:04:36.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9600" PostTypeId="2" ParentId="9587" CreationDate="2015-03-26T01:19:27.540" Score="0" Body="&lt;p&gt;Just a thought, you could try synchronizing micros() / millis() between Arduinos... [ &lt;a href=&quot;https://aaka.sh/patel/2013/12/23/synchronizing-micros-millis-arduino/&quot; rel=&quot;nofollow&quot;&gt;https://aaka.sh/patel/2013/12/23/synchronizing-micros-millis-arduino/&lt;/a&gt; ]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over time you could set instructions/commands to execute at certain time intervals on target arduinos using something as simple as a 2 wire serial setup  [ &lt;a href=&quot;http://arduino.cc/en/Tutorial/MasterReader&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/MasterReader&lt;/a&gt; ]&lt;/p&gt;&#xA;" OwnerUserId="8078" LastActivityDate="2015-03-26T01:19:27.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9601" PostTypeId="2" ParentId="9578" CreationDate="2015-03-26T01:20:24.760" Score="0" Body="&lt;p&gt;Thanks for the above answer. It got me thinking on the right track. After some reading through the motor driver data sheet I realized that I forgot totally about the by-pass capacitors. After connecting a 0.1uF cap between two terminals of the motors and another two between the terminals and the casing the results are much better. It can receive a valid signal from another robot(though not as well as when the motors are turned off). Any suggestions where else I could place by pass cap's to further eliminate electrical noise?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again,&#xA;Thanks a lot guys. &#xA;really appreciate the help.&lt;/p&gt;&#xA;" OwnerUserId="8059" LastActivityDate="2015-03-26T01:20:24.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9602" PostTypeId="1" CreationDate="2015-03-26T02:26:54.907" Score="4" ViewCount="894" Body="&lt;p&gt;Alright, so I have an Atmel 93C66, &lt;a href=&quot;http://www.atmel.com/Images/doc0172Z.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/Images/doc0172Z.pdf&lt;/a&gt; Datasheet and I'm wanting to read whatever is in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I copied the following code from this thread &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=96411.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=96411.0&lt;/a&gt; and made some changes to it, mainly I deleted the part where it writes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//difining pins for eeprom   &#xA;int CLOCK =4;          &#xA;int DATA_OUT =3;&#xA;int DATA_IN = 2;&#xA;int CHIP_SEL =5;&#xA;&#xA;int low =0;     //low address &#xA;&#xA;byte READ  = 0b1100;                //read instruction &#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(CLOCK ,OUTPUT);&#xA;  pinMode(DATA_OUT ,OUTPUT);&#xA;  pinMode(DATA_IN ,INPUT);&#xA;  pinMode(CHIP_SEL ,OUTPUT);&#xA;  digitalWrite(CHIP_SEL ,LOW);&#xA;  digitalWrite(CLOCK, LOW);&#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  for (int i=0;i&amp;lt;=511;i++)&#xA;  { &#xA;    digitalWrite(CHIP_SEL ,HIGH);&#xA;    shiftOut(DATA_OUT,CLOCK,MSBFIRST,READ); //sending READ instruction &#xA;    shiftOut(DATA_OUT,CLOCK,MSBFIRST,low);   //sending low address&#xA;    byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST); //receiving data&#xA;    digitalWrite(CHIP_SEL ,LOW);&#xA;&#xA;    Serial.print(low);&#xA;    Serial.print(&quot;/t&quot;);&#xA;    Serial.print(incoming, BIN);&#xA;    Serial.print(&quot;/t&quot;);&#xA;    Serial.print(incoming, HEX);&#xA;    Serial.println():&#xA;&#xA;    low++;       //incrementing low address&#xA;&#xA;  } &#xA;  while(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to understand is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the 93C66 datasheet page 5, table 6, it says that to read the contents of memory I need to send SB 1, OPCODE 10, and memory address, which I don't know exactly how to do, but I guess the chip wants a 110 (or a HIGH, HIGH, LOW signal) plus memory address (variable “low”=0). The SB and OP CODE are similar to the BYTE variable READ in the code above, but this variable has an extra 0 (1100). I tested the code with 110 and I get different incoming data. I also thought if BYTE is 8 bits then why not make the BYTE variable READ 11000000, but it changes the incoming data. So now I don't really know how exactly to send SB 1 and OP CODE 10. Need help with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as you can see I'm printing the variable &quot;low&quot; and the variable &quot;incoming&quot; (in Binary and Hex) on one line, I thought it would be printing 1 bit per line, but it prints varying amounts of bits. Sometimes it would print 4 bits, 6 bits, or 8 bits, as in 1110, 11111111, 111100. I thought the line &lt;code&gt;byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST);&lt;/code&gt;&#xA;would get filled with 8 bits all the time, so when I Serial.print() it would have 8 bits, but it's not happening, why? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I thought the shifting in of the bits into the variable &quot;incoming&quot; occurs once in the for loop, or is there an inner loop in shiftIn()? I ask because I first made the for loop go for i=&amp;lt;4095, since there are 4096 bits in this EEPROM, but the increment of I doesn’t match the amount of bits I’m getting on each Serial.print() line. &#xA;i.e. I would get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   10111111    BF &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought it would be getting something like this. (I’m thinking the shiftIn() of the 1st bit at address 0 happens when i=0, then 2nd bits gets shiftIn() when i=1, and so forth)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1   1   &#xA;2   1   &#xA;3   0&#xA;4   1&#xA;Etc, etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How is shiftIn() shiftinf in the bits into the BYTE variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks and sorry if it’s so many questions.&lt;/p&gt;&#xA;" OwnerUserId="2769" LastActivityDate="2017-10-08T08:50:24.980" Title="Trying to understand bitbanging, shiftIn(), reading EEPROM" Tags="|spi|eeprom|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9604" PostTypeId="1" AcceptedAnswerId="9605" CreationDate="2015-03-24T13:40:56.000" Score="-2" ViewCount="116" Body="&lt;p&gt;Experiencing that Mega 2560 uploading problem. Tried updating the IDE, worked for a while but symptoms went back. Now i want to reprogram that chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm asking this question cuz hardware ain't free and shipping is not instant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a programmer. So we already know that we can program an arduino board with another arduino board as a programmer. However i just have a Duemilanove available. Will this work? Please do not answer if you're not sure.&lt;/p&gt;&#xA;" OwnerUserId="7343" OwnerDisplayName="Mywiki Witwiki" LastActivityDate="2015-03-26T04:56:04.837" Title="Reprogram Arduino Mega 2560 using Duemilanove?" Tags="|bootloader|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9605" PostTypeId="2" ParentId="9604" CreationDate="2015-03-24T13:46:43.920" Score="1" Body="&lt;p&gt;Yes it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can follow this tutorial: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11635&lt;/a&gt;&#xA;The uno is basically the same as the Duemilanove&lt;/p&gt;&#xA;" OwnerDisplayName="Ronald" LastActivityDate="2015-03-24T13:46:43.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9606" PostTypeId="2" ParentId="9586" CreationDate="2015-03-26T06:21:11.053" Score="-1" Body="&lt;p&gt;As far as I know you should use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text.write(getCurrentTime());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That because (if I'm not wrong) you need to send it as ASCII characters so the text editor will be able to read them in the right way.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-26T06:21:11.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9607" PostTypeId="1" CreationDate="2015-03-26T06:31:17.187" Score="2" ViewCount="2816" Body="&lt;p&gt;I wired ESP-05 to my usb-to-ttl as images below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected it to USB #2 port, and my computer seems not knowing this.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/xRnbb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to send &quot;AT+RST&quot; through Realterm but, it didn't work neither.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ujhz5.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Ogin.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gSEYz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8029" LastEditorUserId="8029" LastEditDate="2015-03-26T06:36:44.457" LastActivityDate="2016-06-08T13:32:21.843" Title="My Computer Doesn't Realize ESP8266 ESP-05 is Connected or not" Tags="|wifi|esp8266|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9609" PostTypeId="2" ParentId="9553" CreationDate="2015-03-26T09:29:25.353" Score="2" Body="&lt;p&gt;&lt;strong&gt;YES you can with an Arduino Yùn&lt;/strong&gt;&#xA;The dongle will have to be handled by the linux part of the board and doing so will leave you all the I/O pin free for your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to check out this for the howto:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://n00bsys0p.wordpress.com/2009/08/26/sending-recieving-sms-with-a-3g-device-in-linux/&quot; rel=&quot;nofollow&quot;&gt;https://n00bsys0p.wordpress.com/2009/08/26/sending-recieving-sms-with-a-3g-device-in-linux/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8086" LastActivityDate="2015-03-26T09:29:25.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9610" PostTypeId="2" ParentId="9571" CreationDate="2015-03-26T12:06:06.730" Score="4" Body="&lt;p&gt;Tx and Rx should be crossed; meaning connect Arduino Tx to ESP Rx and vice versa. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second (and first) attempts are correct. Use 1uF capacitor between Vcc and Gnd. This will provide a more&#xA;robust connection since the ESP can draw too much current which might cause it to reset. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using external power supply, hook together the Arduino Gnd to the PS Gnd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get &quot;Programmer is not responding&quot; - disconnect and reconnect the Arduino USB. Also, you shouldn't get this at all since you are not trying to program the Arduino, just use its FTDI as proxy to the ESP. Any serial terminal application can do it (you don't have to use the built-in terminal in Arduino IDE). &lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-03-26T12:17:51.653" LastActivityDate="2015-03-26T12:17:51.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9611" PostTypeId="1" AcceptedAnswerId="9613" CreationDate="2015-03-26T11:25:08.553" Score="1" ViewCount="613" Body="&lt;p&gt;I have an Arduino Uno board.  I have seen how it is possible to program external AVR's through the Arduino Uno board, for instance an ATtiny. But I'm starting with c for atmel µc and I just want to program Atmel328's through the Arduino hardware, and being able to use the arduino pins for outputs etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, can I use the Arduino Uno board together with avrdude and avr-gcc to program the on-board atmel328 in C? And thus being able to use the Arduino pins for output and input? &lt;/p&gt;&#xA;" OwnerUserId="8089" OwnerDisplayName="Ognan" LastEditorUserId="37523" LastEditDate="2019-11-17T19:33:05.887" LastActivityDate="2019-11-17T19:33:05.887" Title="Use Arduino Uno to program the on-board Atmega328 in C" Tags="|avr|avrdude|avr-gcc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9612" PostTypeId="2" ParentId="9611" CreationDate="2015-03-26T12:46:37.397" Score="0" Body="&lt;p&gt;Yes, the Uno is designed to be very simple to program. The only extra hardware you need is a USB cable to connect it to your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're completely new to this then the simplest way to start is by following the official &quot;&lt;a href=&quot;http://arduino.cc/en/Guide/HomePage&quot; rel=&quot;nofollow noreferrer&quot;&gt;Getting Started&lt;/a&gt;&quot; guide. Note that the section on drivers is particularly important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The guide explains how to use the official &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino IDE&lt;/a&gt; for programming the microcontroller. It automatically handles compiling and uploading your code via gcc and avrdude. It's technically configured to compile as C++ code, but plain C code should be fine too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't recommend that IDE for long-term use though as it's really only aimed at beginners (it has a number of limitations and other problems). Using the command-line tools directly is certainly possible if you'd prefer that. However, you may also like to consider &lt;a href=&quot;https://arduino.stackexchange.com/questions/40/what-are-the-other-ides-for-arduino&quot;&gt;alternative IDEs&lt;/a&gt; which have support for Arduino plug-ins.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-03-26T12:46:37.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9613" PostTypeId="2" ParentId="9611" CreationDate="2015-03-26T13:33:41.997" Score="1" Body="&lt;p&gt;You're question is not so clear.&#xA;But from what I understood you are asking if you can program the Atmega328 with c using low level instruction and by setting manually all the registers in order to use IO ports of atmega. If that's what you're asking I will suggest you to use you're arduino ide to program the Atmega using register names as shown on the official datasheet. Doing so you can start learn the internal parts of the micro and at the same time you can avoid buying an external programmer. But if really want to load you're program or hex file you have to buy an external programmer.&#xA;I hope that helped&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS if you are using the arduino ide and writing manually the registers remember not to set incorrectly the configuration registers because that will make you're Atmega useless and you will need to buy an external programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;For better understanding you can refer to this link.&#xA;&lt;a href=&quot;https://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/&quot; rel=&quot;nofollow&quot;&gt;Programming arduino in c&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8075" LastEditorUserId="8075" LastEditDate="2015-03-26T17:28:22.943" LastActivityDate="2015-03-26T17:28:22.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9615" PostTypeId="2" ParentId="9586" CreationDate="2015-03-26T15:17:55.300" Score="2" Body="&lt;p&gt;Your function, &lt;code&gt;getCurrentTimestamp()&lt;/code&gt; saves the date string in an automatic variable - it is on the function's stack frame which gets freed as soon as that function returns. Either &lt;code&gt;Serial.println()&lt;/code&gt; or &lt;code&gt;savelog()&lt;/code&gt; is overwriting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The proper way to do what you're trying to do is to make the buffer live for the duration of both function calls. One way is to use a global buffer. Another is to declare the buffer in &lt;code&gt;loop()&lt;/code&gt; and pass it to both functions.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-03-26T15:17:55.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9616" PostTypeId="1" CreationDate="2015-03-26T15:02:56.577" Score="2" ViewCount="1775" Body="&lt;p&gt;I am attempting to use SPI communication between a Master Arduino Mega 2560, and standalone Slave Arduino Unos (4, to be exact).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The intention&lt;/strong&gt; is for the Unos to do some trivial work and produce one byte of data that the Master will take from it, whenever needed. They produce this byte very quickly, and the SPDR is updated with a holding variable (a byte) when the slave is interrupted. The Slaves do not take data from the Master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standalone platforms are working 100% (doing the work without problem), and using a single Slave to perform the work, create the byte of data, and have a Master take that data from it, is also working 100%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The issue&lt;/strong&gt; When all four slaves are connected (all being powered from the Master), all sharing the MISO, MOSI, and SCK lines, each with its own unique SS line, I am getting xFF for my data byte (garbage data) from the primary slave. I am using the default Mode 0, and the SCK lines are tied to ground via a 0.1uF capacitor (to smooth the clock signal)... All other SPI lines are wired directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other three slaves are floating their MISO lines (third state), and the Master has all four SS lines as outputs, and all are pulled HIGH in the Master setup. The primary slave I am attempting to communicate with is SS connected to the main SS on the Master (pin 53 on a Mega). I pull the pin LOW, grab the byte from the Slave, and then pull the line HIGH... still garbage.. but only when all four slaves are 'hooked up', like I said, it works fine with one Master, one Slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have thoughts as to what I could be neglecting, missing, etc??&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is the slave schematic. What you can't see is that VCC and AVCC are tied to the 5V line from the 10-pin header (the connection to the master).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eCtpa.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The external power supply I am currently using is added in parallel to the 5V/Grnd you see in the schematic. The power supply has a max current draw at 5V of 10A, so I'm pretty confident that power is not my issue now, unless I have missed something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just realized that the imgur image is hard to see, here is a cut-away that should be clearer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dPaoy.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8091" OwnerDisplayName="Mechatronical" LastEditorUserId="4628" LastEditDate="2015-11-26T14:47:11.913" LastActivityDate="2015-11-26T14:47:11.913" Title="Slaving multiple Arduinos via SPI" Tags="|spi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9617" PostTypeId="1" CreationDate="2015-03-24T18:45:39.933" Score="1" ViewCount="5935" Body="&lt;p&gt;I'm using I2C and the Arduino Library (Wire) to communicate between two Arduinos, and my code isn't working. It's supposed to read in an int from the slave, write a value to the slave, then read back that value. I'm expecting &quot;0 4&quot;, but i keep getting &quot;0 0&quot;. Does this mean that the slave isn't registering the write?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();        &#xA;  Serial.begin(9600);  &#xA;  ffsis();&#xA;}&#xA;&#xA;void ffsis()&#xA;{ &#xA;  //request i&#xA;  Wire.requestFrom(2, 1);   &#xA;  int i = Wire.read(); &#xA;  Serial.print(i); &#xA;&#xA;  //send n seed&#xA;  Wire.beginTransmission(2); &#xA;  Wire.write(12);               &#xA;  Wire.endTransmission();   &#xA;&#xA;  Serial.print(&quot; &quot;);&#xA;&#xA;  //request n&#xA;  Wire.requestFrom(2, 1); &#xA;  int n = Wire.read();&#xA;  Serial.print(n);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slave code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin(2);                &#xA;  Wire.onRequest(requestEvents);&#xA;  Wire.onReceive(receiveEvents);&#xA;}&#xA;&#xA;void loop(){}&#xA;&#xA;int n = 0;&#xA;&#xA;void requestEvents()&#xA;{&#xA;  Wire.write(n);&#xA;}&#xA;&#xA;void receiveEvents(int howMany)&#xA;{  &#xA;  int n = wire.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Haskelier" LastEditorUserId="26916" LastEditDate="2017-09-09T14:52:10.250" LastActivityDate="2017-09-09T14:52:10.250" Title="Using I2C: Master Reader and Writer" Tags="|algorithm|hardware|i2c|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9618" PostTypeId="1" CreationDate="2015-03-26T18:59:45.693" Score="-1" ViewCount="388" Body="&lt;p&gt;I am working in an interactive project in displaying texts in POV which people can click to generate different texts automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a String to store the text first, but it seems cannot display it.&#xA;Then I change the code to use &lt;code&gt;char*&lt;/code&gt; to store the text, but it still does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody help to solve this problem....?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* myStrings[] = {&#xA;  &quot;a&quot;, &quot;c&quot;, &quot;d&quot;, &quot;f&quot;,&#xA;  &quot;b&quot;, &quot;e&quot;, &quot;v&quot;, &quot;B&quot;, &quot;C&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7I1Td.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7I1Td.png&quot; alt=&quot;Error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop(){&#xA;&#xA;  //xbee&#xA;  // potVal = analogueRead(potPin);&#xA;  // xbee.println(potVal);&#xA;  for (int t=0; i&amp;lt;sizeof(myStrings)-1; i++) {&#xA;    displayChar(myStrings[i];&#xA;  }&#xA;  for (int i=0;i&amp;lt;7; i++)&#xA;    digitalWrite(leds[i],LOW);&#xA;  delay(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/69vso.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/69vso.png&quot; alt=&quot;Screenshot of sketch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8094" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:03.063" LastActivityDate="2015-08-07T12:17:03.063" Title="How to Display data from Strings?" Tags="|arduino-uno|programming|string|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9619" PostTypeId="2" ParentId="9618" CreationDate="2015-03-26T19:01:56.560" Score="1" Body="&lt;p&gt;Like the error message says, each entry is a &lt;code&gt;char*&lt;/code&gt;. Convert it to an array of characters instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-26T19:01:56.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9621" PostTypeId="1" CreationDate="2015-03-26T20:13:29.680" Score="2" ViewCount="483" Body="&lt;p&gt;On a new Mac (running OS X 10.10) with Java 7 or 8 already installed (for other development), how can I run the Arduino 1.0.6 IDE (which seems to be required for the LightBlue Bean BLE Arduino device), which seems to require using a very old Java 6 installer from Apple?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to install multiple versions of Java without breaking any of them?  Or is there a way to use the Arduino 1.0.x IDE with a newer version of Java?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or should I re-ask this question over at the apple.stackexchange.com site?&lt;/p&gt;&#xA;" OwnerUserId="651" LastEditorUserId="651" LastEditDate="2015-03-26T21:23:53.273" LastActivityDate="2015-03-26T21:23:53.273" Title="How to run Arduino 1.0.6 on OS X 10.10 with Java 7 or 8 already installed" Tags="|arduino-ide|osx|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9622" PostTypeId="2" ParentId="9513" CreationDate="2015-03-26T21:12:30.050" Score="1" Body="&lt;p&gt;I don't know if it will still work but I will suggest you &lt;a href=&quot;http://www.instructables.com/id/Arduino-Leonardo-as-Isp/step5/Target-Atmel-Microcontroller-1-Atmega328p-burning-/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&#xA;As arduino micro is Leonardo compatible and you r two arduino minis are based on atmega328. You should be able to use the tutorial posted above to use micro as programmer for the two mini.&#xA;Hope that helped.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-26T21:12:30.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9623" PostTypeId="2" ParentId="6517" CreationDate="2015-03-26T21:31:19.140" Score="0" Body="&lt;p&gt;you have a small flaw in your readTime function. If you don't want very strange seconds from the device you should combine the two nibbles packed into the seconds byte. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readTime() {&#xA;  Wire.beginTransmission(MCP7940);&#xA;  Wire.write(byte(0));&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(MCP7940, 7);&#xA;&#xA;  int rawsecond = Wire.read();&#xA;  second = bcdToDec( rawsecond &amp;amp; 112) + bcdToDec(rawsecond &amp;amp; 15);&#xA;  minute = bcdToDec(Wire.read());&#xA;  hour = bcdToDec(Wire.read());&#xA;  weekday = bcdToDec(Wire.read());&#xA;  monthday = bcdToDec(Wire.read());&#xA;  month = bcdToDec(Wire.read());&#xA;  year = bcdToDec(Wire.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for the sample - helped me quite a bit.&lt;/p&gt;&#xA;" OwnerUserId="8098" LastActivityDate="2015-03-26T21:31:19.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9624" PostTypeId="1" CreationDate="2015-03-27T01:31:17.477" Score="2" ViewCount="123" Body="&lt;p&gt;I am trying to connect my Android smartphone with my Arduino Uno by sending a NDEF message to my phone.&#xA;I know that the MIME type for bluetooth is application/vnd.bluetooth.ep.oob but in my PN532 library I don't know what's the right prefix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see prefixes here : &lt;a href=&quot;https://github.com/Seeed-Studio/PN532/blob/master/PN532/PN532.h#L66&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Seeed-Studio/PN532/blob/master/PN532/PN532.h#L66&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="8099" LastActivityDate="2015-03-27T01:31:17.477" Title="Don's NDEF library and bluetooth" Tags="|bluetooth|spi|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9626" PostTypeId="1" AcceptedAnswerId="11728" CreationDate="2015-03-27T02:50:25.500" Score="-1" ViewCount="1294" Body="&lt;p&gt;Linkit One is a board based in Arduino by mediatek. &#xA;I am trying to connect a rfid reader with it &lt;a href=&quot;http://www.ebay.com/itm/Mifare-RC522-Card-Read-Antenna-RF-Module-RFID-Reader-IC-Card-Proximity-Module-/261268585155?pt=LH_DefaultDomain_0&amp;amp;hash=item3cd4d23ac3&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&#xA;I am trying from past 3 days to get it working, checked my code wiring but nothing seems to get it working. &#xA;The reader is perfectly working because i tested it on raspberryPi and it worked flawlessly. &#xA;In my linkit board i am able to detect the reader but card is not getting scanned. &#xA;I am using this library &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;&#xA;and my code is fairly simple one &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#define RST_PIN 9   //&#xA;#define SS_PIN  10  //&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance&#xA;void setup() {&#xA;Serial.begin(9600); // Initialize serial communications with the PC&#xA;while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;SPI.begin(); // Init SPI bus&#xA;mfrc522.PCD_Init(); // Init MFRC522&#xA;ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details&#xA;Serial.println(F(&quot;Scan PICC to see UID, type, and data blocks...&quot;));&#xA;}&#xA;void loop() {&#xA;// Look for new cards&#xA;if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;return;&#xA;}&#xA;// Select one of the cards&#xA;if ( ! mfrc522.PICC_ReadCardSerial()) {&#xA;return;&#xA;}&#xA;// Dump debug info about the card; PICC_HaltA() is automatically called&#xA;mfrc522.PICC_DumpToSerial(&amp;amp;(mfrc522.uid));&#xA;}&#xA;void ShowReaderDetails() {&#xA;// Get the MFRC522 software version&#xA;byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);&#xA;Serial.print(F(&quot;MFRC522 Software Version: 0x&quot;));&#xA;Serial.print(v, HEX);&#xA;if (v == 0x91)&#xA;Serial.print(F(&quot; = v1.0&quot;));&#xA;else if (v == 0x92)&#xA;Serial.print(F(&quot; = v2.0&quot;));&#xA;else&#xA;Serial.print(F(&quot; (unknown)&quot;));&#xA;Serial.println(&quot;&quot;);&#xA;// When 0x00 or 0xFF is returned, communication probably failed&#xA;if ((v == 0x00) || (v == 0xFF)) {&#xA;Serial.println(F(&quot;WARNING: Communication failure, is the MFRC522 properly connected?&quot;));&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This program in theory should detet reader and when card is scanned should display the UID. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am getting msg that my card is v2, so its detecting the reader but not reading the card. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/CUH1h.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8058" LastEditorUserId="8058" LastEditDate="2015-03-27T02:56:33.687" LastActivityDate="2016-02-06T06:59:50.453" Title="Linkit One- Connect rc522 rfid with linkit one" Tags="|rfid|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9627" PostTypeId="1" AcceptedAnswerId="9630" CreationDate="2015-03-27T05:16:30.840" Score="1" ViewCount="14997" Body="&lt;p&gt;I'm trying to send 3 ints in the range of 0-180 from Python to the Arduino Uno device using pySerial (py3K). I have managed to send 1 int by using python's struct lib (not sure if it's the best or fastest way but it works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I'm failing to send more than 1 and every example online seems to stop at 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the simplified code. The task is to send servo0-servo4 to the Arduino and apply those values to the corresponding servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python Code&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;import struct&#xA;import time&#xA;&#xA;bge.arduino = serial.Serial('/dev/ttyACM0', 9600)&#xA;&#xA;# let it initialize&#xA;time.sleep(2)&#xA;&#xA;# send the first int in binary format&#xA;bge.arduino.write(struct.pack('&amp;gt;B', 45))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino code&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo servo0;&#xA;Servo servo1;&#xA;Servo servo2;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  servo0.attach(3);&#xA;  servo1.attach(5);&#xA;  servo2.attach(6);&#xA;}&#xA;&#xA;void loop(){&#xA;  if(Serial.available()){&#xA;    int message = Serial.read();&#xA;    // control the servo&#xA;    servo0.write(message);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8083" LastEditorUserId="10794" LastEditDate="2015-11-02T20:42:50.190" LastActivityDate="2020-06-05T12:25:16.630" Title="Send multiple int values from Python to Arduino using pySerial" Tags="|arduino-uno|programming|python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9629" PostTypeId="1" CreationDate="2015-03-27T08:34:35.273" Score="0" ViewCount="322" Body="&#xA;&#xA;&lt;p&gt;Brief - I am using two arduino Uno's. One acts as a master and the other as slave using Arduino IDE.  Below is the Master Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Taken from Nick Gammon's Forum//&#xA;&#xA;#include &quot;SPI.h&quot;&#xA;#include&quot;pin_arduino.h&quot;&#xA;int ss = 10;&#xA;void setup()&#xA;  {&#xA;    pinMode(ss,OUTPUT);&#xA;    Serial.begin(9600);&#xA;    Serial.println();&#xA;    digitalWrite(ss,HIGH);&#xA;    SPI.begin();&#xA;    SPI.setClockDivider(SPI_CLOCK_DIV8);&#xA;   }&#xA;byte transferAndWait(const byte what)&#xA; {&#xA;   byte a = SPI.transfer(what);&#xA;   delayMicroseconds(20);&#xA;   return a;&#xA; }&#xA;void loop()&#xA; {&#xA;   byte a,b,c;&#xA;   digitalWrite(ss,LOW);&#xA;   transferAndWait('a');&#xA;a = transferAndWait(17);&#xA;b =  transferAndWait(33);&#xA;c = transferAndWait(0);&#xA;digitalWrite(ss,HIGH);&#xA;Serial.println(a,DEC);&#xA;Serial.println(b,DEC);&#xA;Serial.println(c,DEC);&#xA;delay(1000);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before I go into the details of the results I obtained and the problem, below is the Slave code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//Taken from Nick Gammon's Forum//&#xA;&#xA;#include &quot;SPI.h&quot;&#xA;#include &quot;pins_arduino.h&quot;&#xA;int slave = 10;&#xA;int miso = 11;&#xA;byte c = 0;&#xA;void setup()&#xA;  {&#xA;    pinMode(miso,OUTPUT);&#xA;    pinMode(slave,INPUT);&#xA;    Serial.begin(9600);&#xA;    SPR|= BV_(SPE);&#xA;    SPR|= BV_(SPIE);&#xA; }&#xA;ISR(SPI_STC_vect)&#xA; {&#xA;   c = SPDR;&#xA;  switch(c)&#xA;    {&#xA;      case 0:&#xA;      SPDR = 0;&#xA;      break;&#xA;&#xA;     case 'a':&#xA;     SPDR = c + 15;&#xA;     break;&#xA;   }&#xA;  }&#xA;  void loop(void)&#xA;   {&#xA;     if(digitalRead(slave)==HIGH)&#xA;     c = 0;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Results : After dumping the master and slave codes into their respective arduino uno's, then when I open the serial monitor of the master code, It displays the number 17, 33, 0 and the same goes with the slave, meaning that the data is being sent to the slave and received back successfully, and hence I presume the SPI bus is working properly!. But why isn't the add operation happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem: Now the problem is, when the command 'a' is sent from the master to the slave, the slave has to interpret this 'a' command as Addition command and perform the addition of a number 15 to the incoming byte from the master as shown in the slave code, and return the results to the master, which should display the addition results in the  masters serial monitor. I am having problem performing this task and looking forward to suggestions on how to test or where I am doing wrong or make changes to the code or methods in order to get this working. I am expecting answers relevant to the below codes and method.&lt;/p&gt;&#xA;" OwnerUserId="3892" LastEditorUserId="10794" LastEditDate="2015-08-24T21:40:19.887" LastActivityDate="2015-12-23T07:41:33.027" Title="Not able to receive the operation results from the slave after the command being sent by Master - SPI" Tags="|arduino-uno|arduino-ide|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9630" PostTypeId="2" ParentId="9627" CreationDate="2015-03-27T09:30:02.133" Score="2" Body="&lt;p&gt;I guess I'll answer my own question for anyone else having this issue. What I did was:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# write to arduino as raw binary&#xA;bge.arduino.write(struct.pack('&amp;gt;BBB',45,90,180))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo0;&#xA;Servo servo1;&#xA;Servo servo2;&#xA;&#xA;// create array&#xA;int incoming[2];&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;&#xA;  servo0.attach(3);&#xA;  servo1.attach(5);&#xA;  servo2.attach(6);&#xA;}&#xA;&#xA;void loop(){&#xA;  while(Serial.available() &amp;gt;= 3){&#xA;    // fill array&#xA;    for (int i = 0; i &amp;lt; 3; i++){&#xA;      incoming[i] = Serial.read();&#xA;    }&#xA;    // use the values&#xA;    servo0.write(incoming[0]);&#xA;    servo1.write(incoming[1]);&#xA;    servo2.write(incoming[2]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8083" LastEditorUserId="8083" LastEditDate="2015-03-31T16:39:52.527" LastActivityDate="2015-03-31T16:39:52.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9632" PostTypeId="1" CreationDate="2015-03-27T12:48:12.210" Score="1" ViewCount="1109" Body="&lt;p&gt;A few years ago I programmed AVR ATmega8 with AVR studio by USB isp programmer.&#xA;I was using C language. Now I would like to use arduino(C++) langauge and my external USB isp programmer. Is it possible? &lt;/p&gt;&#xA;" OwnerUserId="8111" LastEditorUserId="25788" LastEditDate="2016-09-15T07:57:53.527" LastActivityDate="2016-09-15T07:57:53.527" Title="use arduino IDE for USB isp programmer" Tags="|arduino-uno|c++|avr|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9633" PostTypeId="2" ParentId="9629" CreationDate="2015-03-27T13:26:14.477" Score="0" Body="&lt;pre&gt;&lt;code&gt;ISR(SPI_STC_vect);  &amp;lt;-- Reason 1.&#xA; {&#xA;   byte c = SPDR;&#xA;  switch(command)   &amp;lt;-- Reason 2.&#xA;    {                      |&#xA;      case 0:              |&#xA;      command = c;  &amp;lt;------┘ &#xA;      SPDR = 0;&#xA;      break;&#xA;&#xA;     case 'a':&#xA;     SPDR = c + 15;&#xA;     break;&#xA;   }&#xA;  void loop(void)   &amp;lt;--- Reason 3.&#xA;   {&#xA;     if(digitalRead(slave)==HIGH)&#xA;     command = 0;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The slave code is not going to work, for various reasons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reason 1:&#xA;This is a declaration of a function. Not an implementation.&#xA;The &quot;;&quot; is badly misplaced here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reason 2: You're switching on a value &quot;command&quot; but it's only changed after executing the case/command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reason 3: The loop function is still part of the previous function?&#xA;The &quot;{&quot; below the ISR(SPI... isn't closed right. (With another &quot;}&quot;)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-03-27T13:26:14.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9634" PostTypeId="2" ParentId="9632" CreationDate="2015-03-27T14:23:06.040" Score="0" Body="&lt;p&gt;If you want to use arduino IDE to program the atmega328 you don't need a USB ISP programmer. The only thing you have to do is load the arduino bootloader on the atmega328 in order to program it through the arduino IDE. In the ide you can program the board with c++. But if you want to program the atmega328 through you're USB ISP programmer (assuming it is capable of programming the Atmega 328) you have to use other IDE in which you can program in c++ and produce an hex file that can be burned on the chip through you're  programmer on the atmega328.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-27T14:23:06.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9635" PostTypeId="2" ParentId="9570" CreationDate="2015-03-27T16:41:27.153" Score="0" Body="&lt;p&gt;I know some projects are just for the sake of the project alone but have you considered this no-tech solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Automatic-garage-parking-aid/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Automatic-garage-parking-aid/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-03-27T16:41:27.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9636" PostTypeId="2" ParentId="9548" CreationDate="2015-03-27T17:53:32.587" Score="3" Body="&lt;p&gt;I've used the usb battery chargers (marketed to recharge cell phones) with great success on many different Arduino boards. They come in a variety of mAH capacities and are easily recharged with any powered USB port/power adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a link to one I've used. (I'm not affiliated with Duracell in any way).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ww2.duracell.com/en-US/product/instant-usb-charger.jspx&quot; rel=&quot;nofollow&quot;&gt;http://ww2.duracell.com/en-US/product/instant-usb-charger.jspx&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-03-27T17:53:32.587" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9637" PostTypeId="1" CreationDate="2015-03-27T18:05:42.100" Score="2" ViewCount="149" Body="&lt;p&gt;I'm trying to control motors by Arduino, from my laptop. I'm using MATLAB to send over packets of data, i.e. 'x=100,y=150,z=200' My scheme was to send this packet to Arduino, and have Arduino extract the numerical values from the string, since the positions of the numbers will always be consistent. I found a code from Arduino forum, written by PaulS, but I can't figure out why it wouldn't move into 'if (xbee.available())' portion of the code. The code is attached below: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define SOP '&amp;lt;'&#xA;#define EOP '&amp;gt;'&#xA;&#xA;SoftwareSerial XBee(2, 3); // RX, TX&#xA;int test = 0;&#xA;bool started = false;&#xA;bool ended = false;&#xA;&#xA;char inData[20];&#xA;byte index;&#xA;char inChar;&#xA;&#xA;void setup()&#xA;{&#xA;   XBee.begin(9600);&#xA;   Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Read all serial data available, as fast as possible&#xA;  while(Serial.available() &amp;gt; 0)&#xA;  {&#xA;    if (XBee.available())&#xA;    {&#xA;      char inChar = XBee.read();&#xA;     }&#xA;    if(inChar == SOP)&#xA;    {&#xA;       index = 0;&#xA;       inData[index] = '\0';&#xA;       Serial.print(inData);&#xA;       started = true;&#xA;       ended = false;&#xA;    }&#xA;    else if(inChar == EOP)&#xA;    {&#xA;       Serial.print(inChar);&#xA;       ended = true;&#xA;       break;&#xA;    }&#xA;    else&#xA;    {&#xA;      if(index &amp;lt; 19)&#xA;      {&#xA;        inData[index] = inChar;&#xA;        Serial.print(inData);&#xA;        index++;&#xA;        inData[index] = '\0';&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  // We are here either because all pending serial&#xA;  // data has been read OR because an end of&#xA;  // packet marker arrived. Which is it?&#xA;  if(started &amp;amp;&amp;amp; ended)&#xA;  {&#xA;    // The end of packet marker arrived. Process the packet&#xA;    Serial.println(inData);&#xA;    // Reset for the next packet&#xA;    started = false;&#xA;    ended = false;&#xA;    index = 0;&#xA;    inData[index] = '\0';&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8114" LastEditorUserId="37523" LastEditDate="2019-12-27T20:52:30.730" LastActivityDate="2019-12-27T20:52:30.730" Title="Using XBEE from my laptop, I want to assign multiple values in the Arduino" Tags="|softwareserial|xbee|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9638" PostTypeId="2" ParentId="9468" CreationDate="2015-03-27T18:32:27.093" Score="1" Body="&lt;p&gt;From what I'm seeing, the touch screen and card reader use SPI but the LCD uses a bunch of Digital I/O lines. The link in Gerben's comment includes a library for the LCD that might be what you're looking for. I hope you're using a ATMega board as it doesn't look like an Uno or similar board will have enough I/O for the LCD.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-03-27T18:32:27.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9639" PostTypeId="1" CreationDate="2015-03-27T19:30:58.013" Score="2" ViewCount="225" Body="&lt;p&gt;when I upload the code to my leonardo board it just stuck on uploading, like this:&lt;img src=&quot;https://i.stack.imgur.com/vyXxF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;could someone help me with this?&lt;/p&gt;&#xA;" OwnerUserId="8116" LastActivityDate="2015-03-27T19:30:58.013" Title="Pixy Pet Robot stuck on uploading code" Tags="|arduino-ide|uploading|" AnswerCount="0" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9643" PostTypeId="2" ParentId="9618" CreationDate="2015-03-27T21:14:34.013" Score="1" Body="&lt;p&gt;First thing, in C++ (or C) a character in single quotes is just a single lone character, but any characters in double quotes is a string literal. for example &lt;code&gt;&quot;hello&quot;&lt;/code&gt; is a &lt;code&gt;const char[6]&lt;/code&gt; containing the characters &lt;code&gt;'w'&lt;/code&gt;,&lt;code&gt;'o'&lt;/code&gt;,&lt;code&gt;'r'&lt;/code&gt;,&lt;code&gt;'l'&lt;/code&gt;,&lt;code&gt;'d'&lt;/code&gt;,&lt;code&gt;'\0'&lt;/code&gt;. That extra &lt;code&gt;'\0'&lt;/code&gt; is the null terminator that makes an array of chars into a c-string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code is making a variable &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* myStrings[] = { &quot;a&quot;, &quot;c&quot;, ... };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an array of &lt;code&gt;char*&lt;/code&gt;, which means each element is a &lt;code&gt;char*&lt;/code&gt;, which in turn means each element is a full string (in your case each has 2 characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want an array of single characters, which means you either drop the &lt;code&gt;*&lt;/code&gt; in &lt;code&gt;char*&lt;/code&gt;, or drop the &lt;code&gt;[]&lt;/code&gt; in &lt;code&gt;myStrings[]&lt;/code&gt;, and use either an array of single characters &lt;code&gt;{'a','b',...}&lt;/code&gt;, or a single string literal &lt;code&gt;&quot;acdfbevBC&quot;&lt;/code&gt;. Any of these lines will work in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char * myStrings = &quot;acdfbevBC&quot;;&#xA;char myStrings[] = &quot;acdfbevBC&quot;;&#xA;char myStrings[] = { 'a', 'c', 'd', ... 'C', '\0'};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you never plan to print &lt;code&gt;myStrings&lt;/code&gt; as a unified string, you can leave off the &lt;code&gt;'\0'&lt;/code&gt;, the null terminator is there so functions that you pass it to know when it stops without you having to explicitly pass how long the string is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the first line is &lt;code&gt;const char *&lt;/code&gt; because you should never overwrite a string literal. &lt;code&gt;char myStrings[]&lt;/code&gt; is fine without const because the compiler is using the literal to initialize an array that gets its own place in memory, not making &lt;code&gt;myStrings&lt;/code&gt; point into a separate cache of string literals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;a href=&quot;http://en.cppreference.com/w/cpp/language/string_literal&quot; rel=&quot;nofollow&quot;&gt;cpp reference's details here&lt;/a&gt; for more details on string literals.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-27T21:14:34.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9644" PostTypeId="2" ParentId="9617" CreationDate="2015-03-27T23:20:31.857" Score="0" Body="&lt;p&gt;Since you have &#xA;int n&#xA;in the receiveEvents function, you're making a new local variable, not using the global n variable.&lt;/p&gt;&#xA;" OwnerUserId="8118" LastActivityDate="2015-03-27T23:20:31.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9645" PostTypeId="2" ParentId="9627" CreationDate="2015-03-27T23:28:24.890" Score="0" Body="&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  if(Serial.available() &amp;gt;= 3){&#xA;    // fill array&#xA;    for (int i = 0; i &amp;lt; 3; i++){&#xA;      incoming[i] = Serial.read();&#xA;    }&#xA;    // use the values&#xA;    servo0.write(incoming[0]);&#xA;    servo1.write(incoming[1]);&#xA;    servo2.write(incoming[2]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8119" LastActivityDate="2015-03-27T23:28:24.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9646" PostTypeId="1" CreationDate="2015-03-28T04:11:15.227" Score="2" ViewCount="134" Body="&lt;p&gt;I am having some strange issue. I am using Linkit One board, which is a based on Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using rfid reader RC522 which is cheapest and most common. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cant get its official library get it work. I tried to search for problem or differences but nothing help. I am looking for some to take a fresh look because its been 4 days and i am stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not Working &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;https://github.com/miguelbalboa/rfid&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working (this is full ino in single file) &lt;a href=&quot;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&quot; rel=&quot;nofollow&quot;&gt;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8058" LastActivityDate="2015-03-28T04:11:15.227" Title="RFID library issue" Tags="|arduino-uno|rfid|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9649" PostTypeId="1" CreationDate="2015-03-28T08:07:15.107" Score="0" ViewCount="154" Body="&lt;p&gt;I am trying to call a HTTP GET using my Arduino via SIM900A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the commands manually via the USB port, I am able to get the commands to run. Now, when I put the same sequence on arduino, the &lt;code&gt;setup()&lt;/code&gt; is called repeatedly after the &lt;code&gt;sendATcommand(httpAuthCommand, &quot;OK&quot;, 2000);&lt;/code&gt;. Looks like a reset issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read, this link to put all my code into &lt;code&gt;loop&lt;/code&gt; to avoid the &lt;code&gt;setup()&lt;/code&gt; reset issue. But seems like this is did not fix the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have debugged it to this one change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This Works&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char httpAuthCommand[] = &quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;http://www.m2msupport.net/m2msupport/http_get_test.php\&quot;&quot; ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This Does Not work&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char httpAuthCommand[] = &quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;http://1.1.1.1:8080/mytomcatservice/mypath/mycommand/Request?identity=%2B1234567890&amp;amp;identityType=1\&quot;&quot; ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I debugged this a bit more, it does not work when I add &lt;code&gt;?identity=%2B0123456789&amp;amp;identityType=1&lt;/code&gt; to the httpAuthCommand. Something crazy while sending parameters ??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In loop()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sendATcommand(httpAuthCommand, &quot;OK&quot;, 2000); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;sendATcommand method&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){&#xA;&#xA;    uint8_t x=0,  answer=0;&#xA;    char response[100];&#xA;    unsigned long previous;&#xA;    memset(response, '\0', 100);    // Initialice the string&#xA;    delay(100);&#xA;    while( Serial.available() &amp;gt; 0) Serial.read();    // Clean the input buffer&#xA;    Serial.println(ATcommand);    // Send the AT command &#xA;    x = 0;&#xA;    previous = millis();&#xA;    // this loop waits for the answer&#xA;    do{&#xA;        // if there are data in the UART input buffer, reads it and checks for the asnwer&#xA;        if(Serial.available() != 0){    &#xA;            response[x] = Serial.read();&#xA;            x++;&#xA;            // check if the desired answer is in the response of the module&#xA;            if (strstr(response, expected_answer) != NULL)    &#xA;            {&#xA;                answer = 1;&#xA;            }&#xA;        }&#xA;    // Waits for the asnwer with time out&#xA;    }while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));    &#xA;&#xA;    return answer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Raw commands work on Chrome&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://www.m2msupport.net/m2msupport/http_get_test.php&quot; rel=&quot;nofollow&quot;&gt;http://www.m2msupport.net/m2msupport/http_get_test.php&lt;/a&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://1.1.1.1:8080/mytomcatservice/mypath/mycommand/Request?identity=%2B918177900460&amp;amp;identityType=1&quot; rel=&quot;nofollow&quot;&gt;http://1.1.1.1:8080/mytomcatservice/mypath/mycommand/Request?identity=%2B918177900460&amp;amp;identityType=1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Guess&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am missing some escape sequence characters in the command (especially in the parameters section &lt;code&gt;?identity=%2B0123456789&amp;amp;identityType=1&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="3328" LastEditorUserId="3328" LastEditDate="2015-03-28T16:23:58.573" LastActivityDate="2015-03-28T18:20:35.263" Title="setup() resets from loop, when I add parameters to http get `?identity=%2B0123456789&amp;identityType=1`" Tags="|arduino-uno|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9651" PostTypeId="2" ParentId="9649" CreationDate="2015-03-28T10:27:08.500" Score="1" Body="&lt;p&gt;&quot;Something crazy while sending parameters ??&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly your power supply is to weak so 5V drops low and the processor resets when the transmitter sends a message.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-03-28T10:27:08.500" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9653" PostTypeId="1" AcceptedAnswerId="9667" CreationDate="2015-03-28T12:12:28.227" Score="1" ViewCount="818" Body="&lt;p&gt;I executed the following steps in order to burn a bootloader into an  AVR328P-PU chip I acquired on ebay.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have set up AVR328P-PU on a breadboard as described here: &lt;a href=&quot;http://arduino.cc/en/main/standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/main/standalone&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have uploaded the ArduinoISP sketch into Arduion Uno.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connected the wires in a way described here &lt;a href=&quot;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; ( the setup with external clock)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Chose &quot;Tools -&gt; Programmer -&gt; Arduion as ISP&quot; in the IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Chose &quot;Burn Bootloader&quot; from the IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Got and error &lt;code&gt;avrdude: Yikes!  Invalid device signature.&lt;/code&gt;, noticed that I connected the wires in the wrong order.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fixed the wired, but still got the error:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;avrdude: Version 6.0.1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     System wide configuration file is &quot;C:\Program Files\Arduino/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;&#xA;     Using Port                    : COM3&#xA;     Using Programmer              : stk500v1&#xA;     Overriding Baud Rate          : 19200&#xA;     AVR Part                      : ATmega328P&#xA;     Chip Erase delay              : 9000 us&#xA;     PAGEL                         : PD7&#xA;     BS2                           : PC2&#xA;     RESET disposition             : dedicated&#xA;     RETRY pulse                   : SCK&#xA;     serial program mode           : yes&#xA;     parallel program mode         : yes&#xA;     Timeout                       : 200&#xA;     StabDelay                     : 100&#xA;     CmdexeDelay                   : 25&#xA;     SyncLoops                     : 32&#xA;     ByteDelay                     : 0&#xA;     PollIndex                     : 3&#xA;     PollValue                     : 0x53&#xA;     Memory Detail                 :&#xA;&#xA;                              Block Poll               Page                       Polled&#xA;       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;     Programmer Type : STK500&#xA;     Description     : Atmel STK500 Version 1.x firmware&#xA;     Hardware Version: 2&#xA;     Firmware Version: 1.18&#xA;     Topcard         : Unknown&#xA;     Vtarget         : 0.0 V&#xA;     Varef           : 0.0 V&#xA;     Oscillator      : Off&#xA;     SCK period      : 0.1 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.06s&#xA;&#xA;avrdude: Device signature = 0x000000 (retrying)&#xA;&#xA;Reading | ################################################## | 100% 0.05s&#xA;&#xA;avrdude: Device signature = 0x000000 (retrying)&#xA;&#xA;Error while burning bootloader.&#xA;Reading | ################################################## | 100% 0.07s&#xA;&#xA;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;     Double check connections and try again, or use -F to override&#xA;     this check.&#xA;&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2hTrr.jpg&quot; alt=&quot;Breadboard + Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ReuMi.jpg&quot; alt=&quot;Breadboard Close-Up&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My questions&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I understand that this can be caused by poor breadboard quality. How can I test this hypothesis before buying new breadboard?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Could the wrong wiring from step 5 ruin the chip?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8127" LastEditorUserId="8127" LastEditDate="2015-03-28T16:12:44.323" LastActivityDate="2015-04-22T00:09:51.777" Title="Problem Bootloading AVR328P-PU" Tags="|bootloader|avrdude|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9654" PostTypeId="1" CreationDate="2015-03-28T14:55:55.877" Score="2" ViewCount="488" Body="&lt;p&gt;Is it possible to use a custom bootloader, that loads and executes a main program stored for example on an SD card? The idea is to make it possible to update the Arduino remotely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this with a bootloader, which writes the program into the flash storage with a 32KB offset and then uses a function pointer with that address (0x88000) to continue execution there. The 0x80000 is as far as I am informed the address offset of the flash storage. It can be written on Due boards with this library: &lt;a href=&quot;https://github.com/sebnil/DueFlashStorage&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/sebnil/DueFlashStorage&lt;/a&gt;. The problem was that this just hasn't worked, the Arduino simply stopped responding after the function pointer being executed. I would appreciate any information or hints on this topic.&lt;/p&gt;&#xA;" OwnerUserId="8131" LastEditorUserId="4628" LastEditDate="2017-01-19T03:35:56.307" LastActivityDate="2017-01-19T03:35:56.307" Title="How do I implement a userspace bootloader on Arduino Due?" Tags="|arduino-due|flash|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9655" PostTypeId="1" AcceptedAnswerId="9659" CreationDate="2015-03-28T15:01:17.223" Score="2" ViewCount="2168" Body="&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=38627.0&quot; rel=&quot;nofollow&quot;&gt;This page&lt;/a&gt; says to run a shell command I need a &quot;proxy code&quot; running on my computer (Linux Ubuntu). What do they mean by this, and how should I make one?&lt;/p&gt;&#xA;" OwnerUserId="8133" LastActivityDate="2015-03-28T15:44:54.877" Title="How can I execute a shell command?" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9656" PostTypeId="1" CreationDate="2015-03-28T15:01:48.873" Score="4" ViewCount="17921" Body="&#xA;&#xA;&lt;p&gt;I have a project using the RC522 RFID module with my Arduino Uno board and miguelbalboa's rfid library. The example code and every other code I find on the internet work pooling the device in order to know if there is a new card present, but I intend to work with a interrupt-driven approach. I have the proper knowledge to do the hardware/arduino part, but I'm having trouble generating an interrupt in the IRQ pin when the card is present. Have anyone succeded on this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Connection:&#xA;RST -&gt; 8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SS-&gt; 9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MOSI -&gt; 11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MISO -&gt; 12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCK -&gt; 13&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IRQ -&gt; 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#include &amp;lt;String.h&amp;gt;&#xA;&#xA;#define RST_PIN     8 &#xA;#define SS_PIN      9&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);       // Initialize serial communications with the PC&#xA;  while (!Serial);      // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;  SPI.begin();          // Init SPI bus&#xA;  mfrc522.PCD_Init();       // Init MFRC522&#xA;  mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts&#xA;  mfrc522.PCD_WriteRegister(MFRC522::ComIEnReg, 0x7F); //Enable all interrupts&#xA;  mfrc522.PCD_WriteRegister(MFRC522::DivIEnReg, 0x14);&#xA;  Serial.println(F(&quot;Ready...&quot;));&#xA;  attachInterrupt(0, isr, RISING);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;}&#xA;&#xA;void isr()&#xA;{&#xA;  Serial.println(F(&quot;Interrupt&quot;));&#xA;  mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&#xA;I only get the &quot;Ready...&quot; on the Serial Monitor, no matter if there is a card present or not.&lt;/p&gt;&#xA;" OwnerUserId="8132" LastEditorUserId="10794" LastEditDate="2015-08-12T02:21:26.917" LastActivityDate="2020-07-15T16:41:05.083" Title="Using interrrupts with RC522" Tags="|arduino-uno|rfid|" AnswerCount="3" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9657" PostTypeId="2" ParentId="9589" CreationDate="2015-03-28T15:33:30.003" Score="0" Body="&lt;p&gt;First of all, I cannot say if your protocol will work or not since I don't have the details. However, switching protocols will give you the same result. Also, you do not need a transistor for this usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to connect the grounds of the different power sources. Since voltage is relative, having the grounds disconnected will lead one device to think that the voltage is higher/lower than the other one thinks (they have different reference point).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-28T15:33:30.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9658" PostTypeId="1" CreationDate="2015-03-28T15:44:35.163" Score="2" ViewCount="4842" Body="&lt;p&gt;I am trying to send and receive data using I2C between an Arduino Uno and an ATTiny85. The Arduino Uno is using the Wire library. The ATTiny85 is using the TinyWire library and is programmed (and powered) using the Sparkfun Tiny AVR Programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not receiving any data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno I2C master code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDR 0x50&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Wire.requestFrom(SLAVE_ADDR, 1);&#xA;&#xA;  while(Wire.available())&#xA;  { &#xA;    byte byteReceived = Wire.read();&#xA;    Serial.println(byteReceived, DEC);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ATTiny85 I2C slave code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TinyWireS.h&quot;&#xA;&#xA;#define SLAVE_ADDR 0x50&#xA;&#xA;void setup()&#xA;{&#xA;  TinyWireS.begin(SLAVE_ADDR);&#xA;  TinyWireS.onRequest(requestEvent);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&#xA;void requestEvent()&#xA;{&#xA;  byte byteToSend = 23;&#xA;  TinyWireS.send(byteToSend);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8134" LastActivityDate="2015-08-14T01:27:25.350" Title="Arduino Uno (master) and ATTiny85 (slave) I2C connection not working" Tags="|arduino-uno|i2c|attiny|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9659" PostTypeId="2" ParentId="9655" CreationDate="2015-03-28T15:44:54.877" Score="3" Body="&lt;p&gt;I'm not familiar with the term &lt;em&gt;proxy code,&lt;/em&gt; but I'm assuming that it's a piece of code on your computer that acts as a man in the middle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot directly use Arduino to run a shell command, so you'll need to create a program on your computer that listens to &lt;strong&gt;&lt;a href=&quot;http://arduino.cc/en/reference/serial&quot; rel=&quot;nofollow noreferrer&quot;&gt;serial&lt;/a&gt;&lt;/strong&gt; and then executes a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the &quot;proxy code&quot; Python would be a good choice because of the &lt;strong&gt;&lt;a href=&quot;http://pyserial.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;pySerial library&lt;/a&gt;&lt;/strong&gt; that plays nicely with Arduino. It seems &lt;a href=&quot;https://stackoverflow.com/questions/89228/calling-an-external-command-in-python&quot;&gt;fairly easy to execute a shell command with Python&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the Arduino code, something like this would work good:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;loop() {&#xA;  if(state == true) {&#xA;    Serial.print('A');&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-03-28T15:44:54.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9660" PostTypeId="1" AcceptedAnswerId="13369" CreationDate="2015-03-28T17:44:33.037" Score="4" ViewCount="5522" Body="&lt;p&gt;This is a visualization of my Arduino connections: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FMI00.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish to read the data using the &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow noreferrer&quot;&gt;Capacitive sensor Library&lt;/a&gt;. iv'e tried the following code but variables &lt;code&gt;total1&lt;/code&gt;, &lt;code&gt;total2&lt;/code&gt;, &lt;code&gt;total3&lt;/code&gt; always have the value &lt;code&gt;0&lt;/code&gt; and i don't know what is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Import the CapacitiveSensor Library.&#xA;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;&#xA;&#xA;// Name the pin as led. &#xA;#define speaker 11&#xA;&#xA;&#xA;// Set the Send Pin &amp;amp; Receive Pin.&#xA;CapacitiveSensor   cs_2_3 = CapacitiveSensor(2,3);        // 10M resistor between pins 4 &amp;amp; 2, pin 2 is sensor pin, add a wire and or foil if desired&#xA;CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4);        // 10M resistor between pins 4 &amp;amp; 6, pin 6 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor   cs_2_5 = CapacitiveSensor(2,5);        // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor   cs_2_6 = CapacitiveSensor(2,6);        // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor   cs_2_7 = CapacitiveSensor(2,7);        // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor   cs_2_8 = CapacitiveSensor(2,8);        // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor   cs_2_9 = CapacitiveSensor(2,9);        // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;&#xA;&#xA;void setup()                    &#xA;{&#xA;  cs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example&#xA;&#xA;  // Arduino start communicate with computer.&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()                    &#xA;{&#xA;  // Set a timer.&#xA;  long start = millis();&#xA;&#xA;  // Set the sensitivity of the sensors.&#xA;  long total1 =  cs_2_3.capacitiveSensor(60);&#xA;  long total2 =  cs_2_4.capacitiveSensor(60);&#xA;  long total3 =  cs_2_5.capacitiveSensor(60);&#xA; /* long total4 =  cs_2_6.capacitiveSensor(60);&#xA;  long total5 =  cs_2_7.capacitiveSensor(60);&#xA;  long total6 =  cs_2_8.capacitiveSensor(60);&#xA;  long total7 =  cs_2_9.capacitiveSensor(60);*/&#xA;&#xA;&#xA;&#xA;  Serial.print(millis() - start);        // check on performance in milliseconds&#xA;  Serial.print(&quot;\t&quot;);                    // tab character for debug windown spacing&#xA;&#xA;  Serial.print(total1);                  // print sensor output 1&#xA;  Serial.print(&quot;\t&quot;);                    // Leave some space before print the next output&#xA;  Serial.print(total2);                  // print sensor output 2&#xA;  Serial.print(&quot;\t&quot;);                    // Leave some space before print the next output&#xA;  Serial.print(total3);                  // print sensor output 3&#xA;  Serial.print(&quot;\t&quot;);                    // Leave some space before print the next output&#xA;  Serial.print(&quot;\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8135" LastEditorUserId="7417" LastEditDate="2015-03-28T18:13:39.503" LastActivityDate="2016-12-17T06:03:00.477" Title="Arduino UNO capacitive sensor not working" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9661" PostTypeId="2" ParentId="9649" CreationDate="2015-03-28T18:20:35.263" Score="1" Body="&lt;p&gt;Could you have exceeded the rather limited RAM?&#xA;First experiment: Replace the added string with &quot;xxx....x&quot;. If you have the same problem, then it's not the contents of the string but its length.&#xA;Second experiment (or jump straight to this one): &lt;a href=&quot;http://www.arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow&quot;&gt;Compile your strings in flash&lt;/a&gt; instead of in RAM. Note this will only help if you have a number of them, since your code will have to copy each one to RAM (at run-time) in order to use it, taking up some of the space you had saved. If there is only one string moved to flash, your code will need a temporary buffer of equal size (though only during the actual print call). A possible way around this is to break up the long string into a number of short ones, put all of them in flash, then print them sequentially at run time. That will need a buffer only as large as your largest substring. The cost will be increased use of flash, both for string storage and for the extra number of print calls; and slightly slower execution (probably not an issue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may be telling you that you need a more capable processor (one with more RAM space) or that you need to start getting creative about fitting your application into the one you've got.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-03-28T18:20:35.263" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9662" PostTypeId="1" CreationDate="2015-03-28T18:39:30.700" Score="2" ViewCount="111" Body="&lt;p&gt;OS: Ubuntu 14.04&#xA;Board: Teensy 3.1 and Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've ran many tests and concluded that the issue is within the Arduino IDE itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue: Instead of a smooth stream of data displaying from the serial port, the terminal displays big chunks of data periodically. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it with minicom and the stream of data is smooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any solutions?&lt;/p&gt;&#xA;" OwnerUserId="3159" LastActivityDate="2015-03-28T18:39:30.700" Title="Arduino 1.6.1 IDE with Teensyduino Serial port lag issue?" Tags="|serial|teensy|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9663" PostTypeId="1" AcceptedAnswerId="9782" CreationDate="2015-03-28T19:01:01.477" Score="1" ViewCount="4551" Body="&lt;p&gt;I've got a BlueSMIRF Silver (RN-42) Bluetooth module.&#xA;I am trying to create a basic keyboard I can play with on an iPad Air.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment barely manage to get the module to pair with OSX&#xA;but only through using Bluetooth Setup Assistant and using &quot;&lt;strong&gt;Passcode Options...use a specific code&lt;/strong&gt;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this option, the module pairs, but the connection resets about every 5 seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On iPad it tries to use a generate number really fast and fails straight away, being unable to connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed there is a BlueSMIRF HID version, but from what I can tell, the hardware is the same, &#xA;just the firmware is different. I've gone through the whole &lt;a href=&quot;https://dlnmh9ip6v2uc.cloudfront.net/assets/1/e/e/5/d/5217b297757b7fd3748b4567.pdf&quot; rel=&quot;nofollow&quot;&gt;Bluetooth Data Module Command Reference &amp;amp; Advanced Information User’s Guide&lt;/a&gt;(pdf link) manual and from what I can gather,&#xA;even though I have Silver firmware burned onto my module, I should be able to set and use the HID profile&#xA;(from the default SPP):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Roving Networks modules shipped with firmware version 6.11 and higher&#xA;  support the HID profile. You do not need special firmware if your&#xA;  module is running firmware 6.11 or higher.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and my module reports version as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ver 6.15 04/26/2013&#xA;(c) Roving Networks&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also gone through the &lt;a href=&quot;http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/Bluetooth/RN-HID-User%20Guide-1.1r.pdf&quot; rel=&quot;nofollow&quot;&gt;Bluetooth HID Profile&lt;/a&gt;(pdf link) guide from Roving Networks, but the same information is present in Chapter 5 of the advanced user's guide mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've setup the following settings (with commands used):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;HID Profile (&lt;code&gt;S~,6&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;li&gt;Device discovery and pairing is set to automatic, without using GPIO6(&lt;code&gt;SM,6&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;li&gt;HID Flag is set to Keyboard (&lt;code&gt;SH,0000&lt;/code&gt;) &lt;/li&gt;&#xA;&lt;li&gt;Authentication is set to open (&lt;code&gt;SA,0&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've also tried the inquiry scan(&lt;code&gt;SI,0800&lt;/code&gt;)  and page scan(&lt;code&gt;SJ,0800&lt;/code&gt;)  windows to maximum &#xA;in the hope it would increase the odds of successful pairing and made sure I rebooted the module and checked the settings again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used the same module with the SPP profile just fine, but I'm still fairly new to Bluetooth&#xA;and this is the first time I try to use the HID profile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I use the BlueSMIRF Silver as a basic Bluetooth Keyboard for an iPad Air ?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="3505" LastEditorUserId="3505" LastEditDate="2015-03-31T16:08:52.717" LastActivityDate="2017-04-28T15:43:11.477" Title="How can I use a BlueSMIRF Silver (RN-42) as a HID Keyboard (on IOS)?" Tags="|arduino-uno|bluetooth|keyboard|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9664" PostTypeId="1" CreationDate="2015-03-28T21:04:07.253" Score="2" ViewCount="1177" Body="&lt;p&gt;I am attempting to connect an Arduino Uno to a Modern Device RBB Arduino. One is the base and the other the remote. They need to set up a simple handshake to communicate an on and off condition from the remote.The hardware and software work for both the base and remote using Tera Term to simulate the opposite node. I am running Tera Term on a notebook connecting to the node through a BT dongle. In other words if I manually respond to the opposite node on the Tera Term they both operate as they should individually. When I try to get them to interact autonomously they will not handshake. The HC05s are paired and connected but the handshake data will not flow back and forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remote Code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; int pinInt =2; //interrupt pin&#xA;&#xA; int ack = 2; //acknowledge&#xA;&#xA; void setup() {&#xA;&#xA;  pinMode(3,OUTPUT); //power to bluetooth&#xA;&#xA;  pinMode(pinInt,INPUT); //interrupt pin mode&#xA;&#xA;}&#xA;// Still needs sleep and interrupt processing&#xA;&#xA;  void loop() {&#xA;&#xA;  delay(5000);//sim sleep remove or adjust for wake up delay&#xA;&#xA;&#xA;  digitalWrite(3,HIGH);//switches power to bluetooth&#xA;&#xA;  delay(10000);//BT active adjust as necessary&#xA;&#xA;  Serial.begin(9600); &#xA;&#xA;  Serial.print('?');//send am I connected&#xA;&#xA;   while(Serial.available()==0){}//idle until incoming serial&#xA;&#xA;     int heatCall=digitalRead(pinInt);//read interrupt pin&#xA;&#xA;     if (Serial.available() &amp;gt; 0) {ack = Serial.read();}//read ack&#xA;&#xA;     if (ack=='1'){Serial.print(heatCall);}//send state of heatCall&#xA;&#xA;  while(Serial.available()==0){}//idle until incoming serial&#xA;&#xA;    if (Serial.available() &amp;gt; 0) {ack = Serial.read();}//read ack&#xA;&#xA;    if (ack=='0'){Serial.end();digitalWrite(3,LOW);}//BT off &#xA;&#xA;   //sleepNow();//put back to sleep&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Base Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int relayPin =13; //relay pin&#xA;&#xA; char itsOn = 0; //remote calling variable&#xA;&#xA; int heatCall = 0; //state of TH135&#xA;&#xA; int ack = 2; //hand shake&#xA;&#xA;  void setup() {&#xA;&#xA;  pinMode(relayPin,OUTPUT); //power to relay&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;  void loop() {&#xA;&#xA;  while (Serial.available()==0);{}//idle until incoming serial&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {itsOn = Serial.read();//remote calling&#xA;&#xA;    if (itsOn=='?')ack=1;Serial.print(ack);}//send connected ack&#xA;&#xA;  while (Serial.available()==0);{}//idle until incoming serial&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {heatCall = Serial.read();}//incoming heatCall&#xA;&#xA;    if (heatCall=='1'){digitalWrite(relayPin,HIGH);}//turn zone relay ON&#xA;&#xA;     else {digitalWrite(relayPin,LOW);}//turn zone relay OFF&#xA;&#xA;  delay(5000);&#xA;  ack=0;&#xA;  Serial.print(ack);//turn remote BT OFF&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there some BT protocol that I am missing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I have determined that data is being transferred from remote to base and back. The data is not the expected values.&lt;/p&gt;&#xA;" OwnerUserId="8137" LastEditorUserId="37523" LastEditDate="2019-12-27T20:50:44.473" LastActivityDate="2019-12-27T20:50:44.473" Title="HC05 to HC05 Handshake Communication" Tags="|bluetooth|hc-05|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="9665" PostTypeId="1" CreationDate="2015-03-28T21:42:59.553" Score="0" ViewCount="864" Body="&lt;p&gt;i am trying to send data via Labview to my arduino board using serial communication.My problem is that the arduino reads only the first byte of sent data then when i change it ,it doesn't react.&lt;br&gt;&#xA;For example when i start the communication i send '0' to arduino.I sees it.but while it is running i send '1' but it doesn't behave accordingly to it.&lt;br&gt;&#xA;I noticed also that the board 'sees' sometime the new value after a random period of time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;char data = 'F';&#xA;&#xA;void loop()&#xA;{&#xA;    data = Serial.read();&#xA;    delay(50);&#xA;&#xA;    if (data == '0')&#xA;    {&#xA;        digitalWrite(13, HIGH);&#xA;        delay(1000);&#xA;        digitalWrite(13, LOW);&#xA;        delay(1000);&#xA;    }&#xA;    if (data == '1')&#xA;    {&#xA;        digitalWrite(13, HIGH);&#xA;        delay(4000);&#xA;        digitalWrite(13, LOW);&#xA;        delay(4000);&#xA;    }&#xA;&#xA;    data = '4';&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7328" LastEditorUserId="7508" LastEditDate="2017-06-26T19:45:17.053" LastActivityDate="2017-06-26T19:45:17.053" Title="Arduino serial communication synchronisation" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9666" PostTypeId="1" AcceptedAnswerId="9689" CreationDate="2015-03-28T21:52:46.310" Score="6" ViewCount="22571" Body="&lt;p&gt;I am currently playing with a MindWave Mobile headset. I am parsing bluetooth data received from a connected BlueSMIRF Silver.&#xA;The code I started from is a &lt;a href=&quot;http://developer.neurosky.com/docs/doku.php?id=mindwave_mobile_and_arduino&quot; rel=&quot;nofollow&quot;&gt;sample from the MindWave wiki&lt;/a&gt; and it works using hardware Serial.&#xA;For reference here is the original code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;////////////////////////////////////////////////////////////////////////&#xA;// Arduino Bluetooth Interface with Mindwave&#xA;// &#xA;// This is example code provided by NeuroSky, Inc. and is provided&#xA;// license free.&#xA;////////////////////////////////////////////////////////////////////////&#xA;&#xA;#define LED 13&#xA;#define BAUDRATE 57600&#xA;#define DEBUGOUTPUT 1&#xA;&#xA;#define GREENLED1  3&#xA;#define GREENLED2  4&#xA;#define GREENLED3  5&#xA;#define YELLOWLED1 6&#xA;#define YELLOWLED2 7&#xA;#define YELLOWLED3 8&#xA;#define YELLOWLED4 9&#xA;#define REDLED1    10&#xA;#define REDLED2    11&#xA;#define REDLED3    12&#xA;&#xA;#define powercontrol 10&#xA;&#xA;// checksum variables&#xA;byte generatedChecksum = 0;&#xA;byte checksum = 0; &#xA;int payloadLength = 0;&#xA;byte payloadData[64] = {&#xA;  0};&#xA;byte poorQuality = 0;&#xA;byte attention = 0;&#xA;byte meditation = 0;&#xA;&#xA;// system variables&#xA;long lastReceivedPacket = 0;&#xA;boolean bigPacket = false;&#xA;&#xA;//////////////////////////&#xA;// Microprocessor Setup //&#xA;//////////////////////////&#xA;void setup() {&#xA;&#xA;  pinMode(GREENLED1, OUTPUT);&#xA;  pinMode(GREENLED2, OUTPUT);&#xA;  pinMode(GREENLED3, OUTPUT);&#xA;  pinMode(YELLOWLED1, OUTPUT);&#xA;  pinMode(YELLOWLED2, OUTPUT);&#xA;  pinMode(YELLOWLED3, OUTPUT);&#xA;  pinMode(YELLOWLED4, OUTPUT);&#xA;  pinMode(REDLED1, OUTPUT);&#xA;  pinMode(REDLED2, OUTPUT);&#xA;  pinMode(REDLED3, OUTPUT);&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;  Serial.begin(BAUDRATE);           // USB&#xA;&#xA;}&#xA;&#xA;////////////////////////////////&#xA;// Read data from Serial UART //&#xA;////////////////////////////////&#xA;byte ReadOneByte() {&#xA;  int ByteRead;&#xA;&#xA;  while(!Serial.available());&#xA;  ByteRead = Serial.read();&#xA;&#xA;#if DEBUGOUTPUT  &#xA;  Serial.print((char)ByteRead);   // echo the same byte out the USB serial (for debug purposes)&#xA;#endif&#xA;&#xA;  return ByteRead;&#xA;}&#xA;&#xA;/////////////&#xA;//MAIN LOOP//&#xA;/////////////&#xA;void loop() {&#xA;&#xA;&#xA;  // Look for sync bytes&#xA;  if(ReadOneByte() == 170) {&#xA;    if(ReadOneByte() == 170) {&#xA;&#xA;      payloadLength = ReadOneByte();&#xA;      if(payloadLength &amp;gt; 169)                      //Payload length can not be greater than 169&#xA;          return;&#xA;&#xA;      generatedChecksum = 0;        &#xA;      for(int i = 0; i &amp;lt; payloadLength; i++) {  &#xA;        payloadData[i] = ReadOneByte();            //Read payload into memory&#xA;        generatedChecksum += payloadData[i];&#xA;      }   &#xA;&#xA;      checksum = ReadOneByte();                      //Read checksum byte from stream      &#xA;      generatedChecksum = 255 - generatedChecksum;   //Take one's compliment of generated checksum&#xA;&#xA;        if(checksum == generatedChecksum) {    &#xA;&#xA;        poorQuality = 200;&#xA;        attention = 0;&#xA;        meditation = 0;&#xA;&#xA;        for(int i = 0; i &amp;lt; payloadLength; i++) {    // Parse the payload&#xA;          switch (payloadData[i]) {&#xA;          case 2:&#xA;            i++;            &#xA;            poorQuality = payloadData[i];&#xA;            bigPacket = true;            &#xA;            break;&#xA;          case 4:&#xA;            i++;&#xA;            attention = payloadData[i];                        &#xA;            break;&#xA;          case 5:&#xA;            i++;&#xA;            meditation = payloadData[i];&#xA;            break;&#xA;          case 0x80:&#xA;            i = i + 3;&#xA;            break;&#xA;          case 0x83:&#xA;            i = i + 25;      &#xA;            break;&#xA;          default:&#xA;            break;&#xA;          } // switch&#xA;        } // for loop&#xA;&#xA;#if !DEBUGOUTPUT&#xA;&#xA;        // *** Add your code here ***&#xA;&#xA;        if(bigPacket) {&#xA;          if(poorQuality == 0)&#xA;            digitalWrite(LED, HIGH);&#xA;          else&#xA;            digitalWrite(LED, LOW);&#xA;          Serial.print(&quot;PoorQuality: &quot;);&#xA;          Serial.print(poorQuality, DEC);&#xA;          Serial.print(&quot; Attention: &quot;);&#xA;          Serial.print(attention, DEC);&#xA;          Serial.print(&quot; Time since last packet: &quot;);&#xA;          Serial.print(millis() - lastReceivedPacket, DEC);&#xA;          lastReceivedPacket = millis();&#xA;          Serial.print(&quot;\n&quot;);                     &#xA;        }&#xA;#endif        &#xA;        bigPacket = false;        &#xA;      }&#xA;      else {&#xA;        // Checksum Error&#xA;      }  // end if else for checksum&#xA;    } // end if read 0xAA byte&#xA;  } // end if read 0xAA byte&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One problem I have is the blocking while loop in the ReadOneByte function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte ReadOneByte() {&#xA;  int ByteRead;&#xA;&#xA;  while(!Serial.available());&#xA;  ByteRead = Serial.read();&#xA;&#xA;#if DEBUGOUTPUT  &#xA;  Serial.print((char)ByteRead);   // echo the same byte out the USB serial (for debug purposes)&#xA;#endif&#xA;&#xA;  return ByteRead;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to avoid this so I started drafting a basic state machine approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BAUDRATE 57600&#xA;&#xA;// checksum variables&#xA;byte generatedChecksum = 0;&#xA;byte checksum = 0; &#xA;int payloadLength = 0;&#xA;byte payloadData[169] = {0};&#xA;byte poorQuality = 0;&#xA;byte attention = 0;&#xA;byte meditation = 0;&#xA;&#xA;// system variables&#xA;long lastReceivedPacket = 0;&#xA;boolean bigPacket = false;&#xA;&#xA;int payloadIndex;&#xA;&#xA;int state = 0;&#xA;const int STATE_WAIT_FOR_FIRST_A        = 0;&#xA;const int STATE_WAIT_FOR_SECOND_A       = 1;&#xA;const int STATE_WAIT_FOR_PAYLOAD_LENGTH = 2;&#xA;const int STATE_WAIT_FOR_PAYLOAD        = 3;&#xA;const int STATE_WAIT_FOR_CHECKSUM       = 4;&#xA;const String stateNames[5] = {&quot;waiting for first A&quot;,&quot;waiting for second A&quot;,&quot;waiting for payload length&quot;,&quot;accumulating payload&quot;,&quot;waiting for checksum&quot;};&#xA;&#xA;void setup() {&#xA;  Serial.begin(BAUDRATE);           // USB&#xA;}&#xA;void loop() {}&#xA;void parsePayload(){&#xA;  poorQuality = 200;&#xA;  attention = 0;&#xA;  meditation = 0;&#xA;&#xA;  for(int i = 0; i &amp;lt; payloadLength; i++) {    // Parse the payload&#xA;    switch (payloadData[i]) {&#xA;    case 2:&#xA;      i++;            &#xA;      poorQuality = payloadData[i];&#xA;      bigPacket = true;            &#xA;      break;&#xA;    case 4:&#xA;      i++;&#xA;      attention = payloadData[i];                        &#xA;      break;&#xA;    case 5:&#xA;      i++;&#xA;      meditation = payloadData[i];&#xA;      break;&#xA;    case 0x80:&#xA;      i = i + 3;&#xA;      break;&#xA;    case 0x83:&#xA;      i = i + 25;      &#xA;      break;&#xA;    default:&#xA;      break;&#xA;    } // switch&#xA;  } // for loop&#xA;  Serial.print(&quot;bigPacket:&quot;);&#xA;  Serial.println(bigPacket);&#xA;  if(bigPacket) {&#xA;    Serial.print(&quot;PoorQuality: &quot;);&#xA;    Serial.print(poorQuality, DEC);&#xA;    Serial.print(&quot; Attention: &quot;);&#xA;    Serial.print(attention, DEC);&#xA;    Serial.print(&quot; Time since last packet: &quot;);&#xA;    Serial.print(millis() - lastReceivedPacket, DEC);&#xA;    lastReceivedPacket = millis();&#xA;    Serial.print(&quot;\n&quot;);                     &#xA;  }&#xA;  bigPacket = false;   &#xA;}&#xA;&#xA;void printState(){&#xA;  Serial.print(&quot;state:&quot;);&#xA;  Serial.println(stateNames[state]);&#xA;}&#xA;void serialEvent(){&#xA;  if(Serial.available() &amp;gt; 0){&#xA;    switch(state){&#xA;      case STATE_WAIT_FOR_FIRST_A:&#xA;        printState();&#xA;        if(Serial.read() == 170) state = STATE_WAIT_FOR_SECOND_A;&#xA;      break;&#xA;      case STATE_WAIT_FOR_SECOND_A:&#xA;        printState();&#xA;        if(Serial.read() == 170) state = STATE_WAIT_FOR_PAYLOAD_LENGTH;&#xA;      break;&#xA;      case STATE_WAIT_FOR_PAYLOAD_LENGTH:&#xA;        printState();&#xA;        payloadLength = Serial.read();&#xA;        Serial.print(&quot;payloadLength:&quot;);Serial.println(payloadLength);&#xA;        if(payloadLength &amp;gt; 169){&#xA;          Serial.println(payloadLength &amp;gt; 169);&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;          return;&#xA;        }&#xA;        generatedChecksum = payloadIndex = 0;&#xA;        state = STATE_WAIT_FOR_PAYLOAD;&#xA;      break;&#xA;      case STATE_WAIT_FOR_PAYLOAD:&#xA;        printState();&#xA;        if(payloadIndex &amp;lt; payloadLength){&#xA;          payloadData[payloadIndex] = Serial.read();&#xA;          generatedChecksum += payloadData[payloadIndex];&#xA;          Serial.print(&quot;payloadData[&quot;);Serial.print(payloadIndex);Serial.print(&quot; of &quot;);Serial.print(payloadLength);Serial.print(&quot;]: &quot;);&#xA;          Serial.println(payloadData[payloadIndex]);&#xA;        }else{&#xA;          state = STATE_WAIT_FOR_CHECKSUM;&#xA;        }&#xA;      break;&#xA;      case STATE_WAIT_FOR_CHECKSUM:&#xA;        printState();&#xA;        checksum = Serial.read();&#xA;        generatedChecksum = 255 - generatedChecksum;&#xA;        if(checksum == generatedChecksum) {&#xA;          Serial.println(&quot;checksum MATCH! parsing payload&quot;);&#xA;          parsePayload();&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;        }else{&#xA;          Serial.println(&quot;checksum FAIL!&quot;);&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;        }&#xA;      break;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I can understand from the &lt;a href=&quot;http://arduino.cc/en/Reference/SerialEvent&quot; rel=&quot;nofollow&quot;&gt;serialEvent() reference&lt;/a&gt; this function would be called only when a new byte is available. I've also added a condition to check if &lt;code&gt;Serial.available() &amp;gt; 0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see the messages I expect when parsing the data, but only small packets(usually 4 bytes long) end up having a correct checksum and never receive a payload with the useful EEG data I'm looking for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I check that my approach is correct or not/ I'm not loosing bytes using &lt;code&gt;serialEvent()&lt;/code&gt; instead of the blocking &lt;code&gt;while(!Serial.available())&lt;/code&gt; ? &#xA;If so, how can I rewrite the while loop in a non blocking way ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've not super experienced with Arduino, but I started reading on interrupts. Would a &lt;code&gt;USART_RX&lt;/code&gt; interrupt help at all ? (or would it do the same as serialEvent -&gt; trigger when a new byte is available?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update!&lt;/strong&gt;&#xA;Using Wirewrap's suggestion to use read() which returns -1 if there is no data, I've used &lt;a href=&quot;http://file://localhost/Applications/Arduino.app/Contents/Resources/Java/reference/Serial_Peek.html&quot; rel=&quot;nofollow&quot;&gt;peek()&lt;/a&gt; which does almost the same, except it doesn't remove the character peeked at from the buffer.&#xA;For reference here is the code used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BAUDRATE 57600&#xA;#define DEBUGOUTPUT 1&#xA;&#xA;&#xA;// checksum variables&#xA;byte generatedChecksum = 0;&#xA;byte checksum = 0; &#xA;int payloadLength = 0;&#xA;int payloadIndex;&#xA;byte payloadData[169] = {0};&#xA;byte poorQuality = 0;&#xA;byte attention = 0;&#xA;byte meditation = 0;&#xA;&#xA;// system variables&#xA;long lastReceivedPacket = 0;&#xA;boolean bigPacket = false;&#xA;&#xA;int state = 0;&#xA;const int STATE_WAIT_FOR_FIRST_A        = 0;&#xA;const int STATE_WAIT_FOR_SECOND_A       = 1;&#xA;const int STATE_WAIT_FOR_PAYLOAD_LENGTH = 2;&#xA;const int STATE_WAIT_FOR_PAYLOAD        = 3;&#xA;const int STATE_WAIT_FOR_CHECKSUM       = 4;&#xA;&#xA;void setup() {&#xA;  Serial.begin(BAUDRATE);           // USB  &#xA;}&#xA;void loop() {}&#xA;void parsePayload(){&#xA;  poorQuality = 200;&#xA;  attention = 0;&#xA;  meditation = 0;&#xA;&#xA;  for(int i = 0; i &amp;lt; payloadLength; i++) {    // Parse the payload&#xA;    switch (payloadData[i]) {&#xA;    case 2:&#xA;      i++;            &#xA;      poorQuality = payloadData[i];&#xA;      bigPacket = true;            &#xA;      break;&#xA;    case 4:&#xA;      i++;&#xA;      attention = payloadData[i];                        &#xA;      break;&#xA;    case 5:&#xA;      i++;&#xA;      meditation = payloadData[i];&#xA;      break;&#xA;    case 0x80:&#xA;      i = i + 3;&#xA;      break;&#xA;    case 0x83:&#xA;      i = i + 25;      &#xA;      break;&#xA;    default:&#xA;      break;&#xA;    } // switch&#xA;  } // for loop&#xA;  if(bigPacket) {&#xA;    Serial.print(&quot;PoorQuality: &quot;);&#xA;    Serial.print(poorQuality, DEC);&#xA;    Serial.print(&quot; Attention: &quot;);&#xA;    Serial.print(attention, DEC);&#xA;    Serial.print(&quot; Time since last packet: &quot;);&#xA;    Serial.print(millis() - lastReceivedPacket, DEC);&#xA;    lastReceivedPacket = millis();&#xA;    Serial.print(&quot;\n&quot;);                     &#xA;  }&#xA;  bigPacket = false;   &#xA;}&#xA;&#xA;void serialEvent(){&#xA;  if(Serial.peek() &amp;gt;= 0){&#xA;    switch(state){&#xA;      case STATE_WAIT_FOR_FIRST_A:&#xA;        if(Serial.read() == 170) state = STATE_WAIT_FOR_SECOND_A;&#xA;      break;&#xA;      case STATE_WAIT_FOR_SECOND_A:&#xA;        if(Serial.read() == 170) state = STATE_WAIT_FOR_PAYLOAD_LENGTH;&#xA;      break;&#xA;      case STATE_WAIT_FOR_PAYLOAD_LENGTH:&#xA;        payloadLength = Serial.read();&#xA;        if(payloadLength &amp;gt; 169){&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;          return;&#xA;        }&#xA;        generatedChecksum = payloadIndex = 0;&#xA;        state = STATE_WAIT_FOR_PAYLOAD;&#xA;      break;&#xA;      case STATE_WAIT_FOR_PAYLOAD:&#xA;        if(payloadIndex &amp;lt; payloadLength){&#xA;          payloadData[payloadIndex] = Serial.read();&#xA;          generatedChecksum += payloadData[payloadIndex];&#xA;          payloadIndex++;&#xA;        }else{&#xA;          state = STATE_WAIT_FOR_CHECKSUM;&#xA;        }&#xA;      break;&#xA;      case STATE_WAIT_FOR_CHECKSUM:&#xA;        checksum = Serial.read();&#xA;        generatedChecksum = 255 - generatedChecksum;&#xA;        if(checksum == generatedChecksum) {&#xA;          parsePayload();&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;        }else{&#xA;          state = STATE_WAIT_FOR_FIRST_A;&#xA;        }&#xA;      break;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3505" LastEditorDisplayName="user31481" LastEditDate="2017-11-17T12:16:23.420" LastActivityDate="2017-11-17T12:16:23.420" Title="How to avoid blocking while loop reading Serial?" Tags="|arduino-uno|serial|programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9667" PostTypeId="2" ParentId="9653" CreationDate="2015-03-28T23:22:18.753" Score="1" Body="&lt;p&gt;Being from eBay, I would assume the seller &quot;bricked&quot; the chip beyond his/her capability to fix.  Fortunately, you know about stack exchange!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My immediate suggestion is to find, borrow or build a high-voltage programmer.  This is a special programmer that can un-brick the chip no matter what's been done to it. The concept is easy, but you need to protect the programmer's pins from the 12v reset signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling &quot;avr high voltage programmer&quot; gives several useful links.&#xA;I'll get the actual links when I get back to a real computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so life got in the way, sorry about that.&#xA;This is the one I built which worked perfectly:&#xA;&lt;a href=&quot;http://mightyohm.com/blog/products/hv-rescue-shield-2-x/design-files/&quot; rel=&quot;nofollow&quot;&gt;MightyOhm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However hooking up the AVR to a &quot;high voltage programmer&quot; is well documented in the data sheets.  These should be very much similar &lt;a href=&quot;https://www.google.com/search?q=Schematic%20of%20a%20%22High%20Voltage%20Parallel-Programmer&amp;amp;ie=utf-8&amp;amp;oe=utf-8&quot; rel=&quot;nofollow&quot;&gt;circuits on Google&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3416" LastEditorUserId="3416" LastEditDate="2015-04-22T00:09:51.777" LastActivityDate="2015-04-22T00:09:51.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9669" PostTypeId="2" ParentId="9152" CreationDate="2015-03-28T23:40:59.437" Score="0" Body="&lt;p&gt;the network parts are &quot;owned&quot;by the yun side of the board.&#xA;the yun acts like a mini linux pc, who can seperatly connect trough a bridge library to the arduino. so.. i think you could do it or make it a router that would probaply be easier, but this all wouldnt depend on arduino code, more depend on if there are WRT packages who can do this.. i thinks they should exist as this linux variant is in other routers too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(better route then repeat btw, repeats puts delays on your entire lan)&lt;/p&gt;&#xA;" OwnerUserId="8141" LastActivityDate="2015-03-28T23:40:59.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9670" PostTypeId="1" CreationDate="2015-03-29T06:44:16.613" Score="1" ViewCount="286" Body="&lt;p&gt;Arduino Day is so popular! Many boards are cheap during arduino day. So should I buy a &lt;a href=&quot;https://day.arduino.cc/#/&quot; rel=&quot;nofollow&quot;&gt;genuine arduino board&lt;/a&gt; or &lt;a href=&quot;http://eepurl.com/biaWzT&quot; rel=&quot;nofollow&quot;&gt;a sainsmart board?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3468" LastActivityDate="2018-03-12T18:45:23.247" Title="Buy a genuine arduino board or a sainsmart board?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9672" PostTypeId="1" AcceptedAnswerId="9673" CreationDate="2015-03-29T10:23:39.027" Score="9" ViewCount="3483" Body="&lt;p&gt;In the current project I'm programming simultaneously an UNO board and a Leonardo one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switching back and forth between the two boards in the &lt;strong&gt;Tools&lt;/strong&gt; menu takes too much time because of the other 18 boards that I do not own anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to remove those boards from the Tools menu?&lt;/p&gt;&#xA;" OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-03-31T09:30:41.183" LastActivityDate="2015-11-09T21:00:08.220" Title="Remove unused boards from Arduino IDE" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9673" PostTypeId="2" ParentId="9672" CreationDate="2015-03-29T10:42:05.687" Score="8" Body="&lt;p&gt;After some more investigation of the IDE folder, I found a text file called &lt;strong&gt;boards.txt&lt;/strong&gt; in the following path.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; [Arduino Path]/hardware/arduino/boards.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: Be sure to make a copy of the file in case you mess up the following part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Between two series of '&lt;strong&gt;#&lt;/strong&gt;' characters there will be all the information on a specific microcontroller (e.g &lt;em&gt;uno.name=Arduino Uno&lt;/em&gt;). Deleting every line of text between the two '&lt;strong&gt;#&lt;/strong&gt;' series will have the desired effect of removing the board from the &lt;strong&gt;Tools&lt;/strong&gt; menu.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-03-29T10:42:05.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9674" PostTypeId="1" AcceptedAnswerId="9679" CreationDate="2015-03-29T10:47:44.523" Score="0" ViewCount="6803" Body="&lt;p&gt;My arduino has these two capacitors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0wRA6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't find any 47uf capacitors on the schematic. Is this not the value but instead a code? Where are these in the schematic?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/psqR4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6544" LastActivityDate="2018-04-24T17:38:34.593" Title="Where are these capacitors on the arduino schematic?" Tags="|power|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9675" PostTypeId="2" ParentId="9670" CreationDate="2015-03-29T10:54:29.003" Score="3" Body="&lt;p&gt;Buying an official board can be a good choice for a couple of main reasons. First of all, you're guaranteed a good quality board which conforms to the official schematic, and is definitely compatible with any relevant official software and hardware. If the board turns out to be faulty when you get it, you'll be able to get it replaced. Additionally, buying official boards means some of the money you spend goes towards funding future Arduino projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you've no doubt seen, cloned (i.e. unofficial) boards based on Arduino are often much cheaper. Nonetheless, many of the boards are very good. Functionally, you might not see any difference whatsoever from the official/genuine boards. Some of them actually have some additional features which you might find useful depending on your project, such as switching the IO pins between 3.3v and 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, not all cloned boards are worth using. Some of them may have lower quality components. It's even possible that they weren't designed/constructed correctly in the first place. This could lead to a range of problems, from incompatibilities through to outright failure of the hardware. Given the geographic location of some of the manufacturers/sellers, you may not have any way to get a refund if something goes wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose to use a clone, look for a brand which other people have had success with. Also do your best to ensure the board uses the correct microcontroller (e.g. the Atmega328 for boards based on the Uno).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately, the decision is up to you. There's no 'right' answer necessarily.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-03-29T10:54:29.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9676" PostTypeId="1" CreationDate="2015-03-29T11:14:33.837" Score="1" ViewCount="581" Body="&lt;p&gt;I am working with Arduino UNO + AdaFruit CC3000 Wi-Fi shield. I ran it with a lot of websites and webpages, but for now I am going to get sub-domain from &lt;a href=&quot;https://en.wikipedia.org/wiki/Heroku&quot; rel=&quot;nofollow&quot;&gt;Heroku&lt;/a&gt;, and it has no IP address. The sub-domain is &lt;code&gt;myapp.herokuapp.com&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I send a GET request to such an application like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // Library headers section&#xA; #include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA; #include &amp;lt;ccspi.h&amp;gt;&#xA; #include &amp;lt;SPI.h&amp;gt;&#xA; #include &amp;lt;string.h&amp;gt;&#xA; #include &quot;utility/debug.h&quot;&#xA;&#xA; // Constants area&#xA; #define ADAFRUIT_CC3000_IRQ  3 // must be an interrupt pin (2 or 3)&#xA; #define ADAFRUIT_CC3000_VBAT  5 // any pin&#xA; #define ADAFRUIT_CC3000_CS  10 // any pin&#xA;&#xA; //use hardware SPI for remaining pins&#xA; // Uno: SCK=13, MISO=12, MOSI=11&#xA; Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,      ADAFRUIT_CC3000_IRQ,&#xA;                                          ADAFRUIT_CC3000_VBAT,      SPI_CLOCK_DIVIDER);&#xA; #define WLAN_SSID  &quot;Ibtikar.AP2&quot;&#xA; #define WLAN_PASS  &quot;#ibtik@r#&quot;&#xA; // set security type&#xA; // WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2&#xA; #define WLAN_SECURITY  WLAN_SEC_WPA2&#xA; #define IDLE_TIMEOUT_MS  3000 // amount of time to wait with no date      recieved&#xA;                               // before rejecting/closing the collection&#xA; #define WEBSITE  &quot;myapp.herokuapp.com&quot;&#xA; uint32_t ip;&#xA; void setup() {&#xA;   // put your setup code here, to run once:&#xA;    Serial.begin(115200);&#xA;    Serial.print(&quot;Free RAM: &quot;); Serial.println(getFreeRam(), DEC);&#xA;/* Initialise the module */&#xA;    Serial.println(F(&quot;\nInitializing...&quot;));&#xA;    delay(100);&#xA;    if (!cc3000.begin())&#xA;    {&#xA;      Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;      while(1);&#xA;    }&#xA;    Serial.print(F(&quot;\nAttempting to connect to &quot;));           Serial.println(WLAN_SSID);&#xA;     if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;       Serial.println(F(&quot;Failed!&quot;));&#xA;       while(1);&#xA;     } &#xA;    Serial.println(F(&quot;Connected!&quot;));&#xA;    /* Wait for DHCP to complete */&#xA;    Serial.println(F(&quot;Request DHCP&quot;));&#xA;    while (!cc3000.checkDHCP())&#xA;    {&#xA;       delay(100); // ToDo: Insert a DHCP timeout!&#xA;    }  &#xA;&#xA;   /* Display the IP address DNS, Gateway, etc. */  &#xA;   while (! displayConnectionDetails()) {&#xA;     delay(1000);&#xA;   }&#xA;&#xA;    ip = 0;&#xA;   // Try looking up the website's IP address&#xA;   Serial.print(WEBSITE); Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;   while (ip == 0) {&#xA;     if (! cc3000.getHostByName(WEBSITE, &amp;amp;ip)) {&#xA;       Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;     }&#xA;     delay(500);&#xA;   }&#xA;   cc3000.printIPdotsRev(ip);&#xA;&#xA;   // Optional: Do a ping test on the website&#xA;   Serial.print(F(&quot;\n\rPinging &quot;)); cc3000.printIPdotsRev(ip);      Serial.print(&quot;...&quot;);  &#xA;   int replies = cc3000.ping(ip, 5);&#xA;   Serial.print(replies); Serial.println(F(&quot; replies&quot;));&#xA; }&#xA;&#xA; void loop() {&#xA;    /* Try connecting to the website.&#xA;      Note: HTTP/1.1 protocol is used to keep the server from closing the           connection before all data is read.&#xA;   */&#xA;    Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);&#xA;   if (www.connected()) {&#xA;     www.fastrprint(F(&quot;GET &quot;));&#xA;     www.fastrprint(F(&quot; HTTP/1.1\r\n&quot;));&#xA;     www.fastrprint(F(&quot;Host: myapp.herokuapp.com&quot;)); &#xA;     //www.fastrprint(WEBSITE); &#xA;     www.fastrprint(F(&quot;\r\n&quot;));&#xA;     www.println();&#xA;   } else {&#xA;     Serial.println(F(&quot;Connection failed&quot;));    &#xA;     return;&#xA;   }&#xA;   Serial.println(F(&quot;-------------------------------------&quot;));&#xA;   unsigned long lastRead = millis();&#xA;   while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;     while (www.available()) {&#xA;       char c = www.read();&#xA;       Serial.print(c);&#xA;       lastRead = millis();&#xA;     }&#xA;   }&#xA;   www.close();&#xA;   Serial.println(F(&quot;-------------------------------------&quot;));&#xA;&#xA;   /* You need to make sure to clean up after yourself or the CC3000 can           freak out */&#xA;   /* the next time your try to connect ... */&#xA;        Serial.println(F(&quot;\n\nDisconnecting&quot;));&#xA;   cc3000.disconnect();&#xA;   delay(1000);&#xA; }&#xA;&#xA;&#xA; /**************************************************************************/&#xA; /*!&#xA;     @brief  Begins an SSID scan and prints out all the visible networks&#xA; */&#xA; /**************************************************************************/&#xA;&#xA; void listSSIDResults(void)&#xA; {     &#xA;   uint32_t index;&#xA;   uint8_t valid, rssi, sec;&#xA;   char ssidname[33]; &#xA;&#xA;   if (!cc3000.startSSIDscan(&amp;amp;index)) {&#xA;          Serial.println(F(&quot;SSID scan failed!&quot;));&#xA;          return;&#xA;   }&#xA;&#xA;   Serial.print(F(&quot;Networks found: &quot;)); Serial.println(index);&#xA;   Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;   while (index) {&#xA;     index--;&#xA;&#xA;     valid = cc3000.getNextSSID(&amp;amp;rssi, &amp;amp;sec, ssidname);&#xA;&#xA;     Serial.print(F(&quot;SSID Name    : &quot;)); Serial.print(ssidname);&#xA;     Serial.println();&#xA;     Serial.print(F(&quot;RSSI         : &quot;));&#xA;     Serial.println(rssi);&#xA;     Serial.print(F(&quot;Security Mode: &quot;));&#xA;     Serial.println(sec);&#xA;     Serial.println();&#xA;   }&#xA;   Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;   cc3000.stopSSIDscan();&#xA; }&#xA;&#xA;      /**************************************************************************/&#xA; /*!&#xA;     @brief  Tries to read the IP address and other connection details&#xA; */&#xA; /**************************************************************************/&#xA; bool displayConnectionDetails(void)&#xA; {&#xA;   uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;   if(!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv,      &amp;amp;dnsserv))&#xA;   {&#xA;     Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;     return false;&#xA;   }&#xA;   else&#xA;   {&#xA;     Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;     Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;     Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;     Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;     Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;     Serial.println();&#xA;     return true;&#xA;   }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7807" LastEditorUserId="6936" LastEditDate="2016-01-06T14:47:40.103" LastActivityDate="2016-04-07T21:21:53.177" Title="CC3000 - Send GET request to an app, or sub-domain, on Heroku" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9677" PostTypeId="1" CreationDate="2015-03-29T11:46:54.513" Score="-1" ViewCount="2339" Body="&lt;p&gt;I really need all the help I can get...&#xA;It's been a week now and I'm still not able to solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have text file on a server. The whole address is www.example.com/test.txt&#xA;I want to read the file using a GET request every 3-5 secs and parse it for further actions. But the arduino codes that I've tried till now use software serial and it keeps misbehaving. Sometimes it skips a few serial-print commands and loops back sometimes it reads the file 3-4 times and then hangs. Basically I'm getting the response only a few times but then it stops working properly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to solve this...I need a working arduino code to work with ESP8266 so that I can successfully poll a text file from server without any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my current code - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;    #define led 13&#xA;    SoftwareSerial esp(11, 12);&#xA;    String domain = &quot;www.example.com&quot;;&#xA;    String request = &quot;GET /test.txt HTTP/1.0\r\n\r\n&quot;;&#xA;&#xA;&#xA;    void SerialDo(String command, float time, bool debug) {&#xA;      delay(100);&#xA;      esp.print(command);&#xA;&#xA;      int i = millis();&#xA;      while (millis() - i &amp;lt; (time * 1000)) {&#xA;        while ( (esp.available())) {&#xA;          if (debug) {&#xA;            Serial.print((char)esp.read());&#xA;          }&#xA;        }&#xA;      }&#xA;&#xA;      Serial.flush();&#xA;    }&#xA;&#xA;    void setup() {&#xA;      // put your setup code here, to run once:&#xA;      digitalWrite(led, OUTPUT);&#xA;      Serial.begin(9600);&#xA;      esp.begin(9600);&#xA;      esp.setTimeout(3000);&#xA;      digitalWrite(led, LOW);&#xA;      Serial.println(&quot;Hello&quot;);&#xA;      //delay(2000);&#xA;      SerialDo(&quot;AT+RST\r\n&quot;, 5, true);&#xA;      Serial.flush();&#xA;      SerialDo(&quot;AT+CWMODE=1\r\n&quot;, 0.5, true);&#xA;&#xA;      delay(1000);&#xA;      //SerialDo(&quot;AT+CWLAP\r\n&quot;, 5, true);&#xA;      SerialDo(&quot;AT+CWJAP=\&quot;Sherlock\&quot;,\&quot;Watson@11\&quot;\r\n&quot;, 10, true);&#xA;      SerialDo(&quot;AT+CIPMUX=0\r\n&quot;, 0.5, true);&#xA;&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;&#xA;      delay(1000);&#xA;      Serial.print(&quot;loop\r\n&quot;);&#xA;&#xA;      SerialDo(&quot;AT+CIPMUX=0\r\n&quot;, 0.5, true);&#xA;      SerialDo(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot; + domain + &quot;\&quot;,80\r\n&quot;, 1.5, true);&#xA;      esp.flush();&#xA;&#xA;      esp.print(&quot;AT+CIPSEND=&quot; + String(request.length()) + &quot;\r\n&quot;);&#xA;      delay(100);&#xA;      esp.print(request);&#xA;&#xA;      String t = &quot;&quot;;&#xA;      int i = millis();&#xA;      while (millis() - i &amp;lt; 1500) {&#xA;        while ((esp.available() &amp;gt; 0)) {&#xA;          if (true) {&#xA;            char c = (char)esp.read();&#xA;            t += c;&#xA;            Serial.print(c);&#xA;          }&#xA;        }&#xA;      }&#xA;&#xA;      esp.print(&quot;AT+CIPCLOSE\r\n&quot;);&#xA;&#xA;      if (t.indexOf(&quot;hello world&quot;) &amp;gt; -1) {&#xA;        digitalWrite(led, !digitalRead(led));&#xA;      }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5142" LastActivityDate="2016-02-08T17:47:01.603" Title="Arduino + ESP8266 - poll file from a server?" Tags="|arduino-uno|arduino-nano|esp8266|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9678" PostTypeId="1" AcceptedAnswerId="12206" CreationDate="2015-03-29T12:59:57.057" Score="0" ViewCount="446" Body="&lt;p&gt;I am trying to design a bicycle LED lighting system, and for that I bought an Arduino yesterday (so very beginner with Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My final system will operate at 6V, so I plan to put everything on a breadbord and tune everything (blinking times, resistor values, etc.) and for that I want to keep my Arduino plugged to USB during development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I connect USB-powered Arduino to a higher-voltage-powered breadbord (between 6 and 12V) safely?&lt;/p&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="8044" LastEditDate="2015-03-29T14:07:31.827" LastActivityDate="2015-05-28T22:44:48.090" Title="Run Arduino on USB and at the same time BreadBoard on higher voltage?" Tags="|power|voltage-level|usb|battery|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9679" PostTypeId="2" ParentId="9674" CreationDate="2015-03-29T13:18:56.333" Score="4" Body="&lt;p&gt;&lt;strong&gt;What:&lt;/strong&gt; Looking at the schematic that you provided, it seems likely that they serve as C6 &amp;amp; C7. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; These are shown as 100 uF each and act as &quot;filter&quot; capacitors for IC4, the 5V regulator.&lt;br&gt;&#xA;Within certain limits, such capacitors are not critical in value, and the manufacturer has probably decided that a factor of in the capacitance is probably acceptable.&lt;br&gt;&#xA;They are probably correct :-).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to check:&lt;/strong&gt; You can check this yourself with an Ohm-meter set to the lowest Ohm range available - often = 200 Ohms max.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn off power to the board and leave it off for say 5 minutes to allow capacitors to discharge.&lt;br&gt;&#xA;Locate I4 and find its input and output pins or tracks leading to them. You can often get ohmic connections at vias as the tracks change board layers.&lt;br&gt;&#xA;IC4 pin1 will be grounded.&lt;br&gt;&#xA;One lead of C6 &amp;amp; C7 are also grounded.&lt;br&gt;&#xA;The pad you can see in your photo on the board edge side of the caaps is probably the -ve terminals (about 99%+ likely) (and they match the can markings) &#xA;and the &quot;stippled&quot; surface is almost certainly system ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can confirm that the two caps are connected to ground as and where described above, then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apply Ohm meter probes between the non ground lead of a capacitor and each non-ground pin in turn of IC4. One of them will be a low resistance connection if they are C6 &amp;amp; C7. Check the other capacitor - it should connect to the other side of IC4.&lt;br&gt;&#xA;Reversing the meter leads in each case may give somewhat different readings for non-hard-connected points but should be low and consistent for hard-connected by a track points. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-03-29T13:18:56.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9680" PostTypeId="1" CreationDate="2015-03-29T13:42:06.037" Score="0" ViewCount="3904" Body="&lt;p&gt;I am trying to read from a bluetooth module connected to arduino Uno. My application is a simple counter where the values are displayed on the arduino and the android app. The problem is that my android application get readings for some time (40-50 sec) and then stop at a random reading. When I check on the arduino serial monitor, the counter keeps counting and doesn't stop. Can someone please help? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Ignore the buttons that I created :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Java code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package com.example.ibm.bluetooth_3;&#xA;&#xA;import java.io.IOException;&#xA;import java.io.InputStream;&#xA;import java.io.OutputStream;&#xA;import java.lang.reflect.Method;&#xA;import java.util.UUID;&#xA;import com.example.ibm.bluetooth_3.R;&#xA;&#xA;import android.app.Activity;&#xA;import android.bluetooth.BluetoothAdapter;&#xA;import android.bluetooth.BluetoothDevice;&#xA;import android.bluetooth.BluetoothSocket;&#xA;import android.content.Intent;&#xA;import android.os.Build;&#xA;import android.os.Bundle;&#xA;import android.os.Handler;&#xA;import android.util.Log;&#xA;import android.view.View;&#xA;import android.view.View.OnClickListener;&#xA;import android.widget.Button;&#xA;import android.widget.EditText;&#xA;import android.widget.TextView;&#xA;import android.widget.Toast;&#xA;&#xA;public class MainActivity extends Activity {&#xA;    private static final String TAG = &quot;bluetooth2&quot;;&#xA;&#xA;    Button btnOn, btnOff;&#xA;    TextView txtArduino;&#xA;    Handler h;&#xA;&#xA;    final int RECIEVE_MESSAGE = 1;      // Status  for Handler&#xA;    private BluetoothAdapter btAdapter = null;&#xA;    private BluetoothSocket btSocket = null;&#xA;    private StringBuilder sb = new StringBuilder();&#xA;&#xA;    private ConnectedThread mConnectedThread;&#xA;&#xA;    // SPP UUID service&#xA;    private static final UUID MY_UUID = UUID.fromString(&quot;00001101-0000-1000-8000-00805F9B34FB&quot;);&#xA;&#xA;    // MAC-address of Bluetooth module (you must edit this line)&#xA;    private static String address = &quot;00:06:66:68:30:D6&quot;;&#xA;&#xA;    /** Called when the activity is first created. */&#xA;    @Override&#xA;    public void onCreate(Bundle savedInstanceState) {&#xA;        super.onCreate(savedInstanceState);&#xA;        setContentView(R.layout.activity_main);&#xA;        btnOn = (Button) findViewById(R.id.btnOn);                  // button LED ON&#xA;        btnOff = (Button) findViewById(R.id.btnOff);                // button LED OFF&#xA;        txtArduino = (EditText) findViewById(R.id.txtArduino);      // for display the received data from the Arduino&#xA;        h = new Handler() {&#xA;            public void handleMessage(android.os.Message msg) {&#xA;                switch (msg.what) {&#xA;                    case RECIEVE_MESSAGE:                                                   // if receive massage&#xA;                        byte[] readBuf = (byte[]) msg.obj;&#xA;                        String strIncom = new String(readBuf, 0, msg.arg1);                 // create string from bytes array&#xA;                        sb.append(strIncom);                                                // append string&#xA;                        int endOfLineIndex = sb.indexOf(&quot;\r\n&quot;);                            // determine the end-of-line&#xA;                        if (endOfLineIndex &amp;gt; 0) {                                           // if end-of-line,&#xA;                            String sbprint = sb.substring(0, endOfLineIndex);               // extract string&#xA;                           sb.delete(0, sb.length());                                       // and clear&#xA;                            txtArduino.setText(sbprint);                                    // update TextView&#xA;                        }&#xA;                        //Log.d(TAG, &quot;...String:&quot;+ sb.toString() +  &quot;Byte:&quot; + msg.arg1 + &quot;...&quot;);&#xA;                        break;&#xA;                }&#xA;            };&#xA;        };&#xA;&#xA;        btAdapter = BluetoothAdapter.getDefaultAdapter();       // get Bluetooth adapter&#xA;        checkBTState();&#xA;&#xA;        btnOn.setOnClickListener(new OnClickListener() {&#xA;            public void onClick(View v) {&#xA;                btnOn.setEnabled(true);&#xA;                mConnectedThread.write(&quot;1&quot;);    // Send &quot;1&quot; via Bluetooth&#xA;                //Toast.makeText(getBaseContext(), &quot;Turn on LED&quot;, Toast.LENGTH_SHORT).show();&#xA;            }&#xA;        });&#xA;&#xA;        btnOff.setOnClickListener(new OnClickListener() {&#xA;            public void onClick(View v) {&#xA;                btnOff.setEnabled(true);&#xA;                mConnectedThread.write(&quot;0&quot;);    // Send &quot;0&quot; via Bluetooth&#xA;                //Toast.makeText(getBaseContext(), &quot;Turn off LED&quot;, Toast.LENGTH_SHORT).show();&#xA;            }&#xA;        });&#xA;    }&#xA;&#xA;    private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {&#xA;        if(Build.VERSION.SDK_INT &amp;gt;= 10){&#xA;            try {&#xA;                final Method  m = device.getClass().getMethod(&quot;createInsecureRfcommSocketToServiceRecord&quot;, new Class[] { UUID.class });&#xA;                return (BluetoothSocket) m.invoke(device, MY_UUID);&#xA;            } catch (Exception e) {&#xA;                Log.e(TAG, &quot;Could not create Insecure RFComm Connection&quot;,e);&#xA;            }&#xA;        }&#xA;        return  device.createRfcommSocketToServiceRecord(MY_UUID);&#xA;    }&#xA;&#xA;    @Override&#xA;    public void onResume() {&#xA;        super.onResume();&#xA;&#xA;        Log.d(TAG, &quot;...onResume - try connect...&quot;);&#xA;&#xA;        // Set up a pointer to the remote node using it's address.&#xA;        BluetoothDevice device = btAdapter.getRemoteDevice(address);&#xA;&#xA;        // Two things are needed to make a connection:&#xA;        //   A MAC address, which we got above.&#xA;        //   A Service ID or UUID.  In this case we are using the&#xA;        //     UUID for SPP.&#xA;&#xA;        try {&#xA;            btSocket = createBluetoothSocket(device);&#xA;        } catch (IOException e) {&#xA;            errorExit(&quot;Fatal Error&quot;, &quot;In onResume() and socket create failed: &quot; + e.getMessage() + &quot;.&quot;);&#xA;        }&#xA;&#xA;    /*try {&#xA;      btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);&#xA;    } catch (IOException e) {&#xA;      errorExit(&quot;Fatal Error&quot;, &quot;In onResume() and socket create failed: &quot; + e.getMessage() + &quot;.&quot;);&#xA;    }*/&#xA;&#xA;        // Discovery is resource intensive.  Make sure it isn't going on&#xA;        // when you attempt to connect and pass your message.&#xA;        btAdapter.cancelDiscovery();&#xA;&#xA;        // Establish the connection.  This will block until it connects.&#xA;        Log.d(TAG, &quot;...Connecting...&quot;);&#xA;        try {&#xA;            btSocket.connect();&#xA;            Log.d(TAG, &quot;....Connection ok...&quot;);&#xA;        } catch (IOException e) {&#xA;            try {&#xA;                btSocket.close();&#xA;            } catch (IOException e2) {&#xA;                errorExit(&quot;Fatal Error&quot;, &quot;In onResume() and unable to close socket during connection failure&quot; + e2.getMessage() + &quot;.&quot;);&#xA;            }&#xA;        }&#xA;&#xA;        // Create a data stream so we can talk to server.&#xA;        Log.d(TAG, &quot;...Create Socket...&quot;);&#xA;&#xA;        mConnectedThread = new ConnectedThread(btSocket);&#xA;        mConnectedThread.start();&#xA;    }&#xA;&#xA;    @Override&#xA;    public void onPause() {&#xA;        super.onPause();&#xA;&#xA;        Log.d(TAG, &quot;...In onPause()...&quot;);&#xA;&#xA;        try     {&#xA;            btSocket.close();&#xA;        } catch (IOException e2) {&#xA;            errorExit(&quot;Fatal Error&quot;, &quot;In onPause() and failed to close socket.&quot; + e2.getMessage() + &quot;.&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    private void checkBTState() {&#xA;        // Check for Bluetooth support and then check to make sure it is turned on&#xA;        // Emulator doesn't support Bluetooth and will return null&#xA;        if(btAdapter==null) {&#xA;            errorExit(&quot;Fatal Error&quot;, &quot;Bluetooth not support&quot;);&#xA;        } else {&#xA;            if (btAdapter.isEnabled()) {&#xA;                Log.d(TAG, &quot;...Bluetooth ON...&quot;);&#xA;            } else {&#xA;                //Prompt user to turn on Bluetooth&#xA;                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);&#xA;                startActivityForResult(enableBtIntent, 1);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    private void errorExit(String title, String message){&#xA;        Toast.makeText(getBaseContext(), title + &quot; - &quot; + message, Toast.LENGTH_LONG).show();&#xA;        finish();&#xA;    }&#xA;&#xA;    private class ConnectedThread extends Thread {&#xA;        private final InputStream mmInStream;&#xA;        private final OutputStream mmOutStream;&#xA;&#xA;        public ConnectedThread(BluetoothSocket socket) {&#xA;            InputStream tmpIn = null;&#xA;            OutputStream tmpOut = null;&#xA;&#xA;            // Get the input and output streams, using temp objects because&#xA;            // member streams are final&#xA;            try {&#xA;                tmpIn = socket.getInputStream();&#xA;                tmpOut = socket.getOutputStream();&#xA;            } catch (IOException e) { }&#xA;&#xA;            mmInStream = tmpIn;&#xA;            mmOutStream = tmpOut;&#xA;        }&#xA;&#xA;        public void run() {&#xA;            byte[] buffer = new byte[1024];  // buffer store for the stream&#xA;            int bytes; // bytes returned from read()&#xA;            // Keep listening to the InputStream until an exception occurs&#xA;            while (true) {&#xA;                try {&#xA;                    // Read from the InputStream&#xA;                    bytes = mmInStream.read(buffer);        // Get number of bytes and message in &quot;buffer&quot;&#xA;                    h.obtainMessage(RECIEVE_MESSAGE, bytes, -1, buffer).sendToTarget();     // Send to message queue Handler&#xA;                } catch (IOException e) {&#xA;                    break;&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        /* Call this from the main activity to send data to the remote device */&#xA;        public void write(String message) {&#xA;            Log.d(TAG, &quot;...Data to send: &quot; + message + &quot;...&quot;);&#xA;            byte[] msgBuffer = message.getBytes();&#xA;            try {&#xA;                mmOutStream.write(msgBuffer);&#xA;            } catch (IOException e) {&#xA;                Log.d(TAG, &quot;...Error data send: &quot; + e.getMessage() + &quot;...&quot;);&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Android XML:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&#xA;    xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:layout_width=&quot;match_parent&quot;&#xA;    android:layout_height=&quot;match_parent&quot; android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;&#xA;    android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;&#xA;    android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;&#xA;    android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot; tools:context=&quot;.MainActivity&quot;&#xA;    android:focusable=&quot;true&quot;&amp;gt;&#xA;&#xA;    &amp;lt;Button&#xA;        android:layout_width=&quot;wrap_content&quot;&#xA;        android:layout_height=&quot;wrap_content&quot;&#xA;        android:text=&quot;On&quot;&#xA;        android:id=&quot;@+id/btnOn&quot;&#xA;        android:layout_alignParentTop=&quot;true&quot;&#xA;        android:layout_centerHorizontal=&quot;true&quot;&#xA;        android:layout_marginTop=&quot;52dp&quot;&#xA;        android:enabled=&quot;true&quot;&#xA;        android:focusable=&quot;true&quot;&#xA;        android:focusableInTouchMode=&quot;true&quot; /&amp;gt;&#xA;&#xA;    &amp;lt;Button&#xA;        android:layout_width=&quot;wrap_content&quot;&#xA;        android:layout_height=&quot;wrap_content&quot;&#xA;        android:text=&quot;Off&quot;&#xA;        android:id=&quot;@+id/btnOff&quot;&#xA;        android:layout_below=&quot;@+id/btnOn&quot;&#xA;        android:layout_centerHorizontal=&quot;true&quot;&#xA;        android:layout_marginTop=&quot;63dp&quot;&#xA;        android:enabled=&quot;true&quot;&#xA;        android:focusable=&quot;true&quot;&#xA;        android:focusableInTouchMode=&quot;true&quot; /&amp;gt;&#xA;&#xA;    &amp;lt;EditText&#xA;        android:layout_width=&quot;wrap_content&quot;&#xA;        android:layout_height=&quot;wrap_content&quot;&#xA;        android:inputType=&quot;number&quot;&#xA;        android:ems=&quot;10&quot;&#xA;        android:id=&quot;@+id/txtArduino&quot;&#xA;        android:layout_below=&quot;@+id/btnOff&quot;&#xA;        android:layout_centerHorizontal=&quot;true&quot;&#xA;        android:layout_marginTop=&quot;65dp&quot; /&amp;gt;&#xA;&#xA;&amp;lt;/RelativeLayout&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Android Manifest: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&#xA;&amp;lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&#xA;    package=&quot;com.example.ibm.bluetooth_3&quot; &amp;gt;&#xA;    &amp;lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot; /&amp;gt;&#xA;    &amp;lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_ADMIN&quot; /&amp;gt;&#xA;    &amp;lt;application&#xA;        android:allowBackup=&quot;true&quot;&#xA;        android:icon=&quot;@drawable/ic_launcher&quot;&#xA;        android:label=&quot;@string/app_name&quot;&#xA;        android:theme=&quot;@style/AppTheme&quot; &amp;gt;&#xA;        &amp;lt;activity&#xA;            android:name=&quot;.MainActivity&quot;&#xA;            android:label=&quot;@string/app_name&quot; &amp;gt;&#xA;            &amp;lt;intent-filter&amp;gt;&#xA;                &amp;lt;action android:name=&quot;android.intent.action.MAIN&quot; /&amp;gt;&#xA;&#xA;                &amp;lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&amp;gt;&#xA;            &amp;lt;/intent-filter&amp;gt;&#xA;        &amp;lt;/activity&amp;gt;&#xA;    &amp;lt;/application&amp;gt;&#xA;&#xA;&amp;lt;/manifest&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial (3, 2);&#xA;void setup()&#xA;{&#xA;  Serial.begin (57600);&#xA;  mySerial.begin (115200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for (int i=0; i &amp;lt; 1000000; i++)&#xA;  {&#xA;    mySerial.println (i);&#xA;    Serial.println (i);&#xA;    delay (100);&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7875" LastActivityDate="2016-02-14T15:45:30.520" Title="Android stops reading from bluetooth module" Tags="|arduino-uno|bluetooth|android|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9681" PostTypeId="2" ParentId="9678" CreationDate="2015-03-29T14:32:16.820" Score="0" Body="&lt;p&gt;Unless you intend to run both supplies simultaneously, there's no problem. Your ~ 6v input will need to be stepped down and regulated to 5v, and the USB provides a regulated 5v, so the system shouldn't care which one you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to run your system off the 6v during development and need USB communication, I'd suggest using a USB-to-TTL-Serial cable such as this one: &lt;a href=&quot;https://www.sparkfun.com/products/9718&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9718&lt;/a&gt;. Connect its Tx &amp;amp; Rx pins to your Arduino's (Uno?) pins 1 and 0, respectively, and it's ground pin to the ground rail served by your battery supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical regulators will need more headroom above their output voltage to give you a steady, regulated output, and this includes the 5v regulators on Arduino boards which usually specify 7-12v at the Vin (unregulated) input. A 6v battery won't meet this spec so you'd need a buck/boost regulator that could provide a regulated 5v from &quot;0+&quot; to 6v input. Or you might move your system to a bare AtMega328p with a lower clock speed (see the data sheet for max clock speed vs. Vcc), and run it at 3v (for example) which would give a simpler regulator more headroom from its 6v input.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-03-29T14:32:16.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9682" PostTypeId="2" ParentId="9680" CreationDate="2015-03-29T14:50:18.070" Score="0" Body="&lt;p&gt;On the Arduino side, try increasing the delay or decreasing the baud rate. I have an application that dumps a stored history to a Bluetooth module talking to &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.emrctn.BluetoothGraphics&quot; rel=&quot;nofollow&quot;&gt;Bluetooth Terminal/Graphics&lt;/a&gt;&#xA;on a Google Nexus 7. At 57600 baud, I've seen the same thing happen. My solution was to delay for 50ms after every 100 lines of output. While your Arduino code should be sending even slower than mine does, your Android system including your application code, might need an even slower input.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-03-29T15:10:37.367" LastActivityDate="2015-03-29T15:10:37.367" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9683" PostTypeId="1" AcceptedAnswerId="9685" CreationDate="2015-03-29T15:06:32.390" Score="1" ViewCount="205" Body="&lt;p&gt;I have written an ISR-based timer library for Arduino Uno and I would like to share it on the website and get it reviewed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am stuck on how to post it to playground.&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="4628" LastEditDate="2017-08-04T04:06:29.000" LastActivityDate="2017-08-04T04:07:12.980" Title="How to share a library on Arduino Playground?" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9684" PostTypeId="2" ParentId="8847" CreationDate="2015-03-29T15:13:13.557" Score="0" Body="&lt;p&gt;You should try another USB port, install the right drivers for the TTL/uart chip and reboot your PC. That worked for me.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, you should consider getting an arduino nano usb, these have an built in ttl/uart converter, ICSP header and can be placed on a breadboard easily.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-03-29T15:13:13.557" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9685" PostTypeId="2" ParentId="9683" CreationDate="2015-03-29T15:50:52.000" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Main/LibraryList&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Playground library list&lt;/a&gt; is a wiki page (like everything on the playground). That means anyone can log in to edit it and add links to their own libraries. The &quot;Log In&quot; and &quot;Sign Up&quot; links are at the top right of the Arduino site. When you first go to edit a Playground page you'll be taken to a &quot;Password required&quot; page but don't worry, this is only to prevent spam and the password is pre-filled. You only need to click the &quot;I'm not a robot&quot; checkbox, wait for the green checkmark to appear, then click &quot;Submit&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of important things to note though. Firstly, the Playground library list isn't there for getting your work reviewed. It's a place to post things that are functional and ready to be used by other people. If you need someone to help with your project then you can maybe post on the Arduino forums. Alternatively, if you have specific questions, you can post here on Arduino SE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're ready to post your library online, you also have to be aware that the Playground itself won't host your code. You can put a link there and maybe some documentation. However, you'll need to host your code somewhere else, such as &lt;a href=&quot;https://github.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="4628" LastEditDate="2017-08-04T04:07:12.980" LastActivityDate="2017-08-04T04:07:12.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9686" PostTypeId="2" ParentId="9665" CreationDate="2015-03-29T16:28:59.457" Score="1" Body="&lt;p&gt;I suspect you problem stems from the use of delay's in your code. for example,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (data=='1')&#xA; {&#xA;  digitalWrite(13,HIGH);&#xA;  delay(4000);&#xA;  digitalWrite(13,LOW);&#xA;  delay(4000);&#xA; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those delays prevent any computations from happening for 4 seconds each. Your arduino will not read another character after it sees a &lt;code&gt;'1'&lt;/code&gt; for 8 seconds. If you send too much data in that 8 seconds to fit in the serial buffer, the extra characters are lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior you seem to want will require separating the code that reads serial from the code that runs the output, and making sure neither section ever stops execution with delays. Your blinks will need to be timed with something else, like frequent comparisons against the current time with &lt;code&gt;millis()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-29T16:28:59.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9687" PostTypeId="1" CreationDate="2015-03-29T17:28:35.030" Score="2" ViewCount="1157" Body="&#xA;&#xA;&lt;p&gt;I'm trying to configure a Zigbee sensor network. My &quot;gateway (coordinator)&quot; and &quot;End devices&quot; are made with XBeePro S2B model and configured in API mode &quot;2&quot;. The &quot;gateway (coordinator)&quot; also has a SIM900 module, for uploading data to website (recieved on XBee), and Atmega 328p for codes (for &quot;gateway (coordinator)&quot; I'm using a Gboard device &lt;a href=&quot;http://imall.iteadstudio.com/im120411004.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;), and for &quot;End devices&quot;, I make/print a PCB with a atmega328p, XBee and PIR sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The configuration works fine with several &quot;End devices&quot; (sincerilly, I have only tested with two &quot;End devices&quot;, because it is expensive)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when the &quot;gateway (coordinator)&quot; recieve data from more than one &quot;End devices&quot; &lt;strong&gt;at the same time&lt;/strong&gt;. In this situation (&quot;End devices&quot; sending simultaneously) the &quot;gateway (coordinator)&quot; only recieves one packet (and only uploads that data to the website). I'm sure that I have a trouble with my code (sorry for the desestructurated and chaotic code, I'm a newbie).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with the code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;code &quot;gateway (coordinator)&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Streaming.h&amp;gt; &#xA;#include &amp;lt;XBee.h&amp;gt;      &#xA;int xbeeRecibido;&#xA;char urlArreglo[100];&#xA;uint8_t slCmd[] = {'S','L'};  &#xA;uint8_t dbCmd[] = {'D','B'}; &#xA;char adr_part[8];&#xA;char rssiValor_part[8];&#xA;String adr=&quot;&quot;;&#xA;String rssiValor=&quot;&quot;;&#xA;AtCommandRequest atRequest = AtCommandRequest();&#xA;AtCommandResponse atResponse = AtCommandResponse();  &#xA;elapsedMillis timeElapsed = 0;&#xA;unsigned long interval = 1800000 ;////en milisegundos  cada 30 min.&#xA;String direccionRed;&#xA;int bateria;&#xA;String valorRssi;&#xA;int actividadPir;&#xA;String datosHttp; ///concatenacion de datos para enviar por HTTP&#xA;int8_t answer;&#xA;char data[512];&#xA;int data_size;&#xA;char aux_str[100];&#xA;char aux;&#xA;int x = 0;&#xA;XBee xbee = XBee();//XBee object&#xA;Rx16Response rx = Rx16Response();&#xA;SoftwareSerial mySerial(2, 3); //PARA GPRS SIM900&#xA;//int b00;  //este seria el primero, que se pierde al buscar el 0X7E&#xA;int b01;&#xA;int b02;&#xA;int b03;&#xA;int b04; //source network adress 64Bit &#xA;int b05; //source network adress 64Bit&#xA;int b06; //source network adress 64Bit&#xA;int b07; //source network adress 64Bit&#xA;int b08; //source network adress 64Bit&#xA;int b09; //source network adress 64Bit&#xA;int b10; //source network adress 64Bit&#xA;int b11; //source network adress 64Bit &#xA;int b12; //source network adress 16Bit&#xA;int b13; //source network adress 16Bit&#xA;int b14;&#xA;int b15; //pir digital&#xA;int b16; //bateria &#xA;int b17; //checksum&#xA;void setup() {&#xA;   pinMode(14, OUTPUT);////led debug en 14 ((A0)DEBUGGGG!!!!&#xA;   pinMode(6, OUTPUT);///para encender SIM900 ...en pin6 HIGH de arduino GBOARD&#xA;   digitalWrite(6, HIGH);///para encender SIM900 ...en pin6 HIGH de arduino GBOARD&#xA;    mySerial.begin(9600); &#xA;    Serial.begin(9600);&#xA;///////GPRS////////&#xA;    power_on();&#xA;    delay(3000);&#xA;    sendATcommand(&quot;AT+ipr=9600&quot;, &quot;OK&quot;, 2000);///////MIO PARA BAUDERATE A 9600 (por defecto 0=auto..¿se apaga?)&#xA;    // sets the PIN code&#xA;    sendATcommand(&quot;AT+CPIN=****&quot;, &quot;OK&quot;, 2000);&#xA;    delay(3000);&#xA;    while (sendATcommand2(&quot;AT+CREG?&quot;, &quot;+CREG: 0,1&quot;, &quot;+CREG: 0,5&quot;, 2000) == 0);&#xA;    sendATcommand(&quot;AT+SAPBR=3,1,\&quot;Contype\&quot;,\&quot;GPRS\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;    sendATcommand(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;gprsmov.pepephone.com\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;    sendATcommand(&quot;AT+SAPBR=3,1,\&quot;USER\&quot;,\&quot;\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;    sendATcommand(&quot;AT+SAPBR=3,1,\&quot;PWD\&quot;,\&quot;\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;    while (sendATcommand(&quot;AT+SAPBR=1,1&quot;, &quot;OK&quot;, 20000) == 0)&#xA;    {&#xA;        delay(5000);&#xA;    }&#xA;////FIN GPRS////&#xA;lanzarHttpAutoControl();&#xA;delay(15000);&#xA;}&#xA;&#xA;void loop() {  &#xA;if (timeElapsed &amp;gt; interval) &#xA;    {               &#xA;        lanzarHttpAutoControl();&#xA;        delay(15000);&#xA;    timeElapsed = 0;&#xA;    }&#xA;if (Serial.available()==18) {//make sure the frame is all there      &#xA;  if (Serial.read()==0x7E) {   &#xA;     b01 = Serial.read();     &#xA;     b02 = Serial.read();&#xA;     b03 = Serial.read();    &#xA;     b04 = Serial.read(); //source network adress 64Bit &#xA;     b05 = Serial.read(); //source network adress 64Bit    &#xA;     b06 = Serial.read(); //source network adress 64Bit &#xA;     b07 = Serial.read(); //source network adress 64Bit     &#xA;     b08 = Serial.read(); //source network adress 64Bit &#xA;     b09 = Serial.read(); //source network adress 64Bit     &#xA;     b10 = Serial.read(); //source network adress 64Bit &#xA;     b11 = Serial.read(); //source network adress 64Bit &#xA;     b12 = Serial.read(); //source network adress 16Bit&#xA;     b13 = Serial.read(); //source network adress 16Bit&#xA;     b14 = Serial.read(); &#xA;     b15 = Serial.read(); //pir digital   &#xA;     b16 = Serial.read(); //bateria&#xA;     b17 = Serial.read();  //checksum&#xA;     direccionRed =  String(b04, HEX); &#xA;     direccionRed +=  String(b05, HEX); &#xA;     direccionRed +=  String(b06, HEX);&#xA;     direccionRed +=  String(b07, HEX);&#xA;     direccionRed +=  String(b08, HEX);&#xA;     direccionRed +=  String(b09, HEX);&#xA;     direccionRed +=  String(b10, HEX);&#xA;     direccionRed +=  String(b11, HEX);  &#xA;     actividadPir = b15;&#xA;     bateria = int(b16);&#xA;     digitalWrite(14, HIGH);//FOR DEBUG LED&#xA;     delay(1000);//FOR DEBUG LED&#xA;     digitalWrite(14, LOW);//FOR DEBUG LED&#xA;     xbeeRecibido = 1;&#xA;        } //fin if 0x7E &#xA;  }///fin recorrer bytes &#xA;   else {&#xA;         if (xbeeRecibido == 1) {///si se ha recibido info de xbee sensor&#xA;         colectorDatos();&#xA;         xbeeRecibido = 0;         &#xA;        }&#xA;   }&#xA;delay (10);&#xA;}//fin loop&#xA;&#xA;&#xA;void rss() {  ///PARA RSSI&#xA;   /* returns received signal strength value for the last RF data packet */&#xA;   union {byte B; char C;} atCmd[3];&#xA;   AtCommandRequest atCmdReq;&#xA;   AtCommandResponse atResp;&#xA;   byte respLen, *resp, dBm;&#xA;   strcpy(&amp;amp;atCmd[0].C, &quot;DB&quot;);&#xA;   atCmdReq = AtCommandRequest(&amp;amp;atCmd[0].B);&#xA;   atResp = AtCommandResponse();&#xA;   xbee.send(atCmdReq);&#xA;   if (xbee.readPacket(5000)) {&#xA;       if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {&#xA;           xbee.getResponse().getAtCommandResponse(atResp);&#xA;           if (atResp.isOk()) {&#xA;               respLen = atResp.getValueLength();&#xA;               if (respLen == 1) {&#xA;                   resp = atResp.getValue();&#xA;                   dBm = resp[0];&#xA;                   valorRssi = (String)dBm;  &#xA;               }&#xA;               else {&#xA;               }&#xA;           }&#xA;           else {&#xA;           }&#xA;       }&#xA;       else {&#xA;       }&#xA;   }&#xA;   else {&#xA;   } &#xA;}///fin rss()&#xA;&#xA;&#xA;void power_on(){&#xA;    uint8_t answer=0;&#xA;    // checks if the module is started&#xA;    answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);&#xA;    if (answer == 0)&#xA;    {&#xA;        // waits for an answer from the module&#xA;        while(answer == 0){  &#xA;            // Send AT every two seconds and wait for the answer   &#xA;            answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);    &#xA;        }&#xA;    }&#xA;}&#xA;&#xA;&#xA;int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout){&#xA;    uint8_t x=0,  answer=0;&#xA;    char response[100];&#xA;    unsigned long previous;&#xA;    memset(response, '\0', 100);    // Initialize the string&#xA;    delay(100);&#xA;    while( mySerial.available() &amp;gt; 0) mySerial.read();    // Clean the input buffer&#xA;    mySerial.println(ATcommand);    // Send the AT command &#xA;        x = 0;&#xA;    previous = millis();&#xA;    // this loop waits for the answer&#xA;    do{&#xA;        if(mySerial.available() != 0){    &#xA;            response[x] = mySerial.read();&#xA;            x++;&#xA;            // check if the desired answer is in the response of the module&#xA;            if (strstr(response, expected_answer1) != NULL)    &#xA;            {&#xA;                answer = 1;&#xA;            }&#xA;        }&#xA;        // Waits for the asnwer with time out&#xA;    }&#xA;    while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));    &#xA;    return answer;&#xA;}&#xA;&#xA;&#xA;int8_t sendATcommand2(char* ATcommand, char* expected_answer1, &#xA;char* expected_answer2, unsigned int timeout){&#xA;    uint8_t x=0,  answer=0;&#xA;    char response[100];&#xA;    unsigned long previous;&#xA;    memset(response, '\0', 100);    // Initialize the string&#xA;    delay(100);&#xA;    while( mySerial.available() &amp;gt; 0) mySerial.read();    // Clean the input buffer&#xA;    mySerial.println(ATcommand);    // Send the AT command &#xA;        x = 0;&#xA;    previous = millis();&#xA;    // this loop waits for the answer&#xA;    do{        &#xA;        if(mySerial.available() != 0){    &#xA;            response[x] = mySerial.read();&#xA;            x++;&#xA;            // check if the desired answer 1 is in the response of the module&#xA;            if (strstr(response, expected_answer1) != NULL)    &#xA;            {&#xA;                answer = 1;&#xA;            }&#xA;            // check if the desired answer 2 is in the response of the module&#xA;            if (strstr(response, expected_answer2) != NULL)    &#xA;            {&#xA;                answer = 2;&#xA;            }&#xA;        }&#xA;     // Waits for the asnwer with time out&#xA;    }while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));    &#xA;    return answer;&#xA;}&#xA;&#xA;&#xA;void colectorDatos(){ ///funcion para recolectar datos recibidos del xbee y gestionarlos para enviarlos por GPRS&#xA;    rss(); ////recupero rssi que se pone en variable valorRssi&#xA;    datosHttp = direccionRed +&quot;;&quot;; ///cualquier valor del array, todos deverian tener mismo valor (direccion64bits)&#xA;    datosHttp += bateria; &#xA;    datosHttp += &quot;;&quot;;&#xA;    datosHttp += valorRssi;&#xA;    datosHttp += &quot;;&quot;;&#xA;    datosHttp += actividadPir; //pir &#xA;    envio(datosHttp); ///envio por gprs    &#xA;}///fin colectorDatos&#xA;&#xA;&#xA;void lanzarHttpAutoControl() {&#xA;  adr=&quot;&quot;;&#xA;  atRequest.setCommand(slCmd);  // set command to SL to get low part of MAC address &#xA;  while (!sendAtCommand()) {};&#xA;  for (int i = 0; i &amp;lt; atResponse.getValueLength(); i++) {&#xA;    mySerial.print(atResponse.getValue()[i], HEX);&#xA;    sprintf(adr_part, &quot;%lX&quot;, (unsigned long)(atResponse.getValue()[i]));&#xA;    if (atResponse.getValue()[i]&amp;lt;=0xF) &#xA;        adr += 0;      &#xA;        adr += adr_part; &#xA;  } &#xA;  envio(adr); ///envio por gprs&#xA;&#xA;}&#xA;&#xA;&#xA;void envio(String entrada){///envio GPRS...recibe String con datos (o control o sensor)&#xA;   memset(urlArreglo, 0, sizeof(urlArreglo));///a cero el array&#xA;    answer = sendATcommand(&quot;AT+HTTPINIT&quot;, &quot;OK&quot;, 10000);&#xA;    if (answer == 1)&#xA;    {&#xA;        // Sets CID parameter&#xA;        answer = sendATcommand(&quot;AT+HTTPPARA=\&quot;CID\&quot;,1&quot;, &quot;OK&quot;, 5000);&#xA;        if (answer == 1)&#xA;        {&#xA;      sprintf(urlArreglo,  &quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;www.pestmonitors.com/dream/prueba_gsm_get.php?datos=%s\&quot;&quot;,entrada.c_str());&#xA;      answer = sendATcommand(urlArreglo, &quot;OK&quot;, 5000);&#xA;       delay(5000);       &#xA;            if (answer == 1)&#xA;            {&#xA;                answer = sendATcommand(&quot;AT+HTTPACTION=0&quot;, &quot;+HTTPACTION:0,200&quot;, 10000);             &#xA;            }&#xA;    else&#xA;    {&#xA;    }  &#xA;    sendATcommand(&quot;AT+HTTPTERM&quot;, &quot;OK&quot;, 5000);&#xA;    delay(5000);   &#xA;      }&#xA;    }  &#xA;}&#xA;&#xA;&#xA;int sendAtCommand() { // used here to sens AT command to the Xbee to get information such as the MAC address&#xA;  xbee.send(atRequest);&#xA;  if (xbee.readPacket(5000)) {&#xA;    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {&#xA;      xbee.getResponse().getAtCommandResponse(atResponse);&#xA;      if (atResponse.isOk()) {&#xA;        if (atResponse.getValueLength() &amp;gt; 0) {&#xA;          mySerial.println(atResponse.getValueLength(), DEC);&#xA;          for (int i = 0; i &amp;lt; atResponse.getValueLength(); i++) {&#xA;            mySerial.print(atResponse.getValue()[i], HEX);&#xA;          }&#xA;        }&#xA;        return 1;&#xA;      } &#xA;      else {&#xA;      }&#xA;    } else {&#xA;      mySerial.print(xbee.getResponse().getApiId(), HEX);&#xA;    }   &#xA;  } else {&#xA;    if (xbee.getResponse().isError()) {&#xA;    } &#xA;    else {  &#xA;    }&#xA;  }&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;code &quot;End devices&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Sleep_n0m1.h&amp;gt;&#xA;#include &amp;lt;XBee.h&amp;gt;&#xA;XBee xbee = XBee();&#xA;uint8_t payload[] = { 0, 0 };&#xA;XBeeAddress64 addr64 = XBeeAddress64(0x0, 0xFFFF);&#xA;ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));&#xA;ZBTxStatusResponse txStatus = ZBTxStatusResponse();&#xA;boolean apagar;&#xA;int battVolts;&#xA;int PinEntradaBat = A0;&#xA;int valorBateriaTotal;&#xA;int valorBateria;&#xA;int mapeoValorBateria;&#xA;Sleep sleep;&#xA;unsigned long sleepTime; //how long you want the arduino to sleep&#xA;int salida = 7; ////pin salida 7 para DTR xbee&#xA;int entradaInterrumpirSleep =2; ////pin desde pir para interrumpir/despertar &#xA;boolean abortSleep; //cancel sleep cycle&#xA;int modo;&#xA;int cicloTiempoSleep;///establecer ciclo alarma&#xA;int numeroCiclos; ///para retomar ciclo si falsa alarma&#xA;boolean enviado; ///para comprobar si recepción de xbbe, sino, reenviar!&#xA;uint8_t atdCmd[]={'D','5'};&#xA;uint8_t value[]={4};///pongo DIO5 a output LOW&#xA;uint8_t length=1;&#xA;AtCommandRequest atRequest = AtCommandRequest(atdCmd, value, length);&#xA;AtCommandResponse atResponse = AtCommandResponse(); &#xA;//boolean saltarPrimerPir = true; ////PARA NUEVO PIR, SALTAR LA ALARMA AL ARRANCAR ¿PORQUE?&#xA;void setup()&#xA;{  &#xA;  analogReference(DEFAULT); &#xA;  enviado = true;&#xA;  numeroCiclos = 0; &#xA;  apagar = false; &#xA;  pinMode(salida, OUTPUT); //para DTR en xbee&#xA;  pinMode(6, OUTPUT); //para MOSFET (en digitalPin6 PWM)!!&#xA;  digitalWrite(salida, LOW); //EMITE 5V HACIA DTR, ENVIAR EN XBEE&#xA;  delay(120000);//2 minutos para evitar primer interrupt!y dar tiempo a comprobar tecnico la asociación&#xA;  abortSleep = false; //can be used to cancel the sleep cycle&#xA;  sleep.setCalibrationInterval(1);&#xA;  sleepTime = 1000;//set sleep time in ms, max sleep time is 49.7 days (1/2 1 min)&#xA;  modo = 0; //para empezar con modo CONTROL &#xA;  numeroCiclos = 0;&#xA;  Serial.begin(9600);&#xA;  xbee.setSerial(Serial);  &#xA;  xbee.send(atRequest);// set command to ATD50 to stop LED Assoc...////DESCOMENTAR PARA APAGAR LED ASSOC!!!!!!&#xA;  delay(5000);&#xA;}//fin setup&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;if (apagar == true) { ///APAGAR SI BATERIA MUY BAJA!!!!&#xA;  detachInterrupt(0);  &#xA;  while (apagar == true) {&#xA;  }&#xA;}   &#xA;  if (modo == 0) {&#xA;    detachInterrupt(0);&#xA;    digitalWrite(salida, LOW); //EMITE 0V HACIA DTR, ENVIAR EN XBEE&#xA;    digitalWrite(6, HIGH); //EMITE 5V HACIA mosfet/regulador, ENCIENDE XBEE    &#xA;    cicloTiempoSleep = 21600; //6 horas&#xA;    delay(10);&#xA;    enviarXbee(0);    &#xA;    digitalWrite(salida, HIGH);//EMITE 5V HACIA DTR, ACTIVAR DTR (XBEE SLEEP)   &#xA;    digitalWrite(6, LOW); //EMITE 0V HACIA mosfet/regulador, APAGAR &#xA;    delay(30000);///30seg de inactividad post envio control!&#xA;    attachInterrupt(0, interrumpirPir, RISING);    &#xA;  } //fin modo0 CONTROL&#xA;  if (modo == 1) {&#xA;        detachInterrupt(0);&#xA;        digitalWrite(salida, LOW); //EMITE 0V HACIA DTR, ENVIAR EN XBEE&#xA;        digitalWrite(6, HIGH); //EMITE 5V HACIA mosfet/regulador, ENCIENDE XBEE&#xA;        modo = 0; //modo CONTROL&#xA;        numeroCiclos = 0; &#xA;        cicloTiempoSleep = 21600; //6 horas para enviar CONTROL despues de ACTIVIDAD&#xA;        delay(10);&#xA;        enviarXbee(1); &#xA;        digitalWrite(salida, HIGH);//EMITE 5V HACIA DTR, ACTIVAR DTR (XBEE SLEEP)   &#xA;        digitalWrite(6, LOW); //EMITE 0V HACIA mosfet/regulador, APAGAR &#xA;        delay(120000);///2 minutos de inactividad post envio alarma! (para no enviar otra enseguida)&#xA;        attachInterrupt(0, interrumpirPir, RISING);&#xA;  }//fin modo1 ACTIVIDAD&#xA;  abortSleep = false;&#xA;  for (int i=0; i &amp;lt; cicloTiempoSleep; i++){ /////ARREGLO CON FOR PARA REITERAR 1000ms (1seg) x VECES (hace extraños el int0 con SleepDelay juntos) &#xA;        numeroCiclos = i;&#xA;        sleep.pwrDownMode(); //set sleep mode &#xA;        sleep.sleepDelay(sleepTime,abortSleep); //sleep for: sleepTime&#xA;        if (abortSleep == true) {&#xA;          break;&#xA;        }&#xA;   }//fin contador tiempo&#xA;  if (cicloTiempoSleep &amp;lt;= 1 || numeroCiclos == --cicloTiempoSleep) { ///estos dos -- restan 1 al valor de la variable&#xA;    modo = 0;&#xA;  }&#xA;}//fin loop&#xA;&#xA;&#xA;void interrumpirPir() // si disparo PIR por interrupt0 (isr)&#xA;{  &#xA;  if (numeroCiclos != 0) {/////AQUI EVITAR PRIMERA INTERRUPCION AL INICIARSE EL SENSOR/////&#xA;  abortSleep = true;&#xA;  cicloTiempoSleep = cicloTiempoSleep - numeroCiclos;&#xA;  modo = 1; &#xA;  }//fin saltar primer PIR &#xA;}///fin interrumpir! ISR&#xA;&#xA;&#xA;void enviarXbee(int valorPir) // si disparo PIR por interrupt0 (isr)&#xA;{    &#xA;battVolts=getBandgap();&#xA;valorBateriaTotal = 0;&#xA;for (int e=0; e &amp;lt; 20; e++) &#xA;    {&#xA;       mapeoValorBateria = map(analogRead(A1), 0, 1023, 0, battVolts);&#xA;       valorBateriaTotal = valorBateriaTotal + mapeoValorBateria;&#xA;     delay(10);&#xA;    } &#xA;valorBateriaTotal = valorBateriaTotal/20;&#xA;if (mapeoValorBateria &amp;lt;= 95) {///APAGAR SI BATERIA MUY BAJA!!!!&#xA;apagar = true;&#xA;}    &#xA;    payload[0] = valorPir; ///PIR&#xA;    payload[1] = mapeoValorBateria &amp;amp; 0xff;&#xA;    delay (10000);&#xA;    xbee.send(zbTx);&#xA;    //delay (15000);&#xA;    if (xbee.readPacket(5000)) {        &#xA;      if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {&#xA;        xbee.getResponse().getZBTxStatusResponse(txStatus);&#xA;        if (txStatus.getDeliveryStatus() == SUCCESS) {&#xA;         // enviado = true;&#xA;        } else {&#xA;        //  enviado = false;     &#xA;        }&#xA;      }&#xA;    } else if (xbee.getResponse().isError()) {&#xA;    } else {&#xA;    } &#xA;}//end enviar xbee&#xA;&#xA;&#xA;long leerBateria()//para ver estado bateria&#xA;{&#xA;}&#xA;int getBandgap(void) // Returns actual value of Vcc (x 100)&#xA;   {      &#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;    // For mega boards&#xA;    const long InternalReferenceVoltage = 1115L;  // Adjust this value to your boards specific internal BG voltage x1000&#xA;       // REFS1 REFS0          --&amp;gt; 0 1, AVcc internal ref. -Selects AVcc reference&#xA;       // MUX4 MUX3 MUX2 MUX1 MUX0  --&amp;gt; 11110 1.1V (VBG)         -Selects channel 30, bandgap voltage, to measure&#xA;    ADMUX = (0&amp;lt;&amp;lt;REFS1) | (1&amp;lt;&amp;lt;REFS0) | (0&amp;lt;&amp;lt;ADLAR)| (0&amp;lt;&amp;lt;MUX5) | (1&amp;lt;&amp;lt;MUX4) | (1&amp;lt;&amp;lt;MUX3) | (1&amp;lt;&amp;lt;MUX2) | (1&amp;lt;&amp;lt;MUX1) | (0&amp;lt;&amp;lt;MUX0);&#xA;#else&#xA;    // For 168/328 boards&#xA;    const long InternalReferenceVoltage = 1056L;  // Adjust this value to your boards specific internal BG voltage x1000&#xA;       // REFS1 REFS0          --&amp;gt; 0 1, AVcc internal ref. -Selects AVcc external reference&#xA;       // MUX3 MUX2 MUX1 MUX0  --&amp;gt; 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure&#xA;    ADMUX = (0&amp;lt;&amp;lt;REFS1) | (1&amp;lt;&amp;lt;REFS0) | (0&amp;lt;&amp;lt;ADLAR) | (1&amp;lt;&amp;lt;MUX3) | (1&amp;lt;&amp;lt;MUX2) | (1&amp;lt;&amp;lt;MUX1) | (0&amp;lt;&amp;lt;MUX0);     &#xA;#endif&#xA;    delay(50);  // Let mux settle a little to get a more stable A/D conversion&#xA;       // Start a conversion  &#xA;    ADCSRA |= _BV( ADSC );&#xA;       // Wait for it to complete&#xA;    while( ( (ADCSRA &amp;amp; (1&amp;lt;&amp;lt;ADSC)) != 0 ) );&#xA;       // Scale the value&#xA;    int results = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; // calculates for straight line value &#xA;    return results;&#xA;   }&#xA;int sendAtCommand() {&#xA;  xbee.send(atRequest);&#xA;  if (xbee.readPacket(5000)) {// wait up to 5 seconds for the status response&#xA;    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {// should be an AT command response&#xA;      xbee.getResponse().getAtCommandResponse(atResponse);&#xA;      if (atResponse.isOk()) {&#xA;        if (atResponse.getValueLength() &amp;gt; 0) {&#xA;          for (int i = 0; i &amp;lt; atResponse.getValueLength(); i++) {&#xA;          }&#xA;        }&#xA;      } &#xA;      else {&#xA;      }&#xA;    } else {&#xA;    }   &#xA;  } else {&#xA;    if (xbee.getResponse().isError()) {&#xA;    } &#xA;    else {&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you very much. I really appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="4889" LastEditorUserId="10794" LastEditDate="2015-08-28T21:55:52.423" LastActivityDate="2015-08-28T21:55:52.423" Title="Several XBee End devices sending simultaneously; Only one packet recieved on coordinator" Tags="|arduino-uno|xbee|atmega328|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9688" PostTypeId="2" ParentId="9666" CreationDate="2015-03-29T19:59:35.213" Score="2" Body="&lt;p&gt;I don't like &lt;code&gt;serialEvent()&lt;/code&gt; because &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp#L40-L45&quot; rel=&quot;nofollow&quot;&gt;it only checks to see if it should run that function after the whole loop is executed&lt;/a&gt;. With your new example, it's basically the same as the original (except you moved that code to the very bottom of the loop).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure exactly how fast the data is sent, but you should first ask yourself if the data is sent fast enough that you don't even notice that it's blocking. Blocking code isn't bad itself (except maybe from a standpoint of the other device freezing up and stalling your program), but blocking code &lt;em&gt;that takes a long time&lt;/em&gt; is bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you need five bytes, the best thing would be to wrap the blocking code in an if statement like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available &amp;gt;= 5) {&#xA;  //Blocking code here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's simple and readable, yet effective.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-03-29T19:59:35.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9689" PostTypeId="2" ParentId="9666" CreationDate="2015-03-29T20:14:43.867" Score="7" Body="&lt;p&gt;Interestingly enough, &lt;strong&gt;Serial.read()&lt;/strong&gt; does not work like most of us think.&lt;/p&gt;&#xA;&lt;p&gt;Serial.read() is not blocking, it always returns immediately with a byte 0-255 or -1 if there is no character to read.&lt;/p&gt;&#xA;&lt;p&gt;From Arduino Reference&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Reads incoming serial data. read() inherits from the Stream utility class.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Serial.read()&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;None&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Returns&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;the first byte of incoming serial data available (or -1 if no data is available) - int&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7991" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-03-29T20:14:43.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9690" PostTypeId="2" ParentId="9654" CreationDate="2015-03-29T22:40:28.410" Score="0" Body="&lt;p&gt;Not sure if you could get the bootloader to support SD, but I have little experience with bootloader code, so the way I would go about it would be to make the sketch load content from the SD that then affects the sketch process.&lt;/p&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="4628" LastEditDate="2017-01-19T03:12:21.847" LastActivityDate="2017-01-19T03:12:21.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9692" PostTypeId="2" ParentId="9548" CreationDate="2015-03-29T22:58:40.040" Score="0" Body="&lt;p&gt;Firstly if you only need short runs, go with the usb battery pack answer, but if you need the longest time from least batteries:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As has been pointed out, for best battery consumption an arduino board is not efficient due to power regulators and led lights. For best performance you want a standalone 328 chip with its BOD (brown out detector) reduced to 1.8v and then you can run it and the nrf24 chip off 2x AA batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But all this might be a bit beyond you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing though that will help your battery life is a PNP transistor or Mosfet on the +ve of your nrf24l01+ module triggered by a arduino io pin. as these power amplified versions dont sleep (per say, the chip does but not the PA) so it will always be consuming a large amount of power regardless of state. So just use your io pin to power it on and off for each use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(that is unless you need it on always for recieving, in which case this wont help)&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-03-29T22:58:40.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9693" PostTypeId="2" ParentId="9509" CreationDate="2015-03-29T23:03:33.753" Score="0" Body="&lt;p&gt;Another thing to consider is that a nrf24l01+ chip at full power will potentially be pulling more current than your 5v reg can supply, try a lower power setting on the PA.&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-03-29T23:03:33.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9694" PostTypeId="2" ParentId="9201" CreationDate="2015-03-29T23:11:14.367" Score="1" Body="&lt;p&gt;Comparing your rx against the example, i would suggest not having the while done statement. You could also throw in a few serial.write debug lines in both sketches, to log different parts of the code, to find where its getting stuck.&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-03-29T23:11:14.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9696" PostTypeId="1" AcceptedAnswerId="9697" CreationDate="2015-03-30T00:13:06.060" Score="0" ViewCount="321" Body="&lt;p&gt;I've got some working code with a definition that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned char DynTextPositions[10][4][4] = {&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is defined / referenced via a header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#ifndef DYNTEXTPOS_H&#xA;#define DYNTEXTPOS_H&#xA;&#xA;extern const unsigned char DynTextPositions[10][4][4];&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This data is being fed into a rendering function which draws lines based on the given positions. The data is read as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float deltas[4][4];&#xA;// ...&#xA;deltas[n][k] = float(DynTextPositions[c+1][n][k] - DynTextPositions[c][n][k]) / 32.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As-is, this works just fine, as long as I've got my other scenes commented out. When I uncomment them, the combined data size seems to overflow the data segment. This is expected, because there's a fair bit of data, so I'm trying to move the &lt;code&gt;DynTextPositions&lt;/code&gt; data into &lt;code&gt;PROGMEM&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got &lt;code&gt;PROGMEM&lt;/code&gt; working with some bitmaps, but it doesn't seem to work here. An example definition for a working bitmap is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM const unsigned char ArduinoLogo[] = { ... };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, as soon as I apply the &lt;code&gt;PROGMEM&lt;/code&gt; attribute to &lt;code&gt;DynTextPositions&lt;/code&gt; the rendering code seems to freak out - the positions appear to be all off-screen and completely wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I can think of is that, for some reason, the data is either being considered signed rather than unsigned, or is getting corrupted along the way. Either that or the nested array is somehow being treated as a set of pointers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why this might be?&lt;/p&gt;&#xA;" OwnerUserId="8152" LastEditorUserId="368" LastEditDate="2015-03-30T01:05:44.067" LastActivityDate="2015-03-30T01:05:44.067" Title="Unusual behaviour when moving data to PROGMEM" Tags="|arduino-uno|avr|progmem|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9697" PostTypeId="2" ParentId="9696" CreationDate="2015-03-30T01:01:06.417" Score="3" Body="&lt;p&gt;Including &lt;code&gt;&amp;lt;avr/pgmspace.h&amp;gt;&lt;/code&gt; and using the &lt;code&gt;PROGMEM&lt;/code&gt; qualifier macro are only two of the steps required in order to get this to work. Since the data will no longer be available via the data bus you will need to use the various &lt;code&gt;pgm_read_*()&lt;/code&gt; macros or &lt;code&gt;*_P*()&lt;/code&gt; functions defined in &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;avr/pgmspace.h&lt;/code&gt;&lt;/a&gt;. These work by using the appropriate assembly code instructions to access data stored in program space, i.e. flash, on the MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under GCC 4.7 or higher when writing C code, the &lt;code&gt;__flash&lt;/code&gt; named address space is available. Variables declared within this namespace do not require any additional steps to access them. Note that the Arduino IDE compiles as C++, and hence does not make this (or any of the &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#AVR-Named-Address-Spaces&quot; rel=&quot;nofollow&quot;&gt;others&lt;/a&gt;) available.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-03-30T01:01:06.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9699" PostTypeId="2" ParentId="9553" CreationDate="2015-03-30T07:07:43.390" Score="-1" Body="&lt;p&gt;also im in the try of that.YOU HAVE TO USE USB TO SERIAL CONVERTOR CIRCUIT TO ACCESS ARDUINO BY UART (mosi....... miso) connections .and the software in the dongle is the problem here.the difference between the gsm shield and the dongle is .........the SOFTWARE  FIREWALL you have to flash the dongle by your own risk.........try this&lt;/p&gt;&#xA;" OwnerUserId="8157" LastActivityDate="2015-03-30T07:07:43.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9701" PostTypeId="1" CreationDate="2015-03-30T08:51:05.140" Score="0" ViewCount="9213" Body="&lt;p&gt;My idea is Arduino sensor will read and pass the values read on android. Then android will calculate and send the control value (PWM) to the Arduino.&#xA;but android can only get the value from the Arduino but can not send them back to the Arduino ... Can someone please help?&#xA;This my code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;java code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;+MainActivity&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package com.example.tut1;&#xA;&#xA;import java.nio.ByteBuffer;&#xA;import java.util.Timer;&#xA;import java.util.TimerTask;&#xA;&#xA;import android.app.Activity;&#xA;import android.bluetooth.BluetoothSocket;&#xA;import android.content.DialogInterface;&#xA;import android.content.DialogInterface.OnClickListener;&#xA;import android.content.Intent;&#xA;import android.content.pm.ActivityInfo;&#xA;import android.graphics.Color;&#xA;import android.os.Bundle;&#xA;import android.os.Handler;&#xA;import android.os.Message;&#xA;import android.util.Log;&#xA;import android.view.MotionEvent;&#xA;import android.view.View;&#xA;import android.view.Window;&#xA;import android.view.WindowManager;&#xA;import android.widget.Button;&#xA;import android.widget.LinearLayout;&#xA;import android.widget.TextView;&#xA;import android.widget.Toast;&#xA;import android.widget.ToggleButton;&#xA;&#xA;import com.example.tut1.Bluetooth;&#xA;import com.jjoe64.graphview.GraphView;&#xA;import com.jjoe64.graphview.GraphView.GraphViewData;&#xA;import com.jjoe64.graphview.GraphView.LegendAlign;&#xA;import com.jjoe64.graphview.GraphViewSeries;&#xA;import com.jjoe64.graphview.GraphViewSeries.GraphViewStyle;&#xA;import com.jjoe64.graphview.LineGraphView;&#xA;&#xA;public class MainActivity extends Activity implements View.OnClickListener {&#xA;&#xA;    // private StringBuilder recDataString = new StringBuilder();&#xA;&#xA;@Override&#xA;public void onBackPressed() {&#xA;    // TODO Auto-generated method stub&#xA;    if (Bluetooth.connectedThread != null) {&#xA;        Bluetooth.connectedThread.write(&quot;Q&quot;);&#xA;    }// Stop streaming&#xA;    super.onBackPressed();&#xA;}&#xA;&#xA;&#xA;// khai bao bien&#xA;String x, x1;&#xA;int u,u1,adc,adc1;&#xA;public String sensor, sensor1;&#xA;static boolean f=false;&#xA;// toggle Button&#xA;static boolean Lock;// whether lock the x-axis to 0-5&#xA;static boolean AutoScrollX;// auto scroll to the last x value&#xA;static boolean Stream;// Start or stop streaming&#xA;// Button init&#xA;Button bXminus;&#xA;Button bXplus;&#xA;Button bConnect, bDisconnect;&#xA;Button bStart,bStop;&#xA;TextView tvBluetooth, tvpid;&#xA;ToggleButton tbLock;&#xA;ToggleButton tbScroll;&#xA;ToggleButton tbStream;&#xA;// GraphView init&#xA;static LinearLayout GraphView, GraphView1;&#xA;static GraphView graphView, graphView1;&#xA;static GraphViewSeries Series, Series1;&#xA;// graph value&#xA;private static double graph2LastXValue = 0, graph2LastXValue1 = 0;&#xA;private static int Xview = 10, Xview1 = 10;&#xA;&#xA;// khai bao bien timer&#xA;final Handler thandler = new Handler();&#xA;Timer t = new Timer();&#xA;TimerTask mTimerTask;&#xA;&#xA;Handler mHandler = new Handler() {&#xA;    @Override&#xA;    public void handleMessage(Message msg) {&#xA;        // TODO Auto-generated method stub&#xA;        super.handleMessage(msg);&#xA;        switch (msg.what) {&#xA;        case Bluetooth.SUCCESS_CONNECT:&#xA;            Bluetooth.connectedThread = new Bluetooth.ConnectedThread(&#xA;                    (BluetoothSocket) msg.obj);&#xA;            Toast.makeText(getApplicationContext(), &quot;Connected!&quot;, 0).show();&#xA;            String s = &quot;successfully connected&quot;;&#xA;            Bluetooth.connectedThread.start();&#xA;            break;&#xA;        case Bluetooth.MESSAGE_READ:&#xA;&#xA;            byte[] readBuf = (byte[]) msg.obj;&#xA;            String strIncom = new String(readBuf); // create string from&#xA;                                                    // bytes array&#xA;&#xA;            // if(strIncom.indexOf('s')==0){&#xA;            // strIncom = strIncom.replace(&quot;s&quot;, &quot;&quot;);&#xA;            // }&#xA;            int a = strIncom.indexOf(&quot;c&quot;);&#xA;            int b = 4;&#xA;            int c = 4;&#xA;            int d = 8;&#xA;            sensor = (String) strIncom.subSequence(1, 5);&#xA;            sensor1 = (String) strIncom.subSequence(5, 9);&#xA;            tvBluetooth.setText(strIncom);&#xA;//              Bluetooth.connectedThread.write(&quot;E&quot;);&#xA;//              adc=Integer.parseInt(sensor);&#xA;//              adc1=Integer.parseInt(sensor1);&#xA;            tvpid.setText(sensor + &quot;-&quot; + sensor1+&quot;-&quot;+u+&quot;-&quot;+u1);&#xA;            // String readMessage = (String)msg.obj;&#xA;            // recDataString.append(readMessage);&#xA;            // sensor = recDataString.substring(0, 4);&#xA;            Log.d(&quot;strIncom&quot;, sensor);&#xA;            // if (strIncom.indexOf('.')==2 &amp;amp;&amp;amp; strIncom.indexOf('s')==0){&#xA;            // strIncom = strIncom.replace(&quot;s&quot;, &quot;&quot;);&#xA;            if((strIncom.indexOf(&quot;X&quot;)==9)&amp;amp;&amp;amp;(strIncom.indexOf(&quot;Y&quot;)==0)){&#xA;            if (isFloatNumber(sensor) &amp;amp;&amp;amp; isFloatNumber(sensor1)) {&#xA;                Series.appendData(new GraphViewData(graph2LastXValue,&#xA;                        Double.parseDouble(sensor)), AutoScrollX);&#xA;                Series1.appendData(new GraphViewData(graph2LastXValue1,&#xA;                        Double.parseDouble(sensor1)), AutoScrollX);&#xA;&#xA;                // X-axis control&#xA;                if (graph2LastXValue &amp;gt;= Xview &amp;amp;&amp;amp; Lock == true) {&#xA;                    Series.resetData(new GraphViewData[] {});&#xA;                    graph2LastXValue = 0;&#xA;                } else&#xA;                    graph2LastXValue += 0.1;&#xA;&#xA;                if (Lock == true)&#xA;                    graphView.setViewPort(0, Xview);&#xA;                else&#xA;                    graphView.setViewPort(graph2LastXValue - Xview, Xview);&#xA;&#xA;                // grap1&#xA;                if (graph2LastXValue1 &amp;gt;= Xview1 &amp;amp;&amp;amp; Lock == true) {&#xA;                    Series1.resetData(new GraphViewData[] {});&#xA;                    graph2LastXValue1 = 0;&#xA;                } else&#xA;                    graph2LastXValue1 += 0.1;&#xA;&#xA;                if (Lock == true)&#xA;                    graphView1.setViewPort(0, Xview1);&#xA;                else&#xA;                    graphView1.setViewPort(graph2LastXValue1 - Xview1,&#xA;                            Xview1);&#xA;&#xA;                // refresh&#xA;                GraphView.removeView(graphView);&#xA;                GraphView1.removeView(graphView1);&#xA;                GraphView.addView(graphView);&#xA;                GraphView1.addView(graphView1);&#xA;                dieukhienPPM();&#xA;                dieukhienPH();&#xA;            }&#xA;             }&#xA;//              if(f)&#xA;//              t.schedule(mTimerTask, 60, 60);&#xA;&#xA;//              u = (int) adc/4;&#xA;//              u1=(int) adc1/4;&#xA;//              f=true;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    public boolean isFloatNumber(String num) {&#xA;        // Log.d(&quot;checkfloatNum&quot;, num);&#xA;        try {&#xA;            Double.parseDouble(num);&#xA;        } catch (NumberFormatException nfe) {&#xA;            return false;&#xA;        }&#xA;        return true;&#xA;    }&#xA;&#xA;};&#xA;&#xA;@Override&#xA;public void onCreate(Bundle savedInstanceState) {&#xA;    super.onCreate(savedInstanceState);&#xA;    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);&#xA;    requestWindowFeature(Window.FEATURE_NO_TITLE);// Hide title&#xA;    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,&#xA;            WindowManager.LayoutParams.FLAG_FULLSCREEN);// Hide Status bar&#xA;    setContentView(R.layout.activity_main);&#xA;    // set background color&#xA;    LinearLayout background = (LinearLayout) findViewById(R.id.bg);&#xA;    background.setBackgroundColor(Color.BLACK);&#xA;    init();&#xA;    ButtonInit();&#xA;}&#xA;&#xA;void init() {&#xA;    Bluetooth.gethandler(mHandler);&#xA;&#xA;    // init graphview&#xA;    GraphView = (LinearLayout) findViewById(R.id.Graph);&#xA;    // init example series data-------------------&#xA;    Series = new GraphViewSeries(&quot;Signal&quot;, new GraphViewStyle(Color.YELLOW,&#xA;            2),// color and thickness of the line&#xA;            new GraphViewData[] { new GraphViewData(0, 0) });&#xA;    graphView = new LineGraphView(this // context&#xA;            , &quot;Graph&quot; // heading&#xA;    );&#xA;    graphView.setViewPort(0, Xview);&#xA;    graphView.setScrollable(true);&#xA;    graphView.setScalable(true);&#xA;    graphView.setShowLegend(true);&#xA;    graphView.setLegendAlign(LegendAlign.BOTTOM);&#xA;    graphView.setManualYAxis(true);&#xA;    graphView.setManualYAxisBounds(1024, 0);&#xA;    graphView.addSeries(Series); // data&#xA;    GraphView.addView(graphView);&#xA;&#xA;    GraphView1 = (LinearLayout) findViewById(R.id.Graph1);&#xA;    // init example series data-------------------&#xA;    Series1 = new GraphViewSeries(&quot;Signal&quot;, new GraphViewStyle(&#xA;            Color.YELLOW, 2),// color and thickness of the line&#xA;            new GraphViewData[] { new GraphViewData(0, 0) });&#xA;    graphView1 = new LineGraphView(this // context&#xA;            , &quot;Graph1&quot; // heading&#xA;    );&#xA;    graphView1.setViewPort(0, Xview1);&#xA;    graphView1.setScrollable(true);&#xA;    graphView1.setScalable(true);&#xA;    graphView1.setShowLegend(true);&#xA;    graphView1.setLegendAlign(LegendAlign.BOTTOM);&#xA;    graphView1.setManualYAxis(true);&#xA;    graphView1.setManualYAxisBounds(1024, 0);&#xA;    graphView1.addSeries(Series1); // data&#xA;    GraphView1.addView(graphView1);&#xA;}&#xA;&#xA;void ButtonInit() {&#xA;    bConnect = (Button) findViewById(R.id.bConnect);&#xA;    bConnect.setOnClickListener(this);&#xA;    bDisconnect = (Button) findViewById(R.id.bDisconnect);&#xA;    bDisconnect.setOnClickListener(this);&#xA;    bStart = (Button) findViewById(R.id.bStart);&#xA;    bStart.setOnClickListener(this);&#xA;    bStop = (Button) findViewById(R.id.bStop);&#xA;    bStop.setOnClickListener(this);&#xA;    // X-axis control button&#xA;    // bXminus = (Button)findViewById(R.id.bXminus);&#xA;    // bXminus.setOnClickListener(this);&#xA;    // bXplus = (Button)findViewById(R.id.bXplus);&#xA;    // bXplus.setOnClickListener(this);&#xA;    // //&#xA;    // tbLock = (ToggleButton)findViewById(R.id.tbLock);&#xA;    // tbLock.setOnClickListener(this);&#xA;    // tbScroll = (ToggleButton)findViewById(R.id.tbScroll);&#xA;    // tbScroll.setOnClickListener(this);&#xA;//      tbStream = (ToggleButton) findViewById(R.id.tbStream);&#xA;//      tbStream.setOnClickListener(this);&#xA;    tvBluetooth = (TextView) findViewById(R.id.tvBluetooth);&#xA;    tvpid = (TextView) findViewById(R.id.tvpid);&#xA;    // init toggleButton&#xA;    Lock = true;&#xA;    AutoScrollX = true;&#xA;    Stream = false;&#xA;}&#xA;&#xA;@Override&#xA;public void onClick(View v) {&#xA;    // TODO Auto-generated method stub&#xA;    switch (v.getId()) {&#xA;    case R.id.bConnect:&#xA;        startActivity(new Intent(&quot;android.intent.action.BT1&quot;));&#xA;        break;&#xA;    case R.id.bDisconnect:&#xA;        Bluetooth.disconnect();&#xA;        break;&#xA;    case R.id.bStart:&#xA;        if (Bluetooth.connectedThread != null)&#xA;            Bluetooth.connectedThread.write(&quot;E&quot;);&#xA;            doTimerTask();&#xA;        break;&#xA;    case R.id.bStop:&#xA;        if (Bluetooth.connectedThread != null)&#xA;            Bluetooth.connectedThread.write(&quot;Q&quot;);&#xA;        stopTask();&#xA;        break;&#xA;    // case R.id.bXminus:&#xA;    // if (Xview&amp;gt;1) Xview--;&#xA;    // break;&#xA;    // case R.id.bXplus:&#xA;    // if (Xview&amp;lt;30) Xview++;&#xA;    // break;&#xA;    // case R.id.tbLock:&#xA;    // if (tbLock.isChecked()){&#xA;    // Lock = true;&#xA;    // }else{&#xA;    // Lock = false;&#xA;    // }&#xA;    // break;&#xA;    // case R.id.tbScroll:&#xA;    // if (tbScroll.isChecked()){&#xA;    // AutoScrollX = true;&#xA;    // }else{&#xA;    // AutoScrollX = false;&#xA;    // }&#xA;    // break;&#xA;//      case R.id.tbStream:&#xA;//          if (tbStream.isChecked()) {&#xA;//              if (Bluetooth.connectedThread != null)&#xA;//                  Bluetooth.connectedThread.write(&quot;E&quot;);&#xA;//          } else {&#xA;//              if (Bluetooth.connectedThread != null)&#xA;//                  Bluetooth.connectedThread.write(&quot;Q&quot;);&#xA;//          }&#xA;//          break;&#xA;    }&#xA;}&#xA;&#xA;public void doTimerTask() {&#xA;    mTimerTask = new TimerTask() {&#xA;        public void run() {&#xA;            thandler.post(new Runnable() {&#xA;                public void run() {&#xA;                    // TODO Auto-generated method stub&#xA; //                     dieukhienPPM();&#xA;//                      dieukhienPH();&#xA;                    Bluetooth.connectedThread.write(&quot;A&quot;);&#xA;                    x = Integer.toString(u);    &#xA;                    Bluetooth.connectedThread.write(x);&#xA;                    Bluetooth.connectedThread.write(&quot;B&quot;);&#xA;                    x1=Integer.toString(u1);&#xA;                    Bluetooth.connectedThread.write(x1);&#xA;                    Bluetooth.connectedThread.write(&quot;S&quot;);&#xA;                }&#xA;            });&#xA;        }&#xA;    };&#xA;&#xA;    // public void schedule (TimerTask task, long delay, long period)&#xA;     t.schedule(mTimerTask, 500, 500); // Thoi gian delay va thoi gian lap&#xA;    // tinh&#xA;    // bang mili giay&#xA;}&#xA;&#xA;public void stopTask() {&#xA;    if (mTimerTask != null)&#xA;        mTimerTask.cancel();&#xA;}&#xA;&#xA;public void dieukhienPPM() {&#xA;    u= (Integer.parseInt(sensor)/4);&#xA;}&#xA;&#xA;public void dieukhienPH() {&#xA;    u1 = (Integer.parseInt(sensor1)/4);&#xA;}&#xA;&#xA;public static byte[] toByteArray(double value) {&#xA;    byte[] bytes = new byte[8];&#xA;    ByteBuffer.wrap(bytes).putDouble(value);&#xA;    return bytes;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;+Bluetooth&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package com.example.tut1;&#xA;&#xA;import java.io.IOException;&#xA;import java.io.InputStream;&#xA;import java.io.OutputStream;&#xA;import java.util.ArrayList;&#xA;import java.util.Set;&#xA;import java.util.UUID;&#xA;&#xA;import android.app.Activity;&#xA;import android.bluetooth.BluetoothAdapter;&#xA;import android.bluetooth.BluetoothDevice;&#xA;import android.bluetooth.BluetoothSocket;&#xA;import android.content.BroadcastReceiver;&#xA;import android.content.Context;&#xA;import android.content.Intent;&#xA;import android.content.IntentFilter;&#xA;import android.os.Bundle;&#xA;import android.os.Handler;&#xA;import android.util.Log;&#xA;import android.view.View;&#xA;import android.widget.AdapterView;&#xA;import android.widget.AdapterView.OnItemClickListener;&#xA;import android.widget.ArrayAdapter;&#xA;import android.widget.ListView;&#xA;import android.widget.Toast;&#xA;&#xA;public class Bluetooth extends Activity implements OnItemClickListener{&#xA;&#xA;public static void disconnect(){&#xA;    if (connectedThread != null) {&#xA;        connectedThread.cancel(); &#xA;        connectedThread = null;&#xA;    }&#xA;}&#xA;&#xA;public static void gethandler(Handler handler){//Bluetooth handler&#xA;    mHandler = handler;&#xA;}&#xA;static Handler mHandler = new Handler();&#xA;&#xA;static ConnectedThread connectedThread;&#xA;public static final UUID MY_UUID = UUID.fromString(&quot;00001101-0000-1000-8000-           00805F9B34FB&quot;);&#xA;protected static final int SUCCESS_CONNECT = 0;&#xA;protected static final int MESSAGE_READ = 1;&#xA;ArrayAdapter&amp;lt;String&amp;gt; listAdapter;&#xA;ListView listView;&#xA;static BluetoothAdapter btAdapter;&#xA;Set&amp;lt;BluetoothDevice&amp;gt; devicesArray;&#xA;ArrayList&amp;lt;String&amp;gt; pairedDevices;&#xA;ArrayList&amp;lt;BluetoothDevice&amp;gt; devices;&#xA;IntentFilter filter;&#xA;BroadcastReceiver receiver;&#xA;&#xA;@Override&#xA;public void onCreate(Bundle savedInstanceState) {&#xA;    super.onCreate(savedInstanceState);&#xA;    setContentView(R.layout.activity_bluetooth);&#xA;    init();&#xA;    if (btAdapter==null){&#xA;        Toast.makeText(getApplicationContext(), &quot;No bluetooth detected&quot;, 0).show();&#xA;        finish();&#xA;    }else{&#xA;        if (!btAdapter.isEnabled()){&#xA;            turnOnBT();&#xA;        }&#xA;        getPairedDevices();&#xA;        startDiscovery();&#xA;    }&#xA;&#xA;}&#xA;&#xA;&#xA;private void startDiscovery() {&#xA;    // TODO Auto-generated method stub&#xA;    btAdapter.cancelDiscovery();&#xA;    btAdapter.startDiscovery();&#xA;}&#xA;&#xA;private void turnOnBT() {&#xA;    Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);&#xA;    startActivityForResult(intent, 1);&#xA;}&#xA;&#xA;private void getPairedDevices() {&#xA;    devicesArray = btAdapter.getBondedDevices();&#xA;    if (devicesArray.size()&amp;gt;0){&#xA;        for(BluetoothDevice device:devicesArray){&#xA;            pairedDevices.add(device.getName());&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;private void init(){&#xA;    listView = (ListView)findViewById(R.id.listView);&#xA;    listView.setOnItemClickListener(this);&#xA;    listAdapter = new ArrayAdapter&amp;lt;String&amp;gt;(this, android.R.layout.simple_list_item_1,0);&#xA;    listView.setAdapter(listAdapter);&#xA;    btAdapter = BluetoothAdapter.getDefaultAdapter();&#xA;    pairedDevices = new ArrayList&amp;lt;String&amp;gt;();&#xA;    filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);&#xA;    devices = new ArrayList&amp;lt;BluetoothDevice&amp;gt;(); &#xA;    receiver = new BroadcastReceiver(){&#xA;        @Override&#xA;        public void onReceive(Context context, Intent intent) {&#xA;            String action = intent.getAction();&#xA;            if (BluetoothDevice.ACTION_FOUND.equals(action)){&#xA;                BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);&#xA;                devices.add(device);&#xA;                String s = &quot;&quot;;&#xA;                for(int a=0;a&amp;lt;pairedDevices.size();a++){&#xA;                    if (device.getName().equals(pairedDevices.get(a))){&#xA;                        //append&#xA;                        s = &quot;(Paired)&quot;;&#xA;                        break;&#xA;                    }&#xA;                }&#xA;                listAdapter.add(device.getName()+&quot; &quot;+s+&quot; &quot;+&quot;\n&quot;+device.getAddress());&#xA;&#xA;            }else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)){&#xA;&#xA;            }else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){&#xA;&#xA;            }else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){&#xA;                if (btAdapter.getState() == btAdapter.STATE_OFF){&#xA;                    turnOnBT();&#xA;                }&#xA;            }  &#xA;        }&#xA;&#xA;    };&#xA;&#xA;    registerReceiver(receiver, filter);&#xA;    IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED);&#xA;    registerReceiver(receiver, filter);&#xA;    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);&#xA;    registerReceiver(receiver, filter);&#xA;    filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);&#xA;}&#xA;&#xA;@Override&#xA;protected void onPause() {&#xA;    // TODO Auto-generated method stub&#xA;    super.onPause();&#xA;    unregisterReceiver(receiver);&#xA;}&#xA;&#xA;protected void onActivityResult(int requestCode, int resultCode, Intent data){&#xA;    super.onActivityResult(requestCode, resultCode, data);&#xA;    if (resultCode == RESULT_CANCELED){&#xA;        Toast.makeText(getApplicationContext(), &quot;Bluetooth must be enabled to continue&quot;, Toast.LENGTH_SHORT).show();&#xA;        finish();&#xA;    }&#xA;}&#xA;&#xA;@Override&#xA;public void onItemClick(AdapterView&amp;lt;?&amp;gt; arg0, View arg1, int arg2, long arg3) {&#xA;    // TODO Auto-generated method stub&#xA;    if (btAdapter.isDiscovering()){&#xA;        btAdapter.cancelDiscovery();&#xA;    }&#xA;    if (listAdapter.getItem(arg2).contains(&quot;(Paired)&quot;)){&#xA;&#xA;        BluetoothDevice selectedDevice = devices.get(arg2);&#xA;        ConnectThread connect = new ConnectThread(selectedDevice);&#xA;        connect.start();&#xA;    }else {&#xA;        Toast.makeText(getApplicationContext(), &quot;device is not paired&quot;, 0).show();&#xA;    }&#xA;}&#xA;&#xA;private class ConnectThread extends Thread {&#xA;    private final BluetoothSocket mmSocket;&#xA;    private final BluetoothDevice mmDevice;&#xA;&#xA;    public ConnectThread(BluetoothDevice device) {&#xA;        // Use a temporary object that is later assigned to mmSocket,&#xA;        // because mmSocket is final&#xA;        BluetoothSocket tmp = null;&#xA;        mmDevice = device;&#xA;&#xA;        // Get a BluetoothSocket to connect with the given BluetoothDevice&#xA;        try {&#xA;            // MY_UUID is the app's UUID string, also used by the server code&#xA;            tmp = device.createRfcommSocketToServiceRecord(MY_UUID);&#xA;        } catch (IOException e) { }&#xA;        mmSocket = tmp;&#xA;    }&#xA;&#xA;    public void run() {&#xA;        // Cancel discovery because it will slow down the connection&#xA;        btAdapter.cancelDiscovery();&#xA;&#xA;        try {&#xA;            // Connect the device through the socket. This will block&#xA;            // until it succeeds or throws an exception&#xA;            mmSocket.connect();&#xA;            //connectedThread = new ConnectedThread(mmSocket);&#xA;        } catch (IOException connectException) {&#xA;            // Unable to connect; close the socket and get out&#xA;            try {&#xA;                mmSocket.close();&#xA;            } catch (IOException closeException) { }&#xA;            return;&#xA;        }&#xA;&#xA;        // Do work to manage the connection (in a separate thread)&#xA;        mHandler.obtainMessage(SUCCESS_CONNECT, mmSocket).sendToTarget();&#xA;    }&#xA;&#xA;    /** Will cancel an in-progress connection, and close the socket */&#xA;    public void cancel() {&#xA;        try {&#xA;            mmSocket.close();&#xA;        } catch (IOException e) { }&#xA;    }&#xA;}&#xA;&#xA;static class ConnectedThread extends Thread {&#xA;    private final BluetoothSocket mmSocket;&#xA;    private final InputStream mmInStream;&#xA;    private final OutputStream mmOutStream;&#xA;&#xA;    public ConnectedThread(BluetoothSocket socket) {&#xA;        mmSocket = socket;&#xA;        InputStream tmpIn = null;&#xA;        OutputStream tmpOut = null;&#xA;&#xA;        // Get the input and output streams, using temp objects because&#xA;        // member streams are final&#xA;        try {&#xA;            tmpIn = socket.getInputStream();&#xA;            tmpOut = socket.getOutputStream();&#xA;        } catch (IOException e) { }&#xA;&#xA;        mmInStream = tmpIn;&#xA;        mmOutStream = tmpOut;&#xA;    }&#xA;    StringBuffer sbb = new StringBuffer();&#xA;    public void run() {&#xA;&#xA;        byte[] buffer;  // buffer store for the stream&#xA;        int bytes; // bytes returned from read()&#xA;&#xA;        // Keep listening to the InputStream until an exception occurs&#xA;        while (true) {&#xA;            try {&#xA;                try {&#xA;                    sleep(30);&#xA;                } catch (InterruptedException e) {&#xA;                    // TODO Auto-generated catch block&#xA;                    e.printStackTrace();&#xA;                }&#xA;&#xA;                buffer = new byte[1024];&#xA;                // Read from the InputStream&#xA;                bytes = mmInStream.read(buffer);&#xA;                // Send the obtained bytes to the UI activity&#xA;                mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer).sendToTarget();&#xA;            } catch (IOException e) {&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    /* Call this from the main activity to send data to the remote device */&#xA;    public void write(String income) {&#xA;&#xA;        try {&#xA;            mmOutStream.write(income.getBytes());&#xA;            for(int i=0;i&amp;lt;income.getBytes().length;i++)&#xA;            Log.v(&quot;outStream&quot;+Integer.toString(i),Character.toString((char)(Integer.parseInt(Byte.toString(income.getBytes()[i])))));&#xA;            try {&#xA;                Thread.sleep(20);&#xA;            } catch (InterruptedException e) {&#xA;                // TODO Auto-generated catch block&#xA;                e.printStackTrace();&#xA;            }&#xA;        } catch (IOException e) { }&#xA;    }&#xA;&#xA;    public void write_1(byte[] bytes) {&#xA;        try {&#xA;            mmOutStream.write(bytes);&#xA;            try{&#xA;                Thread.sleep(20);&#xA;            }catch(InterruptedException e){&#xA;                e.printStackTrace();&#xA;            }&#xA;        } catch (IOException e) { }&#xA;    }&#xA;&#xA;&#xA;&#xA;    /* Call this from the main activity to shutdown the connection */&#xA;    public void cancel() {&#xA;        try {&#xA;            mmSocket.close();&#xA;        } catch (IOException e) { }&#xA;    }&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;code arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float nhietdo,doam,nhietdotb,doamtb;&#xA;float t,p;&#xA;char re;&#xA;char p1,p2;&#xA;int chanlaynhiet=0;&#xA;int pwm,pwm1;&#xA;String nhan,nhan1;&#xA;boolean batdau = false; &#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; pinMode(10,OUTPUT);&#xA; pinMode(11,OUTPUT);&#xA; pinMode(8,OUTPUT);&#xA; }&#xA;&#xA;void loop()&#xA;{&#xA;if(Serial.available()&amp;gt;0){&#xA; re = Serial.read();&#xA; switch(re){&#xA; case 'S':&#xA; Send();&#xA; digitalWrite(8,LOW);&#xA; break;&#xA;&#xA;  case 'A':&#xA;  nhan=Serial.read();&#xA;  //digitalWrite(8,LOW);&#xA;  break; &#xA;&#xA;  case 'B':&#xA;  nhan1=Serial.read();&#xA;  //digitalWrite(8,LOW);&#xA;   break;&#xA;&#xA;  case 'E' :&#xA;  batdau = true;&#xA;  break;  &#xA;&#xA;  case 'Q':&#xA;  batdau = false;&#xA;  break; &#xA; }&#xA;  if(batdau){&#xA;   start();  &#xA;   }  &#xA;}&#xA;&#xA;&#xA;&#xA;void start()&#xA;{&#xA; while(1)&#xA; {//doc ppm&#xA;   for(int i=0;i&amp;lt;10;i++)&#xA;   {&#xA;   nhietdotb=nhietdotb+analogRead(A0);&#xA;   delay(1);&#xA;   }&#xA;   nhietdo=nhietdotb/10;&#xA;   nhietdotb=0;&#xA;   //doc ph&#xA;   for(int j=0;j&amp;lt;10;j++)&#xA;   {&#xA;  doamtb=doamtb+analogRead(A1);&#xA;  delay(1);&#xA;   }&#xA;  doam=doamtb/10;&#xA;  doamtb=0;&#xA; //if (isDigit(pwm1))&#xA; //analogWrite(10,pwm1);&#xA; //if (isDigit(pwm2))&#xA; //analogWrite(11,pwm2);&#xA; analogWrite(11,nhan1.toInt);&#xA; analogWrite(10,nhan.toInt);&#xA; digitalWrite(8,HIGH);&#xA;&#xA; if(Serial.available()&amp;gt;0)&#xA; return;&#xA;}&#xA;}&#xA;&#xA;void Send()&#xA; {&#xA;  Serial.print('s');&#xA;  Serial.print('Y');&#xA;   if((nhietdo&amp;lt;1000)&amp;amp;&amp;amp;(nhietdo&amp;gt;=100)){&#xA;   Serial.print(&quot;0&quot;);&#xA;   }else if((nhietdo&amp;lt;100)&amp;amp;&amp;amp;(nhietdo&amp;gt;=10)){&#xA;   Serial.print(&quot;00&quot;);&#xA;   }else if(nhietdo&amp;lt;10){&#xA;   Serial.print(&quot;000&quot;); &#xA;  }&#xA;   Serial.print(nhietdo,0); &#xA;&#xA;if((doam&amp;lt;1000)&amp;amp;&amp;amp;(doam&amp;gt;=100)){&#xA;  Serial.print(&quot;0&quot;);&#xA;  }else if((doam&amp;lt;100)&amp;amp;&amp;amp;(doam&amp;gt;=10)){&#xA;  Serial.print(&quot;00&quot;);&#xA;  }else if(doam&amp;lt;10){&#xA;  Serial.print(&quot;000&quot;);&#xA; }&#xA; Serial.print(doam,0);&#xA; Serial.print('X');&#xA; Serial.print(nhan);&#xA; Serial.print(nhan1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8160" LastEditorUserId="8160" LastEditDate="2015-03-30T10:14:27.783" LastActivityDate="2015-04-02T06:41:06.147" Title="How to send 1 byte from android to arduino" Tags="|arduino-uno|android|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9702" PostTypeId="1" AcceptedAnswerId="9769" CreationDate="2015-03-30T09:13:21.240" Score="0" ViewCount="331" Body="&lt;p&gt;I have a specific arduino code (no .ino files) &lt;a href=&quot;https://github.com/justintconroy/MdbBillValidator&quot; rel=&quot;nofollow&quot;&gt;https://github.com/justintconroy/MdbBillValidator&lt;/a&gt; , which can't be opened by arduino IDE. How can I make &amp;amp; upload this code? I have an arduino 2560 mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've created an empty &lt;code&gt;MdbBillValidator.ino&lt;/code&gt; file and added these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;MdbBillValidator.h&quot;&#xA;&#xA;void setup() {&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the error message&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MdbSerial.cpp: In function ‘void __vector_37()’:&#xA;MdbSerial.cpp:289:23: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp:291:24: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp: In function ‘void __vector_52()’:&#xA;MdbSerial.cpp:314:23: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp:316:24: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp: In function ‘void __vector_55()’:&#xA;MdbSerial.cpp:339:23: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp:341:24: error: ‘TXB8’ was not declared in this scope&#xA;MdbSerial.cpp: At global scope:&#xA;MdbSerial.cpp:554:135: error: expected ‘)’ before numeric constant&#xA;MdbSerial.cpp:554:189: error: no matching function for call to ‘MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, int, int, int, int, int, int, int, int, int, int, int)’&#xA;MdbSerial.cpp:554:189: note: candidates are:&#xA;MdbSerial.cpp:352:1: note: MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)&#xA;MdbSerial.cpp:352:1: note:   candidate expects 20 arguments, 19 provided&#xA;In file included from MdbSerial.cpp:38:0:&#xA;MdbSerial.h:52:7: note: MdbSerial::MdbSerial(const MdbSerial&amp;amp;)&#xA;MdbSerial.h:52:7: note:   candidate expects 1 argument, 19 provided&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7852" LastEditorUserId="7852" LastEditDate="2015-03-31T08:06:47.833" LastActivityDate="2015-04-01T19:49:47.587" Title="How to compile and upload the specific (.cpp + .h) code?" Tags="|arduino-mega|arduino-ide|compile|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="9703" PostTypeId="2" ParentId="9701" CreationDate="2015-03-30T09:40:18.953" Score="0" Body="&lt;p&gt;sr,&#xA;Arduino code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float nhietdo,doam,nhietdotb,doamtb;&#xA;float t,p;&#xA;char re;&#xA;char p1,p2;&#xA;int chanlaynhiet=0;&#xA;int pwm,pwm1;&#xA;String nhan,nhan1;&#xA;boolean batdau = false; &#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(11,OUTPUT);&#xA;  pinMode(8,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;if(Serial.available()&amp;gt;0){&#xA;re = Serial.read();&#xA;switch(re){&#xA;  case 'S':&#xA;  Send();&#xA;  digitalWrite(8,LOW);&#xA;  break;&#xA;&#xA;  case 'A':&#xA;  nhan=Serial.read();&#xA;//      digitalWrite(8,LOW);&#xA;      break; &#xA;&#xA;      case 'B':&#xA;      nhan1=Serial.read();&#xA;//      digitalWrite(8,LOW);&#xA;       break;&#xA;&#xA;      case 'E' :&#xA;      batdau = true;&#xA;      break;  &#xA;&#xA;      case 'Q':&#xA;      batdau = false;&#xA;      break; &#xA;    }&#xA;    if(batdau){&#xA;     start();  &#xA;    }  &#xA;  }&#xA;&#xA;&#xA;&#xA;void start()&#xA;{&#xA;  while(1)&#xA;  {//doc ppm&#xA;    for(int i=0;i&amp;lt;10;i++)&#xA;    {&#xA;    nhietdotb=nhietdotb+analogRead(A0);&#xA;    delay(1);&#xA;    }&#xA;    nhietdo=nhietdotb/10;&#xA;    nhietdotb=0;&#xA;    //doc ph&#xA;    for(int j=0;j&amp;lt;10;j++)&#xA;    {&#xA;   doamtb=doamtb+analogRead(A1);&#xA;   delay(1);&#xA;    }&#xA;   doam=doamtb/10;&#xA;   doamtb=0;&#xA;//    if (isDigit(pwm1))&#xA;//   analogWrite(10,pwm1);&#xA;//   if (isDigit(pwm2))&#xA;//   analogWrite(11,pwm2);&#xA;   analogWrite(11,nhan1.toInt);&#xA;   analogWrite(10,nhan.toInt);&#xA;   digitalWrite(8,HIGH);&#xA;&#xA;   if(Serial.available()&amp;gt;0)&#xA;   return;&#xA;}&#xA;}&#xA;&#xA;void Send()&#xA;{&#xA;   Serial.print('s');&#xA;   Serial.print('Y');&#xA;   if((nhietdo&amp;lt;1000)&amp;amp;&amp;amp;(nhietdo&amp;gt;=100)){&#xA;   Serial.print(&quot;0&quot;);&#xA;   }else if((nhietdo&amp;lt;100)&amp;amp;&amp;amp;(nhietdo&amp;gt;=10)){&#xA;   Serial.print(&quot;00&quot;);&#xA;   }else if(nhietdo&amp;lt;10){&#xA;   Serial.print(&quot;000&quot;); &#xA;  }&#xA;   Serial.print(nhietdo,0); &#xA;&#xA;   if((doam&amp;lt;1000)&amp;amp;&amp;amp;(doam&amp;gt;=100)){&#xA;  Serial.print(&quot;0&quot;);&#xA;  }else if((doam&amp;lt;100)&amp;amp;&amp;amp;(doam&amp;gt;=10)){&#xA;  Serial.print(&quot;00&quot;);&#xA;  }else if(doam&amp;lt;10){&#xA;  Serial.print(&quot;000&quot;);&#xA; }&#xA; Serial.print(doam,0);&#xA; Serial.print('X');&#xA; Serial.print(nhan);&#xA; Serial.print(nhan1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8160" LastActivityDate="2015-03-30T09:40:18.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9704" PostTypeId="1" CreationDate="2015-03-30T10:05:32.553" Score="0" ViewCount="620" Body="&lt;p&gt;Just trying to understand and use the SoftwareSerial&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to connect a WiFi Module (ESP8266)&#xA;If I send an AT command to the module I would like to print a response on my pc screen in the serial monitor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some example code it tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   SoftwareSerial dbgSerial(10, 11); // RX, TX&#xA;   void setup()&#xA;   {&#xA;     // Open serial communications and wait for port to open:&#xA;     Serial.begin(57600);&#xA;     Serial.setTimeout(5000);&#xA;     dbgSerial.begin(9600); //can't be faster than 19200 for softserial&#xA;     dbgSerial.println(&quot;ESP8266 Demo&quot;);&#xA;     //test if the module is ready&#xA;     Serial.println(&quot;AT+RST&quot;);&#xA;     delay(1000);&#xA;     if(Serial.find(&quot;ready&quot;))&#xA;     {&#xA;       dbgSerial.println(&quot;Module is ready&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to receive ready in the serial&lt;/p&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="653" LastEditDate="2015-10-03T16:37:41.570" LastActivityDate="2015-10-03T16:37:41.570" Title="SoftwareSerial Struggles" Tags="|softwareserial|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9706" PostTypeId="1" CreationDate="2015-03-30T11:04:31.357" Score="2" ViewCount="443" Body="&lt;p&gt;I've wrote a code for arduino mega, and want to force it from copying (this is commerce project). How can I obfuscate .hex file before uploading to arduino?&lt;/p&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-03-30T13:43:40.237" Title="Obfuscate .hex file" Tags="|arduino-mega|compile|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9708" PostTypeId="2" ParentId="9704" CreationDate="2015-03-30T14:57:05.230" Score="1" Body="&lt;p&gt;Looks like you are swapping the use of &lt;code&gt;Serial&lt;/code&gt; and &lt;code&gt;dbgSerial&lt;/code&gt;. I think you mean to use &lt;code&gt;Serial&lt;/code&gt; to print to the computer and &lt;code&gt;dbgSerial&lt;/code&gt; to communicate with your module. &lt;code&gt;Serial.println&lt;/code&gt; should display the message in the terminal on your computer.&lt;/p&gt;&#xA;" OwnerUserId="11" LastActivityDate="2015-03-30T14:57:05.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9709" PostTypeId="1" AcceptedAnswerId="9749" CreationDate="2015-03-30T15:28:40.510" Score="3" ViewCount="34135" Body="&lt;p&gt;I was wondering how I can get 4 Arduinos in total to communicate with each-other through a wired connection. The goal is to have the master Arduino send a number 0-100 to each of the other Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The master unit will be an Arduino Uno and the other 3 Arduinos will be Arduino Pro Minis.&lt;/p&gt;&#xA;" OwnerUserId="8167" LastEditorUserId="4628" LastEditDate="2017-11-18T08:33:14.623" LastActivityDate="2018-07-18T07:44:18.010" Title="How to have an Arduino communicate with 3 other Arduinos?" Tags="|arduino-uno|arduino-pro-mini|communication|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9710" PostTypeId="1" AcceptedAnswerId="9739" CreationDate="2015-03-30T16:32:16.943" Score="0" ViewCount="118" Body="&lt;p&gt;Recently I bought a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B006RATC2E&quot; rel=&quot;nofollow&quot;&gt;B006RATC2E&lt;/a&gt; wireless shield for my Arduino One, but didn't notice that I had to buy a wifi module as well to let it work (bad surprise as the shield already cost me $30 + travel expenses to CR). Could someone be so kind to suggest me some compatible wifi modules for the shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm kind of newbie in this and when I search specs for Adafruit and XBee modules, the documentation is not explicit about the compatibility with Arduino shields, so I'm stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to buy components that would't work together (my budget is limited). Is &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B007R9U1QA&quot; rel=&quot;nofollow&quot;&gt;XBee XB24&lt;/a&gt; a good module for the shield? Any other alternative?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help!&lt;/p&gt;&#xA;" OwnerUserId="8170" LastEditorUserId="8170" LastEditDate="2015-03-31T14:22:26.433" LastActivityDate="2015-03-31T14:22:26.433" Title="Wifi module for arduino shield" Tags="|arduino-uno|shields|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9711" PostTypeId="2" ParentId="9709" CreationDate="2015-03-30T17:44:37.117" Score="2" Body="&lt;p&gt;You can use the I2C communication protocol through the wire.h library. That will permit you to use the arduino uno as master device and the pro minis as slave.&#xA;Briefly, you use a two wire's connected to the SDA and SCL pins of all the arduino board and then the master to interact ( meaning request data and send data) with the slaves uses there address (that is user defined in the slave software). So the normal routine in I2C goes like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The master sends the address plus the read write instruction on the bus.&lt;/li&gt;&#xA;&lt;li&gt;All the arduino boards listen and if the address matches with there internal adress they perform the instruction.&lt;/li&gt;&#xA;&lt;li&gt;If it is write command from the master the slaves prepare to receive. If it is read command from the master, the master waits until the slave send a byte.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Fr more information go on:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Arduino two wire communication&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.it/urlhttps://www.google.it/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;ei=IIsZVZ31G8bsUveEgbgB&amp;amp;url=http://www.nxp.com/documents/user_manual/UM10204.pdf&amp;amp;ved=0CB4QFjAB&amp;amp;usg=AFQjCNG5emVs3tU5RbGVKjblTMFgLLHdqg&amp;amp;sig2=rdzEDOM6eEHT43fGziDtxQ&quot; rel=&quot;nofollow&quot;&gt;I2C official datasheet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-30T17:44:37.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9712" PostTypeId="1" CreationDate="2015-03-30T18:01:37.857" Score="2" ViewCount="1506" Body="&lt;p&gt;I want to power an Arduino Leonardo with an external power supply and simultanously communicate via USB. I have read some other threads on this topic, therefore, I know that if one supplies more than 7V over the power jack, the board will use the external power supply in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suspicion is rather concerning the ground connection. From the schematic, I can tell that the USB ground is connected via a tiny coil to the board ground, so with DC it is shorted. Wouldn't that cause problems if the computer's USB ground is at a different potential than the external power supply of the board, resulting in a voltage between the two grounds? What if this voltage is up to several Volts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="8172" LastEditorUserId="612" LastEditDate="2017-05-31T05:11:17.560" LastActivityDate="2017-11-26T18:56:02.293" Title="Conflicts with USB and external power supply" Tags="|serial|power|arduino-leonardo|usb|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9713" PostTypeId="2" ParentId="9712" CreationDate="2015-03-30T18:55:43.343" Score="1" Body="&lt;p&gt;Why do you suspect a potential difference? Where is th 7V coming from? If the 7V power supply is free floating and used for nothing else, there is no source for potential difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical wall wart will have a free floating output.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-03-30T18:55:43.343" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9714" PostTypeId="1" CreationDate="2015-03-30T19:03:25.587" Score="0" ViewCount="1070" Body="&lt;p&gt;I want to send a generic (not Sony, etc.) remote's signal from my Arduino.  I have already used a IR decoder program to capture the timing of the signal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int IRsignal[] = {&#xA;// ON, OFF (in 10's of microseconds)&#xA;    88, 88,&#xA;    174, 88,&#xA;    86, 86,&#xA;    88, 86,&#xA;    88, 88,&#xA;    86, 86,&#xA;    88, 174,&#xA;    86, 88,&#xA;    86, 88,&#xA;    174, 174,&#xA;    86, 88,&#xA;    86, 2252,&#xA;    88, 88,&#xA;    174, 88,&#xA;    86, 86,&#xA;    88, 88,&#xA;    86, 88,&#xA;    86, 86,&#xA;    86, 176,&#xA;    86, 88,&#xA;    86, 88,&#xA;    174, 174,&#xA;    86, 88,&#xA;    86, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I need to send this through the IR LED.  I have never written a program that can modulate a signal at this microsecond level.  How would I do this?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-04-16T18:27:46.833" Title="How do I send an IR signal from an Arduino" Tags="|ir|signal-processing|timing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9715" PostTypeId="1" CreationDate="2015-03-30T21:14:50.480" Score="0" ViewCount="496" Body="&lt;p&gt;I have this microphone (&lt;a href=&quot;http://www.digikey.com/product-detail/en/CMA-4544PF-W/102-1721-ND/1869981&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com/product-detail/en/CMA-4544PF-W/102-1721-ND/1869981&lt;/a&gt;) and an Arduino Uno board. I'm trying to read audio values off of my microphone (to test the noise of something (in dB)). I'm very new at this kind of stuff so keeping it simple would really help me out! I have a bunch of different capacitors, LM386N op amps, a bread board, and many resistors. Could someone provide a code and schematic that could help me get data off of my mic? I've tried using this schematic: &lt;a href=&quot;http://wiring.org.co/learning/basics/microphone.html&quot; rel=&quot;nofollow&quot;&gt;http://wiring.org.co/learning/basics/microphone.html&lt;/a&gt;&#xA;but couldn't get the code to download onto a Wiring S board due to a &quot;timeout&quot; error and it not being able to &quot;connect with the programmer&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any and all help would be much appreciated!! &lt;/p&gt;&#xA;" OwnerDisplayName="Jonah" LastActivityDate="2022-10-18T17:10:32.773" Title="Arduino Board with Microphone" Tags="|audio|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9716" PostTypeId="1" AcceptedAnswerId="9724" CreationDate="2015-03-30T21:53:00.747" Score="0" ViewCount="119" Body="&lt;p&gt;I'm building a project to measure/track &lt;a href=&quot;http://en.wikipedia.org/wiki/Flyball&quot; rel=&quot;nofollow&quot;&gt;flyball&lt;/a&gt; dog races.&#xA;The dogs timings are measured by photoelectric sensors at the start/finish line of the racing lane.&#xA;I have most of my code working (&lt;a href=&quot;https://github.com/vyruz1986/FlyballSensor&quot; rel=&quot;nofollow&quot;&gt;available&lt;/a&gt; on github) but I'm having some difficulties in handling very short crossings of dogs. Since I cannot realistically run a real race at home next to my development machine :-), I'm trying to build a simulator class which gives the triggers that would normally come from my photoelectric sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a RaceHandler class which has the following in its header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class RaceHandlerClass&#xA;{&#xA; public:&#xA;   long* lRaceStartTime = &amp;amp;_lRaceStartTime;&#xA;&#xA; private:&#xA;   long _lRaceStartTime;&#xA;}&#xA;extern RaceHandlerClass RaceHandler;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see I made a public pointer lRaceStartTime which points to the private _lRaceStartTime member variable.&#xA;This might seem stupid/strange, but it really should a private member variable, I just want to 'temporarily' make it publicly available, so that I can use it in a temporary 'simulator' class to simulate a race towards my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I want to use this public pointer in the Simulator class like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long* lRaceStartTime = RaceHandler.lRaceStartTime;&#xA;long lRaceElapsedTime = micros() - lRaceStartTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I get the following error when trying to compile this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: invalid operands of types 'long unsigned int' and 'long int*'&#xA;  to binary 'operator-'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm afraid my c++ knowledge ends here and I have no clue what I should do different to fix this...&#xA;Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="6635" LastActivityDate="2016-02-10T23:56:24.023" Title="Use pointer in calculation results in error" Tags="|c++|pointer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9717" PostTypeId="2" ParentId="9715" CreationDate="2015-03-30T21:59:32.830" Score="0" Body="&lt;p&gt;Very interesting stuff. As you are new to this kind of stuff i can suggest you, instead of explaining ( because videos are cool), to watch &lt;a href=&quot;https://youtu.be/hpMVG4a9sR4&quot; rel=&quot;nofollow&quot;&gt;this video&lt;/a&gt; that explains very clearly how to use the lm386 with some filters. That video is a project about controlling the arduino through whistling. Hope that helped.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-30T21:59:32.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9718" PostTypeId="1" CreationDate="2015-03-24T15:40:28.543" Score="5" ViewCount="5068" Body="&lt;p&gt;I have two square wave signals with the same frequency. I want to measure the phase shift between these two signals. There will be a small phase difference between two signals. (0-90 degree) and the frequency will vary in the range 100mHz - 50kHz. I am using an Arduino DUE (ATMEL ATSAM3X8E AU ,ARM)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use &quot;micros()&quot; for timer functionality to get 2 different times and then calculate the phase shift using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led=47,count1=0,count2=0,temp=0;&#xA;int i=0,j=0;&#xA;float time1[3]={0,0};&#xA;float time2[3]={0,0};&#xA;float freq1=0,freq2=0;&#xA;float period1=0,period2=0;&#xA;float ps=0;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;      Serial.begin(9600);&#xA;      Serial.println();&#xA;       Serial.println();&#xA;      pinMode(31,INPUT);&#xA;      pinMode(33,INPUT);&#xA;      pinMode(led,OUTPUT);&#xA;      digitalWrite(led,HIGH);&#xA;      noInterrupts();  &#xA;      attachInterrupt(31,in1,RISING);&#xA;      attachInterrupt(33,in2,RISING);&#xA;      interrupts();&#xA;}&#xA;&#xA;void in1()&#xA;{      noInterrupts();&#xA;       switch(i){&#xA;           case 0 : time1[i]=micros(); i++;  break;&#xA;           case 1 : if(j==1){time1[i]=micros(); i++; break;}&#xA;       }&#xA;       interrupts();&#xA;}&#xA;void in2()&#xA;{      noInterrupts();&#xA;       switch(j){&#xA;            case 0 : if(i==1){time2[j]=micros(); j++; break;}&#xA;            case 1 : if(i==2){time2[j]=micros(); j++; break;}&#xA;       }&#xA;           if(j==2){&#xA;             period1 = (time1[1]-time1[0]);&#xA;             period2 = (time2[1]-time2[0]);          &#xA;             freq1 = 1000.0/period1;         &#xA;             freq2 = 1000.0/period2;         &#xA;             ps = (((time2[1]-time1[1])*360.0)s/period1);&#xA;          if(freq1==freq2){&#xA;          Serial.println(&quot;&quot;);&#xA;          Serial.print(&quot;TIME1[0] = &quot;);&#xA;          Serial.print(time1[0],6);&#xA;          Serial.print(&quot;\t TIME1[1] = &quot;);&#xA;          Serial.print(time1[1],6);&#xA;          Serial.print(&quot;\t DEL1 = &quot;);&#xA;          Serial.println(time1[1]-time1[0],6);&#xA;          Serial.print(&quot;TIME2[0] = &quot;);&#xA;          Serial.print(time2[0],6);&#xA;          Serial.print(&quot;\t TIME2[1] = &quot;);&#xA;          Serial.print(time2[1],6);&#xA;          Serial.print(&quot;\t DEL2 = &quot;);&#xA;          Serial.println(time2[1]-time2[0],6);&#xA;          Serial.print(&quot;\t x = &quot;);&#xA;          Serial.print(time2[0]-time1[0],6);&#xA;          Serial.print(&quot;period1(ms) = &quot;);&#xA;          Serial.print(period1,6);&#xA;          Serial.print(&quot;\t period2(ms) = &quot;);&#xA;          Serial.println(period2,6);&#xA;          Serial.print(&quot;freq1 = &quot;);&#xA;          Serial.print(freq1,6);&#xA;          Serial.print(&quot;\t freq2 = &quot;);&#xA;          Serial.print(freq2,6);&#xA;          Serial.print(&quot;\t Phase Shift = &quot;);&#xA;          Serial.println(ps,6);&#xA;          } &#xA;          else { &#xA;          i=0;j=0;&#xA;          interrupts();&#xA;          }        &#xA;       }&#xA;       interrupts();&#xA;}&#xA;void loop()&#xA;{&#xA;       ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this code I am not getting any errors, but in high frequency (above 400 Hz) Ihave a problem. When I tested at 0 degrees, this code produced this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;400 Hz 1.152 degree&#xA;500 Hz 1.440 degree&#xA;600 Hz 1.727 degree&#xA;700 Hz 2.015 degree&#xA;800 Hz 2.304 degree&#xA;900 Hz 2.592 degree&#xA;1 kHz  2.880 degree&#xA;2 kHz  5.760 degree&#xA;3 kHz  8.649 degree&#xA;.&#xA;.&#xA;.&#xA;10 kHz 28.8 degree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each frequency has lowest degree that this code can calculate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this code? Is it possible to calculate the phase shift between two square wave signals this way?&lt;/p&gt;&#xA;" OwnerDisplayName="chaya" LastActivityDate="2015-07-01T18:48:29.403" Title="How to calculate phase shift between two square waveforms with Arduino DUE" Tags="|c|programming|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9719" PostTypeId="2" ParentId="9718" CreationDate="2015-03-24T15:59:39.080" Score="4" Body="&lt;p&gt;With 0° you have two inputs triggering interrupts at the same time.  That can't happen.  You can't run two interrupts at the same time, so the second one gets queued up until the first has finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all that serial printing in there there's going to be quite a delay between one interrupt triggering and the next one being allowed to trigger - giving you skewed results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest passing your signal through an XOR gate so that you end up with a single small pulse that represents the phase shift between the two signals.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2015-03-24T15:59:39.080" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9720" PostTypeId="2" ParentId="9718" CreationDate="2015-03-24T16:21:32.747" Score="3" Body="&lt;p&gt;Even if your code worked perfectly, with zero processing latency, you still are working with a timer resolution of only 1 microsecond.  If I did my math correctly, that means at 50 kHz, the smallest phase difference you can detect is around 18 degrees.  At 100 MHz, 1 microsecond is 100 complete cycles.  You probably want to look into hardware specifically designed for &lt;a href=&quot;http://en.wikipedia.org/wiki/Phase_detector&quot; rel=&quot;nofollow&quot;&gt;phase detection&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="40" OwnerDisplayName="Karl Bielefeldt" LastActivityDate="2015-03-24T16:21:32.747" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9721" PostTypeId="2" ParentId="9718" CreationDate="2015-03-24T20:04:19.013" Score="3" Body="&lt;p&gt;Connect the two signals to the TIOA pins of two different timer/counter channels on the same timer/counter block (either TIOA0 and TIOA1, which are Arduino pins 2 and A7, or any two of TIOA6, TIOA7, and TIOA8, which are Arduino pins 5, 3, and 11, respectively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set the two timer channels to capture mode, &quot;up&quot; counting, and internal clocking at the fastest rate that seems appropriate (I don't see any reason not to use &lt;code&gt;TIMER_CLOCK1&lt;/code&gt; = 42MHz on the Due). Set them both to load RA on rising edge of TIOA, and RB on falling edge. Assuming TIOA0 and 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pmc_enable_periph_clk(ID_TC0);&#xA;TC_Configure(TC0, 0,&#xA;    TC_CMR_TCCLKS_TIMER1 |&#xA;    TC_CMR_WAVSEL_UP |&#xA;    TC_CMR_LDRA_RISING |&#xA;    TC_CMR_LDRB_FALLING&#xA;);&#xA;&#xA;pmc_enable_periph_clk(ID_TC1);&#xA;TC_Configure(TC0, 1,&#xA;    TC_CMR_TCCLKS_TIMER1 |&#xA;    TC_CMR_WAVSEL_UP |&#xA;    TC_CMR_LDRA_RISING |&#xA;    TC_CMR_LDRB_FALLING&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set them both to generate interrupts on RA load:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TC0-&amp;gt;TC_CHANNEL[0].TC_IER = TC_IER_LDRAS;&#xA;NVIC_EnableIRQ(TC0_IRQn);&#xA;TC0-&amp;gt;TC_CHANNEL[1].TC_IER = TC_IER_LDRAS;&#xA;NVIC_EnableIRQ(TC1_IRQn);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Enable both clocks, and synchronize them so that they're both 0 at the same moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TC0-&amp;gt;TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN;&#xA;TC0-&amp;gt;TC_CHANNEL[1].TC_CCR = TC_CCR_CLKEN;&#xA;TC0-&amp;gt;TC_BCR = TC_BCR_SYNC;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And handle the interrupts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void TC0_Handler() {&#xA;    uint32_t status = TC0-&amp;gt;TC_CHANNEL[0].TC_SR;&#xA;    if (status &amp;amp; TC_SR_LDRAS) {&#xA;        uint32_t tm = TC0-&amp;gt;TC_CHANNEL[0].TC_RA;&#xA;        // rising edge of TIOA0 happened at &quot;tm&quot;,&#xA;        // do something here to deal with it...&#xA;    }&#xA;}&#xA;&#xA;void TC1_Handler() {&#xA;    uint32_t status = TC0-&amp;gt;TC_CHANNEL[1].TC_SR;&#xA;    if (status &amp;amp; TC_SR_LDRAS) {&#xA;        uint32_t tm = TC0-&amp;gt;TC_CHANNEL[1].TC_RA;&#xA;        // rising edge of TIOA1 happened at &quot;tm&quot;,&#xA;        // do something here to deal with it...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Just defining functions with those names registers them as interrupt handlers, using weak-symbol magic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose to use TIOA6/7/8, the clock will be &lt;code&gt;ID_TC6&lt;/code&gt;/&lt;code&gt;ID_TC7&lt;/code&gt;/&lt;code&gt;ID_TC8&lt;/code&gt;, and the &lt;code&gt;EnableIRQ&lt;/code&gt; will be &lt;code&gt;TC6_IRQn&lt;/code&gt;/&lt;code&gt;TC7_IRQn&lt;/code&gt;/&lt;code&gt;TC8_IRQn&lt;/code&gt;, but the &lt;code&gt;TC_Configure&lt;/code&gt; calls will be &lt;code&gt;TC2, 0&lt;/code&gt; / &lt;code&gt;TC2, 1&lt;/code&gt; / &lt;code&gt;TC2, 2&lt;/code&gt;, the &lt;code&gt;SYNC&lt;/code&gt; will be issued to &lt;code&gt;TC2&lt;/code&gt;, and the register accesses will be to &lt;code&gt;TC2-&amp;gt;TC_CHANNEL[0]&lt;/code&gt; / &lt;code&gt;TC2-&amp;gt;TC_CHANNEL[1]&lt;/code&gt; / &lt;code&gt;TC2-&amp;gt;TC_CHANNEL[2]&lt;/code&gt;. This is due to the way that the channels are grouped into blocks of three in the hardware. This is also why you have to use 0 and 1, or two of 6, 7, and 8; in order to sync the timers they have to be on the same block (and TIOA2 through TIOA5 aren't routed on the Due).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the clocks run at MClk/2 = 42MHz, the times you get will be in units of 1/42 microsecond, 42 times better than you get from &lt;code&gt;micros()&lt;/code&gt;. Because the timer values are latched into the timer hardware &lt;em&gt;before&lt;/em&gt; the interrupt is set, there isn't a problem if the two events come close to each other in time; you'll get the second interrupt after you finish handling the first, and the value in the register will still be valid (as long as you don't take so long that you miss more than one edge).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're interested in the falling edges, you can get those as well by setting the &lt;code&gt;TC_IER_LDRBS&lt;/code&gt; bits and checking for &lt;code&gt;status &amp;amp; TC_SR_LDRBS&lt;/code&gt; in your interrupt handlers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final advice: set your serial baud rate higher than 9600 if you can, you'll greatly decrease the amount of time you spend in &lt;code&gt;Serial.print&lt;/code&gt;!&lt;/p&gt;&#xA;" OwnerUserId="3508" OwnerDisplayName="hobbs" LastActivityDate="2015-03-24T21:14:28.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9722" PostTypeId="1" CreationDate="2015-03-30T22:32:53.180" Score="0" ViewCount="98" Body="&lt;p&gt;I am using an Arduino in an automation project which will be using a state machine to conduct a one-hour scenario.  Currently, the Arduino reads each input pin, runs its state update script, then sets each update pin.  99.99% of the time, each output pin will be set to the same state that it had in the last step.  Although it is better (in my opinion) to only set the pin when a setting changes, I was wondering if constantly checking and setting pins would have a big negative impact on the hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would checking a pin's current state (digitalRead or other method) before setting the pin improve anything?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-04-01T12:05:36.463" Title="Is it problematic to 'check an input pin' or 'set an output pin' each step?" Tags="|pins|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9723" PostTypeId="2" ParentId="9722" CreationDate="2015-03-30T23:05:10.507" Score="4" Body="&lt;p&gt;It does not hurt the Arduino to set an output pin to high if it was already set to high.  If you are concerned about performance, it is more efficient to just set the output pin compared to reading the pin and then setting it only if it's different&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-03-30T23:05:10.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9724" PostTypeId="2" ParentId="9716" CreationDate="2015-03-30T23:08:58.273" Score="2" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long* lRaceStartTime = RaceHandler.lRaceStartTime;&#xA;long lRaceElapsedTime = micros() - *lRaceStartTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You assigned the pointer to lRaceStartTime on the first line, but on the second line you are subtracting the pointer from &lt;code&gt;micros()&lt;/code&gt; which returns an &lt;code&gt;unsigned long&lt;/code&gt;.  You need to dereference the pointer before subtracting. Also you might consider making all your longs &lt;code&gt;unsigned&lt;/code&gt; to match the return type of &lt;code&gt;micros()&lt;/code&gt; &lt;a href=&quot;http://arduino.cc/en/reference/micros&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/reference/micros&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8175" LastEditorUserId="8033" LastEditDate="2015-04-01T14:54:04.400" LastActivityDate="2015-04-01T14:54:04.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9725" PostTypeId="1" CreationDate="2015-03-30T23:32:39.717" Score="1" ViewCount="50" Body="&lt;p&gt;If powering the Arduino (Mega) through the USB port, is a voltage of 5.19VDC acceptable?&lt;/p&gt;&#xA;" OwnerUserId="8176" LastActivityDate="2015-03-31T07:43:47.550" Title="Question regarding powering Arduino through the USB Port" Tags="|arduino-mega|power|usb|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9726" PostTypeId="2" ParentId="9725" CreationDate="2015-03-30T23:44:21.783" Score="0" Body="&lt;p&gt;That's the approximate expected voltage. The Arduino devices are typically powered at 5V, but the chips themselves are rated to work at values lower and higher than 5V.&lt;/p&gt;&#xA;" OwnerUserId="2947" LastActivityDate="2015-03-30T23:44:21.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9727" PostTypeId="2" ParentId="9653" CreationDate="2015-03-30T23:53:17.143" Score="1" Body="&lt;p&gt;I had this exact same problem.  It turned out that my atmega328p had the wrong fuses.  I am not sure how to solve the problem using the default ardiuino ide, however I was able to plug my ArduinoISP into a linux machine (just plug in the usb) and correctly profram the fuses on a slave atmega328p to solve the problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The guide here gets you started, however it missing some of the fuses:&#xA;&lt;a href=&quot;http://heliosoph.mit-links.info/arduinoisp-reading-writing-fuses-atmega328p/&quot; rel=&quot;nofollow&quot;&gt;http://heliosoph.mit-links.info/arduinoisp-reading-writing-fuses-atmega328p/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full command to set the default fuses is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -P /dev/ttyACM0 -b 19200 -c arduino -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-03-30T23:53:17.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9729" PostTypeId="2" ParentId="3165" CreationDate="2015-03-31T00:51:26.260" Score="1" Body="&lt;p&gt;In case anyone comes looking for an answer to this question, here is my solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with the excellent library by jeelabs (link: &lt;a href=&quot;https://github.com/jcw/rtclib&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jcw/rtclib&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create my new library, I changed a few of the register addresses, and added the few functions that I wanted it to do (set alarm, create an ordinal date, manually adjust the time with user input)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I posted my code to a Git project: &lt;a href=&quot;https://github.com/crako1t/MCP7940-library-for-logger.git&quot; rel=&quot;nofollow&quot;&gt;https://github.com/crako1t/MCP7940-library-for-logger.git&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2947" LastActivityDate="2015-03-31T00:51:26.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9730" PostTypeId="2" ParentId="6886" CreationDate="2015-03-31T02:38:25.353" Score="0" Body="&lt;p&gt;I have just spotted this question because I had a similar issue: the while condition reading Serial data is blocking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've rewritten the parsing part a little bit, which you can see &lt;a href=&quot;https://arduino.stackexchange.com/questions/9666/how-to-avoid-blocking-while-loop-reading-serial&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes it smoother to run things in parallel, but it takes about the same time to accumulate a big packet of brainwave data.&lt;/p&gt;&#xA;" OwnerUserId="3505" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-03-31T02:38:25.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9731" PostTypeId="1" CreationDate="2015-03-31T05:02:28.583" Score="4" ViewCount="41234" Body="&lt;p&gt;I want to make a circuit that control speed of DC fan Using Arduino PID Library to get thing at specific temperature.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZoVbA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit looks like this but can be changed, The dc fan motor connected to PWM 3 and thermistor connected with pin A0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thermistor check the temperature of a device that heated by nearby heater so fan cools the device to get the specific temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Heater not running, the thermistor value in Serial monitor 0-1023, When fan not running it gives 1023 and when fan runs at full speed it gives about 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when heater is running the values of thermistor has been changed and when fan not running it gives 1023 and when fan runs at full speed it gives about 500.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to set a point 650 from thermistor value(INPUT Value), and fan speed have to adjust using pid so temperature adjusted and the thermistor gives 650 value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample PID code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;PID_v1.h&amp;gt;&#xA;//Define Variables we'll be connecting to double Setpoint, Input, Output;&#xA;//Define the aggressive and conservative Tuning Parameters&#xA;double aggKp=4, aggKi=0.2, aggKd=1;&#xA;double consKp=1, consKi=0.05, consKd=0.25;&#xA;//Specify the links and initial tuning parameters&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint, consKp, consKi, consKd, DIRECT);&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  //initialize the variables we're linked to&#xA;  Input = map(analogRead(0), 0, 1023, 255, 0);&#xA;  Setpoint = 650;&#xA;  myPID.SetOutputLimits(0, 255);&#xA;  //turn the PID on&#xA;  myPID.SetMode(AUTOMATIC);&#xA;}&#xA;void loop()&#xA;{&#xA;  int sensorValue = analogRead(0);&#xA;  Input = map(analogRead(0), 0, 1023, 255, 0);&#xA;    double gap = abs(Setpoint-Input); //distance away from setpoint&#xA;  if(gap&amp;lt;10)&#xA;  {  //we're close to setpoint, use conservative tuning parameters&#xA;    myPID.SetTunings(consKp, consKi, consKd);&#xA;  }&#xA;  else&#xA;  {&#xA;     //we're far from setpoint, use aggressive tuning parameters&#xA;     myPID.SetTunings(aggKp, aggKi, aggKd);&#xA;  }&#xA;  myPID.Compute();&#xA;  analogWrite(3,Output);&#xA;  Serial.println(sensorValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What changes have to done in code so we can set point from input values?&#xA;And&#xA;Please help me so this code works for me.&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2015-04-13T12:10:28.870" LastActivityDate="2019-09-04T14:25:04.480" Title="Control Speed of DC FAN Using Arduino PID Library" Tags="|arduino-uno|arduino-mega|motor|pwm|pid|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9732" PostTypeId="2" ParentId="9725" CreationDate="2015-03-31T06:48:17.073" Score="1" Body="&lt;p&gt;Yes, the ATMEGA328 processor will work without any problem, in fact if you go in the power informations section on the datasheet, you will find that the processor can run from a little less of 3V to a maximum of 5.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just be careful, because &lt;em&gt;the processor&lt;/em&gt; works at that power, but &lt;em&gt;the board&lt;/em&gt; will need from 5 to 5.5V.&lt;/p&gt;&#xA;" OwnerUserId="4887" LastActivityDate="2015-03-31T06:48:17.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9733" PostTypeId="2" ParentId="140" CreationDate="2015-03-31T06:48:38.067" Score="-1" Body="&lt;p&gt;clc&#xA;clear all&#xA;global value&#xA;global value1&#xA;global val5&#xA;global val6&#xA;global val7&#xA;global val8&#xA;global val9&#xA;a=arduino('COM4');&#xA;   value = zeros();&#xA;   value1 = zeros();&#xA;   val5 = zeros();&#xA;   val6 = zeros();&#xA;   val7 = zeros();&#xA;  val8 = zeros();&#xA;  val9 = zeros();&#xA;for i=1:1000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val1(i)=analogRead(a,0)/2; %incomming&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val2(i)=analogRead(a,1)/2; %heater&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val3(i)=analogRead(a,2)/2;   %heat sink&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val4(i)=analogRead(a,5)/2; %atmsphr&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val8(i)=analogRead(a,6)/2; %pressure&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val9(i)=analogRead(a,7)/2; %pressure&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val(i)=analogRead(a,0)/2;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;value(i)= (val1(i)+val4(i)+val3(i))/3;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;value1(i) =(val8(i)-val9(i)); %pressure&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val5(i)=analogRead(a,0)/2 %incoming&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val6(i)=analogRead(a,4)/2 %outgoing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;val7(i) = value(i)-val6(i)&#xA;    plot(value, 'r');&#xA;    title('heat sink temprature');&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hold on&#xA;&#xA;plot(val5, 'k');&#xA;&#xA;title('incoming air temprature');&#xA;plot(val6, 'g');&#xA;&#xA;title('outgoing air temprature');&#xA;&#xA; plot(val4, 'k');&#xA; title('atmospheric temperature');&#xA;&#xA;plot(val7,  'c');&#xA;title('change in temprature');&#xA;&#xA;pause(6)&#xA;&#xA;figure&#xA;plot(value1,  'r');&#xA;title('change in pressure'); &#xA;&#xA;pause(6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;end&lt;/p&gt;&#xA;" OwnerUserId="8179" LastActivityDate="2015-03-31T06:48:38.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9734" PostTypeId="2" ParentId="9714" CreationDate="2015-03-31T06:52:53.260" Score="0" Body="&lt;p&gt;Please, take a look at Ken Shirrif's  &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;IRRemote&lt;/a&gt; library, as it is what you need. I used it in some project and worked better than other solutions that I coded.&lt;/p&gt;&#xA;" OwnerUserId="4887" LastActivityDate="2015-03-31T06:52:53.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9736" PostTypeId="2" ParentId="9725" CreationDate="2015-03-31T07:43:47.550" Score="0" Body="&lt;p&gt;The 5.19V you see, I guess you expect 5.00V, is a combination of power supply tolerance and the tolerance of your voltmeter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your voltmeter also has some error, we tend to forget that sometimes.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-03-31T07:43:47.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9737" PostTypeId="1" AcceptedAnswerId="9738" CreationDate="2015-03-31T09:23:34.667" Score="1" ViewCount="6515" Body="&lt;p&gt;I have a code with a connection to serial port:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Set baud rate&#xA;UBRR0H = UBRRH_VALUE;&#xA;UBRR0L = UBRRL_VALUE;&#xA;// Disable USART rate doubler (arduino bootloader leaves it enabled...)&#xA;UCSR0A &amp;amp;= ~(1 &amp;lt;&amp;lt; U2X0);&#xA;// Set async, no parity, 1 stop, 9bit&#xA;UCSR0C = (0&amp;lt;&amp;lt;UMSEL01)|(0&amp;lt;&amp;lt;UMSEL00)|(0&amp;lt;&amp;lt;UPM01)|(0&amp;lt;&amp;lt;UPM00)|(0&amp;lt;&amp;lt;USBS0)|(1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;UCSR0B |= (1&amp;lt;&amp;lt;UCSZ02); // 9bit&#xA;// Enable rx/tx&#xA;UCSR0B |= (1&amp;lt;&amp;lt;RXEN0)|(1&amp;lt;&amp;lt;TXEN0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see the comments but I want to know exactly what does these chunks means. Is there any complete documentation about these symbols?&lt;/p&gt;&#xA;" OwnerUserId="7852" LastEditorUserId="1585" LastEditDate="2015-03-31T17:17:47.070" LastActivityDate="2017-12-08T19:40:13.673" Title="What do symbols like UCSR0C, UMSEL01, etc. means?" Tags="|serial|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9738" PostTypeId="2" ParentId="9737" CreationDate="2015-03-31T10:40:30.963" Score="5" Body="&lt;p&gt;Take a look in the datasheet under the &quot;20. USART0&quot; section: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will list the names of the registers, what they are called, and then what your code is doing specifically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;UBRR0H and UBRR0L together form the baud rate divider.  Your program probably uses F_CPU and &lt;code&gt;&amp;lt;util/setbaud.h&amp;gt;&lt;/code&gt; to calculate a divider and set the baud rate.  For more information see Table 20-12.&lt;/li&gt;&#xA;&lt;li&gt;UCSR0A  &quot;USART Control and Status Register n A&quot;  --  This line is enabling the U2X0 which doubles the transmission speed&lt;/li&gt;&#xA;&lt;li&gt;UCSR0C  &quot;USART Control and Status Register n C&quot; --  This line is enabling the UCSZ01 and UCSZ00 bits to set parity check to &quot;Enabled, Odd Parity&quot;.  See Table 20-9.  This line has extra information, all the statements with 0&amp;lt;&amp;lt; actually do nothing.&lt;/li&gt;&#xA;&lt;li&gt;USCR0B &quot; USART Control and Status Register n B&quot; -- This line is setting the UCSZ02 bit which is described here: &quot;The UCSZn2 bits combined with the UCSZn1:0 bit in UCSRnC sets the number of data bits (Character SiZe) in&#xA;a frame the Receiver and Transmitter use. &quot;  This basically allows you to select 9 bit wide serial if you would like (8 bit is more common)&lt;/li&gt;&#xA;&lt;li&gt;The final USCR0B line enables tx and rx&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8175" LastEditorUserId="8175" LastEditDate="2015-03-31T21:54:35.617" LastActivityDate="2015-03-31T21:54:35.617" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9739" PostTypeId="2" ParentId="9710" CreationDate="2015-03-31T11:40:07.400" Score="2" Body="&lt;p&gt;Wireless doesn't necessarily mean it's WiFi.&#xA;You should get an XBee module that explicitly states that it's a WiFi module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a cheaper alternative you can check ESP8266 WiFi modules, which you can get for $5.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-03-31T11:40:07.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9740" PostTypeId="1" AcceptedAnswerId="9786" CreationDate="2015-03-31T11:56:26.100" Score="1" ViewCount="1497" Body="&lt;p&gt;My question is similar to this one: &lt;a href=&quot;https://arduino.stackexchange.com/questions/3892/motor-shield-and-wireless-transceiver-compete-for-same-pins&quot;&gt;Motor shield and wireless transceiver compete for same pins&lt;/a&gt;&#xA;But not exactly the same!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if the solution is as practical, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Mega 2560 R3, with an Arduino Motor shield plugged into it. Now I want to use the Adafruit CC3000 WiFi shield. It plugs in fine, but when reading the specifications, it wants to use pins 13, 12, 11 which are also used by the Motor shield. I also want to use pin 10 as a servo is plugged into it. This is all on a robot so I don't have space to wire the shield separately through a breadboard or similar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should perhaps also be noted that I have the motor shield on top of the wifi shield so that the wifi shield can use the ICSP ports which the motor shield doesn't have, therefore any redirecting of pins on the CC3000 will mean that the motor shield pins will also be affected unless I redirect them too, and at that point I feel like it would be all a bit of a mess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution to the other question was indeed to redirect the relevant pins to other free pins on the micro-controller board. However, I noticed that the Adafruit shield has a second row of connector holes next to the main pin holes. In the &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-cc3000-wifi.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;shield documentation&lt;/a&gt; I found, I didn't find any specific reference to these parts and in what situations they could be used, but maybe this is one of them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My concern with using these is that (as you can see in the second image below, ignoring the coin!), the ports are wired together in the board. Does this mean that it won't make any difference which I use; if I connect a second row of pins/connectors to these points will it simply transmit the same data down both sides? I don't know enough about how electronics work at that level to understand the consequences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really my question is: can I use the outside row of ports for my motor shield and the inside row for the wifi shield? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YSc44.jpg&quot; alt=&quot;Adafruit WiFi Shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TpAAY.jpg&quot; alt=&quot;Underside of shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've spent until now on the Adafruit forums trying to get some help with this and I still am not all the way there... maybe at this point someone here can cast fresh eyes over my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Adafruit CC3000 uses both the dedicated ICSP pins and pins 3, 11-13 to transmit the same data. The reason for this is to do with compatibility between different Arduino boards and their versions. E.g. apparently the Uno uses those pins whilst the mega uses some of the pins in the 50s range. I'm not sure what to make of this as the Uno and most of the boards seem to have the ICSP pins, so if they're not used for this purpose then what's the point of connecting to them? Anyway. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it was explained to me, even if the board can use the ICSP pins to communicate with the microcontroller, it is still sending data via the other pins. So the main pins are essentially useless at this point. To make them useful again, the idea is that you sever the wires that are sending the data through them (often referred to as trace wires). This means that only the ISCP ones will be active for what they are needed, and the main pins will be free for other uses. This is what I ended up doing to my board for pins 11-13, and then for pin 3 I cut the trace wire and wired up the connection to pin 2 as these can both be used for an IRQ (interrupt request) on the Mega and I need pin 3 for the motor shield. The lighting on these pictures isn't the best, but you can see what I've done (the lower part of the second image shows where I made the cuts and the top image shows the wire connection):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/p88FG.jpg&quot; alt=&quot;Top view&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HdtVH.jpg&quot; alt=&quot;Underside view&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing that I have been testing the shield connected to both my Mega and my Uno and they both produce the same results. This is using the Adafruit-created library called &lt;code&gt;Adafruit_CC3000_Library&lt;/code&gt;. It starts the initialisation, then whilst it's trying to run the code it gets stuck. I traced the problem to a while(1) loop of which you can only exit by meeting a condition which is never met in my case: &lt;code&gt;if (*pucReceivedData == HCI_TYPE_EVNT)&lt;/code&gt;. This may be because &lt;code&gt;pucReceivedData&lt;/code&gt; is not initialised properly, but I don't know why and whether it has to do with my modifications. This happens in the &lt;code&gt;hci_event_handler&lt;/code&gt; method of &lt;code&gt;evnt_handler.cpp&lt;/code&gt;. This is  through the main file and &lt;code&gt;wlan.cpp&lt;/code&gt; so I won't write it here as it is simple enough to follow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also be noted that this shield doesn't work properly with the later versions of the arduino IDE (1.5+) so I had to reinstall 1.0.6. To be honest, I got the same problem on both versions so who knows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realise that this is a very specific problem, but I figure that this may leave someone with a lot fewer issues in the future. If anyone has any bright ideas, even if just for testing then I would be grateful.&lt;/p&gt;&#xA;" OwnerUserId="454" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-02T11:22:25.153" Title="Arduino Motor Shield and Adafruit CC3000 WiFi Shield Compatibility" Tags="|shields|wifi|arduino-motor-shield|adafruit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9741" PostTypeId="2" ParentId="9712" CreationDate="2015-03-31T12:47:01.187" Score="1" Body="&lt;p&gt;When you connect the USB, you also connect the ground of the computer to he arduino board. And then when the external power supply is connected to the arduino board the negative pin or the ground pin coming from the external power supply is connected to the ground pin of the USB. Thus the external power supply and the PC share the same ground.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-03-31T12:47:01.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9742" PostTypeId="1" CreationDate="2015-03-31T13:15:03.703" Score="1" ViewCount="2232" Body="&lt;p&gt;I would like to control 2 motors with the Arduino Uno board, which provides only two interrupt pins on digital 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set one encoder using these pins, and it works. What do you think about the following approaches:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Timer Interrupt:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Create a Timer Interrupt.&#xA;Connect the seconder encoder to an analog pin.&#xA;Set an analog read function in the interrupt service routine.&#xA;Change the prescaler of the ADC and increase the acquisition time. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PinChangeInt&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use PinChangeInt to capture the pin change interrupt rather than an external interrupt. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This should allow you to use almost any I/O pins on the Uno for the&#xA;  encoder.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;as Ignacio Vazquez-Abrams suggested &lt;a href=&quot;https://arduino.stackexchange.com/questions/4801/rotary-encoder-on-uno-and-interrupts-issue&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-04-01T01:15:40.900" Title="Is it possible to use two encoders with Arduino Uno?" Tags="|arduino-uno|motor|analogread|timers|rotary-encoder|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9743" PostTypeId="2" ParentId="9742" CreationDate="2015-03-31T15:23:22.303" Score="1" Body="&lt;p&gt;It is very possible. use a separate interrupt pin for Phase A of both motors, then read phase B from a non interrupt pin in the interrupt handler.&#xA;&lt;a href=&quot;http://www.spiked3.com/?p=5501&quot; rel=&quot;nofollow&quot;&gt;http://www.spiked3.com/?p=5501&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-04-01T01:15:40.900" LastActivityDate="2015-04-01T01:15:40.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9744" PostTypeId="1" CreationDate="2015-03-31T15:30:22.583" Score="5" ViewCount="287" Body="&lt;p&gt;My Arduino Uno is running out of memory to support my script (yes, I've tried several ways of optimize it already: PROGMEM, EEPROM, no Strings, and so on), so I would like to upload my script to my &lt;a href=&quot;http://wiring.org.co/hardware/&quot; rel=&quot;noreferrer&quot;&gt;Wiring S&lt;/a&gt; board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, instead of &quot;porting&quot; all libraries to Wiring, I would like to compile my script in Arduino IDE and upload it to my Wiring S. It used to be &quot;easy&quot; in Arduino v.1.0.x. because somwhere I got a Wiring folder (containing, among other things, a boards.txt file) and copied it to Arduino's &lt;code&gt;hardware&lt;/code&gt; folder getting the Wiring S board listed in Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Arduino 1.5 the &lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification&quot; rel=&quot;noreferrer&quot;&gt;specification for adding other boards changed&lt;/a&gt;. I'd say it's more complex now. I simply cannot understand most of the new specification (yes, I'm new into electronics), so I haven't been able to add my Wiring S board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running my script in Arduino 1.0.x doesn't seem to be an option, since it throws lots of errors (although the script compiles in Arduino 1.6.2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any experience adding other boards (like Wiring S) to Arduino IDE? Could you please give me some hint?&lt;/p&gt;&#xA;" OwnerUserId="8034" LastActivityDate="2016-01-25T02:16:10.523" Title="How to add the Wiring S board to Arduino IDE v.1.6.2?" Tags="|arduino-uno|sketch|sketch-size|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9746" PostTypeId="2" ParentId="253" CreationDate="2015-03-31T17:14:23.483" Score="0" Body="&lt;p&gt;You can connect Android and Arduino with usb and use the easy tool App inventor 2 for android &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you try this new application : &lt;a href=&quot;https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo&lt;/a&gt; and full version : &lt;a href=&quot;https://play.google.com/store/apps/details?id=bp.usbbridge.appinv&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=bp.usbbridge.appinv&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find Videos about Explications : USB OTG Bridge Serial UART for APP Inventor 2 and ARDUBLOCK on youtube&lt;/p&gt;&#xA;" OwnerUserId="8187" LastActivityDate="2015-03-31T17:14:23.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9747" PostTypeId="2" ParentId="964" CreationDate="2015-03-31T17:18:28.900" Score="1" Body="&lt;p&gt;You can connect Android and Arduino with usb and use the easy tool App inventor 2 for android &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you try this new application : &lt;a href=&quot;https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo&lt;/a&gt; and full version : &lt;a href=&quot;https://play.google.com/store/apps/details?id=bp.usbbridge.appinv&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=bp.usbbridge.appinv&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find Videos about Explications : USB OTG Bridge Serial UART for APP Inventor 2 and ARDUBLOCK on youtube&lt;/p&gt;&#xA;" OwnerUserId="8187" LastActivityDate="2015-03-31T17:18:28.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9748" PostTypeId="1" AcceptedAnswerId="9750" CreationDate="2015-03-31T19:22:21.997" Score="5" ViewCount="252" Body="&lt;p&gt;I have an Arduino project that has 15 different output pins set.  Some are currently attached to devices and others are not.  Will testing my program cause a problem / damage if it sets pints to HIGH that do not have anything connected to them?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-03-31T19:25:40.493" Title="Can I damage an arduino by setting pins high with no load" Tags="|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9749" PostTypeId="2" ParentId="9709" CreationDate="2015-03-31T19:25:17.340" Score="3" Body="&lt;p&gt;You could use: U(S)ART, I²C or SPI. You should check &lt;a href=&quot;https://electronics.stackexchange.com/questions/37814/usart-uart-rs232-usb-spi-i2c-ttl-etc-what-are-all-of-these-and-how-do-th&quot;&gt;this post&lt;/a&gt; for information on these protocols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some quick googling gave me this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SPI: mainly for high data rates, approx 25 MHz clock but only bus has to be on same voltage level, single master (can be done through software), data arbitration not possible.&lt;/li&gt;&#xA;&lt;li&gt;I2C: mainly for control and low data transfer (limited by bus capacity, etc...), but can be interfaced to different voltage levels and multimaster bus environment, inbuilt arbitration etc...&lt;/li&gt;&#xA;&lt;li&gt;UART: single P2P comm, 115 kbps max.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.edaboard.com/thread53139.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.edaboard.com/thread53139.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't fully agree with it. You can send via UART to multiple devices, but then you have to handle the addressing in software. But other than that, UART is very easy to debug as Arduinos often have an USB connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;I²C is somewhat complicated at the physical level, but all that complication is handled by the hardware (the TWI interface of the AVR chips). At the user level, it may be the simplest to use&quot;. I don't yet have a lot of experience with this protocol, but if you want to use it, check out the other answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI would be a fair shot as it does enable master with multiple slaves in its standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All protocols have different pros and cons. It's not really up to us to choose one for you. And you should look them up and learn about them by yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then try to choose which one applies most to your needs, and get started with that protocol. They are well documented and if you really can't get out of it, you can post another question ;D&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="4628" LastEditDate="2017-11-20T04:36:38.520" LastActivityDate="2017-11-20T04:36:38.520" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9750" PostTypeId="2" ParentId="9748" CreationDate="2015-03-31T19:25:40.493" Score="8" Body="&lt;p&gt;Nope, you should be just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having a pin set to any state while unplugged will not cause any problems with your microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-03-31T19:25:40.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9751" PostTypeId="2" ParentId="1323" CreationDate="2015-03-31T19:39:59.820" Score="1" Body="&lt;p&gt;This would differ per device/reader.&#xA;Currently, I'm in a project with a TRF7970a RFID reader. I've seen it it's datasheet that it does have options to send RAW values as it does not support every protocol (NXP has patent on one?) thus the chip doesn,t parse it, but can send it to the mcu completely.&#xA;In short, yes this is possible.&#xA;But using a reader that is compliant with your protocol might supress your development cost/time&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-03-31T19:39:59.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9752" PostTypeId="1" AcceptedAnswerId="9757" CreationDate="2015-04-01T00:23:10.007" Score="5" ViewCount="21955" Body="&lt;p&gt;I am trying to use the &lt;code&gt;millis()&lt;/code&gt; function to turn on a pin for a specified interval then turn off and turn on a second pin. It is intended to power a relay and offer a visual cue to when the cycle is over. Several of these need to eventually be running, most likely three, so using &lt;code&gt;delay()&lt;/code&gt; won't work. I plan to add additional &quot;button pins&quot; for each input. The LED lights up but gets stuck in the loop and doesn't cycle out. It seemed like a simple program but I can't crack it for some reason. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a much better method to do this? There will be two optical sensors and one pushbutton switch attached to an air driven crushing machine. The two optical sensors will be used only as time indicators with LEDs and the pushbutton will power the relay. Forgive my shortcomings as a programmer, I am learning the programming language still. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =  2;      // the number of the LED pin&#xA;const int buttonPin = 3;    // Button pin number&#xA;// Variables will change:&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;int buttonState = 0;            // Checks if button is pushed&#xA;int buttonPush = 0;             // Toggles between 0 to hold state&#xA;long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;void setup() {&#xA;// set the digital pin as output:&#xA;   pinMode(ledPin, OUTPUT);      &#xA;   pinMode(buttonPin, INPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;   unsigned long currentMillis = millis();&#xA;   buttonState = digitalRead(buttonPin);&#xA;   if (buttonState == HIGH) {&#xA;      buttonPush = 1;&#xA;      if (buttonPush == 1){&#xA;         if(currentMillis - previousMillis &amp;gt; interval) {&#xA;            previousMillis = millis();   &#xA;            digitalWrite(ledPin, HIGH);&#xA;         }&#xA;         else {&#xA;            buttonPush = 0;     &#xA;         }  &#xA;      }&#xA;      else {&#xA;         digitalWrite(ledPin, LOW); &#xA;      }&#xA;   } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Thank you for looking over the code, you guys are awesome. There were a couple questions regarding clarity of the final application so I will elaborate. I am going to attempt to clean it up. I had a feeling something was wrong with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (buttonState == HIGH) {&#xA;   buttonPush = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I couldn't put my finger on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually the system will function with two heating elements to soften plastic, which I will either add an optical sensor to since it will probably get triggered a few hundred times a day, or just a pushbutton to start a timer so the plastic isn't left in too long. A green LED will be illuminated to indicate the system is on. When the plastic object is placed in the heating element it triggers the optical sensor (or the operator pushes a pushbutton to start the timer) that will then illuminate a red LED to indicate heating. When the specified time interval has expired, the LED will revert back to green to show the cycle is complete. The plastic object is then removed and placed in a pneumatic crushing device with a green system on LED. The operator then pushes a pushbutton which turns on a red indicator LED and a relay to power the solenoid on the pneumatic press for a specified amount of time to allow the plastic to cool and crystallise. When that interval has expired, the system will revert back to illuminating the green LED and will end power to the relay allowing the press to release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pneumatic press and the heating system works awesome, I just need better control of the time intervals used. The end result needs to be consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am going to try all suggestions and will post what ended up working if I reach that point or find an answer that functions. &lt;/p&gt;&#xA;" OwnerUserId="8192" LastEditorUserId="6936" LastEditDate="2016-12-06T23:10:38.083" LastActivityDate="2018-01-16T05:30:30.263" Title="millis() function with a button press" Tags="|millis|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9753" PostTypeId="2" ParentId="3700" CreationDate="2015-04-01T00:58:57.060" Score="1" Body="&lt;p&gt;I was having the same problem. installed the latest drivers, I'm using yosemite, installed the Arduino IDE, and tried the board in windows 7 and it worked in windows, so board and cable are working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In mac OS 10.10 in system report now they show as USB 2.0 Serial in arduino IDE it appears the port now (only after I used the SUDO command that sjunnesson posted) /dev/cu.wchusbserialalpha1310 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;so, use the sudo command if you are in yosemite&lt;/p&gt;&#xA;" OwnerUserId="8193" LastEditorUserId="8193" LastEditDate="2015-04-01T06:37:05.473" LastActivityDate="2015-04-01T06:37:05.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9754" PostTypeId="2" ParentId="9752" CreationDate="2015-04-01T02:41:22.827" Score="0" Body="&lt;p&gt;Summary:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fatal problem is caused by the two lines of code below.&lt;br&gt;&#xA;A variable is set and then the same variable is immediately tested to see if it is set.  This means that the IF test always passes and the ELSE never happens. &#xA;As the LED is cleared only when the else occurs, the LED stays lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  buttonPush = 1;  &#xA;  if (buttonPush == 1){ ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When the button is pressed you set buttonPush and then immediately test to see if it is set.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it always is set, the LED never gets turned off as the &quot;else&quot; condition is never met.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even when that is fixed you have other issues.&lt;br&gt;&#xA;I suggest that &quot;expanding&quot; the code along the lines I have shown in (3) below will help you immensely with visualising what your code does.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a large number of editors which handle this task in various ways, but just plain tabbing and white space with a basic editor helps muchly. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It seems almost certain that your code will NOT do what you intend when it does work &quot;properly&quot;, but there are several issues below that need addressing (one fatal, others less so) - see &quot;ISSUES&quot; below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from those issues, it's not 100% clear how this is intended to be used.&lt;br&gt;&#xA;Options include:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch is pressed and released quickly (say 100 mS) - LED lights for one second and then goes out.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Switch is pressed and held - LED lights for one second then turns off even when switch is held on. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Other variants are possible. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At present it will not do any of these.   &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;ISSUES:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(1) You have assigned  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;long previousMillis = 0;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This should be &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;unsigned long previousMillis = 0;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Mixing the two types gives an uncertain result. At best, an error will occur when the value returned by millis() exceeds the length of a &quot;long&quot; data type and when types are mixed there is no guarantee that the result will be valid. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(2) I have not checked it, but I'd be wary of the line&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if(currentMillis - previousMillis &gt; interval)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;as it depend on operator precedence of the &quot;-&quot; being implemented prior to the &quot;&gt;&quot; comparison.&lt;br&gt;&#xA;ie this could potentially evaluate as either  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot; (A-B) &gt; C &quot; .... which is what you intend,&lt;br&gt;&#xA;or&lt;br&gt;&#xA;&quot; A - (B &gt; C) &quot; .... which, while it is not what is intended, does have a valid if not useful result.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can rely on operator precedence if you have confidence in yourself and the system or make it explicit as in eg  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if( (currentMillis - previousMillis) &gt; interval)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Making things easier for yourself:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has been edited to match my main conclusion which was already covered above (the problem was not nesting but a test that can never fail - as covered above) but the formatting  comments are relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code is written in a standard (or usual) manner. Some are able to handle such without problem, but I (and many others) find such layout hard to read and, importantly, easy to bury errors in. The following is overdone - I used existing tabs and expanded it in Word :-) - but to me the following makes it immensely more readable. Layout and style are a matter of personal preference, and there are many opinions re what is &quot;best&quot;, but something which allows ease of visualisation of program structure is liable to be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two adjacent lines&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;  buttonPush = 1;  &#xA;  if (buttonPush == 1){ ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;are logically grouped together when indented like this at make it clearer that the &quot;set then test&quot;   arrangement can never fail so the subsequent &quot;else&quot; where the LED is turned off is never implemented. So the LED must stay on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vPdVX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;buttonPush = 0; is bolded for unrelated reasons.   &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-04-05T05:49:35.637" LastActivityDate="2015-04-05T05:49:35.637" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9755" PostTypeId="2" ParentId="9626" CreationDate="2015-04-01T05:31:03.873" Score="-1" Body="&lt;p&gt;my friend, i have some problems with version 2.0 trying to read some cards. i think that the problem when  u cant read the card is this version . i have both version 1.0 and 2.0, version 1.0 detect all card type, and 2.0 some not. &#xA;for me is a big problem because, here in argentina i only found version 2.0. maybe change on library some.&lt;/p&gt;&#xA;" OwnerUserId="8194" LastActivityDate="2015-04-01T05:31:03.873" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9756" PostTypeId="2" ParentId="1722" CreationDate="2015-04-01T05:44:10.110" Score="0" Body="&lt;p&gt;The reason why your slide/microarray microdispenser continually oscillates about a point rather than dispense the fluid containing your cells/DNA sample specifically at a particular specified/designated point on your slide/microarray is due to your code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(encoderI) == digitalRead(encoderQ)){&#xA;     //dispenser is moving to the left&#xA;     ActualHeadPosition++;&#xA;   }&#xA;&#xA;   else {&#xA;     //dispenser is moving to the right&#xA;     ActualHeadPosition--;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which tells the Arduino to actuate the motor regardless of the values stored in the vars encoderI &amp;amp; encoderQ.&lt;/p&gt;&#xA;" OwnerUserId="8195" LastActivityDate="2015-04-01T05:44:10.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9757" PostTypeId="2" ParentId="9752" CreationDate="2015-04-01T06:58:22.257" Score="2" Body="&lt;p&gt;Some code is shown below to illustrate a method for treating three events independently.&lt;/p&gt;&#xA;&lt;p&gt;This code might not be completely applicable as-is, because the problem description isn't clear about what should happen when a button is pressed and about whether other events to be added to the code are like the one shown there now.  However, if you understand how it works you probably can adjust it to meet any special requirements of your application.&lt;/p&gt;&#xA;&lt;p&gt;During each pass through the &lt;code&gt;loop()&lt;/code&gt; routine, the code does the following for each type of event:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If the event is not currently active (as denoted by &lt;code&gt;states[i] &amp;lt; debounced&lt;/code&gt;), the code checks whether the event's button has been pressed (or, if its sensor has turned on).  If so, the code increments a debounce counter.  If the event's counter gets up to &lt;code&gt;debounced&lt;/code&gt;, then the output for the event is turned on, and the event's end-time is stored in an array entry.&lt;/p&gt;&#xA;&lt;p&gt;If the event &lt;em&gt;is&lt;/em&gt; currently active (as denoted by &lt;code&gt;states[i] &amp;gt;= debounced&lt;/code&gt;), the code tests if the event's end-time has arrived; if so, it turns off the event's output bit and resets its state to 0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The last statement in &lt;code&gt;loop()&lt;/code&gt; busy-waits until &lt;code&gt;milliseconds()&lt;/code&gt; returns a different value than before.  This is done so that switch-debouncing samples are taken at least a millisecond apart.  If your inputs don't need debouncing, you can remove debounce code .&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/* Process three asynchronous activities: Upon a given input going&#xA;true, activate its associated output(s) for specified lengths of time.&#xA;*/&#xA;&#xA;enum { nkinds=3, debounced=5 }; // # of activity kinds;  debounce-criterion&#xA;const byte outPins[nkinds] = {2, 4, 6}; // Output pin numbers&#xA;const byte inPins[nkinds]  = {3, 5, 7}; // Input pin numbers&#xA;const unsigned int actLens[nkinds] = {345, 678, 323}; // Activity lengths, ms&#xA;byte states[nkinds] = {0, 0, 0};&#xA;unsigned long actEnds[nkinds] = {0, 0, 0};&#xA;&#xA;void setup() {&#xA;// Set input/output modes of pins&#xA;  for (byte i=0; i&amp;lt;nkinds; ++i) {&#xA;    pinMode(outPins[i], OUTPUT);&#xA;    pinMode(inPins[i], INPUT);&#xA;  }&#xA;}&#xA;&#xA;// Once per millisecond, for each kind of activity&#xA;// check for new beginning or deal with ongoing action&#xA;void loop() {&#xA;  unsigned long now = millis();&#xA;  for (byte i=0; i&amp;lt;nkinds; ++i) {&#xA;    if (states[i] &amp;lt; debounced) {  // Is activity off?&#xA;      // It's off, look for a turnon&#xA;      if (digitalRead(inPins[i])) {&#xA;        ++states[i];        // Button is closed at the moment&#xA;        // See if button has been debounced&#xA;        if (states[i] &amp;gt;= debounced) { // If so, start its action&#xA;          digitalWrite(outPins[i], HIGH);&#xA;          actEnds[i] = now + actLens[i];&#xA;        }&#xA;      }&#xA;      else {&#xA;        states[i] = 0;      // Button is not closed at moment&#xA;      }&#xA;    }&#xA;    else { // It's on, see if end-time has arrived&#xA;      if (now &amp;gt;= actEnds[i]) {&#xA;        digitalWrite(outPins[i], LOW); // Clear output when done&#xA;        states[i] = 0;        // Return to button-seeking state&#xA;      }&#xA;    }&#xA;  }&#xA;  while (now == millis()) {};       // Finish current millisecond&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code above compiles ok in the Arduino IDE but I haven't tested it on an Arduino device.&lt;/p&gt;&#xA;&lt;p&gt;Note, larger systems with numerous events will use priority queues to implement lower-overhead versions of the same ideas.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-01T14:25:27.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9758" PostTypeId="1" CreationDate="2015-04-01T08:43:57.290" Score="0" ViewCount="561" Body="&lt;p&gt;I'm connect arduino to my PC through serial monitor. Very common situation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;delay(100);&#xA;Serial.print(&quot;Hello, World!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I always get an &lt;code&gt;¤ello, World!&lt;/code&gt;. How can I get the first symbol straight? I've tried on both unix &amp;amp; windows, mega &amp;amp; uno. I've also tried &lt;code&gt;println&lt;/code&gt;, but with no happiness&lt;/p&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-11-16T14:37:23.010" Title="Arduino serial monitor first message" Tags="|serial|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9759" PostTypeId="1" CreationDate="2015-04-01T09:51:14.453" Score="0" ViewCount="1205" Body="&lt;p&gt;I am using two XBee Pro S2B modules. One (Router) connected to the laptop via a UART cable. The other (Coordinator) connected to an Arduino Mega with the sketch below.  All I need it to do is turn a LED on and off and display the status in the IDE serial monitor.  I am using Arduino IDE (v1.6.0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial xbee (2,3);&#xA;&#xA;int myData = 0;&#xA;int ledPin = 13;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    xbee.begin(Serial);&#xA;&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (Serial.available())&#xA;    {&#xA;         int myData = Serial.read();&#xA;&#xA;         if(myData == '1')&#xA;         {&#xA;             digitalWrite(ledPin,HIGH);&#xA;             Serial.write(myData, DEC);&#xA;         }&#xA;         if(myData == '2')&#xA;         {&#xA;             digitalWrite(ledPin,LOW);&#xA;             Serial.write(myData, DEC);&#xA;         }&#xA;     }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where did I go wrong?&lt;/p&gt;&#xA;" OwnerUserId="8202" LastEditorUserId="6936" LastEditDate="2016-03-15T23:43:00.590" LastActivityDate="2016-03-15T23:44:48.467" Title="How to read info from an Xbee Pro S2B to an Arduino with a Xbee Pro S2B" Tags="|serial|xbee|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9760" PostTypeId="2" ParentId="9722" CreationDate="2015-04-01T12:05:36.463" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Would checking a pin's current state (digitalRead or other method)&#xA;  before setting the pin improve anything?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SetPin(OUTPUTPIN,true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You want to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(!PinIsSet(OUTPUTPIN)){&#xA; SetPin(OUTPUTPIN,true):&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To avoid writing to a pin (making it high) when it's already high/enabled?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well doing so will waste a little amount of your programs' speed (it'll need to check each pin before setting it). But when you set a pin, when it's already high, it simply doesn't even change. And even then it's not required to check it first, Microcontrollers are basically made for this.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-01T12:05:36.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9761" PostTypeId="1" CreationDate="2015-04-01T12:14:52.030" Score="2" ViewCount="45" Body="&lt;p&gt;Had some start up difficulties. But updated the YUN and IDE to the latest version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using  &lt;code&gt;* &quot;/arduino/digital/13/1&quot;&lt;/code&gt; works as supposed (turns on the LED) - it's just a bit slow. But I can't see why the analogs shouldn't work. I tried to connect it to 5V or GND, so it wasn't floating. But it still returns no reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't know if this is the cause. But when I connect to my router I can't the the YUN in the list of DHCP Clients...&lt;/p&gt;&#xA;" OwnerUserId="8205" LastActivityDate="2015-04-01T12:14:52.030" Title="Bridge */arduino/analog/2 returns a blank page" Tags="|arduino-yun|analogread|h-bridge|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9763" PostTypeId="2" ParentId="8943" CreationDate="2015-04-01T14:37:25.933" Score="0" Body="&lt;p&gt;I'll have to chime in with the others and say &quot;It depends.&quot; The Uno, or more precisely its Atmega328p microcontroller, is rather memory limited, especially the RAM memory needed for data buffers, stack-frames, and tables such as the character-generator for the LCD. That last one can usually be kept in program memory, but note that if you're having to plan memory assignment before you even start the project, it's a pretty good sign that you should consider something more capable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino Mega 2560 is about twice the price of the Uno (in the US, US$50 vs. US$25) but gives you 4 times the RAM memory, 8 times the flash (program) memory, and a bunch more (sorry to get all technical :) I/O pins. Of these, the RAM is likely to be your most stringent limit with the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I keep one Arduino Mega around for prototyping or when don't want to build another board for an experiment, and a handful of AtMega328p chips to build into &quot;Arduin-ettes&quot; for my more permanent gadgets. Most of my toys will fit on the '328 chip but it's awfully nice to be able to shove a ton of code, libraries, debugging statements, logging buffers and what have you, into the larger processor without having to think about what will fit. Or, what's worse, if I cause a stack crash by stuffing all of that into too-little memory, I could waste a lot of time debugging a presumed coding error when it was really an out-of-memory problem.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-01T14:37:25.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9764" PostTypeId="2" ParentId="9752" CreationDate="2015-04-01T14:49:11.023" Score="0" Body="&lt;p&gt;The direct answer to your first question (LED gets stuck) after formatting and summarizing a section of your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  buttonPush = 1;&#xA;  if (buttonPush == 1){&#xA;     ...&#xA;  }&#xA;  else {&#xA;     digitalWrite(ledPin, LOW); &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is that there's a logic error. You can see that the else clause, turning off the LED, will never be executed because buttonPush is always 1 before you enter this section. I think this is the point @RussellMcMahon was trying to make.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to your second question, needing several of these running at once, is: Get the first one to work first. Then simplify it as much as you can. Then you can choose between using polling loop (repeatedly reading the clock and deciding whether it's time to do something) or setting interrupts (making the clock interrupt your main program to run the routine that does the &quot;something&quot;).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-04-01T15:02:42.903" LastActivityDate="2015-04-01T15:02:42.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9765" PostTypeId="1" CreationDate="2015-04-01T14:50:36.220" Score="2" ViewCount="2740" Body="&#xA;&#xA;&lt;p&gt;I would like to control 2 motors using Timer2 @ 200Hz. The frequency of the timer is printed in the main loop every second. I'm using an Arduino Uno with two interrupt used for the encoders connected to pin 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer runs at 200Hz as expected but the motors are shaking even if I ask them not to spin. The Timer2 is not required by the servo library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem? How do you handle Timer interrupts and servo routines?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo motorDx, motorSx;&#xA;[...]&#xA;&#xA;void setup()&#xA;{&#xA;  // Setup Timer2 @ 200Hz&#xA;  cli(); // Stops interrupts&#xA;&#xA;  TCCR2A = 0;// set entire TCCR1A register to 0&#xA;  TCCR2B = 0;// same for TCCR1B&#xA;&#xA;  // set compare match register for 200 Hz increments&#xA;  OCR2A = 77;// = (16*10^6) / (200*1024) - 1 -&amp;gt; 200 Hz&#xA;&#xA;  // turn on CTC mode&#xA;  TCCR2A |= (1 &amp;lt;&amp;lt; WGM21);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler&#xA;  TCCR2B |= (1 &amp;lt;&amp;lt; CS20) | (1 &amp;lt;&amp;lt; CS21) | (1 &amp;lt;&amp;lt; CS22);  &#xA;  // enable timer compare interrupt&#xA;  TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A);&#xA;&#xA;  sei(); //enable global interrupts&#xA;&#xA;  attachInterrupt(0, MSencVel, RISING);&#xA;  attachInterrupt(1, MDencoder, RISING);&#xA;  motorDx.attach(10, 1000, 2000); &#xA;  motorSx.attach(11, 1000, 2000); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(micros()-tOld &amp;gt;= 50000)&#xA;  {&#xA;    tOld = micros();&#xA;    count += 1;&#xA;    if(count &amp;gt;= 20) // Runs @ 1 Hz&#xA;    {&#xA;      count = 0;&#xA;      serialRoutine();&#xA;      // prints number of ISR/sec&#xA;      Serial.println(contIsr)     &#xA;      contIsr=0;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;  //sendValuesToMotors();&#xA;  motorDX.write(90);&#xA;  contIsr++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="10794" LastEditDate="2015-07-30T22:36:21.597" LastActivityDate="2015-07-30T22:36:21.597" Title="Which Timer can I use to control a servo with Arduino Uno" Tags="|arduino-uno|servo|timers|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9766" PostTypeId="2" ParentId="9758" CreationDate="2015-04-01T15:58:21.383" Score="0" Body="&lt;p&gt;I'd have to be pretty quick to connect my serial monitor to see immediate terminal output from my program, if that output uses the same USB I used to load the program. You can test this by resetting the Arduino so it will repeat the output and see if you get a clear message this time. So I leave a couple of seconds' delay in the code to let the slow human catch up. Most of my devices announce their name and code-version on the serial I/O and flash a quick &quot;I'm here&quot; on the LED (if I chose to attach one) when they first wake up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char IdString[] = &quot;Hello.cpp: $Revision: 1.3 $&quot;;&#xA;&#xA;void setup(void)&#xA;{&#xA;   Serial.begin(57600);            // open serial port&#xA;&#xA;   // Identify to the terminal&#xA;   delay(2000);&#xA;   Serial.println(IdString);       // hello (terminal)&#xA;&#xA;   // Init LED pin&#xA;   pinMode(LED_PIN, OUTPUT);&#xA;   digitalWrite(LED_PIN, LOW);&#xA;&#xA;   nblink(4);                      // hello (LED)&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-01T15:58:21.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9767" PostTypeId="2" ParentId="9759" CreationDate="2015-04-01T16:12:26.607" Score="1" Body="&lt;p&gt;You have two serial connections. One for the main USB of the board and one for the XBee. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to read from the XBee and write to the serial USB?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what speed you have configured for your XBee so I have set it to 9600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This example reads from the XBee and writes to the Serial/USB port&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial xbee (2,3);&#xA;&#xA;int myData = 0;&#xA;int ledPin = 13;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    xbee.begin(9600);&#xA;&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (xbee.available())&#xA;    {&#xA;&#xA;         int myData = xbee.read();&#xA;&#xA;         Serial.print(&quot;Data has arrived on the Arduino&quot;);&#xA;         Serial.write(myData);&#xA;         Serial.println();&#xA;&#xA;         if(myData == '1')&#xA;         {&#xA;             digitalWrite(ledPin,HIGH);&#xA;             Serial.write(myData);&#xA;         }&#xA;         if(myData == '2')&#xA;         {&#xA;             digitalWrite(ledPin,LOW);&#xA;             Serial.write(myData);&#xA;         }&#xA;     }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: Your example also used &lt;code&gt;Serial.write()&lt;/code&gt; with the wrong argument &lt;code&gt;DEC&lt;/code&gt; which applies to &lt;code&gt;Serial.print()&lt;/code&gt;. X-CTU and Arduino both send ascii which is also what the &lt;code&gt;Serial.print()&lt;/code&gt; does. However the &lt;code&gt;Serial.read()&lt;/code&gt; just reads the byte so we need to use &lt;code&gt;Serial.write()&lt;/code&gt; to send the same bytes back to the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also make life a bit easier by replacing &lt;code&gt;xbee.available()&lt;/code&gt; with &lt;code&gt;Serial.available()&lt;/code&gt;. Then use the Arduino IDE serial monitor to both send and receive. This means that you just use the one USB connection to prove the code.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="6936" LastEditDate="2016-03-15T23:44:48.467" LastActivityDate="2016-03-15T23:44:48.467" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="9768" PostTypeId="2" ParentId="9752" CreationDate="2015-04-01T17:34:37.053" Score="0" Body="&lt;p&gt;The simplest way I can think of is something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastPress = 0;&#xA;unsigned long stateOneTime = 2000; //runs until two seconds elapse&#xA;unsigned long stateTwoTime = 4000; //runs after state one until 4 seconds from first press&#xA;...&#xA;if(/*input is active*/) lastPress = millis();&#xA;...&#xA;if(millis() - lastPress &amp;lt; stateOneTime){&#xA;    //set output for first state&#xA;    //active for 2 seconds&#xA;} else if (millis() - lastPress &amp;lt; stateTwoTime){&#xA;    //set output for second state&#xA;    //active an additional 2 seconds&#xA;} else {&#xA;    //set output to the &quot;off&quot; state&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Many improvments could be made, like going more of a state machine route (separating the time checks from the branches) or paramaterizing the state lengths better (durations would make more sense than total time from start, but be slightly more complicated to code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the key to making your life easier while working on this code will be separating the input segment from the output segment. It will help keep the code easy to read and modular.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-04-01T17:34:37.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9769" PostTypeId="2" ParentId="9702" CreationDate="2015-04-01T19:49:47.587" Score="0" Body="&lt;p&gt;The problem is that I need to import this code just a simple usual library.&lt;/p&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-04-01T19:49:47.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9770" PostTypeId="1" AcceptedAnswerId="9772" CreationDate="2015-04-01T19:53:03.707" Score="1" ViewCount="700" Body="&lt;p&gt;This question is a little related to this one: &lt;a href=&quot;https://arduino.stackexchange.com/questions/9702/how-to-compile-and-upload-the-specific-cpp-h-code&quot;&gt;How to compile and upload the specific (.cpp + .h) code?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed &lt;a href=&quot;https://github.com/justintconroy/MdbBillValidator&quot; rel=&quot;nofollow noreferrer&quot;&gt;MdbBillValidator&lt;/a&gt; to my arduino libraries collection. I tried both on ubuntu &amp;amp; windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I include it? Default inclusion, by arduino ide, was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MdbSerial.h&amp;gt;&#xA;#include &amp;lt;wiring_private.h&amp;gt;&#xA;#include &amp;lt;MdbBillValidator.h&amp;gt;&#xA;#include &amp;lt;MdbMaster.h&amp;gt;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is error comes in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_37()’:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:289:23: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR1B |= (1 &amp;lt;&amp;lt; TXB8);&#xA;                       ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:291:24: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR1B &amp;amp;= ~(1 &amp;lt;&amp;lt; TXB8);&#xA;                        ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_52()’:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:314:23: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR2B |= (1 &amp;lt;&amp;lt; TXB8);&#xA;                       ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:316:24: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR2B &amp;amp;= ~(1 &amp;lt;&amp;lt; TXB8);&#xA;                        ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: In function ‘void __vector_55()’:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:339:23: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR3B |= (1 &amp;lt;&amp;lt; TXB8);&#xA;                       ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:341:24: error: ‘TXB8’ was not declared in this scope&#xA;       UCSR3B &amp;amp;= ~(1 &amp;lt;&amp;lt; TXB8);&#xA;                        ^&#xA;In file included from /usr/lib/avr/include/avr/iom2560.h:38:0,&#xA;                 from /usr/lib/avr/include/avr/io.h:160,&#xA;                 from /usr/lib/avr/include/avr/pgmspace.h:88,&#xA;                 from /home/asiniy/sketchbook/libraries/MdbBillValidator/Arduino.h:8,&#xA;                 from /home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:31:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp: At global scope:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:135: error: expected ‘)’ before numeric constant&#xA;   MdbSerial MdbPort1(&amp;amp;rx_buffer1, &amp;amp;tx_buffer1, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1A, &amp;amp;UCSR1B, &amp;amp;UCSR1C, &amp;amp;UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1 UCSZ12, UCSZ11, UCSZ10, UPM11, UPM10, UMSEL11, UMSEL10);&#xA;                                                                                                                                       ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:189: error: no matching function for call to ‘MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, int, int, int, int, int, int, int, int, int, int, int)’&#xA;   MdbSerial MdbPort1(&amp;amp;rx_buffer1, &amp;amp;tx_buffer1, &amp;amp;UBRR1H, &amp;amp;UBRR1L, &amp;amp;UCSR1A, &amp;amp;UCSR1B, &amp;amp;UCSR1C, &amp;amp;UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1 UCSZ12, UCSZ11, UCSZ10, UPM11, UPM10, UMSEL11, UMSEL10);&#xA;                                                                                                                                                                                             ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:554:189: note: candidates are:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:352:1: note: MdbSerial::MdbSerial(ring_buffer*, ring_buffer*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)&#xA; MdbSerial::MdbSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,&#xA; ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:352:1: note:   candidate expects 20 arguments, 19 provided&#xA;In file included from /home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.cpp:38:0:&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.h:52:7: note: MdbSerial::MdbSerial(const MdbSerial&amp;amp;)&#xA; class MdbSerial&#xA;       ^&#xA;/home/asiniy/sketchbook/libraries/MdbBillValidator/MdbSerial.h:52:7: note:   candidate expects 1 argument, 19 provided&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I need to do to avoid this error and get the code worked?&lt;/p&gt;&#xA;" OwnerUserId="7852" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-01T20:04:54.533" Title="mega include a library" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9772" PostTypeId="2" ParentId="9770" CreationDate="2015-04-01T20:04:54.533" Score="1" Body="&lt;p&gt;Could you try adding this to your program?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RXB8 1&#xA;#define TXB8 0&#xA;#define UPE 2&#xA;#define OVR 3&#xA;#define FE 4&#xA;#define UDRE 5&#xA;#define RXC 7&#xA;&#xA;#define FRAMING_ERROR (1&amp;lt;&amp;lt;FE)&#xA;#define PARITY_ERROR (1&amp;lt;&amp;lt;UPE)&#xA;#define DATA_OVERRUN (1&amp;lt;&amp;lt;OVR)&#xA;#define DATA_REGISTER_EMPTY (1&amp;lt;&amp;lt;UDRE)&#xA;#define RX_COMPLETE (1&amp;lt;&amp;lt;RXC)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found someone with similar code, who had these defines and as your code seems to miss/cannot find something, this might fix it.&#xA;Though I'm not sure if these defines apply in your specific implementation. For that I should have to see the code where the error is pointing at.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-01T20:04:54.533" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9773" PostTypeId="1" AcceptedAnswerId="9774" CreationDate="2015-04-02T00:46:42.053" Score="3" ViewCount="3606" Body="&lt;p&gt;So recently I have been looking into prototyping my arduino project and there are a lot of tutorials online on how to take your Arduino and using a software such as Eagle to make a PCB layout but I was wondering how you would get the Arduino program onto that PCB. Surely in large scale circuit manufacturing they wouldn't have a usb attached so that they upload a program into each and every one of their circuits?&lt;/p&gt;&#xA;" OwnerUserId="8313" OwnerDisplayName="Brandan B" LastEditorUserId="6452" LastEditDate="2015-04-03T18:21:58.703" LastActivityDate="2015-04-03T18:21:58.703" Title="How are PCB's programmed?" Tags="|prototype|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9774" PostTypeId="2" ParentId="9773" CreationDate="2015-04-02T00:58:19.887" Score="5" Body="&lt;p&gt;why not? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well ok ... they might not connect a USB to each one as there are faster ways - flyingProbe/PogoPins on a &quot;bed of nails&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/In-circuit_test&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://en.wikipedia.org/wiki/In-circuit_test&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QV9BI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This type of temporary connection speeds up testing &amp;amp; pre-programming considerably. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each card that is made has to go through some form of test process at the end (flying probe or manual). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/electronics-assembly&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/electronics-assembly&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On boards that require programming or calibration, additional steps&#xA;  are taken to load code and verify the output.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="25735" OwnerDisplayName="JonRB" LastActivityDate="2015-04-02T00:58:19.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9775" PostTypeId="2" ParentId="9773" CreationDate="2015-04-02T00:59:27.987" Score="2" Body="&lt;p&gt;For commercial products where very large quantities are produced, a microcontroller will be &quot;mask programmed&quot; - the (well-debugged) program will be built into the microcontroller as part of the IC production process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For smaller quantities, the microcontroller may be programmed in a special fixture before being installed on the PC board.  Also, most current microcontrollers have &quot;In System Programming (ISP)&quot; capability, which typically requires a 6 - 10 pin connector on the board, and a special programmer to plug into that board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it is highly unlikely that an Arduino-based program would be used in any commercial product.&lt;/p&gt;&#xA;" OwnerUserId="1498" OwnerDisplayName="Peter Bennett" LastActivityDate="2015-04-02T00:59:27.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9776" PostTypeId="2" ParentId="9773" CreationDate="2015-04-02T01:00:31.980" Score="2" Body="&lt;p&gt;Actually, they generally do load a program into each and every one of their devices individually.  They can do a lot more than that as well.  Ever heard of something called JTAG?  For large circuit boards, most of the large ICs are connected to a JTAG scan chain.  Once the board is assembled, they connect a JTAG cable to the scan chain.  Special test software controls the scan chain through the JTAG cable, possibly connected to the control computer via USB.  The software can take control over the I/O pins on the ICs on the scan chain and set test patterns to check for opens or shorts.  It can also perform more complex testing in concert with external test equipment, even including temporarily loading special diagnostic firmware.  Once the test passes, the computer can then initialize ROMs, load firmware, set serial numbers, etc.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is done one board at a time.  Often, special test and/or programming jigs are built that allow boards to be connected and disconnected quickly, and usually multiple jigs are used in parallel for higher throughput.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some chips, they can be programmed before installation either with mask ROM or with a standalone programmer.  This is done when volumes are large and testing is not required, or if the devices must be programmed for the automated testing to work correctly.  &lt;/p&gt;&#xA;" OwnerUserId="3832" OwnerDisplayName="alex.forencich" LastActivityDate="2015-04-02T01:06:51.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9777" PostTypeId="2" ParentId="9701" CreationDate="2015-04-02T03:14:43.463" Score="2" Body="&lt;p&gt;Your issue is probably this code (and similar) in the Android MainActivity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = Integer.toString(u);&#xA;Bluetooth.connectedThread.write(x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remember that you are sending &lt;em&gt;bytes&lt;/em&gt;, not &lt;a href=&quot;http://www.asciitable.com/&quot; rel=&quot;nofollow&quot;&gt;ascii representations&lt;/a&gt; of them.  For example, if the variable 'u' is 9, you would be sending the value 57.  The larger problem is that if 'u' is 10 or higher, you are sending more than one byte, and the code below...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case 'A':&#xA;    nhan=Serial.read();&#xA;    //digitalWrite(8,LOW);&#xA;    break; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...only reads one byte of the number.  A better way to approach this is to always send your data in a packet - start each packet with a control or attention byte (255 is a good one), a command for your select, and as many bytes as you need for the data.  Then &lt;em&gt;always&lt;/em&gt; send and read a complete packet.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Arduino code:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Defines make your code more readable.&#xA;#define PACKET_SIZE 3&#xA;#define CONTROL_BYTE 255&#xA;#define WHATEVER_A_MEANS 65&#xA;#define WHATEVER_B_MEANS 66&#xA;&#xA;//...&#xA;&#xA;void loop()&#xA;{&#xA;    byte buffer[PACKET_SIZE];&#xA;&#xA;    if (Serial.available() &amp;gt;= PACKET_SIZE)&#xA;    {&#xA;        // Read the first byte&#xA;        buffer[0] = Serial.read();&#xA;        // If it's really the start byte (255) ...&#xA;        if (buffer[0] == CONTROL_BYTE)&#xA;        {&#xA;            // ... then get the next two bytes&#xA;            for (i = 1; i &amp;lt; PACKET_SIZE; i++) buffer[i] = Serial.read();&#xA;        }&#xA;        else&#xA;        {&#xA;            //Otherwise it isn't a good packet.&#xA;            return;&#xA;        }&#xA;&#xA;        switch (buffer[1])&#xA;        {&#xA;            case WHATEVER_A_MEANS:&#xA;                nhan = buffer[2];&#xA;                break;&#xA;            case WHATEVER_B_MEANS:&#xA;                nhan1 = buffer[2];&#xA;                    break;&#xA;            //etc.&#xA;        }&#xA;&#xA;        //...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Android code:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Class level scope. Note that these don't have to be 'letters' unless you  &#xA;//need them to be for some other reason.&#xA;public static final byte CONTROL_BYTE = (byte)255;&#xA;public static final byte WHATEVER_A_MEANS = (byte)65;&#xA;public static final byte WHATEVER_B_MEANS = (byte)66;&#xA;&#xA;//...&#xA;public void doTimerTask() {&#xA;    mTimerTask = new TimerTask() {&#xA;        public void run() {&#xA;            thandler.post(new Runnable() {&#xA;                public void run() {&#xA;                    Bluetooth.connectedThread.write(CONTROL_BYTE);&#xA;                    Bluetooth.connectedThread.write(WHATEVER_A_MEANS);&#xA;                    //Note that this is a narrowing cast of u.&#xA;                    Bluetooth.connectedThread.write((byte)u);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If 'u' needs to hold values bigger than 8 bits (you have it declared as an int), you'll need to split it into bytes and then recombine them in the Arduino code.&lt;/p&gt;&#xA;" OwnerUserId="8216" LastActivityDate="2015-04-02T03:14:43.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9778" PostTypeId="1" CreationDate="2015-04-02T06:19:55.323" Score="1" ViewCount="7109" Body="&lt;p&gt;I have to use a camera to take picture in my major project. I want to use &lt;a href=&quot;https://i.stack.imgur.com/42CDx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; camera, which has AV output. Please tell me how to interface this camera with my Arduino Uno and use the data from camera and send it to my PC using a Wi-fi Module?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. Please do not suggest me to use wireless camera because firstly they are expensive and secondly I require a board in my project anyway.&lt;/p&gt;&#xA;" OwnerUserId="8218" LastEditorUserId="6452" LastEditDate="2015-04-02T10:08:53.707" LastActivityDate="2015-05-02T10:55:46.230" Title="Interfacing a CCTV camera (AV output) with Arduino Uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9780" PostTypeId="2" ParentId="9701" CreationDate="2015-04-02T06:41:06.147" Score="0" Body="&lt;p&gt;As Cominterm said, you are doing a lot of mistakes. I would use start and end bytes like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HEX       ASCII&#xA;&#xA;31 3B  |  &quot;1;&quot; -start of the message &#xA;&#xA;3F 30  |  &quot;?0&quot; - end of message&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in arduino check for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a tip, if you read bytes i would get rid of those 'A', 'S' and so on. These are ascii codes. You can easily do a mistake and this will be pain in the ass. Send byte &lt;code&gt;10&lt;/code&gt; from Android and read as byte &lt;code&gt;138&lt;/code&gt; in Arduino, because in Java byte is &lt;code&gt;-127 : 128&lt;/code&gt; and Arduino &lt;code&gt;0 : 255&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would do in hex representation, this helps in troubleshooting. For ex.: byte &lt;code&gt;1C&lt;/code&gt; hex in Android is &lt;code&gt;1C&lt;/code&gt; hex in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also get rid of those byte to string, int to string conversations. They add more points to mistake :) Also check if string is terminated with &lt;code&gt;\0&lt;/code&gt; and it will be 2 bytes instead of 1.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-04-02T06:41:06.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9781" PostTypeId="2" ParentId="9773" CreationDate="2015-04-02T06:51:24.163" Score="0" Body="&lt;p&gt;cheers Brandan :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest for you to make your own programmer. Then you will know a lot about programming and so on. If you want to program a chip on pcb, you have to have output pins of ISP. Throw these pins you will pump your code to Atmega chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software &lt;a href=&quot;http://khazama.com/project/programmer/&quot; rel=&quot;nofollow&quot;&gt;Khazama&lt;/a&gt; is &quot;old&quot; and tested one. It really works :) &lt;a href=&quot;http://www.atmel.com/microsite/atmel_studio6/&quot; rel=&quot;nofollow&quot;&gt;AVR studio&lt;/a&gt; is also good one&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware &lt;a href=&quot;http://www.fischl.de/usbasp/&quot; rel=&quot;nofollow&quot;&gt;USBasp&lt;/a&gt; There are ready pcb layouts in eagle. Building your own HW will be a bit more expensive than buying one, but if we count in experience it will be priceless :)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you can use bootloader. Check in google there are plenty of tutorials.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-04-02T06:51:24.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9782" PostTypeId="2" ParentId="9663" CreationDate="2015-04-02T07:01:01.740" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I should be able to set and use the HID profile (from the default SPP)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, your assumption is incorrect. From the same documentation you quoted, the previous sentence says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To use Roving Networks’ Bluetooth HID profile, you must use a special&#xA;  build of firmware, version 6.03 or later.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Poorly phrased, this does mean that you need to have two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A &lt;strong&gt;special HID&lt;/strong&gt; firmware &lt;/li&gt;&#xA;&lt;li&gt;Version 6.03 or later&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your BlueSmirf Silver only complies with the second condition; it does not have the special HID firmware (also note that the Rovnix command reference does not address a specific variant of the BlueSmirf, but speaks generally about all of the variants).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;SPP protocol&lt;/strong&gt; (Serial Port Profile) is used for emulating a serial cable, and functions as a substitute for the physical RS-232 connection, &lt;strong&gt;but cannot stack pure HID profile on top of it&lt;/strong&gt;. In order for you do talk HID, you will need the HID firmware. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, the HID version comes with SPP and you can switch between the two modes interchangeably, I have been using the HID version for a while now and it works fine (including the pairing with iOS). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another misfortune is that it does not appear that &lt;em&gt;Roving Networks&lt;/em&gt; officially support any re-flashing of the BlueSmirf firmware, so unless you are willing to reverse the hardware, this is off the table as well.&lt;/p&gt;&#xA;" OwnerUserId="630" LastEditorUserId="630" LastEditDate="2015-04-02T07:06:16.243" LastActivityDate="2015-04-02T07:06:16.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9783" PostTypeId="1" AcceptedAnswerId="9785" CreationDate="2015-04-02T09:35:32.137" Score="3" ViewCount="2647" Body="&lt;p&gt;&lt;sup&gt;I am a hobbyist &amp;amp; know little about electronics.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am making a robot arm, like &lt;a href=&quot;http://www.lynxmotion.com/c-124-al5a.aspx&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. For which I will need 2 stepper motors (for elbow &amp;amp; shoulder joint) &amp;amp; 4 simple DC motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means I will need to allocate a lot of pins on my board (Uno).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was just reading about I2C &amp;amp; then eventually SPI. My question is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to control 6 motors (or atleast 2 steppers) with I2C or SPI (assuming the motors are powered by seperate source), if so can you point me to someone's example code.&lt;/li&gt;&#xA;&lt;li&gt;If not possible, how do I overcome the shortage of pins, because I have already dedicated them to many sensors.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8219" LastActivityDate="2015-04-02T10:37:01.000" Title="I2C or SPI to control 6 motors?" Tags="|pins|motor|i2c|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9784" PostTypeId="2" ParentId="9778" CreationDate="2015-04-02T10:22:05.897" Score="2" Body="&lt;p&gt;Unfortunately, I have to tell you that a UNO isn't enough powerful to work with any type of camera: it hasn't got enough ram and processing power to elaborate your camera's data. (&lt;a href=&quot;http://www.atmel.com/devices/atmega328.aspx&quot; rel=&quot;nofollow&quot;&gt;see atmega328P's specs&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure you can work with that camera, unless it is digital and has integrated RAM to keep the frames.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good project which I suggest you to see is &lt;a href=&quot;http://www.arducam.com/&quot; rel=&quot;nofollow&quot;&gt;arducam&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4887" LastActivityDate="2015-04-02T10:22:05.897" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9785" PostTypeId="2" ParentId="9783" CreationDate="2015-04-02T10:37:01.000" Score="2" Body="&lt;p&gt;For the stepper motors, the easiest way to work with them is by using a very common &lt;a href=&quot;https://www.pololu.com/product/1182&quot; rel=&quot;nofollow noreferrer&quot;&gt;A4988 board&lt;/a&gt; which is widely used with 3D printers. The controls are very easy and for them I send you &lt;a href=&quot;https://arduino.stackexchange.com/questions/8965/stepper-motor-controller-using-leonardo-pro-micro/8977#8977&quot;&gt;this question&lt;/a&gt; which I answered some time ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, you say that you haven't got a lot of connections left on your UNO board, so I think that SPI would't be very useful, as it takes 3 pins for the data transmission (SCLK, MOSI, MISO) plus one pin for every device you connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way (even if it is a little slower that SPI) is to use I2C, which needs that you leave unused analog input pins A4 and A5, as they are the I2C BUS. Unfortunately I haven't any knowledge about I2C DC motor drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the steppers, I suggest to take a look at &lt;a href=&quot;http://www.ebay.co.uk/itm/Serial-I2C-Microstepping-Motor-Driver-DC-PWM-CNC-Raspberry-Pi-Aduino-1-2A-/111177026930&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, but it depends by your budget for what you can buy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could fix the pin shortage problem by adding some &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC595&lt;/a&gt; shift registers. They aren't very expensive (less than a dollar, or if you live in europe, .5€) and they can be daisy-chained. To control them, see the &lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftOut&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino website tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if the pins that you use are inputs, use a &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT165.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC165&lt;/a&gt;, which is the opposite of a 595. As always, see the &lt;a href=&quot;http://arduino.cc/en/tutorial/ShiftIn&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino website tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4887" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-04-02T10:37:01.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9786" PostTypeId="2" ParentId="9740" CreationDate="2015-04-02T11:22:25.153" Score="0" Body="&lt;p&gt;It works!&lt;/p&gt;&#xA;&lt;p&gt;First I'll say thanks to the moderators/support staff from Adafruit. One dude in particular has tried to help me constantly for the past couple of days or so.&lt;/p&gt;&#xA;&lt;p&gt;So, following on from my edit, Adafruit told me that the ICSP pins are connected to the control part of the board via the main pins. I should have seen it actually, but I obviously didn't examine and understand it properly. This means that although I severed the connection between the main pins and the centre, the ICSP and 11,12,13 were still connected together. What I actually needed was for the ICSP pins to be connected to the controls to receive the data, and the main pins to be detached from them. So I de-soldered the solder jumpers that I had originally put on the connector plates on the underside of the board (which connect the ISCPs to the main pins), then soldered wire from the ICSP side to the associated breakout holes which are the ones on the inside of the cuts that I made on the board. Here is a picture:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HQFUw.jpg&quot; alt=&quot;New wiring on board&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;If anyone tries to do this, beware of where you are wiring to! I was very careful to make sure I matched the connecting wires to the correct pins. I have tested it several times (using the example test file that comes with the library) and it works as it should. It works on my Uno R3 and my Mega 2560 R3, which is great, as now pins 11-13 are free to use for my motor shield, or potentially any other shield which may need those pins.&lt;/p&gt;&#xA;&lt;p&gt;I hope this helps someone else in the future. There doesn't seem to be any information on this particular combination of shields, but as these projects are becoming more popular this may prove to be useful.&lt;/p&gt;&#xA;" OwnerUserId="454" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-02T11:22:25.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9787" PostTypeId="1" CreationDate="2015-04-02T12:43:29.307" Score="0" ViewCount="83" Body="&lt;p&gt;I want to control a servo with the least amount of components. But generally, what is the simplest way to do this without actually using a fullblown arduino board?&lt;/p&gt;&#xA;" OwnerUserId="310" LastActivityDate="2015-04-02T15:16:59.927" Title="What's the simplest way to get arduino functionality?" Tags="|atmega328|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9788" PostTypeId="2" ParentId="9787" CreationDate="2015-04-02T12:51:32.473" Score="2" Body="&lt;p&gt;If you what you're looking for is the cheapest option with the fewer components possible, then you can use a regular ATMega328p chip, with a few passive components attached to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need to program it with an Arduino Bootloader once, in order to be able to program it easily, but you can use any existing Arduino to do that. After doing this once, you can program it with any FTDI-type USB to Serial converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an Instructable that &lt;a href=&quot;http://www.instructables.com/id/Program-an-ATmega168328-with-codebender/&quot; rel=&quot;nofollow&quot;&gt;explains the whole process&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8222" LastActivityDate="2015-04-02T12:51:32.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9789" PostTypeId="2" ParentId="9787" CreationDate="2015-04-02T13:22:56.983" Score="0" Body="&lt;p&gt;Please, take a look at &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow&quot;&gt;this guide&lt;/a&gt; by Nick Gammon, which explains in detail how to build a breadboard Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need also an Arduino board without the chip (a good UNO will do the job) because you need to program it some way. It is needed absolutely in the case that you buy an ATMEGA328 that hasn't the bootloader, as you'll have to write it on the blank chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To speak directly via serial with the standalone Arduino (and to program it), I suggest you to buy a FT232RL board (just be careful to buy a real one, as there are fakes that FTDI blocked and bricked with drivers)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, for the servo you just have to plug it correctly: two cables for power, one for the control.&lt;/p&gt;&#xA;" OwnerUserId="4887" LastActivityDate="2015-04-02T13:22:56.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9791" PostTypeId="2" ParentId="9787" CreationDate="2015-04-02T15:16:59.927" Score="0" Body="&lt;p&gt;This is useful if you don't need all the I/O of the Atmega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a simple board just to run a servo or two and still have some I/O you could use a ATTiny85 chip and use this &lt;a href=&quot;http://projectsfromtech.blogspot.com/2013/03/attiny85-servo-softwareservo-library.html&quot; rel=&quot;nofollow&quot;&gt;software servo library&lt;/a&gt; that works with the attiny. It also works best with the High-Low tech cores.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used this with a project and it works flawlessly without stalling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would give you small setup as you can use the internal clock 8MHz and minimal external components, i.e. regulator and Capacitors. &lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-04-02T15:16:59.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9794" PostTypeId="1" AcceptedAnswerId="9802" CreationDate="2015-04-02T17:08:52.393" Score="1" ViewCount="109" Body="&lt;p&gt;I want to make a device with a sensor I can attach to the places my dog likes to mark. When sensor becomes wet I want a buzzer to make a loud noise to scare the animal and notify me I need to encourage the dog to go outside. Any suggestions on what sensor to use.&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-06-13T06:43:11.117" Title="Don't pee there! Device" Tags="|arduino-uno|sensors|hardware|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9795" PostTypeId="1" AcceptedAnswerId="9796" CreationDate="2015-04-02T17:25:54.787" Score="0" ViewCount="266" Body="&lt;p&gt;I'm using a dual h bridge to control two dc motors on an inverted pendulum (cart-pole system).  At the moment, I have to send two different pulse width modulated signals to the two enable pins to control the two motor speeds and four digital write commands to control the directions.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, I want to switch the two motors simultaneously in the same direction and with the same speed.  So, I'd like to be able to control both motors' speeds with only one pulse width modulation signal and control both motor directions with only two digital write commands.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can do with with Arduino?  Can one PWM signal from a single arduino pin be sent to two enable pins at the same time? Can the same be done for a single digital output pin?  If so, how can I accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="667" LastActivityDate="2015-04-02T17:48:03.847" Title="Switching a dual h bridge in parallel" Tags="|arduino-uno|motor|pwm|digital|h-bridge|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9796" PostTypeId="2" ParentId="9795" CreationDate="2015-04-02T17:48:03.847" Score="2" Body="&lt;p&gt;You can connect a single output to as many input loads as you like, provided the current is sufficient to hold the output voltage within the input thresholds. See the datasheet for the H bridge to find out what the input load and thresholds are, and compare them with the output from the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-02T17:48:03.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9798" PostTypeId="1" AcceptedAnswerId="9800" CreationDate="2015-04-02T18:04:42.423" Score="0" ViewCount="316" Body="&lt;p&gt;I'm making a project and I'm using multiple 1 digit 7 segment displays. I haven't plugged them all on my arduino because currently I'm just testing. The problem is on the I/O ports. Obviously I need to use shift registers and since it's my first time ever using them I need to know more about them. After googling, I found that the specific model I bought outputs 8 pins and you can stack up to 8 in series. So lets do the math. &lt;code&gt;8 shift register&lt;/code&gt; x &lt;code&gt;8 pins each SR&lt;/code&gt; = &lt;code&gt;64 new pins&lt;/code&gt; It seems cool but assuming I'm using 28 displays let's do the math again.&#xA;28 displays, each display has 8 pins (8 for segments and 2 as common cathode)&#xA;&lt;code&gt;28&lt;/code&gt; x &lt;code&gt;8&lt;/code&gt; = &lt;code&gt;224&lt;/code&gt; required pins.&#xA;Is is possible to expand the I/O pins by 224 pins? How many shift registers can I stack together? Also which is better, the single digit display or the 4 digit display?&lt;/p&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="4594" LastEditDate="2015-04-02T19:53:33.493" LastActivityDate="2015-06-27T22:44:12.397" Title="Shift registers. What, how and why?" Tags="|arduino-uno|pins|communication|display|shift-register|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9799" PostTypeId="1" CreationDate="2015-04-02T19:10:43.840" Score="2" ViewCount="226" Body="&lt;p&gt;I've currently got a setup where I am using a 2 thermocouple setup using MAX31850 and the circuit looks exactly as mentioned here using the external power option. (&lt;a href=&quot;https://learn.adafruit.com/adafruit-1-wire-thermocouple-amplifier-max31850k/wiring-and-test&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-1-wire-thermocouple-amplifier-max31850k/wiring-and-test&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I take the data that is returned from this over serial and pass it over to a simple inverter circuit, which inverts the signal and fluctuates the voltage of a small CREE LED.&#xA;The problem that I am encountering is that the data being received from the thermocouples is incorrect when the LED is attached to the setup. And it becomes correct as soon as the LED is detached.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have tried running my thermocouple set up over an external 5V&#xA;supply and using common ground with the Arduino, but it still does&#xA;not help.&lt;/li&gt;&#xA;&lt;li&gt;I have tried using decoupling capacitors on the power rails&#xA;to remove any noise due to the LED, but again to no help. What else&#xA;can I try to ensure that I can read the data and modulate the LED&#xA;simultaneously?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7865" LastActivityDate="2015-04-02T19:10:43.840" Title="Arduino based temperature sensing circuit" Tags="|serial|led|voltage-level|communication|temperature-sensor|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9800" PostTypeId="2" ParentId="9798" CreationDate="2015-04-02T19:22:53.517" Score="4" Body="&lt;p&gt;You can chain as many shift registers as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most commonly, these displays are multiplexed. Only one digit is lit at a time, cycling though all the digits fast enough, so the eye can't tell. This is however not very good practice for 28 digits, as the brightness will become 1/28th (though you could create groups of digits, and multiplex those groups separately).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are specialized chips that do this multiplexing for you. E.g. the Max7219. This chip can multiplex 8 digits, with 8 segments. So you'd need 4 of these to light up 28 digits.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="4594" LastEditDate="2015-04-12T15:06:25.020" LastActivityDate="2015-04-12T15:06:25.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9801" PostTypeId="1" AcceptedAnswerId="9807" CreationDate="2015-04-02T19:28:51.790" Score="0" ViewCount="442" Body="&lt;p&gt;I recently purchased a pcDuino 3B and I am very pleased with the Board so far. I can use the preinstalled arduino IDE to program the board from the board and run programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I came to use I2C, it generated a load of errors with the built-in libraries when I tried to compile. I don't know why it did this, it does it when trying to compile any program using I2C. Here is the error list (Yes, I am using an Adafruit display library that works fine with exactly the same sketch on my laptop):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from /usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Stream.h:26:0,&#xA;                 from /usr/share/arduino/hardware/arduino/pcduino/libraries/Wire/Wire.h:9,&#xA;                 from Stopwatch_new.ino:1:&#xA;/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Print.h:47:23: error: ‘byte’ has not been declared&#xA;In file included from Stopwatch_new.ino:1:0:&#xA;/usr/share/arduino/hardware/arduino/pcduino/libraries/Wire/Wire.h:41:23: error: ‘byte’ has not been declared&#xA;Stopwatch_new.ino:5:51: error: cannot allocate an object of abstract type ‘Adafruit_RGBLCDShield’&#xA;/home/ubuntu/Arduino/libraries/AdafruitLCD/Adafruit_RGBLCDShield.h:68:7: note:   because the following virtual functions are pure within ‘Adafruit_RGBLCDShield’:&#xA;/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Print.h:47:17: note:  virtual int Print::write(int)&#xA;Stopwatch_new.ino:5:23: error: cannot declare variable ‘lcd’ to be of abstract type ‘Adafruit_RGBLCDShield’&#xA;/home/ubuntu/Arduino/libraries/AdafruitLCD/Adafruit_RGBLCDShield.h:68:7: note:   since type ‘Adafruit_RGBLCDShield’ has pure virtual functions&#xA;Stopwatch_new.ino: In function ‘void updateScreen()’:&#xA;Stopwatch_new.ino:125:27: error: call of overloaded ‘String(float&amp;amp;, int)’ is ambiguous&#xA;Stopwatch_new.ino:125:27: note: candidates are:&#xA;/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:44:14: note: String::String(unsigned int, unsigned char)&#xA;/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:43:14: note: String::String(int, unsigned char)&#xA;/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:42:14: note: String::String(unsigned char, unsigned char)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that no one else is having this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to clarify, the issue is not with my code or the library, it compiles fine on my other computer running WINDOWS but same Arduino version (1.5.3), same sketch code and same library code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help much appreciated, thanks!&lt;/p&gt;&#xA;" OwnerUserId="4594" LastEditorUserId="10794" LastEditDate="2015-08-01T00:04:32.633" LastActivityDate="2015-09-30T05:26:05.557" Title="pcDuino 3B Wire library errors" Tags="|i2c|library|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9802" PostTypeId="2" ParentId="9794" CreationDate="2015-04-02T19:39:27.150" Score="2" Body="&lt;p&gt;You probably will want a moisture sensor like &lt;a href=&quot;http://www.ebay.co.uk/itm/like/370999421770?limghlpsr=true&amp;amp;hlpv=2&amp;amp;ops=true&amp;amp;viphx=1&amp;amp;hlpht=true&amp;amp;lpid=108&amp;amp;chn=ps&amp;amp;device=c&amp;amp;adtype=pla&amp;amp;crdt=0&amp;amp;ff3=1&amp;amp;ff11=ICEP3.0.0-L&amp;amp;ff12=67&amp;amp;ff13=80&amp;amp;ff14=108&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; (there are many variations of this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will return one signal when dry, and another when wet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need a Buzzer to make a sound as well (Or a piezo speaker if you feel like getting more advanced) in order to make a sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your sketch should have, in its &lt;code&gt;loop&lt;/code&gt;, an &lt;code&gt;if&lt;/code&gt; statement checking if the moisture sensor has returned the wet signal (The signal will depend on the sensor you get) and, in the block that executes if there is a signal, a statement driving the buzzer and a delay before turning it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind that you want to keep the Arduino itself away from the moisture sensor, as your Arduino probably won't survive the dog's doings.&lt;/p&gt;&#xA;" OwnerUserId="4594" LastEditorUserId="4594" LastEditDate="2015-06-13T06:43:11.117" LastActivityDate="2015-06-13T06:43:11.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9804" PostTypeId="1" CreationDate="2015-04-02T20:10:17.137" Score="0" ViewCount="1940" Body="&lt;p&gt;i am doing a Ultimate GPS module like this:&lt;img src=&quot;https://i.stack.imgur.com/r87dZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it works when i use arduino UNO board, but when I use arduino micro board it doesn't work, so could anyone tell me how to fix it?.By the way I use the example code in GPS library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UNO: the data looks like messy code&#xA;&lt;img src=&quot;https://i.stack.imgur.com/lXlrk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Micro: didn't give me any time, date or fix&#xA;&lt;img src=&quot;https://i.stack.imgur.com/U2Xw6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8117" LastEditorUserId="8117" LastEditDate="2015-04-02T22:51:09.863" LastActivityDate="2015-04-02T23:25:17.990" Title="Can Ultimate GPS module use arduino micro instead of UNO?" Tags="|arduino-uno|arduino-micro|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9805" PostTypeId="2" ParentId="9804" CreationDate="2015-04-02T20:17:30.470" Score="0" Body="&lt;p&gt;The Arduino Uno and Micro, in practice, work almost exactly the same. Just make sure that your wiring is correct (In this photo, the wires go from TX to TX and RX to RX, they should go between TX on one board and RX on the other, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code should work on a micro exactly as it does on an Uno. That is one of the best features of Arduino; the ability to port code to another board without much (if any) modification.&lt;/p&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2015-04-02T20:17:30.470" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9806" PostTypeId="1" CreationDate="2015-04-02T20:29:10.927" Score="2" ViewCount="539" Body="&lt;p&gt;As arduino.org states, the bootloader is pre-burnt by Atmel at the factory. I'd like to know if it will be possible for us to buy &quot;raw&quot; ICs and burn them at home for our own boards, as we do with the Atmega328 for example.&lt;/p&gt;&#xA;" OwnerUserId="7734" LastActivityDate="2015-04-02T20:29:10.927" Title="Will we be able to burn arduino zero pro's bootloader?" Tags="|bootloader|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9807" PostTypeId="2" ParentId="9801" CreationDate="2015-04-02T20:34:11.023" Score="1" Body="&lt;p&gt;It turns out that the libraries for compiling were incomplete. Having copied the libraries for the official IDE, it worked fine.&lt;/p&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2015-04-02T20:34:11.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9808" PostTypeId="2" ParentId="61" CreationDate="2015-04-02T20:41:16.367" Score="8" Body="&lt;p&gt;Virtualbreadboard has a new VBB4Arduino 'Two Arduino's' edition which includes BOTH a JVM Arduino emulator AND a AVR Instruction set simulator with examples that cover almost all of the Arduino distribution examples and a bunch of peripheral hardware - LCD's, WS2812 Neo LEDS, Motors, Servo's, Logic Analyser and more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.virtualbreadboard.com&quot;&gt;http://www.virtualbreadboard.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I am the author of Virtual Breadboard&lt;/p&gt;&#xA;" OwnerUserId="8230" LastEditorUserId="6452" LastEditDate="2015-04-03T18:21:34.320" LastActivityDate="2015-04-03T18:21:34.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9810" PostTypeId="1" CreationDate="2015-04-02T22:31:56.470" Score="1" ViewCount="321" Body="&lt;p&gt;So this might be a total noob question (which admittedly I am) I have a Motor, if I connect it to GND and the 5V output it runs. Ok so far. But if I connect it to GND and a pin set to OUTPUT and HIGH nothing happens. My multimeter reads 5V for both setups, so if 5V come to the motor one way or the other why does one work and one not? &lt;/p&gt;&#xA;" OwnerUserId="8233" LastActivityDate="2015-04-03T12:28:11.987" Title="difference between output pin high and 5v pin" Tags="|motor|voltage-level|electricity|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9811" PostTypeId="1" AcceptedAnswerId="9818" CreationDate="2015-04-02T23:13:04.363" Score="1" ViewCount="1128" Body="&lt;p&gt;I have a LED Matrix just like this one&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/S4JeL.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but couldn't find the data sheet for it (1855AS)&#xA;I asked around in my country and one guy told me to try attaching one side to 5v and the other to GND. Some LEDs worked fine and others didn't light up at all. In the end one if not more got burned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm here asking if anyone can tell me a way to figure out how it works.&#xA;I would appreciate the help!&lt;/p&gt;&#xA;" OwnerUserId="7612" LastActivityDate="2015-04-03T06:42:31.790" Title="How to use an 8x8 LED Matrix?" Tags="|arduino-uno|led|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9812" PostTypeId="2" ParentId="9804" CreationDate="2015-04-02T23:25:17.990" Score="1" Body="&lt;p&gt;Your photo shows the GPS connected to pins 0 and 1 (RX and TX) on the UNO.  But you don't show the sketch you are running.  Do you have it set that way in the sketch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out the micro and UNO are different in the way those pins work.  From &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/arduinoBoardMicro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Serial: 0 (RX) and 1 (TX).  Used to receive (RX) and transmit (TX) TTL&#xA;  serial data using the ATmega32U4 hardware serial capability. Note that&#xA;  on the Micro, the Serial class refers to USB (CDC) communication; for&#xA;  TTL serial on pins 0 and 1, use the Serial1 class.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This suggests to me that you'd need to change the code to read pins 0 and 1.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Easier is probably to wire it up to pins 2 and 3 and use the defaults in the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// If using software serial, keep this line enabled&#xA;// (you can change the pin numbers to match your wiring):&#xA;SoftwareSerial mySerial(3, 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2015-04-02T23:25:17.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9813" PostTypeId="1" CreationDate="2015-04-03T01:48:51.593" Score="0" ViewCount="1290" Body="&lt;p&gt;I have a bluetooth adapter connected to uno, and using a serial monitor on phone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the arduino code im debugging there is this line waiting for new line signal in the serial stream:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = SerialBT.read();&#xA;&#xA;if (c == '\r' || c == '\n'){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;no matter what i try sending to via my phone i cant get this to evaluate as true...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if i send \n , i believe it is sending it as 2 chars \ and n , not as a single char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is this a problem with the phone app or what ?&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-04-03T02:06:20.517" Title="Send \r or \n via phone serial monitor" Tags="|serial|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9814" PostTypeId="2" ParentId="9813" CreationDate="2015-04-03T02:06:20.517" Score="1" Body="&lt;p&gt;It turns out it was a problem with the android terminal program i was using, by switching to another that specifically has support and options for \n \r things it works now.&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-04-03T02:06:20.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9815" PostTypeId="1" AcceptedAnswerId="9817" CreationDate="2015-04-03T05:20:15.540" Score="0" ViewCount="556" Body="&lt;p&gt;I got a Sparkfun Redbot Kit a while back. I ended up building it vanilla and it was a good introduction to the board (the board is basically Uno and a motor shield in one) and the toys that came with it. I figured if could scavenge an RC car, I'd get a more robust redbot. I found an old RC Rock Crawler, it has a basic suspension, two motors, and a steering servo.&lt;br&gt;&#xA;Unfortunately, I encountered a problem. The steering servo only has two wires. I loaded the &lt;em&gt;Servo&lt;/em&gt; -&gt; &lt;em&gt;Sweep&lt;/em&gt; example that is default in the Arduino IDE to see if I could make it work regardless. I tried all the different all the different wire/header combinations on the servo headers:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When I attach the wires to gnd and # I get a buzzing noise.&lt;/li&gt;&#xA;&lt;li&gt;When I attach the wires to gnd and pow the servo turns left or, if I swap the wires, it turns right.&lt;/li&gt;&#xA;&lt;li&gt;When I attach the wires to pow and # nothing happens.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I currently can't take advantage of the servo headers on the board (or at least I don't know how to). I was hoping that I could that there might be a work around, I just don't know what it is.&lt;br&gt;&#xA;The obvious answer is that I could run both motors off of only one of the headers and use the other to control the steering (thats how the original board from the car was wired), but I can get a faster car if each motor has its own header, and I'm all about the vroom vroom...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running the whole thing off the default 6v (4 AA) battery pack. I might be able to wire in the extra 2 AA's for the extra 3v but I don't want mess with the wiring on the pack unless I know it's going to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an accelerometer connected to the A4 A5 header block and the motors connected too (I checked w/o them connected but there was no difference). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://dlnmh9ip6v2uc.cloudfront.net/assets/7/6/b/4/6/520026ca757b7f2344958fd5.jpg&quot; alt=&quot;A basic image of all the headers on the RedBot board&quot;&gt;&#xA;&lt;em&gt;Image courtesy of &lt;a href=&quot;https://learn.sparkfun.com/tutorials/getting-started-with-the-redbot&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/getting-started-with-the-redbot&lt;/a&gt;&lt;/em&gt;&lt;br&gt;&#xA;More info on the redbot board &lt;a href=&quot;https://www.sparkfun.com/products/12097&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12097&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8236" LastActivityDate="2015-04-03T06:31:34.690" Title="Adding a steering servo" Tags="|arduino-uno|motor|pins|servo|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9816" PostTypeId="2" ParentId="9811" CreationDate="2015-04-03T06:24:36.857" Score="1" Body="&lt;p&gt;You could check from where you have bought it. Maybe they have datasheet.&#xA;I found one similar, but before you must check if everything is the same and then do testing with power. &lt;a href=&quot;http://www.adafruit.com/datasheets/454datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;LuckyLight&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-04-03T06:24:36.857" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9817" PostTypeId="2" ParentId="9815" CreationDate="2015-04-03T06:31:34.690" Score="0" Body="&lt;p&gt;If the motor you are using has only two wires, and as you described it's response to the direct connection to the power, it can't be a servo. The motor is a normal dc motor.&#xA;If you want to control the amount of the turns on your rc car you should try to play with the pwm signal, I don't know if it will work or not but at least you will have tried. And remember not to connect the motor directly on the micro's pin if there no motor pins on your red board.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-04-03T06:31:34.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9818" PostTypeId="2" ParentId="9811" CreationDate="2015-04-03T06:42:31.790" Score="1" Body="&lt;p&gt;As you are testing the correct functionality of LEDs on matrix board, which means the LEDs are multiplexed together. The fastest way to check the pinout is to use a multimeter in continuity test mode and then connect the positive or signal wire ( the red one ) to an fixed pin  (usually start with one ) and the with negative or gnd wire ( the black one ) connect it one by one to the all the remaining pins. When you have finished move the signal wire to the next pin and rescan all the pins, repeat all the steps for every pins on the matrix board.&#xA;I don't recommend you to use directly 5v because it can be dangerous and you can damage the LEDs of the matrix display as there isn't a current limiting resistor.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-04-03T06:42:31.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9821" PostTypeId="1" CreationDate="2015-04-03T08:08:17.430" Score="-1" ViewCount="287" Body="&lt;p&gt;I am new to Arduino and IoT. I got my hands on a Yun and loaded a simple sketch to subscribe to a topic. I am receiving messages (I have set up a PHP script and broker on a server, which takes care of the messages) and can turn ON and OFF LED, L13. But when I disconnect the Yun from my PC and connect it again (to power it up), it stops receiving messages. I have to load the sketch again to make it work. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;spi.h&amp;gt;&#xA;#include &amp;lt;pubsubclient.h&amp;gt;&#xA;#include &amp;lt;yunclient.h&amp;gt;&#xA;&#xA;byte server[] = { 192, 168, 1, 196 };&#xA;int port = 1883;&#xA;char* pubTopic = &quot;fromYun&quot;;&#xA;char* subTopic = &quot;sensor/light&quot;;&#xA;&#xA;void callback(char* topic, byte* payload, unsigned int length) {&#xA;  //convert byte to char&#xA;  payload[length] = '\0';&#xA;  String strPayload = String((char*)payload);&#xA;  // handle message arrived&#xA;  if(strPayload == &quot;ON&quot;) {&#xA;    digitalWrite(13, HIGH);&#xA;  } else if(strPayload == &quot;OFF&quot;) {&#xA;    digitalWrite(13, LOW);&#xA;  }&#xA;}&#xA;&#xA;YunClient yun;&#xA;PubSubClient mqtt(server, port, callback, yun);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;  Bridge.begin();&#xA;  if (mqtt.connect(&quot;arduinoClient&quot;)) {&#xA;    mqtt.publish(pubTopic,&quot;hello world!&quot;);&#xA;    mqtt.subscribe(subTopic);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  mqtt.loop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I referred to &lt;a href=&quot;http://jpmens.net/2013/10/15/mqtt-on-the-arduino-yun/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; post and PubSubClient -&gt; mqtt_basic.ino for making this ketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand what &lt;code&gt;mqtt.connect(&quot;arduinoClient&quot;)&lt;/code&gt; is. I mean, what is this string &quot;arduinoClient&quot;? In one sketch on GitHub I saw it as &quot;yun&quot;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated. Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I am using Mosquitto MQTT.&lt;/p&gt;&#xA;" OwnerUserId="8224" LastEditorUserId="4628" LastEditDate="2017-12-01T08:18:53.980" LastActivityDate="2023-01-12T06:03:35.413" Title="I have to reload Sketch every time I start my Yun" Tags="|arduino-yun|uploading|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9823" PostTypeId="2" ParentId="9810" CreationDate="2015-04-03T08:55:30.223" Score="1" Body="&lt;p&gt;That's probably caused by the motor's current consumption. The 5V pin can deliver much more current than the output pin in high state. If you want to switch the motor on/off by software, you need a &quot;hardware driver&quot; for the motor, in the simplest case a power transistor. &lt;/p&gt;&#xA;" OwnerUserId="8238" LastEditorUserId="2881" LastEditDate="2015-04-03T12:28:11.987" LastActivityDate="2015-04-03T12:28:11.987" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9824" PostTypeId="1" CreationDate="2015-04-03T09:37:39.283" Score="-1" ViewCount="124" Body="&lt;p&gt;I want to use Arduino Uno (Rev. 3) resp. Arduino Nano for time critical ignition control of a combustion engine. Software is developed under arduino rev. 1.6.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only Arduino system functions i use are micros()  and delayMicroseconds(). I suppose they are implemented by a timer interrupt, which may fire within time critical port polling regions of the program.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the maximum runtime for the ISR i have to expect? As long it stays within the range of a few microseconds, say 10 or like, it would be tolerable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there other time ressources used in the background by the arduino system i have to cope with? &lt;/p&gt;&#xA;" OwnerUserId="8238" LastActivityDate="2015-04-03T12:46:06.507" Title="interrupt and/or other ressources used by Time functions micros() and delayMicroseconds()" Tags="|interrupt|arduino-nano|timers|time|core-libraries|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9825" PostTypeId="2" ParentId="9824" CreationDate="2015-04-03T12:46:06.507" Score="1" Body="&lt;p&gt;Here is the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring.c#L47-L65&quot; rel=&quot;nofollow&quot;&gt;The ISR code&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the obj-dump:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;000008f6 &amp;lt;__vector_16&amp;gt;:&#xA;#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)&#xA;ISR(TIM0_OVF_vect)&#xA;#else&#xA;ISR(TIMER0_OVF_vect)&#xA;#endif&#xA;{&#xA; 8f6:   1f 92           push    r1&#xA; 8f8:   0f 92           push    r0&#xA; 8fa:   0f b6           in  r0, 0x3f    ; 63&#xA; 8fc:   0f 92           push    r0&#xA; 8fe:   11 24           eor r1, r1&#xA; 900:   2f 93           push    r18&#xA; 902:   3f 93           push    r19&#xA; 904:   8f 93           push    r24&#xA; 906:   9f 93           push    r25&#xA; 908:   af 93           push    r26&#xA; 90a:   bf 93           push    r27&#xA;    // copy these to local variables so they can be stored in registers&#xA;    // (volatile variables must be read from memory on every access)&#xA;    unsigned long m = timer0_millis;&#xA; 90c:   80 91 a0 01     lds r24, 0x01A0&#xA; 910:   90 91 a1 01     lds r25, 0x01A1&#xA; 914:   a0 91 a2 01     lds r26, 0x01A2&#xA; 918:   b0 91 a3 01     lds r27, 0x01A3&#xA;    unsigned char f = timer0_fract;&#xA; 91c:   30 91 9f 01     lds r19, 0x019F&#xA;&#xA;    m += MILLIS_INC;&#xA;    f += FRACT_INC;&#xA; 920:   20 e3           ldi r18, 0x30   ; 48&#xA; 922:   23 0f           add r18, r19&#xA;    if (f &amp;gt;= FRACT_MAX) {&#xA; 924:   2d 37           cpi r18, 0x7D   ; 125&#xA; 926:   20 f4           brcc    .+8         ; 0x930 &amp;lt;__stack+0x31&amp;gt;&#xA;    // copy these to local variables so they can be stored in registers&#xA;    // (volatile variables must be read from memory on every access)&#xA;    unsigned long m = timer0_millis;&#xA;    unsigned char f = timer0_fract;&#xA;&#xA;    m += MILLIS_INC;&#xA; 928:   40 96           adiw    r24, 0x10   ; 16&#xA; 92a:   a1 1d           adc r26, r1&#xA; 92c:   b1 1d           adc r27, r1&#xA; 92e:   05 c0           rjmp    .+10        ; 0x93a &amp;lt;__stack+0x3b&amp;gt;&#xA;    f += FRACT_INC;&#xA;    if (f &amp;gt;= FRACT_MAX) {&#xA;        f -= FRACT_MAX;&#xA; 930:   23 eb           ldi r18, 0xB3   ; 179&#xA; 932:   23 0f           add r18, r19&#xA;        m += 1;&#xA; 934:   41 96           adiw    r24, 0x11   ; 17&#xA; 936:   a1 1d           adc r26, r1&#xA; 938:   b1 1d           adc r27, r1&#xA;    }&#xA;&#xA;    timer0_fract = f;&#xA; 93a:   20 93 9f 01     sts 0x019F, r18&#xA;    timer0_millis = m;&#xA; 93e:   80 93 a0 01     sts 0x01A0, r24&#xA; 942:   90 93 a1 01     sts 0x01A1, r25&#xA; 946:   a0 93 a2 01     sts 0x01A2, r26&#xA; 94a:   b0 93 a3 01     sts 0x01A3, r27&#xA;    timer0_overflow_count++;&#xA; 94e:   80 91 a4 01     lds r24, 0x01A4&#xA; 952:   90 91 a5 01     lds r25, 0x01A5&#xA; 956:   a0 91 a6 01     lds r26, 0x01A6&#xA; 95a:   b0 91 a7 01     lds r27, 0x01A7&#xA; 95e:   01 96           adiw    r24, 0x01   ; 1&#xA; 960:   a1 1d           adc r26, r1&#xA; 962:   b1 1d           adc r27, r1&#xA; 964:   80 93 a4 01     sts 0x01A4, r24&#xA; 968:   90 93 a5 01     sts 0x01A5, r25&#xA; 96c:   a0 93 a6 01     sts 0x01A6, r26&#xA; 970:   b0 93 a7 01     sts 0x01A7, r27&#xA;}&#xA; 974:   bf 91           pop r27&#xA; 976:   af 91           pop r26&#xA; 978:   9f 91           pop r25&#xA; 97a:   8f 91           pop r24&#xA; 97c:   3f 91           pop r19&#xA; 97e:   2f 91           pop r18&#xA; 980:   0f 90           pop r0&#xA; 982:   0f be           out 0x3f, r0    ; 63&#xA; 984:   0f 90           pop r0&#xA; 986:   1f 90           pop r1&#xA; 988:   18 95           reti&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'll let you calculate how many clock cycles that is. My guess is that it's less that 160 clock cycles (i.e. 10S).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm unsure if the accuracy of &lt;code&gt;micros&lt;/code&gt; is good enough in your application.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-03T12:46:06.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9828" PostTypeId="1" AcceptedAnswerId="11889" CreationDate="2015-04-03T14:17:30.853" Score="1" ViewCount="228" Body="&lt;p&gt;I'm having a soft pot meter here and I would like to register the duration of the touch event. I'm having a different variable, which keeps going from 1024 to 0 , which regularly takes 60 seconds, but for every second you touch the soft pot meter the count adds 50 up to 1024. Like returning the clock backward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I register/code this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NtBgH.jpg&quot; alt=&quot;Softpot meter&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8242" LastActivityDate="2015-12-12T14:08:00.137" Title="How to I measure the duration of touch with a soft potentiometer?" Tags="|potentiometer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9829" PostTypeId="1" CreationDate="2015-04-03T12:32:56.083" Score="2" ViewCount="350" Body="&lt;p&gt;I am trying to execute the sweep program but all the servo does is go back and forth in one step. When I tried changing the delay, It behaves erratically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo Specs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Required Pulse: 3-5 Volt Peak to Peak Square Wave&#xA;Operating Voltage: 4.8-7.2 Volts&#xA;Operating Temperature Range: -10 to +60 Degree C&#xA;Operating Speed (4.8V): 0.18sec/60 degrees at no load&#xA;Operating Speed (6V): 0.16sec/60 degrees at no load&#xA;Operating Speed (7.2V): 0.14sec/60 degrees at no load&#xA;Stall Torque (4.8V): 11kg/cm&#xA;Stall Torque (6V): 13.5kg/cm&#xA;Stall Torque (7.2V): 16kg/cm&#xA;360 Modifiable: Yes&#xA;Potentiometer Drive: Indirect Drive&#xA;Bearing Type: Double Ball Bearing&#xA;Gear Type: All Metal Gears&#xA;Connector Wire Length: 12&quot;&#xA;Dimensions: 1.6&quot; x 0.8&quot;x 1.4&quot; (41 x 20 x 36mm)&#xA;Weight: 56gm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sweep Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;  // create servo object to control a servo &#xA;                // twelve servo objects can be created on most boards&#xA;&#xA;int pos = 0;    // variable to store the servo position &#xA;&#xA;void setup() &#xA;{ &#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  for(pos = 0; pos &amp;lt;= 180; pos += 1) // goes from 0 degrees to 180 degrees &#xA;  {                                  // in steps of 1 degree &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;  for(pos = 180; pos&amp;gt;=0; pos-=1)     // goes from 180 degrees to 0 degrees &#xA;  {                                &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried both powering up internally and externally. Internally it responds but externally, arduino's L LED is high all the time and servo does not respond. May I know what is actually going wrong here.&lt;/p&gt;&#xA;" OwnerUserId="8252" OwnerDisplayName="iBot" LastActivityDate="2015-04-03T15:22:34.390" Title="Servo Issues with Arduino" Tags="|servo|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9831" PostTypeId="1" AcceptedAnswerId="9832" CreationDate="2015-04-03T19:16:30.040" Score="1" ViewCount="1035" Body="&lt;p&gt;I am attempting to send a RAW IR code using the IRremote.h library.  The process for capturing IR pulses is easy to find on the web, but the process for sending them again is not.  After a few days, i pieced the following code together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA; IRsend irsend;&#xA;&#xA;void setup() {&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int IRsignal[] = {&#xA;&#xA;// ON, OFF (in 10's of microseconds)&#xA;&#xA;    90, 86,&#xA;&#xA;    174, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 174,&#xA;&#xA;    88, 86,&#xA;&#xA;    174, 88,&#xA;&#xA;    86, 2340,&#xA;&#xA;    88, 86,&#xA;&#xA;    174, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 88,&#xA;&#xA;    86, 174,&#xA;&#xA;    88, 86,&#xA;&#xA;    174, 88,&#xA;&#xA;    86, 0};&#xA;&#xA;&#xA;      irsend.sendRaw(IRsignal, 10, 38);&#xA;&#xA;      delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run it, i get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ir_test.ino: In function 'void loop()': ir_test.ino:65:38: error:&#xA;  invalid conversion from 'int*' to 'unsigned int*' [-fpermissive] In&#xA;  file included from ir_test.ino:3:0:&#xA;  /Applications/Arduino.app/Contents/Resources/Java/libraries/RobotIRremote/src/IRremote.h:143:8:&#xA;  error:   initializing argument 1 of 'void IRsend::sendRaw(unsigned&#xA;  int*, int, int)' [-fpermissive]    void sendRaw(unsigned int buf[],&#xA;  int len, int hz);&#xA;          ^ Error compiling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am not sure what I did wrong, or how to convert the data types.  Any tips or ideas?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-04-03T20:29:02.293" Title="IR trouble with raw buffer" Tags="|ir|data-type|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9832" PostTypeId="2" ParentId="9831" CreationDate="2015-04-03T20:29:02.293" Score="2" Body="&lt;p&gt;Use &lt;code&gt;unsigned int IRsignal[]&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, your array is 48 items long, not 10. So &lt;code&gt;irsend.sendRaw(IRsignal, 48, 38);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-03T20:29:02.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9833" PostTypeId="1" CreationDate="2015-04-03T20:57:27.533" Score="2" ViewCount="684" Body="&lt;p&gt;Is there anything like the link below that I can read/set with an arduino/raspberry pi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to control this completely from a computer in my kegerator setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any search terms that might help me find something would be useful too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0060NOX40&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Taprite-Product-Pressure-Kegerator-Regulator/dp/B0060NOX40/ref=lh_ni_t?ie=UTF8&amp;amp;psc=1&amp;amp;smid=AEUC6GAA8XY7Y&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8245" LastActivityDate="2015-04-03T20:57:27.533" Title="CO2 pressure regulator for keg" Tags="|sensors|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9835" PostTypeId="1" AcceptedAnswerId="9836" CreationDate="2015-04-04T07:48:47.770" Score="-1" ViewCount="1250" Body="&lt;p&gt;I have included the STL library in Arduino and i can run a program with 1D vector.&#xA;But i am getting error while declaring a 2D vector.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;StandardCplusplus.h&amp;gt;&#xA;#include &amp;lt;serstream&amp;gt;&#xA;#include&amp;lt;vector&amp;gt;&#xA;#include&amp;lt;iterator&amp;gt;&#xA;&#xA;using namespace std;&#xA;&#xA;vector &amp;lt;vector&amp;lt;int&amp;gt; &amp;gt; grid;&#xA;vector&amp;lt;int&amp;gt; col(5,3);&#xA;grid.push_back(col);&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for(int i = 0; i &amp;lt; 5; i++)&#xA;  {&#xA;    Serial.println(grid[[0][i]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the error is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'grid' does not name a type.   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do i need to add another header file?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-04-04T08:27:36.123" Title="Problem with declaring 2D vector in Arduino" Tags="|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9836" PostTypeId="2" ParentId="9835" CreationDate="2015-04-04T08:27:36.123" Score="4" Body="&lt;p&gt;The error is coming from &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; grid.push_back(col);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You cannot have this line at the top-most level outside a function / main. Move it inside &lt;code&gt;setup&lt;/code&gt; or &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-04-04T08:27:36.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9839" PostTypeId="1" CreationDate="2015-04-04T14:42:39.303" Score="2" ViewCount="145" Body="&lt;p&gt;It's easy enough to attach a display for displaying sensor data, but I'm wondering what the proper way is to have the user change variables using an user interface on the attached 2x16 display. &#xA;The only library I found for this purpose:&#xA;&lt;a href=&quot;https://liudr.wordpress.com/libraries/phi_prompt/&quot; rel=&quot;nofollow&quot;&gt;https://liudr.wordpress.com/libraries/phi_prompt/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Takes a lot of code just to set up. I'm wondering if there's perhaps an easier option. All thoughts appreciated!&lt;/p&gt;&#xA;" OwnerUserId="8256" LastActivityDate="2015-04-04T14:42:39.303" Title="How should I make a UI for my arduino project?" Tags="|ui|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9840" PostTypeId="1" AcceptedAnswerId="9855" CreationDate="2015-04-04T14:43:57.127" Score="6" ViewCount="3807" Body="&lt;p&gt;I have following code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MyApp.ino&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DfRobotLcdShield.h&quot;&#xA;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DfRobotLcdShield.h&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to compile, I'm getting the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from MyApp.ino:1:0:&#xA;c:\temp\build5856181074637812172.tmp\DfRobotLcdShield.h:4:27: fatal error: LiquidCrystal.h: No such file or directory&#xA; #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;                           ^&#xA;compilation terminated.&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;directly to the .ino file, it works. I'm using the latest Arduino-IDE 1.6.3.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2015-04-05T05:05:27.487" LastActivityDate="2015-04-05T09:31:37.120" Title="Problem importing a library in .h file" Tags="|library|c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9841" PostTypeId="1" CreationDate="2015-04-04T16:16:08.210" Score="0" ViewCount="553" Body="&lt;p&gt;as it is in the question, i need to know what is the size of the biggest string that i can send using the serial port to the arduino.&lt;br&gt;&#xA;Thank you&lt;/p&gt;&#xA;" OwnerUserId="7328" LastActivityDate="2015-04-04T19:30:36.143" Title="What is the size of the buffer in serial communication with arduino uno?" Tags="|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9842" PostTypeId="2" ParentId="8343" CreationDate="2015-04-04T16:50:51.193" Score="0" Body="&lt;p&gt;The likely causes of failure are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wrong baud rate: you're already using 57600, the most common one.&lt;/li&gt;&#xA;&lt;li&gt;Rx and Tx cross connected: try connecting them the other way round.&lt;/li&gt;&#xA;&lt;li&gt;Wrong clock clock frequency in the chip: The tools usually assume an AtMega328 runs at 16MHz.&lt;/li&gt;&#xA;&lt;li&gt;Chip is not in bootloader/programming state, in the very first seconds after releasing the reset button or powering the arduino, the bootloader is listening for instructions to start reprogramming the chip via serial communication, if there is none it will continue running the program on it. Hold reset -&gt; Hold upload -&gt; Release upload -&gt; Release reset.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The above assumes, of course, that you have a working board. If that isn't certain, follow @Nathan's advice to plug in a chip pre-programmed with a Blinky sketch to confirm it. I use a combined Blinky and HelloWorld sketch to prove both the basic functioning and the serial I/O in one test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of these are handy to keep around, too, for proving there is power or a logic HIGH where you expect it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ztoil.jpg&quot; alt=&quot;LED with resistor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       LED with current-limiting resistor on the cathode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="11529" LastEditDate="2016-01-06T03:16:54.603" LastActivityDate="2016-01-06T03:16:54.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9843" PostTypeId="1" AcceptedAnswerId="9844" CreationDate="2015-04-04T18:13:02.570" Score="-1" ViewCount="1427" Body="&lt;p&gt;I am trying to calculate time between two serial events. Using Arduino UNO R3 with 16MHz default clock source.&#xA;I am using timer 1 with pre-scale of 64 to get time per one count = 4000ns. This i am choosing at random without any specific reason.&#xA;Sending character 'o' to start the timer and character 'k' to stop it and hence calculate the time in between. The ISR routine calculates how much times the timer overflows.&#xA;The code is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    unsigned int t;&#xA;unsigned int c;&#xA;char r;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;  TCNT1 = 0;&#xA;  &#xA;  TIMSK1 = (1&amp;lt;&amp;lt;TOIE1);//enable timer overflow interrupt&#xA;  sei();&#xA;  //SREG = (1&amp;lt;&amp;lt;8);//enable global inteerupt&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if(Serial.available()&amp;gt;0)&#xA;  {&#xA;    r=Serial.read();&#xA;  if(r=='o')&#xA;  {&#xA;    TCNT1=0;&#xA;    TCCR1B |= (1&amp;lt;&amp;lt;CS11)|(1&amp;lt;&amp;lt;CS10);//64 pre-scale &amp;amp; start&#xA;    Serial.println(TCNT1);&#xA;  }&#xA;  else if(r=='k')&#xA;  {&#xA;    Serial.println(TCNT1);&#xA;    TCCR1B = 0;//stop timer&#xA;    t=TCNT1+(c*65536);&#xA;    t=t*(4*10^(-9));&#xA;    Serial.print(&amp;quot;overflows = &amp;quot;);&#xA;    Serial.println(c);&#xA;    Serial.print(&amp;quot;time = &amp;quot;);&#xA;    Serial.println(t);&#xA;    c=0;&#xA;    t=0;&#xA;  }&#xA;  }&#xA;}//loop&#xA;&#xA;ISR(TIMER1_OVF_vect)&#xA;{&#xA;  c++;&#xA;}//isr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But, on serial monitor only the block of if(Serial.read()=='o').... is executing. The flow does not enter the second else if block.&lt;/p&gt;&#xA;&lt;p&gt;What is wrong with this code? How long does the Serial buffer hold its vale ?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I got the code working for checking for 'k'. But the timer value it calculates is very less than compared to what it should be. Is anything wrong with the timer settings. Setting CS10=CS11=1 gets the pre-scaler value to 64.&lt;/p&gt;&#xA;&lt;p&gt;Hence, the time for 1 count should be = 1/(16MHz/64) .&lt;/p&gt;&#xA;&lt;p&gt;Is anything wrong with this?&lt;/p&gt;&#xA;" OwnerUserId="8254" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-04T18:43:15.817" Title="Calculating time between Serial events" Tags="|arduino-uno|serial|timers|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9844" PostTypeId="2" ParentId="9843" CreationDate="2015-04-04T18:22:19.390" Score="0" Body="&lt;p&gt;I'd read the result of &lt;code&gt;Serial.read()&lt;/code&gt; to a variable and check this variable, because otherwise the first &lt;code&gt;Serial.read()&lt;/code&gt; will have already read the 'k'. I reckon you can remove the &lt;code&gt;Serial.available()&lt;/code&gt; check.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    int chr = Serial.read();&#xA;    if(chr=='o')&#xA;    {&#xA;        TCNT1=0;&#xA;        TCCR1B |= (1&amp;lt;&amp;lt;CS11)|(1&amp;lt;&amp;lt;CS10);//64 pre-scale &amp;amp; start&#xA;    }&#xA;    else if(chr=='k')&#xA;    {&#xA;        t=TCNT1;&#xA;        TCCR1B = 0;//stop timer&#xA;        t=t+(c*65536);&#xA;        c=0;&#xA;        Serial.println(t);&#xA;        t=0;&#xA;    }&#xA;}//loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2015-04-04T18:26:27.193" LastActivityDate="2015-04-04T18:26:27.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9845" PostTypeId="1" CreationDate="2015-04-04T18:49:15.353" Score="0" ViewCount="2291" Body="&lt;p&gt;I am trying to play a tone with a buzzer connected on an arduino nano pin. I have also connected a reed switch with INPUT_PULLUP on INT0 and a led. The program loops continuously (it's an environmental monitor and alarm personal project) until the reed switch is set on HIGH where a function is called and the buzzer should play an one-second high pitch tone. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void doorStateChange() {&#xA;  static unsigned long last_interrupt_time = 0;&#xA;  unsigned long interrupt_time = millis();&#xA;  if (interrupt_time - last_interrupt_time &amp;gt; 1000)&#xA;  {&#xA;    led_B_state   = !led_B_state;&#xA;    digitalWrite(buzzPin, HIGH);&#xA;    digitalWrite(led_A_Pin, HIGH);&#xA;&#xA;    if (millis() - interrupt_time &amp;lt;= 1000 ){&#xA;        digitalWrite(buzzPin, LOW);&#xA;        digitalWrite(led_A_Pin, LOW);&#xA;    }&#xA;&#xA;  }&#xA;  last_interrupt_time = interrupt_time;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The interrupt is called, the Led lights up but I can't make the buzzer sound right. I 've tried with &lt;code&gt;tone(buzzPin, 5000, 1000);&lt;/code&gt; but seems that the delay does not work - The sound is heard but after the 1000ms it continuous to work in a different tone (strange?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I could make it work is with &lt;code&gt;buzzPin_state = ! buzzPin_state;&lt;/code&gt; where the buzzer beeps as long as the reed switch is HIGH. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also need to say that &lt;code&gt;attachInterrupt(0, doorStateChange, CHANGE);&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The information I get from googling this issue is gibberish: some say that delays don't run in interrupts, others call external functions etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the proper way to achieve this ?&lt;/p&gt;&#xA;" OwnerUserId="8084" LastEditorUserId="8084" LastEditDate="2015-04-04T18:55:28.707" LastActivityDate="2019-09-02T01:11:25.680" Title="Tone inside interrupt" Tags="|interrupt|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9846" PostTypeId="1" CreationDate="2015-04-04T19:03:11.190" Score="0" ViewCount="2912" Body="&lt;p&gt;I am doing a project where I need to send some numbers between arduinos. But it has to be wirelessly because they will be moving. How to Communicate between arduinos wirelessly? I need to send data between them. Wifi would be preferred.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You.&lt;/p&gt;&#xA;" OwnerUserId="8257" LastActivityDate="2015-06-12T05:13:20.973" Title="How to Communicate between arduinos wirelessly?" Tags="|arduino-uno|bluetooth|wifi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9848" PostTypeId="2" ParentId="9841" CreationDate="2015-04-04T19:30:36.143" Score="1" Body="&lt;p&gt;That would be 64 bytes, providing the buffer is fully empty. See &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.h#L42-L43&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.h#L42-L43&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-04T19:30:36.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9849" PostTypeId="2" ParentId="9840" CreationDate="2015-04-04T21:06:05.333" Score="-1" Body="&lt;p&gt;Try &lt;code&gt;#include &quot;LiquidCrystal.h&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or where is the library located?&#xA;Be sure the include specifies the location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might have to add the library location to your environment variables.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-04T21:06:05.333" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9850" PostTypeId="1" AcceptedAnswerId="9853" CreationDate="2015-04-04T21:17:08.233" Score="2" ViewCount="480" Body="&lt;p&gt;I have an interesting situation.  I wonder if anyone can help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;4x Arduino Micros loaded with the basic Blink sketch&lt;/li&gt;&#xA;&lt;li&gt;5x &lt;a href=&quot;http://uk.rs-online.com/web/p/magnetic-buzzer-components/7243184/&quot; rel=&quot;nofollow&quot;&gt;12 volt buzzers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;A desk full of completely fresh Duracell AA and 9v batteries&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I connect (using VIN and GND) any of the Arduino Micros to either a 9v battery, or a 12v network of 8 AA batteries, then they run the blink sketch, and the appropriate LED flashes on the Arduino as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect any of the buzzers to either a 9v battery, or a 12v network of 8 AA batteries, then they buzz as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect both a buzzer and an Arduino in parallel to either a 9v battery, or a 12v network of 8 AA batteries, then the Arduino works fine, &lt;strong&gt;but the buzzer makes barely an inaudible whimper&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect only a buzzer to the Arduino and battery, it works fine.  If whilst the buzzer is buzzing I connect the Arduino, then on every ON or OFF of the blink sketch LED, the buzzer gets quieter and quieter until it can barely be heard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These buzzers are rated to work at 25mA, so it really astounds me that they can't be run off a battery together with an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dave&lt;/p&gt;&#xA;" OwnerUserId="8260" LastActivityDate="2015-04-06T21:36:01.987" Title="Using Arduino Micro With 12V Buzzer" Tags="|current|arduino-micro|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9851" PostTypeId="1" CreationDate="2015-04-04T22:26:21.673" Score="2" ViewCount="324" Body="&lt;p&gt;I am using the following code to send an IR signal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA; IRsend irsend;&#xA;&#xA;void setup() {&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    unsigned int IRsignal[] = {86,88,86,88,174,86,88,88,86,88,86,86,88,86,88,86,88,174,86,88,174,86,88,2336,90,86,88,86,174,88,86,88,86,88,86,88,86,88,86,88,86,174,88,86,174,88,86,0};&#xA;&#xA;    irsend.sendRaw(IRsignal, 48, 40);&#xA;&#xA;    delay(3000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I attach an IR receiver to another Arduino and take a look at the signal that is produced by the code above, I see this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Received: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OFF     ON&#xA;332 usec, 460 usec&#xA;1040 usec, 280 usec&#xA;2680 usec, 260 usec&#xA;820 usec, 80 usec&#xA;400 usec, 260 usec&#xA;int IRsignal[] = {&#xA;// ON, OFF (in 10's of microseconds)&#xA;    46, 104,&#xA;    28, 268,&#xA;    26, 82,&#xA;    8, 40,&#xA;    26, 0};&#xA;&#xA;&#xA;Received: &#xA;&#xA;OFF     ON&#xA;39228 usec, 280 usec&#xA;1160 usec, 340 usec&#xA;2460 usec, 480 usec&#xA;440 usec, 500 usec&#xA;340 usec, 260 usec&#xA;int IRsignal[] = {&#xA;// ON, OFF (in 10's of microseconds)&#xA;    28, 116,&#xA;    34, 246,&#xA;    48, 44,&#xA;    50, 34,&#xA;    26, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These numbers are not even close to the ones that are going in.  There are far few pulses recorded, the duration is very inconsistent (the original code is almost entirely made up of 880-860um pulses) and even close to the original values.  I must have made a serious mistake here.  What happened?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE ========================== &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I multiplied all of the values in the array by 10 and attempted to play/read the values using another Adruino with an IR sensor.  I started to see better results.  each pulse time was close to 88, 86, or 174 but they are still off by up to 10%.  The related IR device is still unresponsive.  Is there any other way to improve this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Received: &#xA;&#xA;OFF     ON&#xA;29828 usec, 860 usec&#xA;900 usec, 820 usec&#xA;880 usec, 1700 usec&#xA;880 usec, 860 usec&#xA;880 usec, 840 usec&#xA;940 usec, 760 usec&#xA;840 usec, 880 usec&#xA;860 usec, 880 usec&#xA;860 usec, 860 usec&#xA;1740 usec, 840 usec&#xA;880 usec, 1700 usec&#xA;880 usec, 840 usec&#xA;6920 usec, 880 usec&#xA;860 usec, 860 usec&#xA;880 usec, 1680 usec&#xA;880 usec, 860 usec&#xA;900 usec, 820 usec&#xA;900 usec, 820 usec&#xA;880 usec, 840 usec&#xA;860 usec, 840 usec&#xA;960 usec, 740 usec&#xA;1760 usec, 880 usec&#xA;920 usec, 1620 usec&#xA;900 usec, 10680 usec&#xA;13580 usec, 8580 usec&#xA;8820 usec, 8680 usec&#xA;int IRsignal[] = {&#xA;// ON, OFF (in 10's of microseconds)&#xA;    86, 90,&#xA;    82, 88,&#xA;    170, 88,&#xA;    86, 88,&#xA;    84, 94,&#xA;    76, 84,&#xA;    88, 86,&#xA;    88, 86,&#xA;    86, 174,&#xA;    84, 88,&#xA;    170, 88,&#xA;    84, 692,&#xA;    88, 86,&#xA;    86, 88,&#xA;    168, 88,&#xA;    86, 90,&#xA;    82, 90,&#xA;    82, 88,&#xA;    84, 86,&#xA;    84, 96,&#xA;    74, 176,&#xA;    88, 92,&#xA;    162, 90,&#xA;    1068, 1358,&#xA;    858, 882,&#xA;    868, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-04-07T18:20:15.833" LastActivityDate="2015-04-07T18:20:15.833" Title="How to fix an IR remote signal" Tags="|ir|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9852" PostTypeId="1" CreationDate="2015-04-05T04:38:36.790" Score="1" ViewCount="225" Body="&lt;p&gt;i am working on this arduino project using processing. There are some sensor values which should be logged, but unfortunately my processing code rewrites the file after each cycle so that i get the last sensor value only. How do i prevent this from happening? I am using the ordinary method by the way. PrintWriter command followed by createWriter&lt;/p&gt;&#xA;" OwnerUserId="8262" LastActivityDate="2020-10-27T02:03:00.280" Title="How to prevent file overwriting in processing?" Tags="|arduino-duemilanove|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9853" PostTypeId="2" ParentId="9850" CreationDate="2015-04-05T06:00:58.767" Score="4" Body="&lt;p&gt;Attach your voltmeter across the battery, and measure the available voltage when different things are attached; or attach it in series, and measure current draws.  You probably will find that a 9V battery's voltage is under 8 volts when a mix of multiple Arduinos and buzzers is attached.  That voltage may be too low to activate the buzzer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A powerstream.com web page called &lt;em&gt;&lt;a href=&quot;http://www.powerstream.com/9V-Alkaline-tests.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;9V Alkaline tests&lt;/a&gt;&lt;/em&gt; shows how rapidly a 9V battery's voltage drops when heavy currents (more than a few dozen milliamps) are drawn from it, and a batteriesinaflash.com &lt;a href=&quot;http://www.batteriesinaflash.com/lithium/9v/12x-ultralife-9v-lithium-battery-1200mah-for-alarm-home-safety&quot; rel=&quot;nofollow noreferrer&quot;&gt;web page&lt;/a&gt; includes the following diagram that shows battery voltage quickly falling below 8.5 V in its first minutes of life when 27 mA is drawn from it. &lt;img src=&quot;https://i.stack.imgur.com/egLKW.gif&quot; alt=&quot;9v-lithium-comparison.gif&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some models of Arduino, eg the &lt;a href=&quot;http://arduino.cc/en/main/arduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uno R3&lt;/a&gt;, various &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=5536.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;posts on the web&lt;/a&gt; list currents from 25 mA up to 45 mA, depending on LED and sleep settings.  Currents for the &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardDuemilanove&quot; rel=&quot;nofollow noreferrer&quot;&gt;Duemilanove&lt;/a&gt; from 10 mA up are reported.  The &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardMicro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Micros&lt;/a&gt; in your tests probably use a little more current than &lt;a href=&quot;http://arduino.cc/en/Main/arduinoBoardProMini&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pro Mini&lt;/a&gt; boards (which have no USB), and although it's unlikely they will use as much or more current than the buzzers, they still may drag the voltage down to a level where the buzzers won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your system needs to be battery powered, consider using separate batteries for different devices, to avoid problems like you saw.  Alternatively, use heavier-duty batteries, eg &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_battery_sizes#Cylindrical_lithium-ion_rechargeable&quot; rel=&quot;nofollow noreferrer&quot;&gt;good-sized lithium-polymer units&lt;/a&gt;.  Also review posts about decreasing Arduino power usage via sleep, disconnecting the power LED, and using large capacitors to buffer power surges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Given that voltage measurements show enough voltage being available, the suggested use of capacitors or inductors to isolate circuits may be a good idea.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When adding a capacitor, locate it physically close to the power-using board or component.  For electrolytic  capacitors, attach the capacitor's + terminal to the high side, eg to the +5, +9, or +12 side, and attach its - terminal to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When adding ferrite beads, wrap the supply wire through the bead several times, if there's room.  The picture below illustrates the idea.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An electrolytic capacitor across a circuit acts as a voltage reservoir.  It also gives high-frequency signals an easy path to ground, reducing interference.  A ferrite bead or other inductor impedes high frequency signals, again reducing interference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T9qkj.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-04-06T21:36:01.987" LastActivityDate="2015-04-06T21:36:01.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9854" PostTypeId="2" ParentId="9852" CreationDate="2015-04-05T08:32:02.853" Score="1" Body="&lt;p&gt;&lt;code&gt;PrintWriter pw = new PrintWriter(new FileOutputStream(&#xA;    new File(&quot;persons.txt&quot;), &#xA;    true /* append = true */));&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;true&lt;/code&gt; is the append mode flag.&#xA;Also check if you're using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pw.append(p.toString());&#xA;        pw.append(&quot;sdf&quot;);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/8210616/printwriter-append-method-not-appending&quot;&gt;https://stackoverflow.com/questions/8210616/printwriter-append-method-not-appending&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-05T08:32:02.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9855" PostTypeId="2" ParentId="9840" CreationDate="2015-04-05T09:23:39.477" Score="4" Body="&lt;p&gt;This seems to be a general problem of the Arduino IDE: It only recognizes libraries that are included in the (primary) &lt;code&gt;.ino&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;If you look at the invocation of the compiler, the path to any given library is only added if this library's header file is included in the &lt;code&gt;.ino&lt;/code&gt; file.&lt;/p&gt;&#xA;&lt;p&gt;I tested this with the EEPROM library. If this library is included in the &lt;code&gt;.ino&lt;/code&gt; file, the compiler is called with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/eightanaloginputs -I/usr/share/arduino/libraries/EEPROM /tmp/build2678545434708654378.tmp/test.cpp -o/tmp/build2678545434708654378.tmp/test.cpp.o &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where the important part is the &lt;code&gt;-I/usr/share/arduino/libraries/EEPROM&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If I now remove &lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&lt;/code&gt; (but still have it in another header file which in turn is included in the &lt;code&gt;.ino&lt;/code&gt; as in your case), the compiler call changes to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/eightanaloginputs /tmp/build2678545434708654378.tmp/test.cpp -o/tmp/build2678545434708654378.tmp/test.cpp.o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where now the include path to the library is missing.&lt;/p&gt;&#xA;&lt;h2&gt;TL;DR&lt;/h2&gt;&#xA;&lt;p&gt;If you need to use a library, just (also) add an include to the &lt;code&gt;.ino&lt;/code&gt; file. It doesn't cost you anything and will solve your problem ;)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;&lt;code&gt;#include &amp;lt;file&amp;gt;&lt;/code&gt; vs. &lt;code&gt;#include &amp;quot;file&amp;quot;&lt;/code&gt;&lt;/h3&gt;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;gcc documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;#include &amp;lt;file&amp;gt;&lt;/em&gt; is used for system header files. It searches for a file named file in a standard list of system directories. [...]&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;#include &amp;quot;file&amp;quot;&lt;/em&gt; is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for &amp;lt;file&amp;gt;. [...]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-05T09:31:37.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9856" PostTypeId="1" CreationDate="2015-04-05T09:25:06.783" Score="2" ViewCount="4102" Body="&lt;p&gt;I am running a small project. I want to use an Arduino Mega 2560 v3, a PIR sensor, a micro SD card module, an RTC 1307 module, some LEDs, buttons and a buzzer. To enable and disable motion detection and when detection is found the time is saved to the SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wired everything together, coded and started to test. During tests, Arduino on bootup was restarting over and over. First, I was thinking that the problem is in the breadboard and connection. I checked it a few times and I didn't notice anything wrong. So I checked the code over and over. Still nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I started to test modules. And I found a problem. When I don't use in the sketch either the RTC or the SD card (physically they are still connected, because I am lazy) everything works fine. Arduino doesn't restart. I didn't use the SD module to write data, instead I used the serial port to show data. Everything works fine: I can see at what time is motion detected and Arduino prints it on the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second scenario, I didn’t use the RTC, only the SD module. This time again everything works fine. On the SD card I could read how many times motion was detected. This is weird because when I mix all together it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// *********************************************&#xA;// INCLUDE&#xA;// *********************************************&#xA;#include &amp;lt;Wire.h&amp;gt;                    &#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;// *********************************************&#xA;// DEFINE&#xA;// *********************************************&#xA;#define GREENLED 39&#xA;#define BTNON 11 &#xA;#define REDLED 41&#xA;#define BTNOFF 9 &#xA;#define BUZZ 3 &#xA;#define PIR_PIN 10 &#xA;//SD (na mega)&#xA;#define SD_CLK_SD 52&#xA;#define SD_MI 50&#xA;#define SD_MO 51&#xA;#define SD_CS 4&#xA;&#xA;//RTC &#xA;#define RTC_SDA 20&#xA;#define RTC_SCL 21&#xA;#define RTC_DS 2&#xA;&#xA;// *********************************************&#xA;// VARIABLES&#xA;// *********************************************&#xA;RTC_DS1307 rtc;&#xA;File myFile;&#xA;char godz[8];&#xA;char data[5];&#xA;&#xA;int btnON;&#xA;int btnOFF;&#xA;int pirD;&#xA;bool stan_alarmu;&#xA;&#xA;void wlAlarmu() {&#xA;  digitalWrite(REDLED,LOW);&#xA;  digitalWrite(GREENLED, HIGH);&#xA;  stan_alarmu=true;&#xA;  gettime();&#xA;  myFile = SD.open(&quot;dane.txt&quot;, FILE_WRITE);&#xA;  if (myFile) {&#xA;    myFile.print(&quot;### Wlaczenie alarmu ### &quot;);&#xA;    myFile.print(&quot; &quot;);&#xA;    myFile.print(godz);&#xA;    myFile.print(data);&#xA;    myFile.println(&quot;&quot;);&#xA;    myFile.close();&#xA;  }&#xA;}&#xA;&#xA;void wylAlarmu(){&#xA;  digitalWrite(GREENLED, LOW);&#xA;  digitalWrite(REDLED,HIGH);&#xA;  stan_alarmu=false;&#xA;  gettime();&#xA;  myFile = SD.open(&quot;dane.txt&quot;, FILE_WRITE);&#xA;  if (myFile) {&#xA;    myFile.print(&quot;### Wylaczenie alarmu ### &quot;);&#xA;    myFile.print(&quot; &quot;);&#xA;    myFile.print(godz);&#xA;    myFile.print(data);&#xA;    myFile.println(&quot;&quot;);&#xA;    myFile.close();&#xA;  }&#xA;}&#xA;&#xA;void alarm(){&#xA;  digitalWrite(GREENLED,LOW);&#xA;  digitalWrite(REDLED,HIGH);&#xA;  digitalWrite(BUZZ,HIGH);&#xA;  delay(500);&#xA;  digitalWrite(BUZZ,LOW);&#xA;&#xA;  gettime();&#xA;  myFile = SD.open(&quot;dane.txt&quot;, FILE_WRITE);&#xA;  if (myFile) {&#xA;    myFile.print(&quot;Alarm: &quot;);&#xA;    myFile.print(&quot; &quot;);&#xA;    myFile.print(godz);&#xA;    myFile.print(data);&#xA;    myFile.println(&quot;&quot;);&#xA;    myFile.close();&#xA;  }&#xA;  delay(5000);&#xA;  digitalWrite(REDLED,LOW);&#xA;  digitalWrite(GREENLED,HIGH);&#xA;}&#xA;&#xA;void blad() {&#xA;  while(1){&#xA;    digitalWrite(REDLED,HIGH);&#xA;    delay(500);&#xA;    digitalWrite(REDLED,LOW);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&#xA;void gettime() {&#xA;  DateTime now = rtc.now();&#xA;  sprintf(godz,&quot;%02d:%02d:%02d &quot;,now.hour(),now.minute(),now.second());&#xA;  sprintf(data,&quot;%d.%d&quot;,now.day(),now.month());&#xA;}&#xA;&#xA;// *********************************************&#xA;// SETUP&#xA;// *********************************************&#xA;void setup() {&#xA;  //RTC&#xA;  Wire.begin();&#xA;  // Shield I2C pins connect to alt I2C bus on Arduino Due&#xA;  rtc.begin();&#xA;  if (!rtc.isrunning()) {&#xA;    blad();&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;    // This line sets the RTC with an explicit date &amp;amp; time, for example to set&#xA;    // January 21, 2014 at 3am you would call:&#xA;    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));&#xA;  }&#xA;  pinMode(BTNON,INPUT);&#xA;  pinMode(GREENLED, OUTPUT);&#xA;  pinMode(BTNOFF,INPUT);&#xA;  pinMode(REDLED, OUTPUT);&#xA;  pinMode(PIR_PIN,INPUT);&#xA;  pinMode(BUZZ,OUTPUT);&#xA;&#xA;  //test seq&#xA;  digitalWrite(GREENLED,HIGH);&#xA;  digitalWrite(REDLED,HIGH);&#xA;  digitalWrite(BUZZ,HIGH);&#xA;  delay(100);&#xA;  digitalWrite(BUZZ,LOW);&#xA;  digitalWrite(GREENLED,LOW);&#xA;  digitalWrite(REDLED,LOW);&#xA;  delay(500);  &#xA;  pinMode(SD_CS, OUTPUT);&#xA;  if (!SD.begin(SD_CS)) {&#xA;    blad();&#xA;  }&#xA;  digitalWrite(GREENLED,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(GREENLED,LOW);&#xA;  gettime();&#xA;  Serial.begin(9600);&#xA;&#xA;  myFile = SD.open(&quot;dane.txt&quot;, FILE_WRITE);&#xA;  if (myFile) {&#xA;    myFile.print(&quot;####START SYSTEMU: &quot;);&#xA;    myFile.print(godz);&#xA;    myFile.print(data);&#xA;    myFile.print(&quot; ####&quot;);&#xA;    myFile.println(&quot;&quot;);&#xA;    myFile.close();&#xA;  }&#xA;  wylAlarmu();&#xA;}&#xA;&#xA;void loop() {  &#xA;  btnON = digitalRead(BTNON);&#xA;  btnOFF = digitalRead(BTNOFF); &#xA;  pirD = digitalRead(PIR_PIN);&#xA;&#xA;  if(btnON == HIGH) {&#xA;    wlAlarmu();&#xA;    delay(2000);&#xA;  }&#xA;  if(btnOFF == HIGH) {&#xA;    wylAlarmu();&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  if(pirD==HIGH &amp;amp;&amp;amp; stan_alarmu==true) {&#xA;    alarm();&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8266" LastEditorUserId="4628" LastEditDate="2017-11-29T14:00:00.047" LastActivityDate="2018-08-03T16:22:12.827" Title="RTC and SD work separately but not together" Tags="|arduino-mega|sd-card|rtc|" AnswerCount="6" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9857" PostTypeId="1" AcceptedAnswerId="9858" CreationDate="2015-04-05T11:27:50.980" Score="9" ViewCount="12479" Body="&lt;p&gt;I like having serial communication for debugging and testing purposes but after a while it takes away too much speed from the sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have the Arduino ignore serial.print and serial.println throughout my code, without turning it into a comment or placing every serial printing inside for example &quot;if(debug == true)&quot; statements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8268" LastActivityDate="2015-09-19T13:02:33.223" Title="Can I make the Arduino ignore serial print" Tags="|serial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9858" PostTypeId="2" ParentId="9857" CreationDate="2015-04-05T11:34:27.403" Score="15" Body="&lt;p&gt;If you insist on top performance, the best thing would be to use a macro for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Sprintln(a) (Serial.println(a))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;Hello world!&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;write &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sprintln(F(&quot;Hello world!&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc. To deactivate the &lt;code&gt;Serial&lt;/code&gt; printing, define the macro empty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Sprintln(a) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will have the preprocessor remove all debugging code defined with &lt;code&gt;Sprintln&lt;/code&gt; from your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Of course, there's a huge number of variations on this theme.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-04-05T11:49:58.140" LastActivityDate="2015-04-05T11:49:58.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9859" PostTypeId="2" ParentId="9857" CreationDate="2015-04-05T12:31:48.470" Score="7" Body="&lt;p&gt;You could, for example, use the preprocessor to change all &lt;code&gt;Serial&lt;/code&gt; in your code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef ENABLE_PRINT&#xA;// disable Serial output&#xA;#define Serial SomeOtherwiseUnusedName&#xA;static class {&#xA;public:&#xA;    void begin(...) {}&#xA;    void print(...) {}&#xA;    void println(...) {}&#xA;} Serial;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1323" LastEditorUserId="1323" LastEditDate="2015-04-05T19:48:50.713" LastActivityDate="2015-04-05T19:48:50.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9860" PostTypeId="1" CreationDate="2015-04-05T16:10:24.113" Score="3" ViewCount="2246" Body="&lt;p&gt;I have a specific problem :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm working on a testing platform. It has to be absolutely isolated, so I cannot wire it back to my PC. I again reiterate it. There is no way to wire it to my PC. IT HAS TO BE ABSOLUTELY ISOLATED&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It has about 10 different sensors on it and I need to read sensor's data simultaneously at 100Hz.  It is currently working fine with 16Hz, but I need to improve it further, so I think maybe in future sampling rates higher than 100 is beneficial. 7 Hz is the lowest possible value that doesn't botch the whole things up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a laptop on the platform which reads the sensor data via RS232, then it processes them in a fraction of a second and produce a control signal and send it to the actuators. It has to happen at real-time. Control algorithm is not heavy, it is several PIDs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It has 6 actuators with the fastest possible reaction time of 0.005 second.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The main sensor currently is &lt;a href=&quot;http://www.microstrain.com/inertial/3DM-GX1&quot; rel=&quot;nofollow&quot;&gt;Microstrain 3DM-GX1&lt;/a&gt;. It is a very good sensors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I want to add a &lt;a href=&quot;http://www.forkrobotics.com/2013/06/using-the-gy80-10dof-module-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;GY-80&lt;/a&gt; sensor in parallel to 3DM-GX1. I want to test various filtering algorithms on the GY-80's output and compare them to 3DM-GX1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Platform has 6 degrees of freedom so I think laser transmission is not practical.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Distance between the computer and the platform is at most 3 meters.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For some reasons I am not able to use the laptop anymore. I want to read the sensor's data with an Arduino, preferably Arduino Mega 2560. My problem is that I don't want to load the control algorithm to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO the perfect solution is going to be a Wireless link between the Sensors via Arduino to my PC. This way my PC logs data and also the Control Algorithm can promptly calculate the feedback signal and send it to Arduino which will send them to the actuators. This immensely makes things easier for me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need a RS232 shield for the 3DM-GX1 &amp;amp; Arduino, + some wireless solution for sending data from both sensors to my computer. Then I need to send back the control signal back to the actuators wirelessly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what is the fast and easy way to transmit the data between PC and Arduino in real-time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="8269" LastEditorUserId="8269" LastEditDate="2015-04-16T05:08:39.327" LastActivityDate="2016-06-22T16:29:30.520" Title="What is the fastest and easiest way to transmit arduino's sensor data to a PC wirelessly" Tags="|sensors|wifi|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9861" PostTypeId="2" ParentId="3926" CreationDate="2015-04-05T19:11:20.877" Score="3" Body="&lt;p&gt;Looking further here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,188236.0.h&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,188236.0.h&lt;/a&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Removing &#xA;the files - libraries\RobotIRremote\IRremoteTools.cpp and &#xA;libraries\RobotIRremote\IRremoteTools.h solved the problem. They are&#xA;example files which somehow are getting included. You can move those two &#xA;files to some other location as backup.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went to my libraries &#xA;file and did this and can confirm that the example given above then &#xA;compiles fine without downloading a new library. Its an Arduino &#xA;libraries problem .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way will work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Remote-Control-Light-switch-ARDUINO/&quot; rel=&quot;nofollow&quot;&gt;answer from here and worked for me&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;int input_pin = 10; //set D10 as input signal pin&#xA;IRrecv irrecv(input_pin);&#xA;decode_results signals;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    irrecv.enableIRIn(); // enable input from IR receiver&#xA;}&#xA;void loop() {&#xA;if (irrecv.decode(&amp;amp;signals)) {&#xA;        Serial.println(signals.value, HEX);&#xA;        irrecv.resume(); // get the next signal&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8273" LastActivityDate="2015-04-05T19:11:20.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9862" PostTypeId="1" CreationDate="2015-04-05T19:30:38.710" Score="3" ViewCount="7962" Body="&lt;p&gt;I need to put my arduino into the sleep mode in order to consume less power. My arduino receives IR data and do some work with it, but I need to make it sleep until there is no data. If the data has appeared it should wake up and do something with data and go back to sleep mode.&lt;br&gt;&#xA;Is there any way to do this.&lt;br&gt;&#xA;I would be grateful for any help.&lt;/p&gt;&#xA;" OwnerUserId="7757" LastActivityDate="2015-09-22T07:54:14.993" Title="IR Receiver interrupt and arduino sleep mode" Tags="|interrupt|arduino-pro-mini|ir|sleep|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9863" PostTypeId="2" ParentId="9862" CreationDate="2015-04-05T19:46:09.583" Score="-1" Body="&lt;p&gt;Connect the IR receiver to INT0 or INT1 (pins 2 or 3 respectively). You can use the &lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;attachInterrupt&lt;/a&gt; function. E.g. attachInterrupt(0, yourfunctionname, LOW). The function being called can be empty, if you only use it to wake up the MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To wake from sleep you need to use the LOW trigger mode. Once waken up you probably want to remove the interrupt handler (&lt;code&gt;detachInterrupt&lt;/code&gt;), or it will swamp the cpu with interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note that most IR receiver will still use something like 3mA.)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-05T19:46:09.583" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9864" PostTypeId="1" AcceptedAnswerId="9869" CreationDate="2015-04-05T20:07:41.950" Score="2" ViewCount="11596" Body="&lt;p&gt;I have this array of bytes, that I need to convert to an array of unsigned ints. Also the function (&lt;code&gt;btea&lt;/code&gt;) that needs it, seems to need a pointer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently using &lt;code&gt;reinterpret_cast&lt;/code&gt; which seems to work, but I'd like to know how/why. I'm pretty new to &lt;code&gt;C&lt;/code&gt;. It also seems kind of dirty. I could use a for loop, and bitshift everything into a separate int array variable, but that seems wasteful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t data[] = {1,2,3,4,5,6,7,8};//can be any multiple of 4 bytes&#xA;&#xA;btea(reinterpret_cast&amp;lt;uint32_t*&amp;gt;(data), sizeof(data)/4, encryption_key);&#xA;&#xA;radio.write(data, sizeof(data));&#xA;&#xA;...&#xA;&#xA;void btea(uint32_t *v, int n)&#xA;{&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any pointers (pun intended) are much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-06T01:03:44.633" Title="Convert uint8_t array to uint32_t array" Tags="|atmega328|c|data-type|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9865" PostTypeId="2" ParentId="9864" CreationDate="2015-04-05T21:10:23.333" Score="3" Body="&lt;p&gt;I prefer to use unions. example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union fourbyte {&#xA;  uint32_t dword;&#xA;  uint16_t word[2];&#xA;  uint8_t  byte[4];&#xA;};&#xA;&#xA;union fourbyte val;&#xA;&#xA;val.dword = 0x03020100;&#xA;&#xA;Serial.println(val.byte[0], HEX);&#xA;Serial.println(val.byte[1], HEX);&#xA;Serial.println(val.byte[2], HEX);&#xA;Serial.println(val.byte[3], HEX);&#xA;&#xA;Serial.println(val.word[0], HEX);&#xA;Serial.println(val.word[1], HEX);&#xA;&#xA;Serial.println(val.dword, HEX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="60" LastEditorUserId="60" LastEditDate="2015-04-05T21:15:36.843" LastActivityDate="2015-04-05T21:15:36.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9866" PostTypeId="2" ParentId="8674" CreationDate="2015-04-05T22:03:17.463" Score="1" Body="&lt;p&gt;The answer is :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I combined all my &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;&amp;lt;b&amp;gt;&amp;lt;font size=+1 color='#CC33FF'&amp;gt;Some text here&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;html statements into much longer statements eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;&amp;lt;b&amp;gt;&amp;lt;font size=+1 color='#CC33FF'&amp;gt;Some text here&amp;lt;/font&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;a href=\'?s4-all-on' target='x2'&amp;gt;All On&amp;lt;/a&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;a href='/?s4-all-off' target='x2'&amp;gt;All Off&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;a href='/?s4-1on' target='x2'&amp;gt;Socket 1 On&amp;lt;/a&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;a href='/?s4-1off' target='x2'&amp;gt;Socket 1 Off&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This reduced the number of client.println(&quot;  &quot;);  statements by about one third, which resolved the issue.&lt;/p&gt;&#xA;" OwnerUserId="7360" LastActivityDate="2015-04-05T22:03:17.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9867" PostTypeId="1" AcceptedAnswerId="9871" CreationDate="2015-04-05T22:40:32.647" Score="7" ViewCount="463" Body="&lt;p&gt;What should I do to have an Arduino Pro Mini 5V (clone) powered by a 5V solar panel during the day and by battery during night which will be charged during the day by the solar panels.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;is there any guide out there?&lt;/li&gt;&#xA;&lt;li&gt;is it possible with the 5V version of Arduino Pro Mini or will I have to buy the 3.3V&lt;/li&gt;&#xA;&lt;li&gt;I prefer to make the circuits by myself rather than buying them (for example: the charging circuit.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8275" LastEditorUserId="6936" LastEditDate="2015-07-30T18:44:03.790" LastActivityDate="2015-07-30T18:44:03.790" Title="Day-night powered Arduino" Tags="|battery|solar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9868" PostTypeId="1" CreationDate="2015-04-05T22:54:12.140" Score="0" ViewCount="2299" Body="&lt;p&gt;I have an Arduino Uno R3 and when I plug it into any computer, the computer doesn't recognize the Arduino. I checked up and the LEDs are working fine and when I open the device manager it doesn't show any &lt;code&gt;Unkown Device&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it could be? Could the ATMega be dead? I tried on two Windows 7 and one Linux machines, none recognized the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="8276" LastEditorUserId="4628" LastEditDate="2017-11-28T12:22:18.093" LastActivityDate="2017-11-28T12:22:18.093" Title="Arduino is not recognized by any computer" Tags="|arduino-uno|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ClosedDate="2017-11-30T04:17:51.320" ContentLicense="CC BY-SA 3.0" />
  <row Id="9869" PostTypeId="2" ParentId="9864" CreationDate="2015-04-06T01:03:44.633" Score="3" Body="&lt;p&gt;@mpflaga's answer gives a great alternative, but I thought I'd explain why your code works (grossly simplified). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the reinterpret cast does is let the compiler know how wide of a variable it assumes is in each element of the array.  When you access &lt;code&gt;data[1]&lt;/code&gt;, it uses one byte at an offset of one byte from &lt;code&gt;data[0]&lt;/code&gt;.  When you cast to uint32_t and access &lt;code&gt;data[1]&lt;/code&gt;, it uses 4 bytes at an offset of 4 bytes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your memory looks like this (each square is one byte)...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gec1a.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...before the cast you are interpreting it as the top layout, after the cast you interpret it as the bottom layout.  It's still exactly the same in memory, you're just telling the compiler to use it differently. The reason that using a union is better is that it is safer.  Your code would read garbage after the end of the array if its length &lt;em&gt;wasn't&lt;/em&gt; divisible by 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other quick note, be careful with the sizeof() operator on arrays - it always gives the length in bytes regardless of the element size.&lt;/p&gt;&#xA;" OwnerUserId="8216" LastActivityDate="2015-04-06T01:03:44.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9870" PostTypeId="2" ParentId="9868" CreationDate="2015-04-06T01:06:15.677" Score="3" Body="&lt;p&gt;The reason that it is not connecting can be anything from wrong driver installation to the dead Atmega 16u2 chip. But I must exclude the former option as you said you'd tried on different OS and different computers. So double check the driver installation. And if does not work try to find out whether Atmega16u2 is fried or not. One solution might be to reflash the original firmware through an external ICSP programmer. If don't have any programmer but another arduino uno you might try out the gamon's tutorial on flashing firmware on the little USB to serial interface chip.&#xA;Anyway if your arduino is new and official you can get the right support online on arduino.cc. but if it is a clone you may try to contact the reseller whom you bought from.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-04-06T01:06:15.677" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9871" PostTypeId="2" ParentId="9867" CreationDate="2015-04-06T02:06:16.310" Score="9" Body="&lt;p&gt;This would be better answered on Stack Exchange Electrical Engineering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;https://arduino.stackexchange.com/questions/665/powering-arduino-with-solar-panels?rq=1&quot;&gt;see this question and answers&lt;/a&gt;. This is not quite the same and the answers there are OK but less than complete or correct, but it adds to the resource available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a battery charging controller, a PV (solar) panel capable of producing somewhat more than maximum battery voltage and enough energy to operate your circuit and a battery with enough voltage to operate the device and enough capacity to store the energy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current drain will vary with total circuit. You can measure this will a milliammeter. I'll assume that 50 mA continuous will be enough. Less or much less may suffice. I have a pro mini clone operating at 20 mA on 5V at present and with due care you may be able to operate one with less or much less current depending on application and what your circuit needs are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at solar current needs at present, the average solar current needed is about Icircuit x 24/SSH mA where SSH = average sunshine hours per day. eg if you had 4 hours of sunshine per day but want to run the circuit for 24 hours a day the sun must provide (24 hours per day)/(4 hours of sun) = 6 x as much current as the circuit needs on average. So if your circuit needs 50 mA continuous the PV panel must provide 6 x 50 mA = 300 mA for 4 hours per day. You will see below that this is not a trivial amount. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sunshine hours per day may be found for sites worldwide using the excellent www.gaisma.com The &lt;a href=&quot;http://www.gaisma.com/en/location/iraklion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;average sunshine hours per day for Iráklion&lt;/strong&gt;&lt;/a&gt; may be found at that link and other locations in Greece can be found &lt;a href=&quot;http://www.gaisma.com/en/dir/gr-country.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; but will probably be similar.&lt;br&gt;&#xA;For Iráklion the SSH may be found in the 1st line of the 4th chart.&lt;br&gt;&#xA;Average hours/day of equivalent full sunshine = kWh/m^2/day = a peak of 8.53 hours in June and a low of 2.08 hours in December.&lt;br&gt;&#xA;Wow! &#xA;I think that is about as sunny a place in Summer as anywhere on earth not in the polar regions.  In Winter it gets about the same SSH as in &lt;a href=&quot;http://www.gaisma.com/en/location/manukau.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;my city&lt;/a&gt;. You can calculate PV sizing for peak summer - but if you want year round operation you should use the worst case winter month and add a bit for bad days.&lt;br&gt;&#xA;For Iraklion us say 2 SSH per day so the panels needs to provide 24/2 = 12 x winter average load. So per 10 mA of load yo need 120 mA of panel and if the mean load is 50 mA you need 12 x 50 = 300 mA panel output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Battery voltage needs to be &gt; 5V at all times.&lt;br&gt;&#xA;An easy cheap available starting solution is to use a 6B lead acid battery.&#xA;These are easyish to charge and provide a relatively stable operating voltage.&lt;br&gt;&#xA;Vmax_charge is &lt;strong&gt;about&lt;/strong&gt; 7V so an 8V or 9V PV panel is &quot;about right&quot;. 9V is a common voltage for hobby applications. An alternative is to use a 12V panel. this is probably more suitable as they are widely available and cost per energy out is often lower. This wastes MOST of the panel output but still MAY be the cheapest option in many cases. (A 12V x 600 mA panel is rated at about 18V x 0.6A ~= 10 Watts. Actual Arduino load = 50 mA x 5V x 12:1 = 3 Watts) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 50 mA load you need 24/2 x 50 mA = 600 mA PV output in full sun.&lt;br&gt;&#xA;PV panel sizing is not as may be expected. It is easiest to get a panel that makes at least enough voltage and enough current. This is because panel RATED voltages are usually higher than the voltages they are used at. eg 12V system PV panels are usually rated at 18V max power voltage- so an 18W panel provide 18V at 1 A BUT if attached directly to a 12V battery the input to the battery = 12V x 1A = 12 Watts. There are ways around this but at first, just concentrate on panel mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you &quot;need&quot; a 600 mA panel for a 50 mA load.&lt;br&gt;&#xA;Or a 60 mA panel for a 5 mA load.&lt;br&gt;&#xA;Or a 6 mA panel for a 0.5 mA load.&lt;br&gt;&#xA;Obviously, reducing load current is going to help panel sizing.&lt;br&gt;&#xA;So knowing what your application really needs is essential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Batery is easier.&lt;br&gt;&#xA;If you use 6V lead acid then for one day you need.&lt;br&gt;&#xA;Hours x load = mAh.&lt;br&gt;&#xA;Here load=24 hours. mA = 50 in this example.&lt;br&gt;&#xA;mAh = 24 x 50 mA =  1200 mAh = 1.2 Ah. This is the capacity of about the smallest LA battery commonly available. In practice you want to discharge your battery by only a small % of its actual capacity so use a 2.4 Ah or 3.5 Ah or larger. 7Ah is not vastly dearer and will last far longer and will have several days of reserve capacity for bad weather.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Charging can now be discussed - but I'll stop here and see what is said about the above. We can add charging and other detail if it seems useful to do so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/F3oG9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy battery to use is 2 x LiIon or LiPo cells in series. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-06T02:06:16.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9873" PostTypeId="1" CreationDate="2015-04-06T07:47:48.417" Score="1" ViewCount="5116" Body="&lt;p&gt;Does using the delay function use any less power than spinning in a polling loop on a timer?&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2015-05-07T04:19:58.933" Title="Delay versus polling power consumption?" Tags="|power|timers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9874" PostTypeId="2" ParentId="9873" CreationDate="2015-04-06T08:46:53.290" Score="1" Body="&lt;p&gt;The answer is probably &quot;they are equal&quot; because what the CPU is doing is less than 1% of power draw. In order to save power while waiting you can put the chip to sleep. Assuming you have an Arduino uno, this post contains sample code about sleeping and current consumption. &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=78430.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=78430.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe explain what you are doing (what size battery you have) and we can add some advice about ways to save power &lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-04-06T08:46:53.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9875" PostTypeId="2" ParentId="8842" CreationDate="2015-04-06T08:51:54.613" Score="0" Body="&lt;p&gt;Cypress makes very small usb chips capable of host mode. Does this board meet your size requirements? &lt;a href=&quot;http://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8CKIT-049-41XX/?qs=FSHIiqjonm0YmFbmBQfo1A%3D%3D&amp;amp;kpid=1159933375&amp;amp;gclid=CPjl6KOm4cQCFYGUfgodJh4A_g&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8CKIT-049-41XX/?qs=FSHIiqjonm0YmFbmBQfo1A%3D%3D&amp;amp;kpid=1159933375&amp;amp;gclid=CPjl6KOm4cQCFYGUfgodJh4A_g&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also consider ditching the arduino and running everything on the cypress&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-04-06T08:51:54.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9876" PostTypeId="2" ParentId="9860" CreationDate="2015-04-06T08:56:28.650" Score="1" Body="&lt;p&gt;The fastest way would be to use a laser link!! Yeah lasers. You could go with wifi or some other custom wireless but lasers will guarantee the highest energy density and therefor best bandwidth.  This guy claims near 10 MB/s with his setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Laser-Transceiver/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Laser-Transceiver/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-04-06T08:56:28.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9877" PostTypeId="1" AcceptedAnswerId="9879" CreationDate="2015-04-06T12:13:19.783" Score="1" ViewCount="4360" Body="&lt;p&gt;Does anyone know if you can set the time for the timeout Ethernet Shield library? Let me explain:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a very simple function (below) that attempts to connect to an address if it is not accessible returns 0 if it is available returns 1. Problem is that when the site is not available, the microcontroller is waiting for an answer for a long time, wanted to reduce it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t ping(const char* address)&#xA;{&#xA;    EthernetClient http;&#xA;&#xA;    if(http.connect(address, 80)) {&#xA;        http.stop();&#xA;        return 1;&#xA;    }&#xA;    else &#xA;        return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-04-06T14:03:10.843" Title="Set the timeout - Ethernet Shield library" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9879" PostTypeId="2" ParentId="9877" CreationDate="2015-04-06T14:03:10.843" Score="0" Body="&lt;p&gt;In the stream class there is a setTimeout(ms) function. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str;&#xA;Serial.setTimeout(5000) ;&#xA;str = Serial.readStringUntil('\r');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where this does timeout the initial connection attempt in http.connect(). Whereas I found it also important to timeout each line, as a web page may not disconnect at the end or not send anything.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int httpGetHeaders() {&#xA;  String request, response;&#xA;  int result = 0;&#xA;  long startOfHttpResponseTime;&#xA;&#xA;  client.setTimeout(1000) ;&#xA;  response = &quot;&quot;;&#xA;  inHeaders = true;&#xA;  startOfHttpResponseTime = millis();&#xA;  while((client.connected()) &amp;amp;&amp;amp; inHeaders &amp;amp;&amp;amp; ((long)(millis() - startOfHttpResponseTime) &amp;lt; HTTP_RESPONSE_TIMEOUT)) {&#xA;    String header = client.readStringUntil('\n');&#xA;    header.trim(); // trim off white spaces including CR and LF at end.&#xA;    Serial.print(F(&quot;head[&quot;)); &#xA;    Serial.print(header.length()); &#xA;    Serial.print(F(&quot;]:\&quot;&quot;)); &#xA;    Serial.print(header);&#xA;    Serial.println(F(&quot;\&quot;&quot;)); &#xA;    if (!header.length()) { // first blank line indicates end of headers&#xA;      inHeaders = false;&#xA;      Serial.println(F(&quot;No longer in Headers&quot;)); &#xA;    }&#xA;    else {&#xA;      if (header.startsWith(&quot;HTTP&quot;)) {&#xA;        Serial.println(F(&quot;HTTP Found&quot;)); &#xA;        int firstspace = header.indexOf(&quot; &quot;);&#xA;        result = header.substring(firstspace + 1, header.indexOf(&quot; &quot;, firstspace + 1)).toInt();&#xA;        Serial.print(F(&quot;result = &quot;)); &#xA;        Serial.println(result); &#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;Result code = &quot;));&#xA;  Serial.println(result);&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may want to review the whole code at &lt;a href=&quot;https://github.com/lansing-makers-network/StatusBotArduino/blob/master/StatusBotArduino.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/lansing-makers-network/StatusBotArduino/blob/master/StatusBotArduino.ino&lt;/a&gt; I have reduced the connection to a sequence of commands that can be used consectutively in the desired order to meet different needs. The above is just to read a headers response.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-04-06T14:03:10.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9880" PostTypeId="1" CreationDate="2015-04-06T15:10:55.113" Score="0" ViewCount="173" Body="&lt;p&gt;I have a functionality on my mega 2560 to connect with other devices. Sometimes, devices can't answer. I don't want to wait for a longwhile. So, how can I interrupt the chunk of program after the specific amount of time? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code for receiving messages is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (!(UCSR1A &amp;amp; (1&amp;lt;&amp;lt;RXC1)));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so, &lt;code&gt;millis&lt;/code&gt; can't solve my problem because I haven't ability to check for conditional loops like that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(currentMillis - previousMillis &amp;gt; interval) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-12-02T20:12:45.320" Title="How to interrupt a code after delay" Tags="|serial|arduino-mega|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9881" PostTypeId="2" ParentId="9880" CreationDate="2015-04-06T15:22:26.697" Score="1" Body="&lt;p&gt;OMG, I was stupid. I can just place millis in this &lt;code&gt;while&lt;/code&gt; condition.&lt;/p&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2015-04-06T15:22:26.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9882" PostTypeId="1" CreationDate="2015-04-06T17:19:36.950" Score="1" ViewCount="2465" Body="&lt;p&gt;I'm trying to connect my Arduino Uno with MySQL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;sha1.h&amp;gt;&#xA;#include &amp;lt;mysql.h&amp;gt;&#xA;&#xA;/* Setup for Ethernet Library */&#xA;byte mac_addr[] = { 0xC8, 0x0A, 0xA9, 0xAF, 0x83, 0x58 }; &#xA;IPAddress server_addr(192,168,0,102);&#xA;&#xA;/* Setup for the Connector/Arduino */&#xA;Connector my_conn; // The Connector/Arduino reference&#xA;char user[] = &quot;root&quot;;&#xA;char password[] = &quot;fifa2005&quot;;&#xA;char INSERT_SQL[] = &quot;INSERT INTO test_arduino.hello VALUES ('Hello from Arduino!', NULL)&quot;;&#xA;&#xA;void setup() {&#xA;Ethernet.begin(mac_addr);&#xA;Serial.begin(115200);&#xA;delay(1000);&#xA;Serial.println(&quot;Connecting...&quot;);&#xA;if (my_conn.mysql_connect(server_addr, 3306, user, password))&#xA;delay(500);&#xA;else&#xA;Serial.println(&quot;Connection failed.&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the following database:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mysql&amp;gt; CREATE DATABASE test_arduino;&#xA;Query OK, 1 row affected (0.00 sec)&#xA;mysql&amp;gt; USE test_arduino;&#xA;Database changed&#xA;mysql&amp;gt; CREATE TABLE hello (source char(20), event_date timestamp);&#xA;Query OK, 0 rows affected (0.01 sec)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connecting... Connection failed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not sure this is the right IP address: &lt;code&gt;192,168,0,102&lt;/code&gt;. I tried with the localhost IP address - &lt;code&gt;127.0.0.1&lt;/code&gt;, but nothing happened.&lt;/p&gt;&#xA;" OwnerUserId="8289" LastEditorUserId="6936" LastEditDate="2016-03-27T11:38:13.567" LastActivityDate="2016-03-27T11:38:13.567" Title="Arduino Uno, Ethernet shield, MySQL" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9883" PostTypeId="1" CreationDate="2015-04-06T20:34:19.353" Score="2" ViewCount="3775" Body="&lt;p&gt;I am trying to build a quadcopter using an arduino. I Bought 4 30A ESC's from Ebay the link is &lt;a href=&quot;http://www.ebay.co.uk/itm/4pcs-Brushless-speed-controller-ESC-MultiCopter-KK-Quad-rotor-X-copter-30A-S-/310950293677?pt=LH_DefaultDomain_3&amp;amp;hash=item486614f0ad&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/4pcs-Brushless-speed-controller-ESC-MultiCopter-KK-Quad-rotor-X-copter-30A-S-/310950293677?pt=LH_DefaultDomain_3&amp;amp;hash=item486614f0ad&lt;/a&gt; and a A2212 2200KV motor, im also using a sparkfun arduino uno. I have connected the white (data) servo wire of the ESC to pin 9 of my arduino and the black (ground) servo wire of the ESC to gnd of the arduino. When i connect the battery to the esc i get the 3 beeps because of my 3 cell battery regardless of what code is on the arduino even if the arduino is not present. the code that is on the arduino is. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo motor;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  motor.attach(0);&#xA;}&#xA;void loop()&#xA;{&#xA;  motor.write(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what is wrong. Can someone please help me.&lt;/p&gt;&#xA;" OwnerUserId="7790" OwnerDisplayName="Root0x" LastActivityDate="2016-01-09T18:31:27.020" Title="Control Brushless ESC From Arduino" Tags="|motor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9884" PostTypeId="1" CreationDate="2015-04-06T23:20:02.307" Score="1" ViewCount="1751" Body="&lt;p&gt;I have a &lt;strong&gt;Bluetooth device&lt;/strong&gt; from Sparkfun which I would like to use with the &lt;strong&gt;Arduino Mega&lt;/strong&gt;. If I connect the module via the hardware serial pin everything works fine but when I use other pins like 12 and 13 with &lt;strong&gt;SoftwareSerial&lt;/strong&gt;, the communication doesn't work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;THE CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int bluetoothTx = 12;&#xA;int bluetoothRx = 13;&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup()&#xA;{&#xA;  //Setup usb serial connection to computer&#xA;  Serial.begin(9600);&#xA;&#xA;  //Setup Bluetooth serial connection to android&#xA;  bluetooth.begin(115200);&#xA;  bluetooth.print(&quot;$$$&quot;);&#xA;  delay(100);&#xA;  bluetooth.println(&quot;U,9600,N&quot;);&#xA;  bluetooth.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Read from bluetooth and write to usb serial&#xA;  if(bluetooth.available())&#xA;  {&#xA;    char toSend = (char)bluetooth.read(); &#xA;    Serial.print(&quot; Receiving: &quot;);&#xA;    Serial.println(toSend);&#xA;  }&#xA;&#xA;  //Read from usb serial to bluetooth&#xA;  if(Serial.available())&#xA;  {&#xA;    char modeS = Serial.read(); &#xA;    Serial.print(&quot; Writing Blu: &quot;);&#xA;    Serial.println(modeS);&#xA;    bluetooth.print(modeS);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using an Android App (BlueTerm) to test the communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I get when sending a letter from Android to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Receiving: ÿ&#xA; Receiving: ÿ&#xA; Receiving: ÿ&#xA; Receiving: ÿ&#xA; Writing Blu: d&#xA; Writing Blu: d&#xA; Writing Blu: d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not able to receive anything from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried decreasing the baudrate but nothing changed. Do you have any advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried without the following lines but nothing changed... It seems that the module can be used only with the hardware serial pins 0 and 1... It's a shame&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bluetooth.print(&quot;$$$&quot;);&#xA;delay(100);&#xA;bluetooth.println(&quot;U,9600,N&quot;);&#xA;bluetooth.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4396" LastEditorUserId="4396" LastEditDate="2016-03-18T16:07:45.927" LastActivityDate="2016-03-18T16:07:45.927" Title="Wrong characters received with Bluetooth Mate Gold using Software Serial" Tags="|serial|arduino-mega|bluetooth|softwareserial|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9885" PostTypeId="2" ParentId="9873" CreationDate="2015-04-07T03:40:55.733" Score="3" Body="&lt;p&gt;That depends very much on how delay() was written (and how it will be written in the future!). There are &quot;sleep modes&quot;, which will reduce the power consumption of the arduino - these are one of the best way to reduce power consumption. Delay() may or may not activate these. If not, there could be a replacement Delay() function that could do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to reduce power, check out &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt; - this is an excellent step-by-step tutorial on how to reduce power consumption from 50mA down to 288 µA&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-04-07T03:40:55.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9886" PostTypeId="1" CreationDate="2015-04-07T04:42:21.100" Score="0" ViewCount="4708" Body="&lt;p&gt;Can I charge a 4.2&amp;nbsp;V battery with a 5&amp;nbsp;V adapter without damaging the battery?&lt;/p&gt;&#xA;" OwnerUserId="8298" LastEditorUserId="510" LastEditDate="2015-04-07T21:08:05.047" LastActivityDate="2015-04-07T21:08:05.047" Title="Can I charge a 4.2 V battery with a 5 V adapter?" Tags="|gsm|usb|battery|" AnswerCount="2" CommentCount="2" ClosedDate="2015-04-07T21:42:21.053" ContentLicense="CC BY-SA 3.0" />
  <row Id="9887" PostTypeId="1" CreationDate="2015-04-07T04:51:16.727" Score="0" ViewCount="747" Body="&lt;p&gt;Is it possible to hook up a GSM/GSRM module &lt;em&gt;AND&lt;/em&gt; an SD card at the same time to an Arduino Uno, or any Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to build a cellphone to read off the buttons that are being dialed into it for a poor guy who has no hope of using a regular cellphone, and I figure I need to include wav files for the buttons (and any other functions) on an external source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a good programmer, so if I can hobble the parts together I can make them talk to each other.  But, I'm not so sure the different schemes for this all use the same pins, so I was wondering if someone would be so kind as to enlighten me..&lt;/p&gt;&#xA;" OwnerUserId="8299" LastEditorUserId="8299" LastEditDate="2015-04-07T04:58:40.100" LastActivityDate="2022-12-04T06:06:15.650" Title="Is is possible to hook up an SD card and a GSM/GSRM module?" Tags="|arduino-uno|gsm|sd-card|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9888" PostTypeId="1" CreationDate="2015-04-07T07:01:08.670" Score="0" ViewCount="2351" Body="&lt;p&gt;I have a string which I send to the arduino using serial monitor. Something like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;my specific string 0x0F 0x2C 0x98 0xBC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I parse this string in the arduino to get an array of hex values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x0F 0x2C 0x98 0xBD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;? There are two prerequisites:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;All hexadecimal starts with &lt;code&gt;#&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;The size of hexadecimal is 2. No &lt;code&gt;0x111&lt;/code&gt; or '0xbbb'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7852" LastActivityDate="2016-02-10T15:58:38.863" Title="Convert string plus hexadecimals to array of hex:" Tags="|c++|arduino-ide|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9889" PostTypeId="2" ParentId="9886" CreationDate="2015-04-07T07:08:28.103" Score="1" Body="&lt;p&gt;No. You must use a charger properly designed for the battery; attempting to connect a Li-ion battery directly to a USB charger will damage the battery, possibly catastrophically.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-07T07:08:28.103" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9890" PostTypeId="1" AcceptedAnswerId="9912" CreationDate="2015-04-07T07:42:17.817" Score="-1" ViewCount="441" Body="&lt;p&gt;I have a 5.1 home theater(old one), I would like to transform it into a audio streaming system. I have a Arduino UNO and HC-05 Bluetooth Module, and I don't know how to install it in my home theater(if it does). solution please... &lt;/p&gt;&#xA;" OwnerUserId="8302" LastActivityDate="2019-09-30T14:08:41.010" Title="Install Bluetooth inside a home theater, How?" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9891" PostTypeId="2" ParentId="9887" CreationDate="2015-04-07T07:55:22.040" Score="-1" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But let me try to talk you through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 1 - Analysis/Requirements:&lt;/strong&gt;&#xA;Get your requirements right, what should your system do, what functionality.&#xA;So, GSM functionalities and SD card savings (in short).&#xA;One of the requirements would be that's it on an Arduino (atmega 328P).&#xA;Any other hardware requirements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 2 - Design:&lt;/strong&gt;&#xA;Check the possibilities with the Arduino, 1 hardware serial and multiple software serial connections. One hardware SPI/I2C I believe.&#xA;SD cards often use SPI connection and GSM units most likely use serial.&#xA;So this works great. Check some tutorials on SPI and (arduino) serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3 - Wiring up&lt;/strong&gt;&#xA;Wire everything up, as defined in the datasheet of the devices. Cross the Rx and Tx lines. Put MISO to MISO and MOSI to MOSI accordingly.&#xA;Be sure everything has enough power (GSM modules typically draw a lot of current when sending/connecting). Usually, if you find out that two devices are attached to the same pin, there might be something wrong (unless you can declare how they're seperated or why this is the case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 4 - Implement&lt;/strong&gt;&#xA;Well, you stated you're good at programming, so I'll leave this open for you.&#xA;But mind that it's only one of the three steps, so you should look at some tutorials, it'll learn a lot faster than asking everything. Try to get a bit comfortable with your thoughts, base them on things you have learned.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So this shouldn't be an issue? Those pins aren't shared? - user1833028&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Things like this can be found in the device's datasheet and if you follow some tutorials you'll see that they're different and why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what helps for me often, is to try to seperate this 'big' project into two smaller projects.&#xA;Try to get the GSM working and after that you go for the SD card reader.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-07T07:55:22.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9892" PostTypeId="5" CreationDate="2015-04-07T08:41:22.833" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-07T08:41:22.833" LastActivityDate="2015-04-07T08:41:22.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9893" PostTypeId="4" CreationDate="2015-04-07T08:41:22.833" Score="0" Body="A small microcontroller board based on the ATmega168 or ATmega328 chip. Use this tag for questions specifically regarding the Mini, and not just general Arduino usage." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-04-07T18:13:02.083" LastActivityDate="2015-04-07T18:13:02.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9894" PostTypeId="1" CreationDate="2015-04-07T09:26:51.860" Score="3" ViewCount="141" Body="&lt;p&gt;I have seen people using ATtiny45 and other boards and there are hardware configurations files for them. Can we use ATtiny48 as a processor for Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so where can I get a boards.txt file that supports it? Alternatively how can I write such a file?&lt;/p&gt;&#xA;" OwnerUserId="3277" LastEditorUserId="6452" LastEditDate="2015-04-07T10:09:22.997" LastActivityDate="2015-04-08T05:43:30.490" Title="Can I use ATtiny48 as a board in Arduino?" Tags="|hardware|" AnswerCount="0" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9895" PostTypeId="1" CreationDate="2015-04-07T10:10:08.420" Score="2" ViewCount="182" Body="&lt;p&gt;I was reading about using an &lt;a href=&quot;http://thinkingonthinking.com/an-arduino-sketch-from-scratch/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino with a Makefile&lt;/a&gt;. In the &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow noreferrer&quot;&gt;Makefile-Arduino&lt;/a&gt; project there is a reference to the Python serial library required to reset the board.&#xA;Looking into the usage of PySerial to reset the board, there is some reference to &lt;a href=&quot;https://stackoverflow.com/questions/15460865/disable-dtr-in-pyserial-from-code&quot;&gt;DTR&lt;/a&gt; or &lt;a href=&quot;http://johanneshoff.com/arduino-command-line.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is DTR?&lt;/li&gt;&#xA;&lt;li&gt;How to control this bit with node-serial and reset the Arduino?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1484" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-07T10:10:08.420" Title="How to reset an Arduino with node-serial?" Tags="|serial|reset|node.js|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9896" PostTypeId="2" ParentId="9886" CreationDate="2015-04-07T10:51:16.707" Score="2" Body="&lt;p&gt;This question would be a better match to the Stack Exchange Electrical Engineering group. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 4.2V battery is very likely a LiIon or LiPo battery. I'll call it LiPO below as it's easier to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most cellphones and many small electronic device use a single LiPo battery and use a 5V input to charge them. To do this they have internal control circuitry that ensures the battery's specifications are met. You can obtain suitable control electronics (in many cases as a single IC requiring maybe a few external resistors to configure it) and it makes great sense to use such a control circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an emergency you can use a 5V source to charge a 4.2V battery &lt;strong&gt;IF&lt;/strong&gt; you know what you are doing and are able to ensure the battery specifications are adhered to. Failing to stay &quot;in spec&quot; may lead to the traditional LiPo &quot;vent with flame&quot; response, and even if there is no apparent damage the battery life can be greatly or very greatly reduced by out of spec treatment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Key requirements are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;NEVER exceed 4.2V at battery terminals.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;NEVER exceed Ichg_max = manufacturers max charging current.&lt;br&gt;&#xA;This is usually the same value in mA as the battery capacity in mAh.&lt;br&gt;&#xA;ie 1000 mA for a 1000 mAh battery&lt;br&gt;&#xA;3300 mA for a 3300 mAh battery etc&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When charging, EITHER stop charging when battery potential reaches 4.2V OR if you are able to hold the battery AT 4.2V, then stop charging when Ichg falls (under battery control) to say Ichgmax/4.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If Vbattery is under 3.0 V (which it NEVER should be) charge at no more than C/10 (eg  for a 1000 mAh cell) until Vbattery rises to &gt;= 3.0V. If the battery will not rise to 3.0V under C/10 charge it is dead. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;IF you can satisfy ALL these requirements at all times you can charge a LiPo or LiIon battery from 5V without a special charger. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-07T10:51:16.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9897" PostTypeId="1" CreationDate="2015-04-07T11:00:25.197" Score="0" ViewCount="812" Body="&lt;p&gt;I want to introduce a boolean that is the first iteration of loop and then false &#xA;every subsequent iteration. I want it invisible, so I have to modify loop in some way. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="8303" LastEditorUserId="220" LastEditDate="2015-04-10T22:59:43.070" LastActivityDate="2015-04-10T22:59:43.070" Title="Overloading function loop" Tags="|core-libraries|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9899" PostTypeId="1" AcceptedAnswerId="9910" CreationDate="2015-04-07T13:20:38.743" Score="0" ViewCount="8555" Body="&lt;p&gt;I use the Arduino compatible &lt;a href=&quot;http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,1193&amp;amp;Prod=CHIPKIT-WF32&quot; rel=&quot;nofollow&quot;&gt;chipKIT WF32&lt;/a&gt; board. I want to transfer structure data between my board and a Linux PC. Can I do it like the following?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct data d;&#xA;char *tx = (char*)d;&#xA;Serial.print(tx);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if the above code works, the data type size in Arduino and on Linux will vary. Is there a way to serialize the data, like &lt;a href=&quot;https://en.wikipedia.org/wiki/Protocol_Buffers&quot; rel=&quot;nofollow&quot;&gt;Protocol Buffers&lt;/a&gt; on Arduino?&lt;/p&gt;&#xA;" OwnerUserId="8307" LastEditorUserId="4143" LastEditDate="2017-04-22T17:48:40.103" LastActivityDate="2017-04-27T17:42:59.213" Title="Serial structure data transfer between an Arduino and a Linux PC" Tags="|serial|arduino-ide|chipkit|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9900" PostTypeId="1" AcceptedAnswerId="9902" CreationDate="2015-04-07T13:32:30.687" Score="0" ViewCount="2490" Body="&lt;p&gt;i'm trying to understand how to connect this motor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Mitsumi 334P/R AB&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/Mitsumi-334P-R-AB-phase-encoder-encodes-tacho-motor-speed-disk-DC3V-24V-5V-6V-/221702525894?pt=LH_DefaultDomain_0&amp;amp;hash=item339e8013c6&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link to the motor i bought&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UST5F.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;connections are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND - Obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5v - Obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;rest of the connections are a bit confusing to me and i do not want to fry my arduino trying.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;do i need a driver or this looks like a built in one?&lt;/li&gt;&#xA;&lt;li&gt;do i need to add any electrical components like resistors and capacitors ect?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8273" LastEditorUserId="8273" LastEditDate="2015-04-08T06:16:06.900" LastActivityDate="2015-04-08T06:16:06.900" Title="Connecting an AB phase encoder motor to arduino" Tags="|motor|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9902" PostTypeId="2" ParentId="9900" CreationDate="2015-04-07T13:41:21.500" Score="1" Body="&lt;p&gt;It's just a regular motor, with a (optical) rotary encoder inside. So the first two &lt;code&gt;motor&lt;/code&gt; pins are to run the motor. So connect to VCC and GND, or GND and VCC, if you want to run it in reverse. (VCC doesn't have to be 5v; it can be 3v to 30v).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect A and B to a digital input pin. You can see what kind of signal you can expect in the screenshot of the oscilloscope, attached to the ebay-listing. So you can measure the speed, and relative position of the motor-shaft.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-07T13:41:21.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9903" PostTypeId="1" CreationDate="2015-04-07T13:55:55.583" Score="2" ViewCount="420" Body="&lt;p&gt;I bought a Blend Micro (an Arduino Micro with Bluetooth) a few months ago, and after my first experimentation with uploading the Blink sketch something went wrong with the USB connection--it would supply power, but no computer (Windows, OS X or Linux) would show it as a USB device, and Windows would complain that the device was somehow damaged. Anyway, when I plug the board in, it still boots up and runs &quot;Blink&quot; so I'd like to try to still use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a USB-to-FTDI cable, and it would seem fairly straight-forward to use that, but I'm a little uncertain to the appropriate wiring and whether I would need to tell the Arduino software somehow that I was using FTDI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can figure out these connections: (I think)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;black to ground&lt;/li&gt;&#xA;&lt;li&gt;red to 5V (VIN?)&lt;/li&gt;&#xA;&lt;li&gt;orange to RX&lt;/li&gt;&#xA;&lt;li&gt;yellow to TX&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What about green and brown? Do one of those go to RST (Brown?) and MOSI (Green?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured I would ask before accidentally burning something out.&lt;/p&gt;&#xA;" OwnerUserId="8305" LastEditorUserId="2881" LastEditDate="2015-04-07T16:16:23.403" LastActivityDate="2015-04-07T16:16:23.403" Title="FTDI Cable to bypass USB for Arduino (Blend Micro) Programming" Tags="|sketch|arduino-micro|ftdi|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9904" PostTypeId="1" AcceptedAnswerId="9906" CreationDate="2015-04-07T14:59:25.383" Score="2" ViewCount="2380" Body="&lt;p&gt;I've created a function whereby an int ('cleanCount') automatically goes up or down (0-1000) based on the situation. The value changes every few milliseconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the value, I would like to turn on or off LEDs. Let's say for every increment of '100' another LED goes on. So if the value is 359 there are 3 leds on, if It would been 899 there would've been 8 LEDs on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could simply write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (cleanCount &amp;lt;= 100) { // turn on NO LEDs&#xA;    digitalWrite(led1, LOW);&#xA;    digitalWrite(led2, LOW);&#xA;    ...&#xA;}&#xA;&#xA;...&#xA;&#xA;else if (cleanCount &amp;lt;= 500) { // turn on 4 LEDs&#xA;    ...&#xA;    digitalwrite(led3, HIGH);&#xA;    digitalwrite(led4, HIGH);&#xA;    digitalwrite(led5, LOW);&#xA;    digitalwrite(led6, LOW);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that would be a big pile of code which could be way more efficient. Perhaps.. my code isn't even correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how could this be more efficient or perhaps actually working?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The whole code, here below.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int cleanCount = 1000;&#xA;int softpotPin = A0; //analog pin 0&#xA;&#xA;&#xA;&#xA;void setup () {&#xA;    Serial.begin(9600);&#xA;    digitalWrite(softpotPin, HIGH); //enable pullup resistor    &#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;    int softpotReading = analogRead(softpotPin);&#xA;    if (softpotReading &amp;lt; 980) { // IF AANGERAAKT&#xA;        digitalWrite(werktIeLED, HIGH); &#xA;        ++cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(16); // 5x zo snel als leeglopen&#xA;    }&#xA;    else if (softpotReading &amp;gt; 980) { // IF NIET AANGERAAKT&#xA;        digitalWrite(werktIeLED, LOW); &#xA;        --cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(64); // 1000 / 60 seconden&#xA;    }&#xA;    else {      // Als er een fout optreed..&#xA;        Serial.println(&quot;Fout!&quot;);&#xA;        digitalWrite(werktIeLED, HIGH);    &#xA;        delay(250);               &#xA;        digitalWrite(werktIeLED, LOW);    &#xA;        delay(250);               &#xA;    }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8242" LastEditorUserId="8242" LastEditDate="2015-04-07T16:55:17.340" LastActivityDate="2015-04-07T20:12:38.523" Title="How do I turn on or off an array of LEDs based on the value of a variable?" Tags="|led|variables|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9905" PostTypeId="2" ParentId="9904" CreationDate="2015-04-07T15:26:04.783" Score="0" Body="&lt;p&gt;Instead of repeating several calls to &lt;code&gt;digitalwrite&lt;/code&gt; you should consider changing the pins directly as described &lt;a href=&quot;http://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This now depends on which port your LEDs are connected to. Assuming port D you would use &lt;code&gt;DDRD&lt;/code&gt; to define the pins as output (usually in &lt;code&gt;setup()&lt;/code&gt;) and &lt;code&gt;PORTD&lt;/code&gt; to set their values (in &lt;code&gt;loop&lt;/code&gt;), e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRD = B11111110; // define pins 1..7 as outputs, pin 0 as input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PORTD = B11110000; // switch on first 4 LEDs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now all you need to do is to write a function to map your number range to suitable bit strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function could look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int convert(int n) {                                                                     &#xA;&#xA;  int res = 0;   // start with all pins off (zero)&#xA;  while (n &amp;gt; 100) { &#xA;    res &amp;lt;&amp;lt;= 1;   // shift pattern 1 bit (i.e. pin) to the left&#xA;    res |= 1;    // &quot;switch on&quot; lowest pin &#xA;    n -= 100;    // defines step size (1 LED for every  100)&#xA;  }&#xA;  return res;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes your value and returns an &lt;code&gt;int&lt;/code&gt; that you can assign to the port. I.e. for 0..100 it returns &lt;code&gt;0&lt;/code&gt;, for 101..200 it returns &lt;code&gt;1&lt;/code&gt;, for 201..300 it returns &lt;code&gt;3&lt;/code&gt; = &lt;code&gt;B11&lt;/code&gt;, for 301..400 it returns &lt;code&gt;7&lt;/code&gt; = &lt;code&gt;B111&lt;/code&gt; and so on. (Note that it does not do any sanity checks on the input / output but that's certainly easy for you to add if needed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In response to comment: Note that the bit pattern I use as example for &lt;code&gt;DDRD&lt;/code&gt; above is an example: It sets bit / pin 0 as input. If you use &lt;code&gt;convert&lt;/code&gt; you would, of course, set the lowest bit of &lt;code&gt;DDRD&lt;/code&gt; to 1 to make it an output.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-04-07T16:30:58.687" LastActivityDate="2015-04-07T16:30:58.687" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="9906" PostTypeId="2" ParentId="9904" CreationDate="2015-04-07T15:27:08.530" Score="2" Body="&lt;p&gt;Here is a suggestion with the led pins in an array that you loop over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest making the array global, so put it outside any functions (usually at the top):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte led_pins[] = {pin1, pin2, pin3, pin4, pin5, pin6, pin7, pin8};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then put this in your loop (assumes that you have a &lt;code&gt;int&lt;/code&gt; called cleanCount that is in scope:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int increment = 100;&#xA;&#xA;for (int i = 0; i &amp;lt; sizeof(led_pins) / sizeof(led_pins[0]); i++) {&#xA;  boolean onOrOff = cleanCount &amp;gt; (i+1) * increment;&#xA;  digitalWrite(led_pins[i], onOrOff);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2015-04-07T15:44:17.220" LastActivityDate="2015-04-07T15:44:17.220" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9907" PostTypeId="1" AcceptedAnswerId="9908" CreationDate="2015-04-07T15:57:58.770" Score="2" ViewCount="754" Body="&lt;p&gt;I'm using an LM35 temperature sensor, and it outputs 190 mV (which agrees with 19°C). I'm using an external reference voltage which I measure as 417mV. (This is set by the pin &quot;aRefCntrl&quot;). So I should have a reading around 467, but I get 1023, i.e. the ADC overflows. When I use the internal 1.1V reference I get a correct reading. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code (Arduino waits for a request from the PC to send the data):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define lm35 A0&#xA;#define aRefCtrl 10&#xA;&#xA;void setup() {    &#xA;  pinMode(aRefCtrl, OUTPUT);&#xA;  digitalWrite(aRefCtrl, 0);&#xA;  analogReference(EXTERNAL);&#xA;  analogRead(lm35); // dummy read&#xA;  Serial.begin(9600);  &#xA;}  &#xA;&#xA;void loop() {&#xA;  if ( Serial.available() ) {&#xA;    Serial.read(); // PC's request is a single byte&#xA;    int temperature = analogRead(lm35);&#xA;    Serial.println(temperature);    &#xA;  }&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;follow-up&lt;/strong&gt; on Ignacio's comment: would a decoupling capacitor do? (I can't test for the moment, I have to order some)&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-04-07T16:18:48.937" LastActivityDate="2015-04-07T17:40:16.180" Title="Why does the ADC overflow when using an external Aref?" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9908" PostTypeId="2" ParentId="9907" CreationDate="2015-04-07T16:35:05.277" Score="4" Body="&lt;p&gt;The minimum reference voltage is 1.0 V according to the atmega328 &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;. See table 29-15. ADC Characteristics.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="2973" LastEditDate="2015-04-07T17:40:16.180" LastActivityDate="2015-04-07T17:40:16.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9909" PostTypeId="2" ParentId="8025" CreationDate="2015-04-07T17:02:00.837" Score="0" Body="&lt;p&gt;Coming in late but seeing no solutions offered yet, I'll take a stab at it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume your vehicle is traveling obliquely toward the wall.&#xA;Assume you can find and measure the perpendicular distance to the wall.&#xA;Then you can calculate the travel distance from those two measurements:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OsmP1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next we need to find the angle between the vehicle's heading (center-line) and the perpendicular. A rotating sensor that senses return-signal strength could probably give good results but is mechanically more complicated. Given that the ultrasonic sensors have a somewhat broad sensing angle, 3 or 5 fixed sensors (1 straight ahead and 1 or 2 to either side) may work well enough if you're just trying to avoid hitting the wall. In that case you could measure with all of the sensors, take the least distance measurement as 'p' and the known angle of that sensor as 'theta'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's left is to decide how to make the calculation and work with cosines. For the rotating sensor case, you'll have to find the angle of the sensor at the time of it's smallest reading, and look up in a table (or calculate) the cosine of that angle. For the multiple fixed sensors case, you already know the sensors' angles and therefore, their cosines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have enough code memory it would easy to write your calculations in floating point, certainly for some quick and dirty testing. If not, or you need to speed up the calculations, you can do it in fixed point with less code. it's a little bit harder for the programmer but much easier and quicker for the MCU.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-04-08T15:27:48.720" LastActivityDate="2015-04-08T15:27:48.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9910" PostTypeId="2" ParentId="9899" CreationDate="2015-04-07T17:02:46.580" Score="0" Body="&lt;p&gt;The following solution isn't strictly portable, but it should work as long as both ends are &lt;a href=&quot;https://en.wikipedia.org/wiki/Endianness&quot; rel=&quot;nofollow&quot;&gt;little-endian&lt;/a&gt; (most platforms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the GCC attribute &lt;code&gt;packed&lt;/code&gt; to tell the compiler not to pad the fields like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct __attribute__ ((packed)) my_struct {&#xA;  char c;&#xA;  int32_t n;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can send your struct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write((uint8_t*) a_my_struct_ptr, sizeof(my_struct));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the receiving end you just copy the received data to a similarly packed struct. If you would rather use &lt;a href=&quot;http://en.wikipedia.org/wiki/Python_%28programming_language%29&quot; rel=&quot;nofollow&quot;&gt;Python&lt;/a&gt; over C/C++ you can use the &lt;code&gt;struct&lt;/code&gt; module to unserialize the data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I just googled your product and the &lt;a href=&quot;https://en.wikipedia.org/wiki/MIPS_instruction_set&quot; rel=&quot;nofollow&quot;&gt;MIPS&lt;/a&gt; processor is bi-endian, but I will assume that it is configured for little-endian by default. You can try and see if &lt;code&gt;int&lt;/code&gt;s keep their value after transmit. Also remember to use explicit size types such as int16_t, uint64_t, etc.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="510" LastEditDate="2015-04-09T05:49:39.297" LastActivityDate="2015-04-09T05:49:39.297" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9911" PostTypeId="2" ParentId="9104" CreationDate="2015-04-07T17:28:36.713" Score="2" Body="&lt;p&gt;If you want to take it to to the extreme, I always use an algorithm called Diamond Coordinates. It is described in &lt;a href=&quot;http://www.rchordata.com/files/Using%20Diamond%20Coordinates%20to%20Power%20a%20Differential%20Drive.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; PDF.  It performs perfectly, and I keep a C# and Java implementation handy. I'll probably be doing a Python one soon :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/u9Z1H.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-04-07T17:28:36.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9912" PostTypeId="2" ParentId="9890" CreationDate="2015-04-07T17:32:56.270" Score="0" Body="&lt;p&gt;I don't think this will be feasible. There are two main issues:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; I don't think there's a sensible way to get the HC-05 module to work with A2DP. It's great for a simple serial connection, but Bluetooth-enabled media devices generally won't connect to it if they're looking for audio streaming systems (as far as I know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; The Uno probably isn't powerful enough. Even if you could get the audio data into it, I don't think it will be able to decode the information to an analog audio signal in real-time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like a Raspberry Pi with a suitable Bluetooth module might be a better choice for this.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-07T17:32:56.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9913" PostTypeId="1" CreationDate="2015-04-07T18:35:41.663" Score="3" ViewCount="534" Body="&lt;p&gt;Since the DUE works on 3.3 volts has anyone successfully modified a 5V 16x2 LCD shield to work with Arduino DUE?  I'm thinking 3.3V will be seen as a logic &amp;quot;1&amp;quot;&#xA;by the 5V LCD shield and there are no 5V outputs that feed back to the 3.3V due if the R/~W line on the LCD is simply grounded.&lt;/p&gt;&#xA;&lt;p&gt;Would love to hear anyone's opinion on this.&lt;/p&gt;&#xA;&lt;p&gt;Thanks,&#xA;Charlie&lt;/p&gt;&#xA;" OwnerUserId="7459" LastEditorUserId="4628" LastEditDate="2023-10-20T16:47:27.607" LastActivityDate="2023-10-20T16:47:27.607" Title="Has anyone modified a 16x2 LCD shield to work with Arduino DUE?" Tags="|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9914" PostTypeId="1" AcceptedAnswerId="9915" CreationDate="2015-04-07T19:56:53.723" Score="1" ViewCount="2523" Body="&lt;p&gt;I've got a function that decreases over time (1000 / 60 seconds) and by touching a softPotentiometer you can increase that value. By every increment of 200 a LED is lid. So for 0-200, 1 LED; 201-400, 2 LEDs; etc. And since it decreases over time while doing nothing, if it drops below a certain value, a LED is shut off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've got a (amateur) coded set up, but somehow it lids the LEDs in the opposite direction. In a way that, I've coded it that if it's above 800, lid 5 LED's. However, it will only lid one LED when it's dropped below the 800, in the area of 601-800.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's exactly the opposite of what I want. So what am I doing wrong here? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;br&gt;&#xA;&lt;em&gt;And with amateur, I mean that I didn't use arrays and therefor write everything multiple times..&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int cleanCount = 1000;&#xA;int IsItWorkingLED = 13;&#xA;int softpotPin = A0; //analog pin 0&#xA;int LED1 = 1;&#xA;int LED2 = 2;&#xA;int LED3 = 4;&#xA;int LED4 = 5;&#xA;int LED5 = 7;&#xA;&#xA;&#xA;&#xA;void setup () {&#xA;    Serial.begin(9600);&#xA;    digitalWrite(softpotPin, HIGH); //enable pullup resistor    &#xA;        pinMode(1, OUTPUT); &#xA;        pinMode(2, OUTPUT); &#xA;        pinMode(4, OUTPUT); &#xA;        pinMode(5, OUTPUT); &#xA;        pinMode(7, OUTPUT);&#xA;&#xA;           digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;    int softpotReading = analogRead(softpotPin);&#xA;    if (softpotReading &amp;lt; 980) { // IF TOUCHED&#xA;        digitalWrite(IsItWorkingLED, HIGH); &#xA;        ++cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(16); // Drain 5 times as fast&#xA;    }&#xA;    else if (softpotReading &amp;gt; 980) { // IF NOT DTOUCHED&#xA;        digitalWrite(IsItWorkingLED, LOW); &#xA;        --cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(64); // 1000 / 60 seconds&#xA;    }&#xA;    else {      // Als er een fout optreed..&#xA;        Serial.println(&quot;Something wrong!&quot;);&#xA;        digitalWrite(IsItWorkingLED, HIGH);    &#xA;        delay(250);               &#xA;        digitalWrite(IsItWorkingLED, LOW);    &#xA;        delay(250);               &#xA;    }&#xA;&#xA;        if (cleanCount &amp;gt;= 0 &amp;amp;&amp;amp; cleanCount &amp;lt;= 200) {&#xA;           Serial.println(&quot;Knal 1 LED aan&quot;);&#xA;           digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED2, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED3, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED4, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED5, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 201 &amp;amp;&amp;amp; cleanCount &amp;lt;= 400) {&#xA;           Serial.println(&quot;Knal 2 LEDs aan&quot;);&#xA;           digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED3, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED4, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED5, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 401 &amp;amp;&amp;amp; cleanCount &amp;lt;= 600) {&#xA;           Serial.println(&quot;Knal 3 LEDs aan&quot;);&#xA;           digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED3, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED4, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED5, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 601 &amp;amp;&amp;amp; cleanCount &amp;lt;= 800) {&#xA;           Serial.println(&quot;Knal 4 LEDs aan&quot;);&#xA;           digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED3, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED4, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(LED5, LOW);   // turn the LED on (HIGH is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 801 &amp;amp;&amp;amp; cleanCount &amp;lt;= 1000) {&#xA;           Serial.println(&quot;Knal 5 LEDs aan&quot;);&#xA;           digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;           digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;        }&#xA;        else {&#xA;          Serial.println(&quot;Just..do nothing&quot;); &#xA;        }&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8242" LastActivityDate="2015-04-07T20:28:30.480" Title="Arduino turns LEDs off when set 'high', opposite direction as coded" Tags="|led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9915" PostTypeId="2" ParentId="9914" CreationDate="2015-04-07T20:08:24.333" Score="6" Body="&lt;p&gt;If your LEDs are connected anode to +5, cathode to i/o pin, they would behave this way. Cathode to ground, anode to i/o would behave as you expect.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-07T20:08:24.333" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9916" PostTypeId="2" ParentId="9904" CreationDate="2015-04-07T20:12:38.523" Score="2" Body="&lt;p&gt;You can use the barGraph example from the Arduino code examples. This gives a bar-type graph and not point. I will give rough explination why it will work and the need not to re-invent the wheel.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int sensorReading = analogRead(analogPin);&#xA;  // map the result to a range from 0 to the number of LEDs:&#xA;  int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);&#xA;&#xA;  // loop over the LED array:&#xA;  for (int thisLed = 0; thisLed &amp;lt; ledCount; thisLed++) {&#xA;    // if the array element's index is less than ledLevel,&#xA;    // turn the pin for this element on:&#xA;    if (thisLed &amp;lt; ledLevel) {&#xA;      digitalWrite(ledPins[thisLed], HIGH);&#xA;    } &#xA;    // turn off all pins higher than the ledLevel:&#xA;    else {&#xA;      digitalWrite(ledPins[thisLed], LOW); &#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will give you the point in the array, 0-10, for 0-1000, if you replace &lt;code&gt;1023&lt;/code&gt; with &lt;code&gt;1000&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simplified &lt;code&gt;map()&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int point = sensorReading*10/1000&lt;/code&gt; this gives you a range of 0-10, the int keeps it from having decimal points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from the for loop it turns on all the LEDs that are in the array to the end and then turns off those not needed.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-04-07T20:12:38.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9917" PostTypeId="2" ParentId="9914" CreationDate="2015-04-07T20:28:30.480" Score="0" Body="&lt;p&gt;Try reversing the if statements.&#xA;You say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've coded it that if it's above 800, lid 5 LED's.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And your code is:&#xA;&lt;code&gt;(softpotReading &amp;lt; 980) { // IF TOUCHED&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code describes: &lt;code&gt;IF softpotReading IS SMALLER THAN 980, DO{ code.. }&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In dutch (as OP is dutch, and to be honest his English somehow confuses me a bit, to be sure it's not the other way around also):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ik denk dat je de IF statements verkeerd om hebt.&#xA;Je beschrijft dat bij een waarde hoger dan 800 de ledjes aan gaan...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Echter staat in je code &lt;code&gt;(softpotReading &amp;lt; 980) { // IF TOUCHED&lt;/code&gt;&#xA;Wat dus zal betekenen dat de code wordt uitgevoerd als die &amp;lt; (kleiner dan) 980 is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (softpotReading &amp;gt; 980) { // IF TOUCHED&#xA;    digitalWrite(IsItWorkingLED, HIGH); &#xA;    ++cleanCount;&#xA;    Serial.println(cleanCount);&#xA;    delay(16); // Drain 5 times as fast&#xA;}&#xA;else if (softpotReading &amp;lt;= 980) { // IF NOT DTOUCHED&#xA;    digitalWrite(IsItWorkingLED, LOW); &#xA;    --cleanCount;&#xA;    Serial.println(cleanCount);&#xA;    delay(64); // 1000 / 60 seconds&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-07T20:28:30.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9918" PostTypeId="1" CreationDate="2015-04-07T22:45:09.593" Score="3" ViewCount="3029" Body="&lt;p&gt;So I have 3 ground pins, but I need 4 motors on my Arduino. Can I connect multiple motors to the same ground pin?&lt;/p&gt;&#xA;" OwnerUserId="8025" LastActivityDate="2015-04-12T23:34:14.847" Title="Use same ground with 2 wires?" Tags="|pins|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9919" PostTypeId="2" ParentId="9897" CreationDate="2015-04-08T02:43:54.663" Score="2" Body="&lt;p&gt;The way to do this isn't to overload the loop function, the way to do this is to abuse the linker and replace main(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main.cpp file that gets used in the Arduino make prototypes main as &lt;code&gt;int main(void)&lt;/code&gt;. On my system at least the linker prefers the longer prototype, so you can just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(int argc, char* argv[])&#xA;{&#xA;    init();&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA;&#xA;    //The one shot loop...&#xA;    loop();&#xA;    if (serialEventRun) serialEventRun();&#xA;    //Put whatever else you need to do between before the unending loop here.&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;&#xA;    return 0;    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both get compiled, but the &lt;code&gt;int main(int argc, char* argv[])&lt;/code&gt; prototyped version gets linked as the entry point, so your &quot;invisibile&quot; code gets executed.&lt;/p&gt;&#xA;" OwnerUserId="8216" LastActivityDate="2015-04-08T02:43:54.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9920" PostTypeId="1" CreationDate="2015-04-08T02:43:58.253" Score="0" ViewCount="194" Body="&lt;p&gt;I am trying to build a set of four stars using an Arduino, potentiometer and a four channel relay to control how fast it speeds across the stars. My question is how can I delay the process, say for 20 or 30 seconds before it starts again?&lt;/p&gt;&#xA;" OwnerUserId="8322" LastActivityDate="2015-04-16T10:10:28.897" Title="trying to delay between sequences" Tags="|arduino-uno|arduino-mega|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9921" PostTypeId="1" CreationDate="2015-04-08T05:22:15.973" Score="0" ViewCount="1089" Body="&#xA;&#xA;&lt;p&gt;Couldn't find any other post that mentions Serial Monitor crippling the normal workflow of the NRF24l01, so here it goes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two Arduino Nano, both with NRF24l01 attached, and an RF24 library working. Both NRF24l01 have 10uF caps soldered on them. One is only sending data, another is receiving only. Both of them flash LED on, successful transmission and successful receiving respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run both devices, i see both LEDs flashing, so one succeeds in sending, and another one in receiving. But whenever I try to open Serial Monitor in my Arduino 1.6.1 software, the LEDs flash only every forth of fifth time of expected, and in my Serial Monitor I can see only 1 of 4 or 5 packets received (though received correctly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what I could have done wrong? Could Serial Monitor somehow interfere with Nano talking to NRF24l01?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code follows, it's simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sender&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    /*&#xA;     Copyright (C) 2011 J. Coliz &amp;lt;maniacbug@ymail.com&amp;gt;&#xA;&#xA;     This program is free software; you can redistribute it and/or&#xA;     modify it under the terms of the GNU General Public License&#xA;     version 2 as published by the Free Software Foundation.&#xA;     */&#xA;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &quot;nRF24L01.h&quot;&#xA;    #include &quot;RF24.h&quot;&#xA;    #include &quot;printf.h&quot;&#xA;&#xA;    // On Successfull Sending Blink PIN&#xA;&#xA;    #define BLPIN 5&#xA;&#xA;    //&#xA;    // Hardware configuration&#xA;    //&#xA;&#xA;    // Set up nRF24L01 radio on SPI bus plus pins 9 &amp;amp; 10 &#xA;&#xA;    RF24 radio(9,10);&#xA;&#xA;    //&#xA;    // Topology&#xA;    //&#xA;&#xA;    // Radio pipe addresses for the 2 nodes to communicate.&#xA;    const uint64_t pipe = 0xF0F0F0F0E1LL;&#xA;&#xA;    void setup(void)&#xA;    {&#xA;      pinMode(BLPIN, OUTPUT);&#xA;&#xA;      //&#xA;      // Print preamble&#xA;      //&#xA;&#xA;      Serial.begin(57600);&#xA;      printf_begin();&#xA;      printf(&quot;\n\rRF24/examples/GettingStarted/\n\r&quot;);&#xA;&#xA;      //&#xA;      // Setup and configure rf radio&#xA;      //&#xA;&#xA;      radio.begin();&#xA;&#xA;      // optionally, increase the delay between retries &amp;amp; # of retries&#xA;      radio.setRetries(15,15);&#xA;&#xA;      // optionally, reduce the payload size.  seems to&#xA;      // improve reliability&#xA;      radio.setPayloadSize(8);&#xA;&#xA;      //&#xA;      // Open pipes to other nodes for communication&#xA;      //&#xA;&#xA;      radio.openWritingPipe(pipe);&#xA;&#xA;      //&#xA;      // Dump the configuration of the rf unit for debugging&#xA;      //&#xA;&#xA;      radio.printDetails();&#xA;    }&#xA;&#xA;    // counter data to be sent&#xA;    unsigned long counter = 0;&#xA;&#xA;    void loop(void)&#xA;    {&#xA;&#xA;      // Increase the counter and send it&#xA;      counter++;&#xA;      printf(&quot;Sending counter = %lu...&quot;, counter);&#xA;&#xA;      if (radio.write( &amp;amp;counter, sizeof(unsigned long) ))&#xA;      {&#xA;        printf(&quot;ok...\n\r&quot;);&#xA;        digitalWrite(BLPIN, HIGH); &#xA;        delay(10);&#xA;        digitalWrite(BLPIN, LOW); &#xA;      }&#xA;      else&#xA;        printf(&quot;failed.\n\r&quot;);&#xA;&#xA;      // Try again 1s later&#xA;      delay(1000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    /*&#xA;     Copyright (C) 2011 J. Coliz &amp;lt;maniacbug@ymail.com&amp;gt;&#xA;&#xA;     This program is free software; you can redistribute it and/or&#xA;     modify it under the terms of the GNU General Public License&#xA;     version 2 as published by the Free Software Foundation.&#xA;     */&#xA;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &quot;nRF24L01.h&quot;&#xA;    #include &quot;RF24.h&quot;&#xA;    #include &quot;printf.h&quot;&#xA;&#xA;    // On Receiver Blink PIN&#xA;&#xA;    #define BLPIN 5&#xA;&#xA;    //&#xA;    // Hardware configuration&#xA;    //&#xA;&#xA;    // Set up nRF24L01 radio on SPI bus plus pins 9 &amp;amp; 10 &#xA;&#xA;    RF24 radio(9,10);&#xA;&#xA;    //&#xA;    // Topology&#xA;    //&#xA;&#xA;    // Radio pipe addresses for the 2 nodes to communicate.&#xA;    const uint64_t pipe = 0xF0F0F0F0E1LL;&#xA;&#xA;    void setup(void)&#xA;    {&#xA;      pinMode(BLPIN, OUTPUT);&#xA;&#xA;      //&#xA;      // Print preamble&#xA;      //&#xA;&#xA;      Serial.begin(57600);&#xA;      printf_begin();&#xA;      printf(&quot;\n\rRF24/examples/GettingStarted/\n\r&quot;);&#xA;&#xA;      //&#xA;      // Setup and configure rf radio&#xA;      //&#xA;&#xA;      radio.begin();&#xA;&#xA;      // optionally, increase the delay between retries &amp;amp; # of retries&#xA;      radio.setRetries(15,15);&#xA;&#xA;      // optionally, reduce the payload size.  seems to&#xA;      // improve reliability&#xA;      radio.setPayloadSize(8);&#xA;&#xA;      //&#xA;      // Open pipes to other nodes for communication&#xA;      //&#xA;&#xA;      radio.openReadingPipe(1,pipe);&#xA;&#xA;      //&#xA;      // Start listening&#xA;      //&#xA;&#xA;      radio.startListening();&#xA;&#xA;      //&#xA;      // Dump the configuration of the rf unit for debugging&#xA;      //&#xA;&#xA;      radio.printDetails();&#xA;    }&#xA;&#xA;    unsigned long counter;&#xA;&#xA;    void loop(void)&#xA;    {&#xA;      // if there is data ready&#xA;      if (radio.available())&#xA;      {&#xA;        while( radio.available() ) {&#xA;          radio.read( &amp;amp;counter, sizeof(unsigned long) );&#xA;          // Dump the payloads until we've gotten everything&#xA;          printf(&quot;Got payload %lu...\n\r&quot;, counter);&#xA;        }&#xA;        digitalWrite(BLPIN, HIGH); &#xA;        delay(10);&#xA;        digitalWrite(BLPIN, LOW); &#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8324" LastEditorUserId="10794" LastEditDate="2015-08-06T22:55:21.443" LastActivityDate="2016-02-03T01:53:21.883" Title="Serial Monitor breaks normal behaviour of Nano + NRF24l01" Tags="|serial|arduino-nano|nrf24l01+|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9923" PostTypeId="2" ParentId="9918" CreationDate="2015-04-08T06:32:36.567" Score="2" Body="&lt;p&gt;You can do it as long as the current isn't excessive. I don't think there are any specs available, but the connector and the width / thickness of the copper tracks on the PCB will be the limiting factor.&lt;/p&gt;&#xA;" OwnerUserId="2973" LastActivityDate="2015-04-08T06:32:36.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9924" PostTypeId="2" ParentId="9920" CreationDate="2015-04-08T07:11:13.423" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/pmwiki.php?n=Reference/Delay&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;delay()&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(20000); // wait for 20 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-04-08T07:11:13.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9925" PostTypeId="1" AcceptedAnswerId="9927" CreationDate="2015-04-08T08:12:49.787" Score="1" ViewCount="2598" Body="&lt;p&gt;&lt;sup&gt;This is my followup question based on a serie of one project. Go my to profile to read 'm all.&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm building something which includes a function that has a count (1000) that decreases over time, but by pressing a soft pot meter the count increases. By every increment of 200 one LED is lit. So if the count is 837 4 LEDs are burning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my previous question I had issues lighting the LEDs, because they didn't burn even when the code was, as far as I could see correct. Instead it did the opposite of what I coded. Now I changed my code the opposite direction, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;writing:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;digitalWrite(LED1, LOW);   // turn the LED on (LOW is the voltage level)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which actually set the LED to bright. While is I'd write it 'HIGH' it would dim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my actual question is: How could my LED be lit if it's set to 'low', while you have to set it to 'high' to be actually popping off light?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;My complete code:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int cleanCount = 1000;&#xA;int IsItWorkingLED = 13;&#xA;int softpotPin = A0; //analog pin 0&#xA;int LED1 = 1;&#xA;int LED2 = 2;&#xA;int LED3 = 4;&#xA;int LED4 = 5;&#xA;int LED5 = 7;&#xA;&#xA;&#xA;&#xA;void setup () {&#xA;    Serial.begin(9600);&#xA;    digitalWrite(softpotPin, HIGH); //enable pullup resistor    &#xA;    pinMode(LED1, OUTPUT);  &#xA;    pinMode(LED2, OUTPUT);  &#xA;    pinMode(LED3, OUTPUT);  &#xA;    pinMode(LED4, OUTPUT);  &#xA;    pinMode(LED5, OUTPUT);&#xA;&#xA;    digitalWrite(LED1, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    digitalWrite(LED2, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    digitalWrite(LED3, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    digitalWrite(LED4, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    digitalWrite(LED5, HIGH);   // turn the LED on (HIGH is the voltage level)  &#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;    int softpotReading = analogRead(softpotPin);&#xA;    if (softpotReading &amp;lt; 980) { // IF TOUCHED&#xA;        digitalWrite(IsItWorkingLED, HIGH); &#xA;        ++cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(8); // Increase 5 times as fast&#xA;    }&#xA;    else if (softpotReading &amp;gt; 980) { // IF NOT TOUCHED&#xA;        digitalWrite(IsItWorkingLED, LOW); &#xA;        --cleanCount;&#xA;        Serial.println(cleanCount);&#xA;        delay(32); // Decrease slowly&#xA;    }&#xA;    else {      // If there is something wrong..&#xA;        Serial.println(&quot;Something wrong!&quot;);&#xA;        digitalWrite(IsItWorkingLED, HIGH);    &#xA;        delay(250);               &#xA;        digitalWrite(IsItWorkingLED, LOW);    &#xA;        delay(250);               &#xA;    }&#xA;&#xA;        if (cleanCount &amp;lt;= 200) {&#xA;            Serial.println(&quot;Knal 1 LED aan&quot;);&#xA;            digitalWrite(LED1, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED2, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED3, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED4, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED5, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 201 &amp;amp;&amp;amp; cleanCount &amp;lt;= 400) {&#xA;            Serial.println(&quot;Knal 2 LEDs aan&quot;);&#xA;            digitalWrite(LED1, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED2, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED3, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED4, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED5, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 401 &amp;amp;&amp;amp; cleanCount &amp;lt;= 600) {&#xA;            Serial.println(&quot;Knal 3 LEDs aan&quot;);&#xA;            digitalWrite(LED1, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED2, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED3, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED4, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED5, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 601 &amp;amp;&amp;amp; cleanCount &amp;lt;= 800) {&#xA;            Serial.println(&quot;Knal 4 LEDs aan&quot;);&#xA;            digitalWrite(LED1, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED2, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED3, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED4, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(LED5, HIGH);   // turn the LED on (LOW is the voltage level)&#xA;        }&#xA;        else if (cleanCount &amp;gt;= 801 &amp;amp;&amp;amp; cleanCount &amp;lt;= 1000) {&#xA;            Serial.println(&quot;Knal 5 LEDs aan&quot;);&#xA;            digitalWrite(1, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(2, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(4, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(5, LOW);   // turn the LED on (LOW is the voltage level)&#xA;            digitalWrite(7, LOW);   // turn the LED on (LOW is the voltage level)&#xA;        }&#xA;        else {&#xA;            Serial.println(&quot;Just..do nothing&quot;); &#xA;        }&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8242" LastActivityDate="2020-06-18T02:19:49.017" Title="A LED should be lit when 'high'. Why does mine only burn with 'low'?" Tags="|led|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9926" PostTypeId="1" AcceptedAnswerId="9942" CreationDate="2015-04-08T08:13:14.243" Score="1" ViewCount="2229" Body="&lt;p&gt;I'm working on sketches uploading over BLE. I had to write my own uploader (looking at avrdude sources with one eye) so i can change uploading behaviour as needed and it's working over USB just perfect but it does not get response from bootloader if trying over Bluetooth LE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno (and i'm having Arduino Mega2560)&lt;/li&gt;&#xA;&lt;li&gt;HM-10 BLE module&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As HM-10 does not support DTR/RTS i had to add my own software reboot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In brief: it reads incoming bytes on interrupt event and compares to reset command passed in ble_setup. If it's equal then it uses watchdog timer to reboot the board. If it's not equal it stores byte in byffer, then sketch loop() just returns incoming byes back (&quot;echo&quot;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;const char *ble_reset_cmd;&#xA;int ble_reset_index = 0;&#xA;int ble_available = 0;       // chars available&#xA;int ble_byte;                // income buffer as 1 char&#xA;int *ble_bytes = &amp;amp;ble_byte;  // income buffer&#xA;boolean delete_ble_bytes = false;&#xA;&#xA;//#define BLE_DEBUG&#xA;&#xA;// reboot Arduino board using Watchdog timer&#xA;void reboot() {&#xA;//    #ifdef BLE_DEBUG&#xA;    Serial.println(&quot;rebooting ...&quot;);&#xA;//    #endif&#xA;&#xA;//    digitalWrite(13, HIGH);&#xA;//    delay(2000);&#xA;&#xA;    wdt_enable(WDTO_15MS);&#xA;    while(1) { };&#xA;}&#xA;&#xA;void ble_setup(int baud, const char *reset_cmd) {&#xA;    Serial.begin(baud);&#xA;    ble_reset_cmd = reset_cmd;&#xA;}&#xA;&#xA;int Serial_available() {&#xA;    return ble_available;&#xA;}&#xA;&#xA;int Serial_read() {&#xA;    if (ble_available &amp;lt; 0)&#xA;        return -1;&#xA;&#xA;    int inByte = ble_bytes[--ble_available];&#xA;    if (ble_available == 0 &amp;amp;&amp;amp; delete_ble_bytes) {&#xA;        // restore buffer as 1 char buffer&#xA;        delete[] ble_bytes;&#xA;        ble_bytes = &amp;amp;ble_byte;&#xA;        delete_ble_bytes = false;&#xA;    }&#xA;    return inByte;&#xA;}&#xA;&#xA;void serialEvent() {&#xA;    if (Serial.available() &amp;lt;= 0)&#xA;        return;&#xA;&#xA;    int inByte = Serial.read();&#xA;    if (inByte == ble_reset_cmd[ble_reset_index]) {&#xA;        // entered char is cmd character&#xA;&#xA;        if (ble_reset_cmd[++ble_reset_index] == 0)&#xA;            reboot();&#xA;&#xA;        #ifdef BLE_DEBUG  &#xA;        Serial.write(&quot;ble_index = &quot;);&#xA;        Serial.print((byte)ble_reset_index);&#xA;        Serial.write('\n');&#xA;        #endif &#xA;&#xA;    } else {&#xA;        // entered char is NOT cmd character&#xA;&#xA;        if (ble_reset_index &amp;gt; 0) {&#xA;            // got character not from cmd, so we should to return characters&#xA;            // starting ble_reset_cmd until current index and then this character&#xA;&#xA;            ble_available = ble_reset_index + 1;&#xA;            ble_reset_index = 0;&#xA;&#xA;            #ifdef BLE_DEBUG&#xA;            Serial.print(&quot;Copy &quot;);&#xA;            Serial.print((byte)(ble_available - 1));&#xA;            Serial.println(&quot; bytes&quot;);&#xA;            #endif&#xA;&#xA;            // recreate input buffer using cmd characters&#xA;            ble_bytes = new int[ble_available + 1];&#xA;            delete_ble_bytes = true;&#xA;            ble_bytes[0] = inByte;&#xA;            for (int i=0; i&amp;lt;(ble_available-1); i++) {&#xA;              ble_bytes[i + 1] = ble_reset_cmd[ble_available - i - 2];&#xA;            }&#xA;            ble_bytes[ble_available] = 0; // null-terminated array&#xA;&#xA;            #ifdef BLE_DEBUG&#xA;            Serial.print(&quot;input buffer now contains &quot;);&#xA;            Serial.print(ble_available);&#xA;            Serial.println(&quot; bytes&quot;);&#xA;            #endif&#xA;&#xA;        } else {&#xA;&#xA;            #ifdef BLE_DEBUG&#xA;            Serial.println(&quot;ble_index = 0&quot;);&#xA;            #endif&#xA;&#xA;            // pass inByte next ...&#xA;            ble_available++;&#xA;            ble_byte = inByte;&#xA;        }&#xA;&#xA;    }&#xA;} &#xA;&#xA;// ----------------------------------- &#xA;&#xA;int led = 13;&#xA;int ledHIGH = 0;&#xA;&#xA;void setup() {&#xA;  ble_setup(9600, &quot;AT+RESET&quot;);&#xA;  Serial.print(&quot;ready\n&quot;);&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial_available() &amp;gt; 0) {&#xA;    int inByte = Serial_read();&#xA;&#xA;//    Serial.write('&amp;gt;');&#xA;//    Serial.write(inByte);&#xA;//    Serial.write('\n');&#xA;    ledHIGH = 1- ledHIGH;&#xA;    digitalWrite(led, ledHIGH);&#xA;    Serial.write(inByte); // echo&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As i said it's working good for USB uploading:&#xA;right after rebooting bootloader waits for upload commands and start to reply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;015-04-07 21:22:10.860 Apploader[11226:303] Apploader v0.1&#xA;2015-04-07 21:22:12.772 Apploader[11226:303] DTR/RTS supported by Serial, resetting&#xA;2015-04-07 21:22:13.075 Apploader[11226:303] draining ...&#xA;2015-04-07 21:22:13.327 Apploader[11226:303] drain done&#xA;2015-04-07 21:22:13.328 Apploader[11226:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:22:13.328 Apploader[11226:303] draining ...&#xA;2015-04-07 21:22:13.723 Apploader[11226:303] drain done&#xA;2015-04-07 21:22:13.724 Apploader[11226:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:22:13.724 Apploader[11226:303] draining ...&#xA;2015-04-07 21:22:13.977 Apploader[11226:303] drain done&#xA;2015-04-07 21:22:13.978 Apploader[11226:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:22:13.979 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:13.980 Apploader[11226:303] Recv: . [0x10] &#xA;2015-04-07 21:22:13.980 Apploader[11226:303] Send: A [0x41]  . [0x81]   [0x20] &#xA;2015-04-07 21:22:13.984 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:13.984 Apploader[11226:303] Recv: . [0x04] &#xA;2015-04-07 21:22:13.985 Apploader[11226:303] Recv: . [0x10] &#xA;2015-04-07 21:22:13.985 Apploader[11226:303] Send: A [0x41]  . [0x82]   [0x20] &#xA;2015-04-07 21:22:13.988 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:13.988 Apploader[11226:303] Recv: . [0x04] &#xA;2015-04-07 21:22:13.989 Apploader[11226:303] Recv: . [0x10] &#xA;2015-04-07 21:22:13.989 Apploader[11226:303] Send: B [0x42]  . [0x86]  . [0x00]  . [0x01]  . [0x00]  . [0x01]  . [0x01]  . [0x01]  . [0x03]  . [0xff]  . [0xff]  . [0xff]  . [0xff]  . [0x00]  . [0x80]  . [0x04]  . [0x00]  . [0x00]  . [0x00]  . [0x80]  . [0x00]   [0x20] &#xA;2015-04-07 21:22:13.996 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:13.997 Apploader[11226:303] Recv: . [0x10] &#xA;2015-04-07 21:22:13.997 Apploader[11226:303] Send: E [0x45]  . [0x05]  . [0x04]  . [0xd7]  . [0xc2]  . [0x00]   [0x20] &#xA;2015-04-07 21:22:14.000 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:14.001 Apploader[11226:303] Recv: . [0x10] &#xA;2015-04-07 21:22:14.003 Apploader[11226:303] Send: P [0x50]   [0x20] &#xA;2015-04-07 21:22:14.004 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:14.008 Apploader[11226:303] Recv: . [0x10] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when trying over BLE bootloader stops listening in 200ms and then launches sketch, i can see sketch setup() started as it prints &quot;ready&quot;. Also i can see it actually reboots the board as it sends &quot;rebooting&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;015-04-07 21:23:30.287 Apploader[11253:303] Apploader v0.1&#xA;2015-04-07 21:23:30.296 Apploader[11253:1503] CBCentralManager state is 5&#xA;2015-04-07 21:23:31.297 Apploader[11253:303] BleSerialDevice: open()&#xA;2015-04-07 21:23:31.298 Apploader[11253:303] Waiting for peripheral to be discovered ...&#xA;2015-04-07 21:23:31.591 Apploader[11253:1503] Found peripheral: &amp;lt;CBPeripheral: 0x100401940 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;Ardu&quot;, state = disconnected&amp;gt;&#xA;2015-04-07 21:23:31.593 Apploader[11253:1503] Stop scanning&#xA;2015-04-07 21:23:31.595 Apploader[11253:1503] Connecting to &amp;lt;CBPeripheral: 0x100401940 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;Ardu&quot;, state = disconnected&amp;gt;&#xA;2015-04-07 21:23:32.025 Apploader[11253:1503] Connected to peripheral &amp;lt;CBPeripheral: 0x100401940 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;Ardu&quot;, state = connected&amp;gt;&#xA;2015-04-07 21:23:32.041 Apploader[11253:1503] Discovered services for peripheral &amp;lt;CBPeripheral: 0x100401940 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;Ardu&quot;, state = connected&amp;gt;&#xA;2015-04-07 21:23:32.042 Apploader[11253:1503] Discovered service &amp;lt;CBService: 0x103701450&amp;gt;&#xA;2015-04-07 21:23:32.043 Apploader[11253:1503] Discovered service &amp;lt;CBService: 0x1037015f0&amp;gt;&#xA;2015-04-07 21:23:32.043 Apploader[11253:1503] Discovered service &amp;lt;CBService: 0x103701630&amp;gt;&#xA;2015-04-07 21:23:32.044 Apploader[11253:1503] Discovered characteristics for service &amp;lt;CBService: 0x103701630&amp;gt;&#xA;2015-04-07 21:23:32.044 Apploader[11253:1503] Discovered characteristic &amp;lt;CBCharacteristic: 0x1037005c0&amp;gt;&#xA;2015-04-07 21:23:32.045 Apploader[11253:1503] Subscribed to Rx value&#xA;2015-04-07 21:23:32.046 Apploader[11253:303] Connected successfully&#xA;2015-04-07 21:23:33.342 Apploader[11253:303] BleSerialDevice: open()&#xA;2015-04-07 21:23:33.343 Apploader[11253:303] already connected, exiting&#xA;2015-04-07 21:23:33.343 Apploader[11253:303] DTR/RTS supported by Serial, resetting&#xA;2015-04-07 21:23:33.594 Apploader[11253:303] Within interval&#xA;2015-04-07 21:23:33.595 Apploader[11253:303] Perform reset&#xA;2015-04-07 21:23:33.596 Apploader[11253:303] Send: A [0x41] T [0x54] + [0x2b] R [0x52] E [0x45] S [0x53] E [0x45] T [0x54] &#xA;2015-04-07 21:23:33.647 Apploader[11253:303] Skip draining after reset&#xA;2015-04-07 21:23:33.648 Apploader[11253:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:23:33.648 Apploader[11253:303] Draining for 200 ms ...&#xA;2015-04-07 21:23:33.649 Apploader[11253:303] Start reading&#xA;2015-04-07 21:23:33.712 Apploader[11253:1503] Rx value received 15 bytes: r [0x72] e [0x65] b [0x62] o [0x6f] o [0x6f] t [0x74] i [0x69] n [0x6e] g [0x67]   [0x20] . [0x2e] . [0x2e] . [0x2e] . [0x0d] . [0x0a] &#xA;2015-04-07 21:23:33.713 Apploader[11253:1503] _characterRead = true&#xA;2015-04-07 21:23:33.780 Apploader[11253:1503] Rx value received 6 bytes: r [0x72] e [0x65] a [0x61] d [0x64] y [0x79] . [0x0a] &#xA;2015-04-07 21:23:33.780 Apploader[11253:1503] _characterRead = true&#xA;2015-04-07 21:23:33.850 Apploader[11253:303] Finish reading&#xA;2015-04-07 21:23:33.851 Apploader[11253:303] Drained 21 bytes&#xA;2015-04-07 21:23:33.852 Apploader[11253:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:23:33.853 Apploader[11253:303] Draining for 200 ms ...&#xA;2015-04-07 21:23:33.853 Apploader[11253:303] Start reading&#xA;2015-04-07 21:23:33.982 Apploader[11253:1503] Rx value received 2 bytes: 0 [0x30]   [0x20] &#xA;2015-04-07 21:23:33.983 Apploader[11253:1503] _characterRead = true&#xA;2015-04-07 21:23:34.054 Apploader[11253:303] Finish reading&#xA;2015-04-07 21:23:34.055 Apploader[11253:303] Drained 2 bytes&#xA;2015-04-07 21:23:34.056 Apploader[11253:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:23:34.056 Apploader[11253:303] Reading 1 bytes ...&#xA;2015-04-07 21:23:34.057 Apploader[11253:303] Start reading&#xA;2015-04-07 21:23:34.057 Apploader[11253:303] _characterRead = false&#xA;2015-04-07 21:23:34.184 Apploader[11253:1503] Rx value received 1 bytes: . [0x00] &#xA;2015-04-07 21:23:34.185 Apploader[11253:1503] _characterRead = true&#xA;2015-04-07 21:23:34.186 Apploader[11253:303] Finish reading&#xA;2015-04-07 21:23:34.186 Apploader[11253:1503] Rx value received 2 bytes: 0 [0x30]   [0x20] &#xA;2015-04-07 21:23:34.186 Apploader[11253:1503] _characterRead = true&#xA;2015-04-07 21:23:34.186 Apploader[11253:303] Recv: . [0x00] &#xA;2015-04-07 21:23:34.187 Apploader[11253:303] stk500_getsync() attempt 1 of 5: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once again - bootloader stops listening in 200 ms instead of 1-1.5 secons as over USB:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-04-07 21:23:33.596 Apploader[11253:303] Send: A [0x41] T [0x54] + [0x2b] R [0x52] E [0x45] S [0x53] E [0x45] T [0x54] &#xA;...&#xA;2015-04-07 21:23:33.780 Apploader[11253:1503] Rx value received 6 bytes: r [0x72] e [0x65] a [0x61] d [0x64] y [0x79] . [0x0a]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect bootloader to reply with 0x14 0x10 as over USB:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-04-07 21:22:13.978 Apploader[11226:303] Send: 0 [0x30]   [0x20] &#xA;2015-04-07 21:22:13.979 Apploader[11226:303] Recv: . [0x14] &#xA;2015-04-07 21:22:13.980 Apploader[11226:303] Recv: . [0x10] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see later communication over Bluetooth is working good, as i receive exactly what was sent (0x30 0x20)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when sketch is launched it's ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ideas what's wrong:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;baud rate&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since serial.begin(N) is invoked after bootloader stops and launch sketch bootloader by default uses another baud rate? Is it correct? HM-10 default daud rate is 9600 and in sketch i also use 9600. &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;wrong wire connection?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Bluetooth-arduino:&#xA;rx -&gt; tx&#xA;tx -&gt; rx&#xA;Since its working for sketch i believe it's ok. Do i need any capacitors or resistors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts are highly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems i've found &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/atmega/ATmegaBOOT_168.c&quot; rel=&quot;nofollow&quot;&gt;Uno bootloader source code&lt;/a&gt; and bootloader baud rate is 19200 by default&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* set the UART baud rate */&#xA;/* 20060803: hacked by DojoCorp */&#xA;//#define BAUD_RATE   115200&#xA;#ifndef BAUD_RATE&#xA;#define BAUD_RATE   19200&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE2&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm in stuck as in this tutorial 115200 is used:&#xA;&lt;a href=&quot;http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/&quot; rel=&quot;nofollow&quot;&gt;http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in step 8. &quot;build the programmer circuit&quot; R1 2.2K is set on arduino rx pin. Why? Another thing i can't understand is that SoftwareSerial baud rate is set to 38400 but BT module baud rate is set 115200 using &quot;AT&quot; command. why?&lt;/p&gt;&#xA;" OwnerUserId="8327" LastEditorUserId="8327" LastEditDate="2015-04-08T18:08:57.873" LastActivityDate="2015-04-09T09:36:09.220" Title="Uploading over Bluetooth Low Energy - bootloader not responding" Tags="|arduino-uno|bluetooth|uploading|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9927" PostTypeId="2" ParentId="9925" CreationDate="2015-04-08T08:15:53.240" Score="2" Body="&lt;p&gt;Your assumption that a high is required to light a LED is false. All you need is to meet certain minimum voltage and current thresholds. Since the anode of the LED is tied high, &lt;a href=&quot;http://www.sysrecon.com/electronics/how-to-use-light-emitting-diodes-leds/&quot; rel=&quot;nofollow noreferrer&quot;&gt;the way to meet these&lt;/a&gt; is to bring the cathode low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.sysrecon.com/electronics/how-to-use-light-emitting-diodes-leds/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z9V7P.png&quot; alt=&quot;LED symbol&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-04-08T08:20:39.117" LastActivityDate="2015-04-08T08:20:39.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9928" PostTypeId="5" CreationDate="2015-04-08T09:48:55.160" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-08T09:48:55.160" LastActivityDate="2015-04-08T09:48:55.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9929" PostTypeId="4" CreationDate="2015-04-08T09:48:55.160" Score="0" Body="An IC that offers Wi-Fi networking compatible with b/g/n standards. It also has integrated TCP/IP protocol stack. Extremely popular along IoT community as a low cost and powerful board. " OwnerUserId="6452" LastEditorUserId="11529" LastEditDate="2016-02-26T14:56:22.030" LastActivityDate="2016-02-26T14:56:22.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9931" PostTypeId="1" AcceptedAnswerId="9932" CreationDate="2015-04-08T10:59:31.667" Score="0" ViewCount="1879" Body="&lt;p&gt;I just bought an Arduino Mega2560 R3 and it doesn't connect to my Laptop. The connection is somewhat random, sometimes it connects and sometimes it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me identify whats the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it gets connected I can upload sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to remove the Atmega 16U2 and replace it with ftdi USB to Serial, would it be possible?&lt;/p&gt;&#xA;" OwnerUserId="8291" LastActivityDate="2015-04-08T13:23:29.633" Title="Arduino Mega 2560: Busted Atmega 16U2" Tags="|arduino-mega|usb|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9932" PostTypeId="2" ParentId="9931" CreationDate="2015-04-08T13:23:29.633" Score="1" Body="&lt;p&gt;You can use your USB/Serial adapter to program the 2560 as the Arduino uses the 16u2 as the same thing to program the mega. You shouldn't remove the 16u2, just wait till you get the programmers and reflash the 16u2 with its firmaware and it will work, I actually had the same problem where the DFU didn't work and the 16u2 stopped responding, after reflashing the firmware it worked. The firmaware can be found under(as of 1.6.0):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;...\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\MEGA-dfu_and_usbserial_combined.hex&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to connect the Serial pins on the FTDI and Mega in the below fashion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; FTDI           MEGA&#xA; GND&amp;lt;-----------&amp;gt;GND&#xA; CTS&amp;lt;-----------&amp;gt;GND&#xA; VCC&amp;lt;-----------&amp;gt;VCC&#xA; TXD&amp;lt;-----------&amp;gt;RX0&#xA; RXD&amp;lt;-----------&amp;gt;TX0&#xA; RTS/DTR&amp;lt;---||--&amp;gt;RST&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Capacitor between the &lt;code&gt;DTR&lt;/code&gt; pin and &lt;code&gt;RST&lt;/code&gt; pin are needed this should be 100nF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6oMHQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have bought an I |SP programmer but it will take 3 weeks to reach and no I dont have another arduino, TBH I'm scared to buy another one... –  echo_salik&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you are buying clones, those will more than likely give issues as they will be cutting back on costs in places, i.e. QC checks.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-04-08T13:23:29.633" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="9934" PostTypeId="1" CreationDate="2015-04-08T15:40:34.670" Score="3" ViewCount="4219" Body="&lt;p&gt;Arduino newbie here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking about building an Arduino-based light switch to control the Philips Hue light system in my living room. I have standard wall light switches that power ceiling lamps, and I basically want all Hue lamps that are scattered around the room to be on when the switch is on, and off when the switch is off, so that I don't necessarily need the app or the Hue remote to turn the room's lights on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to install an Arduino on the ceiling instead of a normal lamp, so that its power supply is switchable through the light switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would configure it as a Hue remote control, e.g. with &lt;a href=&quot;https://github.com/bsalinas/ArduinoHue&quot; rel=&quot;nofollow&quot;&gt;ArduinoHue&lt;/a&gt;; if all works well, this would control the Hue lamps directly via ZigBee or via WiFi through the bridge - in both cases without having to use additional wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Whenever it gets power, I would have it &lt;code&gt;turnOn()&lt;/code&gt; all lamps, and whenever its power supply is turned off, I would have it &lt;code&gt;turnOff()&lt;/code&gt; all lamps.&lt;/strong&gt;&#xA;The first part seems simple to me, the second part - not so much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's my question:&#xA;&lt;strong&gt;Can I execute code in the event of the Arduino losing power, i.e. turn off my Hue lights with its last energy before shutting down?&lt;/strong&gt; Is there maybe some hardware configuration that would allow me to detect the power off event and retain enough energy through a battery or capacitors to still run the code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never worked with Arduino before, but I do have some colleagues that can help me out when there's trouble.&lt;/p&gt;&#xA;" OwnerUserId="8337" LastEditorUserId="8337" LastEditDate="2015-04-08T18:07:09.077" LastActivityDate="2018-02-21T08:52:26.973" Title="Execute Code on power off?" Tags="|power|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9937" PostTypeId="2" ParentId="9921" CreationDate="2015-04-08T17:16:18.813" Score="1" Body="&lt;p&gt;The reason for the Monitor being unable to work properly seems to be the length of the usb cable or a faulty usb port on my computer. I had a usb-cable extender, to which another (this time short) usb cable of my Arduino Nano was attached. It seemed to work fine while I was uploading things to Nano, but a quick serial exchange was, perhaps, not possible.Another usb port, or bypassing the usb cable extender brings everything back to normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a solution, while I still had no reason, how debugging through serial could influence that much on the chip behaviour itself, until now. I just thought it may well be the same power problem, as FTDI chip both powers the radio (even with the capacitor I installed!) and talks to computer through my long usb cable. If it starts talking, there could be no power for RF24 for a longer period than could be saved by my capacitor.&lt;/p&gt;&#xA;" OwnerUserId="8324" LastEditorUserId="8324" LastEditDate="2015-04-08T18:22:26.677" LastActivityDate="2015-04-08T18:22:26.677" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9938" PostTypeId="2" ParentId="9934" CreationDate="2015-04-08T17:22:23.367" Score="2" Body="&lt;p&gt;You could do what you want as you describe it, but are making things harder for yourself that you need to. If you can access the circuit from the switch at or near the switch (which should be 'easy' in most cases) then your system does not have to be depowered when the lighting circuit is as you will have access to the mains AC voltage on either side of the switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do wish to depower the processor when the lights are turned off you can easily add either a backup battery or a capacitor that runs the processor for &quot;long enough&quot;. You can also run a processor in &quot;sleep&quot; mode at extremely low power so that it is always running so have no 'wakeup time&quot;. And it is possible to power up a processor so that the delay is not noticeable for practical purposes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as &lt;a href=&quot;http://www.philips.co.nz/c-p/8718291547778/hue-personal-wireless-lighting&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Hue Bulbs&lt;/strong&gt;&lt;/a&gt; are Zigbee controlled, with provision ofr both iOS and Android control,  you should be able to control them via Zigbee directly without any connection to their wiring.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://ifttt.com/hue&quot; rel=&quot;nofollow&quot;&gt;Hue control&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.philips.co.nz/c-p/8718291547778/hue-personal-wireless-lighting/specifications&quot; rel=&quot;nofollow&quot;&gt;Hue specifications&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-08T17:22:23.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9939" PostTypeId="2" ParentId="8849" CreationDate="2015-04-08T17:23:10.133" Score="0" Body="&lt;p&gt;Are you using a USB hub? I had problems with my MBP when the Arduino was on a hub. Attached directly to the mac it was fine.&lt;/p&gt;&#xA;" OwnerUserId="8342" LastActivityDate="2015-04-08T17:23:10.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9940" PostTypeId="1" CreationDate="2015-04-08T18:10:41.663" Score="1" ViewCount="1298" Body="&lt;p&gt;This may be an extremely obvious question but I don't seem able to find a definitive answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Uno and a Sim900 GPRS/GSM shield fitted on top of it. I had I2C working on the Arduino to communicate with a Raspberry Pi, but now that I have put the shield on top I can't get the Pi to detect the Arduino. As far as I can tell the SDA and SCL pins on the Arduino aren't being used by the shield so does anyone have any idea how I go about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="8330" LastEditorUserId="8330" LastEditDate="2015-04-08T18:30:55.710" LastActivityDate="2022-10-02T06:09:01.083" Title="How do I use I2C from an Arduino Uno when I have a GSM shield mounted?" Tags="|arduino-uno|shields|gsm|i2c|communication|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9941" PostTypeId="1" CreationDate="2015-04-08T19:07:02.433" Score="0" ViewCount="852" Body="&lt;p&gt;I had a question, I tried to control a servo with the arduino, to the servo I attached a stick and at the end of the stick a little weight. After runing my code my servo tried to move the stick, but maybe it had not enough torque to move it so after that I paused the code. Then I tried to control the servo again without weight and this time it didn´t moved. Is it broken? why? Is there a posible solution? Thanks&lt;/p&gt;&#xA;" OwnerUserId="8344" LastActivityDate="2016-03-08T21:48:18.060" Title="Servo broken? Explanation, Solution" Tags="|motor|servo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9942" PostTypeId="2" ParentId="9926" CreationDate="2015-04-08T19:21:54.863" Score="1" Body="&lt;p&gt;It seems that's &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/atmega/ATmegaBOOT_168.c#L286&quot; rel=&quot;nofollow&quot;&gt;the reason&lt;/a&gt; why bootloader does not wait:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.&#xA;    if (! (ch &amp;amp;  _BV(EXTRF))) // if its a not an external reset...&#xA;        app_start();  // skip bootloader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now i have another question ;) How to reboot arduino board from the sketch to jump into bootloader waiting for upload command?&lt;/p&gt;&#xA;" OwnerUserId="8327" LastActivityDate="2015-04-08T19:21:54.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9943" PostTypeId="1" AcceptedAnswerId="9956" CreationDate="2015-04-08T19:32:13.263" Score="0" ViewCount="680" Body="&lt;p&gt;I want two Arduino Yuns in different private networks to communicate, i.e., behind two distinct routers of which at least one does &lt;em&gt;not&lt;/em&gt; have dynamic DNS, so its external IP may change from time to time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be reachable, this Yun could forward its router's external IP to the other Yun which has a fixed DNS name. But for this to work, it must be able to determine its router's external IP. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;How can the Yun find out that the external IP of the router has changed? The Yun will be runnning all the time. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the external router IP has changed (i.e., my Fritz.Box disconnects in the night and may receive a different IP when it reconnects), how can the Yun determine the new external IP? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If this is not the right place to ask, I'm happy for pointers to somewhere else (Server Fault SE forum?).&lt;/p&gt;&#xA;" OwnerUserId="8320" LastActivityDate="2016-02-05T11:49:23.220" Title="Find external router IP from Arduino Yun inside router network" Tags="|arduino-yun|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9945" PostTypeId="2" ParentId="8493" CreationDate="2015-04-08T22:45:12.837" Score="1" Body="&lt;p&gt;I have used the ProMicro and the nano for a few projects and they are both great boards.  I had a little bit of trouble getting the Pro Micro up and running but SparkFun has a great tutorial that should give you plenty of information to get that board up and running. If it's between those three boards, I would suggest the Pro Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider the Pro Mini (&lt;a href=&quot;https://www.sparkfun.com/products/11114&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11114&lt;/a&gt;).  You will need an FTDI programmer for it (&lt;a href=&quot;https://www.sparkfun.com/products/9873&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9873&lt;/a&gt;) but don't be discouraged by that.  It's really straightforward to use.  The cost is about the same as the Pro Micro and there are no special drivers required to get your computer talking to the Pro Micro.  The Pro Mini with the FTDI basic &quot;just works&quot;.  One disadvantage to the Pro Micro is that you won't be able to power it over USB unless you leave the FTDI attached to it...but like most Arduinos you can just power it over a pin with a wide range of voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really any of the boards you mentioned will do the job.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another board that's even smaller than the ones you mentioned would be the trinket or pro trinket by Adafruit.  Similar to the pro micro, you need some additional drivers but Adafruit is really good about providing tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to worry about external programmers and additional drivers and you want to power over usb get the Micro.  If you are powering off of a battery and need to wire it up anyway and are willing to do a little bit of configuration on your computer consider the Pro Micro or the trinket.&lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-04-08T22:45:12.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9946" PostTypeId="1" AcceptedAnswerId="9947" CreationDate="2015-04-08T22:46:41.350" Score="0" ViewCount="8334" Body="&lt;p&gt;Is there a compiler that I can use to run C on an arduino or any other way so that I can upload C programs to my arduino?&lt;/p&gt;&#xA;" OwnerUserId="8346" LastEditorUserId="37523" LastEditDate="2019-11-13T19:01:00.530" LastActivityDate="2019-11-13T19:01:00.530" Title="Running C for arduino" Tags="|arduino-uno|c|avr-gcc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9947" PostTypeId="2" ParentId="9946" CreationDate="2015-04-08T22:59:11.790" Score="2" Body="&lt;p&gt;Perhaps you should look into here&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Build-Process&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/arduino/Arduino/wiki/Build-Process&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino uses avr-gcc compiler. Basically, it is a C compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an step by step on how to customize this process using an avr-gcc compiler of your own here&#xA;&lt;a href=&quot;http://www.wikihow.com/Write-Arduino-Software-in-C&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.wikihow.com/Write-Arduino-Software-in-C&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I best recommend you downloading the arduino IDE on the official website to get things going. It has all the serial pairing stuff you don't really need to know to get started.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="8347" LastEditorUserId="47458" LastEditDate="2018-08-15T14:03:35.837" LastActivityDate="2018-08-15T14:03:35.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="9950" PostTypeId="2" ParentId="6712" CreationDate="2015-04-09T08:28:33.513" Score="0" Body="&lt;p&gt;I had the same problem and it appears that with Arduino IDE 1.6.x, libraries are defined &quot;per board&quot; and not shared any more.  At least, not all libraries are shared, and SoftwareSerial appears to be one of those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the solution is to copy the SoftwareSerial library from the Arduino installation at &lt;code&gt;[programs]/Arduino/hardware/arduino/avr/libraries/SoftwareSerial&lt;/code&gt; to your ATTiny hardware folder at &lt;code&gt;[documents]/Arduino/hardware/tiny/avr/libraries/SoftwareSerial&lt;/code&gt;, and restart the IDE, as per [this thread].&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=302080.0&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1084" LastActivityDate="2015-04-09T08:28:33.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9952" PostTypeId="1" AcceptedAnswerId="9967" CreationDate="2015-04-09T09:10:05.067" Score="0" ViewCount="2327" Body="&lt;p&gt;I encounter a problem when deploy matlab simulink model to Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following shows the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*The call to realtime_make_rtw_hook, during the after_make hook generated  the following error:&#xA;The build failed with the following message: The system cannot find the path specified&#xA;The build process will terminate as a result.&#xA;The build failed with the following message: The system cannot find the path specified。&#xA;Component: Simulink | Category: Block error*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When type &gt;&gt; getenv('path')&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ans =&#xA;&#xA;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\MathWorks\runtime\win64;E:\MathWorks\bin;E:\MathWorks\polyspace\bin;C:\Program Files\MATLAB\R2014b\runtime\win64;C:\Program Files\MATLAB\R2014b\bin;C:\Program Files\MATLAB\R2014b\polyspace\bin;C:\Program Files\Microsoft Windows Performance Toolkit\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did not see anything wrong with the path. I tried to solve the problem following the &quot;&lt;a href=&quot;http://www.mathworks.com/matlabcentral/answers/168555-what-does-the-path-in-the-system-cannot-find-the-path-specified-refer-to&quot; rel=&quot;nofollow&quot;&gt;http://www.mathworks.com/matlabcentral/answers/168555-what-does-the-path-in-the-system-cannot-find-the-path-specified-refer-to&lt;/a&gt;&quot;. However it does not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone know how to solve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS:Win8.1 Matlab 2014b 64bit&lt;/p&gt;&#xA;" OwnerUserId="8354" LastEditorUserId="8354" LastEditDate="2015-04-10T00:35:14.073" LastActivityDate="2015-04-10T06:43:54.233" Title="Problem with deploying matlab simulink mode to Arduino UNO" Tags="|arduino-uno|matlab|" AnswerCount="1" CommentCount="0" ClosedDate="2015-04-16T01:13:03.653" ContentLicense="CC BY-SA 3.0" />
  <row Id="9953" PostTypeId="1" CreationDate="2015-04-09T09:20:42.250" Score="-1" ViewCount="184" Body="&lt;p&gt;I have just got &lt;a href=&quot;http://www.induino.com/&quot; rel=&quot;nofollow&quot;&gt;Induino R3&lt;/a&gt;. I have installed Arduino on my Ubuntu. I tried blink example but it shows error &lt;code&gt;serial port COM1 not found&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think i need to select proper option from &lt;em&gt;serial port&lt;/em&gt;. But i can't click on it! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I am completely new to Arduino&lt;/p&gt;&#xA;" OwnerUserId="8355" LastEditorUserId="2881" LastEditDate="2015-04-09T15:37:28.287" LastActivityDate="2016-02-12T14:17:42.677" Title="How to use Induino R3 on Ubuntu 14.04" Tags="|serial|ubuntu|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9954" PostTypeId="2" ParentId="9926" CreationDate="2015-04-09T09:36:09.220" Score="2" Body="&lt;p&gt;The bootloader used on the Uno is &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/optiboot/optiboot.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;optiboot&lt;/a&gt;. But it contains the same &quot;feature&quot; of skipping straight to the application program if the reset source wasn't external.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could remove this feature and reprogram the bootloader to the chip (using an external programmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can use a dirty trick, and jump into the bootloader right after this check of the reset source happens. It happens to be right in the beginning, so not much has happened. The problem is that optiboot makes the assumption that the system is in a freshly reset state. So either you can write a flag to EEPROM to indicate that you just made an intentional WDT reset, or you can jump and hope for the best(not really recomendable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also write a routine to reset the system to the same state as after a reset. But it might not be trivial since there are a lot of reserved memory addresses that Atmel (the manufacturer of AVR's the microcontroller used on the uno, mega, and others) recommends you never write to. So basically you would have to more or less manually set a lot of registers to their reset default (usually zero), in the right order (eg. first tri-state / set pins to input).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can jump to the bootloader using this inline assembler code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;asm volatile (&quot;jmp 0x7e00&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Optiboot fits in 512 bytes = 256 AVR words. The bootloader address can be found in the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; Table 27-13. Boot Size Configuration, ATmega328/328P. It is printed in the datasheet as the word address, but the avr-as assembler takes the byte address. Word address 0x3f00 * 2 = 0x7e00 byte address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also see the address in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/optiboot/optiboot_atmega328.lst&quot; rel=&quot;nofollow noreferrer&quot;&gt;optiboot_atmega328.lst&lt;/a&gt; where code starts at byte address 0x7e00.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to jump past the boot source check we find the first address in optiboot_atmega328.lst that comes after the check. It is 0x7e0a. We then modify our bootloader jump:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;asm volatile (&quot;jmp 0x7e0a&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will want to make this jump first thing after a reset. We want to skip the Arduino initialization code. As per suggestion by user &lt;a href=&quot;https://arduino.stackexchange.com/users/8216/comintern&quot;&gt;Comintern&lt;/a&gt; in another question you can write a &lt;code&gt;main&lt;/code&gt; routine with a longer prototype to make the linker prefer it over the one shipped with Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(int argc, char** argv) {&#xA;  if (/* is your bootloader reset flag set in EEPROM */) {&#xA;    // first clear the flag&#xA;    // ...&#xA;&#xA;    // Jump to bootloader, after reset source check (optiboot on atmega328)&#xA;    asm volatile (&quot;jmp 0x7e0a&quot;);&#xA;  }&#xA;&#xA;  // Else proceed same as Arduino main&#xA;  init();&#xA;&#xA;  #if defined(USBCON)&#xA;      USBDevice.attach();&#xA;  #endif&#xA;&#xA;  setup();&#xA;&#xA;  //The one shot loop...&#xA;  loop();&#xA;  if (serialEventRun) serialEventRun();&#xA;  //Put whatever else you need to do between before the unending loop here.&#xA;&#xA;  for (;;) {&#xA;      loop();&#xA;      if (serialEventRun) serialEventRun();&#xA;  }&#xA;&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using these jumps depends on your bootloader being exactly the one referenced. AFAIK that is the one the Uno ships with, but that could change in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is untested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; overwrite trick depends on the linker exhibiting this behaviour which I think is also prone to change (it could be guaranteed by c/c++ standard, I don't know that).&lt;/p&gt;&#xA;" OwnerUserId="2973" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-09T09:36:09.220" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="9955" PostTypeId="1" AcceptedAnswerId="9957" CreationDate="2015-04-09T10:48:48.310" Score="5" ViewCount="8760" Body="&lt;p&gt;At school, our teacher always taught us to use .hpp (C++ Header files) with our .cpp (C++ files). But Arduino seems to use .h files (with .cpp links?).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When someone is programming in C (without C++ compiler) they have the chance to get linked to a .cpp file through a .h file? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;So why isn't a .cpp file always with a .hpp file? &lt;/li&gt;&#xA;&lt;li&gt;What are the drawbacks of using .hpp files with your .cpp files?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is not to start a discussion on what's best, please provide an answer with arguments that are not based on &quot;what you like to do more&quot;.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="6936" LastEditDate="2015-07-30T08:59:52.543" LastActivityDate="2015-07-30T08:59:52.543" Title="Why use .h files with .cpp?" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9956" PostTypeId="2" ParentId="9943" CreationDate="2015-04-09T11:32:54.157" Score="0" Body="&lt;p&gt;You can write a program that updates its own external IP every couple of minutes/hours, or when it doesn't get a response from another Yún/PC/server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use this link (or find another site of the web that gives you your external IP address): &lt;a href=&quot;http://www.realip.info/api/p/realip.php&quot; rel=&quot;nofollow&quot;&gt;http://www.realip.info/api/p/realip.php&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This link has a beautifully formatted information that you can easily extract. I have a similar solution on one of my servers that have a dynamic IP...&lt;/p&gt;&#xA;" OwnerUserId="1019" LastEditorUserId="46" LastEditDate="2016-01-06T10:58:48.420" LastActivityDate="2016-01-06T10:58:48.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9957" PostTypeId="2" ParentId="9955" CreationDate="2015-04-09T11:38:47.173" Score="14" Body="&lt;p&gt;The extension you use for a header file doesn't technically matter because the compiler never sees it. You could name it with the extension &lt;code&gt;.this-is-a-header-file&lt;/code&gt; and it would probably still work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler only handles the C/C++ source files, typically named &lt;code&gt;.c&lt;/code&gt; and &lt;code&gt;.cpp&lt;/code&gt;. However, before that happens, the preprocessor goes through and looks for any &lt;code&gt;#include&lt;/code&gt; lines. When it sees one, it basically copies the entire contents of the included file into the source file before it gets compiled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is normally used to include header files. However, the preprocessor doesn't know or care about different programming languages. All it does is process the raw text so there's nothing stopping you from including any text file you like, with any name or extension.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choosing to use &lt;code&gt;.h&lt;/code&gt; or &lt;code&gt;.hpp&lt;/code&gt; is mostly just personal preference. You could certainly argue that it lets you (as a programmer) distinguish between C/C++ code more easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the reason why &lt;code&gt;.h&lt;/code&gt; is more common is probably that C and C++ code is mixed so freely. You can generally compile C code as C++ without any problems, in which case it's the context (rather than the file itself) that tells you if it's C or C++. It's also possible to write a library in C++ which only exposes a C interface, meaning it could be used by C programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could definitely include a C++-specific header file in a C program by mistake. All that would happen is that the compiler wouldn't understand the contents of that header file. Sensible development environments don't link to a project/library when it sees a &lt;code&gt;#include&lt;/code&gt; directive (the Arduino IDE is the only one which does this, as far as I'm aware).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-09T11:38:47.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9958" PostTypeId="1" CreationDate="2015-04-09T12:00:50.080" Score="2" ViewCount="1088" Body="&lt;p&gt;I am building an access control project which uses two SoftwareSerial ports. One will be used for communication with an RFID reader and another one to receive serial messages via an Xbee (e.g. remote commands). The hardware serial port is used for a cabled serial connection to another remote &quot;server&quot;-Arduino, which then actuates the relays. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the Arduino website, the SoftwareSerial Library has, amongst others, the following limitation:  - &quot;&lt;strong&gt;&lt;em&gt;If using multiple software serial ports, only one can receive data at a time&lt;/strong&gt;.&lt;/em&gt;&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan is to poll constantly / on regular intervals both SoftwareSerial ports, e.g. by checking RFID_Serial.available() and XBeeSerial.available(), and if it turns out that data is available, to read it out and parse it accordingly. This obviouosly has to be done in an alternating fashion, i.e. one after the other. My questions are the following. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Can I initialise the ports in void setup() &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;RFID_Serial.begin(..);&#xA;XBeeSerial.begin(..);&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... and are they then both actually active simultaneously (i.e. ready for commans like xxxxSerial.available(), or xxxxSerial.read(), or is in this case only the XBeeSerial active, because I it was the last one to be initialised?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) If I want to poll one after the other, do I have to &quot;close&quot; one SoftwareSerial port, e.g. by RFID_Serial.end(); and open the other (XbeeSerial.begin(..)) before I can do XBeeSerial.available() or read out by XBeeSerial.read()? &lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-04-09T12:00:50.080" Title="Multiple SoftwareSerial ports - how to handle the limitations" Tags="|softwareserial|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9959" PostTypeId="1" CreationDate="2015-03-10T10:05:06.173" Score="2" ViewCount="916" Body="&lt;p&gt;I need help with interfacing ov7670 to Aduino Uno. I know there is a lot of literature available but the problem is that all this literature is for ov7670 without FIFO. I have Ov7670 with FIFO and its a 22-pin image sensor. I haven't been able to relate the available tutorials to my module. Any help in this regard is appreciated. (I need Wire Configuration as well as Code to get images).&#xA;Kind Regards,&lt;/p&gt;&#xA;" OwnerUserId="18473" OwnerDisplayName="Xtreme_Enigma" LastEditorUserId="6452" LastEditDate="2015-04-10T15:25:00.007" LastActivityDate="2015-04-10T15:25:00.007" Title="Interfacing Arduino Uno with OV7670 (with FIFO)?" Tags="|arduino-uno|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9960" PostTypeId="2" ParentId="9941" CreationDate="2015-04-09T16:50:17.800" Score="0" Body="&lt;p&gt;You may have broken the gears if the servo was not rated for the load applied or if the servo was rotated too far (by software) 1ms and 2ms should be your (conservative) software limits, though most servos will work from 0.7ms to 2.3ms.&lt;/p&gt;&#xA;" OwnerUserId="8362" LastEditorUserId="8420" LastEditDate="2015-04-12T20:00:21.013" LastActivityDate="2015-04-12T20:00:21.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9961" PostTypeId="1" CreationDate="2015-04-09T17:54:54.130" Score="3" ViewCount="1250" Body="&lt;p&gt;I want Arduino to conserve energy and turn it on automatically only when the lights is on. Can I use some kind of light sensor and put it in between power supply and arduino somehow? Ideally light sensor will power from the same power source, if possible.&#xA;I'm not an electrical engineer - just enthusiast, so please explain your idea as detailed as possible. Many thanks! &lt;/p&gt;&#xA;" OwnerUserId="8363" LastActivityDate="2015-05-12T20:39:30.680" Title="How to power Arduino only when light is on" Tags="|sensors|power|battery|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9962" PostTypeId="1" CreationDate="2015-04-09T17:56:26.340" Score="0" ViewCount="576" Body="&lt;p&gt;I have very limited knowledge regarding electronics. Please help me cure my ignorance on the subject of robotics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to power the Arduino Uno R3, US-015 ultrasonic sensor, and the L298N motor controller from a single power source (7.2v). However, I'm not sure if this diagram is correct. If it is functional, will it last that way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sPyn6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this diagram is deemed wrong, please suggest alternatives with one power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Advance thanks to those who would reply. Elaborate answers would be very much appreciated. :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Since it's deemed incorrect, I'm going to power Arduino through the DC barrel jack and power the L298N motor controller through the Vin and the ultrasonic sensor from the Arduino 5v output. Is it wise to do this?&lt;/p&gt;&#xA;" OwnerUserId="8364" LastEditorUserId="8364" LastEditDate="2015-04-10T05:53:03.987" LastActivityDate="2015-04-10T12:08:55.860" Title="Alternative Way to Power Components on an Arduino" Tags="|arduino-uno|power|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9963" PostTypeId="1" CreationDate="2015-04-09T19:50:09.697" Score="2" ViewCount="1406" Body="&lt;p&gt;I am currently working on my first Arduino project and I am having some issues that I am seeking help with. The robot I am building must have human following capabilities and to do so I am using 3 PIR sensors (One on the front, one on the left and one on the right) and an Ultrasonic Sensor so the robot won't run into a wall or a person it is following. To handle the motors I am using the Adafruit Motor Shield (V.1)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I am trying to make this work is as follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot's main PIR sensor is the one attached to the front. If this sensor reads HIGH then the robot will move forward while checking its distance from any objects in front of it in which case it stops and reverses until there is at least 30cm of space between itself and the object in front. The radius of this sensor had to be reduced so that it only reads HIGH if the person is exactly in front of the robot. This was done using carton paper and black duct tape. Two images of this have been provided below in case this has something to do with my issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/q8R9m.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3CcxR.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other 2 PIR sensors attached to the sides will tell the robot if it should turn left or right. If the left PIR is triggered then the robot will start turning left and keep doing so until the front PIR finally reads HIGH, and then it moves forward. The same thing is done with the right PIR except that it moves right. These PIR sensors are handled using interrupts on the Arduino Mega 2560 board as can be seen in the provided code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I am using can be found below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AFMotor.h&amp;gt;&#xA;#include &amp;lt;NewPing.h&amp;gt;&#xA;&#xA;#define trigPin 34&#xA;#define echoPin 32&#xA;&#xA;NewPing sonar(trigPin, echoPin);&#xA;int minimumDistance = 30;&#xA;int currentDistance = 0;&#xA;&#xA;int calibrationTime = 60;&#xA;int redLED = 22;&#xA;int greenLED = 24;&#xA;&#xA;int PIR = 26;&#xA;volatile int PIR_val = 0;&#xA;int PIR_left = 19; // (interrupt 4)&#xA;int PIR_right = 18; // (interrupt 5)&#xA;&#xA;AF_DCMotor motorL(1, MOTOR12_64KHZ);&#xA;AF_DCMotor motorR(2, MOTOR12_64KHZ);&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(redLED, OUTPUT);&#xA;  pinMode(greenLED, OUTPUT);&#xA;&#xA;  pinMode(PIR, INPUT);&#xA;  pinMode(PIR_left, INPUT);&#xA;  pinMode(PIR_right, INPUT);&#xA;&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;&#xA;  digitalWrite(redLED, HIGH);&#xA;  // Calibration for PIR sensors&#xA;  for (int i = 0; i &amp;lt; calibrationTime; i++)&#xA;  {&#xA;    delay(1000);&#xA;  }&#xA;  digitalWrite(redLED, LOW);&#xA;  digitalWrite(greenLED, HIGH);&#xA;&#xA;  attachInterrupt(4, turnLeft, RISING);&#xA;  attachInterrupt(5, turnRight, RISING);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(50);&#xA;  currentDistance = sonar.ping_cm();&#xA;&#xA;  if (currentDistance &amp;lt; minimumDistance &amp;amp;&amp;amp; currentDistance &amp;gt; 0)&#xA;  {&#xA;    moveBackward();&#xA;  }&#xA;  else&#xA;  {&#xA;    PIR_val = digitalRead(PIR);&#xA;&#xA;    if (PIR_val == HIGH)&#xA;    {&#xA;      moveForward();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void moveForward()&#xA;{&#xA;  motorL.run(FORWARD);&#xA;  motorL.setSpeed(180);&#xA;  motorR.run(FORWARD);&#xA;  motorR.setSpeed(200);&#xA;}&#xA;&#xA;void moveBackward()&#xA;{&#xA;  motorL.run(RELEASE);&#xA;  motorR.run(RELEASE);&#xA;  motorL.run(BACKWARD);&#xA;  motorL.setSpeed(190);&#xA;  motorR.run(BACKWARD);&#xA;  motorR.setSpeed(225);&#xA;&#xA;  while (currentDistance &amp;lt; 30 &amp;amp;&amp;amp; currentDistance &amp;gt; 0)&#xA;  {&#xA;    currentDistance = sonar.ping_cm();&#xA;  }&#xA;&#xA;  motorL.run(RELEASE);&#xA;  motorR.run(RELEASE);&#xA;}&#xA;&#xA;void turnLeft()&#xA;{&#xA;  motorL.run(BACKWARD);&#xA;  motorL.setSpeed(150);&#xA;  motorR.run(FORWARD);&#xA;  motorR.setSpeed(150);&#xA;&#xA;  // While front PIR is reading LOW&#xA;  while (PIR_val == LOW)&#xA;  {&#xA;    PIR_val = digitalRead(PIR);&#xA;  }&#xA;  // After front PIR reads HIGH&#xA;  moveForward();&#xA;}&#xA;&#xA;void turnRight()&#xA;{&#xA;  motorR.run(BACKWARD);&#xA;  motorR.setSpeed(150);&#xA;  motorL.run(FORWARD);&#xA;  motorL.setSpeed(150);&#xA;&#xA;  // While front PIR is reading low&#xA;  while (PIR_val == LOW)&#xA;  {&#xA;    PIR_val = digitalRead(PIR);&#xA;  }&#xA;  // After front PIR reads HIGH&#xA;  moveForward();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first issue I am having is that as soon as the PIR sensors are done calibrating, the robot starts moving forward by itself. Even if I leave the robot alone inside a room with the door closed, after the calibration time passes the robot automatically moves forward on its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other issue I am having is also with the front PIR sensor. While the robot is turning and looking for a human as seen in the 'turnLeft()' and 'turnRight()' methods, the robot will sometimes move forward toward a random direction instead of towards me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried replacing the front PIR sensor twice and the sensor itself does not seem to be the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PIR sensors I am using are the 'HC-SR501' model.&#xA;For all PIR sensors, the delay time is set to the lowest possible time (5 seconds) and the sensitivity is set to full.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I welcome any input or suggestions whatsoever. If you would like me to provide any additional information about this project please ask and I will do so.&lt;/p&gt;&#xA;" OwnerUserId="8369" LastEditorUserId="2944" LastEditDate="2015-04-10T15:25:20.693" LastActivityDate="2022-11-25T23:04:15.623" Title="Issues with PIR Sensor triggering by itself" Tags="|programming|arduino-mega|sensors|" AnswerCount="1" CommentCount="1" ClosedDate="2022-11-26T06:47:54.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="9964" PostTypeId="2" ParentId="9899" CreationDate="2015-04-09T21:27:47.693" Score="0" Body="&lt;p&gt;I usually send structures from arduino via serial port to PC &lt;del&gt;and use the memcpy function to do it.&lt;/del&gt;&#xA;Let's say you have the struct data d (&lt;em&gt;as pointed by the comments the memcpy as unnecessary. Use cast or union&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; struct data state;&#xA; len = sizeof(state);&#xA; Serial.write((uint8_t *)&amp;amp;state,len);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is useful to create a starting and ending character to delimit your important data and make sure you receive all data and good information.&#xA;Let me give you one of my recent work example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&#xA;void send_state(){&#xA; len = sizeof(state);&#xA; Serial.write('S');&#xA; Serial.write((uint8_t *)&amp;amp;state, len);&#xA; Serial.write('E');&#xA; return;&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example the struct state is preceded with &quot;S&quot; (start) and succeeded with &quot;E&quot;.&#xA;Then in python, for example, you can get the data using the unpack function. In my case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;&#xA;# wait for data from arduino&#xA;myByte = port.read(1)&#xA;if myByte == 'S':&#xA;    data = port.read(39)&#xA;    myByte = port.read(1)&#xA;    if myByte == 'E':&#xA;        # is  a valid message struct&#xA;        new_values = unpack('&amp;lt;c6BH14B4f', data)&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See if arduino sends data in little endian. The one I have used to send it. &lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2017-04-27T17:42:59.213" LastActivityDate="2017-04-27T17:42:59.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9965" PostTypeId="1" AcceptedAnswerId="9970" CreationDate="2015-04-09T22:52:48.097" Score="2" ViewCount="4255" Body="&lt;p&gt;I am working on a human following robot project and I am trying to achieve this with 1 Ultrasonic sensor that makes sure the robot won't crash into something and 3 PIR sensors that will detect human movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot has an Ultrasonic Sensor and a PIR sensor attached to the front and a PIR sensor attached to the right side and another PIR sensor attached to the left side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the front PIR reads HIGH, then the robot will move forward. If the left or right PIR reads HIGH, then the robot will start turning in a 360 degree motion to the left/right side and will keep on doing so until the front PIR reads HIGH, and the robot moves forward again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working with this build and I am having issues with the sensors. Sometimes they read HIGH when they shouldn't and sometimes they read LOW when they should be reading HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, what can I do to help the PIR sensors with getting the correct reading and is it possible to do so while the robot is turning? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, how will calibration work here? Am I able to let the robot turn slowly in 360 degree motion so the 3 PIR sensors will be calibrated with the rooms surrounding or is this a dumb question? If so I'm sorry, I am pretty new to PIR sensors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help everyone. I have now replaced the side PIR sensors with Ultrasonic sensors. I have kept the front PIR sensor though. It is working a lot better than with the side PIR sensors and I thank you all for your input.&lt;/p&gt;&#xA;" OwnerUserId="8369" LastEditorUserId="8369" LastEditDate="2015-04-14T15:36:55.400" LastActivityDate="2016-04-23T04:47:38.340" Title="Detect movement on moving robot? PIR Sensor" Tags="|arduino-mega|sensors|robotics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9966" PostTypeId="1" CreationDate="2015-04-09T23:02:25.640" Score="0" ViewCount="573" Body="&lt;p&gt;I am fairly new to arduino boards and I was wondering which board to use. I was looking into the edison board because it has built in wifi and bluetooth.&lt;/p&gt;&#xA;" OwnerUserId="8378" LastEditorUserId="8378" LastEditDate="2015-04-10T02:32:09.310" LastActivityDate="2015-04-12T15:05:55.390" Title="What board to use to send a text message via an arduino board" Tags="|arduino-galileo|edison|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9967" PostTypeId="2" ParentId="9952" CreationDate="2015-04-10T06:43:54.233" Score="0" Body="&lt;p&gt;Right click on your MATLAB shortcut and click &quot;run as administrator&quot;. See if helps. Then do all the necessary steps and see if it happens again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also test with x86 version. I have seen lots of these kinds of error with x64 version. Always had compiling related issues with MATLAB x64 and Simulink!&lt;/p&gt;&#xA;" OwnerUserId="8269" LastActivityDate="2015-04-10T06:43:54.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9968" PostTypeId="5" CreationDate="2015-04-10T07:14:40.757" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-10T07:14:40.757" LastActivityDate="2015-04-10T07:14:40.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9969" PostTypeId="4" CreationDate="2015-04-10T07:14:40.757" Score="0" Body="A robot kit controlled by Arduino and others compatible boards." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-04-10T15:25:44.043" LastActivityDate="2015-04-10T15:25:44.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9970" PostTypeId="2" ParentId="9965" CreationDate="2015-04-10T07:21:50.973" Score="1" Body="&lt;p&gt;Basically you have a robot and sensors that can detect movement.&#xA;There is one caveat though. For the PIR sensors to (non false-positive) detect motion, they have to be stationary (as far as I know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with only these PIR sensors it's unlikely that you can track something well.&#xA;Tracking something would be done best by using a range/proximity sensor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The image below, seems to be a cute robot, with eyes.&#xA;You could take 3 sensors and place them under an angle (one forward, one forward/left and one forward/right) [picture 2]. Or just have one that rotates (will be more difficult) [picture 1].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would want the robot to start following anything that comes close (or when one of the sensors sees a difference in distance. And then the robot will try to keep that distance, brake when he gets closer, drive when he gets further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's working, you can implement the sensors at the side, that if suddenly he loses track of the object/person, he'll adjust his alignment so that the middle sensor sees it again. This could also be done by simpler sensors [picture 3]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the robot gets to close, and the other object doesn't try to run for quite a time, you can make him check for another target. (With a PIR or by rotating and stopping rotating to check range/pir)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this solution is more applicable as with only PIR sensors, as it's usefull to know the range when you're following something. You don't want to bash into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ll83.jpg&quot; alt=&quot;Cute robot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9YGWD.jpg&quot; alt=&quot;3-directional ping&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hCzN5.jpg&quot; alt=&quot;proximity sensor&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-10T07:21:50.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9972" PostTypeId="1" CreationDate="2015-04-10T07:36:13.527" Score="2" ViewCount="425" Body="&lt;p&gt;I'm having a SparkFun 9 DoF sensor stick including the following components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ADLX345 - Accelerometer &lt;/li&gt;&#xA;&lt;li&gt;ITG3200 Gyroscope &lt;/li&gt;&#xA;&lt;li&gt;HMC5843 - Magnetometer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Im currently working on a project in which I need to calculate the yaw angle, I tried using the gyroscope and the accelerometer for this and found out that it didn't work for the yaw angle but only for the roll and pitch angles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im trying to do my implmentation in Simulink where I read the sensors via I2C through an S-function. My sensor stick is connected to an Arduino Mega and it works well for both the accelerometer and the gyroscope but when I try to do the same thing for the magnetometer all the signals have a constant value of zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For doing this i include the two libraries &lt;code&gt;wire.h&lt;/code&gt;, &lt;code&gt;wire.cpp&lt;/code&gt;, &lt;code&gt;twi.h&lt;/code&gt; and &lt;code&gt;twi.c&lt;/code&gt;. This is the same libraries that are used in many Arduino sketches for reading I2C-devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the following code for the initialization:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (xD[0]!=1) {&#xA;&#xA;  # ifndef MATLAB_MEX_FILE&#xA;&#xA;  Wire.begin(); // start i2c bus&#xA;&#xA;  Wire.beginTransmission(MAG_ADDRESS); // 0x3C&#xA;  Wire.write(MAG_MEASMODE);            // 0x02&#xA;  Wire.write(MAG_MEASMODEC);           // 0x00&#xA;  Wire.endTransmission();&#xA;&#xA;  # endif   &#xA;  // initialization done &#xA;  xD[0]=1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the output I use the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// wait until after initialization is done&#xA;if (xD[0]==1) {&#xA;&#xA;# ifndef MATLAB_MEX_FILE&#xA;&#xA;    unsigned int i = 0;         // counter var.&#xA;&#xA;    unsigned char lb_mag[6] = {0};&#xA;&#xA;    int temp_mag[6] = {0};&#xA;&#xA;    Wire.beginTransmission(MAG_ADDRESS); //0x3C&#xA;    Wire.write(MAG_XMSB);                //0x03&#xA;    Wire.requestFrom(MAG_ADDRESS,6);     //requesting MSB,LSB of XYZ-component&#xA;    while (Wire.available()){&#xA;        lb_mag[i++] = Wire.read();&#xA;    }&#xA;&#xA;    Wire.endTransmission();&#xA;&#xA;    temp_mag[0] = (lb_mag[0] &amp;lt;&amp;lt; 8) + lb_mag[1];  // convert x reading to int16&#xA;    temp_mag[1] = (lb_mag[2] &amp;lt;&amp;lt; 8) + lb_mag[3];  // convert y reading to int16&#xA;    temp_mag[2] = (lb_mag[4] &amp;lt;&amp;lt; 8) + lb_mag[5];  // convert z reading to int16&#xA;&#xA;&#xA;    for(i=0;i&amp;lt;3;i++){&#xA;       magnet[i] = temp_mag[i];&#xA;    }&#xA;&#xA;# endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any ideas on why this does not work? As I mentioned before it works for both the gyroscope and the accelerometer. Anyhow, all help is appreciated! Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="8386" LastActivityDate="2015-07-07T08:50:03.083" Title="Problem reading HMC5843 - Magnetometer in Simulink" Tags="|arduino-mega|sensors|matlab|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9973" PostTypeId="1" AcceptedAnswerId="9974" CreationDate="2015-04-10T07:37:41.120" Score="1" ViewCount="9035" Body="&lt;p&gt;For a project I am interested in using the HC-05 Bluetooth module to control five LEGO Mindstorms Bricks simultaneously. For this to work the Bluetooth module will obviously have to be paired / connected with the five bricks at the same time. This means that the HC-05 Bluetooth module will have to be master in the piconet and the five bricks the slaves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyone who has any experience with using the Arduino Uno and HC-05 Bluetooth module to send data to multiple, connected, slaves? If not, are there any alternative Bluetooth modules? And if Bluetooth modules compatible with the Arduino Uno cannot connect to multiple slaves at the same time, are there other ways that an Arduino can control multiple Bluetooth slaves at the same time?&lt;/p&gt;&#xA;" OwnerUserId="8385" LastActivityDate="2016-09-05T00:25:51.800" Title="Is it possible for a HC-05 Bluetooth module to have multiple slaves" Tags="|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9974" PostTypeId="2" ParentId="9973" CreationDate="2015-04-10T08:55:59.050" Score="1" Body="&lt;p&gt;After some research, it looks like multiple slaves aren't possible with this particular module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;http://en.wikipedia.org/wiki/Bluetooth#Implementation&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt; the Bluetooth technology allows a master to communicate with 7 slaves, but this option isn't implemented in the HC-05.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-04-10T08:55:59.050" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9975" PostTypeId="2" ParentId="9966" CreationDate="2015-04-10T09:03:14.757" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://arduino.cc/en/Guide/ArduinoGSMShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;GSM Shield&lt;/a&gt; will suit your needs. This is a &lt;em&gt;shield&lt;/em&gt;, meaning that is a board that will go &lt;strong&gt;on top&lt;/strong&gt; of another Arduino board (e.g UNO, Leonardo, ..., choose whatever you'll need).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what it will look like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/h4SvU.jpg&quot; alt=&quot;Arduino UNO and the GSM Shield stacked&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To send SMS you'll also need a working &lt;strong&gt;SIM card&lt;/strong&gt; and the &lt;strong&gt;GSM library&lt;/strong&gt; to program the shield. On the previously linked page there are some tutorials to follow in order to check the basic functioning of the setup.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-04-10T09:03:14.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9976" PostTypeId="1" AcceptedAnswerId="9978" CreationDate="2015-04-10T09:24:13.980" Score="3" ViewCount="8996" Body="&lt;p&gt;I accidently bought a &quot;Common Anode&quot; 7-segment display instead of a &quot;Common Cathode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that the polarity of the leds within the display is 'reversed'. So instead of putting the common pin on GND I have to put it to 5v (with current limiting resistor)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions on this are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I still use only one current limiting resistor on the common pin? Instead of a resistor on every segment pin.&lt;/li&gt;&#xA;&lt;li&gt;Can I use the pins from arduino to drive it (withouth pull-up/pull-down?) By making the signal &lt;code&gt;LOW&lt;/code&gt; the current will flow from 5V common anode to the arduino and thus the segment wil light?&lt;/li&gt;&#xA;&lt;li&gt;Can I still use a shift register to drive the segment led? (By inversing the outputs (in software))&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Obviously I would like to have wiring more like this&lt;/strong&gt; (but then I would ofcourse change  the GND line to a 5V line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/S6MnF.jpg&quot; alt=&quot;Better wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The wiring below is the worst-case wiring I can think of.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/t9mfh.png&quot; alt=&quot;Wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;^ So can I avoid this, when using a &lt;code&gt;Common Anode 7-segment display&lt;/code&gt; or am I forced to buy a &lt;code&gt;Common Cathode 7-segment display&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-04-10T09:34:07.670" LastActivityDate="2017-01-02T10:23:32.347" Title="7-Segment Common Anode" Tags="|led|electronics|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9977" PostTypeId="2" ParentId="8273" CreationDate="2015-04-10T09:45:48.247" Score="7" Body="&lt;p&gt;The Neo 6M takes a bit of time to fix when first powered on. If your board is fitted with a small battery it will most probably be flat and will take an hour or two to charge up. It is there to provide charge to the EEPROM and the onboard RTC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check that the leads on the battery are not shorting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not get a valid data sentence out of the GPS until the RTC can sync time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Error message that you got from Mike Hart routine first says that there is not enough data to do a FIX and second the Date Time is not syncing.&lt;/p&gt;&#xA;" OwnerUserId="8388" LastEditorUserId="84" LastEditDate="2015-04-10T17:00:08.323" LastActivityDate="2015-04-10T17:00:08.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9978" PostTypeId="2" ParentId="9976" CreationDate="2015-04-10T10:11:18.080" Score="3" Body="&lt;p&gt;You can use a single resistor on the common pin if you want. The problem is that lighting up multiple segments at the same time will substantially reduce the brightness of each one. You could work around that by lighting each segment one at a time in very quick succession though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be possible to control the display directly from the IO pins by setting them LOW. In this configuration, they will be &lt;strong&gt;sinking&lt;/strong&gt; current (rather than &lt;strong&gt;sourcing&lt;/strong&gt; it). It depends on the specification of the display and on what resistor you use though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, try to keep the current &lt;strong&gt;below 20mA&lt;/strong&gt; and it should be OK (assuming you're using a standard 5V Arduino). For example, if each segment has a forward voltage drop of 2V, you would want to use a resistor of around 180 Ohm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Controlling the display directly from a shift register is probably not possible, although once again it depends on its specification. Shift registers usually aren't designed to sink enough current so you'll need something like a transistor on each output.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-10T10:11:18.080" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9979" PostTypeId="2" ParentId="9962" CreationDate="2015-04-10T12:08:55.860" Score="2" Body="&lt;p&gt;Using a motor controller to power an Arduino or analog peripherals is probably unwise as the source is liable to be noisy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better, probably, is to power the Arduino from the 7.2V supply via a noise filtering resistor into the Arduino's &lt;strong&gt;Vin&lt;/strong&gt; terminal.&lt;br&gt;&#xA;&lt;strong&gt;NBNBNB&lt;/strong&gt; 7.2V input &lt;strong&gt;MUST&lt;/strong&gt; be to Arduino Vin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a small series resistor from 7.2V to Vin and a large filter cap at Vin to ground. Then power the sensor from Arduino 5 V output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltage drop in series resistor from 7.2V to Vin must drop under 2V.&lt;br&gt;&#xA;Rmz is &amp;lt;= Vdrop / Iload&lt;br&gt;&#xA;For say 50 mA load Rseries = V/I = 2V max / 0.05 = 40 Ohms .&#xA;For 100 mA R &amp;lt;= 2/.1 20 Ohms.&lt;br&gt;&#xA;So probably try about 22 Ohms to start.&lt;br&gt;&#xA;If Vdrop is &gt; 2V a smaller R is needed.&lt;br&gt;&#xA;If Vdrop is &amp;lt;&amp;lt; 2V increase R.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the capacitor at Vin - the larger the better.&lt;br&gt;&#xA;100 uF good. 1000 uF better. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resistor power dissipation is I^2 x R.&lt;br&gt;&#xA;So at even 100 mA Pres = 0.1^2 x 22R = 0.22W&lt;br&gt;&#xA;A 1/2 Watt resistors would suffice.&#xA;A  1 W resistor would do no harm and would tolerate the heat better. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The 22 Ohm resistor and large capacitor form an RC (Resistor + Capacitor) noise filter.&lt;br&gt;&#xA;This greatly reduces motor noise which appears on the 7.2V line.&lt;br&gt;&#xA;This is very standard practice in real world installations like this.&lt;br&gt;&#xA;An inductor based filter can be better but RC should suffice. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-10T12:08:55.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9980" PostTypeId="2" ParentId="9425" CreationDate="2015-04-10T13:11:04.750" Score="10" Body="&lt;p&gt;It turns out that the &lt;code&gt;theme.txt&lt;/code&gt; configuration file is &lt;em&gt;not&lt;/em&gt; located alongside the &lt;code&gt;preferences.txt&lt;/code&gt; file, but alongside/under the Arduino application's &lt;code&gt;.jar&lt;/code&gt; files. Thus, for the current version (1.6.3):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;on OS X, &lt;code&gt;.../Arduino-1.6.3.app/Contents/Java/lib/theme/theme.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;on Win7, &lt;code&gt;C:\Program Files\Arduino\lib\theme\theme.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;on Linux, &lt;code&gt;.../arduino-1.6.3/lib/theme/theme.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;on Windows 10, when installed as an App, C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\lib\theme\theme.txt, however it does not seem possible to edit it - it can be opened in notepad++ but a save fails.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;See an associated Github issue, &lt;a href=&quot;https://github.com/arduino/Arduino/issues/1878&quot; rel=&quot;noreferrer&quot;&gt;IDE Background and print color options needed&lt;/a&gt;, for a little more discussion.&lt;/p&gt;&#xA;" OwnerUserId="8391" LastEditorUserId="-1" LastEditDate="2017-10-14T09:04:37.073" LastActivityDate="2017-10-14T09:04:37.073" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="9981" PostTypeId="2" ParentId="9976" CreationDate="2015-04-10T13:46:12.390" Score="4" Body="&lt;p&gt;Sorry about the crudity of my image, but you don't always need those transistors. Peter has already said so, but I wanted to explain a bit further.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/01Y8C.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing is that you need to set a pin to LOW to light up the led, and HIGH to turn it off. Just use a &lt;code&gt;!&lt;/code&gt; to make your code more intuitive if your like. So e.g. &lt;code&gt;digitalWrite(segmentA, !HIGH)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some limitations. A pin can sink up to 40mA (no problem here), but the total sink current for the digital pins &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt; shouldn't exceed 100mA. The same goes for pins &lt;code&gt;5&lt;/code&gt; to &lt;code&gt;13&lt;/code&gt;. And the same goes for the analog pins. So either limit the current through the leds to around 10mA, or make sure no more than 5 leds are lit at the same time, or connect half of the segments to on of the above mentioned groups, and the other half another (f.y.i. analog pins can be used just like digital pins).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-04-10T19:45:18.647" LastActivityDate="2015-04-10T19:45:18.647" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="9982" PostTypeId="2" ParentId="9966" CreationDate="2015-04-10T14:49:43.437" Score="2" Body="&lt;p&gt;Another option is the &lt;a href=&quot;https://store.spark.io/?product=spark-core&quot; rel=&quot;nofollow&quot;&gt;Spark Core or Photon&lt;/a&gt;.  It's not an Arduino but it's very close.  I have Arduino sketches that I have ported right over with no modification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Spark boards are internet-connected and you can send text messages or emails using IFTTT.  It's also going to be a lot more cost effective than an Arduino plus wifi shield, particularly if you can wait until June for the $19 Photon to ship.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a Raspberry Pi connected to the internet to just do the email part but that's a little more trouble than it's worth. &lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-04-10T14:49:43.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9983" PostTypeId="2" ParentId="9961" CreationDate="2015-04-10T15:11:06.220" Score="0" Body="&lt;p&gt;If it's OK for it go off (not just to sleep) when the light is off, power it from the lighting circuit. These two parts will do it without messing with the electrics:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fZnYv.png&quot; alt=&quot;enter image description here&quot;&gt;   &lt;img src=&quot;https://i.stack.imgur.com/2SR5X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The light socket adapter with two outlets is a hardware-store part, probably about USD$3, and the USB charger makes a compact and useful Arduino 5v power supply, USD$6 at Amazon right now. (Apple's little USB power cube might fit better but is more expensive). I use the Nokias for Arduino power supplies and their no-load voltage is just barely over 5v. If you substitute a different one, that would be a worthwhile test to make before you connect it to your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-10T15:11:06.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9985" PostTypeId="2" ParentId="9953" CreationDate="2015-04-10T17:13:32.107" Score="1" Body="&lt;p&gt;Not 100% sure of the specific differences between your board and a normal Arduino[clone], but I've never seen serial devices referenced in Ubuntu via COM# labels(Granted I've only used or needed to use serial type devices in the last year, so I could be a bit under experienced).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, usually I find serial devices available at /dev/ttyXXX. On my Lubuntu 14.04 installs, my USB connected Arduinos all show up as /dev/ttyACM#. I have an FTDI programmer I usually use on wifi routers which generally shows up as /dev/tty#.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rule of thumb in Linux, everything is a file somewhere.&lt;/p&gt;&#xA;" OwnerUserId="8393" LastActivityDate="2015-04-10T17:13:32.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9986" PostTypeId="1" AcceptedAnswerId="9988" CreationDate="2015-04-10T13:06:55.540" Score="0" ViewCount="227" Body="&lt;p&gt;I have an Arduino Uno rev 3 and an Arduino Nano in my Setup. I want to create a proof of concept, where one Arduino triggers the other via the Digital IOs.&#xA;Arduino 1 sets a blinking signal on a digital pin (500ms delay between high/low), which is received by arduino 2. If the signal is high, Arduino 2 triggers a LED (digital pin to LED+; LED- over 330 Ohm resistor to ground), so the signal gets looped through somehow. The grounds of the two Arduinos are connected, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UBWWU.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code Arduino #1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  DDRD |=_BV(PD7); //Sets Digital Pin 7 as Output&#xA;}&#xA;&#xA;void loop() {&#xA; PORTD |=_BV(PD7); // equivalent with digitalWrite(7, HIGH);&#xA; delay(500);&#xA; PORTD &amp;amp;=~_BV(PD7); // equivalent with digitalWrite(7, LOW);&#xA; delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code Arduino #2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  DDRD &amp;amp;=~_BV(PD7); //Sets Digital Pin 7 as Input&#xA;  DDRD |=_BV(PB0); //Set Digital Pin 8 as Output&#xA;}&#xA;&#xA;bool set = false;&#xA;&#xA;void loop() {&#xA;  if((PIND&amp;amp;_BV(PD7))==_BV(PD7)) { //true if digital pin 7 is set&#xA;    if(!set) {&#xA;      //PORTB |= _BV(PB0);&#xA;      digitalWrite(8, HIGH);&#xA;      set = true;&#xA;    }&#xA;  } else {&#xA;    //PORTB &amp;amp;=~_BV(PB0);&#xA;      digitalWrite(8, LOW);&#xA;    set = false;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But instead of emitting a bright light, which can be seen if connecting the blinking signal directly to the LED, it emits a faint light. The voltmeter also shows an significant Voltage drop. Whilst the digital pin should have a voltage of ~5V when set to HIGH (never reached because of inner resitance inside the arduino), it measures about 1.6-1.8V.&#xA;I also switched the both Arduinos which showed the same result, so it shouldn't be a hardware defect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advance!&lt;/p&gt;&#xA;" OwnerDisplayName="Matze" LastEditorUserId="6452" LastEditDate="2015-04-13T20:16:59.323" LastActivityDate="2015-04-13T20:16:59.323" Title="Arduino voltage drop while communicating with another Arduino" Tags="|arduino-uno|arduino-nano|voltage-level|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="9987" PostTypeId="2" ParentId="9986" CreationDate="2015-04-10T14:47:47.040" Score="0" Body="&lt;p&gt;A couple of delays in the Arduido #2 if(!set) { } else { } might allow the LED to stay on long enough to be seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment this is rapidly switching the LED whenever the digital pin7 is set.&lt;/p&gt;&#xA;" OwnerUserId="8396" OwnerDisplayName="Neomada" LastActivityDate="2015-04-10T14:47:47.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="9988" PostTypeId="2" ParentId="9986" CreationDate="2015-04-10T14:55:58.813" Score="3" Body="&lt;p&gt;the line &lt;code&gt;DDRD |=_BV(PB0);&lt;/code&gt; should be &lt;code&gt;DDRB |=_BV(PB0);&lt;/code&gt; currently PB0 is set as an input so when you set it high it is just turning on the pull-up resistor, which is basically adding another ~10k in series with the LED, hence the dim light.&lt;/p&gt;&#xA;" OwnerUserId="51285" OwnerDisplayName="Gorloth" LastActivityDate="2015-04-10T14:55:58.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="9989" PostTypeId="1" CreationDate="2015-04-10T19:17:07.533" Score="1" ViewCount="115" Body="&lt;p&gt;I have a robot application on my Arduino which basically takes values from a SoftSerial instance on my 0/1 pins (connected to a Bluetooth board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the 'driver station' I send speed values to the Arduino through the aforementioned Bluetooth controller. The freezing happens when I compare the data (an integer) to a local integer (i.e 500). If I send the reverse command, I'm actually sending the int 500. If I compare my SoftSerial data like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(softSerial.parseInt() == 500)&#xA;{&#xA; //Reverse&#xA;}else{&#xA; //Forward&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it freezes. It only happens when I'm using my SoftSerial stack over Bluetooth, over USB it doesn't freeze. What are my options?&lt;/p&gt;&#xA;" OwnerUserId="8395" LastActivityDate="2015-12-27T11:47:25.533" Title="SoftSerial freezes on comparing getInt to int" Tags="|serial|bluetooth|softwareserial|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9990" PostTypeId="1" CreationDate="2015-04-10T19:26:01.780" Score="0" ViewCount="42" Body="&lt;p&gt;I've seen an Arduino-compatible board called Bluno from DFRobot. I'm curious if a shield, specifically the DFRobot motor shield can be connected to the Bluno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone confirm if it can be connected with a shield?&lt;/p&gt;&#xA;" OwnerUserId="8364" LastActivityDate="2015-04-10T19:55:39.417" Title="Questions Concerning Arduino Compatible Boards" Tags="|arduino-uno|bluetooth|arduino-motor-shield|robotics|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9991" PostTypeId="2" ParentId="9990" CreationDate="2015-04-10T19:55:39.417" Score="1" Body="&lt;p&gt;The Bluno is identical to the Uno, except the USB-to-serial chip, also supports BT. So it won't be a problem.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-10T19:55:39.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9994" PostTypeId="1" AcceptedAnswerId="10097" CreationDate="2015-04-10T23:33:16.227" Score="0" ViewCount="4143" Body="&lt;p&gt;I am using Arduino Uno R3 board and a wiznet W5100 ethernet Shield. The temperature from the One wire sensors before using Ethernet Shield was showing correct. However later after connecting the shield, the temperature is showing to be 85. The server and everything else works fine, but the data is all wrong. Now I am pretty sure the connections are correct and it is not in parasite mode. Any suggestions of how I might get the accurate reading ? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Web Server&#xA;&#xA;  A simple web server that shows the value of the analog input pins.&#xA;  using an Arduino Wiznet Ethernet shield.&#xA;&#xA;*/&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;#define ONE_WIRE_BUS 2&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;// The IP address will be dependent on your local network:&#xA;byte mac[] = {&#xA;            0xF0, 0xBF, 0x97, 0x67, 0xF6, 0x98&#xA;        };&#xA;IPAddress ip(192, 168, XXX, XXX);&#xA;&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;EthernetServer server(80);&#xA;&#xA;void setup() {&#xA;    // Open serial communications and wait for port to open:&#xA;    Serial.begin(9600);&#xA;    sensors.begin();&#xA;    while (!Serial) {&#xA;        ; // wait for serial port to connect. Needed for Leonardo only&#xA;    }&#xA;    // start the Ethernet connection and the server:&#xA;    Ethernet.begin(mac, ip);&#xA;    server.begin();&#xA;    Serial.println(sensors.getTempCByIndex(0));&#xA;    Serial.print(&quot;Siddhartha Temperature &quot;);&#xA;    Serial.print(&quot;server is at &quot;);&#xA;    Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;    // listen for incoming clients&#xA;    EthernetClient client = server.available();&#xA;    if (client) {&#xA;        Serial.println(&quot;new client&quot;);&#xA;        // an http request ends with a blank line&#xA;        boolean currentLineIsBlank = true;&#xA;        while (client.connected()) {&#xA;            if (client.available()) {&#xA;                char c = client.read();&#xA;                Serial.write(c);&#xA;                // if you've gotten to the end of the line (received a newline&#xA;                // character) and the line is blank, the http request has ended,&#xA;                // so you can send a reply&#xA;                if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;                    // send a standard http response header&#xA;                    client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;                    client.println(&quot;Content-Type: text/html&quot;);&#xA;                    client.println(&quot;Connection: close&quot;);  &#xA;                    client.println(&quot;Refresh: 2&quot;);&#xA;                    client.println();&#xA;                    client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&#xA;                    client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;                    // output the value of each analog input pin&#xA;                    for (int analogChannel = 0; analogChannel &amp;lt; 6; analogChannel++) {&#xA;                        float sensorReading = sensors.getTempCByIndex(0);&#xA;                        client.print(&quot;Temperature &quot;);&#xA;                        client.print(analogChannel);&#xA;                        client.print(&quot; is &quot;);&#xA;                        client.print(sensorReading);&#xA;                        Serial.println(sensorReading);&#xA;                        client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;                    }&#xA;                    client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;                    break;&#xA;                }&#xA;                if (c == '\n') {&#xA;                    // you're starting a new line&#xA;                    currentLineIsBlank = true;&#xA;                }&#xA;                else if (c != '\r') {&#xA;                    // you've gotten a character on the current line&#xA;                    currentLineIsBlank = false;&#xA;                }&#xA;            }&#xA;        }&#xA;        // give the web browser time to receive the data&#xA;        delay(1);&#xA;        // close the connection:&#xA;        client.stop();&#xA;        Serial.println(&quot;client disconnected&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7170" LastEditorUserId="84" LastEditDate="2015-04-11T06:30:08.517" LastActivityDate="2015-04-15T17:21:47.177" Title="Dallas Temperature Sensor DS18B20 not showing correct Result with Ethernet Shield" Tags="|arduino-uno|ethernet|temperature-sensor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="9995" PostTypeId="1" CreationDate="2015-04-10T23:53:21.937" Score="1" ViewCount="822" Body="&lt;p&gt;I've trying to write my code in plain C++ dropping out the Arduino's IDE. Although I've succeed in compiling the code, whenever I try to upload it to the board it doesn't run, seems that it stucks at some unknown point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, everytime I try to upload a new code to the board it stops responding and avrdude throws this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ino upload -m leonardo -p /dev/ttyACM1&#xA;/dev/ttyACM1 doesn't exist. Is Arduino connected?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter if I unplug and then plug again the board, that message is still showing up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to restart the board, I open the Arduino IDE and then I upload any sketch, then the board comes to live again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first time I tried overriding the main() function and the program didn't run I thought it was the tool I was using at that moment, &lt;em&gt;arduino.mk&lt;/em&gt;, the one that was doing something strange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried the &lt;em&gt;ino&lt;/em&gt; tool, but the result was the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think &lt;em&gt;avrdude&lt;/em&gt; is failing because it actually uploads the .hex to the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My original main() code was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;const int LED_PIN = 13;&#xA;&#xA;int main(void)&#xA;{&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;&#xA;    while (1)&#xA;    {&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(900);&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried to mimic the one that comes with Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;const int LED_PIN = 13;&#xA;&#xA;int main(void)&#xA;{&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;&#xA;#if defined (USBCON)&#xA;    USBDevice.attach();&#xA;#endif  &#xA;&#xA;    while (1)&#xA;    {&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(900);&#xA;&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sadly, with both codes the board gets stucked at some point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I figure out how to solve this issue I've been exercising this solution inside a sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LED_PIN = 13;&#xA;&#xA;void setup() {                &#xA;}&#xA;&#xA;void loop() {&#xA;    pinMode(LED_PIN, OUTPUT);     &#xA;&#xA;    while (1)&#xA;    {&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(900);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas that led me to a solution? Thank you!&lt;/p&gt;&#xA;" OwnerUserId="8401" LastActivityDate="2015-04-11T00:31:14.550" Title="Overriding main function in Leonardo" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9996" PostTypeId="1" CreationDate="2015-04-11T00:29:07.367" Score="2" ViewCount="39" Body="&lt;p&gt;I am following &lt;a href=&quot;http://www.fabric8r.com/forums/showthread.php?1308-Customizing-Marlin-Firmware-for-the-One-Up-and-Two-Up&quot; rel=&quot;nofollow noreferrer&quot;&gt;these instructions&lt;/a&gt; to set up my Two-Up 3D printer, and I have no problems all the way up until step 18.  The board uses the arduino IDE to burn the bootloader, which is why I am posting this here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have my board set to &quot;[BootloaderCDC]Teensylu/Printrboard&quot; in the tools menu, and I have selected the appropriate COM port.  I use arduino for tons of other things so I know my way around the IDE reasonably well, but I have never encountered this error before so I'm not quite sure what to make of it or how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bephe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here is the error.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the red board (version 2) and I am using Arduino version 1.0.6.  As far as I can tell, I have perfectly followed all of the steps up until this part with no noticible problems.  I remembered to bridge the boot pins and everything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the video the guy says there may be an error when you go to program the board but my error is way different than his error in the video, and hbe says you should hear the dissconnect and reconnect sounds as the board gets reset after a bootload (I didn't hear them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have any idea how to fix this issue?&lt;/p&gt;&#xA;" OwnerUserId="3386" LastActivityDate="2015-04-11T00:29:07.367" Title="Having trouble bootloading my Two-Up printer" Tags="|arduino-ide|bootloader|teensy|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9997" PostTypeId="2" ParentId="9995" CreationDate="2015-04-11T00:31:14.550" Score="2" Body="&lt;p&gt;&lt;strong&gt;Solved!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was a (big) silly mistake of my own. I overloocked the init() function right after entering the main() function. I'm shure it initializes the hardware and the entire system, so my board stucks when I skipped it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my code now looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;const int LED_PIN = 13;&#xA;&#xA;int main(void)&#xA;{&#xA;    init();&#xA;&#xA;&#xA;#if defined (USBCON)&#xA;    USBDevice.attach();&#xA;#endif  &#xA;&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;&#xA;    while (1)&#xA;    {&#xA;&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(900);&#xA;&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, the mix: Arduino + Vim + ino, rocks! Now I can do whatever I want from the console :)&lt;/p&gt;&#xA;" OwnerUserId="8401" LastActivityDate="2015-04-11T00:31:14.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="9998" PostTypeId="1" AcceptedAnswerId="20393" CreationDate="2015-04-11T03:36:18.890" Score="1" ViewCount="9281" Body="&lt;p&gt;NOTE: Using the Arduino Uno&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am WORKING on a project that I have to submit in a few days. My arduino was all set up and was working fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Project:Arduino controls a 9v motor depending on the command given. As the arduino only provides 5v , i added a 9v battery to it through a transistor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to add new code into the arduino but when I tried it failed. I have uploaded code thousands of times before (successfully) all of a sudden the IDE keeps giving the following message&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;\.\COM3&quot;: Access is denied.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have looked up for a lot of solutions on this forum and elsewhere. Here are the things I have tried so far:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Changing the COM port &lt;/li&gt;&#xA;&lt;li&gt;Disabling all the other devices CONNECTED to COM&lt;/li&gt;&#xA;&lt;li&gt;Tightening the CONNECTIONS&lt;/li&gt;&#xA;&lt;li&gt;Re installing all the drivers and the IDE&lt;/li&gt;&#xA;&lt;li&gt;Rebooting the system&lt;/li&gt;&#xA;&lt;li&gt;Using another laptop to upload code&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All the above have given me the same output for some reason. The built in LED light and the power LED switch on when the board is CONNECTED to a power source (my laptop). Could the board have been damaged by any chance ? How can I check if the board is spoilt ? Should I buy a new board ? &lt;/p&gt;&#xA;" OwnerUserId="8405" LastEditorUserId="10794" LastEditDate="2016-02-07T08:45:52.753" LastActivityDate="2016-02-07T08:46:53.923" Title="Not able to upload any code to Arduino Uno" Tags="|arduino-uno|uploading|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="9999" PostTypeId="1" CreationDate="2015-04-11T03:48:55.717" Score="0" ViewCount="197" Body="&lt;p&gt;Im using a OSEPP Uno R3 Plus to connect with a Ultimate GPS Logger Shield. I am currently working through the Adafruit Ultimate GPS Logger Shield pdf. When connecting in Soft Serial Mode and loading a parsing sketch. In the com window my values are showing but unreadable. I have included an image. Any help is appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wsaln.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8403" LastEditorUserId="8403" LastEditDate="2015-04-11T13:37:26.413" LastActivityDate="2016-05-06T00:50:55.780" Title="Ultimate GPS Logger Shield : Soft Serial Sketch Error" Tags="|tinygps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10001" PostTypeId="2" ParentId="9998" CreationDate="2015-04-11T09:26:41.317" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Remove all device connect to uno, and upload code to uno. Because,&#xA;your device like motor will confuse uno.&lt;/li&gt;&#xA;&lt;li&gt;Check you usb to serial device.&lt;/li&gt;&#xA;&lt;li&gt;Check your uno&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8407" LastActivityDate="2015-04-11T09:26:41.317" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10002" PostTypeId="2" ParentId="9362" CreationDate="2015-04-11T09:35:26.703" Score="2" Body="&lt;p&gt;Based on the image .. i see that the programmer pins at the back of the shield and the arduino aren't connected properly.. That might be the error or at least happened with me. &#xA;Apart from that, certain network need to identify the mac address from a look up table and if the shield mac address matches, then only network transactions are allowed.&#xA;Also i suggest you to drop the virtual machine mac address and networking protocols and try upon the base OS which you have on your computer.     &lt;/p&gt;&#xA;" OwnerUserId="7170" LastActivityDate="2015-04-11T09:35:26.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10003" PostTypeId="2" ParentId="249" CreationDate="2015-04-11T12:48:32.507" Score="1" Body="&lt;p&gt;I used TSOP1738 which is easily available at cheap price and I recorded values from more than 10 remotes and it worked very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/gpFxDbkP&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a file which contain recorded values of a Videocon DTH setup box's remote&lt;/p&gt;&#xA;" OwnerUserId="8409" LastActivityDate="2015-04-11T12:48:32.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10004" PostTypeId="2" ParentId="9999" CreationDate="2015-04-11T13:40:46.037" Score="1" Body="&lt;p&gt;jfpoilpret &gt; My apologies for not including enough information and details. But your comments did lead to me resolving my issue. I did not change my baud rate to match the baud rate of the source code and the script is working now. Appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8403" LastActivityDate="2015-04-11T13:40:46.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10005" PostTypeId="1" AcceptedAnswerId="10006" CreationDate="2015-04-11T17:53:02.253" Score="4" ViewCount="307" Body="&lt;p&gt;&lt;em&gt;How do the analog pins on an Arduino measure voltage?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do they either measure current and calculate the voltage with Ohm's law? (If so, why can we only read voltage and not current directly?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do they compare the unknown input voltage with a known internal one? (If so, how does that work? What's the known voltage?)&lt;/p&gt;&#xA;" OwnerUserId="4270" LastActivityDate="2015-04-21T19:44:35.313" Title="How exactly is voltage measured on an Arduino?" Tags="|analogread|electronics|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10006" PostTypeId="2" ParentId="10005" CreationDate="2015-04-11T18:00:13.293" Score="1" Body="&lt;p&gt;Known voltage is usually provided by a diode or similar reference. The atmega328p chip has a separate aref pin so you can choose your own reference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ADC or analog to digital converter &lt;a href=&quot;http://en.m.wikipedia.org/wiki/Analog-to-digital_converter&quot; rel=&quot;nofollow&quot;&gt;http://en.m.wikipedia.org/wiki/Analog-to-digital_converter&lt;/a&gt; is a collection of comparators. A comparator is a logic gate that simply tells which of two inputs has more voltage. This aref voltage is divided evenly into 2^10 values (it's a 10 bit ADC). Then the incoming signal is compared against all of these and the largest comparator which triggers is the reading you get in your arduino code. &lt;/p&gt;&#xA;" OwnerUserId="8175" LastEditorUserId="313" LastEditDate="2015-04-12T14:48:19.527" LastActivityDate="2015-04-12T14:48:19.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10007" PostTypeId="2" ParentId="10005" CreationDate="2015-04-11T18:00:41.810" Score="0" Body="&lt;p&gt;The Arduino uses a analog-to-digital converter. For instance on the Arduino Uno there is a 10-bit ADC. Therefore the resolution is 2^10 bits which is 1024 different representations. As the Uno runs at 5V, each step represents 4.9mV. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual inner workings of the ADC can be quite complex and I don't exactly know which specific type it uses, but there can be many ways. One example is measuring time to discharge of a known capacitor. Another is comparing the voltage to the running voltage and using a counter. &lt;/p&gt;&#xA;" OwnerUserId="6331" LastActivityDate="2015-04-11T18:00:41.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10008" PostTypeId="1" CreationDate="2015-04-11T18:39:08.700" Score="-2" ViewCount="1152" Body="&lt;p&gt;I just got all my parts together that I needed for my project and put everything together like said here: &lt;a href=&quot;https://web.archive.org/web/20140303140445/http://cerulean.dk/words/?page_id=42&quot; rel=&quot;nofollow&quot;&gt;https://web.archive.org/web/20140303140445/http://cerulean.dk/words/?page_id=42&lt;/a&gt; but the serial monitor gives me all random outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogValue: 865.52&#xA;             load: 43.27584&#xA;analogValue: 865.54&#xA;             load: 43.27717&#xA;analogValue: 865.50&#xA;             load: 43.27517&#xA;analogValue: 865.43&#xA;             load: 43.27151&#xA;analogValue: 865.32&#xA;             load: 43.26601&#xA;analogValue: 865.45&#xA;             load: 43.27255&#xA;analogValue: 865.45&#xA;             load: 43.27241&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I can't calibrate everything to even continue, what is wrong? I checked all my connections like 50 times and everything is wired up like shown in the tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;INA125P:&#xA;&lt;a href=&quot;http://www.reichelt.de/INA-125-PA/3/index.html?&amp;amp;ACTION=3&amp;amp;LA=446&amp;amp;ARTICLE=147252&amp;amp;artnr=INA+125+PA&amp;amp;SEARCH=ina125p&quot; rel=&quot;nofollow&quot;&gt;http://www.reichelt.de/INA-125-PA/3/index.html?&amp;amp;ACTION=3&amp;amp;LA=446&amp;amp;ARTICLE=147252&amp;amp;artnr=INA+125+PA&amp;amp;SEARCH=ina125p&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Load cell from a simple 5kg kitchen scale (tested it before removing&#xA;and it worked)&lt;/li&gt;&#xA;&lt;li&gt;10 Ohm resistor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thank you in advanced, Greetings&lt;/p&gt;&#xA;" OwnerUserId="8413" LastActivityDate="2021-12-06T15:11:05.637" Title="Weight sensor / load cell not working" Tags="|sensors|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10009" PostTypeId="2" ParentId="8894" CreationDate="2015-04-11T19:02:28.267" Score="1" Body="&lt;p&gt;I've just got mine working, in about 3 hours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first example I've never got working. The SAT+RESET worked first time... and I was then able to pair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easier module is the HC-05. That by default goes straight to discovery mode, and makes things alot easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have more success with the serial monitor in Arduino studio, rather than X-CTU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point of the sheild is to prototype, or the shield you have to use in your production project. If you are doing the former, then there is little point in using the shield as you would have to change the code to fit the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems a thorough product, probably too involved.&lt;/p&gt;&#xA;" OwnerUserId="8414" LastActivityDate="2015-04-11T19:02:28.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10011" PostTypeId="1" AcceptedAnswerId="56154" CreationDate="2015-04-11T19:50:03.470" Score="3" ViewCount="4344" Body="&lt;p&gt;I'm trying to use the &lt;a href=&quot;https://github.com/jscrane/TTS&quot; rel=&quot;nofollow&quot;&gt;TTS library for Arduino&lt;/a&gt; on an Arduino Micro board, which is based on the Leonardo. When I try to compile my sketch I get some errors;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/libraries/TTS/TTS.cpp: In function 'void soundOff()':&#xA;/libraries/TTS/TTS.cpp:355: error: 'TCCR2A' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:355: error: 'COM2B1' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp: In function 'void soundOn()':&#xA;/libraries/TTS/TTS.cpp:382: error: 'TCCR2A' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:382: error: 'COM2B1' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:382: error: 'WGM20' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:383: error: 'TCCR2B' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:383: error: 'CS20' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:383: error: 'WGM22' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:384: error: 'OCR2B' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:385: error: 'TCNT2' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp: In function 'void sound(byte)':&#xA;/libraries/TTS/TTS.cpp:424: error: 'OCR2B' was not declared in this scope&#xA;/libraries/TTS/TTS.cpp:425: error: 'TCNT2' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Googling revealed that the Leonardo uses different timers. And other things I don't understand! But I couldn't piece together an answer beyond that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the correct constants to use for Leonardo boards, and is there a way I can update the library to work across both?&lt;/p&gt;&#xA;" OwnerUserId="8415" LastActivityDate="2018-09-16T23:39:10.553" Title="TCCR1A and TCCR2A on Leonardo" Tags="|arduino-leonardo|library|timers|arduino-micro|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10012" PostTypeId="1" AcceptedAnswerId="10018" CreationDate="2015-04-11T20:10:21.130" Score="1" ViewCount="687" Body="&lt;p&gt;We are using Arduino Uno revision 3, with TinkerKit DMX Shield rev. 4 and Sparkfun Mp3 Shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We uploaded the Mp3 Shield example called FilePlayer and after we open the serial monitor, the interface is there and working. The problem is that it won't output the music from the SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we ONLY stack the Mp3 Shield onto Arduino, it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some king od incompatibility between the DMX and Mp3 Shield, and if there is, what would be the solution, maybe some kind of bypass, since we aren't that familiar with what pins the DMX shield uses for it's purpose. ATM the Tinkerit site is down so we can't acess the TinkerKit DMX Shield datasheet.&lt;/p&gt;&#xA;" OwnerUserId="8416" LastEditorUserId="8416" LastEditDate="2015-04-11T21:31:53.877" LastActivityDate="2015-04-11T22:45:02.907" Title="MP3 Shield stacked on DMX Shield - Arduino Uno" Tags="|arduino-uno|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10013" PostTypeId="1" CreationDate="2015-04-10T23:45:47.073" Score="1" ViewCount="608" Body="&lt;p&gt;I'm working with Arduino's libraries. And my interest in the possibility to change the call stack of the SPI interrupt, this because I want: after the interrupt happen, the program could jump to other function and not to the interrupted address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean:&#xA;This is the Main code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop ()&#xA;{&#xA;    func();&#xA;}&#xA;&#xA;void func()&#xA;{&#xA;   // code&#xA;   // here happens the ISR interrupt&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ISR happens inside &lt;code&gt;func()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(SPI_STC_vect)&#xA;{&#xA;    // code&#xA;    // SPDR = 0x00; // MY ANSWER to SPI&#xA;    // MODIFY CALL STACK TO GO TO LOOP()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now, after answering the SPI, I want to go back to &lt;code&gt;loop()&lt;/code&gt; instead of continue &lt;code&gt;func()&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I do this?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="10037" OwnerDisplayName="jaspher" LastActivityDate="2015-09-02T00:55:30.700" Title="Modify the call stack of interrupts on Arduino" Tags="|avr|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10014" PostTypeId="2" ParentId="10013" CreationDate="2015-04-11T00:19:01.240" Score="1" Body="&lt;p&gt;Arduino is open source, so just modify the ISR to set a global flag when ran. Within func() just check for this flag and return when the condition is met. Little can be offered as little contextual information is given. To modify the stack you would have to work with avr assembly, but either way you must modify the ISR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the following would work, but performance depends heavily on your application. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SPI_ISR_RAN 0x00&#xA;static volatile uint8_t flagByte;&#xA;&#xA;void loop(){&#xA;    func();&#xA;}&#xA;&#xA;void func(){&#xA;    uint8_t indicator;&#xA;    do {&#xA;        // Do something&#xA;&#xA;        //Check for SPI condition&#xA;        ATOMIC_BLOCK(ATOMIC_RESTORESTATE){ //Atomic access is required&#xA;            indicator = flagByte;&#xA;        }&#xA;    }while( !(indicator &amp;amp; 1&amp;lt;&amp;lt;SPI_ISR_RAN) );&#xA;&#xA;    ATOMIC_BLOCK(ATOMIC_RESTORESTATE){&#xA;        flagByte &amp;amp;= ~(1&amp;lt;&amp;lt;SPI_ISR_RAN); //Don't forget to clear the flag!&#xA;    }&#xA;}&#xA;&#xA;ISR(SPI_STC_vect){&#xA;    // Do ISR necessities&#xA;&#xA;    // Set flag when appropriate            &#xA;    flagByte &amp;amp; 1&amp;lt;&amp;lt;SPI_ISR_RAN;            &#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="sherrellbc" LastActivityDate="2015-04-11T00:19:01.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10016" PostTypeId="1" CreationDate="2015-04-11T21:35:59.620" Score="5" ViewCount="1715" Body="&lt;p&gt;When I write '13' to the EEPROM and read it straight after it works correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I comment out the write part of the code and try to just read the data, the value is no longer 13 as it used to be but reverts back to 255. Whats going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running a standalone atmega328 on a breadboard with a 16mhz crystal, programmed by a Nano R3.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;Serial.begin(9600);&#xA;pinMode(2, OUTPUT);&#xA;&#xA;//EEPROM.write(1,13);&#xA;}&#xA;&#xA;void loop() {&#xA;scoreBinary();&#xA;&#xA;&#xA;}&#xA;&#xA;void scoreBinary(){&#xA;&#xA;int score= EEPROM.read(1);&#xA;&#xA;if(score==13){&#xA;digitalWrite(2,HIGH);&#xA;}&#xA;delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8417" LastActivityDate="2015-04-11T21:46:20.560" Title="EEPROM value reverting to 255" Tags="|atmega328|eeprom|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10017" PostTypeId="2" ParentId="10016" CreationDate="2015-04-11T21:46:20.560" Score="4" Body="&lt;p&gt;By default the EEPROM in the MCU is erased (to 0xff) when the chip is erased before flash is written to. If you want to prevent this then you will need to program EESAVE in the fuse bits, which is bit 3 in the high fuse byte of the '328.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-11T21:46:20.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10018" PostTypeId="2" ParentId="10012" CreationDate="2015-04-11T22:45:02.907" Score="1" Body="&lt;p&gt;Yes, overlapping is a problem, by default the MP3 Shield uses digital pins 2(DREQ),6(mp3CS),7(mp3DCS),8(RST),9(SD-CS),11(MOSI),12(MISO),13(SCK)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Tinkerkit DMX Master Shield R4 uses 2(RE-ENn),3(VTX),4(VRX),5(DE-EN),6(D6)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are conflicts with D2 DREQ vs RE-ENn and D6 mp3CS vs D6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DMX Master Shield basically converts the UNO's serial to DMX. If nothing is at first included into the Sketch for this, then the problem is with only D6. Leave this jumper OFF. And I suspect the MP3 Shield will work stacked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use them together you can move the pins, as demonstrated at &lt;a href=&quot;https://www.youtube.com/watch?v=behMgV3tUr4&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=behMgV3tUr4&lt;/a&gt;. Noting that is for different pins. And of course you will need to subsequently change their definition, in the sketch.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-04-11T22:45:02.907" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10019" PostTypeId="1" CreationDate="2015-04-12T00:39:43.407" Score="0" ViewCount="1369" Body="&lt;p&gt;I have a arduino due which i know has usb host mode. The usb library that comes with the due supports mouse and keyboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have another usb device (diacnostic tool) id like to talk to, it use a:&#xA;USB Com Board Driver ( Multi-instance )&#xA;TI USBN9604&#xA;&quot;Universal Serial Bus Full Speed Node Controller with&#xA;Enhanced DMA Support&quot;&#xA;datasheet: www.ti.com/lit/ds/symlink/usbn9603.pdf&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ive also logged the raw byte usb traffic between windows and it when operating and would like to try sending some of those same calls to the device with the due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where do i start ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example Capture:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    000000: PnP Event: Device Connected (UP), 12.04.2015 09:14:51.390 (1. Device: USB Com Board Driver ( Multi-instance ))&#xA;The USB device has just been connected to the system.&#xA;000001: Bulk or Interrupt Transfer (DOWN), 12.04.2015 09:15:14.953 +23.562 (1. Device: USB Com Board Driver ( Multi-instance ))&#xA;Pipe Handle: 0x8639885c (Endpoint Address: 0x6)&#xA;Send 0x1b bytes to the device&#xA; 40 05 17 C0 00 09 02 00 AA 00 00 00 00 00 00 00&#xA; 00 00 00 00 00 00 00 00 16 06 12&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="4024" LastEditDate="2015-04-12T00:48:47.830" LastActivityDate="2021-06-24T01:04:35.413" Title="Communicate with custom usb slave device with DUE?" Tags="|arduino-due|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10020" PostTypeId="1" AcceptedAnswerId="10037" CreationDate="2015-04-12T08:55:30.723" Score="1" ViewCount="22399" Body="&lt;p&gt;I am reading a string which i have to convert into a float with a maximum of precision.I didn't want to use toFloat() function since it make a truncation so i made my own code.&#xA;My problem is that the final result is also approximated.&#xA;I need a precision of 4 digits after the float.I read the documentation about float in the arduino website.They say it should be maximum 7 digits of precision but i don't get it.When i test my code on the value of '23,459' ,all i get is 23,46.&#xA;Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { &#xA;&#xA; Serial.begin(9600); &#xA;&#xA;&#xA;} &#xA;int longu=0;&#xA;char data='2';&#xA;  String data2=&quot;23,459&quot;;&#xA;  float val=0;&#xA;  int posVir=0;&#xA;  int t=0;&#xA;  float postVir=0;&#xA;  float preVir=0;&#xA;  int lonPostVir=0;&#xA;  int lonPreVir=0;&#xA;  float posvir2=0;&#xA;  void loop() &#xA;{&#xA;&#xA;&#xA;   lonPostVir=(data2.substring(posVir+1)).length();&#xA;   lonPreVir=(data2.substring(0,posVir)).length();&#xA;&#xA;   longu=data2.length();&#xA;   posVir=data2.indexOf(&quot;,&quot;);&#xA;   preVir=(data2.substring(0,posVir)).toFloat();&#xA;   postVir=(data2.substring(posVir+1)).toFloat();&#xA;   posvir2=postVir*pow(10,-lonPostVir);&#xA;   val=preVir+postVir*pow(10,-lonPostVir);&#xA;&#xA;  Serial.println(val);&#xA;&#xA;    } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7328" LastActivityDate="2016-05-04T08:40:18.597" Title="float precision in arduino" Tags="|string|float|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10021" PostTypeId="2" ParentId="10005" CreationDate="2015-04-12T09:27:00.727" Score="1" Body="&lt;p&gt;The Arduino uses a &lt;b&gt;10 bit &lt;I&gt;Analog to Digital Converter(ADC)&lt;/I&gt;&lt;/b&gt;. A good ADC  is made such that it has only as many comparators as is the resolution of the ADC (in BITS) . Therefore the Arduino should have only ten comparators.&lt;br&gt;&#xA;More detailed:&lt;br&gt;&#xA;Comparator Number      Trigger voltage&lt;br&gt;&#xA;        1.(LSB)..............................       (5/1024)V&lt;br&gt;&#xA;        2........................................             (5/512)V&lt;br&gt; &#xA;        3........................................(5/256)V&lt;br&gt;&#xA;       ..........and so on till&lt;br&gt;&#xA;        4.(MSB)..............................(5/2)V&lt;br&gt;&lt;br&gt;&#xA;So, for a voltage of say 2.75V, you will get a value of 768(11000000 in Binary)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:If you choose to give and use a separate Ref Voltage to the Arduino, It replaces the 5V with the new ref voltage.&lt;br&gt;&#xA;Update 2: Sometimes a single comparator may be used in exchange of all 10 comparators.i.e., it is used to trigger all the bits .But the voltage at which each bit is triggered remains same.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastEditorUserId="8420" LastEditDate="2015-04-14T08:46:53.033" LastActivityDate="2015-04-14T08:46:53.033" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10022" PostTypeId="2" ParentId="9998" CreationDate="2015-04-12T09:40:24.790" Score="1" Body="&lt;p&gt;Have you tried changing the Microprocessor in the Arduino Uno?&#xA;An AtMega320P is much cheaper than new Arduino, and usually only the microprocessor gets spoilt, rest of the board remains intact.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T09:40:24.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10023" PostTypeId="2" ParentId="9976" CreationDate="2015-04-12T10:03:33.323" Score="1" Body="&lt;p&gt;Peter and Gerben have already said what is needed , but I wish to explain things even further.&lt;br&gt;&lt;br&gt;&#xA;A normal small 7-Segment display consumes only &lt;b&gt;70-80mA&lt;/b&gt; when all segments are HIGH.So you can use the Arduino directly without damaging it. Also note, depending on the quality of the project, you could either use a common resistor for all segments, or use separate ones. Separate ones will give much brighter light and better quality.&lt;br&gt;&#xA;A medium size one will require max consumption of around &lt;b&gt;400mA&lt;/b&gt; current, so use cheap transistors.&lt;br&gt;&#xA;A large size one will require max consumption of upto &lt;b&gt;1.5-2A&lt;/b&gt; current , so use MOSFETS or other high current Transistors.&lt;br&gt;&#xA;An Extra Large one will require max consumption of upto &lt;b&gt;10-25A&lt;/b&gt; current, so use good MOSFETS or maybe even Relays.&lt;br&gt;&lt;br&gt;&#xA;&lt;I&gt;&lt;b&gt;Usage&lt;/b&gt;&lt;br&gt;&#xA;Small- Wrist watches&lt;br&gt;&#xA;Medium- Small clocks&lt;br&gt;&#xA;Large- Big clocks&lt;br&gt;&#xA;Extra Large- Very big clocks like ones in Railway stations&lt;br&gt;&#xA;&lt;/I&gt;&lt;/p&gt;&#xA;" OwnerUserId="8420" LastEditorUserId="8420" LastEditDate="2015-04-12T10:09:56.880" LastActivityDate="2015-04-12T10:09:56.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10024" PostTypeId="1" AcceptedAnswerId="10026" CreationDate="2015-04-12T10:44:21.337" Score="2" ViewCount="707" Body="&lt;p&gt;I am trying to make simple TV remote using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got &lt;a href=&quot;http://www.zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; link from Google for making a remote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code uploaded perfectly on my device. But all it does is blink a the LED on pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope I have got right code. I have tested it on my TV at home. Is that the correct way of testing it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IR receiver I have is TSOP-15&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I am completely new to Arduino &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below shown is my Arduino board(induino r3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bwboE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8355" LastEditorUserId="26916" LastEditDate="2017-11-04T06:51:48.567" LastActivityDate="2017-11-04T06:51:48.567" Title="How to make universal remote controller?" Tags="|ir|remote-control|testing|induino|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10025" PostTypeId="2" ParentId="10019" CreationDate="2015-04-12T11:51:17.107" Score="1" Body="&lt;p&gt;i found what i needed here: &lt;a href=&quot;http://arduino.cc/en/Reference/USBHost&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Reference/USBHost&lt;/a&gt;&#xA;and&#xA;&lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0&quot; rel=&quot;nofollow&quot;&gt;https://github.com/felis/USB_Host_Shield_2.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-04-12T11:51:17.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10026" PostTypeId="2" ParentId="10024" CreationDate="2015-04-12T12:24:46.787" Score="1" Body="&lt;p&gt;As you've stated in your question, the TSOP-15 is a receiver. That means it detects infrared signals rather than sending them out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make a remote control with that code, you need a simple infrared light emitting diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also important to note that you need to know what signals to send. Different TVs will have different IR codes, depending on the manufacturer. That information can be detected using your receiver module along with your TV's proper remote control.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-12T12:24:46.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10027" PostTypeId="2" ParentId="9966" CreationDate="2015-04-12T15:05:55.390" Score="0" Body="&lt;p&gt;Actually, you should use a Raspberyy Pi if your project involves complex processing in it.&lt;br&gt;&#xA;But if the project is very simple, just use one of those Spark Core or Photon.&lt;br&gt;&#xA;Using an Arduino and a Sheild to do it is certainly &lt;b&gt;not&lt;/b&gt; a good idea, as the Pi is much faster in processing and costs about the same.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T15:05:55.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10028" PostTypeId="2" ParentId="9965" CreationDate="2015-04-12T15:17:00.150" Score="0" Body="&lt;p&gt;Try using &lt;I&gt;&lt;b&gt;heat detectors&lt;/b&gt;(technically speaking, &lt;b&gt;Infrared sensors&lt;/b&gt;)&lt;/I&gt; (along with &gt;1 Ultrasonic sensors and PIR motion sensors for greater accuracy) with 1 ultrasonic sensor.&#xA;Comment if you want more help.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T15:17:00.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10029" PostTypeId="2" ParentId="9961" CreationDate="2015-04-12T15:24:39.863" Score="0" Body="&lt;p&gt;Conserve energy?&lt;br&gt;&#xA;There are many ways to conserve energy in an Arduino(e.g. Use a USB adapter that does not waste energy as heat, instead of using Battery power)&lt;br&gt;&#xA;But if you want to save energy by only switching on the Arduino when light is on, it depends on the intensity of the light.&lt;br&gt;&#xA;If it is supposed to switch on only during the day, use Solar Panels to power the Arduino.&lt;br&gt;&#xA;Else, use an LDR.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T15:24:39.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10030" PostTypeId="2" ParentId="9941" CreationDate="2015-04-12T15:35:20.860" Score="0" Body="&lt;p&gt;Servo is probably broken, or fried.&lt;br&gt;&#xA;Same thing happened to me, that too twice!&lt;br&gt;&#xA;First time, I had fried the servo(overpowered it).&lt;br&gt;&#xA;Second time, one of the gears had broken.(finally I managed to salvage one total servo by using gears from fried one in the one with broken gears)&lt;br&gt;&#xA;First, try a different way to control the servo. If the servo fails to respond, then try opening up the servo.You might be able to salvage something.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T15:35:20.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10031" PostTypeId="1" CreationDate="2015-04-12T15:50:34.650" Score="1" ViewCount="104" Body="&lt;p&gt;so I am not a newbie to computers or programming. I regularly program in C# and Java, know quite a bit about computer hardware and operating systems. But I am bored of writing stupid calculators or game bots. I want something exciting and something that involves physical hardware. So I want to get into electronics and micro-controllers. I was wondering how I should go about this? Any topics I should read first? How electrics work maybe? Any guides I should skim over? I plan to buy the Arduino starter kit and a load of components, along with a soldering iron etc soon; but want to get reading now. I do not need to go right into the advanced stuff but I like to know how things work before I use them; not just &quot;plug this wire here to do this&quot;. Any help is much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8425" LastActivityDate="2015-04-12T18:38:39.960" Title="Getting started" Tags="|arduino-uno|programming|electronics|" AnswerCount="2" CommentCount="2" ClosedDate="2015-04-21T23:02:28.390" ContentLicense="CC BY-SA 3.0" />
  <row Id="10032" PostTypeId="1" AcceptedAnswerId="10086" CreationDate="2015-04-12T14:30:56.973" Score="1" ViewCount="1810" Body="&lt;p&gt;I've got an Arduino Uno and two Sparkun's Monster Motor Shields.&#xA;The aim is to control 4 motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no problem to control 2 DC motors with single motor shield. There's a &lt;a href=&quot;https://www.sparkfun.com/products/10182&quot; rel=&quot;nofollow&quot;&gt;manual&lt;/a&gt; on how to do it .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how can I control all of motors (address commands to each of them) when I stack motor shields one on one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8472" OwnerDisplayName="llaabbss" LastEditorUserId="6452" LastEditDate="2015-04-13T20:17:07.507" LastActivityDate="2018-08-27T06:10:05.893" Title="Arduino Uno + 2 Monster Motor Shields" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10033" PostTypeId="2" ParentId="9920" CreationDate="2015-04-12T17:19:08.357" Score="3" Body="&lt;p&gt;Use Delay(  ).&#xA;Or this code&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long previousMillis;&#xA;&#xA;void setup(){&#xA;  previousMillis = millis();//in void setup&#xA;  bool lS=LOW;//in void setup&#xA;}&#xA;&#xA;void loop(){&#xA;  long currentMillis= millis();//in void loop&#xA;&#xA;  if(currentMillis-previousMillis&amp;gt;=20000){&#xA;     if (lS==LOW){&#xA;       digitalWrite(pinNo,HIGH);&#xA;       lS=HIGH;&#xA;     }&#xA;     else&#xA;     {&#xA;       digitalWrite(pinNo,LOW);&#xA;       lS=LOW;&#xA;     }&#xA;     previousMillis= millis();&#xA;  }&#xA;  delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While this does not serve your purpose, it shows you an how to switch on and off and LED after every 20 sec without keeping the Arduino idle for 20 sec.You could improve on it and make your own code.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastEditorUserId="8033" LastEditDate="2015-04-16T10:10:28.897" LastActivityDate="2015-04-16T10:10:28.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10034" PostTypeId="2" ParentId="9918" CreationDate="2015-04-12T17:21:50.537" Score="2" Body="&lt;p&gt;All ground is internal connected.&lt;br&gt;&#xA;But anyway, you CANNOT use the Arduino's power to power a motor, you will need an external power source.And again, you will connect the external power source's ground to the Arduino's ground.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-12T17:21:50.537" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10035" PostTypeId="5" CreationDate="2015-04-12T17:45:12.700" Score="0" Body="" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-04-12T17:45:12.700" LastActivityDate="2015-04-12T17:45:12.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10036" PostTypeId="4" CreationDate="2015-04-12T17:45:12.700" Score="0" Body="An Arduino-compatible board by Simple Labs." OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-04-12T17:45:12.700" LastActivityDate="2015-04-12T17:45:12.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10037" PostTypeId="2" ParentId="10020" CreationDate="2015-04-12T17:48:16.170" Score="6" Body="&lt;p&gt;The simplest way to get more decimal places to print is this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(val,NUMBER_OF_DECMIAL_PLACES);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will print out any number of digits after the decimal place. Regular print without the number of digits specified will default to 2 decimal places. for example, here is some code and the result that gets printed:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;float val = 23.459;&#xA;Serial.println(val);&#xA;Serial.println(val, 4);&#xA;Serial.println(val, 10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;23.46&lt;/p&gt;&#xA;&lt;p&gt;23.4590&lt;/p&gt;&#xA;&lt;p&gt;23.4589996337&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You may notice that with 10 decimal places printed you can start to see how much the actual value of 23.459 needs to be approximated to fit within a floating point number. This is similar to how 1/3 can not be represented 100% accurately in a finite number of decimal digits; 459/1000 cannot be represented 100% accurately in a finite number of binary bits, so it is approximated.&lt;/p&gt;&#xA;&lt;p&gt;Also, note that for non-floating point numbers the optional second argument to &lt;code&gt;print&lt;/code&gt; and &lt;code&gt;println&lt;/code&gt; is the base it should be printed in (dec, hex, oct, ...) and has nothing to do with precision.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-12T20:09:39.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10038" PostTypeId="2" ParentId="10031" CreationDate="2015-04-12T17:59:58.243" Score="2" Body="&lt;p&gt;A quick search on Amazon found a number of basic books on electronics. I'm not familiar with any of them to recommend one of them. But &quot;plug this wire here to do this&quot; isn't a bad way to start - you'll probably have some questions about what this component is for or why they had you connect it the way they did. That will give an immediate direction to your studying which in turn will bring in some more questions and more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want some basics ahead of time (noting that I don't know what will be basic for you), you might search for Ohm's Law (voltage and current through a resistor), and Kirchoff's Laws (voltage and current in electric circuits), and follow any leads that look interesting. Look up some common components that you'd find in a starter kit, like resistors, capacitors, and LEDs. But things will begin to get &quot;real&quot; for you once you have parts in hand and start using them to make some basic stuff like making lights blink or fade, motors turn, and buzzers buzz.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-12T17:59:58.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10039" PostTypeId="2" ParentId="10031" CreationDate="2015-04-12T18:38:39.960" Score="3" Body="&lt;p&gt;The best way to get started is surely by reading a book, I would recommend&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/B008SMKPW0&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Getting Started with Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/com/1118549368&quot; rel=&quot;nofollow noreferrer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Exploring Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Besides, there are many tutorials on YouTube also to start with.&lt;/p&gt;&#xA;&lt;p&gt;But books are just one thing. Arduino or electronics is more about getting a hands on experience. Even if you have read a hundred times on how to blink a LED it is difficult to do it when doing it on hardware. So the best thing for you is to work with small small codes.&lt;/p&gt;&#xA;&lt;p&gt;Say initially just blinking a LED(thats like the HelloWorld of electronics) and then moving on two patterns with LED. As you get used to the IDE and the hardware move on to more challenging projects like simple DC motor control or servo control. Try and make your own projects with your imagination. The challenges which you face teaches you more than any book. Then move on to serial and wireless communication and try working with a few sensors on the ADC and start making small projects.&lt;/p&gt;&#xA;" OwnerUserId="8426" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-12T18:38:39.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10041" PostTypeId="1" AcceptedAnswerId="10047" CreationDate="2015-04-12T21:36:34.357" Score="5" ViewCount="20398" Body="&lt;p&gt;I was considering several different ways to send simple data from one Arduino to another when I though, why not connect a PWN pin of one Arduino to the analog pin on another?  I could send simple messages for one to the other by setting different values on the PWM pin.  This seems like it would work, except for the fact the the PWM pins mimic voltages with pulses.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a reliable way to link two Arduinos, If I only want to communicate 4 states?  Also, will I need to include some additional components in the connection (resister, capacitor, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All it needs to do is send a 2v pulse for yes and a 5 v pulse for no. It needs to do this about 6 times an hour. &lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-04-13T00:29:15.273" LastActivityDate="2017-06-25T11:43:22.433" Title="Can I connect a PWM pin on one Arduino to an analog input on another?" Tags="|pwm|analogread|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10042" PostTypeId="2" ParentId="10041" CreationDate="2015-04-12T22:11:03.907" Score="5" Body="&lt;p&gt;It is possible, but not the best idea. The analog inputs require a reasonably stable input - this can be achieved with a RC filter to smooth the PWM output. This would work for reasonably slow data rates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be better to use one of the many communication protocols supported by Arduino (serial, SPI, I²C).&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-04-12T22:11:03.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10044" PostTypeId="2" ParentId="9918" CreationDate="2015-04-12T23:34:14.847" Score="1" Body="&lt;p&gt;You can connect multiple components to a single ground pin.  IF you are using a breadboard, be sure to put the wire going to the go&lt;/p&gt;&#xA;" OwnerUserId="8431" LastActivityDate="2015-04-12T23:34:14.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10046" PostTypeId="1" CreationDate="2015-04-13T01:45:05.847" Score="0" ViewCount="572" Body="&lt;p&gt;I am doing a project using Arduino UNO, cc3000 WIFI chip, micro SD card shield, and a TTL serial camera in order to make a security system that will post a picture online (not enough processing power for video) when motion is detected on the camera. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thankfully, the hardware works after a few shortcomings, but my program seems to be taking up 97% of the Flash storage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I am looking for a better way to transfer the image than saving it 32 bits at a time and then waiting about 10 sec so the HTTP request will send it to the server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I do know is that I have tested all the hardware and those functions are working. My problem is in the logic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help appreciated! (Image is around 13KB and UNO only has 2kb of dynamic memory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My full code is here: &lt;a href=&quot;https://www.dropbox.com/s/arxa253mxwvqtg1/HomeProj.rtf?dl=0&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/arxa253mxwvqtg1/HomeProj.rtf?dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void)&#xA;{&#xA;    cam.setMotionDetect(true);&#xA;&#xA;    while (1) {&#xA;        if (cam.motionDetected()) {&#xA;            Serial.println(&quot;Motion!&quot;);&#xA;&#xA;            cam.setMotionDetect(false);&#xA;            if (! cam.takePicture())&#xA;                Serial.println(&quot;Failed to snap!&quot;);&#xA;            else&#xA;                Serial.println(&quot;Picture taken!&quot;);&#xA;&#xA;            uint16_t jpglen = cam.frameLength();&#xA;            Serial.print(jpglen, DEC);&#xA;            Serial.println(&quot; byte image&quot;);&#xA;&#xA;            char filename[13];&#xA;            strcpy(filename, &quot;IMAGE00.JPG&quot;);&#xA;            for (int i = 0; i &amp;lt; 100; i++) {&#xA;                filename[5] = '0' + i/10;&#xA;                filename[6] = '0' + i%10;&#xA;                // create if does not exist, do not open existing, write, sync after write&#xA;                if (! SD.exists(filename)) {&#xA;                    break;&#xA;                }&#xA;            }&#xA;&#xA;            File imgFile = SD.open(filename, FILE_WRITE);&#xA;            while(jpglen &amp;gt; 0) {&#xA;                uint8_t *buffer;&#xA;                uint8_t bytesToRead = min(32, jpglen);&#xA;                buffer = cam.readPicture(bytesToRead);&#xA;                imgFile.write(buffer, bytesToRead);&#xA;&#xA;                //Send Request&#xA;                Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);&#xA;                if (client.connected()) {&#xA;                    Serial.println(&quot;Connected!&quot;);&#xA;                    client.println(&quot;POST /upload HTTP/1.0&quot;);&#xA;                    client.println(&quot;From: Arduino&quot;);&#xA;                    client.println(&quot;Host: fierce-chamber-5675.herokuapp.com&quot;);&#xA;                    client.println(&quot;Content-Type: image/jpeg&quot;);&#xA;                    client.println(&quot;Content-Length: &quot; + 32);&#xA;                    client.print(&quot;Connection: close&quot;);&#xA;                    client.println();&#xA;                    for(int i = 0; i &amp;lt; 32; i++) {&#xA;                        client.print(buffer[i], HEX);&#xA;                    }&#xA;                    client.println();&#xA;                } else {&#xA;                    Serial.println(F(&quot;Connection failed&quot;));&#xA;                    return;&#xA;                }&#xA;                client.close();&#xA;&#xA;                Serial.println(F(&quot;-------------------------------------&quot;));&#xA;                jpglen -= bytesToRead;&#xA;            }&#xA;            imgFile.close();&#xA;            cam.resumeVideo();&#xA;            cam.setMotionDetect(true);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8433" LastEditorUserId="84" LastEditDate="2015-04-13T18:44:20.203" LastActivityDate="2015-04-13T19:32:46.200" Title="Memory Problems on Arduino Uno" Tags="|arduino-uno|wifi|sd-card|memory-usage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10047" PostTypeId="2" ParentId="10041" CreationDate="2015-04-13T02:27:00.190" Score="7" Body="&lt;p&gt;Yes, you can do this with &quot;a little programming&quot;  or more easily by adding two cheap components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you connect a say 47k resistor from PWM_Out to Analog_In and a say 100 uF capacitor from Anaolg_In to ground you will be able to read the equivalent analog value to an accuracy of around 1%. Read it N times (maybe 10 times) with a delay of say 12 ms between reads and average it for a better result. This works because the PWM period is &lt;strong&gt;about&lt;/strong&gt; 1 mS so delaying for a period of multiple cycles but not an exact multiple means you sample semi randomly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sort of resolution that you want (4 levels) a MUCH smaller capacitor could be used (maybe 1 uF.) But even a 100 uF capacitor is cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could instead use PWM out (analogWrite) and a digitalRead.&lt;br&gt;&#xA;Perform say 100 digital reads with say 12 ms between reads (so about 1.2 seconds total) and keep two counts - PinWasHigh and PinWasLow for (obviously) high or low conditions. The contents of PinWasHigh tells you what % of reads was high. Due to random sampling you cannot rely on this for 100 levels but determining say 10 levels should give good accuracy. The sum of PinWasHigh and PinWasLow should total 100 as a sanity check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While use of a serial port (hardware or software) or SPI allows more data transfer per time and without much effort, this simple analog method is good enough for many applications. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-13T02:27:00.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10048" PostTypeId="1" CreationDate="2015-04-13T04:16:27.440" Score="2" ViewCount="40" Body="&lt;p&gt;I am new to using serial input. I have an IR emitter and a photo transistor hooked up to my Arduino, I am trying to see which values corresponds to the colored object I put over my IR emitter and phototransistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I find which values are corresponding to the changing values from my phototransistor?&lt;/p&gt;&#xA;" OwnerUserId="8434" LastEditorUserId="6452" LastEditDate="2015-04-13T19:09:56.617" LastActivityDate="2015-04-13T19:09:56.617" Title="How do I find which values are corresponding to the changing values from my phototransistor?" Tags="|serial|ir|photoresistor|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10049" PostTypeId="1" CreationDate="2015-04-12T17:37:16.233" Score="0" ViewCount="1292" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4vGjF.png&quot; alt=&quot;L293D Connection.. Pin refers to pin of the Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor are not rotating in the above circuit . Or rather the Voltage between the two Motor Terminal is zero. I have checked the Pin 10 &amp;amp; 11 and Pin 12 &amp;amp; 13. They are fine and produces desired Voltage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have earlier connected the circuit only to one motor then it worked[ there were no motor right, Pin 12 and Pin 13]. But now, it's not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the problem? The code in the arduino is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int echo = 7;// connected to ultrasonic sensor's echo&#xA;const int trig = 8;// connected to ultrasonic sensor's trig&#xA;const int Right1 = 10;&#xA;const int Right2 = 11;&#xA;const int Left1 = 12;&#xA;const int Left2 = 13;&#xA;void setup() {&#xA;  pinMode(echo, INPUT_PULLUP);&#xA;  pinMode(trig, OUTPUT);&#xA;  pinMode(Right1, OUTPUT);&#xA;  pinMode(Right2, OUTPUT);&#xA;  pinMode(Left1, OUTPUT);&#xA;  pinMode(Left2, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(trig, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trig, HIGH);&#xA;  delayMicroseconds(5);&#xA;  digitalWrite(trig, LOW);&#xA;  int duration = pulseIn(echo, HIGH);&#xA;  int cm = microsecondsToCentimeters(duration);&#xA;  if (cm &amp;gt; 4)&#xA;  {&#xA;    digitalWrite(Right1, HIGH);&#xA;    digitalWrite(Right2, LOW);&#xA;    digitalWrite(Left1, HIGH);&#xA;    digitalWrite(Left2, LOW);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(Right2, HIGH);&#xA;    digitalWrite(Right1, LOW);&#xA;    digitalWrite(Left1, LOW);&#xA;    digitalWrite(Left2, HIGH);&#xA;  }&#xA;  delay(50);&#xA;  Serial.println(cm);&#xA;}&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8620" OwnerDisplayName="iamSiddharthYadav" LastEditorUserId="2944" LastEditDate="2015-04-26T21:50:45.330" LastActivityDate="2015-05-27T01:25:31.823" Title="Problems with L293D" Tags="|arduino-uno|motor|h-bridge|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10050" PostTypeId="2" ParentId="10049" CreationDate="2015-04-12T17:58:50.507" Score="1" Body="&lt;p&gt;Try these steps&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Increase the delay of 50ms to a longer time.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If that fails to work try,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.Running the motor by just directly connecting the terminal to the 9V battery which you are using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the motor runs then most probably the motor requires more current than what the L293D can output which as per the data sheet is 600mA. A solution to this would be using a higher current motor driver like L298N.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the motor doesn't run directly by the battery then well change the battery to one which can supply enough current.&lt;/p&gt;&#xA;" OwnerUserId="8426" OwnerDisplayName="Parthiv Parikh" LastActivityDate="2015-04-12T17:58:50.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10052" PostTypeId="1" AcceptedAnswerId="10057" CreationDate="2015-04-13T08:16:18.733" Score="1" ViewCount="570" Body="&lt;p&gt;I'm looking for a fast (and safe, in terms of stability) way to send sensor data from an Arduino UnoR3 in real time to a Computer (in my case a MacBook Pro) with a sample rate of at least 1kHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Sending sensor values with the related timestamp (in microseconds):&#xA;I use 7 bytes for each sample [1 Header byte, 2 bytes for the sensor value (10/(16)bit-Int), and 4 bytes for a 32-bit unsigned long (time in microseconds)] and send them right away.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the receiving end i mainly use Processing (Im relatively new to Processing though): Reading the bytes in, converting them in integers and safe them in a file or plot them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For sampling rates of 1sample/10ms my code runs smooth and i even can plot the data in &quot;real-time&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For higher frequencies i ran into following problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If i want to plot things, my peripherals freeze and program stops after some time. I have no clue why... maybe serial buffer overflow??&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If i just save the data in a text file (without plotting) it works but with a delay of around 20-30seconds on total sampling times of 10seconds (10000 samples).&#xA;Meaning that somewhere seems to be a bottleneck and i cant keep up with the sent samples from the Arduino.&#xA;Is it possible that the serial bus is the bottleneck here? How can i speed things up? (I'm working with a baudrate 115200bits/s and also 230400bits/s)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can i improve this while still be able to process data in almost real-time (e.g plotting). Is this even possible or do you recommend logging the data in a text file first and then plot? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will it helps to send the data in packages (10samles = 70bytes)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added a timestamp on each sample, since i observed some delay between the actual sensor measurement and the input on the receiving end. I thought that would allow me to plot and postprocess accurately in &quot;real&quot;-time (with a little delay). Any other ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate some input and advice!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="8438" LastActivityDate="2015-04-13T13:39:17.760" Title="General Question about fast Serial Communication and Arduino" Tags="|arduino-uno|serial|communication|processing-lang|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10053" PostTypeId="2" ParentId="1558" CreationDate="2015-04-13T10:55:07.793" Score="0" Body="&lt;p&gt;A common reason is could be because your servo cannot operate at a PWM signal of 0ms.&#xA;For conservative limits, you should stay between 100ms and 2800ms even for very high quality servos.&#xA;With lower quality servos that do not specify maximum and minimum values, conservative limits are 700ms to 2400ms.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-13T10:55:07.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10054" PostTypeId="2" ParentId="9731" CreationDate="2015-04-13T11:12:36.180" Score="1" Body="&lt;p&gt;First try using external power source to power the motor, as only &lt;I&gt; very&lt;/I&gt; small motors can be connected to an Arduino's power source.(Basically, the Motor is using most of the power, leaving too little power for the Arduino to operate properly)&lt;br&gt;&#xA;If that fails, change the code(I will give sample code by tomorrow, if you cannot find one yourself)-maybe use a PWM signal instead of trying PID, as it is much simpler and give very little room for error.&#xA;And also, don't forget the fly back diode mentioned by Gerben.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-13T11:12:36.180" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10057" PostTypeId="2" ParentId="10052" CreationDate="2015-04-13T13:39:17.760" Score="1" Body="&lt;p&gt;You are sending data at ~70kbps. Provided you use serial rate greater than this (115.2 kbps or faster on the Arduino) there should be no problem, assuming you samples are processed quickly enough. This seems to be the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your problem seems to be on the Mac. With a quad core CPU on a fast multitasking machine this should not be an issue. If you are having problems this would be in how you are processing the data. I am not familiar with &lt;code&gt;Processing&lt;/code&gt; but you could do this in any language. You need to separate the data logging from the processing and display task. This could be as simple as running a logger and piping the data into a display program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not an Arduino issue (or even a Mac issue), you should ask on &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;https://stackoverflow.com/&lt;/a&gt;. NOTE if you want help there you will need to give more detail of the code you are running in the Mac.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-13T13:39:17.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10059" PostTypeId="1" CreationDate="2015-04-13T16:16:06.983" Score="0" ViewCount="3675" Body="&lt;p&gt;I'm trying to get the power consumption of a MFRC522 RFID module down, currently while running it consumes about 4mA. There should be a way to put it into sleep mode, I just can't find any documentation on it. I'm using the module with a arduino currently if that helps; and this is the module itself : &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E0ODLWQ&quot; rel=&quot;nofollow&quot;&gt;MFRC522&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1671" LastActivityDate="2021-02-18T19:58:23.807" Title="How to send the MFRC522 RFID module into sleep mode?" Tags="|arduino-uno|power|rfid|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10060" PostTypeId="2" ParentId="10059" CreationDate="2015-04-13T16:28:06.640" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at section &lt;code&gt;8.6.2   Soft power-down mode&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-13T16:28:06.640" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10061" PostTypeId="2" ParentId="10046" CreationDate="2015-04-13T19:32:46.200" Score="1" Body="&lt;p&gt;You are running a wireless TCP stack, an SD card interface, and a web camera with some sort of motion detection, on a less than $20 computer?  I think you should congratulate yourself and move on to the next project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe you are asking too much to add more to it. At $20 a pop, I would think about adding another UNO if you really do want to add more functionality. Let the 2 talk via serial, with one processing the video, the other processing the wireless.  The TCP part uses a considerable amount of resources, both memory and processing power.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-04-13T19:32:46.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10062" PostTypeId="1" AcceptedAnswerId="10063" CreationDate="2015-04-13T20:05:42.473" Score="0" ViewCount="2800" Body="&lt;p&gt;I am using an arduino nano with the standard arduino IR remote library. For now I am using the Irrecord sketch. However, I want to have some pre - programed codes for remotes I don't have. I found this &lt;a href=&quot;http://www.remotecentral.com/cgi-bin/codes/&quot; rel=&quot;nofollow&quot;&gt;site&lt;/a&gt; which apparently has the hex of an endless number of remotes. When I use the regular IR decode, the hex of any remote I use, is only a couple of characters.  However at this site the typical amount is at least 100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the hex for a Toshiba model's sleep command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0000 006c 0022 0002 0157 00ab 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0040 0016 0016 0016 0040 0016 0040 0016 0040 0016 0040 0016 0040 0016 0040 0016 0016 0016 0040 0016 0040 0016 0016 0016 0040 0016 0016 0016 0040 0016 0016 0016 0016 0016 0016 0016 0016 0016 0040 0016 0016 0016 0040 0016 0016 0016 0040 0016 0040 0016 0040 0016 05f0 0157 0055 0016 0e52&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, finally after all that if you are still with me my question is, how would I send that command with the IRRemote library.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2016-03-13T16:05:43.220" Title="Infra Red Send Hex Code" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10063" PostTypeId="2" ParentId="10062" CreationDate="2015-04-13T20:15:32.930" Score="0" Body="&lt;p&gt;That seems to be pronto hex format for codes. A quick google showed this explanation: &lt;a href=&quot;http://www.remotecentral.com/features/irdisp2.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.remotecentral.com/features/irdisp2.htm&lt;/a&gt; and this sample code: &lt;a href=&quot;https://gist.github.com/probonopd/5793692&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/probonopd/5793692&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-04-13T20:15:32.930" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10064" PostTypeId="1" CreationDate="2015-04-14T00:06:31.157" Score="2" ViewCount="896" Body="&lt;p&gt;I am trying to make four LEDs glow using my Arduino, based on some relationship between them in terms of brightness and the time for which LEDs glow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, the relationships are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pin_3_value = 250  // LED 1 intensity&#xA;pin_5_value = 1.2 * pin_3_value // LED 2 intensity&#xA;pin_7_value = 1.1 * pin_5_value  // LED 3 intensity&#xA;pin_13_value = 0.59 * pin_7_value  // LED 4 intensity&#xA;&#xA;time_till_led_1_on = 100&#xA;time_till_led_2_on = time_till_led_1_on * 1.2&#xA;time_till_led_3_on = time_till_led_2_on * 2.4&#xA;time_till_led_4_on = time_till_led_3_on * 1.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that only a fixed set of values are permitted as input to the &lt;code&gt;analogWrite()&lt;/code&gt;. Is there some way to implement this relationship on the Arduino? I cannot use a &lt;code&gt;digitalWrite()&lt;/code&gt;, as the output of PWM pins are used for something else; making the LED glow is just for testing purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I have written so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Brightness level for the four pins&#xA;&#xA;int Brightness_1 = 255;&#xA;int Brightness_2 =  Brightness_1 * 2;&#xA;int Brightness_3 = Brightness_2 * 3;&#xA;int Brightness_4 = Brightness_3 * 4;&#xA;&#xA;// Delay or time between  LED turn off and next LED turn ON&#xA;&#xA;int Delay_1 = 500;&#xA;int Delay_2 =  Delay_1 * 1.1;&#xA;int Delay_3 = Delay_2 * 1.2;&#xA;int Delay_4 = Delay_3 * 1.3;&#xA;&#xA;int pins[] = { 2, 4, 5, 7 }; // An array of pin numbers&#xA;&#xA;void setup()&#xA;{&#xA;    int i;&#xA;    for (i = 0; i &amp;lt; 4; i++) // The array elements are numbered from 0  to num pins - 1&#xA;        pinMode(pins[i], OUTPUT); // Set each pin as an output&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Loop through each pin...&#xA;    analogWrite(pins[0], Brightness_1 ); // Turning it on,&#xA;    delay(Delay_1);                      // pausing,&#xA;    analogWrite(pins[0], 0);             // and turning it off.&#xA;&#xA;    analogWrite(pins[1], Brightness_2); // Turning it on,&#xA;    delay(Delay_2);                     // pausing,&#xA;    analogWrite(pins[1], 0);            // and turning it off.&#xA;&#xA;    analogWrite(pins[2], Brightness_3); // Turning it on,&#xA;    delay(Delay_3);                     // pausing,&#xA;    analogWrite(pins[2], 0);            // and turning it off.&#xA;&#xA;    analogWrite(pins[3], Brightness_4); // Turning it on,&#xA;    delay(Delay_4);                     // pausing,&#xA;    analogWrite(pins[3], 0);            // and turning it off.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I make this work?&lt;/p&gt;&#xA;" OwnerUserId="8454" LastEditorUserId="11763" LastEditDate="2016-07-13T22:58:40.473" LastActivityDate="2016-07-13T22:58:40.473" Title="Arduino PWM LED blinking on four pins, each pin's intensity and time period based on the previous pin" Tags="|arduino-uno|led|arduino-nano|pwm|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10065" PostTypeId="1" CreationDate="2015-04-14T00:52:29.773" Score="0" ViewCount="9549" Body="&lt;p&gt;I am an experienced web developer, but my C++ skills are very basic. I struggle with the concepts because it is so different from something like Javascript (which I already know). I do not have a lot of time to learn C++, and I only need to know enough to play with Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any good resources out there for learning C++ that is specifically geared towards Arduino programming, and is there anything interactive like &lt;a href=&quot;http://codecademy.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Codecademy&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerDisplayName="user8452" LastEditorUserId="4628" LastEditorDisplayName="user8452" LastEditDate="2017-04-19T05:25:32.270" LastActivityDate="2017-04-19T05:27:42.403" Title="How to learn enough C++ to program Arduino?" Tags="|programming|c++|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10066" PostTypeId="2" ParentId="10065" CreationDate="2015-04-14T01:31:37.117" Score="0" Body="&lt;p&gt;Since you have programming experience and you say you only want to learn enough to play with Arduinos, I think a resource worth mentioning is the built-in example programs. I've seen Arduino itself used as a learning tool for C/C++; their examples are very basic and intended for complete novices. If you keep hacking on progressively more complicated examples and googling specific things you don't understand, you will probably be able to get a good handle on things IMHO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That isn't to say it's necessarily a good tool for learning C++ in general, since the limited memory resources and 8-bit CPU make some capabilities of the language commonly used on desktops (and the whole standard library) rarely used or unavailable on Arduino.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="4628" LastEditDate="2017-04-19T05:27:42.403" LastActivityDate="2017-04-19T05:27:42.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10067" PostTypeId="1" CreationDate="2015-04-14T04:38:18.830" Score="5" ViewCount="30418" Body="&lt;p&gt;I want to capture images from my OV7670 (w/o FIFO) and send it to my PC via Wi-Fi (ESP8266) (which I know how to use) using an Arduino Uno. I have read so many blogs and threads on the internet but couldn't find a simple and exact solution for the problem. I am a newbie in this and all I want is the simple wiring schema, code that can be used with Arduino IDE and the direction on how to proceed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this random code. Please see if I can use it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &amp;lt;Ethernet.h&amp;gt;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    uint8_t sensor_addr = 0x42;&#xA;&#xA;    //************ REGISTRADORES **********************//&#xA;&#xA;    #define REG_COM1    0x04    /* Control 1 */&#xA;&#xA;    #define REG_COM7    0x12    /* Control 7 */&#xA;&#xA;    #define   COM7_RESET      0x80    /* Register reset */&#xA;&#xA;    #define   COM7_FMT_MASK   0x38&#xA;&#xA;    #define   COM7_FMT_VGA    0x00&#xA;&#xA;    #define   COM7_FMT_CIF    0x20    /* CIF format */&#xA;&#xA;    #define   COM7_FMT_QVGA   0x10    /* QVGA format */&#xA;&#xA;    #define   COM7_FMT_QCIF   0x08    /* QCIF format */&#xA;&#xA;    #define   COM7_RGB    0x04    /* bits 0 and 2 - RGB format */&#xA;&#xA;    #define   COM7_YUV    0x00    /* YUV */&#xA;&#xA;    #define   COM7_BAYER      0x01    /* Bayer format */&#xA;&#xA;    #define   COM7_PBAYER     0x05    /* &quot;Processed bayer&quot; */&#xA;&#xA;    #define REG_RGB444  0x8c    /* RGB 444 control */&#xA;&#xA;    #define   R444_ENABLE     0x02    /* Turn on RGB444, overrides 5x5 */&#xA;&#xA;    #define   R444_RGBX   0x01    /* Empty nibble at end */&#xA;&#xA;    #define REG_COM9    0x14    /* Control 9  - gain ceiling */&#xA;&#xA;    #define REG_COM10   0x15    /* Control 10 */&#xA;&#xA;    #define REG_COM13   0x3d    /* Control 13 */&#xA;&#xA;    #define   COM13_GAMMA     0x80    /* Gamma enable */&#xA;&#xA;    #define   COM13_UVSAT     0x40    /* UV saturation auto adjustment */&#xA;&#xA;    #define   COM13_UVSWAP    0x01    /* V before U - w/TSLB */&#xA;&#xA;    #define REG_COM15   0x40    /* Control 15 */&#xA;&#xA;    #define   COM15_R10F0     0x00    /* Data range 10 to F0 */&#xA;&#xA;    #define   COM15_R01FE     0x80    /*            01 to FE */&#xA;&#xA;    #define   COM15_R00FF     0xc0    /*            00 to FF */&#xA;&#xA;    #define   COM15_RGB565    0x10    /* RGB565 output */&#xA;&#xA;    #define   COM15_RGB555    0x30    /* RGB555 output */&#xA;&#xA;    #define REG_COM11   0x3b    /* Control 11 */&#xA;&#xA;    #define   COM11_NIGHT     0x80    /* NIght mode enable */&#xA;&#xA;    #define   COM11_NMFR      0x60    /* Two bit NM frame rate */&#xA;&#xA;    #define   COM11_HZAUTO    0x10    /* Auto detect 50/60 Hz */&#xA;&#xA;    #define   COM11_50HZ      0x08    /* Manual 50Hz select */&#xA;&#xA;    #define   COM11_EXP   0x02&#xA;&#xA;    #define REG_COM16   0x41    /* Control 16 */&#xA;&#xA;    #define   COM16_AWBGAIN   0x08    /* AWB gain enable */&#xA;&#xA;    #define REG_COM17       0x42    /* Control 17 */&#xA;&#xA;    #define COM17_AECWIN    0xc0    /* AEC window - must match COM4 */&#xA;&#xA;    #define COM17_CBAR      0x08    /* DSP Color bar */&#xA;&#xA;    #define REG_TSLB    0x3a    /* lots of stuff */&#xA;&#xA;    #define   TSLB_YLAST      0x04    /* UYVY or VYUY - see com13 */&#xA;&#xA;    #define MTX1            0x4f    /* Matrix Coefficient 1 */&#xA;&#xA;    #define MTX2            0x50    /* Matrix Coefficient 2 */&#xA;&#xA;    #define MTX3            0x51    /* Matrix Coefficient 3 */&#xA;&#xA;    #define MTX4            0x52    /* Matrix Coefficient 4 */&#xA;&#xA;    #define MTX5            0x53    /* Matrix Coefficient 5 */&#xA;&#xA;    #define MTX6            0x54    /* Matrix Coefficient 6 */&#xA;&#xA;    #define REG_CONTRAS     0x56    /* Contrast control */&#xA;&#xA;    #define MTXS            0x58    /* Matrix Coefficient Sign */&#xA;&#xA;    #define AWBC7           0x59    /* AWB Control 7 */&#xA;&#xA;    #define AWBC8           0x5a    /* AWB Control 8 */&#xA;&#xA;    #define AWBC9           0x5b    /* AWB Control 9 */&#xA;&#xA;    #define AWBC10          0x5c    /* AWB Control 10 */&#xA;&#xA;    #define AWBC11          0x5d    /* AWB Control 11 */&#xA;&#xA;    #define AWBC12          0x5e    /* AWB Control 12 */&#xA;&#xA;    #define REG_GFIX        0x69    /* Fix gain control */&#xA;&#xA;    #define GGAIN           0x6a    /* G Channel AWB Gain */&#xA;&#xA;    #define DBLV            0x6b    &#xA;&#xA;    #define AWBCTR3         0x6c    /* AWB (Automatic White Balance) Control 3 */&#xA;&#xA;    #define AWBCTR2         0x6d    /* AWB Control 2 */&#xA;&#xA;    #define AWBCTR1         0x6e    /* AWB Control 1 */&#xA;&#xA;    #define AWBCTR0         0x6f    /* AWB Control 0 */&#xA;&#xA;    #define REG_COM8    0x13    /* Control 8 */&#xA;&#xA;    #define   COM8_FASTAEC    0x80    /* Enable fast AGC/AEC (Automatic Gain Control - Automatic Exposure Control)*/&#xA;&#xA;    #define   COM8_AECSTEP    0x40    /* Unlimited AEC step size */&#xA;&#xA;    #define   COM8_BFILT      0x20    /* Band filter enable */&#xA;&#xA;    #define   COM8_AGC    0x04    /* Auto gain enable */&#xA;&#xA;    #define   COM8_AWB    0x02    /* White balance enable */&#xA;&#xA;    #define   COM8_AEC    0x01    /* Auto exposure enable */&#xA;&#xA;    #define REG_COM3        0x0c    /* Control 3 */&#xA;&#xA;    #define COM3_SWAP       0x40    /* Byte swap */&#xA;&#xA;    #define COM3_SCALEEN    0x08    /* Enable scaling */&#xA;&#xA;    #define COM3_DCWEN      0x04    /* Enable downsamp/crop/window */&#xA;&#xA;    #define REG_BRIGHT      0x55    /* Brightness */&#xA;&#xA;    #define REG_COM14      0x3E    &#xA;&#xA;    //*************************************************************************//&#xA;&#xA;    byte mac[] = {&#xA;      0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC do arduino&#xA;    IPAddress ip(192,168,0,120); // IP do arduino&#xA;    byte server[] = {&#xA;      192,168,0,105}; //Endereço do servidor&#xA;&#xA;&#xA;&#xA;    void setup (){&#xA;&#xA;      DDRC&amp;amp;=~15;//low d0-d3 camera  PORTC (pino A0 ao pino A5) (11110000) A0 a A3 como entrada e A4 (SDA) e A5 (SCL) como saídas - essa linha tem a mesma função de pinMode que declara quem &#xA;      //é pino de saída e de entrada. Se for 0 é entrada e se for 1 é saída. O valor é não 15 (acima).                 &#xA;      DDRD&amp;amp;=~255;//d7-d4 and interupt pins PORTD (pino 0 ao pino 7) (0000 d7 ao d4           0=d3=vsync 0=d2=pclock               0=d1=href   1=d0=button)&#xA;&#xA;      DDRB&amp;amp;=~1;&#xA;&#xA;      Serial.begin(57600);&#xA;      Wire.begin();&#xA;&#xA;      UCSR0B = (1&amp;lt;&amp;lt;RXEN0)|(1&amp;lt;&amp;lt;TXEN0);//Enable receiver and transmitter (habilita bit 4 e bit 3)&#xA;&#xA;      UCSR0C=6;// B (00000110) async (b7 e b6 = 00); (b3 = 0) 1 stop bit; (b2 e b1 = 1)  8bit char; no parity bits (b5 e b4 = 00); (b0 = 0)clock polaridade&#xA;&#xA;      //set up twi for 100khz&#xA;      TWSR&amp;amp;=~3;//disable prescaler for TWI&#xA;      TWBR=72;//set to 100khz&#xA;&#xA;      //SET UP CAMERA&#xA;      wrReg(0x15,32);//pclk does not toggle on HBLANK COM10 vsync falling&#xA;      //wrReg(0x15,0);//pclk does not toggle on HBLANK COM10 vsync falling&#xA;      wrReg(REG_RGB444, 0x00);             // Disable RGB444&#xA;      wrReg(REG_COM11,226);//enable nigh mode 1/8 frame rate COM11*/&#xA;      wrReg(REG_TSLB,0x04);                // 0D = UYVY  04 = YUYV     &#xA;      wrReg(REG_COM13,0x88);               // connect to REG_TSLB&#xA;      //definição para o RGB 565&#xA;      wrReg(REG_COM7, 0x04);           // RGB + color bar disable &#xA;      wrReg(REG_COM15, 0xD0);          // Set rgb565 with Full range    0xD0&#xA;&#xA;        wrReg(REG_COM3,0);    // REG_COM3&#xA;&#xA;      wrReg(0x32,0xb6);        // HREF   &#xA;      wrReg(0x17,0x13);        // HSTART&#xA;      wrReg(0x18,0x01);        // HSTOP&#xA;      wrReg(0x19,0x02);        // VSTART&#xA;      wrReg(0x1a,0x7a);        // VSTOP&#xA;      wrReg(0x03,0x0a);        // VREF&#xA;&#xA;      wrReg(REG_COM1, 0x00);&#xA;&#xA;&#xA;&#xA;      //COLOR SETTING&#xA;      wrReg(REG_COM8,0x8F);        // AGC AWB AEC Unlimited step size&#xA;      wrReg(0xAA,0x14);            // Average-based AEC algorithm&#xA;      wrReg(REG_BRIGHT,0x00);      // 0x00(Brightness 0) - 0x18(Brightness +1) - 0x98(Brightness -1)&#xA;      wrReg(REG_CONTRAS,0x40);     // 0x40(Contrast 0) - 0x50(Contrast +1) - 0x38(Contrast -1)&#xA;      // wrReg(0xB1,0xB1);            // Automatic Black level Calibration&#xA;      wrReg(0xB1,4);//really enable auto black level calibration&#xA;      wrReg(MTX1,0x80);        &#xA;      wrReg(MTX2,0x80);      &#xA;      wrReg(MTX3,0x00);        &#xA;      wrReg(MTX4,0x22);        &#xA;      wrReg(MTX5,0x5e);        &#xA;      wrReg(MTX6,0x80);        &#xA;      wrReg(MTXS,0x9e);        &#xA;      wrReg(AWBC7,0x88);&#xA;      wrReg(AWBC8,0x88);&#xA;      wrReg(AWBC9,0x44);&#xA;      wrReg(AWBC10,0x67);&#xA;      wrReg(AWBC11,0x49);&#xA;      wrReg(AWBC12,0x0e);&#xA;      wrReg(REG_GFIX,0x00);&#xA;      //wrReg(GGAIN,0x40);&#xA;      wrReg(AWBCTR3,0x0a);&#xA;      wrReg(AWBCTR2,0x55);&#xA;      wrReg(AWBCTR1,0x11);&#xA;      wrReg(AWBCTR0,0x9f);&#xA;&#xA;      wrReg(0xb0,0x84);//not sure what this does&#xA;      wrReg(REG_COM16,COM16_AWBGAIN);//disable auto denoise and edge enhancment&#xA;      //wrReg(REG_COM16,0);&#xA;      wrReg(0x4C,0);//disable denoise&#xA;      wrReg(0x76,0);//disable denoise&#xA;      wrReg(0x77,0);//disable denoise&#xA;      wrReg(0x7B,4);//brighten up shadows a bit end point 4&#xA;      wrReg(0x7C,8);//brighten up shadows a bit end point 8&#xA;      //wrReg(0x88,238);//darken highligts end point 176&#xA;      //wrReg(0x89,211);//try to get more highlight detail&#xA;      //wrReg(0x7A,60);//slope&#xA;      //wrReg(0x26,0xB4);//lower maxium stable operating range for AEC&#xA;      //hueSatMatrix(0,100);&#xA;      //ov7670_store_cmatrix();&#xA;      //wrReg(0x20,12);//set ADC range to 1.5x&#xA;      wrReg(REG_COM9,0x6A);//max gain to 128x&#xA;      wrReg(0x11,9);//using scaler for divider&#xA;      delay(100);//i2c uses interupts to write data wait for all bytes to be written&#xA;&#xA;&#xA;&#xA;      //            #ifdef qqvga || ifdef qvga&#xA;&#xA;      wrReg(REG_COM3,4);    // REG_COM3 &#xA;&#xA;      //    #ifdef qqvga&#xA;&#xA;      wrReg(REG_COM14, 0x1a);          // divide by 4&#xA;&#xA;      wrReg(0x72, 0x22);               // downsample by 4&#xA;&#xA;      wrReg(0x73, 0xf2);               // divide by 4&#xA;&#xA;      wrReg(0x17,0x16);&#xA;&#xA;      wrReg(0x1A,0x04);&#xA;&#xA;      wrReg(0x32,0xa4);           &#xA;&#xA;      wrReg(0x19,0x02);&#xA;&#xA;      wrReg(0x18,0x7a);&#xA;&#xA;      wrReg(0x03,0x0a);&#xA;&#xA;&#xA;&#xA;&#xA;      wrReg(REG_COM1, 0x00);&#xA;&#xA;      // COLOR SETTING&#xA;&#xA;&#xA;&#xA;      wrReg(REG_COM8,0x8F);        // AGC AWB AEC Unlimited step size&#xA;&#xA;      wrReg(0xAA,0x14);            // Average-based AEC algorithm&#xA;&#xA;      wrReg(REG_BRIGHT,0x00);      // 0x00(Brightness 0) - 0x18(Brightness +1) - 0x98(Brightness -1)&#xA;&#xA;      wrReg(REG_CONTRAS,0x40);     // 0x40(Contrast 0) - 0x50(Contrast +1) - 0x38(Contrast -1)&#xA;&#xA;      // wrReg(0xB1,0xB1);            // Automatic Black level Calibration&#xA;&#xA;      wrReg(0xB1,4);//really enable auto black level calibration&#xA;&#xA;      wrReg(MTX1,0x80);        &#xA;&#xA;      wrReg(MTX2,0x80);      &#xA;&#xA;      wrReg(MTX3,0x00);        &#xA;&#xA;      wrReg(MTX4,0x22);        &#xA;&#xA;      wrReg(MTX5,0x5e);        &#xA;&#xA;      wrReg(MTX6,0x80);        &#xA;&#xA;      wrReg(MTXS,0x9e);        &#xA;&#xA;      wrReg(AWBC7,0x88);&#xA;&#xA;      wrReg(AWBC8,0x88);&#xA;&#xA;      wrReg(AWBC9,0x44);&#xA;&#xA;      wrReg(AWBC10,0x67);&#xA;&#xA;      wrReg(AWBC11,0x49);&#xA;&#xA;      wrReg(AWBC12,0x0e);&#xA;&#xA;      wrReg(REG_GFIX,0x00);&#xA;&#xA;      //wrReg(GGAIN,0x40);&#xA;&#xA;      wrReg(AWBCTR3,0x0a);&#xA;&#xA;      wrReg(AWBCTR2,0x55);&#xA;&#xA;      wrReg(AWBCTR1,0x11);&#xA;&#xA;      wrReg(AWBCTR0,0x9f);&#xA;&#xA;&#xA;&#xA;      wrReg(0xb0,0x84);//not sure what this does&#xA;&#xA;      wrReg(REG_COM16,COM16_AWBGAIN);//disable auto denoise and edge enhancment&#xA;&#xA;      //wrReg(REG_COM16,0);&#xA;&#xA;      wrReg(0x4C,0);//disable denoise&#xA;&#xA;      wrReg(0x76,0);//disable denoise&#xA;&#xA;      wrReg(0x77,0);//disable denoise&#xA;&#xA;      wrReg(0x7B,4);//brighten up shadows a bit end point 4&#xA;&#xA;        wrReg(0x7C,8);//brighten up shadows a bit end point 8&#xA;&#xA;        //wrReg(0x88,238);//darken highligts end point 176&#xA;&#xA;      //wrReg(0x89,211);//try to get more highlight detail&#xA;&#xA;      //wrReg(0x7A,60);//slope&#xA;&#xA;      //wrReg(0x26,0xB4);//lower maxium stable operating range for AEC&#xA;&#xA;      //hueSatMatrix(0,100);&#xA;&#xA;      //ov7670_store_cmatrix();&#xA;&#xA;      //wrReg(0x20,12);//set ADC range to 1.5x&#xA;&#xA;      wrReg(REG_COM9,0x6A);//max gain to 128x&#xA;&#xA;      //    #ifdef qvga&#xA;&#xA;      wrReg(0x11,4);//using scaler for divider&#xA;&#xA;      pinMode(4,OUTPUT);&#xA;      digitalWrite(4,HIGH);&#xA;      Serial.println(&quot;Iniciando conexao&quot;);&#xA;      Ethernet.begin(mac, ip);&#xA;      Serial.println(&quot;Por favor, espere.&quot;);&#xA;      delay(1000);&#xA;&#xA;    }&#xA;&#xA;&#xA;    EthernetClient client;&#xA;    void loop (){&#xA;&#xA;    connectWeb(7000,server);&#xA;    foto(480,640);&#xA;&#xA;    }&#xA;&#xA;&#xA;    byte wrReg(int regID, int regDat )&#xA;&#xA;    { &#xA;&#xA;      Wire.beginTransmission(sensor_addr &amp;gt;&amp;gt; 1);&#xA;      Wire.write(regID &amp;amp; 0x00FF);   &#xA;      Wire.write(regDat &amp;amp; 0x00FF);  &#xA;      if(Wire.endTransmission())&#xA;      {&#xA;        return 0; &#xA;        PORTB|=32;&#xA;        while (1) {&#xA;        }&#xA;      }&#xA;      delay(1);&#xA;      return(1);&#xA;    }&#xA;&#xA;    uint16_t d;&#xA;&#xA;&#xA;    void foto(uint16_t linha, uint16_t coluna)&#xA;    { &#xA;      while (!(PIND&amp;amp;8)) {&#xA;      }//wait for high&#xA;      while ((PIND&amp;amp;8)) {&#xA;      }//wait for low&#xA;      //uint16_t a =millis(); //teste de tempo&#xA;      if (linha != 0)&#xA;      {&#xA;        //while (!(PINB&amp;amp;1)) {}//wait for high&#xA;        //while ((PINB&amp;amp;1)) {}//wait for low&#xA;        //while (!(PINB&amp;amp;1)) {}//wait for high&#xA;&#xA;        while (linha--)&#xA;        {&#xA;&#xA;          while (!(PIND&amp;amp;4)) {&#xA;          }//wait for high&#xA;          while ((PIND&amp;amp;4)) {&#xA;          }//wait for low&#xA;          //      int a = millis(); //teste de tempo&#xA;&#xA;          uint16_t byte1, byte2;&#xA;          uint8_t buf[512];&#xA;&#xA;          uint16_t  coluna_temp=coluna;&#xA;          while (coluna--){&#xA;&#xA;            for(int i=0; i&amp;lt;2;i++){&#xA;              while (!(PIND&amp;amp;4)) {&#xA;              }//wait for high&#xA;              if(i==0){             &#xA;                byte1= (uint8_t)(PINC&amp;amp;15)|(PIND&amp;amp;240); //B 00001111 (A0 a A3) ou 11110000 (d7 ao d4)&#xA;              }&#xA;              else{&#xA;                byte2= (uint8_t)(PINC&amp;amp;15)|(PIND&amp;amp;240);&#xA;&#xA;                //((byte1&amp;lt;&amp;lt;8)|byte2);&#xA;               /* for(int x=0;x&amp;lt;512;x++){&#xA;                  buf[x]= (((byte1&amp;lt;&amp;lt;8)|byte2),BIN);&#xA;                  d+=buf[x];        &#xA;                }*/&#xA;            sendMsg(client, ((byte1&amp;lt;&amp;lt;8)|byte2));    &#xA;                //Serial.println(d);&#xA;&#xA;                // Serial.println(((byte1&amp;lt;&amp;lt;8)|byte2),BIN); //B 00001111 (A0 a A3) ou 11110000 (d7 ao d4)&#xA;                //teste++;&#xA;              }&#xA;              while ((PIND&amp;amp;4)) {&#xA;              }//wait for low&#xA;            }&#xA;&#xA;          }&#xA;          //                                        int b = millis(); //teste de tempo&#xA;          //  Serial.println((b-a)); //teste de tempo&#xA;          coluna=coluna_temp;&#xA;        }&#xA;&#xA;        //while ((PIND&amp;amp;1)) {}//wait for low&#xA;&#xA;&#xA;&#xA;      }&#xA;      //uint16_t b =millis(); //teste de tempo&#xA;      //Serial.println((b-a)); //teste de tempo&#xA;     // return teste;&#xA;&#xA;    }&#xA;&#xA;&#xA;&#xA;    void connectWeb(int port, byte ipServer[]){&#xA;&#xA;      if (client.connect(ipServer,port)){&#xA;        Serial.println(&quot;Conectado&quot;);&#xA;        //essa e a parte que da erro. Perceba que estou enviando a mensagem&#xA;        //aqui, mas a intençao e enviar na funcao de tirar a foto.Aqui e teste&#xA;       // sendMsg(client, 800);&#xA;&#xA;      }else{&#xA;        Serial.println(&quot;Conexao falhou&quot;);&#xA;      }&#xA;&#xA;       if (!client.connected()) {&#xA;        Serial.println();&#xA;        Serial.println(&quot;disconnecting.&quot;);&#xA;        client.stop();&#xA;&#xA;        // do nothing forevermore:&#xA;        while(true);&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    //void sendMsg(EthernetClient client, uint8_t msg){&#xA;    //      client.println(&quot;valor &quot;+String(msg));&#xA;    //}&#xA;&#xA;    void sendMsg(EthernetClient client, uint32_t msg){&#xA;          client.println(msg,DEC);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8218" LastEditorUserId="6936" LastEditDate="2016-02-02T06:16:39.047" LastActivityDate="2019-06-16T14:26:58.270" Title="Capturing images from OV7670 (w/o FIFO) using Arduino Uno?" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10068" PostTypeId="1" CreationDate="2015-04-14T07:27:27.817" Score="0" ViewCount="2564" Body="&lt;p&gt;I am using Arduino GSM Module and Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Kf9Y.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want my GSM module to be stand alone once I programmed it. It will store the phone number of the user if he sends a correct passcode. Since I want the data to available even after I power off my module. I need to store it to my sim. I don't want to use an SD card shield or store data to arduino's EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read &lt;a href=&quot;https://arduino.stackexchange.com/questions/1370/getting-the-contacts-storing-contacts-to-sim-card&quot;&gt;Getting the contacts/ storing contacts to SIM card&lt;/a&gt;. The only clear reply is reading from the SIM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to add phonebook entry to SIM card?&#xA;Do you know a tutorial?&lt;/p&gt;&#xA;" OwnerUserId="8457" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2020-04-30T23:34:55.073" Title="How can I add phonebook entry to sim card using Arduino GSM shield?" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10069" PostTypeId="1" AcceptedAnswerId="10071" CreationDate="2015-04-14T08:56:46.927" Score="0" ViewCount="1766" Body="&lt;p&gt;Some time ago I came across a Vedic in which a person has hacked an optical mouse's camera and displayed the image in the Serial Monitors.&lt;br&gt;&#xA;My question:&lt;br&gt;&#xA;How to use Serial Monitor to display an image captured by the Arduino&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-14T09:45:44.603" Title="Using Arduino to show images in Serial Monitor" Tags="|sensors|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10071" PostTypeId="2" ParentId="10069" CreationDate="2015-04-14T09:45:44.603" Score="1" Body="&lt;p&gt;Based on &lt;a href=&quot;http://frenki.net/2013/12/convert-optical-mouse-into-arduino-web-camera/&quot; rel=&quot;nofollow&quot;&gt;this guide&lt;/a&gt;, he doesn't actually display the images on the serial monitor, only the image data for each pixel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then another program (Javascript and some HTML) on the PC side collects the data and converts it to a greyscale image.&lt;/p&gt;&#xA;" OwnerUserId="6452" LastActivityDate="2015-04-14T09:45:44.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10072" PostTypeId="2" ParentId="10065" CreationDate="2015-04-14T10:11:04.620" Score="3" Body="&lt;p&gt;If I were you I'd take the high road.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was in your shoes a while ago and I didn't know how to approach Arduino. I was very lucky that I came across a book written by the famous Jack Purdum, &quot;Learn C programming for the Arduino&quot;. It is written by a retired Purdue University professor who is well known for his extremely easy to learn teaching method. He has another &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only knew MATLAB and Simulink before starting this book. This book is amazing. It was extremely easy to follow. I now have no difficulty programming Arduino in the correct way. This book trains you to optimize everything which is very crucial with the limited resources on Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest C instead of C++. It is the language of choice for programming embedded system. It is said to be low level, but as a MATLAB user I should tell you that syntaxes are extremely easy and intuitive. I didn't find anything hard about them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;There isn't any problem to use C in Arduino IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You don't need to worry about libraries. You only need to load them in the beginning of the code. You do not need to know how was the code written in the library.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check the comments about the book on Amazon if you are not convinced.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Good Luck&lt;/p&gt;&#xA;" OwnerUserId="8269" LastActivityDate="2015-04-14T10:11:04.620" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10074" PostTypeId="1" CreationDate="2015-04-14T14:41:17.447" Score="2" ViewCount="68" Body="&lt;p&gt;I want to track my pets using some sensors (their location in space) but I could only find radio sensors. These radio sensors are big and cumbersome for my dogs to carry around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some sensor that I can use in order to locate them in space? I want to use my arduino board to capture the data.&lt;/p&gt;&#xA;" OwnerUserId="8467" LastActivityDate="2015-04-14T14:41:17.447" Title="Sensors to use in Pets" Tags="|sensors|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="10076" PostTypeId="1" AcceptedAnswerId="14428" CreationDate="2015-04-14T16:24:20.833" Score="0" ViewCount="415" Body="&lt;p&gt;I am trying to upload to my nano the code &lt;a href=&quot;http://www.righto.com/2010/11/improved-arduino-tv-b-gone.html&quot; rel=&quot;nofollow&quot;&gt;attached&lt;/a&gt;. It is giving me an error saying variable must be const about something I am trying to put in progrem. I learned that installing a older version of the compiler worked. However I was wondering is there a way to just edit the code to make it work. I tried putting const before it but it didn't work. It is on line 78 and 79 of the first file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;const extern PGM_P *NApowerCodes[] PROGMEM;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;const extern PGM_P *EUpowerCodes[] PROGMEM;&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="8046" LastEditDate="2015-04-14T17:09:46.930" LastActivityDate="2015-08-22T01:40:20.600" Title="&quot;variable must be const&quot; fix for Arduino progrem" Tags="|compile|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10077" PostTypeId="2" ParentId="10065" CreationDate="2015-04-14T16:50:01.853" Score="0" Body="&lt;p&gt;Another way to approach the problem is to come up with a project that you want to do with an Arduino and look for code samples.  Since you already have some programming experience you should be able to pick up what's going on pretty quickly and you will have a vested interest in what the code is doing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Example: &lt;a href=&quot;https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor&quot; rel=&quot;nofollow&quot;&gt;Read temperature from a sensor&lt;/a&gt; and &lt;a href=&quot;https://learn.adafruit.com/character-lcds&quot; rel=&quot;nofollow&quot;&gt;display to an LCD&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos are really good for reading from a sensor and there's a huge arduino community.  So, if you start with just reading from different types of sensors you'll find a lot of examples and learn a lot about Arduinos at the same time. &lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-04-14T16:50:01.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10078" PostTypeId="1" AcceptedAnswerId="10079" CreationDate="2015-04-14T18:30:03.103" Score="0" ViewCount="369" Body="&lt;p&gt;Firstly, I must apologise as I'm a complete noob but the Arduino kits / lego pieces are fantastic and I can't stop tinkering.  Unfortunatley my knowledge does not match my passion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I picked up a laser from &lt;a href=&quot;http://www.amazon.co.uk/FamilyMall-KY-008-Transmitter-Module-Arduino/dp/B00KYHL7HO&quot; rel=&quot;nofollow&quot;&gt;Amazon: FamilyMall(TM) KY-008 Laser Transmitter Module 650nm 5V Diode For Arduino AVR PIC&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what the middle pin is good for and if I can somehow manage to detect and respond to the beam being broken? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for looking. :)&lt;/p&gt;&#xA;" OwnerUserId="8423" LastEditorUserId="2881" LastEditDate="2015-04-14T19:03:17.230" LastActivityDate="2015-04-14T20:30:30.517" Title="Responding to a broken laser beam?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10079" PostTypeId="2" ParentId="10078" CreationDate="2015-04-14T20:30:30.517" Score="1" Body="&lt;p&gt;Without a data sheet or the device on hand not sure what the middle pin is used for.  On the topic of detecting a broken beam the item you purchased is purely an emitter, in order to detect the beam being broken there are two main ways, using a photodetector on the &quot;opposite end&quot; of the beam but this means having wires trailing the same path as the laser beam, alternatively you could mount a mirror where the beam lands and reflect it back to a photodetector mounted close to the laser diode.  You would them use the arduino to detect the state of the photodetector.&lt;/p&gt;&#xA;" OwnerUserId="8476" LastActivityDate="2015-04-14T20:30:30.517" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10080" PostTypeId="1" AcceptedAnswerId="10176" CreationDate="2015-04-14T21:56:07.940" Score="1" ViewCount="3646" Body="&lt;p&gt;I developed a PWM using timer1,using arduino uno and digital output, and identified that when I send a wave with duration of 0.6ms in High level, the motor goes to 0º. If I send 2.1ms, it goes to 180º. I tried to make a relationship between these scales to send the angle and change the time period in order to achieve that angle and it did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to move with a precision of 1 degree, is that possible? Just adjusting the time period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The model of the motor is mg996r.&#xA;Maybe I am missing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code just generates an interrupt over 50 microsencods and I use this to set the frequency of 50Hz and the duty cycle in ms using digitalWrite associated with pin 9.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;double t = 0.0;&#xA;&#xA;double period = 0;&#xA;&#xA;void setup() &#xA;{&#xA;  t = 0;&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(9, OUTPUT);    &#xA;  Timer1.initialize(50);&#xA;  Timer1.attachInterrupt( timerIsr ); // attach the service routine here&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Main code loop&#xA;  // TODO: Put your regular (non-ISR) logic here&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    float grau = Serial.parseFloat();&#xA;&#xA;    // receive data as angle&#xA;    if (grau &amp;gt; 180) grau = 180;&#xA;    if (grau &amp;lt; 0) grau = 0;&#xA;&#xA;    // set period for that angle&#xA;    // relationship developed between angle and period in ms&#xA;    //set it to period&#xA;    period = (0.00833*grau + 0.6)*1E-3;  &#xA;  }&#xA;&#xA;}&#xA;&#xA;/// --------------------------&#xA;/// Custom ISR Timer Routine&#xA;/// --------------------------&#xA;void timerIsr()&#xA;{&#xA;    t += 50E-6;&#xA;    if (t &amp;lt;= period) {&#xA;      digitalWrite(9, HIGH);&#xA;    }&#xA;    else if (t &amp;lt; 20E-3) { // periodo max de 20ms -&amp;gt; 50Hz&#xA;      digitalWrite(9, LOW);&#xA;    }&#xA;    else {&#xA;      t = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just got it working by creating a timer1 interrupt on CTC mode with a frequency of 100kHz and counting the necessary time to get increments (~ 10us each) of around 1 degree on my servo motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info &lt;a href=&quot;https://arduino.stackexchange.com/questions/10389/why-timer1-does-not-generate-correct-period-on-ctc-mode-with-a-resolution-of-5us&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-28T01:54:29.347" Title="How to precisely control servo motor by changing duty cycle?" Tags="|arduino-uno|motor|pwm|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10081" PostTypeId="1" CreationDate="2015-04-14T22:36:59.680" Score="5" ViewCount="2041" Body="&lt;p&gt;I am currently working on a project that plays music for you. My question for this thread is, is it possible to retrieve the names of the songs within the micro SD card that is inserted into the shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I am renaming the song files to track001, track002, track003, etc. As can be seen in the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int arraySize = 5;&#xA;char songs[arraySize][15] =&#xA;{&#xA;  {&quot;track001.mp3&quot;},&#xA;  {&quot;track002.mp3&quot;},&#xA;  {&quot;track003.mp3&quot;},&#xA;  {&quot;track004.mp3&quot;},&#xA;  {&quot;track005.mp3&quot;}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is how am I currently playing music with this shield. I am not too happy with this as I would like to be able to insert different micro SD cards into the shield without having to rename them to track00X or without having to change the code every time to match the song names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is it possible to code it to retrieve the song names from the SD card instead of having to specify their name in the code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below you can see my full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_VS1053.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;#define BREAKOUT_RESET  9      // VS1053 reset pin (output)&#xA;#define BREAKOUT_CS     10     // VS1053 chip select pin (output)&#xA;#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)&#xA;&#xA;#define SHIELD_CS     7      // VS1053 chip select pin (output)&#xA;#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)&#xA;&#xA;#define CARDCS 4     // Card chip select pin&#xA;#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin&#xA;&#xA;Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&#xA;int volume = 20;&#xA;const int arraySize = 5;&#xA;char songs[arraySize][15] =&#xA;{&#xA;  {&quot;track001.mp3&quot;},&#xA;  {&quot;track002.mp3&quot;},&#xA;  {&quot;track003.mp3&quot;},&#xA;  {&quot;track004.mp3&quot;},&#xA;  {&quot;track005.mp3&quot;}&#xA;};&#xA;&#xA;int songNumber = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  musicPlayer.begin();&#xA;  SD.begin(CARDCS);&#xA;  musicPlayer.setVolume(volume, volume);&#xA;  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Lower Volume&#xA;  if (musicPlayer.GPIO_digitalRead(7) == HIGH)&#xA;  {&#xA;    if (volume &amp;lt; 70)&#xA;    {&#xA;      volume = volume + 1;&#xA;      musicPlayer.setVolume(volume, volume);&#xA;      delay(50);&#xA;    }&#xA;  }&#xA;&#xA;  // Increase Volume&#xA;  if (musicPlayer.GPIO_digitalRead(6) == HIGH)&#xA;  {&#xA;    if (volume &amp;gt; 0)&#xA;    {&#xA;      volume = volume - 1;&#xA;      musicPlayer.setVolume(volume, volume);&#xA;      delay(50);&#xA;    }&#xA;  }&#xA;&#xA;  // Start Music Player&#xA;  if (musicPlayer.GPIO_digitalRead(5) == HIGH)&#xA;  {&#xA;    if (! musicPlayer.playingMusic)&#xA;    {&#xA;      musicPlayer.startPlayingFile(songs[songNumber]);&#xA;    }&#xA;  }&#xA;&#xA;  // Pause / Resume&#xA;  if (musicPlayer.GPIO_digitalRead(4) == HIGH)&#xA;  {&#xA;    if (! musicPlayer.paused())&#xA;    {&#xA;      musicPlayer.pausePlaying(true);&#xA;    }&#xA;    else&#xA;    {&#xA;      musicPlayer.pausePlaying(false);&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;  // Prev Song&#xA;  if (musicPlayer.GPIO_digitalRead(3) == HIGH)&#xA;  {&#xA;    if (songNumber - 1 &amp;gt;= 0)&#xA;    {&#xA;      songNumber = songNumber - 1;&#xA;    }&#xA;    else&#xA;    {&#xA;      songNumber = arraySize - 1;&#xA;    }&#xA;    Serial.println(songNumber);&#xA;    musicPlayer.startPlayingFile(songs[songNumber]);&#xA;&#xA;    delay(500);&#xA;  }&#xA;&#xA;  // Next Song&#xA;  if (musicPlayer.GPIO_digitalRead(2) == HIGH)&#xA;  {&#xA;    if (songNumber + 1 &amp;lt; arraySize)&#xA;    {&#xA;      songNumber = songNumber + 1;&#xA;    }&#xA;    else&#xA;    {&#xA;      songNumber = 0;&#xA;    }&#xA;    Serial.println(songNumber);&#xA;    musicPlayer.startPlayingFile(songs[songNumber]);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this is possible and someone reading this knows how to do so, I would truly appreciate it if you explained it to me and even provided an example or even edit my own code if you want. Thank you! :)&lt;/p&gt;&#xA;" OwnerUserId="8369" LastActivityDate="2015-04-14T23:50:59.577" Title="Adafruit Music Maker Shield - Retrieve song names from SD Card" Tags="|arduino-uno|shields|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10082" PostTypeId="2" ParentId="10081" CreationDate="2015-04-14T23:50:59.577" Score="1" Body="&lt;p&gt;The adafruit library was is similar to the prior &lt;a href=&quot;https://github.com/mpflaga/Sparkfun-MP3-Player-Shield-Arduino-Library&quot; rel=&quot;nofollow&quot;&gt;SFEMP3shield library&lt;/a&gt; (disclosure I am the main author of that). That said either library can work on either Adafruit or SFE shield or breakout board. AdaFruit's library is cleaner re-write. But in doing so it is minimal in its functions. The SFE library demonstrates many more features of the VS1053 chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said; the &lt;a href=&quot;https://github.com/mpflaga/Sparkfun-MP3-Player-Shield-Arduino-Library/blob/master/SFEMP3Shield/Examples/FilePlayer/FilePlayer.ino&quot; rel=&quot;nofollow&quot;&gt;./Example/fileplayer.ino&lt;/a&gt; does exactly what you are asking. The directory command lists out the files with an enumerating number. Entering 0[number] plays that file. This is how I broke away from &quot;track###.mp3&quot;, without having to implement a command prompt parser. And it also allows other file formats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bulk of this feature is in the LOOP() and not in the constrained to the library. So one can cut and paste it into a sketch using the Adafruit library in place of the SFEMP3 or any sketch with an SdCard. That said it would actually be easier to replace the play file calls and include in the FilePlayer.ino example. Or just use it straight up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SFEmp3 library is bit overwhelming because it supports so many features of the VS1053. And uses a different SdCard library, which is more upto date than the IDE's SD&quot;. While the Adafruit library is a very nice re-write and cleans much hte confusing #define's making it much easier code to read, it is not as feature rich. But most feature beyond play and stop are not really needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-04-14T23:50:59.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10083" PostTypeId="2" ParentId="10065" CreationDate="2015-04-15T03:06:48.250" Score="2" Body="&lt;p&gt;A very good book: Beginning C for Arduino:Learn C Programming for the Arduino, by Ph.D. , Jack Purdum&lt;/p&gt;&#xA;" OwnerUserId="4880" LastActivityDate="2015-04-15T03:06:48.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10086" PostTypeId="2" ParentId="10032" CreationDate="2015-04-15T07:03:32.613" Score="1" Body="&lt;p&gt;Not really the answer to your question, but an alternative solution, which has proven to work in my case.&#xA;We were working on a line-following robot with an ATMega 328P (Same as arduino, but withouth shields) and thus we wired an shield directly. For the shield we used, we only needed 4 inputs (pwm left, pwm right, direction left, direction right). Try to find out what your shield is using, on which pin, and you can drive the shield directly withouth stacking them (as they then would use the same pin).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My alternative solution would be to use 1 driver. And wire the motors parrallel.&#xA;If you choose to use 1 shield, you can stack it. But for other shields you have to check which pins to use. There is no drawback on using one shield, the only thing is that the motor driver will draw more current, but they're basically designed for this.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/o53ic.png&quot; alt=&quot;motor driver schematic&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-15T07:03:32.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10088" PostTypeId="1" CreationDate="2015-04-15T07:13:49.997" Score="45" ViewCount="157421" Body="&lt;p&gt;What is the difference between Serial.write and Serial.print? And when are they used?&lt;br&gt;&#xA;Both have been used to print on serial monitor, what are their actual differences?&lt;/p&gt;&#xA;" OwnerUserId="8484" LastEditorUserId="6834" LastEditDate="2015-04-22T17:41:49.643" LastActivityDate="2021-08-25T08:18:58.460" Title="What is the difference between Serial.write and Serial.print? And when are they used?" Tags="|serial|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10089" PostTypeId="2" ParentId="10088" CreationDate="2015-04-15T08:08:13.667" Score="24" Body="&lt;p&gt;From the Arduino site for &lt;a href=&quot;http://arduino.cc/en/Serial/Write&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial.write&lt;/a&gt; and &lt;a href=&quot;http://arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow noreferrer&quot;&gt;Serial.print&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Serial.write()&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Writes binary data to the serial port.&#xA;This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Serial.print()&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Prints data to the serial port as human-readable ASCII text.&#xA;This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2021-08-25T08:18:58.460" LastActivityDate="2021-08-25T08:18:58.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10090" PostTypeId="1" CreationDate="2015-04-15T09:25:50.387" Score="2" ViewCount="581" Body="&lt;p&gt;2days back I opened my cousin brothers laptop battery as it was a spare one left unused over a year.&#xA;I disintegrated it and found 6x 18650 batteries when I checked them with voltmeter individually I found that 2 were dead I.e.0V and 2 read 2.15 V and the last two read 1.5V. I thought of making a power bank using them individually. The battery are ideal for a power bank because they have 2200ah capacity. I need a circuit to charge it. I thought of chraging it with arduino. But how? &#xA;To get the datasheet just search &quot;lr1865ah&quot; in google and click the one and only pdf link that is the cell's datasheet. I need the charing circuit using arduino.&lt;/p&gt;&#xA;" OwnerUserId="8409" LastActivityDate="2017-08-29T00:21:16.763" Title="Charging Li ion cell using arduino" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10091" PostTypeId="1" AcceptedAnswerId="10093" CreationDate="2015-04-15T10:49:26.817" Score="0" ViewCount="231" Body="&lt;pre&gt;&lt;code&gt;#include&amp;lt;PinChangeInt.h&amp;gt;&#xA;#define SensorPin 2&#xA;&#xA;int ledPin = 10;&#xA;int BuzzerPin = 12;&#xA;volatile byte blip = 0;&#xA;&#xA;void blipcount(){&#xA;  blip++;&#xA;};&#xA;&#xA;void setup() {&#xA;   // put your setup code here, to run once:&#xA;   pinMode(SensorPin,INPUT);&#xA;   pinMode(ledPin,OUTPUT);&#xA;   pinMode(BuzzerPin,OUTPUT);&#xA;   PCintPort::attachInterrupt(SensorPin,blipCount,FALLING);&#xA;   Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;   // put your main code here, to run repeatedly:&#xA;   if(digitalRead(SensorPin)==HIGH){&#xA;      digitalWrite(ledPin,HIGH);&#xA;      digitalWrite(BuzzerPin,HIGH);&#xA;      Serial.print(&quot;blipcoun:\t&quot;);&#xA;      Serial.println(blip,DEC);&#xA;   }&#xA;&#xA;   if(digitalRead(SensorPin)==LOW){&#xA;      digitalWrite(ledPin,LOW);&#xA;      digitalWrite(BuzzerPin,LOW);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using arduino uno for a project.I need to record when my sensor gives a high value but i need it to read only falls in pulses.The program is giving  error as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.3 (Windows 8.1), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Sense.ino: In function 'void setup()':&#xA;&#xA;Sense.ino:14:38: error: 'blipCount' was not declared in this scope&#xA;&#xA;Error compiling&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;please tell me what is the problem with the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library link is &#xA;&lt;a href=&quot;https://code.google.com/p/arduino-pinchangeint/downloads/list&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-pinchangeint/downloads/list&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tested the code on both 1.72 and 2.19&lt;/p&gt;&#xA;" OwnerUserId="8485" LastEditorUserId="6452" LastEditDate="2015-04-15T23:03:04.720" LastActivityDate="2015-04-15T23:03:04.720" Title="Scope error in arduino PinChangeInt library" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10092" PostTypeId="1" AcceptedAnswerId="10131" CreationDate="2015-04-15T11:03:37.110" Score="0" ViewCount="185" Body="&lt;p&gt;I'm using a simple IR receiver connected to the Arduino through A0 analog pin. The problem is that I want to stabilize the output of IR receiver when it's not receiving an IR signal from a specific IR source, or at least minimizing the disruption to a specific range that I can handle, no matter where its position, But in my case moving the IR receiver a few inches in any direction will results in different voltage output. the difference between values on disruption is very random to handle.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to isolate IR receiver, may be a specific material or a specific color?&lt;/p&gt;&#xA;" OwnerUserId="7941" LastActivityDate="2015-04-21T22:02:51.527" Title="Isolating IR receiver from disruption?" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10093" PostTypeId="2" ParentId="10091" CreationDate="2015-04-15T14:53:57.263" Score="1" Body="&lt;p&gt;You have a typo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PCintPort::attachInterrupt(SensorPin,blipCount,FALLING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PCintPort::attachInterrupt(SensorPin,blipcount,FALLING);&#xA;                                         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the lower-case &quot;c&quot;.&lt;/p&gt;&#xA;" OwnerUserId="5063" LastActivityDate="2015-04-15T14:53:57.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10094" PostTypeId="2" ParentId="9082" CreationDate="2015-04-15T16:14:02.777" Score="1" Body="&lt;p&gt;These Obstacle sensors don't always work as expected.I bought 3 of them, but only 2 worked properly.The other only worked to a distance of about 6-7cm.&lt;br&gt;&#xA;By the way, the code seems to be fine, but there is no way to tell for sure without complete code.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-15T16:14:02.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10095" PostTypeId="1" AcceptedAnswerId="10108" CreationDate="2015-04-15T16:21:24.717" Score="0" ViewCount="224" Body="&lt;p&gt;how to send input values from host computer to arduino,such that speficing the number of rotations for a stepper motor etc&lt;/p&gt;&#xA;" OwnerUserId="8436" LastEditorUserId="8436" LastEditDate="2015-04-15T18:26:04.813" LastActivityDate="2015-04-16T13:18:50.547" Title="how to send input values from host computer to arduino" Tags="|arduino-mega|motor|firmware|" AnswerCount="1" CommentCount="1" ClosedDate="2015-04-17T03:45:21.820" ContentLicense="CC BY-SA 3.0" />
  <row Id="10096" PostTypeId="2" ParentId="8273" CreationDate="2015-04-15T16:57:33.413" Score="1" Body="&lt;p&gt;1) Try outside or near the window. &#xA;because the signal may not reach inside a house.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)Check the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Print the number of satellites connection to know the device is connectied by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(gps.satellites.value());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good luck!!!&lt;/p&gt;&#xA;" OwnerUserId="8489" LastEditorUserId="55244" LastEditDate="2019-10-14T18:02:59.857" LastActivityDate="2019-10-14T18:02:59.857" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10097" PostTypeId="2" ParentId="9994" CreationDate="2015-04-15T17:21:47.177" Score="0" Body="&lt;p&gt;The Solution was actually much simpler. Apparently the Ground on the voltage I/O ports wasn't the right place to connect the ground terminal of the sensor. rather The Ground of the Digital I/O should be connected. Mistake retrieved by trail and error!! Its working just fine now. &lt;/p&gt;&#xA;" OwnerUserId="7170" LastActivityDate="2015-04-15T17:21:47.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10098" PostTypeId="1" CreationDate="2015-04-15T17:20:33.497" Score="0" ViewCount="1092" Body="&lt;p&gt;I've been struggling for a long time trying to get the MM5451 chip to light up all 35 leds sequentially without any luck.  I've had intermittent help from the arduino forum, someone on youtube, and even found source code on here.  But all I've been able to accomplish is either to get all the lights lit up at once, or every other led lit up at once, or having two sets of 8 leds lighting up sequentially together.  I can't figure out how to get all of them lit on and off sequentially.  I'm sure it has to do with shifting bits but can't figure out how to do this.  Here's two sets of code that either light two sets of 8 bits together sequentially, and another program that lights every other led all at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sequential lighting of two sets of 8 bits&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CLK 2 // to MM5451 pin 21&#xA;#define dataBit  3 // to MM5451 pin 22&#xA;&#xA;&#xA; byte singleled[]=  {1,2,4,8,16,32,64,128};&#xA;//   0b00000001, 0b00000010, 0b00000100,&#xA; //  0b00001000, 0b00010000, 0b00100000,&#xA; //  0b01000000, 0b10000000, 0b11111111 };&#xA;&#xA;  byte singleled2[]=  {1,2,4,8,16,32,64,128};&#xA; //  0b00000001, 0b00000010, 0b00000100,&#xA; //  0b00001000, 0b00010000, 0b00100000,&#xA; //  0b01000000, 0b10000000, 0b11111111 };&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(CLK, OUTPUT);&#xA;  pinMode(dataBit, OUTPUT);&#xA;  digitalWrite(CLK, 0);&#xA;  digitalWrite(dataBit, 0); &#xA;  Serial.begin(1200);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;&#xA;  for (int i=0; i&amp;lt;8; i++)   {&#xA;        // start bit&#xA;    digitalWrite(dataBit, 1);&#xA;    pulseCLK();&#xA;    // the &quot;+ 0x80&quot; turns on DP&#xA;    ssrWriteLSB(singleled2 [i]); // MOD myCount = 0-9  &#xA;    ssrWriteMSB (singleled [i]); // eight LEDs binary count 0-255&#xA;      delay(500);&#xA;   // ssrWriteMSB(myCount);&#xA;    //Serial.println(myCount);&#xA;    delay(500);&#xA;   // Serial.println(myCount);&#xA;    zeroWrite(29); // pad remaining bits with 0s&#xA;    delay(500);&#xA;  }&#xA;&#xA;&#xA;} // end loop&#xA;&#xA;&#xA;void pulseCLK()   {&#xA;  digitalWrite(CLK, 1);&#xA;  digitalWrite(CLK, 0);&#xA;}&#xA;&#xA;&#xA;// LSB out first!&#xA;void ssrWriteLSB(byte value)   {&#xA;  Serial.println(value);&#xA;  for(int x =0; x &amp;lt; 8; x++)   {&#xA;    byte temp = value &amp;amp; 0x01;&#xA;    if (temp == 0x01)   digitalWrite(dataBit, 1); // data bit HIGH&#xA;    else digitalWrite(dataBit, 0); // data bit LOW&#xA;    pulseCLK();&#xA;   value = value &amp;gt;&amp;gt; 0x01; // shift right&#xA;  }&#xA;}&#xA;&#xA;// MSB out first!&#xA;void ssrWriteMSB(byte value)   {&#xA; Serial.println(value);&#xA;  for(int x =0; x &amp;lt; 8; x++)   {&#xA;    byte temp = value &amp;amp; 0x80;&#xA;    if (temp == 0x80)   digitalWrite(dataBit, 1); // data bit HIGH&#xA;    else digitalWrite(dataBit, 0); // data bit LOW&#xA;    pulseCLK();&#xA;    value = value &amp;lt;&amp;lt; 0x01; // shift left&#xA;  }&#xA;}&#xA;&#xA;void  zeroWrite(byte num1)   {&#xA;  digitalWrite(dataBit, 0); // data bit LOW&#xA;  for(int x = 0; x &amp;lt; num1; x++) pulseCLK();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turns on every other light all at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define dataBit 3&#xA;#define clk 2&#xA;&#xA;&#xA;void setup()  {&#xA;  Serial.begin(1200);&#xA;  pinMode(dataBit, OUTPUT);&#xA;  pinMode(clk, OUTPUT);&#xA;  digitalWrite(dataBit, 0);&#xA;  digitalWrite(clk, 0);&#xA;}&#xA;&#xA; void loop() {&#xA;     //digitalWrite(dataBit,1);     &#xA;     for(int index=0; index &amp;lt; 36; index++)  {&#xA;          digitalWrite(dataBit,1);&#xA;          digitalWrite(clk,1);&#xA;          digitalWrite(clk,0); &#xA;          digitalWrite(dataBit,0);&#xA;          digitalWrite(clk,1);&#xA;          digitalWrite(clk,0);&#xA;      }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bryan&lt;/p&gt;&#xA;" OwnerDisplayName="Bryan Charles Greifinger" LastEditorUserId="2881" LastEditDate="2015-04-15T17:45:45.697" LastActivityDate="2015-04-15T19:56:01.490" Title="Turning all 35 leds on sequentially with MM5451" Tags="|shift-register|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10099" PostTypeId="2" ParentId="10098" CreationDate="2015-04-15T18:08:07.737" Score="1" Body="&lt;p&gt;I think you need something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CLK 2 // to MM5451 pin 21&#xA;#define DATA  3 // to MM5451 pin 22&#xA;&#xA;void setup() &#xA;{&#xA;    pinMode(CLK, OUTPUT);&#xA;    pinMode(DATA, OUTPUT);&#xA;    digitalWrite(CLK, 0);&#xA;    digitalWrite(DATA, 0); &#xA;    Serial.begin(1200);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() &#xA;{&#xA;    for( byte led=0; led&amp;lt;35; led++ )&#xA;    {&#xA;&#xA;        lightLed(led);&#xA;&#xA;&#xA;        delay(1000);    &#xA;    }&#xA;}&#xA;&#xA;void lightLed(byte index)&#xA;{&#xA;    //always send a one first&#xA;    sendOne();&#xA;    // turn off all leds preceding index&#xA;    for( byte i=0; i&amp;lt;index; i++ )&#xA;        sendZero();&#xA;    // one led on&#xA;    sendOne();&#xA;    // pad with leds off&#xA;    for( byte i=index+1; i&amp;lt;35; i++ )&#xA;        sendZero();&#xA;}&#xA;&#xA;void sendOne()&#xA;{&#xA;    digitalWrite(DATA, HIGH);&#xA;    digitalWrite(CLK, HIGH);&#xA;    digitalWrite(CLK, LOW);&#xA;}&#xA;void sendZero()&#xA;{&#xA;    digitalWrite(DATA, LOW);&#xA;    digitalWrite(CLK, HIGH);&#xA;    digitalWrite(CLK, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-15T18:08:07.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10100" PostTypeId="1" CreationDate="2015-04-15T18:44:35.823" Score="2" ViewCount="171" Body="&lt;p&gt;I'm building a Model rocket, and i will use xbee series 1 pro, so i think RP-SMA antenna would be the best to use because i will put the xbee into the rocket. So does anyone know what is the range of the xbee with this antenna? &#xA;Can it reach 1000 feet?&lt;/p&gt;&#xA;" OwnerUserId="8492" LastActivityDate="2015-04-15T18:44:35.823" Title="What is the actual range of Xbee RP-SMA antenna?" Tags="|xbee|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10101" PostTypeId="1" AcceptedAnswerId="10102" CreationDate="2015-04-15T19:36:18.900" Score="1" ViewCount="2295" Body="&lt;p&gt;let's say that I've connected an arduino uno to a pc, or to a mobile phone via usb .. how can I detect the device type and the running operation system if it's possible?&lt;/p&gt;&#xA;" OwnerUserId="8545" OwnerDisplayName="donfoneseo" LastActivityDate="2016-12-04T20:31:09.903" Title="Is it possible to detect host usb device connected to arduino? and how?" Tags="|usb|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10102" PostTypeId="2" ParentId="10101" CreationDate="2015-04-15T19:42:37.353" Score="3" Body="&lt;p&gt;You can't, using stock firmware. And with custom firmware it's still very difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB communication chip on the Uno has no out-of-band means of telling the main MCU that it is connected to a host. You might be able to rewrite the communication firmware on the R3 to tell the main MCU over serial that it is connected, but the firmware on the main MCU will need to be written in such a manner that it will anticipate this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want this to work then you should consider using one that has a native USB connection, such as the Leonardo. You will then be able to query the USB facility directly to know whether or not you are connected to a host.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-04-15T19:42:37.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10103" PostTypeId="2" ParentId="10101" CreationDate="2015-04-15T19:43:00.327" Score="2" Body="&lt;p&gt;No. The arduino sees usb through a USB-&gt; UART converter (typically FTDI). UART doesn't allow you to do anything other than listen on the RX line and throw bits at the TX line.&lt;/p&gt;&#xA;" OwnerUserId="32307" OwnerDisplayName="kolosy" LastActivityDate="2015-04-15T19:43:00.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10105" PostTypeId="1" CreationDate="2015-04-15T20:38:01.087" Score="5" ViewCount="1069" Body="&lt;p&gt;I'm porting a project from a teensy microcontroller to the arduino. Essentially the project uses a microcontroller to simulate touchscreen input for the Nintendo 3DS console. I am doing this by unplugging the touchscreen digitizer of my Nintendo 3DS and putting my arduino in its place. See the link below for the original teensy code and schematics that I'm trying to modify. (The oscilloscope picture below is also credit of author of the teensy code)&#xA;&lt;a href=&quot;https://github.com/dekuNukem/3xtDS&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dekuNukem/3xtDS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is a fairly generic touchscreen I'm trying to simulate input for, so I'm not sure what's going wrong.&lt;/strong&gt; I am not sure if my schematic has a problem, or if the Arduino's PWM frequency limitation is the problem. The teensy code was setup to output at 90khz, while the highest I can possibly set my arduino is around 31khz. I believe this should be good &lt;em&gt;enough&lt;/em&gt; because I believe the Nintendo 3DS only samples at around 100 microsecond intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I have done:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm connecting two of my arduino pins to the X+ and Y+ pins where the Nintendo touchscreen digitizer used to be.&lt;/li&gt;&#xA;&lt;li&gt;I have used a voltage divider to change the arduino's output voltage from 5v to 1.8v, which is the VCC of the nintendo device.&lt;/li&gt;&#xA;&lt;li&gt;I have used a 0.22uf capacitor and 1k resistor as a DAC to change the PWM output to analog.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I tried troubleshooting by:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;using 68 &amp;amp; 120 ohm resistors in my voltage divider for smoother analog PWM response, instead of 68k &amp;amp; 120k resistors&lt;/li&gt;&#xA;&lt;li&gt;adding a 1N914 diode between the capacitor and ground (since I am using ceramic capacitors, which are bidirectional)&lt;/li&gt;&#xA;&lt;li&gt;eliminating the &lt;code&gt;while(analogRead(senseY) &amp;lt; 46)&lt;/code&gt; line in my code and instead using a static delay of 100 microseconds&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Touchscreen press I want to simulate (Yellow is Y+, blue is X+):&lt;/strong&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/mwlpq.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Schematic:&lt;/strong&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/YSW6R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Teensy code ported to arduino:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// I've included the setPwmFrequency() function listed on the arduino site, &#xA;// but I'm omitting it here for clarity reasons.&#xA;&#xA;// The main change between the Teensy and arduino is that the teensy uses &#xA;// software to lower the PWM voltage from teensy's native 3.3v down to the &#xA;// nintendo's 1.8v, while I have instead used a voltage divider on the PWM &#xA;// output of the arduino.&#xA;&#xA;// X+ pin of touchscreen.&#xA;int touchX = 9;&#xA;&#xA;// Y+ pin of touchscreen.&#xA;int touchY = 10;&#xA;&#xA;// Pin to monitor arduino's output of Y+&#xA;int senseY = 11;&#xA;&#xA;void setup() {&#xA;  // -Change pins 9 and 10 to have 31,250 hz PWM frequency. This is the &#xA;  // highest I can set it. Teensy originally set their frequency to 90khz.&#xA;  // My difference in frequencies MIGHT be the cause of my problems.&#xA;  // I picked pins 9 and 10 because they won't affect timing for millis() &#xA;  // and delay. &#xA;  setPwmFrequency(9, 1);&#xA;  setPwmFrequency(10, 1);&#xA;&#xA;  // Original teensy code set analog write resolution to 9bits.&#xA;  // This was necessary because the nintendo touchscreen is 320x240, which is greater than 255 for an 8bit resolution.&#xA;  // However, I don't mind this minor accuracy loss! arduino's analog resolution is accurate enough for me.&#xA;  pinMode(touchX, OUTPUT);&#xA;  pinMode(touchY, OUTPUT);&#xA;  analogWrite(touchX, 0);&#xA;  disable_touch_screen();&#xA;}&#xA;&#xA;void touch_screen_click(unsigned int x, unsigned int y, unsigned int duration_ms) {&#xA;  // Calculate PWM value to write  based on the xy touchscreen coordinates we want.&#xA;  unsigned int x_potential = ((double)x / 320) * 255;&#xA;  unsigned int y_potential = ((double)y / 240) * 255;&#xA;&#xA;  // Start outputting the x value.&#xA;  analogWrite(touchX, x_potential);&#xA;&#xA;  // Pull Y+ to ground.&#xA;  enable_touch_screen();&#xA;&#xA;  unsigned int start = millis();&#xA;&#xA;  // Keep touch screen pressed for tap duration.&#xA;  while(millis() - start &amp;lt; duration_ms) {&#xA;    // wait until Y+ pin is in output mode&#xA;    // original teensy code checked for 512, which was half of the max value 1024.&#xA;    // we're outputting 1.8v with our circuit, but reading analog at 5v&#xA;    // so the value we check for is half of this max value: 1.8/5*255=92&#xA;    // I COULD have used arduino's Aref, but math is faster than soldering&#xA;    while(analogRead(senseY) &amp;lt; 46)&#xA;    delayMicroseconds(490);&#xA;&#xA;    // now Y+ pin is in output mode&#xA;    analogWrite(touchY, y_potential);&#xA;    delayMicroseconds(180);&#xA;&#xA;    // pull Y+ down again to keep interrupt going&#xA;    enable_touch_screen();&#xA;  }&#xA;  disable_touch_screen();&#xA;  analogWrite(touchX, 0);&#xA;  delay(50);&#xA;}&#xA;&#xA;void disable_touch_screen() {&#xA;  analogWrite(touchY, 255);&#xA;}&#xA;&#xA;// pull Y+ pin low to initialize 3DS's touch interrupt&#xA;void enable_touch_screen() {&#xA;  analogWrite(touchY, 0);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;delay(800);&#xA;// tap at 150x150 for 100ms.&#xA;touch_screen_click(150, 150, 100);&#xA;&#xA;delay(800);&#xA;&#xA;// tap at 50x50 for 100ms.&#xA;touch_screen_click(50, 50, 100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8497" LastActivityDate="2015-04-23T06:15:03.820" Title="Simulating touchscreen input using PWM" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="10106" PostTypeId="1" AcceptedAnswerId="10107" CreationDate="2015-04-15T23:03:25.770" Score="2" ViewCount="1123" Body="&lt;p&gt;I have my Arduino Nano connected to the &lt;a href=&quot;http://www.banggood.com/HC-06-Wireless-Bluetooth-Transceiver-RF-Main-Module-Serial-For-Arduino-p-80364.html&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;HC-06&quot;&gt;HC-06&lt;/a&gt; module (with the RX/TX pins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that when I try to upload new code to my Arduino (via the Arduino IDE, through the USB connection) the Arduino IDE doesn't succeed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get this error: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe that it is just trying to upload the code to the HC-06 (instead of the Arduino). Is there a way to overcome this issue?. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I found this entry &lt;a href=&quot;https://stackoverflow.com/questions/27175937/arduino-program-upload-while-btooth-module-connected-avrdude-stk500-getsync&quot;&gt;https://stackoverflow.com/questions/27175937/arduino-program-upload-while-btooth-module-connected-avrdude-stk500-getsync&lt;/a&gt; indicating that it wasn't possible (that I need to unplug the module). I am trying to confirm it. &lt;/p&gt;&#xA;" OwnerUserId="8500" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-16T01:04:12.510" Title="Program arduino via USB while using a Bluetooth module (HC-06)" Tags="|bluetooth|" AnswerCount="1" CommentCount="2" ClosedDate="2015-05-21T23:25:42.110" ContentLicense="CC BY-SA 3.0" />
  <row Id="10107" PostTypeId="2" ParentId="10106" CreationDate="2015-04-16T01:04:12.510" Score="2" Body="&lt;p&gt;The link in question was correct... you do need to unplug it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's serial chip uses pins 0 and 1 to communicate with the ATmega 328 PU chip onboard, thus you have two independent devices connected to the same wires and both the Arduino main chip and the Bluetooth module are trying to communicate at the same time (rendering all data unreadable by the computer).&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-04-16T01:04:12.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10108" PostTypeId="2" ParentId="10095" CreationDate="2015-04-16T02:20:10.733" Score="1" Body="&lt;p&gt;The easiest method is to use the serial communication. Use the sample code at &lt;a href=&quot;http://arduino.cc/en/Tutorial/SwitchCase2&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/SwitchCase2&lt;/a&gt;, upload that to an Arduino, start the serial monitor (Ctrl+Shift+M), make sure the baud rate is the same as set in the code (9600 in this case), then write the commands and send them to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&#xA;Since the serial characters are usually read one by one you need a character that will signal the end of the string. This is usually a newline &lt;code&gt;\n&lt;/code&gt;, but can be any character you choose (and can be sent to Arduino). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample code (&lt;code&gt;processString&lt;/code&gt; would be your function to do something with the string):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buf[64];&#xA;byte cnt = 0;&#xA;void loop() &#xA;{&#xA;    while (Serial.available()&amp;gt;0) {&#xA;        byte c = Serial.read();&#xA;        // Check for terminator character or the size of buffer&#xA;        if (c == '\n' || cnt &amp;gt;= 63) {&#xA;            // Add the terminating 0&#xA;            buf[cnt] = 0;&#xA;            // Process the full string&#xA;            processString(buf);&#xA;            // Prepare to read the next string&#xA;            cnt = 0;&#xA;        } else {&#xA;            // Not terminator - add to string&#xA;            buf[cnt++] = c;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7699" LastEditorUserId="7699" LastEditDate="2015-04-16T13:18:50.547" LastActivityDate="2015-04-16T13:18:50.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10109" PostTypeId="2" ParentId="10088" CreationDate="2015-04-16T03:18:14.550" Score="7" Body="&lt;p&gt;&lt;code&gt;Serial.write&lt;/code&gt; sends bytes to the serial port while &lt;code&gt;Serial.print&lt;/code&gt; sends ASCII characters so people can read easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some devices work using bytes to set configurations, commonly use packets of data and you need to use write function to communicate with them. Eventually they will send bytes through serial interface and then you can interpret by going each byte.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-16T03:18:14.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10110" PostTypeId="2" ParentId="9920" CreationDate="2015-04-16T03:26:14.453" Score="1" Body="&lt;p&gt;If you want to just provide a delay use this function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(ms) -&amp;gt; where the argument is an integer value that represents the time in milliseconds.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, 1s = 1000ms&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanna stop everything and wait 1s, just use like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the atmega controller will stop everything it is doing and wait the amount of time. If you need to count or wait for something while other things are occurring, use timer interrupts. So the counting process is done in background and your main loop continues to do its jobs.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-16T03:26:14.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10111" PostTypeId="2" ParentId="9888" CreationDate="2015-04-16T03:46:29.637" Score="0" Body="&lt;p&gt;You can try reading each character and convert it to hexadecimal representation.&#xA;I suppose you wanna 1 byte each value in hexadecimal representation, so, let's start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the string &quot;0x25&quot;, ignore the 0x and read the '2' and save it into a char variable. Same for '5';&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char highBits = '2' - '0'; // convert to decimal representation&#xA;char lowBits  = '5' - '0'; &#xA;&#xA;byte = (highBits &amp;lt;&amp;lt; 4 | lowBits);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, save it inside you array. Make sure you check if the value is one of the possible letters in hexadecimal and convert it properly (A=10 and so on).&#xA;Just include an if statement if it is a letter and convert it.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-16T03:46:29.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10112" PostTypeId="1" AcceptedAnswerId="13090" CreationDate="2015-04-16T06:41:35.583" Score="2" ViewCount="7234" Body="&lt;p&gt;I'd like illuminate my room solely with several RGB LED strips using Arduino's PWM (together with LED amplifier and few transistors). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the Arduino to control 2 independent chains of LED strips, and I want to make sure, that the LEDs would not blink simultaneously, creating a very strong stroboscopic effect in my room. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to delay three Arduino's PWM pins half a phase relative to the other three?&lt;/p&gt;&#xA;" OwnerUserId="7329" LastActivityDate="2019-03-01T18:59:14.973" Title="How to make sure Arduino's PWM pulses are phase shifted?" Tags="|led|pwm|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="10113" PostTypeId="1" CreationDate="2015-04-16T08:09:47.760" Score="2" ViewCount="580" Body="&lt;p&gt;I want to use Arduino Yun as a client, that connects to my nodejs server, receives a message from nodejs and then change led pin 13 on/off according to the message send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this example of a nodejs server:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  var express = require('express');&#xA;var http = require('http');&#xA;var url = require('url');                       &#xA;&#xA;var app = express();&#xA;&#xA;//app.set('port', 8080);&#xA;&#xA;var server = http.createServer(function(request, response){             &#xA;    console.log('Connection');                                                          var path = url.parse(request.url).pathname;                                 &#xA;&#xA;    switch(path){                                               &#xA;        case'/':&#xA;            response.writeHead(200, {'Content-Type': 'text/html'});     &#xA;            response.write('Hello World');                          &#xA;            response.end();&#xA;            break;&#xA;        case '/arduino/digital/13/0':&#xA;            response.writeHead(200, {'Content-Type': 'text/html'});     &#xA;            response.write('Led 13 is off');                        &#xA;            console.log('Led 13 is off');&#xA;            response.end();&#xA;            break;&#xA;        case '/arduino/digital/13/1':&#xA;            response.writeHead(200, {'Content-Type': 'text/html'});&#xA;            response.write('Led 13 is on');&#xA;            console.log('Led 13 is on');&#xA;            response.end();&#xA;            break;&#xA;        default:&#xA;            response.writeHead(404);&#xA;            response.write(&quot;Oops, this doesn't exist - 404&quot;);   &#xA;            response.end();                                                     &#xA;            break;&#xA;    }&#xA;&#xA;});&#xA;&#xA;//server.listen(8080);&#xA;&#xA;var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080&#xA;var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'&#xA;&#xA;server.listen(server_port, server_ip_address, function () {&#xA;  console.log( &quot;Listening on &quot; + server_ip_address + &quot;, server_port &quot; + server_port )&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The server is running on an openshift nodejs server - It's not Localhost!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Arduino sketch I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Possible commands created in this shetch:&#xA; * &quot;http://yunobomber-cuebo.rhcloud.com&quot;                         -&amp;gt; Serial Monitor &quot;Hello World&quot;&#xA; * &quot;http://yunobomber-cuebo.rhcloud.com/arduino/digital/13/1&quot;    -&amp;gt; Serial Monitor &quot;Led 13 is on&quot;  &amp;amp;  digitalWrite(13, HIGH)&#xA; * &quot;http://yunobomber-cuebo.rhcloud.com//arduino/digital/13/0&quot;   -&amp;gt; Serial Monitor &quot;Led 13 is off&quot; &amp;amp;  digitalWrite(13, LOW)&#xA; */&#xA;&#xA;#include &amp;lt;Bridge.h&amp;gt;   &#xA;#include &amp;lt;HttpClient.h&amp;gt;&#xA;&#xA;HttpClient client;&#xA;&#xA;void setup() {&#xA;  Bridge.begin();                                                          // Bridge startup&#xA;&#xA;  Serial.begin(9600);&#xA;  while (!Serial);                                                         // wait for a serial connection&#xA;}&#xA;&#xA;void loop() {&#xA;  // Initialize the client library&#xA;  HttpClient client;&#xA;&#xA;  // Make a HTTP request:&#xA;  client.get(&quot;http://yunobomber-cuebo.rhcloud.com&quot;);       // Insert alternative url for other commands - See explanation at top&#xA;&#xA;  while (client.available()) {                             // Read message from server&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  Serial.flush();&#xA;  delay(5000);&#xA;}&#xA;&#xA;void process(HttpClient client) {&#xA;  String command = client.readStringUntil('/');&#xA;&#xA;  if (command == &quot;digital&quot;) {&#xA;    digitalCommand(client);&#xA;  }&#xA;}&#xA;&#xA;void digitalCommand(HttpClient client) {&#xA;  int pin, value;&#xA;&#xA;  // Read pin number&#xA;  pin = client.parseInt();&#xA;&#xA;  // If the next character is a '/' it means we have an URL&#xA;  // with a value like: &quot;/digital/13/1&quot;&#xA;  if (client.read() == '/') {&#xA;    value = client.parseInt();&#xA;    digitalWrite(pin, value);&#xA;  }&#xA;  else {&#xA;    Serial.println('Error: Could not read url!');&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serve works as it should, which can be seen here:&#xA;&lt;a href=&quot;http://yunobomber-cuebo.rhcloud.com&quot; rel=&quot;nofollow&quot;&gt;http://yunobomber-cuebo.rhcloud.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also get the message send from the server, when I read serial monitor, so the connection to the server from the Yun is also working. I can also console.log on the server side and see that a connection is established from the Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem seems to be with the readStringUntil(); method, what I want to do is actually readStringAfter(arduino/), but such a method doesn't exist or at least I'm not sure how to make one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I wonder if my approach is wrong, since I use REST calls to control the Yun, maybe I should solve it diffenrently, since I've already established a connection to and receiving input from the nodejs server?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that someone can help my understand and solve this issue?&lt;/p&gt;&#xA;" OwnerUserId="4606" LastEditorUserId="4606" LastEditDate="2015-04-16T08:21:58.817" LastActivityDate="2015-04-16T08:21:58.817" Title="How to use console.log message from nodejs server, to control led pin 13?" Tags="|wifi|arduino-yun|web-server|remote-control|node.js|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10115" PostTypeId="1" AcceptedAnswerId="10360" CreationDate="2015-04-16T11:24:44.297" Score="0" ViewCount="190" Body="&lt;p&gt;I don't want the same string to be printed again and again. I'm getting the data into an Excel sheet.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte readValue1=0;&#xA;byte readValue2=0;&#xA;int add=0;&#xA;int row=0;&#xA;int Zigbee1=0,Zigbee2=0,Zigbee3=0;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;        Serial.println(&quot;CLEARDATA&quot;);&#xA;        Serial.println(&quot;LABEL,Time,Zigbee,a1,a2,a3,a4,a5,a6,a7&quot;);&#xA;        row++;&#xA;}&#xA;&#xA;void loop(){&#xA;  String a1,a2,a3;&#xA;  String c1,c2,c3;&#xA;  int b;&#xA;&#xA;  if (Serial.available()&amp;gt;21){&#xA;        if(Serial.read() == 0x7E) {  &#xA;            for(int i=0; i&amp;lt;10; i++){&#xA;                byte discard = Serial.read();&#xA;            }&#xA;                        add = Serial.read();     &#xA;                       if(add == 33)&#xA;                        {                 &#xA;                        a1 = func1();                    &#xA;                        if(a1==c1){&#xA;                          b=0;&#xA;                        } &#xA;                        else                   &#xA;                        {&#xA;                          b = a1.length(); &#xA;                        } &#xA;                        if(b != 0)&#xA;                       {&#xA;                        Zigbee=1;&#xA;                        Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                        Serial.print(&quot;,&quot;); Serial.println(a1);&#xA;                        row++;              &#xA;                        }&#xA;                        }&#xA;                      else if(add == 48)&#xA;                        { &#xA;                        a2 = func1();&#xA;                        b = a2.length();&#xA;                        if(b != 0) &#xA;                      { &#xA;                        Zigbee=2;&#xA;                        if(a2!=c2){&#xA;                       Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                       Serial.print(&quot;,&quot;); Serial.println(a2);&#xA;                        }&#xA;                        c2=a2;&#xA;                       row++;                                          &#xA;                        }&#xA;                        }&#xA;&#xA;                       else if(add == 69)&#xA;                        {&#xA;                          a3 = func1();&#xA;                          b = a3.length();&#xA;                          if(b != 0)&#xA;                         {&#xA;                          Zigbee=3;&#xA;                          Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                          Serial.print(&quot;,&quot;); Serial.println(a3);&#xA;                          row++;                  &#xA;                    }&#xA;                        }&#xA;} &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8511" LastEditorDisplayName="user6430" LastEditDate="2016-07-24T22:30:12.623" LastActivityDate="2016-07-24T22:30:12.623" Title="How to discard same string received at Arduino" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10116" PostTypeId="2" ParentId="10115" CreationDate="2015-04-16T12:32:05.877" Score="0" Body="&lt;p&gt;Only print the string when he has changed?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String previousString = &quot;&quot;;&#xA;String newString = &quot;&quot;;&#xA;&#xA;if(newString != previousString){&#xA;   println(newString);&#xA;   previousString = newString;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if it's applicable in your situation, just the first thing that came to my mind. You (kinda) should make a function of it, so that you don't have to copy/paste it all the time and it'll look way better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fuction could be made like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String previousString = &quot;&quot;; //Put this above your setup code (global variables)&#xA;&#xA;void NoSpamString(String input){ //Put this block before the setup&#xA;   if(input != previousString){&#xA;      println(input);&#xA;      previousString = input;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use: &lt;code&gt;NoSpamString(&quot;text&quot;);&lt;/code&gt; to print a line withouth spamming it.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-04-22T13:32:39.137" LastActivityDate="2015-04-22T13:32:39.137" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10117" PostTypeId="1" AcceptedAnswerId="10122" CreationDate="2015-04-16T13:40:57.677" Score="2" ViewCount="11863" Body="&lt;p&gt;I'm trying to start with the SainSmart 4x20 serial LCD, and copied the library to the Arduino library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QLGNM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;LiquidCrystal_I2C.h&lt;/code&gt; is included. But when I try to compile an example sketch it says &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino: 1.7.0 (Windows 7), Board: &quot;Arduino Uno&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;HelloWorld_i2c.pde:2:31: fatal error: LiquidCrystal_I2C.h: No such file or directory&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;compilation terminated.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Error compiling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to fix this?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2017-11-08T04:17:50.360" Title="Arduino IDE doesn't find header file" Tags="|library|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10118" PostTypeId="1" CreationDate="2015-04-16T13:50:14.653" Score="2" ViewCount="143" Body="&lt;p&gt;I am trying to make &lt;a href=&quot;http://www.righto.com/2010/11/improved-arduino-tv-b-gone.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ken Sherriff's version&lt;/a&gt; of the TV-Be-Gone with the Arduino using the updated v1.2 software.  He uses this setup:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;His Setup&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8dqTQ.png&quot; alt=&quot;Setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;My Setup&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I used the Arduino Nano with same MCU (Atmel ATmega328) as Uno but changed a few other things also. For power I supplied 9v to the vin pin but supplied the transistor with 5v from the 5v pin. I used this &lt;a href=&quot;http://www.instructables.com/id/Arduino-TV-B-Gone/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instructable&lt;/a&gt; by the same person.  The only major change was I used a PN2222A transistor instead of 2N4401. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vPldJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My problem is that even though when I push the button the infrared light blinks for a while sending the different codes my receiver won't pick it up. I checked my receiver with other remotes and it works and I tried at close and far range. My receiver just blinks if it senses any infrared command regardless of what type of remote but it doesn't work with my Arduino TV-Be-Gone. I haven't tried it with a real TV yet but would like for it to work before I try it on a real one.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="653" LastEditDate="2015-04-16T16:31:23.447" LastActivityDate="2015-04-16T16:31:23.447" Title="Ken Sherriff Arduino Version Tv-Be-Gone" Tags="|arduino-uno|remote-control|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10119" PostTypeId="2" ParentId="10117" CreationDate="2015-04-16T14:01:02.073" Score="0" Body="&lt;p&gt;There is not enough info to give a specific answer so I will give some troubleshooting tips:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First make sure at the top of your code you have: #include &amp;lt;LiquidCrystal_I2C.h&amp;gt; - with angle brackets&lt;/li&gt;&#xA;&lt;li&gt;You may also need the Wire header file: #include &amp;lt;Wire.h&amp;gt;  - with angle brackets&lt;/li&gt;&#xA;&lt;li&gt;Make sure you Include Serial&lt;/li&gt;&#xA;&lt;li&gt;Make sure there are no extra folders in the library for example there should be a folder called liquidcrystal inside the liquidcrystal folder&lt;/li&gt;&#xA;&lt;li&gt;If all fails copy the code from the header file make a new file in the IDE paste it in there and call it LiquidCrystal_I2C.h&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope one of those solves your problem.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="6834" LastEditDate="2015-04-16T14:20:55.633" LastActivityDate="2015-04-16T14:20:55.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10122" PostTypeId="2" ParentId="10117" CreationDate="2015-04-16T15:07:21.110" Score="4" Body="&lt;p&gt;I copied the SainSmart library to the IDE's library folder, not noticing that there was already a folder named &quot;LiquidCrystal&quot;. Apparently the files added to the existing folder are being ignored.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Renaming the SainSmart library before adding it solves the problem.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-16T15:07:21.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10123" PostTypeId="1" AcceptedAnswerId="10124" CreationDate="2015-04-16T16:22:35.557" Score="0" ViewCount="233" Body="&lt;p&gt;After execute the program of below, the 13 pin output is 4.8v. Why it's not 3.3v?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  digitalWrite(13, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8304" LastEditorUserId="8304" LastEditDate="2015-04-16T16:30:44.827" LastActivityDate="2015-04-16T16:30:44.827" Title="output of yun is not 3.3" Tags="|arduino-yun|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10124" PostTypeId="2" ParentId="10123" CreationDate="2015-04-16T16:24:25.923" Score="1" Body="&lt;p&gt;The Atheros chip on the Yún is run off 3.3V, but the AVR chip, which is what is connected to the external pins, runs off 5V. What you are seeing is normal (a bit low though, but within spec).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-16T16:24:25.923" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10125" PostTypeId="1" CreationDate="2015-04-16T16:31:47.827" Score="6" ViewCount="8645" Body="&lt;p&gt;I'm testing out an accelerometer and I want to know if there's a way to make it so that the serial monitor will update the values without printing a new line. Ideally the serial monitor would say something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Accelerometer X: $xval&#xA;Accelerometer y: $yval&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then instead of printing two new lines each time, it just updates the values. Is there anyway to do that in Arduino? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="8519" LastActivityDate="2015-11-26T01:00:34.080" Title="How do I update the serial monitor without printing a new line each time?" Tags="|arduino-uno|serial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10126" PostTypeId="2" ParentId="10125" CreationDate="2015-04-16T16:35:55.233" Score="3" Body="&lt;p&gt;No. The serial monitor does not support terminal handling. Either use a serial communications program that does and use those features, or write a custom client that will only update those values in its interface.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-16T16:35:55.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10127" PostTypeId="1" CreationDate="2015-04-16T17:10:50.710" Score="2" ViewCount="74" Body="&lt;p&gt;in &quot;Disabling the Bridge Script&quot; of &lt;a href=&quot;http://cylonjs.com/documentation/platforms/yun/&quot; rel=&quot;nofollow&quot;&gt;http://cylonjs.com/documentation/platforms/yun/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Edit the /etc/inittab file to comment out the ttyATH0 line (put a # before it)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;::sysinit:/etc/init.d/rcS S boot&#xA;::shutdown:/etc/init.d/rcS K shutdown&#xA;#ttyATH0::askfirst:/bin/ash --login&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I want to turn it on or off manually. Then I can program through WiFi if I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to do that?&lt;/p&gt;&#xA;" OwnerUserId="8304" LastActivityDate="2015-04-16T17:10:50.710" Title="yun manage bridge manually" Tags="|arduino-yun|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10128" PostTypeId="1" CreationDate="2015-04-16T17:31:26.943" Score="3" ViewCount="308" Body="&lt;p&gt;Can I turn Yun to ad hoc mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TL5Yi.png&quot; alt=&quot;ad hoc mode&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the image above I can see the Ad-Hoc model in that drop down list. But only WEP for its security.&lt;/p&gt;&#xA;" OwnerUserId="8304" LastActivityDate="2015-04-16T17:31:26.943" Title="how to turn yun to ad hoc mode?" Tags="|arduino-yun|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10129" PostTypeId="1" AcceptedAnswerId="10265" CreationDate="2015-04-16T18:10:15.653" Score="0" ViewCount="994" Body="&lt;p&gt;I just got a Serial LCD and wanted to test it out with a game. I found this &lt;a href=&quot;http://eturnerx.blogspot.com/2012/08/arduino-lcd-hunt-wumpus-conversion.html&quot; rel=&quot;nofollow&quot;&gt;site&lt;/a&gt; with game conversions and wanted to use &lt;a href=&quot;http://eturnerx.com/files/arduino/003_wumpus_hunt_eturnerx_arduino_lcd.html&quot; rel=&quot;nofollow&quot;&gt;this game&lt;/a&gt;.  However since my serial LCD use the LiquidCrystalic2 library the code in its current state won't work. Is there a simple method of converting or porting liquidcrystal to LiquidCrystalic2? Or if someone knows of a simple game in regards to hardware that uses a serial lcd and could direct me to a link that would be great.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="8046" LastEditDate="2015-04-20T18:13:38.227" LastActivityDate="2015-04-23T14:05:05.120" Title="Converting Arduino LCD Programs to Serial I2C LCD code" Tags="|lcd|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10130" PostTypeId="2" ParentId="10125" CreationDate="2015-04-16T18:15:49.803" Score="1" Body="&lt;p&gt;You might want to look into &lt;a href=&quot;https://processing.org/&quot; rel=&quot;nofollow&quot;&gt;processing&lt;/a&gt;. You can use that to view the accelerometers position in 3d and see the values changing if that's what you want. The official Arduino site talks about it &lt;a href=&quot;http://playground.arduino.cc/interfacing/processing&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  Here is a great &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; on it.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="8046" LastEditDate="2015-04-20T18:15:23.090" LastActivityDate="2015-04-20T18:15:23.090" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10131" PostTypeId="2" ParentId="10092" CreationDate="2015-04-16T18:23:25.730" Score="0" Body="&lt;p&gt;I would suggest two things. First You could put electrical tape around the receiver in such a way that it will only pick up signals from a certain direction. Also you could use low and high pass filters to accept input only in the 38khz range(range of most infra red remotes).  Keep in mind that you will need a couple of rounds for it to work effectively.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="8046" LastEditDate="2015-04-21T22:02:51.527" LastActivityDate="2015-04-21T22:02:51.527" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10132" PostTypeId="2" ParentId="9714" CreationDate="2015-04-16T18:27:46.833" Score="1" Body="&lt;p&gt;Use the IRRemote library as mentioned and use the IRecord example.  This will allow you to input a signal and then push a button which will send that signal from the infra-red LED on the arduino.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-16T18:27:46.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10133" PostTypeId="2" ParentId="1550" CreationDate="2015-04-16T18:35:50.037" Score="1" Body="&lt;p&gt;To add to Chris's answer: fiducials appear at three levels. First there are fiducials at the panel level, which contains one or more PCBs, depending on their size. Next there are fiducials for the PCB, acting as a position reference for component placement. Sometimes you can see component fiducials close to some fine pitch components, to make sure they are placed with high precision. You'll sometimes see these latter fiducials on opposite corners of QFP (Quad Flat Package) parts. (The AVR controller on the Arduino Mega 2560 is in QFP.)&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="186" LastEditDate="2016-02-21T08:18:23.720" LastActivityDate="2016-02-21T08:18:23.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10134" PostTypeId="1" CreationDate="2015-04-16T18:46:57.933" Score="1" ViewCount="935" Body="&lt;p&gt;I purchased a half dozen fake Arduinos hoping to build a bunch of projects without paying a fortune. I have all the drivers installed, and the port shows up in the Arduino IDE. The problem is when I try and upload the code I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;can't open device &quot;/dev/cu.wch&quot;: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I played around a little and tried running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ln -s cu.wch\ ch341\ USB\=\&amp;gt;RS232\ 1a1220  cu.wch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running this a new port shows up called &lt;code&gt;cu.wch&lt;/code&gt;, and if I select that it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is the Arduino's port is &lt;code&gt;cu.wch ch341 USB=&amp;gt;RS232 1a1220&lt;/code&gt;, but for some reason the IDE is trying to write to &lt;code&gt;cu.wch&lt;/code&gt;. By linking the folders I can fix this but since it is a hack every time I restart my computer I have to rerun the command. Is there a way I can either rename the Arduino port or permanently link the folder?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I am using OSX 10.10 and Arduino IDE v1.6.3&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user8452" LastEditorUserId="4628" LastEditDate="2017-02-06T05:07:57.013" LastActivityDate="2017-07-07T00:36:23.860" Title="Arduino uploading to the wrong port" Tags="|arduino-ide|uploading|mac-os|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10137" PostTypeId="2" ParentId="8027" CreationDate="2015-04-16T20:43:20.427" Score="1" Body="&lt;p&gt;Hope you get this.  Trimming the aging compensation in the DS3231 is not worth the trouble.  You won't significantly improve the temperature accuracy or aging drift due to the crystal used, etc.&#xA;On the other hand, 10MHz Double Oven Reference Oscillators are available for under $50 on EBAY.  These are good to 2x10-12 short-term, or about 1x10-6 yearly drift.  For timekeeping purposes, you can ignore the short-term drift, could not measure it anyway :).  On the other hand, the aging drift will be large because you do not know how long these have been in service.  The good news is that aging drift is very stable if temperature is kept constant, the reason for the double ovens. So once you determine how far off frequency the OCXO is, you just periodically add a count to your divider during one period to keep it synched to the GPS signal.  For more info write mhuss103athotmaildotcom&lt;/p&gt;&#xA;" OwnerUserId="8523" LastActivityDate="2015-04-16T20:43:20.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10138" PostTypeId="2" ParentId="10134" CreationDate="2015-04-16T21:26:15.313" Score="1" Body="&lt;p&gt;I would guess the problem is the IDE not properly handling device names containing spaces. Consider your symlink a workaround rather than a hack - unless you want to repair the IDE itself.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-16T21:26:15.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10139" PostTypeId="1" AcceptedAnswerId="10140" CreationDate="2015-04-16T21:39:34.477" Score="0" ViewCount="333" Body="&lt;p&gt;I bought a Arduino Wi-Fi Module it does not have any manual or catalog &lt;/p&gt;&#xA;&#xA;&lt;p&gt;my project is to turn on/off a motor wireless &#xA;&lt;img src=&quot;https://i.stack.imgur.com/EvYip.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA; it is working grate for the serial/usb cable but i couldn't make it work for wireless/wifi&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after some walking around i found that my wifi module is making a wifi network called &quot;HL-link_A49D&quot;&#xA;with password from 1-8 and after network scanning i found that the module ip is 192.168.16.254/ username and pass are admin/admin&#xA;here is what i found &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hanz4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my question is how could i connect to the wifi module and send commands to it ?&lt;/p&gt;&#xA;" OwnerUserId="8524" LastActivityDate="2015-04-16T22:31:01.317" Title="Wi-Fi Module communication?" Tags="|arduino-uno|wifi|tcpip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10140" PostTypeId="2" ParentId="10139" CreationDate="2015-04-16T22:31:01.317" Score="1" Body="&lt;p&gt;Good detective work so far!&lt;br&gt;&#xA;In the admin page you found one can see the name of the module: &lt;code&gt;HLK-RM04&lt;/code&gt;. Googling on that I found the &lt;a href=&quot;http://www.hlktech.net/product_detail.php?ProId=39&quot; rel=&quot;nofollow&quot;&gt;manufacturer/seller page&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A PDF with some information can be found &lt;a href=&quot;http://www.hlktech.net/inc/lib/download/download.php?DId=21&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also one link with &lt;a href=&quot;http://rayshobby.net/first-impression-on-hlk-rm04-serial-to-wifi-module/&quot; rel=&quot;nofollow&quot;&gt;somebody's experience&lt;/a&gt; with the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other projects you might want to try as well the ESP8266 - very cheap and seems a lot of people have experience with it, so you might find more information on the net.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-04-16T22:31:01.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10143" PostTypeId="1" CreationDate="2015-04-16T21:58:57.757" Score="2" ViewCount="1704" Body="&lt;p&gt;I'm doing a project for school with an arduino uno. I want to control a motor using a RF-module as remote control. I need the library Virtualwire.h to use the RF-module and the library Servo.h to control the motor. I downloaded the library Servotimer2.h because Virtualwire.h and Servo.h both want to use timer 1 of the arduino. I added this library to arduino libraries but arduino doesn't recognise it as a library when I include it to my program.&#xA;can someone help me with this issue? I tried to find a solution but can't find it. &#xA;Many thanks allready!&lt;/p&gt;&#xA;" OwnerUserId="8551" OwnerDisplayName="loran" LastActivityDate="2015-04-16T23:09:28.437" Title="Servotimer2.h is not recognised as a library by arduino uno" Tags="|servo|library|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10144" PostTypeId="1" AcceptedAnswerId="10153" CreationDate="2015-04-16T21:58:31.007" Score="1" ViewCount="5275" Body="&lt;p&gt;So my question is that I am trying to use a arduino library called Accel Stepper to control a stepper motor, I made code that makes the stepper motor move one rev clockwise and then one rev counter clockwise &lt;/p&gt;&#xA;&#xA;&lt;p&gt;however as i run the code, the motor has no problem going clockwise, however when it comes to reversing the shaft of the motor stays still and doesn't move while the whole motor itself vibrates, what could be my problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // MultiStepper.pde&#xA;    // -*- mode: C++ -*-&#xA;    //&#xA;    // Shows how to multiple simultaneous steppers&#xA;    // Runs one stepper forwards and backwards, accelerating and decelerating&#xA;    // at the limits. Runs other steppers at the same time&#xA;    //&#xA;    // Copyright (C) 2009 Mike McCauley&#xA;    // $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $&#xA;&#xA;    #include &amp;lt;AccelStepper.h&amp;gt;&#xA;    int user = 800;&#xA;    // Define some steppers and the pins the will use&#xA;&#xA;    AccelStepper stepper2(AccelStepper::DRIVER, 9,8 );&#xA;    AccelStepper stepper3(AccelStepper::DRIVER, 4, 7);&#xA;&#xA;    void setup()&#xA;    {  &#xA;&#xA;        stepper2.setMaxSpeed(1000);  &#xA;        stepper2.setSpeed(300);  &#xA;&#xA;&#xA;    }&#xA;&#xA;    void loop()&#xA;    {&#xA;        // Change direction at the limits&#xA;      stepper2.moveTo(user);&#xA;      stepper2.setSpeed(300);  &#xA;      stepper2.runSpeedToPosition();   &#xA;      if (stepper2.distanceToGo() == 0){ &#xA;        stepper2.moveTo(-stepper2.currentPosition());  &#xA;        stepper2.setSpeed(300);  &#xA;        stepper2.runSpeedToPosition(); &#xA;      } &#xA;&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8532" OwnerDisplayName="Redrachet2" LastActivityDate="2020-01-17T10:48:33.420" Title="Accel Stepper help, stepper not going backwards" Tags="|library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10145" PostTypeId="1" CreationDate="2015-04-16T23:11:28.383" Score="2" ViewCount="3954" Body="&lt;p&gt;I came across this post&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/10327506/android-arduino-bluetooth-data-transfer&quot;&gt;https://stackoverflow.com/questions/10327506/android-arduino-bluetooth-data-transfer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where the author sends files from the arduino to android platform over bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering, is this possible to achieve with the ESP8266 SoC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no experience with it, but i am willing to buy and experiment, if it hads that functionality.&lt;/p&gt;&#xA;" OwnerUserId="1499" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-16T23:18:58.487" Title="Sending file from SD card to android using ESP8266" Tags="|android|esp8266|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10146" PostTypeId="2" ParentId="10125" CreationDate="2015-04-16T23:27:25.687" Score="6" Body="&lt;p&gt;The ultra-basic &quot;serial monitor&quot; in the Arduino IDE cannot do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to either write a special client program, or use a more standard serial terminal program, such as Tera Term (Windows), Minicom (Linux), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These standard serial terminal programs use a special sequence of characters called &lt;em&gt;ANSI escape codes&lt;/em&gt; which manipulate the display, doing such things as setting colours, moving the cursor around, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information on ANSI escape codes can be found here: &lt;a href=&quot;http://en.wikipedia.org/wiki/ANSI_escape_code&quot;&gt;http://en.wikipedia.org/wiki/ANSI_escape_code&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-04-16T23:27:25.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10147" PostTypeId="1" AcceptedAnswerId="10148" CreationDate="2015-04-17T00:26:32.223" Score="1" ViewCount="417" Body="&lt;p&gt;I am making a moving robot that will be autonomous in many respects. However if something goes wrong I want to be able to use a remote to push a button and it stop in its tracks no matter what function its in.  My understanding is that interrupts can do that. The official site I did not find to be helpful. Any ideas? Or if the scheduler library would be of use.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-21T10:48:01.977" Title="Intterupts For Arduino" Tags="|interrupt|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10148" PostTypeId="2" ParentId="10147" CreationDate="2015-04-17T01:19:55.120" Score="1" Body="&lt;p&gt;An interrupt can not &lt;em&gt;always&lt;/em&gt; stop the code, although that is almost always the case. Certainly having an interrupt based kill switch would be better than a &quot;regular code&quot; polled one, which would still be better than nothing. If possible I would feel safest with a cut-power-to-the-whole-thing style safety switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many functions that have sensitive timing constrains disable interrupts while they are active. It is rare for any of these to take a noticable amount of time, but it is possible that a bug in an interrupt dissabled function or another interrupt function could cause it to block and in that case your stop switch wouldn't work. rare, but possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose you could turn on the chip watchdog timer, have a regular timer based interrupt reset the watchdog timer at a certain interval, and have your interrupt safety switch enabled. Then if interrupts ever stopped firing for too long the chip would reset itself. &lt;a href=&quot;http://www.atmel.com/images/doc2551.pdf&quot; rel=&quot;nofollow&quot;&gt;Checkout AVR132: Using the Enhanced Watchdog Timer&lt;/a&gt;. I've never used the watchdog myself, but it exists for a reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have enough experience with a scheduler system to know if they would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-04-17T01:19:55.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10150" PostTypeId="1" CreationDate="2015-04-17T03:07:07.697" Score="2" ViewCount="130" Body="&lt;p&gt;I am using Arduino Uno Rev 3, and according to &lt;a href=&quot;https://arduino.stackexchange.com/questions/296/how-high-of-a-baud-rate-can-i-go-without-errors&quot;&gt;this link&lt;/a&gt; we can achieve 2000000 baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem can be easily repeated by the following code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(2000000);&#xA;}&#xA;&#xA;void loop() {&#xA;  int val = 234;&#xA;  Serial.println(val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the serial-USB cable. To read the data, I used Python pyserial (&amp;lt; 20 lines of code including empty lines and import lines):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;import matplotlib.pyplot as plt&#xA;&#xA;LEN = 10000&#xA;data = []&#xA;ser = serial.Serial('COM3', baudrate=2000000)&#xA;for i in range(LEN):&#xA;    try:&#xA;        data.append(int(ser.readline()))&#xA;    except:&#xA;        pass&#xA;ser.close()&#xA;&#xA;# %% Plot data&#xA;plt.figure(figsize=(6, 4))&#xA;plt.plot(data)&#xA;plt.savefig('data.png')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sFZUG.png&quot; alt=&quot;Plot of data&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Edit below&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Chris mentioned a good point that it might be the high baud rate of 2,000,000 causing the instability. I did think about that when I first ran into this, but then I did a little trick: adding a sinusoid into the constant. If I do that, the weird spiking goes away! I think it indicate that this is not a high baud rate issue... Is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(2000000);&#xA;}&#xA;&#xA;void loop() {&#xA;  int val = 234;&#xA;  val += int(512 * (sin(float(millis()) * 0.01) + 1)) * 0.1;&#xA;  Serial.println(val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UeP9p.png&quot; alt=&quot;Output&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8475" LastEditorUserId="37523" LastEditDate="2019-08-24T20:39:47.710" LastActivityDate="2019-08-24T20:39:47.710" Title="Sending constant int from Arduino to PC causes error" Tags="|arduino-uno|serial|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="10151" PostTypeId="1" CreationDate="2015-04-17T03:25:04.133" Score="2" ViewCount="479" Body="&lt;p&gt;I know this is very common project and it's already been done, however, most of the guides don't have a clear instruction, and being this inexperienced, I struggle to understand exactly what's going on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently working on a line following robot, but I'm largely inexperienced. For the most part, I'm going to be using SparkFun's Magician Chassis with Inventors Kit. The main sensor available is the Line Sensor Breakout(QRE113), which I have 3 of, but I'm not sure if whether I should use the Digital or Analog model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm having trouble finding how to wire this circuit. I know as much that, I have to connect the motors, diode, simple transistor(with emitter, collector, and base), some sort of resistors, and maybe a capacitor(this one I'm not too sure of). All of this has to be set on a breadboard, and be jointly connected to the arduino. I think there has to be two identical circuits on the breadboard for each motor, as the voltage of the sensor is expected to decrease when it encounters a white reflective surface(tape), this in turn will slow down the motor, which would allow the robot to turn in the direction of the tape, due to the other wheel not slowing down. One part of the circuit, should handle the motor drive circuit, this should be the output of the transistor, but I'm not sure how to use the arduino(redboard) to control the speeds of the motors using the sensors, which I think will go into the base of the emitter. Which pins should I use basically?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from this, how will the code look? But I think this is dependent on how I wire it, right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I'm using...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/12060&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12060&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9453&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9453&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8529" LastActivityDate="2015-04-17T07:18:53.047" Title="Line Follow Vehicle" Tags="|arduino-uno|sensors|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10152" PostTypeId="1" CreationDate="2015-04-17T04:21:36.763" Score="5" ViewCount="9887" Body="&lt;p&gt;I'm prototyping out a board with temperature, humidity, windspeed sensors, and using an NRF2401+ board to send values to a Raspberry Pi base station that will record the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a Leonardo clone board, I'm able to successfully run the &lt;em&gt;pingair_dyn&lt;/em&gt; sketch to send test payloads to the RPi and receive acks.  (So I know the RPi can send and recieve OK.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moving the same NRF2401+ to a breadboard setup with an ATMEGA328P-PU, the same sketch &lt;strong&gt;can send&lt;/strong&gt; payloads which are received on the RPi, but &lt;strong&gt;always hits the timeout&lt;/strong&gt; trying to get the ack (which the RPi is dutifully sending).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact when running pingair_dyn as a receiver, it just spins in the loop waiting for radio.available() to return true, which it never does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The immediate problem is that &lt;strong&gt;radio.available() is always returning false&lt;/strong&gt;.  So basically I can send but can't receive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked my wiring several times, and I'm mostly confident that it's right.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;CE - physical pin 14 (arduino digital pin 8 )&lt;/li&gt;&#xA;  &lt;li&gt;CSN - physical pin 13 (arduino digital pin 7)&lt;/li&gt;&#xA;  &lt;li&gt;SCK - physical pin 19, per atmega328 datasheet&lt;/li&gt;&#xA;  &lt;li&gt;MOSI - physical pin 17, per datasheet&lt;/li&gt;&#xA;  &lt;li&gt;MISO - physical pin 18, per datasheet&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In the software, I construct the RF24 instance:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;RF24 radio(8,7);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any ideas?  I tried swapping CE &amp;lt;--&gt; CSN, then nothing worked.  Is there some wiring problem that would cause XMIT to work but RECV to fail?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried putting a 2.2 uF capacitor across the 3.3V - GND as I've seen mentioned in other threads, but no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on what is useful information to dig out of the RF24 library to give some idea of what's going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More background&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the RF24 debug info from the mega328&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0&#xA;RX_ADDR_P0-1    = 0xf0f0f0f0d2 0xf0f0f0f0e1 &#xA;RX_ADDR_P2-5    = 0xc3 0xc4 0xc5 0xc6 &#xA;TX_ADDR       = 0xf0f0f0f0d2 &#xA;RX_PW_P0-6    = 0x20 0x20 0x00 0x00 0x00 0x00 &#xA;EN_AA       = 0x3f &#xA;EN_RXADDR    = 0x02 &#xA;RF_CH      = 0x4c &#xA;RF_SETUP    = 0x07 &#xA;CONFIG       = 0x0f &#xA;DYNPD/FEATURE    = 0x3f 0x04 &#xA;Data Rate    = 1 MBPS &#xA;Model       = nRF24L01+ &#xA;CRC Length    = 16 bits &#xA;PA Power    = PA_MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the debug info from the base station (Raspberry Pi):&#xA;pyRF24/examples/pingpair_dyn/&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;================ SPI Configuration ================ &#xA;CSN Pin          = CE0 (PI Hardware Driven) &#xA;CE Pin           = Custom GPIO22 &#xA;Clock Speed      = 8 Mhz&#xA;================ NRF Configuration ================ &#xA;STATUS           = 0x0e RX_DR=0 TX_DS=0 &#xA;MAX_RT=0 RX_P_NO=7     TX_FULL=0         RX_ADDR_P0-1     =&#xA;0xe7e7e7e7e7 0xc2c2c2c2c2 &#xA;RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6&#xA;TX_ADDR          = 0xe7e7e7e7e7 &#xA;RX_PW_P0-6       = 0x00 0x00 0x00 0x00 0x00 0x00 &#xA;EN_AA            = 0x3f &#xA;EN_RXADDR        = 0x03 &#xA;RF_CH            = 0x4c &#xA;RF_SETUP         = 0x07 &#xA;CONFIG           = 0x0e &#xA;DYNPD/FEATURE    = 0x3f 0x04 &#xA;Data Rate        = 1MBPS &#xA;Model            = nRF24L01+ &#xA;CRC Length       = 16 bits &#xA;PA Power         = PA_MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8531" LastActivityDate="2018-01-18T14:31:48.410" Title="nRF24L01+ RF24 library - can send but can't receive" Tags="|atmega328|nrf24l01+|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10153" PostTypeId="2" ParentId="10144" CreationDate="2015-04-17T04:36:36.507" Score="0" Body="&lt;p&gt;Work through your code. When it gets to the target position, your loop looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    // Change direction at the limits&#xA;  stepper2.moveTo(user);&#xA;  stepper2.setSpeed(300);  &#xA;  stepper2.runSpeedToPosition();   &#xA;    stepper2.moveTo(-stepper2.currentPosition());  &#xA;    stepper2.setSpeed(300);  &#xA;    stepper2.runSpeedToPosition(); &#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you say, move to position 'user', then move to position '-stepper2.currentPosition'. Then as the loop comes around you again say move to position 'user', and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The loop will repeat hundreds if no thousands of times per second, so you are basically telling the stepper motor to change direction thousands of times per second which will be why the motor starts vibrating when it gets to the user position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, just for the sake of argument, you were to move the first three lines of code in the loop() function to the setup() function, what behaviour do you think you will observe?&lt;/p&gt;&#xA;" OwnerUserId="6860" LastActivityDate="2015-04-17T04:36:36.507" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10154" PostTypeId="2" ParentId="10151" CreationDate="2015-04-17T07:18:53.047" Score="1" Body="&lt;p&gt;You should, really, cut this complete project into smaller little projects.&#xA;Actually, first you should get clear what you want, there are a lot of possibilities.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Try to get one line sensor working&lt;/li&gt;&#xA;&lt;li&gt;Try to get one motor working (check Pulse Width Modulation)&lt;/li&gt;&#xA;&lt;li&gt;Try to get the two motors working and put them on the chassis.&lt;/li&gt;&#xA;&lt;li&gt;Make the motors drive around a little, turn and reverse.&lt;/li&gt;&#xA;&lt;li&gt;Get the three line sensors working (I think you're following a single line withouth crossroads etc.?)&lt;/li&gt;&#xA;&lt;li&gt;Make your arduino check for changes in the pattern 0 1 0 respectively for the line sensors would mean that you're on the line. If the pattern is 0 0 1, you're driving off the line to the left.&lt;/li&gt;&#xA;&lt;li&gt;Use the engines to adjust back onto the line.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've actually done a project similiar to this one, but we used a motor-board instead. Driving the motors with a transistor&amp;amp;diode(&amp;amp;mosfet?) should indeed also be possible... but it'll get difficult once you want to be able to also reverse the motor (check H-Bridge motor driver).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the patterns, you should make a &lt;code&gt;switch case&lt;/code&gt; which checks the last pattern and keeps steering until he finds the right pattern again. But this can be achieved in many other ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to get a line sensor working, be sure to check some tutorials before you ask here and try to use different kinds of tape, blue tape didn't work for us :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a really fun project, with lots of possibilities.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Below the schematics we used in the project.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;We used a motor controller board.&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth module to receive command/routes from the server.&lt;/li&gt;&#xA;&lt;li&gt;(LS) line sensors, 5 of them, to see crossroads/sideroads.&lt;/li&gt;&#xA;&lt;li&gt;(Infrarood) IR sensors for collision detection.&lt;/li&gt;&#xA;&lt;li&gt;(RS) I actually have no idea which sensors these are.&lt;/li&gt;&#xA;&lt;li&gt;(Ultrasonic Sensor) Ping sensor to determine distance to other robots.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9MGwa.png&quot; alt=&quot;schematics&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-17T07:18:53.047" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10156" PostTypeId="1" AcceptedAnswerId="10165" CreationDate="2015-04-17T11:00:30.867" Score="0" ViewCount="14666" Body="&lt;p&gt;I have an Arduino Uno which communicated with the computer (Ubunutu 14.04) fine till 6 days ago (I assume some software update is to blame).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when trying to upload I get&lt;/p&gt;&#xA;&#xA;&lt;p&gt;processing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools &gt; Serial Port menu?   at processing.app.Serial.(Serial.java:191)    at processing.app.Serial.(Serial.java:77)     at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)    at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175)   at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)     at processing.app.Sketch.upload(Sketch.java:1671)   at processing.app.Sketch.exportApplet(Sketch.java:1627)     at processing.app.Sketch.exportApplet(Sketch.java:1599)     at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)     at java.lang.Thread.run(Thread.java:745)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I sudo ls /dev/ttyA*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls: cannot access /dev/ttyA*: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it does not look like a permission issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I lsusb&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 001 Device 002: ID 8087:8000 Intel Corp. &#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&#xA;Bus 002 Device 003: ID 04f2:b39a Chicony Electronics Co., Ltd &#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it does not even see the device (which is connected and pulling current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I dmesg before and after connecting the Arduino, I don't see anything new.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried switching USB cables, and switching USB ports on the machine (both ports work with a mouse), but in vain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What went wrong and how do I fix it ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;David.&lt;/p&gt;&#xA;" OwnerUserId="8534" LastEditorUserId="4143" LastEditDate="2015-04-17T18:38:05.667" LastActivityDate="2015-04-17T18:47:09.317" Title="ttyACM0 no such file or directory On Ubunutu 14.04" Tags="|arduino-uno|uploading|usb|linux|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10158" PostTypeId="1" CreationDate="2015-04-17T13:49:11.317" Score="2" ViewCount="2345" Body="&lt;p&gt;I want to switch from using disposable 9V blocks to a proper setup of 3.7V LiPolys for all my portable Arduino (Uno/Mega) projects consisting of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;only 3.7V LiPo units&lt;/li&gt;&#xA;&lt;li&gt;charger&lt;/li&gt;&#xA;&lt;li&gt;upconverter (to 5V)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this generally a good idea? Or is there a better solution for portable Arduino power?&lt;/li&gt;&#xA;&lt;li&gt;How should I actually hook the LiPolys up to the Arduino? They usually ship with JST connectors. Should I use the Vin/GND Pins or should I build my own JST/DC-Connector adaptor? I want to create a robust, pluggable solution.&lt;/li&gt;&#xA;&lt;li&gt;Am I actually losing power twice that way (once in the upconverter and then in the Arduino voltage regulator)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8220" LastEditorUserId="8220" LastEditDate="2015-04-20T09:07:42.503" LastActivityDate="2015-04-20T09:07:42.503" Title="Lithium Polymer/LiPo set to power Arduinos" Tags="|power|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10160" PostTypeId="1" AcceptedAnswerId="10161" CreationDate="2015-04-17T16:43:14.867" Score="2" ViewCount="8035" Body="&lt;p&gt;Otherwise worded: How do I resolve my understanding about baud rates and high speed serial data transfer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand, serial communication is relatively slow.  By slow, I mean that the fastest common rate of transmission of data is 115.2 kBaud.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, also from what I understand there are fast ways of transferring data serially.  I know that some serial configurations through Firewire or Ethernet can transfer data at speeds that are orders of magnitude higher than 115.2 kBaud.  These data streams are able to be read on simple computers that you can buy from Staples.  I don't know how these systems receive data at such a high speed if common baud rates are so low.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know something is wrong with my understanding of it all.  I am new to electrical engineering and I am trying to teach myself some basic ideas for my research project - with much frustration.  I know that I need to have a system that can receive a pulse train at a minimum speed of 10MHz (hopefully up to 500MHz).  I will then program it to process this data.  The system that I currently have to receive the data is an Arduino certified product:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://store.arduino.cc/product/E000052&quot; rel=&quot;nofollow&quot;&gt;http://store.arduino.cc/product/E000052&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming in the Arduino language is not a problem, I already know how to do this.  I just want to understand what I can do to receive this data stream.  Do I need something faster than this?  Or will this suffice?  I'm more interested in the theory than the device; it is more valuable for me to bolster my education than for me to solve my problem (though it needs to be solved).  &lt;/p&gt;&#xA;" OwnerUserId="4335" LastEditorUserId="7727" LastEditDate="2015-09-15T12:08:41.380" LastActivityDate="2015-09-15T15:13:11.550" Title="What are the different types of high-speed serial data transfer protocols, and how do they work (ex: baudrate, synchronous vs asynchronous, etc)?" Tags="|serial|edison|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10161" PostTypeId="2" ParentId="10160" CreationDate="2015-04-17T17:19:17.530" Score="7" Body="&lt;p&gt;Basically there are two kinds of serial: Asynchronous and Synchronous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;em&gt;asynchronous&lt;/em&gt;, which is what serial as in UART and RS-232 are, it's all down to how accurate a system's clock is.  Both ends of the line have to agree on the same speed (baud rate) and any deviation from that causes transmission errors.  The more accurately the two ends can agree on their baud rates the faster you can transfer data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that on many systems (Arduino included) when you ask for one baud rate you actually get a slightly different baud rate.  That's due to the way that the internal UART hardware works - it divides the system clock into finer and finer bits to get as close to the requested baud rate as possible.  Lower baud rates are easer to get close to, but higher ones are much harder.  So it's &quot;safer&quot; to use a lower baud rate which gives more reliable communication to a greater variety of devices.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter&quot;&gt;http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The other kind of serial, &lt;em&gt;synchronous&lt;/em&gt;, uses an extra wire for the transmitting (or &lt;em&gt;master&lt;/em&gt;) end of the connection to send the clock to the receiving (&lt;em&gt;slave&lt;/em&gt;) end.  The receiver uses the incoming clock to know precisely when it should look at the data line to receive a bit of data.  This is how things like SPI and I²C work, and very high baud rates can be achieved.  Speeds in the tens of megahertz are common.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot;&gt;http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/I%C2%B2C&quot;&gt;http://en.wikipedia.org/wiki/I%C2%B2C&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some synchronous systems (such as Ethernet), instead of providing the clock as a discrete wire, encode the clock into the data stream.  This keeps the number of wires to a minimum yet allows high speed data transfer.  The down side is that this usually means the maximum speed you can run at is actually slightly lower since the effective size of the data being transmitted is increased.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Clock_recovery&quot;&gt;http://en.wikipedia.org/wiki/Clock_recovery&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-04-17T17:26:10.743" LastActivityDate="2015-04-17T17:26:10.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10162" PostTypeId="2" ParentId="10158" CreationDate="2015-04-17T17:32:38.677" Score="1" Body="&lt;p&gt;Sparkfun do the ideal solution for you - their &quot;LiPower&quot; shield:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10711&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10711&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It contains the Li-Ion / Li-Poly charger, 5V boost converter, and MAX17043G+U fuel gauge chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-04-17T17:32:38.677" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10164" PostTypeId="2" ParentId="10158" CreationDate="2015-04-17T18:30:03.530" Score="5" Body="&lt;p&gt;If you can get away with it, I recommend not using a boost converter and instead connecting the battery directly to the supply voltage input (the &quot;5V&quot; pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AVR chips used in most Arduinos (but not the Due or Zero [and the Yún and Tre are a totally different kettle of fish entirely]) can operate with anywhere between 2.7 and 5.5 volts, with the ATmega328P found in the Uno able to run with as little as 1.8V. This is a &lt;em&gt;much&lt;/em&gt; larger range than the 3.0-4.2V available from rechargeable Li-ion/Li-poly/LiFePO4 cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally you will need to make sure that any external components can run with the reduced voltage as well, but quite a few are able to work with anything from 2.0 to 5.5 volts.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-17T18:30:03.530" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10165" PostTypeId="2" ParentId="10156" CreationDate="2015-04-17T18:47:09.317" Score="2" Body="&lt;p&gt;Ok, it sounds like there is an issue with the ATMega(8/16)U2 chip or its surroundings.  It might just need its firmware refreshing (which can be done with another Arduino as a programmer) or it might be plain dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is the USB socket itself.  I have two UNOs, one which is perfectly fine, and one where I need to hold the cable at just the right angle for it to connect properly.  You can try using a fine needle to try and raise the four metal strips in the USB connector a fraction to make better contact.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-04-17T18:47:09.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10166" PostTypeId="1" CreationDate="2015-04-17T19:22:49.860" Score="2" ViewCount="1043" Body="&lt;p&gt;I am doing a project with an Intel Edison Arduino breakout board.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://store.arduino.cc/product/E000052&quot; rel=&quot;nofollow&quot;&gt;http://store.arduino.cc/product/E000052&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://download.intel.com/support/edison/sb/edisonmodule_hg_331189002.pdf&quot; rel=&quot;nofollow&quot;&gt;http://download.intel.com/support/edison/sb/edisonmodule_hg_331189002.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a device that I want to communicate with by SPI.  This device can receive a maximum of 16MHz for its clock.  I want this maximum speed of 16 MHz.  From what I understand, the Edison can output a clock speed of 19.2 MHz.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know much about clocks and I am still learning.  Is it possible to program the Edison to operate its SPI output clock at a speed of 16 MHz?  If so, how would this be done?&lt;/p&gt;&#xA;" OwnerUserId="4335" LastActivityDate="2015-04-17T19:22:49.860" Title="Simple question about the SPI clock for Intel Edison" Tags="|spi|edison|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10167" PostTypeId="2" ParentId="10160" CreationDate="2015-04-17T20:43:48.183" Score="1" Body="&lt;p&gt;Different serial communications protocols use different &lt;a href=&quot;http://en.wikipedia.org/wiki/Modulation#Digital_modulation_methods&quot; rel=&quot;nofollow&quot;&gt;signal modulation methods&lt;/a&gt; to encode data; if you want to roll your own wire protocol, you'll want to learn about those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Back in the day, low-rate UART serial systems were mostly used with modems that had to transmit long distances over voice telephone circuits. Those circuits were bandwidth-limited to the needs of voice communication, and were frequently &quot;noisy&quot;, so phone line modems never evolved beyond 56Kbit/s rates. The UARTs themselves could go faster, so if you were doing a local serial connection you could get up to 115kbps. These UARTs were relatively cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More advanced encoding schemes plus more expensive hardware (with a lower noise floor) allowed connections about 100 times faster -- 10mbps ethernet. That's a much more common standard now than RS-232 serial connections, and as it became widely adopted it got cheap, and so 100mbps and gigabit ethernets followed the same form factor and basic electrical characteristics because (under good conditions) all could work over the same wiring, so compatibility with existing systems was good; the endpoints for the most part can automatically downgrade to whatever speed is supported by both ends of a given wire.&lt;/p&gt;&#xA;" OwnerUserId="8543" LastActivityDate="2015-04-17T20:43:48.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10168" PostTypeId="2" ParentId="10158" CreationDate="2015-04-18T00:18:16.803" Score="1" Body="&lt;p&gt;Consider using 2 x LiPo is series (2S). Vmax is 2 x 4.2V = 8.4V&lt;br&gt;&#xA;This may be attractive compared to boosting from a single cell.&lt;br&gt;&#xA;This is still &amp;lt; the 9V you used previously.&lt;br&gt;&#xA;Vmin is say 2 x 3V = 6V - but higher is better for the LiPos.&lt;br&gt;&#xA;You can use a buck converter or a linear regulator as desired, and could use one or other depending on project.&lt;br&gt;&#xA;You could even use linear + buck in parallel for applications where sleep current is very small and buck converters may find efficiency at very low I challenging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 5V rather than less than 5 is attractive in that you do not need to ensure the processor speed will accommodate the lower voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a linear regulator and 5V:&lt;br&gt;&#xA;Efficiency at 4V/cell = 5/8 = 62.5%.&lt;br&gt;&#xA;Efficiency at 3V/cell = 5/6 = 83%.&lt;br&gt;&#xA;Any sensible buck regulators will be more efficient at more than a few mA but at very low currents that may be acceptable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 LiPo in 2S will notionally need balancing occasionally but this is easy to do informally occasionally or using any of the many available charging ICs.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-18T00:18:16.803" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10169" PostTypeId="2" ParentId="10147" CreationDate="2015-04-18T02:35:05.950" Score="1" Body="&lt;p&gt;If you are using an arduino uno, pin 2 and 3 are the hardware interrupt pins. You may send rising , falling, high or low signals to these pins using a Bluetooth module (for eg). Say for eg when you press the remote switch, Bluetooth gets a low signal and triggers an interrupt. If the output of Bluetooth is connected to pin 2, then in the setup you have to declare         &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, stoprobo, LOW);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the function stoprobo, you can write the code to stop your robot.&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="6549" LastEditDate="2015-04-21T10:48:01.977" LastActivityDate="2015-04-21T10:48:01.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10170" PostTypeId="1" CreationDate="2015-04-18T08:04:20.440" Score="2" ViewCount="15505" Body="&lt;p&gt;I want to interface my OV7670 camera (without FIFO) to my Arduino Uno. I have browsed internet quite a lot about it and found people either saying it's not possible or they just give me the link to this &lt;a href=&quot;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow&quot;&gt;github repository&lt;/a&gt; (As this guy has done exactly what I want). As the author of this &lt;a href=&quot;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow&quot;&gt;repository&lt;/a&gt; is a man of few words, he did not help me very much. I just want to know how to use this to get image sent to my PC serially. I only know how to use Arduino IDE in windows platform and no other platform.&lt;/p&gt;&#xA;" OwnerUserId="8218" LastEditorUserId="6936" LastEditDate="2016-03-11T06:04:18.927" LastActivityDate="2016-07-01T12:58:08.363" Title="How to use code for OV7670 on Arduino Uno" Tags="|arduino-uno|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10171" PostTypeId="2" ParentId="5388" CreationDate="2015-04-18T09:25:42.493" Score="1" Body="&lt;p&gt;I notice that your code only mentions &quot;child1&quot;, but the output you've displayed mentions &quot;child 2&quot;. I assume that means you're using more than one instance of &lt;code&gt;SoftwareSerial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's important to note that only one instance can receive data at any given time. You need to call &lt;code&gt;listen()&lt;/code&gt; on an instance to enable it, which will prevent any other instance from receiving data. (Anything which would have been received by another instance will be discarded.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the documentation here: &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerialListen&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/SoftwareSerialListen&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-18T09:25:42.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10174" PostTypeId="1" AcceptedAnswerId="10177" CreationDate="2015-04-18T11:07:30.157" Score="0" ViewCount="58" Body="&lt;p&gt;In this &lt;a href=&quot;https://arduino.stackexchange.com/questions/4436/send-processing-color-data-into-arduino&quot;&gt;Question&lt;/a&gt; how does the code &lt;code&gt;Processing&lt;/code&gt; work?&#xA;Which programming language is it written in? How to run it?&lt;/p&gt;&#xA;" OwnerUserId="8420" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-04-18T12:05:59.413" Title="Communicating with Arduino" Tags="|programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10175" PostTypeId="1" CreationDate="2015-04-18T11:17:48.247" Score="4" ViewCount="64206" Body="&lt;p&gt;I am new to programming and am trying to communicate with my arduino using python through serial communication. I am using the following code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 11;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin,OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(ledPin,LOW);&#xA;    if (Serial.read() == 'M'){&#xA;      digitalWrite(ledPin,HIGH);}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import imaplib&#xA;import serial&#xA;ser = serial.Serial(&quot;COM3&quot;,9600)&#xA;ser.write(b'T')&#xA;ser.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error on running the python script:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8548" LastEditorUserId="84" LastEditDate="2015-04-19T07:31:02.453" LastActivityDate="2020-11-09T12:47:15.787" Title="Can't communicate with arduino using python (Windows)" Tags="|serial|python|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10176" PostTypeId="2" ParentId="10080" CreationDate="2015-04-18T11:36:38.127" Score="3" Body="&lt;p&gt;The best is to use 10us Period, instead of 50us.&lt;br&gt; &#xA;That precision will be close to 1°&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-18T11:36:38.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10177" PostTypeId="2" ParentId="10174" CreationDate="2015-04-18T12:05:59.413" Score="2" Body="&lt;p&gt;&quot;Processing&quot; is a simplified programming language/environment based on Java. It's designed to be very easy for non-programmers to use, and is quite a popular choice for using alongside Arduino projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can download it for free (and get lots of tutorials/documentation) from here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://processing.org&quot; rel=&quot;nofollow&quot;&gt;https://processing.org&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a side note, the Arduino IDE was based on Processing, so it will probably look familiar!&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-18T12:05:59.413" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10178" PostTypeId="2" ParentId="10175" CreationDate="2015-04-18T13:33:06.357" Score="1" Body="&lt;p&gt;There can be several reasons as highlighted in these questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6032568/using-serial-on-python-win7&quot;&gt;https://stackoverflow.com/questions/6032568/using-serial-on-python-win7&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6105182/error-while-opening-port-in-python&quot;&gt;https://stackoverflow.com/questions/6105182/error-while-opening-port-in-python&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;port is already in use by another application&lt;/li&gt;&#xA;&lt;li&gt;permissions are set to deny access to normal users&lt;/li&gt;&#xA;&lt;li&gt;problems in the code (top answer in first link)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Try to run with administrator priviledges (&quot;run as administrator&quot;). Others claim that a simple retry might help.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-04-18T13:33:06.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10179" PostTypeId="1" CreationDate="2015-04-18T14:55:43.143" Score="1" ViewCount="584" Body="&lt;p&gt;I'm a beginner and, sorry, also I don't speak English very well. However, I'm going to try to explain my problem. &#xA;I'm working on Ubuntu 14.04.2 and Arduino Uno R3. &#xA;I downloaded Firmata Test binaries for Linux 64 bit, I gave it permissions with &lt;code&gt;chmod 754 &amp;lt;file&amp;gt;&lt;/code&gt;. Also I uploaded StandardFirmata from Arduino IDE to the board. Afterwards, I quit Arduino IDE and ran Firmata Test with &lt;code&gt;./file&lt;/code&gt;. But, the Port menu has no items within. I tried restarting the board and the application as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="8292" LastActivityDate="2021-08-02T13:15:42.893" Title="Why Firmata Test doesn't allow me to choose a port?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10180" PostTypeId="1" CreationDate="2015-04-18T16:10:34.323" Score="2" ViewCount="109" Body="&lt;p&gt;i'm trying to compile native code in VC++ using galileo sdk for windows iot. &#xA;I've copied Ethernet.h file to the include directory of &#xA;D:\galileo-sdk-develop\galileo-sdk-develop\source&gt; but still getting error on cannot open include file &quot;Ethernet.h&quot;&lt;/p&gt;&#xA;" OwnerUserId="8554" LastActivityDate="2015-04-18T16:10:34.323" Title="error C1083: Cannot open include file: 'Ethernet.h':" Tags="|ethernet|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10181" PostTypeId="2" ParentId="10175" CreationDate="2015-04-18T17:28:26.973" Score="8" Body="&lt;p&gt;More than likely you ran the Arduino program from the Arduino IDE, and left the terminal window open. You must close it before you run the python program, as it will already 'own' the port until it closes. You dont have to quit Arduino IDE, just close the terminal window.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-04-18T17:28:26.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10183" PostTypeId="1" CreationDate="2015-04-19T00:45:34.530" Score="2" ViewCount="663" Body="&lt;p&gt;I've got my Arduino Yun (less than a year old) connected to my computer via a USB cable. The device seems to be on (that is, the lights are all on). However, the Arduino is not showing up in either the /dev/ttyACMx (linux) or COMx on my Windows boot. Does anyone have any suggestions for why this could be? I've tried to reset the Yun to factory settings by holding the WRT RST button for 30+ seconds, but that still didn't fix anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm afraid that I'm now looking at a bricked Yun; if this is the case, what could / should I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have the 1.6.0 version running. I'm indeed using a microUSB cable to connect to the arduino via USB. If I'm connected to the Arduino-90xxxxxxx wifi network, I can still push sketches to the arduino. However, I'm unable to see the arduino over serial, both in the IDE / terminal. The only port I see in the IDE is 192.168.240.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2: I was able to see my Arduino Yun in the IDE again after flashing the blink sketch via wifi and resetting the 32u4. This makes me think that it's a software issue due to the sketch I'm pushing. &lt;strong&gt;Is there something that I could be calling which would make the Arduino unable to connect via serial?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8559" LastEditorUserId="8559" LastEditDate="2015-04-19T01:33:33.223" LastActivityDate="2015-04-19T01:33:33.223" Title="Arduino Yun not showing up in Windows or Linux [software issue?]" Tags="|serial|arduino-yun|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10185" PostTypeId="1" AcceptedAnswerId="10186" CreationDate="2015-04-19T03:00:23.567" Score="7" ViewCount="331" Body="&lt;p&gt;I'm trying to find an easy way to allow an Arduino Uno to determine if it's being powered from USB or the DC barrel jack. In &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=120693.0&quot; rel=&quot;noreferrer&quot;&gt;this thread&lt;/a&gt;, one user recommends wiring the output of the on-board comparator op-amp (U5A pin 1) into the digital input pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find U5A on the &lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;current schematic&lt;/a&gt;, but I think he's actually referring to U1A pin 1. Is this correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I'm not sure where on the physical Arduino that device is located. I have one in front of me, and almost none of the parts are labeled on the silk screen. How do I find out where it is? I've googled for Arduino Uno part placement schematics, but all I'm finding are blurry unlabeled low-res images.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="510" LastEditDate="2015-04-19T20:37:57.880" LastActivityDate="2015-04-19T20:37:57.880" Title="What is the physical location of the U1A symbol on Arduino Uno?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10186" PostTypeId="2" ParentId="10185" CreationDate="2015-04-19T04:12:29.300" Score="9" Body="&lt;p&gt;The op-amp is a LM358 so you can look at the ICs themselves. Also it's a dual comparator with 8 pins. On my example image below you can see it below the crystal. I can't comment if that's the correct way to sense what you need, but it seems the comparator output should be 1 if there is external power applied. You could check with a multimeter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bANvw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-04-19T04:12:29.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10187" PostTypeId="1" AcceptedAnswerId="10188" CreationDate="2015-04-19T11:27:03.537" Score="8" ViewCount="69467" Body="&lt;p&gt;What is the difference between print( ) and println( )?&lt;br&gt;&#xA;I see none when I run a code.&lt;/p&gt;&#xA;" OwnerUserId="8565" LastActivityDate="2019-07-28T13:04:55.577" Title="Difference between print() and println()" Tags="|arduino-ide|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10188" PostTypeId="2" ParentId="10187" CreationDate="2015-04-19T11:36:55.477" Score="6" Body="&lt;p&gt;print() prints whatever you send in.&lt;br&gt;&#xA;println() does the same thing, only after using println, anything new that is printed gets printed in next line, I.e. a new line is formed.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-04-19T11:36:55.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10189" PostTypeId="1" AcceptedAnswerId="10195" CreationDate="2015-04-19T14:29:58.407" Score="1" ViewCount="2041" Body="&lt;p&gt;Is there any way to make sounds using an Arduino without using the tone function?&lt;br&gt;&#xA;It must be possible via this new method to control frequency of sound.&lt;/p&gt;&#xA;" OwnerUserId="8565" LastActivityDate="2015-04-20T18:06:49.607" Title="Alternative to Tone( )" Tags="|programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10190" PostTypeId="1" AcceptedAnswerId="10191" CreationDate="2015-04-19T14:55:10.920" Score="1" ViewCount="317" Body="&lt;p&gt;So. I'm trying to read an input on the Arduino Nano using C++/AVR/Eclipse instead of the regular arduino IDE.&#xA;The code below is working in the arduino IDE&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(13, OUTPUT);&#xA;  pinMode(5, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if(digitalRead(5)){&#xA;    digitalWrite(13,1);&#xA;  }else{&#xA;    digitalWrite(13,0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm porting the code to AVR/C++ in Eclipse, regular blinking leds is working... but I can't read inputs for some reason...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL //16MHz&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;#define set_bit(Y,bit_x) (Y|=(1&amp;lt;&amp;lt;bit_x))&#xA;#define clear_bit(Y,bit_x) (Y&amp;amp;=~(1&amp;lt;&amp;lt;bit_x))&#xA;#define isset_bit(Y,bit_x) (Y&amp;amp;(1&amp;lt;&amp;lt;bit_x))&#xA;#define toggle_bit(Y,bit_x) (Y^=(1&amp;lt;&amp;lt;bit_x))&#xA;&#xA;int main( ){&#xA;    DDRB = 0xFF;//Setting all portB pins to output (D13/PB5 - LED)&#xA;    DDRD = 0x00;//Setting all portD pins to input  (D5 /PD5 - INPUT)&#xA;&#xA;    while(1){&#xA;        if(isset_bit(PORTD,PD5)){//if input... doesn't work?&#xA;            set_bit(PORTB,PB5);//Set output (Tested to be working)&#xA;        }else{&#xA;            clear_bit(PORTB,PB5);//Clear output&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="368" LastEditDate="2015-04-19T16:21:09.633" LastActivityDate="2015-04-19T16:21:09.633" Title="Porting Arduino code to AVR/C++ input not working?" Tags="|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10191" PostTypeId="2" ParentId="10190" CreationDate="2015-04-19T14:56:23.570" Score="4" Body="&lt;p&gt;During the creation of this question I found out the answer... Though I wanted to share it with you guys for later reference.&#xA;It has been quite a time since I have worked with AVR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You should read pins from PINx&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You should set pins in PORTx&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Set DDRx to 1 for OUTPUT and to 0 for INPUT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;^ This is fun because PIC/Microchip MCU's use 1 for input and 0 for output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;#define set_bit(Y,bit_x) (Y|=(1&amp;lt;&amp;lt;bit_x))&#xA;#define clear_bit(Y,bit_x) (Y&amp;amp;=~(1&amp;lt;&amp;lt;bit_x))&#xA;#define isset_bit(Y,bit_x) (Y&amp;amp;(1&amp;lt;&amp;lt;bit_x))&#xA;#define toggle_bit(Y,bit_x) (Y^=(1&amp;lt;&amp;lt;bit_x))&#xA;&#xA;int main( ){&#xA;    DDRB = 0xFF;&#xA;    DDRD = 0x00;&#xA;&#xA;    while(1){&#xA;        if((PIND&amp;amp;(1&amp;lt;&amp;lt;PD5))){&#xA;            set_bit(PORTB,PB5);&#xA;        }else{&#xA;            clear_bit(PORTB,PB5);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-04-19T15:02:04.167" LastActivityDate="2015-04-19T15:02:04.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10192" PostTypeId="1" AcceptedAnswerId="10193" CreationDate="2015-04-16T23:03:43.857" Score="3" ViewCount="5926" Body="&lt;p&gt;I would like to be able to create permanent projects with my arduino Nano but be able to remove the nano in order to use it in other projects. The arduino Nano has 30 pins so I would be looking for some kind of female 30 pin header. Most of the headers that I found like that are too narrow because they are for IC's. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="8046" OwnerDisplayName="Einstein Jr." LastEditorUserId="6452" LastEditDate="2015-04-20T18:07:16.637" LastActivityDate="2015-04-24T17:00:09.923" Title="Best Header for Arduino Nano" Tags="|pins|arduino-nano|system-design|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10193" PostTypeId="2" ParentId="10192" CreationDate="2015-04-16T23:16:27.220" Score="8" Body="&lt;p&gt;The Nano boards that I have used all have pins on 0.1&quot; (2.54mm) spacing.  There are single-row female connectors that are designed to accept 0.025&quot; square pins.  One example is &lt;a href=&quot;http://www.digikey.ca/product-detail/en/SSA-132-S-G/SAM1121-32-ND/1105752&quot;&gt;Samtec 32 position female header&lt;/a&gt; but there are &lt;em&gt;many&lt;/em&gt; others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that these female headers are available to accept either 0.018&quot; round or 0.025&quot; square pins.  My great preference is for the 0.018&quot; round pins but those are less common in hobby circles.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The really huge advantage of the smaller round pins is that you can safely insert them into solderless breadboards without damaging the contacts in the breadboard.  But you would want to standardize on one style or the other.&lt;/p&gt;&#xA;" OwnerUserId="6854" OwnerDisplayName="Dwayne Reid" LastActivityDate="2015-04-16T23:16:27.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10194" PostTypeId="2" ParentId="10170" CreationDate="2015-04-19T17:36:58.357" Score="1" Body="&lt;p&gt;I am ComputerNerd. I read this post and realized the real problem and why I am having difficulty helping you. You are asking the wrong question. What you should be asking is &quot;how do I compile it using GNU Make and Avr-Gcc on Windows?&quot;. Instead you are asking &quot;how can I use this code in the Arduino IDE?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to what you should be asking is simple. Use what you already have. The Arduino IDE ships with Avr-gcc and (maybe) GNU Make. Just run the programs directly. Better yet download MinGW and compile GCC to target the AVR yourself.&lt;/p&gt;&#xA;" OwnerUserId="8568" LastActivityDate="2015-04-19T17:36:58.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10195" PostTypeId="2" ParentId="10189" CreationDate="2015-04-19T18:43:23.840" Score="4" Body="&lt;p&gt;I've used &lt;a href=&quot;http://playground.arduino.cc/Code/PCMAudio&quot; rel=&quot;nofollow&quot;&gt;a somewhat more complex method&lt;/a&gt; with some success, which uses 2 timers to play 8kHz sampled audio. The idea is that one of the timers runs at 8kHz to determine the PWM duty cycle of the other, which runs at as fast a frequency as possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the original code uses a short stored sample (On an Arduino, you could store maybe 3 seconds of audio that way), my usages involved computing the audio on the fly by overlapping several sine waves or using table lookups with varying strides. As long as computation is kept simple, this just barely works.&lt;/p&gt;&#xA;" OwnerUserId="353" LastEditorUserId="1447" LastEditDate="2015-04-20T18:06:49.607" LastActivityDate="2015-04-20T18:06:49.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10196" PostTypeId="1" AcceptedAnswerId="10198" CreationDate="2015-04-19T20:34:39.293" Score="2" ViewCount="1134" Body="&lt;p&gt;i'm making a project and i came across the follwing error.&#xA;Whan i'm trying to compile and upload the code i'm getting those errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ShiftRegisterTest1.ino:In function 'int* return_pins(int)'&#xA;displays.ino:9: error: expected primary-expression before '{' token&#xA;displays.ino:9: error: expected `;' before '{' token&#xA;displays.ino:12: error: expected primary-expression before '{' token&#xA;displays.ino:12: error: expected `;' before '{' token&#xA;displays.ino:15: error: expected primary-expression before '{' token&#xA;displays.ino:15: error: expected `;' before '{' token&#xA;displays.ino:18: error: expected primary-expression before '{' token&#xA;displays.ino:18: error: expected `;' before '{' token&#xA;displays.ino:21: error: expected primary-expression before '{' token&#xA;displays.ino:21: error: expected `;' before '{' token&#xA;displays.ino:24: error: expected primary-expression before '{' token&#xA;displays.ino:24: error: expected `;' before '{' token&#xA;displays.ino:27: error: expected primary-expression before '{' token&#xA;displays.ino:27: error: expected `;' before '{' token&#xA;displays.ino:30: error: expected primary-expression before '{' token&#xA;displays.ino:30: error: expected `;' before '{' token&#xA;displays.ino:33: error: expected primary-expression before '{' token&#xA;displays.ino:33: error: expected `;' before '{' token&#xA;displays.ino:36: error: expected primary-expression before '{' token&#xA;displays.ino:36: error: expected `;' before '{' token&#xA;displays.ino:39: error: expected primary-expression before '{' token&#xA;displays.ino:39: error: expected `;' before '{' token&#xA;displays.ino:42: error: expected primary-expression before '{' token&#xA;displays.ino:42: error: expected `;' before '{' token&#xA;displays.ino:45: error: expected primary-expression before '{' token&#xA;displays.ino:45: error: expected `;' before '{' token&#xA;displays.ino:48: error: expected primary-expression before '{' token&#xA;displays.ino:48: error: expected `;' before '{' token&#xA;displays.ino:51: error: expected primary-expression before '{' token&#xA;displays.ino:51: error: expected `;' before '{' token&#xA;displays.ino:56: error: expected primary-expression before '{' token&#xA;displays.ino:56: error: expected `;' before '{' token&#xA;Error compiling&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really understand why since the code (see below) should be working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int * return_pins(int get_number)&#xA;{&#xA;static int rp[8];&#xA;switch(get_number)&#xA;{&#xA;            //DP, A, B, C, D, E, F, G&#xA;    case 48: //0&#xA;        rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};&#xA;        break;&#xA;    case 49: //1&#xA;        rp[8] = {0, 0, 1, 1, 0, 0, 0, 0};&#xA;        break;&#xA;    case 50: //2&#xA;        rp[8] = {0, 1, 1, 0, 1, 1, 0, 1};&#xA;        break;&#xA;    case 51: //3&#xA;        rp[8] = {0, 1, 1, 1, 1, 0, 0, 1};&#xA;        break;&#xA;    case 52: //4&#xA;        rp[8] = {0, 0, 1, 1, 0, 0, 1, 1};&#xA;        break;&#xA;    case 53: //5&#xA;        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};&#xA;        break;&#xA;    case 54: //6&#xA;        rp[8] = {0, 1, 0, 1, 1, 0, 1, 1};&#xA;        break;&#xA;    case 55: //7&#xA;        rp[8] = {0, 1, 1, 1, 0, 0, 0, 0};&#xA;        break;&#xA;    case 56: //8&#xA;        rp[8] = {0, 1, 1, 1, 1, 1, 1, 1};&#xA;        break;&#xA;    case 57: //9&#xA;        rp[8] = {0, 1, 1, 1, 1, 0, 1, 1};&#xA;        break;&#xA;    case 65: //A&#xA;        rp[8] = {0, 1, 1, 1, 0, 1, 1, 1};&#xA;        break;&#xA;    case 70: //F&#xA;        rp[8] = {0, 1, 0, 0, 0, 1, 1, 1};&#xA;        break;&#xA;    case 69: //E&#xA;        rp[8] = {0, 1, 0, 0, 1, 1, 1, 1};&#xA;        break;&#xA;    case 80: //P&#xA;        rp[8] = {0, 1, 1, 0, 0, 1, 1, 1};&#xA;        break;&#xA;    case 72: //H&#xA;        rp[8] = {0, 0, 1, 1, 0, 1, 1, 0};&#xA;        break;&#xA;            //DP, A, B, C, D, E, F, G&#xA;    case 45: //-&#xA;    default:&#xA;    rp[8] = {0, 0, 0, 0, 0, 0, 0, 1};&#xA;    break;&#xA;}&#xA;return rp;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this code does is to basicaly get an &lt;code&gt;int&lt;/code&gt; ad input and based on this number it returns an &lt;code&gt;int array&lt;/code&gt;. It's a very simple code which is called inside the &lt;code&gt;loop()&lt;/code&gt; method which is located on an other file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Also i'm using Atmel Studio 6 instead of the original Arduino IDE but i dont think it has to do something with the problem :/&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="6969" LastActivityDate="2015-04-23T19:39:59.303" Title="Arduino error in code" Tags="|arduino-uno|programming|sketch|c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10197" PostTypeId="2" ParentId="10196" CreationDate="2015-04-19T20:48:08.687" Score="2" Body="&lt;p&gt;What you try here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is only valid in C++11. (Before that you can initialize an array like this only upon initialization.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides, as pointed out by Pete Becker, you need to declare &lt;code&gt;rp&lt;/code&gt; as an array rather than a single &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-04-20T05:55:48.563" LastActivityDate="2015-04-20T05:55:48.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10198" PostTypeId="2" ParentId="10196" CreationDate="2015-04-19T22:35:08.973" Score="1" Body="&lt;p&gt;As &lt;code&gt;fuenfundachtzig&lt;/code&gt; said this cannot be done in this version of C++ Arduino uses. A replacement for this method is to set the number for each place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case 48:&#xA;    //rp[8] = {0, 1, 1, 1, 1, 1, 1, 0};&#xA;    rp[0] = 0;&#xA;    rp[1] = 1;&#xA;    rp[2] = 1;&#xA;    rp[3] = 1;&#xA;    rp[4] = 1;&#xA;    rp[5] = 1;&#xA;    rp[6] = 1;&#xA;    rp[7] = 0;  &#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works the same however it takes more space but i dont this there is a problem.&lt;/p&gt;&#xA;" OwnerUserId="6969" LastActivityDate="2015-04-19T22:35:08.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10200" PostTypeId="1" CreationDate="2015-04-20T13:43:22.387" Score="0" ViewCount="3440" Body="&lt;p&gt;I recently bought an Arduino Uno and installed everything necessary. I tried it on both USB ports on my computer. However, the Ports menu only shows COM1. There is a line on the bottom of the IDE which says Arduino Uno on COM1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any program I try fails to upload to the board. When I tried the Blink example, the following error message appeared:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.3 (Windows 7), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for&#xA;local variables. Maximum is 2,048 bytes.&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x43&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x43&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on. Until,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This report would have more information with&#xA;&quot;Show verbose output during compilation&quot; enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a Windows 7 64 bit desktop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8577" LastEditorUserId="6452" LastEditDate="2015-04-20T20:17:56.297" LastActivityDate="2015-05-21T23:00:02.520" Title="The IDE says my (brand new) Arduino UNO is on COM 1" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="10" FavoriteCount="0" ClosedDate="2015-05-21T23:20:18.040" ContentLicense="CC BY-SA 3.0" />
  <row Id="10202" PostTypeId="1" AcceptedAnswerId="10207" CreationDate="2015-04-20T15:33:59.713" Score="1" ViewCount="115" Body="&lt;p&gt;I'm designing a custom dual-uC board, where I want there to be two Arduinos both running different programs - kind of dual core arduino. In order to load new programs onto the uCs, yes, I could have two USB ports each connected to one of the uCs (say a ATmega32u4). But I'm trying to work out strategies with just one USB port (and no usb-hub).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't need the USB functionality for general use, only for program updates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switch access to each USB capable Arduino (e.g. ATmega32U). Program one uC, toggle switch, program other uC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: this is fine, however I ideally want to use zero additional end-user buttons - I want the end-user to do as little as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino UNO has two devices, ATmega16U2 and a ATmega328. During normal operation the 16U operates as a usb-to-serial. However, I'm aware that there are custom firmwares that allow different functionality (such as USB-Joystick etc) - it is possible to switch firmawares between a custom-firmware and default firmware, to allow the ATmega328 to be programmed normally but also to run the custom program. But it seems that Arduino.h doesn't support the ATmega16U2, so I would have to program this device using the AVR or another framework.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, the ATmega32U4 is supported by Arduino.h but there doesn't seem to be Arduino usb-serial 'firmware' for the 32U (only the 8U &amp;amp; 16U)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use a ATmega32u4 with Arduino-ISP programming an ATmega328p?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: above seems valid:&#xA;&lt;a href=&quot;https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/&quot; rel=&quot;nofollow&quot;&gt;https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other simple recommended approaches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: the firmware update should be physically as hands off as possible, as to be used by end-user, and preference for solutions that require zero additional buttons/etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the Arduino as ISP method (option 3), and it works&lt;/p&gt;&#xA;" OwnerUserId="8580" LastEditorUserId="8580" LastEditDate="2015-04-21T12:11:45.520" LastActivityDate="2015-04-21T12:11:45.520" Title="Uploading/Flashing different programs to two different Arduino uCs, using one USB" Tags="|uploading|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10204" PostTypeId="2" ParentId="10202" CreationDate="2015-04-20T16:16:23.223" Score="1" Body="&lt;p&gt;Option 1 using three header pins and a jumper wouldn't take up much board space, is simple to implement, and easy to use. Even easier if the jumper has a handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ZaOg.png&quot; alt=&quot;Pins &amp;amp; jumper&quot;&gt; &lt;img src=&quot;https://i.stack.imgur.com/YxwtF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-20T16:16:23.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10205" PostTypeId="2" ParentId="6456" CreationDate="2015-04-20T16:56:08.750" Score="0" Body="&lt;p&gt;I can think of 3 ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You could have the Base polling for updates to each node&#xA;sequentially, or&lt;/li&gt;&#xA;&lt;li&gt;If all child nodes see each other, node2 can hear when node1&#xA;finished transmitting so it can transmit and so on. Or&lt;/li&gt;&#xA;&lt;li&gt;You can punch through collisions setting random delays between each&#xA;retry&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3725" LastActivityDate="2015-04-20T16:56:08.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10206" PostTypeId="2" ParentId="10189" CreationDate="2015-04-20T16:57:50.933" Score="0" Body="&lt;p&gt;Thanks a lot, but anyway, I got an answer myself.&lt;br&gt;&#xA;I can use the simple delaymicroseconds( ) .&lt;br&gt;&#xA;Also, I can use timer interrupts to do basically the same thing&lt;br&gt;&#xA;And these are a lot less complicated than the other answers I got.&lt;/p&gt;&#xA;" OwnerUserId="8565" LastActivityDate="2015-04-20T16:57:50.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10207" PostTypeId="2" ParentId="10202" CreationDate="2015-04-20T17:15:39.147" Score="1" Body="&lt;p&gt;Provided that you are okay with producing a customized PC side tool (which you would probably want anyway for user convenience) automated target selection should be far superior to manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to use one ATmega16u2 with a  minimally customized firmware as a front end to program two distinct ATmega328p's.  This could be as simple as selecting the target based on the baud rate, having it hold the de-selected one in reset the whole time, and using some resistors on the shared TX lines for safety.  Last I checked the stock firmware used a soft serial at some rates, and that can be put on different pins, so it could be another way to de-conflict and select targets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your idea of using a 32u4 both as a functional part and as a buddy-programmer for another part is perfectly valid too - you can do that programming to a serial bootloader (it should be a simple matter to port the 16u2 firmware, or find another example), or via the ISP pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that I think about it, there's been a version of this question here before, as I remember writing about an idea for using two ATmega328p's permanently wired to a stock USB-serial, but with their bootloaders customized to use unique baud rates, and a little logic added so that on reset each would leave its serial TX pin tristated if it didn't detect bootloader traffic at its individually unique baudrate, thus allowing the other to be programmed without interference.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-04-20T18:07:11.853" LastActivityDate="2015-04-20T18:07:11.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10208" PostTypeId="1" AcceptedAnswerId="16922" CreationDate="2015-04-20T18:10:30.320" Score="0" ViewCount="5905" Body="&lt;p&gt;I think I made a mistake. Now, the 662k on my Arduino Uno very hot about 90°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I test it, it can be programmed and can run blink program normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a switch for voltage choose. Now, run in 3.3v mode get 2.8v and in 5v mode get 4.8v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 662k be replaced, can I use that Arduino normally in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zOAUA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8304" LastEditorUserId="8304" LastEditDate="2015-04-20T18:16:02.467" LastActivityDate="2015-10-17T20:56:08.377" Title="SMD Voltage Regulator 662k very hot, how to repair it?" Tags="|arduino-uno|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10209" PostTypeId="1" AcceptedAnswerId="10220" CreationDate="2015-04-20T18:46:22.853" Score="0" ViewCount="1176" Body="&lt;p&gt;I am trying to compile an Arduino program that takes analog input. However, when I declare multiple global variables, it often will not compile and because it throws an error that the variables aren't within scope of the functions within the program. I am not super familiar with Arduino IDE, but this doesn't programmatically make sense to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;*  By Hannah Perner-Wilson, www.plusea.at&#xA;*  Modified 3/30/2012 By Brian E Kaminski, www.AdvancerTechnologies.com&#xA;*&#xA;*  IMPORTANT!!:&#xA;*  Scroll down to set your serial port&#xA;*  Scroll down to set your thresholds&#xA;*/&#xA;&#xA;import processing.serial.*;&#xA;&#xA;// definition of window size&#xA;// you can change the size of the window as you like&#xA;// the thresholdGraph will be scaled to fit&#xA;// the optimal size for the thresholdGraph is 1000 x 400&#xA;int xWidth = 1200;&#xA;int yHeight = 750;&#xA;&#xA;// xPos input array, using prefix&#xA;int[] xPosArr= {0,0,0,0,0,0}; &#xA;&#xA;// &#xA;int[] messageArr= {0,0,0,0,0,0}; &#xA;&#xA;// Arrays for threshholding&#xA;int[] threshMax= {0,0,0,0,0,0}; &#xA;int[] threshMin= {0,0,0,0,0,0}; &#xA;&#xA;// variables for serial connection. portname and baudrate are user specific&#xA;Serial port1;&#xA;&#xA;//Set your serial port here (look at list printed when you run the application once)&#xA;String V3 = Serial.list()[1];&#xA;String portname1 = V3;&#xA;int baudrate = 9600;&#xA;&#xA;int prefix = 10001;&#xA;boolean myCatch = false;&#xA;String serialIN = &quot;&quot;;&#xA;String serialINPUT = &quot;&quot;; &#xA;String buffer = &quot;&quot;; &#xA;int value = 0; &#xA;&#xA;// ThresholdGraph draws grid and poti states&#xA;ThresholdGraph in;&#xA;&#xA;void setup(){&#xA;  // set size and framerate&#xA;  size(xWidth, yHeight);&#xA;  frameRate(25);&#xA;  background(255);&#xA;  strokeWeight(5);&#xA;  stroke(0);&#xA;  smooth();&#xA;  strokeCap(ROUND);&#xA;&#xA;  // establish serial port connection      &#xA;  port1 = new Serial(this, portname1, baudrate);&#xA;  port1.bufferUntil('\n') ;&#xA;  println(Serial.list());  // print serial list&#xA;&#xA;  // create DisplayItems object&#xA;  in = new ThresholdGraph();&#xA;&#xA;  // THRESHOLD VALUES:&#xA;  // using the thresholdGraph you can determine the MIN and MAX values&#xA;  // of your sensors. Enter these here. They must lie between 0 and 1000.&#xA;&#xA;    //MIN trashhold&#xA;    threshMin[0] = 20;   // one&#xA;    threshMin[1] = 20;   // two&#xA;    threshMin[2] = 20;   // three&#xA;    threshMin[3] = 20;   // four&#xA;    threshMin[4] = 20;   // five&#xA;    threshMin[5] = 20;   // six&#xA;&#xA;    //MAX trashhold&#xA;    threshMax[0] = 600;   // one&#xA;    threshMax[1] = 600;   // two&#xA;    threshMax[2] = 600;   // three&#xA;    threshMax[3] = 600;   // four&#xA;    threshMax[4] = 600;   // five&#xA;    threshMax[5] = 600;   // six&#xA;}//end setup&#xA;&#xA;// draw listens to serial port, draw &#xA;void draw(){&#xA;&#xA;  // listen to serial port and trigger serial event  &#xA;  while(port1.available() &amp;gt; 0){&#xA;        serialIN = port1.readStringUntil('\n');&#xA;        //println((int)float(serialIN));&#xA;        if(serialIN != &quot;&quot;)&#xA;          serialEvent(serialIN);  &#xA;        else&#xA;          Serial.println(&quot;found empty&quot;);&#xA;        }&#xA;&#xA;  // threshold serial input  &#xA;  threshHolding();  &#xA;&#xA;  // draw serial input&#xA;  in.update();&#xA;}//end draw()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error that are being thrown are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;testproject.ino:100:17: error: 'threshHolding' was not declared in this scope&#xA;testproject.ino:103:3: error: 'in' was not declared in this scope&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8604" OwnerDisplayName="rsheeler" LastEditorUserId="6452" LastEditDate="2015-04-20T20:18:44.040" LastActivityDate="2015-04-21T15:19:08.943" Title="Global Variable not able to be accessed in function?" Tags="|programming|variables|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="10210" PostTypeId="2" ParentId="10192" CreationDate="2015-04-20T20:13:05.897" Score="1" Body="&lt;p&gt;You've already got a lot of really good answers here but I thought I would offer another product suggestion.  I purchased some of the 12 pin versions of these &lt;a href=&quot;https://www.pololu.com/product/1031&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/product/1031&lt;/a&gt; for some recent projects.&lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-04-20T20:13:05.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10211" PostTypeId="1" AcceptedAnswerId="21030" CreationDate="2015-04-20T20:29:54.720" Score="2" ViewCount="135" Body="&lt;p&gt;Doing a little project for work and trying to get the Arduino hooked to an RC car to read the throttle channel output and send that via bluetooth to a nearby laptop which will output an animation based on that speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial test worked very well and signals from my airplane Tx were solid with very little variance. Once the proof of concept worked, we went ahead and purchased a Traxxas car. I have a wire going from pin 5 to the signal wire on the Rx. With the serial monitor up and arduino powered via my usb cable, the #s jump from the 1400 (where its supposed to be) to 6000 and sometimes 11000.  Even more interesting, is when I engaged the throttle via the transmitter, values went down to 30-50...?? I removed the Rx from the car and powered it via the 5v on arduino...#s are solid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it appears the battery or esc is giving a lot of interference. Do I need to use a different kind of wire? If so, what kind of wire? Or ground it somehow?&lt;/p&gt;&#xA;" OwnerUserId="8585" LastActivityDate="2016-02-23T21:48:07.093" Title="Signal noise on R/C car channel output" Tags="|remote-control|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10212" PostTypeId="1" CreationDate="2015-04-20T21:30:38.217" Score="-1" ViewCount="101" Body="&lt;p&gt;I want to create a motion sensored system, if the motion sensor detects motion it will make a speaker play a sound and a screen will record the time. This needs to be a loop that turns on for x number of hours and off for z number of hours. &#xA;Also, I need the speaker to loop through different sounds...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to this sort of programming so any help anyone can give me on how to write this code would be greatly appreciated, thanks.&lt;/p&gt;&#xA;" OwnerUserId="8588" LastActivityDate="2015-04-20T21:58:04.107" Title="Motion sensored speaker with display screen?" Tags="|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10213" PostTypeId="2" ParentId="10212" CreationDate="2015-04-20T21:58:04.107" Score="1" Body="&lt;p&gt;Good project idea...This breaks down very nicely into parts that you can build and test individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I would start with the blink example, this will be helpful when debugging the other parts and it will guarantee that you have everything setup and can program the Arduino with the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there's the actual pieces to get the project working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Play a Sound&#xA;*Display Information &#xA;*Record Time of Day&#xA;*Enable and Disable based on Elapsed Time or Time of Day&#xA;*Motion Sensing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To play a sound you have a couple of options.  The simplest would be to get a buzzer since you can control these right from an Arduino pin.  If you want to play a specific MP3 or wav file, you will need a slightly more involved setup.  Here is an example for playing a tone with a buzzer.  &lt;a href=&quot;http://www.arduino.cc/en/tutorial/tone&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/tutorial/tone&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the motion sensing you probably want a PIR sensor.  You can find them everywhere (Ebay, Sparkfun, Adafruit, Amazon, etc).  You can also google Arduino PIR Example.  Here is one result. &lt;a href=&quot;http://playground.arduino.cc/Code/PIRsense&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/PIRsense&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you've got those two bits working you can play a tone, when motion is detected.  Next is the display.  Outputting to an LCD is pretty easy.  There's a few ways to do this.  You may want to find a tutorial for the specific LCD screen that you decide to buy.  (While you are looking, check out the OLED screens from Adafruit, they are pretty neat).  Anyway, get the screen working in code by itself, then you can connect it to the rest of your system to print something when you trigger the motion sensor and play the tone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the timing...This is a little more involved.  The Arduino does not have a real time clock (RTC) so it can't tell the time.  You would have to get a separate RTC module and set the time on it.  I haven't worked with those before but...there are a few ways to interact with time.  If motion is triggered, you can check the time and if it is between the times that are valid (which you would define) then trigger the speaker, otherwise don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you can get the time from the RTC, you can display that information to the screen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should get you started.&lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-04-20T21:58:04.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10214" PostTypeId="1" CreationDate="2015-04-21T03:46:33.027" Score="1" ViewCount="114" Body="&lt;p&gt;I am new to electronics and learning how to play around with arduino. I recently purchased the Arduino ultimate GPS Logger, and despite also buying an external anntenae the GPS data shows that it does not fix at all. Despite leaving the unit powered for more than 5 minutes. Please advise on what could be wrong. Is it normal to take so long to get a GPS fix? This is the Arduino in question. &lt;a href=&quot;https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield/overview&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8593" LastActivityDate="2015-04-21T03:54:35.477" Title="Arduino Ultimate GPS Logger Issue" Tags="|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10215" PostTypeId="2" ParentId="10214" CreationDate="2015-04-21T03:54:35.477" Score="1" Body="&lt;p&gt;This style of antenna can be very finicky.  GPS on this module may take 15 or 30 minutes to lock, not just 5.  I would suggest you take this outside away from any walls or buildings and see if it will lock then.  I also suggest that you run it off a battery.  (one of those USB battery packs for charging your phone will work great).  Once you get a lock try changing one variable at a time (power supply / location) and see if you can get it to look again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason this module takes longer to lock than your cellphone is that your cellphone is cheating by doing a warmstart.  The cellphone can get a semi-accurate time/date and also your regional location.  This warm start data improves GPS lock time down to 5 seconds or less sometimes.&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-04-21T03:54:35.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10216" PostTypeId="2" ParentId="4274" CreationDate="2015-04-21T05:29:29.800" Score="-1" Body="&lt;p&gt;if your design allows , the NFC is available on a module rather than a shield allowing you to separate the GSM and NFC. like &lt;a href=&quot;http://www.ebay.co.uk/itm/New-RC522-Card-Read-Antenna-RFID-Reader-IC-Card-NFC-TAG-Keychain-Arduino-Kit-/331252663260?pt=LH_DefaultDomain_3&amp;amp;hash=item4d203283dc&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; on ebay&lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-04-21T05:29:29.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10218" PostTypeId="1" CreationDate="2015-04-21T14:16:56.420" Score="1" ViewCount="281" Body="&lt;p&gt;I have some level of programming background, however never with Arduino's. I've just started hacking at the examples - I'm not even sure what language I'm currently writing. I presume it's C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I figured I'd try out the pin 13 LED with the BlinkWithoutDelay example. I've got that running fine (which I was very excited about), however I've tried to modify it to blink out SOS in Morse code, but it doesn't appear to be working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// constants won't change. Used here to set a pin number :&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// Variables will change :&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;&#xA;// Generally, you should use &quot;unsigned long&quot; for variables that hold time&#xA;// The value will quickly become too large for an int to store&#xA;unsigned long previousMillis = 0;        // will store last time LED was updated&#xA;&#xA;// constants won't change :&#xA;//unsigned long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;// Number of times to blink&#xA;const long blinkMax = 10;&#xA;// Counter for number of times blinked&#xA;unsigned long blinkCount = 0;&#xA;&#xA;void setup() {&#xA;  // set the digital pin as output:&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int loopCount = 0;&#xA;  // S O S&#xA;  int values[] = {1000, 1000, 1000, 200, 200, 200, 1000, 1000, 100};&#xA;  blink(values[loopCount]);&#xA;  loopCount = loopCount + 1;&#xA;}&#xA;&#xA;void blink(int interval)&#xA;{&#xA;  unsigned long currentMillis = millis();&#xA;  if(currentMillis - previousMillis &amp;gt;= interval) {&#xA;    previousMillis = currentMillis;   &#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I've assigned the time values (1000 for long and 200 for short) to an array and had the loop function call my blink function each time. Every time it loops, it increments and goes to the next value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's able to pull values from the array fine, as I've tried manually modifying loopCount just before the blink() and it blinks at the specified timeout. I presume the loopCount increment is fine (I also did loopCount++; - no luck).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could point me in the right direction, this would be great. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8602" LastActivityDate="2015-04-21T20:17:43.803" Title="Debugging modified BlinkWithoutDelay" Tags="|arduino-uno|programming|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10219" PostTypeId="2" ParentId="10218" CreationDate="2015-04-21T15:04:37.917" Score="1" Body="&lt;p&gt;&lt;strike&gt;Since it's blink without delay, the next loop will happen immediately. Not after the blink function is don't. So &lt;code&gt;loopCount&lt;/code&gt; will increment continuously. You don't limit loopCount to 9, so it will after a few milliseconds try to access, e.g. &lt;code&gt;values[12]&lt;/code&gt; which doesn't exist.&lt;/strike&gt; (see @jfpoilpret's comment)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// constants won't change. Used here to set a pin number :&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// Variables will change :&#xA;int ledState = LOW;             // ledState used to set the LED&#xA;&#xA;// Generally, you should use &quot;unsigned long&quot; for variables that hold time&#xA;// The value will quickly become too large for an int to store&#xA;unsigned long previousMillis = 0;        // will store last time LED was updated&#xA;int blinkValues[] = {1000, 1000, 1000, 200, 200, 200, 1000, 1000, 100};&#xA;int loopCount = 0;&#xA;&#xA;&#xA;// constants won't change :&#xA;//unsigned long interval = 1000;           // interval at which to blink (milliseconds)&#xA;&#xA;// Number of times to blink&#xA;const long blinkMax = 10;&#xA;// Counter for number of times blinked&#xA;unsigned long blinkCount = 0;&#xA;&#xA;void setup() {&#xA;  // set the digital pin as output:&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  blink();&#xA;}&#xA;&#xA;void blink()&#xA;{&#xA;  unsigned long currentMillis = millis();&#xA;  if(currentMillis - previousMillis &amp;gt;= blinkValues[loopCount]) {&#xA;    previousMillis = currentMillis;   &#xA;    loopCount = (loopCount + 1) % 9;&#xA;    if (ledState == LOW)&#xA;      ledState = HIGH;&#xA;    else&#xA;      ledState = LOW;&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also note that the blink function will &lt;strong&gt;toggle&lt;/strong&gt; the led, after the interval. So you need to add intervals, for how long the led should be off between flashes. But I leave that for you to figure out.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-04-21T20:17:43.803" LastActivityDate="2015-04-21T20:17:43.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10220" PostTypeId="2" ParentId="10209" CreationDate="2015-04-21T15:19:08.943" Score="2" Body="&lt;p&gt;The problem is that this is not an Arduino Sketch, but a processing file which is noted by the initial import statement that is Java based. Because the Arduino IDE is not very sophisticated, it didn't shout out obvious errors such as &lt;code&gt;import type not defined&lt;/code&gt; or even &lt;code&gt;ThresholdGraph&lt;/code&gt; not defined. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use this file it is necessary to use the following IDE: &lt;a href=&quot;https://processing.org/reference/environment/&quot; rel=&quot;nofollow&quot;&gt;https://processing.org/reference/environment/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8604" LastActivityDate="2015-04-21T15:19:08.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10223" PostTypeId="1" CreationDate="2015-04-21T19:02:16.783" Score="1" ViewCount="1478" Body="&lt;p&gt;Note: I'm using just the atmega chip and atmel studio. Not exactly a full arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using the atmega168 with a MAX17040 fuel gauge in a project. The I2C interface between the atmel and the fuel gauge is working fine and I am able to read data from the fuel gauge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the power requirement of the project, the fuel gauge requires its compensation value to be adjusted. This is a 16 bit register, so according to the manufacturer I have to write 0x1234 across address 0x0C and 0X0D in one go. Otherwise the values are discarded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the datasheet and online forums talk about 8-bit I2C addressing (which I have working), but instruction on addressing 16 bit register is limited. I was wondering if anyone can help me on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My basic code is pasted below. The I2C_start takes care of TWCR, TWDR, etc. It could be something to do with Repated_Start, but not sure.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t I2C_write_register(uint8_t device, uint8_t address, uint8_t value)&#xA;{&#xA;    device &amp;lt;&amp;lt;= 1;&#xA;&#xA;    uint8_t ret = I2C_start(device | TW_WRITE);&#xA;    if (ret)&#xA;        return 1;&#xA;&#xA;    if (!ret)&#xA;        ret = I2C_write(address);&#xA;    if (!ret)&#xA;        ret = I2C_write(value);&#xA;    I2C_stop();&#xA;&#xA;    return ret;&#xA;}&#xA;&#xA;uint8_t I2C_start(uint8_t address){&#xA;    // reset TWI control register&#xA;    TWCR = 0;&#xA;    // transmit START condition&#xA;    TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);&#xA;    // wait for end of transmission&#xA;    while( !(TWCR &amp;amp; _BV(TWINT)) );&#xA;&#xA;    // check if the start condition was successfully transmitted&#xA;    if((TWSR &amp;amp; 0xF8) != TW_START){ return 1; }&#xA;&#xA;    // load slave address into data register&#xA;    TWDR = address;&#xA;    // start transmission of address&#xA;    TWCR = _BV(TWINT) | _BV(TWEN)|_BV(TWEA); //|_BV(TWEA) added&#xA;    // wait for end of transmission&#xA;    while( !(TWCR &amp;amp; _BV(TWINT)) );&#xA;&#xA;    // check if the device has acknowledged the READ / WRITE mode&#xA;    uint8_t twst = TW_STATUS &amp;amp; 0xF8;&#xA;    if ( (twst != TW_MT_SLA_ACK) &amp;amp;&amp;amp; (twst != TW_MR_SLA_ACK) ) return 1;&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastEditorUserId="3925" LastEditDate="2015-04-21T19:15:44.043" LastActivityDate="2015-04-21T21:46:10.043" Title="16 bit register addressing through i2c" Tags="|i2c|atmega328|atmel-studio|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10224" PostTypeId="1" AcceptedAnswerId="10227" CreationDate="2015-04-21T19:07:20.740" Score="2" ViewCount="313" Body="&lt;p&gt;Let's say that I use a 5V Arduino board, and I set AREF to 3V, thus 0-3V equals to 0-1023 of the analog inputs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I exceed the AREF voltage, powering an analog pin with 4V, could that damage the analog input pin? If not, what would be the reading?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.  &lt;/p&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="2881" LastEditDate="2015-04-21T20:19:59.260" LastActivityDate="2015-04-21T20:26:00.237" Title="Exceed AREF voltage" Tags="|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10225" PostTypeId="2" ParentId="10088" CreationDate="2015-04-21T19:24:40.210" Score="3" Body="&lt;p&gt;Yet another way to answer this is to state the Serial.write accepts single characters where Serial.print accepts strings. There may be some differences but this is the main one.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-04-21T19:24:40.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10226" PostTypeId="2" ParentId="10005" CreationDate="2015-04-21T19:44:35.313" Score="0" Body="&lt;p&gt;I'm not sure what the answer is or why no one has addressed the second part of your question. To calculate current you need to know voltage and resistance (I=E/R). The ADC is giving you the voltage but I don't know what value to use for resistance in order to calculate the current. I do better with digital electronics but I suspect you might be able to use a resistor divider network to measure the voltage drop across a known resistor to measure current but do not take my word for this.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-04-21T19:44:35.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10227" PostTypeId="2" ParentId="10224" CreationDate="2015-04-21T20:15:56.303" Score="2" Body="&lt;p&gt;The reading would saturate at 1023 when the voltage on the input pin exceeds AREF. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet (for the ATmega328P) states as absolute maximum rating for the &quot;Voltage on any Pin except -RESET with respect to Ground&quot; V&lt;sub&gt;CC&lt;/sub&gt; + 0.5 V. So applying 4 V to AREF for a 5 V Arduino board should not (necessarily) damage the ATmega. (But you also won't be able to extend the 10-bit resolution range, if that is what you're after...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, choose the reference voltage above the maximum expected voltage.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-04-21T20:26:00.237" LastActivityDate="2015-04-21T20:26:00.237" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10228" PostTypeId="2" ParentId="10223" CreationDate="2015-04-21T21:46:10.043" Score="1" Body="&lt;p&gt;Ahh, was just able to solve it. Essentially, do not use TW_REPEATED_START. Just keep sending data 8 bit at a time. 1 bit at the beginning of each 8 bit will be lost, so make sure you shift them first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire library uses a very similar concept for use with arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t I2C_write_register(uint8_t device, uint8_t address, uint8_t value, uint8_t value)&#xA;{&#xA;    device &amp;lt;&amp;lt;= 1;&#xA;&#xA;    uint8_t ret = I2C_start(device | TW_WRITE);&#xA;    if (ret)&#xA;        return 1;&#xA;&#xA;    if (!ret)&#xA;        ret = I2C_write(address);&#xA;    if (!ret)&#xA;        ret = I2C_write(value);&#xA;    if (!ret)&#xA;        ret = I2C_write(value2);&#xA;    I2C_stop();&#xA;&#xA;    return ret;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastActivityDate="2015-04-21T21:46:10.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10230" PostTypeId="1" AcceptedAnswerId="10250" CreationDate="2015-04-21T22:15:56.623" Score="1" ViewCount="1180" Body="&lt;p&gt;I want to work with interrupts and heard that the watchdog timer is effective way to deal with them.  I haven't been able to find a good tutorial on them though and was wondering if someone could head me in the right direction or give me a couple tips and an example.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-22T16:05:20.683" Title="Arduino Watchdog Timer" Tags="|arduino-uno|interrupt|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10231" PostTypeId="2" ParentId="10200" CreationDate="2015-04-21T22:26:54.120" Score="0" Body="&lt;p&gt;Here are a few troubleshooting tips:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First check if the board is listed as Arduino Uno in the IDE by going to Tools --&gt; Board&lt;/li&gt;&#xA;&lt;li&gt;Check this &lt;a href=&quot;http://redhotengineer.blogspot.com/2014/11/my-fight-with-avrdude-stk500getsync-not.html&quot; rel=&quot;nofollow&quot;&gt;site&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Also, try reinstalling the driver.&lt;/li&gt;&#xA;&lt;li&gt;Check your cable.&lt;/li&gt;&#xA;&lt;li&gt;As a last resort you can try re uploading the bootloader.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-21T22:26:54.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10233" PostTypeId="1" CreationDate="2015-04-21T22:53:30.767" Score="2" ViewCount="245" Body="&lt;p&gt;I am trying to post temperature measurements from DS18b20 thermal sensors to an online repository using a cc3000 WiFi shield on an Arduino Mega.  It works great, once.  All the temperatures get read fine. Then I post the data. Then the temperatures all return -127 error values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I fix the temperatures to const values, I can send any amount of data over wifi. If I don't send the data over wifi, I can pull temperatures indefinitely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't imagine anyone is set up to test this or has a good way to debug it, so I am open to wild speculation- Any guesses what is going wrong? Any suggestions on how to debug it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define temppin 53&#xA;&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;#define ADAFRUIT_CC3000_VBAT  5  // any pin&#xA;#define ADAFRUIT_CC3000_CS    10  // any pin&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                                     SPI_CLOCK_DIVIDER); // you can change this clock speed but DI&#xA;&#xA;#define WLAN_SSID       &quot;MyNetwork&quot;        // cannot be longer than 32 characters!&#xA;#define WLAN_PASS       &quot;mypassword&quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;uint32_t dweetioIp = 0;&#xA;char c;&#xA;unsigned long lastpost = 15000L;&#xA;&#xA;OneWire oneWire(temppin);&#xA;DallasTemperature sensors(&amp;amp;oneWire);  // Pass our oneWire reference to Dallas Temperature.&#xA;&#xA;DeviceAddress TS1 = {0x28, 0xFF, 0xB4, 0x5E, 0x68, 0x14, 0x03, 0x60};  // serial numbers&#xA;DeviceAddress TS2 = {0x28, 0xFF, 0xFE, 0x4F, 0x68, 0x14, 0x02, 0xDD};  // for DS18b20's&#xA;DeviceAddress TS3 = {0x28, 0xFF, 0x3D, 0x5C, 0x68, 0x14, 0x03, 0x5F};&#xA;DeviceAddress TS4 = {0x28, 0xFF, 0x16, 0x5C, 0x68, 0x14, 0x03, 0xD7};&#xA;DeviceAddress TS5 = {0x28, 0xFF, 0xA3, 0x62, 0x51, 0x14, 0x04, 0xC4};&#xA;DeviceAddress TS6 = {0x28, 0xFF, 0xA9, 0x61, 0x68, 0x14, 0x03, 0x22};&#xA;DeviceAddress TS7 = {0x28, 0xFF, 0x2A, 0x72, 0x68, 0x14, 0x03, 0x17};&#xA;DeviceAddress TS8 = {0x28, 0xFF, 0xD2, 0x61, 0x68, 0x14, 0x03, 0x3F};&#xA;DeviceAddress TS9 = {0x28, 0xFF, 0xFA, 0x43, 0x68, 0x14, 0x02, 0xD0};&#xA;DeviceAddress TS10 = {0x28, 0xFF, 0x0B, 0x63, 0x68, 0x14, 0x02, 0xCB};&#xA;DeviceAddress TS11 = {0x28, 0xFF, 0x97, 0x41, 0x68, 0x14, 0x02, 0x2A};&#xA;DeviceAddress TS12 = {0x28, 0xFF, 0x47, 0x7E, 0x68, 0x14, 0x03, 0xF8};&#xA;&#xA;DeviceAddress TS16 = {0x28, 0xC8, 0x47, 0x15, 0x06, 0x00, 0x00, 0xF0};&#xA;&#xA;float t1;&#xA;float t2;&#xA;float t3;&#xA;float t4;&#xA;float t5;&#xA;float t6;&#xA;float t7;&#xA;float t8;&#xA;float t9;&#xA;float t10;&#xA;float t11;&#xA;float t12;&#xA;float t13;&#xA;&#xA;String command = &quot;&quot;;&#xA;boolean stringComplete = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  sensors.begin();&#xA;&#xA;  pinMode(temppin, INPUT);&#xA;&#xA;  // Initialize wifi shield&#xA;  if (!cc3000.begin()) {&#xA;    Serial.println(F(&quot;\n\nFailed to initialize WiFi shield.&quot;));&#xA;  }&#xA;  Serial.println(F(&quot;\n\nInitialized WiFi shield&quot;));&#xA;&#xA;  // Connect to wifi network&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed to connect to WiFi network&quot;));&#xA;  }&#xA;  Serial.print(F(&quot;Connected to &quot;));&#xA;  Serial.println(F(WLAN_SSID));&#xA;&#xA;  // Wait for DHCP to complete (get an IP address)&#xA;  while (!cc3000.checkDHCP()) {&#xA;    delay(1000);&#xA;    Serial.println(F(&quot;Waiting to get IP address&quot;));&#xA;  }&#xA;  Serial.println(F(&quot;Got an IP address\n&quot;));&#xA;&#xA;  // Connect to dweet.io&#xA;  while (dweetioIp == 0) {&#xA;    if (! cc3000.getHostByName(&quot;dweet.io&quot;, &amp;amp;dweetioIp)) {&#xA;      Serial.println(F(&quot;Failed to resolve dweetio website&quot;));&#xA;    }&#xA;    delay(500);&#xA;    Serial.println(F(&quot;Resolving dweetio website&quot;));&#xA;  }&#xA;  Serial.print(&quot;Accessed dweetio website at IP address: &quot;);&#xA;  cc3000.printIPdotsRev(dweetioIp);  &#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;  // Get temperatures&#xA;  sensors.requestTemperatures();&#xA;  delay(1000);&#xA;  t1 = sensors.getTempC(TS1);&#xA;  t2 = sensors.getTempC(TS2);&#xA;  t3 = sensors.getTempC(TS3);&#xA;  t4 = sensors.getTempC(TS4);&#xA;  t5 = sensors.getTempC(TS5);&#xA;  t6 = sensors.getTempC(TS6);&#xA;  t7 = sensors.getTempC(TS7);&#xA;  t8 = sensors.getTempC(TS8);&#xA;  t9 = sensors.getTempC(TS9);&#xA;  t10 = sensors.getTempC(TS10);&#xA;  t11 = sensors.getTempC(TS11);&#xA;  t12 = sensors.getTempC(TS12);&#xA;  t13 = sensors.getTempC(TS16);   &#xA;&#xA;  Serial.println(t1);&#xA;  Serial.println(t2);&#xA;  Serial.println(t3);&#xA;  Serial.println(t4);&#xA;  Serial.println(t5);&#xA;  Serial.println(t6);&#xA;  Serial.println(t7);&#xA;  Serial.println(t8);&#xA;  Serial.println(t9);&#xA;  Serial.println(t10);&#xA;  Serial.println(t11);&#xA;  Serial.println(t12);&#xA;  Serial.println(t13);&#xA;&#xA;  long curmillis = millis();&#xA;  if (curmillis - lastpost &amp;gt; 1000*15L) {&#xA;    // Post data to dweetio&#xA;    char data[125];&#xA;    sprintf(data, &quot;?t1=%i&amp;amp;t2=%i&amp;amp;t3=%i&amp;amp;t4=%i&amp;amp;t5=%i&amp;amp;t6=%i&amp;amp;t7=%i&amp;amp;t8=%i&amp;amp;t9=%i&amp;amp;t10=%i&amp;amp;t11=%i&amp;amp;t12=%i&amp;amp;t13=%i&quot;, &#xA;            (int)(t1*10.),(int)(t2*10.),(int)(t3*10.),(int)(t4*10.),(int)(t5*10.),&#xA;            (int)(t6*10.),(int)(t7*10.),(int)(t8*10.),(int)(t9*10.),(int)(t10*10.),&#xA;            (int)(t11*10.),(int)(t12*10.),(int)(t13*10.));&#xA;    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);&#xA;    if (client.connected()) {&#xA;      client.fastrprint(F(&quot;GET &quot;));&#xA;      client.fastrprint(F(&quot;/dweet/for/testdweets&quot;));&#xA;      client.fastrprint(data);&#xA;      client.fastrprint(F(&quot; HTTP/1.1\r\n&quot;));&#xA;      client.fastrprint(F(&quot;Host: https://www.dweet.io\r\n&quot;));&#xA;      client.fastrprint(F(&quot;\r\n\r\n&quot;));&#xA;      // client.println();&#xA;      Serial.println(F(&quot;Sent dweet\n&quot;));&#xA;    } else {&#xA;      Serial.println(F(&quot;Sending dweet failed&quot;));&#xA;      return;&#xA;    }&#xA;&#xA;    /* Read data until either the connection is closed, or the idle timeout is reached. */ &#xA;    unsigned long lastRead = millis();&#xA;    while (client.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; 1000)) {&#xA;      while (client.available()) {&#xA;        char c = client.read();&#xA;        Serial.print(c);&#xA;        lastRead = millis();&#xA;      }&#xA;    }&#xA;&#xA;    client.close();&#xA;    Serial.println(&quot;Connection to dweet.io closed&quot;);&#xA;&#xA;    lastpost = millis();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7975" LastActivityDate="2015-04-21T22:53:30.767" Title="cc3000 WiFi distrupting DS18b20 temp measurements" Tags="|arduino-mega|wifi|temperature-sensor|1-wire|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10236" PostTypeId="1" AcceptedAnswerId="10237" CreationDate="2015-04-22T03:19:19.173" Score="9" ViewCount="8345" Body="&lt;p&gt;I just picked up a pair of Arduino Mini Pro 5v clone boards (Inland, sold at Microcenter, currently $4 USD) and I wanted to use my Uno as an ISP like I've done with ATmega328 and ATtiny85 chips before.  I've programmed the Uno with the instructions at &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoISP&quot;&gt;the ArduinoISP tutorial page&lt;/a&gt; and I've connected up the Uno to the Mini Pro using the instructions at &lt;a href=&quot;http://www.arduino.cc/en/Hacking/MiniBootloader&quot;&gt;this page&lt;/a&gt;.  I cannot get the Arduino IDE or avrdude from the command line to successfully program these boards no matter what I try.  Except that I can use the Arduino IDE to burn a new bootloader to the Mini Pro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected up the status LEDs as well (pins 7, 8 and 9), and I can see that the programmer has an error condition (pin 8) when I attempt to program anything besides the bootloader. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my avrdude command line where I tried to set the fuses on the Mini Pro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -P /dev/tty.usbmodema0121 -b 57600 -c avrisp -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xdb:m -U efuse:w:0xfd:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following back from avrdude:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've not had any problems with using pretty much this exact same setup, but with a ATmega328 or ATtiny85 chip on a breadboard with avrdude in the past, so I'm at a loss as to what is happening here.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also taken a look at the ArduinoISP code, and I'm not really sure what the resp=0x1c is.  I don't see a 0x1c value defined in the STK Definitions section of the code, so I'm not sure what might be causing this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers here would be appreciated. And yes, I do know that I can use the Uno board with the ATmega328 chip pulled to use as a programmer as well.  But I want to be able to overwrite the bootloader area with my own code like I can with a regular ATmega328 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8613" LastActivityDate="2015-04-22T03:42:02.883" Title="Problem programming Mini Pro via Arduino as ISP" Tags="|arduino-pro-mini|avrdude|isp|clones|arduinoisp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10237" PostTypeId="2" ParentId="10236" CreationDate="2015-04-22T03:42:02.883" Score="7" Body="&lt;p&gt;After poking around for a bit more, it turns out my problem was the baud rate.  I could make it work by setting it to 19200, just a little slower.  Alternatively, you can modify the ArduinoISP sketch to enable higher baud rates.  I used &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=48784.5&quot;&gt;this post&lt;/a&gt; to enable 115200 baud and I was able to successfully use avrdude at the higher rates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure how I missed this before, but it's an easy to solve at least.&lt;/p&gt;&#xA;" OwnerUserId="8613" LastActivityDate="2015-04-22T03:42:02.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10238" PostTypeId="1" CreationDate="2015-04-22T07:14:09.603" Score="5" ViewCount="574" Body="&lt;p&gt;If I want to design an Arduino-compatible board I guess I'll have to use the same outline, and connector positions to fit existing enclosures. (Beats me why they didn't choose a simple rectangular board, which would have been cheaper.) But I wonder if the ICSP header's position is standardized. Some enclosures have a hole above it, but many don't. Can I move the ICSP header to another position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(Can somebody add a &quot;compatibility&quot; tag? Thanks. Also, neither &quot;mechanical&quot; nor &quot;board&quot; nor &quot;layout&quot; seem to exist as tags. Feel free to improve my generic tagging.)&lt;br&gt;&#xA;The &quot;shield&quot; tag was suggested, but this isn't about shields, it's about the ICSP header.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="313" LastEditDate="2015-04-22T11:45:41.793" LastActivityDate="2015-04-27T18:32:00.303" Title="Mechanical requirements for Arduino compatibility" Tags="|arduino-uno|mechanical|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10239" PostTypeId="2" ParentId="10187" CreationDate="2015-04-22T09:10:28.287" Score="1" Body="&lt;p&gt;The print(&quot;aString&quot;) method prints just the string &quot;aString&quot;, but does not move the cursor to a new line. Hence, subsequent printing instructions will print on the same line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The println(&quot;aString&quot;) method prints the string &quot;aString&quot; and moves the cursor to a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The println() method can also be used without parameters, to position the cursor on the next line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards&lt;/p&gt;&#xA;" OwnerUserId="675" LastActivityDate="2015-04-22T09:10:28.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10240" PostTypeId="2" ParentId="10230" CreationDate="2015-04-22T09:28:15.840" Score="1" Body="&lt;p&gt;Since you talk about the watchdog I presume you want timer interrupts. (There are also I/O interrupts, for instance when the level of a pin changes state.)&#xA;Like Russell McMahon says the watchdog is not a good source. The ATmega has several timers (8-bit and 16-bit) which serve your exact purpose. Let's view some example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// timer interrupts&#xA;// adapted from code by Amanda Ghassaei&#xA;// June 2012&#xA;// http://www.instructables.com/id/Arduino-Timer-Interrupts/&#xA;&#xA;/*&#xA; * This program is free software; you can redistribute it and/or modify&#xA; * it under the terms of the GNU General Public License as published by&#xA; * the Free Software Foundation; either version 3 of the License, or&#xA; * (at your option) any later version.&#xA; *&#xA;*/&#xA;&#xA;// timer setup for timer0, timer1, and timer2.&#xA;// For arduino uno or any board with ATMEL 328/168.. diecimila,&#xA;// duemilanove, lilypad, nano, mini...&#xA;&#xA;// this code will enable all three arduino timer interrupts.&#xA;// timer0 will interrupt at 2kHz&#xA;// timer1 will interrupt at 1Hz&#xA;// timer2 will interrupt at 10kHz&#xA;&#xA;// storage variables&#xA;boolean toggle0 = 0;&#xA;boolean toggle1 = 0;&#xA;boolean toggle2 = 0;&#xA;&#xA;void setup() {&#xA;&#xA;  // set pins as outputs&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  cli(); // stop interrupts&#xA;&#xA;  // set timer0 interrupt at 2kHz&#xA;  TCCR0A = 0; // set entire TCCR2A register to 0&#xA;  TCCR0B = 0; // same for TCCR2B&#xA;  TCNT0  = 0; // initialize counter value to 0&#xA;  // set compare match register for 2khz increments&#xA;  OCR0A = 124; // = (16*10^6) / (2000*64) - 1 (must be &amp;lt;256)&#xA;  // turn on CTC mode&#xA;  TCCR0A |= (1 &amp;lt;&amp;lt; WGM01);&#xA;  // Set CS01 and CS00 bits for 64 prescaler&#xA;  TCCR0B |= (1 &amp;lt;&amp;lt; CS01) | (1 &amp;lt;&amp;lt; CS00);   &#xA;  // enable timer compare interrupt&#xA;  TIMSK0 |= (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&#xA;  // set timer1 interrupt at 1Hz&#xA;  TCCR1A = 0; // set entire TCCR1A register to 0&#xA;  TCCR1B = 0; // same for TCCR1B&#xA;  TCNT1  = 0; // initialize counter value to 0&#xA;  // set compare match register for 1hz increments&#xA;  OCR1A = 15624; // = (16*10^6) / (1*1024) - 1 (must be &amp;lt;65536)&#xA;  // turn on CTC mode&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS12 and CS10 bits for 1024 prescaler&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS10);  &#xA;  // enable timer compare interrupt&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;  // set timer2 interrupt at 10kHz&#xA;  TCCR2A = 0; // set entire TCCR2A register to 0&#xA;  TCCR2B = 0; // same for TCCR2B&#xA;  TCNT2  = 0; // initialize counter value to 0&#xA;  // set compare match register for 8khz increments&#xA;  OCR2A = 199;// = (16*10^6) / (10000*8) - 1 (must be &amp;lt;256)&#xA;  // turn on CTC mode&#xA;  TCCR2A |= (1 &amp;lt;&amp;lt; WGM21);&#xA;  // Set CS21 bit for 8 prescaler&#xA;  TCCR2B |= (1 &amp;lt;&amp;lt; CS21);   &#xA;  // enable timer compare interrupt&#xA;  TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A);&#xA;&#xA;  sei(); // enable interrupts&#xA;&#xA;} // end setup&#xA;&#xA;ISR(TIMER0_COMPA_vect){ // timer0 interrupt 2kHz toggles pin 8&#xA;  // generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles &#xA;  // for full wave- toggle high then toggle low)&#xA;  toggle0 = HIGH - toggle0;&#xA;  digitalWrite(8, toggle0);&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect) { // timer1 interrupt 1Hz toggles pin 13 (LED)&#xA;  // generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles&#xA;  // for full wave- toggle high then toggle low)&#xA;  toggle1 = HIGH - toggle1;&#xA;  digitalWrite(13, toggle1);&#xA;}&#xA;&#xA;ISR(TIMER2_COMPA_vect) { // timer1 interrupt 10kHz toggles pin 9&#xA;  // generates pulse wave of frequency 10kHz/2 = 5kHz (takes two cycles &#xA;  // for full wave- toggle high then toggle low)&#xA;  toggle2 = HIGH - toggle2;&#xA;  digitalWrite(9, toggle2);&#xA;}&#xA;&#xA;void loop() {&#xA;  // do other things here &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets up 3 different timers: one at 500 &amp;micro;s, one at 1 s, one at 100 &amp;micro;s. For the details about each timer, look up the registers in the datasheet.&lt;br&gt;&#xA;With each timer goes a timer interrupt service routine (ISR). These perform the action required when an interrupt occurs. It's a good practice to exit an ISR as quickly as possible. Only do the things which are really time-critical, but for the rest set a flag to indicate that the interrupt occurred. Then in the main loop you continuously check that flag, and when it is set, perform the necessary actions. Don't forget to clear the flag when you're done. &lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-22T09:28:15.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10241" PostTypeId="1" CreationDate="2015-04-22T10:43:45.353" Score="2" ViewCount="482" Body="&lt;p&gt;Is there any good quality GSM shield compatible with Arduino Due?&#xA;I have searched for gsm shield but it seems all shields have operation voltage 5v.&#xA;Any suggestion would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="8619" LastEditorUserId="6452" LastEditDate="2015-04-22T13:31:56.170" LastActivityDate="2016-04-28T18:44:48.483" Title="GSM shield for Arduino Due" Tags="|shields|gsm|arduino-due|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10243" PostTypeId="1" CreationDate="2015-04-22T11:21:00.640" Score="2" ViewCount="2392" Body="&lt;p&gt;I have build a simple voltage divider with a light resistor and a 5.6k resistor. I am reading the input on A0 on my arduino board but it is almost always at 1023, independent of light. If I cover it it might go down to 1020 but not more than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to use a greater resistor than 5.6k to achieve more difference in the sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The light sensor is similar to this: &lt;a href=&quot;http://www.ebay.com/itm/20x-5549CDS-Photo-Light-Dependent-Sensitive-Resistor-Photoresistor-LDR-Photocell-/281425650814?pt=LH_DefaultDomain_0&amp;amp;hash=item418646a47e&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/20x-5549CDS-Photo-Light-Dependent-Sensitive-Resistor-Photoresistor-LDR-Photocell-/281425650814?pt=LH_DefaultDomain_0&amp;amp;hash=item418646a47e&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the resistance is pending between 1k-10k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit is like this image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AXZiT.png&quot; alt=&quot;Voltage divider&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where Vin is 5V from the arduino. R1 is the light sensor, R2 is 5.6k and Vout is connected to A0.&lt;/p&gt;&#xA;" OwnerUserId="4912" LastEditorUserId="4912" LastEditDate="2015-04-22T14:55:44.603" LastActivityDate="2015-11-19T06:43:35.287" Title="Light sensor always getting max value" Tags="|arduino-mini|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10244" PostTypeId="1" CreationDate="2015-04-22T11:41:29.563" Score="0" ViewCount="9506" Body="&lt;p&gt;The error shown is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp/core.a(Tone.cpp.o): In function `__vector_7':&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of `__vector_7'&#xA;C:\Users\SIDDHA~1\AppData\Local\Temp\build3397782103973366883.tmp\IRremote\IRremote.cpp.o:C:\Users\Siddharth Yadav\Documents\Arduino\libraries\IRremote/IRremote.cpp:361: first defined here&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uydI1.png&quot; alt=&quot;Error snapshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;const int echo = 7;// connected to ultrasonic sensor's echo&#xA;const int trig = 8;// connected to ultrasonic sensor's trig&#xA;const int Right1 = 10;&#xA;const int Right2 = 11;&#xA;const int Left1 = 12;&#xA;const int Left2 = 9;// change this to any other pin; except pin 13&#xA;const int buzzer = 5;&#xA;const int rightIR = 3;// change here&#xA;const int leftIR = 2;// change here&#xA;int RECV_PIN = 4;&#xA;const int forward = 51;&#xA;const int backward = 36;&#xA;const int left = 19;&#xA;const int right = 0;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;decode_results results;&#xA;&#xA;void setup() {&#xA;  pinMode(buzzer, OUTPUT);&#xA;  pinMode(echo, INPUT_PULLUP);&#xA;  pinMode(rightIR, INPUT_PULLUP);&#xA;  pinMode(leftIR, INPUT_PULLUP);&#xA;  pinMode(trig, OUTPUT);&#xA;  pinMode(Right1, OUTPUT);&#xA;  pinMode(Right2, OUTPUT);&#xA;  pinMode(Left1, OUTPUT);&#xA;  pinMode(Left2, OUTPUT);&#xA;  sing(1);&#xA;  Serial.begin(9600);&#xA; irrecv.enableIRIn(); // Start the receiver&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);&#xA;  if (calcDistance() &amp;gt; 30 &amp;amp;&amp;amp; !isRight() &amp;amp;&amp;amp; !isLeft())&#xA;  {&#xA;    if (irrecv.decode(&amp;amp;results))&#xA;    {&#xA;      Serial.println(results.value, HEX);&#xA;      irrecv.resume(); // Receive the next value&#xA;      delay(50);&#xA;    }&#xA;    else {&#xA;      moveForward();&#xA;    }&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;    delay(10);&#xA;    int dist = calcDistance();&#xA;    if (dist &amp;lt; 30 &amp;amp;&amp;amp; isLeft() &amp;amp;&amp;amp; isRight())&#xA;    {&#xA;      Serial.println(&quot;Moving backward&quot;);&#xA;      tone(buzzer, 4699, 10);&#xA;      moveBackward();&#xA;      delay(1000);&#xA;    }&#xA;    else if (isLeft())&#xA;    {&#xA;      turnRight();&#xA;      digitalWrite(13, LOW);&#xA;      tone(buzzer, 104, 10);&#xA;      Serial.println(&quot;Turning Right&quot;);&#xA;    }&#xA;    else if (isRight())&#xA;    {&#xA;      turnLeft();&#xA;      digitalWrite(13, LOW);&#xA;      delay(300);&#xA;      tone(buzzer, 880, 10);&#xA;      Serial.println(&quot;Turning LEft&quot;);&#xA;    }&#xA;    else if (dist &amp;lt; 30)&#xA;    {&#xA;      turnRight();&#xA;      digitalWrite(13, LOW);&#xA;      tone(buzzer,  104 , 10);&#xA;      Serial.println(&quot;Turning Right&quot;);&#xA;    }&#xA;&#xA;  }&#xA;&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8620" LastEditorUserId="8620" LastEditDate="2015-04-22T12:18:57.637" LastActivityDate="2016-04-17T00:09:54.413" Title="Error in Compiling" Tags="|programming|remote-control|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10245" PostTypeId="2" ParentId="10244" CreationDate="2015-04-22T12:14:36.470" Score="1" Body="&lt;p&gt;As the error message says you have multiple definitions of __vector_7 which is defined in: IRemote.cpp:361 and Tone.cpp:536&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tone.cpp is arduino standart lib. If IRemote is a lib of yours then you should edit the cpp file and change the symbol to sth else.&lt;/p&gt;&#xA;" OwnerUserId="8622" LastEditorUserId="8622" LastEditDate="2015-04-22T12:21:41.397" LastActivityDate="2015-04-22T12:21:41.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10247" PostTypeId="2" ParentId="10244" CreationDate="2015-04-22T13:43:56.457" Score="1" Body="&lt;p&gt;The IRemote.cpp and Tone.cpp would be using the same interrupt vector. I believe it's &lt;code&gt;ISR(TIMER5_COMPA_vect) {&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You could. I don't think it's the best solution, but go to Tone.cpp and comment the &lt;code&gt;ISR(TIMER5_COMPA_vect) {&lt;/code&gt; like &lt;code&gt;/*ISR(TIMER5_COMPA_vect)*/void XunusedX(void) {&lt;/code&gt;. And be sure to never use any function from ...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could also try to find a way on how not to invoke Tone.h with core.a. &lt;code&gt;include &amp;lt;Tone.h&amp;gt;&lt;/code&gt; could be replaced with &lt;code&gt;//include &amp;lt;Tone.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You could use another timer in &lt;code&gt;IRRemote.h&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-04-22T13:43:56.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10248" PostTypeId="2" ParentId="10187" CreationDate="2015-04-22T14:06:22.860" Score="8" Body="&lt;p&gt;An easy way to see the difference is using &lt;code&gt;Serial.print();&lt;/code&gt;/&lt;code&gt;Serial.println();&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will print out whatever you input wherever the cursor currently is. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Test&quot;);&#xA;Serial.print(&quot;Words&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TestWords_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The underscore marks where the cursor is (and therefore where the next print command will start). In contrast, the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Test&quot;);&#xA;Serial.println(&quot;Words&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will print the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test&#xA;Words&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also print multiple statements and then follow with &lt;code&gt;println&lt;/code&gt; like so (note the space at the end/beginning of the strings):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;These &quot;);&#xA;Serial.print(&quot;Test&quot;);&#xA;Serial.println(&quot; Words.&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;These Test Words.&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;println();&lt;/code&gt; to add a newline character in general. If you would print a variable that doesn't return a newline character, &lt;code&gt;println();&lt;/code&gt; can be used for formatting. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x = 50;&#xA;Serial.print(x);&#xA;Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;50&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, you can add in special characters like a tab &lt;code&gt;\t&lt;/code&gt; inside your quotes for formatting. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Test\tTest&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will return:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Test    Test&#xA;_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8623" LastActivityDate="2015-04-22T14:06:22.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10249" PostTypeId="2" ParentId="10238" CreationDate="2015-04-22T15:03:58.493" Score="1" Body="&lt;p&gt;Depends on what you define as &quot;Arduino compatible&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &quot;Arduino Nano&quot; is 'Compatible' but a whole other design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or well, it already separates here.&#xA;&quot;Software compatible&quot; working with the Arduino IDE and/or Libraries. In general, any board with ATMega 328P / USB or ICSP / Bootloader could be considered compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, however, for an &quot;Arduino clone&quot; being &quot;Hardware compatible&quot; you could also look at:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Pin placement (Thus being compatible with shields).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using the same FTDI chip, thus being directly compatible with arduino&#xA;drivers (not sure)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Using &quot;exactly&quot; same electronic specifications.&lt;/li&gt;&#xA;&lt;li&gt;Size and/or shape or even weight of the board.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Strictly, moving the ICSP header will make it 'incompatible' for some shields.&#xA;But, well, for most shields it won't be a problem. For casings that have an opening for the ICSP header it'll mostly just look funny.&#xA;By replacing the ICSP header it might touch components of other shields/casings and thus be not compatible with it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(update)&#xA;The website and file below are from the arduino site and could thus be considered to be the 'standard' as it's set by arduino. You can however make your board how you want it and compatible with what you want. But changes will often make it incompatible with (some) shields/adapters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino website with specifications on the board:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoBoardUno&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EAGLE files:&#xA;&lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-04-27T18:32:00.303" LastActivityDate="2015-04-27T18:32:00.303" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10250" PostTypeId="2" ParentId="10230" CreationDate="2015-04-22T15:49:27.270" Score="0" Body="&lt;p&gt;For the Uno, you can set an interrupt on digital pins 2 and 3.  Check out &lt;a href=&quot;http://www.arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/attachInterrupt&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the example code from that page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 13;&#xA;volatile int state = LOW;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(pin, OUTPUT);&#xA;  attachInterrupt(0, blink, CHANGE);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(pin, state);&#xA;}&#xA;&#xA;void blink()&#xA;{&#xA;  state = !state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, blink() will be called anytime pin 0 changes state.  If you only want the rising or falling edge, change the call to attachInterrupt to say RISING or FALLING instead of CHANGE.&lt;/p&gt;&#xA;" OwnerUserId="8613" LastEditorUserId="8613" LastEditDate="2015-04-22T16:05:20.683" LastActivityDate="2015-04-22T16:05:20.683" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10251" PostTypeId="1" CreationDate="2015-04-22T18:49:32.893" Score="1" ViewCount="198" Body="&lt;p&gt;I have a few potentiometers connected to analog inputs in an Arduino UNO. These are then processed and then the servo motors start moving to move the bot.&#xA;I would like to keep the motors with the uno and send signals from the pots to the uno. I do not want to use a laptop or another arduino as the remote control. However.. XBEE and other related stuff will do... Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit- The wireless solution has to cover a long range preferrably 1 mile.(I dont think I will get any that will cover a mile but I'll give it a try.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 2- I have 8 servos and 4 potentiometer. I don't necessarily need an xbee. However it may be used.&lt;/p&gt;&#xA;" OwnerUserId="8630" LastEditorUserId="8630" LastEditDate="2015-04-23T01:37:05.287" LastActivityDate="2015-04-23T08:07:50.487" Title="How to control Arduino robot wirelessly?" Tags="|arduino-uno|robotics|remote-control|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10252" PostTypeId="2" ParentId="10251" CreationDate="2015-04-22T19:06:11.227" Score="1" Body="&lt;p&gt;A 13 year old programming an embedded device? Good luck to you, if you conquer it you will be years ahead of your age group. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to understand are the fundamentals; how can you transmit a 'pot' over an XBee? That is an electronics question, start there. You will find that another arduino or laptop is probably required. The XBee itself requires some sort of host adapter, and it might as well be another Arduino since something has to electronically read the 'pots'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to develop your own protocol for signals sent between the 2 Arduino (over XBee or on a serial wire , it is the same).  There are many already out there, but they assume you know the basics before you use them (eg firmata). This is the basics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that your google results showed nothing similar is probably a good indication it can not be done as you had hoped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;update: I like @gerben comment, but even as an advanced person, I would find it challenging.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-04-22T20:00:53.010" LastActivityDate="2015-04-22T20:00:53.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10253" PostTypeId="2" ParentId="10251" CreationDate="2015-04-22T19:50:32.337" Score="0" Body="&lt;p&gt;You need to find a way to do this without having individual wireless communication from each pot. There are boards that can communicate wirelessly that are small, however, most of these are around the size of a quarter developed by an electrical engineer. This presents two problems, first the wireless modules will be too big, second, you will need to do a lot of work before you have the experience necessary  to build something like this. I recommend changing a design decision. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, in order to help you further we will need to know more information about your setup.&lt;/p&gt;&#xA;" OwnerUserId="3818" LastActivityDate="2015-04-22T19:50:32.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10255" PostTypeId="1" AcceptedAnswerId="10273" CreationDate="2015-04-22T21:53:46.397" Score="1" ViewCount="635" Body="&lt;p&gt;I am trying to program a digital resistor and set it's wiper resistance. The general circuit looks a little like this where &quot;pot&quot; represents the &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS1801.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maxim DS1801 digital resistor&lt;/a&gt; and DUE is, of-course the 3.3v Arduino DUE. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POT       DUE&#xA;CLk ----&amp;gt; SCK&#xA;D    ----&amp;gt; MOSI&#xA;RST ----&amp;gt; CS (ChipSelect) (PIN10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now so far, I have sucessfully been able to interface with the DS1801, but I am having issues determining how to properly set the wiper resistance values. The DS1801 datasheet says the it accepts a 16bit input and from application example online it looks like the values range from 0 to 64. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the SPI library:&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;// set pin 10 as the slave select for the digital pot:&#xA;const int slaveSelectPin = 10;&#xA;int mute = 64;&#xA;int loud = 63;&#xA;int soft = 0;&#xA;&#xA;void setup() {&#xA;  // set the slaveSelectPin as an output:&#xA;  pinMode (slaveSelectPin, OUTPUT);&#xA;  // initialize SPI:&#xA;  SPI.setBitOrder(LSBFIRST);&#xA;  SPI.setDataMode(SPI_MODE0);&#xA;  SPI.setClockDivider(slaveSelectPin,SPI_CLOCK_DIV8);&#xA;  SPI.begin();&#xA;  delay(10);&#xA;   digitalPotWrite(mute, mute);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Raise the volume from off to loud&#xA;for(int i = 0; i &amp;lt;= 63; i++){&#xA;  digitalPotWrite(i, i);&#xA;  delay(5);&#xA;    }&#xA;  }&#xA;&#xA;void digitalPotWrite(int left, int right) {&#xA;  // take the SS pin low to select the chip:&#xA;  digitalWrite(slaveSelectPin, HIGH);&#xA;  //  send in the address and value via SPI:&#xA;  SPI.transfer(left);&#xA;  SPI.transfer(right);&#xA;  // take the SS pin high to de-select the chip:&#xA;  digitalWrite(slaveSelectPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I THINK my issue lies with setting the clock rate for the DS1801. The data sheet say the chip runs at 10MHz which is why I wrote&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.setClockDivider(slaveSelectPin,SPI_CLOCK_DIV8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to divide the 84MHz default speed down to 10MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have suggestions on why my code is not working??? At the moment, I have LED's connected to chip with series resistors to limit current below 2mA. The resistors just blink randomly with the code posted above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/K8HKw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4S4LY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8633" LastEditorUserId="8633" LastEditDate="2015-04-23T03:41:33.533" LastActivityDate="2015-04-23T18:34:34.463" Title="How to interface DS1801 digital resistor with Arduino DUE SPI interface? What clock rate so use?" Tags="|arduino-due|spi|digital|resistor|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10256" PostTypeId="2" ParentId="10243" CreationDate="2015-04-22T22:36:09.463" Score="2" Body="&lt;p&gt;What have you selected as the analog reference? And if 'external', what is connected to the Vref pin? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the LDR resistances of 10K and 1K, you  Vout should be ~ 1.8v at 10K, and ~ 4.2v at 1K, and giving A/D readings of somewhere around 370 counts and 860 counts, respectively, &lt;em&gt;with a 5v analog reference&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your analog reference selected to the 1.1v internal reference, either LDR resistance should give you the max reading, but an LDR = 20K could give just over a volt and pretty close to the reading you're getting.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-22T22:36:09.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10257" PostTypeId="1" AcceptedAnswerId="16342" CreationDate="2015-04-22T23:40:30.873" Score="2" ViewCount="686" Body="&lt;p&gt;I have quite a lot of experience with Arduino but have recently been faced with a challenge that has stumped me. The project is to create a robot that can be controlled from a separate network than it is on. I had the idea of using the Yun board to receive the values. Does anyone know a way I could have a computer send data to a Yun on a different network? (Maybe through a website?)&lt;/p&gt;&#xA;" OwnerUserId="8635" LastActivityDate="2016-06-21T22:51:12.480" Title="Sending values to an Arduino Yun across different networks" Tags="|wifi|arduino-yun|remote-control|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10258" PostTypeId="2" ParentId="10255" CreationDate="2015-04-23T03:47:42.963" Score="1" Body="&lt;p&gt;There is &lt;strong&gt;&lt;em&gt;no way in hell&lt;/em&gt;&lt;/strong&gt; you're going to get a 10MHz signal down that line. Shorten it to 3 inches total &lt;em&gt;maximum&lt;/em&gt; and reduce the clock rate to 2MHz or lower. It is possible to get a 10MHz signal through, but you'd need to switch to twisted pair wiring and proper termination to even begin to have a chance to get it to work.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-23T03:47:42.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10259" PostTypeId="2" ParentId="10105" CreationDate="2015-04-23T06:15:03.820" Score="1" Body="&lt;p&gt;To confirm your analysis that the issue is caused by the lower pwm frequency on the Arduino, did you try reproducing the problem with the teensy? Just divide by 3 the PWM frequency on the Teensy and see if you get the same problems that you are experiencing with the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-04-23T06:15:03.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10260" PostTypeId="2" ParentId="10251" CreationDate="2015-04-23T08:07:50.487" Score="1" Body="&lt;p&gt;You can use so many methods to achieve it,as you are a newbie.i would prefer bluetooth and an android app.use bluetooth hc-05 module and use an android app to control.use this app and send string and control arduino.&#xA;&lt;a href=&quot;https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO&amp;amp;hl=en&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=mobi.dzs.android.BLE_SPP_PRO&amp;amp;hl=en&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8435" LastActivityDate="2015-04-23T08:07:50.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10261" PostTypeId="1" CreationDate="2015-04-23T10:52:17.473" Score="0" ViewCount="1078" Body="&lt;p&gt;I faced a problem to send 1 SMS if an input is HIGH and if it is LOW no SMS will be sent. The code not working, just sends SMS when I turn the GPRS on and after that nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check this link to see the code : &lt;a href=&quot;https://stackoverflow.com/questions/29818894/send-sms-for-1-time-with-arduino-gprs-sim900-if-an-iput-is-high&quot;&gt;the code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for helping in advance.&lt;/p&gt;&#xA;" OwnerUserId="8640" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-04-08T05:32:09.597" Title="Sending SMS once with arduino GPRS SIM900 if an input is HIGH" Tags="|arduino-uno|gsm|c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10262" PostTypeId="1" AcceptedAnswerId="10267" CreationDate="2015-04-23T12:50:05.783" Score="3" ViewCount="1717" Body="&lt;p&gt;Without declaring the pin 2 as INPUT or OUTPUT, it remains constantly HIGH. Can anyone explain why is it so?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="6549" LastEditDate="2015-04-23T13:49:02.203" LastActivityDate="2015-04-23T14:21:03.717" Title="Why does the pin 2 of arduino Mega stay always HIGH?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10263" PostTypeId="1" CreationDate="2015-04-23T13:30:24.447" Score="2" ViewCount="70" Body="&lt;p&gt;I have a friend who is just getting started with Arduino UNO.  He downloaded a sketch and is using a UNO on Mac OS.  He loaded the sketch and verified.  it comes up with errors.  He sent me the same sketch and i opened it under Win7 arduino software.  verified, and it says it is fine.  i made an arduino file and emailed it back to him.  he is still getting the same errors.  can anyone help and let me know what is wrong?  i am not a MAC expert and wonder why  this works in win and not MAC????????  appreicate any help anyone can give me&lt;/p&gt;&#xA;" OwnerUserId="8641" LastActivityDate="2017-08-29T01:08:27.703" Title="arduino sketch on Win7 vs. MAC op system?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10265" PostTypeId="2" ParentId="10129" CreationDate="2015-04-23T14:05:05.120" Score="0" Body="&lt;p&gt;i got my lcd working on I2C following the steps in this link &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=128635.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=128635.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8642" LastActivityDate="2015-04-23T14:05:05.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10267" PostTypeId="2" ParentId="10262" CreationDate="2015-04-23T14:21:03.717" Score="2" Body="&lt;p&gt;Pin 2 connects to the controller's PE4, which is a GPIO pin, which can also be used for PWM. You should be able to use it either as input or output, and both high and low. It could be that setup initializes it as output high, while you would usually have uninitialized pins as input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/U9ZfI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried to make it low, or make it input?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(2, LOW);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should make it low, while&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(2, INPUT);&#xA;int pin2Status = digitalRead(2);&#xA;digitalWrite(13, pin2Status);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will copy the status of pin 2 to the on-board LED.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-23T14:21:03.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10268" PostTypeId="2" ParentId="4925" CreationDate="2015-04-23T14:30:46.297" Score="1" Body="&lt;p&gt;I had problems with this library too, until I realized the default library name &quot;LiquidCrystal&quot; conflicts with that of another library, which makes that the files get mixed up. Simply place the files in a different folder (I named mine) &quot;LiquidCrystal_4x20&quot;. Solved it for me.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-23T14:30:46.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10270" PostTypeId="1" AcceptedAnswerId="10276" CreationDate="2015-04-23T16:15:57.383" Score="0" ViewCount="92" Body="&lt;p&gt;I am looking into building a robot with my Arduino Nano but I don't want to shell out more then 50 bucks. Does anyone have any suggestions for a four wheel robot chassis at this price that I could use to make my robot mobile?&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-06-22T19:22:30.593" Title="Arduino Robot Chasis" Tags="|arduino-nano|robotics|" AnswerCount="1" CommentCount="1" ClosedDate="2015-07-23T19:12:28.320" ContentLicense="CC BY-SA 3.0" />
  <row Id="10271" PostTypeId="2" ParentId="6632" CreationDate="2015-04-23T16:19:40.867" Score="0" Body="&lt;p&gt;I assume you are using a 16 pin 16x2 display.  Try wiring a potentiometer like this with the pot wiper on pin 3. This is what adjusts text contrast:&#xA; &lt;img src=&quot;https://i.stack.imgur.com/aLpZX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-23T16:19:40.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10272" PostTypeId="1" CreationDate="2015-04-23T17:18:40.110" Score="2" ViewCount="168" Body="&lt;p&gt;I'm building a lathe that will be powered by a 3-phase 750w AC motor (4 pole, max unloaded RPM of 1400 RPM). I want to be able to control the RPM using a potentiometer attached to an Arduino mega which I can figure out how to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under load, I'm guessing the motor is going to want to draw more current across each of the phases, the cabling can take the extra current draw but I don't want to damage the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I use AnalogueRead (using current transducers) to tell the Arduino to increase the resistance with a servo-potentiometer setup or cut the power momentarily (using transistors on each phase) if the current rose above a certain level? If so, is there any code that would be good to steal/adapt?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks all!&lt;/p&gt;&#xA;" OwnerUserId="7391" LastActivityDate="2015-04-23T17:18:40.110" Title="Arduino-controlled current limiter for lathe" Tags="|sensors|motor|current|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10273" PostTypeId="2" ParentId="10255" CreationDate="2015-04-23T18:34:34.463" Score="1" Body="&lt;p&gt;Well, it turns out that apparently my issue was not having the AGND pin hooked up. In addition to that, I was trying to switch the wiper resistance value too quickly. By putting at least a 10ms delay between calls, it works much better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it does seem to work even at 10MHz just fine...  &lt;/p&gt;&#xA;" OwnerUserId="8633" LastActivityDate="2015-04-23T18:34:34.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10274" PostTypeId="1" CreationDate="2015-04-23T18:47:07.250" Score="2" ViewCount="1202" Body="&lt;p&gt;I have been awaiting the release date for some time for the Arduino TRE.  So, my question is simple does anyone know the release date or any hints about when it might come out?  Also, what do you think the cost will be?&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-05-26T17:51:42.980" Title="Arduino TRE Release Date and Cost" Tags="|hardware|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10276" PostTypeId="2" ParentId="10270" CreationDate="2015-04-23T19:06:47.180" Score="1" Body="&lt;p&gt;There's plenty of &lt;a href=&quot;http://www.ebay.com/itm/Hot-sale-4WD-Robot-Smart-Car-Chassis-with-Speed-Encoder-DC-3V5V6V-for-Arduin-EEW-/291423639383?pt=LH_DefaultDomain_3&amp;amp;hash=item43da33d757&quot; rel=&quot;nofollow&quot;&gt;options on ebay&lt;/a&gt;, you will have to add a DC motor &lt;a href=&quot;http://www.ebay.com/itm/L9110S-H-bridge-Stepper-Motor-Dual-DC-motor-Driver-Controller-Board-New-GA-/181650502852?pt=LH_DefaultDomain_15&amp;amp;hash=item2a4b36b4c4&quot; rel=&quot;nofollow&quot;&gt;driver&lt;/a&gt; and optionally, sensors, but these are a good starting point.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-04-23T19:06:47.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10278" PostTypeId="2" ParentId="10196" CreationDate="2015-04-23T19:39:59.303" Score="0" Body="&lt;p&gt;Have you tried compiling without the &quot;static&quot; keyword. I think the compiler is complaining because it sees multiple statements trying to make an assignment to a static variable. Even if your logic is such that only one of the assignments will ever be executed the compiler doesn't know that.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-04-23T19:39:59.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10279" PostTypeId="1" CreationDate="2015-04-23T20:00:59.310" Score="2" ViewCount="123" Body="&lt;p&gt;I am trying to code something for fun using an Arduino Due and a LED matrix. The led matrix has a &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/rgbmatrixbackpack_userguide.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;backpack controller&lt;/a&gt;. This device is using SPI. So I connect MOSI and SCLK to their respective pins and SS to pin 10 on the Due. So far so good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I have is that when i run my rudimentary code nothing happens.&#xA;this is the current code I am using. I thought this should be enough, but it clearly isn't.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;void setup() {&#xA;  SPI.begin(10);&#xA;  SPI.transfer(10, 0x26, SPI_CONTINUE); //setup the matrix&#xA;  for (int i = 0; i&amp;lt;64; i++){&#xA;    SPI.transfer(10, 0x00, SPI_CONTINUE); //set all pixels to black...&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Erase flash&#xA; Write 10444 bytes to flash&#xA; [                              ] 0% (0/41 pages)&#xA; [=======                       ] 24% (10/41 pages)&#xA; [==============                ] 48% (20/41 pages)&#xA; [=====================         ] 73% (30/41 pages)&#xA; [============================= ] 97% (40/41 pages)&#xA; [==============================] 100% (41/41 pages)&#xA; Verify 10444 bytes of flash&#xA; [                              ] 0% (0/41 pages)&#xA; [=======                       ] 24% (10/41 pages)&#xA; [==============                ] 48% (20/41 pages)&#xA; [=====================         ] 73% (30/41 pages)&#xA; [============================= ] 97% (40/41 pages)&#xA; [==============================] 100% (41/41 pages)&#xA; Verify successful&#xA; Set boot flash true&#xA; CPU reset.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wj8kd.jpg&quot; alt=&quot;Image of the ever unchanging LED-matrix&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: am I doing something wrong? what? &#xA;Or is the Led matrix broken?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hoping for good answers.&#xA;regs &#xA;KB&lt;/p&gt;&#xA;" OwnerUserId="201" LastActivityDate="2015-04-23T20:00:59.310" Title="Arduino DUE and a ledmatrix with issues" Tags="|arduino-due|spi|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10280" PostTypeId="1" AcceptedAnswerId="10282" CreationDate="2015-04-23T20:56:26.573" Score="0" ViewCount="1421" Body="&lt;p&gt;Suppose I have a number with 2 digits, 42.&#xA;It is an integer, received from my RTC&lt;/p&gt;&#xA;&lt;p&gt;Now for my 7 segment displays, I will need 2 separate numbers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;4 on display 1.&lt;/li&gt;&#xA;&lt;li&gt;2 on display 2.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;How do I slice this number in 2?&lt;/p&gt;&#xA;" OwnerUserId="8646" LastEditorUserId="27544" LastEditDate="2022-10-06T06:55:02.737" LastActivityDate="2022-10-06T06:55:02.737" Title="2 digit number to 2x 1 digit" Tags="|display|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="10281" PostTypeId="1" AcceptedAnswerId="10297" CreationDate="2015-04-23T21:00:54.273" Score="2" ViewCount="1589" Body="&lt;p&gt;In my project I need to connect more then 10 I2C sensors(MPU-6050) to Arduino Mega and an interrupt line for each sensor is essential. &#xA;Since the Arduino Mega only has several interrupt slots (digital 2, 3, 21,29,19,18), how can it be achieved? Is that using a multiplexer every time I switch sensors and also switching interrupt lines solve the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I'm using is Jeff Rowberg's MPU-6050 DMP example, which means interrupt line is essential and important, also very sensitive (a wrong change can cause sudden stop).. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class using DMP (MotionApps v2.0)&#xA;// 6/21/2012 by Jeff Rowberg &amp;lt;jeff@rowberg.net&amp;gt;&#xA;// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib&#xA;//&#xA;// Changelog:&#xA;//      2013-05-08 - added seamless Fastwire support&#xA;//                 - added note about gyro calibration&#xA;//      2012-06-21 - added note about Arduino 1.0.1 + Leonardo compatibility error&#xA;//      2012-06-20 - improved FIFO overflow handling and simplified read process&#xA;//      2012-06-19 - completely rearranged DMP initialization code and simplification&#xA;//      2012-06-13 - pull gyro and accel data from FIFO packet instead of reading directly&#xA;//      2012-06-09 - fix broken FIFO read sequence and change interrupt detection to RISING&#xA;//      2012-06-05 - add gravity-compensated initial reference frame acceleration output&#xA;//                 - add 3D math helper file to DMP6 example sketch&#xA;//                 - add Euler output and Yaw/Pitch/Roll output formats&#xA;//      2012-06-04 - remove accel offset clearing for better results (thanks Sungon Lee)&#xA;//      2012-06-01 - fixed gyro sensitivity to be 2000 deg/sec instead of 250&#xA;//      2012-05-30 - basic DMP initialization working&#xA;&#xA;/* ============================================&#xA;I2Cdev device library code is placed under the MIT license&#xA;Copyright (c) 2012 Jeff Rowberg&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a copy&#xA;of this software and associated documentation files (the &quot;Software&quot;), to deal&#xA;in the Software without restriction, including without limitation the rights&#xA;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;copies of the Software, and to permit persons to whom the Software is&#xA;furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included in&#xA;all copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#xA;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&#xA;THE SOFTWARE.&#xA;===============================================&#xA;*/&#xA;&#xA;// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files&#xA;// for both classes must be in the include path of your project&#xA;#include &quot;I2Cdev.h&quot;&#xA;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;//#include &quot;MPU6050.h&quot; // not necessary if using MotionApps include file&#xA;&#xA;// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation&#xA;// is used in I2Cdev.h&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &quot;Wire.h&quot;&#xA;#endif&#xA;&#xA;// class default I2C address is 0x68&#xA;// specific I2C addresses may be passed as a parameter here&#xA;// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)&#xA;// AD0 high = 0x69&#xA;//MPU6050 mpu;&#xA;MPU6050 mpu(0x69); // &amp;lt;-- use for AD0 high&#xA;&#xA;/* =========================================================================&#xA;   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch&#xA;   depends on the MPU-6050's INT pin being connected to the Arduino's&#xA;   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is&#xA;   digital I/O pin 2.&#xA; * ========================================================================= */&#xA;&#xA;/* =========================================================================&#xA;   NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error&#xA;   when using Serial.write(buf, len). The Teapot output uses this method.&#xA;   The solution requires a modification to the Arduino USBAPI.h file, which&#xA;   is fortunately simple, but annoying. This will be fixed in the next IDE&#xA;   release. For more info, see these links:&#xA;&#xA;   http://arduino.cc/forum/index.php/topic,109987.0.html&#xA;   http://code.google.com/p/arduino/issues/detail?id=958&#xA; * ========================================================================= */&#xA;&#xA;&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_QUATERNION&quot; if you want to see the actual&#xA;// quaternion components in a [w, x, y, z] format (not best for parsing&#xA;// on a remote host such as Processing or something though)&#xA;//#define OUTPUT_READABLE_QUATERNION&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_EULER&quot; if you want to see Euler angles&#xA;// (in degrees) calculated from the quaternions coming from the FIFO.&#xA;// Note that Euler angles suffer from gimbal lock (for more info, see&#xA;// http://en.wikipedia.org/wiki/Gimbal_lock)&#xA;//#define OUTPUT_READABLE_EULER&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_YAWPITCHROLL&quot; if you want to see the yaw/&#xA;// pitch/roll angles (in degrees) calculated from the quaternions coming&#xA;// from the FIFO. Note this also requires gravity vector calculations.&#xA;// Also note that yaw/pitch/roll angles suffer from gimbal lock (for&#xA;// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)&#xA;#define OUTPUT_READABLE_YAWPITCHROLL&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_REALACCEL&quot; if you want to see acceleration&#xA;// components with gravity removed. This acceleration reference frame is&#xA;// not compensated for orientation, so +X is always +X according to the&#xA;// sensor, just without the effects of gravity. If you want acceleration&#xA;// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.&#xA;//#define OUTPUT_READABLE_REALACCEL&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_WORLDACCEL&quot; if you want to see acceleration&#xA;// components with gravity removed and adjusted for the world frame of&#xA;// reference (yaw is relative to initial orientation, since no magnetometer&#xA;// is present in this case). Could be quite handy in some cases.&#xA;//#define OUTPUT_READABLE_WORLDACCEL&#xA;&#xA;// uncomment &quot;OUTPUT_TEAPOT&quot; if you want output that matches the&#xA;// format used for the InvenSense teapot demo&#xA;//#define OUTPUT_TEAPOT&#xA;&#xA;&#xA;&#xA;#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)&#xA;bool blinkState = false;&#xA;&#xA;// MPU control/status vars&#xA;bool dmpReady = false;  // set true if DMP init was successful&#xA;uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU&#xA;uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)&#xA;uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)&#xA;uint16_t fifoCount;     // count of all bytes currently in FIFO&#xA;uint8_t fifoBuffer[64]; // FIFO storage buffer&#xA;&#xA;// orientation/motion vars&#xA;Quaternion q;           // [w, x, y, z]         quaternion container&#xA;VectorInt16 aa;         // [x, y, z]            accel sensor measurements&#xA;VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements&#xA;VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements&#xA;VectorFloat gravity;    // [x, y, z]            gravity vector&#xA;float euler[3];         // [psi, theta, phi]    Euler angle container&#xA;float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector&#xA;&#xA;// packet structure for InvenSense teapot demo&#xA;uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===               INTERRUPT DETECTION ROUTINE                ===&#xA;// ================================================================&#xA;&#xA;volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high&#xA;void dmpDataReady() {&#xA;    mpuInterrupt = true;&#xA;}&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===                      INITIAL SETUP                       ===&#xA;// ================================================================&#xA;&#xA;void setup() {&#xA;    // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;        Wire.begin();&#xA;        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)&#xA;    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;        Fastwire::setup(400, true);&#xA;    #endif&#xA;&#xA;    // initialize serial communication&#xA;    // (115200 chosen because it is required for Teapot Demo output, but it's&#xA;    // really up to you depending on your project)&#xA;    Serial.begin(115200);&#xA;    while (!Serial); // wait for Leonardo enumeration, others continue immediately&#xA;&#xA;    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Arduino&#xA;    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to&#xA;    // the baud timing being too misaligned with processor ticks. You must use&#xA;    // 38400 or slower in these cases, or use some kind of external separate&#xA;    // crystal solution for the UART timer.&#xA;&#xA;    // initialize device&#xA;    Serial.println(F(&quot;Initializing I2C devices...&quot;));&#xA;    mpu.initialize();&#xA;&#xA;    // verify connection&#xA;    Serial.println(F(&quot;Testing device connections...&quot;));&#xA;    Serial.println(mpu.testConnection() ? F(&quot;MPU6050 connection successful&quot;) : F(&quot;MPU6050 connection failed&quot;));&#xA;&#xA;    // wait for ready&#xA;    Serial.println(F(&quot;\nSend any character to begin DMP programming and demo: &quot;));&#xA;    while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer&#xA;    while (!Serial.available());                 // wait for data&#xA;    while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer again&#xA;&#xA;    // load and configure the DMP&#xA;    Serial.println(F(&quot;Initializing DMP...&quot;));&#xA;    devStatus = mpu.dmpInitialize();&#xA;&#xA;    // supply your own gyro offsets here, scaled for min sensitivity&#xA;    mpu.setXGyroOffset(220);&#xA;    mpu.setYGyroOffset(76);&#xA;    mpu.setZGyroOffset(-85);&#xA;    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip&#xA;&#xA;    // make sure it worked (returns 0 if so)&#xA;    if (devStatus == 0) {&#xA;        // turn on the DMP, now that it's ready&#xA;        Serial.println(F(&quot;Enabling DMP...&quot;));&#xA;        mpu.setDMPEnabled(true);&#xA;&#xA;        // enable Arduino interrupt detection&#xA;        Serial.println(F(&quot;Enabling interrupt detection (Arduino external interrupt 0)...&quot;));&#xA;        attachInterrupt(0, dmpDataReady, RISING);&#xA;        mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;        // set our DMP Ready flag so the main loop() function knows it's okay to use it&#xA;        Serial.println(F(&quot;DMP ready! Waiting for first interrupt...&quot;));&#xA;        dmpReady = true;&#xA;&#xA;        // get expected DMP packet size for later comparison&#xA;        packetSize = mpu.dmpGetFIFOPacketSize();&#xA;    } else {&#xA;        // ERROR!&#xA;        // 1 = initial memory load failed&#xA;        // 2 = DMP configuration updates failed&#xA;        // (if it's going to break, usually the code will be 1)&#xA;        Serial.print(F(&quot;DMP Initialization failed (code &quot;));&#xA;        Serial.print(devStatus);&#xA;        Serial.println(F(&quot;)&quot;));&#xA;    }&#xA;&#xA;    // configure LED for output&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===                    MAIN PROGRAM LOOP                     ===&#xA;// ================================================================&#xA;&#xA;void loop() {&#xA;    // if programming failed, don't try to do anything&#xA;    if (!dmpReady) return;&#xA;&#xA;    // wait for MPU interrupt or extra packet(s) available&#xA;    while (!mpuInterrupt &amp;amp;&amp;amp; fifoCount &amp;lt; packetSize) {&#xA;        // other program behavior stuff here&#xA;        // .&#xA;        // .&#xA;        // .&#xA;        // if you are really paranoid you can frequently test in between other&#xA;        // stuff to see if mpuInterrupt is true, and if so, &quot;break;&quot; from the&#xA;        // while() loop to immediately process the MPU data&#xA;        // .&#xA;        // .&#xA;        // .&#xA;    }&#xA;&#xA;    // reset interrupt flag and get INT_STATUS byte&#xA;    mpuInterrupt = false;&#xA;    mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;    // get current FIFO count&#xA;    fifoCount = mpu.getFIFOCount();&#xA;&#xA;    // check for overflow (this should never happen unless our code is too inefficient)&#xA;    if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;        // reset so we can continue cleanly&#xA;        mpu.resetFIFO();&#xA;        Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;    } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;        // wait for correct available data length, should be a VERY short wait&#xA;        while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;&#xA;        // read a packet from FIFO&#xA;        mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;&#xA;        // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;        // (this lets us immediately read more without waiting for an interrupt)&#xA;        fifoCount -= packetSize;&#xA;&#xA;        #ifdef OUTPUT_READABLE_QUATERNION&#xA;            // display quaternion values in easy matrix form: w x y z&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            Serial.print(&quot;quat\t&quot;);&#xA;            Serial.print(q.w);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(q.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(q.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(q.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_EULER&#xA;            // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetEuler(euler, &amp;amp;q);&#xA;            Serial.print(&quot;euler\t&quot;);&#xA;            Serial.print(euler[0] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(euler[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(euler[2] * 180/M_PI);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;            // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;            Serial.print(&quot;ypr\t&quot;);&#xA;            Serial.print(ypr[0] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(ypr[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(ypr[2] * 180/M_PI);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_REALACCEL&#xA;            // display real acceleration, adjusted to remove gravity&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetAccel(&amp;amp;aa, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetLinearAccel(&amp;amp;aaReal, &amp;amp;aa, &amp;amp;gravity);&#xA;            Serial.print(&quot;areal\t&quot;);&#xA;            Serial.print(aaReal.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(aaReal.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(aaReal.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_WORLDACCEL&#xA;            // display initial world-frame acceleration, adjusted to remove gravity&#xA;            // and rotated based on known orientation from quaternion&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetAccel(&amp;amp;aa, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetLinearAccel(&amp;amp;aaReal, &amp;amp;aa, &amp;amp;gravity);&#xA;            mpu.dmpGetLinearAccelInWorld(&amp;amp;aaWorld, &amp;amp;aaReal, &amp;amp;q);&#xA;            Serial.print(&quot;aworld\t&quot;);&#xA;            Serial.print(aaWorld.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(aaWorld.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(aaWorld.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_TEAPOT&#xA;            // display quaternion values in InvenSense Teapot demo format:&#xA;            teapotPacket[2] = fifoBuffer[0];&#xA;            teapotPacket[3] = fifoBuffer[1];&#xA;            teapotPacket[4] = fifoBuffer[4];&#xA;            teapotPacket[5] = fifoBuffer[5];&#xA;            teapotPacket[6] = fifoBuffer[8];&#xA;            teapotPacket[7] = fifoBuffer[9];&#xA;            teapotPacket[8] = fifoBuffer[12];&#xA;            teapotPacket[9] = fifoBuffer[13];&#xA;            Serial.write(teapotPacket, 14);&#xA;            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose&#xA;        #endif&#xA;&#xA;        // blink LED to indicate activity&#xA;        blinkState = !blinkState;&#xA;        digitalWrite(LED_PIN, blinkState);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8643" LastEditorUserId="26916" LastEditDate="2017-11-04T18:52:30.383" LastActivityDate="2017-11-04T18:52:30.383" Title="Multiple interrupt lines connection" Tags="|arduino-uno|arduino-mega|i2c|interrupt|mpu6050|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10282" PostTypeId="2" ParentId="10280" CreationDate="2015-04-23T21:33:26.517" Score="2" Body="&lt;p&gt;Numbers retrieved from an rtc are usually returned as a char or integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On this basis, you want&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ones_column = bytefromrtc % 10;&#xA;tens_column = (bytefromrtc / 10) % 10;&#xA;hundreds_column = (bytefromrtc / 100) % 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;%&lt;/code&gt; operator returns the modulus - if you divide 42 by 10, the answer is 4, with a remainder of 2. % returns the remainder, in this example, 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do the tens column, first get rid of the last digit by dividing by 10, then do the modulus as above. Since bytefromrtc is not a float, if you divide it, you lose the remainder - 42 / 10 = 4, not 4.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the output is a word, or integer, or long integer, the method is exactly the same, except for the number of digits you can get out.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-04-23T21:39:13.573" LastActivityDate="2015-04-23T21:39:13.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10283" PostTypeId="1" CreationDate="2015-04-23T21:47:43.470" Score="0" ViewCount="88" Body="&lt;p&gt;I have a very simple idea I want to implement. I am making a home automation using an Arduino Uno. I am familiar with Arduino programming but the problem is what kind of IR receiver I need to buy if i want my TV remote (or similar) to communicate with my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you suggest me any example (low cost, and available in India)?&lt;/p&gt;&#xA;" OwnerUserId="8647" LastEditorUserId="10003" LastEditDate="2015-06-23T14:02:16.077" LastActivityDate="2015-06-23T14:02:16.077" Title="Stuck in a small confusion about Infrared leds and receivers?" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10284" PostTypeId="2" ParentId="10283" CreationDate="2015-04-23T22:06:05.040" Score="1" Body="&lt;p&gt;Element14 has an India based store, and they carry these IR devices. &#xA;Here is one for 66 rupees:&#xA;&lt;a href=&quot;http://in.element14.com/vishay-semiconductor/tsop38238/ir-receiver-45m-38khz-th/dp/2395954?MER=MER-BPR-4PPM-SP-VSHY-OD&amp;amp;&quot; rel=&quot;nofollow&quot;&gt;http://in.element14.com/vishay-semiconductor/tsop38238/ir-receiver-45m-38khz-th/dp/2395954?MER=MER-BPR-4PPM-SP-VSHY-OD&amp;amp;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to do research into what the carrier frequency of your remote is also. Most are generally around 35 - 40khz, and the receiver I provided a link to is 38khz. It should work, but if you want to be safe I suggest you look it up. Or, if you have an old TV lying around, you can pull one out of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="4440" LastActivityDate="2015-04-23T22:06:05.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10285" PostTypeId="1" CreationDate="2015-04-23T22:33:14.193" Score="2" ViewCount="1131" Body="&lt;p&gt;I've been working on a project (Arduino Uno: Atmega328) that implements a gyroscope (which is used with the LSM9DS0 spark-fun library) that is communicated with through I2C and uses a Servo library. Due to a timer conflict with the standard Servo library and another library I've been using, I am now using the ServoTimer2 library which obviously uses timer 2. This is when the problem started. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I call the attach() function of the ServoTimer2 library, it allows the gyroscope to be read a few times and then the gyroscope feed cuts out. I am using the serial monitor (115200 baud) to read the gyroscope data. The Serial monitor is not the problem because it uses a UART interrupt for Serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this error, I modified the ServoTimer2 library to run on Timer0 (Yes I know this handles the delay functions, but they are not needed in my case), which is now called ServoTimer0. This modified version of the library works perfect except for when I attempt to use it with the gyroscope. The same problem still arises though. I've traced what causes this failure down to one line of code that sets up the interrupts: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TIMSK0 =  _BV(OCIE0A) //This is in my own modified version of the library. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is what causes it to fail. I believe the AtMega328 can run I2C natively, and my thought is that this native running somehow uses these timers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any solutions?&#xA;Thanks &lt;/p&gt;&#xA;" OwnerUserId="4440" LastEditorUserId="6452" LastEditDate="2015-04-24T17:34:00.193" LastActivityDate="2015-06-26T05:39:00.620" Title="Unexpected Timer Conflicts (Uno)" Tags="|arduino-uno|i2c|atmega328|servo|timers|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10286" PostTypeId="1" CreationDate="2015-04-23T23:32:21.400" Score="-1" ViewCount="1202" Body="&lt;p&gt;I'm doing a project using the ADXL335 accelerometer from SparkFun. The actual project I'm using P5 and it's working great. I'm running workshops in parallel and want to demo the chip in real-time but am currently out of time to build something from scratch. I'm desperate for a simple processing (or something else) sketch that takes my x, y, z values being printed to the serial port from Arduino and visualizes them in some way. Can anyone point me to anything that won't need a lot of coding time and effort just now?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&#xA;Claudia&lt;/p&gt;&#xA;" OwnerUserId="6536" LastActivityDate="2023-02-03T20:24:18.113" Title="Need a simple accelerometer visualization example!" Tags="|accelerometer|processing-lang|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10287" PostTypeId="1" CreationDate="2015-04-24T01:40:21.460" Score="2" ViewCount="50" Body="&lt;p&gt;I acquired a Seeed studio Arduino motor shield V.2 and wanted to start using it. The problem is that there is like no good example code. The library for the shield on the seeed website has one example and doesn't really explain anything. Does anybody know where I could get a good guide for this thing?&lt;/p&gt;&#xA;" OwnerUserId="8650" LastEditorUserId="37523" LastEditDate="2019-08-24T18:43:28.007" LastActivityDate="2019-08-24T18:43:28.007" Title="Coding for Seeed Arduino motor shield" Tags="|arduino-motor-shield|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10288" PostTypeId="1" AcceptedAnswerId="10289" CreationDate="2015-04-24T02:08:58.247" Score="3" ViewCount="9883" Body="&lt;p&gt;I've been looking at water flow control with Arduino and I'm finding a huge difficulty in managing to do an 'analog' control on water flow. The mainstream solution seems to be the well known solenoid valve, however those seem to be binary (full flow, no flow), and I'm looking for a more variable answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to get middlegrounds with solenoids? Maybe actuating them with less voltage or amperage will cause it to partially actuate? If not, does anyone know of embedded solutions using servos or steppers maybe?&lt;/p&gt;&#xA;" OwnerUserId="8651" LastActivityDate="2018-11-28T14:57:11.620" Title="Proportional water flow control" Tags="|arduino-uno|motor|" AnswerCount="2" CommentCount="3" ClosedDate="2018-11-29T02:35:26.650" ContentLicense="CC BY-SA 3.0" />
  <row Id="10289" PostTypeId="2" ParentId="10288" CreationDate="2015-04-24T06:27:47.940" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to get middle grounds with solenoids? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.  The solenoid will be all or nothing.  If you have used a magnet, you have seen that the force decreases rapidly with distance.  As you move something closer, it will typically snap to a magnet at one point.  The same thing happens in a solenoid valve: once you apply enough voltage to start motion, the motion will complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Side note: that is actually a common trick to saving much power with solenoid valve.  You might apply 12 V to actuate, but then you can reduce the voltage very low (maybe 2 V or lower) and the valve will still say actuated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you want flow, you need a flow control valve.  A common 1/4 turn ball valve will provide the fractional flow you seek.  You should be able to hook a servo or gear motor to that.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical ball valve will not provide a constant change of flow with angle.  That means the change in flow between the first 5 degrees opening will be large while the last 5 degrees of motion will have little effect.  If the application is not critical, that would be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want more precise flow control, valves are made with a particular cutout in the ball that makes the flow control more linear.  You can get a commercial type valve with motor attached in cost range of 100 $US.  For hooking up to an Arduino, a Belimo flow valve (&lt;a href=&quot;http://www.belimo.us/americas/ccv.html&quot; rel=&quot;noreferrer&quot;&gt;one example vendor&lt;/a&gt;) only seems appropriately named&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EHiKa.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are commercial type valves used to control water in heater systems and such.  They take a 0 - 10 V input signal as control and will rotate the vale.  The keyword search is &quot;motorized flow control valve&quot; and that will find you many.  These are not exotic, you will find many in all sorts of sizes.  You may even find from a local plumbing supplier where you can pick one up at will call.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-04-24T06:27:47.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10291" PostTypeId="1" AcceptedAnswerId="10292" CreationDate="2015-04-24T07:02:00.857" Score="0" ViewCount="218" Body="&lt;p&gt;i am using Arduino Mega.. ANd this is the code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void bump(void);&#xA;&#xA;void setup() &#xA;{&#xA;    pinMode(19,INPUT);&#xA;    attachInterrupt(4,bump,HIGH);&#xA;    pinMode(13,OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;}&#xA;&#xA;void bump()&#xA;{&#xA;   for(float i = 0; i &amp;lt; 90000; i++){&#xA;   digitalWrite(13,HIGH);&#xA;   }&#xA;   for(float i = 0; i &amp;lt; 10000; i++){&#xA;   digitalWrite(13,LOW);&#xA;   }&#xA;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although i give +5 V to it once, the LED will blink twice...!&#xA;What is the solution?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-04-24T07:02:00.857" Title="The code of ISR executes twice" Tags="|isr|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10292" PostTypeId="2" ParentId="10291" CreationDate="2015-04-24T07:02:00.857" Score="1" Body="&lt;p&gt;After wondering over it for quite a long time, I finally came to the conclusion, that the interrupt should be made to trigger at RISING edge, &lt;strong&gt;if I want it to go into ISR the moment it gets HIGH.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence the setup line was change to   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(4,bump,RISING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the cod e works well.&lt;br&gt;&#xA;I suppose that is because, when it receives a HIGH signal, than the period for which it receives HIGH is a bit long, during which it adds another interrupt into the queue, and so the ISR is executed once again.&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-04-24T07:02:00.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10293" PostTypeId="1" AcceptedAnswerId="10296" CreationDate="2015-04-24T07:52:59.783" Score="3" ViewCount="277" Body="&lt;p&gt;Background:&#xA;I'm looking at writing a library to drive an LED matrix panel (one of these:&lt;a href=&quot;http://www.adafruit.com/product/607&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/product/607&lt;/a&gt;) from my newly acquired Arduino Due.  My background is C++ programming, not electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm planning to experiment with various optimisations of the code for memory and speed, but one constant is that I would like to be able to send the data to the matrix with single memory writes to port registers without having to use masking operations to leave certain bits unaffected.  As I need to send 6 bits of data with a clock signal, I figured this could be easy with an 8 bit write to one byte of a port register.  The 8th bit/pin could be used as the latch or some other used line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the nice pinout diagram that someone has kindly put together (&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,132130.0.html&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,132130.0.html&lt;/a&gt;), I was pretty shocked to discover that my plans weren't going to be as easy as I would have liked.  There are only two circumstances where there are whole bytes of port registers that connect to digital pins (Port A byte 1 and Port D byte 0).  All other bytes have &quot;holes&quot; in them, for example Port C byte 0 has no connection for bit 0, but has bits 1-7;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While two complete bytes is enough (I actually only need to use 13 pins to control the display, plus ground connections), the pins of the available two are spread out in a way that would make it a little awkward for me to make a stripboard shield as I intended due to the pins on the Arduino boards not being evenly spaced (why is that?) and I'm guessing that since most of the digital pins in Port A byte 1 are used for communication pins (including RX0 and TX0) I would lose my ability to print to the debug log.  As a result, I've ruled out using those port registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That leaves me with bytes 0 and 1 of Port C.  There are just enough pins available with those bytes and they are grouped nicely on the double connector at the bottom of the board (Digital pins 33-40 and 48-51), however some bits in those bytes are not mapped to Arduino IO pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be bad if I were to write to bits of a port register that do not have Arduino IO pins assigned to them?  Would the answer depend on whether I had set those bits to be inputs or outputs using the Output Write Enable Registers?  I'm assuming that these bits are used for IO pins on the SAM3X8E chip but just not made available to the Arduino boards.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-04-24T09:20:05.910" Title="Is it harmful to write to unused bits in PORT registers?" Tags="|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10294" PostTypeId="1" CreationDate="2015-04-24T08:54:06.997" Score="2" ViewCount="785" Body="&lt;p&gt;I faced a problem to send 1 SMS if an input is HIGH,and if it is LOW==&gt; no SMS to send,if LOW to HIGH==&gt; send 1 SMS. this code not working,just sent SMS when I turn the GPRS on,and after nothing is happened.&#xA;Thank you for helping in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA; #include &quot;TimerOne.h&quot;&#xA;&#xA; const int DI = 2;&#xA; const int DT = 3;&#xA; const int DGP1 = 4;&#xA; const int DGP2 = 5;&#xA; const long interval = 100000; // in microseconds&#xA;&#xA; int value1 = 0;&#xA; int value2 = 0;&#xA; int value3 = 0;&#xA; int value4 = 0;&#xA;&#xA; int value1_old = 0;&#xA; int value2_old = 0;&#xA; int value3_old = 0;&#xA; int value4_old = 0;&#xA;&#xA; boolean changed1 = false;&#xA; boolean changed2 = false;&#xA; boolean changed3 = false;&#xA; boolean changed4 = false;&#xA;&#xA; SoftwareSerial SIM900 (7, 8);&#xA;&#xA; void SIM900power(){&#xA;   digitalWrite(9, HIGH);&#xA;   delay(1000);&#xA;   digitalWrite(9, LOW);&#xA;   delay(5000);&#xA; }&#xA;&#xA; void initia(){&#xA;   SIM900.print(&quot;AT+CMGF=1\r&quot;);&#xA;   delay(100);&#xA;   SIM900.println(&quot;AT + CMGS = \&quot;xxxxxxxxxx\&quot;&quot;);&#xA;   delay(100);&#xA;  }&#xA;&#xA; void Send_SMS(){&#xA;    SIM900.println((char)26);&#xA;    delay(100);&#xA;    SIM900.println();&#xA;    delay(5000);&#xA;&#xA;  }&#xA;&#xA;  void isr_timer(){&#xA;    if (changed2) {&#xA;      initia();&#xA;      SIM900.println(&quot;Station 85: Defaut electrique&quot;);&#xA;      delay(100);&#xA;      Send_SMS();&#xA;      value2_old = value2;&#xA;      changed2 = false;&#xA;   }  &#xA;&#xA;   if (changed3) {&#xA;     initia();&#xA;     SIM900.println(&quot;Station 85: DefautGP1&quot;);&#xA;     delay(100);&#xA;     Send_SMS();&#xA;     value3_old = value3;&#xA;     changed3 = false;&#xA;   }&#xA;&#xA;   if (changed4) {&#xA;     initia();&#xA;     SIM900.println(&quot;Station 85:DD&amp;gt;1000&quot;);&#xA;     delay(100);&#xA;     Send_SMS();&#xA;     value4_old = value4;&#xA;     changed4 = false;&#xA;   }&#xA; }&#xA;&#xA; void setup() {&#xA;    pinMode(DI, INPUT);&#xA;    pinMode(DT, INPUT);&#xA;    pinMode(DGP1, INPUT);&#xA;    pinMode(DGP2, INPUT);&#xA;&#xA;    SIM900.begin(19200);&#xA;    Timer1.initialize(interval);&#xA;    Timer1.attachInterrupt(isr_timer);&#xA;  }&#xA;&#xA;  void loop() {&#xA;    value1 = digitalRead (DI);&#xA;    value2 = digitalRead (DT);&#xA;    value3 = digitalRead (DGP1);&#xA;    value4 = digitalRead (DGP2);&#xA;&#xA;    if (value1 != value1_old &amp;amp;&amp;amp; value1 == HIGH) changed1 = true;&#xA;    if (value2 != value2_old &amp;amp;&amp;amp; value2 == HIGH) changed2 = true;&#xA;    if (value3 != value3_old &amp;amp;&amp;amp; value3 == HIGH) changed3 = true;&#xA;    if (value4 != value4_old &amp;amp;&amp;amp; value4 == HIGH) changed4 = true;&#xA;&#xA;    value1_old = value1;&#xA;    value2_old = value2;&#xA;    value3_old = value3;&#xA;    value4_old = value4;&#xA;&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8640" LastActivityDate="2015-09-13T17:28:20.100" Title="send SMS for 1 time with arduino GPRS SIM900 if an iput is HIGH (4 Digi inputs)" Tags="|arduino-uno|gsm|c|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10295" PostTypeId="1" CreationDate="2015-04-24T09:05:23.410" Score="0" ViewCount="351" Body="&lt;p&gt;I have to control with an Arduino UNO and xbee shield:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;9 5V relay&lt;/li&gt;&#xA;&lt;li&gt;9 RGB LED&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;What kind of multiplexing can you advice me? Do I have to use external power supply (like 12V DC external from arduino or from vcc)? Is there any kind of already ready-to-use shield?&lt;/p&gt;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&lt;p&gt;I'm planning to use a &lt;a href=&quot;http://tinyurl.com/peagrd5&quot; rel=&quot;nofollow noreferrer&quot;&gt;8 relays shield&lt;/a&gt; plus one single relay&lt;/p&gt;&#xA;" OwnerUserId="1335" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-24T16:47:34.183" Title="Multiplexing help for relay and pwm" Tags="|pwm|relay|multiplexer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10296" PostTypeId="2" ParentId="10293" CreationDate="2015-04-24T09:20:05.910" Score="2" Body="&lt;p&gt;If the pins have no connection to the outside world (i.e., they don't have any actual pin associated with them on the SAM3X chip) then writing to the PORT (or indeed any other register associated with them) will have no effect whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they have a pin but that pin is not connected to anything, then there will be little effect.  There may be slightly increase current draw as the pin switches on/off, or you enable/disable the internal pullup resistor, but that's all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pin exists and is connected to something on the board - maybe a button or LED, then you will basically be providing an output to that item.  If it's an LED it will flash.  However, if it's a button, and you provide an output opposite of its active state (i.e., provide a HIGH when it normally connects to ground when you press it) and that button lacks any current limiting resistance, then you could risk burning out that IO pin if the button gets pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pin just goes straight to a header, then as long as nothing gets connected to that header then there will be no effect other than as detailed in the &quot;pin present on the chip but not connected&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-04-24T09:20:05.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10297" PostTypeId="2" ParentId="10281" CreationDate="2015-04-24T09:37:02.850" Score="2" Body="&lt;p&gt;One possible solution is to use a &quot;global&quot; interrupt pin which all the sensors use, and also normal GPIO pins to work out which interrupt has occurred.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feed the interrupt signals into a multiple-input OR gate (if they are active HIGH) or a multuple-input AND gate (if they are active LOW).  The output of that AND gate goes to a single INT pin.  Each interrupt signal also goes to a normal IO pin.  When the interrupt pin triggers the ISR can then look at the IO pins to determine which of the interrupt signals that triggered the interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5joiB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For fastest operation use IO pins that are on the same port and use direct register reading for that port to see which bits are on and which are off.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-04-24T09:37:02.850" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="10298" PostTypeId="2" ParentId="9549" CreationDate="2015-04-24T12:11:52.187" Score="0" Body="&lt;p&gt;You should consider using hardware timers (&lt;code&gt;millis()&lt;/code&gt; uses this, see answer of edgarBonnet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you might want to use a Real Time (Calendar) Clock chip, which often has even better accuracy (some even adjust to temperature). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a possibility is using a GPS module, and using the GPS time which should be extremely accurate and will not drift (since it's synchronized).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Post on AVR timer precision (hardware timers):&#xA;&lt;a href=&quot;http://www.seanet.com/~karllunt/interval.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seanet.com/~karllunt/interval.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RTC (Real Time Clock) example:&#xA;&lt;a href=&quot;http://www.instructables.com/id/Real-Time-Clock-DS1302/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Real-Time-Clock-DS1302/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS example:&#xA;&lt;a href=&quot;http://blog.arduino.cc/2014/01/06/simple-arduino-micro-gps-clock-project-arduinomicromonday/&quot; rel=&quot;nofollow&quot;&gt;http://blog.arduino.cc/2014/01/06/simple-arduino-micro-gps-clock-project-arduinomicromonday/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-05-26T09:11:18.960" LastActivityDate="2015-05-26T09:11:18.960" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10299" PostTypeId="1" AcceptedAnswerId="10312" CreationDate="2015-04-24T13:44:52.557" Score="2" ViewCount="1172" Body="&lt;p&gt;I want to be able to dim various high powered (20mA) LEDs in an array (8X12 LEDs). I do not need individual control, but would like to be able to dim each row (or two rows together) so that I can create gradients. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important caveat is that I can't use pulse width modulation (PWM) as there should be no flashing whatsoever, even if it is invisible to humans. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How can I best achieve this?&lt;/strong&gt;&#xA;(I do not care about energy efficiency)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fist thing I found which seemed to be the right solution in the beginning is using digital potentiometers as explained in &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/SPIDigitalPot&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;. However they only support low currents so I can't use one channel for 8 or 16 LEDs. &#xA;Maybe I could use various digipots in parallel with one Arduino, each powering 1 LED per channel? But that sounds overcomplicated and a nightmare to wire up. Is there a more elegant solution? &lt;/p&gt;&#xA;" OwnerUserId="8657" LastEditorUserId="2881" LastEditDate="2015-04-24T18:52:57.727" LastActivityDate="2015-04-26T21:15:35.783" Title="How can I best control various high power LEDs without using PWM" Tags="|led|potentiometer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10300" PostTypeId="5" CreationDate="2015-04-24T15:04:39.000" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-04-24T15:04:39.000" LastActivityDate="2015-04-24T15:04:39.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10301" PostTypeId="4" CreationDate="2015-04-24T15:04:39.000" Score="0" Body="A graphic and sound shield for Arduino, featuring a 4.3 inch display, headphone jack, accelerometer and microSD slot." OwnerUserId="6452" LastEditorUserId="6452" LastEditDate="2015-04-24T17:33:39.710" LastActivityDate="2015-04-24T17:33:39.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10302" PostTypeId="1" CreationDate="2015-04-21T18:17:28.950" Score="0" ViewCount="47" Body="&lt;p&gt;Board: OE Gravitech Nano&#xA;Is it possible to destroy the board if there are a voltage on a Analog pin while the board is not powered? &#xA;I have a application that use a analog (speed) voltage 0-4,9 from a GPS module, this worked very nice for a hour of 10, after that the voltage seems to be not constant available.&#xA;Maybe the user have powered off the Arduino while driving the machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Rien&lt;/p&gt;&#xA;" OwnerUserId="8638" OwnerDisplayName="Rien Brand" LastActivityDate="2015-04-24T15:28:57.780" Title="Nano destroyed?" Tags="|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10303" PostTypeId="2" ParentId="10302" CreationDate="2015-04-21T18:25:01.967" Score="2" Body="&lt;p&gt;Assuming you're talking about the device with &lt;a href=&quot;http://www.mouser.com/pdfdocs/ArduinoNano30_schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this schematic&lt;/a&gt; (or similar), the &quot;analog&quot; pins go directly to Atmel AVR I/O pins with no series resistance, so yes, it's quite possible to damage the microcontroller. Add some series resistance of a few K and you'll have a better chance of the part surviving such an event. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage on any pin should not, under any circumstances exceed Vcc+ 0.5V as the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; specifies, however it's usually okay under non-operational conditions if the current is limited to much less than the 40mA. A 4.7K resistor would limit the current to less than 1mA with a 5V input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lBahq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="5080" OwnerDisplayName="Spehro Pefhany" LastActivityDate="2015-04-21T20:44:13.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10304" PostTypeId="2" ParentId="10295" CreationDate="2015-04-24T16:17:55.007" Score="2" Body="&lt;p&gt;You can use shift registers to control the relays. This will only use 3 pins and allow you to use the xbee. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the RGB LEDs you can use the &lt;a href=&quot;https://www.sparkfun.com/products/10136&quot; rel=&quot;nofollow&quot;&gt;TLC5940&lt;/a&gt; to control 16 channels, so you will need two, giving you 32 channels. This is a PWM chip with serial interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering you will be using the board linked. It is driven by transistors, so you can use the shift registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the power supply, if you will be operating all of the relays at the same time it will draw about 650 mA (9x72mA), you will need a separate 5V power supply for the relay board, as I believe drawing that much current will heat the board and regulator a lot. If one at a time it will not draw too much, so its possible you can run it all off the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=94255.0&quot; rel=&quot;nofollow&quot;&gt;forum&lt;/a&gt; post of someone running 360 relays with shift registers. &lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2015-04-24T16:47:34.183" LastActivityDate="2015-04-24T16:47:34.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10305" PostTypeId="2" ParentId="10192" CreationDate="2015-04-24T17:00:09.923" Score="3" Body="&lt;p&gt;I use the female headers from the original Nano manufacturer: &lt;a href=&quot;http://gravitech.us/2015feheanas.html&quot; rel=&quot;nofollow&quot;&gt;http://gravitech.us/2015feheanas.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8638" LastActivityDate="2015-04-24T17:00:09.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10306" PostTypeId="2" ParentId="10281" CreationDate="2015-04-24T18:22:19.073" Score="0" Body="&lt;p&gt;Just FYI, the interrupt is not essential. If you can write efficient code you can read an MPU(DMP) without it (UNO, been there, done that). But that is only for one MPU. I doubt if an UNO can keep up with 10, no idea about the faster processors. In any case, even with interrupts, I doubt if an UNO could keep up with 10. Keep googling and you will find a note how to change the sampling rate to slow the MPU down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code you referenced provides AHRS (Attitude Heading Reference System) - I would be real curious to see what projects needs 10 of those :) Sounds like fun.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-04-24T18:22:19.073" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10307" PostTypeId="2" ParentId="10152" CreationDate="2015-04-24T20:23:50.007" Score="-1" Body="&lt;p&gt;have a look at &lt;a href=&quot;https://github.com/TMRh20&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/TMRh20&lt;/a&gt; he's done some great work on the nrf24 radios and has code allowing connection between arduinos and pi's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh and while i've played with non ip addressed data transfer a bit it wasn't the main focus of my research, but shouldn't the tx addresses be matched up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;also you mention a 2.2uf cap on the 3.3v line, but what is supplying the 3.3v line on the arduino side? &#xA;iirc the pi will supply enough current on its 3.3v line to supply the radio (i remember it working well enough) and i don't know what voltage your running the MEGA at, 3.3v or 5v with level shifters, either way i would imagine your power supply would be sufficient. Unless your running the mega at 16mhz and on a 3.3v (to be stable needs ~4.1v &lt;a href=&quot;https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz&quot;&gt;https://electronics.stackexchange.com/questions/58818/programming-3-3v-atmega328-running-at-16mhz&lt;/a&gt;) &#xA;Also iirc most nrf24's are happy enough with 5v logic level, although there are plenty of clones out there, you'll have to do your own testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you have one to hand would suggest starting off with a non breadboard arduino, get it to work before moving onto the breadboard... there is less that could go wrong :)&lt;/p&gt;&#xA;" OwnerUserId="8661" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-04-25T00:52:24.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10308" PostTypeId="1" AcceptedAnswerId="10309" CreationDate="2015-04-25T01:05:24.787" Score="5" ViewCount="19973" Body="&lt;p&gt;my MPU6050 works very unstable , the problem is unable clear excessed FIFO buffer on MPU6050, I am using Jeff Rowberg's MPU library and according to his DMP example but without using interruptions,here is my modified code but I've tried several method listed in the library to clear buffer but doesn't work.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks very much! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;#include &quot;Wire.h&quot;&#xA;&#xA;MPU6050 mpu(0x69); //AD0=High&#xA;&#xA;&#xA;//MPU control/status vars &#xA;bool dmpReady = false; &#xA;uint8_t mpuIntStatus;  //actual interrupt status byte &#xA;uint8_t deviceStatus; //device status , 0 = success , &#xA;uint16_t packetSize; //expected DMP packet size (defult 42) -- ?&#xA;uint16_t fifoCount; //count of all bytes currently in FIFO&#xA;uint8_t fifoBuffer[64]; // FIFO buffer storage &#xA;&#xA;// orientation/motion vars&#xA;Quaternion q;           // [w, x, y, z]         quaternion container&#xA;VectorInt16 aa;         // [x, y, z]            accel sensor measurements&#xA;VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements&#xA;VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements&#xA;VectorFloat gravity;    // [x, y, z]            gravity vector&#xA;float euler[3];         // [psi, theta, phi]    Euler angle container&#xA;float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;volatile bool mpuInterrupt = false;&#xA;//void dmpDataReady() {&#xA;//  mpuInterrupt = true;&#xA;//}&#xA;&#xA;&#xA;// put your setup code here, to run once:&#xA;void setup() {&#xA;  //join I2C bus &#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;        Wire.begin();&#xA;        TWBR = 48; // 400kHz I2C clock (200kHz if CPU is 8MHz)&#xA;    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;        Fastwire::setup(400, true);&#xA;    #endif&#xA;  //initialize serial communication&#xA;  Serial.begin(115200);&#xA;  while(!Serial); //common for Leonardo issues&#xA;&#xA;  //initialize the mpu &#xA;  Serial.println(&quot;Call MPU6050 Lib to initialize devices...&quot;);&#xA;  mpu.initialize(); //initialize I2C device by using MPU6050 library &#xA;&#xA;  //verify connection&#xA;  Serial.println(&quot;Tesing device connections&quot;);&#xA;  Serial.println(mpu.testConnection() ? F(&quot;MPU6050 connection test successed &quot;) : F(&quot;MPU6050 connection test failed&quot;));&#xA;&#xA;//  //wait for begin , uncomment if we need wait user interruption&#xA;//  Serial.println(&quot;Press any button to begin&quot;);&#xA;//  while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer&#xA;//  while (!Serial.available());                 // wait for data&#xA;//  while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer again&#xA;&#xA;&#xA;  //load and configure DMP &#xA;  Serial.println(&quot;initializing DMP&quot;); &#xA;  deviceStatus = mpu.dmpInitialize(); //use MPU6050 library to inilisalize the dmp &#xA;&#xA; //feed offsets &#xA;  mpu.setXGyroOffset(220);&#xA;  mpu.setYGyroOffset(76);&#xA;  mpu.setZGyroOffset(-85);&#xA;  mpu.setZAccelOffset(1788); // 1688 factory default for my test chip&#xA;&#xA;  //make sure it works &#xA;  if (deviceStatus == 0) {&#xA;    Serial.println(&quot;DMP initialization success, now enable DMP for use&quot;);&#xA;    //turn on DMP &#xA;    mpu.setDMPEnabled(true); //use MPU6050 library to enable DMP)&#xA;&#xA;    //wait for first interrup . currently just leave it false automatically &#xA;    mpuInterrupt == false; &#xA;&#xA;    //let main llop know it's ok to use DMP, set dmpRead flag to ture &#xA;    dmpReady = true;&#xA;    Serial.println(&quot;DMP is ready to use.&quot;);&#xA;&#xA;    //get expected DMP packet size for later comparison &#xA;    packetSize = mpu.dmpGetFIFOPacketSize();&#xA;  } else {&#xA;    //ERROR! , device status !=0 when initializing DMP&#xA;    Serial.print(&quot;DMP initialization failed when using MPU6050 library:&quot;);&#xA;    if (deviceStatus == 1) {&#xA;      Serial.println(&quot; intial memory load failed&quot;);&#xA;    } else if (deviceStatus == 2) {&#xA;      Serial.println(&quot; failed to update DMP configuration&quot;);&#xA;    } else {&#xA;      Serial.print(&quot; unknow error with code: &quot;);&#xA;      Serial.println(deviceStatus);&#xA;    }&#xA;}&#xA;}&#xA;&#xA;&#xA;int ticket = 1;&#xA;void printOnlyOnce (String message){&#xA;  if (ticket == 1){&#xA;   Serial.println(message);&#xA;   ticket = 0 ;&#xA;  } else {&#xA;    return;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  //if DMP not ready don't do anything &#xA;  if (!dmpReady) {&#xA;    printOnlyOnce(&quot;MAIN LOOP: DMP disabled&quot;);&#xA;    return;&#xA;  } else {&#xA;&#xA;    //testing overflow &#xA;    if (fifoCount == 1024) {&#xA;      mpu.resetFIFO();&#xA;      Serial.println(&quot;FIFO overflow&quot;);&#xA;    } else {&#xA;&#xA;&#xA;    //wait for enough avaliable data length&#xA;    while (fifoCount &amp;lt; packetSize) {&#xA;      //waiting until get enough&#xA;      fifoCount = mpu.getFIFOCount();&#xA;    }&#xA;&#xA;&#xA;    //read this packet from FIFO buffer &#xA;    mpu.getFIFOBytes(fifoBuffer,packetSize);&#xA;&#xA;    //track FIFO count here is more then one packeage avalible &#xA;&#xA;    //reset fifo count &#xA;    fifoCount -= packetSize ;&#xA;    Serial.println(fifoCount);&#xA;&#xA;    if (fifoCount &amp;gt; 2) {&#xA;        ////// clear fifo buffer &#xA;    }&#xA;    //display stage &#xA;                // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;            Serial.print(&quot;ypr\t&quot;);&#xA;            Serial.print(ypr[0] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(ypr[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(ypr[2] * 180/M_PI);&#xA;  }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8643" LastActivityDate="2018-12-11T07:24:18.387" Title="How to clear FIFO buffer on MPU6050?" Tags="|arduino-uno|arduino-mega|mpu6050|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10309" PostTypeId="2" ParentId="10308" CreationDate="2015-04-25T05:29:58.623" Score="4" Body="&lt;p&gt;Yank,&#xA;I ended up clearing the buffer after every read.  In your code it would be following the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//read this packet from FIFO buffer &#xA;mpu.getFIFOBytes(fifoBuffer,packetSize);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I added &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mpu.resetFIFO();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I came to this conclusion after watching when the over flows occurred. The fifo buffer is adding on to the end of the buffer, and when it gets full, rather than wrap, it over flows. Reading does not seem to remove data from buffer in any way.  By clearing the buffer you might be discarding data, but the DMP is doing the integration for AHRS for you, so you really do not need to worry about dropping data since you are only interested in the current pitch,roll,yaw or Euler or whatever, at least that was my case.&#xA;I am running it on an Arduino UNO shield prototype and it is rock solid stable (at the default 100 hz rate). See spiked3.com PiPlate / Pilot.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-04-25T05:29:58.623" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10310" PostTypeId="2" ParentId="8450" CreationDate="2015-04-25T06:25:17.890" Score="1" Body="&lt;p&gt;If you want just to control and receive data from your end user, option 2 is easy to implement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use any programming language that supports serial communication such as python, node.js, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you have to is to note how your coordinator is recognized by your operating system (in windows as com1 port, unix-like as ttyACM or similar) and open it from your preferred language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, you establish a protocol that should be agreed with your Arduino. For example. Suppose you want to collect data from end user, so, you send a message from the coordinator connected in your PC with a code #data through the serial. When the Arduino receives it, it decodes the message and return something like #d125 where it says it is sending the data and the value is 125 (supposing integer values).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making sure you already have configured the XBees in the same network by setting Same PAN id and cross setting the destination address of each one so they send packates to each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am supposing you are using AT transparent mode where they just send whatever comes in the serial interface, in this mode they work basically sending chunks of bytes and it is up to you to establish a protocol to provide a good flow of data. In this mode there is no guarantee that your packet will reach the destination. In order to fully extend the XBee usage, you'd need the API mode where all the transmission checks are done. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for you purpose, AT mode seems enough. &lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-25T06:25:17.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10312" PostTypeId="2" ParentId="10299" CreationDate="2015-04-25T07:58:18.863" Score="1" Body="&lt;p&gt;The figure below illustrates a method of current control.  It shows four LEDs in a 2x2 arrangement; one  would adapt the number of LEDs in series or parallel in accord with how one's array is wired, what voltages are available, LED current requirements, transistor power limitations, etc. &lt;em&gt;[Edit: See transistor-power example calculation at end.]&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each separately-controlled group of LEDs would need one such circuit.  Each circuit needs one control voltage (eg, from a DAC or a digital potentiometer voltage divider circuit) and needs one transistor per series chain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9vx8w.jpg&quot; alt=&quot;figure 1, cc circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Circuit Operation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose the following conditions hold.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Q1 and Q2 are equivalent transistors and V&lt;sub&gt;be&lt;/sub&gt; is 0.7 V typ. (one diode drop)&lt;/li&gt;&#xA;&lt;li&gt;D1, D2, D3, D4 are equivalent LEDs&lt;/li&gt;&#xA;&lt;li&gt;Resistors R1, R2 are small and equal (eg 1–30Ω)&lt;/li&gt;&#xA;&lt;li&gt;V1 is some fixed DC voltage, eg about 1 V&lt;/li&gt;&#xA;&lt;li&gt;V &gt; 2*V&lt;sub&gt;f&lt;/sub&gt; + V&lt;sub&gt;be&lt;/sub&gt; + V&lt;sub&gt;R&lt;/sub&gt; where V&lt;sub&gt;f&lt;/sub&gt; = typical forward voltage of D1...4 &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Under these conditions, V1 will drive current into the bases of Q1 and Q2, causing transistor-amplified current to flow through R1 and R2 and maintain the condition V1 = V&lt;sub&gt;be&lt;/sub&gt; + V&lt;sub&gt;R1&lt;/sub&gt; = V&lt;sub&gt;be&lt;/sub&gt; + V&lt;sub&gt;R2&lt;/sub&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a concrete example:  Suppose we want 23 mA through each LED and that R1=R2=17Ω. V&lt;sub&gt;R&lt;/sub&gt; = IR = 0.023 mA · 17 Ω = 0.391 V.  If V&lt;sub&gt;be&lt;/sub&gt; is about 0.7 V, then we set V1 = 0.7 + 0.391 V or about 1.09 V to get 23 mA through each LED.  More generally, to get current I through the LEDs we solve V1 = V&lt;sub&gt;be&lt;/sub&gt; + V&lt;sub&gt;R&lt;/sub&gt; = 0.7 + IR = 0.7 + I·17.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Base current:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The amount of current required from the V1 voltage source depends on transistor &lt;a href=&quot;http://en.wikipedia.org/wiki/Bipolar_junction_transistor#h-parameter_model&quot; rel=&quot;nofollow noreferrer&quot;&gt;h&lt;sub&gt;FE&lt;/sub&gt; or β&lt;/a&gt;.&#xA;Eg, if β is about 100 and I&lt;sub&gt;LED&lt;/sub&gt; is 20 mA then each transistor will need about 20/100 mA or about 200 μA of base drive.  This amount of current probably could be delivered by a voltage divider based on an AD5206 (the digital potentiometer chip that's used in the &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/SPIDigitalPot&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPIDigitalPot&lt;/a&gt; tutorial mentioned in the question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Power Dissipation:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AD5206 digital potentiometer datasheet shows an absolute maximum rating for Package Power Dissipation of  (T&lt;sub&gt;J&lt;/sub&gt;MAX-T&lt;sub&gt;A&lt;/sub&gt;)/θ&lt;sub&gt;JA&lt;/sub&gt;.  If ambient T&lt;sub&gt;A&lt;/sub&gt; is 25℃ and θ&lt;sub&gt;JA&lt;/sub&gt; is 70°C/W (as for a SOIC package) this gives (150-25)/70 = 1.8 W max package power.  However, it would be reasonable to limit dissipation to under half a watt.  In the 10 KΩ version of the AD5206, that means a little less than 2.9 mA maximum per channel.  [I = √(0.5 W /(6 channels * 10000Ω)).]  If several low-beta transistors are used to drive several strings of LEDs, 2.8 mA might be marginal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Voltage-divider Linearity:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only a small fraction of the current through a voltage divider can be drawn off without upsetting the division ratio.  A &lt;a href=&quot;http://en.wikipedia.org/wiki/Buffer_amplifier#Voltage_buffer_examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;unity gain buffer&lt;/a&gt; amplifier [as in the following figure] can be used to increase linearity of voltage-divider output by providing a high-impedance connection to the divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rZykZ.jpg&quot; alt=&quot;figure 2, unity gain buffer with voltage divider input&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(In the figure above, R1 and R2 are not related to R1 and R2 of the previous figure.  Here, R2 represents a digitally-variable resistor.  Choose R1 and R3 so that V1's range is from slightly below V&lt;sub&gt;be&lt;/sub&gt; to slightly above  V&lt;sub&gt;be&lt;/sub&gt; + I&lt;sub&gt;max&lt;/sub&gt;R, where I&lt;sub&gt;max&lt;/sub&gt; is the maximum LED current desired.  For example: Suppose V=5 V, that R2's total resistance is 10 KΩ, that R is 15Ω, that V&lt;sub&gt;be&lt;/sub&gt; is 0.7 V, and I&lt;sub&gt;max&lt;/sub&gt; is 25 mA.  Let R&lt;sub&gt;T&lt;/sub&gt; = R1+R2+R3.  Now R3/R&lt;sub&gt;T&lt;/sub&gt; = V&lt;sub&gt;be&lt;/sub&gt;/V = 0.7/5 = 0.14, and R1/R&lt;sub&gt;T&lt;/sub&gt; = (V - V&lt;sub&gt;be&lt;/sub&gt; - I&lt;sub&gt;max&lt;/sub&gt;R)/V = (5 - 0.7 - 0.025·15)/5 = 3.925/5 = 0.785.  Thus R1+R3 = 0.925·R&lt;sub&gt;T&lt;/sub&gt;, whence 0.075·R&lt;sub&gt;T&lt;/sub&gt; = R2 = 10 KΩ, giving R&lt;sub&gt;T&lt;/sub&gt; = 133 KΩ, R1 = 105 KΩ, and R3 = 19 KΩ.  With these R1 and R2 values, each digital pot step should give a change in LED current of 25/256 mA, or about 98 μA.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;[Edit:  When V1 is set to less than V&lt;sub&gt;BE&lt;/sub&gt;, no current will flow through the LEDs.  That is, to turn off the controlled LEDs, set V1 to V&lt;sub&gt;BE&lt;/sub&gt; or less.]&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PWM with RC filter:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be worthwhile to experiment with using a PWM-driven low pass &lt;a href=&quot;http://en.wikipedia.org/wiki/RC_circuit&quot; rel=&quot;nofollow noreferrer&quot;&gt;RC filter&lt;/a&gt; to supply V1, possibly avoiding need for buffer amplifiers and digital potentiometers.  See eg “Arduino’s AnalogWrite – Converting PWM to a Voltage”&#xA;by Scott Daniels at &lt;a href=&quot;http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/&quot; rel=&quot;nofollow noreferrer&quot;&gt;provideyourown.com&lt;/a&gt;, and also see the &lt;a href=&quot;http://sim.okawa-denshi.jp/en/PWMtool.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;filter-calculation page&lt;/a&gt; it refers to.  You might need an oscilloscope to verify the design and its quality of results, and might need to use several RC filter stages in a row to adequately filter out ripple, but it can be done, at the cost of slower response to control changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Transistor-power example calculations:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Letting  V&lt;sub&gt;CE&lt;/sub&gt;, I&lt;sub&gt;CE&lt;/sub&gt;, V&lt;sub&gt;BE&lt;/sub&gt;, and I&lt;sub&gt;BE&lt;/sub&gt; represent collector-to-emitter and base-to-emitter voltages and currents, transistor power dissipation is V&lt;sub&gt;CE&lt;/sub&gt;·I&lt;sub&gt;CE&lt;/sub&gt;+V&lt;sub&gt;BE&lt;/sub&gt;·I&lt;sub&gt;BE&lt;/sub&gt;.  Because V&lt;sub&gt;BE&lt;/sub&gt;·I&lt;sub&gt;BE&lt;/sub&gt; is likely to be sub-milliwatt, we ignore it in following, taking P ≅ V&lt;sub&gt;CE&lt;/sub&gt;·I&lt;sub&gt;CE&lt;/sub&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the LED-driving circuit,  V&lt;sub&gt;CE&lt;/sub&gt; = V – V&lt;sub&gt;LEDs&lt;/sub&gt; – V&lt;sub&gt;sense&lt;/sub&gt;, where V&lt;sub&gt;LEDs&lt;/sub&gt; is the series voltage across the chain of LEDs the transistor controls, and V&lt;sub&gt;sense&lt;/sub&gt; is the voltage across the sense resistor (ie, across R1 or R2 in the top figure).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, it is a good idea to keep V&lt;sub&gt;sense&lt;/sub&gt; small (under a volt) to allow a wider compliance range – ie, so that LED current is the same over a wider range of variation of supply voltage V.  Thus, the approximation  V&lt;sub&gt;CE&lt;/sub&gt; ≅ V – V&lt;sub&gt;LEDs&lt;/sub&gt; is reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a concrete example: Suppose we have eight LEDs in series, and they are white LEDs with about 3.6 V forward drop at 20 mA. [LEDs of different colors may have different drops; eg see &lt;a href=&quot;http://www.oksolar.com/led/led_color_chart.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;LED color chart&lt;/a&gt; at oksolar.com.]  Then V&lt;sub&gt;LEDs&lt;/sub&gt; = 8·3.6 V = 28.8 V. We need V&lt;sub&gt;(BR)CEO&lt;/sub&gt; &gt; V &gt; V&lt;sub&gt;LEDs&lt;/sub&gt; + V&lt;sub&gt;BE&lt;/sub&gt; + V&lt;sub&gt;sense&lt;/sub&gt;, where  V&lt;sub&gt;(BR)CEO&lt;/sub&gt; = collector-emitter breakdown voltage (which is 40 V min. for 2N3904 or 2N2222).  Allowing a volt for V&lt;sub&gt;sense&lt;/sub&gt; and 0.7 V for V&lt;sub&gt;BE&lt;/sub&gt; we have V &gt; 28.8 + 0.7 + 1 = 30.5 V.  Let's suppose V=32 V.  Then P &amp;lt; (32–28.8)·0.020 W = 64 mW.  Thus a small general purpose NPN transistor will work, for example a 2N3904 (rated at 350 mW to 1 W, depending on package, before derating for ambient and heatsinking) or a 2N2222 (similarly rated).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a second example, suppose V&lt;sub&gt;LEDs&lt;/sub&gt; = 8·1.7 V = 13.6 V (for, eg, eight infrared LEDs at 50 mA) and V=32 V.  Then P ≅  (32–13.6)·0.050 W = 920 mW, so a larger (and heatsinked) transistor would be needed.  Or, V could be decreased, say to 16 V, giving  P ≅  (16–13.6)·0.050 W = 120 mW, allowing use of a small transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a third example, suppose eight LEDs are paralleled (rather than seriesed), that V&lt;sub&gt;LEDs&lt;/sub&gt; = 2.0 V at 20 mA, that V&lt;sub&gt;sense&lt;/sub&gt; is about 0.4 V at desired operating point, and that V=5 V.  The transistor will need to drop 5-2-0.4 V = 2.6 V at 160 mA, which is 416 mW, probably large enough to require a heatsink.  [Note:  if LEDs are placed in parallel and driven by a single transistor, some of them probably will be dimmer than others; “current hogging” may occur in some of the LEDs, making them brighter than the others.  However, many cheap flashlights connect LEDs in parallel without individual current control.]&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-04-26T21:15:35.783" LastActivityDate="2015-04-26T21:15:35.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10313" PostTypeId="1" AcceptedAnswerId="10325" CreationDate="2015-04-25T08:07:18.307" Score="0" ViewCount="11041" Body="&lt;p&gt;I have a single simple DC motor that upon a condition I wish to let it run for 3 minute. How can I do it in Arduino? a simple addition to the code will be great help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I use Adafruit motor shield this is my current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;Adafruit_DCMotor *myMotor = AFMS.getMotor(1);&#xA;&#xA;void setup() {&#xA;   Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;   AFMS.begin();  // create with the default frequency 1.6KHz&#xA;}&#xA;&#xA;void loop() {&#xA;IOvalue = 1000&#xA;&#xA;if (IOvalue = 1000) { &#xA;&#xA; //this is the motor I wish to run for 3 min &#xA;   myMotor-&amp;gt;setSpeed(25); &#xA;   myMotor-&amp;gt;run(FORWARD); &#xA;   delay(100); &#xA; }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot&lt;/p&gt;&#xA;" OwnerUserId="7936" LastEditorUserId="7936" LastEditDate="2015-04-25T09:01:13.823" LastActivityDate="2015-04-25T15:24:40.563" Title="Activate a DC motor for a fixed amount of time" Tags="|motor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10314" PostTypeId="2" ParentId="10313" CreationDate="2015-04-25T08:20:23.880" Score="-1" Body="&lt;pre&gt;&lt;code&gt;long int currentMillis;&#xA;void setup() {&#xA;    pinMode(motorPin, OUTPUT);&#xA;    digitalWrite(motorPin, LOW);&#xA;}&#xA;void loop() {&#xA;    if(condition is met){&#xA;        startOfMotor = millis();&#xA;        while(millis() != (startOfMotor+180000)){&#xA;            digitalWrite(motorPin, HIGH);&#xA;        }&#xA;    digitalWrite(motorPin, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;motorPin&lt;/code&gt; is the pin to which the motor is connected. &lt;code&gt;millis()&lt;/code&gt; gets the milliseconds after the board is started. 3 min = 180 seconds = 180000 ms.&lt;/p&gt;&#xA;" OwnerUserId="8630" LastEditorUserId="8630" LastEditDate="2015-04-25T08:39:26.610" LastActivityDate="2015-04-25T08:39:26.610" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10315" PostTypeId="1" CreationDate="2015-04-25T08:02:15.157" Score="2" ViewCount="12423" Body="&lt;p&gt;Does anyone know of a site or book where you can learn how to create, or for first reed, libraries. Because I think the libraries I use are sometimes unnecessary complicated, or have similar features, for example &lt;a href=&quot;http://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire&lt;/a&gt; and &lt;a href=&quot;http://playground.arduino.cc/Learning/OneWire&quot; rel=&quot;nofollow&quot;&gt;OneWire&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think, these make my sketch unnecessary big, when I need both of them.&lt;/p&gt;&#xA;" OwnerUserId="8638" OwnerDisplayName="Rien Brand" LastEditorUserId="6936" LastEditDate="2015-04-27T10:13:17.633" LastActivityDate="2015-04-28T00:51:52.683" Title="Making my own libraries" Tags="|programming|library|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10316" PostTypeId="2" ParentId="10288" CreationDate="2015-04-25T09:53:13.397" Score="1" Body="&lt;p&gt;Do you use a pump to circulate the water flow, if so maybe you have a better result with a variable pump speed (PWM), in state of a variable valve opening.&lt;/p&gt;&#xA;" OwnerUserId="8638" LastActivityDate="2015-04-25T09:53:13.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10317" PostTypeId="1" AcceptedAnswerId="38666" CreationDate="2015-04-25T10:47:43.720" Score="5" ViewCount="19218" Body="&lt;p&gt;I hooked up a 16x2 Arduino compatible LCD yesterday and made sure all the connections were according to the program and the schematics provided all over the web. My contrast is adjusted perfectly but the problem is that there are black boxes on the top line while the lower one is empty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LO0Vk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LO0Vk.jpg&quot; alt=&quot;Black boxes on top row only of LCD&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this question has been asked many times but no one has answered the question other than saying, &quot;Check your contrast pin&quot;. I'm using the default sample code provided in the Arduino IDE.&#xA;HELP!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards.&lt;/p&gt;&#xA;" OwnerUserId="8666" LastEditorUserId="19409" LastEditDate="2017-05-19T16:06:11.647" LastActivityDate="2019-09-10T13:35:02.253" Title="Arduino 16x2 LCD Black Boxes" Tags="|lcd|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="10319" PostTypeId="1" CreationDate="2015-04-25T13:57:55.657" Score="2" ViewCount="979" Body="&lt;p&gt;I'm using the I2C library to connect to a GY-521 board and, when executing the getAcceleration() methods I get gyro values and viceversa..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my setup (I'm using a proto shield but that shouldn't change anything as far as I understand):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/H0UV4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It follows this schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Chs6l.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is the code I'm testing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;#include &quot;MPU6050.h&quot;&#xA;&#xA;MPU6050 accel;&#xA;&#xA;int16_t ax, ay, az;&#xA;&#xA;void setup() {&#xA;    Wire.begin();&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Initializing I2C devices...&quot;);&#xA;    accel.initialize();&#xA;    Serial.println(&quot;Testing device connections...&quot;);&#xA;    Serial.println(accel.testConnection() ? &quot;Connected&quot; : &quot;Connection failed&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    accel.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;    Serial.print(&quot;acc x:    &quot;);&#xA;    Serial.println(ax);  // This prints the gyro value of the Y axis!&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't think it has to do with the wiring since inverting the 4 and 5 analog pins yields zero values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a problem with the library? Or with my chip?&lt;/p&gt;&#xA;" OwnerUserId="8668" LastEditorUserId="8668" LastEditDate="2015-04-25T14:26:35.513" LastActivityDate="2022-11-26T23:04:55.567" Title="Getting inverse values of acceleration and tilt for the MPU 6050" Tags="|i2c|mpu6050|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10320" PostTypeId="1" AcceptedAnswerId="10329" CreationDate="2015-04-25T14:27:10.383" Score="1" ViewCount="1189" Body="&lt;p&gt;This might be a very stupid question but please bear with me. So I am using an HC-SR04 Ultrasonic sensor model (5 V) and I want to connect it to Arduino Uno. Do I have to use an external power supply for the ultrasonic sensor (just like with the motors) in order to connect it to the Arduino? Or can I just use the 5 V pin?&lt;/p&gt;&#xA;" OwnerUserId="8670" LastEditorUserId="4628" LastEditDate="2018-01-07T06:48:13.010" LastActivityDate="2018-01-07T06:48:13.010" Title="Do I have to use an external power supply when connecting an ultrasonic sensor to Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10323" PostTypeId="2" ParentId="9856" CreationDate="2015-04-25T14:48:03.540" Score="0" Body="&lt;p&gt;You should start to debug your code stepwise. I.e. insert debug output commands (print via serial) at some crucial points to find the block of code which resets your device. Then narrow it down, until you know the very command which breaks your setup. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe, there will be more than one point in your software, which is responsible for the failure. Nonetheless you will be wiser after that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you will probably have to dive into the guts of the libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have identified some command or procedure call responsible for the reboot, it may be still a hardware issue. Writing SD-cards consumes considerable amount of power. If you supply your device solely via USB, I recommend buying an additional PSU and see, if the behaviour changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next thing is to check the reset-signal on all of your shields and daughter-boards for unwanted connections like solder-bridges or single wire threads snipped of elswhere. Another funny thing are stacking connectors not matching the mainboard and shorting something on it.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-04-25T14:48:03.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10325" PostTypeId="2" ParentId="10313" CreationDate="2015-04-25T15:24:40.563" Score="1" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;Adafruit_DCMotor *myMotor = AFMS.getMotor(1);&#xA;boolean motorRunning = false;&#xA;unsigned long motorStartMillis;&#xA;unsigned long motorRunMillis = 180000;&#xA;&#xA;void setup() {&#xA;   Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;   AFMS.begin();  // create with the default frequency 1.6KHz&#xA;}&#xA;&#xA;void loop() {&#xA;  IOvalue = 1000&#xA;&#xA;  if (IOvalue = 1000) {&#xA;    //this is the motor I wish to run for 3 min &#xA;    myMotor-&amp;gt;setSpeed(25); &#xA;    myMotor-&amp;gt;run(FORWARD); &#xA;    motorStartMillis = millis();&#xA;    motorRunning = true;&#xA;  }&#xA;&#xA;  // check if motor is running and time-to-run has elapsed&#xA;  if( motorRunning &amp;amp;&amp;amp; (millis()-motorStartMillis &amp;gt; motorRunMillis) )&#xA;  {&#xA;    myMotor-&amp;gt;setSpeed(0); &#xA;    myMotor-&amp;gt;run(RELEASE);&#xA;    motorRunning = false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-25T15:24:40.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10326" PostTypeId="1" AcceptedAnswerId="14537" CreationDate="2015-04-25T15:40:46.550" Score="0" ViewCount="1091" Body="&lt;p&gt;I have an Arduino setup from which I can control my RGB LED strip from my computer using LAN.&lt;/p&gt;&#xA;&lt;p&gt;It worked like a charm in the start, but after two days, my Ethernet Shield W5100 for Arduino Uno stopped working, and I can't figure out why.&lt;/p&gt;&#xA;&lt;p&gt;When I connect the Ethernet Shield, the red LED &amp;quot;pwr&amp;quot; is solid red and the &amp;quot;FULLD&amp;quot; flashes orange every second.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The setup:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have followed an Adafruit guide, connecting the Arduino as such: &lt;img src=&quot;https://i.stack.imgur.com/VOa9Y.gif&quot; alt=&quot;Image from Adafruit.com&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;On top of the Arduino, I have the Ethernet Shield. All this is powered by an 12V/4A power supply connected to the Arduinos 2.1mm jack.&lt;/p&gt;&#xA;&lt;p&gt;As I said, this setup worked fine for a few days. While it was on, I noticed the Arduino getting somewhat hot, but some google searches assured me that Arduino Uno can handle high temperatures, so I did not pay any attention to it.&lt;/p&gt;&#xA;&lt;p&gt;The LED strip is not too long - about 2 meters with about 150 LEDs.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;What I have tried:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I detach the Arduino from my breadboard, the Ethernet Shield&#xA;will still not connect&lt;/li&gt;&#xA;&lt;li&gt;I have tried connecting the Shield to another Power Supply (Computer USB) using another Arduino, but the Shield would still not connect.&lt;/li&gt;&#xA;&lt;li&gt;I have added a debugging Serial.print message in the Arduino loop function. When using serial monitor, this message is printed over and over again (as if it is stuck in a reset loop)&lt;/li&gt;&#xA;&lt;li&gt;I have verified for MAC address collisions, even changed the MAC address of the Shield multiple times.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Have I somehow burned the Ethernet Shield? Why won't it work anymore?&lt;/p&gt;&#xA;" OwnerUserId="8674" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-08-25T22:20:22.667" Title="Is my Arduino Ethernet Shield broken?" Tags="|power|ethernet|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10327" PostTypeId="1" CreationDate="2015-04-25T16:02:19.893" Score="2" ViewCount="463" Body="&lt;p&gt;I want to build a program that will seek audio file inside a USB DOK (DisK On Key/Pen Drive) when it is inserted to the Circuits@Home USB Host shield. After a specified file will be found i want it to be played via the Audio library and the Teensy 3.1 12 Bit Analog Output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I can use an Arduino MEGA with the shield and the TMRpcm library: &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/TMRpcm/wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've saw that there's a sample with SD card and I've fiddled a lot to get the USB Host Shield 2.0 library to work and succeeded. However I've found a simpler implementation of it in the UsbFat library: &lt;a href=&quot;https://github.com/greiman/UsbFat&quot; rel=&quot;nofollow&quot;&gt;https://github.com/greiman/UsbFat&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now basically I need to connect between these two libraries but sadly I've failed to understand how to convert &quot;play_sd_wav.h&quot; to use the UsbFat Library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, more simply put, how do I command a USB pen drive like it is a SD card and pull an audio file from it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone can help please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ziv&lt;/p&gt;&#xA;" OwnerUserId="8677" LastActivityDate="2015-04-25T16:02:19.893" Title="Trying to play audio files on arduino via Usb Host Shield" Tags="|arduino-mega|usb|audio|teensy|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10328" PostTypeId="2" ParentId="10286" CreationDate="2015-04-25T17:21:32.960" Score="-1" Body="&lt;p&gt;A simple and fast solution would be implement a chart using a JavaScript library called Chart.js. it is simple and you can visualize your data in realtime. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try node.js to make the back-end by communicating via serial (serialport package is good) and send the data using socket.io.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is simple and you can set everything in less than 2 hours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://Chart.js&quot; rel=&quot;nofollow&quot;&gt;Chart.js&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently made some video tutorials about this and you see them &lt;a href=&quot;https://youtu.be/LNtmLapUSzw&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. The audio is in Portuguese but you can just skip and go directly to coding sections.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-25T17:21:32.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10329" PostTypeId="2" ParentId="10320" CreationDate="2015-04-25T17:43:39.053" Score="1" Body="&lt;p&gt;From the question I assume you power your Arduino via USB in which case you don't need an external supply. The HC-SR04 draws 15 mA with is far below the specifications for USB. I did this myself some time ago:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/J5bNc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-04-25T17:43:39.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10330" PostTypeId="1" CreationDate="2015-04-25T18:45:23.097" Score="3" ViewCount="1491" Body="&lt;p&gt;Fair warning: I'm a newbie when it comes to Arduino, so if I'm not too great at describing things, let me know so I can learn!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have recently built a fairly accurate laser timer to time sprinters through a section of a soccer pitch, giving a nice reading of their average speed through the zone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The limitation is that we would love to be able to see their speed as a progressive measurement throughout the sprint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem? I have NO idea where to start. Google has so far come up empty...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I have is the following link, &lt;a href=&quot;http://youtu.be/uPQgAdP14Ck&quot; rel=&quot;nofollow&quot;&gt;Best of the 2015 NHL All-Star Skills Competition&lt;/a&gt;, illustrating the sort of thing we would like to accomplish. The bit in question starts at around 0:35 when they are talking about sensors in the players' jerseys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any one able to point me in the right direction? &lt;/p&gt;&#xA;" OwnerUserId="8678" LastEditorUserId="6936" LastEditDate="2016-03-26T02:46:15.827" LastActivityDate="2016-12-21T14:17:31.797" Title="Speed sensors for sport" Tags="|arduino-uno|sensors|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10331" PostTypeId="2" ParentId="638" CreationDate="2015-04-25T23:20:52.220" Score="1" Body="&lt;p&gt;Standard car batteries are 12.6 volts there are 6 2.1V cells.  AGM batteries (i.e. Optima batteries, some interstates, and many other brands make AGM), in my experience with AGM batteries they are around 12.8 volts (I do not know the technical voltage).  Without the car running you do not need to worry about voltage spikes &lt;strong&gt;AS LONG AS THE WIRES TO AND FROM THE BATTERY ARE SHORT&lt;/strong&gt;.  When the car is running the serpentine belt turns the alternator which is an AC generator.  The alternator is connected to a rectifier to change it back to DC and the unit has a voltage regulator.  When the car is running the alternator runs the electrical system and charges the battery.  When you connect to the battery while the car is running you are actually connected to the alternator.  When connected to the alternator there is a ton of electrical noise, voltage spikes, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have always had success connecting straight from the battery to the Arduino through its barrel jack connector, I have not tried any analog read function when the car is running.  On the Arduino website it recommends 7-12V, however the limits (as listed on the Arduino website below the recommended) are 6-20. I have actually experienced problems with lower input voltages.  If you feel uncomfortable just buy a 5 volt regulator and power through the usb.  &lt;/p&gt;&#xA;" OwnerUserId="1192" LastActivityDate="2015-04-25T23:20:52.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10332" PostTypeId="1" CreationDate="2015-04-26T01:18:05.873" Score="1" ViewCount="469" Body="&lt;p&gt;I am using the Arduino Due and I am programming it with Atmel Studio 6.2. I have had a HUGE learning curve using this IDE and the Atmel ASF. Nothing is straightforward as it is in the Arduino IDE. Nonetheless, I want to toggle an LED on and off with a simple interrupt on a pull-up configured tactile button. This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;asf.h&amp;gt;&#xA;#include &quot;pio.h&quot;&#xA;&#xA;// Define the LED pins &#xA;#define BLUE_LED2 PIO_PC28 // Arduino Due pin 3&#xA;#define BLUE_LED3 PIO_PC26 // Arduino Due pin 4&#xA;#define BLUE_LED4 PIO_PC25 // Arduino Due pin 5&#xA;#define BLUE_LED5 PIO_PC24 // Arduino Due pin 6&#xA;#define BLUE_LED6 PIO_PC23 // Arduino Due pin 7&#xA;&#xA;// Define the button pins&#xA;#define BUTTON_1 PIO_PC22&#xA;#define BUTTON_2 PIO_PC21&#xA;&#xA;// Define function prototype for button interrupt&#xA;void button_press_handler(uint32_t, uint32_t);&#xA;void toggle_LED(uint32_t);&#xA;&#xA;&#xA;int main (void)&#xA;{&#xA;    /* Initialize the SAM system. */&#xA;    sysclk_init();&#xA;&#xA;    // Initialize input/out &#xA;    ioport_init();&#xA;    pmc_enable_periph_clk(ID_PIOC);&#xA;    pmc_enable_periph_clk(ID_PIOB);&#xA;&#xA;&#xA;    // Set LED pins as outputs and set there default values (off)&#xA;    pio_set_output(PIOC, BLUE_LED2, LOW, DISABLE, ENABLE); &#xA;    pio_set_output(PIOC, BLUE_LED3, LOW, DISABLE, ENABLE); &#xA;    pio_set_output(PIOC, BLUE_LED4, LOW, DISABLE, ENABLE); &#xA;    pio_set_output(PIOC, BLUE_LED5, LOW, DISABLE, ENABLE); &#xA;    pio_set_output(PIOC, BLUE_LED6, LOW, DISABLE, ENABLE); &#xA;&#xA;    // Set button pins as pull-up inputs &#xA;    pio_set_input(PIOC, BUTTON_1, PIO_PULLUP);&#xA;    pio_set_input(PIOC, BUTTON_2, PIO_PULLUP); &#xA;&#xA;    // Configure button input pin interrupt mode and handler (Falling Edge)&#xA;    pio_handler_set(PIOC, ID_PIOC, BUTTON_1,  PIO_IT_RISE_EDGE, button_press_handler);&#xA;    pio_handler_set(PIOC, ID_PIOC, BUTTON_2,  PIO_IT_RISE_EDGE, button_press_handler);&#xA;&#xA;    // Enable the interrupts&#xA;    pio_enable_interrupt(PIOC, BUTTON_1); &#xA;    pio_enable_interrupt(PIOC, BUTTON_2); &#xA;    NVIC_EnableIRQ(PIOC_IRQn); &#xA;&#xA;    while(1){&#xA;         // Doing stuff in here...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then this is my interrupt routine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Interrupt handler for button press&#xA;void button_press_handler(uint32_t a, uint32_t b)&#xA;{&#xA;    // Turn the LED's on or off&#xA;    toggle_LED(BLUE_LED2);&#xA;    toggle_LED(BLUE_LED3);&#xA;    toggle_LED(BLUE_LED4);&#xA;    toggle_LED(BLUE_LED5);&#xA;    toggle_LED(BLUE_LED6);&#xA;}&#xA;&#xA;// Function to toggle LED on/off&#xA;void toggle_LED(uint32_t LED){&#xA;&#xA;    if (pio_get(PIOC, PIO_TYPE_PIO_OUTPUT_0, LED))&#xA;    pio_clear(PIOC, LED);&#xA;    else&#xA;    pio_set(PIOC, LED); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Things work normal and as expected up until about 18 seconds in. After 18 seconds, the LED turns off if it is on. I tested this by setting LED 2 HIGH by default and removing the interrupt all together:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pio_set_output(PIOC, BLUE_LED2, HIGH, DISABLE, ENABLE); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case, the LED will stay on forever, but about every 18 seconds, the LED will flash off then back on once quickly. Why is this happening?&lt;/p&gt;&#xA;" OwnerUserId="8633" LastEditorUserId="26916" LastEditDate="2017-11-04T23:06:14.597" LastActivityDate="2019-01-30T16:05:13.563" Title="Why does my LED turn off automatically after about 18 seconds on its own?" Tags="|arduino-due|c|atmel-studio|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10333" PostTypeId="2" ParentId="10332" CreationDate="2015-04-26T02:28:05.410" Score="1" Body="&lt;p&gt;The symptoms you describe are consistent with your program crashing after 18 seconds.  I expect you will find something in this that is the problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(1){&#xA;     // Doing stuff in here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To debug this, add something to the startup that is unique or clearly identifiable:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a print &quot;reset&quot; to a serial port if you have one&lt;/li&gt;&#xA;&lt;li&gt;in your case, blink the led's in sequence 2,3,4,5,6&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once you confirm that your program is resetting, strip out everything in the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Doing stuff in here...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the program stripped down, it should keep the LED's lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the LED's still do not stay lit, but you see your reset indicator, consider power.  Microcontrollers will reset when the voltage droops too low.  The LED's might be consuming enough power to reduce the voltage below the trip point.  Connect a voltmeter to the supply voltage to see if it is stable.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The time delay can be associated with the power supply heating at higher current.  The LM2734 chip on the Due has a thermal shutdown, same as most voltage regulators.  If your hardware draws enough current to overheat, the chip will shutoff, cool down and turn back on.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-04-26T02:28:05.410" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10334" PostTypeId="2" ParentId="10315" CreationDate="2015-04-26T02:35:47.310" Score="3" Body="&lt;p&gt;Arduino has a library tutorial here: &lt;a href=&quot;http://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;noreferrer&quot;&gt;http://www.arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and a formal specification here: &lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;these explain the specifics to making arduino libraries, like the propeties files, the keywords file, and the directory structure. Most of that is unnecessary though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, there are not many differences between the actual code in an arduino library and the normal code you write for arduino sktech. The only major ones being that &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The arduino preprocessor doesn't generate function declarations - you have to make your own header file&lt;/li&gt;&#xA;&lt;li&gt;You can't use setup or loop&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other than that, its just normal c++ code that exposes a particular interface and provides an implementation. If you want the library to work well for a lot of users, you will need to put in the extra work to make it run on all the different arduino hardware variants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making libraries for c++ often involves creating .a, .so, .dll etc. files of compiled code that new programs can link against, but arduino compiles everything from source for every sketch so you don't need to worry about that here.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-04-26T06:58:44.120" LastActivityDate="2015-04-26T06:58:44.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10335" PostTypeId="1" CreationDate="2015-04-26T03:39:23.797" Score="1" ViewCount="753" Body="&lt;p&gt;Working on an Arduino + Raspberry Pi project and hoping that this question fits into this category. I'm recording audio using a MEMS microphone on the Arduino and transmitting it over to the Pi to store in a playable file (WAV).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I currently have setup is TCP transmission from the Arduino to the RaspPi. This part is fine and dandy for the purpose of seeing the data transmission that I am looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where my issue lies, is the audio data being recorded on the Arduino.&#xA;At the moment, I see data from my &lt;code&gt;analogRead()&lt;/code&gt; function displaying like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2035&#xA;2046&#xA;2030&#xA;2031&#xA;2044&#xA;2038&#xA;2034&#xA;2031&#xA;2034&#xA;2019&#xA;2028&#xA;2030&#xA;2024&#xA;2032&#xA;2028&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is, what does this mean? How would I translate this, preferably on the Pi, as usable data that I can store in a WAV file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any libraries or hints/clues that can steer me in the right direction would be great.&lt;/p&gt;&#xA;" OwnerUserId="8679" LastActivityDate="2019-04-13T07:02:10.433" Title="Microphone Data on Arduino to Wav File on RaspPi" Tags="|audio|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10339" PostTypeId="1" AcceptedAnswerId="10343" CreationDate="2015-04-26T08:40:30.400" Score="0" ViewCount="321" Body="&lt;p&gt;I would like ask for help. Can you give me an advice how to create (contacts) nubers who can turn on led.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;#define PINNUMBER &quot;&quot;&#xA;GSM gsmAccess;&#xA;GSMVoiceCall vcs; &#xA;char numtel[20];&#xA;&#xA;void setup()&#xA;{&#xA; pinMode(13, OUTPUT);&#xA;&#xA;Serial.begin(9600);&#xA;while (!Serial) {&#xA;;&#xA;}&#xA;&#xA;Serial.println(&quot;Receive Voice Call&quot;);&#xA;&#xA;boolean notConnected = true;&#xA;&#xA;while (notConnected)&#xA;{&#xA;if (gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;  notConnected = false;&#xA;else&#xA;{&#xA;  Serial.println(&quot;Not connected&quot;);&#xA;  delay(1000);&#xA;}&#xA;}&#xA;&#xA;vcs.hangCall();&#xA;&#xA;Serial.println(&quot;Waiting for a call&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;switch (vcs.getvoiceCallStatus())&#xA;{&#xA;case IDLE_CALL: &#xA;&#xA;  break;&#xA;&#xA;case RECEIVINGCALL: &#xA;&#xA;  Serial.println(&quot;RECEIVING CALL&quot;);&#xA;&#xA;  vcs.retrieveCallingNumber(numtel, 20);&#xA;&#xA;&#xA;  digitalWrite(13, HIGH);&#xA;&#xA;&#xA;  vcs.answerCall();&#xA;  vcs.hangCall();&#xA;  digitalWrite(13, LOW);&#xA;&#xA;  break;&#xA;&#xA;&#xA;  }&#xA;  delay(1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8686" LastEditorUserId="8686" LastEditDate="2015-04-26T08:52:44.857" LastActivityDate="2015-04-26T12:53:08.040" Title="Turn on led by phone and phone contacts" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10340" PostTypeId="1" AcceptedAnswerId="10342" CreationDate="2015-04-26T11:39:45.150" Score="3" ViewCount="13333" Body="&lt;p&gt;I built this circuit to learn button control. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2lLCK.png&quot; alt=&quot;My setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my code (or button) is working in reverse. I want to initialize led flash effect when the button is pressed with this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonState = digitalRead(8);&#xA;if (buttonState == HIGH)&#xA;  doFlash();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead the effect runs continuously and pauses if I push and hold the button. If change the condition as &lt;code&gt;if (buttonState == LOW)&lt;/code&gt; code is working as expected. (Effect starts when I push the button.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is just the opposite of what I read in tutorials. What is wrong in my circuit or code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup(){&#xA;  for(int i=2;i&amp;lt;=6;i++) &#xA;  pinMode(i,OUTPUT);&#xA;  pinMode(8,INPUT_PULLUP);&#xA; }&#xA;&#xA; void loop(){&#xA;  int buttonState;&#xA;&#xA;  buttonState = digitalRead(8);&#xA;  if (buttonState == LOW)&#xA;    doFlash();&#xA; }&#xA;&#xA;void doFlash() {&#xA;    int i;&#xA;    for (i=2;i&amp;lt;=6;i++) {&#xA;        digitalWrite(i,HIGH);&#xA;        delay(100);&#xA;        digitalWrite(i,LOW); &#xA;    }   &#xA;    for (i=6;i&amp;gt;=2;i--) {&#xA;        digitalWrite(i,HIGH);&#xA;        delay(100);&#xA;        digitalWrite(i,LOW); &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8687" LastActivityDate="2017-07-11T19:00:34.337" Title="My button control working in reverse" Tags="|arduino-uno|button|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10341" PostTypeId="2" ParentId="10340" CreationDate="2015-04-26T12:06:15.493" Score="4" Body="&lt;p&gt;This behavior is expected: INPUT_PULLUP means the pin is pulled up via the internal pull up, i.e. it will read as high if not connected externally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With your push button you connect it to ground (0 volts), thus bringing it to low level and it will read as low. Therefore, in your code, you need to check for low level (LOW) to check if the button is pressed (as you found out by changing the code).&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-04-26T12:06:15.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10342" PostTypeId="2" ParentId="10340" CreationDate="2015-04-26T12:50:21.580" Score="0" Body="&lt;p&gt;Most tutorials will make the code more &quot;intuitive&quot; by adding additional components to the circuit. E.g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gMroc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you can see one end of the button is connected to 5 volt, will the other end is connected to a digital input, and via a (pull-down) resistor to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the button isn't pressed the pull-down resistor will make the input read LOW. If the button is pressed the input will go to 5v (overpowering the pull-down resistor) and the input will read HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like you I found the pull-up version a bit weird. But once I figured out how both versions worked, I now prefer the pull-up one. For once, because you don't need an addition resistor. &lt;strike&gt;(And secondly because I don't like to use unrestricted 5v signals. If in the above example you accidentally set the input to an output, and press the button, you create a short, and could blow up the micro controller.)&lt;/strike&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-04-26T12:50:21.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10343" PostTypeId="2" ParentId="10339" CreationDate="2015-04-26T12:53:08.040" Score="1" Body="&lt;p&gt;So, &lt;code&gt;retrieveCallingNumber&lt;/code&gt; is documented in &lt;a href=&quot;http://www.arduino.cc/en/Reference/GSMVCSRetrieveCallingNumber&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. It &quot;retrieves the calling number, and stores it&quot; in a character array passed as second argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution to check if this number is among the allowed ones is to &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/StringConstructors&quot; rel=&quot;nofollow&quot;&gt;construct&lt;/a&gt; a &lt;a href=&quot;http://www.arduino.cc/en/Reference/String&quot; rel=&quot;nofollow&quot;&gt;string&lt;/a&gt; from this and &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/StringComparisonOperators&quot; rel=&quot;nofollow&quot;&gt;compare&lt;/a&gt; it against a predefined string for equality. (If you have more than one allowed number, repeat for all.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vcs.retrieveCallingNumber(numtel, 20);&#xA;String s = String(numtel);&#xA;if (s == &quot;allowed number goes here&quot;) {&#xA;    // toggle LED etc.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-04-26T12:53:08.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10344" PostTypeId="1" AcceptedAnswerId="10348" CreationDate="2015-04-26T14:26:47.917" Score="0" ViewCount="636" Body="&lt;p&gt;I am following a simple example &lt;a href=&quot;http://openenergymonitor.org/emon/javaexamples&quot; rel=&quot;nofollow noreferrer&quot;&gt;found here (example one)&lt;/a&gt;, to have an Arduino connected to a Raspberry Pi and read some data from the Arduino on the Pi in Java.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that the SerialEvent method is never called, which implies that no data is coming in. However, when I open the Serial Monitor I can see that data is being read correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct serial port is being used as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Java code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//This class:&#xA;// - Starts up the communication with the Arduino.&#xA;// - Reads the data coming in from the Arduino and&#xA;//   converts that data in to a useful form.&#xA;// - Closes communication with the Arduino.&#xA;&#xA;//Code builds upon this great example:&#xA;//http://www.csc.kth.se/utbildning/kth/kurser/DH2400/interak06/SerialWork.java&#xA;//The addition being the conversion from incoming characters to numbers. &#xA;&#xA;//Load Libraries&#xA;import java.io.*;&#xA;import java.util.TooManyListenersException;&#xA;&#xA;//Load RXTX Library&#xA;import gnu.io.*;&#xA;&#xA;class ArduinoComm implements SerialPortEventListener&#xA;{&#xA;&#xA;   //Used to in the process of converting the read in characters-&#xA;   //-first in to a string and then into a number.&#xA;   String rawStr=&quot;&quot;;&#xA;&#xA;   //Declare serial port variable&#xA;   SerialPort mySerialPort;&#xA;&#xA;   //Declare input steam&#xA;   InputStream in;&#xA;&#xA;   boolean stop=false;&#xA;&#xA;   public void start(String portName,int baudRate)&#xA;   {&#xA;&#xA;      stop=false; &#xA;      try &#xA;      {&#xA;         //Finds and opens the port&#xA;         CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName);&#xA;         mySerialPort = (SerialPort)portId.open(&quot;my_java_serial&quot; + portName, 2000);&#xA;         System.out.println(&quot;Serial port found and opened&quot;);&#xA;&#xA;         //configure the port&#xA;         try &#xA;         {&#xA;            mySerialPort.setSerialPortParams(baudRate,&#xA;            mySerialPort.DATABITS_8,&#xA;            mySerialPort.STOPBITS_1,&#xA;            mySerialPort.PARITY_NONE);&#xA;            System.out.println(&quot;Serial port params set: &quot;+baudRate);&#xA;         } &#xA;         catch (UnsupportedCommOperationException e)&#xA;         {&#xA;            System.out.println(&quot;Probably an unsupported Speed&quot;);&#xA;         }&#xA;&#xA;         //establish stream for reading from the port&#xA;         try &#xA;         {&#xA;            in = mySerialPort.getInputStream();&#xA;         } &#xA;         catch (IOException e) &#xA;         { &#xA;            System.out.println(&quot;couldn't get streams&quot;);&#xA;         }&#xA;&#xA;         // we could read from &quot;in&quot; in a separate thread, but the API gives us events&#xA;         try &#xA;         {&#xA;            mySerialPort.addEventListener(this);&#xA;            mySerialPort.notifyOnDataAvailable(true);&#xA;            System.out.println(&quot;Event listener added&quot;);&#xA;         } &#xA;         catch (TooManyListenersException e) &#xA;         {&#xA;            System.out.println(&quot;couldn't add listener&quot;);&#xA;         }&#xA;      }&#xA;      catch (Exception e) &#xA;      { &#xA;         System.out.println(&quot;Port in Use: &quot;+e);&#xA;      }&#xA;   }&#xA;&#xA;   //Used to close the serial port&#xA;   public void closeSerialPort() &#xA;   {&#xA;      try &#xA;      {&#xA;         in.close();&#xA;         stop=true; &#xA;         mySerialPort.close();&#xA;         System.out.println(&quot;Serial port closed&quot;);&#xA;&#xA;      }&#xA;      catch (Exception e) &#xA;      {&#xA;      System.out.println(e);&#xA;      }&#xA;   }&#xA;&#xA;   //Reads the incoming data packets from Arduino. &#xA;   public void serialEvent(SerialPortEvent event) &#xA;   { &#xA;&#xA;      //Reads in data while data is available&#xA;      while (event.getEventType()== SerialPortEvent.DATA_AVAILABLE &amp;amp;&amp;amp; stop==false) &#xA;      {&#xA;         try &#xA;         {&#xA;            //------------------------------------------------------------------- &#xA;&#xA;            //Read in the available character&#xA;            char ch = (char)in.read();&#xA;&#xA;            //If the read character is a letter this means that we have found an identifier.&#xA;            if (Character.isLetter(ch)==true &amp;amp;&amp;amp; rawStr!=&quot;&quot;)&#xA;            {&#xA;               //Convert the string containing all the characters since the last identifier into an integer&#xA;               int value = Integer.parseInt(rawStr);&#xA;&#xA;               if (ch=='A')&#xA;               {&#xA;                  System.out.println(&quot;Value A is: &quot;+value);&#xA;               }&#xA;&#xA;               if (ch=='B')&#xA;               {&#xA;                  System.out.println(&quot;Value B is: &quot;+value);&#xA;               }&#xA;&#xA;               //Reset rawStr ready for the next reading&#xA;               rawStr = (&quot;&quot;);&#xA;            } &#xA;            else &#xA;            {&#xA;               //Add incoming characters to a string.&#xA;               //Only add characters to the string if they are digits. &#xA;               //When the arduino starts up the first characters it sends through are S-t-a-r-t- &#xA;               //and so to avoid adding these characters we only add characters if they are digits.&#xA;&#xA;               if (Character.isDigit(ch))&#xA;               {&#xA;                  rawStr = ( rawStr + Character.toString(ch));&#xA;               } &#xA;               else &#xA;               {&#xA;                  System.out.print(ch);&#xA;               } &#xA;            }&#xA;         } &#xA;         catch (IOException e) &#xA;         {&#xA;         }&#xA;      }&#xA;   }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the Arduino Sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Arduino code for Part 01&#xA;&#xA;//First we will define the values to be sent&#xA;//Note: The java code to go with this example reads-&#xA;//-in integers so values will have to be sent as integers&#xA;int valueA = 21;&#xA;int valueB = 534;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(115200);&#xA;   Serial.println(&quot;Start&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;&#xA;   //We send the value coupled with an identifier character&#xA;   //that both marks the end of the value and what the value is.&#xA;&#xA;   Serial.print(valueA);&#xA;   Serial.print(&quot;A&quot;);&#xA;&#xA;   Serial.print(valueB);&#xA;   Serial.print(&quot;B&quot;);&#xA;&#xA;   //A delay to slow the program down to human pace.&#xA;   delay(500);  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have read that changing &lt;code&gt;Serial.print()&lt;/code&gt; to &lt;code&gt;Serial.write()&lt;/code&gt; is the new way to do this, but changing this had no result. &lt;/p&gt;&#xA;" OwnerUserId="8690" LastEditorUserId="26916" LastEditDate="2017-09-09T14:58:29.330" LastActivityDate="2017-09-09T14:58:29.330" Title="Arduino Java SerialEvent not being called (Rasberry PI) XPOST from stack overflow" Tags="|serial|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10345" PostTypeId="2" ParentId="10340" CreationDate="2015-04-26T14:47:01.733" Score="2" Body="&lt;p&gt;There are two kinds of logic: &quot;active high&quot; and &quot;active low&quot;. (At least that's one way to characterize it.) Your circuit is &quot;active low&quot;, and there's nothing wrong with it. If fact, when you use the internal pull-up resistors of the microcontroller you're bound to use active low logic. (More modern microcontrollers have configurable pull-up or pull-down resistors.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this confuses you you can use a #define in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ACTIVE LOW&#xA;&#xA;if (buttonState == ACTIVE)&#xA;  doFlash();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-26T14:47:01.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10346" PostTypeId="2" ParentId="10330" CreationDate="2015-04-26T15:41:24.673" Score="0" Body="&lt;p&gt;I would use an ultrasonic sensor pointed at them it will give you a list of distanced at the rate that the sensor collects information (e.g. 5Hz) this could be used to plot a graph of distance over time then a graph of speed over time, then acceleration over time ect.&lt;/p&gt;&#xA;" OwnerUserId="8566" LastActivityDate="2015-04-26T15:41:24.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10347" PostTypeId="2" ParentId="10330" CreationDate="2015-04-26T16:56:24.807" Score="0" Body="&lt;p&gt;An option would be to use a GPS module which would give you actual speed accurately, this data can be logged to EEPROM or SD and downloaded later or it can be sent wirelessly to a base station. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;http://www.adafruit.com/product/1059&quot; rel=&quot;nofollow&quot;&gt;wearable GPS module&lt;/a&gt; from adafruit, there are a few tutorials on getting started with it. You can the make a jacket or something light that can go onto the sprinters with the system attached. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could use an &lt;a href=&quot;http://en.wikipedia.org/wiki/Inertial_measurement_unit&quot; rel=&quot;nofollow&quot;&gt;IMU&lt;/a&gt;(Inertial measurement unit), this uses an Accelerometer, Gyro and Magnetometer. There is an article on using IMUs for measuring velocity of an object with basic modules and not using the expensive systems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.chrobotics.com/library/accel-position-velocity&quot; rel=&quot;nofollow&quot;&gt;This article&lt;/a&gt; by CH Robotics covers a starting point, also &lt;a href=&quot;https://www.google.com/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=measuring%20velocity%20with%20accelerometer&quot; rel=&quot;nofollow&quot;&gt;googling&lt;/a&gt; this should give a whole load more of links. As the article says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It depends entirely on how much accuracy is needed. In general, accelerometer-based position and velocity estimates from low-cost sensors ... are very poor and are simply unusable. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2015-04-27T07:43:14.247" LastActivityDate="2015-04-27T07:43:14.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10348" PostTypeId="2" ParentId="10344" CreationDate="2015-04-26T17:29:21.813" Score="1" Body="&lt;p&gt;So the reason for no events being triggered was due to the program exiting and ending before it had the chance to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this i added a thread with a loop inside it inside the main thread.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public static void main(String[] args) throws Exception {&#xA; ArduinoComm = new ArduinoComm ();&#xA; main.start(&quot;/dev/ttyUSB0&quot;,115200);&#xA; Thread t=new Thread() {&#xA; public void run() {&#xA; try {&#xA; //Messy implementation but it works for this demo purpose&#xA;    while(true){&#xA;      //optional sleep  &#xA;      thread.Sleep(500);&#xA;    }&#xA; } catch (InterruptedException ie) {}&#xA; }&#xA; };&#xA; t.start();&#xA; System.out.println(&quot;Started&quot;);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bit of an oversight on my part. &lt;/p&gt;&#xA;" OwnerUserId="8690" LastActivityDate="2015-04-26T17:29:21.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10349" PostTypeId="2" ParentId="10330" CreationDate="2015-04-26T18:30:33.380" Score="-1" Body="&lt;p&gt;Your best bet would be to use a module of Gyro, Accelerometer and Magnetometer much like MPU-9150. These devices communicate using I2C and you can log in data about the direction and the change in direction as well as acceleration. Using this data you can easily find out the speed in a particular direction and even overall data like the average speed, distance travelled, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea is using the accelerometer to measure a jerk.A jerk can be taken as a footstep and using appropriate calculations you can find out how much a person has moved throughout the sprint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use ultrasonic sensors too which would tell you the position of the sprinter from a point but they have their disadvantages like small pressure changes due to air will affect the readings and you won't get accurate reading.&lt;/p&gt;&#xA;" OwnerUserId="8426" LastActivityDate="2015-04-26T18:30:33.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10350" PostTypeId="2" ParentId="10330" CreationDate="2015-04-26T19:01:51.480" Score="0" Body="&lt;p&gt;You will likely need to buy a relativly high quality GPS for each runner. Alternatly, if you could get a camera mounted so it could see large portions on track from a good angle it could probably perform pretty well with the right optical recoginition code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMU's are not going to be capable of tracking a runners velocity. Even constrained to linear motion the position and velocity measurements from integrating a consumer accelerometer become garbage in a few seconds because of accumulated error. Once you add the fact that the sensor will not be level all the time and your angle estimation is at best within 1 degree, I'd estimate the velocity and position of a runner recorded by a normal 9-dof IMU would be irrelevent after at most 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at the table on this page for a detailed analysis of orientation based errors:&lt;a href=&quot;http://www.chrobotics.com/library/accel-position-velocity&quot; rel=&quot;nofollow&quot;&gt;http://www.chrobotics.com/library/accel-position-velocity&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-04-26T19:01:51.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10351" PostTypeId="2" ParentId="10332" CreationDate="2015-04-27T00:49:01.753" Score="2" Body="&lt;p&gt;Again, figured this out. I simply forgot to put in &lt;code&gt;board_init();&lt;/code&gt; Also, since &lt;code&gt;board_init()&lt;/code&gt; already calls &lt;code&gt;ioport_init()&lt;/code&gt;, I had to disable that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main (void)&#xA;{&#xA;    /* Initialize the SAM system. */&#xA;    sysclk_init(); // Initialize the System Clock&#xA;    board_init();  // Initialize the board&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;....&lt;/p&gt;&#xA;" OwnerUserId="8633" LastEditorUserId="19409" LastEditDate="2018-06-26T05:01:21.357" LastActivityDate="2018-06-26T05:01:21.357" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10352" PostTypeId="1" CreationDate="2015-04-26T10:42:52.097" Score="1" ViewCount="1490" Body="&lt;p&gt;I have two questions want to ask &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm using Arduino Uno with 16*2 LCD Blue ( also I have temp. sensor and two motors also 3 limit switches) ,, my code is working good, but sometimes my lcd stop printing the values of Temperature and time [print nothing i.e. print all the leds on] \\ then when I reboot it everything works good .... why this problem happened ? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any way to save the value of millis function when the arduino was rebooted ?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;thanks for your help&#xA;regards &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My code is for an egg incubator , it consists of &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Dht22 sensor [humidity + Temp]&lt;/li&gt;&#xA;&lt;li&gt;three limit sw.&lt;/li&gt;&#xA;&lt;li&gt;one motor&lt;/li&gt;&#xA;&lt;li&gt;16*2 lcd&lt;/li&gt;&#xA;&lt;li&gt;lamp [acting as  heaters]&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As I said previously,  millis function  that I'm using is for controlling the motor movement every 3 hours and stop the movement after 18 days of working &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem I faced is POINT 1 that I mentioned previously (I don't need to lose the time when I reboot the LCD)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If any one can help by giving me a short code as an example who to deal with EEPROM or any other idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DHT.h&quot;  //includes lib for the temperature-humdity sensor&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt; //lcd lib&#xA;&#xA;#define DHTPIN 13 //pin that DHT is connected to &#xA;#define DHTTYPE DHT22 //Sensor we are using&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE); //defines location for DHT&#xA;&#xA;int sw1,sw2,sw3;&#xA;const int LM1=0;&#xA;const int LM2=1;&#xA;const int LM3=6;&#xA;const int LAMP=8;&#xA;const int CW=10;&#xA;const int CCW= 9;&#xA;const int Buzzer=7;&#xA;long previousMillis = 0;        // will store last time LED was updated&#xA;unsigned long RealTime = 0;  &#xA;float MOTORTime =0;// This is the real time that present on LCD now.&#xA;unsigned long MOTORSTOP = 0;// store the valve after 18 days of ranning ,, &#xA;&#xA;// the follow variables is a long because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long interval = 10800000;           // interval at which to blink (milliseconds)(3 hours waiting)&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;&#xA;  lcd.begin(16, 2);   // set up the LCD's number of rows and columns: [LCD that we have (Colomn,Row)]&#xA;  pinMode(LAMP,OUTPUT);&#xA;  pinMode(LM1,INPUT);&#xA;  pinMode(LM2,INPUT);&#xA;  pinMode(LM3,INPUT);&#xA;  pinMode(CW,OUTPUT);&#xA;  pinMode(CCW,OUTPUT);&#xA;&#xA; }&#xA;void loop() {&#xA;  sw3=digitalRead(LM3);&#xA;      unsigned long currentMillis = millis();&#xA;MOTORSTOP = currentMillis;&#xA;if (MOTORSTOP &amp;lt; 1555200000){ // 18 days&#xA;  float h = dht.readHumidity(); //defines the variable for humidity&#xA;  float t = dht.readTemperature(); //defines the variable for temperature&#xA;  // set the cursor to column 0, line 0&#xA;  lcd.setCursor(0,0);&#xA;  // print the humidity &#xA;  lcd.print(&quot;H &quot;);&#xA;  lcd.print(h);&#xA;  lcd.print(&quot;% &quot;);&#xA;  //move line down&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;T &quot;);&#xA;  lcd.print(t);&#xA;  lcd.print(&quot;C &quot;);&#xA;&#xA;  lcd.setCursor(10,0);&#xA;  lcd.print(&quot;MOTOR&quot;); // to print motor working time&#xA;&#xA;&#xA;if (t==37.65)digitalWrite(LAMP,LOW);// Lamp OFF&#xA;else if (t&amp;gt;37.65)digitalWrite (LAMP,LOW); // Lamp OFF&#xA;else { digitalWrite(LAMP,HIGH);}// Lamp ON&#xA;&#xA;&#xA;  delay(2000); //wait two sec. before taking another reading.&#xA;  ///////////////stepper motor control and delay time 2.45 hours. &#xA; sw1= digitalRead(LM1);&#xA;  sw2= digitalRead(LM2);&#xA;&#xA;&#xA;  RealTime = currentMillis - previousMillis;&#xA;  MOTORTime=((RealTime/(1000))/60); //////////////////////////////////////////// &#xA;  MOTORTime = 180 - MOTORTime;&#xA;&#xA;  if (MOTORTime &amp;gt;= 1){&#xA;   lcd.setCursor(10,1);&#xA;  lcd.print(MOTORTime); }// this will print the ACTUAL Time Remaining on LCD&#xA;  else {&#xA;    lcd.setCursor(10,1);&#xA;   lcd.print(&quot;&amp;lt;1 MIN&quot;);}&#xA;&#xA;&#xA;  if(RealTime &amp;gt; interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;  if (sw1==LOW &amp;amp;&amp;amp; sw2==HIGH){&#xA;    digitalWrite (CW,LOW);&#xA;    digitalWrite (CCW,LOW);&#xA;    do {&#xA;      digitalWrite(Buzzer,HIGH);&#xA;      digitalWrite (CW,HIGH);// change the direction of rotation (DOWN Movement)&#xA;      digitalWrite (CCW,LOW);&#xA;&#xA;      sw2= digitalRead(LM2);}&#xA;      while(sw2==HIGH);}&#xA;&#xA;      else if (sw1==HIGH &amp;amp;&amp;amp; sw2==LOW){&#xA;&#xA;      digitalWrite(CW,LOW);&#xA;      digitalWrite(CCW,LOW);&#xA;&#xA;        do {&#xA;          digitalWrite(Buzzer,HIGH);&#xA;          digitalWrite(CW,LOW);// change the direction of rotation (UP Movement)&#xA;          digitalWrite(CCW,HIGH);&#xA;&#xA;          sw1= digitalRead(LM1);}&#xA;          while(sw1 == HIGH);}}&#xA;}&#xA;//----------------------------------------------------------------------------------------------------------------------&#xA;else if (((MOTORSTOP/10800000)&amp;gt;= 144 )&amp;amp;&amp;amp; (LM3== LOW)&amp;amp;&amp;amp;(MOTORSTOP &amp;gt;= 1555200000)){&#xA;  digitalWrite (CW,LOW);&#xA;    digitalWrite (CCW,LOW);&#xA;&#xA;   float h = dht.readHumidity(); //defines the variable for humidity&#xA;  float t = dht.readTemperature(); //defines the variable for temperature&#xA;  // set the cursor to column 0, line 0&#xA;  lcd.setCursor(0,0);&#xA;  // print the humidity &#xA;  lcd.print(&quot;H &quot;);&#xA;  lcd.print(h);&#xA;  lcd.print(&quot;% &quot;);&#xA;  //move line down&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(&quot;T &quot;);&#xA;  lcd.print(t);&#xA;  lcd.print(&quot;C &quot;);&#xA;&#xA;  lcd.setCursor(10,0);&#xA;  lcd.print(&quot;MOTOR&quot;); // to print motor working time&#xA;  lcd.setCursor(10,1);&#xA;  lcd.print(&quot;OFF&quot;);&#xA;&#xA;if (t==36.70)digitalWrite(LAMP,LOW);// Lamp OFF&#xA;else if (t&amp;gt;36.70)digitalWrite (LAMP,LOW); // Lamp OFF&#xA;else { digitalWrite(LAMP,HIGH);}// Lamp ON&#xA;&#xA;&#xA;  delay(2000); //wait two sec. before taking another reading.&#xA;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Zouhd" LastEditorUserId="6452" LastEditDate="2015-04-27T09:49:24.823" LastActivityDate="2016-01-23T15:57:33.730" Title="need help for saving the millis function when arduino was rebooted" Tags="|lcd|time|millis|rtc|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10353" PostTypeId="2" ParentId="10352" CreationDate="2015-04-26T11:34:06.643" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;You could be running out of memory. Posting your code would be helpful.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;2. Not without some external memory such as an SD card.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;As David points out in the comments the Arduino does have EEPROM memory (512bytes or 1024bytes depending on which version you have). See here for the library: &lt;a href=&quot;http://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/EEPROM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6331" OwnerDisplayName="cheechm" LastActivityDate="2015-04-26T11:53:20.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10354" PostTypeId="2" ParentId="10352" CreationDate="2015-04-26T17:20:32.937" Score="3" Body="&lt;p&gt;You might try a real-time clock module instead of the &lt;code&gt;millis()&lt;/code&gt; function. They keep time in external hardware and are battery backed so continue through a power down, you get calendar date and clock time instead of milliseconds since restart, and they don't overflow every 50 days.&lt;/p&gt;&#xA;" OwnerUserId="313" OwnerDisplayName="JRobert" LastActivityDate="2015-04-26T17:20:32.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10355" PostTypeId="1" AcceptedAnswerId="10416" CreationDate="2015-04-27T01:56:40.113" Score="1" ViewCount="587" Body="&lt;p&gt;I am using an Arduino UNO that is connected to an Arduino GSM shield (&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoGSMShield&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I want to connect the SparkFun Venus GPS module to this combination. (*unfortunately due to my rep I can only post two links)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Venus GPS works fine with the Arduino UNO by itself, but I am having some trouble getting the GPS module to communicate with the Arduino when the GSM shield is stacked on top.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GPS powers on and begins blinking (which means it has a lock), but the serial monitor is not showing any information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coming from the programming side of things, I really don't understand much about electronics, so please pardon me if I am missing something basic here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on what I've managed to figure out so far, I think it has something to do with the shield requiring 5V operating voltage and the Venus operating at 3.3V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that when the GSM shield is plugged in, its expecting a 5V input, but the Venus GPS is only capable of sending a 3.3V signal.  Furthermore, any other 5V sensors that I am currently using don't have any problems communicating with the UNO through the GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I actually have two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this assumption correct or could something else be the cause of my issue?&lt;/li&gt;&#xA;&lt;li&gt;If this is correct, could I use something like this logic level converter (&lt;a href=&quot;https://solarbotics.com/product/50550/&quot; rel=&quot;nofollow&quot;&gt;https://solarbotics.com/product/50550/&lt;/a&gt;) to step up the Venus GPS input signal?  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any help and guidance you are able to provide.&lt;/p&gt;&#xA;" OwnerUserId="8700" LastActivityDate="2015-06-10T16:52:19.357" Title="Arduino UNO + Arduino GSM Shield + Sparkfun Venus GPS" Tags="|gsm|gps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10356" PostTypeId="2" ParentId="10315" CreationDate="2015-04-27T02:13:10.477" Score="1" Body="&lt;p&gt;To address your query about libraries making sketch code too big...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have recently completed (or rather, am in the process of completing) my first library, &lt;a href=&quot;https://github.com/greenonline/SevenSegmentSL1255&quot; rel=&quot;nofollow&quot;&gt;SevenSegmentSL1255&lt;/a&gt;. I too was concerned about the growing size of the library, as I incorporated more and more ideas. So I decided to plan for a &quot;Lite&quot; version, &lt;a href=&quot;https://github.com/greenonline/SevenSegmentSL1255Lite&quot; rel=&quot;nofollow&quot;&gt;SevenSegSL1255Lite&lt;/a&gt;, so that the casual user would not feel to overwhelmed and also to reduce the memory footprint, for simple sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, after reading the &lt;a href=&quot;http://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;Arduino page on the build process&lt;/a&gt;, I discovered that the whole library is not necessarily included in all sketches:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The .c and .cpp files of the target are compiled and output with .o&#xA;  extensions to this directory, as is the main sketch file and any other&#xA;  .c or .cpp files in the sketch and any .c or .cpp files in any&#xA;  libraries which are #included in the sketch.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These .o files are then linked together into a static library and the&#xA;  main sketch file is linked against this library. &lt;em&gt;Only the parts of&#xA;  the library needed for your sketch are included in the final .hex&#xA;  file, reducing the size of most sketches.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you see, from a memory footprint point of view, no matter how big the library may be, the resultant compiled sketch can still be quite small, depending on the amount of the library that is called for the sketch. From my point of view, this makes the &quot;Lite&quot; version of my library now somewhat redundant. Although, the argument for a simpler, more user friendly library may still exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, the resources that I used in creating the library are listed below:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;Writing a Library for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/APIStyleGuide&quot; rel=&quot;nofollow&quot;&gt;Arduino Style Guide for Writing Libraries&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=36935.0&quot; rel=&quot;nofollow&quot;&gt;error in using overloaded constructor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Memory&quot; rel=&quot;nofollow&quot;&gt;Memory&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/StyleGuide&quot; rel=&quot;nofollow&quot;&gt;Style Guide&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-04-28T00:51:52.683" LastActivityDate="2015-04-28T00:51:52.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10357" PostTypeId="1" AcceptedAnswerId="20115" CreationDate="2015-04-27T04:11:50.250" Score="3" ViewCount="5384" Body="&lt;p&gt;Hey all I have been trying to figure out a way to random set patterns for my fade in/ out code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int PIN = 3;&#xA;int totalLEDs = 11;&#xA;int ledFadeTime = 5;&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(totalLEDs, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  rgbFadeInAndOut(0, 0, 255, ledFadeTime); // Blue&#xA;}&#xA;&#xA;void rgbFadeInAndOut(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  for(uint8_t b = 0; b &amp;lt;255; b++) {&#xA;     for(uint8_t i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;&#xA;     strip.show();&#xA;     delay(wait);&#xA;  };&#xA;&#xA;  for(uint8_t b=255; b &amp;gt; 0; b--) {&#xA;     for(uint8_t i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;     strip.show();&#xA;     delay(wait);&#xA;  };&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above works great. Fades the blue in and out infinity times. However, I am wanting random LEDs to be off or have a lighter/darker shade of the color I choose (in the above it's blue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[off][blue][blue][off][off][dark blue][blue][off][dark blue][dark blue][off]&#xA;[blue][blue][blue][dark blue][off][blue][dark blue][blue][dark blue][off][off]&#xA;etc etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would anyone happen to have code already like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great! Thanks!&lt;/p&gt;&#xA;" OwnerUserId="5133" LastEditorUserId="10794" LastEditDate="2016-01-30T03:32:13.503" LastActivityDate="2016-03-30T08:20:43.847" Title="Arduino with WS2812 using Adafruit NeoPixel library fade in/out different patterns" Tags="|arduino-uno|c++|led|arduino-ide|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10358" PostTypeId="1" CreationDate="2015-04-27T04:14:38.570" Score="0" ViewCount="630" Body="&lt;p&gt;A little background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to generate a 40KHz frequency as accurately as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(One of my other posts is here: &#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/8671/stable-frequency-generation&quot;&gt;Stable frequency generation&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is solid- I'm using an Uno R3 and generating the most accurate frequency I can at this point. The only way to get a more accurate frequency is to upgrade the ceramic resonator to a crystal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my over-arching question is: How do I actually upgrade the ceramic resonator to a crystal oscillator? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I'm considering are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it worth it to actually upgrade my Uno R3 - and is it even possible? Is there a clone that drives the ATMega328p with a crystal oscillator that I could use instead? Is there simply just a better model for this application?&lt;/p&gt;&#xA;" OwnerUserId="7317" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-06-26T18:22:13.997" Title="How to upgrade Arduino UnoR3 clock" Tags="|arduino-uno|timing|oscillator-clock|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10359" PostTypeId="2" ParentId="10358" CreationDate="2015-04-27T05:24:46.023" Score="0" Body="&lt;p&gt;Looking at the Arduino R3 reference design, it should have a crystal! But in practice it seems that the manufacturers are cutting corners and using a resonator because it is cheaper. I don't like your chances of fitting an xtal instead of a resonator. Unless you are a soldering expert and have suitable facilities, the most likely outcome is a dead board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your board has the MCU chip in a socket, you could bend the xtal pins so they don't go into the socket and solder a xtal and a couple capacitors to them. Not exactly a production line solution, but it will be fine if you just want a one-off - and anyone reasonably at home with a soldering iron could do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Freetronics (an Australian company) make a R3 compatable with xtals for both processors. These are very well made (I own two), and have a prototyping area as well. Downside is the higher cost. See &lt;a href=&quot;http://www.freetronics.com.au/products/eleven#.VT3F-PCo1BA&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/products/eleven#.VT3F-PCo1BA&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-04-27T05:24:46.023" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10360" PostTypeId="2" ParentId="10115" CreationDate="2015-04-27T05:32:06.177" Score="0" Body="&lt;p&gt;i solved it out by using comparing the received bits in that frame..&#xA;here is my code..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                   if(add == 33)&#xA;                    {                 &#xA;                    a1 = func1();&#xA;                    b = a1.length();  &#xA;                    if(b != 0)&#xA;                   {&#xA;                    Zigbee=1;&#xA;                    if(a1!=c1)&#xA;                    {&#xA;                    Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                    Serial.print(&quot;,&quot;); Serial.println(a1);&#xA;                    }&#xA;                    c1=a1;&#xA;                    row++;              &#xA;                    }&#xA;                    }&#xA;                  else if(add == 48)&#xA;                    { &#xA;                    a2 = func1();&#xA;                    b = a2.length();&#xA;                    if(b != 0) &#xA;                  { &#xA;                    Zigbee=2;&#xA;                    if(a2!=c2){&#xA;                   Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                   Serial.print(&quot;,&quot;); Serial.println(a2);&#xA;                    }&#xA;                    c2=a2;&#xA;                   row++;                                          &#xA;                    }&#xA;                    }&#xA;&#xA;                   else if(add == 69)&#xA;                    {&#xA;                      a3 = func1();&#xA;                      b = a3.length();&#xA;                      if(b != 0)&#xA;                     {&#xA;                      Zigbee=3;&#xA;                      if(a3!=c3)&#xA;                     {&#xA;                      Serial.print(&quot;DATA,TIME,&quot;); Serial.print(Zigbee);                     &#xA;                      Serial.print(&quot;,&quot;); Serial.println(a3);&#xA;                     }&#xA;                     c3=a3;&#xA;                     row++;                  &#xA;                }&#xA;                    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8511" LastActivityDate="2015-04-27T05:32:06.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10361" PostTypeId="1" CreationDate="2015-04-27T05:50:35.253" Score="1" ViewCount="224" Body="&lt;p&gt;I have 5 shift register changed in series and want to shift the data quickly. I have learned that the internal shiftOut function is slow and direct port manipulation can speed up the things. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am not sure to write code in the specific way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current working code block is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SensDataPin 4 &#xA;#define SensClockPin 9 &#xA;#define SensLatchPin 8 &#xA;updateAllShifters()&#xA;{&#xA;digitalWrite(SensLatchPin, LOW);&#xA;shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_1);&#xA;shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_2);&#xA;shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_3);&#xA;shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_4);&#xA;shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_5);&#xA;digitalWrite(SensLatchPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the code shows, I have 5 bytes which are written by independent functions and just before the return statement, these functions call &quot;updateAllShifters()&quot; to mark the changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have followed few tutorials over the internet and have re-written the logic like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MSDATAHIGH PORTD |= (1&amp;lt;&amp;lt;PD4)&#xA;#define MSDATALOW PORTD &amp;amp;= ~(1&amp;lt;&amp;lt;PD4)&#xA;#define MSLATCHHIGH PORTB |= (1&amp;lt;&amp;lt;PB0)&#xA;#define MSLATCHLOW PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB0)&#xA;#define MSCLOCKHIGH PORTB |= (1&amp;lt;&amp;lt;PB1)&#xA;#define MSCLOCKLOW PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB1)&#xA;updateAllShifters()&#xA;{&#xA;MSLATCHLOW;&#xA;for(int i=0;i&amp;lt;40;i++)&#xA;{&#xA;HOW TO CODE HERE USING THE DEFINED MACROS!&#xA;}&#xA;MSLATCHHIGH;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Coding example of this (but want a more optimized way):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MSDATAHIGH PORTD |= (1&amp;lt;&amp;lt;PD4)&#xA;#define MSDATALOW PORTD &amp;amp;= ~(1&amp;lt;&amp;lt;PD4)&#xA;#define MSLATCHHIGH PORTB |= (1&amp;lt;&amp;lt;PB0)&#xA;#define MSLATCHLOW PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB0)&#xA;#define MSCLOCKHIGH PORTB |= (1&amp;lt;&amp;lt;PB1)&#xA;#define MSCLOCKLOW PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB1)&#xA;updateAllShifters()&#xA;{&#xA;MSLATCHLOW;&#xA;for(byte i=0;i&amp;lt;8;i++)&#xA;{&#xA; if(!!(byte_1 &amp;amp; (1 &amp;lt;&amp;lt; i)));// LSBFIRST&#xA;   {&#xA;   MSDATAHIGH;&#xA;   }else&#xA;   {&#xA;   MSDATALOW;&#xA;   }&#xA;}&#xA; MSCLOCKHIGH;&#xA; MSCLOCKLOW;&#xA;//DO ABOVE FOR ALL REMAINING 4 BYTES&#xA;MSLATCHHIGH;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8035" LastEditorUserId="8035" LastEditDate="2015-04-28T06:26:04.127" LastActivityDate="2015-11-22T07:39:20.177" Title="Direct port manipulation to write 40 bits" Tags="|digital|shift-register|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10362" PostTypeId="1" AcceptedAnswerId="10364" CreationDate="2015-04-27T06:11:54.427" Score="11" ViewCount="9027" Body="&lt;p&gt;I read definitions like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin = 9;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ledPin 9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that a definition like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 9;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a bad practice if you're not going to change it (which you usually won't), though I've see this several times in Arduino programs.&#xA;Which one of the other two is preferred?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-04-27T07:47:38.163" LastActivityDate="2015-04-27T17:28:15.360" Title="What is the best way to define an I/O pin?" Tags="|programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10364" PostTypeId="2" ParentId="10362" CreationDate="2015-04-27T07:06:32.003" Score="7" Body="&lt;p&gt;&lt;code&gt;#define ledPin 9&lt;/code&gt; is preferred. By doing &lt;code&gt;int ledPin = 9;&lt;/code&gt; you will be allocating an &lt;code&gt;int&lt;/code&gt; memory whose value is used every time you use &lt;code&gt;ledPin&lt;/code&gt;. &lt;code&gt;#define&lt;/code&gt; is different in the sense it doesn't allocate memory. there is no memory called &lt;code&gt;ledPin&lt;/code&gt;. Before compiling all &quot;ledPin&quot;s in the code(other than strings) are replaced by &lt;code&gt;9&lt;/code&gt;. So basically &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(ledPin);&lt;/code&gt;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(9);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Advantages of &lt;code&gt;#define&lt;/code&gt; : Saves memory and since all &lt;code&gt;ledPin&lt;/code&gt; are replaced by &lt;code&gt;9&lt;/code&gt; &lt;strong&gt;before execution&lt;/strong&gt;, it saves processor time. &lt;p&gt;&#xA;Doesn't really matter in small codes...&lt;/p&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user8688" LastActivityDate="2015-04-27T07:06:32.003" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10365" PostTypeId="2" ParentId="10362" CreationDate="2015-04-27T09:19:19.463" Score="6" Body="&lt;p&gt;Strictly speaking, the &lt;code&gt;#define&lt;/code&gt; approach will use slightly less memory. The difference is usually tiny though. If you need to reduce memory usage, then other optimisations would probably be far more effective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An argument in favour of using &lt;code&gt;const int&lt;/code&gt; is &lt;strong&gt;type safety&lt;/strong&gt;. Wherever you refer to that pin number by variable, you know exactly what data type you're getting. It might be promoted/converted implicitly or explicitly by the code which uses it, but it should behave in very clear ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By contrast, the value in a &lt;code&gt;#define&lt;/code&gt; is open to interpretation. The vast majority of the time, it probably won't cause you any problems at all. You just need to be a little careful if you have code which makes assumptions about the type or size of the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I almost always prefer type safety unless I have a very serious need to save memory.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-27T09:19:19.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10366" PostTypeId="1" CreationDate="2015-04-27T09:40:32.123" Score="1" ViewCount="37130" Body="&lt;p&gt;We are so tired and would like to get help with this. We are trying to bootload using the arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have an &lt;code&gt;atmega 328p&lt;/code&gt; smd , that we are trying to bootload. We have connected all the right pins, added to the boards.txt the  &lt;code&gt;&quot;Atmega328 on a breadboard(8mhz internal clock)&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have chosen from the &quot;board&quot; menu, this option (internal clock), and uploaded the program. &lt;strong&gt;it worked&lt;/strong&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later, I wanted to try and bootload for external clock so I chose from the boards menu the &lt;code&gt;pro mini with 5v board.&lt;/code&gt;(is it wrong?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only that I got an error, now, &lt;strong&gt;I can't bootload the internal clock again&lt;/strong&gt; !!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't we bootload again? Did we damage something? Can it be reset again?&#xA;How can you bootload for external 16Mhz ??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;error :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4989" LastEditorUserId="2944" LastEditDate="2015-04-27T21:25:18.707" LastActivityDate="2021-11-29T17:14:40.973" Title="Cannot bootload again after changing the board?" Tags="|arduino-uno|atmega328|bootloader|avrdude|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10367" PostTypeId="2" ParentId="3007" CreationDate="2015-04-27T09:56:38.667" Score="1" Body="&lt;p&gt;The following link was suggested in the comments by user &lt;a href=&quot;https://arduino.stackexchange.com/users/490/phillynj&quot;&gt;PhillyNJ&lt;/a&gt;. Adding it here as a community wiki answer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Tutorials/GPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Tutorials/GPS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-04-27T09:56:38.667" CommentCount="0" CommunityOwnedDate="2015-04-27T09:56:38.667" ContentLicense="CC BY-SA 3.0" />
  <row Id="10368" PostTypeId="1" AcceptedAnswerId="10379" CreationDate="2015-04-27T12:37:05.633" Score="3" ViewCount="11458" Body="&lt;p&gt;According to the ATmega328P datasheet, the total current from &lt;strong&gt;all I/O pins&lt;/strong&gt; must not exceed 200mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that an Output pin sources 30mA and an Input pin sinks 10mA. The total current should be 30+10=40mA or 30-10=20mA?  &lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2015-04-27T16:48:06.730" Title="ATMega I/O maximum current" Tags="|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10369" PostTypeId="1" AcceptedAnswerId="10370" CreationDate="2015-04-27T12:53:25.783" Score="0" ViewCount="155" Body="&lt;p&gt;I have been a bit confused about calculating the input current, so I'd be much obliged if someone could help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that we have a potentiometer connected with an analog input as shown below. In a middle position the resistance of the potentiometer is spitted to R1 and R2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I calculate the current in A0?&#xA;How much will be the current value if (R1=0, R2=Rmax), (R1=Rmax, R2=0), (R1 and R2 !=0,Rmax)?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 5V --------&#xA;           |&#xA;           R1&#xA;           |&#xA; A0 --------&#xA;           |&#xA;           R2&#xA;           |&#xA;          GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2015-04-27T16:42:26.153" Title="calculating the input current" Tags="|current|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10370" PostTypeId="2" ParentId="10369" CreationDate="2015-04-27T13:00:44.117" Score="1" Body="&lt;p&gt;When reading an analog voltage an analog pin has a very high resistance - usually very very much higher than the resistance of any potentiometer used, and input current to A0 can be regarded as zero for practical purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For practical purposes the current drain from the supply will be that which flows from 5V to ground via R1 &amp;amp; R2.&lt;br&gt;&#xA;I = V/R = 5V/(R1  + R2)   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for a potentiometer the sum of R1 + R2 is constant, the position of the pot-wiper makes no difference to current draw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg 10k pot. I_supply  = V/r = 5V/10K = 0.5 mA.&lt;br&gt;&#xA;An I_A0 ~= 0&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The upper value of a potentiometer which should be used for an analog input is covered by the uC (microcontroller) data sheet. The key parameter is uC input bias currents flowing in the potentiometer and causing &lt;strong&gt;small&lt;/strong&gt; voltages which affect the analog reading. A rule of thumb is to keep such voltages under about one LSB (least significant bit) of the ADC.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-27T13:00:44.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10371" PostTypeId="2" ParentId="10368" CreationDate="2015-04-27T13:10:35.760" Score="0" Body="&lt;p&gt;Usually you sum the magnitudes of the currents - so&lt;br&gt;&#xA;|+30| + |-10| = 30 + 10 = 40 mA in your example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Predictably but unfortunately. the principle of &lt;a href=&quot;http://en.wikipedia.org/wiki/There_ain&amp;#39;t_no_such_thing_as_a_free_lunch&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;TANSTAAFL&lt;/strong&gt;&lt;/a&gt;  usually applies in such matters :-).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such limitations are often (but not solely) dissipation based.&lt;br&gt;&#xA;A low level output pin is dissipating ~= (Vo_low) x I low and&lt;br&gt;&#xA;a high level pin dissipates (Vdd-Vo_high) x I_high.&lt;br&gt;&#xA;For low currents versus I_pin_max, Voutlow is ~= 0  and Vouthigh is ~= Vdd.&lt;br&gt;&#xA;As currents approach design capacities Voutlow starts to rise and Vouthigh starts to fall (due to the internal 'switch' not being able to handle the current) and dissipation rises. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IF&lt;/strong&gt; you pulled a high pin fully low or a low pin fully high then&lt;br&gt;&#xA;at 5V and 200 mA IC dissipation = 1 Watt.&lt;br&gt;&#xA;Under that sort of abuse other bad things may happen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There MAY be some specialist cases where you can treat &lt;strong&gt;SOME&lt;/strong&gt; high and low currents as semi independent but this would need a good understanding of the IC and probably still lies outside specification.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-04-27T13:10:35.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10372" PostTypeId="1" AcceptedAnswerId="10382" CreationDate="2015-04-27T13:26:49.343" Score="2" ViewCount="4628" Body="&lt;p&gt;In my project I need to use as noiseless as possible data from a MPU6050, I do have some nice DMP data, what will happen if I apply Kalman filter above it? Will I get more noiseless data? Or will it become unreliable anymore? Are there any benefits to do that ?&lt;/p&gt;&#xA;" OwnerUserId="8643" LastEditorUserId="2944" LastEditDate="2015-04-27T18:14:30.017" LastActivityDate="2015-04-27T18:14:30.017" Title="Do I need Kalman Filter after I read DMP data on MPU6050?" Tags="|i2c|mpu6050|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10373" PostTypeId="2" ParentId="10362" CreationDate="2015-04-27T14:30:32.463" Score="-1" Body="&lt;p&gt;Not only will &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin = 9;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;take up RAM, but in this case, will use more RAM than necessary as &lt;code&gt;digitalWrite(uint8_t, uint8_t)&lt;/code&gt; only needs one-byte arguments, and an int is usually two bytes (compiler-dependent, but typical). Note that you can give the literal an explicit type in the #define:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ledPin ((int)9) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;though in a context such as a function argument where a specific type is required (because the function was properly prototyped!) it would either be implicitly cast or get an error message if the types don't match. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-04-27T14:30:32.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10374" PostTypeId="2" ParentId="10358" CreationDate="2015-04-27T15:32:50.507" Score="1" Body="&lt;p&gt;It's really easy to take an ATmega328 chip and wire it up on it's own.  There are even instructions on the Arduino site on how to do it.  Take a look at &lt;a href=&quot;http://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/Standalone&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even pull the 328 out of the Uno, add the crystal and a few caps and then program it with the Uno board.  I've done this a few times myself and it worked just fine for my needs.&lt;/p&gt;&#xA;" OwnerUserId="8613" LastActivityDate="2015-04-27T15:32:50.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10375" PostTypeId="2" ParentId="10352" CreationDate="2015-04-27T15:53:45.413" Score="1" Body="&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have an incorrect variable type assignment for previousMillis ('long' instead of 'unsigned long') resulting in illegal mixing of types in a subtraction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not certain that this is causing your problems but, if not, it will cause problems at some stage if millis() is never reset  - if only when millis() passes its halfway point.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not possible to prove with certainty that the mixing of types is not causing a problem without examining the compiled code as the action is 'illegal' and so no assurance is possible.&lt;br&gt;&#xA;(We &lt;strong&gt;hope&lt;/strong&gt; that the compiler writer 'got it right' :-) ). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you now use  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;long previousMillis = 0;  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should use   &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;unsigned long previousMillis = 0;  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Both 'long' and 'unsigned long' are 32 bit data types but long is signed and effectively &quot;wraps around&quot; at half value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from having funny things happen after about 25 days, if you mix data types in a calculation as you do in  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;RealTime = currentMillis - previousMillis;&lt;br&gt;&#xA;  where&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RealTime = unsigned long  &lt;/li&gt;&#xA;&lt;li&gt;currentMillis = unsigned long , but  &lt;/li&gt;&#xA;&lt;li&gt;previousMillis = long&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;then there is no certainty as to what the code will do when subtracting a long' from an 'unsigned long'.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We know what we would like it to do, and we hope that the compiler writer made the same assumptions as we do, but there is no guarantee. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, while it does no harm for RealTime to be of type 'unsigned long', this is usually not essential, as we know that  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;up to about 25 days the result will fit in the lower 31 bits of a 'long' and&lt;br&gt;&#xA;  up to 65.535 seconds the result will fit in the 16 bits of an unsigned int and&lt;br&gt;&#xA;  up to 32.767 seconds the result will fit in the lower 15 bits of an int.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if your period between millis() tests is guaranteed to fit in the above ranges then the lower range variables may be used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the mixing of types in the actual subtraction produces a technically undefined result, the use of a different type for the result than is used in the calculation is acceptable as the calculation result is well defined as long as the subtraction is performed correctly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;millis() wrap-around - &lt;strong&gt;NOT&lt;/strong&gt; a problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People have expressed concern about incorrect results when millis() overflows after about 50 days, but this need not be a concern if correct data typing is used.   When two variables or 'counters' (in this case eg millis() and previousMillis), both of type 'unsigned long' are subtracted or compared, the result is arithmetically valid, even if the &quot;upper&quot; variable ( millis() ) has reached the top of its range and 'wrapped around'. This result is true for any two unsigned integer counters which are both of the same length.&lt;br&gt;&#xA;ie the result of eg&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;delay = millis() - previousMillis &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;will ALWAYS be valid if millis() and previousMillis are both 'unsigned long's.&lt;br&gt;&#xA;This result is not intuitively obvious to most people and there are many &quot;solutions&quot; to this &quot;problem&quot; on web which seek to correct a problem that does not exist. If you are interested in making use of this fact in other situations it is worth taking pencil and paper (or your favoured equivalent) and using eg 3 or 4 bit variables, working through how this works and why. What happens is that the overflowing / wrapping around higher counter (millis() in this case) &quot;looks like&quot; a longer unsigned variable with additional bits above its MSb. When the subtraction is carried out an MSb &quot;bowwow&quot; may occur  - this is being &quot;borrowed&quot; from data bits that do not exist but this matters not when only the lower N bits (32 in this case) are of importance. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Variable (including the state of millis() ) can be saved in EEROM memory prior to a reboot. IF the data has to be validly written when a power outage occurs the system must detect the outage and continue to run long enough to validly write to EEROM. This requires proper design of power supply holdup time - without which EEROM corruption may occur due to power loss while writing to memory. As well as internal EEROM, it is possible to use low cost I^2C EEROM memory if non volatile storage requirements exceed uC EEROM capacity. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More detail on any of the above available if required. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-04-27T16:00:17.403" LastActivityDate="2015-04-27T16:00:17.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10376" PostTypeId="1" CreationDate="2015-04-27T16:41:28.600" Score="1" ViewCount="406" Body="&lt;p&gt;I am a programmer but pretty new to electronics , I recently bought a prototyping shield like the picture :&#xA;&lt;img src=&quot;https://i.stack.imgur.com/c3ZJc.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;In my view there is no bus connections here . I have lots components need connect to solder into a single board , and some ports like GND and VCC , SDA and SCL need connect via buses , how could I make solder such a bus connection by using this shield?&lt;/p&gt;&#xA;&lt;p&gt;Should I just continuously solder through the holes I want to form a bus?&lt;/p&gt;&#xA;&lt;p&gt;Thanks..!&lt;/p&gt;&#xA;" OwnerUserId="8643" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-27T10:32:07.713" Title="How I could make a bus connection in a prototype shield?" Tags="|arduino-uno|arduino-mega|shields|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10378" PostTypeId="2" ParentId="10369" CreationDate="2015-04-27T16:42:26.153" Score="1" Body="&lt;p&gt;The input current of the ADC is low enough not to change the potentiometer's characteristic (which won't be perfectly straight, anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only requirement is that the impedance of the potentiometer (according to Thévénin equal to R1 parallel to R2) shouldn't be greater than 10 k&amp;Omega;. That's because otherwise it takes too long for the ADC's capacitor to get charged.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-27T16:42:26.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10379" PostTypeId="2" ParentId="10368" CreationDate="2015-04-27T16:48:06.730" Score="4" Body="&lt;p&gt;Neither. First, inputs don't draw current. Whether you're sourcing current or draining it, it will always be an output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 200 mA rule is probably determined by the bonding wires for the Vcc and ground pins on the die. That means that all outputs which are sourcing current shouldn't source more than 200 mA combined, as this current will have to enter the device through the Vcc pin.&lt;br&gt;&#xA;Likewise all outputs sinking current shouldn't sink more than 200 mA combined, as this current will drain through the ground pin.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-27T16:48:06.730" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10380" PostTypeId="2" ParentId="9589" CreationDate="2015-04-27T17:02:06.077" Score="0" Body="&lt;p&gt;Are you sure one pins is configured as input? If one would be output high and the other output low you basically get a short circuit: from Vcc through the top FET of the high output, through the wire to the other Arduino, and into the lower FET of the low output, and back to ground.&lt;br&gt;&#xA;If the short circuit were perfect the voltage would drop to zero, but both FETs have a non-zero resistance, which makes them a voltage divider.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to protect your Arduino against this (such a short circuit does damage the I/O circuits!) is to place a 1 k&amp;Omega; series resistor between the pins. Since an input pin won't draw any current there won't be a voltage drop across the resistor either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't use Harry's I2C, because it's probably too complicated for your needs. (I don't know what data you want to exchange). A simple connection is the UART: one transmit line and one receive line. It's true that the UART is used for the USB communication, but that connection goes via a set of resistors, so that another controller using the bus should be able to override the USB's signals. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a long distance between the Arduino's you'll want RS232 level shifters.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-04-27T17:02:06.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10381" PostTypeId="2" ParentId="10362" CreationDate="2015-04-27T17:28:15.360" Score="4" Body="&lt;p&gt;Probably the best way would be&lt;br&gt;&#xA;    &lt;code&gt;const uint8_t LED_PIN = 9; // may require to #include &amp;lt;stdint.h&amp;gt;&lt;/code&gt;&lt;br&gt;&#xA;    or&lt;br&gt;&#xA;    &lt;code&gt;const byte LED_PIN = 9; // with no include necessary&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;const unsigned char LED_PIN = 9; // similarly&lt;/code&gt;&lt;br&gt;&#xA;The name is in caps as per general practice in C++ (and others) to name constants. &#xA;This should not use any RAM in itself, and use about 1 byte of program memory per use.&lt;br&gt;&#xA;However, there &lt;em&gt;might&lt;/em&gt; be problems when the number is higher than 127 and is sign-extended while getting promoted to larger signed integers (not entirely sure on this), although that is unlikely to happen with pin numbers.&lt;/p&gt;&#xA;" OwnerUserId="8711" LastActivityDate="2015-04-27T17:28:15.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10382" PostTypeId="2" ParentId="10372" CreationDate="2015-04-27T18:08:36.073" Score="2" Body="&lt;p&gt;The DMP data from the MPU6050 is already filtered, and while I have not expirimented with the DMP data much myself I believe it is pretty clean. If there is a calibration process you can do to improve it, that is probably worth expirimenting with, but you should not filter the values a second time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should figure out what your application's noise tolerance actually is before worrying about different filters. There are potential benefits to your own filter, I think knowing exactly how it performs in edge cases and being able to calibrating it to your specific problem could be beneficial; However, it could also end up being worse than the DMP. Don't forget that filter calculations can generally take a few milliseconds for an arduino to run that you don't have to worry about with the DMP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do work on your own filter, you will need to turn off the DMP and filter the raw values. Look into complementary, mahoney, and madgwick filters as well as kalman, which is quite computationally expensive. Using an existing library or an implementation from an open source quadcopter project is probably most efficient. The math associated with kalman filters and 3d rotations gets very complicated very quickly.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-04-27T18:08:36.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10384" PostTypeId="1" CreationDate="2015-04-27T18:43:35.140" Score="3" ViewCount="4944" Body="&lt;p&gt;&lt;strong&gt;Hardware:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Mega 2560 Rev3&lt;/li&gt;&#xA;&lt;li&gt;Ethernet Shield Rev3&lt;/li&gt;&#xA;&lt;li&gt;A sensor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take value from sensor, upload it to ThingSpeak.&lt;/li&gt;&#xA;&lt;li&gt;Host a web page on the Arduino.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done both things in the past. But now I want to upload the data to ThingSpeak and host a page on the board at the same time , and it doesn't seem to work. Should I try to make two clients? I'm really new two the whole networking stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm basically trying to stitch up ThingSpeak's example code with Zoomkat's client/server code. Here is what I'm trying. The webpage does work, but it doesn't upload to ThingSpeak for some reason.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;//zoomkat 12-08-11, combined client and server&#xA;//simple button GET with iframe code&#xA;//for use with IDE 1.0&#xA;//open serial monitor and send an g to test client and&#xA;//see what the arduino client/server receives&#xA;//web page buttons make pin 4 high/low&#xA;//use the \ slash to escape the &quot; in the html&#xA;//address will look like http://192.168.1.102:84 when submited&#xA;//for use with W5100 based ethernet shields&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address&#xA;IPAddress ip(192, 168, 0, 197); // ip in lan&#xA;IPAddress gateway(192, 168, 0, 1); // internet access via router&#xA;IPAddress subnet(255, 255, 255, 0); //subnet mask&#xA;&#xA;// ThingSpeak Settings&#xA;char thingSpeakAddress[] = &quot;api.thingspeak.com&quot;;&#xA;String writeAPIKey = &quot;2M6SFMKICXR7MU1A&quot;;&#xA;const int updateThingSpeakInterval = 4 * 1000;&#xA;&#xA;// Variable Setup&#xA;long lastConnectionTime = 0;&#xA;boolean lastConnected = false;&#xA;int failedCounter = 0;&#xA;&#xA;EthernetServer server(84); //server port&#xA;EthernetClient client;&#xA;String readString;&#xA;&#xA;void setup() {&#xA;  pinMode(4, OUTPUT); //pin selected to control&#xA;  Ethernet.begin(mac, ip, subnet, gateway);&#xA;  server.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;server/client 1.0 test 12/08/11&quot;);&#xA;  // keep track of what is loaded&#xA;  Serial.println(&quot;Send an g in serial monitor to test client&quot;);&#xA;  // what to do to test client&#xA;}&#xA;&#xA;void loop() {&#xA;  // Print Update Response to Serial Monitor&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  // Disconnect from ThingSpeak&#xA;  if (!client.connected() &amp;amp;&amp;amp; lastConnected) {&#xA;    Serial.println(&quot;...disconnected&quot;);&#xA;    Serial.println();&#xA;    client.stop();&#xA;  }&#xA;&#xA;  if(!client.connected() &amp;amp;&amp;amp; (millis() - lastConnectionTime &amp;gt; updateThingSpeakInterval)) {&#xA;    Serial.println(&quot;sendPost function started&quot;);&#xA;    sendPost();&#xA;  }&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        //read char by char HTTP request&#xA;        if (readString.length() &amp;lt; 100) {&#xA;          //store characters to string&#xA;          readString += c;&#xA;          //Serial.print(c);&#xA;        }&#xA;        //if HTTP request has ended&#xA;        if (c == '\n') {&#xA;          Serial.println(readString);&#xA;          //print to serial monitor for debuging&#xA;          //now output HTML data header&#xA;          if (readString.indexOf('?') &amp;gt;= 0) { //don't send new page&#xA;            client.println(&quot;HTTP/1.1 204 &quot;);&#xA;            client.println();&#xA;            client.println();&#xA;          } else {&#xA;            client.println(&quot;HTTP/1.1 200 OK&quot;); //send new page&#xA;            client.println(&quot;Content-Type: text/html&quot;);&#xA;            client.println();&#xA;            client.println(&quot;&amp;lt;HTML&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;HEAD&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;TITLE&amp;gt;Arduino test page&amp;lt;/TITLE&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;/HEAD&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;BODY&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;H1&amp;gt;THIS IS A TEST&amp;lt;/H1&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;/BODY&amp;gt;&quot;);&#xA;            client.println(&quot;&amp;lt;/HTML&amp;gt;&quot;);&#xA;          }&#xA;          delay(1);&#xA;          //stopping client&#xA;          client.stop();&#xA;          readString = &quot;&quot;;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void sendPost() {&#xA;  Serial.println(&quot;function initiated&quot;);&#xA;  client.stop();&#xA;  String tsData = String(analogRead(A0), DEC);&#xA;  if (client.connect(thingSpeakAddress, 80)) {&#xA;    client.print(&quot;POST /update HTTP/1.1\n&quot;);&#xA;    client.print(&quot;Host: api.thingspeak.com\n&quot;);&#xA;    client.print(&quot;Connection: close\n&quot;);&#xA;    client.print(&quot;X-THINGSPEAKAPIKEY: &quot; + writeAPIKey + &quot;\n&quot;);&#xA;    client.print(&quot;Content-Type: application/x-www-form-urlencoded\n&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.print(tsData.length());&#xA;    client.print(&quot;\n\n&quot;);&#xA;    client.print(&quot;field1=&quot;);&#xA;    //// is this the prob?&#xA;    client.print(tsData);&#xA;    lastConnectionTime = millis();&#xA;    if (client.connected()) {&#xA;      Serial.println(&quot;Connecting to ThingSpeak...&quot;);&#xA;      Serial.println();&#xA;      failedCounter = 0;&#xA;    } else {&#xA;      failedCounter++;&#xA;      Serial.println(&quot;Connection to ThingSpeak failed (&quot;+String(failedCounter, DEC)+&quot;)&quot;);   &#xA;      Serial.println();&#xA;    }&#xA;  } else {&#xA;    failedCounter++;&#xA;    Serial.println(&quot;Connection to ThingSpeak Failed (&quot;+String(failedCounter, DEC)+&quot;)&quot;);   &#xA;    Serial.println();&#xA;    lastConnectionTime = millis(); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8712" LastEditorUserId="37523" LastEditDate="2019-05-16T09:51:59.703" LastActivityDate="2021-11-20T17:01:20.137" Title="Arduino Ethernet shield server and client at the same time" Tags="|ethernet|web-server|networking|" AnswerCount="0" CommentCount="4" ClosedDate="2021-11-20T17:06:19.363" ContentLicense="CC BY-SA 4.0" />
  <row Id="10385" PostTypeId="1" AcceptedAnswerId="10397" CreationDate="2015-04-27T18:44:48.247" Score="0" ViewCount="401" Body="&lt;p&gt;I'm trying to connect 16x2 LCD screen to clone Arduino UNO via PF8574T backpack. 4 cables are connected to +5V, GND, SDA and SDL pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;When I tried &lt;a href=&quot;http://playground.arduino.cc/Main/I2cScanner?action=sourceblock&amp;amp;num=1&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; I2C scanner code from arduino.cc. It returned strange characters in serial monitor at first couple of tries. And now, when I try computer hangs.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use A4 A5 pins on the Arduino instead of SDA and SDL, i2c reported the device is on 0x27. It is ok. But if i keep LCD connected to Arduino, my iMac shutdowns after for a while. In error log i see there was a problem regarding USB serial device. I assume it as a power problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm on OS X Yosemite. Why this can be happening and how can I fix?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Computer is hanging as soon as the Arduino usb cable connected.&lt;/p&gt;&#xA;" OwnerUserId="8687" LastEditorUserId="8687" LastEditDate="2015-04-28T12:36:58.603" LastActivityDate="2015-04-28T12:36:58.603" Title="LCD Display hangs the computer" Tags="|arduino-uno|i2c|lcd|osx|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10386" PostTypeId="1" CreationDate="2015-04-27T19:10:35.487" Score="2" ViewCount="2644" Body="&lt;p&gt;I am making a web-client with an Arduino mega and Ethernet Shield. I am trying to receive data from a web-server running a php script and saving that data to the SD card located in the Arduino Ethernet shield. I have separately tested to read and write to SD and to Get data from the the php script using the Ethernet. But when i tried to merge those two code into one, i found that Ethernet is unable to connect to the web-server(php Script).But the Ethernet connects fine when i remove the SD Card from its slot. During my research i found that Arduino mega has different SPI pin configuration that the uno. And the libraries are supposed to handle the SPI data-line independently. But i still tried to manually controlled the SPI bus, but it did not work. As far as i know, i am now unable to change the SPI bus using the D4 pin for SD card and D10 pin for Ethernet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using native Ethernet library and SDFat library.(I Even used the native SD library but the result is the same).  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SdFat.h&amp;gt;&#xA;#define Ethernet_ss_pin 53&#xA;#define Sd_ss_pin 4&#xA;&#xA;// On the Ethernet Shield, CS is pin 4. SdFat handles setting SS&#xA;/////////////////////////////////////////////////////////////////////////////////&#xA;////////SD Config&#xA;/////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;SdFat sd;&#xA;SdFile myFile;&#xA;//const int chipSelect = 4;&#xA;const char* fileName=&quot;database.txt&quot;;&#xA;&#xA;/////////////////////////////////////////////////////////////////////////////////&#xA;////////Ethernet Config&#xA;/////////////////////////////////////////////////////////////////////////////////&#xA;//String server = &quot;rfid.unisec-bd.org&quot;; //ip Address of the server you will connect to&#xA;&#xA;//The location to go to on the server&#xA;//make sure to keep HTTP/1.0 at the end, this is telling it what type of file it is&#xA;String location = &quot;/getData.php HTTP/1.0&quot;;&#xA;&#xA;&#xA;// if need to change the MAC address (Very Rare)&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;////////////////////////////////////////////////////////////////////////&#xA;&#xA;EthernetClient client;&#xA;&#xA;char inString[3200]; // string for incoming serial data&#xA;int stringPos = 0; // string index counter&#xA;boolean startRead = false; // is reading?&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(53,OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  ChipSelect(0);&#xA;  Ethernet.begin(mac);&#xA;  String pageValue;&#xA;  pageValue=connectAndRead(); //connect to the server and read the output&#xA;  Serial.println(pageValue); //print out the findings.&#xA;  ChipSelect(1);&#xA;  // Initialize SdFat or print a detailed error message and halt&#xA;  // Use half speed like the native library.&#xA;  // change to SPI_FULL_SPEED for more performance.&#xA;  if (!sd.begin(Sd_ss_pin, SPI_HALF_SPEED)) {&#xA;    sd.initErrorHalt(&quot;Sd initialization failed&quot;);&#xA;  }else{&#xA;    Serial.println(&quot;Sd card Initialized&quot;);&#xA;  }&#xA;  ChipSelect(0);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Type any character to start&quot;);&#xA;  while (Serial.read() &amp;lt;= 0) {}&#xA;  delay(1000);  // catch Due reset problem&#xA;  ChipSelect(2);&#xA;  String pageValue = connectAndRead(); //connect to the server and read the output&#xA;  Serial.println(pageValue); //print out the findings.&#xA;  ChipSelect(1);&#xA;  writeSd(pageValue);&#xA;  readSd();&#xA;  ChipSelect(0);&#xA;}&#xA;void readSd(){&#xA;  //const char path=(const char)fileName;&#xA;  if (!myFile.open(fileName, O_READ)) {&#xA;    sd.errorHalt(&quot;file read error&quot;);&#xA;  }&#xA;  Serial.println(fileName);&#xA;  // read from the file until there's nothing else in it:&#xA;  char data;&#xA;  int c=0;&#xA;  while ((data = myFile.read()) &amp;gt;= 0) {&#xA;    data=char(data);&#xA;    Serial.print(data);&#xA;    //Serial.println(c);&#xA;    c++;&#xA;  }&#xA;  // close the file:&#xA;  myFile.close();&#xA;}&#xA;&#xA;void writeSd(String storeData){&#xA;  // open the file for write at end like the Native SD library&#xA;  if (!myFile.open(fileName, O_RDWR | O_CREAT | O_AT_END)) {&#xA;    sd.errorHalt(&quot;opening database.txt for write failed&quot;);&#xA;  }&#xA;  // if the file opened okay, write to it:&#xA;  Serial.print(&quot;Writing to database.txt...&quot;);&#xA;  myFile.println(storeData);&#xA;&#xA;  // close the file:&#xA;  myFile.close();&#xA;  Serial.println(&quot;done.&quot;);&#xA;}&#xA;&#xA;String connectAndRead(){&#xA;   ///////// Pin 10,11,12,13 are used as SPI Bus of the ethernet Shield&#xA;/// MOSI-         pin 11&#xA;/// MISO-         pin 12&#xA;/// CLK-          pin 13&#xA;/// CS for sdCard-pin 4&#xA;/// ss-           pin 10&#xA;  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.&#xA;  // Note that even if it's not used as the CS pin, the hardware SS pin &#xA;  // (10 on most Arduino boards, 53 on the Mega) must be left as an output &#xA;  // or the SD library functions will not work. &#xA;        //digitalWrite(Sd_ss_pin,HIGH); //SD is not active&#xA;&#xA; /*       USE THIS CODE FOR PROXY SERVER IN BRAC UNIVERSITY&#xA;        // if you get a connection, report back via serial:&#xA;  if (client.connect(&quot;192.168.1.5&quot;, 8080)) {  // This is connecting to the proxy&#xA;    Serial.println(&quot;connected&quot;);&#xA;    // Make a HTTP request through proxy:&#xA;    client.println(&quot;GET rfid.unisec-bd.org/getData.php HTTP/1.0&quot;);&#xA;    client.println();&#xA;  }&#xA;*/&#xA;  //connect to the server&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;  while(!client){;}&#xA;  //port 80 is typical of a www page&#xA;  if (client.connect(&quot;rfid.unisec-bd.org&quot;, 80)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    client.print(&quot;GET &quot;);&#xA;    client.println(location);&#xA;    client.println(&quot;Host: rfid.unisec-bd.org&quot;); // SERVER ADDRESS HERE TOO&#xA;    client.println(&quot;Content-Type: application/x-www-form-urlencoded&quot;);&#xA;    client.println();&#xA;    //Connected - Read the page&#xA;    return readPage(); //go and read the output&#xA;  }else{&#xA;    return &quot;connection failed&quot;;&#xA;  }&#xA;}&#xA;&#xA;String readPage(){&#xA;  //read the page, and capture &amp;amp; return everything between '&amp;lt;' and '&amp;gt;'&#xA;  stringPos = 0;&#xA;  memset( &amp;amp;inString, 0, 3200 ); //clear inString memory&#xA;  while(true){&#xA;    if (client.available()) {&#xA;      char c = client.read();&#xA;      if (c == '!' ) { //'!' is our begining character&#xA;        startRead = true; //Ready to start reading the part &#xA;      }else if(startRead){&#xA;        if(c != '@'){ //'@' is our ending character&#xA;          inString[stringPos] = c;&#xA;          stringPos ++;&#xA;        }else{&#xA;          //got what we need here! We can disconnect now&#xA;          startRead = false;&#xA;          client.stop();&#xA;          client.flush();&#xA;          Serial.println(&quot;disconnecting.&quot;);&#xA;          return inString;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;void ChipSelect(int s){&#xA;  if(s=0){                              //Both Device is off&#xA;    //digitalWrite(53,HIGH);&#xA;    digitalWrite(10,HIGH);&#xA;    digitalWrite(4,HIGH);&#xA;  }else if(s=1){                        //Only SD is active&#xA;    //digitalWrite(53,HIGH);&#xA;    digitalWrite(10,HIGH);&#xA;    digitalWrite(4,LOW);&#xA;  }else if(s=2){                        //Only Ethernet is Active&#xA;    //digitalWrite(53,HIGH);&#xA;    digitalWrite(10,LOW);&#xA;    digitalWrite(4,HIGH);&#xA;  }&#xA;  Serial.print(&quot;Ethernet SS:&quot;);&#xA;  Serial.println(digitalRead(10));&#xA;  Serial.print(&quot;SD SS:&quot;);&#xA;  Serial.println(digitalRead(4));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8713" LastActivityDate="2017-10-17T22:57:27.277" Title="Ethernet shield and sd card not working togather on arduino mega" Tags="|arduino-mega|ethernet|sd-card|spi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10387" PostTypeId="1" AcceptedAnswerId="10388" CreationDate="2015-04-27T19:21:49.227" Score="0" ViewCount="973" Body="&lt;p&gt;Hell0!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I run in small problem. I am try to control LED's by serial port.So I am expect to send &quot;1&quot; and two LED's will start to blink or send &quot;0&quot; and only one LED is constantly lighted up. At first I thought that do-wile will work, Arduino will run do loop while value sent by serial port is &quot;1&quot; or &quot;0&quot;. However at first I sent &quot;0&quot; and one LED are lighted, after I send &quot;1&quot; and two LED's are blinking. But when I send &quot;0&quot; again, LED's keeps blinking. What should I change in my code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin2=2;&#xA;const int ledPin3=3;&#xA;const int ledPin4=4;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(ledPin3, OUTPUT);&#xA;  pinMode(ledPin4, OUTPUT);&#xA;&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  while (Serial.available()==0);&#xA;&#xA;  int serialVal = Serial.read()-'0';&#xA;&#xA;&#xA;  do&#xA;   {&#xA;      digitalWrite(ledPin3, LOW);&#xA;      digitalWrite(ledPin4,HIGH); &#xA;    } while(serialVal==0);&#xA;&#xA;  do&#xA;    {&#xA;      digitalWrite(ledPin4,LOW);   &#xA;      digitalWrite(ledPin2, HIGH);&#xA;      digitalWrite(ledPin3, LOW);&#xA;&#xA;      delay(100);&#xA;&#xA;      digitalWrite(ledPin3, HIGH);&#xA;      digitalWrite(ledPin2, LOW);&#xA;&#xA;      delay(100);&#xA;&#xA;  }while (serialVal==1);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8715" LastActivityDate="2015-04-29T04:49:08.657" Title="Serial LED control" Tags="|arduino-uno|serial|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10388" PostTypeId="2" ParentId="10387" CreationDate="2015-04-27T19:32:34.423" Score="1" Body="&lt;p&gt;I don't think you understand how your code is being executed. I would recommend trying the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin2=2;&#xA;const int ledPin3=3;&#xA;const int ledPin4=4;&#xA;int serialVal;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(ledPin3, OUTPUT);&#xA;  pinMode(ledPin4, OUTPUT);&#xA;&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  // If data is available, then read it!&#xA;  if (serial.available() &amp;gt; 0) &#xA;  {&#xA;      serialVal = serial.read()-'0';&#xA;  }&#xA;&#xA;  // If serial val is 1, turn on LEd4, turn off Led3&#xA;  if (serialVal == '1')&#xA;  {&#xA;      digitalWrite(ledPin3, LOW);&#xA;      digitalWrite(ledPin4,HIGH); &#xA;  }&#xA;&#xA;  // If serial val is 0, &#xA;  // turn on LED2. Turn off Led3&#xA;  // delay for 100ms&#xA;  // turn of LED2, turn on LED3&#xA;  // delay for 100 ms&#xA;  if (serialVal == '0')&#xA;  {&#xA;      digitalWrite(ledPin4,LOW);   &#xA;      digitalWrite(ledPin2, HIGH);&#xA;      digitalWrite(ledPin3, LOW);&#xA;&#xA;      delay(100);&#xA;&#xA;      digitalWrite(ledPin3, HIGH);&#xA;      digitalWrite(ledPin2, LOW);&#xA;&#xA;      delay(100);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason why your code doesn't work, is once you are within a do while loop, you will not be allowed to exit until the condition is met. If you are not scanning for more serial values within that do while, you will get stuck there forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another reason why you might be confused, is how digitalWirte operates. There is no need to loop over a digitalWrite, as the pin will stay HIGH, or LOW until you change its state. Once you digitalWrite(HIGH) that pin will stay high until it is told to go LOW.&lt;/p&gt;&#xA;" OwnerUserId="8716" LastEditorUserId="8716" LastEditDate="2015-04-29T04:49:08.657" LastActivityDate="2015-04-29T04:49:08.657" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10389" PostTypeId="1" AcceptedAnswerId="10394" CreationDate="2015-04-27T20:16:14.703" Score="2" ViewCount="1106" Body="&lt;p&gt;I have defined my code to generate an interrupt over each 5&amp;mu;s on CTC mode using timer1 but the output shows a time of ~15&amp;mu;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the equation to set the counting number to achieve the desired time &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(# timer counts + 1) = (target time) / (timer resolution)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've got OCR1A = 79 for a desired time of 5&amp;mu;s using no prescaler and a source clock of 16MHz on Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// avr-libc library includes&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;#define LEDPIN 9&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(LEDPIN, OUTPUT);&#xA;    digitalWrite(LEDPIN, HIGH);&#xA;&#xA;    // initialize Timer1&#xA;&#xA;    cli();          // disable global interrupts&#xA;&#xA;    TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;    // set compare match register to desired timer count:&#xA;    OCR1A = 79;&#xA;&#xA;    // turn on CTC mode:&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;&#xA;    // Set CS10 bit for no prescaler:&#xA;    TCCR1B |= _BV(CS10);&#xA;&#xA;    // enable timer compare interrupt:&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;    sei();          // enable global interrupts&#xA;&#xA;}&#xA;&#xA;void loop () {}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;  digitalWrite(LEDPIN, !digitalRead(LEDPIN));  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output from my logic analyzer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ft4Ti.png&quot; alt=&quot;Output From Logic Analyzer&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a limitation of the Arduino or am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to generate a PWM manually to control a servo motor using timer1 and precisely increase the period by 10&amp;mu;s during &quot;on&quot; time and get the desired angle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some experiments, I have discovered that my motor (&lt;a href=&quot;http://www.servodatabase.com/servo/towerpro/mg996r&quot; rel=&quot;nofollow noreferrer&quot;&gt;MG996R&lt;/a&gt;) has a range from 0.6ms to 2.1ms during &quot;on&quot; time to move from 0 to 180 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the Arduino's Servo library but it goes far than 180 degrees (I don't know why). That's why I am building my own code for that purpose.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="10794" LastEditDate="2015-07-30T22:38:01.300" LastActivityDate="2015-07-30T22:38:01.300" Title="Why does timer1 not generate correct period on CTC mode with a resolution of 5us?" Tags="|arduino-uno|c++|servo|timers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10390" PostTypeId="1" CreationDate="2015-04-27T20:35:13.050" Score="6" ViewCount="3338" Body="&lt;p&gt;I am looking to devise a level tracking system using arduino and some sensors. My particular situation is I have solute that is coming out of solution and I want to track the formation rate of the solid phase as the salts settle at the bottom and build a bed of particulates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for precision at about 0.5mm and over a range of like 6 inches. My initial idea was to get a sensor bar that could detect when and where light is hitting the sensor and post processes that signal. I have to design this device to sit outside the cylindrical vessel. The solvent is transparent so any form of light would work. I am stuck on finding the parts that could pull this off and I was hoping the more experienced community could point in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;* UPDATE *&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a little cartoon for a clearer picture of the idea &#xA;I am leaning towards capacitance since using light seems like a rabbit hole. I was playing with some foil and it may work but I need a much more sensitive tool on the order of pico-Farads to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oWIi9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8718" LastEditorUserId="8718" LastEditDate="2015-04-29T19:27:04.483" LastActivityDate="2015-11-02T01:01:46.800" Title="Level tracking using optical or capacitance sensors" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="10391" PostTypeId="1" AcceptedAnswerId="10395" CreationDate="2015-04-28T00:31:01.497" Score="1" ViewCount="1759" Body="&lt;p&gt;I created a class inside the sketch file(not in another file) and init it as object before setup() and loop() as a global object, after I change some parameters inside the object in setup() , I found in loop() the parameters in the global object remain unchanged.&#xA;Here is the pseudocode code to describe my question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//all of the code below are in the same ino file.&#xA;class Animal{&#xA;public:&#xA;  bool alive = false; &#xA;  Animal (bool liveStatus){&#xA;    alive = liveStatus;&#xA;  }&#xA;}&#xA;&#xA;Animal dog(false);&#xA;Animal cat(false);&#xA;Animal lion(false);&#xA;Animal animalArray(dog,cat,lion);&#xA;&#xA;&#xA;&#xA;&#xA;void setup(){&#xA;&#xA;  for (int i=0;i&amp;lt;3;i++){&#xA;    Animal current_animal = animalArray[i];&#xA;    current_animal.alive = true;&#xA;  }&#xA;  //here when I print each animal's alive flag is 'true'&#xA;}&#xA;&#xA;void loop(){&#xA;  for (int i=0;i&amp;lt;3;i++){&#xA;         // here the alive flag of each animal is still false  , they should be all true!!&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like after I quit setup() somehow every change of the global object inside the setup are all gone .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for helping me .. &lt;/p&gt;&#xA;" OwnerUserId="8643" LastEditorUserId="8643" LastEditDate="2015-04-28T03:12:41.913" LastActivityDate="2015-04-28T03:23:03.053" Title="How can I use a 'Global' class object?" Tags="|arduino-uno|arduino-ide|ide|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10392" PostTypeId="1" AcceptedAnswerId="10393" CreationDate="2015-04-28T01:37:44.677" Score="2" ViewCount="228" Body="&lt;p&gt;I have been building a standalone Arduino on a breadboard following the guide, &lt;a href=&quot;http://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Building an Arduino on a Breadboard&lt;/a&gt;. The guide is generally very good, however, I have yet to get the Arduino working, for a number of various reasons, be it misinterpreted, or misread instructions (the reset pull-up resistor connected to GND instead of Vcc, Tx to Tx, instead of Tx to Rx (and vice versa), to name but a few issues that I have had to resolve).  However, I am sure that the following issue is not down to my careless interpretation or lack of attention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;a href=&quot;http://arduino.cc/en/uploads/Main/arduinobload_wires.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;the photo&lt;/a&gt; taken from the webpage, &lt;a href=&quot;http://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Building an Arduino on a Breadboard&lt;/a&gt;, on the Arduino website, showing the &lt;em&gt;Sparkfun AVR programming adapter&lt;/em&gt; connected to the ATmega IC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bQWqz.jpg&quot; alt=&quot;Standalone Arduino breadboard&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MOSI on the adapter is shown to be connected, via a dark green wire, to pin 16 on the ATmega chip, whereas the instructions say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Be sure to refer to the Arduino pin mapping for help wiring this up.&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;The MISO pin of your adapter will go to pin 18 or Arduino digital pin    12 of your Atmega chip.&lt;/li&gt;&#xA;  &lt;li&gt;The SCK pin of your adapter will go to pin 19 or Arduino digital pin    13 of your Atmega chip.&lt;/li&gt;&#xA;  &lt;li&gt;The RESET pin of your adapter will go to pin 1 of your Atmega chip.&lt;/li&gt;&#xA;  &lt;li&gt;The MOSI pin of your adapter will go to pin 17 or Arduino digital pin    11 of your Atmega chip.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to the pinout below, Pin 16 is SS and pin 17 is indeed MOSI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PdcP5.png&quot; alt=&quot;ATmega168 pin out&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to my mind, the photo is definitely wrong. Indeed I was getting avrdude errors when trying to use a USBasp to load a bootloader, when using the wiring as shown in the photo. When I correctly wired MOSI, from the adapter, to pin 17, the avrdude errors disappeared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct in my thinking? Has anyone else attempted to build this circuit, following the instructions on the Arduino website, and come across this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am just looking for confirmation that I am right, before I contact the owner of the web page.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2016-10-05T21:27:42.063" LastActivityDate="2016-10-05T21:27:42.063" Title="Arduino Standalone - photo shows incorrect pin wired to MOSI" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10393" PostTypeId="2" ParentId="10392" CreationDate="2015-04-28T01:40:15.517" Score="4" Body="&lt;p&gt;I have programmed AVR microcontrollers for a while. I would follow the datasheet, instead of the guide you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmega168 Pin Mapping shows SS on 16, MOSI 17, MISO 18, SCK 19 and you will also need to connect to RST 1&lt;/p&gt;&#xA;" OwnerUserId="8716" LastActivityDate="2015-04-28T01:40:15.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10394" PostTypeId="2" ParentId="10389" CreationDate="2015-04-28T01:46:49.220" Score="3" Body="&lt;p&gt;I got it working just analyzing time consumption of digitalWrite and digitalRead functions. They took around 13us to execute (each one), so this added up a few extra undesired microseconds to the final period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I set up digital output using DDRD for configuring and PORTD for setting the desired output, which results in approximately 1us to set the output value (HIGH or LOW).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the prescaler to 8 and the code below shows how to get a 100kHz wave output with 5us duration of &quot;on&quot; time using timer1 CTC mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    DDRD = B00001000; // pin 3 as output&#xA;    PORTD &amp;amp;= ~_BV(PORTD3);   // set 3 as LOW&#xA;&#xA;    // initialize Timer1&#xA;&#xA;    cli();          // disable global interrupts&#xA;&#xA;    TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;    // set compare match register to desired timer count:&#xA;    OCR1A = 9;&#xA;&#xA;    // turn on CTC (Clear Timer on Compare Match) mode:&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;&#xA;    // Set CS10 bit for clk/8 prescaler:&#xA;    TCCR1B |= _BV(CS11);&#xA;&#xA;    // Output Compare A Match Interrupt Enable&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;    sei();          // enable global interrupts&#xA;&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;  PORTD = ~PORTD;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-04-28T01:46:49.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10395" PostTypeId="2" ParentId="10391" CreationDate="2015-04-28T03:23:03.053" Score="1" Body="&lt;p&gt;Your problem here is that &lt;code&gt;Animal current_animal = animalArray[i];&lt;/code&gt; is making a whole new Animal object that starts as a copy of &lt;code&gt;animalArray[i];&lt;/code&gt;, but after that the two are no longer associated. Then when you call &lt;code&gt;current_animal.alive = true;&lt;/code&gt;, you are not actually changing the animal in &lt;code&gt;animalArray[i]&lt;/code&gt; anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way to fix this is to make &lt;code&gt;current_animal&lt;/code&gt; a reference to the object you pick out of the array, although a pointer would work the same way. With this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Animal&amp;amp; current_animal = animalArray[i];&#xA;current_animal.alive = true;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;current_animal&lt;/code&gt; becomes a reference to &lt;code&gt;animalArray[i]&lt;/code&gt;, instead of a copy. Then operating on &lt;code&gt;current_animal&lt;/code&gt; changes the same data that is stored in &lt;code&gt;animalArray[i]&lt;/code&gt; like you intend.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-04-28T03:23:03.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10397" PostTypeId="2" ParentId="10385" CreationDate="2015-04-28T05:45:13.583" Score="0" Body="&lt;p&gt;Sometimes my system hangs in the way you describe  (&quot;hanging as soon as the Arduino usb cable connected&quot;)  if I mistakenly connect  the +ve and -ve supply lines to an i2c device the wrong way round. &lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-04-28T05:45:13.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10399" PostTypeId="1" CreationDate="2015-04-28T08:00:59.277" Score="0" ViewCount="2180" Body="&lt;p&gt;my project involves 9 Neopixel LEDs. I have tested my code with my Arduino Uno board successfully. I'm using a mix of breadboard, jumper wires, and solder to connect everything. Powering the strip of 9 LEDs with 4 AA NiMh rechargable batteries, showing 5.2v on the meter. I've put a capacitor (1000mF 25v) in the circuit, right at the power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I upload the same code to my Mini (5v/16MHz) and swap it in in place of the Uno, I get nothing. No matter how much I jiggle wires or provide a good ground (which helped me get good results from my Uno). Every now and then by messing with wires, or as a few minutes go by, the first few lights &lt;em&gt;might&lt;/em&gt; light up, but not in the right colors and no animation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to test the Mini board I uploaded the sample program &quot;blink&quot; and the mini runs that one properly. So I'm certain my code is getting on there. My program is definitely bigger and involves some quick changes (I'm making an &quot;ebbing&quot; glow of supernatural eyes). Connecting the Mini to the Neopixel strip I soldered a wire with a female jumper onto the board, and my strip of lights has a wire soldered on with a male jumper. As a side note, it takes a little physical handling to get the project to work with the Uno (like pressing a little bit on the data wire in it's plug on the Uno or using a jumper wire in the breadboard clamped in a metal measuring tool and my hand to ground out the circuit). So maybe I'm just experiencing some of the shortcomings of the Mini, but I was under the impression that it would do just about anything the Uno could do. Especially in terms of just providing a data line for the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to Neopixel. This is my first project in fact. So it is entirely possible I'm doing something wrong or there's something I just missed completely, or maybe my luck just sucks and I have some piece of faulty hardware... No idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be most appreciated!&lt;/p&gt;&#xA;" OwnerUserId="8742" LastActivityDate="2015-05-10T23:56:58.490" Title="Arduino Mini Pro not working with my Neopixel project" Tags="|arduino-uno|led|arduino-mini|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10400" PostTypeId="1" CreationDate="2015-04-28T09:05:15.253" Score="-1" ViewCount="567" Body="&lt;p&gt;I am using the EasyVR Arduino Shield with Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i am trying to do is train a custom phrase like a name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to train the phrase directly with arduino whilst it is not connected a pc.  I have noticed in the documentation there are some references to commands like it, but i'm not sure how to go around writing code for such a thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you&lt;/p&gt;&#xA;" OwnerUserId="878" LastActivityDate="2016-02-03T23:04:26.647" Title="Training Commands with easyVR" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10401" PostTypeId="1" AcceptedAnswerId="10402" CreationDate="2015-04-28T11:56:42.953" Score="1" ViewCount="118" Body="&lt;p&gt;Good afternoon,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a nutshell I'm having some difficulty with splitting and returning part of a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially I'm working on the code for transmitting a password (24 character string) and command (string) in a single packet. However, the 'get_command' function is only returning the first character of the string (T) as opposed to the whole string (T1) and I'm not sure why. Any help would be greatly appreciated. Thanks in advance.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entire sketch is below so you should be able to just drop it in and compile.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *received_data = &quot;KkV3vKvLgC4PdBZRs5kkKM86T1&quot;;&#xA;char *password = &quot;KkV3vKvLgC4PdBZRs5kkKM86&quot;;&#xA;&#xA;int authenticate_transmission(char *data) {&#xA;    if(strncmp(data, password, 24)) {&#xA;        Serial.println(&quot;no match&quot;);&#xA;        return false;&#xA;    } else {&#xA;        Serial.println(&quot;match&quot;);&#xA;        return true;&#xA;    }&#xA;}&#xA;&#xA;char *get_command(char *data) {&#xA;    char command[3];&#xA;    strncpy(command, data + 24, 3);&#xA;    // Fine here&#xA;    Serial.println(command);&#xA;    return command;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    // test received data - message is T1 at the end.&#xA;    if (authenticate_transmission(received_data)) {&#xA;        char *command = get_command(received_data);&#xA;        // But just prints out first char when returned from a function&#xA;        Serial.println(*command);&#xA;    }&#xA;    delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8726" LastActivityDate="2015-04-28T13:06:26.617" Title="Problems splitting a string to get authentication and command" Tags="|arduino-uno|c|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10402" PostTypeId="2" ParentId="10401" CreationDate="2015-04-28T12:17:52.987" Score="1" Body="&lt;p&gt;The &lt;code&gt;command&lt;/code&gt; array created inside &lt;code&gt;get_command()&lt;/code&gt; is local data. That means it's only available while that function is being executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you're returning a pointer to it. That means when you're trying to use &lt;code&gt;command&lt;/code&gt; afterwards from inside &lt;code&gt;loop()&lt;/code&gt;, you're trying to refer to data which has been deallocated. By that point, it's getting used for something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various solutions to this. A fairly simple approach would be to have the caller allocate the &lt;code&gt;command&lt;/code&gt; array, passing a pointer to it into &lt;code&gt;get_command()&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void get_command(char *data, char *command) {&#xA;    strncpy(command, data + 24, 3);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From &lt;code&gt;loop()&lt;/code&gt;, you would call it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;char command[3];&#xA;get_command(received_data, command);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;command&lt;/code&gt; array is still local data in this case. However, it's local to the &lt;code&gt;loop()&lt;/code&gt; function (or wherever else you put that code). That means it will still be available when &lt;code&gt;get_command()&lt;/code&gt; is called.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-04-28T12:17:52.987" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10403" PostTypeId="1" AcceptedAnswerId="10475" CreationDate="2015-04-28T12:21:53.943" Score="0" ViewCount="504" Body="&lt;p&gt;I want to make a RC buggy or something down those lines (using Legos of course) and I'm confused while looking what transmitter/receiver to use. Would like a simple classic remote and any compatible receiver for the Arduino. &#xA;Found such a remote: &lt;a href=&quot;http://www.hobbypartz.com/79p-th9x-r9b-9channel-radio.html&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbypartz.com/79p-th9x-r9b-9channel-radio.html&lt;/a&gt;&#xA;But this seems way overkill for what I want to do. Any links or suggestions would be appreciated. Hope the question isn't too broad for stack exchange.&lt;/p&gt;&#xA;" OwnerUserId="6646" LastActivityDate="2015-05-01T16:32:25.863" Title="Arduino R/C compatible transmitter and reciever" Tags="|arduino-mega|remote-control|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10404" PostTypeId="2" ParentId="10401" CreationDate="2015-04-28T13:06:26.617" Score="1" Body="&lt;p&gt;The direct issue is you have a dereference operator (&lt;code&gt;*&lt;/code&gt;) in the loop that you don't need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(*command);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This causes it to pass &lt;strong&gt;only the first character&lt;/strong&gt; to &lt;code&gt;Serial.println()&lt;/code&gt; instead of the pointer to the memory location. That's the first issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like Peter mentioned, the string gets deallocated when returned from the &lt;code&gt;get_command()&lt;/code&gt; function. It's undefined behavior, but it's luck that it worked the way it did.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-04-28T13:06:26.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10405" PostTypeId="2" ParentId="104" CreationDate="2015-04-28T14:17:25.650" Score="0" Body="&lt;p&gt;i have been trying out arduinodroid - it's an ide that claims you can upload to your arduino from it. you need an OTG cable (on the go) and to be honest i never actually managed to upload from arduinodroid but others seem to be able to...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my arduino is currently not talking to my computer - a bootloader problem it seems - so i'm getting hold of an AVR ISP MKii - with one of them it is apparently possible to send from terminal ide - an android app, will feedback when and if i get it to work.&lt;/p&gt;&#xA;" OwnerUserId="8729" LastActivityDate="2015-04-28T14:17:25.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10407" PostTypeId="2" ParentId="117" CreationDate="2015-04-28T17:34:34.363" Score="5" Body="&#xA;&#xA;&lt;p&gt;I do not claim this method for my own, but I found this neat trick on the webpage &lt;a href=&quot;http://dawson-station.blogspot.com/2010/01/mux-demux-cd4051-parlor-tricks.html&quot; rel=&quot;noreferrer&quot;&gt;MUX-DEMUX: CD4051 Parlor Tricks&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever method you choose to use to drive outputs or read inputs (shift registers, multiplexors or the straightforward direct use of the Arduino pins themselves) you can DOUBLE the number of outputs or inputs by a clever use of parallel circuit pairs (to form a dual input or output &lt;em&gt;bank&lt;/em&gt;), employing diodes in opposing senses on each parallel branch, and switching the inputs/outputs to high and low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To illustrate the method for outputs (LEDs in this case, note that the extra diodes are not required):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nb0Mi.png&quot; alt=&quot;LED bank&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you consider the pair of LEDs in this example to be a &quot;bank&quot;, and&#xA;  you want to light LED_0, you need to set PIN 17 to HIGH, and PIN 18 to&#xA;  LOW. (The pin numbers are confusing, but they match the later example&#xA;  so bare with me). To light LED_1, you just reverse the PINS. The diode&#xA;  nature of LEDs keeps the current from flowing the opposite direction&#xA;  keeping the other one off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To illustrate the method for inputs (CdSs in this case, note that the extra diodes are required):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/m11CU.png&quot; alt=&quot;CdS bank&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This gets a little more complicated if you want to do an analog read&#xA;  on a CdS light sensor. First, you need to add a diode to each sensor&#xA;  to control the flow. Second, since you are reading values, you need to&#xA;  pull the inputs high or low to keep them from floating. Being a lazy&#xA;  person, I'm going to pull them high using the internal pull-up&#xA;  resistors. To read CdS_0, you set PIN 17 mode to OUTPUT and set it to&#xA;  LOW. This makes it the ground. Then you set PIN 18 mode to INPUT and&#xA;  set it to HIGH to engage the pull-up resistor. Now you are set to do a&#xA;  read on PIN 18 (a.k.a. analog pin 4). To access the other sensor, just&#xA;  switch the modes and outputs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if you have a CD4051 8 port multiplexor, using 5 pins on the Arduino (instead of the usual 3), you can obtain 16 inputs or outputs, or a mix of the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/H8E2F.png&quot; alt=&quot;16 outputs/inputs using a CD4051&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise, if you have a 4067 16 port multiplexor you can obtain 32 inputs or outputs, or a mix of the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example sketch would be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Example of getting 16 i/o from 5 pins using a CD4051&#xA; *&#xA; * Based on tutorial and code by david c. and tomek n.* for k3 / malmö högskola&#xA; * http://www.arduino.cc/playground/Learning/4051?action=sourceblock&amp;amp;ref=1&#xA; */ &#xA;&#xA;&#xA;int selPin[] = { 14, 15, 16 }; // select pins on 4051 (analog A0, A1, A2)&#xA;int commonPin[] = { 17, 18};   // common in/out pins (analog A3, A4)&#xA;int led[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };  // stores eight LED states&#xA;int CdSVal[] = { 0, 0, 0, 0 }; // store last CdS readings&#xA;int cnt = 0;  // main loop counter&#xA;int persistDelay = 100; // LED ontime in microseconds&#xA;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);  // serial comms for troubleshooting (always)&#xA;  for(int pin = 0; pin &amp;lt; 3; pin++){ // setup select pins&#xA;    pinMode(selPin[pin], OUTPUT);&#xA;  } &#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  flashLEDs();&#xA;  if (cnt == 0){&#xA;    for(int x; x &amp;lt; 8; x++){&#xA;      led[x] = random(2);&#xA;    }&#xA;  }&#xA;  cnt++;&#xA;  if (cnt &amp;gt; 100) { cnt = 0; }&#xA;}&#xA;&#xA;&#xA;void flashLEDs() {&#xA;  for(int pin = 0; pin &amp;lt; 2; pin++) {  // set common pins low&#xA;    pinMode(commonPin[pin], OUTPUT);&#xA;    digitalWrite(commonPin[pin], LOW);&#xA;  } &#xA;  for (int bank = 0; bank &amp;lt; 4; bank++) {&#xA;    for(int pin = 0; pin &amp;lt; 3; pin++) { // parse out select pin bits&#xA;      int signal = (bank &amp;gt;&amp;gt; pin) &amp;amp; 1;  // shift  &amp;amp; bitwise compare&#xA;      digitalWrite(selPin[pin], signal);&#xA;    }&#xA;    if (led[bank * 2]){        // first LED&#xA;      digitalWrite(commonPin[0], HIGH);  // turn common on&#xA;      delayMicroseconds(persistDelay);   // leave led lit&#xA;      digitalWrite(commonPin[0], LOW);   // turn common off&#xA;    } &#xA;    if (led[bank * 2 + 1]){     // repeat for second LED&#xA;      digitalWrite(commonPin[1], HIGH);&#xA;      delayMicroseconds(persistDelay);&#xA;      digitalWrite(commonPin[1], LOW); &#xA;    }&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like I said in the first line, the full explanation can be found on &lt;a href=&quot;http://dawson-station.blogspot.com/2010/01/mux-demux-cd4051-parlor-tricks.html&quot; rel=&quot;noreferrer&quot;&gt;MUX-DEMUX: CD4051 Parlor Tricks&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="10794" LastEditDate="2015-07-29T21:53:28.797" LastActivityDate="2015-07-29T21:53:28.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10408" PostTypeId="1" CreationDate="2015-04-28T19:11:07.753" Score="0" ViewCount="3400" Body="&lt;p&gt;I have just started playing with a low power arduino project, and have managed to get the power drain down to about 220uA using &lt;code&gt;powerDown&lt;/code&gt; from &lt;code&gt;LowPower&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would love to be able to do is start the USB controller and send some data every 8 seconds, but I cant seem to send anything...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea would be greatly appreciated :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Her is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// **** INCLUDES *****&#xA;#include &amp;lt;LowPower.h&amp;gt;&#xA;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  DDRD = B00100000;       // PORTD5 = TXLED&#xA;  DDRB = B00000001;        // PORTB0 = RXLed&#xA;&#xA;&#xA;  Serial.begin(9600);&#xA;  while (!Serial) ; // Needed for Leonardo only&#xA;  Serial.println(&quot;Starter...&quot;);&#xA;  delay(100);&#xA;  Serial.end();&#xA;&#xA;  /*&#xA;  *  IKKE FJERN DENNE!!! Da greier vi ikke å omprogramere kortet...&#xA;  */&#xA;  delay(10000);&#xA;  Serial.begin(9600);&#xA;  while (!Serial) ; // Needed for Leonardo only&#xA;  Serial.println(&quot;low-power...&quot;);&#xA;  delay(100);&#xA;  Serial.end();&#xA;  flash();&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF);//, USB_OFF);&#xA;  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);&#xA;  //USBCON &amp;amp;= B11011111; //Disable USB Freeze clock USBCON.FRZCLK&#xA;  //USBCON |= B10010001; //SET USB_MACRO_ENABLE_BIT USBCON.USBE&#xA;&#xA;    PLLCSR |= B00000010;   //-Enable             PLL PLLCSR.PLLE = 1; &#xA;    while (!(PLLCSR &amp;amp; 1)); //-Wait PLL LOCK      while (PLLCSR.PLOCK != 1);&#xA;    USBCON &amp;amp;= B11011111;   //-Unfreeze USB clock USBCON.FRZCLK = 0; (Clear to unfreeze)&#xA;    //-Clear Resume information ???&#xA;&#xA;  flash();&#xA;&#xA;&#xA;  /*&#xA;  * Test USB kommunikasjon :)&#xA;  */&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;  delay(5);&#xA;  Serial.println(&quot;Hello world!!!&quot;);&#xA;  delay(5);&#xA;  Serial.end();&#xA;   PORTD |= B00100000;&#xA;   PORTB |= B00000001;&#xA;}&#xA;&#xA;void flash() {&#xA;&#xA;   PORTD &amp;amp;= B11011111;&#xA;   PORTB &amp;amp;= B11111110;&#xA;   delay(100);&#xA;   PORTD |= B00100000;&#xA;   PORTB |= B00000001;&#xA;   delay(100);&#xA;&#xA;   PORTD &amp;amp;= B11011111;&#xA;   PORTB &amp;amp;= B11111110;&#xA;   delay(100);&#xA;   PORTD |= B00100000;&#xA;   PORTB |= B00000001;&#xA;   delay(100);&#xA;&#xA;   PORTD &amp;amp;= B11011111;&#xA;   PORTB &amp;amp;= B11111110;&#xA;   delay(100);&#xA;   PORTD |= B00100000;&#xA;   PORTB |= B00000001;&#xA;   delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Best regards, Richard&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;EDIT&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The manual specifies this resume protocol:&#xA;Resuming the USB interface (21.13 USB Software Operating Modes)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Enable PLL &lt;/li&gt;&#xA;&lt;li&gt;Wait PLL lock&lt;/li&gt;&#xA;&lt;li&gt;Unfreeze USB clock&lt;/li&gt;&#xA;&lt;li&gt;Clear Resume Informtion&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;which I have translated into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PLLCSR |= B00000010;   //-Enable             PLL PLLCSR.PLLE = 1; &#xA;while (!(PLLCSR &amp;amp; 1)); //-Wait PLL LOCK      while (PLLCSR.PLOCK != 1);&#xA;USBCON &amp;amp;= B11011111;   //-Unfreeze USB clock USBCON.FRZCLK = 0; (Clear to unfreeze)&#xA;//-Clear Resume information ???&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It have no effect whatsoever, have no idea how to &lt;strong&gt;clear resume information&lt;/strong&gt; though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, for the record, the LEDs are flashing happily every 8 seconds.&lt;/p&gt;&#xA;" OwnerUserId="4192" LastEditorUserId="4192" LastEditDate="2015-04-28T21:39:59.377" LastActivityDate="2016-01-24T19:41:07.233" Title="Starting usb on pro micro after deep sleep (ATmega32u4)" Tags="|arduino-leonardo|arduino-micro|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10409" PostTypeId="2" ParentId="4321" CreationDate="2015-04-28T19:45:25.043" Score="1" Body="&lt;p&gt;This is probably way to late, but with newer editions of the Micro you have to &quot;double-press&quot; the reset (input).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had some experiences today where playing with low-power modes that shuts down the usb interface, and the only way I got it back was activating the reset input twice fast, and then uploading a new scetch (this time with a 10sec delay before any usb-chaning stuff takes place!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Richard&lt;/p&gt;&#xA;" OwnerUserId="4192" LastActivityDate="2015-04-28T19:45:25.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10410" PostTypeId="1" CreationDate="2015-04-28T21:21:47.343" Score="0" ViewCount="17250" Body="&lt;p&gt;I'm working on Arduino and Ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to call a URL. How can do it? (This URL is HTTP API to send an SMS to my phone).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;url:&#xA;&lt;a href=&quot;http://api.clickatell.com/http/sendmsg?user=mohammed.atha&amp;amp;password=&quot; rel=&quot;nofollow&quot;&gt;http://api.clickatell.com/http/sendmsg?user=mohammed.atha&amp;amp;password=&lt;/a&gt;********&amp;amp;api_id=3539384&amp;amp;to=********&amp;amp;text=hello&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6583" LastEditorUserId="4628" LastEditDate="2015-06-30T17:50:12.167" LastActivityDate="2015-07-30T18:50:08.777" Title="How to call URL with Arduino Ethernet shield?" Tags="|arduino-uno|arduino-mega|shields|ethernet|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10411" PostTypeId="1" AcceptedAnswerId="10417" CreationDate="2015-04-28T22:20:30.777" Score="1" ViewCount="174" Body="&lt;p&gt;I am making a reverse sensing alarm system. I am using a HC-SR04, arduino UNo and a piezo buzzer. The programming was a success however i will like this circuit to be powered when the reverse gear is shifted into place. So I am thinking to power the V in of the UNO with the 10V from the  reverse bulb socket receives. However I think the amperage sent to this bulb is too much for my UNO. What should I do ? and Does anyone have any other recommendations to power the UNO in such a scenario? &lt;/p&gt;&#xA;" OwnerUserId="8738" LastActivityDate="2015-04-29T21:22:54.807" Title="Powering arduino uno from Car's reverse light?" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10412" PostTypeId="2" ParentId="10134" CreationDate="2015-04-28T22:52:18.930" Score="-1" Body="&lt;p&gt;You must download the CH431 drivers to your computer and restart. This will solve your problem. Google these drivers, you should be able to find them. If not, let me know and I can send you a link to my drive.&lt;/p&gt;&#xA;" OwnerUserId="8739" LastActivityDate="2015-04-28T22:52:18.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10413" PostTypeId="2" ParentId="10410" CreationDate="2015-04-28T23:15:24.580" Score="2" Body="&lt;p&gt;You need to use the &lt;strong&gt;EthernetClient&lt;/strong&gt;. &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/WebClient&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exemple using your API call is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    // Make your API request:&#xA;    client.println(&quot;GET /sendmsg?user=mohammed.atha&amp;amp;password=********&amp;amp;api_id=3539384&amp;amp;to=********&amp;amp;text=hello HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: api.clickatell.com/http/sendmsg&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Full example from Arduino.cc docs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address for your controller below.&#xA;// Newer Ethernet shields have a MAC address printed on a sticker on the shield&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;// if you don't want to use DNS (and reduce your sketch size)&#xA;// use the numeric IP instead of the name for the server:&#xA;//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)&#xA;char server[] = &quot;www.google.com&quot;;    // name address for Google (using DNS)&#xA;&#xA;// Set the static IP address to use if the DHCP fails to assign&#xA;IPAddress ip(192,168,0,177);&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server &#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA; // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;   while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  // start the Ethernet connection:&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    // try to congifure using IP address instead of DHCP:&#xA;    Ethernet.begin(mac, ip);&#xA;  }&#xA;  // give the Ethernet shield a second to initialize:&#xA;  delay(1000);&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  // if you get a connection, report back via serial:&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    // Make your API request:&#xA;    client.println(&quot;GET /sendmsg?user=mohammed.atha&amp;amp;password=********&amp;amp;api_id=3539384&amp;amp;to=********&amp;amp;text=hello HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: api.clickatell.com/http/sendmsg&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;  } &#xA;  else {&#xA;    // kf you didn't get a connection to the server:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // if there are incoming bytes available &#xA;  // from the server, read them and print them:&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;&#xA;  // if the server's disconnected, stop the client:&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;&#xA;    // do nothing forevermore:&#xA;    while(true);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8740" LastEditorUserId="8740" LastEditDate="2015-04-30T02:56:05.583" LastActivityDate="2015-04-30T02:56:05.583" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10415" PostTypeId="1" AcceptedAnswerId="18827" CreationDate="2015-04-29T00:44:03.387" Score="0" ViewCount="96" Body="&lt;p&gt;I have a UDOO, and I wonder whether or not it is possible to use the Arduino that it has without starting the UDOO's operating system, i.e., I would like use Atmel Studio to load a program within the Arduino at UDOO.&lt;/p&gt;&#xA;" OwnerUserId="8721" LastEditorUserId="6452" LastEditDate="2015-04-29T17:39:16.977" LastActivityDate="2015-12-18T23:57:47.520" Title="Can I use a UDOO as an Arduino?" Tags="|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10416" PostTypeId="2" ParentId="10355" CreationDate="2015-04-29T01:19:49.513" Score="1" Body="&lt;p&gt;I received my logic level converter today and wired it in between the Venus GPS and the Arduino GSM shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue seems to be resolved and I'm able to properly receive information from the TX on the Venus GPS.  It would seem that my assumption was correct and I needed to &quot;step-up&quot; the 3.3V TX signal from the Venus GPS in order to use it with the GSM shield. &lt;/p&gt;&#xA;" OwnerUserId="8700" LastActivityDate="2015-04-29T01:19:49.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10417" PostTypeId="2" ParentId="10411" CreationDate="2015-04-29T01:35:43.303" Score="2" Body="&lt;p&gt;Power the Arduino in parallel with the bulb.  Take the V+ wire running to the reverse light and the frame ground.  The frame ground is any bare metal surface of your car will be grounded, just connect a wire to your frame.  Or you can just splice the light bulbs ground wire.  When powering the circuit in parallel you do not have to worry about the amperage draw of the light.  By a barrel jack connector like &lt;a href=&quot;https://www.sparkfun.com/products/10287&quot; rel=&quot;nofollow&quot;&gt;this connector from spark fun&lt;/a&gt; you can buy these cheaper elsewhere just a 2.1mm barrel jack connector.  Connect the positive and negative respectively, and connect the 12v into the Arduino's barrel jack.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note the bulb should be getting 12V not 10V it's not a huge problem, but it is a slight issue that could later be a problem or be caused by an electrical bug.  If everything works don't scramble to fix it, but be aware it exists.&lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="1192" LastEditDate="2015-04-29T21:22:54.807" LastActivityDate="2015-04-29T21:22:54.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10418" PostTypeId="2" ParentId="9499" CreationDate="2015-04-29T01:47:37.367" Score="0" Body="&lt;p&gt;As mentioned in another answer use a multimeter to measure.  However I would recommend using the cars battery to power the system.  A parasitic draw on a cars battery of under 1 amp is considered acceptable (per what I learned in school).  A parasitic draw is current used while the car is off.  Get a clamp ammeter and check your parasitic draw and if you have the available amperage to spare run it from your battery. To check your parasitic draw place the clamp around the ground wire (or multiple ground wires) at the battery terminal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run it from your car battery you will never have to worry about changing the battery and it becomes a set and forget system.&lt;/p&gt;&#xA;" OwnerUserId="1192" LastActivityDate="2015-04-29T01:47:37.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10419" PostTypeId="2" ParentId="9571" CreationDate="2015-04-29T10:45:49.827" Score="0" Body="&lt;p&gt;Put CH_PD HIGH for AT mode COM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note if you upgrade firmware you need to take CH_PD LOW to write new firmware.&#xA;Also note if you upgrade your firmware for the LUA com speed will probably default to 115200 and then SoftSerial wont work.&#xA;I found it best to test on Arduino Mega as has extra serial ports.&lt;/p&gt;&#xA;" OwnerUserId="5010" LastActivityDate="2015-04-29T10:45:49.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10420" PostTypeId="1" AcceptedAnswerId="10429" CreationDate="2015-04-29T10:52:11.847" Score="0" ViewCount="201" Body="&lt;p&gt;some time ago i tried doing &lt;a href=&quot;https://www.youtube.com/watch?v=CMz2DYpos8w&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; with my original arduino uno r3. I guess i had to plug the power cables in wrong order(i think it's called reversing polarity)  because my arduino stoped working. It turns on (the power diode is on) but i cannot upload any sketch on it. I'm thinking about changing the ATMega chip but, before i do that i want to be certain that it's the chip issue ,not the programmer. I have another arduino uno, and i heard that i can upload sketch with it to another uno. So my idea is, if i do this i will be able to say whether it's the programmer or the chip issue. The only problem is that i don't know how to do this and i wasn't able to find any reasonable tutorials online. Please tell me what to do.&#xA;Many Thanks,&#xA;Jan&lt;/p&gt;&#xA;" OwnerUserId="8750" LastActivityDate="2015-04-29T17:14:29.113" Title="Not sure if programmer or ATMega is burned" Tags="|arduino-uno|programming|power|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10421" PostTypeId="2" ParentId="9571" CreationDate="2015-04-29T11:02:06.007" Score="2" Body="&lt;p&gt;When the 8266 is powered from the Arduino there is barely power enough for sending. So there will be power glitches that makes the USB port inactive.&#xA;Even a short voltage drop seems to disable the USB port until it is pulled and reconnected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I struggled with this. One solution is external power for the WiFi chip. One other solution is to put a 1000 uF capacitor on the 3V power line and ground. That has worked for me.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-04-29T11:02:06.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10425" PostTypeId="1" CreationDate="2015-04-29T16:01:40.610" Score="-1" ViewCount="567" Body="&lt;p&gt;So I just got this board I ordered from ebay and tried to play with it for the first time. &lt;a href=&quot;http://www.ebay.com/itm/Leonardo-Pro-Micro-ATmega32U4-Arduino-IDE-1-0-3-Bootloader-replace-Pro-Mini-/310634777706?pt=LH_DefaultDomain_0&amp;amp;hash=item4853468c6a&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/Leonardo-Pro-Micro-ATmega32U4-Arduino-IDE-1-0-3-Bootloader-replace-Pro-Mini-/310634777706?pt=LH_DefaultDomain_0&amp;amp;hash=item4853468c6a&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected it to my PC and it was installing a driver. I didn't pay much attention to it but I think it finished installing it successfully. I then installed arduino IDE 1.6.3(latest) and tried to compile and upload the empty default sketch just to see if it uploads it. the progress bar got to the end but it was stuck on &quot;uploading..&quot;. I waited for a few minutes but it didn't seem like it is going to end so I unplugged the USB and re inserted it back. I then looked in the tools menu and saw it was set to port COM1 which is the communications port on my pc, so I changed it to port COM4(Arduino Leonardo) and the board to Leonardo and again tried to compile and upload the default sketch but now I got this error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino: 1.6.3 (Windows 7), Board: &quot;Arduino Leonardo&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Error opening serial port 'COM4'. (Port not found)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;trying to open the serial monitor gives the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I checked the item listing on ebay and it said that the board was supported under arduino IDE 1.0.3 so I downloaded it and tried to compile and upload the default sketch but it gave me the serial port 'COM4' already in use error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried resetting the board, uninstalling and reinstalling the driver and the IDEs and disabling/re-enabling the device in the device manager. nothing helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure what I am doing wrong as I am new to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="8756" LastActivityDate="2016-02-13T17:31:16.780" Title="Clone pro micro serial port 'COM4' already in use" Tags="|serial|arduino-ide|arduino-leonardo|arduino-pro-micro|clones|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10427" PostTypeId="1" AcceptedAnswerId="10534" CreationDate="2015-04-29T16:34:41.440" Score="1" ViewCount="1040" Body="&lt;p&gt;I've got an electret microphone and I understand that I need quite some amplification to get it to be read by an Arduino (0-5V input). So I seeked the web, but answers are as different as people on the street. Some use Op-Amps, some only a transistor cicruit or the like. This guy is using 2 amps before and after his filters &lt;a href=&quot;https://www.youtube.com/watch?v=hpMVG4a9sR4&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow&quot;&gt;Video&lt;/a&gt;, &lt;a href=&quot;http://wiring.org.co/learning/basics/microphone.html&quot; rel=&quot;nofollow&quot;&gt;LM386&lt;/a&gt; and this guy claims, that exactly this amp isn't good for the job: &lt;a href=&quot;https://arduinodiy.wordpress.com/2012/12/20/electret-microphone-amplifier/&quot; rel=&quot;nofollow&quot;&gt;recommends NOT using LM386&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really only want to have a threshold switch, so I need no filters whatsoever and not a super duper amplification. What is the simplest solution, with which I can read a voltage with the arduino? With a transistor alone (seems easiest to me so far) - how can I know how much it amplifies (or as I understand it modifies the &quot;other voltage&quot; to look the same)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found many different schematics using various op-amps, but regarding them I don't really need another tutorial, but rather a rule of thumb for a &quot;readable&quot; amplification. Is 100 times enough? I found circuits with 1000 times amplification, so I'm really wondering which one works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the really simple thing would be this: &lt;a href=&quot;https://www.youtube.com/watch?v=0E9DzgRuL_k&quot; rel=&quot;nofollow&quot;&gt;video at 17sec&lt;/a&gt;. At second 17 and 50 or so, they show an extremly basic circuit, which would be exactly what would work best for me... However the question is, if this is enough amplification for the ADC in an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I can't get a satisfying answer I think I'll build both and see how they compare/work for me.&lt;/p&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2015-04-30T08:11:26.933" LastActivityDate="2015-05-05T09:56:37.620" Title="Electret microphone amplification" Tags="|audio|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10428" PostTypeId="1" CreationDate="2015-04-29T05:54:03.137" Score="5" ViewCount="651" Body="&lt;p&gt;For doing some experiments I bootloaded an Atmega16a with Arduino Uno. I am powering my Atmega16a from Arduino UNO. I am not using any external clock. Atmega16a is connected to a breadboard. For bootloading I refer the site &lt;a href=&quot;http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers&quot;&gt;http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers&lt;/a&gt; I can run blink sketch on my Atmega16a using Arduino as ISP. TX and RX of Atmega16 is connected to Max485's DI and RO respectively.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega16a pin 14 (RXD) -&amp;gt; MAX485 pin 1-RO &#xA;Atmega16a pin 15 (TXD) -&amp;gt; MAX485 pin 4-DI  &#xA;Atmega16a pin 17 (D3)  -&amp;gt; MAX485 pin 2 and 3. Also connects a LED to the pin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used a boards.txt downloaded from &lt;a href=&quot;https://github.com/sudar/arduino-extra-cores/blob/master/boards.txt&quot;&gt;https://github.com/sudar/arduino-extra-cores/blob/master/boards.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Issue: hang at Serial.println&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I faced issues when I started to interface with MAX485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program wont run if I add a &lt;code&gt;Serial.println&lt;/code&gt;, see my program below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   Serial.begin(76800); // I tried 9600 too&#xA;   pinMode(3, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(3, HIGH); &#xA;  delay(400);&#xA;  Serial.println(&quot;20&quot;); //comment this code and could see the led blinks&#xA;  delay(2000);&#xA;  digitalWrite(3, LOW);&#xA;  delay(400); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Regression&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I tried Latest Arduino IDE as well as 1.0.6 version&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could do a serial communication with Raspberrypi and Arduino Uno via MAX485 without any issues. For the complete connection detail of MAX485 and other Arduino, check &lt;a href=&quot;http://sonyarouje.com/2015/04/23/rs485-communication-protocol-with-micro-controllers-and-raspberry-pi/&quot;&gt;my blog&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some times I receive some string to serial port of Raspberry pi like below. I run a nodejs app in RPi, using serialport npm and parser is RAW.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Buffer fa&amp;gt;&#xA;&amp;lt;Buffer 82&amp;gt;&#xA;&amp;lt;Buffer 86 ff&amp;gt;&#xA;&amp;lt;Buffer fe&amp;gt;&#xA;&amp;lt;Buffer fe&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to prevent these hangs?&lt;/p&gt;&#xA;" OwnerDisplayName="Sony Arouje" LastActivityDate="2015-10-30T10:21:27.583" Title="How to solve Atmega 16A Serial write (println) hang with Arduino Uno firmware?" Tags="|rs485|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10429" PostTypeId="2" ParentId="10420" CreationDate="2015-04-29T17:14:29.113" Score="0" Body="&lt;p&gt;The Arduino IDE ships with a built in &lt;code&gt;ArduinoISP&lt;/code&gt; sketch, and there is a very detailed &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; with wiring diagrams etc on the Arduino site.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2015-04-29T17:14:29.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10431" PostTypeId="1" AcceptedAnswerId="10439" CreationDate="2015-04-29T19:59:20.550" Score="1" ViewCount="1244" Body="&lt;p&gt;There are countless boards called &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems&quot; rel=&quot;nofollow&quot;&gt;&quot;Arduino compatible board&quot;&lt;/a&gt;. Some of them have specialized hardware features such as WiFi, SD card readers etc., but most of them seem like plain Arduino copies to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure, they are a bit cheaper, but for me the price difference doesn't make me favor the money I'd safe over the potential issues I have yet to discover.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; What are the benefits (or disadvantages) of Arduino compatible boards &lt;em&gt;(the ones without the &quot;extras&quot;)&lt;/em&gt; in general? Do you know an Arduino compatible board that you would recommend for some extraordinary features?&lt;/p&gt;&#xA;" OwnerUserId="8762" LastActivityDate="2015-04-30T15:33:03.837" Title="What are the advantages of &quot;Arduino compatible&quot; boards" Tags="|hardware|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10432" PostTypeId="2" ParentId="10427" CreationDate="2015-04-29T20:00:12.667" Score="1" Body="&lt;p&gt;For the most basic circuit you must bias your microphone since it is electret with a 10k pull up resitor. If you do not want to build a complex circuit you could use a breakout board such as &lt;a href=&quot;https://www.sparkfun.com/products/9964&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;.  To build your own see &lt;a href=&quot;http://www.arduino-hacks.com/arduino-vu-meter-lm386electret-microphone-condenser/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. It is used as a VU meter which is basically the same idea.  Also, make sure you observe polarity(pin with traces touching metal packaging is negative).&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-04-29T20:00:12.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10437" PostTypeId="2" ParentId="10427" CreationDate="2015-04-30T07:39:27.043" Score="1" Body="&lt;p&gt;You can use Maxim MAX4466 op-amp which works very well with Arduino. There is a breakout available for the same for arduino at Adafruit &lt;a href=&quot;https://www.adafruit.com/products/1063&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. The chip has a select-able gain from 25x-125x. This amplifies works very well to get a nice waveform for audible noise. There are a couple of libraries available for the waveform that you record and can translate it to frequencies. You can also use it to distort or change the voice. Here is a schematic of the circuit if you want to make one yourself.&lt;img src=&quot;https://i.stack.imgur.com/Va3A5.jpg&quot; alt=&quot;enter image description here&quot;&gt; &lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2015-04-30T07:39:27.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10438" PostTypeId="2" ParentId="9715" CreationDate="2015-04-30T07:41:47.737" Score="1" Body="&lt;p&gt;You can use Maxim MAX4466 op-amp which works very well with Arduino. There is a breakout available for the same for arduino at Adafruit &lt;a href=&quot;https://www.adafruit.com/products/1063&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. The chip has a select-able gain from 25x-125x. This amplifies works very well to get a nice waveform for audible noise. There are a couple of libraries available for the waveform that you record and can translate it to frequencies. You can also use it to distort or change the voice. Here is a schematic of the circuit if you want to make one yourself.&lt;img src=&quot;https://i.stack.imgur.com/Va3A5.jpg&quot; alt=&quot;enter image description here&quot;&gt; &lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2015-04-30T07:41:47.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10439" PostTypeId="2" ParentId="10431" CreationDate="2015-04-30T07:54:35.103" Score="2" Body="&lt;p&gt;Arduino compatible means that you would be able to use the boards directly with the Arduino IDE and you can use most of the libraries and examples that come for the official Arduino Boards.&lt;/p&gt;&#xA;&lt;p&gt;The official Arduino boards comes with a standard set of features that are infinitely expandable, but sometimes you have constraints for a project and you need a board that you can easily adapt to a project, the compatible boards come handy in those place. For example, you can use &lt;a href=&quot;http://ardupilot.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ardupilot&lt;/a&gt; to control UAV's and has a lot of sensors on it with a very small form factor but you can still code it with the Arduino IDE, you can use &lt;a href=&quot;http://femto.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Femtoduino&lt;/a&gt; (which is an arduino board the size of a coin) for very small projects.&lt;/p&gt;&#xA;&lt;p&gt;Another simple reason for using the compatible boards is that a lot times they are cheaper than the official Arduino Boards (see &lt;a href=&quot;https://www.sparkfun.com/products/12757&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun Redboard&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;p&gt;You should be able to use any Arduino compatible boards without any problems but it would be better to go with a reputable supplier rather than a supplier in China to ensure that you get a good board that works without any problems.&lt;/p&gt;&#xA;" OwnerUserId="1387" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-04-30T07:54:35.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10440" PostTypeId="1" AcceptedAnswerId="10453" CreationDate="2015-04-30T08:06:29.613" Score="1" ViewCount="2906" Body="&lt;p&gt;Hello I have flashed my Arduino Uno with USB keyboard firmware from this tutorial &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard/#comment-6786&quot; rel=&quot;nofollow&quot;&gt;http://mitchtech.net/arduino-usb-hid-keyboard/#comment-6786&lt;/a&gt;, and I have been successful sending individual key presses but, not when trying to press an hold a key. I am attempting to use this firmware to create a custom Game Pad to USB adapter, the only issue is sending simultaneous keystrokes (not sending them one at a time). If you know how to accomplish this task I would be very happy. The technical term for this is &quot;Key Rollover&quot; &lt;/p&gt;&#xA;" OwnerUserId="8773" LastEditorUserId="8773" LastEditDate="2015-04-30T23:14:18.797" LastActivityDate="2016-05-13T18:56:47.557" Title="How to use an Arduino Uno + Keyboard Firmware to make a &quot;N Key Rollover&quot; Game Pad" Tags="|arduino-uno|usb|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10441" PostTypeId="1" AcceptedAnswerId="10442" CreationDate="2015-04-30T08:59:51.217" Score="0" ViewCount="733" Body="&lt;p&gt;To interact with its &lt;a href=&quot;http://redbearlab.com/bleshield/&quot; rel=&quot;nofollow&quot;&gt;BLE shield&lt;/a&gt;, Redbearlab published sample Android apps in the Play Store. The sources for the apps are available on &lt;a href=&quot;https://github.com/RedBearLab/Android&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt;. How can I build them in Android Studio?&lt;/p&gt;&#xA;" OwnerUserId="8220" LastEditorUserId="8220" LastEditDate="2015-04-30T09:06:41.373" LastActivityDate="2015-04-30T09:34:28.210" Title="Android Studio project for Redbearlab BLE Shield apps" Tags="|shields|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10442" PostTypeId="2" ParentId="10441" CreationDate="2015-04-30T09:34:28.210" Score="0" Body="&lt;p&gt;It was much simpler than expected to put together the Android Studio projects. They are on &lt;a href=&quot;https://github.com/ryklith/RBL_for_Android_Studio&quot; rel=&quot;nofollow&quot;&gt;GitHub now&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the apps built from source are actually different from the ones published by Redbearlabs on the Play Store. On top of that, the chat app is not working.&lt;/p&gt;&#xA;" OwnerUserId="8220" LastActivityDate="2015-04-30T09:34:28.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10443" PostTypeId="2" ParentId="10440" CreationDate="2015-04-30T11:49:05.760" Score="0" Body="&lt;p&gt;You don't want to send random keys do you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well consider using the code below as your base.&#xA;It's using &lt;a href=&quot;http://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot; title=&quot;Port Manipulation&quot;&gt;Port Manipulation&lt;/a&gt; to read the buttons (Digital 0 to 7).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;  Serial.begin(9600);//Start serial connection.&#xA;  DDRD = 0b00000000; //Set Data Direction Register of port D to inputs (attach keys to digital pins 0to7;&#xA;  delay(200); //Misc delay.&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  Serial.write(PIND, 8);    // Send states of PORTD (digital 0 to 7)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I strongly suggest you use pull-down/up resistors on the buttons also.&#xA;Adjust your code to the amount of keys you're using, or pull the pins low if not used. To avoid receiving random/floating pin values.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-04-30T14:54:24.873" LastActivityDate="2015-04-30T14:54:24.873" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10444" PostTypeId="1" AcceptedAnswerId="10447" CreationDate="2015-04-30T12:43:11.153" Score="0" ViewCount="1208" Body="&lt;p&gt;For some strange reason my Arduino UNO clone board occasionally cause my Mac to reset, when I connect the usb cable. Possibly a power problem in Arduino or the USB hub. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to program Arduino UNO with USB/TTL adaptor withouth conncecting the Vcc and GND pins (RX/TX and DTR only.)&lt;/p&gt;&#xA;" OwnerUserId="8687" LastEditorUserId="8687" LastEditDate="2015-05-01T11:08:18.357" LastActivityDate="2015-05-01T11:08:18.357" Title="Is it possible to program Arduino UNO with USB/TTL adapter withouth connection Vcc" Tags="|arduino-uno|programmer|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10445" PostTypeId="2" ParentId="10444" CreationDate="2015-04-30T14:01:56.550" Score="1" Body="&lt;p&gt;If you power the board with an external source of electricity (e.g. a battery), it's possible. But as it can force your Mac to reset, it will possibly damage your battery.&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2015-04-30T14:01:56.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10447" PostTypeId="2" ParentId="10444" CreationDate="2015-04-30T14:51:02.100" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to program Arduino UNO with USB/TTL adaptor without connecting the Vcc and GND pins (RX/TX and DTR only.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.&lt;br&gt;&#xA;As a minimum you need to add ground as well - even if the Mac is battery powered.  Serial port signals are ground referenced so removing the ground would prevent operation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operation is possible without deriving Vcc from the USB port, but you will then need to derive Vcc from some other source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If connecting ground alone causes your Mac to reset you have a serious system problem which may damage your Mac and which possibly may be dangerous to you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Presumably you are NOT using an external power supply for the UNO.&lt;br&gt;&#xA;In case you are: If the power supply for the UNO is AC mains powered it should be connected to the same mains outlet as the Mac. If the programmer powerpack is intended to be grounded but is not powered from a grounded socket AND using a 3 wire mains lead (ie with a ground pin and wire) then it s possible in some cases for the programmer to float at half mains voltage with a high impedance capacitive connection to mains. This is not &lt;strong&gt;usually&lt;/strong&gt; dangerous to people but can cause minor nuisance shocks. It can destroy equipment (ask me how I know :-( .)&lt;br&gt;&#xA;If you have a DMM (digital multimeter) set it to an AC voltage range greater than your local mains voltage and measure the AC voltage from a known ground (such as a water tap in most cases) and the programmer power supply (either wire or jack terminal). If you measure a voltage of about 50VAC with 100 VAC mains or about 115 VAC with 230 VAC mains then the power supply MUST be operated with a 3 wire mains cord and grounded power socket OR a ground lead from mains ground to power supply output ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Mac is battery powered and you have reset problems then something is wrong with connections or signal levels. You may be feeding voltage back onto the USB lines or loading the too heavily or ... ?&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-04-30T14:57:05.500" LastActivityDate="2015-04-30T14:57:05.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10448" PostTypeId="2" ParentId="10431" CreationDate="2015-04-30T15:04:19.700" Score="4" Body="&lt;p&gt;While Arduino is an open source system, &quot;Arduino&quot; is a trademarked name and may only legally be used for products from the Arduino's originators or licensed suppliers. Arduino are quite clear about this requirement - &lt;a href=&quot;http://www.arduino.cc/en/Trademark/CommunityLogo&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;see here - Logo&lt;/strong&gt;&lt;/a&gt; and here &lt;a href=&quot;http://www.arduino.cc/en/Trademark/HomePage?from=Main.Trademark&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Trademark&lt;/strong&gt;&lt;/a&gt; &#xA;and here &lt;a href=&quot;http://www.arduino.cc/en/Main/Policy&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;What makes an Arduino board an Arduino?&lt;/strong&gt;&lt;/a&gt; and &lt;a href=&quot;http://www.arduino.cc/en/Main/FAQ&quot; rel=&quot;nofollow&quot;&gt;FAQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, compatible microcontroller boards are legally required to NOT identify themselves as being &quot;Arduinos&quot;, so the term &quot;Arduino compatible&quot; is about the most that even an Arduino-identical clone can claim.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As karan notes, some Chinese sourced Arduino compatibles &quot;have issues&quot;.&lt;br&gt;&#xA;however, I have had no problems at all with Arduino compatibles manufactured and supplied by &lt;a href=&quot;http://www.aliexpress.com/store/812021/search?SearchText=nano&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;this Chinese supplier&lt;/strong&gt;&lt;/a&gt;. As well as the basic devices they sell various interface boards (shields) and related equipment. Prices are astoundingly low, free postage is included in many cases (about 2 to 3 weeks delivery time to New Zealand) or you can pay for courier delivery. I buy Nano or Pro-Mini compatibles devices  - usually in batches of 10. As you will see -  Nano compatible costs $US3 each in 10's. Pro Mini compatible is currently $US1.68 each in 10's. !!!&lt;br&gt;&#xA;Uno compatible &lt;a href=&quot;http://www.aliexpress.com/store/812021/search?SearchText=arduino&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; is $3.80 in 10s.  The voltage requlator may be a different type than than on 'real' Arduinos (but work OK) and versions with a USB-serial bridge IC use a non FTDI IC and you need to source and load the correct (freely available) drivers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: (1) I have NO commercial connection with this company except as a very happy customer.&lt;br&gt;&#xA;(2) I'd expect you to have no problems with these or other products from them but I of course have  no responsibility for what they sell.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-04-30T15:33:03.837" LastActivityDate="2015-04-30T15:33:03.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10449" PostTypeId="2" ParentId="816" CreationDate="2015-04-30T16:20:04.423" Score="9" Body="&lt;p&gt;As mentioned in several answers, if you are programing an embedded system in general you should avoid &lt;strong&gt;new&lt;/strong&gt; unless you are managing your own memory heap and you really know what your object life cycles will be. Static allocation or stack variables are much safer. That said, one common trick to manage things like variable length buffers allocated for the duration of a function is to have an automatic variable (on the stack) that is an object that calls &lt;strong&gt;new&lt;/strong&gt; in its constructor, and then put the &lt;strong&gt;delete&lt;/strong&gt; in the destructor so when the object goes out of scope the buffer is released back to the heap. Again, this is usually of limited use in little micros but it is a nice pattern to remember.&lt;/p&gt;&#xA;" OwnerUserId="7978" LastActivityDate="2015-04-30T16:20:04.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10450" PostTypeId="1" CreationDate="2015-04-30T18:59:26.383" Score="2" ViewCount="894" Body="&lt;p&gt;I am trying to communicate between two Arduino UNO. One has a HC-05 which is configured as master, the other Arduino has HC-06 which is the slave. What I want to achieve is to be able to print a character on the Serial monitor of the slave Arduino when a button on the master Arduino is pressed. I have been able to pair the two and once they are powered, they connect automatically. When I press a button on the master, what I get on the serial monitor of the slave is the 254 instead of the character 'a' which is what I am sending from the master. I have tried changing the data type, and also switched the code for master and slave, but the problem persists. I have also used hardware serial instead of software serial. My HC-05, and HC-06 works well when paired with android phone and can send and receive useful data. My code is as shown below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE FOR MASTER:(SENDER)&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;const int rxPin = 10;&#xA;const int txPin = 11;&#xA;const int button = 2;&#xA;&#xA;SoftwareSerial masterSerial(rxPin,txPin);//RX,TX.&#xA;&#xA;void setup() {&#xA;   pinMode(button, INPUT);&#xA;   Serial.begin(9600);&#xA;   masterSerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;   int buttonVal = digitalRead(button);&#xA;   if(buttonVal==HIGH){&#xA;       masterSerial.write('a');&#xA;      delay(1000);&#xA;   }&#xA;//mySerial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;CODE FOR SLAVE( RECEIVER)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int rxPin = 10;&#xA;const int txPin = 11;&#xA;&#xA;int incomingByte = 0;&#xA;&#xA;SoftwareSerial slaveSerial(rxPin,txPin);//RX,TX.&#xA;&#xA;void setup() {&#xA;&#xA;   pinMode(13, OUTPUT);&#xA;   Serial.begin(9600);&#xA;   slaveSerial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;   while(slaveSerial.available()){&#xA;      incomingByte = slaveSerial.read();&#xA;      delay(3);&#xA;      Serial.println(incomingByte);  &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8776" LastEditorUserId="37523" LastEditDate="2019-08-24T17:55:49.647" LastActivityDate="2019-08-24T17:55:49.647" Title="HC-05 and HC-06 Bluetooth not communicating well" Tags="|bluetooth|softwareserial|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="10451" PostTypeId="1" AcceptedAnswerId="10452" CreationDate="2015-04-30T22:41:10.633" Score="0" ViewCount="67" Body="&lt;p&gt;I would like to make a custom ethernet card that uses the enc28j60 like this:&#xA;&lt;a href=&quot;http://www.picprojects.net/enc28j60_modul/index.html&quot; rel=&quot;nofollow&quot;&gt;DIY Ethernet card&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but first I would like to know if I can use the standard libraries which can be used with the ethernet card which is in the market like this:&#xA;&lt;a href=&quot;http://www.ebay.co.uk/sch/i.html?_from=R40&amp;amp;_trksid=p2047675.m570.l1313.TR0.TRC0.H0.XENC28J60%20module.TRS0&amp;amp;_nkw=ENC28J60%20module&amp;amp;_sacat=0&quot; rel=&quot;nofollow&quot;&gt;ENC28J60 ethernet module&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-04-30T23:01:34.373" Title="Can I use custom ethernet shield with standard libraries?" Tags="|library|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10452" PostTypeId="2" ParentId="10451" CreationDate="2015-04-30T23:01:34.373" Score="1" Body="&lt;p&gt;The libraries don't care whether or not you're using a shield, only that you're using a device they support and that you've wired it up how they expect (or that you've modified the library to use the actual wiring you're using). So find a library that supports the ENC28J60 and knock yourself out.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-04-30T23:01:34.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10453" PostTypeId="2" ParentId="10440" CreationDate="2015-04-30T23:59:49.250" Score="0" Body="&lt;p&gt;After closer research on this topic I have found the answer to my problem but,thank you to all that have tried to help. In order to do &quot;Key Rollover&quot; I needed to write the additional key states to the remaining values of the buffer array then write the values with Serial.write(buf,8). I can now use my Arduino Uno + My Game Pads as controllers for all my computer games. &lt;/p&gt;&#xA;" OwnerUserId="8773" LastActivityDate="2015-04-30T23:59:49.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10455" PostTypeId="2" ParentId="10444" CreationDate="2015-05-01T01:31:10.420" Score="1" Body="&lt;p&gt;It's possible the reboot isn't a hardware issue, short circuiting, but some kind of operating system issue such as a faulty driver, or conflicts... Best to have a look at the Console after a reboot to see if there are any notes here, or try the same Arduino on another Mac or PC.&lt;/p&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-05-01T01:31:10.420" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10456" PostTypeId="2" ParentId="10444" CreationDate="2015-05-01T02:02:02.890" Score="1" Body="&lt;p&gt;It is a bit of work, but it is possible to use a couple of optoisolators to &lt;A href=&quot;http://www.nerdkits.com/forum/thread/2040/&quot; rel=&quot;nofollow noreferrer&quot;&gt;build a circuit that will electrically isolate the MCU from the serial adapter&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3fGYZ.jpg&quot; alt=&quot;optoisolator circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should still figure out why your computer resets though, as it may not be related to the Arduino at all (e.g. maybe the cable is bad).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-01T02:02:02.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10457" PostTypeId="1" AcceptedAnswerId="10463" CreationDate="2015-05-01T02:24:11.193" Score="1" ViewCount="313" Body="&lt;p&gt;Is there any way so an ethernet shield to ask the router for an available ip address? For example to ask for an ip an the router to return 192.168.1.2 if it is available. I am asking it because if we set the ip programmatically and it is attached to another device we gonna have problem. &lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-01T10:11:42.777" Title="Ask for available ip on ethernet shield" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10458" PostTypeId="1" AcceptedAnswerId="20081" CreationDate="2015-05-01T02:39:48.267" Score="5" ViewCount="3112" Body="&lt;p&gt;I am looking specifically to connect to a CDMA carrier from an Arduino. In doing research, I came across a CDMA shield option (requires getting a &lt;a href=&quot;https://www.nimbelink.com/2g-cdma-1xrtt/&quot; rel=&quot;noreferrer&quot;&gt;CDMA module&lt;/a&gt; that you drop &lt;a href=&quot;https://www.nimbelink.com/skywire-arduino-cellular-shield/&quot; rel=&quot;noreferrer&quot;&gt;into a shield&lt;/a&gt;), but that ends up being quite expensive - the CDMA module alone is $140, as opposed to a GSM shield which runs $30-$60. I've also tried looking for other CDMA modules, but haven't been able to find much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if it's not sold as a proper Arduino shield, does anyone know of a CDMA module for hobby projects?&lt;/p&gt;&#xA;" OwnerUserId="8782" LastActivityDate="2016-06-23T21:08:52.033" Title="What options are available for connecting to a CDMA network?" Tags="|shields|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10459" PostTypeId="2" ParentId="5264" CreationDate="2015-05-01T05:09:02.690" Score="1" Body="&lt;p&gt;As a fundamental principle of design you should not be expecting to receive multiple characters in the ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interrupt fires when &lt;em&gt;a character&lt;/em&gt; has been received, so that is all your program should count on finding.  You can if you really want to &lt;em&gt;poll&lt;/em&gt; the UART when you are done reading the first character and see if another has arrived, but there would generally not be time for that to have happened &lt;strong&gt;and you definitely should not be &lt;em&gt;waiting&lt;/em&gt; for it in the ISR&lt;/strong&gt;.  Rather, if the ultimate consuming code needs multiple characters, then &lt;em&gt;that&lt;/em&gt; should hold off executing dependent code until multiple invocations of the ISR have resulted in the collection of the needed number of characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things can get a little more complicated on parts with multi-stage UART FIFOs, but that is not the case here.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-01T05:09:02.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10460" PostTypeId="1" CreationDate="2015-05-01T05:46:41.647" Score="2" ViewCount="83" Body="&lt;p&gt;I would like to augment a live music performance by displaying an specific LED for any given musical note.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For vocals:&lt;/strong&gt;&#xA;Rather than attempt to process the audio using the Arduino board, I'd like to use something like an auto-tune box to do the heavy lifting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For digital instruments:&lt;/strong&gt; Would like to drive the Arduino board with some kind of digital signal (for example midi)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having trouble finding out which (if any) consumer audio device can provide the pre-processing. Are there any comparable projects or insights?&lt;/p&gt;&#xA;" OwnerUserId="8784" LastActivityDate="2015-05-01T08:45:39.420" Title="Converting live vocals to discrete signals" Tags="|audio|midi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10461" PostTypeId="2" ParentId="816" CreationDate="2015-05-01T06:42:25.130" Score="8" Body="&lt;p&gt;In addition to the comments above, I would like to further stress the problems with working RAM that you have on Arduino boards, particularly with the Uno (and others that share the same microcontroller).  I recently wrote a simple Space Invaders game running on a 32x32 LED matrix and repeatedly ran into problems caused by low memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno only has 2048 bytes of RAM.  The library for my matrix took over 3/4 of that leaving me with around 400 bytes for the game.  As it is my intention to &quot;upgrade&quot; the project at some point to run multiple games with the same program base on the more powerful Due, I designed the code with OO principals and a lot of class inheritance.  (The game class was inherited with virtual update and draw calls, the game entities were all inherited).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pretty much ran out of memory just adding the invaders.  I tried to save memory by bit-fielding their member variables but ran out again when adding the shield objects.  After a bit more scraping I ran out adding the bombs/bullets.  At this point I scoured the code and removed all &quot;virtual&quot; tags (all my class prototypes are built from a Visual Assist snippet and destructors are all virtual automatically).  This halved my memory usage instantly, freeing enough to be able to complete the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long story short, the end result is C++ code that doesn't really use any C++ features.  You might be as well just sticking to C and being very aware of your memory usage.  You get no help if you exceed the 2KB - particularly if you are using any dynamic allocation, the code just stops working and you are left scratching your head for a while until you consider the possibility of memory overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS - Bit fielding variables is bad.  Very bad.  Apart from adding processing overhead, I lost track of the number of times I'd add a new state to the game but the code wouldn't run and I couldn't understand why.  My state variable was not wide enough to hold the new state value so I was getting some unexpected state.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="8616" LastEditDate="2017-04-12T12:41:07.473" LastActivityDate="2017-04-12T12:41:07.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10462" PostTypeId="1" CreationDate="2015-05-01T07:57:04.400" Score="-1" ViewCount="1408" Body="&lt;p&gt;I am trying to connect my arduino uno to GSM 900A with the help of this tutorial &lt;a href=&quot;https://elementztechblog.wordpress.com/2014/10/10/interfacing-sim900a-gsm-modem-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;https://elementztechblog.wordpress.com/2014/10/10/interfacing-sim900a-gsm-modem-with-arduino/&lt;/a&gt;&#xA;but the calling is not being carried out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial output is as following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Calling through GSM Modem&#xA;Called &#xA;ÿÿÿÿ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the code is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup()&#xA;&#xA;{&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Calling through GSM Modem&quot;);&#xA;&#xA;  mySerial.begin(9600);&#xA;  delay(2000);&#xA;  mySerial.println(&quot;ATD99abc19965;&quot;); &#xA;  mySerial.println(&quot;ATH&quot;);&#xA;  Serial.println(&quot;Called &quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  if (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8787" LastEditorUserId="8782" LastEditDate="2015-05-02T00:49:29.163" LastActivityDate="2015-07-01T01:46:51.183" Title="connecting GSM 900A module to arduino" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10463" PostTypeId="2" ParentId="10457" CreationDate="2015-05-01T08:27:37.183" Score="0" Body="&lt;p&gt;Using the &lt;a href=&quot;http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol&quot; rel=&quot;nofollow&quot;&gt;DHCP (Dynamic Host Configuration Protocol)&lt;/a&gt; you can obtain an IP address dynamically from a DHCP server (which a router usually also is), without having to hardcode it into the firmware of the Arduino, thus enabling it to work on different networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a library for that: &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/DhcpAddressPrinter&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/DhcpAddressPrinter&lt;/a&gt;. It's an extension of the official Arduino Ethernet library, written for the Arduino Ethernet Shield, but you'll likely find implementations of DHCP in many Ethernet libraries (I am using the &lt;a href=&quot;https://github.com/jcw/ethercard&quot; rel=&quot;nofollow&quot;&gt;EtherCard library&lt;/a&gt;) because it's an important feature to be able to connect to a network without a statically assigned IP and &quot;only&quot; requires UDP (on top of IP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For e.g. the Ethernet library you call the &lt;a href=&quot;http://www.arduino.cc/en/Reference/EthernetBegin&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;begin&lt;/code&gt; function&lt;/a&gt; either with only the MAC address of your device or with MAC and IP address: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ethernet.begin(mac);&#xA;Ethernet.begin(mac, ip); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the first case it will use DHCP to obtain an IP address dynamically, in the second case it will use the static IP address you provide. Be warned that the second case, due to the needed implementation of DHCP, will increase the size of the compiled binary significantly. &lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-05-01T10:11:42.777" LastActivityDate="2015-05-01T10:11:42.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10464" PostTypeId="2" ParentId="10460" CreationDate="2015-05-01T08:38:25.943" Score="1" Body="&lt;p&gt;Confusing question. You list vocals and Digital Instruments, then you ask which audio device provided pre-processing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are the auto tunes boxes you mentioned. Since you know about them I don't see how you would be asking about them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A digital instrument might output midi, and midi is just a simple serial protocol, so there is no device needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is your question actually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An auto-tune box does work that would be best suited to a laptop or desktop computer. It first must determine the intended pitch than apply a formant filter to shift the incoming signal to a correct pitch. It requires the use of heavy fast math, Fast Fourier Transforms, FFT.  The smaller boxes you see doing this are actually specialized computers. Do not confuse their size with their power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google 'digital tuner software' to get an idea of what goes on.  I do not know of a device that specifically output the 'corrected' midi for an auto-tune, but at that point it would be fairly trivial so it would not surprise me if many did it.  For sure the many guitar to Midi converts do just that, but a good one is several thousand dollars.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-01T08:45:39.420" LastActivityDate="2015-05-01T08:45:39.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10465" PostTypeId="2" ParentId="5264" CreationDate="2015-05-01T08:58:47.377" Score="2" Body="&lt;p&gt;First of all, you shouldn't share a &lt;em&gt;simple&lt;/em&gt; variable between ISRs and the main loop: &lt;code&gt;unsigned char uart_string[20];&lt;/code&gt; should be &lt;code&gt;volatile unsigned char uart_string[20];&lt;/code&gt;. Moreover, you must define it out of any scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, using possibly blocking loop in an ISR is strongly not recommended. In fact, whenever your microcontroller enter an ISR, everything else is stopped: thus, an ISR should last as short as possible. Plus, the &lt;code&gt;USART_RX_vect&lt;/code&gt; triggers whenever a &lt;em&gt;single&lt;/em&gt; character is received: this means that you'll have to wait for the next one. Thus, you mustn't use ISR like that: I would just use a global volatile variable to monitor the amount of received characters. Then, in the main loop, I would analyze the input characters whenever this counter is greater or equal than 2&#xA;.&#xA;Finally, in your ISR, you try to read four input characters: '/0' is only one character, in the ASCII table it's called NULL, so you should only read up to three characters.&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2015-05-01T08:58:47.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10466" PostTypeId="2" ParentId="10403" CreationDate="2015-05-01T09:17:35.620" Score="0" Body="&lt;p&gt;It depends on the number of channels you need, but you could go to HobbyKing, they offer RC remotes for down to 20$&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2015-05-01T09:17:35.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10467" PostTypeId="2" ParentId="5264" CreationDate="2015-05-01T09:42:43.067" Score="0" Body="&lt;p&gt;I would suggest using code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Above your program, global variable.&#xA;char uartRXbuffer[100];//Adjust size!&#xA;int  uartRXbufferIndex = 0;&#xA;//bool uartRXmessage = false;&#xA;&#xA;ISR(USART_RXC_vect){&#xA;   uartRXbuffer[uartRXbufferIndex++] = UDR;//read UART register into buffer. And increase index by 1.&#xA;   if(uartRXbufferIndex &amp;gt; sizeof(uartRXbuffer){&#xA;      //uartRXmessage = true;&#xA;      uartRXbufferIndex = 0;&#xA;   }//else if(uartRXbuffer[uartRXbufferIndex-1] == &quot;\n&quot;){&#xA;   //   uartRXmessage = true;&#xA;   //}&#xA;}&#xA;&#xA;void loop(){&#xA;   HandleBuffer();&#xA;}&#xA;&#xA;void HandleBuffer(){&#xA;   //Do something with your buffer values.&#xA;   //if(uartRXmessage){&#xA;      if(strstr(uartRXbuffer,&quot;Command1&quot;)){&#xA;        //Code for when &quot;Command1&quot; is found in your buffer.  &#xA;      }&#xA;   //}&#xA;//uartRXmessage = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I havent tested this code, but the idea is correct I believe.&#xA;You can un-comment the uartRXmessage stuff if you only want to handle the buffer when there is an end-of-line character or when the buffer is full.&#xA;Alternatively you can implement a ring buffer.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-05-01T09:51:16.987" LastActivityDate="2015-05-01T09:51:16.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10468" PostTypeId="2" ParentId="10462" CreationDate="2015-05-01T10:00:05.720" Score="1" Body="&lt;p&gt;You're really missing multiple parts here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out this tutorial: &lt;a href=&quot;http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/&quot; rel=&quot;nofollow&quot;&gt;http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First of all, did you power up the SIM900A using its PWRKEY pin?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And can you send and receive AT commands?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How do you know that you have a valid GSM connection?&#xA;Did you try &lt;code&gt;AT+CREG?&lt;/code&gt; and &lt;code&gt;AT+CPIN?&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do you understand the AT commands you send?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You send &lt;code&gt;ATD&lt;/code&gt; (with &lt;code&gt;abc&lt;/code&gt; in the number?) and after that you &lt;em&gt;immediately&lt;/em&gt; send ATH. Thus you would hang up directly after calling, and probably wouldn't even get to the actual calling part.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial sim900Serial(10, 11); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   Serial.println(&quot;Calling through GSM Modem&quot;);&#xA;   sim900Serial.begin(9600);&#xA;   delay(2000);&#xA;   sim900Serial.println(&quot;ATD99abc19965;&quot;);&#xA;   delay(10000);&#xA;   sim900Serial.println(&quot;ATH&quot;);&#xA;   Serial.println(&quot;Call ended &quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   if (mySerial.available()){&#xA;      Serial.write(mySerial.read());&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, your code isn't very well formatted. Compare the code above with yours.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-05-01T11:49:23.237" LastActivityDate="2015-05-01T11:49:23.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10470" PostTypeId="1" CreationDate="2015-05-01T12:59:53.413" Score="0" ViewCount="9297" Body="&lt;p&gt;I have a L298 motor driver, which I coded with an Arduino Nano. &#xA;The code is very simple at the moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// connect motor controller pins to Arduino digital pins&#xA;// motor one&#xA;int enA = 10;&#xA;int in1 = 9;&#xA;int in2 = 8;&#xA;// motor two&#xA;int enB = 5;&#xA;int in3 = 7;&#xA;int in4 = 6;&#xA;void setup()&#xA;{&#xA;  // set all the motor control pins to outputs&#xA;  pinMode(enA, OUTPUT);&#xA;  pinMode(enB, OUTPUT);&#xA;  pinMode(in1, OUTPUT);&#xA;  pinMode(in2, OUTPUT);&#xA;  pinMode(in3, OUTPUT);&#xA;  pinMode(in4, OUTPUT);&#xA;}&#xA;&#xA;void demoTwo()&#xA;{&#xA;  // this function will run the motors across the range of possible speeds&#xA;  // note that maximum speed is determined by the motor itself and the operating voltage&#xA;  // the PWM values sent by analogWrite() are fractions of the maximum speed possible &#xA;  // by your hardware&#xA;  // turn on motors&#xA;  Motors_FWD_PWM_Initialize();&#xA;&#xA;  // accelerate from zero to maximum speed&#xA;  for (int i = 0; i &amp;lt; 256; i++)&#xA;  {&#xA;    analogWrite(enA, i);&#xA;    analogWrite(enB, i);&#xA;    delay(20);&#xA;  } &#xA;  // decelerate from maximum speed to zero&#xA;  for (int i = 255; i &amp;gt;= 0; --i)&#xA;  {&#xA;    analogWrite(enA, i);&#xA;    analogWrite(enB, i);&#xA;    delay(20);&#xA;  } &#xA;  // now turn off motors&#xA;  MotorsOff();&#xA;}&#xA;void loop()&#xA;{&#xA;  demoTwo();&#xA;  delay(1000);&#xA;}&#xA;&#xA;void Motors_FWD_PWM_Initialize()&#xA;{&#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, LOW);  &#xA;  digitalWrite(in3, HIGH);&#xA;  digitalWrite(in4, LOW);  &#xA;}&#xA;&#xA;void MotorsOff()&#xA;{&#xA;  digitalWrite(in1, LOW);&#xA;  digitalWrite(in2, LOW);  &#xA;  digitalWrite(in3, LOW);&#xA;  digitalWrite(in4, LOW);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q1:&lt;/strong&gt; I have an ultrasonic sensor, how can I write the code so that the motors work and 'keep an eye out' with the ultrasonic sensor simultaneously? i.e. When a certain proximity is reached I would like the robot to stop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q2:&lt;/strong&gt; Also I would like my robot to 'rove' around. How can I make it so? I was thinking having a number of subroutines, and making the arduino randomly choose one.&lt;/p&gt;&#xA;" OwnerUserId="8060" LastActivityDate="2017-12-14T22:06:00.540" Title="How to drive motors and use an ultrasonic sensor simultaneously?" Tags="|sensors|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10472" PostTypeId="1" CreationDate="2015-05-01T15:17:21.490" Score="2" ViewCount="12696" Body="&lt;p&gt;I acquired a HC-06 Bluetooth module, and understand that the voltage on the pins must be 3v3 and therefore requires the use of a voltage divider to lower the Arduino's 5v to 3v3 &lt;a href=&quot;http://cdn.instructables.com/FFM/2LM8/HHS9W6IV/FFM2LM8HHS9W6IV.LARGE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OnBrt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OnBrt.jpg&quot; alt=&quot;wiring diagram with 3V3 pullups&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the page where I purchased the product says the following:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;interface level 3.3V, you can directly connect a variety of SCM (51, AVR, PIC, ARM, MSP430, etc.), 5V microcontroller can also be directly  connected, it can not pass without MAX232 MAX232!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does this mean I can connect without using a voltage divider?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does &quot;it can not pass without MAX232 MAX232!&quot; mean?&lt;/p&gt;&#xA;" OwnerUserId="8791" LastEditorUserId="3917" LastEditDate="2015-11-29T20:47:12.853" LastActivityDate="2015-11-29T20:47:12.853" Title="HC-06 Bluetooth RX &amp; TX voltage (3v3 || 5v)" Tags="|arduino-uno|serial|bluetooth|voltage-level|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10473" PostTypeId="1" CreationDate="2015-05-01T15:50:10.553" Score="0" ViewCount="539" Body="&lt;p&gt;Is it possible to change serial information of arduinos board ? &#xA;For example I have an arduino uno with this serial informations : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ &#xA;      comName: '/dev/cu.usbmodem1411',&#xA;      manufacturer: 'Arduino (www.arduino.cc)',&#xA;      serialNumber: '75430333137351804230',&#xA;      pnpId: '',&#xA;      locationId: '0x14100000',&#xA;      vendorId: '0x2341',&#xA;      productId: '0x0043' &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to modify for example the manufacturer to be able to automatically detect the device whatever the comName is. I don't want to detect arduino board I want to detect arduino board modify by me without make a serial connection.&lt;/p&gt;&#xA;" OwnerUserId="8792" LastActivityDate="2015-05-01T16:18:15.950" Title="Arduino serial informations" Tags="|arduino-uno|serial|sketch|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10474" PostTypeId="2" ParentId="10473" CreationDate="2015-05-01T16:18:15.950" Score="1" Body="&lt;p&gt;Once you have &lt;a href=&quot;http://www.usb.org/developers/vendor/&quot; rel=&quot;nofollow&quot;&gt;purchased a USB vendor ID&lt;/a&gt; you can edit the firmware within the Arduino installation at &lt;code&gt;hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial/&lt;/code&gt; with your vendor ID, chosen product ID, and other USB parameters as you wish and then rebuild the firmware and upload it to the ATmega16U2 on the board via ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not wish to purchase a vendor ID for the time being then you can use 0x6666, the prototype vendor ID, in the meantime, but you are not allowed to make products using that vendor ID available to the public.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-01T16:18:15.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10475" PostTypeId="2" ParentId="10403" CreationDate="2015-05-01T16:32:25.863" Score="0" Body="&lt;p&gt;If you want to involve an Arduino on the receiver, you may want to choose a transmitter which is compatible with a 2.4 GHz chipset that is both available, and for which you can find Arduino code.  The NRF24L01+ and Beken compatibles are probably the most available, and a lot of RC toys use something compatible, though getting firmware right to interact with them can be tricky.  Beware that there are some other chips in wide use too, which can be harder to source a module for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use an off-the-shelf multi-channel receiver, but that will tend to output each channel on a distinct PWM pin, which is annoying if you want to capture the data into an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to spend some time looking on rcgroups and in various hobby drone sites - the latter folks have a similar problem, as they want to collect all the control channels and mediate them through a custom flight computer (which in the early days was sometimes Arduino-compatible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also make your own transmitter - perhaps by retrofitting an NRF24L01+ module and miniature Arduino equivalent into the casing of an older 5/72/75 MHz set - or the IR transmitter from a toy helicopter.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-01T16:32:25.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10477" PostTypeId="2" ParentId="10376" CreationDate="2015-05-01T18:00:55.417" Score="1" Body="&lt;p&gt;I would mount the components to the board first then create busses with wire. Depending on the components you might be able to use the same row the component leads are in or you may need to lay the bus in the adjacent row and bridge the gap with component leads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick search turned up an image that sort of gives an idea of what I'm talking about. If you look closely you can see the wire bridging the gap between each solder pad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.bing.com/images/search?q=soldering+protoboard+bus+wiring&amp;amp;view=detailv2&amp;amp;&amp;amp;&amp;amp;id=EF1514CA6486FC44E0132E7DE1CFBFDBFD015809&amp;amp;selectedIndex=15&amp;amp;ccid=vQ%2beHllm&amp;amp;simid=608022938507020230&amp;amp;thid=JN.TBpqHtXSA7o3dTvD8dPVaQ&amp;amp;ajaxhist=0&quot; rel=&quot;nofollow&quot;&gt;https://www.bing.com/images/search?q=soldering+protoboard+bus+wiring&amp;amp;view=detailv2&amp;amp;&amp;amp;&amp;amp;id=EF1514CA6486FC44E0132E7DE1CFBFDBFD015809&amp;amp;selectedIndex=15&amp;amp;ccid=vQ%2beHllm&amp;amp;simid=608022938507020230&amp;amp;thid=JN.TBpqHtXSA7o3dTvD8dPVaQ&amp;amp;ajaxhist=0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-05-01T18:00:55.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10478" PostTypeId="1" CreationDate="2015-05-01T18:11:19.047" Score="0" ViewCount="4702" Body="&lt;p&gt;I try to make this Arduino Open CV tutorial for webcams. OpenCV 3.0 RC1 is compiled and installed. I also use Code::Blocks 13.12 as IDE. I am a newbie what comes to OpenCV and I do not know too much about Arduino either but here I am learning. Arduino IDE is 1.7.2. The tutorial is made for Windows 7 and software for this OS but I bet it is possible to repeat this in Ubuntu Linux 14.04 also. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the tutorial is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://duino4projects.com/face-detection-and-tracking-with-arduino-and-opencv/&quot; rel=&quot;nofollow&quot;&gt;http://duino4projects.com/face-detection-and-tracking-with-arduino-and-opencv/&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to compile and run the techbitarFaceDetection.cpp &lt;/p&gt;&#xA;&#xA;&lt;p&gt;the Code::Block IDE gives me following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fatal error: Tserial.h: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So please tell me what to do next and how to fix this error. &lt;/p&gt;&#xA;" OwnerUserId="8799" LastEditorUserId="8799" LastEditDate="2015-05-01T18:18:29.093" LastActivityDate="2015-10-20T20:36:39.607" Title="WebCam Face detection and tracking tutorial with Arduino Uno R3 and OpenCV 3.0 RC1 in Ubuntu 14.04" Tags="|arduino-uno|programming|compile|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10479" PostTypeId="2" ParentId="10472" CreationDate="2015-05-01T18:39:45.440" Score="1" Body="&lt;p&gt;Some chips that run on 3.3v have 5v tolerant inputs. But it doesn't look like the BC417 does (looking at the datasheet). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So just add the voltage divider.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-01T18:39:45.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10480" PostTypeId="2" ParentId="10470" CreationDate="2015-05-01T22:26:52.087" Score="1" Body="&lt;p&gt;For the first question, you could simply implement an &lt;strong&gt;interrupt routine&lt;/strong&gt; to regularly check the status of your sensor and when it achieves the desired threshold it triggers the action to stop the motor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve this by setting timer1. There is a library &lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for example, where you set the period to execute a desired function, when some distance is detected you just stop the motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second question could be done exactly like you said. Say you have some paths saved in memory, you can just create some options for them and execute whenever you want using switch/case command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/code/timer1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-01T22:26:52.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10483" PostTypeId="1" AcceptedAnswerId="10487" CreationDate="2015-05-02T08:07:40.360" Score="0" ViewCount="1844" Body="&lt;p&gt;I have built the following to dim the brightness of the LED backlight of a display:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/T3KtX.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;I am using a BS170 MOSFET (the diode is no extra part but included in the MOSFET, according to the &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/BS/BS170.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;). The BL pin is the supply of the LED backlight. (I have left out all other pins.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it does not work. Even if I set the PWM pin to 255, the backlight does not light (actually it's completely off). If I short BL and Vcc, it lights up as it should. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the voltage readings confuse me: I measure 3.3 V on the gate and drain against ground, 1.5 V on source against ground (= the voltage across the backlight) but only 1 V if I measure drain against source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Shouldn't this add up to 3.3 V?&lt;/li&gt;&#xA;&lt;li&gt;More importantly, why do I get only 1.5 V at BL?&lt;/li&gt;&#xA;&lt;li&gt;Most importantly, what do I need to change? Different MOSFET? No MOSFET?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The primary aim of controlling the backlight is to be able to switch in off completely, thus reducing power consumption. (Being able to dim it is only a plus.)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I should have added details about the display. It's one of those:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/dP3Uh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't found a datasheet / specs for exactly this model. Most datasheets I found refer to a different version that is not 5 V compatible. A very similar model is described &lt;a href=&quot;http://skpang.co.uk/catalog/images/lcd/graphic/docs/User_Manual_ET_LCD5110.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning my question I haven't found information on how much current the backlight would draw. Therefore I didn't want to drive it directly from the PWM pin. (Actually I could just measure it...)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-05-02T12:46:36.247" LastActivityDate="2015-05-02T13:59:41.867" Title="MOSFET to dim LED backlight" Tags="|power|led|pins|pwm|mosfet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10484" PostTypeId="1" CreationDate="2015-05-02T09:43:04.937" Score="0" ViewCount="772" Body="&lt;p&gt;I'm new to the world of Arduino &amp;amp; PI, so far it's been a fantastic experience but I'm now looking to build something a bit more practical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan is for the PI to host a JSP Servlet website.  I'd like to go to a certain page of this site: 'powerCycleDevice' for example where it would pass a parameter in '?=on' or something similar.  This would then be picked up by the Arduino which in turn would then power said device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also be nice to just use it as a monitoring station.  If I have several Arduinos hooked up (and I plan to - think Wallace &amp;amp; Gromit :)) then it'd be nice to view the statistics of each of the sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is not knowing if a: it's possible (I'm certain it is) and b: where to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone can lend any advice, hints or tips on where to get started it would be fantastic.  A noob guide or tutorial would be great as I'd then use the info and expand upon it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.  &lt;/p&gt;&#xA;" OwnerUserId="8423" LastActivityDate="2015-05-08T10:00:48.737" Title="Control external device using Java Web Servlet -&gt; Pi -&gt; Arduino -&gt; Device" Tags="|arduino-uno|serial|web-server|home-automation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10485" PostTypeId="1" AcceptedAnswerId="10506" CreationDate="2015-05-02T09:48:05.750" Score="1" ViewCount="126" Body="&lt;p&gt;I'm writing software for a laser tag gun, which under the system we use needs the output waveform to be a carrier wave of 57600Hz with a signal wave of 1800HZ for about 50ms&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the Tone library (&lt;a href=&quot;https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation&lt;/a&gt;) and a transistor AND gate, I've had this working using two timers, however I really want to shrink it down to one timer so that I can use the other for sound (using the TMRPCM library which only needs timer1). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified the Tone library cut down to what I need, with the following methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void TagTone::beginPulse(uint8_t tonePin)&#xA;{&#xA;    _pin = tonePin;&#xA;    _timer = 2;&#xA;&#xA;    // 8 bit timer&#xA;    TCCR2A = 0;&#xA;    TCCR2B = 0;&#xA;    bitWrite(TCCR2A, WGM21, 1);&#xA;    bitWrite(TCCR2B, CS20, 1);&#xA;    timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));&#xA;    timer2_pin_mask = digitalPinToBitMask(_pin);&#xA;&#xA;    int duration = 50; //50 milliseconds&#xA;    uint8_t prescalarbits = 0b001;&#xA;    int32_t signal_toggle_count = 0;&#xA;&#xA;&#xA;    // Note: may need prescaler reimplemented if using 16Mhz, fine on current 8Mhz&#xA;    ocr = F_CPU / (CARRIER_FREQUENCY * 2) - 1;&#xA;    prescalarbits = 0b001;  &#xA;&#xA;&#xA;    TCCR2B = (TCCR2B &amp;amp; 0b11111000) | prescalarbits;&#xA;&#xA;    toggle_count = 2 * CARRIER_FREQUENCY * duration / 1000; // how many times the carrier toggles before pulse ends&#xA;&#xA;    // want to AND with 1800 Hz signal&#xA;&#xA;    // as duration now set to 50: toggle_count for carrier = 5760&#xA;    // equivalent toggle count for signal = 180&#xA;    signal_toggle_count = 2* SIGNAL_FREQUENCY * duration / 1000;&#xA;&#xA;    // want to flip signal state every 32 carrier pulses&#xA;    signal_cycle_count = 32; //toggle_count / signal_toggle_count;&#xA;}&#xA;&#xA;&#xA;&#xA;// duration (in milliseconds).&#xA;&#xA;void TagTone::playPulse()&#xA;{&#xA;&#xA;    OCR2A = ocr;&#xA;    timer2_signal_toggle_count = signal_cycle_count;&#xA;    timer2_toggle_count = toggle_count;&#xA;    bitWrite(TIMSK2, OCIE2A, 1);&#xA;&#xA;}&#xA;&#xA;&#xA;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;    if(timer2_toggle_count  &amp;lt; 0)&#xA;    {&#xA;        *timer2_pin_port ^= timer2_pin_mask &amp;amp; signal_state; // flip&#xA;&#xA;        if (timer2_signal_toggle_count &amp;gt; 0)&#xA;        {&#xA;          timer2_signal_toggle_count--;&#xA;        }&#xA;        else&#xA;        {&#xA;            signal_state ^= signal_state;&#xA;            timer2_toggle_count -= timer2_signal_toggle_count;&#xA;            timer2_signal_toggle_count = signal_cycle_count;&#xA;        }&#xA;    }&#xA;    else&#xA;    {&#xA;        TIMSK2 &amp;amp;= ~(1 &amp;lt;&amp;lt; OCIE2A);                 // disable the interrupt&#xA;        *timer2_pin_port &amp;amp;= ~(timer2_pin_mask);   // keep pin low after stop&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I hope this is doing is 32 toggles at the carrier speed (ie 16 full cycles of 57600Hz), followed by 32 'silent' toggles where nothing happens, followed by another 32 at carrier speed, etc.  I should then be able to fire using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(signalPin, HIGH);&#xA;carrierTone.playPulse();&#xA;delay(60);&#xA;digitalWrite(signalPin, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that doesn't set off the sensor, whereas the simple code below works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;carrierTone.play(57600, 50);&#xA;signalTone.play(1800, 50);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8806" LastActivityDate="2015-05-03T12:22:48.237" Title="Making a composite waveform using a single TIMER interrupt" Tags="|interrupt|signal-processing|isr|frequency|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10486" PostTypeId="2" ParentId="10478" CreationDate="2015-05-02T10:32:47.147" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.tetraedre.com/advanced/serial/tserial.h&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;TSerial.h&lt;/code&gt;&lt;/a&gt; is part of the Serial C++ Library that is used by the project that you are trying to build (see the section &quot;Software Required&quot; on the tutorial page you linked).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you have that library installed correctly.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-02T10:32:47.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10487" PostTypeId="2" ParentId="10483" CreationDate="2015-05-02T11:48:26.443" Score="2" Body="&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; &#xA;It looks as though you can just drive BL directly with the PWM-output.&lt;br&gt;&#xA;What happens when you do?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Details:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1)  As shown, even  if the circuit did what you wanted, all you would be doing is providing a rail to rail (0V to 3.3V ) signal to the BL pin. You can do this by connecting PWM-out to BL directly.&lt;br&gt;&#xA;Does this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the LCD and Arduino used differing power supplies the MOSFET may be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) To use circuit almost as-is you need a PChannel FET. &#xA;Swap Drain and Source and it will provide PWM to the BL pin. When BL is high the FET is off. When BL is low the FET is on. The FET used must turn on with about 3V between gate and source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) To use the N Channel BS170 you must drive the gate +ve above the source by an amount that is enough to just turn it one &quot;plus a little more&quot;. This is called Vth (Vthreshold). The BS170 has Vth ~= 1.8V at low currents. Vth varies somewhat between samples. When you connect the gate to +3.3V the FET tried to turn on but as the source rises it reduced Vgs until it reaches about Vth. Raising the source above this level reduced Vgs to below Vth so the FET is not turned on.&lt;br&gt;&#xA;ie this is what a=accounts for the 1.5V that you see as 3.3V - 1.8V = 1.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the BS170,&lt;br&gt;&#xA;connect the source to ground,&lt;br&gt;&#xA;connect drain via a say 1k resistor to +3.3V,&lt;br&gt;&#xA;connect drain to BL,&lt;br&gt;&#xA;drive gate with PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT why does not just driving BL with PWM do what you want?&lt;br&gt;&#xA;A data sheet for the display would be useful.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-02T11:48:26.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10488" PostTypeId="2" ParentId="10483" CreationDate="2015-05-02T13:59:41.867" Score="0" Body="&lt;p&gt;Since you are switching on the high side, you need a P-channel mosfet, not an N-channel like the BS170. (Or you need a higher voltage on the Gate to reach the V&lt;SUB&gt;GS(th)&lt;/SUB&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a similar display, but mine will light up if BL is connected to ground. For these kind of displays you'd use a N-channel mosfet.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-02T13:59:41.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10489" PostTypeId="1" AcceptedAnswerId="10495" CreationDate="2015-05-02T14:01:03.950" Score="0" ViewCount="797" Body="&lt;p&gt;i bought two arduino uno r3 card (not original)&#xA;one is working perfectly:&#xA;&lt;img src=&quot;https://img11.hostingpics.net/pics/6526993911.jpg&quot; alt=&quot;1&quot; /&gt;&#xA;the other is not powering up (no led is lit), i did some measuring and i found that two usb connector pins on the board are shorted, how can i proceed to repair it taking in account that it works from time to time !&#xA;&lt;img src=&quot;https://img11.hostingpics.net/pics/217640602.jpg&quot; alt=&quot;2&quot; /&gt;&#xA;thank you&#xA;More images:&#xA;&lt;img src=&quot;https://s11.postimg.org/6ukiv3khf/SAM_1434.jpg&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tgYhM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tgYhM.jpg&quot; alt=&quot;4&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;" OwnerUserId="8807" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-02-18T10:02:41.507" Title="Arduino uno r3 not powering up" Tags="|arduino-uno|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 4.0" />
  <row Id="10490" PostTypeId="2" ParentId="10472" CreationDate="2015-05-02T14:47:53.527" Score="1" Body="&lt;p&gt;About the MAX232, I have a Dwengo (similar to Arduino) and to use the HC06 I have to disconnect the serial port(=RS232) else I short circuit my HC06.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some googling, MAX232 is simply the name of that chip which is required to convert your TX/RX from your bluetooth module to something usable by Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://en.m.wikipedia.org/wiki/MAX232&quot; rel=&quot;nofollow&quot;&gt;http://en.m.wikipedia.org/wiki/MAX232&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8808" LastActivityDate="2015-05-02T14:47:53.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10491" PostTypeId="2" ParentId="10489" CreationDate="2015-05-02T17:28:52.300" Score="0" Body="&lt;p&gt;Since it's intermittent I'd try two things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Easy: Briefly reheat each pin of the USB connector and it's pad, the goal being to make sure the solder joints are solid. Clean away any solder bridging the pads. Of course you can only reach the back side of the board, but this is an easy first step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More thorough: If the first step didn't get it working, then try desoldering the USB connector, using a solder pump and desoldering braid to remove as much of the solder as possible from all four pins before you try to actually remove the part. Work slowly giving it time to cool between steps so you don't overheat anything. When the part is removed, inspect the top of the board and clean up any solder bridges. Inspect the bottom of the USB connector where it touches the board and clean it, too, if necessary. Then solder it onto the board again using as little solder as necessary to make solid connections.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-02T17:28:52.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10495" PostTypeId="2" ParentId="10489" CreationDate="2015-05-03T00:27:43.447" Score="1" Body="&lt;p&gt;It looks as though there may be material between at least one USB pin and the ground layer. This may be flux of solder 'splash'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If visual inspection shows that this may be the case I would try &lt;strong&gt;carefully&lt;/strong&gt; scratching with a sharp poibt (eg scriber) along at least the green arc on the image below. Be careful not to break intended conduction paths (eg as shown in black).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AZ38r.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-03T00:27:43.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10496" PostTypeId="1" AcceptedAnswerId="10498" CreationDate="2015-05-03T04:37:18.237" Score="3" ViewCount="215" Body="&lt;p&gt;I'm looking to develop my own personal SmartWatch, hardware, software, and all. My problem is starting off on the hardware portion of it; more specifically what platform I should build it on. I already have an Arduino Uno (R3), nut I was hoping to find something a bit smaller. Any recommendations on what parts I should use?&lt;/p&gt;&#xA;" OwnerUserId="9814" LastActivityDate="2023-01-02T23:52:35.040" Title="Picking an Arduino" Tags="|arduino-uno|shields|hardware|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10498" PostTypeId="2" ParentId="10496" CreationDate="2015-05-03T04:56:26.287" Score="7" Body="&lt;p&gt;What you start with is not too critical as you can develop basic concepts on any Arduino hardware and use it to drive a display of your choice for testing. This can be migrated to whatever is found suitable as the project progresses.&lt;/p&gt;&#xA;&lt;p&gt;Important to consider are the number of I/O lines of various sorts that you need. Most AVR ICs that you are liable top use will have &amp;quot;some&amp;quot; analog input and PWM output lines. If you were going to drive a &amp;quot;bare&amp;quot; LCD you may need to use a processor with LCD drivers, but in  most designs use of an existing module with eg SPI interface is probable preferable.&lt;/p&gt;&#xA;&lt;p&gt;Most Arduinos in the UNO, Nano, Pro Mini, ... range are in reality not a lot more functionally that a processor IC, USB bridge (if needed) and voltage regulator(s). For a tidily small watch you may ultimately wish to use a bare SMD AVR IC with an Arduino boot loader code installed. You can move away from AVR ICs to other Arduino compatible systems - with some extra knowledge needed in most cases.&lt;/p&gt;&#xA;&lt;p&gt;.____________________________________________________&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Examples only:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is an &lt;a href=&quot;http://postscapes.com/internet-of-things-hardware&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Internet of things hardware roundup&lt;/strong&gt;&lt;/a&gt; which includes some small controllers as examples.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.panstamp.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Panstamps&lt;/strong&gt;&lt;/a&gt; offer MSP430 and ATMega328p (Arduino compatible versions).&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YdzzS.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;. _______________________________________________&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.rfduino.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;RFDuino - from here&lt;/strong&gt;&lt;/a&gt; offer some fingertip sized products with RF capability. Note that this use an ARM Cortex M0 processor, not an ATMega controller. While it is &amp;quot;Arduino compatible&amp;quot; it will not run all code that the typical UNO, Nano, ... boards run.&lt;br /&gt;&#xA;&lt;a href=&quot;http://www.rfduino.com/wp-content/uploads/2014/04/RFduino.Quick_.Start_.Guide_.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Manual here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bZXdw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bZXdw.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.kickstarter.com/projects/1608192864/rfduino-iphone-bluetooth-40-arduino-compatible-board&quot; rel=&quot;nofollow noreferrer&quot;&gt;Their Kickstarter page&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="27346" LastEditDate="2023-01-02T23:52:35.040" LastActivityDate="2023-01-02T23:52:35.040" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10500" PostTypeId="1" CreationDate="2015-05-03T10:23:12.680" Score="1" ViewCount="239" Body="&lt;p&gt;The below code is meant to display lines stored in a text file to an arduino based web page (it's a IR gate monitoring solution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I visit &#xA;I can execute client.println(&quot;hello&quot;) and I see the word &quot;hello&quot; on the page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I loop round the SD card rows and I can Serial.print (by char) in the Serial Monitor all the lines in the text file. Great - so far so good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I attempt to print to screen (instead of Serial Monitor) it does not work.  The offending line (but don't know why) is the FileSystem.Open - this prevents any further output to screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why does FileSystem.Open prevent client.print from working?&lt;/strong&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;  void loop() {&#xA;&#xA;  YunClient client = server.accept();&#xA;&#xA;  if (client) {&#xA;    String command = client.readString();&#xA;    command.trim();&#xA;    Serial.println(command);&#xA;&#xA;    if (command == &quot;today&quot;)&#xA;    {&#xA;        //client.println(&quot;hello&quot;);&#xA;&#xA;        // Get a timestamp&#xA;        String strTS = getTimeStamp();&#xA;        String strFileName = strTS;&#xA;&#xA;        // Build the file name containing the &#xA;        strFileName.replace(&quot;-&quot;, &quot;_&quot;);&#xA;        strFileName.replace(&quot;/&quot;, &quot;-&quot;);&#xA;        strFileName.replace(&quot;:&quot;, &quot;-&quot;);&#xA;        strFileName = strFileName.substring(0, 8);&#xA;        strFileName = &quot;/mnt/sd/BeerLogger/&quot; + strFileName + &quot;.txt&quot;;&#xA;&#xA;        // Display the file name in the serial window&#xA;      //  Serial.println((strFileName).c_str());&#xA;&#xA;        // Print the contents of the text file to screen&#xA;        File myFile = FileSystem.open(strFileName.c_str(), FILE_READ);&#xA;&#xA;&#xA;        if (myFile) {&#xA;           while (myFile.available()) {&#xA;              char c = myFile.read();&#xA;              if ( c == '\n') {&#xA;                //client.println(&quot;&quot;);               &#xA;              }&#xA;              Serial.print(c);&#xA;              client.print(c);&#xA;          }&#xA;          myFile.close();&#xA;      }&#xA;    }&#xA;&#xA;    // Terminate the client connection so we may resume&#xA;    client.stop();&#xA;    //Serial.println(&quot;client disconnected&quot;);&#xA;&#xA;  } else {&#xA;      MonitorIRGate();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7623" LastEditorUserId="37523" LastEditDate="2019-08-24T17:08:10.583" LastActivityDate="2019-08-24T17:08:10.583" Title="Yun - FileSystem.Open prevents client.println from outputting to web page" Tags="|wifi|arduino-yun|sd-card|web-server|ir|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10501" PostTypeId="1" AcceptedAnswerId="10524" CreationDate="2015-05-03T11:17:24.247" Score="0" ViewCount="7940" Body="&lt;p&gt;I have this schematic for a DC motor in my arduino, now I want to add 9v battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I've seen that people use TIP120 transistor, I have BC548B, &#xA;can I just put the 9v with that transistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7rYsX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9818" LastEditorUserId="2944" LastEditDate="2015-05-04T09:48:39.017" LastActivityDate="2015-05-04T12:22:53.373" Title="Transistor for DC motor and 9v" Tags="|arduino-uno|motor|transistor|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10502" PostTypeId="1" CreationDate="2015-05-03T11:19:04.547" Score="3" ViewCount="2352" Body="&lt;p&gt;I am new to arduino programming. And almost inexperienced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to program my arduino Uno board to read 2/3/4 wire configuration of PT100 RTD sensor (in accuracy levels of atleast 0.5°C). The temperature range is 0 to 400°C and -50 to 100°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I am totally new to this field I would appreciate a rather descriptive information with circuits and images and code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have researched a lot on the subject, but couldn't get anything useful or substantial to solve my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, I cannot use thermistor or any IC to read the temperatures as the machine on which the RTD is installed has PIDs, but I would like to create a datalogger that can fetch temperatures on computer itself.&lt;/p&gt;&#xA;" OwnerUserId="9819" LastActivityDate="2015-11-25T17:49:05.070" Title="How to read temperature using arduino uno board with PT100 RTD sensor?" Tags="|arduino-uno|temperature-sensor|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10505" PostTypeId="1" AcceptedAnswerId="10529" CreationDate="2015-05-03T11:47:37.633" Score="0" ViewCount="1986" Body="&lt;p&gt;Finally got around to playing with my uno today for the first time. ( It's a branded sunfounder UNO R3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First project. Simple blink. Using arduino 1.6.3, Windows 8.1 It is hooked up correctly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   // initialize digital pin 13 as an output.&#xA;   pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;   digitalWrite(9, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;   delay(10000);              // wait for a second&#xA;   digitalWrite(9, LOW);    // turn the LED off by making the voltage LOW&#xA;   delay(10000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I get is a fast blinking LED. I've tried multiple values and it doesn't change. No error on upload.&#xA;I've commented out everything except the digitalWrite(9, HIGH); and I get a fast blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;   digitalWrite(9, LOW);&#xA;   delay(5000);&#xA;   digitalWrite(9, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I get nothing, it doesn't even turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same if I remove the first digitalWrite();&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'm already a little lost here. I did a but of google searching tried adding a serial 9600 line, and a few other things. Nada.&lt;/p&gt;&#xA;" OwnerUserId="9822" LastEditorUserId="6452" LastEditDate="2015-05-04T20:59:42.003" LastActivityDate="2016-03-10T18:17:52.990" Title="New UNO, BLINK not working" Tags="|arduino-uno|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="10506" PostTypeId="2" ParentId="10485" CreationDate="2015-05-03T12:22:48.237" Score="0" Body="&lt;p&gt;Woo, solved it.  My ISR code was completely wrong.  Works using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER2_COMPA_vect)&#xA;{&#xA;  if (timer2_signal_toggle_count != 0)&#xA;  {&#xA;    // toggle the pin&#xA;    if(signal_state == 1)&#xA;        *timer2_pin_port ^= timer2_pin_mask;&#xA;&#xA;    if (timer2_toggle_count &amp;gt; 0)&#xA;      timer2_toggle_count--; &#xA;    else&#xA;    {&#xA;        TIMSK2 &amp;amp;= ~(1 &amp;lt;&amp;lt; OCIE2A);                 // disable the interrupt&#xA;        *timer2_pin_port &amp;amp;= ~(timer2_pin_mask);   // keep pin low after stop&#xA;    }&#xA;     timer2_signal_toggle_count --; &#xA;  }&#xA;  else&#xA;  {&#xA;    timer2_signal_toggle_count = signal_cycle_count;&#xA;    timer2_toggle_count --;&#xA;    if(signal_state == 1)&#xA;    {&#xA;        signal_state = 0;&#xA;        *timer2_pin_port &amp;amp;= ~(timer2_pin_mask);&#xA;        //*timer2_pin_port ^= timer2_pin_mask;&#xA;    }&#xA;    else &#xA;    {&#xA;        signal_state = 1;&#xA;        *timer2_pin_port ^= timer2_pin_mask;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was trying to just AND the signal state into the original pin state, which was completely the wrong thing to do.&lt;/p&gt;&#xA;" OwnerUserId="8806" LastActivityDate="2015-05-03T12:22:48.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10508" PostTypeId="1" AcceptedAnswerId="10522" CreationDate="2015-05-03T17:06:33.773" Score="0" ViewCount="273" Body="&lt;p&gt;I am looking at making an Arduino robot car. I have a RC car( photos below). I was wondering if I could take the chassis of the car and modify it to make it Arduino controlled, if so how could I do that?(I have an Arduino UNO R3). I would like to make it into a wall avoiding robot. I have never soldered a thing in my life, and I don't own a soldering iron.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fZtWO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JL37f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5GVaX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wa7ho.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9826" LastEditorUserId="9826" LastEditDate="2015-05-04T00:23:41.240" LastActivityDate="2015-07-28T02:23:53.157" Title="Disassembling a RC car for a Arduino Robot" Tags="|arduino-uno|robotics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10510" PostTypeId="1" CreationDate="2015-05-03T18:05:54.100" Score="1" ViewCount="608" Body="&lt;p&gt;I'm developing a sketch which I need to run on an Uno (for debug) and a Gemma (as the target).  Adafruit has their own Wire library (TinyWireM) which I was planning on using on the Gemma.  Thus, I was trying to use #if's to automatically include the correct library for the given target board.  However, it appears that the TinyWireM include files is always included even if the &lt;strong&gt;AVR_ATtiny85&lt;/strong&gt;  macro symbol is undefined (I get many undefined symbols reported inside the Arduino\libraries\TinyWireM-master\USI_TWI_Master.cpp file).  If I comment out the TinyWireM.h include statement (inside the #if define statement), then it compiles fine.  Code example below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So why isn't this include statement being skipped?  I'm at a loss.  Anyone have any thoughts?   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thx all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mike&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#undef __AVR_ATtiny85__        // Debug only - making sure not defined.&#xA;&#xA;#if defined (__AVR_ATtiny85__)&#xA;  #include &amp;lt;TinyWireM.h&amp;gt;    // Seems this file is still being included and&#xA;                          // must comment out this line when compiling &#xA;                          // code for an UNO.  This should not be necessary &#xA;                          // given __AVR_ATtiny85__ is not defined.&#xA;#else&#xA;  #include &amp;lt;Wire.h&amp;gt;         // This is the Wire library for the Uno.&#xA;#endif&#xA;&#xA;void setup() { }&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9828" LastActivityDate="2015-05-05T11:01:38.107" Title="#ifdef / #include CPP issue" Tags="|i2c|arduino-ide|ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10511" PostTypeId="2" ParentId="3926" CreationDate="2015-05-03T18:47:30.900" Score="1" Body="&lt;p&gt;I could be wrong, but I believe that this receiver operates at 38kHz (at least that is listed in the specs), so the IR source must be oscillating at that frequency for this receiver to see it. Check out this link to see how to create a circuit to oscillate your IR LED:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.electro-tech-online.com/threads/ir-emitter-at-38khz.94119/&quot; rel=&quot;nofollow&quot;&gt;http://www.electro-tech-online.com/threads/ir-emitter-at-38khz.94119/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9829" LastActivityDate="2015-05-03T18:47:30.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10512" PostTypeId="1" AcceptedAnswerId="10514" CreationDate="2015-05-03T18:53:40.663" Score="3" ViewCount="4119" Body="&lt;p&gt;When I do the led calculation I found 150 ohm resistor is enough for 3mm red led. If so why all arduino tutorials, &lt;a href=&quot;http://blog.grifby.com/2013/04/tutorial-1-blinking-led-using-arduino.html&quot; rel=&quot;nofollow&quot;&gt;like this one&lt;/a&gt;, are suggesting 330 ohm resistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume V = 5 Volt, diode forward voltage = 2V and diode forward current 20mA&lt;/p&gt;&#xA;" OwnerUserId="8687" LastActivityDate="2015-06-28T02:23:17.790" Title="Why all blink tutorials use 330 ohm resistor" Tags="|led|resistor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10514" PostTypeId="2" ParentId="10512" CreationDate="2015-05-03T19:21:43.353" Score="4" Body="&lt;p&gt;150 Ohms may be &quot;enough&quot;, but it's often still far too bright, so many tutorials keep a lower limit of around 10mA to help the LED live longer without affecting the application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll probably find that red LEDs are still visible at 1mA and a 330 Ohm resistor with a 5V supply will give about 8.5mA (assuming a 2.2V drop), which is plenty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really a &quot;lazy&quot; choice that will work well in &quot;most&quot; situations.&lt;/p&gt;&#xA;" OwnerUserId="5063" LastActivityDate="2015-05-03T19:21:43.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10515" PostTypeId="2" ParentId="10505" CreationDate="2015-05-03T19:47:43.937" Score="0" Body="&lt;p&gt;&lt;em&gt;Added as new answer because comments limit was reached&lt;/em&gt;&#xA;Doesn't really matter which programmer you set because in this instance you're not actually burning the bootloader just setting the fuses (to those already stored in boards.txt for the Uno) but 'Using Arduino as ISP' is the nearest to what you're doing&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-05-03T19:47:43.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10516" PostTypeId="1" AcceptedAnswerId="10561" CreationDate="2015-05-03T19:51:21.180" Score="1" ViewCount="10253" Body="&lt;p&gt;I have a DS3231 Real Time Clock module and I'd like to use the Square Wave output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder how can I set the frequency of the pulse?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How long is the (time) length of the pulse?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATED QUESTION&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to use the DS3231 as an 1PPS interrupt, I want to use the Square Wave output. Here's how I connected it to an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yeJ10.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected to the SQW output a 10kΩ pull-up resistor and an LED. After that I tested the code which shows the time and worked fine. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;void setup () {&#xA;   Serial.begin(9600);&#xA;   #ifdef AVR&#xA;      Wire.begin();&#xA;   #else&#xA;      Wire1.begin(); &#xA;   #endif&#xA;   rtc.begin();&#xA;&#xA;  if (! rtc.isrunning()) {&#xA;     Serial.println(&quot;RTC is NOT running!&quot;);&#xA;     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;    }  &#xA;  }&#xA;&#xA;void loop () {&#xA;&#xA;   DateTime now = rtc.now();&#xA;   Serial.print(now.year(), DEC);&#xA;   // etc&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(The DS3231 works fine with the DS1307 library)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the LED was just flickering, so I thought that the default frequency of the SQW should be grater than 1Hz. I googled a bit and realized that I had to change some registers. So I found this piece of code which I called from the setup() function, but with no success, the LED is still flickering.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void set1Hz() {&#xA;   // Frequency is stored in register 0x0e in bit 3 and 4&#xA;   Wire.beginTransmission(0x68);&#xA;   Wire.write(0x0e);&#xA;   Wire.endTransmission();&#xA;   Wire.requestFrom(0x68, 1);&#xA;   uint8_t register0E = Wire.read();&#xA;&#xA;   // clear bits 3 and 4 for 1Hz&#xA;   register0E &amp;amp;= ~(1 &amp;lt;&amp;lt; 3);&#xA;   register0E &amp;amp;= ~(1 &amp;lt;&amp;lt; 4);&#xA;&#xA;   // put the value of the register back&#xA;   Wire.beginTransmission(0x68);&#xA;   Wire.write(0x0e);&#xA;   Wire.write(register0E);&#xA;   Wire.endTransmission();&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I'm now qualified for low level programming, any suggestions on how to change the registers would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="7728" LastEditDate="2015-05-04T19:02:35.967" LastActivityDate="2018-06-06T18:34:46.663" Title="RTC square wave" Tags="|rtc|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10517" PostTypeId="2" ParentId="10510" CreationDate="2015-05-03T23:00:14.940" Score="2" Body="&lt;p&gt;The Arduino IDE does its own non-standard preprocessing before the C++ preprocessor/compiler is invoked. One of the main purposes for this is to detect &lt;code&gt;#include&lt;/code&gt; directives which refer to libraries so it can link them properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess would be that part of this procedure ends up moving all &lt;code&gt;#include&lt;/code&gt; lines to the start of the file. In the code you've posted, that means I think it's being moved outside the whole &lt;code&gt;#if&lt;/code&gt;/&lt;code&gt;#else&lt;/code&gt; structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In most cases, you can avoid the Arduino IDE trickery by moving things into a separate header or source file. Unfortunately though, doing that means it may not link the libraries properly. As such, the easiest solution may be to switch to a 3rd party IDE which has Arduino support (e.g. Eclipse).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-05-03T23:00:14.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10519" PostTypeId="2" ParentId="10496" CreationDate="2015-05-04T00:41:56.407" Score="2" Body="&lt;p&gt;Why not start with your Arduino Uno, it's got lots of I/O pins, and it's a great little device to start prototyping your watch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could add a number of sensors/peripherals such as&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a Bluetooth module, - connect your phone&lt;/li&gt;&#xA;&lt;li&gt;an IMU, - detect different excercises from your wrist movement&lt;/li&gt;&#xA;&lt;li&gt;a tiny motor - to make the watch vibrate&lt;/li&gt;&#xA;&lt;li&gt;a speaker for audible notifications&lt;/li&gt;&#xA;&lt;li&gt;tactile buttons for switch between modes and functions of the watch&lt;/li&gt;&#xA;&lt;li&gt;a LCD screen, - to see the time and other data&lt;/li&gt;&#xA;&lt;li&gt;maybe a few LEDs as a torch function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once you develop your code and your happy with it, you could shrink your board accordingly, because you will then know how much I/O pins you'll need, and what voltage these sensors need to operate, and their inputs (analog vs. digital). You could even design your own PCB board with all these sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the Uno as a stepping stone.&lt;/p&gt;&#xA;" OwnerUserId="8060" LastActivityDate="2015-05-04T00:41:56.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10520" PostTypeId="1" CreationDate="2015-05-04T02:33:20.290" Score="3" ViewCount="6474" Body="&lt;p&gt;I want to convert a string into a int value. in my real code, I receive a string &quot;Slider 255&quot; the number after slider changes from 0 to 255, so I want a int value to be equal to that number. This is a small example of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myServo;&#xA;&#xA;&#xA;int val = 0;&#xA;String s = &quot;&quot;;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  myServo.attach(9);&#xA;}&#xA;&#xA;void loop() {&#xA;  while(BT.available() &amp;gt;0){&#xA;  s =  Serial.read(); // which wiil be a number between 0 and 255&#xA;  // So I want val to be = to ehatever the string is. So far I have try this but it doesn´t work.&#xA;  // first attempt # 1&#xA;  val = s:&#xA;  myServo.write(val); &#xA;&#xA;  // Second attempt # 2 &#xA;  Serial.println(s)&#xA;  val = Serial.read();&#xA;   myServo.write(val);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9836" LastEditorUserId="1585" LastEditDate="2015-05-04T03:10:05.790" LastActivityDate="2015-05-04T03:16:41.233" Title="How to convert a String number Into a int value?" Tags="|arduino-uno|c++|robotics|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10521" PostTypeId="2" ParentId="10520" CreationDate="2015-05-04T03:16:41.233" Score="4" Body="&lt;p&gt;The easiest way is to use the &lt;a href=&quot;http://www.arduino.cc/en/Reference/ParseInt&quot; rel=&quot;noreferrer&quot;&gt;parseInt method available to Serial&lt;/a&gt; like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = Serial.parseInt()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, you will have to be sure that the non-number part of the message (&quot;Slider&quot;) has already been dealt with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also put the data into an &lt;a href=&quot;http://www.arduino.cc/en/Reference/StringToInt&quot; rel=&quot;noreferrer&quot;&gt;arduino String Object and use it's toInt method&lt;/a&gt;, or put it in a &lt;a href=&quot;http://www.cplusplus.com/reference/cstdlib/atoi/&quot; rel=&quot;noreferrer&quot;&gt;C style string and use the atoi method&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-05-04T03:16:41.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10522" PostTypeId="2" ParentId="10508" CreationDate="2015-05-04T05:19:48.977" Score="0" Body="&lt;p&gt;Sometimes modifying something can be harder than starting from scratch. This is probably one of those cases, but it is over all not too difficult if you have the courage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with a good example, like &lt;a href=&quot;http://www.instructables.com/id/Arduino-Obstacle-Avoidance-Robot/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; robot.  It will give you an idea of what hardware you must add to your RC car and how to program the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/o2vl6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-04T05:19:48.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10524" PostTypeId="2" ParentId="10501" CreationDate="2015-05-04T09:51:59.597" Score="1" Body="&lt;p&gt;There are many circuits using the &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/TI/TIP120.pdf&quot; rel=&quot;nofollow&quot;&gt;TIP120 NPN&lt;/a&gt; transistor because it is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Darlington_transistor&quot; rel=&quot;nofollow&quot;&gt;darlington transistor&lt;/a&gt;. This is used because its max voltage is &lt;code&gt;60V&lt;/code&gt; and the max current is &lt;code&gt;5A&lt;/code&gt;, this means you can control a variety of external high current devices with low voltage circuitry because of the darlington arrangement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/BC/BC547.pdf&quot; rel=&quot;nofollow&quot;&gt;BC548B&lt;/a&gt; with your motor(low current) and a 9V battery as it does handle &lt;code&gt;30V&lt;/code&gt;, &lt;strong&gt;but it is limited to &lt;code&gt;100mA&lt;/code&gt;&lt;/strong&gt;, which is fine for tiny low current motors. But these are actually Amplifier transistors, so there main design area is not for inductive loads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend the TIP120 as this will ensure that you don't trash a transistor with current spikes as you could easily go over the 100mA spec of the BC548.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2015-05-04T12:22:53.373" LastActivityDate="2015-05-04T12:22:53.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10526" PostTypeId="2" ParentId="10501" CreationDate="2015-05-04T11:08:51.377" Score="1" Body="&lt;p&gt;Firstly, I see no external power supply in your schematic.&lt;br&gt;&#xA;Secondly, you certainly CANNOT use a BC548 for controlling a motor.&lt;br&gt;&#xA;MOSFETS are the best.&lt;/p&gt;&#xA;" OwnerUserId="8420" LastActivityDate="2015-05-04T11:08:51.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10528" PostTypeId="2" ParentId="10510" CreationDate="2015-05-04T12:41:54.767" Score="3" Body="&lt;p&gt;The problem isn't your code. There is a 2012 &lt;a href=&quot;https://code.google.com/p/arduino/issues/detail?id=906&quot; rel=&quot;nofollow&quot;&gt;bug report&lt;/a&gt; on this issue in Google Code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you start getting bitten by the non-standard behavior of the Arduino IDE, you've outgrown it and the only real remedy is to move up to real tools that work as you'd expect. A few of the choices include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Eclipse is a good choice; it can take a little patience and searching to&#xA;get it set up right, but once you do it's a solid development&#xA;environment you can stay with for a long time. It runs everywhere  Java does.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/tools/atmelstudio.aspx&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt; is well thought of. It's proprietary, not free [?], and only for windows.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Apple's &lt;a href=&quot;http://playground.arduino.cc/Main/EmbedXcode&quot; rel=&quot;nofollow&quot;&gt;Xcode&lt;/a&gt; can be configured to use the avr-gcc toolset. (Even thought it's right here on my system, I'm happy with Eclipse and haven't tried it).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Likewise, you can use Microsoft &lt;a href=&quot;http://www.megunolink.com/building-arduino-programs-with-microsoft-visual-studio/&quot; rel=&quot;nofollow&quot;&gt;Visual Studio&lt;/a&gt; (the linked article is just one of many).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Command line: You can get down and dirty with your favorite editor, the gcc toolset for AVR, and bang away at your keyboard. Not sexy, but you'll learn everything that's going on between your code the board.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-05-05T11:01:38.107" LastActivityDate="2015-05-05T11:01:38.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10529" PostTypeId="2" ParentId="10505" CreationDate="2015-05-04T12:58:26.610" Score="0" Body="&lt;p&gt;Defective board.  Thanks to @br1an for the milli idea.  New board in the way,  not a clone. &lt;/p&gt;&#xA;" OwnerUserId="9822" LastActivityDate="2015-05-04T12:58:26.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10531" PostTypeId="1" AcceptedAnswerId="10535" CreationDate="2015-05-04T15:25:11.430" Score="3" ViewCount="2242" Body="&lt;p&gt;I am brand new to Arduino and am having a difficult time understanding the &quot;lay of the land&quot;. I'm looking for the beefiest, fastest, most compute-centric Arduino available to the market that will run &lt;a href=&quot;https://github.com/embox/embox&quot; rel=&quot;nofollow&quot;&gt;embox&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I understand it, there is really only the Uno and the Mega, both of which are 32-bit. However I also believe that 64-bit variations/designs exist and was wondering if anyone has actually implemented Arduino Uno/Mega as a 64-bit MCU. I also see there is the Arduino Due, but not sure how that fairs (beefiness-wise) with Uno/Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to summarize: &lt;strong&gt;What is the beefiest Arduino one can find, is it 32- or 64-bit, and will it run an embedded RTOS like embox?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-08-31T19:00:57.290" Title="Arduino selection for RTOS" Tags="|arduino-uno|arduino-mega|hardware|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10533" PostTypeId="1" CreationDate="2015-05-04T15:43:20.710" Score="1" ViewCount="415" Body="&lt;p&gt;I bought a kit of 37 sensors for Arduino, and downloaded all the example sketches. Now, when I try to start up the Arduino IDE I get a &lt;em&gt;lot&lt;/em&gt; of frustrating messages like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aGJua.png&quot; alt=&quot;Sensor kit error message&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;... and I have to click &quot;OK&quot; on every one in turn before the IDE will start up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously I do not want to delete the sketches and their accompaniments, so I have tried to rename all the files and directories, with a shell script, to remove non-alphanumerical characters, but my understanding of shell programming is not good enough, so I have had no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made backups of the files in case things went awry with my scripting, and now see that these messages are repeated, as in the image, for the backup copies as well. I cannot find out how the Arduino IDE finds them, they are not in my Sketchbook folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be grateful for advice on either how to avoid these messages, or to edit the names so that they do not occur: I would be happy to edit the names of each sketch as I come to try it out, but I baulk at doing the lot at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Linux Fedora 20.&lt;/p&gt;&#xA;" OwnerUserId="1631" LastEditorUserId="4628" LastEditDate="2017-04-08T04:40:25.893" LastActivityDate="2017-04-08T04:40:25.893" Title="How to avoid report of unsuitable sketch names?" Tags="|sketch|ide|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10534" PostTypeId="2" ParentId="10427" CreationDate="2015-05-04T16:14:47.087" Score="0" Body="&lt;p&gt;I've built &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ceEoB.jpg&quot; alt=&quot;Inverting Op-Amp&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit without C4 and everything after R4 (no rectifier, not a single diode used). R4 has to be switched for 100kOhms, since this gives a 100x amplification. I guess this is simple enough for most people.&#xA;Thanks for the hints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code can be used to detect claps/noises. It is restricted to a double-clap with silence in between. Parameters can be easily tuned. This works quite well for me, even when I play noise/TV/music to the speaker directly it triggers rarely, or not at all!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// CLAP switch using an electret microphone&#xA;// switches ie. a relais or led with a certain&#xA;// clap-melody&#xA;&#xA;// sound parameters&#xA;const int THRESHOLD = 20;&#xA;const int VAL_MEAN = 507;&#xA;&#xA;// trigger characteristics&#xA;const int CLAPS_TO_TRIGGER = 2; // number of claps&#xA;const int DEBOUNCE_TIME = 150; // ms to ignore double-clapping&#xA;const int SILENCE_T = 40; // ms between claps, otherwise reset&#xA;const int MELODY_INTERVAL = 800; // ms max time for the claps&#xA;const int PAUSE_TIME = 2000; // wait after switch, or noise&#xA;&#xA;// pin-layout&#xA;const int analogPin = 0;&#xA;const int OUTPUT_PIN = 13;&#xA;&#xA;&#xA;int output_state = LOW;&#xA;uint32_t pause_t = 0;&#xA;uint32_t debounce_t = 0;&#xA;uint32_t start_time = 0; // timestamp of first clap-start&#xA;uint8_t claps = 0;&#xA;int sensorVal = 0;&#xA;int amp = 0;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(OUTPUT_PIN,OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  sensorVal = analogRead(analogPin);&#xA;  amp = abs(sensorVal-VAL_MEAN);&#xA;&#xA;  // Serial.print(F(&quot;sensed: &quot;)); Serial.println(sensorVal);&#xA;  // Serial.print(F(&quot;amp: &quot;)); Serial.println(amp);&#xA;&#xA;  // at the end of an interval check the number of claps&#xA;  if (millis()-start_time &amp;gt; MELODY_INTERVAL &amp;amp; claps != 0) {&#xA;    if (claps == CLAPS_TO_TRIGGER &amp;amp; millis()-pause_t &amp;gt; PAUSE_TIME) {&#xA;      output_state = !output_state;&#xA;      pause_t = millis();&#xA;      digitalWrite(OUTPUT_PIN,output_state);&#xA;      Serial.print(F(&quot;Triggered &quot;));&#xA;      Serial.println(output_state);&#xA;    }&#xA;    if (claps&amp;gt;CLAPS_TO_TRIGGER) { Serial.print(F(&quot;- too many&quot;)); }&#xA;    reset();&#xA;  }&#xA;&#xA;  // noise/clap detected&#xA;  if (amp &amp;gt; THRESHOLD &amp;amp;\&#xA;      millis()-debounce_t &amp;gt; DEBOUNCE_TIME &amp;amp;\&#xA;      millis()-pause_t &amp;gt; PAUSE_TIME) {&#xA;    // there has to be silence between claps&#xA;    if (millis()-debounce_t &amp;lt; SILENCE_T+DEBOUNCE_TIME) {&#xA;      claps = 0;&#xA;      debounce_t = millis();&#xA;      Serial.print(F(&quot;reset - silence interrupted&quot;));&#xA;      Serial.print(F(&quot; amp &quot;));Serial.println(amp);&#xA;    } else {&#xA;      claps++;&#xA;      debounce_t = millis();&#xA;      Serial.print(F(&quot;claps &quot;));Serial.print(claps);&#xA;      Serial.print(F(&quot; amp &quot;));Serial.println(amp);&#xA;      if (claps == 1) { start_time = debounce_t; }&#xA;    }&#xA;  }&#xA;  delay(1);&#xA;}&#xA;&#xA;&#xA;void reset() {&#xA;  // time has expired&#xA;  start_time = 0;&#xA;  claps = 0;&#xA;  debounce_t = 0;&#xA;  Serial.println(F(&quot;reset&quot;));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2015-05-05T09:56:37.620" LastActivityDate="2015-05-05T09:56:37.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10535" PostTypeId="2" ParentId="10531" CreationDate="2015-05-04T16:29:41.777" Score="3" Body="&lt;p&gt;While I'm not experienced with running an RTOS on it, I'd highly recommend &lt;a href=&quot;https://www.pjrc.com/teensy/teensy31.html&quot; rel=&quot;nofollow&quot;&gt;Teensy 3.1&lt;/a&gt; as the &quot;beefiest, fastest, most compute-centric Arduino&quot;. FreeRTOS and ChibiOS both support Teensy.&lt;/p&gt;&#xA;" OwnerUserId="9849" LastActivityDate="2015-05-04T16:29:41.777" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="10536" PostTypeId="1" CreationDate="2015-05-04T16:43:36.077" Score="0" ViewCount="2134" Body="&lt;p&gt;I made simple code for a robotic arm, but the servos don't seem to be reacting at all. I made debug code before all the if statements, and those aren't working. I made sure my wiring was good and it is.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo release1;&#xA;Servo release2;&#xA;Servo updown;&#xA;&#xA;&#xA;int pos = 64;    // variable to store the servo position &#xA;int pos2 = 85;&#xA;int val = 0;&#xA;int val2 = 0;&#xA;int val3 = 0;&#xA;&#xA;void setup() &#xA;{ &#xA;    release1.attach(8);&#xA;    release2.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;    updown.attach(10);&#xA;    release1.write(pos2);&#xA;    release2.write(pos2);&#xA;    updown.write(pos);&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;    val = digitalRead(4);  &#xA;    val2 = digitalRead(5); &#xA;    val3 = digitalRead(6);&#xA;    pos++;&#xA;    pos2++; &#xA;    if(val = LOW){&#xA;        pos = pos + 15;&#xA;    }&#xA;    if(val2 = LOW)&#xA;    {&#xA;        pos = pos - 15;&#xA;    }&#xA;    if(val3 = LOW)&#xA;    {&#xA;        pos2 = 180;&#xA;    }&#xA;    if(val3 = HIGH){&#xA;        pos2 = 0;&#xA;    }&#xA;    release1.write(pos2);&#xA;    release2.write(pos2);&#xA;    updown.write(pos);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this code and it still wont work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Sweep&#xA; by BARRAGAN &amp;lt;http://barraganstudio.com&amp;gt; &#xA; This example code is in the public domain.&#xA;&#xA; modified 8 Nov 2013&#xA; by Scott Fitzgerald&#xA; http://arduino.cc/en/Tutorial/Sweep&#xA;*/ &#xA;&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;  // create servo object to control a servo &#xA;                // twelve servo objects can be created on most boards&#xA;&#xA;int pos = 0;    // variable to store the servo position &#xA;&#xA;void setup() &#xA;{ &#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object &#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  for(pos = 0; pos &amp;lt;= 180; pos += 1) // goes from 0 degrees to 180 degrees &#xA;  {                                  // in steps of 1 degree &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;  for(pos = 180; pos&amp;gt;=0; pos-=1)     // goes from 180 degrees to 0 degrees &#xA;  {                                &#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos' &#xA;    delay(15);                       // waits 15ms for the servo to reach the position &#xA;  } &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9850" LastEditorUserId="10794" LastEditDate="2015-10-02T21:47:03.943" LastActivityDate="2015-10-02T21:47:03.943" Title="Servos don't move" Tags="|arduino-uno|c++|servo|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="10537" PostTypeId="1" AcceptedAnswerId="10547" CreationDate="2015-05-04T16:56:45.047" Score="2" ViewCount="1841" Body="&lt;p&gt;I'm trying to understand the relationship between embedded RTOSes, SoCs and chip architectures. Specifically, I have a hobby project that would involve me writing a real-time, embedded application for the &lt;a href=&quot;https://github.com/embox/embox&quot; rel=&quot;nofollow&quot;&gt;embox RTOS&lt;/a&gt;, and use Arduino hardware for my proof of concept/prototype. Then, budget permitting, I'd like to port that app to run on another, non-Arduino ARM-based system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; is that ARM is the chip architecture (a conceptual design, really), and that Arduino simply implements this design, and is also a &quot;system on a chip&quot; because it has other things (USB ports, GPIO pins, etc.) that make it more of a computer than just a MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; is that if embox runs on ARM, which they claim it does, then at some point in the future I can take my application and run it on another ARM-based system without any real headache/pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my understanding of: ARM, Arduino, MCU, SoC and embox/RTOS correct? If not, please clarify/correct me! If so, what sort of considerations &lt;em&gt;would&lt;/em&gt; have to be made when porting my app to another ARM system in the future?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-04T20:21:22.280" Title="Arduino: ARM, MCU, SoC and RTOS" Tags="|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10538" PostTypeId="2" ParentId="10533" CreationDate="2015-05-04T17:00:13.320" Score="4" Body="&lt;p&gt;That message is actually a hang-over from when the IDE was Processing.  The name of a file had to match the name of the Java class within that file, and there are strict rules about what can be in a Java class name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They just basically haven't got around to deleting that piece of ancient code yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have 3 options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Rename all the folders and files.&lt;/li&gt;&#xA;&lt;li&gt;Edit the IDE's source code to delete that old code&lt;/li&gt;&#xA;&lt;li&gt;Use a different IDE.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first option can be long winded if you don't know how to do good scripting, as you have found out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option requires knowledge of Java coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that leaves the third option.  Now, I'm going to be shamelessly advertising my own work here ;)  Why not try a better IDE?  Such as the popular and powerful &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; (yes, written by me). It's based on the Arduino IDE, so it will mostly be familiar to you, but the whole of the insides have been ripped out and re-written.  If you're feeling brave you might want to give &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow&quot;&gt;the beta version&lt;/a&gt; a go - it has some really really cool features not found in any other IDE in the history of mankind.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-04T17:00:13.320" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10539" PostTypeId="1" CreationDate="2015-05-04T17:16:09.330" Score="2" ViewCount="428" Body="&lt;p&gt;Trying to send bytes from an RPi as a master to an Arduino as a slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The send uses the &lt;code&gt;write_byte(addr, value)&lt;/code&gt; function and seems to be working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino however has issues with separating the received bytes into individual values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use the RPi to dictate when data is sent so I just need the Arduino to listen on wire.available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the wire.onreceive event function I can have a separate function which has: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int var = wire.read()&#xA;Serial.print(var)   //for monitoring read byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code shows that the bytes being received are the right ones however, when I try something like &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;ledData[0] = wire.read();&#xA;ledData[1] = wire.read();&#xA;ledData[1] = wire.read();&#xA;etc&#xA;etc&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This returns wildly different values as if the bytes are getting mixed up. Can anyone help me to specifically intake 16 bytes into array indexes for use in the main loop function.&lt;/p&gt;&#xA;" OwnerUserId="9851" LastEditorUserId="37523" LastEditDate="2019-08-24T16:00:34.723" LastActivityDate="2019-08-24T16:00:34.723" Title="Receiving multiple bytes from an RPi using the i2c protocol" Tags="|serial|i2c|raspberrypi|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10541" PostTypeId="1" AcceptedAnswerId="10542" CreationDate="2015-05-04T18:08:23.287" Score="0" ViewCount="3398" Body="&lt;p&gt;I was struggling with timer interrupts in my project. I couldn't make it work properly. So I decided writing a simple code and I saw a very interesting case.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_COMPB_vect)&#xA;{&#xA;        PORTB ^= (1 &amp;lt;&amp;lt; PORTB5);&#xA;}&#xA;&#xA;&#xA;int main(void)&#xA;{&#xA;    cli();          // disable global interrupts&#xA;    TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;    TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;    OCR1A = 10000;&#xA;    OCR1B = 100;&#xA;&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1B);&#xA;    DDRB= 0xFF;&#xA;&#xA;    #define F_CPU 16000000&#xA;    sei();&#xA;    while (1)&#xA;    {&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my code. When I change OCR1B value, nothing happens, but if I change OCR1A value then blinking gets faster. Is there a logical explanation for this?&lt;/p&gt;&#xA;" OwnerUserId="6994" LastActivityDate="2015-05-04T18:36:25.130" Title="AVR Timer1 OCR1A controls TIMER1_COMPB_vect interrupt!" Tags="|interrupt|timers|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10542" PostTypeId="2" ParentId="10541" CreationDate="2015-05-04T18:36:25.130" Score="2" Body="&lt;p&gt;By setting WGM12, you set the time to CTC mode. In this mode the timer will restart when it reaches that value set to OCR1A. So the lower the value, the faster it restarts, so the higher the frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OCR1B value only changes where in this cycle the interrupt occurs. It will however still only be called once per timer1 overflow.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-04T18:36:25.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10543" PostTypeId="1" AcceptedAnswerId="10544" CreationDate="2015-05-04T18:47:11.873" Score="1" ViewCount="145" Body="&lt;p&gt;I see there is an &lt;a href=&quot;http://www.ns-electric.com/products/energyshield/&quot; rel=&quot;nofollow&quot;&gt;Arduino EnergyShield&lt;/a&gt; available, and am wondering what (specific) &lt;strong&gt;solar&lt;/strong&gt; shield/panels/attachments can be used to power it. Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus points if someone can explain how long the solar unit would take to charge the Energy Shield if the Arduino was on but idling (low-to-nonexistent power output).&lt;/p&gt;&#xA;" OwnerUserId="9842" LastEditorUserId="9842" LastEditDate="2015-05-04T19:05:20.767" LastActivityDate="2015-05-04T19:25:45.293" Title="What connects to Arduino Solar Shield?" Tags="|shields|battery|solar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10544" PostTypeId="2" ParentId="10543" CreationDate="2015-05-04T19:25:45.293" Score="1" Body="&lt;p&gt;First, panels that you can use...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few at Adafruit (&lt;a href=&quot;https://www.adafruit.com/products/200&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;https://www.adafruit.com/products/500&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;https://www.adafruit.com/products/1525&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just want to check that the barrel jack and plug are the same size.  I couldn't find dimensions in the &lt;a href=&quot;http://www.ns-electric.com/download/energyshield/energyShield%20-%20Product%20Manual.pdf&quot; rel=&quot;nofollow&quot;&gt;documentation for the energy shield&lt;/a&gt; so you may need to dig a little deeper or just swap it for &lt;a href=&quot;http://www.digikey.com/product-detail/en/PJ-035D/CP-035D-ND/1644534&quot; rel=&quot;nofollow&quot;&gt;one that you know will work&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the question about how long it will take also depends.  First, if we assume that the arduino is not running we can get ~500mA from the second solar panel listed.  If we can get all of that into the battery, it would take (1200mAH/500mA) about 2.4 hours to fully charge the battery.  It looks like you have to make some adjustments on the shield to get the most out of your solar panel.  And of course, you'll want to adjust those calculations based on the panel that you end up getting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if we assume the Arduino is running &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=5536.0&quot; rel=&quot;nofollow&quot;&gt;and consuming about 25mA&lt;/a&gt; you will have to subtract that 25mA from the 500mA that the solar panel is providing.  So, in general...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;**&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(Battery Capacity)/(Solar Panel Current - Arduino Current) = Charge&#xA;  Time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;**&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you have a lot of control over the solar panel current and the arduino current based on the exact arduino that you use, etc, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also probably some loss regulating the solar panel voltage from 5-6V down to charge the battery (which is probably at 3.7V). I also don't know if the charging circuitry will limit the amount of current going to the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take Away: There's a lot of stuff to consider when trying to answer this question.  I think your best bet would be to get a panel that fits and dump the fuel gauge values out to the console every few minutes.&lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-05-04T19:25:45.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10545" PostTypeId="2" ParentId="9009" CreationDate="2015-05-04T19:48:17.543" Score="0" Body="&lt;p&gt;I personally find that one of the simplest solutions to a web server is one of the two following options.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Buy a serial cable, and transmit data using the Serial port on your Arduino. You can transmit data to a PC, and use PHP to read the serial port and display the data you would like.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Buy a Raspberry Pi. You will be doing the same as step 1, however you don't need a serial cable to use serial between Pi and Arduino. However you might need a 3.3V / 5V converter, which depends if the arduino serial port outputs data at 3.3V or 5V.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8716" LastActivityDate="2015-05-04T19:48:17.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10547" PostTypeId="2" ParentId="10537" CreationDate="2015-05-04T20:21:22.280" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding is that ARM is the chip architecture (a conceptual design, really),&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;ARM is the CPU core architecture used in the Atmel SAM3X MCU family. The MCU is the CPU plus all of the facilities (PWM, ADC, DAC, DMA, etc.) that are implemented in order to allow the CPU to interact with external circuitry.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and that Arduino simply implements this design,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most appropriately, &quot;Arduino&quot; is the IDE and the software libraries that come along with it, plus the specifications and connector layout of the various pieces of Arduino hardware.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and is also a &quot;system on a chip&quot; because it has other things (USB ports, GPIO pins, etc.) that make it more of a computer than just a MCU.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&quot;SoC&quot; is exactly what it says on the tin: it's an entire system on a single chip. The Due is not a SoC, since it's a full board. The BCM2835 found on the RPi is a SoC. The SAM3X is a MCU, since it still requires more than just connectors to become a full &quot;system&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding is that if embox runs on ARM, which they claim it does, then at some point in the future I can take my application and run it on another ARM-based system without any real headache/pain.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Provided that embox runs on the new system and that your application can be compiled for it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-04T20:21:22.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10548" PostTypeId="1" CreationDate="2015-05-04T20:45:12.290" Score="0" ViewCount="1839" Body="&lt;p&gt;I'm about to ask a question for the most common problem which everyone has with &lt;code&gt;attiny85&lt;/code&gt; and the IR library. I will try to make this question as simple as possible.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Few things about the lib and the chip&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First of all the lib &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/shirriff/Arduino-IRremote&lt;/a&gt; works great on the &lt;code&gt;UNO&lt;/code&gt; and it's the best out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Attiny85&lt;/code&gt; is the smallest chip you can get able to run Arduino code. It has alot of limitations but it worth it!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The common problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Attiny85&lt;/code&gt; uses different timers from the normal Attiny and Atmega chips which makes it impossible to run the standard libraries. There are some fixes for some libs. For example the &lt;code&gt;IR Remote&lt;/code&gt; has a version which &lt;strong&gt;ALMOST&lt;/strong&gt; works with the chip and it can be found over here: &lt;a href=&quot;http://gammon.com.au/Arduino/IRremote_Attiny.zip&quot; rel=&quot;nofollow&quot;&gt;http://gammon.com.au/Arduino/IRremote_Attiny.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the problem lies in the core. The first time i used the patched &lt;code&gt;IR&lt;/code&gt; i had the &lt;code&gt;MIT High Low Media Group&lt;/code&gt; versino 1 of the core files which bearly worked but it was the first released so...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading this guide:&lt;a href=&quot;http://www.instructables.com/id/Attiny-IR-library/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Attiny-IR-library/?ALLSTEPS&lt;/a&gt; I used an updated core which can be found here: &lt;a href=&quot;https://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0017.zip&quot; rel=&quot;nofollow&quot;&gt;https://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0017.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;And the final problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Even with the updated core i still got &lt;em&gt;only 1&lt;/em&gt; last error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compiling 'Shit' for 'ATtiny85 @ 8 MHz  (internal oscillator; BOD disabled)'&#xA;IRremoteInt.h:101: error: 'RAWBUF' was not declared in this scope&#xA;Error compiling&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to fix it?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Links&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;MIT high-low group first version: &lt;a href=&quot;http://highlowtech.org/?p=1229&quot; rel=&quot;nofollow&quot;&gt;http://highlowtech.org/?p=1229&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Tutorial for the chip and the IR: &lt;a href=&quot;http://www.instructables.com/id/Attiny-IR-library/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Attiny-IR-library/?ALLSTEPS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;The IR original lib: &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/shirriff/Arduino-IRremote&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Updated core: &lt;a href=&quot;https://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0017.zip&quot; rel=&quot;nofollow&quot;&gt;https://arduino-tiny.googlecode.com/files/arduino-tiny-0100-0017.zip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Just in case you wanna know i'm using the Atmel Studio 6 with the Visual Micro plugin instead of the crappy-arduino-IDE&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="6969" LastActivityDate="2015-05-04T21:06:00.133" Title="Arduino Attiny 85 IR library compiler error" Tags="|library|attiny|avr|ir|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10549" PostTypeId="2" ParentId="8401" CreationDate="2015-05-04T20:46:18.800" Score="0" Body="&lt;p&gt;I would use a sleep mode, e.g. PIN sleep, in order to reduce the power consumption of the Xbee. At the hardware level, the XBee uses pin 9 as a control pin. This pin can be used to sleep the radio: setting it to 3,3V (“high” or “asserted”) causes the radio to sleep; setting it to 0V (“low” or “deasserted”) wakes the radio up. You can find some useful hints on the following websites &lt;a href=&quot;http://citizen-sensing.org/2013/08/xbee-sleeping/&quot; rel=&quot;nofollow&quot;&gt;http://citizen-sensing.org/2013/08/xbee-sleeping/&lt;/a&gt; or &lt;a href=&quot;https://www.digi.com/wiki/developer/index.php/Designing_a_Sleeping_XBee_Sensor&quot; rel=&quot;nofollow&quot;&gt;https://www.digi.com/wiki/developer/index.php/Designing_a_Sleeping_XBee_Sensor&lt;/a&gt;  or here &lt;a href=&quot;http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index&quot; rel=&quot;nofollow&quot;&gt;http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastEditorUserId="1612" LastEditDate="2015-05-06T03:49:37.663" LastActivityDate="2015-05-06T03:49:37.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10550" PostTypeId="2" ParentId="10548" CreationDate="2015-05-04T21:06:00.133" Score="1" Body="&lt;p&gt;&lt;code&gt;RAWBUF&lt;/code&gt; is defined in IRremote.h. Make sure you include that header before including IRremoteInt.h.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-04T21:06:00.133" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10551" PostTypeId="1" AcceptedAnswerId="10567" CreationDate="2015-05-04T21:28:42.903" Score="0" ViewCount="216" Body="&lt;p&gt;I'm working with this &lt;a href=&quot;http://knolleary.net/arduino-client-for-mqtt/&quot; rel=&quot;nofollow&quot;&gt;http://knolleary.net/arduino-client-for-mqtt/&lt;/a&gt;. I'm using Arduino Uno + Ethernet shield + Tinkerkit Shield. But, if i have only Arduino Uno + Ethernet Shield, i can connect my arduino with MQTT and make publish/subscribe, but, when i put the tinkerkit shield, i lost the connection and i cannot connect any more. Any idea? Tinkerkit sensor shield is incompatible with mqtt? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="9820" LastActivityDate="2015-05-05T09:10:49.780" Title="MQTT vs Tinkerkit sensor Shield" Tags="|arduino-uno|ethernet|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10552" PostTypeId="1" AcceptedAnswerId="11612" CreationDate="2015-05-04T22:58:35.400" Score="3" ViewCount="12597" Body="&lt;p&gt;I have an arduino Uno board with a screen attached on top (&lt;a href=&quot;http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VUf0tMWN0iT&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VUf0tMWN0iT&lt;/a&gt; This is the screen). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get it so that the screen displays the time in hours, minutes and seconds and counts on a 24 hours loop. Like a digital clock. I have it so that it can count but it just counts up to 99 then repeats. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this code which counts milliseconds but I need minutes and hours &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;    void setup()&#xA;{&#xA;    lcd.begin( 16, 2 ); &#xA;}&#xA;&#xA;    void loop()&#xA;{&#xA;    lcd.setCursor ( 0, 1);&#xA;    lcd.print(millis());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8588" LastEditorUserId="2881" LastEditDate="2015-05-05T12:24:38.000" LastActivityDate="2020-05-30T21:35:50.733" Title="Program Arduino Uno as a digital clock" Tags="|arduino-uno|lcd|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10553" PostTypeId="2" ParentId="10552" CreationDate="2015-05-04T23:01:41.960" Score="1" Body="&lt;p&gt;Not sure what you're asking, but getting a Real Time Clock module will make your life a lot easier when dealing with time. Maybe post some sample code to show what your issue is. &lt;/p&gt;&#xA;" OwnerUserId="9849" LastActivityDate="2015-05-04T23:01:41.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10554" PostTypeId="2" ParentId="10536" CreationDate="2015-05-05T00:34:31.753" Score="0" Body="&lt;p&gt;I tried uploading on a computer with windows 8 freshed installed and it still wont work, i tried serval differn't servo motors, looks like the arduino it self is broken.&lt;/p&gt;&#xA;" OwnerUserId="9850" LastActivityDate="2015-05-05T00:34:31.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10556" PostTypeId="1" AcceptedAnswerId="10569" CreationDate="2015-05-05T02:23:31.777" Score="1" ViewCount="531" Body="&lt;p&gt;I'm using a Digispark, which is basically an attiny85 packaged with a few other things, as an ISP to program attiny85's. The Digispark is loaded with Littlewire and recognized as an USBtinySPI device on the computer. The target attiny85 to be programmed is stacked on top of the Digispark. All pins are connected 1-to-1, 2-to-2, etc. Programming is done from the Arduino IDE. The tutorial I followed can be found here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://digistump.com/wiki/digispark/tutorials/programming&quot; rel=&quot;nofollow&quot;&gt;http://digistump.com/wiki/digispark/tutorials/programming&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Digispark uses port 3 (USB-) and port 4 (USB+) to communicate with the computer. There are series resistors and shunt zener diodes on both USB connections. The Digispark schematic can be seen here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://s3.amazonaws.com/digispark/DigisparkSchematicFinal.pdf&quot; rel=&quot;nofollow&quot;&gt;https://s3.amazonaws.com/digispark/DigisparkSchematicFinal.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been happily programming attiny85's with this setup, but recently hit a snag. On the target chip, if port 3 or 4 produce an output, the computer will no longer recognize the programmer. The computer will immediately connect to the programmer once the target chip is removed from it's socket. The target chip must be messing up communication between the computer and the programmer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Curious if I was missing something, I compared my setup with Sparkfun's Tiny AVR Programmer. It seems like a more robust programmer. I thought it might have extra components or something, but it's almost identical. It uses an attiny84 with pins directly connected to an attiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After lots of random guesses, I added series 2.2kohm resistors on ports 3 and 4 between the target attiny85 and the programmer. This solves the problem, but seems like a workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something? It seems like a programmer should be able to work without worrying about what the pins on the target device are doing. I assumed poorly, that was the purpose behind the RESET pin. Is there a better solution?&lt;/p&gt;&#xA;" OwnerUserId="8765" LastActivityDate="2015-05-05T10:05:18.940" Title="Programmed device causes issues between computer and ISP" Tags="|attiny|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10557" PostTypeId="1" CreationDate="2015-05-05T02:29:03.970" Score="0" ViewCount="659" Body="&lt;p&gt;I have this method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void getWeatherData() {&#xA;    String resp = &quot;&quot;;&#xA;&#xA;    Process p;&#xA;    p.begin(&quot;python2.7&quot;);&#xA;    p.addParameter(&quot;/root/weather.py&quot;);&#xA;    p.run();&#xA;&#xA;    while (p.available() &amp;gt; 0) {&#xA;        char c = p.read();&#xA;        resp = resp + c;&#xA;    }&#xA;&#xA;    Serial.print(resp);&#xA;    Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the serial monitor, I see the string &lt;code&gt;70.7|45|1030.29|06:05|20:04|04 May 2015 22:24&lt;/code&gt;. The delimiter here is the pipe. Now, the parts I take a send them to methods that puts the values on the TFT screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I fail to understand how to split this long string into individual parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EC&lt;/p&gt;&#xA;" OwnerUserId="9858" LastEditorUserId="368" LastEditDate="2015-05-05T02:59:39.363" LastActivityDate="2015-05-05T08:02:58.013" Title="How to get string parts from string?" Tags="|arduino-yun|string|" AnswerCount="1" CommentCount="2" ClosedDate="2015-05-11T11:31:39.937" ContentLicense="CC BY-SA 3.0" />
  <row Id="10558" PostTypeId="2" ParentId="10552" CreationDate="2015-05-05T02:55:01.650" Score="1" Body="&lt;p&gt;Well you need to break this problem down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are currently able to count in milliseconds, then you know 1000 milliseconds equal 1 second, so every time the milliseconds equals 1000, you reset it to 0 and increment the seconds by 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You keep going from here, if seconds equals 60, then you increase minutes by 1, and reset seconds to zero.. You get the picture.&lt;/p&gt;&#xA;" OwnerUserId="8716" LastActivityDate="2015-05-05T02:55:01.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10559" PostTypeId="1" CreationDate="2015-05-05T03:21:34.117" Score="3" ViewCount="10516" Body="&lt;p&gt;Can anyone assist me to make a power supply whose output voltage will be controlled by an Arduino, with the latest voltage setting automatically saved in non volatile memory?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am in an OJT (On the Job Training Scheme). I was given a task to make a Arduino controlled voltage variable power supply whose outputs can be switched between several preset values using pushbutton control.   It's like switching between two different outputs when a designated button is being pushed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I have done so far. I made an LM317 based power supply with the output voltage controlled by a potentiometer. I followed &lt;strong&gt;this youtube tutorial&lt;/strong&gt;. It works well but I was ask to upgrade it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using a potentiometer to adjust the voltage, I wish to use switching buttons to choose between two or more preset voltage levels. Each switch buttons have their corresponding voltages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This link may also be relevant.&lt;br&gt;&#xA;Code is given below the circuit diagram.&lt;br&gt;&#xA;&lt;a href=&quot;http://diydrones.com/forum/topics/use-the-arduino-to-switch-between-two-batteries-1?id=705844%3ATopic%3A1114167&amp;amp;page=3#comments&quot; rel=&quot;nofollow&quot;&gt;ARDUINO AS A POWER SOURCE ALTERNATOR&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9859" LastEditorUserId="6959" LastEditDate="2015-05-06T05:19:42.770" LastActivityDate="2018-09-01T10:02:35.690" Title="Microcontroller controlled power supply" Tags="|arduino-uno|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10561" PostTypeId="2" ParentId="10516" CreationDate="2015-05-05T07:19:06.273" Score="2" Body="&lt;p&gt;Even though it is unusual for someone to answer his/her own question, I did some more digging and managed to solve the problem. So, I'd like to mention one or two items in order to help someone who may encounter the same problem.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I used the Jack Christensen's library &lt;a href=&quot;https://github.com/JChristensen/DS3232RTC&quot; rel=&quot;nofollow&quot;&gt;https://github.com/JChristensen/DS3232RTC&lt;/a&gt;, but I had to update the Time.h library.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the setup() I add this line in order to enable the SQW output and set it to 1PPS.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RTC.squareWave(SQWAVE_1_HZ);     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other options are SQWAVE_1024_Hz, SQWAVE_4096_Hz, SQWAVE_8192_Hz and SQWAVE_NONE&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using the LED and resistor (390Ω) as shown in the figure above, it works as a voltage divider. In that case the voltage between SQW output and Ground didn't exceed 2.0V. Thus someone should be careful if wants to have an LED indicator and wants to use SQW output as interrupt.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2015-05-05T07:19:06.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10562" PostTypeId="2" ParentId="10557" CreationDate="2015-05-05T08:02:58.013" Score="0" Body="&lt;p&gt;I used to have my own String class with a member method called Chomp which did exactly what you are requiring.  The body was something similar to this untested code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String chomp(String&amp;amp; pSrc, char pMatch)&#xA;{&#xA;    int matchPos = pSrc.indexOf(pMatch);    // Find the first occurrence of the separator&#xA;    if (matchPos &amp;lt; 0)   // Separator was not found.&#xA;    {&#xA;        String ret = pSrc;  // Return the remainder of the source string.&#xA;        pSrc = &quot;&quot;;          // Clear the source string&#xA;        return ret;&#xA;    }&#xA;&#xA;    String ret = pSrc.substring(0, matchPos - 1);   // &quot;Chomp&quot; the start of the string up to the separator into the return value&#xA;    pSrc.remove(0, matchPos);                       // Remove everything up to and including the separator.&#xA;    return ret;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully the above code should be pretty understandable and fixable if there are any errors.  Our version worked on a &quot;this&quot; pointer rather than passing in the source string, so we would have something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String sourceCoords = &quot;12,47,292,85&quot;;&#xA;int x1 = sourceCoords.chomp(&quot;,&quot;).toInt();&#xA;int y1 = sourceCoords.chomp(&quot;,&quot;).toInt();&#xA;int x2 = sourceCoords.chomp(&quot;,&quot;).toInt();&#xA;int y2 = sourceCoords.chomp(&quot;,&quot;).toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this is of some use.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-05T08:02:58.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10563" PostTypeId="1" AcceptedAnswerId="11633" CreationDate="2015-05-05T08:25:38.993" Score="0" ViewCount="1527" Body="&lt;p&gt;&lt;strong&gt;THIS QUESTION ISN'T IN USE ANYMORE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Solved by using an other remote that is supported by the libary&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;====NEW CODE====&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;    int RECV_PIN = 11;&#xA;    int relay1 = 2;&#xA;    int relay2 = 3;&#xA;    int relay3 = 4;&#xA;&#xA;    int on = 1;&#xA;    int on1 = 1;&#xA;    int on2 = 1;&#xA;&#xA;    IRrecv irrecv(RECV_PIN);&#xA;    decode_results results;&#xA;&#xA;    void setup()&#xA;    {&#xA;      digitalWrite(relay3, HIGH);&#xA;      pinMode(relay3, OUTPUT);&#xA;      digitalWrite(relay2, HIGH);&#xA;      pinMode(relay2, OUTPUT);&#xA;      digitalWrite(relay1, HIGH);&#xA;      pinMode(relay1, OUTPUT);&#xA;      pinMode(13, OUTPUT);&#xA;      irrecv.blink13(true);&#xA;      irrecv.enableIRIn();&#xA;    }&#xA;&#xA;    unsigned long last = millis();&#xA;&#xA;    void loop() {&#xA;      if (irrecv.decode(&amp;amp;results)){&#xA;        if (results.value == 0x36167A85) {&#xA;          if (millis() - last &amp;gt; 250) {&#xA;            on = !on;&#xA;            digitalWrite(relay1, on ? HIGH : LOW);&#xA;          }&#xA;          last = millis();&#xA;        } else if (results.value == 0x36161AE5) {&#xA;          if (millis() - last &amp;gt; 250) {&#xA;            on1 = !on1;&#xA;            digitalWrite(relay2, on1 ? HIGH : LOW);&#xA;          }&#xA;             last = millis();&#xA;        } else if (results.value == 0x3616FA05) {&#xA;         if (millis() - last &amp;gt; 250) {&#xA;            on2 = !on2;&#xA;            digitalWrite(relay3, on2 ? HIGH : LOW);&#xA;          }&#xA;            last = millis();&#xA;        }&#xA;        irrecv.resume();&#xA;      }  &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;================&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on this bit of arduino code for a while now but i can't get it to work. My circuit is wired up correctly, but it isn't returning any data in the serial prompt. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;decode_results results;&#xA;&#xA;int main = 0;&#xA;int left = 0;&#xA;int right = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn();&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    Serial.println(results.value, HEX);&#xA;    switch (results.value) {&#xA;      case 0x2E3A06C0:&#xA;        main = 1;&#xA;        Serial.println(&quot;MAIN: on&quot;);&#xA;        break;&#xA;      case 0x8C2921D6:&#xA;        left = 1;&#xA;        Serial.println(&quot;LEFT: on&quot;);&#xA;        break;&#xA;      case 0x226270DA:&#xA;        right = 1;&#xA;        Serial.println(&quot;RIGHT: on&quot;);&#xA;        break;&#xA;      case 0x4AC6E6A:&#xA;        main = 0;&#xA;        Serial.println(&quot;MAIN: off&quot;);&#xA;        break;&#xA;      case 0xDD5E26EF:&#xA;        left = 0;&#xA;        Serial.println(&quot;LEFT: off&quot;);&#xA;        break;&#xA;      case 0x3E5BEF99:&#xA;        right = 0;&#xA;        Serial.println(&quot;RIGHT: off&quot;);&#xA;        break;&#xA;    }&#xA;    irrecv.resume();&#xA;  }&#xA;&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using the libary Arduino-IRremote. When I try the demo &quot;IRrecvDemo&quot;, it works fine. I have the hex codes from this demo. So can someone help me get this code working? It would be nice!&lt;/p&gt;&#xA;" OwnerUserId="9863" LastEditorUserId="9863" LastEditDate="2015-05-09T18:10:51.267" LastActivityDate="2015-05-10T16:10:46.503" Title="Arduino IR not returning data" Tags="|serial|c++|arduino-nano|ir|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="10565" PostTypeId="1" AcceptedAnswerId="10568" CreationDate="2015-05-05T08:47:11.410" Score="3" ViewCount="1391" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/AJKKC.jpg&quot; alt=&quot;Clone&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought &lt;a href=&quot;http://www.ebay.com/itm/ATmega328P-CH340G-UNO-R3-Development-Board-Free-USB-Cable-for-Arduino-TGSNUYS-/261844126901?ssPageName=ADME:X:RRIRTB:US:3160&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; Arduino clone over eBay. It seems to have an extra SPI and serial ports. How do I use these?&lt;/p&gt;&#xA;" OwnerUserId="9865" LastActivityDate="2015-11-10T08:07:00.373" Title="How do I use the additional serial ports on an Arduino UNO R3 clone?" Tags="|serial|clones|arduino-uno-smd|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10566" PostTypeId="2" ParentId="10565" CreationDate="2015-05-05T08:55:27.607" Score="4" Body="&lt;p&gt;Those are not additional I&lt;sup&gt;2&lt;/sup&gt;C and UART ports, those are additional connectors connected to the normal peripherals. They are used in exactly the same manner as the normal connector.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-05T08:55:27.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10567" PostTypeId="2" ParentId="10551" CreationDate="2015-05-05T09:10:49.780" Score="0" Body="&lt;p&gt;I think your problem is in wiring. Ethernet shield is using SPI communication, it requires pins: &lt;code&gt;SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK)&lt;/code&gt;. Those pins must be left for the Ethernet shield. Information is from &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno description&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does your Arduino communicates with you after you plug-in Tinkerkit? If not, maybe you have a short in Tinkerkit shield. &lt;/p&gt;&#xA;" OwnerUserId="9866" LastActivityDate="2015-05-05T09:10:49.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10568" PostTypeId="2" ParentId="10565" CreationDate="2015-05-05T09:29:01.560" Score="4" Body="&lt;p&gt;UNO means ATmega328. It has always only one serial and one I2C port regardless of how many connectors (or solder pads) it is hooked to. They are just parallel outputs to ATmega pins:&#xA;&lt;code&gt;&#xA;D0 - TX &#xA;D1 - RX&#xA;A5 - SCL&#xA;A4 - SDA&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra pads are just for user convenience, for easier wiring. &lt;/p&gt;&#xA;" OwnerUserId="9866" LastActivityDate="2015-05-05T09:29:01.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10569" PostTypeId="2" ParentId="10556" CreationDate="2015-05-05T10:05:18.940" Score="1" Body="&lt;p&gt;With  the Tiny AVR programmer, the &lt;code&gt;D+&lt;/code&gt; and &lt;code&gt;D-&lt;/code&gt; lines are connected to there own input pins on the ATtiny84, see below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/k3yKU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the pins from the target chip do not interfere with the function of these. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whereas the digistump board has the outputs of the USB connected to pin &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt;, these pins are also connected to pin &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; of the target, as you know,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/yTs4d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that as soon as you have your outputs active on &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; these interrupt the function of the USB lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By adding the 2.2k you are increasing the resistance before the Zener regulator circuit(thus decreasing the effect of the voltage from the target on these lines) and allowing the main tiny to have 'control' over the bus lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is actual done on the &lt;a href=&quot;http://www.kanda.com/avr-isp-circuits.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPI buses&lt;/a&gt; as well when a ISP is programming a target, while the target has other SPI chips on the bus, you add series resistors on the SPI bus, as seen below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4h12S.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;R&lt;/strong&gt; is usually between 1k - 4k7ohm. So you method is not a workaround, but normal procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method to use instead of the resistor would be to cut the traces on the &lt;strong&gt;&lt;em&gt;target board&lt;/em&gt;&lt;/strong&gt; for pins &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt;, thus preventing it from going back onto the USB line. This is as I see no need to have control over the USB lines from the target.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Am I missing something? It seems like a programmer should be able to work without worrying about what the pins on the target device are doing. I assumed poorly, that was the purpose behind the RESET pin. Is there a better solution?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The programmer only toggles reset when programming, and once the target is flashed with your firmware that uses the same lines as USB and the PC then does not recognize the programmer because of this, the programmer won't be able to issue a RESET to the target, as  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the PC can't issue it, &lt;/li&gt;&#xA;&lt;li&gt;the programmer won't know to do that on its own.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-05-05T10:05:18.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10571" PostTypeId="1" AcceptedAnswerId="10574" CreationDate="2015-05-05T11:02:57.997" Score="0" ViewCount="747" Body="&lt;p&gt;After countless attemps on making this thing work i'm not sure what the hell is going on. First of all you can't use the normal IR library because Attiny85 is crap and due to timer isses it wont work. So basicaly you need just the specific part which gets the data from the remote and thats all.&#xA;This is what i did but i failed badly again.&lt;/p&gt;&#xA;&lt;p&gt;This time i used the simplest possible code which works perfectly on the Arduino UNO but it wont do anything on the Attiny85&lt;/p&gt;&#xA;&lt;h2&gt;The code&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;int irPin     = 4;&#xA;int tipPin    = 3;&#xA;int start_bit = 2200;    //Start bit threshold (Microseconds)&#xA;int bin_1     = 1000;    //Binary 1 threshold (Microseconds)&#xA;int bin_0     = 400;     //Binary 0 threshold (Microseconds)&#xA;&#xA;boolean state = 0x0;&#xA;&#xA;void setup() {&#xA;   pinMode(tipPin, OUTPUT);&#xA;   pinMode(irPin, INPUT);&#xA;   //Serial.begin(9600);&#xA;   //Serial.println(&amp;quot;IR/Serial Initialized: &amp;quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   int key = getIRKey();   //Fetch the key&#xA;   //Serial.println(key);&#xA;   if (key != 0) {&#xA;     state != state;&#xA;     digitalWrite(tipPin, state);&#xA;   }&#xA;   delay(400);    // avoid double key logging (adjustable)&#xA;}&#xA;&#xA;int getIRKey() {&#xA;  int data[12];&#xA;  int i;&#xA;&#xA;while(pulseIn(irPin, LOW) &amp;lt; start_bit); //Wait for a start bit&#xA;&#xA;for(i = 0 ; i &amp;lt; 11 ; i++)&#xA;  data[i] = pulseIn(irPin, LOW);      //Start measuring bits, I only want   low pulses&#xA;&#xA;  for(i = 0 ; i &amp;lt; 11 ; i++)             //Parse them&#xA;  {&#xA;    if(data[i] &amp;gt; bin_1)                 //is it a 1?&#xA;data[i] = 1;&#xA;else if(data[i] &amp;gt; bin_0)            //is it a 0?&#xA;data[i] = 0;&#xA;else&#xA;return -1;                        //Flag the data as invalid; I don't know what it is! Return -1 on invalid data&#xA;  }&#xA;&#xA;  int result = 0;&#xA;  for(i = 0 ; i &amp;lt; 11 ; i++)             //Convert data bits to integer&#xA;    if(data[i] == 1) result |= (1&amp;lt;&amp;lt;i);&#xA;&#xA;  return result;                        //Return key number&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The ouput values are 3-digit numbers which work OK and i'm not even checking the value here. Just if something came in. And it doesn't bloody work!!!!&lt;/p&gt;&#xA;&lt;h2&gt;Stuff i've already checked&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The circuit&lt;/li&gt;&#xA;&lt;li&gt;If the pin works&lt;/li&gt;&#xA;&lt;li&gt;If the timers are set correctly&lt;/li&gt;&#xA;&lt;li&gt;Using adafruits library&lt;/li&gt;&#xA;&lt;li&gt;Changing every possible core&lt;/li&gt;&#xA;&lt;li&gt;If the receiver works&lt;/li&gt;&#xA;&lt;li&gt;The wiring&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-05T13:35:18.677" Title="IR not working on Attiny85" Tags="|attiny|ir|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10572" PostTypeId="1" CreationDate="2015-05-05T11:37:21.473" Score="1" ViewCount="1012" Body="&lt;p&gt;I want to use Arduino as described in this instructable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But i thought i would give it a little twist by adding a TFT monitor to some devices. I have bought and got the following tft shield to work:&#xA;&lt;a href=&quot;http://www.banggood.com/UNO-R3-ATmega328P-Board-2_4-Inch-TFT-LCD-Screen-Module-For-Arduino-p-945755.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/UNO-R3-ATmega328P-Board-2_4-Inch-TFT-LCD-Screen-Module-For-Arduino-p-945755.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now it strikes me:&#xA;How can i combine the screen on an arduino where i also have a sensor and a radio transmitter?&lt;/p&gt;&#xA;" OwnerUserId="8752" LastActivityDate="2015-05-05T13:12:53.500" Title="How can i use a TFT Screen shield along with other sensors and transmitters" Tags="|lcd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10573" PostTypeId="2" ParentId="10572" CreationDate="2015-05-05T13:12:53.500" Score="1" Body="&lt;p&gt;You need another layer! A breadboard shield - from the &lt;a href=&quot;http://www.banggood.com/buy/Arduino-breadboard-shield.html&quot; rel=&quot;nofollow&quot;&gt;same source&lt;/a&gt; if you like - would seem the obvious answer.&lt;br&gt;&#xA;Alternatively, take flying leads from the pins you are using to the screen &amp;amp; mount it elswhere, then connect the sensors.&lt;br&gt;&#xA;LCD's use quite a few pins, you'll probably need to be creative with an Uno. I have one on a Mega, &amp;amp; have been there with the same problem!&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-05-05T13:12:53.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10574" PostTypeId="2" ParentId="10571" CreationDate="2015-05-05T13:35:18.677" Score="1" Body="&lt;p&gt;If you are trying to toggle the LED when a signal comes in, then there is a glitch in the code and I have no idea how the UNO worked for you as I tried and it only spat out Serial, but didn't do anything with the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try changing this line of code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;state != state;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;to&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;state = !state&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you are not actually toggling the LED &lt;code&gt;state&lt;/code&gt; with the other line, but instead doing a logical &lt;code&gt;not equal to&lt;/code&gt; which won't do what you want.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-05-05T13:35:18.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="10575" PostTypeId="1" AcceptedAnswerId="10577" CreationDate="2015-05-05T14:27:15.000" Score="1" ViewCount="738" Body="&lt;p&gt;I'm trying to understand the difference between programming Arduino hardware (Atel/ARM based) versus 'normal C-based ARM programming'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; is that the Arduino language is cross-compiled into C-compatible binary, and the Arduino EEPROM libraries are used to effectively 'flash' your Arduino code onto the Atel/ARM chip, which is running DuinOS. Your Arduino 'app' (software) can then take advantage of DuinOS utilities, such as scheduling, semaphores, events, critical sections, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; is that if I wanted to program an ARM chip myself from scratch, I would have to use something called an ISP programmer to 'flash' an embedded RTOS onto the chip first. Then, I would have to write C code, compile it, and again use the ISP programmer to deploy the compiled binary to the ARM chip, which is already setup to boot the RTOS when powered on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure I'm mucking up a few things here, but this is my general understanding: can someone correct/clarify these things for me?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-05T15:26:43.083" Title="Arduino/DuinOS vs Normal C/ARM Programming" Tags="|arduino-uno|c|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="10576" PostTypeId="2" ParentId="10552" CreationDate="2015-05-05T15:23:04.577" Score="4" Body="&lt;p&gt;Im with @arvid-jense on this one, if you are working on a serious Digital Clock, then you should get the Real Time Clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you are learning Arduino and want to play with your LCD Minidisplay and build a clock, you must know some important limitations of the &lt;a href=&quot;http://www.arduino.cc/en/Reference/Millis&quot; rel=&quot;nofollow&quot;&gt;millis()&lt;/a&gt; function on this project:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The mills function will overflow, after approximately 50 days.&lt;/li&gt;&#xA;&lt;li&gt;Your clock will be &lt;strong&gt;inexact&lt;/strong&gt; because the cycles of the Arduino&#xA;loop, you will be checking how much mills has passed on each loop.&#xA;&lt;em&gt;(it will be lagging ~ 10 seconds each day, so on day 7 you will be one minute late)&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;the parameter for millis is an unsigned long, errors may be generated&#xA;if a programmer tries to do math with other datatypes such as ints.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That being said&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;/**&#xA; * Clock Variables&#xA; */&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds, minutes, hours;&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;void setup()&#xA;{&#xA;    lcd.begin( 16, 2 ); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    setClock();&#xA;    /**&#xA;     * After set clock now you have 3 int variables with the current time&#xA;     */&#xA;     //seconds&#xA;     //minutes&#xA;     //hours&#xA;     lcd.setCursor ( 0, 1);&#xA;     lcd.print(millis());&#xA;}&#xA;&#xA;void setClock()&#xA;{&#xA;    currentMillis = millis();&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;&#xA;    /**&#xA;     * If we use equals 1000 its possible that because of the mentioned loop limitation&#xA;     * you check the difference when its value is (999) and on the next loop its value is (1001)&#xA;     */&#xA;    if (elapsedMillis &amp;gt; 999){&#xA;        seconds++;&#xA;        elapsedMillis = elapsedMillis - 1000;&#xA;    }&#xA;&#xA;    if (seconds == 60){&#xA;        minutes++;&#xA;        seconds = 0;&#xA;    }&#xA;    if (minutes == 60){&#xA;        hours++;&#xA;        minutes = 0;&#xA;    }&#xA;    if (hours == 24){&#xA;        hours = 0;&#xA;    }&#xA;&#xA;    previousMillis = currentMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Binary-Alarm-Clock/#step1&quot; rel=&quot;nofollow&quot;&gt;Nice tutorial on building an Alarm Clock&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4438" LastEditorUserId="4438" LastEditDate="2015-05-12T20:54:38.667" LastActivityDate="2015-05-12T20:54:38.667" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="10577" PostTypeId="2" ParentId="10575" CreationDate="2015-05-05T15:26:43.083" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding is that the Arduino language is cross-compiled into C-compatible binary,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no &quot;Arduino language&quot;. Programs are written in C++ or C, and the IDE mangles them in certain ways in order to ease development by beginners (and on occasion frustrate development by veterans).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and the Arduino EEPROM libraries are used to effectively 'flash' your Arduino code onto the Atel/ARM chip,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. The uploading of the compiled code is done using a separate program, usually &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVRDUDE&lt;/a&gt; or &lt;a href=&quot;http://www.shumatech.com/web/products/bossa&quot; rel=&quot;nofollow noreferrer&quot;&gt;bossac&lt;/a&gt;, and the code is uploaded into flash. Data can be optionally uploaded into EEPROM via the same program, but this is not required.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;which is running DuinOS. Your Arduino 'app' (software) can then take advantage of DuinOS utilities, such as scheduling, semaphores, events, critical sections, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not by default. If you want to use DuinOS then you will need to download, compile, and upload it yourself.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding is that if I wanted to program an ARM chip myself from scratch, I would have to use something called an ISP programmer to 'flash' an embedded RTOS onto the chip first. Then, I would have to write C code, compile it, and again use the ISP programmer to deploy the compiled binary to the ARM chip, which is already setup to boot the RTOS when powered on.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/80933/do-i-need-an-os-in-my-device&quot;&gt;Nope.&lt;/a&gt; Any system can be run &lt;a href=&quot;https://raspberrypi.stackexchange.com/questions/542/using-raspberry-pi-without-a-linux-os&quot;&gt;without an OS&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2015-05-05T15:26:43.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="10578" PostTypeId="1" AcceptedAnswerId="10582" CreationDate="2015-05-05T16:34:27.310" Score="12" ViewCount="7877" Body="&lt;p&gt;I like the idea of using the Arduino IDE for simple projects and for getting started with Arduino, but the &lt;em&gt;consensus&lt;/em&gt; I've gotten so far is that it is for those who are new to Arduino and/or programming in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; is that it is possible to write a C program from scratch, completely outside of the Arduino IDE, and then use a tool like AVRDUDE to upload it to an Arduino MCU. This option, albeit appealing and interesting, leaves me with a few concerns:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What Arduino libraries would need to be imported/linked by such a &quot;raw C&quot; program? I assume that when an Arduino IDE-based program executes a &lt;code&gt;digitalWrite(...)&lt;/code&gt; it is &lt;em&gt;really&lt;/em&gt; calling a C lib, probably provided by Arduino, under the hood. I am concerned about making sure all these &quot;underlying libs&quot; get included with my C program. Thoughts?&lt;/li&gt;&#xA;&lt;li&gt;Is anything else &quot;lost&quot; by flying solo and venturing outside the Arduino IDE? Any capabilities/features that I would now have to &quot;roll my own&quot;?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2016-05-22T15:57:48.103" Title="Writing C Program outside of Arduino IDE?" Tags="|arduino-ide|library|c|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="10579" PostTypeId="2" ParentId="10578" CreationDate="2015-05-05T16:59:20.113" Score="5" Body="&lt;p&gt;You're absolutely right about needing to link against other libraries. However, you don't necessarily need to worry about all of the details yourself, unless you want/need to do something unusual. Several alternative IDEs already support Arduino, typically via plugins which handle a lot of the details automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I normally recommend Eclipse as it's a very widely used IDE for various purposes. However, there are several other possibilities. See this question for more information:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/40/what-are-the-other-ides-for-arduino&quot;&gt;What are the other IDEs for Arduino?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="42" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-05-05T16:59:20.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10581" PostTypeId="1" AcceptedAnswerId="10584" CreationDate="2015-05-05T18:53:36.740" Score="0" ViewCount="112" Body="&lt;p&gt;I just watched this &lt;a href=&quot;https://www.youtube.com/watch?v=_LCCGFSMOr4&quot; rel=&quot;nofollow&quot;&gt;excellent video tutorial&lt;/a&gt; that shows a simple Arduino program that toggles an LED via a pushbutton. Very cool!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being brand new to electronics/robotics, I was shocked that something as simple as a pushbutton required his &lt;code&gt;debounce&lt;/code&gt; behavior. That's something I would have never thought about in a million years. What is the 'rule of thumb' for when this type of &lt;code&gt;debounce&lt;/code&gt; behavior (regardless of what sensor we're talking about, pushbutton or otherwise) must be accounted for? Is it simply that any type of &lt;em&gt;analog sensor&lt;/em&gt; can generate this kind of unexpected 'noise'?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone provide other examples for when special code must be put in place to accommodate unexpected sensor noise?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-06T06:34:36.327" Title="When and where do I have to worry about accounting for sensor &quot;noise&quot;?" Tags="|arduino-uno|sensors|analogread|analogwrite|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="10582" PostTypeId="2" ParentId="10578" CreationDate="2015-05-05T18:56:01.307" Score="4" Body="&lt;p&gt;Here you are two nice articles how Arduino actually works in background. How it removed friction from microcontroller  programming.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://urbanhonking.com/ideasfordozens/2009/05/18/an_tour_of_the_arduino_interna/&quot; rel=&quot;nofollow noreferrer&quot;&gt;A Tour of the Arduino Internals: How does Hello World actually work?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ashleymills.com/node/327&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino and GCC, compiling and uploading programs using only makefiles&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It was also discussed here &lt;a href=&quot;https://stackoverflow.com/questions/10307496/is-there-a-way-or-tutorial-for-converting-arduino-code-to-c-code?rq=1&quot;&gt;Is there a way or tutorial for converting Arduino code to C code?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9866" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-05-05T18:56:01.307" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10583" PostTypeId="1" CreationDate="2015-05-05T18:53:18.993" Score="-5" ViewCount="709" Body="&lt;p&gt;How do I ever understand what the Arduino IDE means when they advise you of any errors?  The reason I ask is because I got several errors that don't make sense to me as I see what the error means and what line the issue is but I don't see anything wrong with the code. It's written how it should be, the reason I say this is because before I ended the code I was compiling/verifying my code every time I write a new line just to make sure if I got new errors. It's easy to check as it was more than likely the very last line of code I just wrote, rather than write a book then do a spell check you know? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have included the part of the code where I get errors and the errors themselves. Hopefully someone can point out to me what is it that Arduino sees that I don't and in the same token I'll learn how to counter measure those errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.  //imu's&#xA;2.  #include &quot;Wire.h&quot; // i dont think this will be needed on this mcu's &quot;slaves&quot;&#xA;3.  #include &quot;I2Cdev.h&quot; // i dont think this will be needed on this mcu's &quot;slaves&quot;&#xA;4.  #include &quot;MPU6050.h&quot; // i dont think this will be needed on this mcu's &quot;slaves&quot;&#xA;5.  &#xA;6.  //motors&#xA;7.  #include &quot;Servo.h&quot; // select which motor this slave mcu has and comment out the other&#xA;8.  #include &quot;Stepper.h&quot; // select which motor this slave mcu has and comment out the other&#xA;9.  &#xA;10. //wireless&#xA;11. #include &quot;nRF24L01.h&quot;&#xA;12. #include &quot;RF24.h&quot;&#xA;13. #include &quot;SPI.h&quot; // i dont think this will be needed on this mcu's &quot;slaves&quot;&#xA;14. &#xA;15. #define RF_CS 12&#xA;16. #define RF_CSN 13&#xA;17. RF24 radio(RF_CS, RF_CSN);//RF24 radio(9, 10);&#xA;18. const int pinCE = 9;&#xA;19. const int pinCSN = 10;&#xA;20. &#xA;21. byte bArray[] = {0000, 1000, 0100, 1100, 0010, 1010, 0110, 1110}; // this are the Ch 0/7 address from Mux&#xA;22. const uint64_t LA = 0xF0F0F0F0D2LL;//mcu1 address of Slave&#xA;23. const uint64_t RA = 0xF0F0F0F0C3LL;//mcu2 address of Slave&#xA;24. const uint64_t LL = 0xF0F0F0F0B4LL;//mcu3 address of Slave&#xA;25. const uint64_t RL = 0xF0F0F0F0A5LL;//mcu4 address of Slave&#xA;26. const uint64_t LW = 0xF0F0F0F0E6LL;//mcu5 address of Slave&#xA;27. const uint64_t RW = 0xF0F0F0F0F7LL;//mcu6 address of Slave&#xA;28. const uint64_t UT = 0xF0F0F0F0F8LL;//mcu7 address of Slave&#xA;29. const uint64_t BT = 0xF0F0F0F0F9LL;//mcu8 address of Slave&#xA;30. &#xA;31. /* MUX CH address To simplify things, 1 is HIGH, 0 is LOW&#xA;32.                                                                     0000 – 0&#xA;33.                                                                     1000 – 1&#xA;34.                   A multiplexer of this sort really just            0100 – 2&#xA;35.                   acts as a 16 to one 1 switch. The 4 digital       1100 – 3&#xA;36.                   pins are used to set HIGH or LOW, in a binary     0010 – 4&#xA;37.                   fashion (0-15) to determine what pin “SIG” is      1010 – 5&#xA;38.                   connected to. So bringing all 4 pins LOW would    0110 – 6&#xA;39.                   switch the CD74HC4067 to channel 0 (so SIG and    1110 – 7&#xA;40.                   C0 would be connected), bringing them all HIGH    0001 – 8&#xA;41.                   would switch it to 15 (so SIG and C15 would be    1001 – 9&#xA;42.                   connected)                                        0101 – 10&#xA;43.                                                                     1101 – 11&#xA;44.                                                                     0011 – 12&#xA;45.                                                                     1011 – 13&#xA;46.                                                                     0111 – 14&#xA;47.                                                                     1111 – 15 */&#xA;48. &#xA;49. int recivers[8][4] = {&#xA;50.   { 0xF0F0F0F0D2LL, { 0, 0, 0, 0 }, //0000 – 0 SDATA line from MPU to Multiplexer ch0&#xA;51.     { 0xF0F0F0F0C3LL, { 1, 0, 0, 0 }, //1000 – 1 SDATA line from MPU to Multiplexer ch1&#xA;52.       { 0xF0F0F0F0B4LL, { 0, 1, 0, 0,}, //0100 – 2 SDATA line from MPU to Multiplexer ch2&#xA;53.         { 0xF0F0F0F0A5LL, { 1, 1, 0, 0 }, //1100 – 3 SDATA line from MPU to Multiplexer ch3&#xA;54.           { 0xF0F0F0F0D6LL, { 0, 0, 1, 0 }, //0010 – 4 SDATA line from MPU to Multiplexer ch4&#xA;55.             { 0xF0F0F0F0E7LL, { 1, 0, 1, 0 }, //1010 – 5 SDATA line from MPU to Multiplexer ch5&#xA;56.               { 0xF0F0F0F0F8LL, { 0, 1, 1, 0 }, //0110 – 6 SDATA line from MPU to Multiplexer ch6&#xA;57.                 { 0xF0F0F0F0F9LL, { , 1, 1, 1, 0 } //1110 – 7 SDATA line from MPU to Multiplexer ch7&#xA;58.                 }&#xA;59.               }&#xA;60.             }&#xA;61.           }&#xA;62.         }&#xA;63.       }&#xA;64.     }&#xA;65.   }&#xA;66. }&#xA;67. &#xA;68. MPU6050 mpu;&#xA;69. int16_t ax, ay, az;&#xA;70. int16_t gx, gy, gz;&#xA;71. &#xA;72. long long  val[6];//6 DOF MPU 6050 thats where this val{6} come from&#xA;73. long val;&#xA;74. long prevVal;&#xA;75. &#xA;76. byte bArray[] = ( 0, 180 );&#xA;77. &#xA;78. //Mux control pins on the Arduino Digital pins&#xA;79. int s0 = 8;&#xA;80. int s1 = 7;&#xA;81. int s2 = 6;&#xA;82. int s3 = 5;&#xA;83. &#xA;84. //Mux in &quot;SIG&quot; pin&#xA;85. int SIG_pin = 0;&#xA;86. //int val = readMux(7);&#xA;87. &#xA;88. void setup()&#xA;89. {&#xA;90.   pinMode(s0, OUTPUT);&#xA;91.   pinMode(s1, OUTPUT);&#xA;92.   pinMode(s2, OUTPUT);&#xA;93.   pinMode(s3, OUTPUT);&#xA;94. &#xA;95.   digitalWrite(s0, LOW);&#xA;96.   digitalWrite(s1, LOW);&#xA;97.   digitalWrite(s2, LOW);&#xA;98.   digitalWrite(s3, LOW);&#xA;99. &#xA;100.      Wire.begin();&#xA;101.    &#xA;102.      for (int i = 0; i &amp;lt; 10; i++) //10 mpu's&#xA;103.      {&#xA;104.        mpu.initialize();&#xA;105.      }&#xA;106.    &#xA;107.      radio.begin();&#xA;108.      radio.payload = 6;&#xA;109.      radio.setAutoAck(false);&#xA;110.      radio.setDataRate(RF24_2MBPS);&#xA;111.      radio.openWritingPipe();&#xA;112.    }&#xA;113.    &#xA;114.    void loop()&#xA;115.    {&#xA;116.      for (int i = 0; i &amp;lt; 16; i ++)//Loop through and read all 16 values&#xA;117.      {&#xA;118.        int readMux(int channel)&#xA;119.    &#xA;120.        int controlPin[] = {s0, s1, s2, s3};&#xA;121.    &#xA;122.        int muxChannel[8][4] = {&#xA;123.          {0, 0, 0, 0}, //channel 0&#xA;124.          {1, 0, 0, 0}, //channel 1&#xA;125.          {0, 1, 0, 0}, //channel 2&#xA;126.          {1, 1, 0, 0}, //channel 3&#xA;127.          {0, 0, 1, 0}, //channel 4&#xA;128.          {1, 0, 1, 0}, //channel 5&#xA;129.          {0, 1, 1, 0}, //channel 6&#xA;130.          {1, 1, 1, 0}, //channel 7&#xA;131.          {0, 0, 0, 1}, //channel 8&#xA;132.          {1, 0, 0, 1}, //channel 9&#xA;133.          //  {0, 1, 0, 1}, //channel 10&#xA;134.          //  {1, 1, 0, 1}, //channel 11&#xA;135.          //  {0, 0, 1, 1}, //channel 12&#xA;136.          //  {1, 0, 1, 1}, //channel 13&#xA;137.          //  {0, 1, 1, 1}, //channel 14&#xA;138.          //  {1, 1, 1, 1}  //channel 15&#xA;139.        }&#xA;140.      }&#xA;141.      //loop through the 4 sig&#xA;142.      for (int i = 0; i &amp;lt; 4; i ++)&#xA;143.      {&#xA;144.        digitalWrite(controlPin[i], muxChannel[channel][i]);&#xA;145.      }&#xA;146.    &#xA;147.      //read the value at the SIG pin&#xA;148.      int val = analogRead(SIG_pin);&#xA;149.    &#xA;150.      //return the value&#xA;151.      return val;&#xA;152.    &#xA;153.      for (int i = 0; i &amp;lt; 6 i++)&#xA;154.      {&#xA;155.        mpu.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;156.        val[0] = map(ax, -17000, 17000, 0, 180);&#xA;157.        val[1] = map(ay, -17000, 17000, 0, 180);&#xA;158.        val[2] = map(az, -17000, 17000, 0, 180);&#xA;159.        val[3] = map(gz, -17000, 17000, 0, 180);&#xA;160.        val[4] = map(gy, -17000, 17000, 0, 180);&#xA;161.        val[5] = map(gx, -17000, 17000, 0, 180);&#xA;162.    &#xA;163.        radio.openWritingPipe(recievers[i].address);&#xA;164.        radio.write(val);&#xA;165.      }&#xA;166.    &#xA;167.      delay(50);&#xA;&#xA;&#xA;    Arduino: 1.6.4 (Windows 8.1), Board: &quot;Arduino Nano, ATmega328&quot;&#xA;&#xA;    sketch_may19a:57: error: expected primary-expression before ',' token&#xA;    sketch_may19a:66: error: braces around scalar initializer for type 'int'&#xA;    sketch_may19a:68: error: expected ',' or ';' before 'MPU6050'&#xA;    sketch_may19a:73: error: conflicting declaration 'long int val'&#xA;    sketch_may19a:72: error: 'val' has a previous declaration as 'long long int                val [6]'&#xA;    sketch_may19a:76: error: redefinition of 'byte bArray []'&#xA;    sketch_may19a:21: error: 'byte bArray [8]' previously defined here&#xA;    sketch_may19a.ino: In function 'void setup()':&#xA;    sketch_may19a:104: error: 'mpu' was not declared in this scope&#xA;    sketch_may19a:108: error: 'class RF24' has no member named 'payload'&#xA;    sketch_may19a:111: error: no matching function for call to         'RF24::openWritingPipe()'&#xA;    sketch_may19a.ino:111:25: note: candidate is:&#xA;    In file included from sketch_may19a.ino:12:0:&#xA;    C:\Program Files (x86)\Arduino\libraries\RF24/RF24.h:324:8: note: void     RF24::openWritingPipe(uint64_t)&#xA;    void openWritingPipe(uint64_t address);&#xA;    ^&#xA;    C:\Program Files (x86)\Arduino\libraries\RF24/RF24.h:324:8: note:   candidate         expects 1 argument, 0 provided&#xA;    sketch_may19a.ino: In function 'void loop()':&#xA;    sketch_may19a:120: error: expected initializer before 'int'&#xA;    sketch_may19a:139: error: too many initializers for 'int [8][4]'&#xA;    sketch_may19a:140: error: expected ',' or ';' before '}' token&#xA;    sketch_may19a:144: error: 'controlPin' was not declared in this scope&#xA;    sketch_may19a:144: error: 'muxChannel' was not declared in this scope&#xA;    sketch_may19a:144: error: 'channel' was not declared in this scope&#xA;    sketch_may19a:151: error: return-statement with a value, in function     returning     'void' [-fpermissive]&#xA;    sketch_may19a:153: error: expected ';' before 'i'&#xA;    sketch_may19a:155: error: 'mpu' was not declared in this scope&#xA;    sketch_may19a:156: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:157: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:158: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:159: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:160: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:161: error: invalid types 'int[int]' for array subscript&#xA;    sketch_may19a:163: error: 'recievers' was not declared in this scope&#xA;    sketch_may19a:164: error: no matching function for call to 'RF24::write(int&amp;amp;)'&#xA;    sketch_may19a.ino:164:20: note: candidate is:&#xA;    In file included from sketch_may19a.ino:12:0:&#xA;    C:\Program Files (x86)\Arduino\libraries\RF24/RF24.h:281:8: note: bool     RF24::write(const void*, uint8_t)&#xA;   bool write( const void* buf, uint8_t len );&#xA;    ^&#xA;    C:\Program Files (x86)\Arduino\libraries\RF24/RF24.h:281:8: note:candidate     expects 2 arguments, 1 provided&#xA;    expected primary-expression before ',' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9881" OwnerDisplayName="Frank's Desig'Nature" LastEditorUserId="11529" LastEditDate="2016-01-20T22:37:36.120" LastActivityDate="2016-01-20T22:37:36.120" Title="nRF24L01+ Arduino mpu6050" Tags="|arduino-ide|compile|" AnswerCount="1" CommentCount="6" ClosedDate="2015-05-19T23:09:42.733" ContentLicense="CC BY-SA 3.0" />
  <row Id="10584" PostTypeId="2" ParentId="10581" CreationDate="2015-05-05T19:42:29.380" Score="1" Body="&lt;p&gt;Switch bounce is a physical issue that can be cleaned up with filtering. Since the sense states are very simple, only very crude (time-based) filtering is required to clean up its signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other mechanical sensors that can exhibit similar characteristics are bump sensors, tilt sensors, and accelerometers. Bump and tilt sensors are also very simple, and similar filtering will clean up their signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accelerometers on the other hand react to very minute perturbations, so they may require more advanced filtering based on the application they will be used in; orientation sensing can use time-based filtering, whereas things such as motion tracking including dead reckoning will require one or more layers of calculus in order to clean up the signal.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-05T19:42:29.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="10585" PostTypeId="1" CreationDate="2015-05-05T19:57:56.433" Score="2" ViewCount="195" Body="&lt;p&gt;I am using a Ruggeduino for a project involving an autonomous vehicle, and I need GPS capability in it. I am using the &quot;VPN1513 GPS Smart Module with External Antenna&quot; from Parallax (&lt;a href=&quot;https://www.parallax.com/product/28510&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.parallax.com/product/28510&lt;/a&gt;), and the TinyGPS Library (&lt;a href=&quot;http://arduiniana.org/libraries/tinygps/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduiniana.org/libraries/tinygps/&lt;/a&gt;). I have it supplied with 5v, grounded, and with the SIG and EN wires going to ports 0 and 1 on the Ruggeduino. Everything that I have done so far has resulted in this example program from the library returning &quot;****&quot;, which means it is getting invalid data. Does anyone know what I'm doing wrong? Thank's for the help in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the program:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;TinyGPS gps;&#xA;SoftwareSerial nss(1, 0);&#xA;&#xA;static void gpsdump(TinyGPS &amp;amp;gps);&#xA;static bool feedgps();&#xA;static void print_float(float val, float invalid, int len, int prec);&#xA;static void print_int(unsigned long val, unsigned long invalid, int len);&#xA;static void print_date(TinyGPS &amp;amp;gps);&#xA;static void print_str(const char *str, int len);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  nss.begin(9600);&#xA;&#xA;  Serial.print(&quot;Testing TinyGPS library v. &quot;); &#xA;  Serial.println(TinyGPS::library_version());&#xA;  Serial.println(&quot;by Mikal Hart&quot;);&#xA;  Serial.println();&#xA;  Serial.print(&quot;Sizeof(gpsobject) = &quot;); &#xA;  Serial.println(sizeof(TinyGPS));&#xA;  Serial.println();&#xA;  Serial.println(&quot;Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum&quot;);&#xA;  Serial.println(&quot;          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail&quot;);&#xA;  Serial.println(&quot;--------------------------------------------------------------------------------------------------------------------------------------&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  bool newdata = false;&#xA;  unsigned long start = millis();&#xA;&#xA;  // Every second we print an update&#xA;  while (millis() - start &amp;lt; 1000)&#xA;  {&#xA;    if (feedgps())&#xA;      newdata = true;&#xA;  }&#xA;&#xA;  gpsdump(gps);&#xA;}&#xA;&#xA;static void gpsdump(TinyGPS &amp;amp;gps)&#xA;{&#xA;  float flat, flon;&#xA;  unsigned long age, date, time, chars = 0;&#xA;  unsigned short sentences = 0, failed = 0;&#xA;  static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;&#xA;&#xA;  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);&#xA;  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);&#xA;  gps.f_get_position(&amp;amp;flat, &amp;amp;flon, &amp;amp;age);&#xA;  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);&#xA;  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);&#xA;  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;&#xA;  print_date(gps);&#xA;&#xA;  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);&#xA;  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);&#xA;  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(gps.f_course()), 6);&#xA;  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);&#xA;  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);&#xA;&#xA;  gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed);&#xA;  print_int(chars, 0xFFFFFFFF, 6);&#xA;  print_int(sentences, 0xFFFFFFFF, 10);&#xA;  print_int(failed, 0xFFFFFFFF, 9);&#xA;  Serial.println();&#xA;}&#xA;&#xA;static void print_int(unsigned long val, unsigned long invalid, int len)&#xA;{&#xA;  char sz[32];&#xA;  if (val == invalid)&#xA;    strcpy(sz, &quot;*******&quot;);&#xA;  else&#xA;    sprintf(sz, &quot;%ld&quot;, val);&#xA;  sz[len] = 0;&#xA;  for (int i=strlen(sz); i&amp;lt;len; ++i)&#xA;    sz[i] = ' ';&#xA;  if (len &amp;gt; 0) &#xA;    sz[len-1] = ' ';&#xA;  Serial.print(sz);&#xA;  feedgps();&#xA;}&#xA;&#xA;static void print_float(float val, float invalid, int len, int prec)&#xA;{&#xA;  char sz[32];&#xA;  if (val == invalid)&#xA;  {&#xA;    strcpy(sz, &quot;*******&quot;);&#xA;    sz[len] = 0;&#xA;    if (len &amp;gt; 0) &#xA;      sz[len-1] = ' ';&#xA;    for (int i=7; i&amp;lt;len; ++i)&#xA;      sz[i] = ' ';&#xA;    Serial.print(sz);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(val, prec);&#xA;    int vi = abs((int)val);&#xA;    int flen = prec + (val &amp;lt; 0.0 ? 2 : 1);&#xA;    flen += vi &amp;gt;= 1000 ? 4 : vi &amp;gt;= 100 ? 3 : vi &amp;gt;= 10 ? 2 : 1;&#xA;    for (int i=flen; i&amp;lt;len; ++i)&#xA;      Serial.print(&quot; &quot;);&#xA;  }&#xA;  feedgps();&#xA;}&#xA;&#xA;static void print_date(TinyGPS &amp;amp;gps)&#xA;{&#xA;  int year;&#xA;  byte month, day, hour, minute, second, hundredths;&#xA;  unsigned long age;&#xA;  gps.crack_datetime(&amp;amp;year, &amp;amp;month, &amp;amp;day, &amp;amp;hour, &amp;amp;minute, &amp;amp;second, &amp;amp;hundredths, &amp;amp;age);&#xA;  if (age == TinyGPS::GPS_INVALID_AGE)&#xA;    Serial.print(&quot;*******    *******    &quot;);&#xA;  else&#xA;  {&#xA;    char sz[32];&#xA;    sprintf(sz, &quot;%02d/%02d/%02d %02d:%02d:%02d   &quot;,&#xA;    month, day, year, hour, minute, second);&#xA;    Serial.print(sz);&#xA;  }&#xA;  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;  feedgps();&#xA;}&#xA;&#xA;static void print_str(const char *str, int len)&#xA;{&#xA;  int slen = strlen(str);&#xA;  for (int i=0; i&amp;lt;len; ++i)&#xA;    Serial.print(i&amp;lt;slen ? str[i] : ' ');&#xA;  feedgps();&#xA;}&#xA;&#xA;static bool feedgps()&#xA;{&#xA;  while (nss.available())&#xA;  {&#xA;    if (gps.encode(nss.read()))&#xA;      return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9882" LastEditorUserId="37523" LastEditDate="2019-08-23T02:23:27.247" LastActivityDate="2019-08-23T02:23:27.247" Title="Using Parallax VPN1513 GPS Smart Module with External Antenna and Ruggeduino" Tags="|softwareserial|gps|tinygps|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="10586" PostTypeId="1" CreationDate="2015-05-05T20:39:07.053" Score="0" ViewCount="882" Body="&lt;p&gt;I'm wondering if using the &lt;a href=&quot;https://www.adafruit.com/products/1411&quot; rel=&quot;nofollow&quot;&gt;Adafruit 16-Channel 12-bit PWM/Servo Shield&lt;/a&gt; is it possible to switch relays, such as use that shield as a multiplexer and use digital output without PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? example code?&lt;/p&gt;&#xA;" OwnerUserId="1335" LastActivityDate="2019-07-21T17:51:39.540" Title="Use Adafruit 16-Channel 12-bit PWM/Servo Shield to switch relays" Tags="|pwm|adafruit|multiplexer|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11586" PostTypeId="1" AcceptedAnswerId="11587" CreationDate="2015-05-06T00:10:43.870" Score="0" ViewCount="131" Body="&lt;p&gt;I just watched this &lt;a href=&quot;https://www.youtube.com/watch?v=_LCCGFSMOr4&quot; rel=&quot;nofollow&quot;&gt;excellent video tutorial&lt;/a&gt; that shows a simple Arduino program that toggles an LED via a pushbutton. Very cool!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the video, the author is using a breadboard for prototyping his circuit. What's the next &quot;step up&quot; from this? In other words, say I get my breadboard circuit working perfectly, is it now time to create a PCB? If my understanding of circuitry is correct, this is &lt;em&gt;not&lt;/em&gt; a trivial process. I would need a CAD program to design my circuit, and it would likely be very expensive to get the design actually fabricated. At least too expensive for simple hobby purposes. &lt;strong&gt;Is there a middle ground between breadboard and PCB?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-06T15:06:59.893" Title="Arduino: Breadboards and PCBs" Tags="|arduino-uno|system-design|prototype|" AnswerCount="4" CommentCount="1" ClosedDate="2015-05-12T23:45:02.467" ContentLicense="CC BY-SA 3.0" />
  <row Id="11587" PostTypeId="2" ParentId="11586" CreationDate="2015-05-06T02:58:21.507" Score="3" Body="&lt;p&gt;You can build your project on stripboard (aka Veroboard, which is a particular brand). The wiki page at &lt;a href=&quot;http://en.wikipedia.org/wiki/Stripboard&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Stripboard&lt;/a&gt; covers most of the salient points - it is essentially a generic PCB. You can cut tracks, either with a knife, or a specialized tool, and you can solder your parts on to the tracks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They come in various configurations - my personal preference is just straight strips - and you can cut them to size with a hacksaw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your project is non-trivial, you might still like to spend some time working out a decent layout. There are free, and not quite free, products to help you - I use Kicad, which is free &amp;amp; opensource, there are many others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also used stripboard to group a few components together - for example, 2 7-segment displays and two SIPO chips to run them - this can then be a &quot;component&quot; for future bread-board projects.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-05-06T02:58:21.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11588" PostTypeId="2" ParentId="3167" CreationDate="2015-05-06T03:47:36.463" Score="0" Body="&lt;p&gt;To speak to the point of the question, and what the author was attempting to accomplish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of this code actually works as a whole. The data would get over written and just keep looping continuously... anyway here is a working example of the original code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method I prefer to clear an array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    for( int i = 0; i &amp;lt; sizeof(data);  ++i )&#xA;    data[i] = (char)0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is working example. ( Make sure to select Carriage Return on the serial monitor )&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char message[32];&#xA;    uint8_t incomingByte = 0; &#xA;    uint8_t BufferPos = 0;&#xA;    int clearbyte = 0;&#xA;&#xA;&#xA;    void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;\n String conversion testing&quot;);&#xA;&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;       if (BufferPos &amp;gt;= 32) {&#xA;              Serial.print(&quot;Buffer Full\n&quot;);&#xA;              BufferPos = 00;&#xA;              incomingByte = 0;&#xA;&#xA;       }  &#xA;&#xA;      if (Serial.available()) {&#xA;             incomingByte = Serial.read();&#xA;             message[BufferPos++]= incomingByte;   &#xA;&#xA;         switch(incomingByte)&#xA;      {&#xA;           case '\n':&#xA;           case ' ':&#xA;             break;&#xA;           case '\r':&#xA;              Serial.println(message); &#xA;&#xA;          for( int i = 0; i &amp;lt; sizeof(message);  ++i )&#xA;         message[i] = (char)0;&#xA;              BufferPos= 0;&#xA;              incomingByte= 0;&#xA;&#xA;      }&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9886" LastActivityDate="2015-05-06T03:47:36.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11589" PostTypeId="2" ParentId="11586" CreationDate="2015-05-06T06:05:31.753" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://www.cadsoftusa.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eagle CAD&lt;/a&gt; is one of the most popular E-CAD programs, and is reasonably priced &lt;a href=&quot;http://www.cadsoftusa.com/download-eagle/freeware/&quot; rel=&quot;nofollow noreferrer&quot;&gt;free&lt;/a&gt; for personal use. When Libraries, tutorials and examples are made available it is most often in Eagle CAD format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5dQxx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you ready your design and layout (in Eagle) you can get boards made for $30ish (&lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://oshpark.com/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have to obtain parts and solder yourself for assembly, but your time is free, right?  I have done a few. I was a software only person until I started in November 2014 (&lt;a href=&quot;http://www.spiked3.com/?p=5981&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.spiked3.com/?p=5981&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-06T06:23:29.983" LastActivityDate="2015-05-06T06:23:29.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11590" PostTypeId="2" ParentId="10581" CreationDate="2015-05-06T06:34:36.327" Score="0" Body="&lt;p&gt;Anyone who believes sensors do not have noise has never used one.  True you may not encounter noise while reading the digital information, but I promise you the information will have noise in it.  Noise from a switch can be dealt with by hardware or software, such as his debounce behavior.  Other sensor noise is 4 years of study at college.  Look into Kalman Filters, probabilistic robotics.  Even the self driving cars you hear about currently require large compute capacity, mostly in order to deal with sensor noise.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-06T06:34:36.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11592" PostTypeId="1" AcceptedAnswerId="11596" CreationDate="2015-05-06T08:28:02.360" Score="2" ViewCount="20568" Body="&lt;p&gt;I was perusing Arduino's list of official shields and noticed the &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoMotorShieldR3&quot; rel=&quot;nofollow&quot;&gt;Motor Shield&lt;/a&gt; that can be used to drive up to 2 servo motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being brand new to Arduino/robotics, I am wondering: do I &lt;em&gt;really&lt;/em&gt; need this shield to drive a set of servos?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What does this shield really offer in the way of driving motors?&lt;/li&gt;&#xA;&lt;li&gt;What is lost by &lt;em&gt;not&lt;/em&gt; using this shield?&lt;/li&gt;&#xA;&lt;li&gt;What if I my project has more than 2 motors?!?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-06T17:10:52.957" Title="Do I need the Motor Shield to drive servo motors?" Tags="|arduino-uno|motor|servo|arduino-motor-shield|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11593" PostTypeId="2" ParentId="11586" CreationDate="2015-05-06T08:42:34.403" Score="0" Body="&lt;p&gt;If you are only making one or two the following works well:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Download Kicad (Free) and design your board.&lt;/li&gt;&#xA;&lt;li&gt;Print out the layout on special film, and transfer to a blank PCB using a domestic iron.An example: &lt;a href=&quot;http://www.maplin.co.uk/p/press-and-peel-film-pcb-transfer-system-ab15r&quot; rel=&quot;nofollow&quot;&gt;http://www.maplin.co.uk/p/press-and-peel-film-pcb-transfer-system-ab15r&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Etch the board in ammonium persulphate or ferric chloride solution.&lt;/li&gt;&#xA;&lt;li&gt;Drill the holes. You will need some 0.8 and 1.0mm drills and a Dremel drill press or similar.&lt;/li&gt;&#xA;&lt;li&gt;Mount your components and solder away.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The above works well for single-sided boards. Double sided are possible, but will take some practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a learning curve getting to grips with Kicad, but if you are serious about electroncs, the time invested is well worthwhile. I got from being a Kicad novice to producing a specialist Arduino shield in a weekend. I had the advantage of having used similar tools in the past, and the disadvantage of being 67 years old (with eyesight to suit)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the required parts should be available from agood electronics parts suppier (For example Jaycay here in New Zealand)&lt;/p&gt;&#xA;" OwnerUserId="881" LastActivityDate="2015-05-06T08:42:34.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11594" PostTypeId="1" AcceptedAnswerId="11597" CreationDate="2015-05-06T08:49:04.413" Score="2" ViewCount="144" Body="&lt;p&gt;I am interested in using the &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;Arduino Due&lt;/a&gt; in an upcoming project, however I am worried that the other shields/components that I need will not be compatible with it, because, according to that link:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Due is compatible with all Arduino shields that work at 3.3V and are compliant with the 1.0 Arduino pinout.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The components I need to use are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;NightShade Electronics &lt;a href=&quot;http://www.ns-electric.com/products/energyshield/&quot; rel=&quot;nofollow&quot;&gt;energyShield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/200&quot; rel=&quot;nofollow&quot;&gt;Solar Panel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/1143?gclid=CjwKEAjw96aqBRDNhM6MtJfE-wYSJADiMfgguI7rTduiPEzHwVkcWxKifp1IMtwpI6VHO8btHORRKBoCStHw_wcB&quot; rel=&quot;nofollow&quot;&gt;Servo Motors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Essentially a solar panel will power the energyShield (rechargeable battery), which in turn will power multiple servo motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot tell if the energyShield uses the 1.0 pinout or not. I am also worried that since the the solar power generates 6V it will overload the energyShield which is rated at 3.3V. At the same time, I am worried that the servo motors, which seem to require 4.8V, will not be capable of being powered by the energyShield which outputs 3.3V. Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bonus Points if someone can explain to me what the &quot;1.0 Pinout&quot; is, and whether it is the latest/most modern pinout available for Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="9842" LastEditorUserId="9842" LastEditDate="2015-05-06T09:43:29.980" LastActivityDate="2015-05-16T08:19:05.450" Title="How to tell what components are compatible with Arduino Due?" Tags="|motor|arduino-due|electronics|solar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11595" PostTypeId="2" ParentId="11592" CreationDate="2015-05-06T08:51:43.330" Score="2" Body="&lt;p&gt;The Motor Shield is for driving bare motors, not servos. Servos already include drive electronics and only require a PWM signal in order to control them, whereas the Motor Shield provides the drive electronics for bare motors.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-06T08:51:43.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11596" PostTypeId="2" ParentId="11592" CreationDate="2015-05-06T11:36:34.977" Score="1" Body="&lt;p&gt;The shield will drive a pair of DC motors (the common small ones in models), or one stepper motor (the precision motors you find in dead printers, etc), and can also connect onwards to other stuff, which happens to include servos. I certainly wouldn't get one to run a servo...&lt;br&gt;&#xA;If you want more than two motors, there are other motor shields, or you could make a custom board to suit.&#xA;There isn't enough power from Arduino outputs to drive a motor (in general) so some sort of driver is needed - for a simple DC motor, a simple transistor would do, you need bridges for steppers, or ESC's for RC-model type high-power motors. Servo's have their own drivers built-in, so can just plug-in to Arduino.&lt;br&gt;&#xA;If you just want to control a couple of motors or a single stepper, the shield is quick &amp;amp; easy, which is where it is placed in the market.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-05-06T11:36:34.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11597" PostTypeId="2" ParentId="11594" CreationDate="2015-05-06T11:39:46.723" Score="2" Body="&lt;p&gt;As far as I understood this energyShiled accepts any input between 5-24V and output 5 - 3.3V. This specs are compatible with arduino Due. And with the solar panel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always power servos from seperate source or from the same battery but with seperate direct line.&lt;/p&gt;&#xA;" OwnerUserId="8687" LastEditorUserId="8687" LastEditDate="2015-05-16T08:19:05.450" LastActivityDate="2015-05-16T08:19:05.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11598" PostTypeId="2" ParentId="11586" CreationDate="2015-05-06T11:50:22.080" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a middle ground between breadboard and PCB?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A prototype PCB with breadboardlike layout is a fast way to turn a breadboard design into a permanent build. So it may be in the range of valid answers to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(-: &lt;em&gt;The link below is just an example, there are lots of other names, designs and sellers and I am in no way releated to any of those...&lt;/em&gt; :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.tindie.com/products/Schmart/400-tiepoint-schmartboard-breadproto-board-bundle/&quot; rel=&quot;nofollow&quot;&gt;https://www.tindie.com/products/Schmart/400-tiepoint-schmartboard-breadproto-board-bundle/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="653" LastEditDate="2015-05-06T15:06:59.893" LastActivityDate="2015-05-06T15:06:59.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11599" PostTypeId="1" AcceptedAnswerId="12907" CreationDate="2015-05-06T14:20:03.077" Score="3" ViewCount="1076" Body="&lt;p&gt;I run into this problem when I mess something up, and it's pretty annoying to wait for 10 not in sync timeouts before I can try some different method.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x85&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I set the number of &quot;attempts&quot; to say 2 instead of 10? Or how can I safely interrupt the upload process in the IDE?&lt;/p&gt;&#xA;" OwnerUserId="1281" LastActivityDate="2015-06-25T12:00:23.947" Title="how can I change the setting for number of upload retries in the IDE?" Tags="|arduino-ide|avrdude|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11600" PostTypeId="2" ParentId="10586" CreationDate="2015-05-06T14:34:36.597" Score="1" Body="&lt;p&gt;That will work. Just make sure you are not using Servo part of the library, but only the PWM part, and set the duty cycle to 100%. The relay should still work, even if the duty cycle is slightly lower, as the magnetic field takes a bit of time to collapse. Just make sure you don't forget to add a (flyback) diode to the relay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the datasheet I think you need to use the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pwm.setPWMFreq(1000);//put this in setup()&#xA;...&#xA;// enable relay at channel 15&#xA;pwm.setPWM(15, 1, 0);&#xA;...&#xA;// disable relay at channel 15&#xA;pwm.setPWM(15, 1, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-06T14:34:36.597" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11601" PostTypeId="1" AcceptedAnswerId="11606" CreationDate="2015-05-06T16:14:50.090" Score="8" ViewCount="21416" Body="&lt;p&gt;Where can I see outputs from such instruction in an ino file ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;my message&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user9891" LastEditorDisplayName="user9891" LastEditDate="2017-01-09T13:26:28.420" LastActivityDate="2021-09-11T05:12:21.890" Title="How to see log from Arduino IDE?" Tags="|arduino-ide|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11602" PostTypeId="1" AcceptedAnswerId="11604" CreationDate="2015-05-06T16:16:42.673" Score="0" ViewCount="1920" Body="&lt;p&gt;at &lt;a href=&quot;http://www.ftdichip.com/FTDrivers.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.ftdichip.com/FTDrivers.htm&lt;/a&gt; they seem to divide chips into two categories,  FT4222H vs. D2XX driver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the correct for a arduino nano?&lt;/p&gt;&#xA;" OwnerUserId="9900" LastActivityDate="2015-05-06T17:05:55.987" Title="what ftdi windows driver for arduino nano" Tags="|arduino-nano|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11603" PostTypeId="2" ParentId="11592" CreationDate="2015-05-06T17:04:08.860" Score="2" Body="&lt;p&gt;You don't need this shield to drive &lt;em&gt;servo&lt;/em&gt; motors, they have their own controller, you need just a 5V power line, GND and digital output pin to generate a PWM and that's it. Usually Arduino has enough power to drive &lt;strong&gt;servo motors&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shield you are talking about is used for DC (direct current) and stepper motor. These motors need power gain and the shield provides it and often has a chip called L298N (which implements &lt;a href=&quot;http://en.m.wikipedia.org/wiki/H_bridge&quot; rel=&quot;nofollow&quot;&gt;H-bridge&lt;/a&gt;) with MOSFETs to properly feed the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What does this shield really offer in the way of driving motors?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A proper circuit and components so you plug your motor and connect into your board leaving you just the programming task to control motor's position and speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is lost by not using this shield?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, you use this kind of component just for practice purposes. It is already built and you just use it. However, it's a good learning process building the H-bridge yourself and understanding how it works and why it is necessary (if you have time, this is a good task).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What if I my project has more than 2 motors?!?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, just decide how many H-bridges you need. This shield has the capacity for 2 DC motors or 1 stepper motor. In case they are servo motor, you just use this &lt;a href=&quot;http://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow&quot;&gt;lib&lt;/a&gt;. It is possible to have plenty of servos working together and all you need are good battery and enough digital pins. They share timers of microcontroller, that's why it works for many motors.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="8478" LastEditDate="2015-05-06T17:10:52.957" LastActivityDate="2015-05-06T17:10:52.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11604" PostTypeId="2" ParentId="11602" CreationDate="2015-05-06T17:05:55.987" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://www.arduino.cc/en/Main/arduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Official Arduino Nano&lt;/a&gt; has an FTDI FT232RL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to use the &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;Virtual Com Port(VCP) Driver&lt;/a&gt; so the FTDI device appears as a COM port under windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://www.arduino.cc/en/Guide/Windows#toc4&quot; rel=&quot;nofollow&quot;&gt;getting started guide&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2015-05-06T17:05:55.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11605" PostTypeId="2" ParentId="3535" CreationDate="2015-05-06T17:06:56.777" Score="0" Body="&lt;p&gt;Your 12 strip probably puts each set of 3 LEDs in series.  3 Red LEDs take about 6V to be fully on, while 3 blue LEDs take about 9V; when you have 12v the resistors absorb the rest of the voltage drop (higher value resistors are needed for the red LEDs if you want about the same current in each color).  Driving 3 in series is good - the same current travels through 3 LEDs producing 3 times as much light per amp than if each LED was separately driven.  (Or from another perspective, with 3 in series the LEDs get 6-9v and thethe resistors and power amp need to drop the 3-6v from a 12v supply, versus a single LED dropping 2-3v and the resistors and power amp dropping the other 9-10v).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All is good, if you are driving each color with close to 12v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT - your LED amplifier may expect more than 5v inputs in order to be fully on (eg: if it uses conventional FETs).  Driving it with 5v may not fully turn on the LED driving transistors.  In that case, the LEDs may be seeing less than 12V.  The blue LEDs would be the first to suffer from this voltage sag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if this is the case, the LED amplifier may also overheat - the transistors dissipate more power when not fully on, which raises the temperatures, probably leading to shortened life at best, possibly release of the magic smoke that makes electronics work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test this.  Disconnect the Arduino.  Connect the +12v to one of the inputs at a time.  If that color is now fully bright, then you have shown that 12v input fully turns on the driving transistor, but 5v does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If your LED amplifier says it's designed to be driven by 5v, do not do this test.  Many of them however expect to be driven by the tail end of a previous strip, at roughly 12v)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of an LED amplifier which &lt;strong&gt;IS&lt;/strong&gt; designed for 5v inputs: &lt;a href=&quot;http://www.usledsupply.com/shop/rgb-mini-amplifier-ttl.html&quot; rel=&quot;nofollow&quot;&gt;http://www.usledsupply.com/shop/rgb-mini-amplifier-ttl.html&lt;/a&gt;  I have not used this device and am not recommending it, just using it as an example.  Note that it appears that for this amplifier, you would connect the Arduino's +5 to the input (along with the PWM outputs from the Arduino), rather than ground - and the PWM sense would be reversed, with lower PWM values being brighter, because the amp would turn on when the output pin was &lt;strong&gt;low&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastEditorUserId="1186" LastEditDate="2015-05-06T17:15:32.507" LastActivityDate="2015-05-06T17:15:32.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11606" PostTypeId="2" ParentId="11601" CreationDate="2015-05-06T17:09:40.857" Score="5" Body="&lt;p&gt;The Serial.print statements show up on whatever terminal program is opened and connected. Their can be only one open at a time, but it could the Arduino IDE built in monitor (ctl-shft-m) or an external terminal program, eg putty, or some other program you wrote that opened the com/serial port the Arduino is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember though - only 1 can be open at a time. If you use an external program you MUST close the com port before attempting to download a new version of your sketch.  If you use the built in monitor/terminal it will automatically do this for you.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-06T17:09:40.857" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11608" PostTypeId="2" ParentId="10583" CreationDate="2015-05-06T17:35:27.737" Score="3" Body="&lt;p&gt;You do know that you assign 6 different values to val, before you use the last one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And assigning 4 interrupts? I have to question how well you understand what you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google pastebin for a method of posting all of your code before asking for help. And be sure to include what you have already tried and how it failed. People are much more likely to help, as opposed to do it for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;update:  As pointed out using pastebin is not a good long term solution, just a quick fix.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are doing quite a few newb things in your code. There is nothing wrong with that we were all newbs at some point.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you are driving 21 servos?  Assuming you board has 21 PWM pins, do you realize they could be drawing up a half amp or more each?  If at 1/2 that it would still be around 5 amps, that is probably 100 times more than the Arduino can handle.  So I hope you have made provisions to power them externally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first real error is on line 130. You define a stepper motor called GzUT, then you pass it to a function expecting a pin number. This is not correct, and I also suspect the 'stepper' library would already set up the pins and there is no need for you to do that. Even beyond that, you declare the GzUT as part of a structure, but you never create a variable that is made of that structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is indicative you are not an experienced programmer, and an embedded program is not the place to learn how to program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are trying to do too much at first.  Go slower.  Get 1 servo (or stepper) to work. then add the others once you understand how to do that. Refer to samples from the stepper library web site. (&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/MotorKnob&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/MotorKnob&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MPU-6050 is also a somewhat more advanced sensor. It look like you plan on multiplexing them? With an I2C multiplexer?  Have you thought out the addressing? Do you have any idea of timing requirements of 21 servos and multiple i2c data streams and if the processor is even capable of meeting those requirements?  My experience with an Arduino UNO is it barely can keep up with 1 mpu-6050. I doubt if you can add more than one servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduinos in general are awesome prototype platforms. They are great for learning embedded programming. But they are not so good for just learning to program in general, especially when you are trying to do a lot of work, of which 21 servos certainly qualifies as.  Again, my recommendation would be slow down, do one small thing at a time, or if this is a real project, contract it out to someone with experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I didn't mean to offend. It is just unclear from your question and your code how much experience you have or do not have. That being said, I am not able to figure out which of the rlf2401 libraries you are trying to use. There 5 of them mentioned on this Arduino page &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&lt;/a&gt;. So follow up with which one you used and I will take a look.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-08T20:13:53.473" LastActivityDate="2015-05-08T20:13:53.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11609" PostTypeId="1" CreationDate="2015-05-06T18:16:25.153" Score="1" ViewCount="1326" Body="&lt;p&gt;I am using arduino uno to make a sound detector. I uploaded a program, found error in the code that it returns unintended numbers unreasonably big. I also think I used wrong code for the module, but it was connected in the way that can work properly with the proper code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I uploaded was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =13;&#xA;const int middleValue = 512;&#xA;const int numberOfSamples =128;&#xA;&#xA;int sample;&#xA;long signal;&#xA;long averageReading;&#xA;&#xA;long runningAverage = 0;&#xA;const int averagedOver = 16;&#xA;&#xA;const int threshold=400;&#xA;&#xA;void setup(){&#xA;    pinMode(ledPin, OUTPUT)&#xA;    Serial.begin(9600)&#xA;}&#xA;&#xA;void loop(){&#xA;    long sumOfSquares = 0;&#xA;    for (int i=0; i&amp;lt;numberOfSamples; i++){&#xA;        sample = analogRead(0);&#xA;        signal = (sample - middleValue);&#xA;        signal *= signal;&#xA;        sumOfSquares += signal;&#xA;    }&#xA;    averageReading = sumOfSquares/numberOfSamples;&#xA;    runningAverage=(((averagedOver -1 )*runningAverage)+averageReading)/averagedOver;&#xA;&#xA;    if(runningAverage&amp;gt;threshold){&#xA;        digitalWrite(ledPin, HIGH);&#xA;    }else{&#xA;        digitalWrite(ledPin, LOW);&#xA;    }&#xA;    Serial.println(runningAverage);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the arduino suddenly stopped sending serial numbers, I pressed reset button and uploaded the default code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but now it shows that it cannot connect to COM3 (arduino) and cant find the device, When I can see arduino uno successfully connected to PC using device manager (windows 8.1). The led light of arduino also turns on when I connect it to power source or usb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it shows &quot;port not found&quot; when I click to see the serial output&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I just fry Arduino? How should I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, i checked the led pin 13 blinking three times when i plug in the usb. I just cant upload anything&lt;/p&gt;&#xA;" OwnerUserId="9903" LastEditorUserId="9903" LastEditDate="2015-05-06T18:40:30.410" LastActivityDate="2022-04-01T21:23:03.633" Title="arduino suddenly shows “avrdude: ser_open(): can't open device ”\\.\COM3&quot; after last upload" Tags="|arduino-uno|serial|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11610" PostTypeId="1" AcceptedAnswerId="11611" CreationDate="2015-05-06T18:19:13.410" Score="1" ViewCount="130" Body="&lt;p&gt;I am interested in seeing how much &quot;&lt;em&gt;uptime&lt;/em&gt;&quot; I can achieve with my Arduino device/project. I am brand new to electronics/robotics, and so I wanted to bounce my idea off of this community first and see if I am overlooking anything obvious/major, or if my overall approach is incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is simple:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Provide my Arduino device with 2+ &quot;rechargeable power sources&quot; (described next) and then provide a mechanism to route power to any viable (non-dead) power source at any time. While one power source is being used to power the Arduino device, the other &quot;idling&quot; power sources are recharging. The intention is to allow the device to keep switching between power sources endlessly, in perpetuity, achieving 100% uptime (perfect &quot;high availability&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for each &quot;rechargeable power source&quot; I am thinking an &lt;a href=&quot;http://www.ns-electric.com/products/energyshield/&quot; rel=&quot;nofollow&quot;&gt;energyShield&lt;/a&gt; (rechargeable Li-polymer) backed by a &lt;a href=&quot;http://www.adafruit.com/products/200&quot; rel=&quot;nofollow&quot;&gt;solar panel&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did some preliminary research and was told that if I were to wire these power sources in series with diodes, then the circuit would always by default draw power from the source with the highest voltage. As soon as another source has higher voltage, the circuit begins drawing power from that one, and the &quot;old source&quot; begins recharging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a noob but not a fool, and I &lt;strong&gt;know&lt;/strong&gt; there is no such thing as perpetual energy (hence the title &quot;quasi-perpetual&quot;), and I'm sure factors like sunlight/weather conditions/etc. would affect the efficacy of the solar panels, etc. But I guess my first concern is: am I doin' it right? Are there any caveats/pitfalls or considerations I'm overlooking here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming I'm more or less correct in my approach, the other concern is how to actually implement power sources and diodes in a series, and how to actually rig that all up and connect it to the Arduino board. Again, I'm a total electronics newbie, so I'm just having a tough time visualizing the precise solution there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as for determining the &lt;em&gt;actual&lt;/em&gt; number of power sources (energyShield + solar panel combo) my device would need, I was just planning on starting with 2, and running the device at max power and monitoring their recharge rates. The more sources I add, the longer the device will operate. Obviously, at some point I'll either reach a point where its uptime is sufficient for my needs, or I'll run out of money. :-)&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2018-03-05T17:54:20.537" Title="Implementing Quasi-Perpetual Battery on Arduino" Tags="|arduino-uno|battery|solar|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11611" PostTypeId="2" ParentId="11610" CreationDate="2015-05-06T18:58:24.597" Score="4" Body="&lt;p&gt;You're overthinking it. Use one or more solar panels, a &lt;a href=&quot;https://www.google.com/search?q=harvesting+ic&quot; rel=&quot;nofollow&quot;&gt;harvesting IC&lt;/a&gt; with sufficient storage, and the bare MCU and peripherals. Use enough panels and storage to run the MCU and peripherals 24/7, and to also charge the storage during the day.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-06T18:58:24.597" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11612" PostTypeId="2" ParentId="10552" CreationDate="2015-05-06T20:38:40.663" Score="1" Body="&lt;p&gt;Why not trying the timer interrupt from atmega328 uC. You'll also learn something usefully and I think is more interesting than using a library and some methods ( functions) without knowing how they are implemented. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really simple to make a digital clock just by interrupting every second. In ISR you'll just have to update the the values for seconds/minutes/hours. For displaying on the LCD, if you don't want to mess with LCD commands and bytes, you can use LiquidCrystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of code:(here I also used an analog pin for modifying time)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU   16000000UL&#xA;#include &amp;lt;avr/delay.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;&#xA;const short buttonPin = 5;&#xA;volatile unsigned char seconds;&#xA;volatile unsigned char minutes;&#xA;volatile unsigned char hours;&#xA;void update_clock()&#xA;{&#xA;    seconds++;&#xA;    if (seconds == 60)&#xA;    {&#xA;        seconds = 0;&#xA;        minutes++;&#xA;    }&#xA;    if(minutes==60)&#xA;    {&#xA;      minutes=0;&#xA;      hours++;&#xA;    }&#xA;    if(hours&amp;gt;23)&#xA;    {&#xA;      hours=0;&#xA;    }&#xA;&#xA;&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;&#xA;  update_clock(); &#xA;&#xA;}&#xA;&#xA;void setup() &#xA;{                &#xA;&#xA;&#xA;&#xA;  // initialize Timer1&#xA;  pinMode(A5, INPUT_PULLUP);&#xA;  cli();          // disable global interrupts&#xA;  TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;  TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;  // set compare match register to desired timer count:&#xA;  OCR1A = 15624;&#xA;  // turn on CTC mode:&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;  sei();          // enable global interrupts&#xA;  lcd.begin(16, 2);&#xA;  lcd.print(&quot;HH:MM:SS&quot;);&#xA;  Serial.begin(9600); &#xA;&#xA;&#xA;}&#xA;&#xA;void display_on_lcd()&#xA;{&#xA;&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(hours);&#xA;  lcd.setCursor(2,1);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.setCursor(3,1);  &#xA;  lcd.print(minutes);&#xA;  lcd.setCursor(5,1);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.setCursor(6,1);&#xA;  lcd.print(seconds);&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  display_on_lcd();&#xA;&#xA;  Serial.println(analogRead(5));&#xA;  if(analogRead(buttonPin)&amp;lt;1000)&#xA;  {&#xA;    if(minutes==59)&#xA;    {&#xA;      minutes=0;&#xA;      if(hours==23)&#xA;        hours=0;&#xA;      else&#xA;        hours++;&#xA;    }&#xA;    else&#xA;    {&#xA;      minutes++;&#xA;    }&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just search and you'll find a lot of examples. &lt;/p&gt;&#xA;" OwnerUserId="4552" LastActivityDate="2015-05-06T20:38:40.663" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11613" PostTypeId="2" ParentId="10578" CreationDate="2015-05-06T20:46:34.420" Score="1" Body="&lt;p&gt;Yes, you can write a program outside Arduino IDE.&#xA;For example I tried Eclipse IDE with AVR plug-in and now I stick with AVR Studio. Of course,you won't have some functions that you maybe usually use when you write in Arduino IDE and also some libraries. But, why not to try implementing stuff. Why to limit yourself to functions and libraries made by others when you can learn and write your owns, maybe better than the existing ones. &lt;/p&gt;&#xA;" OwnerUserId="4552" LastActivityDate="2015-05-06T20:46:34.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11615" PostTypeId="1" CreationDate="2015-05-07T00:26:09.557" Score="3" ViewCount="274" Body="&lt;p&gt;I have downloaded a sketch that uses SPI.  The sketch includes the Wire library but at compilation time, I am getting errors that TwoWire doesn't have methods called &lt;code&gt;send()&lt;/code&gt; and &lt;code&gt;receive()&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="9911" LastEditorUserId="6936" LastEditDate="2015-08-05T14:55:20.743" LastActivityDate="2015-08-05T14:55:52.393" Title="Undefined functions send() and receive() on TwoWire/SPI" Tags="|spi|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11616" PostTypeId="2" ParentId="11615" CreationDate="2015-05-07T00:26:09.557" Score="7" Body="&lt;p&gt;This is caused by the sketch you downloaded being old.  In prior releases, the methods called &lt;code&gt;send()&lt;/code&gt; and &lt;code&gt;receive()&lt;/code&gt; were used to send and receive SPI data.  These were renamed to be &lt;code&gt;write()&lt;/code&gt; and &lt;code&gt;read()&lt;/code&gt;.  If you change your code where there are references to &lt;code&gt;Wire.send()&lt;/code&gt; and change to &lt;code&gt;Wire.write()&lt;/code&gt; and also change &lt;code&gt;Wire.receive()&lt;/code&gt; to &lt;code&gt;Wire.read()&lt;/code&gt;, you should find that your applications compile and run correctly.&lt;/p&gt;&#xA;" OwnerUserId="9911" LastEditorUserId="6936" LastEditDate="2015-08-05T14:55:52.393" LastActivityDate="2015-08-05T14:55:52.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11618" PostTypeId="1" CreationDate="2015-05-06T08:35:50.893" Score="0" ViewCount="8618" Body="&lt;p&gt;Anyone ever run into a problem with your attiny not reading  your analog pins correctly? (-1023 or 1023 or 0 value) How did you resolve the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what my code looks like now :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4th revision of code as of 5/6/2015 8pm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int NTC = A1; // thermistor&#xA;int switchPin = PB1; // push button&#xA;int LED = PB0;  // led &#xA;&#xA;&#xA;// button latch&#xA;byte ButtonState;&#xA;byte lastState = LOW;&#xA;byte count = 0;&#xA;&#xA; //brightness level of each different mode &#xA;int low = 50; &#xA;int med = 140;&#xA;int high = 255;             &#xA;int dim = 0;&#xA;&#xA;&#xA;int ADCcount = 0;&#xA;&#xA;void setup() &#xA;{ &#xA;&#xA; pinMode(switchPin, OUTPUT);&#xA; pinMode(LED, OUTPUT);  &#xA;&#xA;  }&#xA;&#xA; void loop() &#xA; {&#xA;&#xA;  ADCcount = analogRead(NTC);  &#xA;&#xA;delay(100);&#xA;&#xA;&#xA;  ButtonState = digitalRead(switchPin);&#xA;&#xA;  if(ButtonState &amp;amp;&amp;amp; ButtonState != lastState)  // button latch, no debounce      needed.&#xA;   {&#xA;      if(count &amp;lt; 4) // This will check to see if the count is within a range of  0 - 255 &#xA;                 // anything over that, it will reset count back to 0. Of course&#xA;      count += 1;  // same as count = count + 5;&#xA;      else &#xA;      count == 0;&#xA;        }    &#xA;&#xA;    lastState = ButtonState;&#xA;&#xA;   if (count == 0)&#xA;  {analogWrite(LED,0);} &#xA;    else if (count == 1) { if(ADCcount &amp;lt; 500) {analogWrite(LED,high);}&#xA;      else{ if(ADCcount &amp;gt; 525){analogWrite(LED,low);}&#xA;       }            &#xA;          } &#xA;      else if (count == 2 ){analogWrite(LED,med);} &#xA;      else if (count == 3) {analogWrite(LED,low);}&#xA;      if(count &amp;gt;=4) {count = 0;}&#xA;      delay(50);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dyIZY.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fdyIZY.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="10166" OwnerDisplayName="Blue Stallion" LastEditorUserId="10166" LastEditDate="2015-05-19T21:34:17.673" LastActivityDate="2015-05-19T21:34:17.673" Title="How do i properly read an analog pin on attiny85?" Tags="|attiny|" AnswerCount="1" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="11619" PostTypeId="2" ParentId="11618" CreationDate="2015-05-06T15:18:02.880" Score="1" Body="&lt;p&gt;The improper bush-button event handling is likely to cause the problem. One way to properly react to the external environment signals could be constant polling or using interrupts. With constant polling, all the time is spent on the checking the status of the button. With interrupts, the program is executed as it should, and only if interrupt happens - the execution jumps to the interrupt subroutine, executes it, and goes back to the main code where it left off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you can use pin 7, for example, for push button signal. It can have a function of &lt;em&gt;INT0&lt;/em&gt;. Read &lt;em&gt;Section 9. Interrupts&lt;/em&gt; of the datasheet - it is straight forward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not completely understand what your program should do, but I will try to convey the general approach of using subroutines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile bool pressed = false;&#xA;int main(void)&#xA;   {&#xA;   MCUCR |= (1&amp;lt;&amp;lt;ISC01 |1&amp;lt;&amp;lt;ISC00);       // set INT0 to interrupt on rising edge of pin7&#xA;   sei();                               // enable global interrupts&#xA;&#xA;   while(1){&#xA;      if (pressed) then do something; //You can disable interrupts here so your code is not interrupted by cli();&#xA;      pressed = false; // reset the state&#xA;      else do something else;&#xA;   // you can re-enable your interrupts here by sei();&#xA;   }        &#xA;}&#xA;&#xA;// only happens when the change on pin 7 is from LOW to HI &#xA;ISR(INT0_vect){&#xA;pressed = true; // update the pressed status&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use pin6 for push button, you should enable the PCINT1 instead of INT0 and change the ISR to handle the PCINT1 interrupt. In this case, pin 6 will react on voltage toggle (from HI to LOW, or the other way) and you can not discriminate rizing/falling edges. In that way, you must read pin6 within the instruction subroutine to know if it is hi or low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest to stop the calculations in the &lt;em&gt;Temp()&lt;/em&gt; function after the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  average = SERIESRESISTOR / average;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line due to the fact that you have only three operating modes for the LED. Thus you can, back calculate the &lt;em&gt;average&lt;/em&gt; value that makes your &lt;em&gt;steinhart&lt;/em&gt; value to be, for example &gt;30. This way, all other values greather/smaller than that value will also fall under the same condition depending on whether average/steinhart are directly/inversely proportional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you determine the three ranges of raw &lt;em&gt;average&lt;/em&gt; values you can use them directly in the &lt;em&gt;Mode()&lt;/em&gt; function. Eventually, you can optimize you code even further, by performing monotonic read instead of burst reads. If you keep a buffer, you do only one addition of the most recent sample and subtracting the oldest sample. For this you will need two pointers and one memory for to store &lt;em&gt;sum&lt;/em&gt;, but you will not need to do nSamples additions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;read (newSample);&#xA;sum += newSample;&#xA;sum -= oldestSample;&#xA;average = sum/numSamples;&#xA;update pointers to the memory for oldest sample and for the feature sample;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Naz" LastActivityDate="2015-05-06T20:31:13.073" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="11620" PostTypeId="2" ParentId="10586" CreationDate="2015-05-07T06:15:16.660" Score="0" Body="&lt;p&gt;Using the adafruit PWM servo shield seems like overkill, you are paying for a lot facilities (PWM) that you won't be using. If you want to use the shield to reduce the number of pins used on your arduino board,  consider a pair of shift out registers (74HC595 for example). The relays need a logic 1 or a logic 0 to change state. You send a bit pattern to the shiftout register that sets the output pins of the shift register to 1 or 0. I found &lt;a href=&quot;http://playground.arduino.cc/Main/ShiftOutX&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; helpful.&lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-05-07T06:15:16.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11621" PostTypeId="1" CreationDate="2015-05-07T07:44:20.850" Score="0" ViewCount="148" Body="&lt;p&gt;I have a very specific problem, exactly with real time control. For example I try to write an application where I can edit min or max temperature that after reaching it , I will receive SMS with message. I'm wondering how to edit variables &quot;on-the-fly&quot; because, as I know Arduino IDE use it own libraries not this from C/C++, and I don't know how to get to SD card in Arduino too. Can someone help ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="9917" LastActivityDate="2015-05-07T08:31:15.280" Title="Arduino YUN real time control" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11622" PostTypeId="2" ParentId="10559" CreationDate="2015-05-07T07:48:49.310" Score="2" Body="&lt;p&gt;I am wary about providing a complete answer without knowing what is expected of YOU - is this like an assignment where you are being tested on understanding and what you have learned. The following will be useful to you. You need to give some more details if you want more assistance with these circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an existing stack exchange question. I see that I answered it in 2011 :-).&lt;br&gt;&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/17852/how-does-this-power-supply-circuit-work-mcu-lm317&quot;&gt;How does this power supply circuit work? (MCU + LM317)&lt;/a&gt;&lt;br&gt;&#xA;The circuit and my previous answer should help greatly.&lt;br&gt;&#xA;In your case you apply PWM  using analog.Write to R1.&lt;br&gt;&#xA;You MUST understand how the circuit works and not just apply it.&lt;br&gt;&#xA;The original appears to be &lt;a href=&quot;http://electronicdesign.com/electromechanical/control-high-power-load-low-power-microcontroller&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; with circuit description, with diagram &lt;a href=&quot;http://electronicdesign.com/site-files/electronicdesign.com/files/archive/electronicdesign.com/files/29/13077/figure_01.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jqLA9.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;http://www.edn.com/design/analog/4363990/Control-an-LM317T-with-a-PWM-signal&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;this page&lt;/strong&gt;&lt;/a&gt; from EDN magazine is a similar circuit. The pot between pins 1 &amp;amp; 5 would not usually be used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SfM7R.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In another stack exchange question there is a very useful caution about the opamp's load limits in a similar circuit.&lt;br&gt;&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/56506/problems-controlling-an-lm317-with-an-op-amp&quot;&gt;&lt;strong&gt;Problems controlling an LM317 with an op-amp&lt;/strong&gt;&lt;/a&gt; - 2013&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can get many possible ideas here - search = &lt;a href=&quot;https://www.google.co.nz/search?q=voltage+controlled+power+supply&amp;amp;biw=1615&amp;amp;bih=1014&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ei=bxFLVb-PG8XemAXQy4D4BQ&amp;amp;sqi=2&amp;amp;ved=0CCEQsAQ#tbm=isch&amp;amp;q=lm317+voltage+controlled+power+supply&quot; rel=&quot;nofollow noreferrer&quot;&gt;lm317 voltage controlled power supply&lt;/a&gt; - this is an immensely powerful way of finding information -  IF a picture is worth a thousand words then this is priceless. Note the terms used.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bad designs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some bad designs around which can look OK but behave badly.&lt;br&gt;&#xA;Despite the detailed writeup, &#xA;&lt;a href=&quot;http://tuxgraphics.org/electronics/201005/bench-power-supply-v3.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;This poor design&lt;/a&gt; uses &quot;open loop control&quot; and the output voltage varies with load and is only &quot;sort of controlled&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was asked why I think this circuit is &quot;open loop&quot;. I could not find a complete circuit diagram on the page but this diagram was shown of the output stage. If this is NOT the actual circuit used it would be &quot;good&quot; to have the complete circuit easily accessible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/espW1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/espW1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IF&lt;/strong&gt; this is the actual circuit used, then: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call the transistors Q1 Q2 Q3 Q4 in left to right order.&lt;br&gt;&#xA;Call intended output voltage = Vset = Vdac x (R6 + R7)/R7.&lt;br&gt;&#xA;Vdac is applied to Q1 base and amplified by Q1 &amp;amp; Q2 to form the desired output voltage, appearing at Q2 collector. A lesser voltage appears as Vout due to the Vbe drop in Q3 &amp;amp; Q4. As load current increases Vout will &quot;droop&quot; thereby increasing the drive to Q4. This in turn increases the load on Q3 and Q3 emitter voltage will droop increasing Q3 drive. The actual Vbe voltages will depend on the beta (current gain) of Q3 and Q4, their temperatures (which depends on heat sinking, load and ambient temperatures) and manufacturing variation. At no or very low loads Vout will be about 1 Volt below Vset. At heavy loads Vbe_Q3 will be in the 0.6-0.8V range and Vbe_Q4 will be 0.8V+. So Vout will be around 1.5+ Volts below Vset and variable with (at least) the factors mentioned above.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is still a usable design, but Vout could 'easily enough' be made far more stable with load by feedback from Vout to the Q1-Q2 amplifier - essentially forming a comparator that compares Vset and Vout. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;br&gt;&#xA; &lt;a href=&quot;http://tuxgraphics.org/common/images2/article379/powersupply.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;This&lt;/strong&gt;&lt;/a&gt; [reference provided by NilsB] MAY be the actual circuit diagram or close to it. It's an earlier 2005 design which presumably is much the same as the later version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NwJ3Q.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NwJ3Q.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears not to be open loop in the broad sense. The Vout is still decoupled from Vset, with the software feedback allowing him to adjust the Vset to make Vout what he wants on a &quot;nudge it and see&quot; basis. ie Vset is not a fixed ratio wrt Vout so he can never set it and have it &quot;just track&quot;. So it does not automatically stabilise for load or temperature changes and there is a variable drp between k x Vset and Vout.&lt;br&gt;&#xA;Software is fastish but not as fast as a closed loop in hardware which allows Vout to track Vset within mV in a time delay as short as you provide an error amp loop for.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's a 2005 circuit diagram so an earlier version than the originally cited V3 - one assumes he has not 'gone backwards' in design concept. It's strange that he does not include the whole circuit diagram or a good discussion of the provided current and voltage feedback. He may have wanted to sell kitsets rather than give away his final design. The link to the kitset sales is now broken so he now manages neither. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd consider it preferable to add a simple hardware error amplifier so Vout = k x Vset and THEN measure Vout and Iout with ADCs (as he does). Vout is then essentially &quot;set and forget&quot; with the added ability to check that Vout is what it should be (which allows eg heavy overload to be detected.&lt;br&gt;&#xA;Constant current mode operation is still &quot;nudge and see&quot; but 'not too bad'.&lt;br&gt;&#xA;Also, Vout includes the Vdrop across the current sense resistors - about 0.5V/A. Measuring with 2 x AD C channels as he does allows this to be compensated for. If the Isense resistors were in the &quot;high side&quot; feed before the regulator this would remove this variation but make current sensing somewhat harder. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2018-09-01T10:02:35.690" LastActivityDate="2018-09-01T10:02:35.690" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11623" PostTypeId="2" ParentId="11621" CreationDate="2015-05-07T08:31:15.280" Score="1" Body="&lt;p&gt;the SD card is at /mnt/sd/ . you should consider reading the yun tutorials &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Bridge&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; before going further, the ability to send and receive data is at the heart of the yun design.&lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-05-07T08:31:15.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11624" PostTypeId="1" AcceptedAnswerId="11839" CreationDate="2015-05-07T09:00:01.230" Score="2" ViewCount="350" Body="&lt;p&gt;I'm using an AdaFruit CC3000 Wifi shield as an HTTP server with an Arduino Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a script which works fine -- logs into my Wifi and listens for connections as it should. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I want to use an infrared library which writes to the CC33000 default IRQ 3, so to avoid conflict I change the following setting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the only other Interrupt pin&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADAFRUIT_CC3000_IRQ   2  // MUST be an interrupt pin!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The device hangs at &quot;Initializing&quot; .. or at least I see neither of the subsequent lines in the following code on my serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;\nInitializing...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;\nAttempting to connect to &quot;)); Serial.println(WLAN_SSID);&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've stripped everything back down to just the example code for HTTPServer to ensure it's not a conflict with my own code or the IR Library. I've changed the setting from 2 to 0 and 1 thinking there was some confusion over literal IRQs vs Pins, but those settings generate the &quot;Couldn't begin&quot; error trap. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other setting that I need to vary in order to get the CC3000 to opearate on IRQ 2 or is this a hardware bug and I'm out of luck if I want to use Pin 3?&lt;/p&gt;&#xA;" OwnerUserId="8477" LastActivityDate="2015-05-14T14:11:44.980" Title="Adafruit CC3000 Wifi Shield on IRQ 2?" Tags="|arduino-uno|interrupt|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11625" PostTypeId="2" ParentId="11601" CreationDate="2015-05-07T09:08:51.013" Score="3" Body="&lt;p&gt;It took me ages to realize that instead of remembering Ctrl-Shft-M you can just click on the little magnifying glass in the upper right of the IDE interface. Wait until after your script uploads though, it won't do anything while compiling or uploading your script. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qrktx.png&quot; alt=&quot;Screen Shot of Arduino IDE interface showing serial monitor icon&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8477" LastActivityDate="2015-05-07T09:08:51.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11626" PostTypeId="2" ParentId="10563" CreationDate="2015-05-07T09:25:23.287" Score="0" Body="&lt;p&gt;Did you try removing the 0x indicator? If I remember correctly the incoming signals are raw, e.g. 2E3A06C0, even though the script requires the 0x indicator on the send routines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you'd need to rewrite, but you could try this IR Library and code, which I found has much better documentation and data analysis options on the receiving side: &lt;a href=&quot;https://github.com/cyborg5/IRLib/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/cyborg5/IRLib/&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="8477" LastActivityDate="2015-05-07T09:25:23.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11627" PostTypeId="1" CreationDate="2015-05-07T10:09:33.760" Score="-1" ViewCount="123" Body="&lt;p&gt;Can you program a sketch so that if the time is between 1m and 10m then it will reset itself?&#xA;Reset I found already, it is the if that I don't know. &lt;/p&gt;&#xA;" OwnerUserId="9920" LastEditorUserId="6452" LastEditDate="2015-05-07T14:11:25.490" LastActivityDate="2019-10-19T11:11:14.717" Title="Programming question for Time Arduino" Tags="|arduino-uno|programming|time|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11628" PostTypeId="2" ParentId="11627" CreationDate="2015-05-07T10:32:26.500" Score="2" Body="&lt;p&gt;You can use the timer interrupts. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU   16000000UL&#xA;#include &amp;lt;avr/delay.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;...&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;&#xA;  //do something every seconds when interrupt is raised.&#xA;&#xA;}&#xA;void setup()&#xA;{&#xA;/*the following code will setup timer register to generate interrupt&#xA;  when 15624 is reached, at a clock frequency of 16 MHz and 1024 prescaler. This means that     every second an interrupt is generated&#xA;*/&#xA;  cli();          // disable global interrupts&#xA;  TCCR1A = 0;     // set entire TCCR1A register to 0&#xA;  TCCR1B = 0;     // same for TCCR1B&#xA;&#xA;  // set compare match register to desired timer count:&#xA;  OCR1A = 15624;&#xA;  // turn on CTC mode:&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS10 and CS12 bits for 1024 prescaler:&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12);&#xA;  // enable timer compare interrupt:&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;  sei();          // enable global interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code works on Arduino Uno. You should calculate the value of OCR1A for your frequency.&lt;/p&gt;&#xA;" OwnerUserId="4552" LastActivityDate="2015-05-07T10:32:26.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11629" PostTypeId="1" AcceptedAnswerId="11630" CreationDate="2015-05-07T11:33:21.350" Score="0" ViewCount="317" Body="&lt;p&gt;I'm trying to made a program that turn on and turn off leds with an input and send the coordinates of joystick, but, in the loop, the arduino makes one at a time, and i want make this in the same time. How can i make that? &lt;/p&gt;&#xA;" OwnerUserId="9820" LastActivityDate="2015-05-07T14:03:07.417" Title="Multithreading Leds and Joystick" Tags="|arduino-uno|led|shields|ethernet|threads|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11630" PostTypeId="2" ParentId="11629" CreationDate="2015-05-07T12:55:16.093" Score="1" Body="&lt;p&gt;One way to do this is to use the millis() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;millis() returns the current value of a timer that is incremented once per millisecond (hence the function name). You can compare the value of millis() at some past time with the current value to determine how many milliseconds have passed. By having multiple compare registers you can have multiple independent delays operating. (There is also micros() which increments at the 1 uS rate (with a &quot;granularity&quot; of 4uS on some processors). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code is an example only. It MAY run but has not been tested and probably contains silly mistakes which do not affect its example purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A function ToggleLED(n) is assumed which toggles the specified LED n from 1-&gt;0 or 0-&gt;1  as required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED1 will flash 200 mS on, 200 mS off, ...&lt;br&gt;&#xA;LED2 will flash 333 mS on, 333 mS off, ...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two loops are essentially independent. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long delay1; delay2;&#xA;&#xA;void setup(){  &#xA;&#xA;int FlashTime1 = 200; / LED 1 will have a 200 on 200 off cycle&#xA;int FlashTime2 = 333; / LED 2 will have a 333 on 333 off cycle&#xA;&#xA;delay1 = millis() + FlashTime1;  / Init LED timers&#xA;delay2 = millis() + Flashtime2;  &#xA;}&#xA;&#xA;void loop()  &#xA;{  &#xA;  if (millis() == delay1){ / Not until delay expired. &#xA;&#xA;    ToggleLED(1);&#xA;    delay1= millis() + FlashTime1; / Reinit flash timer}&#xA;&#xA;  if (millis() == delay2){&#xA;&#xA;       ToggleLED(2);&#xA;       delay2= millis() + FlashTime2;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="2881" LastEditDate="2015-05-07T13:51:09.867" LastActivityDate="2015-05-07T13:51:09.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11631" PostTypeId="2" ParentId="11629" CreationDate="2015-05-07T14:03:07.417" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the loop is something like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;controlleds();&#xA;joystickevent();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;but he runs, controlleds first, and joystickevent next, i want at the&#xA;  same time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are typically two ways to read a simple potentiometer joystick: Connect it in a voltage divider and measure the analog voltage; and connect it in an R-C circuit and measure the time for the capacitor to charge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first way is faster and you should not be able to notice the time difference between controlling the LEDs and reading the joystick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second way takes longer and you might be able to notice. If this is how your joystick controller works, you would need to separately start the joystick reading, continue to poll the buttons control the LEDs, and check whether the joystick reading is ready yet. The joystick routine must not delay, waiting for the measurement to finish.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-07T14:03:07.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11632" PostTypeId="1" CreationDate="2015-05-07T15:12:19.907" Score="1" ViewCount="353" Body="&lt;p&gt;I´m using Spark Fun Micro Pro board 5V: &#xA;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and to that i´ve hooked a true color OLED from digole:&#xA;&lt;a href=&quot;http://www.digole.com/index.php?productID=859&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.digole.com/index.php?productID=859&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got a wire from OLED &quot;data&quot; to Pro micro &quot;TX&quot;-pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OLED starts up and runs the start up screen, but the sample code I uploaded won't run. And that code looks like this:(the code is pretty long, if anybody would have a simplified sample code it would be much appreciated!! To get the OLED to show a simple &quot;Hello World&quot; would make me a very happy man! =)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#ifndef DigoleSerialDisp_h&#xA;#define DigoleSerialDisp_h&#xA;&#xA;#include &amp;lt;inttypes.h&amp;gt;&#xA;#include &quot;Print.h&quot;&#xA;#include &quot;Wire.h&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;// Communication set up command&#xA;&#xA;// Text function command&#xA;&#xA;// Graph function command&#xA;&#xA;#define Serial_UART 0&#xA;#define Serial_I2C 1&#xA;#define Serial_SPI 2&#xA;#define _TEXT_ 0&#xA;#define _GRAPH_ 1&#xA;&#xA;void setup() {}&#xA;&#xA;void loop () {}&#xA;&#xA;class DigoleSerialDisp : public Print {&#xA;&#xA;public:&#xA;#if defined(_Digole_Serial_UART_)&#xA;&#xA;DigoleSerialDisp(HardwareSerial1 *s, unsigned long baud) //UART set up&#xA;&#xA;{&#xA;&#xA;    _mySerial = s;&#xA;&#xA;    _Baud = baud;&#xA;&#xA;    _Comdelay=2;&#xA;&#xA;}&#xA;&#xA;size_t write(uint8_t value) {&#xA;    _mySerial-&amp;gt;write((uint8_t)value);&#xA;    return 1; // assume sucess&#xA;}&#xA;&#xA;void begin(void) {&#xA;&#xA;    _mySerial-&amp;gt;begin(9600);&#xA;    _mySerial-&amp;gt;print(&quot;SB&quot;);&#xA;    _mySerial-&amp;gt;println(_Baud);&#xA;    delay(100);&#xA;    _mySerial-&amp;gt;begin(_Baud);&#xA;&#xA;}&#xA;&#xA; #endif&#xA;&#xA; #if defined(_Digole_Serial_I2C_)&#xA;&#xA;&#xA;void begin(void) {&#xA;    _myWire-&amp;gt;begin();&#xA;}&#xA;&#xA;&#xA;DigoleSerialDisp(TwoWire *s, uint8_t add) //U2C set up&#xA;&#xA;{&#xA;&#xA;    _myWire = s;&#xA;    _I2Caddress = add;&#xA;    _Comdelay=6;&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t write(uint8_t value) {&#xA;&#xA;    _myWire-&amp;gt;beginTransmission(_I2Caddress);&#xA;&#xA;    _myWire-&amp;gt;write((uint8_t)value);&#xA;    _myWire-&amp;gt;endTransmission();&#xA;&#xA;    return 1; // assume sucess&#xA;&#xA;}&#xA;&#xA;#endif&#xA;&#xA;#if defined(_Digole_Serial_SPI_)&#xA;&#xA;void begin(void) {&#xA;&#xA;}&#xA;&#xA;DigoleSerialDisp(uint8_t pin_data, uint8_t pin_clock, uint8_t SS) //spi set up&#xA;&#xA;{&#xA;&#xA;    _Clockpin = pin_clock;&#xA;    _Datapin = pin_data;&#xA;    _SSpin = SS;&#xA;&#xA;    pinMode(_Clockpin, OUTPUT);&#xA;    pinMode(_Datapin, OUTPUT);&#xA;    pinMode(_SSpin, OUTPUT);&#xA;&#xA;    digitalWrite(_SSpin, HIGH);&#xA;    digitalWrite(_Clockpin, LOW);&#xA;    digitalWrite(_Datapin, LOW);&#xA;&#xA;    _Comdelay=6;&#xA;&#xA;}&#xA;&#xA;size_t write(uint8_t value) {&#xA;&#xA;    digitalWrite(_SSpin, LOW);&#xA;    digitalWrite(_SSpin, LOW);&#xA;    digitalWrite(_SSpin, LOW);&#xA;&#xA;    shiftOut(_Datapin, _Clockpin, MSBFIRST, value);&#xA;&#xA;    digitalWrite(_SSpin, HIGH);&#xA;&#xA;    return 1; // assume sucess&#xA;&#xA;}&#xA;&#xA;#endif&#xA;&#xA;//    virtual size_t write(uint8_t);&#xA;&#xA;    /*---------fucntions for Text and Graphic LCD adapters---------*/&#xA;&#xA;&#xA;void disableCursor(void) {&#xA;&#xA;    Print::print(&quot;CS0&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void enableCursor(void) {&#xA;&#xA;    Print::print(&quot;CS1&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void clearScreen(void) {&#xA;&#xA;    Print::print(&quot;CL&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void setI2CAddress(uint8_t add) {&#xA;&#xA;    Print::print(&quot;SI2CA&quot;);&#xA;&#xA;    write(add);&#xA;&#xA;    _I2Caddress = add;&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void displayConfig(uint8_t v) {&#xA;&#xA;    Print::print(&quot;DC&quot;);&#xA;&#xA;    write(v);&#xA;&#xA;}&#xA;&#xA;//print function&#xA;&#xA;&#xA;&#xA;size_t println(const __FlashStringHelper *v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;    Print::print(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(const String &amp;amp;v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(const char v[]) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(char v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(unsigned char v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(int v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(unsigned int v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(long v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(unsigned long v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(double v, int base = 2) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(const Printable&amp;amp; v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t println(void) {&#xA;&#xA;    Print::println(&quot;\x0dTRT&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(const __FlashStringHelper *v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(const String &amp;amp;v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(const char v[]) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(char v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(unsigned char v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(int v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(unsigned int v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(long v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(unsigned long v, int base = DEC) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(double v, int base = 2) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v, base);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;size_t print(const Printable&amp;amp; v) {&#xA;&#xA;    preprint();&#xA;&#xA;    Print::println(v);&#xA;&#xA;}&#xA;&#xA;void preprint(void);&#xA;&#xA;/*----------Functions for Graphic LCD/OLED adapters only---------*/&#xA;&#xA;//the functions in this section compatible with u8glib&#xA;&#xA;void drawBitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);&#xA;&#xA;void drawBitmap256(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);&#xA;&#xA;void drawBitmap262K(unsigned int x, unsigned int y, unsigned int w, unsigned int h, const uint8_t *bitmap);&#xA;&#xA;void setTrueColor(uint8_t r, uint8_t g, uint8_t b);&#xA;&#xA;void setRot90(void);&#xA;&#xA;void setRot180(void);&#xA;&#xA;void setRot270(void);&#xA;&#xA;void undoRotation(void);&#xA;&#xA;void setRotation(uint8_t);&#xA;&#xA;void setContrast(uint8_t);&#xA;&#xA;void drawBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h);&#xA;&#xA;void drawCircle(unsigned int x, unsigned int y, unsigned int r, uint8_t = 0);&#xA;&#xA;void drawDisc(unsigned int x, unsigned int y, unsigned int r);&#xA;&#xA;void drawFrame(unsigned int x, unsigned int y, unsigned int w, unsigned int h);&#xA;&#xA;void drawPixel(unsigned int x, unsigned int y, uint8_t = 1);&#xA;&#xA;void drawLine(unsigned int x, unsigned int y, unsigned int x1, unsigned int y1);&#xA;&#xA;void drawLineTo(unsigned int x, unsigned int y);&#xA;&#xA;void drawHLine(unsigned int x, unsigned int y, unsigned int w);&#xA;&#xA;void drawVLine(unsigned int x, unsigned int y, unsigned int h);&#xA;&#xA;//-------------------------------&#xA;&#xA;//special functions for our adapters&#xA;&#xA;void setFont(uint8_t font); //set font, availale: 6,10,18,51,120,123, user font: 200-203&#xA;&#xA;void nextTextLine(void); //got to next text line, depending on the font size&#xA;&#xA;void setColor(uint8_t); //set color for graphic function&#xA;&#xA;void backLightOn(void); //Turn on back light&#xA;&#xA;void backLightOff(void); //Turn off back light&#xA;&#xA;void directCommand(uint8_t d); //send command to LCD drectly&#xA;&#xA;void directData(uint8_t d); //send data to LCD drectly&#xA;&#xA;void moveArea(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, char xoffset, char yoffset); //move a area of screen to another place&#xA;void drawStr(unsigned int x, unsigned int y, const char *s);&#xA;void setPrintPos(unsigned int x, unsigned int y, uint8_t =0 );&#xA;void setLCDColRow(uint8_t col, uint8_t row);&#xA;&#xA;void setTextPosAbs(unsigned int x, unsigned int y);&#xA;void write2B(unsigned int v);&#xA;&#xA;&#xA;void displayStartScreen(uint8_t m) {&#xA;&#xA;    Print::print(&quot;DSS&quot;);&#xA;&#xA;    write(m);&#xA;&#xA;} //display start screen&#xA;&#xA;&#xA;&#xA;void setMode(uint8_t m) {&#xA;&#xA;    Print::print(&quot;DM&quot;);&#xA;&#xA;    write(m);&#xA;&#xA;} //set display mode&#xA;&#xA;&#xA;&#xA;void setTextPosBack(void) {&#xA;&#xA;    Print::print(&quot;ETB&quot;);&#xA;&#xA;} //set text position back to previous, only one back allowed&#xA;&#xA;&#xA;&#xA;  void setTextPosOffset(char xoffset, char yoffset) {&#xA;&#xA;    Print::print(&quot;ETO&quot;);&#xA;&#xA;    write(xoffset);&#xA;&#xA;    write(yoffset);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void setLinePattern(uint8_t pattern) {&#xA;&#xA;    Print::print(&quot;SLP&quot;);&#xA;&#xA;    write(pattern);&#xA;&#xA; }&#xA;&#xA;void setLCDChip(uint8_t chip) {      //only for universal LCD adapter&#xA;&#xA;    Print::print(&quot;SLCD&quot;);&#xA;&#xA;    write(chip);&#xA;&#xA; }&#xA;void setBackLight(uint8_t bl){&#xA;    Print::print(&quot;BL&quot;);&#xA;&#xA;    write(bl);&#xA;&#xA;}&#xA;&#xA;void uploadStartScreen(int lon, const unsigned char *data); //upload start screen&#xA;&#xA;void uploadUserFont(int lon, const unsigned char *data, uint8_t sect); //upload user font&#xA;&#xA;void digitalOutput(uint8_t x) {Print::print(&quot;DOUT&quot;);write(x);}&#xA;&#xA;private:&#xA;&#xA;unsigned long _Baud;&#xA;&#xA;HardwareSerial *_mySerial;&#xA;&#xA;uint8_t _I2Caddress;&#xA;&#xA;TwoWire *_myWire;&#xA;&#xA;uint8_t _Clockpin;&#xA;&#xA;uint8_t _Datapin;&#xA;&#xA;uint8_t _SSpin;&#xA;&#xA;uint8_t _Comdelay;&#xA;&#xA;};&#xA;&#xA;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9922" LastEditorUserId="37523" LastEditDate="2019-08-23T01:18:54.697" LastActivityDate="2019-08-23T01:18:54.697" Title="Can't get my code to my OLED" Tags="|uart|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="11633" PostTypeId="2" ParentId="10563" CreationDate="2015-05-07T17:36:37.027" Score="0" Body="&lt;p&gt;Try to put Quotation mark like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (results.value) {&#xA;  case &quot;0x2E3A06C0&quot;:&#xA;    main = 1;&#xA;    Serial.println(&quot;MAIN: on&quot;);&#xA;    break;&#xA;  case &quot;0x8C2921D6&quot;:&#xA;    left = 1;&#xA;    Serial.println(&quot;LEFT: on&quot;);&#xA;    break;&#xA;  case &quot;0x226270DA&quot;:&#xA;    right = 1;&#xA;    Serial.println(&quot;RIGHT: on&quot;);&#xA;    break;&#xA;  case &quot;0x4AC6E6A&quot;:&#xA;    main = 0;&#xA;    Serial.println(&quot;MAIN: off&quot;);&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this doesn't work too, maybe you've got a hardware problem&lt;/p&gt;&#xA;" OwnerUserId="9923" LastActivityDate="2015-05-07T17:36:37.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11634" PostTypeId="1" AcceptedAnswerId="11636" CreationDate="2015-05-07T18:08:45.940" Score="0" ViewCount="104" Body="&lt;p&gt;The below code starts off with lots of data in the beginning, distracting the reader from the actual code.  What is the best practice to clean this up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;// For LED Backpack&#xA;#include &quot;Adafruit_LEDBackpack.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;// For LCD Shield&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;&#xA;// For pixel Units, such as hero&#xA;#include &amp;lt;Unit.h&amp;gt;&#xA;&#xA;&#xA;Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;&#xA;Unit *hero;&#xA;boolean doesNeedRedraw = true;&#xA;boolean textNeedsRedraw = true;&#xA;int8_t lastButtonPress = 0;&#xA;int8_t frame = 0;&#xA;&#xA;void setup() {&#xA;  /* Important Setup Routine */&#xA;}&#xA;&#xA;static const uint8_t PROGMEM&#xA;  smile_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10100101,&#xA;    B10011001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  neutral_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10111101,&#xA;    B10000001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  frown_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10011001,&#xA;    B10100101,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  walls_bmp[] =&#xA;  { B10100000,&#xA;    B10110000,&#xA;    B10010000,&#xA;    B11011100,&#xA;    B01000100,&#xA;    B01110100,&#xA;    B00010100,&#xA;    B00011100 };&#xA;&#xA;void loop() {&#xA;  /* Important Main Loop Routine */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9924" LastEditorUserId="9924" LastEditDate="2015-05-12T06:53:00.173" LastActivityDate="2015-05-12T06:55:01.550" Title="Arduino: Put Data in Other File" Tags="|programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11635" PostTypeId="1" CreationDate="2015-05-07T18:14:34.803" Score="1" ViewCount="1559" Body="&lt;p&gt;I'm trying to use the Arduino Uno to make a strip of LEDs blink as fast as they can while still blinking at different rates. I am able to get them blinking at different rates but the blinking is very slow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_DotStar.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;         // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET&#xA;&#xA;#define NUMPIXELS 144 // Number of LEDs in strip&#xA;&#xA;// Here's how to control the LEDs from any two pins:&#xA;#define DATAPIN    11&#xA;#define CLOCKPIN   13&#xA;Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);&#xA;&#xA;void setup() {&#xA;strip.begin(); // Initialize pins for output&#xA;strip.show();  // Turn all LEDs off ASAP&#xA;}&#xA;&#xA;  int brightness = 1; //Setting brightness of all LEDs&#xA;&#xA;   void loop() {&#xA;&#xA;  for(int i=1; i&amp;lt;6; i++) &#xA;//This loop is here so the number i can be used below to get different blink     //rates for the 3 LEDs blink at the same time&#xA;  {  &#xA;    if(i%2==0){&#xA;&#xA;    strip.setPixelColor(0, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(0, 0);&#xA;    }&#xA;    //Sets blink rate of first LED, will be the fastest&#xA;&#xA;    if(i%3==0){&#xA;&#xA;    strip.setPixelColor(1, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(1, 0);&#xA;    }&#xA;     //Sets blink rate of second LED&#xA;&#xA;    if(i%4==0){&#xA;&#xA;    strip.setPixelColor(2, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(2, 0);&#xA;    }&#xA;     //Sets blink rate of third LED&#xA;&#xA;   strip.show();&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought I would be able to make them blink as fast as possible by using the micro() function as my counter instead of the i in the for loop, but this led to strange behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_DotStar.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;         &#xA;&#xA;#define NUMPIXELS 144 // Number of LEDs in strip&#xA;&#xA;// Here's how to control the LEDs from any two pins:&#xA;#define DATAPIN    11&#xA;#define CLOCKPIN   13&#xA;Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);&#xA;&#xA;void setup() {&#xA;&#xA;  strip.begin(); // Initialize pins for output&#xA;  strip.show();  // Turn all LEDs off ASAP&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;int brightness = 1;&#xA;&#xA;void loop() {&#xA;&#xA;    int time = micros();&#xA;&#xA;    if(time%2==0){&#xA;&#xA;    strip.setPixelColor(0, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(0, 0);&#xA;    }&#xA;&#xA;  if(time%3==0){&#xA;    strip.setPixelColor(1, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(1, 0);&#xA;    }&#xA;&#xA;   if(time%4==0){&#xA;    strip.setPixelColor(1, brightness, brightness, brightness);&#xA;    }&#xA;    else&#xA;    {strip.setPixelColor(2, 0);&#xA;    }&#xA;&#xA;   strip.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This led to the first LED appearing on (good, presumably I wouldn't be able to see it blinking) and the second blinking at a rate I could see (I shouldn't be able to see this) and the third LED is not on at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone see the mistake I'm making? Am I using the micro() function right?&#xA;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="9925" LastActivityDate="2015-05-07T18:14:34.803" Title="Blinking LEDs as fast as possible at different rates." Tags="|arduino-uno|led|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11636" PostTypeId="2" ParentId="11634" CreationDate="2015-05-07T18:15:52.900" Score="3" Body="&lt;p&gt;One way to clean that up is to create a &quot;Globals.inc&quot; file and cut and paste all of your globals into there.  After that's done, simply include the globals file from your main .ino file with &lt;code&gt;#include &quot;Globals.inc&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Main.ino)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;// For LED Backpack&#xA;#include &quot;Adafruit_LEDBackpack.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;// For LCD Shield&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;&#xA;// For pixel Units, such as hero&#xA;#include &amp;lt;Unit.h&amp;gt;&#xA;&#xA;#include &quot;Globals.inc&quot;&#xA;&#xA;void setup() {&#xA;  /* Important Setup Routine */&#xA;}&#xA;&#xA;void loop() {&#xA;  /* Important Main Loop Routine */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Globals.inc)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;&#xA;Unit *hero;&#xA;boolean doesNeedRedraw = true;&#xA;boolean textNeedsRedraw = true;&#xA;int8_t lastButtonPress = 0;&#xA;// 0-255&#xA;uint8_t frame = 0;&#xA;&#xA;static const uint8_t PROGMEM&#xA;  smile_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10100101,&#xA;    B10011001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  neutral_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10111101,&#xA;    B10000001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  frown_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10011001,&#xA;    B10100101,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  walls_bmp[] =&#xA;  { B10100000,&#xA;    B10110000,&#xA;    B10010000,&#xA;    B11011100,&#xA;    B01000100,&#xA;    B01110100,&#xA;    B00010100,&#xA;    B00011100 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9924" LastEditorUserId="9924" LastEditDate="2015-05-12T06:55:01.550" LastActivityDate="2015-05-12T06:55:01.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11637" PostTypeId="1" CreationDate="2015-05-07T19:55:33.623" Score="2" ViewCount="30238" Body="&lt;p&gt;My arduino gets some data from sensors and save it into EEPROM. Now, I want that when I connect my arduino to PC there should be a software(like sketch) which can fetch data from arduino's EEPROM processes it and saves it into a file in PC. I am willing to create such a software but how will I then communicate with arduino like Sketch does?&lt;/p&gt;&#xA;" OwnerUserId="8226" LastActivityDate="2015-05-09T03:49:08.513" Title="How to transfer data from Arduino to some software in computer?" Tags="|serial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11638" PostTypeId="2" ParentId="11637" CreationDate="2015-05-07T20:45:59.417" Score="0" Body="&lt;p&gt;The options that I see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Via serial - this can either be done wirelessly via Bluetooth serial adapter, or via the standard USB connector. Your program will have to have a way of sending the data - some way to indicate that you want to download the data.&lt;/li&gt;&#xA;&lt;li&gt;Transfer via ICSP - these are the 2x3 grid of pins on your Arduino. You can download the data, without having to write any code. You will need something like a USBASP - they're cheap. You can download the entire EEPROM, and dissect it once you have it on your computer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a vague recollection that EEPROM may be overwritten when you upload a sketch, so if you want to use serial (the first option), make sure your sketch already knows how to transfer the data before you collect it. This is not a limitation for ICSP.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-05-07T20:45:59.417" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11639" PostTypeId="1" AcceptedAnswerId="11643" CreationDate="2015-05-07T22:01:08.697" Score="1" ViewCount="1597" Body="&lt;p&gt;I'm programming an arduino uno with attached screen to be a clock and have the code below. It counts up from zero the milliseconds, seconds, minutes and hours and when it hits 24 hours it starts again from zero. &#xA;Does anyone know how I can set the start time that it automatically starts at when it is reset? It will be a one off thing and I don't want it to interfere with the clock resetting to 0 hours after it hits 24. Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;#define MILLIS_OVERFLOW 34359738&#xA;&#xA;/**&#xA; * Clock Variables&#xA; */&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds, minutes, hours;&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;void setup()&#xA;{&#xA;    lcd.begin( 16, 2 ); &#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    setClock();&#xA;    /**&#xA;     * After set clock now you have 3 int variables with the current time&#xA;     */&#xA;     //seconds&#xA;     //minutes&#xA;     //hours&#xA;     lcd.setCursor ( 0, 1);&#xA;     lcd.print(hours);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(minutes);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(seconds);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(elapsedMillis);&#xA;&#xA;}&#xA;&#xA;void setClock()&#xA;{&#xA;    currentMillis = millis();&#xA;    /**&#xA;     * The only moment when currentMillis will be smaller than previousMillis&#xA; * will be when millis() oveflows&#xA; */&#xA;if (currentMillis &amp;lt; previousMillis){&#xA;    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;&#xA;} else {&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;}&#xA;&#xA;/**&#xA; * If we use equals 1000 its possible that because of the mentioned loop limitation&#xA; * you check the difference when its value is (999) and on the next loop its value is (1001)&#xA; */&#xA;if (elapsedMillis &amp;gt; 999){&#xA;    seconds++;&#xA;    elapsedMillis = elapsedMillis - 1000;&#xA;}&#xA;&#xA;if (seconds == 60){&#xA;    minutes++;&#xA;    seconds = 0;&#xA;}&#xA;if (minutes == 60){&#xA;    hours++;&#xA;    minutes = 0;&#xA;}&#xA;if (hours == 24){&#xA;    hours = 0;&#xA;}&#xA;&#xA;previousMillis = currentMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8588" LastEditorUserId="8588" LastEditDate="2015-05-07T22:47:58.570" LastActivityDate="2015-06-01T16:18:13.100" Title="Set start time for arduino uno clock" Tags="|arduino-uno|time|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11640" PostTypeId="1" AcceptedAnswerId="11641" CreationDate="2015-05-07T23:10:58.447" Score="1" ViewCount="2905" Body="&lt;p&gt;I currently have a standing desk at work, and I thought a fun way to learn Arduino would be to automate it, as it currently uses a hand crank.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would love some help determining what I would need for this task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What kind of motor should I use?&#xA;  -Stepper motor?&#xA;  -High/low rpm?&#xA;  -High/low torque? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What sort of power would I need? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking forward to hearing people's suggestions! &lt;/p&gt;&#xA;" OwnerUserId="9929" LastEditorUserId="2881" LastEditDate="2015-05-08T13:27:46.783" LastActivityDate="2015-05-08T13:27:46.783" Title="Arduino Stepper Motor Standing Desk help!" Tags="|motor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11641" PostTypeId="2" ParentId="11640" CreationDate="2015-05-08T00:27:47.830" Score="4" Body="&lt;p&gt;I think this might end up being more of a fun way to electrocute yourself, but let's find out...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Energy required to lift an object with mass &quot;m&quot; an upward distance of &quot;h&quot; in the Earth's gravitational field, on the surface...  E = mgh = m(9.8)h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to lift a 50kg desk one meter, we will need 50 x 9.8 x 1 = 490 Joules&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How fast do you want to lift it? Let's say we want it to take 10 seconds - that will give us the power level we need. Power is in watts (Joules per second) - so if we want to lift the desk in 10 seconds we need 49 watts - let's call it 50.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to produce 50 watts with a 12-volt battery, that would be 4.2 Amps. This is do-able, and it's not the high power level I expected for lifting a desk. Even if we throw in some efficiency losses, we're well within the safety zone and won't have to get out the high voltage equipment. So, I'm glad I did the math - my initial impression of this task was the joke at the beginning of the post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you need a 50 watt motor... that's easy to find. Hell, why not go way over that and get a 100-watt motor... google that...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.electricscooterparts.com/motors24volt.html&quot; rel=&quot;nofollow&quot;&gt;http://www.electricscooterparts.com/motors24volt.html&lt;/a&gt; - bang! Scooter motors! Nice!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, that's an example of how you might figure out what parts to get - it all starts with basic physics and ends with Google (or Bing if you're one of &lt;em&gt;those&lt;/em&gt; people). I simplified a lot, but you get the idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other part of this task is to figure out the control system. I would probably not use Arduino to do this. I would have three switches - one &quot;directional&quot; switch to run the motor, and two sensor switches to disconnect the directions of the motor at each end of the track. I think that's how automatic power windows in cars used to work, which explains why if you didn't hold the button down long enough, it would immediately instead of continuing to the other end - it was still sitting on the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sticking an Arduino in the mix and having it read the sensors would just waste power all day long, but you could do it that way. It's the same idea - just mount sensors on the track, which get tripped when the desk rolls up to that spot. Coding wouldn't be that tricky - when the user activates the &quot;change button&quot; or whatever, check which sensor is currently active, and move the desk the other way until the other sensor activates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're going to need a good power supply for that motor - a 24-volt &lt;strong&gt;2&lt;/strong&gt;00-watt power supply if you like to over-engineer like I do. You'll need a relay to control the motor - it needs to handle 24 volts/200 watts. Then you'll need some kind of activation button, and two sensors. You want some kind of sensor that is definitely going to be activated when the desk is in position, or you risk over-running your target, binding the mechanics, and burning the motor, and possibly the office as well. So, I would choose some kind of mechanical sensor, not a light sensor or something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should get you started on finding those parts...&#xA;&lt;a href=&quot;https://www.sparkfun.com/categories/145&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/categories/145&lt;/a&gt; - these are all kinds of buttons and switches - you should be able to find something that you can mount to the track which will activate when the desk runs into it. Search on this site for the other parts - they have the relays and stuff too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final warning though - this may be too complicated and dangerous for a first project. At 24 volts and 100 watts, we are getting into dangerous power levels. But, these are common power levels in consumer equipment. So, if you know what you're doing you should be safe. If you don't, I strongly suggest getting an experienced electrical engineer to look at your designs. Also, you probably can't install this device in an office - there is an insurance reason that it hand-cranks, your company isn't just being cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens if someone bumps the desk and it becomes active when you're not around? What happens when the power goes out? What happens when the power comes back on? Do we have enough fuses in the right places to shut this system down before it catches fire? You need to consider all that.&lt;/p&gt;&#xA;" OwnerUserId="228" LastEditorUserId="228" LastEditDate="2015-05-08T00:34:45.523" LastActivityDate="2015-05-08T00:34:45.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11642" PostTypeId="2" ParentId="11640" CreationDate="2015-05-08T02:18:33.837" Score="2" Body="&lt;p&gt;For initial playing,  and possibly for a final solution, battery powered electric drills with external powering are an excellent source of reasonable wattage well geared down motors. Drills are often discarded when the batteries die and may be available free or at lo cost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For relatively low duty cycle use 9V drills operate OK on a small 12V battery and drills rated at up to 18V usually operate well enough on 12V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use of a 12V lead acid battery charged by a trickle charger makes high current peaks easy to accommodate. Almot any condition battery will do - one which is too dead for eg motorcyle use probably works well enough here. Floating 12V lead acid batteries at 13.7 V allows them to be permanenetly connected to the &quot;charger&quot;.  A power pack can be used without a battery if enough current is provided.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Battery powered drills typically have a  two stage epicyclic gearbox giving typically hundreds of RPM output speed. If desired you can use the supplied switching which has a DPDT mechanical reversing switch. If you remove the mechanical reversing switch you can feed voltage directly to the motor. Changing polarity changes direction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dismantling the gearbox can be educational but may be a one way journey. Beware a flood of ball bearings. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-08T02:18:33.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11643" PostTypeId="2" ParentId="11639" CreationDate="2015-05-08T06:29:51.287" Score="3" Body="&lt;p&gt;Assume you want the clock to start at 08:42:21, change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int seconds, minutes, hours;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int seconds = 21, minutes = 42, hours = 8;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you should always also initialize (as in the second case above), and not only declare (as in the first case) all variables before you first read their values. Otherwise, for local variables you &lt;a href=&quot;https://stackoverflow.com/a/11233616/143931&quot;&gt;cannot be sure&lt;/a&gt; what their initial value is. (Global variables are &lt;a href=&quot;https://stackoverflow.com/q/14049777/143931&quot;&gt;implicitly initialized&lt;/a&gt; to zero if not explicitly initialized.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-06-01T16:18:13.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11644" PostTypeId="2" ParentId="11637" CreationDate="2015-05-08T07:46:47.040" Score="0" Body="&lt;p&gt;You should specify what programming language/compiler/IDE you want to use for the part on your pc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using &quot;Processing&quot; - &lt;a href=&quot;https://processing.org/&quot; rel=&quot;nofollow&quot;&gt;https://processing.org/&lt;/a&gt; it's a similiar IDE as the arduino IDE and the coding is also a bit similiar. You can use a serial library to receive data from USB/COM port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Processing has the ability to create a window with graphics. You could read the position of something with your arduino, then send it to 'processing' and it will draw the object on the screen (after a bit of coding).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Guide: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-05-08T07:46:47.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11645" PostTypeId="2" ParentId="10563" CreationDate="2015-05-08T08:41:24.557" Score="0" Body="&lt;p&gt;Well, found the problem but I don't know why. It was your variable declarations. The following code with &quot;main, right, and left&quot; integer variables commented out ran, the original didn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;decode_results results;&#xA;//int main = 0;&#xA;//int left = 0;&#xA;//int right = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    Serial.println(results.value, HEX);&#xA;        switch (results.value) {&#xA;      case 0xB9F56762:&#xA;        Serial.println(&quot;MARNIX IS RIGHT&quot;);&#xA;        break;&#xA;        case 0x8C2921D6:&#xA;//        left = 1;&#xA;        Serial.println(&quot;LEFT: on&quot;);&#xA;        break;&#xA;      case 0x226270DA:&#xA;//        right = 1;&#xA;        Serial.println(&quot;RIGHT: on&quot;);&#xA;        break;&#xA;    }&#xA;    irrecv.resume();&#xA;&#xA;&#xA;  }&#xA;   delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8477" LastActivityDate="2015-05-08T08:41:24.557" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11646" PostTypeId="1" AcceptedAnswerId="11724" CreationDate="2015-05-08T08:58:56.433" Score="0" ViewCount="473" Body="&lt;p&gt;I have a two-relay system set up to a DC motor. So, if I close one relay, the motor moves on one way and if I close the second relay (and open the first) the motor goes on the other direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I compare two variables (target inclination and real inclination) if they are not the same I would like to open one of the two relays UNTIL the are the same value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both variables are calculated based on inclinometer input and some aritmethics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do know how to calculate the variables, how to close the relay based in the comparation of variables and which relay open. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don´t know how I can tell to open the relay because the motor has reached target inclination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I can recalculate and compare constantly target inclination and real inclination when the relay is closed and the motor moving?&#xA;Is this posible on Arduino? Is this multithreading?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much, any ideas are welcome!&lt;/p&gt;&#xA;" OwnerUserId="9931" LastActivityDate="2015-05-31T15:57:58.840" Title="Relay feedback control" Tags="|arduino-mega|motor|relay|solar|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11647" PostTypeId="2" ParentId="10484" CreationDate="2015-05-08T09:42:57.660" Score="1" Body="&lt;p&gt;You can use Ardulink. It's a java open source project of mine. It can control an Arduino boad. So you have just to write a servlet that call my library. That's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this post to understand how install ardulink in a PI: &lt;a href=&quot;http://www.ardulink.org/how-to-install-arduino-pc-link-on-raspberry-pi/&quot; rel=&quot;nofollow&quot;&gt;http://www.ardulink.org/how-to-install-arduino-pc-link-on-raspberry-pi/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read a sample code that sends some messages to Arduino you can read this post:&#xA;&lt;a href=&quot;http://www.ardulink.org/how-to-blink-a-led/&quot; rel=&quot;nofollow&quot;&gt;http://www.ardulink.org/how-to-blink-a-led/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most important statement is &lt;strong&gt;Link link = Link.getDefaultInstance();&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Link&lt;/strong&gt; is the Ardulink class you need to send (and receive) messages.&lt;/p&gt;&#xA;" OwnerUserId="9934" LastEditorUserId="9934" LastEditDate="2015-05-08T10:00:48.737" LastActivityDate="2015-05-08T10:00:48.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11648" PostTypeId="1" CreationDate="2015-05-08T10:11:34.140" Score="2" ViewCount="67" Body="&lt;p&gt;When Arduino was conceived AVR was very much the best 8-bit controller available. But we're 10 years on now, and still using the AVR, despite lots of better microcontrollers available, notably ARMs. In particular M0 and M0+ cores are a lot cheaper, yet are a lot faster and have many more features than AVR.&lt;br&gt;&#xA;For instance the NXP LPC824 has more serial buses, more A/D channels and higher A/D resolution, is almost twice as fast as the AVR, yet costs 30% less. (Granted, it doesn't have EEPROM, but you can have that for 20 cents.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was wondering if there are particular issues which prevent the use of more modern microcontrollers on Arduino.&lt;br&gt;&#xA;One difference may be Vcc, which is 5V for AVR and 3.3V for ARM. But given that more peripherals work at 3.3V this seems more to be an AVR issue than an ARM issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I'm aware of Arduino Due, but that one costs twice as much as a Uno. I'm talking about controllers which price-wise can compete with AVR.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-08T11:57:38.903" Title="What are possible issues when moving Arduino to another microcontroller?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11649" PostTypeId="1" AcceptedAnswerId="11652" CreationDate="2015-05-08T10:30:28.203" Score="1" ViewCount="244" Body="&lt;p&gt;I write a code to store patterns for LED blinking, but I got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led_basics:39: error: cannot convert 'char (*)[17][2]' to 'char*' in initialization&#xA;&#xA;led_basics:39: error: cannot convert 'char (*)[16][2]' to 'char*' in initialization&#xA;&#xA;led_basics:39: error: cannot convert 'char (*)[13][2]' to 'char*' in initialization &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on for all pattern.&#xA;How can I fix it?&#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char nulla[17][2]={{0,127},{8,125},{9,121},{10,113},{12,97},{14,65},{24,67},{27,71},{28,70},{30,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};&#xA;&#xA;char egy[16][2]={{0,0},{9,4},{16,6},{18,2},{21,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};&#xA;&#xA;char ketto[13][2]={{0,98},{7,99},{8,97},{12,113},{14,81},{20,89},{21,88},{24,74},{27,78},{30,70},{32,68},{36,64},{68,0}};&#xA;&#xA;char harom[17][2]={{0,34},{7,35},{8,33},{10,41},{14,9},{17,73},{21,72},{24,74},{27,78},{30,70},{32,68},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};&#xA;&#xA;char negy[17][2]={{0,7},{7,6},{8,4},{9,0},{10,8},{21,9},{24,11},{27,15},{28,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};&#xA;&#xA;char ot[14][2]={{0,39},{8,37},{9,33},{10,41},{14,9},{17,73},{28,72},{30,64},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};&#xA;&#xA;char hat[17][2]={{0,62},{7,63},{8,61},{9,57},{12,41},{14,9},{17,73},{21,72},{24,74},{30,66},{32,64},{36,80},{42,112},{48,96},{51,32},{56,0},{68,0}};&#xA;&#xA;char het[15][2]={{0,7},{8,5},{9,1},{24,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};&#xA;&#xA;char nyolc[15][2] = {{0,127},{8,125},{9,121},{12,105},{14,73},{24,75},{27,79},{28,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};&#xA;&#xA;char kilenc[13][2] = {{0,79},{8,77},{9,73},{24,75},{27,79},{28,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};&#xA;&#xA;char kettospont[6][2] = {{0,0},{9,4},{12,20},{18,16},{24,0},{68,0}};&#xA;&#xA;char *karakterek[11]={&amp;amp;nulla,&amp;amp;egy,&amp;amp;ketto,&amp;amp;harom,&amp;amp;negy,&amp;amp;ot,&amp;amp;hat,&amp;amp;het,&amp;amp;nyolc,&amp;amp;kilenc,&amp;amp;kettospont};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9935" LastActivityDate="2015-05-08T15:55:18.300" Title="cannot convert error with pointers" Tags="|arduino-uno|c|pointer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11651" PostTypeId="2" ParentId="11648" CreationDate="2015-05-08T11:57:38.903" Score="2" Body="&lt;p&gt;There is NO &lt;em&gt;best&lt;/em&gt; 8 bit or 16 or whatever bit uC (micro controller).&lt;br&gt;&#xA;There always have been &quot;better&quot; ones and there always will be and better changes with your need as well as with time.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want or need a faster or more capable processor, use one.&lt;br&gt;&#xA;For many tasks the existing AVR processors are very fine indeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A number of people are making Arduino-like uC's using ARM right now.&lt;br&gt;&#xA;You can buy them 'off the shelf'.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &quot;Arduino&quot; code is where issues arise:&lt;br&gt;&#xA;If you are willing to run 100% standard Arduino code applications will usually run well on the new uC.&lt;br&gt;&#xA;If applications use precompiled libraries and you wish to use eg an ARM it will not run.&lt;br&gt;&#xA;If you recompile the libraries and they are written in a compatible language flavor (C or whatever) then they MAY work for your new processor.&lt;br&gt;&#xA;If they use assembler then they will not work in essentially all cases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, existing 'Arduino' hardware can use the high level language of your choice. &#xA;A new processor with a compatible compiler will compile eg C code that runs on Arduino hardware BUT port locations, register control methods etc need to be correctly allowed for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gets harder and harder as you try to fit the new giants into the old not-so-giant framework. Somewhere along the way it is easier to give up the attempt and use the Arduino for what it is good for and the 'new' processor where necessary.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Whatever the Arduino did well when new it still does well.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In most cases the speed, peripherals and memory capabilities are entirely fine for tasks that people who wish to use it wish to do.&lt;br&gt;&#xA;The main issue is that an Arduino is not something it is not, just as a small family car is not a bus or a sportscar. Use the car where it is useful and use a bus or sportscar when necessary. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-08T11:57:38.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11652" PostTypeId="2" ParentId="11649" CreationDate="2015-05-08T12:17:26.950" Score="1" Body="&lt;p&gt;karakterek is an array of char pointers.  It cannot be used to store pointers to char arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure it would be possible to store pointers to your 2 dimensional arrays since they are all of different dimensions.  Someone else might know a way to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I would do it (using as similar as possible a structure):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char nulla[]={0,127,8,125,9,121,10,113,12,97,14,65,24,67,27,71,28,70,30,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};&#xA;&#xA;char egy[]={0,0,9,4,16,6,18,2,21,3,27,7,28,6,30,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};&#xA;&#xA;char ketto[]={0,98,7,99,8,97,12,113,14,81,20,89,21,88,24,74,27,78,30,70,32,68,36,64,68,0};&#xA;&#xA;char harom[]={0,34,7,35,8,33,10,41,14,9,17,73,21,72,24,74,27,78,30,70,32,68,36,80,42,112,48,96,51,32,56,0,68,0};&#xA;&#xA;char negy[]={0,7,7,6,8,4,9,0,10,8,21,9,24,11,27,15,28,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};&#xA;&#xA;char ot[]={0,39,8,37,9,33,10,41,14,9,17,73,28,72,30,64,36,80,42,112,48,96,51,32,56,0,68,0};&#xA;&#xA;char hat[]={0,62,7,63,8,61,9,57,12,41,14,9,17,73,21,72,24,74,30,66,32,64,36,80,42,112,48,96,51,32,56,0,68,0};&#xA;&#xA;char het[]={0,7,8,5,9,1,24,3,27,7,28,6,30,14,32,12,36,24,40,16,42,48,48,32,51,96,56,64,68,0};&#xA;&#xA;char nyolc[] = {0,127,8,125,9,121,12,105,14,73,24,75,27,79,28,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};&#xA;&#xA;char kilenc[] = {0,79,8,77,9,73,24,75,27,79,28,78,32,76,36,88,40,80,42,112,48,96,56,64,68,0};&#xA;&#xA;char kettospont[] = {0,0,9,4,12,20,18,16,24,0,68,0};&#xA;&#xA;char* karakterek[]={nulla,egy,ketto,harom,negy,ot,hat,het,nyolc,kilenc,kettospont};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For starters, I'd make the char arrays single dimension.  Since the 2nd dimension is always a size of 2, you could index through your values reading index 0 into x0, index 1 to y0, index 2 to x1 and index 3 to y1 (I'm assuming these are x y co-ordinate pairs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, I'd lose the hard-coded sizes for the arrays.  If you want to add or remove entries, you don't have to keep updating the sizes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I'd lose the '&amp;amp;' from your array of array pointers.  Referring to an array simply by its name gives you a pointer to it.  I think '&amp;amp;' gives you a pointer to the pointer, but I could be wrong.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-08T12:17:26.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11653" PostTypeId="2" ParentId="11609" CreationDate="2015-05-08T13:19:17.023" Score="0" Body="&lt;p&gt;my arduino revived the next day.... don't know why but it works!&lt;/p&gt;&#xA;" OwnerUserId="9903" LastActivityDate="2015-05-08T13:19:17.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11655" PostTypeId="2" ParentId="11634" CreationDate="2015-05-08T14:46:55.707" Score="2" Body="&lt;p&gt;There is actually not a lot wrong with the way the code is.  You are writing / using embedded code. It is not expected to be some planned out UML model, and does not need to look like it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want less lines, start by converting your binary data to hex. Otherwise the answer of a global.h is valid (and I would still convert binary to hex). You could easily shrink 24 lines down to 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you could use a real IDE navigation would be unimportant, but since Arduino chose not to use a standard build process it takes extra effort (but still worth it). You could also switch to native AVR (and easily use a real IDE), which is what I plan to do as soon as the proof of concept is finished.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-08T14:46:55.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11656" PostTypeId="2" ParentId="10552" CreationDate="2015-05-08T15:36:44.447" Score="2" Body="&lt;p&gt;Others mention a Real-Time Clock (RTC), and it may look like the obvious choice, but maybe it isn't. All a RTC does is keep counters for hours, minutes, seconds, date and month, but your microcontroller can do that as well.&lt;br&gt;&#xA;Unfortunately the Uno doesn't have a crystal, but a ceramic resonator, which isn't nearly as accurate. Not that it matters much, even a crystal-based RTC may deviate several seconds a day. You can measure the error over a long time, and correct at regular times in software, but this is tedious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want long-time accuracy there are two cheap ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use an atomic clock receiver. In Europe there's DCF77, in North-America it's WWVB which broadcasts very accurate date and time information. A receiver module for these costs around 10 dollar&lt;/li&gt;&#xA;&lt;li&gt;use the mains frequency to clock your clock. On the long term this is extremely accurate (just think about your alarm clock: how often do you have to adjust that?) In Europe you would count 100 half periods per second (120 in the US). When your counter reaches that count, reset it and increment the seconds. If seconds reaches 60, reset it and increment minutes. And so on. If you're not exactly electronics-savvy you can ask on &lt;a href=&quot;http://electronics.stackexchange.com&quot;&gt;electronics.stackexchange.com&lt;/a&gt; to help you out. It's not difficult.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-08T15:36:44.447" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11657" PostTypeId="1" AcceptedAnswerId="11660" CreationDate="2015-05-08T15:46:43.973" Score="7" ViewCount="2794" Body="&lt;p&gt;I came across this &lt;a href=&quot;http://www.instructables.com/id/Simple-2-way-motor-control-for-the-arduino/&quot; rel=&quot;noreferrer&quot;&gt;instructable&lt;/a&gt; about using no external hardware but two pwm pins to control a motor in both directions. Usually you would use an H bridge. However, ever since I have had my Arduino I have heard that you are not supposed to connect a pin to another pin. So how does this circuit works. It looks like he sends a signal from one pin and in my experience it would fry the board. So basically, my question is this circuit ok with an Arduino Nano and if so how does it work? Below is a picture of the setup he gave:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/KPyz3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2016-07-03T14:39:54.427" Title="How does this Motor Circuit not ruin the Microcontroller" Tags="|arduino-nano|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11658" PostTypeId="2" ParentId="11657" CreationDate="2015-05-08T15:52:02.257" Score="1" Body="&lt;p&gt;You are not supposed to connect one pin directly to another pin because the current will destroy the electronics connected to the pins. The motor provides a small impedance and limits the current flowing (although the amount of current will increase if the motor stalls).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the other reason you missed for the MCU possibly being damaged, the answer is that it is absorbed by the input protection diodes and subsequently the supply.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-08T15:52:02.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11659" PostTypeId="2" ParentId="11649" CreationDate="2015-05-08T15:55:18.300" Score="1" Body="&lt;p&gt;As the second dimension is always 2, you can do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef char Tuple[2];&#xA;&#xA;Tuple nulla[17] = {{0,127},{8,125},{9,121},{10,113},{12,97},{14,65},{24,67},{27,71},{28,70},{30,78},{32,76},{36,88},{40,80},{42,112},{48,96},{56,64},{68,0}};&#xA;Tuple egy[16]   = {{0,0},{9,4},{16,6},{18,2},{21,3},{27,7},{28,6},{30,14},{32,12},{36,24},{40,16},{42,48},{48,32},{51,96},{56,64},{68,0}};&#xA;Tuple ketto[13] = {{0,98},{7,99},{8,97},{12,113},{14,81},{20,89},{21,88},{24,74},{27,78},{30,70},{32,68},{36,64},{68,0}};&#xA;// etc.&#xA;&#xA;Tuple* karakterek[3] = {nulla, egy, ketto}; // etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(The &lt;code&gt;typedef&lt;/code&gt; makes it easier.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-08T15:55:18.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11660" PostTypeId="2" ParentId="11657" CreationDate="2015-05-08T16:09:48.027" Score="4" Body="&lt;p&gt;This is a bad idea, but not because two pins seem to be connected directly. They're not; there is a load (the motor) between the pins, and that motor will take care of different levels between the pins. High and low will make the motor turn one way, low and high the other way, and the same level on both pins will stop the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this bad? An I/O pin can only supply a limited current, and even for a small motor that will peak rather high. If you run the motor for some time this way you will damage the I/O ports. An H-bridge, like you mention, is the solution.&lt;br&gt;&#xA;Note that electric motors cause a lot of noise in the power supply, which may cause the microcontroller to reset all the time, so that your program doesn't work. (The motor may seem to start/stop all the time.) You need to decouple the power supply with capacitors.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-08T16:09:48.027" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11662" PostTypeId="2" ParentId="7896" CreationDate="2015-05-08T19:13:18.387" Score="0" Body="&lt;p&gt;The protocol is peculiar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are to send the command unterminated within one second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the AT command comprises the two characters AT and nothing more, no line ending at all. And the command must be completed within one second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So,&lt;br&gt;&#xA;AT[cr][lf] will just be ignored.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-05-08T19:13:18.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11663" PostTypeId="1" CreationDate="2015-04-14T20:19:55.893" Score="3" ViewCount="504" Body="&lt;p&gt;I need a help with this question. I'm trying to make a Wheatstone Bridge with Arduino, the main idea is read the two legs of the circuit with two analog inputs of Arduino, for the while I'm analyzing the values with 4 equal resistors as the Arduino reads (0 to 1023 bits). The problem is when I change one of the resistors (Rx), the voltage on A0 (first leg C) should not be changed, but it happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bIYSn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read something about the analog inputs of the Arduino suffer interference, but I don't know how to avoid this.&lt;/p&gt;&#xA;" OwnerDisplayName="Ivanks" LastEditorUserId="7508" LastEditDate="2015-06-07T13:19:22.107" LastActivityDate="2015-06-07T13:19:22.107" Title="Accuracy reading two analog inputs on Arduino" Tags="|analogread|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11664" PostTypeId="1" AcceptedAnswerId="11666" CreationDate="2015-05-08T20:28:49.880" Score="1" ViewCount="7113" Body="&lt;p&gt;I'm trying to send data saved on a txt file to arduino over serial connection. I wrote this simple sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    Serial.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to send serial data from bash by typing &lt;code&gt;cat input.txt &amp;gt;&amp;gt; /dev/cu.wchusbserial1a1340&lt;/code&gt; while the Arduino's serial connection window is open. It gives an error message &quot;resource busy: /dev/cu.wchusbserial1a1340&quot;. Then I tried &lt;code&gt;cat input.txt &amp;gt;&amp;gt; /dev/tty.wchusbserial1a1340&lt;/code&gt;. Now it hangs. Bash is busy, and it is not possible close Arduino IDE or serial connection window. What is wrong here?&lt;/p&gt;&#xA;" OwnerUserId="8687" LastActivityDate="2015-05-09T01:56:57.757" Title="Sending data from txt file over serial connection" Tags="|serial|communication|terminal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11665" PostTypeId="2" ParentId="5327" CreationDate="2015-05-08T22:11:19.947" Score="1" Body="&lt;p&gt;Previous versions of arduino-mk had a dependency on arduino, which was everything, but with the split out of arduino-core, which both of the other packages now depend, arduino only includes the ide, everything else is in core so that you do not need the ide to develop, compile and load standard projects to your Arduino. I have only used the ide for less than 15 minutes And do all my work using vi and the command line. the makefile allows you to compile ino files with a make just by linking it into your project directory, it also has options for uploading using make.&lt;/p&gt;&#xA;" OwnerUserId="445" LastActivityDate="2015-05-08T22:11:19.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11666" PostTypeId="2" ParentId="11664" CreationDate="2015-05-08T22:58:20.143" Score="3" Body="&lt;p&gt;I don't know the details of why the hang is occurring.  However, the problem stems from serial ports being available to one process at a time.  When the Arduino-environment's serial-port-monitor opens a serial port, that port becomes unavailable to bash.  (To close the hung Arduino IDE process and the SPM, say &lt;code&gt;ps aux |grep arduino&lt;/code&gt; and &lt;code&gt;kill&lt;/code&gt; &lt;em&gt;n&lt;/em&gt;, where &lt;em&gt;n&lt;/em&gt; is the PID shown by the &lt;code&gt;ps&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a python program you can run, that sends and receives data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;# Send data to an Arduino and report responses.&#xA;from time import time, sleep, asctime, localtime&#xA;from serial import Serial&#xA;print 'Opening serial port'&#xA;ser = Serial('/dev/ttyACM0', 9600, timeout=3)&#xA;sleep(1)                      # Let board initialize&#xA;while 1:&#xA;    txt = 'It is about ' + asctime(localtime()) + ' now'&#xA;    print 'Sending  &quot;{}&quot;'.format(txt)&#xA;    ser.write(txt)&#xA;    s = ser.readline()          # Get result from arduino&#xA;    print 'Readback &quot;{}&quot; at {}'.format(s, asctime(localtime()))&#xA;    sleep(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is some sample output from it, with your sketch runing in a Mega2650.  (I'm not sure why the readback is taking so long as it apparently is.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Opening serial port&#xA;Sending  &quot;It is about Fri May  8 16:48:41 2015 now&quot;&#xA;Readback &quot;It is about Fri May  8 16:48:41 2015 now&quot; at Fri May  8 16:48:44 2015&#xA;Sending  &quot;It is about Fri May  8 16:48:45 2015 now&quot;&#xA;Readback &quot;It is about Fri May  8 16:48:45 2015 now&quot; at Fri May  8 16:48:48 2015&#xA;Sending  &quot;It is about Fri May  8 16:48:49 2015 now&quot;&#xA;Readback &quot;It is about Fri May  8 16:48:49 2015 now&quot; at Fri May  8 16:48:52 2015&#xA;Sending  &quot;It is about Fri May  8 16:48:53 2015 now&quot;&#xA;Readback &quot;It is about Fri May  8 16:48:53 2015 now&quot; at Fri May  8 16:48:56 2015&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-08T22:58:20.143" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11668" PostTypeId="1" CreationDate="2015-05-08T23:21:44.417" Score="0" ViewCount="5066" Body="&lt;p&gt;I'm on a project to sense any amounts of methane in the home. I have bought the popular MQ-4 methane sensor from SparkFun: &lt;a href=&quot;https://www.sparkfun.com/products/9404&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9404&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked online for any sample code, but I am confused as to whether the input from the sensor is already given in parts per million, or it is just a voltage. To be specific, here is the sample code the data sheet for the sensor gives: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);      // sets the serial port to 9600&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  sensorValue = analogRead(0);       // read analog input pin 0&#xA;  Serial.println(sensorValue, DEC);  // prints the value read&#xA;  delay(100);                        // wait 100ms for next reading&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also used a breakout board for these sensors: &lt;a href=&quot;https://www.pololu.com/product/1479&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/product/1479&lt;/a&gt;&#xA;The sensor is soldered on it, along with a 20K ohm load resistor, like how the spec. sheet specifies. &#xA;However, I am confused on the readings I am getting. It's always something that ranges between 259 and 261. Is this ppm of methane in my home? If it is, shouldn't the normal level be 0? I currently have no methane based heating. Or is the 259 - 261 voltage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2015-05-09T12:07:36.783" Title="Sensing concentration of methane with MQ-4 methane sensor?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11669" PostTypeId="2" ParentId="11664" CreationDate="2015-05-09T01:56:57.757" Score="1" Body="&lt;p&gt;As noted by jwpat7 the port can be accessed by one application at a time, so when the serial monitor is open no other application can access it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hang might happen because when first connecting to an arduino port the arduino gets reset and waits for a second or so for programming data (that's how a new sketch is updated). I don't know for sure, but this might mess up with &lt;code&gt;cat&lt;/code&gt; and make it to hang up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best option might be to make a script like jwpat7's that would wait a second after opening the port and then send the file contents in.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-09T01:56:57.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11670" PostTypeId="2" ParentId="11668" CreationDate="2015-05-09T03:24:47.277" Score="2" Body="&lt;p&gt;Actually, you are getting raw data from the sensor. A little bit of math should be done in order to calibrate it and based on the chart in datasheet, measure the real value in PPM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The calibration basically helps you find R0, which is an internal resistance (along with RS form a voltage divider) that could be derived by doing calibration in a clean environment. After that, you use R0 to calculate a ratio and then look at the datasheet's chart to measure whatever gas you want since there is a curve describing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please refer to this &lt;a href=&quot;http://sandboxelectronics.com/?p=165&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; for more information. I have developed a similar application using MQ-4 before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is related to MQ-2, you may have noticed that all theses sensors have similar features and principle applications.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-09T03:24:47.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11671" PostTypeId="2" ParentId="11637" CreationDate="2015-05-09T03:36:04.067" Score="5" Body="&lt;p&gt;Just use serial communication. Make sure you know which port your Arduino is recognized in your system, make a sketch to send data through Arduino's &lt;a href=&quot;http://www.arduino.cc/en/Serial/Write&quot; rel=&quot;noreferrer&quot;&gt;serial communication&lt;/a&gt; and try making a simple &lt;a href=&quot;https://nodejs.org/&quot; rel=&quot;noreferrer&quot;&gt;Node.js&lt;/a&gt; application using &lt;a href=&quot;https://www.npmjs.com/package/serialport&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;serialport&lt;/strong&gt;&lt;/a&gt; package which will receive your data. There is a code sample where you can start from. Just set the port and start receiving data. And that's good, using Node.js you are really close to web tools, so it's easy to migrate your application to web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really simple and you can get it done in a few minutes, even if you have not been introduced to node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These kind of embedded applications have been accepted by Node.js and there are plenty of robotics projects which use node on the web.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var SerialPort = require(&quot;serialport&quot;).SerialPort&#xA;var serialPort = new SerialPort(&quot;/dev/ttyACM0&quot;, {&#xA;  baudrate: 57600&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usually Arduino is recognized as ttyACM0 on Unix-based systems.&#xA;With this line of code you establish a serial communication with your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going further you can register events like data, which is fired when data comes from Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// it opens the connection and register an event 'data'&#xA;serialPort.on(&quot;open&quot;, function () {&#xA;  console.log('Communication is on!');&#xA;&#xA;  // when your app receives data, this event is fired&#xA;  // so you can capture the data and do what you need&#xA;  serialPort.on('data', function(data) {&#xA;    console.log('data received: ' + data);&#xA;  });&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example your app just receives data and log it to your terminal.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="8478" LastEditDate="2015-05-09T03:49:08.513" LastActivityDate="2015-05-09T03:49:08.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11673" PostTypeId="1" CreationDate="2015-05-09T07:22:16.113" Score="1" ViewCount="318" Body="&lt;p&gt;Not able to upload sketches to standalone arduino on breadboard (with Atmega328 bootloaded with blink LED program). Searched on the internet but there is no solution. Help ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;error : &#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OS: Ubuntu 14.04 LTS&lt;/p&gt;&#xA;" OwnerUserId="9951" LastEditorUserId="9951" LastEditDate="2015-05-09T07:27:24.960" LastActivityDate="2019-04-23T17:50:55.183" Title="Unable to Upload" Tags="|atmega328|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11674" PostTypeId="1" AcceptedAnswerId="11927" CreationDate="2015-05-09T08:32:52.753" Score="1" ViewCount="3703" Body="&lt;p&gt;I'm trying to program my ATtiny 13 - 20PU. An it seems to work, but there is no action upon the &quot;delay&quot; command. If on the sketch below I comment out the &quot;High&quot; line, my led is off all the time and whenever I have a &lt;code&gt;Pin 4 High&lt;/code&gt;, it's on all the time! Basically this seems to be a frequency/fuse/bootloader problem and made me think the upload was broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added a led between the tiny's pin 3 (digital pin 4) and ground with a 1k current limiting resistor. This one is for testing with the attached sketch.&#xA;I also tried &lt;a href=&quot;http://highlowtech.org/?p=1706&quot; rel=&quot;nofollow&quot;&gt;this breadboard circuit&lt;/a&gt;, which gives exactly the same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon upload to the tiny I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 380 bytes (37%) of program storage space. Maximum is 1,024 bytes.&#xA;Global variables use 8 bytes of dynamic memory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Everybody warns about 2 errors occuring upon a proper upload - I don't get those).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My boards.txt look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;menu.cpu=Processor&#xA;menu.clock=Clock&#xA;&#xA;attiny.name=ATtiny&#xA;attiny.bootloader.tool=arduino:avrdude&#xA;attiny.bootloader.unlock_bits=0xff&#xA;attiny.bootloader.lock_bits=0xff&#xA;attiny.build.core=arduino:arduino&#xA;attiny.build.board=attiny&#xA;attiny.upload.tool=arduino:avrdude&#xA;&#xA;attiny.menu.cpu.attiny45=ATtiny45&#xA;attiny.menu.cpu.attiny45.upload.maximum_size=4096&#xA;attiny.menu.cpu.attiny45.build.mcu=attiny45&#xA;attiny.menu.cpu.attiny45.build.variant=tiny8&#xA;&#xA;attiny.menu.cpu.attiny85=ATtiny85&#xA;attiny.menu.cpu.attiny85.upload.maximum_size=8192&#xA;attiny.menu.cpu.attiny85.build.mcu=attiny85&#xA;attiny.menu.cpu.attiny85.build.variant=tiny8&#xA;&#xA;attiny.menu.cpu.attiny44=ATtiny44&#xA;attiny.menu.cpu.attiny44.upload.maximum_size=4096&#xA;attiny.menu.cpu.attiny44.build.mcu=attiny44&#xA;attiny.menu.cpu.attiny44.build.variant=tiny14&#xA;&#xA;attiny.menu.cpu.attiny84=ATtiny84&#xA;attiny.menu.cpu.attiny84.upload.maximum_size=8192&#xA;attiny.menu.cpu.attiny84.build.mcu=attiny84&#xA;attiny.menu.cpu.attiny84.build.variant=tiny14&#xA;&#xA;attiny.menu.clock.internal1=1 MHz (internal)&#xA;attiny.menu.clock.internal1.bootloader.low_fuses=0x62&#xA;attiny.menu.clock.internal1.bootloader.high_fuses=0xdf&#xA;attiny.menu.clock.internal1.bootloader.extended_fuses=0xff&#xA;attiny.menu.clock.internal1.build.f_cpu=1000000L&#xA;&#xA;attiny.menu.clock.internal8=8 MHz (internal)&#xA;attiny.menu.clock.internal8.bootloader.low_fuses=0xe2&#xA;attiny.menu.clock.internal8.bootloader.high_fuses=0xdf&#xA;attiny.menu.clock.internal8.bootloader.extended_fuses=0xff&#xA;attiny.menu.clock.internal8.build.f_cpu=8000000L&#xA;&#xA;attiny.menu.clock.external8=8 MHz (external)&#xA;attiny.menu.clock.external8.bootloader.low_fuses=0xfe&#xA;attiny.menu.clock.external8.bootloader.high_fuses=0xdf&#xA;attiny.menu.clock.external8.bootloader.extended_fuses=0xff&#xA;attiny.menu.clock.external8.build.f_cpu=8000000L&#xA;&#xA;attiny.menu.clock.external16=16 MHz (external)&#xA;attiny.menu.clock.external16.bootloader.low_fuses=0xfe&#xA;attiny.menu.clock.external16.bootloader.high_fuses=0xdf&#xA;attiny.menu.clock.external16.bootloader.extended_fuses=0xff&#xA;attiny.menu.clock.external16.build.f_cpu=16000000L&#xA;&#xA;attiny.menu.clock.external20=20 MHz (external)&#xA;attiny.menu.clock.external20.bootloader.low_fuses=0xfe&#xA;attiny.menu.clock.external20.bootloader.high_fuses=0xdf&#xA;attiny.menu.clock.external20.bootloader.extended_fuses=0xff&#xA;attiny.menu.clock.external20.build.f_cpu=20000000L&#xA;&#xA;&#xA;#################################################&#xA;attiny.menu.cpu.attiny13=ATtiny13&#xA;attiny.menu.cpu.attiny13.upload.maximum_size=1024&#xA;attiny.menu.cpu.attiny13.build.mcu=attiny13&#xA;attiny.menu.cpu.attiny13.build.variant=core13&#xA;&#xA;attiny.menu.clock.internal96=9.6MHz (internal)&#xA;attiny.menu.clock.internal96.bootloader.low_fuses=0x7A&#xA;attiny.menu.clock.internal96.bootloader.high_fuses=0xff&#xA;attiny.menu.clock.internal96.build.f_cpu=9600000L&#xA;################################################&#xA;&#xA;attiny.menu.clock.internal48=4.8MHz (internal)&#xA;attiny.menu.clock.internal48.bootloader.low_fuses=0x79&#xA;attiny.menu.clock.internal48.bootloader.high_fuses=0xff&#xA;attiny.menu.clock.internal48.build.f_cpu=4800000L&#xA;################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I choose the settings: Board ATtiny, Processor ATtiny13, Clock 9.6 MHz (internal), Port Arduino Uno (same as when I upload the ISP sketch), Programmer Arduino as ISP. I upload by clicking &quot;Upload using Programmer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Software is 1.6.4, the programmer Arduino is an Uno SMD edition.&#xA;I used this &lt;a href=&quot;https://arduinodiy.wordpress.com/2015/03/31/1256/#comment-907&quot; rel=&quot;nofollow&quot;&gt;programmer&lt;/a&gt; and this &lt;a href=&quot;https://arduinodiy.wordpress.com/2015/04/26/installing-attiny13-core-files-in-arduino-ide-1-6-x-and-1-7-x/&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; for smeezkitty core13. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to upload this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Blink sketch to test ATtiny Chips&#xA;&#xA;//       ATMEL ATTINY13 / ARDUINO&#xA;//&#xA;//                 +-\/-+&#xA;// ADC0 (D 5) PB5 1|*   |8 Vcc&#xA;// ADC3 (D 3) PB3 2|    |7 PB2 (D 2) ADC1&#xA;// ADC2 (D 4) PB4 3|    |6 PB1 (D 1) PWM1&#xA;//            GND 4|    |5 PB0 (D 0) PWM0&#xA;//                 +----+&#xA;&#xA;&#xA;const int LED_PIN = 4; // digital pin&#xA;const int DELAY_TIME = 1000; // time between blinks [ms]&#xA;&#xA;void setup() {&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(LED_PIN, LOW);&#xA;  delay(DELAY_TIME);&#xA;  digitalWrite(LED_PIN, HIGH);&#xA;  delay(DELAY_TIME);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to burn a bootloader with the same settings as uploading to the tiny and then tools -&gt; burn bootloader, get's me the error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;efuse&quot; memory type not defined for part &quot;ATtiny13&quot;&#xA;Error while burning bootloader.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Skimming through the data sheet I noticed that the tiny13 - 20PU (the 20) stand for 20 MHz,... theoretically one should be able to downclock them to the ordinary 10 MHz, but maybe this is my problem?&lt;/p&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="2902" LastEditDate="2015-05-17T11:55:42.357" LastActivityDate="2015-05-23T16:29:36.973" Title="Program ATtiny13 - 20PU" Tags="|attiny|frequency|fuses|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11675" PostTypeId="2" ParentId="10552" CreationDate="2015-05-09T08:46:33.567" Score="1" Body="&lt;p&gt;Thanks everyone for your help! I've ended up with the code below which works quite well, there's the odd glitch with the seconds which is for some reason fixed if milliseconds is added on the end, but other than that it works very well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;#define MILLIS_OVERFLOW 34359738&#xA;&#xA;/**&#xA;* Clock Variables&#xA;*/&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds, minutes, hours;&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  lcd.begin( 16, 2 ); &#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    setClock();&#xA;    /**&#xA;   * After set clock now you have 3 int variables with the current time&#xA;   */&#xA;   //seconds&#xA;   //minutes&#xA;   //hours&#xA;     lcd.setCursor ( 0, 1);&#xA;     lcd.print(hours);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(minutes);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(seconds);&#xA;     lcd.print(&quot;:&quot;);&#xA;     lcd.print(elapsedMillis);&#xA;&#xA;}&#xA;&#xA;void setClock()&#xA;{&#xA;    currentMillis = millis();&#xA;    /**&#xA;     * The only moment when currentMillis will be smaller than            previousMillis&#xA;     * will be when millis() oveflows&#xA;    */&#xA;    if (currentMillis &amp;lt; previousMillis){&#xA;    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;&#xA;} else {&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;}&#xA;&#xA;/**&#xA; * If we use equals 1000 its possible that because of the mentioned loop limitation&#xA; * you check the difference when its value is (999) and on the next loop its value is (1001)&#xA; */&#xA;if (elapsedMillis &amp;gt; 999){&#xA;    seconds++;&#xA;    elapsedMillis = elapsedMillis - 1000;&#xA;}&#xA;&#xA;if (seconds == 60){&#xA;    minutes++;&#xA;    seconds = 0;&#xA;}&#xA;if (minutes == 60){&#xA;    hours++;&#xA;    minutes = 0;&#xA;}&#xA;if (hours == 24){&#xA;    hours = 0;&#xA;}&#xA;&#xA;previousMillis = currentMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8588" LastActivityDate="2015-05-09T08:46:33.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11676" PostTypeId="1" AcceptedAnswerId="11828" CreationDate="2015-05-09T08:50:06.053" Score="0" ViewCount="336" Body="&lt;p&gt;I need to display some dynamic Chinese characters to 12864 using Arduino. What to show is transported from my web server. The character is stored as a 16x16 dot matrix, needing 16*16/8=32 byte. And I need to show some sentences, which contains more than 100 Chinese characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I can't storage all the dot matrix data in Arduino because it has too small memory.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I get the dot matrix data from web server, I need to have 100*32B memory, but SPAM with EEPROM have only 3k. So that failed.&lt;/li&gt;&#xA;&lt;li&gt;If I save the dot matrix &quot;library&quot; in the Flash memory, I need 3500*32B (There are 3500 Chinese frequent-used characters), but there is only 32K Flash. Saving the &quot;library&quot; means that I should storage the dot matrix data of all the 3500 chars in Flash, then the server only need to send the Unicode of characters, and I can get the matrix of the char.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="9953" LastActivityDate="2015-05-14T12:39:06.837" Title="How to increase Arduino's memory to save Dot Matrix Library?" Tags="|arduino-uno|memory-usage|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11677" PostTypeId="1" CreationDate="2015-05-09T08:53:13.690" Score="0" ViewCount="696" Body="&lt;p&gt;A Pro Mini needs to be placed in a 100mmx50mmx25mm, no holes but not air tight ABS plastic enclosure, with a 12v power supply connected to the raw input. It will be consuming max 40mA, ambient temperature 30-32C, and needs to be run 24/7. Upon prototyping in open air, I tried to touch the regulator MIC5205, after 30 seconds upon powering on with my bare fingers and it was too hot to touch. The rest of the components were cool to touch. I would use a buck converter to step down to 5v, however there isn't space for it in the current setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to run a Mega 24/7 on 12v, consuming much more current about 700mA, the onboard regulator malfunctioned after 1 year of use, which I believe was due to the excessive heat, as the PCB around the regulator turned a little brownish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite being hot to touch, I understand that electronics run in heat all the time like computers, routers, etc for 24/7. Therefore, I would like to know if 12vx0.04A=0.48w will be too much heat/feasible to run in the above mentioned setup, without damaging the regulator in the long run?&lt;/p&gt;&#xA;" OwnerUserId="9952" LastEditorUserId="9952" LastEditDate="2015-05-09T09:29:29.343" LastActivityDate="2015-05-11T14:47:01.520" Title="Running Pro Mini Continuous on 12v w/o Damaging Regulator" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11679" PostTypeId="2" ParentId="11676" CreationDate="2015-05-09T10:46:29.370" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a different &lt;a href=&quot;http://www.arduino.cc/en/Main/Products&quot; rel=&quot;nofollow&quot;&gt;Arduino&lt;/a&gt; or &lt;a href=&quot;http://playground.arduino.cc/Main/SimilarBoards#goArdComp&quot; rel=&quot;nofollow&quot;&gt;Arduino-clone&lt;/a&gt; with &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Memory&quot; rel=&quot;nofollow&quot;&gt;more flash memory&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Store the character bitmaps in external EEPROM (&lt;a href=&quot;http://www.hobbytronics.co.uk/arduino-external-eeprom&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="316" LastEditorUserId="316" LastEditDate="2015-05-10T11:37:00.633" LastActivityDate="2015-05-10T11:37:00.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11680" PostTypeId="1" CreationDate="2015-05-09T11:36:54.227" Score="9" ViewCount="1118" Body="&lt;p&gt;When I compile my code, the Arduino IDE returns the binary sketch size in byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a good way to find out (approximately) what function or what part of my code takes up how much memory in flash, so that I get a feeling what feature takes most of precious flash memory or where I may be wasting flash and should start optimizing?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-09T16:51:19.287" Title="Overview of compiled code size" Tags="|debugging|memory-usage|code-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11681" PostTypeId="2" ParentId="11668" CreationDate="2015-05-09T12:07:36.783" Score="2" Body="&lt;p&gt;The values you're reading relate to the voltage measured by the AD converter, that is, the voltage over the load resistor. Arduino's AD converters have 10 bit resolution and measure against a 5V reference, so you can use the following line to convert it to millivolts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;VRL = map(sensorValue, 0, 1023, 0, 5000);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have the voltage, you can compute the resistance of the sensor using the formula&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rs=(Vc/VRL-1)×RL&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with Vc the circuit voltage (5V), VRL the voltage over the load resistor, and RL the resistance of the load resistor in Ohms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tricky part is to convert this to a concentration in ppm CH4. The curve in the datasheet gives you a starting point, but the values it gives are not absolute, but relative to the reference of 1000 ppm. The value of that reference depends on various factors, like temperature, humidity, other gases in the environment and how long the sensor has been running (the longer, the more reliable are the results). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need exact ppm values, you'll need to calibrate your setup in an environment where you can exactly control the CH4 concentration. You'll also have to measure temperature and humidity along with the sensor readings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you'll get only a qualitative estimate of CH4 concentration, which is actually sufficient for many use cases. &lt;/p&gt;&#xA;" OwnerUserId="9956" LastActivityDate="2015-05-09T12:07:36.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11682" PostTypeId="1" AcceptedAnswerId="11685" CreationDate="2015-05-09T13:36:32.303" Score="1" ViewCount="472" Body="&lt;p&gt;I currently connected 5 sensor via a multiplexer (I must connect them to a multiplexer because they are I2C devices but they cannot been allocate more then 2 addresses so I use a multiplexer to solve the addressing problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the sample rate is a shame , it is about 6.5Hz . I wish I could improve the sample rate by using some tricks.&#xA;In my loop() function, multiplexer will loop through channel 0-4 , and read each of these channel's sensor value and print it by using Serial.print()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any tricks I could use to improve my sampling rate faster ? Thanks...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my multiplexer class :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MUX {&#xA;public:&#xA;//mux control pins:&#xA;int s0 = 22;&#xA;int s1 = 24;&#xA;int s2 = 26;&#xA;int s3 = 28;&#xA;&#xA;//SIG pin (not necessary WHEN sig is connect to 5V)&#xA;//int SIG_pin = 0;&#xA;&#xA;//array to store channel :: muxChannel[channel numbers ][4 digit channel representation]&#xA;int muxChannel[16][4] = {&#xA;  {0, 0, 0, 0}, //channel 0&#xA;  {1, 0, 0, 0}, //channel 1&#xA;  {0, 1, 0, 0}, //channel 2&#xA;  {1, 1, 0, 0}, //channel 3&#xA;  {0, 0, 1, 0}, //channel 4&#xA;  {1, 0, 1, 0}, //channel 5&#xA;  {0, 1, 1, 0}, //channel 6&#xA;  {1, 1, 1, 0}, //channel 7&#xA;  {0, 0, 0, 1}, //channel 8&#xA;  {1, 0, 0, 1}, //channel 9&#xA;  {0, 1, 0, 1}, //channel 10&#xA;  {1, 1, 0, 1}, //channel 11&#xA;  {0, 0, 1, 1}, //channel 12&#xA;  {1, 0, 1, 1}, //channel 13&#xA;  {0, 1, 1, 1}, //channel 14&#xA;  {1, 1, 1, 1} //channel 15&#xA;};&#xA;&#xA;void setupMux() {&#xA;  pinMode(s0, OUTPUT);&#xA;  pinMode(s1, OUTPUT);&#xA;  pinMode(s2, OUTPUT);&#xA;  pinMode(s3, OUTPUT);&#xA;&#xA;  digitalWrite(s0, LOW);&#xA;  digitalWrite(s1, LOW);&#xA;  digitalWrite(s2, LOW);&#xA;  digitalWrite(s3, LOW);&#xA;  Serial.println(F(&quot;Multiplexer initialized&quot;));&#xA;}&#xA;&#xA;void selectChannel(int channel) {&#xA;  int controlPin[] = {s0, s1, s2, s3};&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    digitalWrite(controlPin[i], muxChannel[channel][i]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8643" LastActivityDate="2015-05-09T19:31:23.113" Title="Improve sampling speed while using a multiplexer" Tags="|arduino-uno|arduino-mega|sensors|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11683" PostTypeId="2" ParentId="11677" CreationDate="2015-05-09T15:34:33.337" Score="1" Body="&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Simple, effective, low cost solution - choose any 3:&lt;/strong&gt;&lt;br&gt;&#xA;A series resistor in the regulator input, of properly designed resistance and wattage will greatly reduce regulator temperature and increase overall reliability. Reason and design details given below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Detail:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming a 5V processor dissiaption in the regulator is&lt;br&gt;&#xA;(Vsupply - Vregulator_out) x Current&lt;br&gt;&#xA;= (12-5)x 0.040 = 280 mW - usefully less than the 480 mW if you are dissipating all the power in the regulator.&lt;br&gt;&#xA;For a 3V3 processor dissipation is (12-3.3)* 0.040 ~= 350 mW&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Too hot to touch&quot; is a minimum of 55C and probably hotter - say 70C for now.&lt;br&gt;&#xA;At 30C ambient delta T = (70-30) = 40 C.&lt;br&gt;&#xA;Thermal resistanc = dT/Watts =40/0.280 = 140 C/W or 114 C/W at 3V3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of those thermal resistances are very high. You do not describe what heatsinking is on the regulator but that suggests PCB copper only and not much of it. Even adding a very rudimentary heat sink should help immensely. If there is no obvious way to add a formal heat sink then adding a 'flag' of copper or brass by soldering should be doable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Mark William's 220C/Watt figure (see datasheet for conditions).&lt;br&gt;&#xA;Say 300 mW (see above).&lt;br&gt;&#xA;Delta t = 220 C/W  x 0.3 W = 66 C rise.&lt;br&gt;&#xA;Ambient is 30-32 so allow 35 for very minor safety factor.&lt;br&gt;&#xA;66 C rise + 35 C ~= 101C - water boils.&lt;br&gt;&#xA;And temperature inbox will rise mildly from energy dissipated so hotter again.&lt;br&gt;&#xA;BUIT a series resistor inside the box or external  will make an immense difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;An easy and effective solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regulator needs some &quot;headroom&quot; - some voltage above the Vout value to allow some dropacross the internal switch. Check the data sheet, but a modern LDO probably allows as little as 1V headroom. So, for 5V out you need 6V in. The extra 6v from 12V to 6V is not &quot;needed&quot; by the regulator. So, it can be dissipated in a low cost high reliability resistor.&lt;br&gt;&#xA;Determine &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Vsupply_minimum - the absolute lowest value supply will assume.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vreg_in_minimum  I'll use 6V to start.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I_load_maximum - you said 40 ma. This must be abs_max or if of very short duration must be able to be supported by capacitors. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rmax = V/I = (V_supply_min-Vregin_nax) / Imax&lt;br&gt;&#xA;= (12 - 6 )/.040 = 150 Ohm.&lt;br&gt;&#xA;This is the absolute maximum resistor that meets the specification. A slightly smaller value will be safer. Say 120 R in this case.&lt;br&gt;&#xA;Then&lt;br&gt;&#xA;Pmax in R = I^2R = .04^2 x 120 = 192 mW.&lt;br&gt;&#xA;A 500 mW resistor would be &quot;safe enough&quot; and a 1 watt one very safe.&lt;br&gt;&#xA;Pregulator max = (6-5) x 0.040 = 40 mW, 14% of the 280 mW initially. &#xA;A  W resistor with adequate cooling will be very safe. Safest is probably a purpose built air cooled wire wound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the dissipated energy will raise internal ambient. A resistor is still an effective solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place a suitable decoupling capacitor at the regulator input. Even if not normally used here it is needed due to the series input resistor raising the supply resistance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;._______________________________________&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Temperature rise inside box due to heat dissipation.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; Using pessimistic assumptions for box thickness, available area and power dissipation an internal temperature rise of under 15 degrees C can be expected. As the regulator is now dissipating under 15% of the original dissipation due to the series resistor it will have a far longer operating lifetime. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Temperature rise (assuming no air transfer occurs) is limited by heat transfer through the plastic. This is controlled by the thermal conductivity of th e plastic, its thickness and its area.  Obviously:&lt;br&gt;&#xA; - Thicker plastic leads to higher temperature rise.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;More surface area leads to lower temperature rise. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Higher thermal conductivity of the plastic leads to lower temperature rise &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So given Thermal conductivity = Ktc&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Delta T = Watts x thickness / (Ktc x area)&lt;/strong&gt;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So Ktc = Watts x thickness /(Delta_Tx area)&lt;br&gt;&#xA;So units of Ktc must be Watts/metre/degree_C&lt;br&gt;&#xA;Which is indeed how Ktc is usually expressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This table of &lt;a href=&quot;http://www.professionalplastics.com/professionalplastics/ThermalPropertiesofPlasticMaterials.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;Thermal properties of plastic materials&lt;/strong&gt;&lt;/a&gt; lists Ktc for ABS as 0.17 W/m/K&lt;br&gt;&#xA;This means that 170 mW will cause a 1 degree K (or C) rise when plastic ratio of thickness to area is 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume thickness of box = 5mm = much higher than is likely.&lt;br&gt;&#xA;Box area for a box L x W x D = 2 x (LW + WD + DL)&lt;br&gt;&#xA;Here  = L D W = 100mm x  50mm  25 mm or 0.1 x 0.05 x 0.025m&#xA;Area = 0.0175 m^2.&lt;br&gt;&#xA;Use a smaller more pessimistic area of 0.01 m^2&lt;br&gt;&#xA;Use a pessimistic heat dissipation of 0.5 Watts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the formula - &lt;strong&gt;Delta T = Watts x thickness / (Ktc x area)&lt;/strong&gt;  from above &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Temperature rise = 0.5 x 0.05 / (0.17 x 0.01) ~= 15 degrees C (or K)&lt;/strong&gt;&lt;br&gt;&#xA;This is based on a thicker than likely box, smaller than actual area, and higher than expected energy dissipation. A 15C rise is bearable and actual is lower, and as the regulator now dissipates under 20% of original it will survive very well. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-05-11T14:47:01.520" LastActivityDate="2015-05-11T14:47:01.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11684" PostTypeId="2" ParentId="11680" CreationDate="2015-05-09T16:51:19.287" Score="6" Body="&lt;p&gt;One approach is to look at the assembly listing of the program.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;After compiling the program (via the Verify or Download button) locate the directory where the .cpp, .hex, and .elf files for the program have been stored.  (If you have trouble finding them, briefly turn on verbose compile options in the arduino IDE and look at the directory names in the output.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In that directory, run &lt;code&gt;avr-objdump -S&lt;/code&gt; &lt;em&gt;fn.cpp.elf&lt;/em&gt; &lt;code&gt;&amp;gt; listing.txt&lt;/code&gt; where &lt;em&gt;fn.cpp.elf&lt;/em&gt; is the name of your sketch with &lt;code&gt;.ino&lt;/code&gt; taken off and &lt;code&gt;.cpp.elf&lt;/code&gt; added on at the end.  For example, with sketch &lt;code&gt;serialecho.ino&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr-objdump -S serialecho.cpp.elf &gt; listing.txt&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;View the &lt;code&gt;listing.txt&lt;/code&gt; file, and subtract each function's starting address from its ending address, using hex arithmetic.  For example, with &lt;code&gt;setup&lt;/code&gt; code &lt;/p&gt;&#xA;&#xA;&lt;p&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;}&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;in the listing we will see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000144 &amp;lt;setup&amp;gt;:&#xA;...(6 lines snipped)...&#xA; 144:   26 e0           ldi     r18, 0x06       ; 6&#xA; 146:   40 e8           ldi     r20, 0x80       ; 128&#xA; 148:   55 e2           ldi     r21, 0x25       ; 37&#xA; 14a:   60 e0           ldi     r22, 0x00       ; 0&#xA; 14c:   70 e0           ldi     r23, 0x00       ; 0&#xA; 14e:   80 e1           ldi     r24, 0x10       ; 16&#xA; 150:   92 e0           ldi     r25, 0x02       ; 2&#xA; 152:   db c1           rjmp    .+950           ; 0x50a &amp;lt;_ZN14HardwareSerial5beginEmh&amp;gt;&#xA;&#xA;00000154 &amp;lt;loop&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The calculation 0x154–0x144 = 0x10 shows this portion of &lt;code&gt;setup&lt;/code&gt; is 16 bytes long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These examples were generated on a linux system.  I think the approach is the same on a MSWindows system except you may need to say &lt;code&gt;avr-objdump.exe&lt;/code&gt; instead of &lt;code&gt;avr-objdump&lt;/code&gt;, and may need to specify its path.  See, eg, the &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,3537.0.html&quot; rel=&quot;noreferrer&quot;&gt;Assemler results, where?&lt;/a&gt; thread at forum.arduino.cc.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-09T16:51:19.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11685" PostTypeId="2" ParentId="11682" CreationDate="2015-05-09T17:54:56.127" Score="2" Body="&lt;p&gt;It's hard to offer much more than speculation without knowing more about the sensors and your current code, but here is one possibility:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the bulk of your loop time is the sum of the conversion times, is it possible to cycle through the sensors twice, once to start each conversion (so they will convert nearly simultaneously), wait one conversion-time (or for the first sensor to complete), then cycle through them again to read back each converted value?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for each sensor,&#xA;  setup mux;&#xA;  send start conversion command;&#xA;end&#xA;&#xA;for each sensor,&#xA;  setup mux;&#xA;  while conversion not done,&#xA;    ;  // wait&#xA;  read and store value;&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For 16 sensors and assuming the conversion time the majority of the time spent, that could speed your sample rate to ~100Hz. Expect maybe half of that, since mux-setup and communication times are probably not negligible.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-09T17:54:56.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11687" PostTypeId="1" CreationDate="2015-05-09T18:49:43.137" Score="1" ViewCount="7009" Body="&lt;p&gt;I need to pass a 16-bit long address (for an external EEPROM) to a function (&lt;code&gt;twi_writeTo&lt;/code&gt;) in a buffer.&#xA;I am currently doing this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte buffer[2];&#xA;buffer[0] = (byte)(eeaddress &amp;gt;&amp;gt; 8);&#xA;buffer[1] = (byte)(eeaddress &amp;amp; 0xFF);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;eeaddress&lt;/code&gt; is an &lt;code&gt;unsigned int&lt;/code&gt; with the address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t ret = twi_writeTo(eeprom_i2c_addr, buffer, 2, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before I tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t ret = twi_writeTo(eeprom_i2c_addr, (uint8_t*)&amp;amp;eeaddress, 2, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that returns garbage. Probably the byte order is swapped. Is that the case?&#xA;And if so, is there a better way than copying the two bytes to a buffer?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-06-12T02:01:04.167" Title="Big endian or little endian?" Tags="|byte-order|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11688" PostTypeId="2" ParentId="11682" CreationDate="2015-05-09T19:31:23.113" Score="1" Body="&lt;p&gt;The technique suggested by @JRobert (starting all the conversions in one loop, then running another loop to wait for completions and read results) looks reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a couple of ways to shorten the code shown in the question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, instead of four &lt;code&gt;int&lt;/code&gt; declarations to set the value of &lt;code&gt;s0 ... s3&lt;/code&gt;, use an &lt;code&gt;enum&lt;/code&gt;.  An &lt;code&gt;enum&lt;/code&gt; is used to declare integer constants.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { s0 = 22, s1 = 24, s2 = 26, s3 = 28};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, don't bother with the lengthy, tedious, and unnecessary &lt;code&gt;muxChannel&lt;/code&gt; array.  Delete the declaration of &lt;code&gt;muxChannel&lt;/code&gt; and replace &lt;code&gt;selectChannel&lt;/code&gt; with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void selectChannel(int channel) {&#xA;  int controlPin[] = {s0, s1, s2, s3};&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    digitalWrite(controlPin[i], channel &amp;amp; 1);&#xA;    channel /= 2;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The expression &lt;code&gt;channel &amp;amp; 1&lt;/code&gt; picks off the least-significant-bit of &lt;code&gt;channel&lt;/code&gt;.  The statement &lt;code&gt;channel /= 2;&lt;/code&gt; divides &lt;code&gt;channel&lt;/code&gt; by 2, which moves the next bit of &lt;code&gt;channel&lt;/code&gt; into place for output.  You could instead say &lt;code&gt;channel &amp;gt;&amp;gt;= 1;&lt;/code&gt; or &lt;code&gt;channel = channel/2;&lt;/code&gt;, etc. if you prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also look closely at your sensor boards to see if there is any way to add jumpers to get another bit or two of I2C device addressing, allowing you to avoid multiplexing.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-09T19:31:23.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11689" PostTypeId="1" CreationDate="2015-05-09T20:50:08.447" Score="7" ViewCount="17115" Body="&lt;p&gt;I am looking for (reasonably easy to use and well tested) alternatives to the &lt;code&gt;Wire&lt;/code&gt; library. &lt;code&gt;Wire&lt;/code&gt; works very well, but: I only need the Arduino to act as I2C master and the &lt;code&gt;Wire&lt;/code&gt; library seems to be a real waste of resources: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to send out data en bloc (e.g. 32 or 64 bytes). This data is already sitting in an array in SRAM. Now when you use the &lt;code&gt;Wire&lt;/code&gt; library, you call the &lt;code&gt;TwoWire::write&lt;/code&gt; function which copies your data into a 2nd buffer. Afterwards, &lt;code&gt;Wire&lt;/code&gt; makes use of the &lt;code&gt;TWI&lt;/code&gt; library where &lt;code&gt;twi_writeTo&lt;/code&gt; copies the data again into a 3rd buffer. That's a bit clunky, isn't it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen the &lt;a href=&quot;https://github.com/DSSCircuits/I2C-Master-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;DSSCircuits / I2C-Master-Library&lt;/a&gt; but I am not sure how mature it is because there hasn't been any commit after the initial commit which is 3 years old now.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="7148" LastEditDate="2020-04-19T13:55:07.640" LastActivityDate="2020-04-19T13:55:07.640" Title="Alternatives to Wire library for I2C" Tags="|i2c|library|wire-library|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="11690" PostTypeId="1" CreationDate="2015-05-10T08:45:14.613" Score="5" ViewCount="2628" Body="&lt;p&gt;I am looking for a way to listen for received text messages on multiple numbers. When I came across the Arduino and its shields, I thought to myself this might be the perfect way to do just that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the modules / shields I found on the internet by watching a youtube video is the TC 35 GSM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been reading multiple questions here regarding the &quot;stacking&quot; of shields, and the usual reply is &quot;check what pins / if they are using the same pins&quot;. Though these questions were not GSM module specific, and did not include stacking the &lt;strong&gt;same&lt;/strong&gt; shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am very curious if this is possible. Let's say I want to listen to 10 SIM cards at once for received messages, will this be possible by stacking the modules on one Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="9963" LastEditorUserId="4628" LastEditDate="2017-04-01T06:27:35.250" LastActivityDate="2018-01-16T16:12:03.507" Title="Multiple GSM shields on one Arduino" Tags="|arduino-uno|shields|gsm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11691" PostTypeId="1" AcceptedAnswerId="11693" CreationDate="2015-05-10T11:18:44.960" Score="5" ViewCount="877" Body="&lt;p&gt;I'm trying to write a faster &lt;code&gt;shiftOut&lt;/code&gt; function, which does not use the slow &lt;code&gt;digitalWrite&lt;/code&gt;. In my code I have the original &lt;code&gt;shiftOut&lt;/code&gt;, the new shiftOutFast, and the same as shiftOutFast, but inline. The three blocks are separated by delays to tell them apart on my scope. Here's the code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CLR(x,y) (x &amp;amp;= (~(1 &amp;lt;&amp;lt; y)) )&#xA;#define SET(x,y) (x |= (1 &amp;lt;&amp;lt; y) )&#xA;&#xA;void shiftOutFast(uint8_t dataPort, uint8_t dataBit, uint8_t clkPort, &#xA;                  uint8_t clkBit, uint8_t bitOrder, uint8_t val) {&#xA;  for (uint8_t i = 0; i &amp;lt; 8; i++)  {&#xA;    if (bitOrder == LSBFIRST) {&#xA;      if (val &amp;amp; 0x01) {&#xA;        SET(dataPort, dataBit);&#xA;      } else {&#xA;        CLR(dataPort, dataBit);&#xA;      }&#xA;      val &amp;gt;&amp;gt;= 1;&#xA;    } else {    &#xA;      if (val &amp;amp; 0x80) {&#xA;        SET(dataPort, dataBit);&#xA;      } else {&#xA;        CLR(dataPort, dataBit);&#xA;      }&#xA;      val &amp;lt;&amp;lt;= 1;&#xA;    }   &#xA;&#xA;    CLR(clkPort, clkBit);&#xA;    SET(clkPort, clkBit);&#xA;  }&#xA;}&#xA;&#xA;&#xA;#define dataPin 4&#xA;#define clockPin 5&#xA;#define dataPort PORTD&#xA;#define dataBit PORTD4&#xA;#define clockPort PORTD&#xA;#define clockBit PORTD5&#xA;&#xA;void setup() {&#xA;  pinMode(dataPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  shiftOut(dataPin, clockPin, LSBFIRST, 0x55);&#xA;  delay(1);&#xA;&#xA;  shiftOutFast(dataPort, dataBit, clockPort, clockBit, LSBFIRST, 0x5C);&#xA;  delay(1);  &#xA;&#xA;  bool bitOrder = LSBFIRST;&#xA;  uint8_t val = 0x5C; &#xA;&#xA;  for (uint8_t i = 0; i &amp;lt; 8; i++)  {&#xA;    if (bitOrder == LSBFIRST) {&#xA;      if (val &amp;amp; 0x01) {&#xA;        SET(dataPort, dataBit);&#xA;      } else {&#xA;        CLR(dataPort, dataBit);&#xA;      }&#xA;      val &amp;gt;&amp;gt;= 1;&#xA;    } else {    &#xA;      if (val &amp;amp; 0x80) {&#xA;        SET(dataPort, dataBit);&#xA;      } else {&#xA;        CLR(dataPort, dataBit);&#xA;      }&#xA;      val &amp;lt;&amp;lt;= 1;&#xA;    }   &#xA;&#xA;    CLR(clockPort, clockBit);&#xA;    SET(clockPort, clockBit);&#xA;  }&#xA;  delay(1);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that calling &lt;code&gt;shiftOutFast&lt;/code&gt; doesn't do zilch. Absolutely nothing. It doesn't seem to be the logic, because when I do the same inline it works. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="9975" LastEditDate="2015-05-11T23:21:02.310" LastActivityDate="2015-05-11T23:21:02.310" Title="Why doesn't my code work in a function, yet works inline?" Tags="|programming|c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11692" PostTypeId="2" ParentId="11691" CreationDate="2015-05-10T12:02:41.167" Score="5" Body="&lt;p&gt;You should declare &lt;code&gt;volatile&lt;/code&gt; the port parameters of your function. Otherwise, to the compiler, their write accesses seem useless, and they get optimized out.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-10T12:02:41.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11693" PostTypeId="2" ParentId="11691" CreationDate="2015-05-10T12:50:09.237" Score="11" Body="&lt;p&gt;The problem is that you are passing the value of the ports to the function, not the address of the ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to either pass &quot;by reference&quot; or as a pointer, so that modifying the port variable modifies the &lt;em&gt;actual&lt;/em&gt; port variable not the copy of the value that you pass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way is to modify your function to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shiftOutFast(volatile uint8_t &amp;amp;dataPort, uint8_t dataBit,&#xA;                  volatile uint8_t &amp;amp;clkPort, uint8_t clkBit, &#xA;                  uint8_t bitOrder, uint8_t val) {&#xA;....&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, instead of passing whatever is in the port at the time to the function (pass by value) it instead creates a new variable which is located at the same address as the variable that you are passing (pass by reference) so modifications of one variable modifies the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that only the &quot;port&quot; variables need to be passed by reference, all the others remain as pass by value.  Also they should be, as Edgar says, flagged as &lt;em&gt;volatile&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-10T12:50:09.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11694" PostTypeId="1" AcceptedAnswerId="11695" CreationDate="2015-05-10T13:31:43.463" Score="5" ViewCount="9316" Body="&lt;p&gt;Is it possible to send OTA updates to Arduino via nRF24L01+ module?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my findings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Wireless-upload-program-to-Arduino-without-USB-cab/&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is an instructable explaining how to program Arduino wirelessly but this thing uses a BT module which shows up on PC as a COM port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Wireless-Programming-with-XBee-Series-1-or/?ALLSTEPS&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is something similar using Xbees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, these use another arduino attached to a PC on the other end. In my case, I am planning to use rPi hooked to another nRF24L01+ rather than PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an excerpt from the datasheet of Atmega chip:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In ATmega88A/88PA/168A/168PA/328/328P the Boot LoaderSupport provides&#xA;  a real Read-While-Write SelfProgramming mechanism for downloading and&#xA;  uploading program code by the MCU itself. This feature allows flexible&#xA;  application software updates controlled by the MCU using a&#xA;  Flash-resident Boot Loader program. The Boot Loader program can use&#xA;  any available data interface and associated protocol to read code and&#xA;  write (program) that code into the Flash memory, or readthe code from&#xA;  the program memory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here is what I planned as a strategy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master programmer = Raspberry Pi + nRF module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slave arduino = Arduino + nRF24L01 + external EEPROM&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I have to upload a new code, I can transmit the compiled code to the arduino (I can do that, right?) and Arduino will save it in the external EEPROM for the time being.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the transfer is complete, I will send a signal which will make the arduino reset and copy the code from EEPROM to its flash memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the strategy correct and feasible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I proceed to achieve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other suggestions which you might have are welcome.&lt;/p&gt;&#xA;" OwnerUserId="7553" LastActivityDate="2018-01-17T09:03:35.853" Title="OTA updates for Arduino using nRF24L01+" Tags="|arduino-uno|nrf24l01+|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11695" PostTypeId="2" ParentId="11694" CreationDate="2015-05-10T13:35:08.507" Score="5" Body="&lt;p&gt;Your best strategy would be to write your own bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The existing bootloader receives data through the serial port and writes it, a page at a time, to the flash.  Your custom bootloader, instead, would receive the data through the nRF module and write it to flash, a page at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the source code for the existing bootloader (maybe use optiboot?) as a starting point and remove the UART code, replacing it with nRF code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you still need a way to enter the bootloader when you want to program it - the easiest way is to ensure that is added into any sketch you upload so you can send an instruction to that sketch to enter the bootloader.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would also need to create a program on the Pi to do the programming over the air - or modify an existing one like avrdude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may, in the long run, be simpler to have a pair of other Arduinos (maybe something small like an ATTiny based board) to act as bridges between UART and the nRF modules so they become a transparent wireless serial link.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-10T13:40:55.277" LastActivityDate="2015-05-10T13:40:55.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11696" PostTypeId="1" CreationDate="2015-05-10T14:46:08.953" Score="0" ViewCount="6752" Body="&lt;p&gt;I have an Arduino with Ethernet Shield. I'm trying to get data from Arduino, using AJAX call.&#xA;At the moment I have the following code on Arduino:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;IPAddress ip(192, 168, 1, 177);&#xA;&#xA;EthernetServer server(80);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; &#xA;  }&#xA;&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  float temperatureIndoor;&#xA;  float temperatureOutdoor;&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    Serial.println(&quot;new client&quot;);&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        Serial.write(c);&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: application/json;charset=utf-8&quot;);&#xA;          client.println(&quot;Server: Arduino&quot;);&#xA;          client.println(&quot;Connnection: close&quot;);&#xA;          client.println();&#xA;&#xA;          temperatureIndoor = 22.77;&#xA;          temperatureOutdoor = 15.55;&#xA;          client.print(&quot;{\&quot;0\&quot;:{\&quot;TemperaturaInterior\&quot;:\&quot;&quot;);&#xA;          client.print(temperatureIndoor);&#xA;          client.print(&quot;\&quot;,\&quot;TemperaturaExterior\&quot;:\&quot;&quot;);&#xA;          client.print(temperatureOutdoor);&#xA;&#xA;          client.print(&quot;\&quot;}}&quot;);&#xA;          client.println();&#xA;          break;&#xA;        }&#xA;&#xA;      }&#xA;    }&#xA;    delay(1);&#xA;    client.stop();&#xA;    Serial.println(&quot;client disconnected&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get values with the following ajax call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    $.ajax({&#xA;        url: 'http://192.168.1.177/',&#xA;        type: 'post',&#xA;            data: { tag: 'getData'},&#xA;            dataType: 'json',&#xA;                  async: false,&#xA;                  success: function (data) {&#xA;&#xA;$('#TemperaturaInterior').val(data.TemperaturaInterior).show();&#xA;$('#TemperaturaExterior').val(data.TemperaturaExterior).show();&#xA;&#xA;                            }&#xA;                        });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I access directly from the browser to Arduino (192.168.1.177) I get the correct JSON reply from arduino:&#xA;{&quot;0&quot;:{&quot;TemperaturaInterior&quot;:&quot;22.77&quot;,&quot;TemperaturaExterior&quot;:&quot;15.55&quot;}}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not getting the values.&#xA;Any idea?&#xA;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This what I get when ask to arduino to give me the values:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tc7fw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9969" LastEditorUserId="9969" LastEditDate="2015-05-10T17:07:48.880" LastActivityDate="2016-01-07T19:38:04.603" Title="Get JSON data from Arduino with AJAX" Tags="|arduino-uno|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11697" PostTypeId="2" ParentId="10563" CreationDate="2015-05-10T16:10:46.503" Score="0" Body="&lt;p&gt;&lt;strong&gt;THIS QUESTION ISN'T IN USE ANYMORE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Solved by using an other remote that is supported by the libary&#xA;  and tweaking the code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;====NEW CODE====&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;    int RECV_PIN = 11;&#xA;    int relay1 = 2;&#xA;    int relay2 = 3;&#xA;    int relay3 = 4;&#xA;&#xA;    int on = 1;&#xA;    int on1 = 1;&#xA;    int on2 = 1;&#xA;&#xA;    IRrecv irrecv(RECV_PIN);&#xA;    decode_results results;&#xA;&#xA;    void setup()&#xA;    {&#xA;      digitalWrite(relay3, HIGH);&#xA;      pinMode(relay3, OUTPUT);&#xA;      digitalWrite(relay2, HIGH);&#xA;      pinMode(relay2, OUTPUT);&#xA;      digitalWrite(relay1, HIGH);&#xA;      pinMode(relay1, OUTPUT);&#xA;      pinMode(13, OUTPUT);&#xA;      irrecv.blink13(true);&#xA;      irrecv.enableIRIn();&#xA;    }&#xA;&#xA;    unsigned long last = millis();&#xA;&#xA;    void loop() {&#xA;      if (irrecv.decode(&amp;amp;results)){&#xA;        if (results.value == 0x36167A85) {&#xA;          if (millis() - last &amp;gt; 250) {&#xA;            on = !on;&#xA;            digitalWrite(relay1, on ? HIGH : LOW);&#xA;          }&#xA;          last = millis();&#xA;        } else if (results.value == 0x36161AE5) {&#xA;          if (millis() - last &amp;gt; 250) {&#xA;            on1 = !on1;&#xA;            digitalWrite(relay2, on1 ? HIGH : LOW);&#xA;          }&#xA;             last = millis();&#xA;        } else if (results.value == 0x3616FA05) {&#xA;         if (millis() - last &amp;gt; 250) {&#xA;            on2 = !on2;&#xA;            digitalWrite(relay3, on2 ? HIGH : LOW);&#xA;          }&#xA;            last = millis();&#xA;        }&#xA;        irrecv.resume();&#xA;      }  &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;================&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="9863" LastActivityDate="2015-05-10T16:10:46.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11698" PostTypeId="1" CreationDate="2015-05-10T16:32:18.710" Score="1" ViewCount="24960" Body="&lt;p&gt;I have got this library+code example from a friend, to read RFID numbers using the RFID-RC522 chip:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RFID.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RFID.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;/**&#xA;* RFID pins&#xA;* MOSI: Pin 11 / ICSP-4&#xA;* MISO: Pin 12 / ICSP-1&#xA;* SCK: Pin 13 / ISCP-3&#xA;* SS: Pin 10&#xA;* RST: Pin 9&#xA;*/&#xA;&#xA;RFID rfid(10, 9);&#xA;unsigned char prevNum[] = {0,0,0,0,0};&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  SPI.begin();&#xA;  rfid.init();&#xA;}&#xA;&#xA;void loop() {&#xA;    if (rfid.isCard()){&#xA;        if (rfid.readCardSerial() &amp;amp;&amp;amp; (&#xA;            rfid.serNum[0] != prevNum[0]&#xA;         or rfid.serNum[1] != prevNum[1]&#xA;         or rfid.serNum[2] != prevNum[2]&#xA;         or rfid.serNum[3] != prevNum[3]&#xA;         or rfid.serNum[4] != prevNum[4]&#xA;        )){&#xA;          Serial.println(rfid.serNum[0]);&#xA;          Serial.println(rfid.serNum[1]);&#xA;          Serial.println(rfid.serNum[2]);&#xA;          Serial.println(rfid.serNum[3]);&#xA;          Serial.println(rfid.serNum[4]);&#xA;&#xA;          prevNum[0] = rfid.serNum[0];&#xA;          prevNum[1] = rfid.serNum[1];&#xA;          prevNum[2] = rfid.serNum[2];&#xA;          prevNum[3] = rfid.serNum[3];&#xA;          prevNum[4] = rfid.serNum[4];&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RFID.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* RFID.h - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.&#xA; * Based on code Dr.Leong   ( WWW.B2CQSHOP.COM )&#xA; * Created by Miguel Balboa (circuitito.com), Jan, 2012.&#xA; */&#xA;#ifndef RFID_h&#xA;#define RFID_h&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;&#xA;/******************************************************************************&#xA; * Definitions&#xA; ******************************************************************************/&#xA;#define MAX_LEN 16   // Largo m�ximo de la matriz&#xA;&#xA;//MF522 comando palabra&#xA;#define PCD_IDLE              0x00               // NO action; Y cancelar el comando&#xA;#define PCD_AUTHENT           0x0E               // autenticaci�n de clave&#xA;#define PCD_RECEIVE           0x08               // recepci�n de datos&#xA;#define PCD_TRANSMIT          0x04               // Enviar datos&#xA;#define PCD_TRANSCEIVE        0x0C               // Enviar y recibir datos&#xA;#define PCD_RESETPHASE        0x0F               // reajustar&#xA;#define PCD_CALCCRC           0x03               // CRC calcular&#xA;&#xA;//Mifare_One  Tarjeta Mifare_One comando palabra&#xA;#define PICC_REQIDL           0x26               // �rea de la antena no est� tratando de entrar en el estado de reposo&#xA;#define PICC_REQALL           0x52               // Todas las cartas para encontrar el �rea de la antena&#xA;#define PICC_ANTICOLL         0x93               // anti-colisi�n&#xA;#define PICC_SElECTTAG        0x93               // elecci�n de tarjeta&#xA;#define PICC_AUTHENT1A        0x60               // verificaci�n key A&#xA;#define PICC_AUTHENT1B        0x61               // verificaci�n Key B&#xA;#define PICC_READ             0x30               // leer bloque&#xA;#define PICC_WRITE            0xA0               // Escribir en el bloque&#xA;#define PICC_DECREMENT        0xC0               // cargo&#xA;#define PICC_INCREMENT        0xC1               // recargar&#xA;#define PICC_RESTORE          0xC2               // Transferencia de datos de bloque de buffer&#xA;#define PICC_TRANSFER         0xB0               // Guardar los datos en el b�fer&#xA;#define PICC_HALT             0x50               // inactividad&#xA;&#xA;//MF522 C�digo de error de comunicaci�n cuando regres�&#xA;#define MI_OK                 0&#xA;#define MI_NOTAGERR           1&#xA;#define MI_ERR                2&#xA;&#xA;//------------------ MFRC522 registro---------------&#xA;//Page 0:Command and Status&#xA;#define     Reserved00            0x00&#xA;#define     CommandReg            0x01&#xA;#define     CommIEnReg            0x02&#xA;#define     DivlEnReg             0x03&#xA;#define     CommIrqReg            0x04&#xA;#define     DivIrqReg             0x05&#xA;#define     ErrorReg              0x06&#xA;#define     Status1Reg            0x07&#xA;#define     Status2Reg            0x08&#xA;#define     FIFODataReg           0x09&#xA;#define     FIFOLevelReg          0x0A&#xA;#define     WaterLevelReg         0x0B&#xA;#define     ControlReg            0x0C&#xA;#define     BitFramingReg         0x0D&#xA;#define     CollReg               0x0E&#xA;#define     Reserved01            0x0F&#xA;//Page 1:Command&#xA;#define     Reserved10            0x10&#xA;#define     ModeReg               0x11&#xA;#define     TxModeReg             0x12&#xA;#define     RxModeReg             0x13&#xA;#define     TxControlReg          0x14&#xA;#define     TxAutoReg             0x15&#xA;#define     TxSelReg              0x16&#xA;#define     RxSelReg              0x17&#xA;#define     RxThresholdReg        0x18&#xA;#define     DemodReg              0x19&#xA;#define     Reserved11            0x1A&#xA;#define     Reserved12            0x1B&#xA;#define     MifareReg             0x1C&#xA;#define     Reserved13            0x1D&#xA;#define     Reserved14            0x1E&#xA;#define     SerialSpeedReg        0x1F&#xA;//Page 2:CFG&#xA;#define     Reserved20            0x20&#xA;#define     CRCResultRegM         0x21&#xA;#define     CRCResultRegL         0x22&#xA;#define     Reserved21            0x23&#xA;#define     ModWidthReg           0x24&#xA;#define     Reserved22            0x25&#xA;#define     RFCfgReg              0x26&#xA;#define     GsNReg                0x27&#xA;#define     CWGsPReg              0x28&#xA;#define     ModGsPReg             0x29&#xA;#define     TModeReg              0x2A&#xA;#define     TPrescalerReg         0x2B&#xA;#define     TReloadRegH           0x2C&#xA;#define     TReloadRegL           0x2D&#xA;#define     TCounterValueRegH     0x2E&#xA;#define     TCounterValueRegL     0x2F&#xA;//Page 3:TestRegister&#xA;#define     Reserved30            0x30&#xA;#define     TestSel1Reg           0x31&#xA;#define     TestSel2Reg           0x32&#xA;#define     TestPinEnReg          0x33&#xA;#define     TestPinValueReg       0x34&#xA;#define     TestBusReg            0x35&#xA;#define     AutoTestReg           0x36&#xA;#define     VersionReg            0x37&#xA;#define     AnalogTestReg         0x38&#xA;#define     TestDAC1Reg           0x39&#xA;#define     TestDAC2Reg           0x3A&#xA;#define     TestADCReg            0x3B&#xA;#define     Reserved31            0x3C&#xA;#define     Reserved32            0x3D&#xA;#define     Reserved33            0x3E&#xA;#define     Reserved34                0x3F&#xA;//-----------------------------------------------&#xA;&#xA;class RFID&#xA;{&#xA;  public:&#xA;    RFID(int chipSelectPin, int NRSTPD);&#xA;&#xA;    bool isCard();&#xA;    bool readCardSerial();&#xA;&#xA;    void init();&#xA;    void reset();&#xA;    void writeMFRC522(unsigned char addr, unsigned char val);&#xA;    void antennaOn(void);&#xA;    unsigned char readMFRC522(unsigned char addr);&#xA;    void setBitMask(unsigned char reg, unsigned char mask);&#xA;    void clearBitMask(unsigned char reg, unsigned char mask);&#xA;    void calculateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData);&#xA;    unsigned char MFRC522Request(unsigned char reqMode, unsigned char *TagType);&#xA;    unsigned char MFRC522ToCard(unsigned char command, unsigned char *sendData, unsigned char sendLen, unsigned char *backData, unsigned int *backLen);&#xA;    unsigned char anticoll(unsigned char *serNum);&#xA;    unsigned char auth(unsigned char authMode, unsigned char BlockAddr, unsigned char *Sectorkey, unsigned char *serNum);&#xA;    unsigned char read(unsigned char blockAddr, unsigned char *recvData);&#xA;    unsigned char write(unsigned char blockAddr, unsigned char *writeData);&#xA;    void halt();&#xA;&#xA;    unsigned char serNum[5];       // Constante para guardar el numero de serie leido.&#xA;    unsigned char AserNum[5];      // Constante para guardar el numero d serie de la secion actual.&#xA;&#xA;  private:&#xA;    int _chipSelectPin;&#xA;    int _NRSTPD;&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the code I have now I can read RFID data, and read them via the Serial monitor.&#xA;Now, if I want to write RFID numbers to a card, can I do this with this library, or what other library should I use that is capable of writing?&lt;/p&gt;&#xA;" OwnerUserId="8646" LastEditorUserId="8646" LastEditDate="2015-05-10T19:16:04.673" LastActivityDate="2017-03-27T13:23:03.120" Title="How to write RFID data using the RFID-RC522 chip" Tags="|library|spi|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11699" PostTypeId="2" ParentId="11690" CreationDate="2015-05-10T16:50:45.160" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://www.robotshop.com/media/files/pdf/datasheet-gsm-tc35.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;data sheet for the Siemens TC35&lt;/a&gt; says &lt;em&gt;&quot;The  data  interface  is  implemented  as  a  serial  asynchronous  transmitter  and  receiver conforming  to  ITU-T  RS-232  Interchange  Circuits  DCE.  It  operates  at  CMOS  level  (2.65V).&#xA;All RS-232 signals on the ZIF connector are low active.&quot;&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is actually a low-voltage  equivalent of &quot;RS232&quot; serial. Real RS232 uses -12V and +12V signalling for binary 0 and 1 but most modern devices work with logic levels, often inverted (e.g. 0V and ~3.3V). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduinos support in hardware only a single logic-level serial interface. A few Arduinos, like the Arduino Mega, will support up to four logic-level RS232 interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a software library, you can emulate a serial port over the digital IO pins but the Arduino will quickly run out of processing power if you try to emulate several RS232 interfaces. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;will this be possible by stacking the modules on one arduino?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Almost certainly not. I doubt the daughterboard (&quot;shield&quot;) designers made provision for that. At the least you'd have to re-route the serial interface to nonstandard pins and check that the power requirements don't exceed what the Arduino can supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can find a module that communicates over I2C or SPI there might be a better chance of getting it to work.&lt;/p&gt;&#xA;" OwnerUserId="316" LastEditorUserId="316" LastEditDate="2018-01-16T16:12:03.507" LastActivityDate="2018-01-16T16:12:03.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11701" PostTypeId="2" ParentId="11694" CreationDate="2015-05-10T19:40:02.547" Score="2" Body="&lt;p&gt;It's definitely feasible and it's been done. Look at &lt;a href=&quot;http://lowpowerlab.com/blog/category/moteino/wireless-programming/&quot; rel=&quot;nofollow&quot;&gt;Low Power Labs site&lt;/a&gt; where Felix did the same thing, but with a RF69 radio and an external flash chip. You do need a modified bootloader as he uses, one that would detect the new sketch in the external flash and will upload it to the Arduino on reset. Radio difference aside this should work well for your purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the flaky nature of the radio communication I think it's a good idea to store the program separately rather than create a highly modified bootloader which will read the radio stream - it might be that for programming you need a constant stream of bytes which the radio can't always provide (though I'm not 100% sure about this); another reason being that the extra code you would need to access the radio will make for a larger bootloader.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-10T19:40:02.547" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11703" PostTypeId="1" CreationDate="2015-05-10T20:43:59.023" Score="2" ViewCount="402" Body="&lt;p&gt;I'm trying to design an RC controller using an Arduino and an XBee Series 2 Pro. I have the hardware serial running for debug information and I want the XBee to be connected to a soft serial on pins 8 and 9. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino keeps restarting, or at least the setup function keeps looping, every time I try to send data through the XBee. If I modify the code so the XBee runs on the hard serial, the program works, but I would rather not have that setup because then to load new code onto the arduino I have to open the controller and disconnect the XBee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried changing the pins that the soft serial runs on and that makes no difference, nor does unplugging the power to the XBee but leaving the serial connections in. I also tried to write another pin high to make sure there's enough current, and that didn't cause a restart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino is connected to the XBee, 4 potentiometers, and 1 switch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBee.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define NOTE_A3  220&#xA;#define NOTE_B3  247&#xA;#define NOTE_C4  262&#xA;#define NOTE_D4  294&#xA;#define NOTE_E4  330&#xA;&#xA;#define THR_JOYSTICK A0&#xA;#define YAW_JOYSTICK A1&#xA;#define RL_JOYSTICK A2&#xA;#define FB_JOYSTICK A3&#xA;#define POT A4&#xA;#define TOGGLE 4&#xA;#define SPEAKER_PIN 3&#xA;//#define WAKE_PIN 10&#xA;&#xA;#define YAW_MIN 0&#xA;#define YAW_OFFSET 386&#xA;#define YAW_MAX 815&#xA;&#xA;#define RL_MIN 0&#xA;#define RL_OFFSET 359&#xA;#define RL_MAX 800&#xA;&#xA;#define FB_MIN 0&#xA;#define FB_OFFSET 355&#xA;#define FB_MAX 795&#xA;&#xA;#define THR_MIN 0&#xA;#define THR_OFFSET 0&#xA;#define THR_MAX 754&#xA;&#xA;const int ESC_MIN = 764;&#xA;const int ESC_OFFSET = 1500;&#xA;const int ESC_MAX = 2000;&#xA;&#xA;XBee xbee = XBee();&#xA;SoftwareSerial nss(13,12);&#xA;uint8_t payload[10];&#xA;// SH + SL Address of receiving XBee&#xA;XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40c67584);&#xA;ZBTxRequest packet = ZBTxRequest(addr64, payload, sizeof(payload));&#xA;ZBTxStatusResponse txStatus = ZBTxStatusResponse();&#xA;&#xA;void setup() {&#xA;  //start serials&#xA;  Serial.begin(9600);&#xA;  nss.begin(9600);&#xA;  xbee.setSerial(nss);&#xA;&#xA;  //pin modes&#xA;  pinMode(THR_JOYSTICK,INPUT);&#xA;  pinMode(YAW_JOYSTICK,INPUT);&#xA;  pinMode(RL_JOYSTICK,INPUT);&#xA;  pinMode(FB_JOYSTICK,INPUT);&#xA;  pinMode(POT,INPUT);&#xA;  pinMode(TOGGLE,INPUT);&#xA;  pinMode(SPEAKER_PIN,OUTPUT);&#xA;&#xA;  //delay to allow inputs to settle&#xA;  delay(1000);&#xA;&#xA;  //the speaker will need a total resistance of at least 125 Ohm&#xA;  //so if it's an 8 Ohm speaker, an additional 117 is needed etc...&#xA;&#xA;   //calibrate THR&#xA;  int first = millis();&#xA;  tone(SPEAKER_PIN,NOTE_A3);&#xA;  int reading = analogRead(THR_JOYSTICK);&#xA;  while(reading &amp;gt; THR_OFFSET + 5 || reading &amp;lt; THR_OFFSET - 5) {&#xA;    delay(20);&#xA;    reading = analogRead(THR_JOYSTICK);&#xA;  }&#xA;  int dif = 200 - millis() + first;&#xA;  if(dif &amp;lt;= 200 &amp;amp;&amp;amp; dif &amp;gt;= 0) {&#xA;    delay(dif);&#xA;  }&#xA;&#xA;  //calibrate YAW&#xA;  first = millis();&#xA;  tone(SPEAKER_PIN,NOTE_B3);&#xA;  reading = analogRead(YAW_JOYSTICK);&#xA;  while(reading &amp;gt; YAW_OFFSET + 5 || reading &amp;lt; YAW_OFFSET - 5) {&#xA;    delay(20);&#xA;    reading = analogRead(YAW_JOYSTICK);&#xA;  }&#xA;  dif = 200 - millis() + first;&#xA;  if(dif &amp;lt;= 200 &amp;amp;&amp;amp; dif &amp;gt;= 0) {&#xA;    delay(dif);&#xA;  }&#xA;&#xA;  //calibrate FB&#xA;  first = millis();&#xA;  tone(SPEAKER_PIN,NOTE_C4);&#xA;  reading = analogRead(FB_JOYSTICK);&#xA;  while(reading &amp;gt; FB_OFFSET + 5 || reading &amp;lt; FB_OFFSET - 5) {&#xA;    delay(20);&#xA;    reading = analogRead(FB_JOYSTICK);&#xA;  }&#xA;  dif = 200 - millis() + first;&#xA;  if(dif &amp;lt;= 200 &amp;amp;&amp;amp; dif &amp;gt;= 0) {&#xA;    delay(dif);&#xA;  }&#xA;&#xA;  //calibrate RL&#xA;  first = millis();&#xA;  tone(SPEAKER_PIN,NOTE_D4);&#xA;  reading = analogRead(RL_JOYSTICK);&#xA;  while(reading &amp;gt; RL_OFFSET + 5 || reading &amp;lt; RL_OFFSET - 5) {&#xA;    delay(20);&#xA;    reading = analogRead(RL_JOYSTICK);&#xA;  }&#xA;  dif = 200 - millis() + first;&#xA;  if(dif &amp;lt;= 200 &amp;amp;&amp;amp; dif &amp;gt;= 0) {&#xA;    delay(dif);&#xA;  }&#xA;&#xA;  //done&#xA;  tone(SPEAKER_PIN,NOTE_E4);&#xA;  delay(200);&#xA;  noTone(SPEAKER_PIN);&#xA;  delay(15);&#xA;  tone(SPEAKER_PIN,NOTE_E4);&#xA;  delay(200);&#xA;  noTone(SPEAKER_PIN);&#xA;  delay(15);&#xA;  tone(SPEAKER_PIN,NOTE_E4);&#xA;  delay(350);&#xA;  noTone(SPEAKER_PIN);&#xA;}&#xA;&#xA;void loop() {&#xA;  int POTReading = analogRead(POT);&#xA;  int toggle = digitalRead(TOGGLE);&#xA;&#xA;  int throttleValue = mapLimit(analogRead(THR_JOYSTICK) - THR_OFFSET,THR_MIN,THR_MAX - THR_OFFSET,0,ESC_OFFSET);&#xA;  int yawValue = mapLimit(analogRead(YAW_JOYSTICK),YAW_MIN,YAW_MAX,ESC_OFFSET-ESC_MAX,ESC_MAX - ESC_OFFSET);&#xA;  int rightLeftValue = mapLimit(analogRead(RL_JOYSTICK) - RL_OFFSET,RL_MIN,RL_MAX - RL_OFFSET,0,ESC_MAX - ESC_OFFSET);&#xA;  int frontBackValue = mapLimit(analogRead(FB_JOYSTICK) - FB_OFFSET,FB_MIN,FB_MAX - FB_OFFSET,0,ESC_MAX - ESC_OFFSET);&#xA;  int potValue = analogRead(POT);&#xA;  int toggleValue = digitalRead(toggle);&#xA;&#xA;  //throttle&#xA;  payload[0] = throttleValue &amp;gt;&amp;gt; 8 &amp;amp; 0xff;&#xA;  payload[1] = throttleValue &amp;amp; 0xff;&#xA;  //yaw&#xA;  payload[2] = yawValue &amp;gt;&amp;gt; 8 &amp;amp; 0xff;&#xA;  payload[3] = yawValue &amp;amp; 0xff;&#xA;  //RL&#xA;  payload[4] = rightLeftValue &amp;gt;&amp;gt; 8 &amp;amp; 0xff;&#xA;  payload[5] = rightLeftValue &amp;amp; 0xff;&#xA;  //FB&#xA;  payload[6] = frontBackValue &amp;gt;&amp;gt; 8 &amp;amp; 0xff;&#xA;  payload[7] = frontBackValue &amp;amp; 0xff;&#xA;  //Pot&#xA;  payload[8] = potValue &amp;gt;&amp;gt; 8 &amp;amp; 0xff;&#xA;  payload[9] = potValue &amp;amp; 0xff;&#xA;  //toggle&#xA;  payload[10] = (byte) toggleValue;&#xA;&#xA;  //wake XBee&#xA;  //digitalWrite(WAKE_PIN,LOW);&#xA;  xbee.send(packet);&#xA;   if(xbee.readPacket(500)) {&#xA;     if(xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {&#xA;       xbee.getResponse().getZBTxStatusResponse(txStatus);&#xA;       if(txStatus.getDeliveryStatus() != SUCCESS) {&#xA;         //the remote XBee didn't ACK&#xA;         tone(SPEAKER_PIN,NOTE_C4,100); &#xA;       }&#xA;     }  &#xA;   } else {&#xA;     //error or something&#xA;     tone(SPEAKER_PIN,NOTE_E4);&#xA;     noTone(SPEAKER_PIN);&#xA;     tone(SPEAKER_PIN,NOTE_E4,50);  &#xA;   }&#xA;&#xA;    //sleep XBee&#xA;    //digitalWrite(WAKE_PIN,HIGH);&#xA;    delay(100);&#xA;}&#xA;&#xA;int mapLimit(int val, int fromLow, int fromHigh, int toLow, int toHigh) {&#xA;  int result = map(val,fromLow,fromHigh,toLow,toHigh);&#xA;  if(result &amp;gt; toHigh) {&#xA;    result = toHigh;&#xA;  } else if(result &amp;lt; -toHigh) {&#xA;    result = -toHigh;&#xA;  }&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9973" LastEditorUserId="9973" LastEditDate="2015-05-10T21:22:10.657" LastActivityDate="2015-05-11T03:00:36.987" Title="Why is SoftwareSerial causing arduino to reboot?" Tags="|arduino-uno|serial|xbee|softwareserial|uart|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11705" PostTypeId="2" ParentId="11703" CreationDate="2015-05-10T23:36:25.460" Score="0" Body="&lt;p&gt;Just a guess, but maybe your Arduino power supply isn't juicy enough. I had the same problem running 2 modules + LCD on a Arduino powered via USB.&#xA;Try to find a power supply somewhere between 9 and 12V (from an old router, modem or cellphone you don't need anymore), and use it to power your Arduino instead of relying on the the USB port alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Learning/WhatAdapter&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/WhatAdapter&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9860" LastActivityDate="2015-05-10T23:36:25.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11706" PostTypeId="2" ParentId="10399" CreationDate="2015-05-10T23:56:58.490" Score="1" Body="&lt;p&gt;As I was playing around today I found a solution. Powering the board through the FTDI adapter, which in turn was being powered by a USB juicepack charger, wasn't supplying enough juice and/or ground. It was enough for the Uno to work, so that's what was confusing me. I soldered in a 9V battery and clamped down on the pins with a wrench to ground it out. That made the board happy and it kicked into gear and lit my project up perfectly. It's pretty ghetto but it works! Yeah! :D&lt;img src=&quot;https://i.stack.imgur.com/6oxPo.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8742" LastActivityDate="2015-05-10T23:56:58.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11707" PostTypeId="1" CreationDate="2015-05-11T02:25:43.833" Score="0" ViewCount="2246" Body="&lt;p&gt;I'm making a clock using an arduino uno and a compatible freetronics screen. So far it can count the time in a 24 hour loop after which it repeats and counts again. The screen had a number of buttons built onto it and I want to get it so that when one of the buttons on the screen is pressed it prints the time that it was pressed on the top line of the screen while continuing to count and print the time on the second line of the screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I edit my code below to do this when a button is pressed? What sort of command do I need to add?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;#define MILLIS_OVERFLOW 34359738&#xA;&#xA;/**&#xA;* Clock Variables&#xA;*/&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds = 0, minutes = 0, hours = 8;&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;    lcd.begin( 16, 2 ); &#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;setClock();&#xA;&#xA;/**&#xA; * After set clock now you have 3 int variables with the current time&#xA; */&#xA; //seconds&#xA; //minutes&#xA; //hours&#xA; lcd.setCursor ( 0, 1);&#xA; lcd.print(hours);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(minutes);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(seconds);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(elapsedMillis);&#xA;&#xA;}&#xA;&#xA;void setClock()&#xA;{&#xA;currentMillis = millis();&#xA;/**&#xA; * The only moment when currentMillis will be smaller than previousMillis&#xA; * will be when millis() oveflows&#xA; */&#xA;if (currentMillis &amp;lt; previousMillis){&#xA;    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;&#xA;} else {&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;}&#xA;&#xA;/**&#xA; * If we use equals 1000 its possible that because of the mentioned loop limitation&#xA; * you check the difference when its value is (999) and on the next loop its value is (1001)&#xA; */&#xA;if (elapsedMillis &amp;gt; 999){&#xA;    seconds++;&#xA;    elapsedMillis = elapsedMillis - 1000;&#xA;}&#xA;&#xA;if (seconds == 60){&#xA;    minutes++;&#xA;    seconds = 0;&#xA;}&#xA;if (minutes == 60){&#xA;    hours++;&#xA;    minutes = 0;&#xA;}&#xA;if (hours == 24){&#xA;    hours = 0;&#xA;}&#xA;&#xA;previousMillis = currentMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help will be greatly appreciated, thanks&lt;/p&gt;&#xA;" OwnerUserId="8588" LastEditorUserId="8588" LastEditDate="2015-05-11T20:36:26.793" LastActivityDate="2015-11-09T14:14:48.437" Title="Arduino clock needed to print the time a button is pressed while continuing to count the time?" Tags="|arduino-uno|time|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11708" PostTypeId="2" ParentId="11703" CreationDate="2015-05-11T03:00:36.987" Score="2" Body="&lt;p&gt;10 bytes in &lt;code&gt;payload&lt;/code&gt; were being used, but &lt;code&gt;payload&lt;/code&gt; was declared using &lt;code&gt;int payload[10]&lt;/code&gt; when it should have been &lt;code&gt;int payload[11]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="9973" LastActivityDate="2015-05-11T03:00:36.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11709" PostTypeId="2" ParentId="11707" CreationDate="2015-05-11T06:27:54.373" Score="0" Body="&lt;p&gt;use a second variable called TNow and when the button is pressed pass it the value of currentMillis. parse  and use this as the value to display. or have misunderstood your question? wondering why you aren't using a time library. such as &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_Time.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;&#xA;if you look on the site &lt;a href=&quot;http://playground.arduino.cc/code/time&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;  use the time library you can then use  &lt;em&gt;variable name&lt;/em&gt; = now();&lt;/p&gt;&#xA;" OwnerUserId="8004" LastEditorUserId="8004" LastEditDate="2015-05-13T04:50:43.367" LastActivityDate="2015-05-13T04:50:43.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11710" PostTypeId="1" CreationDate="2015-05-11T06:37:53.703" Score="4" ViewCount="3208" Body="&lt;p&gt;I am using Arduino Uno and my question is when data is coming on Rx pin and at that time our program is not checking Serial.available() &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then after some time the program will check Serial.available(). &#xA;Can we read data? Does it get stored in memory? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If stored how to remove that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the answer the same for Software.Serial()?&lt;/p&gt;&#xA;" OwnerUserId="7165" LastEditorUserId="26717" LastEditDate="2017-08-25T00:27:12.123" LastActivityDate="2017-08-25T00:27:12.123" Title="Does data coming in on Arduino serial port store for some time?" Tags="|arduino-uno|serial|xbee|communication|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11714" PostTypeId="2" ParentId="11710" CreationDate="2015-05-11T10:23:18.647" Score="7" Body="&lt;p&gt;Yes.  The serial port uses a &lt;em&gt;ring buffer&lt;/em&gt; (also known as a &lt;em&gt;circular buffer&lt;/em&gt;) for storing the incoming data until you want it.  That buffer is 16 bytes in size on the smaller Arduinos and 64 bytes in size on the larger one.  A similar ring buffer is used to store transmitted data until the port is ready to transmit it in the background.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2017-08-22T09:12:48.130" LastActivityDate="2017-08-22T09:12:48.130" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="11715" PostTypeId="1" CreationDate="2015-05-11T11:15:18.770" Score="0" ViewCount="342" Body="&lt;p&gt;Is there a way to set a time for instance 8.00 PM to make the arduino-uno start or stop at that time?&lt;/p&gt;&#xA;" OwnerUserId="9920" LastActivityDate="2015-05-11T12:08:41.387" Title="Arduino Start en Stop" Tags="|arduino-uno|timers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11716" PostTypeId="1" AcceptedAnswerId="11720" CreationDate="2015-05-11T11:45:57.787" Score="0" ViewCount="33" Body="&lt;p&gt;I´m using Spark Fun Micro Pro board 5V: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and to that i´ve hooked a true color OLED from digole: &lt;a href=&quot;http://www.digole.com/index.php?productID=859&quot; rel=&quot;nofollow&quot;&gt;http://www.digole.com/index.php?productID=859&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I manage to get my VAL from my potentiometer on screen. But when I exceeds val &quot;10&quot;, and then go back to lets say &quot;9&quot;, the zero from &quot;10&quot; is still there. It looks like:  &quot;90&quot; instead of &quot;9&quot;. The problem is of course that the second (and third) number don't go away.. Im sure there is a simple way of doing this but I can't get my head around it..&#xA;I´ve tried using clearScreen but that function makes the OLED blink in a unpleasant way every time it clears... Hope you get my question, english isn't my native language, as u maybe can tell =)&#xA;Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  val = analogRead(potpin);        // reads the value of the     potentiometer (value between 0 and 1023) &#xA;  val = map(val, 0, 1023, 0, 179);  // scale it to use it with the servo (value between 0 and 180) &#xA;  myservo.write(val)  sets the servo position according to the scaled     value &#xA;  mydisp.clearScreen();&#xA;  mydisp.setPrintPos(9, 6);&#xA;  mydisp.print(val);&#xA;&#xA;  delay(200);  // waits for the servo to get there &#xA; // mydisp.clearScreen();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9922" LastActivityDate="2015-05-12T18:24:07.940" Title="Passing VAL(0-179) to OLED" Tags="|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11717" PostTypeId="2" ParentId="11715" CreationDate="2015-05-11T11:46:27.067" Score="3" Body="&lt;p&gt;Really stop Arduino is possible, it's called sleep mode, but the UNO is designed so badly with respect to power consumption that you may as well keep it running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have it done something at a specific time you could connect a real time clock (RTC) breakout board (SparkFun has a couple). Use a 1 second timer interrupt to read the clock and compare it with (a table of) times where you want things done. A table could hold the time, an output (e.g. for a relay) and the new status (on or off). If you have just a couple of those you can store them in the RTC's battery-backed up RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt;&lt;br&gt;&#xA;You can use your PC's time, all the hardware you need is the USB cable. On the PC you run a program that sends the current time to the Arduino. (There are &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;Processing examples&lt;/a&gt; of how to communicate with the Arduino on the Net.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that without an RTC your PC will have to be on all the time and connected to the Arduino. You could use the PC just to sync the Arduino's clock and keep time yourself, but the clock of the Arduino is not very accurate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting the time from the Internet is also possible, but then you'll need a Wifi or Ethernet shield to make the connection. &lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-05-11T12:08:41.387" LastActivityDate="2015-05-11T12:08:41.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11719" PostTypeId="2" ParentId="9214" CreationDate="2015-05-11T12:09:30.873" Score="0" Body="&lt;p&gt;Take a look at these jumper wires. &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00M5WLZDW&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/gp/aw/d/B00M5WLZDW/ref=mp_s_a_1_6?qid=1431346007&amp;amp;sr=8-6&amp;amp;pi=AC_SX110_SY165_QL70&lt;/a&gt; they are really great for debugging as well as more permanent solutions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking to build more than 5 go with some of the other posted answers &lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-05-11T12:09:30.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11720" PostTypeId="2" ParentId="11716" CreationDate="2015-05-11T12:13:10.923" Score="0" Body="&lt;p&gt;Instead of printing &quot;10&quot; or &quot;9&quot; etc, print &quot;10 &quot; or &quot;9 &quot;.  Add an extra space at the end of what you print which overwrites the character that was there before.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mydisp.print(val);&#xA;mydisp.print(&quot;  &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used 2 spaces there, in case you go from 3 digits straight to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method is to &quot;format&quot; the number using sprintf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp[4];&#xA;sprintf(temp, &quot;%3d&quot;, val);&#xA;mydisp.print(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-12T18:24:07.940" LastActivityDate="2015-05-12T18:24:07.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11721" PostTypeId="2" ParentId="11696" CreationDate="2015-05-11T12:17:57.183" Score="0" Body="&lt;p&gt;Ouch man you are getting burned by CORS. This stack overflow box isn't big enough for me to explain how much of a pain CORS is and how much trouble it will cause you. That being said there is a really good recourse that will help explain how to get this working with a couple of http headers &lt;a href=&quot;http://enable-cors.org/&quot; rel=&quot;nofollow&quot;&gt;http://enable-cors.org/&lt;/a&gt;. Good luck &lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-05-11T12:17:57.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11722" PostTypeId="1" CreationDate="2015-05-11T12:34:33.297" Score="1" ViewCount="84" Body="&lt;p&gt;I am using an Arduino MEGA connected to my Linux workstation via USB. I have been using this setup for several months with no issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few days ago, &lt;strong&gt;the usual serial device file (&lt;code&gt;/dev/ttyACM0&lt;/code&gt;) stopped showing up when I plug in the device&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Haven't re-flashed recently.&lt;/li&gt;&#xA;&lt;li&gt;Unable to reflash.&lt;/li&gt;&#xA;&lt;li&gt;Removing the devices only shield does not do anything.&lt;/li&gt;&#xA;&lt;li&gt;Have not changed my physical setup recently.&lt;/li&gt;&#xA;&lt;li&gt;Connector cable is confirmed working with a different device.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is this a case of bad hardware, or is there a possible fix other than buying a new device?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;code&gt;dmesg&lt;/code&gt; results&lt;/strong&gt;: None (cleared buffer and re-ran dmesg after plugging / unplugging device)&#xA;&lt;strong&gt;usb-devices&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2&#xA;D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=1d6b ProdID=0002 Rev=03.13&#xA;S:  Manufacturer=Linux 3.13.0-37-generic ehci_hcd&#xA;S:  Product=EHCI Host Controller&#xA;S:  SerialNumber=0000:00:1a.0&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&#xA;T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 6&#xA;D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=8087 ProdID=0024 Rev=00.00&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&#xA;T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2&#xA;D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=1d6b ProdID=0002 Rev=03.13&#xA;S:  Manufacturer=Linux 3.13.0-37-generic ehci_hcd&#xA;S:  Product=EHCI Host Controller&#xA;S:  SerialNumber=0000:00:1d.0&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&#xA;T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 6&#xA;D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=8087 ProdID=0024 Rev=00.00&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&#xA;T:  Bus=02 Lev=02 Prnt=02 Port=03 Cnt=01 Dev#=  3 Spd=480 MxCh= 0&#xA;D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=1bcf ProdID=2805 Rev=20.15&#xA;S:  Manufacturer=6047B0021601A0218M7NB&#xA;S:  Product=HP HD Webcam [Fixed]&#xA;C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo&#xA;I:  If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo&#xA;&#xA;T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=02 Dev#=  4 Spd=12  MxCh= 0&#xA;D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=0bda ProdID=0001 Rev=68.17&#xA;S:  Product=CSR BS8510&#xA;C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb&#xA;I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb&#xA;&#xA;T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2&#xA;D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=1d6b ProdID=0002 Rev=03.13&#xA;S:  Manufacturer=Linux 3.13.0-37-generic xhci_hcd&#xA;S:  Product=xHCI Host Controller&#xA;S:  SerialNumber=0000:26:00.0&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&#xA;T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 2&#xA;D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1&#xA;P:  Vendor=1d6b ProdID=0003 Rev=03.13&#xA;S:  Manufacturer=Linux 3.13.0-37-generic xhci_hcd&#xA;S:  Product=xHCI Host Controller&#xA;S:  SerialNumber=0000:26:00.0&#xA;C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ls-usb&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 002 Device 004: ID 0bda:0001 Realtek Semiconductor Corp. &#xA;Bus 002 Device 003: ID 1bcf:2805 Sunplus Innovation Technology Inc. &#xA;Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&#xA;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9984" LastEditorUserId="9984" LastEditDate="2015-05-11T13:50:37.373" LastActivityDate="2015-05-11T14:25:46.180" Title="Serial device file no longer shows up in /dev/ after working fine for months" Tags="|serial|arduino-mega|shields|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11724" PostTypeId="2" ParentId="11646" CreationDate="2015-05-11T13:16:12.657" Score="1" Body="&lt;p&gt;This is a classic system where PID will really pay off. Basically this will allow you to tune your system so that if you are off by 5 degree it will open the relays for 3 seconds. But if you are off by 1 degree it will open them for half a second. (Or whatever works for you). It might be tricky for you to get right but it will give you the smooth response that looks really good and feels natural.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look here &lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/PIDLibrary&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8175" LastActivityDate="2015-05-11T13:16:12.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11726" PostTypeId="2" ParentId="11722" CreationDate="2015-05-11T14:25:46.180" Score="1" Body="&lt;p&gt;The fact that &lt;code&gt;dmesg&lt;/code&gt; gives you nothing at all is the most telling fact.  The there was a communication problem, or the firmware had messed up on the USB interface chip, then you'd expect something to show up - even if it was something along the lines of &quot;device not accepting address 8: -71&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can ignore the main ATMega2560 chip since that has no bearing on the USB interface.  Instead we're interested in the ATMega16U2 (or whatever is on your board version).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So some things you need to confirm by probing around on the board with a multimeter, or better still, an oscilloscope:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check that there is power to the board through the USB.&lt;/li&gt;&#xA;&lt;li&gt;Check that there is power both sides of the green (or brown-ish if you have a clone) poly-fuse near the USB socket&lt;/li&gt;&#xA;&lt;li&gt;If you have an oscilloscope, switch the probe to 10x and look for oscillations on the crystal's pins.&lt;/li&gt;&#xA;&lt;li&gt;Grab the datasheet for your ATMega&lt;em&gt;xx&lt;/em&gt;U2 chip and get the pinout.  Check that there is power on the pins there should be power on.&lt;/li&gt;&#xA;&lt;li&gt;Check that the RESET pin of the ATMega&lt;em&gt;xx&lt;/em&gt;U2 chip is HIGH.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you have a hardware programmer, or another Arduino you can use as a hardware programmer, connect it to the 2x3 header (you may need to populate it first) and try get it to identify the chip ID.  Try to re-flash the USB interface firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing to check is the USB socket itself.  Those big chunky USB sockets look strong, but they're actually quite flimsy inside.  The metal leaves that the plug presses against can bend with time and not make a good contact.  Using a fine needle try lifting them up slightly so they make better contact with the cable.  I think Arduino are the only people that still use them in an active product these days ;)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-11T14:25:46.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11728" PostTypeId="2" ParentId="9626" CreationDate="2015-05-11T15:10:53.937" Score="0" Body="&lt;p&gt;This link worked for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&quot; rel=&quot;nofollow&quot;&gt;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Found it in a forum:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please have a look at this ino file&#xA;  &lt;a href=&quot;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&quot; rel=&quot;nofollow&quot;&gt;http://www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid_en_ino.txt&lt;/a&gt;&#xA;  this ino file works with my reader  but this rc522 library does not&#xA;  &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;https://github.com/miguelbalboa/rfid&lt;/a&gt;  I want to know the difference as&#xA;  i was not able to spot any, one works and another does not. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Please let me know if there is any editing to be done so to get&#xA;  &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;https://github.com/miguelbalboa/rfid&lt;/a&gt; this working&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="9991" LastActivityDate="2015-05-11T15:10:53.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11729" PostTypeId="1" AcceptedAnswerId="11733" CreationDate="2015-05-11T16:25:04.993" Score="1" ViewCount="1370" Body="&lt;p&gt;I have an nmake file;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  srcpath = ..\pilot&#xA;  cmdline =  &quot;C:\Program Files (x86)\Arduino\arduino.exe&quot;&#xA;  cmdflags = --verify  --board arduino:avr:uno --port com4 -v --preserve-temp-files&#xA;  prefs = --pref sketchbook.path=$(srcpath) --pref build.path=build&#xA;  deps = $(srcpath)\pilot.ino $(srcpath)\commands.h $(srcpath)\publish.h $(srcpath)\motor.h &#xA;&#xA;  pilot.hex :$(deps)&#xA;    type $(srcpath)\pilot.ino&#xA;    $(cmdline) $(cmdflags) $(prefs) $(srcpath)\pilot.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file types out fine, but Arduino returns an error;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;failed to open sketch ..\pilot\pilot.ino&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am setting --pref sketchbook.path=$(srcpath), but I have tried with and without (and many variations of both) and get the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the command that is currently being invoked, and looks correct to me;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;C:\Program Files (x86)\Arduino\arduino.exe&quot; --verify  --board arduino:avr:uno --port com4 -v --preserve-temp-files --pref sketchbook.path=..\pilot --pref build.path=build ..\pilot\pilot.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-11T18:11:50.430" LastActivityDate="2015-05-12T11:47:06.807" Title="Using Arduino command line on windows" Tags="|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11730" PostTypeId="1" AcceptedAnswerId="12310" CreationDate="2015-05-11T16:45:55.620" Score="0" ViewCount="4888" Body="&lt;p&gt;I need help to record databаse from dht11 sensor to mysql server.&#xA;this is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // RESERVED MAC ADDRESS&#xA;EthernetClient client;&#xA;&#xA;IPAddress server(192,168,0,102); // IP Adres (or name) of server to dump data to&#xA;&#xA;#define DHTPIN 2 // SENSOR PIN&#xA;#define DHTTYPE DHT11 // SENSOR TYPE - THE ADAFRUIT LIBRARY OFFERS SUPPORT FOR MORE MODELS&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;long previousMillis = 0;&#xA;unsigned long currentMillis = 0;&#xA;long interval = 250000; // READING INTERVAL&#xA;&#xA;float temperature = 0;  // TEMPERATURE VAR&#xA;float humidity = 0; // HUMIDITY VAR&#xA;String data;&#xA;&#xA;void setup() { &#xA;    Serial.begin(115200);&#xA;&#xA;    if (Ethernet.begin(mac) == 0) {&#xA;        Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;); &#xA;    }&#xA;&#xA;    dht.begin(); &#xA;    delay(10000); // GIVE THE SENSOR SOME TIME TO START&#xA;&#xA;       temperature = (float) dht.readTemperature();&#xA;       humidity = (float) dht.readHumidity();&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;    currentMillis = millis();&#xA;    if(currentMillis - previousMillis &amp;gt; interval) { // READ ONLY ONCE PER INTERVAL&#xA;        previousMillis = currentMillis;&#xA;        temperature = (float) dht.readTemperature();&#xA;                humidity = (float) dht.readHumidity();&#xA;    }&#xA;&#xA;&#xA;    if (client.connect(server, 3306)) {&#xA;          Serial.print(&quot;temperature=&quot; );&#xA;          Serial.println( temperature );&#xA;          Serial.print(&quot;humidity=&quot; );&#xA;          Serial.println( humidity );&#xA;          Serial.println(&quot;-&amp;gt; Connected&quot;);&#xA;            if(client.connected()){&#xA;            // Make a HTTP request:&#xA;            client.print( &quot;GET /add_data.php?&quot;);&#xA;            client.print(&quot;temperature=&quot;);&#xA;            client.print( temperature);&#xA;            client.print(&quot;humidity=&quot;);&#xA;            client.print( humidity);&#xA;            client.println( &quot; HTTP/1.1&quot;);&#xA;            client.println( &quot;Host: 192.168.0.102&quot; );&#xA;            //client.println(server);&#xA;            client.println( &quot;Connection: close&quot; );&#xA;            client.println();&#xA;            client.println();&#xA;            client.stop();&#xA;          }&#xA;        }&#xA;    if (client.connected()) { &#xA;        client.stop();  // DISCONNECT FROM THE SERVER&#xA;    }&#xA;&#xA;    delay(30000); // WAIT FIVE MINUTES BEFORE SENDING AGAIN&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I connected to database but can't make records. this is output on serial monitor: &#xA;temperature=21.00&#xA;humidity=73.00&#xA;-&gt; Connected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my php:add_data.php&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;    // Connect to MySQL&#xA;    include(&quot;dbconnect.php&quot;);&#xA;&#xA;    // Prepare the SQL statement&#xA;    $SQL = &quot;INSERT INTO test.test.temperature (temperature ,humidity) VALUES ('&quot;.$_GET[&quot;temperature&quot;].&quot;', '&quot;.$_GET[&quot;humidity=&quot;].&quot;')&quot;;&#xA;&#xA;    // Execute SQL statement&#xA;    mysql_query($SQL);&#xA;&#xA;    // Go to the review_data.php (optional)&#xA;    header(&quot;Location: review_data.php&quot;);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;dbconnect.php=&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;$MyUsername = &quot;root&quot;;  // enter your username for mysql&#xA;$MyPassword = &quot;fifa2005&quot;;  // enter your password for mysql&#xA;$MyHostname = &quot;localhost&quot;;      // this is usually &quot;localhost&quot; unless your database resides on a different server&#xA;&#xA;$dbh = mysql_pconnect($MyHostname , $MyUsername, $MyPassword);&#xA;$selected = mysql_select_db(&quot;test&quot;,$dbh);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;review_data.php=&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;&amp;lt;head&amp;gt;&#xA;    &amp;lt;title&amp;gt;Arduino Temperature Log&amp;lt;/title&amp;gt;&#xA;    &amp;lt;style type=&quot;text/css&quot;&amp;gt;&#xA;        .table_titles, .table_cells_odd, .table_cells_even {&#xA;            padding-right: 20px;&#xA;            padding-left: 20px;&#xA;            color: #000;&#xA;        }&#xA;        .table_titles {&#xA;            color: #FFF;&#xA;            background-color: #666;&#xA;        }&#xA;        .table_cells_odd {&#xA;            background-color: #CCC;&#xA;        }&#xA;        .table_cells_even {&#xA;            background-color: #FAFAFA;&#xA;        }&#xA;        table {&#xA;            border: 2px solid #333;&#xA;        }&#xA;        body { font-family: &quot;Trebuchet MS&quot;, Arial; }&#xA;    &amp;lt;/style&amp;gt;&#xA;&amp;lt;/head&amp;gt;&#xA;&#xA;&amp;lt;body&amp;gt;&#xA;&amp;lt;h1&amp;gt;Arduino Temperature Log&amp;lt;/h1&amp;gt;&#xA;&amp;lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;4&quot;&amp;gt;&#xA;    &amp;lt;tr&amp;gt;&#xA;        &amp;lt;td class=&quot;table_titles&quot;&amp;gt;ID&amp;lt;/td&amp;gt;&#xA;        &amp;lt;td class=&quot;table_titles&quot;&amp;gt;Date and Time&amp;lt;/td&amp;gt;&#xA;        &amp;lt;td class=&quot;table_titles&quot;&amp;gt;Temperature&amp;lt;/td&amp;gt;&#xA;        &amp;lt;td class=&quot;table_titles&quot;&amp;gt;Humidity&amp;lt;/td&amp;gt;&#xA;    &amp;lt;/tr&amp;gt;&#xA;    &amp;lt;?php&#xA;    // Retrieve all records and display them&#xA;    $result = mysql_query(&quot;SELECT * FROM temperature ORDER BY id ASC&quot;);&#xA;&#xA;    // Used for row color toggle&#xA;    $oddrow = true;&#xA;&#xA;    // process every record&#xA;    while( $row = mysql_fetch_array($result) )&#xA;    {&#xA;        if ($oddrow)&#xA;        {&#xA;            $css_class=' class=&quot;table_cells_odd&quot;';&#xA;        }&#xA;        else&#xA;        {&#xA;            $css_class=' class=&quot;table_cells_even&quot;';&#xA;        }&#xA;&#xA;        $oddrow = !$oddrow;&#xA;&#xA;        echo '&amp;lt;tr&amp;gt;';&#xA;        echo '   &amp;lt;td'.$css_class.'&amp;gt;'.$row[&quot;id&quot;].'&amp;lt;/td&amp;gt;';&#xA;        echo '   &amp;lt;td'.$css_class.'&amp;gt;'.$row[&quot;timestamp&quot;].'&amp;lt;/td&amp;gt;';&#xA;        echo '   &amp;lt;td'.$css_class.'&amp;gt;'.$row[&quot;temperature&quot;].'&amp;lt;/td&amp;gt;';&#xA;        echo '   &amp;lt;td'.$css_class.'&amp;gt;'.$row[&quot;humidity&quot;].'&amp;lt;/td&amp;gt;';&#xA;        echo '&amp;lt;/tr&amp;gt;';&#xA;    }&#xA;    ?&amp;gt;&#xA;&amp;lt;/table&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8289" LastEditorUserId="8289" LastEditDate="2015-05-12T05:42:23.100" LastActivityDate="2017-02-12T14:04:05.460" Title="DHT11 with Mysql" Tags="|arduino-uno|ethernet|temperature-sensor|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11732" PostTypeId="2" ParentId="9223" CreationDate="2015-05-11T19:36:15.193" Score="2" Body="&lt;p&gt;In fact, the basic Arduino Mega (with the ATmega 1280) &lt;strong&gt;utilizes an FT232RL&lt;/strong&gt;, so yes, it will work if you connect it correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is only the newer Mega2560 (along with the similar-generation Uno, etc) which utilizes an ATmega16u2 or similar as the USB bridge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, the bootloader doesn't care - you should be able to use either target chip with either USB bridge (or others).&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-11T19:36:15.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11733" PostTypeId="2" ParentId="11729" CreationDate="2015-05-11T19:58:41.423" Score="0" Body="&lt;pre&gt;&lt;code&gt;srcPath = C:\Users\mikep\Documents\MWPRobotics\Pilot\Pilot&#xA;bldPath = $(srcPath)\build&#xA;arduinoCmd = &quot;C:\Program Files (x86)\Arduino\arduino.exe&quot;&#xA;arduinoFlags = --verify --board arduino:avr:uno --port com4 -v --preserve-temp-files --preferences-file $(bldPath)\pilotPrefs.txt&#xA;prefs = --pref sketchbook.path=$(srcPath) --pref build.path=$(bldPath)&#xA;&#xA;deps = $(srcPath)\Pilot.ino $(srcPath)\commands.h $(srcPath)\publish.h  $(srcPath)\motor.h &#xA;&#xA;pilot.hex : $(deps)&#xA;#   type $(srcPath)\Pilot.ino&#xA;    $(arduinoCmd) $(arduinoFlags) $(prefs) $(srcPath)\Pilot.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently it is really picky about absolute full paths (contrary to the comments that say it is relative)&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorUserId="46" LastEditDate="2015-05-12T11:47:06.807" LastActivityDate="2015-05-12T11:47:06.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11734" PostTypeId="1" CreationDate="2015-05-11T20:13:04.257" Score="2" ViewCount="5815" Body="&lt;p&gt;I'm building a garden monitor, so I got myself an Arduino Nano, a soil humidity sensor, an air humidity and temperature sensor as well as a luminosity sensor. Since I had not one but two Raspberry Pis laying around I thought I'll handle the receiving end with one of them. I also got a 433 MHz RF kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trail of the information will look like this: Sensor(s) -&gt; Arduino -&gt; 433 MHz Transmitter - - - 433 MHz - - - 433 MHz Receiver -&gt; Raspberry Pi&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my question is, what libraries should I use? I checked &lt;a href=&quot;https://github.com/sui77/rc-switch&quot; rel=&quot;nofollow&quot;&gt;rc-switch&lt;/a&gt; (it has libs for both Arduino as well as &lt;a href=&quot;https://github.com/r10r/rcswitch-pi&quot; rel=&quot;nofollow&quot;&gt;RPi&lt;/a&gt;) and managed to send some codes but it seems that I'll need to write my own protocol to use this to transmit even simple data as it wasn't developed for sending data, rather simple switch on / switch off signals to simulate remotes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.airspayce.com/mikem/arduino/VirtualWire/&quot; rel=&quot;nofollow&quot;&gt;VirtualWire&lt;/a&gt; would seem as the ideal candidate but the problem is it doesn't have an RPi equivalent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="9988" LastEditorUserId="9988" LastEditDate="2015-05-12T09:46:39.633" LastActivityDate="2016-04-16T03:23:50.627" Title="Sending sensor readings from Arduino to Raspberry Pi over 433 MHz" Tags="|virtualwire|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11735" PostTypeId="1" AcceptedAnswerId="11736" CreationDate="2015-05-11T10:44:11.013" Score="0" ViewCount="200" Body="&lt;p&gt;I have a setup where two XBEES modules are talking to each other, both using XBEE shields, one attached to an UNO ARDUINO and the other a MEGA ARDUINO. One XBEE sends the data and the other receives it and switch on or off a LED. &#xA;The problem is the receiver one don't work. &#xA;This is the sender code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;const int bouton = 2; String inputString;&#xA;void setup() {&#xA;pinMode(led, OUTPUT);&#xA;Serial1.begin(9600);&#xA;Serial.begin(9600);&#xA;digitalWrite(led, LOW);&#xA;}&#xA;void loop() {&#xA;while (Serial.available() ) {&#xA;// get the new byte:&#xA;delay(3);  &#xA;char inChar = Serial.read();&#xA;// add it to the inputString:&#xA;inputString += inChar;&#xA;}&#xA;if (inputString.length() &amp;gt;0) {&#xA;Serial.println(inputString);&#xA;Serial1.println(inputString);&#xA;inputString=&quot;&quot;; &#xA;}&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This the receiver one &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;String inputString;&#xA;void setup() {&#xA;// put your setup code here, to run once:&#xA;pinMode(led, OUTPUT);&#xA;Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;while (Serial.available() ) {&#xA;// get the new byte:&#xA;delay(3);  &#xA;char inChar = Serial.read();&#xA;// add it to the inputString:&#xA;inputString += inChar;   &#xA;}&#xA;&#xA;if (inputString.length() &amp;gt;0) {&#xA;Serial.println(inputString);&#xA;if (inputString == &quot;on&quot;){&#xA;digitalWrite(led,HIGH);&#xA;Serial.println(&quot;LED ON&quot;);&#xA;}&#xA;&#xA;if (inputString == &quot;off&quot;){&#xA;digitalWrite(led,LOW);&#xA;   Serial.println(&quot;LED OFF&quot;);&#xA;}&#xA;inputString=&quot;&quot;; &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get on the serial monitor of ARDUINO UNO what i wrote in the serial monitor of ARDUINO MEGA but the LED don't switch on or off :/&lt;/p&gt;&#xA;" OwnerUserId="10095" OwnerDisplayName="sawi" LastActivityDate="2015-05-11T21:07:55.213" Title="connection between two ARDUINO with xbee" Tags="|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11736" PostTypeId="2" ParentId="11735" CreationDate="2015-05-11T12:37:58.917" Score="0" Body="&lt;p&gt;Probably you are getting a new character/carrier return (\n or \n\r) in your receivers' string, that is why it won't match exactly &quot;on&quot; or &quot;off&quot;, it will be &quot;on\n&quot;, &quot;on\r\n&quot; or similar.&lt;/p&gt;&#xA;" OwnerUserId="10001" OwnerDisplayName="davidrojas" LastActivityDate="2015-05-11T12:37:58.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11737" PostTypeId="1" CreationDate="2015-05-11T21:39:20.667" Score="2" ViewCount="4999" Body="&lt;p&gt;I have two Arduino boards and I want to make them communicate via I2C. The first board (slave) should read a temperature value from a DS18B20 sensor (OneWire) and send it to the second board (master) via I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I tried to merge some code from the standard examples (Wire/master_reader, Wire/slave_sender and dallas/simple).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the two sketches bellow, the serial monitor of the master board is printing the &quot;hello &quot; message, but when I enable the request temperature lines (slave code)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;sensors.requestTemperatures();&#xA;sensors.getTempCByIndex(0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the serial monitor shows nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wander if there is a conflict between OneWire and I2C, or if I've made some serious mistakes in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Master&lt;/h1&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup(){&#xA;    Wire.begin();        &#xA;    Serial.begin(9600);  &#xA;}&#xA;&#xA;void loop(){&#xA;    Wire.requestFrom(2, 6);    &#xA;    while(Wire.available()){ &#xA;        char c = Wire.read();&#xA;        Serial.print(c);     &#xA;        }&#xA;    delay(500);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Slave&lt;/h1&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#define ONE_WIRE_BUS 2&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;void setup(){&#xA;    sensors.begin();&#xA;    Wire.begin(2);                &#xA;    Wire.onRequest(requestEvent); &#xA; }&#xA;&#xA;void loop(){&#xA;}&#xA;&#xA;void requestEvent(){&#xA;&#xA;    //sensors.requestTemperatures();&#xA;    //sensors.getTempCByIndex(0);&#xA;&#xA;    Wire.write(&quot;hello &quot;); // respond with message of 6 bytes&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="4131" LastEditDate="2015-09-28T13:59:38.687" LastActivityDate="2015-09-28T13:59:38.687" Title="Conflict between OneWire and I2C?" Tags="|i2c|1-wire|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11738" PostTypeId="1" CreationDate="2015-05-11T22:20:47.150" Score="1" ViewCount="321" Body="&lt;p&gt;This is the first code I wrote for my UNO R3 just to feel out the functions and I've already got some jankiness. Throughout this description I am referring to the &lt;strong&gt;first two if statements&lt;/strong&gt; one inside the other one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to increment &lt;code&gt;i&lt;/code&gt; every time the signal is activated and then &lt;code&gt;j&lt;/code&gt; is used to create a small space of time where the button being pressed will not increment &lt;code&gt;i&lt;/code&gt;. My problem is my if statement involving &lt;code&gt;j&lt;/code&gt; seem to be totally ignored. I've tried multiple configurations of the if statement structure to no avail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is where things get interesting. So upon setting up the serial connection back to my PC to debug this irritating problem and printing out the actual value of &lt;code&gt;j&lt;/code&gt; (to see why it was triggering my if statement prematurely) it magically fixed the problem. It's like until the program literally acknowledges &lt;code&gt;j&lt;/code&gt;'s value in the print statement it doesn't exist but if it does it works. Any ideas on this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the serial monitor in both picture depicts consecutive iterations with the signal activated the entire time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This picture shows the serial monitor after running with the button pressed but the print statement commented out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/adizC.jpg&quot; alt=&quot;This picture shows the serial monitor after running with the button pressed but the print statement commented out&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This picture shows the serial monitor at a space where the button was pressed and held (same time frame as image 1) but in this one it increments &lt;code&gt;i&lt;/code&gt; to 3 and then continues incrementing &lt;code&gt;j&lt;/code&gt;. How is this happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KcVYF.jpg&quot; alt=&quot;This picture shows the serial monitor at a space where the button was pressed and held(same time frame as img 1) but in this one it incremements i to 3 and then continues incrementing j. How is this happening?&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9995" LastEditorUserId="10794" LastEditDate="2015-07-19T05:10:41.377" LastActivityDate="2015-07-19T05:10:41.377" Title="Arduino UNO code ignores variables selectively" Tags="|arduino-uno|programming|c|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11739" PostTypeId="2" ParentId="11738" CreationDate="2015-05-11T22:55:56.543" Score="1" Body="&lt;p&gt;Its hard to see you code, but I think I can make a pretty good guess from your description what is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that you are using the time it takes to increment a value as a way to slow down your code. I think you are underestimating the speed of the arduino. The time it takes to count to 200 (if I'm reading your pictures right) is almost instant; However, you then start printing to with serial each time. Once the serial buffer is full, &lt;code&gt;Serial.print()&lt;/code&gt; will wait until there is room in the buffer to place the new value. This time is still small, but making the code wait for it to pass 200 times will take much longer than just waiting for a number to increment to 200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that having added a print statement is slowing down the code enough that your increment based delay is having a noticable effect. What you should do is use the &lt;a href=&quot;http://www.arduino.cc/en/Reference/Delay&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;void delay(unsigned long milliseconds);&lt;/code&gt;&lt;/a&gt; function to cause the code to stop for a bit after it first detects the button has been pressed, and then see if its still pressed afterward. You can also use &lt;a href=&quot;http://www.arduino.cc/en/Reference/delayMicroseconds&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;delayMicroseconds(unsigned int)&lt;/code&gt;&lt;/a&gt; for shorter but more precise timing. Or better yet, use the &lt;a href=&quot;http://www.arduino.cc/en/Reference/Millis&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;unsigned long millis();&lt;/code&gt;&lt;/a&gt; function to grab and store the time when the button was activated, and continue polling the current time until the desired delay has been acheived. That way is more code, It allows the code to do something productive while it waits or keep looping.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-05-11T22:55:56.543" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11740" PostTypeId="2" ParentId="1045" CreationDate="2015-05-12T00:09:57.370" Score="0" Body="&lt;p&gt;Totally insane thought here but.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried writing a chrome App to talk to your Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did it on the Mac - had chrome monitoring things happening on the network and sending Serial Commands to the Arduino over USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find samples in the Chrome samples / docs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/apps/serial&quot; rel=&quot;nofollow&quot;&gt;https://developer.chrome.com/apps/serial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9996" LastActivityDate="2015-05-12T00:09:57.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11741" PostTypeId="2" ParentId="11734" CreationDate="2015-05-12T01:59:20.720" Score="1" Body="&lt;p&gt;You could look into the &lt;a href=&quot;http://airspayce.com/mikem/arduino/RadioHead/&quot; rel=&quot;nofollow&quot;&gt;RadioHead&lt;/a&gt; library - there might be a port for RPi, though I couldn't find one with a (very) quick google. This library works well, I use it actually with RFM69H 433 MHz radios (from Moteinos), a little more expensive than the simple 433 kits, but also supports encryption which might be important down the line. If you can't find a good library for RPi one solution could be to have a second Arduino acting as a receiver and sending data serially to RPi. This is what I use with a regular desktop PC which is my home server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found a discussion about connecting a RFM69 to the RPi &lt;a href=&quot;http://homeautomation.proboards.com/thread/7/raspberry-rfm69-sensor-node-gateway&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; which might give you more information about the process in general, even if you won't use the same radio.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-12T01:59:20.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11742" PostTypeId="2" ParentId="11730" CreationDate="2015-05-12T02:06:43.560" Score="1" Body="&lt;p&gt;You can break down testing in steps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call your PHP page from the browser with some dummy parameters and see if it saves them in the DB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that part works use a network sniffer, like WireShark to sniff the TCP connection and make sure the correct data is sent to the PHP server from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on which part is not working you can ask the question in the appropriate stack exchange.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-12T02:06:43.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11743" PostTypeId="1" AcceptedAnswerId="11744" CreationDate="2015-05-10T23:13:20.470" Score="0" ViewCount="678" Body="&lt;p&gt;The Arduino due exclusively runs on 3.3V, so I am wondering if this can be used as a USB to serial converter just like the Arduino Uno could, or do you need to do level shifting?? Will I ruin the board if I just hook up RX and TX to a 5v device?&lt;/p&gt;&#xA;" OwnerUserId="8633" OwnerDisplayName="John August" LastActivityDate="2015-05-12T04:05:31.120" Title="Can the Arduino Due be used as a serial to USB converter?" Tags="|usb|serial|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11744" PostTypeId="2" ParentId="11743" CreationDate="2015-05-10T23:26:18.673" Score="1" Body="&lt;p&gt;Yes it will work as a USB to serial device, however the serial will be at 3.3V not 5V. It'll still be serial though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For it to send data to a 5V device, depending on the device, it might work.  3.3V is often around the &quot;high&quot; threshold for an input pin on a 5V device, but check the datasheet for the 5V device to be sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For receiving data the 5V will be above the 3.3V supply voltage of the main SAM3X chip, so should be avoided. As with most Atmel datasheets, actually finding the information you want is almost impossible, and I haven't found if there is a maximum &quot;over voltage input current&quot; or not, so to be on the safe side a full level shifting voltage divider should be used on the RX pin.&lt;/p&gt;&#xA;" OwnerUserId="4143" OwnerDisplayName="Majenko" LastActivityDate="2015-05-10T23:26:18.673" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11745" PostTypeId="2" ParentId="11730" CreationDate="2015-05-12T04:32:41.370" Score="1" Body="&lt;p&gt;You have one problem in the construction of your HTTP GET request on Arduino side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        // Make a HTTP request:&#xA;        client.print( &quot;GET /add_data.php?&quot;);&#xA;        client.print(&quot;temperature=&quot;);&#xA;        client.print( temperature);&#xA;        client.print(&quot;humidity=&quot;);&#xA;        client.print( humidity);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You forgot to separate both request arguments with an ampersand. It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        // Make a HTTP request:&#xA;        client.print( &quot;GET /add_data.php?&quot;);&#xA;        client.print(&quot;temperature=&quot;);&#xA;        client.print( temperature);&#xA;        client.print(&quot;&amp;amp;humidity=&quot;);&#xA;        client.print( humidity);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;&quot;&amp;amp;humidity&quot;&lt;/code&gt; instead of just &lt;code&gt;&quot;humidity&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2015-05-12T04:32:41.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11748" PostTypeId="1" CreationDate="2015-05-12T06:30:59.477" Score="2" ViewCount="1562" Body="&lt;p&gt;I recently bought an XBee shield (&lt;a href=&quot;http://www.ebay.com/itm/New-For-Arduino-ZigBee-XBee-Bluetooth-Bee-V03-Shield-Module-Wireless-Control-Hot/301457628487?_trksid=p2047675.c100005.m1851&amp;amp;_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D30543%26meid%3D6648f5c1a8f54e9e92e799f4092616ce%26pid%3D100005%26rk%3D3%26rkt%3D6%26sd%3D221568487830&amp;amp;rt=nc&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;). The shield has a switch that seems to switch between USB/XBee. However, there is no USB port. What exactly is the switch supposed to do?&lt;/p&gt;&#xA;" OwnerUserId="9865" LastActivityDate="2021-06-24T00:10:29.327" Title="What is the function of the XBee / USB switch on an XBee shield?" Tags="|serial|xbee|usb|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11749" PostTypeId="1" CreationDate="2015-05-12T08:03:15.663" Score="9" ViewCount="2624" Body="&lt;p&gt;I wonder why Arduino doesn't run at 20 MHz, the frequency the AVR is specified for. Now, running at 16 MHz, we're wasting 20% performance for nothing.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there are &lt;em&gt;any&lt;/em&gt; implications when you replace the 16 MHz resonator with a 20 MHz type, with probably the sole exception for the baudrate in the bootloader. Or is there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know why the Arduino designers chose 16 MHz?&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2016-02-04T21:31:53.203" Title="Arduino at 20 MHz?" Tags="|oscillator-clock|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11750" PostTypeId="2" ParentId="11734" CreationDate="2015-05-12T08:15:54.043" Score="1" Body="&lt;p&gt;There is custom made library to solve this issue &lt;a href=&quot;https://github.com/maditnerd/433wirelessPI&quot; rel=&quot;nofollow&quot; &gt; here&lt;/a&gt; and i recomend you read &lt;a href=&quot;https://www.raspberrypi.org/forums/viewtopic.php?f=37&amp;amp;t=24215&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; discussion.&lt;/p&gt;&#xA;" OwnerDisplayName="user8688" LastActivityDate="2015-05-12T08:15:54.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11751" PostTypeId="2" ParentId="11749" CreationDate="2015-05-12T09:02:14.570" Score="6" Body="&lt;p&gt;There's no hardware reason (as far as I'm aware) that you couldn't run a suitable Arduino at 20 MHz. You'd run into minor timing inaccuracies in software though, as the standard Arduino configuration apparently works best if the clock speed is either 8 or 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect this is largely for historical reasons. Early Arduino boards were based on chips which only went up to 16 MHz, such as the &lt;code&gt;ATmega8&lt;/code&gt;. Using the same configuration for all chips just keeps everything a bit simpler and more consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is more information here about the timing issues: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=158223.0#msg_1186708&quot; rel=&quot;noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=158223.0#msg_1186708&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-05-12T12:03:09.923" LastActivityDate="2015-05-12T12:03:09.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11752" PostTypeId="2" ParentId="11748" CreationDate="2015-05-12T09:27:01.887" Score="1" Body="&lt;p&gt;Better to check connection with tester. I think it switches connection to bluetooth module directly to your PC (with usb serial converter which is on arduino board)  or with arduino microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="10006" LastActivityDate="2015-05-12T09:27:01.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11753" PostTypeId="2" ParentId="11734" CreationDate="2015-05-12T09:30:39.750" Score="0" Body="&lt;p&gt;Presuming you want to get results quickly, I recommend you have a look at &lt;a href=&quot;http://openhab.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;openHab&lt;/a&gt; This is a Java based home automation framework and server that has plugins for many existing protocols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get your protocol running it is just a matter of plugging it into openHab for charting and storage. I use for inside home measurements:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/5SM7e.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;http://www.princetronics.com/how-to-read-433-mhz-codes-w-raspberry-pi-433-mhz-receiver/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; will help you further with connect 433 to RasPi and Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically for temp and humidity sensors there is the reverse engineered Cresta protocol, that is also used in a lot of commercial sensors. See &lt;a href=&quot;https://github.com/mysensors/Arduino/tree/master/libraries/RemoteSensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Github repo&lt;/a&gt; for Arduino code. Also findable for Raspberry Pi.&lt;/p&gt;&#xA;" OwnerUserId="7255" LastActivityDate="2015-05-12T09:30:39.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11754" PostTypeId="1" AcceptedAnswerId="11795" CreationDate="2015-05-12T09:31:45.340" Score="2" ViewCount="3235" Body="&lt;p&gt;How can I write lightweight cross correlation code for arduino? I couldnt find any solution. The measurement system contains an ultrasonic sensor and a servo  that turns from 45 to 135 degree and measures distance from 4-300 cm. Than i collect data in an array which contains distances with respect to angle. System makes several measurement like this and program finds cross correlation between new and old arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/How-To-Make-an-Obstacle-Avoiding-Arduino-Robot/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-To-Make-an-Obstacle-Avoiding-Arduino-Robot/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2015-05-12T15:25:06.960" LastActivityDate="2021-05-30T20:29:52.630" Title="Arduino Cross Correlation?" Tags="|analogread|signal-processing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11755" PostTypeId="2" ParentId="8559" CreationDate="2015-05-12T10:20:11.167" Score="5" Body="&lt;p&gt;I have found that this is a common issue across my development machines, however using Visual Micro for Visual Studio reduces this time by a significant factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I primarily use it for other Visual Studio features like Intellisense, refactoring, and solution management. Visual Micro has some compelling features of its own, like debugging tools, however I haven't used them.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;noreferrer&quot;&gt;Visual Micro&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx&quot; rel=&quot;noreferrer&quot;&gt;Visual Studio Community Edition&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I haven't personally tried, but I would expect that you can avoid the rebuild using the project/solution options in Visual Studio - I found that the compile time is fast enough in most cases with this environment for it to not matter.&lt;/p&gt;&#xA;" OwnerUserId="10007" LastActivityDate="2015-05-12T10:20:11.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11756" PostTypeId="2" ParentId="4540" CreationDate="2015-05-12T10:49:54.590" Score="1" Body="&lt;p&gt;You may have more luck investigating standard C ways of dealing with this issue, instead of the common C++ methods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although it is typically not advised, you can use malloc and free on the Arduino. This allows you to dynamically use memory. I would provide a more detailed code example than below but when using dynamic memory it can be hard to troubleshoot what is going on without the use of a library to simplify the process. I would strongly advise doing a little study and understanding both dynamic memory management, and the repercussions of doing so on the Arduino platform. A solid foundation in this will pay off tenfold in time saved when debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you should check each time that you call malloc that it is successful&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These resources might help:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://forum.codecall.net/topic/51010-dynamic-arrays-using-malloc-and-realloc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dynamic Arrays&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/5607455/checking-that-malloc-succeeded-in-c&quot;&gt;Check Malloc Succeded&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=37796.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Malloc and Free on Arduino Discussion&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino&quot;&gt;Is it a bad idea?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Simple Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Make a pointer to your array&#xA;someType *A;&#xA;&#xA;// The size of your array, may be changed programmatically.&#xA;int arraySize = 5;&#xA;&#xA;// Reserve memory for your array.&#xA;A = malloc(arraySize * sizeof(someType));&#xA;&#xA;// Use Array&#xA;A[0] = someData;&#xA;&#xA;// Release A's memory when complete.&#xA;free(A);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10007" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-05-12T10:49:54.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11757" PostTypeId="1" CreationDate="2015-05-12T14:06:10.003" Score="0" ViewCount="261" Body="&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int trigPin = 4;&#xA;const int echoPin = 2;&#xA;const int trigPin2 = 6;&#xA;int incomingByte;&#xA;int val, val2;&#xA;const int echoPin2 = 7;&#xA;&#xA;void setup() {&#xA;  // initialize serial communication:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  pinMode(trigPin, OUTPUT);&#xA;  digitalWrite(trigPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  pinMode(trigPin2, OUTPUT);&#xA;  digitalWrite(trigPin2, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin2, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trigPin2, LOW);&#xA;&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(echoPin2, INPUT);&#xA;&#xA;  val = digitalRead(echoPin);&#xA;  val2 = digitalRead(echoPin2);&#xA;&#xA;  if (val &amp;amp;&amp;amp; val2 == HIGH) {&#xA;    Serial.println(&quot;Elephant on tracks&quot;);&#xA;  }&#xA;&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {  // if the data came&#xA;    incomingByte = Serial.read();&#xA;  }&#xA;  // read byte&#xA;  if(incomingByte == '0') {&#xA;     digitalWrite(trigPin, LOW);  &#xA;     digitalWrite(trigPin2, LOW);&#xA;     Serial.println(&quot;The system is OFF.&quot;);  // print message&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anyhow, I click upload, and as the title of this question says, have to wait forever.&#xA;Not only this code, nothing gets uploaded. It was working just fine a week ago.&#xA;I run a Windows 7 64-bit system, and have an Arduino Uno R3. &#xA;Does anyone have any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="8577" LastEditorUserId="4143" LastEditDate="2015-05-12T16:06:13.700" LastActivityDate="2015-12-20T17:44:16.957" Title="Uploading... forever" Tags="|arduino-uno|uploading|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11759" PostTypeId="2" ParentId="11748" CreationDate="2015-05-12T15:28:09.860" Score="1" Body="&lt;p&gt;I imagine that the switch has the same functionality as the &quot;serial select&quot; switch on the official Arduino Wireless Shield for XBee modules. Therefore the explanations on the switch settings given there (&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoWirelessShield&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoWirelessShield&lt;/a&gt;) probably apply also to your board.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastEditorUserId="1612" LastEditDate="2015-05-14T09:21:10.023" LastActivityDate="2015-05-14T09:21:10.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11760" PostTypeId="2" ParentId="9961" CreationDate="2015-05-12T16:22:41.947" Score="1" Body="&lt;p&gt;For a chip like the basic Arduino's ATmega, you don't really &quot;turn it off&quot; to save power, rather you put it into a low-power sleep mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, make sure you aren't consuming more power than needed normally.  Make sure unused peripherals like the ADC are off.  If your program spends most of its time waiting for external events, try reducing the clock speed either with a slower crystal or the 8 MHz oscillator, and with the clock prescale register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, implement a sleep cycle.  Turn off everything you can, and program a hardware timer to generate an interrupt at some point in the future.  Enter sleep mode, so the processor stops and only the logic in the counter is still running.  When the interrupt fires, the ATmega CPU will wake up and continue operating, at which point you enable the ADC, use a GPIO to drive your light sensor, and take a reading from it.  If it doesn't meet your conditions, turn it all off again and go back to sleep until it's worth checking again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In low power design you must be very careful of things outside the processor stealing power.  Watch out for any resistors pulling signals, if the signals are actively drive against the resistor.  LEDs are an obvious issue.  Also watch out for voltage regulators which may have high quiescent current.  And finally beware of peripheral chips - a stock Arduino has an entire second processor sitting there in the USB-serial adapter wasting power.  So you will either need to customize the firmware of that to shut down too, or else use a simpler board that doesn't have one (don't just hold it in hardware reset, as the reset pin has an internal pullup which will then consume power).&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-12T16:22:41.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11761" PostTypeId="1" CreationDate="2015-05-12T16:48:49.210" Score="0" ViewCount="330" Body="&lt;p&gt;I bought a ethernet shield for my Arduino Uno. I plug it my Arduino and PC with ethernet cable. There is all led is working on ethernet shield. But when i try to examples about ethernet which is in Arduino IDE as &quot;DHCPChatServer&quot; example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I hope to see;&#xA;&quot;Trying to get an IP address using DHCP&quot;&#xA;&quot;My IP address: 192.168.1.177&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But I just see &quot;Trying to get an IP address using DHCP&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any problem with my ethernet shield?&lt;/p&gt;&#xA;" OwnerUserId="8761" LastEditorUserId="8761" LastEditDate="2015-05-12T21:20:29.423" LastActivityDate="2015-11-13T05:33:39.563" Title="arduino ethernet shield" Tags="|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11762" PostTypeId="1" AcceptedAnswerId="11770" CreationDate="2015-05-12T17:00:07.477" Score="1" ViewCount="9198" Body="&lt;p&gt;I'm interested in writing a C program &lt;em&gt;without&lt;/em&gt; the Arduino IDE and related libraries and am trying to figure out how I can access the GPIO pins for read and write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;assumption&lt;/em&gt; is that the GPIO pins are - at the hardware layer - just memory addresses, and so if I know what their address is I can send/receive data to and from them.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For writing to the digital pins, do I just send an &lt;code&gt;int&lt;/code&gt; with a value of &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; to the pin's address? If so, what might that code look like? Can I then assume I could poll that address for a value, which would be either &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Can I assume the same for analog pins, but instead of binary values, I'd get an integral value between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1023&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And if I'm way off here, and pins are &lt;em&gt;not&lt;/em&gt; accessed via memory addresses, then how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, the solution I'm looking for wouldn't involve Arduino software, just the Arduino hardware (an AVR or ARM MCU). Bonus points for C pseudo-code examples! Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-13T01:46:12.820" Title="Reading/writing to Arduino GPIO pins from raw C code" Tags="|pins|c|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11763" PostTypeId="1" AcceptedAnswerId="11777" CreationDate="2015-05-12T17:09:17.823" Score="1" ViewCount="1556" Body="&lt;p&gt;I'm not too familiar with the Arduino C++ language, but I would like to get this native code to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In curl this works:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;curl &quot;&lt;a href=&quot;http://access.alchemyapi.com/calls/text/TextGetTextSentiment?text=i+feel+great&amp;amp;outputMode=json&amp;amp;apikey=my-apikey&quot; rel=&quot;nofollow&quot;&gt;http://access.alchemyapi.com/calls/text/TextGetTextSentiment?text=i+feel+great&amp;amp;outputMode=json&amp;amp;apikey=my-apikey&lt;/a&gt;&quot;^C&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I am trying to use a WiFi client for the same request but it seems the passing and parsing of the URL parameters is causing a problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(request,&quot;/calls/text/TextGetTextSentiment?apikey=%s&amp;amp;text=%s&amp;amp;outputMode=%s&quot;,&quot;31adba6dfc3a879b88762f50efc9f892bd573207&quot;, &quot;i+feel+great&quot;, &quot;json&quot;);&#xA;Serial.println(request);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I print the request, everything after the &amp;amp; gets truncated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  char serverName[] = &quot;access.alchemyapi.com&quot;;&#xA;  if(client.connect(serverName,port) == 1)&#xA;  {&#xA;    sprintf(outBuf,&quot;GET %s HTTP/1.1&quot;,page);&#xA;    client.println(outBuf);&#xA;    sprintf(outBuf,&quot;Host: %s&quot;,serverName);&#xA;    client.println(outBuf);&#xA;    client.println(F(&quot;Connection: close\r\n&quot;));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works (HTTP status 200, though with missing parameters error from the API service) if I only pass in 1 parameter. &lt;/p&gt;&#xA;" OwnerUserId="10013" LastEditorUserId="84" LastEditDate="2015-05-12T19:11:30.577" LastActivityDate="2015-07-12T00:25:07.060" Title="Wifi REST API GET call - how to concatenate and pass URL parameters?" Tags="|wifi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11764" PostTypeId="1" CreationDate="2015-05-12T17:13:13.917" Score="3" ViewCount="908" Body="&lt;p&gt;I am using an HC-05 bluetooth Module. How can I stop someone from pairing with my device by brute forcing the key? Failing that, and if someone does pair with my device, is there a way to authenticate the user? I was thinking of salted hash with a shared secret key. Is there anything better?&lt;/p&gt;&#xA;" OwnerUserId="9865" LastEditorDisplayName="user6569" LastEditDate="2015-07-10T00:02:12.577" LastActivityDate="2021-01-31T14:57:22.927" Title="How can I stop someone from hacking in to my Arduino via Bluetooth?" Tags="|bluetooth|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11765" PostTypeId="1" CreationDate="2015-05-12T14:39:19.183" Score="0" ViewCount="101" Body="&lt;p&gt;I created a quite simple Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorValue = analogRead(A0);&#xA;  Serial.println(sensorValue);  &#xA;&#xA;  float voltage = sensorValue * (5 / 1023.0); &#xA;  Serial.println(voltage);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the following circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NT6sS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My multimeter measures &lt;strong&gt;3.31 V&lt;/strong&gt;, between the pin 3V3 and GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get a &lt;em&gt;sensorValue&lt;/em&gt; of &lt;strong&gt;730&lt;/strong&gt; and a calculated &lt;em&gt;voltage&lt;/em&gt; of &lt;strong&gt;3.57 V&lt;/strong&gt;. This is 8% higher that 3.3V. What is the tolerance by the AD-converter?&lt;/p&gt;&#xA;" OwnerUserId="10025" OwnerDisplayName="Dennis" LastEditorUserId="10794" LastEditDate="2015-09-12T00:51:27.170" LastActivityDate="2015-09-12T00:51:27.170" Title="Arduino AD-converter tolerance" Tags="|c++|analogread|hardware|analog-sampling|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11766" PostTypeId="2" ParentId="11765" CreationDate="2015-05-12T15:30:00.080" Score="1" Body="&lt;p&gt;The absolute accuracy of the ADC in the ATmega328P when its clock is within its optimal range is given &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;in the datasheet&lt;/a&gt; as 2LSB. This means that the actual value could be anywhere between 728 and 732.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course this depends on the accuracy of V&lt;sub&gt;CC&lt;/sub&gt;, since it is being used as the ADC reference. This is why supply voltage measurements should be performed &lt;a href=&quot;https://arduino.stackexchange.com/questions/1794/arduino-adc-reference-voltage-if-it-is-battery-powered&quot;&gt;using the internal bandgap voltage&lt;/a&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-05-12T15:44:50.377" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11767" PostTypeId="2" ParentId="10013" CreationDate="2015-05-12T17:40:07.757" Score="0" Body="&lt;p&gt;You can achieve almost what you are describing with the &lt;code&gt;setjmp()&lt;/code&gt; and&#xA;&lt;code&gt;longjmp()&lt;/code&gt; functions. Here is an example, using INT0 to interrupt a&#xA;function calling &lt;code&gt;delay()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Test non local return from ISR:&#xA; *   - wire a pushbutton between digital 2 and GND&#xA; *   - monitor the serial port at 9600/8N1&#xA; *   - pressing the button should skip &quot;func() ending&quot; and immediately&#xA; *     write &quot;func() returned&quot;&#xA; */&#xA;&#xA;#include &amp;lt;setjmp.h&amp;gt;&#xA;&#xA;jmp_buf saved_context;&#xA;&#xA;/*&#xA; * ISR triggered by low level of INT0 = PD2 = Arduino digital 2.&#xA; * Should only be allowed to trigger while inside loop().&#xA; */&#xA;ISR(INT0_vect) {&#xA;    EIMSK &amp;amp;= ~_BV(INT0);        // disable further interrupts&#xA;    longjmp(saved_context, 1);  // return to loop()&#xA;}&#xA;&#xA;void func() {&#xA;    Serial.println(&quot;  func() beginning&quot;);&#xA;    EIMSK |= _BV(INT0);   // enable INT0 interrupt&#xA;    delay(3e3);           // wait 3 s for an interrupt&#xA;    EIMSK &amp;amp;= ~_BV(INT0);  // disable INT0 interrupt&#xA;    Serial.println(&quot;  func() ending&quot;);&#xA;}&#xA;&#xA;void setup() {&#xA;    pinMode(2, INPUT_PULLUP);  // pin 2 is INT0&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;Calling func()&quot;);&#xA;    if (setjmp(saved_context) == 0) func();&#xA;    Serial.println(&quot;func() returned&quot;);&#xA;    Serial.println();&#xA;    delay(2e3);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-12T17:40:07.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11768" PostTypeId="2" ParentId="9998" CreationDate="2015-05-12T18:08:10.910" Score="0" Body="&lt;p&gt;Check the device that the IDE says you're connected to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=51489.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=51489.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10014" LastActivityDate="2015-05-12T18:08:10.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11769" PostTypeId="1" AcceptedAnswerId="14420" CreationDate="2015-05-12T18:14:50.223" Score="1" ViewCount="493" Body="&lt;p&gt;I am playing around with the Sparkfun Venus GPS.  I followed &lt;a href=&quot;http://www.doctormonk.com/2012/05/sparkfun-venus-gps-and-arduino.html&quot; rel=&quot;nofollow&quot; title=&quot;this&quot;&gt;this&lt;/a&gt; tutorial to get started.  In here the author states that you should &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Upload the following sketch to your Arduino BEFORE making any&#xA;  connections. 5V from an IO pin left high on the Arduino may well kill&#xA;  the 3.3V output from the Tx pin on the GPS module.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, I am using the Sparkfun bi-directional logic level converter in between the Arduino and the Venus GPS (because I'm using the 5V Arduino GSM shield stacked on top of the Arduino).  In that case, would the above statement still apply?&lt;/p&gt;&#xA;" OwnerUserId="8700" LastActivityDate="2015-08-26T04:34:11.290" Title="Venus GPS + Arduino. Kill 3.3V TX during sketch upload" Tags="|gsm|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11770" PostTypeId="2" ParentId="11762" CreationDate="2015-05-12T18:27:33.127" Score="3" Body="&lt;p&gt;In theses cases you are right, using register address is the way to read/write data from/to digital pins.&#xA;In the case you use analog input, the process is similar but you have to follow some procedures before getting the value of the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://techawarey.wordpress.com/2013/12/28/avr-gpio-tutorial/&quot; rel=&quot;nofollow&quot;&gt;GPIO REGISTERS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For AVR micro-controllers these registers are:&#xA;DDRn – Data Direction Register&#xA;PORTn – Port Output data Register&#xA;PINn – Port Input Register&#xA;n- Indicates the port name i.e. A, B, C &amp;amp; D&#xA;If you have arduino board and want to use these pins, look for mapping pictures about arduino and avr pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is an example from the Arduino website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DDRD is the direction register for Port D (Arduino digital pins 0-7). The bits in this register control whether the pins in PORTD are configured as inputs or outputs so, for example:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRD = B11111110; // sets Arduino pins 1 to 7 as outputs, pin 0 as input&#xA;DDRD = DDRD | B11111100; // this is safer as it sets pins 2 to 7 as outputs&#xA;                         // without changing the value of pins 0 &amp;amp; 1, which are RX &amp;amp; TX &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the bitwise operators reference pages and The Bitmath Tutorial in the Playground&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PORTD is the register for the state of the outputs. For example;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PORTD = B10101000; // sets digital pins 7,5,3 HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will only see 5 volts on these pins however if the pins have been set as outputs either by using the &lt;code&gt;DDRD&lt;/code&gt; register directly or by using the  &lt;code&gt;pinMode()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For analog read&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need to include the headers and start using the registers. They hold the equivalent hexadecimal values for your microcontroller. And the procedure is described in the datasheet. All you have to do is to translate it to code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// this code scans ADC1 for an analog signal upon request, using 8Mhz processor clock&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;stdint.h&amp;gt;       // needed for uint8_t&#xA;&#xA;int ADCsingleREAD(uint8_t adctouse)&#xA;{&#xA;    int ADCval;&#xA;&#xA;    ADMUX = adctouse;        // use #1 ADC&#xA;    ADMUX |= (1 &amp;lt;&amp;lt; REFS0);   // use AVcc as the reference&#xA;    ADMUX &amp;amp;= ~(1 &amp;lt;&amp;lt; ADLAR);  // clear for 10 bit resolution&#xA;&#xA;    // 128 prescale for 8Mhz&#xA;    ADCSRA |= (1 &amp;lt;&amp;lt; ADPS2) | (1 &amp;lt;&amp;lt; ADPS1) | (1 &amp;lt;&amp;lt; ADPS0);&#xA;&#xA;    ADCSRA |= (1 &amp;lt;&amp;lt; ADEN);    // Enable the ADC&#xA;    ADCSRA |= (1 &amp;lt;&amp;lt; ADSC);    // Start the ADC conversion&#xA;&#xA;    while(ADCSRA &amp;amp; (1 &amp;lt;&amp;lt; ADSC)); // waits for the ADC to finish&#xA;&#xA;    ADCval = ADCL;&#xA;    ADCval = (ADCH &amp;lt;&amp;lt; 8) + ADCval; // ADCH is read so ADC can be updated again&#xA;&#xA;    return ADCval;&#xA;}&#xA;   &#xA;&#xA;int main(void)&#xA;{&#xA;    int ADCvalue;&#xA;&#xA;    while (1)&#xA;    {&#xA;        ADCvalue = ADCsingleREAD(1);&#xA;        // ADCvalue now contains an 10bit ADC read&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information about analog read, see &lt;a href=&quot;https://sites.google.com/site/qeewiki/books/avr-guide/analog-input&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="220" LastEditDate="2015-05-13T01:46:12.820" LastActivityDate="2015-05-13T01:46:12.820" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11771" PostTypeId="2" ParentId="9846" CreationDate="2015-05-12T19:21:17.893" Score="1" Body="&lt;p&gt;You can use XBees. They are powerful and do provide wifi connections (the recent versions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you rely on well-designed devices which guarantee packet retransmission and they achieve up to 1km in an open field. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;XBee still works with serial communications making them an excellent tool for your embedded project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just plug your Arduinos and write code to send/receive data. This &lt;a href=&quot;https://code.google.com/p/xbee-arduino/&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; is a good start point for API mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind using all the benefits from ZigBee protocol, just use AT mode where all you push in one side is sent to another via serial communication. &lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-12T19:21:17.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11773" PostTypeId="1" AcceptedAnswerId="11780" CreationDate="2015-05-12T20:30:21.020" Score="1" ViewCount="724" Body="&lt;p&gt;I need vibration sensor for my project. I have found many sensors similar to &lt;a href=&quot;https://www.sparkfun.com/products/9196&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. But it seems, that this sensor outputs only zeros for &quot;non-hit&quot; state and ones for &quot;hit state&quot;. And I need something that can output levels of vibration, not only presence/abscense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any high-resolution vibration sensor for arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="10016" LastActivityDate="2016-11-11T02:43:24.447" Title="Vibration sensor for arduino" Tags="|sensors|" AnswerCount="2" CommentCount="4" ClosedDate="2016-10-28T19:42:24.673" ContentLicense="CC BY-SA 3.0" />
  <row Id="11774" PostTypeId="2" ParentId="9961" CreationDate="2015-05-12T20:39:30.680" Score="0" Body="&lt;p&gt;You may keep your Arduino powered, but have it sleep when the lights are&#xA;off. During sleep, it would periodically awake to check the light level:&#xA;if it's low enough, it goes back to sleep, otherwise it resumes its&#xA;work. Here are the detailed steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try to find a power-efficient Arduino or clone (no ON LED, no USB&#xA;bridge...) or learn how to build and program a barebones one. If you&#xA;can live with a 8&amp;nbsp;MHz clock, a bare ATmega, or even ATtiny, may&#xA;be a good option.&lt;/li&gt;&#xA;&lt;li&gt;Get an LDR (light-dependent resistor) and an ohmmeter.&lt;/li&gt;&#xA;&lt;li&gt;Measure the resistance of the LDR at the relevant light levels, and&#xA;decide for a value of resistance that will serve as a threshold for&#xA;switching on and off. I will call this &lt;code&gt;LDR_THRESHOLD_RES&lt;/code&gt; in the&#xA;code.&lt;/li&gt;&#xA;&lt;li&gt;Get a plain resistor with a value close to the previous threshold&#xA;(within a factor 10 should be OK), but not lower than 1&amp;nbsp;kΩ.&#xA;This will be your &quot;pullup&quot; resistor, and its resistance will be&#xA;&lt;code&gt;LDR_PULLUP_RES&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Decide how often the program will check for the lights being turned&#xA;on. This delay, in milliseconds, will be &lt;code&gt;LDR_CHECK_DELAY&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Assign both a digital and an analog pin for measuring the LDR. These&#xA;will be &lt;code&gt;LDR_DRIVE_PIN&lt;/code&gt; and &lt;code&gt;LDR_SENSE_PIN&lt;/code&gt; respectively.&lt;/li&gt;&#xA;&lt;li&gt;Connect the LDR between &lt;code&gt;LDR_SENSE_PIN&lt;/code&gt; and ground; connect the&#xA;pullup resistor between &lt;code&gt;LDR_SENSE_PIN&lt;/code&gt; and &lt;code&gt;LDR_DRIVE_PIN&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Update the code below (the first 5 #defines) and include it in your&#xA;sketch.&lt;/li&gt;&#xA;&lt;li&gt;Add &lt;code&gt;pinMode(LDR_DRIVE_PIN, OUTPUT);&lt;/code&gt; to your &lt;code&gt;setup()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Call &lt;code&gt;wait_for_lights()&lt;/code&gt; inside &lt;code&gt;loop()&lt;/code&gt;, wherever you want your&#xA;program to pause if the lights are off.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;#define LDR_THRESHOLD_RES 25e3  // 25 kOhm&#xA;#define LDR_PULLUP_RES    10e3  // 10 kOhm&#xA;#define LDR_CHECK_DELAY    200  // 200 ms&#xA;#define LDR_DRIVE_PIN        2  // digital 2&#xA;#define LDR_SENSE_PIN        0  // analog 0&#xA;&#xA;#define LDR_THRESHOLD_RATIO (1.0*LDR_PULLUP_RES/LDR_THRESHOLD_RES)&#xA;#define LDR_THRESHOLD_READING ((int)(1024 / (1 + LDR_THRESHOLD_RATIO)))&#xA;&#xA;/* Sleep until the light is on. */&#xA;void wait_for_lights() {&#xA;    for (;;) {&#xA;        // Sense light level.&#xA;        digitalWrite(LDR_DRIVE_PIN, HIGH);&#xA;        int reading = analogRead(LDR_SENSE_PIN);&#xA;        digitalWrite(LDR_DRIVE_PIN, LOW);&#xA;&#xA;        // Low reading means the light is on.&#xA;        if (reading &amp;lt; LDR_THRESHOLD_READING) return;&#xA;&#xA;        // Wait for a few milliseconds.&#xA;        unsigned long start = millis();&#xA;        do sleep_mode();&#xA;        while (millis() - start &amp;lt; LDR_CHECK_DELAY);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should already get your power consumption pretty low. If you want&#xA;to save further power, you will likely have to dig into your&#xA;microcontroller's datasheet. You can try the various &lt;code&gt;power_*_disable()&lt;/code&gt;&#xA;functions and turn off all the peripherals you do not need. You can also&#xA;try a deeper sleep mode than the default one (IDLE), but then your&#xA;&lt;code&gt;millis()&lt;/code&gt; clock will freeze during sleep, and you will have to set up&#xA;some wake up source if you do not want to sleep forever. The watchdog&#xA;timer is a good option.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-12T20:39:30.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11775" PostTypeId="1" AcceptedAnswerId="11776" CreationDate="2015-05-12T21:00:05.453" Score="0" ViewCount="221" Body="&lt;p&gt;I am experimenting with low-power wireless arduino modules. For that, I needed 3V powered arduino so that I can do away with voltage regulators which eat up a lot of battery juice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using 28 pin Atmega328p-PU dip IC with 8 MHz external crystal oscillator. Just for trying, I dumped the arduino pro mini 3.3V 8 MHz bootloader into it and it was a success. Everything is working as expected. However, I realized that SMD package which is being used in pro mini has 8 ADC pins compared to 6 in the DIP version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I be worried about it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second feasible option is modifying the Arduino UNO board definition to use 8 MHz clock source as compared to 16 MHz and leave everything else same. Do you think this will serve my purpose?&lt;/p&gt;&#xA;" OwnerUserId="7553" LastActivityDate="2015-05-12T21:26:57.307" Title="Custom Bootloader on Atmega328p - PU - 28 pin DIP" Tags="|arduino-uno|bootloader|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11776" PostTypeId="2" ParentId="11775" CreationDate="2015-05-12T21:26:57.307" Score="2" Body="&lt;p&gt;The Atmega328p has 8 analog inputs. Some packages (such as the DIP) don't have enough pins to bring all of them out, but they are in there. The SMD package brings all of them out, but it apparently the Pro Mini does not pick up two of them. The net result is the same - 6 useable and 2 unusable analog inputs.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-12T21:26:57.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11777" PostTypeId="2" ParentId="11763" CreationDate="2015-05-12T23:38:52.797" Score="0" Body="&lt;p&gt;Concatenating the string data in memory before sending it shouldn't be necessary. Instead, you should just be able to use &lt;code&gt;client.print()&lt;/code&gt; (or equivalent) to output each part of the request in sequence. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.print(&quot;GET &quot;);&#xA;client.print(page);&#xA;client.print(&quot; HTTP/1.1\r\n&quot;);&#xA;&#xA;client.print(&quot;Host: &quot;);&#xA;client.print(serverName);&#xA;client.print(&quot;\r\n&quot;);&#xA;&#xA;// etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should let you output any combination of HTTP headers you need.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-05-12T23:38:52.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11778" PostTypeId="1" CreationDate="2015-05-13T00:48:56.560" Score="2" ViewCount="2596" Body="&lt;p&gt;I have a device I'm working on and the only issue I'm running into is I can't manage to figure out how to get my LCD display to move around vertically with the joystick I have attached to it. I have a feeling with a tip this could be a very simple fix, but I'm just stuck. So the brief of this is that I need someone to fill in the ???'s for me provided in my example code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Include the LCD Library.&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;//Declare the LCD object and define pins.&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LCD.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;&#xA;#define SAD 10&#xA;#define RST 5&#xA;&#xA;&#xA;//Ignore The below line it is for the master code&#xA;#define I2C_ADDR    0x27 // &amp;lt;&amp;lt;----- Add your address here.  Find it from I2C Scanner&#xA;#define BACKLIGHT_PIN     3&#xA;#define En_pin  2&#xA;#define Rw_pin  1&#xA;#define Rs_pin  0&#xA;#define D4_pin  4&#xA;#define D5_pin  5&#xA;#define D6_pin  6&#xA;#define D7_pin  7&#xA;&#xA;int n = 1;&#xA;&#xA;LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;//Booting the LCD&#xA;  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);&#xA;  lcd.setBacklight(HIGH);&#xA;  lcd.home (); // go home&#xA;  lcd.cursor();&#xA;&#xA;//Starting settings&#xA;  lcd.begin(1,0);&#xA;  lcd.clear();&#xA;&#xA;}&#xA;&#xA;//Sometimes you have to hit reset on the device&#xA;&#xA;//Joystick Defaults X=484 Y=513&#xA;&#xA;void loop() {&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Example&quot;);&#xA;  delay(100);&#xA;&#xA;for (int positionCounter = 0; positionCounter = 1; positionCounter++) {&#xA;if(analogRead(1) &amp;gt; 584) {&#xA;  lcd.scrollDisplayLeft();&#xA;  delay(30);&#xA;  } else if(analogRead(1) &amp;lt; 384) {&#xA;    lcd.scrollDisplayRight();&#xA;    delay(30);&#xA;  } else if(analogRead(0) &amp;lt; 413) {&#xA;     lcd.???????????????????();&#xA;     delay(30);&#xA;  } else if(analogRead(0) &amp;gt; 613) {&#xA;     lcd.??????????????????();&#xA;     delay(30);     &#xA;    } &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10021" LastEditorDisplayName="user6430" LastEditDate="2015-07-16T10:17:45.130" LastActivityDate="2015-08-15T10:38:14.523" Title="How do I scroll through the LCD vertically with joystick?" Tags="|arduino-uno|programming|sensors|lcd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11779" PostTypeId="2" ParentId="4530" CreationDate="2015-05-13T00:52:01.490" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;the docs&lt;/a&gt;, SoftwareSerial doesn't support &lt;code&gt;.end()&lt;/code&gt;, so Gerben's answer won't work here, I think. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's hacky, but you could exploit the fact that only one SoftwareSerial can receive data at a time, and create a second one, activating it with &lt;code&gt;SoftwareSerial.listen()&lt;/code&gt;.  Then &lt;code&gt;.listen()&lt;/code&gt; again on your original SoftwareSerial, when you want to resume listening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you could do as Marty Grogan says, and flush the read buffer before starting a new read.  Again, I don't think SoftwareSerial supports a flush method as such, so you'd need to just &lt;code&gt;.read()&lt;/code&gt; until there's nothing &lt;code&gt;.available()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10020" LastEditorUserId="6936" LastEditDate="2016-03-04T13:30:27.327" LastActivityDate="2016-03-04T13:30:27.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11780" PostTypeId="2" ParentId="11773" CreationDate="2015-05-13T01:40:45.740" Score="0" Body="&lt;p&gt;I assume the OP wants the frequency of the vibration, which an accelerometer such as the ADXL345 won't give.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two workarounds: if the expected vibration frequency is low, say, under 100Hz, use instead an on/off vibration sensor (adafruit has them for under a dollar) and count the number of transitions. If it's more, how about a microphone and a band-pass filter? &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2015-05-13T01:40:45.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11781" PostTypeId="2" ParentId="11687" CreationDate="2015-05-13T01:50:23.237" Score="2" Body="&lt;p&gt;If it's the byte order that causes a problem that's likely compiler specific and I don't think one can change it. Even if it were possible, changing the global endianness might break libraries that depend on it, so you likely can't escape using a function to swap the variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know you only need one value at a time you could write something like the following code, with a global buffer (untested but in principle should work (and I know global variables are evil, but should work for an Arduino project)):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte buf[2];&#xA;&#xA;byte* reverse(int val) {&#xA;    buf[0] = (byte)(val &amp;gt;&amp;gt; 8);&#xA;    but[1] = (byte)val;&#xA;    return buf;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you could use it like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t ret = twi_writeTo(eeprom_i2c_addr, reverse(eeaddress), 2, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-13T01:50:23.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11782" PostTypeId="1" AcceptedAnswerId="11784" CreationDate="2015-05-13T02:58:02.463" Score="0" ViewCount="352" Body="&lt;p&gt;Recently, I have been playing around with a gyroscope and accelerometer in the hopes of building a quadcopter. I have plotted some of the data the two sensors and I am noticing that the pitch from the accelerator lags significantly behind the gyroscopic pitch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From some research, I understand that these two are not going to equivalent values due to the mechanisms of measurement, however is it common to have such large discrepancies (i.e a difference of 20 degrees or higher) between the two sensors or is this an issue with my conversion? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have listed the graph and source code &lt;a href=&quot;https://www.dropbox.com/sh/lemczvtzstgdhcj/AAAYqmxft7sWJ-tMkcKaA2d7a?dl=0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Any help would be appreciated!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sincerely,&#xA;Anand&lt;/p&gt;&#xA;" OwnerUserId="7422" LastActivityDate="2015-06-12T04:01:04.223" Title="Comparing orientation data obtained using gyroscope and accelerometer" Tags="|arduino-uno|accelerometer|gyroscope|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11783" PostTypeId="1" AcceptedAnswerId="11817" CreationDate="2015-05-13T03:43:47.833" Score="1" ViewCount="1610" Body="&lt;p&gt;I am trying to get values from this sensor &lt;strong&gt;Airspeed v3&lt;/strong&gt; from eagle tree but it seems my I2C is not working properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought a module in third party mode and followed these &lt;a href=&quot;http://www.eagletreesystems.com/Manuals/microsensor-i2c.pdf&quot; rel=&quot;nofollow&quot;&gt;instructions&lt;/a&gt; from the manufacturer website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I went to rcgroups forum and discovered the right values for the bits mentioned in the documentation about WRITE and READ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started the development of a code but I cannot get the values from the sensor. It is supposed to send me a 2 byte-formatted value indicating the airspeed measured. But surprisingly when I call this method &lt;code&gt;Wire.requestFrom(AIRSPEED_ADDRESS, 2)&lt;/code&gt; it returns 0, so someway the communication is not working. I have used I2C before for ADXL345 sensor and it works perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The results from these lines &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(data[0]);  &#xA;Serial.println(data[1]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are just -1 indicating that no data is available to display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how to get this working? Am I missing something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code right now.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define AIRSPEED_ADDRESS  0xEA&#xA;#define WRITE_BIT         0x00&#xA;#define READ_BIT          0x01&#xA;&#xA;&#xA;void setup() {&#xA;  // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Program started&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte data[2] = {0};&#xA;  int i = 0;&#xA;  int16_t velocidade = 0;&#xA;&#xA;  Wire.beginTransmission(AIRSPEED_ADDRESS);  &#xA;  if (!Wire.write(WRITE_BIT)) {&#xA;    Serial.println(&quot;error sending write_bit&quot;);&#xA;  }&#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.beginTransmission(AIRSPEED_ADDRESS);  &#xA;  if (!Wire.write(0x07)) {&#xA;    Serial.println(&quot;error sending 0x07&quot;);&#xA;  }&#xA;  Wire.endTransmission(false);&#xA;&#xA;  Wire.beginTransmission(AIRSPEED_ADDRESS);  &#xA;  if (!Wire.write(READ_BIT)) {&#xA;    Serial.println(&quot;error sending read_bit&quot;);&#xA;  }&#xA;  else {&#xA;    //Serial.println(&quot;ok sending read_bit&quot;);&#xA;  }  &#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.beginTransmission(AIRSPEED_ADDRESS);  &#xA;  Serial.print(&quot;bytes read from slave: &quot;);&#xA;  Serial.println(  Wire.requestFrom(AIRSPEED_ADDRESS, 2) );&#xA;  data[0] = Wire.read();&#xA;  data[1] = Wire.read();&#xA;  Wire.endTransmission(); &#xA;&#xA;  velocidade = data[1] | (data[0] &amp;lt;&amp;lt; 8);&#xA;  Serial.println(data[0]);  &#xA;  Serial.println(data[1]);  &#xA;  Serial.println(&quot; &quot;);  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8478" LastEditorUserId="8478" LastEditDate="2015-05-14T00:25:26.143" LastActivityDate="2019-05-20T12:24:01.853" Title="Reading data from airspeed v3 eagle tree" Tags="|arduino-uno|sensors|i2c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11784" PostTypeId="2" ParentId="11782" CreationDate="2015-05-13T04:00:54.107" Score="0" Body="&lt;p&gt;Normally the values from gyroscope will drift overtime. It is natural and depends on the parameters of your code. It could drift a few degrees per seconds and the data will be far way from the accelerometer in a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen that you have applied the complementary filter, so you don't need to worry about the single value from the gyros since you combine them with the acceleromter and everything seems fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gyros are good for short time response, in long time response the values get pretty bad as they drift a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, accelerometers are good for long time response, since short time response is noisy because of gravitational influence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why you need a filter to combine them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wrapping up, it is normal to have this behavior in gyros. If you want to know more about the effect behind this sensor, try this &lt;a href=&quot;http://en.wikipedia.org/wiki/Coriolis_effect&quot; rel=&quot;nofollow&quot;&gt;reading&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-13T04:00:54.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11785" PostTypeId="1" AcceptedAnswerId="11787" CreationDate="2015-05-11T03:56:58.113" Score="1" ViewCount="15929" Body="&lt;p&gt;For overcoming torque issues, I have attached 2 &lt;em&gt;identical&lt;/em&gt; servos on a certain part of my robot arm &lt;sub&gt;and because I saw someone do the same.&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, while writing code I realize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;...&#xA;...&#xA;shoulder1.write(map(analogRead(p1), 0, 1023, 0, 179));&#xA;shoulder2.write(map(analogRead(p1), 0, 1023, 0, 179));&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will turn &lt;code&gt;shoulder1&lt;/code&gt; by 20* and then &lt;code&gt;shoulder2&lt;/code&gt; by another 20*, ie. an overall turn of 40*; that too with too much load on servos, as the other servo would be inactive at the time first is active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to achieve 20* fully-sync.ed turn on both servos, how do I accomplish this? Any arduino libraries or walkthrough?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Can I possibly move them &lt;a href=&quot;http://playground.arduino.cc/ComponentLib/servo&quot; rel=&quot;nofollow&quot;&gt;both at the same time&lt;/a&gt; - something like &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=4854.0&quot; rel=&quot;nofollow&quot;&gt;multithreading&lt;/a&gt; on arduino? Here's what I tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void rotateTwoServoInSync(int angle) {&#xA;    for(int i = 0; i&amp;lt;angle; i++) {&#xA;        shoulder1.attach(9);&#xA;        shoulder1.write(i);&#xA;        shoulder1.detach();&#xA;        shoulder2.attach(10);&#xA;        shoulder2.write(i);&#xA;        shoulder2.detach();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will it work? Is this approach recommendable?&lt;/p&gt;&#xA;" OwnerUserId="8219" OwnerDisplayName="aim100k" LastActivityDate="2019-05-22T04:33:17.180" Title="How to control 2 servos at same time in sync?" Tags="|programming|servo|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11786" PostTypeId="2" ParentId="11785" CreationDate="2015-05-11T04:08:22.887" Score="0" Body="&lt;p&gt;&lt;code&gt;analogRead()&lt;/code&gt; and &lt;code&gt;map()&lt;/code&gt; are slow; only perform them once.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char rot = map(analogRead(p1), 0, 1023, 0, 179);&#xA;shoulder1.write(rot);&#xA;shoulder2.write(rot);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-05-11T04:08:22.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11787" PostTypeId="2" ParentId="11785" CreationDate="2015-05-11T06:14:50.263" Score="5" Body="&lt;p&gt;If you have two RC servos that are always required to move together you can simply connect both control inputs to a single output. &lt;/p&gt;&#xA;" OwnerUserId="5080" OwnerDisplayName="Spehro Pefhany" LastActivityDate="2015-05-11T06:14:50.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11788" PostTypeId="2" ParentId="11738" CreationDate="2015-05-13T05:43:57.600" Score="0" Body="&lt;p&gt;Yes, and I do appreciate the original answer as it is effective(something just bugs me about losing sensory capability for any amount of time), I just was not really looking for a work around but rather the engineer in me was simply interested in why the code would be responding the way it was. Anyways though I got around to writing my tester and now it's working like a charm. Maybe I was being sloppy before? Obviously I just need to do a bit more testing. I'll post the code just in case anyone is interested in seeing it(also will keep in mind the preference to actual code rather than screen shot in the future) . Thanks for the support!&lt;img src=&quot;https://i.stack.imgur.com/O0SJ4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9995" LastActivityDate="2015-05-13T05:43:57.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11789" PostTypeId="2" ParentId="11707" CreationDate="2015-05-13T08:21:10.197" Score="0" Body="&lt;p&gt;You probably want to read the button press on LCD using &quot;read_LCD_buttons&quot; function. See an example at: &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29&quot; rel=&quot;nofollow&quot;&gt;Arduino LCD KeyPad Shield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your part of your code would probably be: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define btnRIGHT  0&#xA;#define btnUP     1&#xA;#define btnDOWN   2&#xA;#define btnLEFT   3&#xA;#define btnSELECT 4&#xA;#define btnNONE   5&#xA;int lcd_key     = 0;&#xA;&#xA;void loop()&#xA;{&#xA; setClock();&#xA;&#xA; /**&#xA; * After set clock now you have 3 int variables with the current time&#xA; */&#xA; //seconds&#xA; //minutes&#xA; //hours&#xA; printValueAtLine(0);&#xA;&#xA; lcd_key = read_LCD_buttons();  // read the buttons&#xA;&#xA; switch (lcd_key)&#xA; {&#xA;   case btnSELECT:&#xA;   {&#xA;     printValueAtLine(1);&#xA;     break;&#xA;   }&#xA;   case btnRIGHT:&#xA;   {&#xA;     // code in case other buttons like  btnRIGHT, etc are pressed&#xA;     break;&#xA;   }&#xA;   case btnNONE:&#xA;   {&#xA;     //do nothing&#xA;     break;&#xA;   }&#xA; }&#xA;}&#xA;&#xA;void printValueAtLine(int line)&#xA;{&#xA; lcd.setCursor (1, line);&#xA; lcd.print(hours);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(minutes);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(seconds);&#xA; lcd.print(&quot;:&quot;);&#xA; lcd.print(elapsedMillis);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code is untested and you may have to make minor corrections to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, rather than saving values in global variables, you might want to use local ones using libraries suggested by wobbler.&lt;/p&gt;&#xA;" OwnerUserId="9918" LastActivityDate="2015-05-13T08:21:10.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11790" PostTypeId="2" ParentId="11785" CreationDate="2015-05-13T09:00:15.270" Score="3" Body="&lt;p&gt;Spehro's answer is the most obvious. But note that there is no such thing as identical servos. You may stress them if you connect them through a stiff connection.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to have two mechanical parts make the same movement the proper solution is to connect them mechanically, rather than have two servos doing the same action.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-13T09:00:15.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11791" PostTypeId="1" AcceptedAnswerId="11793" CreationDate="2015-05-13T10:07:51.913" Score="1" ViewCount="909" Body="&lt;p&gt;So maybe it's a very low class form of question, but please bear with me. I'm working on a project with 7 HC-SR04 ultrasonic sensors connected to one Arduino. I tried to unify the trigger and echo pin, but the sensing isn't good enough, so I dropped the Uno and convert it to Mega. My question is, do I need external power source for those 7 Sensors? And how do I connect all of them? Thanks&lt;/p&gt;&#xA;" OwnerUserId="10027" LastActivityDate="2017-11-20T22:49:07.100" Title="Do multiple ultrasonic sensors need an external power source?" Tags="|arduino-mega|sensors|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11792" PostTypeId="2" ParentId="11707" CreationDate="2015-05-13T10:15:45.420" Score="1" Body="&lt;p&gt;Since you will have to deal with &lt;em&gt;two&lt;/em&gt; different times, I suggest&#xA;writing a small class for representing those times in broken-down form.&#xA;This is a reduced version of the classical &lt;code&gt;strcut tm&lt;/code&gt;. Times are made&#xA;&lt;code&gt;Printable&lt;/code&gt; so you can just &lt;code&gt;print()&lt;/code&gt; them to the LCD. I included an&#xA;&lt;code&gt;increment()&lt;/code&gt; method to add one second to this time.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class BrokenDownTime : public Printable {&#xA;    uint8_t hours;&#xA;    uint8_t minutes;&#xA;    uint8_t seconds;&#xA;public:&#xA;    void increment();&#xA;    size_t printTo(Print &amp;amp;p) const;&#xA;};&#xA;&#xA;/* Increment the time by one second. */&#xA;void BrokenDownTime::increment()&#xA;{&#xA;    if (++seconds &amp;gt;= 60) {&#xA;        seconds = 0;&#xA;        if (++minutes &amp;gt;= 60) {&#xA;            minutes = 0;&#xA;            if (++hours &amp;gt;= 24)&#xA;                hours = 0;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;/*&#xA; * Print to anything that inherits from the Print class (Serial,&#xA; * LiquidCrystal, etc.). This makes times `Printable'.&#xA; */&#xA;size_t BrokenDownTime::printTo(Print &amp;amp;p) const&#xA;{&#xA;    p.print(hours/10);&#xA;    p.print(hours%10);&#xA;    p.write(':');&#xA;    p.print(minutes/10);&#xA;    p.print(minutes%10);&#xA;    p.write(':');&#xA;    p.print(seconds/10);&#xA;    p.print(seconds%10);&#xA;    return 8;  // 8 bytes written&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The main program checks in &lt;code&gt;loop()&lt;/code&gt; for the button being pressed. When&#xA;this happens, it saves the current time as &lt;code&gt;lastPress&lt;/code&gt;. If the button&#xA;was ever pressed (variable &lt;code&gt;button_was_pressed&lt;/code&gt;), the recorded time is&#xA;displayed on the first line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;#define BUTTON_ADC_PIN A0&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;BrokenDownTime now;&#xA;&#xA;/* Detect a press on `left', change the thresholds for other buttons. */&#xA;bool buttonPressed()&#xA;{&#xA;    int reading = analogRead(BUTTON_ADC_PIN);&#xA;    return reading &amp;gt; 405 &amp;amp;&amp;amp; reading &amp;lt; 605;&#xA;}&#xA;&#xA;/* Update `now'. */&#xA;void updateTime()&#xA;{&#xA;    static unsigned long last;&#xA;    if (millis() - last &amp;gt;= 1000) {&#xA;        now.increment();&#xA;        last += 1000;&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    static BrokenDownTime lastPress;&#xA;    static bool button_was_pressed;&#xA;&#xA;    updateTime();&#xA;&#xA;    /* Record the time of the button press. */&#xA;    if (buttonPressed()) {&#xA;        lastPress = now;&#xA;        button_was_pressed = true;&#xA;    }&#xA;&#xA;    /* Display the recorded time on the first line. */&#xA;    if (button_was_pressed) {&#xA;        lcd.setCursor(0, 0);&#xA;        lcd.print(lastPress);&#xA;    }&#xA;&#xA;    /* Display the current time on the second line. */&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(now);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did not test the program, but I hope you get the idea.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-13T10:15:45.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11793" PostTypeId="2" ParentId="11791" CreationDate="2015-05-13T10:32:35.153" Score="4" Body="&lt;p&gt;Well, according to &lt;a href=&quot;http://www.micropik.com/PDF/HCSR04.pdf&quot; rel=&quot;nofollow&quot;&gt;the datasheet&lt;/a&gt; the &quot;working current&quot; is 15mA.  Even if you had all 7 working at once, which I doubt you will - you'll be working through them in sequence I guess - that would be just 105mA - way below the 800mA the Arduino's on-board regulator can supply, and only a fifth of what a USB port can provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet doesn't mention the quiescent (idle) current, but it will be a tiny fraction of that 15mA and so can mostly be ignored.  Running the sensors in sequence, which is the most likely scenario, would use about the same amount of current as if you had 1 sensor - or 20 sensors.  Most of the current consumption would be while you are actively producing an ultrasonic chirp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, you don't need an external power supply to run them all - just take them all from the Arduino's 5V pin.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-13T10:32:35.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11794" PostTypeId="1" AcceptedAnswerId="11802" CreationDate="2015-05-13T12:12:20.580" Score="0" ViewCount="341" Body="&lt;p&gt;I have a question about using the Arduino and Processing. I want to build a touch sensor using aluminum foil and connect it to an interface built in Processing. However i've come across a problem. I don't know how to send the serial data from the Arduino to Processing. This is the code I'm using to get the sensor value from the aluminum foil:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;&#xA;&#xA;CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);   &#xA;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  long start = millis();&#xA;  long total1 =  cs_4_2.capacitiveSensor(30);&#xA;&#xA;  Serial.print(millis() - start);        &#xA;  Serial.print(&quot;\t&quot;);                    &#xA;&#xA;  Serial.print(total1);                  &#xA;  Serial.print(&quot;\t&quot;); &#xA;  Serial.print('\n');&#xA;&#xA;  delay(100);          &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The foil is connected to dig pin 4 with a resistor of 1M in between and to dig pin 2 with a resistor of 1K. Pin 4 is the send pin, pin 2 is the receive pin. It all works just fine, in the serial monitor in the Arduino software I get the value of the time between refreshes and the sensor value. But how do I use this sensor value in a Processing sketch? I thought of maybe using Firmata on the Arduino, but then I wouldn't know how to use the CapacitiveSensor library and get the sensor values. Does anyone know how to get this to work? Help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="10028" LastActivityDate="2015-05-13T15:04:01.740" Title="Sending serial data to Processing" Tags="|serial|processing-lang|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11795" PostTypeId="2" ParentId="11754" CreationDate="2015-05-13T12:12:48.330" Score="4" Body="&lt;p&gt;Given the time scale of the measurements, performance is not an issue.&#xA;And since you are not computing in real-time, as the samples are being&#xA;measured, you can apply the definition of cross-correlation as is, and&#xA;compute it in a double loop. The only difficulty is figuring out that&#xA;cross-correlation may not be the proper tool for the job... and finding&#xA;the right one! My assumption is that you want to estimate a rotation&#xA;angle between the two measurements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mathematical definition of cross-correlation assumes infinite&#xA;arrays. In practice, cross-correlation is often used to locate a short&#xA;pattern inside a long signal. In this case, the computation is done only&#xA;for shifts where the pattern completely overlaps the signal. Then the&#xA;length of the result is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;length(result) = length(signal) − length(pattern) + 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your case, since your pattern is a previously measured signal, this&#xA;would give a single-sample result, which is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could instead compute the integral for all shifts where there is&#xA;&lt;em&gt;any&lt;/em&gt; overlap between the pattern and the signal. This is equivalent to&#xA;zero-padding the signal. This has the drawback of biasing the result: if&#xA;your signal and pattern are both featureless (positive constants), you&#xA;will find a very nice peak at zero shift!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can remove this bias by subtracting the average from both the signal&#xA;and the pattern, and correlating (signal −&amp;nbsp;avg(signal)) with&#xA;(pattern −&amp;nbsp;avg(pattern)). This still carries a bias for “big”&#xA;features. Imagine for example that, after removing the averages, you&#xA;have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pattern = [  0,   0, −20, +20,   0,   0];&#xA;signal  = [−50, +50,   0,   0, −20, +20];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would expect your correlator to find a good match between the&#xA;[−20, +20] of the pattern and the [−20, +20] of the signal. The&#xA;correlation is, however, much better with the [−50, +50] of the signal.&#xA;You may try to alleviate this by computing a normalized&#xA;cross-correlation instead, but you will at best make both matches&#xA;equally good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is that you completely forget about correlations and&#xA;instead think in terms of “goodness of fit”. Correlations are good for&#xA;finding scaled and shifted copies of a pattern inside a signal. You are&#xA;looking for &lt;em&gt;shifted only&lt;/em&gt; copies, with no scaling. Your question should&#xA;be: if you shift the pattern by some amount, how well does it fit the&#xA;signal? What amount of shift gives the better fit? The canonical answer&#xA;to all “goodness of fit” questions is to minimize the RMS difference&#xA;between the two: you compute the sum&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S = Σ(signal − shifted(pattern))²&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the RMS difference is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RMS(difference) = √(S/N)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;em&gt;N&lt;/em&gt; is the number of samples involved in the sum. The most likely&#xA;shift is the one that minimizes this error. In practice, you do not need&#xA;the square root, you just minimize&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RMS(difference)² = Σ(signal − shifted(pattern))² / N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can implement this formula as-is, it's completely straightforward.&#xA;Just beware that &lt;em&gt;N&lt;/em&gt; depends on the shift, as it's the length of the&#xA;overlap. And avoid going to very small overlaps (i.e. large shifts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if you expand the square inside the sum, you may find that, after&#xA;all, this is not so far from a cross-correlation... And BTW, all this&#xA;has nothing to do with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-13T12:12:48.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11796" PostTypeId="2" ParentId="11794" CreationDate="2015-05-13T12:19:39.160" Score="0" Body="&lt;p&gt;SparkFun has &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;a tutorial&lt;/a&gt; where they explain in great detail how to create a project where your Arduino communicates with Processing on your PC.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-13T12:19:39.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11797" PostTypeId="1" AcceptedAnswerId="11805" CreationDate="2015-05-13T12:30:54.630" Score="1" ViewCount="4068" Body="&lt;p&gt;I want to make a RC mixer mixing two channels of a receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have: a delta model plane, two servos, a receiver and a Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd like to mix the aileron (two channels) with the elevator(one channel).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: What I've done: I read the input of the receiver and wrote it to the servos. The problem: The servo stutters and the arduino displays false inputs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = A0;&#xA;int pin1 = A1;&#xA;unsigned long duration;&#xA;unsigned long dur;&#xA;&#xA;unsigned long duration2;&#xA;unsigned long dur2;&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;&#xA;Servo myservo2;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  myservo.attach(9);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  duration = pulseIn(pin, HIGH);&#xA;  dur = duration;&#xA;  Serial.println(dur);&#xA;  myservo.writeMicroseconds(dur);&#xA;  delay(50);&#xA;//  duration2 = pulseIn(pin1, HIGH);&#xA;//  dur2 = duration2-980/4-200;&#xA;//  Serial.println(dur2);&#xA;//  myservo2.write(dur2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8644" LastEditorUserId="8644" LastEditDate="2015-05-13T17:59:18.563" LastActivityDate="2015-05-13T20:58:13.840" Title="How to make an RC mixer with the arduino" Tags="|arduino-nano|pwm|remote-control|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11798" PostTypeId="1" CreationDate="2015-05-13T13:08:27.137" Score="0" ViewCount="1172" Body="&lt;p&gt;I want to get emails read from a Hotmail account using an Arduino Uno. Is there a way to do it with SSL or is there a way to disable SSL?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;// Use comments to enable or disable this define for debug messages&#xA;#define DEBUG_POP&#xA;// Use comments to enable or disable the deleting of the mail&#xA;#define ENABLE_DELETE_POP&#xA;&#xA;&#xA;// The mac address must be an unique number&#xA;// A mac generator is used:&#xA;//   http://www.miniwebtool.com/mac-address-generator/&#xA;byte mac[] = { 0xDE, 0x36, 0x5F, 0x0A, 0x19, 0x83 };&#xA;// change network settings to yours&#xA;IPAddress ip(192, 168, 1, 117);&#xA;IPAddress gateway(192, 168, 1, 1);&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;&#xA;&#xA;// Set the server POP3 address, the port, the user and password.&#xA;// The POP3 mail server is something like this: &#xA;//     mail.yourdomain.com, pop.yourdomain.com, pop3.yourdomain.com&#xA;// Using PROGMEM for these causes a fail when trying to connect and log in.&#xA;const char pop_server[] = &quot;pop3.live.com&quot;;&#xA;const int  pop_port = 995;&#xA;const char pop_user[] = &quot;xxxxxx@hotmail.com&quot;;&#xA;const char pop_pass[] = &quot;xxxxxx&quot;;&#xA;&#xA;&#xA;// The number of milliseconds timeout for parseInt() and find().&#xA;// The response time for the Server can still be 10 seconds.&#xA;#define POP_TIMEOUT 10&#xA;#define POP_TIMEOUT_DEFAULT 1000&#xA;&#xA;&#xA;EthernetClient client;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial.println(F(&quot;\nArduino POP3 email reader&quot;));&#xA;&#xA;    pinMode(13, OUTPUT);     // the system led is used for testing&#xA;&#xA;    // When the Ethernet Shield is used, there is also a SD card connected&#xA;    // to the SPI bus. Disable the SD card with chip select at pin 4.&#xA;    pinMode(4, OUTPUT);&#xA;    digitalWrite(4, HIGH);&#xA;&#xA;&#xA;    // Start Ethernet. Use only the 'mac' parameter for DHCP&#xA;    // Use 'mac' and 'ip' parameters for static IP address.&#xA;    //  Ethernet.begin( mac, ip);&#xA;    //  Ethernet.begin( mac, ip, gateway, gateway, subnet);&#xA;    if (Ethernet.begin(mac) == 0)&#xA;    {&#xA;        Serial.println(&quot;Failed to configure Ethernet using DHCP.&quot;);&#xA;        // no point in carrying on, so do nothing forevermore:&#xA;        while (1);&#xA;    }&#xA;    Ethernet.begin(mac, ip, gateway, gateway, subnet);&#xA;    // print your local IP address.&#xA;    Serial.println(F(&quot;Ethernet started.&quot;));&#xA;    Serial.print(F(&quot;Local IP = &quot;));&#xA;    Serial.println(Ethernet.localIP());&#xA;&#xA;    Serial.println(F(&quot;Press 'c' to check mail.&quot;));&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    // Create a buffer to receive the commands in (that is the Subject of the mail).&#xA;    char buffer[32];&#xA;&#xA;    byte inChar = Serial.read();&#xA;    if (inChar == 'c')&#xA;    {&#xA;        // The getEmail gets the text of the mail Subject into the buffer.&#xA;        // The valid number of received characters are returned.&#xA;        // If the return value is &amp;lt; 0, it is an error.&#xA;        int n = getEmail(buffer, sizeof(buffer));&#xA;&#xA;        if (n &amp;lt; 0)&#xA;        {&#xA;            Serial.print(F(&quot;Email POP3 failed, error = &quot;));&#xA;            Serial.println(n);&#xA;        }&#xA;        else&#xA;        {&#xA;            if (n == 0)&#xA;            {&#xA;                Serial.println(F(&quot;Ready, nothing to do.&quot;));&#xA;            }&#xA;            else&#xA;            {&#xA;                // 'n' is &amp;gt; 0, a command received.&#xA;                Serial.print(F(&quot;Email checked, Command = \&quot;&quot;));&#xA;                Serial.print(buffer);&#xA;                Serial.println(F(&quot;\&quot;&quot;));&#xA;&#xA;&#xA;                // Check the commands.&#xA;                //&#xA;                // At this moment, a single command 'L' is used to set system led on or off.&#xA;                //    L=1   (set led on)&#xA;                //    L=0   (set led off)&#xA;                if (buffer[0] == 'L' &amp;amp;&amp;amp; buffer[1] == '=')&#xA;                {&#xA;                    digitalWrite(13, buffer[2] == '0' ? LOW : HIGH);&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;&#xA;// getEmail&#xA;// --------&#xA;// Find an email on a mail server, using POP3.&#xA;// The Subject should start with &quot;ARDUINO &quot; and the text&#xA;// after that is copied into pBuf.&#xA;// &#xA;// The data in pBuf is only valid if the return value is not an error&#xA;// (an error is return value less than zero).&#xA;//&#xA;int getEmail(char *pBuf, int nBufSize)&#xA;{&#xA;    // nBytes is the number of bytes that is returned by getEmail.&#xA;    int nBytes = 0;&#xA;&#xA;    // Connect to server&#xA;    // client.connect returns '1' if okay, or negative number if error.&#xA;    //    SUCCESS 1&#xA;    //    0     (error, unknown timeout, perhaps an error in the library)&#xA;    //    TIMED_OUT -1&#xA;    //    INVALID_SERVER -2&#xA;    //    TRUNCATED -3&#xA;    //    INVALID_RESPONSE -4&#xA;    //    -5    (there is no mail server at that IP address and port)&#xA;    // The string for the server must be a normal string in sram, no PROGMEM allowed.&#xA;    int nError = client.connect(pop_server, pop_port);&#xA;&#xA;    // During testing, a value of zero was sometimes returned.&#xA;    // This is not according to the documentation and it is an error.&#xA;    // Therefor the non-error value '0' is turned into a negative number to&#xA;    // indicate an error.&#xA;    if (nError == 0)&#xA;        return(-200);&#xA;&#xA;    // Only a value of 1 is okay.&#xA;    if (nError != 1)&#xA;        return(nError);&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;connected&quot;));&#xA;    //Serial.println(nError);&#xA;#endif&#xA;    // The server should respond with &quot;+OK&quot; and maybe more text after that.&#xA;    // Check if &quot;+OK&quot; can be read.&#xA;    // The parameter 'true' is to read also everything after the &quot;+OK&quot;.&#xA;    if (!readOk(true))&#xA;        return -102;&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;command USER&quot;));&#xA;#endif&#xA;    client.print(F(&quot;USER &quot;));&#xA;    client.println(pop_user);&#xA;    if (!readOk(true))&#xA;        return -103;&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;command PASS&quot;));&#xA;#endif&#xA;    client.print(F(&quot;PASS &quot;));&#xA;    client.println(pop_pass);&#xA;    if (!readOk(true))&#xA;        return -104;&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;command STAT&quot;));&#xA;#endif  &#xA;    client.println(F(&quot;STAT&quot;));&#xA;    if (!readOk(false))&#xA;        return -105;&#xA;&#xA;    // The whole line was like this: &quot;+OK 3 15343&quot;&#xA;    // It means that 3 emails are waiting with a total size of 15343.&#xA;    // At this moment, the &quot;+OK&quot; is read, but nothing else.&#xA;    // Check if there is a space after &quot;+OK&quot;.&#xA;    char c = client.read();&#xA;    if (c != ' ')&#xA;        return -106;&#xA;&#xA;    client.setTimeout(POP_TIMEOUT);       // set timeout lower for parseInt&#xA;    // Read the number of emails that are on the server.&#xA;    int nMails = client.parseInt();&#xA;    client.setTimeout(POP_TIMEOUT_DEFAULT);  // restore timeout to 1 second&#xA;&#xA;    // Read the remaining of the response to STAT.&#xA;    readRemaining();&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.print(F(&quot;Number of emails=&quot;));&#xA;    Serial.println(nMails);&#xA;#endif&#xA;&#xA;    // Test if there are emails waiting.&#xA;    if (nMails == 0)&#xA;    {&#xA;        // No emails, but no error. Set buffer to empty string.&#xA;        nBytes = 0;               // the returned value&#xA;        pBuf[0] = '\0';           // set empty string&#xA;    }&#xA;    else if (nMails &amp;gt; 0)&#xA;    {&#xA;        // emails are waiting.&#xA;        // Scan the emails until the first is found with the keyword &quot;ARDUINO &quot; at the&#xA;        // beginning of the &quot;Subject: &quot;.&#xA;&#xA;        boolean found_and_ready = false;&#xA;        for (int nMailNumber = 1; nMailNumber &amp;lt;= nMails &amp;amp;&amp;amp; !found_and_ready; nMailNumber++)&#xA;        {&#xA;            // The command RETR &amp;lt;x&amp;gt; gets the whole mail.&#xA;            // The command TOP &amp;lt;x&amp;gt; &amp;lt;size&amp;gt; gets the header plus 'size' of the body.&#xA;&#xA;#ifdef DEBUG_POP&#xA;            Serial.print(F(&quot;command TOP &quot;));&#xA;            Serial.print(nMailNumber);&#xA;            Serial.println(F(&quot; 0&quot;));&#xA;#endif    &#xA;            client.print(F(&quot;TOP &quot;));&#xA;            client.print(nMailNumber);&#xA;            client.println(F(&quot; 0&quot;));&#xA;&#xA;            // Use readOk with parameter 'false' to stop reading after &quot;+OK&quot;.&#xA;            if (!readOk(false))&#xA;                return -107;&#xA;            // The header of the email is waiting to be read, use the Stream.find() to look for the Subject.&#xA;            // The text &quot;Subject: &quot; should be at the beginning of a line, but that is not tested.&#xA;            // The first found text &quot;Subject: &quot; is assumed to be the real subject.&#xA;            // I have checked many years of emails, and the text is always &quot;Subject: &quot;, and never &quot;SUBJECT: &quot;.&#xA;            // At the moment, it is not possible to use the F() macro for Stream.find&#xA;            // Only the email that starts with &quot;ARDUINO &quot; at the start of the Subject is used.&#xA;&#xA;            client.setTimeout(POP_TIMEOUT);      // set short timeout for find().&#xA;            // find() returns true if found and false if not.&#xA;            boolean foundsubject = client.find(&quot;Subject: ARDUINO &quot;);&#xA;            client.setTimeout(POP_TIMEOUT_DEFAULT);   // restore timeout to 1 second&#xA;&#xA;            if (foundsubject)&#xA;            {&#xA;#ifdef DEBUG_POP&#xA;                Serial.println(F(&quot;Found an email for me&quot;));&#xA;#endif        &#xA;&#xA;                // Read the remaining subject (that is the command for the Arduino) into a buffer.&#xA;                // Every line from the mail server should end with CR + LF, &#xA;                // but to be sure, both CR and LF are checked.&#xA;                // Alternative:&#xA;                //    client.readBytesUntil('\r', pBuf, nBufSize);&#xA;&#xA;                // The last position in the buffer is reserved for the zero terminator.&#xA;                // So read data until (nBufSize-1).&#xA;                int i;&#xA;                for (i = 0; i &amp;lt; (nBufSize - 1) &amp;amp;&amp;amp; client.available(); i++)&#xA;                {&#xA;                    char c = client.read();&#xA;                    if (c == '\r' || c == '\n')&#xA;                        break;&#xA;                    pBuf[i] = c;&#xA;                }&#xA;                // Add zero terminator&#xA;                pBuf[i] = '\0';&#xA;                nBytes = i;     // the number of received bytes is returned by the getEmail() function.&#xA;&#xA;                // More text of the header could be following the Subject.&#xA;                // That is read and disregarded.&#xA;                readRemaining();&#xA;&#xA;#ifdef DEBUG_POP&#xA;                Serial.print(F(&quot;Subject = \&quot;ARDUINO &quot;));&#xA;                Serial.print(pBuf);&#xA;                Serial.println(F(&quot;\&quot;&quot;));&#xA;#endif&#xA;&#xA;#ifdef ENABLE_DELETE_POP&#xA;                // Delete the just read message.&#xA;#ifdef DEBUG_POP&#xA;                Serial.print(F(&quot;command DELE &quot;));&#xA;                Serial.println(nMailNumber);&#xA;#endif    &#xA;                client.print(F(&quot;DELE &quot;));&#xA;                client.println(nMailNumber);&#xA;                if (!readOk(true))&#xA;                    return -108;&#xA;#endif&#xA;&#xA;                // Everything is okay, the mail is read and deleted.&#xA;                // Ready for now, don't process the remaining emails.&#xA;                found_and_ready = true;&#xA;            }&#xA;            else&#xA;            {&#xA;#ifdef DEBUG_POP&#xA;                Serial.println(F(&quot;No ARDUINO keyword in subject&quot;));&#xA;#endif        &#xA;                // This email has no &quot;Subject: ARDUINO &quot;.&#xA;                // But the remaining text has still to be read and disregarded.&#xA;                readRemaining();&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;Sending QUIT&quot;));&#xA;#endif  &#xA;    client.println(F(&quot;QUIT&quot;));&#xA;&#xA;    // After &quot;QUIT&quot;, the server still respons with &quot;+OK&quot;,&#xA;    // but after that, the connection might get lost.&#xA;    // So don't read everything after &quot;+OK&quot; (use parameter 'false' for readOk).&#xA;    if (!readOk(false))&#xA;        return -109;&#xA;&#xA;    client.stop();&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;normally disconnected&quot;));&#xA;#endif&#xA;&#xA;    return(nBytes);&#xA;}&#xA;&#xA;&#xA;// Read the response from the mail server.&#xA;// That is &quot;+OK&quot; if everything is okay.&#xA;// Parameter 'readAll' is to read every character after the &quot;+OK&quot;.&#xA;boolean readOk(boolean readAll)&#xA;{&#xA;    // Check the response &quot;+OK&quot; from the mail server&#xA;    // In most cases that is followed by a space and more text, but not always.&#xA;    // In case of an error the text &quot;-ERR&quot; is received.&#xA;&#xA;    int loopCount = 0;&#xA;    char bufOk[4];&#xA;    Serial.print(&quot;Connected: &quot;);&#xA;    Serial.println(client.connected());&#xA;&#xA;    Serial.print(&quot;Client Available: &quot;);&#xA;    Serial.println(client.available());&#xA;    // Wait for response of mail server, with a timout.&#xA;    while (!client.available())&#xA;    {&#xA;        delay(1);&#xA;        loopCount++;&#xA;&#xA;        // if nothing received for 10 seconds, timeout&#xA;        if (loopCount &amp;gt; 10000)&#xA;        {&#xA;            client.stop();&#xA;#ifdef DEBUG_POP&#xA;            Serial.println(F(&quot;\nTimeout&quot;));&#xA;#endif      &#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    // Read the first three bytes.&#xA;    client.readBytes(bufOk, 3);&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.write(bufOk, 3);&#xA;    Serial.println();&#xA;#endif&#xA;&#xA;    // Is it &quot;+OK&quot; ?&#xA;    if (strncmp(bufOk, &quot;+OK&quot;, 3) != 0)&#xA;    {&#xA;        popFail();&#xA;        return false;&#xA;    }&#xA;&#xA;    // When the text after &quot;+OK&quot; is not needed, everything&#xA;    // else can be read and disregarded &#xA;    // (or shown in the serial monitor during debugging).&#xA;    if (readAll)&#xA;        readRemaining();&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;&#xA;void readRemaining()&#xA;{&#xA;    // This function is called after checking the &quot;+OK&quot;.&#xA;    // It reads everything from the server, until no more text is&#xA;    // available.&#xA;&#xA;    while (client.available())&#xA;    {&#xA;        char c = client.read();&#xA;#ifdef DEBUG_POP_EXTRA   &#xA;        Serial.print(c);&#xA;#endif    &#xA;    }&#xA;    return;&#xA;}&#xA;&#xA;&#xA;void popFail()&#xA;{&#xA;    int loopCount = 0;&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;popFail&quot;));&#xA;#endif&#xA;&#xA;    while (!client.available())&#xA;    {&#xA;        delay(1);&#xA;        loopCount++;&#xA;&#xA;        // if nothing received for 10 seconds, timeout&#xA;        if (loopCount &amp;gt; 10000)&#xA;        {&#xA;            client.stop();&#xA;#ifdef DEBUG_POP&#xA;            Serial.println(F(&quot;\nTimeout&quot;));&#xA;#endif      &#xA;            return;&#xA;        }&#xA;    }&#xA;&#xA;    client.stop();&#xA;&#xA;#ifdef DEBUG_POP&#xA;    Serial.println(F(&quot;disconnected due to fail&quot;));&#xA;#endif  &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino POP3 email reader&#xA;Ethernet started.&#xA;Local IP = 192.168.1.117&#xA;Press 'c' to check mail.&#xA;connected&#xA;Connected: 1&#xA;Client Active: 0&#xA;&#xA;Timeout&#xA;Email POP3 failed, error = -102&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9920" LastEditorUserId="4143" LastEditDate="2015-05-13T14:10:58.840" LastActivityDate="2015-06-12T15:01:17.120" Title="Arduino-uno sending email with Hotmail" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11799" PostTypeId="2" ParentId="11794" CreationDate="2015-05-13T13:09:04.717" Score="0" Body="&lt;p&gt;You're already half way there - you're sending the data from the Arduino.  All you need to do now is read up on how to use Serial in Processing (hint: Arduino is based on Processing, so you should already know most of it) in order to read what you're sending.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-13T13:09:04.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11800" PostTypeId="1" AcceptedAnswerId="11837" CreationDate="2015-05-13T13:23:45.037" Score="3" ViewCount="468" Body="&lt;p&gt;My project requires reading 5 serial devices (RFID readers) at the same time. I chose an Arduino Mega 2560 as it comes with 4 serial RX ports. For the fifth port I am using the SoftwareSerial library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My loop() checks each Serial port to detect if an RFID tag is being read. This works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am powering the board from an wall wart. When the power is disconnected the sketch no longer runs. I must unplug RX0, plug in the power supply, and reattach RX0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the board ever loses power it will have to be reset manually which is not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me understand Why is this happening? and how can I fix it?&lt;/p&gt;&#xA;" OwnerUserId="10029" LastActivityDate="2015-07-03T22:46:43.723" Title="How to avoid pulling the RX0 pin to reset sketch" Tags="|serial|arduino-mega|softwareserial|rfid|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11801" PostTypeId="2" ParentId="11798" CreationDate="2015-05-13T14:10:00.057" Score="1" Body="&lt;p&gt;Hotmail doesn't provide a non-encrypted POP3 service, which would normally run on port 110.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have no choice but to use the SSL service.  However, you can't.  Or not easily.  SSL is quite a heavy protocol and it is highly doubtful the little Uno is capable of even coming close to being able to work with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Due might have a chance, but again, unlikely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be best off using a computer (server) to check the emails for you and provide a &quot;digest&quot; of information to the Uno instead.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-13T14:10:00.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11802" PostTypeId="2" ParentId="11794" CreationDate="2015-05-13T15:04:01.740" Score="1" Body="&lt;p&gt;Try to use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Graphing sketch&#xA;&#xA;import processing.serial.*;&#xA;&#xA;Serial myPort;        // The serial port&#xA;int xPos = 1;         // horizontal position of the graph&#xA;&#xA;void setup () {&#xA;// set the window size:&#xA;size(400, 300);        &#xA;&#xA;// List all the available serial ports&#xA;println(Serial.list());&#xA;// I know that the first port in the serial list on my mac&#xA;// is always my  Arduino, so I open Serial.list()[0].&#xA;// Open whatever port is the one you're using.&#xA;myPort = new Serial(this, Serial.list()[0], 9600);&#xA;// don't generate a serialEvent() unless you get a newline character:&#xA;myPort.bufferUntil('\n');&#xA;// set inital background:&#xA;background(0);&#xA;}&#xA;void draw () {&#xA;// everything happens in the serialEvent()&#xA;}&#xA;&#xA;void serialEvent (Serial myPort) {&#xA;// get the ASCII string:&#xA;String inString = myPort.readStringUntil('\n');&#xA;&#xA;if (inString != null) {&#xA;// trim off any whitespace:&#xA;inString = trim(inString);&#xA;// convert to an int and map to the screen height:&#xA;float inByte = float(inString);&#xA;inByte = map(inByte, 0, 1023, 0, height);&#xA;&#xA;// draw the line:&#xA;stroke(127,34,255);&#xA;line(xPos, height, xPos, height - inByte);&#xA;&#xA;// at the edge of the screen, go back to the beginning: &#xA;if (xPos &amp;gt;= width) {&#xA;xPos = 0;&#xA;background(0);&#xA;}&#xA;else {&#xA;// increment the horizontal position:&#xA;xPos++;&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also look at: &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Graph&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/Graph&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8644" LastActivityDate="2015-05-13T15:04:01.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11803" PostTypeId="1" AcceptedAnswerId="11804" CreationDate="2015-05-13T15:25:00.160" Score="2" ViewCount="775" Body="&lt;p&gt;I am interested in writing a simple C program &lt;em&gt;outside&lt;/em&gt; of the Arduino IDE and respective libraries, but deploying it directly to an Arduino Due (which uses a SAM3X8E ARM MCU). I am trying to figure out what comms/serial protocols are used for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Flashing/deploying the program to the ARM MCU; and&lt;/li&gt;&#xA;&lt;li&gt;Connecting the program to a debugger&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And, not just the protocols used, but what &lt;em&gt;tools&lt;/em&gt; are compatible with these protocols, and henceforth, can be used for both use cases. How can I tell what my viable options are?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-13T15:31:59.737" Title="What protocols and tools does Arduino Due use for flashing and debugging?" Tags="|serial|arduino-due|debugging|uart|flash|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11804" PostTypeId="2" ParentId="11803" CreationDate="2015-05-13T15:31:59.737" Score="3" Body="&lt;p&gt;The Due (more specifically the SAM3X) uses its own proprietary protocol. It's all embedded in the bootloader, which is hard wired in the ROM and can never be changed (idiotic if you ask me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know of two systems for communicating with it.  Atmel's SAM-BA program, and the open source &lt;a href=&quot;http://www.shumatech.com/web/products/bossa&quot; rel=&quot;nofollow&quot;&gt;BOSSA&lt;/a&gt;.  The command line version of BOSSA (bossac) is used by the Arduino IDE for programming.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-13T15:31:59.737" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11805" PostTypeId="2" ParentId="11797" CreationDate="2015-05-13T16:05:54.417" Score="1" Body="&lt;p&gt;You do not need to use long for values from pulseIn, using int will be sufficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code is not complete, at least there is a missing '}' at the end of setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The slower the baud rate (9600) actually the more it interferes with timing code, to a point.  PWM is all timing code.  I would suggest 57,600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You never set the servos to any pins.  And is using Servo lib needed? I have always used &lt;a href=&quot;http://www.arduino.cc/en/Reference/analogWrite&quot; rel=&quot;nofollow&quot;&gt;analogWrite&lt;/a&gt; with no problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are not using parenthesis on your math (currently commented). It will not give you the result you expect. But you are somewhat on the right track, subtract 1500 from each pulse read, that will give you -/+ range. How you mix that depends on how your radio is setup (servo reversing, which channel is which). Keep in mind ailerons is 1 channel, so left aileron = -rightAileron.  Elevator up = that + elevator.  so;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;aileronLeft = airleronChannel + elevatorChannel&lt;br&gt;&#xA;aileronRight = -airleronChannel + elevatorChannel&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do realize this a &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/__6321__TURNIGY_V_Tail_Mixer_Ultra_small.html&quot; rel=&quot;nofollow&quot;&gt;$3 part&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;update: I have always used analogWrite, but I also always use good equipment. I see cautions that cheapo servos might be damaged with analogWrite. You can read more &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=5701.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. It has always worked for me.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-13T20:58:13.840" LastActivityDate="2015-05-13T20:58:13.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11806" PostTypeId="1" CreationDate="2015-05-13T17:18:35.453" Score="0" ViewCount="1405" Body="&lt;p&gt;I've been working on some software to do REALLY basic composition of music.&#xA;Here's my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;notes_sharps.h&quot;&#xA;&#xA;int notes[] = {NOTE_B0,NOTE_C1,NOTE_D1,NOTE_E1,NOTE_F1,NOTE_G1,NOTE_A1,NOTE_B1,NOTE_C2,NOTE_D2,NOTE_E2,NOTE_F2,NOTE_G2,NOTE_A2,NOTE_B2,NOTE_C3,NOTE_D3,NOTE_E3,NOTE_F3,NOTE_G3,NOTE_A3,NOTE_B3,NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5,NOTE_D5,NOTE_E5,NOTE_F5,NOTE_G5,NOTE_A5,NOTE_B5,NOTE_C6,NOTE_D6,NOTE_E6,NOTE_F6,NOTE_G6,NOTE_A6,NOTE_B6,NOTE_C7,NOTE_D7,NOTE_E7,NOTE_F7,NOTE_G7,NOTE_A7,NOTE_B7,NOTE_C8,NOTE_D8};&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;&#xA;  for(int i = 0; i &amp;lt; 51; i++){&#xA;    Serial.println(&quot;%i's sharp is %i&quot;,notes[i], notes[i]+(notes[i]*0.05937));  &#xA;  }&#xA;}&#xA;&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code just refuses to compile, no error messages, it simply leaves my computer dormant.&#xA;Here's the log:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp -o C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp.o&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10017" LastActivityDate="2015-09-10T21:42:49.147" Title="This specific code just refuses to compile?" Tags="|arduino-uno|programming|c++|compile|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11807" PostTypeId="1" CreationDate="2015-05-13T17:39:05.260" Score="0" ViewCount="170" Body="&lt;p&gt;I want to use the &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow&quot;&gt;Ino command line toolkit&lt;/a&gt; to build and upload my HEXes. It works well for the regular Arduino, however when I try to upload code to a Mini Pro 3.3V at 8 MHz, the code has the timing wrong. The serial output is garbled (I tried at different baud rates and was garbled each time) and &lt;code&gt;delay(1000);&lt;/code&gt; seems to take double the time. I have selected the correct board (pro328 in my boards.txt), but it didn't seem to make a difference in the generated code. Has anyone used this and encountered a similar problem?&lt;/p&gt;&#xA;" OwnerUserId="7699" LastEditorUserId="4628" LastEditDate="2015-12-13T17:09:55.927" LastActivityDate="2015-12-13T17:09:55.927" Title="Problem using Ino build for 8 MHz" Tags="|compile|timing|frequency|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11808" PostTypeId="1" CreationDate="2015-05-13T18:15:40.767" Score="-1" ViewCount="175" Body="&lt;p&gt;I am trying to use some Relative Humidity sensors (DHT11 and DHT22) with the ATMega1284 processor on a breadboard. I use libraries from Arduino playground (dht.h), Adafruit (DHT.h) and others. Even though both sensors and libraries work fine with Arduino Uno and Mega, they fail with ATMega1284, which produces an INVALID_VALUE error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections are double checked, and other libraries such as Wire, OneWire etc work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any experience with the ATMega1284 processor, or any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2023-02-14T14:08:56.140" Title="ATMega1284 and Relative Humidity libraries" Tags="|sensors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11809" PostTypeId="2" ParentId="11806" CreationDate="2015-05-13T18:47:38.877" Score="1" Body="&lt;p&gt;As Majenko stated in the comments, your use of the println function is not valid as there exists no overload that takes char*, int, int as parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could get your program to work by replacing your println as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 51; i++){&#xA;    Serial.print(notes[i]);&#xA;    Serial.print(&quot;'s sharp is &quot;);&#xA;    Serial.println(notes[i]+(notes[i]*0.05937));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10034" LastActivityDate="2015-05-13T18:47:38.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11810" PostTypeId="1" CreationDate="2015-05-13T19:00:04.117" Score="0" ViewCount="219" Body="&lt;p&gt;I can't use this program on my Arduino Uno since the max is 16 bits. I need my water pump to run for 5 min, then wait for 60 min.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int motorPin = A0; &#xA;int blinkPin = 13;&#xA;&#xA;int watertime = 300000; // how long to water in miliseconds&#xA;int waittime = 3600000; // how long to wait between watering&#xA;&#xA;void setup() {&#xA;    pinMode(motorPin, OUTPUT);&#xA;    pinMode(blinkPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(motorPin, HIGH);&#xA;    digitalWrite(blinkPin, HIGH);&#xA;    delay(watertime);&#xA;    digitalWrite(motorPin, LOW);&#xA;    digitalWrite(blinkPin, LOW);&#xA;    delay(waittime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Changed int to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define watertime 300000&#xA;#define waittime 3600000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it does not work.&lt;/p&gt;&#xA;" OwnerUserId="10035" LastEditorUserId="4628" LastEditDate="2017-01-09T09:10:22.340" LastActivityDate="2017-01-09T09:10:51.047" Title="Need help rewriting a program" Tags="|arduino-uno|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11811" PostTypeId="2" ParentId="11810" CreationDate="2015-05-13T19:06:51.527" Score="5" Body="&lt;p&gt;Use the &lt;code&gt;long&lt;/code&gt; type instead&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long watertime = 300000; // how long to water in miliseconds&#xA;long waittime = 3600000; // how long to wait between watering&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-13T19:06:51.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11813" PostTypeId="2" ParentId="11810" CreationDate="2015-05-13T20:29:28.410" Score="0" Body="&lt;p&gt;If did not misunderstand, you want a longer delay. Why don't you use a for loop in order to obtain such a delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 50; i++) {&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This produces 50 seconds instead of 1 second. You can replace 1000 and 50 according to your needs. This is just an example.&lt;/p&gt;&#xA;" OwnerUserId="1052" LastEditorUserId="4628" LastEditDate="2017-01-09T09:10:51.047" LastActivityDate="2017-01-09T09:10:51.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11814" PostTypeId="2" ParentId="9731" CreationDate="2015-05-13T20:32:11.710" Score="2" Body="&lt;p&gt;Two thing that may be helpful.&#xA;First make sure you have a common ground. For instance for you transistor you are using separate power from the arduino and 12 volt source. Connecting the two ground of the arduino and the power supply may resolve this for you.&#xA;The other thing is it is often times helpful to put a capacitor across the DC motor to help with voltage fluctuations. &lt;/p&gt;&#xA;" OwnerUserId="9908" LastActivityDate="2015-05-13T20:32:11.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11815" PostTypeId="2" ParentId="11810" CreationDate="2015-05-13T22:38:23.453" Score="2" Body="&lt;p&gt;For any delays longer than a few seconds you really need to use a Real-Time Clock chip, like the popular DS1307 from Maxim. The Arduino's delay() function is only very roughly accurate, and even less so when used as you are using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't get a DS1307 or something similar (there's plenty to choose from) or you Arduino has too much connected already to allow anything else to be added, you could use the &lt;code&gt;Time&lt;/code&gt; library to simulate one.  The &lt;code&gt;Time&lt;/code&gt; library is also useful if you do have an RTC attached.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/code/time&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/code/time&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-13T22:38:23.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11816" PostTypeId="2" ParentId="11810" CreationDate="2015-05-13T23:25:23.690" Score="0" Body="&lt;p&gt;I do not know if you plan on doing anything else on your arduino, but holding a delay inside the loop function is bad idea if you do, things need to happen outside of your code (any serial I/O for sure and others, right?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I like @zgrknr answer the best, although the others will also work. That answer allows using smaller numbers, that are easier to understand. Just make sure to keep your variables global, and not within loop or else they will get re-initialized every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as accuracy, do some real by the clock testing, and adjust your numbers, who cares if it is accurately counting as long as you can identify what numbers gives you the time period you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;response to comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My firmware code looks like this, is yours different?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(void)&#xA;{&#xA;  init();&#xA;  initVariant();&#xA;&#xA;#if defined(USBCON)&#xA;  USBDevice.attach();&#xA;#endif&#xA;&#xA;  setup();&#xA;&#xA;  for (;;) {&#xA;    loop();&#xA;    if (serialEventRun) serialEventRun();&#xA;  }        &#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-13T23:54:21.247" LastActivityDate="2015-05-13T23:54:21.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11817" PostTypeId="2" ParentId="11783" CreationDate="2015-05-14T00:20:37.590" Score="1" Body="&lt;p&gt;That's interesting but after using a different library the code worked out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has to follow exactly what the datasheet says in order to get things done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following source code makes it and get the airspeed from the sensor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SENSOR_ADDRESS 0xEA &#xA;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;I2cMaster.h&amp;gt; &#xA;TwiMaster AIRSPEED_SENSOR(true); &#xA;&#xA;void setup() { &#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;long airspeed_update(void) { &#xA;  static struct { &#xA;    union { int16_t val; uint8_t raw[2]; &#xA;    } airspeed16; &#xA;  } airspeedv3; &#xA;&#xA;  long airsp;    &#xA;&#xA;  if(AIRSPEED_SENSOR.start(SENSOR_ADDRESS | I2C_WRITE)) { &#xA;    delay(10);   &#xA;    AIRSPEED_SENSOR.write(0x07);  &#xA;    delay(10); &#xA;    AIRSPEED_SENSOR.stop(); &#xA;  } &#xA;&#xA;  if(AIRSPEED_SENSOR.restart(SENSOR_ADDRESS | I2C_READ)) { &#xA;    delay(10);  &#xA;    airspeedv3.airspeed16.raw[0]=AIRSPEED_SENSOR.read(false); &#xA;    delay(10); &#xA;    airspeedv3.airspeed16.raw[1]=AIRSPEED_SENSOR.read(true); &#xA;    delay(10); &#xA;    AIRSPEED_SENSOR.stop();&#xA;  } &#xA;&#xA;  airsp=airspeedv3.airspeed16.val; &#xA;  return airsp; &#xA;}&#xA;&#xA;void loop() {    &#xA;  int airspeed = airspeed_update(); Serial.println(airspeed); &#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get this library from &lt;a href=&quot;https://github.com/landis/arduino/tree/master/libraries/I2cMaster&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-14T00:20:37.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11818" PostTypeId="1" CreationDate="2015-05-14T00:21:08.587" Score="1" ViewCount="5327" Body="&lt;p&gt;Hello guys (and gals)!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out how to program thresholds using my arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, to make this as simple as possible, this is what I have going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sampling a value every one second, I am taking the value and trying to make certain actions occur based on when this value crosses certain thresholds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value read every second will be a value between 0-150.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thresholds will work something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If value crosses over 20 and becomes 20 or higher, do an action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If value crosses over 20 and becomes 19.9 or less, do a different action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then do the same for a threshold at 30, 40, 50, and 65.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would need to have it so that if it reads a value of 15, and then a second later, reads a value of 23, it does an action. But if it reads 23, and then reads 24 a next, it needs to not do anything because it hasn't crossed over from one threshold to another. I only want an action to perform if a threshold is crossed either by increasing or decreasing past it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So again, to reiterate; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If first value read is 34, and second is 42, do an action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If first value is read at 57, and second at 44, do an action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If first value is 24, and second value is 26, do nothing. (no threshold was crossed)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next part would be figured out if a threshold was crossed twice, or more, to do that action twice or more times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice on how to code this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="10039" LastActivityDate="2016-04-10T05:49:21.443" Title="How to program thresholds?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ClosedDate="2021-11-14T15:56:23.850" ContentLicense="CC BY-SA 3.0" />
  <row Id="11819" PostTypeId="2" ParentId="11818" CreationDate="2015-05-14T03:09:27.417" Score="0" Body="&lt;p&gt;The way you described it, the first and good solution I can approach it is &lt;a href=&quot;http://en.m.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;state machine.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a lot of thresholds to check and very specific details such as going up at some level and doing something or nothing depending on the level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I advise you is creating the state machine for you code setting up all the thresholds and saving the actual &lt;em&gt;state&lt;/em&gt; of your system into a variable. After you have this set up, coding is just a matter of switch/cases or if statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example. The first part is to check if it goes until 20 and then keep with at least 20.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (state) {&#xA;    case 1:&#xA;        if (value &amp;gt;= 20 &amp;amp;&amp;amp; value &amp;lt; 30)&#xA;             state = 2;&#xA;        break;&#xA;     case 2:&#xA;        if (value &amp;lt; 20)&#xA;             state = 1;  // initial state&#xA;        else if (value &amp;gt;= 20 &amp;amp;&amp;amp; value &amp;lt; 30)&#xA;             state = 3; // or call a function&#xA;        break;&#xA;     case 3:&#xA;          doSomething();&#xA;          break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you could have some delay or timer interrupt to check the value each 1s and repeat the state machine again and again. If you change or read the value inside an interrupt function call, make sure you declare the variable as &lt;strong&gt;volatile&lt;/strong&gt; otherwise the compiler will optimize it and your machine won't work properly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you can expand the idea and have all the thresholds set up. &lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-14T03:09:27.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11820" PostTypeId="1" CreationDate="2015-05-14T04:13:26.540" Score="1" ViewCount="3649" Body="&lt;p&gt;I've created a circuit to turn on bulb using GSM module and Arduino. I want a mechanism(or programming) to know whether the bulb is on or off or fused. I've tried taking the input from the pins. But it only tells whether the pin is on or off but not the circuit as a whole. &lt;/p&gt;&#xA;" OwnerUserId="10040" LastActivityDate="2016-06-13T07:03:32.957" Title="How can I programming detect that a Bulb/LED is ON/OFF or a circuit is working as expected using Arduino?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11821" PostTypeId="1" AcceptedAnswerId="11825" CreationDate="2015-05-14T08:04:02.643" Score="6" ViewCount="263" Body="&lt;p&gt;I've written a simple program - it generates signals over &lt;code&gt;Port D&lt;/code&gt; at 4 MHz:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main(void) {&#xA;&#xA;    DDRD = B11111111;&#xA;    PORTD = B00000000;&#xA;&#xA;    while (true) {&#xA;        PORTD = 0;&#xA;        PORTD = 5;&#xA;        PORTD = 10;&#xA;        PORTD = 15;&#xA;        PORTD = 20;&#xA;        PORTD = 25;&#xA;        PORTD = 30;&#xA;        PORTD = 35;&#xA;        PORTD = 40;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is the signal coming out on D4:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/O3IfR.jpg&quot; alt=&quot;Max Frequency&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified the program by inserting NOP after each assignment to &lt;code&gt;POTRD&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NOP __asm__ __volatile__ (&quot;nop\n\t&quot;)&#xA;&#xA;int main(void) {&#xA;&#xA;    DDRD = B11111111;&#xA;    PORTD = B00000000;&#xA;&#xA;    while (true) {&#xA;        PORTD = 0;NOP;&#xA;        PORTD = 5;NOP;&#xA;        PORTD = 10;NOP;&#xA;        PORTD = 15;NOP;&#xA;        PORTD = 20;NOP;&#xA;        PORTD = 25;NOP;&#xA;        PORTD = 30;NOP;&#xA;        PORTD = 35;NOP;&#xA;        PORTD = 40;NOP;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now signal looks fine, but frequency is limited to 800 KHz:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/gKU53.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason for interference at 4 MHz? Is there a limitation to maximal frequency on digital out? I do not really need it for some particular project, just wanted to know it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've asked this question on &lt;a href=&quot;https://stackoverflow.com/questions/30201318/disturbed-digital-out-at-4mhz-on-arduino-nano&quot;&gt;stackoverflow&lt;/a&gt;, but then I've discovered this dedicated forum so... I've decided to try it out ;)&lt;/p&gt;&#xA;" OwnerUserId="10045" LastEditorUserId="84" LastEditDate="2015-05-14T08:57:55.663" LastActivityDate="2015-05-14T12:54:12.750" Title="Disturbed digital out at 4Mhz on Arduino NANO" Tags="|arduino-uno|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11822" PostTypeId="2" ParentId="9677" CreationDate="2015-05-14T08:19:00.473" Score="1" Body="&lt;p&gt;It seems that you're trying to do the same thing:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=q02f4sPghSo&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=q02f4sPghSo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Maybe it will help, I'm tryin' to do that (a POST), only that I don't have the server on a text file.&lt;/p&gt;&#xA;" OwnerUserId="10046" LastActivityDate="2015-05-14T08:19:00.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11823" PostTypeId="1" CreationDate="2015-05-14T09:34:45.260" Score="1" ViewCount="12444" Body="&lt;p&gt;I have several Arduinos connected to my Windows PC, and they appear as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;COM7 (Arduino Uno)&lt;br&gt;&#xA;  COM11 (Arduino Uno)&lt;br&gt;&#xA;  COM13 (Arduino Uno)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So there's no way to tell which is which, and when I want to upload a sketch to one, I have to unplug the others to make sure my code goes to the right one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to change the &quot;Arduino Uno&quot; description?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I found a similar question but that was about Mac specifically).&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-14T13:39:29.563" Title="Can I change the USB device name of Arduino?" Tags="|serial|usb|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11824" PostTypeId="1" AcceptedAnswerId="11827" CreationDate="2015-05-14T11:10:23.023" Score="42" ViewCount="46936" Body="&lt;p&gt;Recently I have noticed that there are two arduino sites, arduino.cc and arduino.org.  They both have the Arduino logo and both sell what seems to be official Arduino boards. Also, arduino.org came out with the Arduino Zero board first. What is the deal here? Has Arduino partnered with another site? Any ideas appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2018-07-31T20:51:26.163" Title="Difference between Arduino.cc and Arduino.org" Tags="|hardware|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11825" PostTypeId="2" ParentId="11821" CreationDate="2015-05-14T11:23:09.547" Score="1" Body="&lt;p&gt;This is not a limitation of the Arduino: you can toggle a pin on every clock cycle. It's a synchronization problem between the generated signal and the triggering of the scope. Your scope displays several traces superimposed, and it synchronizes them on the rising edges, but since those are unequally spaced, it gets out of sync with the full period of the signal. By adding a few nops you reached a lucky synchronization in your second version of the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution is to set the scope mode to &lt;em&gt;Single&lt;/em&gt; instead of &lt;em&gt;Normal&lt;/em&gt;. Then it only displays a single trace and synchronization is not an issue anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use one of the bits of &lt;code&gt;PORTD&lt;/code&gt; as a trigger&#xA;signal. This bit should cycle only once inside the loop. &lt;code&gt;PD5&lt;/code&gt; should&#xA;work in the current version of your code. Configure the scope for&#xA;external trigger and feed this signal into its TRIG input.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-05-14T12:19:00.123" LastActivityDate="2015-05-14T12:19:00.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11826" PostTypeId="2" ParentId="11824" CreationDate="2015-05-14T11:28:33.000" Score="14" Body="&lt;p&gt;This article can explain it better than I could paraphrase:&#xA;&lt;a href=&quot;http://hackaday.com/2015/02/25/arduino-v-arduino/&quot; rel=&quot;noreferrer&quot;&gt;http://hackaday.com/2015/02/25/arduino-v-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Relevant excerpt:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Arduino LLC [&lt;em&gt;&lt;strong&gt;arduino.cc&lt;/strong&gt;&lt;/em&gt;] is the company founded by Massimo Banzi, David Cuartielles, David Mellis, Tom Igoe and Gianluca Martino in 2009 and is the owner of the Arduino trademark and gave us the designs, software, and community support that’s gotten the Arduino where it is. The boards were manufactured by a spinoff company, Smart Projects Srl, founded by the same Gianluca Martino. So far, so good.&lt;/p&gt;&#xA;&lt;p&gt;Things got ugly in November when Martino ... renamed Smart Projects to Arduino Srl and registered &lt;em&gt;&lt;strong&gt;arduino.org&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;According to this &lt;a href=&quot;http://www.wired.it/gadget/computer/2015/02/12/arduino-nel-caos-situazione/&quot; rel=&quot;noreferrer&quot;&gt;Italian Wired article&lt;/a&gt;, the cause of the split is that Banzi and the other three wanted to internationalize the brand and license production to other firms freely, while Martino ... [wanted] to list on the stock market and keep all production strictly in the Italian factory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-14T14:23:58.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11827" PostTypeId="2" ParentId="11824" CreationDate="2015-05-14T11:30:49.803" Score="43" Body="&lt;p&gt;The short of it is that there was a falling out within the Arduino people and now &lt;a href=&quot;http://hackaday.com/2015/03/28/arduino-srl-to-distributors-were-the-real-arduino/&quot;&gt;there are two groups laying claim to the &quot;Arduino&quot; name.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino LLC runs arduino.cc. They are the steward of the Arduino IDE and libraries and own the &quot;Arduino&quot; trademark in the United States, and also owns the &quot;Genuino&quot; trademark outside of the United States. Arduino SRL (fka Smart Projects SRL) is the company that assembles(assembled) the majority of Arduino boards for Arduino LLC, runs arduino.org, and owns the &quot;Arduino&quot; trademark inside Italy and all of the other countries they have registered the &quot;Arduino&quot; trademark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino SRL recently decided that they are no longer beholden to Arduino LLC and has stopped paying licensing fees for using the Arduino name. Whether this is justified or not has not been fully tested in court yet.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="3022" LastEditDate="2016-03-09T23:18:52.077" LastActivityDate="2016-03-09T23:18:52.077" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11828" PostTypeId="2" ParentId="11676" CreationDate="2015-05-14T12:39:06.837" Score="0" Body="&lt;p&gt;The basic EEPROM write, each 1 byte, as is mentioned in the above answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.hobbytronics.co.uk/arduino-external-eeprom&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/arduino-external-eeprom&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PAGE WRITE which is suitable for this situation. One can easily read 32 bytes for a dot matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.hobbytronics.co.uk/eeprom-page-write&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/eeprom-page-write&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9953" LastActivityDate="2015-05-14T12:39:06.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11830" PostTypeId="2" ParentId="11821" CreationDate="2015-05-14T12:54:12.750" Score="1" Body="&lt;p&gt;Thank you - correct trigger solves my problem:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/VFWpu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10045" LastActivityDate="2015-05-14T12:54:12.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11831" PostTypeId="2" ParentId="11820" CreationDate="2015-05-14T13:14:59.777" Score="1" Body="&lt;p&gt;This can be done using a few methods.  The simplest and least expensive option is to measure the current consumption of the device you want to verify correct operation of, and see if it's using enough, but not too much, current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the following would work well in the arduino case of using an LED:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7ySWi.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f7ySWi.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the &lt;code&gt;Power&lt;/code&gt; to 5V or to the pin you're controlling the LED with. Connect the &lt;code&gt;Sense&lt;/code&gt; to an analog input such as A0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the LED isn't installed, or is broken as an open circuit, the sense would register 5V.  If the LED is broken as a shorted element, the sense would register 0v. If the LED is operating correctly, you would sense the voltage drop of the LED (which varies according to the LED's design), but it would be well above 0V and well below 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For bulbs and other loads, use a much smaller resister for R1 (so the resistor doesn't affect the load as much) and it would be considered a current shunt.  Knowing the resister value, and the voltage at the &lt;code&gt;Sense&lt;/code&gt; location will give you a current value using &lt;code&gt;Current = Voltage / Resistance&lt;/code&gt;. Again, the load should be drawing current within an acceptable range during proper operation.  If it's not drawing enough current, or too much current, it may not be operating correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This won't tell you if the LED is on, however it's a very reliable method to discover if it's working correctly, and you'll probably never run into a situation where the correct LED is installed and in the right current range, but not emitting light.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-05-14T13:14:59.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11832" PostTypeId="2" ParentId="11807" CreationDate="2015-05-14T13:30:02.527" Score="1" Body="&lt;p&gt;Per the &lt;a href=&quot;http://inotool.org/quickstart&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quick start guide&lt;/a&gt;, Ino assumes the board is an Arduino Uno unless otherwise specified on the command line:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;All examples were done in assumption that you have Arduino Uno and it is available on default port. Now consider you have Arduino Mega 2560 and it is available on port &lt;code&gt;/dev/ttyACM1&lt;/code&gt;. We have to specify this for our build steps as command-line switches.&lt;/p&gt;&#xA;&lt;p&gt;Board model may be set with &lt;code&gt;--board-model&lt;/code&gt; or &lt;code&gt;-m&lt;/code&gt; switch. Port is set with &lt;code&gt;--serial-port&lt;/code&gt; or &lt;code&gt;-p&lt;/code&gt; switch. So lets do it:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ino build -m mega2560&#xA;$ ino upload -m mega2560 -p /dev/ttyACM1&#xA;$ ino serial -p /dev/ttyACM1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For the full list of board names refer to &lt;code&gt;ino build --help&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So you might be able to do this by using&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ ino build -m pro328&#xA;$ ino upload -m pro328 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However I don't know what options Ino includes for boards (presumably it uses the boards file), so using &lt;code&gt;ino build --help&lt;/code&gt; should give you the information you need to select a suitable board if &lt;code&gt;pro328&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;&lt;p&gt;Once that's done, the frequency setting should be taken care of for you.&lt;/p&gt;&#xA;" OwnerUserId="349" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-14T13:30:02.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11833" PostTypeId="2" ParentId="11823" CreationDate="2015-05-14T13:39:13.513" Score="2" Body="&lt;p&gt;You'll have to change the software on the Arduino USB chip itself, and you may need to modify the drivers for the Arduino USB interface on the computer side.  It's not trivial, and probably not worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Windows attempts to use the same serial port for the same devices in the same USB positions, so if you figure out which is which (blinking the LED at different frequencies) then you can mark the USB port itself with the com number that Windows uses when you plug an arduino into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a hub, and you move that hub to a different port, the com numbers will change, but if you keep it in the same port, then it too will try to have them match what they have been in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's an annoyance, but it's a design decision by arduino.cc.  The old FTDI chips kept their assigned com port numbers because they have individual serial numbers and windows would attempt to reassign the same com port to the same chip each time it was plugged in, regardless of its location.  When Arduino.cc moved to a programmed MCU for the USB interface, they chose not to provide USB serial numbers, and thus windows has little option but to try to keep things straight by determining the location in the USB hierarchy that the device is connected, and try to keep com port assignments the same using that method.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-05-14T13:39:13.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11834" PostTypeId="2" ParentId="11823" CreationDate="2015-05-14T13:39:29.563" Score="0" Body="&lt;p&gt;I have never tried it, but I suspect using zadig might work;&#xA;&lt;a href=&quot;http://zadig.akeo.ie/&quot; rel=&quot;nofollow&quot;&gt;http://zadig.akeo.ie/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It lets you pick the driver and name for WinUSB and LibUSB devices.  Uninstall any existing driver first. And remember to pick the driver you wish to use when it asks. Also it is not real apparent, but you can edit the name of the device as it installs the driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us know if it works&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-14T13:39:29.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11835" PostTypeId="2" ParentId="11808" CreationDate="2015-05-14T13:50:58.603" Score="0" Body="&lt;p&gt;Per the library instructions, you will receive &lt;code&gt;INVALID_VALUE&lt;/code&gt; in the following situations:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;code&gt;readXX()&lt;/code&gt; functions return:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;DHTLIB_OK&lt;/code&gt; (0) : if the sensor sample and its checksum is OK.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;DHTLIB_ERROR_CHECKSUM&lt;/code&gt; (-1) : if the checksum test failed. This means that data was received but may be incorrect.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;DHTLIB_ERROR_TIMEOUT&lt;/code&gt; (-2) : if a timeout occured, communication failed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In case of a &lt;code&gt;DHTLIB_ERROR_TIMEOUT&lt;/code&gt;, humidity and temperature will both get the value &lt;code&gt;DHTLIB_INVALID_VALUE&lt;/code&gt;. In case of &lt;code&gt;DHTLIB_ERROR_CHECKSUM&lt;/code&gt; the values of humidity and temperature are left unchanged as it is impossible to determine which byte failed in the checksum. It is up to the programmer to decide what to do. One can compare with previous value, but better reread the sensor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So read the value returned by the &lt;code&gt;read11()&lt;/code&gt; or &lt;code&gt;read22()&lt;/code&gt; functions to verify that it's an &lt;code&gt;DHTLIB_ERROR_TIMEOUT&lt;/code&gt; condition, and if so try to figure out why the library is having trouble talking to the device.&lt;/p&gt;&#xA;" OwnerUserId="349" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-14T13:50:58.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11836" PostTypeId="2" ParentId="9543" CreationDate="2015-05-14T13:53:02.710" Score="0" Body="&lt;p&gt;I can say from personal experience, I had a similar event. I had a logic analyzer hooked up and was using it. I got the code working the way I wanted.  A day later when I tried it the code failed.  Turned to be because I had not powered up the logic analyzer and it was still hooked up.  If I unhooked it or powered it on everything worked fine.  This was on an Netduino BTW, but it leads me to believe (not being an electronics person per se) that yes it very possible if some unexpected load is on the I2C bus.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-14T13:53:02.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11837" PostTypeId="2" ParentId="11800" CreationDate="2015-05-14T13:59:19.680" Score="1" Body="&lt;p&gt;It looks like your RFID readers are very chatty on startup, and the board is going into bootloader mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd consider either controlling the RFID reader's power using another pin (and a transistor or mosfet if the reader needs more than 20mA), or using a gate ( &lt;code&gt;AND&lt;/code&gt; for instance, or a simple switch IC like the 4066) that you can control to disable the &lt;code&gt;RX0&lt;/code&gt; input until program start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing I've done in the past is multiplexed multiple serial devices to one serial input.  The RFID readers probably have outputs that indicate a card presence, so use those and a multiplexor.  When the card presence is indicated, connect that serial port using the multiplexor, read the card and act accordingly, then wait for another card detect event.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-05-14T13:59:19.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11838" PostTypeId="2" ParentId="11657" CreationDate="2015-05-14T14:10:52.727" Score="0" Body="&lt;p&gt;Another problem here is when running a motor you want to include a 'flyback diode' to prevent damage from voltage spikes, which is a problem with loads like motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.nerdkits.com/videos/motors_and_microcontrollers_101/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; for details.&lt;/p&gt;&#xA;" OwnerUserId="3004" LastActivityDate="2015-05-14T14:10:52.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11839" PostTypeId="2" ParentId="11624" CreationDate="2015-05-14T14:11:44.980" Score="1" Body="&lt;p&gt;It is a &quot;hardware bug&quot; as you so aptly put it. As far as I know, the only way to get the CC3000 board to use pin 2 as the IRQ is to physically rewire the connections. I did exactly that on my board and it works without a problem, leaving pin 3 free to use for whatever else you want. You can see what I did &lt;a href=&quot;https://arduino.stackexchange.com/questions/9740/arduino-motor-shield-and-adafruit-cc3000-wifi-shield-compatibility&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&#xA;It basically involves cutting the trace wire and running a jumper cable between the holes next to the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important thing to understand perhaps is that pins 2 and 3 are available to use for IRQ on the Mega and Uno, but it is an actual dedicated pin on the CC3000, hence why you have to go to this effort to change it. Also remember that once you have cut the trace to pin 3 it becomes an open/free pin and is no longer connected to the wifi shield. By the sounds of your requirements this shouldn't matter, but it is still useful to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you haven't already, I recommend that you read the &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-cc3000-wifi.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation for the CC3000 board&lt;/a&gt;, as it really helped me understand the irritating intricacies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But yeah, if you choose to follow this and reroute the pin, it works perfectly. Hope this helps, even if it is a bit late.&lt;/p&gt;&#xA;" OwnerUserId="454" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-05-14T14:11:44.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11840" PostTypeId="1" AcceptedAnswerId="11841" CreationDate="2015-05-14T15:04:15.743" Score="0" ViewCount="2768" Body="&lt;p&gt;I am interested in writing a simple Arduino program that will turn a servo back and forth (180 degrees each time) continuously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking at &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00KA393PK&quot; rel=&quot;nofollow&quot;&gt;these servos&lt;/a&gt; and am planning on following &lt;a href=&quot;http://playground.arduino.cc/ComponentLib/servo&quot; rel=&quot;nofollow&quot;&gt;this example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being so new to Arduino, I first wanted to confirm that the &lt;code&gt;SoftwareServo&lt;/code&gt; library in that example will drive those particular servos. If it will not, then can someone begin by explaining to me &lt;em&gt;why&lt;/em&gt; these servos are incompatible with the lib?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming they are compatible, I am looking at the main example on that page (comments stripped out for brevity):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareServo.h&amp;gt; &#xA;&#xA;SoftwareServo myservo;&#xA;&#xA;int potpin = 0;&#xA;int val;&#xA;&#xA;void setup() { &#xA;    myservo.attach(2);&#xA;} &#xA;&#xA;void loop() { &#xA;    val = analogRead(potpin);&#xA;    val = map(val, 0, 1023, 0, 179);&#xA;    myservo.write(val);&#xA;    delay(15);&#xA;&#xA;    SoftwareServo::refresh();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My concerns:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There seem to be 3 pins involved here: a potentiometer pin (&lt;code&gt;0&lt;/code&gt;), an analog pin (&lt;code&gt;val&lt;/code&gt;) and a servo pin (&lt;code&gt;2&lt;/code&gt;). What is the purpose of each of these pins, and is this 3-pin wiring common across all/most servos?&lt;/li&gt;&#xA;&lt;li&gt;Is there anything &quot;wrong&quot; with defining &lt;code&gt;myservo.attach(2);&lt;/code&gt; up &lt;em&gt;above&lt;/em&gt; the &lt;code&gt;setup&lt;/code&gt; function, and leave the &lt;code&gt;setup&lt;/code&gt; function an empty no-op function?&lt;/li&gt;&#xA;&lt;li&gt;Where does the &lt;code&gt;map(...)&lt;/code&gt; function come from? If it was defined inside &lt;code&gt;SoftwareServo&lt;/code&gt; I would have expected its usage to be something like &lt;code&gt;SoftwareServo::map(...)&lt;/code&gt;, etc.&lt;/li&gt;&#xA;&lt;li&gt;Why do we need the &lt;code&gt;delay&lt;/code&gt; after calling &lt;code&gt;myservo.write(val);&lt;/code&gt;? What would happen if this delay wasn't in there?&lt;/li&gt;&#xA;&lt;li&gt;According to that link, calling &lt;code&gt;SoftwareServo::refresh()&lt;/code&gt; once every 50ms is necessary in order to: &quot;&lt;em&gt;keep your servos updating.&lt;/em&gt;&quot; &lt;strong&gt;But what does this mean, really?&lt;/strong&gt; Updating to what?!?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-05-14T15:56:04.153" Title="Arduino SoftwareServo by example" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11841" PostTypeId="2" ParentId="11840" CreationDate="2015-05-14T15:27:54.353" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;There seem to be 3 pins involved here: a potentiometer pin (0), an analog pin (val) and a servo pin (2). What is the purpose of each of these pins, and is this 3-pin wiring common across all/most servos?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, there is only 2 pins.  The value of the potentiometer attached to pin 0 is read and stored in the variable &lt;code&gt;val&lt;/code&gt;.  That is then used to set the angle of the servo motor on pin 2.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there anything &quot;wrong&quot; with defining myservo.attach(2); up above the setup function, and leave the setup function an empty no-op function?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.  It'll never get called.  &lt;code&gt;setup()&lt;/code&gt; is the first function to be called and its purpose is to perform any initialization routines, such as attaching the servo code to the pin the servo is connected to.  So you &lt;em&gt;have&lt;/em&gt; to call that either from &lt;code&gt;setup()&lt;/code&gt; or from a function which &lt;code&gt;setup()&lt;/code&gt; itself calls.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Where does the map(...) function come from? If it was defined inside SoftwareServo I would have expected its usage to be something like SoftwareServo::map(...), etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;map()&lt;/code&gt; is part of the standard Arduino API.  &lt;a href=&quot;http://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/Map&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why do we need the delay after calling myservo.write(val);? What would happen if this delay wasn't in there?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't need the &lt;code&gt;delay()&lt;/code&gt; call, but you don't want to set the value of the servo too rapidly.  You really want to allow at least one PWM cycle between each call to ensure the values have been set properly.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;According to that link, calling SoftwareServo::refresh() once every 50ms is necessary in order to: &quot;keep your servos updating.&quot; But what does this mean, really? Updating to what?!?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SoftwareServo is just what it says - a piece of software.  You have to run that software for it to work, and the &lt;code&gt;refresh()&lt;/code&gt; function is that bit that you run.  If you don't call that then the PWM signal for the servo will never get generated and nothing will happen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and yes those little servos should be fine.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-14T15:56:04.153" LastActivityDate="2015-05-14T15:56:04.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11842" PostTypeId="2" ParentId="11840" CreationDate="2015-05-14T15:31:02.097" Score="1" Body="&lt;p&gt;1- there is only two pins a servo pin which is D2 and an analog pin which is A0. D2 pin for writing analog value to servo. D2 pin is used for getting analog pin value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- map function is a default function like sin, cos or digitalRead so library inport not necesary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3- delay function and waiting 50ms is used to wait servo response time. if you change servo angle too quickly servo will not respond accurately &lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-05-14T15:31:02.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11843" PostTypeId="2" ParentId="11778" CreationDate="2015-05-14T16:34:39.977" Score="2" Body="&lt;p&gt;The LCD library provides easy functions that activate commands in the LCD itself.  The LCD doesn't have functions that do what you want, so there is no simple vertical scrolling like you're suggesting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to have it, you'll need to re-write the screen with the content you want to display when the user scrolls around. I can't make any specific suggestions as I don't know the reason you need to scroll around the display this way, but one comprehensive method would be to create a buffer of data the LCD should be displaying, then scroll it using software (move the bytes around the way you want) and then send that buffer to the LCD when it changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be other more applicable or easier tricks, but that would largely depend on your specific use case and user interface design.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-05-14T16:34:39.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11844" PostTypeId="2" ParentId="11761" CreationDate="2015-05-14T16:45:53.307" Score="1" Body="&lt;p&gt;When you connect your arduino directly to the PC using the ethernet cable, neither of them have any information about the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most ethernet devices attach to switches, routers, and gateways, and one or more of these devices host network services such as DHCP, DNS, or provide a way to obtain those services.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without DHCP, for instance, neither your PC nor the Arduino know what IP adress to use, what their netmask is, and whether there's a gateway to other IP addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a few options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Follow the &lt;a href=&quot;https://support.microsoft.com/en-us/kb/220874&quot; rel=&quot;nofollow&quot;&gt;Automatic Private IP Addressing&lt;/a&gt; specification, which windows computers default to when no DHCP server is present or available. Set the IP address of the Arduino to 169.254.x.y where x and y are randomly chosen numbers between 0 and 255, and set th netmask to 255.255.0.0.  The windows computer should have done the same if no static IP address was set - use &lt;code&gt;ipconfig&lt;/code&gt; on the windows command prompt to find its IP address.  Your computer and arduino should be able to talk to each other.&lt;/li&gt;&#xA;&lt;li&gt;Set up a router. It doesn't need to connect to the internet, it just needs to connect to both the PC and the Arduino.  It'll implement a DHCP server and make sure, at minimum, that the two devices can talk to each other and the router.&lt;/li&gt;&#xA;&lt;li&gt;Set static IP addresses on both devices.  Set up the PC with something like 192.168.42.1 with a netmask of 255.255.0.0 and the Arduino with 192.168.42.2 and the same netmask.  Now they should be able to talk to each other.&lt;/li&gt;&#xA;&lt;li&gt;Connect both to an existing network.  The network should already have a router with DHCP on it, so it'll take care of everything, and as a bonus you may be able to get internet access as well, which could help with testing since you can use the ethernet shield to communicate with google and other known working services, rather than trying to set up a server on the PC.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-05-14T16:45:53.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11845" PostTypeId="1" CreationDate="2015-05-14T16:46:16.863" Score="2" ViewCount="1057" Body="&lt;p&gt;I am using an Arduino with 2048 bytes of SRAM. I have a complex project so that it is no longer obvious how much SRAM it would use in total (there is not one large dominant object but many different routines, many libraries most of which I have not written myself etc. Each of these uses some small buffers, global variables etc.). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I determine how much SRAM I have left in the live system?&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-14T17:55:34.960" Title="Measure SRAM usage" Tags="|memory-usage|sram|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11846" PostTypeId="1" AcceptedAnswerId="11847" CreationDate="2015-05-14T16:57:34.770" Score="4" ViewCount="177" Body="&lt;p&gt;If I use &lt;code&gt;EEPROM.write(someAddr, someValue)&lt;/code&gt; to write a value to an address, how long will that value &quot;stick&quot; to that address before being lost?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were to power down the Arduino, flash a whole new program to it, and power it on, could I still retrieve that old/cached value written from the previous program?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2016-09-03T15:55:06.703" Title="Is EEPROM persisted across program flashes?" Tags="|eeprom|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11847" PostTypeId="2" ParentId="11846" CreationDate="2015-05-14T17:15:53.240" Score="2" Body="&lt;p&gt;Only if the &lt;code&gt;EESAVE&lt;/code&gt; fuse is programmed (it is unprogrammed by default). If not then the EEPROM will be erased when a chip erase command is performed.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-05-14T18:25:30.030" LastActivityDate="2015-05-14T18:25:30.030" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11848" PostTypeId="2" ParentId="11845" CreationDate="2015-05-14T17:55:34.960" Score="5" Body="&lt;p&gt;Expanding on my previous comment... The RAM memory map of an AVR-based&#xA;Arduino looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;┌──────┬─────┬──────┬──────────┬───────┐&#xA;│ data │ bss │ heap │→  free  ←│ stack │&#xA;└──────┴─────┴──────┴──────────┴───────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The data and bss sections are fixed, and their size can be known at&#xA;compile time. However, the stack and the heap grow and shrink&#xA;dynamically as the program runs. You can estimate the amount of free&#xA;memory at run time by measuring the gap between the heap and the stack.&#xA;The result may be pessimistic if the heap contains usable holes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory&quot; rel=&quot;noreferrer&quot;&gt;a very simple function&lt;/a&gt; that does exactly that, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/AvailableMemory&quot; rel=&quot;noreferrer&quot;&gt;a more complex version&lt;/a&gt; that also counts the holes in the heap.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-14T17:55:34.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11850" PostTypeId="1" CreationDate="2015-05-14T19:31:14.620" Score="1" ViewCount="2874" Body="&lt;p&gt;I am trying to make a connection between 2 Arduino's with the APC220 rf modules.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;   int value = 5;&#xA;   Serial.println(value);&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I uploaded this code to my Arduino Nano and Uno. I disconnected the rf modules for uploading the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to run this program with an external power source (lipo 11.1V 2200mAh).&#xA;The Arduino is powered on(power led is on) BUT the tx led doesn't blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to make it work is by using the usb and opening the serial monitor on my pc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use a 10k resistor between tx and rx (or rx to ground) but the code won't run...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution : the arduino worked perfect. When you connect the arduino with an exernal power supply the tx and rx lights won't light up, Even when they are transmitting or receiving. &lt;/p&gt;&#xA;" OwnerUserId="10056" LastEditorUserId="10056" LastEditDate="2015-06-02T08:45:05.407" LastActivityDate="2016-11-09T06:32:10.603" Title="Arduino won't send serial data if connected with external power supply" Tags="|serial|usb|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11851" PostTypeId="2" ParentId="11807" CreationDate="2015-05-14T19:32:17.670" Score="0" Body="&lt;p&gt;So it seems the F_CPU should be set up at compile time and I'm not sure if Ino does that or not (probably, or I'm missing something else). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However after pulling my hair for a day or so I discovered &lt;a href=&quot;http://platformio.org/#!/&quot; rel=&quot;nofollow&quot;&gt;PlatformIO&lt;/a&gt; which has a much better functionality - my code works correctly, the lib manager is intriguing, is platform independent and seems it doesn't even require the Arduino environment to be installed (it can pull the required files itself).&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-14T19:32:17.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11852" PostTypeId="2" ParentId="11850" CreationDate="2015-05-14T20:25:26.843" Score="0" Body="&lt;p&gt;I think tx not activated without available serial connection. What is you rf module and what is the baud rate of RF module. Also can you share connection diagram or a test video. Alternativeliy you can look SoftwareSerial: &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/SoftwareSerial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-05-14T20:25:26.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11853" PostTypeId="2" ParentId="3316" CreationDate="2015-05-14T20:31:20.780" Score="0" Body="&lt;p&gt;If you uploaded a program that uses &lt;strong&gt;serial port&lt;/strong&gt; &lt;strong&gt;too often&lt;/strong&gt; you cannot upload program from arduino IDE. try to &lt;strong&gt;press reset button on mega2560 when you begin to upload&lt;/strong&gt; program. Many times I solved like this.&lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-05-14T20:31:20.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11854" PostTypeId="2" ParentId="804" CreationDate="2015-05-14T23:57:40.890" Score="6" Body="&lt;p&gt;I was having the same problem and got the same error message.  Turns out these boards don't come with a bootloader preinstalled.  If you have some jumper wires and another working arduino you can use this &lt;a href=&quot;http://www.instructables.com/id/How-To-Burn-a-Bootloader-to-Clone-Arduino-Nano-30/step3/Simple-few-steps/&quot; rel=&quot;noreferrer&quot;&gt;tutorial&lt;/a&gt; to install the bootloader and it should work great, mine did at least! :)&lt;/p&gt;&#xA;" OwnerUserId="10067" LastActivityDate="2015-05-14T23:57:40.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11855" PostTypeId="1" CreationDate="2015-05-15T04:46:21.750" Score="0" ViewCount="1240" Body="&lt;p&gt;I'm working on a project that will require two arduinos to be able to relay information to each other from long distances (up to about 10 miles or around 16 km).  WiFi won't be guaranteed to be available to either arduino as this is a wilderness application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my options for long range wireless communication?  I haven't decided on an arduino model yet so if one particular model would be best for this application let me know.&lt;/p&gt;&#xA;" OwnerUserId="3386" LastActivityDate="2015-05-15T06:39:45.177" Title="Long range wireless communication between two arduinos?" Tags="|communication|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11857" PostTypeId="1" CreationDate="2015-05-13T07:49:53.683" Score="0" ViewCount="661" Body="&lt;p&gt;I have a sensor which I am trying to communicate with over SPI using an Arduino UNO. It is my first time using SPI and I'm experiencing some problems which I'm hoping are just due to some misunderstanding on my part. I have written a simple code to perform one basic operation: Turn on the sensor's fan. The Arduino is being powered through the 2.1 mm barrel jack by a 1.5 A DC adapter. The 5V, GND, MOSI, MISO, SS and SCK pins on the Arduino are connected to the corresponding pins on the sensor. The sensor receives power from the Arduino, drawing up to 250 mA (with the fan on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manufacturer provides a list of commands corresponding to each function of the sensor. To turn on the fan, the command list gives the following information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command_byte: 0x03&#xA;Bytes: 0x03, 0x00&#xA;Bytes_in: 0xF3, 0x03&#xA;Time_between_current_and_next_byte: 1.7ms, NA&#xA;Note: 1ms would be adequate delay between command byte and following byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on my understanding of this, to turn on the fan, I need to send a command byte (0x03), then wait 1.7 ms and send another byte (0x00). My code for doing this is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;const int chipSelectPin = 10;&#xA;&#xA;void setup() {      &#xA;  Serial.begin(9600);&#xA;&#xA;  SPI.begin();&#xA;  pinMode(chipSelectPin, OUTPUT);&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV32); //set clock to 500kHz&#xA;  SPI.setDataMode(SPI_MODE1);&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  delay(10000); // Let the sensor settle for 10 seconds&#xA;&#xA;  digitalWrite(chipSelectPin, LOW);&#xA;  indata = SPI.transfer(0x03); //command byte for fan on&#xA;  Serial.println(indata);// value returned should be 0xF3&#xA;  delay(2);&#xA;  indata = SPI.transfer(0x00); //Turn on fan&#xA;  digitalWrite(chipSelectPin, HIGH);&#xA;  Serial.println(indata);// value returned should be 0x03     &#xA;}&#xA;&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I send the command byte, the returned value (which gets printed to the terminal) is 243 which corresponds to the expected hex value of 0xF3. However, the second command does not turn on the fan and the second returned value is 231 which does not correspond to the expected hex value of 0x03.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think it's a hardware issue because at least one of the returned values is correct and because the sensor does work when used with a different platform. I also experimented with different delays between bytes.&lt;/p&gt;&#xA;" OwnerUserId="10198" OwnerDisplayName="user3668294" LastEditorUserId="26916" LastEditDate="2017-09-08T23:14:07.007" LastActivityDate="2023-02-14T10:08:15.997" Title="SPI: problems communicating with sensor using Arduino" Tags="|spi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11858" PostTypeId="2" ParentId="11855" CreationDate="2015-05-15T06:39:45.177" Score="2" Body="&lt;p&gt;Your range of options depends strongly on what your budget is, what country you are in, whether you are a licensed radio operator, whether cell service is available, etc.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;If you aren't licensed:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In the USA, unlicensed (or lightly licensed) radio options include GMRS (&lt;a href=&quot;https://en.wikipedia.org/wiki/General_Mobile_Radio_Service&quot; rel=&quot;nofollow&quot;&gt;General Mobile Radio Service&lt;/a&gt;), FRS (&lt;a href=&quot;https://en.wikipedia.org/wiki/Family_Radio_Service&quot; rel=&quot;nofollow&quot;&gt;Family Radio Service&lt;/a&gt;) and CB (&lt;a href=&quot;https://en.wikipedia.org/wiki/Citizens_band_radio&quot; rel=&quot;nofollow&quot;&gt;Citizens band radio&lt;/a&gt;).  GMRS and FRS range typically is at most a few miles – ten miles is too much to hope for.  CB range would be ok but CB radios often are fairly large and antennas would be large, eg nine feet long.  I don't know whether it is legal to transmit digital data over GMRS/FRS/CB radio.  &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;If you are licensed:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/2-meter_band&quot; rel=&quot;nofollow&quot;&gt;2-meter band&lt;/a&gt; radio might be a good choice.  Frequencies are 144 MHz to 148 MHz in the Americas and Asia, or 144 MHz to 146 MHz elsewhere.  Per wikipedia, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The license privileges of amateur radio operators include the use of frequencies within this band  for telecommunication, usually conducted locally within a range of about 100 miles (160 km).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h3&gt;If cell service is available:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Consider a &lt;a href=&quot;https://en.wikipedia.org/wiki/GSM&quot; rel=&quot;nofollow&quot;&gt;GSM&lt;/a&gt; shield, eg the &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;Arduino GSM Shield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To access the cell network you would need to buy a &lt;a href=&quot;http://www.arduino.cc/en/Guide/ArduinoGSMShield#toc4&quot; rel=&quot;nofollow&quot;&gt;SIM card&lt;/a&gt; for each GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPRS (&lt;a href=&quot;https://en.wikipedia.org/wiki/General_Packet_Radio_Service&quot; rel=&quot;nofollow&quot;&gt;General Packet Radio Service&lt;/a&gt;) on GSM provides data rates between 10 and 240 kbs.  Other GSM protocols may be faster or slower.  Data rates depend also on whether 3G service is available or only 2G.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-15T06:39:45.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11860" PostTypeId="1" AcceptedAnswerId="11862" CreationDate="2015-05-15T07:56:38.607" Score="1" ViewCount="336" Body="&lt;p&gt;I'm going to be writing some performance critical code and have started trying to get an understanding of timers and how much &quot;work&quot; the Due CPU can do per second.  To help get started with this, I wrote a bare sketch that simply increments a counter whilst a timer which ticks every second dumps the value of the counter to the serial log and then resets the counter.  Here's the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void EnableTimer7TickEverySecond();&#xA;&#xA;volatile uint32_t gCounter = 0;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;&#xA;    EnableTimer7TickEverySecond();&#xA;&#xA;//  while ( true )&#xA;//  {&#xA;//      ++gCounter;&#xA;//  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    ++gCounter;&#xA;}&#xA;&#xA;void EnableTimer7TickEverySecond()&#xA;{&#xA;    pmc_set_writeprotect(false);&#xA;    pmc_enable_periph_clk(ID_TC7);&#xA;    TC_Configure(TC2, 1, TC_CMR_WAVE | &#xA;        TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);&#xA;    TC_SetRC(TC2, 1, 656000 * 64);&#xA;    TC_Start(TC2, 1);&#xA;    TC2-&amp;gt;TC_CHANNEL[1].TC_IER = TC_IER_CPCS;&#xA;    TC2-&amp;gt;TC_CHANNEL[1].TC_IDR = ~TC_IER_CPCS;&#xA;    NVIC_EnableIRQ(TC7_IRQn);&#xA;}&#xA;&#xA;void TC7_Handler()&#xA;{&#xA;    TC_GetStatus( TC2, 1 );&#xA;&#xA;    Serial.println( (uint32_t)gCounter );&#xA;&#xA;    gCounter = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this, I get values averaging 446,000 in the serial log for the increments per second.  That is way lower than I was expecting.  On an ARM chip running at 84MHz, I'd expect at least 14 million increments as few ARM instructions take more than 2 clock cycles and an increment should involve a read from memory, addition and a write back to memory (approx 6 clock cycles by my reckoning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer is configured correctly, the TX led flashes regularly at 1 second intervals as the Serial.println is called.  I've checked for overflow on the counter (oddly, I found that the number of increments when working with a uint64_t was slightly higher).  I've also tried not calling Serial.begin() until I'm about to write the value to the log (and then only writing the value once) and whilst there is a slight increase in &quot;performance&quot;, it doesn't account for the whole difference between expectation and reality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best guess would be that loop() is called on some sort of timer or has a built in default delay, so it occurred to me that if I comment out the counter increment in loop() and instead comment in the infinite while loop in setup(), I should be able to counteract any delay caused by how frequently the Arduino IDE calls loop().  I have seen other examples that never bother with loop() and just stick all their code in setup().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do see a performance increase with this setup, but only to around 9 million, not the 14+ million I would expect. Oddly though, sometimes, randomly, the value is 2 or 3 times the &quot;usual&quot; value.  Not between 2 and 3 times, but exactly 2 or 3 times.  This happens regardless of whether I am incrementing the counter inside the loop() function or my own loop inside setup().  It is not a case of the timer &quot;skipping&quot;, the output is written every second like clockwork.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;What does the Arduino library do to make loop() so inefficient?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there any harm in keeping all your code inside an infinite loop in&#xA;setup() and never returning out of it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why would I sometimes see the number of increments being 2 or 3 times&#xA;higher than usual?  Could the counter be getting cached (despite&#xA;being marked as volatile) and not reset properly?  If so, how can I&#xA;prevent this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-15T10:22:19.503" Title="Help needed understanding Due performance" Tags="|arduino-due|performance|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11862" PostTypeId="2" ParentId="11860" CreationDate="2015-05-15T09:52:12.087" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What does the Arduino library do to make loop() so inefficient?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Alot.  For a start it's a function, so it has to push registers onto the stack before it runs, and pop them off afterwards.  Secondly there is the &quot;serial event&quot; system outside the loop.  In main.cpp in the core you can see how loop is called:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup();&#xA;&#xA;for (;;)&#xA;{&#xA;    loop();&#xA;    if (serialEventRun) serialEventRun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any harm in keeping all your code inside an infinite loop in setup() and never returning out of it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you don't use serial events, no harm whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why would I sometimes see the number of increments being 2 or 3 times higher than usual? Could the counter be getting cached (despite being marked as volatile) and not reset properly? If so, how can I prevent this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My guess is the operations you are using are not atomic.  This is, the interrupt is able to be fired right in the middle of doing the series of instructions that perform the increment. The temporary registers end up not being the same as they were at the start of the operation, and consequently the value is corrupted.  You should wrap the increment in a &lt;em&gt;critical section&lt;/em&gt; (i.e., disable interrupts before it, and enable them afterwards).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To better analyse the speed of execution you can look at the generated assembly code of your program.  If we look at the disassembled &lt;code&gt;main()&lt;/code&gt; function for the bit where it loops you can get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;80596:  f7ff fe05   bl  801a4 &amp;lt;loop&amp;gt;&#xA;8059a:  4b04        ldr r3, [pc, #16]   ; (805ac &amp;lt;main+0x30&amp;gt;)&#xA;8059c:  2b00        cmp r3, #0&#xA;8059e:  d0fa        beq.n   80596 &amp;lt;main+0x1a&amp;gt;&#xA;805a0:  f7ff feec   bl  8037c &amp;lt;_Z14serialEventRunv&amp;gt;&#xA;805a4:  e7f7        b.n 80596 &amp;lt;main+0x1a&amp;gt;&#xA;805a6:  bf00        nop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;loop()&lt;/code&gt; consists of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;801a4:  4b02        ldr r3, [pc, #8]    ; (801b0 &amp;lt;loop+0xc&amp;gt;)&#xA;801a6:  681a        ldr r2, [r3, #0]&#xA;801a8:  3201        adds    r2, #1&#xA;801aa:  601a        str r2, [r3, #0]&#xA;801ac:  4770        bx  lr&#xA;801ae:  bf00        nop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we feed that into &lt;code&gt;main()&lt;/code&gt; where it calls &lt;code&gt;loop()&lt;/code&gt; the finished code looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;80596:  f7ff fe05   bl  801a4 &amp;lt;loop&amp;gt;&#xA;801a4:  4b02        ldr r3, [pc, #8]    ; (801b0 &amp;lt;loop+0xc&amp;gt;)&#xA;801a6:  681a        ldr r2, [r3, #0]&#xA;801a8:  3201        adds    r2, #1&#xA;801aa:  601a        str r2, [r3, #0]&#xA;801ac:  4770        bx  lr&#xA;801ae:  bf00        nop&#xA;8059a:  4b04        ldr r3, [pc, #16]   ; (805ac &amp;lt;main+0x30&amp;gt;)&#xA;8059c:  2b00        cmp r3, #0&#xA;8059e:  d0fa        beq.n   80596 &amp;lt;main+0x1a&amp;gt;&#xA;805a0:  f7ff feec   bl  8037c &amp;lt;_Z14serialEventRunv&amp;gt;&#xA;805a4:  e7f7        b.n 80596 &amp;lt;main+0x1a&amp;gt;&#xA;805a6:  bf00        nop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that is what gets executed for every single iteration of &lt;code&gt;loop()&lt;/code&gt;.  If we (incorrectly) assume that each instruction takes 1 clock tick, that's 13 ticks.  84,000,000 / 13 = ~6.4 million loops per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now - if we map the instructions against actually how many clock cycles they take, we can get a clearer picture:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bl                  1+P  (P = 1 to 3)&#xA;ldr (pc relative)   2&#xA;ldr (word)          2&#xA;adds                1&#xA;str (word)          2&#xA;bx                  1+P  (P = 1 to 3)&#xA;nop                 1&#xA;ldr (pc relative)   2&#xA;cmp                 1&#xA;beq.n               1 or 1+P (P = 1 to 3)&#xA;bl                  1+P (Only if serial event runs)&#xA;b.n                 1 or 1+P (P = 1 to 3)&#xA;nop                 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So taking a worst case scenario where P = 3 (pipeline re-fill clock counts, that is), and no serial event running, we can calculate a total number of clock cycles of 4+2+2+1+2+4+1+2+1+4+0+4+1 = 28.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;84,000,000 / 28 = 3,000,000 loops per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But hang on - that's still much more than you're seeing.  That's because you're still only looking at the small picture.  You're looking at just your sketch and forgetting what else there is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every millisecond the &lt;code&gt;SysTick_Handler()&lt;/code&gt; gets called which does various tasks, including calling the &lt;code&gt;TimeTick_Increment()&lt;/code&gt; routine to deal with &lt;code&gt;millis()&lt;/code&gt;.  That's 1,000 times per second, and that eats into your processing time somewhat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important point is &lt;em&gt;it can't be incrementing while you're running your interrupt&lt;/em&gt;.  The more you do in your interrupt (&lt;em&gt;and using serial is a very heavy-weight thing to do in an interrupt&lt;/em&gt;) the less of your 1-second slice you get for doing your incrementing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an experiment, why not try disabling all the interrupts except just the one you are using for your timer and see how it changes the value.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-15T10:22:19.503" LastActivityDate="2015-05-15T10:22:19.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11864" PostTypeId="2" ParentId="11857" CreationDate="2015-05-15T12:31:11.773" Score="-1" Body="&lt;p&gt;Change your chipSelectPin. Pin 10 is exclusively used by SPI library. See &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno description&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar issue has been discussed &lt;a href=&quot;https://arduino.stackexchange.com/questions/10551/mqtt-vs-tinkerkit-sensor-shield/10567#10567&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9866" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-05-15T12:31:11.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11865" PostTypeId="1" CreationDate="2015-05-15T13:37:25.427" Score="0" ViewCount="269" Body="&lt;p&gt;I'm trying to send an email using an Arduino Uno and a Sparkfun CC3000. When I plugged in the arduino to the computer with the code I wrote for it, all wireless communication in the room I was in went down. This includes both computers that were there, my cell phone, even my Pebble Watch got disconnected. Any idea on why this happened and how to fix it? I replicated this numerous times to make sure it wasn't a fluke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PingTest.ino&#xA;CC3000 Ping Test&#xA;Shawn Hymel @ SparkFun Electronics&#xA;February 1, 2014&#xA;https://github.com/sparkfun/SFE_CC3000_Library&#xA;&#xA;Connects to the access point given by the SSID and password and&#xA;waits for a DHCP-assigned IP address. Pings the give website or&#xA;IP address and waits for a response.&#xA;&#xA;The security mode is defined by one of the following:&#xA;WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2&#xA;&#xA;Hardware Connections:&#xA;&#xA; Uno Pin    CC3000 Board    Function&#xA;&#xA; +5V        VCC or +5V      5V&#xA; GND        GND             GND&#xA; 2          INT             Interrupt&#xA; 7          EN              WiFi Enable&#xA; 10         CS              SPI Chip Select&#xA; 11         MOSI            SPI MOSI&#xA; 12         MISO            SPI MISO&#xA; 13         SCK             SPI Clock&#xA;&#xA;Resources:&#xA;Include SPI.h and SFE_CC3000.h&#xA;&#xA;Development environment specifics:&#xA;Written in Arduino 1.0.5&#xA;Tested with Arduino UNO R3&#xA;&#xA;This code is beerware; if you see me (or any other SparkFun &#xA;employee) at the local, and you've found our code helpful, please&#xA;buy us a round!&#xA;&#xA;Distributed as-is; no warranty is given.&#xA;****************************************************************/&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000_Client.h&amp;gt;&#xA;#include &amp;lt;Client.h&amp;gt;&#xA;#include &amp;lt;Temboo.h&amp;gt;&#xA;#include &quot;TembooAccount.h&quot; // Contains Temboo account information&#xA;&#xA;&#xA;// Pins&#xA;#define CC3000_INT      3   // Needs to be an interrupt pin (D2/D3)&#xA;#define CC3000_EN       9   // Can be any digital pin&#xA;#define CC3000_CS       10  // Preferred is pin 10 on Uno&#xA;&#xA;// Connection info data lengths&#xA;#define IP_ADDR_LEN     4   // Length of IP address in bytes&#xA;&#xA;// Constants&#xA;char ap_ssid[] = &quot;comcast&quot;;                  // SSID of network&#xA;char ap_password[] = &quot;gooddays&quot;;          // Password of network&#xA;unsigned int ap_security = WLAN_SEC_WPA2; // Security of network&#xA;unsigned int timeout = 30000;             // Milliseconds&#xA;char remote_host[] = &quot;www.sparkfun.com&quot;;  // Host to ping&#xA;unsigned int num_pings = 3;    // Number of times to ping&#xA;&#xA;// Global Variables&#xA;SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);&#xA;SFE_CC3000_Client client = SFE_CC3000_Client(wifi);&#xA;&#xA;int numRuns = 1;   // Execution count, so this doesn't run forever&#xA;int maxRuns = 10;&#xA;&#xA;void setup() {&#xA;&#xA;  ConnectionInfo connection_info;&#xA;  IPAddress ip_addr;&#xA;  IPAddress remote_ip;&#xA;  PingReport ping_report = {0};&#xA;  int i;&#xA;&#xA;  // Initialize Serial port&#xA;  Serial.begin(115200);&#xA;  Serial.println();&#xA;  Serial.println(&quot;---------------------------&quot;);&#xA;  Serial.println(&quot;SparkFun CC3000 - Ping Test&quot;);&#xA;  Serial.println(&quot;---------------------------&quot;);&#xA;&#xA;  // Initialize CC3000 (configure SPI communications)&#xA;  if ( wifi.init() ) {&#xA;    Serial.println(&quot;CC3000 initialization complete&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Something went wrong during CC3000 init!&quot;);&#xA;  }&#xA;&#xA;  // Connect and wait for DHCP-assigned IP address&#xA;  Serial.print(&quot;Connecting to: &quot;);&#xA;  Serial.println(ap_ssid);&#xA;  if(!wifi.connect(ap_ssid, ap_security, ap_password, timeout)) {&#xA;    Serial.println(&quot;Error: Could not connect to AP&quot;);&#xA;  }&#xA;&#xA;  // Gather connection details and print IP address&#xA;  if ( !wifi.getConnectionInfo(connection_info) ) {&#xA;    Serial.println(&quot;Error: Could not obtain connection details&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Connected!&quot;);&#xA;    Serial.print(&quot;IP Address: &quot;);&#xA;    for (i = 0; i &amp;lt; IP_ADDR_LEN; i++) {&#xA;      Serial.print(connection_info.ip_address[i]);&#xA;      if ( i &amp;lt; IP_ADDR_LEN - 1 ) {&#xA;        Serial.print(&quot;.&quot;);&#xA;      }&#xA;    }&#xA;    Serial.println();&#xA;  }&#xA;&#xA;  // Perform a DNS lookup to get the IP address of a host&#xA;  Serial.print(&quot;Looking up IP address of: &quot;);&#xA;  Serial.println(remote_host);&#xA;  if ( !wifi.dnsLookup(remote_host, &amp;amp;remote_ip) ) {&#xA;    Serial.println(&quot;Error: Could not lookup host by name&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;IP address found: &quot;);&#xA;    for (i = 0; i &amp;lt; IP_ADDR_LEN; i++) {&#xA;      Serial.print(remote_ip[i], DEC);&#xA;      if ( i &amp;lt; IP_ADDR_LEN - 1 ) {&#xA;        Serial.print(&quot;.&quot;);&#xA;      }&#xA;    }&#xA;    Serial.println();&#xA;  }&#xA;&#xA;  // Ping IP address of remote host&#xA;  Serial.print(&quot;Pinging &quot;);&#xA;  for (i = 0; i &amp;lt; IP_ADDR_LEN; i++) {&#xA;    Serial.print(remote_ip[i], DEC);&#xA;    if ( i &amp;lt; IP_ADDR_LEN - 1 ) {&#xA;      Serial.print(&quot;.&quot;);&#xA;    }&#xA;  }&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(num_pings, DEC);&#xA;  Serial.println(&quot; times...&quot;);&#xA;  if ( !wifi.ping(remote_ip, ping_report, 3, 56, 1000) ) {&#xA;    Serial.println(&quot;Error: no ping response&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Pong!&quot;);&#xA;    Serial.println();&#xA;    Serial.print(&quot;Packets sent: &quot;);&#xA;    Serial.println(ping_report.packets_sent);&#xA;    Serial.print(&quot;Packets received: &quot;);&#xA;    Serial.println(ping_report.packets_received);&#xA;    Serial.print(&quot;Min round time (ms): &quot;);&#xA;    Serial.println(ping_report.min_round_time);&#xA;    Serial.print(&quot;Max round time (ms): &quot;);&#xA;    Serial.println(ping_report.max_round_time);&#xA;    Serial.print(&quot;Avg round time (ms): &quot;);&#xA;    Serial.println(ping_report.avg_round_time);&#xA;    Serial.println();&#xA;  }&#xA;&#xA;  // Disconnect&#xA;  if ( wifi.disconnect() ) {&#xA;    Serial.println(&quot;Disconnected&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Error: Could not disconnect from network&quot;);&#xA;  }&#xA;&#xA;  // Done!&#xA;  Serial.println(&quot;Finished ping test&quot;);&#xA;&#xA;}&#xA;    TembooChoreo SendEmailChoreo(client);&#xA;void loop() {&#xA;  if (numRuns &amp;lt;= maxRuns) {&#xA;    Serial.println(&quot;Running SendEmail - Run #&quot; + String(numRuns++));&#xA;&#xA;    //TembooChoreo SendEmailChoreo(client);&#xA;&#xA;    // Invoke the Temboo client&#xA;    SendEmailChoreo.begin();&#xA;&#xA;    // Set Temboo account credentials&#xA;    SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);&#xA;    SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);&#xA;    SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);&#xA;&#xA;    // Set profile to use for execution&#xA;    SendEmailChoreo.setProfile(&quot;Testofsoftware&quot;);&#xA;&#xA;    // Identify the Choreo to run&#xA;    SendEmailChoreo.setChoreo(&quot;/Library/Google/Gmail/SendEmail&quot;);&#xA;&#xA;    // Run the Choreo; when results are available, print them to serial&#xA;    SendEmailChoreo.run();&#xA;&#xA;    while(SendEmailChoreo.available()) {&#xA;      char c = SendEmailChoreo.read();&#xA;      Serial.print(c);&#xA;    }&#xA;    SendEmailChoreo.close();&#xA;  }&#xA;&#xA;  Serial.println(&quot;\nWaiting...\n&quot;);&#xA;  delay(30000); // wait 30 seconds between SendEmail calls&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4571" LastEditorUserId="4571" LastEditDate="2015-05-15T15:59:34.783" LastActivityDate="2015-12-16T17:13:50.163" Title="CC3000 Blocking All Wireless Communication" Tags="|arduino-uno|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11866" PostTypeId="2" ParentId="3796" CreationDate="2015-05-15T13:47:58.640" Score="1" Body="&lt;p&gt;Have both sync to a master clock using GSM shields. These shields are getting very cheap (&lt;a href=&quot;http://www.ebay.com/itm/like/181722612700?lpid=82&amp;amp;chn=ps&quot; rel=&quot;nofollow&quot;&gt;as low as $14 on ebay&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shields receive the time wirelessly from the cellular network and this time base is extremely accurate. Here is some example code to read the current time from the shield...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=163155.msg2102141#msg2102141&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=163155.msg2102141#msg2102141&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you will need a SIM card to get the time, but you should not need an active cellular account. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-05-15T13:47:58.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11867" PostTypeId="2" ParentId="3796" CreationDate="2015-05-15T14:15:24.060" Score="1" Body="&lt;p&gt;You can also use real time clock (RTC) modules to syncronize arduinos. These are cheaper than other solutions like GPS or WiFi.&lt;/p&gt;&#xA;" OwnerUserId="8687" LastActivityDate="2015-05-15T14:15:24.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11868" PostTypeId="1" CreationDate="2015-05-15T15:16:59.723" Score="1" ViewCount="677" Body="&lt;p&gt;I run my 12V car battery trough a trimpot into my pro micro, micro controller. &#xA;I am using (voltPinValue1 * 0.01465) to get the Volt out of analog in. I have trimmed the pots and getting the right V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now I want to calculate for how long I can run for, example the stereo and some LED:s, but don't know how.. Does anybody know how I can do this??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for my English&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks! //Rasmus&lt;/p&gt;&#xA;" OwnerUserId="9922" LastEditorUserId="4143" LastEditDate="2015-05-15T16:07:58.187" LastActivityDate="2016-01-10T19:57:36.197" Title="Calculate how much battery power left" Tags="|voltage-level|battery|arduino-pro-micro|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11870" PostTypeId="1" CreationDate="2015-05-15T16:09:23.150" Score="1" ViewCount="48" Body="&lt;p&gt;So, I was working on a project where I needed to get a random object from a stack, so to make sure my design was correct, I made a dummy program that does nothing but fill a stack with data, then print it out.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/F6tCB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;why in the world is nothing coming out of the stack but -1s??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the stack.h file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/vjhNLpNu&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://pastebin.com/vjhNLpNu&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10017" LastActivityDate="2015-05-15T16:18:39.373" Title="Stack isn't popping off correct data?" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11871" PostTypeId="2" ParentId="11868" CreationDate="2015-05-15T16:12:17.860" Score="1" Body="&lt;p&gt;You really need to know the current being drawn rather than the instantaneous voltage. A voltage drop profile of a battery changes depending on the current draw, and just using the voltage is very very hard indeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could measure the voltage over time, and try and calculate the slope of the voltage and attempt to predict when it would reach a specific pre-determined cut-off point, but since that change in voltage will be non-linear it's not really something that can easily be calculated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, if you can measure the current instead, and you know the Ah of the battery, then you can get a better estimate of how long the battery will run until it's considered flat.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-15T16:12:17.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11872" PostTypeId="2" ParentId="11870" CreationDate="2015-05-15T16:16:28.483" Score="3" Body="&lt;p&gt;You're not telling it how big your stack should be, and it defaults to 0 entries, which means nothing gets stored.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Stack&#xA;{&#xA;private:&#xA;    int *p;&#xA;    int top,length;&#xA;&#xA;public:&#xA;    Stack(int = 0);  &amp;lt;&amp;lt;== CONSTRUCTOR - DEFAULT SIZE IS 0&#xA;    ~Stack();&#xA;&#xA;    void push(int);&#xA;    int pop();&#xA;    void display();&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you make your Stack object you must give it a size for the number of entries in the stack:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Stack stack(4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-15T16:16:28.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11873" PostTypeId="2" ParentId="11870" CreationDate="2015-05-15T16:18:39.373" Score="1" Body="&lt;p&gt;You never allocate space for the stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way it's written, you need to pass the stack size into the constructor, and then it's fixed for the lifetime of the object; i.e. it won't grow automatically when you call &lt;code&gt;push()&lt;/code&gt;. You're not passing anything into the &lt;code&gt;Stack&lt;/code&gt; constructor, so the parameter is defaulting to &lt;code&gt;0&lt;/code&gt;, meaning it has zero size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to declare the stack something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Stack stack(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(10 is just an arbitrary size -- use whatever you expect to need.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, there isn't an effective safeguard in your code to handle an empty stack. The result is that you're technically getting undefined behaviour at the moment when you call &lt;code&gt;push()&lt;/code&gt; (it's writing to arbitrary memory locations).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-05-15T16:18:39.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11874" PostTypeId="1" AcceptedAnswerId="11879" CreationDate="2015-05-15T17:47:18.330" Score="2" ViewCount="461" Body="&lt;p&gt;I've connected a SIM900A GSM module to Arduino and the circuit works standalone on a 12V power supply. The problem is when I provide the 12V power supply, both GSM module and Arduino starts but the Arduino don't initializes the program for GSM module and hence the send or receive message functions don't work. Also when I first power on the GSM module and let it initialize first and then power on the Arduino, everything works fine. How to deal with this problem? &lt;/p&gt;&#xA;" OwnerUserId="10040" LastActivityDate="2015-05-15T19:18:29.230" Title="How to power on Arduino a few seconds later after GSM module initialization?" Tags="|arduino-uno|programming|gsm|electronics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11875" PostTypeId="2" ParentId="11874" CreationDate="2015-05-15T17:56:23.747" Score="1" Body="&lt;p&gt;Let the 12 V charge a large capacitor over a resistor. The time to charge to 63% is RxC. Place a 5 V zener diode parallel to the capacitor, so that doesn't damage the microcontroller. Then either connect to the microcontroller's reset, or, and this is &quot;nicer&quot;, use a MAX809 reset controller. The latter will keep the output low until a precise threshold is reached, there's for instance a 4.00 V version. Use that output to keep the microcontroller reset for some time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure how much delay you want, but a 10 uF capacitor and a 100k resistor will give you (from the top of my head) about half a second before the voltage on the capacitor reaches 4 V.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-15T17:56:23.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11876" PostTypeId="1" CreationDate="2015-05-15T18:12:03.960" Score="3" ViewCount="2055" Body="&lt;p&gt;I'm trying to convert a class header file from another c++ project to arduino, which in my mind involves replacing cout with Serial.println.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to recomplile with all of these changes, I get this error from the compiler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: 'Serial' was not declared in this scope&#xA;     Serial.print(p[i]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone explain this to me?&lt;/p&gt;&#xA;" OwnerUserId="10017" LastActivityDate="2015-05-15T18:46:51.237" Title="Can I use Serial.println() in a class?" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11878" PostTypeId="2" ParentId="11876" CreationDate="2015-05-15T18:46:51.237" Score="3" Body="&lt;p&gt;You have to &lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&lt;/code&gt;, or compile with the &lt;code&gt;-include Arduino.h&lt;/code&gt; flag. The Arduino IDE normally does that for you, but you have to do it yourself if you are working outside the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of Arduino Makefiles floating around the Web which, just like the IDE, take care of this for you.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-15T18:46:51.237" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11879" PostTypeId="2" ParentId="11874" CreationDate="2015-05-15T19:18:29.230" Score="1" Body="&lt;p&gt;It sounds like your problem is that the GSM module needs time to initialize before it is ready to be talked to by the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A crude way of providing this would be to use the &lt;code&gt;delay()&lt;/code&gt; function in the Setup() of your sketch.  The argument to that is an &lt;code&gt;unsigned long&lt;/code&gt; number of milliseconds (thousandths of a second) so it can produce delays far longer than you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But a more sophisticated solution would be to repeatedly try to talk to the module and check for an expected response.  Apparently, with at least some of these, if you disable baud rate detection they will announce themselves with a prompt when they are ready - you could wait for that.  But I think repeatedly trying until you get a response is going to be the most robust.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-15T19:18:29.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11880" PostTypeId="2" ParentId="9082" CreationDate="2015-05-15T19:24:02.493" Score="0" Body="&lt;p&gt;Well, the range of the sensor should be: &quot;2-40cm&quot;&#xA;I would suggest using the code below and changing the potentiometers to see if it makes any difference.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Led = 13 ;// define LED Interface&#xA;int buttonpin = 3; // define the obstacle avoidance sensor interface&#xA;&#xA;void setup ()&#xA;{&#xA;  pinMode (Led, OUTPUT) ;// define LED as output interface&#xA;  pinMode (buttonpin, INPUT) ;// define the obstacle avoidance sensor output interface&#xA;}&#xA;void loop ()&#xA;{&#xA;  if (digitalRead (buttonpin) == HIGH) // When the obstacle avoidance sensor detects a signal, LED goes on.&#xA;  {&#xA;    digitalWrite (Led, HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite (Led, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-05-15T19:24:02.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11883" PostTypeId="2" ParentId="11818" CreationDate="2015-05-15T23:37:05.837" Score="1" Body="&lt;p&gt;Thanks again for your contributions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've gone ahead and decided to go with the following code. Its purpose is to turn vol up or down based on current car MPH. I choose to define brackets that cover a range of values. When one bracket ends, another begins. I've also set the previous bracket to current bracket at the end of each loop so that the application knows where it was previously, so that if it hops above or goes under a defined bracket, it does the desired action.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used a random generator to supply the MPH for testing purposes for now and commented out a few things that disturbed the testing process. If you'd like to critique this code to make is better, please let me know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I've also borrowed some of this code from another individual (Matthew McMillan, &lt;a href=&quot;http://matthewcmcmillan.blogspot.com&quot; rel=&quot;nofollow&quot;&gt;http://matthewcmcmillan.blogspot.com&lt;/a&gt;) who wanted to figure out how to convert a vehicle speed sensor wire info into MPH. I needed this code in order to make use of the vehicle's speed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;const int lightPin = 0;&#xA;const int hardwareCounterPin = 5;&#xA;const int samplePeriod = 1000; //in milliseconds&#xA;const float pulsesPerMile = 4000; // this is pulses per mile for Toyota. Other cars are different.&#xA;const float convertMph = pulsesPerMile/3600;&#xA;unsigned int count;&#xA;float mph;&#xA;unsigned int imph;&#xA;int roundedMph;&#xA;int previousMph;&#xA;int prevCount;&#xA;&#xA;// Declare brackets&#xA;const int BracketA = 1;&#xA;const int BracketB = 2;&#xA;const int BracketC = 3;&#xA;const int BracketD = 4;&#xA;const int BracketE = 5;&#xA;const int BracketF = 6;&#xA;&#xA;// Initialize Previous and Current Brackets&#xA;int PreviousBracket = 1;&#xA;int CurrentBracket = 1;&#xA;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;&#xA;  TCCR1A = 0; //Configure hardware counter &#xA;  TCNT1 = 0;  // Reset hardware counter to zero&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;  /////////////////////////////////////////////////////////////&#xA;  // This uses the hardware pulse counter on the Arduino.&#xA;  // Currently it collects samples for one second.&#xA;  //&#xA;  bitSet(TCCR1B, CS12); // start counting pulses&#xA;  bitSet(TCCR1B, CS11); // Clock on rising edge&#xA;  delay(samplePeriod); // Allow pulse counter to collect for samplePeriod&#xA;  TCCR1B = 0; // stop counting&#xA;  count = TCNT1; // Store the hardware counter in a variable&#xA;  TCNT1 = 0;     // Reset hardware counter to zero&#xA;  mph = (count/convertMph)*10; // Convert pulse count into mph.&#xA;  imph = (unsigned int) mph; // Cast to integer. 10x allows retaining 10th of mph resolution.&#xA;&#xA;  int x = imph / 10;&#xA;  int y = imph % 10;&#xA;&#xA;  // Round to whole mile per hour&#xA;  //if(y &amp;gt;= 5){&#xA;  //  roundedMph = x + 1;&#xA;  //}else{&#xA;  //  roundedMph = x;&#xA; // }&#xA;&#xA;&#xA;  //Code to write your own MPH for testing purposes.&#xA;  //if (Serial.available() &amp;gt; 0) {&#xA;                // read the incoming byte:&#xA;               // roundedMph = Serial.read();&#xA;               //}&#xA;&#xA;  //If mph is less than 1mph just show 0mph.&#xA;  //Readings of 0.9mph or lower are some what erratic and can&#xA;  //occasionally be triggered by electrical noise.&#xA;  //if(x == 0){&#xA;  //  roundedMph = 0;&#xA; // }&#xA;&#xA;  roundedMph = random(1,80);&#xA;&#xA;&#xA;  // Don't display mph readings that are more than 50 mph higher than the &#xA;  // previous reading because it is probably a spurious reading.&#xA;  // Accelerating 50mph in one second is rocketship fast so it is probably&#xA;  // not real.&#xA;  if((roundedMph - previousMph) &amp;gt; 50){&#xA;    roundedMph = previousMph;&#xA;  }&#xA;&#xA;&#xA;  //Place the gatherered MPH value into a bracket&#xA;  //---------------------------------------------&#xA;  if(roundedMph &amp;gt;= 0 &amp;amp;&amp;amp; roundedMph &amp;lt; 20) {&#xA;   CurrentBracket = BracketA;  //Value1&#xA;   Serial.println(&quot;I Choose Bracket A&quot;);&#xA;    }&#xA;&#xA;  if(roundedMph &amp;gt;= 20 &amp;amp;&amp;amp; roundedMph &amp;lt; 30) {&#xA;   CurrentBracket = BracketB;  //Value2&#xA;   Serial.println(&quot;I Choose Bracket B&quot;);&#xA;    }&#xA;&#xA;  if(roundedMph &amp;gt;= 30 &amp;amp;&amp;amp; roundedMph &amp;lt; 40) {&#xA;   CurrentBracket = BracketC;  //Value3&#xA;   Serial.println(&quot;I Choose Bracket C&quot;);&#xA;    }&#xA;&#xA;  if(roundedMph &amp;gt;= 40 &amp;amp;&amp;amp; roundedMph &amp;lt; 50) {&#xA;   CurrentBracket = BracketD;  //Value4&#xA;   Serial.println(&quot;I Choose Bracket D&quot;);&#xA;    }&#xA;&#xA;  if(roundedMph &amp;gt;= 50 &amp;amp;&amp;amp; roundedMph &amp;lt; 65) {&#xA;   CurrentBracket = BracketE;  //Value5&#xA;   Serial.println(&quot;I Choose Bracket E&quot;);&#xA;    }&#xA;&#xA;  if(roundedMph &amp;gt;= 65) {&#xA;   CurrentBracket = BracketF;  //Value6&#xA;   Serial.println(&quot;I Choose Bracket F&quot;);&#xA;    }&#xA;&#xA;&#xA; //Decide if bracket stayed the same, went up, or down. &#xA; //--------------------------------------------------- &#xA; if(CurrentBracket == PreviousBracket) {&#xA; //Do Nothing&#xA; Serial.println(&quot;Nothing Changed&quot;);&#xA; }  &#xA;&#xA;if(CurrentBracket &amp;gt; PreviousBracket) {&#xA; //Command for Vol Up&#xA; int VolUp;&#xA; VolUp = CurrentBracket - PreviousBracket;&#xA;Serial.println(&quot;Volume Went Up One by &quot;); &#xA;Serial.println(VolUp);&#xA;delay(2000); // Delay to not change Vol to fast if near threshold &#xA;}&#xA;&#xA;if(CurrentBracket &amp;lt; PreviousBracket) {&#xA;  //Command for Vol Down&#xA;  int VolDown;&#xA;  VolDown = PreviousBracket - CurrentBracket;&#xA; Serial.println(&quot;Volume Went Down One by &quot;);  &#xA; Serial.println(VolDown);&#xA; delay(2000); // Delay to not change Vol to fast if near threshold&#xA; }&#xA;  previousMph = roundedMph; // Set previousMph for use in next loop.&#xA;  PreviousBracket = CurrentBracket; //Set PreviousBracket for use in next loop.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10039" LastActivityDate="2015-05-15T23:37:05.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11885" PostTypeId="1" AcceptedAnswerId="11892" CreationDate="2015-05-16T07:18:44.290" Score="2" ViewCount="3533" Body="&lt;p&gt;I have an arduino nano which is powered through unregulated 5V (pin 27). For debugging purpose, I'd like to connect the USB port to my computer in order to use the Serial.Print function. The external 5V will stay connected. Will this cause damage ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit : I forgot to mention that the external power supplied to pin 27 is regulated with a switching DC-DC converter (measured 5.1V). Sorry it was not clear in my question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my circuit : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/avlw4.png&quot; alt=&quot;Schema&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The switching regulator is not exactly the one in the schema.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is using the circuit with the battery power supply + usb connection to my computer will damage something ?&lt;/p&gt;&#xA;" OwnerUserId="10090" LastEditorUserId="11529" LastEditDate="2017-03-17T20:50:04.457" LastActivityDate="2017-03-17T20:50:04.457" Title="Is supplying 5V from both external 5V and USB harmful?" Tags="|serial|power|usb|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11889" PostTypeId="2" ParentId="9828" CreationDate="2015-05-16T09:29:46.307" Score="2" Body="&lt;p&gt;You have to go with timer interrupts. Here is the documentation: &lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/code/timer1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Roughly, when you detect a press, an interrupt is raised and the same thing goes for releasing. Using the timer values from both these events, you can accurately measure the time that the press lasted.&lt;/p&gt;&#xA;" OwnerUserId="10094" LastActivityDate="2015-05-16T09:29:46.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11890" PostTypeId="2" ParentId="11885" CreationDate="2015-05-16T09:36:26.087" Score="-1" Body="&lt;p&gt;Since the external 5V supply is not regulated, it may cause some problems. It is possible that a small voltage difference will appear if and when the external voltage fluctuates from the 5V level. What you should do is short-circuit the 5V of the USB to pin 27.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in general, add a 5V regulator circuit to feed the Arduino nano, like this one: &lt;img src=&quot;https://i.stack.imgur.com/gMdDq.jpg&quot; alt=&quot;http://www.techulator.com/attachments/Resources/10562-75631-V-Voltage-Regulator.jpg&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10094" LastActivityDate="2015-05-16T09:36:26.087" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11891" PostTypeId="1" CreationDate="2015-05-16T09:59:28.310" Score="2" ViewCount="156" Body="&lt;p&gt;im working on a project which requires alo i/o pins. For that reason i bought a pcf8574P 8bit I/O expander which uses the I2C protocol. The problem is how to combine the Rasp PI and the arduino.&lt;/p&gt;&#xA;&lt;h2&gt;For example:&lt;/h2&gt;&#xA;&lt;p&gt;I want the Rasp to send data to the Arduino. Currently i'm using serial but i wanted to switch over to I2C because it better, simpler, and faster however how can i use 2 I2C when the Atmega 328P supports only 1 I2C bus?&lt;/p&gt;&#xA;&lt;p&gt;The plan goes like this:&lt;/p&gt;&#xA;&lt;p&gt;The PI is master of the arduino and it sends the data. Arduino is the slave&lt;/p&gt;&#xA;&lt;p&gt;Arduino is master of the IO expander and the expander is slave&lt;/p&gt;&#xA;&lt;h2&gt;Possible solutions:&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use the Serial protocol to send the data and use the I2C for the expander&lt;/li&gt;&#xA;&lt;li&gt;Make the arduino master of the PI and the expander which i'm not sure if its possible&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6969" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-16T09:59:28.310" Title="I2C with an arduino, a PI and an IO expander" Tags="|arduino-uno|pins|i2c|communication|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11892" PostTypeId="2" ParentId="11885" CreationDate="2015-05-16T10:14:31.727" Score="1" Body="&lt;p&gt;No, it probably won't damage anything, as the PC's USB port is protected from overvoltage by the D1 schottky device on your arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update, my previous answer contained the following paragraph, which is not related to your problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But you should take care of some things. &lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Make sure, the voltage applied to your +5V-Net is regulated properly elsewhere. I.e. choose a laboratory PSU or another good&#xA;  source. &lt;/li&gt;&#xA;  &lt;li&gt;Avoid having both your PC and your 5V-supply connected to line voltage. Ground levels may differ due to Y-capacitors present in the&#xA;  switching PSUs. Those provide a AC voltage of half your line voltage&#xA;  to DC ground (only with 0.3 to 0.7 mA, but enough to cause&#xA;  disturbances on your signals at 55 volts in the US or 115 V in the EU)&lt;/li&gt;&#xA;  &lt;li&gt;If you have to use two switching PSU for both PC and arduino, provide an equipotential bonding between your PC's mass (e.g.&#xA;  VGA-port-screw) to your arduino's PSU's ground directly, to prevent&#xA;  leakage currents from the Y-capacitors wandering around in your&#xA;  circuitry.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update according to your enhanced question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are using a battery powered DC-DC supply for your Arduino. So, my previous notes do not apply to your problem. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5.1 V seem exact enough to drive your arduino safely. No need for additional stabilisation measures&lt;/li&gt;&#xA;&lt;li&gt;D1 (see genuine arduino schematic) separates USB-Power from +5V and prevents current flowing in reverse direction over your USB connection.&lt;/li&gt;&#xA;&lt;li&gt;Arduino circuitry and USB port have common GND so there are always well defined voltage levels.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my opinion, there's nothing with your setup, which may harm your circuitry or your PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the maximum power of your DC-DC converter you may consider adding a fuse to protect converter and components in case of short circuit.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2015-05-16T19:13:32.883" LastActivityDate="2015-05-16T19:13:32.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11893" PostTypeId="1" CreationDate="2015-05-16T10:30:56.943" Score="0" ViewCount="2130" Body="&lt;p&gt;I have two XBees S2, one is configured as an API coordinator connected to Arduino and the other as an AT router. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The coordinator sends a frame to the router to switch on a LED. I want to switch off that LED with a button and the router send a message to the coordinator to tell him that it switch off the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have one Arduino with the coordinator. I'm asking what I have to put in the script to make the coordinator receive the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code, how the coordinator sends the data to the router:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String inputString;&#xA;int led = 13;&#xA;void setup() {&#xA;pinMode(led, OUTPUT);&#xA;Seria.begin(9600);&#xA;}&#xA;void loop() {&#xA;while (Serial.available() ) {&#xA;// get the new byte:&#xA;delay(3);  &#xA;char inChar = Serial.read();&#xA;// add it to the inputString:&#xA;inputString += inChar;&#xA;}&#xA;if (inputString.length() &amp;gt;0) {&#xA;Serial.println(inputString);&#xA;if (inputString == &quot;on&quot;){&#xA;digitalWrite(led,HIGH);&#xA;setRemoteState(5);&#xA;&#xA;}&#xA;inputString=&quot;&quot;; &#xA;}&#xA;}&#xA;&#xA;void setRemoteState(char value){&#xA;Serial.write(0x7E); // start byte&#xA;Serial.write((byte)0x0);&#xA;Serial.write(0x10);&#xA;Serial.write(0x17);&#xA;Serial.write((byte)0x0);&#xA;// id of recipient or use 0xFFFF for broadcast&#xA;Serial.write((byte)00);&#xA;Serial.write((byte)00);&#xA;Serial.write((byte)00);&#xA;Serial.write((byte)00);&#xA;Serial.write((byte)00);&#xA;Serial.write((byte)00);&#xA;Serial.write(0xFF);&#xA;Serial.write(0xFF);&#xA;// 16 bit of reciepent &#xA;Serial.write(0xFF);&#xA;Serial.write(0xFE);  &#xA;&#xA;Serial.write(0x02); &#xA;&#xA;  Serial.write('D');&#xA;  Serial.write('2');&#xA;&#xA; Serial.write(value);&#xA;&#xA;long sum = 0x17 + 0xFF + 0xFF + 0xFF + 0xFE + 0x02 + 'D' + '2' + value;&#xA;Serial.write(0xFF - ( sum &amp;amp; 0xFF) );&#xA;Serial.print(sum,HEX);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10095" LastEditorUserId="6936" LastEditDate="2016-03-15T23:50:10.810" LastActivityDate="2017-02-14T11:50:46.043" Title="How does coordinator XBee receive data from router?" Tags="|arduino-uno|xbee|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11895" PostTypeId="2" ParentId="9856" CreationDate="2015-05-16T15:18:03.060" Score="0" Body="&lt;p&gt;Are you using breakout boards as pictured in your links? Or Arduino shields?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many Uno shields are almost, but not quite, compatible with Mega boards. It is possible there there is one or more pins that are not compatible between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using breakout boards, double check all of the connections to the Mega. Could something be dragging down your power supply? Or actually grounding the reset pin? It would probably be one of the programmable I/O pins since the failure only depended on whether you used the SD library and seems not affected by the mere presence of the board.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-16T15:18:03.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11896" PostTypeId="1" AcceptedAnswerId="11897" CreationDate="2015-05-16T18:55:31.917" Score="2" ViewCount="6283" Body="&lt;p&gt;I'm looking to directly program an ESP8266 WiFi Module with out using a FTDI (USB-Serial interface) as suggested in this excelent &lt;a href=&quot;https://www.openhomeautomation.net/control-a-lamp-remotely-using-the-esp8266-wifi-chip/&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;. The real purpose is to have access to the GPIO ports of the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I heard (from &lt;a href=&quot;http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;) that one can use an Arduino UNO as an intermediate interface for burning the bootloader onto an AVR (e.g. ATmega168 or ATmega328). That is, using the ArduinoISP code example in the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use an Arduino UNO as temporal bridge to program the ESP8266? Can anyone please suggest some tutorial? Thanks&lt;/p&gt;&#xA;" OwnerUserId="8170" LastEditorUserId="653" LastEditDate="2015-10-03T16:37:20.447" LastActivityDate="2017-09-02T09:55:26.730" Title="Simulate a FTDI using an Arduino UNO" Tags="|arduino-uno|esp8266|ftdi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11897" PostTypeId="2" ParentId="11896" CreationDate="2015-05-16T18:59:03.027" Score="2" Body="&lt;p&gt;The simplest way is to unplug the ATMega328P from the board (or otherwise disable it) and just use the ATMega16U2 by connecting the ESP8266 to pins 0 and 1 of the Uno.  No programming required at all then - the ESP8266 just takes the place of the ATMega328P.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to &quot;pass it through&quot; the ATMega328P then you will need to make a transparent pipe for the serial data.  That would involve nominating two more pins on the Uno to be a new serial connection, and using SoftwareSerial to interface with those pins.  Then you have a simple loop which reads from one port and writes to the other, and the same in reverse of course.  Make sure you have the baud rates right.  I don't know how well SoftwareSerial would perform at the (commonly) 115200 baud the ESP8266 works at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: (Interfacing to a 3.3-V system) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ESP8266 works at 3.3V, while the ATMEGA16U2 is powered at 5V, you might need to adapt the level of the ATMEGA16U2's TXD line (which is connected to the &quot;RX&quot; input line of the ATMEGA328P/Arduino Uno Board), to 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this, connect a  1.5 kOhm resistor between the RX pin and ground. In fact, the connection between ATMEGA16U2 and ATMEGA328P is done using an 1kOhm series resistor. This, together with the 1.5k Ohm resistor, will create a resistor divider, which converts the 5V output to 3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See schematics below.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XVPNz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XVPNz.png&quot; alt=&quot;Suggested modifications&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="37540" LastEditDate="2017-09-02T09:55:26.730" LastActivityDate="2017-09-02T09:55:26.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11900" PostTypeId="1" CreationDate="2015-05-16T16:00:27.187" Score="0" ViewCount="4402" Body="&lt;p&gt;I want to burn the arduino bootloader with arduino IDE, but I cant get it done. And here  is my circuit:&#xA;I have marked the way I connect the ISP port and the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZzI6v.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I choose Arduino NG/older as the board and Atmega8 as the processor, but when I start to burn the bootloader to the chip the LED on the usbasp just blink once and an error was given:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino:1.6.5 Hourly Build 2015/05/15 06:16 (Windows 7), 板：&quot;Arduino NG or older, ATmega8&quot;&#xA;&#xA;avrdude: warning: cannot set sck period. please check for usbasp firmware update.&#xA;&#xA;avrdude: error: programm enable: target doesn't answer. 1 &#xA;&#xA;烧录引导程序出错。&#xA;&#xA;avrdude: initialization failed, rc=-1&#xA;&#xA;         Double check connections and try again, or use -F to override&#xA;&#xA;         this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should go wrong? I have check the connection many times and replace a chip as well, and I even add a 12M crystal(with 22pF caps) but things still keep the same. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I do the flowing things as advise:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;short the jp3 jumper of the usbasp to make a slow commiuncation. And remove the crystal.&lt;/li&gt;&#xA;&lt;li&gt;I just found the way I connect the isp port might be wrong. so I changed it as flowing&#xA;&lt;img src=&quot;https://i.stack.imgur.com/9Z7bn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And my actually circuit is like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/imPKv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But got no luck, things still the same :-(&lt;/p&gt;&#xA;" OwnerUserId="10119" OwnerDisplayName="armnotstrong" LastActivityDate="2015-05-16T19:44:12.343" Title="Can't burn arduino bootloader to atmega8a with usbasp" Tags="|bootloader|avrdude|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11901" PostTypeId="2" ParentId="11900" CreationDate="2015-05-16T17:02:08.633" Score="0" Body="&lt;p&gt;You forgot the Pull Up resistor for Reset. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 12Mhz crystal is not a good idea because the Atmega8 config probably uses 8Mhz or 16Mhz, and the fuses which are burned during the bootloader process (yes, they burn fuses first, and THEN load the bootloader) will not expect there to be a 12Mhz crystal, so any further communication can fail because of this too.&lt;/p&gt;&#xA;" OwnerUserId="4179" OwnerDisplayName="KyranF" LastActivityDate="2015-05-16T17:02:08.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11902" PostTypeId="2" ParentId="11900" CreationDate="2015-05-16T17:20:22.227" Score="1" Body="&lt;p&gt;Did you set the SLOW SCK jumper on the USBasp Programmer? Completely new ATMegas use the internal RC-Oscillator at a frequency of 8MHz, but the &lt;em&gt;divide clock by 8&lt;/em&gt; fuse is set too. That means that (before burning the fuses) the AVR is running at a clock frequency of 1MHz and the standard SCK clockrate of the USBasp is too high for this clock frequency. Therefore, you need to set the SLOW SCK jumper to get a lower SCK clockrate.&lt;/p&gt;&#xA;" OwnerUserId="10113" OwnerDisplayName="Simon M. Laube" LastActivityDate="2015-05-16T17:20:22.227" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="11903" PostTypeId="2" ParentId="11761" CreationDate="2015-05-16T19:51:50.500" Score="-1" Body="&lt;p&gt;I changed my Arduino Uno with Arduino Mega and problem is solved.Thank you&lt;/p&gt;&#xA;" OwnerUserId="8761" LastActivityDate="2015-05-16T19:51:50.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11904" PostTypeId="1" CreationDate="2015-05-16T20:01:13.923" Score="0" ViewCount="254" Body="&lt;p&gt;I have Arduino Mega and Weather Shield. I want to calculate wind speed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float get_wind_speed()&#xA;{&#xA;&#xA;float deltaTime = millis() - lastWindCheck; //750ms &#xA;&#xA;deltaTime /= 1000.0; &#xA;&#xA;  float windSpeed = (float)windClicks / deltaTime; //3 / 0.750s = 4&#xA;&#xA;  windClicks = 0; //Sıfırla ve yeni oluşan rüzgarı izle&#xA;  lastWindCheck = millis();&#xA;&#xA;  windSpeed *= 1.492; //4 * 1.492 = 5.968MPH&#xA;&#xA; Serial.println();&#xA; Serial.print(&quot;Windspeed :&quot;);&#xA; Serial.println(windSpeed);&#xA;&#xA; return(windSpeed);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run my code I see two windspeed value. First one is windspeed=0.0 or any value. Second one is windspeed=nan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make it better?&lt;/p&gt;&#xA;" OwnerUserId="8761" LastActivityDate="2015-06-16T04:57:18.900" Title="arduino weather shield and wind speed" Tags="|hardware|software|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11905" PostTypeId="2" ParentId="4233" CreationDate="2015-05-16T21:00:51.487" Score="1" Body="&lt;p&gt;I think your Arduino resets itself because of connection or current overload. Also, please share your connection. What is the voltage of the external source? If it needs high power, try a &lt;a href=&quot;http://en.wikipedia.org/wiki/MOSFET&quot; rel=&quot;nofollow&quot;&gt;MOSFET&lt;/a&gt; like &lt;a href=&quot;http://bildr.org/2012/03/rfp30n06le-arduino/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8552" LastEditorUserId="510" LastEditDate="2015-10-18T09:06:38.730" LastActivityDate="2015-10-18T09:06:38.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11907" PostTypeId="1" AcceptedAnswerId="11908" CreationDate="2015-05-16T23:32:13.663" Score="1" ViewCount="1921" Body="&lt;p&gt;I am using a standard infared distance sensor on a small robot and i am trying to even out the readings on it so it is more accurate. The readings are very sporadic and often take huge jumps in the distance. Is there a method of programming or circuit design that might make this easier to use? I'm trying to keep my robot from running into things. &lt;/p&gt;&#xA;" OwnerUserId="10106" LastActivityDate="2015-05-18T10:31:47.383" Title="How do I even out Infared distance sensor readings?" Tags="|sensors|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11908" PostTypeId="2" ParentId="11907" CreationDate="2015-05-17T00:34:52.530" Score="2" Body="&lt;p&gt;Wikipedia has a page on moving averages: &lt;a href=&quot;http://en.wikipedia.org/wiki/Moving_average&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Moving_average&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest at first try an exponential moving average: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;average = a * sample + (1 - a) * average&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Experiment with different values of a (with 0 &amp;lt; a &amp;lt;= 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The smaller a is, the smoother the curve, but also the longer (more iterations) it takes for an actual change in the input to be reflected in average.&lt;/p&gt;&#xA;" OwnerUserId="10107" LastEditorUserId="84" LastEditDate="2015-05-17T07:26:06.970" LastActivityDate="2015-05-17T07:26:06.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11909" PostTypeId="1" CreationDate="2015-05-17T03:00:31.533" Score="1" ViewCount="82" Body="&lt;p&gt;It keeps giving me this warning:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You are using a version of the Arduino IDE that is newer than available at the release of this plugin.`&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does this means I need to use a night build?&lt;/p&gt;&#xA;" OwnerUserId="10093" LastEditorUserId="4628" LastEditDate="2016-04-24T08:41:10.200" LastActivityDate="2016-04-24T08:41:10.200" Title="Can the Arduino Eclipse plugin v2.2 be used with Arduino 1.5.8?" Tags="|eclipse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11910" PostTypeId="2" ParentId="11893" CreationDate="2015-05-17T04:29:20.813" Score="1" Body="&lt;p&gt;When you have one working as AT mode, it puts out whatever comes in, it is also called transparent mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should first define which mode you want to use them and start coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose AT, load the firmware for both and use Arduino to check the commands and execute tasks (supposing it is connected to the router).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the task was done correctly, you send an okay message, otherwise, send error. This is a simple task in AT mode, just use Serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (led == 1)&#xA;   Serial.println(&quot;ok&quot;);&#xA;else&#xA;   Serial.println(&quot;error&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you choose API mode, it is a little bit different, where you have to mount the packet for sending data and put a message inside it. There are some &lt;a href=&quot;https://code.google.com/p/xbee-arduino/&quot; rel=&quot;nofollow&quot;&gt;libs&lt;/a&gt; out there you can achieve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other side, the coordinator will receive the message and interpret it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is in AT mode, just read the serial. In API, you have to decode the packet and check the payload field where the data is located.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-17T04:29:20.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11911" PostTypeId="2" ParentId="11904" CreationDate="2015-05-17T04:48:44.507" Score="1" Body="&lt;p&gt;When debugging a problem like this one, print out values of the variables that the calculation depends on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you may find that both &lt;code&gt;windClicks&lt;/code&gt; and &lt;code&gt;deltaTime&lt;/code&gt; are 0 or 0.0.  The IEEE 754 floating-point-operations specification dictates a result of &lt;code&gt;NaN&lt;/code&gt; (not-a-number) for various zero over zero calculations.  It dictates a result of &lt;code&gt;+Inf&lt;/code&gt; or &lt;code&gt;-Inf&lt;/code&gt; for calculations like 7/0.0 or -13/0.0.  [See, for example, the stackoverflow question, &lt;a href=&quot;https://stackoverflow.com/q/12954193&quot;&gt;Why does division by zero with floating point (or double precision) numbers not throw an exception&lt;/a&gt;.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If arithmetic generates a &lt;code&gt;NaN&lt;/code&gt; or &lt;code&gt;+Inf&lt;/code&gt; result, subsequent arithmetic using that result will also produce &lt;code&gt;NaN&lt;/code&gt; or &lt;code&gt;+Inf&lt;/code&gt; results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To deal with the problem, you could use &lt;code&gt;deltaTime &amp;gt; 0&lt;/code&gt; as a required pre-condition for calculation of &lt;code&gt;windSpeed&lt;/code&gt;.  That is, have an if-statement protecting the calculation block.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-05-17T04:48:44.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11912" PostTypeId="2" ParentId="11907" CreationDate="2015-05-17T06:34:19.230" Score="0" Body="&lt;p&gt;My solution keeps reading for cycles (10 times) and calculate average it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be careful voltage output of many surface NOT same. &lt;/p&gt;&#xA;" OwnerUserId="10110" LastActivityDate="2015-05-17T06:34:19.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11915" PostTypeId="1" AcceptedAnswerId="11919" CreationDate="2015-05-17T09:09:11.040" Score="0" ViewCount="157" Body="&lt;p&gt;Is it safe to feed 5v dc 1amp to an Arduino uno board?&lt;/p&gt;&#xA;" OwnerUserId="10114" LastActivityDate="2015-05-17T09:50:43.183" Title="Is it safe to feed 5v dc 1amp to an Arduino uno R3 board?" Tags="|power|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11916" PostTypeId="2" ParentId="11915" CreationDate="2015-05-17T09:24:46.467" Score="0" Body="&lt;p&gt;Yes as long as the polarity is correct, the board will only take the current it requires&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-05-17T09:24:46.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11917" PostTypeId="2" ParentId="11907" CreationDate="2015-05-17T09:37:32.033" Score="2" Body="&lt;p&gt;IR sensors are very erratic in my experience. The best way is to take an average of multiple sensor readings. The number of readings required can be found by experimentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example Sketch&lt;/strong&gt; (&lt;a href=&quot;https://www.parallax.com/downloads/sharp-gpy2y0a21yk0f-ir-distance-sensor-arduino-demo&quot; rel=&quot;nofollow&quot;&gt;Source&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example below should be similar, and a good start for your model of IR sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Sharp GP2Y0A21YK0F infrared proximity sensor (#28995)&#xA; Collects an average of five readings from the sensor and displays the&#xA; resulting value about every half second.&#xA;&#xA; See the SharpGP2Y0A21_Simple demonstration for additional usage notes,&#xA; including connection diagram.&#xA;&#xA; This example code is for the Arduino Uno and direct compatible boards, using the&#xA; Arduino 1.0 or later IDE software. It has not been tested, nor designed for, other &#xA; Arduino boards, including the Arduino Due.&#xA;&#xA;*/&#xA;&#xA;const int irSense = A0;          // Connect sensor to analog pin A0&#xA;int distance = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);            // Use Serial Monitor window&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(irRead(), DEC); // Call irRead function to read sensor&#xA;                                 // Print value in Serial Monitor&#xA;  delay(250);                    // Wait another 1/4 second for the next read&#xA;                                 // (Note: Because of delays built into the&#xA;                                 //   irRead function the display of values will&#xA;                                 //   be slower than in the SharpGP2Y0A21_Simple&#xA;                                 //   sketch&#xA;}&#xA;&#xA;// Take multiple readings, and average them out to reduce false readings&#xA;int irRead() {&#xA;  int averaging = 0;             //  Holds value to average readings&#xA;&#xA;  // Get a sampling of 5 readings from sensor&#xA;  for (int i=0; i&amp;lt;5; i++) {&#xA;    distance = analogRead(irSense);&#xA;    averaging = averaging + distance;&#xA;    delay(55);      // Wait 55 ms between each read&#xA;                    // According to datasheet time between each read&#xA;                    //  is -38ms +/- 10ms. Waiting 55 ms assures each&#xA;                    //  read is from a different sample&#xA;  }&#xA;  distance = averaging / 5;      // Average out readings&#xA;  return(distance);              // Return value&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8161" LastActivityDate="2015-05-17T09:37:32.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11918" PostTypeId="2" ParentId="11915" CreationDate="2015-05-17T09:49:52.530" Score="0" Body="&lt;p&gt;The 1 Ampère you're mentioning is likely the maximum rating of the power supply, i.e. it cannot sustain higher currents for a long time. However, if you connect your Arduino board (or any other device) to your power supply, the actually flowing current will depend on the voltage U and the resistance R of the device as I = U/R. You can think of this as the Arduino drawing as much power as it needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words: you must not exceed the maximum voltage, but you don't have to (and cannot in a simple way) adjust the current flowing into the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-17T09:49:52.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11919" PostTypeId="2" ParentId="11915" CreationDate="2015-05-17T09:50:43.183" Score="0" Body="&lt;p&gt;That's a common newbie question: &quot;What will happen when I use a 1 A power supply for a device which only needs 0.1 A?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device will only draw the current it needs. It's the same as on your electricity grid. The nuclear power plant can supply a gigawatt, yet the bulb will only draw the 60 W it needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But do you want to apply that 5 V to the power connector? Then the 5 V is too low, you'll need at least something like 6.5 V, otherwise the onboard voltage regulator won't have enough headroom to output 5 V. If you're using the USB connector for a &lt;strong&gt;regulated&lt;/strong&gt;(!) 5 V, then the onboard regulator will be bypassed. Never place an unregulated 5 V on the USB connector, though.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-05-17T09:50:43.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11921" PostTypeId="1" CreationDate="2015-05-17T10:58:39.463" Score="-1" ViewCount="10601" Body="&lt;p&gt;Please explain in detail. How the Hexadecimal code has been assigned?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;void setup() &#xA;{&#xA;   Wire.begin(); &#xA;   Serial.begin(9600); &#xA;   delay(1000); &#xA;   Serial.println(&quot;AT+CMGF=1&quot;); //set to SMS mode&#xA;   delay(1000);&#xA;   Serial.println(&quot;AT+CMGS=\&quot;+918460588440\&quot;&quot;); //set the phone number (wrapped in double quotes)&#xA;   delay(1000);&#xA;   Serial.println(&quot;hello world. this is arduino&quot;);&#xA;   delay(1000);&#xA;   Serial.write(0x1A); // sends ctrl+z end of message&#xA;   delay(1000);&#xA;   Serial.write(0x0D); // Carriage Return in Hex&#xA;   delay(1000);&#xA;   Serial.write(0x0A);&#xA;}&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user4236" LastEditorUserId="313" LastEditDate="2015-05-17T12:28:58.347" LastActivityDate="2015-05-17T12:35:41.200" Title="Can anyone explain how hex codes 0x1A is used for sending ctrl+z &amp; 0x0D for Carriage Return &amp; 0x0A for LineFeed?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11922" PostTypeId="2" ParentId="11921" CreationDate="2015-05-17T11:02:39.603" Score="0" Body="&lt;p&gt;These hex values are the numbers in the ASCII table, &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/ASCII&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Characters corresponding to values below 32 are control characters, reserved for special purposes. For the values you mention in the question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0x0d = 1*16 + d*1 = 13 = CR (carriage return)&lt;/li&gt;&#xA;&lt;li&gt;0x0a = 0*16 + a*1 = 10 = LF (line feed)&lt;/li&gt;&#xA;&lt;li&gt;0x1a = 1*16 + a*1 = 26 = &lt;a href=&quot;https://en.wikipedia.org/wiki/Control-Z&quot; rel=&quot;nofollow&quot;&gt;SUB&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(&quot;control+Z&quot; is not the ASCII control character, but how you would generate this control character (SUB) on a keyboard.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A table with both hexadecimal and decimal numbers is also &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart&quot; rel=&quot;nofollow&quot;&gt;given&lt;/a&gt; in the Wikipedia article.&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-17T11:02:39.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11923" PostTypeId="2" ParentId="11921" CreationDate="2015-05-17T11:06:29.087" Score="1" Body="&lt;p&gt;They are all to do with where in the alphabet they are.  There are 26 letters in the English alphabet, and Z is the 26th.  The 26 in hexadecimal is 0x1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A carriage return is a CTRL-M, and a line feed is a CTRL-J.  M is the 13th letter of the alphabet, and 13 in hexadecimal is 0x0D.  J is the 10th letter - 10 is 0x0A in hexadecimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are they CTRL-M and CTRL-J?  Well, that all stems from the old teletype interfaces used on the very early computers.  That's what they used, and that's what's stuck, and finally made it into the ASCII standard.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-17T11:06:29.087" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11925" PostTypeId="2" ParentId="11921" CreationDate="2015-05-17T12:35:41.200" Score="0" Body="&lt;p&gt;(I've formatted your code and edited it into your question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code is apparently driving a device - GPRS shield? - to send an SMS. No doubt the code was written to meet the requirements of the device. Note that the CR and LF literals could have been written as '\r' and '\n', respectively. The author chose to write them in hex, probably because there is no &quot;\&quot; code defined for Ctrl-Z, and so wrote all three in a consistent style.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-17T12:35:41.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11926" PostTypeId="2" ParentId="9413" CreationDate="2015-05-17T14:20:09.373" Score="2" Body="&lt;p&gt;It does it to &quot;force&quot; a reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Historically, when you open the serial port on an FTDI interface, the DTR will automatically go LOW.  However, recently FTDI decided it'd be a good idea to change their driver so that when you open the port the DTR line doesn't go low - you have to manually tell it to go low.  But this is only on the FTDI official drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a driver that is newer than a certain date (no idea what date) then just running &lt;code&gt;avrdude&lt;/code&gt; by itself on an FTDI interface may not work properly since DTR isn't being lowered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around that Arduino have included a forced toggling of the DTR line as part of the programming sequence to make the target board reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course, if the driver is old enough, or not the &quot;official&quot; FTDI driver (i.e., you're in Linux for instance) then the lowering of the DTR by &lt;code&gt;avrdude&lt;/code&gt; works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you are seeing there is first a brief toggle of DTR by the IDE to force a reset, then &lt;code&gt;avrdude&lt;/code&gt; opening the port and DTR going low, then finally the IDE toggling DTR again one last time to force a final reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to me that says you're either not in Windows, or you have an FTDI driver while does toggle the DTR line automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a feeling that &lt;code&gt;avrdude&lt;/code&gt; may also have started including manual control of the DTR line within it - so if &lt;code&gt;avrdude&lt;/code&gt; is new enough, even with a new FTDI driver that doesn't automatically, you will still see the repeated action of DTR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's what we call &lt;em&gt;belt and braces&lt;/em&gt;.  Use every method possible to get the board to reset, so no matter what you hardware and software arrangement the board has a very good chance of being reset into the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-17T14:20:09.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11927" PostTypeId="2" ParentId="11674" CreationDate="2015-05-17T14:22:31.523" Score="1" Body="&lt;p&gt;There was some mistakes in the boards.txt it seems. After finding a very detailed and extensive boards file &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=89781.msg2235877#msg2235877&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, I modified it to have neat and tidy categories and is easier to use to become a working boards.txt. I had to burn the bootloader once to set the fuses right. After that everything works like a charm for 3 ATtiny13! No warnings or errors. This is used with Arduino 1.6.4. The folder tree is &lt;code&gt;~Arduino/hardware/attiny/avr/cores/core13&lt;/code&gt; and &lt;code&gt;~Arduino/hardware/attiny/avr/boards.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# boards.txt for Arduino 1.6.4&#xA;&#xA;menu.flag=GCC Flags&#xA;menu.cpu=Processor&#xA;menu.clock=Clock&#xA;&#xA;attiny13.name=ATtiny13&#xA;attiny13.upload.tool=arduino:avrdude&#xA;attiny13.upload.using=arduino:usbtiny&#xA;&#xA;attiny13.bootloader.tool=arduino:avrdude&#xA;&#xA;attiny13.menu.cpu.attiny13=ATtiny13&#xA;attiny13.menu.cpu.attiny13.upload.maximum_size=1024&#xA;attiny13.menu.cpu.attiny13.upload.maximum_data_size=64&#xA;attiny13.menu.cpu.attiny13.build.mcu=attiny13&#xA;attiny13.menu.cpu.attiny13.build.core=core13&#xA;# attiny13.menu.cpu.attiny13.build.variant=core13&#xA;&#xA;#################################################&#xA;############## clock speeds #####################&#xA;#################################################&#xA;&#xA;#### 9.6 MHz&#xA;############&#xA;attiny13.menu.clock.t13_9M6=9.6MHz (internal clock, Preserve EEPROM, BOD disable)&#xA;attiny13.menu.clock.t13_9M6.bootloader.low_fuses=0x3A&#xA;attiny13.menu.clock.t13_9M6.bootloader.high_fuses=0xFF&#xA;attiny13.menu.clock.t13_9M6.upload.speed=57600L&#xA;attiny13.menu.clock.t13_9M6.build.f_cpu=9600000L&#xA;&#xA;#### 9.6 MHz - 2.7V&#xA;attiny13.menu.clock.t13_9M6_bod=9.6MHz (internal clock, Preserve EEPROM, BOD - 2.7V)&#xA;attiny13.menu.clock.t13_9M6_bod.bootloader.low_fuses=0x32&#xA;attiny13.menu.clock.t13_9M6_bod.bootloader.high_fuses=0xFB&#xA;attiny13.menu.clock.t13_9M6_bod.upload.speed=57600L&#xA;attiny13.menu.clock.t13_9M6_bod.build.f_cpu=9600000L&#xA;&#xA;#### 4.8 MHz - 2.7V&#xA;attiny13.menu.clock.t13_4M8_bod=4.8 MHz (int 4.8 MHz clock, Preserve_EEPROM, BOD - 2.7V)&#xA;attiny13.menu.clock.t13_4M8_bod.bootloader.low_fuses=0x31&#xA;attiny13.menu.clock.t13_4M8_bod.bootloader.high_fuses=0xFB&#xA;attiny13.menu.clock.t13_4M8_bod.upload.speed=57600L&#xA;attiny13.menu.clock.t13_4M8_bod.build.f_cpu=4800000L&#xA;&#xA;#### 1.2 MHz&#xA;attiny13.menu.clock.t13_1M2=1.2 MHz (int 9.6 MHz divided by 8,Preserve_EEPROM, BOD - 2.7V)&#xA;attiny13.menu.clock.t13_1M2.bootloader.low_fuses=0x2A&#xA;attiny13.menu.clock.t13_1M2.bootloader.high_fuses=0xFB&#xA;attiny13.menu.clock.t13_1M2.upload.speed=9600L&#xA;attiny13.menu.clock.t13_1M2.build.f_cpu=1200000L&#xA;&#xA;#### 600 kHz&#xA;attiny13.menu.clock.t13_0M6=600 kHz (int 4.8 MHz divided by 8, Preserve_EEPROM, BOD disable)&#xA;attiny13.menu.clock.t13_0M6.bootloader.low_fuses=0x29&#xA;attiny13.menu.clock.t13_0M6.bootloader.high_fuses=0xFF&#xA;attiny13.menu.clock.t13_0M6.upload.speed=9600L&#xA;attiny13.menu.clock.t13_0M6.build.f_cpu=600000L&#xA;&#xA;## 128 kHz&#xA;attiny13.menu.clock.t13_128k=128 KHz (internal watchdog oscillator)&#xA;attiny13.menu.clock.t13_128k.bootloader.low_fuses=0x7B&#xA;attiny13.menu.clock.t13_128k.bootloader.high_fuses=0xFF&#xA;attiny13.menu.clock.t13_128k.upload.speed=250&#xA;attiny13.menu.clock.t13_128k.build.f_cpu=128000L&#xA;&#xA;## 16 kHz&#xA;attiny13.menu.clock.t13_16k=16 KHz (internal watchdog oscillator, Preserve_EEPROM, BOD disable)&#xA;attiny13.menu.clock.t13_16k.bootloader.low_fuses=0x2B&#xA;attiny13.menu.clock.t13_16k.bootloader.high_fuses=0xFF&#xA;attiny13.menu.clock.t13_16k.upload.speed=250&#xA;attiny13.menu.clock.t13_16k.build.f_cpu=16000L&#xA;&#xA;&#xA;&#xA;##-----------------------------------&#xA;##--------- compiler flags ----------&#xA;##-----------------------------------&#xA;&#xA;attiny13.menu.flag.Os=Default&#xA;attiny13.menu.flag.Os.compiler.c.extra_flags=&#xA;attiny13.menu.flag.Os.compiler.c.elf.extra_flags=&#xA;attiny13.menu.flag.Os.compiler.cpp.extra_flags=&#xA;&#xA;attiny13.menu.flag.Os_flto=Default -flto&#xA;attiny13.menu.flag.Os_flto.compiler.c.extra_flags=-Wextra -flto&#xA;attiny13.menu.flag.Os_flto.compiler.c.elf.extra_flags=-w -flto&#xA;attiny13.menu.flag.Os_flto.compiler.cpp.extra_flags=-Wextra -flto&#xA;&#xA;attiny13.menu.flag.O1=-O1&#xA;attiny13.menu.flag.O1.compiler.c.extra_flags=-O1&#xA;attiny13.menu.flag.O1.compiler.c.elf.extra_flags=-O1&#xA;attiny13.menu.flag.O1.compiler.cpp.extra_flags=-O1&#xA;&#xA;attiny13.menu.flag.O1_flto=-O1 -flto&#xA;attiny13.menu.flag.O1_flto.compiler.c.extra_flags=-O1 -Wextra -flto&#xA;attiny13.menu.flag.O1_flto.compiler.c.elf.extra_flags=-O1 -w -flto&#xA;attiny13.menu.flag.O1_flto.compiler.cpp.extra_flags=-O1 -Wextra -flto&#xA;&#xA;attiny13.menu.flag.O3=-O3&#xA;attiny13.menu.flag.O3.compiler.c.extra_flags=-O3&#xA;attiny13.menu.flag.O3.compiler.c.elf.extra_flags=-O3&#xA;attiny13.menu.flag.O3.compiler.cpp.extra_flags=-O3&#xA;&#xA;attiny13.menu.flag.O3_flto=-O3 -flto&#xA;attiny13.menu.flag.O3_flto.compiler.c.extra_flags=-O3 -Wextra -flto&#xA;attiny13.menu.flag.O3_flto.compiler.c.elf.extra_flags=-O3 -w -flto&#xA;attiny13.menu.flag.O3_flto.compiler.cpp.extra_flags=-O3 -Wextra -flto&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2015-05-17T14:22:31.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11928" PostTypeId="1" AcceptedAnswerId="11929" CreationDate="2015-05-17T14:31:13.390" Score="0" ViewCount="2032" Body="&lt;p&gt;So I've been trying to get a capacitive sensor made from aluminum foil to work. And I have had success the kind of proximity and readings I need to light up a single LED and produce basic tone. Using this very basic code : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  Serial.println(value1);//value that i get from analog sensor&#xA;  //this is just to get the values in order for the led and sound&#xA;  if (value1&amp;lt;=8) value1=-100; &#xA;  analogWrite(ledPin,value1+100);//these weird calculations seem to work for me&#xA;  tone(tonepin,value1+100,100); &#xA;  delay(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All this works perfectly for me, the delay isn't perceivable, the response is for all practical purposes simultaneous to input. Except it's not beautiful, because the LED keeps flickering when values reduce or increase because the jumps are sudden I suppose. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;SO I thought I'll try to fade in and fade out to different values from present values.  Used the fading examples. Here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(value1);&#xA;  if (value1&amp;lt;=8) value1=-100;&#xA;&#xA;  if (value1+100&amp;lt;=value2+100) {&#xA;    for(int fadeValue = value2+100 ; fadeValue &amp;lt;= value1+100; fadeValue +=5) {&#xA;&#xA;    analogWrite(ledPin, fadeValue);        &#xA;&#xA;    delay(10);                            &#xA;    } &#xA;  }&#xA;&#xA;  else &#xA;  {&#xA;&#xA;    for(int fadeValue = value2+100 ; fadeValue &amp;gt;= value1+100; fadeValue -=5) &#xA;    {&#xA;        analogWrite(ledPin, fadeValue);        &#xA;&#xA;    delay(10);                            &#xA;    } &#xA;  }&#xA;  //analogWrite(ledPin,value1+100);&#xA;  tone(tonepin,value1+100,100); &#xA;  delay(10);&#xA;  value2=value1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this takes away the responsiveness, the whole thing is so slow to react, the sound and the light are obviously not in sync as I read my code. But also the light is not really fading, still blinking, but there seems to be some effect but I am not sure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help with what I could do and what I am doing wrong would be nice. &lt;/p&gt;&#xA;" OwnerUserId="10118" LastEditorUserId="2881" LastEditDate="2015-05-17T14:37:26.513" LastActivityDate="2015-05-17T14:57:02.757" Title="How to fade in and fade out led strip connected to arduino based on continous analog input from capacitative sensor?" Tags="|arduino-uno|led|pwm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11929" PostTypeId="2" ParentId="11928" CreationDate="2015-05-17T14:45:24.597" Score="0" Body="&lt;p&gt;Smooth the change in output value by taking, e.g 10% of the new value, and 90% of the old value. You can try experimenting with different ratios and longer/shorter delays.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int lastValue = 0;&#xA;&#xA;{&#xA;  Serial.println(value1);//value that i get from analog sensor&#xA;  //this is just to get the values in order for the led and sound&#xA;  if (value1&amp;lt;=8) value1=-100;&#xA;  value1 = (1*value + 9*lastValue)/10;// smooth the change in value by taking 10% of the current value, and 90% of the previous value&#xA;  analogWrite(ledPin,value1+100);//these weird calculations seem to work for me&#xA;  tone(tonepin,value1+100,100); &#xA;  lastValue = value1;&#xA;  delay(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-17T14:45:24.597" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11930" PostTypeId="2" ParentId="11928" CreationDate="2015-05-17T14:57:02.757" Score="0" Body="&lt;p&gt;You need to re-think the entire way of dealing with the fading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of saying &quot;The value has changed, fade the LED to that brightness&quot;, you need to say &quot;The value has changed. I want the LED to be this brightness.&quot; followed by &quot;Is the LED the brightness I want? No? Then move it a bit towards the brightness I want&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like, in pseudo-code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TargetBrightness = SensorValue&#xA;if LEDBrightness &amp;lt; TargetBrightness&#xA;    increment LEDBrightness&#xA;    set LED to LEDBrightness&#xA;if LEDBrightness &amp;gt; TargetBrightness&#xA;    decrement LEDBrightness&#xA;    set LED to LEDBrightness&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that all happens too fast then you need to only run the brightness tests at certain periods.  Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TargetBrightness = SensorValue&#xA;Has 10ms passed since last check? Yes?&#xA;    Remember the time this check happened.&#xA;    if LEDBrightness &amp;lt; TargetBrightness&#xA;        increment LEDBrightness&#xA;        set LED to LEDBrightness&#xA;    if LEDBrightness &amp;gt; TargetBrightness&#xA;        decrement LEDBrightness&#xA;        set LED to LEDBrightness&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-17T14:57:02.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11931" PostTypeId="2" ParentId="153" CreationDate="2015-05-17T16:03:54.893" Score="2" Body="&lt;p&gt;If you have another, working, Uno, and both have socketed microcontroller chips, you could use the known board to program a test sketch onto the unknown board's chip, put it back on the unknown board, and run it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I like the following (pseudo-coded) test sketch for quick-checking my hand-built boards; it's just as handy for testing an unknown factory-built one. It's not an exhaustive test, it just checks for basic digital I/O, serial I/O, and shorts or opens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;forever,&#xA;  for each digital I/O pin:&#xA;    write high;&#xA;    delay 100ms;&#xA;    write low;&#xA;  end;&#xA;&#xA;  write &quot;Hello, World!\n&quot; to serial output;&#xA;  while serial character available,&#xA;    write character to serial output;&#xA;  end;&#xA;  write &quot;\n&quot; to the serial output;&#xA;end;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A test LED - an LED with its resistor soldered to it - connected between any I/O and ground should blink every 2 seconds. If it doesn't, that pin may have failed or have a bad connection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Two test LEDs connected to numerically adjacent pins (they may not be physically next to one another) should blink in sequence. If they blink together, it indicates a short, probably a solder bridge, between them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The terminal should say &quot;Hello World!&quot; every two seconds. If not, that pin or the FTDI cable or on-board USB/Serial chip may have failed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Type something on the keyboard and it should be repeated back to the serial terminal (if the previous test passed). If not, again that pin or the FTDI cable or on-board USB/Serial chip may have failed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-05-27T10:18:03.387" LastActivityDate="2015-05-27T10:18:03.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11936" PostTypeId="1" CreationDate="2015-05-17T18:17:04.260" Score="1" ViewCount="435" Body="&lt;p&gt;I have Arduino Mega and Weather shield and GPS Receiver - GP-635T (50 Channel).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my code for GPS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;&#xA;TinyGPSPlus gps;&#xA;&#xA;static const int RXPin = 5, TXPin = 4;&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;const byte GPS_PWRCTL = 6;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(9600);&#xA;&#xA;  pinMode(GPS_PWRCTL, OUTPUT);&#xA;  digitalWrite(GPS_PWRCTL, HIGH);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  smartdelay(800);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And print weather with this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void printWeather()&#xA;{&#xA;  Serial.print(&quot;lat=&quot;);&#xA;  Serial.print(gps.location.lat(), 6);&#xA;  Serial.print(&quot;lat=&quot;);&#xA;  Serial.print(gps.location.lng(), 6);&#xA;  Serial.print(&quot;altitude=&quot;);&#xA;  Serial.print(gps.altitude.meters());&#xA;  Serial.print(&quot;sats=&quot;);&#xA;  Serial.print(gps.satellites.value());&#xA;&#xA;  char sz[32];&#xA;  Serial.print(&quot;date=&quot;);&#xA;  sprintf(sz, &quot;%02d/%02d/%02d&quot;, gps.date.month(), gps.date.day(),gps.date.year());&#xA;  Serial.print(sz);&#xA;&#xA;  Serial.print(&quot;time=&quot;);&#xA;  sprintf(sz, &quot;%02d:%02d:%02d&quot;, gps.time.hour(), gps.time.minute(), gps.time.second());&#xA;  Serial.print(sz);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I see only zero for location and date and time. What should I do?&lt;/p&gt;&#xA;" OwnerUserId="8761" LastActivityDate="2016-03-13T17:28:50.263" Title="arduino weather shield with gps" Tags="|gps|tinygps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11937" PostTypeId="1" CreationDate="2015-05-17T18:38:42.257" Score="2" ViewCount="1757" Body="&lt;p&gt;I'm planning to make a handbrake for my racing simulator (Assetto Corsa) and I wanted to know how can I transform arduino into a joystick so the game can read the &lt;strong&gt;analog&lt;/strong&gt; input?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance, and sorry for my bad english.&lt;/p&gt;&#xA;" OwnerUserId="10125" LastActivityDate="2015-12-30T16:04:19.887" Title="Arduino analog joystick" Tags="|arduino-uno|programming|potentiometer|emulation|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11939" PostTypeId="1" CreationDate="2015-05-17T19:04:26.227" Score="-1" ViewCount="440" Body="&lt;p&gt;I have a wearable wristband project where I'd like to detect a touch to the outside of the wristband, like a button. However, all my attempts to get this to work with capacitive sensing fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problems accumulate from these aspects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Without grounding, the behaviour seems totally arbitrary at times&lt;/li&gt;&#xA;&lt;li&gt;I need high response times (12 fps so &amp;lt; 100ms), so some resistor values keep hitting the timeout limit&lt;/li&gt;&#xA;&lt;li&gt;Testing is really hard, as behaviour changes after unplugging the USB connection to the computer. I have a bluetooth connection in the Arduino and debug via bluetooth connection to get a &quot;actual scenario&quot; type of reading&lt;/li&gt;&#xA;&lt;li&gt;I've also tried things like setting very short timeouts as well as low sample sizes as well as experimented with different resistors&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I am not trying to really get any sort of gradual &quot;capacitive sensing&quot; here at all, I merely would need to detect a threshold for &quot;is touching&quot;. In fact, the area that the user is touching could even be made out of metal (which it was in my tests so far) and touched directly (so nothing in between finger and metal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems like such an obvious thing to try to achieve, I believe there must be some way to get this done. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="7157" LastActivityDate="2016-02-18T22:34:48.293" Title="Capacitive sensor touch detection on wearable" Tags="|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11941" PostTypeId="1" CreationDate="2015-05-17T19:42:38.500" Score="9" ViewCount="38308" Body="&lt;p&gt;Is there any way to store the values of necessary variables somewhere (may be in a file that gets updated by the program at various events), which can be read back when program starts after rebooting the Arduino board?&lt;/p&gt;&#xA;&lt;p&gt;I am trying to control my AC appliances using IR remote control. Where I want Arduino to remember what was on and what was off in my room after a power failure.&lt;/p&gt;&#xA;&lt;p&gt;Using EEPROM looks like a fairly good solution, though it has a limitation of 100,000 writes which is making me try to find another way out.&lt;/p&gt;&#xA;&lt;p&gt;Using an external EEPROM which doesn't have that limitation or is fairly big, is a really good idea I got from fuenfundachtzig, thanks for this great idea. But I don't know how to implement this in my project. Any resource to gather knowledge on using external EEPROM, will be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10114" LastEditorUserId="90731" LastEditDate="2023-06-29T07:43:31.400" LastActivityDate="2023-12-13T16:08:02.883" Title="How to remember variable values after rebooting an Arduino Uno R3 board?" Tags="|power|system-design|eeprom|home-automation|" AnswerCount="7" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="11942" PostTypeId="2" ParentId="11941" CreationDate="2015-05-17T19:43:41.410" Score="2" Body="&lt;p&gt;Store them in the on-chip EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/EEPROM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/EEPROMWrite&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/EEPROMWrite&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/EEPROMRead&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/EEPROMRead&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-17T19:43:41.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11943" PostTypeId="2" ParentId="11941" CreationDate="2015-05-17T20:52:49.410" Score="7" Body="&lt;p&gt;The internal RAM of the Arduino will be reset when you repower the chip, so if you want to keep your data, you need to store it in EEPROM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are worried about the limited write/erase cycles, you should estimate how often the data would be updated (i.e. written to EEPROM) and how long you plan the lifetime of the device you build. If 100,000 cycles then still is an issue, you have several options: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Keep the variables in RAM and only write them to EEPROM say every 5 minutes (100,000 cycles then makes about one year of continuous usage until the EEPROM might fail).&lt;/li&gt;&#xA;&lt;li&gt;Use an external EEPROM (in a socket) that could be easily replaced if needed.&lt;/li&gt;&#xA;&lt;li&gt;If replacing it is not an option, consider using an &lt;a href=&quot;http://en.wikipedia.org/wiki/Ferroelectric_RAM&quot; rel=&quot;noreferrer&quot;&gt;FRAM&lt;/a&gt; instead (advantage vs EEPROM: &lt;em&gt;much&lt;/em&gt; more erase/write cycles but also very expensive, so not an option for large amounts of data but certainly for a few variables).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note, however, that your description sounds like a typical use-case for user settings that you don't want to get lost on reboot. For those the internal EEPROM is the right place: only store them when they're changed and you're golden -- the user won't change them a 100,000 times easily...&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-17T20:52:49.410" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11944" PostTypeId="1" AcceptedAnswerId="11978" CreationDate="2015-05-17T22:26:43.547" Score="-1" ViewCount="948" Body="&lt;p&gt;Does anyone have any information other than &quot;coming soon&quot; about the Tre?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;ul&gt;&lt;li&gt;Could the Tre be stuck in development hell?&lt;/li&gt;&#xA;&lt;li&gt;Perhaps the new partnership with Adafruit could expidite things, seeing as Ardiuno (.cc) was touting the Tre to be the first Arduino made in the USA?&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;p&gt;I'm just giddily awaiting its arrival, so I'm just wondering!&lt;/p&gt;&lt;/p&gt;&#xA;" OwnerUserId="8121" LastActivityDate="2015-05-18T22:27:15.840" Title="Arduino Tre, will it ever come out?" Tags="|hardware|" AnswerCount="1" CommentCount="1" ClosedDate="2015-05-28T22:04:04.043" ContentLicense="CC BY-SA 3.0" />
  <row Id="11945" PostTypeId="2" ParentId="11941" CreationDate="2015-05-17T22:28:25.623" Score="3" Body="&lt;p&gt;EEPROM space, as already mentioned, will work if non-volatile is required. However, you have not qualified if it needs to be non-volatile or not. If not then you can use an __attribute__ to define the variable space not to be initialized. As the SRAM on the ATmega's are not cleared by reset or power cycle. The Compiler defaults to initializing them. Where this can be turned off per variable as in the below example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//non-initialized value&#xA;union configUnion{&#xA;  uint8_t    byte[6]; // match the below struct...&#xA;  struct {&#xA;    uint16_t value1;&#xA;    uint16_t value2;&#xA;    uint16_t chksum;&#xA;  } val ;&#xA;} config  __attribute__ ((section (&quot;.noinit&quot;)));&#xA;&#xA;void setup() {&#xA;  uint16_t sum; &#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  // prints title with ending line break&#xA;  Serial.print(&quot;Out of Reset -&quot;);&#xA;  sum = getchksum();&#xA;  printValues();&#xA;&#xA;  if (sum != config.val.chksum) {&#xA;    config.val.chksum = sum;&#xA;    Serial.print(&quot;chksum is incorrect setting config.val.chksum = 0x&quot;); Serial.println(config.val.chksum, HEX);&#xA;  }&#xA;&#xA;  config.val.value1++;&#xA;  config.val.value2++;&#xA;  Serial.print(&quot;setup new values - &quot;);&#xA;  printValues();&#xA;  config.val.chksum = getchksum();&#xA;  Serial.print(&quot;updating chksum config.val.chksum = 0x&quot;); Serial.println(config.val.chksum, HEX);&#xA;}&#xA;&#xA;int counter = 0;&#xA;&#xA;void loop() {&#xA;  if (counter &amp;lt; 200) {&#xA;    Serial.print(&quot;after a while - &quot;);&#xA;    printValues();&#xA;    Serial.println();&#xA;    while (true) {&#xA;      continue;&#xA;    }&#xA;  }&#xA;  counter++;&#xA;}&#xA;&#xA;void printValues() {&#xA;  Serial.print(&quot; value1 = 0x&quot;); Serial.print(config.val.value1, HEX);&#xA;  Serial.print(&quot;, value2 = 0x&quot;); Serial.print(config.val.value2, HEX);&#xA;  Serial.print(&quot;, sum = 0x&quot;); Serial.print(getchksum(), HEX);&#xA;  Serial.print(&quot;, chksum = 0x&quot;); Serial.println(config.val.chksum, HEX);&#xA;}&#xA;&#xA;uint16_t getchksum() {&#xA;  int sum = 0;&#xA;  for (int position = 0; position &amp;lt; (sizeof(config) - sizeof(config.val.chksum)); position++) {&#xA;    sum = sum + config.byte[position];&#xA;  }&#xA;  return sum;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output of above code is below. Note that the first output was the result of powering the UNO up with the Reset button depressed and then released after the Monitor window was started. Otherwise the &quot;incorrect setting&quot; print would have been missed, before the monitor window can be started.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Out of Reset - value1 = 0xBFED, value2 = 0xD2F9, sum = 0x377, chksum = 0xF457&#xA;chksum is incorrect setting config.val.chksum = 0x377&#xA;setup new values -  value1 = 0xBFEE, value2 = 0xD2FA, sum = 0x379, chksum = 0x377&#xA;updating chksum config.val.chksum = 0x379&#xA;after a while -  value1 = 0xBFEE, value2 = 0xD2FA, sum = 0x379, chksum = 0x379&#xA;&#xA;Out of Reset - value1 = 0xBFEE, value2 = 0xD2FA, sum = 0x379, chksum = 0x379&#xA;setup new values -  value1 = 0xBFEF, value2 = 0xD2FB, sum = 0x37B, chksum = 0x379&#xA;updating chksum config.val.chksum = 0x37B&#xA;after a while -  value1 = 0xBFEF, value2 = 0xD2FB, sum = 0x37B, chksum = 0x37B&#xA;&#xA;Out of Reset - value1 = 0xBFEF, value2 = 0xD2FB, sum = 0x37B, chksum = 0x37B&#xA;setup new values -  value1 = 0xBFF0, value2 = 0xD2FC, sum = 0x37D, chksum = 0x37B&#xA;updating chksum config.val.chksum = 0x37D&#xA;after a while -  value1 = 0xBFF0, value2 = 0xD2FC, sum = 0x37D, chksum = 0x37D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this your variables will persist resets. As long as the power is not lost. Noting the above where you will get random data, to start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using either EEPROM or .noinit I would recommend that you checksum your persistent variable space during setup and if incorrect you can initialize or issue a warning.&lt;/p&gt;&#xA;" OwnerUserId="60" LastActivityDate="2015-05-17T22:28:25.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11946" PostTypeId="1" AcceptedAnswerId="18698" CreationDate="2015-05-17T22:56:13.453" Score="18" ViewCount="29184" Body="&lt;p&gt;I am doing a small project with a bathroom scale but I run into some problems. I am using an Arduino Uno V3, HX711 module amp and a scale. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Scale:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Bxnr9.jpg&quot; alt=&quot;Digital bathroom scale with 4 sensors&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HX711 amplifier:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/NppEm.jpg&quot; alt=&quot;Amplifier&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disassembled the scale to get to sensor wires and I am a bit confused. These sensors have three wires each. So they are half bridge sensors. The scale is using 4 sensors so when the scale is measuring it is measuring with a full bridge. And these 3 wires are RED, BLACK, BLUE. I don't know what is black (GND or Positive) and blue (same guess). Four red wires are given names E+, E-, S+ and S-. I will provide a picture of the disassembled scale.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/04AzD.jpg&quot; alt=&quot;Sensor wires&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two blue wires are soldered together on each side. I guess red wires are signal (S+, S-, E+ and E-) but what are Blue and Black? Then I soldered the wires to these wires to get sensor readings but I don't know what is what. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/en6bG.jpg&quot; alt=&quot;Config&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor is looking like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/EGMol.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I tried:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Two different libraries for this project both named HX711 (for this module)&lt;/li&gt;&#xA;&lt;li&gt;Changing A+ for A- on module&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Hx711.DOUT - pin #A1&#xA;// Hx711.SCK - pin #A0&#xA;&#xA;#include &quot;hx711.h&quot;&#xA;&#xA;Hx711 scale(A1, A0);&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Serial.print(scale.getGram(), 1);&#xA;  Serial.println(&quot; g&quot;);&#xA;&#xA;  delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;with no success. I get 0.0g on the serial monitor when calm, and the same when load is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions are:&lt;/strong&gt;&#xA;How to know which wire is GND, +5V and which is signal? How to connect 4 of these sensors to read data? How to use HX711 libraries available and HX711 module? And, most important, how to read data from this scale on serial?&lt;/p&gt;&#xA;" OwnerUserId="10131" LastEditorUserId="27346" LastEditDate="2017-11-19T13:01:28.430" LastActivityDate="2018-07-14T06:58:14.597" Title="How to get weight data from glass electronic bathroom scale sensors?" Tags="|arduino-uno|serial|sensors|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="11947" PostTypeId="2" ParentId="11946" CreationDate="2015-05-18T00:45:38.733" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;The HX711 provides power to a bridge and amplifies the bridge's differential voltage.  The scale's original circuit board (which drives an LCD readout) also  provides power to a bridge.  You are unlikely to get any useful readings while both circuits are applying power to the bridge.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(You could cut the existing wires and attach connectors to allow changing back and forth between the original board and your Arduino circuit.)&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Some scales like the one shown use a 9 V battery to run the electronics.  That voltage, if used, is likely to be incompatible with connecting an Arduino (typically powered by 3.3 V or 5 V) or an HX711 (powered with VDD in the range 2.7 V to 5.5 V) at the same time as the original board.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-18T00:45:38.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11948" PostTypeId="2" ParentId="11936" CreationDate="2015-05-18T06:44:27.953" Score="0" Body="&lt;p&gt;You need to feed the output from the GPS module to the &lt;code&gt;TinyGPSPlus&lt;/code&gt; routines, otherwise they won't do anything (other than return &lt;code&gt;0&lt;/code&gt;). Try adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial.available() &amp;gt; 0) {&#xA;  gps.encode(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;loop&lt;/code&gt;. &lt;code&gt;TinyGPSPlus&lt;/code&gt; comes with examples that you should have a look at. It also provides many debug statistics, e.g. the number of characters processed (&lt;code&gt;gps.charsProcessed()&lt;/code&gt;) and the if these made sense (&lt;code&gt;gps.passedChecksum()&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2015-05-18T06:44:27.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11949" PostTypeId="2" ParentId="11865" CreationDate="2015-05-18T07:01:20.757" Score="0" Body="&lt;p&gt;not a direct answer but the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/cc3000-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;sparkfun hookup guide&lt;/a&gt; connects pin 8 (SDCS) to the chip select for the SD card. If this line is floating, I'm not sure of the impact.&lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-05-18T07:01:20.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11950" PostTypeId="1" AcceptedAnswerId="11955" CreationDate="2015-05-18T07:02:18.120" Score="0" ViewCount="1811" Body="&lt;p&gt;i've got a seven-segment-display on my arduino-nano and want to write some numbers on it. The problem is that HIGH and LOW seems to be reversed.&#xA;If the output should be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it displays &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could solve this, replacing all HIGH and LOW through HIGHX and LOWX, and defining them reversed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #define HIGHX 0x0&#xA; #define LOWX 0x1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this is reversed and not a &lt;em&gt;good&lt;/em&gt; solution...&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring is correct like this (just GND not connected):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/DwotM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if i connect the GND, the hole display isn't showing something anymore.&lt;/p&gt;&#xA;" OwnerUserId="10134" LastEditorUserId="11529" LastEditDate="2017-03-17T20:39:32.963" LastActivityDate="2017-11-06T21:51:28.200" Title="HIGH and LOW reversed" Tags="|arduino-nano|display|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11951" PostTypeId="1" AcceptedAnswerId="11965" CreationDate="2015-05-18T07:21:38.703" Score="0" ViewCount="3217" Body="&lt;p&gt;I have been trying OR conditional operator in a if condition statement in my arduino program and the result is not what I expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// three variables assigned to const int datatype as the&#xA;// pin numbers they are assigned to are  going to remain &#xA;// constant through out the program.&#xA;const int led1=10;&#xA;const int led2=11;&#xA;const int led3=12;&#xA;&#xA;void setup(){&#xA;  // assigning the pins as input/output.&#xA;  pinMode(10,INPUT);&#xA;  pinMode(11,INPUT);&#xA;  pinMode(12,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  control();&#xA;}&#xA;&#xA;void control()&#xA;{&#xA;  int task1 = digitalRead(led1);&#xA;  int task2 = digitalRead(led2);&#xA;  if (task1==HIGH || task2==HIGH)&#xA;  {&#xA;    digitalWrite(led3,HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(led3,LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if the 'IF' conditional statement used without 'OR' operator is working fine that is not including both the tasks instead only one task either task1 or task2, else it is working without errors but the result is not as expected.&#xA;hardware part is all fine. i reckon that there is a problem with the OR || operator.&lt;/p&gt;&#xA;" OwnerUserId="10136" OwnerDisplayName="muhammad rizwan" LastEditorUserId="6452" LastEditDate="2015-05-18T13:48:47.357" LastActivityDate="2015-05-22T03:59:46.723" Title="Arduino OR operator" Tags="|programming|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="11953" PostTypeId="2" ParentId="11946" CreationDate="2015-05-18T08:06:57.837" Score="1" Body="&lt;p&gt;Text mainly from my comments with some additions - with image added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensors are quite possibly configured as in Fig1 in the data sheet.&lt;br&gt;&#xA; If so there should be +5 and 0V across two points, and weight signal between two others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a DMM to Check for Vdd (probably 5V if pV battery, ~= 3V with Lithium battery). Find two leads to bridge with ~= Vdd on. Other two probably at Vdd/2 above ground. It is likely there are 4 wire effectively so each of the red wires on one side may be conncted tpo one on the other side - an Ohm-meter will tell you. Connect meter on LOW V range between other two and see if reading varies with weight change. Report back. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As jwpat7 says - you may need to repower sensors off HX711 supply to get correct readings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;HX711 looks nice. Under $1/module in modest volume on Alibaba and under $US/0.50 / IC in hundreds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What Fig1? I know where is GND and VDD on HX711 module, and where goes the signal wires(A-,A+,B-,B+). That is clear. I dont know which colors of wires from sensors is GND VDD and Signal. I will do this. I will put back the power on the scale (3v from battery) and I will try to measure wires to determine what is what (i will put some load on the scale). I have a multimer so i will try to determine which wires are signal, and which wires are GND and VDD. I will report back. Tnx Russell. –&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See fig  of &lt;a href=&quot;http://www.aviaic.com/uploadfile/hx711_brief_en.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;HX711 Data sheet&lt;/strong&gt;&lt;/a&gt; for larger view of this image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9wHry.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-18T08:06:57.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11954" PostTypeId="2" ParentId="11950" CreationDate="2015-05-18T08:57:35.053" Score="0" Body="&lt;p&gt;reversing a boolean can be done using the &lt;code&gt;!&lt;/code&gt; operator.&#xA;So doing something like &lt;code&gt;print(!true);&lt;/code&gt; will print &lt;code&gt;false&lt;/code&gt; (or 0, I'm not sure.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you make a wrapper or class to abstract this specific/odd behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;setLedPin(pinnr,state){digitalWrite(pinnr,!state)} //The pins are inverted, LOW is ON, HIGH is off, this piece inverts it.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may even make a class for these segment displays and pass to your constructor if it's an inverted or &quot;normal&quot; one.&#xA;Or even make two classes that implement the same interface, but for such a small difference, that shouldn't be necessary.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2017-11-06T21:51:28.200" LastActivityDate="2017-11-06T21:51:28.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11955" PostTypeId="2" ParentId="11950" CreationDate="2015-05-18T09:20:33.873" Score="1" Body="&lt;p&gt;With the given schematic both your logic for segments and digits should be active high, so it looks like you made a mistake. Especially because you say it doesn't work anymore when you connect ground. Check that you have the right transistor and that it's connected correctly: Emitter should go to ground, collector to the display's common cathode. (Check that your displays are common &lt;em&gt;cathode&lt;/em&gt;!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not a good idea to define some version of high as low, that's only confusing. Instead name the signals:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define DISPLAY_SEGMENT_ON HIGH&#xA;#define DISPLAY_DIGIT_ON HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The image can be found at several places on the Internet, so I guess you didn't draw it. This is a &lt;strong&gt;common cathode&lt;/strong&gt; display, and the transistors are &lt;strong&gt;NPN&lt;/strong&gt; types. If your displays are &lt;strong&gt;common anode&lt;/strong&gt; then the whole thing flips upside-down: The Ground rail becomes Vcc, and the NPN transistors should be &lt;strong&gt;PNP&lt;/strong&gt; types. Then you will indeed have inverted logic, and you should define:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define DISPLAY_SEGMENT_ON LOW&#xA;#define DISPLAY_DIGIT_ON LOW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="26916" LastEditDate="2017-11-06T13:17:13.500" LastActivityDate="2017-11-06T13:17:13.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11956" PostTypeId="2" ParentId="11907" CreationDate="2015-05-18T09:25:34.670" Score="2" Body="&lt;p&gt;Averaging is a very good technique for improving noisy data, provided&#xA;you have a “nice” noise. “Nice” meaning that you never get “atypical”&#xA;data points, i.e. the error of any given data point is of the order of&#xA;the “typical” error amplitude. If you have for instance&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Additive_white_Gaussian_noise&quot; rel=&quot;nofollow&quot;&gt;additive white Gaussian&#xA;noise&lt;/a&gt;, then&#xA;it can be shown that averaging is in some way the “best” way to clean&#xA;your data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you have big sporadic errors, then &lt;strong&gt;averaging is not a good&#xA;solution&lt;/strong&gt;. This is because you will have to average &lt;em&gt;a lot&lt;/em&gt; of samples&#xA;in order to smoothen out a single big error... and the more samples you&#xA;average, the more chances you have to get &lt;em&gt;another&lt;/em&gt; huge error that will&#xA;ruin your average. Of course, averaging will somewhat improve things,&#xA;and it is better than no smoothing at all, but there are better options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solutions to this problem lye in the realm of &lt;a href=&quot;http://en.wikipedia.org/wiki/Robust_statistics&quot; rel=&quot;nofollow&quot;&gt;robust&#xA;statistics&lt;/a&gt;. It may look&#xA;like hairy math, but there is actually a very simple smoothing filter&#xA;that is far more robust than the average: it's called the&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Median&quot; rel=&quot;nofollow&quot;&gt;median&lt;/a&gt;. The idea is quite simple:&#xA;you sort your list of samples from smallest to largest, then you pick&#xA;the one sample that ends right in the middle of the sorted list. Unlike&#xA;the average, this filter is completely insensitive to samples carrying&#xA;&lt;em&gt;huge&lt;/em&gt; errors, as long as the &lt;em&gt;majority&lt;/em&gt; of samples are reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an implementation of a simple moving-median filter based on the&#xA;standard libc’s &lt;code&gt;qsort()&lt;/code&gt;. It assumes samples have &lt;code&gt;int&lt;/code&gt; type, but you&#xA;can change it to whatever numeric type you want. You can also change the&#xA;filter length: longer lengths provide more robustness against series of&#xA;consecutive bad samples, at the cost of more filter delay, more memory,&#xA;and more processing time.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Comparison function for qsort(): return an integer &quot;less than, equal&#xA; * to, or greater than zero if the first argument is considered to be&#xA; * respectively less than, equal to, or greater than the second.&quot;&#xA; */&#xA;int compare(const void *pa, const void *pb) {&#xA;    int a = *(int *)pa;&#xA;    int b = *(int *)pb;&#xA;    return a&amp;lt;b ? -1 : a&amp;gt;b ? +1 : 0;&#xA;}&#xA;&#xA;#define FILTER_LENGTH 11  // length of the median filter, should be odd&#xA;&#xA;/*&#xA; * Input: raw sample.&#xA; * Ouput: filtered sample.&#xA; */&#xA;int median_filter(int data) {&#xA;    static int input_buffer[FILTER_LENGTH];&#xA;    static int input_index;&#xA;    int sorted_buffer[FILTER_LENGTH];&#xA;&#xA;    // Store the current data point.&#xA;    input_buffer[input_index] = data;&#xA;    if (++input_index &amp;gt;= FILTER_LENGTH) input_index = 0;&#xA;&#xA;    // Sort a copy of the input buffer.&#xA;    for (int i = 0; i &amp;lt; FILTER_LENGTH; i++)&#xA;        sorted_buffer[i] = input_buffer[i];&#xA;    qsort(sorted_buffer, FILTER_LENGTH, sizeof *sorted_buffer, compare);&#xA;&#xA;    // Return median.&#xA;    return sorted_buffer[FILTER_LENGTH/2];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I did not explicitly initialize the filter memory, this will output&#xA;zeros the few first times it is called. I encourage you to try this&#xA;filter and compare against an exponential moving average, and only then&#xA;decide which works best for you.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-18T09:25:34.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11957" PostTypeId="1" CreationDate="2015-05-18T10:09:10.283" Score="2" ViewCount="264" Body="&lt;p&gt;I'd like to use an Arduino Nano BLE to activate or deactivate an electric circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I intend to use a relay to do so, but activating a relay seems to require a current with more intensity than what we can get out of a digital output (about 20 mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to get more intensity out of a BLE nano ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there others components that could behave the same way as a relay but could react from a digital output ?&lt;/p&gt;&#xA;" OwnerDisplayName="user9891" LastActivityDate="2015-05-18T10:09:10.283" Title="Using Arduino BLE Nano to switch an electric circuit on and off" Tags="|relay|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11958" PostTypeId="2" ParentId="11907" CreationDate="2015-05-18T10:31:47.383" Score="2" Body="&lt;p&gt;The Sharp GP... infra red proximity sensors can produce noisy output sometimes.  This is partly caused by the fact that they work by repeating a brief, powerful IR pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So - the very first tweak I would suggest when using any of these sensors is to try a cheap 10 micro Farad electrolytic capacitor on the 5V power connections, reasonably close to the sensor itself.  This is mentioned on some of their datasheets, but gets forgotten...&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2015-05-18T10:31:47.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11959" PostTypeId="1" AcceptedAnswerId="12014" CreationDate="2015-05-18T10:48:45.330" Score="0" ViewCount="357" Body="&lt;p&gt;I worked on the starterkit project #9 motorized pinwheel, and the motor worked just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then tried to add a potentiometer, and now the motor won't rotate at all any more (neither in the current nor in the project's baseline configuration). I also tried connecting the motor to the 9V battery directly, to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did check the battery by briefly connecting a LED right away. The motor apparently also still generates current if I turn it manually (checked with a directly connected LED either).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else can I do to check what's wrong with the motor? Is it possible that I somehow accidently killed it with my attempts with the potentiometer?&lt;/p&gt;&#xA;" OwnerUserId="10137" LastActivityDate="2015-05-20T03:05:57.653" Title="Troubleshooting DC motor" Tags="|motor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11960" PostTypeId="1" AcceptedAnswerId="11966" CreationDate="2015-05-18T11:01:31.317" Score="0" ViewCount="9153" Body="&lt;p&gt;I'd like to print a bitmap on my TFT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I setup my screen with this library: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=292777.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=292777.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is like the Adafruit_GFX library (only a little bit changed). Everything works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the tool Img2Code I converted my image into a bitmap.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,&#xA;                               const uint8_t *bitmap, int16_t w, int16_t h,uint16_t color)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/5fnlO.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to include this code and print the bitmap on the tft?&lt;/p&gt;&#xA;" OwnerUserId="8644" LastEditorUserId="8644" LastEditDate="2015-05-18T11:16:02.037" LastActivityDate="2015-05-18T14:27:38.113" Title="How to draw a bitmap on a tft display?" Tags="|arduino-mega|display|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11962" PostTypeId="1" AcceptedAnswerId="11999" CreationDate="2015-05-18T12:32:46.643" Score="2" ViewCount="10267" Body="&lt;p&gt;I'm using a home made &quot;bare bones&quot; Arduino, made with the ATmega328, and I need to read angle data from a geared DC drill motor, turning at speeds between 0 and 450 RPM. This is so I can use it as feedback for an angle control system implemented on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've not yet bought the encoder. I'm waiting until I find a suitable one which works easily with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already written the control algorithm. I'm using state variable feedback, and the algorithm depends on a &lt;code&gt;getAngle()&lt;/code&gt; function that I have not written yet. This function is inside an if statement that executes every 0.2 seconds. It needs to return the angle of the DC motor in degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I implement this &lt;code&gt;getAngle()&lt;/code&gt; function using a rotary encoder? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is an example of a rotary encoder that is suitable for this application?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Will it be better to use the interrupt pins of the Atmega328, or use some other method? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have seen &lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;a few library's on Arduino Playground&lt;/a&gt; that claim to make reading angle data easier, but how do I use them? I need something that is fast (it, and the control algorithm operations, both needs to finish before the 0.2 seconds sample time), and more importantly it needs to be easy to implement. I'm coming up to the project deadline so I don't want to have to spend a whole day figuring out how to implement this &lt;code&gt;getAngle()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="4499" LastActivityDate="2015-05-19T20:28:46.523" Title="How to read data from a rotary encoder with ATmega328" Tags="|motor|interrupt|rotary-encoder|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11963" PostTypeId="2" ParentId="11962" CreationDate="2015-05-18T13:21:23.250" Score="1" Body="&lt;p&gt;Your encoder choice will probably be driven by the mechanical requirements and the precision you need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Runs occasionally, and briefly to 450 RPM or runs continuously, and often at the higher speeds?&lt;/li&gt;&#xA;&lt;li&gt;Do you need position to e.g., within 3 degrees (7 bits)? Or 1/3 degrees (10 bits)? Or are you willing to count pulses from an index mark (this gets more complicated if the direction of rotation can change).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An n-bit encoder can probably be read whenever you need a position sample, so interrupts would probably not be necessary. With an index wheel (a pulse every x degrees, plus a separate pulse at 0 degrees, e.g.)&#xA;you would probably benefit from tracking the position at interrupt level and letting the main loop simply access the last known position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;getAngle()&lt;/code&gt; implementation depends totally on the choices you make above. If you use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Gray_code&quot; rel=&quot;nofollow&quot;&gt;Gray-coded&lt;/a&gt; encoder wheel, you'd need to convert the code to a binary fraction and multiply by 360 to get degrees. If you use an index wheel, &lt;code&gt;getAngle()&lt;/code&gt; just reads the current pulse-count maintained by your interrupt routine and converts it to degrees. But you need an interrupt routine to count angle-pulses and reset the count on the index pulse (not especially hard to do).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fixed-point arithmetic is pretty fast. Floating point takes longer. Depending on what else, besides position-keeping, your code needs to do, and how math-heavy it is, whether you can afford floating point. The floating point library will take more code space, too, but my guess is you'll be constrained by time more than by code-space.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-18T13:21:23.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11964" PostTypeId="2" ParentId="11950" CreationDate="2015-05-18T13:35:15.467" Score="0" Body="&lt;p&gt;If your display is a common anode type, the following will happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose you put a HIGH on D12, and LOW on D2 then current will flow from D12 through the base-collector diode of Q1, through the LED and out D2 to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you now connect Gnd to ground wihout changing anything else, the current from D12 will flow through the base-emitter diode of Q1 to ground and not through the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the display is probably of the wrong type for your design. &lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-05-18T13:35:15.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11965" PostTypeId="2" ParentId="11951" CreationDate="2015-05-18T13:42:43.510" Score="0" Body="&lt;p&gt;Your code is correct for what you described you want it to do - raise &lt;code&gt;led3&lt;/code&gt; when either or both of &lt;code&gt;led1&lt;/code&gt; or &lt;code&gt;led2&lt;/code&gt; is high, and make it low otherwise. Some things to check:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do the push-buttons pull their respective pins HIGH? (Pulling LOW is more common).&lt;/li&gt;&#xA;&lt;li&gt;Are the pins pulled to ground with a 5K or 10K resistor, and not left floating, when the respective button is not active?&lt;/li&gt;&#xA;&lt;li&gt;Real buttons need to be de-bounced. They behave as if their contacts bounce several times before making contact (even though that isn't really what happens). If this is an experiment and you hold the button down, even briefly, you should get proper results without de-bouncing, but it's something to be aware of as you move on.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-05-18T13:49:07.380" LastActivityDate="2015-05-18T13:49:07.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11966" PostTypeId="2" ParentId="11960" CreationDate="2015-05-18T14:27:38.113" Score="2" Body="&lt;p&gt;As the function prototype you have show suggests, the data needs to be in a uint8_t array format.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,&#xA;            const uint8_t *bitmap, int16_t w, int16_t h,uint16_t color)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your array data would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t myBitmap[] = { 0xff, 0xff, 0xc0, 0x00, 0xc0, 0xff,&#xA;    0xc0, 0xc0, 0xff, 0xff, 0xde, 0xad, 0xbe, 0xef,&#xA;    .... etc ....&#xA;    0xff, 0xff, 0xff, 0xff, 0xff&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You then call the function with the needed parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tft.drawXBitmap(10, 20, myBitmap, 100, 80, 0xFFFF);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is assuming you want to place it at (top left corner) 10,20 and the bitmap is 100x80 pixels in size.  It will draw it in white (0xFFFF).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-18T14:27:38.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11967" PostTypeId="2" ParentId="682" CreationDate="2015-05-18T14:49:12.093" Score="10" Body="&lt;p&gt;I disagree with people who think you shouldn't use it or it is generally unnecessary. I believe it can be dangerous if you don't know the ins and outs of it, but it is useful. I do have cases where I don't know (and shouldn't care to know) the size of a structure or a buffer (at compile time or run time), especially when it comes to libraries I send out into the world. I agree that if you're application is only dealing with a single, known structure, you should just bake in that size at compile time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: I have a serial packet class (a library) that can take arbitrary length data payloads (can be struct, array of uint16_t, etc.). On the sending end of that class you simply tell the Packet.send() method the address of the thing you wish to send and the HardwareSerial port through which you wish to send it. However, on the receiving end I need a dynamically allocated receive buffer to hold that incoming payload, as that payload could be a different structure at any given moment, depending on the application's state, for instance. IF I'm only ever sending a single structure back and forth, I'd just make the buffer the size it needs to be at compile time. But, in the case where packets may be different lengths over time, malloc() and free() are not so bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've run tests with the following code for days, letting it loop continuously, and I've found no evidence of memory fragmentation. After freeing the dynamically allocated memory, the free amount returns to its previous value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// found at learn.adafruit.com/memories-of-an-arduino/measuring-free-memory&#xA;int freeRam () {&#xA;    extern int __heap_start, *__brkval;&#xA;    int v;&#xA;    return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval);&#xA;}&#xA;&#xA;uint8_t *_tester;&#xA;&#xA;while(1) {&#xA;    uint8_t len = random(1, 1000);&#xA;    Serial.println(&quot;-------------------------------------&quot;);&#xA;    Serial.println(&quot;len is &quot; + String(len, DEC));&#xA;    Serial.println(&quot;RAM: &quot; + String(freeRam(), DEC));&#xA;    Serial.println(&quot;_tester = &quot; + String((uint16_t)_tester, DEC));&#xA;    Serial.println(&quot;alloating _tester memory&quot;);&#xA;    _tester = (uint8_t *)malloc(len);&#xA;    Serial.println(&quot;RAM: &quot; + String(freeRam(), DEC));&#xA;    Serial.println(&quot;_tester = &quot; + String((uint16_t)_tester, DEC));&#xA;    Serial.println(&quot;Filling _tester&quot;);&#xA;    for (uint8_t i = 0; i &amp;lt; len; i++) {&#xA;        _tester[i] = 255;&#xA;    }&#xA;    Serial.println(&quot;RAM: &quot; + String(freeRam(), DEC));&#xA;    Serial.println(&quot;freeing _tester memory&quot;);&#xA;    free(_tester); _tester = NULL;&#xA;    Serial.println(&quot;RAM: &quot; + String(freeRam(), DEC));&#xA;    Serial.println(&quot;_tester = &quot; + String((uint16_t)_tester, DEC));&#xA;    delay(1000); // quick look&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't seen any sort of degradation in RAM or in my ability to allocate it dynamically using this method, so I'd say it's a viable tool. FWIW.&lt;/p&gt;&#xA;" OwnerUserId="10140" LastActivityDate="2015-05-18T14:49:12.093" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="11968" PostTypeId="1" CreationDate="2015-05-18T16:35:13.020" Score="3" ViewCount="4272" Body="&lt;p&gt;Adafruit has this wonderful product: &lt;a href=&quot;http://www.adafruit.com/products/85&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.adafruit.com/products/85&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/caRKC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are these actually called? I've looked all over the place in Mouser and DigiKey and can't find them (now, granted, it's impossible to find anything in DigiKey since they discontinued their printed catalog, but I'm digressing...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are great for putting other things that are on breakout boards on a tightly-packed breadboard and still be able to attach probes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, sometimes, the board you are trying to attach is this:&lt;img src=&quot;https://i.stack.imgur.com/stwEE.jpg&quot; alt=&quot;TaylorEdge Smartnixie board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is a dip switch blocking the 8-pin header. This is fine for its final resting place (on a board with a socket), but putting it on a breadboard is a bit of a pain. I have quite a few of those, so even though the aforementioned adafruit part is pretty cheap and I could get a bunch, I'd rather know what the real part is called so I can get the sizes I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: In case you are wondering, and you like old-style nixie tubes, that's &lt;a href=&quot;http://www.tayloredge.com/storefront/SmartNixie/DataSheets/Datasheet_SmartNixie.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.tayloredge.com/storefront/SmartNixie/DataSheets/Datasheet_SmartNixie.pdf&lt;/a&gt;.)&lt;/p&gt;&#xA;" OwnerUserId="10024" LastEditorUserId="6834" LastEditDate="2015-05-21T15:59:53.930" LastActivityDate="2015-07-20T17:36:48.757" Title="Mouser/DigiKey part number for female &quot;stacking&quot; headers?" Tags="|prototype|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11969" PostTypeId="1" CreationDate="2015-05-18T16:54:42.483" Score="4" ViewCount="801" Body="&lt;p&gt;The unsolved: when I connect power and signal lines to my Arduino - while power is on - I potentially kill it. I have fried 2 so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Situation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have build an DMX-controlled lighting fixture, which consists of the fixture and a Controller Box.&lt;/li&gt;&#xA;&lt;li&gt;The fixture houses 2 Arduino's (5V), 2 steppers, 2 drives (36V), 2 fans (24V) and some temperature sensors.&lt;/li&gt;&#xA;&lt;li&gt;The controller box houses 1 Arduino, amongst other electronics.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The controller box receives DMX and does calculations an send controls via I2C to the fixture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 8 pole connector between fixture and controller box. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 - GND&#xA;2 - 5v&#xA;3 - 24v&#xA;4 - 36v&#xA;5 - CLK (i2c)&#xA;6 - SDA (i2c)&#xA;7 - signal line (used as charge pump)&#xA;8 - reset&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All wires are shielded(but the shield is only connected AFTER the initial pins make contact)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the power on the controller box is ON and i connect the light Fixture with the 8-pole connector my arduino goes to heaven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My own idea's so far:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Voltage spike, because the connection wires is grounded after it connects the pins.&lt;/li&gt;&#xA;&lt;li&gt;Some strange flyback? via the Arduinos in the light fixture? I connected everything straight to the 5v pins, not using the regulator.&lt;/li&gt;&#xA;&lt;li&gt;no idea&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any help on a way to search for the most likely cause of the problem would be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="6547" LastEditorUserId="7368" LastEditDate="2015-05-20T12:11:40.083" LastActivityDate="2021-08-11T04:07:30.753" Title="How to protect my arduino, while hotplugging its power supply and other related electronics" Tags="|voltage-level|electricity|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11970" PostTypeId="2" ParentId="11968" CreationDate="2015-05-18T17:28:37.673" Score="2" Body="&lt;p&gt;They're actually called &quot;Wire-Wrap Headers&quot; and they pre-date the Arduino probably by at least 50 years or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They used to be used to create circuits between chips and components by wrapping wire around the pins and routing it to other connectors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JxfcL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have since been adopted as stackable headers on boards like the Arduino shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being such old technology not many people make them any more, though thanks to their popularity on things like the Arduino they are starting to appear more and more from normal electronics supply companies.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-18T17:28:37.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11971" PostTypeId="2" ParentId="11969" CreationDate="2015-05-18T18:03:09.180" Score="0" Body="&lt;p&gt;There's usually a number of scenarios that can cause hardware to go &lt;em&gt;poof&lt;/em&gt; when you plug it in to a live system.  Most of them you have managed to identify, so I won't go into detail here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suffice it to say that creating hot-pluggable devices isn't as straight forward as you would at first guess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two main critical things to consider when designing your system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Suppression&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Invest in TVS diodes to suppress ESD.  All the IO pins that connect to the outside world that will be liable to be disconnected or connected at any time should be protected by adequate suppression.  Any inputs should also ideally be tied to a default state with pullup or pulldown resistors so they aren't left floating.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connector&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The connector itself is pretty critical.  Hot-plug connectors typically have different pins of different lengths so that they connect in a specific pre-determined order.  Normally you want your ground and shield to connect first.  Then your power supplies, and finally your IO pins.  Doing it in any other order is asking for trouble - such things as back-powering through the IO pins if the supply hasn't been connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't use a proper hot-plug connector then there are ways you can simulate it internally.  You can add hardware (buffers, reed relays, FETs, whatever, depending on your signals) which normally isolate the signals from the MCU, and only when the MCU is powered up and ready does it then activate the buffers to allow the signals through.  Of course, the buffers themselves have to be able to withstand any possible back-powering etc while the plug is being inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other small trick is to ensure that all your IO lines have a series resistor in them.  This limits the maximum current that can ever go in or out of a pin (at a specific voltage of course) to a level that is safe for the hardware.  470Ω - 1KΩ are good values.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-18T18:03:09.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11972" PostTypeId="2" ParentId="11968" CreationDate="2015-05-18T18:26:20.250" Score="0" Body="&lt;p&gt;That DIP switch is also connected to the 4 address pins so you could cut the switch off, plug it into a proto board and then set the address by selectively grounding those pins.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2015-05-18T18:26:20.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11976" PostTypeId="1" AcceptedAnswerId="11979" CreationDate="2015-05-18T21:55:06.343" Score="0" ViewCount="2901" Body="&lt;p&gt;I recently came across &lt;a href=&quot;http://www.utopiamechanicus.com/article/low-memory-serial-print/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; nice &lt;code&gt;SerialPrint()&lt;/code&gt; implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void StreamPrint_progmem(Print &amp;amp;out,PGM_P format,...)&#xA;{&#xA;  // program memory version of printf - copy of format string and result share a buffer&#xA;  // so as to avoid too much memory use&#xA;  char formatString[128], *ptr;&#xA;  strncpy_P( formatString, format, sizeof(formatString) ); // copy in from program mem&#xA;  // null terminate - leave last char since we might need it in worst case for result's \0&#xA;  formatString[ sizeof(formatString)-2 ]='\0'; &#xA;  ptr=&amp;amp;formatString[ strlen(formatString)+1 ]; // our result buffer...&#xA;  va_list args;&#xA;  va_start (args,format);&#xA;  vsnprintf(ptr, sizeof(formatString)-1-strlen(formatString), formatString, args );&#xA;  va_end (args);&#xA;  formatString[ sizeof(formatString)-1 ]='\0'; &#xA;  out.print(ptr);&#xA;}&#xA;&#xA;#define Serialprint(format, ...) StreamPrint_progmem(Serial,PSTR(format),##__VA_ARGS__)&#xA;#define Streamprint(stream,format, ...) StreamPrint_progmem(stream,PSTR(format),##__VA_ARGS__)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to use it in my more complex projects to save precious RAM space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works really well when I have just one *.ino file where I'm using the SerialPrint() function.&#xA;When I try to use it in my more complext projects, which consist of a central *.ino files and several &lt;em&gt;.cpp/&lt;/em&gt;.h files (mostly one cpp/h pair per class).&#xA;The problem is if I put the code below into the *.ino file, it will not be known inside any of the *.cpp files. The compiler is not complanining, but I'm never seeing the serial output of my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to fix it?&#xA;I've tried putting this code in a central global.cpp/h file which I include everywhere, but it does not seem to work (no output on serial).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!-&lt;/p&gt;&#xA;" OwnerUserId="6635" LastActivityDate="2015-05-18T23:08:57.110" Title="How to define function/macro so it is accesible throughout various cpp files" Tags="|arduino-uno|programming|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="11977" PostTypeId="2" ParentId="11968" CreationDate="2015-05-18T21:57:57.553" Score="3" Body="&lt;p&gt;A &lt;a href=&quot;http://www.digikey.com/product-search/en/connectors-interconnects/rectangular-connectors-headers-receptacles-female-sockets/1442548?k=%20SSQ%20samtec&quot; rel=&quot;nofollow&quot;&gt;Digikey.com search for &lt;code&gt;samtec SSQ&lt;/code&gt;&lt;/a&gt; includes numerous longtail stackable headers (as well as some shorttail, or non-stackable).  However, looking at Digikey's prices suggests to me that &lt;a href=&quot;http://www.adafruit.com/products/85&quot; rel=&quot;nofollow&quot;&gt;adafruit.com's price&lt;/a&gt; is a bargain unless you are purchasing thousands of pieces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=23857.0&quot; rel=&quot;nofollow&quot;&gt;an arduino.cc thread&lt;/a&gt; on this topic.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-18T21:57:57.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11978" PostTypeId="2" ParentId="11944" CreationDate="2015-05-18T22:27:15.840" Score="0" Body="&lt;p&gt;The latest news from Arduino that I can find is in their blog archive that the &lt;a href=&quot;http://blog.arduino.cc/2014/12/12/arduino-tre-developer-edition-2nd-round-of-beta-testing/&quot; rel=&quot;nofollow&quot;&gt;second round of beta testing is out&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mentioned this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When is the Arduino TRE going to be finally on the market? The board is ready, but we don’t have a final release date yet because we are still figuring out some manufacturing matters. We’ll keep you posted!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'd imagine that the &lt;a href=&quot;http://hackaday.com/2015/02/25/arduino-v-arduino/&quot; rel=&quot;nofollow&quot;&gt;Arduino LLC vs Arduino SLR&lt;/a&gt; legal issue is also delaying the production.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, speculation is all that we know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: it's still spring until Sunday, June 21! :-)&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-05-18T22:27:15.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11979" PostTypeId="2" ParentId="11976" CreationDate="2015-05-18T23:08:57.110" Score="3" Body="&lt;p&gt;Have you thought of turning it into a small library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;libraries/StreamPrint/StreamPrint.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;StreamPrint.h&amp;gt;&#xA;&#xA;void StreamPrint_progmem(Print &amp;amp;out,PGM_P format,...)&#xA;{&#xA;  // program memory version of printf - copy of format string and result share a buffer&#xA;  // so as to avoid too much memory use&#xA;  char formatString[128], *ptr;&#xA;  strncpy_P( formatString, format, sizeof(formatString) ); // copy in from program mem&#xA;  // null terminate - leave last char since we might need it in worst case for result's \0&#xA;  formatString[ sizeof(formatString)-2 ]='\0'; &#xA;  ptr=&amp;amp;formatString[ strlen(formatString)+1 ]; // our result buffer...&#xA;  va_list args;&#xA;  va_start (args,format);&#xA;  vsnprintf(ptr, sizeof(formatString)-1-strlen(formatString), formatString, args );&#xA;  va_end (args);&#xA;  formatString[ sizeof(formatString)-1 ]='\0'; &#xA;  out.print(ptr);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;libraries/StreamPrint/StreamPrint.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;extern void StreamPrint_progmem(Print &amp;amp;out,PGM_P format,...);&#xA;&#xA;#define Serialprint(format, ...) StreamPrint_progmem(Serial,PSTR(format),##__VA_ARGS__)&#xA;#define Streamprint(stream,format, ...) StreamPrint_progmem(stream,PSTR(format),##__VA_ARGS__)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in your code, wherever you want to use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;StreamPrint.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read more about writing libraries here: &lt;a href=&quot;http://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Hacking/LibraryTutorial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-18T23:08:57.110" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11980" PostTypeId="1" CreationDate="2015-05-18T23:35:13.340" Score="0" ViewCount="298" Body="&lt;p&gt;I am working on a project for my final in a first year programming course at my high school. I would like to make an Arduino based data logging device that I can bring with my on the mountain biking trails around where I live to create a map. I have found a lot of great sources online but I do not have a small budget. I have an Arduino Uno and a breadboard. My first question is whether it is easy to interface between an Uno and my phone for data logging, or if it would just be easier to buy a microSD card shield? And I need help finding a GPS unit. I have no preference and size is not really a problem. I just need to know how to interface with the Uno. Also if you have any links to other sources I can use that would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="10159" LastActivityDate="2021-02-24T02:00:30.080" Title="Data Logging GPS with Arduino" Tags="|arduino-uno|gps|datalogging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11981" PostTypeId="1" CreationDate="2015-05-18T23:45:13.673" Score="-1" ViewCount="541" Body="&lt;p&gt;I am sending data from an Arduino Uno to an Arduino Mega via serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data is analog value. I'm getting that data and converting it to an int. There is no problem there. However, when I connect the servo to the attached pin, the serial communication on mega becomes disconnected. When I  remove the PWM pin, the serial communication is working again. Why does the servo stop serial communication?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring: Mega-- 5v and gnd pins linked to servo ( 13kg/cm ), PWM 2 pin is linked to servo's pwm input, rx2 pin is linked to uno's tx pin&lt;/p&gt;&#xA;" OwnerUserId="10160" LastEditorUserId="220" LastEditDate="2015-09-04T01:43:36.123" LastActivityDate="2017-08-24T14:21:28.380" Title="Servo - Serial communication problem" Tags="|serial|servo|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="11982" PostTypeId="2" ParentId="11980" CreationDate="2015-05-19T00:04:16.147" Score="0" Body="&lt;p&gt;first questions; is it easy? Very, do it all the time. But easy to me (30+ year programmer with some embedded experience) may not mean easy to you. Seek out a local make group or friend to help guide you if you are just starting out. I would look into a simple bluetooth adapter for the arduino, they are cheap, $5 in some places like &lt;a href=&quot;http://www.ebay.com/bhp/bluetooth-uart&quot; rel=&quot;nofollow&quot;&gt;eBay&lt;/a&gt;. Then find or write a phone app that log bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;second question;&#xA;Pick a GPS unit from SparkFun or somewhere like that.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is a serial unit it may need need some sort of FTDI adapter, which can sometimes be just a cable (and it might not need it, depends).  You really need to match the GPS with the appropriate way to hook it up and there are so many options I don't think someone will be able to cover them all. Depending on which arduino, you will use softSerial, since the hardware serial pins are probably being used by the bluetooth adapter. BTW, did this exact thing for a robot project not too long ago, work ok. I used XBees instead of bluetooth. If I did it again I would try Bluetooth as the XBee reliability wasnt very good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another type of connection is called I2C, and that would attach directly to Arduino UNO SDA/SCL (pins A4/A5 I think).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases there are 3V and 5V devices and again you need to match things up on your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to spoil your fun, you realize if you are carrying a phone and it is on, you are already being tracked and they are ways to view the history on the web?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some cases it is easy to find (used to be called google tracks I think). Others are a little harder and I wont give out details, but I used to follow my ATV excursions on fire roads in the mountain all the time after I got back home.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://junkee.com/google-maps-has-been-tracking-your-every-move-and-theres-a-website-to-prove-it/39639&quot; rel=&quot;nofollow&quot;&gt;http://junkee.com/google-maps-has-been-tracking-your-every-move-and-theres-a-website-to-prove-it/39639&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:  gps (&lt;a href=&quot;https://www.sparkfun.com/products/11571&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11571&lt;/a&gt;) -&gt; softSerial on UNO -&gt; tx/rx -&gt; bluetooth (&lt;a href=&quot;http://www.ebay.com/itm/New-Slave-UART-Wireless-Bluetooth-Transeiver-RF-Module-Serial-for-Arduino-AVR-/121643226124&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/New-Slave-UART-Wireless-Bluetooth-Transeiver-RF-Module-Serial-for-Arduino-AVR-/121643226124&lt;/a&gt;) -&gt; phone logging app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I picked that bluetooth because it claims it can do 3.3v-6v - the others I looked at said 3.3V but I bet they are all the same.  Technically, you probably do not even need the arduino in the middle, but said you wanted to learn.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-20T00:06:15.680" LastActivityDate="2015-05-20T00:06:15.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11983" PostTypeId="1" CreationDate="2015-05-19T08:10:53.107" Score="2" ViewCount="97" Body="&lt;p&gt;I am using arduino leonardo for moving mouse pointer with head tracking using MPU6050. It works fine in general. But as soon as I connect an external lcd screen to my laptop via hdmi cable, it stops transmitting. (that is the TX led goes off altogether and the mouse stops moving) I am not able to figure out what the issue is here Will using a teensy 3.0 instead of leonardo solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2021-05-25T11:04:25.500" Title="arduino leonardo stops transmitting once hdmi cable is connected to a screen" Tags="|lcd|arduino-leonardo|mpu6050|gyroscope|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11984" PostTypeId="1" AcceptedAnswerId="11986" CreationDate="2015-05-19T12:27:54.020" Score="0" ViewCount="728" Body="&lt;p&gt;I want keep my RTC1307 always updated with my server, so I created this code to first search the time on the server then passes to getServerTime() function to divide it and set in the RTC. I use the rtc.adjust() to adjust my watch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: My watch is getting wrong, this is set &lt;strong&gt;2165/165/165 165:165:85&lt;/strong&gt;. I think the problem is in defining the time in rtc.adjust(), I'm going as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//tempDate -&amp;gt; May 19 2015&#xA;//tempHour -&amp;gt; 09:25:14&#xA;rtc.adjust(DateTime(tempDate, tempHour));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know the cause of this error?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;RTC_DS1307 rtc;&#xA;&#xA;byte server[] = { 192, 168, 0, 8 };&#xA;byte ip[] = { 192, 168, 0, 237 };&#xA;byte mac[] = { 0xDE, 0xAD, 0xAD, 0xEF, 0xFE, 0xED };&#xA;&#xA;void setup() {&#xA;    Ethernet.begin(mac, ip);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    getServerTime(getSiteData());&#xA;    DateTime now = rtc.now();&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;    Serial.println();&#xA;    delay(5000);&#xA;&#xA;}&#xA;&#xA;char * getSiteData()&#xA;{&#xA;    EthernetClient http;&#xA;    unsigned char startRead = 0, i = 0;&#xA;    char inString[50];&#xA;&#xA;    if (http.connect(server, 80)) {&#xA;        http.println(&quot;GET /util/date.php HTTP/1.1&quot;);&#xA;        http.println(&quot;Host: &quot;);&#xA;        http.println(&quot;Connection: close&quot;);&#xA;        http.println();&#xA;&#xA;        while (http.connected()) {&#xA;            while (http.available()) {&#xA;                char c = http.read();&#xA;&#xA;                if (c == '&amp;lt;' )&#xA;                    startRead = 1;&#xA;&#xA;                else if (startRead) {&#xA;&#xA;                    if (c != '&amp;gt;') {&#xA;                        inString[i] = c;&#xA;                        i++;&#xA;                        inString[i] = '\0';&#xA;                    } else {&#xA;                        startRead = 0;&#xA;                        http.stop();&#xA;                        http.flush();&#xA;                        return inString;&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;        Serial.println(inString);&#xA;        http.stop();&#xA;        http.flush();&#xA;    }&#xA;    else&#xA;        Serial.println(&quot;Tentativa de conexão falhou. Sem internet ou servidor inacessivel&quot;);&#xA;}&#xA;&#xA;//May 19 2015-09:17:24&#xA;void getServerTime(char* siteData)&#xA;{&#xA;    char *tempDate, //May 19 2015&#xA;        *tempHour; //09:17:24&#xA;&#xA;    tempDate = strtok(siteData, &quot;-&quot;);&#xA;    tempHour =  strtok(NULL, &quot;-&quot;);&#xA;&#xA;    rtc.adjust(DateTime(tempDate, tempHour));&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-05-19T13:34:42.670" Title="Set dynamically hour - DS1307" Tags="|arduino-uno|ethernet|rtc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="11985" PostTypeId="2" ParentId="11962" CreationDate="2015-05-19T12:36:12.713" Score="1" Body="&lt;p&gt;There is no such thing as an encoder that &quot;works well with Arduino&quot; - encoders are encoders, and there are several basic types. As @JRobert said, you need to make an appropriate choice, and an encoder that will &lt;em&gt;mechanically&lt;/em&gt; couple well with your drill motor is probably your primary criteria, and of course an encoder that can spin unrestricted (some are only for an angular range like 180 or 270 degrees); my guess is you'll want to put the encoder on the ungeared motor, rather than the geared output of whatever it is you're driving, to get good feedback from a cheap (i.e. relatively small number of 'pulses per rev') encoder.  Search on DigiKey, Mouser, online hobby stores, etc.  Then just deal with whatever type of encoder it is, hack its electrical interface into the Arduino:&#xA;&lt;a href=&quot;http://www.digikey.com.au/product-search/en?pv69=848&amp;amp;FV=fff4001e%2Cfff80033&amp;amp;k=encoder&amp;amp;mnonly=0&amp;amp;newproducts=0&amp;amp;ColumnSort=0&amp;amp;page=1&amp;amp;stock=1&amp;amp;quantity=0&amp;amp;ptm=0&amp;amp;fid=0&amp;amp;pageSize=25&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com.au/product-search/en?pv69=848&amp;amp;FV=fff4001e%2Cfff80033&amp;amp;k=encoder&amp;amp;mnonly=0&amp;amp;newproducts=0&amp;amp;ColumnSort=0&amp;amp;page=1&amp;amp;stock=1&amp;amp;quantity=0&amp;amp;ptm=0&amp;amp;fid=0&amp;amp;pageSize=25&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This (2-signal quadrature) encoder library for Arduino is superb, by Paul Stoffregen @ pjrc.com:&#xA;&lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_Encoder.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_libs_Encoder.html&lt;/a&gt;&#xA;For best results you'll want the 2 'quadrature encoder' outputs to go into 2 interrupt inputs on the Arduino, and there are only 2 available.  There is an option to run this library on only 1 IRQ-capable input (the other can go into any input), or even no IRQ-capable pins, but performance will suffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sampling at only 5/second isn't much - don't be afraid to increase that substantially - 10 to 50 / second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also might want a PID control algorithm, depending on what your actual aims are.  the &quot;PIDLibrary&quot; by Breatt Beauregard on the Arduino Playground website is excellent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coding your 'getAngle()' function shouldn't be hard - for a rotary quadrature encoder, X pulses from the encoder corresponds to 1 revolution.  The 'encoder library' you end up using may provider more than 1 pulse output per actual pulse output from the encoder.  Do that math. Simple.&lt;/p&gt;&#xA;" OwnerUserId="7937" LastActivityDate="2015-05-19T12:36:12.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11986" PostTypeId="2" ParentId="11984" CreationDate="2015-05-19T13:34:42.670" Score="0" Body="&lt;p&gt;The numbers you are reporting are very familiar to me.  They are telling me that it is not possible to obtain the time from the RTC chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are getting the time from your server, and as long as the string is actually what you think it is, then the values should be fine.  This snippet works perfecty:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RTClib.h&amp;gt;&#xA;&#xA;char siteData[] = &quot;May 19 2015-09:17:24&quot;;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;&#xA;    char *tempDate = strtok(siteData, &quot;-&quot;);&#xA;    char *tempHour =  strtok(NULL, &quot;-&quot;);&#xA;    DateTime now(tempDate, tempHour);&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;    Serial.println();   &#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So it must be in the passing of the data through the RTC chip that is failing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check that the chip is actually wired up properly, is running, and is responding normally before you try adding in the code to set the time from the server.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-19T13:34:42.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11987" PostTypeId="1" CreationDate="2015-05-19T13:53:09.893" Score="0" ViewCount="98" Body="&lt;p&gt;We have an arduino pro mini, we are trying to trying to upload sketch the controller but we are prohibited, as the arduino attempt to upload the sketch, it display an error of: not in sync.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are pretty new in this are, so any help would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our setup is: -Breadboard -Connection to adapter: USB Serial. -Arduino Pro Mini as a controller&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Through the Arduino Programming Client.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The processor and the port are setup op properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The strange thing is, it has worked sometimes these past days..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mieer&lt;/p&gt;&#xA;" OwnerUserId="10171" LastActivityDate="2015-05-20T02:59:44.643" Title="Arduino stk500_getsync(): not in sync" Tags="|serial|arduino-pro-mini|accelerometer|" AnswerCount="1" CommentCount="1" ClosedDate="2015-05-21T23:18:50.553" ContentLicense="CC BY-SA 3.0" />
  <row Id="11988" PostTypeId="2" ParentId="11968" CreationDate="2015-05-19T17:38:10.700" Score="1" Body="&lt;p&gt;If you are already ordering from Digi-Key, they do carry the &lt;a href=&quot;http://www.digikey.com/product-detail/en/85/1528-1074-ND/5154649&quot; rel=&quot;nofollow&quot;&gt;same set of stackable headers&lt;/a&gt; from Adafruit.  It's just a bit hidden in an accessories family.  Otherwise it looks like Samtec is the only company Digikey carries that makes this style of connector.  Some dual-row long tail headers can be found using the term &lt;a href=&quot;http://www.digikey.com/product-search/en?keywords=STACKTHROUGH%20&amp;amp;stock=1&quot; rel=&quot;nofollow&quot;&gt;stackthrough&lt;/a&gt;, but this is mostly used in conjunction with PC104 connectors. &lt;/p&gt;&#xA;" OwnerUserId="10175" LastActivityDate="2015-05-19T17:38:10.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11989" PostTypeId="1" AcceptedAnswerId="12012" CreationDate="2015-05-19T18:07:59.457" Score="0" ViewCount="637" Body="&lt;p&gt;I seem to be getting the right response on single LED but with multiple LEDS or a relay connected LED strip the voltage outputs seem to be insuffiecient. &#xA;What kind of analogWrite values does an LED respond to? &lt;/p&gt;&#xA;" OwnerUserId="10118" LastActivityDate="2019-01-01T15:03:57.450" Title="Could an `analogWrite` command and its variable output values be used to power multiple leds with same intensity?" Tags="|led|voltage-level|analogwrite|" AnswerCount="1" CommentCount="3" ClosedDate="2015-05-27T16:17:11.227" ContentLicense="CC BY-SA 3.0" />
  <row Id="11990" PostTypeId="1" CreationDate="2015-05-19T18:15:36.860" Score="0" ViewCount="2739" Body="&lt;p&gt;The circuit contains a relay interfacing with 12v power supply and LED strip. Can the brightness for this strip of LEDs be controlled using the &lt;code&gt;analogWrite&lt;/code&gt; command? &#xA;This works perfectly for a single LED, but when i replace the LED with a relayed LED strip with its own adapter, it doesnt produce any perceivable output&lt;/p&gt;&#xA;" OwnerUserId="10118" LastActivityDate="2015-11-16T18:37:43.257" Title="It is possible to control brightness of an LED strip (connected using a relay and having a seperate power supply ) using output from an arduino?" Tags="|arduino-uno|sensors|analogwrite|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11991" PostTypeId="2" ParentId="11980" CreationDate="2015-05-19T18:32:22.730" Score="1" Body="&lt;p&gt;I've been looking at the same problem, and there is a lot of new stuff now that may still count as a DIY project, but cut out a lot of the leg-work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On kickstarter there are a lot of new boards that can make it easy:&#xA;Here is a ready to go GPS tracking band:&#xA;&lt;a href=&quot;https://www.kickstarter.com/projects/blipperbands/blipper-bands-safety-wherever-you-go?ref=nav_search&quot; rel=&quot;nofollow&quot;&gt;https://www.kickstarter.com/projects/blipperbands/blipper-bands-safety-wherever-you-go?ref=nav_search&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spark-IO has a board that gives you 20,000 messages per month, so you could use it instead of a cellphone to send out the data. &#xA;&lt;a href=&quot;https://store.particle.io/?product=particle-electron&quot; rel=&quot;nofollow&quot;&gt;https://store.particle.io/?product=particle-electron&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;U-Blox makes gps higher-end consumer GPS units that are used in autonomous drones.&#xA;There are also a lot of instructables that show how to do the GPS datalogging with while building a drone. These would be small enough and light enough to use while cycling. &lt;/p&gt;&#xA;" OwnerUserId="10176" LastActivityDate="2015-05-19T18:32:22.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11992" PostTypeId="1" CreationDate="2015-05-19T06:45:21.857" Score="0" ViewCount="742" Body="&lt;p&gt;I'm trying to simulate a certain µController to characterize and measure a certain chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to write my data on the negative edge of the master clock and read the data coming from the slave in the positive edge of the master clock. Is there any way I can have this kind of freedom in my code? Or do I have to do it manually without using the predefined SPI interface?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I would like to have my master clock running continuously without going idle&amp;hellip; is there a way to do that too?&lt;/p&gt;&#xA;" OwnerDisplayName="Sherif Badawy" LastEditorUserId="7090" LastEditDate="2015-09-17T20:40:33.793" LastActivityDate="2015-12-17T00:24:36.267" Title="Reading and Writing on different clock edges with Arduino SPI interface" Tags="|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11993" PostTypeId="1" AcceptedAnswerId="12011" CreationDate="2015-05-19T19:21:08.453" Score="-2" ViewCount="637" Body="&lt;p&gt;i do have sketch from various people out there who have build nice code to do what i need done BUT not for my application and well they grant us permission to use and or modify their code so this is what i attempt to do with your help.&lt;/p&gt;&#xA;" OwnerUserId="9881" LastEditorUserId="9881" LastEditDate="2015-09-03T07:30:53.403" LastActivityDate="2015-09-03T07:30:53.403" Title="how to multi merge code" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ClosedDate="2015-05-23T20:15:16.187" ContentLicense="CC BY-SA 3.0" />
  <row Id="11994" PostTypeId="1" AcceptedAnswerId="11995" CreationDate="2015-05-19T19:38:53.840" Score="1" ViewCount="214" Body="&lt;p&gt;My problem seems very simple but has been impossible to find a straight forward answer searching online. I need my Arduino to output different DC voltages from six ports (probably PWM ports), like 2 V from port 3, 2.1 V from port 5 and so on. And then be able to quickly change to like 4 V from port 3, and 4.1 V from port 5 and so on. But these DC signals need to be near perfect for the highly sensitive sensor I am working with. Everywhere I've searched says to use the PWM outputs and then an RC filter but the ripple from this process is concerning, can I get the the ripple to be under a few mV amplitude? Is there more smoothing I can do beyond a simple RC lowpass filter? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;TLDR: I basically need a DC voltage generator that can select between 1 and 5 volts at 0.1 V intervals, and I need to be able to do it with output from the Arduino and some external hardware that will provide a near perfect DC signal to a sensor.&lt;/p&gt;&#xA;" OwnerUserId="10177" LastEditorUserId="26916" LastEditDate="2017-11-04T07:14:18.270" LastActivityDate="2017-11-04T07:14:18.270" Title="Supplying near perfect DC signals from Arduino UNO" Tags="|arduino-uno|sensors|pwm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="11995" PostTypeId="2" ParentId="11994" CreationDate="2015-05-19T19:45:26.577" Score="0" Body="&lt;p&gt;Would 0-4.095V in 1mV (or 0.5mV 0-2.047V) steps do for you?  Then why not use some &lt;a href=&quot;http://www.microchip.com/wwwproducts/Devices.aspx?product=MCP4822&quot; rel=&quot;nofollow&quot;&gt;MCP4822&lt;/a&gt; SPI SAC chips?  You get 2 channels on each 8-pin chip (DIP chips are available, yes), and if you need a different voltage range you could always amplify it with a simple op-amp buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So 6 ports would be 3 chips, which would entail using SCK, MOSI and three CS pins, so 5 pins in all.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-19T21:09:26.900" LastActivityDate="2015-05-19T21:09:26.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11996" PostTypeId="2" ParentId="11865" CreationDate="2015-05-19T19:56:39.160" Score="1" Body="&lt;p&gt;Because of the limited information given any answers given will be by nature limited. However, I can suggest several troubleshooting tips.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Tips&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Verify that username and password used are exactly right(punctuation, spaces, etc.). Where you put&lt;code&gt;comcast&lt;/code&gt; you should put the name of the network not the name of the provider. I am not sure if you have done this or not.&lt;/li&gt;&#xA;&lt;li&gt;Make sure network is in fact WPA2.&lt;/li&gt;&#xA;&lt;li&gt;In order to debug the issue make sure if you are getting nothing through serial to set it to the baud rate of &lt;code&gt;115200&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you are using the breakout board make sure you correctly wired it and check any solder points:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7kL9c.png&quot; alt=&quot;wiring&quot;&gt;&lt;/li&gt;&#xA;&lt;li&gt;Make sure you have the correct libraries installed.  Also, try sample code from the examples. Libraries can be found &lt;a href=&quot;https://github.com/sparkfun/SFE_CC3000_Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Many of these seem obvious but can through someone off. So try these and let me know the results. A lot of information about setup can be found &lt;a href=&quot;https://learn.sparkfun.com/tutorials/cc3000-hookup-guide&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Try removing the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( wifi.disconnect() ) {&#xA;    Serial.println(&quot;Disconnected&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Error: Could not disconnect from network&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;block. It appears that you are disconnecting before going into the main loop. This would obviously make it impossible to send an email. The reason pining would work sometimes would be that wifi.disconnect() is called sometimes but not all the time. To narrow the issue try an example code from the library.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastEditorUserId="8046" LastEditDate="2015-05-20T14:07:51.330" LastActivityDate="2015-05-20T14:07:51.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="11997" PostTypeId="2" ParentId="11962" CreationDate="2015-05-19T20:00:59.300" Score="1" Body="&lt;p&gt;You are mixing two related ideas together.  Keeping track of encoders is best done with at least one interrupt in my experience. Whether or not you should use 2 or can get away with none depends on the speed of the shaft.  In my experience, RPMs generally encountered at the hobby level can be handled by 1.  So your interrupt code is interrupted by phase A rising or falling (Pin Change Interrupt).  At that point it read phase B, depending on the combination of A and B you are either going forwards (interrupt count+) or backwards (interrupt count-).  You know by specifications how many pulses you will have in a 360 degree rotation, and by modulo math, (e.g. x % 360) you will know how many degrees you are currently at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The concept of sampling rate has to do with how often you read the current interrupt values, but they themselves will always be accurate and realtime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keywords to google volatile.  Also use signed long integers, not unsigned (don't ask how I know :| )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure why the other answer suggested a PID, I didn't see anything in your question that would need it. For holding an angle you are more likely to use acceleration and deceleration, not PID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search &lt;a href=&quot;https://www.google.com/search?q=optical%20quadrature%20encoder%20diy&amp;amp;tbm=isch&quot; rel=&quot;nofollow noreferrer&quot;&gt;google&lt;/a&gt;, you might find a way to build your own encoders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/e7PUl.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-19T20:00:59.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11998" PostTypeId="1" AcceptedAnswerId="12000" CreationDate="2015-05-19T20:10:47.280" Score="4" ViewCount="13262" Body="&lt;p&gt;How can I control an AC ceiling fan speed using Arduino Uno R3? I cannot understand the key behind controlling AC voltage using Arduino (though I know how to on/off ac appliances using arduino and relays). &lt;/p&gt;&#xA;" OwnerUserId="10114" LastActivityDate="2016-03-02T13:53:52.210" Title="AC ceiling fan speed control using arduino Uno R3" Tags="|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="11999" PostTypeId="2" ParentId="11962" CreationDate="2015-05-19T20:28:46.523" Score="4" Body="&lt;p&gt;You will have to use interrupts or otherwise the encoder might be rotating but your Arduino is doing something else than reading the encoder. By using interrupts, the encoder counter is always updated when the encoder moves. This also means that the interrupt function has to be very short so that it only takes a few cycles to complete and thus leaves the majority of the Arduinos computing time for your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a code that I've used in many applications from CNC handwheels to servos and for reading extremely accurate angle sensors. It is dead simple, uses two interrupts to read the quadrature signal (A &amp;amp; B channel) and also makes use of Arduinos built in pull-up resistors to keep the channels held high for reliable readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that your encoder is an open-collector output and works with 5V, you only need to connect 5V and GND to it and then the A channel to the first interrupt pin #2 and channel B to #3. That's it for the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code goes at the start of your sketch, right before setup() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const signed byte encoderDirections[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};&#xA;volatile long encCount = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It defines a constant array that is used for finding the direction that the encoder has turned based on the previous value and the current value. It is defined as constant as it is never changed. Also a global variable calle encCount is defined as a long type variable so that the encoder can count in both directions. It is absolutelu imperative to declare it as volatile so that the compiler and the microprocessor never try to do any &quot;shortcuts&quot; when you use this variable, but instead always loads it from its respective memory address. This is done so because the interrupt can fire at any time and change the variables value without any other function knowing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, in your setup() function you will want to include these lines to make the Arduino pins as inputs with the internal pull-up resistors connected. The latter two lines attach the interrupts 0 &amp;amp; 1 (hardware pins pins 2 &amp;amp; 3) so that whenever the pin state changes (low to high or vice versa), it halts the microprocessors operation and jumps to the encoder_interrupt function immediately.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(2, INPUT_PULLUP);&#xA;pinMode(3, INPUT_PULLUP);&#xA;attachInterrupt(0, encoder_interrupt, CHANGE);&#xA;attachInterrupt(1, encoder_interrupt, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Last you will need the actual interrupt function that reads the encoder and updates the counter value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void encoder_interrupt() {&#xA;  static unsigned int oldEncoderState = 0;&#xA;  oldEncoderState &amp;lt;&amp;lt;= 2;&#xA;  oldEncoderState |= ((PIND &amp;gt;&amp;gt; 2) &amp;amp; 0x03);&#xA;  encCount += encoderDirections[(oldEncoderState &amp;amp; 0x0F)];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First this defines a variable that holds the previous encoder value that was read from the pins 2 &amp;amp; 3. This is declared as static, so the value is stored in memory even when this function exits so that it can be used the next time the interrupt routine is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second line moves the previous interrupt channel values two bits to the left (multiply by 4) to make room for the new values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third line is an interesting one. It reads the PIND, meaning all the pins at D register, which holds many Arduino pin states, including the pins 2 &amp;amp; 3 that we are interested in. Next it shifts this value 2 bits to the right (divide by 4) to &quot;drop&quot; the pin 2 &amp;amp; 3 states to the lowest bits of this byte. Then it AND's this byte with 0x03 to zero everything else but the lowest two bits that now contain the interrupt channel states. Lastly these two bytes are OR'd with the previous encoder state values to obtain a 4 bit number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the forth line this 4 bit number is AND'd with a 0x0F to make sure the highest 4 bits are zero to make sure this number is truly a 4 bit number that stays between 0..15, as it is used as an index for the constant array we defined at the start of the program to get the encoders direction of rotation and this is then added to the counter variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now you have an accurate and extremely fast way of reading a two channel encoder to keep track of its position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to calculate an angle from the encoders current position, you could do a function like this, but you have to know the line count of your encoder and multiply it by 4 so you know the encoder pulse count per revolution. For example, a 100 line rotary encoder gives out 400 pulses per revolution. I assume that there is a constant defined as follows at the start of program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LINE_COUNT = 400;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, this function assumes that the encoder could have turned more than one revolution and you just want the angle from some reference spot in degrees. Do take in to account that the long type variable will overflow after +-2 147 483 648 pulses as it is a 32 bit signed variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float getAngle() {&#xA;  long curCount = encCount;  // Store the current count.&#xA;  while(curCount &amp;lt; 0) {&#xA;    curCount += LINE_COUNT;&#xA;  }&#xA;  while(curCount &amp;gt;= LINE_COUNT) {&#xA;    curCount -= LINE_COUNT;&#xA;  }&#xA;  return (curCount / LINE_COUNT * 360.0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First the encoder count is copied to a one use variable. then two while statements make sure the values is positive from 0 to LINE_COUNT-1, so it basically reduces the count to what it would be with just under one revolution. Then it returns the number of degrees by calculating the current position as a fraction of a one revolution count and multiplies this with 360 to get the degrees.&lt;/p&gt;&#xA;" OwnerUserId="10149" LastActivityDate="2015-05-19T20:28:46.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12000" PostTypeId="2" ParentId="11998" CreationDate="2015-05-19T21:03:32.320" Score="2" Body="&lt;p&gt;&lt;strong&gt;Controlling the speed of an AC motor is not an easy undertaking, and messing around with mains voltages if you're not experienced and know what you're doing can be fatal.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that's the disclaimer out of the way, on to your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unlike DC, you cannot use PWM to control the average power of AC.  That is, after all, what PWM does - the on-off ratio creates a percentage of the power - but it can only be done if the incoming power is of a steady state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For AC there are two ways of reducing the output power - either reduce the voltage, which can be done with resistors (look inside a multi-speed fan and you'll see resistors to change the speed); or chop up the AC waveform, which is a little like PWM but more specialized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want specific speeds then you could pre-define them using resistors and switch different resistor combinations in and out using relays.  It's crude, but simple, and also probably the safest option for the beginner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want proper variable speed, though, then you're going to have to chop up the waveform.  The theory is quite simple:  Start where the waveform crosses 0V in either direction, with the output on, and turn it off again at some percentage of the way through the cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like PWM it's the on-off percentage that defines the output power (and thus the speed), but timing is critical - you must start the PWM sequence at 0V and it must last exactly one cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RxuQX.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A number of simple circuits work in the opposite way - they remain off until the input waveform reaches a certain point, then switch on, until they reach the zero-crossing point.  While simple, these circuits aren't good.  The reason being that the sudden rise from 0V to the &quot;trigger&quot; voltage when the output becomes live can cause large spikes and noise in the circuit, which can cause lights to blow etc.  It's the same effect as why bulbs most often blow when you turn them on, not when they have been running for a while - it's that very rapid rise from 0V to a high voltage which causes them to be over-stressed and blow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So any circuit you choose should really be a proper one which turns on at 0V and turns off after a period, not turn on at a voltage and turn off at 0V.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-19T21:03:32.320" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12001" PostTypeId="2" ParentId="11990" CreationDate="2015-05-19T21:13:55.370" Score="1" Body="&lt;p&gt;As Gerben said relays are only for on/off control. If you need to fade led you should use transistor. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;What kind of transistor?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It depends on power consumption (how many LEDs).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;How to connect Arduino, LEDs, transistor?&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is schematics how to connect the strip. As i assume resistors are already on the strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ljDVH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And little bit simpler image :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/C1dYD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-05-19T21:13:55.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12002" PostTypeId="1" AcceptedAnswerId="12275" CreationDate="2015-05-19T21:46:43.093" Score="3" ViewCount="6145" Body="&lt;p&gt;I tried different times to use socat and ser2net in order to upload a sketch to an Arduino Uno (connected to a PC) from my laptop, unsuccessfully. Can anyone teach me how to achieve this goal? I use Linux.&lt;/p&gt;&#xA;" OwnerUserId="10183" LastEditorUserId="4628" LastEditDate="2017-01-12T06:48:46.783" LastActivityDate="2017-01-12T06:48:46.783" Title="Upload sketch remotely through a serial-IP-serial connection" Tags="|arduino-uno|serial|uploading|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12003" PostTypeId="1" CreationDate="2015-05-19T21:52:53.523" Score="1" ViewCount="5664" Body="&lt;p&gt;i'm having few PCF8574P which i want to use with my arduino and multiplex them however i have no idea how to use the I2C BUS and the IC in general. There are few libraries but they're fairly complex. Is there any library which makes writing and reading from the PCF8574P easy?&lt;/p&gt;&#xA;" OwnerUserId="6969" LastActivityDate="2017-10-01T08:35:31.573" Title="How to use an PCF8574P with the simplest code possible" Tags="|arduino-uno|pins|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12004" PostTypeId="2" ParentId="11941" CreationDate="2015-05-19T22:23:40.937" Score="3" Body="&lt;p&gt;If you really need to update your NVRAM frequently, look into &lt;a href=&quot;http://www.fujitsu.com/downloads/MICRO/fsa/pdf/products/memory/fram/MB85RS64V-DS501-00015-4v0-E.pdf&quot; rel=&quot;nofollow&quot;&gt;FRAM (Ferroelectric Random Access Memory)&lt;/a&gt; which claims a write life of 10^13 cycles (that's ~ 318,000 years if you write once/sec!). They're 8KB, and faster than Flash or EEPROM at 20MHz (SPI).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit (in the US) sells them on a breakout board for about US$6 in onesies. Or you can buy the bare chips from the usual suppliers for around US$1.30, but not DIP, only SOP8 packages. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-19T22:23:40.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12005" PostTypeId="2" ParentId="11969" CreationDate="2015-05-19T22:59:37.477" Score="1" Body="&lt;p&gt;If you ever drive an I/O more than a diode drop above or below its power supply rails, the internal ESD protection structure will begin to conduct.  The internal structure is only there to keep the part alive during normal handling, i.e. in a factory but not for the situation described above.  If the current in this structure is allowed to go high enough, it looks like an SCR and &quot;Latches&quot; up.  When latch up occurs the device, like an SCR, will keep conducting as much current as the power supply rails are capable of until the current is removed and usually results in device destruction.  The way around this is to limit the current that may flow into a pin, and prevent current from forward biasing the ESD structure:  &lt;a href=&quot;http://www.tayloredge.com/reference/Electronics/EMIESD/InputProtection.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.tayloredge.com/reference/Electronics/EMIESD/InputProtection.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2015-05-19T22:59:37.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12006" PostTypeId="1" AcceptedAnswerId="12007" CreationDate="2015-05-19T23:22:27.587" Score="0" ViewCount="227" Body="&lt;p&gt;I originally discouraged my friend against the use of Javascript in his robot project because I didn't know any use for Javascript outside of web developement but then I saw &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/1457186950&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; book on amazon. Since I wouldn't want to mislead him could someone help me develop a better understanding of how often Javascript is used when making robots with an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="8763" LastEditorDisplayName="user6569" LastEditDate="2015-05-22T12:42:55.077" LastActivityDate="2015-05-22T12:42:55.077" Title="To what extent is Javascript used in robots?" Tags="|node.js|" AnswerCount="1" CommentCount="4" ClosedDate="2015-05-20T00:11:02.150" ContentLicense="CC BY-SA 3.0" />
  <row Id="12007" PostTypeId="2" ParentId="12006" CreationDate="2015-05-19T23:27:56.527" Score="0" Body="&lt;p&gt;It wouldn't be my first choice for programming of robotics, but it's certainly doable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to NodeJS, JavaScript (or ECMAScript as it is properly known) has broken free of the browser and is now a general programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to the BeagleBone Black (and others), which runs most of its systems by default through NodeJS, including its web-based IDE, you can program the whole board with ECMAScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, you &lt;em&gt;can&lt;/em&gt; do robotics with ECMAScript, and there are platforms which &lt;em&gt;do&lt;/em&gt; allow you to do robotics with ECMAScript.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would you want to do it in a real industrial environment?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said - it wouldn't be my first choice.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-19T23:27:56.527" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12009" PostTypeId="1" CreationDate="2015-05-20T02:14:40.820" Score="0" ViewCount="61" Body="&lt;p&gt;I want my arduino to give the output at a specified delay .The delay is calculated from a polynomial equation. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long t=40*Vin*Vin-760*Vin+4320; &#xA;delay(t);&#xA;digitalWrite(ledPin,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but while doing this i was unable to get the delay accurately while observing it through oscilloscope??&lt;/p&gt;&#xA;" OwnerUserId="10186" LastEditorUserId="4552" LastEditDate="2015-05-20T12:11:33.950" LastActivityDate="2015-05-20T17:50:47.787" Title="giving delay function to output" Tags="|programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12010" PostTypeId="2" ParentId="12003" CreationDate="2015-05-20T02:28:30.020" Score="2" Body="&lt;p&gt;Have you given &lt;a href=&quot;http://playground.arduino.cc/Main/PCF8574Class&quot; rel=&quot;nofollow&quot;&gt;Rob Tillaart's library from the Arduino Playground&lt;/a&gt; a try? The demo sketch might look a bit overwhelming, but at it's simplest, all your sketch should need to have to make a led blink like the standard arduino 'blink' sketch is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;PCF8574.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;// adjust addresses if needed&#xA;PCF8574 PCF_38(0x38);  // add led to P0 (pin 4) (used as output)&#xA;&#xA;void setup()&#xA;{&#xA;//your setup code here&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    //turn P0 (pin 4) of the I/O expander on and off once a second&#xA;    PCF_38.write(0, 1);&#xA;    delay(1000);&#xA;    PCF_38.write(0, 0);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have any of these parts handy so I can only give generic advice.&lt;/p&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2015-05-20T02:28:30.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12011" PostTypeId="2" ParentId="11993" CreationDate="2015-05-20T02:40:26.503" Score="2" Body="&lt;p&gt;Unfortunately there is no easy way to do this. All you can hope to do if you see multiple sketches, which if combined would achieve your desired goal, is to splice the code into a single sketch (by copying and pasting), and hope that there are no conflicts resulting from the merging of the different sets of code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For simple things like two sketches using the same pins, you may be able to fix that by changing which pins are used (unless they are special purpose pins such as PWM or hardware interrupts). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For harder to diagnose problems like two libraries not working if used the same sketch, that is almost impossible to resolve unless you know the hardware or library well enough. Best option there is to find another that does the same job, but differently. &lt;/p&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2015-05-20T02:40:26.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12012" PostTypeId="2" ParentId="11989" CreationDate="2015-05-20T02:56:04.053" Score="0" Body="&lt;p&gt;Single LEDs like the standard 5mm leds work from low voltages such as 1.7 - 2.1v, so can be directly driven via an Arduino pin (through a resistor to prevent excess current draw which would damage the pin). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED strips such as automotive LED strips (12v) require the use of a relay if you are simply switching the LEDs on and off. You can't run the relay directly from an Arduino pin, you will need to use a transistor to act as a buffer between the relay and the Arduino to prevent damaging the Arduino. Instead of the motor and diode in the below diagram, you connect your 12v led strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oqukb.png&quot; alt=&quot;relay arduino connection&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to control intensity, you will need to use a transistor, or a mosfet (mosfets are easier). You can then use AnalogWrite to control the intensity of the LEDs via the MOSFET. You will need to connect the control pin for the MOSFET to one of the PWM-capable pins on the Arduino (the pins which have the ~ mark next to them), otherwise you will only be able to switch the MOSFET on and off, similar to the Relay. This site has a good guide on how to do this with a &lt;a href=&quot;http://bildr.org/2012/03/rfp30n06le-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSFET&lt;/a&gt;. It also has a guide on how to use a transistor, but I can't include the link yet due to not enough reputation points. It shows both the code needed, and how to connect the components to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SAKF3.png&quot; alt=&quot;mosfet arduino connection&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10187" LastEditorUserId="27346" LastEditDate="2019-01-01T15:03:57.450" LastActivityDate="2019-01-01T15:03:57.450" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12013" PostTypeId="2" ParentId="11987" CreationDate="2015-05-20T02:59:44.643" Score="0" Body="&lt;p&gt;If your error is intermittent, check all of your wiring to ensure there is nothing loose, and try hitting the 'reset' button the Arduino as the compile message changes to uploading, in case your serial adapter isn't resetting the Arduino properly. &lt;/p&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2015-05-20T02:59:44.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12014" PostTypeId="2" ParentId="11959" CreationDate="2015-05-20T03:05:57.653" Score="1" Body="&lt;p&gt;If your motor doesn't work when connected to the 9V battery, either the battery is flat (which is likely since you were able to connect the LED without destroying it!! - they are a 2.5-3v part, not a 9v part) or the wiring to the motor is damaged. When you connect the motor directly to a 9v battery, it should turn pretty fast - may also work if you connect it to between 2 &amp;amp; 4 AA batteries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;9v batteries don't have that much energy in them... you would be better off with a battery pack with 6 AA batteries in it.&lt;/p&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2015-05-20T03:05:57.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12015" PostTypeId="2" ParentId="11968" CreationDate="2015-05-20T03:11:28.127" Score="1" Body="&lt;p&gt;You can find stackable headers on eBay (ie. 141063314400 , 191576393028 , 271841707614). &lt;a href=&quot;http://www.futurlec.com.au/ConnHead.jsp&quot; rel=&quot;nofollow&quot;&gt;Futurlec&lt;/a&gt; also sell them pretty cheap - about half-way down the page.&lt;/p&gt;&#xA;" OwnerUserId="10187" LastActivityDate="2015-05-20T03:11:28.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12016" PostTypeId="1" AcceptedAnswerId="12085" CreationDate="2015-05-20T04:39:35.260" Score="1" ViewCount="53" Body="&lt;p&gt;I would like to read MUX 14 with the ADC.  On page 263 of the &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmega328 data  sheet&lt;/a&gt; it shows 1110b on the MUX corresponding with reading V_BG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to read this so I can calibrate my sensor readings taken with the 5v reference to those taken with the 1.1v reference.  Because the 5v power supply may vary and the 1.1 is more stable, I need to be able to translate the readings taken with a 5v reference based on how the internal 1.1v is read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the &lt;a href=&quot;http://garretlab.web.fc2.com/en/arduino/inside/arduino/wiring_analog.c/analogRead.html&quot; rel=&quot;nofollow&quot;&gt;code for analogRead&lt;/a&gt;, I wrote this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int readVBG(int _analogReference) {&#xA;  uint8_t low, high;&#xA;  ADMUX = (_analogReference &amp;lt;&amp;lt; 6) | 14;&#xA;  sbi(ADCSRA, ADSC);&#xA;  while (bit_is_set(ADCSRA, ADSC));&#xA;  low  = ADCL;&#xA;  high = ADCH;&#xA;  return (high &amp;lt;&amp;lt; 8) | low;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;_analogReference is either 1 or 3 depending on the reference voltage desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect to read 1023 when _analogReference is 3 and about 225 when _analogReference is 1.  Instead I get smaller values which I'm guessing are from a floating (unconnected) analog pin.&lt;/p&gt;&#xA;" OwnerUserId="10188" LastActivityDate="2015-08-21T02:14:39.560" Title="Trouble reading V_BG" Tags="|analogread|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12017" PostTypeId="1" CreationDate="2015-05-20T05:02:14.773" Score="1" ViewCount="2553" Body="&lt;p&gt;I am using Windows 8.1 64 bit. I have an Arduino Mega 2560. I configured and installed it with the Merlin firmware before. I had a system format in between. I tried to connect my Arduino again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Not detecting any hardware when plugging in the Arduino board: the green LED is on and the yellow LED is blinking. I checked the Device manager. It doesn't come in either COM ports or other devices. (The last time it came in COM ports as Arduino Uno). I installed legacy hardware on COM 3 (which was used before) and tried to update the driver from a newly downloaded version of Arduino. No success. I disabled the certification signature requirement from boot menu and tried: again no success.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The serial port on Arduino is greyed out.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I need some help. I am running out of ideas. I tried uninstalling COM port. I cleaned the registry with CCleaner. I uninstalled all Arduino software. I rebooted the system. I downloaded everything again, then connected the board. Still not detecting the new hardware. :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help me out.&lt;/p&gt;&#xA;" OwnerUserId="10190" LastEditorUserId="4628" LastEditDate="2017-05-13T05:42:17.367" LastActivityDate="2017-05-13T05:42:17.367" Title="Not detecting Arduino Mega 2560. It worked before but now not detecting" Tags="|arduino-mega|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12018" PostTypeId="2" ParentId="12009" CreationDate="2015-05-20T06:39:43.040" Score="1" Body="&lt;p&gt;I suggest you look into using a hardware timer rather than using delay(), I suspect it will give you more accurate timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer configuration is not as straight forwards as using delay - they don't work in milliseconds or microseconds, but instead in multiples of clock cycles, which (I find) makes configuring them a little difficult to understand, but it is possible to set the interval of a timer within its own interrupt routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another advantage to using timers is that your code can do other things whilst waiting between interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a read here for more information and simple examples:&#xA;&lt;a href=&quot;http://playground.arduino.cc/code/timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/code/timer1&lt;/a&gt;&#xA;or just Google &quot;Arduino timers&quot; for other examples and explanations.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-20T06:39:43.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12019" PostTypeId="2" ParentId="11994" CreationDate="2015-05-20T07:18:54.810" Score="1" Body="&lt;p&gt;(1) A multipole active lowpass filter works wonders.&lt;br&gt;&#xA;Something like a 5 pole Bessel filter will probably meet your need. That needs two active stages (1 input RC pole +2 +2 ). You can use transistors in emitter follower mode with some reservations but using 2/4 of a quad opamp per filter is easier overall. I can't spare the lookup time just now (later maybe) but AD &amp;amp; LT and NatSemi all have good free active filter design programs.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) A Simple sample &amp;amp; hold per channel will give you steady output limited only by the drift of the opamp used. You can buy commercial S&amp;amp;H ICs or use std opamps. I've used even the venerable LM324 for this but there are much better - you apply the voltage via a switch to a cap[acitor at a unity gain buffer input and then turn off the switch. Again, the &quot;switch can be as simple as an ancient CD4016 or CD4051 but much better more modern ICs are available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With 1 x CD4051 and 2 x LM324 (or better) you can feed 8 x S&amp;amp;H and update them occasionally top compensate for drift.  If you add another CD4051 with identical addressing but working backwards you can read back the current capacitor voltage and &quot;nudge&quot; it with a simple digital on signal via a diode and high R  resistor if it is slightly off. You can even do ALL signal setting this way if required with NO PWM (or you are effectively implementing adaptive PWM without formally doing so). You eg use 4 driver lines - a fast and slow drive high and a fast and slow drive low. Each is just a digital pin + a resistor and a diode. Select one output channel with the output mux (CD4051 or whatever, and the return mux connects it to your ADC. Pump it up to about right with fast-high, top it off with slow-high and correct with slow-low if needed, then step the mux to the next channel and the S&amp;amp;H cap looks after it. Note that the return channel to the ADC must not load the cap significantly while reading. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this answer attracts significant interest I can add detail and suggestions re more modern components etc. If not, the above is all a keen person needs to look into the concept. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-20T07:18:54.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12020" PostTypeId="2" ParentId="11992" CreationDate="2015-05-20T07:47:54.487" Score="1" Body="&lt;p&gt;To set the spi to shift out on falling edge and shifting in on rising edge of the clock you need to set the spi mode to 0 or 2 (depends on idle clock polarity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;More info here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To continuously generate clock signal as far as I remember you will need to write to the SPI dummy values. &lt;/p&gt;&#xA;" OwnerUserId="10191" LastActivityDate="2015-05-20T07:47:54.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12021" PostTypeId="1" AcceptedAnswerId="18750" CreationDate="2015-05-20T12:42:31.943" Score="-1" ViewCount="652" Body="&lt;p&gt;I'm using Hc-Sr 04 ultrasonic sensor for my project and I want to know that if I could or not utilize an slope. Have you an idea?&lt;/p&gt;&#xA;" OwnerUserId="10196" LastActivityDate="2015-12-22T00:00:44.127" Title="Hc Sr 04 Ultrasonic Sensor" Tags="|sensors|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12022" PostTypeId="1" CreationDate="2015-05-20T14:45:37.497" Score="2" ViewCount="1295" Body="&lt;p&gt;I am building a device that communicates with my Android phone.&#xA;I know that my App works but my Arduino code seems to have a problem.&#xA;So I have made a smaller programm and everything works fine there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SMALLER PROGRAM - THAT WORKS&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial btSerial(8,9); // RX, TX&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  btSerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  //Send everything from PC-Console&#xA;  while( Serial.available() )&#xA;  {&#xA;     btSerial.write( Serial.read() ); &#xA;  }&#xA;&#xA;  //Show everything received with bluetooth to PC-Console&#xA;  if(btSerial.available())&#xA;  {&#xA;    while(btSerial.available())&#xA;          Serial.write((char)btSerial.read());&#xA;&#xA;    Serial.println(&quot;&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought everything is fine so I've changed a few things in my original code.&#xA;But still the Arduino receives nothing, sending is no problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ORIGINAL PROGRAM - PROBLEM&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial btSerial(8, 9); //RX TX&#xA;SoftwareSerial rfidSerial(11, 12);&#xA;&#xA;char tagCollection4][13] = { {&quot;6A003D68AA95&quot;},&#xA;                             {&quot;6A003D8879A6&quot;},&#xA;                             {&quot;6A003D49617F&quot;},&#xA;                             {&quot;6A003A426775&quot;} }; &#xA;&#xA;String tagCollection_str[4] = {&quot;6A003D68AA95&quot;, &#xA;                               &quot;6A003D8879A6&quot;, &#xA;                               &quot;6A003D49617F&quot;,&#xA;                               &quot;6A003A426775&quot;};&#xA;&#xA;&#xA;bool tagsFound[4] = {false, false, false, false};&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  btSerial.begin(9600);&#xA;  rfidSerial.begin(9600); &#xA;}&#xA;&#xA;void loop() {  &#xA;&#xA; //Send everything from PC-Console to Bluetooth device | that part works &#xA;  while( Serial.available()  )&#xA;  {&#xA;    btSerial.write( Serial.read() ); &#xA;  }&#xA;&#xA;  //Show everything received with Bluetooth device on my PC-Console&#xA;  if( btSerial.available() )&#xA;  { &#xA;     while(btSerial.available())&#xA;              Serial.write((char)btSerial.read());&#xA;&#xA;    Serial.println(&quot;&quot;);&#xA;  }&#xA;&#xA;  //Here starts the Rfid Part that I’ve done first it works mostly&#xA;  char tagString[13];&#xA;  int index = 0;&#xA;  boolean reading = false;&#xA;&#xA;  if(rfidSerial.available() )&#xA;  {&#xA;    while( rfidSerial.available() )&#xA;    {&#xA;      int readByte = rfidSerial.read(); //read next available byte&#xA;&#xA;      if(readByte == 2) reading = true; //begining of tag&#xA;      if(readByte == 3) reading = false; //end of tag&#xA;&#xA;      if(reading &amp;amp;&amp;amp; readByte != 2 &amp;amp;&amp;amp; readByte != 10 &amp;amp;&amp;amp; readByte != 13){&#xA;        //store the tag&#xA;        tagString[index] = readByte;&#xA;        index ++;&#xA;      } &#xA;    }&#xA;&#xA;    delay(50);&#xA;  }&#xA;&#xA;  checkTag(tagString); &#xA;  clearTag(tagString); //Clear the char of all value&#xA;*/&#xA;}&#xA;&#xA;void checkTag( char tag[] )&#xA;{&#xA;  if(strlen(tag) == 0) {return;}&#xA;&#xA;  int tagNum = compareTag( tag );&#xA;&#xA;  if( tagNum == -1 )&#xA;  {&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.println(&quot;NO MATCH&quot;);&#xA;    Serial.println(&quot;&quot;);&#xA;  }&#xA;  else &#xA;  {&#xA;   if( !tagsFound[tagNum] )&#xA;   {&#xA;      tagsFound[tagNum] = true;&#xA;   }&#xA;   else&#xA;   {&#xA;     tagsFound[tagNum] = false;&#xA;   }  &#xA;   //Just a little delay&#xA;   delay(2000);&#xA;  }&#xA;&#xA;  //Show the scanned tag&#xA;  Serial.println(&quot;&quot;);&#xA;  for( int i=0; i&amp;lt;13; i++ )&#xA;  {&#xA;   Serial.write(tag[i]); &#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  for(int i=0; i&amp;lt;4; i++)&#xA;  {&#xA;      Serial.println( tagsFound[i] );&#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;}&#xA;&#xA;int compareTag( String tag )&#xA;{&#xA;&#xA;  if(tag[9] == tagCollection4[0][9])&#xA;      return 0;&#xA;&#xA;  if(tag[9] == tagCollection4[1][9])&#xA;      return 1; &#xA;&#xA; if(tag[9] == tagCollection4[2][9])&#xA;      return 2;&#xA;&#xA;  if(tag[9] == tagCollection4[3][9])&#xA;      return 3;&#xA;&#xA;  return -1;&#xA;}&#xA;&#xA;&#xA;void clearTag(char one[]){&#xA;///////////////////////////////////&#xA;//clear the char array by filling with null - ASCII 0&#xA;//Will think same tag has been read otherwise&#xA;///////////////////////////////////&#xA;  for(int i = 0; i &amp;lt; strlen(one); i++){&#xA;    one[i] = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me, it's for a school project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for everything in advance.&lt;/p&gt;&#xA;" OwnerUserId="10199" LastEditorUserId="37523" LastEditDate="2019-08-22T21:48:23.597" LastActivityDate="2019-08-22T21:48:23.597" Title="Arduino code issue (using Bluetooth and Rfid technology)" Tags="|bluetooth|communication|softwareserial|rfid|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="12023" PostTypeId="1" AcceptedAnswerId="12024" CreationDate="2015-05-20T15:22:23.753" Score="0" ViewCount="2256" Body="&lt;p&gt;I want to Create a battery Charger with the Arduino with real time battery status. I don't have any idea how to do that same time as the charging.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;I know to use a serial monitor to get battery status but not to charge.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;br&gt;&#xA;I would like to know how to do that simultaneously so that I don't over charge the battery. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This is the battery for Lumia 822 &lt;/li&gt;&#xA;&lt;li&gt;Nokia BP-4W 1800mAh 3.7v 6.7Wh&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1296" LastActivityDate="2015-05-21T09:44:15.407" Title="Create a Li-Polymer Battery Charger" Tags="|arduino-uno|voltage-level|battery|electronics|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="12024" PostTypeId="2" ParentId="12023" CreationDate="2015-05-20T16:01:57.880" Score="4" Body="&lt;p&gt;&lt;strong&gt;(1) A simple method&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;BEST method is to use a proper charger - they are not high cost if you look around and doing it properly extends precious battery life.&lt;/p&gt;&#xA;&lt;p&gt;Next best in this context is my &amp;quot;better&amp;quot; method in 2. below.&lt;/p&gt;&#xA;&lt;p&gt;BUT, given the system you say you are using now, the following very simple method will greatly improve your result and ave your battery from an early death.&lt;/p&gt;&#xA;&lt;p&gt;You need a 1 Ohm resistor and a voltmeter that you can trust to read a 4.1V votage accurately. Without these the simple method risks battery damage or destruction - just as your present method does.&lt;/p&gt;&#xA;&lt;p&gt;Warning: Straight connection to a USB port is very unwise but may be viable if the port current-limits.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If the current is ever higher than the rated maximum then battery destruction may occur.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the battery voltage ever exceeds 4.2V at room temperature battery damage WILL occur and battery destruction may occur.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Worst case a badly treated battery can turn into a flaming inferno in seconds.&lt;/p&gt;&#xA;&lt;p&gt;A usably OK result can be gained by:&lt;/p&gt;&#xA;&lt;p&gt;(1) Calculate Imax = same mA as battery mAh capacity.&lt;br /&gt;&#xA;LOWER is OK. Higher is not.&lt;br /&gt;&#xA;eg 1200 mAh battery = 1200 mA max and say 1000 or 500 or lower mA is OK.&lt;/p&gt;&#xA;&lt;p&gt;(2) Connect a ONE OHM resistor in USB to battery line.&lt;/p&gt;&#xA;&lt;p&gt;(3) Connect &lt;strong&gt;discharged&lt;/strong&gt; LiPo battery to USB port via 1 Ohm.&lt;/p&gt;&#xA;&lt;p&gt;(4) Measure voltage across the resistor.  The voltage will be 0.001 Volt for every mA that flows. eg&lt;br /&gt;&#xA;1000 mA gives 1.000 Volt&#xA;789 mA gives 0.789 V.&#xA;1234 mA gives 1.234 V. etc.&lt;/p&gt;&#xA;&lt;p&gt;If the measured mA is LESS THAN Imax in (1) above then this is OK to charge with.&lt;/p&gt;&#xA;&lt;p&gt;(5) Use Arduino analogRead() function WHILE CHARGING to measure battery voltage.&lt;br /&gt;&#xA;BE SURE that the voltage that you read with the Arduino matches what a quality meter says.&lt;br /&gt;&#xA;When Vbattery (measured from Bat + to Bat- AT the battery) measures 4.1 V STOP CHARGING, remove voltage.&lt;br /&gt;&#xA;Battery will be perhaps 70% charged and will have a long cycle life (if not already damaged).&lt;/p&gt;&#xA;&lt;p&gt;For 10 bit ADC = 1024 counts total (0-1023) then&lt;br /&gt;&#xA;for 5V reference 4.1V count = 4.1/5 x 1023&lt;br /&gt;&#xA;= 838 counts.&lt;br /&gt;&#xA;Using 830 counts to start with is safer.&lt;/p&gt;&#xA;&lt;p&gt;When battery is at the upper charge limit,  and &lt;strong&gt;before&lt;/strong&gt; removing Vcharge, measure voltage at battery with calibrated quality meter. Result should be 4.1V using above system.&lt;/p&gt;&#xA;&lt;p&gt;Even with a quality calibrated meter NEVER exceed 4.2V - and 4.1V is better.&lt;/p&gt;&#xA;&lt;p&gt;The BEST method is to use a proper charger - they are not high cost if you look around and they extend precious battery life.&lt;/p&gt;&#xA;&lt;p&gt;._______________________________&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;(2) A better method:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;LiIon (Lithium Ion)and LiPo (Lithium Polymer) batteries are functionally the same for charging purposes. I'll use the term &amp;quot;LiPO&amp;quot; from here on. I'll assume single cell batteries as most in cellphones and similar are. If the terminal voltage is between about 2.5V (should really be higher) and 4.3V they are single cell,&lt;/p&gt;&#xA;&lt;p&gt;LiPo batteries have 4 main charge areas.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Under about 2V = dangerously dead. Discard&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;2V to about 3V = under voltage - charge very slowly&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;3V to 4.2V = charge at CC  = Constant Current.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On reaching 4.2V charge at CV = Constant Voltage until current reduces &amp;quot;automatically&amp;quot; (under battery chemistry control)  to about 1/4 x max rate.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Max charge rate is set by the manufacturer but is almost always the numerical mAh rating in mA. eg for a 1000 mAh battery max rate is 1000 mA. For a 3300 mAh battery it's 3300 mA etc. In a very few cases it is lower - maybe =half standard values and for a very small number of cells its higher - assume you do not have those.&lt;/p&gt;&#xA;&lt;p&gt;Max voltage &lt;strong&gt;MUST NOT&lt;/strong&gt; exceed 4.2V at room temperature. Lower, say 4.1V, does no harm and increases battery cycle life while slightly reducing capacity per charge.&lt;/p&gt;&#xA;&lt;p&gt;The battery mAh rating is known as &amp;quot;C&amp;quot;.&lt;br /&gt;&#xA;If C = 1200 then a cahrage rate of 1200 mA = C/1,&lt;br /&gt;&#xA;a charge rate of 300 mA = C/4,&lt;br /&gt;&#xA;a charge rate of 12 mA = C/100 etc&lt;/p&gt;&#xA;&lt;p&gt;An easy charging method that gives long cycle life and about 70% to 80% of max possible capacity and a fast charge is&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Determine max charge rate = C  = Imax = same mA as battery has mAh capacity.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If Vbattery is &amp;lt; 3V, charge at C/20 or less until Vbattery reaches 3V.&lt;br /&gt;&#xA;If Vbattery never reaches 3V it is dead.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When V_battery = &amp;gt;= 3V, charge at C/1 until Vbattery = 4.2V ( or 4.1V)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Finished!.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove applied voltage. DO NOT EVER leave 4.2V applied to a charged battery.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;A more usual method that is only slightly harder is.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Monitor charge current.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Charge as above until Vbat = 4.2V.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;While holding Vbat at 4.2V monitor charge current. This will fall as the battery absorbs additional charge.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When  Icharge falls to C/2 or C/4, stop charge. C/4 adds slightly more charge than C/2 but shortens cycle life.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Again - DO NOT leave 4.2V applied to battery once charged. Doing so will destroy the battery rapidly. Remove all voltage once charged.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;.______________________________&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Battery University:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://batteryuniversity.com/learn/article/charging_lithium_ion_batteries&quot; rel=&quot;nofollow noreferrer&quot;&gt;Charging Lithium Ion &amp;amp; LiPo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries&quot; rel=&quot;nofollow noreferrer&quot;&gt;Increasing lifetime&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://batteryuniversity.com/learn/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Index&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;.______________________&lt;/p&gt;&#xA;&lt;h3&gt;Q&amp;amp;A&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Q: This is a 3.7v battery by giving 4.2v will it destroy it or are you referring 4.2v to explain the concept.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Read the above material and the battery university pages.&lt;/p&gt;&#xA;&lt;p&gt;4.1 V ABSOLUTE MAXIMUM is what I recommended.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Most LiPo single cell batteries are labelled as 3.6 V or 3.7 V as that is approximately the &lt;strong&gt;average voltage&lt;/strong&gt; across the discharge cycle.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When &lt;strong&gt;fully charged&lt;/strong&gt; they are at &lt;strong&gt;about 4.2 V (or 4.1 V if you take my advice -&lt;/strong&gt; which you should :-).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As they discharge the voltage falls and by the time they get to just above 3 V they are essentially fully discharged. They should never be discharged below 3 V as it damages them and there is only a tiny amount of energy left.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So 4.1 V ABSOLUTE MAXIMUM is good&lt;br /&gt;&#xA;MEASURED WHILE CHARGING and&lt;br /&gt;&#xA;AT the battery terminals or very close to them.&lt;br /&gt;&#xA;ie no long leads or resistors or connectors.&lt;/p&gt;&#xA;&lt;p&gt;If using an Arduino to measure battery voltage,  connect an Arduino ground lead to battery negative with as short a wire as practical and the ADC +ve input to the battery +ve at the battery connection point.&lt;/p&gt;&#xA;&lt;p&gt;So once more: A LiPo battery labelled as 3.6V or 3.7V can and should be charged to 4.1V maximum and never discharged to below 3V.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-05-21T09:44:15.407" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12025" PostTypeId="2" ParentId="12021" CreationDate="2015-05-20T17:23:53.277" Score="0" Body="&lt;p&gt;Slope surfaces may cause reflections so you need to try. I think 30 degree going to make reflection and gives wrong value&lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-05-20T17:23:53.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12026" PostTypeId="2" ParentId="12009" CreationDate="2015-05-20T17:50:47.787" Score="0" Body="&lt;p&gt;Perhaps you had in mind something like this fragment, which will raise &lt;code&gt;ledPin&lt;/code&gt; for the time you calculated (in msec) then lower it again?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ...&#xA;unsigned long t=40*Vin*Vin-760*Vin+4320; &#xA;digitalWrite(ledPin,HIGH);&#xA;delay(t);&#xA;digitalWrite(ledPin,LOW);&#xA;// ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-20T17:50:47.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12028" PostTypeId="1" AcceptedAnswerId="12029" CreationDate="2015-05-20T20:15:17.137" Score="4" ViewCount="12385" Body="&lt;p&gt;This is my first post to this forum.  I am fairly experienced in electronics, but am in the process of learning C, Arduino coding, and how to use microcontrollers in general for various applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a toy-like 5 degree of freedom (DOF) robot arm that is currently controlled using the OEM hand-held switch box.  It is a basic electromechanical robot arm to illustrate the fundamentals and it uses DC motors to drive the joint motions.  The direction of motion is controlled by changing the polarity of the applied voltage.  The manufacturer did offer an &quot;interface board&quot; and SW to be able to hook up the arm and control it using a computer program.  However, this approach was fairly dated and their SW was not compatible with windows 8.1.  I wanted to experiment and use an Arduino Uno Rev 3 and 5V DC relay PCBs to develop my own interface system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, the HW aspect was straightforward and is working fine.  The Arduino SW also is working fine.  I am playing around with 2 variations of the program: 1) One program that simultaneously moves up to 3 joints and 2) A sequential joint movement program where each joint only moves after the other has finished moving.  One &lt;strong&gt;note&lt;/strong&gt; about the simultaneous program is that I am using the &quot;internal&quot; batteries in the robot's base (only 3V each direction) and thus can not realistically move more than 3 joints at the same time without putting too much load on the source voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Ok, now to my question!&lt;/strong&gt; As it stands now, the program works well, but is not intuitive.  Each joint has 2 relays associated with it: one for each direction of travel.  There are 5 joints total in the robot arm.  I am able to use the program easily since I know directly (from setting up the HW and then the SW) which relays correspond to which Arduino pins and of course which relays correspond to each joint.  I'd like to make the program more intuitive where instead of &quot;2,2,0,0,3,4&quot; input string for example, the user would do something like &quot;B,CCW,S,CW&quot;  where B is for B = base, CCW = is counter clockwise etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that in the numerical only input string &quot;2,2,3,4&quot; for example, the 2nd value corresponds to the duration in seconds that the relay will be ON (and thus the joint moving).  The robot arm is not very sophisticated in that it doesn't have encoders for position feedback.  The simplest way (and the method which the OEM interface board uses) to interface this arm and make a program where the arm will move in a &quot;hands-off fashion&quot; was to use relays and program delays (to create time durations of joint movement&quot;.  The numerical only input works really well currently and it was very easy to use examples to figure out how to parse a comma separated string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand (I think) from looking at the examples how to parse a comma separated text string and pull from it the input values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, I am uncertain how to use those input values and then associate them in the SW with the correct relays (Arduino Pins)!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried seeking help with this but am unable to understand this thread:  &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,94701.0.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php/topic,94701.0.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I need a 2D table where the joint and direction are input and then the SW associates one particular relay with those inputs. Please see the table below for a graphical example of what I tried to say above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible solution that I &lt;strong&gt;dread&lt;/strong&gt; and saw mentioned was to use a ton of &lt;strong&gt;if else-if statements....&lt;/strong&gt;  I dread this since I want to be able to input any joint in any order and thus it seems like when the code parses the input string for the ith relay, it would have to check ALL of the conditions to see which joint it is, which direction etc.  For example, I think I could minimize the # of if statements needed if I only entered in the input commands in a certain order: base first, shoulder next, etc.  Doing so however, limits the intuitiveness of the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zkLUT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you all for reading this!  I hope this isn't too challenging!&lt;/p&gt;&#xA;" OwnerUserId="10203" LastEditorUserId="10203" LastEditDate="2015-05-20T20:24:03.917" LastActivityDate="2015-05-21T06:28:25.557" Title="How to implement a 2D lookup table?" Tags="|relay|" AnswerCount="4" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12029" PostTypeId="2" ParentId="12028" CreationDate="2015-05-20T20:33:05.350" Score="2" Body="&lt;p&gt;I suggest you turn this into a simple 1D table by using two different&#xA;separators, for example ‘:’ between joint and direction, and ‘,’ between&#xA;consecutive movements. Then, instead of “B,CCW,S,CW” you would type&#xA;“B:CCW,S:CW”. For parsing the string, you split at the commas, and&#xA;consider the pieces between the commas as single items. In other words,&#xA;“B:CCW” would be the name for relay 2, and you do not try to split it&#xA;further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple method to map the strings to the relays:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;const char * const relay_names[] = {&quot;&quot;, &quot;B:CW&quot;, &quot;B:CCW&quot;, &quot;S:UP&quot;,&#xA;    &quot;S:DN&quot;, &quot;W:CW&quot;, &quot;W:CCW&quot;, &quot;E:UP&quot;, &quot;E:DN&quot;, &quot;G:OP&quot;, &quot;G:CL&quot;};&#xA;&#xA;// Return the relay number.&#xA;int get_relay(const char * name)&#xA;{&#xA;    for (int i = 1; i &amp;lt;= 10; i++)&#xA;        if (strcmp(name, relay_names[i]) == 0)&#xA;            return i;&#xA;    return -1;  // meaning invalid&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-05-21T05:58:47.793" LastActivityDate="2015-05-21T05:58:47.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12030" PostTypeId="2" ParentId="12028" CreationDate="2015-05-20T21:22:52.133" Score="0" Body="&lt;p&gt;In C/C++, multi-dimensional arrays are represented as arrays of arrays of arrays ..., for the number of dimensions needed (the last subscript varying most rapidly as you step through the stored elements in RAM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array you described is a sparse array; not all cells hold valid data. To simplify (and that's a relative term!) the storage and the code, I would arbitrarily assign each joint a forward and a reverse direction, reducing your 10-row sparse array to a dense array of only 2 rows. You can then, if you wish associate joint-relative motionss (up/down, open/close, etc.) with forward/reverse. Then you can find the pin # for a given joint relay by the joint name and direction as &lt;code&gt;RelayPin[&amp;lt;direction-name&amp;gt;][&amp;lt;joint-name&amp;gt;]&lt;/code&gt;. A downside is that writing &lt;code&gt;RelayPin[DIR_OPEN][JNT_ELBO]&lt;/code&gt; looks like nonsense but actually executes, though maybe not in the direction you think you meant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code snippet defines a 2D array of joint-relay pin numbers, with an example of enabling one of the relays:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Number of joints and directions&#xA;#define NDIRECTIONS 2&#xA;#define NJOINTS 5&#xA;&#xA;// Basic joint-motion directions&#xA;#define _DIR_FWD 0&#xA;#define _DIR_REV 1&#xA;&#xA;// Aliases for joint-motion directions&#xA;#define DIR_CW _DIR_FWD&#xA;#define DIR_CCW _DIR_REV&#xA;&#xA;#define DIR_UP _DIR_FWD&#xA;#define DIR_DN _DIR_REV&#xA;&#xA;#define DIR_OPEN _DIR_FWD&#xA;#define DIR_CLOSE _DIR_REV&#xA;&#xA;// Joint table indices&#xA;#define JNT_BASE 0&#xA;#define JNT_SHOU 1&#xA;#define JNT_ELBO 2&#xA;#define JNT_WRIS 3&#xA;#define JNT_GRIP 4&#xA;&#xA;// Joint table - each element is a digital pin number&#xA;uint8_t const RelayPin[DIRECTIONS][JOINTS] = {&#xA;//  B  S  E  W  Ga&#xA;   {1, 3, 7, 5, 9}, // forward&#xA;   {2, 4, 8, 6, 10},    // reverse&#xA;};&#xA;&#xA;// Example of enabling motion to raise the shoulder:&#xA;digitalWrite(RelayPin[DIR_UP][JNT_SHOU], HIGH)  // raise shoulder&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-20T21:22:52.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12031" PostTypeId="2" ParentId="12028" CreationDate="2015-05-20T21:51:58.070" Score="3" Body="&lt;p&gt;Another thing you can consider is to define a &lt;em&gt;struct&lt;/em&gt;.  This is a compound variable that contains other variables of different types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could define a &lt;em&gt;struct&lt;/em&gt; to describe the joints of an arm:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct arm {&#xA;    int base;&#xA;    int shoulder;&#xA;    int elbow;&#xA;    int wrist;&#xA;    int grip;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which you can then assign as variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const struct arm left_forward = { 1, 3, 7, 5, 9};&#xA;const struct arm left_reverse = { 2, 4, 8, 6, 10};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then get at different pins by using such things as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(left_forward.shoulder, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another trick is to make your struct contain a &lt;em&gt;union&lt;/em&gt; and an &lt;em&gt;anonymous struct&lt;/em&gt; so you have multiple ways of accessing the pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct arm {&#xA;    union {&#xA;        struct {&#xA;            int base;&#xA;            int shoulder;&#xA;            int elbow;&#xA;            int wrist;&#xA;            int grip;&#xA;        };&#xA;        int pins[5];&#xA;    };&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can now get at &lt;code&gt;left_forward.shoulder&lt;/code&gt; and &lt;code&gt;left_shoulder.pins[1]&lt;/code&gt; and they point to the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can create an array of these structures now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const struct arm left[2] = {&#xA;    { 1, 3, 7, 5, 9},&#xA;    { 2, 4, 8, 6, 10}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now you have &lt;code&gt;left[0].shoulder&lt;/code&gt; and &lt;code&gt;left[0].pins[1]&lt;/code&gt; both for the left shoulder moving forwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, which might be far more logical, is to turn the whole thing inside out.  Define a &quot;pin pair&quot; structure that defines the two pins for a joint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct pinpair {&#xA;    int forward;&#xA;    int reverse;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then an arm consists of 5 &quot;pin pairs&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const struct pinpair leftarm[5] = {&#xA;    {1, 2},&#xA;    {3, 4},&#xA;    {7, 8},&#xA;    {5, 6},&#xA;    {9, 10}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So to move the left shoulder forward it would be &lt;code&gt;leftarm[1].forward&lt;/code&gt; and to move the wrist backward would be &lt;code&gt;leftarm[4].reverse&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you could combine the two and have a struct of named structs for each joint if you wanted (&lt;code&gt;leftarm.shoulder.reverse&lt;/code&gt;. I'll leave you to work out the syntax for that from the examples above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for your &quot;control string&quot;.  How to deal with that.  Well, I would &quot;pre-parse&quot; it into an array of numbers.  Compile it into &quot;byte code&quot; if you will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with an empty array that would be big enough to store the data you want, then work your way through the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tokenize it (hint: strtok() is good for this) and check each piece of the string against others.  Unfortunately it's not something you can easily automate, and you'd either have to loop through an array of strings to compare each one to, or use a series of &quot;if&quot; statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each item that you match you then assign a &quot;command code&quot; to - a number you can then easily associate with a specific action or joint.  For instance, &quot;B&quot; may equate to command 0, &quot;S&quot; to 1, &quot;&quot;E&quot; to 2, etc - which just happen to coincide with the array slices for the joints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The directions could then be other codes (keep them outside the range of your array so you can identify them), maybe 16 and 17 (hint: think about the hexadecimal representation of those and how you could use that to your benefit).  It can also be useful to mark the end of the array with a special token to say &quot;this is the end&quot; - say 255 (0xff).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then once you have parsed the string and got your list of numbers, which may be something like &lt;code&gt;{ 0, 16, 1, 17, 255 }&lt;/code&gt;, you can then &quot;execute&quot; it.  Just step through each entry, if it's &amp;lt; 16 then it's a command, if it's &gt;= 16 then it's a direction, and if it's == 255 then it's the end of the command list.  It's then up to you to drive the right pins for the right periods to execute those commands.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-20T21:58:08.970" LastActivityDate="2015-05-20T21:58:08.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12032" PostTypeId="1" CreationDate="2015-05-20T22:53:34.297" Score="0" ViewCount="1433" Body="&lt;p&gt;Should I use 2 relays, one for the hot wire and one for the neutral ?&#xA;I'm talking about 16A.&lt;/p&gt;&#xA;" OwnerUserId="10206" LastActivityDate="2015-05-21T09:22:37.810" Title="Controlling a 240v AC high current relay" Tags="|current|relay|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12033" PostTypeId="2" ParentId="12032" CreationDate="2015-05-20T23:33:56.910" Score="0" Body="&lt;p&gt;As mentioned in the comments, if switching both, and the neutral relay fails open, unpredictable things may happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to switch both then use a two pole relay which switches both the live and the neutral together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, I use these relays:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://uk.farnell.com/finder/22-22-9-012-4000/relay-modular-dpst-no-12vdc-20a/dp/1169296&quot; rel=&quot;nofollow&quot;&gt;http://uk.farnell.com/finder/22-22-9-012-4000/relay-modular-dpst-no-12vdc-20a/dp/1169296&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;20A, 250VAC contact rating, double pole.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-20T23:33:56.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12034" PostTypeId="1" AcceptedAnswerId="12036" CreationDate="2015-05-21T02:50:27.803" Score="2" ViewCount="879" Body="&lt;p&gt;I'd like to write a function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void lcdPositionPrint(int row, int col,  content) {&#xA;    lcdPosition(row, col);&#xA;    LCD.print(content);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm not certain how to declare &quot;content&quot;, because it might be a string, or an int, or who knows what, just as it is for the &quot;Serial.print&quot; function or the LCD.print() function. Is there an easy way to do this? &lt;/p&gt;&#xA;" OwnerUserId="10209" LastEditorUserId="37523" LastEditDate="2019-12-04T14:40:27.287" LastActivityDate="2019-12-04T14:40:27.287" Title="Passing arguments to LCD.print through another function" Tags="|programming|avr-gcc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12035" PostTypeId="2" ParentId="12034" CreationDate="2015-05-21T04:54:35.223" Score="1" Body="&lt;p&gt;One way to do this is to use &lt;a href=&quot;http://en.wikipedia.org/wiki/Generic_programming&quot; rel=&quot;nofollow&quot;&gt;generics&lt;/a&gt;. And we also need to use an unnamed &lt;a href=&quot;http://en.wikipedia.org/wiki/Namespace&quot; rel=&quot;nofollow&quot;&gt;namespace&lt;/a&gt; to get around the IDE's &quot;helpfulness&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace {&#xA;    template&amp;lt;typename T&amp;gt;&#xA;    void lcdPositionPrint(int row, int col, T content) {&#xA;        lcdPosition(row, col);&#xA;        LCD.print(content);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will cause the compiler to create one function for each type passed in &lt;code&gt;content&lt;/code&gt; that the function is actually called with.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-21T04:54:35.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12036" PostTypeId="2" ParentId="12034" CreationDate="2015-05-21T04:54:52.543" Score="1" Body="&lt;p&gt;There isn't really a great way to do it, but there are a few ways to get it to work. Most of the problem here is that there is actually a different &lt;code&gt;LCD.print&lt;/code&gt; function for every data type. You aren't really calling the same function, your calling different functions that share the same name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You could use templates.&lt;/strong&gt; They are a powerful system built into C plus plus for generating functions and avr-gcc supports them well. With them, you can make the compiler generate all the necessary versions of your function for you. Your function would then look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt;typename T&amp;gt;&#xA;void lcdPositionPrint(int x, int y, T content) throw() {&#xA;  lcdPosition(row, col);&#xA;  LCD.print(content);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That part about &lt;code&gt;throw()&lt;/code&gt; isn't doing anything except keeping the &quot;.ino&quot; preprocessor from messing the template function up. You can call the templated function like normal, or with an explicit type &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcdPositionPrint(0,0,&quot;hello&quot;);&#xA;lcdPositionPrint&amp;lt;float&amp;gt;(0,0,32.0f);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You could also use the preprocessor.&lt;/strong&gt; Your function is very simple, so you could just as easily make it a preprocessor macro that just places you code you want in the file whenever your &quot;function call&quot; appears. It looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define lcdPositionPrint2(row,col,content) \&#xA;    do { lcdPosition(row, col); LCD.print(content); } while (0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;\&lt;/code&gt; there tells the preprocessor that the next line is also part of the macro, and you will need one on every line but the last of your function. Wrapping it in a &lt;code&gt;do&lt;/code&gt; loop that immediately ends makes it nicely substitute into more situations. Micros don't scale up well, but they are a bit simpler for quick debugging situations. The code is duplicated in each call location instead of being bundled into functions though.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-05-21T17:09:31.247" LastActivityDate="2015-05-21T17:09:31.247" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12037" PostTypeId="2" ParentId="12028" CreationDate="2015-05-21T06:28:25.557" Score="0" Body="&lt;p&gt;The other answers have presented some good techniques that are flexible enough to be adapted to other, similar problems.  By contrast, the following method is specialized to work with the particular chart of joint-letters and relay-numbers mentioned in the question.  (It can be modified for other relay-number sequences, as noted in program's comments.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than requiring entry of verbose text like CCW, or obscure abbreviations like DN, OP, and CL, it accepts a + or a - to set motor direction, with “+” corresponding to choices CW, UP, and OP, and “-” corresponding to  other choices.  For example, the question's sequence “B,CCW,S,CW” could be written as any of “B-S+”, “b-s+”, “B- S+”,  “B-,S+”, etc (ie, case is ignored, and spaces and commas are ignored before a joint-letter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the code as shown assumes each command-list line starts with a number that gives desired delay time in tenths of a second.  For example, “23 e-s+” would run E down and S up for 2.3 seconds.  The command-list “47” would sit idle (no motors on) for 4.7 seconds. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ctype.h&amp;gt;&#xA;void operateRelays(char *cmdList) {&#xA;  char *joints = &quot;BSEWG&quot;, *c=cmdList, *j;&#xA;  byte relay, delaytenths= 0;&#xA;&#xA;  while (*c &amp;amp;&amp;amp; isdigit(*c)) // Get # of tenths-of-seconds to delay&#xA;    delaytenths = 10*delaytenths + *c-'0';&#xA;&#xA;  for (; *c; ++c) {&#xA;    while (*c &amp;amp;&amp;amp; !isalpha(*c)) ++c; // Ignore non-alphas before joint&#xA;    if (!*c) break;     // At end of command list, break&#xA;    for (j=joints; *j; ++j)&#xA;      if (toupper(*c) == *j) break;&#xA;    if (!*j) break;     // Ab-exit if joint-letter not found&#xA;    if (!*(++c)) break;     // Advance to + or -&#xA;    relay = 2*(j-joints) + 1 + (*c != '+'); // The last term is 0 or 1&#xA;    digitalWrite(relay, HIGH);&#xA;    // If relay numbers aren't contiguous as in question, just use&#xA;    // an array (like: byte relays[] = {2,1,5,4,6,3,7,9,10,8};)&#xA;    // and in above statement say digitalWrite(relays[relay-1], HIGH);.&#xA;  }    &#xA;  delay (100*delaytenths); // Wait specified time&#xA;  for (relay=1; relay&amp;lt;11; ++relay) // Turn motors off&#xA;    digitalWrite(relay, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-05-21T06:28:25.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12038" PostTypeId="2" ParentId="12032" CreationDate="2015-05-21T07:29:45.540" Score="1" Body="&lt;p&gt;Use 1 relay, more precisely a DPST (Double pole, single throw) type. You'll only need 1 signal to drive both, and be sure that both lines are switched off. Electrical installation regulations require double throw relays/switches for certain applications, e.g. in wet rooms like bathrooms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that relays are more delicate devices than they appear to be. A 16A relay may not always be suitable for switching 16A. They have to be &lt;strong&gt;derated&lt;/strong&gt; according to their type of load. And that is almost everything. Not only for capacitive or inductive loads you'll have to limit the current to a fraction of the rated 16A, but even for incandescent lighting (due to the high current peak when switching on). See the manufacturer's datasheet or application documents for the amount of derating.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-05-21T09:22:37.810" LastActivityDate="2015-05-21T09:22:37.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12040" PostTypeId="1" AcceptedAnswerId="12042" CreationDate="2015-05-21T08:35:59.953" Score="1" ViewCount="1161" Body="&lt;p&gt;Hi we are using an Arduino Micro and working with a Bluetooth device and a Rfid Scanner from Sparkfun(ID-20 LA). For that we implemented 2 SoftwareSerial objects and the Serial port for the Serial Monitor. If we use one SoftwareSerial object and the normal Serial everything works fine. For example we can send and receive things over Bluetooth. But when adding another SoftwareSerial object( Rfid then ) One of them doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with the Rfid SoftwareSerial ends up to the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We've also already tried to change the ports and so one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every help is appreciated.&#xA;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Code ( this is already the third programm nothing has changed )&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial rf(11, 12);&#xA;SoftwareSerial bt(8,9);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  rf.begin(9600);&#xA;  bt.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available())&#xA;  {&#xA;   while(Serial.available())&#xA;     Serial.write(Serial.read());&#xA;&#xA;   Serial.println(&quot;&quot;); &#xA;  }&#xA;&#xA;  if(rf.available())&#xA;  {&#xA;   while(rf.available())&#xA;     Serial.write(rf.read());&#xA;&#xA;   Serial.println(&quot;&quot;); &#xA;  }&#xA;&#xA;  if(bt.available())&#xA;  {&#xA;   while(bt.available())&#xA;     Serial.write(bt.read());&#xA;&#xA;   Serial.println(&quot;&quot;); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10199" LastActivityDate="2015-05-21T09:06:30.190" Title="SoftwareSerial problems" Tags="|serial|bluetooth|communication|softwareserial|arduino-micro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12041" PostTypeId="2" ParentId="12040" CreationDate="2015-05-21T09:04:11.493" Score="0" Body="&lt;p&gt;Under the known limitations in the &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;SoftwareSerial&lt;/code&gt; documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If using multiple software serial ports, only one can receive data at a time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's still possible to use multiple instances of &lt;code&gt;SoftwareSerial&lt;/code&gt;. However, when you want to use a specific one, you need to call the &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerialListen&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;listen()&lt;/code&gt;&lt;/a&gt; member function. This will allow it to receive data until you call that function on a different instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One very important thing to understand is that data is not queued in the background. If information arrives while a SoftwareSerial port is not listening, it simply gets discarded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be alternative software serial libraries which suit your needs, depending on how they use interrupts. Alternatively, you could use a different Arduino which has multiple hardware serial ports (such as the Mega).&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-05-21T09:04:11.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12042" PostTypeId="2" ParentId="12040" CreationDate="2015-05-21T09:06:30.190" Score="3" Body="&lt;p&gt;Taken from &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/SoftwareSerial&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Limitations&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library has the following known limitations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If using multiple software serial ports, only one can receive data at a time. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If your project requires simultaneous data flows, see Paul Stoffregen's AltSoftSerial library. &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt; overcomes a number of other issues with the core SoftwareSerial, but has it's own limitations. Refer to the AltSoftSerial site for more information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at SoftwareSerial's code, you'll understand the limitation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* static */&#xA;inline void SoftwareSerial::handle_interrupt()&#xA;{&#xA;  if (active_object)&#xA;  {&#xA;    active_object-&amp;gt;recv();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, the code waits for an interrupt to detect state changes on the pin, and directs it to the &quot;active&quot; serial object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastActivityDate="2015-05-21T09:06:30.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12043" PostTypeId="5" CreationDate="2015-05-21T09:45:03.270" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow&quot;&gt;Teensy&lt;/a&gt; is a cheap and powerful development board with some Arduino compatibility. Through its teensyduino compability module, it can be programmed from Arduino IDE and use most of Arduino base code. Teensyduino replicates Arduino APIs, and many Arduino libraries can run on the Teensy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Teensy 3 has much more power than most Arduino with a 32bits cortex-M4 (K20) processor, 64KB of RAM, 3 UARTs (hardware Serial) + 1 separated for USB, I2S, DMA SPI, multiple ADCs, etc... The Arduino compatibily offers a smooth migration path for a project started on an Arduino but needing a more beefy controller.&lt;/p&gt;&#xA;" OwnerUserId="1155" LastEditorUserId="1155" LastEditDate="2015-05-26T21:11:53.327" LastActivityDate="2015-05-26T21:11:53.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12044" PostTypeId="4" CreationDate="2015-05-21T09:45:03.270" Score="0" Body="Teensy is a cheap and powerful development board with some Arduino compatibility. " OwnerUserId="1155" LastEditorUserId="1155" LastEditDate="2015-05-22T12:43:05.750" LastActivityDate="2015-05-22T12:43:05.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12045" PostTypeId="1" AcceptedAnswerId="12680" CreationDate="2015-05-21T09:48:04.183" Score="3" ViewCount="15189" Body="&lt;p&gt;I have been trying to make my two Nrf24L01 wireless model work for few days now, to do so I follow the tutorial in the following link. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the link exactly, i changed nothing, expect i didn't add the bypass capacitor , as they said it will improve the performance and reduce heat, however mine is not working at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is a pictures of my hardware setup ,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L5eu9.jpg&quot; alt=&quot;arduino setup&quot;&gt;&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/YsFHC.jpg&quot; alt=&quot;anther picture for the setup&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/KRdBz.jpg&quot; alt=&quot;my whole setup&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/o8wjR.jpg&quot; alt=&quot;nrf24L01 model&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for the code i didnt change any this from the tutorial but i will past it to make it easy to follow Transmitting code  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /* YourDuinoStarter Example: nRF24L01 Transmit Joystick values&#xA; - WHAT IT DOES: Reads Analog values on A0, A1 and transmits&#xA; them over a nRF24L01 Radio Link to another transceiver.&#xA; - SEE the comments after &quot;//&quot; on each line below&#xA; - CONNECTIONS: nRF24L01 Modules See:&#xA; http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&#xA; 1 - GND&#xA; 2 - VCC 3.3V !!! NOT 5V&#xA; 3 - CE to Arduino pin 9&#xA; 4 - CSN to Arduino pin 10&#xA; 5 - SCK to Arduino pin 13&#xA; 6 - MOSI to Arduino pin 11&#xA; 7 - MISO to Arduino pin 12&#xA; 8 - UNUSED&#xA; - &#xA; Analog Joystick or two 10K potentiometers:&#xA; GND to Arduino GND&#xA; VCC to Arduino +5V&#xA; X Pot to Arduino A0&#xA; Y Pot to Arduino A1&#xA;&#xA; - V1.00 11/26/13&#xA; Based on examples at http://www.bajdi.com/&#xA; Questions: terry@yourduino.com */&#xA;&#xA; /*-----( Import needed libraries )-----*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;/*-----( Declare Constants and Pin Numbers )-----*/&#xA;#define CE_PIN   9&#xA;#define CSN_PIN 10&#xA;#define JOYSTICK_X A0&#xA;#define JOYSTICK_Y A1&#xA;&#xA;// NOTE: the &quot;LL&quot; at the end of the constant is &quot;LongLong&quot; type&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe&#xA;&#xA;&#xA;/*-----( Declare objects )-----*/&#xA;RF24 radio(CE_PIN, CSN_PIN); // Create a Radio&#xA;/*-----( Declare Variables )-----*/&#xA;int joystick[2];  // 2 element array holding Joystick readings&#xA;&#xA;void setup()   /****** SETUP: RUNS ONCE ******/&#xA;{&#xA;  Serial.begin(9600);&#xA;  radio.begin();&#xA;  radio.openWritingPipe(pipe);&#xA; }//--(end setup )---&#xA;&#xA;&#xA; void loop()   /****** LOOP: RUNS CONSTANTLY ******/&#xA; {&#xA;  joystick[0] = analogRead(JOYSTICK_X);&#xA;  joystick[1] = analogRead(JOYSTICK_Y);&#xA;&#xA;   radio.write( joystick, sizeof(joystick) );&#xA;&#xA;   }//--(end main loop )---&#xA;&#xA;  /*-----( Declare User-written Functions )-----*/&#xA;&#xA;  //NONE&#xA;  //*********( THE END )***********&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiving code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* YourDuinoStarter Example: nRF24L01 Receive Joystick values&#xA;&#xA; - WHAT IT DOES: Receives data from another transceiver with&#xA;   2 Analog values from a Joystick or 2 Potentiometers&#xA;   Displays received values on Serial Monitor&#xA; - SEE the comments after &quot;//&quot; on each line below&#xA; - CONNECTIONS: nRF24L01 Modules See:&#xA; http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&#xA;   1 - GND&#xA;   2 - VCC 3.3V !!! NOT 5V&#xA;   3 - CE to Arduino pin 9&#xA;   4 - CSN to Arduino pin 10&#xA;   5 - SCK to Arduino pin 13&#xA;   6 - MOSI to Arduino pin 11&#xA;   7 - MISO to Arduino pin 12&#xA;   8 - UNUSED&#xA;&#xA; - V1.00 11/26/13&#xA;   Based on examples at http://www.bajdi.com/&#xA;   Questions: terry@yourduino.com */&#xA;&#xA;/*-----( Import needed libraries )-----*/&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;/*-----( Declare Constants and Pin Numbers )-----*/&#xA;#define CE_PIN   9&#xA;#define CSN_PIN 10&#xA;&#xA;// NOTE: the &quot;LL&quot; at the end of the constant is &quot;LongLong&quot; type&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe&#xA;&#xA;&#xA;/*-----( Declare objects )-----*/&#xA;RF24 radio(CE_PIN, CSN_PIN); // Create a Radio&#xA;/*-----( Declare Variables )-----*/&#xA;int joystick[2];  // 2 element array holding Joystick readings&#xA;&#xA;void setup()   /****** SETUP: RUNS ONCE ******/&#xA;{&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;  Serial.println(&quot;Nrf24L01 Receiver Starting&quot;);&#xA;  radio.begin();&#xA;  radio.openReadingPipe(1,pipe);&#xA;  radio.startListening();;&#xA;}//--(end setup )---&#xA;&#xA;&#xA;void loop()   /****** LOOP: RUNS CONSTANTLY ******/&#xA;{&#xA;  if ( radio.available() )&#xA;  {&#xA;    // Read the data payload until we've received everything&#xA;    bool done = false;&#xA;    while (!done)&#xA;    {&#xA;      // Fetch the data payload&#xA;      done = radio.read( joystick, sizeof(joystick) );&#xA;      Serial.print(&quot;X = &quot;);&#xA;      Serial.print(joystick[0]);&#xA;      Serial.print(&quot; Y = &quot;);      &#xA;      Serial.println(joystick[1]);&#xA;    }&#xA;  }&#xA;  else&#xA;  {    &#xA;      Serial.println(&quot;No radio available&quot;);&#xA;  }&#xA;&#xA;}//--(end main loop )---&#xA;&#xA;/*-----( Declare User-written Functions )-----*/&#xA;&#xA;//NONE&#xA;//*********( THE END )***********&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output result on the serial is No radio available &lt;/p&gt;&#xA;&#xA;&lt;p&gt;dose anyone know where i can go from here ?&#xA;or how i can debuge such a problem ? &#xA;i dont even know if the problem is with the sender or receiver or both of them &lt;/p&gt;&#xA;" OwnerUserId="10208" LastActivityDate="2016-06-18T16:10:02.240" Title="Not able to make my NrF24L01 work" Tags="|nrf24l01+|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12046" PostTypeId="1" AcceptedAnswerId="12047" CreationDate="2015-05-21T12:20:48.123" Score="0" ViewCount="731" Body="&lt;p&gt;I found a lot of methods on the internet and I was wondering what would be the best method to send data from sensors connected to Arduino to a MySQL database in a WAMP server continuously.&lt;/p&gt;&#xA;" OwnerUserId="9972" LastEditorUserId="4628" LastEditDate="2017-05-26T11:13:56.057" LastActivityDate="2017-05-26T11:13:56.057" Title="Arduino to mysql database?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ClosedDate="2015-05-23T20:14:01.707" ContentLicense="CC BY-SA 3.0" />
  <row Id="12047" PostTypeId="2" ParentId="12046" CreationDate="2015-05-21T12:34:45.620" Score="2" Body="&lt;p&gt;There is no absolute &quot;best&quot; way, there is only the way that &quot;works best for your situation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a nutshell, the different methods that I can think of, and their pros and cons, are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple HTTP GET with parameters&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Quick to implement, light weight, but not very secure or robust. Perfectly fine for things like &quot;send the temperature once a minute&quot; etc, but crafting very long GET requests with lots of parameters can severely impact on both your RAM and your sanity.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;HTTP POST request&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Like the GET request it's fairly simple to implement, but needs more RAM since you need to know the size of the data you're sending first so you can send a &lt;code&gt;Content-length&lt;/code&gt; header.  You can send much more that way though, assuming you have the resources for it.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SOAP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is basically HTTP POST but with a specially XML formatted body.  It has the advantage that it's a standard protocol for transferring data and commands around the place, so there are plenty of resources to help you.  The main problem is crafting the XML at the Arduino side.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Custom TCP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Connect to a special port to communicate with your own software.  You define all of the protocol, but you have to write all (or most) of the software too.  This can be more like a serial connection to your computer but through the network.  Good for sending larger amounts of data, such as images from a camera, etc.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Custom UDP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to send lots of small values very frequently this is probably the best bet.  Harder to implement than most of the others, but the light-weight nature of UDP means you can send data much more rapidly.  Of course, with UDP, you run the risk of losing packets since it's very much a &quot;fire and forget&quot; protocol - you send a packet and hope it gets there.  Fine if you don't mind missing the odd bit of data, say for higher speed temperature logging.  Of course, you have to write the server side software yourself, but there's plenty of resources to help you with that online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's really not a case of &quot;best&quot; but &quot;most suitable&quot;.  Define what the data is and how often you want to send it, then think about how complex you are willing to get with your programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nine times out of ten a simple HTTP GET request fits the bill.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-21T12:34:45.620" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="12048" PostTypeId="1" AcceptedAnswerId="12050" CreationDate="2015-05-21T12:38:14.820" Score="4" ViewCount="296" Body="&lt;p&gt;I am developing AVR microcontollers in Atmle Studio and sometimes I am using Arduino libraries(such as LiquidCrystal). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I initialize &lt;code&gt;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&lt;/code&gt; I don't think Arduino Libraries use registers and ports of ATmega2560, although I am building my code with the device selection ATmega2560 option of Atmel Studio. Atmel Studio works in order to program 2560 but how can I tell Arduino libraries that I am using 2560?&lt;/p&gt;&#xA;" OwnerUserId="1052" LastActivityDate="2015-05-21T13:59:00.420" Title="How can I indicate that I am using ATmega2560 so that Arduino libraries understand it?" Tags="|arduino-mega|avr|atmel-studio|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12050" PostTypeId="2" ParentId="12048" CreationDate="2015-05-21T13:59:00.420" Score="2" Body="&lt;p&gt;There are two things that have to be considered here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is telling the code what board you are using, so it can compile in the right optional parts, and the other is getting the right pin mappings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first can be covered simply with a compilation flag:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DARDUINO_MEGA2560&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That defines the macro &lt;code&gt;ARDUINO_MEGA2560&lt;/code&gt; which is used in some places to know which board you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second is the pin mappings.  These are stored in the file &lt;code&gt;pins_arduino.h&lt;/code&gt; and each board variant has its own copy.  You need to ensure that this file (and be sure to get the right one) is included in your code in the right places to ensure that the pins can be mapped right.  If you are including the whole Arduino core (which it sounds like you must be in order for things to even have a hope of working) then you just need to ensure that you have the compiler set up to include the right copy of the &lt;code&gt;pins_arduino.h&lt;/code&gt; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means making sure you have an include path in your compile command line which points to where the &lt;code&gt;pins_arduino.h&lt;/code&gt; file is before anything else Arduino core related.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-IC:\Path\to\arduino\mega2560\variant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-I/path/to/arduino/mega2560/variant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-21T13:59:00.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12051" PostTypeId="2" ParentId="12002" CreationDate="2015-05-21T14:38:56.320" Score="0" Body="&lt;p&gt;&lt;strong&gt;Basically it would require another bootloader.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to check this out: &#xA;&lt;a href=&quot;http://playground.arduino.cc/Code/TFTPBootloader1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/TFTPBootloader1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Programming through serial&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have the intention to advertise a product, but I worked with an Lantronix xport which was able to receive serial information (or a telnet session) over ethernet. You might want to look into cheaper models of other manufacturers (that do not use modem like commands) you should look for ethernet to serial converters.&#xA;It should be compatible  with: &lt;a href=&quot;http://blog.solutions-cubed.com/programming-the-arduino-uno-with-a-serial-port/&quot; rel=&quot;nofollow&quot;&gt;http://blog.solutions-cubed.com/programming-the-arduino-uno-with-a-serial-port/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You might also connect to another PC over ethernet which then programs the arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would require another PC, but can be fairly easy to set up, but cumbersome to use. You could use teamviewer or another remote desktop. Find a way to send your code (or completely program it at the other pc) and then execute the program command. You might even check if it's possible to use an raspberry PI instead of a full PC (always wanted to try this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Use an arduino to program your arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might use an arduino that receives code and then uploads it to another arduino. Not sure how that works out. Or how to get the code on the first arduino. Should work fine if you've got something like a modificated arduino webserver running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also details on programming arduino can be found here:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-05-21T14:38:56.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12052" PostTypeId="2" ParentId="12017" CreationDate="2015-05-21T15:12:40.910" Score="1" Body="&lt;p&gt;What you said has happened to me before.This happened to me as I supplied over 20v to the arduino.Did you supply a higher voltage than recommended or pull too many amps from the board?If you did so,it is almost futile to try to repair it.&lt;/p&gt;&#xA;" OwnerUserId="10220" LastActivityDate="2015-05-21T15:12:40.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12054" PostTypeId="1" AcceptedAnswerId="12055" CreationDate="2015-05-21T18:32:54.317" Score="0" ViewCount="68" Body="&lt;p&gt;I am trying to use a Raspberry Pi to control a ESC and for that I am sending the instructions for the ESC using serial. My problem is that when i send the instructions i can not interoperate them, and by interoperate I mean check what the first letter is and then remove it and make the Arduino output a PWM signal. My problem is when I use the serial monitor to send an instruction it firstly comes up on several lines, and when I try and look at the first letter of the string the if statement thinks it is true for all inputs of &quot;FirstLetter&quot; my function to get the serial input it &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String readSerial()&#xA;{&#xA;  char SerialInput;&#xA;  String Data = &quot;&quot;;&#xA;  if (Serial.available())&#xA;  {&#xA;    SerialInput = Serial.read();&#xA;    Data.concat(SerialInput);&#xA;    //Serial.println(Data);&#xA;  }&#xA;  return Data;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the function that should interoperate  the information from readSerial() is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void DecodeInput()&#xA;{&#xA;  String input = readSerial();&#xA;  if (input != &quot;&quot;)&#xA;  {&#xA;    char FirstLetter = input.charAt(1);&#xA;    if (FirstLetter = 'U')&#xA;    {&#xA;      Serial.println(&quot;Hello World&quot;);&#xA;      //input.setCharAt[0, '');&#xA;      //SetPower('U', Power);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7790" LastEditorUserId="2881" LastEditDate="2015-05-21T18:40:37.310" LastActivityDate="2015-05-21T18:53:25.317" Title="Reading and interpreting Serial information" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12055" PostTypeId="2" ParentId="12054" CreationDate="2015-05-21T18:39:44.383" Score="1" Body="&lt;p&gt;Two things immediately jump out at me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char FirstLetter = input.charAt(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;charAt(1) is the &lt;em&gt;second&lt;/em&gt; letter, not the first - the first is charAt(0).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (FirstLetter = 'U')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is saying &quot;If I have been successful in assigning the value 'U' to FirstLetter then...&quot; - &quot;=&quot; is assignment, you need &quot;==&quot; for comparison.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also your &lt;code&gt;readSerial()&lt;/code&gt; function is complete junk.  It's not doing anything at all like you think it is.  You should read this to better understand Arduino serial reading: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-21T18:39:44.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12056" PostTypeId="2" ParentId="12054" CreationDate="2015-05-21T18:53:25.317" Score="0" Body="&lt;p&gt;You may want to look at the Firmata protocol, and not re-invent the wheel. Although doing so (re-inventing the wheel) is a good learning exercise, so is understanding something already written.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/Firmata&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Reference/Firmata&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then move on to the &lt;a href=&quot;http://cylonjs.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;cool stuff&lt;/a&gt; that uses it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZlA4M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-21T18:53:25.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12057" PostTypeId="2" ParentId="11941" CreationDate="2015-05-21T21:36:05.690" Score="0" Body="&lt;p&gt;If you're open to a off-chip solution, it isn't too difficult to buy/build an SD card reader.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-05-21T21:36:05.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12058" PostTypeId="1" CreationDate="2015-05-22T03:09:04.553" Score="1" ViewCount="2619" Body="&lt;p&gt;I am using an encoder motor for one of my projects and i was reading encoder values manually through Arduino. It was working fine when i turned it slowly, but whenever i would rotate it at some higher speed, data input to the arduino would stop. I am using the encoder at 4 x. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody help me with some code to read the data from encoder faster.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int pulses, A_SIG=0, B_SIG=1;&#xA;&#xA;void setup(){&#xA;  attachInterrupt(0, A_RISE, RISING);&#xA;  attachInterrupt(1, B_RISE, RISING);&#xA;  Serial.begin(115200);&#xA;}//setup&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;void A_RISE(){&#xA; detachInterrupt(0);&#xA; A_SIG=1;&#xA;&#xA; if(B_SIG==0)&#xA;  pulses++;//moving forward&#xA; if(B_SIG==1)&#xA;  pulses--;//moving reverse&#xA; Serial.println(pulses);&#xA; attachInterrupt(0, A_FALL, FALLING);&#xA;}&#xA;&#xA;void A_FALL(){&#xA;  detachInterrupt(0);&#xA; A_SIG=0;&#xA;&#xA; if(B_SIG==1)&#xA;    pulses++;//moving forward&#xA; if(B_SIG==0)&#xA;     pulses--;//moving reverse&#xA; Serial.println(pulses);&#xA; attachInterrupt(0, A_RISE, RISING);  &#xA;}&#xA;&#xA;void B_RISE(){&#xA;  detachInterrupt(1);&#xA;  B_SIG=1;&#xA;&#xA;  if(A_SIG==1)&#xA;     pulses++;//moving forward&#xA;  if(A_SIG==0)&#xA;      pulses--;//moving reverse&#xA;  Serial.println(pulses);&#xA;  attachInterrupt(1, B_FALL, FALLING);&#xA;}&#xA;&#xA; void B_FALL(){&#xA;    detachInterrupt(1);&#xA;    B_SIG=0;&#xA;&#xA;    if(A_SIG==0)&#xA;       pulses++;//moving forward&#xA;    if(A_SIG==1)&#xA;       pulses--;//moving reverse&#xA;    Serial.println(pulses);&#xA;    attachInterrupt(1, B_RISE, RISING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6745" LastEditorUserId="6745" LastEditDate="2015-05-22T12:03:28.907" LastActivityDate="2015-07-28T01:17:19.003" Title="Reading quadrature encoder" Tags="|arduino-uno|motor|rotary-encoder|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12059" PostTypeId="1" AcceptedAnswerId="12061" CreationDate="2015-05-22T01:04:05.070" Score="2" ViewCount="285" Body="&lt;p&gt;I want to make a large clock, 16 inch x 7.5 inch, which will display dd Month yyyy.&#xA;What would be the best way to do this?&#xA;Does Arduino have a built in clock, and I'd just need logic to turn on/off LEDs on a display that already has dd Month yyyy? Do such displays exist which I can connect to Arduino?&lt;/p&gt;&#xA;" OwnerUserId="66119" OwnerDisplayName="Backwards_Dave" LastActivityDate="2015-05-22T07:54:49.753" Title="Creating a clock using Arduino" Tags="|rtc|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12060" PostTypeId="2" ParentId="12059" CreationDate="2015-05-22T01:17:34.933" Score="1" Body="&lt;p&gt;Usually displays with pre-determined shapes for numbers and/or letters are LCD or quite specific parts.&#xA;It's entirely doable to just use standard Alpha-Numeric LED displays, there's many tutorials and explanations to be found, if that's something you think you need, you can ask more directly towards that and many of us will probably be happy to explain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino has its own little clock frequency. Most are probably powered by some manner of crystal making them quite accurate. Some may have an actual watch crystal running some kind of real-time timer/clock. These matters are device dependent and cannot be answered by me, as I never used an Arduino.&#xA;In the basis every Atmel (the controller brand Arduinos use) can be used to maintain a clock and calendar, even the Tiny10 can, given a stable enough external clock source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On most simpler Atmels (and as such simpler Arduinos) you will have to maintain the numbers and how they translate to the displays yourself, that last part especially if you want your own design in the display. But you'll probably be able to get a reasonably accurate pulse that you can use to update the values with the right interval. &#xA;On the larger/more complex chips and/or Arduinos you might get a (near) complete calendar unit that can basically maintain itself and allow you to just read the values. But then those will be more expensive and able to do many, many much cooler things, so that might be a bit of a waste for just a clock and doing the calendar stuff yourself is very good exercise for getting to know the processors you are working with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more assistance you will need to be much more specific about what Arduino/Atmel you are using and exactly what manner of display you want: Are blocky number/letter like those in radio's and alarm clocks okay, or do you want something self-designed or more flowy? Are you willing to actually use a dot-type display and learn to use that (no that hard, to be honest, but very different from segment), allowing you to display anything that fits the dots? Like smiley-like graphics, Chinese characters to some extend, etc.&lt;/p&gt;&#xA;" OwnerUserId="10230" OwnerDisplayName="Asmyldof" LastActivityDate="2015-05-22T01:17:34.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12061" PostTypeId="2" ParentId="12059" CreationDate="2015-05-22T01:52:37.807" Score="1" Body="&lt;p&gt;Presuming you intend to have a more or less standard clock the hardest part of project will be accurate timekeeping. This functionality is generally reffered to as RTC i.e. Real Time Clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is probably best offloaded to a dedicated IC, this provides many benefits. The foremost is that small inexpensive modules can be bought that include, a reasonably accurate crystal, the timekeeping IC and a backup battery, so your clock doesn't forget the time when unplugged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good place to get started would be &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_DS1307RTC.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; it goes over using one such chip to get the time (and date).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there you can apply your own creativity for the clock interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible option is making a &lt;a href=&quot;http://www.instructables.com/id/My-Arduino-WordClock/&quot; rel=&quot;nofollow&quot;&gt;wordclock&lt;/a&gt; interface but setup for dates.&lt;/p&gt;&#xA;" OwnerUserId="21300" OwnerDisplayName="Hugoagogo" LastActivityDate="2015-05-22T01:52:37.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12062" PostTypeId="2" ParentId="11951" CreationDate="2015-05-22T03:59:46.723" Score="0" Body="&lt;p&gt;If you aren't getting the expected result, as JRobert suggested you should look at your hardware. Ensure pull-ups/downs are being used correctly, your interpretation of your hardware's logic is correct (positive/negative logic), and maybe even use a simple sketch to check that everything is working correctly. Firstly I would simplify the control function. You could try replacing the OR with a bitwise OR, or changing your variables to booleans. Realistically, more code and a diagram illustrating your implementation would help us reproduce and troubleshoot this with you. I'm a little confused as to whether pins 10 &amp;amp; 11 are LEDs or Buttons. I would be happy to help you get a test program together if you can provide more detail. :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void control()&#xA;{&#xA;    boolean task1 = digitalRead(led1);&#xA;    boolean task2 = digitalRead(led2);&#xA;&#xA;    // Note that the if isn't needed&#xA;    digitalWrite(led3, (task1 || task2));&#xA;&#xA;    // If your buttons use negative logic&#xA;    // digitalWrite(led3, (!task1 || !task2));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For humour-sake when I hit a problem that doesn't make sense, I rework my logic to break down the problem and output in stages, or use the Serial library to output what is going on periodically. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Reference&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.ladyada.net/learn/arduino/lesson4.html&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Tutorial&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Typically for inputs and outputs I define a structure which buffers everything per IO, and write my code with a loop-based mentality, much like how a game loop is implemented in video games. It is easy to print and trace when troubleshooting, and the positive/negative/default-state logic is abstracted. This will help you get started if you are curious.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://rbwhitaker.wikidot.com/the-game-loop&quot; rel=&quot;nofollow&quot;&gt;Game Loop Example&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10007" LastActivityDate="2015-05-22T03:59:46.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12063" PostTypeId="2" ParentId="12059" CreationDate="2015-05-22T04:38:54.063" Score="0" Body="&lt;p&gt;It is possible to use the RTC. Another option is to use the Arduino Yun. This has a OpenWRT (Linux) running alongside the Atmel and is a little bit more expensive than the cosyt of the RTC and an Arduino. However, you can query the Linux side for the time with the Arduino command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String GetDateAndTime (void) {&#xA;  Process time;&#xA;  String junkString = &quot;&quot;;&#xA;  time.runShellCommand(&quot;date +\&quot;%F %T\&quot;&quot;);&#xA;  while(time.available()) {&#xA;    char c = time.read();&#xA;    junkString += c;&#xA;  }&#xA;  junkString = junkString.substring(0,junkString.length()-1);&#xA;  return(junkString);&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can update the Linux clock periodically using the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**************************************************************************/&#xA;// Update Clock on the OpenWRT Side using NTP&#xA;// command kinda swiped from:&#xA;// http://karlduino.wordpress.com/2014/01/14/set-clock-on-arduino-yun/&#xA;void forceNTPUpdate()&#xA;{&#xA;  Process date;&#xA;  String junkString;&#xA;  date.runShellCommand(&quot;ntpd -qn -p 0.pool.ntp.org&quot;);&#xA;  junkString = &quot;&quot;;&#xA;  while(date.available()) {&#xA;    char c = date.read();&#xA;    junkString += c;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update the clock when the code starts to set the time and update as needed  to keep things as accurate as you like.&lt;/p&gt;&#xA;" OwnerUserId="8142" LastActivityDate="2015-05-22T04:38:54.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12064" PostTypeId="2" ParentId="12058" CreationDate="2015-05-22T05:12:44.110" Score="1" Body="&lt;pre&gt;&lt;code&gt;volatile long rawTacho[2];      // interrupt 0 &amp;amp; 1 tachometers&#xA;&#xA;ISR(MotorISR1)&#xA;{&#xA;    int b = digitalReadFast(8);&#xA;    if (digitalReadFast(2))&#xA;        b ? rawTacho[0]-- : rawTacho[0]++;&#xA;    else&#xA;        b ? rawTacho[0]++ : rawTacho[0]--;&#xA;}&#xA;&#xA;ISR(MotorISR2)&#xA;{&#xA;    int b = digitalReadFast(9);&#xA;    if (digitalReadFast(3))&#xA;        b ? rawTacho[1]-- : rawTacho[1]++;&#xA;    else&#xA;       b ? rawTacho[1]++ : rawTacho[1]--;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(2, INPUT_PULLUP);&#xA;    pinMode(3, INPUT_PULLUP);&#xA;    pinMode(8, INPUT_PULLUP);&#xA;    pinMode(9, INPUT_PULLUP);&#xA;&#xA;   attachInterrupt(PCINT0, MotorISR1, CHANGE);  // pin 2&#xA;   attachInterrupt(PCINT1, MotorISR2, CHANGE); // pin 3&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;something similar to that - it was extracted from bigger code so you will have read it and understand it as opposed to copy paste.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update note: This is not complete in a pure form - the cpu doesnt tell you what pin had an interrupt - thus some underlying Arduino code figures that out for me, but it is fairly efficient, and I used it as is. Also if it is not obvious, this is reading encoders from 2 motors. 1 interrupt is assigned to each motor, the second phase of each is on a non-interrupt pin. Never lost a reading to my knowledge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with your code is probably the print in the interrupt as pointed out in a comment.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-05-22T14:37:26.410" LastActivityDate="2015-05-22T14:37:26.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12065" PostTypeId="2" ParentId="12059" CreationDate="2015-05-22T07:54:49.753" Score="1" Body="&lt;p&gt;If you are willing to go the “barebones” route, you can turn an&#xA;ATmega328P (the MCU at the heart of the Arduino Uno) into a very&#xA;accurate RTC by hooking a watch crystal to it's clock pins. Given proper&#xA;calibration, you can get an accuracy of &lt;strong&gt;a few seconds per year&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would require some coding though, and is not as straightforward as&#xA;using an off-the-shelf RTC. C.f.&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/a/9039&quot;&gt;this answer&lt;/a&gt; for the details.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-05-22T07:54:49.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12067" PostTypeId="1" AcceptedAnswerId="12068" CreationDate="2015-05-22T08:27:15.477" Score="0" ViewCount="770" Body="&lt;p&gt;I wrote a simple code on lillypad with fdti module as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;Serial.begin(57600);&#xA;}&#xA;void loop(){&#xA; Serial.println(&quot;ddd&quot;);&#xA; delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it gives wrong characters at serial port window of arduino ide at 57600 baudrate. But I changed baudrate to 115200 at same window it gives right string as &quot;ddd&quot;. Other baudrates do the same thing. What is the solution or where is the problem. I couldnt understand why baudrate shift occurs&lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-05-22T09:37:01.980" Title="lilypad works with wrong baudrate" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12068" PostTypeId="2" ParentId="12067" CreationDate="2015-05-22T09:37:01.980" Score="3" Body="&lt;p&gt;The baud rate shift occurs because of a mismatch between the speed your program thinks the chip is running at and the speed the chip is actually running at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also have noticed that &lt;code&gt;delay(500)&lt;/code&gt; is too fast and actually lasts as long as &lt;code&gt;delay(250)&lt;/code&gt; would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the numbers involved it looks like the board is running twice as fast (115200 / 57600 = 2) as your board definition says it is - maybe you're using an 8MHz definition for a 16MHz board, or a 1MHz definition for a 2MHz board, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you have the right board definition selected in the IDE for your board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-22T09:37:01.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12069" PostTypeId="2" ParentId="4092" CreationDate="2015-05-22T10:17:55.167" Score="1" Body="&lt;p&gt;I've got the same problem on my Ubuntu.&#xA;Eventually, I was stuck at every uploading, even after unplugging+replugging the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Killing all avrdude process, remove the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo killall avrdude&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or with new IDEs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo killall avrdude_bin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10227" LastActivityDate="2015-05-22T10:17:55.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12070" PostTypeId="1" AcceptedAnswerId="12088" CreationDate="2015-05-22T14:57:19.890" Score="-5" ViewCount="176" Body="&lt;p&gt;Arduino Mega ADK is working well but it is not working circuit in which pull-up/down resistors. It is generating wrong results. I guess, pull-up/down resistors fried. What can i do? &lt;/p&gt;&#xA;" OwnerUserId="10196" LastActivityDate="2015-05-23T08:24:59.150" Title="I guess, pull-up/down resistors fried. What can i do?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="6" ClosedDate="2015-05-23T14:32:39.410" ContentLicense="CC BY-SA 3.0" />
  <row Id="12071" PostTypeId="1" CreationDate="2015-05-22T12:29:01.927" Score="3" ViewCount="6792" Body="&lt;p&gt;Is there any limit on the number of &lt;code&gt;Wire.write()&lt;/code&gt; commands consecutively in between the &lt;code&gt;Wire.beginTransmission()&lt;/code&gt; command and the &lt;code&gt;Wire.endTransmission()&lt;/code&gt; command for the Arduino Wire library?&lt;/p&gt;&#xA;" OwnerUserId="10231" OwnerDisplayName="pascalm" LastEditorUserId="61722" LastEditDate="2022-06-27T23:08:13.583" LastActivityDate="2022-06-27T23:08:13.583" Title="Arduino I2C maximum number of writes per transmisson" Tags="|i2c|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12072" PostTypeId="2" ParentId="12071" CreationDate="2015-05-22T12:42:02.293" Score="1" Body="&lt;p&gt;A quick look at the source code implies that there is a fixed length buffer of 32 bytes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the header file &lt;code&gt;wire.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUFFER_LENGTH 32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And from the implementation of the &lt;code&gt;write&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t TwoWire::write(uint8_t data)&#xA;{&#xA;  if(transmitting){&#xA;  // in master transmitter mode&#xA;    // don't bother if buffer is full&#xA;    if(txBufferLength &amp;gt;= BUFFER_LENGTH){&#xA;      setWriteError();&#xA;      return 0;&#xA;    }&#xA;    // put byte in tx buffer&#xA;    txBuffer[txBufferIndex] = data;&#xA;    ++txBufferIndex;&#xA;    // update amount in buffer   &#xA;    txBufferLength = txBufferIndex;&#xA;  }else{&#xA;  // in slave send mode&#xA;    // reply to master&#xA;    twi_transmit(&amp;amp;data, 1);&#xA;  }&#xA;  return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5063" OwnerDisplayName="Roger Rowland" LastActivityDate="2015-05-22T12:42:02.293" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12073" PostTypeId="1" AcceptedAnswerId="12075" CreationDate="2015-05-22T16:48:06.840" Score="1" ViewCount="1127" Body="&lt;p&gt;I have two Arduino boards and want to make them communicate with each other over serial. The code I have used for the two boards is almost identical.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Every one second the &amp;quot;A&amp;quot; board sends a &amp;quot;ping&amp;quot; message over serial.&lt;/li&gt;&#xA;&lt;li&gt;The &amp;quot;B&amp;quot; board receives the &amp;quot;ping&amp;quot; message and responds with a &amp;quot;pong&amp;quot; one.&lt;/li&gt;&#xA;&lt;li&gt;The &amp;quot;A&amp;quot; board receives the &amp;quot;pong&amp;quot; message and prints it on screen.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Board A - ping code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;String inputString = &amp;quot;&amp;quot;;         &#xA;boolean stringComplete = false;  &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  inputString.reserve(200);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Serial.print(&amp;quot;ping&amp;quot;);&#xA;&#xA;  if (stringComplete) {&#xA;    Serial.println(inputString);&#xA;    inputString = &amp;quot;&amp;quot;;&#xA;    stringComplete = false;&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available()) {&#xA;    char inChar = (char)Serial.read();&#xA;    inputString += inChar;&#xA;    if (inChar == 'g') {&#xA;      stringComplete = true;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Board B - pong code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;String inputString = &amp;quot;&amp;quot;;         &#xA;boolean stringComplete = false;  &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  inputString.reserve(200);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (stringComplete) {&#xA;    Serial.println(&amp;quot;pong&amp;quot;);&#xA;    inputString = &amp;quot;&amp;quot;;&#xA;    stringComplete = false;&#xA;  }&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available()) {&#xA;    char inChar = (char)Serial.read();&#xA;    inputString += inChar;&#xA;    if (inChar == 'g') {&#xA;      stringComplete = true;&#xA;  }&#xA; }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code seems to work, but not exactly as expected. I initiate the serial monitor of the board &amp;quot;A&amp;quot; and expect to see every one second:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;pingpong&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Instead I see this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;pingpong&lt;/p&gt;&#xA;&lt;p&gt;pong&lt;/p&gt;&#xA;&lt;p&gt;pong&lt;/p&gt;&#xA;&lt;p&gt;....&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;which means that the pong message is repeated more than one time per second. But I want the &amp;quot;B&amp;quot; board to transmit the &amp;quot;pong&amp;quot; message only when it receives the &amp;quot;ping&amp;quot; one.&lt;/p&gt;&#xA;&lt;p&gt;Why is this happening? Is there an error in the code? Is there a detail about the serial protocol which escapes me?&lt;/p&gt;&#xA;&lt;p&gt;Any thoughts would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-15T09:33:41.740" Title="ping pong with two Arduinos over serial" Tags="|serial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12074" PostTypeId="2" ParentId="899" CreationDate="2015-05-22T16:55:42.797" Score="0" Body="&lt;p&gt;What happens with your Arduino YUN is that it has an internal clock which sincronizes with a computer (at least this is what I do).&#xA;However I have read that it can be automatically but I could not do that; have you got a probable solution?&lt;/p&gt;&#xA;" OwnerUserId="10234" LastActivityDate="2015-05-22T16:55:42.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12075" PostTypeId="2" ParentId="12073" CreationDate="2015-05-22T17:08:39.387" Score="4" Body="&lt;p&gt;The problem is with your protocol and also with how you are using the serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are using the same serial channel both for your communication protocol &lt;em&gt;and&lt;/em&gt; for the reporting of the results.  What you see the B end sees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So A sends &lt;code&gt;ping&lt;/code&gt;, and when it sees the letter &lt;code&gt;g&lt;/code&gt; it responds with &lt;code&gt;pong&lt;/code&gt;.  You then print that &lt;code&gt;pong&lt;/code&gt; to the serial, so end B sees &lt;code&gt;pong&lt;/code&gt;. It gets the character &lt;code&gt;g&lt;/code&gt; and thinks &quot;That was a ping, I'll respond with a pong&quot;, so it does - it sends &lt;code&gt;pong&lt;/code&gt;, which you then receive and duly print - starting the sequence over yet again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You either need to separate out the communication and the reporting, or make your protocol look for the whole string &quot;ping&quot; so it never inadvertently responds to a &quot;pong&quot; when it shouldn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a good resource about reading serial strings on the Arduino: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-22T17:08:39.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12076" PostTypeId="1" AcceptedAnswerId="12078" CreationDate="2015-05-22T17:28:35.790" Score="1" ViewCount="1792" Body="&lt;p&gt;This is probably a beginner question. You've been warned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently purchased a touchscreen (&lt;a href=&quot;http://www.adafruit.com/products/1651#tutorials&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/1651#tutorials&lt;/a&gt;) specifically because it left so many pins open to work with and I needed to hook up one, possibly two more items to my Arduino. However the touchscreen fits over the Arduino and covers all the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I access the pins that the LCD isn't using?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be specific, I will be adding a Galvanic Skin Sensor on two analog pins. &lt;/p&gt;&#xA;" OwnerUserId="10235" LastActivityDate="2017-07-05T10:39:14.327" Title="2.8&quot; TFT Touchscreen Prohibits Access to Unused Pins" Tags="|arduino-uno|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12077" PostTypeId="2" ParentId="12076" CreationDate="2015-05-22T17:34:28.753" Score="3" Body="&lt;p&gt;Several options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use wires to connect it rather than sticking it directly onto the Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a header extension to lift the display away from the other headers.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use right-angle headers on the other pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-22T17:34:28.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12078" PostTypeId="2" ParentId="12076" CreationDate="2015-05-22T18:05:24.603" Score="1" Body="&lt;p&gt;Dupont jumper cables are your friend. The most useful ones are male-to-female:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zXYaT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can end up with a bit of a tangled mess though when you have a number of shields all side by side.  Not a lot you can do about it though.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-22T18:05:24.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12079" PostTypeId="1" AcceptedAnswerId="14557" CreationDate="2015-05-22T18:30:19.190" Score="1" ViewCount="1592" Body="&lt;p&gt;Is it possible to run Arduino on a &lt;a href=&quot;https://store.particle.io/?product=particle-photon&quot; rel=&quot;nofollow&quot;&gt;Particle Photon&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want complete software control over the device so I can connect it to the internet and do stuff without going through Particle's cloud, logins, etc.&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-08-26T15:01:12.850" Title="Compatibility between Particle Photon and Arduino" Tags="|wifi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12080" PostTypeId="1" CreationDate="2015-05-22T18:39:41.137" Score="3" ViewCount="871" Body="&lt;p&gt;I'm a teacher, working on eliminating some difficulties of Arduino in the name of getting to the fun stuff. Namely, I am building a small Arduino powered device that will collect simple data from sensors like a DHT11, or an accelerometer. That being said, I want to pass simple settings (sample rate, sensor type, etc.) into the device with out reprogramming the board out right. I'm worried I'm over thinking the challenge. Initially, I wanted to pass the settings over serial in Python script, then save the settings to EEPROM and read them when rebooting...but sending strings over serial from Python is proving to be challenging, let alone the EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long term, this will run on an ESP8266 and I'd try to make a simple interface for entering the SSID and password for the Wifi network we want to connect to. Simply plug in the board over USB, run some simple little Python app that asks for SSID, password, maybe sample rate, sensor type and hit configure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an easier way to build a user interface for adjusting variables in code already running on an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="10237" LastActivityDate="2015-05-23T01:50:40.767" Title="Adjusting variables in code without reprogramming?" Tags="|serial|sensors|esp8266|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12081" PostTypeId="2" ParentId="12080" CreationDate="2015-05-22T19:28:13.487" Score="1" Body="&lt;p&gt;Take a look at &lt;a href=&quot;http://www.arduino.cc/en/Reference/Firmata&quot; rel=&quot;nofollow noreferrer&quot;&gt;firmata&lt;/a&gt;, which allows you to remotely set pins.  There are some robotic frameworks built around it such as as &lt;a href=&quot;http://cylonjs.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cylon.JS&lt;/a&gt; that are doing similar things, but you are not over thinking it. If anything probably under thinking it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino programming environment is about as simple as it gets. It would be hard to have something easier.  Perhaps some of the Graphic interfaces like those with a LEGO robotics set would be closer to what you want?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/NWdBb.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-22T19:28:13.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12082" PostTypeId="1" AcceptedAnswerId="12083" CreationDate="2015-05-22T20:30:32.663" Score="1" ViewCount="1657" Body="&lt;p&gt;I've recently bought an Arduino Pro Mini, the 3.3V and 8MHz version. The first time I powered it, using the VCC pin, all worked. But, as soon as I attempt using the RAW pin instead, nothing lights up... Is my regulator broken ? Or is this a typical issue ?&lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2015-05-22T20:39:04.610" Title="Unable to power an Arduino Pro Mini through the RAW pin" Tags="|power|arduino-pro-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12083" PostTypeId="2" ParentId="12082" CreationDate="2015-05-22T20:39:04.610" Score="4" Body="&lt;p&gt;I am not completely familiar with that specific board, but according to the schematic there is a solder jumper which is used to isolate the RAW voltage regulator from the rest of the system &quot;for low power applications&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qoVld.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know off hand if that comes pre-soldered or not, but check it to make sure it is connected, otherwise the RAW input will do nothing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-22T20:39:04.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12084" PostTypeId="2" ParentId="12080" CreationDate="2015-05-22T23:12:39.837" Score="3" Body="&lt;p&gt;If the number of choices is limited (device types, a few selections of sample rate), you might consider a bank or two of DIP switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/y1Qf9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-22T23:12:39.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12085" PostTypeId="2" ParentId="12016" CreationDate="2015-05-23T00:20:05.203" Score="0" Body="&lt;p&gt;The problem is that a 2ms delay is required after setting the ADMUX bits before starting the conversion.  Thank you Majenko for the link.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int readVBG(int _analogReference) {&#xA;  uint8_t low, high;&#xA;  ADMUX = (_analogReference &amp;lt;&amp;lt; 6) | 14;&#xA;  delay(2); // Wait for voltage to settle&#xA;  sbi(ADCSRA, ADSC);&#xA;  while (bit_is_set(ADCSRA, ADSC));&#xA;  low  = ADCL;&#xA;  high = ADCH;&#xA;  return (high &amp;lt;&amp;lt; 8) | low;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code is specifically for the Arduino UNO.  Majenko's link above has #ifdef statements which support other devices.&lt;/p&gt;&#xA;" OwnerUserId="10188" LastActivityDate="2015-05-23T00:20:05.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12086" PostTypeId="2" ParentId="12080" CreationDate="2015-05-23T01:38:53.983" Score="1" Body="&lt;p&gt;To avoid the serial input and hit the ground running; you could add a simple hardware input like a potentiometer, rotary encoder, or push button that cycled through settings. I would use the Arduino Serial Library to make the configuration viewable on a computer in the IDE serial monitor or terminal. As long as you pull up/down the buttons and separate the inputs properly, a push button and rotary encoder would be easy to keep modular so that it could be safely plugged in and unplugged without an issue. You could also make an interactive menu over the serial interface which asks you for each parameter. The simplest way would be to detect a button press in your application which would take you to 'config mode', which prompts the user for input via the serial monitor. Once everything is entered, save to EEPROM and restart.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/StreamReadString&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Streams&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are determined to take the Serial scripted approach for programming, and are having difficulty with Python, you could repost or update your question to include your code and explain where you are having trouble, or use a different language. I prefer C#, because I use it for so many different things (From websites to XBOX games), and it lends itself well to rapid development. Java would be another good choice particularly if you would like to integrate with Android ;). All of these are easy to integrate with a GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you are having difficulty dealing with strings - and don't feel bad about this, strings can be a complex thing because of how they are construed and work. Check out some examples, and re-implement them to suit your application. Try breaking your strings up into characters (which are a byte in size, easy to fit in EEPROM!) and send them byte by byte - this might be simpler.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Csharp/SerialCommsCSharp&quot; rel=&quot;nofollow&quot;&gt;Arduino and C# Communication&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=39811.0&quot; rel=&quot;nofollow&quot;&gt;A better C# Example.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Java&quot; rel=&quot;nofollow&quot;&gt;Arduino and Java Communication&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/interfacing/python&quot; rel=&quot;nofollow&quot;&gt;Arduino and Python Communication&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Saving to EEPROM is trivial and well covered in the Arduino documentation. One thing to keep in mind is that the EEPROM is accessed and used in bytes! What does this mean? - Well, if a larger variable is to be stored, like an int (16 bit on Arduino Uno) it must first be split in half. To do this you would use bit shifting. To give you a quick idea on how this is done, see functions below - note this assumes you only ever save integers to EEPROM (this is in the way I choose to address the memory):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Include EEPROM library&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;// location is an int from 0-511 using Arduino Uno with 1KB of EEPROM&#xA;void SaveValue(unsigned int location, unsigned int value)&#xA;{&#xA;    // Find addresses to store each half of the integer&#xA;    unsigned int saveLocationLower = location * 2;&#xA;    unsigned int saveLocationUpper = saveLocationLower + 1;&#xA;&#xA;    // Split the integer into two parts&#xA;    byte lowerValue = value;&#xA;    byte upperValue = (value &amp;gt;&amp;gt; 8);&#xA;&#xA;    // Save both parts&#xA;    EEPROM.write(saveLocationLower, lowerValue);&#xA;    EEPROM.write(saveLocationUpper, upperValue);&#xA;}&#xA;&#xA;int LoadValue(unsigned int location) &#xA;{&#xA;    // Find both locations to read using same method as above&#xA;    unsigned int saveLocationLower = location * 2;&#xA;    unsigned int saveLocationUpper = saveLocationLower + 1;&#xA;&#xA;    // Read both locations&#xA;    byte lowerValue = EEPROM.read(saveLocationLower);&#xA;    byte upperValue = EEPROM.read(saveLocationUpper);&#xA;&#xA;    // Assemble both halves and return value&#xA;    return lowerValue + (upperValue &amp;lt;&amp;lt; 8);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/EEPROMRead&quot; rel=&quot;nofollow&quot;&gt;Arduino EEPROM Read&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/EEPROMWrite&quot; rel=&quot;nofollow&quot;&gt;Arduino EEPROM Write&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are feeling really outgoing and adventurous, and have good luck with the C# route - you could check out Microsoft's latest Arduino offerings - they are pretty cool. It makes it easy to integrate Arduino devices with Windows 10 and Phone apps. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://ms-iot.github.io/content/GetStarted.htm&quot; rel=&quot;nofollow&quot;&gt;WIndows 10 IOT, Getting Started&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10007" LastEditorUserId="10007" LastEditDate="2015-05-23T01:50:40.767" LastActivityDate="2015-05-23T01:50:40.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12087" PostTypeId="1" AcceptedAnswerId="12093" CreationDate="2015-05-23T08:24:48.583" Score="1" ViewCount="396" Body="&lt;p&gt;Is there a way to use the atmega 32u4 breakout board to make a mp3 player without the mp3 shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/L56Jq.jpg&quot; alt=&quot;atmega 32u4 breakout from adafruit&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10244" LastEditorUserId="2881" LastEditDate="2015-05-23T12:22:28.497" LastActivityDate="2015-05-23T12:30:10.450" Title="How do I make a atmega 32u4 mp3 player?" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="1" ClosedDate="2015-05-23T20:12:07.980" ContentLicense="CC BY-SA 3.0" />
  <row Id="12088" PostTypeId="2" ParentId="12070" CreationDate="2015-05-23T08:24:59.150" Score="1" Body="&lt;p&gt;If you want internal pullup or pulldown resistors on input pins, you can use external ones to do the same job as internal ones if you wish to. Generally, if you use say 100 k Ohms from a pin to V+ or ground then it will act as a pullup or pull down respectively on an input pin, but have much effect on an output pin - which is what you want to happen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is unlikely that 'fried internal resistors is the reason for code not working and, if this is the case, there is probably unknown and unknowable other damage as well. Pull up/down resistors are usually not actually resistors. They are FETs with high Rds_on values that look resistor like when on. Anything that &quot;fries&quot; them has a reasonable prospect of doing other damage as well.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-05-23T08:24:59.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12089" PostTypeId="1" CreationDate="2015-05-23T08:34:58.497" Score="0" ViewCount="87" Body="&lt;p&gt;I created a shield for Arduino on a soldering board. The next step shall be to implement the circuit on a PCB. I'm new to this, so I'd like to know what the basic steps in designing a PCB are. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically, &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What software do I use for this? Is free software sufficient, or do I get substantially more value from a commercial package? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I have a single PCB printed by a commercial provider, or are there minimum quantities? What is the approximate cost for a shield-sized PCB in a small quantity - is it in the tens, or rather in the hundreds of bucks? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of course, any pointers to good tutorials on the Web will be appreciated,  too! &lt;/p&gt;&#xA;" OwnerUserId="9956" LastEditorUserId="9956" LastEditDate="2015-05-23T15:13:11.947" LastActivityDate="2016-07-05T09:14:37.223" Title="What are the basic steps to make a printed circuit board?" Tags="|shields|system-design|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12090" PostTypeId="1" AcceptedAnswerId="12091" CreationDate="2015-05-23T09:02:45.980" Score="0" ViewCount="5274" Body="&lt;p&gt;I've recently purchased an Arduino Pro Mini, 3.3V version. I've planned to use it in a diy remote: I've empty a ps2 remote, just left the buttons, and the board will be inside. The remote will be wireless: I use an xbee, which also fit inside the ps2 controller. To power it, I use a one cell Lipo, which will empower the Arduino and the XBee, here comes my issue: As you've seen, there will be many things an a single ps2 controller, so I try to minimize connections and external components. But, the XBee will take more than the maximum 150mA provided by internal regulator of the Arduino. So, either I use an external regulator, or I directly plug the lipo in the VCC pin if the Arduino. Can the board survive? If the voltage is greater than 3.3V, will it damage the board? &lt;/p&gt;&#xA;" OwnerUserId="8754" LastActivityDate="2023-10-20T14:58:38.313" Title="Powering an Arduino Pro Mini directly from a LiPo" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12091" PostTypeId="2" ParentId="12090" CreationDate="2015-05-23T09:31:41.463" Score="6" Body="&lt;p&gt;The only thing about the 3.3V Pro Mini that is actually 3.3V is the 3.3V regulator.  The main chip (pretty much the only other component) is good for anything from 1.8V up to 5.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running direct from a 3.7V LiPo or Li-Ion will be perfectly fine.  You might want to disconnect or otherwise disable the regulator though to reduce current consumption - the latest Minis have a solder jumper &lt;em&gt;SJ1&lt;/em&gt; for doing just that, but older versions you may want to actually cut the 3.3V OUT pin of the regulator or de-solder it entirely.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-23T09:31:41.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12092" PostTypeId="2" ParentId="12089" CreationDate="2015-05-23T09:38:08.553" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What software do I use for this? Is free software sufficient, or do I get substantially more value from a commercial package? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are plenty of good free ones, or free versions of commercial ones. Use the one that best suits your way of working - they are all different, try some out and find out which you like best.  I use a free one for all my work (but then I am a FOSS junkie).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I have a single PCB printed by a commercial provider, or are there minimum quantities? What is the approximate cost for a shield-sized PCB in a small quantity - is it in the tens, or rather in the hundreds of bucks?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Generally, no.  It'd be just too costly.  There are small quantity houses around though, and I often use iTead for my prototyping, since they will do batches of just 10 boards at a reasonable cost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic steps in designing a PCB though are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Design it as a schematic&lt;/li&gt;&#xA;&lt;li&gt;Lay it out as a PCB design&lt;/li&gt;&#xA;&lt;li&gt;Get a prototype made&lt;/li&gt;&#xA;&lt;li&gt;Build it&lt;/li&gt;&#xA;&lt;li&gt;Correct the mistakes&lt;/li&gt;&#xA;&lt;li&gt;Go back to 3&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you only want one circuit and it is a pretty simple one you might want to give making the PCB yourself a go - it's quite rewarding and if nothing else gives you good insights into PCB design requirements and how best to lay out a PCB and the tracks for a good reliable etch.  If you have a laser printer the &lt;a href=&quot;http://hacking.majenko.co.uk/toner-transfer-etching-part-1-designing-the-circuit&quot; rel=&quot;nofollow&quot;&gt;Toner Transfer&lt;/a&gt; method of home PCB production is good.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-23T09:38:08.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12093" PostTypeId="2" ParentId="12087" CreationDate="2015-05-23T12:30:10.450" Score="1" Body="&lt;p&gt;You don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A basic ATmega lacks the computational (and perhaps memory also) resources for mp3 decoding.  And even if you do decode to a linear PCM format, you do not have a good way to output it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can playback linear PCM data by pulse width modulating a pin, but the limited clock rate will result in limited resolution, and thus poor fidelity.  You will also end up with a low sample rate, making it hard to avoid audible artifacts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation can actually be somewhat better with an ATtiny85 - still no MP3 decoding of course, but you can clock the counter/time block at a higher rate and so playback PWM audio with higher fidelity, provided you are willing to tolerate the inaccuracy of the onboard clock oscillator that may shift your audio frequencies by a small amount.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do MP3, you will need either a more powerful processor (often no more expensive than the one you have, and typically cheaper as a module than anything &quot;-duino&quot;), or else a dedicated function chip to act as a coprocessor for that purpose.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-05-23T12:30:10.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12094" PostTypeId="2" ParentId="12089" CreationDate="2015-05-23T12:33:52.643" Score="2" Body="&lt;p&gt;Software packages are, amongst others&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://fritzing.org/home/&quot; rel=&quot;nofollow&quot;&gt;Fritzing&lt;/a&gt; (more target at beginners)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cadsoftusa.com/download-eagle/freeware/&quot; rel=&quot;nofollow&quot;&gt;Eagle&lt;/a&gt; (free for board of size 100 x 80 mm (4 x 3.2 inches)).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.kicad-pcb.org/display/KICAD/KiCad+EDA+Software+Suite&quot; rel=&quot;nofollow&quot;&gt;KiCad&lt;/a&gt; (open source)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Companies that make you pcb in small quantities are e.g.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;nofollow&quot;&gt;OSHPark&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.seeedstudio.com/service/index.php?r=pcb&quot; rel=&quot;nofollow&quot;&gt;seeedstudio&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://dirtypcbs.com/&quot; rel=&quot;nofollow&quot;&gt;Dirt Cheap Dirty Boards&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I personally create my own double layer PCBs at home. I first started with the toner-transfer method, but now use photo lithography. I etch in Hydrochloric acid and hydrogen-peroxide. I can have a finished board in 1-2 hours, instead of having to wait a week or so. Great learning experience.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-23T12:33:52.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12095" PostTypeId="1" AcceptedAnswerId="12129" CreationDate="2015-05-23T15:08:32.407" Score="0" ViewCount="9426" Body="&lt;p&gt;I want to implement a simple musical keyboard with Arduino using &lt;code&gt;tone()&lt;/code&gt; and &lt;code&gt;noTone()&lt;/code&gt; functions, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The desired behavior is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;While PC and Arduino are connected via USB/Serial...&lt;/li&gt;&#xA;&lt;li&gt;...when I press a key, a corresponding note starts playing...&lt;/li&gt;&#xA;&lt;li&gt;...and if I release that key that note stops playing...&lt;/li&gt;&#xA;&lt;li&gt;...or if I press &lt;em&gt;another&lt;/em&gt; key, another note replaces the former one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, basically, instead of &quot;while key is pressed&quot; logic, I would like to just write a byte to serial when a key is pressed, write nothing while the key is held pressed, and write another byte when that key is released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will be using a Python script in the PC, but examples in other languages, or just using a plain serial monitor, are fine.&lt;/p&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="4628" LastEditDate="2015-05-25T17:03:25.923" LastActivityDate="2015-07-16T02:46:58.867" Title="How to tell Arduino Uno that I pressed or released a key on PC keyboard over serial?" Tags="|arduino-uno|serial|keyboard|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12096" PostTypeId="1" AcceptedAnswerId="12098" CreationDate="2015-05-23T15:12:50.637" Score="0" ViewCount="196" Body="&lt;p&gt;Which pins are the analog and digital pins? I've been searching the internet for an hour and I could get an answer.&lt;/p&gt;&#xA;" OwnerUserId="10244" LastActivityDate="2015-05-23T15:20:10.220" Title="Where are the digital and analog pins for the adafruit atmega 32u4 breakout board?" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12097" PostTypeId="2" ParentId="12095" CreationDate="2015-05-23T15:18:13.903" Score="0" Body="&lt;p&gt;You need to come up with a protocol.  Then you need to write the PC software.  The PC software will monitor the keyboard, and when you press a key it will send a certain signal through the serial port. When you release the key it will send a different signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How you arrange that is entirely up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might implement a protocol that sends something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b4&#xA;c4&#xA;d3&#xA;off&#xA;c3&#xA;f3&#xA;off&#xA;g4&#xA;off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the first letter is the note, the second letter is the octave to play that note in, and the word &quot;off&quot; is to stop playing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a clue (and probably few people here do) how you'd program the PC end in Python.  It most likely depends on what platform you're working on as to what kind of interface you can build.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-23T15:18:13.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12098" PostTypeId="2" ParentId="12096" CreationDate="2015-05-23T15:20:10.220" Score="0" Body="&lt;p&gt;The information is right there on the product page for you. It took be a total of about 4 seconds to find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ladyada.net/products/atmega32u4breakout/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ladyada.net/products/atmega32u4breakout/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/d4NSw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-23T15:20:10.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12099" PostTypeId="2" ParentId="11674" CreationDate="2015-05-23T16:29:36.973" Score="0" Body="&lt;p&gt;The &quot;efuse error&quot;  on burning the bootloader is described in the article you refer to and a solution is given there as well.&#xA;It occurs when the attiny13 is defined in the same group as the attiny25/45/85 as the former has no efuse and the latter do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Giving the attiny13 its own menu entry in the IDE -as described in that article- should solve that.&lt;/p&gt;&#xA;" OwnerUserId="3367" LastActivityDate="2015-05-23T16:29:36.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12100" PostTypeId="2" ParentId="12095" CreationDate="2015-05-23T16:54:05.000" Score="0" Body="&lt;p&gt;It sounds really simple, but as I think about it, the python twist makes it near impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First the simple part.  What you are describing is very close to the MIDI spec. It define a sequence of character for note on/note off events over serial. I'm rusty but it something like this x'90' + chan1..16, note, velocity (3 bytes for note on) and x'80' + chan1..16, note, velocity (3 bytes for note off).  (&lt;a href=&quot;https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;spec&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firmata took that idea, and turned it into a remote arduino protocol, where instead of a note, a pin number is used (eg pin on/pin off) and you could dig into the firmata that is included with Arduino for some ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hard part is the keyboard.  I use a function getch, that I define myself based on whether the script is running on a POSIX host or not (although that is technically inaccurate).  It is described at&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user&quot;&gt;https://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user&lt;/a&gt;&#xA;but unfortunately it only waits for a keystroke and provide no information about a key release. You are going to have to dig deep and probably write some platform specific code, maybe even a C .DLL, to get that kind of interaction in python. Handling key down/up is trivial in any language but python (for windows anyhow, dont know about *nix)&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-05-23T16:54:05.000" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12101" PostTypeId="1" AcceptedAnswerId="12120" CreationDate="2015-05-23T18:37:41.767" Score="2" ViewCount="3775" Body="&lt;p&gt;I want to make a network with arduinos and nrf24l01 chips. The network will be like this: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 master arduino &lt;/li&gt;&#xA;&lt;li&gt;multiple (no specific number) slave nodes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want all nodes to have the same receiving and the same transmitting address and the master arduino to understand which one send the message from the message itself.&#xA;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Master:&lt;/strong&gt; &#xA;Receiving: 0xABCDABCD71&#xA;Transmitting: 0xABCDABCD01&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave 1&lt;/strong&gt;&#xA;Receiving: 0xABCDABCD01&#xA;Transmitting: 0xABCDABCD71&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave 2&lt;/strong&gt;&#xA;Receiving: 0xABCDABCD01&#xA;Transmitting: 0xABCDABCD71&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave 3&lt;/strong&gt;&#xA;Receiving: 0xABCDABCD01&#xA;Transmitting: 0xABCDABCD71&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Slave 4&lt;/strong&gt;&#xA;Receiving: 0xABCDABCD01&#xA;Transmitting: 0xABCDABCD71&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When master send a message, all nodes will receive it.&#xA;What I want to ask is : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is that possible? &lt;/li&gt;&#xA;&lt;li&gt;Will there be any problems? &lt;/li&gt;&#xA;&lt;li&gt;Is there any other way so I can add more nodes in the future without changing the code?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2018-11-13T16:36:46.690" Title="Multiple nodes with the same receiving and transmitting address" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12102" PostTypeId="1" AcceptedAnswerId="12103" CreationDate="2015-05-23T19:53:28.873" Score="-1" ViewCount="89" Body="&lt;p&gt;I recently bought the atmega 32u4 breakout board from adafruit. I uploaded a sketch, then it says that there isn't a timer 2 on it and it won't do as I programmed my sketch. how can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="10244" LastActivityDate="2015-06-22T20:22:30.163" Title="What is wrong with my 32u4 breakout board from adafruit?" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12103" PostTypeId="2" ParentId="12102" CreationDate="2015-05-23T19:56:20.630" Score="0" Body="&lt;p&gt;You will need to port any libraries and code that depend on timer 2 to the '32U4 architecture. There is no way to add timer 2 to the chip, and it is likely that trying to force it to use a different timer won't help since it may configure things the other timer doesn't have.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-23T19:56:20.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12104" PostTypeId="1" CreationDate="2015-05-23T20:17:20.210" Score="3" ViewCount="2944" Body="&lt;p&gt;Few days ago, I built my own custom Arduino on the breadboard. It is built according to tutorial on &lt;a href=&quot;http://www.crash-bang.com/resource/breadboard-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.crash-bang.com/resource/breadboard-arduino/&lt;/a&gt;. The Atmega328P-PU is already burned with the Arduino bootloader with simple blink sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the programmer, I decided to use the Arduino USB2Serial. Again, it is connected as shown on crash-bang site. Problem is I get this error when uploading a different sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -Cavrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:build244630154737317489.tmp/sketch_may23a.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;     Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;     System wide configuration file is &quot;avrdude.conf&quot;&#xA;&#xA;     Using Port                    : COM3&#xA;     Using Programmer              : arduino&#xA;     Overriding Baud Rate          : 115200&#xA;     AVR Part                      : ATmega328P&#xA;     Chip Erase delay              : 9000 us&#xA;     PAGEL                         : PD7&#xA;     BS2                           : PC2&#xA;     RESET disposition             : dedicated&#xA;     RETRY pulse                   : SCK&#xA;     serial program mode           : yes&#xA;     parallel program mode         : yes&#xA;     Timeout                       : 200&#xA;     StabDelay                     : 100&#xA;     CmdexeDelay                   : 25&#xA;     SyncLoops                     : 32&#xA;     ByteDelay                     : 0&#xA;     PollIndex                     : 3&#xA;     PollValue                     : 0x53&#xA;     Memory Detail                 :&#xA;&#xA;                              Block Poll               Page                       Polled&#xA;       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;     Programmer Type : Arduino&#xA;     Description     : Arduino&#xA;     Hardware Version: 3&#xA;     Firmware Version: 4.4&#xA;     Vtarget         : 0.3 V&#xA;     Varef           : 0.3 V&#xA;     Oscillator      : 28.800 kHz&#xA;     SCK period      : 3.3 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: reading input file &quot;build244630154737317489.tmp/sketch_may23a.cpp.hex&quot;&#xA;avrdude: writing flash (450 bytes):&#xA;&#xA;Writing | avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most of the time I do not even get to this point and just end up with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I already tried to reset Arduino just before uploading the sketch.&lt;/li&gt;&#xA;&lt;li&gt;According to the avrdude, bootloader is fine. &lt;/li&gt;&#xA;&lt;li&gt;Reinstalled drivers, Arduino IDE&lt;/li&gt;&#xA;&lt;li&gt;Changed the USB cable and connected it to another USB slot&lt;/li&gt;&#xA;&lt;li&gt;Burned new bootloader using ArduinoISP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thank you for help.&lt;/p&gt;&#xA;" OwnerUserId="10253" LastEditorUserId="10253" LastEditDate="2015-05-23T20:25:47.470" LastActivityDate="2021-12-02T10:07:30.677" Title="Atmega328P-PU: Programmer is not responding" Tags="|arduino-uno|serial|atmega328|programmer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12105" PostTypeId="1" CreationDate="2015-05-22T13:40:26.933" Score="5" ViewCount="891" Body="&lt;p&gt;I've been reading about the protocol DASH7 but can't find much documentation about it. There seems to be a protocol stack called OpenTag writen in C and I want to know if there is something familiar written in arduino code and why can't I find a lot about this tecnology.&lt;/p&gt;&#xA;" OwnerUserId="10254" OwnerDisplayName="equidna" LastActivityDate="2015-05-23T21:24:31.887" Title="Is it possible to use the DASH7 protocol in an arduino?" Tags="|rf|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12106" PostTypeId="1" AcceptedAnswerId="12107" CreationDate="2015-05-23T22:28:45.347" Score="1" ViewCount="124" Body="&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I'm trying to teach myself some low[er] level code, but I just can't get it to work. I've tried OR-ing stuff in, AND-ing stuff in, and just straight up defining stuff, but it's not blinking! What am I doing wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino UNO R3 DIP for this. I am just using the on-board LED, (on pin13/PORTB_5)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define STATE B00001000&#xA;#define ZERO B00000000&#xA;void setup() {&#xA;    DDRB = STATE;&#xA;    }&#xA;&#xA;void loop(){&#xA;    PORTB |= STATE;&#xA;    delay(500);&#xA;    PORTB &amp;amp;= ZERO;&#xA;    delay(500);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8121" LastActivityDate="2015-05-23T23:03:25.060" Title="Starting Off Low-Level Port Access" Tags="|arduino-uno|debugging|arduino-uno-smd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12107" PostTypeId="2" ParentId="12106" CreationDate="2015-05-23T23:03:25.060" Score="3" Body="&lt;p&gt;It would probably help if you were using the right pin.  In the pins_arduino.h file for the Uno is this diagram:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//                  +-\/-+&#xA;//            PC6  1|    |28  PC5 (AI 5)&#xA;//      (D 0) PD0  2|    |27  PC4 (AI 4)&#xA;//      (D 1) PD1  3|    |26  PC3 (AI 3)&#xA;//      (D 2) PD2  4|    |25  PC2 (AI 2)&#xA;// PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)&#xA;//      (D 4) PD4  6|    |23  PC0 (AI 0)&#xA;//            VCC  7|    |22  GND&#xA;//            GND  8|    |21  AREF&#xA;//            PB6  9|    |20  AVCC&#xA;//            PB7 10|    |19  PB5 (D 13)&#xA;// PWM+ (D 5) PD5 11|    |18  PB4 (D 12)&#xA;// PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM&#xA;//      (D 7) PD7 13|    |16  PB2 (D 10) PWM&#xA;//      (D 8) PB0 14|    |15  PB1 (D 9) PWM&#xA;//                  +----+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That shows that pin D 13 is PB5 which would be a binary value of &lt;code&gt;0b00100000&lt;/code&gt; not &lt;code&gt;0b00001000&lt;/code&gt; as you have, which would be PB3, or pin D11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I can come up with &lt;code&gt;0b00001000&lt;/code&gt; is if I count from the left (wrong) and start at 1 (wrong) rather than count from the right (right) and start at 0 (right).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-23T23:03:25.060" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12108" PostTypeId="1" CreationDate="2015-05-24T00:22:54.277" Score="1" ViewCount="4614" Body="&lt;p&gt;&lt;code&gt;Arduino&lt;/code&gt; pins can be used as &lt;code&gt;UART&lt;/code&gt; using the &lt;code&gt;SoftwareSerial.h&lt;/code&gt; library. Is there any alternative for &lt;code&gt;AVR&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need more than one serial port on a &lt;code&gt;ATmega328P&lt;/code&gt;, but i don't use &lt;code&gt;Arduino&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SoftwareSerial.h&lt;/code&gt; is tied to &lt;code&gt;Arduino.h&lt;/code&gt; and &lt;code&gt;Arduino&lt;/code&gt; pins. I do not use &lt;code&gt;Arduino&lt;/code&gt;, i use &lt;code&gt;avr-gcc&lt;/code&gt; with &lt;code&gt;atmega328p&lt;/code&gt; and &lt;code&gt;atmega8&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="595" LastActivityDate="2015-05-24T00:27:10.820" Title="SoftwareSerial.h alternative with AVR (Two Serial/UART ports in atmega328p)" Tags="|serial|atmega328|softwareserial|uart|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12109" PostTypeId="2" ParentId="12108" CreationDate="2015-05-24T00:27:10.820" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/AVR274.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR274&lt;/a&gt; describes a single-wire, half-duplex software UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc0941.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR304&lt;/a&gt; describes a half-duplex, interrupt-driven software UART, and &lt;a href=&quot;http://www.atmel.com/Images/doc0952.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR305&lt;/a&gt; describes a polled alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc4300.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR307&lt;/a&gt; describes implementing a half-duplex UART using a USI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All code associated with each app note can be downloaded from Atmel's website.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-24T00:27:10.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12110" PostTypeId="2" ParentId="8708" CreationDate="2015-05-24T04:28:39.867" Score="5" Body="&lt;p&gt;To generate a &lt;strong&gt;square wave&lt;/strong&gt;, you only need to update the output at a rate of two points per cycle. (&lt;em&gt;Technically, when the Arduino's PWM output is configured for 50% duty cycle, that's a square wave at some frequency.&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to generate a clean &lt;strong&gt;sine wave&lt;/strong&gt; (without a lot of &lt;strong&gt;distortion&lt;/strong&gt;), you need to update a lot more frequenclly than two points per cycle. Personally I wouldn't want to go much below 20 points per cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine the sine wave is generated by a wheel that spins at some rate. Viewed from the edge, a point on the edge of the wheel traces out a sine wave. Viewed from the axle, you see the point going around in a circle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now instead of spinning the wheel continuously, suppose the wheel moves in steps of 30 degrees, 12 steps for a complete turn. Instead of a continuous sine wave, you get discrete steps of 0, 0.5, 0.866, 1, 0.866, 0.5, 0, -0.5, -0.866, -1, -0.866, -0.5, 0, 0.5, ...   Although this sequence approximates an ideal sine wave, it's pretty coarse because the steps are so large. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now try 15 degrees per step (24 steps per cycle). Now you get 0, 0.259, 0.5, 0.707, 0.866, 0.965, 1, ... Much smoother, although the steps are still fairly noticeable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there will be less &lt;strong&gt;phase error&lt;/strong&gt;, the more steps there are per cycle of the signal. That's not the only source of distortion however. There is also round-off error due to the limited resolution of the Digital-to-Analog Converter (DAC). For example, the value 0.866 I mentioned above should actually be an irrational value, half the square root of 3. Since it's an irrational number, there's no way for a real DAC to get this value exactly right. DAC output step values are ideally based on powers of two (1/2, 1/4, 3/4, 1/8, 3/8, 5/8, 7/8, etc.). And furthermore a real DAC can have offset error, gain error, non-linearity, as well as uncertainty about precisely when the new programmed value is reached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also &lt;strong&gt;frequency error&lt;/strong&gt; when the system's highest-frequency master clock is divided by an integer. If the Arduino UNO's master clock frequency is 16MHz, and the SPI setup function &lt;code&gt;setClockDivider()&lt;/code&gt; is used to divide the master clock by 2, that's 8MHz. Divide by 3 and you get 5.333MHz. Divide by 4, that's 4MHz. Divide by 5, that's 3.2MHz. There's no way to get a clock frequency that's between these discrete steps. For small divisors, there's a big jump between steps. So if you needed to be able to smoothly adjust the frequency, you'd need a much higher master clock frequency. And, if you needed to configure the 16MHz Arduino UNO to an SPI clock frequency of exactly 5.7MHz, that's just not possible -- setClockDivider(2) is too fast, setClockDivider(3) is too slow, and setClockDivider(2.807017543859649) isn't supported by the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your system could write to a DAC at an &lt;strong&gt;update rate&lt;/strong&gt; of 12MHz, then 12 points per cycle gives a 1MHz output, and 24 points per cycle gives a 500kHz output. Or taking it the other way round, if you need to generate a 5.7MHz output waveform, then the DAC update rate needs to be somewhere around 100MHz to get a clean, low-distortion waveform. This is probably beyond the limit of what you can directly synthesize in software using something like an Arduino or a Raspberry Pi. A 16MHz Arduino UNO could maybe synthesize a few 100kHz using software synthesis, but at 1MHz there's going to be significant distortion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software-controlled&lt;code&gt;Direct Digital Synthesis&lt;/code&gt; is very sensitive to timing, so the actual DAC update would need to be implemented in an &lt;strong&gt;interrupt service routine&lt;/strong&gt;, run by a periodic timer. ( See &lt;a href=&quot;https://electronics.stackexchange.com/questions/26363/how-do-i-create-a-timer-interrupt-with-arduino&quot;&gt;https://electronics.stackexchange.com/questions/26363/how-do-i-create-a-timer-interrupt-with-arduino&lt;/a&gt; )  If you just used a while loop with a delay statement, then whenever the code needs to do something else, the waveform would just freeze up. This is more of a problem if the Arduino is trying to manage several other tasks at the same time as it is synthesizing the waveform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt; &lt;code&gt;Direct Digital Synthesis&lt;/code&gt; (DDS) is possible. Same principles. There needs to be a &lt;code&gt;phase accumulator&lt;/code&gt;, which is just a counter that keeps track of the phase angle of the &quot;wheel&quot; that's generating the sine wave. &lt;em&gt;(The phase accumulator needs to be modulus 360 degrees or 2 pi radians, but there's no requirement to count in 1 degree steps. Better to divide the circle into 2^N slices so that 360 degress maps to the natural counter overflow value.)&lt;/em&gt; And there also needs to be a lookup table with the sine value for each of those steps. This lookup table only needs to cover 90 degrees of the sinewave, because the waveform is symmetrical -- the other three quadrants can be found by 2's complementing the values and indexing from the other end of the table. Or, the sine can be approximated by a polynomial calculation. More steps x more DAC resolution requires a deeper, wider lookup table. There are integrated circuits available that perform the timing-critical actions, all the software needs to do is send some initial configuration to set it up. Changing the frequency only requires configuring a new frequency divisor value into the DDS chip, so the Arduino can manage other things without causing distortion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the original problem only needs one &lt;strong&gt;fixed frequency under 200MHz&lt;/strong&gt;, and doesn't need any adjustment to that frequency, then the hardware gets a whole lot simpler. The crystal oscillator circuits that we use to generate the timing for digital circuits, are in fact analog to begin with. You can contact a crystal vendor and request a custom &lt;strong&gt;AT cut crystal&lt;/strong&gt;; google &lt;code&gt;custom quartz crystal frequency&lt;/code&gt; for quartz crystal vendors. Construction requires a careful printed circuit board layout; the white solderless breadboard commonly used in Arduino projects just doesn't work well above 10MHz. Granted, this fixed-frequency solution doesn't involve Arduino in any way, but if it solves the problem, that's what's important.&lt;/p&gt;&#xA;" OwnerUserId="7174" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-05-24T04:28:39.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12111" PostTypeId="1" CreationDate="2015-05-24T11:43:09.507" Score="2" ViewCount="257" Body="&lt;p&gt;I am using the embedded coder target for arduino following this: (&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/30277-embedded-coder-target-for-arduino&quot; rel=&quot;nofollow&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/30277-embedded-coder-target-for-arduino&lt;/a&gt;). I am having problem while running the myarduino_blink.slx demo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My MATLAB version is R2015a, and I am using an Arduino Uno. I ran the file setup_custom_target_arduino.m after changing the relevant directory listing and the arduino version in the m file, and I got the output of Arduino on COM 3, which was correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this, I checked the Simulink Library Browser and I had the Custom C/C++ Target Arduino Library will all its modules. Now when I simulate the model, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Error in S-function 'myarduino_blink/Digital Output':&#xA;S-Function 'sfunar_digitalOutput' does not exist&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly help me out, what could I have done wrong?&lt;/p&gt;&#xA;" OwnerUserId="10258" LastEditorUserId="10258" LastEditDate="2015-05-24T18:57:48.537" LastActivityDate="2015-05-24T18:57:48.537" Title="Issue with Embedded Coder Target for Arduino" Tags="|arduino-uno|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12112" PostTypeId="2" ParentId="11939" CreationDate="2015-05-24T12:50:23.230" Score="0" Body="&lt;p&gt;Expanding on my previous comment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can think of capacitive sensing as a form of impedance measurement,&#xA;even though it's more a threshold detection than an actual measurement.&#xA;In order to perform an impedance measurement, you have to build a&#xA;circuit like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;┌─────────┐           ┌───────────┐&#xA;│         ├───────────┤           │&#xA;│  meter  │           │ impedance │&#xA;│         ├───────────┤           │&#xA;└─────────┘           └───────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important thing in this figure is that you need &lt;strong&gt;two&lt;/strong&gt; electrical&#xA;contacts in order to close the circuit. The lower contact is often&#xA;provided by a common ground, but since your wristband is not properly&#xA;grounded, you will have to provide it by some other means.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is to have two electrodes on the wristband: a lower&#xA;electrode in permanent contact with the user, and an upper electrode&#xA;that will be the touch button. If both electrodes are exposed metal,&#xA;then you have a full DC path all around, and this is not “capacitive”&#xA;sensing any more. Depending on how your sensing is done, this may not be&#xA;a problem, and it may be detected just like an infinite capacity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to avoid a full DC path, you can have one of the electrodes&#xA;covered by a thin layer of dielectric. Or even both, but then you have&#xA;two capacitors in series and need twice the sensitivity.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-24T12:50:23.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12113" PostTypeId="2" ParentId="1546" CreationDate="2015-05-24T13:32:55.950" Score="2" Body="&lt;p&gt;A simple way to test for short between LEDs is to write a loop that lights one of them at a time, one right after the other, for 50ms or so. It's relatively easy to notice two LEDs lighting together (a short) or a missing blink in the sequence (an open)&lt;del&gt;, assuming you can see all the LEDs at once&lt;/del&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Update (6 years later, but hey - I since people still read this question):&lt;br&gt;&#xA;I use a sketch that does exactly this to help find shorts and opens when I'm building up a new board. I'd previously implied that you need all of the LEDs attached, but you need at most 2.&lt;/p&gt;&#xA;&lt;p&gt;On a newly soldered cpu with power &amp;amp; ground (and reset jumpered to ground), holding an LED on each of two adjacent pins will show a shorted pair, while a single LED on one pin will display an open or a short to ground (or to +5, if you orient your LED+resistor that way). I keep a few LEDs with a resistor soldered to the cathode, or ground, leg to use as digital probes.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2022-01-23T14:12:39.700" LastActivityDate="2022-01-23T14:12:39.700" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12114" PostTypeId="1" AcceptedAnswerId="12116" CreationDate="2015-05-24T16:25:09.870" Score="8" ViewCount="15008" Body="&lt;p&gt;I would like to make a makefile for compiling c programs for the arduino. I am somewhat familiar with make but have never used it with avr-gcc. What is the simplest way I could put the commands below in a makefile?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c&#xA;$ avr-gcc -mmcu=atmega328p led.o -o led&#xA;$ avr-objcopy -O ihex -R .eeprom led led.hex&#xA;$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:led.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10262" LastActivityDate="2017-07-02T08:45:56.193" Title="Basic makefile for avr-gcc" Tags="|arduino-uno|atmega328|c|avr|compile|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12115" PostTypeId="1" AcceptedAnswerId="12157" CreationDate="2015-05-24T16:26:24.450" Score="2" ViewCount="11712" Body="&lt;p&gt;&lt;strong&gt;What is the best / simplest way to play audio files from an SD card?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently working on a sound board, where each button plays a different sound. But I have yet to find the right combination of shields / hardware to do this efficiently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a shield that supports this directly (SD card -&gt; speaker)? Note that I also need additional pinheads for my buttons to connect to. I think I will be using the Arduino Mega for that purpose.&lt;/p&gt;&#xA;" OwnerUserId="8762" LastActivityDate="2015-05-26T22:37:38.773" Title="How can I play audio from an SD card?" Tags="|arduino-mega|sd-card|audio|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12116" PostTypeId="2" ParentId="12114" CreationDate="2015-05-24T17:05:40.813" Score="7" Body="&lt;p&gt;It's no different to working with Make and any other form of GCC.  Just set your CC variable and CFLAGS variable accordingly and work as per normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, I just knocked this one up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CC=avr-gcc&#xA;OBJCOPY=avr-objcopy&#xA;&#xA;CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega328p&#xA;PORT=/dev/ttyACM0&#xA;&#xA;led.hex: led.elf&#xA;    ${OBJCOPY} -O ihex -R .eeprom led.elf led.hex&#xA;&#xA;led.elf: led.o&#xA;    ${CC} -o led.elf led.o&#xA;&#xA;install: led.hex&#xA;    avrdude -F -V -c arduino -p ATMEGA328P -P ${PORT} -b 115200 -U flash:w:led.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's saying that any automatic C compilation will be done with avr-gcc and the flags specified in CFLAGS.  It will by default make the hex file using OBJCOPY, which is set to the avr one, which relies on the file led.elf - so to get that file it runs the led.elf target, which links the object file led.o with the default libraries using whatever was set in CC. To do that it needs led.o, and it makes that automatically using the program specified in CC and the flags in CFLAGS.  You can then optionally to &lt;code&gt;make install&lt;/code&gt; which will run &lt;code&gt;avrdude&lt;/code&gt; to install the hex file into the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make it even more generic so you can copy it in to other projects and make the minimum changes necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;BIN=led&#xA;OBJS=led.o test.o&#xA;&#xA;CC=avr-gcc&#xA;OBJCOPY=avr-objcopy&#xA;CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega328p&#xA;PORT=/dev/ttyACM0&#xA;&#xA;${BIN}.hex: ${BIN}.elf&#xA;    ${OBJCOPY} -O ihex -R .eeprom $&amp;lt; $@&#xA;&#xA;${BIN}.elf: ${OBJS}&#xA;    ${CC} -o $@ $^&#xA;&#xA;install: ${BIN}.hex&#xA;    avrdude -F -V -c arduino -p ATMEGA328P -P ${PORT} -b 115200 -U flash:w:$&amp;lt;&#xA;&#xA;clean:&#xA;    rm -f ${BIN}.elf ${BIN}.hex ${OBJS}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That uses &quot;automatic variables&quot; and simple name replacement.  &lt;code&gt;BIN&lt;/code&gt; contains the &quot;base&quot; of your binary files, &lt;code&gt;OBJS&lt;/code&gt; contains the list of object files.  $@ is the name of the current target, $&amp;lt; is the name of the first prerequisite, and $^ is the list of all the prerequisites.  Just change &lt;code&gt;BIN&lt;/code&gt; and &lt;code&gt;OBJS&lt;/code&gt; to suit.  As a bonus I have thrown in &lt;code&gt;make clean&lt;/code&gt; to remove the compiled files and just leave you with the source.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-24T17:29:33.313" LastActivityDate="2015-05-24T17:29:33.313" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12117" PostTypeId="1" AcceptedAnswerId="12118" CreationDate="2015-05-24T22:41:00.437" Score="2" ViewCount="121" Body="&lt;p&gt;I'm writing code for a project with Arduino Yun. My project is quite simple: it takes a picture with a webcam and saves it in a PNG or JPEG file format. I've already installed the uvc driver for Arduino Yun and tested it with my webcam and the fswebcam application. The application saved pictures both in PNG and JPEG format successfully, so I went on and installed the C compiler, make and binutils for Arduino Yun and started to write my own application that would do the same thing (just taking a picture and saving it in PNG format). After writing the code to capture the pixels of the image, I decided to write them down in a PNG file format by using the libpng library available for Arduino Yun through luci web control panel. After installing the package, I included the png.h (using #include png.h) in my source code and wrote the code to write those pixels down in a simple PNG file (thanks to this tutorial: &lt;a href=&quot;http://www.labbookpages.co.uk/software/imgProc/libPNG.html&quot; rel=&quot;nofollow&quot;&gt;http://www.labbookpages.co.uk/software/imgProc/libPNG.html&lt;/a&gt;).&#xA;What's the problem? It just won't compile! I tried everything and all I got were &quot;undefined reference to 'function name here'&quot; errors. I thought that, maybe, libpng was buggy so I moved to libjpeg. No luck! I get the same errors over and over again. I really don't know what else I can do, I tried everything, it just seems that the Arduino Yun C compiler can't handle &quot;external&quot; libraries. I thank you in advance for any help you'll give me...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the errors I get when I try to compile it using the libjpeg library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/ccdzMFgN.o: In function `salvaImmagineJPEG':&#xA;    ScattaFoto.c:(.text+0x1d9c): undefined reference to `jpeg_std_error'&#xA;    ScattaFoto.c:(.text+0x1da8): undefined reference to `jpeg_std_error'&#xA;    ScattaFoto.c:(.text+0x1dc8): undefined reference to `jpeg_CreateCompress'&#xA;    ScattaFoto.c:(.text+0x1dd4): undefined reference to `jpeg_CreateCompress'&#xA;    ScattaFoto.c:(.text+0x1dec): undefined reference to `jpeg_stdio_dest'&#xA;    ScattaFoto.c:(.text+0x1df8): undefined reference to `jpeg_stdio_dest'&#xA;    ScattaFoto.c:(.text+0x1e2c): undefined reference to `jpeg_set_defaults'&#xA;    ScattaFoto.c:(.text+0x1e38): undefined reference to `jpeg_set_defaults'&#xA;    ScattaFoto.c:(.text+0x1e54): undefined reference to `jpeg_set_quality'&#xA;    ScattaFoto.c:(.text+0x1e60): undefined reference to `jpeg_set_quality'&#xA;    ScattaFoto.c:(.text+0x1e78): undefined reference to `jpeg_start_compress'&#xA;    ScattaFoto.c:(.text+0x1e84): undefined reference to `jpeg_start_compress'&#xA;    ScattaFoto.c:(.text+0x1ed8): undefined reference to `jpeg_write_scanlines'&#xA;    ScattaFoto.c:(.text+0x1ee4): undefined reference to `jpeg_write_scanlines'&#xA;    ScattaFoto.c:(.text+0x1f10): undefined reference to `jpeg_finish_compress'&#xA;    ScattaFoto.c:(.text+0x1f1c): undefined reference to `jpeg_finish_compress'&#xA;    collect2: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10266" LastEditorUserId="1585" LastEditDate="2015-05-24T22:55:29.467" LastActivityDate="2015-05-24T23:12:33.613" Title="Arduino Yun doesn't link any library" Tags="|programming|c|compile|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12118" PostTypeId="2" ParentId="12117" CreationDate="2015-05-24T23:12:33.613" Score="1" Body="&lt;p&gt;It's not the compiler, it's the libpng package (and other libraries too).  It only contains the runtime shared library (&lt;code&gt;.so&lt;/code&gt;) files.  You can't use it for development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't yet found if it's possible to directly install a full development package or not - normally development for OpenWRT is done outside the low-powered chip using a cross-compiler environment on a PC.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-24T23:12:33.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12119" PostTypeId="2" ParentId="12115" CreationDate="2015-05-24T23:32:22.843" Score="0" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;                      // need to include the SD library&#xA;//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560&#xA;#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328&#xA;#include &amp;lt;TMRpcm.h&amp;gt;           //  also need to include this library...&#xA;&#xA;TMRpcm tmrpcm;   // create an object for use in this sketch&#xA;char mychar;&#xA;&#xA;void setup(){&#xA;&#xA;  tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc&#xA;&#xA;  Serial.begin(9600);&#xA;  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can      be initialized:&#xA;    Serial.println(&quot;SD fail&quot;);  &#xA;    return;   // don't do anything more if not&#xA;     }&#xA;  tmrpcm.play(&quot;beware.wav&quot;); //the sound file &quot;music&quot; will play each time the arduino powers up, or is reset&#xA;}&#xA;&#xA;void loop(){  &#xA;&#xA;  if(Serial.available()){   &#xA;    mychar = Serial.read();&#xA;&#xA;    if(mychar == 'o'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;helpyou.wav&quot;);&#xA;} else if(mychar == 'r'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;chortle.wav&quot;);&#xA;} else if(mychar == 'q'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;helpyou.wav&quot;);&#xA;} else if(mychar == 'p'){&#xA;  tmrpcm.play(&quot;beware.wav&quot;);&#xA;}&#xA;else if(mychar == 'w'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;impresiv.wav&quot;);&#xA;}&#xA;else if(mychar == 't'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;seekyoda.wav&quot;);&#xA;}&#xA;else if(mychar == 'y'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;sensefear.wav&quot;);&#xA;}&#xA;else if(mychar == 'u'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;strongami.wav&quot;);&#xA;}&#xA;else if(mychar == 'i'){ //send the letter p over the serial monitor to start playback&#xA;  tmrpcm.play(&quot;whyhere.wav&quot;);&#xA;}&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code should be helpful. Make sure you have a SD card reader. You must also hookup the card reader:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3.3v goes to 3.3v on the Arduino UNO (for power)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND goes to Ground on Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D0 goes to pin 12 on Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D1 goes to pin 11 on Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CLK goes to pin 13 on Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D3 goes to pin 10 on Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, download an arduino library so it can play audio files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/TMRh20/TMRpcm&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/TMRpcm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10267" LastActivityDate="2015-05-24T23:32:22.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12120" PostTypeId="2" ParentId="12101" CreationDate="2015-05-25T00:04:32.913" Score="1" Body="&lt;p&gt;as well as comment #1 the other thing will be the ack packets that the slaves will send back to the master to confirm message recieved. with all slaves sending back a ack at about the same time there will be no way for master to tell which ack is from which client, and thus who needs a retransmit. a way around this is to turn off ack for the clients and make the master transmit max times regardless. there is a rf24 fork that has broadcast mode, the makes it more easy to specify not to wait for ack before retransmitting&lt;/p&gt;&#xA;" OwnerUserId="4024" LastActivityDate="2015-05-25T00:04:32.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12121" PostTypeId="1" CreationDate="2015-05-25T03:55:21.890" Score="0" ViewCount="256" Body="&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to use sdFat library, more precisely AnalogBinLogger example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to log data from changing analog pins for example, I want to log from pin 0 to pin 3 for 5 minutes and then from pin 4 to pin 6 for another 5 mins and then from pin 7 to pin 9 for another 5 mins. that is going to be continuously which means I am going to get rid of the part where you have to enter &quot;r&quot; to start logging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the time, I managed to figure it out, I am just using the value of the variable count, if my sampling rate is 1000 samples/sec for example then 5 minutes will be 1000*60*5 and the change will be done in this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available()) {&#xA;  // Stop ISR calls.&#xA;  adcStop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (count &amp;gt;1000*60*5) {&#xA;  // Stop ISR calls.&#xA;  adcStop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this worked fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is with the changing pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t PIN_LIST[] = {1};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I changed this line to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t PIN_LIST[3] = {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First I removed the word &lt;code&gt;const&lt;/code&gt;, because it's not going to be constant anymore, and I just declared an empty array, and second I am changing the pins in the loop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the loop after I got rid of doing the serial input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;int i;&#xA;for (i=0;i&amp;lt;=12;i+3)&#xA;{   &#xA;  PIN_LIST[] = {i,i+1,i+2};&#xA;  logData();&#xA;  Serial.println(&quot;done&quot;);&#xA; }}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is I get this error :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;AnalogBinLogger.ino: In function 'void loop()':&lt;/li&gt;&#xA;&lt;li&gt;AnalogBinLogger:808: error: expected primary-expression before ']'&#xA;token&lt;/li&gt;&#xA;&lt;li&gt;AnalogBinLogger:808: error: expected primary-expression before '{'&#xA;token&lt;/li&gt;&#xA;&lt;li&gt;AnalogBinLogger:808: error: expected `;' before '{' token&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The line 808 is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PIN_LIST[] = {i,i+1,i+2};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this is the only error, any help please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is so long (800+ lines) if this information is not enough and you need me to explain a part then just tell me. &lt;/p&gt;&#xA;" OwnerUserId="10270" LastEditorUserId="6936" LastEditDate="2016-02-21T08:41:46.210" LastActivityDate="2016-02-21T08:41:46.210" Title="changing analog pins data logging using sdFat library" Tags="|analogread|data-type|datalogging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12122" PostTypeId="2" ParentId="12121" CreationDate="2015-05-25T04:23:45.470" Score="1" Body="&lt;p&gt;in case someone has the same problem&#xA;it seems like after you initialize an array this way &lt;/p&gt;&#xA;&#xA;&lt;p&gt;uint8_t PIN_LIST[3] = {};&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you won't be able to assign all the values at once:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PIN_LIST[] = {i,i+1,i+2};&lt;br&gt;&#xA;instead you assign each individual value&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PIN_LIST[0] = i;&lt;/li&gt;&#xA;&lt;li&gt;PIN_LIST[1] = i+1;&lt;/li&gt;&#xA;&lt;li&gt;PIN_LIST[2] = i+2;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and now it worked : )&lt;/p&gt;&#xA;" OwnerUserId="10270" LastActivityDate="2015-05-25T04:23:45.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12123" PostTypeId="2" ParentId="9532" CreationDate="2015-05-25T05:58:20.620" Score="1" Body="&lt;p&gt;If you connect a power supply directly to 5V pin on gpio it bypasses voltage regulator hence your board may be damaged if the power supply generates  spikes. But you can power it using 5V supply directly to 5V pin provided you are using a good quality power supply. If you are supplying the power via Vin or power jack there is additional voltage regulator in path giving extra security. Thus you need more 6.5v so as the output of the regulator is 5v. If you supply 5v to Vin the output is nearly 4v thus the board doesn't get enough power.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2015-05-25T05:58:20.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12124" PostTypeId="2" ParentId="3160" CreationDate="2015-05-25T06:28:51.393" Score="2" Body="&lt;p&gt;Bluetooth generally support only one to one connection. Atmost 6 bluetooth can be connected to single module in latest bluetooth version(the basic model probably used by you connects only 1 device). Hence it is not a good idea to use bluetooth. Also if you need a web based platform you should switch to some more powerful platform like raspberry pi, beagle bone etc.&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2015-05-25T06:28:51.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12125" PostTypeId="1" CreationDate="2015-05-25T09:47:03.473" Score="2" ViewCount="1249" Body="&lt;p&gt;I am using Arduino Uno, and MPU6050(3 axis imu sensors), not gate,  and L298 dc motor drive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My algorithm is very easy.&#xA;Receive an angle how the balancing robot is tilt.&#xA;Decision speed of motors by using the angle.&#xA;For example, when robot is tilt n degrees forth or back, robot will go forth or back with speed proportional n.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is similar to the following code.&#xA;Sorry, it is difficult to type on my phone. TT&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Angle = getComplementaryAngle();&#xA;&#xA;Speed = pidCompute(abs(Angle));&#xA;// Speed range: 0 to 255&#xA;&#xA;if (Angle &amp;gt; 0.4) {&#xA;&#xA;  DigitalWrite(dirA, HIGH);&#xA;&#xA;  DigitalWrite(dirB, HIGH);&#xA;&#xA;  analogWrite(enA, Speed);&#xA;&#xA;  analogWrite(enB, Speed);&#xA;&#xA;}&#xA;&#xA;else if (Angle &amp;lt; -0.4) {&#xA;&#xA;  DigitalWrite(dirA, LOW);&#xA;&#xA;  DigitalWrite(dirB, LOW);&#xA;&#xA;  analogWrite(enA, Speed);&#xA;&#xA;  analogWrite(enB, Speed);&#xA;&#xA;}&#xA;&#xA;else {&#xA;&#xA;  analogWrite(enA, 0);&#xA;&#xA;  analogWrite(enB, 0);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know why left motor's speed is different from right motor's one.&#xA;I checked the voltage of motor pin.&#xA;Both pins' voltage are same as 11V.&#xA;I think pwm is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Arduino makes two pwm output, it causes some problems?&lt;/p&gt;&#xA;" OwnerUserId="10272" LastEditorUserId="37523" LastEditDate="2019-08-20T23:22:39.913" LastActivityDate="2019-08-20T23:22:39.913" Title="DC Motor speed control by using pwm" Tags="|arduino-uno|motor|pwm|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="12126" PostTypeId="2" ParentId="11673" CreationDate="2015-05-25T09:56:15.140" Score="0" Body="&lt;p&gt;Make sure the board selected and port selected are correct. I face this problem many time but they disappear after I remove my other circuit connection and reconnect my arduino board to pc&lt;/p&gt;&#xA;" OwnerUserId="10216" LastActivityDate="2015-05-25T09:56:15.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12128" PostTypeId="2" ParentId="12095" CreationDate="2015-05-25T13:57:33.823" Score="1" Body="&lt;p&gt;As mentioned by Spiked3 there are a few ways to hit the ground running with C#.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, as detailed by Majenko, you will need an application running on your PC and some code on the Arduino to interact with this. For the desktop application, the two easiest ways to get started with C# are with WinForms, or XNA/MonoGame. WinForms is targeted at Desktop application development; think legacy desktop apps. Although it is not the current defacto standard (replaced largely by WPF) it is very simple and akin to Swing in Java to use. MonoGame and XNA are targeted at video game development. The latter would be my preference as it lends itself more towards real time applications, and has a game loop much like the Arduino so it is very easy to start using. The caveat is that there is more setup involved, but you will probably find this the friendliest and best supported. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, The Code! So for the Winforms Route, We have something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using System.Collections.Generic;&#xA;using System.Diagnostics;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace WindowsFormsApplication1&#xA;{&#xA;    public partial class Form1 : Form&#xA;    {&#xA;        public Form1()&#xA;        {&#xA;            InitializeComponent();&#xA;        }&#xA;&#xA;        private void Form1_KeyUp(object sender, KeyEventArgs e)&#xA;        {&#xA;            Debug.WriteLine(&quot; Key Up! ({0})&quot;, e.KeyCode);&#xA;&#xA;            // TODO: Talk with Arduino&#xA;        }&#xA;&#xA;        private void Form1_KeyPress(object sender, KeyPressEventArgs e)&#xA;        {&#xA;            Debug.WriteLine(&quot; Key Press! ({0})&quot;, e.KeyChar);&#xA;&#xA;            // TODO: Talk With Arduino&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get to this point, fire up a new winforms project, and open up the 'Form1' code (the default window which is added to the project) add the methods as outlined above. You will need to go to the designer afterwards and add events for on KeyPressand on KeyUp to tie these functions to the Window. You can do this by clicking the Window, then opening the Properties Panel, and then clicking the lightening bolt. You will see a list of event names; find the corresponding events (Key Press and Key Up) and associate them with these methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From here, you can perform some logic when a button is either pressed or released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The monogame or XNA approach is a bit simpler to follow as there is no hidden magic; but may be more intimidating if you're not familiar with C# and the project type.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using Microsoft.Xna.Framework;&#xA;using Microsoft.Xna.Framework.Input;&#xA;using System.Diagnostics;&#xA;&#xA;namespace GameName1&#xA;{&#xA;    public class Game1 : Game&#xA;    {&#xA;        GraphicsDeviceManager graphics;&#xA;&#xA;        KeyboardState currentState;&#xA;        KeyboardState previousState;&#xA;&#xA;        public Game1() : base()&#xA;        {&#xA;            graphics = new GraphicsDeviceManager(this);&#xA;            Content.RootDirectory = &quot;Content&quot;;&#xA;        }&#xA;&#xA;        protected override void Initialize()&#xA;        {&#xA;            // Get state management started&#xA;            currentState = Keyboard.GetState();&#xA;&#xA;            base.Initialize();&#xA;        }&#xA;&#xA;        protected override void Update(GameTime gameTime)&#xA;        {&#xA;            // Listen for exit command&#xA;            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))&#xA;                Exit();&#xA;&#xA;            // Update the state of your keyboard object&#xA;            previousState = currentState;&#xA;            currentState = Keyboard.GetState();&#xA;&#xA;            // Detect Keypress of key 'F'&#xA;            if (currentState.IsKeyDown(Keys.F) &amp;amp;&amp;amp; previousState.IsKeyUp(Keys.F))&#xA;            {&#xA;                // F Key has been pressed&#xA;                Debug.WriteLine(&quot; Key Pressed! ({0})&quot;, 'F');&#xA;                //TODO Talk to Arduino&#xA;            }&#xA;&#xA;            // Detect Keyrelease of key 'F'&#xA;            if (currentState.IsKeyUp(Keys.F) &amp;amp;&amp;amp; previousState.IsKeyDown(Keys.F))&#xA;            {&#xA;                // F Key has been pressed&#xA;                Debug.WriteLine(&quot; Key Released! ({0})&quot;, 'F');&#xA;                //TODO Talk to Arduino&#xA;            }&#xA;&#xA;            base.Update(gameTime);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In either case, you will need to get yourself set up first. Get a compy of Visual Studio Community from the link below, and install MonoGame if desired. Then do some C# tutorials to get comfortable in your new environment.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx&quot; rel=&quot;nofollow&quot;&gt;Visual Studio Community Edition&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.monogame.net/&quot; rel=&quot;nofollow&quot;&gt;Mono Game&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx&quot; rel=&quot;nofollow&quot;&gt;C# Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://rbwhitaker.wikidot.com/monogame-tutorials&quot; rel=&quot;nofollow&quot;&gt;C# Mono Game Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/dd492132.aspx&quot; rel=&quot;nofollow&quot;&gt;C# WinForms Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Lastly, you will want to talk with your Arduino. This can be done by implementing a compatible Serial interface between your desktop application and your Arduino. See the tutorial below to get started! &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Interfacing-your-arduino-with-a-C-program/&quot; rel=&quot;nofollow&quot;&gt;Arduino C# Serial Tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I hope this information is useful. There is a very broad range of topics mentioned here, and it may seem overwhelming at first - but C# is a very idiosyncratic language in that it permits rapid development in many different scenarios, and I think that you will find it rewarding to conquer the learning curve. &lt;/p&gt;&#xA;" OwnerUserId="10007" LastActivityDate="2015-05-25T13:57:33.823" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12129" PostTypeId="2" ParentId="12095" CreationDate="2015-05-25T14:16:16.627" Score="0" Body="&lt;p&gt;UPDATE: When I posted this answer I had not yet any knowledge of the Processing Language. If you came to this answer with the same intention I had (the question title), I strongly suggest you to use Processing instead, which has much more straightforward keyboard event capturing and serial communication working out of the box with minimal code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A question showing this in action is here: &lt;a href=&quot;https://stackoverflow.com/questions/18366482/processing-to-arduino-with-keyboard&quot;&gt;https://stackoverflow.com/questions/18366482/processing-to-arduino-with-keyboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After realizing that what I actually wanted was to &quot;capture keyboard events&quot;, I ended up using &lt;a href=&quot;http://www.pygame.org/news.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PyGame&lt;/a&gt; due to its minimalistic setup. Now I can send whatever I want to the Arduino using &lt;a href=&quot;http://playground.arduino.cc/interfacing/python&quot; rel=&quot;nofollow noreferrer&quot;&gt;PySerial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.: Don't be fooled by the lame aesthetics of PyGame website, it is a very mature gaming platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full code here: &lt;a href=&quot;https://github.com/heltonbiker/Experiments/tree/master/SerialMusicKeyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/heltonbiker/Experiments/tree/master/SerialMusicKeyboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#/usr/bin/env python&#xA;&#xA;import pygame&#xA;import serial&#xA;import glob&#xA;import time&#xA;&#xA;def pygameSetup():&#xA;    pygame.init()&#xA;    screen = pygame.display.set_mode((468, 60))&#xA;&#xA;    background = pygame.Surface(screen.get_size())&#xA;    background = background.convert()&#xA;    background.fill((250, 250, 250))&#xA;&#xA;    if pygame.font:&#xA;        font = pygame.font.Font(None, 36)&#xA;        text = font.render(&quot;Shut up 'n play yer keyboard!&quot;, 1, (10, 10, 10))&#xA;        textpos = text.get_rect(centerx=background.get_width()/2)&#xA;        background.blit(text, textpos)&#xA;&#xA;    screen.blit(background, (0, 0))&#xA;    pygame.display.flip()&#xA;&#xA;&#xA;def main():&#xA;&#xA;    pygameSetup()&#xA;&#xA;    initialized = False&#xA;&#xA;    while not initialized:&#xA;        try:&#xA;            serialpath = glob.glob('/dev/ttyACM*')[0]&#xA;            ser = serial.Serial(serialpath, 9600)&#xA;            initialized = True&#xA;            print &quot;serial up&quot;&#xA;        except:&#xA;            time.sleep(500)&#xA;            print &quot;waiting for serial&quot;&#xA;&#xA;    while True:&#xA;        for event in pygame.event.get():&#xA;            if event.type == pygame.QUIT:&#xA;                return&#xA;            elif event.type == pygame.KEYDOWN:&#xA;                print event&#xA;                ser.write(chr(event.key))            &#xA;            elif event.type == pygame.KEYUP:&#xA;                ser.write(chr(0))&#xA;&#xA;&#xA;if __name__ == '__main__': &#xA;    main()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-16T02:46:58.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12130" PostTypeId="1" AcceptedAnswerId="12132" CreationDate="2015-05-25T15:55:33.123" Score="2" ViewCount="2506" Body="&lt;p&gt;I'm trying to convert the project &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/DueSimpleWaveformGenerator&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; to an Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I scaled the waveforms from 12 bit to 8 bit values. I replaced the &lt;code&gt;analogReadResolution&lt;/code&gt; and &lt;code&gt;analogWriteResolution&lt;/code&gt; calls with &lt;code&gt;pinMode(10, OUTPUT)&lt;/code&gt; and &lt;code&gt;pinMode(11, OUTPUT)&lt;/code&gt; and changed the two &lt;code&gt;analogWrite&lt;/code&gt; calls to write to pins 10 and 11. Otherwise the program is unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thinking (and this is where my poor electronics skills come into play) is that I just need a simple low pass filter to convert the PWM into the appropriate waveform (which, at startup, ought to be a sine wave on both pins). According to the article, the frequency generator tops out at 170Hz. I figure the PWM signal is going to be significantly higher than that, so I use R=3.3K and C = .1uF for my RC filter which ought to give me a -3dB at about 480Hz, but what I'm seeing on my scope is a mess. Not a stable signal at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the waveform I'm seeing on my scope:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RK99A.jpg&quot; alt=&quot;OscopeImage&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone educate me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: BTW, this is the initial waveform which ought to be a sine wave.&lt;/p&gt;&#xA;" OwnerUserId="10276" LastEditorUserId="10276" LastEditDate="2015-05-25T16:38:11.577" LastActivityDate="2015-05-26T08:44:57.630" Title="Function generator with Arduino Nano" Tags="|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12131" PostTypeId="2" ParentId="12130" CreationDate="2015-05-25T16:38:44.150" Score="2" Body="&lt;p&gt;The PWMs on pins 10 and 11 of the Arduino Nano run at 488 Hz. That's what you are seeing on the scope. The code you are using was meant for an Arduino Due, which has real digital-to-analog converters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: You can tune the PWM to run as high as &lt;code&gt;F_CPU/256&lt;/code&gt; by&#xA;reconfiguring the timers 1 and 2 to “fast PWM” mode, instead of phase&#xA;correct PWM, and setting their prescalers to 1 instead of 64. This&#xA;should raise the PWM frequency to 62.5&amp;nbsp;kHz, given that the Nano has&#xA;a 16&amp;nbsp;MHz clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code should do exactly this. You can put it somewhere&#xA;inside your &lt;code&gt;setup()&lt;/code&gt;. &lt;strong&gt;Warning&lt;/strong&gt;: I have not tested this code. This&#xA;will change the PWM frequency on pins 10 and 11, but also on pins 3 and&#xA;9, which share the same timers. It will probably break the &lt;code&gt;tone()&lt;/code&gt;&#xA;Arduino function.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Set PWM frequency to 62.5 kHz on pins 3, 9, 10 and 11.&#xA;TCCR1A = 1&amp;lt;&amp;lt;WGM10;&#xA;TCCR1B = 1&amp;lt;&amp;lt;WGM12 | 1&amp;lt;&amp;lt;CS10;&#xA;TCCR2A = 1&amp;lt;&amp;lt;WGM21 | 1&amp;lt;&amp;lt;WGM20;&#xA;TCCR2B = 1&amp;lt;&amp;lt;CS20;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-05-26T08:44:57.630" LastActivityDate="2015-05-26T08:44:57.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12132" PostTypeId="2" ParentId="12130" CreationDate="2015-05-25T16:46:54.827" Score="2" Body="&lt;p&gt;What you're proposing &lt;a href=&quot;http://interface.khm.de/index.php/lab/interfaces-advanced/arduino-dds-sinewave-generator/&quot; rel=&quot;nofollow&quot;&gt;can work&lt;/a&gt;, but the PWM frequency needs to be &lt;em&gt;much&lt;/em&gt; higher than the frequency you're trying to generate. If you look at the &lt;a href=&quot;http://playground.arduino.cc/Code/PCMAudio&quot; rel=&quot;nofollow&quot;&gt;PCMAudio sample&lt;/a&gt; you'll see that it tunes the PCM frequency almost as high as it will go.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-25T16:46:54.827" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12133" PostTypeId="1" CreationDate="2015-05-25T19:10:38.890" Score="47" ViewCount="150613" Body="&lt;p&gt;I have a MacBook Pro running OS X Yosemite (10.10.3). I connected my Arduino UNO R3 to my computer for the first time after the Yosemite upgrade - it worked fine before this!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I opened the Arduino IDE I selected Tools &gt; Board &gt; &quot;Arduino UNO&quot;, but when I try to choose a Serial Port the only options are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.Bluetooth-Incoming-Port&#xA;/dev/cu.Bluetooth-Incoming-Port&#xA;/dev/tty.Bluetooth-Modem&#xA;/dev/cu.Bluetooth-Modem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have followed several tutorials and threads on how to 'fix' this issue, all to no avail:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've installed the latest version of the FTDI drivers (even though, from what I recall the UNO doesn't even need them): FTDIUSBSerialDriver_v2_3.dmg&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downgraded to a prev. version of the FTDI driver hoping that would clear it up: /Volumes/FTDIUSBSerialDriver_v2_2_18&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed a tutorial of how to remove the existing Apple drivers and removed the kext files, etc... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried connecting arduino to both USB ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried various cables, including the one that a I used before the Yosemite upgrade.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried installing updated Silabs drivers:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3324/arduino-compatibles-serial-port-not-showing-mac-osx/3328#3328&quot;&gt;Arduino compatible&amp;#39;s serial port not showing Mac OSX&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Walked through the entire Arduino Mac OSX guide:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/guide/macOSX&quot; rel=&quot;noreferrer&quot;&gt;http://www.arduino.cc/en/guide/macOSX&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After looking into the system info of my Macbook Pro, I can see the USB Controller is Broadcom based, in case that helps. I searched for Broadcom USB drivers but got hits for Silabs one instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under my Tools &gt; Port menu.. I can see these options:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/MOvDD.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;clicking the Serial Ports option doesn't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;ls -1 /dev/tty.*&lt;/code&gt; or &lt;code&gt;ls -l /dev/tty.usb*&lt;/code&gt; from terminal gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.Bluetooth-Incoming-Port&#xA;/dev/tty.Bluetooth-Modem&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Board does NOT show up under system networking (as it has for others), so it's not recognized as an incorrect device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm at a complete loss. The board powers up... but I cannot connect to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SIDE NOTE: This is a legit Uno R3, not a clone.&lt;/p&gt;&#xA;" OwnerUserId="10279" LastEditorUserId="-1" LastEditDate="2018-05-12T13:27:21.473" LastActivityDate="2018-05-12T13:27:21.473" Title="Mac OSX Yosemite no serial ports showing for Uno R3" Tags="|arduino-uno|usb|" AnswerCount="11" CommentCount="17" ContentLicense="CC BY-SA 4.0" />
  <row Id="12134" PostTypeId="1" CreationDate="2015-05-25T20:27:40.887" Score="2" ViewCount="4334" Body="&lt;p&gt;I'm working on a project that needs to use USB to pass serial messages between Arduinos (I can't use I2C or SPI for a few reasons – I especially need USB's support for hot-swapping and address allocation). So far I have the USB Host Shield set up on one Arduino Uno, connected to the standard USB port on another. It appears to be working, as can be seen when I run the board_qc:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fALe7.png&quot; width=&quot;300&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 'slave' Arduino is just running the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  Serial.println(&quot;Hello&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the master, I create a USB object from the USB Host library (&lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/felis/USB_Host_Shield_2.0&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USB Usb;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    Usb.Init();&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Usb.getUsbTaskState() == USB_STATE_RUNNING)&#xA;    {&#xA;        Usb.ForEachUsbDevice(&amp;amp;PrintAllData);&#xA;    }&#xA;} &#xA;&#xA;void PrintAllData(UsbDevice *pdev)&#xA;{&#xA;    UsbDeviceAddress adr;&#xA;    adr.devAddress = pdev-&amp;gt;address.devAddress;&#xA;    Serial.println(adr.devAddress, HEX);&#xA;&#xA;    uint8_t msg = 0;&#xA;    uint16_t len = 0;&#xA;    uint8_t rcode = Usb.inTransfer(adr.devAddress, pdev-&amp;gt;epinfo-&amp;gt;epAddr, &amp;amp;len, msg);&#xA;&#xA;    if (rcode &amp;amp;&amp;amp; rcode != hrNAK) {&#xA;     Serial.print(F(&quot;\r\nData rcv: &quot;));&#xA;     Serial.print(rcode, HEX);&#xA;   } else if (len &amp;gt; 0) {&#xA;     Serial.print(F(&quot;\r\nData Packet: &quot;));&#xA;     Serial.print(msg[0]);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not getting any data through though. Does anyone have any suggestions? Or know of any helpful sample code?&lt;/p&gt;&#xA;" OwnerUserId="8147" LastActivityDate="2017-08-17T23:19:22.827" Title="Communication between Arduinos using USB Host Shield" Tags="|serial|usb|" AnswerCount="1" CommentCount="9" ClosedDate="2017-08-20T22:43:36.027" ContentLicense="CC BY-SA 3.0" />
  <row Id="12136" PostTypeId="1" AcceptedAnswerId="12138" CreationDate="2015-05-26T01:08:22.090" Score="0" ViewCount="381" Body="&lt;p&gt;I'm having trouble figuring this out. I'm using this popular shield: &lt;a href=&quot;https://www.sparkfun.com/products/12761&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12761&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a breadboard area in the middle of the shield. But what confuses me is the lack of lines (order). On normal breadboards you can tell which row would be at the same voltage. If I wanted to put something on this prototyping area, how would I connect it? For example an LED, which would have a resistor attached to the positive side going to 5V and the negative side going to ground?&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2015-05-26T01:52:34.057" Title="How do I use the prototyping area on a SparkFun MicroSD Card shield?" Tags="|arduino-uno|shields|sd-card|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12138" PostTypeId="2" ParentId="12136" CreationDate="2015-05-26T01:52:34.057" Score="2" Body="&lt;p&gt;This type of board, &quot;pad per hole&quot;, has no pre-made interconnects. If you use thin enough wire sometimes you can push two pieces of wire into the same hole before you solder, say a resistor lead and another wire to connect to the next component. You can also solder an interconnect wire to the protruding leg of a DIP chip. You can make a buss for ground or 5v by assigning a whole row for that purpose, on the top side wire everything that needs to connect to that buss, and on the bottom side solder a straight piece of bare wire to all those wire ends in that row. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-05-26T01:52:34.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12139" PostTypeId="1" AcceptedAnswerId="12141" CreationDate="2015-05-26T02:13:51.187" Score="0" ViewCount="132" Body="&lt;p&gt;I have an old RC helicopter controller, but not the helicopter.  I recently purchased an Arduino Uno and would like to do something with LEDs(beside the on-board one built-in). Can I use an LED from the controller, that is already soldered in, cut it free and plug into my breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Side Note&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no experience in soldering and don't own a soldering iron.&lt;/p&gt;&#xA;" OwnerUserId="9826" LastActivityDate="2017-03-17T20:37:10.627" Title="Reusing LED from RC helicopter controller" Tags="|arduino-uno|led|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12140" PostTypeId="2" ParentId="12133" CreationDate="2015-05-26T02:16:27.317" Score="4" Body="&lt;p&gt;This exact same thing happen to me on my mac running the same operating system. I had to restart this system a few times to get it to work. I restarted it with the arduino plugged in; and that worked rather than my previous attempts when i rebooted then plugged in.&lt;/p&gt;&#xA;" OwnerUserId="9826" LastActivityDate="2015-05-26T02:16:27.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12141" PostTypeId="2" ParentId="12139" CreationDate="2015-05-26T02:24:20.993" Score="1" Body="&lt;p&gt;Yes, you can. For convenience, cut a bit shorter the lead on the side of the package where the flat part is so that you can identify the leads easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://digitalmedia.risd.edu/pbadger/PhysComp/?n=Devices.Led&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/79vli.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="11529" LastEditDate="2017-03-17T20:37:10.627" LastActivityDate="2017-03-17T20:37:10.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12142" PostTypeId="2" ParentId="9587" CreationDate="2015-05-26T03:17:05.110" Score="1" Body="&lt;p&gt;Arduinos are great for many things, and I think the idea of synchronizing two or more Arduinos might have several applications.&#xA;However, if I wanted to generated VGA or NTSC video, I would look at the Parallax Propeller as another option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people use the Parallax Propeller to produce VGA video, keeping its 8 processors working in parallel.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://dangerousprototypes.com/2013/01/20/hive-retro-computer/&quot; rel=&quot;nofollow&quot;&gt;&quot;Hive retro computer&quot;&lt;/a&gt;&#xA;&quot;containing a total of 24 RISC processors, VGA graphics, stereo sound, ...&#xA;uses all DIP and through hole components.&quot;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.ghielectronics.com/community/forum/topic?id=13725&quot; rel=&quot;nofollow&quot;&gt;&quot;Signal processing module using Parallax's propeller chip&quot;&lt;/a&gt;,&#xA;apparently can do &quot;video in ... to do video-overlay then send it to video out.&quot;&lt;/li&gt;&#xA;&lt;li&gt;Dangerous prototypes has a long list of projects using the Parallax Propeller.&#xA;&lt;a href=&quot;http://dangerousprototypes.com/category/parallax-propeller/&quot; rel=&quot;nofollow&quot;&gt;&quot;Dangerous Prototypes: Parallax Propeller&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://demin.ws/blog/english/2012/11/22/personal-mini-computer-on-parallax-propeller/&quot; rel=&quot;nofollow&quot;&gt;&quot;Pocket Mini Computer on Parallax Propeller&quot;&lt;/a&gt; includes VGA output&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.propellerpowered.com/forum/index.php&quot; rel=&quot;nofollow&quot;&gt;&quot;Propellerpowered Forums&quot;&lt;/a&gt; includes many people discussing video output on the Parallax Propeller.&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-05-26T03:17:05.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12143" PostTypeId="2" ParentId="12139" CreationDate="2015-05-26T04:01:36.807" Score="0" Body="&lt;p&gt;Yes you can. Make sure you have a resistor in series with your led. It is much, much better to guess and use the wrong resistor, than not to put a resistor in at all. I use &lt;a href=&quot;http://led.linear1.org/1led.wiz&quot; rel=&quot;nofollow&quot;&gt;http://led.linear1.org/1led.wiz&lt;/a&gt; to calculate my resistor. Your source voltage will be 5v. Each thing you have to fill has help on what value you're likely to want to put here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter which side of the led you put the resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can cut the led out, it should be fine, so long as you have long enough legs to go into the breadboard.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-05-26T04:01:36.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12144" PostTypeId="2" ParentId="12139" CreationDate="2015-05-26T07:17:34.647" Score="0" Body="&lt;p&gt;Ignacio's drawing shows you how to connect a LED. If you don't have any soldering tools you can use a &lt;strong&gt;solderless breadboard&lt;/strong&gt;. &lt;a href=&quot;https://www.adafruit.com/products/65&quot; rel=&quot;nofollow noreferrer&quot;&gt;This small one&lt;/a&gt; from Adafruit is ideal for small circuits:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cdd2f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(They exist in all sizes from very small to very large). The holes in each 5-hole row are all internally connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with cutting the LED from the board may be that the remaining wire length is too short to fit in the breadboard. (You'll need at least something like 6 mm.) LEDs are a nice way to start with electronics, since you need minimal part count to make something visible. If you can't cannibalize the LED from the controller, just buy one from your local electronics shop. They're dirt cheap.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastEditorUserId="6834" LastEditDate="2015-05-26T07:23:23.870" LastActivityDate="2015-05-26T07:23:23.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12145" PostTypeId="1" CreationDate="2015-05-26T09:28:40.030" Score="-2" ViewCount="1565" Body="&lt;p&gt;I am building a door lock that we will use at a local MakerSpace-club in my city, and we had this idea about building a fingerprint lock with parts compatible with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What we are aiming to do is create a database that holds all our customers and their associated information. Fingerprint data being one of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: Is it possible to have a fingerprint sensor &lt;strong&gt;store and compare fingerprint data&lt;/strong&gt; with an &lt;strong&gt;external source&lt;/strong&gt; such as a &lt;strong&gt;MySQL database&lt;/strong&gt;, instead of using the on-board memory? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically: When a customer puts his finger on the sensor, the Arduino board grabs the fingerprint data and queries our database for a match through its WiFi shield. If match is found: Log entry and unlock the door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Google is not helping me out here.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10286" LastActivityDate="2016-02-23T05:26:42.533" Title="Fingerprint sensor with external memory source" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12146" PostTypeId="1" AcceptedAnswerId="12231" CreationDate="2015-05-26T10:22:44.637" Score="1" ViewCount="1323" Body="&lt;p&gt;I'm making a project with MQTT Arduino, but on publish messages i read that it's not possible to publish with qos 1 and 2? It is true? If is not, how can i put qos on publish messages? &lt;/p&gt;&#xA;" OwnerUserId="9820" LastActivityDate="2021-09-14T21:17:52.597" Title="MQTT Arduino add quality of service" Tags="|arduino-uno|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12147" PostTypeId="1" CreationDate="2015-05-26T13:51:39.113" Score="2" ViewCount="1623" Body="&lt;p&gt;The title pretty much says it all:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the most obvious way to setup the Arduino (shields?), the Sketch (libraries?) and PC (webserver, ajax, plain html?) so that I get the following system working:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I open some page in a browser. The page has some labels/fields/values;&lt;/li&gt;&#xA;&lt;li&gt;I power up Arduino, which is connected to some sensors (or even potentiometers);&lt;/li&gt;&#xA;&lt;li&gt;The sensor values display keep being constantly updated in the page, with a sensible refresh rate (the fastest as possible, as to control some browser-based game for example);&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The fundamental idea here is to use the Browser, and not some other GUI toolkit, or Processing, or the command line.&lt;/p&gt;&#xA;" OwnerUserId="8044" LastActivityDate="2015-05-26T14:52:43.950" Title="Using Browser window to display sensor values in realtime" Tags="|ethernet|" AnswerCount="3" CommentCount="0" ClosedDate="2015-05-28T02:37:59.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="12148" PostTypeId="2" ParentId="12147" CreationDate="2015-05-26T14:13:08.213" Score="0" Body="&lt;p&gt;Your question actually exists out of multiple questions...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. How to connect arduino to network/internet.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using a &lt;a href=&quot;https://www.sparkfun.com/products/13252&quot; rel=&quot;nofollow&quot;&gt;cheap WIFI module&lt;/a&gt; or &lt;a href=&quot;http://www.mouser.com/ProductDetail/WIZnet/WIZ550io/?qs=sGAEpiMZZMs64UhKbFbsce4VNQuqbcmAbUaU%2F%2FiSHPWsh1gbPl3iTA%3D%3D&quot; rel=&quot;nofollow&quot;&gt;Ethernet module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. How to send values from arduino over ethernet.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fastest would be using a direct connection (TCP/IP or UDP?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. How to receive values from arduino over ethernet on a PC.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this would (I think) be that a webserver usually does not enable a direct TCP/IP connection, but instead would use HTML to transfer data/webpages. But I'm not a web-developer at all. I would create a dedicated program in processing/c++/python or something similiar.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-05-26T14:13:08.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12149" PostTypeId="2" ParentId="12147" CreationDate="2015-05-26T14:22:17.217" Score="2" Body="&lt;p&gt;The most obvious way? Not what is the best way? It is a subjective question. The most obvious way would be to do it in a way you know how to. I am sure there are at least 20 ways to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I know, and that I would do it is write a PC service that establishes serial communications with the Arduino, transfers data using JSON, and presents a web server I could connect TCP to.  Knowing C# and using existing code I have, it would take less than 15 minutes.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-26T14:22:17.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12150" PostTypeId="1" AcceptedAnswerId="12156" CreationDate="2015-05-26T14:25:28.527" Score="3" ViewCount="1062" Body="&lt;p&gt;Im using Spark fun pro micro:&lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am controlling a servo motor which reads its data from a pot connected to A0, and then writes to the servo on D9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A speaker is connected to A5. Im using tone()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I comment out the servo part of it, the tone() works out just fine and vise versa..&#xA;The error message I get is &quot;multiple definition of `__vector_32'&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got a clue??! &#xA;Thanks! &lt;/p&gt;&#xA;" OwnerUserId="9922" LastActivityDate="2015-05-26T20:03:47.153" Title="Running a servo and tone() won't compile? &quot;multiple definition of `__vector_32'&quot;?" Tags="|servo|arduino-pro-micro|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12151" PostTypeId="2" ParentId="12147" CreationDate="2015-05-26T14:41:01.637" Score="1" Body="&lt;p&gt;I guess there are a number of ways to tackle the problem. Using the Ethernet shield is probably the most intuitive option, but this isn't something I have explored in too much detail - I would usually opt for other micros at this stage and I am confident you will get an answer from someone else detailing this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the most out of the Arduino and leverage what the Arduino is good at, I would probably make a C# console application or Windows service which communicates with the Arduino over serial, and use the 'System.Web.Http.SelfHost' assembly to make the data available through a RESTful web service which a html page could use &lt;a href=&quot;https://jquery.com/&quot; rel=&quot;nofollow&quot;&gt;JQuery&lt;/a&gt; to poll for information. It would be pretty easy to extend this to push the data to the page using &lt;a href=&quot;http://signalr.net/&quot; rel=&quot;nofollow&quot;&gt;SignalR&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fundamental drawback of this architecture is that your device isn't serving the website, so these must be hosted somewhere else, or run from flat files. Also a PC must be attached to facilitate the data transfer over serial and provide the web service.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get started you will want to familiarise yourself with c# and the SelfHost module, and WebApi 2.0 if you aren't already, this is all covered &lt;a href=&quot;http://www.asp.net/web-api/overview/older-versions/self-host-a-web-api&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, and of course you will need &lt;a href=&quot;https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx&quot; rel=&quot;nofollow&quot;&gt;Visual Studio Community&lt;/a&gt; edition or greater to start creating projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, write a &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx&quot; rel=&quot;nofollow&quot;&gt;Windows Service&lt;/a&gt; or &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/0wc2kk78(v=vs.90).aspx&quot; rel=&quot;nofollow&quot;&gt;Console Application&lt;/a&gt; which implements an object model holding your data, and updates this periodically with the &lt;a href=&quot;http://playground.arduino.cc/Interfacing/Csharp&quot; rel=&quot;nofollow&quot;&gt;Arduino via serial&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Self Host module is pretty incredible in that it allows you to add a web interface to any .Net application very easily, and directly manipulate your model. The tutorial linked above is very easy to follow, and can easily be adapted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For testing and development purposes, I would highly recommend &lt;a href=&quot;https://www.getpostman.com/&quot; rel=&quot;nofollow&quot;&gt;Postman&lt;/a&gt;, which can be used to test and trigger your API endpoints. It's a comprehensive and well polished tool specifically for this job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of the network logistics, I would then use JQuery to make periodic posts to the self-host service in the same fashion that Postman would. You can use the function call backs to trigger successive queries on completion to maximise the data refresh rate without causing excessive consumption. A time interval would be another option you could consider between requests, and is discussed in &lt;a href=&quot;http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; article on polling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical Ajax request structure would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$.ajax({&#xA;    url: 'yourApiMethodAddress',&#xA;    type: 'get',&#xA;    error: function (jqXHR, status, ex) {&#xA;        /* Something went wrong. Maybe you could stop &#xA;           the update process and show a message and&#xA;           a retry button. */&#xA;        console.log(&quot;Error: &quot; + status);&#xA;        console.log(ex);&#xA;    },&#xA;}).done(function (data) {&#xA;    // Update page with information stored in 'data'. View console for hints&#xA;    console.log(data);&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would recommend using &lt;a href=&quot;http://getbootstrap.com/&quot; rel=&quot;nofollow&quot;&gt;Twitter Bootstrap&lt;/a&gt; in your webpage file to pretty things up and maintain readability. Don't forget to include the javascript and css files for both Bootstrap and JQuery in your html document (if used).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, I would recommend implementing an application which runs on a computer attached via USB/Serial to the Arduino, with the .Net Self Host module utilised to provide a RESTful API. This API can then be polled from a html page using javascript and JQuery to obtain the information and update the page. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this information helps, and as there a lot of moving parts I didn't provide many code examples for simplicity sake. If you find this useful and would like more information adding, mention it in the comments and I will update my answer.&lt;/p&gt;&#xA;" OwnerUserId="10007" LastEditorUserId="10007" LastEditDate="2015-05-26T14:52:43.950" LastActivityDate="2015-05-26T14:52:43.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12152" PostTypeId="2" ParentId="12150" CreationDate="2015-05-26T14:49:10.630" Score="1" Body="&lt;p&gt;The libraries are not compatible with each other, welcome to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont use either library, and usually avoid libraries altogether because of things like this. I will assume you want a solution, not a clue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quickest route is to pick one of the libraries, and globally modify __vector_32 to something like __vector_32x. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That probably is not the best solution but the quickest. The best solution would be to understand how it is used in both libraries, and modify them to work together. In the end it might be as simple as wrapping it with some #ifdef, but that requires understanding it enough to get to that conclusion, and it will take some time.  Maybe someone else already has.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-05-26T14:49:10.630" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12153" PostTypeId="2" ParentId="9632" CreationDate="2015-05-26T15:23:05.953" Score="0" Body="&lt;p&gt;The programmers supported by the Arduino IDE are listed under &lt;code&gt;Tools&lt;/code&gt; | &lt;code&gt;Programmer&lt;/code&gt;. In order to upload your sketch using the programmer either Shift-click the upload button, select &lt;code&gt;File&lt;/code&gt; | &lt;code&gt;Upload Using Programmer&lt;/code&gt;, or press &lt;kbd&gt;Ctrl&lt;/kbd&gt;&lt;kbd&gt;Shift&lt;/kbd&gt;&lt;kbd&gt;U&lt;/kbd&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-26T15:23:05.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12154" PostTypeId="2" ParentId="12150" CreationDate="2015-05-26T16:22:53.003" Score="2" Body="&lt;p&gt;The problem you're seeing arises when two codes (e.g. libraries) try to use the same interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the source code of the two libraries, you'll find that they both make use of a number of ISRs (interrupt service routines): &lt;code&gt;Tone.cpp&lt;/code&gt; uses&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMERn_COMPA_vect) {...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for n = 0..5, while &lt;code&gt;Servo.cpp&lt;/code&gt; uses&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMERn_COMPA_vect) {...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for n = 1, 3, 4, 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what happens when you compile this code is that they both libraries generate identical symbols (the &lt;code&gt;__vector_32&lt;/code&gt; part) which then clash when the compiled code is linked to give the final binary you'd upload to your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no simple way around this because the interrupt handlers need to be  registered at certain fixed positions in flash memory and there can only be exactly one interrupt handler for each of these slots (these slots are simply entries in a look-up table with the addresses of the interrupt handlers in flash, cf. Table 9-1 in the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to solve this problem you would need to find a way to either merge the interrupt handlers of the two libraries (not so easy I guess), or make them use different interrupts (without looking further into what options the pro micro offers, the code suggests that there are several TIMER interrupts which could be assigned one to the Servo, one to the Tone, &lt;em&gt;if&lt;/em&gt; that is supported by the hardware).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case you'll not get around modifying the libraries (or writing your own code for one functionality or the other).&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-05-26T16:36:20.260" LastActivityDate="2015-05-26T16:36:20.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12155" PostTypeId="2" ParentId="9963" CreationDate="2015-05-26T18:19:50.470" Score="0" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;turn sensor OFF when robot is moving  &lt;/li&gt;&#xA;&lt;li&gt;turn sensor ON while robot is standing still &lt;/li&gt;&#xA;&lt;li&gt;look for some prey&lt;/li&gt;&#xA;&lt;li&gt;repeat from 1 one&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Same schema goes with rotating :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;rotate to some angle,&lt;/li&gt;&#xA;&lt;li&gt;stop rotation&lt;/li&gt;&#xA;&lt;li&gt;detect&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;xD I was wondering bout it too, but only thinking, not implemented yet!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that simple is best, but something advanced with faster reaction would be better! &lt;/p&gt;&#xA;" OwnerUserId="10293" LastEditorUserId="10293" LastEditDate="2015-07-20T19:01:26.703" LastActivityDate="2015-07-20T19:01:26.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12156" PostTypeId="2" ParentId="12150" CreationDate="2015-05-26T18:51:39.413" Score="1" Body="&lt;p&gt;The link you provided shows a board built around the ATmega32U4.&#xA;On this chip, “__vector_32” is the low-level name of an ISR&#xA;(Interrupt Service Routine) named “TIMER3_COMPA_vect”. Your problem&#xA;comes from having two libraries trying to define an ISR for the same&#xA;interrupt, which is generated by the timer&amp;nbsp;3 of the chip. Merging&#xA;the ISRs is actually unlikely to work, because since each library&#xA;configures the timer in its own way, the timing of the interrupts will&#xA;be wrong for at least one of the libraries. You really have to use&#xA;different timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my copy of Tone.cpp I can read:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#elif defined(__AVR_ATmega32U4__)&#xA;&#xA;#define AVAILABLE_TONE_PINS 1&#xA;#define USE_TIMER3&#xA;&#xA;const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };&#xA;static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which shows that the code is configured to use timer 3 on this&#xA;particular chip. In Servo.h I have:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#elif defined(__AVR_ATmega32U4__)  &#xA;#define _useTimer1 &#xA;typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which shows it should use timer 1, and not conflict with Tone.cpp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems we have different versions of Servo.h. Mine is from Arduino&#xA;1.0.5. You may try to fix the problem by modifying the relevant section&#xA;of either file (just after &lt;code&gt;#elif defined(__AVR_ATmega32U4__)&lt;/code&gt;) and&#xA;have them use different timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: It appears this issue has already been fixed... on June 2012!&#xA;See this diff: &lt;a href=&quot;https://github.com/arduino/Arduino/commit/f60f17f79ae383a948a9cc4baa8bd0983fad6465&quot; rel=&quot;nofollow&quot;&gt;Avoid TIMER3 conflict with Servo and&#xA;tone()&lt;/a&gt;&#xA;on the Arduino GitHub repository. The simplest fix in your case may be&#xA;to just upgrade your Arduino software. You could also manually apply&#xA;that (really small) diff to your current copy.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-05-26T20:03:47.153" LastActivityDate="2015-05-26T20:03:47.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12157" PostTypeId="2" ParentId="12115" CreationDate="2015-05-26T22:37:38.773" Score="2" Body="&lt;p&gt;There are several audio products/shields.  Because you mention &quot;speakers&quot;, the first one listed can come with an on-board amplifier to drive speakers directly.  Most shields just give line-out to drive a pre-amp.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adafruit Music maker shield plays MP3/WAV/OGG from microSD &lt;a href=&quot;http://www.adafruit.com/products/1788&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/1788&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Adafruit Wave shield plays WAV files on SD card &lt;a href=&quot;http://www.adafruit.com/products/94&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/94&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SparkFun MP3 trigger board supports 256 tracks and a serial protocol for running individual tracks. &lt;a href=&quot;https://www.sparkfun.com/products/11029&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11029&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SparkFun MP3 shield board plays MP3/WAV/OGG &lt;a href=&quot;https://www.sparkfun.com/products/10628&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10628&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2015-05-26T22:37:38.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12158" PostTypeId="1" CreationDate="2015-05-25T21:03:57.803" Score="0" ViewCount="102" Body="&lt;p&gt;Anyways cutting to the chase I am pretty good at C++ as I have been doing it for over 6 months pretty much 1-2 hours each day and I am looking for cool things to use my knowledge on ,I have heard of the Arduino's but the problem is I don't know my arse from my elbow when it comes to electrical engineering and all that so I have a couple of questions.&#xA;1. Do I need to have a background in engineering to use an Arduino.&#xA;2. Is there any cheap alternatives to the quite costly starter kit.&lt;/p&gt;&#xA;" OwnerDisplayName="Luke" LastEditorUserId="10794" LastEditDate="2015-09-12T00:49:46.267" LastActivityDate="2015-09-12T00:49:46.267" Title="Arduino Uno questions" Tags="|arduino-uno|c++|hardware|clones|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12159" PostTypeId="2" ParentId="12158" CreationDate="2015-05-25T21:10:03.057" Score="0" Body="&lt;p&gt;1) You do not have to have engineering background. You only need to know basics such as what a resistor is, what a transistor is, how an led works etc. (Of course the answer depends on what you want to do. For instance, if you want to work on a robotic project then yes, you need a little knowledge.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Shopping questions are not answered here, but since you are asking something about &quot;cost&quot; then I have two answers. You can find cheaper solutions, but I, personally, always support original products for two reasons. First, you need to support the people who serves your work. Second is that original products are generally more reliable.&lt;/p&gt;&#xA;" OwnerUserId="1052" OwnerDisplayName="Zgrknr" LastActivityDate="2015-05-25T21:10:03.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12160" PostTypeId="2" ParentId="12158" CreationDate="2015-05-25T21:24:06.597" Score="0" Body="&lt;p&gt;First question, no. Tons of tutorials for a from scratch beginner online. Second question, Google Arduino clones.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastActivityDate="2015-05-25T21:24:06.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12161" PostTypeId="2" ParentId="12158" CreationDate="2015-05-25T22:03:32.353" Score="1" Body="&lt;p&gt;If you are the &quot;hacker&quot; type (i.e. you are good at self-learning and you like to explore things) even if you are an absolute newbie I advice &lt;em&gt;against&lt;/em&gt; those starter kits. They usually contain lots of overpriced parts, which you can get much more cheaply ordering directly to digikey, mouser or the like for your country (or maybe at your local shop). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand I strongly recommend buying an original Arduino board (for beginners an &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO&lt;/a&gt; is optimal, IMO, and comes at a reasonable price around 20-25EUR). This because the quality is guaranteed and you risk less problems. There are really good clones out there, but also tons of crappy ones, so I'll leave them to when you get more experience. Nothing is more frustrating while learning that wasting hours to debug a supposedly idiotproof project only to discover that &lt;em&gt;it was not your fault&lt;/em&gt;, but the board's!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: if you go for an Arduino UNO choose the version with a socketed plastic DIP package MCU (that big, long chip with two parallel rows of pins), instead of the SMT version, using an MCU packaged as a tiny plastic square. The version with the socket may come handy if you accidentally fry the MCU: a new one will cost you less than 4EUR and it's easily replaceable (it is not soldered on the board). The SMT, on the other hand, is a PITA to replace and you'd need special hardware to do that. Moreover, the socketed version can be used as a &quot;poor man's&quot; programmer for ATMega328 MCUs. You program it on the board and then place it on an external circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are an absolute beginner at EE, you can find lots of beginner tutorials on the Internet. Concentrate on key basic aspects. Most electronic projects can be handled with less math than you expect. You absolutely need to know Kirchhoff's laws and Ohm's law and a couple of related formulas if you want to begin &lt;em&gt;learning&lt;/em&gt; electronics, but nothing more fancy. The rest can be learned on the way. Keep in mind that there are people out there that know much less than that and that are able to put together an electronics project successfully only by following &quot;instructables&quot; found on the Internet (really hardcore tinkerers! :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, one thing you may find interesting, given your C++ background, is that what they call the &quot;Arduino language&quot; is really true C++! The Arduino environment &lt;a href=&quot;http://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;&quot;enhances&quot; the source program&lt;/a&gt; (the &quot;sketch&quot;, as they call it) and inserts all the boilerplate code needed to configure the MCU and other low-level stuff a beginner would have hard time digesting. Then the source program so enhanced is fed to AVR-GCC, in its G++ incarnation, which is nothing more that GNU GCC configured as cross-compiler for AVR MCUs. You can even use templates and derived classes, if you dare :-) Of course they don't tell you, otherwise the poor Arduino beginner would be scared away :-D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very advanced Arduino users can bypass the Arduino environment completely and write directly C++ code and use the board as a simple prototyping board for the MCU it is based upon (ATMega328P for the Arduino UNO), exploiting all the features of the MCU without all the abstraction layers which comprises the Arduino environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A note of caution: when I talk about C++ I mean what is technically known as a &lt;strong&gt;&lt;em&gt;freestanding C++ implementation&lt;/em&gt;&lt;/strong&gt;, as opposed to a &lt;strong&gt;&lt;em&gt;hosted implementation&lt;/em&gt;&lt;/strong&gt; like on PC's. This means that the implementation doesn't need an OS to work, but also that it doesn't have all the standard libraries that you expect to find on a hosted implementation (sorry, no std::vector or std::cout !!!). A freestanding implementation must only provide a very limited subset of the usual standard libraries (those that handle lower level stuff, like memory allocation), and normally relies on implementation-specific libraries to do other stuff. In particular with the Arduino environment and the underlying AVR-GCC comes the &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;AVR-LIBC library&lt;/a&gt;. But this is needed only when you do advanced stuff. The basic &lt;a href=&quot;http://www.arduino.cc/en/Reference/HomePage&quot; rel=&quot;nofollow&quot;&gt;Arduino library&lt;/a&gt; will keep you busy for a nice amount of time until you reach such a level of expertise.&lt;/p&gt;&#xA;" OwnerUserId="1736" OwnerDisplayName="Lorenzo Donati" LastActivityDate="2015-05-25T22:33:26.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12162" PostTypeId="2" ParentId="12158" CreationDate="2015-05-25T22:13:52.823" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know my arse from my elbow when it comes to electrical engineering and all that so I have a couple of questions. 1. Do I need to have a background in engineering to use an Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer to your first question: it depends on what you want to achieve, and how much time you are willing to spend stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit of electrical/electronic background can help you a lot.  Basics such as Ohm's, Kirchhoff's.  Semiconductor devices (diodes, transistors, OpAmps).  It's very useful to understand what kinds of test&amp;amp;measurement equipment exists and how it can be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pursue C++ for 6 months 1-2 hours a day.  You can pursue electrical knowledge in the same way as well.  A solid book like &quot;The Art of Electronics&quot; will help you a lot (doesn't have to be the latest edition).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can pursue more exciting things: sensors (for example).&lt;/p&gt;&#xA;" OwnerDisplayName="Nick Alexeev" LastActivityDate="2015-05-25T22:21:33.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12163" PostTypeId="1" CreationDate="2015-05-27T00:55:06.673" Score="1" ViewCount="1593" Body="&lt;p&gt;I have 2 arduinos I made some code and I managed to send from the first to the second and from the second to the first with two different pairs of code. What I want to do is to send from the first to the second and from the second to the first with no code change. I added in my current code some monitoring commands but what I can see in my Serial monitor is that not all characters are passed thru. I attach something like my code below only more simplified because it is a big project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1st arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.stopListening();&#xA;  for(int i=0; i&amp;lt;lnth; i++){&#xA;      chartosend=data.charAt(i);&#xA;      radio.write( &amp;amp;chartosend, sizeof(chartosend) );&#xA;  }&#xA;  radio.write(&amp;amp;endchar,1);&#xA;radio.startListening();&#xA;  if(radio.available()){&#xA;    radio.read( &amp;amp;inchar, sizeof(inchar) );&#xA;    inradio+=inchar;&#xA;    //Serial.println(inchar);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2nd Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.startListening();&#xA;  if(radio.available()){&#xA;    radio.read( &amp;amp;data, sizeof(data) );&#xA;    inradio+=data;&#xA;  }&#xA;radio.stopListening(); &#xA;  if(analogRead(0)&amp;gt;20){&#xA;     for(int i=0; i&amp;lt;6; i++){&#xA;      chartosend=pir1.charAt(i);&#xA;      radio.write( &amp;amp;chartosend, sizeof(chartosend) );&#xA;    }&#xA;    radio.write( &amp;amp;endchar, sizeof(endchar) );&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where is the problem and how I could solve this?&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-27T08:50:44.077" Title="Cannot receive and transmit at the same time" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12164" PostTypeId="1" CreationDate="2015-05-27T05:55:03.880" Score="1" ViewCount="628" Body="&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(13, OUTPUT);  // Red&#xA;  pinMode(14, OUTPUT);  // Yellow&#xA;  pinMode(15, OUTPUT);  // Green&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);&#xA;  digitalWrite(14, LOW);&#xA;  digitalWrite(15, LOW);  // Stop&#xA;  delay(20000);           // Wait 20 seconds&#xA;  digitalWrite(13, HIGH);&#xA;  digitalWrite(14, HIGH);&#xA;  digitalWrite(15, LOW);  // Listen&#xA;  delay(20000);           // Wait 20 seconds&#xA;  digitalWrite(13, LOW);&#xA;  digitalWrite(14, LOW);&#xA;  digitalWrite(15, HIGH);  // Go&#xA;  delay(20000);            // Wait 20 seconds&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How good is this code and is there any error ?&lt;/p&gt;&#xA;" OwnerUserId="10298" LastActivityDate="2016-03-23T08:19:13.593" Title="Verify a code for Traffic Signal" Tags="|arduino-uno|led|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12165" PostTypeId="2" ParentId="12164" CreationDate="2015-05-27T06:25:40.040" Score="0" Body="&lt;p&gt;I have a similar requirement, this gives you a little more flexibility , My traffic light code is controlled by a PIR outside my door , if the PIR detects an individual the lights turn to stop when the PIR clears the lights turn to green.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the code and hardware are still in the test phase.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;#include&amp;nbsp;&amp;lt;&lt;b&gt;EasyTransfer&lt;/b&gt;.h&amp;gt;&#xA;&#xA;int D_Status_Word = 0;&#xA;int Status_Word = 0; //sets all bits to  zero&#xA;int Light_Threshold = 150; //the light level that constitutes an unusual entry&#xA;int Active = 0;&#xA;int Passive = 100;&#xA;int Counter = 100;&#xA;int Green_Pin = 7;&#xA;int Amber_Pin = 8;&#xA;int Red_Pin = 9;&#xA;int Photocell_Pin = 1;     // the cell and 10K pulldown are connected to a0&#xA;int Photocell_Reading;&#xA;int Sensor_Frequency = 0;&#xA;&#xA;struct&amp;nbsp;SEND_DATA_STRUCTURE&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;//put your variable definitions here for the data you want to receive&#xA;&amp;nbsp;&amp;nbsp;//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO&#xA;&amp;nbsp;&amp;nbsp;int Out_Word;&#xA;&amp;nbsp;&amp;nbsp;int LDR_Level;&#xA;};&#xA;&#xA;SEND_DATA_STRUCTURE&amp;nbsp;My_Tx_Data;&#xA;&#xA;//create&amp;nbsp;an&amp;nbsp;object&amp;nbsp;for&amp;nbsp;themessage&#xA;&lt;b&gt;EasyTransfer&lt;/b&gt; ETout;&#xA;int D_Sensor_Pin [] = {&#xA;&amp;nbsp;&amp;nbsp;2,&amp;nbsp;3,&amp;nbsp;5,&amp;nbsp;6&#xA;};&#xA;//&amp;nbsp;pin&amp;nbsp;hallwaypir,&amp;nbsp;3&amp;nbsp;doorpir,&amp;nbsp;5&amp;nbsp;door&amp;nbsp;sensor,&amp;nbsp;6&amp;nbsp;hallpir&#xA;&#xA;void setup() {&#xA;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.begin (9600);&#xA;&amp;nbsp;&amp;nbsp;// put your setup code here, to run once:&#xA;&amp;nbsp;&amp;nbsp;ETout.begin(details(My_Tx_Data), &amp;amp;&lt;b&gt;Serial&lt;/b&gt;);&#xA;&amp;nbsp;&amp;nbsp;for (int i = 0; i &amp;lt;= 3; i++)// read the two state sensors&#xA;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pinMode(D_Sensor_Pin [i], INPUT);&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;pinMode(A1, INPUT);//set the analoge u ldr pin ot input mode&#xA;&amp;nbsp;&amp;nbsp;pinMode (Green_Pin, OUTPUT);&#xA;&amp;nbsp;&amp;nbsp;pinMode (Amber_Pin , OUTPUT);&#xA;&amp;nbsp;&amp;nbsp;pinMode (Red_Pin , OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&amp;nbsp;&amp;nbsp;Scan_Sensors();&#xA;&amp;nbsp;&amp;nbsp;if (D_Status_Word != Status_Word)&#xA;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sensor_Frequency&amp;nbsp;=&amp;nbsp;Active;&amp;nbsp;// high frequency sampling because a sensor has activated&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//send a data packet to the mega with mem card via serial.&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Send_Data_Packet();&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;if (bitRead (Status_Word, 1) != bitRead (D_Status_Word, 1))&#xA;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ((D_Status_Word, 1) == 1)&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Traffic_Light_Stop();&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Traffic_Light_Go();&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;Status_Word&amp;nbsp;=&amp;nbsp;D_Status_Word;&#xA;&#xA;&amp;nbsp;&amp;nbsp;delay(Sensor_Frequency);// 1000= waits for a second&#xA;}&#xA;&#xA;void Scan_Sensors()&#xA;{&#xA;&amp;nbsp;&amp;nbsp;byte readings = 0;&#xA;&amp;nbsp;&amp;nbsp;Photocell_Reading&amp;nbsp;&amp;nbsp;=&amp;nbsp;0;&#xA;&amp;nbsp;&amp;nbsp;for (int i = 0; i &amp;lt;= 3; i++)// read the two state sensors&#xA;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bitWrite(readings, i, digitalRead(D_Sensor_Pin [i] ));&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;//test to see if any sensors have trivggered (readings&amp;gt;0)&#xA;&amp;nbsp;&amp;nbsp;if (readings &amp;gt; 0)&#xA;&amp;nbsp;&amp;nbsp;{&amp;nbsp;// a 2 state sensor has triggered, reset the Counter to 100&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Counter&amp;nbsp;=&amp;nbsp;100;&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&#xA;&amp;nbsp;&amp;nbsp;//read threshold sensors&#xA;&amp;nbsp;&amp;nbsp;Photocell_Reading&amp;nbsp;&amp;nbsp;=&amp;nbsp;analogRead(Photocell_Pin);&#xA;&amp;nbsp;&amp;nbsp;{&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bitSet(readings, 4); // 4 becaus there are 4 2 state sensors (0 to 3)&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//we write 1 because thelight is below the threshold&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.print (&quot;photocell Reading = &quot;);&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.println(Photocell_Reading);&#xA;&amp;nbsp;&amp;nbsp;}&#xA;&amp;nbsp;&amp;nbsp;D_Status_Word&amp;nbsp;=&amp;nbsp;readings;&#xA;&amp;nbsp;&amp;nbsp;Counter&amp;nbsp;-=&amp;nbsp;1;&amp;nbsp;//decrement the Counter&#xA;&amp;nbsp;&amp;nbsp;if (Counter &amp;lt;= 0)&#xA;&amp;nbsp;&amp;nbsp;{&amp;nbsp;//the Counter has counted 100 scans since a 2state has triggered&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//rest freqenvcy to Passive&#xA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Sensor_Frequency&amp;nbsp;=&amp;nbsp;Passive;&#xA;&#xA;&amp;nbsp;&amp;nbsp;}&#xA;}&#xA;void Send_Data_Packet()&#xA;{&#xA;&amp;nbsp;&amp;nbsp;My_Tx_Data.Out_Word&amp;nbsp;=&amp;nbsp;D_Status_Word;&#xA;&amp;nbsp;&amp;nbsp;My_Tx_Data.LDR_Level&amp;nbsp;=&amp;nbsp;Photocell_Reading;&#xA;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.print (&quot;photocell Reading = &quot;);&#xA;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.println(Photocell_Reading);&#xA;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.print (&quot;status word = &quot;);&#xA;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.println(D_Status_Word);&#xA;&amp;nbsp;&amp;nbsp;ETout.sendData();&#xA;}&#xA;&#xA;void Traffic_Light_Stop()&#xA;{&#xA;&amp;nbsp;&amp;nbsp;//lights turn from green to yellow to red&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Green_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Amber_Pin, HIGH);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Red_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;delay(750);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Green_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Amber_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Red_Pin, HIGH);&#xA;}&#xA;&#xA;void Traffic_Light_Go()&#xA;{&#xA;&amp;nbsp;&amp;nbsp;//lights turn red to red and yellow to green&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Green_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Amber_Pin, HIGH);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Red_Pin, HIGH);&#xA;&amp;nbsp;&amp;nbsp;delay(750);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Green_Pin, HIGH);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Amber_Pin, LOW);&#xA;&amp;nbsp;&amp;nbsp;digitalWrite (Red_Pin, LOW);&#xA;&#xA;}&#xA;&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-05-27T06:25:40.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12166" PostTypeId="2" ParentId="12164" CreationDate="2015-05-27T06:27:13.793" Score="1" Body="&lt;p&gt;There is nothing wrong with your code. But it could use some cleaning to make it efficient. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code at the moment will be 'deaf' to any user inputs for twenty seconds between light changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be fixed by using a timer interrupt and changing the lights every 20 seconds and listen for other inputs or do other things. You can use the &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;arduino timer library&lt;/a&gt;, this is well documented and you should be able to find examples of its use. Basically you would monitor a variable until it reaches a point and then trigger the lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other option would be to use the &lt;code&gt;millis()&lt;/code&gt; and every 20 seconds change a light, but do stuff between those 20s. This can be done like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousMillis;  //hold the previous time&#xA;unsigned long currentMillis;   // hold the current time&#xA;&#xA;long threshold = 20000;&#xA;int count = 0;&#xA;&#xA;int pins[] = {13, 14, 15};&#xA;&#xA;//setup code stuff&#xA;&#xA;//put the following at the top of loop()&#xA;&#xA;currentMillis = millis();&#xA;&#xA;if(currentMillis - previousMillis &amp;gt; threshold){&#xA;&#xA;    previousMillis = currentMillis;&#xA;&#xA;    for(int i = 0; i &amp;lt; 3; i++){&#xA;    digitalWrite(pins[i], LOW);  //turn off all&#xA;&#xA;    }&#xA;&#xA;    if(count &amp;gt; 2) count = 0;&#xA;&#xA;    digitalWrite(pins[count], HIGH);&#xA;&#xA;    count++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2015-11-24T07:04:21.790" LastActivityDate="2015-11-24T07:04:21.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12167" PostTypeId="2" ParentId="12164" CreationDate="2015-05-27T06:37:28.407" Score="0" Body="&lt;p&gt;There is nothing wrong with the code that I can see although you do have some redundant statements:&#xA;When you go to &quot;Listen&quot; you set the red and green pins high and low respectively, but they are already high and low from the previous state.  Not a big issue, being verbose adds clarity so there is some argument for leaving it as is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would consider using #define macros to number the ports and set the delay times.  This adds readability and also means you can make changes easily without having to search through the code and match up appropriate instances of the port number that you want to change, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RED_PIN 13&#xA;#define DELAY_BETWEEN_CHANGES 20000&#xA;...&#xA;digitalWrite(RED_PIN, HIGH);&#xA;delay(DELAY_BETWEEN_CHANGES);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also means that you can get rid of comments in your code as it becomes pretty self explanatory.  I personally believe that comments are bad.  If you write code and put a comment explaining what it does, when you have to modify the code you also have to modify the comment.  Make the code understandable in the first place, no need for comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Final point (not related to code): What happens after &quot;Go&quot;?  I'm from the UK so we have another phase after Go.  It reminds me of an old driving test joke:&#xA;Instructor: What is the sequence of traffic lights?&#xA;Student: Red, red and amber, green.&#xA;Instructor: What comes after green?&#xA;Student: How would I know?  I've always gone by then!&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-27T06:37:28.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12168" PostTypeId="2" ParentId="12158" CreationDate="2015-05-27T07:38:13.990" Score="0" Body="&lt;p&gt;I am having loads of fun with Arduino from a background of programming with no electronics experience.  From simple &quot;flash some LEDs&quot; in the early days (back in Feb) through to making my own &quot;games console&quot; using a 32x32 LED matrix, FRAM memory chip, piezo buzzer and a home made controller for input.  I found that once I got started and browed various relevant sites, ideas started to flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using straight C rather than C++, especially if you are working on one of the particularly low memory devices (such as the Uno).  I ran out of working RAM more times than I care to remember.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for starter kits, if you search, you should be able to find cheap kits.  I got a pretty decent starter kit for around £20 but there were cheaper ones with a few less components.  Mine included (amongst other things) 30 LEDs, various IR and flame sensors, photo resistors, a 7 segment LED, a 4 digit 7 segment LED, an 8x8 LED matrix, a servo, a stepper motor, a stepper motor control board, a couple of breadboards and an Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-27T07:38:13.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12169" PostTypeId="2" ParentId="12163" CreationDate="2015-05-27T08:50:44.077" Score="1" Body="&lt;p&gt;I dunno know about the radio interface you are using. But I can see something which will break your code for sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sections, where you read data from the interface on both Arduinos are passed without a delay, interrupt, polling loop or something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means: your &quot;read&quot; code section is in no way synchronised with the write code section on the other arduino and vice versa. At the point when you call the function &quot;radio.available()&quot; (which probably tests if there's any data available at the receiver fifo) there is possibly one or any number of bytes available, but not necessary the whole transmission from the other arduino. You have to make sure — somehow — that the transmission is finished, before you can call it a day and go on with processing the received data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this you have to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;synchronise the beginning and the end of your transmissions on both Arduinos&lt;/li&gt;&#xA;&lt;li&gt;poll the data on the respective receiver side, until you are satisfied&lt;/li&gt;&#xA;&lt;li&gt;or run into a timeout you have to apply in case there's a byte or more lost by chance.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I hope this gives you a little bit of orientation where to start.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-05-27T08:50:44.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12170" PostTypeId="1" CreationDate="2015-05-27T09:36:54.363" Score="0" ViewCount="287" Body="&lt;p&gt;I am using this real-time-clock module to keep track of the time for a project:&#xA;&lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Real_Time_Clock_Module_(DS1307)_V1.1_(SKU:DFR0151)&quot; rel=&quot;nofollow&quot;&gt;http://www.dfrobot.com/wiki/index.php/Real_Time_Clock_Module_(DS1307)&lt;em&gt;V1.1&lt;/em&gt;(SKU:DFR0151)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have hooked up the respective pins correctly to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the code I'm using. This first one is the code used to set the time on the module. It writes the initial time you specify to the RTC module.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define DS1307_ADDRESS 0x68&#xA;byte zero = 0x00;         //workaround for issue #527&#xA;&#xA;void setup(){&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  setDateTime();         //MUST CONFIGURE IN FUNCTION&#xA;}&#xA;&#xA;void loop(){&#xA;  printDate();&#xA;  delay(1000);&#xA;}&#xA;&#xA;void setDateTime(){          //Set the time to a minute or two ahead. After upload has completed, simply press the reset button to start the time while watching another clock.&#xA;  byte second = 0;     //0-59&#xA;  byte minute = 56;     //0-59&#xA;  byte hour = 13;     //0-23&#xA;  byte monthDay = 26;     //1-31&#xA;  byte month = 5;     //1-12&#xA;  byte year = 15;     //0-99&#xA;  Wire.beginTransmission(DS1307_ADDRESS);&#xA;  Wire.write(zero);     //stop Oscillator&#xA;  Wire.write(decToBcd(second));&#xA;  Wire.write(decToBcd(minute));&#xA;  Wire.write(decToBcd(hour));&#xA;  Wire.write(decToBcd(monthDay));&#xA;  Wire.write(decToBcd(month));&#xA;  Wire.write(decToBcd(year));&#xA;  Wire.write(zero);       //start &#xA;  Wire.endTransmission();&#xA;}&#xA;&#xA;byte decToBcd(byte val){&#xA;return ((val/10*16)+(val%10));        //Convert normal decimal numbers to binary coded decimal&#xA;}&#xA;&#xA;byte bcdToDec(byte val)  {&#xA;  return ((val/16*10)+(val%16));        //Convert binary coded decimal to normal decimal numbers&#xA;}&#xA;&#xA;void printDate(){&#xA;  Wire.beginTransmission(DS1307_ADDRESS);        // Reset the register pointer&#xA;  Wire.write(zero);&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(DS1307_ADDRESS, 7);&#xA;  int second = bcdToDec(Wire.read());&#xA;  int minute = bcdToDec(Wire.read());&#xA;  int hour = bcdToDec(Wire.read() &amp;amp; 0b111111);     //24 hour time&#xA;  int monthDay = bcdToDec(Wire.read());&#xA;  int month = bcdToDec(Wire.read());&#xA;  int year = bcdToDec(Wire.read());&#xA;  Serial.print(month);        //print the date, EG: 3/1/11 23:59:59&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(monthDay);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(year);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(hour);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(minute);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.println(second);&#xA;}&#xA;&#xA;//http://projectsfromtech.blogspot.com/2013/06/arduino-rtc-tinyrtc-v1-with-arduino.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this next block reads the time from the RTC module. It has an onboard battery, so it keeps time even when disconnected from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define DS1307_ADDRESS 0x68&#xA;&#xA;void setup(){&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  printDate();&#xA;  delay(1000);&#xA;}&#xA;&#xA;byte bcdToDec(byte val){&#xA;  return ((val/16*10)+(val%16));          //Convert binary coded decimal to normal decimal numbers&#xA;}&#xA;&#xA;void printDate(){&#xA;  Wire.beginTransmission(DS1307_ADDRESS);          // Reset the register pointer&#xA;  byte zero = 0x00;&#xA;  Wire.write(zero);&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(DS1307_ADDRESS, 7);&#xA;  int second = bcdToDec(Wire.read());&#xA;  int minute = bcdToDec(Wire.read());&#xA;  int hour = bcdToDec(Wire.read() &amp;amp; 0b111111);     //24 hour time&#xA;  int monthDay = bcdToDec(Wire.read());&#xA;  int month = bcdToDec(Wire.read());&#xA;  int year = bcdToDec(Wire.read());&#xA;  Serial.print(month);          //print the date, EG: 3/1/11 23:59:59&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(monthDay);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(&quot;20&quot;);&#xA;  Serial.print(year);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(hour);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(minute);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.println(second);&#xA;}&#xA;&#xA;//http://projectsfromtech.blogspot.com/2013/06/arduino-rtc-tinyrtc-v1-with-arduino.html&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The weird thing is, when I open the serial monitor after I upload the getTime sketch (the second one), every thing works except that the dayOfMonth only shows the last digit. For example, if the day was the 23rd, it would only print 3. Or if it was 31, it prints 1. I've gone through the code, but can't find anything that I think would cause this. Any tips?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get started, I followed this tutorial: &lt;a href=&quot;http://projectsfromtech.blogspot.com/2013/06/arduino-rtc-tinyrtc-v1-with-arduino.html&quot; rel=&quot;nofollow&quot;&gt;http://projectsfromtech.blogspot.com/2013/06/arduino-rtc-tinyrtc-v1-with-arduino.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6324" LastActivityDate="2015-05-27T14:29:24.703" Title="Cannot print the first number of the date with RTC module" Tags="|arduino-uno|serial|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12173" PostTypeId="2" ParentId="12170" CreationDate="2015-05-27T14:29:24.703" Score="3" Body="&lt;p&gt;You forgot&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int weekDay = bcdToDec(Wire.read()); //0-6 -&amp;gt; Sunday - Saturday&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just before reading &lt;code&gt;monthDay&lt;/code&gt;. Even though you may not be interested in&#xA;this piece of data, the RTC chip has no way of knowing that, and it will&#xA;always send the date and time in the same format. You can replace that&#xA;line by&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Wire.read(); // discard day of week&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if you want to make clear that you are discarding this information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ah, BTW, &lt;code&gt;decToBcd()&lt;/code&gt; and &lt;code&gt;bcdToDec()&lt;/code&gt; are ill-named: they convert&#xA;between BCD and &lt;em&gt;binary&lt;/em&gt;, not &lt;em&gt;decimal&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-27T14:29:24.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12174" PostTypeId="1" CreationDate="2015-05-27T15:19:31.740" Score="2" ViewCount="138" Body="&lt;p&gt;I'm making USART support for SAM3x8e based Arduino Due board.&#xA;I looked into arduino source code, exactly&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino-1.5.7/hardware/arduino/sam/variants/arduino_due_x/variant.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and see that for Serial0 UART component is used, for Serial1 USART0 is used, for Serial2 - USART1 and for Serail3 - USART3. The USART2 is not even mentioned. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why is this done that way? &lt;/li&gt;&#xA;&lt;li&gt;I would like to realize what those comonents (USARTx &amp;amp; UART) are? Is UART is the subset of one of USARTs?&lt;/li&gt;&#xA;&lt;li&gt;What is relation between USARTn &amp;amp; UART components and arduino board's TXn/RXn pins? Exactly, what pins are those component mapped to?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanx.&lt;/p&gt;&#xA;" OwnerUserId="7695" LastEditorUserId="7695" LastEditDate="2015-05-27T18:31:26.810" LastActivityDate="2015-05-27T18:31:26.810" Title="Adrudio Due: How do MCU components USARTx &amp; UART relate to board pins TXn/RXn?" Tags="|arduino-due|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12175" PostTypeId="1" AcceptedAnswerId="12176" CreationDate="2015-05-27T17:03:22.547" Score="0" ViewCount="569" Body="&lt;p&gt;I am trying to make a mini project with attiny84 and I searched the web so I can make an arduino on breadboard. What I saw on the internet is that they didnt use crystal. Is it mandatory if I want to use 1 pwm pin and the SPI interface on the attiny84?&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-27T17:12:32.373" Title="Is crystal mandatory on attiny84?" Tags="|pwm|attiny|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12176" PostTypeId="2" ParentId="12175" CreationDate="2015-05-27T17:12:32.373" Score="2" Body="&lt;p&gt;Only if you need crystal accuracy. If the internal RC oscillator is accurate enough then feel free to use it instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-27T17:12:32.373" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12177" PostTypeId="1" CreationDate="2015-05-27T21:01:32.740" Score="2" ViewCount="12978" Body="&lt;p&gt;My Due is interfaces with a DAC which I need to update with freq 1MHz. The nice solution seems to be a timer interrupt. I found a thread here called &quot;Arduino Due - creating an 8Mhz clock signal&quot;. I tried the following code to see if I can get 4MHz on P41. No luck. Any help will be greatly appreciated. Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile boolean l = false;&#xA;&#xA;void TC6_Handler()&#xA;{&#xA;    TC_GetStatus(TC2, 0);&#xA;    digitalWrite(41, l = !l);&#xA;}&#xA;&#xA;void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq) {&#xA;    pmc_set_writeprotect(false);&#xA;    pmc_enable_periph_clk((uint32_t)irq);&#xA;&#xA;    TC_Configure(tc, channel,&#xA;    TC_CMR_WAVE |&#xA;    TC_CMR_WAVSEL_UP_RC |&#xA;    TC_CMR_TCCLKS_TIMER_CLOCK1|&#xA;    TC_CMR_ACPA_TOGGLE );  // RC compare TOGGLES TIOA);&#xA;&#xA;    TC_SetRA(tc, channel, 1); //50% high, 50% low&#xA;    TC_SetRC(tc, channel, 1);&#xA;&#xA;&#xA;    PIO_Configure(PIOC,&#xA;    PIO_PERIPH_B,&#xA;    PIO_PC25B_TIOA6,&#xA;    PIO_DEFAULT);&#xA;&#xA;TC_Start(tc, channel);&#xA;&#xA;}&#xA;&#xA;void setup(){&#xA;pinMode(41,OUTPUT);&#xA;startTimer(TC2, 0, TC6_IRQn);&#xA;}&#xA;&#xA;void loop(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10310" LastActivityDate="2017-07-21T15:07:00.077" Title="Arduino DUE Interrupt 1MHz" Tags="|arduino-due|interrupt|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12178" PostTypeId="1" CreationDate="2015-05-27T21:17:32.393" Score="6" ViewCount="1107" Body="&lt;p&gt;I am attempting to build an Android app from which I can can upload a .hex file to my Arduino(Leonardo). I am aware of a few apps in the Google Play store that are capable of this functionality but I can't seem to find any actionable resources on how to go about doing this. I am aware that the desktop Arduino IDE uses AVRDude to perform the upload but I don't believe AVRDude is available on Android so I'm at a complete loss here. Does anyone know how I would go about accomplishing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some more searching I now know that the Leonardo(ATMega32u4) uses the AVR109 Protocol to flash new programs onto the hardware but I'm still at a complete loss as to what that process is and how I'd reproduce it in Java.&lt;/p&gt;&#xA;" OwnerUserId="1720" LastEditorUserId="1720" LastEditDate="2015-05-29T19:14:52.547" LastActivityDate="2016-12-23T03:58:55.053" Title="Programmatically Upload Arduino Sketch From Android App" Tags="|arduino-leonardo|uploading|android|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12179" PostTypeId="1" AcceptedAnswerId="12180" CreationDate="2015-05-27T22:15:20.147" Score="0" ViewCount="409" Body="&lt;p&gt;I'm installing some daylight running lights in my car and I have purchased 2 LED bars, each with 8 white LEDs. They use 12V and I need to make some effect when they turn on. Like in some modern cars, when I turn on the key, LEDs should blink(shake like when old fluorescent tubes turns on) and then turn on slowly(brightness from 0-100).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do this with Arduino-Uno and I need to put this in a smaller chip. What would be the best suitable ATTiny chip for this project? Because using an ATmega328 is not worth for a small project like this.&lt;/p&gt;&#xA;" OwnerUserId="3806" LastActivityDate="2015-05-27T22:34:54.850" Title="ATTiny to drive LEDs" Tags="|arduino-uno|led|pwm|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12180" PostTypeId="2" ParentId="12179" CreationDate="2015-05-27T22:34:54.850" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;http://www.atmel.com/devices/attiny85.aspx&quot; rel=&quot;nofollow&quot;&gt;ATtiny85&lt;/a&gt; is an 8-pin AVR device with 3 PWM channels available in DIL and SO packages. The Arduino core can be downloaded from &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;arduino-tiny&lt;/a&gt;. It can be programmed via ISP using either &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;ArduinoISP&lt;/a&gt; or a dedicated programmer.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-27T22:34:54.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12181" PostTypeId="1" AcceptedAnswerId="32188" CreationDate="2015-05-27T22:57:55.987" Score="5" ViewCount="7489" Body="&lt;p&gt;I have two I2C LCD screens:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one with 2 lines&lt;/li&gt;&#xA;&lt;li&gt;one with 4 lines.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both have 4 pins each: &lt;code&gt;GND&lt;/code&gt;, &lt;code&gt;VCC&lt;/code&gt;, &lt;code&gt;SDA&lt;/code&gt;, &lt;code&gt;SDL&lt;/code&gt;. I connect &lt;code&gt;SDA&lt;/code&gt; and &lt;code&gt;SDL&lt;/code&gt; to &lt;code&gt;A4&lt;/code&gt; and &lt;code&gt;A5&lt;/code&gt; respectively, and I display text on each one of them with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;LiquidCrystal_I2C lcd(0x27,16,4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can I use both of them at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the second one's &lt;code&gt;SDA&lt;/code&gt; and &lt;code&gt;SDL&lt;/code&gt; to &lt;code&gt;A2&lt;/code&gt; and &lt;code&gt;A3&lt;/code&gt;, but apparently I have to provide the right address for them (like &lt;code&gt;0x27&lt;/code&gt;), right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, while both are connected, using &lt;a href=&quot;http://playground.arduino.cc/Main/I2cScanner&quot; rel=&quot;noreferrer&quot;&gt;I2C_Scanner&lt;/a&gt; only shows one device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scanning...&#xA;I2C device found at address 0x27  !&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="10242" LastEditorUserId="10242" LastEditDate="2015-05-27T23:10:48.123" LastActivityDate="2018-03-27T02:19:42.490" Title="How do I use two I2C LCDs with 4 pins?" Tags="|i2c|lcd|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12182" PostTypeId="2" ParentId="12181" CreationDate="2015-05-27T23:19:31.057" Score="0" Body="&lt;p&gt;You can't hook up I&lt;sup&gt;2&lt;/sup&gt;C devices to arbitrary pins; they must either be connected to SDA and SCL and given different addresses, or you must use software I&lt;sup&gt;2&lt;/sup&gt;C. Figure out how to give the second device a different address, and then instantiate another &lt;code&gt;LiquidCrystal_I2C&lt;/code&gt; with the new address in order to be able to use it.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-05-27T23:19:31.057" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="12183" PostTypeId="1" CreationDate="2015-05-27T23:34:03.900" Score="3" ViewCount="394" Body="&lt;p&gt;A few days ago, I've asked &lt;a href=&quot;https://arduino.stackexchange.com/questions/12117/arduino-yun-doesnt-link-any-library&quot;&gt;this question&lt;/a&gt;.&#xA;Thanks to the replies I've received, I've set up a cross compile environment for Yun by following &lt;a href=&quot;http://wiki.openwrt.org/doc/devel/crosscompile&quot; rel=&quot;nofollow noreferrer&quot;&gt;this guide&lt;/a&gt;. &lt;br /&gt;&#xA;I've created a virtual machine with virtualbox and installed Debian 8.0 on it. I installed all the software required to download and compile the OpenWRT-Attitude Adjustment version (which, I think, is the version used by Arduino Yun) on Debian. &lt;br /&gt;&#xA;So, I've downloaded the OpenWRT source code, downloaded its packages feed (with &quot;git clone git://git.openwrt.org/12.09/packages.git&quot;), downloaded and installed all available &quot;feeds&quot; (with: &quot;./scripts/feeds update -a&quot; &quot;./scripts/feeds install -a&quot;) and then compiled it with: &quot;make defconfig&quot; &quot;make prereq&quot;&#xA;and &quot;make menuconfig&quot;. &lt;br /&gt;&#xA;When I typed in &quot;make menuconfig&quot;, a graphical interface prompted. In that interface I selected: &lt;br /&gt;&#xA;Target System: (Atheros AR7xx/AR9xx); &lt;br /&gt;&#xA;Base System: I selected libc, libcc and marked as package libpthread and librt. &lt;br /&gt;&#xA;I left any other option as default. Then I compiled all with &quot;time make V=99&quot; command. &lt;br /&gt;&#xA;After about 2 hours, the compiling finished and I set the environment variables as the above mentioned guide described. &lt;br /&gt;&#xA;Looks like now I can compile any C code with this cross-compiler. Anyway, my application includes the png.h header in order to use the libpng library, and every time I try to cross-compile it, a &quot;png.h not found&quot; error pops up during the process. &lt;br /&gt;&#xA;So I tried to cross-compile the libpng library but when I ran &quot;./configure&quot; with the options for cross-compiling, it failed saying that zlib wasn't installed. So I downloaded the zlib library source code but looks like I can't cross-compile it. &lt;br /&gt;&#xA;Eventually I compiled zlib and libpng normally on Debian and now, when I try to cross-compile my application, it still says that it can't find png.h...&#xA;So, how can I &quot;integrate&quot; the libpng library to the cross-compiling environment? &lt;br /&gt;&#xA;Sorry for this long question, but it is all I've done today.&lt;br /&gt;&#xA;As always, I thank you for any help you can give me.&lt;/p&gt;&#xA;" OwnerUserId="10266" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-05-27T23:34:03.900" Title="How do I install a library in Arduino Yun cross compile environment?" Tags="|programming|arduino-yun|c|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12184" PostTypeId="1" AcceptedAnswerId="46009" CreationDate="2015-05-27T23:43:51.990" Score="0" ViewCount="545" Body="&lt;p&gt;I have been tinkering for 2 days to manage send and receive between 2 arduinos. My code is bellow:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &quot;printf.h&quot;&#xA;#define LED 2&#xA;#define RF_CS 8&#xA;#define RF_CSN 9&#xA;RF24 radio(8,9);&#xA;String datargb = &quot;rgb: 000000005&quot;;&#xA;char chartosend;&#xA;char inchar;&#xA;String inradio;&#xA;int endchar = '~';&#xA;void check_radio(void);&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;Serial.begin(115200);&#xA;  printf_begin();&#xA;  radio.begin();&#xA;  radio.setRetries(15,15);&#xA;  radio.openWritingPipe(0x080C600C01LL);&#xA;  radio.openReadingPipe(1,0x080C600C71LL);&#xA;  radio.setPALevel(RF24_PA_MAX);&#xA;  radio.setAutoAck(true);&#xA;  radio.printDetails();&#xA;  attachInterrupt(0, check_radio, FALLING);&#xA;  radio.stopListening();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;int lnth = datargb.length();&#xA;  for(int i=0; i&amp;lt;lnth; i++){&#xA;      chartosend=datargb.charAt(i);&#xA;&#xA;      while(!radio.write( &amp;amp;chartosend, sizeof(chartosend) )){}&#xA;&#xA;      Serial.println(&quot;sent&quot;);&#xA;  }&#xA;  radio.write(&amp;amp;endchar,1);&#xA;}&#xA;void check_radio(void){&#xA;&#xA;  bool tx,fail,rx;&#xA;  radio.whatHappened(tx,fail,rx);&#xA;&#xA;  if(rx){&#xA;    Serial.println(&quot;interrupt!!&quot;);&#xA;radio.startListening();&#xA;    radio.read( &amp;amp;inchar, sizeof(inchar) );&#xA;    inradio+=inchar;&#xA;    Serial.println(inchar);&#xA;    if(inradio.endsWith(&quot;~&quot;)){&#xA;      Serial.println(inradio);&#xA;&#xA;      if(inradio.startsWith(&quot;rgb: &quot;)){&#xA;        analogWrite(6,inradio.substring(5,8).toInt());&#xA;        analogWrite(9,inradio.substring(8,11).toInt());&#xA;        analogWrite(5,inradio.substring(11,14).toInt());&#xA;      }&#xA;      inradio = &quot;&quot;;&#xA;      radio.stopListening();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;//#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &quot;printf.h&quot; &#xA;//#include &amp;lt;RF24_config.h&amp;gt;&#xA;RF24 radio(8,10);&#xA;char data;&#xA;char chartosend;&#xA;char endchar = '~';&#xA;String inradio;&#xA;void check_radio(void);&#xA;String datargb = &quot;To mounti tis manas tou nrf24&quot;;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;  pinMode(6, OUTPUT);&#xA;  pinMode(7, INPUT);&#xA;  attachInterrupt(1, check_radio, FALLING);&#xA;  Serial.begin(115200);&#xA;  printf_begin();&#xA;  radio.begin();&#xA;   //radio.setRetries(2,15);&#xA;    // open pipe for writing&#xA;    radio.openReadingPipe(1,0x080C600C01LL);&#xA;    radio.openWritingPipe(0x080C600C71LL);&#xA;    radio.setPALevel(RF24_PA_MAX);&#xA;    radio.startListening();&#xA;    radio.printDetails();&#xA;    radio.setAutoAck(true);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;if(digitalRead(7)==HIGH){&#xA;  radio.stopListening();&#xA;  for(int i=0; i&amp;lt;28; i++){&#xA;      chartosend=datargb.charAt(i);&#xA;      while(!radio.write( &amp;amp;chartosend, sizeof(chartosend) )){}&#xA;      //Serial.println(&quot;sent&quot;);&#xA;  }&#xA;  radio.write(&amp;amp;endchar,1);&#xA;&#xA;&#xA;  while(digitalRead(7)==HIGH){}&#xA;  radio.startListening();&#xA;}&#xA;}&#xA;void check_radio(void){&#xA;&#xA;  bool tx,fail,rx;&#xA;  radio.whatHappened(tx,fail,rx);&#xA;&#xA;  if(rx){&#xA;    Serial.println(&quot;interrupt!!&quot;);&#xA;//radio.startListening();&#xA;    radio.read( &amp;amp;data, sizeof(data) );&#xA;    inradio+=data;&#xA;    Serial.println(data);&#xA;    if(inradio.endsWith(&quot;~&quot;)){&#xA;      Serial.println(inradio);&#xA;&#xA;      if(inradio.startsWith(&quot;rgb: &quot;)){&#xA;        analogWrite(6,inradio.substring(5,8).toInt());&#xA;        analogWrite(9,inradio.substring(8,11).toInt());&#xA;        analogWrite(5,inradio.substring(11,14).toInt());&#xA;      }&#xA;      inradio = &quot;&quot;;&#xA;      //radio.stopListening();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino 2 receives all data from ar1 but when I press the button attached to the pin 7 arduino 2 stops listening and only sends the first character of the string.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastEditorUserId="8275" LastEditDate="2015-05-29T21:24:45.903" LastActivityDate="2017-10-29T08:22:48.313" Title="Pressing button stops listening on nrf24l01" Tags="|arduino-pro-mini|button|nrf24l01+|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12185" PostTypeId="2" ParentId="12181" CreationDate="2015-05-28T03:31:37.147" Score="0" Body="&lt;p&gt;You may be able to wire them in parallel, if you can hold the clock (SCL) high (for one at a time). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put a diode in to stop the other one going high as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pick a spare pin on your arduino (I will use digital pin 7 for device A, 8 for device B, but it doesn't matter which). When you want to talk to device A, make sure pin 7 is in high impedance mode, and 8 is high. Talk to device A. Stop talking to device A. Put pin 8 in high impedance mode, and pin 7 to high. Talk to device B. Wash, rinse, repeat. So long as a device sees it's clock as high, it won't listen or talk.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-05-28T03:31:37.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12186" PostTypeId="2" ParentId="12177" CreationDate="2015-05-28T06:32:21.483" Score="2" Body="&lt;p&gt;I'm not 100% certain without my Due in front of me to test this, but as far as I can see, you are configuring your clock to run at 42MHz with &quot;TC_CMR_TCCLKS_TIMER_CLOCK1&quot; and are getting the timer to trigger when the count is &quot;1&quot; with &quot;TC_SetRC(tc, channel, 1);&quot;, which would give you 42MHz, not 4MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the clock timer still increments during the TC6_Handler() function, I'm guessing that the interrupt triggers a second time before it has exited the function the first time causing a hang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try changing your code to &quot;TC_SetRC(tc, channel, 42000000 / 4000000);&quot; to see if that works.  Your interrupt will still be triggered every 10 ticks of the timer which will only give you 20 ticks of the CPU clock to do your work and exit.  I suspect this may still be too little time to exit before the next interrupt is triggered.  If you still don't get the result you want, try reducing the frequency considerably to see if your timer is actually getting configured correctly.  I don't think you can get exactly 4MHz as the Due timer frequencies are not divisible by 4000000, unless my brain is a little fuzzy this morning and I'm missing something obvious...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do need to optimise the code inside your handler so it can run faster, let me know and I'll post some ideas when I can get near my Due and my source code for reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could always check out this link that I used when I needed to understand how to set up a timer for my own projects:&#xA;&lt;a href=&quot;http://2manyprojects.net/timer-interrupts&quot; rel=&quot;nofollow&quot;&gt;http://2manyprojects.net/timer-interrupts&lt;/a&gt;&#xA;Should that link go dead before you have a chance to read up, this is the example source from that page I modified for my own purposes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// These are the clock frequencies available to the timers /2,/8,/32,/128&#xA;// 84Mhz/2 = 42.000 MHz&#xA;// 84Mhz/8 = 10.500 MHz&#xA;// 84Mhz/32 = 2.625 MHz&#xA;// 84Mhz/128 = 656.250 KHz&#xA;//&#xA;// 42Mhz/44.1Khz = 952.38&#xA;// 10.5Mhz/44.1Khz = 238.09 &#xA;// 2.625Hmz/44.1Khz = 59.5&#xA;// 656Khz/44.1Khz = 14.88 // 131200 / 656000 = .2 (.2 seconds)&#xA;&#xA;// 84Mhz/44.1Khz = 1904 instructions per tick&#xA;const int led_pin = 13;&#xA;int state = false;&#xA;int interruptCtr = 1;&#xA;int S = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(led_pin, OUTPUT);&#xA;  /* turn on the timer clock in the power management controller */&#xA;  pmc_set_writeprotect(false);       // disable write protection for pmc registers&#xA;  pmc_enable_periph_clk(ID_TC7);     // enable peripheral clock TC7&#xA;&#xA;  /* we want wavesel 01 with RC */&#xA;  TC_Configure(/* clock */TC2,/* channel */1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4); &#xA;  TC_SetRC(TC2, 1, 131200);&#xA;  TC_Start(TC2, 1);&#xA;&#xA;  // enable timer interrupts on the timer&#xA;  TC2-&amp;gt;TC_CHANNEL[1].TC_IER=TC_IER_CPCS;   // IER = interrupt enable register&#xA;  TC2-&amp;gt;TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS;  // IDR = interrupt disable register&#xA;&#xA;  /* Enable the interrupt in the nested vector interrupt controller */&#xA;  /* TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number (=(1*3)+1) for timer1 channel1 */&#xA;  NVIC_EnableIRQ(TC7_IRQn);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // do nothing timer interrupts will handle the blinking;&#xA;}&#xA;&#xA;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&#xA;// INTERRUPT HANDLERS&#xA;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&#xA;void TC7_Handler()&#xA;{&#xA;  // We need to get the status to clear it and allow the interrupt to fire again&#xA;  TC_GetStatus(TC2, 1);&#xA;  state = !state;&#xA;  digitalWrite(led_pin, state);&#xA;&#xA;  if( interruptCtr++ &amp;gt;= 6 )&#xA;    {&#xA;     interruptCtr = 1;&#xA;     S = !S; // are we flashing S or O&#xA;     if( S ) // set time till next interrupt&#xA;        TC_SetRC(TC2, 1, 131200); // 131200 / 656000 = .2 seconds&#xA;     else&#xA;        TC_SetRC(TC2, 1, 656000); // 656000/ 656000 = 1 second&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-05-28T06:32:21.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12187" PostTypeId="1" CreationDate="2015-05-28T09:35:33.703" Score="0" ViewCount="2138" Body="&lt;p&gt;I want to send some data from an Arduino Mega to an android device via bluetooth (HC-06). I have installed some sensors whose values are frequently written in an SD card. Every time a new string line is added in a text file of the SD card. This is the format of the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;27/5/2015,11:55:00,34.00,27.00,42.50,26.80,47.80,26.00,24.62,24.12,26,0,0,708,1023,1023,1023,1023,10.5,10.5,10.5,10.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is part of the code. I send from a bluetooth terminal the string &quot;download&quot; and after that the text file is opened and every line is readed and sent to the android device via bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void){  &#xA;    while(Serial1.available()) {&#xA;       character = Serial1.read();&#xA;       content.concat(character);&#xA;     }&#xA;&#xA;if (content == &quot;download&quot;) {&#xA;    Serial.println(content);&#xA;    content = &quot;&quot;;&#xA;    read_from_SD_Card();&#xA;    }&#xA;    ........................&#xA;    ........................&#xA;    ........................&#xA;}&#xA;&#xA;&#xA;void read_from_SD_Card(){&#xA;    myFile = SD.open(&quot;test.txt&quot;);&#xA;    if (myFile) {&#xA;        Serial1.println(&quot;test.txt:&quot;);&#xA;&#xA;        while (myFile.available()) {&#xA;            Serial1.write(myFile.read());&#xA;      }&#xA;      myFile.close();&#xA;    } &#xA;else {&#xA;  Serial1.println(&quot;error opening test.txt&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problems are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;the data are downloaded only after an upload of the sketch has been done. (I can't upload the sketch once and download the data from time to time) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No more than 10-20 lines can be downloaded. With bigger files the downloading seems to slow down and finally stops after a few lines.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any thoughts would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-06-21T23:49:15.387" Title="Bluetooth transfer problem with big files" Tags="|bluetooth|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12188" PostTypeId="2" ParentId="8642" CreationDate="2015-05-28T09:55:35.623" Score="0" Body="&lt;p&gt;After wasting a huge amount of time trying get the Arduino IDE to upload the sketches to my new starter robot I came across the following document in the Arduino Website :&quot;Guide to the Arduino Leonardo and Micro&quot;... In this document they explain how the serial port communication work on the leonardo (which is the ME-Baseboard from MakeBlock)...They state that auto-reset is initiated when the computer opens the serial port at 1200 baud and then closes it... Whatever that means... I went into the makeblock driver setting (under windows 8.1 device manger) and change the baud rate to 1200... Surprise surprise... all  works fine now, I can compile and upload the sketches for the starter robot... What frustration !!!! And for the people at Makeblock... I have been trying to create a community userid and while the system say that it will send me an email, it never does !!!&lt;/p&gt;&#xA;" OwnerDisplayName="user10317" LastActivityDate="2015-05-28T09:55:35.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12191" PostTypeId="2" ParentId="8642" CreationDate="2015-05-28T14:04:43.900" Score="0" Body="&lt;p&gt;I am sad to report that what actually happened it that changing the baud rate also led to a change in board type in the arduino IDE... So the sketch did compile and load but assuming that the board is a UNO.  End result, still facing same problem and robot behave a bit erratically probably because the upload was not performed for a leonardo board.  I have tried counless times with countless different procedures on an acer laptop with Windows 8.1, an acer laptop with Windows 7 and a surface pro with Windows 7.  Same problem everywhere.  If someone from Makeblock read this blog, I would appreciate if you could send me the validating email so I engage this troubleshooting process on their community discussion board.&lt;/p&gt;&#xA;" OwnerDisplayName="user10317" LastActivityDate="2015-05-28T14:04:43.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12192" PostTypeId="1" CreationDate="2015-05-28T14:51:38.070" Score="0" ViewCount="264" Body="&lt;p&gt;I want to make a transmitter and receiver for quad copter for that I am using two arduinos(UNO and nano).I am using 4 pots for controlling the brushless motors.For that I am sending 4 integer values of the pots and with that integer value PWM signals are generated at receiver by the arduino.Now I want to know how to send that 4 integer values of the pots serially using arduino.&lt;/p&gt;&#xA;" OwnerUserId="10246" LastActivityDate="2015-05-28T22:48:38.053" Title="how to make transmitter and receiver for quad copter?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12193" PostTypeId="2" ParentId="11981" CreationDate="2015-05-28T15:15:03.777" Score="0" Body="&lt;p&gt;If you are using delay function then I guess the problem is due to that. Just try once using millis function to generate PWM signal at Mega.&lt;/p&gt;&#xA;" OwnerUserId="10246" LastEditorUserId="11529" LastEditDate="2017-08-24T14:21:28.380" LastActivityDate="2017-08-24T14:21:28.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12196" PostTypeId="1" CreationDate="2015-05-28T17:55:36.757" Score="2" ViewCount="1009" Body="&lt;p&gt;I'm new to all this. I bought an Arduino Uno recently and an Ultrasonic distance sensor. My mom's cats keep walking down into the basement and doing their... business. Anyhow, I want to create a radar system which detects movement past this door. I'd like to have an alert sent to my computer or Android. Is this within a basic Arduino level? Other than the Arduino what else might I need? &lt;/p&gt;&#xA;" OwnerUserId="10325" LastEditorUserId="26717" LastEditDate="2017-05-18T06:05:55.690" LastActivityDate="2017-05-18T12:07:29.773" Title="I want to build a radar alert system with Arduino" Tags="|arduino-uno|sensors|project|" AnswerCount="6" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12197" PostTypeId="2" ParentId="9678" CreationDate="2015-05-28T18:17:28.887" Score="0" Body="&lt;p&gt;Datasheet can be found here: &lt;a href=&quot;http://www.atmel.com/devices/atmega328.aspx?tab=parameters&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/devices/atmega328.aspx?tab=parameters&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this, the absolute rated voltage on the ATMega (aka, the chip at the heart of the Arduino) is 6V.  Above that... above that you risk magic smoke.  But you can just, &lt;em&gt;maybe&lt;/em&gt; get away with running your whole system on 6V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important point - do not rely on using 4 AA batteries for this.  Regulate your 6Vish to &lt;em&gt;exactly&lt;/em&gt; 6V.  Just remember that this is at the extreme limit of the spec.  If you try this, before you start repeat to yourself &quot;I have just voided my warranty.  It is now my fault when it dies.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, why are you so wedded to 6V?  What are you trying to achieve?&lt;/p&gt;&#xA;" OwnerUserId="3058" LastActivityDate="2015-05-28T18:17:28.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12198" PostTypeId="1" AcceptedAnswerId="12199" CreationDate="2015-05-28T19:40:58.097" Score="2" ViewCount="1550" Body="&lt;p&gt;I'm using Raspberry Pi and Arduinos for my home automation project where Raspberry Pi is the controler of Arduino nodes.&#xA;I use nRF24 wireless transceivers to communicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I was sending a structure like following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct TempSensorData&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;{&#xA;      uint32_t result;&#xA;      uint32_t temperature;&#xA;      uint32_t humidity;&#xA;    };&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Raspberry to Raspberry everything went fine but now when I use Arduino as sender I get very strange results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;received: status: 335544320, temperature: 754974720 degrees, humidity: 0%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While on Raspberry it was&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;received: status: 0, temperature: 22 degrees, humidity: 44%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can this be a problem with types? Or with different type of architecture (like different sizes on 3-2bit and 64-bit arch)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code on Raspberry:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (radio.available())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;{&#xA;        // dump the payloads until we've got everything&#xA;        Message receivedData = {0};&#xA;        radio.read(&amp;amp;receivedData, sizeof(Message));&#xA;        TempSensorData data = receivedData.msgData.tempSensorData;&#xA;        std::cout &amp;lt;&amp;lt; &quot;received: status: &quot; &amp;lt;&amp;lt; data.result &amp;lt;&amp;lt; &quot;, temperature: &quot; &amp;lt;&amp;lt; data.temperature &amp;lt;&amp;lt; &quot; degrees, humidity: &quot; &amp;lt;&amp;lt; data.humidity &amp;lt;&amp;lt; &quot;%&quot; &amp;lt;&amp;lt; std::endl; //TODO here we have some strange numbers - check if we have proper types&#xA;    }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before that I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.begin();&#xA;radio.setPALevel(RF24_PA_LOW);&#xA;radio.setChannel(0x4c);&#xA;radio.openReadingPipe(1, RASPI_READ_ADDR);&#xA;radio.openWritingPipe(RASPI_WRITE_ADDR);&#xA;&#xA;radio.enableDynamicPayloads();&#xA;radio.setAutoAck(true);&#xA;radio.powerUp();&#xA;radio.startListening();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Header header = {thisNodeId, thisNodeType, 0, static_cast&amp;lt;uint8_t&amp;gt;(MsgType::TEMP_SENSOR_DATA), 12345, Status::ok};&#xA;TempSensorData dhtData;&#xA;dhtData.result = DHT.read11(DHT11_PIN);&#xA;dhtData.humidity = (int)DHT.humidity;&#xA;dhtData.temperature = (int)DHT.temperature;&#xA;Message message = {0};&#xA;message.header = header;&#xA;message.msgData.tempSensorData = (dhtData);&#xA;radio.stopListening();&#xA;radio.write(&amp;amp;message, sizeof(message));&#xA;radio.startListening();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also use a common header with defined structures for both Arduino and Raspberry, which contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RASPI_WRITE_ADDR 0xF0F0F0F0F0LL&#xA;#define RASPI_READ_ADDR 0xF0F0F0F0E1LL&#xA;&#xA;struct TempSensorData {   &#xA;  uint32_t result;&#xA;  uint32_t temperature;&#xA;  uint32_t humidity;&#xA;};  &#xA;&#xA;enum class Status : uint8_t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;{&lt;br&gt;&#xA;        ok,&#xA;        error,&#xA;        fail&#xA;    };&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum class MsgType : uint8_t {&#xA;    INITIALIZATION,&#xA;    RESET_REQUEST,&#xA;    ACK_NACK,&#xA;    TEMP_SENSOR_DATA,&#xA;};&#xA;&#xA;struct Header {&#xA;  uint8_t nodeId;&#xA;  uint8_t nodeType;&#xA;  uint8_t location;&#xA;  uint8_t msgType;&#xA;  uint16_t checksum;&#xA;  Status status;&#xA;};&#xA;&#xA;union MsgData {&#xA;  InitMsgData initMsgData;&#xA;  AckNack ackNack;&#xA;  TempSensorData tempSensorData;&#xA;};&#xA;&#xA;struct Message {&#xA;    Header header;&#xA;    MsgData msgData;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;radio&lt;/code&gt; is an item of RF24 class from &lt;a href=&quot;https://github.com/TMRh20/RF24/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/TMRh20/RF24/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the RF24 repo is 64 commits ahead of what I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the problem lays in that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum class Status {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which I use in both files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must add that I use g++-4.7 when compiling on Raspberry and when compiling on Arduino I use avr-g++-4.8.2&lt;/p&gt;&#xA;" OwnerUserId="7375" LastEditorUserId="4628" LastEditDate="2018-04-16T10:41:01.847" LastActivityDate="2018-04-16T10:41:01.847" Title="Sending struct from Arduino to Raspberry Pi - wrong types" Tags="|arduino-pro-mini|data-type|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12199" PostTypeId="2" ParentId="12198" CreationDate="2015-05-28T20:27:20.687" Score="0" Body="&lt;p&gt;It is not a size problem: &lt;code&gt;uint32_t&lt;/code&gt; is always 32 bits. Converting the&#xA;numbers to hex gives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Raspberry to Raspberry: 0x00000000, 0x00000016, 0x0000002c&lt;/li&gt;&#xA;&lt;li&gt;Arduino to Raspberry: 0x14000000, 0x2d000000, 0x00000000&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There seems to be an offset between the two. You may just have lost one&#xA;byte when the Arduino is the sender. There &lt;em&gt;may&lt;/em&gt; be also a byte order&#xA;issue, but your test is not sufficient to say. You can, e.g., send a&#xA;series of &lt;code&gt;0x12345678&lt;/code&gt; to know for sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to devise a way of synchronizing the communication, i.e. to&#xA;identify, in the byte stream, which is the first byte of the packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Let me illustrate how this can happen both with and without&#xA;and endianness issue. I'll assume you are transmitting&#xA;&lt;code&gt;{status: 0, temperature: 20, humidity: 45}&lt;/code&gt; and the first byte(s) of&#xA;the first packet are lost. On the receiving side, you combine the&#xA;remaining bytes of the first packet with the first byte(s) of the second&#xA;packet, and interpret the whole as a single packet. You get:&#xA;&lt;code&gt;{status: 335544320, temperature: 754974720, humidity: 0}&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a little endian to little endian scenario, you only need to loose one&#xA;byte:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;original data:     0x00000000, 0x00000014, 0x0000002d&#xA;transmitted bytes: 00 00 00 00 14 00 00 00 2d 00 00 00&#xA;received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00&#xA;received data:     0x14000000, 0x2d000000, 0x00000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In a big endian to little endian scenario, you get the exact same result&#xA;if you loose 4 bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;original data:     0x00000000, 0x00000014, 0x0000002d&#xA;transmitted bytes: 00 00 00 00 00 00 00 14 00 00 00 2d&#xA;received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00&#xA;interpreted data:  0x14000000, 0x2d000000, 0x00000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-05-29T08:35:42.793" LastActivityDate="2015-05-29T08:35:42.793" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12203" PostTypeId="1" AcceptedAnswerId="12204" CreationDate="2015-05-28T22:03:41.257" Score="-1" ViewCount="363" Body="&lt;p&gt;So I'm using the DFRobot LCD Keypad shield to make a text-based game. Can someone give me an example? Let's just say i want to make the LCD display &quot;text1&quot; and then press up then select, it displays &quot;text2&quot;. If I press down then press select, it displays &quot;text3&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10328" LastActivityDate="2015-05-28T22:18:07.413" Title="How to program LCD shield?" Tags="|lcd|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12204" PostTypeId="2" ParentId="12203" CreationDate="2015-05-28T22:18:07.413" Score="0" Body="&lt;p&gt;Attach the shield to arduino then run the following code to check if everything is ok. &#xA;Wiring is made default.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel&#xA;&#xA;// define some values used by the panel and buttons&#xA;int lcd_key     = 0;&#xA;int adc_key_in  = 0;&#xA;&#xA;#define btnRIGHT  0&#xA;#define btnUP     1&#xA;#define btnDOWN   2&#xA;#define btnLEFT   3&#xA;#define btnSELECT 4&#xA;#define btnNONE   5&#xA;&#xA;int read_LCD_buttons(){               // read the buttons&#xA;    adc_key_in = analogRead(0);       // read the value from the sensor &#xA;&#xA;    // my buttons when read are centered at these valies: 0, 144, 329, 504, 741&#xA;    // we add approx 50 to those values and check to see if we are close&#xA;    // We make this the 1st option for speed reasons since it will be the most likely result&#xA;&#xA;    if (adc_key_in &amp;gt; 1000) return btnNONE; &#xA;&#xA;    // For V1.1 us this threshold&#xA;    if (adc_key_in &amp;lt; 50)   return btnRIGHT;  &#xA;    if (adc_key_in &amp;lt; 250)  return btnUP; &#xA;    if (adc_key_in &amp;lt; 450)  return btnDOWN; &#xA;    if (adc_key_in &amp;lt; 650)  return btnLEFT; &#xA;    if (adc_key_in &amp;lt; 850)  return btnSELECT;  &#xA;&#xA;   // For V1.0 comment the other threshold and use the one below:&#xA;   /*&#xA;     if (adc_key_in &amp;lt; 50)   return btnRIGHT;  &#xA;     if (adc_key_in &amp;lt; 195)  return btnUP; &#xA;     if (adc_key_in &amp;lt; 380)  return btnDOWN; &#xA;     if (adc_key_in &amp;lt; 555)  return btnLEFT; &#xA;     if (adc_key_in &amp;lt; 790)  return btnSELECT;   &#xA;   */&#xA;&#xA;    return btnNONE;                // when all others fail, return this.&#xA;}&#xA;&#xA;void setup(){&#xA;   lcd.begin(16, 2);               // start the library&#xA;   lcd.setCursor(0,0);             // set the LCD cursor   position &#xA;   lcd.print(&quot;Push the buttons&quot;);  // print a simple message on the LCD&#xA;}&#xA;&#xA;void loop(){&#xA;   lcd.setCursor(9,1);             // move cursor to second line &quot;1&quot; and 9 spaces over&#xA;   lcd.print(millis()/1000);       // display seconds elapsed since power-up&#xA;&#xA;   lcd.setCursor(0,1);             // move to the begining of the second line&#xA;   lcd_key = read_LCD_buttons();   // read the buttons&#xA;&#xA;   switch (lcd_key){               // depending on which button was pushed, we perform an action&#xA;&#xA;       case btnRIGHT:{             //  push button &quot;RIGHT&quot; and show the word on the screen&#xA;            lcd.print(&quot;RIGHT &quot;);&#xA;            break;&#xA;       }&#xA;       case btnLEFT:{&#xA;             lcd.print(&quot;LEFT   &quot;); //  push button &quot;LEFT&quot; and show the word on the screen&#xA;             break;&#xA;       }    &#xA;       case btnUP:{&#xA;             lcd.print(&quot;UP    &quot;);  //  push button &quot;UP&quot; and show the word on the screen&#xA;             break;&#xA;       }&#xA;       case btnDOWN:{&#xA;             lcd.print(&quot;DOWN  &quot;);  //  push button &quot;DOWN&quot; and show the word on the screen&#xA;             break;&#xA;       }&#xA;       case btnSELECT:{&#xA;             lcd.print(&quot;SELECT&quot;);  //  push button &quot;SELECT&quot; and show the word on the screen&#xA;             break;&#xA;       }&#xA;       case btnNONE:{&#xA;             lcd.print(&quot;NONE  &quot;);  //  No action  will show &quot;None&quot; on the screen&#xA;             break;&#xA;       }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-05-28T22:18:07.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12205" PostTypeId="2" ParentId="9665" CreationDate="2015-05-28T22:36:48.487" Score="-1" Body="&lt;p&gt;JUST add the part ~&#xA;This flushes the serial buffer, which aids in error free data receiving. No need to implement the millis() protocol as you want the led to be active for that time so you do not want any data to enter the system, neither you are using interrupts service.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.readString();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-05-28T22:36:48.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12206" PostTypeId="2" ParentId="9678" CreationDate="2015-05-28T22:44:48.090" Score="2" Body="&lt;p&gt;I think as far as i understood the problem, the system or whatever you call is will run on what ever power as long that power is not fed to the arduino that will not be a problem, just connect the two grounds together and power the arduino through the computer and connect the pins to the system accordingly. i think this will solve thus the trivial problem.&lt;/p&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-05-28T22:44:48.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12207" PostTypeId="2" ParentId="12192" CreationDate="2015-05-28T22:48:38.053" Score="1" Body="&lt;p&gt;The APC220 radio module provides a simple and economic solution to wireless data communications. Integrates an embedded high speed microprocessor and high performance IC that creates a transparent UART/TTL interface, and elminates any need for packetizing and data encoding. Use this module as this works as a pair and more intriguing part is that &quot;it&quot; can transmit over a km away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;link ~&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;filter_name=apc&amp;amp;product_id=57#.VWeKIVWqqko&quot; rel=&quot;nofollow&quot;&gt;http://www.dfrobot.com/index.php?route=product/product&amp;amp;filter_name=apc&amp;amp;product_id=57#.VWeKIVWqqko&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-05-28T22:48:38.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12208" PostTypeId="2" ParentId="12187" CreationDate="2015-05-28T23:01:23.807" Score="0" Body="&lt;pre&gt;&lt;code&gt;String content;&#xA;void loop()&#xA;{  &#xA;    while(Serial1.available()) {&#xA;       character = Serial1.read();&#xA;       content.concat(character);&#xA;     }&#xA;&#xA;if (content == &quot;download&quot;)&#xA;{&#xA;    Serial1.println(content);&#xA;    content = &quot;&quot;;&#xA;    read_from_SD_Card();&#xA;    }&#xA;&#xA;........................&#xA;    ........................&#xA;    ........................&#xA;}//end of loop()&#xA;&#xA;&#xA;read_from_SD_Card(){&#xA;    myFile = SD.open(&quot;test.txt&quot;);&#xA;    if (myFile) {&#xA;        Serial1.println(&quot;test.txt:&quot;);&#xA;&#xA;        while (myFile.available()) {&#xA;            Serial1.print(myFile.read());&#xA;      }&#xA;      myFile.close();&#xA;    } &#xA;else {&#xA;  Serial1.println(&quot;error opening test.txt&quot;);&#xA;  }&#xA;  Serial1.readString()//to flush the serial buffer.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-05-28T23:01:23.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12209" PostTypeId="2" ParentId="12198" CreationDate="2015-05-28T23:30:46.027" Score="-1" Body="&lt;p&gt;I believe this could be because the Raspberry pi is big endian and the arduino is little endian. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Endianness&quot; rel=&quot;nofollow&quot;&gt;Learn about Endianness here!&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="10007" LastActivityDate="2015-05-28T23:30:46.027" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12210" PostTypeId="2" ParentId="12145" CreationDate="2015-05-28T23:55:04.810" Score="1" Body="&lt;p&gt;Yes, all you need is a computer or another device that grabs the data via wifi and store it in a database. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can simply send requests from arduino to computer and the PC does the search and returns the info back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use XBees for communication, just install some serial communication with your preferred language and start sending and receiving data. The database will be accessed through that high level program and data will flow via XBees.&lt;/p&gt;&#xA;" OwnerUserId="8478" LastActivityDate="2015-05-28T23:55:04.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12211" PostTypeId="2" ParentId="12058" CreationDate="2015-05-29T00:30:36.887" Score="0" Body="&lt;p&gt;I built a &lt;a href=&quot;http://forum.freetronics.com/viewtopic.php?f=6&amp;amp;t=5387&quot; rel=&quot;nofollow&quot;&gt;measuring bench&lt;/a&gt; using a glass slide (intended for DRO) with quadrature output. I found the Arduino was easily overwhelmed and would miss beats. I also tried implementing a D flip flop to halve the resolution of the slide. Ultimately, I put a LS7166 IC in the prototyping area of the freeduino eleven I was using and then performed a PORT read on D0-D7.  &lt;/p&gt;&#xA;" OwnerUserId="79" LastActivityDate="2015-05-29T00:30:36.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12212" PostTypeId="1" AcceptedAnswerId="12222" CreationDate="2015-05-29T00:44:34.973" Score="0" ViewCount="3141" Body="&lt;p&gt;The central arduino&#xA;&lt;img src=&quot;https://i.stack.imgur.com/LnAZh.png&quot; alt=&quot;The central arduino&quot;&gt;&#xA;The 1st node&#xA;&lt;img src=&quot;https://i.stack.imgur.com/HrrK8.png&quot; alt=&quot;The 1st node&quot;&gt;&#xA;The 2nd node&#xA;&lt;img src=&quot;https://i.stack.imgur.com/LT4Vu.png&quot; alt=&quot;The 2nd node&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the central to send to the first node the rgb code like a string on the loop&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;rgb: 255000255&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;but when it detects something to PIR to send a string to central.&#xA;In addition every some seconds the 2nd node to send a string to the central the temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i mentioned in my previous questions i have some problems when it comes to the bi-directional comunication. I have tried a lot of code. Can someone show me how to achieve what i want to do if not with code, with steps. Please help me!!&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-29T10:16:04.070" Title="bi-directional nrf24 communication" Tags="|c++|nrf24l01+|timing|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12213" PostTypeId="2" ParentId="12212" CreationDate="2015-05-29T02:35:04.213" Score="0" Body="&lt;p&gt;Try the &lt;a href=&quot;https://github.com/maniacbug/RF24Network&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;RF24Network&lt;/code&gt;&lt;/a&gt; library from &lt;code&gt;maniacbug&lt;/code&gt;. If you don't have too many nodes it's easy to use. It comes with examples easy to test and extend. It also uses different channels for sending and receiving so you should have no collisions.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-05-29T02:35:04.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12214" PostTypeId="2" ParentId="4412" CreationDate="2015-05-29T02:46:34.233" Score="0" Body="&lt;p&gt;i can't be certain, but i reckon it has something to do with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRC = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this equates to b000001, meaning only pinC0 is an output. i think&lt;/p&gt;&#xA;" OwnerUserId="10332" LastActivityDate="2015-05-29T02:46:34.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12215" PostTypeId="2" ParentId="12196" CreationDate="2015-05-29T04:23:49.923" Score="2" Body="&lt;p&gt;I think that's quite possible. As mentioned, not technically radar. I don't know if cats could hear it, but then if it scares them off, job done, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if sending the alert to a PC would help or not - you might just consider an audible alarm using a cheap 8-ohm speaker. Otherwise, USB, bluetooth, wifi, or SMS for notification. A PC or phone (on all the time) to receive the data. Some thought about what you will do with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a deterrent, a water pistol is ideal, you'd need a motor - solenoid? - to fire the water pistol. Harmless, but very distasteful to cats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=lxmRYRlgreo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=lxmRYRlgreo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Inspired by @SDSolar, I checked it out - yes, cats can hear that frequency. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Cats have excellent hearing and can detect an extremely broad range of frequencies. They can hear higher-pitched sounds than humans or most dogs, detecting frequencies from 55 Hz up to 79 kHz.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(from &lt;a href=&quot;https://en.wikipedia.org/wiki/Hearing_range#Cats&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Hearing_range#Cats&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means they will probably learn to associate the sound with the water pistol (yes, cats CAN be trained, if they are motivated). This means if you remove your device, they will probably come back, but if you leave the sensor (active), but remove the water, then it will continue to work!&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2017-05-17T21:16:05.100" LastActivityDate="2017-05-17T21:16:05.100" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12216" PostTypeId="2" ParentId="4412" CreationDate="2015-05-29T06:37:47.843" Score="2" Body="&lt;p&gt;&lt;code&gt;DDRx&lt;/code&gt; is the Data-Direction-Register-x so this can be &lt;code&gt;DDRC&lt;/code&gt; or &lt;code&gt;DDRD&lt;/code&gt; or anything. One register has 8 bits, 1 bit for every pin.&#xA;Making a bit 1 will result in the pin being an output. Making it 0 will result in the pin being an input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we want to make pin 4 and 5 of port C an output.&#xA;We simply do this in the setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       //76543210  Pin numbers.&#xA;       //IIOOIIII  Input/Output indicator&#xA;DDRC = 0b00110000;//Code that actually does it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this way we can read pin 4 &amp;amp; 5.&#xA;But if we want to read the complete port, I suggest setting every pin of the port to input. &lt;code&gt;DDRC = 0b00000000;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we can read the port as simply as &lt;code&gt;uint8_t portValueC = PORTC;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;portValueC will now have a value that represents the port's values.&#xA;It'll be binary, but you read it as decimal.&#xA;So it'll be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 for no inputs.&#xA;1 for only pin 0&#xA;2 for pin 1&#xA;3 for pin 0 &amp;amp; 1&#xA;4 for pin 2&#xA;5 for pin 2 &amp;amp; 0&#xA;6 for pin 2 &amp;amp; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well. it's binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say (pin 7,5,3,1 high)(pin 6,4,2,0 low).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will result into the decimal value of 170.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The binary value, however, will be easier to read &lt;code&gt;0b10101010&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //76543210&#xA;  //0b10101010 (Could be the value) (pin 7,5,3,1 high)(pin 6,4,2,0 low)&#xA;//^ is decimal: 170&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should add these macros to your project to make it easier to get single bits from this value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define bit_get(p,m) ((p) &amp;amp; (m))&#xA;#define bit_set(p,m) ((p) |= (m))&#xA;#define bit_clear(p,m) ((p) &amp;amp;= ~(m))&#xA;#define bit_flip(p,m) ((p) ^= (m))&#xA;#define bit_write(c,p,m) (c ? bit_set(p,m) : bit_clear(p,m))&#xA;#define BIT(x) (0x01 &amp;lt;&amp;lt; (x))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, now you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(bit_get(PINC, BIT(3)))&#xA;{&#xA; //Do only this if PORTC pin 3 is high&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read this first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.elecrom.com/2008/02/12/avr-tutorial-2-avr-input-output/&quot; rel=&quot;nofollow&quot;&gt;Info on the registers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.avrfreaks.net/forum/tut-c-bit-manipulation-aka-programming-101?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=37871&quot; rel=&quot;nofollow&quot;&gt;Info on bit fiddling&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-05-29T11:36:22.493" LastActivityDate="2015-05-29T11:36:22.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12217" PostTypeId="1" CreationDate="2015-05-29T04:00:06.870" Score="0" ViewCount="2504" Body="&lt;p&gt;I am using an Arduino Due for a project. I am running out of digital pins, using 22 to 53. Can pins 0 to 13 and SCL1, SDA1 be used as digital inputs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about analog pins (A0 to A11) and DACs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="tendo" LastEditorUserId="353" LastEditDate="2015-12-29T03:02:09.993" LastActivityDate="2018-06-01T22:23:37.043" Title="Can all Arduino Due pins be used as digital input/output?" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12218" PostTypeId="2" ParentId="12217" CreationDate="2015-05-29T06:17:43.337" Score="1" Body="&lt;p&gt;&lt;strong&gt;Bear in mind that this has nothing to do with &quot;Electrical Engineering&quot;.&#xA;This simply is an arduino question. And should be asked on &lt;a href=&quot;https://arduino.stackexchange.com/&quot;&gt;arduino Stack Exchange.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can be used as input/output pins. [&lt;a href=&quot;http://waihung.net/arduino-tip-turn-your-analog-pins-into-digital-io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simple 'tutorial'&lt;/a&gt;]&#xA;If that even isn't enough or not working on your type of arduino, you can use I/O expanders or shift registers. &#xA;Check them out on the internet. [&lt;a href=&quot;https://www.google.nl/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=io%20expander%20ic&quot; rel=&quot;nofollow noreferrer&quot;&gt;I/O expanders&lt;/a&gt;]&lt;/p&gt;&#xA;" OwnerUserId="8033" OwnerDisplayName="FuaZe" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-05-29T09:54:43.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12219" PostTypeId="2" ParentId="4412" CreationDate="2015-05-29T09:06:11.903" Score="2" Body="&lt;p&gt;Judging from your &lt;code&gt;readSensors()&lt;/code&gt; function, these seem to be capacitive&#xA;sensors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you charge them to Vcc (&lt;code&gt;DDRC = 1; PORTC = 1;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you wait until they are fully charged (&lt;code&gt;delay_us(10);&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you tri-state the pin (&lt;code&gt;DDRC = 0; PORTC = 0&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you wait for them to partially self-discharge (&lt;code&gt;delay_ms(1);&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;you read the pin (&lt;code&gt;return PINC;&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If my assumption is correct, and if &lt;em&gt;all&lt;/em&gt; of those sensors are similar,&#xA;then here is your first bug: you are only charging the sensor on PC0. If&#xA;you want to charge the four sensors, you need to set bits 0 to 3 of the&#xA;port to active high. Thus, the first two statements in &lt;code&gt;readSensors()&lt;/code&gt;&#xA;should be:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRC = 0x0f;   // bits 0 to 3...&#xA;PORTC = 0x0f;  // ...set to active high&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your second bug is in &lt;code&gt;printBinaryLCD()&lt;/code&gt;. The function name, and the way&#xA;you call it, implies it is meant to print on the LCD the value passed as&#xA;a parameter. Instead, it is completely ignoring its parameter, and&#xA;reading &lt;code&gt;PORTC&lt;/code&gt; itself. This is bad because the reading of the&#xA;capacitive sensors is time sensitive, so you should let &lt;code&gt;readSensors()&lt;/code&gt;&#xA;do the work. You should then change &lt;code&gt;printBinaryLCD()&lt;/code&gt; so that it&#xA;examines &lt;code&gt;val&lt;/code&gt; instead of &lt;code&gt;PORTC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void printBinaryLCD(uint8_t val)&#xA;{&#xA;    lcd_home();&#xA;    uint8_t A = (val &amp;amp; (1&amp;lt;&amp;lt;3)) != 0;&#xA;    ...etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-05-29T09:06:11.903" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12220" PostTypeId="2" ParentId="12196" CreationDate="2015-05-29T09:08:19.967" Score="2" Body="&lt;p&gt;I'm not convinced an ultrasound detector will detect a cat.  They're fluffy and (usually) soft, so the ultrasound might not bounce off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead I suggest you just try a gadget that annoys cats and keeps them out of the area.  It's an ultrasound emitter, and the noise is &lt;strong&gt;claimed&lt;/strong&gt; to be objectionable to cats.  I've seen them sold in gardening stores, for keeping cats away from the bird table:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://skeptics.stackexchange.com/questions/5945/do-ultrasonic-cat-repellents-work&quot;&gt;Opinions on cat scarers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10135" LastEditorUserId="-1" LastEditDate="2017-04-13T12:46:46.590" LastActivityDate="2015-05-29T09:08:19.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12221" PostTypeId="1" CreationDate="2015-05-29T10:02:07.567" Score="0" ViewCount="850" Body="&lt;p&gt;I've recently purchased a screen on DX without really thinking about it, because I have no idea how to connect it to my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is &lt;a href=&quot;http://www.dx.com/p/xs057-1-8-serial-128-x-160-spi-tft-lcd-module-display-for-arduino-black-white-golden-255430#.VWg4E8-eDRZ&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; screen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/R40Mz.jpg&quot; alt=&quot;XS075&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The description says that it uses the SPI serial protocol but I don't know how to connect that ribbon to my Arduino, is soldering cables to it the only way?&lt;/p&gt;&#xA;" OwnerUserId="10337" LastActivityDate="2018-08-12T21:49:20.663" Title="How do I connect this SPI serial display to an Arduino?" Tags="|arduino-uno|lcd|display|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12222" PostTypeId="2" ParentId="12212" CreationDate="2015-05-29T10:10:56.127" Score="1" Body="&lt;p&gt;&lt;strong&gt;You &lt;em&gt;cannot&lt;/em&gt; (easily) have all nodes on the network with the same address.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are ways of doing it but they aren't easy.  They basically involve creating a &quot;broadcast&quot; facility in your network, and that has certain caveats involved with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nRF24L01 modules have an &quot;auto-ACK&quot; mode to give reliable communications.  &lt;em&gt;This only works with 1:1 addressing&lt;/em&gt; and cannot work with broadcast.  If you want to (as most people do) use the auto-ACK facility then you have to have each node with its own unique address.  After all, if you're sending the &lt;em&gt;ACK&lt;/em&gt; to a station, and there are multiple stations with that address, &lt;em&gt;which one will ACK?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have to think about if what you are trying to achieve is really the right way of going about it.  It sounds like you want to just program another node with the same code as an existing node without making any changes to that code and &quot;just have it work&quot;.  That's a very advanced topic and one that even I would spend quite some time implementing it.  Yes, you can do unreliable communications (i.e., no auto-ACK) then you could have all the remote stations with the same address, but I would certainly keep the master as a unique address.  Better would be for each node to start up with a pre-defined address which it then uses to ask the master for a unique address (a-la DHCP) and the master then keeps a list of what is connected on what address.  From then on it can use reliable communications to send and receive data to each node as it needs to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/nrf24l01&quot; rel=&quot;nofollow&quot;&gt;A system I wrote for the chipKIT boards&lt;/a&gt; gives each node two addresses - its own unique address which you have to provide manually, and a more global &quot;broadcast&quot; address.  They are each on different pipes within the nRF24L01.  To communicate with an individual node you send to its unique address.  To broadcast to all nodes you send to the broadcast address.  If you're sending to the unique address you can then turn on auto-ACK. If you're sending to the broadcast address you don't turn on auto-ACK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that using auto-ACK is a whole topic in itself and requires careful design planning to get it to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you have to think about what happens when you send a broadcast packet out and it's received by other nodes - how do they handle that data? Sending temperature data out globally, it will be received by the RGB receiver, which may try and interpret it, causing problems.  You need to come up with a way of identifying just what it is you're sending out and only having the right nodes responding to the right data.  That means coming up with a strict packet format.  Luckily the nRF24L01 chips communicate in fixed packet sizes (incidentally, all nodes on the network will have to be set to use the same packet size or it just won't work) up to 32 bytes, so implementing a packet structure over that is easy enough.  Just sending strings of data is both hard to interpret and incredibly inefficient.  You should be sending the data as actual data values in variables as part of the packet structure.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-29T10:16:04.070" LastActivityDate="2015-05-29T10:16:04.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12223" PostTypeId="2" ParentId="12221" CreationDate="2015-05-29T10:21:33.367" Score="1" Body="&lt;p&gt;That kind of connector is most commonly directly soldered on to a PCB.  You can &lt;a href=&quot;http://www.ebay.com/sch/i.html?&amp;amp;_nkw=fpc+adapter+board&quot; rel=&quot;nofollow noreferrer&quot;&gt;buy adaptor boards&lt;/a&gt; with the various different pitch pads on them for soldering it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KeUbI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also there is no mention of what chip the screen uses (I am unfamiliar with &quot;XS057&quot; as a chip, so that is probably the model of the screen not the chip).  At that resolution it's probably an ILI9163, but without being sure all you can do is stab wildly in the dark and try different drivers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-05-29T10:33:02.037" LastActivityDate="2015-05-29T10:33:02.037" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12224" PostTypeId="1" CreationDate="2015-05-29T10:49:28.987" Score="0" ViewCount="393" Body="&lt;p&gt;I am using an Arduino Mega2560. Using Arduino Mega as ISP to burn sketch, I had loaded the bootloader from Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the blink LED code to the Mega. But the LED is responding slowly. Same with Serial code. Delay of 0.1 second acting as 1 second on my board. In code serial communication baud-rate is 9600 but I am getting proper value when I set the baud-rate to 4800 in serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone point out the problem?&lt;/p&gt;&#xA;" OwnerUserId="10338" LastEditorUserId="10794" LastEditDate="2015-08-28T21:53:04.547" LastActivityDate="2015-08-29T05:59:24.163" Title="Arduino Mega2560 clone responding slowly" Tags="|arduino-mega|bootloader|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12225" PostTypeId="2" ParentId="12224" CreationDate="2015-05-29T11:01:21.043" Score="1" Body="&lt;p&gt;Either your fuses are wrong (set to 50% the real speed of your crystal / ceramic resonator), you're using the internal oscillator instead of the expected external one, or you have the wrong board with the wrong F_CPU value selected in the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check all of those carefully.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-29T11:01:21.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12227" PostTypeId="2" ParentId="10170" CreationDate="2015-05-29T13:50:58.927" Score="0" Body="&lt;p&gt;I have successfully compiled the project in arduino IDE, simply concatenated main.c and ov7670.c ov7670.h into .ino file&lt;/p&gt;&#xA;&#xA;&lt;p&gt;didn't test it with the camera yet, but it uploaded to my arduino (Duemilanove)&#xA;Tell me if it worked for you...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;see here:&#xA;&lt;a href=&quot;https://github.com/eranws/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow&quot;&gt;https://github.com/eranws/ov7670-no-ram-arduino-uno&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10326" LastActivityDate="2015-05-29T13:50:58.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12228" PostTypeId="1" CreationDate="2015-05-29T14:21:20.053" Score="2" ViewCount="757" Body="&lt;p&gt;So, I've got a music degree, 5 years programming with Ruby and 7 with Pure Data. I've also got hold of an Arduino and a Raspberry Pi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I've seen a number of Arduino projects which involve firing events which cause a stick to hit a drum, but I really don't know where to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a wicker penguin that I want to have play the drums:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uXNPFm.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What components do I need to produce this kind of one-off percussive event?&lt;/li&gt;&#xA;&lt;li&gt;Can I trigger these events from Ruby?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10342" LastEditorUserId="220" LastEditDate="2015-05-29T15:32:11.130" LastActivityDate="2019-03-28T07:05:46.830" Title="Beginner Arduino Project: Drumming Robot" Tags="|robotics|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12229" PostTypeId="2" ParentId="12228" CreationDate="2015-05-29T14:29:38.720" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;to move the arms: look for tutorials about arduino controlling a motor (either step od DC).&lt;/li&gt;&#xA;&lt;li&gt;to control the arduino from a PC (or the PI) - that's what it means when you say Ruby - check how to remote control over serial port&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-05-29T14:40:41.807" LastActivityDate="2015-05-29T14:40:41.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12230" PostTypeId="1" CreationDate="2015-05-29T14:53:06.197" Score="1" ViewCount="1365" Body="&lt;p&gt;I'm looking for a way to check the air-flow from an aquarium air pump. I need something that can test whether air is flowing or not and I'm not bothered about measuring flow speed. The air will be flowing through a pipe but if required I can have the sensor on the end of an additional pipe just used for measuring.&lt;/p&gt;&#xA;" OwnerUserId="1622" LastActivityDate="2015-05-29T16:48:03.873" Title="How to measure whether air is flowing through a pipe?" Tags="|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12231" PostTypeId="2" ParentId="12146" CreationDate="2015-05-29T14:59:51.467" Score="1" Body="&lt;p&gt;What MQTT client are you using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Paraphrased from the &lt;a href=&quot;http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718099&quot; rel=&quot;nofollow&quot; title=&quot;MQTT spec&quot;&gt;MQTT spec&lt;/a&gt;  &lt;a href=&quot;http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718099&quot; rel=&quot;nofollow&quot;&gt;http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718099&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The MQTT protocol provides three qualities of service for delivering&#xA;  messages between clients and servers: &quot;at most once&quot;, QOS0; &quot;at least&#xA;  once&quot; QOS1; and &quot;exactly once&quot; QOS2. For QOS 1&amp;amp;2: The message must be&#xA;  stored locally at the publisher, until the publisher receives&#xA;  confirmation that the message has been delivered to the receiver.&#xA;  However, for QOS0 there is no storage requirement.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The problem with the Arduino is that there is no large quantity of storage available. If the client is disconnected from the broker while using a QOS of 1 or 2 the client must store the messages until a connection is reestablished and the message transfers are acknowledged. On an Arduino there is no guarantee all the messages can be saved. Consider a sensor node collecting 16-bits (int value) every second. Then supposed the broker goes down over the weekend and a repair person isn’t paid to work on the weekend. That’s two days’ worth of data or 172800 readings or about 1/3 MB (without overhead). The Arduino does not have that much storage.&lt;/p&gt;&#xA;" OwnerUserId="10344" LastActivityDate="2015-05-29T14:59:51.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12232" PostTypeId="2" ParentId="12230" CreationDate="2015-05-29T15:12:20.783" Score="2" Body="&lt;p&gt;Did you consider a barometric sensor deployed inside the pipe?&#xA;The pressure should be higher when the pump is active.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-05-29T15:12:20.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12233" PostTypeId="2" ParentId="12228" CreationDate="2015-05-29T15:37:59.623" Score="2" Body="&lt;p&gt;The approach I would take for the arms is to use a &lt;strong&gt;servo motor&lt;/strong&gt; as these are fairly cheap and are &lt;strong&gt;closed loop&lt;/strong&gt; so you don't have to add any extra sensors to check where the current position is.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Types of Motors:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Stepper motors&lt;/strong&gt; are a type of motor with a special arrangement of coils that allows you to turn a fraction of a degree by sending pulses to the motor. For example, you can buy a 200 step stepper motor that turns in increments of 1.8 degrees. These are somewhat expensive and require somewhat expensive drivers (usually $5-10 per driver). Often used in CNC machines and 3D printers. Continuous rotation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;General DC motors&lt;/strong&gt; (two types: brushless and brushed, but I won't get into that in here) are a type of motor. Their drivers are often cheaper than one for a stepper motor, but you have little control over their rotation (instead of &quot;take one step which is X degrees,&quot; you say , &quot;turn at 25% power clockwise,&quot; where you don't know the actual speed). These are sometimes used with &lt;em&gt;rotary encoders&lt;/em&gt; or &lt;em&gt;potentiometers&lt;/em&gt; to control the speed and position of the spindle. Continuous rotation.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Servo motors&lt;/strong&gt; are actually not their own type of motors; they are DC motors (not steppers) with a potentiometer built in along with the driver. You send pulses to it (you can use the &lt;em&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino servo library&lt;/a&gt;&lt;/em&gt; for this) to tell it the exact degree to go to. Can only go a limited range: usually either 90 or 180 degree, although you can get special ones that can turn much longer ranges than that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Using a Servo Motor:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can hook it up like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hC7tZ.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;From &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Sweep&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Arduino Tutorial&lt;/a&gt;&lt;/em&gt; &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And then some very simple code to use the motor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;Servo myservo;&#xA;&#xA;void setup() {&#xA;  myservo.attach(9);&#xA;} &#xA;&#xA;&#xA;void loop() {&#xA;  myservo.write(10);&#xA;  delay(500); &#xA;  myservo.write(0);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Talking with Ruby:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your best option is to use the serial port on your computer. Figure out how to access a COM/serial port in Ruby. You can then send messages from your computer to the Arduino, but you'll have to figure out a way to structure the messages.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-05-29T15:37:59.623" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12234" PostTypeId="2" ParentId="12230" CreationDate="2015-05-29T15:57:26.333" Score="1" Body="&lt;p&gt;Flow sensors tend to be expensive. However, there are many pressure sensors that provide a simple analog voltage input and others with easy to use digital interfaces. &#xA;As Igor Stoppa points out, these can be used to infer flow. Some can be purchased with tube ports that allow the user to mount the hose directly to the sensor. This would only require a &quot;T&quot; connector and some additional hose to connect to the air pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aquarium air pumps may be pulsatile. So be sure to use an average pressure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Average Pressure:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;above a certain point may indicate blockage&lt;/li&gt;&#xA;&lt;li&gt;between certain values indicates correct flow&lt;/li&gt;&#xA;&lt;li&gt;below a certain value indicates no flow&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8142" LastEditorUserId="8142" LastEditDate="2015-05-29T16:48:03.873" LastActivityDate="2015-05-29T16:48:03.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12235" PostTypeId="2" ParentId="12230" CreationDate="2015-05-29T16:15:28.680" Score="1" Body="&lt;p&gt;Grab yourself something &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B002VBW2I4&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sSmLc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Butcher it to get inside it, and add three small magnets to the fins (should be simple enough - just keep it balanced).  Then glue it all back together again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add a hall effect sensor to the outside, and Bob's your uncle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, since the principle of that unit is so simple, you could make your own from scratch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-29T16:15:28.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12236" PostTypeId="1" CreationDate="2015-05-29T16:17:04.417" Score="0" ViewCount="11150" Body="&lt;p&gt;why do I end up with the display &quot;Failed to read from DHT sensor!&quot; in the serial monitor in most cases when I run the code given below?? In case I reduce the delay to 1000ms the reading shows 0.00 for both temperature and humidity which, as well, is pretty much false......Any help would be highly appreciated... &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example testing sketch for various DHT humidity/temperature sensors&#xA;// Written by ladyada, public domain&#xA;&#xA;#include &quot;DHT.h&quot;&#xA;&#xA;#define DHTPIN 2     // what pin we're connected to&#xA;&#xA;// Uncomment whatever type you're using!&#xA;//#define DHTTYPE DHT11   // DHT 11 &#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;//#define DHTTYPE DHT21   // DHT 21 (AM2301)&#xA;&#xA;&#xA;&#xA;// Initialize DHT sensor for normal 16mhz Arduino&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you&#xA;// might need to increase the threshold for cycle counts considered a 1 or 0.&#xA;// You can do this by passing a 3rd parameter for this threshold.  It's a bit&#xA;// of fiddling to find the right value, but in general the faster the CPU the&#xA;// higher the value.  The default for a 16mhz AVR is a value of 6.  For an&#xA;// Arduino Due that runs at 84mhz a value of 30 works.&#xA;// Example to initialize DHT sensor for Arduino Due:&#xA;//DHT dht(DHTPIN, DHTTYPE, 30);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); &#xA;  Serial.println(&quot;DHTxx test!&quot;);&#xA;&#xA;  dht.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  // Wait a few seconds between measurements.&#xA;  delay(2000);&#xA;&#xA;  // Reading temperature or humidity takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  float h = dht.readHumidity();&#xA;  // Read temperature as Celsius&#xA;  float t = dht.readTemperature();&#xA;  // Read temperature as Fahrenheit&#xA;  float f = dht.readTemperature(true);&#xA;&#xA;  // Check if any reads failed and exit early (to try again).&#xA;  if (isnan(h) || isnan(t) || isnan(f)) {&#xA;    Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // Compute heat index&#xA;  // Must send in temp in Fahrenheit!&#xA;  float hi = dht.computeHeatIndex(f, h);&#xA;&#xA;  Serial.print(&quot;Humidity: &quot;); &#xA;  Serial.print(h);&#xA;  Serial.print(&quot; %\t&quot;);&#xA;  Serial.print(&quot;Temperature: &quot;); &#xA;  Serial.print(t);&#xA;  Serial.print(&quot; *C &quot;);&#xA;  Serial.print(f);&#xA;  Serial.print(&quot; *F\t&quot;);&#xA;  Serial.print(&quot;Heat index: &quot;);&#xA;  Serial.print(hi);&#xA;  Serial.println(&quot; *F&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10345" LastEditorDisplayName="user31481" LastEditDate="2017-11-14T07:51:38.843" LastActivityDate="2017-11-14T07:51:38.843" Title="Failed to read DHT22 sensor using Arduino Uno" Tags="|arduino-uno|temperature-sensor|code-review|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12237" PostTypeId="1" AcceptedAnswerId="12242" CreationDate="2015-05-29T17:36:58.697" Score="0" ViewCount="3090" Body="&lt;p&gt;I am aware of the simplicity of the question.  Nevertheless... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to code into the arduino the execution of a file.  More precisely a .exe. &#xA;To put things in perspective.  I have little to no knowledge of coding.  Yet I need to put together a photocabin.  I have the arduino to count the coins inserted to my coin collector and I need to take a picture when the precise ammount is reached.  Then reset the ammount to avoid taking more pictures. &#xA;here is what my code looks so far: (taken from the examples on the arduino page)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int coinInt = 0;&#xA;//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.&#xA;&#xA;    volatile float coinsValue = 0.00;&#xA;    //Set the coinsValue to a Volatile float&#xA;    //Volatile as this variable changes any time the Interrupt is triggered&#xA;    int coinsChange = 0;                 &#xA;    //A Coin has been inserted flag&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);                 &#xA;//Start Serial Communication&#xA;  attachInterrupt(coinInt, coinInserted, RISING);   &#xA;//If coinInt goes HIGH (a Pulse), call the coinInserted function&#xA;//An attachInterrupt will always trigger, even if your using delays&#xA;&#xA;}&#xA;&#xA;void coinInserted()   &#xA;&#xA;//The function that is called every time it recieves a pulse&#xA;{&#xA;  coinsValue = coinsValue + 0.05; &#xA;//As we set the Pulse to represent 5p or 5c we add this to the coinsValue&#xA;  coinsChange = 1;                           &#xA;//Flag that there has been a coin inserted&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(coinsChange == 1)         &#xA;//Check if a coin has been Inserted&#xA;  {&#xA;    coinsChange = 0;             &#xA;//unflag that a coin has been inserted&#xA;&#xA;   if(coinsValue &amp;gt;= 0.30)&#xA;  {&#xA;       here goes the code to open a file, then the code to reset coinsValue &#xA;&#xA;  }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks a million.&lt;/p&gt;&#xA;" OwnerUserId="10346" LastActivityDate="2015-06-09T15:02:26.207" Title="How to call a file from the arduino?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12238" PostTypeId="2" ParentId="12236" CreationDate="2015-05-29T17:53:07.140" Score="1" Body="&lt;p&gt;Have you put a  4.7kOhm  resistor between data pin and Vcc on the dht22? i had problems with a reading until i did. see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=53888.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;&#xA;HTH&lt;/p&gt;&#xA;" OwnerUserId="8004" LastActivityDate="2015-05-29T17:53:07.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12239" PostTypeId="1" AcceptedAnswerId="12241" CreationDate="2015-05-29T18:00:18.707" Score="0" ViewCount="40" Body="&lt;p&gt;&lt;a href=&quot;http://maniacbug.github.io/RF24Network/structRF24NetworkHeader.html#a99e675f31589d72cf2fe036e77988026&quot; rel=&quot;nofollow&quot;&gt;Link of the member&lt;/a&gt;&#xA;What is the character parameter in the above member of the class NRF24Network &#xA;I cannot understand the use of it.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-29T18:21:38.673" Title="What is the type parameter on the NRF24NetworkHeader member" Tags="|library|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12241" PostTypeId="2" ParentId="12239" CreationDate="2015-05-29T18:21:38.673" Score="1" Body="&lt;p&gt;It's to identify the type of packet.  Apparently that code supports types of 0-127, and I guess (impossible to tell without digging into the code) that what you use them for is entirely up to you.  Basically it would typically define what is in the rest of the packet - again something which is up to you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-29T18:21:38.673" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12242" PostTypeId="2" ParentId="12237" CreationDate="2015-05-29T20:55:00.643" Score="1" Body="&lt;p&gt;First of all you need to develop a windows app. You can achieve this by downloading visual studio express for windows desktop from &lt;a href=&quot;https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Then you must create a project in your language of your preference. You will have to add a &lt;strong&gt;serial port&lt;/strong&gt; component and set the properties to match your arduino serial ones. Then from the &lt;strong&gt;event&lt;/strong&gt; that handles the &quot;data available&quot; of your serial port you can check if there is an incoming character from your arduino and create an if statement that runs the .exe file. Then you must add serial.print('c') to your code when there is a coin inserted. By doing so, you will manage to communicate between arduino and your windows app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info and full guide can be found &lt;a href=&quot;http://www.jeremyblum.com/2011/02/07/arduino-tutorial-6-serial-communication-and-processing/comment-page-1/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-29T20:55:00.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12243" PostTypeId="2" ParentId="9666" CreationDate="2015-05-29T21:25:33.217" Score="2" Body="&lt;p&gt;Since then I've figured out how to rewrite the code to be non-blocking, by replacing the while loop with states, accumulating one byte at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written my first Arduino library with this occasion: &lt;a href=&quot;https://github.com/orgicus/Mindwave&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mindwave&lt;/a&gt;.&#xA;Here's a basic example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Mindwave.h&amp;gt;                   //import the library&#xA;Mindwave mindwave;                      //start using it&#xA;&#xA;void setup() {&#xA;  Serial.begin(MINDWAVE_BAUDRATE);      //setup serial communication (MindWave mobile is set to 57600 baud rate)&#xA;}&#xA;//create a function to received new values as soon as they're avaialble&#xA;void onMindwaveData(){&#xA;  Serial.print(&quot;attention: &quot;);&#xA;  Serial.println(mindwave.attention()); //access attention value&#xA;}&#xA;void loop() {&#xA;  mindwave.update(Serial,onMindwaveData);//update using the data input(Serial in this case) and the function to call when data is ready&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's non blocking, you can see the implementation &lt;a href=&quot;https://github.com/orgicus/Mindwave/blob/master/Mindwave.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was used for the &lt;a href=&quot;https://hackaday.io/project/5969-walk-with-me&quot; rel=&quot;nofollow noreferrer&quot;&gt;Walk with Me&lt;/a&gt; art installation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vvFjG.jpg&quot; alt=&quot;Walk with Me installation image 1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oFQ3N.jpg&quot; alt=&quot;Walk with Me installation image 2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RLNAa.jpg&quot; alt=&quot;Bluetooth and DMX Shield for the Walk with Me installation&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="3505" LastActivityDate="2015-05-29T21:25:33.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12244" PostTypeId="1" CreationDate="2015-05-29T21:36:44.683" Score="0" ViewCount="465" Body="&lt;p&gt;I have a project running on an arduino nano, and as part of it, I'd like to read from and write to a microSD card.  My problem is that the microSD shield for it doesn't fit my form factor (think slightly larger than a pen; definitely handheld).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've purchased a &lt;a href=&quot;http://www.mouser.com/ProductDetail/Yamaichi-Electronics/PJS008-2003-0/?qs=eWHdbjwv0KPMBllWRB82sg==&quot; rel=&quot;nofollow&quot;&gt;PJS008-2003-0&lt;/a&gt;, and I'm wondering, assuming I have the soldering chops, is there any real reason I can't connect this directly?  What does the breakout board get me other than nicer connection points and a blinking light?  Do the example SD sketches rely on anything the shield provides, or will they work for me?&lt;/p&gt;&#xA;" OwnerUserId="4186" LastActivityDate="2015-05-30T19:03:26.483" Title="Smallest package possible reading microSD" Tags="|shields|arduino-nano|sd-card|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12245" PostTypeId="2" ParentId="12244" CreationDate="2015-05-29T22:16:54.603" Score="0" Body="&lt;p&gt;Most likely you will have to add at least some pullup/pulldown resistor. I would recommend having a look at the schematics of the shield.&#xA;For example this shield:&#xA;&lt;a href=&quot;http://freematics.com/store/index.php?route=product/product&amp;amp;product_id=74&quot; rel=&quot;nofollow&quot;&gt;http://freematics.com/store/index.php?route=product/product&amp;amp;product_id=74&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it depends on which mode you want to use (SPI?):&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Secure_Digital#Transfer_modes&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Secure_Digital#Transfer_modes&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-05-29T22:16:54.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12246" PostTypeId="1" CreationDate="2015-05-29T23:00:56.967" Score="1" ViewCount="2206" Body="&lt;p&gt;Using an Arduino Mega. I have a motor hooked up exactly like the picture below. Using a BC548B transistor, 1N4001 diode, 220 ohm resistor and a 9V battery. I'm driving the motor in code by using PWM analogWrite to value 255. Weird thing is, if hooked up to USB (5V), the motor will only start to move after a certain amount of time, seems like it needs some initial &quot;drive&quot; to get started. If using the 9V battery it starts up quicker, but still not directly, as I would expect. Also, if I set analogWrite to some value less than 255, it will not move at all - is the transistor limiting? Can I change the resistor value to compensate? Thanks for any advice.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int motorPin = 3;&#xA;int interval = 10;&#xA;int walkingTime = 7.5;&#xA;bool walking = false;&#xA;&#xA;void setup() {&#xA;  pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(interval * 1000);&#xA;  if (!walking) {&#xA;    startWalk();&#xA;    delay(walkingTime * 1000);&#xA;    stopWalk();&#xA;  }&#xA;}&#xA;&#xA;void startWalk() {&#xA;  walking = true;&#xA;  analogWrite(motorPin, 255);&#xA;}&#xA;&#xA;void stopWalk() {&#xA;  walking = false;&#xA;  analogWrite(motorPin, 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7rYsX.png&quot; alt=&quot;Motor &amp;amp; Arduino hookup&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1525" LastEditorUserId="1525" LastEditDate="2015-05-30T11:36:15.600" LastActivityDate="2015-10-27T15:20:09.227" Title="DC Motor not behaving reliably" Tags="|arduino-mega|motor|transistor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12247" PostTypeId="1" CreationDate="2015-05-29T23:24:52.937" Score="2" ViewCount="527" Body="&lt;p&gt;I have two different codes. The first one makes a LCD screen count the time and print it, then when one of the buttons on the LCD shield itself is pressed, it prints the time on the top line that it was pressed. That's the one below, I apologize that it has a lot of notes though it so unless it's in the Arduino program it looks confusing. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*--------------------------------------------------------------------------    ------------&#xA; Includes&#xA; --------------------------------------------------------------------------------------*/&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;   // include LCD library&#xA;/*--------------------------------------------------------------------------------------&#xA; Defines&#xA; --------------------------------------------------------------------------------------*/&#xA;// Pins in use&#xA;#define MILLIS_OVERFLOW 34359738&#xA;#define BUTTON_ADC_PIN           A0  // A0 is the button ADC input&#xA;#define LCD_BACKLIGHT_PIN         3  // D3 controls LCD backlight&#xA;// ADC readings expected for the 5 buttons on the ADC input&#xA;#define RIGHT_10BIT_ADC           0  // right&#xA;#define UP_10BIT_ADC            145  // up&#xA;#define DOWN_10BIT_ADC          329  // down&#xA;#define LEFT_10BIT_ADC          505  // left&#xA;#define SELECT_10BIT_ADC        741  // right&#xA;#define BUTTONHYSTERESIS         10  // hysteresis for valid button sensing           window&#xA;//return values for ReadButtons()&#xA;#define BUTTON_NONE               0  // &#xA;#define BUTTON_RIGHT              1  // &#xA;#define BUTTON_UP                 2  // &#xA;#define BUTTON_DOWN               3  // &#xA;#define BUTTON_LEFT               4  // &#xA;#define BUTTON_SELECT             5  // &#xA;//some example macros with friendly labels for LCD backlight/pin control, tested and can be swapped into the example code as you like&#xA;#define LCD_BACKLIGHT_OFF()     digitalWrite( LCD_BACKLIGHT_PIN, LOW )&#xA;#define LCD_BACKLIGHT_ON()      digitalWrite( LCD_BACKLIGHT_PIN, HIGH )&#xA;#define LCD_BACKLIGHT(state)    { if( state ){digitalWrite(     LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }&#xA;/*--------------------------------------------------------------------------------------&#xA; Variables&#xA; --------------------------------------------------------------------------------------*/&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds = 0, minutes = 34, hours = 8;&#xA;&#xA;byte buttonJustPressed  = false;         //this will be true after a          ReadButtons() call if triggered&#xA;byte buttonJustReleased = false;         //this will be true after a         ReadButtons() call if triggered&#xA;    byte buttonWas          = BUTTON_NONE;   //used by ReadButtons() for     detection of button events&#xA;        /*--------------------------------------------------------------------------------------&#xA;     Init the LCD library with the LCD pins to be used&#xA; --------------------------------------------------------------------------------------*/&#xA;       LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );   //Pins for the freetronics 16x2 LCD     shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7 )&#xA;/*--------------------------------------------------------------------------------------&#xA;     setup()&#xA;     Called by the Arduino framework once, before the main loop begins&#xA; --------------------------------------------------------------------------------------*/&#xA;    void setup()&#xA;    {&#xA;  //button adc input&#xA;      pinMode( BUTTON_ADC_PIN, INPUT );         //ensure A0 is an input&#xA;      digitalWrite( BUTTON_ADC_PIN, LOW );      //ensure pullup is off on A0&#xA;  //lcd backlight control&#xA;  digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is         high (on)&#xA;  pinMode( LCD_BACKLIGHT_PIN, OUTPUT );     //D3 is an output&#xA;  //set up the LCD number of columns and rows: &#xA;  lcd.begin( 16, 2 );&#xA;&#xA;  //Print some initial text to the LCD.&#xA;  Serial.begin(9600);&#xA;  lcd.begin( 16, 2 ); &#xA;&#xA;&#xA;&#xA;}&#xA;/*--------------------------------------------------------------------------------------&#xA; loop()&#xA; Arduino main loop&#xA; --------------------------------------------------------------------------------------*/&#xA;void loop()&#xA;{&#xA;  setClock();&#xA;  byte button;&#xA;&#xA;&#xA;  button = ReadButtons();&#xA;&#xA;&#xA;  /**&#xA;   * After set clock now you have 3 int variables with the current time&#xA;   */&#xA;  //seconds&#xA;  //minutes&#xA;  //hours&#xA;  lcd.setCursor ( 0, 1);&#xA;  lcd.print(hours);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(minutes);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(seconds);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(elapsedMillis);&#xA;&#xA;&#xA;      //get the latest button pressed, also the buttonJustPressed,     buttonJustReleased flags&#xA;&#xA;  //blank the demo text line if a new button is pressed or released, ready for a new label to be written&#xA;&#xA;  //show text label for the button pressed&#xA;   if(buttonJustPressed || buttonJustReleased)&#xA;  switch( button )&#xA;  {&#xA;&#xA;  case BUTTON_LEFT:&#xA;    {&#xA;      lcd.setCursor( 0, 0 );&#xA;               lcd.print(hours);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(minutes);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(seconds);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(elapsedMillis);&#xA;&#xA;      break;         &#xA;&#xA;    }&#xA;  default:&#xA;    {&#xA;      break;&#xA;    }&#xA;  }&#xA;&#xA;  if( buttonJustPressed )&#xA;    buttonJustPressed = false;&#xA;  if( buttonJustReleased )&#xA;    buttonJustReleased = false;&#xA;}&#xA;     /*--------------------------------------------------------------------------------------&#xA;     ReadButtons()&#xA;     Detect the button pressed and return the value&#xA;     Uses global values buttonWas, buttonJustPressed, buttonJustReleased.&#xA; --------------------------------------------------------------------------------------*/&#xA;        byte ReadButtons()&#xA;    {&#xA;  unsigned int buttonVoltage;&#xA;  byte button = BUTTON_NONE;   // return no button pressed if the below         checks don't write to btn&#xA;&#xA;  //read the button ADC pin voltage&#xA;  buttonVoltage = analogRead( BUTTON_ADC_PIN );&#xA;  //sense if the voltage falls within valid voltage windows&#xA;  if( buttonVoltage &amp;lt; ( RIGHT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_RIGHT;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( UP_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( UP_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_UP;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( DOWN_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( DOWN_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_DOWN;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( LEFT_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( LEFT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_LEFT;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( SELECT_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( SELECT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_SELECT;&#xA;  }&#xA;  //handle button flags for just pressed and just released events&#xA;  if( ( buttonWas == BUTTON_NONE ) &amp;amp;&amp;amp; ( button != BUTTON_NONE ) )&#xA;  {&#xA;    //the button was just pressed, set buttonJustPressed, this can optionally be used to trigger a once-off action for a button press event&#xA;//it's the duty of the receiver to clear these flags if it wants to detect a new button change event&#xA;    buttonJustPressed  = true;&#xA;    buttonJustReleased = false;&#xA;  }&#xA;  if( ( buttonWas != BUTTON_NONE ) &amp;amp;&amp;amp; ( button == BUTTON_NONE ) )&#xA;  {&#xA;    buttonJustPressed  = false;&#xA;    buttonJustReleased = true;&#xA;  }&#xA;&#xA;  //save the latest button value, for change event detection next time round&#xA;  buttonWas = button;&#xA;&#xA;  return( button );&#xA;}&#xA;void setClock()&#xA;{&#xA;  currentMillis = millis();&#xA;      /**&#xA;   * The only moment when currentMillis will be smaller than previousMillis&#xA;   * will be when millis() oveflows&#xA;   */&#xA;  if (currentMillis &amp;lt; previousMillis){&#xA;    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;&#xA;  } &#xA;  else {&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;  }&#xA;&#xA;  /**&#xA;   * If we use equals 1000 its possible that because of the mentioned loop     limitation&#xA;   * you check the difference when its value is (999) and on the next loop its value is (1001)&#xA;   */&#xA;  if (elapsedMillis &amp;gt; 999){&#xA;    seconds++;&#xA;    elapsedMillis = elapsedMillis - 1000;&#xA;  }&#xA;&#xA;  if (seconds == 60){&#xA;    minutes++;&#xA;    seconds = 0;&#xA;  }&#xA;  if (minutes == 60){&#xA;    hours++;&#xA;    minutes = 0;&#xA;  }&#xA;  if (hours == 24){&#xA;    hours = 0;&#xA;  }&#xA;&#xA;  previousMillis = currentMillis;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next code is to control the speaker and makes it play happy birthday when the a proximity sensor is set off. I need to somehow merge the two codes so that when the proximity sensor is set off the speaker plays the sound, but so that the clock continues to still count. Does anyone know how I can do this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;int timer = 1000;&#xA;int C = 262;&#xA;int D = 294;&#xA;int E = 330;&#xA;int F = 349;&#xA;int G = 392;&#xA;int A = 440;&#xA;int B = 494;&#xA;int Bflat = 466;&#xA;int Chigh = 523;&#xA;&#xA;&#xA;LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );&#xA;const int analogPin = A1;    // pin that the sensor is attached to&#xA;const int threshold = 400;&#xA;&#xA;void setup() &#xA;{&#xA;     // initialize serial communications at 9600 bps:&#xA;     Serial.begin(9600);&#xA;     pinMode(10, OUTPUT); // Red LED&#xA;     pinMode(12, OUTPUT); // Yellow LED&#xA;     pinMode(11, OUTPUT); // Green LED&#xA;     pinMode(13, OUTPUT); // Speaker&#xA;         lcd.begin(16, 2);&#xA; }&#xA;void loop()&#xA;{&#xA; int analogValue = analogRead(analogPin);&#xA;&#xA;  if (analogValue &amp;gt; threshold) {&#xA;&#xA;tone(13,C,timer/2);// Happy Bday to You&#xA;delay(200);&#xA;tone(13,C,timer/2);&#xA;delay(200);&#xA;tone(13,D,timer/2);&#xA;delay(400);&#xA;tone(13,C,timer/2);&#xA;delay(400);&#xA;tone(13,F,timer/2);&#xA;delay(400);&#xA;tone(13,E,timer);&#xA;delay(750);&#xA;&#xA; }&#xA;else {&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8588" LastActivityDate="2015-05-29T23:24:52.937" Title="Merging two codes, one for speaker one for LCD clock (Arduino Uno)" Tags="|arduino-uno|lcd|time|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12248" PostTypeId="2" ParentId="8511" CreationDate="2015-05-29T23:34:30.627" Score="4" Body="&lt;p&gt;Check the label of the voltage regulator, KB50 for 5V and KB33 for 3.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2CkXa.jpg&quot; alt=&quot;Voltage Regulator&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10350" LastActivityDate="2015-05-29T23:34:30.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12249" PostTypeId="2" ParentId="12246" CreationDate="2015-05-30T10:16:01.360" Score="1" Body="&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your transistor is the wrong way round.&lt;br&gt;&#xA;Rotate it 180 degree (so that collector and emitter are swapped) and it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are much better transistors available for this job, but this one should work when correctly connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swap, test, report back. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blue wire goes from emitter (right hand lead) to Arduino ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3O6Yx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Longer:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transistor is almost certainly &quot;backwards&quot; as above. More on that below, but first some comment on the actual transistor used and a superior alternative. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it should work better than you describe, the BC548 is not a very good transistor for motor driving. It's maximum collector current is 100 mA. While you do not state the required motor current, within sensible limits a good guide is that the more a transistor can handle the better it will work, all else being equal. A 500 mA rated part would work better. An excellent pair of small transistor for &quot;playing&quot; are the BC327-40 (PNP) and the complementary BC337-40 (NPN). These have guaranteed current gains (effectively current amplification factor) of 250 and typically of 400. They are typically rated at 45V and 500 mA. &#xA;The Fairchild versions &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/BC/BC337.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;data sheet here&lt;/a&gt; from Digikey have an absolute maximum 800 mA rating. While the part was originally a European one it is widely available in the US and Asia and is usually about the same price as transistors with substantially inferior specs. eg see Digikey pricing below for BC548B and BC337-40 in 1, 10 and 100 quantity. The BC337 costs 1 cent more per transistor in each case. The BC337 comes in 3 versions with suffixes -16, -25 and -40. This relates to the current gain. The -40 part has an average Beta or current gain of 400. This is better (higher) than most alternatives and costs little or no more than the lower gain -16 and -25 parts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.fairchildsemi.com/datasheets/BC/BC546.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;BC548B datasheet here&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://www.fairchildsemi.com/datasheets/BC/BC337.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;BC337-40 datasheet here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.digikey.com/product-detail/en/BC548BU/BC548BU-ND/976761&quot; rel=&quot;nofollow noreferrer&quot;&gt;BC548B pricing&lt;/a&gt;&lt;br&gt;&#xA;1 10 100 prices are 22 / 20 / 11 cents each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.digikey.com/product-detail/en/BC33740TA/BC33740TACT-ND/1532788&quot; rel=&quot;nofollow noreferrer&quot;&gt;BC337-40 pricing&lt;/a&gt;&lt;br&gt;&#xA;1 10 100 prices are   23 / 21 / 12 cents each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to that the pinout is CBE (collector base emitter) left to right looking at flat front with pins down. There are occasionally variations between manufacturers (but should not be) but if the datasheet matches your transistor it is &quot;in backwards&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Swap C &amp;amp; E by rotating 180 degrees and report back.&lt;br&gt;&#xA;With C&amp;amp;E swapped it acts like an NPN withj very low current gain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Presumable where you saay digitalWrite you meant analogWrite?&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-05-30T11:38:33.507" LastActivityDate="2015-05-30T11:38:33.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12250" PostTypeId="1" CreationDate="2015-05-30T11:43:42.860" Score="1" ViewCount="296" Body="&lt;p&gt;I'm new to Arduino and I'd like to realize a system using Arduino One and SparkFun Electret Microphone Breakout (BOB-09964) to turn on/off lights clapping my hands. &lt;a href=&quot;https://www.sparkfun.com/products/9964&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9964&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the components I need? I'm going to buy them and I don't want to buy components which I will not use soon (so no starter kits but only a breadboard, resistors, LEDs, etc...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for this basic question but as I said I'm new to this world.&lt;/p&gt;&#xA;" OwnerUserId="10341" LastActivityDate="2016-12-31T12:58:23.263" Title="Arduino ligths on/off clapping hands" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12251" PostTypeId="2" ParentId="12250" CreationDate="2015-05-30T13:27:56.423" Score="1" Body="&lt;p&gt;If you start from the beginning of the project, instead of trying to jump in half way through, you'll know precisely what components you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your first step shouldn't be trying to order components, but to identify (through research) how the technology works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second is to find out how it can be implemented, by looking at existing schematics and designs that other people have created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third is to design your own schematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth is to prototype it.  It's only at this stage that you should be thinking about what components to order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go back to stage one and do the research. Thanks to the likes of Google it'll probably only take you a few minutes.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-30T13:27:56.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12252" PostTypeId="1" CreationDate="2015-05-30T14:21:18.783" Score="2" ViewCount="69" Body="&lt;p&gt;I've got 2 Analog accelerometers and a Gyro/Acc/Mag connected to my arduino and it's been working and reading fine until a few hours ago. &#xA;I've got the arduino sending data over the serial connection and Unity reading the values and interpreting. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LSM303.h&amp;gt;&#xA;#include &amp;lt;L3G.h&amp;gt;&#xA;&#xA;LSM303 compass;&#xA;L3G gyro;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  compass.init();&#xA;  compass.enableDefault();&#xA;  gyro.init();&#xA;  gyro.enableDefault();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  /* Accelerometers: */&#xA;&#xA;  int sensorValueA = analogRead(A0);&#xA;  int sensorValueB = analogRead(A1);&#xA;  //Serial.flush();&#xA;  Serial.print(sensorValueA);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.println(sensorValueB);&#xA;  delay(10);&#xA;&#xA;  /* Accelerometer + Magnometer: */&#xA;&#xA;  compass.read();&#xA;  //Serial.flush();&#xA;  Serial.print(compass.a.x);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(compass.a.y);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(compass.a.z);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(compass.m.x);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(compass.m.y);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.println(compass.m.z);&#xA;  delay(10);&#xA;&#xA;  /* Gyro: */&#xA;&#xA;  gyro.read();&#xA;  //Serial.flush();&#xA;  Serial.print((int)gyro.g.x);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print((int)gyro.g.y);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.println((int)gyro.g.z);&#xA;  delay(10);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I have it unplugged for several minutes then replug it, the print will work for a min or two then just stop completely. I've checked wires several times and it hasn't moved since it was working this morning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said, which I think is probably of importance, the TX light is off when not printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MpnN3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;em&gt;Acc1:&lt;/em&gt; GND - GND | VCC - 3.3v | Y - A2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Acc2:&lt;/em&gt; GND - GND | VCC - 3.3v | Y - A3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Gyro:&lt;/em&gt; VIN - 5v | GND - GND | SAO - A4 | SCL - A5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10357" LastEditorUserId="4131" LastEditDate="2015-08-11T12:07:44.143" LastActivityDate="2015-08-11T12:07:44.143" Title="TX light not flashing, screen.print works sometimes.. UNO" Tags="|arduino-uno|serial|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12253" PostTypeId="2" ParentId="12244" CreationDate="2015-05-30T15:54:47.040" Score="1" Body="&lt;p&gt;SD card need 3.3v for power and logic level. So most breakouts have a buffer chip to convert the logic levels from 5v to 3.3v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS, you could use an microSD to SD adapter, and solder some wires to its pads, if you are unable to solder the tiny pins on the part you ordered.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-05-30T15:54:47.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12254" PostTypeId="1" AcceptedAnswerId="12259" CreationDate="2015-05-30T16:13:16.027" Score="0" ViewCount="371" Body="&lt;p&gt;Good evening :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am fairily new to coding the fabulous Arduino UNO. My project right now are consisting of reading Temperature from a DHT22 (AM2302) and writing to a 4-digit 7-segment display. I have got the display to work, but the system does not update the temperature at all. Just the first reading are displayed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DHT.h&amp;gt;&#xA;  #include &amp;lt;TimerOne.h&amp;gt;&#xA;  #include &amp;lt;SevenSeg.h&amp;gt;&#xA;&#xA;  #define DHTPIN 4    //Defines the temp-pin&#xA;&#xA;  /* DHT22- Pin1 (left) - 5V/3.3V&#xA;  Pin2- DATA&#xA;    Connect a 10K res from pin1 to pin2&#xA;  Pin3 - NC&#xA;  Pin4 - GND&#xA;  */&#xA;&#xA;  //#define DHTTYPE DHT11   // DHT 11 &#xA;  #define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;  //#define DHTTYPE DHT21   // DHT 21 (AM2301)&#xA;&#xA;  DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;  SevenSeg disp (13 ,2 ,3 ,8 ,5 ,6 ,7);&#xA;  //            (11, 7, 4, 2, 1, 10, 5)&#xA;  const int numOfDigits =4;&#xA;  int digitPins [ numOfDigits ]={9,10,11,12};  // uten transistorer&#xA;  //                            (12,9,8,6) Alle med 220 Ohm seriemotstand&#xA;  //int digitPins [ numOfDigits ]={12,11,10,9};  // med transistorer&#xA;&#xA;  void setup () &#xA;  {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;DHT22&quot;);&#xA;&#xA;    disp . setCommonCathode();  // uten transistorer&#xA;    //disp . setActivePinState(HIGH,HIGH);  // med transistoere&#xA;    disp . setDigitPins ( numOfDigits , digitPins );&#xA;&#xA;    Timer1.initialize(15);   // 0.015 sek&#xA;    Timer1.attachInterrupt(loop);&#xA;  }&#xA;&#xA;  void loop() {&#xA;&#xA;    dht.begin();&#xA;&#xA;    delay(300);&#xA;    float t = dht.readTemperature();   &#xA;&#xA;    disp.writeFloat(t);&#xA;    Serial.println(t);&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I get the Sensor to update regularly?&lt;/p&gt;&#xA;" OwnerUserId="10358" LastActivityDate="2015-05-30T21:08:50.633" Title="DHT22 Does not update" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12255" PostTypeId="2" ParentId="12254" CreationDate="2015-05-30T16:20:45.927" Score="0" Body="&lt;p&gt;Try this in your loop method&#xA;The while loop will read the temperature, write to the display and write to the console.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  dht.begin();&#xA;  float t; &#xA;  while(1)&#xA;  {&#xA;    t = dht.readTemperature();   &#xA;    disp.writeFloat(t);&#xA;    Serial.println(t);&#xA;  }&#xA;  delay(300);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="10334" LastActivityDate="2015-05-30T16:20:45.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12256" PostTypeId="1" CreationDate="2015-05-30T17:08:40.660" Score="0" ViewCount="2399" Body="&lt;p&gt;I am using Arduino Duemilanove and a hall effect sensor to calculate the speed of a motor.  When I used sensor out directly to Interrupt0, the rising edges of noise were also detected. So the speed calculation went wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now  sensor is connected to A0.and a threshold is put. Pin No 13 is connected to Interrupt 0(Pin 2). I use the following code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile byte count;&#xA; const int analogPin = A0;&#xA; const int digitalPin=13;&#xA; const int threshold =20;&#xA; unsigned int rpm;&#xA; unsigned long starttime;&#xA;&#xA; void setup()&#xA; {&#xA;   pinMode(digitalPin,OUTPUT);&#xA;   digitalWrite(analogPin,HIGH);&#xA;   digitalWrite(digitalPin,HIGH);&#xA;   Serial.begin(9600);&#xA;   attachInterrupt(0,sense,FALLING);&#xA;   rpm=0;&#xA;   starttime=0;&#xA;   count=0;    &#xA; }&#xA; void loop()&#xA; {&#xA;   int sensorValue = analogRead(analogPin);&#xA;   Serial.println(sensorValue);&#xA;   if (sensorValue &amp;lt; threshold)&#xA;   {&#xA;     digitalWrite(digitalPin,LOW);&#xA;     if (count&amp;gt;=20)&#xA;     {&#xA;       rpm=60*1000*count/(millis()-starttime);&#xA;       starttime=millis();&#xA;       count=0;&#xA;       Serial.println(rpm,DEC);&#xA;     }&#xA;   }&#xA;   else&#xA;   {&#xA;     digitalWrite(digitalPin,HIGH);&#xA;   }&#xA;&#xA; }&#xA; void sense()&#xA; {&#xA;  count++;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get actual speed only in between. The speed changes back . I feel there is some problem with the sampling or rpm updation. Looking forward for help&lt;/p&gt;&#xA;" OwnerUserId="10360" LastEditorUserId="4143" LastEditDate="2015-05-30T20:02:16.483" LastActivityDate="2015-09-29T15:36:31.310" Title="Hall sensor noise removal" Tags="|sensors|motor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12257" PostTypeId="2" ParentId="12244" CreationDate="2015-05-30T19:03:26.483" Score="1" Body="&lt;p&gt;If your willing to be adventurous and step away from Arduino (as in AVR chips) and try out some of the myriad of other offerings there are around now, then you may find a better board that fits your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One popular example is the &lt;a href=&quot;http://fubarino.org/sd/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fubarino SD&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gnq5L.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gives you a PIC32 chip (128KB RAM, 512MB Flash, 80MHz) with a microSD card slot already on the board.  And it measures just 2.5cm x 7cm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you may need to tweak your programming a little to get it working as you want - the IDE (&lt;a href=&quot;http://chipkit.net/started/install-chipkit-software/&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPIDE&lt;/a&gt;) is a bit old and the Arduino API compatibility is slightly behind the times (but catching up gradually). It's also fully supported by my &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;UECIDE&lt;/a&gt; programming environment.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-30T19:03:26.483" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12258" PostTypeId="2" ParentId="8058" CreationDate="2015-05-30T19:20:43.943" Score="4" Body="&lt;p&gt;As the creator of &lt;a href=&quot;http://platformio.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;PlatformIO&lt;/a&gt; I would recommend you to look into it. It's a cross-platform code builder and missing library manager. It can build the same code for the many popular embedded development platforms and boards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PlatformIO can be be integrated with many popular &lt;a href=&quot;http://docs.platformio.org/en/latest/ci/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Continuous Integration (CI)&lt;/a&gt; systems (or your own). See &lt;a href=&quot;http://docs.platformio.org/en/latest/ci/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;documentation with examples&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's look into &lt;code&gt;.travis.yml&lt;/code&gt; config/template for Travis CI:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;language: python&#xA;python:&#xA;    - &quot;2.7&quot;&#xA;&#xA;env:&#xA;    - PLATFORMIO_CI_SRC=path/to/source/file.c&#xA;    - PLATFORMIO_CI_SRC=path/to/source/file.ino&#xA;    - PLATFORMIO_CI_SRC=path/to/source/directory&#xA;&#xA;install:&#xA;    - python -c &quot;$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)&quot;&#xA;&#xA;script:&#xA;    - platformio ci --board=TYPE_1 --board=TYPE_2 --board=TYPE_N&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Integration for &lt;code&gt;USB_Host_Shield_2.0&lt;/code&gt; project. The &lt;code&gt;.travis.yml&lt;/code&gt; configuration file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;language: python&#xA;python:&#xA;    - &quot;2.7&quot;&#xA;&#xA;env:&#xA;    - PLATFORMIO_CI_SRC=examples/acm/acm_terminal&#xA;    - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiIRCamera PLATFORMIO_BUILD_FLAGS=&quot;-DWIICAMERA&quot;&#xA;    - PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback&#xA;    - PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB&#xA;    # - ...&#xA;&#xA;install:&#xA;    - python -c &quot;$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)&quot;&#xA;&#xA;    # Libraries from PlatformIO Library Registry&#xA;    # http://platformio.org/#!/lib/show/416/TinyGPS&#xA;    # http://platformio.org/#!/lib/show/417/SPI4Teensy3&#xA;    - platformio lib install 416 417&#xA;&#xA;script:&#xA;    - platformio ci --board=uno --board=teensy31 --board=due --lib=&quot;.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Configuration file: &lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0/blob/master/.travis.yml&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/felis/USB_Host_Shield_2.0/blob/master/.travis.yml&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Build History: &lt;a href=&quot;https://travis-ci.org/felis/USB_Host_Shield_2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://travis-ci.org/felis/USB_Host_Shield_2.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4568" LastEditorUserId="4143" LastEditDate="2019-03-07T11:03:08.807" LastActivityDate="2019-03-07T11:03:08.807" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12259" PostTypeId="2" ParentId="12254" CreationDate="2015-05-30T20:33:45.193" Score="3" Body="&lt;p&gt;Try moving &lt;code&gt;dht.begin();&lt;/code&gt; to &lt;code&gt;setup()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DHTs are pretty slow and need some time (of the order of seconds!) between consecutive reads. In &lt;code&gt;dht.begin()&lt;/code&gt; an internal timer is reset that is used in &lt;code&gt;readTemperature()&lt;/code&gt; to ensure that reading data from the DHT is not attempted in shorter intervals than supported. By calling &lt;code&gt;dht.begin()&lt;/code&gt; every 300 ms you're making this meachanism inoperative. You're supposed to call &lt;code&gt;dht.begin()&lt;/code&gt; only once at start-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: And please also remove the &lt;code&gt;Timer1&lt;/code&gt; that calls &lt;code&gt;loop&lt;/code&gt;. &lt;code&gt;loop&lt;/code&gt; is already an infinite loop, so no good in calling it additionally from an interrupt...&lt;/p&gt;&#xA;" OwnerUserId="1677" LastEditorUserId="1677" LastEditDate="2015-05-30T21:08:50.633" LastActivityDate="2015-05-30T21:08:50.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12262" PostTypeId="1" CreationDate="2015-05-31T05:40:05.977" Score="-1" ViewCount="2012" Body="&lt;p&gt;can somebody tell me what`s wrong with my code, i am using it to calculate rpm using incremental encoder&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long counter=0;&#xA; long  rpm = 0, z =0;&#xA; long  ini_time = 0;&#xA;long  end_time=0;&#xA;&#xA;&#xA;&#xA;&#xA;void setup(){&#xA;  attachInterrupt(0, A_RISE, RISING);&#xA;&#xA;  Serial.begin(115200);&#xA;}//setup&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;    Serial.println(rpm);&#xA;}&#xA;&#xA;void A_RISE(){&#xA;  counter ++;&#xA;  if (counter == 1)&#xA;    ini_time = micros();&#xA;  else if (counter&amp;gt;470){ //470 is ticks per revolution&#xA;    z = counter;&#xA;    rpm_counter(z);&#xA;&#xA;    counter =0;&#xA;  }&#xA;}&#xA;&#xA;void rpm_counter(int x){&#xA;&#xA;  end_time=micros()-ini_time;&#xA;  rpm=(60*10^6)/end_time;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6745" LastActivityDate="2023-02-13T06:00:30.067" Title="Incremental encoder code" Tags="|arduino-uno|rotary-encoder|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12264" PostTypeId="1" AcceptedAnswerId="12289" CreationDate="2015-05-31T11:55:37.360" Score="3" ViewCount="16730" Body="&lt;p&gt;I am looking at creating a fleet of low power, Arduino driven devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would need some kind of GPS on them all (or could triangulate through phone network?) plus a connection to the internet - just for HTTP POST requests. GPRS or GSM would do but 3G would be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the best (price is a major factor because I'm trying to do a fleet) GSM, GPRS or 3G modules that I can use with Arduinos? As I said, I need their location so one with GPS built in would be great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;The amount of devices in the fleet will change, so the entire network needs to be dynamic which is why having a GPRS/GSM module on each one would work so well.&lt;/p&gt;&#xA;" OwnerUserId="7755" LastEditorUserId="7755" LastEditDate="2015-06-01T15:16:54.523" LastActivityDate="2017-04-27T07:32:18.773" Title="Cheapest Arduino GPRS or 3G solution" Tags="|gsm|gps|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12266" PostTypeId="1" CreationDate="2015-05-31T12:20:59.410" Score="0" ViewCount="470" Body="&lt;p&gt;I have tried to connect a GSM dongle to a Intel Galileo Gen2 board and test the functionality of sending and receiving SMS through it.I know that it is easier to use a GSM shield to do above, but I'm currently doing a project in the way i mentioned above.Basically in Linux, we should know the serial port(like &lt;code&gt;ttyACM0&lt;/code&gt; in &lt;code&gt;/dev&lt;/code&gt; directory) correspond to the device to communicate with it(Using AT commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but when i tried it in Galileo board it doesn't show such a serial port.but it detect device because &lt;code&gt;lsusb&lt;/code&gt; command shows the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does anyone can help me to solve this matter? &lt;/p&gt;&#xA;" OwnerUserId="8041" LastActivityDate="2016-01-26T23:19:47.490" Title="Connecting GSM Dongle to Intel Galileo-Gen 2" Tags="|serial|gsm|arduino-galileo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12267" PostTypeId="1" CreationDate="2015-05-31T14:32:07.883" Score="0" ViewCount="941" Body="&lt;p&gt;I bought an OV7670 camera and I would like to use the following code:&#xA;&lt;a href=&quot;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I wonder whether it is possible to use SPI instead of I2C when I transfer the image data through Arduino to other breakout boards.&lt;/p&gt;&#xA;" OwnerUserId="10070" LastEditorUserId="4628" LastEditDate="2015-07-08T13:24:30.957" LastActivityDate="2016-02-03T16:57:38.570" Title="Transferring OV7670 data with SPI port" Tags="|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12268" PostTypeId="1" CreationDate="2015-05-31T15:37:56.650" Score="0" ViewCount="133" Body="&lt;p&gt;I have included the &lt;strong&gt;RF24Network&lt;/strong&gt; library in my project. I tried to use the Simple Transmit/Receive example from &lt;a href=&quot;https://maniacbug.wordpress.com/2012/03/30/rf24network/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; but when it calls the &lt;strong&gt;network.begin()&lt;/strong&gt; my arduino restarts. I placed some &lt;strong&gt;Serial.println()&lt;/strong&gt; in order to understand where is the problem. This problem appears only in my Arduino Mega 1280. I tried the same code on my Arduino Pro mini and it works like a charm. What causes this? How to fix that? It is very important to use the specific library. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-31T17:19:47.520" Title="Arduino resets when I call network.begin()" Tags="|arduino-mega|nrf24l01+|networking|rf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12269" PostTypeId="2" ParentId="11646" CreationDate="2015-05-31T15:57:58.840" Score="2" Body="&lt;p&gt;Answering my own question, I think I found some way to get the solar panel face the sun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said before, the inclinometer reads the position and makes some calculations using lookposition() function, then this happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void lookforsun() {&#xA;  while ((targetElevation + 3) &amp;lt; realElevation | (targetElevation - 3) &amp;gt; realElevation) {&#xA;&#xA;    Serial.println(&quot;Elevation is not correct&quot;);&#xA;&#xA;    while (realElevation &amp;lt; targetElevation)&#xA;    { Serial.println(&quot;Moving to south&quot;);&#xA;      digitalWrite(south, LOW);&#xA;      lookposition();&#xA;    }&#xA;    digitalWrite(south, HIGH);&#xA;&#xA;    while (realElevation &amp;gt; targetElevation)&#xA;    { Serial.println(&quot;Moving to north&quot;);&#xA;      digitalWrite(north, LOW);&#xA;      lookposition();&#xA;    }&#xA;    digitalWrite(north, HIGH);&#xA;  }&#xA;&#xA;&#xA;  while ((targetHourangle+3) &amp;lt; realHourangle |  (targetHourangle-3) &amp;gt; realHourangle  ) {&#xA;&#xA;    Serial.print(&quot;Hour angle is not correct&quot;);&#xA;    while (realHourangle &amp;gt; targetHourangle)&#xA;    { Serial.println(&quot;Moving to east&quot;);&#xA;      digitalWrite(east, LOW);&#xA;      lookposition();&#xA;    }&#xA;    digitalWrite(east, HIGH);&#xA;&#xA;    while (realHourangle &amp;lt; targetHourangle)&#xA;    { Serial.println(&quot;Moving to west&quot;);&#xA;      digitalWrite(west, LOW);&#xA;      lookposition();&#xA;    }&#xA;    digitalWrite(west, HIGH);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see I took the frightening way of nested while loops, but appears to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first while measures if realElevation is between +-3 degrees of targetElevation, if realElevation is far away (target+-3) enters the second while loop, which determines if needs to go up or down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I included the +-3 because the sensor is so very sensible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much  Russell McMahon and portforwardpodcast for your ideas!&lt;/p&gt;&#xA;" OwnerUserId="9931" LastActivityDate="2015-05-31T15:57:58.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12270" PostTypeId="2" ParentId="12268" CreationDate="2015-05-31T17:19:47.520" Score="2" Body="&lt;p&gt;The problem was that the RF24Network library is &lt;strong&gt;not compatible&lt;/strong&gt; with the version of Arduino IDE I have. I downloaded Arduino IDE v1.0 and now it works like a charm. I will send an email to maniacbug to tell him about the problem.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2015-05-31T17:19:47.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12271" PostTypeId="1" CreationDate="2015-05-31T17:36:59.983" Score="2" ViewCount="1611" Body="&lt;p&gt;hej guys,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;recently I upgraded to Arduino's 1.6.4 IDE just to find out, that I can't seem to upload anything to my board. More specifically: The 1.6.4 IDE is not giving me the option to select the /tty/ board from the serial port list. I am avid Sublime Text 2 user, so obviously I tried to select the port in Stino and voilá: I was &lt;strong&gt;able&lt;/strong&gt; to upload it to my boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I wanted to sort out if this is a software or hardware problem, I started to experiment with all my boards:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(all of them official boards, no clones)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 x Arduino Micro&lt;/li&gt;&#xA;&lt;li&gt;1 x Arduino Uno r3&lt;/li&gt;&#xA;&lt;li&gt;1 x Arduino Duemillanove&lt;/li&gt;&#xA;&lt;li&gt;1 x Arduino Mega 2560 r3&lt;/li&gt;&#xA;&lt;li&gt;12 x Teensy 3.1&lt;/li&gt;&#xA;&lt;li&gt;a bunch of different USB cables.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;none of these boards were registered by the Arduino 1.6.4 IDE, even after restarting the software and the computer several times. i'd only get this in my port selection:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/8SeFr.png&quot; alt=&quot;serial ports only showing /cu/&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;funny enough, my terminal told me the /tty/ device was there. here with the uno connected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Dash:~ julianh$    ls /dev/tty.*&#xA;/dev/tty.Bluetooth-Incoming-Port&#xA;/dev/tty.Bluetooth-Modem&#xA;/dev/tty.usbmodemfa131&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also tried to re-install FTDI drivers, with no results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;only when I installed the old (trusty) 1.6.1 version, I was able to upload again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;all of the boards are also working fine. I just used my uno and mega another machine a few days ago for some side projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can someone confirm this problem with the new IDE 1.6.4 on OSX Yosemite 10.10.3? or is there any solution available online?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks!&lt;/p&gt;&#xA;" OwnerUserId="10374" LastActivityDate="2022-11-27T05:03:25.413" Title="Arduino 1.6.4 not showing any /tty/ options in Serial ports" Tags="|arduino-uno|arduino-mega|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12272" PostTypeId="2" ParentId="12266" CreationDate="2015-05-31T17:48:28.993" Score="1" Body="&lt;p&gt;Try updating the firmware. I'm not sure if this affects also ACM type serial ports, but the initial version of the firmware was not even creating standard /dev/ttySx, rather some weird proprietary interface.&#xA;Luckily this was fixed later on. So, in case you are still running the FW that the board came with, chances are you are having these weird serial ports.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-05-31T17:48:28.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12273" PostTypeId="1" AcceptedAnswerId="12274" CreationDate="2015-05-31T18:20:33.510" Score="3" ViewCount="630" Body="&lt;p&gt;I am currently working on a project, where I design a PID-Controller for a 2-axis stabilization with brushless-propeller-motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Does an Arduino UNO have enough computing power to perform this task in a useful manner? &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO Specs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And secondly: If the UNO was really too slow for this task, would the newly released Arduino ZERO PRO perform at an acceptable rate? &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardZero&quot; rel=&quot;nofollow&quot;&gt;Arduino ZERO PRO Specs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help and inputs in advance!&lt;/p&gt;&#xA;" OwnerUserId="10376" OwnerDisplayName="hallole" LastActivityDate="2015-05-31T19:05:43.253" Title="Arduino UNO/ZERO PRO, enough computing power for PID-controller?" Tags="|power|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12274" PostTypeId="2" ParentId="12273" CreationDate="2015-05-31T19:05:43.253" Score="5" Body="&lt;p&gt;Assuming you're not doing anything too fancy, yes, it should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's even a library to do all the work for you: &lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot;&gt;http://playground.arduino.cc/Code/PIDLibrary&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-05-31T19:05:43.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12275" PostTypeId="2" ParentId="12002" CreationDate="2015-05-31T19:57:31.923" Score="5" Body="&lt;p&gt;I've been searching through the net for some days, in order to discover how I could easily upload a sketch to an Arduino that is not phisically connected to my PC, but instead that is connected to an another one, that belongs to the same LAN. I mean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PC1-SERVER&#xA;Arduino Uno is connected to this PC with classic USB cable.&#xA;This PC is running Ubuntu linux, and sees Arduino as a serial port /dev/ttyACM0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PC2-CLIENT&#xA;This is the PC where I create and compile the sketch. &#xA;I want to upload the sketch to the Arduino Uno described above (so, connected to SERVER, port /dev/ttyACM0)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SOLUTION:&#xA;server-side commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get install ssh-server ser2net&#xA;&#xA;sudo passwd root    (to set the root password)&#xA;&#xA;sudo reboot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;client-side commands (assuming 192.168.0.7 as IP address of SERVER):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssh -L 8086:localhost:8086 root@192.168.0.7 \&#xA;'/usr/sbin/ser2net -d -C &quot;8086:raw:600:/dev/ttyACM0:115200 NONE 1STOPBIT \&#xA;8DATABITS -XONXOFF LOCAL -RTSCTS HANGUP_WHEN_DONE &quot;'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can then upload sketches to arduino doing this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C /path/to/avrdude.conf -p atmega328p -c arduino -P net:localhost:8086 -U flash:w:/path/to/file.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE:&#xA;In Eclipse, if you are using the arduino plugin, just place &quot;net:localhost:8086&quot; in the configuration panel, where &quot;port:&quot; field is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution was also posted on &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=326850.0&quot; rel=&quot;nofollow&quot;&gt;arduino forum&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10183" LastActivityDate="2015-05-31T19:57:31.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12276" PostTypeId="1" CreationDate="2015-05-31T23:00:20.427" Score="0" ViewCount="467" Body="&lt;p&gt;I have two projects in my Visual Studio Community 2013 solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created a project for Arduino, and create another project for Test. When I run the project tests without adding the Arduino project reference, it run ok, but when I add the Arduino project reference I get it error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LNK1561: entry point must be defined D:\VisualStudioArduino\PrinterProject\LINK PrinterProject&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the entry point for Arduino project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not generate any file like a dll or main file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to solve this error?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;UPDATE I&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I also tried this configuration in the Arduino Project but I get the same error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Properties -&amp;gt; Linker -&amp;gt; System -&amp;gt; SubSystem to &quot;Windows (/SUBSYSTEM:WINDOWS)&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;UPDATE II&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am using Visual Micro extension. But the problems is when I try to compile the Test project. Then I recreate this scenario with a C++ console application and create a simple class, and create a test project and added the console application reference to test project and it worked. Then my doubts is about to how do I configure a Test Project to test my Arduino project.&lt;/p&gt;&#xA;" OwnerUserId="10295" LastEditorUserId="19409" LastEditDate="2016-04-27T16:13:35.677" LastActivityDate="2016-04-27T16:13:35.677" Title="Testing Arduino with Visual Studio Community 2013 raise LNK error" Tags="|arduino-mega|visualstudio|testing|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12277" PostTypeId="2" ParentId="12271" CreationDate="2015-05-31T23:14:57.670" Score="-1" Body="&lt;p&gt;I had the same problem when updated to 1.6.4, but with a Spark fun Pro micro. &#xA;Did a &quot;reset to bootloader&quot; on the pro micro, and hit upload, and it worked&#xA; out nice and it still does! &lt;/p&gt;&#xA;" OwnerUserId="9922" LastActivityDate="2015-05-31T23:14:57.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12278" PostTypeId="1" CreationDate="2015-05-31T23:58:37.840" Score="2" ViewCount="10425" Body="&lt;p&gt;I have a &lt;a href=&quot;https://github.com/HorstBaerbel/NerDisco&quot; rel=&quot;nofollow noreferrer&quot;&gt;software&lt;/a&gt; sending bitmap data to an Arduino Pro 5V 16MHz 328P that drives an LED display (&lt;a href=&quot;https://github.com/HorstBaerbel/NerDisco/blob/master/LEDStream_WS2812B/LEDStream_WS2812B.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;sketch&lt;/a&gt;). This works using the USB-Serial adapter for the Arduino Pro with baud rates up to 500000 Baud. Now I wanted to switch to Bluetooth...&lt;br&gt;&#xA;I tried connecting a 5V HC-05 module (set to 230400 Baud 8N1) to the hardware RX/TX pins on the Arduino Pro (Pins 0/1) and connect the PC to the Bluetooth serial port wirelessly (e.g. /dev/rfcomm0 on Linux). My problem is that I can receive data on the PC side using a terminal (the 'Ada' string is received), but nothing is displayed on the LED display. I have tried connecting an oscilloscope to the RX/TX pins on the Arduino and Data is arriving from the HC-05 module TX pin to the Arduino RX pin.&lt;br&gt;&#xA;When the USB-Serial adapter is connected to the same pins (0/1 instead of the regular pin header) it still works as before, so there should be no connection issues.&lt;br&gt;&#xA;What I tried was adding a 5kOhm resistor from the Arduino RX line to ground. (I found this hint somewhere &lt;a href=&quot;https://arduino.stackexchange.com/questions/790/corrupted-output-from-hc-05-bluetooth-module&quot;&gt;here&lt;/a&gt;), but no dice...&#xA;I'm not sure what's wrong, because communication IS working over the USB-Serial adapter. Any ideas on what to try?!&lt;/p&gt;&#xA;" OwnerUserId="8442" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2017-07-25T10:42:44.447" Title="Arduino and HC-05 hardware serial issues" Tags="|serial|bluetooth|" AnswerCount="4" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12279" PostTypeId="1" AcceptedAnswerId="12280" CreationDate="2015-05-31T23:59:05.230" Score="0" ViewCount="115" Body="&lt;p&gt;I have the code below. At the moment there is a proximity sensor that makes a speaker play happy birthday when it is set off. I also have an LCD shield attached and when one of the buttons on LCD screens interface is pressed, the time that it was when the button was pressed prints on the screen. I need to get it so that when the proximity sensor is set off it plays the sound on the speaker and then prints the time which is was set off on the screen. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*--------------------------------------------------------------------------------------&#xA; Includes&#xA; --------------------------------------------------------------------------------------*/&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;   // include LCD library&#xA;&#xA;int timer = 1000;&#xA;int C = 262;&#xA;int D = 294;&#xA;int E = 330;    &#xA;int F = 349;&#xA;int G = 392;&#xA;int A = 440;&#xA;int B = 494;&#xA;int Bflat = 466;&#xA;int Chigh = 523;&#xA;&#xA;&#xA;const int analogPin = A1;    // pin that the sensor is attached to&#xA;const int threshold = 400;&#xA;&#xA;&#xA;/*--------------------------------------------------------------------------------------&#xA; Defines&#xA; --------------------------------------------------------------------------------------*/&#xA;// Pins in use&#xA;#define MILLIS_OVERFLOW 34359738&#xA;#define BUTTON_ADC_PIN           A0  // A0 is the button ADC input&#xA;#define LCD_BACKLIGHT_PIN         3  // D3 controls LCD backlight&#xA;// ADC readings expected for the 5 buttons on the ADC input&#xA;#define RIGHT_10BIT_ADC           0  // right&#xA;#define UP_10BIT_ADC            145  // up&#xA;#define DOWN_10BIT_ADC          329  // down&#xA;#define LEFT_10BIT_ADC          505  // left&#xA;#define SELECT_10BIT_ADC        741  // right&#xA;#define BUTTONHYSTERESIS         10  // hysteresis for valid button sensing     window&#xA;//return values for ReadButtons()&#xA;#define BUTTON_NONE               0  // &#xA;#define BUTTON_RIGHT              1  // &#xA;#define BUTTON_UP                 2  // &#xA;#define BUTTON_DOWN               3  // &#xA;#define BUTTON_LEFT               4  // &#xA;#define BUTTON_SELECT             5  // &#xA;//some example macros with friendly labels for LCD backlight/pin control,     tested and can be swapped into the example code as you like&#xA;#define LCD_BACKLIGHT_OFF()     digitalWrite( LCD_BACKLIGHT_PIN, LOW )&#xA;#define LCD_BACKLIGHT_ON()      digitalWrite( LCD_BACKLIGHT_PIN, HIGH )&#xA;#define LCD_BACKLIGHT(state)    { if( state ){digitalWrite(     LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }&#xA;/*--------------------------------------------------------------------------------------&#xA; Variables&#xA; --------------------------------------------------------------------------------------*/&#xA;unsigned long currentMillis, previousMillis, elapsedMillis;&#xA;int seconds = 0, minutes = 34, hours = 8;&#xA;&#xA;byte buttonJustPressed  = false;         //this will be true after a        ReadButtons() call if triggered&#xA;byte buttonJustReleased = false;         //this will be true after a     ReadButtons() call if triggered&#xA;byte buttonWas          = BUTTON_NONE;   //used by ReadButtons() for detection of button events&#xA;/*--------------------------------------------------------------------------------------&#xA; Init the LCD library with the LCD pins to be used&#xA; --------------------------------------------------------------------------------------*/&#xA;LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );   //Pins for the freetronics 16x2     LCD shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7 )&#xA;/*--------------------------------------------------------------------------------------&#xA; setup()&#xA; Called by the Arduino framework once, before the main loop begins&#xA; --------------------------------------------------------------------------------------*/&#xA;void setup()   &#xA;{&#xA;  //button adc input&#xA;  pinMode( BUTTON_ADC_PIN, INPUT );         //ensure A0 is an input&#xA;  digitalWrite( BUTTON_ADC_PIN, LOW );      //ensure pullup is off on A0&#xA;  //lcd backlight control&#xA;  digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is     high (on)&#xA;  pinMode( LCD_BACKLIGHT_PIN, OUTPUT );     //D3 is an output&#xA;  //set up the LCD number of columns and rows: &#xA;   pinMode(13, OUTPUT);&#xA;  lcd.begin( 16, 2 );&#xA;&#xA;  //Print some initial text to the LCD.&#xA;  Serial.begin(9600);&#xA;  lcd.begin( 16, 2 ); &#xA;&#xA;&#xA;&#xA;}&#xA;/*--------------------------------------------------------------------------------------&#xA; loop()&#xA; Arduino main loop&#xA; --------------------------------------------------------------------------------------*/&#xA;void loop()&#xA;{&#xA;&#xA;  setClock();&#xA;  byte button;&#xA;&#xA;&#xA;  button = ReadButtons();&#xA;&#xA;&#xA;  /**&#xA;   * After set clock now you have 3 int variables with the current time&#xA;   */&#xA;  //seconds&#xA;  //minutes&#xA;  //hours&#xA;  lcd.setCursor ( 0, 1);&#xA;  lcd.print(hours);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(minutes);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(seconds);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.print(elapsedMillis);&#xA;&#xA;&#xA;  //get the latest button pressed, also the buttonJustPressed,     buttonJustReleased flags&#xA;&#xA;  //blank the demo text line if a new button is pressed or released, ready for a new label to be written&#xA;&#xA;  //show text label for the button pressed&#xA;   if(buttonJustPressed || buttonJustReleased)&#xA;  switch( button )&#xA;  {&#xA;&#xA;  case BUTTON_LEFT:&#xA;    {&#xA;      lcd.setCursor( 0, 0 );&#xA;               lcd.print(hours);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(minutes);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(seconds);&#xA;               lcd.print(&quot;:&quot;);&#xA;               lcd.print(elapsedMillis);&#xA;&#xA;      break;         &#xA;&#xA;    }&#xA;  default:&#xA;    {&#xA;      break;&#xA;    }&#xA;  }&#xA;&#xA;  if( buttonJustPressed )&#xA;    buttonJustPressed = false;&#xA;  if( buttonJustReleased )&#xA;    buttonJustReleased = false;&#xA;}&#xA;/*--------------------------------------------------------------------------------------&#xA; ReadButtons()&#xA; Detect the button pressed and return the value&#xA; Uses global values buttonWas, buttonJustPressed, buttonJustReleased.&#xA; --------------------------------------------------------------------------------------*/&#xA;byte ReadButtons()&#xA;{&#xA;  unsigned int buttonVoltage;&#xA;  byte button = BUTTON_NONE;   // return no button pressed if the below checks don't write to btn&#xA;&#xA;  //read the button ADC pin voltage&#xA;  buttonVoltage = analogRead( BUTTON_ADC_PIN );&#xA;  //sense if the voltage falls within valid voltage windows&#xA;  if( buttonVoltage &amp;lt; ( RIGHT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_RIGHT;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( UP_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( UP_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_UP;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( DOWN_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( DOWN_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_DOWN;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( LEFT_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( LEFT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_LEFT;&#xA;  }&#xA;  else if(   buttonVoltage &amp;gt;= ( SELECT_10BIT_ADC - BUTTONHYSTERESIS )&#xA;    &amp;amp;&amp;amp; buttonVoltage &amp;lt;= ( SELECT_10BIT_ADC + BUTTONHYSTERESIS ) )&#xA;  {&#xA;    button = BUTTON_SELECT;&#xA;  }&#xA;  //handle button flags for just pressed and just released events&#xA;  if( ( buttonWas == BUTTON_NONE ) &amp;amp;&amp;amp; ( button != BUTTON_NONE ) )&#xA;  {&#xA;    //the button was just pressed, set buttonJustPressed, this can optionally be used to trigger a once-off action for a button press event&#xA;    //it's the duty of the receiver to clear these flags if it wants to detect a new button change event&#xA;    buttonJustPressed  = true;&#xA;    buttonJustReleased = false;&#xA;  }&#xA;  if( ( buttonWas != BUTTON_NONE ) &amp;amp;&amp;amp; ( button == BUTTON_NONE ) )&#xA;  {&#xA;    buttonJustPressed  = false;&#xA;    buttonJustReleased = true;&#xA;  }&#xA;&#xA;  //save the latest button value, for change event detection next time round&#xA;  buttonWas = button;&#xA;&#xA;  return( button );&#xA;}&#xA;void setClock()&#xA;{&#xA;  currentMillis = millis();&#xA;  /**&#xA;   * The only moment when currentMillis will be smaller than previousMillis&#xA;   * will be when millis() oveflows&#xA;   */&#xA;  if (currentMillis &amp;lt; previousMillis){&#xA;    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;&#xA;  } &#xA;  else {&#xA;    elapsedMillis += currentMillis - previousMillis;&#xA;  }&#xA;&#xA;  /**&#xA;   * If we use equals 1000 its possible that because of the mentioned loop limitation&#xA;   * you check the difference when its value is (999) and on the next loop     its value is (1001)&#xA;   */&#xA;  while (elapsedMillis &amp;gt; 999){&#xA;    seconds++;&#xA;    elapsedMillis = elapsedMillis - 1000;&#xA;  }&#xA;&#xA;  if (seconds == 60){&#xA;    minutes++;&#xA;    seconds = 0;&#xA;  }&#xA;  if (minutes == 60){&#xA;    hours++;&#xA;    minutes = 0;&#xA;  }&#xA;  if (hours == 24){&#xA;    hours = 0;&#xA;  }&#xA;&#xA;  previousMillis = currentMillis;&#xA;&#xA;&#xA; int analogValue = analogRead(analogPin);&#xA;  if (analogValue &amp;gt; threshold) {&#xA;&#xA;tone(13,C,timer/2);// Happy Bday to You&#xA;delay(200);&#xA;tone(13,C,timer/2);&#xA;delay(200);&#xA;tone(13,D,timer/2);&#xA;delay(400);&#xA;tone(13,C,timer/2);&#xA;delay(400);&#xA;tone(13,F,timer/2);&#xA;delay(400);&#xA;tone(13,E,timer);&#xA;delay(750);&#xA; }&#xA;else {&#xA;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8588" LastActivityDate="2015-06-01T01:51:59.167" Title="Change code so motion sensor prints time instead of a button" Tags="|arduino-uno|lcd|display|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12280" PostTypeId="2" ParentId="12279" CreationDate="2015-06-01T01:51:59.167" Score="2" Body="&lt;p&gt;The code seems a little hotchpotch; is the code for reading the sensor supposed to be within the &lt;code&gt;setClock()&lt;/code&gt; function? It would be better to put the following within &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(analogRead(analogPin) &amp;gt; threshold)&#xA;{&#xA;    playMelody();&#xA;    printTriggerTime();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And create two new functions that handle the playing of 'Happy Birthday' and the printing of the time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void playMelody()&#xA;{&#xA;    tone(13, C, timer / 2);// Happy Bday to you&#xA;    ...&#xA;    delay(750);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which is just a cut-paste of what you've got in the &lt;code&gt;setClock()&lt;/code&gt; function, and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void printTriggerTime()&#xA;{&#xA;    lcd.setCursor(0, 0);&#xA;    ...&#xA;    lcd.print(elapsedMillis);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which is a copy-paste of the code from within &lt;code&gt;case BUTTON_LEFT:&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will now play 'Happy Birthday' and print the time whenever the proximity sensor is triggered, AND it will print the time when the left-button is pressed (unless you remove that part of the code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a separate point, it's bad coding practice to use &lt;code&gt;#define&lt;/code&gt; for a function, as you have done with &lt;code&gt;#define LCD_BACKLIGHT(state) { if ( state )...&lt;/code&gt; - it makes it quite difficult to read the code, and can't conceive any reason why this isn't its own function. However, a nice trick in C is the following 'shortcut' statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( CONDITION ? DO_IF_TRUE : DO_IF_FALSE )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus you should change that line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LCD_BACKLIGHT(state) ( state ? digitalWrite(LCD_BACKLIGHT_PIN,HIGH) : digitalWrite(LCD_BACKLIGHT_PIN,LOW))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That being said, &quot;LCD_BACKLIGHT(state)&quot; isn't actually used anywhere in the program!&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-01T01:51:59.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12281" PostTypeId="2" ParentId="12262" CreationDate="2015-06-01T02:55:47.760" Score="0" Body="&lt;p&gt;&lt;strong&gt;Volatile&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially any variable declared within global scope (anything you declare before you get to &lt;code&gt;setup()&lt;/code&gt;) MUST have the &lt;code&gt;volatile&lt;/code&gt; qualifier if you want to use it within an interrupt service routine otherwise it will not be correctly utilised/implemented/instantiated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your code stands, you need to add &lt;code&gt;voltatile&lt;/code&gt; to all four of your global variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int counter = 0;     // if you're stopping at 470, int is all you need&#xA;volatile long rpm = 0;&#xA;volatile long z = 0;          // this isn't necessary, see below!&#xA;volatile long ini_time = 0;&#xA;voltaile long end_time = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your ISR includes some wasteful instructions, which will increase the time it takes for the routine to complete. As @jfpoilpret suggested, you may be constantly interrupting &lt;code&gt;loop()&lt;/code&gt;. Cutting the time down may solve this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, &lt;code&gt;z = counter; rpm_counter(z);&lt;/code&gt; . Pointless, if I'm honest. Why not just call rpm_counter with counter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, &lt;code&gt;rpm_counter()&lt;/code&gt; function... it doesn't use the arguement you sent! &quot;&lt;code&gt;x&lt;/code&gt;&quot; is not used anywhere within the function, so why are you sending it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thirdly, even if my second point wasn't valid &lt;code&gt;rpm_counter()&lt;/code&gt; doesn't really need to be a function in its own right. Unless you're going to be calling it from lots of different places, just inline the contents of the function to into &lt;code&gt;A_RISE()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else if (counter&amp;gt;470)&#xA;{ //470 is ticks per revolution&#xA;    end_time = micros() - ini_time;&#xA;    rpm = (60*10^6) / end_time;&#xA;    counter = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That could save a great deal of execute cycles.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-01T02:55:47.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12282" PostTypeId="2" ParentId="12276" CreationDate="2015-06-01T03:58:54.743" Score="0" Body="&lt;p&gt;Visual Studio knows nothing about an Arduino project. Why would you be trying to reference it from the other project.  Short answer is that you are not  understanding how to use Visual Studio and / or Arduino. Are you using it with some plugin for visual studio? If you are more than likely it does not support being part of a multi solution (at least that has been my experience with them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long answer is give some more details about what you are trying to do, including code from both projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Sorry but this is not an Arduino topic. You are fundamentally incorrect in your understanding of how compilers and linkers work and what they are for. As are the other answers.  You can not reference a project compiled for an Arduino, from a project compiled for Windows, period.  I ask you to explain what you were trying to do and I would give you some idea how to accomplish that, but you did not answer. Yes you can use Visual Studio to compile your Arduino project, I do it every day. But I do not 'reference' it from another project on Windows. Do you have any idea what a reference is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;update 2: You can not create a test suite for an Arduino project, at least not in the traditional way. You can not even debug an Arduino project in the traditional way.  Arduino is for prototyping, and very basic beginner stuff, and nothing more. What you are asking about is more traditional development, and the Arduino is not for that (and does not do it very well).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create 2 separate solutions. One with only your visual micro project for the arduino, and another separate solution with a regular C++ or C# project, not a test project or anything special, just a plain console, or winforms, or WPF project.  The 2 pieces of code must be run at the same time (F5), and probably connect to each other via the serial port, but it depends on what you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This IS NOT testing in a traditional sense. This is test running a project. The traditional sense of testing is to test isolated portions of code, which is different, and again, can not be done with an Arduino and visual studio.  Since the Arduino only remotely provides 2 wire debugging, and I have never heard anyone actually get it to work at all, you can NOT do any traditional debugging or testing with an Arduino. Instead you are limited to beginner hacks (serial.print).&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-06-02T16:46:06.407" LastActivityDate="2015-06-02T16:46:06.407" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12283" PostTypeId="2" ParentId="4900" CreationDate="2015-06-01T05:24:58.220" Score="1" Body="&lt;p&gt;It might have something to do with the internal pull up resistor. According to the SAM3X/A datasheet,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Control of the pull-up resistor is possible regardless of the&#xA;configuration of the I/O line.&lt;/p&gt;&#xA;&lt;p&gt;After reset, all of the pull-ups are enabled.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you dig through all the include files you find:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;../Arduino/hardware/arduino/samd/cores/arduino/wiring_digtal.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Line 124 defines the &lt;code&gt;pinMode(uint32_t ulPin, uint32_t ulMode)&lt;/code&gt; function. Examining the switch/case statement for INPUT vs INPUT_PULLUP vs OUTPUT you see the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;INPUT sets a register to &lt;code&gt;reg = PORT_PINCFG_INEN&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;INPUT_PULLUP sets a register to &lt;code&gt; reg = (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;OUTPUT sets a register to &lt;code&gt;reg &amp;amp;= ~PORT_PINCFG_INEN&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The 'register' in each case is the same. I cannot for the life of me find what value PORT_PINCFG_INEN or PORT_PINCFG_PULLEN are defined as, but they're no doubt just 8-bit masks (they're cast to uint8_t when they're assigned to the 'register'). Thus, we can assume that whichever bit controls input/output is active when asserted, as is the pullup bit. For example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; PORT_PINCFG_INEN   = b'00000001';&#xA; PORT_PINCFG_PULLEN = b'00000010';&#xA;~PORT_PINCFG_INEN   = b'11111110';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If pull-ups are enabled after reset, we can say that on reset:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; reg = b'xxxxxx1x';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Point (3) above strongly implies that the instruction is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; reg = b'xxxxxx1x' &amp;amp; 'b11111110';&#xA;   so&#xA; reg = b'xxxxxx10'; // pull-up is enabled!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Therefore, &lt;em&gt;if you call pinMode(X, OUTPUT) before anything else&lt;/em&gt; you will end up with the pullup resistor enabled. Setting the pin to an input will clear the pullup enable bit, after which you can set the pin to an output and the bit will remain clear.&lt;/p&gt;&#xA;&lt;p&gt;However, the whole arguement falls down with the simple fact that if you don't call pinMode() &lt;strong&gt;at all&lt;/strong&gt;, the problem doesn't occur...&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-01T05:24:58.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12284" PostTypeId="2" ParentId="8875" CreationDate="2015-06-01T05:48:57.373" Score="1" Body="&lt;p&gt;The NRF24s are great, but limited to communication only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digi's &lt;a href=&quot;https://www.sparkfun.com/products/10414&quot; rel=&quot;nofollow&quot; title=&quot;XBee 2mW&quot;&gt;XBee 2mW&lt;/a&gt; module has got great indoor range, but more to the point &lt;strong&gt;it's got 8 I/O lines and 6 10-bit ADCs on board&lt;/strong&gt;. It's also built for mesh networks (or you can get star-network equivalents) and has security encryption to boot. This means that, for some of your nodes, you don't need any other hardware to have a fully functioning control point (not including relays and sensors of course), so you can ditch having arduinos at every node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They're so easy to use, very low power, and have plenty of support and documentation available online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do it!&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-01T05:48:57.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12285" PostTypeId="1" AcceptedAnswerId="12288" CreationDate="2015-06-01T08:38:22.453" Score="7" ViewCount="16901" Body="&lt;p&gt;I were examining &lt;code&gt;shiftOut()&lt;/code&gt; function code in &lt;code&gt;wiring_shift.c&lt;/code&gt; and I didn't quite understand what is going in digitalWrite function. I see &lt;code&gt;!!(val &amp;amp; (1 &amp;lt;&amp;lt; i))&lt;/code&gt; is taking the bit value from &lt;code&gt;val&lt;/code&gt; but how exactly it works?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole function is below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)&#xA;{&#xA;    uint8_t i;&#xA;&#xA;    for (i = 0; i &amp;lt; 8; i++)  {&#xA;        if (bitOrder == LSBFIRST)&#xA;            digitalWrite(dataPin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; i)));&#xA;        else    &#xA;            digitalWrite(dataPin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; (7 - i))));&#xA;&#xA;        digitalWrite(clockPin, HIGH);&#xA;        digitalWrite(clockPin, LOW);        &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8687" LastActivityDate="2017-09-30T23:45:31.943" Title="How shiftOut function works internally? (explanation on source code)" Tags="|c++|arduino-ide|core-libraries|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12286" PostTypeId="2" ParentId="12276" CreationDate="2015-06-01T09:20:43.063" Score="1" Body="&lt;p&gt;I use Visual Studio Community Edition 2013 along with the Visual Micro extensions, which I think is what you need as the &quot;missing link&quot; between VS and Arduino.&lt;/p&gt;&#xA;" OwnerUserId="1675" LastActivityDate="2015-06-01T09:20:43.063" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12288" PostTypeId="2" ParentId="12285" CreationDate="2015-06-01T09:28:18.650" Score="9" Body="&lt;p&gt;I'll assume &lt;code&gt;bitOrder == LSBFIRST&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;i&lt;/code&gt; is the bit number, i.e. the “index” of the next bit to write&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1&lt;/code&gt; is &lt;code&gt;00000001&lt;/code&gt; in binary&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is the shift left operator. It returns its first argument shifted left by as many positions as indicated by the second argument&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1&amp;lt;&amp;lt;i&lt;/code&gt; is binary &lt;code&gt;00000001&lt;/code&gt; shifted left by &lt;code&gt;i&lt;/code&gt; positions, i.e. something like &lt;code&gt;0...010...0&lt;/code&gt;, where the single 1 is in the i-th position counting from the right (rightmost being position 0)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; is the “bitwise and operator”, where &lt;code&gt;any_bit &amp;amp; 0&lt;/code&gt; is zero and &lt;code&gt;any_bit &amp;amp; 1&lt;/code&gt; is &lt;code&gt;any_bit&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;val &amp;amp; (1 &amp;lt;&amp;lt; i)&lt;/code&gt; is &lt;code&gt;0...0(i-th bit of val)0...0&lt;/code&gt; in binary, where the i-th bit of val is in the i-th position of the result&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!!&lt;/code&gt; is a double negation: it converts zero to zero and any non-zero value to one&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;!!(val &amp;amp; (1 &amp;lt;&amp;lt; i))&lt;/code&gt; is either 0 or 1, and is exactly the i-th bit of val&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-01T09:28:18.650" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12289" PostTypeId="2" ParentId="12264" CreationDate="2015-06-01T09:38:07.400" Score="3" Body="&lt;p&gt;Not many possibilities (for the phone part, I suggest a GPRS/3G shield), but not wanting to discourage you, if you are thinking about &quot;a fleet&quot;, forget about:&#xA;&lt;li&gt;low power (the phone radio needs power, some say you need &gt; 1A for both Arduino plus the shield, depending on your distance to the antenna). you must add the GPS part. Even if you communicate just a fraction of the time, you need instant power for feeding the radio.&#xA;&lt;li&gt;low price (gprs shields are not cheap, starting at some 25€, and gps shields about 20€). and don't forget that you need a SIM card with a data plan for every unit....&#xA;&lt;br&gt;&lt;br&gt;&#xA;Depending on what are you trying to achieve, I'd try with less expensive (RF communications, for example) to avoid carrier costs and hardware costs, at the price of a more complex development. &lt;br&gt;If you want to publish to a web service, you can always make your minions transmit to a centralized Raspberry PI, for example, that would take the task of bridging with the Internets, or your mastermind...:-D&lt;/p&gt;&#xA;" OwnerUserId="1675" LastActivityDate="2015-06-01T09:38:07.400" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12290" PostTypeId="2" ParentId="9758" CreationDate="2015-06-01T10:29:51.553" Score="0" Body="&lt;p&gt;This is more a wild guess than a real answer... Assuming your terminal&#xA;is using a character set more or less like ISO-8859-1 or Windows-1252,&#xA;then you are receiving 0xA4 when you expect 0x48. My guess is that the&#xA;very first start bit got lost somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the serial port waveforms corresponding to the expected and&#xA;received bytes. ‘S’ and ‘T’ are the start bit and stop bit respectively.&#xA;The data bits are sent least-significant first. The idle state is HIGH:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• ‘H’ = 0x48 = 0b01001000&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;────┐               ┌───┐       ┌───┐   ┌──────&#xA;    │ S   0   0   0 │ 1 │ 0   0 │ 1 │ 0 │ T&#xA;    └───────────────┘   └───────┘   └───┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;• ‘¤’ = 0xA4 = 0b10100100&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;────┐           ┌───┐       ┌───┐   ┌──────────&#xA;    │ S   0   0 │ 1 │ 0   0 │ 1 │ 0 │ 1   T&#xA;    └───────────┘   └───────┘   └───┘&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that, if you remove the start bit from the first waveform,&#xA;you get exactly the second one. I do not know what may be the cause of&#xA;this though.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-01T10:29:51.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12293" PostTypeId="1" CreationDate="2015-06-01T13:25:41.767" Score="0" ViewCount="461" Body="&lt;p&gt;I have a little personal project involving an Arduino Uno and an amp board from &lt;a href=&quot;http://store.sure-electronics.com/audio/audio-amplifier-board/low-power-100w/aa-ab31521&quot; rel=&quot;nofollow&quot; title=&quot;Sure Electronics&quot;&gt;Sure Electronics&lt;/a&gt;. The amp has contacts for a mute function that involves shorting the contact to ground. I would like to control this muting with the Arduino which I was planning to do with a relay. However I think I might be complicating things and I thought it might be possible to do it directly with the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use the Arduino to directly short a circuit to ground? Or would I need something more complicated to be safe?&lt;/p&gt;&#xA;" OwnerUserId="10392" LastEditorUserId="10392" LastEditDate="2015-07-02T12:42:08.543" LastActivityDate="2018-06-04T19:10:27.887" Title="Can I use an arduino as a ground short?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12295" PostTypeId="2" ParentId="12293" CreationDate="2015-06-01T14:39:43.900" Score="1" Body="&lt;p&gt;I can't see how much current the amp board will sink into the Arduino so like FuaZe I would recommend using your Arduino to drive an external component that you know can take the current.  This isn't really complicating the design too much, use an NPN transistor, with the P connected to the Arduino and just write High to the pin when you want to apply the mute.  If you blow the transistor then its going to cost you a few pence for a new one, if you blow your Arduino you are down £20!&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-06-01T14:39:43.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12296" PostTypeId="2" ParentId="12278" CreationDate="2015-06-01T14:47:57.707" Score="1" Body="&lt;p&gt;The HC-05 requires a 5V power supply and 3.3V logic.&#xA;Using SoftwareSerial might be easier for you as you can use pins 8 and 9 rather than 0 and 1, because there can be issues with the USB.&#xA;Are you transmitting the data you think you are, might Big/Little Endian be an issue?&#xA;I can get two HC-05 devices to communicate when they are connected to the PC via serial port adapters.  However when I replace the receiver with a HC-05 connected to an UNO I get intermittent garbage received.  So I suspect there may be some sort of problem with PC-&gt;Arduino.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-06-01T14:47:57.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12297" PostTypeId="2" ParentId="12293" CreationDate="2015-06-01T14:49:47.800" Score="2" Body="&lt;p&gt;Depends on the voltage that is on that mute pin. If it's below 5 volt, you could use the arduino pin. You can measure the voltage using a multimeter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's more than 5v you can use a NPN transistor and resistor combination. &lt;img src=&quot;https://i.stack.imgur.com/19QUa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current isn't a problem with these kinds of &quot;settings&quot; pins, as there is just a pull-up resistor that by default (unconnected) sets the pin to HIGH. By connecting the pin to ground you set the pin to LOW.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2018-06-04T19:10:27.887" LastActivityDate="2018-06-04T19:10:27.887" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12298" PostTypeId="2" ParentId="12276" CreationDate="2015-06-01T14:53:03.810" Score="0" Body="&lt;p&gt;You are trying to build a Windows program.  You need a main() function as an entry point.  I suspect that when your code is built through the Arduino IDE it adds in a main function in.&#xA;You can tell Visual Studio to build your files differently by defining some build rules, but it sounds like someone may have done this sort of thing by looking at the other answers.&#xA;But the easiest short term solution would be copying and pasting into the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-06-01T14:53:03.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12299" PostTypeId="1" CreationDate="2015-06-01T16:08:59.193" Score="1" ViewCount="2386" Body="&lt;p&gt;I will be using the Arduino platform with other data acquisition hardware for a school electronics project. I have limited knowledge of C++ syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there good introductory to intermediate books that can bring a high school student with some programming experience to proficiency on Arduino? &lt;/p&gt;&#xA;" OwnerUserId="10397" LastActivityDate="2015-12-31T14:27:58.030" Title="Books on Arduino development in C++" Tags="|c++|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12300" PostTypeId="2" ParentId="12299" CreationDate="2015-06-01T18:03:17.110" Score="1" Body="&lt;p&gt;I'd recommend you go to &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/&quot; rel=&quot;nofollow&quot;&gt;cplusplus.com&lt;/a&gt;. Plenty of tutorial pages and topics to further your knowledge. However, be aware that Arduino uses a variant of &lt;strong&gt;C&lt;/strong&gt; designed for microcontrollers (the exact flavour depends on the microcontroller type/family), rather than &lt;em&gt;C++&lt;/em&gt;, so do be aware that some of the topics are not implementable on an Arduino. That said, I can't think why you'd be using some of the more elaborate C++ exclusive features in a fairly middle-of-road embedded system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing you need to ignore in C++ is memory allocation specifics - you're limited to the 'original' &lt;code&gt;malloc()&lt;/code&gt; based functions rather than the all-singing-all-dancing &lt;code&gt;operator new&lt;/code&gt; from C++. If you are in need of memory allocation functions, malloc is well-documented and a tutorial is only a quick Google away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I must also point you in the direction of the highly popular &lt;a href=&quot;http://www.stackoverflow.com&quot;&gt;Stack Overflow&lt;/a&gt; site, part of this Stack Exchange network. While they don't have tutorials, there are plenty of great answers to common questions.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2015-06-04T02:38:29.663" LastActivityDate="2015-06-04T02:38:29.663" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12301" PostTypeId="2" ParentId="12278" CreationDate="2015-06-01T18:35:08.090" Score="1" Body="&lt;p&gt;I've run into similar issues with the Arduino and serial communications - it's quite a pain. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There really shouldn't be an issue with your sketch if PC-&gt;USB-&gt;FTDI-&gt;Arduino is working since the same protocols are used (UART is UART, after all). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In regard to the BAUD rate, sure, 230400 should work just fine. For purpose of testing, though, I would slow it down to a measly 9600 or something like that just to rule out any possible issues. (Plus, if I remember right, 9600 or ~11000 is the rate at which it operates when being programmed via AT commands). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now these are my thoughts on what the problem may be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You said several times that you have a 5V HC-05 with level shifters. The HC-05 chip itself operates on 3.3V, so typically there is a voltage regulator on the breakout board dropping the voltage down to 3.3V for the Vcc pins and whatever else is pulled high on the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have never seen an HC-05 on Amazon, Sparkfun, or Ebay that actually has a true logic-level shifter on the board itself. Instead (and this is true from my experience with Ebay sellers who claim logic-level shifting built in), there is a voltage divider on the HC-05 RX pin that allows you to send a 5V signal without external resistors. But this isn't bidirectional, so your TX pin still has a logic high level of 3.3V. In short, I think your HC-05 chip really doesn’t have a logic-level shifter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be thinking I’m totally wrong about this, and I very well could be since I don’t have your module in front of me, but just hear me out by reading my reasoning below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) You said you can receive data on your PC. This means the HC-05 is receiving data from a 5V signal and successfully converting it to 3.3V. Great. That works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) You said you were able to get an HC-05 (presumably the same model) to work with an Arduino Due in both directions. The Arduino Due operates on 3.3V, so its logic high threshold is around 2.1v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) On the 5V Arduino Pro, the minimum logic high threshold is (0.6)*Vcc -&gt; 3V. So if the HC-05 is transmitting a signal with a logic high of 3.3V, the Arduino is barely registering it. Factoring in resistance and noise, your signal is probably less than 3.3V. (In fact, my HC-05’s usually push out a signal of ~3V).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading that you can see a signal on the HC-05 TX line, but the Arduino is not registering it, I’d bet your signal is below the threshold. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I’d fire up your oscilloscope again and check the peak voltage to see what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Additional (Response to &quot;what can I do?)&quot;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a few options. The best option would be to use a bidirectional 3.3V-5V level shifter, but not many people have those laying around. If you happen to have some common components, you could try building a makeshift level shifter like in the images below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wDavO.png&quot; alt=&quot;enter image description here&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/MCTp5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first &quot;level-shifter&quot; is a a voltage comparator using an opamp. If you go this route, ground V-, tie V+ to 5V, and calculate a voltage divider for around 1.5V. (Note: use the non-inverting setup). A cheap TL272 from Radioshack should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second level shifter uses two NPNs and is self-explanatory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, though, that I haven't tried any of these setups nor know their frequency responses. However, the TL272 should handle signals into the MHzs, and BJTs handle high frequencies rather well. My gut tells me it should work, but just in case, I would use a low BAUD rate.&lt;/p&gt;&#xA;" OwnerUserId="10383" LastEditorUserId="10383" LastEditDate="2015-06-01T21:20:38.193" LastActivityDate="2015-06-01T21:20:38.193" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="12302" PostTypeId="2" ParentId="12299" CreationDate="2015-06-01T22:45:38.833" Score="0" Body="&lt;p&gt;There is a book called &quot;C Programming for Arduino&quot; by Julien Bayle that introduces it pretty well if you are just getting started at it. I think it's from Packt Publishing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another I found interesting is called &quot;Practical AVR Microcontrollers&quot; by Alan Trevennor that gives examples of programming using C without having to get an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, Stack Exchange is always really great to browse.&lt;/p&gt;&#xA;" OwnerUserId="8192" LastActivityDate="2015-06-01T22:45:38.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12303" PostTypeId="2" ParentId="11937" CreationDate="2015-06-01T23:16:15.590" Score="0" Body="&lt;p&gt;Never tried it with the Arduino, but it's &lt;a href=&quot;https://www.pjrc.com/teensy/td_joystick.html&quot; rel=&quot;nofollow&quot;&gt;quite easy to do with Teensy&lt;/a&gt; (which is mostly compatible with Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.pjrc.com/teensy/teensyduino.html&quot; rel=&quot;nofollow&quot;&gt;Teensyduino&lt;/a&gt; actually includes several examples.&lt;/p&gt;&#xA;" OwnerUserId="10405" LastActivityDate="2015-06-01T23:16:15.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12304" PostTypeId="1" AcceptedAnswerId="12311" CreationDate="2015-06-02T00:19:34.163" Score="0" ViewCount="24616" Body="&lt;p&gt;I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Person{&#xA;public:&#xA;    int age;&#xA;};&#xA;&#xA;Person p;&#xA;p.age;&#xA;&#xA;void setup() { ... }&#xA;&#xA;void loop() { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'&#xA;MyProgram.ino:18:1: error: 'p' does not name a type&#xA;Error compiling&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But is I use the Person instance inside setup or loop functions it compiles find.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    // initialize digital pin 13 as an output.&#xA;    Person p;&#xA;    p.age;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'&#xA;Binary sketch size: 4,674 bytes (used 2% of a 253,952 byte maximum) (3.45 secs)&#xA;Minimum Memory Usage: 428 bytes (5% of a 8192 byte maximum)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the different? Why the instance only can be used into the blocks? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also declared a file with a simple class and then create a instance of it class outside the blocks and I got the same error. If I put the instance inside the blocks it works. So, any tips?&lt;/p&gt;&#xA;" OwnerUserId="10295" LastActivityDate="2015-06-02T10:05:27.423" Title="Arduino raise the error: `does not name a type` when an Object is used outside of the main two blocks setup and loop" Tags="|arduino-mega|variables|class|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12305" PostTypeId="2" ParentId="12304" CreationDate="2015-06-02T00:29:54.927" Score="2" Body="&lt;p&gt;All code intended to be executed must be inside a function block in C++.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-02T00:29:54.927" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12307" PostTypeId="1" CreationDate="2015-06-02T05:20:36.577" Score="-1" ViewCount="2637" Body="&lt;p&gt;I have a brand new arduino(original), and it is not showing up in Device manager or anywhere else. Even the computer doesn't Prompt anything. I am using Windows 7 32 bit.&lt;/p&gt;&#xA;" OwnerUserId="10408" LastActivityDate="2016-04-21T22:42:22.943" Title="My arduino won't show up in Device Manager in any way, neither in unknown devices nor in COM port." Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12308" PostTypeId="1" CreationDate="2015-06-02T08:55:39.017" Score="0" ViewCount="365" Body="&lt;p&gt;I'm using the apc220 rf modules. Now I'm having the following problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My receiving arduino uno only receives data when the tx pin on the arduino (rx pin on the rf module) is disconnected. As soon as I connect the tx pin my serial monitor receives only the value 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my rf module broken, or can someone help me with this?&lt;/p&gt;&#xA;" OwnerUserId="10056" LastActivityDate="2015-07-02T10:22:04.817" Title="Serial communication stops when I connect the tx cable" Tags="|serial|rf|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12309" PostTypeId="2" ParentId="12308" CreationDate="2015-06-02T09:24:09.523" Score="1" Body="&lt;p&gt;To have two serial ports on Arduino board like Uno use &lt;code&gt;SoftwareSerial.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(2,3); // RX, TX&#xA;&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;&#xA;&#xA;  Serial.println(&quot;Hello!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now after opening &lt;code&gt;Serial monitor&lt;/code&gt; you should see Hello! and then you can test &lt;code&gt;SoftwareSerial&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DO NOT FORGET!!!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you connect to pins 2,3 or etc, this is &lt;strong&gt;TTL&lt;/strong&gt; voltage level. You &lt;strong&gt;can't&lt;/strong&gt; connect direct to RS232.&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-06-02T09:24:09.523" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12310" PostTypeId="2" ParentId="11730" CreationDate="2015-06-02T09:55:00.190" Score="1" Body="&lt;p&gt;i'm not sure why my old code doesn't work, but this is my new one and it is working fine. Maybe it will help someone.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;dht.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;EthernetClient client;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;char server[] = &quot;192.168.0.101&quot;;&#xA;dht DHT;&#xA;int interval = 5000; // Wait between dumps&#xA;#define DHT11_PIN 2&#xA;void setup()&#xA;{&#xA;  Ethernet.begin(mac);&#xA;  Serial.begin(115200);&#xA;&#xA;  //Serial.println(&quot;Humidity (%),\tTemperature (C)&quot;);&#xA;}&#xA;void loop()&#xA;{&#xA;  Serial.print(&quot;Temperature2 = &quot;);&#xA;    Serial.print(DHT.temperature);&#xA;    Serial.println(&quot; *C&quot;);&#xA;&#xA;    Serial.print(&quot;Humidity = &quot;);&#xA;    Serial.print(DHT.humidity);&#xA;    Serial.println(&quot; &quot;);&#xA;&#xA;  // READ DATA&#xA;  //Serial.print(&quot;DHT11, \t&quot;);&#xA;  int chk = DHT.read11(DHT11_PIN);&#xA;&#xA;  if (client.connect(server, 80)) {&#xA;&#xA;    client.print( &quot;GET /diplomna/Arduino/add_data.php?&quot;);&#xA;    client.print(&quot;temperature=&quot;);;&#xA;    client.print( DHT.temperature );&#xA;    client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;    client.print(&quot;humidity=&quot;);&#xA;    client.println( DHT.humidity );&#xA;    client.println( &quot;HTTP/1.1&quot;);&#xA;    client.println( &quot;Connection: close&quot; );&#xA;    client.stop();&#xA;    Serial.println(&quot;CONNECTED&quot;);&#xA;  }&#xA;  else {&#xA;    // you didn’t get a connection to the server:&#xA;    Serial.println(&quot;–&amp;gt; connection failed/n&quot;);&#xA;  }&#xA;  delay(interval);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8289" LastActivityDate="2015-06-02T09:55:00.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12311" PostTypeId="2" ParentId="12304" CreationDate="2015-06-02T10:05:27.423" Score="3" Body="&lt;p&gt;As you have already noticed, you cannot call methods of a class, nor access its properties, outside a &quot;block&quot; (as you call it).  More specifically, you can only perform &quot;programatical&quot; operations from within a &lt;em&gt;function&lt;/em&gt;.  Anything outside a function (known as the &lt;em&gt;global scope&lt;/em&gt;) is purely for declaration and initialization of variables and types, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any class variables declared in the &lt;em&gt;global scope&lt;/em&gt; have their &lt;em&gt;constructor&lt;/em&gt; executed before the rest of the program (even before &lt;code&gt;setup&lt;/code&gt;) gets run.  However, &lt;code&gt;setup&lt;/code&gt; is not the first function to be called at startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything you put into a constructor has to take into account the fact that anything might be happening between the constructor being called and the object instance actually being used.  Things like &lt;code&gt;pinMode&lt;/code&gt; and &lt;code&gt;digitalWrite&lt;/code&gt; are unsafe to use in a constructor, since there is a chance they may be negated during the startup.  That is why the majority of Arduino classes have a &lt;code&gt;.begin()&lt;/code&gt; method which is called from &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The proper method for using classes with pin control and similar operations is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The constructor takes the pins to use&lt;/li&gt;&#xA;&lt;li&gt;The constructor saves those pins in variables&lt;/li&gt;&#xA;&lt;li&gt;The begin() method is called in setup()&lt;/li&gt;&#xA;&lt;li&gt;The pins are configured appropriately.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class myClass {&#xA;    private:&#xA;        int _myPin;&#xA;    public:&#xA;        myClass(int pin) : _myPin(pin) {}&#xA;&#xA;       void begin() {&#xA;            pinMode(_myPin, OUTPUT);&#xA;            digitalWrite(_myPin, HIGH);&#xA;        }&#xA;};&#xA;&#xA;myClass p(4);&#xA;&#xA;void setup() {&#xA;    p.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The object instance &lt;code&gt;p&lt;/code&gt; is in the &lt;em&gt;global scope&lt;/em&gt; and can be referenced from any function. The pin is configured only when setup() is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The startup sequence, more specifically, is typically this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The memory used by global and static variables is &quot;zeroed&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Any pre-defined variable values (&lt;em&gt;BSS&lt;/em&gt;) are copied from flash into RAM.&lt;/li&gt;&#xA;&lt;li&gt;Any object constructors are called.&lt;/li&gt;&#xA;&lt;li&gt;The main() function is called (main startup function).&lt;/li&gt;&#xA;&lt;li&gt;The init() function is called which configures the Arduino platform.&lt;/li&gt;&#xA;&lt;li&gt;The initVariant() function is called which performs any board specific setup routines.&lt;/li&gt;&#xA;&lt;li&gt;USB is configured on the boards that have it&lt;/li&gt;&#xA;&lt;li&gt;Your setup() function is called.&lt;/li&gt;&#xA;&lt;li&gt;Your loop() function is called.&lt;/li&gt;&#xA;&lt;li&gt;The serialEvent() system runs if defined.&lt;/li&gt;&#xA;&lt;li&gt;Go to 10.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As you can see quite a lot happens between the constructor being called and setup() being called, and you cannot reliably predict what that might be.  Some boards may do nothing more than configure interrupts and enable timers (for things like &lt;code&gt;delay&lt;/code&gt; and &lt;code&gt;millis&lt;/code&gt;), but other boards may configure IO pins to default settings (especially more complex boards with multiple functions per IO pin), so really the only safe operations you can perform in a constructor are operations which act directly on the internals of the class itself.  Anything outside the scope of the class could be changed before you come to use it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-02T10:05:27.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12312" PostTypeId="1" AcceptedAnswerId="12313" CreationDate="2015-06-02T10:57:12.023" Score="3" ViewCount="10209" Body="&lt;p&gt;what is the difference between a motor driver(like L293D) and a motor shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what are the advantage?disadvantages of both?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And which one do you suggest ?&lt;/p&gt;&#xA;" OwnerUserId="10412" LastActivityDate="2020-12-12T07:32:10.563" Title="What is the difference between a motor driver and a motor shield?" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12313" PostTypeId="2" ParentId="12312" CreationDate="2015-06-02T10:59:03.243" Score="5" Body="&lt;p&gt;A motor driver is a chip that drives motors.  A motor shield is a circuit board with connections on it that contains a motor driver chip that drives motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A shield is convenient since you can just plug it in to your Arduino and wire the motors direct to it, but it lacks the flexibility of a raw driver chip which you can wire up precisely as your project demands.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-02T10:59:03.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12314" PostTypeId="1" CreationDate="2015-06-02T11:44:48.250" Score="3" ViewCount="869" Body="&lt;p&gt;I'm trying to communicate with two bluetooth module (RN-42) on the Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I studied about Serial communication in Arduino, and I used Serial1, Serial2 to get information at the same time from the modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the setup period, baud rate will be set. The command &quot;$$$&quot; makes the bluetooth module go into the configuration mode. Until this, everything works pretty well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, it seems nothing works inside the loop(). I think Serial1.print(inByte), Serial2.print(inByte) doesn't work properly. I checked the TX1, TX2 port whether it sends any data or not by using LED, and the LED never blinked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code that I used.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  // initialize both serial ports:&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial1.begin(115200);&#xA;  Serial1.print(&quot;$$$&quot;);&#xA;  delay(100);&#xA;  Serial1.println(&quot;U,9600,N&quot;);&#xA;  Serial1.begin(9600);&#xA;&#xA;  delay(100);&#xA;  Serial1.print(&quot;?&quot;);&#xA;&#xA;  Serial2.begin(115200);&#xA;  Serial2.print(&quot;$$$&quot;);&#xA;  delay(100);&#xA;  Serial2.println(&quot;U,9600,N&quot;);&#xA;  Serial2.begin(9600);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // read from port 1, send to port 0:&#xA;&#xA;  while(Serial1.available()&amp;gt;0) {&#xA;    char inByte = Serial1.read();&#xA;    Serial.print(inByte); &#xA;  }&#xA;&#xA;&#xA;  while(Serial2.available()&amp;gt;0) {&#xA;    char inByte = Serial2.read();&#xA;    Serial.print(inByte);&#xA;  }&#xA;&#xA;&#xA;  // read from port 0, send to port 1:&#xA;  while (Serial.available()&amp;gt;0) {&#xA;    char inByte = Serial.read();&#xA;    Serial1.print(inByte);&#xA;&#xA;    delay(10);&#xA;    Serial2.print(inByte);   &#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="10414" LastEditorUserId="37523" LastEditDate="2019-08-20T23:19:45.320" LastActivityDate="2019-08-20T23:19:45.320" Title="Serial Communication with two bluetooth modules on Arduino Mega" Tags="|serial|arduino-mega|bluetooth|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="12315" PostTypeId="1" CreationDate="2015-06-02T13:30:54.347" Score="2" ViewCount="576" Body="&lt;p&gt;i tried to connect my arduino uno and ethernet shield with Mysql and everything works fine. Then I tried to connect the RF transmitter and receiver. I use a similar code, but i have problem with connection with database. &#xA;For the project i use:2xArduino Uno,Rf transmitter and receiver ,DHT11 and BMP080,and Ethernet shield. This is my Code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;transmitter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;  #include &quot;LowPower.h&quot;&#xA;  #include &quot;DHT.h&quot;&#xA;  #include &quot;Adafruit_BMP085.h&quot;&#xA;  #include &quot;Wire.h&quot;&#xA;&#xA;  #define DHTPIN 8     // what pin we're connected to&#xA;  #define DHTTYPE DHT11   // DHT 11 &#xA;  DHT dht(DHTPIN, DHTTYPE);&#xA;  Adafruit_BMP085 bmp;&#xA;  int ledPin = 13;&#xA;  char Msg[30];// The string that we are going to send trought rf transmitter &#xA;  void setup() &#xA;  {&#xA;    Serial.begin(115200);&#xA;    dht.begin();  // initialing the DHT sensor&#xA;    bmp.begin();  &#xA;    pinMode(ledPin,OUTPUT);&#xA;    // VirtualWire setup&#xA;    vw_setup(2000); // Bits per sec&#xA;    vw_set_tx_pin(12);// Set the Tx pin. Default is 12&#xA;  }  &#xA;  void loop() &#xA;  {&#xA;     Serial.print(&quot;Pressure = &quot;);&#xA;     Serial.println(bmp.readPressure());&#xA;     Serial.print(&quot;Temperature = &quot;);&#xA;     Serial.println(bmp.readTemperature()); &#xA;     Serial.print(&quot;Humidity = &quot;); &#xA;     Serial.println(dht.readHumidity());&#xA;&#xA;    // Read and store Sensor Data&#xA;    int humidity = dht.readHumidity();&#xA;    int temp = bmp.readTemperature();&#xA;    unsigned long pressure = bmp.readPressure()/100;&#xA;     Serial.print(&quot;Pressure = &quot;); &#xA;     Serial.println(pressure );&#xA;&#xA;    sprintf(Msg, &quot;%d,%d,%d&quot;, humidity,temp ,pressure);&#xA;   // Turn on a light to show transmitting&#xA;    digitalWrite(ledPin, HIGH); &#xA;   //LowPower.powerDown(SLEEP_250MS, ADC_OFF, BOD_OFF);  &#xA;    delay(100); &#xA;    vw_send((uint8_t *)Msg, strlen(Msg));&#xA;    vw_wait_tx(); // Wait until the whole message is gone&#xA;   // Turn off a light after transmission&#xA;    digitalWrite(ledPin, LOW); &#xA;    // put 5 mins sleep mode&#xA;    // As lowpower library support maximam 8s ,we use for loop to take longer (5mins) sleep&#xA;    // 5x60=300&#xA;    //300/4=75&#xA;    for(int i=0;i&amp;lt;75;i++)&#xA;    {&#xA;    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);    // Instead of delay(4000); &#xA;   //delay(4000);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;reciever:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &quot;Wire.h&quot;&#xA;#include &amp;lt;VirtualWire.h&amp;gt; // use Virtual library for decode signal from Rx module&#xA;&#xA; EthernetClient client;&#xA;  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;  char server[] = &quot;192.168.0.101&quot;; &#xA;&#xA;  int humidity=0;&#xA;  int temp=0;&#xA;  unsigned long pressure=0;&#xA;  char MsgReceived[21]; &#xA;&#xA;&#xA;  void setup() &#xA;  {&#xA;    Ethernet.begin(mac);&#xA;    Serial.begin(115200);&#xA;&#xA;    // VirtualWire &#xA;    // Bits per sec&#xA;    vw_setup(2000);&#xA;    // set pin for connect receiver module &#xA;    vw_set_rx_pin(5);  &#xA;    // Start the receiver PLL running&#xA;    vw_rx_start();      &#xA;&#xA;  }&#xA;&#xA;  void loop()&#xA;  {    &#xA;    uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;    uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;    //Taking the data from the control base&#xA;    if (vw_get_message(buf, &amp;amp;buflen)) &#xA;    {&#xA;&#xA;      delay(100);&#xA;      int i;&#xA;      // Message with a good checksum received, dump it. &#xA;      for (i = 0; i &amp;lt; buflen; i++)&#xA;      {            &#xA;        // Fill Msg Char array with corresponding &#xA;        // chars from buffer.   &#xA;        MsgReceived[i] = char(buf[i]);&#xA;        Serial.print(MsgReceived[i]);&#xA;      }&#xA;  connection();&#xA;&#xA;    sscanf(MsgReceived, &quot;%d,%d,%d&quot;,&amp;amp;humidity, &amp;amp;temp, &amp;amp;pressure); // Converts a string to an array&#xA;&#xA;&#xA;    memset( MsgReceived, 0, sizeof(MsgReceived));// This line is for reset the StringReceived&#xA;&#xA;    Serial.print(&quot;Temperature = &quot;);&#xA;    Serial.print(temp);&#xA;    Serial.println(&quot; *C&quot;);&#xA;&#xA;    Serial.print(&quot;Pressure = &quot;);&#xA;    Serial.print(pressure);&#xA;    Serial.println(&quot; hPa&quot;);&#xA;&#xA;    Serial.print(&quot;humidity = &quot;);&#xA;    Serial.print(humidity);&#xA;    Serial.println(&quot; %&quot;);&#xA;&#xA;    delay(10000);  &#xA;    }&#xA;}&#xA;&#xA;  void connection()&#xA;  {&#xA;    if(client.connect(server, 80)) {&#xA;&#xA;      client.print( &quot;GET /diplomna/Arduino/add_data.php?&quot;);&#xA;      client.print(&quot;temperature=&quot;);&#xA;      client.print( temp );&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;humidity=&quot;);&#xA;      client.print( humidity );&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;pressure=&quot;);&#xA;      client.println( pressure );&#xA;      client.println( &quot;HTTP/1.1&quot;);&#xA;      client.println( &quot;Connection: close&quot; );&#xA;      client.stop();&#xA;      Serial.println(&quot;CONNECTED&quot;);&#xA;    }&#xA;    else {&#xA;      // you didn’t get a connection to the server:&#xA;      Serial.println(&quot;-&amp;gt; connection failed&quot;);&#xA;    }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;70,23,100-&amp;gt; connection failed &#xA;Temperature = 23 *C &#xA;Pressure = 1001 hPa    &#xA;Pahumidity = 70 %&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8289" LastActivityDate="2015-06-02T13:30:54.347" Title="Arduino uno RF transmitter and receiver, MYSQL" Tags="|arduino-uno|sensors|ethernet|rf|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12316" PostTypeId="1" CreationDate="2015-06-02T14:04:47.167" Score="1" ViewCount="589" Body="&lt;p&gt;I bought the below FTDI programmer for use with my 3v3 arduino pro mini. But even when the switch is set to 3v3 it is powering the board with 5v, (hence the IO voltage is also 5v). Note that when the pro mini is powered by batteries on the RAW input the IO voltage is 3v3 as expected. The problem is that when programming at 5v, any 3v3 peripherals (such as the BMP180) will be surely damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/301597777458?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.co.uk/itm/301597777458?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now on the eBay description it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This board ship default to 5V, but you can cut the default trace and add a solder jumper if you need to switch to 3.3V&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which trace needs to be cut, and where does the jumper need to connect to/from?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XS2lX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tbIS0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10415" LastActivityDate="2015-06-02T14:37:02.523" Title="FTDI Adjustable 3v3/5v only outputs 5v" Tags="|power|voltage-level|arduino-pro-mini|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12317" PostTypeId="2" ParentId="12316" CreationDate="2015-06-02T14:27:12.530" Score="1" Body="&lt;p&gt;The 5V/3.3V switch is fed into the &quot;VCCIO&quot; pin which sets the voltage of communication and nothing else.  The 5V pin of the header is connected straight through to the USB port's 5V pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either take a separate 3.3V feed from the 3V3OUT pin of the FT232RL (limited to 50mA) which is easiest to take from the 3.3V side of the switch's pins (on the underside, either or both of the two pins with no visible trace connecting to them - the lowest two in your top picture), or you can re-wire the header so it takes its voltage from the output of that switch (the middle two pins).  It looks like it would be a case of cutting the left hand portion of the long fat trace at the top edge of the back (on your top picture) then soldering a wire from the 5V pin on the header to the center pins of the switch.  That should make the output power switchable between 5V and 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uaZmt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-02T14:37:02.523" LastActivityDate="2015-06-02T14:37:02.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12318" PostTypeId="1" CreationDate="2015-06-02T14:39:53.503" Score="0" ViewCount="617" Body="&lt;p&gt;I would like to create a camera dolly for capturing timelapse movies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. something like this:&#xA;&lt;a href=&quot;http://youtu.be/Qce1f6SKEMU&quot; rel=&quot;nofollow&quot;&gt;http://youtu.be/Qce1f6SKEMU&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whats a reliable way to detect the end of the track and stop the stepper motor moving the camera? In other words how is it possible to get the current position of the camera and stop the motor before the track ends to prevent crashing into the bumpers?&lt;/p&gt;&#xA;" OwnerUserId="10417" LastActivityDate="2015-06-02T17:38:15.097" Title="Stop at the end of a track" Tags="|motor|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12320" PostTypeId="2" ParentId="12318" CreationDate="2015-06-02T14:55:07.757" Score="1" Body="&lt;p&gt;The simplest way is to have an opto-interrupter fitted at one end of the track (IR LED and IR Phototransistor), and a small bit of plastic or whatever on the dolly which interrupts the IR beam.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Printers have been doing it that way with their print heads for decades.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.martyncurrey.com/connecting-an-photo-interrupter-to-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.martyncurrey.com/connecting-an-photo-interrupter-to-an-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-02T14:55:07.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12321" PostTypeId="1" CreationDate="2015-06-02T15:32:38.230" Score="2" ViewCount="465" Body="&lt;p&gt;I have an Arduino Uno.&#xA;I am trying to write a code that reads a command and according to that command it saves angles into an array or writes the angles of the array into a servomotor.&#xA;I am facing some problems with my code such as executing the instructions of boucle FOR without ending and other strange things.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo s;&#xA;int t[6];&#xA;int n, r = 2, b = 4 ;&#xA;char c;&#xA;String ch = &quot;&quot; ;&#xA;int i = 0;&#xA;int nb, rep = 0;&#xA;int cmd = -1;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(r, OUTPUT);&#xA;    pinMode(b, OUTPUT);&#xA;    digitalWrite(r, LOW);&#xA;    digitalWrite(b, LOW);&#xA;    s.attach(9);&#xA;    t[0] = 0;&#xA;    t[1] = 90;&#xA;    t[2] = 180 ;&#xA;}&#xA;&#xA;void loop() {&#xA;    while ((cmd == 0) || (cmd == -1)) {&#xA;        cmd = lirecmd();&#xA;        delay(20);&#xA;    }&#xA;&#xA;    if (cmd == 1) {&#xA;        digitalWrite(r, HIGH);&#xA;        digitalWrite(b, LOW);&#xA;&#xA;        while (i &amp;lt; 3) {&#xA;            while (Serial.available() &amp;gt; 0) {&#xA;                c = Serial.read();&#xA;                ch.concat(c);&#xA;            }&#xA;&#xA;            if (ch != &quot;&quot;) {&#xA;                nb = ch.toInt();&#xA;                t[i] = nb;&#xA;                i = i + 1;&#xA;                ch = &quot;&quot;;&#xA;            }&#xA;        }&#xA;    } else if (cmd == 2) {&#xA;        int x;&#xA;        cmd = -1;&#xA;        digitalWrite(b, HIGH);&#xA;        digitalWrite(r, LOW);&#xA;&#xA;        for (i = 0; i &amp;lt; 3; i = i + 1) {&#xA;            Serial.print(i);&#xA;            x = t[i];&#xA;            delay(1000);&#xA;            s.write(x);&#xA;            delay(1000);&#xA;            break;&#xA;        }&#xA;    } else {&#xA;        digitalWrite(r, HIGH);&#xA;        digitalWrite(b, HIGH);&#xA;    }&#xA;&#xA;    i = 0 ;&#xA;    cmd = -1;&#xA;    rep = 0;&#xA;    digitalWrite(r, LOW);&#xA;    digitalWrite(b, LOW);&#xA;    delay(50);&#xA;}&#xA;&#xA;int lirecmd() {&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;        n = Serial.read() ;&#xA;        n = n - 48 ;&#xA;    }&#xA;&#xA;    return n ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10420" LastEditorUserId="4143" LastEditDate="2015-06-02T15:57:46.400" LastActivityDate="2015-06-02T15:57:46.400" Title="reading from an array and writing into a servomotor" Tags="|arduino-uno|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12322" PostTypeId="2" ParentId="12318" CreationDate="2015-06-02T17:10:43.913" Score="1" Body="&lt;p&gt;I find a mechanical switch the simplest and cheapest. But technically it is the same as an opto switch.  These are often refered to as &lt;a href=&quot;https://www.google.com/search?q=limit%20switch&amp;amp;tbm=isch&quot; rel=&quot;nofollow noreferrer&quot;&gt;limit switches&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/l7PWO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You tie the switch to a pin with the normally closed (NC) pin, set it to pinMode(pullup), and check it each each loop. When the read value goes low (0), you stop moving your motor.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-06-02T17:10:43.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12323" PostTypeId="2" ParentId="12318" CreationDate="2015-06-02T17:11:08.820" Score="1" Body="&lt;p&gt;Many methods exist:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;References to unpowered means the switch does not draw power when not operated. When a motor is activated it will draw power.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Mechanical switch- microswitch is the most common (as per Spiked3's suggestion). Contamination and weather may be issues (depending on how waterproof your camera is). No power needed for actual switch.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Optical (a la Majenko). Some environmental issues. Effect of ambient light needs to be considered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Capacitive. Can be fully sealed. Need to be powered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Magnetic - Hall (powered) and Reed (unpowered).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Whatever is used, the current and voltage ratings need to be compatible with the load. In many cases the actual switch will need a transistor or relay or similar to provide the power drive to the dolly motor. This is not hard to do but needs to be noted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An end of track signalling method that is relatively unaffected by environmental issues is to use a magnet and magnet detector. The most common detectors are either a &quot;Hall sensor&quot; IC or a reed switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reed switches are mechanical and more fragile than Hall sensors but need no power when unoperated and can be bought in ready made encapsulations that are robust enough to be reliable. Properly implemented a reed switch can be essentially indestructible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hall sensors need to be powered but power levels are small compared to eg dolly motor current and low current versions are available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both Hall sensors and reed switches have a degree of &quot;hysteresis&quot; - the point in the travel where they operate is past the point where they release again, but this is easily allowed for in practice.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=hnCEQYO-i_E&quot; rel=&quot;nofollow&quot;&gt;Reed switch demonstration&lt;/a&gt; - 38 seconds video - simple and obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instructables &lt;a href=&quot;http://www.instructables.com/id/DIY-motorized-moving-timelapse-camera-dolly-with-A/all/&quot; rel=&quot;nofollow&quot;&gt;DIY powered dolly wity reed swithes&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/13247&quot; rel=&quot;nofollow&quot;&gt;Sparkfun magnetic door switch set&lt;/a&gt; and encapsulated reed switch and magnet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.electronics-tutorials.ws/electromagnetism/hall-effect.html&quot; rel=&quot;nofollow&quot;&gt;Hall sensor theory of operation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.co.nz/search?q=hall+sensor&amp;amp;biw=1280&amp;amp;bih=789&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ei=buRtVYmRFtXh8AWv9YOYAQ&amp;amp;sqi=2&amp;amp;ved=0CAYQ_AUoAQ#tbm=isch&amp;amp;q=hall+effect+sensor++circuit&quot; rel=&quot;nofollow&quot;&gt;Many ideas here&lt;/a&gt; for using hall sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.co.nz/search?q=hall+sensor&amp;amp;biw=1280&amp;amp;bih=789&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ei=buRtVYmRFtXh8AWv9YOYAQ&amp;amp;sqi=2&amp;amp;ved=0CAYQ_AUoAQ#tbm=isch&amp;amp;q=reed+switch+&quot; rel=&quot;nofollow&quot;&gt;Reed switches&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-06-02T17:38:15.097" LastActivityDate="2015-06-02T17:38:15.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12324" PostTypeId="1" CreationDate="2015-06-01T07:43:13.783" Score="0" ViewCount="134" Body="&lt;p&gt;Can I use the arduino for an application with a frequency of 4 MHz?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to create a clk with this frequency and send and receive data on the rising and falling edges. and it is not a normal SPI interface I have my own conditions so I need to do it manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is not suitable, is it technically possible?&lt;/p&gt;&#xA;" OwnerDisplayName="Sherif Badawy" LastActivityDate="2015-06-02T18:32:06.293" Title="Is arduino suitable for high frequency application?" Tags="|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12325" PostTypeId="2" ParentId="12324" CreationDate="2015-06-01T07:58:24.177" Score="0" Body="&lt;p&gt;No, it's not suitable due to the inherent maximum pin output frequencies in relation to the clock divider setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it's technically possible. Edit the divider to a value that sets the output to close to what you need. However this is annoying to do, and has serious repercussions in your code. (i.e. having to multiply every timing/bit value by 16, 8, 4, 2 or whatever you choose)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A clock of that high of a frequency would have to be some crystal to set the base time, and then a comparator circuit that could vary fast enough to push data into the edges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could, however, simply note the absence of the 4MHz signal as 0, and it's presence as 1, sending binary data that way it probably a lot easier than encoding it between each individual edge.&lt;/p&gt;&#xA;" OwnerDisplayName="ARMATAV" LastActivityDate="2015-06-01T07:58:24.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12326" PostTypeId="2" ParentId="12324" CreationDate="2015-06-02T18:32:06.293" Score="1" Body="&lt;p&gt;Most Arduinos are based on AVR chips clocked at 16&amp;nbsp;MHz. On those,&#xA;you &lt;em&gt;can&lt;/em&gt; generate a 4&amp;nbsp;MHz clock using hardware timers. Bit-banging&#xA;data at this speed would be difficult though. It &lt;em&gt;may&lt;/em&gt; be possible,&#xA;using unrolled loops and hand-crafted assembly... or not, depending on&#xA;the specifics of your application. Even if possible, it would be a nice&#xA;challenge for an assembly programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due is based on an ARM chip clocked at 84&amp;nbsp;MHz. This&#xA;gives you more leeway to bit-bang at 4&amp;nbsp;MHz. But even on the Due you&#xA;would certainly need hand-crafted assembly.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-02T18:32:06.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12328" PostTypeId="1" AcceptedAnswerId="12329" CreationDate="2015-06-02T20:02:00.460" Score="1" ViewCount="132" Body="&lt;p&gt;My leonardo was working fine until today, when I plug it to my computer all led (RX/TX/L/ON) stays on (Green for on, amber for others) and my computer no longer see a com port. &#xA;(by the way, do you know what the L led mean ?)&#xA;If I add external power, TX goes off then after few seconds RX goes off too then back on.&#xA;With external power, the atmega goes very hot (I can't touch it).&#xA;RESET button do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my Leonardo dead ? Any idea what could have cause that ? The fact that the atmega is so hot when the board is powered up with 12V let me think that the voltage regulators is no longer working. Good guess ? &lt;/p&gt;&#xA;" OwnerUserId="10425" LastActivityDate="2015-06-02T20:43:04.523" Title="Leonardo broken?" Tags="|power|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12329" PostTypeId="2" ParentId="12328" CreationDate="2015-06-02T20:43:04.523" Score="1" Body="&lt;p&gt;By your description, I'd say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Quite Probably.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should check what the 5V and 3.3V voltages are using a DMM.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-02T20:43:04.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12330" PostTypeId="2" ParentId="3926" CreationDate="2015-06-02T20:58:46.907" Score="2" Body="&lt;p&gt;i have also bought this IR receiver with a remote controller (as a kit), and i had the same problem, i changed the remote controller and it worked perfectly, so even if the IR and RC came as a kit it doesn't mean they will work, if you don't have another remote controller in hand you can use a lighter just to check if the IR is working.  &lt;/p&gt;&#xA;" OwnerUserId="8807" LastActivityDate="2015-06-02T20:58:46.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12331" PostTypeId="1" AcceptedAnswerId="12332" CreationDate="2015-06-02T21:34:50.903" Score="0" ViewCount="6424" Body="&lt;p&gt;So I am doing a project where a bunch of servos are moving from 90 - 120 degrees and slowly speed up over time until they reach their max speed and so stay at that speed.&#xA;This is being done by editing the delay under the servo sweep for loop.&#xA;However though this works it doesn't work with the next component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WHat I want to happen next is an MFRC522 RFID reader to always be scanning and at any time it detects a card and verifies it the servos from whatever speed they are now at start to slow down. &#xA;The problem is I can't get the two functions to run simultaneously. IF the servo is running its sweep function it must finish before the RFID tag can scan. This makes the whole device look very lagy.&#xA;Is there a way I can get the RFID scanner to be reading all the time even when the servo sweep for loop is working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&#xA;Please note that I have put printins everywhere to see how often the RFID is scanning etc just while I test the code out. &#xA;I essentially have two functions one called nocardservo and yescardservo each one activating if there is a card there or not.&#xA;Any help would be fantastic!!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define RST_PIN     9       // &#xA;#define SS_PIN      10      //&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance&#xA;&#xA;Servo myservo;&#xA;int pos = 0;&#xA;int y = 15;&#xA;int z = y;&#xA;void setup() {&#xA;  myservo.attach(6);&#xA;  myservo.writeMicroseconds(1518);&#xA;  Serial.begin(9600);       // Initialize serial communications with the PC&#xA;  while (!Serial);      // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;  SPI.begin();          // Init SPI bus&#xA;  mfrc522.PCD_Init();       // Init MFRC522&#xA;  //ShowReaderDetails();    // Show details of PCD - MFRC522 Card Reader details&#xA;  //Serial.println(F(&quot;Scan PICC to see UID, type, and data blocks...&quot;));&#xA;}&#xA;&#xA;void loop() {&#xA;  // Look for new cards&#xA;  if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;nocardservo();&#xA;    return;&#xA;  }&#xA;  delay(20);&#xA;  Serial.println(&quot;carddetected&quot;);&#xA;  // Select one of the cards&#xA;  if ( ! mfrc522.PICC_ReadCardSerial()) {&#xA;&#xA;  }&#xA;  Serial.println(&quot;correctcard&quot;);&#xA;  yescardservo();&#xA;delay(20);&#xA;return;&#xA;}&#xA;&#xA;&#xA;//***If card not detected this function runs**//&#xA;&#xA;&#xA;void nocardservo() {&#xA;&#xA;  for (pos = 90; pos &amp;lt; 180; pos += 1) // goes from 0 degrees to 180 degrees&#xA;  { // in steps of 1 degree&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;  for (pos = 180; pos &amp;gt;= 90; pos -= 1) // goes from 180 degrees to 0 degrees&#xA;  {&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);&#xA;&#xA;  }&#xA;}&#xA;}&#xA;&#xA;&#xA;//***If card is detected this function runs**//&#xA;&#xA;void yescardservo() {&#xA;&#xA;  for (pos = 90; pos &amp;lt; 180; pos += 1) // goes from 0 degrees to 180 degrees&#xA;  { // in steps of 1 degree&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(50);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;  for (pos = 180; pos &amp;gt;= 90; pos -= 1) // goes from 180 degrees to 0 degrees&#xA;  {&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(50);&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10426" LastEditorUserId="1585" LastEditDate="2015-06-02T21:44:39.657" LastActivityDate="2019-02-20T11:22:29.707" Title="Being able to run two functions at once" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12332" PostTypeId="2" ParentId="12331" CreationDate="2015-06-02T22:08:42.297" Score="4" Body="&lt;p&gt;What you want to implement is described in &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;Blink Without Delay&lt;/a&gt;.  Basically, instead of using the delay function to just wait until your time has elapsed, you use variables to measure how much time has elapsed and only execute your operation when it has.  In the mean time, you can check on other things and do those in the mean time.  &lt;/p&gt;&#xA;" OwnerUserId="8321" LastActivityDate="2015-06-02T22:08:42.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12333" PostTypeId="1" AcceptedAnswerId="12338" CreationDate="2015-06-03T01:42:39.850" Score="0" ViewCount="1909" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/21gov.png&quot; alt=&quot;Arduino power supply&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Folks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am planning to power my Arduino, which will be mounted on a motorcycle, using the motorcycle's battery. So the same battery will be starting the engine and powering other electrical components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if this circuit will work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C1 - 1000uF 50V;&#xA;C2 - 1000uF 25V;&#xA;D1 - 1N4001 ;&lt;/p&gt;&#xA;" OwnerUserId="10428" LastActivityDate="2015-06-03T12:44:31.220" Title="Motorcycle Battery Powering Arduino UNO" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12334" PostTypeId="1" CreationDate="2015-06-03T01:44:50.057" Score="2" ViewCount="1556" Body="&lt;p&gt;I made a sketch that receives an rgb code from a remote Arduino using nrf24l01 and while it works &lt;strong&gt;for the first receivings&lt;/strong&gt; then it stops working. I placed a testing &lt;code&gt;Serial.println&lt;/code&gt; in the loop to test if Arduino stops to work completely or it doesn't receive any other data. Finally, I understood that it continues to work but it doesnt receive more data. Bellow is my code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;RF24Network.h&amp;gt;&#xA;#include &amp;lt;RF24Network_config.h&amp;gt;&#xA;#include &amp;lt;Sync.h&amp;gt;&#xA;&#xA;#include  &amp;lt;TimerOne.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;//#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;RF24 radio(8,10);&#xA;RF24Network network(radio);&#xA;volatile int i=0; &#xA;volatile int d=0;     // Variable to use as a counter&#xA;volatile boolean zero_cross=0;  // Boolean to store a &quot;switch&quot; to tell us if we have crossed zero&#xA;int AC_pin= 4;    // Output to Opto Triac pin&#xA;int dim = 0;  // Dimming level (0-128)  0 = ON, 128 = OFF&#xA;int freqStep = 65; &#xA;&#xA;struct payload_rgb&#xA;{&#xA;  unsigned int red;&#xA;  unsigned int green;&#xA;  unsigned int blue;&#xA;};&#xA;struct payload_lightuv&#xA;{&#xA;  unsigned int light;&#xA;  unsigned int uv;&#xA;};&#xA;RF24NetworkHeader header;&#xA;payload_rgb payloadrgb;&#xA;payload_lightuv payloadl;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(AC_pin, OUTPUT);// Set AC Load pin as output&#xA;  pinMode(9, OUTPUT);// Set AC Load pin as output&#xA;  pinMode(5, OUTPUT);&#xA;  pinMode(6, OUTPUT);&#xA;  attachInterrupt(0, zero_cross_detect, RISING);  // Choose the zero cross interrupt # from the table above&#xA;  Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need&#xA;  Timer1.attachInterrupt(dim_check, freqStep);    &#xA;  Serial.begin(115200);&#xA;  radio.begin();&#xA;  network.begin(90,01);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  network.update();&#xA;  while ( network.available() )&#xA;  {&#xA;    Serial.println(&quot;Rec&quot;);&#xA;&#xA;    network.peek(header);&#xA;    if(header.type=='r'){&#xA;      network.read(header,&amp;amp;payloadrgb,sizeof(payloadrgb));&#xA;      analogWrite(6,payloadrgb.red);&#xA;      analogWrite(9,payloadrgb.green);&#xA;      analogWrite(5,payloadrgb.blue);&#xA;    }&#xA;    if(header.type=='l'){&#xA;      network.read(header,&amp;amp;payloadl,sizeof(payloadl));&#xA;      dim=payloadl.light;&#xA;    }&#xA;}&#xA;Serial.println(&quot;!&quot;); //this is the test println&#xA;}&#xA;void zero_cross_detect() {    &#xA;  zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured&#xA;  i=0;&#xA;  digitalWrite(AC_pin, LOW);       // turn off TRIAC (and AC)&#xA;}   &#xA;void dim_check() {                   &#xA;  if(zero_cross == true) {              &#xA;    if(i&amp;gt;=dim) {                     &#xA;      digitalWrite(AC_pin, HIGH); // turn on light       &#xA;      i=0;  // reset time step counter                         &#xA;      zero_cross = false; //reset zero cross detection&#xA;    } &#xA;    else {&#xA;      i++; // increment time step counter                     &#xA;    }                                &#xA;  }                                  &#xA;}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, this Arduino controls an ac dimmer. Bu I have not done it yet.&#xA;How can I fix the problem without removing any feature?&lt;/p&gt;&#xA;" OwnerUserId="8275" LastEditorUserId="37523" LastEditDate="2019-08-16T22:43:25.010" LastActivityDate="2019-08-16T22:43:25.010" Title="Arduino stops working after some receivings from RF" Tags="|spi|timers|nrf24l01+|rf|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="12335" PostTypeId="1" AcceptedAnswerId="12349" CreationDate="2015-06-03T02:32:21.043" Score="0" ViewCount="1782" Body="&lt;p&gt;I am currently working on a RFID card reader. I need the reader to send the ID to a storage space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to achieve is a person swipes their card, enters their name on the serial monitor, and then have that data stored in a pair. The thing is that I do not know how many people will have cards. After that, I could call a person's name and it would show &quot;Hello &lt;code&gt;w&lt;/code&gt;, your ID number is &lt;code&gt;xxx xxx xxx xxx xxx&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I know there are no such things as &quot;dynamic&quot; variables. And I think I would need to pre-define a TON of arrays if I wanted to use them. So I am kinda at a stopping point. Is there no way to generate a new variable name and store data to that variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I work with PLCs so I thought that indirect addressing might work, but I am unfamiliar on how to even do that in C++, only in ladder logic or if it would even work. Or how I would be able to call out an ID by name with that approach. &lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2015-06-03T17:08:52.617" Title="How to add data without pre-defining variables?" Tags="|arduino-uno|c++|rfid|variables|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12337" PostTypeId="2" ParentId="12335" CreationDate="2015-06-03T03:26:40.127" Score="1" Body="&lt;p&gt;The &quot;key&quot; is creating a means to access a table of IDs that you can search through for a given name or a given ID number. There are various ways of doing this and if you are unclear on these that can be discussed in due course. But, to start, I'll assume that making and searching some form of table or array is not a problem for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You obviously MUST have enough storage space for the maximum number of simultaneous IDS that you wish to store at any time. Call this &quot;IDCount&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can allocate IDCount ID storage locations by whatever means suits you.&lt;br&gt;&#xA;In unused locations you store a dummy or null ID number.&lt;br&gt;&#xA;eg ID 000 000 000 000 000 is probably invalid so can be used as an 'empty' indicator.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To add a new ID  either search through your table of IDs for an empty location and store the new ID there. To find a given ID match you search the table for the ID and , if it exists, retrieve the matching name. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Improvements&quot;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To reduce access times&lt;/strong&gt; when the potential entries are large you can store all entries &quot;at the bottom&quot; and have a pointer to the 1st free location. New entries are added &quot;at the end&quot;. If an entry is removed, all entries above it are moved down by one. eg   if entry N is removed:&lt;br&gt;&#xA;for (entry &gt;= N and entry &amp;lt; end_pointer)&lt;br&gt;&#xA;...move entry N + 1 into location N&lt;br&gt;&#xA;...and step N by 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method is to use a &quot;&lt;strong&gt;linked list&lt;/strong&gt;&quot; where each entry has a pointer to the next entry in the list. New entries take an address from the empty_locations list and add their address to the used_locations list. Removed entries do the opposite. This can be fast and effective but also mind blowing for beginners and, when it goes wrong it can go VERY wrong. Best avoided initially.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple &quot;search for 1st empty entry&quot; method will usually work very well.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-06-03T03:26:40.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12338" PostTypeId="2" ParentId="12333" CreationDate="2015-06-03T03:56:05.217" Score="4" Body="&lt;p&gt;Your circuit is 'going in the right direction' but can be improved.&lt;br /&gt;&#xA;If you wish to use the regulator shown:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The larger the input capacitor (C1) the better; it will survive noise spikes and low voltage &amp;quot;droops&amp;quot;, eg during starting.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Adding a series resistor to drop some of the input voltage will help C1 filter out noise.&lt;br /&gt;&#xA;&lt;em&gt;Rin&lt;/em&gt; should be V/I = V_drop_max/I_maximum .&lt;br /&gt;&#xA;With a 9V regulator and 12V supply you cannot afford much drop in the resistor.&lt;br /&gt;&#xA;If you use the 6V output system I recommend below then you could allow closer to 3V drop in &lt;em&gt;Rin&lt;/em&gt;.&lt;br /&gt;&#xA;If &lt;em&gt;Imax&lt;/em&gt; is 100mA then &lt;em&gt;Rin&lt;/em&gt; = V/I = 3/0.1 = 30 Ohms.&lt;br /&gt;&#xA;Typically you'd use 27 Ohms (which is the closest E12 standard value.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Power dissipation is the resistor = I^2 x R.&lt;br /&gt;&#xA;So for eg 27 Ohms and 0.1 A (100 mA) power dissipation in the resistor is&lt;br /&gt;&#xA;I^2 x R = 0.1^2 x 27 = 0.27 Watt&lt;br /&gt;&#xA;So you'd use at least a 0.5 Watt resistor and ideally  Watt or more. Air cooled resistors are relatively low cost and a much better way of dealing with heat than trying to cool a regulator.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adding a ~15V zener diode at the input to U1 will help protect against spikes. This works better if &lt;em&gt;Rin&lt;/em&gt; is used. Without &lt;em&gt;Rin&lt;/em&gt; the zener may be destroyed by spikes. If you use the LM29xx regulators that I mention below the zener is not needed as the regulator has its own internal protection circuitry.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The LM7809 regulator is somewhat unusual. If you have them available they could be used but there are much more common and/or modern regulators available.&lt;/p&gt;&#xA;&lt;p&gt;The regulator's Vout should be fed to the Arduino's Vin terminal, which supplies the Arduino's internal regulator, to provide 5V or 3V3 depending on which Arduino you are using. With a 5V Arduino, using Vin of 6V or more will be adequate. Higher Vin causes more heat in the Arduino on board regulator. (As Chaaarlie2 noted, 6V on Vin may be a bit on the low side for heavy loads on the Arduino 5V supply - as may happen if shields use the 5V supply. Increasing Vin to say 6.5V should allow the Arduino's internal regulator to supply its maximum rated current if desired.&lt;/p&gt;&#xA;&lt;p&gt;9V output is higher than the Arduino needs. It is an acceptable voltage but 6V to 7V will cause less heat on-board the Arduino (and more in the external regulator).&lt;/p&gt;&#xA;&lt;p&gt;Vehicle power systems can have extremely high voltage spikes present and sudden changes in supply voltage. Some regulators are made to work well in the automotive environment. One such family are the LM29xx series of regulators.&lt;/p&gt;&#xA;&lt;p&gt;One superb version of this regulator is the LM2931-N &lt;a href=&quot;http://www.ti.com/lit/ds/snosbe5g/snosbe5g.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;[&lt;strong&gt;Data sheet here&lt;/strong&gt;]&lt;/a&gt; - this is available in a range of versions but the simplest is the 3 lead type in a range of packages. The TO220 package is recommended due to its good power dissipation capability and ease of heatsinking if necessary. This data sheet covers versions with about 100 mA output rating, but higher output examples are available. Fixed 3.3V and 5V output versions are available but in this application the variable output version, set to about 6V or maybe 6.5V is &amp;quot;safest&amp;quot;. These are very similar to the common LM317 in operation. The basic regulator produces 1.26V output and 2 resistors are used to set the desired output voltage. The advantages over the LM317 are the lower dropout voltage and the protection against typical automotive input problems.&lt;/p&gt;&#xA;&lt;p&gt;The datasheet description states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Designed originally for automotive applications, the LM2931-N and all regulated circuitry are protected from reverse battery installations or 2 battery jumps.&lt;/p&gt;&#xA;&lt;p&gt;During line transients, such as a load dump (60V) when the input voltage to the regulator can momentarily exceed the specified maximum operating voltage, the regulator will automatically shut down to protect both internal circuits and the load.&lt;/p&gt;&#xA;&lt;p&gt;The LM2931-N cannot be harmed by temporary mirror-image insertion. Familiar regulator features such as short circuit and thermal overload protection are also provided.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-03T12:44:31.220" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12339" PostTypeId="1" CreationDate="2015-06-02T00:38:00.413" Score="2" ViewCount="949" Body="&lt;p&gt;So I recently got an Arduino Uno R3. Installed the IDE and drivers under Windows 8.1 and everything seemed to work fine and received the 'Done uploading' message when goofing around with the Blink example(was in a hurry that day).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next day when I connected the Uno, I noticed the L(yellow) led keeps staying on and I get the following error when trying to upload:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/cy/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyS0&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: Send: 0 [30]   [20] &#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: Send: 0 [30]   [20] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried on both Windows and Ubuntu and am really excited about learning things with Arduino. Thanks in advance for your help!&lt;/p&gt;&#xA;" OwnerUserId="10440" OwnerDisplayName="Cyrus" LastActivityDate="2015-06-03T11:21:23.107" Title="Arduino Uno R3 L(yellow) led stays on and error on upload" Tags="|arduino-uno|arduino-ide|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12340" PostTypeId="1" CreationDate="2015-06-03T13:43:37.767" Score="2" ViewCount="225" Body="&lt;p&gt;I recently bought a Atmel Atmega 328 P-PU microcontroller.I tried uploading a program to it by using the circuitry given in the link.I am using a RS 232 breakout board.Here is the link &lt;a href=&quot;http://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/Standalone&lt;/a&gt; .I am not able to upload programs to it.It says problem uploading to board or avrdude attempt 1 out of 10 failed.What can I do about it? &lt;/p&gt;&#xA;" OwnerUserId="10220" LastEditorUserId="10220" LastEditDate="2015-06-04T12:46:35.363" LastActivityDate="2015-06-04T12:46:35.363" Title="Problem uploading program to Atmega 328 microcontroller" Tags="|uploading|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12341" PostTypeId="1" CreationDate="2015-06-03T14:27:03.567" Score="2" ViewCount="287" Body="&lt;p&gt;I am using the &quot;SD read/write&quot; code from the Arduino IDE examples to test an ethernet shield (clone). The problem is that although a file is created no data is stored in it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running the serial monitor will only show the first characters of the &lt;em&gt;Serial.print()&lt;/em&gt; sentences, e.g when doing &lt;em&gt;Serial.print(&quot;Initializing SD card...&quot;)&lt;/em&gt; the serial monitors displays &lt;em&gt;Ini&lt;/em&gt; or &lt;em&gt;In&lt;/em&gt; and nothing else.&#xA;Also the IDE shows the following error message: (some words in spanish)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error dentro de Serial.serialEvent()&#xA;java.io.IOException: Error de entrada/salida in nativeavailable&#xA;at gnu.io.RXTXPort.nativeavailable(Native Method)&#xA;at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1598)&#xA;at processing.app.Serial.serialEvent(Serial.java:258)&#xA;at gnu.io.RXTXPort.sendEvent(RXTXPort.java:774)&#xA;at gnu.io.RXTXPort.eventLoop(Native Method)&#xA;at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1644)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried with 2 different SD cards, including a brand new one, and 2 different Arduino Uno (a clone and an original one). The OS is Ubuntu 13.10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that it has something to do with the &lt;em&gt;myFile.println()&lt;/em&gt; sentences, when they are commented the serial monitor works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is much appreciated since I couldn't find the problem anywhere else so far!&lt;/p&gt;&#xA;" OwnerUserId="10438" LastEditorUserId="10438" LastEditDate="2015-06-05T00:12:46.647" LastActivityDate="2015-06-05T00:12:46.647" Title="Problems when communicating with SD card using ethernet shield" Tags="|arduino-uno|ethernet|sd-card|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12342" PostTypeId="1" AcceptedAnswerId="12343" CreationDate="2015-06-03T14:30:55.647" Score="5" ViewCount="2160" Body="&lt;p&gt;I use Ethernet Shield and Arduino to GET data from the server in JSON format. Request looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;GET http://ramp.local/api/actions?&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The response I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[{&quot;action_id&quot;:1,&quot;action_type&quot;:&quot;up&quot;,&quot;action_status&quot;:&quot;new&quot;,&quot;ramp_id&quot;:31,&quot;user_id&quot;:17}, &#xA;{&quot;action_id&quot;:2,&quot;action_type&quot;:&quot;down&quot;,&quot;action_status&quot;:&quot;new&quot;,&quot;ramp_id&quot;:32,&quot;user_id&quot;:20},        &#xA;{&quot;action_id&quot;:3,&quot;action_type&quot;:&quot;up&quot;,&quot;action_status&quot;:&quot;completed&quot;,&quot;ramp_id&quot;:32,&quot;user_id&quot;:17},   &#xA;{&quot;action_id&quot;:4,&quot;action_type&quot;:&quot;up&quot;,&quot;action_status&quot;:&quot;failed&quot;,&quot;ramp_id&quot;:31,&quot;user_id&quot;:17}]  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to collect a data in a string variable and parse it to get &lt;code&gt;action_status&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10439" LastEditorUserId="297" LastEditDate="2015-06-05T07:11:41.240" LastActivityDate="2015-09-03T10:05:14.697" Title="Storing and parsing data with Arduino" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12343" PostTypeId="2" ParentId="12342" CreationDate="2015-06-03T14:56:41.073" Score="0" Body="&lt;p&gt;Ideally, you would use a proper recursive JSON parser, like the one&#xA;suggested in prakharsingh95's answer. However, if code speed and size&#xA;are critical considerations, and if the format of the response is&#xA;narrowly constrained, then you can build a fast special-purpose parser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple example. It assumes the response has been stored in the&#xA;&lt;code&gt;response&lt;/code&gt; char array:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;static const char key[] = &quot;\&quot;action_status\&quot;&quot;;&#xA;const char *p, *q;&#xA;char action_status[16];&#xA;&#xA;for (p = response; ; p = q) {&#xA;    p = strstr(p, key);    // find key&#xA;    if (!p) break;         // not found&#xA;    p = strchr(p, ':');    // find ':' between key and value&#xA;    p = strchr(p, '&quot;');    // find opening quotes for the value&#xA;    q = strchr(p+1, '&quot;');  // find closing quotes&#xA;&#xA;    // Report finding.&#xA;    strncpy(action_status, p+1, q-p-1);&#xA;    action_status[q-p-1] = '\0';&#xA;    Serial.print(&quot;Found action status: &quot;);&#xA;    Serial.println(action_status);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, in production code you would check that every &lt;code&gt;strchr&lt;/code&gt; call&#xA;returns a non-NULL pointer. And you would check that the status you&#xA;found fits in your buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt; about the pros and cons of this method:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compared to a proper JSON parser, this approach will give you smaller&#xA;and faster code, the drawback is it being more &lt;em&gt;fragile&lt;/em&gt;. For example,&#xA;this will not detect a corrupted JSON, and it will return garbage if the&#xA;action_status happens to be a number instead of a string, or is a&#xA;string with embedded double quotes, or if the string &quot;action_status&quot;&#xA;appears as a value of some other field... A full JSON parser should&#xA;correctly handle all these cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a non-embedded computer, a proper JSON parser would probably be the&#xA;only appropriate answer. On a constrained microcontroller environment,&#xA;you sometimes have to make trade-offs. In this particular instance, the&#xA;“best” answer depends on how much you weight speed and size vs.&#xA;robustness against unexpected input.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-05T08:27:47.653" LastActivityDate="2015-06-05T08:27:47.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12344" PostTypeId="1" AcceptedAnswerId="12357" CreationDate="2015-06-03T15:49:49.307" Score="1" ViewCount="142" Body="&lt;p&gt;When I upload my program to Arduino it says the memory that the program is used. But what if I use a bad management of dynamic memory, or any object is created several times in use a lot of memory and the Arduino memory overload. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I know the current size of memory that Arduino is use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking about to create a function in Arduino that return me this information if I send it a request command, but also I don't know how do I inspect the Arduino memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I am using the Board: Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read the question and the answer for &lt;a href=&quot;https://arduino.stackexchange.com/questions/11845/measure-sram-usage&quot;&gt;Measure SRAN usage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the question @fuenfundachtzig ask: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Can I determine how much SRAM I have left in the live system?&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my question I am asking about how do I know or monitoring my program memmory. Ok the Measure SRAN usage answer give me the tips or tools to develop my idea, but the question is not the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am tryin to know in an specific time what is the size of my memmory. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;example...&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { //doing some configuration };&#xA;&#xA;void loop() {  // invoke some functions and evil function  };&#xA;&#xA;// in other place a evil function &#xA;&#xA;void evil(){&#xA;MyClass * instance = new MyClass();&#xA;//play with the instance and it class create other instances....&#xA;//and a dynamic memmory is used but not deleted.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to know if it happens and how do I detect with Arduino? I am not talking about how much memmory do I left in the live system.&lt;/p&gt;&#xA;" OwnerUserId="10295" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-06-04T01:48:41.283" Title="How do I know how many memory that Arduino is use after my code is running for a few time" Tags="|arduino-mega|memory-usage|" AnswerCount="1" CommentCount="2" ClosedDate="2015-06-04T07:43:37.653" ContentLicense="CC BY-SA 3.0" />
  <row Id="12349" PostTypeId="2" ParentId="12335" CreationDate="2015-06-03T17:08:52.617" Score="2" Body="&lt;p&gt;Use the EEPROM. This allows data to remain intact and unchanged even when power is disconnected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you say you're new to programming, and because I wrote a similar program just last week as an experiment for something bigger, I'll talk you through some of it. However, I'm not going to give you the whole code to copy-and-paste, I'm only going to give you information on dealing with EEPROM and structures. C-aficionados may grumble at some bits, and Arduinites at others - sic vita est. This is something of a crash-course so it's not gospel, but it should be more than enough to guide you. You may already know some or most of it; it's included nonetheless for completeness, for those who don't.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;For those who don't know&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In C, data relevant to an object can be stored in a &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/structures/&quot; rel=&quot;nofollow&quot;&gt;structure&lt;/a&gt;, or &lt;code&gt;struct&lt;/code&gt;. You can put all sorts of different types of data in a struct, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct personalProfile {&#xA;    char    firstName[8];&#xA;    char    lastName[8];&#xA;    uint    cardID;           // 'uint' is an unsigned int...&#xA;    bool    accessAllowed;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use that structure to create a 'personal profile' for however many people you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// within your main program:&#xA;&#xA;struct personalProfile Person1;&#xA;struct personalProfile Person2;&#xA;&#xA;// Now you can directly access individual aspects as so:&#xA;&#xA;Person1.firstName = &quot;John&quot;;&#xA;Person1.lastName = &quot;Brown&quot;;&#xA;Person1.accessAllowed = TRUE;&#xA;&#xA;Person2.firstName = &quot;Dodgy&quot;;&#xA;Person2.lastName = &quot;Dave&quot;;&#xA;Person2.accessAllowed = NOT_A_HOPE_IN_HELL;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;em&gt;members&lt;/em&gt; of a structure in exactly the same way you'd use that member type if it wasn't part of a structure. Nice and easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way to store multiple instances of a particular variable type is in an &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/arrays/&quot; rel=&quot;nofollow&quot;&gt;array&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct personalProfile listOfPeople[5];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You now have an array of five (blank) &lt;code&gt;struct&lt;/code&gt;s, which can be accessed by &lt;code&gt;listOfPeople[n].firstName = Potato;&lt;/code&gt;, where 'n' is between 0 and the number-of-entries-minus-one. So far so potato.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An array is pretty basic. It's present in all sorts of programming languages because it's inherently essential to almost any program, but the trouble is that it's static. Using the code above, once the array has been created with five &lt;code&gt;struct&lt;/code&gt;s in it you can't add or remove any. One solution is to create a massive array, and set all the values in each &lt;code&gt;struct&lt;/code&gt; to zero, or some other 'empty' identifier, so you're always going to have enough entries (up to a point). However, that's lazy, time inefficient (you've got to set aaaaalll the individual elements to your 'empty' signifier), resource inefficient (look at all that unused space!), and the data only lasts while the program is running. As soon as you cut the power to the Arduino, the information is lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next comes &lt;a href=&quot;http://www.cplusplus.com/reference/stl/&quot; rel=&quot;nofollow&quot;&gt;containers&lt;/a&gt;. These are part of the Standard Template Library (STL) in C++. They're great for creating and managing dynamic-length arrays. There are different types for different purposes (see the link), but they don't exist in C (at least as far as this post is concerned) and they're not available as part of the Arduino IDE without installing a bunch of libraries or some other intervention. Therefore you've got to make your own version. It's actually pretty easy...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;EEPROM basics&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;EEPROM library&lt;/a&gt; that comes with Arduino is of course essential for this. It doesn't have many functions, and the ones that exist are fantastically easy to understand. EEPROM, for those who don't know, is non-volatile memory. That means that when you store data it stays there forever, even if you remove the power. The only way to get rid of the data is to write over it. The downside of EEPROM is that it has limited amount of times it can be written to - 100,000 times per bit typically so you don't need to start keeping count, it just means you shouldn't be using it as regular program memory. Reading data from EEPROM isn't limited in the same manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the function &lt;code&gt;EEPROM.put(address, data)&lt;/code&gt; you can put ANY data type - an &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;char&lt;/code&gt; or - you guessed it - a &lt;code&gt;struct&lt;/code&gt; into the EEPROM, starting at the byte specified by &lt;em&gt;address&lt;/em&gt;. Of course there has to be enough space so you can't put an &lt;code&gt;int&lt;/code&gt;, which takes up more than 1-byte of space, into the last address without the function failing. (Or can you? I haven't tried it yet because I'd never do it in practice.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you've created your structure, and made sure that all it's members are a fixed size. That means the structure has a fixed size. If you know that size, you can start putting them into the EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// within main program&#xA;&#xA;struct personalProfile Person1;&#xA;struct personalProfile Person2;&#xA;&#xA;// fill in the details for Person 1...&#xA;// fill in the details for Person 2...&#xA;&#xA;// ...then put Person1 in the EEPROM at address 0.&#xA;EEPROM.put(0, Person1);&#xA;&#xA;// Done. Now put in Person2. But where?&#xA;// You need to make sure you put them AFTER Person1.&#xA;&#xA;int AddressJump = sizeof(personalProfile);&#xA;&#xA;// AddressJump now equals how many bytes are need to store one person.&#xA;&#xA;EEPROM.put(AddressJump, Person2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simple as that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you create a Person3, you're going to need to put them &lt;code&gt;sizeof(personalProfile)&lt;/code&gt; bytes AFTER Person2, i.e. &lt;code&gt;EEPROM.put(AddressJump*2, Person3);&lt;/code&gt;. So, you add Person&lt;em&gt;N&lt;/em&gt; to address &lt;code&gt;AddressJump * (N-1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Retrieving data is the same principle, except you use &lt;code&gt;EEPROM.get()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// provided you've used the above snippet somewhere to actually&#xA;// populate the EEPROM with something!&#xA;&#xA;struct personalProfile personA;&#xA;&#xA;EEPROM.get(0, personA);&#xA;&#xA;Serial.print(&quot;Person A is called:&quot;);&#xA;Serial.println(personA.firstName);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, you're going to need &lt;code&gt;sizeof(personalProfile)&lt;/code&gt; to read the second, third, or &lt;em&gt;N&lt;/em&gt;th person. If you 'send &lt;code&gt;EEPROM.get()&lt;/code&gt; to the wrong address it will still populate the personalProfile instance with data, it will just be gobbledygook. Once you start putting people in the EEPROM you're going to need to keep track of things otherwise you'll end up lost. You need to manage the list to make sure you don't &lt;code&gt;put&lt;/code&gt; one person on top of another (you could get in trouble for that) and you don't want to &lt;code&gt;get&lt;/code&gt; someone that isn't there.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;List management&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is where I leave you, for now. When you have digested the information above, and you want to continue, I'll carry on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your first task is to determine what sort of array you want. Inevitably it's going to be a &lt;a href=&quot;http://en.wikipedia.org/wiki/Linked_list&quot; rel=&quot;nofollow&quot;&gt;Linked List&lt;/a&gt;. This is an array of &lt;code&gt;structs&lt;/code&gt;, where each &lt;code&gt;struct&lt;/code&gt; element in the list &lt;em&gt;contains the memory address of the following element&lt;/em&gt;, thus the list is &lt;strong&gt;linked&lt;/strong&gt;. You need to consider:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How the array will be linked (if at all);&lt;/li&gt;&#xA;&lt;li&gt;Whether or not the array is space-critical (does it have to be as small as possible);&lt;/li&gt;&#xA;&lt;li&gt;Where the array is going to start;&lt;/li&gt;&#xA;&lt;li&gt;How you're going to keep track of how many people are in the array.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;@TL140 I await your response, good luck!&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-03T17:08:52.617" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12350" PostTypeId="1" CreationDate="2015-06-03T19:16:14.820" Score="0" ViewCount="247" Body="&lt;p&gt;Some of the code that I have is unbearably long and drives me insane. I don't know if there were simpler ways to doing what I am doing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long turn1;&#xA;long turn2;&#xA;long turn3;&#xA;long turn4;&#xA;long turn5;&#xA;long turn6;&#xA;long turn7; &#xA;long turn8;&#xA;long turn9;&#xA;long turn10;&#xA;long turn11;&#xA;long turn12;&#xA;long turn13;&#xA;long turn14;&#xA;long turn15;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;#################&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  turn1 = random(sizeof(turns) / sizeof(char*));&#xA;  turn2 = random(sizeof(turns) / sizeof(char*));&#xA;  turn3 = random(sizeof(turns) / sizeof(char*));&#xA;  turn4 = random(sizeof(turns) / sizeof(char*));&#xA;  turn5 = random(sizeof(turns) / sizeof(char*));&#xA;  turn6 = random(sizeof(turns) / sizeof(char*));&#xA;  turn7 = random(sizeof(turns) / sizeof(char*));&#xA;  turn8 = random(sizeof(turns) / sizeof(char*));&#xA;  turn9 = random(sizeof(turns) / sizeof(char*));&#xA;  turn10 = random(sizeof(turns) / sizeof(char*));&#xA;  turn11 = random(sizeof(turns) / sizeof(char*));&#xA;  turn12 = random(sizeof(turns) / sizeof(char*));&#xA;  turn13 = random(sizeof(turns) / sizeof(char*));&#xA;  turn14 = random(sizeof(turns) / sizeof(char*));&#xA;  turn15 = random(sizeof(turns) / sizeof(char*));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;#&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (turn1 == turn2 or turn2 == turn3 or turn3 == turn4 or turn4 == turn5 or turn6 == turn7 or turn7 == turn8 or turn8 == turn9 or turn9 == turn10 or turn10 == turn11 or turn11 == turn12 or turn12 == turn13 or turn13 == turn14 or turn14 == turn15) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;#&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(turns[turn1]);&#xA;lcd.print(turns[turn2]);&#xA;lcd.print(turns[turn3]);&#xA;lcd.print(turns[turn4]);&#xA;lcd.print(turns[turn5]);&#xA;lcd.setCursor(0, 2);&#xA;lcd.print(turns[turn6]);&#xA;lcd.print(turns[turn7]);&#xA;lcd.print(turns[turn8]);&#xA;lcd.print(turns[turn9]);&#xA;lcd.print(turns[turn10]);&#xA;lcd.setCursor(0, 3);&#xA;lcd.print(turns[turn11]);&#xA;lcd.print(turns[turn12]);&#xA;lcd.print(turns[turn13]);&#xA;lcd.print(turns[turn14]);&#xA;lcd.print(turns[turn15]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10442" LastActivityDate="2015-06-04T02:35:18.000" Title="Shortening large chunks of code" Tags="|code-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12354" PostTypeId="2" ParentId="12350" CreationDate="2015-06-03T22:29:23.023" Score="6" Body="&lt;p&gt;Yes you can, and the solution is very simple. It's in two parts, and they make up part of the absolute fundamental building blocks not just in C, but in almost any programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read good information on arrays &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/arrays/&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;, and 'for loops' &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/control/&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; (it's about half way down the page). Without wishing to offend, it seems like you are missing some really basic concepts and I recommend starting at the beginning of the &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;tutorial series&lt;/strong&gt;&lt;/a&gt; that the two aforementioned links are part of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll just cover the basics. If you don't understand anything, refer to the tutorials. If you &lt;em&gt;still&lt;/em&gt; don't understand then please comment, but make sure you can convince us that you've really given it a good go. We're here to help as long as you're here to learn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To declare an array of &lt;em&gt;N&lt;/em&gt; variables, all of which are the same type, you use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;type&amp;gt; &amp;lt;name_of_variable&amp;gt; [&amp;lt;number_of_elements&amp;gt;];&#xA;&#xA;or:&#xA;&#xA;long turns[15];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have an array of 15 &lt;code&gt;long&lt;/code&gt;s. Ta da!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now have to set the values of each turn. As your values are all the same (if you ignore the fact that &lt;code&gt;random()&lt;/code&gt; ultimately leaves you with different values) you can use a &lt;strong&gt;for loop&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int x=0; x&amp;lt;15; x++)&#xA;{&#xA;    turns[x] = random(sizeof(turns) / sizeof(char*));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I won't explain how a for loop works; I gave you a link to the tutorial to save me writing it all out myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That covers shrinking of part 1 and 2. Part 3 requires a little more thought. That said, as you didn't complete your &lt;em&gt;if&lt;/em&gt; statement, I don't actually know what you plan to do if any two adjacent &lt;code&gt;turn&lt;/code&gt; elements are the same. I shall assume that you would 're-randomise' one of the duplicates. For this you can again use a for loop, starting at the beginning and running to &lt;em&gt;N-1&lt;/em&gt; th element, where &lt;em&gt;N&lt;/em&gt; is the total number of elements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int x=0; x&amp;lt;14; x++)&#xA;{&#xA;    if (turns[x] == turns[x+1])&#xA;    {&#xA;        turns[x+1] = random(sizeof(turns) / sizeof(char*));&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need make sure that &lt;code&gt;turns[x+1]&lt;/code&gt; is not outside of the array, which is why the for loop runs for one iteration less than there are elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fourth shrinkable part is just a matter of swtiching multiple print statements into single for loops:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int x=0; x&amp;lt;NUMBER_OF_PRINTS_IN_1st_BUNCH; x++)&#xA;    lcd.print(turns[x]);&#xA;lcd.setcursor(0,2);&#xA;for (int x=WHERE_YOU_LEFT_OFF; x&amp;lt;NUMBER_OF_PRINTS_IN_2nd_BUNCH; x++)&#xA;    lcd.print(turns[x]);&#xA;lcd.setcursor(0,3);&#xA;for (int x=WHERE_YOU_LEFT_OFF_AGAIN; x&amp;lt;NUMBER_OF_REMAINING_PRINTS; x++)&#xA;    lcd.print(turns[x]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All done.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2015-06-04T02:35:18.000" LastActivityDate="2015-06-04T02:35:18.000" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12355" PostTypeId="1" CreationDate="2015-06-04T00:30:08.123" Score="2" ViewCount="351" Body="&lt;p&gt;Here is their code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; PROJECT: ArduDroid &#xA; PROGRAMMER: Hazim Bitar (techbitar at gmail dot com)&#xA; DATE: Oct 31, 2013&#xA; FILE: ardudroid.ino&#xA; LICENSE: Public domain&#xA;*/&#xA;&#xA;#define START_CMD_CHAR '*'&#xA;#define END_CMD_CHAR '#'&#xA;#define DIV_CMD_CHAR '|'&#xA;#define CMD_DIGITALWRITE 10&#xA;#define CMD_ANALOGWRITE 11&#xA;#define CMD_TEXT 12&#xA;#define CMD_READ_ARDUDROID 13&#xA;#define MAX_COMMAND 20  // max command number code. used for error checking.&#xA;#define MIN_COMMAND 10  // minimum command number code. used for error checking. &#xA;#define IN_STRING_LENGHT 40&#xA;#define MAX_ANALOGWRITE 255&#xA;#define PIN_HIGH 3&#xA;#define PIN_LOW 2&#xA;&#xA;String inText;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;ArduDroid 0.12 Alpha by TechBitar (2013)&quot;);&#xA;  Serial.flush();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.flush();&#xA;  int ard_command = 0;&#xA;  int pin_num = 0;&#xA;  int pin_value = 0;&#xA;&#xA;  char get_char = ' ';  //read serial&#xA;&#xA;  // wait for incoming data&#xA;  if (Serial.available() &amp;lt; 1) return; // if serial empty, return to loop().&#xA;&#xA;  // parse incoming command start flag &#xA;  get_char = Serial.read();&#xA;  if (get_char != START_CMD_CHAR) return; // if no command start flag, return to loop().&#xA;&#xA;  // parse incoming command type&#xA;  ard_command = Serial.parseInt(); // read the command&#xA;&#xA;  // parse incoming pin# and value  &#xA;  pin_num = Serial.parseInt(); // read the pin&#xA;  pin_value = Serial.parseInt();  // read the value&#xA;&#xA;  // 1) GET TEXT COMMAND FROM ARDUDROID&#xA;  if (ard_command == CMD_TEXT){   &#xA;    inText =&quot;&quot;; //clears variable for new input   &#xA;    while (Serial.available())  {&#xA;      char c = Serial.read();  //gets one byte from serial buffer&#xA;      delay(5);&#xA;      if (c == END_CMD_CHAR) { // if we the complete string has been read&#xA;        // add your code here&#xA;        break;&#xA;      }              &#xA;      else {&#xA;        if (c !=  DIV_CMD_CHAR) {&#xA;          inText += c; &#xA;          delay(5);&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  // 2) GET digitalWrite DATA FROM ARDUDROID&#xA;  if (ard_command == CMD_DIGITALWRITE){  &#xA;    if (pin_value == PIN_LOW) pin_value = LOW;&#xA;    else if (pin_value == PIN_HIGH) pin_value = HIGH;&#xA;    else return; // error in pin value. return. &#xA;    set_digitalwrite( pin_num,  pin_value);  // Uncomment this function if you wish to use &#xA;    return;  // return from start of loop()&#xA;  }&#xA;&#xA;  // 3) GET analogWrite DATA FROM ARDUDROID&#xA;  if (ard_command == CMD_ANALOGWRITE) {  &#xA;    analogWrite(  pin_num, pin_value ); &#xA;    // add your code here&#xA;    return;  // Done. return to loop();&#xA;  }&#xA;&#xA;  // 4) SEND DATA TO ARDUDROID&#xA;  if (ard_command == CMD_READ_ARDUDROID) { &#xA;    // char send_to_android[] = &quot;Place your text here.&quot; ;&#xA;    // Serial.println(send_to_android);   // Example: Sending text&#xA;    Serial.print(&quot; Analog 0 = &quot;); &#xA;    Serial.println(analogRead(A0));  // Example: Read and send Analog pin value to Arduino&#xA;    return;  // Done. return to loop();&#xA;  }&#xA;}&#xA;&#xA;// 2a) select the requested pin# for DigitalWrite action&#xA;void set_digitalwrite(int pin_num, int pin_value)&#xA;{&#xA;  switch (pin_num) {&#xA;  case 13:&#xA;    pinMode(13, OUTPUT);&#xA;    digitalWrite(13, pin_value);  &#xA;    // add your code here      &#xA;    break;&#xA;  case 12:&#xA;    pinMode(12, OUTPUT);&#xA;    digitalWrite(12, pin_value);   &#xA;    // add your code here       &#xA;    break;&#xA;  case 11:&#xA;    pinMode(11, OUTPUT);&#xA;    digitalWrite(11, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 10:&#xA;    pinMode(10, OUTPUT);&#xA;    digitalWrite(10, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 9:&#xA;    pinMode(9, OUTPUT);&#xA;    digitalWrite(9, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 8:&#xA;    pinMode(8, OUTPUT);&#xA;    digitalWrite(8, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 7:&#xA;    pinMode(7, OUTPUT);&#xA;    digitalWrite(7, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 6:&#xA;    pinMode(6, OUTPUT);&#xA;    digitalWrite(6, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 5:&#xA;    pinMode(5, OUTPUT);&#xA;    digitalWrite(5, pin_value); &#xA;    // add your code here       &#xA;    break;&#xA;  case 4:&#xA;    pinMode(4, OUTPUT);&#xA;    digitalWrite(4, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 3:&#xA;    pinMode(3, OUTPUT);&#xA;    digitalWrite(3, pin_value);         &#xA;    // add your code here &#xA;    break;&#xA;  case 2:&#xA;    pinMode(2, OUTPUT);&#xA;    digitalWrite(2, pin_value); &#xA;    // add your code here       &#xA;    break;      &#xA;    // default: &#xA;    // if nothing else matches, do the default&#xA;    // default is optional&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a photo of my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nCTHZ.jpg&quot; alt=&quot;Photo of Arduino and breadboard&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is anyone able to tell me why when the ardudroid app and bluetooth shield are linked successfully, my LED won't respond to the commands on the app?&lt;/p&gt;&#xA;" OwnerUserId="10446" LastEditorUserId="10794" LastEditDate="2016-01-15T20:26:41.483" LastActivityDate="2016-01-15T20:26:41.483" Title="Bluetooth shield with ardudroid RGB LED" Tags="|c++|led|bluetooth|android|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12356" PostTypeId="1" AcceptedAnswerId="12364" CreationDate="2015-06-04T01:30:07.720" Score="0" ViewCount="800" Body="&lt;p&gt;I have taken a data file using arduino and ov7670 camera module. In this project I used the famous code &lt;a href=&quot;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&lt;/a&gt; . But after taking the datafile ov7670NoRam.hex, I can't open it. I spent 3 hours to search how to open, but failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone please let me know how to have a look the image in .hex? or would it be possible to take image data from ov7670 directly to jpg? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to convert the hex file to bin using hex2bin, but when I opened the bin, only errors occurred. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is the content of the ov7670NoRam.hex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:100000000C9436000C944B000C944B000C944B0059&#xA;:100010000C944B000C944B000C944B000C944B0034&#xA;:100020000C944B000C944B000C944B000C944B0024&#xA;:100030000C944B000C944B000C944B000C944B0014&#xA;:100040000C944B000C944B000C944B000C944B0004&#xA;:100050000C944B000C944B000C944B000C944B00F4&#xA;:100060000C944B000C944B005244590011241FBEB9&#xA;:10007000CFEFD8E0DEBFCDBF12E0A0E0B1E0EAE70D&#xA;:10008000F2E002C005900D92A235B107D9F70E94A7&#xA;:10009000AF000C943B010C9400008093BB0084E8FB&#xA;:1000A0008093BC008091BC0087FFFCCF8091B90099&#xA;:1000B000887F90E070E08617970709F408950E9402&#xA;:1000C000A00084EA8093BC008091BC0087FFFCCF35&#xA;:1000D0008091B900887F883009F408950E94A000BB&#xA;:1000E000CF93DF93D82FC62F0E94610068E182E48E&#xA;:1000F0000E944D0068E28D2F0E944D0068E28C2F17&#xA;:100100000E944D0084E98093BC008FE99FE0019735&#xA;:10011000F1F700C00000DF91CF910895CF93DF93F6&#xA;:10012000EC0103C00E9470002296FE01849131967A&#xA;:1001300064918F3FB9F76F3FA9F7DF91CF91089591&#xA;:10014000259A90E285B1892785B92FEF31EE84E0B9&#xA;:10015000215030408040E1F700C00000F3CFF89418&#xA;:10016000239A8091B6008F798093B60083E48093C0&#xA;:10017000B00089E08093B1001092B30087B1807F16&#xA;:1001800087B98AB183708AB92FEF8BE792E9215042&#xA;:1001900080409040E1F700C000008091B9008C7F62&#xA;:1001A0008093B90088E48093B8001092C50081E084&#xA;:1001B0008093C4008091C00082608093C00088E179&#xA;:1001C0008093C10086E08093C20060E882E10E94D3&#xA;:1001D00070002FEF81EE94E0215080409040E1F7D5&#xA;:1001E00000C0000080E091E00E948E0060E285E1A6&#xA;:1001F0000E94700060E08CE00E9470008AE392E050&#xA;:100200000E948E0088E492E00E948E0069E181E104&#xA;:100210000E947000E8E6F0E094918091C00085FFB4&#xA;:10022000FCCF9093C6008091C00085FFFCCF319633&#xA;:1002300084918111F1CF4B9BFECF4B99FECF40EEC5&#xA;:1002400051E08FE792E04A99FECF36B129B1207F85&#xA;:100250003F70232B2093C6004A9BFECF9C01215068&#xA;:100260003109892B11F0C901EECF415051094115D7&#xA;:0A027000510539F7CFCFF894FFCF06&#xA;:10027A0012803A0412001713180132B619021A7AB8&#xA;:10028A00030A0C003E00703A7135721173F0A20134&#xA;:10029A0015027A207B107C1E7D357E5A7F69807616&#xA;:1002AA0081808288838F849685A386AF87C488D706&#xA;:1002BA0089E813C0000010000D401418A505AB070B&#xA;:1002CA002495253326E39F78A068A103A6D8A7D84A&#xA;:1002DA00A8F0A990AA9413C5300031000E610F4B03&#xA;:1002EA0016021E07210222912907330B350B371DEF&#xA;:1002FA003871392A3C784D404E20690074108D4F70&#xA;:10030A008E008F009000910096009A00B084B10C84&#xA;:10031A00B20EB382B80A430A44F045344658472815&#xA;:10032A00483A59885A885B445C675D495E0E6C0A94&#xA;:10033A006D556E116F9E6A400140026013C74F806F&#xA;:10034A00508051005222535E5480589E41083F000B&#xA;:10035A00750576E14C0077013D484B09C960564066&#xA;:10036A0034113B12A48296009730982099309A84CF&#xA;:10037A009B299C039D4C9E3F78047901C8F0790F14&#xA;:10038A00C8007910C87E790AC880790BC801790C2F&#xA;:10039A00C80F790DC8207909C8807902C8C07903C5&#xA;:1003AA00C8407905C8307926FFFF32F617131801BD&#xA;:1003BA0019021A7A030AFFFF12013D08413D76E14C&#xA;:0203CA00FFFF33&#xA;:00000001FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10070" LastEditorDisplayName="user6430" LastEditDate="2015-06-08T03:02:39.497" LastActivityDate="2015-11-12T17:00:07.560" Title="Cannot open ov7670 output file" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12357" PostTypeId="2" ParentId="12344" CreationDate="2015-06-04T01:48:41.283" Score="1" Body="&lt;p&gt;Basically it looks like you want to figure out if you have a memory leak. Since the objects get allocated continuously you will end up having less and less free memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the functions presented in the sister question answered very nicely by Edgar (more specifically the complex one that calculates all the memory going through the allocation chain). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check the returned value every so often (few seconds/minutes depending on your needs) and if the free memory value drops continuously then you have a memory leak somewhere. This will not tell you where the leak is of course. Also this should work well while debugging the code, but would probably not be a good idea to leave it in &quot;production&quot; code.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-06-04T01:48:41.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12358" PostTypeId="1" AcceptedAnswerId="12363" CreationDate="2015-06-04T02:06:43.273" Score="3" ViewCount="191" Body="&lt;p&gt;I am using Adafruit motor shield, I am running multiple DC motors for different amounts of time, but to start at the same time - I have researched that to do this I have to monitor the elapsed time of each motor in the loop instead of using the delay to avoid blocking if I want them to run at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eventually, There will be around 10 DC motors running off this, however it seems very sloppy to me to have 10 repeat entries of very similar code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to create a class or something for the following code so I am not repeating it all as although it works it seems like the way I am currently doing it is bad practice(?) and could be done more eloquently! Forgive me if this is a strange question as I am new to arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example there are only 2 motors, however when it gets to around 10, there will be a lot of code just for this bit!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions are welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;&#xA;boolean runMotor1 = false;&#xA;boolean Motor1Running = false;&#xA;unsigned long Motor1StartMillis;&#xA;unsigned long Motor1RunTime = 5000;&#xA;&#xA;boolean runMotor2 = false;&#xA;boolean Motor2Running = false;&#xA;unsigned long Motor2StartMillis;&#xA;unsigned long Motor2RunTime = 10000;&#xA;&#xA;//etc etc etc up to 10 Motors&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;Adafruit_DCMotor *MotorMotor1 = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *MotorMotor2 = AFMS.getMotor(2);&#xA;&#xA;void setup() &#xA;{ &#xA;  Serial.begin(9600);      &#xA;  AFMS.begin();&#xA;  runMotor1 = true;  // set condition to true for testing&#xA;  runMotor2 = true;&#xA;} &#xA;void loop()&#xA;{&#xA;/// Motor1 START&#xA;  if (runMotor1 == true) {&#xA;     Serial.println(&quot;Run Motor 1!&quot;);&#xA;     runMotor1 = false;&#xA;    MotorMotor1-&amp;gt;setSpeed(255); &#xA;    MotorMotor1-&amp;gt;run(FORWARD); &#xA;    Motor1StartMillis = millis();&#xA;    Motor1Running = true;&#xA;  }&#xA;&#xA;&#xA;  if( Motor1Running &amp;amp;&amp;amp; (millis()-Motor1StartMillis &amp;gt; Motor1RunTime) )&#xA;  {&#xA;    Serial.println(&quot;Motor1 Time Elapsed!&quot;);&#xA;    MotorMotor1-&amp;gt;setSpeed(0); &#xA;    MotorMotor1-&amp;gt;run(RELEASE);&#xA;    runMotor1 = false;&#xA;    Motor1Running = false;&#xA;  }&#xA;&#xA;  /// Motor 2&#xA;    if (runMotor2 == true) {&#xA;     Serial.println(&quot;Run Motor 2!&quot;);&#xA;     runMotor2 = false;&#xA;    MotorMotor2-&amp;gt;setSpeed(255); &#xA;    MotorMotor2-&amp;gt;run(FORWARD); &#xA;    Motor2StartMillis = millis();&#xA;    Motor2Running = true;&#xA;  }&#xA;&#xA;&#xA;  if( Motor2Running &amp;amp;&amp;amp; (millis()-Motor2StartMillis &amp;gt; Motor2RunTime) )&#xA;  {&#xA;    Serial.println(&quot;Motor2 Time Elapsed!&quot;);&#xA;    MotorMotor2-&amp;gt;setSpeed(0); &#xA;    MotorMotor2-&amp;gt;run(RELEASE);&#xA;    runMotor2 = false;&#xA;    Motor2Running = false;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for reading, and thank you for any input you may have.&#xA;Steve&lt;/p&gt;&#xA;" OwnerUserId="10448" LastEditorUserId="10448" LastEditDate="2015-06-04T02:56:55.447" LastActivityDate="2015-06-04T08:21:11.113" Title="Cleaning up code? Removing repetition?" Tags="|code-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12361" PostTypeId="1" CreationDate="2015-06-04T05:13:36.993" Score="0" ViewCount="397" Body="&lt;p&gt;I'm having trouble powering my boards altogether. Right now, I'm using 8x AA batteries to power everything. Running my arduino with one shield runs fine, but not with both shields stacked on top of my arduino. I've even tried powering it with an extra 4x AA batteries on my motor shield, but it still won't run. The way it's stacked is; arduino uno board, usb host shield then motor shield. &lt;/p&gt;&#xA;" OwnerUserId="10450" LastActivityDate="2022-06-18T02:04:00.437" Title="Power source for Arduino uno, sparkfun usb shield and adafruit motor shield" Tags="|arduino-uno|power|motor|shields|battery|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="12363" PostTypeId="2" ParentId="12358" CreationDate="2015-06-04T08:21:11.113" Score="2" Body="&lt;p&gt;You are perfectly right, a class would help simplify your code. Here is&#xA;a tentative class that should work for what you are doing:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class Motor&#xA;{&#xA;public:&#xA;    Motor(const char *_name, Adafruit_DCMotor *_motor,&#xA;          unsigned long _runTime)&#xA;    : name(_name), startNow(false), running(false),&#xA;      runTime(_runTime), motor(_motor) { }&#xA;    void start() { startNow = true; }&#xA;    void update();&#xA;private:&#xA;    const char *name;&#xA;    boolean startNow;&#xA;    boolean running;&#xA;    unsigned long startTime;&#xA;    unsigned long runTime;&#xA;    Adafruit_DCMotor *motor;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most of this is almost copy-paste from your actual code, except for your&#xA;&lt;code&gt;runMotorX&lt;/code&gt; variables that I renamed &lt;code&gt;startNow&lt;/code&gt;, which seemed more&#xA;appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware that the name of the motor is copied as a pointer. Thus you&#xA;should better call the constructor with a literal string (like&#xA;&lt;code&gt;&quot;the name&quot;&lt;/code&gt;) as a first parameter. Otherwise it would be more&#xA;appropriate to allocate memory and copy the characters themselves, but I&#xA;like to avoid dynamic memory allocation on an Arduino if I can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, all the code that you have in &lt;code&gt;loop()&lt;/code&gt; for each motor would be the&#xA;Motor's &lt;code&gt;update()&lt;/code&gt; method:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void Motor::update()&#xA;{&#xA;    if (startNow) {&#xA;        Serial.print(&quot;Run &quot;);&#xA;        Serial.print(name);&#xA;        Serial.println('!');&#xA;        startNow = false;&#xA;        motor-&amp;gt;setSpeed(255);&#xA;        motor-&amp;gt;run(FORWARD);&#xA;        startTime = millis();&#xA;        running = true;&#xA;    }&#xA;&#xA;    if (running &amp;amp;&amp;amp; (millis()-startTime &amp;gt; runTime))&#xA;    {&#xA;        Serial.print(name);&#xA;        Serial.println(&quot; Time Elapsed!&quot;);&#xA;        motor-&amp;gt;setSpeed(0);&#xA;        motor-&amp;gt;run(RELEASE);&#xA;        running = false;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this class, your code would now look like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;Motor m1(&quot;Motor 1&quot;, AFMS.getMotor(1),  5000);&#xA;Motor m2(&quot;Motor 2&quot;, AFMS.getMotor(2), 10000);&#xA;//etc etc etc up to 10 Motors&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    AFMS.begin();&#xA;    m1.start();&#xA;    m2.start();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    m1.update();&#xA;    m2.update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, when you get to 10 motors, this would still be annoying&#xA;repetition. You can simplify further by putting the motors in an array&#xA;and looping through it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;Motor motors[] = {&#xA;    Motor(&quot;Motor 1&quot;, AFMS.getMotor(1),  5000),&#xA;    Motor(&quot;Motor 2&quot;, AFMS.getMotor(2), 10000)&#xA;    //etc etc etc up to 10 Motors&#xA;};&#xA;#define NUM_MOTORS (sizeof motors / sizeof motors[0])&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    AFMS.begin();&#xA;    for (unsigned int i = 0; i &amp;lt; NUM_MOTORS; i++)&#xA;        motors[i].start();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    for (unsigned int i = 0; i &amp;lt; NUM_MOTORS; i++)&#xA;        motors[i].update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-04T08:21:11.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12364" PostTypeId="2" ParentId="12356" CreationDate="2015-06-04T11:13:09.393" Score="0" Body="&lt;p&gt;What is it you hope to achieve by &quot;opening&quot; the hex file or &quot;converting it to binary&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A hex file is a compiled sketch. It is intended to be installed into the Arduino Uno using avrdude.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-04T11:13:09.393" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12365" PostTypeId="1" CreationDate="2015-06-04T12:05:05.390" Score="1" ViewCount="8498" Body="&lt;p&gt;If i have file cSpeedOfSound.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef cSpeedOfSound_h&#xA;#define cSpeedOfSound_h&#xA;#include &quot;Arduino.h&quot;&#xA;#include &quot;math.h&quot;&#xA;class cSpeedOfSound{&#xA;    public:&#xA;        cSpeedOfSound(float *i,float *C);&#xA;    private:&#xA;        float *C;&#xA;        float *a;&#xA;        float *i;&#xA;    };&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and file cSpeedOfSound.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;cSpeedOfSound.h&quot;&#xA;cSpeedOfSound::cSpeedOfSound(float *i,float *C){&#xA;    //some code...&#xA;    *C =roundto(*C,2);}&#xA;float cSpeedOfSound::roundto(float x,float dp){&#xA;return (round(x*pow(10., dp)) / pow(10., dp));}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where i want to run function roundto inside class, but it doesnt seems to work. So what im making wrong and how to do it properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps: Im begginer to arduino (want it to learn robotics + C language) and know python (learnd for about 1+ year), so pls do not hate me if i made crucial mistakes. &lt;/p&gt;&#xA;" OwnerUserId="10293" LastEditorUserId="7508" LastEditDate="2015-06-04T16:33:29.753" LastActivityDate="2015-06-04T16:33:29.753" Title="Call a class method from inside the same class" Tags="|programming|c++|class|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12366" PostTypeId="2" ParentId="12365" CreationDate="2015-06-04T12:12:46.187" Score="3" Body="&lt;p&gt;You need to include &lt;code&gt;roundto()&lt;/code&gt; in your class declaration, e.g. something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class cSpeedOfSound {&#xA;public:&#xA;    cSpeedOfSound(float *i,float *C);&#xA;&#xA;private:&#xA;    float roundto(float x, float dp);&#xA;&#xA;    float *C;&#xA;    float *a;&#xA;    float *i;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In C++, class structures are fixed. You can define the body of a function almost anywhere, but all member functions/data must be specified in the original declaration.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, it's worth pointing out that you have a naming conflict in your code. You have member variables called &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt;, &lt;strong&gt;and&lt;/strong&gt; you have totally separate function parameters called &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;C&lt;/code&gt;. The compiler won't complain about this (the function parameters will simply mask the member variables), but it may not do what you expect.&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-06-04T12:17:47.293" LastActivityDate="2015-06-04T12:17:47.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12367" PostTypeId="1" CreationDate="2015-06-04T12:34:25.183" Score="2" ViewCount="3909" Body="&lt;p&gt;From &lt;a href=&quot;https://arduino.stackexchange.com/questions/10088/what-is-the-difference-between-serial-write-and-serial-print-and-when-are-they&quot;&gt;here&lt;/a&gt; I think I understand the difference between Serial.write and Serial.print, but is it the same when writing to a file in a SD card for example. Does it mean that File.write saves bytes in the file instead of text?&lt;/p&gt;&#xA;" OwnerUserId="10438" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-09-06T08:54:54.470" Title="What is the difference between file.print() and file.write()" Tags="|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12368" PostTypeId="1" CreationDate="2015-06-04T13:02:38.283" Score="2" ViewCount="396" Body="&lt;p&gt;I have sketch that runs almost exactly as I would want it to. Now I am trying to add sound to it using the Mozzi Library instead of just using the tone function. This way I can avoid having to put a memory card slot and a memory card with the Arduino, considering Mozzi produces some good sound. The problem is that Mozzi takes over the timers and a lot of other things. The analogread and the delaymicroseconds have been replaced by Mozzi functions mozzi analog read and mozziMicros etc. I rewrote my sketch adding mozzi relted stuff, but it stops functioning like it should, but it does compile. SO I am assuming I would need to change the Library to replace original functions with mozzi functions like mozzianalogread. On doing this, several errors about arguments and declaration for these functions pop up. Is editing the other library a necessary step? If yes, then what should be things to look out for to prevent such errors. &lt;/p&gt;&#xA;" OwnerUserId="10118" LastActivityDate="2015-06-04T13:02:38.283" Title="How to effectively modify a library to be able to function with Mozzi Library?" Tags="|arduino-uno|library|audio|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12369" PostTypeId="2" ParentId="12361" CreationDate="2015-06-04T14:10:07.683" Score="-1" Body="&lt;p&gt;Its a very bad idea to power everything from the same battery source. Most motors, especially ESP, generate large current spikes, rather than draw a small current throught. AA batteries are not designed for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get away with using AA batteries for micro-controllers, shields. However, keep motors on a sweater power supply. There are batteries for specific motor types, and these will typically have a high current rating. Of course, without a circuit diagram, I cannot go into details. I'll update my answer when you do.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2015-06-04T14:10:07.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12370" PostTypeId="2" ParentId="12342" CreationDate="2015-06-04T14:15:33.417" Score="0" Body="&lt;p&gt;I would recommend a JSON parsing library. Checkout &lt;a href=&quot;https://github.com/bblanchon/ArduinoJson&quot; rel=&quot;nofollow&quot;&gt;https://github.com/bblanchon/ArduinoJson&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;var response = [] ; // get response here&#xA;int response_length = 4; //Put length of the response array here&#xA;StaticJsonBuffer&amp;lt;200&amp;gt; jsonBuffer;&#xA;&#xA;String action_ids[] = new String[response_length];&#xA;String action_types[] = new String[response_length];&#xA;String action_statuses[] = new String[response_length];&#xA;String ramp_ids[] = new String[response_length];&#xA;String user_ids[] = new String[response_length];&#xA;&#xA;for (int i=0; i &amp;lt; response_length ; i++) {&#xA;    JsonObject&amp;amp; data = jsonBuffer.parseObject(response[i]);&#xA;    // Note the '&amp;amp;' above&#xA;&#xA;    action_ids[i] = data[&quot;action_id&quot;];&#xA;    action_types[i] = data[&quot;action_type&quot;];&#xA;    action_statuses[i] = data[&quot;action_status&quot;];&#xA;    ramp_ids[i] = data[&quot;ramp_id&quot;];&#xA;    user_ids[i] = data[&quot;user_id&quot;];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you only need to extract those fields that you need.&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="297" LastEditDate="2015-06-04T14:37:57.523" LastActivityDate="2015-06-04T14:37:57.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12371" PostTypeId="2" ParentId="12342" CreationDate="2015-06-04T14:22:53.940" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/bblanchon/ArduinoJson&quot; rel=&quot;nofollow&quot;&gt;Try this on for size.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an arduino based, open source, JSON processor.&lt;/p&gt;&#xA;" OwnerUserId="407" LastActivityDate="2015-06-04T14:22:53.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12372" PostTypeId="2" ParentId="9009" CreationDate="2015-06-04T14:51:14.810" Score="0" Body="&lt;p&gt;&lt;strong&gt;GENERAL IDEA:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend getting a simple Wi-Fi and/or Ethernet module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then simply set up routes to &lt;strong&gt;receive&lt;/strong&gt; and &lt;strong&gt;send&lt;/strong&gt; data to Arduino (assuming &lt;code&gt;arduino_ip&lt;/code&gt; to be your Arduino's IP), and &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt; being &lt;a href=&quot;http://www.tutorialspoint.com/http/http_methods.htm&quot; rel=&quot;nofollow&quot;&gt;HTTP verbs&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Receive data from Arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;GET  http://arduino_ip/data&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Send data to Arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;POST http://arduino_ip/data&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now use any Web development Framework/Language (&lt;code&gt;PHP&lt;/code&gt;, &lt;code&gt;Node.js&lt;/code&gt;, &lt;code&gt;Python&lt;/code&gt;) to receive and send data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NO ADDITIONAL MODULES SOLUTION:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above method will allow the arduino and server to communicate if they're on the same network. However, if you can constrain the server to be connected by &lt;code&gt;USB&lt;/code&gt; to Arduino, you can use &lt;code&gt;Node.js&lt;/code&gt;, &lt;code&gt;Python&lt;/code&gt; (even &lt;code&gt;PHP&lt;/code&gt;) to directly communicate to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ANOTHER SOLUTION&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add a &lt;strong&gt;Raspberry Pi&lt;/strong&gt;, have it connected to Arduino by USB (Arduino's &lt;code&gt;Serial&lt;/code&gt;), and the use Raspberry's Ethernet to bring in networking (Raspberry Pi can host a server itself)&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="7389" LastEditDate="2015-10-05T11:15:06.160" LastActivityDate="2015-10-05T11:15:06.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12373" PostTypeId="1" AcceptedAnswerId="12401" CreationDate="2015-06-04T08:44:18.363" Score="2" ViewCount="432" Body="&lt;p&gt;I'm having SRAM overflow problems with my 8bit atmega328p in my Arduino Uno, which has 2KB of SRAM, so I'm defining all my for loops with bytes as counters instead of ints. As in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(byte i=0;i&amp;lt;16;i++) buf[i]=(char)ap1[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would it make any difference if I declared the integer literal 16 as a constant? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte BUFSIZE=16;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or using the preprocessor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUFSIZE 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's also the macro &lt;code&gt;PROGMEM&lt;/code&gt; which stores variables in flash memory, which I've decided to use for all my constants, but is it not the point of const to do this? as well as aiding the compiler in warning you if you screwed up changing the variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte BUFSIZE PROGMEM=16;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFAIK, using const would save BUFSIZE in the flash memory, but how about using the preprocessor? Using the preprocesor would be the exact the same as using the literal 16, as far as i'm concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This fear arose from the fact that string literals are saved in Flash and then transferred to SRAM, wasting twice the space, which you can solve using the arduino macro F(&quot;thisisastring&quot;), which stores them in flash memory, and I don't want to waste 2 bytes of SRAM in every for loop I use&lt;/p&gt;&#xA;" OwnerUserId="32462" OwnerDisplayName="Mike" LastActivityDate="2015-06-05T14:43:49.133" Title="What is the most memory-friendly way to declare integer literals?" Tags="|sram|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12374" PostTypeId="2" ParentId="12373" CreationDate="2015-06-04T08:56:34.370" Score="2" Body="&lt;p&gt;Yes, defining &quot;const byte bufsize&quot; would make a difference - it'll use one additional byte of SRAM. All variables are stored in RAM unless they're annotated as being PROGMEM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A #define gets translated into its value by the preprocessor, and so looks the same to the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your constant '16' isn't taking up any SRAM in the first place; look elsewhere (at actual variables) if you need to optimise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;String literals are treated the same way as arrays of any numeric type: they're copied to SRAM on startup because the code has to be able to dereference the pointer (which is what myarray[x] does) and find the location in RAM. Single numeric constants do not have this issue - they're value types - and so don't get copied into RAM.&lt;/p&gt;&#xA;" OwnerUserId="6302" OwnerDisplayName="Nick Johnson" LastActivityDate="2015-06-04T08:56:34.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12375" PostTypeId="2" ParentId="12373" CreationDate="2015-06-04T13:21:55.727" Score="3" Body="&lt;p&gt;I'm not familiar with the Atmel megaAVR microcontrollers or Arduino.  But generally speaking, your memory optimization ideas are misguided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, it's likely that the compiler implements local loop variables within a register so that they don't consume any RAM at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the integer literal constants, such as 16 from your example, also likely don't consume any RAM.  The compiler likely incorporates these constants into the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever you optimize something it's best to go after the big fish first.  You're focusing on the tiniest fish.  To find the big fish, look at the *.map file produced by the linker.  The map file should show how much RAM and Flash memory is used by your program.  The RAM sections might be labeled &quot;bss&quot; and &quot;data&quot; in the map file.  Hopefully the map file will also detail how much RAM is used by each compilation unit.  Find the compilation units that are using the most RAM and focus on them.  Maybe there are large buffers or arrays defined in those compilation units that can be reduced in size or redesigned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The map file is also where you could check to see if your optimizations have made any difference.  For example, try some of the optimization you described and see whether the map file changes significantly.&lt;/p&gt;&#xA;" OwnerDisplayName="kkrambo" LastActivityDate="2015-06-04T13:21:55.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12376" PostTypeId="2" ParentId="12367" CreationDate="2015-06-04T18:37:37.877" Score="3" Body="&lt;p&gt;The File class inherits from the Stream class, which in turn inherits from the Print class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Serial class inherits from the Stream class, which in turn inherits from the Print class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;write()&lt;/code&gt; are defined by the Print class. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, File.print() and Serial.print() are the same, as are File.write() and Serial.Write().&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-04T18:37:37.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12377" PostTypeId="1" CreationDate="2015-06-04T20:58:38.413" Score="2" ViewCount="739" Body="&lt;p&gt;Bluetooth Relay Project:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Develop a USB to bluetooth adapter for my mechanical keyboard. Using a USB host shield, have an Arduino Pro Mini read keyboard usb commands and repeat them over bluetooth.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have minimal experience with Arduino and circuitry, from my perspective this project seems pretty straight forward plug and play of the hardware components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan to use the following hardware:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Pro Mini 328 - 3.3V/8MHz&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11114&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Products: 11114&lt;/a&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bluetooth HID module&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;BlueSMiRF HID&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/10938&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Product: 10938&lt;/a&gt; ($25)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;USB Host Shield&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB Host Shield for Arduino Pro Mini&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini/&quot; rel=&quot;nofollow&quot;&gt;circuitsathome&lt;/a&gt; ($20)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Power Source &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB Phone power block&lt;/li&gt;&#xA;&lt;li&gt;Output: 5v 1000mA&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Total Cost: $55&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will be connecting the USB module by following the write up &lt;a href=&quot;http://www.kobakant.at/DIY/?p=3310)&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and will be connecting the USBHost shield by following this &lt;a href=&quot;https://www.circuitsathome.com/usb-host-shield-hardware-manual&quot; rel=&quot;nofollow&quot;&gt;guide&lt;/a&gt; and this &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_USBHostShield.html&quot; rel=&quot;nofollow&quot;&gt;guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Does anyone have any comments/suggestions/concerns/words of wisdom before I start to order stuff?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10460" LastEditorUserId="10460" LastEditDate="2015-06-08T15:18:20.223" LastActivityDate="2015-06-08T15:18:20.223" Title="Feedback Request: HID USB to Bluetooth Relay" Tags="|bluetooth|usb|arduino-mini|keyboard|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12378" PostTypeId="1" CreationDate="2015-06-04T20:57:50.793" Score="1" ViewCount="475" Body="&lt;p&gt;I have this simple sketch I use on Arduino Micro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int fan = 3;&#xA;int led = 13;&#xA;int ledState = HIGH;         //all'inizio gira&#xA;//unsigned long time;&#xA;unsigned long prevMicros = 0;        // will store last time LED was updated  +&#xA;unsigned long interval =  7000000;           // lunghezza della pausa in secondi&#xA;unsigned long intervalON =  1000000;           // lunghezza del ON in secondi&#xA;&#xA;void setup() {    &#xA; pinMode(fan, OUTPUT);   &#xA; pinMode(led, OUTPUT);  &#xA; prevMicros = micros();&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long currMicros = micros();&#xA;&#xA;  // manage overflow? BOH&#xA;   if (ledState == HIGH &amp;amp;&amp;amp; (((unsigned long)(currMicros  - prevMicros)) &amp;gt;= intervalON)){&#xA;     prevMicros = currMicros;&#xA;      ledState = LOW;&#xA;    }&#xA;    else if (ledState == LOW &amp;amp;&amp;amp; (((unsigned long)(currMicros - prevMicros)) &amp;gt;= interval)){&#xA;      ledState = HIGH;//riparte&#xA;      prevMicros = currMicros;     &#xA;    }&#xA;&#xA;    digitalWrite(led, ledState);&#xA;    digitalWrite(fan, ledState);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could use &lt;code&gt;millis()&lt;/code&gt; instead of &lt;code&gt;micro()&lt;/code&gt;, but I decided to keep this to shorten the overflow rate (should be 72 minutes). I shall go back to &lt;code&gt;millis()&lt;/code&gt; once my issue is fixed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch works as expected, turning on the LED for a second every 7, but &lt;strong&gt;the sketch hangs after 40 minutes&lt;/strong&gt;. Can you tell me why, and how to manage overflow properly? Why is it hanging after 40 and not 72 minutes? Thanks&lt;/p&gt;&#xA;" OwnerUserId="10463" OwnerDisplayName="Shine" LastEditorUserId="10463" LastEditDate="2015-06-04T21:51:22.870" LastActivityDate="2015-06-05T02:38:02.413" Title="Sketch stops working after ~40 minutes. Overflow?" Tags="|arduino-micro|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12380" PostTypeId="2" ParentId="12378" CreationDate="2015-06-04T21:32:07.253" Score="1" Body="&lt;p&gt;When comparing time intervals, use unsigned long instead of long.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( ... (((unsigned long)(currMicros - prevMicros)) &amp;gt;= intervalON) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The time counter overflows at some point -- micros() overflows after 70 minutes, milis() overflows after nearly a month -- but these are unsigned values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When an unsigned value is interpreted as a signed value -- &lt;code&gt;(long)&lt;/code&gt; instead of &lt;code&gt;(unsigned long)&lt;/code&gt; -- then half of the values are interpreted as negative numbers. So after 40 minutes, the micros() value looks like a negative number, and the (curr-prev) &gt;= interval comparison returns false. After 70 minutes, the micros() overflows back to 0, and the signed comparisons work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to use unsigned long for all delta-time comparisons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is easier to see if you consider a smaller, 3-bit number: there are 8 values for a 3-bit number. If the 3-bit number is unsigned, then the values are 0, 1, 2, 3, 4, 5, 6, 7. But if the 3-bit number is signed, then those same binary code numbers are interpreted as 0, 1, 2, 3, -4, -3, -2, -1. Same principle for int and long values, just a larger range of values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on your comment below, I did some testing on my own hardware (Sparkfun &quot;red board&quot; Arduino UNO R3 clone), and added some code to help make it more testable. Some highlights:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Added a diagnostic LED on Arduino pin 9, to indicate when the timer overflow has happened (i.e. new time is less than previous time).&lt;/li&gt;&#xA;&lt;li&gt;Added a mask to force the timer overflow to happen sooner, so I don't have to wait an hour to verify whether the code had any effect.&lt;/li&gt;&#xA;&lt;li&gt;Calculated timeSinceLastChange and applied mask, to handle overflow.&lt;/li&gt;&#xA;&lt;li&gt;Added TIMER_DATATYPE based on jippie's comment&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The complete code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//--- based on comment from jippie about using C++ standard width integer types&#xA;// #define TIMER_DATATYPE unsigned long&#xA;#define TIMER_DATATYPE uint32_t&#xA;&#xA;//--- MarkU: diagnostic LED to indicate that timer overflow happened.&#xA;// Comment out this line for normal operation.&#xA;#define DIAGNOSTIC_LED_TIME_OVERFLOW 9&#xA;//---&#xA;&#xA;//--- MarkU: diagnostic: force timer overflow to happen sooner.&#xA;// This must be significantly longer than the intervals being measured.&#xA;// Must be a binary all-1's bitmask.&#xA;// 0x3FFFFFF overflow after approximately 1 minute&#xA;// 0xFFFFFFF overflow after approximately 5 minutes&#xA;// 0xFFFFFFFF overflow after approximately 70 minutes&#xA;#define DIAGNOSTIC_TIMER_OVERFLOW_MASK 0x3FFFFFF&#xA;//---&#xA;&#xA;int fan = 3;&#xA;int led = 13;&#xA;int ledState = HIGH;         //all'inizio gira&#xA;//unsigned long time;&#xA;TIMER_DATATYPE prevMicros = 0;        // will store last time LED was updated  +&#xA;TIMER_DATATYPE interval =  7000000;           // lunghezza della pausa in secondi&#xA;TIMER_DATATYPE intervalON =  1000000;           // lunghezza del ON in secondi&#xA;&#xA;void setup() {&#xA;  pinMode(fan, OUTPUT);&#xA;  pinMode(led, OUTPUT);&#xA;&#xA;  //--- MarkU: diagnostic LED indicate that timer overflow happened&#xA;#if DIAGNOSTIC_LED_TIME_OVERFLOW&#xA;  pinMode(DIAGNOSTIC_LED_TIME_OVERFLOW, OUTPUT);&#xA;  digitalWrite(DIAGNOSTIC_LED_TIME_OVERFLOW, LOW);&#xA;#endif // DIAGNOSTIC_LED_TIME_OVERFLOW&#xA;  //---&#xA;&#xA;  prevMicros = micros();&#xA;}&#xA;&#xA;void loop() {&#xA;  TIMER_DATATYPE currMicros = micros();&#xA;&#xA;  //--- MarkU: diagnostic: force timer overflow to happen sooner&#xA;#if DIAGNOSTIC_TIMER_OVERFLOW_MASK&#xA;  currMicros = (TIMER_DATATYPE)(currMicros &amp;amp; ((TIMER_DATATYPE)DIAGNOSTIC_TIMER_OVERFLOW_MASK));&#xA;#endif // DIAGNOSTIC_TIMER_OVERFLOW_MASK&#xA;&#xA;  //--- MarkU: consolidate time delta calculation&#xA;  TIMER_DATATYPE timeSinceLastChange;&#xA;  if (currMicros &amp;lt; prevMicros) {&#xA;    //--- MarkU: handle timer overflow&#xA;#if DIAGNOSTIC_LED_TIME_OVERFLOW&#xA;    digitalWrite(DIAGNOSTIC_LED_TIME_OVERFLOW, HIGH);&#xA;#endif // DIAGNOSTIC_LED_TIME_OVERFLOW&#xA;#if DIAGNOSTIC_TIMER_OVERFLOW_MASK&#xA;    timeSinceLastChange = (currMicros - prevMicros) &amp;amp; DIAGNOSTIC_TIMER_OVERFLOW_MASK;&#xA;#else // DIAGNOSTIC_TIMER_OVERFLOW_MASK&#xA;    timeSinceLastChange = (currMicros - prevMicros) &amp;amp; 0xFFFFFFFF;&#xA;#endif // DIAGNOSTIC_TIMER_OVERFLOW_MASK&#xA;  } else {&#xA;    timeSinceLastChange = currMicros - prevMicros;&#xA;  }&#xA;  //---&#xA;&#xA;  // manage overflow? BOH&#xA;  if (ledState == HIGH &amp;amp;&amp;amp; (timeSinceLastChange &amp;gt;= intervalON)) {&#xA;    prevMicros = currMicros;&#xA;    ledState = LOW;&#xA;  }&#xA;  else if (ledState == LOW &amp;amp;&amp;amp; (timeSinceLastChange &amp;gt;= interval)) {&#xA;    ledState = HIGH;//riparte&#xA;    prevMicros = currMicros;&#xA;  }&#xA;&#xA;  digitalWrite(led, ledState);&#xA;  digitalWrite(fan, ledState);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7174" LastEditorUserId="7174" LastEditDate="2015-06-05T02:38:02.413" LastActivityDate="2015-06-05T02:38:02.413" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12381" PostTypeId="1" CreationDate="2015-06-04T22:19:59.593" Score="1" ViewCount="45" Body="&lt;p&gt;I'm using &lt;code&gt;int&lt;/code&gt; with 14 LEDs to specify pins, but I don't want to use int 14 times, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led1 = 2;&#xA;int led2 = 3;&#xA;int led3 = 4;&#xA;int led4 = 5;&#xA;int led5 = 6;&#xA;int led6 = 7;&#xA;int led7 = 8;&#xA;int led8 = 9;&#xA;int led9 = 10;&#xA;int led10 = 11;&#xA;int led11 = 12;&#xA;int led12 = 13;&#xA;int led13 = 45;&#xA;int led14 = 46;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is there any way to not do this?&#xA;Also, to define them as output, is there any way to avoid using &lt;code&gt;pinMode(***, OUTPUT)&lt;/code&gt; 14 times as well?&lt;/p&gt;&#xA;" OwnerUserId="10442" LastActivityDate="2015-06-04T23:38:07.103" Title="How to int variables with similar names without tons of code?" Tags="|code-optimization|" AnswerCount="1" CommentCount="0" ClosedDate="2015-06-06T22:36:28.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="12382" PostTypeId="1" AcceptedAnswerId="12389" CreationDate="2015-06-04T22:10:01.867" Score="2" ViewCount="11307" Body="&lt;p&gt;First time arduino programmer here...however I have programmed the TI MSP430 in the past...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to figure out how to configure internal Interrupt Vectors on this Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE, I am skeptical about writing lines of code like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_CAPT_vect) {&#xA;    Serial.Print(&quot;Entered Capture Vector&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because it doesn't appear to matter what I type inside ISR(), for instance I can write &#xA;    ISR(GibERisH) {&#xA;    }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it still compiles and uploads to the arduino. What?! Also how could Arduino IDE know what the heck TIMER1_CAPT_vect is without having the library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a list of interrupt vector names here: &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can not find documentation ANYWHERE ELSE on what to call these interrupt vectors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I abandon the Arduino IDE and go with the Atmel Studio 6.2 (There is a juicy looking arduino plug-in...)? I need advanced control of the guts of this processor, and there is zero documentation about how to do this anywhere on the internet.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT: I realized my problem was I was looking for documentation for the atmega16U2 (that does something else on the board), not the atmega328P.&lt;/p&gt;&#xA;" OwnerUserId="10465" OwnerDisplayName="OrangeSherbet" LastEditorUserId="10465" LastEditDate="2015-06-04T23:47:43.497" LastActivityDate="2015-06-28T06:37:33.733" Title="Where is documentation on Arduino's Internal Interrupts?" Tags="|arduino-uno|interrupt|ide|atmel-studio|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12383" PostTypeId="1" CreationDate="2015-06-04T22:55:27.367" Score="1" ViewCount="425" Body="&lt;p&gt;I'm sourcing the parts now for an LED &lt;em&gt;persistence of vision&lt;/em&gt; setup on a bicycle.  Two wheels with anywhere between 16-32 LED's per wheel, as well as 24 LED's mounted on the frame of the bike itself&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the Arduinos have to be mounted into the wheels to drive the POV displays - do I need a total of 3 arduinos?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Driven by 2x [Nano 3.0 Atmel Atmega328P Mini-USB Board][1] + an Arduino Uno from the frame?&#xA;So far I think I'll pick up 2 x [433Mhz RF Transmitter Module + Receiver Module Link Kit][2] for wireless control, [Reed Switch Magnetic Detection Sensor Module][3] for calculating velocity from a small magnet mounted somewhere on one of the forks. 4 x [WS2811 RGB 8-LED Light Strip Module][4] as the POV LED's, or maybe some of the [DotStar Digital LED][5]&#xA;and miscellaneously perhaps are some of these required/ useful? maybe instead of the 4x8 I could go 4x [SSC Seoul P4][6], or from [SparkFun][7],  following pieces of [this guide][8] &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DIY AT89S52 Microcontroller Development Board Set&lt;/li&gt;&#xA;&lt;li&gt;[KT0026 Electronic Parts Pack][9]&lt;/li&gt;&#xA;&lt;li&gt;[Square Prototyping Plate][10]&lt;/li&gt;&#xA;&lt;li&gt;[ZnDiy-BRY Z-069 MB102 Breadboard + Power Supply Module][11] &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My main concern is refresh rates....getting everything controlled...and making sure I have enough I/O. Any help would be greatly appreciated.  (URL's available on request :P)&lt;/p&gt;&#xA;" OwnerUserId="10464" LastActivityDate="2016-01-27T05:24:23.490" Title="Do I need 3 full-size arduinos to control this LED setup?" Tags="|arduino-uno|programming|sensors|led|electronics|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12384" PostTypeId="1" AcceptedAnswerId="12387" CreationDate="2015-06-04T23:32:48.887" Score="0" ViewCount="128" Body="&lt;p&gt;I am trying to program this Arduino Uno's Timer1 module to use its Input Capture pin to record the times of edges and store / transmit them during the Input Capture Interupt Service Routine, but I cannot find documentation on how to program the guts of this Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What IDE do people use to do advanced things with their Arduinos? I am trying to use Atmel Studio 6 after I gave up using the Arduino IDE and now I'm trying to use Visual Micro plug-in for visual studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions?&lt;/p&gt;&#xA;" OwnerUserId="10465" LastEditorUserId="10465" LastEditDate="2015-06-04T23:42:29.833" LastActivityDate="2015-06-04T23:42:29.833" Title="IDE to program Arduino Uno especially internal interrupt vectors" Tags="|arduino-uno|arduino-ide|interrupt|ide|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12385" PostTypeId="2" ParentId="12383" CreationDate="2015-06-04T23:37:45.893" Score="0" Body="&lt;p&gt;Those WS2811 strips are a good idea. You can control them all from pins on the same port which will make the control a little more complex but multiply the refresh rate, or you can chain all of them off a single pin if you find the refresh rate high enough that way.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-04T23:37:45.893" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12386" PostTypeId="2" ParentId="12381" CreationDate="2015-06-04T23:38:07.103" Score="4" Body="&lt;p&gt;The word you are looking for is &lt;em&gt;array&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;em&gt;array&lt;/em&gt; is like a list of values all of the same type.  For instance, your LED pins could be specified as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int leds[14] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 45, 46 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then access the LEDs by number.  Note that arrays &lt;em&gt;start counting from zero&lt;/em&gt; not from one, so you would have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leds[0]&#xA;leds[1]&#xA;leds[2]&#xA;... etc to ...&#xA;leds[12]&#xA;leds[13]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's great for using them in an array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 14; i++) {&#xA;    pinMode(leds[i], OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the values are never going to change, as in this case since they are pin numbers, the array should be declared &lt;em&gt;const&lt;/em&gt; so it doesn't take up any of your precious RAM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int leds[14] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 45, 46 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you should get into the habit of tailoring the data types to the expected values.  If the values are never going to exceed 255 then you should use &quot;byte&quot; not &quot;int&quot;, or better still the C standard &quot;uint8_t&quot;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t leds[14] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 45, 46 };&#xA;&#xA;for (uint8_t i = 0; i &amp;lt; 14; i++) {&#xA;    pinMode(leds[i], OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An &lt;em&gt;int&lt;/em&gt; takes two &lt;em&gt;bytes&lt;/em&gt;, so using &lt;em&gt;int&lt;/em&gt; when you can get away with &lt;em&gt;uint8_t&lt;/em&gt; means you're wasting half the memory.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-04T23:38:07.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12387" PostTypeId="2" ParentId="12384" CreationDate="2015-06-04T23:40:40.253" Score="1" Body="&lt;p&gt;You can do all you need to do in the Arduino IDE.  It doesn't &quot;block&quot; you from doing any low-level operations.  Any other IDE will also allow you to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the information you need to manipulate the &quot;guts&quot; of the Arduino is the datasheet for the main chip - the ATMega328P on the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-04T23:40:40.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12388" PostTypeId="2" ParentId="12383" CreationDate="2015-06-04T23:45:46.530" Score="0" Body="&lt;p&gt;You wouldn't necessarily need full Arduinos - you could prototype them on Arduinos, then move them to just Atmel chips on your own board (e.g. stripboard). To do this, you would need your own resonator, power supply, and programming. Resonators are cheap and easy, you would probably want to set up your own power supply anyway (3 AA batteries is a perfect power supply for the Atmel), and you can program using a USBISP or similar, right from inside the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for speed, I see a bicycle wheel is on the order of 26 inches/660mm diameter. This makes the perimeter about 6 foot 9 inches/2 meters (sounds like a lot, doesn't it?). Google tells me that a sprint on a bike by a fit person is about 40km/h, or 11 meters/second, making 5.5 revs/second of the wheel - about 180 milliseconds/revolution. This means that if you want 1 degree accuracy, you're going to have to change ALL the (changing) leds at about 2khz. The Arduino can run at up to 20mhz, giving you 10,000 instructions to change the leds. Plenty of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have strips, you should check the specs on the strips to see how fast you can change them. Remember that you probably have to update ALL of them, and you want most of the time to be spent between updates; while you are updating, it may show unwanted lights on/off.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="10911" LastEditDate="2015-07-01T01:16:44.973" LastActivityDate="2015-07-01T01:16:44.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12389" PostTypeId="2" ParentId="12382" CreationDate="2015-06-04T23:48:08.157" Score="6" Body="&lt;p&gt;The vector names are all defined within the header files for the main chip in the compiler.  The IDE doesn't need to know anything about that kind of thing - that's all up to the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look for the files &quot;lib/avr/include/avr/io*.h within the compiler in your chosen IDE.  In there are all the chips and all their definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the ATMega328P definition (iom328p.h) has this list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define INT0_vect         _VECTOR(1)   /* External Interrupt Request 0 */&#xA;#define INT1_vect         _VECTOR(2)   /* External Interrupt Request 1 */&#xA;#define PCINT0_vect       _VECTOR(3)   /* Pin Change Interrupt Request 0 */&#xA;#define PCINT1_vect       _VECTOR(4)   /* Pin Change Interrupt Request 0 */&#xA;#define PCINT2_vect       _VECTOR(5)   /* Pin Change Interrupt Request 1 */&#xA;#define WDT_vect          _VECTOR(6)   /* Watchdog Time-out Interrupt */&#xA;#define TIMER2_COMPA_vect _VECTOR(7)   /* Timer/Counter2 Compare Match A */&#xA;#define TIMER2_COMPB_vect _VECTOR(8)   /* Timer/Counter2 Compare Match A */&#xA;#define TIMER2_OVF_vect   _VECTOR(9)   /* Timer/Counter2 Overflow */&#xA;#define TIMER1_CAPT_vect  _VECTOR(10)  /* Timer/Counter1 Capture Event */&#xA;#define TIMER1_COMPA_vect _VECTOR(11)  /* Timer/Counter1 Compare Match A */&#xA;#define TIMER1_COMPB_vect _VECTOR(12)  /* Timer/Counter1 Compare Match B */&#xA;#define TIMER1_OVF_vect   _VECTOR(13)  /* Timer/Counter1 Overflow */&#xA;#define TIMER0_COMPA_vect _VECTOR(14)  /* TimerCounter0 Compare Match A */&#xA;#define TIMER0_COMPB_vect _VECTOR(15)  /* TimerCounter0 Compare Match B */&#xA;#define TIMER0_OVF_vect   _VECTOR(16)  /* Timer/Couner0 Overflow */&#xA;#define SPI_STC_vect      _VECTOR(17)  /* SPI Serial Transfer Complete */&#xA;#define USART_RX_vect     _VECTOR(18)  /* USART Rx Complete */&#xA;#define USART_UDRE_vect   _VECTOR(19)  /* USART, Data Register Empty */&#xA;#define USART_TX_vect     _VECTOR(20)  /* USART Tx Complete */&#xA;#define ADC_vect          _VECTOR(21)  /* ADC Conversion Complete */&#xA;#define EE_READY_vect     _VECTOR(22)  /* EEPROM Ready */&#xA;#define ANALOG_COMP_vect  _VECTOR(23)  /* Analog Comparator */&#xA;#define TWI_vect          _VECTOR(24)  /* Two-wire Serial Interface */&#xA;#define SPM_READY_vect    _VECTOR(25)  /* Store Program Memory Read */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, _ISR() is just a macro.  It creates a suitable function prototype for your function, and if that happens to include a valid vector then it becomes an ISR.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#  define ISR(vector, ...)            \&#xA;    extern &quot;C&quot; void vector (void) __attribute__ ((signal,__INTR_ATTRS)) __VA_ARGS__; \&#xA;    void vector (void)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is defined in &quot;avr/interrupt.h&quot; in the compiler's include files.  With your gibberish you'd end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot; void GibERisH (void) __attribute__ ((signal,__INTR_ATTRS));&#xA;void GibERisH (void) {&#xA;    // something here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With a real vector you'd get the more meaningful:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot; void _VECTOR(7) (void) __attribute__ ((signal,__INTR_ATTRS));&#xA;void _VECTOR(7) (void) {&#xA;    // something here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, _VECTOR() itself is a macro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;lib/avr/include/avr/sfr_defs.h:#define _VECTOR(N) __vector_ ## N&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that further expands out to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot; void __vector_7 (void) __attribute__ ((signal,__INTR_ATTRS));&#xA;void __vector_7 (void) {&#xA;    // something here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And magically, that new function name of &lt;code&gt;__vector_7&lt;/code&gt; is directly referenced from the standard vector handling code in the startup library &lt;em&gt;crt&lt;/em&gt; of the AVR compiler.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-04T23:52:35.270" LastActivityDate="2015-06-04T23:52:35.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12390" PostTypeId="1" CreationDate="2015-06-05T02:07:44.990" Score="1" ViewCount="58" Body="&lt;p&gt;I have four LED's all connected the exact same way to four pins via four 150OHM resistors. (ignore the sensors, they are doing nothing currently) The code is very simple in the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  digitalWrite(blue1, HIGH);&#xA;  digitalWrite(green1, HIGH);&#xA;&#xA;  digitalWrite(blue2, HIGH);&#xA;  digitalWrite(green2, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a photo of the setup, notice how the LED's all light up differently. They are receiving the following voltages from left to right (2.48, 1.72, 3.02, 2.15):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1i1wA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening and how do I get them all to light up the same?&lt;/p&gt;&#xA;" OwnerUserId="7806" LastEditorUserId="7806" LastEditDate="2015-06-05T02:14:30.117" LastActivityDate="2015-06-05T03:54:33.187" Title="Why are LED's receiving different voltages connected to Arduino" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12392" PostTypeId="2" ParentId="12390" CreationDate="2015-06-05T03:54:33.187" Score="3" Body="&lt;p&gt;After trying another Arduino I realized the problem. I did not use &lt;code&gt;pinMode&lt;/code&gt; in the setup for all of the pins. Darn.&lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-06-05T03:54:33.187" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12393" PostTypeId="1" CreationDate="2015-06-05T07:11:42.647" Score="2" ViewCount="569" Body="&lt;p&gt;I am trying to write a float value to the EEPROM on an Arduino MEGA2560. According to some research I should use Arduino EEPROMex library. I added the library to Arduino, but I get the message &quot;EEPROM was not declared in this scope&quot;. How can I solve this problem or have you got any suggestions to do this? &lt;/p&gt;&#xA;" OwnerUserId="10471" LastEditorUserId="10003" LastEditDate="2015-06-06T22:35:22.470" LastActivityDate="2015-06-06T22:35:22.470" Title="Arduino EEPROMex library problem" Tags="|arduino-mega|eeprom|eepromex|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12394" PostTypeId="1" CreationDate="2015-06-05T11:11:18.597" Score="0" ViewCount="5028" Body="&lt;p&gt;&lt;strong&gt;How do I put the sensor value and text on the one line in the serial monitor.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want Pot Value 30 to show in the serial console. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;POT value &quot;)(sensorValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10473" LastEditorUserId="7045" LastEditDate="2015-06-10T14:10:22.523" LastActivityDate="2015-07-10T15:51:18.297" Title="Serial.println Sensor Value and text in one line" Tags="|arduino-uno|serial|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12395" PostTypeId="2" ParentId="12394" CreationDate="2015-06-05T11:17:35.927" Score="1" Body="&lt;p&gt;You just do two Serial prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;POT value &quot;);&#xA;Serial.println(sensorValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.print&lt;/code&gt; prints without moving to a new line, the &lt;code&gt;.println&lt;/code&gt; moves to a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be more fancy and don't mind the processing and memory overhead, you can use &lt;code&gt;snprintf&lt;/code&gt; to format the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp[15];&#xA;snprintf(temp, 15, &quot;POT value %4d&quot;, sensorValue);&#xA;Serial.println(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read more about &lt;code&gt;sprintf&lt;/code&gt; and formatting here: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/snprintf/&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/reference/cstdio/snprintf/&lt;/a&gt; (function parameters)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/printf/&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/reference/cstdio/printf/&lt;/a&gt; (formatting options)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that there is no floating point support in the standard library for the Arduino - so you can't use %f etc.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-05T11:17:35.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12397" PostTypeId="1" AcceptedAnswerId="75551" CreationDate="2015-06-05T12:53:26.623" Score="1" ViewCount="4437" Body="&lt;p&gt;I am currently trying to get the Ethernet Shield working on my Mega. I was trying to run the Webserver example but the program seems to stuck at one point, so I tried to start from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my test code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;byte mac[] = {&#xA;  0x90, 0xA2, 0xDA, 0x0F, 0xF6, 0x3D&#xA;};&#xA;byte subnet[] = { 255,0,0,0 };&#xA;byte gateway[] = { 2,0,0,1 };&#xA;IPAddress ip(2, 0, 0, 1);&#xA;&#xA;EthernetServer server(80);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Ethernet.begin(mac, ip, gateway, subnet);&#xA;  Serial.println(&quot;Ethernet started&quot;);&#xA;  server.begin();&#xA;  Serial.println(&quot;Server started&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  Serial.println(&quot;Loop&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output I get from the serial console is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Etrted&#xA;Ethernet started&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I think the program gets stuck inside the EthernetServer::begin() function.&#xA;I am aware that there are earlier versions of ethernet shields which are not compatible to the mega, but the vendor of my shield says it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I don't understand, why it outputs the first line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your hints!&lt;/p&gt;&#xA;" OwnerUserId="10475" LastActivityDate="2020-05-10T03:46:36.600" Title="Arduino Ethernet Shield 2 stuck on EthernetServer::begin()" Tags="|arduino-mega|ethernet|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12398" PostTypeId="1" CreationDate="2015-06-05T13:31:07.860" Score="2" ViewCount="1351" Body="&lt;p&gt;Can any one tell me how to connect Adafruit motor shield v 1.0 with Arduino Pro Mini 5v 8 Mhz. Motor shield uses which pins as I want to replace my Arduino UNO to Pro Mini and need re-wiring. Tried it using jumper cables but did not work. Please help...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Product page &lt;a href=&quot;https://www.adafruit.com/products/81&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;Manual &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-motor-shield.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;Larger version of schematic &lt;a href=&quot;https://learn.adafruit.com/system/assets/assets/000/009/769/original/mshieldv1-schem.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sKLLl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="7235" LastEditorUserId="6959" LastEditDate="2015-06-05T15:03:47.053" LastActivityDate="2015-06-05T15:03:47.053" Title="Adafruit motor shield 1 and Arduino Pro Mini" Tags="|motor|arduino-pro-mini|adafruit|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12399" PostTypeId="1" AcceptedAnswerId="12400" CreationDate="2015-06-05T13:59:26.017" Score="0" ViewCount="1100" Body="&lt;p&gt;i am thinking about building a Quadcopter that can be controlled with a computer via Wifi . but the problem is that with a lack of components and limited resources , i have been thinking of using my available components ( Arduino uno + smart phone + quadcopter frame with 4 brush-less motors and 4 speed control ) &#xA;so i am asking you guys if it is possible to read smartphone sensor values using Arduino usb and control the quadcopter using smartphone wifi ?? &lt;/p&gt;&#xA;" OwnerUserId="10478" LastActivityDate="2015-06-05T14:31:06.163" Title="control Arduino board using Android sensors and wifi?" Tags="|sensors|wifi|android|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12400" PostTypeId="2" ParentId="12399" CreationDate="2015-06-05T14:31:06.163" Score="0" Body="&lt;p&gt;Is it possible?  Yes, it's certainly possible.  You can read the sensor values from within an Android program. It's possible to get Android to communicate with the Arduino through the USB.  The Arduino can be programmed to respond to what it gets through the serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it easy? Well, that depends on how good you are at Android programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One good place to start might be the &lt;a href=&quot;http://shokai.github.io/ArduinoFirmata-Android/&quot; rel=&quot;nofollow&quot;&gt;ArduinoFirmata-Android&lt;/a&gt; project.  Don't worry about programming the Arduino, just install Firmata on it.  Then it's all down to how you program the Android device.  The Arduino just becomes a peripheral to your phone.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-05T14:31:06.163" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12401" PostTypeId="2" ParentId="12373" CreationDate="2015-06-05T14:43:49.133" Score="2" Body="&lt;p&gt;Well, it's easy to just try and see... Let's try the following program:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#ifdef USE_CONST&#xA;const byte BUFSIZE = 16;&#xA;#else&#xA;#  define BUFSIZE 16&#xA;#endif&#xA;&#xA;char buf[BUFSIZE], ap1[BUFSIZE];&#xA;&#xA;int main(void)&#xA;{&#xA;    for (byte i = 0; i &amp;lt; BUFSIZE; i++)&#xA;        buf[i] = ap1[i];    &#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I compiled this for an Uno both with and without &lt;code&gt;#define USE_CONST&lt;/code&gt;,&#xA;and it doesn't make any difference! avr-size reports the same sizes for&#xA;both versions, and the generated assemblies are identical: the optimizer&#xA;transformed the loop into something like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;byte *Z = ap1;&#xA;byte *X = buf;&#xA;do {&#xA;    *X++ = *Z++;&#xA;} while (Z != ap1 + 16);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where X and Z are two of the CPU's pointer registers, and &lt;code&gt;ap1 + 16&lt;/code&gt; is&#xA;an &lt;em&gt;immediate&lt;/em&gt; constant, i.e. part of the instruction itself, c.f. the&#xA;&lt;a href=&quot;http://www.csee.umbc.edu/~alnel1/cmpe311/notes/AVRAddressingModes.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR addressing modes&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is worth noting that, in C++,&#xA;&lt;a href=&quot;https://stackoverflow.com/a/998457&quot;&gt;&lt;code&gt;const&lt;/code&gt; implies internal linkage&lt;/a&gt;.&#xA;Thus a const global variable is very much like a preprocessor constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is unlike C, where you would need to qualify the variable as&#xA;&lt;code&gt;static const&lt;/code&gt; in order to get the same behavior. Otherwise the compiler&#xA;would need to allocate storage to &lt;code&gt;BUFSIZE&lt;/code&gt;, just in case it is&#xA;referenced as &lt;code&gt;extern&lt;/code&gt; from another source file, even though it can&#xA;replace occurrences of &lt;code&gt;BUFSIZE&lt;/code&gt; &lt;em&gt;in the same file&lt;/em&gt; with its immediate&#xA;value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, the Arduino IDE compiles your code with&#xA;&lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-funswitch-loops-1114&quot; rel=&quot;nofollow noreferrer&quot;&gt;-ffunction-sections -fdata-sections&lt;/a&gt;&#xA;and links it with&#xA;&lt;a href=&quot;https://sourceware.org/binutils/docs/ld/Options.html#index-garbage-collection-179&quot; rel=&quot;nofollow noreferrer&quot;&gt;--gc-sections&lt;/a&gt;,&#xA;which means the linker will eventually get rid of the unused reserved&#xA;storage.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-06-05T14:43:49.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12402" PostTypeId="1" CreationDate="2015-06-05T16:27:08.057" Score="2" ViewCount="6421" Body="&lt;p&gt;I know that it is possible to write data in &lt;a href=&quot;https://en.wikipedia.org/wiki/Read-only_memory&quot; rel=&quot;nofollow&quot;&gt;ROM&lt;/a&gt;(Read Only Memory).&lt;br&gt;&#xA;But what about if I want to write data in &lt;a href=&quot;https://en.wikipedia.org/wiki/Random-access_memory&quot; rel=&quot;nofollow&quot;&gt;RAM&lt;/a&gt;(Random Access Memory)?&lt;br&gt;&#xA;Can I do it using &quot;Arduino Uno R3&quot;?&lt;br&gt;&#xA;RAM is normally associated with &lt;a href=&quot;https://en.wikipedia.org/wiki/Volatile_memory&quot; rel=&quot;nofollow&quot;&gt;volatile&lt;/a&gt; types of memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several examples about writing data in &lt;a href=&quot;https://en.wikipedia.org/wiki/EEPROM&quot; rel=&quot;nofollow&quot;&gt;EEPROM&lt;/a&gt; as in a (Read Only Memory) which may have 8 pins.&lt;br&gt;&#xA;In order to store values read from analog input 0 into the EEPROM we need to use the &quot;EEPROM.write()&quot; function.&lt;br&gt;&#xA;These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.&lt;br&gt;&#xA;ROM is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Non-volatile_memory&quot; rel=&quot;nofollow&quot;&gt;Non-volatile&lt;/a&gt; type memory.&lt;br&gt;&#xA;SD card is also Non-volatile type of memory.&lt;br&gt;&#xA;We know that there are few SD card shields for &quot;Arduino Uno&quot; and it is possible create your own shields.       &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what about volatile types of memory?&lt;br&gt;&#xA;what about if I want to write data in RAM like a &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/DDR_SDRAM&quot; rel=&quot;nofollow&quot;&gt;DDR SDRAM&lt;/a&gt;&quot; or in a DDR3 memory which may have 240 pins instead of 8 pins?&lt;br&gt;&#xA;So my question is is it possible to write data in &quot;DDR SDRAM&quot; using &quot;Arduiono Uno R3&quot;?&lt;br&gt;&#xA;How? Where should I connect those 240 pins?           &lt;/p&gt;&#xA;" OwnerUserId="7908" LastEditorUserId="7908" LastEditDate="2015-06-06T09:29:42.567" LastActivityDate="2016-04-11T10:46:45.273" Title="How to write data in RAM memory using Arduino Uno or Arduino Due?" Tags="|arduino-uno|shields|memory-usage|eeprom|sram|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12403" PostTypeId="2" ParentId="12402" CreationDate="2015-06-05T16:51:58.450" Score="3" Body="&lt;p&gt;DRAM of any kind requires a memory controller which is not present in any AVR device. Larger AVR devices such as the &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA64A.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega64A&lt;/a&gt; and &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA128A.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega128A&lt;/a&gt; do have an external memory bus that can be used for SRAM and MMIO.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-05T16:51:58.450" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12404" PostTypeId="1" CreationDate="2015-06-05T17:13:41.180" Score="1" ViewCount="1206" Body="&lt;p&gt;I am struggling with the code that I should write for my project. I finished my breadboard but I have never learnt programming before so I cannot write the program for the dice.&#xA;My project is to make the dice output random numbers when the button is pressed.&#xA;This is what I have completed already. I just want to know how to complete the program to make it work for my arduino.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/iHR4T.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int leda = 2;&#xA;int ledb = 3;&#xA;int ledc = 4;&#xA;int ledd = 5;&#xA;int lede = 6;&#xA;int ledf = 7;&#xA;int ledg = 8;&#xA;int ledh = 9;&#xA;int leda1 = A0;&#xA;int ledb1 = A1;&#xA;int ledc1 = A2;&#xA;int ledd1 = A3;&#xA;int lede1 = A4;&#xA;int ledf1 = A5;&#xA;int ledg1 = A6;&#xA;int ledh1 = A7;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(leda, OUTPUT);&#xA;    pinMode(ledb, OUTPUT);&#xA;    pinMode(ledc, OUTPUT);&#xA;    pinMode(ledd, OUTPUT);&#xA;    pinMode(lede, OUTPUT);&#xA;    pinMode(ledf, OUTPUT);&#xA;    pinMode(ledg, OUTPUT);&#xA;    pinMode(ledh, OUTPUT);&#xA;    pinMode(leda1, OUTPUT);&#xA;    pinMode(ledb1, OUTPUT);&#xA;    pinMode(ledc1, OUTPUT);&#xA;    pinMode(ledd1, OUTPUT);&#xA;    pinMode(lede1, OUTPUT);&#xA;    pinMode(ledf1, OUTPUT);&#xA;    pinMode(ledg1, OUTPUT);&#xA;    pinMode(ledh1, OUTPUT);&#xA;&#xA;    pinMode(12, INPUT);&#xA;&#xA;    digitalWrite(12, HIGH);&#xA;}&#xA;&#xA;if (number == 1)&#xA;{&#xA;    digitalWrite(2, HIGH);&#xA;    digitalWrite(7, HIGH);&#xA;}&#xA;&#xA;else if (number == 2)&#xA;{&#xA;    digitalWrite(3, HIGH);&#xA;    digitalWrite(2, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    digitalWrite(9, HIGH);&#xA;    digitalWrite(8, HIGH);&#xA;    delay(200);&#xA;}&#xA;else if (number == 3)&#xA;{&#xA;    digitalWrite(3,HIGH);&#xA;    digitalWrite(2,HIGH);&#xA;    digitalWrite(5,HIGH);&#xA;    digitalWrite(7,HIGH);&#xA;    digitalWrite(8,HIGH);&#xA;    delay(200);&#xA;}&#xA;&#xA;else if (number == 4)&#xA;{&#xA;    // do number 4&#xA;}&#xA;&#xA;else if (number == 5)&#xA;{&#xA;    // do number 5&#xA;}&#xA;&#xA;// ... etc&#xA;// Additional 'numbers' have been removed for brevity&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10481" LastEditorUserId="10003" LastEditDate="2015-06-05T19:00:39.223" LastActivityDate="2015-06-05T20:31:27.403" Title="Aduino 7 segment dice project" Tags="|programming|led|atmega328|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12405" PostTypeId="2" ParentId="3324" CreationDate="2015-06-05T17:39:56.967" Score="0" Body="&lt;p&gt;If you still have problems, like me after following the above, this might help:&#xA;From this thread: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=292284.msg2229300#msg2229300&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=292284.msg2229300#msg2229300&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the problem is in the spaces of the device name. To fix that you have to manually edit two (2) txt files of the arduino installation.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Go where you have installed it. In my case the path is:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;/Users/MY_USERNAME/Downloads/Arduino.app/Contents/Java/hardware/arduino/avr&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Inside this directory you can see files platform.txt &amp;amp;&#xA;  programmers.txt.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Inside these files replace -P{serial.port} with &quot;-P{serial.port}&quot;. So&#xA;  you simply have to add the quotes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then restart.&lt;/p&gt;&#xA;" OwnerUserId="10422" LastActivityDate="2015-06-05T17:39:56.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12406" PostTypeId="1" AcceptedAnswerId="12408" CreationDate="2015-06-05T17:53:47.427" Score="0" ViewCount="61" Body="&lt;p&gt;When I connect the Arduino to my PC the Led &quot;ON&quot; lights for a second then turns OFF. I wonder if the Arduino has a fault?&lt;/p&gt;&#xA;" OwnerUserId="10420" LastEditorUserId="4143" LastEditDate="2015-06-05T19:03:09.603" LastActivityDate="2015-06-05T19:03:09.603" Title="What's wrong with my Arduino board?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12408" PostTypeId="2" ParentId="12406" CreationDate="2015-06-05T18:47:35.050" Score="0" Body="&lt;p&gt;Most likely a short between VCC (5 volt) and GROUND. When there is a short the fuse will kick in after a second, and disable the whole board, including the ON-led.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you disconnect the board, the fuse will reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So either the board is faulty of the connection you made to it are.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-05T18:47:35.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12409" PostTypeId="2" ParentId="12404" CreationDate="2015-06-05T19:05:38.057" Score="1" Body="&lt;p&gt;I made it so at least it compiles. It should loop through the numbers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the circuit; you really should add a resistor to every segment, instead of just one the the common cathode. Otherwise the brightness will be different if more segments are on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int number = 1;&#xA;int number1 = 1;&#xA;&#xA;int leda = 2;&#xA;int ledb = 3;&#xA;int ledc = 4;&#xA;int ledd = 5;&#xA;int lede = 6;&#xA;int ledf = 7;&#xA;int ledg = 8;&#xA;int ledh = 9;&#xA;&#xA;int leda1 = A0;&#xA;int ledb1 = A1;&#xA;int ledc1 = A2;&#xA;int ledd1 = A3;&#xA;int lede1 = A4;&#xA;int ledf1 = A5;&#xA;int ledg1 = A6;&#xA;int ledh1 = A7;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;    pinMode(leda, OUTPUT);&#xA;    pinMode(ledb, OUTPUT);&#xA;    pinMode(ledc, OUTPUT);&#xA;    pinMode(ledd, OUTPUT);&#xA;    pinMode(lede, OUTPUT);&#xA;    pinMode(ledf, OUTPUT);&#xA;    pinMode(ledg, OUTPUT);&#xA;    pinMode(ledh, OUTPUT);&#xA;&#xA;    pinMode(leda1, OUTPUT);&#xA;    pinMode(ledb1, OUTPUT);&#xA;    pinMode(ledc1, OUTPUT);&#xA;    pinMode(ledd1, OUTPUT);&#xA;    pinMode(lede1, OUTPUT);&#xA;    pinMode(ledf1, OUTPUT);&#xA;    pinMode(ledg1, OUTPUT);&#xA;    pinMode(ledh1, OUTPUT);&#xA;&#xA;    pinMode(12, INPUT);&#xA;    digitalWrite(12, HIGH);&#xA;}&#xA;void loop() {&#xA;&#xA;    // turn off all leds&#xA;    digitalWrite(leda, LOW);&#xA;    digitalWrite(ledb, LOW);&#xA;    digitalWrite(ledc, LOW);&#xA;    digitalWrite(ledd, LOW);&#xA;    digitalWrite(lede, LOW);&#xA;    digitalWrite(ledf, LOW);&#xA;    digitalWrite(ledg, LOW);&#xA;    digitalWrite(ledh, LOW);&#xA;&#xA;    digitalWrite(leda1, LOW);&#xA;    digitalWrite(ledb1, LOW);&#xA;    digitalWrite(ledc1, LOW);&#xA;    digitalWrite(ledd1, LOW);&#xA;    digitalWrite(lede1, LOW);&#xA;    digitalWrite(ledf1, LOW);&#xA;    digitalWrite(ledg1, LOW);&#xA;    digitalWrite(ledh1, LOW);&#xA;&#xA;&#xA;    if (number == 1)&#xA;    {&#xA;        digitalWrite(leda, HIGH);&#xA;        digitalWrite(ledf, HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number == 2)&#xA;    {&#xA;        digitalWrite(ledb, HIGH);&#xA;        digitalWrite(leda, HIGH);&#xA;        digitalWrite(ledd, HIGH);&#xA;        digitalWrite(ledh, HIGH);&#xA;        digitalWrite(ledg, HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number == 3)&#xA;    {&#xA;        digitalWrite(ledb,HIGH);&#xA;        digitalWrite(leda,HIGH);&#xA;        digitalWrite(ledd,HIGH);&#xA;        digitalWrite(ledf,HIGH);&#xA;        digitalWrite(ledg,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number == 4)&#xA;    {&#xA;        digitalWrite(ledc,HIGH);&#xA;        digitalWrite(ledd,HIGH);&#xA;        digitalWrite(leda,HIGH);&#xA;        digitalWrite(ledf,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number == 5)&#xA;    {&#xA;        digitalWrite(ledb,HIGH);&#xA;        digitalWrite(ledc,HIGH);&#xA;        digitalWrite(ledd,HIGH);&#xA;        digitalWrite(ledf,HIGH);&#xA;        digitalWrite(ledg,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number == 6)&#xA;    {&#xA;        digitalWrite(ledb,HIGH);&#xA;        digitalWrite(ledc,HIGH);&#xA;        digitalWrite(ledd,HIGH);&#xA;        digitalWrite(ledf,HIGH);&#xA;        digitalWrite(ledg,HIGH);&#xA;        digitalWrite(ledh,HIGH);&#xA;        delay(200);&#xA;    }&#xA;&#xA;    if (number1 == 1)&#xA;    {&#xA;        digitalWrite(A4, HIGH);&#xA;        digitalWrite(A1, HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number1 == 2)&#xA;    {&#xA;        digitalWrite(A5, HIGH);&#xA;        digitalWrite(A4, HIGH);&#xA;        digitalWrite(A7, HIGH);&#xA;        digitalWrite(A0, HIGH);&#xA;        digitalWrite(A2, HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number1 == 3)&#xA;    {&#xA;        digitalWrite(A5,HIGH);&#xA;        digitalWrite(A4,HIGH);&#xA;        digitalWrite(A7,HIGH);&#xA;        digitalWrite(A1,HIGH);&#xA;        digitalWrite(A2,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number1 == 4)&#xA;    {&#xA;        digitalWrite(A6,HIGH);&#xA;        digitalWrite(A7,HIGH);&#xA;        digitalWrite(A4,HIGH);&#xA;        digitalWrite(A2,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number1 == 5)&#xA;    {&#xA;        digitalWrite(A5,HIGH);&#xA;        digitalWrite(A6,HIGH);&#xA;        digitalWrite(A7,HIGH);&#xA;        digitalWrite(A1,HIGH);&#xA;        digitalWrite(A2,HIGH);&#xA;        delay(200);&#xA;    }&#xA;    else if (number1 == 6)&#xA;    {&#xA;        digitalWrite(A5,HIGH);&#xA;        digitalWrite(A6,HIGH);&#xA;        digitalWrite(A7,HIGH);&#xA;        digitalWrite(A0,HIGH);&#xA;        digitalWrite(A1,HIGH);&#xA;        digitalWrite(A2,HIGH);&#xA;        delay(200);&#xA;    }&#xA;&#xA;    number = (number%6) + 1;//show next number the next loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-05T19:05:38.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12410" PostTypeId="2" ParentId="12404" CreationDate="2015-06-05T19:32:48.890" Score="2" Body="&lt;h2&gt;About random numbers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;What you are trying to achieve is actually not that easy. An Arduino is&#xA;basically a computer, and as any computer, it is designed to execute&#xA;instructions in a very &lt;em&gt;deterministic&lt;/em&gt; fashion. Computers are not good&#xA;at randomness and, unless fitted with dedicated hardware, they &lt;em&gt;cannot&lt;/em&gt;&#xA;generate random numbers. Given this, you are left with two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Pseudorandom_number_generator&quot; rel=&quot;nofollow&quot;&gt;pseudo-random number generators&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Entropy_%28computing%29&quot; rel=&quot;nofollow&quot;&gt;entropy&lt;/a&gt; gathering&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first is the easiest:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int first_dice  = random(1, 7);  // 1 (inclusive) to 7 (exclusive)&#xA;int second_dice = random(1, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and voilà! You have two random-looking numbers. They are random-looking&#xA;in the sense that you will find no obvious pattern in any sequence of&#xA;numbers you draw. However, if you reset your Arduino, either with the&#xA;reset button or by power-cycling it, it will give you the &lt;em&gt;exact same&#xA;sequence&lt;/em&gt; as in the first run. Thus, pseudo-randomness in useless unless&#xA;you commit to never unpower your circuit. It is a good starting point,&#xA;however, if your main goal is to get started with Arduino programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Entropy gathering means getting some randomness from outside the&#xA;Arduino: you would connect it to some source of randomness and perform&#xA;some measurement that has unpredictable outcome. A human being is a good&#xA;source of randomness: if you require the user to press a button before&#xA;displaying the dice value, the timing of the button press is a good&#xA;random source. The &lt;code&gt;micros()&lt;/code&gt; function can be used to get the current&#xA;time with 4&amp;nbsp;µs resolution, which is more than enough for this&#xA;purpose. Entropy gathering is usually used in tandem with pseudo-random&#xA;number generators, as a way to &lt;em&gt;seed&lt;/em&gt; them, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;wait_for_the_user_to_press_a_button();&#xA;randomSeed(micros());&#xA;int first_dice =  random(1, 7);&#xA;int second_dice = random(1, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you cannot have human interaction, you could try to get some&#xA;electromagnetic noise by performing an &lt;code&gt;analogRead()&lt;/code&gt; on a floating pin.&#xA;Ideally you would connect that pin to an analog noise source. See the&#xA;first comment to this answer for more information on this option.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;About arrays and loops&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You should definitely try to find a good tutorial about arrays and&#xA;loops. Whenever you find yourself writing tons of almost-identical lines&#xA;of code, you should wonder whether you can replace that repetition with&#xA;a loop. For example, for displaying the digit &lt;code&gt;1&lt;/code&gt;, you may write:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (number == 1) {&#xA;    digitalWrite(leda,  LOW);&#xA;    digitalWrite(ledb, HIGH);&#xA;    digitalWrite(ledc, HIGH);&#xA;    digitalWrite(ledd,  LOW);&#xA;    digitalWrite(lede,  LOW);&#xA;    digitalWrite(ledf,  LOW);&#xA;    digitalWrite(ledg,  LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I am using the &quot;canonical&quot; A–G letter assignments, and yes, you should&#xA;also take care of setting to &lt;code&gt;LOW&lt;/code&gt; the segments you want to be off).&#xA;This code is an obvious candidate for being replaced by a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (number == 1) {&#xA;    for (int segment = 0; segment &amp;lt; 7; segment++)&#xA;        digitalWrite(leds[segment], digit1[segment]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This requires that you first define the following arrays:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;//                A     B     C     D     E     F     G&#xA;int leds[]   = {  2,    3,    4,    5,    6,    7,    8 };&#xA;int digit1[] = { LOW, HIGH, HIGH,  LOW,  LOW,  LOW,  LOW};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This logic can be pushed one level further by using a two-dimensional&#xA;array (an array of arrays): instead of defining six arrays &lt;code&gt;digit1&lt;/code&gt;,&#xA;&lt;code&gt;digit2&lt;/code&gt;... &lt;code&gt;digit6&lt;/code&gt;, you create an array of arrays like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int digits[][7] = {&#xA;         /*          A     B     C     D     E     F     G  */&#xA;         /* 1 */  { LOW, HIGH, HIGH,  LOW,  LOW,  LOW,  LOW},&#xA;         /* 2 */  {HIGH, HIGH,  LOW, HIGH, HIGH,  LOW, HIGH},&#xA;         ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and you use &lt;code&gt;digits[number]&lt;/code&gt; instead of &lt;code&gt;digit1&lt;/code&gt;, etc. This way you get&#xA;rid of the whole &lt;code&gt;if () ... else if ()&lt;/code&gt; chain, replaced by:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;for (int segment = 0; segment &amp;lt; 7; segment++)&#xA;    digitalWrite(leds[segment], digits[number-1][segment]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Take care though that in C++ arrays are indexed from zero, which is why&#xA;you need to use &lt;code&gt;number-1&lt;/code&gt; as the index in &lt;code&gt;digits&lt;/code&gt;. If you have more&#xA;than one die (which is your case), you can also put their pin&#xA;assignments in a two-dimensional array. Then all the dice updating code&#xA;would be wrapped inside a loop indexed by the die number. Putting all&#xA;this together you end up with something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// Pin assignments.&#xA;int leds[][7] = {&#xA;   /*                A     B     C     D     E     F     G  */&#xA;   /* 1st die */  {  2,    3,    4,    5,    6,    7,    8 },&#xA;   /* 2nd die */  { A0,   A1,   A2,   A3,   A4,   A5,   A6 }&#xA;};&#xA;&#xA;// 7-segment &quot;font&quot;.&#xA;int digits[][7] = {&#xA;         /*          A     B     C     D     E     F     G  */&#xA;         /* 1 */  { LOW, HIGH, HIGH,  LOW,  LOW,  LOW,  LOW},&#xA;         /* 2 */  {HIGH, HIGH,  LOW, HIGH, HIGH,  LOW, HIGH},&#xA;         /* 3 */  {HIGH, HIGH, HIGH, HIGH,  LOW,  LOW, HIGH},&#xA;         /* 4 */  { LOW, HIGH, HIGH,  LOW,  LOW, HIGH, HIGH},&#xA;         /* 5 */  {HIGH,  LOW, HIGH, HIGH,  LOW, HIGH, HIGH},&#xA;         /* 6 */  {HIGH,  LOW, HIGH, HIGH, HIGH, HIGH, HIGH}&#xA;};&#xA;&#xA;void setup()&#xA;{&#xA;    for (int die = 0; die &amp;lt; 2; die++) {&#xA;        for (int segment = 0; segment &amp;lt; 7; segment++) {&#xA;            pinMode(leds[die][segment], OUTPUT);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;    for (int die = 0; die &amp;lt; 2; die++) {&#xA;        int number = random(1, 7);&#xA;        for (int segment = 0; segment &amp;lt; 7; segment++)&#xA;            digitalWrite(leds[die][segment], digits[number][segment]);&#xA;    }&#xA;    delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is still lacking the entropy gathering phase discussed above.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-05T20:31:27.403" LastActivityDate="2015-06-05T20:31:27.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12411" PostTypeId="1" CreationDate="2015-06-05T20:21:02.590" Score="0" ViewCount="6019" Body="&lt;p&gt;I am trying to get Arduino working with &lt;a href=&quot;http://dunkels.com/adam/pt/&quot; rel=&quot;nofollow&quot;&gt;Protothreads&lt;/a&gt; and wanted to confirm I have the basic setup correct. If I have understood the API correctly, then the following code should be what I need to start 2 concurrent threads from inside an Arduino program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;pt.h&amp;gt;&#xA;&#xA;static struct pt t1, t2;&#xA;&#xA;void setup() {&#xA;    PT_INIT(&amp;amp;t1);&#xA;    PT_INIT(&amp;amp;t2);&#xA;}&#xA;&#xA;void loop() {&#xA;    doSomething(&amp;amp;t1, 500);&#xA;    doSomethingElse(&amp;amp;t2, 500);&#xA;}&#xA;&#xA;static int doSomething(struct pt *pt, int interval) {&#xA;    PT_BEGIN(pt);&#xA;    sleep(100);&#xA;    PT_END(pt);&#xA;}&#xA;&#xA;static int doSomethingElse(struct pt *pt, int interval) {&#xA;    PT_BEGIN(pt);&#xA;    sleep(250);&#xA;    PT_END(pt);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone see anything that jumps out at them as missing or wrong?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2018-10-06T18:43:39.507" Title="Arduino Protothreads by Example" Tags="|programming|threads|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12412" PostTypeId="1" CreationDate="2015-06-05T20:54:08.800" Score="2" ViewCount="44" Body="&lt;p&gt;Im using Spark fun´s Pro micro: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And Digole OLED 1.8&quot; hooked up with UART: &lt;a href=&quot;http://www.digole.com/index.php?productID=859&quot; rel=&quot;nofollow&quot;&gt;http://www.digole.com/index.php?productID=859&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the head line reads, got code that work just fine when I upload it to the Pro Micro. But when I restart the pro micro (after successful upload it starts to show these weird characters and tokens. I can still se the &quot;working code&quot; but with a lot of additional crap?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: This is installed in a car, and I´ve notice its just screwing around when I turn the car ON.. The cars electric is probably somehow interfering with the data-signal to the oled. Maybe I need a resistor of some kind?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is this, why is it happening, and what can I do to get rid of the problem?!? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help´s very appreciated!! Thanks!! /Rasmus&lt;/p&gt;&#xA;" OwnerUserId="9922" LastEditorUserId="9922" LastEditDate="2015-06-06T13:14:18.570" LastActivityDate="2015-06-06T13:14:18.570" Title="Graphic fail when rebooting the micro controller and OLED! (NOT when uploading the code??!!)" Tags="|uart|arduino-pro-micro|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12413" PostTypeId="1" AcceptedAnswerId="12414" CreationDate="2015-06-06T04:08:30.913" Score="0" ViewCount="415" Body="&lt;p&gt;I've run into a problem while coding a speedometer meant for bicycles. The speedometer would require the diameter of the wheel in inches for maximum accuracy, so I'd like to have an adjustable (by potentiometer) numerical prompt appear on two 7 segment LEDs. So, for example, the device would be turned on, it would display &quot;16,&quot; the user would turn the potentiometer knob until the 7 segment LED displays &quot;24,&quot; then the user would push a button [indicating the beginning of the loop()], and the speedometer would begin measuring and displaying his or her speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be an easier task to accomplish in the loop section of the code, but, because I only want this series of potentiometer analogReads to occur once, it gets a bit trickier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some clarification: Every other component of the speedometer works (such as the 7 segment LEDs via shift register and the actual measurements), so I'm only looking for help with the code for the potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2015-06-06T08:08:33.040" Title="analogRead-ing Potentiometer Values in void setup()" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12414" PostTypeId="2" ParentId="12413" CreationDate="2015-06-06T07:40:52.887" Score="1" Body="&lt;p&gt;You presumably know that:  The easiest and usual way to read a potentiometer is to connect the &quot;track&quot; between V_pot (often = Vcc) and ground and to connect the pot &quot;wiper&quot; to an analog input pin. You then use analogRead(Ax) to read the pot value in the range 0-255.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of analogRead() is valid in setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However a more &quot;real&quot; method would be to have a &quot;flag&quot; variable that indicates that the speedo initialisation code has or hasn't been run.&lt;br&gt;&#xA;Set this flag to false in setup, detect and action it in loop and then set the flag to true so that the code is not repeatedly actioned. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;eg&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void setup()&#xA;{&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&#xA;boolean initialised = false ;&#xA;...&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop()&#xA;{&#xA;if (initialised == false) {&lt;br&gt;&#xA;// initialise speedo&lt;br&gt;&#xA;//  ....&#xA;   initialised = true;&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;} // end of loop()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-06-06T07:48:29.680" LastActivityDate="2015-06-06T07:48:29.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12415" PostTypeId="2" ParentId="12413" CreationDate="2015-06-06T08:08:33.040" Score="1" Body="&lt;p&gt;If you really want to use this feature in the setup() then you can do like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUTTON 2&#xA;boolean not_done = true;&#xA;&#xA;void stopDiameterSetup() {&#xA;    // some button debounche code&#xA;    ...&#xA;    // we are done with setting up the diameter.&#xA;    not_done = false;&#xA;}&#xA;void setup() {&#xA;    ...&#xA;&#xA;    // POT reading&#xA;    interrupts();&#xA;    attachInterrupt();&#xA;    while(not_done) {&#xA;       attachInterrupt(BUTTON, stopDiameterSetup, CHANGE);&#xA;    }       &#xA;}&#xA;void loop(){&#xA;// your loop code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you can't or afraid to use interrupts then just check for a button pressed inside the while loop.&lt;/p&gt;&#xA;" OwnerUserId="10489" LastActivityDate="2015-06-06T08:08:33.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12416" PostTypeId="2" ParentId="12402" CreationDate="2015-06-06T08:13:01.360" Score="3" Body="&lt;p&gt;Your program is already using the on board RAM:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int a = 5; // This is RAM. Where did you think it goes? (This might go to a CPU Reg)&#xA;int a[5000]; // This is RAM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DDR3 RAMs&lt;/strong&gt; require (typically) &lt;code&gt;1633 MHz&lt;/code&gt; clocks, and store gigabytes of data, not something you use with Arduino, which has a &lt;code&gt;16 MHz&lt;/code&gt; CPU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need &lt;strong&gt;EXTRA&lt;/strong&gt; (emphasis on extra) &lt;code&gt;RAM&lt;/code&gt;, my first advice would be to refactor your project, and reduce processing on &lt;em&gt;Arduino&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if must have more &lt;code&gt;RAM&lt;/code&gt;, get &lt;code&gt;SRAM&lt;/code&gt;. In most cases, &lt;code&gt;DDR3&lt;/code&gt; trade high maintenance for cost. Have a look &lt;a href=&quot;http://playground.arduino.cc/Main/SpiRAM&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="297" LastEditDate="2016-04-11T10:46:45.273" LastActivityDate="2016-04-11T10:46:45.273" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12417" PostTypeId="2" ParentId="432" CreationDate="2015-06-06T08:23:06.640" Score="0" Body="&lt;p&gt;Using the ESP8266 AT cmd set is difficult and error prone.&#xA;Suggest you reflash the ESP8266-01 as a UART-WiFi bridge as described here&#xA;&lt;a href=&quot;http://www.forward.com.au/pfod/ESP8266/simpleWiFiAddon.html&quot; rel=&quot;nofollow&quot;&gt;ESP8266 Wifi Add on for Arduino Made Simple&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that setup also lets you re-configure your wifi settings without re-programming the ESP8266-01&lt;/p&gt;&#xA;" OwnerDisplayName="user10490" LastActivityDate="2015-06-06T08:23:06.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12418" PostTypeId="1" AcceptedAnswerId="12425" CreationDate="2015-06-06T09:02:18.320" Score="1" ViewCount="255" Body="&lt;p&gt;I have a light sensor that works fine and outputs the correct data to the serial monitor when I only upload the following code to the nano:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int lightSensorPin = A0;&#xA;int lightSensorValue = 0;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly: &#xA;  lightSensorValue = analogRead(lightSensorPin);&#xA;  delay(100);&#xA;  Serial.println(lightSensorValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I upload it with all of my other code, which includes lighting up about 6 LED's at one time and getting readings from two rangefinder sensors, the light sensors no longer output expected data, instead spewing out a bunch of random numbers, 0 to over 3000. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could sharing the ground with all the LED's and rangefinders be causing interference for the light sensor? Or could it be a code optimization issue? Here's my entire code if it helps at all:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int trigPin1 = 5;&#xA;int echoPin1 = 6;&#xA;int blue1 =  7;&#xA;int green1 = 8;&#xA;&#xA;int trigPin2 = A3;&#xA;int echoPin2 = A4;&#xA;int blue2 =  A2;&#xA;int green2 = A1;&#xA;&#xA;int redLED = 10;&#xA;int greenLED = 3;&#xA;int yellowLED = 9;&#xA;int blueLED = 4;&#xA;&#xA;const int lightSensorPin = A0;&#xA;int lightSensorValue = 0;&#xA;&#xA;int securityLength1 = 28;&#xA;int securityLength2 = 28;&#xA;&#xA;int frontEyes(11);&#xA;int backEyes(12);&#xA;&#xA;const char* front = &quot;front&quot;;&#xA;const char* back = &quot;back&quot;;&#xA;&#xA;void setup()  &#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(trigPin1, OUTPUT);&#xA;  pinMode(echoPin1, INPUT);&#xA;  pinMode(trigPin2, OUTPUT);&#xA;  pinMode(echoPin2, INPUT);&#xA;&#xA;  pinMode(blue1, OUTPUT);&#xA;  pinMode(green1, OUTPUT);&#xA;  pinMode(blue2, OUTPUT);&#xA;  pinMode(green2, OUTPUT); &#xA;&#xA;  pinMode(frontEyes, OUTPUT);&#xA;  pinMode(backEyes, OUTPUT);&#xA;&#xA;  pinMode(redLED, OUTPUT);&#xA;  pinMode(greenLED, OUTPUT);&#xA;  pinMode(yellowLED, OUTPUT);&#xA;&#xA;}//end setup&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;  digitalWrite(redLED, HIGH);&#xA;  digitalWrite(greenLED, HIGH);&#xA;  digitalWrite(yellowLED, HIGH);&#xA;  digitalWrite(blueLED, HIGH);&#xA;&#xA;eyeballs(trigPin1, echoPin1, securityLength1, green1, blue1, front);&#xA;eyeballs(trigPin2, echoPin2, securityLength2, green2, blue2, back);  &#xA;&#xA;  lightSensorValue = analogRead(lightSensorPin);&#xA;  delay(100);&#xA;  Serial.println(lightSensorValue);&#xA;&#xA;}//end loop&#xA;&#xA;&#xA;void eyeballs(int trigPin, int echoPin, int securityLength, int green, int blue, const char* frontOrBack){   &#xA;  digitalWrite(trigPin, LOW);  &#xA;  delayMicroseconds(2); &#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trigPin, LOW);&#xA;  long duration = pulseIn(echoPin, HIGH);&#xA;  long distance = (duration/2) / 29.1;&#xA;&#xA;  Serial.println(distance);&#xA;&#xA; if (distance &amp;gt;= securityLength || distance &amp;lt;= 0) {  &#xA;  digitalWrite(green,HIGH);&#xA;  digitalWrite(blue,LOW);&#xA;  if (frontOrBack == &quot;front&quot;) {&#xA;    digitalWrite(frontEyes, LOW);&#xA;  }//end if&#xA;  else if (frontOrBack == &quot;back&quot;) {&#xA;    digitalWrite(backEyes, LOW);&#xA;  }//end else&#xA;  }//end if&#xA;&#xA;  else if(distance &amp;lt; securityLength) {&#xA;  digitalWrite(blue,HIGH);&#xA;  digitalWrite(green,LOW);&#xA;&#xA;  if (frontOrBack == &quot;front&quot;) {&#xA;    digitalWrite(frontEyes, HIGH);&#xA;  }//end if&#xA;  else if (frontOrBack == &quot;back&quot;) {&#xA;    digitalWrite(backEyes, HIGH);&#xA;  }//end else&#xA;&#xA; }//end else if&#xA;&#xA;}//end function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2016-02-01T21:33:57.943" Title="Light sensor acting up when used with other code" Tags="|sensors|arduino-nano|code-optimization|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12419" PostTypeId="1" AcceptedAnswerId="12420" CreationDate="2015-06-06T10:26:33.500" Score="1" ViewCount="2133" Body="&lt;p&gt;I am brand new to Arduino/robotics and am trying to take baby steps. First I'd like to just power an Arduino and an LED from a 9V battery like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tIEGq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No programming, just simple circuitry. The battery powers the Due, and the Due in turn powers the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few concerns here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Will the 9V battery fry the Due, which I &lt;em&gt;believe&lt;/em&gt; is expecting 3.3V? If so, what can I do to reduce the voltage/amps?&lt;/li&gt;&#xA;&lt;li&gt;Will the 9V battery fry the resistor and/or LED?&lt;/li&gt;&#xA;&lt;li&gt;As you can see by my question marks, I'm not real sure &lt;em&gt;where&lt;/em&gt; to connect the battery to the Due (both positive &amp;amp; negative terminals) as well as the &lt;em&gt;where&lt;/em&gt; to connect the breadboard to the Due (again, both terminals).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-06-08T06:34:42.380" Title="Connecting battery and LED to Arduino Due" Tags="|led|power|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12420" PostTypeId="2" ParentId="12419" CreationDate="2015-06-06T11:13:06.357" Score="4" Body="&lt;p&gt;What you want is something like this (ignore the fact that my mini breadboard is stuck to a shield):&#xA;&lt;img src=&quot;https://i.stack.imgur.com/bvkU1.png&quot; alt=&quot;Simple LED example with no software.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My starter Arduino kit came with the connector for the 9 volt battery into the power socket on the Arduino, you may need to make one.  You cannot connect the 9V battery to any other part of the Due that I am aware of (without damaging it!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is perfectly safe to power your Arduino with 9V this way, there is circuitry to step the voltage down to the 5V and 3.3V that the board requires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the connector strip nearest this power socket (labelled Power on my board) there are a couple of Gnd connections and 5V and 3.3V connectors perfect for what you want to do.  I have used the 3.3V connector in my photo, but the 5V one should also be fine with the right resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your picture you don't appear to have anything connecting the LED to ground, but other than that, if you were to connect the battery up as I have shown and the red and black LED connectors to 3.3V and Gnd respectively, it should work as desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a next step, you could load the sample sketch Examples-&gt;01Basic-&gt;Blink, write it to your Due, move the red LED connecting wire to pin 13 on the opposite side and your LED would flash (along with one of the LEDs on the Due board itself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit (to specifically address your concerns):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The 9V battery will not fry the Due if it is connected through the power socket, which has circuitry to drop the voltage to safe levels.&lt;/li&gt;&#xA;&lt;li&gt;The 9V battery will not damage the LED or resistor as they are connected to 5V or 3.3V that the Due outputs, not the 9V from the battery.&lt;/li&gt;&#xA;&lt;li&gt;Only connect the battery through the power socket.  If you have a good quality steady 5V power supply, you can power the board through a 5V pin (at least I have been able to), but you bypass the voltage regulation circuitry that way and it is not recommended.  Connect the black wire from your LED to any Gnd pin, connect the red wire from the LED to 3.3V or 5V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additional edit:&#xA;You can connect the battery directly to the Arduino Due board without needing a plug to connect to the power socket.  Connect the red battery wire to the Vin pin and the black battery wire to a Gnd pin.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="8616" LastEditDate="2015-06-08T06:34:42.380" LastActivityDate="2015-06-08T06:34:42.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12421" PostTypeId="1" AcceptedAnswerId="12422" CreationDate="2015-06-06T11:40:41.140" Score="0" ViewCount="68" Body="&lt;p&gt;I have an Arduino UNO, and use the serial for debugging purposes. What happens if I run the arduino on batteries and try to write to serial? Will the code stop running until a serial connection is availible?&lt;/p&gt;&#xA;" OwnerUserId="10491" LastActivityDate="2015-06-06T12:09:51.497" Title="Will writing to serial when no serial is available cause problems?" Tags="|serial|debugging|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12422" PostTypeId="2" ParentId="12421" CreationDate="2015-06-06T12:09:51.497" Score="0" Body="&lt;p&gt;No, that will not cause any problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might hurt you is the fact that if you want to leave your Arduino in low power mode, but keep the serial potr disconnected &lt;em&gt;and&lt;/em&gt; the serial port is a wakeup source, it might pick up sporadic (but frequent enough to cause be noticeable) noise that will trigger wakeups and spam with meaningless data your RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This, however, is not specific to the serial port, but it can happen to any wake up source that is enabled and left dangling.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-06T12:09:51.497" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12423" PostTypeId="2" ParentId="10559" CreationDate="2015-06-06T12:20:40.353" Score="5" Body="&lt;p&gt;If you want to output preset voltage levels in distinct steps, rather than an 'analogue' range from X volts to Y volts, then the answer is in the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm117.pdf&quot; rel=&quot;noreferrer&quot;&gt;datasheet for the LM317&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TEBdt.png&quot; alt=&quot;Figure 57. Digitally Selected Outputs&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect each of the INPUTS through a 1k base resistor to your Arduino pins. Selecting different values for all the resistors will of course allow you to vary Vout by turning each transistor on or off, by themselves or together. You can use any standard transistor: 2N3904, 2N2222, BC548, etc., but I might elect to use a (low power) MOSFET like a BSS138 instead (and omit the base resistor). Of course you can use add more resistor/transistor lines if you want more output options. I recommend using R2 so that Vout is always limited, otherwise - if Vin is quite high - you may damage whatever Vout is powering due to some runaway voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calculating resitor values is your mathmatical challenge. If you really apply some brainpower you can change Vout in linear steps with minimal Arduino pin usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'Input' states            Vout&#xA;  A  B  C  D            (/volts)&#xA;  0  0  0  0              5.00  [Vmax set by R2]&#xA;  0  0  0  1              4.75&#xA;  0  0  1  0              4.50&#xA;  0  0  1  1              4.25&#xA;  0  1  0  0              4.00&#xA;   ...  ...                ..&#xA;  1  1  1  0              1.75&#xA;  1  1  1  1              1.50&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This shows that with &lt;em&gt;N&lt;/em&gt; Arduino pins you can have &lt;em&gt;(N^2)-1&lt;/em&gt; levels. Using R2 gives your final level whne all INPUTs are off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be able to drop Vout down to 1.25V, add transistor/MOSFET that connects R1/ADJ straight to ground. Turning this on will drop Vout to 1.25V, irrespective of the state of the other INPUTS. &lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-06T12:20:40.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12424" PostTypeId="2" ParentId="12418" CreationDate="2015-06-06T12:40:50.827" Score="1" Body="&lt;p&gt;There's no &lt;code&gt;pinMode(lightSensorPin, INPUT);&lt;/code&gt; in either of your codes. In the original code this probably doesn't matter because you set no other pins to In or Out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, instead of declaring all your pin number as &lt;code&gt;int&lt;/code&gt; then defining them, make use of &lt;em&gt;preprocessor directives&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin1  5;&#xA;#define echoPin1  6;&#xA;#define blue1     7;&#xA;#define green1    8;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you hit Verify or Upload the &lt;em&gt;preprocessor&lt;/em&gt; sweeps through your code and replaces all instances of a defined term with whatever comes immediately after it in the definition. You can't use it for variables of course, but it's perfect for designating pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will cut down on unnecessary memory usage. Not a huge saving in your case, but I don't see why people don't do it more often.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-06T12:40:50.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12425" PostTypeId="2" ParentId="12418" CreationDate="2015-06-06T12:59:47.577" Score="2" Body="&lt;p&gt;I'd prefer to delete this question because I'm so embarrassed by the answer. I didn't notice I had &lt;code&gt;Serial.println(distance);&lt;/code&gt; in my function. The odd numbers were coming from my rangefinders and being printed in between my light readings. &lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-06-06T12:59:47.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12426" PostTypeId="1" CreationDate="2015-06-06T13:51:31.567" Score="1" ViewCount="1143" Body="&lt;p&gt;I am recording a varying distance with an Ultrasonic sensor and Arduino but my problem is I want to display the number of times this variable reaches peak (at an instance the value will be increasing and the next instance decreasing in that order) on an LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far this is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;//Libraries&#xA;#include &amp;lt;Ultrasonic.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;//Setup connection with LCD and HC-SR04&#xA;LiquidCrystal lcd(12, 10, 5, 4, 3, 2);&#xA;Ultrasonic ultrasonic(A0,A1);&#xA;&#xA;void setup() {&#xA;  //Lcd init&#xA;  lcd.begin(16, 2); //16 rows, 2 columns&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  lcd.clear();&#xA;  lcd.print(&quot;  Ardumotive ;)  &quot;); // You can change this message.&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Distance: &quot;);&#xA;  lcd.print(ultrasonic.Ranging(CM));&#xA;  lcd.print(&quot;cm&quot;);&#xA;&#xA;  delay(300); // 1sec delay&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10493" LastEditorUserId="7508" LastEditDate="2015-06-06T14:20:00.627" LastActivityDate="2015-06-08T19:11:10.303" Title="How to count the number of times a changing variable reaches a peak value" Tags="|arduino-uno|programming|arduino-mega|pins|variables|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12427" PostTypeId="1" CreationDate="2015-06-06T16:25:05.423" Score="-4" ViewCount="368" Body="&lt;p&gt;This program is supposed to act as a Decimal To Binary Converter, the LeD's acting as output.&#xA;The problem is that this function returns Garbage Value&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;const int LED1 =1, LED2 =3, LED3 =5;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode (LED1, OUTPUT);&#xA;  pinMode (LED2, OUTPUT);&#xA;  pinMode (LED3, OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  int x = 0;&#xA;  x = Serial.read();&#xA;  x = x-48;&#xA;  switch(x){&#xA;    case 0:&#xA;      digitalWrite (LED1, LOW);&#xA;      digitalWrite (LED2, LOW);&#xA;      digitalWrite (LED3, LOW);&#xA;      break;&#xA;    case 1:&#xA;      digitalWrite (LED1, HIGH);&#xA;      digitalWrite (LED2, LOW);    &#xA;      digitalWrite (LED3, LOW);&#xA;      break;&#xA;      case 2:&#xA;      digitalWrite (LED1, LOW);&#xA;      digitalWrite (LED2, HIGH);&#xA;      digitalWrite (LED3, LOW);&#xA;      break;&#xA;      case 3:&#xA;      digitalWrite (LED1, HIGH);&#xA;      digitalWrite (LED2, HIGH);&#xA;      digitalWrite (LED3, LOW);&#xA;      break;&#xA;      case 4:&#xA;      digitalWrite (LED1, LOW);&#xA;      digitalWrite (LED2, LOW);&#xA;      digitalWrite (LED3, HIGH);&#xA;      break;&#xA;      case 5:&#xA;      digitalWrite (LED1, HIGH);&#xA;      digitalWrite (LED2, LOW);&#xA;      digitalWrite (LED3, HIGH);&#xA;      break;&#xA;      case 6:&#xA;      digitalWrite (LED1, LOW);&#xA;      digitalWrite (LED2, HIGH);&#xA;      digitalWrite (LED3, HIGH);&#xA;      break;&#xA;      case 7:&#xA;      digitalWrite (LED1, HIGH);&#xA;      digitalWrite (LED2, HIGH);&#xA;      digitalWrite (LED3, HIGH);&#xA;      break;&#xA;  }&#xA; Serial.write(x); &#xA;}&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="10408" LastEditorUserId="10408" LastEditDate="2015-06-06T16:50:28.523" LastActivityDate="2015-06-07T07:35:50.303" Title="Coding Debugging" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ClosedDate="2019-01-22T16:38:36.743" ContentLicense="CC BY-SA 3.0" />
  <row Id="12428" PostTypeId="2" ParentId="12427" CreationDate="2015-06-06T17:52:43.660" Score="7" Body="&lt;p&gt;That massive program can be compressed into just a handful of lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LED1 = 1, &#xA;          LED2 = 3, &#xA;          LED3 = 5;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode (LED1, OUTPUT);&#xA;    pinMode (LED2, OUTPUT);&#xA;    pinMode (LED3, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Serial.available()) {&#xA;        int x = Serial.read();&#xA;        x = x - '0';&#xA;        digitalWrite(LED1, x &amp;amp; 0x01);&#xA;        digitalWrite(LED2, x &amp;amp; 0x02);&#xA;        digitalWrite(LED3, x &amp;amp; 0x04);&#xA;        Serial.print(x);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of Serial.print() not Serial.write().  If you use Serial.write() then it prints the ASCII character associated with the number you feed it - in your case characters 0 to 7 (none of which are printable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, unless you check for there actually being something available for you to read from the serial you'll only get a brief flicker of something meaningful (too fast for the eye to see) and then it will just return -1, which with 48 subtracted from it would be -49, which would be &quot;complete garbage&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-06T17:52:43.660" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12429" PostTypeId="2" ParentId="12427" CreationDate="2015-06-06T17:53:28.507" Score="0" Body="&lt;p&gt;There are a couple of issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The function &lt;code&gt;loop()&lt;/code&gt; doesn't return anything, by definition. Functions that do return a value return it with a statement like `return(someValue); Did you mean to say that it &lt;em&gt;prints&lt;/em&gt; garbage on the terminal?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to print a value on the terminal, you need to use the the &lt;code&gt;Serial.print(someValue)&lt;/code&gt; function; &lt;code&gt;Serial.write()&lt;/code&gt; sends a binary value and that is probably not what you wanted. The binary values 0 - 9 represent non-printing characters so I'm not surprised that the terminal printed some odd graphic characters.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;- &#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-06T17:53:28.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12430" PostTypeId="2" ParentId="12426" CreationDate="2015-06-06T18:02:21.193" Score="1" Body="&lt;p&gt;The counting portion of what you want to achieve is simple - you just increment a variable.  The hard part is knowing &lt;em&gt;when&lt;/em&gt; to count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to remember what your value has been doing in the past in order to know if you have had a peak or not.  Also you have to define exactly what a peak is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest method (I'm not going to spoon feed you code, just help you understand the concepts) is to set a couple of thresholds, and maintain a flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You decide upon a value &quot;above which the value enters the peak zone&quot;, and another &quot;below which the value leaves the peak zone&quot;.  They could be the same value, but don't need to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then have a flag which remembers if you are in the peak zone or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're not currently in the peak zone and the new value is above the peak zone entry threshold then you have entered the peak zone.  Set the flag to remember that fact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are currently in the peak zone and the new value is below the peak zone leaving threshold then you have just left the peak zone.  Clear the flag to remember the fact that you're not in the peak zone and increment your peak counter now you have left the peak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VfdBH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be very good to have the leaving threshold lower than the entering threshold so that the value has to drop significantly out of the peak zone before it will register another peak.  This is known as &lt;a href=&quot;http://en.wikipedia.org/wiki/Hysteresis&quot; rel=&quot;nofollow noreferrer&quot;&gt;hysteresis&lt;/a&gt; and is great for getting rid of the noise you may get if the value is hovering around the peak zone entry threshold.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-06T18:11:26.917" LastActivityDate="2015-06-06T18:11:26.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12431" PostTypeId="1" AcceptedAnswerId="12432" CreationDate="2015-06-06T20:12:48.247" Score="0" ViewCount="916" Body="&lt;p&gt;I would like to have a serial Bluetooth module thats completely removable, leaving nothing connected to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code would freeze up whenever the Bluetooth module was removed. I eventually tracked down the issue to an overwhelming amount of garbage being received from the disconnected serial pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I enabled the internal pull-up resistor on pin 0 (serial rx) in the setup() function which appears to have solved all my problems but is that correct? I found barely any information on removable serial devices, floating serial connections and pull-up resistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose it's important to enable the pull up before calling serial1.begin() or maybe flushing the serial buffer once before reading any input to ensure there's no garbage?&lt;/p&gt;&#xA;" OwnerUserId="10499" LastActivityDate="2015-06-06T23:19:30.273" Title="Leonardo Serial1 enable internal pull-up for removable Bluetooth module" Tags="|serial|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12432" PostTypeId="2" ParentId="12431" CreationDate="2015-06-06T23:19:30.273" Score="1" Body="&lt;p&gt;Yes, what you have done is good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important to tie all unused inputs to a stable state (normally low) to reduce current consumption from floating inputs.  When those inputs are actively used but not connected it is even more important to stop things happening that shouldn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned, normally you'd use a pull-down, not a pull-up, but the UART is actually a special case where you would want to use a pull-up (as you have) not a pull-down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UART is &quot;Idle High&quot;, which means that when there is no data being transmitted on a line it is held high by the transmitter.  By adding a pull-up you are making it appear as if there is something connected but that something isn't actively transmitting at the moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The internal pullups aren't very strong, so in a noisy environment you may still get some spurious data on the UART.  If that happens then you want to add an external stronger (lower resistance) pull up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing to think about with your disconnected pins is to protect them from ESD.  You should have some TVS diodes on those pins to absorb spikes, and some small inline resistors to limit any overcurrent conditions. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-06T23:19:30.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12433" PostTypeId="1" CreationDate="2015-06-07T03:52:23.180" Score="0" ViewCount="1096" Body="&lt;p&gt;I'm having trouble with controlling my car with the PS3 joystick, and there hasn't been any example codes out there. I'm using;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PS3USB library from USB_Host_shield_2.0 library&lt;/li&gt;&#xA;&lt;li&gt;Freetronics H Bridge shield &lt;a href=&quot;http://www.freetronics.com.au/collections/shields/products/hbridge-dual-channel-h-bridge-motor-driver-shield#.VXMqXUJJmgM&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/collections/shields/products/hbridge-dual-channel-h-bridge-motor-driver-shield#.VXMqXUJJmgM&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is my code; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;include &amp;lt;PS3USB.h&amp;gt;&#xA;&#xA;// Satisfy the IDE, which needs to see the include statment in the ino too.&#xA;#ifdef dobogusinclude&#xA;#include &amp;lt;spi4teensy3.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#endif&#xA;&#xA;USB Usb;&#xA;/* You can create the instance of the class in two ways */&#xA;PS3USB PS3(&amp;amp;Usb); // This will just create the instance&#xA;//PS3USB PS3(&amp;amp;Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch&#xA;&#xA;bool printAngle;&#xA;uint8_t state = 0;&#xA;&#xA;int motora1 = 4;&#xA;int motora2 = 7;&#xA;int motoraspeed = 6;&#xA;int motorb1 = 3;&#xA;int motorb2 = 2;&#xA;int motorbspeed = 5;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;#if !defined(__MIPSEL__)&#xA;  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection&#xA;#endif&#xA;  if (Usb.Init() == -1) {&#xA;    Serial.print(F(&quot;\r\nOSC did not start&quot;));&#xA;    while (1); //halt&#xA;  }&#xA;  Serial.print(F(&quot;\r\nPS3 USB Library Started&quot;));&#xA;  pinMode(motora1, OUTPUT);&#xA;  pinMode(motora2, OUTPUT);&#xA;  pinMode(motoraspeed, OUTPUT); &#xA;  pinMode(motorb1, OUTPUT);&#xA;  pinMode(motorb2, OUTPUT);&#xA;  pinMode(motorbspeed, OUTPUT);  &#xA;  delay(5000); &#xA;}&#xA;&#xA;void loop() {&#xA;  Usb.Task();&#xA;&#xA;  if (PS3.PS3Connected || PS3.PS3NavigationConnected) {&#xA;&#xA;    //go forward&#xA;     if (PS3.getAnalogHat(LeftHatY) == 0) {&#xA;       Serial.print(F(&quot;\r\nLeftHatY: &quot;));&#xA;      Serial.print(PS3.getAnalogHat(LeftHatY));&#xA;         digitalWrite(motora1, HIGH);&#xA;          digitalWrite(motora2, LOW);&#xA;          digitalWrite(motoraspeed, 255);&#xA;        digitalWrite(motorb1, HIGH);&#xA;        digitalWrite(motorb2, LOW);&#xA;        digitalWrite(motorbspeed, 255);  &#xA;}&#xA;&#xA;//go backward&#xA;if (PS3.getAnalogHat(LeftHatY) == 255) {&#xA;       Serial.print(F(&quot;\r\nLeftHatY: &quot;));&#xA;      Serial.print(PS3.getAnalogHat(LeftHatY));&#xA;           digitalWrite(motora1, LOW);&#xA;  digitalWrite(motora2, HIGH);&#xA;  digitalWrite(motoraspeed, 255);&#xA;  digitalWrite(motorb1, LOW);&#xA;  digitalWrite(motorb2, HIGH);&#xA;  digitalWrite(motorbspeed, 255);  &#xA;}&#xA;&#xA;//turn left&#xA;if (PS3.getAnalogHat(RightHatX) == 0) {&#xA;       Serial.print(F(&quot;\r\RightHatX: &quot;));&#xA;      Serial.print(PS3.getAnalogHat(RightHatX));&#xA;           digitalWrite(motora1, HIGH);&#xA;  digitalWrite(motora2, LOW);&#xA;  digitalWrite(motoraspeed, 200);&#xA;  digitalWrite(motorb1, LOW);&#xA;  digitalWrite(motorb2, HIGH);&#xA;  digitalWrite(motorbspeed, 200);   &#xA;}&#xA;&#xA;   //turn right&#xA;   if (PS3.getAnalogHat(RightHatX) == 255) {&#xA;       Serial.print(F(&quot;\r\RightHatX: &quot;));&#xA;      Serial.print(PS3.getAnalogHat(RightHatX));&#xA;          digitalWrite(motora1, LOW);&#xA;  digitalWrite(motora2, HIGH);&#xA;  digitalWrite(motoraspeed, 200);&#xA;  digitalWrite(motorb1, HIGH);&#xA;  digitalWrite(motorb2, LOW);&#xA;  digitalWrite(motorbspeed, 200);   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As of now, when I look at my code in the serial monitor, I get the following; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 130&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;LeftHatY: 131&#xA;RightHatX: 127&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The numbers adjust as I'm moving the joystick around but just keeps going even though I'm not moving the joystick around. Any help would be appreciated, thanks&lt;/p&gt;&#xA;" OwnerUserId="10450" LastActivityDate="2015-08-06T15:22:05.563" Title="Controlling 2WD car chassis with PS3 controller" Tags="|arduino-uno|programming|motor|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12434" PostTypeId="1" AcceptedAnswerId="12435" CreationDate="2015-06-07T04:57:06.650" Score="0" ViewCount="925" Body="&lt;p&gt;I'm using this Dual Motor Shield&#xA;&lt;img src=&quot;https://i.stack.imgur.com/N5DAh.jpg&quot; alt=&quot;L293D Arduino Dual Motor Shield&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I plug Arduino Dual Motor Shield into Aruino uno can't seen any way to communicate with Adruino uno.how can I communicate with uno ?&lt;/p&gt;&#xA;" OwnerUserId="10500" LastEditorUserId="10500" LastEditDate="2015-06-07T05:09:48.457" LastActivityDate="2015-06-07T06:06:29.093" Title="How to communicate with arduino uno when arduino motor shield connected to arduino uno?" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12435" PostTypeId="2" ParentId="12434" CreationDate="2015-06-07T06:06:29.093" Score="1" Body="&lt;p&gt;Communicate with what? A PC? The usb serial port should still work fine, and anything connected to the RX/tx pins (D0 and  D1)&#xA;If your concern is that there is no longer a socket on the top of this shield that you can plug wires into, well you can solder on some wires to the top of the board, or you could get a screw shield board to go between the arduino and motor shield which would make all the pins available. I have also use small gauage wire wrapped around the shield pins and then just insert the shield onto the arduino making kind of a wire wrap connection between the boards.&lt;/p&gt;&#xA;" OwnerUserId="10502" LastActivityDate="2015-06-07T06:06:29.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12437" PostTypeId="1" CreationDate="2015-06-07T07:57:35.657" Score="1" ViewCount="114" Body="&lt;p&gt;I seem to remember somewhere somebody making an &quot;Always&quot; loop between Setup() and Loop().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't find any documentation on it. Does such a thing exist, or am I imagining it?&lt;/p&gt;&#xA;" OwnerUserId="10504" LastActivityDate="2015-06-07T10:56:40.590" Title="Is there such a thing as an &quot;Always&quot; loop?" Tags="|c++|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12438" PostTypeId="2" ParentId="12437" CreationDate="2015-06-07T08:39:23.643" Score="1" Body="&lt;p&gt;There's nothing officially called an &quot;always&quot; loops as such. However, you can make a loop which goes on forever like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (true)&#xA;{&#xA;    // this bit repeats forever&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;while&lt;/code&gt; loop checks the condition before every iteration of the main body. If it detects that the condition equals boolean &lt;code&gt;false&lt;/code&gt; then it will stop the loop and move on to the next bit of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally, the condition would be some kind of expression, like &lt;code&gt;(x &amp;lt; 10)&lt;/code&gt;. However, in the example above, the condition is hard-coded as &lt;code&gt;true&lt;/code&gt;, meaning it will never be &lt;code&gt;false&lt;/code&gt; so it will never stop.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-06-07T08:39:23.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12439" PostTypeId="1" CreationDate="2015-06-07T10:06:42.820" Score="0" ViewCount="207" Body="&lt;p&gt;Does anyone know a good IDE for Ipad to write Arduino code and compile it for teensy 3 ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answers with different alternatives would be appreciated&lt;/p&gt;&#xA;" OwnerUserId="2860" LastActivityDate="2015-06-07T14:17:37.330" Title="Arduino IDE / Teensy 3 on Ipad" Tags="|programming|arduino-ide|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12440" PostTypeId="2" ParentId="12437" CreationDate="2015-06-07T10:56:40.590" Score="1" Body="&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; be thinking of the &lt;em&gt;Serial Event&lt;/em&gt; system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a specially defined function which runs whenever &lt;code&gt;loop()&lt;/code&gt; finishes &lt;em&gt;if there is anything to read from the serial port&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/SerialEvent&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/SerialEvent&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically it is implemented as a function call after &lt;code&gt;loop()&lt;/code&gt; in the &lt;code&gt;main()&lt;/code&gt; function, which looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup();&#xA;&#xA;for (;;) {&#xA;    loop();&#xA;    if (serialEventRun) serialEventRun();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see there is only &lt;code&gt;setup()&lt;/code&gt;, &lt;code&gt;loop()&lt;/code&gt; and the &lt;em&gt;serial event&lt;/em&gt; system.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-07T10:56:40.590" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12441" PostTypeId="1" CreationDate="2015-06-07T11:27:51.230" Score="1" ViewCount="566" Body="&lt;p&gt;I've been using a pair of arduino uno and nrf24l01 and found it wasn't really suitable due to low range when it comes to obstacles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially I'd like to use it in country areas where it would ideally transmit through dense trees and over hills at around 500 meters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've spotted the &lt;a href=&quot;http://www.banggood.com/SI4432-470MHz-1000M-Wireless-Module-Wireless-Communication-Module-p-920484.html&quot; rel=&quot;nofollow&quot;&gt;SI4432&lt;/a&gt; and the &lt;a href=&quot;https://www.cooking-hacks.com/documentation/tutorials/extreme-range-lora-sx1272-module-shield-arduino-raspberry-pi-intel-galileo)&quot; rel=&quot;nofollow&quot;&gt;sx1272&lt;/a&gt; (which seems ideal but it doesn't seem popular despite it's high NLOS range capabilities?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just wondering if anyone had any recommendations on which would be the best radio module to try? Any help would be really appreciated. Many thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="8726" LastActivityDate="2015-06-07T21:19:31.417" Title="Non line of sight radio and arduino uno" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12442" PostTypeId="2" ParentId="12441" CreationDate="2015-06-07T13:18:20.000" Score="1" Body="&lt;p&gt;General rule is, the lower the frequency, the longer the range (but lower bandwidth). So both should have a better range at 433Mhz and 137MHz instead of the 2.4Ghz of the NRF. Antennas also affect the range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;over the hills&quot; part I think will be problematic. The RF won't be able to penetrate through the hill. So the signal has to bounce of the ionosphere to get over the hill, which is to long a distance. So you probably have to have some kind of repeater on top of the hill to accomplish this.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-07T13:18:20.000" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12443" PostTypeId="2" ParentId="12439" CreationDate="2015-06-07T14:17:37.330" Score="-1" Body="&lt;p&gt;I don't know of any way to &lt;em&gt;compile&lt;/em&gt; it on an iPad, but &lt;a href=&quot;https://itunes.apple.com/us/app/textastic-code-editor-for/id383577124&quot; rel=&quot;nofollow&quot;&gt;Textastic&lt;/a&gt; should do the trick for writing the code if you set the syntax highlighting to &lt;code&gt;C++&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10507" LastActivityDate="2015-06-07T14:17:37.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12444" PostTypeId="2" ParentId="12433" CreationDate="2015-06-07T14:30:10.627" Score="1" Body="&lt;p&gt;I found three issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You don't have a &lt;code&gt;#&lt;/code&gt; before the include on line 1.&lt;/li&gt;&#xA;&lt;li&gt;There is no &lt;code&gt;}&lt;/code&gt; at the end of the &lt;code&gt;void loop()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You forgot to include an if statement for when the joystick is idle.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PS3USB.h&amp;gt;&#xA;&#xA;    // Satisfy the IDE, which needs to see the include statment in the ino too.&#xA;#ifdef dobogusinclude&#xA;#include &amp;lt;spi4teensy3.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#endif&#xA;&#xA;USB Usb;&#xA;/* You can create the instance of the class in two ways */&#xA;PS3USB PS3(&amp;amp;Usb); // This will just create the instance&#xA;                  //PS3USB PS3(&amp;amp;Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch&#xA;&#xA;bool printAngle;&#xA;uint8_t state = 0;&#xA;&#xA;int motora1 = 4;&#xA;int motora2 = 7;&#xA;int motoraspeed = 6;&#xA;int motorb1 = 3;&#xA;int motorb2 = 2;&#xA;int motorbspeed = 5;&#xA;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;#if !defined(__MIPSEL__)&#xA;    while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection&#xA;#endif&#xA;    if (Usb.Init() == -1) {&#xA;        Serial.print(F(&quot;\r\nOSC did not start&quot;));&#xA;        while (1); //halt&#xA;    }&#xA;    Serial.print(F(&quot;\r\nPS3 USB Library Started&quot;));&#xA;    pinMode(motora1, OUTPUT);&#xA;    pinMode(motora2, OUTPUT);&#xA;    pinMode(motoraspeed, OUTPUT);&#xA;    pinMode(motorb1, OUTPUT);&#xA;    pinMode(motorb2, OUTPUT);&#xA;    pinMode(motorbspeed, OUTPUT);&#xA;    delay(5000);&#xA;}&#xA;&#xA;void loop() {&#xA;    Usb.Task();&#xA;&#xA;    if (PS3.PS3Connected || PS3.PS3NavigationConnected) {&#xA;&#xA;        if (PS3.getAnalogHat(LeftHatY) == 0) { //go forward&#xA;            Serial.print(F(&quot;\r\nLeftHatY: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(LeftHatY));&#xA;            digitalWrite(motora1, HIGH);&#xA;            digitalWrite(motora2, LOW);&#xA;            digitalWrite(motoraspeed, 255);&#xA;            digitalWrite(motorb1, HIGH);&#xA;            digitalWrite(motorb2, LOW);&#xA;            digitalWrite(motorbspeed, 255);&#xA;        } else if (PS3.getAnalogHat(LeftHatY) == 255) { //go backward&#xA;            Serial.print(F(&quot;\r\nLeftHatY: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(LeftHatY));&#xA;            digitalWrite(motora1, LOW);&#xA;            digitalWrite(motora2, HIGH);&#xA;            digitalWrite(motoraspeed, 255);&#xA;            digitalWrite(motorb1, LOW);&#xA;            digitalWrite(motorb2, HIGH);&#xA;            digitalWrite(motorbspeed, 255);&#xA;        } else if PS3.getAnalogHat(RightHatX) == 0) { //turn left&#xA;            Serial.print(F(&quot;\r\RightHatX: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(RightHatX));&#xA;            digitalWrite(motora1, HIGH);&#xA;            digitalWrite(motora2, LOW);&#xA;            digitalWrite(motoraspeed, 200);&#xA;            digitalWrite(motorb1, LOW);&#xA;            digitalWrite(motorb2, HIGH);&#xA;            digitalWrite(motorbspeed, 200);&#xA;        } else if (PS3.getAnalogHat(RightHatX) == 255) { //turn right&#xA;            Serial.print(F(&quot;\r\RightHatX: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(RightHatX));&#xA;            digitalWrite(motora1, LOW);&#xA;            digitalWrite(motora2, HIGH);&#xA;            digitalWrite(motoraspeed, 200);&#xA;            digitalWrite(motorb1, HIGH);&#xA;            digitalWrite(motorb2, LOW);&#xA;            digitalWrite(motorbspeed, 200);&#xA;        } else { //stop moving&#xA;            Serial.print(F(&quot;\r\RightHatX: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(RightHatX));&#xA;            Serial.print(F(&quot;\r\nLeftHatY: &quot;));&#xA;            Serial.print(PS3.getAnalogHat(LeftHatY));&#xA;            digitalWrite(motora1, LOW);&#xA;            digitalWrite(motora2, LOW);&#xA;            digitalWrite(motoraspeed, 0);&#xA;            digitalWrite(motorb1, LOW);&#xA;            digitalWrite(motorb2, LOW);&#xA;            digitalWrite(motorbspeed, 0);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10507" LastActivityDate="2015-06-07T14:30:10.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12447" PostTypeId="1" CreationDate="2015-06-07T15:03:07.967" Score="2" ViewCount="363" Body="&lt;p&gt;I have an Arduino BT-V06 laying around which I can't program over bluetooth for some reason. To be honest I don't understand the exact problem, but the problem is described in the question &lt;a href=&quot;https://electronics.stackexchange.com/questions/7843/arduino-bt-upload-problem&quot;&gt;https://electronics.stackexchange.com/questions/7843/arduino-bt-upload-problem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve the problem of programming the board I'm trying to program the BT-V06 using an Arduino Uno. I wired it all up using the description at &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader&lt;/a&gt;. The UNO seems fine, but the BT-V06 has the BATT-LOW led burning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've programmed the Arduino UNO using the Arduino ISP sketch. I've set the Arduino IDE to the COM port of the UNO, the target board to Arduino BT and the programmer to &quot;Arduino as ISP&quot;. When trying to program the blink sketch I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: verification error, first mismatch at byte 0x0002&#xA;         0x40 != 0x5c&#xA;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could it be that the power requirements are too high to be powered through the UNO?&lt;/p&gt;&#xA;" OwnerUserId="10513" OwnerDisplayName="Wouter" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-06-07T17:05:06.110" Title="Programming an Arduino BT-V06 using an UNO using ICSP" Tags="|programmer|icsp|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12449" PostTypeId="1" AcceptedAnswerId="12451" CreationDate="2015-06-07T19:16:23.410" Score="0" ViewCount="148" Body="&lt;p&gt;I'm working on project 9 of the Arduino starter kit - the motorized pinwheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wKxI0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;(if img not showing: &lt;a href=&quot;https://goo.gl/tqZmKD&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://goo.gl/tqZmKD&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, why is the 10k resistor needed after the switch? Why can't it just go straight to ground? The switch's output just connects to a digital pin, it doesn't care how much voltage there is, correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT**: Additional help from the arduino forums:&#xA;The resistor is needed so when the switch is closed you don't short the supply&#xA;to ground.  Switch open the resistor pulls the signal to ground and no current&#xA;flows, when the switch is closed it forms a resistive divider with the 10k&#xA;(switch contacts might have 0.01 to 0.1 ohms resistance or so), thus pulling&#xA;the signal to Vcc, but with only 0.5mA flowing through the 10k resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the 10k with a wire and you'd simply overload the supply completely and&#xA;perhaps weld the switch contacts shut.&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=328353.new#new&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Forums&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10516" LastEditorUserId="10516" LastEditDate="2015-06-07T20:24:42.300" LastActivityDate="2015-06-07T20:24:42.300" Title="Use of Resistor in PinWheel Exercise" Tags="|resistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12450" PostTypeId="1" AcceptedAnswerId="14289" CreationDate="2015-06-07T19:24:02.627" Score="1" ViewCount="1436" Body="&lt;p&gt;I had posted some questions about this project earlier this week. Arduino uno + w5100 ethernet shield + nrf24l01 transeiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The w5100 is running a webserver to accept GET requests and parse out the variables - Works all the time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nrf24l01 is acting as a transmitter and sending data out to other nodes - Only works with no Ethernet code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What doesn't work is both at the same time. With everything hooked up it parses get fine, gets the variable but I can't transmit it since the radio never seems to fire up. Remove all the ethernet code and leave just the radio code it sends fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code here. &lt;a href=&quot;http://pastebin.com/SMWC9x4F&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/SMWC9x4F&lt;/a&gt; it errors at 146. Which I assume is the radio never starting since the:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.printDetails(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using manicbug's library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the EXACT same send bits in that file to test wireless communication, it works. I only need it to transmit wirelessly when it get data from the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pinouts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CSN -&gt; 10&#xA;CE   -&gt;  9&#xA;MISO -&gt; 12&#xA;MOSI -&gt; 11&#xA;SCK   -&gt; 13&#xA;VCC   -&gt;  Separate 3.3 source, not the arduino&#xA;GND  -&gt; GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is this is because both are using SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried the softspi method &lt;a href=&quot;http://pastebin.com/4mv612B7&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/4mv612B7&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same thing. I can post GET to it, parse out variables but nothing on the radio side. And I still get no output from radio.printDetails() so it just must not be starting. Commence hair pulling..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Bloody hell, printDetails() relies on printf...... that would have been handy to figure out an hour or two ago.  I can get details now. still having communication issues.  Will post more debugging information in a bit.&lt;/p&gt;&#xA;" OwnerUserId="9822" LastEditorUserId="9822" LastEditDate="2015-06-07T21:30:28.550" LastActivityDate="2015-08-17T23:18:44.767" Title="w5100 and nrf24l01 - SoftSPI - Radio not starting" Tags="|ethernet|nrf24l01+|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12451" PostTypeId="2" ParentId="12449" CreationDate="2015-06-07T19:34:11.107" Score="1" Body="&lt;p&gt;It's a pull-down resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A pull-up or pull-down resistor is used the make sure that the input of a digital device is confined to strict logic levels, i.e +Vdd (positive, or HIGH) or GND (Ground, or LOW).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the switch open and no resistor present, the Arduino pin is neither high nor low. It will &lt;em&gt;probably&lt;/em&gt; read as low if you tried &lt;code&gt;digitalRead()&lt;/code&gt;, but there's no guarantee. The probability of the pin being one or the other changes according to the layout of the PCB and other external factors; the pin is termed 'floating' because it could be at any voltage between Vdd and GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you apply a pull-(somewhere) resistor you force the Arduino pin to one of either Vdd (up) or GND (down) &lt;em&gt;until you press the switch&lt;/em&gt;, at which point the Arduino pin switches state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you removed the resistor and joined the switch directly to ground, what happens when the switch contacts close?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think about it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One side of the switch connected to Vdd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other side is connected to the Arduino and GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close the switch, &lt;em&gt;I dare you.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Vdd is now connected to GND&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-07T19:34:11.107" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12452" PostTypeId="1" AcceptedAnswerId="12453" CreationDate="2015-06-07T19:36:20.753" Score="3" ViewCount="499" Body="&lt;p&gt;I'm working on project 9 of the arduino starter-kit - the motorized pinwheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the schematic:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wysl1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diode in question (and the only one here) is toward the bottom right of the breadboard. It is to prevent the back-voltage from the motor from harming the circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the above img, would the backvoltage travel back down the motor's supply of energy (the red wire)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, what is the diode preventing here? That whole energy strip will just have current running through it and the diode's cathode will prevent it from running to the transistor - which would also happen fi we just didn't connect anything to that power strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, and the back-voltage is running through the black wire (our ground), then I still do not see how the diode is helping. The diode seems to want to pull the extra energy back to our power strip (which is why the anode is facing toward the left, where the motor's output is. But this doesn't prevent the current from still hitting the green wire which leads to the transistor's 'source'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how is this diode working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10516" LastActivityDate="2015-06-07T19:59:53.217" Title="How is the diode here effective?" Tags="|motor|transistor|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12453" PostTypeId="2" ParentId="12452" CreationDate="2015-06-07T19:49:19.017" Score="4" Body="&lt;p&gt;Under normal operation the + connection of  any inductive component (motor, relay, etc) is at a higher potential than the - connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During a &quot;back EMF&quot; event (the collapsing of the magnetic field) a large voltage &lt;em&gt;of the opposite potential&lt;/em&gt; is generated.  That means that the - connection suddenly becomes a much higher potential than the + connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is very bad for anything connected to the - pin of the inductive load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the diode connected backwards like that across the inductive load, under normal operation, it does absolutely nothing.  However, when the - pin becomes a higher potential than the + pin the diode will become &lt;em&gt;forward biased&lt;/em&gt; and start to conduct.  That allows a very low resistance path for all the energy stored in the coil of the inductive component to flow from the high potential to the low potential, which is what it wants to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without it, the only way for that energy to get from the high potential to the low potential is through the rest of your circuit, which it won't like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The excess energy at the - side of your motor wants to get to the + side. That's the only place it wants to go.  It'll (crudely speaking*) take the shortest, quickest, route to get there.  That means it goes through the diode and nowhere else.  Straight from the black wire to the red wire of your motor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* Note: In actuality the energy will take all possible routes at once, but in varying proportions depending on the resistance of the route.  The lower the resistance the greater the proportion. Because the diode is such low resistance it gets the majority of the energy and only a very negligible proportion takes the other possible routes through your circuit. Unless your circuit is incredibly sensitive it won't even notice it's there.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-07T19:59:53.217" LastActivityDate="2015-06-07T19:59:53.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12454" PostTypeId="2" ParentId="12452" CreationDate="2015-06-07T19:50:01.487" Score="1" Body="&lt;p&gt;Flywheel Diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the transistor shuts off, the stopping of the motor generates &lt;em&gt;back EMF (ElectroMotive Force)&lt;/em&gt; . This manifests itself as negative potential difference (voltage) across the motor. In plain English the collector of the transistor, connected to the -Ve side of the motor, is raised to a damagingly high voltage. If you include the diode, this voltage is siphoned immediately back to the positive rail, so the damage is averted.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-07T19:50:01.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12455" PostTypeId="2" ParentId="12356" CreationDate="2015-06-07T19:59:36.600" Score="0" Body="&lt;p&gt;I am the author of the code and needless to say I am very confused right now on what you are trying to do. You run make writeflash in order to do what the target names implies write the hex file to microcontroller's internal flash memory. After that is done the code will run and you will use my frame grabber &lt;a href=&quot;https://github.com/ComputerNerd/simpleFrameGrabber&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ComputerNerd/simpleFrameGrabber&lt;/a&gt; to capture an image.&lt;/p&gt;&#xA;" OwnerUserId="8568" LastActivityDate="2015-06-07T19:59:36.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12456" PostTypeId="2" ParentId="12267" CreationDate="2015-06-07T20:09:10.213" Score="1" Body="&lt;p&gt;I2C is not used to get the pixel data. That is used only to configure the ov7670. You can read the pixel data by reading the IO PORTS and then send the data via SPI.&lt;/p&gt;&#xA;" OwnerUserId="8568" LastActivityDate="2015-06-07T20:09:10.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12457" PostTypeId="2" ParentId="12441" CreationDate="2015-06-07T21:19:31.417" Score="0" Body="&lt;p&gt;Since you already have the uno+nrf24 working, it might be worth trying a better nrf24 module before trashing the work you've already done. You can buy nrf24 modules with an integrated LNA, PA, and external antenna port. Just do a search for NRF24L01+LNA+PA. You can find them on amazon for &amp;lt; $10 and usually come with an external antenna.&lt;/p&gt;&#xA;" OwnerUserId="8765" LastActivityDate="2015-06-07T21:19:31.417" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12458" PostTypeId="2" ParentId="12450" CreationDate="2015-06-07T21:41:26.047" Score="0" Body="&lt;p&gt;Issue one:  .printDetails(); uses printh.  If you don't have that included you won't get the information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issue two:  The ide gets confused when you have two libraries with the same file.  I compiled my receiver with the softspi file. Once I put the right library in it works. &lt;/p&gt;&#xA;" OwnerUserId="9822" LastActivityDate="2015-06-07T21:41:26.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12459" PostTypeId="2" ParentId="8383" CreationDate="2015-06-07T22:06:30.760" Score="0" Body="&lt;p&gt;Same probem. Kludgy solution ... but it works&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get the startstopsimple skectch from GitHub.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set the period to 60 minutes&#xA;Set the timeout to whatever makes sense for you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modify the setup function to loop until the clock says the minute is 59. &#xA;something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do&#xA;{&#xA;   delay (100);&#xA;} while !(minute() == 59);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it will go into the loop function. It will be asleep. So it will then do a whole &quot;empty&quot; loop and sync after that, dunno how one gets rid of first the empty loop. But it works .... :-)&lt;/p&gt;&#xA;" OwnerUserId="10519" LastEditorUserId="6452" LastEditDate="2015-06-08T17:24:01.163" LastActivityDate="2015-06-08T17:24:01.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12460" PostTypeId="1" AcceptedAnswerId="12479" CreationDate="2015-06-08T00:51:04.123" Score="2" ViewCount="2638" Body="&lt;p&gt;I have arduino nano and sim900a modem.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/Ze9I6.jpg&quot; alt=&quot;My arduino pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wpPOc.jpg&quot; alt=&quot;SIM900A Modem&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kXEOE.jpg&quot; alt=&quot;Modem Backside&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rx(pin30) and Tx(pin31) pins of &lt;strong&gt;arduino&lt;/strong&gt; shows 3.8VDC respectively and Rx and Tx of &lt;strong&gt;SIM900a&lt;/strong&gt; shows 3.6VDC and 2.8VDC respectively. Could i connect the SIM900a modem directly to the arduino? Since Should i use level shifter between arduino TX(3.8v) and SIM900A modem(3.6v)? Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks..&lt;/p&gt;&#xA;" OwnerUserId="10520" LastEditorUserId="10520" LastEditDate="2015-06-08T15:04:47.957" LastActivityDate="2015-06-08T16:31:25.313" Title="How to interface arduino nano with sim900A?" Tags="|serial|arduino-nano|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12462" PostTypeId="1" CreationDate="2015-06-08T05:50:31.387" Score="0" ViewCount="13379" Body="&lt;p&gt;I was trying to apply PI controller to a motor using Arduino. I have somewhat achieved the task but the problem is that it oscillates too much. Also i couldn't figure out what to do when pwm signal are calculated as negative &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int counter = 0;&#xA;  double end_time=0;&#xA;  double ini_time=0;&#xA;  double rpm=0;&#xA;  double my_time=0;&#xA;  double temp = 0;&#xA;  int pid_speed=0;&#xA;  float kp=2.25;&#xA;  float ki=.01;&#xA;  float kd=0.005;&#xA;  int prev_error=0;&#xA;  double pwm_sig=0;&#xA;  int integrator  = 0;&#xA;  int motor_sig_pin= 5;&#xA;  int error=0;&#xA;  int absolute = 0;&#xA;  float desired_rpm=1000; //my desired RPM value&#xA;  double zero_time=0;&#xA;  double i_time=0;&#xA;  double f_time=0;&#xA;  int rpm_tacho=0;&#xA;  int previous_error=0;&#xA;  int derivative=0;&#xA;&#xA;  void setup() {&#xA;    pinMode(2,INPUT);&#xA;    digitalWrite(2,HIGH);&#xA;    pinMode(motor_sig_pin,OUTPUT);&#xA;    pinMode(9,OUTPUT);&#xA;    pinMode(10,OUTPUT);&#xA;    digitalWrite(9,HIGH);&#xA;    digitalWrite(10,LOW );&#xA;    attachInterrupt (0,Count,RISING);&#xA;    ini_time = micros();&#xA;    i_time=micros();&#xA;    Serial.begin(115200); &#xA;  }&#xA;&#xA;   void Count(){ //calculating time for one round using encoder&#xA;&#xA;      counter++;&#xA;      if (counter&amp;gt;=100){&#xA;        end_time=micros()-ini_time;&#xA;&#xA;        ini_time=micros();&#xA;        counter=0;&#xA;      }&#xA;   }&#xA;  void loop() { &#xA;      rpm = ((1000000*60)/(end_time));&#xA;      rpm = abs(rpm);&#xA;      rpm_tacho = ((1000000*60)/(zero_time));&#xA;      if (rpm &amp;lt;10 || rpm&amp;gt;5000){&#xA;        rpm=0;&#xA;      }&#xA;      error=desired_rpm-rpm;&#xA;&#xA;      integrator += error;&#xA;      pid_speed = kp*error; + ki*integrator;&#xA;&#xA;      pid_speed=(int)pid_speed;&#xA;&#xA;      Serial.print(pid_speed);&#xA;      Serial.print(&quot;       &quot;);&#xA;&#xA;      if (pid_speed&amp;gt; 0){&#xA;        if (pid_speed&amp;gt;255)&#xA;          analogWrite(motor_sig_pin,255);&#xA;        else&#xA;          analogWrite(motor_sig_pin,pid_speed);&#xA;      }&#xA;      if(pid_speed&amp;lt;0){&#xA;        if(pid_speed&amp;lt;-255)&#xA;        {&#xA;            analogWrite(motor_sig_pin,0); &#xA;        }&#xA;        else&#xA;       {&#xA;          pid_speed=abs(pid_speed);&#xA;          analogWrite(motor_sig_pin,255-pid_speed);&#xA;       }&#xA;      }&#xA;      Serial.print (&quot;      &quot;);&#xA;      Serial.println(rpm);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6745" LastEditorUserId="7045" LastEditDate="2015-06-10T14:11:02.890" LastActivityDate="2019-03-27T12:05:03.423" Title="PID control for Motor Speed control" Tags="|arduino-uno|pwm|pid|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12463" PostTypeId="1" CreationDate="2015-06-08T07:49:50.467" Score="2" ViewCount="644" Body="&lt;p&gt;I am a newbie in arduino. I successfully installed driver for arduino atmega 8l, which were provided by the company i bought arduino from. The driver is PL2303 by prolific. The reason i m mentioning this is because at first i had some problems in installing them.&#xA;Now after i have made a blink program. I thought of uploading it. Whenever I try to upload i get this error:&#xA;avrdude: arduino_read_sig_bytes(): (a) protocol error, expect=0x14, resp=0x75&#xA;avrdude: error reading signature data for part &quot;ATMEGA8&quot;, rc=-2&#xA;avrdude: error reading signature data, rc=-1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My computer: Windows 7 32-bit&#xA;I tried pressing the reset button before uploading, i get the same message.&#xA;I tried it in another computer of mine. There the driver is showing a code 37 error so basically my other computer is not reading the arduino.(also my board comes with bootloader already innstalled). Thank You&lt;/p&gt;&#xA;" OwnerUserId="10522" LastActivityDate="2015-06-08T07:49:50.467" Title="Need help with uploading to arduino ng or older with atmega8" Tags="|uploading|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12464" PostTypeId="1" AcceptedAnswerId="12465" CreationDate="2015-06-08T09:29:21.880" Score="-1" ViewCount="1675" Body="&lt;h1&gt;Arduino UNO R3 Compatible Board ATmega328P ATmega16U2&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.in/itm/UNO-R3-ATmega328P-ATmega16U2-Compatible-Board-For-Arduino-with-USB-Cable-/201367107680?pt=LH_DefaultDomain_203&amp;amp;hash=item2ee26a3860&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.in/itm/UNO-R3-ATmega328P-ATmega16U2-Compatible-Board-For-Arduino-with-USB-Cable-/201367107680?pt=LH_DefaultDomain_203&amp;amp;hash=item2ee26a3860&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Arduino UNO R3 ATmega328P USB Development Board CH340G&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.in/itm/UNO-R3-Development-Board-SMD-Chip-Arduino-Compatible-/301653217776?pt=LH_DefaultDomain_203&amp;amp;hash=item463beed1f0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.in/itm/UNO-R3-Development-Board-SMD-Chip-Arduino-Compatible-/301653217776?pt=LH_DefaultDomain_203&amp;amp;hash=item463beed1f0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;I will be working on a windows 7 32 bit pc.&lt;/h3&gt;&#xA;" OwnerUserId="10524" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-08T10:15:15.550" Title="What is the diffrence between following arduino boards and which should i buy?" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="0" ClosedDate="2015-06-10T21:36:54.390" ContentLicense="CC BY-SA 3.0" />
  <row Id="12465" PostTypeId="2" ParentId="12464" CreationDate="2015-06-08T10:15:15.550" Score="1" Body="&lt;p&gt;The first is an unofficial clone of an R3 using the same schematic as the real R3.  The second is a rough copy using a cheaper USB serial interface chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither of them are real Arduino boards.  The first one is closer to the real UNO and should do the same things that a real UNO should do (assuming it works at all).  The second one - well, who knows?  You certainly can't do any of the fancy things to the USB interface that you can with a real UNO R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which should you buy? Well, really, you shouldn't buy either of them - but if you &lt;em&gt;must&lt;/em&gt; go for one I'd pick the first one.  Better to buy a real UNO from Arduino though, at least then you know what it is you're getting, and you expect it to work.  With these cheap Chinese clones (Chinduinos) you may just get a bunch of counterfeit chips selotaped to a piece of cardboard.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-08T10:15:15.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12466" PostTypeId="1" AcceptedAnswerId="12493" CreationDate="2015-06-08T11:42:13.467" Score="0" ViewCount="628" Body="&lt;p&gt;I have a mpu6050(which I got from here &lt;a href=&quot;http://www.sainsmart.com/sainsmart-mpu-6050-3-axis-gyroscope-module.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.sainsmart.com/sainsmart-mpu-6050-3-axis-gyroscope-module.html&lt;/a&gt;) and I have connected it to special ports on a sensor shield made for the mpu6050(&lt;a href=&quot;http://www.amazon.co.uk/SainSmart-InstaBots-SS-SBR-1-0-Sensor-Shield/dp/B00N1YANH2&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.co.uk/SainSmart-InstaBots-SS-SBR-1-0-Sensor-Shield/dp/B00N1YANH2&lt;/a&gt;) which is on a Arduino uno. I have a sketch which is meant to print stuff out to the serial monitor, however when the mpu6050 is attached nothing is printed out and when it is not attached the Arduino does print out things to the serial monitor. I attached other things to the sensor shield and things were printed out on the serial monitor, so I know it is the mpu6050 that is the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt; &#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;#include &amp;lt;I2Cdev.h&amp;gt;&#xA;#include &amp;lt;MPU6050.h&amp;gt;&#xA;&#xA;MPU6050 accelgyro;&#xA;int16_t ax, ay, az;&#xA;int16_t gx, gy, gz;&#xA;&#xA;#define Gry_offset 0 &#xA;#define Gyr_Gain 0.00763358  &#xA;#define Angle_offset 4&#xA;#define RMotor_offset 20&#xA;#define LMotor_offset 20&#xA;#define pi 3.14159 &#xA;&#xA;long data;&#xA;int x, y;&#xA;float kp, ki, kd; &#xA;float r_angle, omega;&#xA;float f_angle;&#xA;float Turn_Speed = 0, Turn_Speed_K = 0;&#xA;float Run_Speed = 0, Run_Speed_K = 0, Run_Speed_T = 0;&#xA;float LOutput,ROutput;&#xA;&#xA;unsigned long preTime = 0;&#xA;float SampleTime = 0.08;&#xA;unsigned long lastTime;&#xA;float Input, Output;&#xA;float errSum, dErr, error, lastErr;&#xA;int timeChange; &#xA;&#xA;int TN1=3;&#xA;int TN2=4;&#xA;int ENA=9;&#xA;&#xA;int TN3=5;&#xA;int TN4=6;&#xA;int ENB=10;&#xA;&#xA;void setup() {&#xA;  Wire.begin();&#xA;  accelgyro.initialize();&#xA;  pinMode(TN1,OUTPUT);&#xA;  pinMode(TN2,OUTPUT);&#xA;  pinMode(TN3,OUTPUT);&#xA;  pinMode(TN4,OUTPUT);&#xA;  pinMode(ENA,OUTPUT);&#xA;  pinMode(ENB,OUTPUT);&#xA;&#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;   &#xA;  Mirf.init();&#xA;  Mirf.setRADDR((byte *)&quot;serv1&quot;);&#xA;  Mirf.payload = sizeof(long);&#xA;  Mirf.config();&#xA;  Serial.begin(115200);&#xA;  Serial.print(&quot;Hello&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Recive();&#xA;  accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;  r_angle = (atan2(ay, az) * 180 / pi + Angle_offset);&#xA;  omega =  Gyr_Gain * (gx +  Gry_offset);  &#xA;  //Serial.print(&quot;  omega=&quot;); Serial.print(omega);&#xA;  if (abs(r_angle)&amp;lt;45){&#xA;    myPID();&#xA;    PWMControl();&#xA;  }&#xA;  else{&#xA;    analogWrite(ENA, 0);&#xA;    analogWrite(ENB, 0);&#xA;  }&#xA;}&#xA;&#xA;void Recive(){&#xA;  if(!Mirf.isSending() &amp;amp;&amp;amp; Mirf.dataReady()){&#xA;    Mirf.getData((byte *)&amp;amp;data);&#xA;    Mirf.rxFifoEmpty();&#xA;&#xA;    y = data &amp;gt;&amp;gt; 16;&#xA;    x = data &amp;amp; 0x0000ffff;&#xA;    //Serial.print(&quot;  x=&quot;); Serial.print(x);&#xA;    //Serial.print(&quot;  y=&quot;); Serial.println(y);&#xA;    if(x &amp;gt;= 520){&#xA;      Run_Speed_K = map(x, 520, 1023, 0, 100);&#xA;      Run_Speed_K = Run_Speed_K / 50;&#xA;      Run_Speed = Run_Speed + Run_Speed_K;&#xA;    }&#xA;    else if(x &amp;lt;= 480){&#xA;      Run_Speed_K = map(x, 480, 0, 0, -100);&#xA;      Run_Speed_K = Run_Speed_K / 50;&#xA;      Run_Speed = Run_Speed + Run_Speed_K;&#xA;    }&#xA;    else{&#xA;      Run_Speed_K = 0;&#xA;    }&#xA;    if(y &amp;gt;= 520){&#xA;      Turn_Speed = map(y, 520, 1023, 0, 20);&#xA;    }&#xA;    else if(y &amp;lt;= 480){&#xA;      Turn_Speed = map(y,480,0,0,-20);&#xA;    }&#xA;    else{&#xA;      Turn_Speed = 0;&#xA;    }&#xA;  }&#xA;  else{&#xA;    x = y = 500;&#xA;  }&#xA;}&#xA;&#xA;void myPID(){&#xA;  kp = analogRead(A0)*0.1;  &#xA;  //kp=17;&#xA;  Serial.print(&quot;  kp=&quot;);Serial.print(kp);&#xA;  kd = analogRead(A2)*1.0;  &#xA;  //kd=840;&#xA;  Serial.print(&quot;  kd=&quot;);Serial.print(kd);&#xA;  //ki = analogRead(A3)*0.001;  Serial.print(&quot;  ki=&quot;);Serial.print(ki);&#xA;&#xA;  //kp = 0;  Serial.print(&quot;  kp=&quot;);Serial.print(kp);&#xA;  //kd = 0;  Serial.print(&quot;  kd=&quot;);Serial.print(kd);&#xA;  ki = 0.08;  &#xA;  Serial.print(&quot;  ki=&quot;);Serial.print(ki);&#xA;&#xA;  unsigned long now = millis();&#xA;  float dt = (now - preTime) / 1000.0;&#xA;  preTime = now;&#xA;  float K = 0.8;&#xA;  float A = K / (K + dt);&#xA;  f_angle = A * (f_angle + omega * dt) + (1 - A) * r_angle; &#xA;&#xA;  Serial.print(&quot;  f_angle=&quot;);Serial.print(f_angle);&#xA;&#xA;&#xA;  timeChange = (now - lastTime);&#xA;  if(timeChange &amp;gt;= SampleTime){&#xA;    Input = f_angle;&#xA;    error = Input;&#xA;    errSum += error * timeChange;&#xA;    dErr = (error - lastErr) / timeChange;&#xA;    Output = kp * error + ki * errSum + kd * dErr;&#xA;    LOutput = Output + Run_Speed + Turn_Speed;  Serial.print(&quot;  LOutput=&quot;);Serial.print(LOutput);&#xA;    ROutput = Output + Run_Speed - Turn_Speed;  Serial.print(&quot;  ROutput=&quot;);Serial.println(ROutput);&#xA;    lastErr = error;&#xA;    lastTime = now;&#xA;  }&#xA;}&#xA;&#xA;void PWMControl(){&#xA;  if(LOutput &amp;gt; 0){&#xA;    digitalWrite(TN1, HIGH);&#xA;    digitalWrite(TN2, LOW);&#xA;  }&#xA;  else if(LOutput &amp;lt; 0){&#xA;    digitalWrite(TN1, LOW);&#xA;    digitalWrite(TN2, HIGH);&#xA;  }&#xA;  else{&#xA;    digitalWrite(TN1, HIGH);&#xA;    digitalWrite(TN2, HIGH);&#xA;  }&#xA;  if(ROutput &amp;gt; 0){&#xA;    digitalWrite(TN3, HIGH);&#xA;    digitalWrite(TN4, LOW);&#xA;  }&#xA;  else if(ROutput &amp;lt; 0){   &#xA;    digitalWrite(TN3, LOW);&#xA;    digitalWrite(TN4, HIGH);&#xA;  }&#xA;  else{&#xA;    digitalWrite(TN3, HIGH);&#xA;    digitalWrite(TN4, HIGH);&#xA;  }&#xA;    analogWrite(ENA, min(255, abs(LOutput) + LMotor_offset));&#xA;    analogWrite(ENB, min(255, abs(ROutput) + RMotor_offset));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is a picture of the mpu6050 on the sensor shield &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/S8koh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10529" LastEditorUserId="10529" LastEditDate="2015-06-09T11:54:10.573" LastActivityDate="2015-06-09T16:17:18.037" Title="MPU6050 causing arduino not to run sketch" Tags="|arduino-uno|mpu6050|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12468" PostTypeId="1" AcceptedAnswerId="12492" CreationDate="2015-06-08T12:33:26.380" Score="1" ViewCount="286" Body="&lt;p&gt;I am interested in Arduino projects. I want to learn to develop my own Arduino based system. The problem is I am not sure which Adruino board must I start with. Any ideas are appreciated, I have searched many discussion forum but could not find a satisfactory answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Which Arduino Board should I start with?&lt;/li&gt;&#xA;&lt;li&gt;Is it possible to work on Arduino based projects without the board; like having a simulation of the board? If so how?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10528" LastActivityDate="2015-06-08T21:14:50.220" Title="Which Arduino Board should I start with?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12469" PostTypeId="2" ParentId="12468" CreationDate="2015-06-08T13:05:39.550" Score="0" Body="&lt;p&gt;Depending on your budget you could start with an Arduino Uno starter kit that will include the Arduino, breadboard and wires plus different sensors (like &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00K6PYGQ8&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; - but there are others with less peripherals and cheaper).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a lower budget you can still buy the arduino and many separate sensors/LEDs etc from eBay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By googling you'll find a lot of tutorials about getting started with the hardware that you bought.&lt;/p&gt;&#xA;" OwnerUserId="7699" LastActivityDate="2015-06-08T13:05:39.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12470" PostTypeId="1" CreationDate="2015-06-08T13:46:30.513" Score="0" ViewCount="136" Body="&lt;p&gt;I'm looking for some method to control an Arduino with voice commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could this work on this platform?&lt;/p&gt;&#xA;" OwnerUserId="10531" LastEditorUserId="10003" LastEditDate="2015-06-08T17:24:34.920" LastActivityDate="2015-06-08T21:11:49.443" Title="Can we control an Arduino with voice commands?" Tags="|arduino-uno|android|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12471" PostTypeId="1" CreationDate="2015-06-08T14:46:09.850" Score="0" ViewCount="1365" Body="&lt;p&gt;Is it possible to &quot;send&quot; a serial command to the device itself to see the response?&#xA;I have written a little routine based on a couple of serial sends and receives and want to see if that works out like I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a device (an AVR with arduino boot loader) and as part of my program, the device exchanges phrases with peripheral devices over a serial connection. Since I have right now just the arduino itself and can't really test, if at least the logic behind the serial part of works out, I would like to get serial commands from somewhere and trigger 'continuous talking', so I want to monitor the response behavior of my module, if it gets a certain command (stability reasons). Instead of waiting for a second device, is it possible to &quot;link the TX/RX line to itself&quot; internally or externally to test my program with itself?&lt;/p&gt;&#xA;" OwnerUserId="10532" LastEditorUserId="220" LastEditDate="2015-06-08T16:22:29.310" LastActivityDate="2015-08-08T13:18:38.270" Title="Sending serial commands to yourself" Tags="|serial|softwareserial|uart|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12473" PostTypeId="2" ParentId="10308" CreationDate="2015-06-08T15:51:10.013" Score="0" Body="&lt;p&gt;To prevent overflow problems, please, go to MPU6050_6Axis_MotionApps20.h and modify that line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x02,   0x16,   0x02,   0x00, **0x01**                // D_0_22 inv_set_fifo_rate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value in bold is the objective! Change it to &lt;code&gt;0x03&lt;/code&gt; or &lt;code&gt;0x04&lt;/code&gt; or &lt;code&gt;0x05&lt;/code&gt; to reduce the Hz of rate. I am using &lt;code&gt;0x03&lt;/code&gt; and not getting error values, junk data, or overflows anymore.&lt;/p&gt;&#xA;" OwnerUserId="10534" LastEditorUserId="220" LastEditDate="2015-06-09T13:17:43.860" LastActivityDate="2015-06-09T13:17:43.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12474" PostTypeId="1" CreationDate="2015-06-08T15:55:01.113" Score="0" ViewCount="628" Body="&lt;p&gt;I'm trying to read 5 analog inputs, but all the pins are reading the same as pin A0, plus or minus a couple points. I tried using pulldown resistors on all 5 pins and it made no difference. The board is a Leonardo. Thanks for any ideas/help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(115200);&#xA;    analogReference(EXTERNAL);&#xA;}&#xA;&#xA;void loop() {&#xA;    int A0, A1,A2,A3,A4;&#xA;    delay(200);&#xA;    A0= analogRead(A0);&#xA;    A1= analogRead(A1);&#xA;    A2= analogRead(A2);&#xA;    A3= analogRead(A3);&#xA;    A4= analogRead(A4);&#xA;&#xA;    Serial.print(A0);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(A1);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(A2);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(A3);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(A4);&#xA;    Serial.print(&quot;\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10533" LastActivityDate="2015-06-08T16:00:20.927" Title="Analog pins all reading same value" Tags="|arduino-leonardo|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12475" PostTypeId="2" ParentId="12474" CreationDate="2015-06-08T16:00:20.927" Score="6" Body="&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;int A0, A1,A2,A3,A4;&#xA;delay(200);&#xA;A0= analogRead(A0);&#xA;A1= analogRead(A1);&#xA;A2= analogRead(A2);&#xA;A3= analogRead(A3);&#xA;A4= analogRead(A4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your local variables (&lt;code&gt;A0&lt;/code&gt; through &lt;code&gt;A4&lt;/code&gt;) are shadowing the global variables for the pins (&lt;code&gt;A0&lt;/code&gt; through &lt;code&gt;A4&lt;/code&gt;). Give your local variables different names.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-08T16:00:20.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12476" PostTypeId="1" AcceptedAnswerId="12486" CreationDate="2015-06-08T16:05:42.707" Score="1" ViewCount="7914" Body="&lt;p&gt;I just want to confirm something before I wire up my first ever Arduino project and fry all the stuff I just spent money on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is my &lt;em&gt;understanding&lt;/em&gt; that the &lt;code&gt;Vin&lt;/code&gt; power input will tolerate a 9V battery and use voltage regulators to pare it down to either 3.3V or 5V (as different parts of the board require). So it is then my &lt;em&gt;assumption&lt;/em&gt; that if I have a 9V battery running to &lt;code&gt;Vin&lt;/code&gt;, that I could then connect a power wire to the &lt;code&gt;3.3V&lt;/code&gt; connector, and reliably get a 3.3V signal (and ditto for 5V), &lt;strong&gt;yes?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, is it that they are &lt;em&gt;input&lt;/em&gt; jacks &lt;em&gt;expecting&lt;/em&gt; either 3.3V or 5V signals? I guess I'm confused over this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Will &lt;code&gt;Vin&lt;/code&gt; then power the 3.3V and 5V inputs, giving me access to voltage at that level; or&lt;/li&gt;&#xA;&lt;li&gt;Do I have to choose between 3.3V, 5V or &lt;code&gt;Vin&lt;/code&gt;, and only use one of those to power my board (with the appropriate voltage level)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-06-08T18:37:31.467" Title="Arduino Due and Vin, 3.3V and 5V power inputs" Tags="|power|arduino-due|voltage-level|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12477" PostTypeId="1" AcceptedAnswerId="12478" CreationDate="2015-06-08T16:12:57.473" Score="1" ViewCount="1536" Body="&lt;p&gt;I am trying to understand what each pin on my Arduino Due is and what it is used for, and so I have been searching for things like &quot;&lt;em&gt;Arduino Due pinout&lt;/em&gt;&quot;, &quot;&lt;em&gt;Arduino Due pin mapping&lt;/em&gt;&quot; and similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best I could find was &lt;a href=&quot;http://www.arduino.cc/en/Hacking/PinMappingSAM3X&quot; rel=&quot;nofollow&quot;&gt;this table&lt;/a&gt;, however it doesn't help you out at all if you are completely new to electronics and have no idea what &lt;code&gt;TX2&lt;/code&gt;, &lt;code&gt;SDA&lt;/code&gt; or &lt;code&gt;NPCSO&lt;/code&gt; mean, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know of Arduino/Due documentation that explains what each I/O pin is?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2017-10-12T01:42:04.703" Title="Arduino Due Pinout with Explanations?" Tags="|pins|arduino-due|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12478" PostTypeId="2" ParentId="12477" CreationDate="2015-06-08T16:23:37.467" Score="1" Body="&lt;p&gt;The Arduino Due is backed by an Atmel SAM3X8E ARM Cortex-M3 microprocessor and most of the pins on the Due are connected directly to this chip. Therefore, you can refer directly to the chip's datasheet for descriptions of these hardware features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmel SAM3X8E ARM Cortex-M3 datasheet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10535" LastActivityDate="2015-06-08T16:23:37.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12479" PostTypeId="2" ParentId="12460" CreationDate="2015-06-08T16:31:25.313" Score="1" Body="&lt;p&gt;The bottom of your board shows a chip that gives every hint of being a charge-pump logic-level to RS232 inverting level shifter, to translate from the SIM900A's levels to the RS232 D-Sub connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would appear that the 3 pin header just inside the D-sub would allow you to communicate at these levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, a quick look at the SIM900A docs I could find &lt;strong&gt;suggests that these logic levels may be 2.8v, NOT 3.3v, and 3.3v is actually outside absolute maximum rating!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, you have two problems: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You need to drive and read signals with 2.8v logic, either by modifying your arduino to run at that voltage, or by using a level shifter.  It's possible that a resistor would protect the SIM900A, but that is going to be the most expensive component and so short of finding solid evidence of input protection diodes I'd be more hesitant to do that here than I would in other cases.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You need to make the level shifter not drive a signal into the SIM900A, so you don't fight with it.  You could do this by looking in the documenation (if any) for your board and seeing what accommodations they made for this, looking up the level shifter's  data sheet and finding the enable pin, or merely desoldering it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Another option would be to make your Arduino talk at RS232 levels using its own shifter board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there's a sort of hackish option:  Connect the &lt;em&gt;transmit&lt;/em&gt; data from the SIM900A to a 3.3v Arduino, but connect the transmit from the Arduino through a simple inverter (tinylogic, whatever) to the RS232 &lt;em&gt;receive&lt;/em&gt; pin.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-06-08T16:31:25.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12480" PostTypeId="1" AcceptedAnswerId="12485" CreationDate="2015-06-08T17:11:42.157" Score="4" ViewCount="6188" Body="&#xA;&#xA;&lt;p&gt;I'm trying to create a code using an Arduino Uno board to increment and decrement the output voltage of the Arduino Uno which is 5 volts and I need to step it up to 10 volts which I have done below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The things that are missing on the schematic are two buttons. I want to be able to increment 0.5 volts with each press of Button-A until the Arduino is at 5 volts. With Button-B I want to be able to lower the voltage by 0.5 volts with each press of the button till value is 0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can do the calculations and the circuit design but I'm not much of a programmer. I just want to know if anyone can point me in a good direction of where I can get the right code. I have already looked at all the tutorials on the Arduino Website. I do know I have to work with the PWM functions as well as &lt;code&gt;attachinterrupt()&lt;/code&gt; and &lt;code&gt;Debounce()&lt;/code&gt; functions. Also, how do I set the increments so that I don't go over, say it takes 10 presses to get to 5 volts on the 11th press have it not do anything so I don't break anything. So can anyone please help me with any suggestions? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a low pass filter on the circuit for noise handling and like I said I need to add in the buttons to my schematic. &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sMiDk.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fsMiDk.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code I have made. I'm using an LED to test the V&lt;sub&gt;out&lt;/sub&gt; aspect. So far I can only get my LED to flicker from 2 to 4 volts and my buttons A and B don't work. Can someone look over my code and see how bad I made this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int PWMPin = 6; // output pin supporting PWM  &#xA;int buttonApin = 9; // buttonA to pin 9 PWM  &#xA;int buttonBpin = 10; // buttonB to pin 10 PWM  &#xA;float value = 0; // read the value at 0  &#xA;int fadeValue = value;  &#xA;&#xA;void setup()    &#xA;{   &#xA;  Serial.begin(9600); //initialize serial communication at 9600 baud  &#xA;  pinMode(buttonApin, INPUT_PULLUP);   &#xA;  pinMode(buttonBpin, INPUT_PULLUP);  &#xA;  pinMode(PWMPin, OUTPUT);  &#xA;}   &#xA;void loop()    &#xA;{   &#xA;  {  &#xA;    int port = analogRead(0);  &#xA;    port = map(port, 0, 10, 0, 255);  &#xA;    analogWrite(6, port);  &#xA;  }  &#xA;&#xA;  {  &#xA;  if (digitalRead(buttonApin) == LOW, fadeValue)  &#xA;  {  &#xA;  // fade from min to max in increments of 25.5 points: basically (0.5 volts)  &#xA;  for(int fadeValue = 0 ; fadeValue &amp;lt;= 255; fadeValue +=25.5)   &#xA;&#xA;    digitalWrite(PWMPin, fadeValue);  &#xA;&#xA;    // sets the value (range from 0 to 255):  &#xA;   Serial.println(PWMPin);  &#xA;   analogWrite(PWMPin, fadeValue);                                       &#xA;  }   &#xA;  }  &#xA;&#xA;  {   &#xA;    if (digitalRead(buttonBpin) == LOW, fadeValue)  &#xA;  {  &#xA;  // fade from max to min in increments of 25.5 points:  &#xA;  for(int fadeValue = 255 ; fadeValue &amp;gt;= 0; fadeValue -=25.5)   &#xA;&#xA;    digitalWrite(PWMPin, fadeValue);  &#xA;&#xA;  // sets the value (range from 0 to 255): basically (0.5 volts)  &#xA;  analogWrite(PWMPin, fadeValue);                                     &#xA;  }  &#xA;  }   &#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10541" OwnerDisplayName="A-UNO help " LastEditorUserId="10794" LastEditDate="2015-09-20T22:11:13.937" LastActivityDate="2015-09-20T22:11:13.937" Title="How to increment and decrement an output voltage by using two buttons?" Tags="|arduino-uno|c++|pwm|analogread|hardware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12481" PostTypeId="2" ParentId="12476" CreationDate="2015-06-08T17:40:28.470" Score="0" Body="&lt;p&gt;Yes your assumption is correct you can power 3.3v and 5v items from those pins as long as you don't take more current than the onboard regulator(s) can supply&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-06-08T17:40:28.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12482" PostTypeId="2" ParentId="12471" CreationDate="2015-06-08T17:57:12.100" Score="1" Body="&lt;p&gt;Yes, you can do that by cross-connecting the transmit and receive pins on the Arduino. But then your devices sits there silently murmuring to itself (or not...) and you can't really tell what it's saying, or if it's doing anything unless you can observe some other hardware - LEDs, a 'scope, f/ex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why not hand-type or script some messages to it on your PC? If the Arduino sketch would make some brief, coherent replies you could confirm what it's doing and debug it if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done just this in your situation: Two of us defined a serial protocol - the ASCII (for human readability!) commands and replies that either end could make or expect. Then each of us wrote the communication code for one of the two devices and proved that it met the protocol. Once both of us had finished and were confident in our respected communication code, we plugged the two devices together, and - they played! Nicely! :)  And if they hadn't we could have eavesdropped on the serial line and printed their attempted conversation to discover where it went wrong.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-08-08T13:18:38.270" LastActivityDate="2015-08-08T13:18:38.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12483" PostTypeId="2" ParentId="12480" CreationDate="2015-06-08T18:05:59.267" Score="4" Body="&lt;p&gt;If all you have to do is to read those 2 buttons, you could just forgo the interrupts and simply poll in the main loop.&#xA;The &lt;a href=&quot;http://playground.arduino.cc/Code/Bounce&quot; rel=&quot;nofollow&quot;&gt;Bounce2 library&lt;/a&gt; does basically the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, about the PWM, why not an R-2R?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;10V/0.5V + 1 =&gt; 21 steps &amp;lt; 32 =&gt; 5 bits =&gt; 6 resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it could be more precise, as you would not depend on the oscillator, rather on the precision of the resistors.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="6936" LastEditDate="2015-09-20T19:43:37.003" LastActivityDate="2015-09-20T19:43:37.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12484" PostTypeId="2" ParentId="12470" CreationDate="2015-06-08T18:17:52.277" Score="1" Body="&lt;p&gt;Yes possible on some of the high end Arduinos, but I know of no example where it has been done. The quality of recognition will be proportional to the processing power provided. In the case of an Arduino, probably not at an acceptable level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be much better off looking at the multitudes of PC solutions, and using the Arduino as an interface to what ever it is you plan on controlling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: &lt;a href=&quot;https://www.sparkfun.com/products/13316&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/13316&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-06-08T21:11:49.443" LastActivityDate="2015-06-08T21:11:49.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12485" PostTypeId="2" ParentId="12480" CreationDate="2015-06-08T18:19:15.447" Score="3" Body="&#xA;&#xA;&lt;p&gt;I suggest you to use debounce to detect if a pin has been definitely pressed. You could also test using interrupts (hint: interrupts can happen multiple times even if you &quot;only&quot; pressed once). So either use Arduino's example of debounce or take a look at the &lt;a href=&quot;http://playground.arduino.cc/Code/Bounce&quot; rel=&quot;nofollow&quot;&gt;Bounce2 library&lt;/a&gt; found on their website. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that you can check whether or not either button A or B has been pressed, how do you keep track of the voltage to be output? You should use a &lt;code&gt;counter&lt;/code&gt; variable that will be incremented when button A is pressed and decremented when button B is pressed. Here is a pseudocode: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if(ButtonA == pressed) &#xA;  counter++; &#xA;else if(ButtonB == pressed) &#xA;  counter--;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &lt;code&gt;counter&lt;/code&gt; variable can be used to control the output voltage. Remember that the argument for &lt;code&gt;analogWrite()&lt;/code&gt; function on the Arduino Uno is the duty cycle which takes in values from 0 to 255. So &lt;code&gt;analogWrite(0)&lt;/code&gt; ≣ 0 Volt and &lt;code&gt;analogWrite(255)&lt;/code&gt; ≣ 5 Volt. So at the moment, you couldn't just do &lt;code&gt;analogWrite(counter)&lt;/code&gt; because you would need to press 255 times button A!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you would need a way to convert your counter to reflect the increment you need. You mentioned that it should require 10 presses to reach 5 Volt at the Arduino output, and the easiest way to accomplish this is to use Arduino's &lt;a href=&quot;http://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;Map function&lt;/a&gt;. The pseudocode would look like this: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Output = map(counter, 0, 10, 0, 255); &#xA;analogWrite(Output); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now there is one last step! The map function will limit the output voltage from 0 to 5 Volt so everything will be safe; however, the counter is not limited to 0 to 10. This means that even if the counter is at 15 (because you pressed button A too many times) the voltage will be 5 Volt and you would need to press button B at least 6 times to see the voltage go down! So to limit the counter you could easily implement your own function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if(counter &amp;gt;= 10) &#xA;  counter = 10; &#xA;else if (counter&amp;lt;= 0) &#xA;  counter = 0; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could also use Arduino's &lt;code&gt;constrain()&lt;/code&gt; function which more information can be found on their website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully this points you in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="10536" LastEditorUserId="10794" LastEditDate="2015-09-20T22:07:54.267" LastActivityDate="2015-09-20T22:07:54.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12486" PostTypeId="2" ParentId="12476" CreationDate="2015-06-08T18:37:31.467" Score="3" Body="&lt;p&gt;&lt;code&gt;DC Jack&lt;/code&gt; is connected, through a diode, to &lt;code&gt;Vin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Vin&lt;/code&gt; is stepped down to &lt;code&gt;5V&lt;/code&gt; on-board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;5V&lt;/code&gt; is stepped down to &lt;code&gt;3V3&lt;/code&gt; on board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you can do any one of the following numbered items.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect a 7-12V supply to the &lt;code&gt;DC Jack&lt;/code&gt;; thus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;Vin&lt;/code&gt; as a supply @ DC - 0.7V for off-board peripherals, and&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;5V&lt;/code&gt; as a supply for off-board peripherals, and&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;3V3&lt;/code&gt; as a supply for off-board peripherals.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect a 6-12V supply to &lt;code&gt;Vin&lt;/code&gt;; thus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;5V&lt;/code&gt; as a supply for off-board peripherals, and&lt;/li&gt;&#xA;&lt;li&gt;use &lt;code&gt;3V3&lt;/code&gt; as a supply for off-board peripherals.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect 5V supply to the &lt;code&gt;5V&lt;/code&gt;; thus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use &lt;code&gt;3V3&lt;/code&gt; as a supply for off-board peripherals.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The above is only guaranteed for boards that &lt;strong&gt;follow the reference schematic&lt;/strong&gt;, as plenty of clone/compatible boards do. If you buy a cheap Chinarduino and something doesn't work, or the thing breaks, after following anything above then that's your tough luck.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-08T18:37:31.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12489" PostTypeId="2" ParentId="12426" CreationDate="2015-06-08T19:11:10.303" Score="0" Body="&lt;p&gt;If ((current distance - previous distance) &amp;lt; 0)&#xA;Max = previous distance;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current distance = previous distance;&lt;/p&gt;&#xA;" OwnerUserId="10539" LastActivityDate="2015-06-08T19:11:10.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12490" PostTypeId="1" CreationDate="2015-06-08T20:44:21.747" Score="0" ViewCount="1152" Body="&lt;p&gt;Hey I just started using arduino and so far can't get any help with how to write a code for an led to turn on when someone gets in range of a three pin ultrasonic sensor, and off when they are out of a specific range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help?&lt;/p&gt;&#xA;" OwnerUserId="10543" LastActivityDate="2020-10-25T22:01:35.157" Title="how to make an led turn on when something gets close to an ultrasonic sensor" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12491" PostTypeId="2" ParentId="12490" CreationDate="2015-06-08T21:03:46.607" Score="1" Body="&lt;p&gt;Try with this and check that at least you can reproduce the desired effect:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can refer to this for the part related to driving the LED:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Blink?from=Tutorial.BlinkingLED&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/Blink?from=Tutorial.BlinkingLED&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ultra sound demo already calculates the distance, you can do the test on that to decide when to turn ON/OFF the LED.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-08T21:03:46.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12492" PostTypeId="2" ParentId="12468" CreationDate="2015-06-08T21:14:50.220" Score="1" Body="&lt;p&gt;My advice:&#xA; - get a model with USB port (some do not have one)&#xA; - the DUE might seem attractive, but you have less libraries available and less examples, I'd recommend it more as follow up&#xA; - you will get frustrated if you do not know how to code, at least a bit, so if you have not programmed before, you might want to spend some time trying simple stuff just with your PC&#xA; - same about electronics: if you do not have previous experience, it might be preferable to play a bit with a breadboard and some components (LEDs, resistors, switches, etc.); this will reduce the likelyhood that you fry your Arduino. Remember to buy some cables MM/MF/FF, you will end up needing all of them, sooner or later. For powering the board, you can find nice power supplies that cn be powered by a USB cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have bought UNOR3 clones at $4-$5 on ebay, so if you can afford it, I'd suggest you buy a couple, that will enable you playing with I2C master slave and similar configurations.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-08T21:14:50.220" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12493" PostTypeId="2" ParentId="12466" CreationDate="2015-06-08T21:28:16.777" Score="0" Body="&lt;p&gt;The shield you linked to is no longer sold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current version is&#xA;&lt;img src=&quot;https://i.stack.imgur.com/F7ccO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it has no special connection for an MPU6050 breakout (and BTW that same 6050 board is $6 about everywhere else).  A shield serves no purpose for just the 6050 really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you connected the 6050 to the I2C lines (aka A4 &amp;amp; A5), Then you also need to connect an additional interrupt line.  If you are using unmodified example code, it depends on the interrupt being connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a post made a while back using the 6050&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.spiked3.com/very-cool-imu-demo/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.spiked3.com/very-cool-imu-demo/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use the 6050 without interrupts but you would have to (understand and) modify the standard example code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I knew you had a different board, and it had a connector for the 6050, the comment was that the link you provided, since it was 'no longer available', did not link to any documentation. Without a schematic it can not be known how it is hooked up beyond simple I2C. As you are using other devices I am not familiar with, I would expect some sort of conflict on the i2C bus maybe. Are all i2c bus devices using the same reference voltage? It does not matter if they are all 5v or all 3.3V as long as they are all the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you say 'nothing is printed' and your second line of setup is 'initialize' gyro, odds are good it is not getting past that. Simple (archaic) debugging, put a print (and a small delay) before and after the call to initialize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code uses the following for Wire.begin&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    Wire.begin();&#xA;    TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)&#xA;#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;    Fastwire::setup(400, true);&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I dont know if your Arduino is different and if it would make any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a line after initialize&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mpu.testConnection();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That may or may not help you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI PI is already defined, as is DEG_TO_RAD and RAD_TO_DEG&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (abs(RAD_TO_DEG * headingDelta) &amp;gt; .1F)&#xA;    poseChanged = true;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update: I just looked quickly at the code, and the only thing initialize does is write to i2c, it never waits really. And that means writing to I2C is hanging.  I ran into this once when I had an unpowered device on the bus. I thought it would not harm, but I was wrong.  Does the power light on the mpu come on? (is it really getting power?)  I have run them at 3.3v and 5V so I do not think that would be a problem, but  if you can, switch it to 3.3V to be sure. Getting down to the nitty gritty, you could check if the default pullup resistors are still on the board and did not get accidentally knocked off. Even better would be to try it with a known good MPU.  I have about 10 of them within reach :P (spiked3.com)&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-06-09T16:17:18.037" LastActivityDate="2015-06-09T16:17:18.037" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12494" PostTypeId="1" CreationDate="2015-06-09T00:49:58.067" Score="4" ViewCount="4872" Body="&lt;p&gt;I am trying to connect my Arduino Uno board with SeeedStudio Can Bus Shield to my 2006 325i BMW. After compiling and uploading the example program by SeeedStudio, the serial monitor returns &quot;Can Bus Shield Init ok!&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// demo: CAN-BUS Shield, receive data with check mode&#xA;// send data coming to fast, such as less than 10ms, you can use this way&#xA;// loovee, 2014-6-13&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;mcp_can.h&quot;&#xA;&#xA;// the cs pin of the version after v1.1 is default to D9&#xA;// v0.9b and v1.0 is default D10&#xA;const int SPI_CS_PIN = 9;&#xA;&#xA;MCP_CAN CAN(SPI_CS_PIN); // Set CS pin&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;START_INIT:&#xA;  if(CAN_OK == CAN.begin(CAN_500KBPS)) {&#xA;  // init can bus : baudrate = 500k&#xA;    Serial.println(&quot;CAN BUS Shield init ok!&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;CAN BUS Shield init fail&quot;);&#xA;    Serial.println(&quot;Init CAN BUS Shield again&quot;);&#xA;    delay(100);&#xA;    goto START_INIT;&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA;  unsigned char len = 0;&#xA;  unsigned char buf[8];&#xA;  if(CAN_MSGAVAIL == CAN.checkReceive()) {&#xA;    // check if data coming&#xA;    CAN.readMsgBuf(&amp;amp;len, buf);&#xA;    // read data,  len: data length, buf: data buf&#xA;    unsigned char canId = CAN.getCanId();&#xA;    Serial.println(&quot;-----------------------------&quot;);&#xA;    Serial.println(&quot;get data from ID: &quot;);&#xA;    Serial.println(canId);&#xA;    for(int i = 0; i&amp;lt;len; i++) {&#xA;      // print the data&#xA;      Serial.print(buf[i]);&#xA;      Serial.print(&quot;\t&quot;);&#xA;    }&#xA;    Serial.println();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I get the initialize statement returned but I'm not receiving any data. It seems like the &lt;code&gt;if(CAN_MSGAVAIL == CAN.checkReceive())&lt;/code&gt; statement isn't executed. I found my vehicle's Can high and Can low wires and inserted them into my Can Bus Shield. So I'm not sure if it's a code problem or if the wires aren't transmitting the data to the shield. Any help would be great. &lt;/p&gt;&#xA;" OwnerUserId="10544" LastEditorUserId="3917" LastEditDate="2015-12-03T22:05:31.630" LastActivityDate="2017-03-29T10:48:10.217" Title="Can Bus Shield Not Receiving Data" Tags="|arduino-uno|serial|can-bus|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="12496" PostTypeId="1" AcceptedAnswerId="12499" CreationDate="2015-06-09T02:21:34.030" Score="0" ViewCount="243" Body="&lt;p&gt;I am busy toying with some PIR sensors to detect movement etc for a nightlight for my kids. One of the sensors I ordered is the PYM-1 PIR sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data sheet states the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Operating Voltage: 4,5~5V.&lt;/li&gt;&#xA;&lt;li&gt;Standby current: 65 micro-amps (65uA)&lt;/li&gt;&#xA;&lt;li&gt;Operating Current: 40mA (40 milli-amps)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The limit for current on the arduino pins is 40mA. According to documentation at the arduino site 40mA is the upper limit per pin and the site clearly states: Absolute Maximum Ratings - the point where damage will start to happen I would rather avoid sinking the current directly on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is will sinking 40mA on a pin cause damage? I have not been visited by the blue smoke genie yet and would rather avoid it at this point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it might be safer to run this via a transistor and external power than directly on the arduino?&lt;/p&gt;&#xA;" OwnerUserId="3897" LastActivityDate="2015-06-09T11:45:21.037" Title="PYM-1 PIR sensor current concerns" Tags="|arduino-uno|arduino-mega|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12497" PostTypeId="2" ParentId="12496" CreationDate="2015-06-09T02:53:13.370" Score="1" Body="&lt;p&gt;When I look at the PYM-1 seen here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/Infrared-PIR-Human-Sensor-NEW-Arrival-Pyroelectric-DIY-Kit-PYM-1-for-Arduino-/271677900953&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/Infrared-PIR-Human-Sensor-NEW-Arrival-Pyroelectric-DIY-Kit-PYM-1-for-Arduino-/271677900953&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see any need for an external microprocessor such as an Arduino.  It seems that one just applies 5V as input and it switches on/off up to 300W of power.  Where would one use an Arduino GPIO?&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-09T02:53:13.370" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12498" PostTypeId="2" ParentId="4932" CreationDate="2015-06-09T03:21:51.133" Score="0" Body="&lt;p&gt;You can just have a sketch in the arduino that takes the measurements at whatever interval you want using the &lt;code&gt;analogRead(pin)&lt;/code&gt; function and then forward those results to the raspberry pi via serial using &lt;code&gt;Serial.print(whatever you want here)&lt;/code&gt;. If you don't know how to use serial with arduino just go to their site, they have very good documentation.&#xA;Hope that helps :)&lt;/p&gt;&#xA;" OwnerUserId="10546" LastActivityDate="2015-06-09T03:21:51.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12499" PostTypeId="2" ParentId="12496" CreationDate="2015-06-09T09:27:12.793" Score="2" Body="&lt;p&gt;This is completely acceptable for your intended purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By itself it will act as a light on/off trigger as others have noted.&lt;br&gt;&#xA;An Arduino could be added if you wish to add extra features when the PIR is triggered. In it's most basic light-switching form using an Arduino is overkill. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By itself it will act as a light on/off trigger as others have noted.&lt;br&gt;&#xA;An Arduino could be added if you wish to add extra features when the PIR is triggered. In it's most basic light-switching form adding an Arduino is overkill. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it comes to playing overkill can be good :-)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To use it to provide input to an Arduino and NOT to a mains level light:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NB&lt;/strong&gt; relay contacts may only be connected to mains for light switching &lt;strong&gt;OR&lt;/strong&gt; to the Arduino. &lt;strong&gt;NEVER&lt;/strong&gt; to both at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect it's DC supply input to your Arduino (or other) power supply.&lt;br&gt;&#xA;As long as the &lt;strong&gt;supply&lt;/strong&gt; can provide 40 mA when needed it will work OK.&lt;br&gt;&#xA;40 mA is a &lt;strong&gt;power supply&lt;/strong&gt; rating This is unrelated to the Arduino pin loading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the output to an Arduino digital pin configured as an input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HrPkj.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output is a relay, activated when an object is sensed.&lt;br&gt;&#xA;When inactive the centre pin is probably connected to the right pin - Check with Ohm meter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When activated the left pin in connected to the centre pin (see their diagram)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect ground to right pin.&lt;br&gt;&#xA;Connect Arduino digital input to centre pin.&#xA;Connect a &quot;high&quot; level to left hand pin.&lt;br&gt;&#xA;OR as Majenko suggests, just set the pin to have pullups enabled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If connecting to V+ as shown then V+ can be Vcc  (=5V for a 5V Arduino, 3v3 for a 3V3 Arduino) &#xA;DO NOT set V+ to higher than Arduino's Vcc. &#xA;You can connect a say 1k to 10k resistor from V+ to the voltage source bur still do not set V+ above Vcc.&lt;br&gt;&#xA;OK - just have pullups enabled:-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg (untested)  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;int ADCMode = 0;&lt;br&gt;&#xA;   int PIRPin = 6;                 // PIR connected to digital pin 6&lt;br&gt;&#xA;   void setup()&lt;br&gt;&#xA;   {&lt;br&gt;&#xA;     pinMode(PIRPin, INPUT_PULLUP); // set PIRpin as input with pullup&lt;br&gt;&#xA;   }&lt;br&gt;&#xA;   void loop()&lt;br&gt;&#xA;   {&lt;br&gt;&#xA;    ...&lt;br&gt;&#xA;     ADCMode  = digitalRead(PIRpin);   // $Read PIR status&lt;br&gt;&#xA;   ...&lt;br&gt;&#xA;   }  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When the circuit activates digitalRead() will return a high.&lt;br&gt;&#xA;When the circuit is not activated digitalRead() will return a low. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; re Arduino pin modes &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-06-09T11:45:21.037" LastActivityDate="2015-06-09T11:45:21.037" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12500" PostTypeId="1" CreationDate="2015-06-09T12:15:55.183" Score="3" ViewCount="1463" Body="&lt;p&gt;I have connected Arduino with ESP8266 with&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino pin 2 connected to ESP's Tx Arduino pin 3 connected to ESP's Rx via Voltage Divider Arduino GND connected to ESP's GND Arduino 3v3 connected to ESP's CH_PD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have powered ESP8266 using 1117 Voltage regulator&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I initially bought ESP8266 it was working properly(I could even set up a server) but now when I connect it to Arduino an endless stream of garbage values is seen on the Serial Monitor...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino is programmed with the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;                             // and the RX line from the esp to the Arduino's pin 3&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); // your esp's baud rate might be different&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(esp8266.available()) // check if the esp is sending a message &#xA;  {&#xA;    while(esp8266.available())&#xA;    {&#xA;      // The esp has data so display its output to the serial window &#xA;      char c = esp8266.read(); // read the next character.&#xA;      Serial.write(c);&#xA;    }  &#xA;  }&#xA;&#xA;&#xA;&#xA;  if(Serial.available())&#xA;  {&#xA;    // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest&#xA;    // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it&#xA;    // but we want to send everything at the same time.&#xA;    delay(1000); &#xA;&#xA;    String command=&quot;&quot;;&#xA;&#xA;    while(Serial.available()) // read the command character by character&#xA;    {&#xA;        // read one character&#xA;      command+=(char)Serial.read();&#xA;    }&#xA;    esp8266.println(command); // send the read character to the esp8266&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7045" LastEditorUserId="7045" LastEditDate="2015-06-09T14:50:08.310" LastActivityDate="2015-12-17T10:56:43.247" Title="ESP8266 and Arduino Interfacing" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12502" PostTypeId="2" ParentId="11764" CreationDate="2015-06-09T13:07:57.920" Score="2" Body="&lt;p&gt;Configure your Bluetooth module to AT Command Mode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then use &lt;code&gt;AT+PIN&lt;/code&gt; Command to change the default PAIRING PIN of the Bluetooth Module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visit &lt;a href=&quot;http://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; for more information about how to configure bluetooth to AT Mode&lt;/p&gt;&#xA;" OwnerUserId="7045" LastActivityDate="2015-06-09T13:07:57.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12503" PostTypeId="1" CreationDate="2015-06-09T14:52:32.090" Score="2" ViewCount="142" Body="&lt;p&gt;I need some help. I use function rx_setup()  оf library VirtualWire.h which is used to transmit information wirelessly. The function use timer аnd there is  conflict with any of the other libraries. Does anyone know how I can change the timer, which uses function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void vw_setup(uint16_t speed)&#xA;{&#xA;    uint16_t nticks; // number of prescaled ticks needed&#xA;    uint8_t prescaler; // Bit values for CS0[2:0]&#xA;&#xA;#ifdef __AVR_ATtiny85__&#xA;    // figure out prescaler value and counter match value&#xA;    prescaler = _timer_calc(speed, (uint8_t)-1, &amp;amp;nticks);&#xA;    if (!prescaler)&#xA;    {&#xA;        return; // fault&#xA;    }&#xA;&#xA;    TCCR0A = 0;&#xA;    TCCR0A = _BV(WGM01); // Turn on CTC mode / Output Compare pins disconnected&#xA;&#xA;    // convert prescaler index to TCCRnB prescaler bits CS00, CS01, CS02&#xA;    TCCR0B = 0;&#xA;    TCCR0B = prescaler; // set CS00, CS01, CS02 (other bits not needed)&#xA;&#xA;    // Number of ticks to count before firing interrupt&#xA;    OCR0A = uint8_t(nticks);&#xA;&#xA;    // Set mask to fire interrupt when OCF0A bit is set in TIFR0&#xA;    TIMSK |= _BV(OCIE0A);&#xA;&#xA;#elif defined(__arm__) &amp;amp;&amp;amp; defined(CORE_TEENSY)&#xA;    // on Teensy 3.0 (32 bit ARM), use an interval timer&#xA;    IntervalTimer *t = new IntervalTimer();&#xA;    t-&amp;gt;begin(TIMER1_COMPA_vect, 125000.0 / (float)(speed));&#xA;&#xA;#else // ARDUINO&#xA;    // This is the path for most Arduinos&#xA;    // figure out prescaler value and counter match value&#xA;    prescaler = _timer_calc(speed, (uint16_t)-1, &amp;amp;nticks);&#xA;    if (!prescaler)&#xA;    {&#xA;        return; // fault&#xA;    }&#xA;&#xA;    TCCR1A = 0; // Output Compare pins disconnected&#xA;    TCCR1B = _BV(WGM12); // Turn on CTC mode&#xA;&#xA;    // convert prescaler index to TCCRnB prescaler bits CS10, CS11, CS12&#xA;    TCCR1B |= prescaler;&#xA;&#xA;    // Caution: special procedures for setting 16 bit regs&#xA;    // is handled by the compiler&#xA;    OCR1A = nticks;&#xA;    // Enable interrupt&#xA;#ifdef TIMSK1&#xA;    // atmega168&#xA;    TIMSK1 |= _BV(OCIE1A);&#xA;#else&#xA;    // others&#xA;    TIMSK |= _BV(OCIE1A);&#xA;#endif // TIMSK1&#xA;&#xA;#endif // __AVR_ATtiny85__&#xA;&#xA;    // Set up digital IO pins&#xA;    pinMode(vw_tx_pin, OUTPUT);&#xA;    pinMode(vw_rx_pin, INPUT);&#xA;    pinMode(vw_ptt_pin, OUTPUT);&#xA;    digitalWrite(vw_ptt_pin, vw_ptt_inverted);&#xA;}&#xA;&#xA;#endif // ARDUINO&#xA;&#xA;// Start the transmitter, call when the tx buffer is ready to go and vw_tx_len is&#xA;// set to the total number of symbols to send&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8289" LastActivityDate="2015-06-09T14:52:32.090" Title="Rf receiver, change timer" Tags="|arduino-uno|timers|rf|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12504" PostTypeId="2" ParentId="12237" CreationDate="2015-06-09T15:02:26.207" Score="1" Body="&lt;p&gt;I used the following code to run a program, not from the arduino, but from software listening to a specific character sent from the arduino.  Thanks for your help.  I share the code that I used.  It doesn´t need to print the character, but I copied it exactlyy from microsoft help pages (lost the link). I just aded the if statement and the start.process part (I got this from a stackoverflow answer).  Without any further delay:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;using System;&#xA;using System.IO.Ports;&#xA;using System.Diagnostics;&#xA;&#xA;class PortDataReceived&#xA;{&#xA;    public static void Main()&#xA;    {&#xA;        SerialPort mySerialPort = new SerialPort(&quot;COM3&quot;);&#xA;&#xA;        mySerialPort.BaudRate = 9600;&#xA;        mySerialPort.Parity = Parity.None;&#xA;        mySerialPort.StopBits = StopBits.One;&#xA;        mySerialPort.DataBits = 8;&#xA;        mySerialPort.Handshake = Handshake.None;&#xA;        mySerialPort.RtsEnable = true;&#xA;&#xA;        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);&#xA;&#xA;        mySerialPort.Open();&#xA;&#xA;        Console.WriteLine(&quot;Press any key to continue...&quot;);&#xA;        Console.WriteLine();&#xA;        Console.ReadKey();&#xA;        mySerialPort.Close();&#xA;    }&#xA;&#xA;    private static void DataReceivedHandler(&#xA;                        object sender,&#xA;                        SerialDataReceivedEventArgs e)&#xA;    {&#xA;        SerialPort sp = (SerialPort)sender;&#xA;        string indata = sp.ReadExisting();&#xA;        Console.WriteLine(&quot;Data Received:&quot;);&#xA;        Console.Write(indata);&#xA;        if (indata == &quot;c&quot;)&#xA;        {&#xA;            Process.Start(@&quot;C:\Users\Laptop\Desktop\print.ahk&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10346" LastActivityDate="2015-06-09T15:02:26.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12505" PostTypeId="1" CreationDate="2015-06-09T08:34:27.020" Score="0" ViewCount="585" Body="&lt;p&gt;I'm working on my project car, and I have decided I would like to have a GPS and log some sensors too. I'm just at a bottle neck here, the sensors I have brought pull about 7v each where I can't pull that much from the breakout board that I have, and I can't seam to get the GPS to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using ths code but software serial isn't supported on the edison: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// GPS Setup&#xA;#define rxGPS 0&#xA;#define txGPS 1&#xA;SoftwareSerial serialGPS = SoftwareSerial(rxGPS, txGPS);&#xA;String stringGPS = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;  pinMode(rxGPS, INPUT);&#xA;  pinMode(txGPS, OUTPUT);&#xA;&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Started&quot;);&#xA;&#xA;  // GPS Setup&#xA;  serialGPS.begin(4800);&#xA;  digitalWrite(txGPS,HIGH);&#xA;&#xA;  // Cut first gibberish&#xA;  while(serialGPS.available())&#xA;    if (serialGPS.read() == '\r')&#xA;      break;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  String s = checkGPS();&#xA;  if(s &amp;amp;&amp;amp; s.substring(0, 6) == &quot;$GPGGA&quot;)&#xA;  {&#xA;    Serial.println(s);&#xA;  }&#xA;}&#xA;&#xA;// Check GPS and returns string if full line recorded, else false&#xA;String checkGPS()&#xA;{&#xA;  if (serialGPS.available())&#xA;  {&#xA;    char c = serialGPS.read();&#xA;    if (c != '\n' &amp;amp;&amp;amp; c != '\r')&#xA;    {&#xA;      stringGPS  = c;&#xA;    }&#xA;    else&#xA;    {&#xA;      if (stringGPS != &quot;&quot;)&#xA;      {&#xA;        String tmp = stringGPS;&#xA;        stringGPS = &quot;&quot;;&#xA;        return tmp;&#xA;      }&#xA;    }&#xA;  }&#xA;  return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas or help would be much appreciated&lt;/p&gt;&#xA;" OwnerUserId="10570" OwnerDisplayName="bedrock" LastActivityDate="2020-10-26T02:03:10.340" Title="GPS logging on the intel edison breakout board" Tags="|c|gps|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12506" PostTypeId="2" ParentId="12505" CreationDate="2015-06-09T12:16:44.130" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String GPSLine;&#xA;&#xA;bool checkGPS()&#xA;{&#xA;  while(serialGPS.available())&#xA;  {&#xA;    char c = serialGPS.read();&#xA;    if(c == '\n') return true;&#xA;    if(c == '\r') continue;&#xA;&#xA;    GPSLine += c;&#xA;  }&#xA;  return false;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(checkGPS())&#xA;  {&#xA;    Serial.println(GPSLine);&#xA;    GPSLine = &quot;&quot;;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Alex" LastActivityDate="2015-06-09T12:16:44.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12509" PostTypeId="1" AcceptedAnswerId="12511" CreationDate="2015-06-09T18:53:55.887" Score="0" ViewCount="154" Body="&lt;p&gt;I'm using an Arduino to control a reverse osmosis machine, I would like after a certain number low pressure events to return to the testing routine. Can you call to previous functions? &lt;/p&gt;&#xA;" OwnerUserId="10557" LastEditorUserId="4143" LastEditDate="2015-06-09T20:24:53.320" LastActivityDate="2015-06-09T20:24:53.320" Title="How do you call to a previous function?" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12510" PostTypeId="2" ParentId="12509" CreationDate="2015-06-09T19:29:45.033" Score="0" Body="&lt;p&gt;What do you mean by &quot;previous&quot;? In the call stack or in the code?&#xA;Either way, you can call any (public|member|static) function you want at any time, even call the very same function you're already in (recursion, but not recommended on Arduino or any other embedded system).&lt;/p&gt;&#xA;" OwnerUserId="777" LastActivityDate="2015-06-09T19:29:45.033" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12511" PostTypeId="2" ParentId="12509" CreationDate="2015-06-09T19:44:40.950" Score="1" Body="&lt;p&gt;You need to get your head around the Finite State Machine (FSM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a programming method which allows your program (&quot;Machine&quot;) to be in any of a certain number (&quot;Finite&quot;) of states (&quot;State&quot;).  One state would be reading pressure. Another state would be &quot;testing&quot;, or whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a tutorial ages ago about it: &lt;a href=&quot;http://hacking.majenko.co.uk/finite-state-machine&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/finite-state-machine&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-09T19:44:40.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12512" PostTypeId="2" ParentId="501" CreationDate="2015-06-09T22:27:20.130" Score="1" Body="&lt;p&gt;The limited access issue is tough... If you were going to use the float idea, it would be hard to difficult to actually install the thing. The other issue is waterproofing components and making sure that they won't corrode and cause false readings, which defeats the purpose of installing the system. Although it is a different scenario, i use this &lt;a href=&quot;http://www.vegetronix.com/Products/AquaPlumb/&quot; rel=&quot;nofollow&quot;&gt;Water Level Sensor&lt;/a&gt; to moniter my home aquarium. the sensor is totally insulated, and is thus waterproof. also the sensor itself is aproximately 1 mm in width,so it probably fit into your reservoir. From what i've seen so far from my use is that it is pretty accurate, and it works in both my salt water and fresh water tanks. Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="10560" LastActivityDate="2015-06-09T22:27:20.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12513" PostTypeId="1" CreationDate="2015-06-09T23:41:03.803" Score="3" ViewCount="1637" Body="&lt;p&gt;I have a brand new 8GB micro SD card freshly formatted as FAT in my Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run &lt;code&gt;df -h&lt;/code&gt;, I don't see the card's capacity included.&lt;br&gt;&#xA;When I enter &lt;code&gt;cd /mnt/sda1&lt;/code&gt;, it says &lt;code&gt;can't cd to /mnt/sda1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I SSH into the Yun with &lt;code&gt;ssh root@arduino.local&lt;/code&gt; and run &lt;code&gt;dmesg&lt;/code&gt;, I see confirmation that the SD card is recognized:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[   11.510000] sd 0:0:0:0: [sda] 15431680 512-byte logical blocks: (7.90 GB/7.35 GiB)&#xA;[   11.510000] sd 0:0:0:0: [sda] Write Protect is off&#xA;[   11.510000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00&#xA;[   11.510000] sd 0:0:0:0: [sda] No Caching mode page present&#xA;[   11.510000] sd 0:0:0:0: [sda] Assuming drive cache: write through&#xA;[   11.520000] sd 0:0:0:0: [sda] No Caching mode page present&#xA;[   11.520000] sd 0:0:0:0: [sda] Assuming drive cache: write through&#xA;[   11.530000]  sda: sda1&#xA;[   11.530000] sd 0:0:0:0: [sda] No Caching mode page present&#xA;[   11.530000] sd 0:0:0:0: [sda] Assuming drive cache: write through&#xA;[   11.540000] sd 0:0:0:0: [sda] Attached SCSI removable disk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I access my SD card and include it in the Yun's recognized storage space?&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-06-09T23:41:03.803" Title="Cannot access SD card on Yun" Tags="|arduino-yun|sd-card|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12515" PostTypeId="1" AcceptedAnswerId="12592" CreationDate="2015-06-10T02:14:14.033" Score="2" ViewCount="1991" Body="&lt;p&gt;Using an ILI9341. I'm trying to set the rotation from within a class, but it's not working.  The code is very straight forward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I rotate in the class, the setRotation code does not work but the text is still printed. The pointer is set properly and the text is still printed, it just doesn't get rotated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Outside of the class, the rotation works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SPI.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;#include &quot;Adafruit_ILI9341.h&quot;&#xA;&#xA;#define TFT_DC 5&#xA;#define TFT_CS 3&#xA;&#xA;Adafruit_ILI9341 *tft;&#xA;uint8_t newRotationAngle = 0;&#xA;&#xA;void drawStuff() {&#xA;    tft-&amp;gt;setTextColor(map(rand(), 0, RAND_MAX, 0, 0xffff));&#xA;    tft-&amp;gt;fillRect(0, 0, tft-&amp;gt;width(), tft-&amp;gt;height(), ILI9341_BLACK);&#xA;    tft-&amp;gt;setCursor(0, 0);&#xA;&#xA;    tft-&amp;gt;print(F(&quot;01234567890&quot;));&#xA;    delay(250);&#xA;}&#xA;&#xA;&#xA;class test {&#xA;public:&#xA;    void init(Adafruit_GFX *_p) { ptrTft = _p; };&#xA;&#xA;    void inClassRotation(int newRotation) {&#xA;        ptrTft-&amp;gt;setRotation(newRotation);&#xA;        drawStuffInClass();&#xA;    };&#xA;&#xA;    void drawStuffInClass() {&#xA;        ptrTft-&amp;gt;setTextColor(map(rand(), 0, RAND_MAX, 0, 0xffff));&#xA;        ptrTft-&amp;gt;fillRect(0, 0, ptrTft-&amp;gt;width(), ptrTft-&amp;gt;height(), ILI9341_BLACK);&#xA;        ptrTft-&amp;gt;setCursor(0, 0);&#xA;&#xA;        ptrTft-&amp;gt;print(F(&quot;01234567890&quot;));&#xA;        delay(250);&#xA;    }&#xA;&#xA;    Adafruit_GFX *ptrTft;&#xA;};&#xA;&#xA;test instance;&#xA;&#xA;void setup() {&#xA;    tft = new Adafruit_ILI9341(TFT_CS, TFT_DC);&#xA;&#xA;    tft-&amp;gt;begin();&#xA;    tft-&amp;gt;setTextSize(2);&#xA;&#xA;    instance.init(tft);&#xA;}&#xA;&#xA;&#xA;void outsideClassRotation(Adafruit_GFX *passed) {&#xA;    passed-&amp;gt;setRotation(newRotationAngle);&#xA;    drawStuff();&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;    newRotationAngle++;&#xA;&#xA;    // This works. No problems.&#xA;//    outsideClassRotation(tft);&#xA;&#xA;    // This does NOT rotate but still prints the text fine.&#xA;    instance.inClassRotation(newRotationAngle);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10565" LastActivityDate="2015-06-12T14:33:06.260" Title="Adafruit_GFX setRotation not working when called from within a class" Tags="|lcd|library|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12516" PostTypeId="1" CreationDate="2015-06-10T04:04:18.447" Score="0" ViewCount="1306" Body="&lt;p&gt;I'm transmitting: Temperature: 28.22C&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and on the receiving end I'm receiving the whole tranmission as a string. I'm trying to spilt Temperature to leave it as a string and 28.22 as a float to compare, how do I do that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX end hardware: (Arduino Uno board with Xbee S1)  to computer&#xA;RX end hardware: (Arduino Uno board with Xbee S2)  to computer&lt;/p&gt;&#xA;" OwnerUserId="10566" LastEditorUserId="10566" LastEditDate="2015-06-10T08:04:31.903" LastActivityDate="2016-10-03T02:51:55.210" Title="Spilt string and convert to float to compare" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12517" PostTypeId="1" CreationDate="2015-06-10T05:56:14.497" Score="2" ViewCount="3064" Body="&lt;p&gt;I flashed my ESP-01 with the &lt;a href=&quot;https://github.com/nodemcu/nodemcu-firmware&quot; rel=&quot;nofollow&quot;&gt;nodemcu firmware 512k version&lt;/a&gt;, and everything was working fine.  I testing some lua scripting on init.lua and it was working.  Then, after writing a bunch of code and uploading, the module restarted.  And it restarted.  And it's still restarting, over and over again, and prints to serial&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CÀbc0°ýbcü¨HøNodeMcu 0.9.4 build 20141230  powered by Lua 5.1.4&#xA;ö,3bþÈH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It was always printing the garbage in there before, so I'm not worried about that.  However, I can't send anything to the device--I can't send serial commands, or reflash the device.  I'm thinking I overloaded the memory or something.  Anyone have any ideas for recovering this brick?&lt;/p&gt;&#xA;" OwnerUserId="10384" LastActivityDate="2015-06-11T03:10:48.953" Title="esp8266 esp-01 crashing, restarting over and over" Tags="|esp8266|" AnswerCount="1" CommentCount="1" ClosedDate="2015-06-12T05:49:19.453" ContentLicense="CC BY-SA 3.0" />
  <row Id="12518" PostTypeId="2" ParentId="12517" CreationDate="2015-06-10T06:44:44.390" Score="1" Body="&lt;p&gt;Turns out I was pulling up on the GPIO0 pin, instead of down.  Ensure you have the correct pin-out when flashing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP-01 VCC - 3.3v Serial Adapter&#xA;ESP-01 GND - Ground or Minus Serial Adapter&#xA;ESP-01 RX - Connect to TX on Serial Adapter&#xA;ESP-01 TX - Connect to RX on Serial Adapter&#xA;ESP-01 CH_PD - 3.3v Serial Adapter&#xA;ESP-01 GPIO0 - Pull low by connecting to ground / minus&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There also seems to be a problem with NodeMCU not clearing variables in the Ram, so Ram fills up as you run, and this causes the module to crash upon restarting, over and over.  That is also what was happening.  There is some problem with wifi.sta.getap() that exacerbates this.&lt;/p&gt;&#xA;" OwnerUserId="10384" LastEditorUserId="10384" LastEditDate="2015-06-11T03:10:48.953" LastActivityDate="2015-06-11T03:10:48.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12519" PostTypeId="2" ParentId="12516" CreationDate="2015-06-10T10:42:01.830" Score="0" Body="&lt;p&gt;I suppose your communication is working... In order to retrieve a floating number from a string you might use toFloat() function. You can watch the reference page &lt;a href=&quot;http://www.arduino.cc/en/Reference/StringToFloat&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; to understand how does it work.&lt;/p&gt;&#xA;" OwnerUserId="8075" LastActivityDate="2015-06-10T10:42:01.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12520" PostTypeId="1" AcceptedAnswerId="12522" CreationDate="2015-06-10T11:30:28.873" Score="4" ViewCount="4051" Body="&lt;p&gt;I am doing a project with bi-color led matrix 8x8 and MAX7219 as the LED driver. I want to implement a fading effect on the LEDs, like mixing the two colors by varying the individual duty cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is the use of the &lt;code&gt;Iset&lt;/code&gt; parameter; I would connect the PWM pin from Arduino through the &lt;code&gt;Rset&lt;/code&gt; resistor and feed that into the Iset of the MAX7129 instead of 5V supply. Please suggest whether or not this is possible, if not what can be the alternative approach?&lt;/p&gt;&#xA;" OwnerUserId="10201" LastEditorUserId="10003" LastEditDate="2015-06-10T14:11:36.020" LastActivityDate="2015-06-10T14:11:36.020" Title="Fading the brightness of LEDs using MAX7219 and PWM" Tags="|led|pwm|max7219|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12521" PostTypeId="2" ParentId="12516" CreationDate="2015-06-10T11:58:28.400" Score="2" Body="&lt;p&gt;Okk very simple approach :-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose this is your string variable inStr = &quot;Temperature: 28.22C&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String inStr = &quot;Temperature: 28.22C&quot;;&#xA;int indexOfSpace = inStr.indexOf(' ');&#xA;//this stores the address of the space character in the string.&#xA;int indexOfC = inStr.indexOf('C');&#xA;&#xA;String Temp = inStr.substring(indexOfScace+1,indexOfC);&#xA;//as the parameter for the function is supposed to be the starting point of the string to&#xA; be extracted and one more than its ending point.&#xA;&#xA;&#xA;//Now to convert to float&#xA;&#xA;float TempFlo = Temp.toFloat();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10201" LastActivityDate="2015-06-10T11:58:28.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12522" PostTypeId="2" ParentId="12520" CreationDate="2015-06-10T13:25:38.107" Score="3" Body="&lt;p&gt;This is possible in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The MAX72xx has its own internal intensity control register. From the datasheet:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Digital control of display brightness is provided by an internal pulse-width modulator [...]. The modulator scales the average segment current in 16 steps from a maximum of 31/32 down to 1/32 of the peak current set by RSET [...].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This of course requires no extra components or effort, but you are limited slightly by only a 4-bit intensity resolution. Also, there is no 'off' so you'd have to either manually blank the displays or put the ICs into shutdown mode.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Your suggested way is possible. However, the low frequency of the Arduino's PWM may lead to flickering if the MAX7219's internal segment current reference driver needs a steady voltage. You'll have to consider smoothing the PWM output through a low pass filter - the TL072/TL082 has two op-amps so you can use one for colour A and the other for colour B. I'd choose an op-amp over passive filtering because the current drawn from the Arduino will be negligible and the stability of the current into the MAX7219 will be improved.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-10T13:25:38.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12523" PostTypeId="1" AcceptedAnswerId="12525" CreationDate="2015-06-10T14:16:24.410" Score="1" ViewCount="15423" Body="&lt;p&gt;This is my first circuit ever (!) and so I'm hoping that I'm just making an easy-to-spot rookie mistake. I am trying to power an Arduino Due with a 9V battery and then have the Due in turn power a red LED. No blinking. No sketchpad/C program flashed to the chip. Just straight up electricity:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1dQW0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connect the battery, several things happen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is a green power LED on the Due that lights up; and&lt;/li&gt;&#xA;&lt;li&gt;Right next to it is an orange LED (on the Due itself) that blinks every few seconds (not sure what this LED is or what the blinking means, but providing that detail for good measure); and&lt;/li&gt;&#xA;&lt;li&gt;The red LED on the breadboarrd does &lt;strong&gt;not&lt;/strong&gt; light up&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is a 2V/15mA LED, and as you can see I'm powering it from the 5V power jack on the Due. So a 220 ohm resistor should be perfect for it (&lt;code&gt;R = (Vs - V) / I = (5V-2V) / .015A ~= 220 ohms&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for the first time ever, I busted out my multimeter, set it to the voltage setting, and started testing the circuit. First I tested &lt;code&gt;Vin&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt; on the Due (that is, the connection between the battery and the Due), and the multimeter lit up and hovered (correctly) around 5V. So far so good. Next I tested the power and ground connections on the breadboard power rails (indicated in green above). Again, the multimeter reported a roughly 5V power supply. Then I tested the connection from the power rail to the row (purple in pic above) feeding power to the resistor, and to my surprise, the multimeter reports &lt;strong&gt;no power&lt;/strong&gt; at those two purple locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;em&gt;understanding&lt;/em&gt; was that the power rail will power the entire column its connected to (in my case, the left-most column), and then any rows connecting to a power rail/column will also be powered. So I'm not understanding why there's voltage on my power rail/column, but not on the wire connecting my power rail to the resistor. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Update:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Here is my corrected circuit per initial feedback. Please note this is still not working, but I think I'm getting close:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lxCrP.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9842" LastEditorUserId="9842" LastEditDate="2015-06-10T14:50:05.853" LastActivityDate="2015-06-10T15:25:02.740" Title="Simple LED circuit is not working" Tags="|led|power|arduino-due|battery|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12524" PostTypeId="2" ParentId="12523" CreationDate="2015-06-10T14:26:42.847" Score="1" Body="&lt;p&gt;It looks like you've got confused between columns and rows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are correct that the power rails run the length of the breadboard -- these are seen as the top and bottom pairs of rows in the diagram below (ignore the middle row). However, the rest of the board is connected up as separate columns. Each column is independent of its adjacent columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QqY3n.gif&quot; alt=&quot;breadboard diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means your red wire going from the power rail to the resistor is connected correctly. However, the other end of your resistor is currently going nowhere. It needs to be in the same column as the anode of your LED.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-06-10T14:26:42.847" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12525" PostTypeId="2" ParentId="12523" CreationDate="2015-06-10T14:45:32.510" Score="5" Body="&lt;p&gt;What connects the resistor to the LED?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/E3mmD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Absolutely nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's hard to work out which holes the LED is plugged into, but I think your current circuit looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/moMz2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to connect that resistor and LED together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your circuit looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zM9rH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Behind the 5 pins in that column with the ground wire there is a big chunk of metal connecting them all together.  It's no different to if you'd taken the LED and twisted the pins together into one.  There's no way the power can get up one and down the other when they are connected together like that.  You need to separate them into different columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is how the (black) connections inside are laid out, and how your (red) electricity is flowing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Q11H.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is how the circuit should look, using a program called Fritzing.  It's a pretty basic design tool, but great for showing wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/X23yu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see how the green highlighting shows the columns that are connected.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-10T15:25:02.740" LastActivityDate="2015-06-10T15:25:02.740" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12526" PostTypeId="1" CreationDate="2015-06-10T14:52:57.243" Score="0" ViewCount="721" Body="&lt;p&gt;I am trying to send data from QSerialPort to Arduino Mega 2560. The proccess always takes some time to establish the connection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;How do I know with QSerialPort is the connections is ready to send data?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how much time do I have to wait for that and it happens every time when I run the application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The configuration of my QSerialPort instance is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mSerialPort = new QSerialPort();&#xA;mSerialPort-&amp;gt;setPortName(&quot;COM3&quot;);&#xA;mSerialPort-&amp;gt;setBaudRate(QSerialPort::Baud9600);&#xA;mSerialPort-&amp;gt;setDataBits(QSerialPort::Data8);&#xA;mSerialPort-&amp;gt;setParity(QSerialPort::NoParity);&#xA;mSerialPort-&amp;gt;setStopBits(QSerialPort::OneStop);&#xA;mSerialPort-&amp;gt;setFlowControl(QSerialPort::NoFlowControl);&#xA;mSerialPort-&amp;gt;open(QIODevice::ReadWrite);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I check the device configuration of COM port:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TVVu0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also changed and play the Arduino delay but nothing changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sending to Arduino little piece of data. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X100.10,Y10.23, H9999, ...others&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And these data work when I am debugging the functions of my application. Everything is writting and work. So I am lost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope all this information be usefull to give me an answer or at less some tips.&lt;/p&gt;&#xA;" OwnerUserId="10295" LastActivityDate="2015-06-10T15:31:04.937" Title="How do I know when the connections is ready between Arduino and QSerialPort" Tags="|serial|arduino-mega|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12527" PostTypeId="1" AcceptedAnswerId="12532" CreationDate="2015-06-04T17:39:28.830" Score="2" ViewCount="5573" Body="&lt;p&gt;I am sending data to Arduino using QtSerialPort. When I read the data the ouput has several not printer characters. I am using a QTexEdit (in left hand) to insert the data to send and other (in right hand) to insert  the data to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EaziF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the receive data has some no printer character.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Workflow of sending and receiving data between QtSerialPort and Arduino&lt;/h1&gt;&#xA;&#xA;&lt;h3&gt;Sending Data with QtSerialPort&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MainWindow::sendData(){&#xA;&#xA;    QString m_allData = m_sendEdit-&amp;gt;toPlainText();&#xA;    int i = 0;&#xA;    int size = m_allData.size();&#xA;&#xA;    QString line = &quot;&quot;;&#xA;    int c = 0;&#xA;    while(i &amp;lt; size){&#xA;        line.append(m_allData[i]);&#xA;        if(c == 24){&#xA;            int sended = m_serialPort-&amp;gt;write(line.toUtf8(), 24);&#xA;            m_serialPort-&amp;gt;flush();&#xA;            line.clear();&#xA;            c = 0;&#xA;        }&#xA;        i++;&#xA;        c++;&#xA;    }&#xA;    if(c &amp;gt; 0){&#xA;        m_serialPort-&amp;gt;write(line.toUtf8(), c);&#xA;    }&#xA;    m_serialPort-&amp;gt;flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to send the data with a buffer size of 24 bytes.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Reading and Sending Data with Arduino&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup() {&#xA;    Serial.begin(9600);&#xA; }&#xA;&#xA; void loop() {&#xA;&#xA;    delay(1000);&#xA;&#xA;    if (Serial.available() &amp;gt; 0){&#xA;        short i = 0;&#xA;        int size = Serial.available();&#xA;        String data = Serial.readString();&#xA;        Serial.print(data);&#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino code is simple. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Receiving Data with QtSerialPort&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MainWindow::readData(){&#xA;    int c = 0;&#xA;    char * dataBuffer;&#xA;    int size = m_serialPort-&amp;gt;bytesAvailable();&#xA;    dataBuffer = new char[size];&#xA;    c = m_serialPort-&amp;gt;read(dataBuffer, size);&#xA;    m_receiveEdit-&amp;gt;setText(m_receiveEdit-&amp;gt;toPlainText() + QString::fromUtf8(dataBuffer));&#xA;        delete dataBuffer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to read the same data that I send to Arduino. What kind of convertion do I have to do?&lt;/p&gt;&#xA;" OwnerUserId="10295" OwnerDisplayName="Robert" LastEditorUserId="10794" LastEditDate="2015-09-12T00:48:17.023" LastActivityDate="2015-09-12T00:48:17.023" Title="How do I print the reading serial data sending from Arduino" Tags="|serial|programming|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12528" PostTypeId="1" AcceptedAnswerId="12530" CreationDate="2015-06-05T15:48:40.853" Score="2" ViewCount="4630" Body="&lt;p&gt;I am using QtSerialPort to send and receive data from Arduino. I am sending &lt;strong&gt;more than 64 bytes&lt;/strong&gt; (125, 220, more), I receive the data with Arduino, and trying to sending back the same data, but Arduino &lt;strong&gt;sending only 64 bytes&lt;/strong&gt; in its response. Then I am thinking that the problem is with Arduino buffer. I am trying to clear the data but without result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {    &#xA;    if (Serial.available() &amp;gt; 0) {&#xA;        int i = 0;&#xA;        delay(500);&#xA;        int size = Serial.available();&#xA;        while (i &amp;lt; size)&#xA;            buffer[i++] = Serial.read();&#xA;&#xA;        Serial.print(buffer);&#xA;        //delay(500);&#xA;        int j = 0;&#xA;        while (j &amp;lt; size)&#xA;            buffer[j++] = '\0';&#xA;        //while (Serial.available()) Serial.read(); I tried it&#xA;        //Serial.flush();   Also tried it, but nothing.             &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10295" OwnerDisplayName="Robert" LastEditorUserId="10794" LastEditDate="2015-09-12T00:47:48.587" LastActivityDate="2015-09-12T00:47:48.587" Title="How do I receive more that 64 bytes with Arduino" Tags="|serial|programming|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12530" PostTypeId="2" ParentId="12528" CreationDate="2015-06-10T15:23:53.850" Score="2" Body="&lt;p&gt;Instead of blocking the loop for 500&amp;nbsp;ms, you should be actively&#xA;reading the data as it comes. Otherwise the internal buffer of the&#xA;&lt;code&gt;Serial&lt;/code&gt; object will overflow after only 64&amp;nbsp;bytes are received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example that copies the incoming bytes into a larger buffer&#xA;(256&amp;nbsp;bytes) and, upon receiving an end-of-line character, echoes&#xA;back the whole line.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static char buffer[256];&#xA;    static size_t pos;              // position of next write&#xA;&#xA;    while (Serial.available() &amp;amp;&amp;amp; pos &amp;lt; sizeof buffer - 1) {&#xA;&#xA;        // Read incoming byte.&#xA;        char c = Serial.read();&#xA;        buffer[pos++] = c;&#xA;&#xA;        // Echo received message.&#xA;        if (c == '\n') {            // \n means &quot;end of message&quot;&#xA;            buffer[pos] = '\0';     // terminate the buffer&#xA;            Serial.print(buffer);   // send echo&#xA;            pos = 0;                // reset to start of buffer&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-10T15:23:53.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12531" PostTypeId="2" ParentId="12526" CreationDate="2015-06-10T15:31:04.937" Score="1" Body="&lt;p&gt;I am guessing that what you are seeing is not the port taking some time to open, but the Arduino resetting as soon as you open the serial port.  That means there is a short time while it's in the bootloader looking for an &quot;I am here&quot; signal from avrdude.  The timeout of that signal is configured in the bootloader, and is usually something like 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest thing you can do is, as one of the first commands in your program, send an &quot;I am ready to receive&quot; signal to the computer (maybe just the word &quot;OK&quot; or something like that), which you then wait for before sending your data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-10T15:31:04.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12532" PostTypeId="2" ParentId="12527" CreationDate="2015-06-10T15:35:58.063" Score="1" Body="&lt;p&gt;You have no warranty that Qt will receive the whole message in a single&#xA;chunk. It may receive &quot;no se&quot; as the first chunk, and then &quot;q pasa&quot; as&#xA;the second chunk. Since &lt;code&gt;dataBuffer&lt;/code&gt; is dynamically allocated, it&#xA;initially contains garbage, and you are printing the part of this&#xA;garbage that you did not overwrite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy fix would be to simply NULL-terminate the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;dataBuffer = new char[size + 1];            // + 1 byte for '\0'&#xA;c = m_serialPort-&amp;gt;read(dataBuffer, size);&#xA;dataBuffer[c] = '\0';                       // terminate the string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-10T15:35:58.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12534" PostTypeId="1" AcceptedAnswerId="12539" CreationDate="2015-06-10T15:59:27.873" Score="2" ViewCount="8024" Body="&lt;p&gt;I am trying to interface MPU6050 with arduino. Found a simple code online, but having a bit of trouble in interpreting it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MPU-6050 Short Example Sketch&#xA;// By Arduino User JohnChi&#xA;// August 17, 2014&#xA;// Public Domain&#xA;#include&amp;lt;Wire.h&amp;gt;&#xA;const int MPU=0x68;  // I2C address of the MPU-6050&#xA;int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;&#xA;void setup(){&#xA;Wire.begin();&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;Wire.endTransmission(true);&#xA;Serial.begin(9600);&#xA;}&#xA;void loop(){&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)&#xA;Wire.endTransmission(false);&#xA;Wire.requestFrom(MPU,14,true);  // request a total of 14 registers&#xA;AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C     (ACCEL_XOUT_L)     &#xA;AcY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;AcZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;Tmp=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x41 (TEMP_OUT_H) &amp;amp; 0x42 (TEMP_OUT_L)&#xA;GyX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x43 (GYRO_XOUT_H) &amp;amp; 0x44 (GYRO_XOUT_L)&#xA;GyY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x45 (GYRO_YOUT_H) &amp;amp; 0x46 (GYRO_YOUT_L)&#xA;GyZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x47 (GYRO_ZOUT_H) &amp;amp; 0x48 (GYRO_ZOUT_L)&#xA;Serial.print(&quot;AcX = &quot;); Serial.print(AcX);&#xA;Serial.print(&quot; | AcY = &quot;); Serial.print(AcY);&#xA;Serial.print(&quot; | AcZ = &quot;); Serial.print(AcZ);&#xA;Serial.print(&quot; | Tmp = &quot;); Serial.print(Tmp/340.00+36.53);  //equation for   temperature in degrees C from datasheet&#xA;Serial.print(&quot; | GyX = &quot;); Serial.print(GyX);&#xA;Serial.print(&quot; | GyY = &quot;); Serial.print(GyY);&#xA;Serial.print(&quot; | GyZ = &quot;); Serial.println(GyZ);&#xA;delay(3330); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now there are a few things i want to ask regarding this code:&#xA;1. Here we have specified that the data from 3B register of the slave should be the first one and master will receive in total 14 bytes. In this case the 14 registers are continuous (&lt;a href=&quot;https://www.olimex.com/Products/Modules/Sensors/MOD-MPU6050/resources/RM-MPU-60xxA_rev_4.pdf&quot; rel=&quot;nofollow&quot;&gt;see datasheet here&lt;/a&gt;) .Now how should i go about reading the values if i am interested in registers which are not continuous ,let us say alternative?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.&lt;code&gt;AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line is taking the first 8 bits and last 8 bits and forming a 16 bit number . But why do we need to shift the first 8-bits byte 8 places to left.Please explain how exactly this line works?    &lt;/p&gt;&#xA;" OwnerUserId="10574" LastActivityDate="2015-06-10T18:08:23.017" Title="Reading values from the register of a slave" Tags="|arduino-uno|mpu6050|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12535" PostTypeId="1" CreationDate="2015-06-10T16:46:11.967" Score="-1" ViewCount="521" Body="&lt;p&gt;I was wondering whether anyone could help me... I am using an Arduino Uno and I am writing my code in the Arduino IDE. I am trying to implement the code so that the output voltage can be varied from 0 - 5 volts using 2 pushbuttons. I want to be able to increment the voltage by +0.5 volts from 0-5 volts every time I push Button A. Also I want to decrement the voltage by -0.5 volts from 5-0V every time I push Button B. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: (push Button A): output voltage 0.5: (push Button A): output voltage 1.0 etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far when I upload my code the LED as my test for output just flickers between 2 - 4 volts. Can anyone tell me what I am doing wrong? I am not that good at coding so any help would be awesome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int PWMPin = 6; // output pin supporting PWM&#xA;int buttonApin = 8; // buttonA to pin 9 PWM&#xA;int buttonBpin = 10; // buttonB to pin 10 PWM&#xA;float value = 0; // read the value at 0&#xA;float fadeValue = value;&#xA;float counter = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(buttonApin, INPUT);&#xA;  pinMode(buttonBpin, INPUT);&#xA;  pinMode(PWMPin, OUTPUT);&#xA;} &#xA;void loop() {&#xA;  int port = analogRead(0);&#xA;  port = map(port, 0, 10, 0, 255);&#xA;  analogWrite(6, port);&#xA;  if (digitalRead(buttonApin) == LOW, fadeValue) {&#xA;    if (counter &amp;gt;= 10) {&#xA;      counter = 10;&#xA;    }&#xA;    // fade from min to max in increments of 25.5 points: basically (0.5 volts)&#xA;    for(fadeValue = 0 ; fadeValue &amp;lt;= 255; fadeValue +=25.5) {&#xA;      counter = fadeValue;&#xA;      // sets the value (range from 0 to 255):&#xA;      analogWrite(PWMPin, fadeValue);&#xA;      delay(100);&#xA;    }&#xA;  }&#xA;  if (digitalRead(buttonBpin) == LOW, fadeValue) {&#xA;    if (counter &amp;lt;= 0) {&#xA;      counter = 0;&#xA;    }&#xA;    // fade from max to min in increments of 25.5 points: basically (0.5 volts)&#xA;    for(fadeValue = 255 ; fadeValue &amp;gt;= 0; fadeValue -=25.5) {&#xA;      counter = fadeValue;&#xA;      // sets the value (range from 0 to 255):&#xA;      analogWrite(PWMPin, fadeValue);&#xA;      delay(100);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10541" LastEditorUserId="4628" LastEditDate="2015-09-09T12:28:17.863" LastActivityDate="2016-02-06T17:07:52.613" Title="Arduino Uno coding problem voltage varying" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="11" ClosedDate="2017-11-21T21:24:57.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="12537" PostTypeId="1" CreationDate="2015-06-10T16:59:27.330" Score="3" ViewCount="189" Body="&lt;p&gt;I want to buy this kit: &lt;a href=&quot;http://www.banggood.com/UNO-Basic-Starter-Learning-Kit-Upgrade-Version-For-Arduino-p-970714.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/UNO-Basic-Starter-Learning-Kit-Upgrade-Version-For-Arduino-p-970714.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as shipping stuff from China takes like 3 months to arrive, i need to be certain i won't have much else to buy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How far can i go just with this kit, and what would you recommend me buying together with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="10577" LastActivityDate="2015-06-10T16:59:27.330" Title="How far can i go just with this starter kit?" Tags="|arduino-uno|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12538" PostTypeId="2" ParentId="12535" CreationDate="2015-06-10T17:17:07.933" Score="0" Body="&lt;p&gt;There's a number of very basic things wrong with your code - things that aren't doing what you think, or you just telling it completely the wrong things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start by formatting your code properly (INDENTS!) and match up all your brackets.  You'll soon see what I see as far as what is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll give you some clues:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{  &#xA;if (digitalRead(buttonApin) == LOW, counter)   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where to I start with that one...?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int fadeValue = 0 ; fadeValue &amp;lt;= 255; fadeValue +=25.5)    &#xA;  counter = fadeValue;   &#xA;  digitalWrite(PWMPin, fadeValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C is not Python!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(PWMPin, fadeValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Writing an analog value to a digital pin?!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(PWMPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Printing the pin number - now what is the point of that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... fadeValue += 25.5 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding a float to an integer - bad practice (and ultimately pointless) - pick one, float or integer, and stick to it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And then there is the whole logic of your program. I can't work out what it's supposed to be achieving.  It looks like you've tried to get it to do all sorts of parts of different things and not got it to do anything at all.  Strip it right out and get it to do ONE thing - provide a specific, STATIC, voltage.  Then add in some way of changing that voltage afterwards.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-10T17:24:38.607" LastActivityDate="2015-06-10T17:24:38.607" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12539" PostTypeId="2" ParentId="12534" CreationDate="2015-06-10T18:08:23.017" Score="1" Body="&lt;p&gt;For reading non-consecutive bytes, the “normal” way would be to do a&#xA;one-byte request and a one-byte read for each byte you want. However, if&#xA;the bytes you want are close enough (e.g. you want every other byte), it&#xA;would be faster to do a contiguous read and just ignore the bytes you do&#xA;not want. E.g.:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;byte data1 = Wire.read();  // read first byte&#xA;Wire.read();               // read and ignore second byte&#xA;byte data3 = Wire.read();  // read third byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For your question regarding the meaning of&#xA;&lt;code&gt;Wire.read()&amp;lt;&amp;lt;8|Wire.read();&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;Wire.read()&lt;/code&gt; return a 16-bit integer, where the 8 most significant&#xA;bits are zero and the 8 least-significant bits contain the actual&#xA;data. In binary, it's something like &lt;code&gt;00000000xxxxxxxx&lt;/code&gt;, where &lt;code&gt;x&lt;/code&gt;&#xA;are the data bits.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;8&lt;/code&gt; means “shift left by eight positions”, where the missing bits&#xA;are replaced by zeros. Thus &lt;code&gt;Wire.read()&amp;lt;&amp;lt;8&lt;/code&gt; is &lt;code&gt;xxxxxxxx00000000&lt;/code&gt;&#xA;in binary.&lt;/li&gt;&#xA;&lt;li&gt;The second call to &lt;code&gt;Wire.read()&lt;/code&gt; return another 16-bit integer in the&#xA;form &lt;code&gt;00000000yyyyyyyy&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The vertical bar &lt;code&gt;|&lt;/code&gt; is the bitwise-or operator: each bit of the left&#xA;operand is or-ed with the corresponding bit of the right operand to&#xA;give one bit of the result: &lt;code&gt;x or 0&lt;/code&gt; is &lt;code&gt;x&lt;/code&gt;, &lt;code&gt;0 or y&lt;/code&gt; is &lt;code&gt;y&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Then, the whole expression gives &lt;code&gt;xxxxxxxxyyyyyyyy&lt;/code&gt;, where &lt;code&gt;xxxxxxxx&lt;/code&gt;&#xA;comes from the first &lt;code&gt;Wire.read()&lt;/code&gt; and &lt;code&gt;yyyyyyyy&lt;/code&gt; from the second.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The problem here is that the “first” and “second” &lt;code&gt;Wire.read()&lt;/code&gt; in the&#xA;sentence above refer to the position of the call in the line, not to the&#xA;actual order in which the calls are performed. Thus you may be lucky and&#xA;get the the correct byte order... or not. You should instead do a single&#xA;read per statement if you want to control the byte order. For MSB first:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;AcX = Wire.read() &amp;lt;&amp;lt; 8;  // read most significant byte first&#xA;AcX |= Wire.read();      // then least significant byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for LSB first:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;AcX = Wire.read();        // read least significant byte first&#xA;AcX |= Wire.read() &amp;lt;&amp;lt; 8;  // then most significant byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-10T18:08:23.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12540" PostTypeId="1" AcceptedAnswerId="12541" CreationDate="2015-06-10T18:20:39.063" Score="1" ViewCount="7218" Body="&lt;p&gt;Windows 7 here. I just bought an &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;Arduino Due&lt;/a&gt; and downloaded the Arduino IDE. I wrote a simple &quot;blink LED&quot; program (see below) and am trying to flash it to the Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connected the Due to my laptop (via micro USB cable), I got a warning on my laptop that it could not find the correct device driver. So I followed the instructions discussed on &lt;a href=&quot;https://www.youtube.com/watch?v=fCxzA9_kg6s&quot; rel=&quot;nofollow&quot;&gt;this excellent video tutorial&lt;/a&gt; and went into &lt;code&gt;Control Panel &amp;gt;&amp;gt; System &amp;gt;&amp;gt; Device Manager &amp;gt;&amp;gt; Arduino&lt;/code&gt; and pointed it to load the appropriate device driver from &lt;code&gt;C:\Program Files (x86)\Arduino\drivers&lt;/code&gt;. This got rid of the warning. Hooray!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then Verified &amp;amp; Compiled my program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;&#xA;void setup() {&#xA;    pinMode(led, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(led, HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(led, LOW);&#xA;    delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Great success! Now it was time for me to upload the program to my Due. The first time I tried to upload it, I got the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.4 (Windows 7), Board: &quot;Arduino Uno&quot;&#xA;Sketch uses 1,068 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: ser_open(): can't open device &quot;\\.\COM1&quot;: The system cannot find the file specified.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&#xA;    This report would have more information with&#xA;    &quot;Show verbose output during compilation&quot;&#xA;    enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So then in the IDE I went to &lt;code&gt;Tools &amp;gt;&amp;gt; Port&lt;/code&gt; and changed the selection from &lt;code&gt;Serial&lt;/code&gt; to &lt;code&gt;COM3&lt;/code&gt; (again, sort of explained in that video tutorial). I tried to upload again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.4 (Windows 7), Board: &quot;Arduino Uno&quot;&#xA;Sketch uses 1,068 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x09&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x09&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&#xA;    This report would have more information with&#xA;    &quot;Show verbose output during compilation&quot;&#xA;    enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought it was interesting that the IDE thinks this is an Arduino Uno. So then I went to &lt;code&gt;Tools &amp;gt;&amp;gt; Board&lt;/code&gt; and changed the selection from &lt;code&gt;Uno&lt;/code&gt; to &lt;code&gt;Duemilanove&lt;/code&gt;, hoping that Due and Duemilanove are compatible for the programmer/flasher tool. This time the error was the same as last, except the first line reads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.4 (Windows 7), Board: &quot;Arduino Duemilanove or Diecimila, ATmega328&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So at least the IDE is switching board correctly. :-) I should note that my &lt;code&gt;Tools &amp;gt;&amp;gt; Board&lt;/code&gt; menu &lt;strong&gt;does not&lt;/strong&gt; have an &quot;Arduino Due&quot; option. And when I go to &lt;code&gt;Tools &amp;gt;&amp;gt; Board &amp;gt;&amp;gt; Board Manager&lt;/code&gt;, searching for Due does not turn up anything either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried running the upload with verbose output, but that really didn't tell me anything more. I'm happy to post the exact verbose output but figured I could omit it here for brevity. I also &lt;em&gt;did&lt;/em&gt; peruse the &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow&quot;&gt;troubleshooting link&lt;/a&gt; that the error output recommends, but it looks like I've already exhausted all of those recommendations as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm stuck and frustrated, any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to do to get the IDE programming my Due?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-07-31T21:22:54.397" Title="Problems uploading sketch to Arduino Due" Tags="|arduino-ide|arduino-due|uploading|avrdude|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12541" PostTypeId="2" ParentId="12540" CreationDate="2015-06-10T18:25:26.780" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... hoping that Due and Duemilanove are compatible for the programmer/flasher tool.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not even close. You will need to go into the Boards Manager and download and install the SAM support files, select the Due from the list, and &lt;em&gt;then&lt;/em&gt; upload the sketch.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-10T18:25:26.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12544" PostTypeId="2" ParentId="3422" CreationDate="2015-06-11T01:04:51.937" Score="0" Body="&lt;p&gt;Suggest starting with the  the &lt;code&gt;Mailbox&lt;/code&gt; examples in the Bridge library. Specifically the example &#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/MailboxReadMessage&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/MailboxReadMessage&lt;/a&gt;&#xA;Which shows how to transfer messages to the Arduino processor. It does discuss how to fire the curl process from the command line.&lt;/p&gt;&#xA;" OwnerUserId="8142" LastActivityDate="2015-06-11T01:04:51.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12545" PostTypeId="1" CreationDate="2015-06-11T01:11:53.903" Score="1" ViewCount="1807" Body="&lt;p&gt;So I am programming an LED Music Visualizer that uses a combination of Processing and Arduino. I have it all working as I want to but there is a small problem. If I were to stop the music, then the Arduino will keep displaying the visualization for a few seconds. I believe that this issue would be caused by it &quot;catching up&quot; on new serial data from Processing like a queue. So my question is: When arduino uses the Serial.read() function, is it using the most recent value or is it using the next value received after the last one that it used, like a queue of values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: Processing sends the values 1,2,3,4,5,6,7,8,9 over serial in 10 millisecond intervals. Arduino only performs Serial.read at 20 millisecond intervals. Would the arduino read the values 1,3,5,7,9 in or would it read the values 1-9 but in twice the time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the confusing question, hopefully somebody could shed some light. At the core, it is a question on how serial works, you can ignore the part about the music visualizer.&lt;/p&gt;&#xA;" OwnerUserId="10585" LastEditorUserId="7508" LastEditDate="2015-06-12T09:59:08.280" LastActivityDate="2016-03-08T15:49:04.497" Title="Arduino Serial Queue" Tags="|serial|programming|processing-lang|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12547" PostTypeId="1" CreationDate="2015-06-11T02:26:27.920" Score="0" ViewCount="855" Body="&lt;p&gt;I am building a 2-Axis gantry system to dispense some thermal paste on boards. I was given two stepper motors in order to do so along with a gantry already built that will arrive in two weeks. So basically I just need to figure out how to drive them on the software side. However the boss demands testable code to be finished by EOB tomorrow, despite the hardware not being here yet. So I drafted some quick code that should drive a stepper motor, it's an easy open loop system, but I'm struggling. The operator will home the gantry after each cycle so it's just a matter of getting the motors moving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My method was as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Stepper.h&amp;gt;&#xA;*declaring the stepper and all that goes here*&#xA;void loop(){ etc.&#xA;   basic logic flow stuff&#xA;   stepper.step(20); // to move forward twenty steps &#xA;   stepper.step(-20) // to move back twenty steps&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However my boss says this is incorrect as I need to be giving the steppers both &lt;em&gt;step&lt;/em&gt; and &lt;em&gt;direction&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some tenuous google searching he recommended I use the AccelStepper library to fix this problem. After looking through this library I'm unsure how this will give me anything I need (distances are so small acceleration is useless) and how I am not giving it both step and direction in my original example code, I give it steps (20) and a direction with my negative/positive coefficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct in my thinking? Is there a better solution neither of us have found? I'd love to understand not just that I'm wrong, but why I am.&lt;/p&gt;&#xA;" OwnerUserId="10586" LastActivityDate="2015-06-11T08:16:19.297" Title="Help understanding how to drive Step motors with Arduino" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12548" PostTypeId="2" ParentId="12545" CreationDate="2015-06-11T04:13:19.940" Score="1" Body="&lt;p&gt;It sounds like you figured most of your question out already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Someone correct me here if I'm wrong). The Atmega 328p uC, I believe, has an 8 byte hardware buffer for RX serial data. In software, the Arduino core code defines a maximum ring buffer of 64 bytes that acts as a FIFO queue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what does his mean? Let's just focus on the hardware buffer since it's fairly easy. Say you send your data 1,2,...,10 at 10ms intervals, and you read your data at 100ms intervals (for illustration purposes). The problem is that you send 10 bytes of data but only have room for 8 bytes. So, your first two values (1,2) are pushed out of the buffer and lost. This idea also illustrates a FIFO queue, first in first out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same idea can be extended to a ring buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, like you said, this could explain your problem. If you have 64 bytes, which will obviously be full since your inevitably losing data (20ms read with a 10ms write), you'll be seeing the effects for 64 * 20ms = 1.28s. There's probably some processing delay too which will extend this delay, but it's more than likely minimal if it's efficient code.&lt;/p&gt;&#xA;" OwnerUserId="10383" LastActivityDate="2015-06-11T04:13:19.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12549" PostTypeId="1" AcceptedAnswerId="12556" CreationDate="2015-06-11T07:19:15.727" Score="0" ViewCount="1332" Body="&lt;p&gt;I need to transfer files from my local machine to my Arduino Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scp /Users/SSCirrus/Documents/index.html root@arduino.local:/root&#xA;scp ~/Users/SSCirrus/Documents/index.html root@arduino.local:/root&#xA;# No such file or directory (referring to my desktop)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have confirmed that the filepath is accurate. What's wrong here?&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-06-11T17:22:38.173" Title="How to copy files from local computer to Yun with scp?" Tags="|arduino-yun|ssh|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12550" PostTypeId="2" ParentId="12547" CreationDate="2015-06-11T08:16:19.297" Score="1" Body="&lt;p&gt;I think there is some mis-communication between you and your boss. I do not think your boss is stupid, but I do think he's talking on a different level as you do. You're using arduino which covers up a lot of hardware-interfacing, especially with steppers.&#xA;I suggest you check out this video: &lt;a href=&quot;https://www.youtube.com/watch?v=bngx2dKl5jU&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=bngx2dKl5jU&lt;/a&gt;&#xA;(I haven't watched it, but It will help you get more into the ideas of your boss)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you understand your boss's view, you can try to show him your view. When talking about steppers/arduino and how you can put in negative steps, he might think you're talking trash, as steppers require different pairs of coils to be active depending on the direction. (which is all handled by arduino)&#xA;The best way is to provide him a visual guidance, so that he can see the relation with his (hardware-view) on the issue and your software/arduino solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could make something like the image below.&#xA;I'm not sure if this is what you're trying to tell him.&#xA;I guess you should mention/add that the software on the arduino takes integer values, with negative values being clockwise or such. &lt;strong&gt;And that the arduino will convert this to the right coil pairs or direction and step.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S:with &lt;em&gt;direct driving&lt;/em&gt;, I think he meant toggling the right pins at the right moments so that the stepper will rotate, basically what the stepper library does for you. Maybe he wants you to implement something like the stepper library (is it an internship? so that you can learn?) I suggest you check some tutorials on how stepper motors work, and how you can drive them 'directly' withouth the use of libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8RlXt.png&quot; alt=&quot;Example&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-06-11T08:16:19.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12551" PostTypeId="1" AcceptedAnswerId="12553" CreationDate="2015-06-11T10:03:05.770" Score="5" ViewCount="2940" Body="&lt;p&gt;For a school project we're working on a wearable device to track people's movement and heart rate. We use an Arduino Pro Mini with a heartbeat sensor and an accelerometer. The wearable device uses Bluetooth to send data, but only once or twice a day to save battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem we currently face is having the Arduino keep track of the accelerometer data while also reading the heartbeat sensor on a select interval. See the pseudo-code underneath. In what way (preferably without implementing too many libraries) could we merge these two loops so the accelerometer is read non-stop while keeping an interval (of about 30 minutes) between the heart beat readings? Any input would be greatly appreciated and if needed I can provide additional information.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;// Heartbeat sensor loop&#xA;  while (array is not full) {&#xA;    delay(30 minutes);&#xA;    heartbeatArray[index++] = readHeartbeat();&#xA;  }&#xA;  sendData_Bluetooth(heartbeatArray);&#xA;  emptyArray();&#xA;// End of heartbeat sensor loop&#xA;&#xA;// Accelerometer loop&#xA;  while (true)&#xA;    if (readAccelerometerData &amp;gt; limit)&#xA;      sendAlert();&#xA;// End of accelerometer loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10590" LastActivityDate="2015-06-15T21:05:29.397" Title="Running multiple tasks at once" Tags="|sensors|bluetooth|interrupt|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12552" PostTypeId="2" ParentId="12551" CreationDate="2015-06-11T11:00:07.467" Score="1" Body="&lt;p&gt;millis() is your great friend here.&lt;/p&gt;&#xA;&lt;p&gt;millis() is function that returns the value of a 32 bit counter that is incremented once per millisecond. By adding the current value returned by millis() to a value representing the number of milliseconds that you want to 'delay' for you get a value that can be compared with the ongoing value returned by millis() to see if the time period has elapsed.&lt;/p&gt;&#xA;&lt;p&gt;You can have as many variables as you wish which hold future timeout values for millis(0 - you perform the related action when millis() returns &amp;gt;= the saved value and reinitialise the value to some new future time.&lt;/p&gt;&#xA;&lt;p&gt;Variables used to hold values from millis() &lt;strong&gt;MUST&lt;/strong&gt; be type unsigned long.&lt;br /&gt;&#xA;The millis() timer rolls over every 49.7 days.&lt;br /&gt;&#xA;( = 2^32/1000 ms/s / 3600 s/hr / 24 h/day)&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If your system may run for longer than that without being reset or powered down then handling millis()'s timer rollover must be known about.&lt;/p&gt;&#xA;&lt;p&gt;It's MUCH easier than many people realise but best not dealt with here EXCEPT to know that if you add a constant to millis() and the value exceeds 2^32 and is truncated the comparisons with and subtractions wrt millis() still work correctly if the variable is type unsigned long. (&amp;quot;Why&amp;quot; is for elsewhere)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;micros() is like unto millis() but returns the time since reset in microseconds. Depending on the processor used micros() may have a granularity of 4 uS rather than one uS. ie it steps by 4 counts every 4 uS rather than 1 count per uS.&lt;br /&gt;&#xA;micros() rolls over every 1.19 hours&lt;br /&gt;&#xA;( = 2^32 / 10^6/3600s/h)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;// &lt;strong&gt;Example - not tested:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long DoitNow;  &#xA;&#xA;void setup(){  &#xA;  DoitNow = millis() + 1800000; // Add half an hour of milliseconds &#xA; }  &#xA;void loop(){  &#xA;   if(millis() &amp;gt; DoitNow)  &#xA;   { Do heartbeat stuff;  &#xA;      DoitNow = millis() + 1800000; // Add another half hour of ms&#xA;   }  &#xA; Do accelerometer stuff;  &#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-11T11:25:59.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12553" PostTypeId="2" ParentId="12551" CreationDate="2015-06-11T11:37:11.713" Score="4" Body="&lt;p&gt;What you want to do is rather easy task, you just need to forget about &lt;code&gt;delay()&lt;/code&gt; function. When writing some more complex programs using it is generally a bad idea, as it blocks code execution, so you won't get any sensor readings, communication, anything. Instead try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long delay1 = 100;&#xA;unsigned long delay2 = 1800000; //30 minutes in miliseconds&#xA;unsigned long t1, t2;&#xA;&#xA;void setup() {&#xA;  t1 = t2 = millis();&#xA;}&#xA;&#xA;void loop() {&#xA;  if(millis() - t1 &amp;gt; delay1) { //this will be executed every delay1 ms&#xA;    // do one part of code&#xA;    t1 = millis();&#xA;  }&#xA;&#xA;  if(millis() - t2 &amp;gt; delay2) { //this will be executed every delay2 ms&#xA;    // do another part of code&#xA;    t2 = millis();&#xA;  }&#xA;&#xA;  // here insert the code that should be executed as frequently as possible&#xA;  // (every loop passage)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also a nice Arduino library called &lt;a href=&quot;http://playground.arduino.cc/Code/TaskScheduler&quot; rel=&quot;nofollow&quot;&gt;TaskScheduler&lt;/a&gt;, that basically does the same thing: periodically executes different functions with different time intervals.&lt;/p&gt;&#xA;" OwnerUserId="10591" LastActivityDate="2015-06-11T11:37:11.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12554" PostTypeId="2" ParentId="5268" CreationDate="2015-06-11T13:48:28.287" Score="0" Body="&lt;p&gt;Problem with Atmega8A-pu &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the correct com port is selected then on the tools menu select Arduino NG or Older as the board type then choose the ATmega8 as the processor from the tools menu and upload any example Program probably i prefer blink to test (courtesy-PARC-India).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the best&lt;/p&gt;&#xA;" OwnerUserId="10593" LastActivityDate="2015-06-11T13:48:28.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12556" PostTypeId="2" ParentId="12549" CreationDate="2015-06-11T17:22:38.173" Score="0" Body="&lt;p&gt;Try &lt;code&gt;~/Documents/index.html&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;~&lt;/code&gt; represents the current user's home directory, so &lt;code&gt;~/Documents&lt;/code&gt; is the Documents folder for the current user.  It means you don't have to make sure you have spelled the user's home directory exactly right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other options are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;$HOME/Documents/index.html&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Documents/index.html&lt;/code&gt; (if you are in your home directory)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cd ~/Documents&lt;/code&gt; then just use &lt;code&gt;index.html&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... the list goes on ...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-11T17:22:38.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12558" PostTypeId="1" AcceptedAnswerId="12560" CreationDate="2015-06-11T17:31:17.797" Score="1" ViewCount="13135" Body="&lt;p&gt;we can upload a code into Arduino UNO from our computers, but how about reading code? Can we read and get C codes from compiled codes from Arduino hardwares? My second question is that will we read these compiled codes on Arduino ZERO's debug port, which will be a new product for us as developers?&lt;/p&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="1006" LastEditDate="2015-06-12T18:19:38.267" LastActivityDate="2015-06-12T18:19:38.267" Title="How to read code from Arduino Uno to Arduino IDE?" Tags="|arduino-uno|c|sketch|debugging|code-optimization|" AnswerCount="2" CommentCount="0" ClosedDate="2015-06-13T14:39:40.040" ContentLicense="CC BY-SA 3.0" />
  <row Id="12559" PostTypeId="2" ParentId="12558" CreationDate="2015-06-11T17:37:37.587" Score="1" Body="&lt;p&gt;You wont be able to get the code in readable C. It would be in Machine code.&lt;/p&gt;&#xA;" OwnerUserId="8716" LastActivityDate="2015-06-11T17:37:37.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12560" PostTypeId="2" ParentId="12558" CreationDate="2015-06-11T17:39:41.963" Score="8" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can we read and get C codes from compiled codes from Arduino hardwares?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While it is possible, even trivial, to disassemble machine code, it is very difficult to convert the assembly code into a higher-level language, and essentially impossible to turn it back into an exact copy of the source code it came from. There simply isn't enough information in the machine code to do so.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My second question is that will we read these compiled codes on Arduino ZERO's debug port, which will be a new product for us as developers?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The debug port will work in tandem with appropriate software that will already have access to the source code, so this is not a method for conversion either.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-11T17:39:41.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12561" PostTypeId="1" CreationDate="2015-06-11T19:16:26.047" Score="2" ViewCount="1158" Body="&lt;p&gt;I have found this interesting device wile looking for a cheap Arduino.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/7G7Pu.jpg&quot; alt=&quot;4x4 Soft Keypad Driver&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a &quot;driver&quot; that converts a &lt;a href=&quot;http://www.learningaboutelectronics.com/Articles/Arduino-keypad-circuit.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;4x4 Keyboard 8-PIN (8-IO)&lt;/a&gt; &#xA;to &lt;a href=&quot;http://www.aliexpress.com/store/product/EB-4x4-Soft-Keypad-Driver/226959_1795573537.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;a 4-Pin (2-IO) Device&lt;/a&gt;&#xA;I would like to know if is Achieved by a &lt;a href=&quot;http://forums.parallax.com/showthread.php/150719-4x4-Keypad-With-Four-I-O-Pins-(using-shift-registers)&quot; rel=&quot;nofollow noreferrer&quot;&gt;shift register&lt;/a&gt; ,&lt;a href=&quot;http://playground.arduino.cc/Code/OneWireKeyPad&quot; rel=&quot;nofollow noreferrer&quot;&gt;One Wire Keypad&lt;/a&gt; or some other magic. If you have a diagram/tutorial/video please share (I know the &quot;One Wire Keypad&quot; uses Only 3-PINS (1-Analog-IO))Naturally ordered one to have a look but its gonna take some time to get here and i am way to exited.&lt;/p&gt;&#xA;" OwnerUserId="10598" LastEditorUserId="4143" LastEditDate="2015-06-11T19:22:36.660" LastActivityDate="2015-06-11T19:22:36.660" Title="EB - 4x4 Soft Keypad Driver Diagram from Makerstudio needed" Tags="|arduino-uno|keyboard|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12563" PostTypeId="1" CreationDate="2015-06-11T19:43:19.730" Score="0" ViewCount="231" Body="&lt;p&gt;Hi I'm using a adafruit motor shield v2 and I need to power a DC motor 6-12V but I'm not sure if my battery will be okay for the shield. Will it burn the shield? I'm going to be using 6V so it should draw less current?&lt;/p&gt;&#xA;" OwnerUserId="10599" LastActivityDate="2015-06-11T22:08:09.890" Title="Powering a 6-12V motor using a lead acid 6V battery with 6Amps of current?" Tags="|motor|arduino-motor-shield|current|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12564" PostTypeId="1" CreationDate="2015-06-11T20:27:57.363" Score="1" ViewCount="557" Body="&lt;p&gt;I have a circuit running with capacitive Sensors, that also has an LED strip. everything works fine when using USB power from a laptop (connected to the mains) and 12v 2A adapter powering 1m LED strip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the power supply is split and the arduino is also powered from this supply ( using adapter port ) the capacitive sensor begins to give junk values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What changes in a circuit that would create such a porblem? Could it be a grounding issue? How else to ground this arduino to behave as it would with a usb connection?&lt;/p&gt;&#xA;" OwnerUserId="10118" LastActivityDate="2016-04-20T15:40:44.183" Title="How does changing arduino power supply from USB to Adapter change the circuit?" Tags="|arduino-uno|sensors|power|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12565" PostTypeId="1" CreationDate="2015-06-11T20:49:56.717" Score="1" ViewCount="7130" Body="&lt;p&gt;Can I connect two ARDUINO UNO circuit boards in serial to increase room for more code and more functionality. For instance I wish to connect six sensors to a board. I need code for all six sensors and there is not enough space on one board. If I connect two circuit boards in serial will that provide the space and functionality to run the code for all six sensors.&#xA;If not how is this accomplished? I am a beginner with ARDUINO and I have been assigned a big task to make the ARDUINO UNO circuit boards provide six different functions using sensors such as temperature, pressure, humidity, voltage, current and possibly other functions. I am new at this.&lt;/p&gt;&#xA;" OwnerUserId="10602" LastActivityDate="2015-06-11T21:47:17.377" Title="How do I interface two Arduino boards so they act as one with double the code space?" Tags="|communication|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12566" PostTypeId="2" ParentId="12565" CreationDate="2015-06-11T20:55:14.320" Score="5" Body="&lt;p&gt;There is no simple way to combine multiple boards into a unified system. What you will need to do is delegate certain tasks to each board and then have them communicate via SPI, I&lt;sup&gt;2&lt;/sup&gt;C, or UART between a master board and each slave board in the system. The master system will then present the interface of the system as a whole via serial, wifi, console, etc.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-11T20:55:14.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12567" PostTypeId="2" ParentId="12565" CreationDate="2015-06-11T21:35:33.303" Score="1" Body="&lt;p&gt;What you described is not a big task. I suspect you are new to both the Arduino and computers in general, and so it seems big to you. Hang in there, it is a lot easier than you think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In many cases, a sensor requires 1 electrical pin (plus ground, which is shared by all).  So even an Arduino UNO can read a dozen or more sensors.  In many cases the instructions to read the sensor is as simple as 'read(x)'  and that takes 2 bytes, so if you got really lucky, the UNO's 32k of memory could read 16k sensors (a 'k' being a thousand if you didnt know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reality is it is not quite that simple, but it is not far from it.  You probably want to find a library that matches your sensor, and the only hard part is figuring out how to combine many libraries, which indeed do interfere with each other on occasion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1, learn the basics.  Get an Arduino experimenters kit or equivalent, play with the examples until you understand them. It will include some of the sensors you may use later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 2, identify which other sensors you will need, find Arduino compatible versions of those.  You will know if it is Arduino compatible if it has an accompanying library, get that also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;step 3, make sure you can make each sensor work by itself first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;step 4, start combining sensors and resolving errors that will show up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forget the idea of combining boards, it is an advanced topic and you are no where near ready to try that yet.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-06-11T21:35:33.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12568" PostTypeId="2" ParentId="12565" CreationDate="2015-06-11T21:47:17.377" Score="2" Body="&lt;p&gt;If you're doing something that exceeds the resources of an UNO, then one simple next step would be to try a MEGA.  It is similar enough to the UNO that porting should be trivial, but has more RAM, more flash, and more I/O ports than two UNO units combined.&lt;/p&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2015-06-11T21:47:17.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12569" PostTypeId="2" ParentId="12563" CreationDate="2015-06-11T22:08:09.890" Score="1" Body="&lt;p&gt;If you take the &quot;full load&quot; to be the &quot;stall current&quot;, then you can work out the resistance of the winding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R=V/I = 12/14 = 0.857Ω&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that you can then work out the stall current at 6V:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I=VR = 6×0.857 = 5.143A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That, being the &lt;em&gt;stall current&lt;/em&gt;, is the &lt;em&gt;maximum&lt;/em&gt; the motor will draw - the current drawn when it is trying to move an impossible amount of load and the rotor cannot move.  At that current you will melt the motor drivers (or they will go into thermal shutdown).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, with a geared motor, that becomes a (comparatively) massive load and would be quite hard to achieve.  You have a 50:1 gear ratio, so the stall load is effectively 50x greater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there is going to be a limit to the load that you can drive with the motor before it becomes a problem for the driver.  There are ways of calculating it from the given torque, gear ratio, load/noload current ratings, etc, but I don't have all that at my fingertips right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can either &quot;play it safe&quot; and invest in a driver that can cope with the stall current, or experiment and measure what current is drawn by the motor with different loads and see if it stays below the 1.2A limit of the shield.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-11T22:08:09.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12571" PostTypeId="1" AcceptedAnswerId="12572" CreationDate="2015-06-11T22:17:50.933" Score="1" ViewCount="215" Body="&lt;p&gt;I'm trying to get an Arduino Uno to run four sensors (all I2C). The first two are TMP102 temperature sensors. The address is controlled by tying the ADD0 pin to GND, VCC, SDA, or SCL (four possible addresses, without multiplexing). I get it to receive data just fine through the GND setting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote some code to collect from two, but before I was even talking to the second one, plugging it in causes the data stream from the GND one to stop. Unplugging it from the breadboard makes it work again. Either sensor in either location on the breadboard will work fine, as long as it's addressed as ground. Neither sensor will, even by itself, work with any other address. I tried some other sketches from the net (one attached below that should read from any of four different sensors), but all have the same issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;byte res;&#xA;byte msb;&#xA;byte lsb;&#xA;int val;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  res = Wire.requestFrom(72,2); &#xA;  if (res == 2) {&#xA;    msb = Wire.read(); /* Whole degrees */ &#xA;    lsb = Wire.read(); /* Fractional degrees */ &#xA;    val = ((msb) &amp;lt;&amp;lt; 4);   /* MSB */&#xA;    val |= (lsb &amp;gt;&amp;gt; 4);    /* LSB */&#xA;    Serial.print( &quot;72:&quot;);&#xA;    Serial.println(val*0.0625);&#xA;    delay(1000);   &#xA;  }&#xA;  res = Wire.requestFrom(73,2); &#xA;  if (res == 2) {&#xA;    msb = Wire.read(); /* Whole degrees */ &#xA;    lsb = Wire.read(); /* Fractional degrees */ &#xA;    val = ((msb) &amp;lt;&amp;lt; 4);   /* MSB */&#xA;    val |= (lsb &amp;gt;&amp;gt; 4);    /* LSB */&#xA;    Serial.print( &quot;73:&quot;);&#xA;    Serial.println(val*0.0625);&#xA;    delay(1000);   &#xA;  }&#xA;  res = Wire.requestFrom(74,2); &#xA;  if (res == 2) {&#xA;    msb = Wire.read(); /* Whole degrees */ &#xA;    lsb = Wire.read(); /* Fractional degrees */ &#xA;    val = ((msb) &amp;lt;&amp;lt; 4);   /* MSB */&#xA;    val |= (lsb &amp;gt;&amp;gt; 4);    /* LSB */&#xA;    Serial.print( &quot;74:&quot;);&#xA;    Serial.println(val*0.0625);&#xA;    delay(1000);   &#xA;  }&#xA;  res = Wire.requestFrom(75,2); &#xA;  if (res == 2) {&#xA;    msb = Wire.read(); /* Whole degrees */ &#xA;    lsb = Wire.read(); /* Fractional degrees */ &#xA;    val = ((msb) &amp;lt;&amp;lt; 4);   /* MSB */&#xA;    val |= (lsb &amp;gt;&amp;gt; 4);    /* LSB */&#xA;    Serial.print( &quot;75:&quot;);&#xA;    Serial.println(val*0.0625);&#xA;    delay(1000);   &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Breadboard:&#xA;(image link: the forum kept crashing when I tried to upload the image directly)&#xA;&lt;a href=&quot;https://www.sugarsync.com/pf/D333436_95042359_6938296&quot; rel=&quot;nofollow&quot;&gt;https://www.sugarsync.com/pf/D333436_95042359_6938296&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10605" LastActivityDate="2015-06-11T22:27:20.263" Title="Trouble making TMP102 work with any ADD0 other than ground" Tags="|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12572" PostTypeId="2" ParentId="12571" CreationDate="2015-06-11T22:27:20.263" Score="1" Body="&lt;p&gt;You see that little solder jumper block on the breakout board labelled &quot;ADD0&quot;?  You need to remove the solder from that.  It's currently connected in a pre-defined position and you trying to use the ADD0 pin is conflicting with that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-11T22:27:20.263" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12574" PostTypeId="1" CreationDate="2015-06-12T00:47:35.950" Score="1" ViewCount="2716" Body="&#xA;&#xA;&lt;p&gt;I am trying to accomplish 1-wire communication between 2 Arduinos and so I wanted to start off by having 1 Arduino toggle a digital output pin and have the other read the state of that pin. To accomplish this, I have 2 computers with Arduino IDE installed and each one is connected to one Arduino Uno. Both Arduino Uno's are connected with a single male-male jumper cable on Pin 13 of the header. I am watching the state of the pin by looking at the prints in the Serial Console on both computers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a diagram of my setup:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Computer1 ---&amp;gt; Arduino1[Sender] --------&amp;gt; Arduino2[Receiver] -----&amp;gt; Computer2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I have is that I am seeing when I first start both Arduinos - the sender is definitely toggling the output pin high-&gt;low-&gt;high forever - but the receiver Arduino only shows its input pin as toggling for a few seconds and then it gets stuck high. Sometime later, it may go low for 1 iteration, but then sticks at high again. What is going on? I would expect to see the sender and receiver show high-&gt;low-&gt;high forever. The code seems simple but I must be doing something wrong - thanks for your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sender Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int led = 13; // Comm Pin&#xA;&#xA;// Setup pins&#xA;void setup() {&#xA;&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;&#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  Serial.println(&quot;high&quot;);&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  Serial.println(&quot;low&quot;);&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int led = 13; // Comm Pin&#xA;&#xA;// Setup pins&#xA;void setup() {&#xA;&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;&#xA;  // Pin is an input - normal state high&#xA;  pinMode(led, INPUT);&#xA;&#xA;}&#xA;void loop() {&#xA;&#xA;  // Put your main code here, to run repeatedly:&#xA;  Serial.println(digitalRead(led));&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10607" LastEditorUserId="10794" LastEditDate="2015-08-11T21:40:46.577" LastActivityDate="2015-12-09T23:55:48.340" Title="2 Arduino Unos Connected with 1-Wire and Receiver Pin getting Stuck High" Tags="|arduino-uno|pins|communication|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12575" PostTypeId="1" CreationDate="2015-06-12T01:26:54.860" Score="2" ViewCount="88" Body="&lt;p&gt;I want to control a kettle. It has 4 buttons and a digital disply of the temp. I would like the buttons and disply to remain functional. I just want to make the buttons remoteky pressabke. The buttons are at 5v. There is an almost bread‐board like set of little sockets where they connect to the higher voltage part of the kettle. (Where I see the kettle's built in relay, that powers the buttons and displsy.)k&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have a 2nd set of wires to my arduino feed into these sockets would there be an issue with the signal from arduino going &lt;em&gt;to&lt;/em&gt; the buttons? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I think I might need a relay if I later adapt this for spark/particle core because it is 3.3v is there such a relay?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-06-12T01:26:54.860" Title="How to splice into existing buttons?" Tags="|voltage-level|relay|remote-control|wires|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12576" PostTypeId="1" AcceptedAnswerId="12577" CreationDate="2015-06-12T01:58:20.760" Score="0" ViewCount="724" Body="&lt;p&gt;I want to pass the preprocessor values(AT commands) to the Serial.println function. Im trying TCP connection using arduino-SIM900A. I've declared all AT commands to each preprocessor variables like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define A &quot;AT\r&quot;&#xA;#define B &quot;AT+CPIN?\&quot;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've assigned all preprocessor variables in char array and pass it into Serial.print using for loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char varAT[12]={'A','B'....};&#xA;for(int i=0;i&amp;lt;=12;i++)&#xA;{&#xA;Serial.print(varAT[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Its not printing AT, instead it print preprocessor variable name A. I searched the google how to convert char value to variable, in C there is a function called &quot;eval&quot;. Using eval we can acheive, but it wont work in arduino lang. How to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="10608" LastActivityDate="2015-06-12T02:25:08.457" Title="Conver char value to variable?" Tags="|programming|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12577" PostTypeId="2" ParentId="12576" CreationDate="2015-06-12T02:14:19.680" Score="0" Body="&lt;p&gt;Ok, first, &lt;code&gt;char varAT[12]&lt;/code&gt; indicates an array of 12 characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, quotes indicate literals - 'A' means, literally, the character 'A'. Variables and constants are without quotes (same way you use  &lt;code&gt;i&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *varAT[12]={A,B....};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, your constant &lt;code&gt;B&lt;/code&gt; is invalid - I think you meant for it to end in &lt;code&gt;\r&quot;&lt;/code&gt;, not &lt;code&gt;\&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-06-12T02:25:08.457" LastActivityDate="2015-06-12T02:25:08.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12578" PostTypeId="1" CreationDate="2015-06-12T03:26:05.030" Score="3" ViewCount="14378" Body="&lt;p&gt;I'm trying to measure the amount of time that has passed between every time a reed switch mounted on a wheel is activated to calculate the speed of a bike in miles per hour and display it on two 7 segment LEDs. This is what I have so far (without 7 seg code, as that works):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int reed = A3;&#xA;float circumference;&#xA;float pi = 3.141592653589&#xA;unsigned long time0 = 0;&#xA;unsigned long time1;&#xA;unsigned long revolutionTime;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  circumference = (pi * 26); //26 = the diameter of the wheel&#xA;  int reedState = digitalRead(reed);&#xA;  if (reedState == HIGH) {&#xA;    time1 = millis();&#xA;    revolutionTime = (time1 - time0);&#xA;    time0 = time1;&#xA;    int mph = ((circumference / revolutionTime) * (3600000 / 63360)); //this is the conversion from inches/millisecond to miles/hour.&#xA;    Serial.println(mph);&#xA;    //And I'd print the result on the 7 segment displays here&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code results in around 25 printed entries in the serial monitor from a single activation of the reed switch, all of which consist of randomly alternating values of either 0 or 4571.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following each step of the code, I assume that the program would generate a garbage result for the first entry (because the time before the reed is activated for the first time could vary greatly), but that following entries would be the correct mph displayed on the 7 segment displays until the reed switch is activated again and a new mph is calculated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how would I go about modifying the code to get useful data?&lt;/p&gt;&#xA;" OwnerUserId="7942" LastActivityDate="2016-06-15T01:10:45.040" Title="Measuring Time Between Inputs" Tags="|programming|time|millis|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12579" PostTypeId="2" ParentId="12578" CreationDate="2015-06-12T05:01:51.997" Score="0" Body="&lt;p&gt;Imagine your wheel rotating very slow ... imagine time was slowed down.  Imagine the magnet comes to the reed sensor and closes the switch.  You will now take a measurement.  The Ardunio code loop will end and immediately restart ... because time has been slowed (in our story), the wheel will have barely moved and AGAIN you will take another measurement because the reed switch is STILL closed because the magnet hasn't moved far enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe you need to change your logic such that after you detect the reed switch closing, you then need to detect that the reed switch is OPEN again ... before once more looking for the reed switch to close. Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (reedState == HIGH) {&#xA;   // do something&#xA;   while(digitalRead(reed) == HIGH) {&#xA;      // do nothing&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-12T05:01:51.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12580" PostTypeId="2" ParentId="9846" CreationDate="2015-06-12T05:13:20.973" Score="1" Body="&lt;p&gt;As has been mentioned in the comments, you have at least three possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wifi using the ESP8266&lt;/li&gt;&#xA;&lt;li&gt;Private protocol using the nRF24&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth using the HC-05&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All of these will handle 20 feet of separation.  All of these have high quality libraries for Arduinos and lots of free tutorials and assistance via forums and Stack Exchanges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the primary differences are price, size of data and power consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My personal weapon of choice, and not knowing anything further about your project ... is the nRF24.  This is crazy cheap and pretty easy to use.  It also benefits from no need for a Wifi access point and also has a broadcast capability so that multiple devices can receive the same message.  The down sides are that it is a private protocol that your phone and laptop can't decode natively (it isn't WiFi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second choice would be Bluetooth.  This would allow your phone and laptop to be transmitters and receivers as there are plenty of great Bluetooth terminal emulators available.&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-12T05:13:20.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12581" PostTypeId="2" ParentId="12578" CreationDate="2015-06-12T06:16:32.120" Score="0" Body="&lt;p&gt;Your test &lt;code&gt;if (reedState == HIGH)&lt;/code&gt; does not tell you when the reed&#xA;switch is &lt;em&gt;activated&lt;/em&gt;, it tells you when it's &lt;em&gt;active&lt;/em&gt;, which is not the&#xA;same. You should instead look at when the switch transitions from &lt;code&gt;LOW&lt;/code&gt;&#xA;to &lt;code&gt;HIGH&lt;/code&gt;, which means you also have to remember the last state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static int lastReedState;&#xA;    static unsigned long lastTransition;&#xA;    int reedState = digitalRead(reed);&#xA;&#xA;    // On a rising transition of the reed switch:&#xA;    if (reedState == HIGH &amp;amp;&amp;amp; lastReedState == LOW) {&#xA;&#xA;        // Compute time since last valid transition.&#xA;        unsigned long now = millis();&#xA;        unsigned long revolutionTime = now - lastTransition;&#xA;&#xA;        // Debounce: this transition is valid only if enough time has&#xA;        // elapsed since the last valid one.&#xA;        if (revolutionTime &amp;gt; 20) {&#xA;&#xA;            // Compute and report speed.&#xA;            int speed = circumference / revolutionTime;&#xA;            Serial.println(speed);&#xA;&#xA;            // Remember this transition.&#xA;            lastTransition = now;&#xA;        }&#xA;    }&#xA;&#xA;    // Remember last state.&#xA;    lastReedState = reedState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes &lt;code&gt;circumference&lt;/code&gt; has already been calculated and has the&#xA;appropriate unit (miles⋅ms/h if you want the speed reported in mph).&#xA;Actually it could be a compile-time &lt;code&gt;int&lt;/code&gt; constant (4641), which would&#xA;avoid having floating point calculations at run time.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-12T08:02:54.330" LastActivityDate="2015-06-12T08:02:54.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12582" PostTypeId="1" CreationDate="2015-06-12T05:40:54.763" Score="-2" ViewCount="958" Body="&lt;p&gt;Is an arduino password controlled lock safe or can the password be seen if they plug it in to a computer?&lt;/p&gt;&#xA;" OwnerDisplayName="Luke" LastEditorUserId="10794" LastEditDate="2015-09-12T00:43:40.177" LastActivityDate="2015-09-12T00:43:40.177" Title="Are arduino passwords safe?" Tags="|programming|hardware|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12583" PostTypeId="2" ParentId="12578" CreationDate="2015-06-12T07:08:25.460" Score="3" Body="&lt;p&gt;Currently your code is not working, because Arduino is fast enough to check the closed switch state many times before it opens again, so before calculating a new speed value, you need to see LOW on the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, there are at least 2 better ways to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;pulseIn()&lt;/a&gt;&lt;/strong&gt; - a function intended just for what you are trying to do: measuring lenght of a pulses. If your switch is active HIGH, you need to measure length of a LOW pulse:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long duration;&#xA;duration = pulseIn(reed, LOW);&#xA;// calculate speed basing on duration (in microseconds)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Keep in mind, that &lt;code&gt;pulseIn()&lt;/code&gt; is a blocking function, so no code will be executed, until it receives the pulse. You can counter it bu specifying a timeout, after which, the program will continue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;External &lt;a href=&quot;http://www.arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow&quot;&gt;interrupts&lt;/a&gt;&lt;/strong&gt; are an another approach. Interrupt handling routines are executed when a specified event occurs, no matter if the microcontroller is busy doing something else or not. They would guarantee, that you will not miss any pulse even if they would have frequency in order of kHz.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned long lastTime = 0;&#xA;&#xA;void setup() {&#xA;    attachInterrupt(0, readTime, RISING);&#xA;} &#xA;&#xA;void readTime() {&#xA;    unsigned long t = millis();&#xA;    // calculate speed basing on t - lastTime&#xA;    lastTime = t;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interrupt handling routine should be as short as possible. Avoid using delays in it, doing Serial.print and other communications. Also, millis() and micros() will not increment during execution of interrupt handler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Debouncing&lt;/strong&gt; - even with above two methods, things may still not work properly. The most probable cause would be switch &quot;bouncing&quot;. You can counter it by&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;software debouncing  - delaying after &lt;code&gt;pulseIn()&lt;/code&gt; or ignoring interrupts for some period of time after first interrupt is detected&lt;/li&gt;&#xA;&lt;li&gt;adding a small (10-100nF) capacitor at the input, that will act as a low-pass filter, cutting out short pulses&lt;/li&gt;&#xA;&lt;li&gt;using not a reed switch, but a hall sensor with hysteresis&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10591" LastActivityDate="2015-06-12T07:08:25.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12584" PostTypeId="2" ParentId="9117" CreationDate="2015-06-12T08:04:41.700" Score="7" Body="&lt;p&gt;If you have a read of section 31 of the Datasheet, available from &lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;, things may come a little clearer for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a summary of what I know:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PIO stands for Parallel Input/Output and offers the functionality to read and write multiple register ports at a time.  Where the datasheet mentions a register, for example PIO_OWER, the Arduino library has macros for accessing them in this format REG_PIO?_OWER where ? is either A, B, C or D for the different ports available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to still use the slow Arduino pinMode() function to set input/output on the pins as it makes the code more readable than the acronym based registers calls such as REG_PIOC_OWER = 0xdeadbeef, but then use the direct registers to set the pins for performance/synchronisation.  As yet, I haven't done anything with input, so my examples are all output based.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For basic usage, you would use REG_PIO?_SODR to set output lines high and REG_PIO?_CODR to set them low.  For example REG_PIOC_SODR = 0x00000002 would set bit 1 (numbered from zero) on PORTC (this is Due digital pin 33) high. All other pins on PORTC remain unchanged.  REG_POIC_CODR = 0x00000002 would set bit 1 on PORTC low.  Again all other pins would be unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As this is still not optimal, or synchronised if you are working with parallel data, there is a register that allows you to write all 32 bits of a port with a single call.  These are the REG_PIO?_ODSR, so REG_PIOC_ODSR = 0x00000002 would now set bit 1 on PORTC high and all other bits on PORTC would be set low instantly in a single CPU instruction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it is unlikely that you would ever be in a situation where you need to set all 32 bits of a port at the same time, you would need to store the current value of the pins, perform an AND operation to mask out the ones you want to alter, perform an OR operation to set the ones you want set high then perform your write and again, and this is not optimal.  To overcome this, the CPU itself will perform the masking for you.  There is a register called OWSR (output write status register) that will mask out any bits that you write to ODSRs that don't match bits set in the OWSR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, now if we call REG_PIOC_OWER = 0x00000002 (this sets bit 1 of the OWSR high) and REG_PIOC_OWDR = 0xfffffffd (this clears all bits except bit 1 of the OWSR) and then call REG_PIOC_ODSR = 0x00000002 again, this time it would only change bit 1 of PORTC and all other bits remain unchanged.  Pay attention to the fact that &lt;strong&gt;OWER enables&lt;/strong&gt; any bits &lt;strong&gt;that are set to 1&lt;/strong&gt; in the value you write and that &lt;strong&gt;OWDR disables&lt;/strong&gt; any bits &lt;strong&gt;&lt;em&gt;that are set to 1&lt;/em&gt;&lt;/strong&gt; in the value you write.  Even though I understood this when I read it, I still managed to make a code mistake when writing my first test code thinking that OWDR disabled bits that &lt;strong&gt;weren't&lt;/strong&gt; set to 1 in the value I wrote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this has at least given you a bit of a start in understanding the PIO of the Due CPU.  Have a read and a play and if you have any further questions, I'll try to answer them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;One more thing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you know which bits of the PORTs correspond to which digital lines of the Due?  Check this out: &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,132130.0.html&quot; rel=&quot;noreferrer&quot;&gt;Due Pinout&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="8616" LastEditDate="2015-06-12T08:14:26.627" LastActivityDate="2015-06-12T08:14:26.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12585" PostTypeId="2" ParentId="12582" CreationDate="2015-06-12T09:53:56.340" Score="1" Body="&lt;p&gt;There are no passwords inherent to Arduino. You can implement them any way you want, resulting in any safety level from zero safely to nearly uncrackable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Not so good&lt;/strong&gt;: store the passwords straight in EEPROM. No protection of your data means that there's always a way to read them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Quite safe&lt;/strong&gt;: hash the password before storing it, for instance through SHA-512. Even if you can read the list of hashed passwords, it's pretty hard (read: nearly impossible) to reverse the algorithm to get the password back. For that reason SHA functions are called one-way functions. When you enter a password you run it through the SHA algorithm and check the hash against the list of hashes in EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-06-12T09:53:56.340" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12586" PostTypeId="1" AcceptedAnswerId="12641" CreationDate="2015-06-12T10:49:44.643" Score="0" ViewCount="246" Body="&lt;p&gt;I have a somewhat large sketch that uses the &lt;code&gt;Adafruit_ssd1306&lt;/code&gt;(I2C) library for a 128X64 LCD. The sketch is a designed to be an alarm clock. When I upload the sketch with out initializing serial, it works as designed. However if I do intialize serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the program fails to run on my UNO. After many hours of troubleshooting I noticed I have several large char arrays that may be the culprit.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *menusDisplay[] = {&quot;1. Alarm-is Off&quot;, &quot;2. Month&quot;, &quot;3. Hour&quot;, &quot;4. Minute&quot;, &quot;5. Exit&quot;, &quot;6. Alarm Set&quot;, NULL};&#xA;const char *months[] = {&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot; , &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;, NULL};&#xA;const int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The months array as 12 elements. If I shorted it down to 2 elements and upload the programs with serial initialized, the program runs. At first I thought is was a memory leak in perhaps the &lt;code&gt;Adafruit_ssd1306&lt;/code&gt;. But I also have another LCD library &lt;code&gt;Adafruit_ssd1306syp&lt;/code&gt; that the issue occurred too. So that ruled out those libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I compile the sketch without Serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 16,846 bytes (52%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 737 bytes (35%) of dynamic memory, leaving 1,311 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 17,862 bytes (55%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 910 bytes (44%) of dynamic memory, leaving 1,138 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas of what may be going on? I would load the sketch but its very large. If needed, I can try to cut it down and reproduce the issue.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-06-15T00:15:07.920" Title="Intializing Serial crashes UNO" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12587" PostTypeId="1" AcceptedAnswerId="12588" CreationDate="2015-06-12T11:16:30.810" Score="132" ViewCount="106966" Body="&lt;p&gt;I need to read a sensor every five minutes, but since my sketch also has&#xA;other tasks to do, I cannot just &lt;code&gt;delay()&lt;/code&gt; between the readings. There&#xA;is the &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;noreferrer&quot;&gt;Blink without&#xA;delay&lt;/a&gt; tutorial&#xA;suggesting I code along these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    // Read the sensor when needed.&#xA;    if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;        previousMillis = currentMillis;&#xA;        readSensor();&#xA;    }&#xA;&#xA;    // Do other stuff...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;code&gt;millis()&lt;/code&gt; is going to roll over back to zero after&#xA;roughly 49.7&amp;nbsp;days. Since my sketch is intended to run for longer&#xA;than that, I need to make sure the rollover does not make my sketch&#xA;fail. I can easily detect the rollover condition&#xA;(&lt;code&gt;currentMillis &amp;lt; previousMillis&lt;/code&gt;), but I am not sure what to do then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus my question: what would be the proper/simplest way to handle the&#xA;&lt;code&gt;millis()&lt;/code&gt; rollover?&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2018-11-29T20:29:36.663" LastActivityDate="2021-07-20T15:42:48.343" Title="How can I handle the millis() rollover?" Tags="|programming|time|millis|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="12588" PostTypeId="2" ParentId="12587" CreationDate="2015-06-12T11:16:30.810" Score="178" Body="&#xA;&lt;p&gt;Short answer: do not try to “handle” the millis rollover, write&#xA;rollover-safe code instead. Your example code from the tutorial is fine.&#xA;If you try to detect the rollover in order to implement corrective&#xA;measures, chances are you are doing something wrong. Most Arduino&#xA;programs only have to manage events that span relatively short&#xA;durations, like debouncing a button for 50 ms, or turning a heater&#xA;on for 12 hours... Then, and even if the program is meant to run&#xA;for years at a time, the millis rollover should not be a concern.&lt;/p&gt;&#xA;&lt;p&gt;The correct way to manage (or rather, avoid having to manage) the&#xA;rollover problem is to think of the &lt;code&gt;unsigned long&lt;/code&gt; number returned by&#xA;&lt;code&gt;millis()&lt;/code&gt; in terms of &lt;a href=&quot;http://en.wikipedia.org/wiki/Modular_arithmetic&quot; rel=&quot;noreferrer&quot;&gt;modular&#xA;arithmetics&lt;/a&gt;. For the&#xA;mathematically inclined, some familiarity with this concept is very&#xA;useful when programming. You can see the math in action in Nick Gammon's&#xA;article &lt;a href=&quot;https://www.gammon.com.au/millis&quot; rel=&quot;noreferrer&quot;&gt;millis() overflow ... a bad&#xA;thing?&lt;/a&gt;. For the problem at hand,&#xA;what's important to know is that in modular arithmetics the numbers&#xA;“wrap around” when reaching a certain value – the modulus – so that&#xA;1 − modulus is not a negative number but 1 (think of a&#xA;12 hour clock where the modulus is 12: here 1 − 12 = 1).&lt;/p&gt;&#xA;&lt;p&gt;For those who do not want to&#xA;go through the computational details, I offer here an alternative&#xA;(hopefully simpler) way of thinking about it. It is based on the simple&#xA;distinction between &lt;em&gt;instants&lt;/em&gt; and &lt;em&gt;durations&lt;/em&gt;. As long as your tests&#xA;only involve comparing durations, you should be fine.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Note on micros()&lt;/strong&gt;: Everything said here about &lt;code&gt;millis()&lt;/code&gt; applies&#xA;equally to &lt;code&gt;micros()&lt;/code&gt;, except for the fact that &lt;code&gt;micros()&lt;/code&gt; rolls over&#xA;every 71.6 minutes, and the &lt;code&gt;setMillis()&lt;/code&gt; function provided below&#xA;does not affect &lt;code&gt;micros()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&quot;instants-timestamps-and-durations-wetz&quot;&gt;Instants, timestamps and durations&lt;/h2&gt;&#xA;&lt;p&gt;When dealing with time, we have to make the distinction between at least&#xA;two different concepts: &lt;em&gt;instants&lt;/em&gt; and &lt;em&gt;durations&lt;/em&gt;. An instant is a&#xA;point on the time axis. A duration is the length of a time interval,&#xA;i.e. the distance in time between the instants that define the start and&#xA;the end of the interval. The distinction between these concepts is not&#xA;always very sharp in everyday language. For example, if I say “&lt;em&gt;I will&#xA;be back in five minutes&lt;/em&gt;”, then “&lt;em&gt;five minutes&lt;/em&gt;” is the estimated&#xA;&lt;em&gt;duration&lt;/em&gt; of my absence, whereas “&lt;em&gt;in five minutes&lt;/em&gt;” is the &lt;em&gt;instant&lt;/em&gt;&#xA;of my predicted coming back. Keeping the distinction in mind is&#xA;important, because it is the simplest way to entirely avoid the rollover&#xA;problem.&lt;/p&gt;&#xA;&lt;p&gt;The return value of &lt;code&gt;millis()&lt;/code&gt; could be interpreted as a duration: the&#xA;time elapsed from the start of the program until now. This&#xA;interpretation, however, breaks down as soon as millis overflows. It is&#xA;generally far more useful to think of &lt;code&gt;millis()&lt;/code&gt; as returning a&#xA;&lt;em&gt;timestamp&lt;/em&gt;, i.e. a “label” identifying a particular instant. It could&#xA;be argued that this interpretation suffers from these labels being&#xA;ambiguous, as they are reused every 49.7 days. This is, however,&#xA;seldom a problem: in most embedded applications, anything that happened&#xA;49.7 days ago is ancient history we do not care about. Thus,&#xA;recycling the old labels should not be an issue.&lt;/p&gt;&#xA;&lt;h2 id=&quot;do-not-compare-timestamps-1ggw&quot;&gt;Do not compare timestamps&lt;/h2&gt;&#xA;&lt;p&gt;Trying to find out which among two timestamps is greater than the other&#xA;does not make sense. Example:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;unsigned long t1 = millis();&#xA;delay(3000);&#xA;unsigned long t2 = millis();&#xA;if (t2 &amp;gt; t1) { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Naively, one would expect the condition of the &lt;code&gt;if ()&lt;/code&gt; to be always&#xA;true. But it will actually be false if millis overflows during&#xA;&lt;code&gt;delay(3000)&lt;/code&gt;. Thinking of t1 and t2 as recyclable labels is the&#xA;simplest way to avoid the error: the label t1 has clearly been assigned&#xA;to an instant prior to t2, but in 49.7 days it will be reassigned&#xA;to a future instant. Thus, t1 happens both &lt;em&gt;before&lt;/em&gt; and &lt;em&gt;after&lt;/em&gt; t2. This&#xA;should make clear that the expression &lt;code&gt;t2 &amp;gt; t1&lt;/code&gt; makes no sense.&lt;/p&gt;&#xA;&lt;p&gt;But, if these are mere labels, the obvious question is: how can we do&#xA;any useful time calculations with them? The answer is: by restricting&#xA;ourselves to the only two calculations that make sense for timestamps:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;later_timestamp - earlier_timestamp&lt;/code&gt; yields a duration, namely the&#xA;amount of time elapsed between the earlier instant and the later&#xA;instant. This is the most useful arithmetic operation involving&#xA;timestamps.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;timestamp ± duration&lt;/code&gt; yields a timestamp which is some time after&#xA;(if using +) or before (if −) the initial timestamp. Not as useful as&#xA;it sounds, since the resulting timestamp can be used in only two&#xA;kinds of calculations...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thanks to modular arithmetics, both of these are guaranteed to work fine&#xA;across the millis rollover, at least as long as the delays involved are&#xA;shorter than 49.7 days.&lt;/p&gt;&#xA;&lt;h2 id=&quot;comparing-durations-is-fine-fvsc&quot;&gt;Comparing durations is fine&lt;/h2&gt;&#xA;&lt;p&gt;A duration is just the amount of milliseconds elapsed during some time&#xA;interval. As long as we do not need to handle durations longer than&#xA;49.7 days, any operation that physically makes sense should also&#xA;make sense computationally. We can, for example, multiply a duration by&#xA;a frequency to get a number of periods. Or we can compare two durations&#xA;to know which one is longer. For example, here are two alternative&#xA;implementations of &lt;code&gt;delay()&lt;/code&gt;. First, the buggy one:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void myDelay(unsigned long ms) {          // ms: duration&#xA;    unsigned long start = millis();       // start: timestamp&#xA;    unsigned long finished = start + ms;  // finished: timestamp&#xA;    for (;;) {&#xA;        unsigned long now = millis();     // now: timestamp&#xA;        if (now &amp;gt;= finished)              // comparing timestamps: BUG!&#xA;            return;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is the correct one:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void myDelay(unsigned long ms) {              // ms: duration&#xA;    unsigned long start = millis();           // start: timestamp&#xA;    for (;;) {&#xA;        unsigned long now = millis();         // now: timestamp&#xA;        unsigned long elapsed = now - start;  // elapsed: duration&#xA;        if (elapsed &amp;gt;= ms)                    // comparing durations: OK&#xA;            return;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Most C programmers would write the above loops in a terser form, like&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;while (millis() &amp;lt; start + ms) ;  // BUGGY version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;while (millis() - start &amp;lt; ms) ;  // CORRECT version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Although they look deceptively similar, the timestamp/duration&#xA;distinction should make clear which one is buggy and which one is&#xA;correct.&lt;/p&gt;&#xA;&lt;h2 id=&quot;what-if-i-really-need-to-compare-timestamps-i1pv&quot;&gt;What if I really need to compare timestamps?&lt;/h2&gt;&#xA;&lt;p&gt;Better try to avoid the situation. If it is unavoidable, there is still&#xA;hope if it is known that the respective instants are close enough:&#xA;closer than 24.85 days. Yes, our maximum manageable delay of&#xA;49.7 days just got cut in half.&lt;/p&gt;&#xA;&lt;p&gt;The obvious solution is to convert our timestamp comparison problem into&#xA;a duration comparison problem. Say we need to know whether instant t1 is&#xA;before or after t2. We choose some reference instant in their common&#xA;past, and compare the durations from this reference until both t1 and&#xA;t2. The reference instant is obtained by subtracting a long enough&#xA;duration from either t1 or t2:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;unsigned long reference_instant = t2 - LONG_ENOUGH_DURATION;&#xA;unsigned long from_reference_until_t1 = t1 - reference_instant;&#xA;unsigned long from_reference_until_t2 = t2 - reference_instant;&#xA;if (from_reference_until_t1 &amp;lt; from_reference_until_t2)&#xA;    // t1 is before t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This can be simplified as:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if (t1 - t2 + LONG_ENOUGH_DURATION &amp;lt; LONG_ENOUGH_DURATION)&#xA;    // t1 is before t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It is tempting to simplify further into &lt;code&gt;if (t1 - t2 &amp;lt; 0)&lt;/code&gt;. Obviously,&#xA;this does not work, because &lt;code&gt;t1 - t2&lt;/code&gt;, being computed as an unsigned&#xA;number, cannot be negative. This, however, although not portable, does&#xA;work:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if ((signed long)(t1 - t2) &amp;lt; 0)  // works with gcc&#xA;    // t1 is before t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The keyword &lt;code&gt;signed&lt;/code&gt; above is redundant (a plain &lt;code&gt;long&lt;/code&gt; is always&#xA;signed), but it helps make the intent clear. Converting to a signed long&#xA;is equivalent to setting &lt;code&gt;LONG_ENOUGH_DURATION&lt;/code&gt; equal to&#xA;24.85 days. The trick is not portable because, according to the C&#xA;standard, the result is &lt;em&gt;implementation defined&lt;/em&gt;. But since the gcc&#xA;compiler &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html&quot; rel=&quot;noreferrer&quot;&gt;promises to do the right&#xA;thing&lt;/a&gt;,&#xA;it works reliably on Arduino. If we wish to avoid implementation defined&#xA;behavior, the above signed comparison is mathematically equivalent to&#xA;this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;limits.h&amp;gt;&#xA;&#xA;if (t1 - t2 &amp;gt; LONG_MAX)  // too big to be believed&#xA;    // t1 is before t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with the only problem that the comparison looks backwards. It is also&#xA;equivalent, as long as longs are 32-bits, to this single-bit test:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if ((t1 - t2) &amp;amp; 0x80000000)  // test the &amp;quot;sign&amp;quot; bit&#xA;    // t1 is before t2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The last three tests are actually compiled by gcc into the exact same&#xA;machine code.&lt;/p&gt;&#xA;&lt;h2 id=&quot;how-do-i-test-my-sketch-against-the-millis-rollover-hlw0&quot;&gt;How do I test my sketch against the millis rollover&lt;/h2&gt;&#xA;&lt;p&gt;If you follow the precepts above, you should be all good. If you&#xA;nevertheless want to test, add this function to your sketch:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;util/atomic.h&amp;gt;&#xA;&#xA;void setMillis(unsigned long ms)&#xA;{&#xA;    extern unsigned long timer0_millis;&#xA;    ATOMIC_BLOCK (ATOMIC_RESTORESTATE) {&#xA;        timer0_millis = ms;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and you can now time-travel your program by calling&#xA;&lt;code&gt;setMillis(destination)&lt;/code&gt;. If you want it to go through the millis&#xA;overflow over and over again, like Phil Connors reliving Groundhog Day,&#xA;you can put this inside &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// 6-second time loop starting at rollover - 3 seconds&#xA;if (millis() - (-3000) &amp;gt;= 6000)&#xA;    setMillis(-3000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The negative timestamp above (-3000) is implicitly converted by the&#xA;compiler to an unsigned long corresponding to 3000 milliseconds before&#xA;the rollover (it is converted to 4294964296).&lt;/p&gt;&#xA;&lt;h2 id=&quot;what-if-i-really-need-to-track-very-long-durations-r1ce&quot;&gt;What if I really need to track very long durations?&lt;/h2&gt;&#xA;&lt;p&gt;If you need to turn a relay on and turn it off three months later, then&#xA;you really need to track the millis overflows. There are many ways to do&#xA;so. The most straightforward solution may be to simply extend &lt;code&gt;millis()&lt;/code&gt;&#xA;to 64 bits:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;uint64_t millis64() {&#xA;    static uint32_t low32, high32;&#xA;    uint32_t new_low32 = millis();&#xA;    if (new_low32 &amp;lt; low32) high32++;&#xA;    low32 = new_low32;&#xA;    return (uint64_t) high32 &amp;lt;&amp;lt; 32 | low32;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is essentially counting the rollover events, and using this count&#xA;as the 32 most significant bits of a 64 bit millisecond count.&#xA;For this counting to work properly, the function needs to be called at&#xA;least once every 49.7 days. However, if it is only called once per 49.7 days, for some cases it is possible that the check &lt;code&gt;(new_low32 &amp;lt; low32)&lt;/code&gt; fails and the code misses a count of &lt;code&gt;high32&lt;/code&gt;. Using millis() to decide when to make the only call to this code in a single &amp;quot;wrap&amp;quot; of millis (a specific 49.7 day window) could be very hazardous, depending on how the time frames line up. For safety, if using millis() to determine when to make the only calls to millis64(), there should be at least two calls in every 49.7 day window.&lt;/p&gt;&#xA;&lt;p&gt;Keep in mind, though, that 64 bit arithmetic is expensive on the&#xA;Arduino. It may be worth to reduce the time resolution in order to stay&#xA;at 32 bits.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2021-07-17T16:58:07.653" LastActivityDate="2021-07-17T16:58:07.653" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="12589" PostTypeId="1" AcceptedAnswerId="12590" CreationDate="2015-06-12T11:17:52.490" Score="0" ViewCount="344" Body="&lt;p&gt;I have an Arduino program that uses the &lt;a href=&quot;https://github.com/ivanseidel/ArduinoThread&quot; rel=&quot;nofollow noreferrer&quot;&gt;Thread library&lt;/a&gt; to create two concurrent threads, where:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Thread #1 blinks an LED every 500ms; and&lt;/li&gt;&#xA;&lt;li&gt;Thread #2 blinks another LED every 250ms&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I wired things up, flashed the program to my Arduino Due, and it ran beautifully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now trying to add a 3rd thread that &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Sweep&quot; rel=&quot;nofollow noreferrer&quot;&gt;sweeps&lt;/a&gt; a servo back and forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my design:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kIYK9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the schematic that Fritzing generated for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VSuFE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And an accompanying actual picture of the wire up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HjUyc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can see it, I've rigged Pin 10 as an &lt;code&gt;OUTPUT&lt;/code&gt;, and attached the servo's signal line to Pin 9. Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Thread.h&amp;gt;&#xA;#include &amp;lt;ThreadController.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int SERVO_SIGNAL_PIN = 9;&#xA;int SERVO_PWR_PIN = 10;&#xA;int LED_1_PIN = 12;&#xA;int LED_2_PIN = 13;&#xA;&#xA;Servo servo;&#xA;int pos = 0;&#xA;&#xA;static bool LED_1_STATUS = false;&#xA;static bool LED_2_STATUS = false;&#xA;&#xA;Thread blinkLED1Thread = Thread();&#xA;Thread blinkLED2Thread = Thread();&#xA;Thread servoThread = Thread();&#xA;ThreadController master = ThreadController();&#xA;&#xA;void setup() {&#xA;    pinMode(LED_1_PIN, OUTPUT);  &#xA;    pinMode(LED_2_PIN, OUTPUT);&#xA;    pinMode(SERVO_PWR_PIN, OUTPUT); &#xA;&#xA;    servo.attach(SERVO_SIGNAL_PIN);&#xA;&#xA;    blinkLED1Thread.onRun(blinkLED1);&#xA;    blinkLED1Thread.setInterval(250);&#xA;&#xA;    blinkLED2Thread.onRun(blinkLED2);&#xA;    blinkLED2Thread.setInterval(500);&#xA;&#xA;    servoThread.onRun(runServo);&#xA;&#xA;    master.add(&amp;amp;blinkLED1Thread);&#xA;    master.add(&amp;amp;blinkLED2Thread);&#xA;    master.add(&amp;amp;servoThread);&#xA;}&#xA;&#xA;void loop() {&#xA;    master.run();&#xA;}&#xA;&#xA;void runServo() {&#xA;    // Give the servo a few seconds to reset to the starting position.&#xA;    servo.write(0);&#xA;    delay(5000);&#xA;&#xA;    while(true) {&#xA;        for(pos = 0; pos &amp;lt; 180; pos += 1)  {&#xA;            servo.write(pos);&#xA;            delay(15);&#xA;        } &#xA;&#xA;        for(pos = 180; pos &amp;gt;=1; pos-=1) { &#xA;            servo.write(pos);&#xA;            delay(15);&#xA;        } &#xA;    }&#xA;}&#xA;&#xA;void blinkLED1() {&#xA;    LED_1_STATUS = !LED_1_STATUS;&#xA;    digitalWrite(LED_1_PIN, LED_1_STATUS);&#xA;}&#xA;&#xA;void blinkLED2() {&#xA;    LED_2_STATUS = !LED_2_STATUS;&#xA;    digitalWrite(LED_2_PIN, LED_2_STATUS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I flash this to the Due, two disappointing things happen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The LEDs, which previously blinked at the correct rates, now stay lit and do not blink at all; and&lt;/li&gt;&#xA;&lt;li&gt;The servo doesn't move&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now perhaps I have a bum servo, or perhaps I haven't wired it up correctly, but the most concerning thing to me is that the LEDs are no longer blinking. I have a &lt;em&gt;feeling&lt;/em&gt; that once I get those blinking again, the servo will &lt;em&gt;probably&lt;/em&gt; start sweeping as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone spot &lt;em&gt;anything&lt;/em&gt; that jumps out at them as being wrong here, wiring and code alike?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-06-12T14:56:29.453" Title="Arduino Servo circuit by example" Tags="|arduino-due|servo|wires|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12590" PostTypeId="2" ParentId="12589" CreationDate="2015-06-12T11:27:48.487" Score="2" Body="&lt;p&gt;One thing that immediately jumps out at me is you are trying to power the servo from a digital pin.  That is very very wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo must be powered from the +5V pin (or +3.3V pin if it's a 3.3V servo) and only the &quot;pulse&quot; pin is connected to an Arduino's PWM capable IO pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't know how the &quot;Threads&quot; library works, but it looks to me like it's not real threads, but a &quot;round robin&quot; execution of function with time delays.  If one of your functions never returns (like your servo one) then the whole system will lock up.  You need to make your servo function non-blocking like your LED functions.  Give it a 15ms time setting and only move one step of the servo each time it gets called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, according to comments and research I can confirm that in fact the Thread library is really badly named.  It doesn't run threads, it just runs different functions at different times.  Those functions MUST be &quot;single shot&quot; - i.e., they MUST complete before anything else can happen.  There is absolutely no concurrency whatsoever.  It is entirely up to you to ensure that all your &quot;threads&quot; are fairly simple repetitive operations which are to be run at specific points in time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the operation is thus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Add a function and its time to a list.&lt;/li&gt;&#xA;&lt;li&gt;Work through the list to find a function whose time has expired&lt;/li&gt;&#xA;&lt;li&gt;Call that function&lt;/li&gt;&#xA;&lt;li&gt;Continue through the table&lt;/li&gt;&#xA;&lt;li&gt;Go back to the beginning&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have two functions both with the same time then one function will be called first and execute to completion, then the other function will be called afterwards, to execute to completion.  Only when a function returns is the system able to move on to the next entry in the function list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;must not&lt;/em&gt; use &lt;code&gt;delay()&lt;/code&gt; in your &quot;thread&quot; functions for anything more than maybe 1-2ms of delay &lt;em&gt;in total&lt;/em&gt;.  You &lt;em&gt;MUST&lt;/em&gt; return from your thread with enough time for your next timed event to execute, otherwise it will be delayed, or never run at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your servo thread would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add my current &quot;direction&quot; to the servo value&lt;/li&gt;&#xA;&lt;li&gt;If the servo value &amp;lt; 0 or &gt; 180 then invert the direction and limit the value to 0-180.&lt;/li&gt;&#xA;&lt;li&gt;Write the value to the servo&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That is then triggered every 15ms by the thread library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as real code it may look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void runServo() {&#xA;    static int direction = 1; // 1 = up, -1 is down&#xA;    static int value = 0;&#xA;&#xA;    value += direction;&#xA;    if ((value &amp;lt;= 0) || (value &amp;gt;= 180)) {&#xA;        direction = 0 - direction; // Change direction from + to - or - to +&#xA;    }&#xA;&#xA;    value = max(min(180, value), 0); // Clamp it to between 0 and 180&#xA;&#xA;    servo.write(value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-12T14:56:29.453" LastActivityDate="2015-06-12T14:56:29.453" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12591" PostTypeId="2" ParentId="12587" CreationDate="2015-06-12T13:14:02.603" Score="36" Body="&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Short version:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;code&gt;unsigned long&lt;/code&gt; is 0 to 4,294,967,295 (2^32 - 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So lets say &lt;code&gt;previousMillis&lt;/code&gt; is 4,294,967,290 (5 ms before rollover), and &lt;code&gt;currentMillis&lt;/code&gt; is 10 (10ms after rollover). Then &lt;code&gt;currentMillis - previousMillis&lt;/code&gt; is actual 16 (not -4,294,967,280) since the result will be calculated as an &lt;strong&gt;unsigned&lt;/strong&gt; long (which can't be negative, so itself will roll around). You can check this simply by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.println( ( unsigned long ) ( 10 - 4294967290 ) ); // 16&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the above code will work perfectly fine. The trick is to always calculate the time difference, and not compare the two time values.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="-1" LastEditDate="2016-04-06T18:19:07.480" LastActivityDate="2016-04-06T18:19:07.480" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12592" PostTypeId="2" ParentId="12515" CreationDate="2015-06-12T14:33:06.260" Score="0" Body="&lt;p&gt;I would actually be quite surprised if &lt;code&gt;outsideClassRotation()&lt;/code&gt; actually&#xA;worked. My guess is that &lt;em&gt;it does not work as is&lt;/em&gt;. Maybe it did work at&#xA;some point, but then you made some subtle changes to your code and did&#xA;not check that it is still working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the deal: there are two &lt;code&gt;setRotation()&lt;/code&gt; methods:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Adafruit_GFX::setRotation(unsigned char)&lt;/code&gt; does very little besides&#xA;storing the rotation angle... which is not used anyway.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;Adafruit_ILI9341::setRotation(unsigned char)&lt;/code&gt; actually sends commands&#xA;to the LCD asking it to apply the rotation; this is the method you&#xA;want.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;em&gt;these methods are not &lt;code&gt;virtual&lt;/code&gt;&lt;/em&gt;, which means that&#xA;when you call them through a pointer, as in&#xA;&lt;code&gt;some_pointer-&amp;gt;setRotation(the_angle);&lt;/code&gt;, you get the method&#xA;corresponding to &lt;em&gt;the type of the pointer&lt;/em&gt;, not the type of the actual&#xA;object. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;tft-&amp;gt;setRotation(the_angle);     // calls Adafruit_ILI9341::setRotation()&#xA;ptrTft-&amp;gt;setRotation(the_angle);  // calls Adafruit_GFX::setRotation()&#xA;passed-&amp;gt;setRotation(the_angle);  // calls Adafruit_GFX::setRotation()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked this by uncommenting your call to &lt;code&gt;outsideClassRotation()&lt;/code&gt; and&#xA;disassembling the compiled binary: both times you are calling&#xA;&lt;code&gt;Adafruit_GFX::setRotation()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: change your &lt;code&gt;Adafruit_GFX *&lt;/code&gt; pointers to be of&#xA;type &lt;code&gt;Adafruit_ILI9341 *&lt;/code&gt;, or patch Adafruit_GFX.h to make&#xA;&lt;code&gt;setRotation()&lt;/code&gt; virtual.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-12T14:33:06.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12593" PostTypeId="1" CreationDate="2015-06-12T15:35:22.160" Score="1" ViewCount="717" Body="&lt;p&gt;I'm designing a PCB with a standard arduino ATMEGA328 DIP IC. Do I need to make a connection to the reset pin?&lt;/p&gt;&#xA;" OwnerUserId="276" LastActivityDate="2015-06-12T15:42:14.363" Title="What to with reset pin when laying out Arduino PCB?" Tags="|system-design|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12594" PostTypeId="2" ParentId="12593" CreationDate="2015-06-12T15:41:28.917" Score="0" Body="&lt;p&gt;Yes, you do.  The pin needs to be pulled up to Vcc via a pullup resistor - typically 10KΩ.  Also, if you are using the Arduino bootloader and want to program via serial then this pin should be connected to your serial interface's DTR pin through a 100nF (typically) capacitor.  It is also often desirable to provide a reset button which switches this pin to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should examine the Arduino Uno's schematics and use them as a reference.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-12T15:41:28.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12595" PostTypeId="2" ParentId="12593" CreationDate="2015-06-12T15:42:14.363" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Atmel AVR042: AVR Hardware Design Considerations&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QDsBy.png&quot; alt=&quot;AVR reset connections&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-12T15:42:14.363" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12596" PostTypeId="1" CreationDate="2015-06-12T15:51:41.400" Score="1" ViewCount="457" Body="&lt;p&gt;So I'm taking a class where the project is to create a new embedded language. We are using OCaml for the compiler, so I was looking for a way to interface with AVR or its C library in such a way as I can write programs in my language, then compile and somehow get it on the arduino I have. I was curious if there's a library for OCaml or some sort of white paper for interfacing with the board at a high level or even at a low level where I can get this to work.&lt;/p&gt;&#xA;" OwnerUserId="10622" LastEditorUserId="37523" LastEditDate="2019-12-05T01:53:07.510" LastActivityDate="2019-12-05T01:53:07.510" Title="New Language - Interfacing with AVR" Tags="|arduino-uno|programming|avr-gcc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12597" PostTypeId="2" ParentId="12586" CreationDate="2015-06-12T17:00:54.107" Score="0" Body="&lt;p&gt;Since no other code is posted, I am going to guess that you're performing a loop on months[], which has 13 elements (last one is NULL). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are likely also trying to walk the days[] array (or some other array), which only has 12 elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since days[] or the other (not pasted) array doesn't have 13 elements, you're probably overriding a critical bootloader memory which causes a crash.&lt;/p&gt;&#xA;" OwnerUserId="10565" LastActivityDate="2015-06-12T17:00:54.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12598" PostTypeId="1" CreationDate="2015-06-12T18:26:03.570" Score="2" ViewCount="109" Body="&lt;p&gt;Sorry folks, I understand this question has been asked quite few times, but I wasn't able to find a definitive answer: my Mega 2560 R3 is powered by 7.7V from Vin, and runs at a steady 135mA (in theory it's 2.7 x 0.135 = 0.38W dissipation). But the regulator with a heat sink still gets hot. Not burning hot but definitely to a point where you'd question whether it's a good idea to leave it running for months.&lt;br&gt;&lt;br&gt;Is this normal? Also is this a sustainable plan for a long running project?&lt;br&gt;&lt;br&gt;The 7.7V (7.7 because I remember the regulator needs a voltage around that to work) is coming from a variable step down module that could deliver a 5V. However I've noticed although it does stabilize at 5V , when the power just comes on it would surge to ~9V for a fraction of a second. My understanding is the 5V input on arduino is assuming clean 5V, so I hesitated there. &lt;br&gt;&lt;br&gt;Any suggestions? Thanks! &lt;/p&gt;&#xA;" OwnerUserId="10584" LastActivityDate="2015-06-13T09:02:30.297" Title="Hot regulator 7.7V Vin @ 135mA" Tags="|arduino-mega|power|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12599" PostTypeId="2" ParentId="12574" CreationDate="2015-06-12T18:59:15.627" Score="-1" Body="&lt;p&gt;You should add a random delay in setup of receiver and reduce the sampling time of the receiver to 200ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, digital communication is an INSANELY EXTREMELY complex process, especially on the physical layer. This is not the correct way for two arduinos to digitally communicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you are a teacher and are trying to demonstrate why this would fail, (not criticising), you mustn't use it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use the Arduino wire library to establish communication instead. You can send whole integers, and it's totally reliable (it uses hash checks, guaranteeing correct communication even at 1152000 baud). As a comparison, you're at 1 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a tutorial here: &lt;a href=&quot;http://www.instructables.com/id/I2C-between-Arduinos/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/I2C-between-Arduinos/&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2015-06-12T18:59:15.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12600" PostTypeId="1" AcceptedAnswerId="12601" CreationDate="2015-06-12T20:03:17.030" Score="0" ViewCount="104" Body="&lt;p&gt;I am trying out some code using the Arduino IDE. The code basically tries to connect to a server and push some data to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I upload the sketch to the Arduino from Mac (Apple PC running on Mac OS) the code works as expected without an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I upload the same code/sketch from a Linux machine on Ubuntu, the arduino does not operate as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried taking a diff comparison of the HEX files created in both machines to check whether there are any differences (expecting very few). But found that there a lot of differences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing? Why isn't my code working when uploaded via the Linux PC!!!!!&lt;/p&gt;&#xA;" OwnerUserId="10625" LastEditorUserId="313" LastEditDate="2015-12-11T00:02:09.903" LastActivityDate="2015-12-11T00:02:09.903" Title="Same Arduino Sketch when uploaded from a Linux machine does not work" Tags="|arduino-uno|linux|mac-os|" AnswerCount="1" CommentCount="4" ClosedDate="2021-11-27T17:12:39.510" ContentLicense="CC BY-SA 3.0" />
  <row Id="12601" PostTypeId="2" ParentId="12600" CreationDate="2015-06-12T20:31:10.200" Score="1" Body="&lt;p&gt;Got this sorted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue was that different versions of the library was being used in both the PCs. One we made sure that the Linux PC used the same as the MAC one it all worked fine!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Guys&lt;/p&gt;&#xA;" OwnerUserId="10625" LastActivityDate="2015-06-12T20:31:10.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12602" PostTypeId="1" CreationDate="2015-06-12T20:40:58.917" Score="0" ViewCount="487" Body="&lt;p&gt;How does one go about programming the 16u2 on an Uno? &lt;strong&gt;I have the isp header (for the 16u2) hooked up to another Uno programmed as ArduinoISP&lt;/strong&gt; I'm not talking about DFU or USB-&gt;UART, I'm talking about using it like a standalone chip (Like, say, a Leonardo or Yun [the 32u4, not the Linux, obviously])&lt;/p&gt;&#xA;" OwnerUserId="4664" LastEditorUserId="4664" LastEditDate="2015-06-14T01:28:23.610" LastActivityDate="2015-07-14T02:14:34.147" Title="16u2 programming" Tags="|isp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12603" PostTypeId="2" ParentId="12602" CreationDate="2015-06-12T20:55:49.473" Score="1" Body="&lt;p&gt;First you need to write a program for it. There is no Arduino core for the 'XU2, so you will need to write it out longhand. Then you compile it. Then you upload it using ISP. Then you run it. Note that the only pins you have access to on the board are the UART pins, the two on the LEDs, and the 3 on the ISP header.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-12T20:55:49.473" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12604" PostTypeId="2" ParentId="12587" CreationDate="2015-06-12T21:02:24.553" Score="1" Body="&lt;p&gt;Wrap the &lt;code&gt;millis()&lt;/code&gt; in a class!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Logic:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use id's instead of &lt;code&gt;millis()&lt;/code&gt; directly.&lt;/li&gt;&#xA;&lt;li&gt;Compare reversals using id's. This is clean and rollover independent.&lt;/li&gt;&#xA;&lt;li&gt;For specific applications, to calculate exact difference between two id's, keep track of reversals and stamps. Calculate the difference.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Keeping track of reversals:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Update a local stamp periodically faster than &lt;code&gt;millis()&lt;/code&gt;. This will help you find out if &lt;code&gt;millis()&lt;/code&gt; has overflown.&lt;/li&gt;&#xA;&lt;li&gt;The period of the timer determines accuracy&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class Timer {&#xA;&#xA;public:&#xA;    static long last_stamp;&#xA;    static long *stamps;&#xA;    static int *reversals;&#xA;    static int count;&#xA;    static int reversal_count;&#xA;&#xA;    static void setup_timer() {&#xA;        // Setup Timer2 overflow to fire every 8ms (125Hz)&#xA;        //   period [sec] = (1 / f_clock [sec]) * prescale * (255-count)&#xA;        //                  (1/16000000)  * 1024 * (255-130) = .008 sec&#xA;&#xA;&#xA;        TCCR2B = 0x00;        // Disable Timer2 while we set it up&#xA;&#xA;        TCNT2  = 130;         // Reset Timer Count  (255-130) = execute ev 125-th T/C clock&#xA;        TIFR2  = 0x00;        // Timer2 INT Flag Reg: Clear Timer Overflow Flag&#xA;        TIMSK2 = 0x01;        // Timer2 INT Reg: Timer2 Overflow Interrupt Enable&#xA;        TCCR2A = 0x00;        // Timer2 Control Reg A: Wave Gen Mode normal&#xA;        TCCR2B = 0x07;        // Timer2 Control Reg B: Timer Prescaler set to 1024&#xA;&#xA;        count = 0;&#xA;        stamps = new long[50];&#xA;        reversals = new int [10];&#xA;        reversal_count =0;&#xA;    }&#xA;&#xA;    static long get_stamp () {&#xA;        stamps[count++] = millis();&#xA;        return count-1;&#xA;    }&#xA;&#xA;    static bool compare_stamps_by_id(int s1, int s2) {&#xA;        return s1 &amp;gt; s2;&#xA;    }&#xA;&#xA;    static long long get_stamp_difference(int s1, int s2) {&#xA;        int no_of_reversals = 0;&#xA;        for(int j=0; j &amp;lt; reversal_count; j++)&#xA;        if(reversals[j] &amp;lt; s2 &amp;amp;&amp;amp; reversals[j] &amp;gt; s1)&#xA;            no_of_reversals++;&#xA;        return stamps[s2]-stamps[s1] + 49.7 * 86400 * 1000;       &#xA;    }&#xA;&#xA;};&#xA;&#xA;long Timer::last_stamp;&#xA;long *Timer::stamps;&#xA;int *Timer::reversals;&#xA;int Timer::count;&#xA;int Timer::reversal_count;&#xA;&#xA;ISR(TIMER2_OVF_vect) {&#xA;&#xA;    long stamp = millis();&#xA;    if(stamp &amp;lt; Timer::last_stamp) // reversal&#xA;        Timer::reversals[Timer::reversal_count++] = Timer::count;&#xA;    else &#xA;        ; // no reversal&#xA;    Timer::last_stamp = stamp;    &#xA;    TCNT2 = 130;     // reset timer ct to 130 out of 255&#xA;    TIFR2 = 0x00;    // timer2 int flag reg: clear timer overflow flag&#xA;};&#xA;&#xA;// Usage&#xA;&#xA;void setup () {&#xA;    Timer::setup_timer();&#xA;&#xA;    long s1 = Timer::get_stamp();&#xA;    delay(3000);&#xA;    long s2 = Timer::get_stamp();&#xA;&#xA;    Timer::compare_stamps_by_id(s1, s2); // true&#xA;&#xA;    Timer::get_stamp_difference(s1, s2); // return true difference, taking into account reversals&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/26363/how-do-i-create-a-timer-interrupt-with-arduino&quot;&gt;Timer credits&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="297" LastEditorUserId="7508" LastEditDate="2015-06-13T12:59:59.637" LastActivityDate="2015-06-13T12:59:59.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12605" PostTypeId="2" ParentId="12551" CreationDate="2015-06-12T21:08:05.277" Score="0" Body="&lt;p&gt;To keep the 10Hz accelerometer sample rate consistent, you'll need an 10Hz interrupt routine to do the sampling, and probably queue them somewhere, as they will accumulate while you're off measuring the heart rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your main loop can collect any accelerometer samples out of the queue periodically, and at appropriate intervals, read the heart beat. This organization will keep the accelerometer sample rate stead whether your main loop has anything else to do or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make the queue more than long enough to hold all the samples that could collect during a heartbeat measurement, which you should probably make one at a time, even though you might do it in rapid succession, so the main loop gets to drain the accelerometer queue as often as possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you'll need a queue as large as (10 Hz * 10 sec * maxPossibleConsecutiveHeartBeatMeasurements * factorOfSafety * sizeof(oneSample) bytes; and you don't have a whole lot of memory to play with in an Atmega 328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where will you be storing the measurements between Bluetooth connects? If it's an SD card, you'll need some space for its write-buffer, and the main loop will have to manage the card writing.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-12T21:08:05.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12606" PostTypeId="2" ParentId="12596" CreationDate="2015-06-13T03:48:28.340" Score="1" Body="&lt;p&gt;The OCAML compiler can emit C code and the Arduino IDE takes C code, so in theory it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to get the OCAML runtime code ported over to the Arduino IDE. At very least, I think this would be a lot of work. At worst, the Arduino might not have enough memory to support it.&lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-06-13T03:48:28.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12607" PostTypeId="1" CreationDate="2015-06-13T07:36:58.377" Score="1" ViewCount="784" Body="&lt;p&gt;Can someone explain (in a non-wiki technical way) what reverse current is through an Arduino ? Cheers y'all &lt;/p&gt;&#xA;" OwnerUserId="10630" LastActivityDate="2015-07-13T09:10:00.907" Title="What is Reverse Current through an Arduino?" Tags="|sketch|current|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12608" PostTypeId="2" ParentId="12607" CreationDate="2015-06-13T08:54:06.447" Score="1" Body="&lt;p&gt;It's current flowing &quot;the wrong way&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The electronics inside the main chip are designed such that the + side (Vcc) must be at a significantly higher voltage than the - side (GND).  By significantly I mean 2.1-5.5V higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of that it is expected that the current will flow through the components in one direction (or in a couple of pre-determined directions depending on settings).  Any situation which causes a reversal of that current through the internals is bad, and as called &quot;reverse current&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be caused by something as simple as connecting a power supply backwards, or more technical things like the &quot;Back EMF&quot; from an inductive load (motor, relay, etc) entering a pin that is an output and flowing backwards up to Vcc, or &quot;Back Powering&quot; where the chip is not powered but some external device connected to it is powered, and it &quot;leeches&quot; power backwards through IO pins to power the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of those situations are bad and should be avoided.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-13T08:54:06.447" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12611" PostTypeId="1" CreationDate="2015-06-13T09:55:20.843" Score="1" ViewCount="465" Body="&lt;p&gt;I am trying to use the &lt;a href=&quot;http://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Servo&lt;/a&gt; library to drive a simple &lt;a href=&quot;http://torqpro.com/?product=sg92r-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;servo&lt;/a&gt; and am having some difficulty getting it to even move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/91RAN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the schematic that Fritzing generated for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sPxMd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int SERVO_SIGNAL_PIN = 9;&#xA;&#xA;Servo servo;&#xA;int pos = 0;&#xA;bool GOING_UP = true;&#xA;&#xA;void setup() {&#xA;    // Attach the servo and give it a few seconds to reset to the starting position.&#xA;    servo.attach(SERVO_SIGNAL_PIN);&#xA;    servo.write(0);&#xA;    delay(5000);&#xA;}&#xA;&#xA;void loop() {&#xA;    if((GOING_UP &amp;amp;&amp;amp; pos &amp;lt; 180) || pos == 0) {&#xA;        GOING_UP = true; &#xA;    } else {&#xA;        GOING_UP = false;&#xA;    }&#xA;&#xA;    int step = 1;&#xA;&#xA;    if(!GOING_UP) {&#xA;        step *= -1; &#xA;    }&#xA;&#xA;    pos += step;&#xA;&#xA;    servo.write(pos);&#xA;    delay(15);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this, nothing happens. When I attach a multimeter and set it to the &quot;6V&quot; setting, I have found some strange readings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When I connect the red multimeter lead (&quot;red lead&quot;) to the 5V line connecting the Arduino to the breadboard, and the black multimeter lead (&quot;black lead&quot;) to the black GND line connecting the Arduino to the breadboard, I get readings around 5V; but...&lt;/li&gt;&#xA;&lt;li&gt;When I connect the red lead to the red power line going &lt;em&gt;to&lt;/em&gt; the servo, and the black lead to the black GND line coming back &lt;em&gt;from&lt;/em&gt; the servo, I get a voltage reading of roughly &lt;strong&gt;-20V&lt;/strong&gt;!!!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what this means/implies. Is anything jumping out at anyone? Anything I can troubleshoot here? Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-07-15T16:30:53.973" Title="Arduino Servo is behaving strangely" Tags="|arduino-due|servo|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12613" PostTypeId="1" AcceptedAnswerId="12614" CreationDate="2015-06-13T13:36:16.967" Score="2" ViewCount="1148" Body="&lt;p&gt;I have made my custom serial(UART) library.&#xA;So I made uart.h and uart.cpp files as following.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;uart.h&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef UART_H&#xA;#define UART_H&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;//creating class named uart&#xA;class uart{&#xA;&#xA;  public:&#xA;&#xA;    // creating constructor&#xA;    uart(void);&#xA;&#xA;    //function to start uart at given baudrate&#xA;    void start(int baudrate);&#xA;&#xA;    // function to read uart input&#xA;    unsigned char read();&#xA;&#xA;    // function to print data on serial monitor&#xA;    void print(unsigned char data);&#xA;&#xA;    // function to print string on serial monitor&#xA;    void print(char *string);&#xA;&#xA;    // function to print data with given base&#xA;    void print(unsigned char data,unsigned int base);&#xA;&#xA;    //function to print data like printf&#xA;    void print(char* str,unsigned char data);&#xA;&#xA;    // function to read data by printing string&#xA;    unsigned char read(char* string);&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;uart.cpp&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;uart.h&quot;&#xA;&#xA;uart::uart(void);&#xA;&#xA;void uart::start(int baudrate){&#xA;&#xA;    long BAUDRATE = ((F_CPU)/(baudrate*16UL)-1);&#xA;&#xA;    UBRR0H = (BAUDRATE &amp;gt;&amp;gt; 8);&#xA;&#xA;    UBRR0L = BAUDRATE;&#xA;&#xA;    // enable recieve and transmit&#xA;    UCSR0B |= 1 &amp;lt;&amp;lt; RXEN0 | 1 &amp;lt;&amp;lt; TXEN0;&#xA;&#xA;    // data size is equal to 8 bits&#xA;    UCSR0C |= 1 &amp;lt;&amp;lt; UCSZ00 | 1 &amp;lt;&amp;lt; UCSZ01;&#xA;}&#xA;&#xA;unsigned char uart::read(){&#xA;&#xA;    //wait until receive complete.&#xA;    while(!(UCSR0A &amp;amp; (1 &amp;lt;&amp;lt; RXC0)));&#xA;&#xA;    // return received byte&#xA;    return UDR0;&#xA;}&#xA;&#xA;&#xA;void uart::print(unsigned char data){&#xA;&#xA;    // wait until UDR is empty&#xA;    while(!(UCSR0A &amp;amp; (1 &amp;lt;&amp;lt; UDRE0)));&#xA;&#xA;    //place data into UDR&#xA;    UDR0 = data;&#xA;}&#xA;&#xA;void uart::print(unsigned char* string){&#xA;&#xA;    int index = 0;&#xA;&#xA;    // print string character by character&#xA;    while(string[index] != '\0'){&#xA;&#xA;        print(string[index]);&#xA;&#xA;        index++;&#xA;    }&#xA;}&#xA;&#xA;void uart::print(unsigned char data,unsigned int base){&#xA;&#xA;&#xA;    //buffer to store converted data&#xA;    char buffer[10];&#xA;&#xA;    //convert data to ascii&#xA;    itoa(data,buffer,base);&#xA;&#xA;    //print converted data&#xA;    print(buffer);&#xA;}&#xA;&#xA;// function to print data like printf(%d,data);&#xA;void uart::print(char* str,unsigned char data){&#xA;&#xA;    int index = 0;&#xA;&#xA;    // print string character by character&#xA;    while(str[index] != '\0'){&#xA;&#xA;        if(str[index] == '%'){&#xA;&#xA;            index++;&#xA;&#xA;            if(str[index]=='d') print(data,10);&#xA;&#xA;            else if(str[index] == 'b') print(data,2);&#xA;&#xA;            else if(str[index] == 'x') print(data,16);&#xA;&#xA;            index++;&#xA;        }&#xA;        print(str[index]);&#xA;&#xA;        index++;&#xA;    }&#xA;}&#xA;&#xA;&#xA;unsigned char uart::read(unsigned char* string){&#xA;    // print given string&#xA;    print(string);&#xA;    // return read char&#xA;    return(read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;test.cpp&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;uart.h&quot;&#xA;int main(){&#xA;    uart.start(9600);&#xA;    uart.print(&quot;Hello world\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now all of above function works if i write all function and declations in single &lt;strong&gt;.h&lt;/strong&gt; file and don't divide my header file in &lt;strong&gt;.h&lt;/strong&gt; and &lt;strong&gt;.cpp&lt;/strong&gt; file. if i compile this given program i get following error.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src/uart.cpp&#xA;src/uart.cpp:3:16: error: declaration of 'uart::uart()' outside of class is not definition [-fpermissive]&#xA; uart::uart(void);&#xA;                ^&#xA;src/uart.cpp:39:6: error: prototype for 'void uart::print(unsigned char*)' does not match any in class 'uart'&#xA; void uart::print(unsigned char* string){&#xA;      ^&#xA;In file included from src/uart.cpp:1:0:&#xA;src/uart.h:31:7: error: candidates are: void uart::print(char*, unsigned char)&#xA;  void print(char* str,unsigned char data);&#xA;       ^&#xA;src/uart.h:28:7: error:                 void uart::print(unsigned char, unsigned int)&#xA;  void print(unsigned char data,unsigned int base);&#xA;       ^&#xA;src/uart.h:25:7: error:                 void uart::print(char*)&#xA;  void print(char *string);&#xA;       ^&#xA;src/uart.cpp:30:6: error:                 void uart::print(unsigned char)&#xA; void uart::print(unsigned char data){&#xA;      ^&#xA;src/uart.cpp:91:15: error: prototype for 'unsigned char uart::read(unsigned char*)' does not match any in class 'uart'&#xA; unsigned char uart::read(unsigned char* string){&#xA;               ^&#xA;In file included from src/uart.cpp:1:0:&#xA;src/uart.h:34:16: error: candidates are: unsigned char uart::read(char*)&#xA;  unsigned char read(char* string);&#xA;                ^&#xA;src/uart.cpp:20:15: error:                 unsigned char uart::read()&#xA; unsigned char uart::read(){&#xA;               ^&#xA;.build/uno/Makefile:166: recipe for target '.build/uno/src/uart.o' failed&#xA;make: *** [.build/uno/src/uart.o] Error 1&#xA;Make failed with code 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt;  I use &lt;code&gt;inotool&lt;/code&gt; to compile and upload my programs to arduino and it works great. So you will find &lt;code&gt;src/&lt;/code&gt; in error.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please help me. I'm stuck here.&lt;/p&gt;&#xA;" OwnerUserId="10634" LastEditorUserId="10634" LastEditDate="2015-06-18T15:59:12.833" LastActivityDate="2015-06-18T15:59:12.833" Title="Custom Arduino library problem" Tags="|serial|library|avr|uart|class|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12614" PostTypeId="2" ParentId="12613" CreationDate="2015-06-13T13:58:37.797" Score="3" Body="&lt;pre&gt;&lt;code&gt;uart::uart(void);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's a prototype, not a function.  It needs a body.  Also, using &quot;void&quot; to say &quot;no parameters&quot; is really confusing.  Better to leave it out all together.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart::uart() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart.start(9600);&#xA;uart.print(&quot;Hello world\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;uart&lt;/code&gt; is a class, not an instance.  You should be using &lt;code&gt;uart::start(9600)&lt;/code&gt; if you first set your functions to be &lt;code&gt;static&lt;/code&gt;, or create an instance from the &lt;code&gt;uart&lt;/code&gt; class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart myUart;&#xA;&#xA;int main() {&#xA;    myUart.begin(9600);&#xA;    myUart.print(&quot;Hello world\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Watch your random &lt;code&gt;unsigned&lt;/code&gt; entries...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart.h:&#xA;unsigned char read(char* string);&#xA;&#xA;uart.c:&#xA;unsigned char uart::read(unsigned char* string){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... There may be others too.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-13T14:12:26.890" LastActivityDate="2015-06-13T14:12:26.890" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12615" PostTypeId="2" ParentId="12596" CreationDate="2015-06-13T14:36:35.893" Score="1" Body="&lt;p&gt;I have no experience with OCaml or with writing compilers, but I would&#xA;suggest that you first &lt;em&gt;learn&lt;/em&gt; how to program the Arduino, then &lt;em&gt;teach&lt;/em&gt;&#xA;your compiler to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may start by using the Arduino IDE and a couple basic tutorials.&#xA;There is an option in the IDE for displaying all the commands it runs to&#xA;get your program compiled and linked. Take note of these commands, then&#xA;throw the IDE away. Alternatively, you can download one of the few&#xA;Arduino Makefiles that float around the Web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will see that the basic toolset you need is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The AVR flavor of GNU GCC and the binutils. This allows you to program&#xA;the AVR in assembly, C and C++. Calling these tools from your own&#xA;compiler should be as easy as calling them from the command-line.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;avr-libc&lt;/a&gt;, which is a port of&#xA;the libc for the AVR, together with some AVR-specific stuff, and the C&#xA;runtime. It does &lt;em&gt;not&lt;/em&gt; provide a hardware abstraction layer.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino core library, a beginner-oriented C++ library built on top&#xA;of avr-libc. It does provide a hardware abstraction layer and is&#xA;source-level compatible with non-AVR based Arduinos.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In terms of language and API, your main choices are: AVR assembly, C +&#xA;avr-libc, C++ + avr-libc, C++ + Arduino core + avr-libc. There are&#xA;others, of course, these are just the better known. Pick your favorite,&#xA;learn how to use it, then teach your compiler.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-13T14:36:35.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12616" PostTypeId="1" CreationDate="2015-06-13T14:49:57.543" Score="1" ViewCount="2807" Body="&lt;p&gt;I have an Arduino Uno attached to my MacBook Air running the Arduino IDE 1.6.4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino was visible in the Serial port section this morning, but then it just disappeared. The ON light on the Arduino still comes on, but I cannot connect to it through the port section. I attached the Uno to another computer and it did not appear there either. However, when a different Arduino is connected to my computer it does show up. I also tried using a different IDE version, and it did not appear there either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the other topics I found regarding this were saying it is the OS's fault, but since I was able to see the other Arduino, I am pretty sure it is not. I updated the FTDI drivers, and I tried using a powered hub and it is still not there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I took the chip out of the UNO that is not appearing and put it into a working UNO, I was able to see it, is it possible that the Serial port is just not working, and if so how would I fix that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10529" LastEditorUserId="10529" LastEditDate="2015-12-13T13:40:59.413" LastActivityDate="2016-04-11T15:21:15.793" Title="Arduino Uno not appearing under ports" Tags="|arduino-uno|serial|uploading|" AnswerCount="2" CommentCount="30" ContentLicense="CC BY-SA 3.0" />
  <row Id="12617" PostTypeId="1" CreationDate="2015-06-13T16:57:41.437" Score="2" ViewCount="3022" Body="&lt;p&gt;I connected an ArduiMU v3+ via a FTDI-cable to my Mac (OS X 10.10) (latest VC FTDI driver is installed and loaded).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the Arduino-software the Serial Monitor (monitoring /dev/cu.usbserial-AJ038NZ3) shows &#xA;a lot of weird ASCII characters. &#xA;What could be the reason for this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kiBjW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's part of the code I uploaded to the ArduiMu:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;&#xA;// Init Serial for use by Send.cpp and Receive.cpp&#xA;Serial.begin(115200);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    Receive::doTasks();&#xA;}&#xA;&#xA;    void Send::flexSensorData() {&#xA;    char packet[64];&#xA;    int packetLength = 0;&#xA;    IntUnion intUnion;&#xA;    FlexSensors::read();    // read sensors before sending&#xA;#ifdef BINARY_PACKETS&#xA;    packet[packetLength++] = 'F';&#xA;    intUnion.intVal= (int)FlexSensors::channel[0];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    intUnion.intVal= (int)FlexSensors::channel[1];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    intUnion.intVal= (int)FlexSensors::channel[2];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    intUnion.intVal= (int)FlexSensors::channel[3];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    intUnion.intVal= (int)FlexSensors::channel[4];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    intUnion.intVal= (int)FlexSensors::channel[5];&#xA;    packet[packetLength++] = intUnion.msb;&#xA;    packet[packetLength++] = intUnion.lsb;&#xA;    packet[packetLength++] = calcChecksum(packet, packetLength);&#xA;#else&#xA;    packet[packetLength++] = 'F';&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[0]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[1]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[2]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[3]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[4]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, (int)FlexSensors::channel[5]);&#xA;    packet[packetLength++] = ',';&#xA;    IntValToChars(packet, &amp;amp;packetLength, calcChecksum(packet, packetLength));&#xA;    packet[packetLength++] = '\r';&#xA;#endif&#xA;    Serial.write((uint8_t*)packet, packetLength);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10636" OwnerDisplayName="Hedge" LastEditorUserId="37523" LastEditDate="2019-08-12T16:35:08.800" LastActivityDate="2019-08-12T16:35:08.800" Title="Arduino Serial Monitor shows strange ASCII characters" Tags="|usb|serial|ftdi|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="12619" PostTypeId="1" AcceptedAnswerId="12635" CreationDate="2015-06-13T18:42:07.663" Score="2" ViewCount="1553" Body="&lt;p&gt;I'm doing some initial research on a project I have in mind. I am super new to all this Arduino stuff so taking it slow and gathering lots of info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to control around 1000 small linear actuators to push/pull a very small load. The purpose of this question is specifically how to manage that many devices. The devices won't ever need to start their own transmissions so the Arduino can get everything done by polling them ...I hope ...and I don't think it would be a lot of data to each device but I imagine overall it may be. I want to control each device at the &quot;same&quot; time, all with the same cabling distance (around 2m). From what I can tell, a &lt;a href=&quot;https://en.wikipedia.org/wiki/CAN_bus&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;CANbus&lt;/strong&gt;&lt;/a&gt;  is exactly what I need, where I can assign a unique ID to each device (node) and then write some code to control the network array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, is a CANbus the ideal bit of hardware here to work with an Arduino to control in real time such a high number of devices?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Nick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Sorry for the vagueness, I'm very new to all this so really just looking for keywords to help scope my project out before asking more complex specific questions. It's difficult to formulate what's in my head to experienced people without sounding like a goose. I'm experienced on the software side, but the hardware i/o is all brand new.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately, I am wanting to sample a grey scale image/sequence of images and depending on the value sampled in a 0-255 range which is mapped to the extension capabilities of each actuator to extend/contract in that pixel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that is more helpful. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="10638" LastEditorUserId="10638" LastEditDate="2015-06-14T11:25:14.883" LastActivityDate="2015-06-14T18:58:37.517" Title="How to control a large number of devices with an Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12621" PostTypeId="1" AcceptedAnswerId="12684" CreationDate="2015-06-13T22:15:37.683" Score="1" ViewCount="875" Body="&lt;p&gt;I'm running into the 32k flash ceiling of my 328p. The code is pretty compact but I need help making it smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an analysis tool (part of avr?) that can tell me which functions take up the most space?  Obviously looking at the source code won't help because I don't know how the compiler decides to reorganize things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've moved strings to PROGMEM, but I'm still hitting the ceiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some tips for space saving?&#xA;What are some ways of seeing what's taking up the most space?&lt;/p&gt;&#xA;" OwnerUserId="10565" LastActivityDate="2015-06-16T10:28:52.450" Title="Determining which section of code uses the most flash" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ClosedDate="2015-06-27T10:41:20.947" ContentLicense="CC BY-SA 3.0" />
  <row Id="12622" PostTypeId="2" ParentId="12621" CreationDate="2015-06-13T22:36:50.513" Score="2" Body="&lt;p&gt;Moving strings &lt;em&gt;to&lt;/em&gt; PROGMEM will only exacerbate the problem, since PROGMEM &lt;em&gt;is&lt;/em&gt; the 32k flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily get your &quot;symbol table&quot; from the compiled .elf file by using &lt;code&gt;avr-objdump -t &amp;lt;.elf file&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It results in a list something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;... scrolls past ...&#xA;00000338 g     F .text  00000076 init&#xA;000000d4 g       .text  00000000 __ctors_start&#xA;000000e2 g       .text  00000000 __do_copy_data&#xA;00800110 g       .bss   00000000 __bss_start&#xA;000008a2 g     F .text  00000022 main&#xA;00000126  w      .text  00000000 __vector_4&#xA;00000000  w      *ABS*  00000000 __heap_end&#xA;00000126  w      .text  00000000 __vector_9&#xA;000003ae g     F .text  000000d0 delay&#xA;00000126  w      .text  00000000 __vector_2&#xA;00000126  w      .text  00000000 __vector_21&#xA;00000126  w      .text  00000000 __vector_15&#xA;00000083 g     O .text  0000000a port_to_output_PGM&#xA;00000154 g     F .text  0000002e setup&#xA;008001c3 g       .stab  00000000 __heap_start&#xA;000000d6 g       .text  00000000 __dtors_start&#xA;000000d6 g       .text  00000000 __ctors_end&#xA;000008ff  w      *ABS*  00000000 __stack&#xA;0000008d g     O .text  0000000a port_to_input_PGM&#xA;00800110 g       .data  00000000 _edata&#xA;008001c3 g       .stab  00000000 _end&#xA;00000126  w      .text  00000000 __vector_8&#xA;000000bf g     O .text  00000014 digital_pin_to_timer_PGM&#xA;00000a08  w      .text  00000000 exit&#xA;00000702 g     F .text  00000052 _ZN14HardwareSerial4readEv&#xA;000009b8 g       .text  00000000 __udivmodsi4&#xA;00000a08 g       .text  00000000 _exit&#xA;00000126  w      .text  00000000 __vector_14&#xA;00000126  w      .text  00000000 __vector_10&#xA;000002a8 g     F .text  00000090 __vector_16&#xA;00800100 g       .data  00000000 __data_start&#xA;00000480 g     F .text  00000076 __vector_18&#xA;00000126  w      .text  00000000 __vector_20&#xA;00000108 g       .text  00000000 __do_global_ctors&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lines you are interested in are &lt;code&gt;.text&lt;/code&gt; sections.  The first big number is the HEX location in memory.  The second one is the important one - that is the size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from that snippet that the function &lt;code&gt;delay&lt;/code&gt; is located at address 0x3ae and is 0xd0 bytes in size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're on Unix or OSX you can employ the more advanced searching tools that are at your disposal.  For instance, to just list the &quot;global&quot; &lt;code&gt;.text&lt;/code&gt; entries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ avr-objdump -t &amp;lt;elf file&amp;gt; | grep '\.text' | grep ' g '&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which for my test program results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000079 g     O .text  0000000a port_to_mode_PGM&#xA;00000918 g     F .text  00000040 _ZN5Print7printlnEv&#xA;00000a00 g       .text  00000000 __tablejump__&#xA;000006c2 g     F .text  00000040 _ZN14HardwareSerial4peekEv&#xA;000008c4 g     F .text  00000054 _ZN5Print5writeEPKhj&#xA;000000d4 g       .text  00000000 __trampolines_start&#xA;00000a0c g       .text  00000000 _etext&#xA;000006a0 g     F .text  00000022 _ZN14HardwareSerial9availableEv&#xA;0000012a g     F .text  0000002a loop&#xA;00000774 g     F .text  00000080 _ZN14HardwareSerial5writeEh&#xA;00000126 g       .text  00000000 __bad_interrupt&#xA;000000d4 g       .text  00000000 __trampolines_end&#xA;00000200 g     F .text  000000a8 digitalWrite&#xA;00000592 g     F .text  0000010e _ZN14HardwareSerial5beginEm&#xA;00000182 g     F .text  0000007e pinMode&#xA;00000097 g     O .text  00000014 digital_pin_to_port_PGM&#xA;000000d6 g       .text  00000000 __dtors_end&#xA;00000754 g     F .text  00000020 _ZN14HardwareSerial5flushEv&#xA;0000051c g     F .text  00000076 __vector_19&#xA;00000990 g     F .text  00000026 _ZN5Print7printlnEPKc&#xA;000000f8 g       .text  00000000 __do_clear_bss&#xA;000000ab g     O .text  00000014 digital_pin_to_bit_mask_PGM&#xA;00000000 g       .text  00000000 __vectors&#xA;000009fc g       .text  00000000 __tablejump2__&#xA;00000338 g     F .text  00000076 init&#xA;000000d4 g       .text  00000000 __ctors_start&#xA;000000e2 g       .text  00000000 __do_copy_data&#xA;000008a2 g     F .text  00000022 main&#xA;000003ae g     F .text  000000d0 delay&#xA;00000083 g     O .text  0000000a port_to_output_PGM&#xA;00000154 g     F .text  0000002e setup&#xA;000000d6 g       .text  00000000 __dtors_start&#xA;000000d6 g       .text  00000000 __ctors_end&#xA;0000008d g     O .text  0000000a port_to_input_PGM&#xA;000000bf g     O .text  00000014 digital_pin_to_timer_PGM&#xA;00000702 g     F .text  00000052 _ZN14HardwareSerial4readEv&#xA;000009b8 g       .text  00000000 __udivmodsi4&#xA;00000a08 g       .text  00000000 _exit&#xA;000002a8 g     F .text  00000090 __vector_16&#xA;00000480 g     F .text  00000076 __vector_18&#xA;00000108 g       .text  00000000 __do_global_ctors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From that I can see that the function &lt;code&gt;_ZN14HardwareSerial5beginEm&lt;/code&gt; is the biggest and takes up 0x10e bytes.  That strange named function is a &quot;C++ Munged&quot; name.  It actually corresponds to &lt;code&gt;HardwareSerial::begin()&lt;/code&gt; and is the parent class name for &lt;code&gt;Serial.begin()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-13T22:36:50.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12623" PostTypeId="1" CreationDate="2015-06-13T23:28:50.690" Score="2" ViewCount="44" Body="&lt;p&gt;I've got an ArduiMU V3+ and would like to connect an ordinary push button to it.&#xA;How would I connect it to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xMvXC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10636" LastActivityDate="2015-06-13T23:28:50.690" Title="Connect push button to ArduiMU" Tags="|communication|button|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12624" PostTypeId="1" CreationDate="2015-06-13T23:44:36.850" Score="2" ViewCount="50" Body="&lt;p&gt;Current I use my &lt;a href=&quot;https://store.3drobotics.com/products/arduimu-v3&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArduiMU V3+&lt;/a&gt; with a Bluetooth Mate (from Sparkfun) but I've got a lot of connection problems with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for a better solution involving WLAN and am wondering whether there are compatible modules?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xMvXC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10636" LastActivityDate="2015-06-13T23:44:36.850" Title="WLAN module compatible with ArduiMU V3+" Tags="|bluetooth|wifi|communication|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12625" PostTypeId="1" AcceptedAnswerId="12629" CreationDate="2015-06-14T08:46:47.587" Score="5" ViewCount="1941" Body="&lt;p&gt;How do I store floats in flash and how do I read them from there? (I need a look-up table for pairs of float values.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The storing part doesn't seem to be so difficult as this compiles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM float value1 = 1.23456;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how do I read them? Do I need to copy them byte by byte to a float variable, or is there a better way? (I am using an Arduino ATmega 328p with 4-byte floats.)&lt;/p&gt;&#xA;" OwnerUserId="1677" LastActivityDate="2016-12-02T16:22:41.573" Title="Store floats in and reading them from flash" Tags="|flash|float|arduino-mini|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12626" PostTypeId="2" ParentId="12411" CreationDate="2015-06-14T09:09:15.523" Score="2" Body="&lt;p&gt;Check &lt;a href=&quot;http://harteware.blogspot.de/2010/11/protothread-and-arduino-first-easy.html&quot; rel=&quot;nofollow&quot;&gt;this example&lt;/a&gt;: rather than sleep(), it uses PT_WAIT_UNTIL&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  while(1) {&#xA;      PT_WAIT_UNTIL(pt, millis() - timestamp &amp;gt; interval );&#xA;      timestamp = millis();&#xA;      doSomething();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should be the proto-thread way of waiting: PT_WAIT_UNTIL will make sure that your thread sleeps in a way that allows other threads to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest looks fine, but I have not tried to run the code.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-14T09:09:15.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12627" PostTypeId="1" AcceptedAnswerId="12628" CreationDate="2015-06-14T09:20:23.027" Score="0" ViewCount="32588" Body="&lt;p&gt;I have HC-SR04 Ultrasonic Sensor with me. I couldn't understand the &quot;Trig&quot; pin's working structure and the working technic. Do we really need it while we use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(With Arduino examples, I generally use Echo pin more than trig pin.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/X2dK8.jpg&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2017-11-20T22:43:16.057" Title="How to use Ultrasonic Sensor's trig pin, and why it is needed?" Tags="|sensors|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12628" PostTypeId="2" ParentId="12627" CreationDate="2015-06-14T09:34:08.580" Score="3" Body="&lt;p&gt;Yes, you do need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the TRIG pin is to cause the module to send out a &quot;Ping&quot;.  It's what makes the whole thing work.  As soon as the TRIG pin goes HIGH then LOW (for a period of not less than 10µs) the internal clocks start ticking.  8 cycles of 40KHz audio are sent out of the transmitter and it starts counting how long it takes for the echo to arrive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use the TRIG pin the module won't be able to do anything at all.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-14T09:34:08.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12629" PostTypeId="2" ParentId="12625" CreationDate="2015-06-14T09:40:31.117" Score="4" Body="&lt;p&gt;There is a helper macro in avr-libc that is designed just for this purpose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define pgm_read_float_near(address_short) __LPM_float((uint16_t)(address_short))&#xA;&#xA;Read a float from the program space with a 16-bit (near) address.&#xA;&#xA;Note&#xA;    The address is a byte address. The address is in the program space. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use it like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM float pi=3.141592653;  // constant value in flash&#xA;float diameter = 24.332154;    // variable user value&#xA;&#xA;float circumference = diameter * pgm_read_float_near(&amp;amp;pi);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-14T09:40:31.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12630" PostTypeId="1" CreationDate="2015-06-14T10:03:17.633" Score="1" ViewCount="2096" Body="&lt;p&gt;Working to receive Music for Bluetooth Speaker via HC-05&lt;/p&gt;&#xA;" OwnerDisplayName="user4236" LastActivityDate="2015-12-12T22:17:14.213" Title="Can a connection of HC-05 and Arduino Nano receive audio and display waveform on computer?" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12631" PostTypeId="2" ParentId="12630" CreationDate="2015-06-14T10:11:58.477" Score="2" Body="&lt;p&gt;No, it can't.  The HC-05 is a Bluetooth Serial device, Bluetooth speakers are Bluetooth Audio Sink devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like asking &quot;Can my bicycle fly?&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/K3Yks.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you'll agree the answer is &quot;NO&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible way of doing it using the HC-05 is to receive the audio using your computer then pre-process it and send the important information to the Arduino through the HC-05, so the Arduino can then send it back to the computer for displaying.  But then, what &lt;em&gt;really&lt;/em&gt; is the point of the Arduino...?!&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-14T10:11:58.477" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12632" PostTypeId="2" ParentId="12627" CreationDate="2015-06-14T11:26:21.920" Score="1" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/p3fjW.jpg&quot; alt=&quot;Two versions of ultrasonic sensors&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two versions of this device. In the threepin version you trigger the measurement and receive the echo pulse on the same pin. In the four pin version trigger and echo are on separate pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly your Arduino example is written for the three pin version. &lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-06-14T11:26:21.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12634" PostTypeId="1" AcceptedAnswerId="22413" CreationDate="2015-06-14T16:04:44.927" Score="1" ViewCount="1435" Body="&lt;p&gt;I use for a project an Arduino Yun with Node.JS + socket.io to provide interactivity between a smartphone, driving through a webpage different devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to enable this service for several smartphones at the same time. However I would like to work in the very same conditions that a (well configured) hotspot does:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I want to ensure that no user can see the other users on the network,&lt;/li&gt;&#xA;&lt;li&gt;I want to have a limited number of connections on the Yun at the same time,&lt;/li&gt;&#xA;&lt;li&gt;I want to force the different users when connected to the Wi-Fi to be routed to a captive portal on the first connection.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does anyone know first if it is possible with an Arduino Yun (maybe some actions must be performed on a NodeJS virtual server as point 2). If yes, do you have a tutorial or any clues (do I have to use LuCi)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last question, in the same topic, I would like to use a fast granted access using NFC tag emulation to provide Wi-Fi credentials. Has anyone tried this with Arduino Yun and a shield?&lt;/p&gt;&#xA;" OwnerUserId="10646" LastEditorUserId="6936" LastEditDate="2016-03-28T18:17:29.330" LastActivityDate="2016-03-28T18:17:29.330" Title="Arduino Yun used as Wi-Fi hotspot" Tags="|wifi|arduino-yun|node.js|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12635" PostTypeId="2" ParentId="12619" CreationDate="2015-06-14T16:41:10.810" Score="2" Body="&lt;p&gt;This is just a suggestion, certainly not the only possible approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Get a handful of small linear actuators &lt;em&gt;with a builtin&#xA;controller&lt;/em&gt;. Some actuators have no controller, and will require one&#xA;H-bridge and one analog input each. You do not want these. I have seen&#xA;some actuators with built-in controllers that can be driven just like&#xA;servos, I would suggest you get some of those. At this point you should&#xA;carefully look at costs when choosing the actuators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Learn how to drive those actuators from an AVR-based&#xA;Arduino, like an Arduino Uno, using the Servo library. I believe you can&#xA;drive up to 12 actuators with a single Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Drive them using &lt;em&gt;two&lt;/em&gt; Arduinos in a master-slave&#xA;configuration. The master would be a beefy Arduino, like a Mega or a&#xA;Due. It would send commands to the slave using, say, an I2C bus. After&#xA;sending the set points for the actuators, it would send a &quot;go&quot; order to&#xA;the I2C broadcast address. The slave would be the Uno. It would&#xA;interpret the commands and actually drive the actuators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3b&lt;/strong&gt;: Change the master's program to &lt;em&gt;pretend&lt;/em&gt; it is controlling&#xA;many slaves, and a total of 1000&amp;nbsp;actuators. In reality, all the&#xA;slaves would have the same I2C address: that of the unique slave&#xA;actually available. This will tell you whether your master is powerful&#xA;enough for the job, and you will see how the performance scales.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 3c&lt;/strong&gt;: Optimize the slave's code. Try to have it work with an&#xA;8&amp;nbsp;MHz clock, and use as little flash and RAM as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Replace the slave Arduino with a bare AVR chip. You will&#xA;have to learn how to program it via ISP, but the information is widely&#xA;available. An Uno is an ATmega328P at heart, but depending on the&#xA;program size, you may get away with an ATmega48A, which is the same&#xA;thing only with less memory, and dirty cheap. Or even with a still&#xA;cheaper ATtiny. If you can make your program work with an 8&amp;nbsp;MHz&#xA;clock, then use the internal oscillator, which will save you having to&#xA;buy an external resonator. All this is to keep the costs reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 4b&lt;/strong&gt;: Test, test, test. Last chance to change your mind before&#xA;committing big bucks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;: If everything works at this stage, it's time to scale up.&#xA;The same master Arduino, and one bare AVR for each dozen actuators, each&#xA;with it's own I2C address.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-14T18:58:37.517" LastActivityDate="2015-06-14T18:58:37.517" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12639" PostTypeId="1" CreationDate="2015-06-14T22:53:47.540" Score="2" ViewCount="351" Body="&lt;p&gt;How does one make an outgoing bluetooth connection?  I have already installed packages for bluetooth, and have run &lt;code&gt;hcitool scan&lt;/code&gt; to find the BT address. And I'm using a USB BT dongle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of &lt;code&gt;lsusb&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 001 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub&#xA;Bus 001 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)&#xA;Bus 001 Device 004: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-06-14T22:53:47.540" Title="Yun as bluetooth master" Tags="|bluetooth|arduino-yun|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="12640" PostTypeId="2" ParentId="9658" CreationDate="2015-06-14T23:10:16.380" Score="0" Body="&lt;p&gt;I think the problem is (assuming you've got the pins straight) is that there's no time for the byte to get to the Uno.  Try &lt;code&gt;while(!Wire.available())&lt;/code&gt; between &lt;code&gt;requestFrom...&lt;/code&gt; and the &lt;code&gt;while(Wire.available())&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-06-14T23:10:16.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12641" PostTypeId="2" ParentId="12586" CreationDate="2015-06-15T00:15:07.920" Score="0" Body="&lt;p&gt;@EdgarBonet pointed out in a comment, I need to check my dynamic ram, which could be used by the Heap and Stack. The class can be found &lt;a href=&quot;http://playground.arduino.cc/Code/AvailableMemory&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; to measure ram usage. Since links can die, here is the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* MemoryFree.h */&#xA;&#xA;// MemoryFree library based on code posted here:&#xA;// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213583720/15&#xA;// Extended by Matthew Murdoch to include walking of the free list.&#xA;&#xA;#ifndef MEMORY_FREE_H&#xA;#define MEMORY_FREE_H&#xA;&#xA;#ifdef __cplusplus&#xA;extern &quot;C&quot; {&#xA;#endif&#xA;&#xA;int freeMemory();&#xA;&#xA;#ifdef  __cplusplus&#xA;}&#xA;#endif&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the .cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* MemoryFree.cpp */&#xA;&#xA;#if (ARDUINO &amp;gt;= 100)&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA;#include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&#xA;extern unsigned int __heap_start;&#xA;extern void *__brkval;&#xA;&#xA;/*&#xA; * The free list structure as maintained by the &#xA; * avr-libc memory allocation routines.&#xA; */&#xA;struct __freelist {&#xA;  size_t sz;&#xA;  struct __freelist *nx;&#xA;};&#xA;&#xA;/* The head of the free list structure */&#xA;extern struct __freelist *__flp;&#xA;&#xA;#include &quot;MemoryFree.h&quot;&#xA;&#xA;/* Calculates the size of the free list */&#xA;int freeListSize() {&#xA;  struct __freelist* current;&#xA;  int total = 0;&#xA;  for (current = __flp; current; current = current-&amp;gt;nx) {&#xA;    total += 2; /* Add two bytes for the memory block's header  */&#xA;    total += (int) current-&amp;gt;sz;&#xA;  }&#xA;  return total;&#xA;}&#xA;&#xA;int freeMemory() {&#xA;  int free_memory;&#xA;  if ((int)__brkval == 0) {&#xA;    free_memory = ((int)&amp;amp;free_memory) - ((int)&amp;amp;__heap_start);&#xA;  } else {&#xA;    free_memory = ((int)&amp;amp;free_memory) - ((int)__brkval);&#xA;    free_memory += freeListSize();&#xA;  }&#xA;  return free_memory;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this I was able to see how much ram was used. Of the avialable 2k, I had only 100k left. So now I know why my program is crashing, I need a solution. The solution was to store the static content in program memory (PROGMEM):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* const months[] PROGMEM = &#xA;    {&#xA;            &quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;&#xA;    };&#xA;&#xA;const uint8_t days_of_month[] PROGMEM = &#xA;    {&#xA;        31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-06-15T00:15:07.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12642" PostTypeId="1" CreationDate="2015-06-15T00:31:21.073" Score="1" ViewCount="483" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.banggood.com/1PC-30A-New-Range-Current-Sensor-Module-for-ACS712-p-86583.html&quot; rel=&quot;nofollow&quot;&gt;ACS712 module&lt;/a&gt; that I am connecting to my Arduino Uno to read the current spike when my door bells rings (and then trigger some events in my &quot;sketch&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my country doorbells use the ~115 VAC at ~60Hz. So, I just opened the doorbell and connected the ACS712 module in series. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know how much amperage my doorbell draws, but it is hardly the 30A supposedly supported by the module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I am &lt;em&gt;not&lt;/em&gt; connecting the OUT pin to the Arduino, only VCC and GND to the +5V and GND of the Arduino Uno. (I am also tried connecting the OUT pin to A2 in the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is that as soon as I ring the doorbell the Arduino hangs up. Sometimes I even have to physically unplug the Arduino to get it back to life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't necessarily happens in the first bell, but it does not survive 3 rings in a row. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf&quot; rel=&quot;nofollow&quot;&gt;ACS712 chip&lt;/a&gt; is supposed to provide 2.1 kVRMS of isolation... it doesn't seem likely that the &quot;kickback&quot; from the bell would be 2100 VAC... so I cannot imagine how/why my Arduino is hanging up, when it is supposed to be completely isolated from the AC (that's the whole point of the Hall Effect current sensor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added some capacitors to the VCC/GND pins with no luck. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... any ideas on 1) how to protect the Arduino from hanging up?, 2) what is making the Arduino hang up?.&lt;/p&gt;&#xA;" OwnerUserId="8500" LastEditorUserId="8500" LastEditDate="2015-06-15T01:33:24.860" LastActivityDate="2018-02-04T15:14:52.623" Title="ACS712 to build doorbell sensor - Arduino Hangs up" Tags="|arduino-uno|current|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12643" PostTypeId="1" CreationDate="2015-06-15T00:45:43.010" Score="1" ViewCount="184" Body="&lt;p&gt;I am worried that my Arduino is fried from a previous attempt at connecting a servo to it. To test my concerns, I changed the circuit to see if Arduino could even power a simple LED:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;&#xA;void setup() {&#xA;    pinMode(led, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(led, HIGH);&#xA;    delay(4000);&#xA;    digitalWrite(led, LOW);&#xA;    delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wiring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TCe9F.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that pic, the Arduino is connected to a 9V battery. When I test the purple connections with my multimeter, the power bounces between ~5V and a weird 1.65V value every four seconds. I &lt;em&gt;assume&lt;/em&gt; thats power being applied to the output pin in keeping with my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the LED does &lt;em&gt;not&lt;/em&gt; light up. Any ideas as to what could be going wrong or how I could troubleshoot?&lt;/p&gt;&#xA;" OwnerUserId="9842" LastActivityDate="2015-08-15T04:17:46.903" Title="Is my Arduino fried?" Tags="|led|arduino-due|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12646" PostTypeId="2" ParentId="12643" CreationDate="2015-06-15T01:57:13.040" Score="1" Body="&lt;p&gt;As noted in the previous answer, being able to upload a new sketch indicates an Arduino is ok in general – in particular has a functioning CPU – but of course that does not test all features.  For example, individual inputs and outputs can be damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily change your sketch so that it drives some range of outputs, as shown below.  Thereafter, try moving the red wire (that now connects on 13) to some other of the outputs in the selected range.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { LedLo=2, LedHi=20}; // Set lo and hi limits of range&#xA;&#xA;void setup() {&#xA;  for (int led=LedLo; i &amp;lt;= LedHi; ++i)&#xA;    pinMode (led, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int led=LedLo; i &amp;lt;= LedHi; ++i)&#xA;    digitalWrite(led, HIGH);&#xA;  delay(4000);&#xA;  for (int led=LedLo; i &amp;lt;= LedHi; ++i)&#xA;    digitalWrite(led, LOW);&#xA;  delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-06-15T03:02:48.330" LastActivityDate="2015-06-15T03:02:48.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12647" PostTypeId="1" AcceptedAnswerId="12648" CreationDate="2015-06-15T03:11:14.620" Score="0" ViewCount="338" Body="&lt;p&gt;I want to use a distance sensor like the HC-SR04 to power a stop light like parking sensor for my garage. I have seen a lot of tutorials on how to use the HC-SR04 to power a single LED and found the schematic below on how to control up to 14 LEDs by hooking them onto the 5v and using a transistor. I have added a box where I would hook the sensor in. My question is, would it work if I had the sensor hooked into the 5v as well. The plan is to have 3 sets of 14 LEDs and have one set on at any given time. I plan on using an Arduino Uno. &lt;img src=&quot;https://i.stack.imgur.com/TKtrK.jpg&quot; alt=&quot;Schematic&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10651" LastEditorUserId="10651" LastEditDate="2015-06-15T03:38:25.867" LastActivityDate="2015-06-15T05:50:46.687" Title="Multiple LEDs &amp; HC-SR04" Tags="|sensors|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12648" PostTypeId="2" ParentId="12647" CreationDate="2015-06-15T03:29:37.637" Score="0" Body="&lt;p&gt;If I am understanding correctly, you have 3 LEDs ... call them A, B and C (the fact that they are a group of 14 LEDs is a red herring).  As a function of the distance measured, you want ONE of LED A, B or C lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are using an Arduino, you have GPIO pins.  Connect a different GPIO to each of A, B and C.   You can then write an application that senses the distance (as measured by the HC-SR04) and depending on the distance returned, have a set of  &quot;if&quot; statements which will choose which of the GPIOs to set HIGH and the others LOW.  The GPIO set HIGH will switch on the corresponding LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, its going to look a lot like this Instructable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-15T03:29:37.637" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12650" PostTypeId="1" CreationDate="2015-06-15T06:08:13.560" Score="0" ViewCount="1674" Body="&lt;p&gt;Hy guys,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working on a quadcopter stabilization algorithm for an indoor quadcopter. I now need to setup a wireless communication between my onboard Arduino and my controlling Arduino (and/or RasperryPi (not shure yet)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: What would be the fastest wireless communication possibility?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not worrying about distance; they won't get far apart from eachother. I want to keep a lot of resources on the stabilization algorithm and to keep down resources used for the communication and thus get the fastest communication on very few resources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are your opinions and experiences, what is going to be fastest?&lt;/p&gt;&#xA;" OwnerUserId="10376" LastActivityDate="2016-03-23T22:24:17.703" Title="Fastest wireless communication" Tags="|bluetooth|wifi|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12651" PostTypeId="1" CreationDate="2015-06-15T06:16:08.930" Score="5" ViewCount="1691" Body="&lt;p&gt;I'm new to Arduino, but I have this idea for a game I would like to build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need the Arduino to be able to determine my relative position on a straight line - 20 feet (6 meters) long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Priorities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Durable (Outdoors proof)&lt;/li&gt;&#xA;&lt;li&gt;Easy for a newbie&lt;/li&gt;&#xA;&lt;li&gt;Cheap&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT. Some more context&lt;/em&gt; - I want to play Pong over a physical area (A grid of LEDs to act as pixels), and I want the use player's position on a line to set the position of the paddle.&lt;/p&gt;&#xA;" OwnerUserId="10652" LastEditorUserId="10652" LastEditDate="2015-06-17T06:58:34.667" LastActivityDate="2015-06-17T22:13:50.897" Title="Detect my position" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12652" PostTypeId="1" CreationDate="2015-06-15T06:47:37.957" Score="2" ViewCount="1781" Body="&lt;p&gt;Anybody had worked with ESP8266 to post data to RESTful web service? I was trying but it's not posting anything. Tried with a test server:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.posttestserver.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.posttestserver.com/&lt;/a&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Serial.println(&quot;\nSetting AT+CIPSTART&quot;);&#xA;String client_conn = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;client_conn += SERVER;&#xA;client_conn += &quot;\&quot;,&quot;;&#xA;client_conn += PORT;&#xA;Serial.println(client_conn);&#xA;Serial2.println(client_conn);&#xA;delay(3000);&#xA;while (Serial2.available() &amp;gt; 0) {&#xA;    c = Serial2.read();&#xA;    Serial.print(c);&#xA;    if(c=='\n\r' || c == '\r\n')&#xA;    Serial.println('\n\r'); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It showed me that it got connected &#xA;Now I created POST string&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;String data = &quot;{JSONBODY}&quot;;&#xA;String post = &quot;POST /post.php HTTP/1.0\r\n&quot;;&#xA;post += &quot;Host: posttestserver.com\r\n&quot;;&#xA;post += &quot;Content-Length: &quot;;&#xA;post += data.length();&#xA;post += &quot;\r\n&quot;;&#xA;post += data;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Transmitting data&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Serial2.print(&quot;AT+CIPSEND=&quot;);&#xA;Serial2.println(post.length());&#xA;delay(1000);&#xA;if(Serial2.find(&quot;&amp;gt;&quot;)) {&#xA;    Serial2.println(post);&#xA;    while (Serial2.available() &amp;gt; 0) {&#xA;        c = Serial2.read();&#xA;        Serial.print(c);&#xA;        if(c=='\n\r' || c == '\r\n')&#xA;            Serial.println('\n\r'); &#xA;    }&#xA;    delay(5000);&#xA;    Serial2.flush();&#xA;    delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Returned nothing&#xA;Closing connection&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;delay(1000);&#xA;Serial2.println(&quot;AT+CIPCLOSE&quot;);&#xA;while (Serial2.available() &amp;gt; 0) {&#xA;    c = Serial2.read();&#xA;    Serial.print(c);&#xA;    if(c=='\n\r' || c == '\r\n')&#xA;        Serial.println('\n\r'); &#xA;}&#xA;delay(5000);&#xA;Serial2.flush();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Connection closed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But It returned nothing. posttestserver returns data path where it stored. &lt;/p&gt;&#xA;" OwnerUserId="4855" LastEditorUserId="37523" LastEditDate="2019-08-12T16:32:35.323" LastActivityDate="2019-08-12T16:32:35.323" Title="RESTful API with ESP8266 and arduino mega" Tags="|arduino-mega|esp8266|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12653" PostTypeId="1" CreationDate="2015-06-15T08:03:00.433" Score="2" ViewCount="4389" Body="&lt;p&gt;I've got a project where I'd need to read my mouse's signal. My mouse is a G700S (so USB) and the thing was I don't really know how to do and even if it's feasible.&#xA;I'm using an Arduino Micro and my initial idea was to get a PS/2 to USB Adapter (I already have one) and then to plug it to something like &lt;a href=&quot;http://www.dx.com/p/ps-2-keyboard-adapter-module-for-arduino-works-with-official-arduino-boards-324893#.VX6FnfntlBc&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; wired to my Arduino. &#xA;So my question basically is &quot;will it work ? and if not, why ?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main idea is not to use USB (like an USB Host Shield) because Arduino doesn't have any USB mouse driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="10653" OwnerDisplayName="Thomas Kowalski" LastEditorUserId="10794" LastEditDate="2015-09-12T00:42:54.833" LastActivityDate="2015-09-12T00:42:54.833" Title="Read signal from USB mouse on an Arduino ?" Tags="|usb|hardware|arduino-micro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12654" PostTypeId="2" ParentId="12653" CreationDate="2015-06-15T08:24:05.113" Score="3" Body="&lt;p&gt;This would be possible &lt;strong&gt;only&lt;/strong&gt; if the mouse actually supports PS/2. USB to PS/2 adapters are entirely passive, and in order to function it requires that the controller in the mouse is designed to communicate in both protocols. Modern mice, especially wireless ones don't tend to have this capability anymore as PS/2 is all but a dead standard.&lt;/p&gt;&#xA;" OwnerUserId="6860" LastActivityDate="2015-06-15T08:24:05.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12655" PostTypeId="2" ParentId="12651" CreationDate="2015-06-15T09:17:15.613" Score="3" Body="&lt;p&gt;Whether it's outdoor proof or not depends on the housing where you put your electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For position tracking, there are basically 2 ways:&lt;br&gt;&#xA;1. GPS&lt;br&gt;&#xA;2. Acceleration sensors&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the given distance, a (cheap) GPS solution is not accurate enough (See &lt;a href=&quot;https://www.sparkfun.com/tutorial/GPSTracking/clamped_edit2-L.jpg&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/tutorial/GPSTracking/clamped_edit2-L.jpg&lt;/a&gt;, for instance). And it may be too slow for your purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Acceleration sensors also have a simple serial interface, but handling the data to get accurate results is not really easy (However I'm sure that someone has already written a public available software library)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Luckily, for position tracking on a straight line, there's another solution:&lt;br&gt;&#xA;3. &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Ping?from=Tutorial.UltrasoundSensor&quot; rel=&quot;nofollow&quot;&gt;use a ultrasonic sensor&lt;/a&gt; &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe there are even better solutions; to evaluate, it would help if you could specify your project more detailed (how exact shall the relative position detection be? Static or dynamic calculation? If dynamic, how fast will the movement be? ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;br&gt;&#xA;It could be worth considering the following alternative:&lt;br&gt;&#xA;4. Use a rotary encoder, mount it to a retractable dog leash and hook this to the player's waist. The other end of course must be mounted to a steady pillar. Perhaps this is mechanically tricky, and it limits the mobility of the players, but electrically it's very easy. &lt;/p&gt;&#xA;" OwnerUserId="3878" LastEditorUserId="3878" LastEditDate="2015-06-17T22:13:50.897" LastActivityDate="2015-06-17T22:13:50.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12657" PostTypeId="1" CreationDate="2015-06-15T15:16:38.950" Score="0" ViewCount="1591" Body="&lt;p&gt;I have made two libraries and one test program.I have made my custom uart library.first i have included all functions for printing in single uart library file.but then i have made print library for printing functions only.my files are listed below.i have not posted my code directly so it can be read separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pasted.co/479b09a3&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;uart.h&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pasted.co/6279fbae&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;uart.cpp&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pasted.co/61714885&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;print.h&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pasted.co/d085dcba&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;print.cpp&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Test.cpp&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;                                                          &#xA;#include &quot;uart.h&quot;&#xA;&#xA;int main(){&#xA;    uart.start(9600);&#xA;    uart.print(&quot;Test&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and i get this error..&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Error&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;src/print.cpp&#xA;src/print.cpp: In member function 'void PrintClass::print(unsigned char)':&#xA;src/print.cpp:4:12: error: 'write' was not declared in this scope&#xA;write(data);&#xA;          ^&#xA;src/print.cpp: In member function 'void PrintClass::print(char*)':&#xA;src/print.cpp:13:22: error: 'write' was not declared in this scope&#xA;write(string[index]);&#xA;                   ^&#xA;.build/uno/Makefile:47: recipe for target '.build/uno/src/print.o' failed make: *** [.build/uno/src/print.o] Error 1&#xA;Make failed with code 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i have referred default arduino libraries like hardwareSerial and LiquidCrystal and i made my library like that but i cant get rid of that.&#xA;Please Help me.&lt;/p&gt;&#xA;" OwnerUserId="10634" LastActivityDate="2015-06-15T15:24:12.143" Title="Can't use base class and derived class functions" Tags="|arduino-uno|avr|uart|class|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12658" PostTypeId="2" ParentId="12657" CreationDate="2015-06-15T15:21:09.493" Score="2" Body="&lt;p&gt;Any functions that the base class needs to call that will be defined in the child class must also be defined in the base class.  They should be defined &quot;virtual&quot; so they can be overridden, and can even be &quot;pure virtual&quot; so they &lt;em&gt;have&lt;/em&gt; to be defined in the child class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for any function in the child class that the base class needs to access, add this to the base class's definition (print.h):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;virtual void write(unsigned char data) = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;= 0&lt;/code&gt; bit defines it as &lt;em&gt;pure&lt;/em&gt; virtual, and any classes than inherit this class &lt;em&gt;without&lt;/em&gt; defining their own copy of the &lt;code&gt;void write(unsigned char)&lt;/code&gt; function will thrown an error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of &lt;em&gt;pure&lt;/em&gt; virtual you can provide a &lt;em&gt;default&lt;/em&gt; function that a child &lt;em&gt;can&lt;/em&gt; override if they want to, which can be useful if most classes will work the same way (define it in the parent) but some want to do it differently (override it in the child), in which case you treat it like a normal class function but add the &lt;code&gt;virtual&lt;/code&gt; tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole topic is called &lt;em&gt;polymorphism&lt;/em&gt; and is an incredibly powerful system.  It's discussed in detail here: &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/polymorphism/&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/doc/tutorial/polymorphism/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-15T15:24:12.143" LastActivityDate="2015-06-15T15:24:12.143" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12659" PostTypeId="1" CreationDate="2015-06-15T15:47:44.300" Score="2" ViewCount="537" Body="&lt;p&gt;I followed a couple tutorial on how to receive and send IR codes to control air conditioner the receiving part is working fine and I copied the IR data of the remote control but the problem I am having is sending these codes via IR led can't seem to get it to work can someone help me please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This the code to send the date via IR LED&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;IRremote.h&quot;&#xA;IRsend irsend;&#xA;void setup()&#xA;{&#xA;&#xA;&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;int khz=38; //NB Change this default value as neccessary to the correct modulation frequency&#xA;// ON and 2O C° with 1 FAN heat&#xA;unsigned ON[] ={4400,4300,550,1600,550,500,600,1550,550,1600,550,500,550,550,550,1550,550,550,550,500,550,1600,550,500,600,500,550,1550,600,1550,600,500,550,1550,600,500,550,500,600,500,550,1600,550,1550,550,1600,550,1600,550,1550,600,1550,600,1550,550,1600,550,500,550,550,550,500,550,550,550,500,550,550,550,1550,550,550,550,500,550,1600,550,500,550,550,550,500,550,1600,550,500,600,1550,600,1550,550,500,600,1550,550,1600,550,1550,600};&#xA;unsigned OFF[] ={4350,4350,550,1550,550,550,550,1600,500,1600,550,550,500,550,550,1600,550,550,500,550,550,1600,500,550,550,550,500,1600,550,1600,550,500,550,1600,550,550,500,1600,550,1600,550,1600,550,1600,550,500,550,1600,550,1550,550,1600,550,550,500,550,550,550,500,550,550,1600,500,550,550,550,500,1650,500,1600,550,1600,550,500,550,550,550,500,550,550,550,500,550,550,550,500,550,500,600,1550,550,1600,550,1600,500,1650,500,1600,550};&#xA;&#xA;void loop() {&#xA;&#xA;irsend.sendRaw(ON, sizeof(ON)/sizeof(int), khz);&#xA;delay(5000);&#xA;irsend.sendRaw(OFF, sizeof(OFF)/sizeof(int),khz);&#xA;delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is my A/C doesn't detect IR codes.&lt;/p&gt;&#xA;" OwnerUserId="9972" LastActivityDate="2015-06-15T15:47:44.300" Title="Control air conditioner using Arduino" Tags="|arduino-uno|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12660" PostTypeId="1" AcceptedAnswerId="12661" CreationDate="2015-06-15T15:50:00.870" Score="0" ViewCount="44" Body="&lt;p&gt;I have an arduino uno powered by a battery on a buggy with a sonar distance sensor.  I have a program that calculates the speed it's going, and I want to correlate speed with stopping distance.  I can measure the stopping distance manually, but I want the arduino to report to me the speed it was going when the motor was turned off.  I don't have an LCD display - I wanted to print the number to the serial monitor, but plugging it back into the USB port resets everything I think, or at least the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without buying more components, can I get the data (calculated speed) somehow?&lt;/p&gt;&#xA;" OwnerUserId="10316" LastActivityDate="2015-06-15T16:02:26.560" Title="print data after being plugged back into USB" Tags="|arduino-uno|serial|communication|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12661" PostTypeId="2" ParentId="12660" CreationDate="2015-06-15T16:02:26.560" Score="2" Body="&lt;p&gt;You could have it write the final speed to EEPROM after the motor is shut-off, and output this value when the Arduino boots, see:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/EEPROM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10656" LastActivityDate="2015-06-15T16:02:26.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12662" PostTypeId="1" CreationDate="2015-06-15T16:16:51.087" Score="1" ViewCount="1195" Body="&lt;p&gt;I've bought an HC-SR501-compliant &lt;strong&gt;PIR motion sensor&lt;/strong&gt; (like &lt;a href=&quot;https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;) and connected it to a &lt;strong&gt;Teensy 3.1&lt;/strong&gt;. The circuit seems fine, and the LED lights up. However, &lt;strong&gt;when nothing is moving in front of it, the sensor keeps reporting HIGH and LOW in suspiciously constant intervals&lt;/strong&gt;. The monitor reads like this (numbers in milliseconds)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;motion detected  4113&#xA;motion stopped   7234&#xA;motion detected  4114&#xA;motion stopped   7274&#xA;motion detected  4113&#xA;motion stopped   7204&#xA;motion detected  4111&#xA;motion stopped   7184&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When it detects movement, it stays on the triggered position for longer, but even then goes back to predetermined intervals, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;motion detected   4113&#xA;motion stopped   17204&#xA;motion detected   4111&#xA;motion stopped   41754&#xA;motion detected   4113&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the sketch (&lt;a href=&quot;https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/using-a-pir&quot; rel=&quot;nofollow&quot;&gt;as found on Adafruit&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin   = 13;              // choose the pin for the LED&#xA;int inputPin = 1;               // choose the input pin (for PIR sensor)&#xA;int pirState = LOW;             // we start, assuming no motion detected&#xA;int val      = 0;               // variable for reading the pin status&#xA;&#xA;unsigned long lastTime = millis();&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);      // declare LED as output&#xA;  pinMode(inputPin, INPUT);     // declare sensor as input&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  unsigned long currentTime = millis();&#xA;&#xA;  val = digitalRead(inputPin);   // read input value&#xA;  if (val == HIGH) {             // check if the input is HIGH&#xA;    digitalWrite(ledPin, HIGH);  // turn LED ON&#xA;    if (pirState == LOW) {  &#xA;&#xA;      // we have just turned on&#xA;      Serial.print(&quot;motion detected &quot;);&#xA;      Serial.println(currentTime - lastTime);&#xA;&#xA;      // We only want to print on the output change, not state&#xA;      pirState = HIGH;&#xA;&#xA;      // Save time for measurement&#xA;      lastTime = currentTime;&#xA;    }&#xA;  } else {&#xA;    digitalWrite(ledPin, LOW); // turn LED OFF&#xA;    if (pirState == HIGH){&#xA;&#xA;      // we have just turned off&#xA;      Serial.print(&quot;motion stopped &quot;);&#xA;      Serial.println(currentTime - lastTime);&#xA;&#xA;      // We only want to print on the output change, not state&#xA;      pirState = LOW;&#xA;&#xA;      // Save time for measurement&#xA;      lastTime = currentTime;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Could this be a faulty device?&lt;/strong&gt; I'm thinking about getting a new one for testing. While I can compensate for the gaps when triggered, I can't think of a way to make sure that it's not actually being triggered by this weird internal interval.&lt;/p&gt;&#xA;" OwnerUserId="10655" LastActivityDate="2018-03-04T04:33:58.430" Title="PIR motion sensor stuck in a loop" Tags="|sensors|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12663" PostTypeId="2" ParentId="12611" CreationDate="2015-06-15T16:20:22.290" Score="1" Body="&lt;p&gt;The odd voltages might suggest that the servo isn't actually (fully) connected to the Arduino. As it's a diagram of the breadboard layout, not a photo, I can't say for sure, but on some breadboards the +ve/red and -ve/black rows are sometimes split in the middle. i.e. if you were to connect the Arduino's +5v to one end of the breadboards red row, and the servo to the other end, they might not be joined (same applies for -ve/black). Just a thought; apologises in advance if I’m stating the obvious. &lt;/p&gt;&#xA;" OwnerUserId="10656" LastActivityDate="2015-06-15T16:20:22.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12664" PostTypeId="1" AcceptedAnswerId="12665" CreationDate="2015-06-15T17:06:49.733" Score="14" ViewCount="965" Body="&lt;p&gt;I have accidentally implemented a program that imitates the click of the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that now I can´t delete the program because each time that I connect the USB, the computer starts clicking everything and it is not possible to upload a new program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="10657" LastActivityDate="2015-06-15T23:06:37.180" Title="How to avoid that my arduino clicks eternally?" Tags="|button|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12665" PostTypeId="2" ParentId="12664" CreationDate="2015-06-15T17:09:02.107" Score="18" Body="&lt;p&gt;Hold the RESET button as you plug the Arduino in and keep it pressed all the time it's plugged into your computer.  Load Blink.ino into the IDE and compile it.  Press the UPLOAD button in the IDE and move the mouse to somewhere &quot;safe&quot;.  Release the RESET button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do those last three steps in rapid succession and you should be fine.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-15T17:09:02.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12666" PostTypeId="1" AcceptedAnswerId="12710" CreationDate="2015-06-15T18:55:48.623" Score="0" ViewCount="1193" Body="&lt;p&gt;I am using an Arduino UNO and I am trying to vary the brightness by steps by 0.5 volts till it gets to a max of 5.0 V using buttonA and decrease the brightness of the LED by 0.5 volts with buttonB. The Problem I have is that when I push buttonA the LED steps it's voltage by 0.5V all the way to 5.0V and with buttonB its steps down to 0. I would like to have the LED step each time I press the button not all at once. Here is my code that I have so far can someone help me with telling the Arduino to Step each time a button is pressed. CODE IS DIFFERENT from another post I did &lt;/p&gt;&#xA;&#xA;&lt;p&gt;HERE is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 9; // must be a PWM digital pin&#xA;int buttonApin = A2; //buttonA to analog 2&#xA;int buttonBpin = A1; // buttonB to analog 1&#xA;int maxBright = 255; // between 0 and 255&#xA;int ms = 1500;    // delay in milliseconds&#xA;int buttonPushCounterA = 0; //counter for the number of button presses&#xA;int buttonStateA = 0; // current state of the button&#xA;int lastButtonStateA = 0; // previous state of the button&#xA;int buttonPushCounterB = 0; //counter for the number of button presses&#xA;int buttonStateB = 0; // current state of the button&#xA;int lastButtonStateB = 0; // previous state of the button&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(buttonApin, INPUT_PULLUP);&#xA;  pinMode(buttonBpin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (digitalRead(buttonApin) == LOW) //if buttonA is pushed&#xA;   {&#xA;      buttonStateA = digitalRead(buttonApin);&#xA;&#xA;     if (buttonStateA != lastButtonStateA)&#xA;     {&#xA;        if(buttonStateA == LOW)&#xA;     {&#xA;        buttonPushCounterA++;&#xA;     }&#xA;    }&#xA;&#xA;// fade from min to max in increments of 25.5 points: basically (0.5 volts)&#xA;for (float n = 0; n &amp;lt;= maxBright; n +=25.5) &#xA;{&#xA; // sets the value (range from 0 to 255):&#xA; analogWrite(ledPin,n);&#xA; delay(ms);&#xA;}&#xA;  }&#xA;&#xA;  if (digitalRead(buttonBpin) == LOW) //if buttonB is pushed&#xA;  {&#xA;     buttonStateB = digitalRead(buttonBpin);&#xA;&#xA;       if (buttonStateB != lastButtonStateB)&#xA;         {&#xA;            if(buttonStateB == LOW)&#xA;              {&#xA;                buttonPushCounterB--;&#xA;              }&#xA;         }&#xA;&#xA;&#xA;     // fade from max to min in increments of 25.5 points: basically (0.5 volts)&#xA;     for (float n = maxBright; n &amp;gt;= 0; n -= 25.5) &#xA;    {&#xA;     // sets the value (range from 0 to 255):&#xA;     analogWrite(ledPin, n);&#xA;     delay(ms);&#xA;    }&#xA;  } &#xA;&#xA;  lastButtonStateA = buttonStateA;&#xA;  lastButtonStateB = buttonStateB;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10541" LastEditorUserId="10541" LastEditDate="2015-06-16T18:42:02.750" LastActivityDate="2015-06-17T07:54:26.370" Title="Arduino UNO button LED brightness vary" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12667" PostTypeId="2" ParentId="12666" CreationDate="2015-06-15T19:02:03.210" Score="0" Body="&lt;p&gt;You forgot to check to see if the button was actually &lt;em&gt;pushed&lt;/em&gt; or if it was just &lt;em&gt;held down&lt;/em&gt;. See the &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ButtonStateChange&quot; rel=&quot;nofollow&quot;&gt;State Change Detection example&lt;/a&gt; to understand how to perform edge detection.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-15T19:02:03.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12670" PostTypeId="1" AcceptedAnswerId="12671" CreationDate="2015-06-15T20:12:34.247" Score="0" ViewCount="263" Body="&lt;p&gt;Can the &lt;a href=&quot;http://www.sfml-dev.org/documentation/2.3/classsf_1_1Packet.php&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;sf::Packet&lt;/code&gt;&lt;/a&gt; class of SFML-network be ported over to arduino for use with the Ethernet library or would it be too big? I'm working on a client-program where an arduino is a server and a regular computer is the client making a request. I'm using the SFML-network library to make networking easier on myself and would prefer to use the built in features of SFML to make networking easier. If it is not feasible would I be better off using fixed width data to communicate with the arduino&lt;/p&gt;&#xA;" OwnerUserId="4883" LastActivityDate="2015-06-15T21:00:57.040" Title="SFML Packet and Arduino" Tags="|ethernet|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12671" PostTypeId="2" ParentId="12670" CreationDate="2015-06-15T21:00:57.040" Score="0" Body="&lt;p&gt;Without knowing how it all works, my guess is that you would have to port the whole of SFML, which would be &lt;strong&gt;HUGE&lt;/strong&gt;.  So, &quot;No!&quot; is the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could, of course, write a library of your own that had an SFML-like interface, but the Arduino networking libraries are already pretty simplistic and easy to use, so what's the point?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-15T21:00:57.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12672" PostTypeId="2" ParentId="12551" CreationDate="2015-06-15T21:05:29.397" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://electronics.stackexchange.com/a/67091/10371&quot;&gt;https://electronics.stackexchange.com/a/67091/10371&lt;/a&gt; (Since this is another stack exchange site, I won't copy the info)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short answer is to use timers that trigger interrupts.  Examples are shown in the link.&lt;/p&gt;&#xA;" OwnerUserId="842" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-06-15T21:05:29.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12673" PostTypeId="2" ParentId="12643" CreationDate="2015-06-15T22:07:54.597" Score="0" Body="&lt;p&gt;If the LED 'ON' is lit, the board has 3.3v power.&#xA;Does the LED 'L' blink? It is also on pin 13, the one your sketch controls.&#xA;If so, perhaps your breadboard circuit is likely at fault.&#xA;Do you have a multimeter? Does the voltage on whichever pin # your sketch controls change as you would expect it to?&#xA;If both are correct, then if you recompile your sketch to use a different pin #, and adjust your connections to match, does your breadboard LED light then?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-15T22:07:54.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12674" PostTypeId="1" AcceptedAnswerId="13399" CreationDate="2015-06-15T22:15:53.517" Score="0" ViewCount="859" Body="&lt;p&gt;I'm trying to read temperature and humidity from a DHT11 sensor and write values to a 20x4 LCD.&#xA;I hit a behaviour I don't understand. When I use the DHT tester program that come with the DHT library, everything works well. I get the DHT information on the Serial console. This DHT tester program use the pin 2 to read the data from the DHT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote the following code who works perfectly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  // F Malpartida's NewLiquidCrystal library&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;&#xA;#define DHTTYPE DHT11&#xA;#define DHTPIN 13      // Digital&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;LiquidCrystal_I2C    lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); &#xA;  while (!Serial) {&#xA;  }&#xA;  Serial.println(&quot;Serial OK!&quot;); &#xA;&#xA;  dht.begin();&#xA;  lcd.begin(20,4);&#xA;  lcd.setBacklight(0);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Hello! &quot;);&#xA;&#xA;  Serial.println(&quot;Init finished!&quot;); &#xA;}&#xA;&#xA;void loop() {&#xA;  delay(2000); &#xA;&#xA;  float DHT_hum = dht.readHumidity();&#xA;  float DHT_temp_c = dht.readTemperature(false);&#xA;  float DHT_temp_f = dht.readTemperature(true);&#xA;&#xA;  if (isnan(DHT_hum) || isnan(DHT_temp_c) || isnan(DHT_temp_f)) {&#xA;    Serial.println(&quot;Failed to read from DHT sensor!!&quot;);&#xA;    lcd.clear();&#xA;    lcd.print(&quot;fail! &quot;); &#xA;    return;&#xA;  }&#xA;&#xA;  float heat_index = dht.computeHeatIndex(DHT_temp_f, DHT_hum);&#xA;&#xA;  Serial.print(&quot;Humidity: &quot;); &#xA;  Serial.print(DHT_hum);&#xA;  Serial.print(&quot; %\t&quot;);&#xA;  Serial.print(&quot;Temperature: &quot;); &#xA;  Serial.print(DHT_temp_c);&#xA;  Serial.print(&quot; *C &quot;);&#xA;  Serial.print(DHT_temp_f);&#xA;  Serial.print(&quot; *F\t&quot;);&#xA;  Serial.print(&quot;Heat index: &quot;);&#xA;  Serial.print(heat_index);&#xA;  Serial.println(&quot; *F&quot;);&#xA;&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Humi: &quot;);  &#xA;  lcd.print(DHT_hum);  &#xA;  lcd.print(&quot;%&quot;);  &#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Temp: &quot;);  &#xA;  lcd.print(DHT_temp_c); &#xA;  lcd.print(&quot;C&quot;); &#xA;  lcd.setCursor(14, 0);&#xA;  lcd.print(&quot;HI: &quot;);&#xA;  lcd.setCursor(14, 1);&#xA;  lcd.print(dht.convertFtoC(heat_index)); &#xA;  lcd.print(&quot;C&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, I use pin 13 for the DHT11 (DHTPIN).&#xA;If I set to it to &quot;2&quot; then my program is no longer working (having the pin connected or not doesn't change the result).&#xA;The serial display&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial OK!&#xA;Init finished!&#xA;Failed to read from DHT sensor!!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and that's all, it even doesn't loop to display &quot;Failed to read from DHT sensor!!&quot; again. LCD text doesn't change too. Like if the program is totally exiting after &quot;Serial.println(&quot;Failed to read from DHT sensor!!&quot;);&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm lost... The LCD lib I use is the very common one from fm&#xA;&lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10425" LastActivityDate="2015-07-12T17:10:20.630" Title="LiquidCrystal_i2c and Pin 2" Tags="|lcd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12676" PostTypeId="1" CreationDate="2015-06-16T00:34:32.600" Score="3" ViewCount="9681" Body="&lt;p&gt;I want to publish sensor data to server using MQTT protocol via GPRS/GSM modem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I googled MQTT for Arduino, AQTT Arduino available only for Ethernet shield or will MQTT Arduino Ethernet shield work in GSM modem?&lt;/p&gt;&#xA;" OwnerUserId="10608" LastEditorUserId="9962" LastEditDate="2016-02-25T20:20:33.857" LastActivityDate="2017-07-13T13:50:47.277" Title="MQTT for GSM/GPRS sheild" Tags="|programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12677" PostTypeId="1" CreationDate="2015-06-16T00:54:10.700" Score="0" ViewCount="1215" Body="&lt;p&gt;I would like to use the &lt;a href=&quot;http://playground.arduino.cc/Main/DS1302&quot; rel=&quot;nofollow&quot;&gt;DS1302&lt;/a&gt;, as a count up timer.&#xA;My goal is to have the arduino time the amount of me driving my car.&#xA;So it DS1302 will be used a count-up timer ie accumulate time. however when the car is switched off, I don't want to lose the value, and when I use my car again I would like to the time to continue accumulating. The resolution can be in minutes, as this will probably be the best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like something like an &lt;a href=&quot;https://en.wikipedia.org/wiki/Odometer&quot; rel=&quot;nofollow&quot;&gt;odometer&lt;/a&gt; of a car, except its going to be the time, instead of distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q:&lt;/strong&gt; Can this be done with the DS1302 Module? and also how can I do this? Is there a sample code for a count-up timer?&lt;/p&gt;&#xA;" OwnerUserId="8060" LastActivityDate="2015-06-16T20:35:18.733" Title="DS1302 as a counter/count-up timer" Tags="|timers|time|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12679" PostTypeId="2" ParentId="12676" CreationDate="2015-06-16T03:45:29.793" Score="0" Body="&lt;p&gt;MQTT is an TCP/IP protocol. MQTT-SN is for wireless serial and is slightly different but you can bridge the two.  Since you can establish a TCP/IP session over GSM, I would expect that functionality would not be duplicated in any way by MQTT, but would instead depend on your GSM hardware providing the TCP layer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the final comment, I doubt if you would ever see this on an Arduino. Simple alternative, use a common smartphone as a wifi hot spot, done.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-06-16T03:45:29.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12680" PostTypeId="2" ParentId="12045" CreationDate="2015-06-16T05:48:54.737" Score="4" Body="&lt;p&gt;Just added a 47uf capacitor to the pin 1 and 2 in  NF24L01 ,then every thing worked fine  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is the new setup .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mrPtm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10208" LastEditorUserId="10208" LastEditDate="2015-06-16T06:48:17.727" LastActivityDate="2015-06-16T06:48:17.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12681" PostTypeId="1" CreationDate="2015-06-16T07:47:23.500" Score="0" ViewCount="739" Body="&lt;p&gt;I am working on a keypad password lock system based on arduino UNO. I have used the password library from Arduino's website. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to accomplish is to set two passwords, namely pass1 and pass 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The condition is that this circuit is attached to a gate, if user 1 lets say knows pass1, after entering the pass the gate will unlock for 10 seconds and the pass1 becomes invalid i.e. can not be used in future. However if user 2 comes and knows pass2, after entering the pass2, the gate will open for 10 seconds and then pass2 becomes invalid; so each password can be used only once. I am attaching the code I already have below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this code is that when pass1 is executed, the system does not take pass2 until unless the system is reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly tell me a solution to fix this.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Password.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Password.h&amp;gt;&#xA;#include &amp;lt;Keypad.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(7, 6, 5, 4, 3, 2);&#xA;Password password1 = Password(&quot;1234&quot;);&#xA;Password password2 = Password(&quot;4567&quot;);&#xA;int ledpin = A5;&#xA;int a = 0;&#xA;const byte ROWS = 4; // Four rows&#xA;const byte COLS = 4; // columns&#xA;&#xA;char keys[ROWS][COLS] = {&#xA;    {'1','2','3','A'},&#xA;    {'4','5','6','B'},&#xA;    {'7','8','9','C'},&#xA;    {'*','0','#','D'}&#xA;};&#xA;&#xA;byte rowPins[ROWS] = {A0, A1, A2, A3};&#xA;byte colPins[COLS] = { 8,  9, 10, 11};&#xA;&#xA;Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);&#xA;&#xA;&#xA;void setup() {&#xA;    lcd.begin(16, 2);&#xA;    keypad.addEventListener(keypadEvent); //add an event listener for this keypad&#xA;}&#xA;&#xA;void loop() {&#xA;    keypad.getKey();&#xA;}&#xA;&#xA;void keypadEvent(KeypadEvent eKey) {&#xA;    switch (keypad.getState()) {&#xA;        case PRESSED:&#xA;            lcd.println(eKey);&#xA;            switch (eKey) {&#xA;                case '*':&#xA;                    checkPassword();&#xA;                    break;&#xA;                case '#':&#xA;                    password1.reset();&#xA;                    password2.reset();&#xA;                    break;&#xA;                default:&#xA;                    password1.append(eKey);&#xA;                    password2.append(eKey);&#xA;            }&#xA;            return;&#xA;    }&#xA;}&#xA;&#xA;void checkPassword() {&#xA;    if (password1.evaluate()) {&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.println(&quot;code1 OK&quot;);&#xA;        delay(2000);&#xA;        digitalWrite(ledpin, HIGH);&#xA;        delay(10000);&#xA;        digitalWrite(ledpin, LOW);&#xA;        password1.append('1');&#xA;        lcd.clear();&#xA;        return;&#xA;    } else if (password2.evaluate()) {&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.println(&quot;code2 OK&quot;);&#xA;        delay (2000);&#xA;        digitalWrite(ledpin, HIGH);&#xA;        delay(10000);&#xA;        digitalWrite(ledpin, LOW);&#xA;        password2.append('2');&#xA;        lcd.clear();&#xA;        return;&#xA;    } else {&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.println(&quot;Wrong&quot;);&#xA;        delay(2000);&#xA;        lcd.clear();&#xA;        lcd.print(&quot;Wait for 5 Sec&quot;);&#xA;        delay(5000);&#xA;        lcd.clear();&#xA;        return;&#xA;    }&#xA;    return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regards&#xA;Fawad  &lt;/p&gt;&#xA;" OwnerUserId="10670" LastEditorUserId="10907" LastEditDate="2016-01-12T22:12:25.270" LastActivityDate="2016-02-12T00:01:03.600" Title="Exiting from one loop and get ready for another" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12682" PostTypeId="2" ParentId="12681" CreationDate="2015-06-16T09:46:31.417" Score="1" Body="&lt;p&gt;You are never really invalidating the passwords. The statement&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;password1.append('1');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;adds '1' to the &lt;strong&gt;guess&lt;/strong&gt;, it does not change the &lt;strong&gt;password&lt;/strong&gt; itself.&#xA;If you really want to invalidate the password, you should change it to&#xA;something that cannot be typed on the keypad. For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;password1.set(&quot;X&quot;);  // untypable password&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whether or not you do invalidate the previously used passwords, you&#xA;should reset the guesses once a password has been checked. This can be&#xA;done in &lt;code&gt;checkPassword()&lt;/code&gt;, or in &lt;code&gt;keypadEvent()&lt;/code&gt; as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (eKey) {&#xA;    case '*':&#xA;        checkPassword();&#xA;        password1.reset();&#xA;        password2.reset();&#xA;        break;&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;strong&gt;all&lt;/strong&gt; your &lt;code&gt;return&lt;/code&gt; statements are useless, and the first&#xA;switch/case in &lt;code&gt;keypadEvent&lt;/code&gt; can be replaced by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (keypad.getState() == PRESSED)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would be easier to read.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-16T09:46:31.417" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12683" PostTypeId="1" AcceptedAnswerId="12701" CreationDate="2015-06-16T10:07:57.380" Score="0" ViewCount="77" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/app/serial2ws&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; to connect an Arduino Yun with a browser using Autobahn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the python file in the above repo, there is this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def controlLed(self, turnOn):&#xA;    if turnOn:&#xA;        payload = b'1'&#xA;    else:&#xA;        payload = b'0'&#xA;    self.transport.write(payload)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the thing - I need to send whole sketches to my Yun, not just '1' or '0'. I tried sending more to the payload (like &lt;code&gt;payload = b'this is part or all of a sketch'&lt;/code&gt;) but that doesn't work. I experimented with some other data types but at the moment these are shots in the dark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I send some proper data (like 100 lines of Arduino sketch) with this mechanism? The end goal is that my existing sketch receives the new sketch commands via serial and runs them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (port-&amp;gt;available()) {&#xA;  int commands = port-&amp;gt;read();&#xA;  // Run commands here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would be hugely appreciative of any help. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-06-16T22:00:53.400" Title="Transmitting sketches to Yun with Autobahn - a byte at a time?" Tags="|serial|arduino-yun|sketch|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12684" PostTypeId="2" ParentId="12621" CreationDate="2015-06-16T10:28:52.450" Score="4" Body="&lt;p&gt;For knowing which functions take the most space, I generally use&#xA;&lt;code&gt;avr-nm&lt;/code&gt;. This command is intended to display the symbol table of a&#xA;compiled program. It is one of the tools that you get when you install&#xA;the Arduino environment, so you already have it. avr-nm provides the&#xA;same information as &lt;code&gt;avr-objdump -t&lt;/code&gt;, but it can display it in a nicer&#xA;format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I ran the following command on the basic blinky program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-nm --size-sort -Crtd blink.elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000148 T __vector_16&#xA;00000118 T init&#xA;00000114 T pinMode&#xA;00000108 T digitalWrite&#xA;00000082 t turnOffPWM&#xA;00000076 T delay&#xA;00000070 T micros&#xA;00000040 T loop&#xA;00000026 T main&#xA;00000020 T digital_pin_to_timer_PGM&#xA;00000020 T digital_pin_to_port_PGM&#xA;00000020 T digital_pin_to_bit_mask_PGM&#xA;00000016 T __do_clear_bss&#xA;00000010 T port_to_output_PGM&#xA;00000010 T port_to_mode_PGM&#xA;00000008 T setup&#xA;00000004 B timer0_overflow_count&#xA;00000004 B timer0_millis&#xA;00000001 b timer0_fract&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first column is the size of the object referenced by the symbol.&#xA;Second column is the type, where ‘t’ (upper or lower case) means “text”&#xA;(code and PROGMEM data), ‘d’ means “initialized data” (stored in flash&#xA;and copied to RAM at startup) and ‘b’ means “uninitialized data” (a.k.a.&#xA;“BSS”, occupies no flash, only RAM). The last column is the symbol's&#xA;name. In this example you can see that the biggest function is&#xA;&lt;code&gt;__vector_16&lt;/code&gt; (the ISR for timer 0 overflow), and it takes 148 bytes of&#xA;flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The options I passed to avr-nm are the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;--size-sort&lt;/code&gt;, obviously, sorts the symbols by size. It also displays&#xA;the size, instead of the address, on the first column.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-C&lt;/code&gt; is for demangling the C++ symbols. For example, instead of&#xA;displaying “_ZN14HardwareSerial5beginEm”, it would display&#xA;“HardwareSerial::begin(unsigned long)”.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-r&lt;/code&gt; means “reverse sort”. This is for having the biggest functions at&#xA;the top, instead of at the bottom.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-td&lt;/code&gt; is for displaying the sizes in decimal instead of hexadecimal.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since you are only interested in flash usage, you can ignore the symbols&#xA;in BSS. On a unixish OS, you could just pipe into &lt;code&gt;grep -iv ' b '&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-16T10:28:52.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12685" PostTypeId="1" CreationDate="2015-06-16T11:53:16.363" Score="0" ViewCount="957" Body="&lt;p&gt;I'm using the DYP-ME007TX sensor with arduino uno. &#xA;The output from this sensor comes in packets of 4-bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Data[0]= 0xFF: Packet Header&#xA;Data[1]= 0x0-0xFF: Data Most Significant Byte (MSB)&#xA;Data[2]= 0x0-0xFF: Data Least Significant Byte (LSB)&#xA;Data[3]= 0x0-0xFF: Data Checksum: = (0XFF + MSB + LSB) &amp;amp;amp; 0xFF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Data is in MILLIMETERS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;16 bit value in &lt;code&gt;mm = Data[1] &amp;lt;&amp;lt; 8 | Data[2]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can exctract this packet in arduino sketch and extract millimeter number?&lt;/p&gt;&#xA;" OwnerUserId="10676" LastEditorUserId="46" LastEditDate="2015-06-16T13:10:58.037" LastActivityDate="2017-07-24T00:33:03.020" Title="How to read bytearray from arduino pin in arduino sketch" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12686" PostTypeId="2" ParentId="12685" CreationDate="2015-06-16T12:08:12.470" Score="1" Body="&lt;p&gt;I found the answer from forum.arduino.cc&#xA;There is a sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;// TX_PIN is not used by the sensor, since that the it only transmits!&#xA;#define PING_RX_PIN 6&#xA;#define PING_TX_PIN 7&#xA;&#xA;SoftwareSerial mySerial(PING_RX_PIN, PING_TX_PIN);&#xA;&#xA;long inches = 0, mili = 0;&#xA;byte mybuffer[4] = {0};&#xA;byte bitpos = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  bitpos = 0;&#xA;  while (mySerial.available()) {&#xA;    // the first byte is ALWAYS 0xFF and I'm not using the checksum (last byte)&#xA;    // if your print the mySerial.read() data as HEX until it is not available, you will get several measures for the distance (FF-XX-XX-XX-FF-YY-YY-YY-FF-...). I think that is some kind of internal buffer, so I'm only considering the first 4 bytes in the sequence (which I hope that are the most recent! :D )&#xA;    if (bitpos &amp;lt; 4) {&#xA;      mybuffer[bitpos++] = mySerial.read();&#xA;    } else break;&#xA;  }&#xA;  mySerial.flush(); // discard older values in the next read&#xA;&#xA;  mili = mybuffer[1]&amp;lt;&amp;lt;8 | mybuffer[2]; // 0x-- : 0xb3b2 : 0xb1b0 : 0x--&#xA;  Serial.print(&quot;PING: &quot;);&#xA;  Serial.print(mili/10);&#xA;  Serial.println(&quot;sm&quot;);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10676" LastActivityDate="2015-06-16T12:08:12.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12687" PostTypeId="1" CreationDate="2015-06-16T13:31:30.443" Score="1" ViewCount="1719" Body="&lt;p&gt;The day before I got my used full package arduino uno. I tested it on USB plug. Everything worked fine. I wrote a piece of testing code and uploaded. After I have accomplished with the test I have unpluged arduino from PC and connected to battery and I see that it does not work. I have used a multi-tester to find out the voltage. It showed 4.7V. Now I wonder should I buy a new battery or there is another reason for this. Anybody, please suggest me what to do.&#xA;&lt;strong&gt;Update&lt;/strong&gt;&#xA;The battery came with arduino set. It is written that it is a 9V battery. I am plugging it to the battery input in my arduino uno. Polarity is ok. The same program working on connection via usb, does not when connected to battery.&lt;/p&gt;&#xA;" OwnerUserId="8389" LastEditorUserId="8389" LastEditDate="2015-06-16T15:37:30.733" LastActivityDate="2021-06-11T14:15:07.550" Title="Arduino does not work on battery" Tags="|arduino-uno|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12688" PostTypeId="2" ParentId="8326" CreationDate="2015-06-16T13:54:06.430" Score="1" Body="&lt;p&gt;I found the &lt;a href=&quot;http://fastled.io/&quot; rel=&quot;nofollow&quot;&gt;http://fastled.io/&lt;/a&gt; libary to be a useful and well documented (&lt;a href=&quot;https://github.com/FastLED/FastLED/wiki/Overview&quot; rel=&quot;nofollow&quot;&gt;https://github.com/FastLED/FastLED/wiki/Overview&lt;/a&gt;) alternative to Adafruit's NeoPixel library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FastLED has some clever compression of palettes, and many other nice features that might save you valuable memory when using many neopixels.&lt;/p&gt;&#xA;" OwnerUserId="10678" LastActivityDate="2015-06-16T13:54:06.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12689" PostTypeId="1" CreationDate="2015-06-16T13:59:21.577" Score="3" ViewCount="1343" Body="&lt;p&gt;WM8731 codec was successfully interfaced with Atmega328 like variants in Arduino. It was first done successfully by Open music labs who are the makers of the breakout board for WM8731. Taking this library as reference another library was developed for atmega2560 Arduino and it also works fine. But now I am trying to get it work with Arduino Due which unlike other AVR micro-controllers in the Arduino family is an ARM. I found some useful code.It compiles well and is able to communicate with the WM8731 codec in I2C. I will post the original library and also explain in parts how the code for Due is built. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original library is here:&#xA;&lt;a href=&quot;http://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/AudioCodecNew.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/AudioCodecNew.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code split looking at the AudioCodec.h file.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define LINVOL 23&#xA;#define RINVOL 23&#xA;#define LHPVOL 121&#xA;#define RHPVOL 121&#xA;#define ADCHPD 0&#xA;#define SIDEATT 0&#xA;#define SIDETONE 0&#xA;#define DACSEL 1&#xA;#define BYPASS 0&#xA;#define INSEL 0&#xA;#define MUTEMIC 1&#xA;#define MICBOOST 0&#xA;#define SAMPLE_RATE 44&#xA;&#xA;volatile boolean l;&#xA;&#xA;unsigned int temp = 0,temp1=0;&#xA;int temp_spi[4];&#xA;int m1[301],m2[301];&#xA;//TC1 ch 0&#xA;int left_in,right_in,left_out,right_out;&#xA;void TC0_Handler()&#xA;{&#xA;TC_GetStatus(TC0, 0);&#xA;&#xA;    temp = random(65535);&#xA;    //temp = left_out;&#xA;    //temp1 = right_out;&#xA;    temp_spi[0] = SPI.transfer(10,highByte(temp),SPI_CONTINUE);&#xA;    temp_spi[1] = SPI.transfer(10,lowByte(temp),SPI_CONTINUE);&#xA;    temp_spi[2] = SPI.transfer(10,highByte(temp),SPI_CONTINUE);&#xA;    temp_spi[3] = SPI.transfer(10,lowByte(temp),SPI_LAST);&#xA;    //left_in - (temp_spi[0]&amp;lt;&amp;lt;8)|temp_spi[1];&#xA;    //right_in = (temp_spi[2]&amp;lt;&amp;lt;8)|temp_spi[3];&#xA;    /*Serial.println(&quot;Hello&quot;);&#xA;    Serial.println(temp_spi[0]);&#xA;    Serial.println(temp_spi[1]);&#xA;    Serial.println(temp_spi[2]);&#xA;    Serial.println(temp_spi[3]);*/&#xA;}&#xA;&#xA;void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t     frequency) {&#xA;    pmc_set_writeprotect(false);&#xA;    pmc_enable_periph_clk((uint32_t)irq);&#xA;    TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);&#xA;    uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above&#xA;    TC_SetRA(tc, channel, rc/2); //50% high, 50% low&#xA;    TC_SetRC(tc, channel, rc);&#xA;    TC_Start(tc, channel);&#xA;    tc-&amp;gt;TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;&#xA;    tc-&amp;gt;TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;&#xA;    NVIC_EnableIRQ(irq);&#xA;}&#xA;&#xA;void AudioCodec_init() {&#xA;    randomSeed(analogRead(0));&#xA;    SPI.begin(10);&#xA;    SPI.setBitOrder(MSBFIRST);&#xA;    SPI.setClockDivider(10,21); // select to ss pin 10, 4 MHz&#xA;    SPI.setDataMode(10,SPI_MODE0);&#xA;&#xA;    // setup i2c pins and configure codec&#xA;    // the new Wire library has trouble with 0x00, so (uint8_t) is added&#xA;    // To change the Wire interface speed, go to:&#xA;    // &amp;lt;path_from_arduino&amp;gt;\hardware\arduino\sam\libraries\Wire\Wire.h&#xA;    // and change the parameters TWI_CLOCK, RECV_TIMEOUT and XMIT_TIMEOUT&#xA;    // to the desire frequency.&#xA;    int temp_wire1;&#xA;    int temp_wire2;&#xA;&#xA;    Wire.begin();&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x0c); // power reduction register&#xA;    Wire.write((uint8_t)0x00); // turn everything on&#xA;    temp_wire1 = Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x0e); // digital data format&#xA;    Wire.write(0x03); // 16b SPI mode&#xA;    temp_wire2 = Wire.endTransmission();&#xA;&#xA;    //Serial.println(temp_wire1);&#xA;    //Serial.println(temp_wire2);&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write((uint8_t)0x00); // left in setup register&#xA;    Wire.write((uint8_t)LINVOL);&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x02); // right in setup register&#xA;    Wire.write((uint8_t)RINVOL);&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x04); // left headphone out register&#xA;    Wire.write((uint8_t)LHPVOL);&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x06); // right headphone out register&#xA;    Wire.write((uint8_t)RHPVOL);&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x0a); // digital audio path configuration&#xA;    Wire.write((uint8_t)ADCHPD);&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x08); // analog audio pathway configuration&#xA;    Wire.write((uint8_t)((SIDEATT &amp;lt;&amp;lt; 6)|(SIDETONE &amp;lt;&amp;lt; 5)|(DACSEL &amp;lt;&amp;lt; 4)|(BYPASS &amp;lt;&amp;lt; 3)|(INSEL &amp;lt;&amp;lt; 2)|(MUTEMIC &amp;lt;&amp;lt; 1)|(MICBOOST &amp;lt;&amp;lt; 0)));&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x10); // clock configuration&#xA;    #if SAMPLE_RATE == 88&#xA;      Wire.write(0xbc);&#xA;    #elif SAMPLE_RATE == 44&#xA;      Wire.write(0xa0);&#xA;    #elif SAMPLE_RATE == 22&#xA;      Wire.write(0xe0);&#xA;    #elif SAMPLE_RATE == 8&#xA;      Wire.write(0xac);&#xA;    #elif SAMPLE_RATE == 2&#xA;      Wire.write(0xce);&#xA;    #endif&#xA;    Wire.endTransmission();&#xA;&#xA;    Wire.beginTransmission(0x1a);&#xA;    Wire.write(0x12); // codec enable&#xA;    Wire.write(0x01);&#xA;    Wire.endTransmission();&#xA;&#xA;}&#xA;&#xA;void setup(){&#xA;&#xA;    pinMode(2,INPUT);&#xA;    pinMode(10,OUTPUT);&#xA;    Serial.begin(115200);&#xA;    Serial1.begin(9600);&#xA;    Serial.println(&quot;Hello&quot;);&#xA;AudioCodec_init();&#xA;startTimer(TC0, 0, TC0_IRQn, 2000); //startTimer(TC1, 0, TC3_IRQn,   44100); //TC1 channel 0, the IRQ for that channel and the desired frequency&#xA;}&#xA;&#xA;void loop(){&#xA;//Serial.println(&quot;Hello&quot;);&#xA;/*for(int i =0;i&amp;lt;300;i++)&#xA;{&#xA;m1[i]=map(analogRead(0),300,800,-400,400);&#xA;m2[i]=map(analogRead(1),300,800,-400,400);&#xA;}*/&#xA;//for(int j =0;j&amp;lt;300;j++)&#xA;//{&#xA;/*Serial1.print(&quot;a&quot;);&#xA;Serial1.print(m1[j]);&#xA;Serial1.print(&quot;b&quot;);&#xA;Serial1.print(m2[j]);*/&#xA;//Serial1.println(left_in);&#xA;Serial.print(temp_spi[0]);&#xA;Serial.print(&quot; &quot;);&#xA;Serial.print(temp_spi[1]);&#xA;Serial.print(&quot; &quot;);&#xA;Serial.print(temp_spi[2]);&#xA;Serial.print(&quot; &quot;);&#xA;Serial.println(temp_spi[3]);&#xA;//Serial1.println(&quot;c&quot;);&#xA;//Serial.println(&quot;In loop&quot;);&#xA;//h23}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So on atmega328 the clockout from the WM8731 was give to T1 pin and on atmega2560 timer 5 was used and clockout was attached to pin T5. I am just starting with Due and I dont know much about ARM but I set the code to TC0,TC0 timer and pin 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As described here in this link:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=130423.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=130423.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some how the SPI part in this code and the timer is not working as I cannot get any voice out from the codec.I am also printing the temp_spi[x] variables over serial port and all of them are just zeros all the time. Could some one help me make this code work with the codec? The code compiles fine for Due in the arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="10677" LastEditorUserId="37523" LastEditDate="2019-05-16T03:53:36.913" LastActivityDate="2019-05-16T03:53:36.913" Title="Interfacing WM8731 code to Arduino Due" Tags="|arduino-due|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12690" PostTypeId="2" ParentId="12677" CreationDate="2015-06-16T14:25:37.073" Score="2" Body="&lt;p&gt;Do you mean only accumulate during powered/driving, or also during standing still? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the former, just get the start time in setup, then in loop continuously get the time and calculate the difference between it and the time read in setup. Since you don't know when power is lost you need to continually write the elapsed time to some form of non-volatile memory. You could use the Arduinos EEPROM, but that can wear out over time. It's better the use the DS1302s 31 byte of battery backed RAM. Next time the arduino starts up you need to read out this value and add this to the difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of the latter, you can halt the DS1302 so it stops incrementing time.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-16T14:25:37.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12691" PostTypeId="1" CreationDate="2015-06-16T14:35:09.653" Score="1" ViewCount="2414" Body="&lt;p&gt;Using Arduino &lt;em&gt;(i got &lt;strong&gt;leonardo&lt;/strong&gt; and &lt;strong&gt;uno&lt;/strong&gt;)&lt;/em&gt;,&#xA;I'm looking for a way to get the &lt;strong&gt;RPM of my car's engine&lt;/strong&gt;.&#xA;I know this can be done using an OBD2 connection however i'm looking for a different way.&lt;/p&gt;&#xA;&lt;h1&gt;Sensing?&lt;/h1&gt;&#xA;&lt;p&gt;I need a reference for a &lt;strong&gt;sensor&lt;/strong&gt; / a &lt;strong&gt;creative way&lt;/strong&gt; to get this data.&lt;/p&gt;&#xA;&lt;p&gt;Having said that, these approaches came up:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;guessing the RPM by reading the amps in the car's 12V connection&lt;/li&gt;&#xA;&lt;li&gt;recording the sound of the engine using a microphone and setting thresholds for certain RPM values&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7417" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-08-07T02:31:22.020" Title="Which type of sensor should i use to get RPM of an engine?" Tags="|sensors|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12692" PostTypeId="1" AcceptedAnswerId="12694" CreationDate="2015-06-16T14:49:52.017" Score="0" ViewCount="130" Body="&lt;p&gt;I am totally new to and don't know where to start, I am interested in building new system with combination of hardware and software and every time I search how to make that embedded system it finally reaches to Arduino and don't know anything about that what to buy and I also have some more question like&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is one Arduino device required for each Arduino project ?&lt;/li&gt;&#xA;&lt;li&gt;Should I have to buy more then one device for each project ?&lt;/li&gt;&#xA;&lt;li&gt;If not then how I will make that project run without Arduino ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10679" LastActivityDate="2015-06-16T15:01:38.000" Title="How to start Arduino programming?" Tags="|arduino-uno|programming|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12693" PostTypeId="1" AcceptedAnswerId="13169" CreationDate="2015-06-16T14:57:33.457" Score="1" ViewCount="545" Body="&lt;p&gt;I am trying to build a ZigBee network using XBee Pro S2 devices (API Mode).&#xA;Setting up the network and sending packets is easy enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to trace the route a packet travelled from the end-device to the coordinator? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &#xA;&lt;br/&gt;I have 2 routers, one in area A connected to the coordinator, and the other in area B connected to the router in area A. End-device enters area B, and transmits a packet to the coordinator. &lt;br&gt;&lt;strong&gt;Path: end-device-&gt;routerB-&gt;routerA-&gt;Coordinator&lt;/strong&gt;. &#xA;&lt;br/&gt;Is it possible to know the end-device is in area B as it is the first router device the packet travelled through? &lt;/p&gt;&#xA;" OwnerUserId="2904" LastActivityDate="2015-07-05T16:32:52.930" Title="Determine XBee Packet Route" Tags="|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12694" PostTypeId="2" ParentId="12692" CreationDate="2015-06-16T15:01:38.000" Score="2" Body="&lt;p&gt;An Arduino is basically a Microcontroller on a handy PCB with built-in programming interface.  It also has a simple programming environment to get you up and running quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chip on the board can be thought of as the &quot;brain&quot; of the system.  It's what you program and it's where you upload your software to.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is one Arduino device required for each Arduino project?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes and no.  You can't &quot;remove&quot; your Arduino from your project and expect it to still work - it'd be like beheading someone - they cease to function without their brain.  However you can replicate the Arduino in your system fairly easily so you don't have to embed the whole Arduino into it.  You can get a blank chip the same as is on the Arduino reasonably cheaply and program the bootloader (the serial interface for programming it) into the chip using your existing Arduino, then build a new circuit around it.  More information here: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/Standalone&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Should I have to buy more then one device for each project?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That depends if your project is complex enough to warrant more than one &quot;brain&quot;.  Using the &quot;standalone&quot; instructions above you could make multiple chips from one Arduino and embed them all in your one project.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If not then how I will make that project run without Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are other Arduino boards available that are designed to be embedded in your project.  These are much smaller than the &quot;development&quot; boards like the Uno etc.  They are also cheaper, being typically the absolute bare minimum you need to get you going.  These can be a great way of saving time compared to the Standalone system above, and at the same time saving money compared to using the full blown Arduino boards.  Boards include the Mini and Nano range of boards.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardMini&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoBoardMini&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoBoardNano&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-16T15:01:38.000" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12696" PostTypeId="1" CreationDate="2015-06-16T17:01:06.587" Score="2" ViewCount="187" Body="&lt;p&gt;i am having a problem while sending sms from arduino to a specific number. cell phone getting sms but every time it gets same unicode -&quot; Ü &quot; . plz help us&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//--------------------------&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(2, 3);&#xA;&#xA;void setup()&#xA;{&#xA;    mySerial.begin(115200);  &#xA;    mySerial.print(&quot;\r&quot;);&#xA;    delay(1000);                    &#xA;    mySerial.print(&quot;AT+CMGF=1\r&quot;);    &#xA;    delay(20000);&#xA;&#xA;    mySerial.print(&quot;AT+CMGS=\&quot;+91..........\&quot;\r&quot;);    &#xA;&#xA;    delay(20000);&#xA;    mySerial.print(&quot;Hello!\r&quot;);   //The text for the message&#xA;    delay(10000);&#xA;    mySerial.write(0x1A);  //Equivalent to sending Ctrl+Z &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10682" LastEditorUserId="4143" LastEditDate="2015-06-16T17:23:57.653" LastActivityDate="2015-06-16T17:23:57.653" Title="sim 900 sending wrong sms -&quot; Ü &quot; to mobile phone from arduino" Tags="|arduino-uno|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12699" PostTypeId="1" AcceptedAnswerId="12702" CreationDate="2015-06-16T20:23:21.243" Score="0" ViewCount="3463" Body="&lt;p&gt;I'm trying to send an array back and forth between Processing and an Arduino UNO. But I think data is being lost along the way. I simply iterate over the array in Processing and send the Values separately. A new set of data is indicated by the character &lt;code&gt;&amp;lt;&lt;/code&gt;. On the Arduino the data gets added to a string and sent back for testing.  When I print out the string in processing, some data changed to &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array contains &lt;code&gt;{1,2,3,4,5,6,7,8}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12345678&#xA;12345678&#xA;1234-1-1-1-1&#xA;12345678&#xA;12345-1-1-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something I'm missing in terms of implementation, or is this simply a hardware related problem (like slightly different clock speeds)? Is there any way to improve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Sketch:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int srr[8];&#xA;&#xA;int content; // Data received from the serial port&#xA;void setup() {&#xA;  Serial.begin(9600); // Start serial communication at 9600 bps&#xA;}&#xA;&#xA; void loop() {&#xA;   String str = &quot;val:&quot;;&#xA;   int test;&#xA;   if (Serial.available()){ // If data is available to read,&#xA;     content = Serial.read();&#xA;   }&#xA;&#xA;   if (content == 60){&#xA;     for(int i=0; i&amp;lt;=7; i++)&#xA;   {&#xA;       str+=Serial.read();&#xA;   }&#xA;   Serial.println(str);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Processing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial myPort;  // Create object from Serial class&#xA;int arr[]={1,2,3,4,5,6,7,8};  //The array to send&#xA;&#xA;String str;&#xA;void setup() &#xA;{&#xA;  size(200,200); //make our canvas 200 x 200 pixels big&#xA;  String portName = Serial.list()[0];&#xA;  myPort = new Serial(this, portName, 9600);&#xA;}&#xA;&#xA;void draw() {&#xA;  //write&#xA;  myPort.write(&quot;&amp;lt;&quot;);&#xA;  for (int i =0; i&amp;lt;=7;i++){&#xA;    myPort.write(arr[i]);&#xA;&#xA;  }&#xA;  //read&#xA;  if ( myPort.available() &amp;gt; 0){  // If data is available,&#xA;    str = myPort.readStringUntil('\n');         // read it and store it in val&#xA;    println(str); //print it out in the console&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="10688" OwnerDisplayName="devon" LastEditorUserId="3917" LastEditDate="2015-06-17T20:12:36.190" LastActivityDate="2015-06-17T20:12:36.190" Title="Arduino processing serial comunication - losing data?" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12700" PostTypeId="2" ParentId="12677" CreationDate="2015-06-16T20:35:18.733" Score="1" Body="&lt;p&gt;What you're describing is the equivalent of a digital Hobbs hour meters. You can read up about them if your are interested. The old ones (not digital in today's sense) clicked an odometer-like movement every 0.1 hours (typically). I don't think you need a real-time clock module as long as you're not interested in &lt;em&gt;when&lt;/em&gt; you drove the car, but only in the accumulated duration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple way would be a 1-minute delay loop that increments a counter and writes it to EEPROM. The EEPROM has a write-endurance spec of 100,000 writes, equivalent to over 800 hours, used this way. You'll lose the last fraction of a minute, whether it's a few seconds or nearly a while minute, whenever you shut down the Arduino. There are ways around this, if it matters, but that's an &quot;exercise left for to the reader&quot; as my textbooks used to say. Clock your micro with a crystal, not with its internal resonator, for best accuracy.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-16T20:35:18.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12701" PostTypeId="2" ParentId="12683" CreationDate="2015-06-16T22:00:53.400" Score="0" Body="&lt;p&gt;Partial answer: to send more information than just a single byte, it is possible to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# python&#xA;payload = &quot;Here is a longer string&quot;&#xA;&#xA;# arduino&#xA;String commands = port-&amp;gt;readString();           // Reads the whole thing&#xA;String commands = port-&amp;gt;readStringUntil('\n');  // Reads until the given separator&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-06-16T22:00:53.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12702" PostTypeId="2" ParentId="12699" CreationDate="2015-06-16T23:26:02.020" Score="1" Body="&lt;p&gt;Ok, let's look at your Arduino program a bit at a time (for that is where the problem lies).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available()) { // If data is available to read,&#xA;    content = Serial.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If there is at least one character available in the buffer then read one character into the variable &lt;em&gt;content&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (content == 60) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the variable content is &lt;em&gt;60&lt;/em&gt; (better to use '&gt;' so you can see what it is), then ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for(int i=0; i&amp;lt;=7; i++) {&#xA;     str+=Serial.read();&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... read 8 characters from the serial buffer &lt;em&gt;whether there are any characters in there or not&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That last bit is the crunch point.  You have an unknown number of characters in the buffer.  You had at least one, and that one you read into &lt;em&gt;content&lt;/em&gt;.  You don't then check to see if there are the required 8 more characters available (or wait in each iteration of the loop for each character to actually arrive) before trying to read that character in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you take a moment to read the &lt;a href=&quot;http://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;documentation on Serial Read&lt;/a&gt; you will see this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Returns&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;the first byte of incoming serial data available &lt;em&gt;(or -1 if no data is available)&lt;/em&gt; - int &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The simplest fix is just to make your loop &lt;em&gt;blocking&lt;/em&gt; so it waits for a character to arrive before reading it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i=0; i&amp;lt;=7; i++) {&#xA;     while (!Serial.available());  // Wait for a character to arrive&#xA;     str+=Serial.read();  // Read it&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-16T23:26:02.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12703" PostTypeId="1" AcceptedAnswerId="12704" CreationDate="2015-06-16T23:47:27.163" Score="0" ViewCount="162" Body="&lt;p&gt;How can I convert a string like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;pinMode(2, INPUT_PULLUP)&quot;&#xA;&#xA;or&#xA;&#xA;'Keyboard.print(&quot;Hello world&quot;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into actual code that the Arduino can act on?&lt;/p&gt;&#xA;" OwnerUserId="10236" LastEditorUserId="10794" LastEditDate="2015-09-06T08:52:12.943" LastActivityDate="2015-09-06T08:52:12.943" Title="Convert a Serial string to a sketch command on Yun?" Tags="|arduino-yun|sketch|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12704" PostTypeId="2" ParentId="12703" CreationDate="2015-06-17T00:30:03.153" Score="1" Body="&lt;p&gt;You can't - not directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things you can do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Build your &quot;command&quot; into a sketch and compile it, then upload it in to the Yun's AVR chip.  The compiling will have to be done on your PC, and the HEX file uploaded to the AVR (you can do it directly through the Yun's web interface).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't send sketch code, but send pre-defined instructions like &quot;Turn on pin 3&quot; which your sketch then interprets.  That could be as simple as two bytes &quot;P3&quot; for instance.  It's entirely up to you how you craft that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Firmata might help with option 2 if uploading a new sketch every time isn't what you want to do.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-17T00:30:03.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12705" PostTypeId="1" CreationDate="2015-06-17T01:00:35.660" Score="1" ViewCount="182" Body="&lt;p&gt;So sanity check for a potential project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have an old dishwasher at work, a GE QuietPower 3, and being a technology company, we want to connect it to our chat room to notify that the cycle is done, so someone can unload it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first iteration of the project we were just going to cover the &quot;finished&quot; indicator light with a photoresistor, so when it lights up, the microcontroller will know it is done. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that is not very nice looking, the second approach, after quickly looking at the technical maintenance manual. Is to literally solder the ground and + of the &quot;finished&quot; indicator light to a digital or analog pin, and the ground pin on the micro controller, so the results are more precise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect the LED is probably less than 12V, (will confirm with a multimeter). I will step it down to 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it is just a matter of checking if the pin is high or not on the microcontroller, is this simple enough to solve the problem, or am I overlooking something obvious? &lt;/p&gt;&#xA;" OwnerUserId="10691" LastActivityDate="2015-06-17T03:04:42.217" Title="Sanity check with potential project. IoT with a dishwasher" Tags="|arduino-uno|led|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12706" PostTypeId="2" ParentId="12705" CreationDate="2015-06-17T01:24:26.907" Score="0" Body="&lt;p&gt;More or less. LEDs are often around the 2.something volt range, which won't be enough to power an Arduino. In addition, if you set it to run in parallel with the LED, then the path of least resistance will get most of the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would probably use the led power to turn on a transistor, then use the transistor to signal the Arduino. Be aware that if you want to power it off an external source, you may find that the ground on the washing machine is not the same as the ground on your power supply. If you're powering it off a battery, this won't matter, but otherwise power can flow from one &quot;ground&quot; to another. If you stick a resistor (maybe start with 1kOhm, if that's too much drop it down) between the washing machine led + and the transistor, and the same between the arduino and the transistor.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-17T01:24:26.907" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12707" PostTypeId="2" ParentId="12705" CreationDate="2015-06-17T03:04:42.217" Score="2" Body="&lt;p&gt;If connecting to the wiring, using an opto-coupler will ensure that your Arduino's days will be long on the face of the land. If it is an LED indicator you may be able to connect the opto-coupler LED  input directly across the existing LED, but use of an appropriate series resistor would be wise. Optocoupler LEDs may have about 2 V forward operating voltage which is in the same range as a red LED. Some use lower forwards voltage LEDS (probably IR).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your opto coupler has low input current requirements then connecting it via a series resistor across the existing LED will allow the indicator to still operate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;R series = (Vsource - V_opto_LED) / I_opto.&lt;br&gt;&#xA;eg 12V source, 2V opto_LED (typical), 1 mA (should be enough for logiclevel signal.)&lt;br&gt;&#xA;R = (12-2) / .001 A = 10/.001 = 10 k Ohm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For direct connection across an existing red LED a 100 Ohm series resistor should avert disaster.&lt;br&gt;&#xA;V drop in resistor at 1 mA:&lt;br&gt;&#xA;V = IR = 0.001 x 100 = 0.1 V&lt;br&gt;&#xA;= liable to be OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ask if more information wanted.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-06-17T03:04:42.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12708" PostTypeId="2" ParentId="12691" CreationDate="2015-06-17T03:36:57.543" Score="0" Body="&lt;p&gt;What about measuring the speedometer? I suspect that would be easiest - you may get away with hooking up the speedo directly to the Arduino analog (but measure with multimeter first!).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-17T03:36:57.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12709" PostTypeId="1" CreationDate="2015-06-17T05:31:26.780" Score="1" ViewCount="903" Body="&lt;p&gt;I have an Arduino that has 4 devices within an enclosure.  Each of the 4 devices needs 5 V and GND.  I have a shield with lots of unused pins (see photo).  I'd like to &quot;bridge&quot; one row of the pins to create a power rail, and I'd like to bridge another row to create a ground rail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think most people are using an external breadboard for this.  Also, I see that there is a shield that has power rails, but I don't have room for it.  I'm looking for a female header, or another way to bridge these unused pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I'm not asking about wiring voltage in parallel or amperage consumption.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6vn7I.jpg&quot; alt=&quot;example shield with unused pins in the center section&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10693" LastEditorUserId="26916" LastEditDate="2017-09-09T02:22:53.797" LastActivityDate="2017-09-09T02:22:53.797" Title="How can I create a power rail on my Arduino shield?" Tags="|arduino-mega|shields|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12710" PostTypeId="2" ParentId="12666" CreationDate="2015-06-17T07:45:34.603" Score="1" Body="&lt;p&gt;One problem in your original code is that you are only storing the current state of the buttons if they are pressed.  The next problem is that you are looping through all your brightness values when a button is pressed giving you your &quot;fades all the way up in one go&quot; problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be my replacement for your loop() code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA;    int currentButtonStateA = digitalRead(buttonApin);&#xA;    if (currentButtonStateA != lastButtonStateA &amp;amp;&amp;amp; currentButtonStateA == LOW)&#xA;    {&#xA;        currentBrightness += BRIGHTNESS_INCREMENT;  // BRIGHTNESS_INCREMENT is defined at the top of the file with #define BRIGHTNESS_INCREMENT 25&#xA;        if (currentBrightness &amp;gt; MAX_BRIGHTNESS)     // MAX_BRIGHTNESS is defined at the top of the file with #define MAX_BRIGHTNESS 255&#xA;        {&#xA;            currentBrightness = MAX_BRIGHTNESS;&#xA;        }&#xA;    }&#xA;    lastButtonStateA = currentButtonStateA;&#xA;&#xA;    int currentButtonStateB = digitalRead(buttonBpin);&#xA;    if (currentButtonStateB != lastButtonStateB &amp;amp;&amp;amp; currentButtonStateB == LOW)&#xA;    {&#xA;        currentBrightness -= BRIGHTNESS_INCREMENT;&#xA;        if (currentBrightness &amp;lt; MIN_BRIGHTNESS)     // MIN_BRIGHTNESS is defined at the top of the file with #define MAX_BRIGHTNESS 0&#xA;        {&#xA;            currentBrightness = MIN_BRIGHTNESS;&#xA;        }&#xA;    }&#xA;    lastButtonStateB = currentButtonStateB;&#xA;&#xA;    analogWrite(ledPin, currentBrightness);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully this is pretty self explanatory.  The current button A state is read and stored in a local variable.  If it is different to the previous state and it is low, the current brightness is incremented and capped at a maximum value.  Next the current button state is stored as the previous state ready for the next run through the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar actions are performed for the B button, but with a decrement rather than an increment.  Finally the LED brightness is set regardless of whether any buttons have been pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not need to store your current button states (buttonStateA) or your counts for the number of button presses (buttonPushCounterA - which you never referenced anyway) or your ms value so could get rid of those global variables.  You need a new global variable at the top of your file for currentBrightness (int currentBrightness = 0;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have used variables to store various non-changing numeric values, such as &quot;maxBright = 255;&quot; which is good practise, but is better (particularly with Arduino development) to use #define macros instead, such as &quot;#define MAX_BRIGHTNESS 255&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for this is that variables take up memory when the code is running - something that an Arduino Uno doesn't have a lot of, whereas a #define takes up no memory - the compiler uses it as a &quot;search and replace&quot; before compiling your code.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="8616" LastEditDate="2015-06-17T07:54:26.370" LastActivityDate="2015-06-17T07:54:26.370" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12711" PostTypeId="2" ParentId="12703" CreationDate="2015-06-17T08:49:03.083" Score="3" Body="&lt;p&gt;There is a third option: install an interpreter on the Arduino, then&#xA;just send it the program you want it to run. There are a few such&#xA;interpreters available. A quick search showed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://bitlash.net/&quot; rel=&quot;nofollow&quot;&gt;Bitlash&lt;/a&gt;, a C-like language&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://n.mtng.org/ele/arduino/iarduino.html&quot; rel=&quot;nofollow&quot;&gt;iArduino&lt;/a&gt;, another&#xA;C-like language&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://flashforth.com/&quot; rel=&quot;nofollow&quot;&gt;FlashForth&lt;/a&gt;, a&#xA;&lt;a href=&quot;http://en.wikipedia.org/wiki/Forth_%28programming_language%29&quot; rel=&quot;nofollow&quot;&gt;Forth&lt;/a&gt;&#xA;implementation&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lpereira/finf&quot; rel=&quot;nofollow&quot;&gt;FINF Is Not Forth&lt;/a&gt;, a Forth-like&#xA;language&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are probably many others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference between this option and Majenko's option 2 is that this&#xA;would allow you to send a complete program, with functions,&#xA;conditionals, loops, etc., whereas with a Firmata or similar approach&#xA;you would keep the program logic (functions, loops, conditionals) on the&#xA;host computer, and only send simple commands to the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-17T08:49:03.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12712" PostTypeId="2" ParentId="12709" CreationDate="2015-06-17T08:52:28.957" Score="4" Body="&lt;p&gt;Just bridge them.  Wire in your +5V connections then join them together on the back with lots of solder.  Maybe with a strand of 0.6mm single core wire along it for extra ruggedness.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-17T08:52:28.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12713" PostTypeId="2" ParentId="12709" CreationDate="2015-06-17T10:16:43.673" Score="3" Body="&lt;p&gt;Have you considered &quot;Conductive Silver Paint&quot;? With this you can literally paint tracks to join any arrangement of holes you so desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everybody from Maplins to Rapid Electronics sell it. There are many brands to choose from. Here is one at random: &lt;a href=&quot;http://www.rapidonline.com/mechanical-fastenings-fixings/kemo-conductive-silver-paint-180423&quot; rel=&quot;nofollow&quot;&gt;http://www.rapidonline.com/mechanical-fastenings-fixings/kemo-conductive-silver-paint-180423&lt;/a&gt; ...I like Rapid because they have a helpful Q&amp;amp;A section for each product.&lt;/p&gt;&#xA;" OwnerUserId="10695" LastActivityDate="2015-06-17T10:16:43.673" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12715" PostTypeId="1" CreationDate="2015-06-17T14:35:12.910" Score="2" ViewCount="13828" Body="&lt;p&gt;Not sure if this is the right place to post this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Due I'd like to start using. I've been using Unos, Megas etc no problem. The newer IDEs have removed the Due support. I've been trying to install Due support through the Board Manager, but it just says there is an error downloading the files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to manually install the board support for the DUe, or must it be done automatically, connecting through the internet?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open the Boards Manager, I get :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Error downloading http://downloads.arduino.cc/packages/package_index.json&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and when I try to install Due support, I get :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Error downloading http://downloads.arduino.cc/cores/sam-1.6.4.tar.bz2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand I may be behind proxies, but in IDE version 1.6.5, that has been removed from the Preferences, so I can't change that. I have tried to allow the IDE past the Windows Firefall, but that has not changed anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have manually downloaded &lt;em&gt;sam-1.6.4.tar.bz2&lt;/em&gt; and extracted the contents to &lt;em&gt;C:\Arduino\arduino-1.6.5\hardware\arduino\sam&lt;/em&gt; (I had to manually create the &lt;em&gt;sam&lt;/em&gt; folder). With this, I can see the options of Arduino Due Native USB Port and Arduino Due Programming Port when selecting the board, and when I look for it in the Ports, it can recognise the board at the port (eg &quot;COM5 (Arduino Due (Programming Port))&quot; ). When I try to compile anything, I get the error message :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Cannot run program &quot;{runtime.tools.arm-none-eabi-gcc.path}\bin\arm-none-eabi-g++&quot; (in directory &quot;.&quot;): CreateProcess error=2, The system cannot find the file specified&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other idea as to how I can install the Due? Is there an option for a manual installation? The same happens with Libraries Manager (I don't get a connection), so I guess, the same can be applied to that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question has been answered:&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/issues/3358&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/issues/3358&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to Federico Fissore!&lt;/p&gt;&#xA;" OwnerUserId="7689" LastEditorUserId="7689" LastEditDate="2015-06-18T14:00:04.930" LastActivityDate="2021-01-04T16:46:18.960" Title="Manual Arduino Due Installation" Tags="|arduino-ide|arduino-due|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12716" PostTypeId="2" ParentId="12691" CreationDate="2015-06-17T14:58:42.340" Score="2" Body="&lt;p&gt;I would think &lt;a href=&quot;http://arduinodev.com/hardware/obd-kit/&quot; rel=&quot;nofollow&quot;&gt;something like this&lt;/a&gt; would benefit you greatly. If your vehicle was produced after 1996 it will have an &lt;a href=&quot;https://en.wikipedia.org/wiki/On-board_diagnostics&quot; rel=&quot;nofollow&quot;&gt;OBD port&lt;/a&gt; near the steering wheel that allows you to read diagnostic information from the car. This diagnostic information always includes error codes (think: Check engine light), and often includes operating information like speed and engine rpm.&lt;/p&gt;&#xA;" OwnerUserId="10689" LastActivityDate="2015-06-17T14:58:42.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12718" PostTypeId="1" AcceptedAnswerId="12719" CreationDate="2015-06-17T16:10:10.613" Score="11" ViewCount="34829" Body="&lt;p&gt;I would like to increase the PWM bit resolution of the Arduino Uno.&#xA;At this moment it is 8-bit which I consider too low.&#xA;Is this possible without losing the ability of interrupts and delays?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Koen&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT&#xA;This setup delivers a 16-bit resultion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setupPWM16() {&#xA;    DDRB |= _BV(PB1) | _BV(PB2);        /* set pins as outputs */&#xA;    TCCR1A = _BV(COM1A1) | _BV(COM1B1)  /* non-inverting PWM */&#xA;        | _BV(WGM11);                   /* mode 14: fast PWM, TOP=ICR1 */&#xA;    TCCR1B = _BV(WGM13) | _BV(WGM12)&#xA;        | _BV(CS11);                    /* prescaler: clock / 8 */&#xA;    ICR1 = 0xffff;                      /* TOP counter value (freeing OCR1A*/&#xA;}&#xA;/* Comments about the setup&#xA;Changing ICR1 will effect the amount of bits of resolution.&#xA;ICR1 = 0xffff; (65535) 16-bit resolution&#xA;ICR1 = 0x7FFF; (32767) 15-bit resolution&#xA;ICR1 = 0x3FFF; (16383) 14-bit resolution etc....&#xA;&#xA;Changing the prescaler will effect the frequency of the PWM signal.&#xA;Frequency[Hz}=CPU/(ICR1+1) where in this case CPU=16 MHz&#xA;16-bit PWM will be&amp;gt;&amp;gt;&amp;gt; (16000000/8)/(65535+1)=30.5175Hz&#xA;*/&#xA;&#xA;/* 16-bit version of analogWrite(). Works only on pins 9 and 10. */&#xA;void analogWrite16(uint8_t pin, uint16_t val)&#xA;{&#xA;    switch (pin) {&#xA;        case  9: OCR1A = val; break;&#xA;        case 10: OCR1B = val; break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10700" LastEditorUserId="62745" LastEditDate="2020-01-30T21:51:59.873" LastActivityDate="2020-01-30T21:51:59.873" Title="Increase PWM bit resolution" Tags="|arduino-uno|pwm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12719" PostTypeId="2" ParentId="12718" CreationDate="2015-06-17T16:19:22.213" Score="16" Body="&lt;p&gt;The Arduino Uno is based on an ATmega382P microcontroller. This chip has&#xA;two 8-bit timers, driving two PWM channels each, and one 16-bit timer,&#xA;driving the last two channels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot increase the resolution of the 8-bit timers. You can,&#xA;however, put the 16-bit timer in 16-bit mode, instead of the 8-bit mode&#xA;used by the Arduino core library. This will give you two 16-bit PWM&#xA;channels, with a reduced frequency of 244&amp;nbsp;Hz (maximum). You will&#xA;probably have to configure the timer yourself, and will not benefit from&#xA;the easy to use &lt;code&gt;analogWrite()&lt;/code&gt; function. For details, see the section&#xA;on Timer 1 in in the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot;&gt;ATmega328P&#xA;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Here is an implementation of a 16-bit &lt;code&gt;analogWrite()&lt;/code&gt;. It&#xA;only works on pins 9 and 10, as these are the only pins connected to the&#xA;16-bit timer.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* Configure digital pins 9 and 10 as 16-bit PWM outputs. */&#xA;void setupPWM16() {&#xA;    DDRB |= _BV(PB1) | _BV(PB2);        /* set pins as outputs */&#xA;    TCCR1A = _BV(COM1A1) | _BV(COM1B1)  /* non-inverting PWM */&#xA;        | _BV(WGM11);                   /* mode 14: fast PWM, TOP=ICR1 */&#xA;    TCCR1B = _BV(WGM13) | _BV(WGM12)&#xA;        | _BV(CS10);                    /* no prescaling */&#xA;    ICR1 = 0xffff;                      /* TOP counter value */&#xA;}&#xA;&#xA;/* 16-bit version of analogWrite(). Works only on pins 9 and 10. */&#xA;void analogWrite16(uint8_t pin, uint16_t val)&#xA;{&#xA;    switch (pin) {&#xA;        case  9: OCR1A = val; break;&#xA;        case 10: OCR1B = val; break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may notice that the top of the counter sequence is configured&#xA;explicitly. You can change this to a smaller value to make the PWM&#xA;faster, at the cost of decreased resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is an example sketch illustrating its use:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    setupPWM16();&#xA;}&#xA;&#xA;/* Test: send very slow sawtooth waves. */&#xA;void loop() {&#xA;    static uint16_t i;&#xA;    analogWrite16(9, i);&#xA;    analogWrite16(10, 0xffff - i);&#xA;    i++;&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-17T19:19:21.793" LastActivityDate="2015-06-17T19:19:21.793" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="12720" PostTypeId="1" CreationDate="2015-06-17T16:25:04.443" Score="4" ViewCount="10364" Body="&lt;p&gt;All cables tested and work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SCL - A5&#xA;SDA - A4&#xA;VCC - 5V&#xA;GND - GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Nano board and an I&lt;sup&gt;2&lt;/sup&gt;C display - I've tried everything to get it to work and I'm now convinced it's a hardware fault. Using the Arduino I&lt;sup&gt;2&lt;/sup&gt;C address scanner, it is unable to find a device, even though it is wired correctly (I've checked multiple times).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6qAFF.jpg&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Nano and I2C display&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6qAFF.jpg&quot; alt=&quot;Nano and I2C display&quot; title=&quot;Nano and I2C display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code I used, &lt;a href=&quot;http://playground.arduino.cc/Main/I2cScanner&quot; rel=&quot;nofollow noreferrer&quot;&gt;i2c_scanner&lt;/a&gt;, and this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&#xA;Scanning...&#xA;No I2C devices found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... is all I get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions, or is my board output fried?&lt;/p&gt;&#xA;" OwnerUserId="10654" LastEditorUserId="6936" LastEditDate="2018-07-07T18:19:05.833" LastActivityDate="2018-07-08T08:48:49.233" Title="Can't detect I2C displays with Arduino Nano" Tags="|i2c|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="12721" PostTypeId="2" ParentId="12718" CreationDate="2015-06-17T17:41:04.263" Score="4" Body="&lt;p&gt;With some calibration you could sum the outputs of two PWM channels with differing weighting resistors. At the extreme you could notionally use one output to provide 8 bits of resolution and scale the other to 1/256th the level and add them so the 2nd channel covers one bit of range and you (again notionally) get 16 bits of resolution. Without immense care and adjustment all you'd get would be a mess.&lt;br&gt;&#xA;However by dividing the 2nd channel by 16 or 32 you could add several extra bits of PWM resolution. Just by adding 2 PWM channels analog filtered outputs you add an extra bit (as potential range is doubled for unchanged mV/bit).&lt;br&gt;&#xA;Notionally (again) for every additional divide by 2  you get an extra bit of resolution, but this can only be carried out for maybe 4 or 5 or 6 extra bits, with increasing accuracy requirements of scaling resistors and more difficult calibration and proneness to errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Brief example.&lt;br&gt;&#xA;If one PWM is scaled down to give say 0 - 255 mV in 1 mV step, then summing two PWMs with equal amplitude would give a 0 - 510 mV range in 1 mV steps.&lt;br&gt;&#xA;If one PWM is scaled down by a factor of 32 then instead of adding 255 mV to the initial PWMs range it would add only 8 mV to the top end (0.256.32 = 8 mV, but resolution would be in 0.03125 (1/32nd) mV steps.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this could perhaps be achieved purely with resistor summing and RC filtering, use of an op amp summer would greatly improve results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also PWM ripple could be filtered with a simple RC filter but use of one opamp as a buffer (or even just a single transistor as an emitter follower) would give you 3 or 5 poles of low pass filtering and much better chance of achieving extra PWM resolution. I have not inspected the &quot;phase coherence&quot; of the PWM outputs but expect that they move in relative lockstep so you don't get the smoothing advantage of adding two uncorrelated waveforms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More comment can be made if needed. Ask if interested. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-06-17T17:41:04.263" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12722" PostTypeId="2" ParentId="12651" CreationDate="2015-06-17T20:33:44.840" Score="0" Body="&lt;p&gt;If it's a grid of LEDs you may be able to place pressure sensors at points up and down the grid. Then you need to step on them in order to place the paddle at that point. Doesn't sound like you need 'exact' position, just a point on a grid. And you may be able to set up such pads to step on relatively cheap: force sensitive resistors or even whip up your own w/ cardboard and thin metal (foil?) separated with foam. We did similar for a halloween prop that was activated by stepping on the doormat.&lt;/p&gt;&#xA;" OwnerUserId="3004" LastActivityDate="2015-06-17T20:33:44.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12723" PostTypeId="1" AcceptedAnswerId="12724" CreationDate="2015-06-17T20:43:30.890" Score="3" ViewCount="2360" Body="&lt;p&gt;I know that the ADC on the Arduino Due has a clock speed from 1 MHz to 20 MHz. I have two questions: 1. What is the default clock speed when I run a sketch, and 2. How can I change it? (I am using Arduino 1.6.4.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why I want to slow down the ADC as much as possible is to obtain the maximum source impedance. Is this logic correct? (i.e., if I slow down the ADC in the arduino code to kHz values, then the source impedance will reach MΩ values?)&#xA;&lt;img src=&quot;https://i.stack.imgur.com/b08cX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10705" LastEditorUserId="10705" LastEditDate="2015-06-17T20:58:47.950" LastActivityDate="2016-02-24T15:29:27.040" Title="How to slow ADC clock speed to 1MHz on Arduino Due?" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12724" PostTypeId="2" ParentId="12723" CreationDate="2015-06-17T20:53:00.837" Score="1" Body="&lt;p&gt;You can change the prescaler (&lt;code&gt;ADCSR&lt;/code&gt; register). Lowest scaler is 2, so it can never run at 20mHz. Also Atmel recommends a max ADC clock of 1MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino sets the ADC clock to 125 KHz (prescaler of 128)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to match Arduino, you should select a prescaler of 8 ( set bits &lt;code&gt;ADPS1&lt;/code&gt; and &lt;code&gt;ADPS0&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-17T20:53:00.837" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12725" PostTypeId="1" AcceptedAnswerId="12727" CreationDate="2015-06-17T22:08:03.053" Score="1" ViewCount="2844" Body="&lt;p&gt;I am doing a project using Arduino Uno and ADXL 345.&#xA;I am quite new to this and I came across this post  in the link&quot; : &lt;a href=&quot;https://www.sparkfun.com/tutorials/240&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/tutorials/240&lt;/a&gt;. Here, a user had posted the below question in the forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Im trying to use this accelerometer to test various frequencies of vibration on a cantilevered beam and I wanted to know what the maximum vibration frequency I could find with using this accelerometer, connected to a 16MHz processor, connected to my laptop. I’m mainly a mechanical person, but after doing some research I found the following: Accelerometer has a maximum of 3200Hz output data rate (so maximum frequency would be 1600Hz) Processor can execute 16,000,000 instructions/sec so this probably is okay Communication rate is 9600 bits/sec so in the program above we read at a minimum 6 bytes for each axis, so that’s 24 bits, leaving you able to read 9600/24 = 400 reads/sec resulting in a one to be capable of reading vibrations at 200Hz. If I bump up the baud rate to 115200, I should be able to then read 4800 times a second, thus measuring 2400Hz vibrations?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I do not see any replies to this question. I feel the above analysis mostly makes sense. It would be helpful if someone could confirm that the above analysis is right. If not right , then why isn't it right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10706" LastEditorUserId="10706" LastEditDate="2015-06-17T22:15:43.363" LastActivityDate="2015-06-17T23:45:57.813" Title="Relationship between baud rate and the frequency of vibration read using ADXL" Tags="|arduino-uno|frequency|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12726" PostTypeId="1" CreationDate="2015-06-17T23:34:53.743" Score="0" ViewCount="1047" Body="&lt;p&gt;I want to make a toy car that follows a black line on the ground by using two sensor on the left and right sides of the car both pointing down. The sensor converts the light into a voltage that I will use to make the car turn left or right. I know that I can use batteries, but I am still very curious to find out if I could use my iPhone to power an Arduino because I also want to make a case with different sensors in it, and it would be thinner if I didn't have to put a 9V battery in the case.&lt;/p&gt;&#xA;" OwnerUserId="10707" LastActivityDate="2016-05-20T08:06:55.847" Title="Can I power a LilyPad with an iPhone lightning port?" Tags="|power|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12727" PostTypeId="2" ParentId="12725" CreationDate="2015-06-17T23:45:57.813" Score="1" Body="&lt;p&gt;Firstly, the datasheet for the accelerometer suggests using &gt;=2Mhz SPI communication rate with 3200 or 1600 Hz output data rate operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the Arduino SPI library default clock is 4Mhz, the Arduino can handle 3200 Hz sampling, so the maximum frequency you could distinguish would be 1600 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the Arduino and accelerometer can detect vibrations up to 1600Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, you send the data to your laptop. At 9600 BAUD, you are correct in saying that since the data is 24 bits, it will only update your laptop with the Arduino's measured frequency at 9600/24 = 400 Hz. So 400 times a second the Arduino could tell the laptop what frequency it measures, the measurement having a maximum frequency of 1600 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Arduino to simply pass the raw data to the laptop at 3200 Hz, you would need 24 bits * 3200 Hz = 76800 BAUD minimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The measurement data is in any case limited by the accelerometer sampling rate of 3200Hz.&lt;/p&gt;&#xA;" OwnerUserId="10708" LastActivityDate="2015-06-17T23:45:57.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12728" PostTypeId="2" ParentId="12726" CreationDate="2015-06-18T00:02:42.663" Score="1" Body="&lt;p&gt;If the phone has an accessible battery you could conceivably use the battery terminals to power a device such as Arduino. However, I think current smartphone batteries have complex monitoring circuits so this wont work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't, you'd be looking at using the USB/charger port on the phone.If your phone supports USB On-The-Go, I know that it allows phones to act as USB hosts, and according to USB-OTG specifications, the host must be able to supply at least 8mA of current between 4.4V and 5.25V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's enough for you it could work.&lt;/p&gt;&#xA;" OwnerUserId="10708" LastActivityDate="2015-06-18T00:02:42.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12729" PostTypeId="1" CreationDate="2015-06-18T00:34:56.720" Score="5" ViewCount="15521" Body="&lt;p&gt;I would like to connect my Arduino Uno to a telephone line in order to answer a call, record a sequence of &lt;a href=&quot;https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling&quot; rel=&quot;nofollow&quot;&gt;DTMF tones&lt;/a&gt;, generate a DTMF tone in response, and hang up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The telephone line uses a standard &lt;a href=&quot;https://en.wikipedia.org/wiki/Modular_connector#RJ11_wiring&quot; rel=&quot;nofollow&quot;&gt;RJ11 connector&lt;/a&gt;. When a &lt;a href=&quot;https://en.wikipedia.org/wiki/Push-button_telephone#Touch-Tone&quot; rel=&quot;nofollow&quot;&gt;touch-tone phone&lt;/a&gt; is connected to the line, it receives one of two rings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a standard ring, which signals an incoming call&lt;/li&gt;&#xA;&lt;li&gt;a shorter &quot;two-ring&quot; sequence which signals a call from a local intercom&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would like my Arduino to listen for the &quot;two-ring&quot; sequence and only answer those calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I go about connecting my Arduino to the telephone line? Is there a shield designed for this purpose? I know I can use the &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Tone&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;tone()&lt;/code&gt; function&lt;/a&gt; to generate the DTMF tones, but I'm assuming I would need to perform some form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Discrete_Fourier_transform&quot; rel=&quot;nofollow&quot;&gt;Discrete Fourier transformation&lt;/a&gt; in order to &quot;read&quot; the DMTF tones from the other end of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10709" LastEditorUserId="10709" LastEditDate="2015-06-18T01:42:54.117" LastActivityDate="2019-10-12T13:29:34.987" Title="Connecting an Arduino to a telephone line?" Tags="|arduino-uno|wires|audio|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12730" PostTypeId="2" ParentId="12729" CreationDate="2015-06-18T00:55:15.057" Score="1" Body="&lt;p&gt;You'll need some hardware assistance for the DTMF detection and generation; I doubt many Arduinos (you didn't say which, but maybe ARM?) have the horsepower to run an FFT (and deliver the results while anyone still cares....)* &lt;code&gt;tone()&lt;/code&gt;may not be precise enough in frequency for DTMF detection by the calling device; you'll have to check that out. A quick search finds a number of articles on building or buying tone detectors and generators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ringing pattern detection is a little easier but you'll still probably want to sense the ringing and convert it to a level in hardware, rather than tracking the instantaneous line voltage and trying to distinguish in software between noise, ringing, noisy ringing, and various degrees of quiet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;* But maybe &lt;a href=&quot;http://hackaday.com/2011/10/20/detecting-dtmf-tones-from-scratch/&quot; rel=&quot;nofollow&quot;&gt;this Hackaday project&lt;/a&gt; can give you some alternate and computationally feasible ideas.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="10709" LastEditDate="2015-06-18T12:01:09.540" LastActivityDate="2015-06-18T12:01:09.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12731" PostTypeId="2" ParentId="12729" CreationDate="2015-06-18T01:11:42.630" Score="7" Body="&lt;p&gt;You can interface arduino to telephone line using MT8870D chip. This IC can decode DTMF tones. Below is a reference schematic from the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PcIHu.png&quot; alt=&quot;Ref Design&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular design floating on the internet is below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8uwXd.gif&quot; alt=&quot;popular design&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are pre-build modules available from &lt;a href=&quot;http://www.futurlec.com/Mini_MT8870.shtml&quot; rel=&quot;noreferrer&quot;&gt;futurelec&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZGJcL.jpg&quot; alt=&quot;module&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use Holtek HT9200 IC to encode DTMF that can be interfaced with Arduino. Below is the reference schematic from its datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xhE7V.png&quot; alt=&quot;encoder&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="9962" LastActivityDate="2015-06-18T01:11:42.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12732" PostTypeId="1" AcceptedAnswerId="12935" CreationDate="2015-06-18T01:44:54.177" Score="1" ViewCount="1169" Body="&lt;p&gt;I have an old land line phone that I want to connect to my Arduino.  Then I would like to write a program that can decipher the touch-tone button presses (which are a combination of two tones) so that the Arduino can react to specific key presses and numeric sequences.  My final goal is to make the Arduino play specific messages when the user enters in codes.  I am really not sure even where to begin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the hardwares fixes for this problem, but if possible, I am looking for a softwares solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will be used to make a telephone (with an attached Arduino) that will play a series of conversations when specific codes are dialed.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-06-20T18:27:19.500" LastActivityDate="2015-06-27T01:33:17.830" Title="Can do I make an Arduino program that can decipher telephone touch tones?" Tags="|programming|arduino-mega|analogread|sound|analog-sampling|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12733" PostTypeId="1" CreationDate="2015-06-18T01:08:10.627" Score="0" ViewCount="4035" Body="&lt;p&gt;I am using a arduino nano to control a adafruit ultimate gps and a xbee wireless controller. However I recently ran into a problem using both at the same time (before I was using each separately until now) and read that I cannot listen to 2 software serials at the same time with a arduino. The biggest problem I see is that since I can only listen to one at a time, if I open a port, will cached data from the xbee and/or gps instantly start transferring in? Or or it more luck based that I will catch it as it comes? How should I go about coding around this? Should I just close and reopen the ports as needed(assuming there is no luck factor involved)? Any help is greatly appreciated. I will explain more if necessary. &lt;/p&gt;&#xA;" OwnerDisplayName="Joe Beck" LastActivityDate="2015-11-16T08:31:29.087" Title="Using Multiple Serial Ports with arduino nano" Tags="|serial|xbee|gps|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12734" PostTypeId="1" CreationDate="2015-06-18T01:53:36.027" Score="1" ViewCount="74" Body="&lt;p&gt;I have an Arduino which is being powered by a 9v, 2 amp power supply.  I have about 20 relays which are powered by 5 volts each.  I do not want to over work the voltage regulator on the board, so I would like to add another (possible 2) 5 volt regulator that I bought on amazon.  I am planning to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect the regulators VIN to the Arduino's vcc (9 volt)&lt;/li&gt;&#xA;&lt;li&gt;Connect the regulator's GND to the Arduino's GND.&lt;/li&gt;&#xA;&lt;li&gt;Connect the regulator's VOUT to the Relay's VCC&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this point, can I also connect the regulator's VOUT to the Arduino's 5volt out?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is it possible (or advisable) to add second voltage regulator to the first in a parallel configuration? &lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-06-18T02:37:36.350" Title="How can I add some additional 5 volt power" Tags="|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12735" PostTypeId="1" CreationDate="2015-06-18T01:56:13.653" Score="14" ViewCount="83499" Body="&lt;p&gt;I would like to play a wav file (spoken words) from my Arduino.  I do not want to add a sound shield.  Is there a way to play a sound through an output pin?  The quality does not have to be great.  &lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-06-20T18:29:40.640" LastActivityDate="2019-07-29T18:36:49.640" Title="Is there a way to play sounds from an Arduino without using a sound shield?" Tags="|analogwrite|digital|sound|digital-analog-conversion|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12736" PostTypeId="2" ParentId="12735" CreationDate="2015-06-18T02:19:06.913" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Code/PCMAudio&quot; rel=&quot;noreferrer&quot;&gt;PCMAudio&lt;/a&gt; example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the hardware.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-18T02:19:06.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12737" PostTypeId="2" ParentId="12732" CreationDate="2015-06-18T02:34:51.180" Score="3" Body="&lt;p&gt;It is possible to decode DTMF tones with only a few common external components. The trick is to turn the analog audio into a digital signal, and then check the timing between the leading and trailing edges in order to figure out which tone is present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, create a 1.1V bias using a voltage divider. This bias will connect to both a capacitor that is coupling the audio, as well as one of the analog inputs. &lt;strong&gt;Note that phone lines have high voltages on them at times, and you must have both isolation and voltage clamping in place before connecting a device to one.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, enable the analog comparator in the MCU. See the &quot;Analog Comparator&quot; section of the MCU datasheet for details. Configure the non-inverting input to connect to the internal bandgap reference, the inverting input to connect to the analog input chosen earlier, and the output to connect to the input capture facility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, configure the input capture facility in the MCU. See the &quot;16-bit Timer/Counter1 with PWM&quot; section of the datasheet, with particular emphasis on the &quot;Input Capture Unit&quot; subsection. Note that there is no way to trigger the input capture on &quot;any&quot; edge, therefore you will need to either flip the capture edge select bit each time, or you will need to detect the tone from only one set of edges. Also note that you will need to use the overflow interrupt to increment your explicit &quot;high bytes&quot; counter in case the edges to be detected appear on opposite sides of the overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that all that is done, all that remains is to compare the timing detected by the input capture with your internal table of timings and select the appropriate tone from that. But that's the easy part.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-18T02:34:51.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12738" PostTypeId="2" ParentId="12734" CreationDate="2015-06-18T02:37:36.350" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;At this point, can I also connect the regulator's VOUT to the Arduino's 5volt out?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Absolutely. But don't daisy-chain the regulator to each supply input in turn, connect each one separately directly from the regulator.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, is it possible (or advisable) to add second voltage regulator to the first in a parallel configuration? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is not advisable. Small manufacturing differences between regulators can result in them outputting slightly different voltages, which will lead to destruction of hardware.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-18T02:37:36.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12739" PostTypeId="2" ParentId="12735" CreationDate="2015-06-18T02:41:33.173" Score="3" Body="&lt;p&gt;Yes, you can - see &lt;a href=&quot;http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Space is quite limited, unless you use an SD card.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-18T02:41:33.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12740" PostTypeId="1" AcceptedAnswerId="12741" CreationDate="2015-06-18T03:12:01.027" Score="1" ViewCount="972" Body="&lt;p&gt;I've got an &lt;a href=&quot;https://store.3drobotics.com/products/arduimu-v3&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino V3+&lt;/a&gt; and need to find the correct PIN number for its RX and TX-pin on the FTDI-connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find out the correct number of them to use them with the SoftwareSerial-library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why I need these numbers:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm connecting a Sparkfun Bluetooth Mate/BlueSMIRF to the ArduiMUs FTDI headers and need to set a few settings in its command mode before it operates without flaws.&#xA;This is the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int bluetoothTx = ???;  // TX-O pin of bluetooth mate, Arduino D2&#xA;int bluetoothRx = ???;  // RX-I pin of bluetooth mate, Arduino D3&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);  // Begin the serial monitor at 9600bps&#xA;&#xA;  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps&#xA;  bluetooth.print(&quot;$$$&quot;);  // Enter command mode&#xA;  delay(5000);  // Short delay, wait for the Mate to send back CMD&#xA;  bluetooth.println(&quot;U,9600,N&quot;);  // Temporarily Change the baudrate to 9600, no parity&#xA;  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably&#xA;  bluetooth.begin(9600);  // Start bluetooth serial at 9600&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ySSNf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10636" LastEditorUserId="10636" LastEditDate="2015-06-18T10:56:51.247" LastActivityDate="2015-06-19T04:32:15.037" Title="Find number of RX and TX-pin on ArduiMu" Tags="|serial|programming|pins|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12741" PostTypeId="2" ParentId="12740" CreationDate="2015-06-18T03:40:27.133" Score="2" Body="&lt;p&gt;You can use FTDI cable with your board on the last row of pads as you have highlighted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately your board designers do not publish a pdf version of the schematic so I opened the provided schematics in EAGLE and exported the FTDI connector diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the FTDI connector connections from the schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8WX32.png&quot; alt=&quot;FTDI&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the pinout of the FTDI cable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rdsaD.png&quot; alt=&quot;FTDI Cable&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can solder a 6 pin header on the bottom row and use the standard FTDI cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FTDI row on your board indicates &quot;BLK&quot; on the left so orient your FTDI connector's black wire with the &quot;BLK&quot; pad on your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per your edits you are using hardware serial on your arduino board to monitor and you are using one instance of &quot;SoftwareSerial&quot; to interface with bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;SoftwareSerial&lt;/a&gt; library says, you can define any digital pins for Tx and Rx. In the example they have used Arduino pins 10 (pin 14 of the ATMEGA) and 11 (pin 15 of ATMEGA) for Rx and Tx respectively. In your non-standard arduino board, the micro-controller pin 14 is labeled as PWM1 and pin 15 is labeled as MOSI and they are brought out on connector JP7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fitkg.png&quot; alt=&quot;port&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in a nutshell you can use pin 4 of JP7 as SoftRx and pin 5 of JP7 as SoftTx.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If those pins are in use, you can always use other digital pins that are unused in your design. Just refer to the schematic of your board, ATMEGA328 datasheet and arduino libraries.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastEditorUserId="9962" LastEditDate="2015-06-19T04:32:15.037" LastActivityDate="2015-06-19T04:32:15.037" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12742" PostTypeId="1" CreationDate="2015-06-18T04:58:58.273" Score="2" ViewCount="76" Body="&lt;p&gt;I have replaced /www folder on the Yun (backing it up first), how do I make it so the Yun will redirect to the new index.html? It, right now, gives &lt;code&gt;Access to this resource is forbidden&lt;/code&gt; when I go to &lt;em&gt;yun-name-here&lt;/em&gt;.local&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I guess it's relevent to add I can do it fine with &lt;em&gt;yun-name-here&lt;/em&gt;.local/index.html meaning it works. The real question is how to make it so I don't need to type /index.html (HURRAY LAZINESS!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit II: It's &lt;a href=&quot;http://bloodrizer.ru/games/kittens/&quot; rel=&quot;nofollow&quot;&gt;Kittens game&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4664" LastEditorUserId="4664" LastEditDate="2015-06-18T07:28:39.633" LastActivityDate="2015-06-18T07:28:39.633" Title="How to make the Yun allow access to a resource" Tags="|arduino-yun|web-server|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="12745" PostTypeId="2" ParentId="12397" CreationDate="2015-06-18T06:20:50.803" Score="0" Body="&lt;pre&gt;&lt;code&gt;// fill in your Domain Name Server address here:&#xA;IPAddress myDns(192,168,1,1);&#xA;&#xA;// initialize the library instance:&#xA;EthernetClient client;&#xA;&#xA;char server[] = &quot;www.arduino.cc&quot;;&#xA;&#xA;unsigned long lastConnectionTime = 0;&#xA;// last time you connected to the server, in milliseconds&#xA;boolean lastConnected = false;&#xA;// state of the connection last time through the main loop&#xA;const unsigned long postingInterval = 14*1000;&#xA;// delay between updates, in milliseconds&#xA;&#xA;void setup() {&#xA;  pinMode (pin, OUTPUT);&#xA;  digitalWrite (pin, LOW);&#xA;&#xA;  // start serial port:&#xA;  Serial.begin(9600);&#xA;  // give the ethernet module time to boot up:&#xA;  delay(1000);&#xA;  // start the Ethernet connection using a fixed IP address and DNS server:&#xA;  Ethernet.begin(mac, ip, myDns);&#xA;  // print the Ethernet board/shield's IP address:&#xA;  Serial.print(&quot;My IP address: &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;  // if there's incoming data from the net connection.&#xA;  // send it out the serial port.  This is for debugging&#xA;  // purposes only:&#xA;  if (client.available()) {&#xA;    Serial.println (&quot;1&quot;); delay(500);&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;    } else {Serial.println (&quot;11&quot;);delay (500);}&#xA;  // if there's no net connection, but there was one last time&#xA;  // through the loop, then stop the client:&#xA;  if (!client.connected() &amp;amp;&amp;amp; lastConnected) {&#xA;    Serial.println(2); delay(500);&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;  } else {Serial.println (&quot;22&quot;);delay (500);}&#xA;&#xA;  // if you're not connected, and ten seconds have passed since&#xA;  // your last connection, then connect again and send data:&#xA;  if(!client.connected() &amp;amp;&amp;amp; (millis() - lastConnectionTime &amp;gt; postingInterval)) {&#xA;    Serial.println(3); delay(500);&#xA;    httpRequest();&#xA;    Serial.println (&quot;4&quot;);delay (100);&#xA;  } else {Serial.println (&quot;33&quot;);delay (500);}&#xA;  // store the state of the connection for next time through&#xA;  // the loop:&#xA;  lastConnected = client.connected();&#xA;  Serial.println (&quot;end loop&quot;);&#xA;}&#xA;&#xA;// this method makes a HTTP connection to the server:&#xA;void httpRequest() {&#xA;  // if there's a successful connection:&#xA;  Serial.println (&quot;httpRequest&quot;); delay(500);&#xA;  if (client.connect(server, 80)) {&#xA;     Serial.println (&quot;H1&quot;); delay(500);&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;    // send the HTTP PUT request:&#xA;    client.println(&quot;GET /latest.txt HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.arduino.cc&quot;);&#xA;    client.println(&quot;User-Agent: arduino-ethernet&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;&#xA;    // note the time that the connection was made:&#xA;    lastConnectionTime = millis();&#xA;  } else {&#xA;    Serial.println (&quot;H11&quot;); delay(500);&#xA;    // if you couldn't make a connection:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I inserted debug lines.  all I get are the faileure &quot;if&quot; comments.  after 15 seconds, I get debug #3 and then &quot;HTTP Request&quot; then nothing but crickets....&lt;/p&gt;&#xA;" OwnerUserId="10714" LastEditorUserId="4628" LastEditDate="2015-08-04T23:30:46.380" LastActivityDate="2015-08-04T23:30:46.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12746" PostTypeId="1" CreationDate="2015-06-18T08:32:35.607" Score="4" ViewCount="5282" Body="&lt;p&gt;At this moment I am using oversampling to increase my analogread resolution.&#xA;This in combination with increasing the frequency of the ADC.&#xA;Is someone able to take a look at it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define FASTADC 1&#xA;// defines for setting and clearing register bits&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;int value[100];   // variable to store the value coming from the sensor&#xA;int i=0;&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600) ;&#xA; int start ;&#xA; int i ;&#xA;&#xA;#if FASTADC&#xA; // set prescale to 16 (1MHz)&#xA; sbi(ADCSRA,ADPS2) ;&#xA; cbi(ADCSRA,ADPS1) ;&#xA; cbi(ADCSRA,ADPS0) ;&#xA;#endif&#xA;}&#xA;&#xA;void loop() &#xA;  { &#xA;  for (i=0;i&amp;lt;100;i++)&#xA;  {&#xA;   value[i]=Read12bit(0);&#xA;  } &#xA;  for (i=0;i&amp;lt;100;i++)&#xA;  {&#xA;   Serial.println(value[i]);&#xA;  } &#xA;  Serial.println();//Some blanks between values&#xA;  Serial.println();&#xA;  delay(5000);&#xA;&#xA;}&#xA;&#xA;&#xA;int Read12bit(uint8_t pin){&#xA;      int Result = 0;&#xA;      analogRead(pin);                      //Switch ADC&#xA;      for(int i = 0;i &amp;lt; 16; i++) {          //Read 16 times&#xA;        Result = Result + analogRead(pin);  //Sum results &#xA;      }&#xA;      Result = (int)Result/4;               //Divide by 4 for 12 bit value&#xA;      return(Result);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this moment the resolution of this oversampled analogread is 12-bits. With a little calculation the time to read will take 0,208milliseconds. If I want to increase my resolution more i.e. 13-bit. This will take the measurement 0,832 milliseconds. This seems rather big, so my question is can I do this in another way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT&#xA;&lt;strong&gt;Why?&lt;/strong&gt;&#xA;&lt;em&gt;I am trying to position multiple linear actuator using multiple arduino's connected via CAN-bus (the arduino's will not communicate with eachother unless an error occures) THe positioning has to be precise (&amp;lt;0.1mm on a 30 cm rod).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why is 12 or 13 bit accuracy and/or resolution needed?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;12 is probably enough. But I just like to find out the boundaries of the equipment :)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What real world processes are being monitored that 0.012% perbit step sizes are not swallowed in the noise of reality?&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably none 13-bit resolution is probably too high for my application anyways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other reason why I like a higher resolution&lt;/strong&gt;&#xA;First couple of voltages I cannot use. My sensor gives a 4 to 20mA signal which i convert with resistor to ground.&lt;/p&gt;&#xA;" OwnerUserId="10700" LastEditorUserId="10700" LastEditDate="2015-06-18T13:04:58.233" LastActivityDate="2017-05-04T16:21:55.570" Title="Increasing ADC resolution" Tags="|analogread|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12747" PostTypeId="2" ParentId="12733" CreationDate="2015-06-18T09:57:22.840" Score="0" Body="&lt;p&gt;You might be able to use the GPS's EN pin to enable and disable the communication to it, and also try to use the RTS/CTS pins of the XBee to control the flow, since that's their actual purpose there :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that helped.&lt;/p&gt;&#xA;" OwnerUserId="10718" LastActivityDate="2015-06-18T09:57:22.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12750" PostTypeId="2" ParentId="12703" CreationDate="2015-06-18T10:25:00.707" Score="0" Body="&lt;p&gt;You might also try the Firmata library, too.&#xA;It provides similar functionality, and there are some libs for the computer side of it, if you are so inclined.&lt;/p&gt;&#xA;" OwnerUserId="10718" LastActivityDate="2015-06-18T10:25:00.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12751" PostTypeId="2" ParentId="12746" CreationDate="2015-06-18T11:25:56.650" Score="4" Body="&lt;p&gt;Yes, you can use an external ADC chip. You can get SPI and I2C ΣΔ ADC chips at 16-bit and higher quite easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often use the &lt;a href=&quot;http://www.microchip.com/wwwproducts/Devices.aspx?product=MCP3553&quot; rel=&quot;nofollow&quot;&gt;MCP3553&lt;/a&gt; which allows 60sps at 22-bit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-18T11:25:56.650" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12752" PostTypeId="2" ParentId="12746" CreationDate="2015-06-18T12:08:17.120" Score="3" Body="&lt;p&gt;This is in response to the question.&lt;br&gt;&#xA;It is an answer to the extent that it says that &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The current method may not work (several reasons given), &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There may be better ways to do it, and &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it necessary?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Addressing these points, or knowing that they have been addressed, is an essential part of arriving at a good solution .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we knew the desired conversion time and actual desired resolution it would allow better answers.&lt;br&gt;&#xA;If we knew what you were trying to do it might help immensely.&lt;br&gt;&#xA;ie knowing what you are really trying to do may allow a quite different approach to be suggested or allow a fatal flaw to be identified. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from the statistical sampling considerations that you are addressing, you cannot usually extend ADC bits indefinitely by oversampling with any great  expectations of accuracy. Oversampling works on the basis of the variable + noise being linearly randomly distributed across the 'space' at least 1/2 a bit size either side of the true value. And it makes assumptions about ways in which ADC sample and hold and acquisition gating and more work.&lt;br&gt;&#xA;As you try to squeeze more bits out of the ADC the assumptions become less likely to be consistently valid. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, implementation of the analog input circuitry initially becomes important and then immensely important as bits of ADC resolution increase (whether achieved by over sampling or other means). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;12 bits  = 0.0244% per step (as you know)&lt;br&gt;&#xA;or 1.22 mV steps in a 5V reference system&lt;br&gt;&#xA;or 0.81 mV/bit in a 3.3V reference system.&lt;br&gt;&#xA;Getting your overall system working to that level of accuracy is possible but usually not achieved.&lt;br&gt;&#xA;Any reference you are using will be natively much less accurate than that and those sort of accuracies will require calibration both initially and possibly ongoingly.&lt;br&gt;&#xA;Ratiometric systems, where eg the excitation voltage of a bridge also serves as a reference, allow reference accuracy to notionally be perfect (as readings and excitation are the same and move together.&lt;br&gt;&#xA;However, ensuring that the voltage at the controllers Aref pin wrt controller Agnd, and the bridge's excitation pin wrt the bridge's ground input are the same  within usefully under 1.22 mV in a 5V 12 bit system (0.6 mV in a 13 bit system, and that the bridge and controller grounds are the same within say a few hundred uV, are an obvious necessity if the 13 bits of resolution are to be meaningful - but unlikely to be achieved without the most exquisite attention to both design &amp;amp; implementation. (Ask me how I know :-).)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, it will be much easier to obtain and maintain ADC resolutions of as many bits as are needed by the use of purpose designed conversion ICs operating as close to the signal source as is reasonably possible. (Or using instrumentation amplifiers to acquire the signals and reliably &quot;convey&quot; them elsewhere.) Knowing desired conversion times and resolutions is a necessary first step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;br&gt;&#xA;Why is 12 or 13 bit accuracy and/or resolution needed?&lt;br&gt;&#xA;What real world processes are being monitored that 0.012% perbit step sizes are not swallowed in the noise of reality?&lt;br&gt;&#xA;Such requirements - and much more accurate again, certainly do exist.&lt;br&gt;&#xA;But knowing what the actual application is may help with decisions of how to meet it. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-06-18T12:14:51.303" LastActivityDate="2015-06-18T12:14:51.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12753" PostTypeId="1" CreationDate="2015-06-18T12:21:20.743" Score="0" ViewCount="99" Body="&lt;p&gt;Sorry for bothering.&#xA;I have a problem with my project and I can't fine someone who can help me yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need the next configuration:&#xA;PC --------------USB cable-----------------MegaA---------------USB cable----------------MegaB&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need serial communication with USB cable in both boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have now solved the ( PC --------USB cable------MegaA) part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the other part, I have done PC------------------USB cable------------------MegaB&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I need do that like the first schematic.&#xA;I don't have access to the MegaB because this is inside a machine, I can't access to its pines, I need connect to it by USB Cable.&#xA;Is possible do that with ARDUINO MEGA ADK in the MEGA A position? or I need other kind of board or add one shield (like USB host)?&#xA;I need send one thing from the pc to MegaA and Mega A send the same thing to MegaB.&#xA;Is it possible? because I can't find some way to specify that I need recieve the information from one serial port, and send it to another different serial port. &#xA;I need help, is very important.&#xA;Excuse my english&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10756" OwnerDisplayName="Set " LastActivityDate="2015-06-20T19:03:26.250" Title="Arduino ADK, other board, shield or what?" Tags="|serial|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12754" PostTypeId="2" ParentId="12753" CreationDate="2015-06-18T12:32:21.923" Score="0" Body="&lt;p&gt;A USB host is far beyond what an AVR Mega handle. You could add a 'daugther' board of some kind, but that would be a computer far more powerfull than the Mega itself (think of a RaPi, or a fat 32-bit micro-controller), so it would be a bit weird.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might physically patch the first USB through to the second one, using for instance a relay. That would allow the PC (but not the first Mega) to talk to the second Mega.&lt;/p&gt;&#xA;" OwnerUserId="43104" OwnerDisplayName="Wouter van Ooijen" LastActivityDate="2015-06-18T12:32:21.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12755" PostTypeId="2" ParentId="12720" CreationDate="2015-06-18T16:18:04.597" Score="5" Body="&lt;p&gt;You seem to have two issues here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As already pointed out, you have the white wire connected to the wrong pin on the Arduino&lt;/li&gt;&#xA;&lt;li&gt;Also, &lt;strong&gt;you need to solder the headers on the Arduino.&lt;/strong&gt; There is no solder on the pins, which means that there is no connection. You need to solder those headers on; it looks like you just set the Arduino on top, which won't work with headers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-06-18T16:18:04.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12756" PostTypeId="2" ParentId="12735" CreationDate="2015-06-18T18:05:48.397" Score="8" Body="&lt;p&gt;I helped someone with a similar question. The results are in my github repo at &lt;a href=&quot;https://github.com/linhartr22/count&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/linhartr22/count&lt;/a&gt;. This example uses the PWM library and includes a reference to the article I used to learn how to convert audio files to MP3 with proper settings for the PWM libary. It plays audio through an 8 ohm speaker or a piezo buzzer connected directly to the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastEditorUserId="7297" LastEditDate="2018-07-27T01:07:10.093" LastActivityDate="2018-07-27T01:07:10.093" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12758" PostTypeId="2" ParentId="12733" CreationDate="2015-06-18T21:36:08.397" Score="0" Body="&lt;p&gt;The Mega and the Due have 4 UARTs. It seems like those should work, but they are much larger. I'm embarking on a project that needs to be small and use two serial ports. I'm looking at the Teensy, which has three UARTs.&lt;/p&gt;&#xA;" OwnerUserId="10728" LastActivityDate="2015-06-18T21:36:08.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12759" PostTypeId="2" ParentId="12753" CreationDate="2015-06-18T21:56:11.547" Score="0" Body="&lt;p&gt;You don't actually need to use serial-over-usb, the two devices can communicate more simply. The simplest way would be to Serial1, which uses pins D18 and D19; connect Serial1 on MegaA to either the serial or serial1 on MegaB. Since MegaA's transmit is MegaB's receive, you need to cross-over the wires (i.e. connect MegaA's TX to MegaB RX and vice versa).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Complete details can be found at: &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/MultiSerialMega&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/MultiSerialMega&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the two Megas have a common ground - the easiest way is to use one power supply (in your case, the USB) - you should just be able to wire GND and +5V from one board to the same pins on the other. If you use two different power supplies (e.g. two USB ports, even on the same PC), they may have different ground levels, and you can get a current flow directly out of one ground, and in to the other, damaging your PC.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-18T21:56:11.547" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12760" PostTypeId="2" ParentId="12753" CreationDate="2015-06-19T00:16:02.573" Score="1" Body="&lt;p&gt;You would need a USB host shield to achieve what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino by itself is not capable of connecting to both a PC and another Arduino through USB without the addition of extra hardware.  In this case the USB Host Shield as detailed on the Arduino website:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoUSBHostShield&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoUSBHostShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the list of supported devices is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB to serial converters: FTDI, PL-2303, ACM, as well as certain cell phones and GPS receivers. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The magic word there is ACM - that (or more specifically CDC/ACM) is what the Arduino USB Serial interface is.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-19T00:16:02.573" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12761" PostTypeId="1" CreationDate="2015-06-19T00:37:02.897" Score="2" ViewCount="101" Body="&lt;p&gt;I just downloaded the latest version of the Arduino software (1.6.5). However, when I look into the Application Support folder under Library (I have a mac), I find that I have a folder named 1.6.3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Library ▸ Arduino15 ▸ packages ▸ arduino ▸ hardware ▸ sam ▸ 1.6.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this mean there is a hidden 1.6.5 folder that I am not seeing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, this issue surfaced, because I am trying to fiddle around with the ADC clock speed, but it seems that nothing is happening: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  #define ADC_FREQ_MAX = 1;&#xA;  Serial.begin(9600);&#xA;  Serial.println(ADC_FREQ_MAX);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opamp.ino: In function 'void setup()':&#xA;opamp:2: error: expected primary-expression before '=' token&#xA;opamp.ino:4:18: note: in expansion of macro 'ADC_FREQ_MAX'&#xA;opamp:4: error: expected primary-expression before ')' token&#xA;opamp:4: error: expected ';' before ')' token&#xA;expected primary-expression before '=' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10705" LastEditorUserId="10705" LastEditDate="2015-06-19T01:04:07.647" LastActivityDate="2017-07-07T00:27:13.880" Title="I am running 1.6.5, but the folder says 1.6.3?" Tags="|arduino-ide|arduino-due|" AnswerCount="2" CommentCount="5" ClosedDate="2017-07-07T09:01:23.763" ContentLicense="CC BY-SA 3.0" />
  <row Id="12762" PostTypeId="2" ParentId="8911" CreationDate="2015-06-19T03:43:14.817" Score="1" Body="&lt;p&gt;There is a very good write-up on how to save power, use sleep mode etc, at: &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This includes step-by-step examples of what was done to save power, and how much power was saved, including examples on how to go to sleep and wake back up.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-19T03:43:14.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12763" PostTypeId="1" AcceptedAnswerId="12767" CreationDate="2015-06-19T03:51:32.840" Score="3" ViewCount="1015" Body="&lt;p&gt;I have a simple code, part of which contains the calculation 800/1000, which seems to return a value of zero for some reason (even though I store it in a float variable). When I replace the calculation with the expected result (0.8) the code works as expected, I just wonder why the calculation doesn't produce the same result. &lt;/p&gt;&#xA;" OwnerUserId="10735" LastActivityDate="2015-06-19T09:47:24.407" Title="Weird Arduino math result" Tags="|programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12764" PostTypeId="2" ParentId="12763" CreationDate="2015-06-19T04:39:32.490" Score="6" Body="&lt;p&gt;A whole numbers like 800 or 1000 are integers, while a number like 800.4 is considered fractional and is treated as a float. Two integers divided gives an whole integer result, in your case 0. If one number in the division is an integer, and one is a float, the result is a float.&lt;/p&gt;&#xA;" OwnerUserId="10736" LastActivityDate="2015-06-19T04:39:32.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12765" PostTypeId="2" ParentId="12733" CreationDate="2015-06-19T05:41:51.690" Score="2" Body="&lt;p&gt;You can use &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; library in order to instantiate a second (soft) serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By looking at the &lt;a href=&quot;http://www.arduino.cc/en/Reference/SoftwareSerial#Example&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;, it seems that you can use any two digital pins to use SoftwareSerial library and instantiate a second serial port along with the hardware serial port.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastActivityDate="2015-06-19T05:41:51.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12766" PostTypeId="1" CreationDate="2015-06-19T08:20:22.520" Score="1" ViewCount="491" Body="&lt;p&gt;I have an mpx12DP pressure sensor that I want to use to measure the depth of water in a 1m tall water tank.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it only measures up to 55mV of voltage change, which the arduino can't really detect changes in. (The sensor measures 0 to 1.45psi- 1m of water should give me 1.4psi, so I should be able to get really good accuracy).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this as good sensor to use for this purpose? How do I amplify the signal from the sensor? I have tried an LM324 op-amp, but couldn't get it to work (this may be entirely the wrong thing to use! And I was utterly unsure of the kind of circuit to use it in). Any advice on parts.. schematics.. a suitable already-amplified sensor that reads only up to 1.45psi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressure sensor datasheet: &lt;a href=&quot;http://www.digikey.co.uk/product-detail/en/MPX12DP/MPX12DP-ND/684659&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.co.uk/product-detail/en/MPX12DP/MPX12DP-ND/684659&lt;/a&gt;&#xA;Op amp datasheet: &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm124-n.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/lit/ds/symlink/lm124-n.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10738" LastActivityDate="2015-06-19T20:53:49.633" Title="Reading tiny voltage changes" Tags="|arduino-uno|sensors|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12767" PostTypeId="2" ParentId="12763" CreationDate="2015-06-19T09:47:24.407" Score="3" Body="&lt;p&gt;Both 800.0/1000 or ((float)800)/1000 will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The former works only with hardcoded constants, while the latter works also with variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a = 800;&#xA;int b = 1000;&#xA;float c = ((float)a) / b;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-19T09:47:24.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12768" PostTypeId="2" ParentId="12766" CreationDate="2015-06-19T12:30:53.543" Score="3" Body="&lt;p&gt;You could try using &lt;code&gt;analogReference(INTERNAL);&lt;/code&gt;, to reduce the upper range of the ADC to 1.1volts, thus giving you better voltage resolution.&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-06-19T12:30:53.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12769" PostTypeId="2" ParentId="9758" CreationDate="2015-06-19T13:02:25.243" Score="1" Body="&lt;p&gt;See the following article:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoBoardNano&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the section at the bottom called:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Automatic (Software) Reset&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, one has to delay for 1 second (at least) after initializing the serial port before you can read data.  It seems that the Arduino makes an assumption that after the serial port is initialized, what may happen next is a request to load a program.  As such, it looks for a period of time (I guess up to a second) for a string of magic characters that indicate a program load.  If it doesn't find those, then it starts to behave as you would expect ... but only after it times out looking for a program load.&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-19T13:02:25.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12770" PostTypeId="1" AcceptedAnswerId="12774" CreationDate="2015-06-19T13:17:12.420" Score="2" ViewCount="2077" Body="&lt;p&gt;I need your suggestions and help with my Ping Sensor.&#xA;I have an Arduino Uno with a Parallax Ping sensor and a motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ping sensor is set to to start the motor when the nearest object is &amp;lt;= 10cm. That works fine.&#xA;Now, I'd like the motor to start only if the values of the sensor are progressing in a decreasing manner i.e 15, 14, 13, 12, 11, 10 but do nothing if the values are progressing in a increasing manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking if I stored the last 3 pings as variables and using an if/else statement but I don't know how to implement it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I implement this, or if you have any other suggestion, please help me.&#xA;Thank you&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what i have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Ping))) Sensor&#xA;&#xA;   This sketch reads a PING))) ultrasonic rangefinder and returns the&#xA;   distance to the closest object in range. To do this, it sends a pulse&#xA;   to the sensor to initiate a reading, then listens for a pulse&#xA;   to return.  The length of the returning pulse is proportional to&#xA;   the distance of the object from the sensor.&#xA;&#xA;   The circuit:&#xA;    * +V connection of the PING))) attached to +5V&#xA;    * GND connection of the PING))) attached to ground&#xA;    * SIG connection of the PING))) attached to digital pin 7&#xA;&#xA;   http://www.arduino.cc/en/Tutorial/Ping&#xA;&#xA;   created 3 Nov 2008&#xA;   by David A. Mellis&#xA;   modified 30 Aug 2011&#xA;   by Tom Igoe&#xA;&#xA;   This example code is in the public domain.&#xA;&#xA; */&#xA;&#xA;// this constant won't change.  It's the pin number&#xA;// of the sensor's output:&#xA;const int pingPin = 7;&#xA;const int motorPin = 9;&#xA;//Yomis code&#xA;//int pings[3] = {-1,-1,-1};&#xA;//int i;&#xA;//bool Increasing(int p1, int p2, int p3)&#xA;//{&#xA;//  if(p1 &amp;lt; p2 &amp;amp;&amp;amp; p2 &amp;lt; p3){&#xA;//    return true;&#xA;//  }&#xA;//}&#xA;//&#xA;//bool Decreasing(int p1, int p2, int p3)&#xA;//{&#xA;//  if(p1 &amp;gt; p2 &amp;amp;&amp;amp; p2 &amp;gt; p3){&#xA;//    return true;&#xA;//  }&#xA;//}&#xA;//&#xA;//end of yomis code&#xA;void setup() {&#xA;  // Set up the motor pin to be an output:&#xA;&#xA;  pinMode(motorPin, OUTPUT);&#xA;&#xA;  // initialize serial communication:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  // establish variables for duration of the ping,&#xA;  // and the distance result in inches and centimeters:&#xA;  long duration, inches, cm;&#xA;&#xA;  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.&#xA;  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&#xA;  pinMode(pingPin, OUTPUT);&#xA;  digitalWrite(pingPin, LOW);&#xA;  delayMicroseconds(1000);&#xA;  digitalWrite(pingPin, HIGH);&#xA;  delayMicroseconds(2000);&#xA;  digitalWrite(pingPin, LOW);&#xA;&#xA;  // The same pin is used to read the signal from the PING))): a HIGH&#xA;  // pulse whose duration is the time (in microseconds) from the sending&#xA;  // of the ping to the reception of its echo off of an object.&#xA;  pinMode(pingPin, INPUT);&#xA;  duration = pulseIn(pingPin, HIGH);&#xA;&#xA;  // convert the time into a distance&#xA;  inches = microsecondsToInches(duration);&#xA;  cm = microsecondsToCentimeters(duration);&#xA;&#xA;  Serial.print(inches);&#xA;  Serial.print(&quot;in, &quot;);&#xA;  Serial.print(cm);&#xA;  Serial.print(&quot;cm&quot;);&#xA;  Serial.println();&#xA;&#xA;  delay(1000);&#xA;&#xA;//        //Yomis code       &#xA;//        if (cm &amp;lt;= 10)&#xA;//        {&#xA;//          Serial.println();&#xA;//          Serial.println(pings[0]);&#xA;//              Serial.println(pings[1]);&#xA;//              Serial.println(pings[2]);&#xA;//          Serial.println();&#xA;//          if(Increasing(pings[0],pings[1],pings[2]))&#xA;//          {&#xA;//            int Speed1 = 100;  // between 0 (stopped) and 255 (full speed)&#xA;//            int Time1 = 3000;  // milliseconds for speed 1    &#xA;//            analogWrite(motorPin, Speed1);  // turns the motor On&#xA;//          }    &#xA;//        }&#xA;//        else&#xA;//        {&#xA;//          analogWrite(motorPin, LOW);&#xA;//        }&#xA;//      &#xA;//        //End of yomis code&#xA;&#xA;  if (cm &amp;lt;= 10) {&#xA;&#xA;    int Speed1 = 150;  // between 0 (stopped) and 255 (full speed)&#xA;    int Time1 = 2000;  // milliseconds for speed 1&#xA;&#xA;    int Speed2 = 250;   // between 0 (stopped) and 255 (full speed)&#xA;    int Time2 = 3000;  // milliseconds to turn the motor off&#xA;&#xA;    analogWrite(motorPin, Speed1);  // turns the motor On&#xA;    delay(Time1);                   // delay for onTime milliseconds&#xA;//    analogWrite(motorPin, Speed2);  // turns the motor Off&#xA;//    delay(Time2);                   // delay for offTime milliseconds&#xA;  }&#xA;  else if (cm &amp;gt; 10) {&#xA;    analogWrite(motorPin, LOW);  // turn the motor off&#xA;  }&#xA;  else {&#xA;    Serial.print(inches);&#xA;    Serial.print(&quot;in, &quot;);&#xA;    Serial.print(cm);&#xA;    Serial.print(&quot;cm&quot;);&#xA;    Serial.println();&#xA;&#xA;    delay(100);&#xA;  }&#xA;&#xA;}&#xA;&#xA;long microsecondsToInches(long microseconds)&#xA;{&#xA;  // According to Parallax's datasheet for the PING))), there are&#xA;  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per&#xA;  // second).  This gives the distance travelled by the ping, outbound&#xA;  // and return, so we divide by 2 to get the distance of the obstacle.m&#xA;  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf&#xA;  return microseconds / 74 / 2;&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;  // The speed of sound is 340 m/s or 29 microseconds per centimeter.&#xA;  // The ping travels out and back, so to find the distance of the&#xA;  // object we take half of the distance travelled.&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10741" LastActivityDate="2017-03-21T14:32:37.563" Title="How to Store the results from a Ping Sensor in a variable" Tags="|arduino-uno|sensors|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12771" PostTypeId="1" AcceptedAnswerId="12772" CreationDate="2015-06-19T13:50:06.430" Score="2" ViewCount="956" Body="&lt;p&gt;Can you use the internal pull-up on an ADC pin? Is it correct usage? Example of hardware usage would be a cadmium photocell between &lt;em&gt;Ax&lt;/em&gt; and &lt;em&gt;GND&lt;/em&gt;. Software is the same, except declaring &lt;em&gt;Ax&lt;/em&gt; as INPUT_PULLUP instead of INPUT.&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-06-19T14:03:18.067" Title="Analog INPUT_PULLUP for resistive sensors?" Tags="|analogread|photoresistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12772" PostTypeId="2" ParentId="12771" CreationDate="2015-06-19T14:03:18.067" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you use the internal pull-up on an ADC pin?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it correct usage?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. The exact pullup resistance varies from pin to pin and chip to chip, so depending on it for the high side is problematic at best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally you should be disabling the digital circuitry on an analog input entirely by writing to the &lt;code&gt;DIDR0&lt;/code&gt; and &lt;code&gt;DIDR1&lt;/code&gt; registers appropriately.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-19T14:03:18.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12774" PostTypeId="2" ParentId="12770" CreationDate="2015-06-19T14:50:06.333" Score="0" Body="&lt;p&gt;The general idea of your code is fine, but it can be tweaked to make it more efficient.&lt;/p&gt;&#xA;&lt;p&gt;Firstly, your function &lt;code&gt;increasing(int p1, int p2, int p3)&lt;/code&gt; can be simplified to &lt;code&gt;increasing(int *pingArray)&lt;/code&gt;. This way you pass a &lt;em&gt;reference&lt;/em&gt; to the function, rather than three &lt;code&gt;int&lt;/code&gt;s. If you decide later that your &lt;code&gt;pings&lt;/code&gt; array needs to hold more values you don't have to change the function arguements. However, if you're going to be experimenting with different lengths of the &lt;code&gt;ping&lt;/code&gt; array you need to make sure you change the code &lt;em&gt;within the function&lt;/em&gt; to reflect this. An easy way to stay on top of it is with &lt;code&gt;#define&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_PINGS 3       // Put this at the start of your code somewhere&#xA;&#xA;int pings[MAX_PINGS];     // When you come to declare 'pings'&#xA;for (int x=0; x&amp;lt;MAX_PINGS; x++)&#xA;    pings[x] = -1;        // Whatever each element is initialised to.&#xA;&#xA;&#xA;// Your 'increasing' function&#xA;//   (... and the same for 'decreasing', if you decide to use it!)&#xA;bool increasing(int *pingArray)&#xA;{&#xA;    // CODE GOES HERE&#xA;    // and it doesn't matter how long pingArray / pings is&#xA;    // because you have 'MAX_PINGS' defined.&#xA;    return true;&#xA;}&#xA;&#xA;// You call the 'increasing' function as you'd expect:&#xA;if (increasing(pings))&#xA;{ /* stuff */ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now to the concentrating:&lt;/p&gt;&#xA;&lt;p&gt;Your initial work is good but from what I've read on ultrasonic sensors, and from experience with any generic sensor, is that the readings aren't going to be perfect. The real world is a noisy place and you aren't going to get nice, accurate distance readings. Finding the average is a simple technique, but you will need to find an optimal solution yourself. Once you have your nice row of average values you can then determine if the distance is increasing or decreasing or neither.&lt;/p&gt;&#xA;&lt;p&gt;Thus you have two steps:&lt;/p&gt;&#xA;&lt;h1&gt;Average the distance&lt;/h1&gt;&#xA;&lt;p&gt;Create an array (&lt;code&gt;dist&lt;/code&gt;, for now) and use it to find the average distance your sensor is from an object.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_DIST 5&#xA;&#xA;int dist[MAX_DIST];    // create an array, no need to initialise.&#xA;double distAverage;    // average distance, could be 'int' instead.&#xA;int distIterator = 0;  // 'dist' will be a CYCLIC BUFFER. woooOOOOooo.&#xA;&#xA;// As you get the distance from your sensor, update 'dist' and&#xA;// then calculate the running average.&#xA;&#xA;dist[distIterator] = microsecondsToCentimeters(duration);&#xA;distIterator++;&#xA;if (distIterator == MAX_DIST) distIterator = 0;&#xA;distAverage = 0.0;&#xA;for (int x=0; x&amp;lt;MAX_DIST; x++)&#xA;    distAverage += dist[x];&#xA;distAverage /= MAX_DIST;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope you understand the cyclic buffer principle - if you don't you can google it! A key point about the way the code above is constructed is the use of that &lt;code&gt;#define MAX_DIST 5&lt;/code&gt;. You can change that single number to anything and your code will change along with it. You will discover that there is an optimum number; I can't tell you what it is (but I recommend it remains odd).&lt;/p&gt;&#xA;&lt;p&gt;Now that you have a nice &lt;em&gt;reliable&lt;/em&gt; distance measurement, you need to find if it is increasing or decreasing...&lt;/p&gt;&#xA;&lt;h1&gt;Average the averages&lt;/h1&gt;&#xA;&lt;p&gt;As you have worked out, you need an array of values to determine if the distance is increasing. Bring in, again, the cyclic buffer.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_DIST 5     // these could also be 'const int's&#xA;#define MAX_AVRG 3     // but my preference is this way&#xA;&#xA;int dist[MAX_DIST];    // create an array, no need to initialise.&#xA;int distIterator = 0;  // 'dist' will be a CYCLIC BUFFER. woooOOOOooo.&#xA;int distAvrg[MAX_DIST]; // create an array of averages.&#xA;int avrgIterator = 0;  // wwwwoooOOOOooo ? Not this time.&#xA;&#xA;// There's no single 'distAverage' anymore; the result dumps straight&#xA;//into 'distAvrg[avrgIterator]'...&#xA;&#xA;dist[distIterator] = microsecondsToCentimeters(duration);&#xA;distIterator++;&#xA;if (distIterator == MAX_DIST) distIterator = 0;&#xA;distAvrg[avrgIterator] = 0.0;&#xA;for (int x=0; x&amp;lt;MAX_DIST; x++)&#xA;    distAvrg[avrgIterator] += dist[x];&#xA;distAvrg[avrgIterator] /= MAX_DIST;&#xA;avrgIterator++;&#xA;if (avrgIterator == MAX_AVRG) avrgIterator = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now you have an array of your averages. Winner.&lt;/p&gt;&#xA;&lt;p&gt;From here you can create your &lt;code&gt;increasing&lt;/code&gt;/&lt;code&gt;decreasing&lt;/code&gt; function. I'll leave most of this up to you, but consider the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The contents of &lt;code&gt;distAvrg&lt;/code&gt; may not be perfectly smooth;&lt;/li&gt;&#xA;&lt;li&gt;The longer any of the arrays, the more reliable the average;&lt;/li&gt;&#xA;&lt;li&gt;The longer the array, the slower the response of the 'machine';&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;int&lt;/code&gt; rather than &lt;code&gt;double&lt;/code&gt; for &lt;code&gt;distAvrg&lt;/code&gt; may help 'numb' some of the fluctuations in averages;&lt;/li&gt;&#xA;&lt;li&gt;Because &lt;code&gt;distAvrg&lt;/code&gt; is a cyclic buffer, when analysing it &lt;em&gt;make sure you start at the correct element!&lt;/em&gt; &lt;strong&gt;HINT:&lt;/strong&gt; If you add your increase/decrease function &lt;em&gt;after&lt;/em&gt; all the code above rather than amongst it, &lt;code&gt;avrgIterator&lt;/code&gt; will always point to the &lt;em&gt;oldest&lt;/em&gt; average value;&lt;/li&gt;&#xA;&lt;li&gt;If the &lt;code&gt;distAverage&lt;/code&gt; array gets beyond three of four elements, you should definitely &lt;em&gt;pass it by reference&lt;/em&gt; to the relevant functions; this is what I did in the first codeblock I wrote. It's beyond this answer to explain why you should do it other than &amp;quot;it's more efficient&amp;quot;. This is a general rule for any large chunk of data, but you'll learn more as you go along.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The simplest algorithm for determining whether the &lt;code&gt;distAvrg&lt;/code&gt;s are increasing or decreasing is to run through from oldest to newest and count how many &lt;em&gt;increases&lt;/em&gt; there are and how many &lt;em&gt;decreases&lt;/em&gt; there are:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int direction = 0;&#xA;for (x=oldest ... x=newest)&#xA;{&#xA;    if (x &amp;gt; x+1) direction++;&#xA;    if (x &amp;lt; x+1) direction--;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above is pseudo-code - you'll have translate it yourself. You end up with a value of &lt;code&gt;direction&lt;/code&gt; that is a positive number (increase), a negative number (decrease), or zero. The actual value of &lt;code&gt;direction&lt;/code&gt; will help you determine the speed of the increase/decrease, if it's relevant.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h1&gt;A possible solution:&lt;/h1&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;** EDIT ** As pointed out by @EdgarBonet, &lt;code&gt;double&lt;/code&gt; and &lt;code&gt;float&lt;/code&gt; are 'expensive', in that they take up a lot of computing cycles to be dealt with. The Arduino website recommends avoiding them if you can. The alternative is to use scaled &lt;code&gt;int&lt;/code&gt;s. For example, multiplying the return value from &lt;code&gt;microsecondsToCentimetres()&lt;/code&gt; by 10 will give you the equivalent of one decimal place's worth of extra precision. No other code needs to change unless you're outputing the value on an LCD or similar and want it in centimeters. Dividing by 10 is conveniently the distance in millimeters, which is why I picked it, but there's no reason you can't scale by a different factor. Just be aware that there is a maximum (and mirrored minimum) value that &lt;code&gt;int&lt;/code&gt; can hold, but I doubt you're going to hit it unless you scale by an unnecessarily high factor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Let's say &lt;code&gt;MAX_AVRG&lt;/code&gt; is &lt;code&gt;6&lt;/code&gt;. This gives five &lt;em&gt;changes&lt;/em&gt; between distances to look at. The simplest function for determining an increase is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bool increasing(int * DIST)&#xA;{&#xA;    int dir = 0;&#xA;&#xA;    for (int x=1; x&amp;lt;MAX_AVRG; x++)&#xA;    {&#xA;        if (DIST[x] &amp;gt; DIST[x-1])   // change this to &amp;lt; for DECREASE&#xA;            dir++;&#xA;        else&#xA;            dir--;&#xA;    }&#xA;&#xA;    if (dir &amp;gt; 0)&#xA;        return TRUE;&#xA;    else&#xA;        return FALSE;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The 'decrease' version is identical, save for the single commented line. The &lt;code&gt;for&lt;/code&gt; loop starts at the &lt;em&gt;second&lt;/em&gt; sample and checks against the &lt;em&gt;previous&lt;/em&gt; sample, which is why &lt;code&gt;x&lt;/code&gt; starts at 1, not 0 as 'usual'. The return value will be &lt;code&gt;true&lt;/code&gt; if &lt;code&gt;distAv&lt;/code&gt; has increased more times than it has decreased, and vice versa for decreasing().&lt;/p&gt;&#xA;&lt;p&gt;Let's say distAve = { 1, 2, 1, 3, 4, 5 }. In the function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;distAve   1   2   1   3   4   5&#xA;            ^   ^   ^   ^   ^&#xA;start       |   |   |   |   |    dir = 0&#xA;increase   -'   |   |   |   |    dir = 1&#xA;decrease       -'   |   |   |    dir = 0&#xA;increase           -'   |   |    dir = 1&#xA;increase               -'   |    dir = 2&#xA;increase                   -'    dir = 3&#xA;&#xA;dir &amp;gt; 0 therefore INCREASE.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But what if distAve = { 5, 4, 3, 2, 1, 6 } ? If &lt;code&gt;increasing()&lt;/code&gt; will now return &lt;code&gt;false&lt;/code&gt; because there are four decreases vs one increase, except the final distance indicates that the sensed object has ended up at an increased distance than when it started.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int distance(int * DIST)&#xA;{&#xA;    int overallDistance = 0;&#xA;    for (int x=1; x&amp;lt;MAX_AVRG; x++)&#xA;        overallDistance += (DIST[x] - DIST[x-1]);&#xA;    return overallDistance;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now you have an explicit value for the overall distance change.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-23T16:27:00.340" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12775" PostTypeId="1" AcceptedAnswerId="12790" CreationDate="2015-06-19T15:03:22.210" Score="0" ViewCount="637" Body="&lt;p&gt;I am trying to convert a RC car into autonomous car using Arduino Pro Mini 5v 16 Mhz. I have done this with UNO and Adafruit motor shield 1.0 with 4 gear motors and one micro servo for mounting range finder sensor. That worked fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need to mention here that originally the RC car was using 5 AA cells for 2 motors and its RC reciever which looks like a customized motor shield as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to move everything to Arduino Pro Mini 5v, and motor shield v1 to reduce space. Now how I wired everything.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Uses 8 AA cells to power the motor shield on EXT-PWR input.&lt;/li&gt;&#xA;&lt;li&gt;From EXT-PWR in motor shield one wire goes to RAW in Pro mini.&lt;/li&gt;&#xA;&lt;li&gt;From Pro Mini, VCC connected to +5v on motor shield.&lt;/li&gt;&#xA;&lt;li&gt;One micro servo having range sensor getting its current from motor shield.&lt;/li&gt;&#xA;&lt;li&gt;Motor shield has to run two motors, 1 for rear wheels and 1 for turning front wheels. (they are small motors look like 3v)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now when I turn on the power the motor sometimes run and sometimes sound like bee and no movement. That also cause the L293d chip on motor shield becomes very hot and I think I have burnt one yesterday and replaced it from another motor shield. Same for servo it sometimes move or not move but sounds like hmmmmmmmm. The Arduino power light on and red. But sometimes it flickers and other light is also on and off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I have no idea whats wrong here. I changed the input voltage to lower but no progress. Tried to disconnect the 5v input from Pro Mini to motor shield and give 9v input to motor shield but nothing works. Please suggest best or correct power distribution in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Qazi&lt;/p&gt;&#xA;" OwnerUserId="7235" LastEditorUserId="7235" LastEditDate="2015-06-19T15:10:34.153" LastActivityDate="2015-08-11T20:55:36.097" Title="Pro Mini 5v with Adafruit motor shield v1 power sharing problems" Tags="|power|arduino-pro-mini|arduino-motor-shield|adafruit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12776" PostTypeId="1" CreationDate="2015-06-19T16:55:38.963" Score="0" ViewCount="66" Body="&lt;p&gt;I need to put out 5 volts from an Arduino UNO digital pin. I've read that the pins can do approx. 5 volts, but I need to know if it will actually reach 5. I'm also powering a few other devices from the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the digital pins capable of emitting 5 volts consistently? Are there any better alternatives? &#xA;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="10235" LastEditorUserId="10235" LastEditDate="2015-06-19T17:14:22.160" LastActivityDate="2015-06-19T17:14:22.160" Title="Programmed 5 Volt output to power a relay" Tags="|voltage-level|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12777" PostTypeId="2" ParentId="12776" CreationDate="2015-06-19T17:10:27.600" Score="1" Body="&lt;p&gt;Your concern for the output capability of the pin should be its current sourcing or sinking capability, not its voltage. Arduino pins typically have a limit of 40ma per pin and a total maximum of 200ma. This is for the Atmega328p (you didn't say which Arduino you're using. You'll need to drive motors or relays or anything else with a substantial current requirement with a driver circuit powered independently of the Arduino itself. That can be with a shield made for the purpose or a circuit you design and build into your project. Motors and relays in particular need snubber diodes to protect the driving circuits from inductive &quot;kickback&quot; or spikes generated in their coils.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-19T17:10:27.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12779" PostTypeId="1" CreationDate="2015-06-19T18:56:14.923" Score="1" ViewCount="855" Body="&lt;p&gt;I would like to convert an array of bytes, received from serial, to a float.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's consider this exemple. I'm sending 0.12 byte-wise from an Android application. The conversion from float to array of bytes in the Android side is handled by this function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public static byte [] float2Bytes(float value)&#xA;    {&#xA;        return ByteBuffer.allocate(4)./*order(ByteOrder.LITTLE_ENDIAN).*/putFloat(value).array();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When bytes arrive, they are stored in an array and the assembled.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hiBytew1 = bufferBytes[9];&#xA;//Serial.println(hiBytew1);&#xA;loBytew1 = bufferBytes[10];&#xA;//Serial.println(loBytew1);&#xA;hiBytew2 = bufferBytes[11];&#xA;//Serial.println(hiBytew2);&#xA;loBytew2 = bufferBytes[12];&#xA;//Serial.println(loBytew2);&#xA;float conAck = assemble(hiBytew1, loBytew1, hiBytew2,loBytew2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I achieve this kind of conversion assuming that bytes are received in the correct order?&lt;/p&gt;&#xA;" OwnerUserId="4396" LastActivityDate="2015-06-19T19:01:19.587" Title="Assembling a float from an array of bytes" Tags="|serial|arduino-mega|float|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12780" PostTypeId="2" ParentId="12779" CreationDate="2015-06-19T18:59:01.970" Score="3" Body="&lt;p&gt;Just cast the pointer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float conAck = *((float*)(bufferBytes + 9));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-06-19T19:01:19.587" LastActivityDate="2015-06-19T19:01:19.587" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12781" PostTypeId="2" ParentId="6456" CreationDate="2015-06-19T19:00:13.340" Score="0" Body="&lt;p&gt;1) Since these are all one-way communication, disable AutoAck on all NRFs (setAutoAck(false)). You're not doing Ack anyway which will cause retransmission when not acknowledged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Change the address to something better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Addresses where the level shifts only one time (that is, 000FFFFFFF) can often be detected in noise and can give a false detection, which may give a raised Packet Error Rate. Addresses as a continuation of the preamble (hi-low toggling) also raises the Packet Error Rate&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Put a capacitor between ground and Vcc on all NRFs.&lt;/p&gt;&#xA;" OwnerUserId="10565" LastActivityDate="2015-06-19T19:00:13.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12782" PostTypeId="1" CreationDate="2015-06-19T19:23:01.747" Score="1" ViewCount="524" Body="&lt;p&gt;I am trying to communicate between my PC and Arduino Mega 2560 using this serial &lt;a href=&quot;https://github.com/wjwwood/serial&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt;. It works reliably, however I am having trouble passing messages at a high rate over serial. I set the baud to 460800 bps on both systems, and am using a serial handshake. The Arduino reads the values by parsing a string, however during my testing I cannot parse more than ~240 messages per second. Each message into the Arduino is either of the form &quot;r/n&quot; to reset some variables or &quot;0,0,0\n&quot; where in this case the zeroes are the ints I want to parse, these can change. My Arduino code in the loop is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial.available() &amp;gt; 0){&#xA;  resultString = Serial.readStringUntil('\n');&#xA;  if(resultString.equals(&quot;r&quot;)){&#xA;    countEnc0 = 0;&#xA;    countEnc1 = 0;&#xA;    countEnc2 = 0;&#xA;  }else{&#xA;    int counter = 0;&#xA;    int lastIndex = 0;&#xA;    for (int i = 0; i &amp;lt; resultString.length(); i++) {&#xA;      // Loop through each character and check if it's a comma&#xA;      if (resultString.substring(i, i+1) == &quot;,&quot;) {&#xA;        // Grab the piece from the last index up to the current position and store it&#xA;        write[counter] = resultString.substring(lastIndex, i).toInt();&#xA;        // Update the last position and add 1, so it starts from the next character&#xA;        lastIndex = i + 1;&#xA;        // Increase the position in the array that we store into&#xA;        counter++;&#xA;      }&#xA;      // If we're at the end of the string (no more commas to stop us)&#xA;      if (i == resultString.length() - 1) {&#xA;        // Grab the last part of the string from the lastIndex to the end&#xA;        write[counter] = resultString.substring(lastIndex, i+1).toInt();&#xA;      }&#xA;    }&#xA;    analogWrite(8, write[0]); &#xA;    analogWrite(9, write[1]);&#xA;    analogWrite(10, write[2]);&#xA;  }&#xA;  Serial.println(String(countEnc0) + &quot;,&quot; + String(countEnc1) + &quot;,&quot; + String(countEnc2));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know there are more efficient ways to parse this, however my attempts to use them yield similar results (Using parseInt(), char*, etc). Additionally, I am using 3 interrupts to read sensor values and store them in variables here, and writing the values I acquire to the PWM. As long as I can read and send up to 1000 messages per second that's all I need for now. Many thanks...been banging my head against the wall on this one.&lt;/p&gt;&#xA;" OwnerUserId="10746" LastActivityDate="2015-07-23T23:30:32.193" Title="Parsing Int over Serial Slow" Tags="|serial|c++|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12783" PostTypeId="1" CreationDate="2015-06-19T20:01:56.950" Score="2" ViewCount="106" Body="&lt;p&gt;I'm trying to compute Johnson resistance noise in a simple resistor circuit. However, since all frequencies contribute equally, I am getting an answer of infinity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It then dawned upon me that the Arduino ADC probably detect frequencies larger than some cut off given by something called the full power bandwidth. Does anyone know this spec for the Due?&lt;/p&gt;&#xA;" OwnerUserId="10705" LastEditorUserId="16074" LastEditDate="2016-09-14T23:36:13.220" LastActivityDate="2016-09-14T23:36:13.220" Title="Due ADC specs: full power bandwidth" Tags="|arduino-due|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12784" PostTypeId="2" ParentId="12766" CreationDate="2015-06-19T20:19:01.210" Score="0" Body="&lt;p&gt;Your sensor has differential output, with a voltage difference between the Vout+ and Vout- being the measurement. The span of this difference is 0 to 55mV. The reason the sensor is wired this way is to reduce noise. To amplify this type of output you would need a differential output amplifier which is more complicated than a single op amp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can also just wire the Vout- from the sensor to ground, and then use the sensor as a single-ended output from 0 to 55mV (noise might be a problem). If you do this, you can then amplify Vout+ with your LM324 op-amp as described on page 13 of the LM324 datasheet with a non-inverting amplifier. By setting the ratio of R2/R1 to 60, you would get up to 55mV*80 = 4.4V which is pretty good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The op amp needs some voltage headroom, so if you are using 5V supply for it, don't set the amplified voltage max to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I don't think you need much headroom and 4.4V will give you better resolution than 3.3V&lt;/p&gt;&#xA;" OwnerUserId="10708" LastEditorUserId="10708" LastEditDate="2015-06-19T20:24:13.320" LastActivityDate="2015-06-19T20:24:13.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12787" PostTypeId="2" ParentId="12766" CreationDate="2015-06-19T20:51:41.450" Score="1" Body="&lt;p&gt;It is reasonable to use  &lt;code&gt;analogReference(INTERNAL);&lt;/code&gt;, as suggested by Alexander M, to set the range of the ADC to 1.1 V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to use two resistors to make a voltage divider, to make an external reference of 1 V (min.) at the AREF pin, and then use  &lt;code&gt;analogReference(EXTERNAL);&lt;/code&gt;, but the Arduino's supply voltage is likely to be noisier than the internal reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding tiggun's suggestion about grounding the V- pin, it isn't clear to me that the mpx12DP will function correctly with V- and ground connected together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, you can use two or three of the op amps in the four-op-amp LM324 package to make a differential amplifier or an instrumentation amplifier.  See figures 38 and 39 on page 20 of the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm124-n.pdf&quot; rel=&quot;nofollow&quot;&gt;LMx24 datasheet&lt;/a&gt; mentioned in the question.  Figure 38 shows a differential amplifier; you could, for example, replace R3 with a 50KΩ resistor and R4 with a 1MΩ resistor to get a voltage scaleup of about 21, via the formula shown: Vₒ = (1 + R4/R3)·(V₂-V₁).  Alternately, you can use a small variable resistor as in figure 39 to make a variable-gain instrumentation amplifier.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-06-19T20:53:49.633" LastActivityDate="2015-06-19T20:53:49.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12789" PostTypeId="1" CreationDate="2015-06-20T02:04:03.813" Score="2" ViewCount="2272" Body="&lt;p&gt;I've got an application that requires moving to specific points on a file on an SD card, reading, modifying and then writing an update.  The file is fixed size.  The code has no problems moving to the specific offsets required and then reading in blocks of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when the code does a seek() to the next desired location, then a write() and a flush(), the data is not written.  If my code seeks back to the start of the block just written and reads it back, it does not contain the new data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The file is definitely open for writing, and the write operation indicates it wrote all the bytes.  No calls are indicating any error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since reads and seeks are working I'm assuming this is not a problem with wiring of the device to the Arduino Mega.  The files range from around 100K to almost 2M each, and the code needs to access the entire content of the file, but almost never sequentially.  Writes are almost always non-sequential as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it necessary to do a close after each write instead of the flush?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions of things I should be investigating?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bob&lt;/p&gt;&#xA;" OwnerUserId="10749" LastActivityDate="2015-06-20T02:04:03.813" Title="Write with SD card; flush versus close?" Tags="|sd-card|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12790" PostTypeId="2" ParentId="12775" CreationDate="2015-06-20T02:17:16.817" Score="1" Body="&lt;p&gt;I would check each motor without the motor shield to see if the motors are ok. Check the motor shield motor supply, should be around 12 volts with 8 AA cells. You might run a simple test program to see if the motors run full power forward and full power backward with the motor shield. Check the servo with a simple program like the Arduino Knob program. I suspect the Pro Mini 5 volt regulator is overloaded, causing the buzzing sound, but you have to find out why. One possible reason is that you are dropping from 12 volts to 5 volts via the pro mini linear regulator, creating all kinds of heat. The additional load of even a small servo might push the power dissipation spec over the edge.&lt;/p&gt;&#xA;" OwnerUserId="10748" LastEditorUserId="10748" LastEditDate="2015-06-20T02:22:55.313" LastActivityDate="2015-06-20T02:22:55.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12791" PostTypeId="2" ParentId="12720" CreationDate="2015-06-20T02:46:51.713" Score="2" Body="&lt;p&gt;Check the solder jumper on the display. Note the example code is for one address, but two addresses are supported. Try the other address in code, or solder the LCD address pads to select the address to match the code. I had the same problem, the printed address on the LCD solder pads is just the last address bits that make the difference.&lt;/p&gt;&#xA;" OwnerUserId="10748" LastEditorUserId="6936" LastEditDate="2018-07-08T08:48:49.233" LastActivityDate="2018-07-08T08:48:49.233" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12793" PostTypeId="1" CreationDate="2015-06-20T04:28:52.013" Score="1" ViewCount="107" Body="&lt;p&gt;Hi there i am a beginner and trying to pair some sensors with my arduino. I am looking for some software which will allow me to test my codes in virtual machine also it should be free ...thax in advance&lt;/p&gt;&#xA;" OwnerUserId="10752" LastActivityDate="2015-06-20T04:28:52.013" Title="Free simulation software for arduino hardware" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ClosedDate="2015-06-23T14:15:22.740" ContentLicense="CC BY-SA 3.0" />
  <row Id="12795" PostTypeId="1" AcceptedAnswerId="12797" CreationDate="2015-06-20T08:03:12.600" Score="1" ViewCount="802" Body="&lt;p&gt;I have been researching about the reason why we have a second MCU in arduino UNO for a while now. finally i understood that its been use as  USB to serial converter. the question that really bug me now, why is the boot-loader is burn on the main ATmega328 not Atmega16U2 ? &lt;/p&gt;&#xA;" OwnerUserId="10208" LastActivityDate="2015-06-20T09:39:40.420" Title="Why the bootloader burn on ATmega328 rather than Atmega16U2 in Arduino Uno" Tags="|arduino-uno|serial|bootloader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12796" PostTypeId="1" CreationDate="2015-06-20T08:56:53.160" Score="1" ViewCount="289" Body="&lt;p&gt;my garage door is pretty narrow, about 10 cm (4&quot;) on each side of my car's rear mirrors. So every time I drive to garage, I need to go very slowly because I am afraid I might not be lined up correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking about using Arduino and some sensors to help me. Output is pretty simple, just two leds, one for each side, showing me if I should turn little right or left to have perfect lineup to center. This I can handle with no problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am asking for is idea how to measure the alignment of my car. I know how to use ultrasonic sensors for measuring distance. But I am not sure they are suitable for this project, because I want preferably to put arduino and sensors in my garage, not in my car. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea how to work this out ?&lt;/p&gt;&#xA;" OwnerUserId="3533" LastActivityDate="2015-06-29T21:32:42.103" Title="How to measure direction the car is coming to garage door?" Tags="|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12797" PostTypeId="2" ParentId="12795" CreationDate="2015-06-20T09:39:40.420" Score="2" Body="&lt;p&gt;The purpose of the bootloader is to get the firmware through the serial&#xA;port and burn it into the flash. The 16U2 has no access to the 328's&#xA;flash. The job has to be done in the 328 itself.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-20T09:39:40.420" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12801" PostTypeId="2" ParentId="12796" CreationDate="2015-06-20T11:45:42.600" Score="2" Body="&lt;p&gt;It is very hard to determine position accurately there is a new project on kickstarter called Pozyx, you can look at that but that's expensive, to be honest this sounds like a job for hanging tennis balls or strings or something like that. But if you have a lot of money to blow and you just want a project go for it, you may be able to do this with ultrasonic sensors but I reckon that would be painful. Anyway good luck&lt;/p&gt;&#xA;" OwnerUserId="10757" LastActivityDate="2015-06-20T11:45:42.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12802" PostTypeId="2" ParentId="12782" CreationDate="2015-06-20T12:55:35.687" Score="1" Body="&lt;p&gt;First off, I would recommend &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strtok/&quot; rel=&quot;nofollow&quot;&gt; &lt;code&gt;strtok&lt;/code&gt;&lt;/a&gt; or even &lt;code&gt;getline&lt;/code&gt; to parse comma delimited strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, I'm pretty sure no PWM is responsive enough for 1000 updates per second. But for other purposes this data rate might be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this, build a custom cache that does the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Reads 1000 characters per go, if available, or less.&lt;/li&gt;&#xA;&lt;li&gt;Parses on the go. From this set up callbacks to you PWM class, so that you can set PWM values while parsing.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Why this? I am not convinced that the sluggishness is due to the &lt;code&gt;for&lt;/code&gt; parsing data. More likely, it's because you are processing every instruction as you get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1000 serial reads with 6 length &lt;code&gt;for&lt;/code&gt; loops over strings (your case) will be significantly slower than 1 serial read and a 6k length &lt;code&gt;for&lt;/code&gt; loop.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2015-06-20T12:55:35.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12803" PostTypeId="2" ParentId="12782" CreationDate="2015-06-20T13:12:21.167" Score="0" Body="&lt;p&gt;If your bottleneck is really in the parsing (and you should confirm this before you spend any effort to optimize it), eliminate the parsing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I usually recommend sending ASCII strings on serial channels to make debugging simpler, and I'd still suggest you get everything working this way first, even if you can't make the sample rate you need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you're convinced your system works except for its speed, you can replace the ASCII communication with raw binary. A simple protocol would suffice: 3 or 6 bytes (do you need &lt;code&gt;int16_t&lt;/code&gt;s?) of data and a 1 byte checksum downstream, and an ACK / NAK byte upstream to trigger a resend if needed, will probably be more than sufficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The receiver would only have to confirm the checksum and process the already ready-to-go binary sample values.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-20T13:12:21.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12804" PostTypeId="2" ParentId="12796" CreationDate="2015-06-20T13:23:34.923" Score="1" Body="&lt;p&gt;It seems like an ultrasonic sensor on each door-post should do it. You need, I'm guessing, 30cm to the sides of your car as its nose enters the doorway. Smooth the sensor reading, compute a difference and display the sign of the differences as right/left lights. Keep a small dead-band around zero-difference or you'll drive the driver crazy!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do Ultrasonic sensors have the range and accuracy you need for the job? Time for a feasibility study.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Is 10cm plus the length of a mirror = a couple of feet? But even if so, you have to keep to +/- 10cm of the centerline to prevent striking the mirrors, so you could project your sensors out into the doorway by an amount the still keeps them &gt; 10cm away from the car. You could mount them hinged (like the mirrors are) and padded to limit any damage from the occasional accidental touch.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-06-21T19:27:33.747" LastActivityDate="2015-06-21T19:27:33.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12805" PostTypeId="1" AcceptedAnswerId="12806" CreationDate="2015-06-20T15:22:11.030" Score="2" ViewCount="7782" Body="&lt;p&gt;I've looked in several places, and so far can not understand to want to be the GND who is on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is this documented anywhere?&lt;/p&gt;&#xA;" OwnerUserId="10761" LastActivityDate="2015-06-20T15:41:00.767" Title="What is GND on board?" Tags="|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12806" PostTypeId="2" ParentId="12805" CreationDate="2015-06-20T15:41:00.767" Score="2" Body="&lt;p&gt;It is the 0V reference for everything else, as well as the power supply return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Ground_%28electricity%29&quot; rel=&quot;nofollow&quot;&gt;&quot;Ground (electricity)&quot; on Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-06-20T15:41:00.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12808" PostTypeId="1" AcceptedAnswerId="12817" CreationDate="2015-06-20T20:29:55.317" Score="2" ViewCount="13680" Body="&lt;p&gt;I'm not sure about how to properly handle timing readings from serial inside a Python script. I need to read a value every &lt;strong&gt;5 seconds&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Arduino I could do,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(value);&#xA;delay(5000); // should I wait here?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside Python script I could do,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import time&#xA;&#xA;arduino = serial.Serial('/dev/ttyACM1', 9600, timeout=5) # should I set timeout?&#xA;&#xA;while True and arduino.isOpen():&#xA;&#xA;    try:    &#xA;        value = arduino.readline().strip()&#xA;        print value&#xA;&#xA;        time.sleep(5) # should I wait here?&#xA;&#xA;    except KeyboardInterrupt:&#xA;        print &quot;\nClosing...&quot;&#xA;        arduino.close() &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: Apart from that, the first reading is always wrong, like if there was something in the reading buffer.&#xA;I've found out that to solve that I should add &lt;code&gt;arduino.flushInput()&lt;/code&gt; just after opening the port.&lt;/p&gt;&#xA;" OwnerUserId="5103" LastEditorUserId="5103" LastEditDate="2015-06-21T17:16:32.930" LastActivityDate="2020-05-22T21:48:54.107" Title="Handle reading timing in Python using pySerial" Tags="|python|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12809" PostTypeId="1" AcceptedAnswerId="12810" CreationDate="2015-06-18T12:12:31.637" Score="1" ViewCount="15231" Body="&lt;p&gt;QUCS is the only open source software which offers simulation (and designing PCB layout [in future]) of electrical circuits. But the problem with QUCS is that it is under development and many important features are not yet available in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to simulate Arduino Uno board in it for my circuit. Does anyone know how to simulate Arduino or any other micro-controller in it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; Also any other open source software for simulation and PCB designing?&lt;/p&gt;&#xA;" OwnerUserId="10770" OwnerDisplayName="user263210" LastActivityDate="2024-04-06T15:20:50.233" Title="How to simulate Arduino?" Tags="|simulator|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12810" PostTypeId="2" ParentId="12809" CreationDate="2015-06-18T13:40:37.090" Score="3" Body="&lt;p&gt;Simulating a microcontroller's program is common, but not as part of a circuit, unless you're into Systems on Chips.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Model the micro interfaces and simulate the peripherals separately&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Analog systems cannot be modelled accurately by hand calculations alone, therefore simulation is often a necessary step (on top of that, real circuits might behave differently from the model). Non-programmable digital systems are deterministic in their behaviour, but only if the interfaces are correct - tight specifications on impedances and such often mean simulation is required here as well. Generally speaking, for both simulation becomes a must when the system is not dead simple. Microcontrollers on the other hand are sufficiently deterministic not to require any simulation: they do what they're told, except in very very very rare cases (single event upsets from radiation for example). Now, what they're told might allow glitches to happen, but that's a different story*. Therefore, usually the analog, or digital circuits around a microcontroller would be given equivalent interfaces based on the microcontroller's behaviour and physical specifications, and simulated separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*: As the code becomes more and more complex, it gets more and more difficult to follow what the microcontroller might do. Unexpected glitches may arise from e.g. concurrent access (though I can't say this is common in the micro realm), or insufficient resources (that is why dynamic allocation [malloc,new] are highly discouraged, so that the resources allocation is known at compilation time) etc. That's usually why tests are required, and step-by-step debugging is used as a means to locate any error that arises. But inherently, microcontrollers are highly predictable and except in certain cases, it is not worth it to go through simulation (do not mix up simulations and tests, tests are always required!).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Advantages of microcontroller simulators&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;However, microcontrollers simulators do exist. They are particularly helpful to watch what happens inside the microcontroller when the code executes step by step: call stack, watches on variables, interrupt vectors etc. This can also be done on the actual hardware using in circuit debuggers, but simulators are cheaper and are also good to save on EEPROM erase/write cycles and to avoid damaging your micro if you are afraid that the devices around it might be incorrectly configured (some controllers are very expensive, especially if they are qualified for medical, military or aerospace applications). I have seen such ICD's and simulators for Microchip PICs (MPLABX), but there must be equivalents for AVR (the micro which is on the Arduino's), or perhaps even integrated in an arduino-friendly environment (though I doubt it). You might want to take a look &lt;a href=&quot;https://electronics.stackexchange.com/questions/1677/how-can-i-use-avrsim-to-simulate-arduino?rq=1&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;If you've got deep pockets: mixed signal simulators&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Finally, there are mixed signal simulators which allow you to simulate analog, programmable and non-programmable digital circuits alike; one component will have an analog SPICE model, another a VHDL model, and ADC/DAC blocks will be added automatically by the simulator between those devices depending on the logic input/output technology you specify. Those are extremely expensive (the one I used is Cadence Virtuoso), you don't want to do that unless you're doing an integrated circuit or something critical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: DesignSpark PCB v3 has LTspice in it. Never tried that feature in there though, I used to use LTspice directly.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note that your opening &quot;QUCS is the only open source software [...]&quot; is wrong. There are plenty of simulators out there which are open source. I agree QUCS is a very user-friendly one though.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="62677" OwnerDisplayName="Mister Mystère" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-06-18T22:08:39.923" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12811" PostTypeId="2" ParentId="12809" CreationDate="2015-06-18T16:32:33.927" Score="3" Body="&lt;p&gt;You can use &lt;a href=&quot;https://123d.circuits.io&quot; rel=&quot;nofollow&quot;&gt;123d.circuits.io&lt;/a&gt; for simulation and PCB design for Arduino circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://123d.circuits.io/circuits/251828-16led&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, a previous answer states that Microcontroller based circuits are not simulated. Maybe that's true when prototyping costs are low (though I doubt it), but in an SoC or complex embedded system, microcontrollers certainly are simulated as part of the overall system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes as a highlevel model such as a symbolic simulator or sometimes as a part of the overall mixed-signal simulation environment in which the digital part is usually simulated at RT level.&lt;/p&gt;&#xA;" OwnerUserId="113" OwnerDisplayName="akellyirl" LastActivityDate="2015-06-18T16:32:33.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12812" PostTypeId="1" AcceptedAnswerId="12875" CreationDate="2015-06-21T06:38:07.107" Score="2" ViewCount="5994" Body="&lt;p&gt;Hey all I have the ESP8266 module and I have already set it up and it's working good. However, when I run this HTML page code here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;    &amp;lt;head&amp;gt;&#xA;        &amp;lt;title&amp;gt;ESP8266 LED Control&amp;lt;/title&amp;gt;&#xA;    &amp;lt;/head&amp;gt;&#xA;    &amp;lt;body&amp;gt;&#xA;    &amp;lt;button id=&quot;6894&quot; class=&quot;led&quot;&amp;gt;Toggle Pin 13&amp;lt;/button&amp;gt; &amp;lt;!-- button for pin 13 --&amp;gt;&#xA;&#xA;    &amp;lt;script src=&quot;jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&#xA;    &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&#xA;        $(document).ready(function(){&#xA;            $(&quot;.led&quot;).click(function(){&#xA;                var p = $(this).attr('id'); // get id value (i.e. pin13, pin12, or pin11)&#xA;&#xA;                $.get(&quot;http://192.168.9.60:80/&quot;, {pin:p}); // execute get request&#xA;            });&#xA;        });&#xA;    &amp;lt;/script&amp;gt;&#xA;    &amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have to send the number 6894 instead of 13 because for some reason its not sending out the correct number. If i send 13 then what it receive is 114. When i send 6894 i receive 689.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino code is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*/&#xA;//====================================================================================&#xA;//                                [The SSDI of the current wifi router]&#xA;//                                |              [The password of the current wifi router]&#xA;//                                |              |&#xA;//                                V              V&#xA;String SSIDandPW    = &quot;AT+CWJAP=\&quot;xxxxxxwifi\&quot;,\&quot;xxxxxx123\&quot;\r\n&quot;;&#xA;&#xA;//                                      [The STATIC IP of the wifi module]&#xA;//                                      |                [The main IP of the router]&#xA;//                                      |                |              [The default submask]&#xA;//                                      |                |              |&#xA;//                                      V                V              V&#xA;String eIPrIPmask   = &quot;AT+CIPSTA_DEF=\&quot;192.168.9.60\&quot;,\&quot;192.168.9.1\&quot;,\&quot;255.255.255.0\&quot;\r\n&quot;;&#xA;const int ledDimmer = 5;         // Used to dim the LED strip (digital Pin 3)&#xA;&#xA;SoftwareSerial esp8266(9,10);    // Pin D10 to=&amp;gt; TX on ESP8266 | Pin D9 to=&amp;gt; RX on ESP8266&#xA;//================================= End define WiFi Module =================================&#xA;//==========================================================================================&#xA;&#xA;void setup() {&#xA;  Serial.begin(19200);&#xA;&#xA;  pinMode(13, OUTPUT); //Just for a wifi demo from html page&#xA;&#xA;  //================================ Start Setup WiFi Module =================================&#xA;  //==========================================================================================&#xA;  esp8266.begin(19200);&#xA;  sendData(&quot;AT+RST\r\n&quot;,                    2000, true); // Reset module&#xA;  sendData(&quot;AT+CWMODE=1\r\n&quot;,               2000, true); // Configure as access point&#xA;  sendData(SSIDandPW,                       5000, true); // Pass of current wifi&#xA;  sendData(&quot;AT+CIPMUX=1\r\n&quot;,               2000, true); // Configure for multiple connections&#xA;  sendData(&quot;AT+UART_DEF=19200,8,1,0,0\r\n&quot;, 2000, true); // Set baud of COM&#xA;  sendData(eIPrIPmask,                      2000, true); // Default network mask IP&#xA;  sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;,         2000, true); // Turn on server on port 80&#xA;  sendData(&quot;AT+GMR\r\n&quot;,                    2000, true); // Get firmware version&#xA;  sendData(&quot;AT+CIFSR\r\n&quot;,                  2000, true); // Get ip address&#xA;  Serial.print(&quot;Server is now running!&quot;);&#xA;  //================================ End Setup WiFi Module ===================================&#xA;  //==========================================================================================&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  //=========================================== Start Loop WiFi Module ===========================================&#xA;  //==============================================================================================================&#xA;  if(esp8266.available()) {                               // check if the esp is sending a message &#xA;    if(esp8266.find(&quot;+IPD,&quot;)) {&#xA;      delay(500);&#xA;      int connectionId = esp8266.read() - 48;             // subtract 48 because the read() function returns&#xA;&#xA;      esp8266.find(&quot;pin=&quot;);                               // advance cursor to &quot;pin=&quot;&#xA;      int retunedNum = (esp8266.read() - 48) * 100;       // get first number (example: 123.. this would be &quot;1&quot;)&#xA;      retunedNum += (esp8266.read() - 48) * 10;           // get second number (example: 123.. this would be &quot;2&quot;)&#xA;      retunedNum += (esp8266.read() - 48);                // get last number (example: 123.. this would be &quot;3&quot;)&#xA;      String closeCommand = &quot;AT+CIPCLOSE=&quot;;               // make close command&#xA;      Serial.print(&quot;returned: &quot;);&#xA;      Serial.print(retunedNum);&#xA;      Serial.print(&quot;----------&quot;);&#xA;      closeCommand += connectionId;                       // append connection id&#xA;      closeCommand += &quot;\r\n&quot;;     &#xA;      sendData(closeCommand,                250, true);   // close connection&#xA;      //digitalWrite(retunedNum, !digitalRead(retunedNum));   // toggle pin&#xA;      if (retunedNum == 6894) {&#xA;        Serial.print(&quot;OFF&quot;);&#xA;        digitalWrite(ledDimmer, LOW);&#xA;      } else if (retunedNum == 6904) {&#xA;        Serial.print(&quot;ON&quot;);&#xA;        digitalWrite(ledDimmer, HIGH);&#xA;      } else if (retunedNum == 689) {&#xA;        digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;        delay(1000);              // wait for a second&#xA;        digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;        delay(1000);              // wait for a second &#xA;      }&#xA;    }&#xA;  }&#xA;  //============================================ End Loop WiFi Module ============================================&#xA;  //==============================================================================================================&#xA;}&#xA;&#xA;//                     [The data/command to send]&#xA;//                     |                  [The time to wait for a response]&#xA;//                     |                  |                [Print to Serial window (true = yes | false = no)]&#xA;//                     |                  |                |&#xA;//                     V                  V                V&#xA;String sendData(String command, const int timeout, boolean debug) {&#xA;  String response = &quot;&quot;;&#xA;  long int time   = millis();&#xA;&#xA;  esp8266.print(command);          // send the read character to the esp8266&#xA;&#xA;  while((time + timeout) &amp;gt; millis()) {&#xA;    while(esp8266.available()) {&#xA;                                   // The esp has data so display its output to the serial window&#xA;        char c = esp8266.read();   // read the next character.&#xA;        response += c;&#xA;    }&#xA;  }&#xA;&#xA;  if (debug) { Serial.print('Returned: ' + response); }&#xA;  return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the console output is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;14880AT+RST&#xA;&#xA;&#xA;OK&#xA;14880&#xA;&quot;qXÑ{ÂB!É&#xA;1Â±þ)ÒBÙa&#xA;+ò“H!a5)�#)ÒÂia%YakN‘ J!ÐCÊ!�&#xA;÷þˆ2ô&#xA;ready&#xA;14880AT+CWJAP=&quot;xxxxxxwifi&quot;,&quot;xxxxxx123&quot;&#xA;&#xA;&#xA;OK&#xA;14880AT+CIPMUX=1&#xA;&#xA;&#xA;OK&#xA;14880AT+UART_DEF=19200,8,1,0,0&#xA;&#xA;&#xA;OK&#xA;14880AT+CIPSTA_DEF=&quot;192.168.9.60&quot;,&quot;192.168.9.1&quot;,&quot;255.255.255.0&quot;&#xA;&#xA;&#xA;OK&#xA;14880AT+CIPSERVER=1,80&#xA;&#xA;&#xA;OK&#xA;14880AT+GMR&#xA;&#xA;AT version:0.22.0.0(Mar 20 2015 10:04:26)&#xA;SDK version:1.0.0&#xA;compile time:Mar 20 2015 11:00:56&#xA;&#xA;OK&#xA;14880AT+CIFSR&#xA;&#xA;+CIFSR:STAIP,&quot;192.168.9.60&quot;&#xA;+CIFSR:STAMAC,&quot;18:fe:34:9b:4e:68&quot;&#xA;&#xA;OK&#xA;Server is now running!&#xA;&#xA;returned: 689----------148804 HTTP/1.1&#xA;Host: 192.168.9.60&#xA;Connection: AT+CIPCLOSE=0&#xA;&#xA;0,CLOSED&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I really am wanting to do is have a way to send a 10 charater string to the arduino instead of the limited 3 numbers above. I just am not sure what i need to add/modify in order to make it see letters/numbers and only the first 10 that i send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great!&lt;/p&gt;&#xA;" OwnerUserId="5133" LastActivityDate="2015-06-23T21:51:13.547" Title="ESP8266 wifi module sending data via jQuery" Tags="|arduino-ide|wifi|arduino-nano|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12813" PostTypeId="1" CreationDate="2015-06-21T06:41:40.387" Score="0" ViewCount="455" Body="&lt;p&gt;I've just bought a new LinkIt ONE IoT prototyping board, and I'm having trouble getting started with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on a mac. I've installed the LinkIt ONE SDK onto my Arduino IDE as specified in the instructions here: &lt;a href=&quot;http://labs.mediatek.com/fileMedia/download/5fed7907-b2ba-4000-bcb2-016a332a49fd&quot; rel=&quot;nofollow&quot;&gt;http://labs.mediatek.com/fileMedia/download/5fed7907-b2ba-4000-bcb2-016a332a49fd&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I go to upload my first sketch to my board, the sketch compiles and goes through uploading, but before it uploads, it stops uploading and the Arduino IDE perpetually tells me &quot;Uploading...&quot;. When I look at the console below, it's telling me this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[txd] AT&#xA;&#xA;&#xA;[txd] AT&#xA;&#xA;[medrv]: Time out call back&#xA;&#xA;[error] time out&#xA;[medrv]: Kill timer, event is AT_TIMEOUT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've read some forums about an issue similar to this on the MediaTek website, but they don't help with the issue on the Mac. The ability to use LinkIt ONE on a Mac is new only this month, so I believe if we come up with a fix for this issue, it will help lots of people in the future who have this similar problem. &lt;/p&gt;&#xA;" OwnerUserId="10767" OwnerDisplayName="slomdogmillionaire" LastEditorUserId="10767" LastEditDate="2015-06-21T22:02:40.690" LastActivityDate="2015-06-21T22:26:40.097" Title="Sketch Upload to LinkIt ONE Timeout" Tags="|bluetooth|arduino-ide|wifi|gps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12814" PostTypeId="1" CreationDate="2015-06-21T09:47:03.300" Score="0" ViewCount="2196" Body="&lt;p&gt;I have purchased an Arduino Uno R3 board and a LAN shield from these locations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.amazon.in/gp/product/B00H1HR576&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino UNO R3&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ebay.in/itm/W5100-Ethernet-Shield-for-Arduino-Uno-And-Mega-KG027-/121654747580&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino LAN shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am trying to configure Ethernet using this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address for your controller below.&#xA;// Newer Ethernet shields have a MAC address printed on a sticker on the shield&#xA;byte mac[] = {&#xA;  0x4,0x2,0x45,0x68,0x5E,0x96,0x56&#xA;};&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server&#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  delay(5000);&#xA;  // this check is only needed on the Leonardo:&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  // start the Ethernet connection:&#xA;  Serial.println(&quot;trying to configure ethernet...&quot;);&#xA;  while(Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP, retrying after 5 sec&quot;);&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    delay(5000);&#xA;    Serial.println(&quot;trying to configure ethernet...&quot;);&#xA;  }&#xA;  // print your local IP address:&#xA;  Serial.print(&quot;My IP address: &quot;);&#xA;  for (byte thisByte = 0; thisByte &amp;lt; 4; thisByte++) {&#xA;    // print the value of each byte of the IP address:&#xA;    Serial.print(Ethernet.localIP()[thisByte], DEC);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It generates this output in the Serial Monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;Failed to configure Ethernet using DHCP, retrying after 5 sec&#xA;trying to configure ethernet...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have captured the LED indicators on video on YouTube, it shows Tx and Rx LEDs glowing occasionally, see &lt;a href=&quot;https://www.youtube.com/watch?v=tktkjooh3CA&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino not detecting the ethernet connection&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the Arduino is not able to connect to the Ethernet... I am using the Arduino IDE 1.6.5 on Windows 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any debug tool for Arduino that can be used to figure out this issue?&lt;/p&gt;&#xA;" OwnerUserId="10768" LastEditorUserId="4628" LastEditDate="2017-01-15T03:33:14.817" LastActivityDate="2019-07-11T09:11:24.853" Title="Unable to configure Ethernet using Arduino Uno R3" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12815" PostTypeId="1" CreationDate="2015-06-21T10:46:29.183" Score="0" ViewCount="920" Body="&lt;p&gt;I want to use an external clock signal as an interrupt for the Due timer. How do I do that? I could not find any info on this on the net.&lt;/p&gt;&#xA;" OwnerUserId="10677" LastEditorUserId="4628" LastEditDate="2018-04-20T15:44:39.433" LastActivityDate="2018-04-20T15:44:39.433" Title="How to use an external clock with the Due timer?" Tags="|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12816" PostTypeId="2" ParentId="12815" CreationDate="2015-06-21T11:26:25.163" Score="1" Body="&lt;p&gt;Everything you need to know is in the SAM3X datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as Atmel's datasheets are some of the most cryptic ones around, you'll need to spend quite some time deciphering it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's an entire section just on the timers.  It tells you all about how they work, however, relating that to which registers you need to set to get it to do that is not clear (as is normal for Atmel) since the registers are listed elsewhere in that section with no real relationship between them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-21T11:26:25.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12817" PostTypeId="2" ParentId="12808" CreationDate="2015-06-21T18:27:20.810" Score="3" Body="&lt;p&gt;The answer is that it depends on what you are actually trying to accomplish. If there is nothing else to be done on the Arduino then it is fine to have it sit and wait; on the other hand if there is nothing else for the python script to do then it is fine for it to sit and wait, but there is no reason for both of them wait.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Arduino &lt;code&gt;delay&lt;/code&gt;s&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You don't need to deal with the timing delay in python if the Arduino is &lt;code&gt;delay&lt;/code&gt;ing. According to &lt;a href=&quot;http://pyserial.sourceforge.net/shortintro.html#readline&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt; &lt;code&gt;readline&lt;/code&gt; will wait until it has received a value or until the timeout is reached. That said, I would make the timeout slightly longer than the delay on the Arduino side of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;readline&lt;/code&gt; will block your program from doing anything else while it waits. As such, It is pretty useful to explore python &lt;a href=&quot;https://docs.python.org/2/library/threading.html#module-threading&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;threading&lt;/code&gt;&lt;/a&gt; when you are writing a program which collects data over a serial stream unless the program is &lt;em&gt;only&lt;/em&gt; collecting data. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Python &lt;code&gt;sleep&lt;/code&gt;s&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If there is other stuff to be done on the Arduino (perhaps if you are doing some filtering of the temperature data using the Arduino so as to reduce noise) then it might make more sense for it to push data to the serial stream at the end of each &lt;code&gt;loop&lt;/code&gt;, and for the python script to only read the data every 5 seconds. In this case you could have python &lt;code&gt;sleep&lt;/code&gt; and use no delay (or a shorter delay) on the Arduino. You can achieve this behavior without resorting to using &lt;code&gt;sleep&lt;/code&gt; by using a &lt;a href=&quot;https://docs.python.org/2/library/threading.html#timer-objects&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;timer&lt;/code&gt; object&lt;/a&gt; to periodically call a function that &lt;code&gt;open&lt;/code&gt;s the serial stream (possibly flush it), reads the data, processes it, and closes the serial stream. &lt;/p&gt;&#xA;" OwnerUserId="10689" LastActivityDate="2015-06-21T18:27:20.810" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12819" PostTypeId="1" CreationDate="2015-06-21T21:09:25.663" Score="0" ViewCount="585" Body="&lt;p&gt;I´m trying to insert a binary raw sequence (01010100, 01101000, 01100001) into Arduino. I would like to make 8-led group blink in a loop, showing with light each 8-group binary sequence when: 0=light off and 1=light on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It´s possible to do this operation with Arduino-uno ?&lt;/p&gt;&#xA;" OwnerUserId="10774" LastActivityDate="2021-08-11T16:04:40.370" Title="Binary reader with arduino blinking 8 leds" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12820" PostTypeId="1" AcceptedAnswerId="12846" CreationDate="2015-06-21T21:15:35.470" Score="2" ViewCount="1415" Body="&lt;p&gt;I would like to ask if it is possible and how to connect the following module&#xA;&lt;a href=&quot;http://www.ebay.com/itm/TOP-Mini-W5100-LAN-Ethernet-Shield-Network-Module-board-for-Arduino-Best-NEW-/251981053942?pt=LH_DefaultDomain_0&amp;amp;hash=item3aab3dbff6&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/TOP-Mini-W5100-LAN-Ethernet-Shield-Network-Module-board-for-Arduino-Best-NEW-/251981053942?pt=LH_DefaultDomain_0&amp;amp;hash=item3aab3dbff6&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to the arduino micro &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some pin layouts but only for Leonardo or Ethernet shield, Uno etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I've choosen this model because it can be programmed directly in arduino using Sockets API&lt;/p&gt;&#xA;" OwnerUserId="10773" LastEditorUserId="9962" LastEditDate="2015-06-23T14:00:37.487" LastActivityDate="2015-06-23T14:00:37.487" Title="micro arduino and w5100" Tags="|arduino-uno|ethernet|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12821" PostTypeId="1" AcceptedAnswerId="12823" CreationDate="2015-06-21T21:45:59.823" Score="1" ViewCount="1220" Body="&lt;p&gt;My understanding of using dynamic memory on the arduino is that new/delete are not available, only malloc realloc and such C functions, as mentioned here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus&quot; rel=&quot;nofollow noreferrer&quot;&gt;C++ &amp;amp; the AVR&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am creating a library that defines an object type that needs to contain a dynamic list of other objects. In C++ I would define it something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Container&#xA;{&#xA;std::vector&amp;lt;otherObjectType&amp;gt; otherObjects;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which obviously does not work in the arduino without the C++ standard library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My next choice would be to create a dynamic array using new, ie&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;otherObjects = new otherObjectType[3]&#xA;{ &#xA;    {   (arguments to constructor...)&#xA;    },&#xA;    {   (arguments to constructor...)&#xA;    },&#xA;    {   (arguments to constructor...)&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this does not work as well, since new is not supported...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;finally I could try to use malloc as laid out &lt;a href=&quot;https://stackoverflow.com/questions/4956249/using-malloc-instead-of-new-and-calling-the-copy-constructor-when-the-object-is&quot;&gt;here&lt;/a&gt;, but that also wont work without new.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if I should just rewrite everything as structs, since that wont require me to worry about whether the constructor for the object was called when the memory was allocated in malloc.&lt;/p&gt;&#xA;" OwnerUserId="10683" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-06-21T22:38:01.710" Title="Malloc with Objects in Arduino libraries" Tags="|arduino-uno|c++|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12822" PostTypeId="2" ParentId="12813" CreationDate="2015-06-21T22:26:40.097" Score="1" Body="&lt;p&gt;&lt;em&gt;Disclaimer: I do not have access to one of these devices to test this on.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Section 3.4.1 of &lt;a href=&quot;http://labs.mediatek.com/fileMedia/download/5fed7907-b2ba-4000-bcb2-016a332a49fd&quot; rel=&quot;nofollow noreferrer&quot;&gt;LinkIt's developer's guide&lt;/a&gt; (which you linked to) seems to indicate that it is necessary to install COM port drivers on OS X before you can communicate with the board. The &lt;code&gt;[txd]&lt;/code&gt; report is communication from your computer to the board, so it seems like you are never establishing a connection. The suggestions in the developer's guide are as follows:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you are using a LinkIt ONE development board on Mac OS X 10.10, then a USB driver is required to enable connectivity with and firmware updates on the LinkIt ONE development board. The OS X 10.10 built-in generic CDC ACM USB driver is not compatible with three ports available on the LinkIt ONE development board. The steps to install a custom driver to enable the BROM port for Firmware Updater are as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Extract the content of the zip file available in LinkIt ONE SDK software’s &lt;strong&gt;Driver&lt;/strong&gt; folder (see 2.3.2, “Installing LinkIt ONE SDK”) named &lt;code&gt;MacOS_USB_COM_Driver_BM_xxx.xx.x.zip&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the installation package (&lt;code&gt;BMCDCACM_Driver_v115.05.0.mpkg&lt;/code&gt;) and click &lt;strong&gt;Next&lt;/strong&gt; to install it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wait until driver installation has finished, then restart your Mac.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;BROM USB driver installation is now complete and you have access to the MTK USB Serial ports.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10775" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-06-21T22:26:40.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12823" PostTypeId="2" ParentId="12821" CreationDate="2015-06-21T22:30:55.070" Score="1" Body="&lt;p&gt;&lt;code&gt;new&lt;/code&gt; actually does work in arduino. it is defined in arduino/hardware/arduino/avr/cores/arduino/{new.h, new.cpp} using malloc. It is not part of avr-libc though (which your link concerns) and has not always been added by arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these work for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace{ //namespace to deal with .ino preprocessor bug&#xA;    class foo{&#xA;    public:&#xA;        int bar;&#xA;        foo(int a){&#xA;            bar = a;&#xA;        }&#xA;    };&#xA;}&#xA;...&#xA;//using new&#xA;foo *a = new foo[3]{{1},{2},{3}};&#xA;&#xA;//How I would probably do this with malloc&#xA;foo *b = (foo*) malloc(sizeof(foo)*3);&#xA;b[0] = foo(2);&#xA;b[1] = foo(4);&#xA;b[2] = foo(8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Placement new is not defined right now. I know that copying isn't quite the same, but it should work in most cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you know exactly how long you want the array to be at compile time, you should probably make it a static/global variable so that you avoid using dynamic memory and the sketch ram usage number will be closer to correct.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-06-21T22:38:01.710" LastActivityDate="2015-06-21T22:38:01.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12824" PostTypeId="2" ParentId="12814" CreationDate="2015-06-21T22:55:57.593" Score="0" Body="&lt;p&gt;&lt;strike&gt;I never used the DHCP feature to assign an IP address for the Ethernet shield, but somewhere in there you have to list the IP of the router that assigns the DHCP.&lt;/strike&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In everyday use of the shield, you don't want your router to assign an IP address to your device because every time it connects it might get a different IP address. That means if you want to communicate with it, you need to discover the IP address each time. And communicating with it from the WAN side through a port you open in your router would be impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try one of the fixed IP address sketches, but select a free IP address in your router's IP range that &lt;em&gt;isn't&lt;/em&gt;, also, in the router's DHCP IP range (that way the fixed IP address won't interfere with the IP addresses given out automatically).&lt;/p&gt;&#xA;" OwnerUserId="10736" LastEditorUserId="6936" LastEditDate="2017-01-14T23:12:47.437" LastActivityDate="2017-01-14T23:12:47.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12825" PostTypeId="1" CreationDate="2015-06-19T12:35:36.097" Score="1" ViewCount="1788" Body="&lt;p&gt;I'm trying to upload a hex file to an ATtiny45 with an Arduino. I uploaded the Arduino ISP sketch to my board. I connected the ATtiny as shown below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/25qaC.png&quot; alt=&quot;Wiring diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I go to CMD and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp -p t45 -b 19200 -P COM6 -U flash:w:main.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it gives me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Please define PAGEL and BS2 signals for ATtiny45!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I double checked the connections and i tried to uplad a bootloader with Arduino IDE as written in this article: &lt;a href=&quot;https://arduinodiy.wordpress.com/2012/09/11/programming-hex-code-on-an-attiny85-with-the-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programming Hex-code on an Attiny85 with the Arduino&lt;/a&gt;. I can uplad sketches with ArduinoIDE with no error.&lt;/p&gt;&#xA;" OwnerUserId="10743" OwnerDisplayName="mbalint1" LastActivityDate="2015-06-21T23:03:05.573" Title="Flash a .hex to an ATtiny45 with Arduino" Tags="|flash|attiny|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12827" PostTypeId="2" ParentId="12825" CreationDate="2015-06-19T12:50:40.050" Score="2" Body="&lt;p&gt;Googling the error &lt;a href=&quot;http://highlowtech.org/?p=1229&quot; rel=&quot;nofollow&quot;&gt;gives this tutorial&lt;/a&gt;. Towards the bottom of the page they say &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You’ll probably get the following message, but don’t worry, the upload should have worked anyway:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;em&gt;avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it seems this can be ignored and the part has been programmed!&lt;/p&gt;&#xA;" OwnerUserId="10742" OwnerDisplayName="LeoR" LastActivityDate="2015-06-19T12:50:40.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12828" PostTypeId="1" CreationDate="2015-06-22T03:44:21.310" Score="0" ViewCount="1000" Body="&lt;p&gt;I'v got this USB/SD card/CompactFlash reader from an old DELL AIO 926 printer, it's a double sided PCB board and that's all i know about it.&#xA;I tried to google it but couldn't find anything relevent, how can i tell what voltage it takes and what each wire does and how to interface it with arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/bm3zX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6qnuz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gNJxF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that it has two sets of 4 wires (red/orange - black - yellow - white) and an extra blue wire, i'm guessing that the black is for GND, red/orange for VCC, yellow/white for SDA/XDA I2C serial bus data transfer, but no clue what the blue wire does, i could've tested this with arduino but i don't want to risk frying the board by using a wrong voltage. any help would be greately appreciated. thanks.&lt;/p&gt;&#xA;" OwnerUserId="9960" LastActivityDate="2015-06-22T09:05:17.170" Title="How to connect a card reader (extracted from printer) to arduino uno" Tags="|arduino-uno|usb|sd-card|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12830" PostTypeId="2" ParentId="8406" CreationDate="2015-06-22T04:30:36.360" Score="3" Body="&lt;p&gt;A little late, but I used a potentiometer as a switch to determine which &quot;sketch&quot; to run; in this case swapping LEDs on/off. I assume it can be applied to this instance, the students just have to share/divide pins and declare variables together at the top with comments. (I'm new at this, but I think a shift register (75HC595) could be used if you run out of pins). Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Potentiometers give a value of 0-1023. I split that up into 2, 3, and 4 separate sketches with no problems. You just have to change the IF/ELSEIFs to reflect how many sketches you want to run (512 for 2, 341 for 3, ~256 for 4, etc).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorPin = 0;&#xA;int sensorValue = 0;&#xA;int ledPin1 = 4;&#xA;int ledPin2 = 8;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  sensorValue = analogRead(sensorPin);&#xA;&#xA;  if (sensorValue &amp;lt; 512)&#xA;{&#xA;    digitalWrite(ledPin1,HIGH);&#xA;    digitalWrite(ledPin2,LOW);&#xA;}&#xA;&#xA;  else&#xA;{&#xA;    digitalWrite(ledPin2,HIGH);&#xA;    digitalWrite(ledPin1,LOW);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10778" LastActivityDate="2015-06-22T04:30:36.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12831" PostTypeId="1" CreationDate="2015-06-15T15:49:13.470" Score="-1" ViewCount="1017" Body="&lt;p&gt;We have an instrument that has analog output of 0-1 volts and we need to convert this to 0-5 volts. What is the best op amp to use for this and how should the resistors be set up? Any help would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Paul&lt;/p&gt;&#xA;" OwnerDisplayName="Paul" LastEditorUserId="10794" LastEditDate="2015-09-12T00:42:08.903" LastActivityDate="2015-09-12T00:42:08.903" Title="0-1 V input to 0-5 V Output" Tags="|analogread|hardware|analog-sampling|op-amp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12832" PostTypeId="2" ParentId="12831" CreationDate="2015-06-18T17:21:56.710" Score="5" Body="&lt;p&gt;Since you used Arduino tag..., you don't need an opamp. Instead you can select ADC reference voltage on your arduino to 1.1V. This way you don't need any additional parts and you get the whole precision range. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogReference(INTERNAL1V1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/AnalogReference&quot;&gt;http://www.arduino.cc/en/Reference/AnalogReference&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6372" OwnerDisplayName="Cano64" LastActivityDate="2015-06-18T18:01:53.987" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12833" PostTypeId="1" CreationDate="2015-06-22T06:55:55.277" Score="1" ViewCount="14251" Body="&lt;p&gt;I'd like to write a code for reversing DC motor rotation direction as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start the motor rotation clockwise (CW).&lt;/li&gt;&#xA;&lt;li&gt;When reach Limit Switch (CW) → motor will stop for 5 sec.&lt;/li&gt;&#xA;&lt;li&gt;after 5 sec. of stopping → the motor will rotate in counter clockwise direction(CCW).&lt;/li&gt;&#xA;&lt;li&gt;When reach Limit Switch (CCW) → motor will stop for 5 sec.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;and repeat point 1, 2, 3 and 4... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually I wrote a code for reversing the motor direction using &lt;strong&gt;two&lt;/strong&gt; limit switches and it is working good. But when I added delay the motor did not stop using the limit Switches and continue to rotate... &#xA;If any one can help...&#xA;Here is my code for reversing the direction with out delay 5 sec. My limit SWs are connected on Normal Open.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int sw1, sw2, sw3;&#xA;const int LM1 = 0;&#xA;const int LM2 = 1;&#xA;const int LM3 = 6;&#xA;const int CW = 10;&#xA;const int CCW = 9;&#xA;const int Buzzer = 7;&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(LM1, INPUT);&#xA;  pinMode(LM2, INPUT);&#xA;  pinMode(LM3, INPUT);&#xA;  pinMode(CW, OUTPUT);&#xA;  pinMode(CCW, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  sw3 = digitalRead(LM3);&#xA;  sw1 = digitalRead(LM1);&#xA;  sw2 = digitalRead(LM2);&#xA;&#xA;  if (sw1 == LOW &amp;amp;&amp;amp; sw2 == HIGH) {&#xA;    do {&#xA;      digitalWrite(Buzzer, HIGH);&#xA;      digitalWrite(CW, HIGH);// change the direction of rotation (DOWN Movement)&#xA;      digitalWrite(CCW, LOW);&#xA;&#xA;      sw2 = digitalRead(LM2);&#xA;    } while (sw2 == HIGH);&#xA;  }&#xA;  else if (sw1 == HIGH &amp;amp;&amp;amp; sw2 == LOW) {&#xA;    do {&#xA;      digitalWrite(Buzzer, HIGH);&#xA;      digitalWrite(CW, LOW);// change the direction of rotation (UP Movement)&#xA;      digitalWrite(CCW, HIGH);&#xA;&#xA;      sw1= digitalRead(LM1);&#xA;    } while (sw1 == HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10782" LastEditorUserId="7508" LastEditDate="2015-06-22T07:53:53.717" LastActivityDate="2018-07-04T14:03:45.370" Title="reversing DC motor rotation using TWO limit Switches Problem !! need help" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12834" PostTypeId="1" AcceptedAnswerId="12840" CreationDate="2015-06-22T07:10:46.280" Score="0" ViewCount="150" Body="&lt;p&gt;I am using a sensor which delivers a 4 to 20 mA output.&#xA;Converting this with a 250 Ohm resistor to ground I convert this to a 1 - 5 V output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question how can I change the 0V reference, so I can use the full spectrum&#xA;I found a way to change the 5V reference (analogReference()).&#xA;Is it possible to change the 0V reference of a input to 1V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other solution to my problem is welcome as well! (As long as it doesn't involve I2C or anything which lowers my looptime drastically)&lt;/p&gt;&#xA;" OwnerUserId="10700" LastActivityDate="2015-06-22T10:44:02.693" Title="Change input reference to 1 - 5 V" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12835" PostTypeId="2" ParentId="12833" CreationDate="2015-06-22T07:14:08.480" Score="0" Body="&lt;p&gt;Maybe the code with the 5 second delay is more usefull. Because you are telling us the code you now deliver is supposed to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably using delay(5000) will work?&lt;/p&gt;&#xA;" OwnerUserId="10700" LastActivityDate="2015-06-22T07:14:08.480" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12836" PostTypeId="2" ParentId="12833" CreationDate="2015-06-22T08:23:43.177" Score="2" Body="&lt;p&gt;Normally you use state machine for this kind of programming: you have a&#xA;&lt;code&gt;state&lt;/code&gt; variable that remembers what you are doing, and depending on the&#xA;current state you decide what to do next. Below is an example with two&#xA;states. I have embedded a few assumptions about the wiring of your motor&#xA;and your switches, which may be wrong, so you have to check the code.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static enum {MOVING_CW, MOVING_CCW} state;&#xA;&#xA;    switch (state) {&#xA;    case MOVING_CW:&#xA;        if (digitalRead(LM2) == LOW) {  // hit switch&#xA;            digitalWrite(CW, LOW);      // stop&#xA;            delay(5000);&#xA;            digitalWrite(CCW, HIGH);    // restart&#xA;            state = MOVING_CCW;&#xA;        }&#xA;        break;&#xA;    case MOVING_CCW:&#xA;        if (digitalRead(LM1) == LOW) {  // hit switch&#xA;            digitalWrite(CCW, LOW);     // stop&#xA;            delay(5000);&#xA;            digitalWrite(CW, HIGH);     // restart&#xA;            state = MOVING_CW;&#xA;        }&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will start in the &lt;code&gt;MOVING_CW&lt;/code&gt; state, but you have to actually start&#xA;the movement in &lt;code&gt;setup()&lt;/code&gt;. It has the drawback of having long delay()s in&#xA;the loop, which is undesirable if you have other tasks to perform. These&#xA;delays can be removed by “remembering” that you are waiting as two extra&#xA;states:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static enum {MOVING_CW, MOVING_CCW, STOPPED_CW, STOPPED_CCW} state;&#xA;    static unsigned long time_stopped;&#xA;    unsigned long now = millis();&#xA;&#xA;    switch (state) {&#xA;    case MOVING_CW:&#xA;        if (digitalRead(LM2) == LOW) {  // hit switch&#xA;            digitalWrite(CW, LOW);      // stop&#xA;            state = STOPPED_CW;&#xA;            time_stopped = now;&#xA;        }&#xA;        break;&#xA;    case MOVING_CCW:&#xA;        if (digitalRead(LM1) == LOW) {  // hit switch&#xA;            digitalWrite(CCW, LOW);     // stop&#xA;            state = STOPPED_CCW;&#xA;            time_stopped = now;&#xA;        }&#xA;        break;&#xA;    case STOPPED_CW:&#xA;        if (now - time_stopped &amp;gt;= 5000) {&#xA;            digitalWrite(CCW, HIGH);    // restart&#xA;            state = MOVING_CCW;&#xA;        }&#xA;        break;&#xA;    case STOPPED_CCW:&#xA;        if (now - time_stopped &amp;gt;= 5000) {&#xA;            digitalWrite(CW, HIGH);     // restart&#xA;            state = MOVING_CW;&#xA;        }&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-22T08:57:33.197" LastActivityDate="2015-06-22T08:57:33.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12837" PostTypeId="2" ParentId="12828" CreationDate="2015-06-22T09:05:17.170" Score="1" Body="&lt;p&gt;I can pretty much categorically say you won't get it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a similar board here with the same SMSC (now owned by Microchip) chip on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interface is USB plus some other signals.  I have managed to identify the USB portion of the interface on mine, but not the other signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SMSC chip has the option of using an external ROM chip to store its program, and Dell love to do that.  So, it has a custom firmware which means it doesn't get recognized by my computer without Dell's specific drivers installed.  So it's useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a very very slim chance you may get it working with a USB Host Shield, but unlikely - and at the end of the day, what's the point?  It's just an SD card reader.  Wire an SD card socket direct to the Arduino and save yourself both the headaches of trying to work it out and also the massive pointless expense in buying the hardware you'll need to do the interfacing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-22T09:05:17.170" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12838" PostTypeId="1" CreationDate="2015-06-22T09:29:24.087" Score="0" ViewCount="906" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Moe9T.png&quot; alt=&quot;high pitch noise&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an issue with several Leonardo and Micro boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On all of my boards, there is a sawtooth of about 690mV ptp @ 4kHz on the 5V supply when powered from Vin (external power).&#xA;The frequency changes slightly when changing input voltage from 7V to 12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C12 is a capacitor on the Leonardo board that is making the acoustic noise, it is &quot;singing&quot; with the frequency of this sawtooth. It follows the voltage regulator NCP1117 for the 5V power supply generation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the schematics of the Leonardo and micro, the voltage regulator used on these boards should be the NCP1117, but on the boards I have, there is no number printed on this component, so I suspect an alternative was used, with these annoying results...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a project I have for generating audio signals, this noise was unacceptable, so I cut out the regulator and powered everything with an external LM7805. One should not power the module via USB then as long as the external power is connected!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone having the same trouble with these boards?&#xA;Other solutions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The Leonardo is a genuine Arduino board.)&lt;/p&gt;&#xA;" OwnerUserId="10231" LastEditorUserId="220" LastEditDate="2015-06-22T14:52:32.713" LastActivityDate="2017-01-06T22:02:38.763" Title="Leonardo and micro: high pitch noise when powered from Vin" Tags="|arduino-leonardo|arduino-micro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12839" PostTypeId="2" ParentId="12838" CreationDate="2015-06-22T09:40:21.237" Score="0" Body="&lt;p&gt;It does sound like the regulator is oscillating to me.  That happens when the output capacitor is of the wrong type for the regulator - the ESR is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Leonardo, when powered from 12V, is nice and clean.  The regulator has 7CE50Z on it.  I do notice, on the layout of the Leonardo, that the output capacitor is somewhat further away from the regulator than I like to put it - though that shouldn't cause that much of a problem.  800mV is way too much to be considered normal under &lt;em&gt;any&lt;/em&gt; circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the power source you are using?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-22T09:40:21.237" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12840" PostTypeId="2" ParentId="12834" CreationDate="2015-06-22T10:44:02.693" Score="6" Body="&lt;p&gt;The ADC is ground-referenced, and there's no way to change that. The question is if that's necessary. The ADC has a 10-bit resolution, that's good for 1024 different levels between 0 and 5 V. If you convert the 4-20mA with a 250 &amp;Omega; resistor to a 1-5 V range you still can discriminate between more than 800 different values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not enough you can use a differential amplifier to subtract 1 V:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wV1zG.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By choosing R3 = 1.25 R1 you convert the 0-4 V range to a 0-5 V range.&lt;/p&gt;&#xA;" OwnerUserId="6834" LastActivityDate="2015-06-22T10:44:02.693" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12842" PostTypeId="1" AcceptedAnswerId="12844" CreationDate="2015-06-22T13:58:52.397" Score="5" ViewCount="19635" Body="&lt;p&gt;I'm starting in the arduino world and I'm building an autonomous smart vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, after some weeks building and adjusting the vehicle, I got to a point in this project that I want to log it's movements. Talking with a friend, he showed me an Gyro/Accel sensor and I really think that it would be an awesome upgrade to my vehicle&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading some articles, I'm failing to understand the difference between an &lt;strong&gt;Accelerometer Sensor&lt;/strong&gt;, a &lt;strong&gt;Gyro Sensor&lt;/strong&gt; and a &lt;strong&gt;Magnetometer Sensor&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is the main difference between those sensors?&lt;/p&gt;&#xA;" OwnerUserId="3404" LastEditorUserId="3404" LastEditDate="2015-06-22T16:31:52.930" LastActivityDate="2019-04-19T21:52:32.107" Title="What is the difference between Accelerometer, Gyro, and Magnetometer Sensor?" Tags="|sensors|accelerometer|gyroscope|magnetometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12843" PostTypeId="2" ParentId="12842" CreationDate="2015-06-22T14:31:27.607" Score="4" Body="&lt;p&gt;The main difference is the way they operate and what they sense.  In other words, they are all very very different things.  Yet they can all measure motion in some way.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An accelerometer senses both the gravitational pull of the earth and the inertia / momentum of the motion of the device&lt;/li&gt;&#xA;&lt;li&gt;A magnetometer senses the earth's magnetic field to get a compass heading.&lt;/li&gt;&#xA;&lt;li&gt;A gyroscope senses &lt;em&gt;changes&lt;/em&gt; in twist and angle.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They can all give information about motion and attitude, but each has both benefits and drawbacks compared to the others.  Some drift more than others, some are slower or lower resolution, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So generally all three are used together to get the benefits of them all and, to some extent, negate the drawbacks of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, a gyroscope isn't good at measuring inertia, but it is good at measuring changes in angles.  But those changes in angles drift over time and you lose accuracy.  A magnetometer is good at giving you an exact angle, but it takes longer to get an accurate result, and it's not good at fine changes in angle.  So a magnetometer is used to correct the drift of the gyroscope, and an accelerometer is used to measure inertia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to sum up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Accelerometer for changes in speed&lt;/li&gt;&#xA;&lt;li&gt;Gyroscope for changes in angle&lt;/li&gt;&#xA;&lt;li&gt;Magnetometer to correct the gyroscope&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-22T14:31:27.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12844" PostTypeId="2" ParentId="12842" CreationDate="2015-06-22T16:02:20.370" Score="5" Body="&lt;p&gt;The Accelerometer measures total acceleration on the vehicle, including the static acceleration from gravity it would experience even when its not moving. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The magnetometer measures the magnetic field around the robot, including the static magnetic field pointing approximately north caused by the earth. Being placed in/around a metal frame or any large motors, diving over/around underground metal pipes or electrical equipment will all make large and noticeable effects on its measurements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Gyroscope measures your instantaneous angular momentum around each axis, basically how fast its rotating. Note that angular momentum is not directly compatible with euler angles, but works out similarly for small angles. Very high quality signal in the short term because there isn't much noise, but since your angular position has to be integrated off of the gyroscope, it will build up error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gravity is your best reference for angular position, because it doesn't drift like the gyroscope and since your robot is operating in (and causing) a sea of magnetic disturbances, using north is risky. It will not work if you are experiencing a significant acceleration though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest code would just use the accelerometer for rotations around x and y, the mag for z, and ignore disturbances. The basic idea is &quot;I know gravity is actually down, but its being measured on the accel X axis, so I must be pitched by some amount&quot;. The Better sensor fusion algorithms will use the accelerometer/magnetometer to correct for drift in the gyro, but get most of its information about rotational position from the Gyroscope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tracking lateral position using a standard 9-dof IMU is not possible. Only the accelerometer measures lateral motion at all, and it needs to be integrated twice to get position. Error builds so fast your position estimate is complete garbage within seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tracking angular position is possible because all three sensors measure it in one way or another. Angles are tricky though because they are not commutative. If the gyro measures a 90 degree yaw then a 90 degree pitch from north, you are facing down; if it measures a 90 degree pitch and then a 90 degree yaw from north, your facing east turned on your side. Be careful with the math, or download an arduino IMU library that has it taken care of for you.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-12-12T19:19:38.633" LastActivityDate="2015-12-12T19:19:38.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12845" PostTypeId="1" CreationDate="2015-06-22T17:52:23.157" Score="-1" ViewCount="810" Body="&lt;p&gt;I have a robot with an Arduino Mega that gets data from a bluetooth module and sends it to an Arduino Leonardo to activate some functions. It all works amazing but only if the boards are connected to my computer. As soon as I disconnect them and power them from their own batteries, the serial communications seems to stop working. When I connect it to the PC again the communication between the Arduinos begins working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why this is happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Mega is powered by a 9V battery and the Leonardo by 4x AA (6V). On the Mega I use TX/RX(2) for communication with the BT module and TX/RX(3) for communication to the Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="10787" LastEditorUserId="10003" LastEditDate="2015-06-25T14:44:18.333" LastActivityDate="2015-06-25T14:44:18.333" Title="Serial communication not working between two Arduinos unless connected to computer" Tags="|serial|arduino-mega|arduino-leonardo|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12846" PostTypeId="2" ParentId="12820" CreationDate="2015-06-22T18:23:54.680" Score="2" Body="&lt;p&gt;While it would have been nice to see your research rather then having to spend some time finding this information myself, I did find this &lt;a href=&quot;http://www.instructables.com/id/Add-Ethernet-to-any-Arduino-project-for-less-than-/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Add-Ethernet-to-any-Arduino-project-for-less-than-/&lt;/a&gt; from what I can see this should be compatible to any arduino as long as it has 3 volt pin and 4 i/o pins. While the arduino micro doesn't have a 3v3 pin, as far as I know, that shouldn't be an issue as long as you can drop the voltage from the 5 volt pin, this module should work for you.&lt;/p&gt;&#xA;" OwnerUserId="10788" LastActivityDate="2015-06-22T18:23:54.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12847" PostTypeId="2" ParentId="4107" CreationDate="2015-06-22T19:18:45.530" Score="2" Body="&lt;p&gt;Considering the fact that from a &lt;em&gt;functional point of view&lt;/em&gt;, you just want &lt;strong&gt;to have more digital inputs, I would propose to use a &lt;code&gt;Parallel-In Serial-Out Expander&lt;/code&gt;&lt;/strong&gt;, (e.g. &lt;code&gt;CD4021B&lt;/code&gt; or &lt;code&gt;74HC165&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This IC (i.e. &lt;code&gt;74HC165&lt;/code&gt;) has 8 digital inputs, that can be 'shifted' and send to your Arduino using just 2 wires. Arduino has a built-in function for this (i.e. &lt;code&gt;shiftIn&lt;/code&gt;) to read the input and to convert it to a byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 8 inputs is not enough, then you can chain multiple IC to create 16, 24 ... digital inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an official &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ShiftIn&quot; rel=&quot;nofollow&quot;&gt;tutorial for the CD4021B&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if this is a requirement, but if you want to register &lt;strong&gt;multiple key-presses at the same time&lt;/strong&gt;, then this is a really good strategy.&lt;/p&gt;&#xA;" OwnerUserId="10224" LastActivityDate="2015-06-22T19:18:45.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12848" PostTypeId="2" ParentId="4107" CreationDate="2015-06-22T19:34:15.707" Score="0" Body="&lt;p&gt;I really do not know your level of experience, so please, ignore this if not applicable;&#xA;Most cases of a push button will not need an interrupt. It is a human pushing the button and so precise timing is no where close to needing an interrupt.  You would only need an interrupt if you wanted to actually interrupt some looping code. And since timing (of a human by definition) is not that great, simply checking for a button press in your looping code will always be good enough.&#xA;That being said, the common resistor networks you have read about will work adequately.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;psuedo code;&#xA;void loop()&#xA;{&#xA;  int btn = analogRead(pin);&#xA;  if (btn &amp;gt; pin1Level) &#xA;  {&#xA;    if (btn &amp;gt; pin5level) DoPin5();  &#xA;    else if (btn &amp;gt; pin3level) DoPin3();&#xA;    else DoPin1();&#xA;  }&#xA;  doOtherStuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-06-22T19:34:15.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12849" PostTypeId="1" CreationDate="2015-06-22T21:03:57.000" Score="0" ViewCount="130" Body="&lt;p&gt;I'm trying to read either high or low from a pressure switch, I do have a pulldown resistor attached but even if I plug in a wire with nothing on it i get a false high. I've changed pins, tried adding &lt;code&gt;INPUT_PULLUP&lt;/code&gt; to the program but it it reads false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code i'm using is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int mainPump = 2;&#xA;const int prePump = 3;&#xA;const int idleValve = 4;&#xA;const int chemTankLow = 5;&#xA;const int chemTankHigh = 6;&#xA;int pressure = 8; //7 originally removed const&#xA;const int chemValve = A7;&#xA;const int mem2 = A6;&#xA;const int mem3 = A5;&#xA;const int mem4 = A4;&#xA;const int mem5 = A3;&#xA;int tankLow = 0;&#xA;int tankHigh = 0;&#xA;int pressureFault = 0;&#xA;int lpe = 0;&#xA;int maxlpe = 2;&#xA;unsigned long timer[10]; //number of timers needed&#xA;byte timerState[10]; //store timers&#xA;int goNoGo = 0;&#xA;int readVoltage = 0;&#xA;int var = 0;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(idleValve, OUTPUT);&#xA;  pinMode(prePump, OUTPUT);&#xA;  pinMode(mainPump, OUTPUT);&#xA;  digitalWrite(mainPump, HIGH);&#xA;  pinMode(pressure, INPUT);   //removed _PULLUP after input&#xA;  pinMode(chemTankLow, INPUT);&#xA;  pinMode(chemTankHigh, INPUT);&#xA;  pinMode(chemValve, OUTPUT);&#xA;  pinMode(mem2, OUTPUT);&#xA;  pinMode(mem3, OUTPUT);&#xA;  pinMode(mem4, OUTPUT);&#xA;  pinMode(mem5, OUTPUT);&#xA;&#xA;&#xA;  digitalWrite(mem2, HIGH);&#xA;  digitalWrite(mem3, HIGH);&#xA;  digitalWrite(mem4, HIGH);&#xA;  digitalWrite(mem5, HIGH);&#xA;  digitalWrite(chemValve, HIGH);&#xA;  digitalWrite(idleValve, HIGH);&#xA;  digitalWrite(prePump, HIGH);&#xA;  digitalWrite(prePump, HIGH);&#xA;  digitalWrite(idleValve, HIGH);&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;       tankLow = digitalRead(5);&#xA;   tankHigh = digitalRead(6);&#xA;&#xA;  if (tankLow == LOW &amp;amp;&amp;amp; tankHigh == LOW){ //start day tank refill&#xA;   digitalWrite(A7, LOW);&#xA;  }&#xA;  if (tankLow == HIGH &amp;amp;&amp;amp; tankHigh == HIGH){&#xA;    digitalWrite(A7, HIGH);&#xA;  }&#xA;  static int state = 1; // initial state is 1, the &quot;idle&quot; state.&#xA;  static unsigned long ts;&#xA;&#xA;  switch (state)&#xA;  {&#xA;    case 1:&#xA;    ts = millis();&#xA;&#xA;  if (delayMilliSeconds(1, 6000)){//600000&#xA;&#xA;  digitalWrite(prePump, LOW);&#xA;&#xA;  goNoGo = digitalRead(mainPump);&#xA;  if (goNoGo == LOW) {&#xA;&#xA;    digitalWrite(idleValve, HIGH);&#xA;  }&#xA;    else {&#xA;      digitalWrite(idleValve, LOW);&#xA;          digitalWrite(mem2, LOW);&#xA;    digitalWrite(mem3, LOW);&#xA;    digitalWrite(mem4, LOW);&#xA;    digitalWrite(mem5, LOW);&#xA;    }&#xA;&#xA;        readVoltage= digitalRead(idleValve);&#xA;    if(readVoltage==LOW){&#xA;&#xA;    delay(4000); // wait time motors to stablize&#xA;    // read the input on analog pin 0:&#xA;    int sensorValue = analogRead(A0);&#xA;    // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):&#xA;    float voltage = sensorValue * (4.83 / 1023.0);&#xA;&#xA;    if (voltage &amp;gt;= 2.00) &#xA;    {&#xA;      state = 2;&#xA;    } &#xA;&#xA;&#xA;    else {&#xA;      delay(56000); //on time for test&#xA;    //  if (delayMilliSeconds(2, 51994)){&#xA;    digitalWrite(mem2, HIGH);&#xA;    digitalWrite(mem3, HIGH);&#xA;    digitalWrite(mem4, HIGH);&#xA;    digitalWrite(mem5, HIGH);&#xA;&#xA;     digitalWrite(idleValve, HIGH);&#xA;      digitalWrite(prePump, HIGH);&#xA;      digitalWrite(mainPump, HIGH);&#xA;    }&#xA;    }&#xA;&#xA;}&#xA;//} for if timer&#xA;break;&#xA;&#xA;    case 2:&#xA;       ts = millis();&#xA;      digitalWrite(mainPump, LOW);&#xA;      digitalWrite(idleValve, HIGH);&#xA;       digitalWrite(mem2, HIGH);&#xA;        digitalWrite(mem3, HIGH);&#xA;        digitalWrite(mem4, HIGH);&#xA;        digitalWrite(mem5, HIGH);&#xA;        delay(20000);&#xA;        state = 3;&#xA;&#xA;        break;&#xA;&#xA;&#xA;        case 3:&#xA;&#xA;      digitalWrite(mainPump, LOW);&#xA;      digitalWrite(idleValve, HIGH);&#xA;       digitalWrite(mem2, HIGH);&#xA;        digitalWrite(mem3, HIGH);&#xA;        digitalWrite(mem4, HIGH);&#xA;        digitalWrite(mem5, HIGH);&#xA;&#xA;      pressureFault = digitalRead(pressure);&#xA;  if (pressureFault == HIGH){ &#xA;&#xA;    state = 4; &#xA;  } &#xA;   if (millis() - ts &amp;gt; 3600000){&#xA;    state = 5;&#xA;  }&#xA;&#xA;&#xA;&#xA;   break;&#xA;&#xA;   case 4:&#xA;   digitalWrite(mainPump, HIGH);&#xA;   digitalWrite(prePump, LOW);&#xA;   digitalWrite(idleValve, LOW);&#xA;      digitalWrite(mem2, LOW);&#xA;    digitalWrite(mem3, LOW);&#xA;    digitalWrite(mem4, LOW);&#xA;    digitalWrite(mem5, LOW);&#xA;    delay(3000);&#xA;    digitalWrite(mainPump, HIGH);&#xA;   digitalWrite(prePump, HIGH);&#xA;   digitalWrite(idleValve, HIGH);&#xA;      digitalWrite(mem2, HIGH);&#xA;    digitalWrite(mem3, HIGH);&#xA;    digitalWrite(mem4, HIGH);&#xA;    digitalWrite(mem5, HIGH);&#xA;    delay(600); //60000&#xA;    state = 1;&#xA;&#xA;    break;&#xA;&#xA;    case 5:&#xA;    ts = millis();&#xA;        digitalWrite(idleValve,LOW);&#xA;        digitalWrite(prePump,LOW);&#xA;         digitalWrite(mainPump, HIGH);&#xA;           delay(60000); //60000 for standard&#xA;           digitalWrite(mem2, LOW);&#xA;           delay(60000);&#xA;           digitalWrite(mem2, HIGH);&#xA;           digitalWrite(mem3, LOW);&#xA;           delay(60000);&#xA;           digitalWrite(mem3, HIGH);&#xA;           digitalWrite(mem4, LOW);&#xA;           delay(60000);&#xA;           digitalWrite(mem4, HIGH);&#xA;           digitalWrite(mem5, LOW);&#xA;           delay(60000);&#xA;           digitalWrite(mem5, HIGH);&#xA;&#xA;           delay(1000);   // leave this time&#xA;         digitalWrite(idleValve, HIGH);&#xA;         digitalWrite(mainPump, LOW);&#xA;       state = 2;&#xA;         break;&#xA;         default:&#xA;&#xA;         state = 1; &#xA;&#xA;         break;&#xA;&#xA;&#xA;  } //switch&#xA;} //loop&#xA;&#xA;&#xA;&#xA;&#xA;int delayMilliSeconds(int timerNumber,unsigned long delaytime){&#xA;  unsigned long timeTaken;&#xA;  if (timerState[timerNumber]==0){    //If the timer has been reset (which means timer (state ==0) then save millis() to the same number timer, &#xA;    timer[timerNumber]=millis();&#xA;    timerState[timerNumber]=1;      //now we want mark this timer &quot;not reset&quot; so that next time through it doesn't get changed.&#xA;  }&#xA;  if (millis()&amp;gt; timer[timerNumber]){&#xA;    timeTaken=millis()+1-timer[timerNumber];    //here we see how much time has passed&#xA;  }&#xA;  else{&#xA;    timeTaken=millis()+2+(4294967295-timer[timerNumber]);    //if the timer rolled over (more than 48 days passed)then this line accounts for that&#xA;  }&#xA;  if (timeTaken&amp;gt;=delaytime) {          //here we make it easy to wrap the code we want to time in an &quot;IF&quot; statement, if not then it isn't and so doesn't get run.&#xA;     timerState[timerNumber]=0;  //once enough time has passed the timer is marked reset.&#xA;     return 1;                          //if enough time has passed the &quot;IF&quot; statement is true&#xA;  }&#xA;  else {                               //if enough time has not passed then the &quot;if&quot; statement will not be true.&#xA;    return 0;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for wiring it is as basic as it gets 3.3v pin off the arduino to a pressure switch and then back to the arduino . but i'm not even making it to the switch before i have an issue literally plug in a 3ft wire not connected to anything and it goes to case 4&#xA;I've tried setting the code up to go to case 4 if it detects a LOW but hasn't changed my issue.&lt;/p&gt;&#xA;" OwnerUserId="10557" LastEditorUserId="10557" LastEditDate="2015-06-23T15:58:34.490" LastActivityDate="2016-03-25T23:11:51.953" Title="I am having an issue reading a HIGH LOW signal from a pressure switch" Tags="|programming|sensors|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12851" PostTypeId="2" ParentId="9543" CreationDate="2015-06-23T05:36:54.987" Score="1" Body="&lt;p&gt;There are a number of places in the standard Wire library where the code goes into a tight loop waiting for an interrupt to occur. If that is missed for some reason, it will loop indefinitely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By removing power from one of your devices you may be introducing electrical conditions that prevent the I2C messages from being transmitted properly (possibly just noise). Alternatively the device may parasitically power up from the SDA/SCL data and then behave in unpredictable ways. It is probably unwise to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an alternative I2C master library at &lt;a href=&quot;http://dsscircuits.com/articles/arduino-i2c-master-library&quot; rel=&quot;nofollow&quot;&gt;http://dsscircuits.com/articles/arduino-i2c-master-library&lt;/a&gt; which does not hang (I believe it times out instead).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-23T05:36:54.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12852" PostTypeId="2" ParentId="12770" CreationDate="2015-06-23T08:09:46.520" Score="1" Body="&lt;p&gt;Okay but why is everyone arguing about const and #define. That's clearly not the real problem that the person who posted the question is asking, so i'm kind of lost. @chaaarlie2. What exactly does averaging the averages do, since the distances have already been averaged to find the correct distance.&lt;/p&gt;&#xA;" OwnerUserId="10798" LastActivityDate="2015-06-23T08:09:46.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12854" PostTypeId="1" AcceptedAnswerId="12855" CreationDate="2015-06-23T10:41:28.457" Score="0" ViewCount="1063" Body="&lt;p&gt;It took me about 4 hours to desolder an Arduino Nano I fried and solder on the new one. I'm not exactly sure how but I shorted it somehow while trying to install the nano onto my robot. I could smell a fait burning and the nano no longer powered on or allowed me to upload code via USB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put the second nano on, before properly insulating exposed wire, I fried it again!! This time I actually saw a little smoke and quickly unplugged it. The nano no longer responds to the USB, but...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this nano also being powered by an Arduino Uno. When I turned on the battery connected to the Uno, the Nano turned on and everything was working fine!! I was pretty relieved after a short spout of depression! I plugged in the USB to the Nano and I was able to upload code... only with the nano being powered from the Uno. If I turn off the battery to the Uno the Nano doesn't work with USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what happened exactly and I'm not sure what fried on my Nano but I sure am glad I have this work around instead of replacing the Nano again! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why it's doing this? What did I see smoking? Is it repairable? &lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-06-23T10:57:43.300" Title="Fried two Arduino Nano's but works when powered" Tags="|arduino-uno|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12855" PostTypeId="2" ParentId="12854" CreationDate="2015-06-23T10:57:43.300" Score="1" Body="&lt;p&gt;Judging by your list of observations:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cannot power through USB&lt;/li&gt;&#xA;&lt;li&gt;Can power from external source&lt;/li&gt;&#xA;&lt;li&gt;Can program through USB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;it is most likely that the power feed from the USB to the +5V rail has been interrupted.  There is only one component in that link - the diode D1 (an MBR0520).  That is rated at an absolute maximum constant forward current of 0.5A and most USB ports these days are capable of providing far more than that.  A short circuit on the +5V to ground would draw considerably more current than that diode can handle and the Magic Smoke™ would escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diode is on the underside of the Micro and close examination may show a small crack in the surface of it.  That is if it's still there.  I have used a similar PIC32 based board with 0.5A rated diodes on it, and a short of the power rail when powered from USB caused the diode to completely vaporise (at least I could find no trace of it afterwards).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-23T10:57:43.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12856" PostTypeId="1" AcceptedAnswerId="12863" CreationDate="2015-06-23T11:32:13.610" Score="0" ViewCount="170" Body="&lt;p&gt;I want to make an AIR mouse using Arduino&#xA;and accelerometer, for this i used USB to TTL&#xA;converter i have done everything successfully&#xA;but can anyone tell me how use it in computer.&#xA;I mean i don't know how to make computer&#xA;application for this mouse. please suggest me&#xA;any application for this. And give any idea for&#xA;&quot;how can i use Bluetooth for this.&quot;&lt;/p&gt;&#xA;" OwnerUserId="10801" LastActivityDate="2015-07-15T18:02:40.547" Title="is any windows application available for accelerometer based computer mouse" Tags="|arduino-uno|accelerometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12860" PostTypeId="1" CreationDate="2015-06-23T12:03:28.873" Score="2" ViewCount="3673" Body="&lt;p&gt;I have searched the Internet and found the following circuit to use with my phototransistor but it is not working, I can say so because all analog input i get is 1023 even if i have covered it totally, I have include the phototransistor and the diagram can anyone tell why is it not working!&#xA;I used this webpage to check my sensor and it works-&lt;a href=&quot;https://learn.adafruit.com/ir-sensor/testing-an-ir-sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;I used this page&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used 10kohm resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lGika.jpg&quot; alt=&quot;Image of circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://xmghdm.en.ec21.com/IR_LED_Infrared_LED_IR--3179904_3180358.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is my phototransistor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JnfIZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10522" LastEditorUserId="10522" LastEditDate="2015-06-23T16:25:07.953" LastActivityDate="2021-08-15T09:33:18.203" Title="How do I use a 3 legged phototransistor?" Tags="|arduino-uno|sensors|transistor|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="12862" PostTypeId="2" ParentId="12849" CreationDate="2015-06-23T14:27:01.220" Score="1" Body="&lt;p&gt;As a hint.  Start by removing the stuff you added an just try to detect a grounding of your input pin (I'm assuming digitalRead(pressure) is the standard read the digital value of a pin and not some funky function you've written)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use some code like this to test your hard ware&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int    pressure;   &#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);  //Start a serial monitor to see the results&#xA;    pressure = 4;  // Assumes your pressure input is pin 4 &#xA;                   // change if need be&#xA;    pinMode(pressure,INPUT_PULLUP);  //Sets put to input with pullup&#xA;    digitalWrite(pressure,HIGH);      //Activates pullup&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;     if (digitalRead(pressure))&#xA;     {&#xA;          Serial.println(&quot;Pin is High&quot;);&#xA;     }&#xA;     else&#xA;     {&#xA;          Serial.println(&quot;Pin is low&quot;);&#xA;     }&#xA;     delay(1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now compile, upload and activate the serial monitor.  Every second you will get the read of the pin on the monitor.  See if grounding the pin is detected.  If not, you may have popped the port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW.  3 ft of wire will need some filtering and protection.  That will pick up a lot of noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="10807" LastActivityDate="2015-06-23T14:27:01.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12863" PostTypeId="2" ParentId="12856" CreationDate="2015-06-23T15:18:22.790" Score="0" Body="&lt;p&gt;......................................&#xA;......................................&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-07-15T18:02:40.547" LastActivityDate="2015-07-15T18:02:40.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12864" PostTypeId="2" ParentId="12860" CreationDate="2015-06-23T16:39:18.777" Score="1" Body="&lt;p&gt;A reasonably generic data sheet is &lt;a href=&quot;http://www.datasheetarchive.com/dl/Datasheets-SL3/DSASL0044436.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;HERE&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;That is for an AT156 but yours may be an AT138/HT138 based on an ad some years ago from the same seller when they said they had 10,000 for sale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basic information here and more in the data sheet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iMyu8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-06-23T16:39:18.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12865" PostTypeId="1" CreationDate="2015-06-23T10:51:06.750" Score="0" ViewCount="45" Body="&lt;p&gt;I want to make an AIR mouse using Arduino and accelerometer, for this i used USB to TTL converter i have done everything successfully but can anyone tell me how use it in computer. I mean i don't know how to make computer application for this mouse. please suggest me any application for this. And give any idea for &quot;how can i use Bluetooth for this.&quot;&lt;/p&gt;&#xA;" OwnerUserId="10801" OwnerDisplayName="Nikhil Kumawat" LastActivityDate="2015-06-23T16:41:24.843" Title="is any windows application available for accelerometer based computer mouse" Tags="|accelerometer|" AnswerCount="1" CommentCount="1" ClosedDate="2015-06-24T00:02:02.470" ContentLicense="CC BY-SA 3.0" />
  <row Id="12866" PostTypeId="2" ParentId="12865" CreationDate="2015-06-23T11:07:23.783" Score="1" Body="&lt;p&gt;try &quot;remotemouse.exe&quot;&#xA;its a open source application you can modify the codes according to your requirement&lt;/p&gt;&#xA;" OwnerUserId="10802" OwnerDisplayName="Manish Suthar" LastActivityDate="2015-06-23T11:07:23.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12867" PostTypeId="2" ParentId="7991" CreationDate="2015-06-23T16:49:07.820" Score="-1" Body="&lt;p&gt;Hey thought I'd pitch in.&#xA;I was having quite a few issues in trying to control an led using hc 05 from an android phone.&#xA;I was using SoftwareSerial. It didn't work.&#xA;The board is an arduino mega 2560. &#xA;Finally, I got it. SoftwareSerial turns digital pins to tx and rx com pins.&#xA;Make sure to use digital pins on the board to communicate when your using SoftwareSerial.&#xA;Hope it helps...&lt;/p&gt;&#xA;" OwnerUserId="10810" LastActivityDate="2015-06-23T16:49:07.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12868" PostTypeId="2" ParentId="104" CreationDate="2015-06-23T19:13:07.433" Score="-1" Body="&lt;p&gt;Yes, you can upload over BLE with free(mium) iOS app - Apploader&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.apploader.info&quot; rel=&quot;nofollow&quot;&gt;http://www.apploader.info&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8327" LastActivityDate="2015-06-23T19:13:07.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12869" PostTypeId="1" CreationDate="2015-06-23T19:17:15.373" Score="0" ViewCount="282" Body="&lt;p&gt;I'm looking for a common &quot;wireless gadget&quot; with a rotary encoder that can be accessed by an Arduino. Background: I need a portable rotary encoder to create a simple way to control model railway locomotives. The only one I have found so far is a wireless mouse where the scroll wheel can be easily used as rotary encoder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But they usually are using USB on the PC side which is not that easy to handle by Arduino. Does anybody knows about other common &quot;wireless gadgets&quot;?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="4628" LastEditDate="2015-11-22T17:14:43.833" LastActivityDate="2015-11-22T17:14:43.833" Title="Common wireless gadget with rotary encoder to connect with Arduino" Tags="|wireless|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12872" PostTypeId="2" ParentId="12869" CreationDate="2015-06-23T19:36:40.330" Score="1" Body="&lt;p&gt;That sounds like a candidate for building your own.  It shouldn't be too hard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's plenty of low-cost Arduino-compatible wireless modules available.  My choice for this would probably be the nRF24L01 - dirt cheap, reasonable range, well supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attach that to an Arduino Mini or Arduino Nano (for instance) and connect a rotary encoder of your choice.  Write the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add another nRF24L01 to your main Arduino to receive whatever you send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the way the nRF24L01 works you could quite easily have a number of remote modules talking to the Arduino through the same channel.  I'm sure you could think of other things you could do with that wireless channel :)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-23T19:36:40.330" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12873" PostTypeId="2" ParentId="12845" CreationDate="2015-06-23T21:37:07.957" Score="2" Body="&lt;p&gt;Voltage, Electrical Potential, Potential Difference, Electric Tension - whatever you refer to it as - is the always measured &lt;em&gt;between two points&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally of course we mean two points within one circuit, and most of the time we mean between something and the circuit's 0-Volt rail; it's implied whenever somebody quotes a voltage, unless they specifiy otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We always refer to the 0-Volt rail as 'ground', no doubt stemming from the term 'earth', which is literally a connnection into the ground itself. In the case of a battery powered circuit, the 0-volt rail is only 0 Volts &lt;em&gt;referenced to the rest of the circuit&lt;/em&gt;. In such a circumstance, the circuit's ground is said to be &lt;strong&gt;floating&lt;/strong&gt; when referenced to another circuit. Thus, two circuits with independent power supplies and no interconnection cannot be compared to one another in sense of voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This typically doesn't matter, but when you need to interconnect independently-powered circuits you run into a problem. As both grounds are floating, any other voltage on each circuit is referenced to said floating voltage, and therefore is also floating. This makes wired communication between them impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you create a voltage reference between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply connect the ground rails of each together; the cicruits are then referenced to one another at 0 Volts. It doesn't have to be the ground rails that are connected - any two points connected together will allow you to reference any point on board A to board B and get a correct potential difference. However, it's pretty useless doing that except in some odd situations.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-23T21:37:07.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12874" PostTypeId="2" ParentId="1380" CreationDate="2015-06-23T21:46:22.647" Score="2" Body="&lt;p&gt;I have a Micro and Ubuntu 14.04. I have successfully uploaded sketches to the Micro using IDE 1.0.6. Thus that combination should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you get the sketch compiling OK. Then hold down the Reset button on the Micro, start an upload with your other hand, and release Reset when it says &quot;Uploading&quot;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Try typing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;lsusb | grep Arduino&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found with a sketch uploaded which opens the Serial port:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Bus 003 Device 087: ID 2341:8037 Arduino SA&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you hit Reset and wait a second, then do the lsusb again you see a different device:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Bus 003 Device 086: ID 2341:0036 Arduino SA&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That one (the 0036 one) is the one it will upload to. You might get 0037 rather than 0036 because I reflashed the bootloader to be the Leonardo one, but the concept is the same.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-06-23T21:54:16.810" LastActivityDate="2015-06-23T21:54:16.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12875" PostTypeId="2" ParentId="12812" CreationDate="2015-06-23T21:51:13.547" Score="3" Body="&lt;pre&gt;&lt;code&gt;  int retunedNum = (esp8266.read() - 48) * 100;       // get first number (example: 123.. this would be &quot;1&quot;)&#xA;  retunedNum += (esp8266.read() - 48) * 10;           // get second number (example: 123.. this would be &quot;2&quot;)&#xA;  retunedNum += (esp8266.read() - 48);                // get last number (example: 123.. this would be &quot;3&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code always expects the pin number to have 3 digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of 13, it takes a space character as the last digit.&lt;br&gt;&#xA;It reads charachters '1', '3' and ' '. Their ASCII codes are 49, 51 and 32. With this, the calculated number is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(49 - 48) * 100 + (51 - 48) * 10 + (32 - 48) = 114.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With 6894, it just uses the first three digits and ignores the last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 1 or 2 digit long number you could just pad it with '0' character i.g. &quot;013&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to read an arbitrary string, you should replace the above code with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String retunedStr = &quot;&quot;;&#xA;for(;;) {&#xA;    char c = esp8266.read();&#xA;    if (c == ' ')&#xA;        break;&#xA;    retunedStr += c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And obviously replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(retunedNum);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(retunedStr);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this, you should only use letters (A-Z, a-z), numbers (0-9), dash (-) and an underscore (_) for the string.&lt;br&gt;&#xA;If you use other characters, you could have problems with the URL character encoding.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-06-23T21:51:13.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12876" PostTypeId="2" ParentId="12819" CreationDate="2015-06-23T22:08:55.783" Score="1" Body="&lt;p&gt;You just prepend the number in binary with B e.g. B01100100 which is 100 in decimal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte sequence[] = {&#xA;    B10000000,&#xA;    B01000000,&#xA;    B00100000,&#xA;    B00010000,&#xA;    B00001000,&#xA;    B00000100,&#xA;    B00000010,&#xA;    B00000001&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to check the n-th bit from the right in a number you do&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean bit_set = number &amp;amp; (1 &amp;lt;&amp;lt; (n - 1)) != 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-06-23T22:08:55.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12877" PostTypeId="2" ParentId="12782" CreationDate="2015-06-23T22:24:59.010" Score="1" Body="&lt;p&gt;The String class is slow. I would get rid of that first. I am confused about whether you are sending or receiving, or both, as your code seems to parse and then send. See this test code here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int countEnc0 = 123;&#xA;int countEnc1 = 456;&#xA;int countEnc2 = 789;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  unsigned long start = micros ();&#xA;  Serial.println(String(countEnc0) + &quot;,&quot; + String(countEnc1) + &quot;,&quot; + String(countEnc2));&#xA;  Serial.flush ();&#xA;&#xA;  Serial.print (&quot;Time taken = &quot;);&#xA;  Serial.print (micros () - start);&#xA;  Serial.println (&quot; uS&quot;);  &#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That replicates the time taken for that one line which echoes the three figures. My results were:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Time taken = 1632 uS&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, yours will be faster at the faster baud rate, but only 4 times as fast. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, 240 times that and allowing for the faster baud rate gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1632 * 240 / 4 = 97920 µS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's a fair bit of that second gone (a tenth), without even parsing anything.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-23T22:24:59.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12878" PostTypeId="2" ParentId="12869" CreationDate="2015-06-23T22:31:57.350" Score="0" Body="&lt;p&gt;In addition to @Majenko,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your device is going to talk to a PC/Laptop (or cellphone!), then HC05 or HC06 bluetooth serial module may be a better fit. You will still need to write software to receive the data, but you won't need another Arduino at the other end.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-23T22:31:57.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12879" PostTypeId="1" AcceptedAnswerId="12916" CreationDate="2015-06-24T00:37:00.290" Score="1" ViewCount="1443" Body="&lt;p&gt;I am designing a smart (or at least I hope so) onboard bicycle light system. The system will have an Arduino (currently prototyping with UNO) and a subsystem composed of a &quot;panel&quot; of buttons and leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This panel should stay at the handlebar, connected by multi-wire cable to the Arduino located elsewhere on the bicycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to read an arbitrary number of push-buttons, I plan to use CD4021 IC with &lt;code&gt;shiftIn()&lt;/code&gt; function. And, in order to turn an arbitrary number of leds on and off, I plan to use 74HC595 IC and the &lt;code&gt;shiftOut()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My doubts are: what should I consider in order to do so?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How many wires should I need to connect an arduino to the panel circuit containing the ICs? I believe it is 8 wires (two for the power, three for shifting in [latch, clock, data], and three for shifting out), right?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I use any pin I want? Or is it required to use specific pins?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is that the &quot;right way&quot; of doing this? Any suggestion or improvement is welcome!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8044" LastActivityDate="2015-06-26T04:39:41.380" Title="Using shiftin() and shiftout() with the same circuit - what to consider?" Tags="|button|digital|shift-register|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12881" PostTypeId="1" CreationDate="2015-06-24T02:16:29.063" Score="0" ViewCount="451" Body="&lt;p&gt;No matter how I rearrange this, the increment compare always returns false....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have even taken it out of the if, and put it in its own if:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buttonFSM(button *ptrButton)&#xA;{ &#xA;    int i;&#xA;    i = digitalRead(ptrButton-&amp;gt;pin); &#xA;    switch(ptrButton-&amp;gt;buttonState)&#xA;    {&#xA;    case SW_UP:&#xA;        if(i==0 &amp;amp;&amp;amp; ++ptrButton-&amp;gt;debounceTics == DBNC_TICS) //swtich went down&#xA;        {&#xA;            ptrButton-&amp;gt;buttonState = SW_DOWN;&#xA;            ptrButton-&amp;gt;debounceTics = 0;&#xA;            return SW_TRANS_UD;       &#xA;        }&#xA;        ptrButton-&amp;gt;debounceTics = 0;&#xA;        return SW_UP;&#xA;    case SW_DOWN:&#xA;        if(i==1 &amp;amp;&amp;amp; ++ptrButton-&amp;gt;debounceTics == DBNC_TICS) //switch is back up&#xA;        {&#xA;            ptrButton-&amp;gt;buttonState = SW_UP;&#xA;            ptrButton-&amp;gt;debounceTics = 0;&#xA;            return SW_TRANS_DU;       &#xA;        }&#xA;        ptrButton-&amp;gt;debounceTics = 0;&#xA;        return SW_DOWN;   &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10817" LastEditorUserId="10003" LastEditDate="2015-06-24T05:58:22.977" LastActivityDate="2015-08-24T06:11:47.387" Title="Increment in switch statement not working" Tags="|arduino-mega|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12882" PostTypeId="1" AcceptedAnswerId="12889" CreationDate="2015-06-24T09:29:03.533" Score="8" ViewCount="68740" Body="&lt;p&gt;I'm confused about how and when to use the reset button on the Arduino. Do I simply press the button while it is on? Is it simply restarting the board or clearing the uploaded code as well? Currently when I press the button while my Uno is powered it does absolutely nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using this board for many weeks with no problem and just now I have been getting this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I cannot upload code. I tried using the reset button but I see nothing happening on the board, no blink, no flicker, nothing indicating something was reset.  &lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2017-06-06T10:59:07.607" Title="How does the reset button work on the Arduino?" Tags="|arduino-uno|avrdude|reset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12884" PostTypeId="1" CreationDate="2015-06-24T10:33:17.460" Score="1" ViewCount="1649" Body="&lt;p&gt;I am building a pH meter and having a real close look into the analog components, and reading the Arduino documentation for &lt;code&gt;analogRead()&lt;/code&gt;.&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/AnalogRead&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see it says the Arduino, in my case an 8-bit AVR ATmega328 Arduino Uno,&#xA;yields a resolution between readings of: 5 volts / 1024 units or, .0049.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is whether that is accurate, or even possible. How can an 8-bit MCU provide a 10-bit analog read? how does that work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shouldn't the analog read be 2^8 or 256?&lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="26916" LastEditDate="2017-09-09T07:50:12.363" LastActivityDate="2017-09-09T07:50:12.363" Title="how does an 8-bit AVR do 10-bit analog read?" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12885" PostTypeId="1" CreationDate="2015-06-24T10:37:12.537" Score="0" ViewCount="30067" Body="&lt;p&gt;Goodafternoon,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to read values form a microphone (Adafruit MAX9814) connected to the Analog port A0 from Arduino and store the values that are incoming inside an array. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the values are stored in the array, I want to read out the values and store the number that is repeated most time in a variable. Is this possible and how to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came up with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int micPin = A0;&#xA;int soundArray[10];&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  pinMode(micPin, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int micValue = analogRead(micPin);&#xA;  Serial.println(micValue, DEC);&#xA;  //delay(400);&#xA;&#xA;  for (int i = 0; i &amp;gt; 10; i++) {&#xA;    soundArray[i] = micValue;&#xA;    Serial.println(soundArray[i]);&#xA;  }&#xA;  delay(1000);&#xA;  Serial.println(&quot;End of for loop&quot;);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem now is that a value of the microphone will be repeated 10 times. So I will receive 10 times the number 234 for example. See image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not what I want. I want to get different numbers in the array of that moment.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/sE0ms.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can help me out.&#xA;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="10822" LastEditorUserId="10822" LastEditDate="2015-06-24T12:00:57.657" LastActivityDate="2015-06-24T12:20:59.630" Title="How to store values inside an empty array and get the average integer? [UPDATED QUESTION]" Tags="|arduino-uno|serial|sensors|" AnswerCount="2" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12886" PostTypeId="2" ParentId="12885" CreationDate="2015-06-24T11:41:20.840" Score="1" Body="&lt;p&gt;The error message is correct. You did not define the size of the array.&#xA;You have 3 choices:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Declare it with a constant length&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int foo[10];&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Declare it and initalize it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int foo[] = {0,1,2,3,4,5,6,7,8,9};&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Declare it dynamic as pointer and alloc or realloc the mem by yourself (this is not recommended (realloc) because of possible heap memory fragmentation)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int &lt;em&gt;foo;&#xA;int size = 10;&#xA;foo = (int&lt;/em&gt;)malloc(size * sizeof(int));&#xA;free(foo);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As reference:&#xA;&lt;a href=&quot;http://www.arduino.cc/en/pmwiki.php?n=Reference/Array&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/pmwiki.php?n=Reference/Array&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10823" LastEditorUserId="10823" LastEditDate="2015-06-24T11:47:15.393" LastActivityDate="2015-06-24T11:47:15.393" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12888" PostTypeId="2" ParentId="12884" CreationDate="2015-06-24T11:52:30.597" Score="4" Body="&lt;p&gt;It can do a 10-bit reading quite simply - because the ADC is a 10-bit ADC.  The CPU register size doesn't dictate what it can communicate with, either internally or externally.  The only thing it dictates is how big a number it can cope with at any one time.  Because of this the 10-bit result of the ADC is spread across two registers - 2 bits in the &quot;high&quot; ADC result register, and 8 bits in the &quot;low&quot; ADC result register.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-24T11:52:30.597" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12889" PostTypeId="2" ParentId="12882" CreationDate="2015-06-24T11:56:01.720" Score="10" Body="&lt;p&gt;The reset button does pretty much the same as unplugging the board and plugging it back in.  It restarts your program from the beginning.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing happens when you program the board - the USB interface presses the reset button for you.  That then enters the bootloader for a second or two so it can try and program it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you reset the board the LED on pin 13 should flash a couple of times while it's in the bootloader before it runs whatever program you have programmed in.  If that LED doesn't flash when you press the reset button then there is a serious fault with your board which will take further diagnostic.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you have anything else plugged into the Arduino then unplug it.&lt;/li&gt;&#xA;&lt;li&gt;Try powering the Arduino from different power supplies.&lt;/li&gt;&#xA;&lt;li&gt;If you have another Arduino or an AVR programmer try re-flashing the bootloader.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-24T11:56:01.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12890" PostTypeId="2" ParentId="12885" CreationDate="2015-06-24T12:20:59.630" Score="1" Body="&lt;p&gt;There are three main sorts of &quot;average&quot; used normally in Maths:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mean: This is the most common meaning of Average. It is the mathematical average of all the values in the set - the sum of all the values divided by the number of values.&lt;/li&gt;&#xA;&lt;li&gt;Mode: This is the &quot;most common&quot; value in a set of values.  For the set {1, 2, 3, 4, 3, 5, 3, 1, 7, 3} the &quot;mode&quot; would be 3 since there are more 3's than any other number.&lt;/li&gt;&#xA;&lt;li&gt;Median: This is the middle value of a set of values.  If there are 5 values and they are sorted into ascending order the &quot;median&quot; would be the third (middle) value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By your comments it sounds like &quot;mode&quot; is what you are after - the most common number in your set of values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's quite easy to work out which is the most common number in a set if you are willing to loop through that set enough times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an &lt;a href=&quot;https://github.com/MajenkoLibraries/Average&quot; rel=&quot;nofollow&quot;&gt;Average library&lt;/a&gt; that can do it for you.  The main part of the &lt;code&gt;mode()&lt;/code&gt; function of that library looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;most = _store[0];&#xA;mostcount = 1;&#xA;for(pos = 0; pos &amp;lt; _count; pos++) {&#xA;    current = _store[pos];&#xA;    currentcount = 0;&#xA;    for(inner = pos + 1; inner &amp;lt; _count; inner++) {&#xA;        if(_store[inner] == current) {&#xA;            currentcount++;&#xA;        }&#xA;    }&#xA;    if(currentcount &amp;gt; mostcount) {&#xA;        most = current;&#xA;        mostcount = currentcount;&#xA;    }&#xA;    // If we have less array slices left than the current&#xA;    // maximum count, then there is no room left to find&#xA;    // a bigger count.  We have finished early and we can&#xA;    // go home.&#xA;    if(_count - pos &amp;lt; mostcount) {&#xA;        break;&#xA;    }&#xA;}&#xA;return most;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically two loops, one inside the other.  The outer one steps through each number, and the inner one counts the number of times than number appears in the set (actually just from the current outer loop position to the end of the set - no point in counting numbers we've already looked at).  If the count is greater than the current &quot;mode&quot; count then store that as the &quot;mode&quot; count and also store the value as the &quot;mode&quot; value.  Move on to the next number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the Average library it's quite simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int micPin = A0;&#xA;&#xA;// We want to be able to store 10 int values here.&#xA;Average &amp;lt;int&amp;gt;sounds(10);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    // Push 10 values into the Average buffer.  Any old values will drop&#xA;    // off the bottom.&#xA;    for (int i = 0; i &amp;lt; 10; i++) {&#xA;        sounds.push(analogRead(micPin));&#xA;    }&#xA;    Serial.print(&quot;Mode value is: &quot;);&#xA;    Serial.println(sounds.mode());&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-24T12:20:59.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12891" PostTypeId="1" CreationDate="2015-06-24T12:53:43.153" Score="0" ViewCount="869" Body="&lt;p&gt;I bought an &lt;a href=&quot;http://www.arduino.org/products/arduino-9-axes&quot; rel=&quot;nofollow&quot;&gt;Arduino 9 Axes Motion Shield&lt;/a&gt; without looking at the pinout. I'm worried it won't work with my &lt;a href=&quot;https://www.adafruit.com/products/81&quot; rel=&quot;nofollow&quot;&gt;Adafruit Motor Shield v1&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the 9 axes shield uses I2C, a reset pin and several other pins for the TinkerKit Input, Output and TWI connectors. Does anyone have a list of specific ports used by the shield on the Arduino UNO?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also seems that my Arduino UNO r1 only has the original analog pins for I2C, while the 9 axes shield uses the new pins next to the digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;update: I asked support from arduino.org on twitter and on their forums, no reply yet and it seems their twitter account has been suspended. Should have bought a Genuino I guess.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10513" LastEditorUserId="10513" LastEditDate="2015-07-04T10:24:40.400" LastActivityDate="2016-01-31T05:45:51.607" Title="Pinout of Arduino 9 Axes Motion Shield" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12892" PostTypeId="1" AcceptedAnswerId="12894" CreationDate="2015-06-24T13:19:05.830" Score="1" ViewCount="76" Body="&lt;p&gt;&lt;strong&gt;Consider this question closed, found my answer through the answers I had&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to make a position profile curve depending on Looptime, accelerationloops,Setposition,Currentposition(position) and velocity.&#xA;The curve should look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VttgJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is someone able to check what is wrong with my code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float array[30];&#xA;&#xA;struct Formula {&#xA;  int LoopTime = 1000;&#xA;  int AccelerationLoops = 11;&#xA;  float VelocityLoop = 0;&#xA;  float VelocityFactor = 0;&#xA;  int TotalLoops = 0;&#xA;  float DeltaPosition = 0;&#xA;  int Setpoint = 0;&#xA;  int Iteration = -1;&#xA;  float EndOne = 1.25;&#xA;}Formula;&#xA;&#xA;float SetPosition = 1404;&#xA;float Position = 0;&#xA;float Velocity = 36;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  for(Formula.Iteration ; Formula.Iteration &amp;lt;= Formula.TotalLoops; Formula.Iteration++){&#xA;    ProgFormula();&#xA;    Serial.println(Formula.Iteration);&#xA;    if(Formula.Iteration &amp;gt;= 0) {array[Formula.Iteration] = Formula.Setpoint;}&#xA;  }&#xA;  for(Formula.Iteration = 0 ; Formula.Iteration &amp;lt;= Formula.TotalLoops; Formula.Iteration++){&#xA;    //Serial.println(array[Formula.Iteration]);&#xA;  }                    &#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&#xA;void ProgFormula(){&#xA;  if(Formula.Iteration == -1) {&#xA;    Formula.DeltaPosition = SetPosition - Position;&#xA;    Formula.VelocityLoop = Velocity / (1000 / Formula.LoopTime);&#xA;    Formula.TotalLoops = Formula.DeltaPosition / Formula.VelocityLoop + Formula.AccelerationLoops;&#xA;    Formula.VelocityFactor = Formula.VelocityLoop * 0.5 / Formula.AccelerationLoops;&#xA;    Formula.EndOne = (Formula.VelocityFactor*pow(Formula.AccelerationLoops,2));                       &#xA;  }&#xA;  else if (Formula.Iteration &amp;gt;= 0 &amp;amp;&amp;amp; Formula.Iteration &amp;lt;= Formula.AccelerationLoops) {&#xA;    Formula.Setpoint = Formula.VelocityFactor * pow(Formula.Iteration,2);&#xA;  }&#xA;  else if (Formula.Iteration &amp;gt; Formula.AccelerationLoops &amp;amp;&amp;amp; Formula.Iteration &amp;lt;= (Formula.TotalLoops - Formula.AccelerationLoops)) {&#xA;    Formula.Setpoint = Formula.VelocityLoop * Formula.Iteration - Formula.EndOne;&#xA;  }&#xA;  else if (Formula.Iteration &amp;gt;= (Formula.TotalLoops - Formula.AccelerationLoops) &amp;amp;&amp;amp; Formula.Iteration &amp;lt;= Formula.TotalLoops) {&#xA;    Formula.Setpoint = -Formula.VelocityFactor * pow((Formula.TotalLoops - Formula.Iteration),2) + Formula.DeltaPosition;&#xA;  }&#xA;  else {&#xA;    Formula.Setpoint = Formula.Setpoint;&#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10700" LastEditorUserId="10700" LastEditDate="2015-06-24T14:26:31.107" LastActivityDate="2015-06-24T14:28:48.433" Title="Strange phenomenon when declaring double" Tags="|arduino-uno|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="12894" PostTypeId="2" ParentId="12892" CreationDate="2015-06-24T14:28:48.433" Score="0" Body="&lt;p&gt;OK, this may not be a proper answer. I'm just having a hard time reading&#xA;your code, and I cannot understand why you make it so complicated. If&#xA;you know the acceleration profile, computing the position profile is&#xA;just a matter of integrating twice. Here is an example, not for Arduino&#xA;but for a PC. It should not be very different on an Arduino, you just&#xA;wouldn't use &lt;code&gt;printf()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* Compute position for any acceleration profile. */&#xA;void compute_profile(float (*acceleration)(int), int max)&#xA;{&#xA;    float x = 0, v = 0;&#xA;&#xA;    for (int t = 0; t &amp;lt;= max; t++) {&#xA;        v += acceleration(t);&#xA;        x += v;&#xA;        printf(&quot;%d\t%f\n&quot;, t, x);&#xA;    }&#xA;}&#xA;&#xA;/* Your particular acceleration profile. */&#xA;float VttgJ(int t)&#xA;{&#xA;    if (t &amp;lt;  7) return t;&#xA;    if (t &amp;lt; 13) return 12 - t;&#xA;    if (t &amp;lt; 40) return 0;&#xA;    if (t &amp;lt; 46) return 39 - t;&#xA;    else        return t - 51;&#xA;}&#xA;&#xA;int main(void)&#xA;{&#xA;    compute_profile(VttgJ, 50);&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-06-24T14:28:48.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12895" PostTypeId="2" ParentId="12881" CreationDate="2015-06-24T16:13:09.003" Score="1" Body="&lt;p&gt;Looks to me like the path where the if doesn't happen are getting you. You don't show what DBNC_TICS is set to, but I'm assuming it's &gt; 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ptrButton-&gt;debounceTics will never be greater than 1 because you always:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ptrButton-&amp;gt;debounceTics = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10827" LastActivityDate="2015-06-24T16:13:09.003" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12896" PostTypeId="1" CreationDate="2015-06-24T17:27:16.053" Score="0" ViewCount="5355" Body="&lt;p&gt;I am doing a pretty simple arduino project that uses a Parallax Ping Ultrasonic Sensor to increment a counter when an object moves past the desired distance. (object leaves, counter goes up, object comes back, this loops forever). My problem is now that every time i run this.. the serial monitor just shows me Count: 1 over and over again and does not increment.&#xA;Any help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;example of what i want the Serial Monitor to write:&#xA;Count:0 &#xA;Count:1 &#xA;Count:2 ....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it is currently doing:&#xA;Count:0 &#xA;Count:0 &#xA;Count:0 &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pingPin = 7;&#xA;&#xA;void setup() {&#xA;  // initialize serial communication:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // establish variables for duration of the ping,&#xA;  // and the distance result in inches and centimeters:&#xA;  long duration, inches, cm, count;&#xA;&#xA;  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.&#xA;  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&#xA;  pinMode(pingPin, OUTPUT);&#xA;  digitalWrite(pingPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(pingPin, HIGH);&#xA;  delayMicroseconds(5);&#xA;  digitalWrite(pingPin, LOW);&#xA;&#xA;  // The same pin is used to read the signal from the PING))): a HIGH&#xA;  // pulse whose duration is the time (in microseconds) from the sending&#xA;  // of the ping to the reception of its echo off of an object.&#xA;  pinMode(pingPin, INPUT);&#xA;  duration = pulseIn(pingPin, HIGH);&#xA;&#xA;    // convert the time into a distance&#xA;  inches = microsecondsToInches(duration);&#xA;  cm = microsecondsToCentimeters(duration);&#xA;// count = 1;&#xA;&#xA; if (inches &amp;gt; 5)&#xA;{&#xA;  Serial.print(&quot;Count: &quot;);&#xA;  Serial.print(count);&#xA;  Serial.print('\n');&#xA;  delay(1000);&#xA;        count++;&#xA;&#xA;}&#xA;&#xA;}&#xA;&#xA;&#xA;long microsecondsToInches(long microseconds)&#xA;{&#xA;  return microseconds / 74 / 2;&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10829" LastEditorUserId="4143" LastEditDate="2015-06-24T17:33:32.987" LastActivityDate="2015-06-25T08:56:53.707" Title="Counter using Ultrasonic Sensor (self.arduino)" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12897" PostTypeId="2" ParentId="12896" CreationDate="2015-06-24T17:32:53.287" Score="2" Body="&lt;p&gt;Count is a local variable - it gets re-created afresh every time the loop() runs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either make it global, or make it static.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two options look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Global&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long count = 0;&#xA;&#xA;void loop()&#xA;{&#xA;  // establish variables for duration of the ping,&#xA;  // and the distance result in inches and centimeters:&#xA;  long duration, inches, cm;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Static&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  // establish variables for duration of the ping,&#xA;  // and the distance result in inches and centimeters:&#xA;  long duration, inches, cm;&#xA;  static long count = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both will do the same job, but the &lt;code&gt;static&lt;/code&gt; form is preferred since it is always better to keep a variable's scope as narrow as possible.  It is also important to provide a start value for the counter to begin from (0 in this case) otherwise the starting value will be unknown.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-25T08:56:53.707" LastActivityDate="2015-06-25T08:56:53.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12899" PostTypeId="1" CreationDate="2015-06-24T19:22:02.550" Score="0" ViewCount="5204" Body="&lt;p&gt;I am using an Arduino Uno and have used up all it's pins so I have plugged up a Nano to a couple of the Uno's pins and using the Uno's 5v and ground to power the Nano. Is this ok? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's been working fine until recently. My Uno will no longer allow me to upload code but everything still powers fine and runs on the existing code I had uploaded before. The reset button on the Uno does not work so I assume it's bricked, but it does still operate fine on the code it has, as I said. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, my question, is it ok to run the Nano like this? Is it using too much of the Uno's current... because the Nano's pins are also all being used. I'm no good at regulating current and just want to make sure that the Nano isn't eating up a bunch of current from the Uno by lighting it's LED's and it's other operations. &lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2017-07-17T07:36:54.960" Title="How to use Arduino Nano with Arduino Uno" Tags="|arduino-uno|arduino-nano|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12900" PostTypeId="2" ParentId="12899" CreationDate="2015-06-24T20:38:56.077" Score="0" Body="&lt;p&gt;Be careful not to power any sort of motor directly from an Arduino (or any of it's siblings directly) without a transistor or H-bridge in between, unless you know exactly how much current your motor draws, peak, and how much your arduino can supply on any given pin. The same applies to any other high-draw device too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using LEDs, make sure you have a resistor in series with the LED - google &quot;LED resistor calculator&quot; to help you figure out which resistor you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when you upload the program, it uses two of the pins - rx and tx, should be digital pins 0 &amp;amp; 1 on a Uno (any other, check your docs). &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-06-24T20:38:56.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12901" PostTypeId="2" ParentId="12899" CreationDate="2015-06-24T20:39:37.400" Score="0" Body="&lt;p&gt;Maybe it is a very good idea to connect Arduino UNO's only one DIGITAL out point among other digital output pins. This pin can trig Arduino Nano's analog input pins so that you can work your task for further you needed. But you have to seperate your shields or your motors or other things. Like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/47yYK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, if you get an upload error, please plug out your shileds or motors or LEDs then try to upload your code again into Arduino UNO. &lt;/p&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2015-06-24T20:39:37.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12903" PostTypeId="2" ParentId="12881" CreationDate="2015-06-25T01:23:04.490" Score="0" Body="&lt;p&gt;The error is due to wrong expectations on operators precedence:&#xA;++ and -&gt; have the same precedence, so they are evaluated left to right.&#xA;See &lt;a href=&quot;http://en.cppreference.com/w/c/language/operator_precedence&quot; rel=&quot;nofollow&quot;&gt;http://en.cppreference.com/w/c/language/operator_precedence&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall, the lack of parenthesis makes the readability poor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code can be improved by dropping the switch and simply checking that the current value is equal to the previous value through the duration of the sampling period.&#xA;Then read the value and decide if it's high or low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even this might be a poor choice, because it simply samples the value periodically and can miss changes that are not intercepted by the sampling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the application, it might be preferrable (certainly it is more precise) to use interrupts on both edges (rising and falling) and a timeout: reset the timer at every interrupt. If the timer expires undisturbed, use the level read at the last interrupt.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-25T01:23:04.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12907" PostTypeId="2" ParentId="11599" CreationDate="2015-06-25T12:00:23.947" Score="1" Body="&lt;p&gt;The code is not in the arduino ide but in the tool chain (.exe) that it runs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally it is a program called avrdude.exe that is running so you would need to rebuild the avrdude.exe tool which is not practical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way, but rather crude, is to pull the usb cable. If the port disappears avrdude should stop immediately.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-06-25T12:00:23.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12908" PostTypeId="2" ParentId="8292" CreationDate="2015-06-25T12:05:18.737" Score="0" Body="&lt;p&gt;I hear great things about the cosa core for Arduino. It's a fantastic alternative Arduino core and exposes the power management capabilities of the micro-controller that are not exposed by the standard Arduino core. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find it is too different for your experience but then again it is excellent and worth a look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mikaelpatel/Cosa&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-06-25T12:05:18.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12910" PostTypeId="1" AcceptedAnswerId="12911" CreationDate="2015-06-25T15:15:22.580" Score="2" ViewCount="493" Body="&lt;p&gt;So I'm trying to hook up this &lt;a href=&quot;https://www.sparkfun.com/products/13019&quot; rel=&quot;nofollow&quot;&gt;BLE breakout board&lt;/a&gt; to an Arduino Uno. SparkFun has a &lt;a href=&quot;https://learn.sparkfun.com/tutorials/bc118-ble-mate-2-hookup-guide?_ga=1.207897426.1342547721.1435176975&quot; rel=&quot;nofollow&quot;&gt;hookup guide&lt;/a&gt; which seems to be great for someone who has an FTDI SmartBasic that is mentioned in the article. I don't have the SmartBasic board, and would like to see if this is possible without it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have hooked up the board to my Uno with the following pinouts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GRN -&amp;gt; Reset &#xA;RXI -&amp;gt; RX (tried with TX as well) &#xA;TXI -&amp;gt; TX (tried with RX as well) &#xA;VIN -&amp;gt; Tried 5V and 3.3V &#xA;CTS -&amp;gt; GND &#xA;BLK -&amp;gt; (No Connection)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use their &lt;a href=&quot;https://github.com/sparkfun/SparkFun_BLE_Mate2_Arduino_Library&quot; rel=&quot;nofollow&quot;&gt;example code&lt;/a&gt; they have provided, uploaded without the RX and TX pins hooked up because, from what I notice, you cannot upload a program through the USB serial when these ports are in use. So after I upload the program through USB, I power the board with a battery and connect the RX and TX pins to the BLE board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone either successfully hooked these up without the use of a SmartBasic? I'm a programmer by trade so I do my best to understand this side of the spectrum.&lt;/p&gt;&#xA;" OwnerUserId="8679" LastActivityDate="2016-12-17T23:09:03.710" Title="BLE Mate 2 bluetooth module to Arduino Uno without FTDI SmartBasic" Tags="|arduino-uno|serial|bluetooth|pins|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12911" PostTypeId="2" ParentId="12910" CreationDate="2015-06-25T16:35:53.303" Score="1" Body="&lt;p&gt;So I found out what I was doing wrong, and want to smack myself for it -.-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer was to simply hook up the BLK connection (which I guess is also ground) to a GND pin on the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this ends up helping someone out.&lt;/p&gt;&#xA;" OwnerUserId="8679" LastActivityDate="2015-06-25T16:35:53.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12912" PostTypeId="2" ParentId="1780" CreationDate="2015-06-25T21:12:41.940" Score="1" Body="&lt;p&gt;I have a sketch, that runs on a Uno, that detects chip signatures on other boards. You can use that to verify if the other board is good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/forum/?id=11633&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need six jumper cables, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8TLeK.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your description it sounds more like the Atmega16U2 is not working, that is the USB interface chip, the small chip near the USB socket. You can use the same sketch and a similar interface to check that as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/MfPZf.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should at least show that the chip(s) are alive and giving valid signatures. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use About this Mac -&gt; System Information to see if the problem Uno is listed as some sort of USB device.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-25T21:12:41.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12913" PostTypeId="2" ParentId="8733" CreationDate="2015-06-25T21:31:21.363" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;First: to run at 8 MHz, do I just need to replace the crystal? Or is there anything else I have to do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, run on the internal oscillator as suggested by AMADANON Inc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, set the &quot;divide clock by 8&quot; fuse (which would run it at 2 MHz from a 16 MHz crystal) and then in code change the division back up to 2. ie.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;void setup ()&#xA;  {&#xA;  // slow clock to divide by 2&#xA;  clock_prescale_set (clock_div_2);&#xA;  } // end of setup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for programming in another Uno leave the fuse alone, program at 16 MHz and then drop the clock down in the target chip, hoping it works long enough at 3.3V to execute that first instruction. The safest thing would be to just install an 8 MHz crystal or resonator on the target board. However if timing is not critical run with the internal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Second: Do I need to make any code changes to reflect the new speed? I'm using serial, SPI, and I2C connections in this project, along with the NilRTOS operating system and millis/delay functions. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you tell the IDE you have an 8 MHz processor (eg. a Lilypad) then it should adjust delays, baud rate calculations etc. appropriately.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Will any of these be broken?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I2C and SPI are self-clocked. They can run at a variety of rates. I doubt there will be any problems with them. As for serial, providing the calculations are done right a wide range of baud rates should still be available.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Will the code run noticeably slower?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well yes, it will run at half speed compared to 16 MHz.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Third: How can I program the chip? Is it ok to program it in an Arduino Uno at 16 MHz, then transplant it to the custom arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can do that. Or you could connect up an ICSP header or an FTDI header and program it in situ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples here: &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/breadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Fourth: Will power consumption change at 8 MHz?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, it is reduced somewhat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can reduce it considerably more by using other techniques as described at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;, and referred to by AMADANON Inc.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-25T21:31:21.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12914" PostTypeId="2" ParentId="8618" CreationDate="2015-06-26T04:15:00.883" Score="1" Body="&lt;p&gt;Your code is flawed in that you are waiting a fixed time, and then hoping that the entire response will arrive quickly. Personally I would send the query, and then exit the function. Test for incoming data in your main loop, and process it when it is all received. Techniques described here: &lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/serial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole thing should be able to be written without delay(). &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-26T04:15:00.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12915" PostTypeId="1" AcceptedAnswerId="12928" CreationDate="2015-06-26T04:27:22.277" Score="2" ViewCount="3346" Body="&lt;p&gt;Trying to do my own timer function. I was wondering if there is any other ways to make my code more efficient without the use of a library. I noticed if I only use one timer function, I wont have multiple instances of the timer. My current code works though.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousMillis1 = 0;&#xA;unsigned long currentMillis1 = millis();&#xA;unsigned long previousMillis2 = 0;&#xA;unsigned long currentMillis2 = millis();&#xA;unsigned long previousMillis3 = 0;&#xA;unsigned long currentMillis3 = millis();&#xA;&#xA;bool timer1(int preset){&#xA;  unsigned long currentMillis1 = millis();&#xA;&#xA;  if(currentMillis1 - previousMillis1 &amp;gt;= preset ){&#xA;    previousMillis1 = currentMillis1;&#xA;    return true;&#xA;  }&#xA;  else{&#xA;    return false;&#xA;  }&#xA;}&#xA;&#xA;bool timer2(int preset){&#xA;  unsigned long currentMillis2 = millis();&#xA;&#xA;  if(currentMillis2 - previousMillis2 &amp;gt;= preset ){&#xA;    previousMillis2 = currentMillis2;&#xA;    return true;&#xA;  }&#xA;  else{&#xA;    return false;&#xA;  }&#xA;}&#xA;&#xA;bool timer3(int preset){&#xA;  unsigned long currentMillis3 = millis();&#xA;&#xA;  if(currentMillis3 - previousMillis3 &amp;gt;= preset ){&#xA;    previousMillis3 = currentMillis3;&#xA;    return true;&#xA;  }&#xA;  else{&#xA;    return false;&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(timer1(1000)){Serial.println(1);}&#xA;  if(timer2(2000)){Serial.println(2);}&#xA;  if(timer3(3000)){Serial.println(3);}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5078" LastEditorUserId="5078" LastEditDate="2015-06-26T23:12:06.143" LastActivityDate="2016-06-30T13:04:48.420" Title="Timer function without the use of a library" Tags="|arduino-uno|timers|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12916" PostTypeId="2" ParentId="12879" CreationDate="2015-06-26T04:39:41.380" Score="1" Body="&lt;p&gt;I have a post here about using an I2C 16-port port-expander: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10945&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=10945&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would use 4 wires for I2C (power, ground, SDA, SCL) or there is an SPI version which would require an extra wire (power, ground, SCK, MOSI, MISO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure about noise over your cable runs, on a bicycle presumably electrical noise is low, so either one might suit. This is the chip that  Ignacio Vazquez-Abrams mentioned in his comments. Any of the 16 ports can be configured as inputs or outputs as you desire, plus it can raise an interrupt on a change on an input pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find that the maximum current limits for output may not be adequate for your LEDs (the datasheet says maximum of 25 mA per output pin, plus a maximum of 125 mA for the whole chip). You could work around this with driver transistors on the chip output, but this is more complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are higher-powered shift registers (eg. TPIC6B595) which can handle more per pin than the 74HC595.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use any pin I want? Or is it required to use specific pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to use I2C there are two specific pins dedicated to the I2C hardware. If you want to use SPI there are dedicated hardware pins as well (different ones) but you can also &quot;bit-bang&quot; SPI if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/i2c&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/spi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a through-hole version of that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All the chips I mention here have through-hole versions.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-26T04:39:41.380" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12917" PostTypeId="2" ParentId="4739" CreationDate="2015-06-26T04:42:54.927" Score="-1" Body="&lt;p&gt;you should be selecting the Arduino NANO board as the original Arduino Nano board is equipped with the FT232RL, rest all have either atmega chip for usb to ttl conversion or CP2302 chip. So &lt;strong&gt;select Arduino Nano&lt;/strong&gt; and try. &lt;/p&gt;&#xA;" OwnerUserId="10838" LastActivityDate="2015-06-26T04:42:54.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12919" PostTypeId="2" ParentId="4015" CreationDate="2015-06-26T05:43:53.450" Score="1" Body="&lt;pre&gt;&lt;code&gt;else if (flag=1) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else if (flag==1) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What else would flag be anyway? Why not just use &quot;else&quot;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // Don't display kph readings that are more than 50 kph higher than the previous reading because it is probably a spurious reading.&#xA;  if(roundedKph &amp;lt; 181){&#xA;    if((roundedKph - previousKph) &amp;gt; 50) {&#xA;      Serial.println(previousKph);&#xA;      printNumber(previousKph, 0);&#xA;    }&#xA;    else {&#xA;      Serial.println(roundedKph);&#xA;      printNumber(roundedKph, 0);&#xA;    }&#xA;  }&#xA;&#xA;  previousKph = roundedKph; // Set previousMph for use in next loop.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the code above you admit roundedKph might be wrong, but use it anyway for next time around the loop. That means next time around you will discard a correct reading.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   //If the engine is not running, print 0&#xA;    if ((micros() - lastPulseTime) &amp;lt; 5e6 ) {&#xA;      rpm = rpm;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does that achieve?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rpm;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should be &lt;strong&gt;volatile&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-06-27T06:24:37.953" LastActivityDate="2015-06-27T06:24:37.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12920" PostTypeId="2" ParentId="12915" CreationDate="2015-06-26T08:49:40.557" Score="-1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Those lines like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;currentMillis1;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;are completely useless&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You do not really have &quot;timers&quot;, especially if your goal is to be more efficient. What you have done is to create some convoluted way to perform a test that could be done as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int PERIOD = something;&#xA;for (int target = millis() + PERIOD; millis() &amp;lt; target;);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you really care about efficiency and timed actions, check some library that deals with timer interrupts.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Start reading the code of existing libraries and try to understand it.&#xA;Chances are that who wrote them knew a great deal more than you know. You will learn much more from first reading the code than trying to accomplish something that is clearly too much beyond your current knowledge (the fact you think what you did is an optimization proves it).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-06-26T09:28:58.823" LastActivityDate="2015-06-26T09:28:58.823" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12922" PostTypeId="1" AcceptedAnswerId="12924" CreationDate="2015-06-26T11:00:05.873" Score="0" ViewCount="97" Body="&lt;p&gt;I want to skip all &lt;code&gt;'\r'&lt;/code&gt; and &lt;code&gt;'\n'&lt;/code&gt; chars and I have IF statment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = Serial.read();&#xA;if (c != '\r' || c != '\n') { // &amp;lt;- This line interesting &#xA;   mAnswer[mAnswerLength] = c;&#xA;   mAnswerLength++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;VS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = Serial.read();&#xA;if (c != '\r' &amp;amp;&amp;amp; c != '\n') { // &amp;lt;- This line interesting &#xA;   mAnswer[mAnswerLength] = c;&#xA;   mAnswerLength++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is better and what is the difference?&lt;/p&gt;&#xA;" OwnerUserId="3866" LastActivityDate="2015-06-26T12:41:57.947" Title="Simple question about &amp;&amp; vs ||" Tags="|code-optimization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12923" PostTypeId="2" ParentId="12922" CreationDate="2015-06-26T11:23:39.603" Score="0" Body="&lt;p&gt;|| means logical OR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;amp;&amp;amp; means logical AND&lt;/p&gt;&#xA;" OwnerUserId="10700" LastActivityDate="2015-06-26T11:23:39.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12924" PostTypeId="2" ParentId="12922" CreationDate="2015-06-26T11:38:36.910" Score="4" Body="&lt;p&gt;Think about it &quot;logically&quot; (pun intended...):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You read a character.  Say it's &quot;A&quot;.  You then compare it to both '\r' and '\n'.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = Serial.read();&#xA;if (c != '\r' || c != '\n') { // &amp;lt;- This line interesting &#xA;    mAnswer[mAnswerLength] = c;&#xA;    mAnswerLength++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is saying &quot;If A is not CR or A is not LF then add it&quot;.  Since it's A and not LF or CR then it's going to add it.  Now imagine it's CR.  &quot;If CR is not CR or CR is not LF then add it&quot;.  CR is CR, so the first part will be false.  But CR isn't LF, so the second part is true.  If it's OR, then if either part is true then it will be true.  So since CR is not LF it will add it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = Serial.read();&#xA;if (c != '\r' &amp;amp;&amp;amp; c != '\n') { // &amp;lt;- This line interesting &#xA;    mAnswer[mAnswerLength] = c;&#xA;    mAnswerLength++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is saying &quot;If A is not CR and A is not LF then add it&quot;.  Since it's A and not LF or CR then it's going to add it.  Now imagine it's CR.  &quot;If CR is not CR and CR is not LF then add it&quot;.  CR is CR, so the first part will be false.  But CR isn't LF, so the second part is true.  Just as before.  However, if it's AMD, then if BOTH parts are true then it will be true.  So since CR is CR it won't add it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, the first one will ALWAYS be true since one half is always going to be true.  The second one will ONLY be true if BOTH parts are true.  So the first one just plain isn't going to do what you want.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-26T11:38:36.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12925" PostTypeId="2" ParentId="12922" CreationDate="2015-06-26T12:41:57.947" Score="1" Body="&lt;p&gt;You can rewrite first condition to be more obvious&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (c != '\r' || c != '\n') {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!(c == '\r' &amp;amp;&amp;amp; c == '\n')) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is always true (&lt;code&gt;c&lt;/code&gt; have only one value), i.e. it makes no sense.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-06-26T12:41:57.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12926" PostTypeId="2" ParentId="12915" CreationDate="2015-06-26T13:21:50.160" Score="0" Body="&lt;p&gt;It depends on what kind of efficiency you want. In coding we can often between better execution speed and less memory required. And in the case of Harvard-architected machines such as the AVR devices, which have separate memories for code and data, there may be a further balance between those, too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it looks like you're trying to reduce your code space requirement. So notice how alike your three timer functions are. I'd combine those into one, and pass another argument that indicates which timer value to operate on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, (and this is probably a bug more than an inefficiency), you have three globals that are not being used (in your example, anyway): &lt;code&gt;long currentMillis1&lt;/code&gt;, ..2, &amp;amp; ..3. You have redeclared each of those names as a local variable in the respective timer function, which, within that function over-rides (hides) the global declaration. There is no code that uses those globals.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-26T13:21:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12927" PostTypeId="1" CreationDate="2015-06-26T13:30:41.940" Score="1" ViewCount="6344" Body="&lt;p&gt;I have situation where I need to read RFID cards. There is already installed Roger security system, Roger gate control board and two rfid readers in parallel. By default board and RFID readers communicate in RACS(some sort of coded protocol) but at the moment system is configured to communicate in Wiegand26. Earlier I used chinese wiegand26 reader with Arduino with no problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Arduino I need to read card read by RFID readers.&#xA;Then I process data and make HTTP POST request.&#xA;Arduino is supplied from Roger board ~13.5V DC I do not get anything in arduino, even if I connect RFID readers directly to arduino.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CLK is D0 to Arduino Nano pin 2&lt;/li&gt;&#xA;&lt;li&gt;DTA is D1 to Arduino Nano pin 3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This question is not related only to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to ask is it possible to do? To read data maybe I need some additional electronics?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i also noticed that when Arduino is connected in parallel the Roger board not always reads the card from RFID readers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Roger &lt;a href=&quot;http://www.roger.pl/en/products-to-be-discontinued/760-pr402-brd-access-controller.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PR402-BRD&lt;/a&gt;&#xA;And two readers &lt;a href=&quot;http://www.roger.pl/en/access-control/readers/proximity-readers-em-125-khz/805-prt62lt-proximity-reader-em-125-khz.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PRT62LT&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/z7IBI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is copy of &lt;a href=&quot;https://electronics.stackexchange.com/q/177168/58967&quot;&gt;Electronics.stackexchange&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3866" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-11-24T03:51:47.210" Title="Parallel connection to Wiegand 26bit RFID readers" Tags="|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12928" PostTypeId="2" ParentId="12915" CreationDate="2015-06-26T13:55:23.607" Score="3" Body="&lt;p&gt;Your code is not bad in terms of efficiency. You have, however,&#xA;duplicated code, which is bad in terms of program size, but also makes&#xA;the program harder to read and to maintain. A good rule for programmers&#xA;is “do not repeat yourself”. Then, when you find yourself writing almost&#xA;identical functions, you should try to find a way to merge them into a&#xA;single function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is easy: the only difference between your timer functions is&#xA;that they use a different &lt;code&gt;previousMillis&lt;/code&gt; variable. Also, the name of&#xA;the &lt;code&gt;currentMillis&lt;/code&gt; variable is different, but it being a local&#xA;variable, this difference is irrelevant. Then, to merge them into a&#xA;single function, you only have to give to this function a &lt;em&gt;reference&lt;/em&gt; to&#xA;the relevant &lt;code&gt;PreviousMillis&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;bool timer(unsigned long &amp;amp;last_time, unsigned long period)&#xA;{&#xA;  unsigned long now = millis();&#xA;  if (now - last_time &amp;gt;= period) {&#xA;    last_time = now;&#xA;    return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  static unsigned long previousMillis1;&#xA;  static unsigned long previousMillis2;&#xA;  static unsigned long previousMillis3;&#xA;&#xA;  if (timer(previousMillis1, 1000)) Serial.println(1);&#xA;  if (timer(previousMillis2, 2000)) Serial.println(2);&#xA;  if (timer(previousMillis3, 3000)) Serial.println(3);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I took the liberty of making all the &lt;code&gt;previousMillis&lt;/code&gt; local to &lt;code&gt;loop()&lt;/code&gt;,&#xA;since they are only used there. Making them &lt;code&gt;static&lt;/code&gt; means their values&#xA;are remembered between call to &lt;code&gt;loop()&lt;/code&gt;, much like global variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In plain C you would use pointers instead of references. It is basically&#xA;the same, except that with pointers you are &lt;em&gt;explicitly&lt;/em&gt; manipulating&#xA;addresses, while this is implicit with references:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;bool timer(unsigned long *last_time, unsigned long period)&#xA;{&#xA;  unsigned long now = millis();&#xA;  if (now - *last_time &amp;gt;= period) {&#xA;    *last_time = now;&#xA;    return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&#xA;void loop() {&#xA;  /* [...] */&#xA;  if (timer(&amp;amp;previousMillis1, 1000)) Serial.println(1);&#xA;  /* [...] */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next step in code modularity would be to wrap this timer function,&#xA;together with the associated data (&lt;code&gt;last_time&lt;/code&gt; and &lt;code&gt;period&lt;/code&gt;), inside a&#xA;class:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class Timer&#xA;{&#xA;public:&#xA;&#xA;  Timer(unsigned long _period)&#xA;  : period(_period), last_time(millis()) {}&#xA;&#xA;  bool shouldRun() {&#xA;    unsigned long now = millis();&#xA;    if (now - last_time &amp;gt;= period) {&#xA;      last_time = now;&#xA;      return true;&#xA;    }&#xA;    return false;&#xA;  }&#xA;&#xA;private:&#xA;  unsigned long period;&#xA;  unsigned long last_time;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, you would use it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Timer timer1(1000);    // period = 1000 ms&#xA;Timer timer2(2000);    // period = 2000 ms&#xA;Timer timer3(3000);    // period = 3000 ms&#xA;&#xA;void loop() {&#xA;  if (timer1.shouldRun()) Serial.println(1);&#xA;  if (timer2.shouldRun()) Serial.println(2);&#xA;  if (timer3.shouldRun()) Serial.println(3);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-06-27T12:40:42.503" LastActivityDate="2015-06-27T12:40:42.503" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12929" PostTypeId="2" ParentId="12927" CreationDate="2015-06-26T14:04:33.473" Score="2" Body="&lt;p&gt;It looks to me like the Wiegand interface is an open-collector interface (like I2C), which is why they can be wired in parallel like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as the Arduino has both connections set to &lt;code&gt;INPUT&lt;/code&gt; (not &lt;code&gt;INPUT_PULLUP&lt;/code&gt; and certainly NOT &lt;code&gt;OUTPUT&lt;/code&gt;) it shouldn't interfere at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, for Wiegand, the two signals are DATA0 and DATA1.  To transmit a 0 the DATA0 line is pulled low. To transmit a 1 the DATA1 line is pulled low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also check that the idle voltage on the lines is indeed 5V as it should be.  Anything more than that could cause the Arduino to chip the voltage to 5V through its internal ESD protection diodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you must ensure that the Arduino has its ground pin connected to the ground connection of the Wiegand system (which it should be since you are powering it from that).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-26T14:04:33.473" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="12930" PostTypeId="1" CreationDate="2015-06-26T15:18:49.230" Score="1" ViewCount="2602" Body="&lt;p&gt;I am trying to set up a CAN-bus with its two nodes on the same Arduino. By Using an Arduino DUE without any transceivers. As my first experiment, I want to send a message from one CAN unit to the other. But so far I have not been successful to see any signal on the bus. (I am using an Oscilloscope)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is the detail of my effort:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used this(1) library, and I want to run the CAN_EchoTest example(2).&#xA;As for the physical layer, I have created a circuit, according to a Method that is suggested here(3), here(4), and here(5). I set the transmission rate to 5Kbps, (lowest possible value provided by the library), to make sure that noise and propagation effects are minimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented this mentioned Method to the Arduino board, using the Board's Schematics(6). In other words, I assumed that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CANTX1 in the schematics, refers to PIN with the label '53' on the board.&#xA;CANRX1 in the schematics, refers to PIN with the label 'DAC0' on the board.&#xA;CANRX0 in the schematics, refers to PIN with the label 'CANRX' on the board.&#xA;CANTX0 in the schematics, refers to PIN with the label 'CANTX' on the board.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I assumed the library that I am using configures the mutual PINS (DAC0 and 53), in a way that CAN controllers will be using them exclusively. I am not sure about the pair of diodes that I used: Vishay SS34A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what is missing/wrong? Please be patient regarding any rookie mistakes. I can Provide further information if requested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) &lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;github.com/collin80/due_can&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) &lt;a href=&quot;http://github.com/collin80/due_can/tree/master/examples/CAN_EchoTest&quot; rel=&quot;nofollow noreferrer&quot;&gt;github.com/collin80/due_can/tree/master/examples/CAN_EchoTest&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3) &lt;a href=&quot;http://www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(4) &lt;a href=&quot;https://electronics.stackexchange.com/questions/30564/is-a-can-enabled-microcontroller-sufficient-to-drive-a-can-bus&quot;&gt;electronics.stackexchange.com/questions/30564/is-a-can-enabled-microcontroller-sufficient-to-drive-a-can-bus&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(5) &lt;a href=&quot;http://www.keil.com/download/files/canprimer_v2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;www.keil.com/download/files/canprimer_v2.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(6) &lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10740" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2017-02-20T19:14:07.030" Title="CAN Bus without Transceivers" Tags="|pins|arduino-due|can-bus|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12931" PostTypeId="2" ParentId="12133" CreationDate="2015-06-26T16:01:20.117" Score="15" Body="&lt;p&gt;The cable that shipped with my Arduino Uno worked for power but not data transmission so the /dev/tty.usbmodem was not showing up in the Tools --&gt; Port menu. After I switched to a different cable, the /dev/tty.usbmodem port showed up and it worked beautifully. &lt;/p&gt;&#xA;" OwnerUserId="10847" LastActivityDate="2015-06-26T16:01:20.117" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="12932" PostTypeId="2" ParentId="12732" CreationDate="2015-06-26T22:13:02.507" Score="2" Body="&lt;p&gt;DTMF is actually two non-harmonically related frequencies transmitted at the same time as opposed to a single frequency tone that can be measured with the above process, hence Dual-Tone-Multi-Frequency:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/n8jmp.png&quot; alt=&quot;DTMF Frequency to Code table&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the Rohm BU8872 series devices which decodes the 4 x 4 multi tone combinations directly into a 4 bit digital result per the grid above.  This also works the same way in the Mitel MT8870 series devices (I think they were bought by Microsemi).  These have digital filtering which pick out the two signals and some devices can even do single tone detection.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2015-06-26T22:13:02.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12933" PostTypeId="2" ParentId="8621" CreationDate="2015-06-26T22:15:01.053" Score="1" Body="&lt;p&gt;As was pointed out in the question comments, your use of &lt;strong&gt;unsigned int&lt;/strong&gt; is the problem. The prototype for SPISettings is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments in spi.h say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// We find the fastest clock that is less than or equal to the&#xA;// given clock rate. The clock divider that results in clock_setting&#xA;// is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the&#xA;// slowest (128 == 2 ^^ 7, so clock_div = 6).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your SPI speed will be the processor speed divided by 128, which is 16 MHz divided by 128, being 125000 Hz, which is your observed result (since unsigned int cannot possibly hold more than 65535 on this platform).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-26T22:15:01.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12934" PostTypeId="2" ParentId="9616" CreationDate="2015-06-26T22:26:48.813" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the SCK lines are tied to ground via a 0.1uF capacitor (to smooth the clock signal)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Get rid of that for a start.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The other three slaves are floating their MISO lines (third state)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's your problem. They should all be outputs. From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the SPI is configured as a Slave, the Slave Select (SS) pin is always input. When SS is held low, the SPI is activated, and MISO becomes an output if configured so by the user. All other pins are inputs. When SS is driven high, all pins are inputs, and the SPI is passive, which means that it will not receive incoming data. Note that the SPI logic will be reset once the SS pin is driven high.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you can see from that, you should configure all the MISO pins as outputs. However the SPI hardware will turn them into inputs if SS is high. Thus only one slave (the one you set MISO as an output) is capable of responding at present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should probably set them as outputs &lt;strong&gt;after&lt;/strong&gt; turning on SPI slave mode. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // turn on SPI in slave mode&#xA;  SPCR |= bit (SPE);&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode (MISO, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-26T22:26:48.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12935" PostTypeId="2" ParentId="12732" CreationDate="2015-06-27T01:33:17.830" Score="3" Body="&lt;p&gt;As John Taylor said, DTMF is not a single tone but two tones transmitted simultaneously, which select the digit from a two-dimensional grid. (&lt;em&gt;Dual&lt;/em&gt; tone multi-frequency). This allow 16 possible combinations from only 8 distinct tones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are chips available specifically for the task of decoding DTMF, but it's always nice to try and find a one-chip solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two solutions that I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT&quot; rel=&quot;nofollow&quot;&gt;ArduinoFFT&lt;/a&gt; - a &lt;strong&gt;Fourier transform&lt;/strong&gt; is an operation that splits a time-based signal into its frequency components. If you control the ADC directly instead of via the Arduino library, it is easily fast enough to sample a DTMF signal. Once you've done the FFT you just need to find the peaks in the output, which will tell you the tones that are present.&lt;/li&gt;&#xA;&lt;li&gt;If you put the signal through the analog comparator and &lt;strong&gt;count the rate of zero-crossings&lt;/strong&gt; (use an interrupt with a routine that increments a number, you may miss some if you just poll the pin), the rate of crossings should be &lt;strong&gt;unique for each tone combination&lt;/strong&gt;. Counting for e.g. 10 ms and looking up the closest match from a table you've pre-measured should give reliable decoding, and is a slightly less brute-force approach than an FFT.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That said, you won't be able to beat a dedicated chip (although I personally think this way is much more fun.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy hacking!&lt;/p&gt;&#xA;" OwnerUserId="10854" LastActivityDate="2015-06-27T01:33:17.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12936" PostTypeId="2" ParentId="12915" CreationDate="2015-06-27T03:17:05.230" Score="2" Body="&lt;p&gt;You can simplify &lt;strong&gt;a lot&lt;/strong&gt; by using arrays. The example code below just uses a single variable (array) to store all the time intervals you are interested in.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_TIMERS = 5;&#xA;&#xA;unsigned long intervalStarted [NUMBER_OF_TIMERS];&#xA;&#xA;void resetTimer (const int whichTimer)&#xA;  {&#xA;  if (whichTimer &amp;lt; 0 || whichTimer &amp;gt;= NUMBER_OF_TIMERS)&#xA;    return;   // sanity clause&#xA;  intervalStarted [whichTimer] = millis ();&#xA;  }  // end of resetTimer&#xA;&#xA;// interval in milliseconds&#xA;bool timeUp (const int whichTimer, const unsigned long whatInterval)&#xA;  {&#xA;  if (whichTimer &amp;lt; 0 || whichTimer &amp;gt;= NUMBER_OF_TIMERS)&#xA;    return false;   // sanity clause&#xA;  return  millis () - intervalStarted [whichTimer] &amp;gt;= whatInterval;&#xA;  }  // end of timeUp&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (F(&quot;Starting ...&quot;));&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  if(timeUp(0, 1000))&#xA;    {&#xA;    Serial.println(1);&#xA;    resetTimer (0);&#xA;    }  // end of if timer 0 up&#xA;&#xA;  if(timeUp(1, 2000))&#xA;    {&#xA;    Serial.println(2);&#xA;    resetTimer (1);&#xA;    }  // end of if timer 1 up&#xA;&#xA;  if(timeUp(2, 3000))&#xA;    {&#xA;    Serial.println(3);&#xA;    resetTimer (2);&#xA;    } // end of if timer 2 up&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have allowed for 5 &quot;timers&quot; in the code but only used 3 to be consistent with the original post. You can see that you can have as many as you want (until you run out of RAM) with only an overhead of 4 bytes per &quot;timer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two functions are provided. One checks if a nominated interval is up, the other one &quot;resets&quot; the timer by setting its start time to now. The checking function should work correctly even during millis() wrap-around, providing you are not trying to time more than 4294967296 milliseconds in one hit (49.71 days).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the timer numbers are zero-relative, so the first timer is timer 0. You could make them one-relative if you prefer that with a slight adjustment to the two functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also, if you chose to, put the resetTimer function call inside the timeUp function (if the time is up) so that the timer automatically resets. I didn't do that because I think starting timing, and detecting the end of a period could be two different things. For example, when you boil an egg, you start timing from the time the egg goes onto the boil, not from when you last cooked an egg.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:08:53.817" LastActivityDate="2015-07-01T21:08:53.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12937" PostTypeId="1" CreationDate="2015-06-27T04:34:58.630" Score="0" ViewCount="2252" Body="&lt;p&gt;I've got an Arduino Micro, and a MAX4466 ECM / AMP breakout board (&lt;a href=&quot;https://www.adafruit.com/product/1063&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/product/1063&lt;/a&gt;). I'm powering the Arduino Micro from the USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the MAX4466 (to the Arduino), I've wired VCC to 3.3v, GND to GND, and OUT to A0. I've also wired 3.3v to AREF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the following code, I'm noticing significant noise spikes on the output, as shown in the graph below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not entirely sure what I've done wrong here, and would appreciate any input / criticism that could lead to getting a clean signal.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   analogReference(EXTERNAL);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;   Serial.println(analogRead(0));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/u49QX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10857" LastEditorUserId="37523" LastEditDate="2019-05-23T17:29:12.590" LastActivityDate="2019-06-22T21:00:37.447" Title="Arduino Micro + Max4466 - Noise on A0" Tags="|analogread|arduino-micro|analog-sampling|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="12938" PostTypeId="2" ParentId="8417" CreationDate="2015-06-27T05:17:52.453" Score="1" Body="&lt;p&gt;If your sketch contains !!! in it, that can cause some versions of the bootloader to drop into interactive mode, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (&quot;Rocket firing!!!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also there can be problems with 0xFF bytes in your code causing the bootloader to incorrectly assume that that page of memory was erased, when it was not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a bootloader-uploader sketch at: &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;Atmega bootloader programmer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a second board to use it (eg. a Uno) - the bootloader for the Mega2560 is a reasonably up-to-date one. I haven't actually tested it with the Sainsmart version of the Mega, but I presume that internally that part is the same.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-27T05:17:52.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12939" PostTypeId="5" CreationDate="2015-06-27T14:49:29.707" Score="0" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Digital communications networks implementing the EIA-485 standard can be used effectively over long distances and in electrically noisy environments. Multiple receivers may be connected to such a network in a linear, multi-drop configuration. These characteristics make such networks useful in industrial environments and similar applications.&lt;/p&gt;&#xA;&lt;p&gt;The EIA once labeled all its standards with the prefix &amp;quot;RS&amp;quot; (Recommended Standard), but the EIA-TIA officially replaced &amp;quot;RS&amp;quot; with &amp;quot;EIA/TIA&amp;quot; to help identify the origin of its standards. The EIA has officially disbanded and the standard is now maintained by the TIA.&lt;/p&gt;&#xA;&lt;p&gt;The RS-485 standard is superseded by TIA-485, but often engineers and applications guides continue to use the RS designation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="27346" LastEditDate="2020-08-02T20:28:10.807" LastActivityDate="2020-08-02T20:28:10.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="12940" PostTypeId="4" CreationDate="2015-06-27T14:49:29.707" Score="0" Body="also known as ANSI/TIA/EIA-485, TIA/EIA-485, EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems. The standard is published by the Telecommunications Industry Association/Electronic Industries Alliance (TIA/EIA)." OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-04T17:14:24.373" LastActivityDate="2015-07-04T17:14:24.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12941" PostTypeId="5" CreationDate="2015-06-27T14:51:53.890" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2015-06-27T14:51:53.890" LastActivityDate="2015-06-27T14:51:53.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12942" PostTypeId="4" CreationDate="2015-06-27T14:51:53.890" Score="0" Body="an Arduino library for asynchronous playback of PCM/WAV files direct from SD card&#xD;&#xA;&#xD;&#xA;Utilizes standard Arduino SD library, SD card and output device (Speaker, Headphones, Amplifier, etc)" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-02T16:15:49.353" LastActivityDate="2015-07-02T16:15:49.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12943" PostTypeId="2" ParentId="646" CreationDate="2015-06-27T18:42:07.533" Score="1" Body="&lt;p&gt;I have same problem after set baud rate to 14400.&#xA;For fix this I manual set serial.debug_rate=115200 in config file ~/.arduino/preferences.txt&lt;/p&gt;&#xA;" OwnerUserId="10863" LastActivityDate="2015-06-27T18:42:07.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12944" PostTypeId="1" CreationDate="2015-06-26T23:11:31.423" Score="3" ViewCount="1648" Body="&lt;p&gt;I'm trying to control the speed of two DC motors that are connected to a dual H bridge. I always used digital PWM pins with &lt;code&gt;analogWrite()&lt;/code&gt; to change the speed, but since I'm making a project that will be using most of the digital pins, I wonder if I can use analog pins instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I know I can use analog pins as digital pins to free the digital PWM pins, but I'm not interested in doing that. &lt;/p&gt;&#xA;" OwnerDisplayName="Alvaro Gaita" LastActivityDate="2017-05-16T06:28:44.103" Title="Is it possible to control the speed of DC motors with Arduino's analogWrite() using analog pins?" Tags="|pwm|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12945" PostTypeId="2" ParentId="12944" CreationDate="2015-06-27T00:32:51.173" Score="1" Body="&lt;p&gt;No, you can't.  As it says in the Arduiuno &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;reference page&lt;/a&gt; for analogWrite(): &quot;The analogWrite function has nothing to do with the analog pins or the analogRead function.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &quot;analog input pins&quot; (A0..A5) of Arduino for analog input, or as digital inputs or outputs.  They cannot be used for PWM(digital)-output.  Only digital pins, and only those specifically stated for PWM-output, can actually be used for PWM output (unless you go down the path of software-PWM, though I would hesitate to do that for an H-bridge).&lt;/p&gt;&#xA;" OwnerUserId="7937" OwnerDisplayName="Techydude" LastActivityDate="2015-06-27T00:39:11.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12946" PostTypeId="2" ParentId="12944" CreationDate="2015-06-27T00:35:56.960" Score="1" Body="&lt;p&gt;You can't do it with the analogWrite function as that is reliant on physical binding beween certain pins and hardware timers inside the AVR. But you can always use &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_SoftPWM.html&quot; rel=&quot;nofollow&quot;&gt;SoftPWM&lt;/a&gt; because the the analog pins can generally be used as digital pins just as well.&lt;/p&gt;&#xA;" OwnerUserId="4805" OwnerDisplayName="vicatcu" LastActivityDate="2015-06-27T00:35:56.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12947" PostTypeId="2" ParentId="12944" CreationDate="2015-06-27T05:54:59.730" Score="0" Body="&lt;p&gt;You can use multiplexers if you are running out of digital pins or SPI PWM drivers for the motors. There are many multichannel drivers out there like &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/tlc5940.pdf&quot; rel=&quot;nofollow&quot;&gt;TLC5940&lt;/a&gt;, put a power stage after them and you're done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Use Soft SPI on the analog pins to control the driver.&lt;/p&gt;&#xA;" OwnerUserId="63039" OwnerDisplayName="diegogmx" LastEditorUserId="10794" LastEditDate="2015-08-27T23:50:15.957" LastActivityDate="2015-08-27T23:50:15.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12949" PostTypeId="2" ParentId="9798" CreationDate="2015-06-27T22:44:12.397" Score="1" Body="&lt;p&gt;You can buy these displays on eBay for a few dollars. A bit of soldering and you are done (although also pre-assembled ones are available). They can be daisy-chained. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/dEbzN.jpg&quot; alt=&quot;6 x 4-digit 7-segment display modules&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only need 5 wires to the Arduino: Gnd/5V/MOSI/SCK/SCK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/YhNOe.jpg&quot; alt=&quot;modules in operation&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, 64-dot displays for displaying arbitrary text:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8Z5oV.jpg&quot; alt=&quot;8x8 LED matrix&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, only 5 wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Arduino libraries for driving both sorts of display on &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;&#xA;Interfacing LED displays with the MAX7219 driver &lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-27T22:44:12.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12950" PostTypeId="2" ParentId="6702" CreationDate="2015-06-27T23:00:28.630" Score="1" Body="&lt;p&gt;I bricked my Pro-Micro within ten minutes of ripping it out the packet. I didn't realise that (a) it's not so brilliant on USB 3.0 - or in my case, unuseable, and (b) it's not actually an Arduino board - the Pro-Micro is a &lt;strong&gt;SparkFun&lt;/strong&gt; product, and any clones thereof are from SparkFun's schematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter was only a problem to begin with, while I was scrabbling around on the Arduino website in vain trying to find answers. Once I realised to visit SF's website everything calmed down. Read &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#troubleshooting-and-faq&quot; rel=&quot;nofollow&quot;&gt;this section on bricked/unrecognised pro-micros&lt;/a&gt;, and then have a look at the rest of the page as further reading.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-06-27T23:00:28.630" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12951" PostTypeId="1" AcceptedAnswerId="12955" CreationDate="2015-06-28T00:16:51.957" Score="2" ViewCount="2529" Body="&lt;p&gt;I'm using an MPC73831 - a LiPo charging IC - in my Arduino project. It has a &lt;code&gt;status&lt;/code&gt; pin to allow interface to a microcontroller, which uses a tri-state operation to convey three possible states of charging. I don't have the IC and battery yet, but I wanted to write a quick program to test a generic tri-state pin for HI, LO, and HiZ while I'm waiting for it to arrive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The algorithm I wrote is very simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Set pinTest to input, no pullup.&#xA;Is pinTest high?&#xA;    Yes - pinTriState is HIGH, done.&#xA;Set pinTest to input with pullup.&#xA;Is pinTest high?&#xA;    Yes - pinTriState is HiZ, internal pullup causes high reading.&#xA;    No - pinTriState is LOW, 'cancelling out' internal pullup.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'm not getting the expected results when using the internal pullup resistor - my board is showing correct analysis for HI and LO, but HiZ returns a mixture of HiZ and HIGH. I have tried this on an Uno, a Pro-Micro (32u4) and Uno-&gt;Micro and Micro-&gt;Uno. All give the same spurious results. I am baffled, therefore some advice would be appreciated. The full code is as below. I have left in code which randomises the time &lt;code&gt;pinTriState&lt;/code&gt; stays at in a given state to keep &lt;code&gt;pinTest&lt;/code&gt; guessing, but it's ultimately only an elaborate way of cycling through the three states.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define pinTest 2&#xA;#define pinTriState 3&#xA;&#xA;int state = 0;&#xA;char stateCh = '?';&#xA;&#xA;int sect1;&#xA;int sect2;&#xA;int sectMax;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    randomSeed(analogRead(A0));&#xA;    sect1 = random(1, 20);&#xA;    sect2 = random(sect1 + 1, random(sect1 + 2, sect1 + 20));&#xA;    sectMax = random(sect2 + 1, random(sect2 + 2, sect2 + 20));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // PART (1) Code to toggle three states of a tri-state pin&#xA;    if (state == 0)&#xA;    {&#xA;        pinMode(pinTriState, OUTPUT);&#xA;        digitalWrite(pinTriState, HIGH);&#xA;        stateCh = 'H';&#xA;    }&#xA;    if (state == sect1)&#xA;    {&#xA;        pinMode(pinTriState, OUTPUT);&#xA;        digitalWrite(pinTriState, LOW);&#xA;        stateCh = 'L'&#xA;    }&#xA;    if (state == sect2)&#xA;    {&#xA;        pinMode(pinTriState, INPUT);&#xA;        stateCh = 'Z';&#xA;    }&#xA;&#xA;    // PART (2) Code to determine state of tri-state pin&#xA;    Serial.print(stateCh);     // Shows what it *should* be&#xA;    pinMode(pinTest, INPUT);&#xA;    if (digitalRead(pinTest))&#xA;        Serial.println(&quot; - HIGH&quot;);&#xA;    else&#xA;    {&#xA;        pinMode(pinTest, INPUT_PULLUP);&#xA;        if (digitalRead(pinTest))&#xA;            Serial.println(&quot; - HiZ&quot;);&#xA;        else&#xA;            Serial.println(&quot; - LOW&quot;);&#xA;    }&#xA;&#xA;    (state == sectMax ? state = 0 : state++);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The necessary pins are connected with a single wire. If I upload the code to two boards I remove &lt;em&gt;PART (2)&lt;/em&gt; on the 'triState' board and &lt;em&gt;PART (1)&lt;/em&gt; on the 'testing' board. In this case, &lt;code&gt;stateCh&lt;/code&gt; has no function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a single-board setup, I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;H - HIGH&#xA;H - HIGH&#xA;...&#xA;L - LOW&#xA;L - LOW&#xA;...&#xA;Z - HiZ        &amp;lt;-- the first Z is correct 95% of the time&#xA;Z - HIGH&#xA;Z - HIGH       &amp;lt;-- the remaining Zs are a mixture, biased heavily towards HIGH.&#xA;Z - HiZ&#xA;...&#xA;H - HIGH       &amp;lt;-- H always gives HIGH&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It makes no difference if I change the operating order of &lt;code&gt;pinState&lt;/code&gt;. I've thrown in &lt;code&gt;delay(100);&lt;/code&gt; between almost every other line, again to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with a 22k, a 33k, and a 47k &lt;em&gt;external&lt;/em&gt; pullup resistor. The results are perfect. However, this requires an extra Arduino pin to make sure that the pullup is only active when necessary. &lt;em&gt;Part (2)&lt;/em&gt; becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PART (2) Code to determine state of tri-state pin&#xA;Serial.print(stateCh);     // Shows what it *should* be&#xA;pinMode(pinTest, INPUT);&#xA;pinMode(pinPullup, INPUT);    // connected to pinTest via resistor&#xA;if (digitalRead(pinTest))&#xA;    Serial.println(&quot; - HIGH&quot;);&#xA;else&#xA;{&#xA;    //pinMode(pinTest, INPUT_PULLUP);   &amp;lt;-- not anymore&#xA;    pinMode(pinPullup, OUTPUT);&#xA;    digitalWrite(pinPullup, HIGH);    // pulls pinTest to Vdd&#xA;    if (digitalRead(pinTest))&#xA;        Serial.println(&quot; - HiZ&quot;);&#xA;    else&#xA;        Serial.println(&quot; - LOW&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the extra pin to provide the pullup is a real pain in the ar...duino. I'm cripplingly short of spare pins and I don't see why this is not resolvable with internal pullups. Help?!&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2015-06-28T22:32:32.940" LastActivityDate="2016-03-19T13:32:43.927" Title="Testing tri-state pin - erroneous results with internal pullup" Tags="|pull-up|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="12954" PostTypeId="1" CreationDate="2015-06-28T00:49:44.047" Score="3" ViewCount="199" Body="&lt;p&gt;I am just getting started with my Uno via the Vilros Ultimate Starter Kit. I've done all of the sample circuits and played around with a few other things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I connected the Ethernet shield with the intention of building a temperature logger. I am finding that the output I get from the included TMP36 temperature sensor is much different with the Ethernet shield installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The kit's sample circuit #7 for the temperature sensor connects the sensor directly to 5V and GND and the sensor output to A0. The loop code (compressed a bit for pasting here) looks like this:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;float voltage, degreesC, degreesF;&#xA;voltage = analogRead(temperaturePin) * 0.004882814;&#xA;degreesC = (voltage - 0.5) * 100.0;&#xA;degreesF = degreesC * (9.0/5.0) + 32.0;&#xA;// Write to serial; omitting for brevity&#xA;delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Without&lt;/em&gt; the Ethernet shield installed, a typical output I get from this looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;voltage: 0.81  deg C: 30.57  deg F: 87.02&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That might be a little high but it feels close enough for what I'm going for at the moment (I don't have a reliable thermometer with me, but it's a warm day here). It's close enough, and is stable across readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;With&lt;/em&gt; the shield installed, the exact same circuit and sketch outputs this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;voltage: 0.96  deg C: 46.19  deg F: 115.14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's still very stable across readings but obviously way off. What could cause this and how can I fix it? I am not expecting the sensor to be perfectly accurate but the major discrepancy I'm seeing makes this unworkable.&lt;/p&gt;&#xA;" OwnerUserId="10866" LastEditorUserId="37523" LastEditDate="2019-05-16T02:56:53.140" LastActivityDate="2019-05-16T02:56:53.140" Title="Uno Ethernet shield and TMP36 reading" Tags="|arduino-uno|ethernet|analogread|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="12955" PostTypeId="2" ParentId="12951" CreationDate="2015-06-28T01:15:24.933" Score="5" Body="&lt;p&gt;The internal pull-up is around 50k. So, install an external pull-&lt;strong&gt;down&lt;/strong&gt; (to ground) of a somewhat higher value, like 1M.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to input mode, no pull-up. Get a reading. Turn on the internal pull-up. This should overpower the pull-down. If the reading &lt;strong&gt;changes&lt;/strong&gt;, it was tri-state. Otherwise, if the reading doesn't change the external device is overpowering both pull-up and pull-down and you have the actual reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may need a slight delay to allow the low-value pull-down to change the pin state.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Amended code to demonstrate:&lt;/p&gt;&#xA;&#xA; &#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// PART (2) Code to determine state of tri-state pin&#xA;Serial.print(stateCh);     // Shows what it *should* be&#xA;&#xA;pinMode(pinTest, INPUT);&#xA;delayMicroseconds (100);&#xA;byte firstReading = digitalRead(pinTest);&#xA;pinMode(pinTest, INPUT_PULLUP);&#xA;delayMicroseconds (10);&#xA;byte secondReading =  digitalRead(pinTest);&#xA;&#xA;if (firstReading != secondReading)&#xA;  Serial.println(&quot; - HiZ&quot;);&#xA;else if (secondReading == HIGH)&#xA;  Serial.println(&quot; - HIGH&quot;);&#xA;else&#xA;  Serial.println(&quot; - LOW&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Only showing the part that detects the pin state, the rest is the same).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA; &#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;H - HIGH&#xA;L - LOW&#xA;Z - HiZ&#xA;Z - HiZ&#xA;Z - HiZ&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;L - LOW&#xA;Z - HiZ&#xA;Z - HiZ&#xA;Z - HiZ&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;L - LOW&#xA;Z - HiZ&#xA;Z - HiZ&#xA;Z - HiZ&#xA;H - HIGH&#xA;H - HIGH&#xA;H - HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, working perfectly. I needed a longer delay after turning the internal pullup &lt;strong&gt;off&lt;/strong&gt; because the fall time was around 100 µs. This actually sounds reasonable, because the 1 megohm resistor will take time to discharge the capacitance on the pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;10 µs delay after turning the internal pull-up &lt;strong&gt;on&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;100 µs delay after turning the internal pull-up &lt;strong&gt;off&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Theory for the delays&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmega328 pin is specified as having a maximum capacitance of 10 pF (10e-12). It is considered charged/discharged after 5 time-constants, where &lt;code&gt;T = R.C&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus for an internal pull-up resistance of 50k and a capacitance of 10 pF, charging should take:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;50e3 * 10e-12 * 5 = 2.5e-006 (0.0000025) -&amp;gt; 2.5 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to discharge through 1M (1e6) ohms, discharging should take:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;1e6 * 10e-12 * 5 = 5e-005 (0.00005) -&amp;gt; 50 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My observed results were about 2.5 µS for the charge, but more like 100 µs for the discharge, however I probably had considerable stray capacitance in the wires used in the test circuit.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-22T22:51:36.800" LastActivityDate="2015-07-22T22:51:36.800" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12956" PostTypeId="2" ParentId="10512" CreationDate="2015-06-28T02:23:17.790" Score="3" Body="&lt;p&gt;An important consideration is that the chip cannot necessarily source 20 mA on all output pins at once. In fact pins D5 to D13 on the Uno (PD5 to PD7, and PB0 to PB5) cannot source more than 150 mA combined. Thus the maximum you could source on those pins, if you are driving them all at once, is 150 / 9 = 16 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, designing for 10 mA per LED is allowing a safety margin, possibly to save tutorials the complexity of explaining that 20 mA is OK for one pin, but not for all the pins at once.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-28T02:23:17.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12957" PostTypeId="1" CreationDate="2015-06-28T04:23:12.277" Score="0" ViewCount="706" Body="&lt;p&gt;I spent a significant part of today developing a sprite movement library for a 30-pixel NeoPixel strip using my Arduino Duemilanove (ATmega 168). It works like a charm. However, if I change &lt;code&gt;N_LEDS&lt;/code&gt; to a significantly higher value, the program seems not to run. I can't get it to run on the Duemilanove for a strip of longer than 50.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, (see the below code) a relatively high &lt;code&gt;N_LEDS&lt;/code&gt; value won't even allow the test patterns to run as defined in &lt;code&gt;setup()&lt;/code&gt;. This leads me to believe that inexplicably the constructor for &lt;code&gt;Adafruit_Neopixel&lt;/code&gt; is failing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A friend of mine (who has the ultimate application for this) is hoping to drive a strand of 750 LEDs using this code on an Arduino Due. I can't imagine memory would be an issue with the Due, so what's going on here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Headers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;#define PIN    6&#xA;#define N_LEDS 30      // &amp;lt;-- If this number is &amp;gt; ~50, nothing happens&#xA;#define MAXSPRITES 5&#xA;#define MIN_UPDATE_INTERVAL_IN_MS  15&#xA;#define MAX_UPDATE_INTERVAL_IN_MS  40&#xA;#define SENSOR_TIMEOUT_IN_MS  2000&#xA;#define SCANNER_WIDTH  9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Strip declaration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    randomSeed(analogRead(0));  &#xA;&#xA;    strip.begin();&#xA;&#xA;    darkenStrip();&#xA;&#xA;    manager = new SpriteManager();&#xA;    manager-&amp;gt;Add(new TestPatternSprite(0, 0xff0000));&#xA;    manager-&amp;gt;Add(new TestPatternSprite(5, 0x00ff00));&#xA;    manager-&amp;gt;Add(new TestPatternSprite(10, 0x0000ff));&#xA;}&#xA;&#xA;loop() {&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are there any coding mistakes in the above that wouldn't allow us to run this code on the Due? Or is this a known limitation?&lt;/p&gt;&#xA;" OwnerUserId="10867" LastEditorUserId="10867" LastEditDate="2015-06-28T17:31:00.843" LastActivityDate="2015-06-28T17:31:00.843" Title="Can't drive long NeoPixel strips with Due or Duemilanove?" Tags="|arduino-due|adafruit|arduino-duemilanove|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12958" PostTypeId="2" ParentId="1784" CreationDate="2015-06-28T05:49:38.433" Score="18" Body="&#xA;&#xA;&lt;p&gt;There are two types of &quot;pin change&quot; type interrupts. The external interrupts, of which there are two on the Uno. They are called 0 and 1, however they refer to digital pins 2 and 3 on the board. These can be configured to detect rising, falling, change (rising &lt;strong&gt;or&lt;/strong&gt; falling) or LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to that are &quot;pin change&quot; interrupts, which detect a change to the pin state in any of the 20 pins (A0 to A5, and D0 to D13). These pin change interrupts are also &lt;strong&gt;hardware based&lt;/strong&gt; so, in themselves, will be as fast as the external interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both types are slightly fiddly to use at the register level, but the standard IDE includes attachInterrupt(n) and detachInterrupt(n) which simplifies the interface to external interrupts. You can also use the &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot; rel=&quot;noreferrer&quot;&gt;Pin Change Library&lt;/a&gt; to simplify the pin change interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, steering clear of the library for a minute, we can establish that pin change interrupts can be as fast, or faster, than external interrupts. For one thing, although pin change interrupts work on batches of pins, you don't have to enable the whole batch. For example, if you want to detect changes on pin D4, this will suffice:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR (PCINT2_vect)&#xA; {&#xA; // handle pin change interrupt for D0 to D7 here&#xA; if (PIND &amp;amp; bit (4))  // if it was high&#xA;   PORTD |= bit (5);  // turn on D5&#xA; else&#xA;   PORTD &amp;amp;= ~bit (5); // turn off D5&#xA; }  // end of PCINT2_vect&#xA;&#xA;void setup ()&#xA;  { &#xA;  // pin change interrupt (example for D4)&#xA;  PCMSK2 |= bit (PCINT20);  // want pin 4&#xA;  PCIFR  |= bit (PCIF2);    // clear any outstanding interrupts&#xA;  PCICR  |= bit (PCIE2);    // enable pin change interrupts for D0 to D7&#xA;  pinMode (4, INPUT_PULLUP);&#xA;  pinMode (5, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My testing indicates that it took 1.6 µs for the &quot;test&quot; pin (pin 5) to react to a change on the interrupt pin (pin 4).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now if you take the simple (lazy?) approach and use attachInterrupt() you will find the results are slower, not faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void myInterrupt ()&#xA; {&#xA; if (PIND &amp;amp; bit (2))  // if it was high&#xA;   PORTD |= bit (5);  // turn on D5&#xA; else&#xA;   PORTD &amp;amp;= ~bit (5); // turn off D5&#xA; }  // end of myInterrupt&#xA;&#xA;void setup ()&#xA;  { &#xA;  attachInterrupt (0, myInterrupt, CHANGE);&#xA;  pinMode (2, INPUT_PULLUP);&#xA;  pinMode (5, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This takes 3.7 µs to change the test pin, a lot more than the 1.6 µs above. Why? Because the code the compiler has to generate for the &quot;generic&quot; interrupt handler has to save every conceivable register (push them) on entry to the ISR, and then restore them (pop them) before returning. Plus there is the overhead of another function call.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now we can work around that by avoiding attachInterrupt() and doing it ourselves:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR (INT0_vect)&#xA; {&#xA; if (PIND &amp;amp; bit (2))  // if it was high&#xA;   PORTD |= bit (5);  // turn on D5&#xA; else&#xA;   PORTD &amp;amp;= ~bit (5); // turn off D5&#xA; }  // end of INT0_vect&#xA;&#xA;void setup ()&#xA;  { &#xA;  // activate external interrupt 0&#xA;&#xA;  EICRA &amp;amp;= ~(bit(ISC00) | bit (ISC01));  // clear existing flags&#xA;  EICRA |=  bit (ISC00);    // set wanted flags (any change interrupt)&#xA;  EIFR   =  bit (INTF0);    // clear flag for interrupt 0&#xA;  EIMSK |=  bit (INT0);     // enable it&#xA;&#xA;  pinMode (2, INPUT_PULLUP);&#xA;  pinMode (5, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the fastest of them all at 1.52 µs - it looks like one clock cycle got saved somewhere.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is one caveat though, for pin-change interrupts. They are batched, so if you want to have interrupts on lots of pins, you need to test inside the interrupt &lt;strong&gt;which&lt;/strong&gt; one changed. You could do that by saving the previous pin status, and comparing it to the new pin status. This is not necessarily particularly slow, but the more pins you need to check, the slower it would be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The batches are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A0 to A5&lt;/li&gt;&#xA;&lt;li&gt;D0 to D7&lt;/li&gt;&#xA;&lt;li&gt;D8 to D13&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you just want a couple more interrupt pins, you could avoid any testing by just choosing to use pins from different batches (eg. D4 and D8).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More details at &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;noreferrer&quot;&gt;http://www.gammon.com.au/interrupts&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2018-02-24T21:25:47.890" LastActivityDate="2018-02-24T21:25:47.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12959" PostTypeId="2" ParentId="12957" CreationDate="2015-06-28T06:22:17.647" Score="4" Body="&lt;p&gt;Your Duemilanove only has 1k of RAM. That's not much. Each pixel takes 3 bytes of RAM (R/G/B). So (say) 60 pixels would be 180 bytes. That's less than 1k, but there would be other uses of RAM in your sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;750 LEDs sounds like pushing it for the low-RAM Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to look at &lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot; rel=&quot;nofollow&quot;&gt;NeoPixels Revealed: How to (not need to) generate precisely timed signals&lt;/a&gt; The author managed to drive over 1000 NeoPixels with a Duemilanove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if that applies to your exact type of NeoPixels, but it is worth considering.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-28T06:22:17.647" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="12960" PostTypeId="2" ParentId="12382" CreationDate="2015-06-28T06:37:33.733" Score="0" Body="&lt;pre&gt;&lt;code&gt;ISR(TIMER1_CAPT_vect) {&#xA;    Serial.Print(&quot;Entered Capture Vector&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rule #1. Don't do serial prints inside an ISR. Doing that will likely hang the sketch.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because it doesn't appear to matter what I type inside ISR(), for instance I can write ISR(GibERisH) { }&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes you can do that. It just degrades into some function that is never called. The way it is organized with all the defines, any non-valid ISR name effectively creates a non-ISR function, which is therefore ignored. Even getting the capitalization wrong can cause this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I need advanced control of the guts of this processor, and there is zero documentation about how to do this anywhere on the internet.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a considerable amount of detail on my site: &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/interrupts&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-28T06:37:33.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12962" PostTypeId="2" ParentId="562" CreationDate="2015-06-28T09:23:33.520" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The linker for example requires .cpp files and not .c files, otherwise it leads to errors during the linking process&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So, what are the tools that I need to setup a C environment? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why do you want to? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make a new tab in the IDE (top RH corner). Call it, for example, foo.c. That's your C file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put whatever C code you want into it. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;void foo ()&#xA;{&#xA;PORTD = bit (1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in your &quot;main&quot; sketch call that function, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern &quot;C&quot;&#xA; {&#xA; void foo ();&#xA; }&#xA;&#xA;void setup ()&#xA;  {&#xA;  foo ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Repeat as required for any C functions you care to write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you can't use Serial (that's a C++ class) or Wire (that's a C++ class) or SPI (that's a C++ class), but if you want to work with C, you can certainly do that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-06-29T04:49:28.223" LastActivityDate="2015-06-29T04:49:28.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12963" PostTypeId="2" ParentId="12951" CreationDate="2015-06-28T10:59:31.923" Score="3" Body="&lt;p&gt;Another option is to use an analog input pin instead of a digital input pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create a balanced voltage divider using equal high value resistors (say 100KΩ each).  Attach the mid-point to the ADC pin, and one end to each of Vcc and GND.  The incoming status signal goes to the ADC pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/a2lw6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perform an analogRead() on the pin.  You will get one of 3 results:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Close to 0 = LOW&lt;/li&gt;&#xA;&lt;li&gt;Close to 1024 = HIGH&lt;/li&gt;&#xA;&lt;li&gt;Close to 512 = HiZ&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When the pin is in HiZ the resistors will hold the voltage at around 50% of Vcc.  When the pin goes HIGH it will pull the pin up and override the resistors, giving a high value reading.  Similarly, when the pin goes low, the resistors will be overridden and a low value reading will be given.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-28T10:59:31.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12964" PostTypeId="1" AcceptedAnswerId="12965" CreationDate="2015-06-28T14:13:50.240" Score="0" ViewCount="5222" Body="&lt;p&gt;Hy guys,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having an issue with my new LCD16x2 display. I connected a potentiometer and read the values. The values are properly read and send to Serial. I also display the values on the display. I am having no issues when increasing the values, but when I go down again at a certain point the displays doesn't display the correct value anymore, but on the Serial I can still see the right readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose this has something to do with the display still storing previous values for this digit in the buffer and when I go down the values are not properly reset. But I don't wan't to clear the whole buffer, since then the whole thing just blinks every iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ESC_Calibration.ino&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MCP23017.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define WHITE 0x7&#xA;&#xA;Servo firstESC;&#xA;Servo secondESC;&#xA;int throttlePin = 2;&#xA;int firstESCPin = 2;&#xA;int secondESCPin = 3;&#xA;&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;    lcd.begin(16, 2);&#xA;    lcd.setBacklight(WHITE);&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;throttle:&quot;);&#xA;&#xA;    firstESC.attach(firstESCPin);&#xA;    secondESC.attach(secondESCPin);&#xA;}&#xA;&#xA;void loop() {&#xA;    int throttle = analogRead(throttlePin);&#xA;    throttle = map(throttle, 0, 1023, 0, 179);&#xA;&#xA;    lcd.setCursor(0, 1);&#xA;        Serial.println(throttle);&#xA;        lcd.setCursor(0, 1);&#xA;    lcd.print(throttle);&#xA;&#xA;    firstESC.write(throttle);&#xA;    secondESC.write(throttle);&#xA;&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have a suggestion how to improve this and fix it, so it'll display the right readings, but doesn't blink?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help in advance! :-)&lt;/p&gt;&#xA;" OwnerUserId="10376" LastActivityDate="2015-06-28T16:32:10.783" Title="LCD-Display showing wrong numbers" Tags="|lcd|display|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12965" PostTypeId="2" ParentId="12964" CreationDate="2015-06-28T15:39:53.307" Score="1" Body="&lt;p&gt;As you have surmised, the problem is that the LCD retains what was there before and you need to clear it away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means, as the numbers increase you get, say,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4&#xA;10&#xA;48&#xA;89&#xA;194&#xA;309&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When they go down though, because the LCD remembers what was there, only the characters you print will be replaced:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;309 (309)&#xA;194 (194)&#xA;894 (89 - the 4 remains from before)&#xA;484 (48 - the 4 remains from before)&#xA;104 (10 - the 4 remains from before)&#xA;404 (4 - the 04 remains from before)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, as you have noticed, clearing the whole screen is not very nice since it makes it flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To combat that it is important that you only overwrite the characters that you need to overwrite and leave those that want to stay.  There's two common ways of doing this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Append enough spaces after the number to force an overwrite:&#xA;&lt;code&gt;&#xA;lcd.print(throttle);&#xA;lcd.print(&quot;   &quot;); // 3 spaces should be enough for 3 extra digits&#xA;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Format the data with &lt;code&gt;snprintf()&lt;/code&gt;:&#xA;&lt;code&gt;&#xA;char temp[5]; // enough room for 4 numbers and one NULL character&#xA;snprintf(temp, 5, &quot;%4d&quot;, throttle); // %4d = 4 digits, right aligned&#xA;lcd.print(temp);&#xA;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The latter method, though it is more complex and uses more resources, can be preferred because it creates a much nicer output with the numbers properly right-aligned.  Also arbitrarily adding spaces after the number could overwrite things you want to keep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also achieve a similar result doing it manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (throttle &amp;lt; 10) lcd.print(&quot; &quot;); // 0-9 add one space&#xA;if (throttle &amp;lt; 100) lcd.print(&quot; &quot;); // 0-99 add one space&#xA;if (throttle &amp;lt; 1000) lcd.print(&quot; &quot;); // 0-999 add one space&#xA;lcd.print(throttle);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just like with cats, there's many ways to skin this problem...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-06-28T16:32:10.783" LastActivityDate="2015-06-28T16:32:10.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12968" PostTypeId="1" CreationDate="2015-06-28T18:59:33.617" Score="2" ViewCount="180" Body="&lt;p&gt;&lt;code&gt;Hello,&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently working on a DIY project and I would like to know the Maximum Wattage of a Arduino Nano with a ATmega328 processor. If anyone know what it is it would be a great help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Ricky&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10877" LastActivityDate="2015-06-28T18:59:33.617" Title="What is the Arduino Nano maximum wattage?" Tags="|power|arduino-nano|hardware|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="12969" PostTypeId="2" ParentId="9388" CreationDate="2015-06-28T21:40:41.960" Score="5" Body="&lt;p&gt;I2C requires interrupts to work, however enabling interrupts inside an ISR is &lt;strong&gt;not recommended&lt;/strong&gt;. For one thing you may get into a race condition, where another interrupt occurs while processing the existing one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are doing virtually nothing in your main loop, a more sensible design would be to simply test if it is time to take a reading, and when that time is up, take the reading then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, your main loop could be rewritten as:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long lastReading;&#xA;unsigned long lastDisplay;&#xA;void loop()&#xA;{&#xA;  if (millis () - lastReading &amp;gt;= 5)   // 200 Hz&#xA;    {&#xA;    lastReading = millis ();&#xA;    // Update x, y, and z with new values 2.5ms     &#xA;    getGyroValues(); &#xA;    cont++;&#xA;    }&#xA;&#xA;  if (millis () - lastDisplay &amp;gt;= 1000)  // one second&#xA;    {&#xA;    lastDisplay = millis ();&#xA;    Serial.println(cont);&#xA;    Serial.println(z);&#xA;    cont=0; &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you don't need the timer, and you are interrupt-friendly. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information about interrupts: &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/interrupts&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:09:40.277" LastActivityDate="2015-07-01T21:09:40.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12970" PostTypeId="1" CreationDate="2015-06-28T22:20:15.947" Score="2" ViewCount="1255" Body="&lt;p&gt;I recently built an RC car from scratch and I am using a PS4 controller to control it.  I have an ESC of course but my problem is I barely touch the joystick and the motor is going so fast I cannot control the car. Here is the code and any help would be much appreciated. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Example sketch for the PS4 Bluetooth library - developed by Kristian Lauszus&#xA; For more information visit my blog: http://blog.tkjelectronics.dk/ or&#xA; send me an e-mail:  kristianl@tkjelectronics.com&#xA; */&#xA;&#xA;#include &amp;lt;PS4BT.h&amp;gt;&#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;// Satisfy the IDE, which needs to see the include statment in the ino too.&#xA;#ifdef dobogusinclude&#xA;#include &amp;lt;spi4teensy3.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#endif&#xA;&#xA;USB Usb;&#xA;//USBHub Hub1(&amp;amp;Usb); // Some dongles have a hub inside&#xA;BTD Btd(&amp;amp;Usb); // You have to create the Bluetooth Dongle instance like so&#xA;Servo servo1;  //Steering Servo&#xA;Servo servo2;  //DC Motor&#xA;&#xA;/* You can create the instance of the PS4BT class in two ways */&#xA;// This will start an inquiry and then pair with the PS4 controller - you only have to do this once&#xA;// You will need to hold down the PS and Share button at the same time, the PS4 controller will then start to blink rapidly indicating that it is in paring mode&#xA;PS4BT PS4(&amp;amp;Btd, PAIR);&#xA;&#xA;// After that you can simply create the instance like so and then press the PS button on the device&#xA;//PS4BT PS4(&amp;amp;Btd);&#xA;&#xA;bool printAngle, printTouch;&#xA;uint8_t oldL2Value, oldR2Value;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;#if !defined(__MIPSEL__)&#xA;  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection&#xA;#endif&#xA;  if (Usb.Init() == -1) {&#xA;    Serial.print(F(&quot;\r\nOSC did not start&quot;));&#xA;    while (1); // Halt&#xA;  }&#xA;  Serial.print(F(&quot;\r\nPS4 Bluetooth Library Started&quot;));&#xA;&#xA;  pinMode (3, OUTPUT);&#xA;  pinMode (5, OUTPUT);&#xA;  servo1.attach (3);&#xA;  servo2.attach (5);&#xA;}&#xA;void loop() {&#xA;  Usb.Task();&#xA;&#xA;  if (PS4.connected()) {&#xA;&#xA;    {&#xA;    servo1.write(map(PS4.getAnalogHat(RightHatX), 0, 255, 50, 0)); &#xA;       //map values from the x-axis of the right analog stick&#xA;    servo2.write(map(PS4.getAnalogHat(LeftHatY), 0, 255, 0, 180));&#xA;       //map values from the y-axis of the left analog stick&#xA;    }}&#xA;&#xA;    else&#xA;&#xA;    {&#xA;      servo1.write (25);  // set servo motor to 0 point&#xA;      servo2.write (90);  // Turn DC motor off &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10879" LastEditorDisplayName="user6430" LastEditDate="2015-06-28T22:24:18.197" LastActivityDate="2015-06-28T22:24:18.197" Title="PS4 controller too touchy on the arduino RC car i built" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12971" PostTypeId="2" ParentId="11737" CreationDate="2015-06-28T22:27:14.647" Score="1" Body="&lt;p&gt;The OneWire stuff can be quite slow. I think I timed doing a temperature read at 12.5 mS which is a long time to be in an ISR. I think you will find that the master assumes it is going to get no response and times out, in that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=10902&quot; rel=&quot;nofollow&quot;&gt;1-Wire Peripheral Interface - for Arduino &lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I suggest you do, is get the temperature in the slave, as often as you want, and then just return the temperature when requested. eg.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile float lastTemp;&#xA;&#xA;void loop(){&#xA;  sensors.requestTemperatures();&#xA;  float t = sensors.getTempCByIndex(0);&#xA;  // protect move of 4 bytes&#xA;  noInterrupts ();&#xA;  lastTemp = t;&#xA;  interrupts ();&#xA;}&#xA;&#xA;void requestEvent(){&#xA;  Wire.write ((char *) lastTemp, sizeof lastTemp);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Untested, but that is the general idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation about interrrupts, and why I am turning off interrupts when moving the temperature to a global variable: &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/interrupts&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:12:45.627" LastActivityDate="2015-07-01T21:12:45.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12972" PostTypeId="2" ParentId="12838" CreationDate="2015-06-28T23:52:56.520" Score="1" Body="&lt;p&gt;Yes, I've had this problem on a number of boards. It seems there are some faulty units coming out of the factory. I've had them replaced by my supplier, but I end up being sent more faulty boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It makes any kind of accurate ADC reading impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick way to work out if your board has this problem&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Place a jumper between 3.3v and A0 &lt;/li&gt;&#xA;&lt;li&gt;Put an analogRead in a loop and println the result&lt;/li&gt;&#xA;&lt;li&gt;When powered by 5V you'll see a fairly constant value (around 670), varying by 1 or 2&lt;/li&gt;&#xA;&lt;li&gt;When powered by 12V, if you have a faulty board, you'll see varying values, deviating by 50 or more.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There's a couple of solutions/workarounds to the problem listed here: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=235729.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=235729.0&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10880" LastActivityDate="2015-06-28T23:52:56.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12973" PostTypeId="1" CreationDate="2015-06-29T02:27:27.860" Score="2" ViewCount="2221" Body="&lt;p&gt;I'd like to make a chess-board with the ability to detect the position of each piece.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution that occurs to me would be to put an RFID reader under each square and put RFID tags on the bottoms of each piece.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, apart from the obvious cost (64 readers!) I'm concerned that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maybe RFID readers are too large for the squares of an ordinary chessboard&lt;/li&gt;&#xA;&lt;li&gt;RFID reader range is too large, so a reader might pick up pieces on neighbouring squares&lt;/li&gt;&#xA;&lt;li&gt;How the hell would I connect 64 readers anyway? Could an Arduino handle it? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this just stupid? And is there a better technology to use for this kind of application?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If RFIDs are basically a sane solution, what are the issues/suggestions? E.g. which RFID readers should I go for? (Based on size, energy, convenience for this application). What boards would let me handle this number of them?&lt;/p&gt;&#xA;" OwnerUserId="10883" LastEditorUserId="6936" LastEditDate="2015-08-07T12:17:06.590" LastActivityDate="2015-08-07T12:17:06.590" Title="Smart Chess-board (possibly using RFIDs?)" Tags="|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12974" PostTypeId="1" CreationDate="2015-06-29T02:29:37.313" Score="2" ViewCount="1056" Body="&lt;p&gt;I have put together a breadboard version of the arduino by following the tutorial on arduino's main website &lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Standalone&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done everything exactly how that tutorial explains it and have double checked my work to ensure I didn't mess up a connection somehow. I have a usb mini breadout board that I am connecting from the breadboard to my computer and the pin outs are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GND -&gt; Breadboard GND&lt;/li&gt;&#xA;&lt;li&gt;5v -&gt; Breadboard + rail&lt;/li&gt;&#xA;&lt;li&gt;TXO -&gt; IC pin 2&lt;/li&gt;&#xA;&lt;li&gt;RXI -&gt; IC pin 3&lt;/li&gt;&#xA;&lt;li&gt;GND (GRN) -&gt; IC pin 1 through .1μF cap&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When I go to the arduino IDE and select the arduino duemilanove setting and upload a sketch I come out with this error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a pre-bootloaded atmega328 chip and have switched it out with two others to make sure it wasn't the switch, but that didn't help either. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what might be the problem?&lt;/p&gt;&#xA;" OwnerUserId="10884" OwnerDisplayName="nfoggia" LastEditorUserId="10884" LastEditDate="2015-06-30T03:02:40.020" LastActivityDate="2016-08-23T17:57:09.230" Title="Breadboard Arduino not loading sketches" Tags="|arduino-uno|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12976" PostTypeId="2" ParentId="12973" CreationDate="2015-06-29T03:38:05.447" Score="4" Body="&lt;p&gt;As I read your post an idea came to me that must be obvious in its simplicity.  Since a chess board has pieces already on it we can simply use hall-effect sensors (dirt cheap) under each square and each piece has a magnet at its base.  Since pieces on a chess board move from one square to another and the initial position of all pieces is known/constant, the detection of a move would be that a piece is lifted from the board (hall effect sensor detects a magnetic field removal) and a piece being placed on a square would be detected by a hall effect senor addition of a magnetic field.  We wouldn't know which piece is placed on a square but we can calculate it by remembering what piece was lifted and it can only be the piece that was placed.&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-29T03:38:05.447" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="12977" PostTypeId="1" CreationDate="2015-06-29T03:40:44.990" Score="1" ViewCount="6152" Body="&lt;p&gt;I want to program Attiny88 with Arduino IDE 1.6.5. I chose Attiny88  because it's the cheapest Attiny (as low as $0.5) and at the same time has 28 pins. I found a library that support Attiny88 (&lt;a href=&quot;https://github.com/TCWORLD/ATTinyCore&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TCWORLD/ATTinyCore&lt;/a&gt;) but it seams it does not support IDE 1.6.5 and generates errors when I burn bootloader or during ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any library to program Attiny88 with Arduino 1.6.5?&lt;/p&gt;&#xA;" OwnerUserId="10885" LastActivityDate="2015-08-02T16:28:46.320" Title="Attiny88 programming with Arduino" Tags="|attiny|isp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12978" PostTypeId="2" ParentId="3269" CreationDate="2015-06-29T05:14:01.010" Score="6" Body="&lt;p&gt;Also be warned that the &lt;code&gt;L&lt;/code&gt; LED (the one activated by pin 13) may light up if pin 13 is high-impedance (set to input), and is not connected to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my Uno, a trivial sketch like this lights up the &lt;code&gt;L&lt;/code&gt; LED:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because the LED is not driven directly by pin 13, but by an op-amp (U5B) which -- if the pin is configured as an input -- may pick up enough stray voltage to activate and light up the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be confusing because you might look at your board and think &quot;huh? I didn't command that LED to come on&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-29T05:14:01.010" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12979" PostTypeId="1" AcceptedAnswerId="12982" CreationDate="2015-06-29T05:31:50.917" Score="1" ViewCount="33662" Body="&lt;p&gt;Hey all I am trying to convert a string into a uint8_t with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String data = &quot;#255101987&quot;;&#xA;String tmp1 = data.substring(1, 3);&#xA;&#xA;uint8_t first  = (String)tmp1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am getting the error of:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;cannot convert 'String' to 'uint8_t {aka unsigned char}' in initialization&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any help would be great as I thought adding &lt;strong&gt;(String)&lt;/strong&gt; in front of the varible would solve the issue but it hasn't as you can tell.&lt;/p&gt;&#xA;" OwnerUserId="5133" LastEditorDisplayName="user31481" LastEditDate="2017-11-17T06:40:24.600" LastActivityDate="2018-06-11T14:33:19.500" Title="Cannot convert 'String' to 'uint8_t {aka unsigned char}' in initialization" Tags="|arduino-ide|string|compilation-errors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12981" PostTypeId="1" CreationDate="2015-06-29T05:45:05.117" Score="1" ViewCount="153" Body="&lt;p&gt;i want to ON-OFF two lights(white and red), one from main power source(white light) and one from ups(battery). When main power is present, white light should be ON and red should be off. And when main power fails, red should be ON and White should be OFF. &#xA;I have Arduino, usb cable, external power supplier(adapter of 12V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can any one please suggest me how do i proceed for this ??&lt;/p&gt;&#xA;" OwnerUserId="10889" LastActivityDate="2015-06-29T10:39:57.470" Title="How to read AC Voltage in arduino uno with 12V adaptor and usb cable.?" Tags="|arduino-uno|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12982" PostTypeId="2" ParentId="12979" CreationDate="2015-06-29T06:12:08.080" Score="3" Body="&lt;pre&gt;&lt;code&gt;uint8_t first  = atoi (tmp1.substring(1, 3).c_str ());   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String data = &quot;#255101987&quot;;&#xA;uint8_t first  = atoi (data.substring(1, 3).c_str ());   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-29T06:12:08.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12984" PostTypeId="1" CreationDate="2015-06-29T09:50:46.207" Score="1" ViewCount="5396" Body="&lt;p&gt;I want to use CapacitiveSensor library in order to make my own aluminum keys piano. I have seen many videos online showing projects like the one I'm trying to do, but for some reason mine doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my cuircit:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/zq7rx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;&#xA;CapacitiveSensor   cs_7_6 = CapacitiveSensor(7,6);  // 10M resistor between pins 7 &amp;amp; 6, pin 6 is sensor pin&#xA;&#xA;void setup()                    &#xA;{&#xA;   //cs_7_6.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example&#xA;   Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()                    &#xA;{&#xA;    long start = millis();&#xA;    long total1 =  cs_7_6.capacitiveSensor(5);&#xA;&#xA;    Serial.print(millis() - start);        // check on performance in milliseconds&#xA;    Serial.print(&quot;\t&quot;);                    // tab character for debug windown spacing&#xA;&#xA;    Serial.print(total1);                  // print sensor output 1&#xA;    Serial.println(&quot;\t&quot;);&#xA;&#xA;    delay(10);                             // arbitrary delay to limit data to serial port &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens whenever I touch the aluminum foil:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/foltu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First nothing happens (for ~1 sec), then it prints -2 as the capacity value, and when I release my finger from the foil it prints a very high value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows the reason for it? I'm searching for an answer for a long time and still can't find a solution...&lt;/p&gt;&#xA;" OwnerUserId="9923" LastActivityDate="2015-06-29T12:26:22.003" Title="Capacitive Sensor gets stuck" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12985" PostTypeId="2" ParentId="12981" CreationDate="2015-06-29T10:39:57.470" Score="1" Body="&lt;p&gt;If your battery voltage is lower than 12 but sufficiently high to power the arduino (let's say 9V), you could put a white LED on the 12V line and a red LED on the battery line, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         WHITE       RED         &#xA;  _______|&amp;gt;|_________|&amp;lt;|________&#xA; |             |                |&#xA;_|_          Arduino           _|_&#xA; - 12V         |                -   Battery&#xA; |_____________|________________|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work, as long as the LEDs can withstand the reverse voltage.&#xA;And you do not need to drive them from the Arduino.&#xA;If you still want to know the status fro mthe Arduino (mains or battery) you can sample the voltage level across the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-06-29T10:39:57.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12986" PostTypeId="2" ParentId="562" CreationDate="2015-06-29T11:51:02.323" Score="0" Body="&lt;p&gt;You're already there with the Arduino IDE; C++ compilers understand plain C just fine, but may interpret C syntax slightly differently in some cases. I write most sketches in C, invoking C++ objects from libraries as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're to the point where you want finer grained control over which compiler, C or C++, gets used for a given module, then it's time to graduate to another environment. Eclipse is a very popular and flexible IDE for a large range of languages, compilers &amp;amp; cross-compilers, and provides a very flexible Arduino environment. Or your favorite shell, programming editor, Make, and the avr-gcc cross-compilation tool-set will give you the ultimate access to and control of every detail - perhaps more than you wanted - of the edit/compile/link/download/debug process.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-06-29T11:51:02.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12987" PostTypeId="2" ParentId="12984" CreationDate="2015-06-29T12:26:22.003" Score="2" Body="&lt;p&gt;The problem is that you're touching the foil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;capacitive sensing&quot; used in that library is crude at best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you read &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense&quot; rel=&quot;nofollow&quot;&gt;the Arduino Playground page for the Capacitive Sensing Library&lt;/a&gt; it discusses a lot of the problems with the library, including grounding.  Make sure that the Arduino is properly grounded, or provide your own ground plane under the foil sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also they talk about the value of resistor and the sensitivity.  With a 10MΩ resistor you get sensing at (supposedly) 4-6cm from the foil.  That's the value you're seeing as you remove your finger.  While you're touching the foil it's just having a complete brain haemorrhage and can't work out what is going on (completely unable to charge the pin since you are leeching off all the current).  For &quot;absolute touch&quot; it recommends no more than 1MΩ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, as I mentioned, that method is rather crude.  To do it properly you need to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Discharge an analog input pin through a MOSFET to ground (low impedance).&lt;/li&gt;&#xA;&lt;li&gt;Apply a constant current (typically 50µA is used but varies depending on ADC characteristics) to the analog input for a fixed amount of time.&lt;/li&gt;&#xA;&lt;li&gt;Remove the current and measure the voltage on the ADC input.&lt;/li&gt;&#xA;&lt;li&gt;Repeat.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;More modern MCUs have this kind of functionality built in, in the form of a &quot;CTMU&quot; - &lt;em&gt;Charge Time Measurement Unit&lt;/em&gt;.  If you want to have anything more than &quot;there's someone vaguely in the vicinity of the sensor&quot; then I would suggest switching to a more modern MCU and doing it properly, or employing a specific CTMU chip as an external device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the sensor should be comprised of three parts - a ground plane, a sensor plane (connected to the ADC) and a dielectric layer between them.  The sensor should also be insulated from direct touch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-06-29T12:26:22.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12988" PostTypeId="1" CreationDate="2015-06-29T13:22:34.467" Score="0" ViewCount="826" Body="&lt;p&gt;I am working on a project and got stuck on a point, and I hope somebody will guide me. I have a hardware device which has different color LEDs (green, red and yellow) and I have to calculate how many times each color LED glows for each mode of operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs that are connected to the device are pretty small and will blink only for a couple of seconds, ao I am looking for a very sensitive light sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what kind of light sensor do I have to use with Arduino UNO to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I go for BH1750 or do you have any other suggestion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="10894" LastEditorUserId="4628" LastEditDate="2015-06-30T17:47:35.310" LastActivityDate="2016-01-27T01:20:53.247" Title="Highly sensitive light sensor to calculate number of times each color LED blinks" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="12989" PostTypeId="1" AcceptedAnswerId="12990" CreationDate="2015-06-29T14:55:17.987" Score="1" ViewCount="112" Body="&lt;p&gt;I am looking at modifying the H3LI331DL I2C library posted by Seed Studio for communicating with the H3LI331DL accelerometer. The library hardcodes the address for the accelerometer in the header file. My end goal is to make the library require a slave address input argument so I can talk to 2 accelerometers on the same I2C bus. The chip has a pin that sets the LSB of its address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now onto the question. The library's .h file has the following statement:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#define H3LIS331DL_MEMS_I2C_ADDRESS     0x18//0x32&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the 0x32 simply commented out or am I missing something here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Emach &lt;/p&gt;&#xA;" OwnerUserId="10896" LastActivityDate="2015-06-29T15:15:59.630" Title="Arduino C++ library syntax" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12990" PostTypeId="2" ParentId="12989" CreationDate="2015-06-29T15:15:59.630" Score="1" Body="&lt;p&gt;It is indeed commented out. SeeedStudio is a great company but their code (including code prettifying) is pretty sloppy, and sometimes a little dumbfounding.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-06-29T15:15:59.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12991" PostTypeId="2" ParentId="9095" CreationDate="2015-06-29T15:41:57.773" Score="-1" Body="&lt;p&gt;your kernel need to provide support to USB ACM.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CONFIG_USB_ACM=y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can look for it at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ zcat /proc/config.gz | grep CONFIG_USB_ACM&#xA;CONFIG_USB_ACM=y&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10897" LastActivityDate="2015-06-29T15:41:57.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12996" PostTypeId="2" ParentId="12988" CreationDate="2015-06-29T20:57:10.190" Score="1" Body="&lt;p&gt;Like the OP wrote, you can use very simple sensors, like a phototransistor.&#xA;Even simpler, if you can somehow isolate each pair LED-phototransistor, you don't even need to care about the color of the led, just use some bluetac to stick one phototransistor on top of each LED and only measure the brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick check on ebay shows the 3DU5C as good candidate: it has a metallic container, so it is more directional than one with full plastic body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3DU5C &lt;a href=&quot;http://www.ebay.com/itm/3DU5C-Silicon-Phototransistor-Transistor-2-feet-Metal-Package-/251556003565?pt=LH_DefaultDomain_0&amp;amp;hash=item3a91e7feed&quot; rel=&quot;nofollow&quot;&gt;ebay link&lt;/a&gt;  and  &lt;a href=&quot;http://www.uctronics.com/download/3DU5C_spec.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is shown to have a peak response at 880nm (red light), so you might not be able to use it directly as digital input for the other 2 colors you want to monitor and instead have to treat it as analog reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OTOH if you use them all as analog inputs, you will not have to add the resistor that would be required for binary mode.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-06-30T19:15:01.580" LastActivityDate="2015-06-30T19:15:01.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="12997" PostTypeId="2" ParentId="12726" CreationDate="2015-06-29T21:06:38.450" Score="0" Body="&lt;p&gt;Try to look at the pinout of the lightning port and create your own breakout. Then you can try taking power from the iPhone. &lt;img src=&quot;https://i.stack.imgur.com/vr7vr.jpg&quot; alt=&quot;Apple&amp;#39;s Lighting port pinout&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10904" LastActivityDate="2015-06-29T21:06:38.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="12999" PostTypeId="2" ParentId="9095" CreationDate="2015-06-29T21:22:41.090" Score="1" Body="&lt;p&gt;On windows systems, &lt;code&gt;COM1&lt;/code&gt; is usually the system port, so you shouldn't use that for programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try updating device drivers by going to &lt;em&gt;device manager&lt;/em&gt; and right click on the &lt;code&gt;COM3&lt;/code&gt; and &lt;code&gt;COM4&lt;/code&gt; icons for the arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this keeps persisting then try reinstalling the ide and restarting your computer&lt;/p&gt;&#xA;" OwnerUserId="10904" LastActivityDate="2015-06-29T21:22:41.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13000" PostTypeId="2" ParentId="12974" CreationDate="2015-06-29T21:28:20.820" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you have a 16Mhz crystal attached to your board at the XTAL locations properly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you dont have one already, connect a 0.1uf capacitor (ceramic or metal film) to the reset pin for auto reset capabilities.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&lt;/code&gt; issue is probably due to reset problems, where the arduino is not communicating to the computer. However, there are other possible reasons for this error. &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=28223.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=28223.0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Double check that TX on the arduino is connected to Rx on the computer and Rx on the arduino is connected to Tx on the computer&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If problems keep persisting, post more information so we can help you more.&lt;/p&gt;&#xA;" OwnerUserId="10904" LastActivityDate="2015-06-29T21:28:20.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13001" PostTypeId="2" ParentId="12796" CreationDate="2015-06-29T21:32:42.103" Score="0" Body="&lt;p&gt;Try to place two distance ranging sensors like ultrasonic or active infrared at the sides of the driveway or garage door. Make sure that their readings are similar so that you know that you are in the center. If one has a higher reading(farther distance) light an led to your right so you know  to go that direction and vice versa. Use communication through xbees, bluetooth, or something similar.&lt;/p&gt;&#xA;" OwnerUserId="10904" LastActivityDate="2015-06-29T21:32:42.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13002" PostTypeId="1" AcceptedAnswerId="13281" CreationDate="2015-06-29T21:20:12.990" Score="1" ViewCount="1503" Body="&lt;p&gt;I am a beginner.. I am trying to control RC servo using Arduino based of data from MPU6050.&#xA;I am using library I2Cdev to communicate with gyro and to get yaw, pitch and roll. I am using example script which I have modified to control servo based on received data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;&#xA;Serial.print(&quot;ypr\t&quot;);&#xA;Serial.print(ypr[0] * 180 / M_PI);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(ypr[1] * 180 / M_PI);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.println(ypr[2] * 180 / M_PI);&#xA;&#xA;pitch_angle = (ypr[1] * 180 / M_PI) + 90;&#xA;roll_angle = (ypr[2] * 180 / M_PI) + 90;   &#xA;&#xA;Serial.print(pitch_angle);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.println(roll_angle);&#xA;&#xA;pitchServo.write((int)(pitch_angle));&#xA;rollServo.write((int)(roll_angle));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without servo being connected everything works well. &#xA;But after I plug in servo after few second being still (it seems to even follow movement of gyro) it starts to shake and then probably whole Arduino stops working (serial transmission of data stops) and Arduino has to be restarted. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;100 95&#xA;ypr 12.21   10.51   5.49&#xA;100 95&#xA;ypr 12.23   10.31   5.48&#xA;100 95&#xA;ypr 12.25   10.15   5.45&#xA;100 95&#xA;ypr 12.27   10.02   5.45&#xA;100 95&#xA;ypr -13.31  30.81   55.76&#xA;120 145&#xA;ypr 20.53   -21.36  -52.59&#xA;68  37&#xA;ypr 64.96   35.38   10.25&#xA;125 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to plug two 100 nF capacitors across power and ground of the servo and I tried to connect servo in to different power source than Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;Servo is not fixed with MPU6050 so there shouldn't be any resonance at least on the mechanical base.&#xA;Wiring is very simple:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/BXnLN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea? Thanks&lt;/p&gt;&#xA;" OwnerUserId="10910" OwnerDisplayName="Jakub Jon" LastEditorUserId="10910" LastEditDate="2015-06-30T06:02:00.983" LastActivityDate="2015-07-08T20:47:29.840" Title="RC servo misbehave using arduino and MPU6050" Tags="|servo|gyroscope|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13004" PostTypeId="2" ParentId="860" CreationDate="2015-06-29T22:27:38.023" Score="3" Body="&lt;p&gt;There are multiple places where you can look. As at IDE 1.6.4 (Ubuntu version) some are in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(install location)/libraries&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But these are the high-level libraries, in particular:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bridge&#xA;Esplora&#xA;Ethernet&#xA;Firmata&#xA;GSM&#xA;LiquidCrystal&#xA;Robot_Control&#xA;RobotIRremote&#xA;Robot_Motor&#xA;SD&#xA;Servo&#xA;SpacebrewYun&#xA;Stepper&#xA;Temboo&#xA;TFT&#xA;WiFi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That does not cover the low-level libraries like Tone, Print, main, etc. These are in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(install location)/hardware/arduino/avr/cores/arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There you would find the Arduino core libraries like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abi.cpp&#xA;Arduino.h&#xA;binary.h&#xA;CDC.cpp&#xA;Client.h&#xA;HardwareSerial0.cpp&#xA;HardwareSerial1.cpp&#xA;HardwareSerial2.cpp&#xA;HardwareSerial3.cpp&#xA;HardwareSerial.cpp&#xA;HardwareSerial.h&#xA;HardwareSerial_private.h&#xA;HID.cpp&#xA;hooks.c&#xA;IPAddress.cpp&#xA;IPAddress.h&#xA;main.cpp&#xA;new.cpp&#xA;new.h&#xA;Printable.h&#xA;Print.cpp&#xA;Print.h&#xA;Server.h&#xA;Stream.cpp&#xA;Stream.h&#xA;Tone.cpp&#xA;Udp.h&#xA;USBAPI.h&#xA;USBCore.cpp&#xA;USBCore.h&#xA;USBDesc.h&#xA;WCharacter.h&#xA;WInterrupts.c&#xA;wiring_analog.c&#xA;wiring.c&#xA;wiring_digital.c&#xA;wiring_private.h&#xA;wiring_pulse.c&#xA;wiring_shift.c&#xA;WMath.cpp&#xA;WString.cpp&#xA;WString.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However even that does not locate things like strcpy. The &lt;strong&gt;header&lt;/strong&gt; files for them can be found at:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(install location)/hardware/tools/avr/avr/include/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There you will find:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alloca.h&#xA;assert.h&#xA;ctype.h&#xA;errno.h&#xA;inttypes.h&#xA;math.h&#xA;setjmp.h&#xA;stdfix-avrlibc.h&#xA;stdint.h&#xA;stdio.h&#xA;stdlib.h&#xA;string.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Even that is not the full story. In a subdirectory (avr) you will find the avr-related things, with files for different processors, such as (in part):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boot.h&#xA;builtins.h&#xA;common.h&#xA;cpufunc.h&#xA;crc16.h&#xA;delay.h&#xA;eeprom.h&#xA;fuse.h&#xA;interrupt.h&#xA;io1200.h&#xA;io2313.h&#xA;...&#xA;iox64d4.h&#xA;iox8e5.h&#xA;lock.h&#xA;parity.h&#xA;pgmspace.h&#xA;portpins.h&#xA;power.h&#xA;sfr_defs.h&#xA;signal.h&#xA;signature.h&#xA;sleep.h&#xA;version.h&#xA;wdt.h&#xA;xmega.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for the source of strcpy, I don't think it is in the distribution. They include the standard libraries, pre-compiled. For example, if you look in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(install location)/hardware/tools/avr/avr/lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see various pre-compiled libraries, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libc.a&#xA;libm.a&#xA;libprintf_flt.a&#xA;libprintf_min.a&#xA;libscanf_flt.a&#xA;libscanf_min.a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To find the source you would need to find where the AVR source of libc is (possibly at &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avr-libc/&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for the Mac, all this stuff is a few levels down in the &quot;Application Package&quot; which you can view by right-clicking and selecting &quot;Show Package Contents&quot;. Look in the &lt;code&gt;Contents/Resources/Java&lt;/code&gt; folder.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;None&lt;/strong&gt; of these places are where you should put your &lt;strong&gt;own&lt;/strong&gt; libraries (ones you write or download). They should go into the &lt;code&gt;libraries&lt;/code&gt; folder which is a subdirectory of your &lt;code&gt;sketchbook&lt;/code&gt; folder. Create the &lt;code&gt;libraries&lt;/code&gt; folder if it does not exist. That way user-installed libraries persist from one version of the IDE to the next.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-06-29T22:32:46.447" LastActivityDate="2015-06-29T22:32:46.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13005" PostTypeId="2" ParentId="5287" CreationDate="2015-06-29T23:23:06.790" Score="2" Body="&lt;p&gt;I think you have two issues here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Much to my surprise, when I unplug the Arduino, the digital output pin is still reading 4V. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With a powered device connected to the input pins, the overvoltage protection diodes power your 5V line with what is called &quot;parasitic power&quot;. Those diodes are supposed to clamp an input pin to not exceed 5V, but if the power is off, they actually &lt;strong&gt;supply&lt;/strong&gt; 5V (assuming at least some of the pins are high), hence powering up the processor. It is not designed to do this, and you should not power off the processor in this way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Second:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My problem is that when the digital output pin is told to go low, it only goes down to about 4V.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried out your code, but without the encoder to hand, I just comment out the three &quot;if&quot; tests:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//  if (TDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= TDC[i])  &#xA;...&#xA;//  if (BDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= BDC[i])  &#xA;...&#xA;//  if (Cycle == true &amp;amp;&amp;amp; CamAngle &amp;lt; (PrevCamAngle + 1))  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A multimeter on pin 53 reads 0.98V, however this is because the pin is being turned on and off quickly. I can't work out for sure whether some or all of these conditions would be satisfied in sequence (they don't seem directly related). One thing you could do, since you seem to want pin 53 either on or off is use &quot;else&quot;, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (TDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= TDC[i])  &#xA;{&#xA;...&#xA;} else if (BDCycle == true &amp;amp;&amp;amp; CamAngle &amp;gt;= BDC[i]) &#xA;{&#xA;...&#xA;}&#xA;else if (Cycle == true &amp;amp;&amp;amp; CamAngle &amp;lt; (PrevCamAngle + 1))  &#xA;{&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you won't have multiple attempts to turn the pin on &lt;strong&gt;and&lt;/strong&gt; off through one turn through the loop.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-29T23:23:06.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13006" PostTypeId="2" ParentId="9989" CreationDate="2015-06-30T01:58:56.747" Score="1" Body="&lt;p&gt;There is no point in using SoftwareSerial on pins 0 and 1, as you have HardwareSerial for that. Whatever the sketch does once it starts will not affect whether or not it uploads. If you have something connected to pins 0 and 1, during the upload, that may well stop the upload working, but what the sketch does afterwards does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is hard to tell from your snippet, but if you also have activated HardwareSerial - eg. &lt;code&gt;Serial.begin(9600);&lt;/code&gt; - then the hardware takes over those two pins and SoftwareSerial won't work anyway.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-30T01:58:56.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13007" PostTypeId="2" ParentId="9845" CreationDate="2015-06-30T02:05:51.373" Score="4" Body="&lt;p&gt;Don't do delay() calls inside an ISR. In all probability it will hang indefinitely. If you want to play the tone for a second all you need to do in the ISR is set a flag, which you test in the main loop. Turn the buzzer on when the flag changes state. Remember when you did that. When a second is up turn the buzzer off again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact in your case you probably don't need the interrupt at all. Test for the reed switch change in the main loop as well. Don't overcomplicate it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-30T02:05:51.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13008" PostTypeId="2" ParentId="12256" CreationDate="2015-06-30T03:10:02.163" Score="0" Body="&lt;pre&gt;&lt;code&gt;       rpm=60*1000*count/(millis()-starttime);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since rpm is an unsigned int (which has a maximum of 65535) you will almost certainly overflow if count is more than 1, which will give you negative numbers, or incorrect positive numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus, outputting to serial constantly will cause the program to lock up waiting for the serial buffer to empty, which will throw out any timings you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest making rpm unsigned long (or float as you seem to have done already) and only display the RPM every second or so.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see my page &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11916&quot; rel=&quot;nofollow&quot;&gt;Using the Arduino Analog Comparator&lt;/a&gt;. This is a much faster way of detecting an analog signal merely passing some threshold. This only takes a few microseconds compared to 104 µS for a single analogRead. In the ISR then you just add one to a counter (which is the number of times it passes the threshold). Every second take this counter, and work out the RPM, then zero it. Make sure you make a copy of the counter in a protected way as shown on my page about &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-06-30T04:53:49.857" LastActivityDate="2015-06-30T04:53:49.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13009" PostTypeId="2" ParentId="12256" CreationDate="2015-06-30T04:38:53.037" Score="0" Body="&lt;p&gt;A possibility I am toying with for a similar problem is realizing that there will always be a delay between valid sensor readings.  For example, imagine you had a maximum speed of 10 revolutions/second.  That would mean that there would be a maximum of 10 sensor inputs/second or 1 interrupt every 100 msecs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you changed your interrupt processing logic to something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (millis() - timeOfLastSensorReading &amp;gt;= 10) {&#xA;   count++;&#xA;   timeOfLastSensorReading = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then your logic would become &quot;Only register a sensor change if at least 10 msecs has passed since the last reading&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might have to tune the values based on your real situation ... but it might go a long way to eliminate some aspects of false readings.&lt;/p&gt;&#xA;" OwnerUserId="9911" LastActivityDate="2015-06-30T04:38:53.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13010" PostTypeId="2" ParentId="12383" CreationDate="2015-06-30T05:09:04.883" Score="1" Body="&lt;p&gt;Maybe look at &lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot; rel=&quot;nofollow&quot;&gt;NeoPixels Revealed: How to (not need to) generate precisely timed signals&lt;/a&gt;. The author there controlled 1000 Neopixels with a Duemilanove with fairly simple code. These were WS2812 not WS2811 but perhaps the code could be adapted to suit. Judging by the datasheets they are fairly similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since he got 30 fps with 1000 pixels, your requirement of around 100 pixels would seem fairly straightforward.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-30T05:09:04.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13011" PostTypeId="1" CreationDate="2015-06-30T04:00:20.727" Score="2" ViewCount="1587" Body="&lt;p&gt;I found some information that the attiny88 and attiny828 can be programed from an arduino, similar to the programing of the attiny85/45, simply connecting the right pins. &lt;a href=&quot;https://electronics.stackexchange.com/questions/98970/how-to-program-atmel-attiny88-not-45-or-85&quot;&gt;https://electronics.stackexchange.com/questions/98970/how-to-program-atmel-attiny88-not-45-or-85&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what I have not been able to find out are the arduino cores (drivers) for the attiny88 and attiny828.&#xA;I wonder if the cores (or drivers) to program the attiny88 and attiny828 from an arduino are available somewhere or would they have to be constructed?. &lt;/p&gt;&#xA;" OwnerUserId="10989" OwnerDisplayName="user3029447" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-06-30T05:24:51.810" Title="programming attiny88 &amp; attiny828 with arduino" Tags="|attiny|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13012" PostTypeId="2" ParentId="6640" CreationDate="2015-06-30T06:34:44.203" Score="1" Body="&lt;p&gt;You said you are using a Xbee shield.  What shield is it, and what pins does it use for Serial communications?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were using software to emulate the second serial port on other arduinos, you were probably using different pins, and so if the shield is designed to communicate over (as an example) pins 2 and 3 then it will most likely not work with pin 0 and 1 without moving jumpers or switches.  For example, this &#xA;Xbee Shield: &lt;a href=&quot;http://core-electronics.com.au/xbee-shield.html/?acc=9f61408e3afb633e50cdf1b20de6f466&quot; rel=&quot;nofollow&quot;&gt;http://core-electronics.com.au/xbee-shield.html/?acc=9f61408e3afb633e50cdf1b20de6f466&lt;/a&gt; has a switch to switch between pins 0 and 1 and pins 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try some code that reads from Serial and prints the data to Serial1 and visa versa.  This means you can experiment to get a greater understanding of the problem.&lt;/p&gt;&#xA;" OwnerUserId="10912" LastActivityDate="2015-06-30T06:34:44.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13013" PostTypeId="2" ParentId="8374" CreationDate="2015-06-30T06:44:41.323" Score="2" Body="&lt;p&gt;All you need to do is analyse the packet on-the-fly using a state machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/statemachine&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You certainly don't need to hold the entire packet at once, however you &lt;strong&gt;do&lt;/strong&gt; need room for the information the packet contains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say, for example, that the packet, although wordy, contains 4 x 32-bit numbers of interest. All you need memory for is those 4 numbers, plus a minor extra amount for the current data you are processing (eg. the current state, and the current number being assembled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conceptually it is like streaming a movie to your PC. The PC doesn't need to hold the whole movie, it just needs to hold the current frame, and a few seconds in advance, just to keep things running smoothly.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-06-30T06:44:41.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13014" PostTypeId="2" ParentId="4661" CreationDate="2015-06-30T06:49:27.193" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    char byteSend = RS485Serial.read();    // Read received byte&#xA;    String str = String(byteSend);&#xA;     if (str == &quot;&amp;lt;&quot;)  {      //  beginning of the transmission&#xA;   // does stuff here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an extremely inefficient way of testing for one character. Much better would be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    char byteSend = RS485Serial.read();    // Read received byte&#xA;    if (byteSend == '&amp;lt;')  {      //  beginning of the transmission&#xA;   // does stuff here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, I'd like to make it so that the Slave can be disconnected and reconnected to the line and re-discover the connection (ideally without resetting either Arduino). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know I'm not supposed to ask questions here, but what is stopping you?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:11:08.027" LastActivityDate="2015-07-01T21:11:08.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13016" PostTypeId="1" CreationDate="2015-06-30T12:00:09.247" Score="1" ViewCount="967" Body="&lt;p&gt;I have been getting started with the Arduino and found a great project online called &lt;a href=&quot;http://www.righto.com/2009/12/tv-b-gone-for-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;TV-B-Gone&lt;/a&gt;. It includes some code which I cannot compile. Yes I have included &lt;code&gt;main.h&lt;/code&gt; and &lt;code&gt;worldcodes.cpp&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;TV-B-Gone for Arduino version 0.001&#xA; Ported to Arduino by Ken Shirriff, Dec 3, 2009&#xA; http://arcfn.com&#xA; &#xA; The original code is:&#xA; TV-B-Gone Firmware version 1.2&#xA; for use with ATtiny85v and v1.2 hardware&#xA; (c) Mitch Altman + Limor Fried 2009&#xA; Last edits, August 16 2009&#xA; &#xA; With some code from:&#xA; Kevin Timmerman &amp;amp; Damien Good 7-Dec-07&#xA; &#xA; Distributed under Creative Commons 2.5 -- Attib &amp;amp; Share Alike&#xA; &#xA; This is the 'universal' code designed for v1.2 - it will select EU or NA&#xA; depending on a pulldown resistor on pin B1 !&#xA; */&#xA;&#xA;#include &amp;quot;main.h&amp;quot;&#xA;&#xA;void xmitCodeElement(uint16_t ontime, uint16_t offtime, uint8_t PWM_code );&#xA;void flashslowLEDx( uint8_t num_blinks );&#xA;void quickflashLEDx( uint8_t x );&#xA;void tvbgone_sleep( void );&#xA;void delay_ten_us(uint16_t us);&#xA;void quickflashLED( void );&#xA;uint8_t read_bits(uint8_t count);&#xA;&#xA;#define putstring_nl(s) Serial.println(s)&#xA;#define putstring(s) Serial.print(s)&#xA;#define putnum_ud(n) Serial.print(n, DEC)&#xA;#define putnum_uh(n) Serial.print(n, HEX)&#xA;&#xA;/*&#xA;This project transmits a bunch of TV POWER codes, one right after the other, &#xA; with a pause in between each.  (To have a visible indication that it is &#xA; transmitting, it also pulses a visible LED once each time a POWER code is &#xA; transmitted.)  That is all TV-B-Gone does.  The tricky part of TV-B-Gone &#xA; was collecting all of the POWER codes, and getting rid of the duplicates and &#xA; near-duplicates (because if there is a duplicate, then one POWER code will &#xA; turn a TV off, and the duplicate will turn it on again (which we certainly &#xA; do not want).  I have compiled the most popular codes with the &#xA; duplicates eliminated, both for North America (which is the same as Asia, as &#xA; far as POWER codes are concerned -- even though much of Asia USES PAL video) &#xA; and for Europe (which works for Australia, New Zealand, the Middle East, and &#xA; other parts of the world that use PAL video).&#xA; &#xA; Before creating a TV-B-Gone Kit, I originally started this project by hacking &#xA; the MiniPOV kit.  This presents a limitation, based on the size of&#xA; the Atmel ATtiny2313 internal flash memory, which is 2KB.  With 2KB we can only &#xA; fit about 7 POWER codes into the firmware's database of POWER codes.  However,&#xA; the more codes the better! Which is why we chose the ATtiny85 for the &#xA; TV-B-Gone Kit.&#xA; &#xA; This version of the firmware has the most popular 100+ POWER codes for &#xA; North America and 100+ POWER codes for Europe. You can select which region &#xA; to use by soldering a 10K pulldown resistor.&#xA; */&#xA;&#xA;&#xA;/*&#xA;This project is a good example of how to use the AVR chip timers.&#xA; */&#xA;&#xA;&#xA;/*&#xA;The hardware for this project uses an Arduino:&#xA; Connect an IR LED to pin 3.&#xA; Connect a visible LED to pin 13 (or use builtin LED in some Arduinos).&#xA; Connect a pushbutton between pin 1 and ground.&#xA; Pin 0 is floating for North America, or wired to ground for Europe.&#xA; */&#xA;&#xA;&#xA;&#xA;extern PGM_P *NApowerCodes[] PROGMEM;&#xA;extern PGM_P *EUpowerCodes[] PROGMEM;&#xA;extern uint8_t num_NAcodes, num_EUcodes;&#xA;&#xA;/* This function is the 'workhorse' of transmitting IR codes.&#xA; Given the on and off times, it turns on the PWM output on and off&#xA; to generate one 'pair' from a long code. Each code has ~50 pairs! */&#xA;void xmitCodeElement(uint16_t ontime, uint16_t offtime, uint8_t PWM_code )&#xA;{&#xA;  TCNT2 = 0;&#xA;  if(PWM_code) {&#xA;    pinMode(IRLED, OUTPUT);&#xA;    // Fast PWM, setting top limit, divide by 8&#xA;    // Output to pin 3&#xA;    TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;    TCCR2B = _BV(WGM22) | _BV(CS21);&#xA;  } &#xA;  else {&#xA;    // However some codes dont use PWM in which case we just turn the IR&#xA;    // LED on for the period of time.&#xA;    digitalWrite(IRLED, HIGH);&#xA;  }&#xA;&#xA;  // Now we wait, allowing the PWM hardware to pulse out the carrier &#xA;  // frequency for the specified 'on' time&#xA;  delay_ten_us(ontime);&#xA;&#xA;  // Now we have to turn it off so disable the PWM output&#xA;  TCCR2A = 0;&#xA;  TCCR2B = 0;&#xA;  // And make sure that the IR LED is off too (since the PWM may have &#xA;  // been stopped while the LED is on!)&#xA;  digitalWrite(IRLED, LOW);&#xA;&#xA;  // Now we wait for the specified 'off' time&#xA;  delay_ten_us(offtime);&#xA;}&#xA;&#xA;/* This is kind of a strange but very useful helper function&#xA; Because we are using compression, we index to the timer table&#xA; not with a full 8-bit byte (which is wasteful) but 2 or 3 bits.&#xA; Once code_ptr is set up to point to the right part of memory,&#xA; this function will let us read 'count' bits at a time which&#xA; it does by reading a byte into 'bits_r' and then buffering it. */&#xA;&#xA;uint8_t bitsleft_r = 0;&#xA;uint8_t bits_r=0;&#xA;PGM_P code_ptr;&#xA;&#xA;// we cant read more than 8 bits at a time so dont try!&#xA;uint8_t read_bits(uint8_t count)&#xA;{&#xA;  uint8_t i;&#xA;  uint8_t tmp=0;&#xA;&#xA;  // we need to read back count bytes&#xA;  for (i=0; i&amp;lt;count; i++) {&#xA;    // check if the 8-bit buffer we have has run out&#xA;    if (bitsleft_r == 0) {&#xA;      // in which case we read a new byte in&#xA;      bits_r = pgm_read_byte(code_ptr++);&#xA;      // and reset the buffer size (8 bites in a byte)&#xA;      bitsleft_r = 8;&#xA;    }&#xA;    // remove one bit&#xA;    bitsleft_r--;&#xA;    // and shift it off of the end of 'bits_r'&#xA;    tmp |= (((bits_r &amp;gt;&amp;gt; (bitsleft_r)) &amp;amp; 1) &amp;lt;&amp;lt; (count-1-i));&#xA;  }&#xA;  // return the selected bits in the LSB part of tmp&#xA;  return tmp; &#xA;}&#xA;&#xA;&#xA;/*&#xA;The C compiler creates code that will transfer all constants into RAM when &#xA; the microcontroller resets.  Since this firmware has a table (powerCodes) &#xA; that is too large to transfer into RAM, the C compiler needs to be told to &#xA; keep it in program memory space.  This is accomplished by the macro PROGMEM &#xA; (this is used in the definition for powerCodes).  Since the C compiler assumes &#xA; that constants are in RAM, rather than in program memory, when accessing&#xA; powerCodes, we need to use the pgm_read_word() and pgm_read_byte macros, and &#xA; we need to use powerCodes as an address.  This is done with PGM_P, defined &#xA; below.  &#xA; For example, when we start a new powerCode, we first point to it with the &#xA; following statement:&#xA; PGM_P thecode_p = pgm_read_word(powerCodes+i);&#xA; The next read from the powerCode is a byte that indicates the carrier &#xA; frequency, read as follows:&#xA; const uint8_t freq = pgm_read_byte(code_ptr++);&#xA; After that is a byte that tells us how many 'onTime/offTime' pairs we have:&#xA; const uint8_t numpairs = pgm_read_byte(code_ptr++);&#xA; The next byte tells us the compression method. Since we are going to use a&#xA; timing table to keep track of how to pulse the LED, and the tables are &#xA; pretty short (usually only 4-8 entries), we can index into the table with only&#xA; 2 to 4 bits. Once we know the bit-packing-size we can decode the pairs&#xA; const uint8_t bitcompression = pgm_read_byte(code_ptr++);&#xA; Subsequent reads from the powerCode are n bits (same as the packing size) &#xA; that index into another table in ROM that actually stores the on/off times&#xA; const PGM_P time_ptr = (PGM_P)pgm_read_word(code_ptr);&#xA; */&#xA;&#xA;uint16_t ontime, offtime;&#xA;uint8_t i,j, Loop;&#xA;uint8_t region = US;     // by default our code is U&#xA;&#xA;void setup()   {                &#xA;  Serial.begin(9600);&#xA;&#xA;  TCCR2A = 0;&#xA;  TCCR2B = 0;&#xA;&#xA;  digitalWrite(LED, LOW);&#xA;  digitalWrite(IRLED, LOW);&#xA;  pinMode(LED, OUTPUT);&#xA;  pinMode(IRLED, OUTPUT);&#xA;  pinMode(REGIONSWITCH, INPUT);&#xA;  pinMode(TRIGGER, INPUT);&#xA;  digitalWrite(REGIONSWITCH, HIGH); //Pull-up&#xA;  digitalWrite(TRIGGER, HIGH);&#xA;&#xA;  delay_ten_us(5000);            // Let everything settle for a bit&#xA;&#xA;  // determine region&#xA;  if (digitalRead(REGIONSWITCH)) {&#xA;    region = US; // US&#xA;    DEBUGP(putstring_nl(&amp;quot;US&amp;quot;));&#xA;  } &#xA;  else {&#xA;    region = EU;&#xA;    DEBUGP(putstring_nl(&amp;quot;EU&amp;quot;));&#xA;  }&#xA;&#xA;  // Tell the user what region we're in  - 3 is US 4 is EU&#xA;  quickflashLEDx(3+region);&#xA;&#xA;  // Indicate how big our database is&#xA;  DEBUGP(putstring(&amp;quot;\n\rNA Codesize: &amp;quot;); &#xA;  putnum_ud(num_NAcodes);&#xA;  );&#xA;  DEBUGP(putstring(&amp;quot;\n\rEU Codesize: &amp;quot;); &#xA;  putnum_ud(num_EUcodes);&#xA;  );&#xA;}&#xA;&#xA;void sendAllCodes() {&#xA;  // We may have different number of codes in either database&#xA;  if (region == US) {&#xA;    j = num_NAcodes;&#xA;  } &#xA;  else {&#xA;    j = num_EUcodes;&#xA;  }&#xA;&#xA;  // for every POWER code in our collection&#xA;  for (i=0 ; i &amp;lt; j; i++) {&#xA;    PGM_P data_ptr; &#xA;&#xA;    // print out the code # we are about to transmit&#xA;    DEBUGP(putstring(&amp;quot;\n\r\n\rCode #: &amp;quot;); &#xA;    putnum_ud(i));&#xA;&#xA;    // point to next POWER code, from the right database&#xA;    if (region == US) {&#xA;      data_ptr = (PGM_P)pgm_read_word(NApowerCodes+i);  &#xA;    } &#xA;    else {&#xA;      data_ptr = (PGM_P)pgm_read_word(EUpowerCodes+i);  &#xA;    }&#xA;&#xA;    // print out the address in ROM memory we're reading&#xA;    DEBUGP(putstring(&amp;quot;\n\rAddr: &amp;quot;); &#xA;    putnum_uh((uint16_t)data_ptr));&#xA;&#xA;    // Read the carrier frequency from the first byte of code structure&#xA;    const uint8_t freq = pgm_read_byte(data_ptr++);&#xA;    // set OCR for Timer1 to output this POWER code's carrier frequency&#xA;    OCR2A = freq; &#xA;    OCR2B = freq / 3; // 33% duty cycle&#xA;&#xA;    // Print out the frequency of the carrier and the PWM settings&#xA;    DEBUGP(putstring(&amp;quot;\n\rOCR1: &amp;quot;); &#xA;    putnum_ud(freq);&#xA;    );&#xA;    DEBUGP(uint16_t x = (freq+1) * 2; &#xA;    putstring(&amp;quot;\n\rFreq: &amp;quot;); &#xA;    putnum_ud(F_CPU/x);&#xA;    );&#xA;&#xA;    // Get the number of pairs, the second byte from the code struct&#xA;    const uint8_t numpairs = pgm_read_byte(data_ptr++);&#xA;    DEBUGP(putstring(&amp;quot;\n\rOn/off pairs: &amp;quot;); &#xA;    putnum_ud(numpairs));&#xA;&#xA;    // Get the number of bits we use to index into the timer table&#xA;    // This is the third byte of the structure&#xA;    const uint8_t bitcompression = pgm_read_byte(data_ptr++);&#xA;    DEBUGP(putstring(&amp;quot;\n\rCompression: &amp;quot;); &#xA;    putnum_ud(bitcompression);&#xA;    putstring(&amp;quot;\n\r&amp;quot;));&#xA;&#xA;    // Get pointer (address in memory) to pulse-times table&#xA;    // The address is 16-bits (2 byte, 1 word)&#xA;    PGM_P time_ptr = (PGM_P)pgm_read_word(data_ptr);&#xA;    data_ptr+=2;&#xA;    code_ptr = (PGM_P)pgm_read_word(data_ptr);&#xA;&#xA;    // Transmit all codeElements for this POWER code &#xA;    // (a codeElement is an onTime and an offTime)&#xA;    // transmitting onTime means pulsing the IR emitters at the carrier &#xA;    // frequency for the length of time specified in onTime&#xA;    // transmitting offTime means no output from the IR emitters for the &#xA;    // length of time specified in offTime&#xA;&#xA;#if 0&#xA;&#xA;    // print out all of the pulse pairs&#xA;    for (uint8_t k=0; k&amp;lt;numpairs; k++) {&#xA;      uint8_t ti;&#xA;      ti = (read_bits(bitcompression)) * 4;&#xA;      // read the onTime and offTime from the program memory&#xA;      ontime = pgm_read_word(time_ptr+ti);&#xA;      offtime = pgm_read_word(time_ptr+ti+2);&#xA;      DEBUGP(putstring(&amp;quot;\n\rti = &amp;quot;); &#xA;      putnum_ud(ti&amp;gt;&amp;gt;2); &#xA;      putstring(&amp;quot;\tPair = &amp;quot;); &#xA;      putnum_ud(ontime));&#xA;      DEBUGP(putstring(&amp;quot;\t&amp;quot;); &#xA;      putnum_ud(offtime));&#xA;    }&#xA;    continue;&#xA;#endif&#xA;&#xA;    // For EACH pair in this code....&#xA;    cli();&#xA;    for (uint8_t k=0; k&amp;lt;numpairs; k++) {&#xA;      uint16_t ti;&#xA;&#xA;      // Read the next 'n' bits as indicated by the compression variable&#xA;      // The multiply by 4 because there are 2 timing numbers per pair&#xA;      // and each timing number is one word long, so 4 bytes total!&#xA;      ti = (read_bits(bitcompression)) * 4;&#xA;&#xA;      // read the onTime and offTime from the program memory&#xA;      ontime = pgm_read_word(time_ptr+ti);  // read word 1 - ontime&#xA;      offtime = pgm_read_word(time_ptr+ti+2);  // read word 2 - offtime&#xA;      // transmit this codeElement (ontime and offtime)&#xA;      xmitCodeElement(ontime, offtime, (freq!=0)); &#xA;    } &#xA;    sei();&#xA;&#xA;    //Flush remaining bits, so that next code starts&#xA;    //with a fresh set of 8 bits.&#xA;    bitsleft_r=0;   &#xA;&#xA;    // delay 250 milliseconds before transmitting next POWER code&#xA;    //delay_ten_us(25000);&#xA;    delay_ten_us(10000);&#xA;&#xA;    // visible indication that a code has been output.&#xA;    quickflashLED(); &#xA;  } &#xA;  while (Loop == 1);&#xA;&#xA;  // flash the visible LED on PB0  4 times to indicate that we're done&#xA;  delay_ten_us(65500); // wait maxtime &#xA;  delay_ten_us(65500); // wait maxtime &#xA;  quickflashLEDx(4);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  if (digitalRead(TRIGGER) == 0) {&#xA;    sendAllCodes();&#xA;  }&#xA;}&#xA;&#xA;&#xA;/****************************** LED AND DELAY FUNCTIONS ********/&#xA;&#xA;&#xA;// This function delays the specified number of 10 microseconds&#xA;// it is 'hardcoded' and is calibrated by adjusting DELAY_CNT &#xA;// in main.h Unless you are changing the crystal from 8mhz, dont&#xA;// mess with this.&#xA;void delay_ten_us(uint16_t us) {&#xA;  uint8_t timer;&#xA;  while (us != 0) {&#xA;    // for 8MHz we want to delay 80 cycles per 10 microseconds&#xA;    // this code is tweaked to give about that amount.&#xA;    for (timer=0; timer &amp;lt;= DELAY_CNT; timer++) {&#xA;      NOP;&#xA;      NOP;&#xA;    }&#xA;    NOP;&#xA;    us--;&#xA;  }&#xA;}&#xA;&#xA;&#xA;// This function quickly pulses the visible LED (connected to PB0, pin 5)&#xA;// This will indicate to the user that a code is being transmitted&#xA;void quickflashLED( void ) {&#xA;  digitalWrite(LED, HIGH);&#xA;  delay_ten_us(30);       // 30 millisec delay&#xA;  digitalWrite(LED, LOW);&#xA;}&#xA;&#xA;// This function just flashes the visible LED a couple times, used to&#xA;// tell the user what region is selected&#xA;void quickflashLEDx( uint8_t x ) {&#xA;  quickflashLED();&#xA;  while(--x) {&#xA;    delay_ten_us(DELAY);  // 150 millisec delay between flahes&#xA;    quickflashLED();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I try compile and upload to my Arduino Mega 2560, I get this error&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;In file included from main.h:9:0,&#xA;                 from TVB.pde:21:&#xA;TVB:78: error: variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA;TVB:79: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA;variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Is there any way I can fix this?&lt;/p&gt;&#xA;" OwnerUserId="10917" LastEditorUserId="4854" LastEditDate="2022-07-31T20:12:37.083" LastActivityDate="2022-07-31T20:12:37.083" Title="Error compiling code (tv-b gone)" Tags="|arduino-mega|compile|ir|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13017" PostTypeId="1" CreationDate="2015-06-30T12:10:45.563" Score="2" ViewCount="29144" Body="&lt;p&gt;I am trying to make an ultrasonic distance meter using Arduino. For this I added the ultrasonic library. But on compiling it shows this error &quot;ultrasonic.h&#xA;not available&quot;. Please tell me how to add this .h file.&lt;/p&gt;&#xA;" OwnerUserId="10801" LastEditorUserId="4628" LastEditDate="2015-11-30T15:04:23.803" LastActivityDate="2018-11-22T21:35:11.777" Title="How to add .h file in library" Tags="|library|" AnswerCount="1" CommentCount="3" ClosedDate="2018-02-23T03:40:37.163" ContentLicense="CC BY-SA 3.0" />
  <row Id="13019" PostTypeId="2" ParentId="13017" CreationDate="2015-06-30T14:31:39.923" Score="4" Body="&lt;p&gt;In you Arduino Sketch folder there is a folder called &lt;strong&gt;Libraries&lt;/strong&gt;, create a folder there and put your header file in that folder and restart the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (PC):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Documents/Arduino/Libraries/ultrasonic/ultrasonic.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can now use it in all your projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to use with a particular sketch, place in in the same folder as you  sketch and restart Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="37523" LastEditDate="2018-11-22T21:35:11.777" LastActivityDate="2018-11-22T21:35:11.777" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13020" PostTypeId="1" CreationDate="2015-06-30T15:45:41.213" Score="1" ViewCount="4982" Body="&lt;p&gt;I have an Arduino Uno with a Wireless SD Shield and XBee S1 and a PC with another XBee S1 connected to it. What I'm after is for me to be able to send a message from my computer and receive a message back from the Arduino (For now let's just say if the Arduino receives a &quot;1&quot; I want it to send an &quot;A&quot; back)&#xA;Here is the code I have been practicing with (courtesy of SparkFun)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial XBee(0, 1); // RX, TX&#xA;&#xA;void setup() {&#xA;  XBee.begin(9600);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) { &#xA;    XBee.write(Serial.read());&#xA;  }&#xA;  if (XBee.available()) { &#xA;    Serial.write(XBee.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I have changed the pins from 2,3 to 0,1 as the latter is on the Arduino itself)&#xA;I have set my Xbees up and have been able to get them to talk to each other when both connected to separate PC's, but I am having trouble getting the Arduino to send information to the other XBee. When I try and send data from the Arduino IDE both RX and TX Led's flash. &#xA;Could anyone steer me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="10922" LastEditorUserId="3917" LastEditDate="2015-11-27T23:07:50.480" LastActivityDate="2018-01-19T08:12:00.420" Title="2 way communication between Arduino with XBee and Computer" Tags="|arduino-uno|xbee|softwareserial|ide|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13021" PostTypeId="2" ParentId="13020" CreationDate="2015-06-30T16:03:49.080" Score="2" Body="&lt;p&gt;You don't need to declare an extra (software) serial port because the wireless shield connects the Arduino TX and RX on pins 0 and 1 directly to the TX and RX of the Xbee. So, Serial.available, Serial.read and Serial.write directly addresses the xbee. Just leave out the software serial from your code and it should work.  &lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-06-30T16:03:49.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13022" PostTypeId="1" AcceptedAnswerId="13024" CreationDate="2015-06-30T16:22:28.350" Score="0" ViewCount="15560" Body="&lt;p&gt;I am working on the temperature project using arduino to collect temperature. But sometimes arduino hang there so I have to unplug cord and plug it back in to restart the arduino. I do not when it is going to hang up again. So I decide to do some research on the internet but no luck for that. Here is &lt;a href=&quot;http://sysmagazine.com/posts/189744/&quot; rel=&quot;nofollow&quot;&gt;the article&lt;/a&gt; I read about resetting arduino code with watchdog timer library.(unfortunately, it only work for arduino uno) If someone has any idea how to reset arduino mega 2560 code. Please help !!&lt;/p&gt;&#xA;" OwnerUserId="10923" LastActivityDate="2017-02-24T05:05:54.813" Title="How to reset arduino Mega 2560 code automatically?" Tags="|arduino-mega|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13023" PostTypeId="2" ParentId="13022" CreationDate="2015-06-30T17:36:17.513" Score="0" Body="&lt;p&gt;You could also use an external circuit to reset the arduino when 'heartbeat' pulses are missed. You can even detect when a reset has occured and report accordingly. See &lt;a href=&quot;https://github.com/Bra1nK/HomeMonitor/tree/master/External%20Watchdog&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for an example &lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-06-30T17:36:17.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13024" PostTypeId="2" ParentId="13022" CreationDate="2015-06-30T17:40:45.633" Score="3" Body="&lt;p&gt;avr-libc already has the appropriate functions created for you. Just include &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;avr/wdt.h&amp;gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample usage&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;   wdt_enable(WDTO_8S);&#xA;   ...&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   wdt_reset();// make sure this gets called at least once every 8 seconds!&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-06-30T17:40:45.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13028" PostTypeId="2" ParentId="13022" CreationDate="2015-06-30T20:41:42.520" Score="1" Body="&lt;p&gt;I tried Gerben's suggestion with a display:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (F(&quot;Code starting ...&quot;));&#xA;  wdt_enable(WDTO_8S);&#xA;  }  // end of setup&#xA;&#xA;void loop()&#xA;{&#xA;//   wdt_reset();// make sure this gets called at least once every 8 seconds!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does indeed print &quot;Code starting ...&quot; every 8 seconds or so.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But sometimes arduino hang there so I have to unplug cord and plug it back in to restart the arduino. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are better off working out &lt;strong&gt;why&lt;/strong&gt;. There is probably a bug. Fix the bug rather than just restarting the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:06:48.983" LastActivityDate="2015-07-01T21:06:48.983" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13029" PostTypeId="1" AcceptedAnswerId="13030" CreationDate="2015-06-30T23:58:16.597" Score="4" ViewCount="2624" Body="&lt;p&gt;I bought an assembled Arduino Uno protoshield version 5, similar to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/oqbZo.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought it because I would like to solder wires from Arduino IOs, and I was quite disappointed with the impossibility to do so, since the solder points are already taken by the female headers, which are not connected to anything (there are not tracks coming from then to other islands, which I find quite dumb).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am considering to remove (by desoldering) the headers, so I can access the holes for soldering wires (instead of plugging them to headers), but before doing so, I ask:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a good way to solder wires so they are electrically connected to the Arduino IO pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8044" LastActivityDate="2018-03-18T01:18:06.203" Title="How to directly solder wires to protoshield to connect them to Arduino pins" Tags="|shields|prototype|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13030" PostTypeId="2" ParentId="13029" CreationDate="2015-07-01T00:02:17.097" Score="5" Body="&lt;p&gt;For the signals, get some AWG30 wire and solder them underneath to the female header pads. For power, get some AWG22 or AWG24 wire and solder them to the top of the male header pads.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-01T00:02:17.097" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13031" PostTypeId="1" CreationDate="2015-07-01T00:35:36.943" Score="0" ViewCount="83" Body="&lt;p&gt;I am new in this site, and like you can see I want to do a line follower, not a clumsy and slow line follower, but a fast and &quot;fancy&quot;.&#xA;I investigated about the PID method, but can someone explain me in simple words what is it.&#xA;Thanks for your answers.&lt;/p&gt;&#xA;" OwnerUserId="10931" LastActivityDate="2015-07-01T01:28:33.077" Title="What is the best way to make a good but simple line follower?" Tags="|robotics|" AnswerCount="1" CommentCount="3" ClosedDate="2015-07-04T16:34:11.817" ContentLicense="CC BY-SA 3.0" />
  <row Id="13032" PostTypeId="2" ParentId="13031" CreationDate="2015-07-01T01:23:27.257" Score="2" Body="&lt;p&gt;Did you check wikipedia, for example?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt it is possible to describe a PID controller in simpler words than those used by &lt;a href=&quot;https://en.wikipedia.org/wiki/PID_controller&quot; rel=&quot;nofollow&quot;&gt;the article&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/PID_controller#Pseudocode&quot; rel=&quot;nofollow&quot;&gt;pseudocode&lt;/a&gt; is quite simple and should be also very good for understanding the concept, when applied to a digital system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the &lt;a href=&quot;https://en.wikipedia.org/wiki/PID_controller#Limitations_of_PID_control&quot; rel=&quot;nofollow&quot;&gt;limitations&lt;/a&gt; of PID controllers.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-01T01:23:27.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13035" PostTypeId="2" ParentId="13002" CreationDate="2015-07-01T01:52:27.363" Score="0" Body="&lt;p&gt;So a couple of ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) you need to be real careful with the MPU and overflows. You do not show all your code, but you must check for overflows, and ignore the data if one has occurred. I see in your print a stray negative value, that tells me you are not skipping bad data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) I dont know how 'tight' your loop is. You need to service the MPU a lot. In fact the sample you used, uses an interrupt to do so. I think the default update rate is about 100 times per second.  That may be too fast to make large changes in servo positions.  You will need to think about moving slower from point A to B if the difference is more than the servo can handle at that speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) You are adding 90. With the numbers you have shown that is probably ok, but in your final code you need to be careful you do not exceed a servos range, 0 to 180.  the map() function is probably something you will want to use, instead of just adding 90.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) My guess is that since it works for a second or 2, it is indeed over flowing data, and then goes to heck. Especially since you do not skip errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) it takes the 6050 30 seconds or so to settle - so you will see large gyro drift (including PitchRollYaw) until it does. Probably not what your code is expecting.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-07-01T02:08:12.590" LastActivityDate="2015-07-01T02:08:12.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13036" PostTypeId="2" ParentId="316" CreationDate="2015-07-01T02:27:55.460" Score="0" Body="&lt;p&gt;In the event that you want to detect a voltage passing a &lt;strong&gt;threshold&lt;/strong&gt;, rather than being merely HIGH or LOW, you can use the analog comparator. Example sketch:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile boolean triggered;&#xA;&#xA;ISR (ANALOG_COMP_vect)&#xA;  {&#xA;  triggered = true;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  ADCSRB = 0;           // (Disable) ACME: Analog Comparator Multiplexer Enable&#xA;  ACSR =  bit (ACI)     // (Clear) Analog Comparator Interrupt Flag&#xA;        | bit (ACIE)    // Analog Comparator Interrupt Enable&#xA;        | bit (ACIS1);  // ACIS1, ACIS0: Analog Comparator Interrupt Mode Select (trigger on falling edge)&#xA;   }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (triggered)&#xA;    {&#xA;    Serial.println (&quot;Triggered!&quot;); &#xA;    triggered = false;&#xA;    }&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be useful for things like light-detectors, where you might need to detect a change from (say) 1V to 2V on an input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HnZp5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use the Input Capture Unit on the processor, which will remember the exact time of certain inputs, by saving the current count of Timer/Counter 1. This lets you store the exact (well, almost exact) moment that the event of interest occurred, rather than introducing the delay (of probably a few microseconds) before an ISR can be used to capture the current time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For timing-critical applications, this can give somewhat increased accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example application: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12075&quot; rel=&quot;nofollow noreferrer&quot;&gt;Turn your Arduino into a capacitor tester&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-01T21:10:22.833" LastActivityDate="2015-07-01T21:10:22.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13037" PostTypeId="1" AcceptedAnswerId="13088" CreationDate="2015-07-01T03:44:50.293" Score="2" ViewCount="2030" Body="&lt;p&gt;I am attempting to develop a control system based upon rocket velocity. My first step is attempting to properly filter my sensor data in order to calculate velocity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best approach to get accurate, smooth, and fast data to my control logic? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would I benefit from combining accelerometer and barometric data? If so, how?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently only using a BMP180 barometer to get altitude and then calculating velocity from the last altitude measurement. I am operating the BMP180 on ultra low power to increase the sample rate, but that comes at a cost of a RMS noise of around 0.5 meters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 1D Kalman filtering I can get it smoothed out somewhat (tried on both velocity and altitude), but it is still not anywhere near as smooth as I need for my control system. It also lags behind the data far too much when I get it smoothed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attached an example of what I have done with Kalman filtering. The original data is from a Featherweight Raven altimeter. I used the reported altitude data to calculate velocity (standard deltX/deltT) for each iteration, filtered it, and compared it with the Raven's own calculated velocity from it's accelerometer. The altitude data is at 20 Hz which is about what I am achieving with my Arduino setup right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FVwp5.png&quot; alt=&quot;Kalman Filtering Result&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10933" LastActivityDate="2016-01-13T00:40:28.447" Title="Velocity from Sensor Data - Best Approach?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13038" PostTypeId="1" AcceptedAnswerId="13039" CreationDate="2015-07-01T05:43:28.267" Score="4" ViewCount="6154" Body="&lt;p&gt;I am relatively new to Arduino and I am currently writing some code to control a relay board. The on/off times are provided by the user at run-time and should be stored persistently (EEPROM or flash) in case of power-down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my Uno I worked with the EEPROMex library and that worked well. Now I have a Due which doesnt have any EEPROM and I am struggling how to store variables persistently. Specifically, I dont know how to access whatever I wrote to the flash memory previously. In the example below the content of test[] is obviously overwritten on every restart.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM int test[] = {1, 2, 3, 123, 23};&#xA;&#xA;void test()&#xA;{&#xA;  Serial.println((long)test);&#xA;  for (int i = 0; i &amp;lt; 5; i++)&#xA;  {&#xA;    Serial.println(test[i]++);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed that the address does not change during re-starts, so I I tried reading/writing beyond index 4. This out-of-bounds read/write worked, I guess since I am anyway not storing anything else. Interestingly even this memory which is out of the array is overwritten on power-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: How do I store on unser input data (variables) persistenly on an Arduino due without using any shields?&lt;/p&gt;&#xA;" OwnerUserId="10928" LastEditorUserId="56438" LastEditDate="2020-02-19T14:44:10.280" LastActivityDate="2020-12-04T03:13:44.480" Title="How to read/write variables persistenly on Arduino Due (no EEPROM/shield)?" Tags="|arduino-due|flash|eeprom|eepromex|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13039" PostTypeId="2" ParentId="13038" CreationDate="2015-07-01T06:38:04.397" Score="2" Body="&lt;p&gt;I really hope that somebody knows differently, but I'm fairly sure that the answer is that you can't directly save runtime data back to the Arduino Due board.  I've looked into this myself and have only found answers saying &quot;wire up an external EEPROM&quot; or similar.  Whilst it seems that it should be technically possible to write into unused (or pre-reserved) areas of the program memory, I suspect that the CPU has to be put into a special mode to do this, which is very probably only possible from the bootloader when flashing a new program to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've chosen to go with FRAM chips for data storage. &lt;a href=&quot;http://uk.rs-online.com/web/p/fram-memory-chips/7332240/&quot; rel=&quot;nofollow&quot;&gt;Link to mine.&lt;/a&gt;  They are difficult to wire up - the only ones I found were in surface mount packages (although some hobby retailers sell them mounted to little boards with header pins), but they are very cheap, very durable (you can write to them a great number of times before they wear out), operate at high speeds and you can read/write single bytes from/to them.  Other storage chips often require you to write whole &quot;pages&quot; of data at a time which can mean reading in the existing data, modifying it, then writing it back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional comments:&#xA;In your original question, you state that the contents of your PROGMEM located array must be restored on restarts.  I don't think this is the case.  That would suggest that the contents are stored elsewhere and code is in place to overwrite them, however it could be the case that they are copied into working RAM, which would mean that the PROGMEM macro is not actually doing anything on the Due - which may well be the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modify your code to change one of the values of the array (within the bounds of the array!) and then print its value out again after changing it.  If the value printed has changed then this means that PROGMEM is not actually doing what it is supposed to do on the Due, which would be a real shame.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorUserId="8616" LastEditDate="2015-07-01T06:47:36.713" LastActivityDate="2015-07-01T06:47:36.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13040" PostTypeId="2" ParentId="13038" CreationDate="2015-07-01T09:50:37.463" Score="1" Body="&lt;p&gt;Without an external device you won't be able to store data permanently. So it might not be a full shield, but you'll have to add SOMETHING. Depending on how much data you need you might use components that have EEPROM as a side feature. For instance, as explained &lt;a href=&quot;https://kongduino.wordpress.com/2014/01/19/rtc_spare_memory/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, the DS1337 RTC module has 56 spare bytes of EEPROM^H^H^H^H^H^H Non-Volatile RAM available. I know, it sure isn't much, BUT it might be enough for your needs, depending on how much you need to store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course it provides you with DateTime capabilities, wich could come in handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from this, there are EEPROM chips mounted on a small board, with DIP switches to set the I2C address, which would be very discrete, and could store a large amount of data. See &lt;a href=&quot;http://www.emartee.com/product/41949/Arduino-EEPROM-Shield-With-512K-AT24C512&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; for instance.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastEditorUserId="4628" LastEditDate="2015-07-02T10:42:48.213" LastActivityDate="2015-07-02T10:42:48.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13041" PostTypeId="1" AcceptedAnswerId="13042" CreationDate="2015-07-01T10:17:42.453" Score="0" ViewCount="87" Body="&lt;p&gt;Why does this print output -3? xpos can be any value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;xPos = analogRead(xPin);&#xA;yPos = analogRead(yPin);&#xA;pwm = xPos*(255/1023);&#xA;Serial.println(pwm);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10936" LastEditorUserId="2881" LastEditDate="2015-07-01T12:39:20.010" LastActivityDate="2015-07-01T21:42:13.233" Title="Why is this returning the wrong answer?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13042" PostTypeId="2" ParentId="13041" CreationDate="2015-07-01T10:46:16.127" Score="1" Body="&lt;p&gt;The problem is that &lt;code&gt;(255/1023)&lt;/code&gt; is being treated as an integer calculation, meaning the result gets truncated to 0. You can make the compiler promote it to a floating-point calculation by explicitly making at least one of the values floating-point. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pwm = xPos*(255.0f/1023.0f);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-07-01T10:46:16.127" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13043" PostTypeId="1" AcceptedAnswerId="13044" CreationDate="2015-07-01T11:30:11.463" Score="0" ViewCount="798" Body="&lt;p&gt;I am trying to read information coming from an Atlas Scientific FLO30 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code works fine in an individual sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String inputstring = &quot;&quot;;                                                       //a string to hold incoming data from the PC&#xA;String sensorstring = &quot;&quot;;                                                      //a string to hold the data from the Atlas Scientific product&#xA;String LPM=&quot;&quot;;&#xA;float LPM_INT;&#xA;&#xA;boolean input_stringcomplete = false;                                          //have we received all the data from the PC&#xA;boolean sensor_stringcomplete = false;                                         //have we received all the data from the Atlas Scientific product&#xA;#define CIRC_PUMP_PIN 10 // circulation pump pin - high when on, low when off&#xA;&#xA;unsigned long previousMillis = 0;        // will store last time LED was updated&#xA;&#xA;// constants won't change :&#xA;const long interval = 1000;   &#xA;&#xA;&#xA;&#xA;  void setup(){                                                                //set up the hardware&#xA;     Serial.begin(9600);                                                       //set baud rate for the hardware serial port_0 to 9600&#xA;     Serial3.begin(38400);                                                      //set baud rate for software serial port_3 to 9600&#xA;     inputstring.reserve(5);                                                   //set aside some bytes for receiving data from the PC&#xA;     sensorstring.reserve(30);                                                 //set aside some bytes for receiving data from Atlas Scientific product&#xA;     pinMode(CIRC_PUMP_PIN,OUTPUT);&#xA;     digitalWrite(CIRC_PUMP_PIN,HIGH);&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;&#xA;&#xA;unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt;= interval) {&#xA;    // save the last time you blinked the LED &#xA;    previousMillis = currentMillis;   &#xA;&#xA;            if(Serial3.available()&amp;gt;0){&#xA;              while(sensor_stringcomplete==false){&#xA;        char inchar = (char)Serial3.read();                              //get the char we just received&#xA;              sensorstring += inchar;                                          //add it to the inputString&#xA;              Serial.println(&quot;adding to string&quot;);&#xA;            if(inchar == '\r') {sensor_stringcomplete = true;}               //if the incoming character is a &amp;lt;CR&amp;gt;, set the flag &#xA;             }&#xA;            }&#xA;&#xA;&#xA; if (sensor_stringcomplete){                                                   //if a string from the Atlas Scientific product has been received in its entierty &#xA;      Serial.println(sensorstring);                                            //send that string to to the PC's serial monitor&#xA;      byte n = sensorstring.length();&#xA;      LPM = sensorstring.substring(n-8,n);&#xA;      Serial.print(&quot;This is the extracted part &quot;);&#xA;      Serial.println(LPM);&#xA;      LPM_INT=LPM.toFloat();&#xA;      Serial.print(&quot;Now in float &quot;);&#xA;      Serial.println(LPM_INT);&#xA;      LPM=&quot;&quot;;&#xA;      sensorstring = &quot;&quot;;                                                       //clear the string:&#xA;      sensor_stringcomplete = false;                                           //reset the flag used to tell if we have received a completed string from the Atlas Scientific product&#xA;      }&#xA;&#xA;      if(sensor_stringcomplete==false){&#xA;       Serial.println(&quot;Skipping&quot;);&#xA;&#xA;      }&#xA;  }&#xA;&#xA;&#xA;&#xA;&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;however when I try to integrate the code with another master sketch, the Arduino seems to jam or lockup when it enters the following part of the code, which is called periodically from the main void loop():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if(Serial3.available()&amp;gt;0){&#xA;      while(sensor_stringcomplete==false){&#xA;char inchar = (char)Serial3.read();                              //get the char we just received&#xA;      sensorstring += inchar;                                          //add it to the inputString&#xA;      Serial.println(&quot;adding to string&quot;);&#xA;    if(inchar == '\r') {sensor_stringcomplete = true;}               //if the incoming character is a &amp;lt;CR&amp;gt;, set the flag &#xA;     }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the code is the same and I do not understand why the Arduino locks up. I intially thought it was a problem with memory as the master code is singificantly bigger but the line  &quot;sensorstring = &quot;&quot;;  &quot; and &quot;sensorstring.reserve(30) &quot; should take care of this? Besides it cannot even get one reading from the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone give insight as to why this might be?&lt;/p&gt;&#xA;" OwnerUserId="10938" LastActivityDate="2015-07-01T11:58:23.670" Title="Serial3.available loop issue" Tags="|serial|arduino-mega|memory-usage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13044" PostTypeId="2" ParentId="13043" CreationDate="2015-07-01T11:58:23.670" Score="0" Body="&lt;p&gt;Firstly, don't use String.  It's wasteful of memory and the dynamic aspects of it don't sit well on a tiny resource-starved 8-bit microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, your method of reading from the serial is flawed right from the start.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Serial3.available()&amp;gt;0){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... If there is at least 1 character available ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(sensor_stringcomplete==false){&#xA;    char inchar = (char)Serial3.read(); //get the char we just received&#xA;    sensorstring += inchar;     //add it to the inputString&#xA;    Serial.println(&quot;adding to string&quot;);&#xA;    if(inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a &amp;lt;CR&amp;gt;, set the flag &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... read characters until I get the end of string character regardless of if those characters are even available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to read the data from the serial port you have to ensure that the data is actually available.  Just waiting for the first character to arrive and then reading (much faster than the serial is able to receive) other characters is doomed to failure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have discussed this at great length in a blog article, including how to perform non-blocking string reads that will not interfere with the rest of your program: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It even mentions your specific situation since it is something that is so commonly done wrong.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-01T11:58:23.670" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13045" PostTypeId="2" ParentId="12977" CreationDate="2015-07-01T16:11:46.663" Score="2" Body="&lt;p&gt;Finally I found ATTinyCore library. I have tested it with a blink sketch. Just download the zip file. Unzip and copy  Attinycore-master directory into &quot;program files/Arduino/hardware/arduino/avr&quot; directory. Restart the IDEA. Select ATTiny x8 Series from the boards menu, and select the specific chip (48 or 88), clock speed, and BOD level from the appropriate menus that will appear in the tools menu after selecting ATTiny x8 series as the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/SpenceKonde/ATTinyCore&quot; rel=&quot;nofollow&quot;&gt;https://github.com/SpenceKonde/ATTinyCore&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10885" LastActivityDate="2015-07-01T16:11:46.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13047" PostTypeId="1" AcceptedAnswerId="13049" CreationDate="2015-07-01T17:21:29.107" Score="0" ViewCount="262" Body="&lt;p&gt;I've searched the web but could not find a straightforward answer to my query.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building a control board for one of my models and this time have decided to also include a computer interface, so I have incorporated an Arduino Uno into my project instead of just analog circuits. I'm not an electronics expert of any sort but I manage by applying basic logic and a lot of trial and error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I have a single Arduino. It is operating the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An LCD display,&#xA;a 4 button operation panel I made using an LS148 ic,&#xA;an L293 operating 2 small motors,&#xA;a servo,&#xA;a dark sensor,&#xA;a temperature sensor,&#xA;and it also does serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is working great, but slow (or so it appears to me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i push a button it takes the board about a second to pick up on the signal while an external LED indicator shows the circuit using the LS148 is working as it should. (I basically chained the 1-4 inputs and checking the truth table on the board to determine which button was pressed). Or pick up on a signal sent from the dark sensor for example. It appears as if the whole code in the Arduino runs at a cycle of once per second. Also sending instructions from the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I disable the LCD code everything works fast(er) and so goes when I remove other parts. So my question is, have I overloaded it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am on the verge of ordering another board (which I am going to do anyway), but in this case it is purely due to my belief that if I connect the LCD with the whole display code onto one board and the rest of the sensors and chips to another it will solve my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't figured out yet if it's possible to link the two boards or how to do that, but once I'll get to that bridge I'll cross it as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your advice.&lt;/p&gt;&#xA;" OwnerUserId="10946" LastEditorUserId="4628" LastEditDate="2015-07-02T19:15:20.870" LastActivityDate="2015-07-02T19:15:20.870" Title="A question about the possible limits of an Arduino Uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13048" PostTypeId="1" CreationDate="2015-07-01T17:29:17.887" Score="2" ViewCount="216" Body="&lt;p&gt;I'm really interested in arduino but I don't know much about it. I want to buy a starter kit to play with, but when I searched it on amazon, there are couple unofficial starter kit and a more expensive official one. So, can some one tell me the major difference between the unofficial starter kit and official starter kit? And which one would you recommend me to buy? Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, bonus question: why is the start kit(&lt;a href=&quot;http://store-usa.arduino.cc/products/arduino-starter-kit&quot; rel=&quot;nofollow&quot;&gt;$89&lt;/a&gt;) in arduino website is much cheaper than the official starter kit in amazon(&lt;a href=&quot;http://www.amazon.ca/Arduino-Starter-Official-170-page-Projects/dp/B009UKZV0A/ref=sr_1_1?ie=UTF8&amp;amp;qid=1435770992&amp;amp;sr=8-1&amp;amp;keywords=arduino%20starter%20kit&quot; rel=&quot;nofollow&quot;&gt;$120&lt;/a&gt;)?&lt;/p&gt;&#xA;" OwnerUserId="10945" LastEditorUserId="10945" LastEditDate="2015-07-01T17:34:22.650" LastActivityDate="2015-07-01T22:59:50.220" Title="Beginner here, trying to start learning arduino, which starter kit should I buy?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13049" PostTypeId="2" ParentId="13047" CreationDate="2015-07-01T17:33:04.137" Score="4" Body="&lt;p&gt;A lot of Arduino code is written either generally inefficiently, or written in completely the wrong way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, take the LCD code.  Commands have to be sent at the right speed with the proper delays in there for things to happen.  LCDs are actually quite slow devices to communicate with, and as a result the LCD code has a large number of delays in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing else can happen while there's a delay() running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many other things will introduce their own delays.  Put them all together and you have a slow system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, you're not overloading it, you're slowing it down on purpose, and all those small slow-downs add up to one big grind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other ways of doing these things, of course, which are far more friendly to the chip - things that don't require delays of any form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a start there is the millis() function which tells you the time.  Using that to know when to do things, instead of sitting waiting for them to happen, allows you to do so much more at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like boiling an egg.  Do you put the egg in boiling water and sit there staring at it for 3 minutes (or however long you like your egg cooking), or do you set the timer on your oven to alert you in 3 minutes time so you can go and do the ironing while the egg is boiling?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the same with Arduino programming.  Note the time, then check that time against the current time to see if the required time has passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, with things like the LCD library, changing it to work that way would be quite a lot of effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also hardware timers.  These allow you to run small snippets of code at regular periods.  Great for managing things like servos or other motors where you only want to be changing the state or speed of them say 10 times per second. Instead of updating them all the time, just set a desired speed / position variable and let the timer interrupt update the actual motor at a lower rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two key phrases to take away here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Non-blocking.  That is basically writing routines that never wait for something to complete, but can check to see if it's time for something to happen.&lt;/li&gt;&#xA;&lt;li&gt;Asynchronous programming.  This is using things like timers to make things happen &quot;outside&quot; your main loop.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-01T17:33:04.137" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13051" PostTypeId="1" CreationDate="2015-07-01T19:51:40.213" Score="2" ViewCount="699" Body="&lt;p&gt;More specifically, can I use an Arduino Due to have an interface that can plug in/out of a USB port on a computer, connect it to an SD card or similar via a sd card logging shield, and have it present itself as a flash drive to the computer? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do I want this as opposed to a normal flash drive? I would like the Arduino to also have access to the contents of the sd card when the computer interface is not plugged in (or rather controllable via the Arduino which device has access to the card, the Arduino or the computer), without the need to remove/disconnect the cable&lt;/p&gt;&#xA;" OwnerUserId="10606" LastActivityDate="2015-07-01T19:51:40.213" Title="Can I use an Arduino Due as a flash drive?" Tags="|shields|arduino-due|usb|sd-card|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13052" PostTypeId="2" ParentId="13048" CreationDate="2015-07-01T20:43:34.753" Score="1" Body="&lt;p&gt;I tend to recommend the &lt;a href=&quot;http://oomlout.co.uk/collections/arduino/products/arduino-starter-kit-ardx&quot; rel=&quot;nofollow&quot;&gt;oomlout ARDX starter kit&lt;/a&gt; to students at the university I work at as it is relatively low cost, widely available, and doesn't have too much cheap filler components that you don't use... &lt;/p&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-07-01T20:43:34.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13053" PostTypeId="1" CreationDate="2015-07-01T21:12:06.343" Score="2" ViewCount="138" Body="&lt;p&gt;I'm building a digital gear shift knob, which would display current gear (1-5, R) and based on readings from OBD-II change color when gear shifting is required, to save on fuel consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need a way to detect the current gear - PID 0D (current gear) is not availiable in this car. I was thinking about doing it based on the horizontal tilt of the gear stick, since there are 6 positions plus a neutral gear:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    1   3   5&#xA;     \  |  /&#xA;      --0--&#xA;    /   |  \&#xA;   2    4   R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a sensor I could use? Or perhaps it'd be possible to build one, e.g. using 6 of these ball switches: &lt;a href=&quot;https://www.adafruit.com/products/173&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/173&lt;/a&gt;&#xA;There is however a space constraint since everything needs to fit inside a gear knob, therefore I'd prefer a nice single package.&lt;/p&gt;&#xA;" OwnerUserId="7986" LastActivityDate="2015-10-19T10:09:09.507" Title="Sensing horizontal tilt" Tags="|sensors|hardware|accelerometer|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13054" PostTypeId="2" ParentId="13041" CreationDate="2015-07-01T21:42:13.233" Score="2" Body="&lt;p&gt;The previous answer correctly suggested writing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pwm = xPos*(255.0f/1023.0f);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in place of the original form &lt;code&gt;pwm = xPos*(255/1023);&lt;/code&gt;.  But because 255/1023 - 1/4 = -1/1364 which is fairly small (ie it differs by 1 part in 1364), just saying&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pwm = xPos/4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will usually give the correct result or nearly so.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the following python program shows that this result is exact 514 times as xPos ranges from 0 to 1023, and is one too large 510 times, which for many processes being controlled by PWM signals is close enough.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/env python&#xA;c = [0]*8&#xA;for i in range(1024):&#xA;    vf = int(i*255.0/1023.0)&#xA;    vi = i/4&#xA;    d = vi-vf&#xA;    c[d+3] += 1&#xA;    #print '{:5} {:5} {:5} {:5}'.format(i, d, vi, vf)&#xA;print c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-07-01T21:42:13.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13055" PostTypeId="1" AcceptedAnswerId="13056" CreationDate="2015-07-01T22:23:50.500" Score="5" ViewCount="1254" Body="&lt;p&gt;I am trying to move from arduinos to AVR C. Would somebody know how to remove the arduino bootloader from the microcontroller? Is there a different process for the different atmega microcontrollers like the 32u4, 328, or 2560?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="10904" LastActivityDate="2015-07-01T22:43:06.350" Title="Remove Bootloader on Arduinos" Tags="|arduino-leonardo|avr|avrdude|atmega32u4|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13056" PostTypeId="2" ParentId="13055" CreationDate="2015-07-01T22:43:06.350" Score="2" Body="&lt;p&gt;You don't &quot;remove&quot; the bootloader, you just ignore it.  When you program your new code with the hardware programmer of your choice it will just overwrite the bootloader code with your software's startup code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-01T22:43:06.350" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13057" PostTypeId="2" ParentId="13048" CreationDate="2015-07-01T22:59:50.220" Score="2" Body="&lt;p&gt;You could do worse than a cheap &lt;a href=&quot;http://www.ebay.com/sch/i.html?_nkw=37-in-1+sensor+kit&quot; rel=&quot;nofollow&quot;&gt;37-in-1 Sensor Kit&lt;/a&gt; from eBay and any Arduino board of your choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also some &lt;a href=&quot;http://www.ebay.com/sch/i.html?_nkw=dupont+jumper+wire&quot; rel=&quot;nofollow&quot;&gt;Dupont Jumpers&lt;/a&gt; are essential.  Get a selection of M/M, M/F and F/F.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-01T22:59:50.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13058" PostTypeId="1" CreationDate="2015-07-02T04:24:06.757" Score="0" ViewCount="1233" Body="&lt;p&gt;I am making an attempt to put LED headlights in an RC car I am building. I want the headlights to turn on when I click circle on a PlayStation 4 Dual Shock controller.  I currently have it working except the LED is very dim and not near as bright as if I just power it from the 5v pin on the arduino board.  Since I want it to only turn on when circle is pressed I have it connected to digital pin 7.  Here is my code.  Any help would be much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Example sketch for the PS4 Bluetooth library - developed by Kristian Lauszus&#xA; For more information visit my blog: http://blog.tkjelectronics.dk/ or&#xA; send me an e-mail:  kristianl@tkjelectronics.com&#xA; */&#xA;&#xA;#include &amp;lt;PS4BT.h&amp;gt;&#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;&#xA;// Satisfy the IDE, which needs to see the include statment in the ino too.&#xA;#ifdef dobogusinclude&#xA;#include &amp;lt;spi4teensy3.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#endif&#xA;&#xA;USB Usb;&#xA;//USBHub Hub1(&amp;amp;Usb); // Some dongles have a hub inside&#xA;BTD Btd(&amp;amp;Usb); // You have to create the Bluetooth Dongle instance like so&#xA;Servo servo1;&#xA;Servo servo2;&#xA;&#xA;&#xA;/* You can create the instance of the PS4BT class in two ways */&#xA;// This will start an inquiry and then pair with the PS4 controller - you only have to do this once&#xA;// You will need to hold down the PS and Share button at the same time, the PS4 controller will then start to blink rapidly indicating that it is in paring mode&#xA;PS4BT PS4(&amp;amp;Btd, PAIR);&#xA;&#xA;// After that you can simply create the instance like so and then press the PS button on the device&#xA;//PS4BT PS4(&amp;amp;Btd);&#xA;&#xA;const int headlights = 7;&#xA;bool printAngle, printTouch;&#xA;uint8_t oldL2Value, oldR2Value;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;#if !defined(__MIPSEL__)&#xA;  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection&#xA;#endif&#xA;  if (Usb.Init() == -1)&#xA;  {&#xA;    Serial.print(F(&quot;\r\nOSC did not start&quot;));&#xA;    while (1); // Halt&#xA;  }&#xA;  Serial.print(F(&quot;\r\nPS4 Bluetooth Library Started&quot;));&#xA;&#xA;  pinMode (3, OUTPUT);&#xA;  pinMode (5, OUTPUT);&#xA;  servo1.attach (3);&#xA;  servo2.attach (5);&#xA;}&#xA;void loop()&#xA;{&#xA;  Usb.Task();&#xA;&#xA;  if (PS4.connected())&#xA;  {&#xA;    servo1.write(map(PS4.getAnalogHat(RightHatX), 0, 255, 50, 0));&#xA;    servo2.write(map(PS4.getAnalogButton(R2), 0, 255, 90, 0));&#xA;  }&#xA;  else&#xA;  {&#xA;    servo1.write (25);&#xA;    servo2.write (90);&#xA;  }&#xA;&#xA;&#xA;  if (PS4.getAnalogHat(LeftHatX) &amp;gt; 137 || PS4.getAnalogHat(LeftHatX) &amp;lt; 117 || PS4.getAnalogHat(LeftHatY) &amp;gt; 137 || PS4.getAnalogHat(LeftHatY) &amp;lt; 117 || PS4.getAnalogHat(RightHatX) &amp;gt; 137 || PS4.getAnalogHat(RightHatX) &amp;lt; 117 || PS4.getAnalogHat(RightHatY) &amp;gt; 137 || PS4.getAnalogHat(RightHatY) &amp;lt; 117)&#xA;  {&#xA;      Serial.print(F(&quot;\r\nLeftHatX: &quot;));&#xA;      Serial.print(PS4.getAnalogHat(LeftHatX));&#xA;      Serial.print(F(&quot;\tLeftHatY: &quot;));&#xA;      Serial.print(PS4.getAnalogHat(LeftHatY));&#xA;      Serial.print(F(&quot;\tRightHatX: &quot;));&#xA;      Serial.print(PS4.getAnalogHat(RightHatX));&#xA;      Serial.print(F(&quot;\tRightHatY: &quot;));&#xA;      Serial.print(PS4.getAnalogHat(RightHatY));&#xA;  }&#xA;&#xA;&#xA;&#xA;    if (PS4.getButtonClick(PS)) {&#xA;      Serial.print(F(&quot;\r\nPS&quot;));&#xA;      PS4.disconnect();&#xA;    }&#xA;&#xA;    else {&#xA;        if (PS4.getButtonClick(CIRCLE)) {&#xA;        Serial.print(F(&quot;\r\nCircle&quot;));&#xA;        digitalWrite(headlights, HIGH);&#xA;        }&#xA;&#xA;      if (PS4.getButtonClick(CROSS)) {&#xA;        Serial.print(F(&quot;\r\nCross&quot;));&#xA;        digitalWrite(headlights, LOW);&#xA;      }&#xA;&#xA;      if (PS4.getButtonClick(TRIANGLE)) {&#xA;        Serial.print(F(&quot;\r\nTraingle&quot;));&#xA;        PS4.setRumbleOn(RumbleLow);&#xA;      }&#xA;&#xA;      if (PS4.getButtonClick(SQUARE)) {&#xA;        Serial.print(F(&quot;\r\nSquare&quot;));&#xA;        PS4.setLedFlash(0, 0); // Turn off blinking&#xA;      }&#xA;&#xA;      if (PS4.getButtonClick(UP)) {&#xA;        Serial.print(F(&quot;\r\nUp&quot;));&#xA;        PS4.setLed(Red);&#xA;      } if (PS4.getButtonClick(RIGHT)) {&#xA;        Serial.print(F(&quot;\r\nRight&quot;));&#xA;        PS4.setLed(Blue);&#xA;      } if (PS4.getButtonClick(DOWN)) {&#xA;        Serial.print(F(&quot;\r\nDown&quot;));&#xA;        PS4.setLed(Yellow);&#xA;      } if (PS4.getButtonClick(LEFT)) {&#xA;        Serial.print(F(&quot;\r\nLeft&quot;));&#xA;        PS4.setLed(Green);&#xA;      }&#xA;&#xA;      if (PS4.getButtonClick(L1))&#xA;        Serial.print(F(&quot;\r\nL1&quot;));&#xA;      if (PS4.getButtonClick(L3))&#xA;        Serial.print(F(&quot;\r\nL3&quot;));&#xA;      if (PS4.getButtonClick(R1))&#xA;        Serial.print(F(&quot;\r\nR1&quot;));&#xA;      if (PS4.getButtonClick(R3))&#xA;        Serial.print(F(&quot;\r\nR3&quot;));&#xA;&#xA;      if (PS4.getButtonClick(SHARE))&#xA;        Serial.print(F(&quot;\r\nShare&quot;));&#xA;      if (PS4.getButtonClick(OPTIONS)) {&#xA;        Serial.print(F(&quot;\r\nOptions&quot;));&#xA;        printAngle = !printAngle;&#xA;      }&#xA;      if (PS4.getButtonClick(TOUCHPAD)) {&#xA;        Serial.print(F(&quot;\r\nTouchpad&quot;));&#xA;        printTouch = !printTouch;&#xA;      }&#xA;     }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10879" LastEditorUserId="10003" LastEditDate="2015-07-03T12:36:45.100" LastActivityDate="2015-07-03T12:36:45.100" Title="LED too dim when connected to digital output pin" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13059" PostTypeId="2" ParentId="13058" CreationDate="2015-07-02T04:35:53.567" Score="3" Body="&lt;p&gt;You forgot to set &lt;code&gt;headlights&lt;/code&gt; as an output, meaning that you're attempting to power the LED through the 20k-50kohm input pullup.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-02T04:35:53.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13060" PostTypeId="1" CreationDate="2015-07-02T05:54:38.793" Score="-1" ViewCount="45845" Body="&lt;p&gt;When I try to upload I get this error. I cannot upload the program into my Arduino Mega ADK board. I tried putting the drivers agiain too, but it does not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it the problem with the hardware or the system?&#xA;Please help me. Thank you :)&lt;/p&gt;&#xA;" OwnerUserId="10953" LastEditorUserId="4628" LastEditDate="2015-07-02T18:09:01.777" LastActivityDate="2016-02-28T01:13:53.717" Title="avrdude: stk500v2_getsync(): timeout communicating with programmer error" Tags="|uploading|" AnswerCount="2" CommentCount="1" ClosedDate="2016-02-28T01:25:11.443" ContentLicense="CC BY-SA 3.0" />
  <row Id="13061" PostTypeId="2" ParentId="61" CreationDate="2015-07-02T07:57:38.037" Score="18" Body="&lt;p&gt;Be aware that no simulator will reproduce real-life situations. There have been plenty of posts on the Arduino forum about problems with code or electronics, which turn out to be something subtle, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Timing issues&lt;/li&gt;&#xA;&lt;li&gt;Race conditions (related/dependent events not always happening in the same order)&lt;/li&gt;&#xA;&lt;li&gt;Voltage levels, eg. floating input pins&lt;/li&gt;&#xA;&lt;li&gt;Driving motors which drop the Arduino voltage enough that it resets&lt;/li&gt;&#xA;&lt;li&gt;Not having decoupling capacitors&lt;/li&gt;&#xA;&lt;li&gt;Input pins being in an &quot;undefined&quot; state (eg. 2.5V on a pin where 2 or less V is LOW and 3V or more is HIGH)&lt;/li&gt;&#xA;&lt;li&gt;Problems with interrupt handlers, such as variables not being declared volatile&lt;/li&gt;&#xA;&lt;li&gt;Voltage spikes due to not having flyback diodes on motors&lt;/li&gt;&#xA;&lt;li&gt;The processor resetting once more than 10 LEDs are turned on because the current draw exceeds the amount the hardware can supply&lt;/li&gt;&#xA;&lt;li&gt;Interrupt handlers taking 10 µS to process an interrupt when only 9 µS is available.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;By their nature simulators can't reproduce all of this. Even if they could, would you think to toggle the &quot;insert random noise from motors&quot; option?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for getting ready for the board to arrive, download the IDE and start programming. You can get libraries installed, code written and free of syntax errors, organize it neatly, and be generally ready for the big day when the hardware is in your hands.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Have fun and enjoy experimenting with your Arduino!&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10907" LastEditDate="2016-01-13T05:56:23.413" LastActivityDate="2016-01-13T05:56:23.413" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13062" PostTypeId="1" AcceptedAnswerId="13069" CreationDate="2015-07-02T09:35:04.670" Score="2" ViewCount="879" Body="&lt;p&gt;I would like to wake Attiny45 from sleep by Serial communication. RX is connected to pin 7 (D2). When I try to use PCINT0_vect routine, I get an error &quot;multiple definition of `__vector_2'&quot; so it looks like Software Serial already uses &quot;ISR (PCINT0_vect)&quot; and pin change interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, will incomming communication wake Attiny from sleep?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a possibility to change CLKPR when Attiny starts receiving? For example I set clock divider to 256 for the majority of time and when it starts receiving it changes back to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA; if (SWSerial.available()&amp;gt;0) {&#xA;   noInterrupts ();&#xA;   CLKPR = bit (CLKPCE);&#xA;   CLKPR = clock_div_1;&#xA;   interrupts ();&#xA; }&#xA;//other code here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't mind loosing some bytes, but I need to low Idle current as much as possible.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="10957" LastActivityDate="2015-07-02T19:43:16.403" Title="Attiny45 wake by Software Serial" Tags="|interrupt|attiny|softwareserial|sleep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13063" PostTypeId="2" ParentId="13060" CreationDate="2015-07-02T11:12:38.027" Score="1" Body="&lt;p&gt;I get this problem sometimes with some of my boards. I usually solve the problem following these steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set the compiler on debug/verbose mode to see what's happening&lt;/li&gt;&#xA;&lt;li&gt;Launch compilation/upload&lt;/li&gt;&#xA;&lt;li&gt;When the compile phase is done, and the upload process is about to start, press the reset button on the board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Usually that takes care of the problem.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-07-02T11:12:38.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13064" PostTypeId="1" AcceptedAnswerId="18117" CreationDate="2015-07-02T12:50:00.157" Score="0" ViewCount="9699" Body="&lt;p&gt;I don't know why but when a pin set to input mode receives a high signal, then a low signal, it stays high for a seemingly random amount of time.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(7, 6, 5, 4, 3, 2);&#xA;int thermPin = A5;&#xA;int relayPin = 9;&#xA;int upButton = 10;&#xA;int downButton = 11;&#xA;int rawVoltage;&#xA;float mv;&#xA;float desiredTemp = 20.5;&#xA;float currentTemp = 20;&#xA;long newSetTime = millis();&#xA;long oldSetTime = newSetTime;&#xA;long newUpPushTime = millis();&#xA;long newDownPushTime = millis();&#xA;long oldUpPushTime = millis();&#xA;long oldDownPushTime = millis();&#xA;int mainDelay = 600;&#xA;int flashDelay = 600;&#xA;boolean isSetting = true;&#xA;&#xA;void drawCurrentTemp(){&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(currentTemp);&#xA;}&#xA;&#xA;void drawDesiredTemp(){&#xA;  lcd.setCursor(12, 1);&#xA;  lcd.print(desiredTemp);&#xA;}&#xA;&#xA;void drawMainScreen(){&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;TEMP&quot;);&#xA;  lcd.setCursor(12, 0);&#xA;  lcd.print(&quot;SET&quot;);&#xA;  drawCurrentTemp();&#xA;  drawDesiredTemp();&#xA;}&#xA;String setString = &quot;SET&quot;;&#xA;void flashSet(){&#xA;  if(newSetTime - oldSetTime &amp;gt; flashDelay) {&#xA;    if(setString == &quot;SET&quot;){&#xA;      setString = &quot;   &quot;;&#xA;    }else{&#xA;      setString = &quot;SET&quot;;&#xA;    }&#xA;    lcd.setCursor(12, 0);&#xA;    lcd.print(setString);&#xA;    oldSetTime = millis();&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  lcd.begin(16, 2);&#xA;  lcd.clear();&#xA;  pinMode(relayPin, OUTPUT);&#xA;  pinMode(upButton, INPUT);&#xA;  pinMode(downButton, INPUT);&#xA;  drawMainScreen();&#xA;}&#xA;&#xA;void checkInput(){&#xA;  if(digitalRead(upButton) == HIGH){&#xA;    newUpPushTime = millis();&#xA;  } else {&#xA;    oldUpPushTime = millis();&#xA;  }&#xA;  if(digitalRead(downButton) == HIGH){&#xA;    newDownPushTime = millis();&#xA;  } else {&#xA;    oldDownPushTime = millis();&#xA;  }&#xA;  long upButtonTimePushed = newUpPushTime - oldUpPushTime;&#xA;  long downButtonTimePushed = newDownPushTime - oldDownPushTime;&#xA;  if(upButtonTimePushed &amp;gt; 1000 &amp;amp;&amp;amp; downButtonTimePushed &amp;gt; 1000) {&#xA;    oldDownPushTime = millis();&#xA;    oldUpPushTime = millis();&#xA;    if(!isSetting){&#xA;      isSetting = true;&#xA;    } else {&#xA;      isSetting = false;&#xA;      drawMainScreen();&#xA;    }&#xA;  }&#xA;  if(isSetting){&#xA;    if(digitalRead(upButton) == HIGH) {&#xA;      desiredTemp +=0.5;&#xA;    } else if(digitalRead(downButton) == HIGH) {&#xA;      desiredTemp -=0.5;&#xA;    }&#xA;    drawDesiredTemp();&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  newSetTime = millis();&#xA;  if(isSetting) {&#xA;    flashSet();&#xA;  }&#xA;  checkInput();&#xA;  Serial.println(digitalRead(upButton));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10936" LastEditorUserId="4628" LastEditDate="2015-11-26T14:47:32.323" LastActivityDate="2015-11-26T14:47:32.323" Title="Digital pin input stays high after receiving a high signal" Tags="|arduino-uno|input|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13065" PostTypeId="1" CreationDate="2015-07-02T13:26:10.067" Score="0" ViewCount="891" Body="&lt;p&gt;I have an Arduino sketch where I'm sending commands over serial, and as a result turning pins from low to high. What I'm looking to do is have those pins turn high for 5 seconds and then turn back to low. I was looking for a time or scheduling library for Arduino that allows multiple timers at once and lets you pass a parameter (at least I think that's what I need).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I would like to implement a &quot;doAfter&quot; method and pass the function it is calling a pin number.&lt;/p&gt;&#xA;" OwnerUserId="10960" LastEditorUserId="7508" LastEditDate="2015-07-02T18:09:37.733" LastActivityDate="2015-08-01T19:16:25.383" Title="How do I turn a number of pins to high and then off after 5 seconds based on a serial command" Tags="|serial|led|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13066" PostTypeId="2" ParentId="13065" CreationDate="2015-07-02T13:41:07.680" Score="1" Body="&lt;p&gt;Have you tried the &lt;code&gt;delay()&lt;/code&gt; function? Try putting this in the &lt;code&gt;loop()&lt;/code&gt; function for pin 3.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(3, HIGH);&#xA;delay(1000); // time in milliseconds as parameter&#xA;digitalWrite(3, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10961" LastActivityDate="2015-07-02T13:41:07.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13067" PostTypeId="2" ParentId="13065" CreationDate="2015-07-02T13:57:24.367" Score="0" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://playground.arduino.cc/Code/Timer&quot; rel=&quot;nofollow&quot;&gt;Timer library&lt;/a&gt; to achieve this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Timer.h&quot;&#xA;[...]&#xA;digitalWrite(3, HIGH);&#xA;int afterEvent = t.after(5000, doAfter);&#xA;[...]&#xA;void doAfter() {&#xA;  digitalWrite(3, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, you cannot pass a parameter to the timer, just a callback. I suggest that you implement either a bunch of &lt;code&gt;doAfter&lt;/code&gt; functions, from &lt;code&gt;doAfter3&lt;/code&gt; to doAfter9` for instance, and call the right one in the callback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably other timer libraries, but this one is simple and complete enough for your needs.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-07-02T13:57:24.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13068" PostTypeId="1" CreationDate="2015-07-02T13:58:39.690" Score="-1" ViewCount="171" Body="&lt;p&gt;I want to make some characters scroll left without affecting the first positions in each row of my LCD 16x2 screen. I have this code inside the loop so far:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;lcd .clear();&#xA;lcd.setCursor(17, 0);&#xA;for (int i = 15; i &amp;gt; 0; i--) {&#xA;  lcd.print(&quot;x&quot;);&#xA;  lcd.scrollDisplayLeft();&#xA;  if (digitalRead(switchPin) == HIGH) {&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.write(5);&#xA;  } else {&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.write(5);&#xA;  };&#xA;  lcd.setCursor(17, 0);&#xA;  delay(500);&#xA;}&#xA;lcd.noAutoscroll();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it should work, but the character &lt;em&gt;x&lt;/em&gt; just moves left by one position, whereas the character in the first position, either in the first or second row doesn't appear at all.&lt;/p&gt;&#xA;" OwnerUserId="10961" LastEditorUserId="3917" LastEditDate="2015-12-01T18:04:41.727" LastActivityDate="2022-12-04T09:02:00.293" Title="Scroll LCD display connected to an Arduino Uno" Tags="|arduino-uno|lcd|electronics|ui|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13069" PostTypeId="2" ParentId="13062" CreationDate="2015-07-02T14:23:01.960" Score="2" Body="&lt;h1&gt;Question #1: Can a change on pin 7 wake from sleep?&lt;/h1&gt;&#xA;&lt;p&gt;Yes. The lowest power mode for this chip is &lt;code&gt;Power-down&lt;/code&gt;, and you can wake from this state with a pin change interrupt. Assuming that the soft-serial code you are using already enables interrupts on the pin for its own purposes, then you should just be able to sleep and the part will wake on the next pin generated interrupt.&lt;/p&gt;&#xA;&lt;p&gt;Depending on what compiler/libraries you are using, something like this...&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;...&#xA;&#xA;set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;sleep_enable();&#xA;sleep_cpu();&#xA;//We will only reach this line after an interrupt has occured&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;...should work. Note that an interrupt when waking from sleep takes longer than when already running, so you'll need to check your soft serial library to see if it will possibly garble the first bit received- it will depend on how they do their timing.&lt;/p&gt;&#xA;&lt;p&gt;If you really want the lowest power possible, you could write your own soft serial code that drops the processor to idle in between serial bit transitions. Depending on how much time you will be spending actually receiving data this could drop overall power consumption dramatically.&lt;/p&gt;&#xA;&lt;p&gt;For low baud rates, I could imagine writing serial receive code that woke on an interrupt from the start bit, and used the timer running at a very low clock speed to wake up in the middle of each data bit and very quickly sample and shift the bit in before going idle again. Done right, this could dramatically drop the power used while receiving.&lt;/p&gt;&#xA;&lt;h1&gt;Question #2: Is there a possibility to change CLKPR when Attiny starts receiving?&lt;/h1&gt;&#xA;&lt;p&gt;Yes. You can change the prescaler any time, but note that...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The clock is not running at all during &lt;code&gt;power-down&lt;/code&gt; mode, so there is no reason to scale back before going to sleep - it will just mean that it takes you longer to wake up when a change happens.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sometimes scaling back the clock can actually use more power, especially when sleeping is envolved. A processor running 1/2 as fast uses more than 1/2 as much power, so it is often more power efficient to wake up at full speed, do what you have to do as fast as possible, and then get back to sleep.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The best option for you will depend on factors like how often will you be receiving data compared to waiting for data, and how much work you wan to put into getting optimal power usage. This chip can be &lt;em&gt;extremely&lt;/em&gt; power efficient, but it can take work to take advantage of it.&lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-02T19:43:16.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13070" PostTypeId="1" CreationDate="2015-07-02T14:41:35.353" Score="2" ViewCount="719" Body="&lt;p&gt;I need to detect when a paper comes out from a laser printer and count the number of printed papers. For that I hope to use a PIR sensor to detect the movement of the paper from the printer. Is it possible to detect the movement of a paper using a PIR sensor? Please be kind enough to help me.&lt;/p&gt;&#xA;" OwnerUserId="10964" LastEditorUserId="4628" LastEditDate="2015-07-03T12:36:18.007" LastActivityDate="2015-07-03T12:36:18.007" Title="Use a PIR Sensor to detect the movements of a paper" Tags="|sensors|" AnswerCount="2" CommentCount="0" ClosedDate="2015-07-12T23:32:43.250" ContentLicense="CC BY-SA 3.0" />
  <row Id="13071" PostTypeId="2" ParentId="13070" CreationDate="2015-07-02T15:23:48.800" Score="3" Body="&lt;p&gt;If the paper is hot when it comes out of the printer, possibly.  Could be unreliable though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better would be to place a photo-interrupter (or IR LED and IR Photodiode) in the path of the paper to detect a break in an infra-red beam.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-02T15:23:48.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13072" PostTypeId="1" CreationDate="2015-07-02T16:18:24.990" Score="8" ViewCount="13894" Body="&lt;p&gt;I am trying to get 8 stop buttons to cause an Arduino UNO to activate a single relay!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The stop buttons have been placed 30' to 250' away from the Arduino uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q: How far can you go with 5v and still get signal back?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q: Is there a way to boost the signal?  &lt;/p&gt;&#xA;" OwnerUserId="10966" LastEditorUserId="6959" LastEditDate="2015-07-03T07:43:59.257" LastActivityDate="2015-07-03T08:19:31.797" Title="What maximum length of wire can I use to connect a push button to an Arduino?" Tags="|voltage-level|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13075" PostTypeId="2" ParentId="13070" CreationDate="2015-07-02T17:29:49.220" Score="2" Body="&lt;p&gt;The solution from the OP with the photo-interruptor is probably the most standard one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it might be worth checking if you can get away with a light sensor: assuming that the paper is mostly of different colour than the background, the paper should change the current passing through the photodiode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use a proximity sensor, aimed at a location on the path of the paper, where there is typically nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These 2 solutions are trying to avoid having to place something on both sides of the paper. If that doesn't bother you, then I'd recommend the OP's solution.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-02T17:29:49.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13076" PostTypeId="2" ParentId="13068" CreationDate="2015-07-02T19:34:11.800" Score="0" Body="&lt;p&gt;I would do the following (beware - not tested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.clear();&#xA;lcd.setCursor(15, 0);&#xA;lcd.print(&quot;x&quot;);&#xA;for (int i = 0; i &amp;lt; 15; i++) {&#xA;    lcd.setCursor(0, digitalRead(switchPin) == LOW);&#xA;    lcd.print(&quot;5&quot;);&#xA;    delay(500);&#xA;    lcd.scrollDisplayLeft();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-07-02T21:28:53.377" LastActivityDate="2015-07-02T21:28:53.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13077" PostTypeId="2" ParentId="13072" CreationDate="2015-07-02T21:01:31.640" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Q: how far can you go with 5v and still get signal back?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That depends on two main factors:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The gauge of the wire&lt;/li&gt;&#xA;&lt;li&gt;The noise in the environment&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Assuming a low-noise (where noise is negligible) environment, we will first look at the wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All wire has an inherent resistance to it.  The thicker the wire, the lower the resistance.  This table has good information about the resistance of different gauges of wire: &lt;a href=&quot;http://www.powerstream.com/Wire_Size.htm&quot; rel=&quot;noreferrer&quot;&gt;http://www.powerstream.com/Wire_Size.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a typical arrangement where the internal pullup resistor of the Arduino's IO pin is used to create an &quot;active low&quot; arrangement (&lt;code&gt;pinMode(x, INPUT_PULLUP&lt;/code&gt;) the equivalent circuit can be seen as this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FfPf6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the &quot;Input Logic Low&quot; (VIL) level of an input pin (according to the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATMega328P Datasheet&lt;/a&gt; (Table 30-1) is 0.3Vcc, and Vcc is 5V, the input low level would therefore be 1.5V.  The voltage present at the IO pin has to be below 1.5V in order for the input to be seen as a LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit, when the button is pressed, can be simplified to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/9tIPx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is a simple voltage divider.  The formula for calculating Vout is (R2/(R1+R2))*Vin.  We know that the Vout limit is 1.5, and Vin is 5V.  Also that R1 is approximately 50KΩ (very approximately).  So we can rearrange the formula to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R2 = R1(1/((Vin/Vout)-1))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Substituting our known values we have: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;R2 = 50,000 × ( 1 / ((5 / 1.5) - 1)) = 21428.57Ω&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the total resistance of the wire permissible is around 20KΩ assuming the internal pullup resistor is 50KΩ (note: it could be as low as 10KΩ or as much as 70KΩ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Divide that value by 2, since the wire has to run twice the distance (once there and once back again) and you get a total resistance of around 10KΩ for one leg of the journey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now assume a wire gauge of 24AWG.  That has a resistance of 84.1976Ω/km.  So we can work out that 10,000 / 84.1976 = 118.77km.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with 24AWG wire you could theoretically have your button about 100km away from the Arduino and &lt;em&gt;just about&lt;/em&gt; have it still register properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course that's with no noise, and there &lt;em&gt;will&lt;/em&gt; be noise - especially over that kind of distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The noise will basically make the voltage seen at the input vary randomly around the theoretical value.  Those wires act like great big antennae, and they pick up all sorts of stray EMI.  The longer the wires the more noise there will be, and consequently the lower the voltage you will need to aim for (or higher voltage if using a pull-down arrangement - just turn the whole thing upside down) to keep the logic level below (or above) the right threshold value.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q: is their away to boost the signal? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can use a higher voltage.  There is nothing to say that you have to interface your button directly with the Arduino.  There are many ways of having your button switch a higher voltage on and off and use that to trigger the Arduino.  The simplest (and also the safest) may be to use an opto-coupler.  Use your button(s) to switch a 12V power supply on and off, and that then passes through a suitable resistor to power the LED in the opto-coupler.  That then switches on the built-in transistor to turn on the IO pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sib2l.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option may be to use a reliable communication bus with a small microcontroller at each stop-button point (maybe something like RS-485), though that may be overkill for this kind of application.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-02T21:01:31.640" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13078" PostTypeId="2" ParentId="4580" CreationDate="2015-07-02T21:08:44.033" Score="0" Body="&lt;pre&gt;&lt;code&gt;#include &quot;SoftwareSerial.h&quot; worked instead of &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&lt;/code&gt;&#xA;ie &quot; &quot; not &amp;lt;&gt;&lt;/p&gt;&#xA;" OwnerUserId="10970" LastActivityDate="2015-07-02T21:08:44.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13079" PostTypeId="1" CreationDate="2015-07-02T21:46:25.377" Score="0" ViewCount="2064" Body="&lt;p&gt;I am new to Arduino, and I am working through the &quot;Arduino Projects book,&quot; with the Arduino Uno. I am working on project 5, &quot;the mood cue.&quot; It is basically a potentiometer-controlled servo. I am certain that I have the code for it correct, and certain that I have all the wiring correct. I have the potentiometer value and the angle at which the potentiometer is turned printed on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I upload the code, and the serial monitor begins printing correctly, changing when I twist the potentiometer. But the servo doesn't move. It lets off a faint buzzing sound, and that is it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what the problem is? I don't know what I have done wrong. Do you think my servo is broken?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myServo;&#xA;int const potPin = A0;&#xA;int potVal;&#xA;int angle;&#xA;&#xA;void setup() {&#xA;  myServo. attach(9);&#xA;  Serial.begin (9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  potVal = analogRead(potPin);&#xA;  Serial.print (&quot;potVal:&quot;);&#xA;  Serial.print (potVal);&#xA;  angle = map(potVal, 0, 1023, 0, 179);&#xA;  Serial.print (&quot;angle:&quot;);&#xA;  Serial.print (angle);&#xA;  myServo.write (angle);&#xA;  delay(15);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my wiring:&#xA;file:///C:/Users/matth_000/Downloads/Arduino%20PotServ.jpg&lt;/p&gt;&#xA;" OwnerUserId="10972" LastEditorUserId="4628" LastEditDate="2018-01-01T07:27:54.547" LastActivityDate="2020-03-27T00:59:38.513" Title="Why is my &quot;mood cue&quot; not working?" Tags="|arduino-uno|servo|potentiometer|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13081" PostTypeId="2" ParentId="12276" CreationDate="2015-07-02T22:20:16.273" Score="0" Body="&lt;p&gt;The best place for answers is in the &lt;a href=&quot;http://www.visualmicro.com/forums&quot; rel=&quot;nofollow&quot;&gt;Visual Micro forum&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Be sure about is that the main .ino source file of your Arduino project matches both the name of the Visual Studio project and the name of the folder they existing in. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Folder = Sketch1&lt;/li&gt;&#xA;&lt;li&gt;Master Source = Sketch1.ino&lt;/li&gt;&#xA;&lt;li&gt;Visual Studio Project Name = Sketch1&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This ensure Visual Micro will compile the project and also it will be compatible with the Arduino Ide.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;With two projects in a Visual Studio solution it is important to note which is the &quot;Startup Project&quot;. You can control which is the startup by right clicking a project in the explorer and clicking &quot;Set as Startup project&quot;. The project name will then appear in &lt;strong&gt;bold&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The startup project affects which project is uploaded/started/debugged when you click any of the &quot;Start&quot; commands.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;The menu item &quot;Build&gt;Configuration Manager&quot; allows you to exclude your Arduino project from Visual Studio Win32 builds but changing this option should not normally be required.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can right click each project and click &quot;Start&gt;New instance&quot; to override the current &quot;Startup project&quot; and specifically build and upload a project.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the build/upload fails and you see the visual studio c++ compiler error that you have described above this means that Visual Micro is not handling the build process for the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, please confirm point &lt;em&gt;1&lt;/em&gt; is correct by trying out build task described in point &lt;em&gt;4&lt;/em&gt; above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be useful to know which build command you are selecting when the problem happens.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="6936" LastEditDate="2015-09-19T23:18:49.927" LastActivityDate="2015-09-19T23:18:49.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13082" PostTypeId="2" ParentId="13079" CreationDate="2015-07-02T22:46:14.940" Score="2" Body="&lt;p&gt;The classic way of wiring up motors, including servos, is to provide them with separate power. The image below should clarify this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VTyYl.jpg&quot; alt=&quot;Wiring for servo motor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The batteries (in this case) have the sole function of providing power to the servo motor. The &quot;data&quot; pin however goes to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino itself is powered by the USB cable in this example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;important&lt;/strong&gt; point is the blue wire - the shared ground wire. Both the Arduino and the servo (and batteries) must have a common ground.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-02T22:46:14.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13084" PostTypeId="1" CreationDate="2015-07-02T23:14:42.123" Score="0" ViewCount="2966" Body="&lt;p&gt;I am Creating a laptop controlled robot using an arduino nano using the &lt;a href=&quot;http://www.instructables.com/id/Laptop-Controlled-Robot-v20/#step0&quot; rel=&quot;nofollow&quot;&gt;instructbles&lt;/a&gt;. I have tried running the code but it is throwing back lots off error and the main one is &quot;expected primary expression before &quot;&amp;lt;&quot; token&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as well as various other error. if anyone could take a look and try help me out i would be grateful thank you!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;NewPing.h&amp;gt;&#xA;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(11, 8, 7, 4, 3, 2);&#xA;float temp =1;&#xA;int temppin = A0;&#xA;int r_motor_n = 9; //PWM control Right Motor +&#xA;int r_motor_p = 10; //PWM control Right Motor -&#xA;int l_motor_p = 6; //PWM control Left Motor -&#xA;int l_motor_n = 5; //PWM control Left Motor +&#xA;int f_light = A3;&#xA;int b_light = A4;&#xA;int horn = 12;&#xA;int n_light = 13;&#xA;int speedy = 255;&#xA;int incomingByte = 0; // for incoming serial data&#xA;#define TRIGGER A2 // Arduino pin tied to trigger pin on the ultrasonic sensor.&#xA;#define ECHO A1 // Arduino pin tied to echo pin on the ultrasonic sensor.&#xA;#define MAX 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.&#xA;NewPing sonar(TRIGGER, ECHO, MAX); // NewPing setup of pins and maximum distance.&#xA;void setup()&#xA;{&#xA;pinMode(r_motor_n, OUTPUT); //Set control pins to be outputs&#xA;pinMode(r_motor_p, OUTPUT);&#xA;pinMode(l_motor_p, OUTPUT);&#xA;pinMode(l_motor_n, OUTPUT);&#xA;pinMode(f_light, OUTPUT);&#xA;pinMode(b_light, OUTPUT);&#xA;pinMode(n_light, OUTPUT);&#xA;pinMode(horn, OUTPUT);&#xA;digitalWrite(r_motor_n, LOW); //set both motors off for start-up&#xA;digitalWrite(r_motor_p, LOW);&#xA;digitalWrite(l_motor_p, LOW);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;Start&quot;);&#xA;lcd.begin(16,2);&#xA;lcd.clear();&#xA;lcd.print(&quot;     Hello      &quot;);&#xA;lcd.setCursor(0,1);&#xA;lcd.print(&quot;   I'm Robot   &quot;);&#xA;delay(3000);&#xA;}&#xA;void loop()&#xA;{&amp;lt;/liquidcrystal.h&amp;gt;&amp;lt;/newping.h&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;if (Serial.available() &amp;gt; 0) &#xA;{&#xA;incomingByte = Serial.read();&#xA;}&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;switch(incomingByte)&#xA;{&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'S': // control to stop the robot&#xA;digitalWrite(r_motor_n, LOW); &#xA;digitalWrite(r_motor_p, LOW);&#xA;digitalWrite(l_motor_p, LOW);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;Stop&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Stop&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'R': //control for right&#xA;analogWrite(r_motor_n, speedy); &#xA;digitalWrite(r_motor_p, LOW);&#xA;analogWrite(l_motor_p, speedy);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;right&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Right&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'L': //control for left&#xA;digitalWrite(r_motor_n, LOW); &#xA;analogWrite(r_motor_p, speedy);&#xA;digitalWrite(l_motor_p, LOW);&#xA;analogWrite(l_motor_n, speedy);&#xA;Serial.println(&quot;left&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Left&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'F': //control for forward&#xA;analogWrite(r_motor_n, speedy); &#xA;digitalWrite(r_motor_p, LOW);&#xA;digitalWrite(l_motor_p, LOW);&#xA;analogWrite(l_motor_n, speedy);&#xA;Serial.println(&quot;forward&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Forward&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'B': //control for backward&#xA;digitalWrite(r_motor_n, LOW); &#xA;analogWrite(r_motor_p, speedy);&#xA;analogWrite(l_motor_p, speedy);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;backwards&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Backward&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'f': //control for stop&#xA;digitalWrite(r_motor_n, LOW);&#xA;digitalWrite(r_motor_p, LOW);&#xA;digitalWrite(l_motor_p, LOW);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;Stop&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Stop&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'd': // control for right&#xA;analogWrite(r_motor_n, speedy); &#xA;digitalWrite(r_motor_p, LOW);&#xA;analogWrite(l_motor_p, speedy);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;right&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Right&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'a': // control for left&#xA;digitalWrite(r_motor_n, LOW); &#xA;analogWrite(r_motor_p, speedy);&#xA;digitalWrite(l_motor_p, LOW);&#xA;analogWrite(l_motor_n, speedy);&#xA;Serial.println(&quot;left&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Left&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'w': // control for forward&#xA;analogWrite(r_motor_n, speedy); &#xA;digitalWrite(r_motor_p, LOW);&#xA;digitalWrite(l_motor_p, LOW);&#xA;analogWrite(l_motor_n, speedy);&#xA;Serial.println(&quot;forward&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Forward&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 's': // control for backward&#xA;digitalWrite(r_motor_n, LOW); &#xA;analogWrite(r_motor_p, speedy);&#xA;analogWrite(l_motor_p, speedy);&#xA;digitalWrite(l_motor_n, LOW);&#xA;Serial.println(&quot;backwards&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Backward&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'J': // front lights on&#xA;digitalWrite(f_light, HIGH);&#xA;Serial.println(&quot;front lights on&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'j':&#xA;digitalWrite(f_light, LOW); // off&#xA;Serial.println(&quot;front lights off&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'K':&#xA;digitalWrite(b_light, HIGH); // back lights on&#xA;Serial.println(&quot;back lights on&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'k':&#xA;digitalWrite(b_light, LOW); // off&#xA;Serial.println(&quot;back lights off&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'G':&#xA;digitalWrite(n_light, HIGH); // neon lights on&#xA;Serial.println(&quot;neon lights on&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'g':&#xA;digitalWrite(n_light, LOW); off&#xA;Serial.println(&quot;neon lights off&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'H':&#xA;digitalWrite(horn, HIGH); // horn on&#xA;Serial.println(&quot;horn on&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'h':&#xA;digitalWrite(horn, LOW); off&#xA;Serial.println(&quot;horn off&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'O': // PWM speed values&#xA;speedy = 0 ;&#xA;Serial.println(&quot;speed= 0&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=0&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '1':&#xA;speedy = 155;&#xA;Serial.println(&quot;speed= 10&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=10&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '2':&#xA;speedy = 165;&#xA;Serial.println(&quot;speed= 20&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=20&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '3':&#xA;speedy = 175;&#xA;Serial.println(&quot;speed= 30&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed =30&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '4':&#xA;speedy = 185;&#xA;Serial.println(&quot;speed= 40&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=40&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '5':&#xA;speedy = 195;&#xA;Serial.println(&quot;speed= 50&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=50&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '6':&#xA;speedy = 205;&#xA;Serial.println(&quot;speed= 60&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=60&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '7':&#xA;speedy = 215;&#xA;Serial.println(&quot;speed= 70&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=70&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '8':&#xA;speedy = 225;&#xA;Serial.println(&quot;speed= 80&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=80&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case '9':&#xA;speedy = 235;&#xA;Serial.println(&quot;speed= 90&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=90&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'q':&#xA;speedy = 255;&#xA;Serial.println(&quot;speed= 100&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Speed=100&quot;);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;case 'p': &#xA;delay(50);  // display temp. and distance&#xA;unsigned int uS = sonar.ping(); &#xA;Serial.print(&quot;Distance: &quot;);&#xA;Serial.print(uS / US_ROUNDTRIP_CM); &#xA;Serial.println(&quot;cm&quot;);&#xA;lcd.clear();&#xA;lcd.print(&quot;Distance: &quot;);&#xA;lcd.print(uS / US_ROUNDTRIP_CM); &#xA;lcd.print(&quot;cm&quot;);&#xA;lcd.setCursor(0,1);&#xA;temp = analogRead(temppin);&#xA;temp = temp * 0.48828125;&#xA;Serial.print(&quot;Temperature = &quot;);&#xA;Serial.print(temp);&#xA;Serial.print(&quot;*C&quot;);&#xA;Serial.println();&#xA;lcd.print(&quot;Temp. = &quot;);&#xA;lcd.print(temp);&#xA;lcd.print(&quot;*C&quot;);&#xA;delay(1000);&#xA;incomingByte='*';&#xA;break;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;delay(5000);&#xA;}&#xA;}&amp;lt;/p&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10974" LastActivityDate="2015-07-02T23:44:03.077" Title="Error in code saying &quot;expected primary expression before &quot;&lt;&quot; token&quot; and other errors" Tags="|programming|sensors|arduino-ide|arduino-nano|robotics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13085" PostTypeId="2" ParentId="179" CreationDate="2015-07-02T23:34:29.920" Score="6" Body="&lt;p&gt;Unless your objective is to simply copy the identical code to another device, the simple answer is: &lt;strong&gt;no&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As has been pointed out in other answers, you can turn the hex code on the device back into assembler code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example (once you have copied the code from the device back onto your disk):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -j .sec1 -d -m avr5 yourFileHere.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run on one of the bootloader files I get these results (in part):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00007e00 &amp;lt;.sec1&amp;gt;:&#xA;    7e00:       11 24           eor     r1, r1&#xA;    7e02:       84 b7           in      r24, 0x34       ; 52&#xA;    7e04:       14 be           out     0x34, r1        ; 52&#xA;    7e06:       81 ff           sbrs    r24, 1&#xA;    7e08:       f0 d0           rcall   .+480           ;  0x7fea&#xA;    7e0a:       85 e0           ldi     r24, 0x05       ; 5&#xA;    7e0c:       80 93 81 00     sts     0x0081, r24&#xA;    7e10:       82 e0           ldi     r24, 0x02       ; 2&#xA;    7e12:       80 93 c0 00     sts     0x00C0, r24&#xA;    7e16:       88 e1           ldi     r24, 0x18       ; 24&#xA;    7e18:       80 93 c1 00     sts     0x00C1, r24&#xA;    7e1c:       86 e0           ldi     r24, 0x06       ; 6&#xA;    7e1e:       80 93 c2 00     sts     0x00C2, r24&#xA;    7e22:       80 e1           ldi     r24, 0x10       ; 16&#xA;    7e24:       80 93 c4 00     sts     0x00C4, r24&#xA;    7e28:       8e e0           ldi     r24, 0x0E       ; 14&#xA;    7e2a:       c9 d0           rcall   .+402           ;  0x7fbe&#xA;    7e2c:       25 9a           sbi     0x04, 5 ; 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, not particularly helpful for reproducing what your sketch did. There are likely to be one of two scenarios:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your sketch was short, in which case you might, after weeks of work, turn the assembler code back into C&lt;/li&gt;&#xA;&lt;li&gt;Your sketch was long, in which case it would be virtually impossible to turn it back into C&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the &quot;short sketch&quot; case, you are better off just rewriting from scratch. That would be faster, almost certainly. In the &quot;long sketch&quot; case - it just isn't worth it. None of the variable names are preserved, and the way the compiler optimizes code, even the structure of the code would be hard to determine.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-02T23:34:29.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13086" PostTypeId="2" ParentId="13084" CreationDate="2015-07-02T23:44:03.077" Score="2" Body="&lt;p&gt;your code is ridden with html tags, like &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;/liquidcrystal.h&amp;gt;&amp;lt;/newping.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try removing them all, but it would be better if you could copy it from a plain ASCII source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when reporting a compiler bug, it's always good to paste it exactly as it is shown (it would have listed also line and possibly column where the error was detected)&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-02T23:44:03.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13088" PostTypeId="2" ParentId="13037" CreationDate="2015-07-03T03:29:20.070" Score="1" Body="&lt;p&gt;Welcome to the world of signal processing! (Starting off with a Kalman filter, though, is not very welcoming). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first few things to address are in regard to the barometer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Inevitably, it's going to be noisy, and barometers in particular are known to be noisy. Considering the unfiltered data you posted, I'd say it's reasonable. The spikes are completely normal, especially being that your calculating the derivative from the barometer data. If you want to try to smooth the barometer data &lt;em&gt;before&lt;/em&gt; passing it to the Kalman filter, you could apply a nth order low pass filter to the sampled data. This, of course, would add more lag to your calculations - it's really a trade off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) Looking at the unfiltered data and the velocity calculated from the Raven, it appears that there might be an issue. Starting at time 0, the unfiltered data and the Raven data is nearly identical. Once the rocket reaches 180ft/s, though, the filtered data appears to diverge. After it passes the global maxima and hits 180ft/s again, the two data outputs start to converge. This makes me suspect that your sampling rate may be too low. A hard-core, by the book, DSP engineer will probably start crying when he reads this, but consider this: at a velocity of 180ft/s with a sample rate of 20S/s, each sample corresponds to a change in position of 9ft. So, at best, you have a resolution of 9ft per second. This can pose at least two problems. (1) The barometer has to continuously update temperature and pressure readings in order to calculate an accurate altitude. I only glanced at the datasheet, but it seems like the temperature (and I think one other parameter) is updated at a slower rate than the pressure sampling - that is, there's an oversampling factor for the pressure measurement. Hence, your calculation may start to diverge from reality. And as the rocket's velocity increases, this problem may be exacerbated. Of course, temperature changes at rate of about 9.8C/1000m, so it may not be that significant of an issue. Just wanted to throw it out there.  (2) Again, at 180ft/s with a 20Hz sampling rate, you basically have a resolution of 9ft/S. This isn't necessarily bad, but one thing to keep in mind is that a Kalman filter is predictive; it predicts the state of the system 1/20 of a second into the future. If your underlying model is off, this could lead to slower convergence and larger corrections that would make the filtered data look &quot;jerky.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just one more thing before we get into the filter...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth considering how you're implementing this on the Arduino. There shouldn't be any issues with computation time that could result in significant lag. If your only sampling the altitude at 20Hz and then feeding it to the filter at the same speed, you should be good to go. The only issue I can foresee is if you're using the Arduino Libraries. If you are, you'll probably run into bottlenecks and missed deadlines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the primary issue you're having - in my opinion - is not related to computational speed or hardware issues. Instead, I suspect it's your implementation of the filter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that stood out to me were your values of R and Q. R is the measurement noise covariance, and Q is the process noise covariance. Covariance ranges between [-1, 1]. Your Q = 5. I quickly scanned the link you provided, so I might have missed a simplification they did. I've seen in some cases that the covariance is simplified to a proportional expectation value and left unnormalized, similar to what's seen in Gram matrices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, here's some insight that may be useful:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Kalman filter is &lt;em&gt;very&lt;/em&gt; much dependent on how you model your system. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To illustrate this, let's consider an example analogous to your rocket. (I came across this example at some point, but I don't recall the source):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you want to measure the water level in a bucket, but you have a sensor that gives you noisy data. And of course, to filter the data, you decide to use a 1-D Kalman filter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We assume that we have a pretty accurate model of our system, so we'll let Q = 0.001. We iterate through the filter, and we may get data that looks like this: &#xA;&lt;img src=&quot;https://i.stack.imgur.com/yOcHi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filter works fairly well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if our model happened to be off - that is, it doesn't reflect what's really happening? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the image above, the water level was constant. In reality, perhaps the tank was filling at a constant rate. What happens now if we use the same filter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gTe6Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearly, the filter is diverging. The lag, as you call it, isn't really lag or a delay in the sense that the computation is slow. (In some ways it is a delay, but only in the mathematical sense that the filter is slowly converging). The &quot;lag&quot; effect we're seeing is due to our model. In essence, the filter we designed thinks our model is so good (as indicated by our low Q) that it gives greater weight to our model of the system. As you probably guessed, one way we can fix this problem is by increasing Q. So, let Q = 0.1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/40nDO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can keep increasing Q, and when Q = 1, your filtered data should actually match your measurement data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This, though, really ins't the best way. Ideally, you need to start with a relatively accurate model. Q can be thought of as a measure of the error in your model, and you want to minimize error. At this point, you'll inevitable need to start work with matrices. This won't increase &quot;lag.&quot; In fact, it should help your filtered data converge quicker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one more thing to note. Kalman filters prefer linear data (speaking generally here). Look what happens when you feed in nonlinear data:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WMnJH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To accurately and effectively apply a Kalman filter to non-linear data without such pronounced &quot;lag&quot;,  you need to use what is known as an extended Kalman filter - which basically linearizes your data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before you go down that route, which would probably be overkill, I would suggest improving your model used in your Kalman filter to better reflect it's true state. This means ditching the simplified filter you found and going into the matrix math. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, I hope this helped. Feel free to ask any questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Another method just crossed my mind that may be a simpler approach than a Kalman filter. I'll add it tomorrow).&lt;/p&gt;&#xA;" OwnerUserId="10383" LastEditorUserId="10383" LastEditDate="2015-07-03T06:07:06.073" LastActivityDate="2015-07-03T06:07:06.073" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13089" PostTypeId="1" CreationDate="2015-07-03T04:45:25.300" Score="3" ViewCount="3797" Body="&lt;p&gt;I am trying to write some code to make it easy to add different buttons to a touch screen. I need each object to be a different object of class 'touchButton'. I'd like to be able to run a &lt;code&gt;touchButton.Draw&lt;/code&gt; function, which in turn will run LCD library commands. Is there a way I could do that? Here is my source code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TouchScreen.ino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;touchButton.h&quot;&#xA;#include &amp;lt;UTFT.h&amp;gt;&#xA;#include &amp;lt;UTouch.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;UTFT    myGLCD(ITDB32S, 38, 39, 40, 41);&#xA;UTouch  myTouch( 6, 5, 4, 3, 2);&#xA;extern uint8_t SmallFont[];&#xA;&#xA;void setup() {&#xA;  myGLCD.InitLCD();&#xA;  myGLCD.setFont(SmallFont);&#xA;  myGLCD.clrScr();&#xA;  myTouch.InitTouch();&#xA;  myTouch.setPrecision(PREC_MEDIUM);&#xA;  myGLCD.fillScr(51, 51, 51);&#xA;  //what I want to be able to do:&#xA;  //touchButton Button1 (10, 10, 20, 20, 'p');&#xA;  //Button1.Draw();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;touchButton.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef touchButton_h&#xA;#define touchButton_h&#xA;#include &quot;Arduino.h&quot;&#xA;class touchButton {&#xA;  public:&#xA;    touchButton(int x, int y, int xs, int ys, char use);&#xA;    void Draw();&#xA;    int x1;&#xA;    int y1;&#xA;    int xsize;&#xA;    int ysize;&#xA;    char use;&#xA;    boolean toggle = false;&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;touchButton.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &quot;Arduino.h&quot;&#xA;  #include &quot;touchButton.h&quot;&#xA;  touchButton::touchButton(int x, int y, int xs, int ys, char myuse) {&#xA;    x1 = x;&#xA;    y1 = y;&#xA;    xsize = xs;&#xA;    ysize = ys;&#xA;    use = myuse;&#xA;  }&#xA;&#xA;  void touchButton::Draw() {&#xA;    switch (use) {&#xA;      case 'p':&#xA;      //this is what I would like to have called from the main file.&#xA;      //myGLCD.drawRoundRect(x1, y1, x1+xsize, y1+ysize);&#xA;        break;&#xA;&#xA;       default:&#xA;        break;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10977" LastEditorUserId="4628" LastEditDate="2015-07-03T05:52:08.590" LastActivityDate="2016-01-30T01:29:52.537" Title="How can I reference an object from another file?" Tags="|programming|c++|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13090" PostTypeId="2" ParentId="10112" CreationDate="2015-07-03T04:50:11.283" Score="5" Body="&#xA;&#xA;&lt;p&gt;This (short) code below will achieve what I think you are asking for, on the Atmega328 (eg. the Uno, Duemilanove, etc.).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte dutyCycle = 80;&#xA;&#xA;void setup() &#xA; {&#xA;  pinMode (3, OUTPUT);    // Timer 2 &quot;B&quot; output: OC2B&#xA;  pinMode (11, OUTPUT);   // Timer 2 &quot;A&quot; output: OC2A&#xA;&#xA;  // Set OC2A on Compare Match when up-counting.&#xA;  // Clear OC2B on Compare Match when up-counting.&#xA;  TCCR2A = bit (WGM20) | bit (COM2B1) | bit (COM2A1) | bit (COM2A0);       &#xA;  TCCR2B = bit (CS21);         // phase correct PWM, prescaler of 8&#xA;  OCR2A = dutyCycle;           // duty cycle out of 255 &#xA;  OCR2B = 255 - dutyCycle;     // duty cycle out of 255&#xA;  }  // end of setup&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;How it works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The code uses Timer 2 (an 8-bit timer) to count up to 255 in phase-correct PWM mode. Outputs are to OC2A (the &quot;A&quot; output - pin D11) and OC2B (the &quot;B&quot; output - pin D3). The duty cycle is in variable dutyCycle which must be in the range 0 to 255. The timer counts up to 255 and sets OC2A on compare-equal to the dutyCycle number, and it also clears OC2B on compare-equal, when counting up. The second half of the phase-correct cycle does the reverse. Thus the two cycles are of opposite phase.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Frequency&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The frequency of the timer is 3.9 kHz. This is because the timer has a prescaler of 8, then it counts up to 255, then it takes two cycles per period (one up, one down):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;16000000 / 8 / 255 / 2 = 3921.56 Hz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As Edgar Bonet pointed out in the comments, phase-correct PWM counts are not zero-relative, unlike other counting modes. Thus you divide by 255 to work out the frequency, not 256.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could select other frequencies by choosing different prescalers.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Proof of operation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The oscilloscope screen here shows the two outputs, out of phase with each other by 50%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/khmVI.png&quot; alt=&quot;Timer output&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from the circled cursor measurement that the OC2B pin is off for exactly the requested duty cycle (80 µs).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; 1/ 16000000 * 80 * 8 * 2 = 8e-005 (0.00008)  --&amp;gt; 80 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-03T21:08:24.453" LastActivityDate="2015-07-03T21:08:24.453" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13091" PostTypeId="2" ParentId="8539" CreationDate="2015-07-03T05:04:07.177" Score="1" Body="&lt;p&gt;One problem is here:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // Read Serial input:&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    int inChar = Serial.read();&#xA;&#xA;    if (inChar != '\n') {&#xA;      inString += (char)inChar;&#xA;      Serial.read();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your Serial.available() call guarantees that you have &lt;strong&gt;one&lt;/strong&gt; byte of serial input, but you are attempting to read two of them if the first one is not a newline. This is not valid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;How to process incoming serial data without blocking&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-03T05:04:07.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13092" PostTypeId="2" ParentId="5116" CreationDate="2015-07-03T05:14:36.843" Score="1" Body="&lt;p&gt;CPOL is clock &lt;strong&gt;polarity&lt;/strong&gt;, and CPHA is clock &lt;strong&gt;phase&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SPI modes are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 0 (the default) - clock is normally low (CPOL = 0), and the data is sampled on the transition from low to high (leading edge) (CPHA = 0)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6jUNq.jpg&quot; alt=&quot;SPI Mode 0&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 1 - clock is normally low (CPOL = 0), and the data is sampled on the transition from high to low (trailing edge) (CPHA = 1)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RYDAt.jpg&quot; alt=&quot;SPI Mode 1&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 2 - clock is normally high (CPOL = 1), and the data is sampled on the transition from high to low (leading edge) (CPHA = 0)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/3bNek.jpg&quot; alt=&quot;SPI Mode 2&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 3 - clock is normally high (CPOL = 1), and the data is sampled on the transition from low to high (trailing edge) (CPHA = 1)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hnOoa.jpg&quot; alt=&quot;SPI Mode 3&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;According to your datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Data from the SDIN line is clocked into the 24-bit input shift register on the falling edge of SCLK. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Judging by the diagrams on the datasheet, Mode 1 is what you want. You want the trailing edge of high to low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information at &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPI - Serial Peripheral Interface - for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-03T05:57:29.793" LastActivityDate="2015-07-03T05:57:29.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13093" PostTypeId="2" ParentId="3353" CreationDate="2015-07-03T05:23:48.633" Score="3" Body="&lt;p&gt;The Wire library has an issue in the lines you posted, that if an interrupt is lost, it will stay in that loop forever. There are two things you could do to fix this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Stop the interrupt from being lost (ie. fix electrical problems)&lt;/li&gt;&#xA;&lt;li&gt;Use a library that has a time-out.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the electrical issues, I would make sure you have pull-up resistors from SDA and SCL to +5V - typically 4.7k (for each one), but that would depend a bit on whether the device already has them. Also make sure you have decoupling capacitors on the Vcc lines as appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the software side, there is an alternative library (master only) at &lt;a href=&quot;http://dsscircuits.com/articles/arduino-i2c-master-library&quot; rel=&quot;nofollow&quot;&gt;&#xA;Arduino I2C Master Library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't personally needed to use that library, as with pull-up resistors and short cable runs, I haven't had problems with the Wire library. However if things are marginal you may well find that it helps.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-03T05:23:48.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13094" PostTypeId="2" ParentId="13089" CreationDate="2015-07-03T06:32:24.553" Score="0" Body="&lt;p&gt;I'm not 100% certain I understand what you mean. It's clear that you understand object-oriented code and some of the murkier aspects of c++, judging from what you wrote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I apologize if you already know this (and I'm guessing you do) or if this is completely off base, but your code should already work. That is, you defined your class in your header, implemented it in the .cpp file, and then instantiated it in the .ino file. If you want to operate on it in another file, you could declare the variable as an &quot;extern&quot; data type, which is rather dangerous, or pass it as a reference to a function in another file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I don't believe this is what you mean. From reading your code, I feel that you're asking how you can execute function &quot;x&quot; from another object every time you create a button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is the case, it's definitely possible. myGLCD looks like it's an object (can't read it at the moment), which is good. What you can do is declare your touchLCD class as a derived class of whomever myGLCD belongs to -adding the appropriate header of course:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Parent Class Name.h&amp;gt;&#xA;&#xA;class touchLCD : public &amp;lt;Parent Class Name&amp;gt;.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the functions you want are public or protected, then you can access them without restriction. Here you have a few options. The easiest would probably be calling the function from within the constructor. If you don't have access to the desired function, you'll have to define your class as a friend class. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="10383" LastActivityDate="2015-07-03T06:32:24.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13095" PostTypeId="1" AcceptedAnswerId="13096" CreationDate="2015-07-03T07:18:30.900" Score="1" ViewCount="447" Body="&lt;p&gt;I am assisting some friends on an Arduino Uno project, and we've noticed that when using some earlier versions of the Arduino IDE (In this case 1.0.5), the sketch behaves as desired. However, when using 1.6.5, the program behaves differently. The sketch in question is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/CymaSpace/Programs---Sketches/tree/master/Tim%20Gorbunov/a3%20with%20monosetting/a3&quot; rel=&quot;nofollow&quot;&gt;https://github.com/CymaSpace/Programs---Sketches/tree/master/Tim%20Gorbunov/a3%20with%20monosetting/a3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have noticed that when enabling verbose compilation output, the size of the compiled binary is different between the two different IDE versions. There are also some warnings in the older IDE that are not present in the newer version. There is at least one other version before 1.6.5 that is behaving the same way as 1.0.5 (it's a later version but at the moment I don't know which, I will see if I can find out and post it here later).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why the two sketches might be behaving differently and how to go about troubleshooting the problem? This occurred on both a windows and mac computer. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="10980" LastEditorUserId="10980" LastEditDate="2015-07-03T18:35:03.237" LastActivityDate="2015-07-03T18:35:03.237" Title="Arduino sketch behaves differently depending on version of Arduino IDE" Tags="|arduino-uno|arduino-ide|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13096" PostTypeId="2" ParentId="13095" CreationDate="2015-07-03T08:00:46.080" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;There are also some warnings in the older IDE that are not present in&#xA;  the newer version.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is a &lt;strong&gt;huge&lt;/strong&gt; mistake to disregards those warnings, especially:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;warning: array subscript is above array bounds&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You declared an array &lt;code&gt;int useColor[2]&lt;/code&gt;. Its length is 2 and its indices&#xA;can be either 0 or 1. Yet you are using &lt;code&gt;useColor[2]&lt;/code&gt;, which is out of&#xA;bounds and likely to corrupt memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the language point of view, this is called &lt;em&gt;undefined behavior&lt;/em&gt;,&#xA;which means that &lt;em&gt;anything&lt;/em&gt; can happen. In particular, it could very&#xA;well happen that the program behaves as you expect... which seems to be&#xA;the case with IDE 1.0.5. Simply changing the compiler version, or event&#xA;the compiler settings, can change the behavior.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-07-03T08:00:46.080" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13097" PostTypeId="2" ParentId="13072" CreationDate="2015-07-03T08:19:31.797" Score="4" Body="&lt;p&gt;Majenko's answer is probably the safest option. There is, however,&#xA;something simpler that you can try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a strong pull-up (or pull-down). Something around 1&amp;nbsp;kΩ will&#xA;make it quite difficult for the noise to pull your signal low, at the&#xA;cost of increased current consumption.&lt;/li&gt;&#xA;&lt;li&gt;Connect each push button to the Arduino using a twisted pair of copper&#xA;wires. This will minimize the inductive pickup effect.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-07-03T08:19:31.797" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13098" PostTypeId="2" ParentId="13089" CreationDate="2015-07-03T08:37:30.610" Score="2" Body="&lt;p&gt;The best way is to provide the myGLCD object as a parameter to the constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;touchButton::touchButton(UTFT &amp;amp;glcddev, int x, int y, int xs, int ys, char myuse) {&#xA;  x1 = x;&#xA;  y1 = y;&#xA;  xsize = xs;&#xA;  ysize = ys;&#xA;  use = myuse;&#xA;  glcd = &amp;amp;glcddev;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in your header you provide a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private: &#xA;  UTFT *glcd;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your library code then uses the glcd pointer to the object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;glcd-&amp;gt;drawRoundedRectangle(...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of &lt;code&gt;-&amp;gt;&lt;/code&gt; since &lt;code&gt;glcd&lt;/code&gt; is a &lt;em&gt;pointer&lt;/em&gt; to the object (as created by the &lt;code&gt;&amp;amp;&lt;/code&gt; operator when it was assigned in the constructor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, as Miagma mentions, you need to ensure that anywhere that references any UTFT functions or objects has the UTFT.h header included or it won't know what you're talking about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also do the same with the UTouch class - pass that object as a parameter, then each widget can have its own routine to deal with the touch events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see all this kind of thing in action in the same context in the Widget class of my DisplayCore system for chipKIT boards:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/DisplayCore/blob/master/DisplayCore/DisplayCore.h#L464&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/DisplayCore/blob/master/DisplayCore/DisplayCore.h#L464&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/DisplayCore/blob/master/DisplayCore/DisplayCore.cpp#L1587&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/DisplayCore/blob/master/DisplayCore/DisplayCore.cpp#L1587&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-03T08:37:30.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13099" PostTypeId="1" AcceptedAnswerId="16461" CreationDate="2015-07-03T09:03:21.937" Score="-1" ViewCount="227" Body="&lt;p&gt;I am building a small-scale watering system to water my plants, controlled by Arduino. I have designed most of the project except for how to switch water between multiple pipes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little more background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to use a servo motor to control the amount of water that is sent to each plant (based on pot size and plant type). The motor needs to be able to switch input (a 1/2 inch pipe carrying water) to a set of outputs (similarly sized pipes all going to different plants). I am not able to find something off the shelf that does this. So, I am about to 3D print something. Is there something available that I can use instead?&lt;/p&gt;&#xA;" OwnerUserId="10982" LastEditorUserId="4628" LastEditDate="2015-12-01T21:32:50.087" LastActivityDate="2016-01-31T00:45:38.173" Title="Outlet switcher using servo motor" Tags="|servo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13100" PostTypeId="2" ParentId="13099" CreationDate="2015-07-03T11:10:46.703" Score="0" Body="&lt;p&gt;To me it would seem simpler to use a faucet for each line, each faucet controlled by a motor.&#xA;Then you can even water the plants in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better, why not using submersion pumps, like those used in water tanks? Here too, you can control them in parallel.&#xA;The amount of time you keep a motor running is proportional tothe amount of water delivered.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-03T11:10:46.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13101" PostTypeId="2" ParentId="13089" CreationDate="2015-07-03T12:26:23.047" Score="0" Body="&lt;p&gt;You are asking a question that can be considered as the classical:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;is a&quot; vs. &quot;has a&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want, you can find more details &lt;a href=&quot;http://www.researchgate.net/post/What_is_a_difference_in_Is-a_and_has-a_relationship_of_inheritance_of_c&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On this specific case, I sort of agree with Majenko, that proposes to pass the address of the LCD object to each button, but I would prefer a different implementation where the pointer is stored in a static field shared by all the instances of touchButton, because you are always referring to the same object. That will of course change if you have more than 1 LCD.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-03T12:26:23.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13105" PostTypeId="1" AcceptedAnswerId="13106" CreationDate="2015-07-03T14:50:50.280" Score="0" ViewCount="64" Body="&lt;p&gt;Using Visual Studio to program my Arduino. I want to add additional compiler switches and include paths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be done?&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-03T14:55:17.053" Title="How do I add additional compiler switches in Visual Studio" Tags="|visualstudio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13106" PostTypeId="2" ParentId="13105" CreationDate="2015-07-03T14:55:17.053" Score="0" Body="&lt;p&gt;Use the ExtraFlags in the project properties. The flags can be specified for the currently selected configuration or for all builds of the current project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The feature was released in the 15.06 version of the &lt;a href=&quot;http://www.visualmicro.com&quot; rel=&quot;nofollow&quot;&gt;Visual Micro&lt;/a&gt; Arduino plugin for Visual Studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://www.visualmicro.com/page/User-Guide.aspx?doc=Project-Properties-Reference.html&quot; rel=&quot;nofollow&quot;&gt;guide&lt;/a&gt; shows how to access the project properties&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-03T14:55:17.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13107" PostTypeId="1" AcceptedAnswerId="13273" CreationDate="2015-07-03T14:58:34.223" Score="1" ViewCount="152" Body="&lt;p&gt;Using Visual Studio for my Arduino project I am struggling to know the states of various pins during operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do use the Visual Micro debugger but I don't want to have to set a watch for every pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this be done easily?&lt;/p&gt;&#xA;" OwnerUserId="10987" LastActivityDate="2015-07-08T14:43:30.083" Title="Is it possible to see a graphical view of digital and analog pin values?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13109" PostTypeId="2" ParentId="12977" CreationDate="2015-07-03T16:22:34.633" Score="1" Body="&lt;p&gt;I went through the same problem finding the cores for the attiny 88 and found this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=320742.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=320742.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13011/programming-attiny88-attiny828-with-arduino&quot;&gt;programming attiny88 &amp;amp; attiny828 with arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have not yet found the core for the attiny88 at 12mhz (&lt;a href=&quot;http://co.mouser.com/ProductDetail/Atmel/ATTINY88-AU/?qs=sGAEpiMZZMvqv2n3s2xjscfa4zIkTHJI8r77%252bczQD%252bE%3d&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://co.mouser.com/ProductDetail/Atmel/ATTINY88-AU/?qs=sGAEpiMZZMvqv2n3s2xjscfa4zIkTHJI8r77%252bczQD%252bE%3d&lt;/a&gt;) &lt;/p&gt;&#xA;" OwnerUserId="10989" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-03T16:22:34.633" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13112" PostTypeId="2" ParentId="13107" CreationDate="2015-07-03T16:54:46.030" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;http://www.lvl1.org/2011/07/04/arduino-dashboard-app/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Dashboard&lt;/a&gt; project sounds promising but quite likely it loops through the I/O pins periodically and uploads the results to your PC. I'm guessing you want live monitoring (as opposed to snapshots) while your own program (not the Dashboard sketch) is running. In that case, you'd need to isolate the relevant parts of the Dashboard sketch and integrate them with your code, and unless your are looking for fairly low frequency signal changes, have a timer interrupt function that runs the Dashboard frequently, which will have an impact on your own code. If the signals are fairly low frequency you might get away with putting a call to Dashboard in your &lt;code&gt;loop()&lt;/code&gt; function instead of running it from a timer interrupt. If you're looking for program bugs that are changing your outputs, once per &lt;code&gt;loop()&lt;/code&gt; may be fairly useless. A timer-interrupt would be necessary, and might have to analyze the stack and output the names or addresses of functions that had run recently. At that point you'd be on your way to implementing a debuggerand may want to consider an in-circuit emulator or a bus analyzer to capture the event. Or get smarter about isolating the code responsible for the event until you have a manageable, printf-debuggable code segment.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-03T16:54:46.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13113" PostTypeId="1" CreationDate="2015-07-03T17:35:13.137" Score="1" ViewCount="1134" Body="&lt;p&gt;I am trying to use the official arduino wifi shield, It works occasionally, but most of the time (when running the WiFi web server example code, or my derivitave program, it outputs &lt;code&gt;WiFi shield not present&lt;/code&gt; on the terminal. I have tried updating the firmware several times, but it has not fixed the problem. Is the wifi shield always this unreliable? What can I do to fix it?&lt;/p&gt;&#xA;" OwnerUserId="10991" LastActivityDate="2015-09-07T21:30:15.570" Title="Arduino WiFi shield working intermittently, &quot;WiFi Shield not present&quot;" Tags="|arduino-uno|shields|wifi|" AnswerCount="1" CommentCount="21" ContentLicense="CC BY-SA 3.0" />
  <row Id="13114" PostTypeId="1" AcceptedAnswerId="14316" CreationDate="2015-07-03T18:16:50.363" Score="1" ViewCount="11527" Body="&lt;p&gt;I just received a RC522 board and since i am new to RFID, I tried out some examples from &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Arduino RFID Library for MFRC522&quot;&gt;&quot;Arduino RFID Library for MFRC522&quot;&lt;/a&gt;. Here's one of them &#xA;&lt;strong&gt;rfid_default_keys&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * ----------------------------------------------------------------------------&#xA; * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid&#xA; * for further details and other examples.&#xA; * &#xA; * NOTE: The library file MFRC522.h has a lot of useful info. Please read it.&#xA; * &#xA; * Released into the public domain.&#xA; * ----------------------------------------------------------------------------&#xA; * Example sketch/program which will try the most used default keys listed in &#xA; * https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys to dump the&#xA; * block 0 of a MIFARE RFID card using a RFID-RC522 reader.&#xA; * &#xA; * Typical pin layout used:&#xA; * -----------------------------------------------------------------------------------------&#xA; *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino&#xA; *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro&#xA; * Signal      Pin          Pin           Pin       Pin        Pin              Pin&#xA; * -----------------------------------------------------------------------------------------&#xA; * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST&#xA; * SPI SS      SDA(SS)      10            53        D10        10               10&#xA; * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16&#xA; * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14&#xA; * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15&#xA; *&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;#define RST_PIN         9           // Configurable, see typical pin layout above&#xA;#define SS_PIN          10          // Configurable, see typical pin layout above&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.&#xA;&#xA;// Number of known default keys (hard-coded)&#xA;// NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array&#xA;#define NR_KNOWN_KEYS   8&#xA;// Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys&#xA;byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] =  {&#xA;    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default&#xA;    {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5}, // A0 A1 A2 A3 A4 A5&#xA;    {0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5}, // B0 B1 B2 B3 B4 B5&#xA;    {0x4d, 0x3a, 0x99, 0xc3, 0x51, 0xdd}, // 4D 3A 99 C3 51 DD&#xA;    {0x1a, 0x98, 0x2c, 0x7e, 0x45, 0x9a}, // 1A 98 2C 7E 45 9A&#xA;    {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7}, // D3 F7 D3 F7 D3 F7&#xA;    {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, // AA BB CC DD EE FF&#xA;    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  // 00 00 00 00 00 00&#xA;};&#xA;&#xA;/*&#xA; * Initialize.&#xA; */&#xA;void setup() {&#xA;    Serial.begin(9600);         // Initialize serial communications with the PC&#xA;    while (!Serial);            // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;    SPI.begin();                // Init SPI bus&#xA;    mfrc522.PCD_Init();         // Init MFRC522 card&#xA;    Serial.println(F(&quot;Try the most used default keys to print block 0 of a MIFARE PICC.&quot;));&#xA;}&#xA;&#xA;/*&#xA; * Helper routine to dump a byte array as hex values to Serial.&#xA; */&#xA;void dump_byte_array(byte *buffer, byte bufferSize) {&#xA;    for (byte i = 0; i &amp;lt; bufferSize; i++) {&#xA;        Serial.print(buffer[i] &amp;lt; 0x10 ? &quot; 0&quot; : &quot; &quot;);&#xA;        Serial.print(buffer[i], HEX);&#xA;    }&#xA;}&#xA;&#xA;/*&#xA; * Try using the PICC (the tag/card) with the given key to access block 0.&#xA; * On success, it will show the key details, and dump the block data on Serial.&#xA; *&#xA; * @return true when the given key worked, false otherwise.&#xA; */&#xA;boolean try_key(MFRC522::MIFARE_Key *key)&#xA;{&#xA;    boolean result = false;&#xA;    byte buffer[18];&#xA;    byte block = 0;&#xA;    byte status;&#xA;&#xA;    // Serial.println(F(&quot;Authenticating using key A...&quot;));&#xA;    status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, key, &amp;amp;(mfrc522.uid));&#xA;    if (status != MFRC522::STATUS_OK) {&#xA;        // Serial.print(F(&quot;PCD_Authenticate() failed: &quot;));&#xA;        // Serial.println(mfrc522.GetStatusCodeName(status));&#xA;        return false;&#xA;    }&#xA;&#xA;    // Read block&#xA;    byte byteCount = sizeof(buffer);&#xA;    status = mfrc522.MIFARE_Read(block, buffer, &amp;amp;byteCount);&#xA;    if (status != MFRC522::STATUS_OK) {&#xA;        // Serial.print(F(&quot;MIFARE_Read() failed: &quot;));&#xA;        // Serial.println(mfrc522.GetStatusCodeName(status));&#xA;    }&#xA;    else {&#xA;        // Successful read&#xA;        result = true;&#xA;        Serial.print(F(&quot;Success with key:&quot;));&#xA;        dump_byte_array((*key).keyByte, MFRC522::MF_KEY_SIZE);&#xA;        Serial.println();&#xA;        // Dump block data&#xA;        Serial.print(F(&quot;Block &quot;)); Serial.print(block); Serial.print(F(&quot;:&quot;));&#xA;        dump_byte_array(buffer, 16);&#xA;        Serial.println();&#xA;    }&#xA;    Serial.println();&#xA;&#xA;    mfrc522.PICC_HaltA();       // Halt PICC&#xA;    mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD&#xA;    return result;&#xA;}&#xA;&#xA;/*&#xA; * Main loop.&#xA; */&#xA;void loop() {&#xA;    // Look for new cards&#xA;    if ( ! mfrc522.PICC_IsNewCardPresent())&#xA;        return;&#xA;&#xA;    // Select one of the cards&#xA;    if ( ! mfrc522.PICC_ReadCardSerial())&#xA;        return;&#xA;&#xA;    // Show some details of the PICC (that is: the tag/card)&#xA;    Serial.print(F(&quot;Card UID:&quot;));&#xA;    dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);&#xA;    Serial.println();&#xA;    Serial.print(F(&quot;PICC type: &quot;));&#xA;    byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);&#xA;    Serial.println(mfrc522.PICC_GetTypeName(piccType));&#xA;&#xA;    // Try the known default keys&#xA;    MFRC522::MIFARE_Key key;&#xA;    for (byte k = 0; k &amp;lt; NR_KNOWN_KEYS; k++) {&#xA;        // Copy the known key into the MIFARE_Key structure&#xA;        for (byte i = 0; i &amp;lt; MFRC522::MF_KEY_SIZE; i++) {&#xA;            key.keyByte[i] = knownKeys[k][i];&#xA;        }&#xA;        // Try the key&#xA;        if (try_key(&amp;amp;key)) {&#xA;            // Found and reported on the key and block,&#xA;            // no need to try other keys for this PICC&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So i modified the code to see exactly what is happening there and here is my output:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/LuWoT.png&quot; alt=&quot;my output&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything looks fine, right ?&#xA;So i tried to modify it again by adding some more stuff to the &lt;em&gt;knownKeys&lt;/em&gt; array&#xA;but it looks like that only the first key is used in the actual authentication.&#xA;Here's an output for the same card but i moved &lt;code&gt;{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},  // FF FF FF FF FF FF = factory default&lt;/code&gt; to the end of that array.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/FocJM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So.. as you can see even if it used the right key, nothing happened.&#xA;For the solution i tried few things but without a success. Thanks in advance for answering.&lt;/p&gt;&#xA;" OwnerUserId="10992" LastEditorUserId="10992" LastEditDate="2015-07-03T21:35:39.937" LastActivityDate="2019-10-09T21:15:31.290" Title="rfid_default_keys check with RC522" Tags="|arduino-uno|programming|rfid|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13115" PostTypeId="2" ParentId="12809" CreationDate="2015-07-03T19:08:48.767" Score="1" Body="&lt;p&gt;See my blog which will explain all steps at &lt;a href=&quot;http://tutorial4you.weebly.com/blog/arduino-simulation-on-proteus&quot; rel=&quot;nofollow&quot;&gt;http://tutorial4you.weebly.com/blog/arduino-simulation-on-proteus&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7165" LastActivityDate="2015-07-03T19:08:48.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13116" PostTypeId="1" CreationDate="2015-07-03T19:17:32.103" Score="2" ViewCount="1784" Body="&lt;p&gt;I bought ESC from &lt;a href=&quot;http://www.rcbazaar.com/product.aspx?productid=2443&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; but it rotates motor in one direction only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any program which will control direction of rotation clockwise or anticlockwise with same wire configuration. &lt;/p&gt;&#xA;" OwnerUserId="7165" LastEditorUserId="6959" LastEditDate="2015-07-03T21:15:54.070" LastActivityDate="2015-07-03T21:15:54.070" Title="How to reverse BLDC motor using programming arduino?" Tags="|arduino-uno|motor|pwm|servo|robotics|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13117" PostTypeId="2" ParentId="12674" CreationDate="2015-07-03T21:34:43.593" Score="0" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;LiquidCrystal_I2C    lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;Are you not using pin 2 in the LiquidCrystal_I2C constructor? So you can't also use it for the DHT sensor.&lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I withdraw that suggestion.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Can you please try saving some RAM?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the F macro with your prints, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Serial.print(F(&quot;Humidity: &quot;)); &#xA;  Serial.print(DHT_hum);&#xA;  Serial.print(F(&quot; %\t&quot;));&#xA;  Serial.print(F(&quot;Temperature: &quot;)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ditto with the &lt;code&gt;lcd.print()&lt;/code&gt; calls.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-07T23:59:36.080" LastActivityDate="2015-07-07T23:59:36.080" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13121" PostTypeId="1" AcceptedAnswerId="13132" CreationDate="2015-07-03T22:00:37.853" Score="0" ViewCount="229" Body="&lt;p&gt;I am looking as a first project after some simple project kits, to make a watering system for my indoor plants. I have seen  a few projects on instructables, so I went to look for components. I am not sure how to power the pump from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bucket of water with a water pump inside. An irrigation system linked to the pump, which then goes to all the plants. The pump linked to arduino which turns it on and off based on a timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The components that I will be using are an Arduino uno and:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/351304928817&quot; rel=&quot;nofollow&quot;&gt;DV12 subversive pump&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/271401027990&quot; rel=&quot;nofollow&quot;&gt;Irrigation watering kit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also I guess I will need some tube to connect the pump to the watering kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to connect and power the pump (12V) with the arduino. The arduino it self will be powered by a USB on a wall socket.&lt;/p&gt;&#xA;" OwnerUserId="7301" LastActivityDate="2015-07-04T03:09:41.070" Title="DIY Watering - Required components" Tags="|arduino-uno|motor|voltage-level|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13122" PostTypeId="1" CreationDate="2015-07-03T22:23:10.277" Score="2" ViewCount="957" Body="&lt;p&gt;so here is the issue. I have a mega 1280, a handful of neopixels and a HC-SR04. I am using the New Ping library (tried both 1.5 and 1.6). I am trying to make a device that will tell my mom when she has pulled into the garage enough so she don't get hit by the garage door AND doesn't run into the wall. I wrote a bunch of code to handle the lights and what colors to do when and this part works perfectly. My issue is with the sensor. It works great except for 2 specific conditions.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;if you are too close. I normally either cover one of the 2 sonic sensor part or just barley touch then with a piece of cardboard (or anything for that matter&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you go outside the scope of the max distance&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;when either of this are met, the ping sensor stops clicking and it just returns all 0's for the output. I am including the code less the part for the lights because even if i remove that part of the code, it still fails on those 2 conditions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;NewPing.h&amp;gt;&#xA;#define TRIGGER_PIN  52&#xA;#define ECHO_PIN     53&#xA;#define MAX_DISTANCE 120&#xA;#define PIN 6&#xA;#define LEDNUM 8&#xA;&#xA;int codeFact = (MAX_DISTANCE / (LEDNUM * 3));&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(LEDNUM, PIN, NEO_RGB +     NEO_KHZ800);&#xA;NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;    strip.show(); &#xA;    for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) &#xA;    {&#xA;      strip.setPixelColor(i, strip.Color(0, 255, 0));&#xA;      strip.show();&#xA;      delay(50);&#xA;    }&#xA;    for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) &#xA;    {&#xA;      strip.setPixelColor(i, strip.Color(255, 255, 0));&#xA;      strip.show();&#xA;      delay(50);&#xA;    }&#xA;    for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) &#xA;    {&#xA;      strip.setPixelColor(i, strip.Color(255, 0, 0));&#xA;      strip.show();&#xA;      delay(50);&#xA;    }&#xA;    for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) &#xA;    {&#xA;      strip.setPixelColor(i, strip.Color(0, 0, 0));&#xA;      strip.show();&#xA;      delay(50);&#xA;    }&#xA;&#xA;Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA; delay(2000);&#xA;  int uS = sonar.ping();&#xA;  int dis = uS / US_ROUNDTRIP_CM;&#xA;  Serial.println(dis);&#xA;  /*&#xA;  Light code normally goes here&#xA;  */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10993" LastActivityDate="2015-07-10T03:32:52.100" Title="HC-SR04 quits pinging when distance &lt; 0 || distance &lt; MAXDISTANCE" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13124" PostTypeId="1" CreationDate="2015-07-03T22:41:24.090" Score="1" ViewCount="741" Body="&lt;p&gt;I have this HLK-RM04:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EvYip.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It came with  no catalogue or manual&#xA;all threads about it are in Chinese &#xA;after when I found the configuration webpage and changing it to client &#xA;it wont connect and it stopped board casting hlink wifi&#xA;how could i reset to factory settings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After very long search I found an English manual. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fwed8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does Trst means ?&#xA;I don’t understand what I must do to reset it!&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="37523" LastEditDate="2020-02-16T23:50:13.110" LastActivityDate="2020-11-13T00:04:25.597" Title="HLK-RM04 wifi shield factory reset?" Tags="|arduino-uno|shields|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13125" PostTypeId="2" ParentId="11800" CreationDate="2015-07-03T22:46:43.723" Score="1" Body="&lt;p&gt;You can simply disable the bootloader rather than erasing it. Find out the current fuse settings using a fuse-detection program. Change the BOOTRST flag in the High fuse to be unchecked, referring to this page: &lt;a href=&quot;http://www.engbedded.com/fusecalc&quot; rel=&quot;nofollow&quot;&gt;Engbedded Atmel AVR® Fuse Calculator&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write the High fuse back. Then it will ignore the bootloader and go straight to your code. Of course, to upload a new version you will have to put the BOOTRST fuse back, or you won't be able to use the bootloader to upload a new sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way of changing the fuse is to use my &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow&quot;&gt;Atmega chip stand-alone programmer sketch&lt;/a&gt;. This has an interactive &quot;change fuses&quot; option. To run this you just need a spare board (eg. a Uno) and 6 wires to connect the programming board to your target Mega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example wiring shown on the linked page. Note that you do &lt;strong&gt;not&lt;/strong&gt; need the SD board to merely change fuses. Just the two Arduinos and the connecting wires are enough for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you first run the sketch it should inform you of the current fuses. Look at the High fuse and follow my instructions above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Entered programming mode OK.&#xA;Signature = 1E 98 01 &#xA;Processor = ATmega2560&#xA;Flash memory size = 262144&#xA;LFuse = FF &#xA;HFuse = D8 &#xA;EFuse = FD &#xA;Lock byte = FF &#xA;Bootloader in use: Yes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case the High fuse was D8, which has the bootloader enabled. Using the Fuse Calculator site we can see that it should now be D9 which disables the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;An alternative way to change the fuse is to use Avrdude, if you have a stand-alone ISP programmer handy.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-03T22:46:43.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13126" PostTypeId="1" AcceptedAnswerId="13128" CreationDate="2015-07-04T01:03:43.833" Score="3" ViewCount="15343" Body="&lt;p&gt;At work, I have connected an Arduino to a security key (which has a 12v power supply) in order to give us a more versatile door lock.  Unfortunately, people keep removing the key pad, disconnecting the wires and re-connecting them (defective keypad I guess.)  In the process, I am afraid that they will accidentally send 12v into the Vcc, ground, digital in, and/or analog in pins.  What is the best way to protect my Arduino from the 12 volts?  I really need a component or two that I can to my pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: it is difficult for me to describe this problem without mentioning the danger to all components.  Please describe ways to protect digital outputs &lt;a href=&quot;https://arduino.stackexchange.com/questions/13150/best-way-to-protect-a-digital-output&quot;&gt;HERE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2017-12-23T21:40:43.440" Title="best way to protect a digital or analog input from 12volts" Tags="|voltage-level|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13128" PostTypeId="2" ParentId="13126" CreationDate="2015-07-04T01:37:22.180" Score="5" Body="&lt;p&gt;There are some suggestions at &lt;a href=&quot;http://www.digikey.com/en/articles/techzone/2012/apr/protecting-inputs-in-digital-electronics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Protecting Inputs in Digital Electronics &lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Amended answer&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing of my earlier answer involving clamping diodes gave unsatisfactory results. Due to the small current flow the diodes allowed a considerable voltage to reach the input pin (like, 9 V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The amended circuit below, tested with 12V input, satisfactorily keeps the Arduino input pin to 4.9 V, even with 12 V from the device. The current through R1 is around 7 mA which is what you would expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I = V / R&#xA;I = 7 / 1000&#xA;I = 7 mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 1N4733A is a 5.1 V, 1 W zener diode which can therefore handle dropping 5 V at 7 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you are wondering where the number 7 comes from in the calculations above:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The input voltage is 12 volts&lt;/li&gt;&#xA;&lt;li&gt;The desired output is 5 volts&lt;/li&gt;&#xA;&lt;li&gt;Therefore we need to drop (12 - 5) volts over the resistor&lt;/li&gt;&#xA;&lt;li&gt;Thus 7 volts are dropped over the resistor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SkcmD.png&quot; alt=&quot;Input pin protection&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reference material:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;10 Ways to Destroy An Arduino&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/Protection.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Protection&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.kevinmfodor.com/home/My-Blog/microcontrollerinputprotectiontechniques&quot; rel=&quot;nofollow noreferrer&quot;&gt;Microcontroller Input Protection Techniques&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2017-12-23T21:40:43.440" LastActivityDate="2017-12-23T21:40:43.440" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13129" PostTypeId="1" CreationDate="2015-07-04T02:03:17.213" Score="2" ViewCount="548" Body="&lt;p&gt;i want to implement a discrete transfer function at z domain with arduino UNO.I  know that i must do the inverse z transform and find the difference equation.Afterwards i must use PWM because arduino UNO has not DAC.&#xA;Is there anyone who knows about this ?and can help me.... i want a code as an example  .Thank you.&lt;/p&gt;&#xA;" OwnerUserId="10994" LastActivityDate="2015-07-04T02:03:17.213" Title="Implement a discrete controller /transfer function with arduino uno" Tags="|pwm|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13130" PostTypeId="2" ParentId="5125" CreationDate="2015-07-04T02:10:58.620" Score="0" Body="&lt;p&gt;In addition to the other problems, you should have a break between &lt;strong&gt;letters&lt;/strong&gt;. So, for example, &quot;S&quot; is not just dot-dot-dot it is dot-dot-dot-pause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code below that implements pauses between letters, as well as longer pauses between words.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte LED = 13;&#xA;&#xA;char * letters [26] = {&#xA;   &quot;.-&quot;,     // A&#xA;   &quot;-...&quot;,   // B&#xA;   &quot;-.-.&quot;,   // C&#xA;   &quot;-..&quot;,    // D&#xA;   &quot;.&quot;,      // E&#xA;   &quot;..-.&quot;,   // F&#xA;   &quot;--.&quot;,    // G&#xA;   &quot;....&quot;,   // H&#xA;   &quot;..&quot;,     // I&#xA;   &quot;.---&quot;,   // J&#xA;   &quot;-.-&quot;,    // K&#xA;   &quot;.-..&quot;,   // L&#xA;   &quot;--&quot;,     // M&#xA;   &quot;-.&quot;,     // N&#xA;   &quot;---&quot;,    // O&#xA;   &quot;.--.&quot;,   // P&#xA;   &quot;--.-&quot;,   // Q&#xA;   &quot;.-.&quot;,    // R&#xA;   &quot;...&quot;,    // S&#xA;   &quot;-&quot;,      // T&#xA;   &quot;..-&quot;,    // U&#xA;   &quot;...-&quot;,   // V&#xA;   &quot;.--&quot;,    // W&#xA;   &quot;-..-&quot;,   // X&#xA;   &quot;-.--&quot;,   // Y&#xA;   &quot;--..&quot;    // Z&#xA;};&#xA;&#xA;char * numbers [10] = &#xA;  {&#xA;  &quot;-----&quot;,  // 0&#xA;  &quot;.----&quot;,  // 1&#xA;  &quot;..---&quot;,  // 2&#xA;  &quot;...--&quot;,  // 3&#xA;  &quot;....-&quot;,  // 4&#xA;  &quot;.....&quot;,  // 5&#xA;  &quot;-....&quot;,  // 6&#xA;  &quot;--...&quot;,  // 7&#xA;  &quot;---..&quot;,  // 8&#xA;  &quot;----.&quot;,  // 9&#xA;  };&#xA;&#xA;const unsigned long dotLength = 100;  // mS&#xA;const unsigned long dashLength = dotLength * 3;  &#xA;const unsigned long wordLength = dashLength * 2; &#xA;&#xA;// get a line from serial&#xA;//  forces to upper case&#xA;void getline (char * buf, size_t bufsize)&#xA;{&#xA;byte i;&#xA;&#xA;  // discard any old junk&#xA;  while (Serial.available ())&#xA;    Serial.read ();&#xA;&#xA;  for (i = 0; i &amp;lt; bufsize - 1; )&#xA;    {&#xA;    if (Serial.available ())&#xA;      {&#xA;      int c = Serial.read ();&#xA;&#xA;      if (c == '\n')  // newline terminates&#xA;        break;&#xA;&#xA;      buf [i++] = toupper (c);&#xA;      } // end if available&#xA;    }  // end of for&#xA;  buf [i] = 0;  // terminator&#xA;  Serial.println (buf);  // echo what they typed&#xA;  }     // end of getline&#xA;&#xA;void dot ()&#xA;  {&#xA;  digitalWrite (LED, HIGH);&#xA;  delay (dotLength);&#xA;  digitalWrite (LED, LOW); &#xA;  delay (dotLength);&#xA;  }  // end of dot&#xA;&#xA;void dash ()&#xA;  {&#xA;  digitalWrite (LED, HIGH);&#xA;  delay (dashLength);&#xA;  digitalWrite (LED, LOW); &#xA;  delay (dotLength);&#xA;  }  // end of dash&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  pinMode (LED, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  Serial.println (&quot;Enter your message ...&quot;);&#xA;  char buf [60];&#xA;  getline (buf, sizeof buf);&#xA;&#xA;&#xA;  // for each letter&#xA;  for (char * p = buf; *p; p++)&#xA;    {&#xA;    char c = *p;&#xA;    char * sequence = NULL;&#xA;&#xA;    if (c &amp;gt;= 'A' &amp;amp;&amp;amp; c &amp;lt;= 'Z')&#xA;      sequence = letters [c - 'A'];&#xA;    else if (c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9')&#xA;      sequence = numbers [c - '0'];   &#xA;    else if (c == ' ')&#xA;      {&#xA;      delay (wordLength);   // gap between words&#xA;      continue;&#xA;      }&#xA;&#xA;    // ignore not in table&#xA;    if (sequence == NULL)&#xA;      continue;&#xA;&#xA;    // output sequence for one letter&#xA;    for (char * s = sequence; *s; s++)&#xA;      {&#xA;      if (*s == '.')&#xA;        dot ();&#xA;      else if  (*s == '-')&#xA;        dash (); &#xA;      }&#xA;    // now a gap&#xA;    delay (dashLength);   &#xA;    }  // end of for each letter&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-04T02:10:58.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13131" PostTypeId="1" AcceptedAnswerId="14441" CreationDate="2015-07-04T02:11:52.377" Score="0" ViewCount="987" Body="&lt;p&gt;If i connect a switch to the reset pin, can I create an effective way of turning off the Arduino (overnight) without removing its power supply?  &lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-08-22T06:18:42.613" Title="can I create an on/off switch for my Arduino using the reset pin?" Tags="|reset|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13132" PostTypeId="2" ParentId="13121" CreationDate="2015-07-04T03:09:41.070" Score="1" Body="&lt;p&gt;I have some details about running motors etc. from Arduino pins at &lt;a href=&quot;http://www.gammon.com.au/motors&quot; rel=&quot;nofollow noreferrer&quot;&gt;Driving motors, lights, etc. from an Arduino output pin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite possibly what would work for you is a MOSFET - as Majenko suggested - connected up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2QDZa.png&quot; alt=&quot;Low-side MOSFET driver&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case you connect the positive side of your 12V supply for your pump to the pump, and the MOSFET sinks current to ground, when you require the pump on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget the diode D1 which prevents damage from the inductive load of the pump generating high-voltage spikes.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-04T03:09:41.070" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13133" PostTypeId="1" AcceptedAnswerId="13135" CreationDate="2015-07-04T03:14:36.387" Score="4" ViewCount="23337" Body="&lt;p&gt;I'm attempting to fade a strip of ws2812 7 pixels in length. Below I am using a for loop to increment the color red. I can fade it to red (from blue) but it will do it one pixel at a time or it just stays blue, depending where I move my r for-loop to. I need it to fade from color to color all 7 LEDs at once. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get no errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand the process of getting NUM_LEDS leds all into x then proceeding with my color changing. Seems like I'm grabbing one pixel, fading it to red, then another...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;fastLeds 3.03 library, arduino 1.0.6&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define DATA_PIN 6&#xA;#define NUM_LEDS 7&#xA;&#xA;#define BRIGHTNESS 45&#xA;#define COLOR_ORDER GRB&#xA;#define g 50&#xA;#define b 100&#xA;int r;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup(){&#xA;  FastLED.addLeds&amp;lt;WS2811, DATA_PIN, GRB&amp;gt;(leds, NUM_LEDS);&#xA;}&#xA;&#xA;void loop(){&#xA;  for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;    delay(10);&#xA;    leds[x] = CRGB(r,g,b);&#xA;  }&#xA;  FastLED.show();&#xA;  delay(10); &#xA;&#xA;  //-------------------------&#xA;&#xA;  for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;    for(int r = 0; r &amp;lt; 254; r++) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if NUM_LEDS is holding the number 7 why can't I just do it like this below: leds[NUM_LEDS]?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      leds[x] = CRGB(r,g,b);&#xA;      FastLED.show();&#xA;      delay(100);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10995" LastEditorUserId="84" LastEditDate="2015-07-12T09:19:07.867" LastActivityDate="2017-03-12T20:35:39.850" Title="Fading from color to color using for-loop FastLEDs" Tags="|arduino-uno|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13134" PostTypeId="1" CreationDate="2015-07-04T03:42:27.883" Score="2" ViewCount="240" Body="&lt;p&gt;I have been looking for a good way to play sounds using an Arduino.  I started to consider just buying a cheap mp3 player and replacing the player's buttons with optical switches, which connect to an Arduino.  I wanted to know if anyone has done this before and if there was a good mp3 player for this (one that may have some sort of control port / ir sensor.)  &lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="10794" LastEditDate="2015-09-02T01:38:34.063" LastActivityDate="2015-09-02T01:38:34.063" Title="Connect an mp3 player to an Arduino?" Tags="|sound|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13135" PostTypeId="2" ParentId="13133" CreationDate="2015-07-04T03:45:04.197" Score="6" Body="&lt;p&gt;If you want to fade all the LEDs form blue to red at the same time, I think you want code like this (explanatory comments embedded)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define DATA_PIN 6&#xA;#define NUM_LEDS 7&#xA;&#xA;#define COLOR_ORDER GRB&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup(){&#xA;  FastLED.addLeds&amp;lt;WS2811, DATA_PIN, GRB&amp;gt;(leds, NUM_LEDS);&#xA;&#xA;}&#xA;void loop(){&#xA;&#xA;  // Let's take 256 steps to get from blue to red&#xA;  // (the most possible with an LED with 8 bit RGB values)&#xA;&#xA;  for( int colorStep=0; colorStep&amp;lt;256; colorStep++ ) {&#xA;&#xA;      int r = colorStep;  // Redness starts at zero and goes up to full&#xA;      int b = 255-colorStep;  // Blue starts at full and goes down to zero&#xA;      int g = 0;              // No green needed to go from blue to red&#xA;&#xA;      // Now loop though each of the LEDs and set each one to the current color&#xA;&#xA;      for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;          leds[x] = CRGB(r,g,b);&#xA;      }&#xA;&#xA;&#xA;&#xA;      // Display the colors we just set on the actual LEDs&#xA;      FastLED.show();&#xA;&#xA;      delay(10); &#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="7859" LastEditDate="2015-07-04T04:25:27.923" LastActivityDate="2015-07-04T04:25:27.923" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13136" PostTypeId="1" CreationDate="2015-07-04T01:14:20.893" Score="1" ViewCount="6070" Body="&lt;p&gt;I have a strip of 7 leds. its ws2812. Im starting them on blue. Next I want them to do a slow fade into pink. So all Im trying right now is to increment r.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get them to work one by one. But I need them to all fade together from blue to pink. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ive moved my r++ loop around till I was cross-eyed. Still it didnt fade all 7 leds to pink all at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sometimes it would stay blue and do nothing sometimes fade to pink one pixel at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get all 7 leds to fade together?&#xA;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS 7&#xA;#define DATA_PIN 6&#xA;#define BRIGHTNESS 45&#xA;#define COLOR_ORDER GRB&#xA;#define g 50&#xA;#define b 100&#xA;&#xA;int r; //changed it to undefined&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup(){&#xA;FastLED.addLeds&amp;lt;WS2812, DATA_PIN, GRB&amp;gt;(leds, NUM_LEDS);&#xA;&#xA; }&#xA;void loop(){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this lights all leds to blue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;&#xA;  leds[x] = CRGB(r,g,b);&#xA; }&#xA;  FastLED.show();&#xA;  delay(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this code should grab all 7 leds in NUM_LEDS store it in x&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;&#xA;&#xA;&#xA;  leds[x] = CRGB(r,g,b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Heres the problem area. I get no errors but it doesnt fade all 7 leds at a time.&#xA;Ive tried moving my code around but it either doesnt fade or fades to pink one led at a time. where should my 'for loop' for incrementing r be at?&#xA;Should I be changing rgb all at once using array?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//take r and fade it up to 254&#xA;&#xA;&#xA;for(int r = 0; r &amp;lt; 254; r++) {&#xA;&#xA;&#xA;  }&#xA;  }&#xA;     FastLED.show();&#xA; delay(100);    &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10995" OwnerDisplayName="user28025" LastEditorUserId="10794" LastEditDate="2015-09-12T00:40:30.930" LastActivityDate="2015-09-12T00:40:30.930" Title="fading colors on a ws2812 strip" Tags="|c++|led|rgb-led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13137" PostTypeId="2" ParentId="13136" CreationDate="2015-07-04T03:50:29.140" Score="1" Body="&lt;p&gt;If you want to fade all the LEDs form blue to red at the same time, I think you want code like this (explanatory comments embedded)...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define DATA_PIN 6&#xA;#define NUM_LEDS 7&#xA;&#xA;#define COLOR_ORDER GRB&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup(){&#xA;  FastLED.addLeds&amp;lt;WS2811, DATA_PIN, GRB&amp;gt;(leds, NUM_LEDS);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  // Let's take 256 steps to get from blue to red&#xA;  // (the most possible with an LED with 8 bit RGB values)&#xA;&#xA;  for( int colorStep=0; colorStep&amp;lt;256; colorStep++ ) {&#xA;&#xA;      int r = colorStep;  // Redness starts at zero and goes up to full&#xA;      int b = 255-colorStep;  // Blue starts at full and goes down to zero&#xA;      int g = 0;              // No green needed to go from blue to red&#xA;&#xA;      // Now loop though each of the LEDs and set each one to the current color&#xA;&#xA;      for(int x = 0; x &amp;lt; NUM_LEDS; x++){&#xA;          leds[x] = CRGB(r,g,b);&#xA;      }&#xA;&#xA;&#xA;&#xA;      // Display the colors we just set on the actual LEDs&#xA;      FastLED.show();&#xA;&#xA;      delay(10); &#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7859" OwnerDisplayName="bigjosh" LastActivityDate="2015-07-04T04:27:22.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13138" PostTypeId="2" ParentId="13136" CreationDate="2015-07-04T04:41:07.100" Score="0" Body="&lt;p&gt;@bigjosh has provided code, so I will provide some plain text logic to explain what you should be doing.&lt;/p&gt;&#xA;&lt;p&gt;To fade from one color to the next, in this case from Solid Blue (0,0,255) to Pink (Red + Blue, 255,0,255), you need to change the value a little, latch it, then wait before you change the value again. Pseudo code:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;rgb = 0,0,255&lt;/p&gt;&#xA;&lt;p&gt;write rgb&lt;/p&gt;&#xA;&lt;p&gt;wait X milliseconds&lt;/p&gt;&#xA;&lt;p&gt;rgb = r + 1,0,255&lt;/p&gt;&#xA;&lt;p&gt;write rgb&lt;/p&gt;&#xA;&lt;p&gt;wait X milliseconds&lt;/p&gt;&#xA;&lt;p&gt;loop until r = 255&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;At each step, you need to push out the value to the leds before delaying and then starting again. The delay can and should be varied to your satisfaction. I find a fast fade better. At single steps of r + 1, even slow delays will seem mostly smooth.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-04T04:41:07.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13141" PostTypeId="2" ParentId="13134" CreationDate="2015-07-04T09:34:47.470" Score="2" Body="&lt;p&gt;Yes, people have done this before, and they have documented it on their own blogs and similar sites.  Maybe you should have asked Google first before you came here?  You'd most likely have ended up on &lt;a href=&quot;http://www.instructables.com/id/MP3-Interface-for-Arduino-Cheap-and-Easy/&quot; rel=&quot;nofollow&quot;&gt;instructables, where someone has documented exactly what you want to do and how to do it.&lt;/a&gt; and saved yourself this entire step.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-04T09:34:47.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13142" PostTypeId="1" AcceptedAnswerId="13149" CreationDate="2015-07-04T11:27:37.217" Score="2" ViewCount="688" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/lWDH8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What the two yellow cables as you can see in the picture do not know?&lt;/p&gt;&#xA;" OwnerUserId="10947" LastActivityDate="2019-02-19T22:22:16.463" Title="Motor Shield StepMotor" Tags="|arduino-motor-shield|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13144" PostTypeId="1" CreationDate="2015-07-04T13:36:50.837" Score="0" ViewCount="385" Body="&lt;p&gt;I need to power an enclosed Arduino Fio project with 12V. The intention is not to attach a battery because there is no need as this is a fixed installation with a 12V DC available (for a pair of relays which will be controlled by the Fio). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is what Pins should I use. The Fio page (&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardFio&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardFio&lt;/a&gt;) on the Arduino web site says...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Input Voltage   3.35 -12 V&#xA;Input Voltage for Charge    3.7 - 7 V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, there is no indication what pins these specs refer to. I assume that the &quot;Input Voltage for Charge&quot; refers to the mini-USB port and unlike other Arduino boards, there is no Vin pin to supply the board externally. Looking at the board layout on the same web page, I think the only possible option is via the two pins in parallel to the battery port which I suppose are then going into the voltage regulator on the board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any comments or suggestions? Has anyone done something similar?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2020-10-30T07:00:00.060" Title="What pins to use to externally power an Arduino Fio (without battery)" Tags="|power|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13145" PostTypeId="1" CreationDate="2015-07-04T14:03:50.993" Score="9" ViewCount="1671" Body="&lt;p&gt;I am looking for an inexpensive single board computer that I could program in assembly language, using limited facilities to load the object code from a PC and simple I/O peripherals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to be able to write in a reasonable time all the code on the machine myself. I don't want an OS in the way, as I want to have a program that writes in RAM some code and then branches to execute it.&#xA;Arduino would probably be my best choice, as far as system simplicity suitable for assembly programming goes, but it has a Harvard architecture and it won't allow me to execute from RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Years ago I was using a Von Neumann architecture 8-bit CPU that could branch execution to any address, no matter whether it was mapped to ROM, RAM or whatever. This is what I would like to do now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I probably could write and load in Flash memory an interpreter of op codes written in RAM, but it is a very complex and time-consuming solution, unless virtual machines of this kind exist already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on other workarounds with Arduino or of other micro-controllers I might use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pierre&lt;/p&gt;&#xA;" OwnerUserId="10999" LastEditorUserId="4628" LastEditDate="2017-03-31T13:16:05.210" LastActivityDate="2017-08-30T15:14:27.907" Title="Is there any way to run binary code from RAM?" Tags="|memory-usage|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13146" PostTypeId="1" CreationDate="2015-07-04T14:33:31.477" Score="2" ViewCount="128" Body="&lt;p&gt;I'm working on wireless uploader for Arduino from iOS devices. I'm using HM-10 BLE module which seems to work ok. PIO 2 is used as DTR for resetting (see &lt;code&gt;A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31]&lt;/code&gt; and &lt;code&gt;A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30]&lt;/code&gt; below)- using 0.1uF capacitor and 10K resistor wired to MCU reset pin. Reset seems to be done correctly as i'm getting &lt;code&gt;ready&lt;/code&gt; output (in 'setup()' body in uploaded sketch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason i'm getting &lt;code&gt;0x14 0x10&lt;/code&gt; for &lt;code&gt;0x30 0x20&lt;/code&gt; request (to ping bootloader) but not getting response for &lt;code&gt;A [0x41] . [0x81]   [0x20]&lt;/code&gt; within almost 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uploading over BLE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-07-04 19:24:10.955 xctest[54864:5122867] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31] &#xA;2015-07-04 19:24:10.955 xctest[54864:5122867] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-07-04 19:24:11.106 xctest[54864:5122867] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-07-04 19:24:11.106 xctest[54864:5122867] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30] &#xA;2015-07-04 19:24:11.106 xctest[54864:5122867] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-07-04 19:24:11.148 xctest[54864:5122867] [DEBUG  ] [   ]: Draining for 230 ms ...&#xA;2015-07-04 19:24:11.148 xctest[54864:5122867] [TRACE  ] [IN ]: Start reading&#xA;2015-07-04 19:24:11.323 xctest[54864:5122903] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-07-04 19:24:11.323 xctest[54864:5122903] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE  ] [IN ]: Finish reading&#xA;2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-07-04 19:24:11.381 xctest[54864:5122867] [DEBUG  ] [IN ]: Drained 18 bytes&#xA;2015-07-04 19:24:11.381 xctest[54864:5122867] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-07-04 19:24:11.381 xctest[54864:5122867] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-07-04 19:24:11.382 xctest[54864:5122867] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-07-04 19:24:11.382 xctest[54864:5122867] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-07-04 19:24:11.382 xctest[54864:5122867] [TRACE  ] [IN ]: Start reading&#xA;2015-07-04 19:24:11.746 xctest[54864:5122914] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-07-04 19:24:11.747 xctest[54864:5122914] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-07-04 19:24:11.747 xctest[54864:5122914] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-07-04 19:24:11.748 xctest[54864:5122867] [TRACE  ] [IN ]: Finish reading&#xA;2015-07-04 19:24:11.748 xctest[54864:5122867] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-07-04 19:24:11.749 xctest[54864:5122867] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-07-04 19:24:11.749 xctest[54864:5122867] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-07-04 19:24:11.749 xctest[54864:5122867] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE  ] [IN ]: Start reading&#xA;2015-07-04 19:24:11.750 xctest[54864:5122867] [TRACE  ] [IN ]: Finish reading&#xA;2015-07-04 19:24:11.751 xctest[54864:5122867] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-07-04 19:24:11.751 xctest[54864:5122867] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-07-04 19:24:11.751 xctest[54864:5122867] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-07-04 19:24:11.752 xctest[54864:5122867] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-07-04 19:24:11.752 xctest[54864:5122867] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-07-04 19:24:11.752 xctest[54864:5122867] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-07-04 19:24:11.752 xctest[54864:5122867] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-07-04 19:24:11.753 xctest[54864:5122867] [TRACE  ] [IN ]: Start reading&#xA;2015-07-04 19:24:11.821 xctest[54864:5122914] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-07-04 19:24:11.821 xctest[54864:5122914] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-07-04 19:24:12.721 xctest[54864:5122903] [TRACE  ] [IN ]: Rx value received 5 bytes: r [0x72] e [0x65] a [0x61] d [0x64] y [0x79] &#xA;2015-07-04 19:24:12.722 xctest[54864:5122867] [TRACE  ] [IN ]: Finish reading&#xA;2015-07-04 19:24:12.722 xctest[54864:5122867] [TRACE  ] [IN ]: Receive: r [0x72] &#xA;2015-07-04 19:24:12.723 xctest[54864:5122867] [DEBUG  ] [IN ]: Read 1 bytes, actually received 5 bytes&#xA;2015-07-04 19:24:12.723 xctest[54864:5122867] [TRACE  ] [IN ]: 4 bytes in incoming buffer remaining for next receive&#xA;2015-07-04 19:24:12.723 xctest[54864:5122867] [ERROR  ] [   ]: STK500:getParameter: protocol error #1, expected [0x14], received [0x72]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When uploading over usb it's ok:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-06-29 16:34:10.829 xctest[36585:3703900] [TRACE  ] [   ]: DTR/RTS supported by Serial, resetting&#xA;2015-06-29 16:34:11.140 xctest[36585:3703900] [DEBUG  ] [IN ]: Draining ...&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG  ] [IN ]: Drain done&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-06-29 16:34:11.393 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.531 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.531 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-06-29 16:34:11.533 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.535 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [DEBUG  ] [   ]: STK500:initialize: n_extparms = 4&#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 22 bytes&#xA;2015-06-29 16:34:11.542 xctest[36585:3703900] [TRACE  ] [OUT]: Send: B [0x42] . [0x86] . [0x00] . [0x01] . [0x00] . [0x01] . [0x01] . [0x01] . [0x03] . [0xFF] . [0xFF] . [0xFF] . [0xFF] . [0x00] . [0x80] . [0x04] . [0x00] . [0x00] . [0x00] . [0x80] . [0x00]   [0x20] &#xA;2015-06-29 16:34:11.542 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 7 bytes&#xA;2015-06-29 16:34:11.549 xctest[36585:3703900] [TRACE  ] [OUT]: Send: E [0x45] . [0x05] . [0x04] . [0xD7] . [0xC2] . [0x00]   [0x20] &#xA;2015-06-29 16:34:11.549 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [TRACE  ] [OUT]: Send: P [0x50]   [0x20] &#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.569 xctest[36585:3703900] Reading |                                                    | 0% 0ms&#xA;2015-06-29 16:34:11.570 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.571 xctest[36585:3703900] [TRACE  ] [OUT]: Send: u [0x75]   [0x20] &#xA;2015-06-29 16:34:11.571 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 5 bytes&#xA;2015-06-29 16:34:11.572 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] . [0x1E] . [0x95] . [0x0F] . [0x10] &#xA;2015-06-29 16:34:11.572 xctest[36585:3703900] Reading | ################################################## | 100% 2ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So when uploading over USB DTR/RTS and &lt;a href=&quot;https://electronics.stackexchange.com/questions/61537/what-is-the-cap-for-in-arduino-reset-circuit&quot;&gt;similar schematic&lt;/a&gt; is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the problem is in resetting approach - wiring to reset does not work when trying to upload. Am i right? Is it bootloader issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. Arduino sketch uploaded:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.print(&quot;ready&quot;);&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8327" LastEditorUserId="37523" LastEditDate="2019-08-08T17:56:29.873" LastActivityDate="2019-08-08T17:56:29.873" Title="Arduino not responding while trying to flash over BLE" Tags="|arduino-uno|bluetooth|bootloader|uploading|atmega2560|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="13148" PostTypeId="1" CreationDate="2015-07-04T16:11:43.560" Score="0" ViewCount="705" Body="&lt;p&gt;I have programmed Attiny88 with Arduino IDE 1.6.5 using &lt;a href=&quot;https://github.com/SpenceKonde/ATTinyCore&quot; rel=&quot;nofollow&quot;&gt;https://github.com/SpenceKonde/ATTinyCore&lt;/a&gt; . I chose Attiny88 because it's the cheapest Attiny (as low as $0.5) and at the same time has 28 pins with dedicated SPI.  I wrote a code for arduino to work as SPI master, and a code for Attiny88 as SPI slave but I get only 0 as answer from Attiny. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI master code for ARduino UNO&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// set up the speed, data order and data mode&#xA;SPISettings settingsA(2000000, MSBFIRST, SPI_MODE0); &#xA;const int slaveAPin = 10;&#xA;&#xA;void setup() {&#xA;  // set the Slave Select Pins as outputs:&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;SPI ON&quot;); &#xA;  pinMode (slaveAPin, OUTPUT);&#xA;  SPI.begin(); &#xA;}&#xA;&#xA;uint8_t stat, val1, result;&#xA;&#xA;void loop() {&#xA;   // read two bytes from device A&#xA;   SPI.beginTransaction(settingsA);&#xA;   digitalWrite (slaveAPin, LOW);&#xA;   // reading only, so data sent does not matter&#xA;  stat = SPI.transfer(0);&#xA;  val1 = SPI.transfer(0);&#xA;  digitalWrite (slaveAPin, HIGH);&#xA;  SPI.endTransaction();&#xA;  Serial.println(&quot;data&quot;);&#xA;  Serial.println(stat); &#xA;  Serial.println(val1);&#xA;  Serial.println(&quot;end&quot;);    &#xA;  SPI.endTransaction();&#xA;  delay(300);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SPI slave code for Attiny88:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// set up the speed, data order and data mode&#xA;SPISettings settingsA(2000000, MSBFIRST, SPI_MODE0); &#xA;const int slavePin = 14;&#xA;const int ledPin = 9;&#xA;&#xA;uint8_t stat, val1, val2, result;&#xA;&#xA;void setup() {&#xA;  // set the Slave Select Pins as outputs:&#xA;  pinMode (slavePin, INPUT);&#xA;  pinMode (ledPin, OUTPUT);&#xA;  // initialize SPI:&#xA;  digitalWrite(ledPin, HIGH);&#xA;  delay(1000);&#xA;  SPI.begin();&#xA;  stat =128;&#xA;  val1= 1;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (slavePin==LOW) {&#xA;    SPI.beginTransaction(settingsA);    &#xA;    SPI.transfer(stat);&#xA;    SPI.transfer(val1);&#xA;    result = SPI.transfer(0);&#xA;    digitalWrite(ledPin, result);&#xA;    SPI.endTransaction();&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10885" LastActivityDate="2015-08-04T00:44:12.030" Title="Attiny88 as SPI slave" Tags="|arduino-uno|attiny|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13149" PostTypeId="2" ParentId="13142" CreationDate="2015-07-04T16:40:49.890" Score="0" Body="&lt;p&gt;There are two types of stepper motors: unipolar and bipolar. Bipolars usually have four wires and unipolars have six.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Mi9t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Mi9t.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;--&lt;a href=&quot;http://hobbymilling.com/wp-content/uploads/2011/05/Unipolar-stepper-motor-windings.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hobbymilling.com/wp-content/uploads/2011/05/Unipolar-stepper-motor-windings.png&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;img src=&quot;https://www.codeproject.com/KB/system/steppermotorcontrol/pic6.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;--&lt;a href=&quot;https://www.codeproject.com/KB/system/steppermotorcontrol/pic6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.codeproject.com/KB/system/steppermotorcontrol/pic6.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The motor shield is designed to drive a bipolar motor (4 wires) but the motor is unipolar (6 wires). As you can see in the pictures, if you ignore the middle wire of the unipolar motor, it is the exact same as a bipolar stepper motor.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="27346" LastEditDate="2019-02-19T22:22:16.463" LastActivityDate="2019-02-19T22:22:16.463" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13150" PostTypeId="1" CreationDate="2015-07-04T17:41:42.850" Score="1" ViewCount="4663" Body="&lt;p&gt;I am looking for a way to protect my Arduino's digital outputs from unwanted, outside voltages. My project uses about 20 different outputs, each connected to a wire (run) that can range from 20 to 100 feet (I used cat5 cable, with each inner wire (randomly chosen) dedicated to a single digital in, out, +5, +9 or ground.)  There is a good change that outside voltages could impact these digital outs (or any other pin or power wire.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a good resource on protecting digital in's but I ma not sure how to protect the digital outs.  Each needs to be able to both pull a connect component to ground, and push it up to 5 volts (am I saying this correctly?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should be able to protect the digital outs from shorts or 12v spikes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I build this circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: it is difficult for me to describe this problem without mentioning the danger to all components. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that ways of protecting digital &lt;em&gt;inputs&lt;/em&gt; is &lt;a href=&quot;https://arduino.stackexchange.com/questions/13126/best-way-to-protect-a-digital-or-analog-input-from-12volts/13128?noredirect=1#comment23597_13128&quot;&gt;HERE&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2020-08-19T13:57:40.970" Title="Best way to protect a digital output?" Tags="|voltage-protection|digital-in|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13151" PostTypeId="2" ParentId="13150" CreationDate="2015-07-04T18:51:55.553" Score="1" Body="&lt;p&gt;Add a resistor in the circuit to limit the current in case of a short. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add clamping diode to prevent voltages higher than 5v (combined with the resistor from before). The AVR has internal clamping diodes, but those can only handle very little current. Since you are running such long wires, you probably need to add the lowest value resistor, to limit noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS The possibility of have a external voltage applied to an output sound pretty troubling to me.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-04T18:51:55.553" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13152" PostTypeId="1" CreationDate="2015-07-04T19:03:57.477" Score="-1" ViewCount="579" Body="&lt;p&gt;I'd like to send sensor values over ethernet shield to a webserver. But for this I'd like to encrypt the data on the arduino and decrypt it on the webserver (PHP).&#xA;Do you have any suggestions or examples?&lt;/p&gt;&#xA;" OwnerUserId="11001" LastEditorUserId="2881" LastEditDate="2015-07-04T19:53:19.013" LastActivityDate="2015-07-04T19:53:54.533" Title="Encrypting data for webserver" Tags="|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13153" PostTypeId="2" ParentId="13152" CreationDate="2015-07-04T19:53:54.533" Score="1" Body="&lt;p&gt;XTEA is probably your best bet.  It's lightweight, easy to implement, and secure enough for a bit of sensor data...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/XTEA&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/XTEA&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There's also the slightly more complex, and also slightly more secure, XXTEA:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/XXTEA&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/XXTEA&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-04T19:53:54.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13157" PostTypeId="2" ParentId="13148" CreationDate="2015-07-04T23:10:04.353" Score="2" Body="&lt;p&gt;You do not appear to be configuring the slave as an SPI slave. Merely changing the pin modes won't achieve this. Example code at &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI - Serial Peripheral Interface - for Arduino&lt;/a&gt; - however that does not specifically mention the Attiny88.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my example in reply #1 on that page I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // turn on SPI in slave mode&#xA;  SPCR |= bit (SPE);&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode(MISO, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sets SPCR bit MSTR to zero (by not mentioning it). If you call SPI.begin() it will be activated in &lt;strong&gt;master&lt;/strong&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the Attiny88 has the same register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in my opinion your code merely has two SPI masters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you seem to be doing 3 transfers in the master, but only 2 transfers in the slave.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-04T23:10:04.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13158" PostTypeId="2" ParentId="12891" CreationDate="2015-07-04T23:21:10.413" Score="1" Body="&lt;p&gt;The I2C pins on the V3 shield are just copies of A4 &amp;amp; A5 - so just run a jumper wire some way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW that Motion shield looks like it only uses 1 interrupt pin in addition to I2C, so you may be ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor board does have a library at &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/downloads&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-motor-shield/downloads&lt;/a&gt; and you can look at the code to see what it uses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally use the mpu6050 - same kind of thing, I2C one interrupt but only 6DoF (which is plenty).  The 6050 has been superseded with the 9150, 9DoF.  6050 break out boards sell for $6 (or less).  Actually I put all this together on one piece (&lt;a href=&quot;http://www.spiked3.com/new-products/&quot; rel=&quot;nofollow&quot;&gt;http://www.spiked3.com/new-products/&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-07-04T23:21:10.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13159" PostTypeId="2" ParentId="13145" CreationDate="2015-07-04T23:41:22.093" Score="1" Body="&lt;p&gt;In my opinion the interpreter idea is much more feasible. The notion of writing, in assembler, code that itself generates machine code, in RAM, and then executes it, is itself incredibly complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't said why you want to do this, so this is somewhat of an &lt;a href=&quot;http://xyproblem.info/&quot; rel=&quot;nofollow&quot;&gt;X-Y problem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't want an o.s. in the way ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The normal Arduinos do not have an OS in the way - basically the code you write is what gets loaded onto the chip.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-04T23:41:22.093" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13160" PostTypeId="1" CreationDate="2015-07-05T01:58:38.797" Score="2" ViewCount="4748" Body="&lt;p&gt;I work in a robot using arduino, and i have a few questions:&#xA;It is possible to increase the speed of a servo, for example a parallax?&#xA;It is possible to measure the current that pass through a servo?&lt;/p&gt;&#xA;" OwnerUserId="10931" LastActivityDate="2015-11-17T19:16:38.993" Title="Servo Speed Control" Tags="|servo|robotics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13161" PostTypeId="2" ParentId="4572" CreationDate="2015-07-05T02:39:22.427" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in program memory. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;All&lt;/strong&gt; constants are initially in program memory. Where else would they be when the power is off? &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think of it as embedded somewhere in the code segment, which must be fairly possible inside a von-Neumann-architecture. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's actually &lt;a href=&quot;https://en.wikipedia.org/wiki/Harvard_architecture&quot; rel=&quot;nofollow&quot;&gt;Harvard architecture&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why on earth do I have to copy the damn content to RAM before accessing it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't. In fact there is a hardware instruction (LPM - Load Program Memory) which moves data directly from program memory into a register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an example of this technique in &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11608&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno output to VGA monitor&lt;/a&gt;. In that code there is a bitmapped font stored in program memory. It is read from that on-the-fly and copied to the output like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // blit pixel data to screen    &#xA;  while (i--)&#xA;    UDR0 = pgm_read_byte (linePtr + (* messagePtr++));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A disassembly of those lines shows (in part):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  f1a:  e4 91           lpm r30, Z+&#xA;  f1c:  e0 93 c6 00     sts 0x00C6, r30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that a byte of program memory was copied into R30, and then immediately stored into the USART register UDR0. No RAM involved.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However there is a complexity. For normal strings the compiler expects to find data in RAM not PROGMEM. They are different address spaces, and therefore 0x200 in RAM is something different from 0x200 in PROGMEM. Thus the compiler goes to the trouble of copying constants (like strings) into RAM at program startup, so it doesn't have to worry about knowing the difference later on.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How is the code (32kiB) handled then with only 2kiB RAM?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Good question. You won't get away with having more than 2 KB of constant strings, because there won't be room to copy them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why people who are writing things like menus and other wordy stuff, take extra steps to give the strings the PROGMEM attribute, which disables them being copied into RAM.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But I'm bewildered by those instructions to just read and print data from program memory:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you add the PROGMEM attribute you have to take steps to let the compiler know that these strings are in a different address space. Making a complete (temporary) copy is one way. Or just print directly from PROGMEM, a byte at a time. An example of that is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Print a string from Program Memory directly to save RAM &#xA;void printProgStr (const char * str)&#xA;{&#xA;  char c;&#xA;  if (!str) &#xA;    return;&#xA;  while ((c = pgm_read_byte(str++)))&#xA;    Serial.print (c);&#xA;} // end of printProgStr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you pass this function a pointer to a string in PROGMEM, it does the &quot;special read&quot; (pgm_read_byte) to pull the data from PROGMEM rather than RAM, and the prints it. Note that this takes one additional clock cycle, per byte.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And even more interesting: What happens to literal constants like in this expression &lt;code&gt;a = 5*(10+7)&lt;/code&gt; are 5, 10 and 7 really copied to RAM before loading them into registers? I just can't believe that.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, because they don't have to be. That would compile into a &quot;load literal into register&quot; instruction. That instruction is already in PROGMEM, so the literal is now dealt with. No need to copy it to RAM and then read it back.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have a lengthy description of these things on the page &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt;. That has example code for setting up strings, and arrays of strings, reasonably easily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also mentions the F() macro which is an easy way of simply printing from PROGMEM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (F(&quot;Hello, world&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A bit of preprocessor complexity lets that compile into a helper function which pulls the bytes in the string from PROGMEM a byte at a time. No intermediate use of RAM is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is easy enough to use that technique for things other than Serial (eg. your LCD) by deriving the LCD printing from the Print class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, in one of the LCD libraries I wrote, I did exactly that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class I2C_graphical_LCD_display : public Print&#xA;{&#xA;...&#xA;    size_t write(uint8_t c);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key point here is to derive from Print, and override the &quot;write&quot; function. Now your overridden function does whatever it needs to output a character. Since it is derived from Print you can now use the F() macro. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.println (F(&quot;Hello, world&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-05T02:39:22.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13162" PostTypeId="1" CreationDate="2015-07-05T04:32:12.460" Score="-2" ViewCount="286" Body="&lt;p&gt;I'm working on a Arduino controlled solenoid motor project that I found on Instructables. I have been able to piece together what I think is most of the code but I'm getting some syntax errors and was wondering if I could get some help? Here is the code and the errors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   // Including Libraries&#xA;#include &amp;lt;Wire.h&amp;gt;                                   &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;                     &#xA;#include &amp;lt;math.h&amp;gt;                                   &#xA;&#xA;LiquidCrystal_I2C mydisplay(0x27,16,2);             &#xA;&#xA;// Define Input/Output Pins&#xA;#define solenoidpin 9                               &#xA;#define potpin 1                                    &#xA;#define ignitioninputpin 2                          &#xA;///#define interruptnumber 3                          &#xA;#define isr_rpm(INT0_vect)&#xA;&#xA;// Defineing Variables&#xA; int previousstate;                                  &#xA; byte buttonstate;                                  &#xA; int counter1;                                      &#xA; int start;                                         &#xA; int finish;                                        &#xA; int elapsed;                                        &#xA; int RPM;                                            &#xA;&#xA;// Main setup&#xA;void setup(){ &#xA;  pinMode(ignitioninputpin,INPUT);                  &#xA;  digitalWrite(ignitioninputpin,HIGH);              &#xA;////  attachInterrupt(3,isr_rpm, FALLING);              &#xA;  counter1=1;                                       &#xA;&#xA;  mydisplay.init();                                 &#xA;  mydisplay.backlight();                            &#xA;  mydisplay.setCursor(0,1);                        &#xA;  mydisplay.print(&quot; Soleniod Motor &quot;);             &#xA;&#xA;  previousstate=HIGH;                               &#xA;  Serial.begin(19200);                              &#xA;  buttonstate = digitalRead(ignitioninputpin);      &#xA;}&#xA;&#xA;// Main program loop&#xA;void loop() {&#xA;  buttonstate = digitalRead(ignitioninputpin);      &#xA;  Serial.println(buttonstate);                      &#xA;  Serial.write(&quot;previousstate&quot;);                    &#xA;  Serial.println(previousstate);                    &#xA;  Serial.println(counter1);                         &#xA;  float elapsed=start=finish;                       &#xA;  float RPM= (6000/elapsed);                        &#xA;{&#xA;&#xA;if  (buttonstate==LOW &amp;amp;&amp;amp; previousstate==HIGH &amp;amp;&amp;amp; (counter1%2)==0){    &#xA;    digitalWrite(solenoidpin,HIGH);&#xA;  }&#xA;&#xA;if  (buttonstate==HIGH &amp;amp;&amp;amp; previousstate==LOW &amp;amp;&amp;amp; (counter1%2)==0){&#xA;    digitalWrite(solenoidpin,HIGH);                                 &#xA;  }&#xA;&#xA;if  (buttonstate==LOW &amp;amp;&amp;amp; previousstate==HIGH &amp;amp;&amp;amp; (counter1%2)==0){   &#xA;    digitalWrite(solenoidpin,LOW);&#xA;  }&#xA;&#xA;if  ((counter1%2)==0){                                            for rpm calcs&#xA;    finish=start;                                                  &#xA;    start=millis();&#xA;  }&#xA;&#xA;if  ((counter1%6)==0){                                             &#xA;    mydisplay.setCursor(0,0);                                     &#xA;    mydisplay.print(&quot; RPM &quot;);                                     &#xA;    mydisplay.print(RPM);                                          &#xA;    mydisplay.setCursor(0,1);                                      &#xA;    mydisplay.print(&quot; Solenoid Motor &quot;);                           &#xA;  }&#xA;&#xA;void ISR1();&#xA;  buttonstate=LOW;                                                &#xA;  counter1=counter1+1;                                            &#xA;  previousstate=HIGH;                                              &#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error messages:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Binary sketch size: 7,594 bytes (of a 32,256 byte maximum)&lt;/p&gt;&#xA;" OwnerUserId="6783" LastEditorUserId="4143" LastEditDate="2015-07-05T18:20:52.000" LastActivityDate="2019-04-26T07:44:16.907" Title="coding problems" Tags="|arduino-uno|i2c|lcd|interrupt|" AnswerCount="2" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="13163" PostTypeId="2" ParentId="13162" CreationDate="2015-07-05T10:32:04.283" Score="3" Body="&lt;p&gt;Welcome to Arduino.SE. I am not going to rewrite the code for you but from this and other answers and comments you should be able to correct the code for yourself from constructive criticism.&lt;/p&gt;&#xA;&lt;p&gt;To start at the beginning.&#xA;You have defined &lt;code&gt;interruptpinnumber&lt;/code&gt; but you don't use it in the &lt;code&gt;attachInterrupt&lt;/code&gt; function as you declare interrupt pin 1(digital pin 3) and not 0 as the interrupt pin, this will cause problems in your code.&lt;/p&gt;&#xA;&lt;p&gt;Next, for your timing variables, they need to be &lt;code&gt;unsigned long&lt;/code&gt; as the &lt;code&gt;millis()&lt;/code&gt; function will return unsigned long. There is also no need to declare them volatile as you are not using them in the ISR routine.&lt;/p&gt;&#xA;&lt;p&gt;On the topic of the ISR, you have used the arduino &lt;a href=&quot;https://www.arduino.cc/en/Reference/attachInterrupt&quot; rel=&quot;nofollow noreferrer&quot;&gt;attachInterrupt()&lt;/a&gt; and you have used the actual &lt;code&gt;ISR()&lt;/code&gt; &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;routine from the AVR libraries&lt;/a&gt;, also without including it. In the ISR you need to give it a vector which is not there and that is going to give errors later on. You also do not need the ISR routine if you have used the function from Arduino. You need to ensure that what you declare as the routine( that being &lt;code&gt;isr_rpm&lt;/code&gt;) in the &lt;code&gt;attachInterrupt()&lt;/code&gt; function to be executed when the interrupt occurs, actually exists.&lt;/p&gt;&#xA;&lt;p&gt;Also there are some basic arithmetic issues with the &lt;code&gt;elapsed&lt;/code&gt; time calculation, that is if you were trying to determine the difference.&lt;/p&gt;&#xA;&lt;p&gt;As @Majenko also pointed out and I was going to too, that the use of a bitwise AND, &lt;code&gt;&amp;amp;&lt;/code&gt; in your &lt;code&gt;if()&lt;/code&gt; statements might not be a problem but best to learn now that you should use logical AND for comparison &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;There is also a redundant &lt;code&gt;if&lt;/code&gt; statement, that I will leave to you to find as it is your code and you can determine if it is of use or not. Also you need to keep track of you braces as this will cause the errors you are seeing too.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I think I need to elaborate on a few things as I think you got confused a bit more.&lt;/p&gt;&#xA;&lt;p&gt;Concerning the whole arduino attachInterrupt function, the &lt;code&gt;isr_rpm()&lt;/code&gt; needs to be a function and not a define, I think this caused it&lt;/p&gt;&#xA;&lt;blockquote class=&quot;spoiler&quot;&gt;&#xA;&lt;p&gt; In the ISR you need to give it a vector which is not there and that is going to give errors later on. You also do not need the ISR routine if you have used the function from Arduino. You need to ensure that what you declare as the routine( that being &lt;code&gt;isr_rpm&lt;/code&gt;) in the &lt;code&gt;attachInterrupt()&lt;/code&gt; function to be executed when the interrupt occurs, actually exists.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A function of that would be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void isr_rpm(){&#xA;&#xA;   //code&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As @Majenko has kindly done you a favor and annotated your code, look at the stuff &lt;em&gt;related to the interrupt routine&lt;/em&gt; (and other stuff) and compare it with the below avrfreaks tutorial, and the original code if you have it, the problem to begin with was that you had &lt;em&gt;too many braces&lt;/em&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void ISR(){&#xA;      buttonState = LOW;&#xA;      counter1 = counter1 + 1;&#xA;      previousState = HIGH;&#xA;    }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;it should be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;ISR(INT0_vect){&#xA;      buttonState = LOW;&#xA;      counter1 = counter1 + 1;&#xA;      previousState = HIGH;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is no need to give your own special name to ISR either, this is from the newer code.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.avrfreaks.net/forum/tut-newbies-guide-avr-interrupts?page=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVRfreaks tutorial concerning interrupts and the ISR stuff&lt;/a&gt; it will give you an explanation on the volatile stuff too.&lt;/p&gt;&#xA;&lt;p&gt;I cannot stress the point more but, look through your code that Majenko has annotated and see where you can fix the code.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-04-26T07:44:16.907" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13164" PostTypeId="1" CreationDate="2015-07-05T11:43:17.763" Score="5" ViewCount="442" Body="&lt;p&gt;I'm trying to use the Ethernet Shield and the EasyVR (voice recognition) together.&#xA;The Ethernet shield uses the same pins that the EasyVR, but the easyVR works fine if I don't call Ethernet.begin(). Is there a way to disconnect the ethernet shield in order to be able to use the EasyVR again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't seen any method like &quot;release&quot; or &quot;disconnect&quot; in the Ethernet's class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11007" LastEditorUserId="11007" LastEditDate="2019-08-28T23:05:22.817" LastActivityDate="2019-08-28T23:05:22.817" Title="Disconnect Ethernet Shield" Tags="|arduino-uno|shields|ethernet|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13165" PostTypeId="1" AcceptedAnswerId="13166" CreationDate="2015-07-05T14:04:55.063" Score="9" ViewCount="8499" Body="&lt;p&gt;Is there a way for me to read the pin mode for one of the digital pins on Arduino?   In other words, can I determine whether a pin's been set to an input or output?&lt;/p&gt;&#xA;" OwnerUserId="8611" LastEditorUserId="9962" LastEditDate="2016-02-23T12:28:54.963" LastActivityDate="2016-02-23T13:45:30.393" Title="How to read pinMode for digital pin?" Tags="|pins|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13166" PostTypeId="2" ParentId="13165" CreationDate="2015-07-05T14:43:05.753" Score="4" Body="&lt;p&gt;Yes, you can use the data direction registers (DDR&lt;em&gt;B&lt;/em&gt;, DDR&lt;em&gt;C&lt;/em&gt;, DDR&lt;em&gt;D&lt;/em&gt; depending on which port) to check what mode a pin is in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a pin is in output mode then the corresponding bit in DDRx will be 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One complication is that the Arduino functions give each pin an &quot;Arduino&quot; pin number, and you have to look at a pin map to figure out which DDR register and bit corresponds to the pin you want to check. You can find a pin map for Arduinos based on the ATMEGA168/ATMEGA328 (including Uno) here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Hacking/Atmega168Hardware&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Hacking/Atmega168Hardware&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, if you want to check if Arduino digital pin #4 is set for output, you'd look at the map and see that corresponds to PD4. That means &quot;port D&quot; and &quot;bit 4&quot;, so you could say...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( DDRD &amp;amp; _BV(4) ) {   // Check bit #4 of the data direction register for port D&#xA;    // If we get here, then Arduino digital pin #4 was in output mode&#xA;} else {&#xA;    // If we get here, then Arduino digital pin #4 was in input mode&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to check Arduino digital pin #14, then you would use &lt;code&gt;DDRB &amp;amp; _BV(5)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(&lt;code&gt;_BV(x)&lt;/code&gt; is a macro that shifts &lt;code&gt;1&lt;/code&gt; &lt;code&gt;x&lt;/code&gt; bits to the right.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="10794" LastEditDate="2015-07-11T07:24:17.243" LastActivityDate="2015-07-11T07:24:17.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13167" PostTypeId="1" AcceptedAnswerId="13168" CreationDate="2015-07-05T10:46:14.083" Score="13" ViewCount="14251" Body="&lt;p&gt;I have investigated the sleeps options of the ATmega328, and read a few articles about it, and I would like to understand if there are more options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would like to get as low current as possible, so that anything less that 100uA would be good - as long as I can listen to uart and interrupts for waking up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a custom PCB (not the UNO), with ATmega328p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting the chip to deep sleep:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; set_sleep_mode (SLEEP_MODE_PWR_DOWN);  &#xA; sleep_enable();&#xA; sleep_cpu ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would not wake it up with serial communication,according to &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to put it in &lt;code&gt;IDLE&lt;/code&gt; mode, to listen to serial, but this would consume a few mA -bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found &lt;a href=&quot;http://donalmorrissey.blogspot.co.il/2010/04/sleeping-arduino-part-3-wake-up-via.html&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt; where you can connect in hardware the serial to the interrupt - which is dangerous so you can loose data, and moreover, I need these 2 interrupts pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also read &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot; rel=&quot;noreferrer&quot;&gt;this article of Gammon&lt;/a&gt;, where you can disable some things, so you can get IDLE sleep with much lower power - but he didn't mention how exactly you get from this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; power_adc_disable();&#xA;      power_spi_disable();&#xA;      power_timer0_disable();&#xA;      power_timer1_disable();&#xA;      power_timer2_disable();&#xA;      power_twi_disable();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, bottom line, is there any option out there, to get less than 0.25mA at least, and also listen to serial port, without any hardware manipulation?&#xA;For example, waking up with &lt;strong&gt;long serial data&lt;/strong&gt; input?&lt;/p&gt;&#xA;" OwnerUserId="4989" OwnerDisplayName="Curnelious" LastEditorDisplayName="user6430" LastEditDate="2015-07-12T09:20:35.073" LastActivityDate="2018-05-30T05:13:55.843" Title="Put ATmega328 in very deep sleep and listen to serial?" Tags="|serial|atmega328|sleep|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13168" PostTypeId="2" ParentId="13167" CreationDate="2015-07-05T11:08:12.750" Score="12" Body="&lt;p&gt;A board we make does this. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The RX pin is wired to INT0&lt;/li&gt;&#xA;&lt;li&gt;INT0 pin set to input or input pullup depending on how the RX line is driven&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On sleep, INT0 low level interrupt is enabled&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Clear software flag for rx interrupt&#xA;rx_interrupt_flag = 0;&#xA;//Clear hardware flag for rx interrupt&#xA;EIFR = _BV(INTF0);&#xA;//Re-attach interrupt 0&#xA;attachInterrupt(INT_RX, rx_interrupt, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;INT0 interrupt service routine sets a flag and disables the interrupt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void rx_interrupt()&#xA;{&#xA;    detachInterrupt(INT_RX);&#xA;    rx_interrupt_flag = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On wakeup, we check for the flag (there are other interrupt sources)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the comms side of things we use a message protocol that has a start character &lt;code&gt;&amp;gt;&lt;/code&gt; and end character &lt;code&gt;\r&lt;/code&gt;. e.g. &lt;code&gt;&amp;gt;setrtc,2015,07,05,20,58,09\r&lt;/code&gt;. This give some basic protection against losing messages, as incoming characters are not processed until a &lt;code&gt;&amp;gt;&lt;/code&gt; is received. To wake up the device we send a dummy message before transmission. A single character would do it, but we send &lt;code&gt;&amp;gt;wakeup\r&lt;/code&gt; hehe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device stays awake for 30 seconds after the last message is received in case of new messages. If a new message is receive the 30 second timer is reset. The PC interface software sends a dummy message every second to keep the device awake while the user has it connected for configuration etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method gives absolutely no problems at all. The board with a few peripherals uses about 40uA when sleeping. The actual current consumed by the ATMega328P is probably around 4uA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At look at the datasheet shows that the RX pin is also pin change interrupt pin 16 (PCINT16)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus another method without wires may be&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Before sleep: Set the port change interrupt mask bit in PCMSK2 for PCINT16, clear the pin change port 2 flag in PCIFR, enable the pin change port 2 interrupt (PCINT16-PCINT23) by setting PCIE2 in PCICR.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Setup an ISR for the pin change port 2 interrupt and continue as before.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The only caveat with the port change interrupt is that the interrupt is shared across all the 8 pins that are enabled for that port. So if you have more than one pin change enabled for the port, you have to determine which triggered the interrupt in the ISR. This is not a problem if you are not using any other pin change interrupts on that port (PCINT16-PCINT23 in this case)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally this is how I would have designed our board but what we have works.&lt;/p&gt;&#xA;" OwnerUserId="1566" OwnerDisplayName="geometrikal" LastActivityDate="2015-07-05T11:29:48.470" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="13169" PostTypeId="2" ParentId="12693" CreationDate="2015-07-05T16:32:52.930" Score="1" Body="&lt;p&gt;It is done by using &lt;a href=&quot;https://www.digi.com/wiki/developer/index.php/Large_ZigBee_Networks_and_Source_Routing&quot; rel=&quot;nofollow&quot;&gt;Source Routing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 16-bit addresses of the hopped devices are added to the RF payload space, thus it will reduce the number of bytes that can be sent in one RF packet.&lt;/p&gt;&#xA;" OwnerUserId="2904" LastActivityDate="2015-07-05T16:32:52.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13170" PostTypeId="1" CreationDate="2015-07-05T16:46:50.913" Score="1" ViewCount="611" Body="&lt;pre&gt;&lt;code&gt;char *p = I2CinBuffer; // array contains &quot;string&quot; &quot;,&quot; &quot;string&quot;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *p = I2CinBuffer; // The data to be parsed e.g. 6,100&#xA;char *str;       // Temp store for each data chunk&#xA;int count = 0;  &#xA;&#xA;while ((str = strtok_r(p, &quot;,&quot;, &amp;amp;p)) != NULL)    // seperate at each &quot;,&quot; delimiter&#xA;{ &#xA;    inParse[count] = str;      // Add chunk to array  &#xA;    count++;      &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does not enter while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks but the hard coding of the values &quot;6,100&quot; give correct results as it stands. However, I am now aware that the Arduino code is working in C strings and I2CInBuffer is a C string on which the &quot;strtok&quot; or &quot;strok_r&quot; functions will NOT work. My question now is how to parse the C string I2CinBuffer to obtain 2 values separated by a comma i.e. &quot;6, 100&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11009" LastEditorUserId="11009" LastEditDate="2015-07-05T20:04:51.203" LastActivityDate="2015-07-06T05:39:50.687" Title="Array values won't tokenize" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13171" PostTypeId="2" ParentId="13170" CreationDate="2015-07-05T18:17:24.493" Score="1" Body="&lt;p&gt;You're not using strtok_r properly.  You have to treat the first call to strtok_r differently to all subsequent calls, and I don't know what you're trying to do with the &lt;code&gt;&amp;amp;p&lt;/code&gt; parameter - that could never work since you're breaking the source pointer with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the manual page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The strtok_r() function is a reentrant version strtok().  The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;On  the  first  call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored.  In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unless you're doing concurrent tokenising of multiple strings there is no reason to use the reentrant version of strtok.  Instead you should just go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *p = I2CinBuffer; // The data to be parsed e.g. 6,100&#xA;int count = 0;  &#xA;&#xA;char *str = strtok(p, &quot;,&quot;);&#xA;while (str != NULL)    // seperate at each &quot;,&quot; delimiter&#xA;{ &#xA;    inParse[count] = str;      // Add chunk to array  &#xA;    count++;      &#xA;    str = strtok(NULL, &quot;,&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how the first call, outside the while loop, passes the string to parse.  All subsequent calls (inside the while loop) pass &lt;code&gt;NULL&lt;/code&gt; as the string to parse so it continues from the last point in the string rather than starting the string afresh every time from the start (with a broken string since &lt;code&gt;strtok()&lt;/code&gt; is a destructive function).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A sequence of calls to strtok() that operate on the same string maintains a pointer that determines the point from which to start searching for the  next token.   The  first  call  to strtok() sets this pointer to point to the first byte of the string.  The start of the next token is determined by scanning forward for the next nondelimiter byte in str.  If such a byte is found, it is taken as the start of the next token.  If no  such  byte  is  found,  then there are no more tokens, and strtok() returns NULL.  (A string that is empty or that contains only delimiters will thus cause strtok() to return NULL on the first call.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is considered &lt;em&gt;destructive&lt;/em&gt; because:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The end of each token is found by scanning forward until either the next delimiter byte is found or until the terminating null  byte  ('\0')  is  encountered.   If  a  delimiter byte is found, it is overwritten with a null byte to terminate the current token, and strtok() saves a pointer to the following byte; that pointer will be used as the starting point when searching for the next token.  In this case, strtok() returns a pointer to the  start  of  the found token.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So in other words, your string that started out as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo,bar,baz\0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ends up, after tokenizing, as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo\0bar\0baz\0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after the first tokenizing, if you try and pass the string again as the first parameter, instead of &quot;foo,bar,baz&quot;, it actually only sees &quot;foo&quot; since the string now ends after &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wanted to use the reentrant version you'd need to create a separate pointer variable for the save pointer and pass that as the third argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *p = I2CinBuffer; // The data to be parsed e.g. 6,100&#xA;int count = 0;  &#xA;char *saveptr;&#xA;&#xA;char *str = strtok_r(p, &quot;,&quot;, &amp;amp;saveptr);&#xA;while (str != NULL)    // seperate at each &quot;,&quot; delimiter&#xA;{ &#xA;    inParse[count] = str;      // Add chunk to array  &#xA;    count++;      &#xA;    str = strtok(NULL, &quot;,&quot;, &amp;amp;saveptr);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you still need to use the same &quot;pass the string on the first call and pass NULL on all other calls&quot; methodology since it is still destructive.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-05T18:46:13.420" LastActivityDate="2015-07-05T18:46:13.420" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13172" PostTypeId="2" ParentId="13162" CreationDate="2015-07-05T18:35:17.490" Score="1" Body="&lt;p&gt;Ok, I swore I wasn't going to do this, but I have re-formatted your latest code and I am going to go through and annotate it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Including Libraries&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;  /// &amp;lt;&amp;lt; WHY?!  You're not using it!&#xA;&#xA;LiquidCrystal_I2C mydisplay(0x27, 16, 2);&#xA;&#xA;// Define Input/Output Pins&#xA;#define solenoidpin 9&#xA;#define potpin 1&#xA;#define ignitioninputpin 2&#xA;///#define interruptnumber 3&#xA;#define isr_rpm(INT0_vect)  /// &amp;lt;&amp;lt; What is this hoping to achieve?&#xA;&#xA;// Defineing Variables&#xA;int previousstate;&#xA;byte buttonstate;&#xA;int counter1;&#xA;int start;  /// &#xA;int finish; /// &amp;lt;&amp;lt; These should be unsigned long&#xA;int elapsed;///&#xA;int RPM;&#xA;&#xA;// Main setup&#xA;void setup() {&#xA;    pinMode(ignitioninputpin, INPUT);&#xA;    digitalWrite(ignitioninputpin, HIGH);&#xA;    ////  attachInterrupt(3,isr_rpm, FALLING);  /// &amp;lt;&amp;lt; This will never work with that #define I pointed out...&#xA;    counter1 = 1;&#xA;    mydisplay.init();&#xA;    mydisplay.backlight();&#xA;    mydisplay.setCursor(0, 1);&#xA;    mydisplay.print(&quot; Soleniod Motor &quot;);&#xA;    previousstate = HIGH;&#xA;    Serial.begin(19200);&#xA;    buttonstate = digitalRead(ignitioninputpin);&#xA;}&#xA;&#xA;// Main program loop&#xA;void loop() {&#xA;    buttonstate = digitalRead(ignitioninputpin);&#xA;    Serial.println(buttonstate);&#xA;    Serial.write(&quot;previousstate&quot;);&#xA;    Serial.println(previousstate);&#xA;    Serial.println(counter1);&#xA;    float elapsed = start = finish;  /// &amp;lt;&amp;lt; You already defined these as ints in the global&#xA;    float RPM = (6000 / elapsed);    /// &amp;lt;&amp;lt; scope. Why are you defining them again as floats?!  Also,&#xA;                                     /// &amp;lt;&amp;lt; elapsed = start = finish?!?!  I think you have an = instead of a -&#xA;    { /// &amp;lt;&amp;lt; Why are you starting a new block here???&#xA;        if (buttonstate == LOW &amp;amp;&amp;amp; previousstate == HIGH &amp;amp;&amp;amp; (counter1 % 2) == 0) {  /// &amp;lt;&amp;lt; counter1 % 2 is very inefficient since counter1 is signed.&#xA;            digitalWrite(solenoidpin, HIGH);&#xA;        }&#xA;&#xA;        if (buttonstate == HIGH &amp;amp;&amp;amp; previousstate == LOW &amp;amp;&amp;amp; (counter1 % 2) == 0) { /// &amp;lt;&amp;lt; previousstate never changes from HIGH - this will NEVER run!&#xA;            digitalWrite(solenoidpin, HIGH);&#xA;        }&#xA;&#xA;        if (buttonstate == LOW &amp;amp;&amp;amp; previousstate == HIGH &amp;amp;&amp;amp; (counter1 % 2) == 0) {  /// &amp;lt;&amp;lt; You have already checked this state above with a different outcome.  WHY?!?!&#xA;            digitalWrite(solenoidpin, LOW);&#xA;        }&#xA;&#xA;        if ((counter1 % 2) == 0) {&#xA;            for rpm calcs /// &amp;lt;&amp;lt; This isn't even C!!!&#xA;            finish = start;&#xA;&#xA;        start = millis();&#xA;        }&#xA;&#xA;        if ((counter1 % 6) == 0) {&#xA;            mydisplay.setCursor(0, 0);&#xA;            mydisplay.print(&quot; RPM &quot;);&#xA;            mydisplay.print(RPM);&#xA;            mydisplay.setCursor(0, 1);&#xA;            mydisplay.print(&quot; Solenoid Motor &quot;);&#xA;        }&#xA;&#xA;        void ISR1(); /// &amp;lt;&amp;lt; This is a function prototype, not a function definition.&#xA;        buttonstate = LOW;       /// &amp;lt;&amp;lt; I guess these should be inside&#xA;        counter1 = counter1 + 1; /// &amp;lt;&amp;lt; a function called ISR1() but that&#xA;        previousstate = HIGH;    /// &amp;lt;&amp;lt; function hasn't been written.&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're trying to mess around writing low-level interrupt routines without having a clue how to work with low level interrupt routines.  Go back and read the manuals on how to do external interrupts with Arduino.  It's very very simple.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are things about your program that just make me thing &quot;What?!?!&quot; and things that are just plain missing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-05T18:35:17.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13173" PostTypeId="2" ParentId="13165" CreationDate="2015-07-05T18:39:48.050" Score="7" Body="&lt;p&gt;There are functions which can get you the registers and bit numbers from a pin number built into the Arduino API.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t bit = digitalPinToBitMask(pin);&#xA;uint8_t port = digitalPinToPort(pin);&#xA;volatile uint8_t *reg = portModeRegister(port);&#xA;&#xA;if (*reg &amp;amp; bit) {&#xA;    // It's an output&#xA;} else {&#xA;    // It's an input&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-05T18:39:48.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13176" PostTypeId="2" ParentId="13167" CreationDate="2015-07-05T21:57:29.463" Score="8" Body="&lt;p&gt;The code below achieves what you are asking:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;const byte AWAKE_LED = 8;&#xA;const byte GREEN_LED = 9;&#xA;const unsigned long WAIT_TIME = 5000;&#xA;&#xA;ISR (PCINT2_vect)&#xA;{&#xA;  // handle pin change interrupt for D0 to D7 here&#xA;}  // end of PCINT2_vect&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode (GREEN_LED, OUTPUT);&#xA;  pinMode (AWAKE_LED, OUTPUT);&#xA;  digitalWrite (AWAKE_LED, HIGH);&#xA;  Serial.begin (9600);&#xA;} // end of setup&#xA;&#xA;unsigned long lastSleep;&#xA;&#xA;void loop() &#xA;{&#xA;  if (millis () - lastSleep &amp;gt;= WAIT_TIME)&#xA;  {&#xA;    lastSleep = millis ();&#xA;&#xA;    noInterrupts ();&#xA;&#xA;    byte old_ADCSRA = ADCSRA;&#xA;    // disable ADC&#xA;    ADCSRA = 0;  &#xA;    // pin change interrupt (example for D0)&#xA;    PCMSK2 |= bit (PCINT16); // want pin 0&#xA;    PCIFR  |= bit (PCIF2);   // clear any outstanding interrupts&#xA;    PCICR  |= bit (PCIE2);   // enable pin change interrupts for D0 to D7&#xA;&#xA;    set_sleep_mode (SLEEP_MODE_PWR_DOWN);  &#xA;    power_adc_disable();&#xA;    power_spi_disable();&#xA;    power_timer0_disable();&#xA;    power_timer1_disable();&#xA;    power_timer2_disable();&#xA;    power_twi_disable();&#xA;&#xA;    UCSR0B &amp;amp;= ~bit (RXEN0);  // disable receiver&#xA;    UCSR0B &amp;amp;= ~bit (TXEN0);  // disable transmitter&#xA;&#xA;    sleep_enable();&#xA;    digitalWrite (AWAKE_LED, LOW);&#xA;    interrupts ();&#xA;    sleep_cpu ();      &#xA;    digitalWrite (AWAKE_LED, HIGH);&#xA;    sleep_disable();&#xA;    power_all_enable();&#xA;&#xA;    ADCSRA = old_ADCSRA;&#xA;    PCICR  &amp;amp;= ~bit (PCIE2);   // disable pin change interrupts for D0 to D7&#xA;    UCSR0B |= bit (RXEN0);  // enable receiver&#xA;    UCSR0B |= bit (TXEN0);  // enable transmitter&#xA;  }  // end of time to sleep&#xA;&#xA;  if (Serial.available () &amp;gt; 0)&#xA;  {&#xA;    byte flashes = Serial.read () - '0';&#xA;    if (flashes &amp;gt; 0 &amp;amp;&amp;amp; flashes &amp;lt; 10)&#xA;      {&#xA;      // flash LED x times &#xA;      for (byte i = 0; i &amp;lt; flashes; i++)&#xA;        {&#xA;        digitalWrite (GREEN_LED, HIGH);&#xA;        delay (200);  &#xA;        digitalWrite (GREEN_LED, LOW);&#xA;        delay (200);  &#xA;        }&#xA;      }        &#xA;  }  // end of if&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used a pin-change interrupt on the Rx pin to notice when serial data arrives. In this test the board goes to sleep if there is no activity after 5 seconds (the &quot;awake&quot; LED goes out). Incoming serial data causes the pin-change interrupt to wake the board. It looks for a number and flashes the &quot;green&quot; LED that number of times.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Measured current&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Running at 5 V, I measured about 120 nA of current when asleep (0.120 µA). &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Awakening message&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A problem however is that the first arriving byte is lost due to the fact that the serial hardware expects a falling level on Rx (the start bit) which has already arrived by the time it is fully awake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest (as in geometrikal's answer) that you first send an &quot;awake&quot; message, and then &lt;strong&gt;pause&lt;/strong&gt; for a short time. The pause is to make sure the hardware does not interpret the next byte as part of the awake message. After that it should work fine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since this uses a pin-change interrupt no other hardware is required.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Amended version using SoftwareSerial&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The version below successfully processes the first byte received on serial. It  does this by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Using SoftwareSerial which uses pin-change interrupts. The interrupt which is caused by the start bit of the first serial byte also wakes the processor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Setting the fuses so that we use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Internal RC oscillator&lt;/li&gt;&#xA;&lt;li&gt;BOD disabled&lt;/li&gt;&#xA;&lt;li&gt;The fuses were: Low: 0xD2, High: 0xDF, Extended: 0xFF&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Inspired by FarO in a comment, this lets the processor wake up in 6 clock cycles (750 ns). At 9600 baud each bit time is 1/9600 (104.2 µs) so the extra delay is insignificant.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte AWAKE_LED = 8;&#xA;const byte GREEN_LED = 9;&#xA;const unsigned long WAIT_TIME = 5000;&#xA;const byte RX_PIN = 4;&#xA;const byte TX_PIN = 5;&#xA;&#xA;SoftwareSerial mySerial(RX_PIN, TX_PIN); // RX, TX&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode (GREEN_LED, OUTPUT);&#xA;  pinMode (AWAKE_LED, OUTPUT);&#xA;  digitalWrite (AWAKE_LED, HIGH);&#xA;  mySerial.begin(9600);&#xA;} // end of setup&#xA;&#xA;unsigned long lastSleep;&#xA;&#xA;void loop() &#xA;{&#xA;  if (millis () - lastSleep &amp;gt;= WAIT_TIME)&#xA;  {&#xA;    lastSleep = millis ();&#xA;&#xA;    noInterrupts ();&#xA;&#xA;    byte old_ADCSRA = ADCSRA;&#xA;    // disable ADC&#xA;    ADCSRA = 0;  &#xA;&#xA;    set_sleep_mode (SLEEP_MODE_PWR_DOWN);  &#xA;    power_adc_disable();&#xA;    power_spi_disable();&#xA;    power_timer0_disable();&#xA;    power_timer1_disable();&#xA;    power_timer2_disable();&#xA;    power_twi_disable();&#xA;&#xA;    sleep_enable();&#xA;    digitalWrite (AWAKE_LED, LOW);&#xA;    interrupts ();&#xA;    sleep_cpu ();      &#xA;    digitalWrite (AWAKE_LED, HIGH);&#xA;    sleep_disable();&#xA;    power_all_enable();&#xA;&#xA;    ADCSRA = old_ADCSRA;&#xA;  }  // end of time to sleep&#xA;&#xA;  if (mySerial.available () &amp;gt; 0)&#xA;  {&#xA;    byte flashes = mySerial.read () - '0';&#xA;    if (flashes &amp;gt; 0 &amp;amp;&amp;amp; flashes &amp;lt; 10)&#xA;      {&#xA;      // flash LED x times &#xA;      for (byte i = 0; i &amp;lt; flashes; i++)&#xA;        {&#xA;        digitalWrite (GREEN_LED, HIGH);&#xA;        delay (200);  &#xA;        digitalWrite (GREEN_LED, LOW);&#xA;        delay (200);  &#xA;        }&#xA;      }        &#xA;  }  // end of if&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Power consumption when asleep was measured as 260 nA (0.260 µA) so that is very low consumption when not needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that with the fuses set like that, the processor runs at 8 MHz. Thus you need to tell the IDE about that (eg. select &quot;Lilypad&quot; as the board type). That way the delays and SoftwareSerial will work at the correct speed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2017-11-23T01:18:47.760" LastActivityDate="2017-11-23T01:18:47.760" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13177" PostTypeId="2" ParentId="3855" CreationDate="2015-07-05T22:07:33.743" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a page about saving power with the Atmega328P chips (similar techniques apply to other chips): &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I made a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow&quot;&gt;Temperature and humidity sensor - battery powered&lt;/a&gt; - this runs from 3 x AA batteries, and writes to an SD card. From memory it ran for 2 years before I needed to replace the batteries.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another project flashes an LED every second: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12769&quot; rel=&quot;nofollow&quot;&gt;Simple project - torch-locator&lt;/a&gt;. I made something similar a couple of years ago that is still running from the same button battery.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As a rule-of-thumb, you should be able to achieve 100 nA of current consumption, and still be &quot;alive&quot; and able to respond to external events, like button-presses (eg. a calculator or TV remote). To wake periodically (without an external event) takes more current, because you need the watch-dog timer to be active, but that can still be as low as 6 µA.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-05T22:07:33.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13178" PostTypeId="1" AcceptedAnswerId="13182" CreationDate="2015-07-06T00:41:22.507" Score="21" ViewCount="8345" Body="&lt;p&gt;I have no previous experience with C++ or C, but know how to program C# and am learning Arduino. I just want to organize my sketches and am quite comfortable with the Arduino language even with its limitations, but I really would like to have an object-oriented approach to my Arduino programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have seen that you can have the following ways (not exhaustive list) to organize code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A single .ino file;&lt;/li&gt;&#xA;&lt;li&gt;Multiple .ino files in the same folder (what the IDE calls and displays like &quot;tabs&quot;);&lt;/li&gt;&#xA;&lt;li&gt;An .ino file with an included .h and .cpp file in the same folder;&lt;/li&gt;&#xA;&lt;li&gt;Same as above, but the files are an installed library inside Arduino program folder.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have also heard of the following ways, but have not got them working yet:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Declaring a C++-style class in the same, single .ino file (have heard of, but never seen working - is that even possible?);&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;[preferred approach]&lt;/strong&gt; Including a .cpp file where a class is declared, but &lt;em&gt;without&lt;/em&gt; using a .h file (would like this approach, should that work?);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that I only want to use classes so that code is more partitioned, my applications should be very simple, only involving buttons, leds and buzzers mostly.&lt;/p&gt;&#xA;" OwnerUserId="8044" LastEditorDisplayName="user31481" LastEditDate="2017-11-08T09:23:06.470" LastActivityDate="2017-11-08T09:23:06.470" Title="Classes and objects: how many and which file types do I actually need to use them?" Tags="|programming|c++|class|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13179" PostTypeId="1" CreationDate="2015-07-06T01:21:36.647" Score="0" ViewCount="1193" Body="&lt;p&gt;I'm trying to drive a &lt;strong&gt;12v dc motor&lt;/strong&gt; using three push buttons, one to turn clockwise, the other counter-clockwise and the other to stop the motor completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the code below is not working, apparently it feels like I'm doing something wrong in the code on the connect buttons on the analog part of the engine shield L293D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is powered by a &lt;strong&gt;9v&lt;/strong&gt; battery and &lt;strong&gt;motor shield **L293D&lt;/strong&gt; with an external power.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AFMotor.h&amp;gt;&#xA;&#xA;    AF_DCMotor motor(1);&#xA;&#xA;    int val; &#xA;&#xA;    #define btnleft A0 &#xA;    #define btncenter A1 &#xA;    #define btnright A2 &#xA;&#xA;&#xA;    void setup() &#xA;    { &#xA;      pinMode(btnleft, INPUT);      &#xA;      analogWrite(btnleft, HIGH);  &#xA;      pinMode(btncenter, INPUT);&#xA;      analogWrite(btncenter, HIGH);&#xA;      pinMode(btnright, INPUT);&#xA;      analogWrite(btnright, HIGH);&#xA;    } &#xA;&#xA;    void loop() &#xA;    { &#xA;     val=digitalRead(btnleft);  &#xA;       if(val!=1) &#xA;        {&#xA;        Serial.print(&quot;LEFT: &quot;);&#xA;        motor.setSpeed(255); &#xA;        motor.run(FORWARD); &#xA;        delay(3800); &#xA;        }&#xA;&#xA;     val=digitalRead(btncenter);&#xA;       if(val!=1)&#xA;        {&#xA;        Serial.print(&quot;CENTER&quot;); &#xA;        motor.setSpeed(255); &#xA;        motor.run(BACKWARD);&#xA;        delay(3800); &#xA;        }&#xA;&#xA;     val=digitalRead(btnright);&#xA;       if(val!=1)&#xA;        {&#xA;        Serial.print(&quot;RIGHT&quot;); &#xA;        motor.run(RELEASE);&#xA;        delay(3000);    &#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11015" LastActivityDate="2021-01-21T09:04:35.413" Title="Triggering the push button on the analog input of the L293D motorshield" Tags="|arduino-motor-shield|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13180" PostTypeId="2" ParentId="13178" CreationDate="2015-07-06T01:50:50.120" Score="6" Body="&lt;p&gt;My advice is to stick to the typical C++ way of doing things: separate interface and implementation into .h and .cpp files for each class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few catches:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you need at least one .ino file - I use a symlink to the .cpp file where I instantiate the classes.&lt;/li&gt;&#xA;&lt;li&gt;you must provide the callbacks that the Arduino environment expects (setu, loop, etc.)&lt;/li&gt;&#xA;&lt;li&gt;in some cases you will be surprised by the non-standard weird things that differentiate the Arduino IDE from a normal one, like automatic inclusion of certain libraries, but not others.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or, you could ditch the Arduino IDE and try with &lt;a href=&quot;http://www.instructables.com/id/How-to-get-started-with-Eclipse-and-AVR/&quot;&gt;Eclipse&lt;/a&gt;.&#xA;As i mentioned, some of the things that are supposed to help beginners, tend to come in the way of more experienced developers.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-06T01:50:50.120" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13182" PostTypeId="2" ParentId="13178" CreationDate="2015-07-06T05:19:03.003" Score="34" Body="&#xA;&#xA;&lt;h2&gt;How the IDE organizes things&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First thing, this is how the IDE organizes your &quot;sketch&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The main &lt;code&gt;.ino&lt;/code&gt; file is the one of the same name as the folder it is in. So, for &lt;code&gt;foobar.ino&lt;/code&gt; in &lt;code&gt;foobar&lt;/code&gt; folder - the main file is foobar.ino.&lt;/li&gt;&#xA;&lt;li&gt;Any other &lt;code&gt;.ino&lt;/code&gt; files in that folder are concatenated together, in alphabetic order, at the end of the main file (regardless of where the main file is, alphabetically).&lt;/li&gt;&#xA;&lt;li&gt;This concatenated file becomes a &lt;code&gt;.cpp&lt;/code&gt; file (eg. &lt;code&gt;foobar.cpp&lt;/code&gt;) - it is placed in a temporary compilation folder.&lt;/li&gt;&#xA;&lt;li&gt;The preprocessor &quot;helpfully&quot; generates function prototypes for functions it finds in that file.&lt;/li&gt;&#xA;&lt;li&gt;The main file is scanned for &lt;code&gt;#include &amp;lt;libraryname&amp;gt;&lt;/code&gt; directives. This triggers the IDE to also copy all relevant files from each (mentioned) library into the temporary folder, and generate instructions to compile them.&lt;/li&gt;&#xA;&lt;li&gt;Any &lt;code&gt;.c&lt;/code&gt;, &lt;code&gt;.cpp&lt;/code&gt; or &lt;code&gt;.asm&lt;/code&gt; files in the sketch folder are added to the build process as separate compilation units (that is, they are compiled in the usual way as separate files)&lt;/li&gt;&#xA;&lt;li&gt;Any &lt;code&gt;.h&lt;/code&gt; files are also copied into the temporary compilation folder, so they can be referred to by your .c or .cpp files.&lt;/li&gt;&#xA;&lt;li&gt;The compiler adds into the build process standard files (like &lt;code&gt;main.cpp&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;The build process then compiles all the above files into object files.&lt;/li&gt;&#xA;&lt;li&gt;If the compilation phase succeeds they are linked together along with the AVR standard libraries (eg. giving you &lt;code&gt;strcpy&lt;/code&gt; etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A side-effect of all this is that you can consider the main sketch (the .ino files) to be C++ to all intents and purposes. The function prototype generation however can lead to obscure error messages if you are not careful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Avoiding the pre-processor quirks&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The simplest way of avoiding these idiosyncrasies is to leave your main sketch blank (and not use any other &lt;code&gt;.ino&lt;/code&gt; files). Then make another tab (a &lt;code&gt;.cpp&lt;/code&gt; file) and put your stuff into it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;// put your sketch here ...&#xA;&#xA;void setup ()&#xA;  {&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you need to include &lt;code&gt;Arduino.h&lt;/code&gt;. The IDE does that automatically for the main sketch, but for other compilation units, you have to do it. Otherwise it won't know about things like String, the hardware registers, etc.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Avoiding the setup/main paradigm&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You don't have to run with the setup/loop concept. For example, your .cpp file can be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int main ()&#xA;  {&#xA;  init ();  // initialize timers&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Hello, world&quot;);&#xA;  Serial.flush (); // let serial printing finish&#xA;  }  // end of main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Force library inclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you run with the &quot;empty sketch&quot; concept you still need to include libraries used elsewhere in the project, for example in your main &lt;code&gt;.ino&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because the IDE only scans the main file for library usage. Effectively you can consider the main file as a &quot;project&quot; file which nominates which external libraries are in use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Naming issues&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't name your main sketch &quot;main.cpp&quot; - the IDE includes its own main.cpp so you will have a duplicate if you do that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't name your .cpp file with the same name as your main .ino file. Since the .ino file effectively becomes a .cpp file this also would give you a name clash.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Declaring a C++-style class in the same, single .ino file (have heard of, but never seen working - is that even possible?);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, this compiles OK:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class foo {&#xA;  public:&#xA;};&#xA;&#xA;foo bar;&#xA;&#xA;void setup () { }&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However you are probably best off to follow normal practice: Put your declarations in &lt;code&gt;.h&lt;/code&gt; files and your definitions (implementations) in &lt;code&gt;.cpp&lt;/code&gt; (or &lt;code&gt;.c&lt;/code&gt;) files.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Why &quot;probably&quot;?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As my example shows you &lt;em&gt;can&lt;/em&gt; put everything together in one file. For larger projects it is better to be more organized. Eventually you get to the stage in a medium to large-size project where you want to separate out things into &quot;black boxes&quot; - that is, a class that does one thing, does it well, is tested, and is self-contained (as far as possible).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this class is then used in multiple other files in your project this is where the separate &lt;code&gt;.h&lt;/code&gt; and &lt;code&gt;.cpp&lt;/code&gt; files come into play. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;.h&lt;/code&gt; file &lt;em&gt;declares&lt;/em&gt; the class - that is, it provides enough detail for other files to know what it does, what functions it has, and how they are called.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;.cpp&lt;/code&gt; file &lt;em&gt;defines&lt;/em&gt; (implements) the class - that is, it actually provides the functions, and static class members, that make the class do its thing. Since you only want to implement it once, this is in a separate file.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;.h&lt;/code&gt; file is what gets included into other files. The &lt;code&gt;.cpp&lt;/code&gt; file is compiled once by the IDE to implement the class functions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Libraries&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you follow this paradigm, then you are ready to move the entire class (the &lt;code&gt;.h&lt;/code&gt; and &lt;code&gt;.cpp&lt;/code&gt; files) into a library very easily. Then it can be shared between multiple projects. All that is required is to make a folder (eg. &lt;code&gt;myLibrary&lt;/code&gt;) and put the &lt;code&gt;.h&lt;/code&gt; and &lt;code&gt;.cpp&lt;/code&gt; files into it (eg. &lt;code&gt;myLibrary.h&lt;/code&gt; and &lt;code&gt;myLibrary.cpp&lt;/code&gt;) and then put this folder inside your &lt;code&gt;libraries&lt;/code&gt; folder in the folder where your sketches are kept (the sketchbook folder). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restart the IDE and it now knows about this library. This is really trivially simple, and now you can share this library over multiple projects. I do this a lot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A bit more detail &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-06T22:03:35.283" LastActivityDate="2015-07-06T22:03:35.283" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="13183" PostTypeId="2" ParentId="13170" CreationDate="2015-07-06T05:39:50.687" Score="0" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My question now is how to parse the C string I2CinBuffer to obtain 2 values separated by a comma i.e. &quot;6, 100&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int parseit (char * p, int * results, const int maxSize)&#xA;{&#xA;  int count = 0;  &#xA;  char *str = strtok (p, &quot;,&quot;);   // separate at each &quot;,&quot; delimiter&#xA;  while (str != NULL &amp;amp;&amp;amp; count &amp;lt; maxSize)   &#xA;    { &#xA;    results [count++] = atoi (str);      // Add to array  &#xA;    str = strtok(NULL, &quot;,&quot;);&#xA;    }  // end of while&#xA;  return count;&#xA;}  // end of parseit&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  const int MAX_INTEGERS = 5;&#xA;  int inParse [MAX_INTEGERS];&#xA;  char  I2CinBuffer [50];&#xA;&#xA;  strcpy (I2CinBuffer, &quot;6,100&quot;); &#xA;  int found = parseit (I2CinBuffer, inParse, MAX_INTEGERS);&#xA;  for (int i = 0; i &amp;lt; found; i++)&#xA;    {&#xA;    Serial.print (i);&#xA;    Serial.print (&quot; = &quot;);&#xA;    Serial.println (inParse [i]);&#xA;    }  // end of for&#xA;&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;  // rest of code here&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results from running it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;0 = 6&#xA;1 = 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-06T05:39:50.687" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13184" PostTypeId="2" ParentId="5328" CreationDate="2015-07-06T06:28:15.350" Score="0" Body="&lt;p&gt;You should try to post a minimal piece of code that reproduces your problem. From what you posted I assembled this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef unsigned char addr_t;&#xA;&#xA;#define NUM_CHILDS  0x02&#xA;#define CHILD1_I2C_ADDR         0x10&#xA;#define CHILD2_I2C_ADDR         0x02&#xA;&#xA;addr_t childAddr[NUM_CHILDS] = { CHILD1_I2C_ADDR, CHILD2_I2C_ADDR };&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println(childAddr[0]);&#xA;  Serial.println(childAddr[1]); &#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;16&#xA;2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Clearly the problem isn't where you think it is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, in your file &lt;code&gt;Project.h&lt;/code&gt; you have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Project.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is it including itself?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void commRxISR(int count){&#xA;    /*&#xA;        ISR for the dats received on the I2C bus&#xA;    */&#xA;    Serial.write(&quot;Inside serial receive ISR\n&quot;);&#xA;    while (1);&#xA;    while (0 &amp;lt; Wire.available()){&#xA;        MyNode.commChild.commWriteInBuffer(Wire.read());    // Project specific implementation&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The infinite loop in the ISR is interesting. Also don't do Serial prints inside an ISR. They can (almost certainly will) hang the system.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-06T06:44:05.580" LastActivityDate="2015-07-06T06:44:05.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13185" PostTypeId="1" CreationDate="2015-07-06T06:31:08.353" Score="2" ViewCount="1254" Body="&lt;p&gt;I have bought a HC-05 bluetooth module for Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My requirement is to read data transmitted from iBeacon, is it possible using HC-05 or I have to shift to HM-10? &lt;/p&gt;&#xA;" OwnerUserId="11018" LastEditorUserId="6936" LastEditDate="2015-11-13T18:35:33.747" LastActivityDate="2015-11-13T18:35:33.747" Title="Reading iBeacon Data using HC-05 bluetooth module" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13186" PostTypeId="1" CreationDate="2015-07-06T06:46:15.020" Score="0" ViewCount="1968" Body="&lt;p&gt;I am working on an esp8266 and I am connecting it with Arduino Uno. I have programmed the Arduino but when I write AT command on the serial monitor it doesn't show anything.The connections which i have made are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tx uno - rx esp&#xA;rx uno - tx esp&#xA;gnd uno -gnd esp&#xA;vcc and ch_pd - 3.3v supply&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using an external supply and not the 3.3v from the Arduino.&#xA;I need help with this.&lt;/p&gt;&#xA;" OwnerUserId="11019" LastEditorUserId="37622" LastEditDate="2018-07-19T14:57:13.610" LastActivityDate="2018-07-19T14:57:13.610" Title="esp8266 not getting programmed" Tags="|esp8266|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="13187" PostTypeId="1" CreationDate="2015-07-06T07:17:57.723" Score="0" ViewCount="445" Body="&lt;p&gt;I'm trying to connect an Arduino Micro to MPU-9150 using the  MPU6050_DMP6 example.&#xA;It runs for couple of seconds then the board Hangs, I sometimes see the &quot;FIFO overflow&quot; message.&#xA;The same code runs well when i connect the MPU-9150 to Arduino UNO and Arduino Duemilanove.&#xA;I tried to lower the serial baud rate but no success with that. I even tried connecting an external 12V to the Micro but it's the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;should I lower the i2c clock (not sure how to do it)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;another interesting thing i have noticed is that with the Duemilanove i can use a longer line for the i2c (5m of cat5e), with the Uno it only works with less then 2m cables, can anyone tell why?&lt;/p&gt;&#xA;" OwnerUserId="11020" LastActivityDate="2016-02-01T19:33:52.353" Title="Arduino Micro and MPU-9150" Tags="|arduino-micro|mpu6050|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13188" PostTypeId="1" CreationDate="2015-07-06T08:07:00.550" Score="3" ViewCount="1049" Body="&lt;p&gt;I'm using an Arduino Uno, 1.0.5 r2 version of the IDE with and ultrasonic HC-SR04 sensor for measuring a tank water level. I want to send the data obtained over internet using the official arduino GSM shield sending them on the &lt;a href=&quot;https://plot.ly/&quot; rel=&quot;nofollow noreferrer&quot;&gt;plot.ly servers&lt;/a&gt; with their API using a GPRS connection. When I'm doing all the tasks I get inaccurate values as these:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1qYZJ.jpg&quot; alt=&quot;error&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the only ping sensor without the GSM shield all works well getting good data. The same using a potentiometer + GSM shield + plot.ly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function I use for getting the distance is:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;long distCalc() {&#xA;  long durata, distanza;&#xA;  digitalWrite(TRIG_PIN, LOW);  // TRIG_PIN = pin 12&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(TRIG_PIN, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(TRIG_PIN, LOW);&#xA;  durata = pulseIn(ECHO_PIN, HIGH);  //ECHO_PIN = pin 11&#xA;  distanza = durata / 29.1 / 2 ;&#xA;  return distanza;    // in uscita la distanza in [cm]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the one for posting the data on plot.ly servers is (loop function):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  long distanza;&#xA;  distanza = distCalc();  //fase di calcolo distanza&#xA;  Serial.print(distanza);&#xA;  Serial.println(&quot;cm&quot;);&#xA;  graph.plot(millis(), int(distanza), tokens[0]);  //fase di invio su plot.ly&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could it be a software serial interrupt that hangs the pulseIn measurement?&#xA;How could I avoid this? &lt;/p&gt;&#xA;" OwnerUserId="11021" LastEditorUserId="37523" LastEditDate="2019-05-15T19:52:03.167" LastActivityDate="2019-05-15T19:52:03.167" Title="(Arduino + official GSM shield + ultrasonic HC-SR04 sensor) inaccurate measuring" Tags="|shields|gsm|hc-sr04|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13189" PostTypeId="1" CreationDate="2015-07-06T08:53:55.647" Score="1" ViewCount="3258" Body="&lt;p&gt;I'm using a standard 38kHz receiver with &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;Arduino-IRremote library&lt;/a&gt; and it works fine for a while but then it stops working. The loop function is running time after time as expected but at some point the library decode function starts returning false until I reset the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This example code works for me with any arduino nano or bare atmega328p at 8Mhz but for both of them it freezes after some receptions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is the library example itself:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    Serial.println(results.value, HEX);&#xA;    irrecv.resume(); // Receive the next value&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some times this happens fast and other times it is after 20 or more receptions.&#xA;I only added a led blink later to test if the board is frozen or is only the infrared that stops receiving and it was the second case.&lt;/p&gt;&#xA;" OwnerUserId="11023" LastEditorUserId="2944" LastEditDate="2015-07-06T11:34:45.930" LastActivityDate="2021-03-05T19:59:26.423" Title="Arduino IRremote stops working" Tags="|arduino-uno|library|arduino-nano|ir|remote-control|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="13190" PostTypeId="1" AcceptedAnswerId="13192" CreationDate="2015-07-06T10:00:57.103" Score="0" ViewCount="52" Body="&lt;p&gt;I'm sure this is a very basic coding mistake...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm picking up a reading from A0. If the value is 0, I want the value of the serial to be written to the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want it only to write to the Serial Monitor for the first time that the value falls to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand why, when the value for SensorValue = 0, the if is not performed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean must_print = true;&#xA;int sensorValue = 0;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;// initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  // read the input on analog pin 0:&#xA;  sensorValue = analogRead(A0);&#xA;&#xA;  if (sensorValue = 0) {&#xA;&#xA;     if (must_print = true)&#xA;    {&#xA;     must_print = false;&#xA;     Serial.println(sensorValue);&#xA;    }&#xA;  else&#xA;    must_print = true&#xA;  }&#xA;&#xA;&#xA;   delay(500);        // delay in between reads for stability&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11025" LastActivityDate="2015-07-06T10:10:42.600" Title="0 value integer does not enter If" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13191" PostTypeId="2" ParentId="13187" CreationDate="2015-07-06T10:09:58.847" Score="1" Body="&lt;p&gt;I have seen a lot of variations with the 6050.  Code I know works fine for me, will not run on someone else's system.  Code fixes suggested by others has zero effect for me.  My understanding is the DMP code is a reverse engineered sample that the manufacturer will not release actual documentation on. So it is a gamble to begin with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, I usually reset the FIFO buffer after every read.  I get an occasional over flow (1-2 per minute) with a lot of other code running at the same time, and NOT using interrupts.  The resulting AHRS data is reliable and solid (UNO) at default rate (100hz).  Ive lowered the AHRS rate (you have to modify data tables in a .H file) and I get the same error rate, it seems to have no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as line lengths go, it is I2C. It is some magical combination of wire size and length, internal pull up resistors plus external ones.  I have usually heard people have success adding some pull-up resistors  I2C is a ground sink signal - so it doesn't care if it is 5 volts or 3.3 - only that everything on the bus be the same.  Obviously you will do better at 5V on a longer line vs 3.3V.  Some will argue the pull ups need to be at termination, some say it doesn't matter. I don't know anything other than the spec is very hard to understand and I have not had problems, especially the kind that require some of the elaborate schemes some people come up with (replacing caps and resistors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, 2 meters would seem to be pushing an Integrated circuit to Integrated circuit spec beyond what it was intended for, communication within a board. You might get it to work, but you also might rethink it.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorDisplayName="user6569" LastEditDate="2015-07-06T10:15:21.420" LastActivityDate="2015-07-06T10:15:21.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13192" PostTypeId="2" ParentId="13190" CreationDate="2015-07-06T10:10:42.600" Score="1" Body="&lt;pre&gt;&lt;code&gt;  if (sensorValue = 0) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That assigns zero to sensorValue, which then tests false. You want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (sensorValue == 0) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-06T10:10:42.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13193" PostTypeId="1" CreationDate="2015-07-06T10:32:25.040" Score="0" ViewCount="2395" Body="&lt;p&gt;I have a DC motor which is rated at 11 200 RPM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to count the actual RPM (it seems to be maybe 1500 RPM from what I can tell manually.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought a Photo Interrupter, and have connected it to pin A0. When the beam of the Photo Interrupter is broken, the reading drops to zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All seems to work well when using a delay of 100, but as soon as I drop the delay to less than about 50, I get multiple reads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int must_print = 1;&#xA;int sensorValue = 0;&#xA;&#xA;//the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  // read the input on analog pin 0:&#xA;  sensorValue = analogRead(A0);&#xA;&#xA;  if (sensorValue &amp;gt; 0) &#xA;    {&#xA;      if (must_print == 1)&#xA;      {&#xA;        must_print = 2;&#xA;        Serial.println(sensorValue);&#xA;      }&#xA;    }&#xA;&#xA;  if (sensorValue == 0) {&#xA;    must_print = 1;&#xA;  }&#xA;&#xA;  delay(100);        // delay in between reads for stability&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At delay(100) the Serial Monitor looks like this for a single interrupt of 10 seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;354&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At delay(50) the Serial Monitor looks like this for a single interrupt of 10 seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;298&#xA;312&#xA;328&#xA;336&#xA;349&#xA;360&#xA;366&#xA;371&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11025" LastActivityDate="2015-07-06T10:44:44.403" Title="Counting revolutions of a DC motor with a Photo Interrupter" Tags="|programming|motor|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13194" PostTypeId="2" ParentId="13193" CreationDate="2015-07-06T10:44:44.403" Score="3" Body="&lt;p&gt;You shouldn't use an analog pin with a photointerruptor.  The photointerruptor is a digital device.  Connect it to, preferably, an interrupt pin and use an interrupt to count your revolutions at high speed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-06T10:44:44.403" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13195" PostTypeId="2" ParentId="13185" CreationDate="2015-07-06T12:34:39.097" Score="2" Body="&lt;p&gt;The HC-05 doesn't support BLE, which is used for iBeacons.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-06T12:34:39.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13197" PostTypeId="1" CreationDate="2015-07-06T15:21:04.670" Score="0" ViewCount="74" Body="&lt;p&gt;I have a Sodaq Moja, from supporting the project on Kickstarter, and I didn't have much time until now to play with it. Unfortunately, the online documentation for the Moja has disappeared, and only the docs for the new version, the Mbili, is accessible. And nowhere can I see where to access the user switches. Which, to boot, have been reordered in the Mbili, can cut down from 3 to 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would anyone have an idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&lt;/p&gt;&#xA;" OwnerUserId="4628" LastEditorUserId="27346" LastEditDate="2018-12-12T15:11:13.490" LastActivityDate="2018-12-12T15:11:13.490" Title="Sodaq Moja — Accessing SW2/SW3 user switches" Tags="|documentation|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13198" PostTypeId="1" AcceptedAnswerId="13204" CreationDate="2015-07-06T17:11:21.450" Score="0" ViewCount="281" Body="&lt;p&gt;I'm currently designing a system for my GCSE coursework. For the coursework, I am making a bollard system, controlled by the internet / traffic lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been experimenting with an Arduino Uno and Ethernet shield, in order to fulfill the control by the internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I telnet into my Arduino, and send it the command &quot;S#UP&quot;, the red LED comes on, and stays on for 30 seconds. If I send the command again, the Arduino does not turn on the LED, unless the command was send twice, consecutively. Also, if I were to send a different command, for example &quot;S#DOWN&quot;, the LED does not even turn on, no matter how many times I send it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any ideas for my? Anything I've blatantly missed or got myself confused on?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;String authcode, newstatus, command;  &#xA;bool UP, DOWN, EMERGANCY;&#xA;long UPTime, DOWNTime, EMERGANCYTime, LastFlash;&#xA;bool NextFlash;&#xA;&#xA;byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};&#xA;&#xA;IPAddress ip(192, 168, 1, 177);&#xA;IPAddress gateway(192, 168, 1, 1);&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;&#xA;EthernetServer server(1265);&#xA;&#xA;char serverHost[] = &quot;LambdaLaptop&quot;;&#xA;EthernetClient phpClient;&#xA;&#xA;&#xA;&#xA;int R = 8;&#xA;int G = 9;&#xA;&#xA;void setup() {&#xA;  Ethernet.begin(mac, ip, gateway, subnet);&#xA;  server.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;=----------------------=&quot;);&#xA;  Serial.println(&quot;=- Traffic Management -=&quot;);&#xA;  Serial.println(&quot;=-    System Loaded   -=&quot;);&#xA;  Serial.println(&quot;=----------------------=&quot;);&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  authcode = String(&quot;4b4fec50eaa13b98934c36863293b5cf&quot;);&#xA;  LastFlash = millis();&#xA;  NextFlash = HIGH;&#xA;&#xA;  pinMode(R, OUTPUT);&#xA;  pinMode(G, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    if (client.available() &amp;gt; 0) {&#xA;      char thisChar = client.read();&#xA;      command += thisChar;&#xA;      ProcessCMD( command );&#xA;    }else{&#xA;     if(command.length() &amp;gt; 0 ){&#xA;       command = String(&quot;&quot;);&#xA;     }&#xA;    }&#xA;  }&#xA;  if( UP ){&#xA;    if( UPTime &amp;gt; millis() ){&#xA;      digitalWrite(G, HIGH);&#xA;    }else{&#xA;      UP = false;&#xA;      digitalWrite(G, LOW);&#xA;    }&#xA;  }else if( DOWN ){&#xA;    if( DOWNTime &amp;gt; millis() ){&#xA;      digitalWrite(R, HIGH);&#xA;    }else{&#xA;      DOWN = false;&#xA;      digitalWrite(R, LOW);&#xA;    }&#xA;  }else if( EMERGANCY ){&#xA;   if( EMERGANCYTime &amp;gt; millis() ){&#xA;     if( LastFlash + 100 &amp;lt; millis() ){&#xA;       digitalWrite(R, NextFlash);&#xA;       if(NextFlash == LOW){&#xA;         NextFlash = HIGH;&#xA;       }else{&#xA;         NextFlash = LOW;&#xA;       }&#xA;     }&#xA;    }else{&#xA;      EMERGANCY = false;&#xA;      NextFlash = HIGH;&#xA;      digitalWrite(R, LOW);&#xA;    }&#xA;  }  &#xA;}&#xA;&#xA;void ProcessCMD( String CMD ){&#xA;  if(CMD == &quot;S#UP&quot;){&#xA;    UP = true;   &#xA;    UPTime = millis() + 30000;&#xA;    if(CMD.length() &amp;gt; 11){&#xA;      command = String(&quot;&quot;);&#xA;    }&#xA;  }else if(CMD == &quot;S#DOWN&quot;){&#xA;    // Make the thing go DOWN.&#xA;    // GREEN LIGHT&#xA;    DOWN = true;&#xA;    DOWNTime = millis() + 30000;&#xA;    if(CMD.length() &amp;gt; 11){&#xA;      command = String(&quot;&quot;);&#xA;    }&#xA;  }else if(CMD == &quot;S#EMERGANCY&quot;){&#xA;    // Make the thing go DOWN.&#xA;    // Flash RED beacon.&#xA;    EMERGANCY = true;&#xA;    EMERGANCYTime = millis() + 15000;&#xA;    if(CMD.length() &amp;gt; 11){&#xA;      command = String(&quot;&quot;);&#xA;    }&#xA;  }else if(CMD == &quot;TEST&quot;){&#xA;    UP = true;&#xA;  }else if(CMD == &quot;TEST2&quot;){&#xA;    UPTime = millis() + 30000;&#xA;  }else{&#xA;    if(CMD.length() &amp;gt; 11){&#xA;      command = String(&quot;&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void SetStatus( String newstatus ){&#xA;  if (phpClient.connect(IPAddress(192,168,1,10), 80)) {&#xA;    phpClient.println(String(&quot;GET /setstatus.php?authcode=&quot;) + authcode + String(&quot;&amp;amp;status=&quot;) + newstatus + String(&quot; HTTP/1.1&quot;));&#xA;    phpClient.println(&quot;Host: LambdaLaptop&quot;);&#xA;    phpClient.println(&quot;User-Agent: arduino-ethernet&quot;);&#xA;    phpClient.println(&quot;Connection: close&quot;);&#xA;    phpClient.println();&#xA;    phpClient.stop();&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;Couldn't connect to the system!&quot;);&#xA;    phpClient.stop();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11032" LastActivityDate="2015-07-06T22:31:01.383" Title="Sending a double message for action to occur" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13199" PostTypeId="2" ParentId="13186" CreationDate="2015-07-06T19:19:14.283" Score="3" Body="&lt;p&gt;Be careful, you could fry your ESP like that.  You need to get the signal lines down to 3.3V, not the 5V used by the Arduino Uno.  There are many ways to do this, from voltage dividers, to transistors, or you can use a 3.3v Arduino Pro Micro.  I would also recommend starting out with just a 3.3v FTDI board, and interface that directly to the ESP to remove the Arduino and its code from the picture.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also make sure that your grounds on the external supply and the Arduino are tied together, or just power the ESP from the 3.3v out of the Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, double check your baud rate, some come shipped at 9600, some at 115200, and i'm sure that there are others out there too shipping at different baud rates.  &lt;/p&gt;&#xA;" OwnerUserId="7628" LastEditorUserId="7628" LastEditDate="2015-07-06T20:04:32.143" LastActivityDate="2015-07-06T20:04:32.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13200" PostTypeId="2" ParentId="13179" CreationDate="2015-07-06T19:21:38.953" Score="1" Body="&lt;p&gt;&lt;strike&gt;As noted in Nick Gammon's comment, &lt;code&gt;digitalWrite(btnleft, INPUT)&lt;/code&gt; (etc.) would make a lot more sense than does &lt;code&gt;analogWrite(btnleft, INPUT)&lt;/code&gt; (etc.).&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; &lt;code&gt;INPUT&lt;/code&gt; is a constant defined in &lt;code&gt;wiring.h&lt;/code&gt; (as in following extract), and is intended for use in &lt;a href=&quot;https://www.arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pinMode()&lt;/code&gt;&lt;/a&gt; calls that set an IO pin's mode to one of &lt;code&gt;INPUT&lt;/code&gt;, &lt;code&gt;OUTPUT&lt;/code&gt;, or &lt;code&gt;INPUT_PULLUP&lt;/code&gt;.  It's inept to use it in a call of either &lt;a href=&quot;https://www.arduino.cc/en/Reference/DigitalWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;digitalWrite()&lt;/code&gt;&lt;/a&gt; or &lt;code&gt;analogWrite()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define HIGH 0x1&#xA;    #define LOW  0x0    &#xA;    #define INPUT 0x0&#xA;    #define OUTPUT 0x1&#xA;    #define INPUT_PULLUP 0x2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;a href=&quot;https://www.arduino.cc/en/Reference/DigitalWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;digitalWrite&lt;/code&gt;&lt;/a&gt; to an input-mode pin leaves the pin in input-mode, while an &lt;a href=&quot;https://www.arduino.cc/en/Reference/analogWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;analogWrite&lt;/code&gt;&lt;/a&gt; to an input-mode pin changes the pin to output-mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you want a pin to be input-mode with pullup, it is simpler to use &lt;code&gt;INPUT_PULLUP&lt;/code&gt; as the mode parameter, rather than using two separate calls.  That is, instead of saying &lt;a href=&quot;https://www.arduino.cc/en/Reference/pinMode&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pinMode(pin, INPUT);&lt;/code&gt;&lt;/a&gt; followed by &lt;code&gt;digitalWrite(pin, HIGH);&lt;/code&gt;, just say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-03T18:09:06.267" LastActivityDate="2016-03-03T18:09:06.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13202" PostTypeId="2" ParentId="13198" CreationDate="2015-07-06T21:37:31.803" Score="0" Body="&lt;p&gt;I do not have and ethernet shield at this moment to test on it your code but hopefully the next observations will help to solve your issue.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I send the command again, the Arduino does not turn on the LED,&#xA;  unless the command was send twice, consecutively.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems that your string is not correctly processed, probably caused by &quot;garbage&quot; from previous received string or incomplete string. I think is from this part of the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (client.available() &amp;gt; 0) {&#xA;  char thisChar = client.read();&#xA;  command += thisChar;&#xA;  ProcessCMD( command );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are trying to append a char (one byte) to your command string; by doing this you are not getting the received string necessarily because the &quot;+=&quot; is for retrieve char by char (for example, inside a while loop). First try to print thisChar variable to ensure what are you getting and also you can print client.available() to see how many bytes you got.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, for your &lt;code&gt;ProcessCMD&lt;/code&gt; function it could be better to use pointers to handle the &lt;code&gt;command&lt;/code&gt; variable, meanwhile you must clean &lt;code&gt;command&lt;/code&gt; variable always (and not only when &lt;code&gt;CMD.lenght &amp;gt; 11&lt;/code&gt; ), i.e,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(CMD.length() &amp;gt; 11){&#xA;  command = String(&quot;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;must be at the end of the ProcessCMD function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  command = String(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you can ensure that when you set &lt;code&gt;UP=true&lt;/code&gt;, also set &lt;code&gt;DOWN=false&lt;/code&gt; and so on. I prefer the Switch-Case structure to handle commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to follow arduino examples to better understand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers.&lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-07-06T21:37:31.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13203" PostTypeId="2" ParentId="4957" CreationDate="2015-07-06T22:14:16.873" Score="2" Body="&#xA;&#xA;&lt;p&gt;This is a classic example of the IDE &quot;helping&quot; you by generating function prototypes, and not doing it very well. Example code to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class Highscore {&#xA;public:&#xA;  String name;&#xA;  int score;&#xA;  String toString() {&#xA;    return this-&amp;gt;name + &quot; - &quot; + (String)score;&#xA;  }&#xA;&#xA;  Highscore(String name, int score) {&#xA;    this-&amp;gt;name = name;&#xA;    this-&amp;gt;score = score;&#xA;  }&#xA;};&#xA;&#xA;void setup () { }&#xA;void loop () { }&#xA;&#xA;void writeHighscore(Highscore hs) &#xA;{&#xA;// do stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives the error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;sketch_jul06b:4: error: variable or field ‘writeHighscore’ declared void&#xA;sketch_jul06b:4: error: ‘Highscore’ was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you look at the output of the IDE preprocessor (you can do this by turning on verbose compilation, and finding out the name of the file it is actually compiling) you see this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#line 1 &quot;sketch_jul06b.ino&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;void setup ();&#xA;void loop ();&#xA;void writeHighscore(Highscore hs);&#xA;#line 1&#xA;class Highscore {&#xA;public:&#xA;  String name;&#xA;  int score;&#xA;  String toString() {&#xA;    return this-&amp;gt;name + &quot; - &quot; + (String)score;&#xA;  }&#xA;&#xA;  Highscore(String name, int score) {&#xA;    this-&amp;gt;name = name;&#xA;    this-&amp;gt;score = score;&#xA;  }&#xA;};&#xA;&#xA;void setup () { }&#xA;void loop () { }&#xA;&#xA;void writeHighscore(Highscore hs) &#xA;{&#xA;// do stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important part is that it put:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void writeHighscore(Highscore hs);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;before&lt;/strong&gt; where the class is declared.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can fix the error by simply generating your own function prototype like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void writeHighscore(Highscore hs);  // function prototype&#xA;void writeHighscore(Highscore hs) &#xA;{&#xA;// do stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it compiles without errors. It detects your &lt;em&gt;own&lt;/em&gt; function prototype, and therefore does not generate its own. The first few lines of the generated file are now:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#line 1 &quot;sketch_jul06b.ino&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;void setup ();&#xA;void loop ();&#xA;#line 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That troubling prototype has gone.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-06T22:14:16.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13204" PostTypeId="2" ParentId="13198" CreationDate="2015-07-06T22:31:01.383" Score="0" Body="&lt;p&gt;It would be far better to use char arrays instead of the String class (perhaps 11 bytes, if that is the largest command?).&lt;/p&gt;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&lt;p&gt;const int MAX_COMMAND = 11;&lt;/p&gt;&#xA;&lt;p&gt;char command [MAX_COMMAND];&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt; if (client.available() &amp;gt; 0) {&#xA;      char thisChar = client.read();&#xA;      command += thisChar;&#xA;      ProcessCMD( command );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You appear to be processing the command for every received byte. This means you will process &amp;quot;S&amp;quot;, &amp;quot;S#&amp;quot;, &amp;quot;S#D&amp;quot;, &amp;quot;S#DO&amp;quot; etc. You need to wait until the whole command has arrived.&lt;/p&gt;&#xA;&lt;p&gt;Then, once the command has been processed, empty out the command ready for next time.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt;void ProcessCMD( String CMD ){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also all upper-case is usually reserved for constants, not variables like CMD.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Finally, your detection of end-time by addition will fail when millis() wraps. This might not matter in a small test, but you may as well teach the right way. Instead of adding an interval, remember the start time and detect when the interval is up, eg. instead of:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if( UPTime &amp;gt; millis() ){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You would write:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;if (millis () - UPTime &amp;gt;= 30000) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where UPTime is now the &lt;em&gt;start&lt;/em&gt; of the interval (that is, you remember when the interval starts, and do the above subtraction to find the end of it).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow noreferrer&quot;&gt;Processing incoming serial data&lt;/a&gt; - the same techniques apply to Ethernet&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/millis&quot; rel=&quot;nofollow noreferrer&quot;&gt;millis() overflow ... a bad thing?&lt;/a&gt; - how to handle millis() wrap-around&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow noreferrer&quot;&gt;State machines&lt;/a&gt; - managing events happening on the fly&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-06T22:31:01.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13206" PostTypeId="2" ParentId="3634" CreationDate="2015-07-07T01:06:14.157" Score="1" Body="&lt;p&gt;If your Mega has an ICSP header for the USB chip (circled below) then you can test that chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GNn11.jpg&quot; alt=&quot;Mega2560 ICSP header&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use another Arduino (eg. a Uno) to detect the signature on that chip, as per my sketch on &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sketch to detect Atmega chip types&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need is 6 hookup wires to connect your testing board (the known good one with the sketch on it) to the ICSP header on the Mega. Note the pin orientation. I have circled the correct header pins, and pointed to pin 1. On the board pin 1, has a small white dot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are the ICSP pin names, seen from above (component side).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/fhuK4.png&quot; alt=&quot;ICSP pins&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Wire the Uno to the chip being tested as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino Uno      Target chip&#xA;&#xA;D10 (SS)            /RESET&#xA;D11 (MOSI)          MOSI&#xA;D12 (MISO)          MISO&#xA;D13 (SCK)           SCK&#xA;&#xA;Gnd                 GND&#xA;+5V                 VCC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check your wiring! If you wire things around the wrong way you can turn a good chip into a bad one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important!&lt;/strong&gt; Only attempt this process if you can see that you have an ATmega8U2 or ATmega16U2 chip on your board (see below). If you have something totally different this will not work. In that case you probably have a cheap clone board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qMNCs.jpg&quot; alt=&quot;Atmega16U2 chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using the Serial Monitor on your Uno, you should then see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jul  7 2015 at 10:47:47 with Arduino IDE 106.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x93 0x89 &#xA;Processor = ATmega8U2&#xA;Flash memory size = 8192 bytes.&#xA;LFuse = 0xEF &#xA;HFuse = 0xD9 &#xA;EFuse = 0xF4 &#xA;Lock byte = 0xFF &#xA;Clock calibration = 0xAB &#xA;Bootloader in use: No&#xA;EEPROM preserved through erase: No&#xA;Watchdog timer always on: No&#xA;Bootloader is 4096 bytes starting at 1000&#xA;&#xA;Bootloader:&#xA;&#xA;1000: 0x4B 0xC0 0x00 0x00 0x64 0xC0 0x00 0x00 0x62 0xC0 0x00 0x00 0x60 0xC0 0x00 0x00 &#xA;1010: 0x5E 0xC0 0x00 0x00 0x5C 0xC0 0x00 0x00 0x5A 0xC0 0x00 0x00 0x58 0xC0 0x00 0x00 &#xA;1020: 0x56 0xC0 0x00 0x00 0x54 0xC0 0x00 0x00 0x52 0xC0 0x00 0x00 0xCB 0xC4 0x00 0x00 &#xA;1030: 0x4E 0xC0 0x00 0x00 0x4C 0xC0 0x00 0x00 0x4A 0xC0 0x00 0x00 0x48 0xC0 0x00 0x00 &#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My board had a ATmega8U2 on it, yours might have a ATmega16U2. However the concept is the same. If you see something like that, the chip is (probably) good. At least it responds to programming commands. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you see something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jul  7 2015 at 10:47:47 with Arduino IDE 106.&#xA;Attempting to enter ICSP programming mode ......................................................&#xA;Failed to enter programming mode. Double-check wiring!&#xA;Programming mode off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then either you made a wiring error, or the chip is bad.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-07T01:33:23.513" LastActivityDate="2015-07-07T01:33:23.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13208" PostTypeId="2" ParentId="7950" CreationDate="2015-07-07T02:03:00.753" Score="1" Body="&lt;p&gt;I recommend you get a &lt;a href=&quot;http://www.adafruit.com/products/254&quot; rel=&quot;nofollow noreferrer&quot;&gt;MicroSD card breakout board&lt;/a&gt; from that link, or something similar. That's around $US 15.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tTysW.png&quot; alt=&quot;Micro SD breakout board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That includes the logic level converters. That particular board is for the **micro* SD card, but similar converters could no doubt be found for an SD card. Or use that one with a micro-SD card and just get an SD converter for when you plug it into the Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally have used the &lt;a href=&quot;https://github.com/greiman/SdFat&quot; rel=&quot;nofollow noreferrer&quot;&gt;SDfat library&lt;/a&gt; without any problems. However since he started rewriting it, I did have some issues. I have a &lt;a href=&quot;http://gammon.com.au/Arduino/SdFat-master.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;backup of an earlier version&lt;/a&gt; which might be useful if the live library doesn't work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might be best off not formatting the card, but leave it as factory formatted. That will probably be compatible with the Mac, and also the SDfat library.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-07T02:03:00.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13209" PostTypeId="2" ParentId="343" CreationDate="2015-07-07T02:17:10.200" Score="3" Body="&lt;p&gt;I wrote a post about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12173&quot; rel=&quot;nofollow noreferrer&quot;&gt;Why does it take 1000 bytes to blink one LED?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The brief answer is: &quot;It doesn't take 2000 bytes to blink &lt;strong&gt;two&lt;/strong&gt; LEDs!&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The longer answer is that the standard Arduino libraries (which you don't have to use if you don't want to) have some nice functionality to simplify your life. For example, you can address pins by number at runtime, where the library converts (say) pin 8 to the correct port and correct bit number. If you hard-code port access you can save that overhead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you don't use them, the standard libraries include code to count &quot;ticks&quot; so you can find out the current &quot;time&quot; (by calling &lt;code&gt;millis()&lt;/code&gt;). To do this it has to add the overhead of some interrupt service routines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you simplify down (on the Arduino Uno) to this sketch you get the program memory usage down to 178 bytes (on IDE 1.0.6):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  DDRB = bit (5);&#xA;  while (true)&#xA;    PINB = bit (5);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK, 178 bytes isn't that much, and of that the first 104 bytes are the hardware interrupt vectors (4 bytes each, for 26 vectors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So arguably, there are only 74 bytes required to blink an LED. And of that 74 bytes most are really the code generated by the compiler to initialize global memory. If you add enough code to blink two LEDs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  DDRB = bit (5);  // pin 13&#xA;  DDRB |= bit (4);  // pin 12&#xA;&#xA;  while (true)&#xA;    {&#xA;    PINB = bit (5); // pin 13&#xA;    PINB = bit (4); // pin 12&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the code size increases to 186 bytes. So therefore you could argue that it only takes &lt;code&gt;186 - 178 = 8&lt;/code&gt; bytes to blink an LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, 8 bytes to blink an LED. Sounds pretty efficient to me.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case you are tempted to try this at home, I should point out that whilst the posted code above blinks two LEDs, it does so very rapidly indeed. In fact, they blink at 2 MHz - see screenshot. Channel 1 (yellow) is pin 12, channel 2 (cyan) is pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/mPd81.png&quot; alt=&quot;Rapid blinking of pins 12 and 13&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the output pins have a square wave with a frequency of 2 MHz. Pin 13 changes state 62.5 ns (one clock cycle) before pin 12, due to the order of the toggling of the pins in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So unless you have much better eyes than mine, you won't actually see any blinking effect.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As an amusing extra, you can actually toggle &lt;strong&gt;two&lt;/strong&gt; pins in the &lt;em&gt;same&lt;/em&gt; amount of program space as toggling one pin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  DDRB = bit (4) | bit (5);  // set pins 12 and 13 to output&#xA;&#xA;  while (true)&#xA;    PINB =  bit (4) | bit (5); // toggle pins 12 and 13&#xA;  } // end of main&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That compiles into 178 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives you a higher frequency:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/VdQde.png&quot; alt=&quot;Very rapid blinking of pins 12 and 13&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we are up to 2.66 MHz.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-07T07:54:56.363" LastActivityDate="2015-07-07T07:54:56.363" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13210" PostTypeId="2" ParentId="7985" CreationDate="2015-07-07T05:26:04.710" Score="9" Body="&#xA;&lt;p&gt;I investigated this at some length a while back. On &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;noreferrer&quot;&gt;this page about putting constant data into program memory&lt;/a&gt; I obsessively tracked down every last byte of memory used in a small sketch. This was the sketch:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;quot;memdebug.h&amp;quot;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.print (F(&amp;quot;Free memory = &amp;quot;));&#xA;  Serial.println (getFreeMemory ());&#xA;  }  // end of setup&#xA;&#xA;void loop () { } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;memdebug.h came from &lt;a href=&quot;http://andybrown.me.uk/wk/2011/01/01/debugging-avr-dynamic-memory-allocation/&quot; rel=&quot;noreferrer&quot;&gt;Andy Brown - Debugging AVR dynamic memory allocation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;That particular sketch actually used even more RAM:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Free memory = 1702&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So where did the 346 bytes go? Here:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;34 bytes for the HardwareSerial instance (Serial)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;64 bytes for the Serial transmit buffer&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;64 bytes for the Serial receive buffer&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 bytes for the Serial transmit buffer head and tail pointers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 bytes for the Serial receive buffer head and tail pointers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;9 bytes for keeping track of millis / micros&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 bytes for memory allocation (__malloc_heap_start, __malloc_margin)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;128 bytes for the heap safety margin&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;6 bytes for a few nested function calls (main -&amp;gt; setup -&amp;gt; getFreeMemory)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;16 bytes for the compiler vtable for HardwareSerial&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 bytes for variables __brkval and __flp (used in memdebug)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;2 bytes pushed onto the stack in main (to save registers)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;2 bytes pushed onto the stack in setup (to save registers)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;4 bytes pushed onto the stack in getFreeMemory (to save registers)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;1 byte because the stack pointer starts at 0x8FF rather than 0x900&lt;/p&gt;&#xA;&lt;p&gt;(That's 346 bytes accounted for)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-07T05:26:04.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13213" PostTypeId="2" ParentId="12899" CreationDate="2015-07-07T05:49:15.290" Score="1" Body="&lt;p&gt;try to connect uno and nano with I2C or serial, with I2C it connected to SCA/SDL pin (analog 4/5) or with serial it connected to tx rx. Make sure you use a pull up resistor. From the main site of arduino there's a tutorial in there but forgot to set up a pull up resistor.&lt;/p&gt;&#xA;" OwnerUserId="3920" LastActivityDate="2015-07-07T05:49:15.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13214" PostTypeId="1" AcceptedAnswerId="13222" CreationDate="2015-07-07T06:24:09.590" Score="0" ViewCount="1275" Body="&lt;p&gt;nrf905\ &#xA;nRF905-All-In-One-Shield\&#xA;RadioHead-master\&#xA;RadioHead\&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None any of them are compiled with their examples without getting errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Error message:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nRF905_RX.ino:4:20: fatal error: NRF905.h: No such file or directory&#xA;compilation terminated.&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Libraries used:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.github.com/elechouse/nRF905&quot; rel=&quot;nofollow&quot;&gt;Elechouse&lt;/a&gt;&#xA;&lt;a href=&quot;http://www.github.com/PaulStoffregen/RadioHead&quot; rel=&quot;nofollow&quot;&gt;RadioHead Github&lt;/a&gt;&#xA;&lt;a href=&quot;http://www.airspayce.com/mikem/arduino/RadioHead&quot; rel=&quot;nofollow&quot;&gt;RadioHead Doxygen&lt;/a&gt;&#xA;&lt;a href=&quot;http://www.github.com/zkemble/nRF905&quot; rel=&quot;nofollow&quot;&gt;zkemble/nRF905&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11046" LastEditorUserId="4628" LastEditDate="2015-08-18T21:38:39.943" LastActivityDate="2015-08-19T13:33:32.567" Title="Arduino can't see any library I have installed for nrf905?" Tags="|library|nrf24l01+|wireless|" AnswerCount="1" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="13217" PostTypeId="1" CreationDate="2015-07-07T07:01:20.423" Score="-1" ViewCount="243" Body="&lt;p&gt;I'm currently using an Arduino Uno with the Wireless SD shield with an XBEE attached so I can wirelessly send voltages from sensors to a computer. This works great but I am limited to 5 analog inputs. I am thinking of using a Mega but the Wireless SD Shield is the same for both models. Are there any shields/techniques were  I can wirelessly transmit up to 15 analog inputs to a PC using XBEE or otherwise,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AH&lt;/p&gt;&#xA;" OwnerUserId="10924" LastActivityDate="2016-03-03T09:57:51.077" Title="Arduino Mega XBee Limited inputs" Tags="|arduino-mega|xbee|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13218" PostTypeId="2" ParentId="13217" CreationDate="2015-07-07T07:14:11.123" Score="0" Body="&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC4051 multiplexer / demultiplexer&lt;/a&gt;. That describes how you can use a multiplexer chip to multiplex analog inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 74HC4051 multiplexes 8 inputs into one, and the 74HC4067 multiplexes 16 inputs into one. Thus you would only use one analog input, plus 3 or 4 pins to tell the chip which input you want at a particular moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general way a multiplexer works is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/w8dRV.png&quot; alt=&quot;Multiplexer example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By outputting a binary pattern to the A/B/C pins you select which input you want active at a particular moment. That is then copied to the output pin (pin 3 in this case). You would connect that to your analog port on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code would rotate between each of the 8 pins (or 16 pins with the bigger chip), and then do an analogRead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example wiring&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UFNL4.png&quot; alt=&quot;Connect 4051 chip to Arduino Uno&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example code&lt;/h2&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Example of using the 74HC4051 multiplexer/demultiplexer&#xA;&#xA;// Author: Nick Gammon&#xA;// Date:   14 March 2013&#xA;&#xA;const byte sensor = A0;  // where the multiplexer in/out port is connected&#xA;&#xA;const byte addressA = 5; // the multiplexer address select lines (A/B/C)&#xA;const byte addressB = 6;&#xA;const byte addressC = 7;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Starting multiplexer test ...&quot;);&#xA;  pinMode (addressA, OUTPUT); &#xA;  pinMode (addressB, OUTPUT); &#xA;  pinMode (addressC, OUTPUT); &#xA;  }  // end of setup&#xA;&#xA;int readSensor (const byte which)&#xA;  {&#xA;  // select correct MUX channel&#xA;  digitalWrite (addressA, (which &amp;amp; 1) ? HIGH : LOW);&#xA;  digitalWrite (addressB, (which &amp;amp; 2) ? HIGH : LOW);&#xA;  digitalWrite (addressC, (which &amp;amp; 4) ? HIGH : LOW);&#xA;  // now read the sensor&#xA;  return analogRead (sensor);&#xA;  }  // end of readSensor&#xA;&#xA;void loop ()&#xA;  {&#xA;  // show all 8 sensor readings&#xA;  for (byte i = 0; i &amp;lt; 7; i++)&#xA;    {&#xA;    Serial.print (&quot;Sensor &quot;);&#xA;    Serial.print (i);&#xA;    Serial.print (&quot; reads: &quot;);&#xA;    Serial.println (readSensor (i));&#xA;    }&#xA;  delay (1000);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That only does 8 ports, but the 16-port chip would be conceptually similar.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-07T07:14:11.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13219" PostTypeId="2" ParentId="343" CreationDate="2015-07-07T08:12:16.963" Score="5" Body="&lt;p&gt;You already have some perfectly good answers. I am posting this only to&#xA;share some stats I did one day I asked myself the same sort of&#xA;questions: What is taking so much space on a minimal sketch? What is the&#xA;minimum needed to achieve the same functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below are three versions of a minimal blinky program that toggles the&#xA;LED on pin 13 every second. All three versions have been compiled for an&#xA;Uno (no USB involved) using avr-gcc 4.8.2, avr-libc 1.8.0 and&#xA;arduino-core 1.0.5 (I do not use the Arduino IDE).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the standard Arduino way:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const uint8_t ledPin = 13;&#xA;&#xA;void setup() {&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(ledPin, LOW);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This compiles to 1018 bytes. &lt;a href=&quot;https://arduino.stackexchange.com/a/12684&quot;&gt;Using both &lt;code&gt;avr-nm&lt;/code&gt; and&#xA;disassembly&lt;/a&gt;,&#xA;I broke down that size into individual functions. From&#xA;largest to smallest:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 148 A ISR(TIMER0_OVF_vect)&#xA; 118 A init&#xA; 114 A pinMode&#xA; 108 A digitalWrite&#xA; 104 C vector table&#xA;  82 A turnOffPWM&#xA;  76 A delay&#xA;  70 A micros&#xA;  40 U loop&#xA;  26 A main&#xA;  20 A digital_pin_to_timer_PGM&#xA;  20 A digital_pin_to_port_PGM&#xA;  20 A digital_pin_to_bit_mask_PGM&#xA;  16 C __do_clear_bss&#xA;  12 C __init&#xA;  10 A port_to_output_PGM&#xA;  10 A port_to_mode_PGM&#xA;   8 U setup&#xA;   8 C .init9 (call main, jmp exit)&#xA;   4 C __bad_interrupt&#xA;   4 C _exit&#xA;-----------------------------------&#xA;1018   TOTAL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the list above, the first column is the size in bytes, and the second&#xA;column tells whether the code comes from the Arduino core library (A,&#xA;822 bytes total), the C runtime (C, 148 bytes) or the user (U, 48&#xA;bytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As can be seen in this list, the largest function is the routine&#xA;servicing the timer 0 overflow interrupt. This routine is responsible of&#xA;tracking time, and is needed by &lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;micros()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;.&#xA;The second largest function is &lt;code&gt;init()&lt;/code&gt;, which sets the hardware timers&#xA;for PWM, enables TIMER0_OVF interrupt and disconnects the USART (that&#xA;was used by the bootloader). Both this and the previous function are&#xA;defined in&#xA;&lt;code&gt;&amp;lt;Arduino directory&amp;gt;/hardware/arduino/cores/arduino/wiring.c&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next is the C + avr-libc version:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    DDRB |= _BV(PB5);     /* set pin PB5 as output */&#xA;    for (;;) {&#xA;        PINB = _BV(PB5);  /* toggle PB5 */&#xA;        _delay_ms(1000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The break-down of the individual sizes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;104 C vector table&#xA; 26 U main&#xA; 12 C __init&#xA;  8 C .init9 (call main, jmp exit)&#xA;  4 C __bad_interrupt&#xA;  4 C _exit&#xA;----------------------------------&#xA;158   TOTAL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is 132 bytes for the C runtime and 26 bytes of user code, including&#xA;the inlined function &lt;code&gt;_delay_ms()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It could be noted that, since this program does not use interrupts,&#xA;the interrupt vector table is not needed, and regular user code&#xA;could be put in its place. The following assembly version does exactly&#xA;that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#define io(reg) _SFR_IO_ADDR(reg)&#xA;&#xA;    sbi io(DDRB), 5  ; set PB5 as output&#xA;loop:&#xA;    sbi io(PINB), 5  ; toggle PB5&#xA;    ldi r26, 49      ; delay for 49 * 2^16 * 5 cycles&#xA;delay:&#xA;    sbiw r24, 1&#xA;    sbci r26, 0&#xA;    brne delay&#xA;    rjmp loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is assembled (with &lt;code&gt;avr-gcc -nostdlib&lt;/code&gt;) into only 14 bytes,&#xA;most of which are used to delay the toggles so that the blink is&#xA;visible. If you remove that delay loop, you end up with a 6-byte&#xA;program that blinks too fast to be seen (at 2&amp;nbsp;MHz):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    sbi io(DDRB), 5  ; set PB5 as output&#xA;loop:&#xA;    sbi io(PINB), 5  ; toggle PB5&#xA;    rjmp loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-07-07T08:12:16.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13221" PostTypeId="1" AcceptedAnswerId="13224" CreationDate="2015-07-07T09:31:36.970" Score="3" ViewCount="216" Body="&lt;p&gt;I dont understand what does the word &quot;decoupling&quot; mean? Where and Why it is used? Can anyone give me a brief idea&gt;?&lt;/p&gt;&#xA;" OwnerDisplayName="user4236" LastActivityDate="2015-07-08T00:02:53.573" Title="What is the use of decoupling capacitor?" Tags="|electronics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13222" PostTypeId="2" ParentId="13214" CreationDate="2015-07-07T09:42:09.863" Score="1" Body="&lt;p&gt;The errors you were getting when you compiled was because if the libraries were extracted straight to the Arduino library folder from the .zip, the file path becomes too long for the compiler to find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what you need to do is to create a new folder in the libraries folder for each library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: you cannot do the standard &lt;code&gt;libraryName\src\foo.cpp&lt;/code&gt; as this seems to give errors for these libraries (in that it does not find them). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is to make a file in the &lt;code&gt;libraries&lt;/code&gt; directory; for the &lt;em&gt;zkemble&lt;/em&gt; one you can create a main folder called &lt;code&gt;nRF905&lt;/code&gt;, then take the files under &lt;code&gt;nRF905/arduino/nRF905&lt;/code&gt; from github and place them in the folder created earlier. It should look like this: &#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZTvGC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should repeat this for the Elechouse one as well as it solved the problem too. i.e.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;C:\\...\libraries\NRF\examples\&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C:\\...\libraries\NRF\NRF905.cpp&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C:\\...\libraries\NRF\NRF905.h&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;C:\\...\libraries\NRF\keywords.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also of importance is that once you have the library from Elechouse compiling you need to open up the .cpp file and go to line 16, where there is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM unsigned int freq_tab[10] = {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and to this add &lt;code&gt;const&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM const unsigned int freq_tab[10] = {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="4628" LastEditDate="2015-08-19T13:33:32.567" LastActivityDate="2015-08-19T13:33:32.567" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13224" PostTypeId="2" ParentId="13221" CreationDate="2015-07-07T09:49:04.020" Score="3" Body="&lt;p&gt;Quite simply put, it's a little reservoir of energy for a chip or other device to dip into when it needs to get a little extra power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Electronics &lt;em&gt;nothing&lt;/em&gt; happens instantly.  When a chip needs more power it has to get it from the power source.  The power source then has to respond to that by providing more energy, and that then has to make its way down the wires or traces to where it needs to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By placing a small capacitor near where the power is consumed the capacitor can respond to that call for more power much faster than the power supply.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-07T09:49:04.020" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="13225" PostTypeId="1" AcceptedAnswerId="13227" CreationDate="2015-07-07T10:05:30.937" Score="0" ViewCount="243" Body="&lt;p&gt;-Are there any changes in Bootloader?&#xA;-Why is the coding different for same chip in different softwares?&#xA;-How to upload the program from Atmel Studio?&lt;/p&gt;&#xA;" OwnerDisplayName="user4236" LastActivityDate="2015-07-08T10:54:39.293" Title="What changes I have to take care while coding from Atmel Studio instead of Arduino IDE?" Tags="|arduino-uno|arduino-ide|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13226" PostTypeId="1" CreationDate="2015-07-07T10:19:29.893" Score="1" ViewCount="49525" Body="&lt;p&gt;I am integrating Arduino Uno with the WiFi module ESP8266.  I have already made the connections between the ESP8266 and the Arduino Uno which are :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;txd uno -&amp;gt; rxd esp8266 &#xA;rxd uno -&amp;gt; txd esp8266  &#xA;gnd uno -&amp;gt; gnd esp8266&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The VCC and chid pind of ESP8266 are connected to an external supply of voltage 3.3V and 160mA current. The code is getting uploaded onto the Arduino and the ESP8266 is also getting powered on.But i am facing a problem while i send the AT commands on the serial monitor. It is not responding even though the red led is on constantly and when i press enter after sending the command , the blue led blinks for a few seconds.&#xA;Do i have to update the firmware of the ESP8266?&lt;/p&gt;&#xA;" OwnerUserId="11019" LastEditorUserId="7628" LastEditDate="2015-07-08T18:39:58.360" LastActivityDate="2018-05-02T15:18:14.147" Title="esp8266 not responding to the AT commands" Tags="|esp8266|" AnswerCount="6" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13227" PostTypeId="2" ParentId="13225" CreationDate="2015-07-07T11:58:45.887" Score="2" Body="&lt;p&gt;Atmel cpp projects do not currently provide an option to upload using Arduino bootloader. Atmel only provides upload using hardware programmers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bootloader is deleted when you upload using a hardware programmer either from Atmel Studio or from the Arduino ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The underlying Atmel toolchain is not very different from the latest Arduino toolchain however Atmel does not know about the Arduino hardware/cores. You have to copy the Arduino core sources to your Atmel project if you want to compile for Arduino compatibility but that still does not give you bootloader upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not clear from your question if you have the Arduino sources in your cpp project already. If you do have the sources in your project then you can use avrisp mkII or other programmer to upload but the Arduino libraries might be an issue for you if you are using them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another option in Atmel Studio however it might not be what you require ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can install the Visual &lt;a href=&quot;https://gallery.atmel.com/Products/Details/c7a74708-c128-42fb-b670-29f501e85937?&quot; rel=&quot;nofollow noreferrer&quot;&gt;Micro plugin for Arduino&lt;/a&gt; from the Atmel Gallery and work with standard Arduino sketch projects inside Atmel Studio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Visual Micro plugin provides full Arduino compatible sketch build and bootloader upload in Atmel Studio. Because of the nature of Arduino, the Visual Micro plugin automatically manages the include paths and Atmel project properties so that intellisense works in projects that contain .ino source code files. If the project does not contain .ino files then Visual Micro sleeps (does not interfere with cpp projects)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plugin also provides other features such as a serial usb debugger, library manager, board manager, Arduino examples etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More about Visual Micro is &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tutorials are &lt;a href=&quot;http://www.visualmicro.com/page/User-Guide.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Debugger overview is &lt;a href=&quot;http://www.visualmicro.com/page/Debugging-for-Arduino.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PKBjO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no difference in program execution between uploading using a physical hardware programmer or using a usb cable via bootloader. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino libraries sources can be more complicated to include/compile in a project because they often include additional folders with private source code. This is more of an issue with older Arduino libraries that have a sub folder called \utility.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-07-08T10:54:39.293" LastActivityDate="2015-07-08T10:54:39.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13231" PostTypeId="1" CreationDate="2015-07-07T14:11:12.620" Score="2" ViewCount="223" Body="&lt;p&gt;I have an Arduino Mega 2560 with a cc3000 Wifi shield that is sending messages to dweet.io. Here is the relevant portion of my code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Post data to dweetio&#xA;    char data[125];&#xA;    sprintf(data, &quot;?t1=%i&amp;amp;t2=%i&amp;amp;t3=%i&amp;amp;t4=%i&amp;amp;t5=%i&amp;amp;t6=%i&amp;amp;t7=%i&amp;amp;t8=%i&amp;amp;t9=%i&amp;amp;t10=%i&amp;amp;t11=%i&amp;amp;t12=%i&amp;amp;t13=%i&amp;amp;p=%i&quot;, &#xA;            (int)(t1*10.),(int)(t2*10.),(int)(t3*10.),(int)(t4*10.),(int)(t5*10.),&#xA;            (int)(t6*10.),(int)(t7*10.),(int)(t8*10.),(int)(t9*10.),(int)(t10*10.),&#xA;            (int)(t11*10.),(int)(t12*10.),(int)(t13*10.)),(int)(0);&#xA;    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);&#xA;    if (client.connected()) {&#xA;      client.fastrprint(F(&quot;GET &quot;));&#xA;      client.fastrprint(F(&quot;/dweet/for/blahblah&quot;));&#xA;      client.fastrprint(data);&#xA;      client.fastrprint(F(&quot; HTTP/1.1\r\n&quot;));&#xA;      client.fastrprint(F(&quot;Host: https://www.dweet.io\r\n&quot;));&#xA;      client.fastrprint(F(&quot;\r\n\r\n&quot;));&#xA;      // client.println();&#xA;      // Serial.println(F(&quot;Sent dweet\n&quot;));&#xA;    } else {&#xA;      Serial.println(F(&quot;Sending dweet failed&quot;));&#xA;      return;&#xA;    }&#xA;&#xA;/* Read data until either the connection is closed, or the idle timeout is reached. */ &#xA;long lastRead = millis();&#xA;while (client.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; 1000)) {&#xA;  while (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;    lastRead = millis();&#xA;  }&#xA;}&#xA;&#xA;client.close();&#xA;// Serial.println(&quot;Connection to dweet.io closed&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition to this code, the loop does about two seconds of data collection and setting outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works most of the time when I connect to a typical wireless router. However, I want to deploy it away from my wifi source so I got a T-Mobile hotspot. When I use the identical code with the hotspot, it only successfully sends the message about one out of ten tries (sporadically though, not on even intervals).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code doesn't report any errors. Anyone have any suggestions on how to debug this?&lt;/p&gt;&#xA;" OwnerUserId="7975" LastEditorUserId="37523" LastEditDate="2019-08-08T00:35:50.870" LastActivityDate="2019-08-08T00:35:50.870" Title="Intermittent wifi/hotspot connection" Tags="|wifi|shields|atmega2560|debugging|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13233" PostTypeId="1" AcceptedAnswerId="13365" CreationDate="2015-07-07T15:31:52.850" Score="11" ViewCount="6362" Body="&lt;p&gt;I am drafting a pub quiz project, where the Referee gives a signal and multiple players push their buttons. The first to push wins the right to give an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want all buttons (referee's + X players) to be wireless. Since the best quiz players can click a button within 10ms of the signal, it is very important that there is a very, very little variance in ping between different buttons. I cannot have players shouting &quot;my button is laggy!&quot; On the other hand, I don't want to use more expensive/complex tech than needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SO, what would be the optimal wireless tech to use? Please share your experience from similar projects (or just theoretical knowledge :) Here's what I researched so far (correct me if I'm wrong):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Bluetooth 4 LE (as in RFduino)&#xA;Pros: 3-6ms latency (advertised), low energy&#xA;Cons: cost, not more than 7 buttons to the device&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wi-fi&#xA;Pros: 2ms latency (I justed pinged my wi-fi router), dozens of buttons if need be&#xA;Cons: cost, power-hungry&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;RF data tranceiver&#xA;Pros: dunno, cost seems to be a bit smaller&#xA;Cons: multiple buttons at the same frequency will probably create a lot of noise&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Simplest &quot;Radio remote&quot;&#xA;Pros: zero lag since it's all electromechanical, no data&#xA;Cons: multiple buttons at the same frequency won't work&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, did I miss anything? I appreciate any guidance.&lt;/p&gt;&#xA;" OwnerUserId="10837" LastActivityDate="2017-08-09T13:12:34.530" Title="Choosing wireless tech for lowest possible lag" Tags="|bluetooth|nrf24l01+|button|rf|wireless|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13234" PostTypeId="2" ParentId="13233" CreationDate="2015-07-07T16:57:39.323" Score="1" Body="&lt;p&gt;In my humble opinion it might be even cheaper if you use IR or some other type of light, assuming you can ensure line of sight.&#xA;You can use different wavelengths to ensure separation of the signals.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="11529" LastEditDate="2017-08-08T09:47:22.160" LastActivityDate="2017-08-08T09:47:22.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13235" PostTypeId="1" CreationDate="2015-07-07T02:15:10.667" Score="-1" ViewCount="2225" Body="&lt;p&gt;I have an Atmega328P-AU with 16Mhz crystal(&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematics&lt;/a&gt;). And its analog pins A0 to A3 are connected to button inputs.&#xA;All these pins are pulled-down(10K res). And in code, I have digitalRead(A0) to digtalRead(A3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press button attached to A3 and A2. They works as they should. But when I press any button attached to A0 or A1, both their &lt;code&gt;digitalRead()&lt;/code&gt; returns true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked 3 times, all resistors and buttons wires are well connected and are not shorted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is test code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(A0, INPUT);&#xA;    pinMode(A1, INPUT);&#xA;    pinMode(A3, INPUT);&#xA;    pinMode(A2, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{    &#xA;if (digitalRead(A0))&#xA;    Serial.println(&quot;A0&quot;);&#xA;if(digitalRead(A1))&#xA;    Serial.println(&quot;A1&quot;);&#xA;if (digitalRead(A2))&#xA;    Serial.println(&quot;A2&quot;);&#xA;if (digitalRead(A3))&#xA;    Serial.println(&quot;A3&quot; );&#xA;delay(400);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When pressed &lt;code&gt;A0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A0&#xA;A1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When pressed &lt;code&gt;A1&lt;/code&gt;(same result)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A0&#xA;A1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When pressed &lt;code&gt;A2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When pressed &lt;code&gt;A3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what could be causing this problem ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &#xA;Test&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When I press A1 button, the A1 pin is high with 4.8V as well as A0&#xA;pin is high with 2.6V to 3.8V.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When nothing is pressed, A1 has 180mV while A0 has -180mV.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ohUAe.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fohUAe.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="11063" OwnerDisplayName="xmen" LastEditorUserId="10794" LastEditDate="2015-09-12T00:39:48.843" LastActivityDate="2015-09-12T00:39:48.843" Title="digitalRead(A0) returns true when A1 is HIGH" Tags="|c++|hardware|digital|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13236" PostTypeId="2" ParentId="13235" CreationDate="2015-07-07T02:38:15.100" Score="0" Body="&lt;p&gt;I recreated this experiment on my Arduino and it worked like it should. This should work the way you want it to. The only thing I can think of is maybe the chip possibly being partially fried or the pullup resistors not being adequet (not having a low enough resistance) for the job. The resistors I used are 1k. Other than that there is not much else I can think of.&lt;/p&gt;&#xA;" OwnerUserId="4440" OwnerDisplayName="Sock314" LastActivityDate="2015-07-07T02:38:15.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13237" PostTypeId="2" ParentId="13235" CreationDate="2015-07-07T07:16:55.583" Score="-1" Body="&lt;p&gt;Ok so it could be a number of factors.  You are sure that the pins are 5V tolerant in the mode you're using?  It's possible to burn out pins if they don't have internal current regulation.  You said analog pin which is weird since a button will cause lots of debouce, but it looks configured digital.  Debounce is still an issue on digital circuits with buttons.&lt;/p&gt;&#xA;" OwnerUserId="11068" OwnerDisplayName="Matt" LastActivityDate="2015-07-07T07:22:06.407" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13238" PostTypeId="2" ParentId="13235" CreationDate="2015-07-07T11:50:51.347" Score="2" Body="&lt;p&gt;Assuming you've not activated any ADC functionality in your Arduino code (i.e. assuming the sample code you've posted here is 100% what you've tried, and no analogReference(); statement), then I still think your problem is a partial short between AO &amp;amp; A1.  If my above assumptions are not the case, then there are other possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 5.0V Vcc rail, anything more than 0.5Vcc (i.e. 2.5V) will register as a high/1 (datasheet section 30 - Electrical characteristics, 30.2 DC Characteristics), so based on the measurements you posted to the edit of your question, your code is indeed correctly reporting a 1 on A0 when you push A1 button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it's only barely a 1/high, and as you've said, it varies from 2.6 to 3.8, another classic sign of a soldering or partial short circuit somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're able to remove the '328 from the circuit, use your multimeter to read resistance between A0 &amp;amp; A1.  Also try a new/different '328, maybe you damaged one of its input in the past.&lt;/p&gt;&#xA;" OwnerUserId="7937" OwnerDisplayName="Techydude" LastActivityDate="2015-07-07T11:50:51.347" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13240" PostTypeId="2" ParentId="8025" CreationDate="2015-07-07T18:07:59.977" Score="1" Body="&lt;p&gt;Use a &lt;a href=&quot;https://www.sparkfun.com/products/242&quot; rel=&quot;nofollow noreferrer&quot;&gt;Infrared Proximity Sensor&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/VWQT3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like a &lt;a href=&quot;https://www.sparkfun.com/products/13167&quot; rel=&quot;nofollow noreferrer&quot;&gt;LidarLite&lt;/a&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/YKvmE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They measures distance by measuring the offset (&lt;a href=&quot;https://en.wikipedia.org/wiki/Parallax&quot; rel=&quot;nofollow noreferrer&quot;&gt;parallax&lt;/a&gt;) from a projected point of light. This will not suffer from echo restrictions, like Ultrasonic Sensors do.&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastEditorUserId="25913" LastEditorDisplayName="user6569" LastEditDate="2016-09-07T15:47:12.433" LastActivityDate="2016-09-07T15:47:12.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13243" PostTypeId="1" CreationDate="2015-07-07T22:07:37.587" Score="1" ViewCount="3845" Body="&lt;p&gt;I would like to design a system in which I am able to make a light flash when a motion sensor detects a movement of a non human object such as a car. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The goal here being that when a car is moving behind me in my blind spot around the corner of a wall in my parking spot I don't back into it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked into a few tutorials using arduinos to detect this motion but so far I have only read about the PIR (which only detects humans and animals).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/DIY-Arduino-Motion-Sensor-Lighting-Control/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/DIY-Arduino-Motion-Sensor-Lighting-Control/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What sensor would be best for this situation or do I need to rethink my system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have no intention of harming anyone or anything :) )&lt;/p&gt;&#xA;" OwnerUserId="11066" LastEditorUserId="11066" LastEditDate="2016-01-22T00:29:47.890" LastActivityDate="2018-08-26T09:37:00.383" Title="Detect a non-human moving object" Tags="|arduino-uno|accelerometer|" AnswerCount="6" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13244" PostTypeId="2" ParentId="13197" CreationDate="2015-07-07T23:09:51.357" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/SodaqMoja/SodaqMojaBoard&quot; rel=&quot;nofollow&quot;&gt;the schematics&lt;/a&gt; and pictures of the Moja, the Sodaq Moja has no &quot;User Switches&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 2 buttons and 1 switch.  The switch is a general power on-off switch.  One button (SW2) is the master reset button for the ATMega328P.  The other button, SW3, is the reset for the X-Bee daughter board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of those can be used programmatically.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-07T23:09:51.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13245" PostTypeId="1" AcceptedAnswerId="13260" CreationDate="2015-07-07T23:12:59.407" Score="0" ViewCount="140" Body="&lt;p&gt;I'am new to Arduino and c++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i get his code from the INTERNET&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(57600);  &#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;int f = 0, pos;&#xA;void loop() {&#xA;    boolean has_request = false;&#xA;    String in = &quot;&quot;;&#xA;    if (Serial.available()) {&#xA;        in = &quot;&quot;;&#xA;        while (true) {  // should add time out here&#xA;            while (Serial.available() == false) {}&#xA;            in += (char)(Serial.read());&#xA;            if (in.endsWith(&quot;\r\n\r\n&quot;)) {&#xA;                has_request = true;  break;&#xA;            } &#xA;        }&#xA;    }&#xA;    if (has_request) {&#xA;        int i1 = in.indexOf(&quot;GET /blink?f=&quot;), i2;&#xA;        if (i1 != -1) {&#xA;            i2 = in.indexOf(&quot; &quot;, i1+13);&#xA;            f = in.substring(i1+13, i2).toInt();&#xA;        }&#xA;        Serial.println(&quot;HTTP/1.1 200 OK\nContent-Type: text/html\nConnection: close&quot;);&#xA;        String sr = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\n&quot;;&#xA;        sr += &quot;&amp;lt;html&amp;gt;\n&quot;;&#xA;        sr += &quot;LED frequency: &quot;;&#xA;        sr += f;&#xA;        sr += &quot;Hz.&amp;lt;/html&amp;gt;&quot;;&#xA;        Serial.print(&quot;Content-Length: &quot;);&#xA;        Serial.print(sr.length());&#xA;        Serial.print(&quot;\r\n\r\n&quot;);&#xA;        Serial.print(sr);&#xA;        has_request = false;&#xA;    }&#xA;    if (f&amp;gt;0) {&#xA;        static unsigned long t = millis();&#xA;        if (millis() &amp;gt; t + 1000/f) {&#xA;            digitalWrite(13, 1-digitalRead(13));&#xA;            t = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/mNQQamUg&quot; rel=&quot;nofollow&quot;&gt;see this link if you cant see the code formated here in the site&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this code is used for the Arduino uno wifi shield&#xA;it is working perfectly except it is too complicated for me &#xA;while loop inside a while loop &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and i don't want to do frequency i only need to send turn on or off&#xA;without any complexity &lt;/p&gt;&#xA;&#xA;&lt;p&gt;anyone could help me ? &lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="4143" LastEditDate="2015-07-07T23:20:00.690" LastActivityDate="2015-07-08T11:26:42.557" Title="Need help shrinking a code" Tags="|arduino-uno|shields|wifi|" AnswerCount="3" CommentCount="1" ClosedDate="2015-07-16T14:21:22.270" ContentLicense="CC BY-SA 3.0" />
  <row Id="13246" PostTypeId="2" ParentId="13245" CreationDate="2015-07-07T23:21:40.197" Score="3" Body="&lt;p&gt;There is only one &quot;while loop inside a while loop&quot; and that is hardly complex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial.available() == false) {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All that means is &quot;Wait for something to become available on the serial&quot;.  That is ALL it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing even remotely complex there.  True, it may not be very well written (as is the case with lots of code on t'interwebs).  It's time to start learning how the code works so you can write your own.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-07T23:27:59.180" LastActivityDate="2015-07-07T23:27:59.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13247" PostTypeId="2" ParentId="13243" CreationDate="2015-07-07T23:26:54.430" Score="2" Body="&lt;p&gt;If your car is moving at the time, then relative to your car &lt;em&gt;everything&lt;/em&gt; is moving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Automotive companies have spent billions of dollars working on this problem.  There is no &quot;sensor&quot; that can differentiate one moving object from a background that is also moving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All existing automotive systems that perform this task use cameras and computers, with software such as OpenCV.  This is not something that any Arduino could even come close to doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest you could get is &quot;is there something in this area that is within a certain distance of me&quot; which you may be able to do with an ultrasound &quot;Ping&quot; sensor.  It won't differentiate between a moving car or a bollard or a child or just the wall you are reversing towards.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-07T23:26:54.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13248" PostTypeId="2" ParentId="117" CreationDate="2015-07-07T23:39:54.170" Score="21" Body="&lt;h2&gt;I&lt;sup&gt;2&lt;/sup&gt;C (Wire)&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can use the I&lt;sup&gt;2&lt;/sup&gt;C protocol (Wire library) to connect to other devices such as port-expanders. For example, the MCP23017. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used one of those chips to connect to an LCD board. The MCP23017 has 16 ports, which can be configured as inputs or outputs. As inputs they can raise interrupts if desired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of connecting 13 of those 16 to the LCD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/a30M6.png&quot; alt=&quot;MCP23017 connected to LCD screen&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we connect to the Arduino using only 2 wires (SDA/SCL) plus power and ground:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rDcCd.png&quot; alt=&quot;MCP23017 connected to Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some third-party manufacturers have made boards with 4 x MCP23017 on them, this gives you 64 inputs/outputs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rDTTv.png&quot; alt=&quot;Centipede board&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Multiplexers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can use analog multiplexers like the 74HC4051 (8 ports) or the 74HC4067 (16 ports) to connect one pin to one of the 8/16 ports (but only one at a given time), like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iATER.png&quot; alt=&quot;74HC4051 multiplexer&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are bi-directional, so can be used as an input or output expander.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI with 74HC595&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Using SPI you can send fast serial data to a shift register, such as the 74HC595. These can be daisy chained together. In this example I am controlling 32 LEDs with only 3 I/O pins (MOSI/MISO/SCK) plus power and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OSl67.jpg&quot; alt=&quot;74HC595 driving 32 LEDs&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I found inside a commercial LED sign that the 72 LEDs were driven by 74HC595 chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/StXYR.jpg&quot; alt=&quot;Scrolling LED sign&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This had 9 chips driving the columns (9 x 8 = 72 LEDs) and one chip driving the rows, in a multiplexed configuration.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI with MAX7219&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you just want to drive LEDs you can usually multiplex them. The MAX7219 simplifies that by being designed to drive LED matrixes, for example 7-segment displays:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/keI0f.jpg&quot; alt=&quot;MAX7219 with 7-segment display&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or 64-LED matrixes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0119t.jpg&quot; alt=&quot;MAX7219 with 64-LED matrix&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases these can be daisy-chained together, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WrL3k.jpg&quot; alt=&quot;MAX7219 daisy-chain&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All those examples only use 3 pins of the Arduino (MOSI/MISO/SCK) plus power and ground.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI with MCP23S17&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The 16-port port expander mentioned earlier (MCP23017) also comes in an SPI variant (MCP23S17), which does virtually identical things. It uses one more wire, but would be faster.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Other protocols&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;LED strips (like the NeoPixel ones) have their own protocols. There was a &lt;a href=&quot;https://www.youtube.com/watch?v=I-lR19_kigs&quot;&gt;post on Youtube by Josh Levine&lt;/a&gt; where the author drove over 1000 pixels with a Duemilanove!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot;&gt;I2C and MCP23017&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/lcd&quot;&gt;MCP23017 and graphical LCD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot;&gt;74HC4051 multiplexer / demultiplexer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot;&gt;SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=12298&quot;&gt;Hacking a scrolling LED strip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot;&gt;Using a 74HC595 output shift register as a port-expander&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot;&gt;Interfacing LED displays with the MAX7219 driver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-07T23:39:54.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13249" PostTypeId="2" ParentId="13221" CreationDate="2015-07-08T00:02:53.573" Score="1" Body="&lt;p&gt;Every time a logic circuit switches from a 0 to a 1 or a 1 to a 0, the 1 and 0 transistors are on at the same time for a short period of time.  In MOS circuits, this is combined with the need to charge the gate of the 1 or 0 transistor (Charge is what capacitors store, gates of MOS transistors are capacitors!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since all wiring is inductive, the faster the current, the higher the impedance from the main power supply and the switching device (Your processor or sensor etc).  The terms bypass and decoupling mean the same thing:  You are providing a local charge well to supply fast current demands by bypassing the main power system, i.e. supplying current via a different path and thus decoupling the switching device from the inductively isolated main supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is also why we used to use two types of capacitors for decoupling: A 0.1uF ceramic and a 1uF electrolytic for instance...  You couldn't get the whole 1uF in a low resistance ceramic to cover both the Low and High speed transients without paying a lot so you used two or more parts, each covering a portion of the spectrum.  Nowadays a single SMT ceramic with low ESR, low ESL and no lead wires can do the whole job and is usually pretty economical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another factor is radiation:  A ringing voltage transient current through inductive wiring acts just like an antenna.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2015-07-08T00:02:53.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13250" PostTypeId="2" ParentId="13053" CreationDate="2015-07-08T00:06:31.217" Score="1" Body="&lt;p&gt;You could also sense the position of the stick where it enters the floor with hall sensors... 1-5 and reverse would have sensors, neutral would be when none of the other gears are detected.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2015-07-08T00:06:31.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13251" PostTypeId="1" AcceptedAnswerId="13253" CreationDate="2015-07-08T00:29:51.633" Score="2" ViewCount="1918" Body="&lt;p&gt;Recently I tooked a look at cheaper China 3D Printers and noticed they're all based on RepRap (mostly using Ramps for the electronics part) and the next day i saw a 2d Plotter based in the pi. Then I asked myself why the Pi isnt used in 3d printers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:&#xA;Why is the Arduino Mega/Due more used in 3D Printing than the RasPi? What are the Pro's and Con's for 3D Printing on the two systems?&lt;/p&gt;&#xA;" OwnerUserId="10990" LastActivityDate="2015-07-08T00:55:58.070" Title="Arduino Mega vs. RasPi Pro Cons in 3D Printing" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13252" PostTypeId="2" ParentId="13226" CreationDate="2015-07-08T00:45:17.807" Score="0" Body="&lt;p&gt;Seems like you didnt used any type of voltage divider or level shifter between the Arduino Tx -&gt; ESP8266 RX Line. The ESP8266 isnt really 5V friendly. Too Bad the Arduino outputs 5V on all of it Pins. &#xA;You could still try it With a Voltage Divider using 2 Resistors or a level Shifter in hope it works. Elsewise With a 3.3V USB-&gt; UART Module or get a New ESP8266&lt;/p&gt;&#xA;" OwnerUserId="10990" LastActivityDate="2015-07-08T00:45:17.807" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13253" PostTypeId="2" ParentId="13251" CreationDate="2015-07-08T00:49:52.927" Score="2" Body="&lt;p&gt;A mutli-tasking operating system such as the Linux normally run on the pi is not particularly suited to doing hard real-time control such as coordinated pulse generation for multiple stepper motor axis trying to move as quickly as the rigidity and motor power will permit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use realtime extensions to the Linux kernel to get reasonable performance.  And it is also possible to run something simpler than Linux on the pi.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is also possible to use a far cheaper processor to get the actual G-code execution done (you don't really pay the Arduino cost premium when buying an ATmega on a dedicated board, so it's only a  dollar or three more expensive than it &quot;should be&quot;).  If one were to design printer electronics from scratch today, there are probably better choices, such as as ARM Cortex M0, M3 or M4 - but most of the printer designs came out of the same community where Arduino was a familiar choice, and there are probably more people willing to try to make small personal customizations to an Arduino codebase than there are willing to install the toolchain for a perhaps technically better, but less familiar solution. .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People do use Raspberry Pi's with 3d printers quite frequently though - they just use them for a different job: that of slicing and motion planning and potentially functioning as a network print server, which then drip-feeds the G code to the simpler (ATmega or whatever) based realtime executive.  In effect, they use a pi as a cheap PC to host the ATmega-based printer, rather than dedicating an old PC to that job.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately, the rarely taken alternative of using a realtime Linux kernel extensions to control motion directly from a pi, vs the more common one of using an ATmega as a realtime motion delegate for the pi, are conceptually similar - it's just that in one case the realtime executive engine is a highest priority task on the main processor, and in the other it runs on a dedicated motion co-processor.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-07-08T00:55:58.070" LastActivityDate="2015-07-08T00:55:58.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13254" PostTypeId="2" ParentId="3538" CreationDate="2015-07-08T01:39:36.310" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to learn AVR C programming instead of arduino programming.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not really clear what you think the difference is. You can use the Arduino IDE to do &quot;straight AVR&quot; programming, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  DDRB = bit (5);  // pin 13&#xA;  DDRB |= bit (4);  // pin 12&#xA;&#xA;  while (true)&#xA;    {&#xA;    PINB = bit (5); // pin 13&#xA;    PINB = bit (4); // pin 12&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The AVR register names (eg. DDRB, PINB, PORTB and so on) will be included by the IDE, however you don't have to use a single Arduino library or function if you don't want to.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-08T01:39:36.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13255" PostTypeId="1" AcceptedAnswerId="13257" CreationDate="2015-07-08T04:10:17.760" Score="4" ViewCount="2077" Body="&lt;p&gt;I'm using an Arduino Leonardo and a GPSTiny++ library to parse NMEA strings from my GPS receiver. In this chunk of code I'm averaging all satellite SNR numbers for satellites which are locked (Being used for navigation). The avg value provides some general information on overall performance but I'm also really looking for the avg Top 4 values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I would need to do some sort of sorting algorithm. Increment through the top 4 and average those values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a snippet of my output window:&#xA;12/13 0.92 SNR=17 10 27 27 30 29 25 27 33 0 0 0 31 25.60 0.00&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second to last number is the average. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I get started? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int totalSNR = 0;&#xA;    float avgSNR = 0;&#xA;    int count = 0;&#xA;    Serial.print(F(&quot; SNR=&quot;));&#xA;    for (int i = 0; i &amp;lt; MAX_SATELLITES; ++i)&#xA;      if (sats[i].active)&#xA;      {&#xA;        if (sats[i].snr &amp;gt; 0) {&#xA;          count++;&#xA;          totalSNR = totalSNR + sats[i].snr;&#xA;        }&#xA;&#xA;        Serial.print(sats[i].snr);&#xA;        Serial.print(F(&quot; &quot;));&#xA;      }&#xA;&#xA;    avgSNR = float(totalSNR) / float(count);&#xA;    Serial.print(avgSNR);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11069" LastActivityDate="2017-05-12T08:26:10.853" Title="Do I need a bubble sort or something easier?" Tags="|arduino-leonardo|tinygps|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13256" PostTypeId="2" ParentId="3538" CreationDate="2015-07-08T04:43:33.030" Score="0" Body="&lt;p&gt;You can use the Atmel Studio + Visual Micro plugin to easily get started with atmega328 + support for the uno board (easily program, use arduino libraries etc). Checkout here.  &lt;a href=&quot;http://www.visualmicro.com/page/Arduino-for-Atmel-Studio.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.visualmicro.com/page/Arduino-for-Atmel-Studio.aspx&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11027" LastActivityDate="2015-07-08T04:43:33.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13257" PostTypeId="2" ParentId="13255" CreationDate="2015-07-08T04:59:22.270" Score="5" Body="&#xA;&#xA;&lt;p&gt;You could do a &lt;strong&gt;qsort&lt;/strong&gt;. You haven't posted any data types so it is hard to answer with your specific code, however here is a sample of sorting numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int COUNT = 10;&#xA;&#xA;int someNumbers [COUNT] = { 7342, 54, 21, 42, 18, -5, 30, 998, 999, 3  };&#xA;&#xA;// callback function for doing comparisons&#xA;int myCompareFunction (const void * arg1, const void * arg2)&#xA;  {&#xA;  int * a = (int *) arg1;  // cast to pointers to integers&#xA;  int * b = (int *) arg2;&#xA;&#xA;  // a less than b? &#xA;  if (*a &amp;lt; *b)&#xA;    return -1;&#xA;&#xA;  // a greater than b?&#xA;  if (*a &amp;gt; *b)&#xA;    return 1;&#xA;&#xA;  // must be equal&#xA;  return 0;&#xA;  }  // end of myCompareFunction&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  while (!Serial) { }  // for Leonardo&#xA;  Serial.println ();&#xA;  // sort using custom compare function&#xA;  qsort (someNumbers, COUNT, sizeof (int), myCompareFunction);&#xA;  for (int i = 0; i &amp;lt; COUNT; i++)&#xA;    Serial.println (someNumbers [i]);&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;-5&#xA;3&#xA;18&#xA;21&#xA;30&#xA;42&#xA;54&#xA;998&#xA;999&#xA;7342&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Generic compare function with a template&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Interestingly, you can make the compare function be a &lt;em&gt;template&lt;/em&gt; which lets you compare &lt;em&gt;any&lt;/em&gt; type -- that is, any type that supports direct comparisons. Change the compare function to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// callback function for doing comparisons&#xA;template&amp;lt;typename T&amp;gt;&#xA;int myCompareFunction (const void * arg1, const void * arg2)&#xA;  {&#xA;  T * a = (T *) arg1;  // cast to pointers to type T&#xA;  T * b = (T *) arg2;&#xA;  // a less than b? &#xA;  if (*a &amp;lt; *b)&#xA;    return -1;&#xA;  // a greater than b?&#xA;  if (*a &amp;gt; *b)&#xA;    return 1;&#xA;  // must be equal&#xA;  return 0;&#xA;  }  // end of myCompareFunction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This change removes the reference to &quot;a&quot; and &quot;b&quot; being &quot;int&quot; and replaces them with T, which is the template type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we can change the qsort line to be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // sort using custom compare function&#xA;  qsort (someNumbers, COUNT, sizeof (int), myCompareFunction&amp;lt;int&amp;gt;);&#xA;  // -------add this----------------------------------------^^^^^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That gives the same results, but now we can also compare float, long, unsigned long, byte, all that sort of thing. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Compare floats&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For example to compare floats:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int COUNT = 10;&#xA;&#xA;float someNumbers [COUNT] = { 7342, 54, 21, 42, 18, -5, 30, 998, 999, 3  };&#xA;&#xA;// callback function for doing comparisons&#xA;template&amp;lt;typename T&amp;gt;&#xA;int myCompareFunction (const void * arg1, const void * arg2)&#xA;  {&#xA;  T * a = (T *) arg1;  // cast to pointers to type T&#xA;  T * b = (T *) arg2;&#xA;  // a less than b? &#xA;  if (*a &amp;lt; *b)&#xA;    return -1;&#xA;  // a greater than b?&#xA;  if (*a &amp;gt; *b)&#xA;    return 1;&#xA;  // must be equal&#xA;  return 0;&#xA;  }  // end of myCompareFunction&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  while (!Serial) { }  // for Leonardo&#xA;  Serial.println ();&#xA;  // sort using custom compare function&#xA;  qsort (someNumbers, COUNT, sizeof (float), myCompareFunction&amp;lt;float&amp;gt;);&#xA;  for (int i = 0; i &amp;lt; COUNT; i++)&#xA;    Serial.println (someNumbers [i]);&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The only change there was changing the word &quot;int&quot; to &quot;float&quot; (in two places) on the qsort line, and on the data declaration itself.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Compare String objects&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can even compare &lt;strong&gt;String&lt;/strong&gt; objects (not C strings), for example the data is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;String someStrings [COUNT] = { &quot;the&quot;, &quot;quick&quot;, &quot;brown&quot;, &quot;fox&quot;, &quot;jumped&quot;, &#xA;                               &quot;over&quot;, &quot;the&quot;, &quot;lazy&quot;, &quot;dog&quot;, &quot;ZOMG&quot;  };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the sort is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // sort using custom compare function&#xA;  qsort (someStrings, COUNT, sizeof (String), myCompareFunction&amp;lt;String&amp;gt;);&#xA;  for (int i = 0; i &amp;lt; COUNT; i++)&#xA;    Serial.println (someStrings [i]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Compare C strings&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We need to use &lt;code&gt;strcmp&lt;/code&gt; in this case, but most of the work is done in that. We just have to dereference the pointer so &lt;code&gt;strcmp&lt;/code&gt; gets the pointer to the string (not the pointer to the pointer to the string).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;char * someStrings [COUNT] = { &quot;the&quot;, &quot;quick&quot;, &quot;brown&quot;, &quot;fox&quot;, &quot;jumped&quot;, &#xA;                               &quot;over&quot;, &quot;the&quot;, &quot;lazy&quot;, &quot;dog&quot;, &quot;ZOMG&quot;  };&#xA;&#xA;int myCompareFunction (const void * arg1, const void * arg2)&#xA;  {&#xA;  return strcmp (*(char **) arg1, *(char **) arg2);&#xA;  }  // end of myCompareFunction&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  while (!Serial) { }  // for Leonardo&#xA;  Serial.println ();&#xA;  // sort using custom compare function&#xA;  qsort (someStrings, COUNT, sizeof (char *), myCompareFunction);&#xA;  for (int i = 0; i &amp;lt; COUNT; i++)&#xA;    Serial.println (someStrings [i]);&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-08T21:20:03.043" LastActivityDate="2015-07-08T21:20:03.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13259" PostTypeId="2" ParentId="13189" CreationDate="2015-07-08T06:42:59.547" Score="1" Body="&lt;p&gt;Arduino tutorials I've seen don't mention it but the datasheets from the ir receptors manufacturers advice to stabilize vcc with a resistor and a capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/CVy9g.png&quot; alt=&quot;circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems without that the receptor fail to correctly report the received wave so the library may decode it wrong. In my case the problem started to happen when I added RGB leds controlled by PWM on the same (stabilized) power supply.&lt;/p&gt;&#xA;" OwnerUserId="11023" LastActivityDate="2015-07-08T06:42:59.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13260" PostTypeId="2" ParentId="13245" CreationDate="2015-07-08T08:16:15.870" Score="0" Body="&lt;p&gt;I would recommend starting out with some easy stuff you understand or making code yourself... Starting out with code you don't understand will backfire you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I'll explain the code for you anyway.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This part will &quot;set everything up&quot;. The serial connection and the direction (in/output) of the pin(s).&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(57600);  &#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Somehow did the person who made this think it was logical to put this here instead of on the very top of code. There are 2 integer variables declared here of which one is initialized with 0. (f).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int f = 0, pos;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This part of the code (untill the very last bracket) will be ran continiously, in a &quot;loop&quot;. Many, if not all, embedded systems will run &quot;forever&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is basically a &quot;flag&quot;, it indicates if something has, or has not happened. At this point it's only initialized.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    boolean has_request = false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also we're keeping a buffer (text string) of the characters we receive.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    String in = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check if there are characters in our serial buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    if (Serial.available()) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If so, we empty our own buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        in = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And keep doing this code.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        while (true) {  // should add time out here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We wait until the next character is ready.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;            while (Serial.available() == false) {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And add it to our buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;            in += (char)(Serial.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when we see our buffer ends with \r\n\r\n (carriage return, line break x2).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;            if (in.endsWith(&quot;\r\n\r\n&quot;)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We're going to set te flag, indicating that we have received a message.&#xA;And we stop the: &quot;Keep doing this code&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;                has_request = true;  break;&#xA;            } &#xA;        }//(this is actually the parenthesis of the while(true) which we break out.&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So we had this message, right? Let's do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    if (has_request) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parse the variable in the GET request (f=??) to an int.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        int i1 = in.indexOf(&quot;GET /blink?f=&quot;), i2;&#xA;        if (i1 != -1) {&#xA;            i2 = in.indexOf(&quot; &quot;, i1+13);&#xA;            f = in.substring(i1+13, i2).toInt();&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Send a 200OK (with body) back to the thing that sent the http request (actually pretty neat to do so.)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        Serial.println(&quot;HTTP/1.1 200 OK\nContent-Type: text/html\nConnection: close&quot;);&#xA;        String sr = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\n&quot;;&#xA;        sr += &quot;&amp;lt;html&amp;gt;\n&quot;;&#xA;        sr += &quot;LED frequency: &quot;;&#xA;        sr += f;&#xA;        sr += &quot;Hz.&amp;lt;/html&amp;gt;&quot;;&#xA;        Serial.print(&quot;Content-Length: &quot;);&#xA;        Serial.print(sr.length());&#xA;        Serial.print(&quot;\r\n\r\n&quot;);&#xA;        Serial.print(sr);&#xA;        has_request = false;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We also keep doing this blinking. (Fun fact: While receiving/sending stuff, your blinking will stop/desync. This is because the receive/send code is blocking the blinking code. Making the blinking hardware and/or receive/send interrupt based will improve the systems reaction time and efficiency.)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    if (f&amp;gt;0) {&#xA;        static unsigned long t = millis();&#xA;        if (millis() &amp;gt; t + 1000/f) {&#xA;            digitalWrite(13, 1-digitalRead(13));&#xA;            t = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But how will we make this better? Or atleast easier to read?&lt;/strong&gt;&#xA;By using functions, you can split up the code, and giving the functions a logic name, it all becomes quite obvious. The whole thing is doing 3 jobs:&#xA;Blinking a led on a given frequency.&#xA;Receiving requests/commands through serial (handling serial).&#xA;And handling these requests afterwards.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void BlinkLed(int f);&#xA;void HandleRequest();&#xA;void HandleSerial();&#xA;&#xA;int f = 0, pos;//Pos doesn't have to be a global variable...&#xA;&#xA;void setup() {&#xA;    Serial.begin(57600);  &#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    boolean has_request = false;//Reset the flag every loop.&#xA;    String in = &quot;&quot;;//Clear the string every new loop.&#xA;    if (Serial.available()) {&#xA;        HandleSerial();&#xA;    }&#xA;    if (has_request) {&#xA;        HandleRequest();&#xA;    }&#xA;    BlinkLed(f);&#xA;}&#xA;&#xA;void BlinkLed(int f){&#xA;if (f&amp;gt;0) {&#xA;        static unsigned long t = millis();&#xA;        if (millis() &amp;gt; t + 1000/f) {&#xA;            digitalWrite(13, 1-digitalRead(13));&#xA;            t = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void HandleSerial(){&#xA;        in = &quot;&quot;;&#xA;        while (true) {  // should add time out here&#xA;            while (Serial.available() == false) {}&#xA;            in += (char)(Serial.read());&#xA;            if (in.endsWith(&quot;\r\n\r\n&quot;)) {&#xA;                has_request = true;  break;&#xA;            } &#xA;        }&#xA;}&#xA;&#xA;void HandleRequest(void){&#xA;&#xA;        int i1 = in.indexOf(&quot;GET /blink?f=&quot;), i2;&#xA;        if (i1 != -1) {&#xA;            i2 = in.indexOf(&quot; &quot;, i1+13);&#xA;            f = in.substring(i1+13, i2).toInt();&#xA;        }&#xA;        Serial.println(&quot;HTTP/1.1 200 OK\nContent-Type: text/html\nConnection: close&quot;);&#xA;        String sr = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\n&quot;;&#xA;        sr += &quot;&amp;lt;html&amp;gt;\n&quot;;&#xA;        sr += &quot;LED frequency: &quot;;&#xA;        sr += f;&#xA;        sr += &quot;Hz.&amp;lt;/html&amp;gt;&quot;;&#xA;        Serial.print(&quot;Content-Length: &quot;);&#xA;        Serial.print(sr.length());&#xA;        Serial.print(&quot;\r\n\r\n&quot;);&#xA;        Serial.print(sr);&#xA;        has_request = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;V2 (more likely to compile, but kinda changes the structure):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void BlinkLed(int f);&#xA;void HandleRequest();&#xA;boolean HandleSerial();&#xA;&#xA;int f = 0;//Frequency of the led (blinking)&#xA;&#xA;void setup() {&#xA;    Serial.begin(57600);  &#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    String in = &quot;&quot;;//Clear the string every new loop.&#xA;    if (Serial.available()) {&#xA;        if(HandleSerial()){&#xA;            HandleRequest();&#xA;        }&#xA;    }&#xA;    BlinkLed(f);&#xA;}&#xA;&#xA;void BlinkLed(int f){&#xA;if (f&amp;gt;0) {&#xA;        static unsigned long t = millis();&#xA;        if (millis() &amp;gt; t + 1000/f) {&#xA;            digitalWrite(13, 1-digitalRead(13));&#xA;            t = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;boolean HandleSerial(){&#xA;        in = &quot;&quot;;&#xA;        while (true) {  // should add time out here&#xA;            while (Serial.available() == false) {}&#xA;            in += (char)(Serial.read());&#xA;            if (in.endsWith(&quot;\r\n\r\n&quot;)) {&#xA;                return true;&#xA;            } &#xA;        }&#xA;        return false;&#xA;}&#xA;&#xA;void HandleRequest(void){&#xA;    int i1 = in.indexOf(&quot;GET /blink?f=&quot;), i2;&#xA;    if (i1 != -1) {&#xA;        i2 = in.indexOf(&quot; &quot;, i1+13);&#xA;        f = in.substring(i1+13, i2).toInt();&#xA;    }&#xA;    Serial.println(&quot;HTTP/1.1 200 OK\nContent-Type: text/html\nConnection: close&quot;);&#xA;    String sr = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\n&quot;;&#xA;    sr += &quot;&amp;lt;html&amp;gt;\n&quot;;&#xA;    sr += &quot;LED frequency: &quot;;&#xA;    sr += f;&#xA;    sr += &quot;Hz.&amp;lt;/html&amp;gt;&quot;;&#xA;    Serial.print(&quot;Content-Length: &quot;);&#xA;    Serial.print(sr.length());&#xA;    Serial.print(&quot;\r\n\r\n&quot;);&#xA;    Serial.print(sr);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We can even make it more nicer by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;using hardware (PWM) to toggle/time the led.&lt;/li&gt;&#xA;&lt;li&gt;rewriting the serial handling code... (&lt;a href=&quot;https://www.arduino.cc/en/Serial/ReadStringUntil&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/ReadStringUntil&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Using printf() to format the serial.prints on one line...&lt;/li&gt;&#xA;&lt;li&gt;Make the receive/send code interrupt based, so that it will only take short amounts of time of your code, instead of continously waiting in a while, you can do stuff in the meanwhile ;)&lt;/li&gt;&#xA;&lt;li&gt;using classes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-07-08T08:43:18.033" LastActivityDate="2015-07-08T08:43:18.033" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13261" PostTypeId="2" ParentId="13226" CreationDate="2015-07-08T08:31:00.743" Score="1" Body="&lt;p&gt;Okay, I'll just summarize the stuff I've seen in the comments and answers. It's quite a basic issue? You'll find a lot resources on it on the web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current (draw of chip too high?):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wireless communication can take a lot of current. You should have a good power supply. Arduino usually can't supply enough current. Check the datasheet of the chip to see it max current draw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Rx/Tx (Wiring):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure you send through the Tx pin, into the Receive (Rx) pin of the other device.&#xA;Also, you can't use the same Tx pins for USB communication AND to connect to the ESP, that basically won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Voltage (3.3V vs 5V):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino runs on 5V, but, the ESP on 3.3V you shouldn't want to mix these up.&#xA;It'll do in some cases. Putting 3.3V (Tx of ESP) on the Rx of arduino (5V) won't damage it. But the other way around is strongly discouraged. Use a logic level shifter or voltage divider between it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Chip might be broken&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the chip isn't doing anything at all, you should take in consideration that it's possible the chip is broken... I've spent too many hours on debugging my code while the chip simply wasn't working. Also after having applied 5V to the ESP8266, this becomes quite likely.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-07-08T08:46:56.437" LastActivityDate="2015-07-08T08:46:56.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13262" PostTypeId="1" CreationDate="2015-07-08T08:58:57.800" Score="0" ViewCount="116" Body="&lt;p&gt;I am using Arduino Duemilanove 328,and running the AnalogReadSerial example sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even when nothing is connected to the Arduino board it still shows a value of about 350 out of 1023. Ideally it should have shown 0 out of 1023 when nothing is connected to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="11072" LastEditorUserId="26916" LastEditDate="2017-11-04T08:20:30.673" LastActivityDate="2017-11-04T08:20:30.673" Title="Getting random values on Arduino Duemilanove 328" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13263" PostTypeId="1" AcceptedAnswerId="13265" CreationDate="2015-07-08T09:11:38.080" Score="1" ViewCount="988" Body="&lt;p&gt;If you connect your arduino to a motor you use this schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ibbFi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when it comes to buzzers, which also have a coil, no one protects the circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/JMqnY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What the hell is going on? Are these just buzzers &quot;coiless&quot;? How can I find the type of buzzer I have?&lt;/p&gt;&#xA;" OwnerUserId="1496" LastActivityDate="2015-07-08T09:30:56.417" Title="How come people connect their arduinos to buzzers without any coil protection?" Tags="|arduino-uno|motor|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13265" PostTypeId="2" ParentId="13263" CreationDate="2015-07-08T09:30:56.417" Score="2" Body="&lt;p&gt;That kind of &quot;buzzer&quot; doesn't have a coil.  It is a &quot;Piezo Transducer&quot; and uses a crystal to produce the sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're using a real speaker and producing sound you are doing it very differently to switching a motor or a relay on and off.  You're generating a much smoother waveform and you don't have the sharp &quot;ON-OFF&quot; that causes a collapse of the magnetic field.  You're actually gradually reducing the power and then reversing it to remove the magnetic field then apply a new one in the opposite direction (if you have wired it right of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the currents involved in driving a speaker like that are minuscule compared to switching a relay, especially when driven direct from the Arduino.  For louder volumes you will use an amplifier, and that deals with the whole protection within itself since it is designed to drive a speaker.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-08T09:30:56.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13266" PostTypeId="2" ParentId="13262" CreationDate="2015-07-08T09:34:32.737" Score="1" Body="&lt;p&gt;Why do you think it should show 0 when not connected to anything?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the antenna of your radio give a zero signal just because the end isn't connected to anything?  An Arduino's input pin (either analog or digital) is just the same.  If it isn't connected to anything then it just picks up noise - be that radio transmissions, induction from nearby mains wiring, neutrinos from Alpha Centauri...  Basically if it's not connected to anything then there is &lt;em&gt;no way&lt;/em&gt; you can possibly know what the value should be since there &lt;em&gt;is no set value&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to read 0 on the ADC the ADC has to be connected 0V.  That means connect it to ground. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-08T09:34:32.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13267" PostTypeId="2" ParentId="13245" CreationDate="2015-07-08T11:16:02.007" Score="1" Body="&lt;p&gt;Here is my take at this. I realize that I did not really make the&#xA;program simpler, but hopefully better in some respects, as it avoids&#xA;blocking reads and heap memory allocation. Be warned however that I did&#xA;not test it. It compiles fine though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preamble, hopefully simple enough that it requires no comments:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const uint8_t led_pin = 13;&#xA;&#xA;void setup() {&#xA;    Serial.begin(57600);  &#xA;    pinMode(led_pin, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, here is a function to read the HTTP request. A few things are&#xA;worth noting in this function:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is non-blocking: if there is not data in the serial buffer, it will&#xA;return &lt;code&gt;NULL&lt;/code&gt; immediately. This is to prevent the whole program from&#xA;hanging if the client does not terminate its request.&lt;/li&gt;&#xA;&lt;li&gt;It only saves the first 31 bytes of the request. This is because&#xA;browsers tend to add lots of useless headers, which can be unfriendly&#xA;to the memory of a small Arduino. And the only interesting piece of&#xA;data is at the very beginning anyway.&lt;/li&gt;&#xA;&lt;li&gt;The request terminating sequence (CR LF CR LF) is detected without&#xA;having to store it in the buffer, just by counting how many&#xA;consecutive bytes of that sequence we have already received.&lt;/li&gt;&#xA;&lt;li&gt;Declaring the function as &lt;code&gt;static&lt;/code&gt; makes it possible for the compiler&#xA;to inline it, which it does as it is only called from one place. This&#xA;makes for a smaller executable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Non-blocking read. Returns the first bytes of the request in a static&#xA; * buffer, or NULL if we do not have a complete request yet.&#xA; */&#xA;static char * read_request() {&#xA;    static char buffer[32];&#xA;    static uint8_t pos;&#xA;    static uint8_t crlf_bytes;  // bytes of &quot;\r\n\r\n&quot; received&#xA;&#xA;    while (Serial.available()) {&#xA;        char c = Serial.read();&#xA;&#xA;        // Store the received byte if there is enough room.&#xA;        if (pos &amp;lt; sizeof buffer - 1)&#xA;            buffer[pos++] = c;&#xA;&#xA;        // Update the count of consecutive CRLF bytes received.&#xA;        if ((c == '\r' &amp;amp;&amp;amp; crlf_bytes % 2 == 0)&#xA;         || (c == '\n' &amp;amp;&amp;amp; crlf_bytes % 2 == 1))&#xA;            crlf_bytes++;&#xA;        else&#xA;            crlf_bytes = 0;&#xA;&#xA;        // Return the buffer if we have a complete request.&#xA;        if (crlf_bytes == 4) {&#xA;            buffer[pos] = '\0';  // terminate the string&#xA;            pos = 0;&#xA;            crlf_bytes = 0;&#xA;            return buffer;&#xA;        }&#xA;    }&#xA;    return NULL;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parsing the request is done by a different function. Here, I do not&#xA;search for the &quot;GET /blink?f=&quot; string, because it &lt;em&gt;must&lt;/em&gt; be at the very&#xA;beginning for the request to be valid.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Returns the requested frequency, or 0 if nothing valid is found.&#xA; */&#xA;static int parse_request(char *request) {&#xA;&#xA;    /* The &quot;GET&quot; should be at the very beginning. */&#xA;    if (strncmp(request, &quot;GET /blink?f=&quot;, 13) != 0)&#xA;        return 0;&#xA;&#xA;    return atoi(request + 13);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we can send the response to the client, telling it how we parsed the&#xA;frequency. I avoid using &lt;code&gt;String&lt;/code&gt;, as it involves heap allocation, and I&#xA;put the bulk of the response in PROGMEM (&lt;code&gt;F()&lt;/code&gt; macro) to save RAM. I&#xA;also added a &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; to make it valid HTML.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Tell the client how we understood the requested frequency.&#xA; */&#xA;static void send_response(int freq) {&#xA;    char freq_str[12];&#xA;    itoa(freq, freq_str, 10);&#xA;    Serial.print(F(&quot;HTTP/1.1 200 OK\r\n&quot;&#xA;                   &quot;Content-Type: text/html\r\n&quot;&#xA;                   &quot;Content-Length: &quot;));&#xA;    Serial.print(84 + strlen(freq_str));&#xA;    Serial.print(F(&quot;\r\nConnection: close\r\n\r\n&quot;&#xA;                   &quot;&amp;lt;!DOCTYPE html&amp;gt;\n&quot;&#xA;                   &quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Blink&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;\n&quot;&#xA;                   &quot;LED frequency: &quot;));&#xA;    Serial.print(freq_str);&#xA;    Serial.print(F(&quot; Hz.\n&amp;lt;/html&amp;gt;\n&quot;));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next function blinks the LED in a rollover-safe fashion. Storing the&#xA;current LED state in a static variable avoids a call to &lt;code&gt;digitalRead()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;static void blink_led(unsigned long toggle_time) {&#xA;    static uint8_t led_state;&#xA;    static unsigned long last_toggle;&#xA;    unsigned long now = millis();&#xA;    if (now - last_toggle &amp;gt; toggle_time) {&#xA;        led_state = !led_state;&#xA;        digitalWrite(led_pin, led_state);&#xA;        last_toggle = now;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting it all together, the main &lt;code&gt;loop()&lt;/code&gt; ends up being quite straight&#xA;forward:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static unsigned long period = 1000;&#xA;    char * request = read_request();&#xA;    if (request) {&#xA;        int freq = parse_request(request);&#xA;        if (freq &amp;gt; 0) period = 1000 / freq;&#xA;        send_response(freq);&#xA;    }&#xA;    blink_led(period);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS&lt;/strong&gt;: My version is significantly larger than the original at the&#xA;source level (66 v.s. 44 source lines of code), but the compiled program&#xA;is smaller in both flash and RAM usage:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;text    data     bss     version&#xA;5646     168     197     original&#xA;3316      40     218     my version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-07-08T11:26:42.557" LastActivityDate="2015-07-08T11:26:42.557" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13268" PostTypeId="1" AcceptedAnswerId="13270" CreationDate="2015-07-08T11:47:07.673" Score="0" ViewCount="803" Body="&lt;p&gt;I new to Arduino and I'm attempting to writte a simple string compare code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{  &#xA;  distance(cm);&#xA;  delay(200);    &#xA;}&#xA;&#xA;void distance(char[3] unit) &#xA;{&#xA;  if (unit[] == &quot;cm&quot;) &#xA;    Serial.println(&quot;cm&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could somebody please advise me how to writte it correctly? &#xA;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="11074" LastActivityDate="2015-07-08T15:26:55.543" Title="How to writte simple string compare?" Tags="|string|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13269" PostTypeId="2" ParentId="13178" CreationDate="2015-07-08T11:52:42.940" Score="6" Body="&lt;p&gt;I'm posting an answer just for completeness, after finding out and testing a way of declaring &lt;em&gt;and&lt;/em&gt; implementing a class in the same .cpp file, without using a header. So, regarding the exact phrasing of my question &quot;how many file types do I need to use classes&quot;, the present answer uses two files: one .ino with an include, setup and loop, and the .cpp containing the whole (rather minimalistic) class, representing the turning signals of a toy vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blinker.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TurnSignals.cpp&amp;gt;&#xA;&#xA;TurnSignals turnSignals(2, 4, 8);&#xA;&#xA;void setup() { }&#xA;&#xA;void loop() {&#xA;  turnSignals.run();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;TurnSignals.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;class TurnSignals&#xA;{&#xA;    int &#xA;        _left, &#xA;        _right, &#xA;        _buzzer;&#xA;&#xA;    const int &#xA;        amberPeriod = 300,&#xA;&#xA;        beepInFrequency = 600,&#xA;        beepOutFrequency = 500,&#xA;        beepDuration = 20;    &#xA;&#xA;    boolean&#xA;        lightsOn = false;&#xA;&#xA;    public : TurnSignals(int leftPin, int rightPin, int buzzerPin)&#xA;    {&#xA;        _left = leftPin;&#xA;        _right = rightPin;&#xA;        _buzzer = buzzerPin;&#xA;&#xA;        pinMode(_left, OUTPUT);&#xA;        pinMode(_right, OUTPUT);&#xA;        pinMode(_buzzer, OUTPUT);            &#xA;    }&#xA;&#xA;    public : void run() &#xA;    {        &#xA;        blinkAll();&#xA;    }&#xA;&#xA;    void blinkAll() &#xA;    {&#xA;        static long lastMillis = 0;&#xA;        long currentMillis = millis();&#xA;        long elapsed = currentMillis - lastMillis;&#xA;        if (elapsed &amp;gt; amberPeriod) {&#xA;            if (lightsOn)&#xA;                turnLightsOff();   &#xA;            else&#xA;                turnLightsOn();&#xA;            lastMillis = currentMillis;&#xA;        }&#xA;    }&#xA;&#xA;    void turnLightsOn()&#xA;    {&#xA;        tone(_buzzer, beepInFrequency, beepDuration);&#xA;        digitalWrite(_left, HIGH);&#xA;        digitalWrite(_right, HIGH);&#xA;        lightsOn = true;&#xA;    }&#xA;&#xA;    void turnLightsOff()&#xA;    {&#xA;        tone(_buzzer, beepOutFrequency, beepDuration);&#xA;        digitalWrite(_left, LOW);&#xA;        digitalWrite(_right, LOW);&#xA;        lightsOn = false;&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8044" LastActivityDate="2015-07-08T11:52:42.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13270" PostTypeId="2" ParentId="13268" CreationDate="2015-07-08T12:14:43.873" Score="0" Body="&lt;pre&gt;&lt;code&gt;if (strcmp (unit,&quot;cm&quot;) == 0) {&#xA;&#xA;    // matches cm&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For syntax like this the intellisense in products such as Atmel Studio or Visual Studio can really help. Whilst you still need to understand what you might be looking for the intellisense makes all the available Arduino functions visible from the code. If you install the Arduino plugin then there will be an Arduino reference explorer in both ide's which explains everything. &lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-07-08T15:26:55.543" LastActivityDate="2015-07-08T15:26:55.543" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13271" PostTypeId="1" CreationDate="2015-07-08T12:54:21.283" Score="1" ViewCount="954" Body="&lt;p&gt;I'm making a POV project and need to count the RPM of the DC Motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I purchased a Hall Effect Sensor and it seems to work perfectly at slow speeds, however once the motor speeds up, the sensor doesn't pick up the magnet at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the sensor is at:&#xA;&lt;a href=&quot;http://cdn.shopify.com/s/files/1/0045/8932/files/AH180.pdf?100744&quot; rel=&quot;nofollow&quot;&gt;http://cdn.shopify.com/s/files/1/0045/8932/files/AH180.pdf?100744&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one of my first projects and I'm not sure what I should be looking for on the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor came as part of this product:&#xA;&lt;a href=&quot;http://www.freetronics.com.au/pages/hall-effect-magnetic-and-proximity-sensor-module-quickstart-guide#.VZ0Zs_meDGc&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/pages/hall-effect-magnetic-and-proximity-sensor-module-quickstart-guide#.VZ0Zs_meDGc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There doesn't seem to be a problem with the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 13;&#xA;volatile int state = LOW;&#xA;volatile int tcnt = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(pin, OUTPUT);&#xA;  attachInterrupt(1, blink, CHANGE);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(pin, state);&#xA;  Serial.println(tcnt);&#xA;&#xA;}&#xA;&#xA;void blink()&#xA;{&#xA;  tcnt = tcnt + 1;&#xA;  state = !state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11025" LastActivityDate="2015-07-08T13:23:21.153" Title="Hall Effect Sensor for POV Project" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13272" PostTypeId="2" ParentId="13271" CreationDate="2015-07-08T13:23:21.153" Score="1" Body="&lt;p&gt;From the datasheet of the hall effect sensor, the thing is only checking for 125usec in every 125msec - so if your magnet whizzes by in &amp;lt;100msec it will miss it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously you haven't stated the speed your magnet passes your sensor, but as it's only active 0.1% of the time, this seems the likely reason to miss.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you put it nearer the shaft/axle ?&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-07-08T13:23:21.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13273" PostTypeId="2" ParentId="13107" CreationDate="2015-07-08T14:43:30.083" Score="0" Body="&lt;p&gt;Visual Micro provides this for you if you have the debug module enabled. It also optionally shows analog, memory and i2c. Read more about &lt;a href=&quot;http://www.visualmicro.com/page/Debugging-for-Arduino.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino debug and the digital pin viewer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/TsFgI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-08T14:43:30.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13274" PostTypeId="2" ParentId="482" CreationDate="2015-07-08T14:50:04.423" Score="1" Body="&lt;p&gt;This might not be right for you, but the &lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Visual Micro&lt;/a&gt; plugin for Atmel Studio and Visual Studio has a &lt;a href=&quot;http://www.visualmicro.com/page/Debugging-for-Arduino.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB debugger&lt;/a&gt; which only uses Arduino code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the background the debugger uses Serial which might affect some time-sensitive applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Mqkn.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="510" LastEditDate="2017-09-16T13:15:25.497" LastActivityDate="2017-09-16T13:15:25.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13275" PostTypeId="1" AcceptedAnswerId="13286" CreationDate="2015-07-08T15:14:07.387" Score="1" ViewCount="1644" Body="&lt;p&gt;I want to know if it is possible to use an arduino to tell a pc which os to boot to. I know It is possible to turn on the pc by wiring it to the motherboard pins with the power switch, and I know the arduino I have (&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E5WJSHK&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/SainSmart-ATmega328P-Development-Compatible-Arduino/dp/B00E5WJSHK/ref=sr_1_1?ie=UTF8&amp;amp;qid=1436368217&amp;amp;sr=8-1&amp;amp;keywords=sainsmart+uno+r3&lt;/a&gt;) can act as a mouse or keyboard. Can that be done before the pc has booted however?&lt;/p&gt;&#xA;" OwnerUserId="11076" LastActivityDate="2015-07-09T03:24:59.540" Title="Using Arduino To Control Boot Sequence of PC" Tags="|keyboard|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13276" PostTypeId="2" ParentId="9484" CreationDate="2015-07-08T15:16:58.290" Score="0" Body="&lt;p&gt;I do exactly this with an ATtiny You have 32 bit long that needs to be broken up into 4 8-bit chunks. You need to some simple bit shifting to accomplish this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned long Data1;//this is the data you are sending&#xA;volatile byte SendCount;&#xA;volatile uint8_t sendByte;&#xA;&#xA;void requestEvent()&#xA;{  &#xA;&#xA;  SendCount++; //increment this&#xA;  switch (SendCount)&#xA;  {&#xA;    case 1:&#xA;      Data1 = GetMyData();&#xA;      //Data1 = 55555;&#xA;      sendByte = Data1 &amp;amp; 0xFF;&#xA;      break;&#xA;    case 2:&#xA;      sendByte = Data1 &amp;gt;&amp;gt; 8;&#xA;      break;&#xA;    case 3:&#xA;      sendByte = Data1 &amp;gt;&amp;gt; 16;&#xA;      break;&#xA;    case 4:&#xA;      sendByte = Data1 &amp;gt;&amp;gt; 24;&#xA;      SendCount=0;&#xA;      break;&#xA;  }&#xA;&#xA;  TinyWireS.send(sendByte);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to initialize &lt;code&gt;SendCount = 0;&lt;/code&gt; in your Setup method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to recompose the 4 bits back into a 32 bit long on the Master device too.&lt;/p&gt;&#xA;" OwnerUserId="11075" LastActivityDate="2015-07-08T15:16:58.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13279" PostTypeId="1" CreationDate="2015-07-08T09:04:25.033" Score="4" ViewCount="332" Body="&lt;p&gt;I am trying to program an atmega with arduino sketch using ISP only (mac user).&#xA;So I know how to burn a boot loader, and then to program the chip using the TX, RX. But I would like to program it directly using ISP, without a boot loader.&#xA;So I am using the UNO as a ISP programmer, and trying without success to program a chip on a PCB:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I upload to the UNO the ArduinoISP sketch &lt;/li&gt;&#xA;&lt;li&gt;Connect the lines to the target board (target board have atmega328, crystal, capacitors, LED)&lt;/li&gt;&#xA;&lt;li&gt;Choose the board &quot;Arduino pro or pro mini&quot; in the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;Choose the programmer- &quot;Arduino as ISP&quot;&lt;/li&gt;&#xA;&lt;li&gt;At the beginning I tried to upload a boot loader, to see if its going well, it DID boot loaded the chip,so I know the connections are good, and I am set to go.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now, I am trying to just upload a sketch using the SAME ISP connection, I didn't touch anything(!)&lt;/strong&gt; , so I opened the blinking example, hit the upload button, and it's just not working (not in sync).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, the goal is now to program a chip with ISP directly, without a boot loader. The reason I boot loaded it is to see it's all connected well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't imagine how the exact same configuration can bootload the chip,and later can't upload a sketch directly using the ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? Can't you use the Arduino IDE to upload a sketch directly as an ISP programmer?&lt;/p&gt;&#xA;" OwnerUserId="4989" OwnerDisplayName="Curnelious" LastEditorDisplayName="user6430" LastEditDate="2015-07-12T09:21:21.673" LastActivityDate="2020-11-18T05:36:50.467" Title="Programming an AVR using ISP" Tags="|avr|isp|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13280" PostTypeId="2" ParentId="13255" CreationDate="2015-07-08T19:26:58.723" Score="3" Body="&lt;p&gt;I assume that by&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm also really looking for the avg Top 4 values.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;you mean that you will find the largest four numbers and report their average.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, you can sort all the values (as in previous answer) and then average the last four numbers (or first four, depending on sort order) from the sorted array.  This has complexity &lt;em&gt;O(n lg n)&lt;/em&gt;, that is, sort time grows with array size &lt;em&gt;n&lt;/em&gt; as the product &lt;em&gt;n&lt;/em&gt; times logarithm of &lt;em&gt;n&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you can keep track of the largest four values as you iterate through the array, via technique illustrated in code at the end of this answer.  This has complexity &lt;em&gt;O(n lg k)&lt;/em&gt;, that is, sort time grows with array size &lt;em&gt;n&lt;/em&gt; and number &lt;em&gt;k&lt;/em&gt; of high values as the product &lt;em&gt;n&lt;/em&gt; times logarithm of &lt;em&gt;k&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In using &lt;code&gt;qsort&lt;/code&gt;, I prefer (in this edit) to write the comparator function more compactly, although possibly less transparently, by using &lt;code&gt;*(int*)a&lt;/code&gt; to reference the value that &lt;code&gt;a&lt;/code&gt; points to.   For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Comparator function for integers&#xA;int compareInt (const void *a, const void *b) {&#xA;  // Return -, 0, or + if first value is &amp;lt;, =, or &amp;gt; second value.&#xA;  return *(int*)a - *(int*)b;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make the comparator sort descending (so that the largest four numbers appear in array's first four slots) by using &lt;code&gt;return *(int*)b -*(int*)a;&lt;/code&gt; instead of the &lt;code&gt;return&lt;/code&gt; that's shown.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Templated, the function looks as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt;typename T&amp;gt;&#xA;// Comparator function for Numbers&#xA;int compareNumber (const void *a, const void *b) {&#xA;  // Return -, 0, or + if first value is &amp;lt;, =, or &amp;gt; second value.&#xA;  return *(T*)a -*(T*)b;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I called the routine &lt;code&gt;compareNumber&lt;/code&gt; because it uses subtraction to find out which operand is larger.  But as explained in arduino.cc's &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/StringComparisonOperators&quot; rel=&quot;nofollow noreferrer&quot;&gt;String Comparison Operators&lt;/a&gt; page, for Arduino &lt;code&gt;String&lt;/code&gt;-type objects, subtraction is bound to string comparison, so the above templated function works with &lt;code&gt;String&lt;/code&gt; objects as well as numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For C-type strings, which are character arrays terminated by a null character, &lt;em&gt;ie&lt;/em&gt; of &lt;code&gt;char*&lt;/code&gt; or &lt;code&gt;char[]&lt;/code&gt; type, the &lt;code&gt;strcmp()&lt;/code&gt; function can be used directly as &lt;code&gt;qsort()&lt;/code&gt;'s comparator function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qsort(arrayOfPointersToCStrings, elementCount, pointersize, strcmp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, there is no reason to write a separate comparator function with a call to &lt;code&gt;strcmp()&lt;/code&gt;; just reference &lt;code&gt;strcmp()&lt;/code&gt; directly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When you have a small, fixed number of values to process, just doing a sort is reasonable.  The algorithmic complexity is &lt;code&gt;O(n*lg n)&lt;/code&gt;, and if &lt;code&gt;n&lt;/code&gt; is fixed, this is basically &lt;code&gt;O(1)&lt;/code&gt;. If, however, you were processing extremely large data sets and wanted to identify the largest four numbers without storing all the other numbers, you can track the largest four by keeping the four largest numbers so far seen in an array.  This has algorithmic complexity that is &lt;code&gt;O(n*k)&lt;/code&gt; at worst, where &lt;code&gt;k&lt;/code&gt; is the number of elements tracked; and for fixed &lt;code&gt;k&lt;/code&gt;, this is &lt;code&gt;O(n)&lt;/code&gt;.  If &lt;code&gt;k&lt;/code&gt; is large or variable, a tree method can be used to get complexity &lt;code&gt;O(n*lg k)&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyhow, suppose the array is &lt;code&gt;int largestSoFar[4]&lt;/code&gt;.    Initialize each entry in that array to some number smaller than any valid data item; eg, to &lt;code&gt;INT_MIN&lt;/code&gt; from &lt;code&gt;&amp;lt;limits.h&amp;gt;&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As each new data item arrives, compare it to &lt;code&gt;largestSoFar[0]&lt;/code&gt;.  If it's less or equal, go get the next data item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Else, the new value is one of the largest values so far seen.  Store it in &lt;code&gt;largestSoFar[0]&lt;/code&gt;, then have a loop to do compare-and-swap steps to ripple the new number up to its appropriate level.  That is, compare elements [0] and [1]; break if &lt;code&gt;largestSoFar[0]&amp;lt;largestSoFar[1]&lt;/code&gt;, else swap[0] and [1] and go on to compare-and-swap for elements [1] and [2], etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code below (shown as a standalone C program, rather than as an Arduino sketch) illustrates the technique.  Here is what it prints out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Linear result:   2654  2720  2815  2961  2968  9662    Total: 23780&#xA;Sorting result:  9662  2968  2961  2815  2720  2654    Total: 23780&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the standalone C program illustrating a linear (&lt;code&gt;O(1)&lt;/code&gt;) method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;limits.h&amp;gt;&#xA;&#xA;// Comparator function&#xA;int intCompare(const void *va, const void *vb) {&#xA;  const int a = *(int*)va, b = *(int*)vb;&#xA;  // (a&amp;gt;b) is 1 if a&amp;gt;b, else 0.  (b&amp;gt;a) is 1 if b&amp;gt;a, else 0.&#xA;  // So the following expression has value 1, 0, or -1.&#xA;  return (b&amp;gt;a) - (a&amp;gt;b); // To sort descending&#xA;}&#xA;&#xA;int main () {&#xA;  int someNumbers [] = { 481,  1041, 107,  279,  809, 2052,  2961, 557, &#xA;             2534, 2968, 89,   839,  2720,  85,  2115, 898, &#xA;             1931, 655,  2631, 1897, 2322, 1115, 2815, 674,&#xA;             2259, 176,  598,  525,  600,  1088, 1885, 313,&#xA;             1175, 2654, 915,  536,  978,  2052, 798, 1979,&#xA;             2571, 2154, 1138, 259, 9662  };&#xA;  enum { NumTop = 6, NumNum = (sizeof someNumbers)/sizeof(int) };&#xA;  int i, j, tot, largestSoFar[NumTop];&#xA;&#xA;  for (i = 0; i &amp;lt; NumTop; ++i)&#xA;    largestSoFar[i] = INT_MIN;  // Init. largestSoFar[] to smallest numbers&#xA;&#xA;  // Process all the numbers&#xA;  for (j = 0; j &amp;lt; NumNum; ++j) {&#xA;    if (someNumbers[j] &amp;lt;= largestSoFar[0])&#xA;      continue;&#xA;    // Install number into largestSoFar[] and bubble it up&#xA;    largestSoFar[0] = someNumbers[j];&#xA;    for (i = 1; i &amp;lt; NumTop; ++i) {&#xA;      if (largestSoFar[i] &amp;lt; largestSoFar[i-1]) {&#xA;        int t = largestSoFar[i];&#xA;        largestSoFar[i] = largestSoFar[i-1];&#xA;        largestSoFar[i-1] = t;&#xA;      }&#xA;      else break;&#xA;    }&#xA;  }&#xA;  printf (&quot;Linear result:  &quot;);&#xA;  for (i = tot = 0; i &amp;lt; NumTop; ++i) {&#xA;    printf (&quot;%5d &quot;, largestSoFar[i]);&#xA;    tot += largestSoFar[i];&#xA;  }&#xA;  printf (&quot;   Total: %d\n&quot;, tot);&#xA;&#xA;  // sort the array descending, for comparison&#xA;  qsort (someNumbers, NumNum, sizeof(int), intCompare);&#xA;  printf (&quot;Sorting result: &quot;);&#xA;  for (i = tot = 0; i &amp;lt; NumTop; ++i) {&#xA;    printf (&quot;%5d &quot;, someNumbers[i]);&#xA;    tot += someNumbers[i];&#xA;  }&#xA;  printf (&quot;   Total: %d\n&quot;, tot);&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2017-05-11T14:51:20.837" LastActivityDate="2017-05-11T14:51:20.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13281" PostTypeId="2" ParentId="13002" CreationDate="2015-07-08T20:47:29.840" Score="1" Body="&lt;p&gt;At the end two pull-up resistors and one capacitor solved the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed instruction here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Brushless-Gimbal-with-Arduino/step3/Using-the-Accelerometer-and-Gyro/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Brushless-Gimbal-with-Arduino/step3/Using-the-Accelerometer-and-Gyro/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it works well.. Thank you all.&lt;/p&gt;&#xA;" OwnerUserId="10910" LastActivityDate="2015-07-08T20:47:29.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13282" PostTypeId="1" CreationDate="2015-07-08T21:18:00.227" Score="1" ViewCount="1663" Body="&lt;p&gt;I am trying to read data from uBlox NEO-6m (I need just speed, just part of the code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;static const int RXPin = 7, TXPin = 4;&#xA;static const uint32_t GPSBaud = 9600;&#xA;&#xA;float gps_speed = 0;&#xA;&#xA;// The TinyGPS++ object&#xA;TinyGPSPlus gps;&#xA;&#xA;// The serial connection to the GPS device&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;void setup(){&#xA;ss.begin(GPSBaud);&#xA;}&#xA;&#xA;void loop(){&#xA;if (ss.available())&#xA;    {&#xA;      gps.encode(ss.read());&#xA;      gps_speed = gps.speed.kmph();&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the same time I read data from MPU6090 using this code (gps code is integrated in it):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://nevit.blogspot.de/2014/07/arduino-mpu-6050-pitch-roll-with-2.html&quot; rel=&quot;nofollow&quot;&gt;http://nevit.blogspot.de/2014/07/arduino-mpu-6050-pitch-roll-with-2.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to read data separately it works but together it stuck every second (probably reading of gps data) and MPU6050 serial monitor sending FIFO overflow error .. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to lower MPU data rate to 20Hz from 100Hz but it didn't work. I use Arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not so much skilled.. Any idea? Is it even possible to do it like this?&lt;/p&gt;&#xA;" OwnerUserId="10910" LastActivityDate="2018-04-28T20:49:19.800" Title="FIFO overflow - reading IMU MPU6090 and GPS uBlox NEO-6M at once" Tags="|arduino-uno|gps|mpu6050|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13283" PostTypeId="2" ParentId="13282" CreationDate="2015-07-08T22:26:17.027" Score="0" Body="&lt;p&gt;A guess; Software serial is known for messing with interrupts, in fact I think the rule of thumb is do not use interrupts and software serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MPU code you are using is classic Jeff Rowberg, and uses interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, there are things you can do, where an occasional overflow does not cause problems, but that is way too deep to explain here, sorry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I think I will end up using the arduino to handle the MPU, and attaching it and a GPS to a raspberry pi, and let it merge the two.  You might be able to accomplish something similar with a bigger Arduino if there is one with 2 (or more) uart serial ports, but I do not have experience with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can speed up the GPS serial rate, give that a try, it actually helps (which is counter intuitive).&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-07-08T22:26:17.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13284" PostTypeId="1" CreationDate="2015-07-09T01:08:12.630" Score="0" ViewCount="509" Body="&lt;p&gt;I want to implement a digital controller C(z) on an Arduino Uno&#xA;(transfer function in the z domain) in order to control a plant&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;G(s) = 3750/[(s+10)(s+30)(s+100)].&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have implemented G(s) with electronics (op-amps, capacitors and&#xA;resistances). I want to realize C(z) on the Arduino Uno. The input to&#xA;the Arduino is the error signal &lt;code&gt;(reference − output of G)&lt;/code&gt; and the&#xA;output of C(z) is the input of G(s). Finally, I will have a closed loop&#xA;system with negative unit feedback. The reference input is a unit step&#xA;signal (1 volt).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is: how can I use PWM and filters in place of a DAC?&lt;/p&gt;&#xA;" OwnerUserId="10994" LastEditorUserId="7508" LastEditDate="2015-07-09T07:52:47.483" LastActivityDate="2015-08-08T08:45:06.307" Title="PWM-FILTERS -DAC" Tags="|pwm|digital-analog-conversion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13285" PostTypeId="1" AcceptedAnswerId="13560" CreationDate="2015-07-09T03:12:15.517" Score="0" ViewCount="354" Body="&lt;p&gt;I am new in Arduino but I have experience in electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering how can I make a countdown timer using a CD4510 and an Arduino UNO. I know you would suggest that I should connect my seven segment display on the IO pins but I can't do that because I will use multiple seven segment displays.&lt;/p&gt;&#xA;" OwnerUserId="10809" LastEditorUserId="9962" LastEditDate="2015-07-18T15:25:43.097" LastActivityDate="2015-07-19T04:47:40.643" Title="Arduino UNO with CD4510 Counter" Tags="|arduino-uno|programming|timers|display|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13286" PostTypeId="2" ParentId="13275" CreationDate="2015-07-09T03:24:59.540" Score="2" Body="&lt;p&gt;So it might depend on how you implement it. With an Arduino Uno, your options for creating an HID device are limited to either reprogramming the 16u2 (which will require an ISP) or using a software USB implementation (like V-USB). If you go with the first method I'm pretty sure that will work as it will be a native USB connection. As for the second method, I'm not sure how well V-USB responds to having the USB host turning on while it is running. The best thing to do is just try it and see how well it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bigger challenge you will run into is being able to select your PC operating system. Because this will be a one way connection, there is no way of knowing what state the computer is in and whether or not it is time to press a key yet or not. This means you will have to be timing things fairly accurately, which can be tricky unless you are careful. The internal oscillator is not very accurate (but probably still accurate enough) and interrupts used for communicating with USB can block the main loop. That is not to mention any variations the computer might have in its boot process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good alternative method would be to set up a bootloader on your PC that can be controlled via a serial port. GRUB2 is a popular one that does support a &lt;a href=&quot;https://wiki.archlinux.org/index.php/Working_with_the_serial_console&quot; rel=&quot;nofollow&quot;&gt;serial console&lt;/a&gt;. All you would need to do is add a level adjuster to adapt the Arduino UART to RS232, then set up the code to wait for the GRUB prompt and then send the command necessary to select which OS you wish to use.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-09T03:24:59.540" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13287" PostTypeId="1" AcceptedAnswerId="13318" CreationDate="2015-07-09T04:32:24.343" Score="3" ViewCount="8733" Body="&lt;p&gt;I have a Photo Interrupter which I am using to count the RPM of a motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am incrementing an integer to show the amount of interrupts there have been.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that there can be several interrupts fired for each time the &quot;beam&quot; of the Photo Interrupter is broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a 5mm length of plastic which breaks the &quot;beam&quot;. If I make the plastic shorter than that, the Photo Interrupter doesn't pick up the break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following, very basic code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 13; &#xA;volatile  int tcnt = 0; &#xA;volatile int state = LOW; &#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA;  pinMode(pin, OUTPUT); &#xA;  attachInterrupt(0, blink, CHANGE); &#xA;} &#xA;&#xA;void loop() { &#xA;  Serial.println(tcnt); &#xA;  digitalWrite(pin, state); &#xA;} &#xA;&#xA;void blink() { &#xA;  tcnt = tcnt + 1; &#xA;  state = !state; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11025" LastActivityDate="2015-07-19T16:22:44.303" Title="Interrupt fires multiple times" Tags="|arduino-uno|programming|interrupt|sketch|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13288" PostTypeId="2" ParentId="13287" CreationDate="2015-07-09T05:05:36.977" Score="0" Body="&lt;p&gt;As far as it firing multiple times, are you aware that you have the interrupt mode set to CHANGE? This means the interrupt will fire once when something enters the beam, and again when something leaves the beam. You will probably want to set it to RISING or FALLING so that it only fires on one of those events, not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the not detecting issue I can think of a few reasons why this could be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your motor is moving so fast that the sensor changes again before it has had the chance to finish the interrupt service routine and reset the interrupt on the pin. &lt;/li&gt;&#xA;&lt;li&gt;The photo interrupter you are using is too slow to report the piece of plastic passing through it. Sensors like this usually indicate a rise time and a fall time, and if it moves through the beam faster than these times it will not register the interruption.&lt;/li&gt;&#xA;&lt;li&gt;The piece of plastic isn't large enough to block the beam. Depending on the photo interrupter, the beam used could be laser like and very narrow, or it could be wide and more like a flashlight. If it is more like the latter, you will need to have enough material present to block enough light to set off the sensor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-09T05:05:36.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13289" PostTypeId="1" CreationDate="2015-07-09T05:09:01.733" Score="1" ViewCount="428" Body="&lt;p&gt;I am trying to use the Arduino Uno with the LMT86LP temperature sensor, but I am getting strange output voltages from the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the pins (from left to right, flat side facing forward) as VDD, OUT, and GND. VDD is connected to 5V, GND to GND, and Vout to A0 (analog pin 0). The readings from the Arduino are consistently around 360 mV but should be somewhere around 1800 mV as I measured the output of the sensor using a multimeter and got a constant 1.8 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now the code is very simple. I am just doing &lt;code&gt;analogRead()&lt;/code&gt; and printing to the Serial Monitor.&lt;/p&gt;&#xA;" OwnerUserId="11088" LastEditorUserId="26916" LastEditDate="2017-11-04T06:57:37.310" LastActivityDate="2017-11-04T06:57:37.310" Title="Arduino UNO with LMT86LP temperature sensor" Tags="|arduino-uno|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13290" PostTypeId="2" ParentId="13289" CreationDate="2015-07-09T05:12:56.250" Score="1" Body="&lt;p&gt;The result from &lt;code&gt;analogRead()&lt;/code&gt; is in counts of full scale, not in volts. Since you are using a 10-bit ADC, full scale is 1024.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.8V/5V⋅1024=368.64&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-09T05:12:56.250" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13291" PostTypeId="1" AcceptedAnswerId="15982" CreationDate="2015-07-09T05:29:12.983" Score="1" ViewCount="1695" Body="&lt;p&gt;I am trying to connect the wireless module nrf24l01 with the gyro mpu-6050.  Each works perfectly on its own.  However, when connecting both to a single atmega328 (in order to send over wireless the gyro data), the code runs for between 30 seconds and 5 minutes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen many people have issues, none of the suggestions have worked, but it seems like it is more about the combination than the mpu itself.  I have not had any errors, in that all the attempts have uploaded fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things I have tried (If you have experience with this device, im sure you will know what i am referring to ):&#xA;Changing clock rates from 24 to 12, and 400 to 200&#xA;Changing the header file for mpu from 100 hz to 20 hz and back&#xA;Adding pullup and pulldown resistors on sla/sda&#xA;Using external variable power supply to make sure exact voltage&#xA;Powering devices off arduino 3.3 and external 3.3&#xA;Running code without using serial reader on computer and just transmitting data&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After more debugging, I reduced the issue (I think).  As each module works fine independently, i thought there could be a code issue.  It seems though, that the issue is the combination of buffers.  I don't think this is exactly right, but to us it seems like the gyro needs to run quickly to stop the risk of causing the arduino to hang(even though we clear the buffer). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second part is the wireless.  It seems like the code is looking by default for an acknowledgment the package is received.  This slows down the broadcasting.  So, if we disable the ack requirement, the gyro becomes stable.  However, the receiver stops receiving any packets at all.  If someone knows why, please explain.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what we thought would work is by sending only some packets as the write with ack on a particular pipe.  This way, the gyro will be able to run stably, and the data can sometimes be sent and we can see if this is really the problem.  Again, this does not get recognized by the receiver at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions:&#xA;Does it make sense that the buffers are working against eachother, and this is not solvable through hardware.&#xA;Is there a clear reason why the receiver can not find packets that are being sent, just without the ack requirement?&lt;/p&gt;&#xA;" OwnerUserId="11089" LastEditorUserId="11089" LastEditDate="2015-07-10T01:48:45.527" LastActivityDate="2016-11-13T21:45:22.457" Title="Using nrf24l01 with mpu 6050 unstable" Tags="|nrf24l01+|mpu6050|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13292" PostTypeId="1" AcceptedAnswerId="13293" CreationDate="2015-07-09T05:46:30.023" Score="105" ViewCount="111799" Body="&lt;p&gt;I can't upload sketches to my Arduino Uno. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Have I &quot;bricked&quot; it? &lt;/li&gt;&#xA;&lt;li&gt;What steps can I take to work out what is wrong?&lt;/li&gt;&#xA;&lt;li&gt;What can I do to fix it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-22T00:03:54.090" LastActivityDate="2021-02-18T10:09:26.493" Title="Have I bricked my Arduino Uno? Problems with uploading to board" Tags="|arduino-uno|uploading|atmega328|icsp|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13293" PostTypeId="2" ParentId="13292" CreationDate="2015-07-09T05:46:30.023" Score="139" Body="&lt;h2&gt;It probably isn't bricked&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've got quite a few Arduinos, and over the last few years have only ever &quot;bricked&quot; one, and I think that was by zapping it with static electricity. Unfortunately that particular one had a SMD (surface mounted) processor chip, so it isn't easy to try swapping it with another chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stay calm, and try the following steps ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example board&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An &quot;Arduino Uno&quot; is not just one &lt;em&gt;thing&lt;/em&gt; that might fail. It has multiple major components, and possibly only one has failed (if any). See this reference photograph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uxIPv.jpg&quot; alt=&quot;Arduino Uno major components&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Major components are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Atmega16U2 processor - this handles the interface to the USB connection&lt;/li&gt;&#xA;&lt;li&gt;Atmega328P processor - this is the &quot;main&quot; processor which has your sketch on it&lt;/li&gt;&#xA;&lt;li&gt;Voltage regulator - this converts incoming power from the power jack to 5 V&lt;/li&gt;&#xA;&lt;li&gt;Power LED (green) - marked &quot;On&quot;&lt;/li&gt;&#xA;&lt;li&gt;Indicator LED (yellow) marked &quot;L&quot; - connected via an op-amp to digital pin 13&lt;/li&gt;&#xA;&lt;li&gt;Rx and Tx LEDs (yellow) - these indicate if the USB chip (Atmega16U2) is receiving or transmitting&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that the Rx and Tx LEDs are not connected &lt;em&gt;directly&lt;/em&gt; to digital pins 0 and 1 on the board (marked Rx and Tx). They only illuminate if you are doing serial communications &lt;em&gt;via USB&lt;/em&gt;, not if you have something (like a GPS) plugged directly into digital pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that since the &quot;L&quot; LED is connected via an op-amp, it may illuminate if pin 13 is set to an &lt;em&gt;input&lt;/em&gt; in your sketch. This is normal. It doesn't mean that something is erroneously sending data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Check the power&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;USB power&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Plug the board into your computer with the USB cable and check that the green &quot;On&quot; LED lights up.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a multimeter and a couple of jumper leads to test between the 5V pin and the GND pin (arrowed at the bottom). You should get a reading of around 5.0 V (I got 5.04 V on mine).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(You can buy a cheap multimeter for around $10 if you don't have one, but you are better off getting a better one for around $50 - check all the electronics web sites and stores.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Also test between the 3.3 V pin and the GND pin - you should get 3.3 V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you do not get 5 V with the USB cable plugged in make sure the other end is connected to your computer. Also try a different cable.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Power jack&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you are using, or planning to use, the power jack (marked &quot;power in&quot; on the photo) disconnect the USB, and plug in a power supply - which should be 7 to 12 V DC with positive on the &lt;em&gt;center&lt;/em&gt; pin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Measure the 5 V and 3.3 V pins as above. You should still see the same voltages on them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you get 5 V with the USB connected, but not with the power supply then the voltage regulator (marked on the photo) is probably damaged. Or, possibly the power supply has failed. Try a different power supply to confirm which it is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Check the power-on LED flash&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you have the Optiboot bootloader (the Uno normally ships with that) then if you press and release the Reset button, or unplug and plug the USB or power cable back in, the &quot;L&quot; LED should flash quickly 3 times. The &quot;on&quot; and &quot;off&quot; times are 50 ms each, the three flashes should be over within about 1/3 of a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't, you may have a problem with the bootloader, or the main processor chip (Atmega328P).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Try uploading a sketch&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Important:&lt;/em&gt; If you are having trouble uploading sketches remove any connected devices (like shields). Also remove jumper wires plugged into the board sockets. In particular, there should be &lt;em&gt;nothing plugged into digital pins 0 and 1&lt;/em&gt; (Rx and Tx) because that will interfere with communicating with the uploading computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choose one of the simple example sketches (eg. Blink) and try to upload it. This is what you should see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;L&quot; LED should flash 3 times. This is because the main chip is being reset by a command from the uploading process.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;Rx&quot; LED should flash quickly. This is the instructions from the uploading process trying to activate the bootloader.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;Tx&quot; LED should flash quickly. This is the processor acknowledging the uploaded data.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may see the above, even if the uploading process fails. This could be because the wrong board type is selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If only the &quot;Rx&quot; LED flashes, it could be because of a problem with the bootloader, or the main processor chip (Atmega328P). Someone is knocking, but no-one is at home!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Check the board type&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the LEDs flash, but you get a message like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the board type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/qDHGk.png&quot; alt=&quot;Board type menu&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the wrong board type selected it will probably send the wrong uploading instructions, and time-out or otherwise fail. If you are like me and have different boards lying around it is easy to forget that the last upload you did was for a different board type.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Check the comm port&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the LEDs don't flash at all, you may have the wrong comm port selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the comm port:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ckt4q.png&quot; alt=&quot;Comm port menu&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Try a different PC / Mac if possible&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Try your Arduino on a different PC/Mac if you have one to hand. This can narrow down whether or not you have an issue with the particular computer you have plugged it into, or computers in general.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Do a loopback test&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disconnect all shields and other wires&lt;/li&gt;&#xA;&lt;li&gt;Remove the board from the power&lt;/li&gt;&#xA;&lt;li&gt;Connect a jumper wire from RESET to GND (orange wire in photo)&lt;/li&gt;&#xA;&lt;li&gt;Connect a jumper wire from Rx to Tx (white wire in photo)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Wiring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0hfng.jpg&quot; alt=&quot;Loopback test&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Plug in the USB cable, and start up a terminal program - such as the Terminal Monitor in the Arduino IDE. Type something and send it (eg. hit &lt;em&gt;Enter&lt;/em&gt; in the Terminal Monitor).&lt;/li&gt;&#xA;&lt;li&gt;Everything you type should be echoed back.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If everything is echoed back: That confirms you have the right comm port, the USB cable is OK and the USB interface chip (Atmega16U2) is probably OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If nothing is echoed back, check:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You have the correct comm port.&lt;/li&gt;&#xA;&lt;li&gt;Try a different cable. Some cheap USB cables only have power wires and not data wires.&lt;/li&gt;&#xA;&lt;li&gt;Check the device driver for the Arduino is installed. You probably don't need to do this if that board worked previously on this computer, but it can be worth doing if this is the first time you plugged this board into this computer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Test the Atmega16U2 chip&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If your board fails the loop-back test, and you are certain the USB cable is OK, then you can test the Atmega16U2 chip itself. There is an ICSP (In Circuit Serial Programming) header on the board, adjacent to the Atmega16U2 chip, and near the USB socket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disconnect the power first (unplug the USB cable and any power cable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can connect the ICSP header via 6 jumper wires to a known good Uno, as shown in the photo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Pihx4.jpg&quot; alt=&quot;Test the Atmega16U2 chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin-outs for the ICSP header are (from the top):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jwP1o.png&quot; alt=&quot;ICSP header&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 1 on the ICSP header near the Atmega16U2 chip is marked with a small white dot, near the &quot;F&quot; in &quot;AREF&quot;. Pin 1 on the ICSP header near the ATmega328P chip is marked with a small white dot, below the &quot;N&quot; in &quot;ON&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Good board         Target Uno&#xA;&#xA;  MISO                MISO    (pin with dot - pin 1)&#xA;  VCC                 VCC&#xA;  SCK                 SCK&#xA;  MOSI                MOSI&#xA;  D10                 /RESET&#xA;  GND                 GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Double-check your wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then on the &quot;known good&quot; board install the &quot;Atmega_Board_Detector&quot; sketch as described on the &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot;&gt;Atmega bootloader programmer&lt;/a&gt; page. The code is at &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot;&gt;GitHub - nickgammon/arduino_sketches&lt;/a&gt;. If you click the Download button on that page you will get a number of useful sketches. The one you want is called &quot;Atmega_Board_Detector&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once installed, open the serial monitor, set it to 115200 baud, and you should see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jul  9 2015 at 08:36:24 with Arduino IDE 10604.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x94 0x89&#xA;Processor = ATmega16U2&#xA;Flash memory size = 16384 bytes.&#xA;LFuse = 0xEF&#xA;HFuse = 0xD9&#xA;EFuse = 0xF4&#xA;Lock byte = 0xCF&#xA;Clock calibration = 0x51&#xA;Bootloader in use: No&#xA;EEPROM preserved through erase: No&#xA;Watchdog timer always on: No&#xA;Bootloader is 4096 bytes starting at 3000&#xA;&#xA;Bootloader:&#xA;&#xA;3000: 0x4B 0xC0 0x00 0x00 0x64 0xC0 0x00 0x00 0x62 0xC0 0x00 0x00 0x60 0xC0 0x00 0x00&#xA;3010: 0x5E 0xC0 0x00 0x00 0x5C 0xC0 0x00 0x00 0x5A 0xC0 0x00 0x00 0x58 0xC0 0x00 0x00&#xA;3020: 0x56 0xC0 0x00 0x00 0x54 0xC0 0x00 0x00 0x52 0xC0 0x00 0x00 0xEE 0xC4 0x00 0x00&#xA;...&#xA;3FE0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&#xA;3FF0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&#xA;&#xA;MD5 sum of bootloader = 0xD8 0x8C 0x70 0x6D 0xFE 0x1F 0xDC 0x38 0x82 0x1E 0xCE 0xAE 0x23 0xB2 0xE6 0xE7&#xA;Bootloader name: Arduino-dfu-usbserial-atmega16u2-Uno-Rev3&#xA;&#xA;First 256 bytes of program memory:&#xA;&#xA;0: 0x90 0xC0 0x00 0x00 0xA9 0xC0 0x00 0x00 0xA7 0xC0 0x00 0x00 0xA5 0xC0 0x00 0x00&#xA;10: 0xA3 0xC0 0x00 0x00 0xA1 0xC0 0x00 0x00 0x9F 0xC0 0x00 0x00 0x9D 0xC0 0x00 0x00&#xA;20: 0x9B 0xC0 0x00 0x00 0x99 0xC0 0x00 0x00 0x97 0xC0 0x00 0x00 0x48 0xC4 0x00 0x00&#xA;30: 0x0C 0xC4 0x00 0x00 0x91 0xC0 0x00 0x00 0x8F 0xC0 0x00 0x00 0x8D 0xC0 0x00 0x00&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However if you get a message like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Failed to enter programming mode. Double-check wiring!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would appear to indicate that your ATmega16U2 is not working.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Test the ATmega328P chip&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Disconnect the power from the &quot;known good&quot; Arduino Uno and rewire the ICSP jumpers as per this photo, to connect them to the &quot;main&quot; processor on your Uno:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XQHMD.jpg&quot; alt=&quot;Test the ATmega328P chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin-outs for the ICSP header are (from the top):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jwP1o.png&quot; alt=&quot;ICSP header&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 1 on the ICSP header near the ATmega328P chip is marked with a small white dot, below the &quot;N&quot; in &quot;ON&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring is the same as before, except you are connecting to the other ICSP header - the one at the end of the board, furthest from the USB socket.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Good board       Target Uno&#xA;&#xA;  MISO                MISO    (pin with dot - pin 1)&#xA;  VCC                 VCC&#xA;  SCK                 SCK&#xA;  MOSI                MOSI&#xA;  D10                 /RESET&#xA;  GND                 GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once connected, open the serial monitor, set it to 115200 baud, and you should see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jul  9 2015 at 08:36:24 with Arduino IDE 10604.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x95 0x0F&#xA;Processor = ATmega328P&#xA;Flash memory size = 32768 bytes.&#xA;LFuse = 0xFF&#xA;HFuse = 0xDE&#xA;EFuse = 0xFD&#xA;Lock byte = 0xEF&#xA;Clock calibration = 0x83&#xA;Bootloader in use: Yes&#xA;EEPROM preserved through erase: No&#xA;Watchdog timer always on: No&#xA;Bootloader is 512 bytes starting at 7E00&#xA;&#xA;Bootloader:&#xA;&#xA;7E00: 0x11 0x24 0x84 0xB7 0x14 0xBE 0x81 0xFF 0xF0 0xD0 0x85 0xE0 0x80 0x93 0x81 0x00&#xA;7E10: 0x82 0xE0 0x80 0x93 0xC0 0x00 0x88 0xE1 0x80 0x93 0xC1 0x00 0x86 0xE0 0x80 0x93&#xA;...&#xA;&#xA;MD5 sum of bootloader = 0xFB 0xF4 0x9B 0x7B 0x59 0x73 0x7F 0x65 0xE8 0xD0 0xF8 0xA5 0x08 0x12 0xE7 0x9F&#xA;Bootloader name: optiboot_atmega328&#xA;&#xA;First 256 bytes of program memory:&#xA;&#xA;0: 0x0C 0x94 0x35 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00&#xA;10: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00&#xA;20: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00&#xA;30: 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00 0x0C 0x94 0x5D 0x00&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case it confirms that the main processor is working, and has the Optiboot bootloader on it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Things you can fix&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Failed voltage regulator&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This isn't easy to replace, but it is only needed if you use the power jack. If you run from USB then it is not required. Alternatively you could arrange for a 4 to 5 V supply (eg. 3 x AA batteries) and connect them to the 5 V socket on the board directly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Failed ATmega16U2 chip&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is only required for uploading sketches via the USB port, and serial debugging. It isn't particularly easy to replace because it is a SMD (surface mounted device). However you can manage without it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can upload sketches via the ICSP header, if you purchase a ICSP programming device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples of such devices plugged into the ICSP socket:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SedEP.jpg&quot; alt=&quot;USBtinyISP&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/glssw.jpg&quot; alt=&quot;AVRISP&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Those photos were taken of a Ruggeduino, but the concept is the same).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also get an FTDI cable, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rdZTX.jpg&quot; alt=&quot;Connect FTDI to Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect it to your board's serial ports like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tkvzg.jpg&quot; alt=&quot;FTDI cable&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FTDI    Arduino Uno&#xA;&#xA;GND       GND  (black wire on FTDI cable, blue jumper wire)&#xA;CTS       not connected&#xA;VCC       5V&#xA;TxD       D0 (RX)&#xA;RxD       D1 (TX)&#xA;RTS       To RESET with a 0.1 µF capacitor in series with it (green wire)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can upload sketches directly to the main processor, bypassing the USB chip.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use my &lt;a href=&quot;http://www.gammon.com.au/uploader&quot;&gt;Atmega chip stand-alone programmer to upload .hex files&lt;/a&gt; - this lets you copy the .hex file for a sketch onto an SD card, and then program the board via the ICSP header.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Failed ATmega328P chip&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The main processor can be replaced fairly easily if it is mounted in a socket. Get a replacement chip from somewhere like &lt;a href=&quot;https://www.adafruit.com/products/123&quot;&gt;Adafruit&lt;/a&gt; for around $US 6. Alternatively, try eBay. Try to get a chip which has the Optiboot bootloader already on it, to save hassle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Carefully prise the existing chip out of the socket, and install the new one, taking note of the location of pin 1. Pin 1 has a notch on the chip, and its correct orientation is noted on the first photo in this post with a yellow dot (closest to the edge of the board). You will probably need to straighten the legs slightly. Hold the chip by the ends and gently push down onto a flat surface, like a desk, until the are pushed inwards a bit. Try to &lt;em&gt;not&lt;/em&gt; touch the metal pins, you may zap them with static electricity.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;ATmega328P responds but has no bootloader&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I have a sketch at &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot;&gt;Atmega bootloader programmer&lt;/a&gt; which will replace the Optiboot bootloader. The wiring is the same as for the chip detector sketch. The code is at &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot;&gt;GitHub - nickgammon/arduino_sketches&lt;/a&gt;. If you click the Download button on that page you will get a number of useful sketches. The one you want is called &quot;Atmega_Board_Programmer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install the sketch on your &quot;known good&quot; Uno, and connect it to the target board with the wiring shown earlier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/XQHMD.jpg&quot; alt=&quot;Test the ATmega328P chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open the Serial Monitor on your &quot;good&quot; Uno and you should see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip programmer.&#xA;Written by Nick Gammon.&#xA;Version 1.35&#xA;Compiled on Jul  9 2015 at 15:06:58 with Arduino IDE 10604.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x95 0x0F&#xA;Processor = ATmega328P&#xA;Flash memory size = 32768 bytes.&#xA;LFuse = 0xFF&#xA;HFuse = 0xDE&#xA;EFuse = 0xFD&#xA;Lock byte = 0xEF&#xA;Clock calibration = 0x83&#xA;Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type &quot;U&quot; for the Uno (Optiboot) loader.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Using Uno Optiboot 16 MHz loader.&#xA;Bootloader address = 0x7E00&#xA;Bootloader length = 512 bytes.&#xA;Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Type &quot;G&quot; to program the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Erasing chip ...&#xA;Writing bootloader ...&#xA;Committing page starting at 0x7E00&#xA;Committing page starting at 0x7E80&#xA;Committing page starting at 0x7F00&#xA;Committing page starting at 0x7F80&#xA;Written.&#xA;Verifying ...&#xA;No errors found.&#xA;Writing fuses ...&#xA;LFuse = 0xFF&#xA;HFuse = 0xDE&#xA;EFuse = 0xFD&#xA;Lock byte = 0xEF&#xA;Clock calibration = 0x83&#xA;Done.&#xA;Programming mode off.&#xA;Type 'C' when ready to continue with another chip ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This takes about one second. Now the bootloader is installed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Watchdog timer problems&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The watchdog timer (off by default) can be configured to reset the processor after a certain time. The intention is to recover from a &quot;hang&quot; for a processor deployed in the field. However if the timer is set for a short period (like 16 ms) then the processor can reset again before the bootloader has a chance to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The symptoms are that you cannot upload any new sketches. Some modern bootloaders (like Optiboot) take steps to stop this problem as one of the first things they do. However others do not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be difficult to recover from, because once the sketch runs, you have the problem of it resetting, and if you have the problem you can't replace the sketch. People often report that they have to burn a new bootloader to recover. However that is only because, as a side-effect, burning a bootloader erases the current sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There &lt;em&gt;is&lt;/em&gt; a way of recovering. Take these steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Power off the board completely (remove the USB cable).&lt;/li&gt;&#xA;&lt;li&gt;Hold down the Reset button, and &lt;em&gt;keep it held down&lt;/em&gt; (or, run a jumper wire from the RESET pin to the GND pin). This stops the problem sketch from starting, and thus activating the watchdog timer&lt;/li&gt;&#xA;&lt;li&gt;Still holding down Reset, reconnect the USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Start uploading a sketch that does not have this problem (eg. Blink)&lt;/li&gt;&#xA;&lt;li&gt;Once the IDE reports &quot;Uploading&quot; release the Reset button (or remove the jumper wire).&lt;/li&gt;&#xA;&lt;li&gt;It should now upload OK - as the sketch which activated the watchdog timer never started.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Problems with the Mega2560 upload&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I mention this here, even though this post is really targetting the Uno board, because it is quite common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some versions of the Mega2560 bootloader look for &quot;!!!&quot; in the incoming upload from the PC, and if they see that, drop into debugging mode. This causes the upload to fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (&quot;Furnace overheating!!!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install a more recent bootloader. My &quot;bootloader uploader&quot; sketch mentioned earlier in this reply should install a bootloader that does not have that issue.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or (more simply):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do not use &quot;!!!&quot; in your sketch.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Problems uploading to the Leonardo / Micro / Esplora etc.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Boards with the ATmega32u4 as their main (and only) processor can be trickier to upload to. This is because the same chip has to handle uploads and also run your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a small window of opportunity, after the board is reset, when it looks for a new sketch to be uploaded. The technique for uploading to these boards is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Compile your sketch without errors.&lt;/li&gt;&#xA;&lt;li&gt;Start the upload&lt;/li&gt;&#xA;&lt;li&gt;As soon as the IDE reports &quot;Uploading&quot; press and release the Reset button.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You only have a second or so to do this, before the old sketch starts running. Don't be discouraged if you have to repeat this process a couple of times. That is normal.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11643&quot;&gt;Solving problems with uploading programs to your Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot;&gt;Sketch to detect Atmega chip types&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot;&gt;GitHub site with chip detector / bootloader programmer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/bootloader&quot;&gt;Atmega bootloader programmer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/uploader&quot;&gt;Atmega chip stand-alone programmer to upload .hex files&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.engbedded.com/fusecalc&quot;&gt;Engbedded Atmel AVR® Fuse Calculator&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/uno&quot;&gt;Arduino Uno Rev3 pinouts photo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-11-06T05:30:56.103" LastActivityDate="2016-11-06T05:30:56.103" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="13294" PostTypeId="2" ParentId="13285" CreationDate="2015-07-09T07:33:54.090" Score="0" Body="&lt;p&gt;The CD4510 does not seem at all appropriate for this task. It is a counter chip that counts up or down. You can do that with the Arduino. The output (of the CD4510) would be in &quot;binary&quot; and not suitable for driving a 7-segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get 8 digit 7-segment displays on eBay for around $2. Surely that fits within your budget?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-09T07:33:54.090" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13295" PostTypeId="2" ParentId="13284" CreationDate="2015-07-09T08:28:55.200" Score="1" Body="&lt;p&gt;If you want to use PWM in place of a DAC, the normal thing to do is to&#xA;use some kind of analog low-pass filter. However, many people skip the&#xA;filter when the signal is meant for some system that inherently acts as&#xA;a low-pass. Example: dimming an LED, where the human eye is the filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, since your plant looks like a third order low-pass filter&#xA;with cuts at 1.6, 4.8 and 16&amp;nbsp;Hz, you can probably skip the filter.&#xA;If you output on pins 5 or 6, &lt;a href=&quot;https://www.arduino.cc/en/Reference/analogWrite&quot; rel=&quot;nofollow&quot;&gt;the PWM frequency will be around&#xA;980&amp;nbsp;Hz&lt;/a&gt;&#xA;(exactly: f&lt;sub&gt;CPU&lt;/sub&gt;/16384). At that frequency, your plant gain&#xA;relative to DC will be&lt;/p&gt;&#xA;&#xA;&lt;p&gt;G(j2π × 980 Hz) / G(0) ≈ 1.3 × 10&lt;sup&gt;−7&lt;/sup&gt; j&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably low enough to not be an issue.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-07-09T08:28:55.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13296" PostTypeId="2" ParentId="13292" CreationDate="2015-07-09T10:08:14.170" Score="16" Body="&lt;p&gt;At least - as I assume you upload your sketch via avrdude - please give more information about the upload failure (e.g. output of sketch uploader) so people here can help you better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally to the great answer of Nick Gammon, please search for exclamation marks in your sketch. If your sketch contains a string with more than or equal to 3 exclamation marks, the upload will fail, as old versions of the Arduino Bootloader will interpret these exclamation marks as another function and the upload will stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example for stopping the upload:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* test = &quot;This will stop the upload!!!&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://code.google.com/p/arduino/issues/detail?id=459&quot;&gt;Google Code issue&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11094" LastActivityDate="2015-07-09T10:08:14.170" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13297" PostTypeId="1" CreationDate="2015-07-09T10:18:00.110" Score="2" ViewCount="417" Body="&lt;p&gt;I am using a Fio to control a set of relays. The unit uses an XBee (series 1 Pro) in transparent mode to receive commands over serial UART and everything works fine. The XBee is also configured for digital Input/Output Line Passing and the XBee on the Fio &quot;mirrors&quot; on an output pin the input state on a remote XBee and also this works fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I interrogate from the Fio the state of the output pin (e.g. D0) of the local (receiving) XBee? Is there an AT command that I could send via &lt;code&gt;Serial.println(&quot;ATxx&quot;)&lt;/code&gt; that would trigger the XBee to send back over UART the status of the pin (high or low)?&lt;/p&gt;&#xA;" OwnerUserId="1612" LastEditorUserId="4628" LastEditDate="2017-03-31T13:14:24.890" LastActivityDate="2018-02-25T08:56:49.540" Title="XBee on Arduino Fio - how to read the status of a local digital XBee output pin?" Tags="|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13298" PostTypeId="1" CreationDate="2015-07-09T10:30:59.047" Score="3" ViewCount="12870" Body="&lt;p&gt;I have a code in Visual studio that I want to implement in Arduino. But&#xA;there is a problem. Many libraries usable in Visual Studio aren't usable&#xA;in the Arduino IDE. How can I use them in my Arduino code? To be&#xA;precise, the libraries I want to use are&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;iomanip&amp;gt;&#xA;#include &amp;lt;queue&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;#include &amp;lt;ctime&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I have &lt;code&gt;&amp;lt;iostream&amp;gt;&lt;/code&gt; available in Arduino. &lt;code&gt;&amp;lt;math.h&amp;gt;&lt;/code&gt; is also&#xA;available I think along with the &lt;code&gt;&amp;lt;string&amp;gt;&lt;/code&gt; library. The main problem is&#xA;to how to use &lt;code&gt;#include&amp;lt;queue&amp;gt;&lt;/code&gt; and its functions such as&#xA;&lt;code&gt;priority_queue()&lt;/code&gt; and other functions of iosteam like &lt;code&gt;.pop()&lt;/code&gt;? Any&#xA;help would be highly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="11095" LastEditorUserId="7508" LastEditDate="2015-07-09T10:42:10.817" LastActivityDate="2017-12-05T15:12:52.213" Title="How to use C Libraries for Arduino code" Tags="|c++|c|ide|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13299" PostTypeId="1" CreationDate="2015-07-09T10:39:13.007" Score="6" ViewCount="39250" Body="&lt;p&gt;I am using an Arduino Uno and a Mac and trying to upload my code into the board.&#xA;I tried uploading the program from different computers(MacBook Air and Pro) and I still have this problem.&lt;/p&gt;&#xA;&lt;p&gt;How do I fix this? I tried downloading the FTDI driver. I went to the website that they suggested and tried following the instructions. I even followed other posts in Stack Exchange but I still cannot upload the code.&lt;/p&gt;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&lt;p&gt;Programmer -&amp;gt; AVRISP mkll&lt;/p&gt;&#xA;&lt;p&gt;I am using a cable to connect to my Mac and I am using the Arduino software. The cable connected between the Arduino USB and Mac USB port.&lt;/p&gt;&#xA;&lt;p&gt;I tried quitting and relaunching Arduino app. Once it launches I just press the upload button while my USB is plugged in. My available ports in the app are &lt;code&gt;/dev/cu.Bluetooth-Incoming-Port&lt;/code&gt; and &lt;code&gt;/dev/cu.Bluetooth-Modem&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;And this is the error&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &amp;quot;/dev/cu.usbmodem1421&amp;quot;: No such file or directory&#xA;ioctl(&amp;quot;TIOCMGET&amp;quot;): Inappropriate ioctl for device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11091" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2020-08-14T00:37:04.307" Title="Inappropriate ioctl for device" Tags="|arduino-uno|" AnswerCount="4" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="13300" PostTypeId="1" AcceptedAnswerId="13303" CreationDate="2015-07-09T11:57:34.017" Score="0" ViewCount="297" Body="&lt;p&gt;I just started tinkering with Arduino. I'm curious to know though, is it possible to read and write to a file stored in the SD card in the Wave shield v3 by Elechouse? I'm able to play files stored in said SD card, but I don't know how I'd go about writing some logs. I'm using an Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11098" LastEditorUserId="4628" LastEditDate="2015-07-10T00:37:18.297" LastActivityDate="2015-07-10T00:37:18.297" Title="Write to file in SD card in wave shield V3" Tags="|arduino-mega|shields|sd-card|audio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13301" PostTypeId="2" ParentId="13287" CreationDate="2015-07-09T11:57:43.970" Score="3" Body="&lt;p&gt;Two other possible problems, apart from what Jake C has adressed in his answer are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Hardware bounce&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your signal from the sensor isn't a clean transition from high to low but rather &quot;bouncy&quot; (see image below). The microcontroller will register multiple transitions in the meantime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/6f1w9.gif&quot; alt=&quot;Hardware bounce&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution to this would be to add a small capacitor (wil slow it down though) or add debouncing code... Best would be to get a &quot;clean&quot; sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Floating contact&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I even move my finger close to the wire running to PIN2 the interrupt fires.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That kinda seems like it's a floating contact, where it's not really connected to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is usually solved by using a pullup/pulldown resistor. Or maybe there is something wrong with the connection.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Maybe due to the type of sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should note the part number of the sensor or link a datasheet, so we can see if it's typical behaviour for this type of sensor.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-07-09T11:57:43.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13303" PostTypeId="2" ParentId="13300" CreationDate="2015-07-09T14:11:38.077" Score="1" Body="&lt;p&gt;No, you cannot.  The shield is basically a cheap WAV or AD4 (whatever THAT is) playing chip which loads the audio data direct from an (old, small) SD card.  The only control you have is IO pins that emulate pressing the buttons on an MP3 player.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-09T14:11:38.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13304" PostTypeId="1" AcceptedAnswerId="13311" CreationDate="2015-07-09T17:19:43.970" Score="2" ViewCount="942" Body="&lt;p&gt;I am planning to build a weather station powered by solar power. I want to use an Arduino Nano because it's low power requirement. I want to connect some basic sensors to it (temperature, humidity…) as well as an anemometer, a wind vane and a rain gauge. The weather data should be sent wireless via 433 mhz to a raspberry pi, which acts as a web server. I do not have power cable access to the Arduino so solar is the only option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which solar panel should I use? I was planning to use 2 2.5W 5.5V panels which charge a Lithium-Ion battery which powers the Arduino using a step up converter. Assuming I have 2-4h of direct sunlight per day and I want to query the sensors every 5 minutes, how big of a battery should i choose? I don't want it to go out of power and want it to last a couple of days without sun.&lt;/p&gt;&#xA;" OwnerUserId="11116" LastActivityDate="2015-07-09T21:59:24.930" Title="Choose the correct solar panel and battery for solar use" Tags="|sensors|power|arduino-nano|battery|solar|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13305" PostTypeId="2" ParentId="13297" CreationDate="2015-07-09T17:48:27.540" Score="1" Body="&lt;p&gt;You cannot read the state of output pins via an AT command, you can only read the state of input pins using the ATIS command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://ftp1.digi.com/support/documentation/90000982_S.pdf&quot; rel=&quot;nofollow&quot;&gt;http://ftp1.digi.com/support/documentation/90000982_S.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-09T17:48:27.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13307" PostTypeId="1" CreationDate="2015-07-09T18:15:32.020" Score="2" ViewCount="11093" Body="&lt;p&gt;I wanted to know if it is possible to monitor a battery that is driving the Arduino and check its voltage. When the voltage drops below a certain level (i.E below 3.0V) it should shutdown and disconnect itself from the battery by using a relay or something. When the battery is full enough again it should power up again. Is that possible without any external sensors just by using the Arduino's inputs?&lt;/p&gt;&#xA;" OwnerUserId="11116" LastActivityDate="2015-07-09T19:45:42.140" Title="Use Arduino to detect low battery state and shut it down" Tags="|power|voltage-level|battery|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13308" PostTypeId="2" ParentId="13307" CreationDate="2015-07-09T19:19:33.113" Score="1" Body="&lt;p&gt;It is not entirely beyond possible, in fact quite possible in theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the saying 'in theory, theory and reality are the same, but in reality they are not' is appropriate here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to monitor voltage, a simple voltage divider circuit can be used, and the Arduino can monitor that, and release a relay controlling the power line. The same relay could be wired to also reconnect when voltage reaches a threshold. I think the circuit actually requires 2 (or more) relays, and technically is it a kind of sensor, but since you indicated a relay was ok, it could work. So given those requirements, do you really need someone to draw it out, or were you just curious?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/8JvyC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple battery monitoring from &lt;a href=&quot;http://arduinotronics.blogspot.com/2012/04/voltage-monitor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduinotronics.blogspot.com/2012/04/voltage-monitor.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user6569" LastActivityDate="2015-07-09T19:19:33.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13309" PostTypeId="2" ParentId="13307" CreationDate="2015-07-09T19:28:12.063" Score="1" Body="&lt;p&gt;Have a look here&#xA;&lt;a href=&quot;http://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/&lt;/a&gt;&#xA;It is for bare metal Atmel chip, but applicable to Arduino as well probably.&#xA;Step one in getting longer battery life is to move to a bare metal Atmel chip, choose ATMEGA or ATTINY depending on how many pins you need.&#xA;Also see my answer here&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/6/what-are-or-how-do-i-use-the-power-saving-options-of-the-arduino-to-extend-bat/8556#8556&quot;&gt;What are (or how do I use) the power saving options of the Arduino to extend battery life?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7255" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-07-09T19:28:12.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13310" PostTypeId="2" ParentId="13307" CreationDate="2015-07-09T19:45:42.140" Score="1" Body="&lt;p&gt;I'm assuming Arduino is powered directly by the battery, and not via a voltage regulator. In that case you van measure VCC by first measuring the internal 1.1v voltage reference (in relation to Vcc). Since the internal 1.1v is constant and VCC will lower over time, the reading (0-1023) will increase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this article: &#xA;&lt;a href=&quot;http://jeelabs.org/2012/05/04/measuring-vcc-via-the-bandgap/&quot; rel=&quot;nofollow&quot;&gt;http://jeelabs.org/2012/05/04/measuring-vcc-via-the-bandgap/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-09T19:45:42.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13311" PostTypeId="2" ParentId="13304" CreationDate="2015-07-09T19:59:33.313" Score="3" Body="&lt;p&gt;I won't be able to tell you which solar panel or battery to use, but I can tell you how to figure that out.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Battery&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For the battery there are a few different ways to figure this out:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The most common way to do this at the professional level is to build the device and run it attached to an energy meter and measure it for an hour or two performing its usage, and use that to calculate how much it will use over a 48 hour period. That being said that type of test equipment is not really a hobbyist piece of equipment and probably not something you are wanting to obtain for this project.&lt;/li&gt;&#xA;&lt;li&gt;You can try and use the datasheets for all of your components to determine their idle and active current draw is, add them up for idle and active, adjust the values based upon the efficiency of your step up converter (so if it only 75% efficient, divide them by .75), guesstimate how long your sensor read process will take, multiply your active current draw times the voltage and times the time it will take (in hours, so if this is a few seconds, it will be a really small decimal), multiply your idle current draw times the voltage and times .083 hours (5 minutes), add those two together multiply it times 12 (12 - 5 minute periods per hour) and then by 48 (two days) and that will be an estimate of your energy usage for two days. Now this will be a very rough estimate as the datasheets only provide nominal values, and their actual usage in practice may be different, which leads me to the final option...&lt;/li&gt;&#xA;&lt;li&gt;A hybrid between the two above solutions. Set up your device and have it read the sensors and transmit continuously. Then use a multi-meter to measure the current usage of it actively being used. Repeat the measurement again but this time with it running on an indefinite timer to simulate being idle. Then take those two numbers and use the above formula substituting the datasheet estimates with your actual measurements to get a much more accurate picture of what your energy usage will be.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Once you have your energy usage (this will be in milli-Watt-Hours or mWH) pick a battery voltage you will be using (this is based on the charge circuit you are using, typically, single cell lithium ion batteries are 3.7 or 4.2, with multi-cell batteries being multiples of those), divide your energy by the voltage to get the power (in milli-Amp-Hours or mAH) and you'll want to pick a battery greater than that. You'll also want to double check the data sheet of your step up converter and see what the drop out voltage is, and then compare that to the datasheet for the battery and see at what capacity it hits that voltage. You'll want to make sure that it is at least 80%. Otherwise you'll have to pick a different battery with a larger capacity, or a different step up converter with a lower dropout voltage.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solar Panel&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For the solar panel, what you will want to do is get a battery charger designed specifically for use with solar panels. This is because when it says 5.5v solar panel, that is it's nominal voltage in full sunlight, however, it most often will not be that and will vary greatly throughout the day. What this means is that solar panels are basically on unregulated power supply, and most battery chargers require a regulated power source. With a solar specific batter charger, it is designed such that it can handle voltage variation and sudden dropouts. Usually these chargers come with a recommendation as far as voltage and current requirements and those specifications should form the basis of your solar panel selection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example, if you have a battery, on the datasheet it will list what its charge current is, and you'll want to make sure you have a charger circuit that can supply that amount of current. Then you'll want to take a look at the datasheet for the charger circuit, see what current it requires and then make sure that the solar panel can provide that current.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-07-09T21:59:24.930" LastActivityDate="2015-07-09T21:59:24.930" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13312" PostTypeId="2" ParentId="13113" CreationDate="2015-07-09T20:02:50.160" Score="1" Body="&lt;p&gt;Be sure the shield is not shorting out on the metal USB socket on the Arduino board. I don't know if this is still an issue but I've seen many Arduino boards with black electric tape on the top of the USB socket to insulate it from shorting out the shield.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-07-09T20:02:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13313" PostTypeId="1" CreationDate="2015-07-09T20:06:19.177" Score="0" ViewCount="225" Body="&lt;p&gt;Do Arduinos, or any other single-board computer, come in any sort of industry-standard form factor? I'm trying to sell management on using Arduino, but they are stuck on the question &quot;what if Arduino goes out of business&quot;, and if I could answer &quot;we can just switch over to using brand X because it's the same size and has the same connectors&quot;, my life would be much easier.&lt;/p&gt;&#xA;" OwnerUserId="11122" LastActivityDate="2022-04-04T03:01:20.163" Title="Industry Standard for Single-Board Computers?" Tags="|hardware|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13316" PostTypeId="2" ParentId="13313" CreationDate="2015-07-09T20:40:52.863" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Whether or not the Arduino company goes out of business isn't all that relevant. For one thing, there are now two competing companies vying for the Arduino trademark - &lt;a href=&quot;https://www.arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; and &lt;a href=&quot;http://www.arduino.org/&quot; rel=&quot;nofollow&quot;&gt;arduino.org&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Arduino has such a ground-swell of popularity that clone boards are widely available on eBay and from other suppliers. While people are willing to buy them, someone will sell them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The design is open-source, which makes it a safer choice than other designs who keep their design proprietary. For one thing, it guarantees that someone will make compatible boards, even if Arduino(s) fold.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;heart&quot; of the Arduino is (in most cases anyway) a chip from Atmel - so you really should ask if &lt;a href=&quot;https://en.wikipedia.org/wiki/Atmel&quot; rel=&quot;nofollow&quot;&gt;Atmel&lt;/a&gt; will go out of business. Probably not, but in any case, an alternative supplier might just as easily go out of business.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I wouldn't be building an &quot;Arduino board&quot; into a production system anyway - too much chance that wires would fall out of the prototyping sockets. However the prototyping board is good for learning about their capabilities, and testing your code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do Arduinos, or any other single-board computer, come in any sort of industry-standard form factor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not aware of any industry-standard form factor. The Uno design has caused a &lt;em&gt;lot&lt;/em&gt; of people to make &quot;shields&quot; that fit onto that form factor, so that is probably the closest you would get to an industry standard.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-09T20:40:52.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13317" PostTypeId="1" AcceptedAnswerId="13383" CreationDate="2015-07-09T20:55:59.813" Score="0" ViewCount="3955" Body="&lt;p&gt;I (think I) am trying to iterate through the values of an array and print the string to a tft. I have declared the array of 4 strings, and that works fine. But when I try to print it, I get garbage. Am I missing a nuance of print? Or do I just not understand how to use arrays and strings...?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Declarations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Active System&#xA;char hvacSystems[4][5] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;};&#xA;int activeSystem = 0;  &#xA;String displayActiveSystem = hvacSystems[activeSystem]; &amp;lt;-- Should now be String &quot;off&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use (note the fake if statement for the question)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if(systemNeedsToBeCycled){&#xA;    activeSystem++;&#xA;    displayActiveSystem = hvacSystems[activeSystem]; &amp;lt;-- Should now be String &quot;Fan&quot;&#xA;    tft.print(displayActiveSystem);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead I get random characters most of the time, sometimes nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case its a memory thing, please know that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 26,480 bytes (92%) of program storage space. Maximum is 28,672 bytes. Global variables use 1,126 bytes (43%) of dynamic memory, leaving 1,434 bytes for local variables. Maximum is 2,560 bytes.&lt;/p&gt;&#xA;" OwnerUserId="11107" LastActivityDate="2015-12-28T23:39:12.847" Title="iterate through values in an array of strings to print" Tags="|arduino-yun|string|adafruit|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13318" PostTypeId="2" ParentId="13287" CreationDate="2015-07-09T20:56:41.027" Score="1" Body="&lt;p&gt;I would recommend adding a comparator with hysteresis so as to get a clean digital pulse, pictured below:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EqgJp.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fEqgJp.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the correct values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend the comparator with hysteresis as the phototransistors are prone to cause issues with interrupts even when used with pul-up/pull-down resistors, thus is as they very the voltage more than give a clean &lt;code&gt;0/1&lt;/code&gt; digitally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is your code, modified with the addition of &lt;code&gt;RISING&lt;/code&gt; and of a 10mS delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 13; &#xA;volatile  int tcnt = 0; &#xA;volatile int state = LOW; &#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA;  pinMode(pin, OUTPUT); &#xA;  attachInterrupt(0, blink, RISING); &#xA;} &#xA;&#xA;void loop() { &#xA;  Serial.println(tcnt); &#xA;  digitalWrite(pin, state);&#xA;   delay(10);&#xA;} &#xA;&#xA;void blink() { &#xA;  tcnt = tcnt + 1; &#xA;  state = !state; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This method produces very reliable results. It is also accurate with objects moving rapidly because of the interrupt.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would also say that the problem you have when you use a piece of plastic &amp;lt; 5mm is that the length of the slit in the sensor is &lt;em&gt;6.0±0.1&lt;/em&gt;(seen below). If the plastic is less you probably find that the phototransistor still has enough IR falling on it to allow voltage to flow, but enough to trigger and interrupt. With the comparator you could probably use a smaller piece of plastic and find the voltage swing with a DMM and modify the voltage divider (&lt;strong&gt;R1&lt;/strong&gt; and &lt;strong&gt;R2&lt;/strong&gt;) to suite the needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/4iHaF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-07-09T20:56:41.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13319" PostTypeId="2" ParentId="9709" CreationDate="2015-07-09T21:33:04.280" Score="2" Body="&lt;p&gt;You can use RS-485 connection between all arduinos using serial port of all. For a half duplex connection for 4 arduinos, the setup can be like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What Do You Need:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;4 RS-485 line drivers (&lt;em&gt;like max485&lt;/em&gt;). One for each arduino&lt;/li&gt;&#xA;&lt;li&gt;if the distance between arduinos are short (under 1 mt) these will br enough&lt;/li&gt;&#xA;&lt;li&gt;if the distance between arduinos are long (over 2mt) you'll need to use at least 24 AWG twisted pair cable between them and 2 120 ohm resistors. These resistors will be line terminators.&lt;/li&gt;&#xA;&lt;li&gt;You can check max485 datasheet to see how to connect them&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setting Up:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use rs485 with arduino and half duplex, you'll need 3 pins. 2 pins for rx and tx. 1 pin for &lt;em&gt;transmit-enable&lt;/em&gt;. In half duplex mode, normally all nodes are in listening mode. To configure transmit enable, connect &quot;&lt;em&gt;drive enable&lt;/em&gt;&quot; and &quot;&lt;em&gt;receive enable&lt;/em&gt;&quot; pins of rs485 driver together. This will be our &quot;&lt;em&gt;transmit-enable&lt;/em&gt;&quot; pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Connection:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      |        |&#xA;c  RX |-------&amp;gt;|RO     4&#xA;p  TX |-------&amp;gt;|DI     8&#xA;u D13 |-------&amp;gt;|TE&amp;amp;RE^ 5&#xA;      |        |&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download &lt;a href=&quot;https://github.com/mgulsoy/MertBus&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; library (Mertbus). This library implements a basic transport layer. It is in alpha stage but functional. There is sample code in it and also a .net library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logic is similar to TCP/IP. Give every node an address between 0 and 126. 127 is the broadcast id. Means if you send data to id 127 all nodes will receive it. If you send data to only one node (ex. 2 ...) only target node will receive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;MertBus.h&quot; //include header&#xA;&#xA;#define TXEN 13  //transmit-enable pin&#xA;#define SELF_ID 1  //id of this node&#xA;&#xA;MertBus mb;  //communicator class&#xA;&#xA;void setup() {&#xA;   Serial.begin(57600); //prepare the serial port as usual&#xA;   Serial.println(&quot;Begin init&quot;);&#xA;   //then initialize mertbus instance with port, pin and id&#xA;   mb = MertBus(Serial,TXEN,SELF_ID); &#xA;}&#xA;&#xA;void loop() {&#xA;  if(mb.checkData()) {    //check if and valid data received&#xA;    // reply to sender char[] and length, 26 chars&#xA;    mb.reply(&quot;Incoming Data (SendData): &quot;,26); &#xA;    // reply to sender the received data&#xA;    mb.reply(mb.Buffer,mb.ReceiveCount);&#xA;  } else {&#xA;    digitalWrite(13,HIGH);&#xA;    delay(400);&#xA;    digitalWrite(13,LOW);&#xA;    delay(400);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be a master, to send data (without replying to a message, starting a new one):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//buffer data to send, to_addr is target node address &#xA;//buffer_size is the size of data to send. &#xA;mb.sendData(char * buffer, uint8_t to_addr, uint8_t buffer_size)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8622" LastActivityDate="2015-07-09T21:33:04.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13320" PostTypeId="1" CreationDate="2015-07-09T21:42:22.507" Score="0" ViewCount="3130" Body="&lt;p&gt;I was looking around becouse I need to simulate a OBDII device. I think about to use Arduino for that. I was reading some tutorials how to use bluetooth module but I didn't find any tutorial when Arduino is a server. Alway Android app is a server. Is there way to put SP server in Arduino and Android as a client? And do I need special shield/module for that? If you could gave me some links to tutorials or code would be grate. &#xA;Interesting for me would be also possibility to send data form computer by USB to Arduino then Arduino push it forward to Android. - but that is not must have, first possibility is more importand for me.&lt;/p&gt;&#xA;" OwnerUserId="8266" LastActivityDate="2016-06-05T04:52:38.937" Title="Arduino bluetooth module as a server" Tags="|serial|arduino-mega|bluetooth|android|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13321" PostTypeId="2" ParentId="9709" CreationDate="2015-07-09T21:48:13.733" Score="2" Body="&lt;p&gt;If they are reasonably close to each other, by far the simplest would be to use serial comms, since you say you want to &lt;em&gt;send&lt;/em&gt; a number (but do not mention receiving anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could have the Tx pin on the master Arduino connected to the Rx pin of all the other Arduinos (plus a ground connection of course). Then send your numbers to your heart's delight. I suggest some sort of protocol like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(42)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the opening and closing braces indicate to the receiver where the number starts and ends. If the distance is more than (say) 5 meters, an RS485 transceiver may be called for at each end, eg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/87ZLH.png&quot; alt=&quot;RS485 connections&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a description of the sort of thing on my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;RS485 communications&lt;/a&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can &quot;drop&quot; multiple transceivers off the same pair of cables. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS485 is reasonably resistant to line noise because it is a balanced protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These transceivers can transmit or receive but not at the same time. In your case you would have the master with Tx Enable active, and the slaves the Tx Enable not active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the chips are dropped off a long cable run you should have a termination resistor between A and /B at the end (say, 120 Ω).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI could be OK, but is really for short runs. I&lt;sup&gt;2&lt;/sup&gt;C could be OK too, but may be unnecessarily complex. However if you go with I&lt;sup&gt;2&lt;/sup&gt;C it does have a &quot;broadcast&quot; mode which might suit sending the same thing to multiple devices.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;References&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;RS485 communications&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow noreferrer&quot;&gt;RS485 - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;I&lt;sup&gt;2&lt;/sup&gt;C (Wire)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=10894&quot; rel=&quot;nofollow noreferrer&quot;&gt;Async serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-09T21:48:13.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13322" PostTypeId="2" ParentId="13317" CreationDate="2015-07-09T22:07:45.707" Score="0" Body="&lt;p&gt;I am not sure I understand 100% but here is my best shot. If the below is wrong&#xA;the issue is not due to being out of memory.&#xA;Try this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Active System&#xA;char hvacSystems[] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;}; &#xA;// or char hvacSystems[4] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;}&#xA;int activeSystem = 0;  &#xA;String displayActiveSystem = hvacSystems[activeSystem]; &amp;lt;-- Should now be String &quot;off&quot;&#xA;&#xA;if(systemNeedsToBeCycled){&#xA;    activeSystem++;&#xA;    displayActiveSystem = hvacSystems[activeSystem]; &amp;lt;-- Should now be String &quot;Fan&quot;&#xA;    tft.print(displayActiveSystem);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;char hvacSystems[4][5] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;};&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are attempting to create a two dimensional array here. Essentially a 4x5 table. With your code if you do&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tft.print(hvacSystems[0][1]);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should give you &quot;Off&quot;.  Basically you made a table that looks like&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0{&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;, null}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1{null, null, null, null, null}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2{null, null, null, null, null}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3{null, null, null, null, null }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arrays:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Array&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Array&lt;/a&gt;&#xA;2d Arrays:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=220385.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=220385.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11076" LastActivityDate="2015-07-09T22:07:45.707" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13323" PostTypeId="2" ParentId="13299" CreationDate="2015-07-09T22:54:44.760" Score="7" Body="&lt;p&gt;Plug your Uno into the Mac using a known good USB cable.&lt;/p&gt;&#xA;&lt;p&gt;Go to the Apple menu -&amp;gt; About This Mac -&amp;gt; More Info -&amp;gt; System Report&lt;/p&gt;&#xA;&lt;p&gt;Under the USB selection (on the left) please confirm whether or not you see something like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EQWxI.png&quot; alt=&quot;Arduino USB in System Report&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also open a Terminal window and type:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;system_profiler SPUSBDataType&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Amongst other things you should see:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;USB:&#xA;&#xA;    USB High-Speed Bus:&#xA;&#xA;      Host Controller Location: Built-in USB&#xA;      Host Controller Driver: AppleUSBEHCI&#xA;      PCI Device ID: 0x3b34 &#xA;      PCI Revision ID: 0x0006 &#xA;      PCI Vendor ID: 0x8086 &#xA;      Bus Number: 0xfd &#xA;&#xA;        Hub:&#xA;&#xA;          Product ID: 0x2514&#xA;          Vendor ID: 0x0424  (SMSC)&#xA;          Version: 0.03&#xA;          Speed: Up to 480 Mb/sec&#xA;          Location ID: 0xfd100000 / 2&#xA;          Current Available (mA): 500&#xA;          Current Required (mA): 2&#xA;&#xA;            Communication Device:&#xA;&#xA;              Product ID: 0x0043&#xA;              Vendor ID: 0x2341&#xA;              Version: 0.01&#xA;              Serial Number: 9314036423335121A0B1&#xA;              Speed: Up to 12 Mb/sec&#xA;              Manufacturer: Arduino (www.arduino.cc)&#xA;              Location ID: 0xfd130000 / 8&#xA;              Current Available (mA): 500&#xA;              Current Required (mA): 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note the &amp;quot;www.arduino.cc&amp;quot; entry.&lt;/p&gt;&#xA;&lt;p&gt;In your Arduino IDE you should see the Arduino as a tty.usbmodemfd131 (or some similar number).&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zcTbg.png&quot; alt=&quot;Arduino Uno USB modem&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you see all that it should work.&lt;/p&gt;&#xA;&lt;p&gt;If not, please state in what way it differs.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Programmer -&amp;gt; AVRISP mkll&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The &lt;strong&gt;Tools &amp;gt; Programmer&lt;/strong&gt; menu selection is only used when you do &lt;strong&gt;Tools &amp;gt; Burn Bootloader&lt;/strong&gt; or &amp;quot;Upload Using Programmer. It is completely ignored when doing a standard &amp;quot;Upload&amp;quot;. You should be doing an &amp;quot;Upload&amp;quot; (Command-U) not an &amp;quot;Upload using programmer&amp;quot; (Shift+Command+U). So it makes absolutely no difference what you select from the &lt;strong&gt;Tools &amp;gt; Programmer&lt;/strong&gt; menu.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="26916" LastEditDate="2020-08-14T00:37:04.307" LastActivityDate="2020-08-14T00:37:04.307" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13324" PostTypeId="2" ParentId="13317" CreationDate="2015-07-09T23:08:38.357" Score="0" Body="&lt;p&gt;The problem does not appear to be what you think it is, because I can't reproduce it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Active System&#xA;char hvacSystems[4][5] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;};&#xA;int activeSystem = 0;  &#xA;&#xA;String displayActiveSystem;&#xA;&#xA;bool systemNeedsToBeCycled = true;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  displayActiveSystem = hvacSystems[activeSystem]; // &amp;lt;-- Should now be String &quot;off&quot;&#xA;&#xA;  Serial.println (displayActiveSystem);&#xA;&#xA;  if(systemNeedsToBeCycled){&#xA;    activeSystem++;&#xA;    displayActiveSystem = hvacSystems[activeSystem]; // &amp;lt;-- Should now be String &quot;Fan&quot;&#xA;    Serial.println (displayActiveSystem);&#xA;    }&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Off&#xA;Fan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please post a complete sketch that reproduces the problem. The placement of variables, and their type, might influence the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used Serial.println() to show the variable contents, which are what you expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Possibly this will work better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tft.print(displayActiveSystem.c_str ());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-09T23:08:38.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13325" PostTypeId="2" ParentId="13298" CreationDate="2015-07-10T00:03:56.957" Score="4" Body="&lt;p&gt;Some of the libraries you mention (iomanip, iostream, queue, string) are part of the STL - Standard Template Library. Whilst it does not ship with the IDE download, you can install it yourself. See &lt;a href=&quot;http://andybrown.me.uk/wk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;The Standard Template Library (STL) for AVR with C++ streams&lt;/a&gt; - a port to the Arduino by Andy Brown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11119&quot; rel=&quot;nofollow&quot;&gt;implementation notes here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that a lot of Arduinos don't have much RAM, so you need to use libraries like this with caution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Library download: &lt;a href=&quot;http://andybrown.me.uk/wk/files/avr-stl-1.1.1.zip&quot; rel=&quot;nofollow&quot;&gt;AVR standard template library, version 1.1.1&lt;/a&gt; - 197.29 kB&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-10T00:03:56.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13326" PostTypeId="1" CreationDate="2015-07-10T00:17:27.937" Score="0" ViewCount="3930" Body="&lt;p&gt;I'm trying to control a DC motor through L293D motor controller&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/E21yz.jpg&quot; alt=&quot;circuit diagram using L293D motor controller and Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int controlPin2 = 4; // connected to pin 2 on the H-bridge&#xA;    const int enablePin = 3;   // connected to pin 1 on the H-bridge&#xA;&#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(controlPin2, OUTPUT);&#xA;  pinMode(enablePin, OUTPUT);&#xA;&#xA;  digitalWrite(enablePin, LOW);&#xA;  digitalWrite(controlPin2, LOW);&#xA;&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;Ready&quot;);&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;if (Serial.available() &amp;gt; 0) {&#xA;    int inByte = Serial.read();&#xA;&#xA;    switch (inByte) {&#xA;    case '0':   &#xA;  digitalWrite(enablePin, LOW);&#xA;   digitalWrite(controlPin2, LOW);&#xA; Serial.println(&quot;OFF&quot;);&#xA;      break;&#xA;    case '1':   &#xA;&#xA;  digitalWrite(controlPin2, HIGH);&#xA;    analogWrite(enablePin, 50);&#xA;    Serial.println(&quot;CW slow&quot;);&#xA;      break;&#xA;          case '2':   &#xA;&#xA;  digitalWrite(controlPin2, HIGH);&#xA;    analogWrite(enablePin, 100);&#xA;    Serial.println(&quot;CW slow +&quot;);&#xA;      break;&#xA;          case '3':   &#xA;  digitalWrite(controlPin2, HIGH);&#xA;    analogWrite(enablePin, 150);&#xA;    Serial.println(&quot;CW medium&quot;);&#xA;      break;&#xA;          case '4':   &#xA;  digitalWrite(controlPin2, HIGH);&#xA;    analogWrite(enablePin, 200);&#xA;    Serial.println(&quot;CW fast&quot;);&#xA;      break;&#xA;          case '5':   &#xA;  digitalWrite(controlPin2, HIGH);&#xA;    analogWrite(enablePin, 250);&#xA;    Serial.println(&quot;CW fast +&quot;);&#xA;      break;&#xA;    case '6':   &#xA;  digitalWrite(controlPin2, LOW);&#xA;    analogWrite(enablePin, 50);&#xA;    Serial.println(&quot;CCW slow&quot;);&#xA;      break;&#xA;      case '7':   &#xA;  digitalWrite(controlPin2, LOW);&#xA;    analogWrite(enablePin, 100);&#xA;        Serial.println(&quot;CCW slow +&quot;);&#xA;      break;&#xA;      case '8':   &#xA;  digitalWrite(controlPin2, LOW);&#xA;    analogWrite(enablePin, 150);&#xA;        Serial.println(&quot;CCW medium&quot;);&#xA;      break;&#xA;       case '9':   &#xA;  digitalWrite(controlPin2, LOW);&#xA;    analogWrite(enablePin, 250);&#xA;        Serial.println(&quot;CCW fast&quot;);&#xA;      break;&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is working well except 1 to 5 are reversed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 should be the minimum speed&lt;/li&gt;&#xA;&lt;li&gt;5 should be the maximum.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But it is back to front:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5 is the minimum speed&lt;/li&gt;&#xA;&lt;li&gt;1 is the maximum speed&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="1233" LastEditDate="2015-07-10T14:46:30.263" LastActivityDate="2015-07-10T14:46:30.263" Title="Controlling DC motor speed?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13327" PostTypeId="2" ParentId="13326" CreationDate="2015-07-10T01:38:09.883" Score="2" Body="&lt;p&gt;So first thing, you should try to be more disciplined with your code formatting and the question...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: it's best to use #define as it doesn't use memory for storing pin numbers... It's like Find and Replace in a text editor, this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int controlPin2 = 4; // connected to pin 2 on the H-bridge&#xA;const int enablePin = 3;   // connected to pin 1 on the H-bridge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Becomes this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define controlPin2 4  // connected to pin 2 on the H-bridge&#xA;#define enablePin   3  // connected to pin 1 on the H-bridge&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this is the tidied up code, you can see the problem is a lot more approachable when the code is indented consistently, and good use of spaces and new lines is used...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define controlPin2 4  // connected to pin 2 on the H-bridge&#xA;#define enablePin   3  // connected to pin 1 on the H-bridge&#xA;&#xA;&#xA;void setup () {&#xA;    pinMode( controlPin2, OUTPUT );&#xA;    pinMode( enablePin, OUTPUT );&#xA;&#xA;    digitalWrite( enablePin, LOW );&#xA;    digitalWrite( controlPin2, LOW );&#xA;&#xA;    Serial.begin( 9600 );&#xA;    Serial.println( &quot;Ready&quot; );&#xA;}&#xA;&#xA;void loop() {&#xA;    if ( Serial.available() &amp;gt; 0) {&#xA;        int inByte = Serial.read();&#xA;&#xA;        switch ( inByte ) {&#xA;&#xA;            case '0':&#xA;                digitalWrite( enablePin, LOW );&#xA;                digitalWrite( controlPin2, LOW );&#xA;                Serial.println( &quot;OFF&quot; );&#xA;            break;&#xA;&#xA;            case '1':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 50 );&#xA;                Serial.println( &quot;CW slow&quot; );&#xA;            break;&#xA;&#xA;            case '2':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 100 );&#xA;                Serial.println( &quot;CW slow +&quot; );&#xA;            break;&#xA;&#xA;            case '3':   &#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 150 );&#xA;                Serial.println( &quot;CW medium&quot; );&#xA;            break;&#xA;&#xA;            case '4':   &#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 200 );&#xA;                Serial.println( &quot;CW fast&quot; );&#xA;            break;&#xA;&#xA;            case '5':   &#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 250 );&#xA;                Serial.println( &quot;CW fast +&quot; );&#xA;            break;&#xA;&#xA;            case '6':   &#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 50 );&#xA;                Serial.println( &quot;CCW slow&quot; );&#xA;            break;&#xA;&#xA;            case '7':   &#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 100 );&#xA;                Serial.println( &quot;CCW slow +&quot; );&#xA;            break;&#xA;&#xA;            case '8':   &#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 150 );&#xA;                Serial.println( &quot;CCW medium&quot; );&#xA;            break;&#xA;&#xA;            case '9':   &#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 250 );&#xA;                Serial.println( &quot;CCW fast&quot; );&#xA;            break;&#xA;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your actual problem is that you need to reverse cases 1, 2, 3, 4, 5 to be 5, 4, 3, 2, 1...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inelegant&lt;/strong&gt;: would be to simply change the case numbers, they don't have to be in-order.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Elegant&lt;/strong&gt;: copy and paste the code in each of the 5 cases about.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The result of option 2 is as follows, please feel free to confirm this is working?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define controlPin2 4  // connected to pin 2 on the H-bridge&#xA;#define enablePin   3  // connected to pin 1 on the H-bridge&#xA;&#xA;&#xA;void setup () {&#xA;    pinMode( controlPin2, OUTPUT );&#xA;    pinMode( enablePin, OUTPUT );&#xA;&#xA;    digitalWrite( enablePin, LOW );&#xA;    digitalWrite( controlPin2, LOW );&#xA;&#xA;    Serial.begin( 9600 );&#xA;    Serial.println( &quot;Ready&quot; );&#xA;}&#xA;&#xA;void loop() {&#xA;    if ( Serial.available() &amp;gt; 0) {&#xA;        int inByte = Serial.read();&#xA;&#xA;        switch ( inByte ) {&#xA;&#xA;            case '0':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 250 );&#xA;                Serial.println( &quot;CW fast +&quot; );&#xA;            break;&#xA;&#xA;            case '1':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 200 );&#xA;                Serial.println( &quot;CW fast&quot; );&#xA;            break;&#xA;&#xA;            case '2':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 150 );&#xA;                Serial.println( &quot;CW medium&quot; );&#xA;            break;&#xA;&#xA;            case '3':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 100 );&#xA;                Serial.println( &quot;CW slow +&quot; );&#xA;            break;&#xA;&#xA;            case '4':&#xA;                digitalWrite( controlPin2, HIGH );&#xA;                analogWrite( enablePin, 50 );&#xA;                Serial.println( &quot;CW slow&quot; );&#xA;            break;&#xA;&#xA;            case '5':&#xA;                digitalWrite( enablePin, LOW );&#xA;                digitalWrite( controlPin2, LOW );&#xA;                Serial.println( &quot;OFF&quot; );&#xA;            break;&#xA;&#xA;            case '6':&#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 50 );&#xA;                Serial.println( &quot;CCW slow&quot; );&#xA;            break;&#xA;&#xA;            case '7':&#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 100 );&#xA;                Serial.println( &quot;CCW slow +&quot; );&#xA;            break;&#xA;&#xA;            case '8':&#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 150 );&#xA;                Serial.println( &quot;CCW medium&quot; );&#xA;            break;&#xA;&#xA;            case '9':&#xA;                digitalWrite( controlPin2, LOW );&#xA;                analogWrite( enablePin, 250 );&#xA;                Serial.println( &quot;CCW fast&quot; );&#xA;            break;&#xA;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-07-10T01:38:09.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13328" PostTypeId="1" AcceptedAnswerId="13350" CreationDate="2015-07-10T02:07:05.103" Score="0" ViewCount="254" Body="&lt;p&gt;I have 2 Xbee Series2 modules, one set to Coordinator AT (Connected to PC with XCTU via USB dongle) and other set to Router AT(Connected to Arduino is connected to PC USB... RX&gt;TX  TX&gt;RX and 5V GND)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://continentalee.com.sg/xbee-adapter&quot; rel=&quot;nofollow&quot;&gt;http://continentalee.com.sg/xbee-adapter&lt;/a&gt;&#xA;My xbee adapter&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the programme uploaded into Arduino, a very simple sketch to test xbee wireless communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is here&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char msg = ' '; //contains the message from arduino sender&#xA;const int led = 13; //led at pin 13&#xA;&#xA;&#xA;void setup() {&#xA;Serial.begin(9600);//Remember that the baud must be the same on both arduinos&#xA;pinMode(led,OUTPUT);&#xA;}&#xA;void loop() {&#xA;while(Serial.available() &amp;gt; 0) {&#xA;           msg=(char) Serial.read();&#xA;&#xA;           if(msg=='H') {&#xA;               digitalWrite(led,HIGH);&#xA;           }&#xA;           if(msg=='L') {&#xA;                digitalWrite(led,LOW);&#xA;           }&#xA;delay(1000);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem comes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I type &quot;H&quot; in the Serial Com, the led light up, and the letter &quot;H&quot; appears in the XCTU console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;however, when I type something into the XCTU console, nothing appears on my Serial monitor and no light is seen on arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help in advance.&lt;/p&gt;&#xA;" OwnerUserId="11129" LastActivityDate="2015-07-10T15:32:06.063" Title="xbee communication not established between arduino" Tags="|arduino-mega|xbee|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13329" PostTypeId="2" ParentId="13313" CreationDate="2015-07-10T02:59:53.977" Score="0" Body="&lt;p&gt;If you need a real computer, there are nowadays various options based on the Intel NUC concept.&#xA;&lt;a href=&quot;http://www.gigabyte.us/products/list.aspx?s=47&amp;amp;ck=104&quot; rel=&quot;nofollow&quot;&gt;The Gigabyte variant&lt;/a&gt;, for example. It also has GPIOS accessible through a normal pinheader, in case you need them.&#xA;And, being x86, there is virtualyl no risk of loosing the supplier.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-10T02:59:53.977" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13330" PostTypeId="2" ParentId="13122" CreationDate="2015-07-10T03:32:52.100" Score="1" Body="&lt;p&gt;The HC-SR04's range is 2cm to 300 cm, if you exceed this range or come below this range, which is exactly what you are doing, the utrasonic sensor will not receive any echo and hence there will be no data on the output. &#xA;If you bring it too close and since both the transmitter and receiver located close to each other, the receiver will not receive any ultrasonic. &#xA;Put a function that checks if the ultrasonic comes down to 2-3. If it becomes true beep a buzzer that tells you that you are too close. Don't let it reach 0.  &lt;/p&gt;&#xA;" OwnerUserId="10838" LastActivityDate="2015-07-10T03:32:52.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13331" PostTypeId="1" CreationDate="2015-07-10T04:57:56.830" Score="2" ViewCount="2597" Body="&lt;p&gt;All the Arduino examples involving communication via USB I could find use a virtual COM Port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino part it's &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(baudrate);&#xA;Serial.write(byte);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on the PC part it's just using a virtual COM Port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Arduino Due includes a native USB port, without all that UART+FTDI chip. I couldn't find any examples using the native interface, it seems everyone is content with communicating using the simple but slow way of &lt;code&gt;Serial.write();&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make full use of the native USB port, besides directly accessing the registers of the Cortex-M3, which seems to be a very tedious and complicated process? The data I would like to transmit is both large and time-critical, so I need to take care of buffer sizes, transfer types, etc., so writing characters one at a time to a general-purpose serial interface is not enough. The PC endpoint (I'm considering using libusb) should also see a proper USB device instead of a virtual COM port.&lt;/p&gt;&#xA;" OwnerUserId="11045" LastActivityDate="2015-07-10T04:57:56.830" Title="How to use the native USB of the Arduino Due for high-speed communication?" Tags="|arduino-due|usb|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13332" PostTypeId="1" CreationDate="2015-07-10T05:37:36.667" Score="2" ViewCount="64" Body="&lt;p&gt;from examples of  RadioHead library .&#xA;&lt;a href=&quot;https://github.com/PaulStoffregen/RadioHead/tree/master/examples/nrf905&quot; rel=&quot;nofollow&quot;&gt;https://github.com/PaulStoffregen/RadioHead/tree/master/examples/nrf905&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11046" LastActivityDate="2015-07-10T05:37:36.667" Title="no response in recieving with arduino uno by nfr905" Tags="|wireless|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13333" PostTypeId="1" CreationDate="2015-07-10T07:49:38.127" Score="0" ViewCount="7299" Body="&lt;p&gt;I am trying to read the pH value from a analog pH meter, SEN-01454. From the source code I found, voltage maps to pH value. This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pHArray[pHArrayIndex++]=analogRead(SensorPin);&#xA;      if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;&#xA;      voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;&#xA;      pHValue = 3.5*voltage+Offset;&#xA;      samplingTime=millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then the value is not correct. So how do i actually do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29&quot; rel=&quot;nofollow&quot;&gt;example code from Wiki page&lt;/a&gt; for product.&lt;/p&gt;&#xA;" OwnerUserId="11091" LastEditorUserId="213" LastEditDate="2015-08-29T00:23:03.033" LastActivityDate="2015-08-29T00:23:03.033" Title="How to read pH value" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13334" PostTypeId="1" AcceptedAnswerId="13337" CreationDate="2015-07-10T08:17:55.603" Score="0" ViewCount="788" Body="&lt;p&gt;I have a Yun and I'm trying to change the URL I type in to access the Web UI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've successfully changed its hostname in &lt;code&gt;/etc/config/system&lt;/code&gt;, which now lets me SSH in using the new name. However:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Going to newname.local doesn't work (no response at all).&lt;/li&gt;&#xA;&lt;li&gt;Going to arduino.local pulls up the green page 'Wait a moment or click here...', after which no page is rendered.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How can I access my Yun by typing in newname.local in my browser?&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-07-10T10:43:37.867" Title="Change arduino.local server address" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13335" PostTypeId="1" AcceptedAnswerId="13341" CreationDate="2015-07-10T10:32:52.277" Score="2" ViewCount="578" Body="&lt;p&gt;I'm pretty new to Arduino and I'm developing my first real-world project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Arduino Mega with a full working sketch in it which is going to be placed in several distant places and I have a number of &quot;mantainers&quot; that will need to get to the place, connect the board with their Windows (Vista+) laptop (USB), upload a new version of the sketch (if available), download some data from EEPROM and change (if needed) some parameters stored in PROGMEM. This just to give you the full picture, now I come to the questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to attempt is to write (in c++) a software that gives non-programmers a UI to do this stuff easily, so I wonder:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I load the .hex file to the board? I kinda got I have to use AVRdude: is there any c++ example/tutorial/library I can use not to reinvent the wheel?&lt;/li&gt;&#xA;&lt;li&gt;When can I write to PROGMEM? When I connect with the serial cable Arduino stops the running sketch, waits for a new sketch and, if it does not arrive, it starts the old sketch back again. I guess that is the time to write to PROGMEM: if there is a running sketch I cannot do it, am I right?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11135" LastActivityDate="2015-07-10T15:11:53.590" Title="How do I upload sketch (and parameters) through a user interface" Tags="|c++|uploading|progmem|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13336" PostTypeId="2" ParentId="13333" CreationDate="2015-07-10T10:36:27.487" Score="1" Body="&lt;p&gt;This is SOME of the code. We are missing the &lt;code&gt;avergearray()&lt;/code&gt; function.. I suspect you're taking one reading and averaging it with both old &amp;amp; future ones, but this code clearly is meant to sit in a loop..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From another &lt;a href=&quot;http://www.sgbotic.com/index.php?dispatch=products.view&amp;amp;product_id=1454&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;, I got this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;# This sample codes is for testing the pH meter V1.0.&#xA; # Editor : YouYou&#xA; # Date   : 2013.10.12&#xA; # Ver    : 0.1&#xA; # Product: pH meter&#xA; # SKU    : SEN0161&#xA;*/&#xA;&#xA;#define SensorPin 0          //pH meter Analog output to Arduino Analog Input 0&#xA;unsigned long int avgValue;  //Store the average value of the sensor feedback&#xA;float b;&#xA;int buf[10],temp;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(13,OUTPUT);  &#xA;  Serial.begin(9600);  &#xA;  Serial.println(&quot;Ready&quot;);    //Test the serial monitor&#xA;}&#xA;void loop()&#xA;{&#xA;  for(int i=0;i&amp;lt;10;i++)       //Get 10 sample value from the sensor for smooth the value&#xA;  { &#xA;    buf[i]=analogRead(SensorPin);&#xA;    delay(10);&#xA;  }&#xA;  for(int i=0;i&amp;lt;9;i++)        //sort the analog from small to large&#xA;  {&#xA;    for(int j=i+1;j&amp;lt;10;j++)&#xA;    {&#xA;      if(buf[i]&amp;gt;buf[j])&#xA;      {&#xA;        temp=buf[i];&#xA;        buf[i]=buf[j];&#xA;        buf[j]=temp;&#xA;      }&#xA;    }&#xA;  }&#xA;  avgValue=0;&#xA;  for(int i=2;i&amp;lt;8;i++)                      //take the average value of 6 center sample&#xA;    avgValue+=buf[i];&#xA;  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt&#xA;  phValue=3.5*phValue;                      //convert the millivolt into pH value&#xA;  Serial.print(&quot;    pH:&quot;);  &#xA;  Serial.print(phValue,2);&#xA;  Serial.println(&quot; &quot;);&#xA;  digitalWrite(13, HIGH);       &#xA;  delay(800);&#xA;  digitalWrite(13, LOW); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which reads in the array first and then averages it. Is this what your code does? If so, what sort of errors are you seeing?&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2015-07-10T10:36:27.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13337" PostTypeId="2" ParentId="13334" CreationDate="2015-07-10T10:43:37.867" Score="0" Body="&lt;p&gt;That should be working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just logged into my Yún and changed its name by editing that file.  I then restarted &lt;code&gt;avahi-daemon&lt;/code&gt; since that is what broadcasts its name (faster to restart the daemon that reboot the whole Yún).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Browsing to the new name worked fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matt@dell:~$ ssh root@arduino.local&#xA;root@Arduino:~# vi /etc/config/system&#xA;(edit the config file)&#xA;root@Arduino:~# hostname skybridge&#xA;(manually changing the hostname so I don't have to reboot)&#xA;root@skybridge:~# /etc/init.d/avahi-daemon restart&#xA;(restart the avahi daemon)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Browsing to &lt;code&gt;skybridge.local&lt;/code&gt; now shows me the Arduino login as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a further test I have just rebooted my Yún so it runs everything from scratch and it still works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of caches involved in the system, any of which may be getting in the way.  It could be that the browser has cached incorrect or out of date information about the FQDN (&lt;em&gt;fully qualified domain name&lt;/em&gt;) for the name you have given your Yún, in which case just closing and re-opening your browser may help.  It may be that the mDNS lookup system on your computer (you haven't mentioned which operating system you are using, which is a big factor) has cached old or out-dated information for the FQDN, in which case flushing that cache may help (how you do that depends on your OS), or just rebooting your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, if you are on Linux (Windows lacks these basic networking facilities along with many other basic tools), you can query the network for your Arduino Yún with the &lt;code&gt;avahi-browse&lt;/code&gt; and &lt;code&gt;avahi-resolve&lt;/code&gt; commands.  OS X has similar tools, but I don't know off hand what the commands are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matt@dell:~$ avahi-browse _arduino._tcp&#xA;+  wlan0 IPv4 skybridge                                     _arduino._tcp        local&#xA;^CGot SIGINT, quitting.&#xA;matt@dell:~$ avahi-resolve -n skybridge.local&#xA;skybridge.local 192.168.0.252&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-10T10:43:37.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13339" PostTypeId="2" ParentId="13335" CreationDate="2015-07-10T10:52:57.033" Score="3" Body="&lt;p&gt;1) Why not just&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;system(&quot;avrdude ...&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's more or less what the Arduino IDE does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If you really want to embed the data in the executable, see&#xA;&lt;a href=&quot;http://gareus.org/wiki/embedding_resources_in_executables&quot; rel=&quot;nofollow&quot;&gt;Embedding Blobs in&#xA;Binaries&lt;/a&gt;.&#xA;You would need to re-link and re-upload the program each time you change&#xA;that data. You won't need the Arduino IDE, as it's only job is basically&#xA;to call avr-g++ and avrdude. You &lt;em&gt;can&lt;/em&gt; use the IDE if you find it's CLI&#xA;easier than those of the standard tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put the data in EPPROM instead, the avrdude can upload it without&#xA;re-uploading the program.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-07-10T11:05:00.323" LastActivityDate="2015-07-10T11:05:00.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13341" PostTypeId="2" ParentId="13335" CreationDate="2015-07-10T10:57:23.153" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I load the .hex file to the board? I kinda got I have to use AVRdude: is there any c++ example/tutorial/library I can use not to reinvent the wheel?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you have to use avrdude.  The simplest way is just to bundle avrdude.exe and the avrdude.conf file with your program and call it, along with its required parameters, with &lt;code&gt;system()&lt;/code&gt; or some similar (eg &lt;code&gt;execv()&lt;/code&gt;) method (or whatever Windows has decided to provide instead of those standard functions - who knows what goes through the minds of Windows developers...).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When can I write to PROGMEM? When I connect with the serial cable Arduino stops the running sketch, waits for a new sketch and, if it does not arrive, it starts the old sketch back again. I guess that is the time to write to PROGMEM: if there is a running sketch I cannot do it, am I right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When you upload a new sketch you are writing to PROGMEM.  That's really the only time you can do it.  Yes, there are ways you can write pages of data to PROGMEM, and that's exactly what the bootloader does when you upload a sketch, but manipulating individual variables in PROGMEM is not possible without major brain surgery being done in your sketch.  To store these kind of tweakable parameters you would normally use the EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can also be good to use external storage for some of these things to - either an SD card (overkill) or an external SPI or I2C EEPROM or Flash chip.  This keeps all the data completely separate from your sketch so you can never overwrite that data when you upload a new sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is, of course, up to your sketch to provide some kind of interface to tweak the settings, whether stored in internal EEPROM or an external EEPROM chip.  Creating some kind of serial protocol which your C++ program can interface with will be essential.  Only while your sketch is running will you be able to change those variables.  If you don't want to allow end users access to that interface then one method could be to have a separate sketch which is a &quot;calibration and configuration&quot; sketch which your program uploads in order to adjust the settings.  Once you have finished it then re-uploads the original (or new) sketch to allow normal operation again.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-10T10:57:23.153" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13344" PostTypeId="2" ParentId="3700" CreationDate="2015-07-10T12:56:07.003" Score="6" Body="&lt;p&gt;&lt;em&gt;I am Antonis from codebender and we recently released drivers for the Mac.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to overcome this problem, without disabling your computer's security settings, maybe I can help you with this! Codebender just released their Mac drivers package, which includes a new driver that supports the CH340G chip, on Yosemite and all other versions of OS X for Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will help you to install these drivers securely, and&#xA;all you have to do is to &lt;a href=&quot;https://codebender.cc/static/walkthrough/page/3&quot;&gt;download and install them&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find more &lt;a href=&quot;http://blog.codebender.cc/2015/06/12/new-stuff-updated-mac-drivers/&quot;&gt;information about the drivers in the codebender blog&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11138" LastEditorUserId="8090" LastEditDate="2015-07-11T19:55:07.217" LastActivityDate="2015-07-11T19:55:07.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13345" PostTypeId="1" AcceptedAnswerId="13534" CreationDate="2015-07-10T13:12:14.840" Score="1" ViewCount="1955" Body="&lt;p&gt;I am trying to write a simple Java program to display the analog input fed to an Arduino board upon a stimulus from a user on some physical sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the Arduino program itself and look at the serial monitor, I see the analog read based on user input updated instantly. However, when reading the input from my Java program, there is a significant delay (8-12 seconds) between the physical stimulus and the display of the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code uploaded to Arduino is very simple, just cycle through a bunch of analog ports and print the data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(30, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;  digitalWrite(30, HIGH);&#xA;&#xA;  for (int i = 0; i &amp;lt; 10; i++) {&#xA;    int sensorValue = analogRead(i);&#xA;    Serial.print(String(i) + &quot;:&quot;);&#xA;    Serial.println(sensorValue);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Java code I am using is almost entirely copied from the example provided &lt;a href=&quot;http://playground.arduino.cc/Interfacing/Java&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, with the exception that I updated the port name to work for my system (Mac OS X 10.10.3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Java code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import java.io.BufferedReader;&#xA;import java.io.InputStreamReader;&#xA;import java.io.OutputStream;&#xA;import gnu.io.CommPortIdentifier; &#xA;import gnu.io.SerialPort;&#xA;import gnu.io.SerialPortEvent; &#xA;import gnu.io.SerialPortEventListener; &#xA;import java.util.Enumeration;&#xA;&#xA;&#xA;public class SerialTest implements SerialPortEventListener {&#xA;&#xA;    SerialPort serialPort;&#xA;&#xA;    /** The port we're normally going to use. */&#xA;    private static final String PORT_NAMES[] = { &#xA;            &quot;/dev/cu.usbmodem1411&quot;,&#xA;            &quot;/dev/cu.usbmodem1451&quot;,&#xA;    };&#xA;&#xA;    /**&#xA;    * A BufferedReader which will be fed by a InputStreamReader &#xA;    * converting the bytes into characters &#xA;    * making the displayed results codepage independent&#xA;    */&#xA;    private BufferedReader input;&#xA;&#xA;    /** The output stream to the port */&#xA;    private OutputStream output;&#xA;&#xA;    /** Milliseconds to block while waiting for port open */&#xA;    private static final int TIME_OUT = 2000;&#xA;&#xA;    /** Default bits per second for COM port. */&#xA;    private static final int DATA_RATE = 9600;&#xA;&#xA;    public void initialize() {&#xA;        CommPortIdentifier portId = null;&#xA;        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();&#xA;&#xA;        //First, Find an instance of serial port as set in PORT_NAMES.&#xA;        while (portEnum.hasMoreElements()) {&#xA;            CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();&#xA;            for (String portName : PORT_NAMES) {&#xA;                if (currPortId.getName().equals(portName)) {&#xA;                    portId = currPortId;&#xA;                    break;&#xA;                }&#xA;            }&#xA;        }&#xA;        if (portId == null) {&#xA;            System.out.println(&quot;Could not find COM port.&quot;);&#xA;            return;&#xA;        }&#xA;&#xA;        try {&#xA;            // open serial port, and use class name for the appName.&#xA;            serialPort = (SerialPort) portId.open(this.getClass().getName(),&#xA;                    TIME_OUT);&#xA;&#xA;            // set port parameters&#xA;            serialPort.setSerialPortParams(DATA_RATE,&#xA;                    SerialPort.DATABITS_8,&#xA;                    SerialPort.STOPBITS_1,&#xA;                    SerialPort.PARITY_NONE);&#xA;&#xA;            // open the streams&#xA;            input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));&#xA;            output = serialPort.getOutputStream();&#xA;&#xA;            // add event listeners&#xA;            serialPort.addEventListener(this);&#xA;            serialPort.notifyOnDataAvailable(true);&#xA;        } catch (Exception e) {&#xA;            System.err.println(e.toString());&#xA;        }&#xA;    }&#xA;&#xA;    /**&#xA;     * This should be called when you stop using the port.&#xA;     * This will prevent port locking on platforms like Linux.&#xA;     */&#xA;    public synchronized void close() {&#xA;        if (serialPort != null) {&#xA;            serialPort.removeEventListener();&#xA;            serialPort.close();&#xA;        }&#xA;    }&#xA;&#xA;    /**&#xA;     * Handle an event on the serial port. Read the data and print it.&#xA;     */&#xA;    public synchronized void serialEvent(SerialPortEvent oEvent) {&#xA;        if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {&#xA;            try {&#xA;                String inputLine=input.readLine();&#xA;                System.out.println(inputLine);&#xA;            } catch (Exception e) {&#xA;                System.err.println(e.toString());&#xA;            }&#xA;        }&#xA;        // Ignore all the other eventTypes, but you should consider the other ones.&#xA;    }&#xA;&#xA;    public static void main(String[] args) throws Exception {&#xA;        SerialTest main = new SerialTest();&#xA;        main.initialize();&#xA;        Thread t=new Thread() {&#xA;            public void run() {&#xA;                //the following line will keep this app alive for 1000 seconds,&#xA;                //waiting for events to occur and responding to them (printing incoming messages to console).&#xA;                try {Thread.sleep(1000000);} catch (InterruptedException ie) {}&#xA;            }&#xA;        };&#xA;        t.start();&#xA;        System.out.println(&quot;Started&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the program does is print out the values of the Arduino serial monitor, yet it takes way longer (8-12 seconds) through Java than it does from the Arduino program itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Why is this happening?&lt;br&gt;&#xA;2) How do I fix it?&lt;/p&gt;&#xA;" OwnerUserId="11140" LastActivityDate="2016-12-27T21:12:58.433" Title="Reading Arduino from Java is way too slow" Tags="|arduino-mega|arduino-ide|mac-os|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13346" PostTypeId="1" CreationDate="2015-07-10T14:12:54.287" Score="2" ViewCount="295" Body="&lt;p&gt;I am trying to control a led ON/OFF using Arduino UNO and a Bluetooth shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/35Gsq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sgi9C.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/o7cPz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is based on hc-05. The tutorials I found about hc-05 are not working for me. I have the hc-05 embedded in the shield and I did not  find any tutorials  for this shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code (it is working when I use the USB serial ctrl + shift + m).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup () {&#xA;pinMode( 13, OUTPUT );&#xA;digitalWrite(13,LOW);&#xA;&#xA;Serial.begin( 9600 );&#xA;Serial.println( &quot;Ready&quot; );&#xA;}&#xA;&#xA;void loop() {&#xA;if ( Serial.available() &amp;gt; 0) {&#xA;    int inByte = Serial.read();&#xA;&#xA;    switch ( inByte ) {&#xA;&#xA;        case '0':&#xA;            digitalWrite( 13, LOW );&#xA;        break;&#xA;&#xA;        case '1':&#xA;            digitalWrite( 13, HIGH );&#xA;        break;&#xA;&#xA;&#xA;&#xA;    }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I connected my android phone to the shield successfully using blurterm2. When I send 1 or 0 nothing happens. What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorDisplayName="user6430" LastEditDate="2015-07-12T09:09:37.200" LastActivityDate="2015-07-13T05:25:26.183" Title="Blutooth shield LED control" Tags="|arduino-uno|serial|led|bluetooth|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13347" PostTypeId="1" AcceptedAnswerId="14640" CreationDate="2015-07-10T14:37:19.617" Score="0" ViewCount="145" Body="&lt;p&gt;I'm running the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;XBOXRECV.h&amp;gt;&#xA;&#xA;// Satisfy the IDE, which needs to see the include statment in the ino too.&#xA;#ifdef dobogusinclude&#xA;#include &amp;lt;spi4teensy3.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#endif&#xA;&#xA;USB Usb;&#xA;XBOXRECV Xbox(&amp;amp;Usb);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;#if !defined(__MIPSEL__)&#xA;  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection&#xA;#endif&#xA;  if (Usb.Init() == -1) {&#xA;    Serial.print(F(&quot;\r\nOSC did not start&quot;));&#xA;    while (1); //halt&#xA;  }&#xA;  Serial.print(F(&quot;\r\nXbox Wireless Receiver Library Started&quot;));&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  Usb.Task();&#xA;  if (Xbox.XboxReceiverConnected) {&#xA;    if (Xbox.getAnalogHat(LeftHatY) == 0) {&#xA;      Serial.print(Xbox.getAnalogHat(LeftHatY));&#xA;    }&#xA;   Serial.print(&quot;TEST&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running the example that the library includes and a spin off I wrote for test purposes I keep getting random output, this is just some of it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;9�]==�=�~=���y��:.�:�:����9�=��������:�:�\=���^=�?�}�:^���:�|]=9�\=&lt;em&gt;�&lt;/em&gt;�������:�ܗ��.\�~=���&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11143" LastEditorUserId="11529" LastEditDate="2015-08-29T02:41:21.010" LastActivityDate="2015-08-29T02:41:21.010" Title="xBox receiver code output is scrambled" Tags="|arduino-uno|programming|shields|usb|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13348" PostTypeId="2" ParentId="13346" CreationDate="2015-07-10T14:45:51.020" Score="1" Body="&lt;p&gt;Have you tried the turning just running a simple program to check if the led still works, such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup () {&#xA;pinMode( 13, OUTPUT );&#xA;}&#xA;void loop() {&#xA; digitalWrite( 13, HIGH );&#xA; delay(1000);&#xA; digitalWrite(13,LOW);&#xA; delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11143" LastActivityDate="2015-07-10T14:45:51.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13349" PostTypeId="2" ParentId="13335" CreationDate="2015-07-10T15:11:53.590" Score="1" Body="&lt;p&gt;The avrdude/upload part has been fairly well covered by the other answers, but what has not been mentioned yet is that it is fairy trivial to modify program memory contents by modifying the hex file to be uploaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you just write hex-encoded bytes in the correct place in the file, and then update the checksum at the end of each line you modify.  It can help if you put a readily recognizable placeholder sequence in the desired location in your source code, which you can look for in the hex file as an extra verification you are making your substitutions in the correct place.  This is fairly straightforward string processing and unsigned byte math which you can accomplish in the language of your choice.  There are also tools which can convert between hex files and binary images, and probably tools or libraries which can fix the checksums for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do pay attention to the license terms of avrdude and any other non-original code or tools you distribute.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-07-10T15:11:53.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13350" PostTypeId="2" ParentId="13328" CreationDate="2015-07-10T15:32:06.063" Score="0" Body="&lt;p&gt;Your example does not show your code that sends correctly but I will assume that it used 9600 speed and that the xbees are configured to 9600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure if this will help ...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino is connected to PC USB... RX&gt;TX TX&gt;RX &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;1) In this case maybe you should ensure that xbee tx is connected to the correct rx pin on the Arduino? I know you have stated this above but with the basic xbee configuration, if data works one way then it should also work the opposite way.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;however, when I type something into the XCTU console, nothing appears on my Serial monitor and no light is seen on arduino&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;2) Your example doesn't show any code to send data to XCTU and the pin13 LED will only light up when an 'H' is sent from XCTU&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try this for better diagnostics&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void loop() {&#xA;while(Serial.available() &amp;gt; 0) {&#xA;           msg=(char) Serial.read();&#xA;&#xA;      Serial.print(&quot;data arrived from xctu: &quot;);&#xA;      Serial.print(msg);&#xA;      Serial.println();&#xA;&#xA;&#xA;           if(msg=='H') {&#xA;               digitalWrite(led,HIGH);&#xA;           }&#xA;           if(msg=='L') {&#xA;                digitalWrite(led,LOW);&#xA;           }&#xA;delay(1000);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-10T15:32:06.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13352" PostTypeId="1" CreationDate="2015-07-10T15:43:25.117" Score="2" ViewCount="2703" Body="&lt;p&gt;I have an Arduino + SparkFun CAN shield, and I was hoping to set it up to work with candump on an Ubuntu system. Is this doable, or is candump made specifically for raspberry Pi's?&lt;/p&gt;&#xA;" OwnerUserId="11144" LastActivityDate="2018-08-08T17:02:51.207" Title="Is it possible to setup a CAN-BUS Arduino Shield to communicate with SocketCAN for UNIX?" Tags="|arduino-uno|can-bus|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13354" PostTypeId="1" CreationDate="2015-07-10T18:52:41.533" Score="1" ViewCount="1490" Body="&lt;p&gt;I'm working on an Arduino code which will interpret a given MIDI note message and output the corresponding note number to a string of LEDs as a binary integer. I have adapted it from existing code found on the site &lt;a href=&quot;http://www.notesandvolts.com/2015/02/midi-and-arduino-build-midi-input.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Notes &amp;amp; Volts&lt;/a&gt; which features a similar circuit designed to trigger an LED every time a key is pressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My circuit takes this further by telling the user exactly &lt;em&gt;which&lt;/em&gt; note is being pressed. The note value byte is information is passed to a 74HC595 shift register which displays the note as a binary via a line of LEDs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a loose sense the code I have adapted &quot;works&quot;. When a key is pressed a series of LEDs light up corresponding to the MIDI note designated to that key. The issue is that this only happens sporadically. Many times a key press won’t be followed by any LEDs but other times it will. Even quick, successive presses tend to result in only a handful of &quot;read&quot; notes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this happen? To my intuition it would seem that the Arduino is &quot;missing&quot; notes, that is, spending so many clock cycles writing bits to the shift register that it falls out of sync with incoming bytes from the keyboard. Notes &amp;amp; Volts describes almost this exact situation in one of their &lt;a href=&quot;http://www.notesandvolts.com/2015/02/midi-for-arduino-input-test.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;instructional videos&lt;/a&gt; (relevant part at around 6:57). The author cautions against including too many time consuming processes in the code but doesn't mention how many is &lt;em&gt;too&lt;/em&gt; many. I can only assume that a ShiftOut command takes a good deal longer than a digitalWrite and that this explains why the example code works but my adaptation does not. Given this information, how long exactly does ShiftOut take and what could be done to speed up my program?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MIDI.h&amp;gt;&#xA;MIDI_CREATE_DEFAULT_INSTANCE();&#xA;&#xA;int latchPin = 8;&#xA;int clockPin = 12;&#xA;int dataPin = 11;  //The pins I am using&#xA;&#xA;void note_On(byte channel, byte pitch, byte velocity) {  //Runs when note is pressed&#xA;&#xA;  digitalWrite(latchPin, LOW);&#xA;  shiftOut(dataPin, clockPin, MSBFIRST, pitch);&#xA;  digitalWrite(latchPin, HIGH);  //Write 'pitch' to 74HC595. Standard fare&#xA;}&#xA;&#xA;void note_Off(byte channel, byte pitch, byte velocity){ //Writes '0' when note is off (all LEDs off)&#xA;  digitalWrite(latchPin, LOW);&#xA;  shiftOut(dataPin, clockPin, MSBFIRST, 0x00);&#xA;  digitalWrite(latchPin, HIGH);  &#xA;}&#xA;void setup() {&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;&#xA;  MIDI.begin(MIDI_CHANNEL_OMNI);&#xA;  MIDI.setHandleNoteOn(note_On);&#xA;  MIDI.setHandleNoteOff(note_Off);&#xA;}&#xA;&#xA;  void loop() {&#xA;  MIDI.read();  //This function which must be re-run in quick succession&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;UPDATE&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;@CL @Nick I wrote a code comparing the execution time difference between shiftOut and digitalWrite. While I am not perfectly confident in all of the numbers (1K digitalWrites takes a full 44mS??) one result did not surprise me - shiftOut is slower. By my numbers it is 3.75 times slower. That said, I welcome critiques on my methodology and I will address them as soon as I can. In the meantime I will make a point to research Arduino SPI and welcome any other alternatives to shiftOut. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int latchPin = 8;       //Declaration of serial register pins&#xA;int clockPin = 12;&#xA;int dataPin = 11;&#xA;&#xA;int led = 13;          //On-board LED&#xA;&#xA;void setup() {&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(led, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  unsigned long startTime = millis();    //Writes to SR 1K times.&#xA;  for(int i = 0; i &amp;lt; 1000; i++){       //Prints difference between&#xA;    digitalWrite(latchPin, LOW);       //start and end times.&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, 0xFF);&#xA;    digitalWrite(latchPin, HIGH);  &#xA;  }&#xA;&#xA;  Serial.print(&quot;\nsO:&quot;);&#xA;  Serial.print(millis() - startTime);&#xA;&#xA;  delay(1000);&#xA;&#xA;  startTime = millis();&#xA;  for(int i = 0; i &amp;lt; 8000; i++){    //Performs digitalWrite 8K times&#xA;    digitalWrite(led, HIGH);&#xA;  }&#xA;&#xA;  Serial.print(&quot;\t\tdW:&quot;);          //&#xA;  Serial.print(millis() - startTime);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;While working on a &lt;a href=&quot;https://arduino.stackexchange.com/questions/14054/interfacing-an-attiny85-with-midi-via-software-serial/14304#14304&quot;&gt;similar issue&lt;/a&gt; I discovered that a dramatic change to my code seems to perfectly clear up the issue. I'd still like to know why this particular example does not, however, so I'll keep poking around until I get somewhere.&lt;/p&gt;&#xA;" OwnerUserId="11165" OwnerDisplayName="Patagonian Rat" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-08-18T12:34:13.007" Title="Writing MIDI Notes More Quickly to a Shift Register with Arduino" Tags="|shift-register|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13355" PostTypeId="1" AcceptedAnswerId="13359" CreationDate="2015-07-10T18:38:59.813" Score="0" ViewCount="2721" Body="&lt;p&gt;First I need to say, I'm a complete electrics newbie, so I need your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have got a standalone Atmega 2560, which I want to program. I connected MISO, MOSI, SCK, RESET, 5V and GND to an Arduino Uno.&#xA;In addition a 16MHZ oscillator is connected to XTAL1 and XTAL2 plus I pull all VINs of the Atmega with a 100nF to GND. Plus I connected a separate VIN and GND to the 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I programmed the Arduino Uno as an &quot;Arduino as ISP&quot;. Afterwards I connected the 2560 as mentioned above, changed the board to &quot;Mega 2560&quot; and tried to upload a sketch through the Arduino and I get the error message:&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something I missed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&#xA;jb&lt;/p&gt;&#xA;" OwnerUserId="11150" OwnerDisplayName="jblaze" LastEditorUserId="11529" LastEditDate="2015-08-29T00:24:24.377" LastActivityDate="2015-08-29T00:24:24.377" Title="Standalone Atmega 2560 ISP program" Tags="|avrdude|isp|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13356" PostTypeId="2" ParentId="13354" CreationDate="2015-07-10T19:09:14.753" Score="3" Body="&lt;p&gt;&lt;code&gt;shiftOut&lt;/code&gt; is slow, yes.  It is basically &quot;bit banging&quot; a synchronous serial interface, which is a bit daft really when the Arduino has a hardware synchronous serial interface built in that can operate at much higher speeds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That built in synchronous serial interface is called &lt;strong&gt;SPI&lt;/strong&gt;.  I suggest you switch to SPI instead of shiftOut.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you should check what codes the MIDI keyboard is actually sending out.  I had a similar experience to you recently, but as far as I can tell it's down to the keyboard, not my software.  I built a system which reads in MIDI NoteOn codes through a serial port and plays a sample of a bass guitar at the right pitch.  The system worked perfectly when wired to the computer through a USB MIDI adapter, but as soon as I connected it to a keyboard (I don't have one, so I only had the one chance to test it recently with a real keyboard) it would only react to a key pressed after a long delay.  Almost as if the keyboard only sends a NoteOn if there is nothing happening for a while, and sends something else at other times.  I need to examine the keyboard's output data in more detail to see exactly what is being sent and why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might like to manually examine the MIDI codes being sent by the keyboard to be sure that it is actually sending a NoteOn when you think it should be and not something else (it'd be very interesting to see the results of your experiments too).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-10T19:09:14.753" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13358" PostTypeId="2" ParentId="13320" CreationDate="2015-07-10T19:52:34.330" Score="2" Body="&lt;p&gt;There are two types of bluetooth devices for Arduino. Some are &quot;slave&quot; only and some are both &quot;master or slave&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is little difference in price so you should buy one that is master or slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;http://wiki.iteadstudio.com/Serial_Port_Bluetooth_Module_(Master/Slave)_:_HC-05&quot; rel=&quot;nofollow noreferrer&quot;&gt;page (HC-05)&lt;/a&gt; describes one that appears to be commonly used but there are many and I do not have a recommendation. Some devices are in the form of small boards which connect to the pins on the Arduino (normally serial tx/rx) and some are shields that plug onto an Arduino. The article also shows the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This appears to be an &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=149453.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;ODBII bluetooth arduino forum thread&lt;/a&gt; that uses bluetooth and ODBII. &lt;a href=&quot;https://www.youtube.com/watch?v=iQki0TAHdRI&quot; rel=&quot;nofollow noreferrer&quot;&gt;Video&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default Android is in bluetooth master mode. This &lt;a href=&quot;https://stackoverflow.com/questions/8091184/android-device-as-a-slave-while-using-bluetooth&quot;&gt;article&lt;/a&gt; appears to show the Android programming required to enable a bluetooth slave.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-10T19:52:34.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13359" PostTypeId="2" ParentId="13355" CreationDate="2015-07-10T21:10:01.080" Score="0" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;sketch that programs bootloaders&lt;/a&gt;. A side-effect of that sketch is it fixes up the &quot;divide clock by 8&quot; fuse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the wiring will be the same, but cross-check on that page (scroll down to the part about programming the Mega2560).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once a bootloader is installed you could use it, if you get an FTDI cable, or simply go back to using the ArduinoISP now that the fuse is fixed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-10T21:10:01.080" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13360" PostTypeId="1" CreationDate="2015-07-10T21:14:38.503" Score="3" ViewCount="834" Body="&lt;p&gt;I'm trying to read from the SD card using an Arduino Pro Mini (3.3 V), &lt;a href=&quot;https://www.pololu.com/product/2597&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pololu micro-SD reader&lt;/a&gt; (the 3.3V one) over a SPI protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried both the SD library from Arduino SDK, and the &lt;a href=&quot;https://github.com/adafruit/SD&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit one&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino pin 10 -&gt; CS,&lt;/li&gt;&#xA;&lt;li&gt;pin 11 -&gt; DI&lt;/li&gt;&#xA;&lt;li&gt;pin 12 -&gt; DO&lt;/li&gt;&#xA;&lt;li&gt;pin 13 -&gt; SCLK.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've also connected VCC and GND of course. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This call (from the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DumpFile&quot; rel=&quot;nofollow noreferrer&quot;&gt;DumpFile example&lt;/a&gt;) fails:&lt;/strong&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// I've tried SD.begin(), SD.begin(10) as well.&#xA;if (!SD.begin(10, 11, 12, 13)) {&#xA;  // I can see this print statement in serial monitor.&#xA;  Serial.println(&quot;Card failed, or not present&quot;);&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried manually setting pin 10 to OUTPUT, as well as to set it to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, with the Adafruit SD library, I investigated this issue a bit more. It seems, that &lt;code&gt;SD.begin()&lt;/code&gt; invokes the &lt;code&gt;card.init(SPI_HALF_SPEED, csPin, mosi, miso, sck)&lt;/code&gt; (of the Sd2Card class).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added print statements and discovered &lt;strong&gt;this exact piece fails&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {&#xA;    if (((uint16_t)millis() - t0) &amp;gt; SD_INIT_TIMEOUT) {&#xA;     // This is being printed.&#xA;     // status_ is 1&#xA;     Serial.println(&quot;init err here!&quot;);&#xA;     Serial.println(status_);&#xA;     error(SD_CARD_ERROR_ACMD41);&#xA;      goto fail;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've prepared a card (2GB one) - it's FAT16 formatted, and contains one partition. On this partition there's a single file ony, named &quot;a.txt&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: After trying another SD card, I got some progress.&lt;/strong&gt; Now, the following call fails:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;volume.init(card) // in SD.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After digging in, I discovered that this invokes the &lt;code&gt;cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)&lt;/code&gt;, which invokes &lt;code&gt;sdCard_-&amp;gt;readBlock(blockNumber, cacheBuffer_.data)&lt;/code&gt; and then &lt;code&gt;Sd2Card::readData(block, offset, count, dst)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;readData()&lt;/code&gt;, the following fails:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if (!inBlock_ || block != block_ || offset &amp;lt; offset_) {&#xA;    block_ = block;&#xA;    // use address if not SDHC card&#xA;    if (type()!= SD_CARD_TYPE_SDHC) block &amp;lt;&amp;lt;= 9;&#xA;    if (cardCommand(CMD17, block)) {&#xA;      // ****************************&#xA;      // FAIL IS HERE - cardCommand(CMD17, block) fails.&#xA;      // ****************************&#xA;      error(SD_CARD_ERROR_CMD17);&#xA;      Serial.println(&quot;SD_CARD_ERROR_CMD17&quot;);&#xA;      goto fail;&#xA;    }&#xA;    if (!waitStartBlock()) {&#xA;      goto fail;&#xA;    }&#xA;    offset_ = 0;&#xA;    inBlock_ = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What the issue can possibly be?&lt;/p&gt;&#xA;" OwnerUserId="11153" LastEditorUserId="37523" LastEditDate="2019-05-15T15:47:04.527" LastActivityDate="2019-05-15T15:47:04.527" Title="Read from the SD card - ACMD41 times out" Tags="|sd-card|spi|arduino-mini|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13361" PostTypeId="2" ParentId="13346" CreationDate="2015-07-10T21:18:46.063" Score="1" Body="&lt;p&gt;From your code I cannot see anything that actually initializes the shield and tells it what pins to use and how to use them. This github (&lt;a href=&quot;https://github.com/jdunmire/HC05&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jdunmire/HC05&lt;/a&gt;) has a library for the HC-05 shield and it appears to have instructions for setting baud rate and all of that good stuff. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, their read-me mentions that, if properly configured, you should see traffic to and from the shield in your serial monitor. Are you seeing any traffic?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: This tutorial (&lt;a href=&quot;http://www.instructables.com/id/Arduino-AND-Bluetooth-HC-05-Connecting-easily/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-AND-Bluetooth-HC-05-Connecting-easily/?ALLSTEPS&lt;/a&gt;) seems to have step by step instructions to do exactly what you are asking.&lt;/p&gt;&#xA;" OwnerUserId="11154" LastActivityDate="2015-07-10T21:18:46.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13362" PostTypeId="2" ParentId="13354" CreationDate="2015-07-10T21:27:44.570" Score="1" Body="&lt;p&gt;I can't believe it is the shiftOut that is the issue. There is more going on here than meets the eye. I wrote a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12746&quot; rel=&quot;nofollow&quot;&gt;MIDI decoder&lt;/a&gt; a while back. That reads from MIDI and outputs to serial. That would be a &lt;strong&gt;lot&lt;/strong&gt; slower than doing one shiftOut. It runs perfectly, not just with you sitting there tapping notes, but with the synth generating its inbuilt music. See &lt;a href=&quot;https://vimeo.com/80328016&quot; rel=&quot;nofollow&quot;&gt;video of it in action&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either the library is doing something weird, or your 74HC595 is wired strangely. Do you have current-limiting resistors for each LED? Please show your wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also add a Serial print to display when your &lt;code&gt;note_On&lt;/code&gt; and &lt;code&gt;note_Off&lt;/code&gt; are called, and with what values. In my test I was able to connect MIDI up to Software Serial (pins D2 and D3 in my case) which was fine for receiving MIDI.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-10T21:27:44.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13364" PostTypeId="1" AcceptedAnswerId="13386" CreationDate="2015-07-11T01:22:19.313" Score="0" ViewCount="1871" Body="&lt;p&gt;I have a wire with a 0-5v current. I want to detect if the current is there or not (HIGH/LOW.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an optocoupler to avoid putting too much current into my micro, as it is only a 3.3V micro. I'm nervous about powering this on as one of my other micros stopped working although it's not clear if it could have been the circuit? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/hnbMR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&#xA;I could not find my optocoupler in fritzing. This is it:&#xA;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00CGXK1RG&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.com/gp/product/B00CGXK1RG?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o07_s00&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my plan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aUsOB.jpg&quot; alt=&quot;The microcontroller is a spark/particle core. It the yellow wire connects to the analog/digital pin A6. The screw terminals connect to the wire with the 5v current that I&amp;#39;m trying to detect.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The microcontroller is a spark/particle core 3.3v. It the yellow wire connects to the analog pin A6. The screw terminals connect to the wire with the 5v current that I'm trying to detect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I based my circuit on this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/sL3r6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know if it will do the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/D1vAE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="8769" LastEditDate="2015-07-11T01:54:58.897" LastActivityDate="2015-07-11T23:26:32.083" Title="Reading a photoresistor" Tags="|voltage-level|analogread|photoresistor|voltage-protection|digital-in|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13365" PostTypeId="2" ParentId="13233" CreationDate="2015-07-11T01:32:20.093" Score="6" Body="&lt;p&gt;I've used &lt;code&gt;NRF24L01+&lt;/code&gt; chipset 2.4GHz wireless modules with Arduino before, and found them to be great, and super cheap (~$10 for 10 of them on ebay!). They have 3 modes of transmission: 250kbps, 1Mbps, and 2Mbps. The range decreases accordingly with higher bitrate, but the time spent sending a message does too. There are multiple Arduino libraries (e.g. RF24, Mirf, RadioHead) and tutorials for using the modules (see &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&quot; rel=&quot;noreferrer&quot;&gt;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&lt;/a&gt;). They also have built-in mesh networking modes which may or may not be of use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Versions with an RP-SMA antenna connector and an advertised range of up to 1000m are also available for about $5 each. I would recommend using one of these for the referee's button at least, depending on the range you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://hallard.me/nrf24l01-real-life-range-test/&quot; rel=&quot;noreferrer&quot;&gt;According to Charles Hallard of hallard.me&lt;/a&gt;, The non-amplified chips can get &lt;strong&gt;30m line-of-sight range in 250kbps mode&lt;/strong&gt;, and I have verified this in my own testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.diychristmas.org/vb1/showthread.php?3564-nRF24L01-OTA-Timing-Measurements&quot; rel=&quot;noreferrer&quot;&gt;According to user sporadic on diychristmas.org&lt;/a&gt;, &lt;strong&gt;sending a 32 byte payload in 250kbps mode takes 1432µs&lt;/strong&gt; from the start of Tx mode on the transmitter to receiving the full message on receiver. This decreases to &lt;strong&gt;444µs on 1Mbps mode&lt;/strong&gt; and &lt;strong&gt;283µs on 2Mbps mode&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given these statistics, they fall well within 2ms latency for triggering, suitable for your application, and they use very little power. It's up to you to work out the best balance of latency, range and expense.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2015-07-11T01:32:20.093" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13366" PostTypeId="2" ParentId="13364" CreationDate="2015-07-11T03:20:43.153" Score="5" Body="&lt;p&gt;Wouldn't this be simpler?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/F7gdx.png&quot; alt=&quot;3.3v voltage detector&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: amended answer increases R1 to 10 k.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 10 k resistor limits current to 0.17 mA. The 3.3 V zener diode clamps the input voltage to 3.3 V (I measured 2.3 V on mine so that is well within spec). The other end of the zener diode goes to the Arduino ground pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally had R1 as 1 k however if you had a high voltage input (like 20 V) it didn't quite clamp the pin to 3.3 V (more like 3.8 V). This is a bit high for an input pin, so I tried 10 k instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For an input voltage of 5 V -&gt; 2.3 V on the Arduino input&lt;/li&gt;&#xA;&lt;li&gt;For an input voltage of 10 V -&gt; 2.6 V on the Arduino input&lt;/li&gt;&#xA;&lt;li&gt;For an input voltage of 20 V -&gt; 2.9 V on the Arduino input&lt;/li&gt;&#xA;&lt;li&gt;For an input voltage of 30 V -&gt; 3.1 V on the Arduino input&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is all within spec for the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the question is, will 2.3 V on the input pin register as HIGH? The answer is &quot;yes&quot; because high is considered to be 0.6 * V&lt;sub&gt;CC&lt;/sub&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3.3 * 0.6 = 1.98&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus any voltage of 1.98 or above is considered HIGH, and it will successfully read 2.3 V as high.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-11T03:52:35.243" LastActivityDate="2015-07-11T03:52:35.243" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13367" PostTypeId="1" AcceptedAnswerId="13370" CreationDate="2015-07-11T03:41:13.157" Score="1" ViewCount="86" Body="&lt;p&gt;I noticed something odd recently - a Yún, that was working previously, wouldn't connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After logging in to the web setup, setting the access point and password (which hadn't changed), and save &amp;amp; restart, it connected. Unfortunately, it still doesn't work, and after ssh into it, I find I cannot &lt;code&gt;ls /mnt/sd/&lt;/code&gt; or &lt;code&gt;sda1&lt;/code&gt;. It just sits there, requiring Ctrl+C, and gives no output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I reset the Arduino or Linux somehow by setting up access point again, or could my SD card be broken after months of heavy logging?&lt;/p&gt;&#xA;" OwnerUserId="10780" LastEditorUserId="6936" LastEditDate="2015-07-12T23:09:20.573" LastActivityDate="2015-07-12T23:09:20.573" Title="Does restarting Yún configuration mess up Arduino or its SD card?" Tags="|arduino-yun|sd-card|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13369" PostTypeId="2" ParentId="9660" CreationDate="2015-07-11T05:24:04.540" Score="0" Body="&lt;p&gt;As found on the &lt;a href=&quot;http://playground.arduino.cc/Main/CapacitiveSensor&quot; rel=&quot;nofollow&quot;&gt;Capacitative Sensor Library page&lt;/a&gt; (emphasis added):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;strong&gt;Use a 1 megohm resistor (or less maybe) for absolute touch to activate.&lt;/strong&gt;&lt;/li&gt;&#xA;  &lt;li&gt;With a 10 megohm resistor the sensor will start to respond 4-6 inches away.&lt;/li&gt;&#xA;  &lt;li&gt;With a 40 megohm resistor the sensor will start to respond 12-24 inches away (dependent on the foil size). Common resistor sizes usually end at 10 megohm so you may have to solder four 10 megohm resistors end to end.&lt;/li&gt;&#xA;  &lt;li&gt;&lt;strong&gt;One tradeoff with larger resistors is that the sensor's increased sensitivity means that it is slower. Also if the sensor is exposed metal, it is possible that the send pin will never be able to force a change in the receive (sensor) pin, and the sensor will timeout.&lt;/strong&gt;&lt;/li&gt;&#xA;  &lt;li&gt;Also experiment with small capacitors (100 pF - .01 uF) to ground, on the sense pin. They improve stability of the sensor.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The two emboldened points suggest that for a touch-piano, it would likely be advantageous to use a lower value resistor such as 1MΩ. Because the sensitivity increases as the resistor value increases, you want to use the &lt;em&gt;lowest possible&lt;/em&gt; resistor value to reduce jitter &amp;amp; interference among your signal wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;Also, later on the page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The grounding of the Arduino board is very important in capacitive sensing. The board needs to have some connection to ground, even if this is not a low-impedance path such as a wire attached to a water pipe.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ensure the Arduino is not run from a battery or unplugged laptop. For capacitative sensing to work, a stable ground connection is needed (via a DC plugpack or USB wall-wart is fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general note, try testing with only one capacitative connection first, then when that works, re-add the others.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2015-07-11T05:24:04.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13370" PostTypeId="2" ParentId="13367" CreationDate="2015-07-11T05:27:54.700" Score="2" Body="&lt;p&gt;It sounds like your SD card has likely failed. Try connecting it to a computer with an SD card reader. If it works at all, back it up immediately if you have files you wish to keep. Then try reading and writing files on it. Also if you have a spare SD card, try to use that in the Yun after setting it up appropriately. That should help narrow down the cause to either the Yun or the SD card.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2015-07-11T05:27:54.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13371" PostTypeId="2" ParentId="8148" CreationDate="2015-07-11T06:06:59.837" Score="1" Body="&lt;p&gt;&lt;strong&gt;All&lt;/strong&gt; you need is a function prototype. I have a detailed explanation at &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-i-actually-need-to-use-them&quot;&gt;Classes and objects: how many and which file types I actually need to use them?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this compiles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum WhatArduinoIs {&#xA;  Easy, But, Insane, Obsolete, And, Far, Worse, Than, mBed&#xA;};&#xA;&#xA;void TellMe(WhatArduinoIs pls);  // prototype&#xA;void TellMe(WhatArduinoIs pls) &#xA;  {&#xA;  }&#xA;void setup() { }&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Off-site reference: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to avoid the quirks of the IDE sketch file pre-preprocessing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-11T06:06:59.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13372" PostTypeId="1" AcceptedAnswerId="13373" CreationDate="2015-07-11T06:26:06.307" Score="2" ViewCount="799" Body="&lt;p&gt;I'm attempting what seemed to be a rather simple problem at first glance, but due to my limited knowledge of Arduino workings I need some help. I'm trying to use button outputs from a PS360+ arcade controller. Each of the button terminals output +5V, and is meant to be connected through a button to the grounds on the PS360+.&lt;br&gt;&#xA;  What I want to do is have an Arduino somewhere in between the button output and ground on the PS360+, to control and animate LEDs. What I've done so far is connect the VCC of the PS360+ to the Arduino's VIN and the ground of the Arduino to the PS360+'s button ground, which powers the Arduino. I then have a button output from the PS360+ going into the button, and the button's ground is connected to an Arduino pin. That Arduino pin's mode is set to INPUT. I then have another pin with an LED which is set to the value of the input pin.&#xA;  For some reason, the Arduino seems to get random input from the button(Though it does seem to react somewhat to buttons presses), and the PS360+ does not recognize the button press. Setting the input pin to pullup mode has even less result, and never reads low.&lt;br&gt;&#xA;Anybody got any ideas? Here's my current circuit diagram. 1P is a +5V output. I think that it's an internal pull-up pin like the Arduino's, but I am not certain. &lt;img src=&quot;https://i.stack.imgur.com/ZIZmp.png&quot; alt=&quot;Circuit Diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my current code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buttonlisten = 22;&#xA;int led = 53;&#xA;int val = 0;&#xA;&#xA;void setup() {                &#xA;  pinMode(led, OUTPUT);&#xA;  pinMode(buttonlisten, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  val = digitalRead(buttonlisten);&#xA;  digitalWrite(led, val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11160" LastActivityDate="2015-07-11T06:47:18.440" Title="Using an Arduino as an LED controller for an arcade stick" Tags="|programming|arduino-mega|pull-up|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13373" PostTypeId="2" ParentId="13372" CreationDate="2015-07-11T06:47:18.440" Score="0" Body="&lt;p&gt;I think the idea of putting the arduino between the button and ground is the problem here — &lt;code&gt;1P&lt;/code&gt; appears to be the input for the controller button, and you can't expect to take an 'input' from the button on &lt;em&gt;both pins at once&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try connecting one lead of the button back to its ground, and the other to &lt;code&gt;1P&lt;/code&gt; (as it would be originally I assume). Then solder/connect another lead from the button's non-grounded pin to an arduino pin designated as &lt;code&gt;INPUT_PULLUP&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you have two pulled-up input pins connected to the same button pin, which are both pulled low (since Arduino &amp;amp; PS360+ share &lt;code&gt;GND&lt;/code&gt;) when the button is pressed.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2015-07-11T06:47:18.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13374" PostTypeId="1" CreationDate="2015-07-11T07:06:52.077" Score="0" ViewCount="156" Body="&lt;p&gt;Simple question, of course if you do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FunctionA();&#xA;Delay(1000);&#xA;FunctionB();&#xA;FunctionC();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will call A, then wait a second, then call B, then call C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does one do this? ... &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FunctionA();&#xA;.. Invoke FunctionX one second from now ..&#xA;FunctionB();&#xA;FunctionC();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I want it to do A, then without stopping continue to B and then C.  Later (one second later) it will do X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, in c# you'd just use a coroutine, in Android you'd use a Handler or whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surely there's a command along the lines of .. invoke in .. 2000 .. method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really sorry for the basic question, experts, I am damned if I can find this anywhere. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11162" LastActivityDate="2015-07-11T07:52:22.780" Title="Embedded-c, schedule a function?" Tags="|threads|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13375" PostTypeId="2" ParentId="13374" CreationDate="2015-07-11T07:39:04.283" Score="1" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Surely there's a command along the lines of .. invoke in .. 2000 .. method.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not &quot;a command&quot; but you can make up something like that easily enough. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Function scheduler demo&#xA;// Author: Nick Gammon&#xA;// Date: 11 July 2015&#xA;&#xA;typedef void (*GeneralFunction) (); // function pointer type&#xA;&#xA;GeneralFunction wantedFunction = NULL;  // function to call&#xA;unsigned long functionTimerStarted;     // when the timer started&#xA;unsigned long delayPeriod;              // how long to wait (ms)&#xA;&#xA;void functionA ()&#xA;  {&#xA;  Serial.println (&quot;Function A&quot;);&#xA;  }  // end of functionA&#xA;&#xA;void functionB ()&#xA;  {&#xA;  Serial.println (&quot;Function B&quot;);&#xA;  }  // end of functionB&#xA;&#xA;void functionC ()&#xA;  {&#xA;  Serial.println (&quot;Function C&quot;);&#xA;  }  // end of functionC&#xA;&#xA;void functionX ()&#xA;  {&#xA;  Serial.println (&quot;Function X&quot;);&#xA;  }  // end of functionX&#xA;&#xA;void scheduleFunction (GeneralFunction f, unsigned long when);  // prototype&#xA;void scheduleFunction (GeneralFunction f, unsigned long when)&#xA;  {&#xA;  wantedFunction = f;&#xA;  functionTimerStarted = millis ();&#xA;  delayPeriod = when;&#xA;  }  // end of scheduleFunction&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  functionA ();  // call this now&#xA;  scheduleFunction (functionX, 2000);  // call this later&#xA;  functionB ();  // call this now&#xA;  functionC ();  // call this now&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // see if time to call the delayed function&#xA;  if (wantedFunction &amp;amp;&amp;amp; millis () - functionTimerStarted &amp;gt;= delayPeriod)&#xA;    {&#xA;    wantedFunction ();&#xA;    wantedFunction = NULL;  // don't call it again&#xA;    }  // end of if time up&#xA;&#xA;  // do other wanted stuff here&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A function pointer to remember which function to call in the future. &lt;/li&gt;&#xA;&lt;li&gt;A global variable to remember when you wanted this timing interval to start.&lt;/li&gt;&#xA;&lt;li&gt;A global variable to remember how long to wait.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In setup() I called a function to save this information for future use:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  scheduleFunction (functionX, 2000);  // call this later&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in loop() we see if the time is up, and then call the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This example just calls functions with no arguments, things will get more complex if you want to call a function with an argument. It would even be possible to remember the argument, but it may be unnecessarily complicated to explain how to do that, since your example did not ask for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also even schedule multiple functions, but again, showing all that adds to the complexity of the explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information about function pointers, see &lt;a href=&quot;http://www.gammon.com.au/callbacks&quot; rel=&quot;nofollow&quot;&gt;Function pointers / function callbacks / function variables&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-11T07:52:22.780" LastActivityDate="2015-07-11T07:52:22.780" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13378" PostTypeId="2" ParentId="8559" CreationDate="2015-07-11T09:24:50.223" Score="3" Body="&lt;p&gt;If you find compilation slow then yes, it is probably recompiling things that it doesn't really need to recompile.  This has always been a major failing of the Arduino environment, and is one of the major impetuses for the complete re-write of the whole compilation system in my IDE &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That includes very aggressive caching of compiled library and core files as proper &quot;.a&quot; files which are stored away separate from your board selection and kept until something really does need compiling.  That way the first time you compile something for a board it may take 30 seconds, 50 seconds, whatever.  All subsequent compilations for that same board, even for different sketches (not including the compilation time of &quot;fresh&quot; libraries) would be around 2 seconds, even less.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That caching is especially important when you're running on a very slow system, such as a Raspberry Pi, when compiling can take many minutes without the caches in place, but only a few seconds on all subsequent compilations.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-11T09:24:50.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13379" PostTypeId="2" ParentId="11696" CreationDate="2015-07-11T11:03:06.657" Score="1" Body="&lt;p&gt;This is more of a Stack Overflow question, but I'll help you a bit. The problem has nothing to do with your Arduino per-say. It has more to do with your PHP/Ajax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code is suited for a completely local setup, but pulls from a remote site, which violates some security protocols build into your browser and jQuery. You need to change your code to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$.ajax({&#xA;    url: 'http://192.168.1.177/',&#xA;    type: 'post',&#xA;    data: { tag: 'getData'},&#xA;    dataType: 'jsonp',&#xA;    async: false,&#xA;    success: function (data) {&#xA;        $('#TemperaturaInterior').val(data.TemperaturaInterior).show();&#xA;        $('#TemperaturaExterior').val(data.TemperaturaExterior).show();&#xA;        }&#xA;    });&#xA;(may need slight modifications since you didn't include all PHP/html code)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more information, see the &lt;a href=&quot;http://api.jquery.com/jquery.ajax/%20%22jQuery%20Documentation&quot; rel=&quot;nofollow noreferrer&quot;&gt;jQuery documentation&lt;/a&gt;, particularly look at data types and what it says about cross-domain json vs jsonp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain&quot;&gt;Here&lt;/a&gt; is a relevant SO question.&lt;/p&gt;&#xA;" OwnerUserId="3981" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-11T11:09:40.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13380" PostTypeId="1" CreationDate="2015-07-11T12:40:17.243" Score="2" ViewCount="88" Body="&lt;p&gt;I am now programming for two Arduinos. One is used as Tx and the other is Rx. Of course they are programmed by different codes, but they share some same .h files I programmed(let's say 'share.h'), which are not libraries and shouldn't be put in Arduino's 'library' folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I put 'share.h' and main.ino in one folder, and the ino is like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;share.h&quot;&#xA;#define TX&#xA;#ifdef TX&#xA;void setup(){...something for Tx...}&#xA;void loop(){...}&#xA;#else&#xA;void setup(){...something for Rx...}&#xA;void loop(){...}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The shortage is that every time I want to update my code to the two unos, I have to: first change the board port to 40(the Tx uno) in ide, add the &lt;code&gt;#define&lt;/code&gt; line, and upload. Then I have to change port to 42(the Rx one), comment the &lt;code&gt;#define&lt;/code&gt; line and upload. So inconvenient! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So do you have any good ideas? Much appreciation!&lt;/p&gt;&#xA;" OwnerUserId="9953" LastActivityDate="2015-07-12T03:36:59.780" Title="How to program for two Arduinos with different code but share one same .h?" Tags="|c++|arduino-ide|ide|" AnswerCount="0" CommentCount="0" FavoriteCount="0" ClosedDate="2015-07-13T10:29:26.003" ContentLicense="CC BY-SA 3.0" />
  <row Id="13381" PostTypeId="2" ParentId="13393" CreationDate="2015-07-11T13:07:00.673" Score="1" Body="&lt;p&gt;Because you're using Windows there is no easy way of doing what you want to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were on Linux or OS X you would be able to create a &lt;em&gt;symbolic link&lt;/em&gt; so that your shared file can exist in more than one location:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ln -s /path/to/real/share.h share.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows there is then just two options that I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn your shared file into a library.  I don't know why you are so adverse to this, since it is by far the simplest option.  Just create a folder &quot;MyProjectShared&quot; in your libraries folder, then name you shared header &quot;MyProjectShared.h&quot; within that folder.  Then &lt;code&gt;#include &amp;lt;MyProjectShared.h&amp;gt;&lt;/code&gt;.  Of course, choose a sensible name not MyProjectShared.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change to a different IDE that will allow you to add include locations.  One example is my &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; which allows you to add the line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;#pragma parameter board.flags=-IC:/Path/To/Other/Includes&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;to the top of your sketch, which adds another location to find header files while compiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thought has just occurred to me.  If the two sketches are side by side in a folder (say Arduino/Sketch1 and Arduino/Sketch2) then you may be able to use a relative path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Sketch2, do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;../Sketch1/share.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-11T13:18:56.213" LastActivityDate="2015-07-11T13:18:56.213" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="13383" PostTypeId="2" ParentId="13317" CreationDate="2015-07-11T14:12:18.523" Score="0" Body="&lt;p&gt;If the variable &lt;code&gt;activeSystem&lt;/code&gt; exceeds the length of the array, it's out of bounds, at which point the behavior is undefined.&lt;br&gt;&#xA;In your case you get &quot;garbage data&quot;, which is actually just data in memory after the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the is no implicit check for array bounds, you need to check them yourself.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-07-11T14:12:18.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13384" PostTypeId="1" AcceptedAnswerId="13385" CreationDate="2015-07-11T21:07:49.183" Score="1" ViewCount="6337" Body="&lt;p&gt;How can I convert a &lt;code&gt;float&lt;/code&gt; value into a &lt;code&gt;String&lt;/code&gt; object without implementing any library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to avoid using &lt;code&gt;char&lt;/code&gt; array.&lt;/p&gt;&#xA;" OwnerUserId="11152" LastEditorUserId="6936" LastEditDate="2015-07-12T21:13:03.460" LastActivityDate="2015-07-12T21:13:03.460" Title="Converting float to String" Tags="|arduino-ide|c|variables|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13385" PostTypeId="2" ParentId="13384" CreationDate="2015-07-11T21:28:49.887" Score="3" Body="&lt;p&gt;If you want to do it manually, rather than using the standard tools (&lt;code&gt;dtostrf()&lt;/code&gt; for example) then you need to think mathematically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A floating point number is made up of two distinct parts - the &lt;em&gt;integer&lt;/em&gt; part and the &lt;em&gt;decimal&lt;/em&gt; part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the number &lt;code&gt;123.4567&lt;/code&gt; is made up of the integer part 123 and the decimal part 4567.  Chopping off the integer portion is simple to do, and if that happens to be just one digit then you can simply add that as the first digit of your output.  In this case, though, it isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what to do?  Simple: keep dividing the number by 10 until it is just one digit.  But &lt;em&gt;be sure to count the number of times you divide by 10&lt;/em&gt;.  So the example above would end up as 1.234567 with a divide count of 2.  This is the same as the scientific representation, 1.234567×10².&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have it divided you can chop off the integer (just cast it to an int), add that integer part to your string, then remove it from the source number.  So you end up with &quot;1&quot; and 0.234567 and a count of 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now multiply by 10 and subtract one from your count, so you get 2.34567 and a count of 1.  Grab the integer portion and add it to your string, then remove it from your number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep repeating until your count is 0, at which point you have now done all the integer portion - so you can now add a &quot;.&quot; to your string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now just keep repeating the same process again and again until the &lt;em&gt;absolute&lt;/em&gt; value of the count equals the number of decimal places you want to print.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For negative numbers you should start by placing a &quot;-&quot; in your string, then taking the &lt;em&gt;absolute&lt;/em&gt; value of the number (the number as a positive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you just use the standard library function &lt;code&gt;dtostrf()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-11T21:28:49.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13386" PostTypeId="2" ParentId="13364" CreationDate="2015-07-11T23:26:32.083" Score="1" Body="&lt;p&gt;Based on the revised information given above I present a different answer. Use the opto-coupler as shown here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your kettle LED will be in series with the optocoupler (note the polarity, not reversed like in your question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the LED is on the transistor in the PC817 will conduct and the Arduino pin will be LOW. If the LED is off the transistor will not conduct and the Arduino pin will be HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/D14NA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: The Arduino pin will be the reverse of the kettle LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm leaving the other answer there because I think it is a reasonable answer to the question of &quot;detect a voltage&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-11T23:26:32.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13387" PostTypeId="2" ParentId="13393" CreationDate="2015-07-12T00:00:40.783" Score="2" Body="&lt;p&gt;I confronted this exact issue a little while back when writing some sketches that hard shared information. In particular &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow&quot;&gt;github.com/nickgammon/arduino_sketches&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whilst another IDE may help, I wanted to make my sketches usable by people with the default IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few (annoying) issues here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can't use relative folders as suggested in another answer, because the IDE copies your &lt;em&gt;current&lt;/em&gt; sketch folder to a temporary folder and compiles from there. It won't copy other nearby folders that happen to be mentioned in .h files.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can make soft links (in Linux anyway) as suggested, however that makes it hard to do Git control on them. My first attempt had the link (only) appear in GitHub, which meant that the links didn't compile, once you downloaded them (via the .zip file option in GitHub).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I switched to hard links, but then had another issue. If you edit a file in the IDE, and save it, evidently this becomes a new file, and so the files in other folders, which are now hard-linked, have the older version and not the newer version.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The best solution I could come up with (and I am open to suggestions) was to have a &quot;master&quot; sketch - which has the &quot;real&quot; files you want to include. The other folders have links to them. However if you change the master folder you have to recreate the hard links. I wrote a shell script to do that, but it is still an ugly solution. However since it is a manual process anyway, under Windows you could simply make a copy of the files, when you change the master one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other (simpler) alternative would be to make a library, and then simply change the files in that library. That gives you better Git management. The only thing is that you have to edit the library, and then go and test the sketch. It's not that bad.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And I found that after I added the h as library, no matter how I change the content of the h, the first version is always used in ide.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That shouldn't happen unless the IDE doesn't expect the library to change in-between compiles. If that is the case, even the library idea has flaws.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-12T00:00:40.783" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13388" PostTypeId="1" AcceptedAnswerId="13391" CreationDate="2015-07-12T00:17:58.657" Score="3" ViewCount="13257" Body="&lt;p&gt;I have a webserver successfully running on an Arduino Mega, but I'm trying to make sure it's parsing the GET requests in the fastest way possible. This is what the relevant code for the GET requests looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String readString;&#xA;EthernetClient client = server.available();&#xA;if (client) {&#xA;  while (client.connected()) {   &#xA;    if (client.available()) {&#xA;      char c = client.read();&#xA;&#xA;    if (readString.length() &amp;lt; 20) {&#xA;      readString += c;&#xA;    }&#xA;    ...&#xA;    ...&#xA;      if (readString.indexOf(&quot;?a1o&quot;) &amp;gt;0){&#xA;        mySwitch.send(a1o, 24);&#xA;      }&#xA;      if (readString.indexOf(&quot;?a1c&quot;) &amp;gt;0){&#xA;        mySwitch.send(a1c, 24);&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch checks for 40 possible GET variables. I'm running it as a local webserver with the address: &lt;a href=&quot;http://192.168.0.180&quot; rel=&quot;nofollow&quot;&gt;http://192.168.0.180&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Is there a command faster than &quot;indexOf&quot; that I could be using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-I saw some information suggesting that sometimes &quot;parseInt&quot; can be faster. Is there any way for me to make that work even though my local base URL is already full of integers? I would be willing to convert the commands into integers (like &quot;11&quot; instead of &quot;a1o&quot;) if there was a way to use parseInt or another faster command with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2019-07-31T07:02:07.440" Title="Arduino webserver: faster alternative to &quot;indexof&quot; for parsing GET requests?" Tags="|web-server|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13389" PostTypeId="1" AcceptedAnswerId="13390" CreationDate="2015-07-12T00:30:49.277" Score="2" ViewCount="30923" Body="&lt;p&gt;What kind of function can I use to know how many elements are in an array char?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sizeof() gives the number of 'spaces' available so it doesn't work for me.&lt;/p&gt;&#xA;" OwnerUserId="11152" LastEditorUserId="37523" LastEditDate="2020-02-14T18:29:55.100" LastActivityDate="2020-02-14T18:29:55.100" Title="Number of elements in an array char" Tags="|arduino-ide|c|strlen|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13390" PostTypeId="2" ParentId="13389" CreationDate="2015-07-12T00:38:25.173" Score="11" Body="&#xA;&#xA;&lt;p&gt;You want &lt;code&gt;strlen&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;char foo [100] = &quot;bar&quot;;&#xA;Serial.println (strlen (foo));   // --&amp;gt; prints 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-12T00:38:25.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13391" PostTypeId="2" ParentId="13388" CreationDate="2015-07-12T02:15:26.030" Score="8" Body="&#xA;&#xA;&lt;p&gt;Well, for fast parsing I wouldn't use String for a start. I've written an example (below) which does away with the String class, and also demonstrates parsing the line once.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;byte mac[] = {  0xB3, 0x8D, 0x72, 0x1D, 0xCE, 0x91 };&#xA;&#xA;// Our IP address&#xA;IPAddress ip(10,0,0,241);&#xA;&#xA;// Initialize the Ethernet server library&#xA;// with the IP address and port you want to use&#xA;// (port 80 is default for HTTP):&#xA;EthernetServer server(80);&#xA;&#xA;void setup() &#xA;  {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(115200);&#xA;  while (!Serial) { } // wait for serial port to connect.&#xA;&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;  Serial.print(F(&quot;Server is at &quot;));&#xA;  Serial.println(Ethernet.localIP());&#xA;  }  // end of setup&#xA;&#xA;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 100;&#xA;// the maximum length of paramters we accept&#xA;const int MAX_PARAM = 10;&#xA;&#xA;// Example GET line: GET /?foo=bar HTTP/1.1&#xA;void processGet (const char * data)&#xA;  {&#xA;  // find where the parameters start&#xA;  const char * paramsPos = strchr (data, '?');&#xA;  if (paramsPos == NULL)&#xA;    return;  // no parameters&#xA;  // find the trailing space&#xA;  const char * spacePos = strchr (paramsPos, ' ');&#xA;  if (spacePos == NULL)&#xA;    return;  // no space found&#xA;  // work out how long the parameters are&#xA;  int paramLength = spacePos - paramsPos - 1;&#xA;  // see if too long&#xA;  if (paramLength &amp;gt;= MAX_PARAM)&#xA;    return;  // too long for us&#xA;  // copy parameters into a buffer&#xA;  char param [MAX_PARAM];&#xA;  memcpy (param, paramsPos + 1, paramLength);  // skip the &quot;?&quot;&#xA;  param [paramLength] = 0;  // null terminator&#xA;&#xA;  // do things depending on argument (GET parameters)&#xA;&#xA;  if (strcmp (param, &quot;foo&quot;) == 0)&#xA;    Serial.println (F(&quot;Activating foo&quot;));&#xA;  else if (strcmp (param, &quot;bar&quot;) == 0)&#xA;    Serial.println (F(&quot;Activating bar&quot;));&#xA;&#xA;  }  // end of processGet&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void processData (const char * data)&#xA;  {&#xA;  Serial.println (data);&#xA;  if (strlen (data) &amp;lt; 4)&#xA;    return;&#xA;&#xA;  if (memcmp (data, &quot;GET &quot;, 4) == 0)&#xA;    processGet (&amp;amp;data [4]);&#xA;  }  // end of processData&#xA;&#xA;bool processIncomingByte (const byte inByte)&#xA;  {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;  switch (inByte)&#xA;    {&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;      if (input_pos == 0)&#xA;        return true;   // got blank line&#xA;      // terminator reached! process input_line here ...&#xA;      processData (input_line);&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;    }  // end of switch&#xA;  return false;    // don't have a blank line yet&#xA;  } // end of processIncomingByte  &#xA;&#xA;&#xA;void loop() &#xA;  {&#xA;  // listen for incoming clients&#xA;  EthernetClient client = server.available();&#xA;  if (client) &#xA;    {&#xA;    Serial.println(F(&quot;Client connected&quot;));&#xA;    // an http request ends with a blank line&#xA;    boolean done = false;&#xA;    while (client.connected() &amp;amp;&amp;amp; !done) &#xA;      {&#xA;      while (client.available () &amp;gt; 0 &amp;amp;&amp;amp; !done)&#xA;        done = processIncomingByte (client.read ());&#xA;      }  // end of while client connected&#xA;&#xA;    // send a standard http response header&#xA;    client.println(F(&quot;HTTP/1.1 200 OK&quot;));&#xA;    client.println(F(&quot;Content-Type: text/html&quot;));&#xA;    client.println(F(&quot;Connection: close&quot;));  // close after completion of the response&#xA;    client.println();   // end of HTTP header&#xA;    client.println(F(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;html&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;head&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;title&amp;gt;Test page&amp;lt;/title&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;/head&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;body&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;h1&amp;gt;My web page&amp;lt;/h1&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;p&amp;gt;Requested actions performed&quot;));&#xA;    client.println(F(&quot;&amp;lt;/body&amp;gt;&quot;));&#xA;    client.println(F(&quot;&amp;lt;/html&amp;gt;&quot;));&#xA;&#xA;    // give the web browser time to receive the data&#xA;    delay(10);&#xA;    // close the connection:&#xA;    client.stop();&#xA;    Serial.println(F(&quot;Client disconnected&quot;));&#xA;  }  // end of got a new client&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The incoming lines from the client are captured in a static buffer. This eliminates issues with memory fragmentation (caused by using String).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;processIncomingByte&lt;/code&gt; is called for each byte from the client. Once an entire line is assembled it calls &lt;code&gt;processData&lt;/code&gt;. If that finds a &quot;GET &quot; line it calls &lt;code&gt;processGet&lt;/code&gt;. That looks for the parameters on the GET line. The GET line looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;GET /?bar HTTP/1.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So we need to get between the &quot;?&quot; and the next space, to get the parameter (&quot;bar&quot; in this case). This can be accomplished by finding their positions with &lt;code&gt;strchr&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally (as a simple example) I tested with strcmp for a direct match on various words. You could probably make that more efficient but I doubt it would matter much.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-12T02:36:20.913" LastActivityDate="2015-07-12T02:36:20.913" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13392" PostTypeId="2" ParentId="13393" CreationDate="2015-07-12T03:36:59.780" Score="1" Body="&lt;p&gt;Thanks to everybody, now I get a better solution. It is changing the &lt;code&gt;build path&lt;/code&gt; to our working directory, and then we can use relative path!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the deatiled steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Click IDE's &lt;code&gt;File-Preferences&lt;/code&gt; and find where it storages &lt;code&gt;preferences.txt&lt;/code&gt;. Mine is at &lt;code&gt;C:\Users\Administrator\AppData\Roaming\Arduino15\preferences.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In the txt file add this line: &lt;code&gt;build.path=D:\MyProject\ArduinoBuild&lt;/code&gt;. This means let Arduino put the temp files in this directory, such as the &lt;code&gt;.h&lt;/code&gt; waiting to compile.&lt;/li&gt;&#xA;&lt;li&gt;Because the &lt;code&gt;.h&lt;/code&gt; Arduino automatically generated from our &lt;code&gt;.ino&lt;/code&gt; is in &lt;code&gt;ArduinoBuild&lt;/code&gt; directory, you can now use &lt;code&gt;#include &quot;./../Share/SomeShare.h&quot;&lt;/code&gt; in order to include the &lt;code&gt;D:\MyProject\Share\SomeShare.h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is the same question asked in another stackexchange board: &lt;a href=&quot;https://stackoverflow.com/questions/31357207/how-to-program-for-two-arduinos-with-different-code-but-share-one-same-h/&quot;&gt;Here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9953" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-12T03:36:59.780" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13393" PostTypeId="1" AcceptedAnswerId="13392" CreationDate="2015-07-11T12:30:30.363" Score="1" ViewCount="1475" Body="&lt;p&gt;I am now programming for two Arduinos. One is used as Tx and the other is Rx. Of course they are programmed by different codes, but they share some same .h files I programmed(let's say 'share.h'), which are not libraries and shouldn't be put in Arduino's 'library' folder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I put 'share.h' and main.ino in one folder, and the ino is like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;share.h&quot;&#xA;#define TX&#xA;#ifdef TX&#xA;void setup(){...something for Tx...}&#xA;void loop(){...}&#xA;#else&#xA;void setup(){...something for Rx...}&#xA;void loop(){...}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The shortage is that every time I want to update my code to the two unos, I have to: first change the board port to 40(the Tx uno) in ide, add the &lt;code&gt;#define&lt;/code&gt; line, and upload. Then I have to change port to 42(the Rx one), comment the &lt;code&gt;#define&lt;/code&gt; line and upload. So inconvenient! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So do you have any good ideas? Much appreciation!&lt;/p&gt;&#xA;" OwnerUserId="9953" OwnerDisplayName="Turtle" LastActivityDate="2016-07-19T16:15:50.663" Title="How to program for two Arduinos with different code but share one same .h?" Tags="|arduino-ide|" AnswerCount="6" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13394" PostTypeId="2" ParentId="13393" CreationDate="2015-07-11T13:52:02.340" Score="2" Body="&lt;p&gt;Ok, first of all you have to answer this question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I tell the compiler what program it should compile?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The first&lt;/strong&gt; (and easiest) solution is to have the preprocessor to this job. It's just a matter of writing two &lt;code&gt;/&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, instead of wrapping everything in an &lt;code&gt;ifdef&lt;/code&gt;, I would have done something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;share.h&quot;&#xA;#define TX&#xA;#ifdef TX&#xA;#define setup_tx() setup()&#xA;#define loop_tx() loop()&#xA;#else&#xA;#define setup_rx() setup()&#xA;#define loop_rx() loop()&#xA;#endif&#xA;&#xA;void setup_tx(){...}&#xA;void loop_tx(){...}&#xA;&#xA;void setup_rx(){...}&#xA;void loop_rx(){...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way I could put the two different setup/loop pairs in two different files (e.g. tx.ino and rx.ino). Moreover the &lt;code&gt;ifdef&lt;/code&gt; block can be moved in an h file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: I'm not sure wheter the function redefinition works well, because I never tried it. If it doesn't work you can try doing the opposite (i.e. &lt;code&gt;#define setup() setup_tx()&lt;/code&gt; and so on) or, in the end, make single-line functions (i.e. &lt;code&gt;void setup(){setup_tx();}&lt;/code&gt; and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another&lt;/strong&gt; solution can be applied if the processors are different. For instance if you have an Arduino UNO as transmitter and an Arduino Mega 2560 as a receiver, you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __AVR_ATmega2560__&#xA;- receiver functions&#xA;#else&#xA;- transmitter functions&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this would require you to switch processor along with the port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;third&lt;/strong&gt; solution is to place the shared h file in an include directory. You can do this by using a common include dir:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The include path includes the sketch's directory, the target directory (/hardware/core//) and the avr include directory (/hardware/tools/avr/avr/include/), as well as any library directories (in /hardware/libraries/) which contain a header file which is included by the main sketch file.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(See &lt;a href=&quot;https://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also pass the &lt;code&gt;-Idir&lt;/code&gt; option to avr-gcc to include also &lt;code&gt;dir&lt;/code&gt; in the include dirs list, but this requires you to change the boards.txt file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;last&lt;/strong&gt; solution I can think at is to compile both programs, load the same files on both arduinos and then choose at runtime what is the correct program to use by assinging a pin to the &quot;choice of program&quot; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance you assing pin 8 to this function. On the TX board you connect pin 8 to VCC, while on the RX board you connect it to GND. Then the program is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;share.h&quot;&#xA;&#xA;// Loop function callback (to speed things up)&#xA;typedef void (*loopfunction)();&#xA;loopfunction currentloop;&#xA;&#xA;const int RXTX_PIN = 8;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(RXTX_PIN,INPUT);&#xA;    if (digitalRead(RXTX_PIN))&#xA;    {&#xA;        setup_tx();&#xA;        currentloop = loop_tx;&#xA;    }&#xA;    else&#xA;    {&#xA;        setup_rx();&#xA;        currentloop = loop_rx;&#xA;    }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    currentloop();&#xA;}&#xA;&#xA;void setup_tx(){...}&#xA;void loop_tx(){...}&#xA;&#xA;void setup_rx(){...}&#xA;void loop_rx(){...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;IMHO the best solution is the first one, i.e. the define one. But... You should choose the best for your particular problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bye&lt;/p&gt;&#xA;" OwnerUserId="10214" OwnerDisplayName="frarugi87" LastActivityDate="2015-07-11T13:52:02.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13395" PostTypeId="2" ParentId="13393" CreationDate="2015-07-12T01:57:07.537" Score="1" Body="&lt;p&gt;You can feed the compiler a &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html&quot; rel=&quot;nofollow&quot;&gt;command-line switch&lt;/a&gt;, &lt;code&gt;-D&amp;lt;define_name&amp;gt;&lt;/code&gt;, so for your TX you could have a project that has &lt;code&gt;-DTX&lt;/code&gt; and for the RX &lt;code&gt;-DRX&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can share the code between the two projects and you don't need to change the code when you're compiling.&lt;/p&gt;&#xA;" OwnerDisplayName="Jesper Bangsholt" LastActivityDate="2015-07-12T01:57:07.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13397" PostTypeId="2" ParentId="13389" CreationDate="2015-07-12T11:36:19.947" Score="3" Body="&lt;p&gt;I know you have your answer from @NickGammon, but I'd just like to add a bit more in-depth information about how all this works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sizeof()&lt;/code&gt; is not a function in the normal sense of the word.  It is an operator which gives you the number of bytes of memory allocated to whatever you pass to it.  If you pass it an array then it returns the number of bytes that array has available to it.  If you pass it a pointer to an array then it returns the size of that pointer, not the size of the array.  If you pass it an integer variable it returns the number of bytes used by that integer variable (2 on an 8-bit system like AVR, 4 on a 32-bit system like the Due).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So some examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char array[50] = &quot;hello&quot;;&#xA;// sizeof(array) = 50.&#xA;char *array_p = array;&#xA;// sizeof(array_p) = 2 or 4 depending on architecture.&#xA;char single = 'a';&#xA;// sizeof(single) = 1.&#xA;char string[] = &quot;hello&quot;;&#xA;// sizeof(string) = 6 (5 letters plus \0) - it allocates the memory at compile time to fit the string&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;code&gt;strlen()&lt;/code&gt;.  How exactly does that differ from &lt;code&gt;sizeof()&lt;/code&gt;?  Simply put, &lt;code&gt;strlen()&lt;/code&gt; counts the number of characters in a character array up until it reaches the character &lt;code&gt;\0&lt;/code&gt; which is the &quot;NULL&quot; terminating character of a C string.  Let's take the examples before but use strlen instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char array[50] = &quot;hello&quot;;&#xA;// strlen(array) = 5.&#xA;char *array_p = array;&#xA;// strlen(array_p) = 5.&#xA;char single = 'a';&#xA;// strlen(single) = ERROR!  strlen() doesn't operate on single characters.&#xA;char string[] = &quot;hello&quot;;&#xA;// strlen(string) = 5.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You notice it always returns the number of characters in the string up to, but not including, the trailing &lt;code&gt;\0&lt;/code&gt; character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In its simplest form the &lt;code&gt;strlen()&lt;/code&gt; function might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int strlen(const char *data) {&#xA;    int c = 0;&#xA;    const char *p = data;&#xA;    while (*p) {&#xA;        c++;&#xA;        p++;&#xA;    }&#xA;    return c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically it starts at the first character in the string (&lt;code&gt;*p = data&lt;/code&gt;), examines if it's a &lt;code&gt;\0&lt;/code&gt; or not (&lt;code&gt;while (*p)&lt;/code&gt;), increments the count of characters (&lt;code&gt;c++&lt;/code&gt;) and moves on to the next character in the string (&lt;code&gt;p++&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to iterate through your string in your program you could call &lt;code&gt;strlen()&lt;/code&gt; first to get the number of characters in the string then use that value in a loop.  That is a bit wasteful, since &lt;code&gt;strlen()&lt;/code&gt; first iterates through the string, so you end up iterating through it twice.  It is far more efficient to learn how best to step through each character in the string until you find the terminating character, such as how the &lt;code&gt;strlen()&lt;/code&gt; function uses the &lt;em&gt;pointer&lt;/em&gt; to move through memory.  You can also see just how vital it is that you ensure the &lt;code&gt;\0&lt;/code&gt; character exists at the end of the string, otherwise how will functions like &lt;code&gt;strlen()&lt;/code&gt; know when to stop?  They can't know how long the string is (&lt;code&gt;sizeof()&lt;/code&gt; will return the size of the pointer it is passed, not the size of the array), so they have to have some kind of manual marker, and the convention in C is to use &lt;code&gt;\0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that Arduino's &lt;code&gt;print()&lt;/code&gt; functions actually do it very inefficiently.  If you do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char message[] = &quot;Hello&quot;;&#xA;Serial.println(message);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will actually do quite a lot of work it doesn't &lt;em&gt;really&lt;/em&gt; need to.  Taken step by step it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;calls println(message)&lt;/li&gt;&#xA;&lt;li&gt;which calls write(message)&lt;/li&gt;&#xA;&lt;li&gt;which gets the string length with strlen(message)&lt;/li&gt;&#xA;&lt;li&gt;and calls write(message, length)&lt;/li&gt;&#xA;&lt;li&gt;which then loops from 0 to length-1 sending each character of message to write() in turn.&lt;/li&gt;&#xA;&lt;li&gt;finally prints the &lt;code&gt;\r\n&lt;/code&gt; for the new-line.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So it actually ends nested around 4 functions deep, and iterates the entire string twice. A classic example of how to waste processing time.  By iterating through the string once looking for the &lt;code&gt;\0&lt;/code&gt; character in the &lt;code&gt;write(message)&lt;/code&gt; function (step 2) it would operate at least twice as fast.  Good old Arduino...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2018-05-14T09:10:38.970" LastActivityDate="2018-05-14T09:10:38.970" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="13398" PostTypeId="2" ParentId="9117" CreationDate="2015-07-12T14:59:52.710" Score="3" Body="&lt;p&gt;There is a fairly simple equivalence for the basic direct pin access. Below is some sample code which shows how to set a digital pin high and then low. The first is for an Arduino Due, the second is for the Arduino Uno/Mega/etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned int imThePin = 10; //e.g. digital Pin 10&#xA;&#xA;#ifdef _LIB_SAM_&#xA;&#xA;    //First lets get the pin and bit mask - this can be done once at the start and then used later in the code (as long as the variables are in scope&#xA;    Pio* imThePort = g_APinDescription[imThePin].pPort; &#xA;    unsigned int imTheMask = g_APinDescription[imThePin].ulPin; &#xA;&#xA;    //Lets set the pin high&#xA;    imThePort-&amp;gt;PIO_SODR = imTheMask;&#xA;    //And then low&#xA;    imThePort-&amp;gt;PIO_CODR = imTheMask;&#xA;&#xA;#else&#xA;&#xA;    //First lets get the pin and bit mask - this can be done once at the start and then used later in the code (as long as the variables are in scope&#xA;    volatile unsigned char* imThePort = portOutputRegister(digitalPinToPort(imThePin)); &#xA;    unsigned char imTheMask = digitalPinToBitMask(imThePin);&#xA;&#xA;    //Lets set the pin high&#xA;    *imThePort |= imTheMask;&#xA;    //Now low&#xA;    *imThePort &amp;amp;= ~imTheMask;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything that is needed to do that should be included by default - and if not &lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&lt;/code&gt; should be sufficient to get it there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are actually functions available that can be called once you have the &lt;code&gt;Pio&lt;/code&gt; pointer to do the setting/clearing/pullup resistors/etc. using slightly cleaner looking function calls. A full list can be found in the &lt;a href=&quot;https://android.googlesource.com/platform/external/arduino-ide/+/refs/heads/master/hardware/arduino/sam/system/libsam/include/pio.h&quot; rel=&quot;nofollow&quot;&gt;&lt;/a&gt; header file.&lt;/p&gt;&#xA;" OwnerUserId="6860" LastActivityDate="2015-07-12T14:59:52.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13399" PostTypeId="2" ParentId="12674" CreationDate="2015-07-12T17:10:20.630" Score="0" Body="&lt;p&gt;I'm self answering..&#xA;On my Arduino Leonardo, the SDA and SCL pin used for the I2C connexion to the LCD panel, are the same pin than the Digital pin 2 and 3. So using SDA/SCL remove ability to use pin 2 &amp;amp; 3.&lt;/p&gt;&#xA;" OwnerUserId="10425" LastActivityDate="2015-07-12T17:10:20.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13400" PostTypeId="1" CreationDate="2015-07-12T18:43:47.667" Score="0" ViewCount="1792" Body="&lt;p&gt;I'm trying to write into a file using this code from the example of the library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String dataString = &quot;&quot;;&#xA;int sensor = 0;&#xA;dataString += String(sensor);&#xA;dataString += &quot;,&quot;;&#xA;sensor +=1;&#xA;&#xA;File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;if (dataFile) {&#xA;  dataFile.println(dataString);&#xA;  dataFile.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a char array that I want to write in the file, but it works only with String objects apparently. What can I do?&lt;/p&gt;&#xA;" OwnerUserId="11152" LastActivityDate="2016-02-18T20:28:02.050" Title="SD Library writing char in a file" Tags="|arduino-ide|sd-card|code-optimization|coding-standards|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13402" PostTypeId="1" AcceptedAnswerId="13496" CreationDate="2015-07-12T21:39:42.697" Score="0" ViewCount="1332" Body="&lt;p&gt;A little history: I have two Arduino Uno and I couldn't program them by IDE, I got these errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I googled it for a while and I suspect of missing bootloader on atmega micro on the board, as I don't have AVR programmer I programmed both Arduinos with Raspberry Pi and Arduino IDE tool through ICSP pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It (burning bootloader) runs perfectly on both Arduino. One of them got fixed and got back to normal, but the other one gave me same error, so I changed their Atmega micro, but same result. Second Arduino (bad one) can't transfer program to AVR even with other one (good one) AVR so both AVRs on the boards are good.&#xA;The program (blink LED) run even on the bad Arduino and pin 13 blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I test the suspected Arduino board? Is the second Atmel micro near usb female port need bootloader too?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Update 1&lt;/strong&gt;: I follow &lt;a href=&quot;http://bartruffle.blogspot.com/2013/09/dfu-programming-atmega16u2-on-arduino.html&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; but my Arduino couldn't go to DFU&#xA;  mod by shorting the pins. When I connect those pins led pin 13 not blink and lsusb command show Arduino not Atmel.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt; : I went through &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno&quot;&gt;this question&lt;/a&gt; and &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;this&#xA;  troubleshoot&lt;/a&gt; to upload bootloader to Atmel USB device but my&#xA;  second Arduino (bad one) didn't respond and gave me this error :&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jul 13 2015 at 11:14:35 with Arduino IDE 105.&#xA;Attempting to enter ICSP programming mode......................................................&#xA;Failed to enter programming mode. Double-check wiring!&#xA;Programming mode off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible my Atmega16U2 chip is burned?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Update 3&lt;/strong&gt; : I do reach the point that I am pretty sure Atmega16U2 is&#xA;  dead and it isn't responding to its ICSP pins and it blocks any USB to AVR connection. I check the wiring and I&#xA;  test it on good Arduino and its sequence are correct and it works on good one. Now what can I&#xA;  do, as Atmega16U2 is not rechangeable, should I throw bad Arduino away?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11186" LastEditorDisplayName="user6430" LastEditDate="2015-07-16T10:18:09.083" LastActivityDate="2015-07-16T11:42:05.707" Title="How to test Arduino board?" Tags="|arduino-uno|bootloader|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13403" PostTypeId="1" CreationDate="2015-07-12T23:55:32.580" Score="2" ViewCount="247" Body="&lt;p&gt;I am learning brain wave programming from &lt;a href=&quot;http://www.tinkernut.com/portfolio/homemade-mind-controlled-tv-remote/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tinkernut&lt;/a&gt; tutorial. &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;#include &amp;lt;IRremoteInt.h&amp;gt;&#xA;#include &amp;lt;Brain.h&amp;gt;&#xA;IRsend irsend;&#xA;Brain brain(Serial);&#xA;const int ledPin = 3; &#xA;long interval = 500; &#xA;long previousMillis = 0;&#xA;int ledState = LOW; &#xA;int medValue;&#xA;&#xA;void setup() {&#xA;  // Set up the LED pin.&#xA;  pinMode(ledPin, OUTPUT);&#xA;  // Start the hardware serial.&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // Expect packets about once per second.&#xA;  if (brain.update()) {&#xA;    Serial.println(brain.readCSV());&#xA;    // Attention runs from 0 to 100.&#xA;    medValue = brain.readMeditation();&#xA;  } &#xA;&#xA;  // Make sure we have a signal.&#xA;  if(brain.readSignalQuality() == 0) {&#xA;    // Send a signal to the LED.&#xA;    if (medValue &amp;lt; 50) {&#xA;    irsend.sendNEC(0x10EFA05F, 32); &#xA;    delay(40);&#xA;    }&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code by tinkernut controls a single button of a tv remote only if the meditation value drops below 50.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to program arduino to control all the buttons of a tv remote ?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8302" LastEditorUserId="37523" LastEditDate="2019-08-07T15:33:17.280" LastActivityDate="2019-08-07T15:33:17.280" Title="Programming Arduino for Mindflex" Tags="|arduino-due|communication|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13404" PostTypeId="2" ParentId="13346" CreationDate="2015-07-13T03:19:50.103" Score="0" Body="&lt;p&gt;You should use a &lt;strong&gt;different baud rate&lt;/strong&gt; if your hc-05 does not work with the code. The default is 9600. Use this baud rate and if not, try to find out the baud rate using AT commands, you will get several tutorials on this. &lt;/p&gt;&#xA;" OwnerUserId="10838" LastActivityDate="2015-07-13T03:19:50.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13406" PostTypeId="2" ParentId="13346" CreationDate="2015-07-13T05:25:26.183" Score="0" Body="&lt;p&gt;Here is your problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( Serial.available() &amp;gt; 0) {&#xA;int inByte = Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are not listening to the bluetooth-hardware, but to the build-in serial port of the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a look at the url you can see on the board, but i could not find any example code. If you are lucky your bluetooth should might be compatible with the freetronics bluetooth shield, which has some &lt;a href=&quot;http://www.freetronics.com.au/pages/bluetooth-shield-quickstart-guide&quot; rel=&quot;nofollow&quot;&gt;example code on the bottom of this page&lt;/a&gt; to get you started:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial bt(2,3); // RX, TX&#xA;&#xA;int thisByte = 33;&#xA;&#xA;void setup() {&#xA;  bt.begin(9600);&#xA;  bt.println(&quot;ASCII Table ~ Character Map&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  bt.write(thisByte);&#xA;&#xA;  bt.print(&quot;, dec: &quot;);&#xA;  bt.print(thisByte);&#xA;  bt.print(&quot;, hex: &quot;);&#xA;  bt.print(thisByte, HEX);&#xA;  bt.print(&quot;, oct: &quot;);&#xA;  bt.print(thisByte, OCT);&#xA;  bt.print(&quot;, bin: &quot;);&#xA;  bt.println(thisByte, BIN);&#xA;&#xA;  if(thisByte == 126) {&#xA;    thisByte = 32;&#xA;  }&#xA;  thisByte++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This only sends, and &quot;bt&quot; is your bluetooth hardware here. It behaves like the Serial hardware for the most part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: based on your picture, you might have to change the RX/TX pins on your board to 2,3 - currently they are set to 2,4.&lt;/p&gt;&#xA;" OwnerUserId="9860" LastActivityDate="2015-07-13T05:25:26.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13407" PostTypeId="1" AcceptedAnswerId="13408" CreationDate="2015-07-13T08:09:51.377" Score="0" ViewCount="1306" Body="&lt;p&gt;I have got my own PCB with &amp;quot;some stuff&amp;quot; on it and first I want to make it run a simple &amp;quot;turn on LED&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;My setup:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Atmega 2560&lt;/li&gt;&#xA;&lt;li&gt;LED connected to PE4 (D2 in Arduino language) =&amp;gt; PE4 - LED - 1K resistor - 5V&lt;/li&gt;&#xA;&lt;li&gt;ceramic resonator (CSTCE16M0V53-R0 16MHZ) connected to XTAL1 + XTAL2 with 1MOhm resistor in between&lt;/li&gt;&#xA;&lt;li&gt;all VINs are pulled to GND with capacitors&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/c8hIN.png&quot; alt=&quot;resonator VINs GNDs&quot; /&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZeKns.png&quot; alt=&quot;RESET circuit&quot; /&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/UP9Az.png&quot; alt=&quot;status LEDs&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Upload is working through ICSP (MISO, MOSI, SCK, RESET, 5V, GND) with an USBasp&lt;/p&gt;&#xA;&lt;p&gt;Here is my &lt;strong&gt;Arduino sketch&lt;/strong&gt;, which I upload through the Arduino software:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(2, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(2, LOW);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I checked the fuses on the Atmega as well:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: safemode: lfuse reads as FF&#xA;avrdude: safemode: hfuse reads as D8&#xA;avrdude: safemode: efuse reads as FD&#xA;avrdude: safemode: Fuses OK (H:FD, E:D8, L:FF)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;avrdude uploads successfully: &lt;em&gt;(output truncated!)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: auto set sck period (because given equals null)&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;Reading | ################################################## | 100% 0.01s&#xA;avrdude: Device signature = 0x1e9801&#xA;avrdude: NOTE: &amp;quot;flash&amp;quot; memory has been specified, an erase cycle will be performed&#xA;         To disable this feature, specify the -D option.&#xA;avrdude: erasing chip&#xA;avrdude: auto set sck period (because given equals null)&#xA;avrdude: writing flash (1518 bytes):&#xA;Writing | ################################################## | 100% 5.47s&#xA;avrdude: 1518 bytes of flash written&#xA;avrdude: reading on-chip flash data:&#xA;Reading | ################################################## | 100% 3.45s&#xA;avrdude: verifying ...&#xA;avrdude: 1518 bytes of flash verified&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Problem: the LED doesn't work. It is OFF all the time.&lt;/p&gt;&#xA;&lt;p&gt;Any ideas why it is not working?&lt;/p&gt;&#xA;" OwnerUserId="11150" LastEditorUserId="27544" LastEditDate="2022-10-06T06:55:30.303" LastActivityDate="2022-10-06T06:55:30.303" Title="Separate ATmega 2560 - turn on a single LED - troubleshooting" Tags="|programming|led|uploading|sketch|" AnswerCount="1" CommentCount="23" ContentLicense="CC BY-SA 4.0" />
  <row Id="13408" PostTypeId="2" ParentId="13407" CreationDate="2015-07-13T10:30:10.373" Score="0" Body="&lt;p&gt;You are saying that the LED lights if you write LOW to it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I need to pull the output pin to LOW to make the LED work &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's exactly what you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cKpuI.png&quot; alt=&quot;LED wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the other end of the LED is wired to +5 V, then you need to drive the pin low to have a voltage difference over the LED, and for it to light.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I double checked the Atmega and it is a ATmega2560V, which is rated for 8Mhz. Any chance to fix this with the existing PCB? Change the Fuses to use the internal clock? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, I suggest you do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;a href=&quot;http://www.engbedded.com/fusecalc&quot; rel=&quot;nofollow noreferrer&quot;&gt;Engbedded Atmel AVR® Fuse Calculator&lt;/a&gt; to see what to set them to. I suggest the internal 8 MHz oscillator.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-14T09:37:00.520" LastActivityDate="2015-07-14T09:37:00.520" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="13414" PostTypeId="2" ParentId="71" CreationDate="2015-07-13T14:50:37.007" Score="1" Body="&lt;p&gt;I have found that most clones will do what you expect them to do, but as &lt;a href=&quot;https://arduino.stackexchange.com/users/32/x4mer&quot;&gt;x4mer&lt;/a&gt; states in his &lt;a href=&quot;https://arduino.stackexchange.com/questions/71/compatibility-between-arduino-and-arduino-clones#answer-90&quot;&gt;answer&lt;/a&gt;, be prepared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most annoying issue, and even then it &lt;em&gt;is&lt;/em&gt; quite minor, is that a lot of Chinese clones do not use an ATMega for the USB and instead use a &lt;strong&gt;CH340G&lt;/strong&gt;.  These chips, while fine when connecting to a PC running Windows 7, have great difficulties with the drivers on OS X, and end up just not being recognised. It is possible &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;to find a driver for the CH340G&lt;/a&gt;, but when I installed it, it immediately crashed the MacBook, upon plugging in the cloned UNO..!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to buy three or four clones on eBay until I got an Uno with an &lt;em&gt;actual&lt;/em&gt; 16u2 implementing the USB interface, which would actually be recognised by the MacBook Pro, and would allow me to code using the Arduino IDE running on OS X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before that, I had to use a Wintel laptop.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-07T23:27:27.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13415" PostTypeId="1" AcceptedAnswerId="13425" CreationDate="2015-07-13T14:56:41.600" Score="1" ViewCount="1462" Body="&lt;p&gt;I can get LEDs to fade properly using PWM on pins 44-46 on the Mega2560 when I don't have a servo attached, but once I &quot;attach&quot; the servo in the code, then PWM pins 44-46 don't work for PWM. They can still work with digitalWrite, but not with analogWrite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo;&#xA;int led = 46;&#xA;&#xA;void setup()  { &#xA;  myservo.attach(3);&#xA;  pinMode(led, OUTPUT);&#xA;  analogWrite(led, 60);&#xA;} &#xA;&#xA;void loop()  {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I comment out the &quot;myservo.attach(3);&quot; line, then PWM works for the LED pin. Otherwise the LED stays off. Why would PWM on pins 44-46 stop working once the servo is attached?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-07-13T22:06:09.733" Title="Arduino Mega PWM pins stop working for LEDs once servo is attached?" Tags="|arduino-mega|pwm|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13416" PostTypeId="1" AcceptedAnswerId="13424" CreationDate="2015-07-13T15:10:19.383" Score="3" ViewCount="413" Body="&lt;p&gt;Following on from the question &lt;a href=&quot;https://arduino.stackexchange.com/questions/1477/reset-an-arduino-uno-by-an-command-software&quot;&gt;Reset an Arduino UNO by an command (software)&lt;/a&gt; and the excellent &lt;a href=&quot;https://arduino.stackexchange.com/questions/1477/reset-an-arduino-uno-by-an-command-software#answer-1478&quot;&gt;answer&lt;/a&gt; provided by &lt;a href=&quot;https://arduino.stackexchange.com/users/60/mpflaga&quot;&gt;mpflaga&lt;/a&gt;, the comment addressing option (1) suggests that there are design considerations for connecting an output pin to the RESET pin. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Option 1. or a variant can be a clean enough way to do this as long as&#xA;  power on transient conditions are designed for.&#xA;  - &lt;a href=&quot;https://arduino.stackexchange.com/users/6959/russell-mcmahon&quot;&gt;Russell McMahon&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;or more ominuously&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;From everything I've read, the first option is not recommended. - &lt;a href=&quot;https://arduino.stackexchange.com/users/11/sachleen&quot;&gt;sachleen&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Could someone tell me exactly what those considerations are? Is it that it is not as simple as connecting the two with a jumper cable - is additional circuitry (i.e. an RC timer) required, or is there a software solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find the latter option unlikely as the device is rebooting, so unless the software fix is to ignore hardware interrupts (since a RESET is simply that, and the state of the output pins is unlikely to be known, or stable at reboot) for a few mS after reboot, I presume that a hardware fix is required.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-07-13T22:27:04.503" Title="How does one design for the power on transient conditions?" Tags="|arduino-uno|reset|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13419" PostTypeId="1" CreationDate="2015-07-13T16:25:52.910" Score="2" ViewCount="526" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/vdrgJ.jpg&quot; alt=&quot;The kettle, spark core, relay&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hi! I'm still working on &lt;a href=&quot;https://arduino.stackexchange.com/questions/13364/reading-a-photoresistor&quot;&gt;my kettle project&lt;/a&gt;. I want to obtain the kettle temp from the existing thermometer. I'm able to do this, but much like trying to look at an electron my circuits all reduce the voltage going to the kettle control board. This means the kettle's microcontroller (&lt;a href=&quot;http://www.atech.com.tw/%5Cproduct%5Csonix%5C8bit%5CSN8P27%20Series%5CSN8P2722_V11.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SN8P2722  SONiX&lt;/a&gt;) acts as if the kettle is cooler than it really is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/S2LGM.jpg&quot; alt=&quot;5v control board.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there is an &lt;em&gt;easy&lt;/em&gt; way to program this microcontroller (if there is I'd love to know) -- I suspect the bad temp data will lead to overheating and hot water all over my kitchen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OLk5N.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to passively obtain the voltage? I've been looking into the way that voltmeters work. Is this the right idea? is there a breakout board for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really wanted to have the existing buttons still work as they always have. I've done this with power. I can press it remotely or on the kettle and I can tell of the kettle is on or off both on the control panel and remotely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uutUW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can press all the other buttons remotely but I can't tell if it's working without knowing the kettle temp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I should try to replace the entire control board? What would be easier? I'm something of a beginner.&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-13T23:06:30.160" Title="Read an analog signal without changing it? Or should I start over?" Tags="|analogread|project-critique|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13420" PostTypeId="2" ParentId="13419" CreationDate="2015-07-13T16:36:05.020" Score="3" Body="&lt;p&gt;A JFET op amp such as the &lt;a href=&quot;http://www.ti.com/product/tl071&quot; rel=&quot;nofollow&quot;&gt;TL071&lt;/a&gt; has an input impedance in the hundreds of gigaohms or higher. Using one to &lt;a href=&quot;https://en.wikipedia.org/wiki/Buffer_amplifier#Voltage_buffer_examples&quot; rel=&quot;nofollow&quot;&gt;buffer the voltage&lt;/a&gt; should allow you to sample it without much interference to the existing circuit.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-13T16:36:05.020" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13421" PostTypeId="1" AcceptedAnswerId="13423" CreationDate="2015-07-13T17:20:27.680" Score="1" ViewCount="79" Body="&lt;p&gt;Two days ago, my code is working fine on the arduino board. But yesterday, and today I tried so many time to upload the arduino code, which contains 1000 lines of code. It was successfully uploaded the code into arduino. But it only upload half code into arduino when I saw the serial monitor results (I use serial println(); test where the code is located. ) I am so confusing, why the code is working fine two days ago. but later, only half code being used. Please help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the memory I left when I uploaded it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 48,314 bytes (19%) of program storage space. Maximum is 253,952 bytes.&#xA;Global variables use 2,603 bytes (31%) of dynamic memory, leaving 5,589 bytes for local variables. Maximum is 8,192 bytes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Here is the code it stuck :&#xA;   Get Parameters &#xA;//&#xA;//  This function reads the information from the SD card for a given monitoring&#xA;//  site.&#xA;//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int getParameters(){&#xA;  String lowerLimit, upperLimit;&#xA;&#xA;   char buffer[36];&#xA;  char newChar;&#xA;  int index, index1, index2, index3, line, theLength, numSensors;&#xA;  myFile.setTimeout(2000);&#xA;  line = 0;&#xA;  while (myFile.available()) {&#xA;    index = 0;&#xA;    do{&#xA;      newChar = myFile.read();&#xA;      buffer[index] = newChar;&#xA;      index += 1;&#xA;    }&#xA;    while(newChar != 10);&#xA;    buffer[index] = 0;&#xA;    theLines[line] = buffer;&#xA;    Serial.print(theLines[line]);&#xA;    //here the result is something like this&#xA;    //theLines[0] , class 111&#xA;    //theLines[1] , 192.168.1.10&#xA;    //theLines[2] , Mac Address&#xA;&#xA;    line += 1;&#xA;  }&#xA;&#xA;//so it is working fine above the code. But here is the problem stuck.&#xA;//the code cannot go through the rest of the code below. Nothing happened!!!&#xA;  for (int line = 0; line &amp;lt; 10; line++){&#xA;    Serial.print(theLines[line]);&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10923" LastEditorUserId="10923" LastEditDate="2015-07-13T19:43:00.863" LastActivityDate="2015-07-13T20:34:55.840" Title="Arduino code cannot continute process" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13423" PostTypeId="2" ParentId="13421" CreationDate="2015-07-13T20:34:55.840" Score="0" Body="&lt;p&gt;A portion of your code is shown below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  myFile.setTimeout(2000);&#xA;  ....&#xA;  while (myFile.available()) {&#xA;    index = 0;&#xA;    do {&#xA;      newChar = myFile.read();&#xA;      buffer[index] = newChar;&#xA;      index += 1;&#xA;    } while(newChar != 10);&#xA;   ....&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apparently your code is accepting and printing several lines of option setting text and then hangs up in the code extract shown above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose, for example, one extra character appears after the supposedly-last linefeed character.  Your &lt;code&gt;while (myFile.available())&lt;/code&gt; loop will run again.  It will store the extra character, then try to read another character.  If another character isn't available, &lt;code&gt;newChar = myFile.read();&lt;/code&gt; will return a -1 that your code will store.  That will happen repeatedly,  clobbering RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see if this is what's happening, you could change &lt;code&gt;while(newChar != 10);&lt;/code&gt; to (eg) &lt;code&gt;while(newChar != 10 &amp;amp;&amp;amp; index&amp;lt;36);&lt;/code&gt;.  If the code then stops hanging up, look into where the extra character is coming from.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-07-13T20:34:55.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13424" PostTypeId="2" ParentId="13416" CreationDate="2015-07-13T20:55:48.853" Score="7" Body="&#xA;&#xA;&lt;p&gt;Atmel specifically recommend against driving /RESET low from an output pin, because the first thing that the reset process does is set all pins to high impedance, thus cancelling the reset pulse before the recommended reset pulse length has elapsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The recommended use of the watchdog timer does not suffer from these limitations. It is &lt;em&gt;designed&lt;/em&gt; to reset the board (or there would be no purpose to having it) and it does a proper reset (unlike jumping to address 0x0000).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://atmel.force.com/support/articles/en_US/FAQ/Software-Reset&quot; rel=&quot;noreferrer&quot;&gt;Atmel knowledge base - Software Reset&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you want to perform a software reset of your AVR you should use the internal Watchdog. Simply enable it and let it time out. When the Watchdog triggers it resets the program counter back to 0, clears all the registers and performs all the other tasks. This operation gives the same result as pulling the RESET line low.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You should not try to:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;Use another pin of the AVR to pull the external RESET line. The pins of the AVR are tristated halfway through the minimum reset time, this releases the RESET line and hence nothing happens.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Jump to program location 0. Jumping to program location 0 does not clear all the registers and hence you do not have a &quot;clean&quot; reset.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Their suggested code to reset the processor:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;#define Reset_AVR() wdt_enable(WDTO_30MS); while(1) {}&#xA;&#xA;int main(void)&#xA;{&#xA;Reset_AVR();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-13T22:27:04.503" LastActivityDate="2015-07-13T22:27:04.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13425" PostTypeId="2" ParentId="13415" CreationDate="2015-07-13T22:06:09.733" Score="3" Body="&lt;p&gt;Looks like the mega has some clever &lt;a href=&quot;https://arduino-info.wikispaces.com/Timers-Arduino&quot; rel=&quot;nofollow&quot;&gt;servo handling features&lt;/a&gt;. Servo control always uses a timer of some sort and can conflict with the pwm timer. The first 12 servos knock out pins 44,45,46 ...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For Arduino Mega it is a bit more difficult. The timer needed depends on the number of servos. Each timer can handle 12 servos. For the first 12 servos timer 5 will be used (losing PWM on Pin 44,45,46). For 24 Servos timer 5 and 1 will be used (losing PWM on Pin 11,12,44,45,46).. For 36 servos timer 5, 1 and 3 will be used (losing PWM on Pin 2,3,5,11,12,44,45,46).. For 48 servos all 16bit timers 5,1,3 and 4 will be used (losing all PWM pins).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-13T22:06:09.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13426" PostTypeId="1" AcceptedAnswerId="13427" CreationDate="2015-07-13T22:24:53.407" Score="1" ViewCount="6756" Body="&lt;p&gt;We are trying to implement AES or DES encryption using an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have a keypad module attached that will be used to input integers. A String should be generated based on the entered data and encrypted using AES or DES.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have tried several online libraries with no success due to the constraints put on the &quot;plain text&quot; size. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example pseudo-code for the above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string key = &quot;This is a key&quot;;&#xA;string plain = &quot;This is the keypad input&quot; + keypadInput + &quot;and some other random stuff&quot;; &amp;lt;- This should have any size.&#xA;&#xA;var cipher = AES.encode(plain, key);&#xA;print(cipher);&#xA;&#xA;var decoded = AES.decode(cipher, key);&#xA;print(decoded);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could someone please point to the right direction on how to do this?&lt;/p&gt;&#xA;" OwnerUserId="11207" LastEditorUserId="10794" LastEditDate="2015-07-14T00:20:29.513" LastActivityDate="2015-07-14T04:10:41.587" Title="Implementing DES or AES Encryption with DateTime Synchronization on Uno" Tags="|arduino-uno|programming|c++|string|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13427" PostTypeId="2" ParentId="13426" CreationDate="2015-07-13T22:39:06.880" Score="4" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We have no experience with the byte[] objects and whatnot.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Might be time to do a few tutorials. You won't get far programming if you don't learn how to use arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;string&lt;/strong&gt; class is part of the STL (Standard Template Library) which does not come pre-installed on the Arduino (however you can download it if you want to).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://andybrown.me.uk/ws/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;The Standard Template Library (STL) for AVR with C++ streams &lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Briefly, however you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;char key [20] = &quot;This is a key&quot;;&#xA;char keypadInput [16];  // whatever they entered&#xA;&#xA;char plain[80];&#xA;&#xA;strcpy (plain, &quot;This is the keypad input&quot;);&#xA;strcat (plain, keypadInput);&#xA;strcat (plain, &quot;and some other random stuff&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The example code doesn't have any size checking. You would want to make sure that you don't put more than 79 characters into &quot;plain&quot; (to allow for the terminating 0x00 character). For example, look up &lt;strong&gt;strncat&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you please elaborate on how DES or AES as described in the question can be implemented?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Have you done much research? Have you Googled &lt;code&gt;Arduino AES encryption&lt;/code&gt; like I just did? I got this as the first hit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=88890.0&quot; rel=&quot;nofollow&quot;&gt;Topic: new AES library - Arduino Forum&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've written an AES (Advanced Encryption Standard) library for Arduino.  It supports 128, 192 and 256 bit key sizes.  Code space overhead is about 4KB I think, each instance requires 240 bytes RAM for subkeys.  Fairly tightly coded and checked against official test vectors for ECB mode.  Also CBC mode supported.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems that if value of plain is larger than 16 characters the library will encrypt the first 16 characters only... Is this an Arduino Uno limitation?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't want to seem unhelpful, but you really should do some research before asking these questions. From &lt;a href=&quot;https://en.wikipedia.org/wiki/Advanced_Encryption_Standard&quot; rel=&quot;nofollow&quot;&gt;Wikipedia - Advanced Encryption Standard (AES)&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AES is a variant of Rijndael which has a fixed block size of 128 bits, and a key size of 128, 192, or 256 bits. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A &quot;fixed block size of 128 bits&quot; means you encrypt 128 bits at a time, that is, &lt;code&gt;128/8 = 16 bytes&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, it is not an Arduino Uno limitation, it is the way AES works. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://en.wikipedia.org/wiki/Data_Encryption_Standard&quot; rel=&quot;nofollow&quot;&gt;Wikipedia - DES&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the case of DES, the block size is 64 bits.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So DES does 8 bytes at a time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What you can do with a password is to &lt;strong&gt;hash&lt;/strong&gt; it, for example: &lt;a href=&quot;https://en.wikipedia.org/wiki/Secure_Hash_Algorithm&quot; rel=&quot;nofollow&quot;&gt;Secure Hash Algorithm&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/MD5&quot; rel=&quot;nofollow&quot;&gt;MD5&lt;/a&gt; (amongst others). These algorithms take a variable length string and return a fixed &quot;hash&quot;. In the case of MD5 the output is a 128-bit field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could then encrypt that 128-bit hash, if you want to keep it a secret.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Would encrypting the 16 bytes and then append the next 16 bytes and so on result to the same output as if the whole plain text was encrypted in the first place in one go? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The suggestion by @BrettAM was, if you want to encrypt more than 16 bytes, do them 16 bytes at a time, padding if necessary the final block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;AAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBB CCCCCCCCCC000000&#xA;      encrypt        encrypt          encrypt&#xA;LLLLLLLLLLLLLLLL MMMMMMMMMMMMMMMM NNNNNNNNNNNNNNNN&#xA;      decrypt        decrypt          decrypt&#xA;AAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBB CCCCCCCCCC000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example the final block was padded with zeros. Now the receiving end decrypts in 16-byte blocks.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-14T04:10:41.587" LastActivityDate="2015-07-14T04:10:41.587" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13429" PostTypeId="1" AcceptedAnswerId="13443" CreationDate="2015-07-14T02:20:15.777" Score="19" ViewCount="78174" Body="&lt;p&gt;What does this error means?&#xA;I can't solve it in any way.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11152" LastActivityDate="2019-07-09T16:31:52.837" Title="deprecated conversion from string constant to 'char*'" Tags="|programming|arduino-ide|c|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13430" PostTypeId="2" ParentId="13429" CreationDate="2015-07-14T02:22:22.480" Score="5" Body="&lt;p&gt;Either stop trying to pass a string constant where a function takes a &lt;code&gt;char*&lt;/code&gt;, or change the function so that it takes a &lt;code&gt;const char*&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;String like &quot;random string&quot; are constants.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="11152" LastEditDate="2015-07-14T16:14:29.910" LastActivityDate="2015-07-14T16:14:29.910" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13431" PostTypeId="1" AcceptedAnswerId="13433" CreationDate="2015-07-14T02:46:40.813" Score="3" ViewCount="8476" Body="&lt;p&gt;How do I empty all the values inside a variable &lt;code&gt;char array[256];&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a for loop assigning an empty value at each iteration, but it doesn't compile.&lt;/p&gt;&#xA;" OwnerUserId="11152" LastActivityDate="2015-07-14T09:13:06.197" Title="Empty char variable" Tags="|programming|arduino-ide|c|sketch|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13432" PostTypeId="2" ParentId="13429" CreationDate="2015-07-14T02:50:04.480" Score="4" Body="&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void foo (char * s)&#xA;  {&#xA;  Serial.println (s);&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  foo (&quot;bar&quot;);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Warning:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;sketch_jul14b.ino: In function ‘void setup()’:&#xA;sketch_jul14b.ino:10: warning: deprecated conversion from string constant to ‘char*’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;foo&lt;/code&gt; expects a char* (which it can therefore modify) but you are passing a string literal, which should not be modified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler is warning you not to do this. Being deprecated it might turn from a warning into an error in a future compiler version.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Solution: Make foo take a &lt;strong&gt;const&lt;/strong&gt; char *:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void foo (const char * s)&#xA;  {&#xA;  Serial.println (s);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't get it. Do you mean &lt;em&gt;can not&lt;/em&gt; be modified? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Older versions of C (and C++) let you write code like my example above. You could make a function (like &lt;code&gt;foo&lt;/code&gt;) that prints something you pass down to it, and then pass down a literal string (eg. &lt;code&gt;foo (&quot;Hi there!&quot;);&lt;/code&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However a function that takes &lt;code&gt;char *&lt;/code&gt; as an argument is allowed to modify its argument (ie. modify &lt;code&gt;Hi there!&lt;/code&gt; in this case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might have written, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void foo (char * s)&#xA;  {&#xA;  Serial.println (s);&#xA;  strcpy (s, &quot;Goodbye&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, by passing down a literal, you have now potentially modified that literal so that &quot;Hi there!&quot; is now &quot;Goodbye&quot; which is not good. In fact if you copied in a longer string, you might overwrite other variables. Or, on some implementations you would get an access violation because &quot;Hi there!&quot; might have been put in read-only (protected) RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the compiler-writers are gradually &lt;a href=&quot;https://en.wikipedia.org/wiki/Deprecation&quot; rel=&quot;nofollow&quot;&gt;deprecating&lt;/a&gt; this usage, so that functions to which you pass down a literal, must declare that argument as &lt;code&gt;const&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="24045" LastEditDate="2016-07-20T03:05:52.863" LastActivityDate="2016-07-20T03:05:52.863" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13433" PostTypeId="2" ParentId="13431" CreationDate="2015-07-14T03:30:00.307" Score="1" Body="&lt;pre&gt;&lt;code&gt;char array[256];&#xA;&#xA;...&#xA;&#xA;int i;&#xA;for( i=0; i&amp;lt;256;i++ ) {&#xA;    array[i] = 0x00;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-07-14T03:30:00.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13435" PostTypeId="2" ParentId="13431" CreationDate="2015-07-14T09:13:06.197" Score="2" Body="&lt;p&gt;There is a single-line command you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memset(array, 0, 256);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-14T09:13:06.197" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13437" PostTypeId="1" CreationDate="2015-07-14T12:03:49.783" Score="0" ViewCount="95" Body="&lt;p&gt;We are working on a project to control the reaction of a system to a lever, whose position is monitored by two IR sensors at the ends of its travel, the Reward sensor and the Trigger sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are three modes of action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mode1: lever has to start at TriggerSensor, and a success is recorded if and when the lever is moved to RewardSensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mode2: lever starts at TriggerSensor and has to be held for 4 seconds. At the end of this interval a tone is played for 2 seconds, the reward interval. Within this 2 seconds, if the lever is moved to the RewardSensor, a success is recorded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mode3: same as Mode2, but the initial 4 second timeout is of random length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We also want to use the following lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;digitalWrite(TriggerSensorOut, digitalRead(TriggerSensorIn));  //This is to record to our computer the states of the trigger sensor&#xA;  digitalWrite(RewardSensorOut, digitalRead(RewardSensorIn));  //This is to record to our computer the states of the reward sensor&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to constantly write the state of both sensors to our computer. However, this doesn't work as planned: there are delays between the execution of the mode functions (as described in full code below).Essentially, we are struggling to come up with a suitable way to time things correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see full code below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// -----LIBRARIES&#xA;&#xA;//#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;&#xA;// ----CONSTANTS (won't change)&#xA;&#xA;const int TriggerSensorIn = 2;   //  Input from trigger sensor, LOW = broken&#xA;const int RewardSensorIn = 3;    //  Input from reward sensor, LOW = broken&#xA;const int ModeStateIn1 = 4;      //  Input 1 from switch to define paradigm mode&#xA;const int ModeStateIn2 = 5;      //  Input 2 from switch to define paradigm mode&#xA;const int RewardSignalOut = 12;   //  Output signal of reward, parallel taken off to counter module&#xA;const int ServoResetOut = 6;     //  Servo reset output signal&#xA;const int ToneOut = 10;          //  Audio stimulus&#xA;const int TriggerSensorOut = 7;  //  Output from trigger sensor for DAC board recording&#xA;const int RewardSensorOut = 8;   //  Output from reward sensor for DAC board recording&#xA;&#xA;//------- VARIABLES (will change)&#xA;&#xA;boolean backPressed = false;&#xA;&#xA;int timeoutWindow = 4000;    // 4 second preliminary interval&#xA;int rewardWindow = 2000;    // 2 second reward interval&#xA;&#xA;unsigned long currentMillis = 0;&#xA;&#xA;//===============&#xA;&#xA;void setup() {&#xA;&#xA;  // initialise the digital pins as inputs and outputs&#xA;&#xA;  pinMode(TriggerSensorIn, INPUT);&#xA;  pinMode(RewardSensorIn, INPUT);&#xA;  pinMode(ModeStateIn1, INPUT);&#xA;  pinMode(ModeStateIn2, INPUT);&#xA;&#xA;  pinMode(RewardSignalOut, OUTPUT);&#xA;  pinMode(ServoResetOut, OUTPUT);&#xA;  pinMode(ToneOut, OUTPUT);&#xA;  pinMode(TriggerSensorOut, OUTPUT);&#xA;  pinMode(RewardSensorOut, OUTPUT);&#xA;&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void giveReward() {&#xA;  // This function is the protocol for recording a reward&#xA;  currentMillis=millis();&#xA;  digitalWrite(RewardSignalOut, HIGH);&#xA;  while (millis()&amp;gt;currentMillis+200) {&#xA;    digitalWrite(RewardSignalOut, LOW);&#xA;  }&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void servoReset() {&#xA;  // This function is the protocol for resetting servos after a failed action&#xA;  currentMillis=millis();&#xA;  digitalWrite(ServoResetOut, HIGH);&#xA;  while (millis()&amp;gt;currentMillis+200) {&#xA;    digitalWrite(ServoResetOut, LOW);&#xA;  }&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void mode1() {&#xA;  // This function is the protocol for controlling the system during mode 1, no time constraint on the action&#xA;  if (digitalRead(TriggerSensorIn == LOW)) {&#xA;    backPressed = true;&#xA;&#xA;    if (backPressed == true &amp;amp;&amp;amp; digitalRead(RewardSensorIn == LOW)) {&#xA;      giveReward();&#xA;      backPressed = false;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void mode2() {&#xA;  if (digitalRead(TriggerSensorIn == LOW)) {&#xA;    currentMillis=millis();&#xA;    while (digitalRead(TriggerSensorIn == LOW)) {&#xA;      while (millis() &amp;gt; currentMillis + timeoutWindow) {&#xA;        tone(ToneOut, 3000, 2000); &#xA;        {&#xA;          goto rewardSeeking2;&#xA;        }&#xA;      }&#xA;    }&#xA;&#xA;rewardSeeking2:&#xA;    currentMillis=millis();  // reset timer&#xA;    if (millis() &amp;lt; (currentMillis + rewardWindow) &amp;amp;&amp;amp; digitalRead(RewardSensorIn == LOW)) {&#xA;      giveReward();&#xA;    }&#xA;    else if (millis() &amp;gt; (currentMillis + rewardWindow)) {&#xA;      servoReset();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void mode3() {&#xA;  timeoutWindow=random(1000,5000);&#xA;  if (digitalRead(TriggerSensorIn == LOW)) {&#xA;    currentMillis=millis();&#xA;    while (digitalRead(TriggerSensorIn == LOW)) {&#xA;      while (millis() &amp;gt; currentMillis + timeoutWindow) {&#xA;        tone(ToneOut, 3000, 2000); &#xA;        {&#xA;          goto rewardSeeking3;&#xA;        }&#xA;      }&#xA;    }&#xA;&#xA;rewardSeeking3:&#xA;    currentMillis=millis();  // reset timer&#xA;    if (millis() &amp;lt; (currentMillis + rewardWindow) &amp;amp;&amp;amp; digitalRead(RewardSensorIn == LOW)) {&#xA;      giveReward();&#xA;    }&#xA;    else if (millis() &amp;gt; (currentMillis + rewardWindow)) {&#xA;      servoReset();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//===============&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(TriggerSensorOut, digitalRead(TriggerSensorIn));  //This is to record to our computer the states of the trigger sensor&#xA;  digitalWrite(RewardSensorOut, digitalRead(RewardSensorIn));  //This is to record to our computer the states of the reward sensor&#xA;&#xA;&#xA;  if (digitalRead(ModeStateIn1) == LOW &amp;amp;&amp;amp; digitalRead(ModeStateIn2) == LOW) {&#xA;    // Using the two mode selective switches to define mode1&#xA;    mode1();&#xA;  }&#xA;&#xA;  else if (digitalRead(ModeStateIn1) == LOW &amp;amp;&amp;amp; digitalRead(ModeStateIn2) == HIGH) {&#xA;    // Using the two mode selective switches to define mode2&#xA;    mode2();&#xA;  }&#xA;&#xA;  else if (digitalRead(ModeStateIn1) == HIGH &amp;amp;&amp;amp; digitalRead(ModeStateIn2) == LOW)  {&#xA;    // Using the two mode selective switches to define mode3&#xA;    mode3();&#xA;  }&#xA;}&#xA;&#xA;//===============END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11217" LastActivityDate="2016-03-11T04:24:38.047" Title="Issue with time-dependant conditional I/O control flow (Arduino UNO)" Tags="|arduino-uno|time|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13438" PostTypeId="1" CreationDate="2015-07-14T12:19:32.677" Score="1" ViewCount="63" Body="&lt;p&gt;I have been putting together a small robot using an Arduino Motor Shield R3. The shield has two sockets for motors, however the wheel carriage I bought has four motors. I tried putting both right side motors in one socket set, and the left side motors in the other socket set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I turn on the Arduino, the left side motors turn together according to how I coded the board, however the right side behaves differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the motors does not start. If I push it a little it will start turning. Though not always. When I plugged in the misbehaving motor by itself, it runs correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering about cause of the problem here. Is it likely the second motor on the right side is faulty? Or am I trying to use up too much power and disrupting the current?&lt;/p&gt;&#xA;" OwnerUserId="10356" LastEditorUserId="10907" LastEditDate="2015-11-22T14:52:01.690" LastActivityDate="2015-11-22T14:52:01.690" Title="Two motors in one set of pins/plugs" Tags="|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13439" PostTypeId="2" ParentId="13438" CreationDate="2015-07-14T13:25:12.187" Score="1" Body="&lt;p&gt;The drive capacity of the Motor Shield should match the motors – two of the motors. The shield was probably designed for a load of one motor, and you're giving two, so it is possible that neither of the motors on that side is getting enough current to get started. Here are somethings to check to get started:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Find the drive capacity of the Motor Shield and compare it to the motors (if you don't have specs for the motors you could measure the current they draw if you have an DMM). It might be wise to measure the current anyway, just in case you have a defective motor or shield.&lt;/li&gt;&#xA;&lt;li&gt;If the capacity or the current draw is out of line, that's your problem. You can probably just add a power transistor to the circuit to drive the motors in this case.&lt;/li&gt;&#xA;&lt;li&gt;Try it with just one motor on each output and see if they run normally. If they do, that would suggest a loading problem or a defective motor or shield. You can sort out which is which by swapping sides – if one motor runs and the other doesn't, swap them. If the problem follows the motor, then blame the motor, otherwise blame the shield.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-07-14T13:25:12.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13442" PostTypeId="1" CreationDate="2015-07-14T15:07:52.723" Score="2" ViewCount="6067" Body="&lt;p&gt;I have a max7219 driving an 8 digit 7 segment LED array with forward current of 20mA and typical forward voltage of 1.85V. I'm trying to power this through my arduino UNO (which itself is drawing power from USB), and have the max7219 chip's +5V and ISet(+resistor) and ground pins connected to the respective pins on the arduino.  When I try to plug this in, the arduino will not power up, but removing the jumpers from +5V and GND allows the arduino to power up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have confirmed with my multimeter that there is no short between any of the power cables on my led circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage supplied by the arduino works normally if I connect it up to a simple resistor and led on a breadboard.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage across the +5V &amp;amp; GND pins on the arduino drops from 5V to 0V if the jumpers are inserted whilst the arduino is powered up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought perhaps the circuit was trying to draw too much power from the USB, so tried higher resistor values than my initial resistor (20K), to no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else could be causing this?  &lt;/p&gt;&#xA;" OwnerUserId="11218" LastEditorUserId="10794" LastEditDate="2015-07-16T23:03:24.730" LastActivityDate="2016-04-12T15:38:56.740" Title="Arduino Uno powers off when circuit plugged in to +5V and GND pins" Tags="|arduino-uno|power|max7219|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13443" PostTypeId="2" ParentId="13429" CreationDate="2015-07-14T15:10:36.093" Score="30" Body="&lt;p&gt;As is my wont, I'm going to provide a bit of background technical information into the whys and wherefores of this this error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to inspect four different ways of initializing C strings and see what the differences between them are.  These are the four ways in question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *text = &quot;This is some text&quot;;&#xA;char text[] = &quot;This is some text&quot;;&#xA;const char *text = &quot;This is some text&quot;;&#xA;const char text[] = &quot;This is some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now for this I am going to want to change the third letter &quot;i&quot; into an &quot;o&quot; to make it &quot;Thos is some text&quot;.  That could, in all cases (you would think), be achieved by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;text[2] = 'o';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now let's look at what each way of declaring the string does and how that &lt;code&gt;text[2] = 'o';&lt;/code&gt; statement would affect things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First the most commonly seen way: &lt;code&gt;char *text = &quot;This is some text&quot;;&lt;/code&gt;.  What does this literally mean?  Well, in C, it literally means &quot;Create a variable called &lt;code&gt;text&lt;/code&gt; which is a read-write pointer to this string literal which is held in read-only (code) space.&quot;.  If you have the option &lt;code&gt;-Wwrite-strings&lt;/code&gt; turned on then you get a warning as seen in the question above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically that means &quot;Warning: You have tried to make a variable that is read-write point to an area you can't write to&quot;.  If you try and then set the third character to &quot;o&quot; you would in fact be trying to write to a read-only area and things won't be nice.  On a traditional PC with Linux that results in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Segmentation Fault&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now the second one: &lt;code&gt;char text[] = &quot;This is some text&quot;;&lt;/code&gt;.  Literally, in C, that means &quot;Create an array of type &quot;char&quot; and initialize it with the data &quot;This is some text\0&quot;. The size of the array will be big enough to store the data&quot;.  So that actually allocates RAM and copies the value &quot;This is some text\0&quot; into it at runtime.  No warnings, no errors, perfectly valid.  And the right way to do it &lt;em&gt;if you want to be able to edit the data&lt;/em&gt;.  Let's try running the command &lt;code&gt;text[2] = 'o'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Thos is some text&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It worked, perfectly.  Good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the third way: &lt;code&gt;const char *text = &quot;This is some text&quot;;&lt;/code&gt;.  Again the literal meaning: &quot;Create a variable called &quot;text&quot; that is a &lt;em&gt;read only&lt;/em&gt; pointer to this data in read only memory.&quot;.  Note that both the pointer and the data are now read-only.  No errors, no warnings. What happens if we try and run our test command?  Well, we can't.  The compiler is now intelligent and knows that we are trying to do something bad:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: assignment of read-only location ‘*(text + 2u)’&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It won't even compile.  Trying to write to read-only memory is now protected because we have told the compiler that our pointer is to read-only memory.  Of course, it doesn't &lt;em&gt;have&lt;/em&gt; to be pointing to read-only memory, but if you point it to read-write memory (RAM) that memory will still be protected from being written to by the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally the last form: &lt;code&gt;const char text[] = &quot;This is some text&quot;;&lt;/code&gt;.  Again, like before with &lt;code&gt;[]&lt;/code&gt; it allocates an array in RAM and copies the data into it.  However, now this is a read-only array.  You can't write to it because the pointer to it is tagged as &lt;code&gt;const&lt;/code&gt;.  Attempting to write to it results in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: assignment of read-only location ‘*(text + 2u)’&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, a quick summary of where we are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This form is completely invalid and should be avoided at all costs.  It opens the door to all sorts of bad things happening:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *text = &quot;This is some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This form is the right form if you are wanting to make the data editable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char text[] = &quot;This is some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This form is the right form if you want strings that won't be edited:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char *text = &quot;This is some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This form seems wasteful of RAM but it does have its uses.  Best forget it for now though.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char text[] = &quot;This is some text&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-14T15:10:36.093" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13445" PostTypeId="1" CreationDate="2015-07-14T19:09:15.663" Score="0" ViewCount="71" Body="&lt;p&gt;I have a Yun doing data logging. It runs nicely and when I am on the same wifi network I can use the Console Monitor to watch what it is doing in more detail. However, my arduino is deployed far from me so it generally isn't possible to get on the same wifi network to monitor the console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to monitor the console from a different wifi network?&lt;/p&gt;&#xA;" OwnerUserId="7975" LastActivityDate="2015-07-14T19:24:15.607" Title="Console monitor on different wifi network" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13446" PostTypeId="2" ParentId="13445" CreationDate="2015-07-14T19:24:15.607" Score="1" Body="&lt;p&gt;The Yun is just an ordinary network device.  However, the tools you are provided with use a system called mDNS to find the Yun.  That only works across the same local subnet that you are on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Yun is on a different subnet then you will have to (assuming the routing between subnets is working fine) do it manually by knowing the IP address of your Yun.  Use that IP address in place of &quot;arduino.local&quot; or whatever your Yun is called. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-14T19:24:15.607" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13448" PostTypeId="1" CreationDate="2015-07-14T20:38:59.827" Score="2" ViewCount="14027" Body="&lt;p&gt;How do you do this? I've been digging around and I can see that I should do this and supply my own external pull up resistors but I don't know exactly how to disable them. The pages I've been reading never explicity state how. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to enable I2C between a leonardo and an uno, but I think the i2c bus is slowing down considerably because of the internal pullups. I want to switch to two 4.7k resistors but I can't figure out how to disable the internal ones. I know that the Wire library enables the internals by default, but how do I edit the library or disable the pullups in my sketch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I just haven't been reading the right forums or articles, but if anyone could point me in the right direction that would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: So the problem is probably with my setup or code, I'll put it down here. Everything I have before setup is importing libraries and variables like my mac, ip, placeholders for output, pwm, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  while(!Serial){&#xA;  }&#xA;&#xA;  Wire.begin();&#xA;&#xA;  Ethernet.begin(mac, ip);&#xA;  delay(1000);&#xA;&#xA;  server.begin();&#xA;  if(server.available()){&#xA;    Serial.println(&quot;Client Available&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  ethernetwrite();&#xA;&#xA;}&#xA;&#xA;void ethernetwrite() {      &#xA;  EthernetClient client = server.available();&#xA;  while(client) {&#xA;    if(client.find(&quot;P&quot;)) {&#xA;      output = client.parseInt();&#xA;      pwm = client.parseInt();&#xA;&#xA;      Serial.println(&quot;Begin Transmitting&quot;);&#xA;      Wire.beginTransmission(14);&#xA;      Wire.write(output);&#xA;      Wire.write('\t');&#xA;      Wire.write(pwm);&#xA;      Wire.endTransmission();&#xA;      Serial.println(&quot;Done Transmitting&quot;);&#xA;&#xA;      Serial.print(output);&#xA;      Serial.print('\t');&#xA;      Serial.println(pwm);&#xA;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slave:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Wire.begin(14);&#xA;  Wire.onReceive(wirewrite);&#xA;&#xA;// *   - Base frequencies:&#xA;// *      o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz.&#xA;// *      o The base frequency for pins 5 and 6 is 62500 Hz.&#xA;// *   - Divisors:&#xA;// *      o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64,&#xA;// *        256, and 1024.&#xA;// *      o The divisors available p1on pins 3 and 11 are: 1, 8, 32, 64,&#xA;// *        128, 256, and 1024.&#xA;&#xA;    // Leg 1&#xA;    pinMode(leg[1], OUTPUT); setPwmFrequency(leg[1],8); analogWrite(leg[1], offset);&#xA;&#xA;    // Leg 2 &#xA;    pinMode(leg[2], OUTPUT); setPwmFrequency(leg[2],8); analogWrite(leg[2], offset);&#xA;&#xA;    // Leg 3&#xA;    pinMode(leg[3], OUTPUT); setPwmFrequency(leg[3],8); analogWrite(leg[3], offset);&#xA;&#xA;    // Leg 4&#xA;    pinMode(leg[4], OUTPUT); setPwmFrequency(leg[4],8); analogWrite(leg[4], offset);&#xA;&#xA;    // Mirror&#xA;    pinMode(leg[0], OUTPUT); setPwmFrequency(leg[0],clkdivisor); analogWrite(leg[0], 255);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;    int time = 10;&#xA;    time = time*128/clkdivisor;&#xA;&#xA;    // box(time, 255, 1); // box(delay time, radius pwm, pwm step size);&#xA;    // autodisplay(); &#xA;    updateL();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void updateL(){&#xA;  if (output == 0) pwm = 255 - pwm;&#xA;  switch (output) {&#xA;    case 1: pin =  3; break;&#xA;    case 2: pin =  9; break;&#xA;    case 3: pin =  10; break;&#xA;    case 4: pin =  11; break;&#xA;    case 0: pin = 5; break;&#xA;  }&#xA;  //if (output &amp;lt; 5) {&#xA;    analogWrite(pin, pwm);&#xA;  //}&#xA;}&#xA;&#xA;void wirewrite(int numBytes) {&#xA;  String message;&#xA;  while(Wire.available()&amp;gt;0) {&#xA;    char c = Wire.read();&#xA;    message.concat(c);&#xA;  }&#xA;  output = Wire.parseInt();&#xA;  pwm = Wire.parseInt();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I send data to the master, on the serial monitor it freezes in the first wiring transmission or in the next few, and my slave doesn't seem to respond to the message being sent over i2c. My controls for my device and setup worked prior to my attempts with the Wire library, so there's no problem there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I also am sending a message that looks like this:&#xA;&quot;P1 103&quot;&#xA;every .4 seconds or so, but I usually can't get past the first transmission between the arduinos&lt;/p&gt;&#xA;" OwnerUserId="11223" LastEditorUserId="11223" LastEditDate="2015-07-15T16:05:43.717" LastActivityDate="2018-07-16T01:24:16.153" Title="Disabling i2c internal pull up resistors" Tags="|arduino-uno|i2c|arduino-leonardo|pull-up|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13449" PostTypeId="2" ParentId="13437" CreationDate="2015-07-14T20:43:04.653" Score="1" Body="&lt;p&gt;This is a snippet of how I would refactor the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void mode3() {&#xA;  int timeout = millis() + random(1000,5000);&#xA;  while (digitalRead(TriggerSensorIn == LOW) &amp;amp;&amp;amp; &#xA;         millis() &amp;lt; timeout) {&#xA;  };&#xA;  if (digitalRead(TriggerSensorIn == LOW) &amp;amp;&amp;amp; &#xA;         millis() &amp;gt; timeout) {&#xA;     tone(ToneOut, 3000); &#xA;     timeout = millis() + rewardWindow;&#xA;     while (millis() &amp;lt; timeout)&#xA;       if (digitalRead(RewardSensorIn == LOW)&#xA;         giveReward();&#xA;  }&#xA;  noTone();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // This is to record to our computer the states of&#xA;  // the trigger sensor&#xA;  digitalWrite(TriggerSensorOut, digitalRead(TriggerSensorIn));  &#xA;&#xA;  // This is to record to our computer the states of&#xA;  // the reward sensor&#xA;  digitalWrite(RewardSensorOut, digitalRead(RewardSensorIn));  &#xA;&#xA;&#xA;  int msin1 = digitalRead(ModeStateIn1);&#xA;  int msin2 = digitalRead(ModeStateIn2);&#xA;&#xA;  if (msin1 == LOW)&#xA;      if (msin2 == LOW)&#xA;          mode1();&#xA;      else&#xA;          mode2();&#xA;  else if (msin2 == LOW)&#xA;    mode3();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I think you should first try to write it down in plain English and verify that at least that algo works.&#xA;Then you can think how to transpose it into code.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-14T20:43:04.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13450" PostTypeId="2" ParentId="13448" CreationDate="2015-07-14T20:48:55.380" Score="4" Body="&lt;p&gt;From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that the internal pull-ups in the AVR pads can be enabled by setting the PORT bits corresponding to the SCL and SDA pins, as explained in the I/O Port section.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To disable the internal pull-ups:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(A4, LOW);&#xA;digitalWrite(A5, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(2, LOW);&#xA;digitalWrite(3, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2018-07-16T01:24:16.153" LastActivityDate="2018-07-16T01:24:16.153" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="13452" PostTypeId="1" AcceptedAnswerId="13454" CreationDate="2015-07-14T21:07:54.903" Score="0" ViewCount="1218" Body="&lt;p&gt;Is there a particular function in the library TinyGPS or TinyGPS Plus which outputs the raw NMEA sentences? I couldn't find anything about it on the website guide of the library.&lt;/p&gt;&#xA;" OwnerUserId="11152" LastEditorUserId="10794" LastEditDate="2015-07-14T22:23:51.133" LastActivityDate="2015-07-14T22:23:51.133" Title="TinyGPS (Plus) Library" Tags="|arduino-ide|library|gps|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13453" PostTypeId="2" ParentId="13429" CreationDate="2015-07-14T22:03:26.053" Score="6" Body="&#xA;&#xA;&lt;p&gt;To elaborate on Makenko's excellent answer, there is a good reason why the compiler warns you about this. Let's make a test sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;char *foo = &quot;This is some text&quot;;&#xA;char *bar = &quot;This is some text&quot;;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  foo [2] = 'o';     // change foo only&#xA;  Serial.println (foo);&#xA;  Serial.println (bar);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We have two variables here, foo and bar. I modify &lt;strong&gt;one&lt;/strong&gt; of those in setup(), but see what the result is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Thos is some text&#xA;Thos is some text&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They &lt;strong&gt;both&lt;/strong&gt; got changed!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact if we look at the warnings we see:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;sketch_jul14b.ino:1: warning: deprecated conversion from string constant to ‘char*’&#xA;sketch_jul14b.ino:2: warning: deprecated conversion from string constant to ‘char*’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The compiler knows this is dodgy, and it is right! The reason for this is, that the compiler (reasonably) expects that string constants don't change (since they are constants). Thus if you refer to the string constant &lt;code&gt;&quot;This is some text&quot;&lt;/code&gt; multiple times in your code it is allowed to allocate the &lt;strong&gt;same&lt;/strong&gt; memory to all of them. Now if you modify one, you modify all of them!&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-14T22:03:26.053" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13454" PostTypeId="2" ParentId="13452" CreationDate="2015-07-14T22:22:02.843" Score="2" Body="&#xA;&#xA;&lt;p&gt;There doesn't seem to be, but what you could do is print each character as it arrives. From their example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  while (nss.available())&#xA;  {&#xA;    if (gps.encode(nss.read()))    // &amp;lt;--- pass to TinyGPS&#xA;      return true;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, change that to be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  while (nss.available())&#xA;  {&#xA;    char c = nss.read();  // &amp;lt;--- get the incoming character&#xA;    Serial.print (c);     // &amp;lt;--- print it&#xA;    if (gps.encode(c))    // &amp;lt;--- now pass it to TinyGPS&#xA;      return true;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-14T22:22:02.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13455" PostTypeId="1" CreationDate="2015-07-14T23:05:39.723" Score="1" ViewCount="223" Body="&lt;p&gt;I've been racking my head trying to start programming in a library organized method. My code works, but the translation and split to a .h and .cpp file is riddled with errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's gotta be stupidly simple all I'm asking for is a review:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Header File&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ifndef _INITIALIZE_H&#xA;#define _INITIALIZE_H&#xA;&#xA;#if (ARDUINO &amp;gt;= 100)&#xA;# include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA;# include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&#xA;//-Extra Includes-&#xA;#include &amp;lt;config.h&amp;gt; //Provides baud...&#xA;#include &amp;lt;SSC32.h&amp;gt;&#xA;&#xA;#define STANDARD 0&#xA;#define DEBUG    1&#xA;#define VIRTUAL  2&#xA;&#xA;class Initialize {&#xA;    private:&#xA;        int _mode;&#xA;    public:&#xA;        Initialize();&#xA;        void begin();&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;associated .cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Comments&#xA;#include &amp;lt;Initialize.h&amp;gt;&#xA;SSC32 SSC;&#xA;&#xA;Initialize::Initialize() &#xA;{&#xA;    _mode = STANDARD;&#xA;}&#xA;&#xA;void Initialize::begin() &#xA;{&#xA;    SSC.begin(baud);&#xA;    if(Serial.available() &amp;gt; 0){&#xA;        if(sscReturn == 1){&#xA;            Serial.println(&quot;ver&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error from the compiler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp: In member function 'void Initialize::begin()':&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:12: error: expected primary-expression before '=' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:16: error: expected primary-expression before ')' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:9:16: error: expected ';' before ')' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:7: error: expected primary-expression before '=' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:7: error: expected ')' before ';' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:17: error: expected primary-expression before '==' token&#xA;D:\Github\Project-Onyx-Quadruped\code\HostControllerFirmware\Onyx-HostFirmware-Initial-7-2-15\libraries\Initialize\Initialize.cpp:11:21: error: expected ';' before ')' token&#xA;Failed compiling libraries&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11227" LastEditorUserId="10907" LastEditDate="2016-01-13T01:32:41.030" LastActivityDate="2021-12-02T09:00:40.067" Title="Quick Programming Check/Review" Tags="|programming|code-review|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13456" PostTypeId="1" CreationDate="2015-07-14T23:37:05.600" Score="3" ViewCount="10673" Body="&lt;p&gt;Okay, here's the story. I'm not &lt;strong&gt;very&lt;/strong&gt; familiar with how Arduino works but learning. I have a project that requires AES encryption on the Arduino Uno. As per a previous question we managed to figure out the problem but failed to resolve it fully so we started using another library. (This one: &lt;a href=&quot;https://github.com/qistoph/ArduinoAES256&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/qistoph/ArduinoAES256&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;uint8_t key[] = { //&#xA;    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,&#xA;    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,&#xA;    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,&#xA;    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f&#xA;  };&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now onto the problem itself. Using an online AES encryption tool such as: &lt;a href=&quot;http://aesencryption.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://aesencryption.net/&lt;/a&gt; Simply asks for a &lt;code&gt;Key of the encryption&lt;/code&gt; in &lt;strong&gt;plain text&lt;/strong&gt; and the output is &lt;code&gt;base64&lt;/code&gt; as specified by the service here: &lt;code&gt;The result of the encryption will appear in base64 encoded to prevent character encoding problems.&#xA;&lt;/code&gt;&#xA;Also, &lt;strong&gt;plain text&lt;/strong&gt; can be used to process the encryption using &lt;code&gt;AES&lt;/code&gt; algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying to achieve the exact same result using an &lt;code&gt;Arduino Uno&lt;/code&gt; board with the exact same requirements. The end result is to have a &lt;code&gt;base64&lt;/code&gt; string that can be decrypted on another remote location having the same &lt;code&gt;key&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as for the &lt;code&gt;.ino&lt;/code&gt; file it has this setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;aes256.h&quot; //Include library files&#xA;#define DUMP(str, i, buf, sz) { Serial.println(str); \&#xA;    for(i=0; i&amp;lt;(sz); ++i) { if(buf[i]&amp;lt;0x10) Serial.print('0'); Serial.print(char(buf[i]), HEX); } \&#xA;    Serial.println(); } //Help function for printing the Output&#xA;&#xA;aes256_context ctxt;&#xA;&#xA;void setup() {&#xA;  int i;&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.println(&quot;Initializing AES256... &quot;);&#xA;  uint8_t key[] = { //&#xA;    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,&#xA;    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,&#xA;    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,&#xA;    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f&#xA;  };&#xA;  DUMP(&quot;Key: &quot;, i, key, sizeof(key));&#xA;  aes256_init(&amp;amp;ctxt, key);&#xA;&#xA;  uint8_t data[] = { //&quot;asdfasdfasdfasdf&quot;&#xA;    0x61, 0x73, 0x64, 0x66, 0x61, 0x73, 0x64, 0x66,&#xA;    0x61, 0x73, 0x64, 0x66, 0x61, 0x73, 0x64, 0x66&#xA;  };&#xA;  DUMP(&quot;Unencrypted data: &quot;, i, data, sizeof(data));&#xA;&#xA;  aes256_encrypt_ecb(&amp;amp;ctxt, data);&#xA;  DUMP(&quot;Encrypted data: &quot;, i, data, sizeof(data));&#xA;&#xA;  aes256_decrypt_ecb(&amp;amp;ctxt, data);&#xA;  DUMP(&quot;Back decrypted data: &quot;, i, data, sizeof(data));&#xA;&#xA;  aes256_done(&amp;amp;ctxt);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;1) I can't seem to understand what is required to have a &lt;code&gt;plain text&lt;/code&gt; key and &lt;code&gt;plain text&lt;/code&gt; message to encrypt giving an end result of &lt;code&gt;base64&lt;/code&gt; output.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;For example if I were to do this using &lt;code&gt;JavaScript&lt;/code&gt;: (And this is just an example).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;2) I'd like to achieve something like this:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var key = &quot;32 characters plain text here&quot;;&#xA;var plain = &quot;Unlimited characters text here that can be used by the library to encrypt this plain message variable&quot;;&#xA;var base64_output = aes.encrypt256(key, plain);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;3) &lt;strong&gt;I'd like to have the base64_output as base64 string so that it can be printed on a third-party printer hooked to the Arduino.&lt;/strong&gt; - Is this impossible to achieve? We've been trying for some time now from endless conversions to splitting up our &lt;code&gt;plain&lt;/code&gt; text into chunks of 16 characters so that we can encrypt the message.&lt;/h3&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated. If someone doesn't mind us contacting them over the phone we would also greatly appreciate a phone call to have this issue explained and resolve so we can share our experience with the Arduino community.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;edit:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;We're getting this error&#xA;&lt;img src=&quot;https://i.stack.imgur.com/x4Xm7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;edit2:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Thank you @Nick Gammon for the quick response.&#xA;After removing const from the function 4 places and the &lt;code&gt;key&lt;/code&gt; variable declaration, everything seems to be working fine now.&#xA;We modified the code in order to print all bytes for each cipher block. We have this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;140 145 154 38 228 66 98 128 116 68 245 193 70 84 205 115 &#xA;Œ‘š&amp;amp;äBb€tDõÁFTÍsŒ‘š&amp;amp;äBb€tDõÁFTÍs&#xA;186 174 17 21 162 83 96 210 128 134 46 206 172 215 0 103 &#xA;º®¢S`Ò€†.Î¬×&#xA;112 4 216 150 27 202 6 176 77 159 123 231 127 128 32 132 &#xA;pØ–Ê°MŸ{ç€ „pØ–Ê°MŸ{ç€ „&#xA;215 110 118 33 167 193 212 121 156 46 63 139 183 124 63 152 &#xA;×nv!§ÁÔyœ.?‹·|?˜×nv!§ÁÔyœ.?‹·|?˜&#xA;130 91 174 118 4 202 250 74 228 7 173 40 246 124 53 173 &#xA;‚[®vÊúJä­(ö|5­‚[®vÊúJä­(ö|5­&#xA;231 48 204 82 235 172 202 139 33 134 137 81 209 191 210 217 &#xA;ç0ÌRë¬Ê‹!†‰QÑ¿ÒÙç0ÌRë¬Ê‹!†‰QÑ¿ÒÙ&#xA;184 161 98 135 12 230 86 213 183 113 103 234 187 213 224 133 &#xA;¸¡b‡æVÕ·qgê»Õà…¸¡b‡æVÕ·qgê»Õà…&#xA;Done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We're trying to convert each array of bytes into a &lt;code&gt;char&lt;/code&gt; array of hex values then base_64 encode it.  But we're getting this output which is not what we want. Can you please explain how can we achieve this.&#xA;Please let us know if it is possible to open a chat with you so that we can understand this better.&lt;/p&gt;&#xA;" OwnerUserId="11207" LastEditorUserId="11207" LastEditDate="2015-07-16T23:05:42.170" LastActivityDate="2015-11-14T03:51:06.170" Title="AES Simplified for Arduino - Having hard time achieving desired result" Tags="|arduino-uno|programming|c++|c|sketch|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13457" PostTypeId="2" ParentId="13456" CreationDate="2015-07-15T00:24:11.230" Score="0" Body="&lt;p&gt;If you don't have to have the features of the String object, I'd highly recommend you use a uint8_t (or 'byte' or 'char') array from the get-go. It avoids the conversion altogether, as well as the code complexities of dealing with Strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;uint8_t plain = &quot;Hello World&quot;;&lt;/code&gt; works great for a literal string, or if you need more flexibility, &lt;code&gt;uint8_t plain[256+1] = &quot;Hello World&quot;;&lt;/code&gt; lets you use or re-use that space for whatever strings you need to hold at run-time (pick a size appropriate for your needs, obviously). Will that let you get past the conversion road-block to focus on encryption (about which, I'd be no help at all).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-07-15T00:24:11.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13458" PostTypeId="2" ParentId="13455" CreationDate="2015-07-15T01:31:22.333" Score="-1" Body="&lt;p&gt;Sorry, figured it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &quot;config.h&quot; file I was pulling, I had a&#xA; &lt;code&gt;#define = 18;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;instead of a &lt;code&gt;#define 18&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I might be wrong, but the compiler stopped complaining&lt;/p&gt;&#xA;" OwnerUserId="11227" LastActivityDate="2015-07-15T01:31:22.333" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13459" PostTypeId="1" AcceptedAnswerId="13461" CreationDate="2015-06-30T12:33:06.500" Score="1" ViewCount="1107" Body="&lt;p&gt;I have a problem which I am working on for some days now. I do have knowledge in electronics, but not extensively. I also posted this question in the &lt;a href=&quot;http://forum.rfduino.com/index.php?topic=1146.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;RFduino Forum&lt;/a&gt; but couldn't get any good answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do: I want to connect the Sparkfun CAN bus shield to the RFduino. I am using the code further below. It compiles without problem and &lt;strong&gt;does work&lt;/strong&gt; with my Arduino Leonardo!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a logic analyser (ignore the filled shapes, some display error) to further narrow down the problem and found the following on the &lt;strong&gt;RFduino&lt;/strong&gt;:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yNB30.png&quot; alt=&quot;Picture of the logic analyser on the RFduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the &lt;strong&gt;Leonardo&lt;/strong&gt;, it looks different:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/JhnnI.png&quot; alt=&quot;Picture of the logic analyser on the Leonardo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like I don't get a response on the MISO line! I played around with different speeds, but nothing seemed to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do have a suspicion however: The RFduino works with 3.3V, while the Leonardo works with 5V. So the logic signals on the RFduino can only achieve 3.3V P-P. I confirmed this with my old CRO, LOW is at GND and HIGH at 3.3V. The Leonardo has 5V P-P. &#xA;On page 70 of the datasheet for the MCP2515 (the chip used on the shield), it says that the supply voltage VDD ranges from 2.7V to 5.5V. So supply voltage should be ok. V_INPUT_HIGH ranges from 2.31 to 4.3V. V_INPUT_LOW ranges from -0.3V to 0.495V. I am in this range! Similarly so for the V_OUTPUT_LOW (up to 0.6V) and V_OUTPUT_HIGH (at least 2.8V). Could this nevertheless be a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would you try or change?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21801d.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP2515 Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// demo: CAN-BUS Shield, send data&#xA;#include &amp;lt;mcp_can.h&amp;gt;&#xA;&#xA;&#xA;MCP_CAN CAN0(SS);                                      // Set CS to pin 10&#xA;&#xA;unsigned char stmp[8] = {0, 1, 0, 3, 0, 5, 0, 7};&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  while (!Serial) {&#xA;    ;                  // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  // init can bus, baudrate: 500k&#xA;  if(CAN0.begin(CAN_500KBPS) == CAN_OK) Serial.print(&quot;can init ok!!\r\n&quot;);&#xA;  else Serial.print(&quot;Can init fail!!\r\n&quot;);&#xA;               // send data per 100ms&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;//    // send data:  id = 0x00, standrad flame, data len = 8, stmp: data buf&#xA;//  CAN0.sendMsgBuf(0x00, 0, 8, stmp);      &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="zorgmorg" LastEditorUserId="9962" LastEditDate="2016-02-21T09:06:36.170" LastActivityDate="2016-02-21T09:06:36.170" Title="Connect the Sparkfun CAN bus shield with an RFduino" Tags="|spi|can-bus|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13460" PostTypeId="2" ParentId="13459" CreationDate="2015-06-30T13:53:35.100" Score="0" Body="&lt;p&gt;It is difficult to tell whether your chip select is working correctly or not with the logic analyzer view.  Have you tried hooking it up to an o-scope to capture what the CS is actually doing(in the analog world)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What cabling have you chosen between the CAN and arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get the o-scope out, you may want to check the MISO and MOSI for ringing, which may lead back to cabling.&lt;/p&gt;&#xA;" OwnerDisplayName="AJee" LastActivityDate="2015-06-30T13:53:35.100" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13461" PostTypeId="2" ParentId="13459" CreationDate="2015-07-02T07:43:57.160" Score="2" Body="&lt;p&gt;Ok, I found the solution. The fix first: I had to &lt;strong&gt;physically connect the reset line from the RFduino to the MCP2515 reset pin.&lt;/strong&gt;&#xA;On page 55 in the datasheet of the MCP2515 it says that you can either reset it by pulling the reset line low or by sending a command over the SPI. The library I used is sending this reset command, but it isn't working for some reason. The logic analyser shows me this signal, it is the first recorded. Maybe it is a timing issue, that the reset has to be sent at the same time as the RFduino resets. Connecting the reset pin solves this issue, because then the RFduino and the MCP2515 are being reset at the same time. &#xA;If anybody knows more about this, feel free to tell me!&lt;/p&gt;&#xA;" OwnerDisplayName="zorgmorg" LastActivityDate="2015-07-02T07:43:57.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13462" PostTypeId="1" CreationDate="2015-07-15T04:06:12.113" Score="4" ViewCount="13058" Body="&lt;p&gt;I have used the &lt;a href=&quot;https://github.com/knolleary/pubsubclient/tags&quot; rel=&quot;nofollow&quot;&gt;pubsubclient library&lt;/a&gt; for Arduino for communicating with an MQTT broker in the past, however the library works only with Ethernet connecction. I need to use GSM in my application and am using the SIM900 at the moment. However, I cannot seem to find any library for MQTT communication using an Arduino as MQTT client and SIM900 as gateway. I found this to be surprising as there must surely be many instances where one would want to upload data from Arduino to a MQTT broker in a mobile scenario where cellular network is the only option (in place of Ethernet). So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible to use the Arduino as MQTT client and SIM900 as gateway for communicating with an MQTT broker? Are there any libraries for the same?&lt;/li&gt;&#xA;&lt;li&gt;What is the current standard way (gateway / communication protocol) of uploading some sensor data from Arduino to an internet server in a mobile scenario (i.e., where Ethernet is not an option)? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11051" LastActivityDate="2021-03-20T19:56:28.100" Title="MQTT client on Arduino + SIM900" Tags="|arduino-uno|gsm|ethernet|communication|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13463" PostTypeId="2" ParentId="13442" CreationDate="2015-07-15T04:43:16.747" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;and have the ... ISet(+resistor) and ground pins connected to the respective pins on the arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;What&lt;/em&gt; pin on the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ISet resistor should go to +5 V - don't connect it to an Arduino pin (unless you mean the +5 V Arduino pin). See diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/iyDN7.png&quot; alt=&quot;MAX7219 wiring for 7-segment display&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a 7-segment display working fine on an Arduino via the USB, see photo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/OSkof.jpg&quot; alt=&quot;7-segment display with Arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details here: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interfacing LED displays with the MAX7219 driver&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-15T04:43:16.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13464" PostTypeId="2" ParentId="13456" CreationDate="2015-07-15T05:10:03.327" Score="1" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;We've been trying for some time now from endless conversions to splitting up our plain text into chunks of 16 characters so that we can encrypt the message.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To address this question/issue, below is some code that will take an arbitrary length string and break it into 16-character strings suitable for encoding with AES:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int KEY_SIZE = 32;&#xA;const int BLOCK_SIZE = 16;&#xA;const char message [] = &quot;Unlimited characters text here that can be used by the library to encrypt this plain message variable&quot;;&#xA;const byte key [KEY_SIZE] = &quot;32 characters plain text here&quot;;&#xA;&#xA;void encrypt_it (const byte plaintext [BLOCK_SIZE], const byte cipherkey [KEY_SIZE]);  // prototype&#xA;void encrypt_it (const byte plaintext [BLOCK_SIZE], const byte cipherkey [KEY_SIZE])&#xA;  {&#xA;  // encrypt here&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  const char * p = message;&#xA;&#xA;  while (strlen (p) &amp;gt; 0)&#xA;    {&#xA;    byte plain [BLOCK_SIZE];&#xA;    memset (plain, 0, BLOCK_SIZE);  // ensure trailing zeros&#xA;    // copy block into plain array&#xA;    memcpy (plain, p, min (strlen (p), BLOCK_SIZE));&#xA;    // encrypt it&#xA;    encrypt_it (plain, key);&#xA;    // advance past this block&#xA;    p += min (strlen (p), BLOCK_SIZE);&#xA;    }&#xA;  Serial.println (&quot;Done&quot;);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd like to have the base64_output as base64 string so that it can be printed on a third-party printer hooked to the Arduino. - Is this impossible to achieve?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course it is possible. Just look up (Google) a C or C++ function to base-64 encode a string. There must be thousands of them. This is not an Arduino question, this is a C programming question.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As per a previous question we managed to figure out the problem but failed to resolve it fully ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Namely here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/13426/implementing-des-or-aes-encryption-with-datetime-synchronization-on-uno&quot;&gt;Implementing DES or AES Encryption with DateTime Synchronization on Uno&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question actually looks remarkably similar to your previous one.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-15T05:20:35.253" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13465" PostTypeId="1" AcceptedAnswerId="13513" CreationDate="2015-07-15T05:37:07.360" Score="1" ViewCount="1362" Body="&lt;p&gt;I have 2 Xbee Series 2 modules. &#xA;One of it is connected to arduino via an adapter. And Ground 5V, as well as Rx&gt;&gt;Tx and Tx&gt;&gt;Rx. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The xbee is configured AT mode Coordinator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use the serial monitor in arduino to change the parameters of the xbee, such as DH or DL or PAN ID things like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way for the xbee to display its &quot;OK&quot; response after entering command mode on the serial monitor?&lt;/p&gt;&#xA;" OwnerUserId="11129" LastActivityDate="2015-07-16T23:45:31.130" Title="Arduino Xbee AT command mode" Tags="|serial|arduino-mega|xbee|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13466" PostTypeId="2" ParentId="13465" CreationDate="2015-07-15T09:16:21.657" Score="0" Body="&lt;p&gt;Not if you have it connected to pins 0 and 1, no.  You should not use those pins for anything unless you absolutely have to, since they are what are used for communication with the PC.  You can't do both communication with the PC and with the XBee using the same pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should ensure that the XBee is connected to one of the other serial ports on the Mega and then write a sketch that passes the data through from one port to the other as needed so you can view it on the serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-15T09:16:21.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13467" PostTypeId="2" ParentId="13456" CreationDate="2015-07-15T09:24:33.410" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;2) I'd like to achieve something like this:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;&#xA;  var key = &quot;32 characters plain text here&quot;;&#xA;  var plain = &quot;Unlimited characters text here that can be used by the library to encrypt this plain message variable&quot;;&#xA;  var base64_output = aes.encrypt256(key, plain);&#xA;  &lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So do it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_MESSAGE_SIZE 256&#xA;uint8_t key[] = &quot;32 characters plain text here&quot;;&#xA;uint8_t plain[MAX_MESSAGE_SIZE+1] = &quot;Unlimited characters text here that can be used by the library to encrypt this plain message variable&quot;;&#xA;aes256_init(&amp;amp;ctxt, key);&#xA;aes256_encrypt_ecb(&amp;amp;ctxt, plain);&#xA;// plain is now encrypted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is limited to a maximum message (and encrypted output) size of 256 bytes due to the (purely arbitrary) size of the array I chose.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-15T09:24:33.410" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13468" PostTypeId="2" ParentId="13448" CreationDate="2015-07-15T10:41:28.773" Score="4" Body="&lt;p&gt;Let's go back to basics. A low-value pull-up resistor actually improves the shape of the I&lt;sup&gt;2&lt;/sup&gt;C clock and data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;One internal pull-up:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tPDqD.png&quot; alt=&quot;I2C with one internal pull-up resistor&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Both ends with the internal pull-up:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Ldtd.png&quot; alt=&quot;I2C with two internal pull-up resistors&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;10 k external pull-up:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/jHiPf.png&quot; alt=&quot;I2C with 10 k external pull-up&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;4.7 k external pull-up:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WeSgG.png&quot; alt=&quot;I2C with 4.7 k external pull-up&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;2.2 k external pull-up:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/QebED.png&quot; alt=&quot;I2C with 2.2 k external pull-up&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Majenko pointed out, leaving the internal pull-ups enabled would give you a pull-up between 4.7 k and 2.2 k. And as my screenshots show, that is perfectly acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, it is probably better. See the nice square signals?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So your hypothesis that the pull-up is responsible for it running slowly is not supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to post your code, and other details, such as the length of the cable runs.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think the i2c bus is slowing down considerably ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What do you mean &quot;slowing down&quot;? Compared to what? What are your figures? What is the transmission time? What do you expect it to be? Some facts please.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;My page about I&lt;sup&gt;2&lt;/sup&gt;C&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-15T10:41:28.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13469" PostTypeId="1" AcceptedAnswerId="13471" CreationDate="2015-07-15T11:08:46.373" Score="1" ViewCount="293" Body="&lt;p&gt;I'm working on a system of acquisition and ECG datalogging with the Arduino, and I'm having the following problem:&#xA;I'm losing data every 103 points (just 103). No matter the sampling frequency to use, every 103 points, some points are lost, damaging the signal sampling.&#xA;It could be the recording time on the SD card, but even when the SD.close () command is run only once, the data is lost.&#xA;Here is a simple test algorithm with a 100 Hz sine wave at the entrance.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;int CS = 4;&#xA;int ECG_PIN = 1;&#xA;int voltage;&#xA;&#xA;int index = 0;&#xA;const int bufferSize = 5;&#xA;int vetor[bufferSize];&#xA;int RECORD_TIME = 20000;&#xA;File logFile;&#xA;&#xA;void setup(){&#xA;  pinMode(CS, OUTPUT);&#xA;  pinMode(ECG_PIN,INPUT);&#xA;&#xA;  if(!SD.begin(CS)){&#xA;    return;&#xA;  }&#xA;  logFile = SD.open(&quot;ECG_log.txt&quot;, O_CREAT | O_WRITE);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;  while(millis() &amp;lt;= RECORD_TIME){&#xA;&#xA;      voltage = analogRead(ECG_PIN);&#xA;    if(logFile){&#xA;&#xA;       logFile.println(voltage);&#xA;&#xA;       delay(0.5); &#xA;    }&#xA;  }&#xA;  logFile.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tlVlK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could it be? Speed analogRead ()? Problem on the SD card?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if the question is very basic, I am beginner, in a way, the Arduino platform. Any help will be very welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!...&lt;/p&gt;&#xA;" OwnerUserId="11233" LastActivityDate="2015-07-15T11:31:56.780" Title="Signal sampling: losing data every 103 points when it is recorded in SD" Tags="|analogread|sd-card|signal-processing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13470" PostTypeId="1" AcceptedAnswerId="13472" CreationDate="2015-07-15T11:17:11.887" Score="3" ViewCount="2020" Body="&lt;p&gt;I have completed the circuit and code to interface ESP8266 module with Arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i send &lt;code&gt;AT&lt;/code&gt;,&lt;code&gt;AT+RST&lt;/code&gt; from serial monitor the reply is correct .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when i send AT commands to search WIFI networks (&lt;code&gt;AT+CWLAP&lt;/code&gt;) &amp;amp; connect to WIFI (&lt;code&gt;AT+CWJAP=&quot;SSID&quot;,&quot;password&quot;&lt;/code&gt;) the reply is &lt;code&gt;ERROR&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the IP address (may be default) is obtained as &lt;code&gt;192.168.4.1&lt;/code&gt;&#xA; when i send &lt;code&gt;AT+CIFSR&lt;/code&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.  &#xA;                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2  &#xA;                             // and the RX line from the esp to the Arduino's pin 3  &#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    esp8266.begin(9600); // your esp's baud rate might be different&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if(esp8266.available()) // check if the esp is sending a message&#xA;    {&#xA;        while(esp8266.available())&#xA;        {&#xA;            // The esp has data so display its output to the serial window&#xA;            char c = esp8266.read(); // read the next character.&#xA;            Serial.write(c);&#xA;        }&#xA;    }&#xA;    if(Serial.available())&#xA;    {&#xA;        // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest&#xA;        // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it&#xA;        // but we want to send everything at the same time.&#xA;        delay(1000);&#xA;        String command=&quot;&quot;;&#xA;        while(Serial.available()) // read the command character by character&#xA;        {&#xA;            // read one character&#xA;            command+=(char)Serial.read();&#xA;        }&#xA;        esp8266.println(command); // send the read character to the esp8266&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6725" LastEditorUserId="220" LastEditDate="2015-07-18T15:31:25.303" LastActivityDate="2015-07-18T15:31:25.303" Title="Arduino with ESP8266" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13471" PostTypeId="2" ParentId="13469" CreationDate="2015-07-15T11:31:56.780" Score="4" Body="&lt;p&gt;It's all to do with writing to the SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a buffer of 512 bytes which is one &quot;block&quot; of the SD card.  When you have written to the card enough to fill that buffer up it has to write that buffer to the SD card and empty the buffer so you can start filling it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That writing to the SD card takes time - lots and lots of time (relatively), and it can't be doing anything else at the same time as writing to the SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way you can get around that is to have your sampling performed within an interrupt - maybe a timer interrupt - so that it can interrupt the writing to the SD card.  However, that's not a simple task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to implement a system known as &lt;em&gt;ping-pong&lt;/em&gt; buffers.  You have a pair of buffers for storing incoming samples within your interrupt routine.  When one buffer is filled up you switch to the other buffer and signal to your main loop() routine that you have filled the buffer.  It's then the job of loop() to save that buffer to the SD card and empty it ready for when the second buffer has been filled up.  The name &lt;em&gt;ping-pong&lt;/em&gt; comes from the game of table tennis (also known as &lt;em&gt;ping-pong&lt;/em&gt;) as you are switching from one buffer to the other and back again in a constant backwards-and-forwards motion like the ball in a game of table tennis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting the right size of buffers is also critical.  You have to ensure that the time taken to fill one buffer is always going to be longer than the longest amount of time it takes to write a buffer to the SD card, including any flushing of the internal SD card buffer.  The best size is probably going to be to match that internal SD card buffer so every &lt;em&gt;ping&lt;/em&gt; or &lt;em&gt;pong&lt;/em&gt; you will be doing an entire SD card block's worth of data - so 512 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means you have 3 buffers of 512 bytes - your two ping-pong buffers and the SD card's buffer, which is 1536 bytes - not far off the limit of an Uno, so you may struggle with that.  For this kind of thing it is better to use one of the boards with a more meaty chip, like the Mega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(0.5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is meaningless.  &lt;code&gt;delay()&lt;/code&gt; takes an integer value, so &lt;code&gt;0.anything&lt;/code&gt; is actually truncated to &lt;code&gt;0&lt;/code&gt;.  To delay for less than a millisecond you should use &lt;code&gt;delayMicroseconds()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-15T11:31:56.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13472" PostTypeId="2" ParentId="13470" CreationDate="2015-07-15T11:47:37.577" Score="6" Body="&lt;p&gt;Finally i found the solution . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Send &lt;code&gt;AT+CWMODE=1&lt;/code&gt; first , then all other commands working fine. &lt;/p&gt;&#xA;" OwnerUserId="6725" LastActivityDate="2015-07-15T11:47:37.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13473" PostTypeId="1" CreationDate="2015-07-15T13:52:36.977" Score="2" ViewCount="346" Body="&lt;p&gt;I'm working on implementing CH340 drivers used by cheap Arduino clones on Android (Linux). What endpoints should be used as read endpoint since two endpoints have IN flag - 0x81 and 0x82?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://usbdriverwriting.blogspot.ru/2012/10/connection-status-device-connected.html&quot; rel=&quot;nofollow&quot;&gt;http://usbdriverwriting.blogspot.ru/2012/10/connection-status-device-connected.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any developer documentation except some old c #1 (&lt;a href=&quot;http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/drivers/usb/serial/ch341.c?v=2.6.25.8&quot; rel=&quot;nofollow&quot;&gt;http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/drivers/usb/serial/ch341.c?v=2.6.25.8&lt;/a&gt;) and some linux driver #2 (&lt;a href=&quot;http://0xcf.com/?wpdmdl=124&quot; rel=&quot;nofollow&quot;&gt;http://0xcf.com/?wpdmdl=124&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="8327" LastActivityDate="2015-07-15T13:52:36.977" Title="CH340: right endpoint?" Tags="|arduino-uno|usb|uart|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13474" PostTypeId="1" AcceptedAnswerId="13483" CreationDate="2015-07-15T18:02:36.340" Score="1" ViewCount="303" Body="&lt;p&gt;I'm working with &lt;a href=&quot;https://punchthrough.com/bean/arduino-users-guide/&quot; rel=&quot;nofollow noreferrer&quot;&gt;lightblue bean&lt;/a&gt;. I have a device that writes data to an SD card on a long button press and switches what will be written (from a list of 5 items) on short button press. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output, printed both to the SD card and to serial looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12:38, 7/15/15, subway&#xA;12:55, 7/15/15, subway&#xA;12:38, 7/15/15, bus&#xA;12:55, 7/15/15, rail&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc. It's basically a time stamp then a vale from this list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* modes[]= {&quot;walking&quot;, &quot;subway&quot;, &quot;bus&quot;, &quot;railroad&quot;, &quot;other&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works perfectly. But the bean has very few pins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/aU3Q2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5 SCK  -- connected to SD card. &lt;/li&gt;&#xA;&lt;li&gt;4 MISO -- connected to SD card. &lt;/li&gt;&#xA;&lt;li&gt;3 MOSI -- connected to SD card. &lt;/li&gt;&#xA;&lt;li&gt;2 SS   -- connected to SD card. &lt;/li&gt;&#xA;&lt;li&gt;1      -- input button, takes long and short presses &lt;/li&gt;&#xA;&lt;li&gt;0      --  &lt;/li&gt;&#xA;&lt;li&gt;A1 SDA --- connected to real time clock for timestamp &lt;/li&gt;&#xA;&lt;li&gt;A0 SCL --- connected to RTC (real time clock) for timestamp&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have &lt;strong&gt;&lt;em&gt;one&lt;/em&gt;&lt;/strong&gt; free DIGITAL pin. I need to let the user know what they have selected. This could be done with 5 LEDs that light up next to the user's choice, or maybe displayed text? This is a portable item so a servo that points to the user's choice might be too unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done some research into shift registers. They all seem to need 3 digital pins min. If I could do it with 2 I could rework the button...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideas?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="8769" LastEditDate="2015-07-15T19:33:57.873" LastActivityDate="2019-02-22T19:58:02.783" Title="One free pin. Need to display output for the user?" Tags="|pins|sd-card|display|shift-register|rtc|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13475" PostTypeId="2" ParentId="13474" CreationDate="2015-07-15T18:31:30.320" Score="4" Body="&lt;p&gt;Seems you have I²C on the board you could possibly use an I²C LCD backpack, like from &lt;a href=&quot;http://www.adafruit.com/products/292&quot; rel=&quot;nofollow noreferrer&quot;&gt;breakouts&lt;/a&gt; if you already have an LCD, this means you can have the RTC and display on the I²C bus and probably more things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option seems you mentioned LEDs, you could still use the I²C bus and use an I/O expander and hook LEDs up to that and address them over the I²C. You can use a PCF8575(16 I/O), as there are &lt;a href=&quot;http://playground.arduino.cc/Code/I2CPortExpander8574&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino libraries&lt;/a&gt;. There are &lt;a href=&quot;https://www.sparkfun.com/products/8130&quot; rel=&quot;nofollow noreferrer&quot;&gt;breakouts&lt;/a&gt; for it. Or you could make your own from another AVR, like one from the ATTiny line, seems there is 5 LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A I²C bus example:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mkTCK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mkTCK.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://www.ermicro.com/blog/wp-content/uploads/2009/02/i2c_00.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;ermicro.com&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems you want to use the PWM, you can use a dot/bar driver IC, such as the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm3914.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;LM3914&lt;/a&gt; it takes an analog value and shows it as a point on the strip of LEDs, example below:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wKf0v.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IC can also work down to 3V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you will need to do is add a &lt;a href=&quot;https://en.wikipedia.org/wiki/Low-pass_filter&quot; rel=&quot;nofollow noreferrer&quot;&gt;low pass filter&lt;/a&gt; to convert the PWM to a smooth analog value. You will add this in place of the input circuitry(D1 &amp;amp; C1) there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/K3iut.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is any confusion on the LM3914, there are quite a few tutorials on google.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="27346" LastEditDate="2019-02-22T19:58:02.783" LastActivityDate="2019-02-22T19:58:02.783" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="13476" PostTypeId="1" CreationDate="2015-07-15T18:47:47.077" Score="3" ViewCount="42778" Body="&lt;p&gt;I would like to make this code using the Arduino Uno. I am using three on/off switches and based on the truth table would like to turn on one of 8 LEDs. When I use &lt;code&gt;digitalWrite()&lt;/code&gt;, I get an error code saying that there are too few arguments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int x = A3;    // select the input pin for the switch&#xA;int y = A4;&#xA;int z = A5;&#xA;&#xA;int ledPin1 = 2;      // select the pin for the LED&#xA;int ledPin2 = 3;&#xA;int ledPin3 = 4;&#xA;int ledPin4 = 7;&#xA;int ledPin5 = 8;&#xA;int ledPin6 = 9;&#xA;int ledPin7 = 12;&#xA;int ledPin8 = 13;&#xA;&#xA;void setup(){&#xA;&#xA;  // declare the ledPin as an OUTPUT:&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(ledPin3, OUTPUT);&#xA;  pinMode(ledPin4, OUTPUT);&#xA;  pinMode(ledPin5, OUTPUT);&#xA;  pinMode(ledPin6, OUTPUT);&#xA;  pinMode(ledPin7, OUTPUT);&#xA;  pinMode(ledPin8, OUTPUT);&#xA;&#xA;  pinMode(x, INPUT);&#xA;  pinMode(y, INPUT);&#xA;  pinMode(z, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if ( (x = LOW) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = LOW))              //condition 1&#xA;  {&#xA;    digitalWrite (ledPin1 = HIGH); &#xA;    digitalWrite (ledPin2 = LOW); &#xA;    digitalWrite (ledPin3 = LOW); &#xA;    digitalWrite (ledPin4 = LOW); &#xA;    digitalWrite (ledPin5 = LOW); &#xA;    digitalWrite (ledPin6 = LOW); &#xA;    digitalWrite (ledPin7 = LOW); &#xA;    digitalWrite (ledPin8 = LOW); &#xA;  }&#xA;&#xA;  if ( (x = LOW) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = HIGH))             //condition 2&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = HIGH; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = LOW; &#xA;  }&#xA;&#xA;  if ( (x = LOW) &amp;amp;&amp;amp; (y = HIGH) &amp;amp;&amp;amp; (z = LOW))             //condition 3&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = HIGH; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = LOW;&#xA;  }&#xA;&#xA;  if ( (x = LOW) &amp;amp;&amp;amp; (y = HIGH) &amp;amp;&amp;amp; (z = HIGH))              //condition 4&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = HIGH; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = LOW;&#xA;  }&#xA;&#xA;  if ( (x = HIGH) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = LOW))               //condition 5&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = HIGH; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = LOW;&#xA;  }&#xA;&#xA;  if ( (x = HIGH) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = HIGH))               //condition 6&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = HIGH; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = LOW;&#xA;  }&#xA;&#xA;  if ( (x = HIGH) &amp;amp;&amp;amp; (y = HIGH) &amp;amp;&amp;amp; (z = LOW))                //condition 7&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = HIGH; &#xA;    ledPin8 = LOW;&#xA;  }&#xA;&#xA;  if ( (x = HIGH) &amp;amp;&amp;amp; (y = HIGH) &amp;amp;&amp;amp; (z = HIGH))                //condition 8&#xA;  {&#xA;    ledPin1 = LOW; &#xA;    ledPin2 = LOW; &#xA;    ledPin3 = LOW; &#xA;    ledPin4 = LOW; &#xA;    ledPin5 = LOW; &#xA;    ledPin6 = LOW; &#xA;    ledPin7 = LOW; &#xA;    ledPin8 = HIGH;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/tabgY.png&quot; alt=&quot;Fritzing diagram&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="11236" LastEditorUserId="37523" LastEditDate="2019-11-28T18:44:01.777" LastActivityDate="2019-11-28T18:44:01.777" Title="Multiple if statement conditions" Tags="|arduino-uno|led|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13477" PostTypeId="2" ParentId="13476" CreationDate="2015-07-15T19:01:29.853" Score="4" Body="&lt;p&gt;&lt;code&gt;digitalWrite (ledPin1 = HIGH);&lt;/code&gt; should be &lt;code&gt;digitalWrite (ledPin1, HIGH);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS &lt;code&gt;if ( (x = LOW) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = LOW))&lt;/code&gt; should be &lt;code&gt;if ( (x == LOW) &amp;amp;&amp;amp; (y == LOW) &amp;amp;&amp;amp; (z == LOW))&lt;/code&gt;. &lt;code&gt;=&lt;/code&gt; is for assignment, &lt;code&gt;==&lt;/code&gt; is for comparison.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-15T19:01:29.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13479" PostTypeId="2" ParentId="13474" CreationDate="2015-07-15T19:42:24.180" Score="0" Body="&lt;p&gt;I've found a solution! &lt;a href=&quot;https://learn.sparkfun.com/tutorials/using-the-serial-7-segment-display/assembly&quot; rel=&quot;nofollow noreferrer&quot;&gt;7-segment display breakout board&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2qSpy.png&quot; alt=&quot;I&quot;&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works art 3.3v which is critical for a lightblue bean. I think a servo might be the most creative solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still convinced there must be some way to use PWM... &lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-07-15T19:42:24.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13481" PostTypeId="2" ParentId="13476" CreationDate="2015-07-15T20:43:08.300" Score="4" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;void loop() {&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; if ( (x = LOW) &amp;amp;&amp;amp; (y = LOW) &amp;amp;&amp;amp; (z = LOW))              //condition 1&#xA; {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Apart from the issue of needing &lt;code&gt;==&lt;/code&gt; instead of &lt;code&gt;=&lt;/code&gt; you are never &lt;em&gt;reading&lt;/em&gt; those pins. In fact you are comparing the pin &lt;em&gt;numbers&lt;/em&gt; (which will never change), not the data on those pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop() {&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  if ( (digitalRead (x) == LOW) &amp;amp;&amp;amp; &#xA;       (digitalRead (y) == LOW) &amp;amp;&amp;amp; &#xA;       (digitalRead (z) == LOW))              //condition 1&#xA;    {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and so on.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is wrong too, I'm surprised it compiled:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   digitalWrite (ledPin1 = HIGH); &#xA;   digitalWrite (ledPin2 = LOW); &#xA;   digitalWrite (ledPin3 = LOW); &#xA;   digitalWrite (ledPin4 = LOW); &#xA;   digitalWrite (ledPin5 = LOW); &#xA;   digitalWrite (ledPin6 = LOW); &#xA;   digitalWrite (ledPin7 = LOW); &#xA;   digitalWrite (ledPin8 = LOW); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  digitalWrite (ledPin1, HIGH); &#xA;  digitalWrite (ledPin2, LOW); &#xA;  digitalWrite (ledPin3, LOW); &#xA;  digitalWrite (ledPin4, LOW); &#xA;  digitalWrite (ledPin5, LOW); &#xA;  digitalWrite (ledPin6, LOW); &#xA;  digitalWrite (ledPin7, LOW); &#xA;  digitalWrite (ledPin8, LOW); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when i use digital write i get an error code saying that there are too few arguments.&#xA;  ...&#xA;   I just dont know why the simulation program is still not lighting the LED&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Oh I see, it did &lt;em&gt;not&lt;/em&gt; compile. No wonder the LEDs didn't turn on.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-15T20:48:27.917" LastActivityDate="2015-07-15T20:48:27.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13483" PostTypeId="2" ParentId="13474" CreationDate="2015-07-15T21:50:16.520" Score="2" Body="&lt;p&gt;The 7-segment display board is all very well, but that displays 4 digits. That isn't exactly 5 LEDs. In any case that board has a chip on it, if you are going to buy another chip you may as well get an Attiny and use that. Just have serial input (same as the 7-segment board did).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Attiny you have 8 pins, 3 of which will be reserved: Vcc, Gnd, Reset. That leaves you with 5 for the communications &lt;em&gt;and&lt;/em&gt; the 5 LEDs. So, use one pin for incoming serial, or two pins for SDA/SCL, and use the remaining 3 pins for the LEDs. You can can use &lt;a href=&quot;https://en.wikipedia.org/wiki/Charlieplexing&quot; rel=&quot;nofollow noreferrer&quot;&gt;Charliplexing&lt;/a&gt; to use 3 pins to light up to 6 LEDs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZJfsk.png&quot; alt=&quot;Charliplexing schematic&quot;&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For the fun of it, I made up an example using my Uno (it still only uses 3 pins to light 6 LEDs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/SYzzc.jpg&quot; alt=&quot;Charliplexing demo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 3 x 100 Ω resistors as in the schematic. One is completely hidden by the LEDs (leading from the middle yellow wire to the middle pins of the LEDs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte X1 = bit (2);   // D2 on Uno&#xA;const byte X2 = bit (3);   // D3 on Uno&#xA;const byte X3 = bit (4);   // D4 on Uno&#xA;&#xA;const byte patterns [7] [2] = {&#xA;// PORT DDR&#xA;  { 0,   0, }, // all off&#xA;  { X1, X1 | X2 }, // LED1: X1 on,  X2 off, X3 HiZ&#xA;  { X2, X1 | X2 }, // LED2: X1 off, X2 on,  X3 HiZ&#xA;  { X2, X2 | X3 }, // LED3: X2 on,  X3 off, X1 HiZ&#xA;  { X3, X2 | X3 }, // LED4: X2 off, X3 on,  X1 HiZ&#xA;  { X1, X1 | X3 }, // LED5: X1 on,  X3 off, X2 HiZ&#xA;  { X3, X1 | X3 }, // LED6: X3 on,  X1 off, X2 HiZ&#xA;};&#xA;&#xA;void setup ()&#xA;  {&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  for (int i = 0; i &amp;lt; 7; i++)&#xA;    {&#xA;    DDRD = patterns [i] [1];&#xA;    PORTD = patterns [i] [0];&#xA;    delay (500);&#xA;    }  // end of for loop&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code displays each of the 6 LEDs (plus all off) in a cycle. For each one it configures the DDR (data direction register) plus the PORT (output register) appropriately to light the desired LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works perfectly, except that you may need to work out which LED is which by experimentation.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-16T06:43:08.597" LastActivityDate="2015-07-16T06:43:08.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13484" PostTypeId="2" ParentId="13476" CreationDate="2015-07-15T22:36:20.973" Score="2" Body="&lt;p&gt;Here's a little tip for you (it has nothing to do with your problem, it's just a good programming method).  This will massively reduce the size of your program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have three boolean state variables, and you are comparing the state of all combinations - that's 8 combinations.  If you take each boolean value as 1 bit of a value between 0 and 7 - that is values (as binary) 000, 001, 010, 011, 100, 101, 110, and 111 - then you can use much simpler methods for controlling your LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, this (untested) code will turn three digital reads into a single number between 0 and 7:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t value = digitalRead(x) | (digitalRead(y) &amp;lt;&amp;lt; 1) | (digitalRead(z) &amp;lt;&amp;lt; 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is the least significant bit, and &lt;code&gt;z&lt;/code&gt; is the most significant.  So &lt;code&gt;value&lt;/code&gt; will now be a value between 0 and 7 representing the state of those three pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can use that &lt;code&gt;value&lt;/code&gt; variable to decide which pin to turn on.  Here's another trick:  Store you LED pins as an array.  That means, instead of having &lt;code&gt;ledPin1&lt;/code&gt;, &lt;code&gt;ledPin2&lt;/code&gt;, etc, you just have a list of pin numbers known as &lt;code&gt;ledPin[x]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can use a &lt;code&gt;for&lt;/code&gt; loop to iterate though that list and turn on the LED you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (uint8_t i = 0; i &amp;lt; 8; i++) {&#xA;    if (i == value) {&#xA;        digitalWrite(ledPin[i], HIGH);&#xA;    } else {&#xA;        digitalWrite(ledPin[i], LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact, that can be further compressed, since HIGH and LOW are basically truth values (HIGH is 1, or true, and LOW is 0, or false):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (uint8_t i = 0; i &amp;lt; 8; i++) {&#xA;    digitalWrite(ledPin[i], i == value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your whole program could look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t x = A3;    // select the input pin for the switch&#xA;const uint8_t y = A4;&#xA;const uint8_t z = A5;&#xA;&#xA;const uint8_t ledPin[8] = { 2, 3, 4, 7, 8, 9, 12, 13 };&#xA;&#xA;void setup() {&#xA;    for (uint8_t i = 0; i &amp;lt; 8; i++) {&#xA;        pinMode(ledPin[i], OUTPUT);&#xA;    }&#xA;    pinMode(x, INPUT);&#xA;    pinMode(y, INPUT);&#xA;    pinMode(z, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    uint8_t value = digitalRead(x) | (digitalRead(y) &amp;lt;&amp;lt; 1) | (digitalRead(z) &amp;lt;&amp;lt; 2);&#xA;    for (uint8_t i = 0; i &amp;lt; 8; i++) {&#xA;        digitalWrite(ledPin[i], i == value);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Saves a huge amount of typing and also ends up using considerably less Flash memory.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-15T22:36:20.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13485" PostTypeId="1" CreationDate="2015-07-16T00:21:40.843" Score="-2" ViewCount="1862" Body="&lt;p&gt;I would like to use CD4053 for multiplexing in arduino but the problem is that I don't understand how CD4053 works, is it the same as CD4051, can someone help me, provide example code and circuit??&lt;/p&gt;&#xA;" OwnerUserId="10809" LastActivityDate="2022-11-27T15:01:05.123" Title="Using CD4053 for arduino" Tags="|arduino-uno|programming|pins|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13486" PostTypeId="1" CreationDate="2015-07-16T01:15:29.887" Score="-1" ViewCount="752" Body=" &#xA;&#xA;&lt;p&gt;I have a group project where we are trying to make a user enter a password that we have pre-selected for them. They enter the password using tactile buttons, and they have 5 tries to enter the password correctly. If they enter the password incorrectly, one of 5 LED's will light up to indicate that they have entered it wrong. If they get it right, one LED will light up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are using timers to time out the attempt if the users take too long to enter the entire password, or if they take too long between pressing buttons. Also, if they use all 5 tries, we are trying to make the LED's that were on turn off one by one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now the code doesn't get past Serial.print(&quot;done&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is our code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int input_pin_blue = 5;&#xA;int input_pin_yellow = 6;&#xA;volatile int state_button_red = LOW;&#xA;volatile int state_button_blue = LOW;&#xA;volatile int state_button_yellow = LOW;&#xA;int num_wrong = 0;&#xA;double time_between_buttons = 0;&#xA;double time_since_first_button = 0;&#xA;const int max_time_between_buttons = 10000;&#xA;const int max_time_since_first_button = 30000;&#xA;int reset = 4;&#xA;void setup() {&#xA;    pinMode(input_pin_blue, INPUT);&#xA;    pinMode(input_pin_yellow, INPUT);&#xA;    pinMode(4, INPUT);&#xA;    pinMode(8, OUTPUT);&#xA;    pinMode(9, OUTPUT);&#xA;    pinMode(10, OUTPUT);&#xA;    pinMode(11, OUTPUT);&#xA;    pinMode(12, OUTPUT);&#xA;    pinMode(13, OUTPUT);&#xA;    attachInterrupt(0, handler_red, CHANGE);&#xA;    attachInterrupt(1, handler_blue_yellow, CHANGE);&#xA;    Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;    Serial.print(&quot;bhi&quot;); //wait for button press&#xA;&#xA;    for (num_wrong = 0; num_wrong &amp;lt; 5; num_wrong++) {&#xA;        Serial.print(&quot;blah&quot;); //wait for button press&#xA;&#xA;        while (state_button_red == LOW &amp;amp;&amp;amp; state_button_blue == LOW &amp;amp;&amp;amp; state_button_yellow == LOW) {&#xA;            Serial.print(&quot;waiting&quot;); //wait for button press&#xA;        }&#xA;&#xA;        Serial.print(&quot;DOne&quot;);&#xA;&#xA;        if (state_button_red == LOW) {                  //check if first button pressed is incorrect&#xA;            digitalWrite(num_wrong + 8, HIGH);&#xA;        } else if (state_button_red == HIGH) {&#xA;            time_between_buttons = millis();&#xA;            time_since_first_button = millis();&#xA;&#xA;            while (state_button_red == LOW &amp;amp;&amp;amp; state_button_blue == LOW &amp;amp;&amp;amp; state_button_yellow == LOW&#xA;                    &amp;amp;&amp;amp; time_between_buttons &amp;lt; max_time_between_buttons &amp;amp;&amp;amp; time_since_first_button &amp;lt; max_time_since_first_button) {&#xA;                //wait for button press&#xA;            }&#xA;&#xA;            if (state_button_yellow == LOW || time_between_buttons &amp;lt; max_time_between_buttons || time_since_first_button &amp;lt; max_time_since_first_button)&#xA;//check if second button pressed is incorrect or time has run out&#xA;            {&#xA;                digitalWrite(num_wrong + 8, HIGH);&#xA;            } else if (state_button_yellow == HIGH) {&#xA;                time_between_buttons = millis();&#xA;&#xA;                while (state_button_red == LOW &amp;amp;&amp;amp; state_button_blue == LOW &amp;amp;&amp;amp; state_button_yellow == LOW&#xA;                        &amp;amp;&amp;amp; time_between_buttons &amp;lt; max_time_between_buttons &amp;amp;&amp;amp; time_since_first_button &amp;lt; max_time_since_first_button) {&#xA;                    //wait for button press&#xA;                }&#xA;&#xA;                if (state_button_blue == LOW || time_between_buttons &amp;lt; max_time_between_buttons || time_since_first_button &amp;lt; max_time_since_first_button)&#xA;//check if third button pressed is incorrect or time has run out&#xA;                {&#xA;                    digitalWrite(num_wrong + 8, HIGH);&#xA;                } else if (state_button_blue == HIGH) {&#xA;                    time_between_buttons = millis();&#xA;&#xA;                    while (state_button_red == LOW &amp;amp;&amp;amp; state_button_blue == LOW &amp;amp;&amp;amp; state_button_yellow == LOW&#xA;                            &amp;amp;&amp;amp; time_between_buttons &amp;lt; max_time_between_buttons &amp;amp;&amp;amp; time_since_first_button &amp;lt; max_time_since_first_button) {&#xA;                        //wait for button press&#xA;                    }&#xA;&#xA;                    if (state_button_yellow == LOW || time_between_buttons &amp;lt; max_time_between_buttons || time_since_first_button &amp;lt; max_time_since_first_button)&#xA;//check if fourth(last) button pressed is incorrect or time has run out&#xA;                    {&#xA;                        digitalWrite(num_wrong + 8, HIGH);&#xA;                    } else if (state_button_yellow == HIGH) {&#xA;                        digitalWrite(13, HIGH);&#xA;                        num_wrong = 10;&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    if (num_wrong == 10) {&#xA;        while (digitalRead(reset) == LOW) {&#xA;            //wait for reset&#xA;        }&#xA;    } else if (num_wrong == 5) {&#xA;        while (digitalRead(reset) == LOW) {&#xA;            digitalWrite(8, LOW);&#xA;            delay(100);&#xA;            digitalWrite(8, HIGH);&#xA;            digitalWrite(9, LOW);&#xA;            delay(100);&#xA;            digitalWrite(9, HIGH);&#xA;            digitalWrite(10, LOW);&#xA;            delay(100);&#xA;            digitalWrite(10, HIGH);&#xA;            digitalWrite(11, LOW);&#xA;            delay(100);&#xA;            digitalWrite(11, HIGH);&#xA;            digitalWrite(12, LOW);&#xA;            delay(100);&#xA;            digitalWrite(12, HIGH);&#xA;        }&#xA;    }&#xA;&#xA;    if (digitalRead(reset) == HIGH) {&#xA;        digitalWrite(13, LOW);&#xA;        delay(100);&#xA;        digitalWrite(12, LOW);&#xA;        delay(100);&#xA;        digitalWrite(11, LOW);&#xA;        delay(100);&#xA;        digitalWrite(10, LOW);&#xA;        delay(100);&#xA;        digitalWrite(9, LOW);&#xA;        delay(100);&#xA;        digitalWrite(8, LOW);&#xA;    }&#xA;}&#xA;// interrupt handler function&#xA;void handler_red() {&#xA;    state_button_red = !state_button_red;&#xA;}&#xA;void handler_blue_yellow() {&#xA;    if (digitalRead(input_pin_blue) == HIGH) {&#xA;        state_button_blue = !state_button_blue;&#xA;    }&#xA;&#xA;    if (digitalRead(input_pin_yellow) == HIGH) {&#xA;        state_button_yellow = !state_button_yellow;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11242" LastEditorUserId="4143" LastEditDate="2015-07-16T09:18:17.770" LastActivityDate="2016-02-12T05:10:49.220" Title="Password code using interrupts and timers on Arduino Uno" Tags="|arduino-uno|interrupt|timers|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13487" PostTypeId="2" ParentId="13462" CreationDate="2015-07-16T01:33:04.457" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;MQTT by definition is a TCP/IP protocol, so if you don't have a TCP/IP stack, then it is a no go.&lt;/li&gt;&#xA;&lt;li&gt;A common pattern/infrastructure in the IoT is to have your &quot;things&quot; connect to a hub of some kind (via BLE, XBee, or ... etc.) and then the hub will connect to the network and post the data. Another option would be to get a cellular device that provides a data connection (i.e. 2G/3G) and therefore a TCP/IP stack. It looks like the SIM900 only supports calls and texts, and as of this moment I am not aware of such a device that has libraries for Arduino.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-16T01:33:04.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13488" PostTypeId="1" CreationDate="2015-07-16T02:17:13.880" Score="2" ViewCount="2219" Body="&lt;p&gt;I am designing a turn signal bicycle blinker using two pushbuttons as input, one for each side, with a corresponding light for each button.&#xA;The idea is this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pressing one side makes same side start blinking;&lt;/li&gt;&#xA;&lt;li&gt;Pressing same side again to turn it off;&lt;/li&gt;&#xA;&lt;li&gt;Pressing other side turns off this side and turns other side on;&lt;/li&gt;&#xA;&lt;li&gt;(now the tricky part!) if &lt;strong&gt;both&lt;/strong&gt; buttons are pressed (or more precisely, if one button is pressed before the other is released), then - and only then - I start blinking both sides (&quot;warning signal&quot; feature).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As I see it, the problem is that I need to wait until I release a single button (that would be one complete click) to turn a single side on, because if I press the second while the first remains pressed, that would be another event/gesture (&quot;both_click&quot;, for lack of a better name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another design option would be to turn a single light on immediately on press, and if I press the second before release the first, then in would &lt;em&gt;also&lt;/em&gt; turn the other light (thus comprising the &quot;warning&quot;, both-lights-blinking mode). While that sounds feasible, there is all the debouncing logic in the Button (&quot;Botao&quot;) class, and I am afraid I painted myself into a corner with the specific object-oriented design choices I've made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: a third design option would be to add a &lt;code&gt;run&lt;/code&gt; method on each button and, instead of only running the tested &quot;pseudo-event&quot; method, save the current state and event in variables, testing those variables in &lt;code&gt;loop()&lt;/code&gt; (property &lt;code&gt;button.wasPressed&lt;/code&gt; instead of method &lt;code&gt;button.wasPressed()&lt;/code&gt;, for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm posting my current code (relevant parts only). Note there is a comment in the loop where I think I should detect double click.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main .ino file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;PiscaPisca.cpp&quot;&#xA;#include &quot;Botao.cpp&quot;&#xA;&#xA;PiscaPisca pisca;&#xA;&#xA;Botao botao1;&#xA;Botao botao4;&#xA;&#xA;void setup() {&#xA;&#xA;  pisca.configure(LEFT, RIGHT, BUZZER);&#xA;&#xA;  botao1.configure(BUTTON1);&#xA;  botao4.configure(BUTTON4);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // HOW SHOULD I DETECT BOTH WERE PRESSED??&#xA;  // if (bothPressed()) { pisca.toggleWarning(); }    &#xA;&#xA;  if (botao1.wasPressed()) { pisca.toggleLeft();  }&#xA;  if (botao4.wasPressed()) { pisca.toggleRight(); }&#xA;&#xA;  pisca.run();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Botao.cpp (this is a button class with debounce)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class Botao&#xA;{&#xA;    int _pino;&#xA;&#xA;    const int DEBOUNCE_DELAY = 30;&#xA;&#xA;    int buttonState;&#xA;    int lastState = HIGH;&#xA;&#xA;    int lastDebounceTime;&#xA;&#xA;    public : void configure(int pino)&#xA;    {&#xA;        _pino = pino;&#xA;        pinMode(pino, INPUT_PULLUP);&#xA;    }&#xA;&#xA;    public : boolean wasPressed()&#xA;    {        &#xA;        return debounce(LOW);&#xA;    }&#xA;&#xA;    public : boolean wasReleased()&#xA;    {&#xA;        return debounce(HIGH);&#xA;    }&#xA;&#xA;    public : boolean debounce(int state)&#xA;    {        &#xA;        boolean gotEvent = false;&#xA;&#xA;        int reading = digitalRead(_pino);&#xA;&#xA;        if (reading != lastState) {&#xA;            lastDebounceTime = millis();&#xA;        }&#xA;&#xA;        if ((millis() - lastDebounceTime) &amp;gt; DEBOUNCE_DELAY) {&#xA;            if (reading != buttonState) {&#xA;                buttonState = reading;&#xA;&#xA;                if (buttonState == state) {&#xA;                    gotEvent = true;&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        lastState = reading;&#xA;&#xA;        return gotEvent;&#xA;    }    &#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PiscaPisca.cpp (the state-machine itself)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;PwmPin.cpp&quot;&#xA;#include &quot;Beeper.cpp&quot;&#xA;&#xA;typedef enum {&#xA;    NONE        = 0,&#xA;    RIGHT_LIGHT = 1,&#xA;    LEFT_LIGHT  = 2,&#xA;    BOTH        = 3&#xA;};&#xA;&#xA;class PiscaPisca&#xA;{&#xA;    PwmPin _left;&#xA;    PwmPin _right;&#xA;&#xA;    Beeper _beeper;&#xA;&#xA;    long _timeReference = 0;&#xA;&#xA;    const int PERIOD = 350;&#xA;&#xA;    boolean&#xA;        _running = false,&#xA;        _lightState = false;&#xA;&#xA;    int _sides_to_turn = NONE;  &#xA;&#xA;&#xA;    public : void configure(int leftPin, int rightPin, int buzzerPin)&#xA;    {&#xA;        _left.configure(leftPin);&#xA;        _right.configure(rightPin);&#xA;        _beeper.configure(buzzerPin);&#xA;    }&#xA;&#xA;    public : void run() &#xA;    {        &#xA;        evaluateBlink();&#xA;    }&#xA;&#xA;&#xA;&#xA;    public : void toggleLeft()&#xA;    {&#xA;        checkRestart(LEFT_LIGHT);&#xA;    }&#xA;&#xA;    public : void toggleRight()&#xA;    {&#xA;        checkRestart(RIGHT_LIGHT);&#xA;    }&#xA;&#xA;    void checkRestart(int lightSide)&#xA;    {&#xA;        _timeReference = 0;  &#xA;&#xA;        // some clever bit-twiddling can never hurt too much:&#xA;        _sides_to_turn = lightSide &amp;amp; ~_sides_to_turn;  &#xA;&#xA;        Serial.println(lightSide);&#xA;        Serial.println(_sides_to_turn);     &#xA;&#xA;        if (_sides_to_turn &amp;gt; 0)&#xA;        {&#xA;            _running = true;&#xA;        }&#xA;        else&#xA;        {&#xA;            lightsOff();&#xA;            _running = false;&#xA;            _lightState = false;      &#xA;        }&#xA;    }&#xA;&#xA;&#xA;&#xA;    void evaluateBlink() &#xA;    {&#xA;        if (!_running)&#xA;        {&#xA;            return;&#xA;        }&#xA;        else&#xA;        {&#xA;            long currentMillis = millis();&#xA;            if (currentMillis - _timeReference &amp;gt; PERIOD) {&#xA;                _timeReference = currentMillis;&#xA;                _lightState = !_lightState;&#xA;                performBlink();&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    void performBlink()&#xA;    {&#xA;        if (_lightState)&#xA;        {&#xA;            _beeper.beepIn();&#xA;            lightsOn();&#xA;        }&#xA;        else&#xA;        {&#xA;            _beeper.beepOut();&#xA;            lightsOff();&#xA;        }        &#xA;    }&#xA;&#xA;    void lightsOn()&#xA;    {&#xA;        if (isLightSet(LEFT_LIGHT))&#xA;        {&#xA;            _left.on();&#xA;        }&#xA;        if (isLightSet(RIGHT_LIGHT))&#xA;        {&#xA;            _right.on();&#xA;        }        &#xA;    }&#xA;&#xA;    boolean isLightSet(int lightSide)&#xA;    {&#xA;        return (_sides_to_turn &amp;amp; lightSide) == lightSide;&#xA;    }&#xA;&#xA;    void lightsOff()&#xA;    {&#xA;        _left.off();&#xA;        _right.off();&#xA;    }&#xA;&#xA;&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="8044" LastEditDate="2015-07-16T03:38:37.040" LastActivityDate="2024-03-14T07:38:19.313" Title="How to detect if more than one button was pressed" Tags="|programming|c++|library|button|algorithm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13489" PostTypeId="2" ParentId="13488" CreationDate="2015-07-16T05:56:14.513" Score="2" Body="&#xA;&#xA;&lt;p&gt;Interesting question, and tricky to get perfect. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a switch manager class a while back. It's just a .h file which you can put in your libraries folder (or add to your sketch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SwitchManager.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class SwitchManager&#xA;  {&#xA;  enum { debounceTime = 10, noSwitch = -1 };&#xA;  typedef void (*handlerFunction) (const byte newState, &#xA;                                   const unsigned long interval, &#xA;                                   const byte whichSwitch);&#xA;&#xA;  int pinNumber_;&#xA;  handlerFunction f_;&#xA;  byte oldSwitchState_;&#xA;  unsigned long switchStateChangeTime_;  // when the switch last changed state&#xA;  unsigned long lastLowTime_;&#xA;  unsigned long lastHighTime_;&#xA;&#xA;  public:&#xA;&#xA;     // constructor&#xA;     SwitchManager () &#xA;       {&#xA;       pinNumber_ = noSwitch;&#xA;       f_ = NULL;&#xA;       oldSwitchState_  = HIGH;&#xA;       switchStateChangeTime_ = 0;&#xA;       lastLowTime_  = 0;&#xA;       lastHighTime_ = 0;&#xA;       }  // end of constructor&#xA;&#xA;     void begin (const int pinNumber, handlerFunction f)&#xA;       {&#xA;       pinNumber_ = pinNumber;&#xA;       f_ = f;&#xA;       if (pinNumber_ != noSwitch)&#xA;         pinMode (pinNumber_, INPUT_PULLUP);&#xA;       }  // end of begin()&#xA;&#xA;     void check ()&#xA;       {&#xA;       // we need a valid pin number and a valid function to call&#xA;       if (pinNumber_ == noSwitch || f_ == NULL)&#xA;         return;&#xA;&#xA;        // see if switch is open or closed&#xA;        byte switchState = digitalRead (pinNumber_);&#xA;&#xA;        // has it changed since last time?&#xA;        if (switchState != oldSwitchState_)&#xA;          {&#xA;          // debounce&#xA;          if (millis () - switchStateChangeTime_ &amp;gt;= debounceTime)&#xA;             {&#xA;             switchStateChangeTime_ = millis ();  // when we closed the switch &#xA;             oldSwitchState_ =  switchState;  // remember for next time &#xA;             if (switchState == LOW)&#xA;               {&#xA;               lastLowTime_ = switchStateChangeTime_;&#xA;               f_ (LOW, lastLowTime_ -  lastHighTime_, pinNumber_);&#xA;               }&#xA;             else&#xA;               {&#xA;               lastHighTime_ = switchStateChangeTime_;&#xA;               f_ (HIGH, lastHighTime_ - lastLowTime_, pinNumber_);&#xA;               }&#xA;&#xA;             }  // end if debounce time up&#xA;          }  // end of state change&#xA;       }  // end of check()&#xA;&#xA;     unsigned long getLastStateChangeTime () const { return switchStateChangeTime_; }&#xA;     unsigned long getLastStateLowTime ()    const { return lastLowTime_; }&#xA;     unsigned long getLastStateHighTime ()   const { return lastHighTime_; }&#xA;&#xA;  };  // class SwitchManager&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More details &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put that into a folder called &lt;code&gt;SwitchManager&lt;/code&gt;, put that into your sketch folder -&gt; &lt;code&gt;libraries&lt;/code&gt; folder and restart the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That basically handles:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;debouncing&lt;/li&gt;&#xA;&lt;li&gt;detecting state changes (eg. now on, was off)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using that we can now write a sketch that does the indicators:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SwitchManager.h&amp;gt;&#xA;&#xA;typedef enum {&#xA;    NONE,&#xA;    LH_DOWN,&#xA;    RH_DOWN,&#xA;    LH_LIGHT_ON,&#xA;    RH_LIGHT_ON,&#xA;    BOTH&#xA;};&#xA;&#xA;const unsigned long BLINK_INTERVAL = 500; // ms&#xA;&#xA;// pin assignments&#xA;const byte LH_SWITCH_PIN = 2;&#xA;const byte RH_SWITCH_PIN = 3;&#xA;const byte LH_LIGHT = A4;&#xA;const byte RH_LIGHT = A5;&#xA;&#xA;SwitchManager LHswitch; &#xA;SwitchManager RHswitch; &#xA;&#xA;byte state = NONE;&#xA;&#xA;void handleLHPress (const byte newState, const unsigned long interval, const byte whichPin)&#xA;  {&#xA;  // switch down?&#xA;  if (newState == LOW)&#xA;     {&#xA;     switch (state)&#xA;       {&#xA;       // if other switch down, switch to warning mode&#xA;       case RH_DOWN:&#xA;         state = BOTH;&#xA;         break;&#xA;&#xA;       // if already on or warning signal, turn all off&#xA;       case LH_LIGHT_ON:&#xA;       case BOTH:&#xA;         state = NONE;&#xA;         break;&#xA;&#xA;       // otherwise switch is now down, but not yet released&#xA;       default:&#xA;         state = LH_DOWN;&#xA;         break;&#xA;       }  // end of switch&#xA;     return;&#xA;     }  // end of LH switch down&#xA;&#xA;  // switch must be up&#xA;&#xA;  if (state == LH_DOWN)  // if down, switch to down-and-released mode&#xA;    state = LH_LIGHT_ON;  &#xA;  }  // end of handleLHPress&#xA;&#xA;void handleRHPress (const byte newState, const unsigned long interval, const byte whichPin)&#xA;  {&#xA;  // switch down?&#xA;  if (newState == LOW)&#xA;     {&#xA;     switch (state)&#xA;       {&#xA;       // if other switch down, switch to warning mode&#xA;       case LH_DOWN:&#xA;         state = BOTH;&#xA;         break;&#xA;&#xA;       // if already on or warning signal, turn all off&#xA;       case RH_LIGHT_ON:&#xA;       case BOTH:&#xA;         state = NONE;&#xA;         break;&#xA;&#xA;       // otherwise switch is now down, but not yet released&#xA;       default:&#xA;         state = RH_DOWN;&#xA;         break;&#xA;       }  // end of switch&#xA;     return;&#xA;     }  // end of RH switch down&#xA;&#xA;  // switch must be up&#xA;&#xA;  if (state == RH_DOWN)  // if down, switch to down-and-released mode&#xA;    state = RH_LIGHT_ON;  &#xA;  }  // end of handleRHPress&#xA;&#xA;void setup ()&#xA;  {&#xA;  LHswitch.begin (LH_SWITCH_PIN, handleLHPress);&#xA;  RHswitch.begin (RH_SWITCH_PIN, handleRHPress);&#xA;  pinMode (LH_LIGHT, OUTPUT);&#xA;  pinMode (RH_LIGHT, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;unsigned long lastBlink;&#xA;bool onCycle;&#xA;&#xA;void blinkLights ()&#xA;  {&#xA;  lastBlink = millis ();&#xA;  onCycle = !onCycle;&#xA;&#xA;  // default to off&#xA;  digitalWrite (LH_LIGHT, LOW);&#xA;  digitalWrite (RH_LIGHT, LOW);&#xA;&#xA;  // every second time, turn them all off&#xA;  if (!onCycle)&#xA;    return;&#xA;&#xA;  // blink light&#xA;  switch (state)&#xA;    {&#xA;    case NONE:&#xA;      break;&#xA;&#xA;    case LH_DOWN:&#xA;    case LH_LIGHT_ON:&#xA;      digitalWrite (LH_LIGHT, HIGH);&#xA;      break;&#xA;&#xA;    case RH_DOWN:&#xA;    case RH_LIGHT_ON:&#xA;      digitalWrite (RH_LIGHT, HIGH);&#xA;      break;&#xA;&#xA;    case BOTH:&#xA;      digitalWrite (LH_LIGHT, HIGH);&#xA;      digitalWrite (RH_LIGHT, HIGH);&#xA;      break;&#xA;&#xA;    }  // end of switch on state&#xA;&#xA;  }  // end of blinkLights&#xA;&#xA;&#xA;void loop ()&#xA;  {&#xA;  LHswitch.check ();  // check for presses&#xA;  RHswitch.check ();  // check for presses&#xA;&#xA;  if (millis () - lastBlink &amp;gt;= BLINK_INTERVAL)&#xA;    blinkLights ();&#xA;&#xA;  // other stuff&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The state machine has a number of states:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;NONE  -&gt; all lights off&lt;/li&gt;&#xA;&lt;li&gt;LH_DOWN  -&gt; LH switch depressed, not yet released&lt;/li&gt;&#xA;&lt;li&gt;RH_DOWN  -&gt; RH switch depressed, not yet released&lt;/li&gt;&#xA;&lt;li&gt;LH_LIGHT_ON  -&gt; LH switch depressed, and released&lt;/li&gt;&#xA;&lt;li&gt;RH_LIGHT_ON  -&gt; RH switch depressed, and released&lt;/li&gt;&#xA;&lt;li&gt;BOTH  -&gt; Warning lights mode (flash both lights)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If we get a LH down while the RH is still pressed, or vice-versa, we switch to warning mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a button release we switch from &quot;switch down&quot; to &quot;switch released&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A second press, while either or both lights are on cancels them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that my switches were wired to ground with the internal pull-up, so they are LOW when pressed and HIGH when not pressed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-16T08:05:45.197" LastActivityDate="2015-07-16T08:05:45.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13491" PostTypeId="2" ParentId="9499" CreationDate="2015-07-16T07:15:23.633" Score="0" Body="&lt;p&gt;I have a lot of detail about here: &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Let's call one cycle the two blinks and the following 8 seconds of rest. I am confused about how long I should factor in for the digitalWrite(led, HIGH) and the corresponding 'low' call, because the rest of the time, the circuit is using JeeLib.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To answer this specific question, we can work out a &quot;power budget&quot; by taking the large consumption time (eg. the LED being on) and working out how much that is, as a fraction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in your case you have the LED on for 500 ms every 8 seconds. That is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8 / 0.5 = 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, 1/16&lt;sup&gt;th&lt;/sup&gt; of the time. Or, putting it another way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.5 / 8 = 0.0625&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, let's say the LEDs use 20 mA. The &lt;em&gt;average&lt;/em&gt; consumption then is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.020 * 0.0625 = 0.00125 A (1.25 mA)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And let's assume that while asleep it uses 1 mA. So the total consumption on average is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 + 1.25 = 2.25 mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you have a 2000 mAh battery, you would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 2000 / 2.25 = 888.88  hours&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However as others have pointed out, this is pretty meaningless if you use a development board. The on-board LED, the voltage regulator, the USB chip etc. will use much more power than you save by going to sleep. You have to move to a low-power or custom design, which minimizes these extra effects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With careful design you should be able to get the sleep usage down to around 6 µA with the watchdog timer to wake you up.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-16T07:15:23.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13492" PostTypeId="1" CreationDate="2015-07-16T09:07:49.963" Score="2" ViewCount="185" Body="&lt;p&gt;I have an Arduino Mini Pro 3.3 V powered from a coin cell(3.6 V, CR2450) and connected to Bluetooth Mate Gold. I have checked the connections and they are fine. I can also connect to the bluetooth from while trying to upload the file and also from Android bluetooth terminal.I am not sure if it could be bootloader issue as I have checked 2 Arduino Mini Pros that give the same problem running the sample sketch on the bluetooth hookup guide.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino: 1.6.5 (Mac OS X)&lt;/li&gt;&#xA;&lt;li&gt;Board: &quot;Arduino Pro or Pro Mini, ATmega328 (3.3V, 8 MHz)&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The error is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 2,412 bytes (7%) of program storage space. Maximum is 30,720 bytes.&#xA;Global variables use 210 bytes (10%) of dynamic memory, leaving 1,838 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I burned the bootloader again but no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the same with UNO. However with UNO, when I press the reboot button before the program uploads is works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone point me out to the solution to this? Thanks&lt;/p&gt;&#xA;" OwnerUserId="11196" LastEditorUserId="4143" LastEditDate="2015-07-16T09:14:37.447" LastActivityDate="2015-07-16T09:14:37.447" Title="Arduino Mini Pro 3.3 V Issue with Bluetooth Mate" Tags="|arduino-uno|bluetooth|arduino-pro-mini|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13493" PostTypeId="1" AcceptedAnswerId="13506" CreationDate="2015-07-16T09:53:48.410" Score="2" ViewCount="6615" Body="&lt;p&gt;I have the following digital potentiometer: &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS1803.pdf&quot; rel=&quot;nofollow&quot;&gt;DS1803-100&lt;/a&gt; which, according to the datasheet, can be controlled using a two-wire serial interface. I have managed to get it working using Wire, however I can't seem to get it working using only digitalWrite (&lt;a href=&quot;http://pastebin.com/MknvWvjt&quot; rel=&quot;nofollow&quot;&gt;link to code&lt;/a&gt;). Can somebody tell me why? For reference, &lt;strong&gt;0x50&lt;/strong&gt; is the &lt;em&gt;address + r/!w bit&lt;/em&gt;, &lt;strong&gt;0xA9&lt;/strong&gt; is the &lt;em&gt;command (write to pot 0 in my case)&lt;/em&gt; and the next &lt;strong&gt;0xA9&lt;/strong&gt; is the &lt;em&gt;value to write&lt;/em&gt;. I know there's something wrong with the code, however I cannot figure out what. Thank you in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int PIN_SCK = 12;&#xA;int PIN_SDA = 11;&#xA;&#xA;const int delayvalue = 10;&#xA;&#xA;void setup(){&#xA;    digitalWrite(PIN_SCK, 1); // I can first declare the state&#xA;    digitalWrite(PIN_SDA, 1);&#xA;    pinMode(PIN_SCK, OUTPUT); // then turn them on&#xA;    pinMode(PIN_SDA, OUTPUT);&#xA;&#xA;    delay(1000);&#xA;&#xA;    digitalWrite(PIN_SDA, 0); // start bit&#xA;&#xA;    shift_out(PIN_SDA, PIN_SCK, 0x50);&#xA;    shift_out(PIN_SDA, PIN_SCK, 0xA9);&#xA;    shift_out(PIN_SDA, PIN_SCK, 0xA9);&#xA;&#xA;    digitalWrite(PIN_SDA, 1); // stop bit&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;// uint8_t is the same as 8 bits aka one byte&#xA;void shift_out(uint8_t datapin, uint8_t clockpin, uint8_t val){&#xA;    uint8_t i;&#xA;&#xA;    for (i = 0; i &amp;lt; 8; i++)  {&#xA;        digitalWrite(datapin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; (7 - i))));&#xA;        delay(1);&#xA;        digitalWrite(clockpin, 0);&#xA;        delay(delayvalue);&#xA;        digitalWrite(clockpin, 1);&#xA;        delay(delayvalue);&#xA;    }&#xA;&#xA;    digitalWrite(datapin, 0); // to enable stop bit&#xA;    delay(100); // wait fro aknowledgement&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4566" LastEditorUserId="4566" LastEditDate="2015-07-16T10:25:38.833" LastActivityDate="2022-01-13T08:25:50.963" Title="How do you send data via I2C without the wire library?" Tags="|arduino-uno|i2c|digital-analog-conversion|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13494" PostTypeId="2" ParentId="13493" CreationDate="2015-07-16T10:33:04.217" Score="1" Body="&lt;p&gt;I&lt;sup&gt;2&lt;/sup&gt;C is a lot more complex than just shifting bytes out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C - Two-Wire Peripheral Interface - for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code does not seem to take any of that into account.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do you not want to use the Wire library? The hardware on the chip (what chip do you have?) supports it. Why ignore that and try to do it yourself?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-16T10:33:04.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13495" PostTypeId="2" ParentId="13402" CreationDate="2015-07-16T10:59:46.857" Score="0" Body="&lt;p&gt;does the built-in arduino LED light up?? If yes try connecting your arduino in another uno usb port or try pressing the reset button on your arduino uno.&lt;/p&gt;&#xA;" OwnerUserId="10809" LastActivityDate="2015-07-16T10:59:46.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13496" PostTypeId="2" ParentId="13402" CreationDate="2015-07-16T11:42:05.707" Score="0" Body="&lt;p&gt;This answer is for your 3dr Update - should you throw it away?&#xA;I'd say no, if you are comfortable with using the Raspberry PI as programmer, as you already did.&#xA;You will not be able to use the USB-based programming, nor you will be able to emulate USB peripherals, but that's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything else will (or should) work normally, so why would you throw it away? :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also suggest you grab the stronger magnifying lens you can find and have a look at the soldering of all the components. Especially those connected to the Atmega16U and the chip itself. Maybe it's not broken, but there is some short caused by conductive debris or by some excess of soldering material. If that's the case, it might be easy to remove it.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-16T11:42:05.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13497" PostTypeId="1" CreationDate="2015-07-16T12:06:02.727" Score="1" ViewCount="537" Body="&lt;p&gt;For CNC milling we have code such as Grbl Controller in the PC, and Grbl itself in an Arduino, and these handle the appropriate G-code files. Is there an equivalent package to handle Excellon files and drive a 3-axis drilling machine?&lt;/p&gt;&#xA;" OwnerUserId="11247" LastActivityDate="2015-11-14T00:43:42.923" Title="Is there an equivalent to Grbl for Excellon PCB drilling?" Tags="|mechanical|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13498" PostTypeId="1" CreationDate="2015-07-16T12:58:30.470" Score="0" ViewCount="17870" Body="&lt;p&gt;I'm attempting to send data from a serial connection to a GSM modem, but having problems.&#xA;The string from rx looks like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.0 2.0 3.0 4.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's my code to replace the spaces and then I just want to pass the whole string on, regardless of what's inside (there could be negative values too).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                data_current[data_index++] = ',';&#xA;                char received = bike_port.read(); //bike&#xA;                char test[32];&#xA;                inData += received;     &#xA;                  if (received == '\n')&#xA;                  {&#xA;                      String nospace = inData;&#xA;                      nospace.replace(&quot;\t&quot;,&quot;,&quot;);&#xA;                      debug_println(&quot;Data: &quot;);&#xA;                      debug_println(nospace);&#xA;                      inData = &quot;&quot;; // Clear recieved buffer&#xA;                      delay(1000);&#xA;                  }  &#xA;                  sprintf(test,32,&quot;%d,%d,%d,%d&quot;,(String) nospace);&#xA;                //strtok(received, tmp);&#xA;                for (int i=0; i&amp;lt;strlen(test); i++) {&#xA;                  data_current[data_index++] = test[i];&#xA;                } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(test,32,&quot;%ld,(String) nospace);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I get now is this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cannot pass objects of non-trivially-copyable type 'class String' through '...'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without the sprintf line I can successfully echo the string to debug_println (Serial Monitor). &#xA;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="11249" LastEditorUserId="11249" LastEditDate="2015-07-16T13:10:27.423" LastActivityDate="2015-08-20T21:10:34.067" Title="Cannot pass objects of non-trivially-copyable type 'class String' through '...'" Tags="|serial|communication|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13499" PostTypeId="1" AcceptedAnswerId="13501" CreationDate="2015-07-16T13:47:35.810" Score="3" ViewCount="15178" Body="&lt;p&gt;Is it possible to create a system like a PLL using an Arduino?&#xA;I ask this because there are some parts in the PLL system, such as: phase detector, VCO, divider, and I don't know how to make for each part in Arduino board.&lt;/p&gt;&#xA;" OwnerUserId="11250" LastEditorUserId="11250" LastEditDate="2015-07-22T14:57:34.033" LastActivityDate="2015-09-22T01:55:37.237" Title="Can I Implement a PLL on an Arduino?" Tags="|arduino-uno|programming|arduino-due|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13500" PostTypeId="2" ParentId="13498" CreationDate="2015-07-16T14:54:23.670" Score="1" Body="&lt;p&gt;The basic problem here is that you're trying to pass a &lt;code&gt;String&lt;/code&gt; object to &lt;code&gt;sprintf()&lt;/code&gt;. That isn't possible because &lt;code&gt;String&lt;/code&gt; is a C++ class, and &lt;code&gt;sprintf()&lt;/code&gt; is a C variadic function. The only way to pass a string to it is as a &lt;code&gt;char *&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of your call to &lt;code&gt;sprintf()&lt;/code&gt; doesn't seem to make sense either, although I suspect it's not what you actually want here. You'd normally use &lt;code&gt;sprintf()&lt;/code&gt; if you want to format several values into a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you've suggested in the comments, adding the contents of &lt;code&gt;nospace&lt;/code&gt; to &lt;code&gt;data_current&lt;/code&gt; character-at-a-time would be the sensible approach. You could do it something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; nospace.length(); ++i) {&#xA;    data_current[data_index++] = nospace[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;strlen()&lt;/code&gt; won't work on &lt;code&gt;nospace&lt;/code&gt; because it's a &lt;code&gt;String&lt;/code&gt; object not a &lt;code&gt;char&lt;/code&gt; array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is all assuming that there's enough space in &lt;code&gt;data_current&lt;/code&gt; though. Without seeing the rest of your code, I can't tell you if it will definitely work or not.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;br&gt;&#xA;As an alternative, you could use &lt;code&gt;memcpy()&lt;/code&gt; to do a block transfer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(data_current + data_index, nospace.c_str(), nospace.length());&#xA;data_index += nospace.length();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure there's much benefit to doing that though. It's hypothetically more efficient, but it probably won't make a noticeable difference unless your string is moderately long and it's being called very frequently. (It's trading-off the loop overhead against a function-call overhead.)&lt;/p&gt;&#xA;" OwnerUserId="42" LastEditorUserId="42" LastEditDate="2015-07-16T15:58:13.307" LastActivityDate="2015-07-16T15:58:13.307" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13501" PostTypeId="2" ParentId="13499" CreationDate="2015-07-16T15:02:07.650" Score="4" Body="&lt;p&gt;A PLL is a very complex device which is not something that can easily be created purely in code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many microcontrollers include a PLL as part of their oscillator systemm which allows them to run internally at a higher speed than their external crystal.  This is not a programmable peripheral that you can use for your own things, but an integral part of the workings of the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it may be possible to write one in software the results would be very somewhat limited. The best you could hope for is to use timers to measure an incoming frequency and use the results to output another frequency through some means, maybe PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create a real PLL you would be best off using either a dedicated PLL chip (which you can buy off the shelf) or use some form of programmable logic like a CPLD that has a built in PLL block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some microcontrollers, most notably the Cypress PSoC range, have programmable logic blocks built in that may be more suited to your task than an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical digital PLL looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/eAzru.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Implementing all that in code would be both tricky and somewhat slow on a little 8-bit MCU with no floating point support.  However, the basic principal of what a PLL can be summarised in one simple sentence:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The frequency coming in determines the frequency going out.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The PLL, or &lt;em&gt;Phase Locked Loop&lt;/em&gt; is just one method of achieving that desired result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method, which is &lt;em&gt;not&lt;/em&gt; using any form of PLL, is purely algorithmic and consists of just three things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/I47sg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Three simple blocks, all of which the Arduino is, to a certain extent, capable of performing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first block, the &lt;em&gt;Frequency Detector&lt;/em&gt;, works out what the frequency of the incoming signal is.  That could either be by counting the number of pulses that arrive over a certain time frame, or measuring the time between successive pulses.  Which method you use (&lt;em&gt;Frequency Counting&lt;/em&gt; or &lt;em&gt;Frequency Measuring&lt;/em&gt;) is really down to what frequency ranges you are using.  Frequency Counting is better for higher frequencies, whereas Frequency Measuring is better for low frequencies.  There are many examples on the web of how to do both of those using timers on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;Decision Making&lt;/em&gt; is basically working out what your output frequency wants to be according to your input frequency.  This could be as simple as &quot;Output = input * 2&quot;, for instance, or something more complex like &quot;Between these frequencies I want to output this frequency, between these frequencies this other frequency, etc&quot;.  It's entirely up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third block just takes the decided-upon output frequency and generates it.  That could be done using the hardware PWM generation of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this, though, will be limited to relatively low frequencies (tens of kHz maximum really) though with clever coding you could push it up slightly higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that really makes this method differ from a PLL is that you don't get the &quot;PL&quot; portion of it - that is, the phase of the incoming frequency is lost, and the output frequency is running entirely with its own phase.  There is little or nothing you can do to synchronise the phases of the input and output like you get with a full PLL.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-17T11:17:48.803" LastActivityDate="2015-07-17T11:17:48.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13502" PostTypeId="1" CreationDate="2015-07-16T18:37:48.627" Score="3" ViewCount="59060" Body="&lt;p&gt;When I first started with a bare minimum code. The compiler compiles the code, but when I try to upload, this is the error message I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; AVRDUDE: STK500_GETSYNC&amp;lt;&amp;gt; ATTEMPT 10 OF 10 NOT IN SYNC :RESP=0X20 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I fix this?&lt;/p&gt;&#xA;" OwnerUserId="11252" LastEditorUserId="2944" LastEditDate="2015-07-17T01:17:23.677" LastActivityDate="2015-07-17T01:17:23.677" Title="avrdude : stk500_get sync&lt;&gt; attempt 10 of 10 not in sync : resp=0x20 how do i get pass this error for ardunio uno board" Tags="|arduino-uno|avrdude|compile|" AnswerCount="1" CommentCount="2" ClosedDate="2015-08-09T22:30:50.530" ContentLicense="CC BY-SA 3.0" />
  <row Id="13503" PostTypeId="2" ParentId="13502" CreationDate="2015-07-16T19:12:01.617" Score="1" Body="&lt;p&gt;There are multiple reasons why you are getting this error.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Bootloader is either missing or corrupted. This is fairly unlikely.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wire connected to pin 0 (RX)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wrong COM port is chosen within the arduino IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Drivers are not installed. You can update it within the Device Manager if you are using Windows.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is a link to an article explaining the causes and how to fix them, &lt;a href=&quot;http://www.instructables.com/id/A-solution-to-avrdude-stk500getsync-not-in-syn/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/A-solution-to-avrdude-stk500getsync-not-in-syn/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8716" LastEditorUserId="11086" LastEditDate="2015-07-17T01:17:09.660" LastActivityDate="2015-07-17T01:17:09.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13504" PostTypeId="1" AcceptedAnswerId="13508" CreationDate="2015-07-16T20:35:58.780" Score="0" ViewCount="402" Body="&lt;p&gt;I'm making a thermometer and, so I can graph the data, I have an Uno with the WizNet shield sending the data to a LAN ip. The chip itself is oddly hot, its temperature measures at around &lt;strong&gt;110-120ºF&lt;/strong&gt; (43.33-48.89ºC). I want the program to be running almost 24/7. Is it okay for the chip to be this hot?&lt;/p&gt;&#xA;" OwnerUserId="10442" LastActivityDate="2015-07-16T22:42:15.093" Title="WizNet chip on Ethernet Shield oddly hot" Tags="|arduino-uno|ethernet|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13505" PostTypeId="2" ParentId="13498" CreationDate="2015-07-16T21:16:20.567" Score="0" Body="&lt;p&gt;Let me get this straight. You want to change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.0 2.0 3.0 4.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.0,2.0,3.0,4.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about:&lt;/p&gt;&#xA;&#xA; &#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  char indata[32] = &quot;1.0 2.0 3.0 4.0&quot;;&#xA;&#xA;  int len = strlen (indata);&#xA;  for (int i = 0; i &amp;lt; len; i++)&#xA;    if (isspace (indata [i]))&#xA;      indata [i] = ',';&#xA;&#xA;  Serial.println (indata);   // prints: 1.0,2.0,3.0,4.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Only problem is that when I change &quot;1.0 2.0 3.0 4.0&quot; to the actual incoming read (bike_port.read()), than I get error ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In that case, as Jake C said, modify the incoming byte like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; char received = bike_port.read(); //bike&#xA; if (isspace (received))&#xA;   received = ',';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-21T20:41:40.500" LastActivityDate="2015-07-21T20:41:40.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13506" PostTypeId="2" ParentId="13493" CreationDate="2015-07-16T21:41:13.803" Score="4" Body="&lt;p&gt;Well, short answer: It was the acknowledge bit, I forgot to send a clock pulse in order to receive it (duh! my device generates the clock for the attached potentiometer, I was waiting for the device to &quot;send&quot; me a bit, I needed to &quot;request&quot; the bit on a rising edge of the clock).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long answer: the code looks like this now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int PIN_SCK = 12;&#xA;int PIN_SDA = 11;&#xA;&#xA;const int delayvalue = 10;&#xA;&#xA;void setup(){&#xA;    digitalWrite(PIN_SCK, 1); // I can first declare the state&#xA;    digitalWrite(PIN_SDA, 1);&#xA;    pinMode(PIN_SCK, OUTPUT); // then turn them on&#xA;    pinMode(PIN_SDA, OUTPUT);&#xA;&#xA;    delay(1000);&#xA;&#xA;    digitalWrite(PIN_SDA, 0); // start bit&#xA;    delay(10);&#xA;    digitalWrite(PIN_SCK, 0);&#xA;    delay(10);&#xA;&#xA;    shift_out(PIN_SDA, PIN_SCK, 0x50);&#xA;    shift_out(PIN_SDA, PIN_SCK, 0xA9);&#xA;    shift_out(PIN_SDA, PIN_SCK, 0xA9);&#xA;&#xA;    digitalWrite(PIN_SDA, 1); // stop bit&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;// uint8_t is the same as 8 bits aka one byte&#xA;void shift_out(uint8_t datapin, uint8_t clockpin, uint8_t val){&#xA;    uint8_t i;&#xA;&#xA;    for (i = 0; i &amp;lt; 8; i++)  {&#xA;        digitalWrite(datapin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; (7 - i))));&#xA;        delay(1);&#xA;        digitalWrite(clockpin, 1);&#xA;        delay(delayvalue);&#xA;        digitalWrite(clockpin, 0);&#xA;        delay(delayvalue);&#xA;    }&#xA;&#xA;    digitalWrite(datapin, 0); // to enable stop bit&#xA;    delay(10);&#xA;&#xA;    // Here I handle the AKNOWLEDGE signal which happens after&#xA;    // each byte sent. Be it address, command or value&#xA;    digitalWrite(clockpin, 1);&#xA;    delay(10);&#xA;    digitalWrite(clockpin, 0);&#xA;    delay(10);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically I followed and reproduced the signals in &lt;a href=&quot;https://i.stack.imgur.com/5Kv55.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;this timing diagram&lt;/a&gt; faithfully with one small exception: I did not generate a rising edge when I expected the acknowledge bit (basically the diagram but with SCK being 0 right below the acknowledge bits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps somebody!&lt;/p&gt;&#xA;" OwnerUserId="4566" LastActivityDate="2015-07-16T21:41:13.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13507" PostTypeId="2" ParentId="13486" CreationDate="2015-07-16T21:44:20.763" Score="0" Body=" &#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int input_pin_blue = 5;&#xA;int input_pin_yellow = 6;&#xA;volatile int state_button_red = LOW;&#xA;volatile int state_button_blue = LOW;&#xA;volatile int state_button_yellow = LOW;&#xA;...&#xA;pinMode(input_pin_blue, INPUT);&#xA;pinMode(input_pin_yellow, INPUT);&#xA;...&#xA;attachInterrupt(0, handler_red, CHANGE);&#xA;attachInterrupt(1, handler_blue_yellow, CHANGE);&#xA;&#xA;&#xA;// interrupt handler function&#xA;void handler_red() {&#xA;    state_button_red = !state_button_red;&#xA;}&#xA;void handler_blue_yellow() {&#xA;    if (digitalRead(input_pin_blue) == HIGH) {&#xA;        state_button_blue = !state_button_blue;&#xA;    }&#xA;&#xA;    if (digitalRead(input_pin_yellow) == HIGH) {&#xA;        state_button_yellow = !state_button_yellow;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the Uno external interrupt 0 is pin D2 not D5, and interrupt 1 is pin D3, not D6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence you are not testing the correct pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I would use INPUT_PULLUP instead of INPUT mode for those pins, unless you have external pull-up or pull-down resistors on them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-16T21:44:20.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13508" PostTypeId="2" ParentId="13504" CreationDate="2015-07-16T22:42:15.093" Score="1" Body="&lt;p&gt;According to the &lt;a href=&quot;http://wizwiki.net/forum/viewtopic.php?f=20&amp;amp;t=2108&amp;amp;p=6933&amp;amp;hilit=w5100%20temperature#p6933&quot; rel=&quot;nofollow&quot;&gt;WizNet forums&lt;/a&gt; this is normal for these shields. Their justification being that it is a PHY and controller on a single chip. (Note this post only specifically mentions the W5100, which is among the more commonly used chips on these kinds of shields, however, I suspect that this is typical for most of the WizNet line, e.g. W5200 etc.)&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-16T22:42:15.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13509" PostTypeId="2" ParentId="13497" CreationDate="2015-07-16T22:53:14.273" Score="1" Body="&lt;p&gt;No, there is no existing Arduino library to parse &lt;a href=&quot;https://en.wikipedia.org/wiki/Excellon_format&quot; rel=&quot;nofollow&quot;&gt;Excellon format&lt;/a&gt; drill files in order to control a drilling machine. Looking at the &lt;a href=&quot;http://web.archive.org/web/20071030075236/http://www.excellon.com/manuals/program.htm&quot; rel=&quot;nofollow&quot;&gt;specification&lt;/a&gt; it looks to be very similar to G Code, and some brief googling shows that there are various utilities for converting it to G Code that could be run from something like grbl.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-16T22:53:14.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13510" PostTypeId="2" ParentId="13499" CreationDate="2015-07-16T23:27:02.550" Score="2" Body="&lt;p&gt;There are two types of PLLs, hardware PLLs and &lt;a href=&quot;https://en.wikipedia.org/wiki/Phase-locked_loop#Implementing_a_digital_phase-locked_loop_in_software&quot; rel=&quot;nofollow&quot;&gt;software PLLs&lt;/a&gt;. Majenko has already addressed hardware PLLs so I will leave you to his answer for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software PLLs perform the same function as regular hardware PLLs, but with code, and as a result are constrained by the clock speed and sample rate of the controller they are running on. Usually this means you are limited to sub MHz frequencies. The math and computation necessary to perform this &lt;a href=&quot;http://liquidsdr.org/blog/pll-howto/&quot; rel=&quot;nofollow&quot;&gt;is quite complicated&lt;/a&gt;, and I do not expect you would get particularly good performance out of your standard Arduino controller, as all of them lack a floating point unit to perform these types of computations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to still try and attempt this you would have to do it using integer math only. The faster the CPU, the higher the frequency it will be able to lock on to. The fastest Arduino available today is the Arduino Due. Aside from being fast, the Due can perform 32-bit arithmetic in a single cycle, which should be handy. The frequency limit will be dictated by how many cycles all of your calculations take.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-07-17T01:11:08.683" LastActivityDate="2015-07-17T01:11:08.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13511" PostTypeId="2" ParentId="9115" CreationDate="2015-07-16T23:27:40.847" Score="2" Body="&lt;p&gt;This includes hysteresis and uses some loops and arrays to simplify and compact the code, since the logic for each range is essentially the same.  More ranges are easy to include by extending the Cutoffs and LedPins arrays (one more led than cutoff).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int VoltagePin = 14;&#xA;const int Cutoffs[] = { 628 , 699 };&#xA;const int NumCutoffs = sizeof(Cutoffs)/sizeof(int);&#xA;const int Hysteresis = 5;&#xA;&#xA;const int LedPins[NumCutoffs+1] = {5,4,3};&#xA;&#xA;int Level = 0; &#xA;int Voltage = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  for (int i=0; i&amp;lt;=NumCutoffs; ++i) {&#xA;    pinMode(LedPins[i],OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Voltage = analogRead(VoltagePin);&#xA;&#xA;  while (Level &amp;lt; NumCutoffs &amp;amp;&amp;amp; Voltage &amp;gt;= Cutoffs[Level]) {&#xA;    ++Level;&#xA;  }&#xA;&#xA;  while (Level &amp;gt; 0 &amp;amp;&amp;amp; Voltage &amp;lt; Cutoffs[Level-1] - Hysteresis) {&#xA;    --Level;&#xA;  }&#xA;&#xA;  for (int i=0; i&amp;lt;=NumCutoffs; ++i) {&#xA;    digitalWrite(LedPins[i], i == Level);&#xA;  }&#xA;&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11258" LastEditorUserId="11258" LastEditDate="2015-07-21T04:20:35.980" LastActivityDate="2015-07-21T04:20:35.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13512" PostTypeId="1" AcceptedAnswerId="13514" CreationDate="2015-07-16T23:30:22.303" Score="1" ViewCount="975" Body="&lt;p&gt;Is there any way to have an Arduino web server redirect the client to a file on the SD card only if the client is using a mobile browser?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(My arduino server is already successfully serving pages on &lt;a href=&quot;http://192.168.0.180&quot; rel=&quot;nofollow&quot;&gt;http://192.168.0.180&lt;/a&gt;, and successfully processes GET requests).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of having this javascript code on the main page that's served by the arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&#xA;  &amp;lt;!--&#xA;  if (screen.width &amp;lt;= 800) {&#xA;    window.location = &quot;http://192.168.0.180?mobile&quot;;&#xA;  }&#xA;  //--&amp;gt;&#xA;&amp;lt;/script&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My first thought was that maybe it's possible for the server to process that GET request and then serve a page from the SD card, instead of the regular page it serves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think this is possible, and how would you recommend to do it?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-07-16T23:46:16.763" Title="Arduino web server: redirect to mobile site on SD card?" Tags="|ethernet|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13513" PostTypeId="2" ParentId="13465" CreationDate="2015-07-16T23:45:31.130" Score="1" Body="&lt;p&gt;Because you have an Arduino Mega, you can set it up to use it like a USB-to-UART adapter by using the following code (&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MultiSerialMega&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize both serial ports:&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read from port 1, send to port 0:&#xA;  if (Serial1.available()) {&#xA;    int inByte = Serial1.read();&#xA;    Serial.write(inByte); &#xA;  }&#xA;&#xA;  // read from port 0, send to port 1:&#xA;  if (Serial.available()) {&#xA;    int inByte = Serial.read();&#xA;    Serial1.write(inByte); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically what this does is it takes the data it receives from the USB port via &lt;code&gt;Serial&lt;/code&gt; and transmits it to &lt;code&gt;Serial1&lt;/code&gt; and then also reads from the UART port via &lt;code&gt;Serial1&lt;/code&gt; and transmits it back to the computer via &lt;code&gt;Serial&lt;/code&gt;. With this code running you should be able to hook up the XBee to RX1 and TX1 and communicate to it using the Serial Monitor.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-16T23:45:31.130" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13514" PostTypeId="2" ParentId="13512" CreationDate="2015-07-16T23:46:16.763" Score="2" Body="&lt;p&gt;Yes, it is perfectly possible. you just have to look at the right bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fundamentally there is no difference between an Arduino and any other website, it's just somewhat simpler in how it operates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All browsers follow the same rules - if they didn't they wouldn't work on the web.  Two of the rules you are interested in are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Browsers identify themselves along with their OS.&lt;/li&gt;&#xA;&lt;li&gt;Browsers respond to the &quot;result&quot; code the website provides in a specific way.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Besides the GET request a browser also sends a list of &lt;em&gt;headers&lt;/em&gt;.  These contain lots of extra information about the request, including the domain name of the website that is being accessed (so the web server knows which site you want - it's not one webserver per site, that would be impractical.  For instance, the request to show this page from Firefox on Linux has these headers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Host: arduino.stackexchange.com&#xA;User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.6.0&#xA;Accept:&quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;&#xA;Accept-Language: en-gb,en;q=0.5 &#xA;Accept-Encoding: gzip, deflate&#xA;Cookie: (I won't bore you with this lot)&#xA;Connection: keep-alive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The header of note is the &lt;em&gt;User-Agent:&lt;/em&gt; one.  That tells the web server that I am using firefox from a 64-bit Intel Linux computer.  If I were to do it from my Android phone it would tell you it's from Chrome on Android. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By looking for that header and parsing it for certain keywords you can find if you're serving to a mobile device or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the second bullet above - browsers respond to the &lt;em&gt;response&lt;/em&gt; code in different ways.  Normally you send the response code &lt;code&gt;200&lt;/code&gt; which means &quot;I accepted your request and here is the page you asked for&quot;.  Another response code that is useful is code &lt;code&gt;301&lt;/code&gt; which means &quot;The page you asked for isn't at this address any more - here is the new address you should go to instead&quot;.  That will then cause the browser to go to the newly provided address instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of responding with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HTTP/1.0 200 OK&#xA;Content-type: text/html&#xA;&#xA;&amp;lt;web page content here&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could instead respond with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HTTP/1.0 301 Moved Permanently&#xA;Location: http://myarduino.local/mobile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the browser will &lt;em&gt;redirect&lt;/em&gt; to the new address you give in the &lt;em&gt;Location:&lt;/em&gt; response header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full list of response codes is here: &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to avoid the overhead of a browser redirect you can just serve different data to the browser depending on what the User-Agent header specifies.  After all, it's entirely down to you what is sent as the content of the page.  Whether you get that from purely programmatical means, or by reading a file off an SD card, is entirely up to you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-16T23:46:16.763" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13515" PostTypeId="2" ParentId="13498" CreationDate="2015-07-17T01:35:32.777" Score="0" Body="&lt;p&gt;As a companion to Nick Gammon's excellent answer, here is a streaming version of that (assuming this is coming in one serial port and out another to the modem).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available()) {&#xA;  int inByte = Serial.read();&#xA;  if (inByte == ' ')&#xA;    Serial1.write(',');&#xA;  else&#xA;    Serial1.write(inByte); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-17T01:35:32.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13517" PostTypeId="1" CreationDate="2015-07-17T05:37:51.430" Score="0" ViewCount="9559" Body="&lt;p&gt;I have an Arduino Mega 2560 connected to a Windows 8 laptop. I want to program it to send keystrokes to the attached computer (when a pin's digital read goes from HIGH to LOW.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trouble is, I cannot find any way to program my Arduino Mega to send keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The supposedly &quot;core&quot; Keyboard and Mouse libraries only support 32u4 boards, and other libraries that give the Arduino keystroke functionality are out of sight. When I googled the issue, I found no question or explanation of how to send keystrokes on the Arduino Mega. When I searched further, I thought the V-USB library would be a potential workaround, but the library throws numerous errors when imported into an Arduino sketch (even on the 1.0.0 IDE it was designed for.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After hours of searching, two final workarounds seem to have popped up:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Some method to run a Python code to send keystrokes to the PC, and then connect the Arduino code to Python. (I don't know Python...)&lt;/li&gt;&#xA;&lt;li&gt;Use some program called Gobetwino, which runs between the Arduino and PC, to   convert Serial commands into keystrokes somehow. (Pressing and releasing a key can't be simulated very well by repeatedly sending Serial commands, I think.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both are very unideal, very tedious, and are equally likely to just not work. I have spent hours on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions to get me out of this hell? Libraries, workarounds, anything?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Feel free to PM me questions for clarification.)&lt;/p&gt;&#xA;" OwnerUserId="11261" LastActivityDate="2015-07-17T11:47:41.637" Title="How to input keyboard commands using Arduino Mega 2560?" Tags="|programming|arduino-mega|pins|communication|keyboard|" AnswerCount="1" CommentCount="5" ClosedDate="2015-07-18T15:26:28.083" ContentLicense="CC BY-SA 3.0" />
  <row Id="13518" PostTypeId="1" AcceptedAnswerId="13521" CreationDate="2015-07-17T06:06:14.653" Score="7" ViewCount="2155" Body="&lt;p&gt;I have an Arduino Nano with an 328P and need all 6 PWM pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, I had to adjust the prescaler and WGM Mode of Timer0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is now in phase correct PWM mode with a prescaler of 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);&#xA;TCCR0B = _BV(CS00);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I need a working time calculation for other libraries, but since&#xA;Timer0 had that duty everything is out of order now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried adjusting the wiring.c &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the prescaler is set so that timer0 ticks every 64 clock cycles, and the&#xA;// the overflow handler is called every 256 ticks.&#xA;#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 510))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it's like I didn't change anything.&#xA;(tested other settings that &lt;strong&gt;were changed&lt;/strong&gt; so it was compiled anew )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whole Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;  // Set Timer 0, 1 and 2&#xA;  // Register A: Output A and B to non-inverted PWM and PWM mode to phase correct.&#xA;  // Register B: Pre Scaler to 1.&#xA;  TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);&#xA;  TCCR0B = _BV(CS00);&#xA;&#xA;  TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10);&#xA;  TCCR1B = _BV(CS10);&#xA;&#xA;  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);&#xA;  TCCR2B = _BV(CS20);&#xA;&#xA;  pinMode(8, OUTPUT);&#xA;&#xA;&#xA;}&#xA;void loop() {&#xA;&#xA;  digitalWrite(8, LOW);&#xA;  delay(65000);&#xA;  digitalWrite(8, HIGH);&#xA;  delay(65000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11263" LastEditorUserId="11263" LastEditDate="2015-07-17T07:33:45.087" LastActivityDate="2020-02-03T20:37:02.400" Title="Adjust time calculation after Timer0 frequency change" Tags="|pwm|timers|millis|" AnswerCount="4" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="13520" PostTypeId="2" ParentId="13518" CreationDate="2015-07-17T08:34:06.183" Score="0" Body="&lt;p&gt;You have set &lt;code&gt;MICROSECONDS_PER_TIMER0_OVERFLOW&lt;/code&gt; to a proper value, however, this is only ever used by &lt;code&gt;MILLIS_INC&lt;/code&gt;, which in turn is only ever used by &lt;code&gt;millis()&lt;/code&gt;. This means that the other timing functions, such as &lt;code&gt;micros()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt;, &lt;code&gt;delayMicroseconds()&lt;/code&gt; break when timer0 is changed. This is kind of a bug, and it may be fixed in a future version, but for now, the Arduino libraries are expecting you to leave timer0 alone. The best workaround is to only use &lt;code&gt;millis()&lt;/code&gt; for your timing critical functions.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-17T08:34:06.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13521" PostTypeId="2" ParentId="13518" CreationDate="2015-07-17T08:37:43.327" Score="4" Body="&lt;p&gt;Fixing the timekeeping functions with your PWM settings is not so&#xA;simple. You should at least try to rewrite &lt;code&gt;ISR(TIMER0_OVF_vect)&lt;/code&gt;,&#xA;&lt;code&gt;micros()&lt;/code&gt;, and probably &lt;code&gt;delay()&lt;/code&gt;. Here is why:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, there is a rounding problem. Time is kept using two global&#xA;variables:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;volatile unsigned long timer0_millis;&#xA;static unsigned char timer0_fract;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first one is what &lt;code&gt;millis()&lt;/code&gt; returns. The second one keeps track of&#xA;how much time has passed since the last full millisecond, and it does so&#xA;in units of 8&amp;nbsp;µs. The two variables are incremented by&#xA;&lt;code&gt;ISR(TIMER0_OVF_vect)&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;m += MILLIS_INC;  // temporary copy of timer0_millis&#xA;f += FRACT_INC;   // temporary copy of timer0_fract&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a normal Uno configuration, the ISR is called every 1024&amp;nbsp;µs.&#xA;Then &lt;code&gt;MILLIS_INC&lt;/code&gt; is 1 and &lt;code&gt;FRACT_INC&lt;/code&gt; is 3. With your timer&#xA;configuration, the ISR is called every 31.875&amp;nbsp;µs (510 cycles), then&#xA;&lt;code&gt;MILLIS_INC&lt;/code&gt; should be 0 and &lt;code&gt;FRACT_INC&lt;/code&gt; should be 3.984375. But since&#xA;we are dealing with integers, it will be rounded down to 3, and your&#xA;&lt;code&gt;millis()&lt;/code&gt; will tick about 25% too slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple fix would be to&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 512))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in order for &lt;code&gt;FRACT_INC&lt;/code&gt; to be 4 and &lt;code&gt;millis()&lt;/code&gt; to be 0.4% too fast. Or&#xA;you could make &lt;code&gt;timer0_fract&lt;/code&gt; a 16-bit variable and have it count clock&#xA;cycles, just to avoid this error. Either option should fix &lt;code&gt;millis()&lt;/code&gt;,&#xA;but you still have a problem with &lt;code&gt;micros()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;micros()&lt;/code&gt; works by reading both &lt;code&gt;timer0_overflow_count&lt;/code&gt; (incremented by&#xA;1 in the ISR) and the actual counter value. Since your counter is now&#xA;going alternatively up and down, it will be harder to compute a&#xA;microsecond count from these readings. Maybe you could take two&#xA;consecutive readings of the counter, just to know whether it is going up&#xA;or down...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there is &lt;code&gt;delay()&lt;/code&gt;, which relies on &lt;code&gt;micros()&lt;/code&gt;. If you fix&#xA;&lt;code&gt;micros()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt; should work fine. If not, You could rewrite&#xA;&lt;code&gt;delay()&lt;/code&gt; to use &lt;code&gt;millis()&lt;/code&gt; instead, which should be easy but you will&#xA;loose some accuracy.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-07-17T08:37:43.327" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13522" PostTypeId="1" AcceptedAnswerId="13523" CreationDate="2015-07-17T11:11:00.183" Score="8" ViewCount="12724" Body="&lt;p&gt;analogRead(nGPIO_max + lockerVal) were nGPIO_max(maximum digital pins in Arduino Uno is 13) and lockerval is 2. Which pin is it reading? &lt;/p&gt;&#xA;" OwnerUserId="11262" LastEditorUserId="11262" LastEditDate="2015-07-25T08:45:31.007" LastActivityDate="2015-07-25T08:45:31.007" Title="Can I use analogRead to read a digital pin?" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13523" PostTypeId="2" ParentId="13522" CreationDate="2015-07-17T11:36:38.343" Score="16" Body="&lt;p&gt;To answer the question in the title: No, you cannot use &lt;code&gt;analogRead()&lt;/code&gt; to read a digital pin. A digital pin cannot behave as analog because it isn't connected to the ADC (Analog to Digital Converter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you call something equating to &lt;code&gt;analogRead(15)&lt;/code&gt; on an Uno, then it should read pin &lt;code&gt;A1&lt;/code&gt;. You can see the pin assignments in the board-specific versions of &lt;code&gt;pins_arduino.h&lt;/code&gt; (shipped with the IDE):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t A0 = 14;&#xA;static const uint8_t A1 = 15;&#xA;static const uint8_t A2 = 16;&#xA;static const uint8_t A3 = 17;&#xA;static const uint8_t A4 = 18;&#xA;static const uint8_t A5 = 19;&#xA;static const uint8_t A6 = 20;&#xA;static const uint8_t A7 = 21;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using those raw numbers directly is generally not a good idea though as it obscures your code's meaning, and will potentially make it non-portable to other boards. It's better to call something like &lt;code&gt;analogRead(A1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's worth noting that the Arduino library fudges the pin numbers slightly. Calling &lt;code&gt;analogRead(1)&lt;/code&gt; has the same result as calling &lt;code&gt;analogRead(A1)&lt;/code&gt;. That means that even if you &lt;em&gt;tried&lt;/em&gt; to use &lt;code&gt;analogRead()&lt;/code&gt; on a digital pin, it might actually end up reading an analog pin instead. Alternatively, it might just return a meaningless result, depending on the pin number you give it.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-07-17T11:36:38.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13524" PostTypeId="2" ParentId="13517" CreationDate="2015-07-17T11:47:41.637" Score="0" Body="&lt;p&gt;You are right, the mega can't do what you want unless something in the middle catches the serial/IO and translates to a keystroke command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, more expensive, is to buy an Arduino Leonardo which is also available as a small usb stick type of device. Then use serial/analog or ano from the mega to the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Leonardo boards can emulate any usb device such as keyboard, mouse, joystick etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe not of interested but also look at Teensy 3.1. It can do what the Leonardo does but is 32 bit and very flexible. The only benefit of the mega is the massive number of pins. Teensy costs about $20.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It all depends on what your project requires.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-17T11:47:41.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13525" PostTypeId="1" CreationDate="2015-07-17T13:21:57.160" Score="0" ViewCount="528" Body="&lt;p&gt;I am trying to program an Arduino Mega(Crius) from a Minnowboard Max A2 via an UART (Hardware Flow Control Off) interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can successfully communicate with the ROS (robot Operating System) on the Ubuntu 12.04 installed on the Minnowboard Max via the UART1 port available on the Minnow Board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Crius UART has a FTDi compatible port with a DTR pin. &#xA;Unfortunately the MinnowBoard does not have any DTR pin to communicate with the Arduino (Only CTS/RTS pins for 1 of the 3 UART ports). Thus I cannot upload any sketch to the Arduino via the Minnowboard over the UART. I must always connect to the onboard FTDi-USB chip of the crius and upload the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any workaround to upload the sketch to the Arduino via the UART from the Minnowboard ?&lt;/p&gt;&#xA;" OwnerUserId="11270" LastActivityDate="2022-11-27T09:03:35.427" Title="Arduino communication with ROS via UART" Tags="|arduino-mega|bootloader|communication|uart|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13526" PostTypeId="1" CreationDate="2015-06-18T08:33:56.083" Score="1" ViewCount="73" Body="&lt;p&gt;I have an Arduino Due I'd like to start using. I've been using Unos, Megas etc no problem. The newer IDEs have removed the Due support. I've been trying to install Due support through the Board Manager, but when I open the Boards Manager, I get :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Error downloading http://downloads.arduino.cc/packages/package_index.json&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and when I try to install Due support, I get :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Error downloading http://downloads.arduino.cc/cores/sam-1.6.4.tar.bz2&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand I may be behind proxies, but in IDE version 1.6.5, that has been removed from the Preferences, so I can't change that. I have tried to allow the IDE past the Windows Firefall, but that has not changed anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have manually downloaded &lt;em&gt;sam-1.6.4.tar.bz2&lt;/em&gt; and extracted the contents to &lt;em&gt;C:\Arduino\arduino-1.6.5\hardware\arduino\sam&lt;/em&gt; (I had to manually create the &lt;em&gt;sam&lt;/em&gt; folder). With this, I can see the options of Arduino Due Native USB Port and Arduino Due Programming Port when selecting the board, and when I look for it in the Ports, it can recognise the board at the port (eg &quot;COM5 (Arduino Due (Programming Port))&quot; ). When I try to compile anything, I get the error message :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Cannot run program &quot;{runtime.tools.arm-none-eabi-gcc.path}\bin\arm-none-eabi-g++&quot; (in directory &quot;.&quot;): CreateProcess error=2, The system cannot find the file specified&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other idea as to how I can install the Due? Is there an option for a manual installation? The same happens with Libraries Manager (I don't get a connection), so I guess, the same can be applied to that.&lt;/p&gt;&#xA;" OwnerUserId="7689" OwnerDisplayName="Tom" LastActivityDate="2015-07-17T14:23:37.097" Title="Arduino IDE Board Manager: Unable to install Due on 1.6.5" Tags="|arduino-ide|arduino-due|" AnswerCount="0" CommentCount="0" ClosedDate="2015-07-17T14:23:56.987" ContentLicense="CC BY-SA 3.0" />
  <row Id="13527" PostTypeId="2" ParentId="13525" CreationDate="2015-07-17T14:35:38.790" Score="1" Body="&lt;p&gt;You can use any GPIO you like on the Minnow to trigger a reset of the Mega to initiate the bootloader.  The Yún does just that to program the on-board ATMega chip through a script they have chosen to call &quot;run-avrdude&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;echo 1 &amp;gt; /sys/class/gpio/gpio21/value&#xA;avrdude  -q -q -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U efuse:r:/tmp/efuse:d&#xA;read EFUSE &amp;lt; /tmp/efuse&#xA;rm -f /tmp/efuse&#xA;if [ &quot;x$EFUSE&quot; = &quot;x203&quot; ] # 203 = 0xCB&#xA;then&#xA;    avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xCB:m -Uflash:w:$1:i $2&#xA;else&#xA;    avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFB:m -Uflash:w:$1:i $2&#xA;fi&#xA;echo 0 &amp;gt; /sys/class/gpio/gpio21/value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could do something similar to initiate the bootloader on the remote board - connect any GPIO pin to the RESET line of your Mega board, then perform the following logical actions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Set the GPIO to OUTPUT&lt;/li&gt;&#xA;&lt;li&gt;Set the GPIO to LOW&lt;/li&gt;&#xA;&lt;li&gt;Delay a few ms&lt;/li&gt;&#xA;&lt;li&gt;Set the GPIO to INPUT&lt;/li&gt;&#xA;&lt;li&gt;Run avrdude.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;By setting the GPIO to INPUT you are emulating an open-drain output.  If you were just to drive the GPIO HIGH it would hold the RESET pin HIGH and you wouldn't be able to use the USB interface, nor the RESET button.  By setting it to INPUT it is then effectively disconnected from the RESET pin so won't interfere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Yún again has a script that works in that way, &quot;reset-mcu&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;&#xA;echo 18 &amp;gt; /sys/class/gpio/export&#xA;echo &quot;high&quot; &amp;gt; /sys/class/gpio/gpio18/direction&#xA;echo 1 &amp;gt; /sys/class/gpio/gpio18/value&#xA;echo 0 &amp;gt; /sys/class/gpio/gpio18/value&#xA;echo 18 &amp;gt; /sys/class/gpio/unexport&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a similar setup to you but using a BeagleBone Black and a PONTECH Quick240 PIC32 based controller.  In my IDE &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; I set up a special board definition with the following programmer added to it which performs the manual reset through GPIO and runs the upload program (pic32prog) all in one operation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;upload.local.name=Local upload&#xA;upload.local.using=script&#xA;upload.local.script.0=__builtin_bullet::Entering programming mode...&#xA;upload.local.script.1=__builtin_gpio::7::low&#xA;upload.local.script.2=__builtin_delay::100&#xA;upload.local.script.3=__builtin_gpio::20::low&#xA;upload.local.script.4=__builtin_delay::100&#xA;upload.local.script.5=__builtin_gpio::20::hiz&#xA;upload.local.script.6=__builtin_delay::100&#xA;upload.local.script.7=__builtin_gpio::7::hiz&#xA;upload.local.script.8=__builtin_delay::100&#xA;upload.local.script.9=__builtin_bullet::Uploading sketch...&#xA;upload.local.script.10=${core.root}/tools/linux_arm/pic32prog::-S::-d::${port}::-B::${upload.maxbaud}::-p::${build.path}/${filename}.hex&#xA;upload.local.script.11=__builtin_bullet::Resetting board...&#xA;upload.local.script.12=__builtin_delay::100&#xA;upload.local.script.13=__builtin_gpio::20::low&#xA;upload.local.script.14=__builtin_delay::100&#xA;upload.local.script.15=__builtin_gpio::20::hiz&#xA;&#xA;sketch.upload=local&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That one is a little different in that you have to hold a second GPIO LOW while you reset the board to initiate the bootloader, hence the two GPIOs in use there.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-17T14:35:38.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13528" PostTypeId="1" AcceptedAnswerId="13531" CreationDate="2015-07-17T16:45:45.830" Score="0" ViewCount="4085" Body="&lt;p&gt;I am working on a web server project for work. I have a web server setup with an Arduino Meg2560 with Ethernet. I also have a 16 relay board connected to Ethernet with its own IP. I wanted to see if there is a way I can make calls to the relay board via IP from the Arduino Webserver. For example Relay 1 on the relay board can be turned on by typing 192.168.1.4/30000/00 but this opens the web GUI on the board. I need to do the same thing but without opening the webpage or web GUI.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/dzZjs.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;    // MAC address from Ethernet shield sticker under board&#xA;    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;    IPAddress ip(192, 168, 1, 177); // IP address&#xA;    EthernetServer server(80);  // Server Port 80&#xA;&#xA;    void setup()&#xA;    {&#xA;      Ethernet.begin(mac, ip);  &#xA;      server.begin();           &#xA;    }&#xA;&#xA;    void loop()&#xA;{&#xA;EthernetClient client = server.available();  // try to get client&#xA;&#xA;if (client) {  // got client?&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;        if (client.available()) {   // client data available to read&#xA;            char c = client.read(); // read 1 byte (character) from client&#xA;            // last line of client request is blank and ends with \n&#xA;            // respond to client only after last line received&#xA;            if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;                // send a standard http response header&#xA;                client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;                client.println(&quot;Content-Type: text/html&quot;);&#xA;                client.println(&quot;Connection: close&quot;);&#xA;                client.println();&#xA;                // send web page&#xA;                client.println(&quot;&amp;lt;!DOCTYPE html&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;head&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;title&amp;gt;Arduino Web Page&amp;lt;/title&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;/head&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;h1&amp;gt;Hello from Arduino!&amp;lt;/h1&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;p&amp;gt;A web page from the Arduino server&amp;lt;/p&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;                client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;                break;&#xA;            }&#xA;            // every line of text received from the client ends with \r\n&#xA;            if (c == '\n') {&#xA;                // last character on line of received text&#xA;                // starting new line with next character read&#xA;                currentLineIsBlank = true;&#xA;            } &#xA;            else if (c != '\r') {&#xA;                // a text character was received from client&#xA;                currentLineIsBlank = false;&#xA;            }&#xA;        } // end if (client.available())&#xA;    } // end while (client.connected())&#xA;    delay(1);      // give the web browser time to receive the data&#xA;    client.stop(); // close the connection&#xA;} // end if (client)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="11273" LastEditorUserId="11273" LastEditDate="2015-07-18T07:03:09.303" LastActivityDate="2018-03-22T08:36:27.860" Title="Arduino Web Server and Relay Module" Tags="|programming|arduino-mega|shields|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13530" PostTypeId="2" ParentId="13345" CreationDate="2015-07-17T22:11:11.783" Score="-1" Body="&lt;p&gt;Try adding a delay, eg. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into your main loop. You may be sending data too fast for the Java app to cope with. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-17T22:11:11.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13531" PostTypeId="2" ParentId="13528" CreationDate="2015-07-17T23:19:42.083" Score="0" Body="&lt;p&gt;Documentation on the &lt;a href=&quot;http://www.sainsmart.com/sainsmart-ethernet-control-module-lan-wan-web-server-control-with-rj45-port.html&quot; rel=&quot;nofollow&quot;&gt;controller&lt;/a&gt; you are using is pretty scant, but it looks like you just need to make a GET request to the URI corresponding to the action you need to take.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/00&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/00&lt;/a&gt; : Relay-01 OFF&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/01&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/01&lt;/a&gt; : Relay-01 ON&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/02&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/02&lt;/a&gt; : Relay-02 OFF&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/03&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/03&lt;/a&gt; : Relay-02 ON&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/04&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/04&lt;/a&gt; : Relay-03 OFF&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/05&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/05&lt;/a&gt; : Relay-03 ON&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;…&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/14&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/14&lt;/a&gt; : Relay-8 OFF&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/15&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/15&lt;/a&gt; : Relay-8 ON&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/41&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/41&lt;/a&gt; : Enter&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/40&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/40&lt;/a&gt; : Exit&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/42&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/42&lt;/a&gt; : Next Page&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://192.168.1.4/30000/43&quot; rel=&quot;nofollow&quot;&gt;http://192.168.1.4/30000/43&lt;/a&gt; : Next Page&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example If I wanted to turn off relay 3, I would simple make a GET request to &lt;code&gt;http://192.168.1.4/30000/04&lt;/code&gt; and close the connection. Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IPAddress server(192,168,1,4);&#xA;EthernetClient client;&#xA;client.connect(server, 80);&#xA;client.println(&quot;GET /30000/04 HTTP/1.1&quot;);&#xA;client.println(&quot;Connection: close&quot;);&#xA;client.println();&#xA;client.stop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-17T23:19:42.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13534" PostTypeId="2" ParentId="13345" CreationDate="2015-07-18T02:30:19.890" Score="1" Body="&lt;p&gt;Timing tests show that the Java code lags something like 25 or more seconds behind the input from the Arduino. This can be fixed by changing in the Java code these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       try {&#xA;            String inputLine=input.readLine();&#xA;            System.out.println(inputLine);&#xA;        } catch (Exception e) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       try {&#xA;            while (input.ready ())&#xA;              {&#xA;              String inputLine=input.readLine();&#xA;              System.out.println(inputLine);&#xA;              }&#xA;        } catch (Exception e) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This extra loop &quot;drains&quot; the input buffer of data in the one serialEvent call, rather than relying upon a serialEvent call per line of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found when testing that the output is now highly responsive, even without a delay on the Arduino side.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My other answer of adding a &lt;code&gt;delay&lt;/code&gt; call slowed output down enough for the Java app to catch up, but I must admit it isn't the best solution. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-18T02:30:19.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13535" PostTypeId="1" AcceptedAnswerId="13536" CreationDate="2015-07-18T06:02:35.913" Score="-1" ViewCount="332" Body="&lt;p&gt;I've got this code from the &lt;a href=&quot;http://www.multiwii.com/&quot; rel=&quot;nofollow&quot;&gt;MultiWii&lt;/a&gt; project, which is relevant to the hardware, &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA32U4.aspx&quot; rel=&quot;nofollow&quot;&gt;ATmega32u4&lt;/a&gt;, I have. It is part of a function called &lt;code&gt;initOutput()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the comment it says &quot;connect pin 6&quot;, which is the bit of that which specifies pin 6 as I would like to change it to another pin, specifically A0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Enhanced PWM mode&#xA;TCCR4E |= (1&amp;lt;&amp;lt;ENHC4);&#xA;&#xA;// Prescaler to 16&#xA;TCCR4B &amp;amp;= ~(1&amp;lt;&amp;lt;CS41);&#xA;TCCR4B |= (1&amp;lt;&amp;lt;CS42) | (1&amp;lt;&amp;lt;CS40);&#xA;&#xA;// Phase and frequency correct mode and top to 1023, but&#xA;// with enhanced PWM mode we have 2047.&#xA;TCCR4D |= (1&amp;lt;&amp;lt;WGM40);&#xA;TC4H = 0x3;&#xA;OCR4C = 0xFF;&#xA;&#xA;// Connect pin 6 to timer 4 channel D&#xA;TCCR4C |= (1&amp;lt;&amp;lt;COM4D1) | (1&amp;lt;&amp;lt;PWM4D);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="510" LastEditDate="2015-12-24T22:24:48.057" LastActivityDate="2015-12-24T22:24:48.057" Title="PWM timers, channels and pins" Tags="|pwm|timers|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13536" PostTypeId="2" ParentId="13535" CreationDate="2015-07-18T10:44:56.153" Score="1" Body="&lt;p&gt;It's the &lt;code&gt;(1&amp;lt;&amp;lt;COM4D1)&lt;/code&gt; that enables pin 6, or more specifically &lt;strong&gt;OC4D&lt;/strong&gt; for timer output. You cannot use A0 instead, since there is no output compare capability on that pin; only pins 13, 5, 10, 9, 6, and 12 can be connected to timer 4. See the datasheet for details.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-18T10:44:56.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13538" PostTypeId="1" AcceptedAnswerId="13539" CreationDate="2015-07-18T13:39:50.557" Score="1" ViewCount="2689" Body="&lt;p&gt;I want to connect the &lt;em&gt;Arduino TFT LCD 1.77&quot; screen&lt;/em&gt; to an &lt;em&gt;Arduino Leonardo&lt;/em&gt;. Acording to &lt;a href=&quot;https://www.arduino.cc/en/Guide/TFTtoBoards&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial I should connect some pins on LCD screen to &lt;em&gt;ICSP pins&lt;/em&gt; on Leonardo but I don't have equipment to do it. Can I just connect LCD screen to Leonardo in the way it't recommanded for an &lt;em&gt;Arduino Uno&lt;/em&gt; (same tutorial above) using only digital and power pins. And then use sketches for Uno. Will it work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is it safe for LCD screen?&lt;/p&gt;&#xA;" OwnerUserId="11284" OwnerDisplayName="Garnagar" LastActivityDate="2015-07-19T10:47:48.897" Title="Can I connect TFT LCD screen to Arduino Leonardo same way as it's recommanded for Arduino Uno?" Tags="|lcd|pins|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13539" PostTypeId="2" ParentId="13538" CreationDate="2015-07-18T14:19:21.140" Score="1" Body="&lt;p&gt;I think it could work, but not easily. I.e. you would need to tweak the code and anyway you will end up with really low performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the reason:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardLeonardo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The screen can be configured for use in two ways. One is to use an Arduino's hardware SPI interface. The other is to declare all the pins manually. There is no difference in the functionality of the screen between the two methods, but using hardware SPI is significantly faster when drawing.&#xA;  If you plan on using the SD card on the TFT module, you must use hardware SPI.&#xA;  All the examples are written for hardware SPI use. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.arduino.cc/en/Guide/TFT#toc4&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/TFT#toc4&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end I think it would be better to get the equipment needed...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: You can try with this constructor:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SCLK 4&#xA;#define MOSI 5&#xA;#define CS   6&#xA;#define DC   7&#xA;#define RESET 8&#xA;&#xA;TFT myScreen = TFT(CS, DC, MOSI, SCLK, RESET);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.arduino.cc/en/Reference/TFTLibrary&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/TFTLibrary&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11282" OwnerDisplayName="Luca C." LastActivityDate="2015-07-18T14:39:17.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13543" PostTypeId="1" CreationDate="2015-07-18T15:51:44.310" Score="1" ViewCount="1035" Body="&lt;p&gt;I need to send data from a processing sketch to an Arduino to pass to a function that takes a uint32_t.  How to I send the data in Processing to be run on the Arduino&lt;/p&gt;&#xA;" OwnerUserId="11283" LastActivityDate="2015-09-18T04:39:46.823" Title="Sending data from Processing and receiving as uint32_t" Tags="|data-type|processing-lang|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13545" PostTypeId="1" AcceptedAnswerId="13549" CreationDate="2015-07-18T18:37:54.267" Score="5" ViewCount="11291" Body="&lt;p&gt;I am hitting the limits of my arduino's SRAM and found that SRAM usage can be reduced by storing static stuff in flash memory instead of SRAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project can (optionally) be built with an included SimulatorClass. I use this to 'playback' data at home which I gathered during real-life testing of my project. My project is based on photoelectric sensors, and it's timing-critical, so all timekeeping is done using &lt;code&gt;micros()&lt;/code&gt;, which returns &lt;code&gt;unsigned long&lt;/code&gt; datatype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To simulate these photoelectric sensor triggers, I need an array containing a &lt;code&gt;struct&lt;/code&gt; of 3 variables each:&#xA;unsigned int _iDataPos;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   struct SimulatorRecord&#xA;   {&#xA;      uint8_t iSensorNumber;&#xA;      unsigned long lTriggerTime;&#xA;      uint8_t iState;&#xA;   };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So one these structs is 6 bytes long in my counting (2x &lt;code&gt;uint8_t&lt;/code&gt; = 2 bytes, &lt;code&gt;unsigned long&lt;/code&gt; = 4 bytes).&#xA;A typical set of simulator records I need to use is about 25-30 records long, so worst case scenario the simulator array is 180 bytes in size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I initialize these arrays like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SimulatorRecord SimulatorQueue[28] = {&#xA;      { 1, 41708, 1 }&#xA;      , { 2, 60692, 1 }&#xA;      , { 1, 176848, 0 }&#xA;      , { 2, 197732, 0 }&#xA;      , { 1, 4675580, 1 }&#xA;      , { 2, 4692252, 1 }&#xA;      , { 2, 4830180, 0 }&#xA;      , { 1, 4849032, 0 }&#xA;      , { 2, 9058416, 1 }&#xA;      , { 1, 9074780, 1 }&#xA;      , { 1, 9215868, 0 }&#xA;      , { 2, 9234968, 0 }&#xA;      , { 2, 13497276, 1 }&#xA;      , { 2, 13500924, 0 }&#xA;      , { 2, 13502728, 1 }&#xA;      , { 1, 13514992, 1 }&#xA;      , { 1, 13668000, 0 }&#xA;      , { 1, 13669344, 1 }&#xA;      , { 1, 13681828, 0 }&#xA;      , { 2, 13701464, 0 }&#xA;      , { 2, 18028788, 1 }&#xA;      , { 2, 18034252, 0 }&#xA;      , { 2, 18036540, 1 }&#xA;      , { 1, 18046892, 1 }&#xA;      , { 2, 18160312, 0 }&#xA;      , { 1, 18178224, 0 }&#xA;      , { 1, 20454580, 1 }&#xA;      , { 1, 20456368, 0 }&#xA;   };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my simulator code I then loop through these arrays like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   unsigned int _iDataPos = 0;&#xA;   SimulatorRecord PendingRecord = SimulatorQueue[_iDataPos];&#xA;&#xA;   //main simulator loop&#xA;   if (PendingRecord.lTriggerTime &amp;lt;= lRaceElapsedTime)&#xA;   {&#xA;      //simulate signal&#xA;      digitalWrite(PendingRecord.iSensorNumber, PendingRecord.iState);&#xA;&#xA;      //And increase pending record&#xA;      _iDataPos++;&#xA;      PendingRecord = SimulatorQueue[_iDataPos];&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I've been reading various &lt;code&gt;PROGMEM&lt;/code&gt; tutorials, and storing the &lt;code&gt;SimulatorQueue&lt;/code&gt; array in flash seems to be piece of cake, just change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SimulatorRecord SimulatorQueue[28]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const PROGMEM SimulatorRecord SimulatorQueue[28]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But for the life of me I can't find out how I should change the copying of each array item to the &lt;code&gt;PendingRecord&lt;/code&gt; variable, as my &lt;code&gt;iDataPos&lt;/code&gt; counter increases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I should have mentioned that this simulator class and all it's member functions &amp;amp; variables reside in a seperate *.cpp and *.h file.&#xA;I alreadt found out that since i'm initializing the &lt;code&gt;SimulatorQueue&lt;/code&gt; array in the class itself, and not in the main *.ino file, I should do it like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;constexpr static SimulatorRecord SimulatorQueue[28] PROGMEM = {&amp;lt;structs go in here&amp;gt;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit2: Sample code which reproduces the problem when the simulator array is available here:&#xA;&lt;a href=&quot;http://1drv.ms/1TRwiIB&quot; rel=&quot;noreferrer&quot;&gt;http://1drv.ms/1TRwiIB&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6635" LastEditorUserId="6635" LastEditDate="2015-07-22T22:14:28.663" LastActivityDate="2015-07-22T22:48:00.037" Title="Using PROGMEM to store array of structs" Tags="|flash|progmem|struct|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13546" PostTypeId="2" ParentId="13545" CreationDate="2015-07-18T18:49:13.967" Score="2" Body="&lt;p&gt;Using it with heterogeneous types is trickier, since it has to be copied by hand instead of using one of the &lt;code&gt;pgm_read_*()&lt;/code&gt; macros.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SimulatorRecord PendingRecord;&#xA;memcpy_P(&amp;amp;PendingRecord, &amp;amp;SimulatorQueue[_iDataPos], sizeof(PendingRecord));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-18T18:49:13.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13547" PostTypeId="1" CreationDate="2015-07-18T18:51:11.960" Score="2" ViewCount="1490" Body="&lt;p&gt;I'm trying to send SMS using Arduino Uno v3 and Sony Ericsson K700i. I have a function that converts a text and a number to pdu format but I'm unable to deliver the message. I don't get any error after posting the serial data to phone. Could someone please quide me? &#xA;Here is the function that I use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send_sms(String message, String phone_nr )&#xA;{&#xA; byte original_byte;&#xA;byte newbyte;&#xA;int pdu_length;&#xA;int counter;&#xA;String newphone_nr;&#xA;int numlength;&#xA;&#xA; delay(1000);&#xA;  Serial.begin(9600);  &#xA;  delay(1000);&#xA;  numlength=phone_nr.length()-1;&#xA;  if (numlength% 2 != 0 ) {&#xA;    phone_nr += &quot;F&quot;; &#xA;  }&#xA;  for(int x = 0; x &amp;lt; numlength; x = x+2){&#xA;    newphone_nr.concat(phone_nr.charAt(x+2));&#xA;    newphone_nr.concat(phone_nr.charAt(x+1));&#xA;  }&#xA;&#xA;  //start sending SMS&#xA;  Serial.println(&quot;AT&quot;);  //optional: say hello to the modem&#xA;  delay(3000);&#xA;  Serial.println(&quot;AT+CMGF=0&quot;); //set pdu mode&#xA;  delay(3000);&#xA;  int textlength= message.length()*7/8;   // text message length: number of characters*7/8&#xA;  if (message.length()*7%8 != 0) {&#xA;    textlength++;&#xA;  } &#xA;  if (numlength%2 != 0) {   //if the length of phone number was uneven, it now increases by 1 because of the added &quot;F&quot;&#xA;    pdu_length = (8 + (numlength+1)/2 + textlength);&#xA;  } &#xA;  else { //8 bytes of parameters + (length of phonenumber)/2 + number of bytes in the text&#xA;    pdu_length = (8 + numlength/2 + textlength);&#xA;  }&#xA;&#xA;  Serial.print(&quot;AT+CMGW=&quot;); //message will be stored in the mobile phone - AT+CMGS will send it off.&#xA;  //delay(3000);&#xA;  Serial.println(pdu_length);&#xA;  //delay(100);&#xA;  Serial.print(&quot;001100&quot;);  //these are some parameters which we don't need to bother about&#xA;  //delay(100);&#xA;  if (numlength&amp;lt;16){       //now we have to send the byte containing the length of the phone number in HEX format&#xA;    Serial.print(0);&#xA;  //delay(100);  &#xA;  }        //the byte in HEX format needs to be 2 characters long; if needed we add a 0 in front, e.g. &quot;C&quot; will become &quot;0C&quot;&#xA;  Serial.print(numlength,HEX); //length telnr - this time any additional F is not to be considered&#xA; // delay(100);&#xA;  Serial.print(&quot;91&quot;);     //international format of phone number //81 for national format&#xA;  //delay(100);&#xA;  Serial.print(newphone_nr); //now we send the rearranged phone number&#xA;  //delay(100);&#xA;  Serial.print(&quot;0000AA&quot;); //some more parameters &#xA;  //delay(100);&#xA;  if (message.length()&amp;lt;16){&#xA;    Serial.print(0);&#xA;    //delay(100);&#xA;  }       //a byte in HEX format indicating the length of the text. Again the byte needs to be made of 2 characters&#xA;  Serial.print(message.length(),HEX); &#xA;  //delay(100);&#xA;&#xA;  counter=0;&#xA;  newbyte=0;&#xA;  for (int j=0; j&amp;lt;message.length(); j++) {&#xA;    original_byte = message.charAt(j); //one by one we take each byte out of the original text&#xA;&#xA;    for (int i=0; i&amp;lt;7; i++) {&#xA;      newbyte=newbyte|bitRead(original_byte, i)&amp;lt;&amp;lt;counter;  //take the bits 0 to 6 of the old byte, shift as required for the new byte and add to the new byte&#xA;      counter++;&#xA;      if (counter==8) {&#xA;        counter=0;          //if a new byte is complete, set the counter to 0&#xA;        if (newbyte&amp;lt;16){&#xA;          Serial.print(0);&#xA;         // delay(100);&#xA;        } //each byte in HEX format should consist of 2 characters, if necessary add 0 in front&#xA;        Serial.print (newbyte, HEX); //when the new byte is finished, send it to the mobile phone&#xA;        //delay(100);&#xA;        newbyte=0; // the next new byte will start again from 0&#xA;      }&#xA;    }&#xA;  }&#xA;  if (message.length()*7%8!=0) {    //if there were remaining bits (not enough to form a new byte), these are sent out as the last byte&#xA;    if (newbyte&amp;lt;16){&#xA;      Serial.print(0);&#xA;      //delay(100);&#xA;    } //each byte in HEX format should consist of 2 characters, if necessary add 0 in front&#xA;    Serial.println (newbyte, HEX);&#xA;    //delay(100);&#xA;  }&#xA;  delay (3000);&#xA;  Serial.write(26); //this is a command telling the mobile phone that the end of the transmission has been reached  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Q1: Is there any way I can add service message center as a parameter?&#xA;Q2: How can I make this functionshow the phone response to the commands I give?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="11286" LastActivityDate="2015-07-18T18:51:11.960" Title="Function to send SMS in PDU format" Tags="|arduino-uno|serial|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13549" PostTypeId="2" ParentId="13545" CreationDate="2015-07-18T21:56:31.107" Score="6" Body=" &#xA;&#xA;&lt;p&gt;An easy way of accessing any type of data in PROGMEM is to use this small library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PROGMEM_readAnything.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;  // for type definitions&#xA;&#xA;template &amp;lt;typename T&amp;gt; void PROGMEM_readAnything (const T * sce, T&amp;amp; dest)&#xA;  {&#xA;  memcpy_P (&amp;amp;dest, sce, sizeof (T));&#xA;  }&#xA;&#xA;template &amp;lt;typename T&amp;gt; T PROGMEM_getAnything (const T * sce)&#xA;  {&#xA;  static T temp;&#xA;  memcpy_P (&amp;amp;temp, sce, sizeof (T));&#xA;  return temp;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can put that file into a new tab in your IDE, or make a library by putting it inside a folder called &lt;code&gt;PROGMEM_readAnything&lt;/code&gt; and put that folder inside the &lt;code&gt;libraries&lt;/code&gt; folder, which is inside your sketchbook folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That lets you copy from the memory in PROGMEM (using memcpy_P) into RAM. The template is used to work out how many bytes to copy.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example, using your structure:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PROGMEM_readAnything.h&amp;gt;&#xA;&#xA;struct SimulatorRecord&#xA;{&#xA;  uint8_t iSensorNumber;&#xA;  unsigned long lTriggerTime;&#xA;  uint8_t iState;&#xA;};&#xA;&#xA;const SimulatorRecord SimulatorQueue[28] PROGMEM = {&#xA;      { 1, 41708, 1 }&#xA;      , { 2, 60692, 1 }&#xA;      , { 1, 176848, 0 }&#xA; //    ...   omitted for brevity&#xA;      , { 1, 18178224, 0 }&#xA;      , { 1, 20454580, 1 }&#xA;      , { 1, 20456368, 0 }&#xA;   };&#xA;&#xA;// number of items in an array&#xA;template&amp;lt; typename T, size_t N &amp;gt; size_t ArraySize (T (&amp;amp;) [N]){ return N; }&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  for (int i = 0; i &amp;lt; ArraySize (SimulatorQueue); i++)&#xA;    {&#xA;    SimulatorRecord thisItem;&#xA;    PROGMEM_readAnything (&amp;amp;SimulatorQueue [i], thisItem);&#xA;    Serial.print (i);&#xA;    Serial.print (F(&quot; = &quot;));&#xA;    Serial.print (thisItem.iSensorNumber);&#xA;    Serial.print (F(&quot; / &quot;));&#xA;    Serial.print (thisItem.lTriggerTime);&#xA;    Serial.print (F(&quot; / &quot;));&#xA;    Serial.print (thisItem.iState);&#xA;    Serial.println ();&#xA;    }  // end of for loop&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found that it decreased RAM usage by 166 bytes, which is almost &lt;code&gt;28 * 6&lt;/code&gt; (a couple of bytes must have been used by something).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;noreferrer&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Putting PROGMEM into a class&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In response to some comments below, this explains how to put the constants into a class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alex originally had:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class SimulatorClass&#xA;{&#xA;&#xA;...&#xA;&#xA;   typedef struct SimulatorRecord&#xA;   {&#xA;      uint8_t iSensorNumber;&#xA;      unsigned long lTriggerTime;&#xA;      uint8_t iState;&#xA;   } SimulatorRecord;&#xA;&#xA;   constexpr static SimulatorRecord SimulatorQueue[28] PROGMEM = {&#xA;      { 1, 41708, 1 }&#xA;      , { 2, 60692, 1 }&#xA;   //    ...   omitted for brevity&#xA;      , { 1, 20454580, 1 }&#xA;      , { 1, 20456368, 0 }&#xA;   };&#xA;&#xA;   SimulatorRecord PendingRecord;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putting aside whatever &quot;constexpr&quot; is, you can't put constants inside a class like that. You need to make it static, and have the actual definition elsewhere. So, change the constants to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class SimulatorClass&#xA;{&#xA;&#xA;...&#xA;&#xA;   typedef struct SimulatorRecord&#xA;   {&#xA;      uint8_t iSensorNumber;&#xA;      unsigned long lTriggerTime;&#xA;      uint8_t iState;&#xA;   } SimulatorRecord;&#xA;&#xA;  static const SimulatorRecord SimulatorQueue[28] PROGMEM ;&#xA;&#xA;  SimulatorRecord PendingRecord;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in your main class file (Simulator.cpp in your case):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; const SimulatorClass::SimulatorRecord SimulatorClass::SimulatorQueue[28] PROGMEM = {&#xA;    { 1, 41708, 1 }&#xA;    , { 2, 60692, 1 }&#xA;   //    ...   omitted for brevity&#xA;    , { 1, 20454580, 1 }&#xA;    , { 1, 20456368, 0 }&#xA;   };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That now compiles OK.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-22T22:48:00.037" LastActivityDate="2015-07-22T22:48:00.037" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13550" PostTypeId="2" ParentId="1585" CreationDate="2015-07-18T23:52:32.133" Score="0" Body="&lt;p&gt;{linux}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution for me was to set the correct USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had been previously working with my Uno on USB0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could not upload to my nano as I had it connected on USB1 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In menu: Serial Port -&gt; /dev/ttyUSB1&lt;/p&gt;&#xA;" OwnerUserId="11289" LastActivityDate="2015-07-18T23:52:32.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13551" PostTypeId="1" AcceptedAnswerId="13552" CreationDate="2015-07-18T18:44:27.037" Score="0" ViewCount="2676" Body="&lt;p&gt;My code returns uint8_t format when is cast to char and Display on LCD it works fine but I want to get that scanned code for further processing. not only to display on LCD 16x2 , but it returns some strange symbols. Any Idea?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;hid.h&amp;gt;&#xA;#include &amp;lt;hiduniversal.h&amp;gt; &#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;Usb.h&amp;gt;&#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;hidboot.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;USB     Usb;&#xA;USBHub     Hub(&amp;amp;Usb);&#xA;HIDUniversal Hid(&amp;amp;Usb); &#xA;HIDBoot&amp;lt;HID_PROTOCOL_KEYBOARD&amp;gt;    Keyboard(&amp;amp;Usb);&#xA;&#xA;class KbdRptParser : public KeyboardReportParser&#xA;{&#xA;  void PrintKey(uint8_t mod, uint8_t key);&#xA;protected:&#xA;  virtual void OnKeyDown  (uint8_t mod, uint8_t key);&#xA;  virtual void OnKeyPressed(uint8_t key);&#xA;};&#xA;&#xA;void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)  &#xA;{&#xA;    uint8_t c = OemToAscii(mod, key);&#xA;&#xA;    if (c)&#xA;        OnKeyPressed(c);&#xA;}&#xA;&#xA;/* what to do when symbol arrives */&#xA;void KbdRptParser::OnKeyPressed(uint8_t key)  &#xA;{&#xA;static uint32_t next_time = 0;      //watchdog&#xA;static uint8_t current_cursor = 0;  //tracks current cursor position  &#xA;&#xA;    if( millis() &amp;gt; next_time ) {&#xA;      lcd.clear();&#xA;      current_cursor = 0;&#xA;      delay( 5 );  //LCD-specific &#xA;      lcd.setCursor( 0,0 );&#xA;    }//if( millis() &amp;gt; next_time ...&#xA;&#xA;    next_time = millis() + 200;  //reset watchdog&#xA;&#xA;    if( current_cursor++ == ( DISPLAY_WIDTH + 1 )) {  //switch to second line if cursor outside the screen&#xA;      lcd.setCursor( 0,1 );&#xA;    }&#xA;  char keys=(char) key;&#xA;    Serial.println(keys);&#xA;// char add =keys.indexOf(5)+keys.indexOf(6)+keys.indexOf(7)+keys.indexOf(8);&#xA;    Serial.println(keys);&#xA;    lcd.print(keys);&#xA;};&#xA;&#xA;KbdRptParser Prs;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin( 115200 );&#xA;    Serial.println(&quot;Start&quot;);&#xA;&#xA;    if (Usb.Init() == -1) {&#xA;        Serial.println(&quot;OSC did not start.&quot;);&#xA;    }&#xA;&#xA;    delay( 200 );&#xA;&#xA;    Hid.SetReportParser(0, (HIDReportParser*)&amp;amp;Prs);&#xA;    // set up the LCD's number of columns and rows: &#xA;    lcd.begin(DISPLAY_WIDTH, 2);&#xA;    lcd.clear();&#xA;    lcd.noAutoscroll();&#xA;    lcd.print(&quot;Scan Your Code&quot;);&#xA;    delay( 200 );&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Usb.Task();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11285" OwnerDisplayName="TP Ap" LastEditorUserId="10794" LastEditDate="2015-09-12T00:38:23.063" LastActivityDate="2015-09-12T00:38:23.063" Title="Arduino uint8_t to String or char- retrieve from usb device" Tags="|c++|lcd|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13552" PostTypeId="2" ParentId="13551" CreationDate="2015-07-18T21:13:33.077" Score="0" Body="&lt;p&gt;A unit8_t is an 8 bit unsigned integer - it can have any value between 0 and 255, and can be compared to any numeric value in that range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do &quot;further processing&quot; on the received uint8_t value whether it is a printable ASCII value or not.&lt;/p&gt;&#xA;" OwnerUserId="1498" OwnerDisplayName="Peter Bennett" LastActivityDate="2015-07-18T21:13:33.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13553" PostTypeId="2" ParentId="13551" CreationDate="2015-07-18T21:42:02.187" Score="0" Body="&lt;p&gt;If the symbols look like Japanese, then probably bit 7 of your characters is set to 1. The upper 128 characters are reserved for Katakana in many LCDs. So, if you are sure the characters are correct, you may have to be AND them with 0x7F to assure they are in the right half of the character encoder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do check the requirements of your LCD, and the code in the library to control the display. In one occasion, you added a 5 ms delay, and in other clear(), you didn't. One of the annoyances of LCD displays is that you have to be careful with those delay, else you can land the controller in a strange mode,&lt;/p&gt;&#xA;" OwnerDisplayName="jcoppens" LastActivityDate="2015-07-18T21:42:02.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13557" PostTypeId="1" AcceptedAnswerId="13559" CreationDate="2015-07-19T02:06:35.373" Score="0" ViewCount="3779" Body="&lt;p&gt;I have extracted the following code from the multiwii project. It generates a ~490-500hz pwm signal on pin 6 which is used to drive an esc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to change this frequency down to 50Hz to drive a servo instead. But ive had next to no experience at this level of avr programming, and dont want to loose anymore days to it, if its a dead end. (ie not possible) (i have tried reading various websites on the topic)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { &#xA;    pinMode(6, OUTPUT);&#xA;    TCCR4E |= (1&amp;lt;&amp;lt;ENHC4); // enhanced pwm mode&#xA;    TCCR4B &amp;amp;= ~(1&amp;lt;&amp;lt;CS41); TCCR4B |= (1&amp;lt;&amp;lt;CS42)|(1&amp;lt;&amp;lt;CS40); // prescaler to 16&#xA;    TCCR4D |= (1&amp;lt;&amp;lt;WGM40); TC4H = 0x3; OCR4C = 0xFF; // phase and frequency correct mode &amp;amp; top to 1023 but with enhanced pwm mode we have 2047&#xA;&#xA;    TCCR4C |= (1&amp;lt;&amp;lt;COM4D1)|(1&amp;lt;&amp;lt;PWM4D); // connect pin 6 to timer 4 channel D   &#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    //write out&#xA;    int value = 1500;&#xA;    TC4H = value&amp;gt;&amp;gt;8; &#xA;    OCR4D = (value&amp;amp;0xFF);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the new code so far working off the solution provided below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {   &#xA;    pinMode(6, OUTPUT);&#xA;    TCCR4B &amp;amp;= ~(_BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40));&#xA;    TCCR4B |= _BV(CS43) | _BV(CS41);&#xA;    TCCR4D &amp;amp;= ~(_BV(WGM41) | _BV(WGM40));&#xA;    TC4H = 624 &amp;gt;&amp;gt; 8; // B10 0x2&#xA;    OCR4C = 624 &amp;amp; 0xff;//B1110000 0x70&#xA;    TCCR4C |= (1&amp;lt;&amp;lt;COM4D1)|(1&amp;lt;&amp;lt;PWM4D);&#xA;}&#xA;void loop() {&#xA;    //write out&#xA;    //30 - 60 gives 1000 to 2000 us, but that only allows 30 increments between ??&#xA;    int value = 30;&#xA;    TC4H = value &amp;gt;&amp;gt; 8;&#xA;    OCR4D = value &amp;amp; 0xff;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the wave form i want:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/f1BEv.png&quot; alt=&quot;the wave form i want&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="4024" LastEditDate="2015-07-22T06:46:48.160" LastActivityDate="2015-07-22T06:46:48.160" Title="32u4 timer 4 pwm frequency help" Tags="|pwm|timers|avr|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13558" PostTypeId="1" CreationDate="2015-07-19T02:10:11.410" Score="0" ViewCount="430" Body="&lt;p&gt;I am trying to use &lt;a href=&quot;https://github.com/grintor/QRprint&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt; to print QR codes using Arduino. There is a limit on the number of characters allowed in the string to be printed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printQR(&quot;This is the string to be QR encoded !!! Tralalala. Some other random characters !!!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I scan the generated QR code, the string seems to be truncated. Did anyone run into this before? Or is there any way to get around this issue by raising the number of characters allowed in the string?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11293" LastEditorUserId="4628" LastEditDate="2016-01-15T17:56:14.073" LastActivityDate="2016-01-15T17:56:14.073" Title="QRPrint library characters limit" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13559" PostTypeId="2" ParentId="13557" CreationDate="2015-07-19T04:26:00.883" Score="2" Body="&lt;p&gt;Yeah... sometimes it's easier to scrap what's already there and start fresh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pick a suitable prescaler to get close to the desired cycle length&lt;/li&gt;&#xA;&lt;li&gt;Fine-tune the value in TOP in order to get an exact value&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Assuming this is a 16MHz Leonardo, and we have Fast 10-bit PWM (PWM4x = 1, WGM4x = 0b00) available:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;16MHz / 50Hz / (1 &amp;lt;&amp;lt; 10) = 312.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore we need a prescaler of 512 (CS4x = 0b1010).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;16MHz / 50Hz / 512 = 625&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore we need a TOP of 624 (OCR4C = 624).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR4B &amp;amp;= ~(_BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40));&#xA;TCCR4B |= _BV(CS43) | _BV(CS41);&#xA;TCCR4D &amp;amp;= ~(_BV(WGM41) | _BV(WGM40));&#xA;TC4H = 624 &amp;gt;&amp;gt; 8;&#xA;OCR4C = 624 &amp;amp; 0xff;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you set COM4xn and PWM4x to appropriate values for whichever pin(s) you want to output PWM on, and set OCR4x to a value between 0 and 624 (using TC4H appropriately; see the datasheet for details) to control the duty cycle.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-19T04:26:00.883" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13560" PostTypeId="2" ParentId="13285" CreationDate="2015-07-19T04:47:40.643" Score="0" Body="&lt;p&gt;I can use CD4510 to make a countdown timer, I just need to connect CLOCK INPUT to the Digital IO pins located in the arduino microcontroller and use pulse with modulation (pwm) for the code&lt;/p&gt;&#xA;" OwnerUserId="10809" LastActivityDate="2015-07-19T04:47:40.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13561" PostTypeId="2" ParentId="13558" CreationDate="2015-07-19T05:26:59.303" Score="1" Body="&lt;p&gt;The code in the library truncates to 47 characters for some reason:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void printQR(String message) {&#xA;&#xA;...&#xA;&#xA;  // create QR code&#xA;  message.toCharArray((char *)strinbuf,47);&#xA;  qrencode();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The buffer is actually 116 bytes, oddly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char strinbuf[116];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's a little unclear why the limit of 47, or 116, was chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try changing that line in qrprint.cpp to increase the number from 47 to at least 115.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading some of the comments, I doubt that will help. The QR code looks like it is generated into an internal array, which would have to have some size limits due to the amount of RAM available. The current array size is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char qrframe[600];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is already 1/3 of the available memory on a Uno. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-19T07:49:56.280" LastActivityDate="2015-07-19T07:49:56.280" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13562" PostTypeId="2" ParentId="1585" CreationDate="2015-07-19T06:06:20.810" Score="1" Body="&lt;p&gt;As some of the other answers have said, you may not have soldered on the header pins. You can't just push them into place and hope for the best. See my Pro Mini:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zgG73.jpg&quot; alt=&quot;Arduino Pro Mini&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My soldering is reasonably neat, however you can see the solder come through to the other side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17/some-dude-named-avr-wont-let-me-upload-my-program-aka-avrdude-stk500-getsync&quot;&gt;Some dude named avr won't let me upload my program, aka “avrdude: stk500_getsync(): not in sync: resp=0x00”&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno&quot;&gt;Have I bricked my Arduino Uno?&lt;/a&gt; .&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A lot of the issues in those threads apply to any Arduino.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-07-19T06:06:20.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13563" PostTypeId="1" CreationDate="2015-07-19T06:13:21.817" Score="5" ViewCount="14649" Body="&lt;p&gt;I bought a new OV7670 FIFO camera to connect to my Arduino UNO a few days ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The picture of the cam board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FTzLX.jpg&quot; alt=&quot;Photo of camera board interface pinout&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/zKBs7.jpg&quot; alt=&quot;Photo of camera board Averlogic chip&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=159557.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;forum&lt;/a&gt;, it is nice try but it looks chaotic and confusing with about 50 pages, where you can't find where the questions and where the answers are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found &lt;a href=&quot;https://github.com/ComputerNerd/ov7670-no-ram-arduino-uno&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; library which is for non-FIFO board and could not apply to my project. I also read the OV7670_FIFO and OV7670 and AL422 datasheets and I read I2C protocol and basics; and there are many success story on the internet but there is no schematic on them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is, I can't find any simple example for FIFO with schematic to start with. I don't know if this camera is so new or it is so hard to understand, this problem getting so serious that somebody wrote a book named &quot;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=333334.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Beginning Arduino ov7670 Camera Development&lt;/a&gt;&quot; about it, but I think it is a matter of an Arduino to FIFO cam schematic and example code. I ask if there is a such schematic and code for it on the web or how can I connect them?&lt;/p&gt;&#xA;" OwnerUserId="11186" LastEditorUserId="6936" LastEditDate="2016-01-04T10:54:00.450" LastActivityDate="2017-07-02T06:49:16.027" Title="How to connect new OV7670 FIFO to Arduino?" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13566" PostTypeId="1" AcceptedAnswerId="13595" CreationDate="2015-07-19T10:22:52.887" Score="0" ViewCount="954" Body="&lt;p&gt;I recently purchased Bluno Beetle (basically a smaller Arduino with a BLE chip). It is based on the Bluno: &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Bluno_SKU:DFR0267#Wireless_Programming_via_BLE&quot; rel=&quot;nofollow&quot;&gt;Wiki&lt;/a&gt; I know that its Bluetooth Chip, the TI CC2540, supports the Broadcast mode: &lt;a href=&quot;http://www.ti.com/product/CC2540/description&quot; rel=&quot;nofollow&quot;&gt;Official page&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I can't find any &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Bluno_SKU:DFR0267#AT_Command_List&quot; rel=&quot;nofollow&quot;&gt;AT commands&lt;/a&gt; that would allow me to set it to this mode, does anyone of you have an idea? I am trying to relay the messages they are sending (sensor readings), essentially building an interconnected network.&lt;/p&gt;&#xA;" OwnerUserId="11297" LastActivityDate="2015-07-20T19:10:41.893" Title="Set Bluno Beetle to Broadcast mode" Tags="|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13567" PostTypeId="2" ParentId="13538" CreationDate="2015-07-19T10:47:48.897" Score="0" Body="&lt;p&gt;You can hook up the &quot;Adafruit_ST7735&quot; or from what i later learned after getting my Esplora. Thats when i had my adruino-epiphany. Okay so IF your wondering why im including this super rad Controller shaped arduino, the answer is, its a leonardo. well its just a different flavor of the Atmega32u4 whis is the chip that made ext serial programmers kinda obsolete and makes the uno and megas so unique as well. so with that being said the Esplora has a native language when refering back the tft libraries, but its not too far from a simple (ctrl+F) and replace Esplora references with actual defines and references. and in this case the Leonardo would need to have the icsp header used by the corresponding pins on the display (for this instance of using an SPI connection with the serial display we will not swap the Miso and Mosi  like we would a nother instance.just connect miso to miso and mosi to mosi i usually plug up the whole icsp header and then that wwill leave you with the two pins you MUST DEFINE to make it work which would be :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;// must be an output&#xA;//#define sclk 13    // for MEGAs use pin 52&#xA;//#define mosi 11    // for MEGAs use pin 51&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;define cs 10   // for MEGAs you probably want this to be pin 53&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define dc 9&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define rst 8  // you can also connect this to the Arduino reset&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;// must be an output&#xA;//#define sclk 13    // for MEGAs use pin 52&#xA;//#define mosi 11    // for MEGAs use pin 51&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;define cs 10   // for MEGAs you probably want this to be pin 53&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define dc 9&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define rst 8  // you can also connect this to the Arduino reset&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;// Color definitions&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;define BLACK           0x0000&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define BLUE            0x001F&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define RED             0xF800&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define GREEN           0x07E0&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define CYAN            0x07FF&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define MAGENTA         0xF81F&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define YELLOW          0xFFE0&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;define WHITE           0xFFFF&lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;include &lt;/h1&gt;&#xA;&#xA;&lt;h1&gt;include &lt;/h1&gt;&#xA;&#xA;&lt;p&gt;// Option 1: use any pins but a little slower&#xA;//ST7735 tft = ST7735(cs, dc, mosi, sclk, rst);  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;// Option 2: must use the hardware SPI pins &#xA;// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be &#xA;// an output. This is much faster - also required if you want&#xA;// to use the microSD card (see the image drawing example)&#xA;ST7735 tft = ST7735(cs, dc, rst);&#xA;float p = 3.141592; // value for pi&#xA;int tft_width = 128;&#xA;int tft_height = 160;&#xA;int x1 = 60;&#xA;int y1 = 60;&#xA;int x2 = 20;&#xA;int y2 = 80;&#xA;int ballx = 60;&#xA;int bally = 60;&#xA;int deltay = 1;&#xA;int deltax = 1;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int ball_speed = 24;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int left_score = 4;&#xA;int right_score = 4;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int background_color = 0x00;&#xA;void setup(void) {&#xA;  tft.initR();               // initialize a ST7735R chip&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tft.writecommand(ST7735_DISPON);&#xA;  tft.fillScreen(background_color);&#xA;  delay(700);&#xA;  for(int i = 0; i &amp;lt; 9; i++){&#xA;    pinMode(i,OUTPUT);&#xA;  }&#xA;  for(int i = 0; i &amp;lt; 9; i++){&#xA;    digitalWrite(i,HIGH);&#xA;  }&#xA;  delay(500);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop() {&lt;br&gt;&#xA;  for(int i = 0; i &amp;lt; left_score; i++){&#xA;    digitalWrite(i,HIGH);&#xA;  }&#xA;  for(int i = 0; i &amp;lt; right_score; i++){&#xA;    digitalWrite(i+4,HIGH);&#xA;  }&#xA;  int cur_r = random(20,32);&#xA;  int cur_g = random(55,64);&#xA;  int cur_b = random(10,32);&#xA;  int color = cur_r  | (cur_g &amp;lt;&amp;lt; 5) | (cur_b &amp;lt;&amp;lt; 11); &#xA;  int radius = 4;&#xA;  draw_paddles();&#xA;  draw_ball(color);&#xA;  delay(ball_speed);&#xA;}&#xA;void draw_input_text(){ &#xA;  int cur_x2 =  analogRead(2);&#xA;  int cur_y2 =  analogRead(3);&lt;br&gt;&#xA;  String xs = String(cur_x2);&#xA;  String ys = String(cur_y2);&#xA;  char cx[4];&#xA;  cx[0] = xs.charAt(0);&#xA;  cx[1] = xs.charAt(1);&#xA;  cx[2] = xs.charAt(2);&#xA;  cx[3] =0;&#xA;  char cy[4];&#xA;  cy[0] = ys.charAt(0);&#xA;  cy[1] = ys.charAt(1);&#xA;  cy[2] = ys.charAt(2);&#xA;  cy[3] =0;&#xA;  tft.fillRect(10,20,40,40,background_color);&#xA;  tft.drawString(12,22,cx ,YELLOW);&#xA;  tft.drawString(12,40,cy ,YELLOW);&#xA;}&#xA;void draw_paddles(){&#xA;  int cur_x =  analogRead(0);&#xA;  int cur_y =  analogRead(1);&lt;br&gt;&#xA;  int hval = 620;&#xA;  int lval = 350;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if ( y1 &amp;lt; tft_height - 20  &amp;amp;&amp;amp; cur_y &gt; hval) y1++;&#xA;  else if ( y1 &gt; 0 &amp;amp;&amp;amp; cur_y &amp;lt; lval ) y1--; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;int cur_x2 =  analogRead(2);&#xA;  int cur_y2 =  analogRead(3); &lt;/p&gt;&#xA;&#xA;&lt;p&gt;if ( y2 &amp;lt; tft_height - 20 &amp;amp;&amp;amp; cur_y2 &gt; hval ) y2++;&#xA;  else if (y2 &gt; 0 &amp;amp;&amp;amp; cur_y2 &amp;lt; lval ) y2--; &#xA;  tft.fillRect(2, y1-3, 5, 27, background_color);&#xA;  tft.fillRect(3, y1, 3, 20, YELLOW);&#xA;  tft.fillRect(tft_width-3, y2-3, 5, 27,background_color);&#xA;  tft.fillRect(tft_width-3, y2, 3, 20, YELLOW);&#xA;}&#xA;void draw_ball(int color){&#xA;   int bradius = 6;&#xA;    tft.fillCircle(ballx, bally, bradius , color);&#xA;    ballx += deltax;&#xA;    bally += deltay;&#xA;    if ( ballx &amp;lt; 7 &amp;amp;&amp;amp; bally &gt; y1 &amp;amp;&amp;amp; bally &amp;lt; y1+20) deltax *= -1;&#xA;    else if ( ballx &gt; tft_width-7 &amp;amp;&amp;amp; bally &gt; y2 &amp;amp;&amp;amp; bally &amp;lt; y2+20) deltax *= -1;&#xA;    else if ( bally &amp;lt;= bradius || bally &gt;= tft_height - bradius ) deltay *= -1;&#xA;    if (ballx &amp;lt;=  0 ) {&#xA;      left_score--;&#xA;      tft.drawString(2,42, &quot;Right Won!&quot; ,~background_color,2);&#xA;      tft.drawString(2,62, &quot;Get Ready!&quot; ,CYAN,2);&#xA;      for (int i = 0; i &amp;lt;250; i++){&#xA;        delay(10);&#xA;        draw_paddles();&#xA;      }&#xA;      int cur_r = random(0,26);&#xA;      int cur_g = random(0,30);&#xA;      int cur_b = random(0,18);&#xA;      background_color = cur_r  | (cur_g &amp;lt;&amp;lt; 5) | (cur_b &amp;lt;&amp;lt; 11); &#xA;      tft.fillScreen(background_color);&#xA;      ballx = 64;&#xA;      bally = 80;&#xA;      if (ball_speed &gt; 1) ball_speed--;&#xA;      digitalWrite(left_score,LOW);&#xA;    } else if (ballx &gt;= tft_width  ) {&#xA;      right_score --;&#xA;      tft.drawString(2,42, &quot;Left Won!&quot; ,YELLOW,2);&#xA;      tft.drawString(2,62, &quot;Get Ready!&quot; ,GREEN,2);&#xA;      for (int i = 0; i &amp;lt;250; i++){&#xA;        delay(10);&#xA;        draw_paddles();&#xA;      }&#xA;      int cur_r = random(0,26);&#xA;      int cur_g = random(0,30);&#xA;      int cur_b = random(0,18);&#xA;      background_color = cur_r  | (cur_g &amp;lt;&amp;lt; 5) | (cur_b &amp;lt;&amp;lt; 11); &#xA;      tft.fillScreen(background_color);&#xA;      ballx = 64;&#xA;      bally = 80;&#xA;      if (ball_speed &gt; 1) ball_speed--;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  digitalWrite(4+right_score,LOW);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;enjoy getting that code to fudge around with  i  stole it right form  here &lt;a href=&quot;http://lucidtronix.com/tutorials/7&quot; rel=&quot;nofollow&quot;&gt;http://lucidtronix.com/tutorials/7&lt;/a&gt;&#xA; but the point i had to bring up is that i believe the guy before mentioned that it is a muchslower connectionor process than if it were.....were you saying softwareserial was the option then?&#xA; because im not an explert or novice or maker by any means. but i have picked up along the lines that hardware serial will always trump software serial compilation any day once you get your head wrapped around the brevity of what ports and pins are actually what are used or have the data displayed on the serial ports. and like software is a necessity im afraid, but its as simple as reasigning pins and when that gets too hard going out and just bbuying a mega, haahah hope i sorta helped. id say go out and snag an esplora whilst their like toing a fire clearance sale on the originallt 50$+ boards. but their reference and prebuilt array of sensors is a bit underwhelming for the newbies in what it alll does, but kinda overwhelmine and difficult to transistion onece having looked at some code as it is, but the language is more forg9ving, but i believe their also officially retiring the leonardo espolora and micro series so good luck this tft display kicks bum man and is the only one that hsnt broke&lt;/p&gt;&#xA;" OwnerUserId="11298" LastActivityDate="2015-07-19T10:47:48.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13569" PostTypeId="1" CreationDate="2015-07-19T11:42:10.327" Score="1" ViewCount="953" Body="&lt;p&gt;I am a bit confused. So I want to send messages between two arduinos over RS485, but these are not fixed length, naturally, I have to send the length of the message or add a delimiter to understand that my message has ended. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suppose, now I create a placeholder for the message, and both ends communicating are receiving the placeholder, rather than the message itself. This placeholder is x bytes long always, and each arduino can look it up from its memory what message corresponds to the placeholder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I create a message.h file with contents like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define A &quot;First Message&quot;&#xA;#define B &quot;Second Message&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the two devices are communicating, they send each other A or B, and the Arduino looks it up in its .h file what A and B mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is when the Arduino recieves the A, it recieves a character 'A', but how can I use this to fetch the value assigned to variable A in memory?&lt;/p&gt;&#xA;" OwnerUserId="11301" LastActivityDate="2015-07-19T21:36:48.863" Title="Standard Length Messages over RS-485" Tags="|rs485|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13571" PostTypeId="1" AcceptedAnswerId="13573" CreationDate="2015-07-19T15:33:49.600" Score="1" ViewCount="1945" Body="&lt;p&gt;I need my Arduino Due to work only from external power supply, not from USB power. Is there any way to modify the circuit to allow this? I still need to keep USB communication, but it should happen only when external power is on. Thanks&lt;/p&gt;&#xA;" OwnerUserId="11304" LastActivityDate="2015-07-19T20:06:50.050" Title="How to disable Due USB power?" Tags="|power|arduino-due|usb|" AnswerCount="2" CommentCount="0" ClosedDate="2016-03-26T23:14:48.550" ContentLicense="CC BY-SA 3.0" />
  <row Id="13572" PostTypeId="2" ParentId="13287" CreationDate="2015-07-19T16:22:44.303" Score="0" Body="&lt;p&gt;If you want to count RPM, maybe this link will help you:&#xA;&lt;a href=&quot;http://rjbotics.blogspot.in/2015/07/counting-real-time-rpm-with-ir-sensors.html&quot; rel=&quot;nofollow&quot;&gt;http://rjbotics.blogspot.in/2015/07/counting-real-time-rpm-with-ir-sensors.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6549" LastActivityDate="2015-07-19T16:22:44.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13573" PostTypeId="2" ParentId="13571" CreationDate="2015-07-19T16:53:56.700" Score="2" Body="&lt;p&gt;Disabling USB power is slightly tricky, as the incoming USB power is not only used for potentially powering the system, but it is also used by the various USB interfaces to indicate the presence of a connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way, looking at the schematics of the Due, would be to remove one or both MOSFETs that switch the USB power - that's T1 for the native port and T2 for the ATMega interface.  That will isolate the USB power from the 5V system while keeping it connected to the VBUS pins of the relevant microcontrollers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-19T16:53:56.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13574" PostTypeId="2" ParentId="13569" CreationDate="2015-07-19T17:57:11.537" Score="2" Body="&lt;p&gt;There is no &quot;variable A&quot; - there is only a &lt;em&gt;macro&lt;/em&gt; called &quot;A&quot; which gets replaced by the contents of the #define for &quot;A&quot; at compile time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to remember that the &quot;A&quot; that the Arduino receives is just a number.  It is only us humans who choose to associate that number with the letter A, and write software that takes that number and display it as an A.  The letter A is number 65.  The mapping between numbers and letters is called ASCII - or &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;nofollow&quot;&gt;American Standard Code for Information Interchange&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you do with that number is entirely up to you.  If you want to use it to display pre-defined messages, then there's a number of ways you could do it.  You could:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a series of &lt;code&gt;if&lt;/code&gt; statements to compare the number you have&lt;/li&gt;&#xA;&lt;li&gt;Use a switch/case construct in a similar way&lt;/li&gt;&#xA;&lt;li&gt;Store the messages in an array and use the received number as the index&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For string constants the last option is tricky to get right on an Arduino where there is very limited RAM - you have to ensure that you use PROGMEM and access it properly, and doing that from an array is not as trivial as it would otherwise be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best method would probably be the &lt;code&gt;switch/case&lt;/code&gt; option:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (letter) {&#xA;    case 'A': Serial.println(F(&quot;First Message&quot;)); break;&#xA;    case 'B': Serial.println(F(&quot;Second Message&quot;)); break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-19T17:57:11.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13576" PostTypeId="1" AcceptedAnswerId="13577" CreationDate="2015-07-19T19:51:56.407" Score="1" ViewCount="854" Body="&lt;p&gt;I used simulator &lt;a href=&quot;http://123d.circuits.io&quot; rel=&quot;nofollow&quot;&gt;123d.circuits.io&lt;/a&gt; to create simulation of basic circuit with LDR: LDR is connected to 5V and via 10K resistor to GND. Wire between LDR and resistor is connected to analog pin where I read ADC values and display them using serial monitor. This works fine. But I would like to &lt;em&gt;how to change lighting level of LDR in simulation&lt;/em&gt; because this way LDR shows still the same value. I tried putting LED or light bulb near LDR but it doesn't seem to have any influence. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="11284" LastActivityDate="2016-01-17T07:54:24.667" Title="How to change LDR output in simulator 123D Circuits?" Tags="|simulator|photoresistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13577" PostTypeId="2" ParentId="13576" CreationDate="2015-07-19T20:00:18.477" Score="1" Body="&lt;p&gt;Ok, so I found it myself. You can click on LDR during simulation and bar to adjust lighting appears above it.&lt;/p&gt;&#xA;" OwnerUserId="11284" LastEditorUserId="11284" LastEditDate="2016-01-17T07:54:24.667" LastActivityDate="2016-01-17T07:54:24.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13578" PostTypeId="2" ParentId="13571" CreationDate="2015-07-19T20:06:50.050" Score="2" Body="&lt;p&gt;There is four ways I know of you can do to achieve exactly this :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can remove the usb polyfuse from your board, which will make the usb behave exactly as you need it to. Between the 2 &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoDue_Front.jpg&quot; rel=&quot;nofollow&quot;&gt;two usb connections in this picture &lt;/a&gt; is a smd component marked 501V. This is your polyfuse. Disabling this cuts the +5v line to the board from the usb but leaves the data lines open.&lt;/li&gt;&#xA;&lt;li&gt;If you dont want to physically modify your board, then there is 2 other solutions you could use instead. You can buy a data-only usb cable, but they will probably be expensive and difficult to find.&lt;/li&gt;&#xA;&lt;li&gt;Modify your usb cable. It has 4 pins used by the board, +5v, GND, and the 2 data comms pins. All you have to do here is cut out or block the +5v. The GND pin is still needed as the data pins still draw power off the board.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;The arduino boards auto select a power source(the usb usually) if you have both usb and external power connected at the same time. A way to force the board into switching to the external power source instead, while supplying power to the data lines on the usb is to make sure the dc supply is greater than 6.6v.&lt;/strong&gt; &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: That last one is for the 5v arduino boards, I just remebered the due works on 3.3v instead so this probably won't work on your board&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11306" LastActivityDate="2015-07-19T20:06:50.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13579" PostTypeId="2" ParentId="13569" CreationDate="2015-07-19T21:36:48.863" Score="1" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;write-up about RS485&lt;/a&gt; including a small library to handle this situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be downloaded from &lt;a href=&quot;http://www.gammon.com.au/Arduino/RS485_protocol.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/Arduino/RS485_protocol.zip&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Library features&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Handles &quot;packets&quot; of between 1 and 255 bytes.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Uses a &quot;begin packet&quot; character (Start of Text, STX, 0x02) to reliably indicate that a packet is starting.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Uses an &quot;end packet&quot; character (End of Text, ETX, 0x03) to reliably indicate that a packet is ending.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each data byte (other than STX/ETX) is sent in a &quot;doubled/inverted&quot; form. That is, each nibble (4 bits) is sent twice, once normally, and once inverted. Thus the only valid values for each nibble are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0F, 1E, 2D, 3C, 4B, 5A, 69, 78, 87, 96, A5, B4, C3, D2, E1, F0&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The inverse (ones complement) of 0 is F, hence 0 becomes 0F. The inverse of 1 is E, hence 1 becomes 1E. And so on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This guards somewhat against &quot;bursts&quot; of noise. A burst of either 0s or 1s is unlikely to corrupt a byte preserving this normal/inverse relationship. Also there are only 16/256 valid combinations, so noise has only a 6% chance of becoming a valid byte.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Because of this, also, the STX and ETX characters cannot appear in ordinary data (they are not one of the 16 valid values).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each packet is followed by a CRC (cyclic redundancy check). This is a further test that the packet was received completely. It guards against noise, or possibly some bytes just becoming missing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More details on the linked page, but basically you provide a few functions to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;test if a byte is available for reading&lt;/li&gt;&#xA;&lt;li&gt;read a byte&lt;/li&gt;&#xA;&lt;li&gt;write a byte&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These could be with SoftwareSerial, HardwareSerial, or whatever you choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you either send or receive a &quot;packet&quot; which is the data you want transmitted to the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &quot;blocking&quot; and &quot;non-blocking&quot; version. The blocking version (when reading) waits for an entire packet to arrive. The non-blocking one lets you do other things while waiting for the entire packet.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-19T21:36:48.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13582" PostTypeId="2" ParentId="13160" CreationDate="2015-07-20T00:10:50.890" Score="0" Body="&lt;p&gt;The speed of most servos cannot be changed in your code (unless your code is limiting the speed by changing the position in small increments with long delays between your writes). Most servos, in my experience, try to get to the set position as fast as the physical motors can possibly move while keeping the motion somewhat motors. However, motors can only go so fast, so you are limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note: some servo motors can be powered at higher voltages, but still controlled at 5V. With the increase in voltage, it might allow the motor to go a little faster, although the results will vary based on the servo's electrical characteristics and the motor driver's algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the current, you can buy cheap current sensors online that can be interfaced with the Arduino. You will want to measure the current (in series) flowing either from your power source to the VCC of the stepper, or from the GND of the stepper back to the GND of your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="220" LastActivityDate="2015-07-20T00:10:50.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13583" PostTypeId="2" ParentId="13543" CreationDate="2015-07-20T01:12:48.410" Score="1" Body="&lt;p&gt;I recommend studying up on bitwise shifts (&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;), along with the bitwise OR and AND. They're what you're going to need, especially since &lt;code&gt;atoi()&lt;/code&gt; would only give you a 16 bit, signed integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that your variable's binary is this (split up into 4 segments):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10010010 10110101 01010010 10010100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Sending&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t myVarCopy = myVar;&#xA;for(int i = 0; i &amp;lt; 4; i++) {&#xA;    Serial.write(myVarCopy &amp;amp; 255);&#xA;    myVarCopy = myVarCopy &amp;gt;&amp;gt; 8;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line in the loop modifies the variable by bitshifting right eight to allow us to read the data eight bits at a time. We have to, whenever sending data through the serial port, &quot;trim&quot; any data that is in the 9th digit or above using the &lt;code&gt;&amp;amp; 255&lt;/code&gt; part. This allows us to split this int up into four bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How the &lt;code&gt;myVarCopy&lt;/code&gt; variable would look over the four iterations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;After 1: 00000000 10010010 10110101 01010010 (sent 10010100)&#xA;After 2: 00000000 00000000 10010010 10110101 (sent 01010010)&#xA;After 3: 00000000 00000000 00000000 10010010 (sent 10110101)&#xA;After 4: 00000000 00000000 00000000 00000000 (sent 10010010)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Reading&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t buffer = 0;&#xA;for(int i = 0; i &amp;lt; 4; i++) {&#xA;    buffer = (buffer &amp;gt;&amp;gt; 8) | (Serial.read() &amp;lt;&amp;lt; 24);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code works by adding the newest data onto the digits 25-32 after it moves everything else over eight bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how the &lt;code&gt;buffer&lt;/code&gt; variable would look over the four iterations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;After 1: 10010100 00000000 00000000 00000000&#xA;After 2: 01010010 10010100 00000000 00000000&#xA;After 3: 10110101 01010010 10010100 00000000&#xA;After 4: 10010010 10110101 01010010 10010100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how Processing works, you might have to worry about &lt;strong&gt;&lt;a href=&quot;https://stackoverflow.com/a/701644/1512962&quot;&gt;little/big endian encoding&lt;/a&gt;&lt;/strong&gt; to ensure that your data is in the right order. &lt;strong&gt;Warning:&lt;/strong&gt; I haven't tested these yet as an IDE isn't installed on the computer I'm typing this on. Also, I don't know the exact function calls for Processing, so it might not compile.&lt;/p&gt;&#xA;" OwnerUserId="220" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-07-20T01:12:48.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13584" PostTypeId="1" CreationDate="2015-07-19T19:45:14.030" Score="1" ViewCount="336" Body="&lt;p&gt;I control an analog circuit with Arduino Uno. I want to simulate an Arduino Uno with operational amplifiers (741). Can I simulate Arduino with SPICE?&lt;/p&gt;&#xA;" OwnerUserId="10994" OwnerDisplayName="Νίκος-Μάριος Κοκολάκης" LastEditorUserId="10794" LastEditDate="2015-09-12T00:37:43.873" LastActivityDate="2021-06-10T15:52:43.667" Title="Arduino Uno - Analog Circuit Simulator" Tags="|arduino-uno|hardware|simulator|analog-sampling|op-amp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13585" PostTypeId="2" ParentId="169" CreationDate="2015-07-20T05:42:27.107" Score="2" Body="&lt;p&gt;The &lt;em&gt;entire&lt;/em&gt; premise behind Gravitech's design of the Arduino Nano was for it to be plugged into a &lt;strong&gt;breadboard&lt;/strong&gt;. If done so, then none of the pins are left &lt;em&gt;dangling&lt;/em&gt;. From &lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Arduino's webpage for the Nano&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Nano is a small, complete, and &lt;em&gt;breadboard-friendly&lt;/em&gt; board based on the ATmega328 (Arduino Nano 3.x) or ATmega168 (Arduino Nano 2.x). It has more or less the same functionality of the Arduino Duemilanove, but in a different package. It lacks only a DC power jack, and works with a Mini-B USB cable instead of a standard one. The Nano was designed and is being produced by Gravitech.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://www.gravitech.us/arna30wiatp.html&quot; rel=&quot;nofollow&quot;&gt;Gravitech's webpage for the Nano&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino Nano is a surface mount &lt;em&gt;breadboard&lt;/em&gt; embedded version with&#xA;  integrated USB. It is a smallest, complete, and &lt;em&gt;breadboard friendly&lt;/em&gt;. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Nano’s got the &lt;em&gt;breadboard-ability&lt;/em&gt; of the Boarduino and the Mini+USB&#xA;  with smaller footprint than either, so users have more &lt;em&gt;breadboard&lt;/em&gt;&#xA;  space.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have a Nano in such a &lt;em&gt;dangling&lt;/em&gt; state, then you are using the wrong sort of Arduino board for the wrong purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously a Nano will work just fine when &lt;em&gt;loose&lt;/em&gt; on a surface, i.e. not plugged into a breadboard, but that is not what it was intended for, and maybe you should employ an UNO in its place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you have to use your Nano without a breadboard, then in addition to the wire wrapping, wires with female DuPont connectors, or female header strips, you could just solder wires to the holes in the nano board, if you do not already have header pins already soldered in to them.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-21T14:10:09.300" LastActivityDate="2015-07-21T14:10:09.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13586" PostTypeId="2" ParentId="13584" CreationDate="2015-07-20T08:19:59.713" Score="1" Body="&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; use &lt;a href=&quot;https://en.wikipedia.org/wiki/Ngspice&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Ngspice&lt;/a&gt;.&#xA;From what is written there, the Xspice part could be used for creating a simple model of the Arduino, for checking how the analog part of your circuit interacts with the uC.&#xA;Unfortunately the main site () is down, atm, as many other projects hosted on SourceForge. But it might be worth having a look, once it's back online.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-20T08:19:59.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13587" PostTypeId="2" ParentId="815" CreationDate="2015-07-20T11:26:42.387" Score="5" Body="&lt;p&gt;I use this one, 5V, 3W, very small, and only $3 on Aliexpress.&#xA;&lt;a href=&quot;http://www.hlktech.net/product_detail.php?ProId=54&quot; rel=&quot;noreferrer&quot;&gt;http://www.hlktech.net/product_detail.php?ProId=54&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="777" LastActivityDate="2015-07-20T11:26:42.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13588" PostTypeId="1" AcceptedAnswerId="13589" CreationDate="2015-07-20T12:02:48.573" Score="5" ViewCount="6399" Body="&lt;p&gt;I am trying to read the value of an output pin. online forums say that &lt;code&gt;digitalRead(pinNum);&lt;/code&gt; should work, but that is not the case here. digitalRead always returns 0 (LOW).&#xA;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 22; // or 13, or 3 ...&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(pin,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  digitalWrite(pin,HIGH);&#xA;  delay(100);  &#xA;  Serial.println(digitalRead(pin));&#xA;  delay(100);&#xA;  digitalWrite(pin,LOW);      &#xA;  delay(100);&#xA;  Serial.println(digitalRead(pin));&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;printed values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;0&#xA;0&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10740" LastEditorUserId="10740" LastEditDate="2015-07-20T14:49:58.187" LastActivityDate="2016-10-03T11:59:16.370" Title="Read OUTPUT pin value in Arduino Due" Tags="|pins|arduino-due|" AnswerCount="4" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13589" PostTypeId="2" ParentId="13588" CreationDate="2015-07-20T12:35:25.973" Score="7" Body="&lt;p&gt;That method only works on AVR based systems.  It exploits a &quot;feature&quot; whereby the IO pin, when in OUTPUT mode, is also in INPUT mode at the same time, and reading the pin reads the value that the pin is being driven to by the digitalWrite function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same is not true of the Due, which is an ARM based system.  The IO pins function completely differently and the same &quot;feature&quot; cannot be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will have to remember the state of the pin yourself.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-20T12:35:25.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13592" PostTypeId="1" AcceptedAnswerId="13600" CreationDate="2015-07-20T15:24:49.807" Score="0" ViewCount="228" Body="&lt;p&gt;I want to assign &lt;code&gt;-1&lt;/code&gt; to &lt;code&gt;count&lt;/code&gt; variable again when &lt;code&gt;count == 16&lt;/code&gt; but when I have assigned &lt;code&gt;-1&lt;/code&gt; inside the &lt;code&gt;if&lt;/code&gt; condition I have marked below in the code, the Arduino restarts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone guess what is wrong here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;hid.h&amp;gt;&#xA;#include &amp;lt;hiduniversal.h&amp;gt;&#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;Usb.h&amp;gt;&#xA;#include &amp;lt;usbhub.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;hidboot.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#define DISPLAY_WIDTH 16&#xA;&#xA;// initialize the LCD library with the numbers of the interface pins&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;&#xA;USB     Usb;&#xA;USBHub     Hub(&amp;amp;Usb);&#xA;HIDUniversal Hid(&amp;amp;Usb);&#xA;HIDBoot&amp;lt;HID_PROTOCOL_KEYBOARD&amp;gt;    Keyboard(&amp;amp;Usb);&#xA;&#xA;int count = -1;&#xA;char drawNo[4];&#xA;int m = 0;&#xA;int turn;&#xA;class KbdRptParser : public KeyboardReportParser {&#xA;    void PrintKey(uint8_t mod, uint8_t key);&#xA;protected:&#xA;    virtual void OnKeyDown(uint8_t mod, uint8_t key);&#xA;    virtual void OnKeyPressed(uint8_t key);&#xA;};&#xA;&#xA;void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) {&#xA;    uint8_t c = OemToAscii(mod, key);&#xA;    count++;&#xA;&#xA;    if (c)&#xA;    { OnKeyPressed(c); }&#xA;}&#xA;&#xA;/* what to do when symbol arrives */&#xA;void KbdRptParser::OnKeyPressed(uint8_t key) {&#xA;    static uint32_t next_time = 0;      //watchdog&#xA;    static uint8_t current_cursor = 0;  //tracks current cursor position&#xA;&#xA;    if (millis() &amp;gt; next_time) {&#xA;        lcd.clear();&#xA;        current_cursor = 0;&#xA;        delay(5);    //LCD-specific&#xA;        lcd.setCursor(0, 0);&#xA;    }//if( millis() &amp;gt; next_time ...&#xA;&#xA;    next_time = millis() + 200;  //reset watchdog&#xA;&#xA;    if (current_cursor++ == (DISPLAY_WIDTH + 1)) {    //switch to second line if cursor outside the screen&#xA;        lcd.setCursor(0, 1);&#xA;    }&#xA;&#xA;    int keys = (int) key;&#xA;&#xA;    if (count == 4 | count == 5 | count == 6 | count == 7) {&#xA;        turn++;&#xA;        drawNo[m] = (char)keys;&#xA;        //lcd.print(drawNo[m]);&#xA;        Serial.print(drawNo[m]);&#xA;        Serial.print(m);&#xA;        ++m;&#xA;    }&#xA;&#xA;    if (count == 16) {&#xA;        Serial.println(&quot;Counter equals 16 NOW&quot;);&#xA;        printScreen();&#xA;        delay(200);&#xA;        count = -1; /* &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;Here is the problem*/&#xA;&#xA;        for (int i = 0; i &amp;lt; sizeof(drawNo);  i++) {&#xA;            drawNo[i] = (char)0;&#xA;        }&#xA;    }&#xA;}&#xA;void printScreen() {&#xA;    int j;&#xA;    lcd.print(&quot; DRAW NO : &quot;);&#xA;&#xA;    for (j = 0; j &amp;lt; 4; j++) {&#xA;        lcd.print(drawNo[j]);&#xA;    }&#xA;}&#xA;KbdRptParser Prs;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    Serial.println(&quot;Start&quot;);&#xA;&#xA;    if (Usb.Init() == -1) {&#xA;        Serial.println(&quot;OSC did not start.&quot;);&#xA;    }&#xA;&#xA;    delay(200);&#xA;    Hid.SetReportParser(0, (HIDReportParser *)&amp;amp;Prs);&#xA;    // set up the LCD's number of columns and rows:&#xA;    lcd.begin(DISPLAY_WIDTH, 2);&#xA;    lcd.clear();&#xA;    lcd.noAutoscroll();&#xA;    lcd.print(&quot;Scan Your Code&quot;);&#xA;    delay(200);&#xA;}&#xA;&#xA;void loop() {&#xA;    Usb.Task();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11285" LastEditorUserId="6936" LastEditDate="2015-07-20T21:40:04.657" LastActivityDate="2015-07-20T21:40:04.657" Title="Arduino restarts problem" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13593" PostTypeId="2" ParentId="13592" CreationDate="2015-07-20T15:33:30.077" Score="0" Body="&lt;p&gt;I doubt it is the count. Did you try moving it to above the serial print so that you can be sure of the report?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (count == 16) {&#xA;        count = -1; /* &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;Here is the problem*/       &#xA;        Serial.println(&quot;Counter equals 16 NOW&quot;);&#xA;        printScreen();&#xA;        delay(200);&#xA;&#xA;&#xA;        for (int i = 0; i &amp;lt; sizeof(drawNo);  i++) {&#xA;            drawNo[i] = (char)0;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-07-20T15:33:30.077" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13594" PostTypeId="1" AcceptedAnswerId="13596" CreationDate="2015-07-20T15:29:47.670" Score="1" ViewCount="1902" Body="&lt;p&gt;I am using ATmega8 with 12MHz crystal, on my breadboard. I can use &lt;code&gt;SDA&lt;/code&gt; and &lt;code&gt;SCL&lt;/code&gt; pins with default arduino library &lt;code&gt;wire.h&lt;/code&gt;, and it works. But I want another pins to use I&lt;sup&gt;2&lt;/sup&gt;C protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this &lt;a href=&quot;http://playground.arduino.cc/Main/SoftwareI2CLibrary&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt;, even on real &lt;code&gt;SDA&lt;/code&gt; and &lt;code&gt;SCL&lt;/code&gt; pins, but it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have pull up resistors, I tried with 10k and 4.7k without any success. (But those resistors worked with hardware I&lt;sup&gt;2&lt;/sup&gt;C | TWI)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? (All connections is fine, because hardware TWI works but software does not.) Thank you for your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Fuses are ok, because the Atmega won't respond if I remove the crystal oscillator, the LED blinking duration is ok.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i want to run (that doesn't work):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SDA_PORT PORTC&#xA;#define SDA_PIN 4&#xA;#define SCL_PORT PORTC&#xA;#define SCL_PIN 5&#xA;&#xA;//#define I2C_TIMEOUT 100&#xA;&#xA;#include &amp;lt;SoftI2CMaster.h&amp;gt;&#xA;&#xA;&#xA;uint8_t ADDR  = 0x68;&#xA;&#xA;void setup(void) {&#xA;&#xA;  Serial.begin(19200);&#xA;  Serial.println(&quot;Initializing ...&quot;);&#xA;  i2c_init();&#xA;&#xA;  if (!i2c_start(ADDR | I2C_WRITE)) Serial.println(F(&quot;Device does not respond&quot;));&#xA;  if (!i2c_write(0x00)) Serial.println(F(&quot;Cannot address reg 0&quot;));&#xA;  i2c_stop();&#xA;}  &#xA;&#xA;void loop (void) {&#xA;  unsigned int low0, high0, low1, high1;&#xA;  unsigned int chan0, chan1;&#xA;  unsigned int lux;&#xA;  int state1;&#xA;  int state2;&#xA;&#xA;  delay(1000);&#xA;  i2c_start(ADDR | I2C_WRITE);&#xA;  i2c_write(0x00);&#xA;  i2c_rep_start(ADDR | I2C_READ);&#xA;  low0 = i2c_read(false);&#xA;  high0 = i2c_read(false);&#xA;  low1 = i2c_read(false);&#xA;  high1 = i2c_read(true);&#xA;  i2c_stop();&#xA;  Serial.print(low0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the code with hardware TWI that works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define DS3231_I2C_ADDRESS 0x68&#xA;// Convert normal decimal numbers to binary coded decimal&#xA;byte decToBcd(byte val)&#xA;{&#xA;  return( (val/10*16) + (val%10) );&#xA;}&#xA;// Convert binary coded decimal to normal decimal numbers&#xA;byte bcdToDec(byte val)&#xA;{&#xA;  return( (val/16*10) + (val%16) );&#xA;}&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(19200);&#xA;  pinMode(13, OUTPUT);&#xA;  pinMode(5, INPUT);&#xA;}&#xA;void readDS3231time(byte *second,&#xA;byte *minute,&#xA;byte *hour,&#xA;byte *dayOfWeek,&#xA;byte *dayOfMonth,&#xA;byte *month,&#xA;byte *year)&#xA;{&#xA;  Wire.beginTransmission(DS3231_I2C_ADDRESS);&#xA;  Wire.write(0); // set DS3231 register pointer to 00h&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);&#xA;  // request seven bytes of data from DS3231 starting from register 00h&#xA;  *second = bcdToDec(Wire.read() &amp;amp; 0x7f);&#xA;  *minute = bcdToDec(Wire.read());&#xA;  *hour = bcdToDec(Wire.read() &amp;amp; 0x3f);&#xA;  *dayOfWeek = bcdToDec(Wire.read());&#xA;  *dayOfMonth = bcdToDec(Wire.read());&#xA;  *month = bcdToDec(Wire.read());&#xA;  *year = bcdToDec(Wire.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Schematic is the same as: &lt;a href=&quot;https://www.arduino.cc/en/main/standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/main/standalone&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except instead of 16MHz, I use a 12MHz and ch210x serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino's bootloader works well, I compiled it from source.&lt;/p&gt;&#xA;" OwnerUserId="11318" OwnerDisplayName="ONSC" LastEditorUserId="11763" LastEditDate="2016-09-16T14:23:25.123" LastActivityDate="2016-09-16T14:23:25.123" Title="Software I2C - ATmega8" Tags="|i2c|c|avr|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13595" PostTypeId="2" ParentId="13566" CreationDate="2015-07-20T19:10:41.893" Score="1" Body="&lt;p&gt;It looks like the Bluno only supports the Central and Peripheral roles (i.e. not the Broadcaster and Observer roles.) Keep in mind AT commands are a feature of the firmware, not the actual chip. As such, even if the chip supports a particular mode or role, that doesn't necessarily mean the firmware makes the feature available.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-20T19:10:41.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13596" PostTypeId="2" ParentId="13594" CreationDate="2015-07-20T19:59:20.440" Score="1" Body="&lt;p&gt;OK let me cry till morning...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i was having this issue during day, but the solution was sooo easy&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i need to pay attention more ...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;i2c_start(addr | R/W-bit)&#xA;  Initiates a transfer to the slave device with the (8-bit) I2C address addr. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;what i was trying is to push &lt;strong&gt;7 bit&lt;/strong&gt; address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i hope this might help some others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for help.&lt;/p&gt;&#xA;" OwnerUserId="11318" LastActivityDate="2015-07-20T19:59:20.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13599" PostTypeId="2" ParentId="473" CreationDate="2015-07-20T21:11:40.117" Score="10" Body="&lt;h3&gt;What is a bootloader?&lt;/h3&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And what exactly is the bootloader? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The bootloader is a small piece of code residing in the &quot;high&quot; part of program memory. Normally it is not erased when you upload new sketches. Its purpose it to be activated immediately after a reset (the fuses are configured to commence code at the bootloader address rather than address 0x0000). The bootloader will wait a short time (such as one second) to see if &quot;programming&quot; data is arriving on the serial port.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If so, it reads that data, and decodes it to reprogram the rest of the flash memory. Working in conjunction with the uploading program (normally avrdude) the new sketch is sent via the serial port. The bootloader erases pages of flash memory, and replaces them with the new code. Once done, it executes the new code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If no instructions arrive, the bootloader jumps to address 0x0000 to execute the existing sketch on the board.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;How to replace the bootloader&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;An alternative method to program a bootloader is to use a sketch I wrote a while ago which runs on a:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Uno (or similar, such as Duemilanove)&lt;/li&gt;&#xA;&lt;li&gt;Leonardo&lt;/li&gt;&#xA;&lt;li&gt;Mega2560&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The &quot;programming&quot; board runs the sketch which has bootloaders for a number of boards hard-coded into it. You connect the programming board to the target board (the board wanting the bootloader) with 6 hook-up wires as shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/WA4yE.jpg&quot; alt=&quot;Bootloader programmer for Uno&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That particular photo illustrates one Uno programming another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You run the sketch (operating via the Serial Monitor to give it commands). First it identifies the target chip:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip programmer.&#xA;Written by Nick Gammon.&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x95 0x0F &#xA;Processor = ATmega328P&#xA;Flash memory size = 32768 bytes.&#xA;LFuse = 0xFF &#xA;HFuse = 0xDE &#xA;EFuse = 0xFD &#xA;Lock byte = 0xCF &#xA;Bootloader address = 0x7E00&#xA;Bootloader length = 512 bytes.&#xA;Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...&#xA;Type 'G' to program the chip with the bootloader ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The you  press &lt;strong&gt;G&lt;/strong&gt; to program it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Erasing chip ...&#xA;Writing bootloader ...&#xA;Committing page starting at 0x7E00&#xA;Committing page starting at 0x7E80&#xA;Committing page starting at 0x7F00&#xA;Committing page starting at 0x7F80&#xA;Written.&#xA;Verifying ...&#xA;No errors found.&#xA;Writing fuses ...&#xA;LFuse = 0xFF &#xA;HFuse = 0xDE &#xA;EFuse = 0xFD &#xA;Lock byte = 0xCF &#xA;Done.&#xA;Type 'C' when ready to continue with another chip ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a Uno this takes one second. To program a Mega2560 takes 3 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detailed instructions at &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;noreferrer&quot;&gt;Atmega bootloader programmer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code can be downloaded from &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;noreferrer&quot;&gt;Github: nickgammon/arduino_sketches&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-20T21:18:03.480" LastActivityDate="2015-07-20T21:18:03.480" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13600" PostTypeId="2" ParentId="13592" CreationDate="2015-07-20T21:30:51.350" Score="2" Body="&lt;pre&gt;&lt;code&gt;int m = 0;&#xA;...&#xA;    drawNo[m] = (char)keys;&#xA;...&#xA;    ++m;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No other references to &lt;em&gt;m&lt;/em&gt; in your code. Therefore &lt;em&gt;m&lt;/em&gt; keeps increasing and you are writing outside the bounds of the array &lt;em&gt;drawNo&lt;/em&gt;, corrupting memory.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-20T21:30:51.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13602" PostTypeId="1" CreationDate="2015-07-21T03:30:10.010" Score="0" ViewCount="1826" Body="&lt;p&gt;I am working with a combination of &lt;a href=&quot;https://www.pjrc.com/store/teensypp.html&quot; rel=&quot;nofollow&quot;&gt;Teensy++ 2.0&lt;/a&gt; and &lt;a href=&quot;https://www.sparkfun.com/products/12577&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Bluetooth Modem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino program, inside the loop, continuously reads a sensor value. If the value read is above a threshold, the Arduino transmits a &quot;CHARACTER&quot; over Bluetooth for any receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, inside the same loop, I check for the availability of data, and print the received character. The problem is, the received character is not what is transmitted. The received character is some garbage value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know what is going wrong here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define bluetooth Serial1&#xA;&#xA;#define BAUDRATE 9600&#xA;&#xA;// Analog read 0 is pin 38 &#xA;int sensorValue = 0;&#xA;int SENSOR_ANALOG_READ_PIN = 0;&#xA;int LED = 17;&#xA;&#xA;char toPrint = '\0';&#xA;bool sent = false;&#xA;char state = ' ';&#xA;&#xA;void setup() &#xA;{&#xA;&#xA;// put your setup code here, to run once:&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;&#xA;  Serial.begin(BAUDRATE);&#xA;&#xA;  bluetooth.begin(BAUDRATE);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  sensorValue = analogRead(SENSOR_ANALOG_READ_PIN);&#xA;&#xA;&#xA;  if(value &amp;gt; 500)&#xA;&#xA;  {&#xA;      //Serial.println(&quot;HIGH&quot;);&#xA;&#xA;      digitalWrite(LED, HIGH);&#xA;&#xA;      bluetooth.write(state);&#xA;&#xA;      bluetooth.flush();&#xA;&#xA;      sent = true;&#xA;&#xA;      digitalWrite(LED, LOW);&#xA;&#xA;  }&#xA;&#xA;  else&#xA;&#xA;  {&#xA;&#xA;      delay(100);&#xA;&#xA;  }&#xA;&#xA;  ///////////////////////////////////////////////////////////&#xA;  if((bluetooth.available()) &amp;amp;&amp;amp; (sent == true))&#xA;&#xA;  {&#xA;&#xA;        Serial.println(&quot;printing : &quot;);&#xA;&#xA;        toPrint = (char)bluetooth.read();&#xA;&#xA;        Serial.println((char)toPrint);&#xA;&#xA;        sent = false;&#xA;&#xA;   }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;printing : &#xA;1&#xA;printing : &#xA;ˆ&#xA;printing : &#xA;Ì&#xA;printing : &#xA;¦&#xA;printing : &#xA;È&#xA;printing : &#xA;Ì&#xA;printing : &#xA;Ì&#xA;printing : &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11323" LastEditorUserId="6936" LastEditDate="2015-07-21T19:43:26.130" LastActivityDate="2017-09-23T19:27:44.707" Title="Having issues with Arduino + Bluetooth" Tags="|arduino-uno|bluetooth|data-type|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13603" PostTypeId="1" AcceptedAnswerId="13604" CreationDate="2015-07-21T04:17:09.610" Score="0" ViewCount="440" Body="&lt;p&gt;My Yun has a micro SD card with shared file system using &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ExpandingYunDiskSpace&quot; rel=&quot;nofollow&quot;&gt;ExpandingYunDiskSpace&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to copy my Yun/SD card data &lt;strong&gt;perfectly&lt;/strong&gt; onto my backup Yun/SD card. Because I have made many changes to the filesystem, just re-running the whole process manually would take a long time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What methods can I use to transfer my Yun's data onto my other Yun?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other Yun is brand new (never plugged in), and I have a brand new SD card in there. If I can do a 'bit-perfect' transfer for Yun and Micro SD in one shot that would be ideal.&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-07-21T09:36:24.707" Title="Perfect copy of Yun with Micro SD" Tags="|arduino-yun|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13604" PostTypeId="2" ParentId="13603" CreationDate="2015-07-21T09:31:16.167" Score="0" Body="&lt;p&gt;Copying an SD card (cloning) is easy enough to do.  On Windows you can use &lt;a href=&quot;http://www.raspberry-projects.com/pi/pi-operating-systems/win32diskimager&quot; rel=&quot;nofollow&quot;&gt;Win32DiskImager&lt;/a&gt;.  On Linux and OS X you can either use &lt;code&gt;dd&lt;/code&gt; from the command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(read)&#xA;$ dd if=/dev/sdb of=MySD.img bs=32k&#xA;&#xA;(write)&#xA;$ dd id=MySD.img of=/dev/sdb bs=32k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For OS X the device names will be different, also in Linux you need to check which /dev/sd?? it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also in Linux and OS X there are GUI applications that can do it for you - the Disk Manager in OS X, and &quot;Gnome Disks&quot; in Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is only good for the actual SD card contents though.  If you need to clone the actual Yún itself then it becomes more tricky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately there are tools available to help you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details on how to create and restore a backup of an OpenWRT system (which is what the Yún is) can be found on the OpenWRT Wiki: &lt;a href=&quot;http://wiki.openwrt.org/doc/howto/generic.backup&quot; rel=&quot;nofollow&quot;&gt;http://wiki.openwrt.org/doc/howto/generic.backup&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that again it requires a Linux or OS X (preferably the former) system to do it since it relies on the standard Unix scripting tools and commands that are lacking on a Windows system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to do all the above on a Windows system if you make it look like a Linux system by installing Cygwin.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-21T09:36:24.707" LastActivityDate="2015-07-21T09:36:24.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13606" PostTypeId="2" ParentId="13602" CreationDate="2015-07-21T10:54:00.777" Score="0" Body="&lt;p&gt;Are you sure you have defined your pins properly? I don't see anywhere where you define SENSOR_ANALOG_READ_PIN as an input. If this is the Tx/Rx pin (I forgot the pin configuration), you can define the input pin to be somewhere else to test using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I did and it worked for me, hope it helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This link isn't for your module but the concept should be the same: &lt;a href=&quot;http://www.instructables.com/id/Arduino-AND-Bluetooth-HC-05-Connecting-easily/&quot; rel=&quot;nofollow&quot;&gt;Arduino AND Bluetooth HC-05 Connecting easily&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11326" LastEditorUserId="6936" LastEditDate="2015-07-21T14:46:58.077" LastActivityDate="2015-07-21T14:46:58.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13607" PostTypeId="1" CreationDate="2015-07-21T11:01:28.770" Score="5" ViewCount="14572" Body="&lt;p&gt;I am getting error with this. It is displaying those segments which are not to be displayed, i.e., &lt;code&gt;3.141&lt;/code&gt; is dark and other segments are red.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SevSeg.h&quot;&#xA;&#xA;SevSeg sevseg; //Initiate a seven segment controller object&#xA;&#xA;void setup() {&#xA;    byte numDigits = 4;&#xA;    byte digitPins[] = {2, 3, 4, 5};&#xA;    byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};&#xA;    sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);&#xA;    sevseg.setBrightness(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;    sevseg.setNumber(3141, 3);&#xA;    sevseg.refreshDisplay(); // Must run repeatedly&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11327" LastEditorUserId="6936" LastEditDate="2015-07-21T19:43:04.300" LastActivityDate="2023-06-10T13:12:38.320" Title="How to display a number using SevSeg library on 4 digit 7 segment LED display" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13608" PostTypeId="2" ParentId="13607" CreationDate="2015-07-21T14:19:17.310" Score="2" Body="&lt;p&gt;There are two main types of seven segment display:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Common Anode&lt;/li&gt;&#xA;&lt;li&gt;Common Cathode&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The &lt;em&gt;common&lt;/em&gt; refers to the fact that one end of the LEDs within a digit are linked, and need to be connected to either V&lt;sub&gt;cc&lt;/sub&gt; or GND, depending on the type of the display (see below). The other end of each led (one per segment) is used to switch them on, and it is these that go to the Arduino pins, or LED controller.&lt;/p&gt;&#xA;&lt;h3&gt;Common Anode&lt;/h3&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PmWwm.gif&quot; alt=&quot;Common Anode&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;The common end is connected to the &lt;strong&gt;V&lt;sub&gt;cc&lt;/sub&gt;&lt;/strong&gt; line. If you wish to light a segment, then the input pin for that segment needs to be pulled &lt;code&gt;LOW&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X4slb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X4slb.jpg&quot; alt=&quot;Common Anode 4 digit seven segment display&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Et55I.gif&quot; alt=&quot;Common Anode single digit seven segment display&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://www.physics.mcmaster.ca/phy4d6/MCU/MC9S08/MC9S08QG8%20Code%20Examples_11.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Four multiplexed 7-segment COMMON ANODE LED&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Common Cathode&lt;/h3&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/T2QrE.gif&quot; alt=&quot;Common Cathode&quot; /&gt;&lt;/p&gt;&#xA;&lt;p&gt;The common end is connected to the &lt;strong&gt;GND&lt;/strong&gt; line. If you wish to light a segment, then the input pin for that segment needs to be pulled &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DisqX.gif&quot; alt=&quot;Common Cathode single digit seven segment display&quot; /&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;It sounds as if you have the logic inverted, so the wrong segments are lit, when they should be dark, and vice versa.&lt;/p&gt;&#xA;&lt;p&gt;Either that, or you need to invert the logic in your code, and for example if you are currently pulling a pin &lt;code&gt;LOW&lt;/code&gt; to light up a segment, then you need to change your code to pull the pin &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Image sources:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.electronics-tutorials.ws/blog/7-segment-display-tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Electronics-Tutorials&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://ee.hawaii.edu/%7Esasaki/EE361/Fall06/Lab/7disp.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Common Anode/Cathode 7-segment displays&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-07-21T14:36:24.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13609" PostTypeId="1" AcceptedAnswerId="13617" CreationDate="2015-07-21T16:34:03.423" Score="2" ViewCount="78" Body="&lt;p&gt;I have various subdirectories in &lt;code&gt;{SKETCHBOOK}/hardware/&lt;/code&gt; and &lt;code&gt;{SKETCHBOOK}/libraries/&lt;/code&gt; that contain an &lt;code&gt;examples/&lt;/code&gt; subdirectory. These examples are showing up in &lt;code&gt;File&lt;/code&gt; | &lt;code&gt;Sketchbook&lt;/code&gt; | &lt;code&gt;hardware&lt;/code&gt; and &lt;code&gt;File&lt;/code&gt; | &lt;code&gt;Sketchbook&lt;/code&gt; | &lt;code&gt;libraries&lt;/code&gt;. Is there any way I can prevent them from showing up in that menu without moving them under the system-level Arduino directory?&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="10794" LastEditDate="2015-09-02T01:37:16.250" LastActivityDate="2015-09-02T01:37:16.250" Title="Prevent hardware and library examples from showing in the Sketchbook menu" Tags="|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13610" PostTypeId="1" AcceptedAnswerId="13611" CreationDate="2015-07-21T18:25:23.663" Score="1" ViewCount="49" Body="&lt;p&gt;There is a tutorial in the Arduino website on how to create a library. The tutorial gives the following codes for the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Morse&#xA;{&#xA;  public:&#xA;    Morse(int pin);&#xA;    void dot();&#xA;    void dash();&#xA;  private:&#xA;    int _pin;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the purpose of this line: &lt;code&gt;Morse(int pin);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If any, what is the name of this line?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11333" LastEditorUserId="368" LastEditDate="2015-07-21T18:29:15.100" LastActivityDate="2015-07-21T18:38:09.280" Title="About Making Library" Tags="|c++|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13611" PostTypeId="2" ParentId="13610" CreationDate="2015-07-21T18:32:29.173" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;What is the purpose of this line: &lt;code&gt;Morse(int pin);&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is the method that is called when you create an object of class &lt;code&gt;Morse&lt;/code&gt; when only passing a single &lt;code&gt;int&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Morse somemorse(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;If any, what is the name of this line?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It has multiple names, depending on what aspect you care about:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It is a &lt;strong&gt;constructor&lt;/strong&gt; for the class &lt;code&gt;Morse&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It is a &lt;strong&gt;forward declaration&lt;/strong&gt; for the method &lt;code&gt;Morse::Morse(int)&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-21T18:32:29.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13612" PostTypeId="2" ParentId="13610" CreationDate="2015-07-21T18:32:39.140" Score="1" Body="&lt;pre&gt;&lt;code&gt;Morse(int pin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the &lt;strong&gt;constructor&lt;/strong&gt; for the class, &lt;code&gt;Morse&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The name of this line, and all of the other lines between the curly braces&lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; are &lt;strong&gt;declarations&lt;/strong&gt; of the members of the class &lt;code&gt;Morse&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Morse(int pin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the &lt;em&gt;declaration&lt;/em&gt; of the &lt;em&gt;constructor&lt;/em&gt;, to answer both of your questions in one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Constructors are required pieces of code for Object Oriented Programming. When the constructor is called, it creates an object which is an instance of the class &lt;code&gt;Morse&lt;/code&gt;. In this constructor is where all of the initialisation of the oblject goes. In the case of &lt;code&gt;Morse&lt;/code&gt; it just initialises pin, which is specified in the parameter &lt;code&gt;pin&lt;/code&gt;, by setting it to be an &lt;code&gt;OUTPUT&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is declared here, as a &quot;signpost&quot; if you will, for other parts of the code to know that it exists and is available to be called.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-21T18:38:09.280" LastActivityDate="2015-07-21T18:38:09.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13614" PostTypeId="2" ParentId="4530" CreationDate="2015-07-21T18:54:24.877" Score="-1" Body="&lt;p&gt;I had the same problem with reading GPS-Data on Port 11 while sending APRS-Data out. This code worked for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GPS.end();&#xA;&#xA;aprs_send(); &#xA;while (afsk_busy());&#xA;&#xA;GPS.begin(GPS_BAUDRATE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11337" LastEditorUserId="220" LastEditDate="2015-07-21T19:26:46.147" LastActivityDate="2015-07-21T19:26:46.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13615" PostTypeId="1" CreationDate="2015-07-21T19:13:20.333" Score="0" ViewCount="69" Body="&lt;p&gt;What type of connectors would I use for these buttons?:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/product/1477&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/product/1477&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They sell wires with the connectors already crimped on, but I only need the connectors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://www.jameco.com&quot; rel=&quot;nofollow&quot;&gt;https://www.jameco.com&lt;/a&gt;, but i'm not sure which connector would be right, or what to look for specifically.&lt;/p&gt;&#xA;" OwnerUserId="11338" LastEditorUserId="220" LastEditDate="2015-07-21T19:39:20.407" LastActivityDate="2015-07-21T19:39:20.407" Title="Finding connectors for push button component" Tags="|arduino-uno|button|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13616" PostTypeId="2" ParentId="13615" CreationDate="2015-07-21T19:20:01.590" Score="2" Body="&lt;p&gt;Go down to your local (decently-stocked) hardware store and ask for &quot;quick connect terminals&quot;. From the dimensional drawing you'll need 2mm or 5/64&quot; terminals.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-21T19:20:01.590" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13617" PostTypeId="2" ParentId="13609" CreationDate="2015-07-21T20:43:23.583" Score="0" Body="&lt;p&gt;Looking at the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/2c05841588313918a3fcab7ecbc01023a8621f6f/app/src/processing/app/Base.java#L1618&quot; rel=&quot;nofollow&quot;&gt;code&lt;/a&gt; it is scanning all folders and there is no option to change that behavior. Also looking at the code, it looks like it dumps them into a sub-menu, hiding them away a little further, if the folder is named anything except &quot;examples&quot;, which could be an alternative option for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final option would be to fork your own version and come up with some exclusion logic, maybe with some kind of &quot;.ignore&quot; kind of logic where you can specify folders to exclude form the menu.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-07-21T20:43:23.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13619" PostTypeId="1" CreationDate="2015-07-21T22:35:10.473" Score="-1" ViewCount="1600" Body="&lt;p&gt;What I have done:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made a custom Nanite 841 which uses an ATTINY841 microcontroller. &#xA;I have used the schematics from Wattuino to design my circuit, my PCB was made using a router with all excess copper removed. &#xA;I have built the circuit and have ensured that every component and track does not short circuit. &#xA;I have successfully uploaded the Wattuino bootloader using ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem that I am getting is when the microcontroller is connected to any computer I get an error message saying...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;USB device not recognised&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The device status shows this...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Windows has stopped this device because it has reported problems.&#xA;  (Code 43)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;A request for the USB device descriptor failed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I hope you can help as this is a bit of a bummer after just building my new device. Thank you for your time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nqZWl.png&quot; alt=&quot;PCB Layout of my circuit&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wsynx.png&quot; alt=&quot;Schematic of my circuit&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="11340" LastActivityDate="2015-12-19T03:14:44.377" Title="USB Device not Recognised - Custom Wattuino Nanite 841" Tags="|attiny|hardware|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13620" PostTypeId="1" CreationDate="2015-07-21T23:09:24.343" Score="0" ViewCount="2658" Body="&lt;p&gt;After programming Arduino Nano with the DIY Headtracker code, after trying to plug the Arduino to the receiver and some time, the LED stops flashing and now it's not recognized by the computer anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug it, it only lights the power LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The worst thing is that I've already tried with another Nano and it bricked also, can't use them any more. Anyone know any fix to this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error given when trying to upload the blink sketch to the board...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xb8&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xb8&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11341" LastEditorUserId="10794" LastEditDate="2015-07-21T23:15:54.373" LastActivityDate="2015-10-18T08:04:56.593" Title="Arduino nano stopped working" Tags="|arduino-nano|uploading|ide|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13621" PostTypeId="2" ParentId="13620" CreationDate="2015-07-21T23:23:05.530" Score="0" Body="&lt;p&gt;If you have access to an AVR ICE MKII or an AVRDragon, you could try High Voltage programming. It is, AFAIK, the ultimate way to revive a bricked device. There might be some alternative method to perform HV programming without any of the devices I mentioned (for example with another AVR), but I'm not aware of it, if it exists.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-21T23:23:05.530" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13622" PostTypeId="2" ParentId="13620" CreationDate="2015-07-21T23:59:55.950" Score="1" Body="&lt;p&gt;I suggest you visit the page &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno&quot;&gt;Have I bricked my Arduino Uno?&lt;/a&gt; - whilst you have a Nano and not a Uno, it is the same processor and most of the remarks there will apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Nano page&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It has more or less the same functionality of the Arduino Duemilanove, but in a different package.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have another Uno or similar lying around you could conduct the &quot;chip detector&quot; test described on that page. You could also perform the loopback test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible on the FTDI chip (underneath) is damaged in which case there would be alternatives to using that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-07-21T23:59:55.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13623" PostTypeId="2" ParentId="13619" CreationDate="2015-07-22T00:13:17.433" Score="0" Body="&lt;p&gt;According to &lt;a href=&quot;https://github.com/micronucleus/micronucleus&quot; rel=&quot;nofollow&quot;&gt;Github: micronucleus/micronucleus&#xA;&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Windows machines will need to install the libusb drivers found in the /windows_drivers folder.  Clean Micronucleus devices without uploaded userprogram will not time out and allow sufficient time for proper driver installation. Linux and OS X do not require custom drivers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Make sure you have installed the device drivers.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also you need to attempt an upload &lt;em&gt;shortly&lt;/em&gt; after reset:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The bootloader allows uploading of new firmware via USB. In its usual configuration it is invoked at device reset and will identify to the host computer. If no communication is initiated by the host machine within a given time, the bootloader will time out and enter the user program, if one is present. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See the troubleshooting page &lt;a href=&quot;https://technet.microsoft.com/en-us/library/cc725873%28v=ws.10%29.aspx&quot; rel=&quot;nofollow&quot;&gt;Code 43: Windows has stopped this device because it has reported problems&lt;/a&gt; from Microsoft.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should be able to use a spare Uno or similar device to check the chip response. See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow&quot;&gt;Sketch to detect Atmega chip types&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly you have the &quot;divide clock by 8&quot; fuse set. You could clear that if so.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-22T00:13:17.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13624" PostTypeId="2" ParentId="13557" CreationDate="2015-07-22T03:35:04.437" Score="2" Body="&lt;p&gt;To get finer resolution use Timer 1 - as Ignacio Vazquez-Abrams suggested.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  pinMode (10, OUTPUT);   // OC1B on the Leonardo / Micro&#xA;  TCCR1A = 0;   // stop Timer 1&#xA;  TCCR1B = 0;   //     ditto&#xA;&#xA;  // set up Timer 1&#xA;  TCCR1A = bit (COM1B1) | bit (WGM11) | bit (WGM10);  // toggle OC1B on Compare Match&#xA;  TCCR1B = bit (WGM13) | bit (CS11);   // PWM phase correct, prescaler of 8&#xA;  OCR1A = 20000;  // frequency: 50 Hz&#xA;  OCR1B = 1000;   // duty cycle - 1 ms&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see from the scope output, the pulse width is 1 ms, which extremely conveniently corresponds to the duty cycle of 1000. Thus, therefore, the duty cycle figure is exactly related to microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you can see that the frequency is 50 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kFOiZ.png&quot; alt=&quot;50 Hz Timer 1 example&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This uses a prescaler of 8 to give high resolution. It takes two pulses to make one &quot;cycle&quot; (one on, one off) and thus it effectively divides the system clock by 16. Since the system clock is 16 MHz, that is why one &quot;unit&quot; is 1 µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OCR1A figure is arrived at easily:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1000000 / 50 = 20000  (1 MHz / 50 Hz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can just tweak your desired pulse width knowing that each unit is 1 µs. So for 2 ms OCR1B would need to be 2000.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-22T05:18:40.290" LastActivityDate="2015-07-22T05:18:40.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13625" PostTypeId="1" CreationDate="2015-07-22T12:00:22.153" Score="2" ViewCount="574" Body="&lt;p&gt;Can I combine Leonardo sketch hex file with the Leonardo bootloader hex file?&#xA;I would like to program blank Atmega32U4 with one shot.&lt;/p&gt;&#xA;" OwnerUserId="11351" LastActivityDate="2015-07-22T12:00:22.153" Title="Leonardo sketch and bootloader hex file combination" Tags="|arduino-leonardo|bootloader|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13626" PostTypeId="1" CreationDate="2015-07-22T13:13:43.410" Score="1" ViewCount="2118" Body="&lt;p&gt;Having most of my experience on ATmega chips, and just starting up with Arduino (to reduce hardware development time) I'm happy to see that the usual registers such as &lt;code&gt;TIMSK0&lt;/code&gt;, &lt;code&gt;PCICR&lt;/code&gt;, &lt;code&gt;TCNT1H&lt;/code&gt; and others can be used from the Arduino IDE just as they appear in the Atmel datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Migrating to the Arduino Due, however, came with a shock: the registers specified in the datasheet of the Cortex-M3 are not recognized by the Arduino IDE (although I downloaded the extension necessary for being able to select the Due). I wanted to do something very simple, like configuring a timer. I found &lt;code&gt;TC_CMR0&lt;/code&gt; in the datasheet, but the Arduino IDE doesn't recognize it. I found an example using the Arduino Due with timers in an obscure forum, and they used &lt;code&gt;REG_PWM_CMR0&lt;/code&gt;. I tried it in the Arduino IDE, and it was accepted by the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched the Arduino and other forums, and couldn't find any hint whatsoever about the naming of the registers. Why are the names of the registers different? And can I find a conclusive documentation about the register names, or am I doomed to research each and every one of the hundreds of registers individually?&lt;/p&gt;&#xA;" OwnerUserId="11045" LastActivityDate="2018-01-21T13:01:19.957" Title="Where are the Arduino Due registers?" Tags="|arduino-due|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13627" PostTypeId="1" AcceptedAnswerId="13631" CreationDate="2015-07-22T13:19:11.187" Score="1" ViewCount="1355" Body="&lt;p&gt;I want to stack Ethernet shield and USB host together with my Arduino MEGA 2560.&#xA;Each of these shields works fine separately.&#xA;Is it necessary to contact bootloader pins with each shield and arduino board?&#xA;I have connected and tried, but the problem exists.&lt;/p&gt;&#xA;&lt;p&gt;only one shield works fine at once.(always the sheild that directly connect to the Arduino board).&#xA;How do I resolve this problem ? I want to work all 2 shields at once.&lt;/p&gt;&#xA;&lt;p&gt;these are the sheilds I have used.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://shieldlist.org/circuitsathome/usbhost-v2&quot; rel=&quot;nofollow noreferrer&quot;&gt;Circuits At Home USB Host Shield v2.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://shieldlist.org/arduino/ethernet-v5&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ethernet Shield v5.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="11285" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-12-27T11:13:32.297" Title="Issues with Stacking Ethernet shield and USB Host shield" Tags="|arduino-mega|shields|ethernet|usb|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13628" PostTypeId="1" CreationDate="2015-07-22T13:24:23.703" Score="0" ViewCount="336" Body="&lt;p&gt;I am connecting an Arduino Mega (Crius) to a Intel Embedded processor (Minnowboard) via the following to Peripherals:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Minnowboard USB            -&gt; Arduino      (to flash the micro-controller)&lt;/li&gt;&#xA;&lt;li&gt;Minnowbaord Highspeed UART -&gt; Arduino UART (to communicate)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now both the peripherals are supplying +5V Vcc to the Arduino from the Minnowbaord but via different ports. Both the channels shall always remain connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it safe to power +5V from different ports to the Arduino (because i am technically bypassing all the voltage regulators available on board) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this cause any problems for the Arduino in regards to difference in voltage levels?&lt;/p&gt;&#xA;" OwnerUserId="11270" LastActivityDate="2015-11-19T17:07:50.877" Title="USB and UART simultaneous power to Arduino?" Tags="|arduino-mega|power|usb|communication|uart|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13629" PostTypeId="2" ParentId="13628" CreationDate="2015-07-22T13:46:50.780" Score="1" Body="&lt;p&gt;That's perfectly fine.  As it's the same 5V source the voltage &lt;em&gt;should&lt;/em&gt; be the same and it'll just combine them together as if you had 2 wires in parallel.  However, if there are things like diodes in the path of one connection that causes the voltage to be slightly lower then the increased voltage imposed on the lower voltage side would reverse bias those diodes and end up cutting off that one source, so only one would be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, it's nothing to concern yourself over.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-22T13:46:50.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13630" PostTypeId="2" ParentId="13626" CreationDate="2015-07-22T13:49:15.510" Score="0" Body="&lt;p&gt;I found almost everything I needed to know from the CPUs datasheet &lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  I got the link from the Due page on the Arduino website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For all the registers I was interested in, in my case the Parallel IO registers, it seems to be the case that the Arduino library names them the same as the datasheet, but prepended with &quot;REG_&quot; so PIOC_OWDR (Output Write Disable Reg for PIO port C) becomes REG_PIOC_OWDR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to finding the register names, the datasheet obviously contains a lot more useful information about how the CPU works and how to get the most out of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also found the header files in the Arduino library (arduino\hardware\sam\1.6.4\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_pioc.h for the example above) to be good places to look up what the registers are called.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-07-22T13:49:15.510" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13631" PostTypeId="2" ParentId="13627" CreationDate="2015-07-22T13:51:26.850" Score="0" Body="&lt;p&gt;Both shields are SPI devices, and both shields seem to be hard-wired to use D10 as the chip select line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for you to use both shields at once you will have to either modify one of them or connect the shield via jumper wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to change the chip select connection on one of the shields from D10 to some other pin that is not currently used, and then modify your software (or the library) accordingly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-22T13:51:26.850" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13632" PostTypeId="1" AcceptedAnswerId="13633" CreationDate="2015-07-22T14:28:39.207" Score="0" ViewCount="2492" Body="&lt;p&gt;If I connect a 12V / 12V+ battery to the arduino (uno) analog, will it be damaged ? What if I connect 230-240V to it ? Don't worry I haven't tried it yet. :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11353" LastActivityDate="2015-07-22T21:46:30.363" Title="5V+ Voltage to the arduino analog" Tags="|arduino-uno|power|voltage-level|battery|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13633" PostTypeId="2" ParentId="13632" CreationDate="2015-07-22T14:44:54.193" Score="1" Body="&lt;p&gt;Yes, it will be damaged.  Especially if you connect mains direct to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is designed to take &lt;em&gt;up to&lt;/em&gt; 5V on any of its IO pins.  Any more than that is asking for trouble.  A slight amount above (as in say 5.5V) is usually tolerated OK, but anything more than that WILL cause irreparable damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And with mains, maybe even death.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For low DC voltages, like +12V, you can use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;voltage divider&lt;/a&gt; to reduce the voltage to a 0-5V range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For mains you will need to first reduce it down massively to a safe level (for example through a transformer) then re-scale and adjust it from there.  Note that mains is AC not DC so it has a negative value of voltage as well, so you will either need to rectify and smooth it to create a DC voltage or, if you are interested in the waveform itself, reduce the voltage even more and add a DC offset into it to move the mid-point of the AC waveform up to around 2.5V.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-22T14:44:54.193" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13637" PostTypeId="1" CreationDate="2015-07-22T16:26:55.907" Score="3" ViewCount="266" Body="&lt;p&gt;I have a 9 DOF sensor attached to a BLE chip and Arduino Uno. I want to send the position measurements (i.e. x, y and z coordinates) from the sensor to my iPhone app (Bluefruit LE). The code below starts off well and I am able to see the coordinates on the iPhone. But after showing 6 sets of x-y-z coordinates on the phone all it prints are the x-coordinates. The y and z coordinates do not get shown on the phone at all. I have put the code below (likely not the most efficient code). Any suggestions on how to fix it will be very helpful. thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_BNO055.h&amp;gt;&#xA;#include &amp;lt;utility/imumaths.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;Adafruit_BLE_UART.h&quot;&#xA;&#xA;/* Set the delay between fresh samples */&#xA;#define BNO055_SAMPLERATE_DELAY_MS (100)&#xA;&#xA;#define ADAFRUITBLE_REQ 10&#xA;#define ADAFRUITBLE_RDY 2&#xA;#define ADAFRUITBLE_RST 9&#xA;&#xA;&#xA;Adafruit_BNO055 bno = Adafruit_BNO055(55);&#xA;Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ,     ADAFRUITBLE_RDY, ADAFRUITBLE_RST);&#xA;&#xA;&#xA;void displaySensorDetails(void)&#xA;{&#xA;sensor_t sensor;&#xA;bno.getSensor(&amp;amp;sensor);&#xA;Serial.println(&quot;------------------------------------&quot;);&#xA;Serial.print  (&quot;Sensor:       &quot;); Serial.println(sensor.name);&#xA;Serial.print  (&quot;Driver Ver:   &quot;); Serial.println(sensor.version);&#xA;Serial.print  (&quot;Unique ID:    &quot;); Serial.println(sensor.sensor_id);&#xA;Serial.print  (&quot;Max Value:    &quot;); Serial.print(sensor.max_value);&#xA;Serial.print  (&quot;Min Value:    &quot;); Serial.print(sensor.min_value);&#xA;Serial.print  (&quot;Resolution:   &quot;); Serial.print(sensor.resolution);&#xA;Serial.println(&quot;------------------------------------&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;delay(500);&#xA;}&#xA;&#xA;&#xA;/*&#xA;Arduino setup function (automatically called at startup)&#xA;*/&#xA;&#xA;&#xA;int x = 0;&#xA;int row = 0;&#xA;void setup(void) &#xA;{&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;Orientation Sensor Test&quot;); Serial.println(&quot;&quot;);&#xA;Serial.println(&quot;CLEARDATA&quot;);&#xA;Serial.println(&quot;LABEL,x,y,z&quot;);&#xA;&#xA;/* Initialise the sensor */&#xA;if(!bno.begin())&#xA;{&#xA;/* There was a problem detecting the BNO055 ... check your connections */&#xA;Serial.print(&quot;Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!&quot;);&#xA;while(1);&#xA;}&#xA;&#xA;delay(1000);&#xA;&#xA;/* Display some basic information on this sensor */&#xA;displaySensorDetails();&#xA;bno.setExtCrystalUse(true);&#xA;&#xA;BTLEserial.begin();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;aci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED;&#xA;&#xA;void loop(void) &#xA;{&#xA;&#xA;&#xA;BTLEserial.pollACI();&#xA;&#xA;&#xA;/* Get a new sensor event */ &#xA;sensors_event_t event; &#xA;bno.getEvent(&amp;amp;event);&#xA;&#xA;/* Display the floating point data */&#xA;&#xA;Serial.print(&quot;X: &quot;);&#xA;Serial.print(event.orientation.x, 4);&#xA;Serial.print(&quot;\tY: &quot;);&#xA;Serial.print(event.orientation.y, 4);&#xA;Serial.print(&quot;\tZ: &quot;);&#xA;Serial.print(event.orientation.z, 4);&#xA;Serial.println(&quot;&quot;);&#xA;&#xA;/* This is the code that sends x, y and z coordinates to BLE */&#xA;  uint8_t sendbuffernew_x[20];&#xA;  char buff_x[20] = &quot;&quot;;&#xA;  String xorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.x, 4, 1, buff_x);  //4 is mininum width, 6 is precision&#xA;  xorient += buff_x;&#xA;&#xA;&#xA;  xorient.getBytes(sendbuffernew_x, 20);&#xA;  char sendbuffersizenew_x = min(20, xorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_x, sendbuffersizenew_x);&#xA;  memset(sendbuffernew_x, 0, sizeof(sendbuffernew_x));&#xA;&#xA;  uint8_t sendbuffernew_y[20];&#xA;  char buff_y[20]= &quot;&quot;;&#xA;  String yorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.y, 4, 1, buff_y);  //4 is mininum width, 6 is precision&#xA;  yorient += buff_y;&#xA;&#xA;&#xA;  yorient.getBytes(sendbuffernew_y, 20);&#xA;  char sendbuffersizenew_y = min(20, yorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_y, sendbuffersizenew_y);&#xA;  memset(sendbuffernew_y, 0, sizeof(sendbuffernew_y));&#xA;&#xA;  uint8_t sendbuffernew_z[20];&#xA;  char buff_z[20]=&quot;&quot;;&#xA;  String zorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.z, 4, 1, buff_z);  //4 is mininum width, 6 is precision&#xA;  zorient += buff_z;&#xA;&#xA;&#xA;  zorient.getBytes(sendbuffernew_z, 20);&#xA;  char sendbuffersizenew_z = min(20, zorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_z, sendbuffersizenew_z);&#xA;  memset(sendbuffernew_z, 0, sizeof(sendbuffernew_z));&#xA;&#xA;delay(1000);&#xA;&#xA;delay(BNO055_SAMPLERATE_DELAY_MS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11359" LastEditorUserId="4131" LastEditDate="2016-01-19T17:17:56.553" LastActivityDate="2016-10-15T23:24:15.590" Title="Bluetooth not transmitting refreshed sensor values" Tags="|arduino-uno|bluetooth|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13639" PostTypeId="1" AcceptedAnswerId="13643" CreationDate="2015-07-22T20:19:50.100" Score="1" ViewCount="1484" Body="&lt;p&gt;I'd like to power 30+ LEDs, while having a single LED (at random) flicker every 10-15 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do using an Arduino? I totally new to this so please bear with me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the type of flicker effect I'm hoping to achieve: &lt;a href=&quot;https://www.youtube.com/watch?v=753-lkao8l0&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=753-lkao8l0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks&lt;/p&gt;&#xA;" OwnerUserId="11366" LastActivityDate="2015-07-28T20:52:03.153" Title="Powering 30+ LEDs and flickering one at random" Tags="|led|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13641" PostTypeId="1" AcceptedAnswerId="13642" CreationDate="2015-07-22T20:49:16.603" Score="0" ViewCount="1147" Body="&lt;p&gt;My kids have a few odd inexpensive toys with a soft push-button that will turn on the toy, and subsequent pushes change the toy's mode of operation in some fashon.  A flashlight comes to mind, where the button is pushed once and it turns on, push again and it blinks, and a 3rd time and the light turns off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked inside one of these flashlights, and there's a small blob covering some IC, what looks to be a diode, and the usual connections for the batteries and lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do these circuits &quot;work&quot; without immediately draining the batteries?  I'm looking to mimic this behaviour on a battery powered arduino Uno (or possibly Pro Mini).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What comes to mind is that the button is on an interrupt line, which wakes the system up from some sleep state..  when the button cycles around to an &quot;off&quot; state, the system goes back to sleep.&lt;/p&gt;&#xA;" OwnerUserId="11367" LastEditorUserId="10794" LastEditDate="2015-07-23T21:22:16.807" LastActivityDate="2015-07-23T21:22:16.807" Title="How to mimic soft-power button in inexpensive toys &amp; flashlights?" Tags="|arduino-uno|power|sleep|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13642" PostTypeId="2" ParentId="13641" CreationDate="2015-07-22T21:06:33.957" Score="1" Body="&lt;p&gt;I have a lengthy write-up about saving power at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the sample sketches on that page (Sketch J) does what you ask:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const byte LED = 9;&#xA;&#xA;void wake ()&#xA;{&#xA;  // cancel sleep as a precaution&#xA;  sleep_disable();&#xA;  // precaution while we are doing other things&#xA;  detachInterrupt (0);&#xA;}  // end of wake&#xA;&#xA;void setup () &#xA;  {&#xA;  digitalWrite (2, HIGH);  // enable pull-up&#xA;  }  // end of setup&#xA;&#xA;void loop () &#xA;{&#xA;&#xA;  pinMode (LED, OUTPUT);&#xA;  digitalWrite (LED, HIGH);&#xA;  delay (50);&#xA;  digitalWrite (LED, LOW);&#xA;  delay (50);&#xA;  pinMode (LED, INPUT);&#xA;&#xA;  // disable ADC&#xA;  ADCSRA = 0;  &#xA;&#xA;  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  &#xA;  sleep_enable();&#xA;&#xA;  // Do not interrupt before we go to sleep, or the&#xA;  // ISR will detach interrupts and we won't wake.&#xA;  noInterrupts ();&#xA;&#xA;  // will be called when pin D2 goes low  &#xA;  attachInterrupt (0, wake, FALLING);&#xA;&#xA;  // turn off brown-out enable in software&#xA;  // BODS must be set to one and BODSE must be set to zero within four clock cycles&#xA;  MCUCR = bit (BODS) | bit (BODSE);&#xA;  // The BODS bit is automatically cleared after three clock cycles&#xA;  MCUCR = bit (BODS); &#xA;&#xA;  // We are guaranteed that the sleep_cpu call will be done&#xA;  // as the processor executes the next instruction after&#xA;  // interrupts are turned on.&#xA;  interrupts ();  // one cycle&#xA;  sleep_cpu ();   // one cycle&#xA;&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to when I tested that, it used 0.116 µA when asleep (116 nA). That is well below the rate at which batteries self-discharge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically that code does what you described. It sleeps, when pin D2 goes low it wakes and flashes an LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should point out though that any &quot;development board&quot; Arduino with a voltage regulator, USB interface, and power LED on it will consume &lt;em&gt;considerably more power&lt;/em&gt; because of the current drain they consume.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For low-power applications you need the bare chip (with appropriate supporting circuitry, like decoupling capacitors).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-22T21:21:18.443" LastActivityDate="2015-07-22T21:21:18.443" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13643" PostTypeId="2" ParentId="13639" CreationDate="2015-07-22T21:21:00.723" Score="1" Body="&lt;p&gt;Yes, it is possible, but it's harder than making one LED light up, and then doing the other 29 the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An LED typically draws 20mA, which is within the limit for an Arduino pin (40mA); however, there is also a 200mA limit for all pins together, so you cannot power more than 10 LEDs off the same arduino. Also, the Arduino only has 13 digital pins, and 5 analog pins, a total of 18 pins. This includes 2 pins used for programming your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to run lots of LEDs, the easiest way is running it through an external chip. You can buy a pre-made board e.g. &lt;a href=&quot;https://www.adafruit.com/products/1429&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1429&lt;/a&gt; (24 channel, these can be daisy-chained together for more than 24 LEDs). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can save yourself some money if you can just buy the chip - a DIP chip, or through-hole, will slot directly into a solderless breadboard, and can be soldered onto veroboard later to make your project more permanent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of chips that will do the job, you want an &quot;LED PWM driver&quot; chip - for example, the TLC5940. There is a tutorial for this at &lt;a href=&quot;http://tronixstuff.com/2013/10/21/tutorial-arduino-tlc5940-led-driver-ic/&quot; rel=&quot;nofollow&quot;&gt;http://tronixstuff.com/2013/10/21/tutorial-arduino-tlc5940-led-driver-ic/&lt;/a&gt; - PWM just means you can control the brightness of each LED (individually). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make your project more permanent, you can solder a board of your own - find someone who can solder (your local makerspace/hackspace will be glad to help, I'm sure!) to teach you the basics, don't burn yourself. The easiest way is to use stripboard (aka Veroboard), this also means you can solder the resistors on to the same board (the LEDs too, if you like!). It sounds very intimidating, but it's not hard to learn. You can then buy PWM chips (make sure you get through-hole, aka &quot;DIP&quot; chips - &lt;a href=&quot;https://en.wikipedia.org/wiki/Dual_in-line_package&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Dual_in-line_package&lt;/a&gt; ) rather than &quot;surface mount&quot; chips. The chips are sensitive to heat, so to start you might want to solder on sockets (see same wiki page), then you can slot the chips in later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should consider very carefully your power supply - find out how many milliamps (or amps) it can provide - every (lit) LED will draw 20 milliAmps, and the Arduino is rated for 200mA, so if you want more than 9 LEDs, you will want an external power source, with an appropriate rating - 500mA = 0.5 amp will drive 24 LEDs. In this case, do NOT use the 2.1mm jack on the Arduino to power it; the transformer will overheat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. - you will be able to control the exact brightness of each LED independently. Also, if you use RGB leds, and use 3 pins on the IC to drive each LED, then you will be able to control the exact colour of each LED too!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-22T21:21:00.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13644" PostTypeId="2" ParentId="13632" CreationDate="2015-07-22T21:46:30.363" Score="2" Body="&lt;p&gt;For the 12 V battery, let's assume it might get up to 15 to 20 V when charging, so we need a voltage divider to divide that down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BbuxF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BbuxF.png&quot; alt=&quot;Voltage divider&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The zener diode is there to clamp the input to no more than 5.1 V in case of spikes or other damaging things on the input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage divider will divide down to 25% of the input, ie.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output = R2 / (R1 + R2) = 10 / (30 + 10) = 0.25&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now if you measure 5 V on the analog input you know you have 20 V on the battery. Thus you can scale your calculations appropriately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A more common value would be a 33 k resistor, in which case redo the calculation and scale accordingly).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For 240 V I strongly advise against trying something like that with bigger resistors. For one thing, 240 V RMS will have 240 * sqrt (2) = &lt;strong&gt;340 V&lt;/strong&gt; peak to peak. And that is both negative and positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A suitable approach would be to run through a small transformer, which will reduce the voltage and also isolate you from (almost) certain death.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to that you would need to rectify the resulting voltage (say, 12 V) so that you don't put negative voltages into your input pin. And on top of that filter it so smooth out the peaks and troughs. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-22T21:46:30.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13645" PostTypeId="2" ParentId="3042" CreationDate="2015-07-22T23:48:08.070" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;You had:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void receiveEvent(int howMany)&#xA; {&#xA;   {         &#xA;         if(Wire.available()){&#xA;           char c = Wire.read(); &#xA;           Serial.print(c);&#xA;           if(c == 's'){&#xA;             int x = Wire.read();&#xA;             Serial.println(x);&#xA;&#xA;             //transmit to master &#xA;             Wire.beginTransmission(3);&#xA;             Wire.write(1);&#xA;             Wire.endTransmission();&#xA;&#xA;           }else{&#xA;             Wire.read();&#xA;           }&#xA;         }&#xA;&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are a number of problems with your slave code.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Don't do Serial prints in an ISR (interrupt service routine)&lt;/li&gt;&#xA;&lt;li&gt;Don't do beginTransmission / endTransmission in a receive event.&lt;/li&gt;&#xA;&lt;li&gt;Don't do any writes&lt;/li&gt;&#xA;&lt;li&gt;To send data back use a requestEvent not a receiveEvent.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Better would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// add in setup()&#xA;Wire.onRequest (requestEvent);  // interrupt handler for when data is wanted&#xA;&#xA;...&#xA;&#xA;&#xA;volatile byte what;&#xA;&#xA;void receiveEvent(int howMany)&#xA;{&#xA;  if (howMany &amp;lt; 2)&#xA;    return;&#xA;&#xA;  char c = Wire.read ();&#xA;  if (c != 's')&#xA;    return;&#xA;&#xA;  what = Wire.read ();  // remember what we got&#xA;}  // end of receiveEvent&#xA;&#xA;void requestEvent()&#xA;{&#xA;  Wire.write (1);  // return a response&#xA;}  // end of requestEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the Wire.requestFrom has only one Wire.write. I need multiple Wire.write which is not supported so are there any workarounds?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Batch up the response and do one write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void requestEvent ()&#xA;  {&#xA;  byte buf [4] = { 1, 2, 3, 4 };&#xA;  Wire.write (buf, sizeof buf);   // send response&#xA;  }  // end of requestEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There are a lot of examples at &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C - Two-Wire Peripheral Interface - for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-22T23:48:08.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13646" PostTypeId="1" AcceptedAnswerId="13650" CreationDate="2015-07-23T01:21:00.280" Score="1" ViewCount="631" Body="&lt;p&gt;Say I have given the robot a map of the place, it needs to navigate it. I need a odometer to keep track of its current position in the map. I need it to be precise up to a cm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I simply use the motor's RPM and the diameter of the wheel to calculate how much distance the robot has travelled, or is there any catch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched Google and could not find any odometer small enough for my robot. Most of them are for bicycles.&lt;/p&gt;&#xA;" OwnerUserId="11346" LastActivityDate="2015-07-23T04:59:34.100" Title="How do I make/get a odometer for a lunch box sized robot?" Tags="|arduino-uno|robotics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13647" PostTypeId="2" ParentId="13641" CreationDate="2015-07-23T02:15:07.763" Score="0" Body="&lt;p&gt;I have made a circuit in the past that does more or less this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tOB8A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tOB8A.png&quot; alt=&quot;Latch Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two switches in the diagram - the one on the top right turns the circuit on, and the one lower-middle turns it off. Once turned on, it will stay on until the bottom switch is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two resistors bottom left, and the switch at the bottom, represent your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, this diagram is OUTSIDE the arduino - it provides power TO the Arduino (and any other components relating to your project). That is, the bottom of the 1MOhm resistor, and the bottom of the left transistor, connect to the power pin on the Arduino. Those two resistors don't literally, exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works as follows: The transistors do pretty much all the work. Both transistors work as switches. At the start (as shown in the diagram), both transistors have the same voltage at the base, and the emitter (the top one +5v between top and center/left; the bottom one 0v between center/right and bottom). This turns both switches off, and preserves the status quo, and consuming nearly no power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as the switch at the top is closed, the base (center/right) of the lower transistor is pulled up to +5V, switches this transistor on, and power can flow from this collector to the emitter. This means power can flow through the TOP transistor from emitter (top) to base (center/left), switching on the TOP transistor. This allows power to flow from the emitter (top) to collector (bottom). This takes over from the pushbutton, keeping the bottom transistor on. This is the other stable state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point, power goes to the Arduino (bottom two resistors, representing load, and bottom switch, which is one of the pins on the Arduino. This pin should be set to &quot;high impedance&quot; until the Arduino wants to switch itself off, then it should go low.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I built the top part of the circuit, with an LED for the bottom half (both switches were just wires), and it worked, but I'd have to consider what would happen if the arduino pin is high or low while the top button is being pressed.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-23T02:15:07.763" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13648" PostTypeId="2" ParentId="13637" CreationDate="2015-07-23T03:47:22.520" Score="1" Body="&lt;p&gt;That's an incredibly complex way of outputting a floating point number as a string. You may possibly be fragmenting RAM with your use of String, and those String additions. Try replacing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  uint8_t sendbuffernew_x[20];&#xA;  char buff_x[20] = &quot;&quot;;&#xA;  String xorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.x, 4, 1, buff_x);  //4 is mininum width, 6 is precision&#xA;  xorient += buff_x;&#xA;&#xA;&#xA;  xorient.getBytes(sendbuffernew_x, 20);&#xA;  char sendbuffersizenew_x = min(20, xorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_x, sendbuffersizenew_x);&#xA;  memset(sendbuffernew_x, 0, sizeof(sendbuffernew_x));&#xA;&#xA;  uint8_t sendbuffernew_y[20];&#xA;  char buff_y[20]= &quot;&quot;;&#xA;  String yorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.y, 4, 1, buff_y);  //4 is mininum width, 6 is precision&#xA;  yorient += buff_y;&#xA;&#xA;&#xA;  yorient.getBytes(sendbuffernew_y, 20);&#xA;  char sendbuffersizenew_y = min(20, yorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_y, sendbuffersizenew_y);&#xA;  memset(sendbuffernew_y, 0, sizeof(sendbuffernew_y));&#xA;&#xA;  uint8_t sendbuffernew_z[20];&#xA;  char buff_z[20]=&quot;&quot;;&#xA;  String zorient = &quot;&quot;;&#xA;  dtostrf(event.orientation.z, 4, 1, buff_z);  //4 is mininum width, 6 is precision&#xA;  zorient += buff_z;&#xA;&#xA;&#xA;  zorient.getBytes(sendbuffernew_z, 20);&#xA;  char sendbuffersizenew_z = min(20, zorient.length());&#xA;&#xA;&#xA;  // write the data&#xA;  BTLEserial.write(sendbuffernew_z, sendbuffersizenew_z);&#xA;  memset(sendbuffernew_z, 0, sizeof(sendbuffernew_z));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  char buff[10];&#xA;&#xA;  dtostrf(event.orientation.x, 4, 1, buff); &#xA;  BTLEserial.write(buff, strlen (buff));&#xA;  dtostrf(event.orientation.y, 4, 1, buff); &#xA;  BTLEserial.write(buff, strlen (buff));&#xA;  dtostrf(event.orientation.z, 4, 1, buff);&#xA;  BTLEserial.write(buff, strlen (buff));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-23T03:47:22.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13649" PostTypeId="2" ParentId="13646" CreationDate="2015-07-23T03:55:00.013" Score="0" Body="&lt;p&gt;I think the catch is that the wheel will slip, particularly when starting up. The slightest slip and you are counting a rotation that didn't move the robot forwards. Also if it skids when stopping that is more movement that you didn't detect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are probably best off with a non-powered wheel (stuck out the side perhaps?) which has the task of only detecting movement. Perhaps put a rubber tire on it to get a good grip. You could connect a rotary encoder to the axle which could count the amount it has turned. There are rotary encoders which do not have friction (eg. optical or magnetic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the robot has some non-powered wheels (like a rear wheel) then that could be a good place to measure turns, as it wouldn't slip as much because it isn't under power. You might be able to detect the amount it has turned, for example if it had suitable holes that you could shine a light-detector through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively if the area is small enough use a distance sensor (like a sonar) but that probably wouldn't be accurate enough.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-23T03:55:00.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13650" PostTypeId="2" ParentId="13646" CreationDate="2015-07-23T04:59:34.100" Score="3" Body="&lt;p&gt;I had the idea to use a computer mouse (optical) to do this - cheap, easily available. You would need two, if you want to be able to measure turning rate, one on the left and one on the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't even need the whole mouse - if you pull it apart you can ditch the case, the buttons, and about half the circuitry. You will need to do some hacking to figure out how it works, but I doubt you'll find a cheaper odometer that is anywhere near as accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I pulled one apart, then got distracted on another project, but I can't think of a reason why it wouldn't work.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-23T04:59:34.100" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13651" PostTypeId="2" ParentId="13639" CreationDate="2015-07-23T05:00:36.117" Score="1" Body=" &#xA;&#xA;&lt;p&gt;I've successfully set up a flickering test with 32 LEDs, based on &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using a 74HC595 output shift register as a port-expander&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZcRXU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZcRXU.jpg&quot; alt=&quot;4 x 74HC595 chips and 32 LEDs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Demo of the overall speed (but not the flickering effect): &lt;a href=&quot;https://vimeo.com/80329252&quot; rel=&quot;nofollow noreferrer&quot;&gt;Vimeo - Shift Register Demo with 32 LEDs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That uses 4 x 74HC595, 32 LEDs, and 32 resistors, plus some decoupling capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test sketch which &lt;em&gt;does&lt;/em&gt; flicker one and leave the rest alone:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;const byte LATCH = 10;&#xA;const byte numberOfChips = 4;&#xA;byte LEDdata [numberOfChips];  // initial pattern&#xA;&#xA;void refreshLEDs ()&#xA;  {&#xA;  digitalWrite (LATCH, LOW);&#xA;  for (byte i = 0; i &amp;lt; numberOfChips; i++)&#xA;    SPI.transfer (LEDdata [i]); &#xA;  digitalWrite (LATCH, HIGH);&#xA;  } // end of refreshLEDs&#xA;&#xA;void setup ()&#xA;{&#xA;  SPI.begin ();&#xA;}  // end of setup&#xA;&#xA;void showPattern (unsigned long patt)&#xA;  {&#xA;  LEDdata [0] = patt &amp;amp; 0xFF;&#xA;  LEDdata [1] = (patt &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&#xA;  LEDdata [2] = (patt &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;&#xA;  LEDdata [3] = (patt &amp;gt;&amp;gt; 24) &amp;amp; 0xFF;&#xA;  refreshLEDs ();&#xA;  } // end of showPattern&#xA;&#xA;const int whichFlicker = 12;  // which LED to toggle&#xA;unsigned long pattern = 0xFFFFFFFF;  // pattern for other LEDs&#xA;&#xA;void loop ()&#xA;{&#xA;  pattern ^= 1UL &amp;lt;&amp;lt; whichFlicker;&#xA;  showPattern (pattern);&#xA;  delay (100);&#xA;  pattern ^= 1UL &amp;lt;&amp;lt; whichFlicker;&#xA;  showPattern (pattern);&#xA;  delay (20);&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The flickering is quite fast, but it isn't PWM. If you make the delays lower, the flickering just becomes a duller light, so I think by getting the timing right you could get flickering going fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring (in part) is: &lt;a href=&quot;https://i.stack.imgur.com/tGrfq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tGrfq.png&quot; alt=&quot;74HC595 schematic&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest is similar. Of course, you need current-limiting resistors for the LEDs (one each). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the 595 chips from eBay for around $US 1.70 for 20 of them. LEDs are cheap. Resistors are cheap.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-23T05:00:36.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13652" PostTypeId="2" ParentId="9533" CreationDate="2015-07-23T07:06:58.797" Score="0" Body="&lt;p&gt;I looked at this question as I too plan to drive a Sharp Memory LCD manually with my own code at some point.  From your question and comments I think you are going about it the wrong way, even if you are already very proficient with the electronics side of the task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned, the breakout board is the easiest way to connect the screen and the library is the easiest way to program it.  I suggest you use both &lt;em&gt;initially&lt;/em&gt; and then replace them one by one.  I did this when driving a 32x32 LED matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have a little bit of code running that displays what you want on the screen, try removing the breakout board and wiring the display yourself without changing the code at all.  If the display is not what you expect, you know the problem is in the wiring so you don't waste time looking into your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the wiring is sorted, start on the driver code.  Leave the wiring and your code that makes the display show what you want untouched so that you know any problems are in your driver code.  The other advantage of this is that you have the working library as reference for how the screen works and what signals to send with what sort of timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a pointer to why your code is not doing what you expect, I &lt;em&gt;think&lt;/em&gt; you may be misunderstanding how the screen works.  Your question and code suggest you may be trying to display ASCII characters on the screen which I believe can be done easily with some LCD displays but I'm fairly sure that these LCDs are not character based - you have to manually set or clear each individual dot.  I think the minimum number of dots you can set at a time is a full single line of the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code you have a delay of 3000ms after every byte send.  At that rate it would take 2mins 30secs just to transfer the data for a single line of the screen so maybe you are sending the correct data, but are not waiting long enough to see the results.  I've also read that you have to do something (sorry, not quite sure what) at least once per second to prevent problems with the screen - this suggests that taking over 2mins to send a line of data could not work as you expect.&lt;/p&gt;&#xA;" OwnerUserId="8616" LastActivityDate="2015-07-23T07:06:58.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13653" PostTypeId="1" AcceptedAnswerId="13667" CreationDate="2015-07-23T10:57:46.590" Score="2" ViewCount="5868" Body="&lt;p&gt;Background: I am trying to port &lt;a href=&quot;http://cerebralmeltdown.com/Sun_Tracking_and_Heliostats/&quot; rel=&quot;nofollow&quot;&gt;this solar tracker code&lt;/a&gt; by Gabriel Miller to run on the ESP8266. Now I'm not a particularly great coder, but I'd like to give it an honest try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of recently, the ESP8266 can be natively programmed &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;using the Arduino IDE and code base&lt;/a&gt;. Which is pretty convenient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SO. The solar tracker code written by Gabriel works on the Arduino Uno and the Arduino Mega. The Mega version of the code has a high-precision calculation library called 'BigNumber' to calculate the Sun's position in the sky to a pretty precise degree. My question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I've read, the ESP8266 is supposed to be a 32-bit microprocessor, so (I assume?) it should be able to handle high-precision numbers without using the BigNumber library; so, how do I check what's the highest numerical precision that the ESP8266 can support? That way I could theoretically just copy the equations over to the ported program rather than having to rewrite the BigNumber library.&lt;/p&gt;&#xA;" OwnerUserId="11375" LastActivityDate="2015-07-24T07:41:09.053" Title="How much numerical precision can the ESP8266 achieve?" Tags="|arduino-mega|arduino-ide|esp8266|solar|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13654" PostTypeId="2" ParentId="13653" CreationDate="2015-07-23T13:00:58.860" Score="3" Body="&lt;p&gt;There's not really any difference in numerical precision.  What you do get with 32-bit though is &lt;em&gt;faster&lt;/em&gt; operations on larger data types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, to add two 32-bit numbers together (uint32_t) would take many operations on an 8-bit CPY, whereas on a 32-bit CPU it would just take a couple (only one to do the actual addition - a couple to load/save the values to memory).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One key difference, though, is that (to save space) the AVR system has &lt;em&gt;double precision float&lt;/em&gt; values turned off and aliased to &lt;em&gt;single precision float&lt;/em&gt; values.  This is purely a software feature and has nothing really to do with the hardware.  On 32-bit systems that is normally not done, so you can use &lt;code&gt;double&lt;/code&gt; instead of &lt;code&gt;float&lt;/code&gt; to increase precision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However: While &lt;code&gt;double&lt;/code&gt; is more accurate than &lt;code&gt;float&lt;/code&gt;, it is still not precise.  All floating point values, regardless of precision, are only ever an approximation.  For that reason it is often preferred to use &lt;em&gt;integer&lt;/em&gt; mathematics, and that is where libraries like BigNumber come in handy.  They allow you to (as the name suggests) work with much bigger numbers, which is good when dealing with integers when you want a high precision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you could measure distance in &lt;em&gt;km&lt;/em&gt;.  Say something is 18.329846283746km away.  You could store that as a single precision floating point value and it would end up as 18.329845428467.  As a double precision it would end up as 18.3298462837, which is closer, but still not right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could represent it as &lt;em&gt;meters&lt;/em&gt; instead of &lt;em&gt;km&lt;/em&gt;.  So your 18.329846283746km would be 18329.846283746m.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about if you represented it as &lt;em&gt;mm&lt;/em&gt; instead?  18329846.283746mm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say, why don't we go smaller?  Micrometers? 18329846283.746µm&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't like that decimal point still.  What's smaller than µm? nanometers of course!  That would be 18,329,846,283,746nm.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh look, we have an integer value.  However that integer value is too big to fit in a 32-bit number even, which has a maximum of 4,294,967,295.  You could try using a 64-bit number (uint64_t) if the compiler you have supports it, which on both 8-bit and 32-bit systems would need multiple operations to work with (though less on the 32-bit), or you could use a library like BigNumber to deal with it all for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using that method you start out by stating &quot;I want to work in this fixed resolution and I want 100% precision within that resolution&quot;, rather than saying &quot;I want to work with these values and I hope you'll get it vaguely right&quot;, which is far from ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also working with integer values is generally considerably faster than working with floating point values unless the CPU has a floating point unit available to do the heavy work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the difference between an 8-bit and a 32-bit system has nothing to do with the precision that is available to you, but everything to do with how fast operations at different precisions take to perform.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-07-23T13:00:58.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13655" PostTypeId="2" ParentId="13639" CreationDate="2015-07-23T18:40:25.737" Score="0" Body="&lt;p&gt;The other answers use other components to achieve more LEDs. Part of an led is its a diode. You can use this property to link 2 LEDs together and use a high or a low signal to light one. This has a limitation that you can't light both at the same time. But with lighting both for 50% of the time with a short time between each cycle will illuminate both of them. ( though obviously not as bright as if they were powered 100% of the time. )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea can be extended into a grid to get more LEDs per pin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though not an ardiuino its the same chip using the technique mentioned here &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nerdkits.com/videos/ledarray2/&quot; rel=&quot;nofollow&quot;&gt;http://www.nerdkits.com/videos/ledarray2/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="685" LastActivityDate="2015-07-23T18:40:25.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13656" PostTypeId="1" CreationDate="2015-07-23T20:03:16.507" Score="1" ViewCount="355" Body="&lt;p&gt;I have tested the SimpleAudioPlayer example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works fine, but when I add a &lt;code&gt;sleep(1000)&lt;/code&gt; at the end of the &lt;code&gt;loop()&lt;/code&gt; function, the music sounds dismembered (second run).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    // ... source from the example &#xA;&#xA;    myFile.close();&#xA;    Serial.println(&quot;End of file. Thank you for listening!&quot;);&#xA;&#xA;    sleep(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea on how to resolve this?&lt;/p&gt;&#xA;" OwnerUserId="11381" LastEditorUserId="10794" LastEditDate="2015-07-23T21:21:27.600" LastActivityDate="2021-10-21T04:08:55.843" Title="SimpleAudioPlayer + sleep function" Tags="|arduino-due|audio|sleep|sound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13657" PostTypeId="2" ParentId="13656" CreationDate="2015-07-23T21:10:32.417" Score="1" Body="&lt;p&gt;&lt;code&gt;sleep()&lt;/code&gt; is something different. You are probably want to use &lt;code&gt;delay(1000)&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sleep()&lt;/code&gt; comes from libsam and is not very well documented for use within the Arduino environment. There is probably a conflicting timer or interrupt between &lt;code&gt;sleep()&lt;/code&gt; and the &lt;code&gt;Audio.h&lt;/code&gt; library. So sticking with &lt;code&gt;delay()&lt;/code&gt; is probably your best option.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-07-23T21:36:18.540" LastActivityDate="2015-07-23T21:36:18.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13658" PostTypeId="1" AcceptedAnswerId="13660" CreationDate="2015-07-23T21:38:52.747" Score="0" ViewCount="1008" Body="&lt;p&gt;The arduino due has 2 micro-usb ports that you can connect to two separate computers. I need to send different keyboard signals to each computer. How would I do this?&lt;/p&gt;&#xA;" OwnerUserId="11384" LastActivityDate="2015-07-23T22:07:33.360" Title="How to send keyboard signals to two separate computers (arduino due)" Tags="|arduino-due|keyboard|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13659" PostTypeId="2" ParentId="13658" CreationDate="2015-07-23T21:58:58.693" Score="1" Body="&lt;p&gt;For one of them, use &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Keyboard&lt;/code&gt;&lt;/a&gt; as you normally would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other, do whatever &lt;a href=&quot;https://arduino.stackexchange.com/questions/991/can-the-2nd-mcu-on-the-uno-r3-be-used-for-keyboard-emulation&quot;&gt;Can the 2nd MCU on the UNO R3 be used for keyboard emulation?&lt;/a&gt; tells you to do to reprogram the ATmega16U2 connected to the other USB connector.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-23T21:58:58.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13660" PostTypeId="2" ParentId="13658" CreationDate="2015-07-23T22:07:33.360" Score="1" Body="&lt;p&gt;While the Arduino Due has two separate USB ports, only one of them is a native port accessible to the processor. The second port is only usable for programming, and is connected to a different and much smaller chip that handles the programming task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To connect to multiple computers from an Arduino Due, you have two options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can &lt;a href=&quot;https://arduino.stackexchange.com/questions/991/can-the-2nd-mcu-on-the-uno-r3-be-used-for-keyboard-emulation&quot;&gt;reprogram the second MCU&lt;/a&gt; to allow it to connect to the computer as a keyboard. This method is tricky because it requires an external programmer for it to work.&lt;/li&gt;&#xA;&lt;li&gt;You can use a software USB implementation such as &lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;V-USB&lt;/a&gt; to use regular digital pins to connect to the computer. This is also tricky because it requires a little electronic know how a few extra components to make this work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both options require a little something else to make it work, so you will have to pick based on what you feel more comfortable doing.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-07-23T22:07:33.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13662" PostTypeId="1" CreationDate="2015-07-24T03:54:12.517" Score="2" ViewCount="141" Body="&lt;p&gt;I am trying to make a laser scanner consisting of a webcam and a line laser scanner. I have tried to use a manual scanning (by hand) and has worked, but would now like to consider automating the laser rotation (upwards and downwards) as a higher accuracy entails a slow and smooth rotation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came across arduino a few weeks back and realised it could possibly help to make this a reality. From my limited readings so far, I have obtained an Arduino Uno and a motor shield that seems to be the essentials for my purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a few queries that hopefully someone can help:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Do I need a stepper motor for slow rotations, instead of a normal brushed motor?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do I need to connect the Arduino to computer to make it run? Can I run it off battery, if so, does it have an 'ON' button?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How long will a standard 9V battery last?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For the code, I thought of using the simple one here: &lt;a href=&quot;http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;Arduino Motor Shield Tutorial&lt;/a&gt;.&#xA;Would it be able to allow me to control the amount of rotation, speed and the ability to reverse its rotation?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11390" LastEditorUserId="6936" LastEditDate="2015-09-25T22:05:44.107" LastActivityDate="2015-09-25T22:05:44.107" Title="Newbie need help to make a motor run for a laser scanner and some questions" Tags="|motor|arduino-motor-shield|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13663" PostTypeId="1" CreationDate="2015-07-21T10:21:12.297" Score="0" ViewCount="1614" Body="&lt;p&gt;I'm trying to get a Chinese 20A DC Motor Speed Controller working with a MCP42100 Digital Potentiometer. The analogue potentiometer supplied was 100kOhm. I have programmed my arduino with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DATAOUT     11&#xA;#define DATAIN      12       //not used&#xA;#define SPICLOCK    13&#xA;#define SLAVESELECT 10&#xA;#define NOTEON      9&#xA;int potValue = 255;&#xA;float potInputValue;&#xA;&#xA;void SPIInitialize()&#xA;{&#xA;  byte clr;&#xA;  pinMode(DATAOUT, OUTPUT);&#xA;  pinMode(DATAIN, INPUT);&#xA;  pinMode(SPICLOCK, OUTPUT);&#xA;  pinMode(SLAVESELECT, OUTPUT);&#xA;&#xA;  digitalWrite(SLAVESELECT, HIGH); //disable device&#xA;&#xA;  SPCR = (1 &amp;lt;&amp;lt; SPE) | (1 &amp;lt;&amp;lt; MSTR);&#xA;  clr = SPSR;&#xA;  clr = SPDR;&#xA;  delay(10);&#xA;}&#xA;&#xA;char SPITransfer(volatile char data)&#xA;{&#xA;  SPDR = data;                    // Start the transmission&#xA;  while (!(SPSR &amp;amp; (1 &amp;lt;&amp;lt; SPIF)))   // Wait the end of the transmission&#xA;  {&#xA;  };&#xA;  return SPDR;                    // return the received byte&#xA;}&#xA;&#xA;//--- MCP42100 code&#xA;&#xA;byte SetPot(int address, int value)&#xA;{&#xA;  // Slave Select set low to allow commands&#xA;  digitalWrite(SLAVESELECT, LOW);&#xA;&#xA;  // 2 byte command&#xA;  SPITransfer(0x10 + address);   // 0x10 = 'set pot' command&#xA;  SPITransfer(value);            // Value to set pot&#xA;&#xA;  // Release chip, signal end transfer&#xA;  digitalWrite(SLAVESELECT, HIGH);&#xA;}&#xA;&#xA;//--- Application code&#xA;&#xA;void setup()&#xA;{&#xA;  SPIInitialize();          // Initialize the SPI interface&#xA;&#xA;  Serial.begin(9600);&#xA;  delay(25);&#xA;  Serial.println(&quot;Type a resistance between 0-100 kOhms above.&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    // read the incoming byte:&#xA;    potInputValue = Serial.parseInt();&#xA;    float potValue = (potInputValue / 100.0) * 255;&#xA;    Serial.print(&quot;Value: &quot;);&#xA;    Serial.print(potValue);&#xA;    Serial.print(&quot;, Resistance: &quot;);&#xA;    Serial.print(potInputValue);&#xA;    Serial.println(&quot; kOhms&quot;);&#xA;    SetPot(1, potValue);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a picture of my setup:&lt;img src=&quot;https://i.stack.imgur.com/qXNwI.jpg&quot; alt=&quot;My setup&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently at a resistance of 0 kOhms the motor runs at full speed, as it should do and this is how it reacts with the analogue potentiometer. At a resistance of 100 kOhms, the motor (in this case a computer fan) still has enough juice to spin, until I stop it with my finger, but then it doesn't spin without a little push. With the analogue potentiometer, at 100 kOhms the motor received no juice to spin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to the speed controller: &lt;a href=&quot;http://www.ebay.co.uk/itm/301366805277?_trksid=p2060353.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.co.uk/itm/301366805277?_trksid=p2060353.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The speed controller appears to use a 555 timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong with the digital potentiometer to make it so it doesn't behave the same way as the analogue potentiometer?&lt;/p&gt;&#xA;" OwnerUserId="18863" OwnerDisplayName="JosephFTaylor" LastActivityDate="2019-01-14T01:34:44.787" Title="Digital Potentiometer and Motor Speed Controller" Tags="|motor|spi|potentiometer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13664" PostTypeId="2" ParentId="13663" CreationDate="2015-07-21T11:37:59.183" Score="1" Body="&lt;p&gt;If you look at the MCP42100 data sheet &lt;a href=&quot;http://www.microchip.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.microchip.com/&lt;/a&gt;, on page 4 you will see the details for your unit. Notice that the actual resistance will be in the range of 70k to 130k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the reason that you are getting different results is (probably) due to your having a digital pot with a resistance somewhat lower than the physical pot you used. &lt;/p&gt;&#xA;" OwnerUserId="15988" OwnerDisplayName="WhatRoughBeast" LastActivityDate="2015-07-21T11:37:59.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13665" PostTypeId="2" ParentId="13663" CreationDate="2015-07-21T12:23:50.010" Score="2" Body="&lt;p&gt;The MCP42100 does not appear to be an appropriate digital pot for this application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a schematic of the motor controller it is hard to tell, but a good guess would be that the digital pot is seeing voltages higher than the supply voltage you are feeding it, and higher than the &lt;strong&gt;maximum supply voltage&lt;/strong&gt; of the digital pot (5.5V; 7.0V abs max). I don't see a voltage regulator on the motor controller board, nor would one be necessary for a low-end design. Probably just a PWM using a 555, as you say. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this work you probably need a different type of digital pot - one that can accept logic level inputs and has a higher supply voltage (12V + some margin). You also typically actually have to feed it the higher supply voltage (and be careful that nothing shorts and ruins the micro board).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise the input protection networks on the digital pot conducts more current than you would expect.  &lt;/p&gt;&#xA;" OwnerUserId="5080" OwnerDisplayName="Spehro Pefhany" LastActivityDate="2015-07-21T12:23:50.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13666" PostTypeId="1" CreationDate="2015-07-23T10:50:46.457" Score="2" ViewCount="714" Body="&lt;p&gt;I'm trying to upload a Blink example from Arduino IDE to an atmega8a via USBasp. I have edited the boards.txt file with the specifications of the atmega8a, and I am using the &quot;Upload with programmer&quot; option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVRdude gives no errors, only a warning that my usbasp firmware needs an update. I assume the code is uploaded, but it does not execute. My fuse settings are hfuse - 0xc0, lfuse - 0x9f, but i have tried different ones to no avail.&lt;/p&gt;&#xA;" OwnerUserId="11418" OwnerDisplayName="Nopony" LastActivityDate="2015-07-24T04:30:09.723" Title="Using arduino IDE with USBasp" Tags="|avrdude|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13667" PostTypeId="2" ParentId="13653" CreationDate="2015-07-24T04:32:50.373" Score="3" Body="&lt;p&gt;I ported the BigNumber library to the Arduino in 2012. The BigNumber library is based almost entirely on the GNU &quot;bc&quot; library. What it does is store numbers with arbitrary precision (ie. as large as you like, and with as many decimal places as you like).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on the Uno you can calculate 3&lt;sup&gt;160&lt;/sup&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3^160 = 21847450052839212624230656502990235142567050104912751880812823948662932355201&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, the square root of 2 to 100 decimal places:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sqrt(2) = 1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's up to you how many decimal places you want. However the trade-off is RAM and speed. The more precision, the more RAM and the slower it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A normal precision float (like on the Uno/Mega) has around 7 decimal digits of precision. A &lt;em&gt;double&lt;/em&gt; float has around 16 decimal digits of precision. See &lt;a href=&quot;https://en.wikipedia.org/wiki/Floating_point&quot; rel=&quot;nofollow&quot;&gt;Wikipedia - Floating point&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the ESP8266 has a C++ compiler then you could probably convert the BigNumber library without too many issues. However if it supports double-precision floats you may not need to.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I check what's the highest numerical precision that the ESP8266 can support?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You may want to ask on the &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;ESP8266 Community Forum&lt;/a&gt; - they may be able to give you a more helpful answer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11519&quot; rel=&quot;nofollow&quot;&gt;Arbitrary precision (big number) library port for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nickgammon/BigNumber&quot; rel=&quot;nofollow&quot;&gt;Source on Github&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-24T07:41:09.053" LastActivityDate="2015-07-24T07:41:09.053" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13668" PostTypeId="2" ParentId="13662" CreationDate="2015-07-24T05:08:43.350" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Servomotor&quot; rel=&quot;nofollow noreferrer&quot;&gt;servo motor&lt;/a&gt; would have a lot more control than a normal motor. You usually command them to go to one of the predefined steps (stops) by using a function call in the servo motor library.&lt;/li&gt;&#xA;&lt;li&gt;You can run independently of the computer. Many people do this. Certainly you can run off a battery. It doesn't have an ON button, you normally would have this between your battery and the Uno (eg. built into the battery pack). Like this:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j43ag.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j43ag.jpg&quot; alt=&quot;Battery pack&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;A 9 V battery? I wouldn't use one, especially to drive a motor. It won't last long. Get something like 3 x AA batteries in a battery holder.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/80NYa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/80NYa.jpg&quot; alt=&quot;Servo motor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To show you the idea, I have this servo motor (SG-5010) I got from &lt;a href=&quot;http://www.adafruit.com/products/155&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I measured it using about 200 mA of power when operating. Now, I looked up a typical Alkaline 9 V battery, and found that, consuming 200 mA, it lasts for around 400 mAh. Thus, you could say it would be good for two hours at that rate. Plus, the Arduino will take around 50 mA, so maybe less than two hours.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;A smallish servo motor won't need a motor shield. The pictures on the linked page show ordinary brushed motors. A servo motor has 3 leads:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Power (eg. 5 V)&lt;/li&gt;&#xA;&lt;li&gt;Gnd&lt;/li&gt;&#xA;&lt;li&gt;Data&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Make sure you connect the grounds together, but the power could go to a separate power pack. A bit depends on how much power your motor will use. The data goes to the Arduino for the information about which rotation point to step to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able, in code, to change the rotation position, forwards and backwards. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-26T03:09:40.357" LastActivityDate="2015-07-26T03:09:40.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13670" PostTypeId="1" CreationDate="2015-07-24T08:50:22.157" Score="2" ViewCount="218" Body="&lt;p&gt;Could one use the Arduino Due to control camera module like OV5642 and send the data to spi device? My project is to capture image with OV5642 and then to send the image data(RGB565) to other device via spi. For this STM32 must be enough, but I'd be happy if I can use the arduino IDE. Because it is much easier to program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please let me know, if you can use the Due for this task?&lt;/p&gt;&#xA;" OwnerUserId="11080" LastEditorUserId="11080" LastEditDate="2015-07-24T12:05:06.883" LastActivityDate="2017-12-06T12:53:39.927" Title="Arduino Due for camera control?" Tags="|arduino-due|" AnswerCount="1" CommentCount="8" ClosedDate="2017-12-07T00:14:11.140" ContentLicense="CC BY-SA 3.0" />
  <row Id="13671" PostTypeId="1" CreationDate="2015-07-24T10:21:29.910" Score="0" ViewCount="215" Body="&lt;p&gt;I have Arduino Uno, Arduino Pro Micro, XY-MK-5V and FS1000A.&#xA;I need transmit data from Pro Micro to Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transmitter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;    void setup() {&#xA;&#xA;      Serial.begin(9600);&#xA;&#xA;      vw_setup(2000);&#xA;      vw_set_tx_pin(14);&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;      send(&quot;Test message!&quot;);  &#xA;      delay(2000);&#xA;    }&#xA;&#xA;    void send (char *message)&#xA;    {&#xA;      vw_send((uint8_t *)message, strlen(message));&#xA;      vw_wait_tx();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;&#xA;    vw_set_rx_pin(12);&#xA;    vw_setup(2000);&#xA;&#xA;    vw_rx_start();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;    uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;&#xA;    if(vw_get_message(buf, &amp;amp;buflen))&#xA;    {&#xA;        for(int i = 0; i &amp;lt; buflen; i++)&#xA;        {&#xA;            Serial.print(buf[i]);&#xA;        }&#xA;&#xA;        Serial.println();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I dont know why it's doesn't works. When I changed Uno with Micro and Micro with Uno, it's worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I need: Micro + transmitter FS1000A &amp;amp; Uno + receiver XY-MK-5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me. I'm using &lt;a href=&quot;https://i.stack.imgur.com/HpDfX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Pro Micro&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11396" LastEditorUserId="10003" LastEditDate="2015-07-25T21:28:23.380" LastActivityDate="2016-02-13T18:31:16.957" Title="Doesn't work radio transmission from Arduino Uno to Arduino Pro Micro" Tags="|arduino-uno|networking|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13673" PostTypeId="1" CreationDate="2015-07-24T14:04:33.017" Score="1" ViewCount="1801" Body="&lt;p&gt;Is it possible to build a battery charger with just an arduino UNO board (and perharps some passive components)?. It's a 3.7V 550 mAh LiPo Battery. I understand I need to monitor the charge and the current flowing into the battery to properly (as in &lt;em&gt;safely&lt;/em&gt;) charge it.&lt;/p&gt;&#xA;" OwnerUserId="11399" LastActivityDate="2015-11-22T10:39:47.917" Title="LiPo battery charger" Tags="|arduino-uno|power|battery|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13674" PostTypeId="2" ParentId="13673" CreationDate="2015-07-24T14:08:48.210" Score="0" Body="&lt;p&gt;Yes, it is. &lt;a href=&quot;http://www.atmel.com/Images/doc7801.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR146&lt;/a&gt; describes how to charge a battery using a ATmega16U4/32U4 (Leonardo), but there is nothing specific to that chip regarding the actual charging, and the serial communication can easily enough be ported to the ATmega328P.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-24T14:08:48.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13676" PostTypeId="1" CreationDate="2015-07-24T18:14:26.133" Score="1" ViewCount="756" Body="&lt;p&gt;I am working on a small robot project, the code which i made for this has a sequential execution in a single thread. There are a lot of Delay() function needed. Due to which the accuracy is extremely bad.&#xA;i want to to implement the movements in one thread and the sensor detection in another thread.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define M1 3&#xA;#define M2 5&#xA;#define M3 6&#xA;#define M4 9&#xA;#define L_trig 2&#xA;#define L_echo 4&#xA;#define R_trig 7&#xA;#define R_echo 8&#xA;#define servo 10&#xA;#define solenoid_pin 11&#xA;#define LDR_pin1 12&#xA;#define LDR_pin2 13&#xA;void setup() &#xA;{&#xA;// Motors Initilization&#xA;pinMode(M1,OUTPUT);&#xA;pinMode(M2,OUTPUT);&#xA;pinMode(M3,OUTPUT);&#xA;pinMode(M4,OUTPUT);&#xA;// Ultrasonic  Initilization&#xA;pinMode(L_trig, OUTPUT);&#xA;pinMode(L_echo, INPUT);&#xA;pinMode(R_trig, OUTPUT);&#xA;pinMode(R_echo, INPUT);&#xA;S.attach(servo);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA; Runmotor(M1);&#xA; Runmotor(M2);&#xA; Runmotor(M3);&#xA; Runmotor(M4);&#xA; servo_rotation();&#xA; Ultrasonic_value(L_trig,L_echo);&#xA; Ultrasonic_value(R_trig,R_echo);&#xA;&#xA; if(Ultrasonic_value(L_trig,L_echo)&amp;lt;5 || Ultrasonic_value(R_trig,R_echo)&amp;lt;5)&#xA;&#xA;   {&#xA;     turnLeft();&#xA;     //Serial.println(&quot;Working&quot;);&#xA;   }&#xA;&#xA;}&#xA;&#xA;// Run Motor&#xA;void Runmotor(int which)&#xA;{&#xA;  for(int i=0;i&amp;lt;1023;i++)&#xA;  {&#xA; analogWrite(which, i);  &#xA;  }&#xA;}&#xA;// Stop Motor&#xA;void stopmotor(int which)&#xA;{&#xA;  digitalWrite(which,LOW);&#xA;}&#xA;// To turn the robot left side&#xA;void turnLeft()&#xA;{&#xA;  stopmotor(M2);&#xA;  stopmotor(M3);&#xA;  delay(5000);&#xA;  Runmotor(M2);&#xA;  Runmotor(M3); &#xA;}&#xA;// To turn the robot Rightside&#xA;void turnRight()&#xA;{&#xA;  stopmotor(M1);&#xA;  stopmotor(M4);&#xA;  delay(5000);&#xA;  Runmotor(M1);&#xA;  Runmotor(M4); &#xA;}&#xA;// Servo Rotation&#xA;void servo_rotation()&#xA;{&#xA; for(angle=0;angle&amp;lt;=180;angle++)&#xA;{ &#xA; S.write(angle); &#xA; if(angle==90)&#xA; {&#xA;   delay(2000);&#xA; }&#xA;}&#xA;delay(2000);&#xA;for(angle=180;angle&amp;gt;=0;angle--)&#xA;{&#xA;  S.write(angle);&#xA;  Serial.println(angle);&#xA;  if(angle==90)&#xA; {&#xA;   delay(2000);&#xA; }&#xA;}&#xA; delay(2000); &#xA;}&#xA;&#xA;// Calculation of distance &#xA;long Ultrasonic_value(int which_trig,int which_echo)&#xA;{&#xA;  long duration, distance;&#xA;  digitalWrite(which_trig, LOW);&#xA;  delayMicroseconds(2); &#xA;  digitalWrite(which_trig, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(which_trig, LOW);&#xA;  duration = pulseIn(which_echo, HIGH);&#xA;  // distance = duration*343*100/2;&#xA;  distance = (duration/2) / 29.1;&#xA;  delay(100);&#xA;  return distance;&#xA;}&#xA;&#xA;void Solenoid_Fire()&#xA;{&#xA;  digitalWrite(solenoid_pin,LOW);&#xA;}&#xA;&#xA;void Solenoid_Reload()&#xA;{&#xA;  digitalWrite(solenoid_pin,HIGH);&#xA;}&#xA;/*&#xA;bool LDR_reading(int LDR_pin1 , int LDR_pin2)&#xA;{&#xA;&#xA;&#xA;}&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me. I want to implement this code in a Multi-thread fashion. Thanks in Advance&lt;/p&gt;&#xA;" OwnerUserId="11404" LastEditorUserId="7856" LastEditDate="2015-07-25T16:49:05.060" LastActivityDate="2019-04-27T08:55:27.590" Title="Multi-threaded Robot" Tags="|arduino-uno|robotics|threads|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13677" PostTypeId="2" ParentId="13676" CreationDate="2015-07-24T18:41:54.187" Score="0" Body="&lt;p&gt;I am looking at &lt;a href=&quot;http://file:///home/igor/dev/eclipse-workspace/NilRTOS-Arduino/html/examples.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, for a similar project.&#xA;It seems light and simple enough that you could have a quick trial.&#xA;Converting those functions to threads shouldn't be too time consuming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once every activity is implemented as thread, you could use semaphores to hold them blocked and then create a state machine which controls them through the semaphores.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-07-24T18:48:58.107" LastActivityDate="2015-07-24T18:48:58.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13678" PostTypeId="2" ParentId="13670" CreationDate="2015-07-24T21:04:39.967" Score="1" Body="&lt;p&gt;You are still not giving the full picture, pun intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll give you an example of what sort of info is missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, what's the frame rate? What's the color depth of the sensor?&#xA;If you look at the SAM3x TRM, it says that the SPI is clocked at max 65MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the (simplified) math would say: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;24bit/pixel * 5Mpixel / 65MHz =  1.846 seconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that doesn't even account for acquisition time, so if you do not have fully working DMA on both sides, it's probably even worse.&#xA;And it will be worse, because you cannot stuff in RAM in one go the entire image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But maybe that's good enough for you, however it's not possible to say because of the missing info.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-24T21:04:39.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13679" PostTypeId="1" CreationDate="2015-07-24T21:30:58.267" Score="-2" ViewCount="174" Body="&lt;p&gt;The following code gives me an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// RFIDunio.h is from http://learn.robotgeek.com/getting-started-guides/39-robot-kits/151-rfiduino.html&#xA;#include &amp;lt;RFIDuino.h&amp;gt; &#xA;&#xA;byte    keyTag[5] = {0,0,0,0,0};&#xA;boolean noise = false;&#xA;byte    masterTag[5] = {37,0,0,127,24};&#xA;byte    tagData[5];&#xA;byte    tagDatas[5];&#xA;boolean verifyKey = false;&#xA;boolean mastaKey = false;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Welcome to my system!&quot;);&#xA;}&#xA;&#xA;RFIDuino myRFIDuino(1.2);&#xA;&#xA;void loop()&#xA;{&#xA;  if(myRFIDunio.scanForTag(tagData == true)&#xA;  {&#xA;    verifyKey = myRFIDunio.compareTagData(tagData, keyTag);&#xA;    mastaKey = myRFIDunio.compareTagData(tagData, masterTag);&#xA;    if(verifyKey == true)&#xA;    {&#xA;      digitalWrite(myRFIDunio.led2,HIGH);&#xA;      if(noise == true)&#xA;      {&#xA;        myRFIDunio.successSound();&#xA;      }&#xA;      Serial.println(&quot;Correct Key!&quot; + &quot; UID = &quot; + tagData[5]);&#xA;      delay(250);&#xA;      digitalWrite(myRFIDunio.led2,LOW);&#xA;    }&#xA;    else if(mastaKey == true)&#xA;    {&#xA;      Serial.println(&quot;Programming mode activated!&quot;);&#xA;      delay(500);&#xA;      Serial.println(&quot;Please scan a card.&quot;);&#xA;      myRFIDunio.scanForTag(tagDatas == true)&#xA;      delay(1000);&#xA;      tagDatas[5] = tagData[5];&#xA;      Serial.println(&quot;Card has been programmed!&quot;);&#xA;    }&#xA;    else&#xA;    {&#xA;      digitalWrite(myRFIDuno.led1,HIGH);&#xA;      if(noise == true)&#xA;         {&#xA;            myRFIDuino.errorSound();        &#xA;         }&#xA;      Serial.println(&quot;Wrong! &quot; + &quot;UID = &quot; + tagData[5]);&#xA;      delay(250);&#xA;      digitalWrite(myRFIDunio.led1,LOW);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\variants\standard -IC:\Users\*****\Documents\Arduino\libraries\RFIDuino C:\Users\*****\AppData\Local\Temp\build6101268048586666869.tmp\sketch_jul24a.cpp -o C:\Users\*****\AppData\Local\Temp\build6101268048586666869.tmp\sketch_jul24a.cpp.o &#xA;sketch_jul24a.ino: In function 'void loop()':&#xA;sketch_jul24a:20: error: 'myRFIDunio' was not declared in this scope&#xA;sketch_jul24a:20: error: ISO C++ forbids comparison between pointer and integer&#xA;sketch_jul24a:21: error: expected `)' before '{' token&#xA;sketch_jul24a:55: error: expected statement at end of input&#xA;sketch_jul24a:55: error: expected `}' at end of input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11407" LastEditorUserId="10003" LastEditDate="2015-07-26T21:51:33.747" LastActivityDate="2021-12-02T05:01:40.127" Title="I have an 'error' with my code" Tags="|rfid|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13680" PostTypeId="2" ParentId="13679" CreationDate="2015-07-24T21:35:41.667" Score="0" Body="&lt;p&gt;C++ is spelling-sensitive; identifiers need to be spelled the same way each time they are used.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-24T21:35:41.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13681" PostTypeId="2" ParentId="13679" CreationDate="2015-07-24T21:36:26.870" Score="0" Body="&lt;pre&gt;&lt;code&gt;if(myRFIDunio.scanForTag(tagData == true)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you have a bracket missing there.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(myRFIDunio.scanForTag(tagData) == true)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also I think you have spelled myRFIDuino wrong.  ni &amp;lt;-&gt; in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(myRFIDuino.scanForTag(tagData) == true)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you need a } at the end of your program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As well, you can't add strings together like you are doing in your Serial prints.  Break them up into multiple prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Correct Key!  UID = &quot;);&#xA;Serial.println(tagData[5]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also have other bits that make no sense at all, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myRFIDuino.scanForTag(tagDatas == true)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One further thing - that library will never work on Linux, or on MAC OS/X where case sensitivity is enabled on the filesystem.  The .cpp file is including a badly named .h file.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-07-24T21:45:15.007" LastActivityDate="2015-07-24T21:45:15.007" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13683" PostTypeId="1" AcceptedAnswerId="13695" CreationDate="2015-07-24T23:26:49.180" Score="5" ViewCount="20290" Body="&lt;p&gt;I would like to state that I am not familiar with the whole cellular connection thing. But I was wondering if the SIM900/or/SIM900A is 3G and will work with &lt;a href=&quot;http://www.ptel.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;PTel Mobile&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need this Arduino to be able to travel and needs to connect to every PTel's tower. Will I be able to connect to 3G or only the 2G and the 1G networks?&lt;/p&gt;&#xA;" OwnerUserId="8167" LastEditorUserId="6936" LastEditDate="2018-07-18T08:37:34.460" LastActivityDate="2019-03-31T16:50:21.237" Title="Is the SIM900 3G? Or is the SIM900A able to connect to 3G?" Tags="|shields|gsm|communication|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="13684" PostTypeId="1" CreationDate="2015-07-25T01:32:12.663" Score="2" ViewCount="106" Body="&lt;p&gt;I am doing a wireless rover using arduino mega 2560 that can be controlled by a smartphone and a PC. Which bluetooth module would fit me? Again I want to control it both by my Laptop(Built-in Bluetooth) and my smartphone. Thanks in advance.&lt;/p&gt;&#xA;" OwnerDisplayName="user11295" LastActivityDate="2016-10-30T22:01:20.447" Title="Which bluetooth module should I buy?" Tags="|arduino-mega|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13685" PostTypeId="2" ParentId="13676" CreationDate="2015-07-25T05:13:38.540" Score="1" Body=" &#xA;&#xA;&lt;p&gt;I think this needs a major rework. First here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  for(int i=0;i&amp;lt;1023;i++)&#xA;  {&#xA;  analogWrite(which, i);  &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The maximum you can analogWrite is 255, so change 1023 to 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, get rid of the delay() calls.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Let's look at &lt;code&gt;turnLeft&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// To turn the robot left side&#xA;void turnLeft()&#xA;{&#xA;  stopmotor(M2);&#xA;  stopmotor(M3);&#xA;  delay(5000);&#xA;  Runmotor(M2);&#xA;  Runmotor(M3); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why stop the motor and then start it again? Do you mean:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// To turn the robot left side&#xA;void turnLeft()&#xA;{&#xA;  stopmotor(M1);&#xA;  stopmotor(M4);&#xA;  delay(5000);&#xA;  Runmotor(M2);&#xA;  Runmotor(M3); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't see what the delay achieves anyway. Get rid of it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// To turn the robot left side&#xA;void turnLeft()&#xA;{&#xA;  stopmotor(M1);&#xA;  stopmotor(M4);&#xA;  Runmotor(M2);&#xA;  Runmotor(M3); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact, I don't see what any of the delay() calls achieve. Try removing them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See my post &lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;How to do multiple things at once ... like cook bacon and eggs&lt;/a&gt; for tips on doing multiple things without using delay().&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also consider using arrays. Instead of M1, M2, M3, M4, make an array:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_MOTORS = 4;&#xA;const int motorPins [NUMBER_OF_MOTORS] = { 3, 4, 6, 9 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it is easier to set them all to output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Motors Initilization&#xA;&#xA;for (int i = 0; i &amp;lt; NUMBER_OF_MOTORS; i++)&#xA;  pinMode (motorPins [i], OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is also easier to start or stop all of them:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;for (int i = 0; i &amp;lt; NUMBER_OF_MOTORS; i++)&#xA;  stopmotor (i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where stopmotor is now:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Stop Motor&#xA;void stopmotor(int which)&#xA;{&#xA;  digitalWrite(motorPins [which],LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also don't see what this achieves:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void Runmotor(int which)&#xA;{&#xA;  for(int i=0;i&amp;lt;1023;i++)&#xA;  {&#xA; analogWrite(which, i);  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apart from the fact that you can't go up to 1023, if you stop at 255, the time taken to do all those analogWrite is just over 2 ms. Why bother? Why not just do this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void Runmotor(int which)&#xA;{&#xA;  digitalWrite (which, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-25T05:38:00.230" LastActivityDate="2015-07-25T05:38:00.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13686" PostTypeId="2" ParentId="13673" CreationDate="2015-07-25T08:29:10.740" Score="2" Body="&lt;p&gt;I'll assume that you are trying to charge from a 5V &quot;USB&quot; source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only want to use a UNO + passive components then the hardware intensive method of application note &lt;a href=&quot;http://www.atmel.com/Images/doc7801.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR146: Lithium-Ion Battery Charging via USB with ATmega16/32U4&lt;/a&gt; which Ignacio suggests does not meet your need. This is a capable charger but the UNO would not be the major part of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Normal&quot; charger&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of any of the available LiIon charger ICs is an easy and low cost way of adding a charger. These ICs and all related components can cost as little as a few dollars. But ... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UNO + one resistor very low current charger:&lt;/strong&gt;      &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If using a UNO with no external active parts the current drive rating of the UNO pins limits the maximum current able to be provided. If you &lt;strong&gt;really&lt;/strong&gt; want to meet your specification you can achieve a few ten's of mA charge using with a UNO and a few resistors (possibly just one.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Super simple good capability charger&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, a good compromise can be achieved using a UNO (or similar) + one transistor plus a few resistors and capacitors. This can achieve all the usual basic capabilities&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Low current &quot;trickle up&quot; for very low voltage cells&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constant current charge until Vmax is reached&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constant voltage charge until I_cutoff is reached.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Terminate and stay active until recharge needed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I will only outline the basic system here. More can be said as and if required.&lt;br&gt;&#xA;The main point of note s that in its simplest form the charger uses a linear charging mode so a modest amount of heat needs to be dissipated in the control transistor. Max power dissipation for a A max charge rate would be 2 Watts when the battery was at 3V and full charge was wanted from 5V in.&lt;br&gt;&#xA;Power dissipation = (Vin - Vbattery) x Icharge&lt;br&gt;&#xA;Worst case here = (5V - 3V) x 1A = 2 watts.&lt;br&gt;&#xA;A buck converter could be used (UNO controlled) if desired. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A transistor Q1 connects Vin to battery &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1 can be PWM controlled by the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Battery current is monitored by a small resistor Rcur from B- to ground (or in B+ lead)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vbattery is monitored with an ADC channel (ADC1 or ADC_V)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current is measured by measuring voltage across Rcur with an ADC (ADC2 or ADC_I).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If Rcur is from B- to ground then V Rcur = V ADC2. If Rcur is in B+ lead V across Icur = V_ADC2 - V_ADC1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1 on state can be varied by PWM from Uno to control battery current. PWM voltage is smoothed by an RC low pass filter to allow smooth DC control. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Charging:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following steps constitute the standard LiIon charging algorithm implemented by most charger ICs. Variations can be made.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If Vbat &amp;lt; 3V set Ichg to Itrickle by PWMing Q1 and reading battery current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While 3V &amp;lt;= Vbat &amp;lt;= 4.2V chg at Imax for battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When Vbattery = V-max = 4.2V adjust Ichg with PWM to hold Vbat at 4.2V until   Ichg falls to desired fraction of Imax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn off chg voltage fully and monitor Vbat to restart charge at Vbat = Vrestart - maybe 4.0V or as desired. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-07-25T08:29:10.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13688" PostTypeId="1" AcceptedAnswerId="13690" CreationDate="2015-07-25T09:03:22.523" Score="0" ViewCount="53" Body="&lt;p&gt;can I use this configuration of two pins to run a micro motor ,so I be able to change the polarity of the current (by the code itself-one time out pin1-high out pin2 - low , while next time one low two high!) every time I would like ?(and by changing the polarity OF THE CURRENT to the motor it will revers it) !  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank's !&lt;/p&gt;&#xA;" OwnerUserId="11412" LastActivityDate="2015-07-25T13:58:54.710" Title="reversing a micro motor by reversing two pins - one Source and one sink?" Tags="|power|motor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13689" PostTypeId="2" ParentId="8714" CreationDate="2015-07-25T09:42:13.767" Score="0" Body="&lt;p&gt;I presume you are wanting the print output to show up on the Serial Monitor but you have connected the Arduino IDE to the Yun via the WiFi port on your network. If this is the case, then change all refs of Serial.print to Console.print&#xA;This will direct the ASCII text to the Serial Monitor.&lt;/p&gt;&#xA;" OwnerUserId="11414" LastActivityDate="2015-07-25T09:42:13.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13690" PostTypeId="2" ParentId="13688" CreationDate="2015-07-25T10:58:20.633" Score="1" Body="&lt;pre&gt;&lt;code&gt;**Required:**  &#xA;&#xA;Drive micro-motor directly from two processor pins.   &#xA;&#xA; - Pin 1 high / Pin 2 low for one direction.  &#xA; - Pin 1 low / Pin 2 high for other direction.**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not a very good idea if it can be avoided but yes, you can operate a motor that way,  providing that the motor current is low enough to meet the pin current ratings. It would have to be a very small motor to achieve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take careful note of the current versus voltage drive capabilities of the processor concerned. While a pin may be shown as being able to source or sing 5 or 10 or 20 mA, this is accompanied by a voltage rise for a sink and voltage drop for a source, so at higher currents lower voltages will be available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A danger is that motor noise may affect the processor.&lt;br&gt;&#xA;Placing a small capacitor across the motor will help, and driving the motor through a small resistor from each pin will also help keep noise away from the processor. But depending on the motor used this may not be enough.&lt;br&gt;&#xA;The series resistors will drop some voltage and so are limited in maximum allowable size.&lt;br&gt;&#xA;The parallel capacitor will slow the direction transition - the larger the capacitor the slower the change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using drivers or &quot;buffers&quot; which are higher current rated would allow a larger motor to be driven and would help isolate the processor from the motor noise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ask further if any idea here sounds useful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Added: Had a discussion with Gerben (below).&lt;br&gt;&#xA;I'd avoided mentioning &quot;catch diodes&quot; but this is an add on that can help.&lt;br&gt;&#xA;From each pin add a small Schottky diode* from pin to Vcc and pin to ground so that all 4 diodes are reverse biased.&lt;br&gt;&#xA;(ie Cathode goes to Vcc = line on diode on upper diodes.&lt;br&gt;&#xA;Anode goes to ground on &quot;lower&quot; diodes. )&lt;br&gt;&#xA;These diodes are usually non conducting. If motor operation or switching causes spikes that rise above Vcc or below ground these diodes will conduct (slightly) before  the internal protection diodes do. This is not ideal but can help.&lt;br&gt;&#xA;As Gerben notes, when reversing the motor, driving BOTH pins to ground until the motor has stopped and then applying reversing polarity can help. Also driving both high will do the same. There are pros and cons with either method.   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;eg &lt;a href=&quot;http://www.diodes.com/datasheets/ds11005.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;BAT54&lt;/strong&gt; surface mount&lt;/a&gt;,   &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000768.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;BAT48 through hole&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;http://www.digikey.com/product-search/en?k=schottky+diode+1n581&amp;amp;mnonly=0&amp;amp;newproducts=0&amp;amp;ColumnSort=1000011&amp;amp;page=1&amp;amp;stock=0&amp;amp;pbfree=0&amp;amp;rohs=0&amp;amp;quantity=1&amp;amp;ptm=0&amp;amp;fid=0&amp;amp;pageSize=25&quot; rel=&quot;nofollow&quot;&gt;1N581x&lt;/a&gt;  or similar.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6959" LastEditDate="2015-07-25T13:58:54.710" LastActivityDate="2015-07-25T13:58:54.710" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13691" PostTypeId="1" CreationDate="2015-07-25T11:34:24.040" Score="-1" ViewCount="506" Body="&lt;p&gt;I need to measure KWh of the mains, connecting something like a sensor to the mains and reading its value into analog. I already know to measure KWh from a KWh meter but I need to make my own. &lt;/p&gt;&#xA;" OwnerUserId="11353" LastEditorUserId="6936" LastEditDate="2015-08-12T13:29:31.150" LastActivityDate="2015-08-12T14:07:00.383" Title="Measuring KWh connecting to the mains" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="1" ClosedDate="2015-08-21T12:22:36.997" ContentLicense="CC BY-SA 3.0" />
  <row Id="13692" PostTypeId="1" CreationDate="2015-07-25T14:59:26.903" Score="2" ViewCount="3757" Body="&lt;p&gt;I'm using &lt;a href=&quot;http://sourceforge.net/projects/berryboot/files/os_images/Fedora_21_MATE.img/download&quot; rel=&quot;nofollow&quot;&gt;Fedora_21_MATE.img&lt;/a&gt; on a Raspberry Pi. Installing the Arduino IDE 1.0.6 using these commands, taken from &lt;a href=&quot;http://www.instructables.com/id/Arduino-On-Pi/&quot; rel=&quot;nofollow&quot;&gt;Arduino On Pi&lt;/a&gt;. Those instructions are for Raspbian, I assume, so changing for Fedora, &lt;code&gt;apt-get&lt;/code&gt; to &lt;code&gt;yum&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo yum install arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One waits and &lt;code&gt;arduino&lt;/code&gt; installs. One can then run the Arduino IDE from the Fedora GUI menu, and it loads - after moaning about the user has to be a member of the &lt;code&gt;dialout&lt;/code&gt; and &lt;code&gt;lock&lt;/code&gt; groups. This is easily resolved by adding the user to the required groups, using the control panel. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, trying to compile anything, i.e. &lt;code&gt;blink&lt;/code&gt;, in the IDE, gives me the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++: error trying to exec cc1plus: execvp: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In verbose mode, little additional information is offered.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.0.6 (Linux), Board: &quot;Arduino Uno&quot;&#xA;avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /tmp/build6314348775898760987.tmp/Blink.cpp -o /tmp/build6314348775898760987.tmp/Blink.cpp.o &#xA;avr-g++: error trying to exec 'cc1plus': execvp: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file in question, &lt;code&gt;cc1plus&lt;/code&gt;, is actually present in the filesystem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[piebody@berrybody ~]$ locate cc1plus&#xA;/usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.9.2/cc1plus&#xA;/usr/libexec/gcc/avr/4.9.2/cc1plus&#xA;[piebody@berrybody ~]$ &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why it doesn't run &quot;out of the box&quot;? Do I need to modify any environment variables, and if so, which ones and with what exactly? I assume my &lt;code&gt;PATH&lt;/code&gt; environment variable needs fixing, but is there any environment variable specific to &lt;code&gt;avr-g++&lt;/code&gt; that needs changing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate that this is probably a simple UNIX paths issue, and that the question may be more suited to SE: Unix &amp;amp; Linux.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-28T20:53:24.613" LastActivityDate="2016-05-03T06:02:34.123" Title="Arduino IDE on Fedora" Tags="|arduino-ide|linux|fedora|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13693" PostTypeId="5" CreationDate="2015-07-25T15:04:04.707" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Fedora has a reputation for focusing on innovation, integrating new&#xA;  technologies early on and working closely with upstream Linux&#xA;  communities. Making changes upstream instead of specifically in Fedora&#xA;  ensures that the changes are available to all Linux distributions.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fedora has a relatively short life cycle: version X is supported only&#xA;  until 1 month after version X+2 is released and with approximately 6&#xA;  months between versions, this means that a version of Fedora is&#xA;  supported for approximately 13 months. This promotes leading-edge&#xA;  software because it frees developers from some backward compatibility&#xA;  restraints, but it also makes Fedora a poor choice for product&#xA;  development, which usually requires long-term vendor-support. Fedora&#xA;  users can upgrade from version to version using FedUp.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The default desktop in Fedora is the GNOME desktop environment and the&#xA;  default interface is the GNOME Shell. Other desktop environments,&#xA;  including KDE, Xfce, LXDE, MATE and Cinnamon, are available and can be&#xA;  installed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Fedora 22 with KDE Fedora uses the RPM package management system.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Security is also important in Fedora with one specific security&#xA;  feature being Security-Enhanced Linux, which implements a variety of&#xA;  security policies, including mandatory access controls, and which&#xA;  Fedora adopted early on.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://en.wikipedia.org/wiki/Fedora_(operating_system)&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-13T15:51:36.907" LastActivityDate="2015-08-13T15:51:36.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13694" PostTypeId="4" CreationDate="2015-07-25T15:04:04.707" Score="0" Body=" is an operating system based on the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat. Fedora contains software distributed under a free and open source license and aims to be on the leading edge of such technologies." OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-25T21:30:14.060" LastActivityDate="2015-07-25T21:30:14.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13695" PostTypeId="2" ParentId="13683" CreationDate="2015-07-25T15:12:28.847" Score="3" Body="&lt;p&gt;First of all if you are in USA you cannot use SIM 900A since it supports only Dual frequency bands.(900,1800 MHz)it supports only Asian region countries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_United_States_mobile_virtual_network_operators&quot; rel=&quot;nofollow&quot;&gt;Wikipedia, PTel Mobile&lt;/a&gt; supports only GSM 850/1900 frequencies. &#xA;so SIM 900 supports( 850,900,1800,1900 MHz ) you must use SIM900&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Considering about the speed you cannot obtain 3g, 4g speed since GSM Shield(SIM900) provides maximum of &lt;a href=&quot;http://www.simcom.eu/index.php?m=termekek&amp;amp;prime=1&amp;amp;sub=40&amp;amp;id=0000000147&amp;amp;page=1&quot; rel=&quot;nofollow&quot;&gt;GPRS class 10: max. 85.6 kbps (downlink)&lt;/a&gt; so, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will able to connect but cannot get such speed in 3g and 4g.&lt;/p&gt;&#xA;" OwnerUserId="11285" LastEditorUserId="11285" LastEditDate="2015-07-25T15:26:56.783" LastActivityDate="2015-07-25T15:26:56.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13698" PostTypeId="1" CreationDate="2015-07-25T15:52:51.377" Score="5" ViewCount="1697" Body="&lt;p&gt;&lt;em&gt;The question in short:&lt;/em&gt;&#xA;On an Arduino UNO or Nano using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;noreferrer&quot;&gt;SD library&lt;/a&gt;, is it somehow possible to use the LED on pin 13 (or any other pin that is used by the library) again after finishing all SD operations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Detailed explanation:&lt;/em&gt;&#xA;In my sketch, during setup() I need to read some data from a file on the SD card, which is being closed again before leaving setup().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I wanted to use the LED on pin 13 during loop() as a status indicator for the user, but it seems that after SD.begin(), pin 13 (and its LED) cannot be used as an OUTPUT anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a minimum sketch to show the behavior. It doesn't matter if I try to turn on the LED right after the call to SD.begin() in setup() or in loop():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define SD_CS  4&#xA;#define LED    13&#xA;&#xA;void setup() {&#xA;  pinMode(LED, OUTPUT);&#xA;&#xA;  // This still works:&#xA;  digitalWrite(LED, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LED, LOW);&#xA;&#xA;  SD.begin(SD_CS);&#xA;&#xA;  // This does not work anymore:&#xA;  digitalWrite(LED, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LED, LOW);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11415" LastEditorUserId="11415" LastEditDate="2015-07-25T16:22:42.027" LastActivityDate="2015-07-25T16:22:42.027" Title="Use LED on pin 13 again after using the SD library" Tags="|led|pins|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13699" PostTypeId="2" ParentId="13698" CreationDate="2015-07-25T16:11:59.210" Score="10" Body="&lt;p&gt;It is possible to use the LED on pin 13 again by disabling the SPI bus that is used by the SD library to read/write data to/from the SD card. To disable the SPI bus, simply call &lt;code&gt;SPI.end()&lt;/code&gt; after closing the file on the SD card.&lt;/p&gt;&#xA;" OwnerUserId="11415" LastActivityDate="2015-07-25T16:11:59.210" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13700" PostTypeId="2" ParentId="452" CreationDate="2015-07-25T16:43:39.877" Score="1" Body="&lt;p&gt;For debug and logging you can use the Mac Console app, it will show any errors that come up from the App. You might need to filter for Arduino App related messages though. &lt;/p&gt;&#xA;" OwnerUserId="11420" LastActivityDate="2015-07-25T16:43:39.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13702" PostTypeId="1" CreationDate="2015-07-25T18:00:38.860" Score="1" ViewCount="829" Body="&lt;p&gt;I'm trying to set up timer 1 to run an isr in CTC mode. no matter what i set OCR1A to it always executes at the same frequency and if i print out TCNT1 I get values higher than OCR1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void timer1_init()&#xA;    {&#xA;    // set up timer with prescaler = 8 and CTC mode&#xA;    TCCR1B |= (1 &amp;lt;&amp;lt; WGM12)|(0 &amp;lt;&amp;lt; CS12)|(1 &amp;lt;&amp;lt; CS11)|(0 &amp;lt;&amp;lt; CS10);&#xA;&#xA;    // initialize counter&#xA;    TCNT1 = 0;&#xA;&#xA;    // initialize compare value&#xA;    OCR1A = 100;&#xA;&#xA;    // enable compare interrupt&#xA;    TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;&#xA;&#xA;      // enable global interrupts&#xA;        sei();&#xA;    }&#xA;&#xA;ISR(TIMER1_COMPA_vect){&#xA;    SET(MOTOR_PORT,LEFT_MOTOR_STEP); //set the pin high&#xA;    delayMicroseconds(3); //keep high for a bit&#xA;    CLR(MOTOR_PORT,LEFT_MOTOR_STEP); //set it low&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this to drive a stepper motor so using PWM mode wont work.&lt;/p&gt;&#xA;" OwnerUserId="11421" LastActivityDate="2015-09-24T01:09:56.697" Title="UNO Timer 1 CTC mode not resetting TCNT1" Tags="|arduino-uno|interrupt|timers|isr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13703" PostTypeId="2" ParentId="13702" CreationDate="2015-07-25T20:18:49.550" Score="2" Body="&lt;p&gt;It sounds as though timer 1 has not in fact been set to wavegen mode 4. You can ensure that it is by also clearing the other bits of WGM1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1A &amp;amp;= ~(_BV(WGM10) | _BV(WGM11));&#xA;TCCR1B &amp;amp;= ~_BV(WGM13);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-25T20:18:49.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13704" PostTypeId="1" AcceptedAnswerId="13705" CreationDate="2015-07-25T20:37:45.863" Score="0" ViewCount="746" Body="&lt;p&gt;I want to know if controlling the speed of a DC motor with PWM could break (burn out the DC motor. Sorry my English isn't that good.&lt;/p&gt;&#xA;" OwnerUserId="10125" LastEditorUserId="9962" LastEditDate="2016-02-15T05:44:17.213" LastActivityDate="2016-02-15T05:44:17.213" Title="Can PWM break a DC motor?" Tags="|motor|pwm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13705" PostTypeId="2" ParentId="13704" CreationDate="2015-07-25T20:42:33.973" Score="0" Body="&lt;p&gt;Provided that the voltage specs of the motor are not violated, no. However, the inductance of the motor stands a very good chance of destroying the &lt;em&gt;switch&lt;/em&gt; unless an appropriately-rated &lt;a href=&quot;https://en.wikipedia.org/wiki/Flyback_diode&quot; rel=&quot;nofollow&quot;&gt;flyback diode&lt;/a&gt; is used.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-25T20:42:33.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13706" PostTypeId="1" CreationDate="2015-07-26T00:39:59.453" Score="0" ViewCount="102" Body="&lt;p&gt;I'd like to write a JavaScript function that lights up an led light for X milliseconds depending on the response from the JavaScript function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;function HowManySeconds() {&#xA;   setTimeout(HowManySeconds,5000)&#xA;   return 1000&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The JavaScript function will come from a website, so I suppose I would need an Internet enabled device that connects to my router and can 'browse' to my website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q: What do I need to buy? A &lt;a href=&quot;https://tessel.io/&quot; rel=&quot;nofollow&quot;&gt;tessel&lt;/a&gt;? An &lt;a href=&quot;http://www.espruino.com/&quot; rel=&quot;nofollow&quot;&gt;Espruino&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="11425" LastActivityDate="2015-07-28T07:06:04.420" Title="LIght bulb to light up" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13708" PostTypeId="2" ParentId="13704" CreationDate="2015-07-26T01:28:35.887" Score="0" Body="&lt;p&gt;Providing that you send the appropriate voltage this shouldn't break your motor. The creator of Arduino suggest this way of driving motor on his book.&#xA;Source: Massimo Banzi's book : &quot;getting started with arduino&quot; : chapter 5 Advanced Input and Output.&lt;/p&gt;&#xA;" OwnerUserId="11426" LastActivityDate="2015-07-26T01:28:35.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13709" PostTypeId="1" AcceptedAnswerId="13710" CreationDate="2015-07-26T03:34:22.510" Score="1" ViewCount="1088" Body="&lt;p&gt;I have a motor controller controlling two motors, which works perfectly fine when I comment out the two servos in the below code. These two servos are not connected to the motor controller but simply being operated using other Arduino Uno pins, as seen in the code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the servo &lt;code&gt;attach()&lt;/code&gt; functions are included in the code the motor controller only works with one of the motors and the other completely stops working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand why the servos are interfering with the motor controller. What's going on here?  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;Servo myServo1;  &#xA;Servo myServo2; &#xA;&#xA;int m1_ALI = 10; &#xA;int m1_BLI = 9; &#xA;int m2_ALI = 3;&#xA;int m2_BLI = 11; &#xA;&#xA;int m1_AHI = 12;&#xA;int m1_BHI = 4;&#xA;int m2_AHI = 6;&#xA;int m2_BHI = 5;&#xA;&#xA;void setup() { &#xA;&#xA;  //myServo1.attach(7); &#xA;  //myServo2.attach(8); &#xA;&#xA;  pinMode(m1_AHI, OUTPUT);&#xA;  pinMode(m1_ALI, OUTPUT);&#xA;  pinMode(m1_BLI, OUTPUT);&#xA;  pinMode(m1_BHI, OUTPUT);&#xA;  pinMode(m2_AHI, OUTPUT);&#xA;  pinMode(m2_ALI, OUTPUT);&#xA;  pinMode(m2_BLI, OUTPUT);&#xA;  pinMode(m2_BHI, OUTPUT); &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;moveForward(30);&#xA;&#xA;}//end loop&#xA;&#xA;void moveForward(int x){ &#xA;&#xA;    digitalWrite(m1_AHI, LOW);&#xA;    digitalWrite(m1_BLI, LOW);&#xA;    digitalWrite(m1_BHI, HIGH);&#xA;&#xA;    digitalWrite(m2_AHI, LOW);&#xA;    digitalWrite(m2_BLI, LOW);&#xA;    digitalWrite(m2_BHI, HIGH);&#xA;&#xA;    analogWrite(m2_ALI, x);&#xA;    analogWrite(m1_ALI, x);&#xA;}//end moveForward&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-07-26T03:52:46.417" Title="Servo motors won't work with motor controller" Tags="|arduino-uno|programming|motor|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13710" PostTypeId="2" ParentId="13709" CreationDate="2015-07-26T03:52:46.417" Score="2" Body="&lt;p&gt;See Servo.cpp: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.&#xA;   Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;https://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow&quot;&gt;Servo Library reference&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are using pins 9 and 10 for your motors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;analogWrite uses PWM, the servo library uses PWM, you have a conflict of resources here.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-26T03:52:46.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13711" PostTypeId="1" CreationDate="2015-07-26T05:22:47.960" Score="-1" ViewCount="44" Body="&lt;p&gt;Actually I don't know about Arduino, but seeing my fellow classmates, I want to start learning it. Could anybody tell what actually Arduino is about?&lt;/p&gt;&#xA;" OwnerUserId="11429" LastActivityDate="2015-07-26T05:57:46.720" Title="What is Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13712" PostTypeId="2" ParentId="13711" CreationDate="2015-07-26T05:57:46.720" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;What is Arduino?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLT6rF_I5kknPf2qlVFlvH47qHvqvzkknd&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino video tutorials&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/Products&quot; rel=&quot;nofollow noreferrer&quot;&gt;Official boards&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia - Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino forum&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A popular Arduino - The Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ovHc1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ovHc1.jpg&quot; alt=&quot;Arduino Uno&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case I get accused of writing a &quot;link-only&quot; answer ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is a hobbyist prototyping platform, where users can develop projects for microprocessors. Typically the boards have one or two processors on them, can connect to a PC/Mac/Linux by a USB interface, be programmed in C++, and operate external devices (eg. motors, lights, MIDI, LCD screens, LEDs) and take readings (eg. temperature, time, location, voltage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different boards have different capabilities, such as the number of I/O ports, the amount of memory, and the size of the program that can be uploaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect them to the major operating systems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Linux&lt;/li&gt;&#xA;&lt;li&gt;Macintosh&lt;/li&gt;&#xA;&lt;li&gt;Windows&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The hardware and software are open-source, making development for them easy.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Image attribution: &lt;a href=&quot;http://www.flickr.com/people/41898857@N04&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun Electronics&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-26T05:57:46.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13713" PostTypeId="2" ParentId="9617" CreationDate="2015-07-26T07:21:32.090" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;int n = wire.read();&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&quot;Wire&quot; should be capitalized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Amplifying on Ken's reply, you have two variables called &quot;n&quot;, &lt;strong&gt;and&lt;/strong&gt; the global one should be declared &lt;strong&gt;volatile&lt;/strong&gt;. Also, I&lt;sup&gt;2&lt;/sup&gt;C deals in bytes, not ints, so preferably do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin(2);                &#xA;  Wire.onRequest(requestEvents);&#xA;  Wire.onReceive(receiveEvents);&#xA;}&#xA;&#xA;void loop(){}&#xA;&#xA;volatile byte n = 0;&#xA;&#xA;void requestEvents()&#xA;{&#xA;  Wire.write(n);&#xA;}&#xA;&#xA;void receiveEvents(int howMany)&#xA;{  &#xA;  n = Wire.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In addition, the address 2 is a &lt;em&gt;reserved address&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Address 0 is reserved as a &quot;broadcast&quot; address, addresses 1 to 7 are reserved for other purposes, and addresses 120 to 127 are reserved for future use.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should choose an address in the range 8 to 119.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C - Two-Wire Peripheral Interface - for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.nxp.com/documents/user_manual/UM10204.pdf&quot; rel=&quot;nofollow&quot;&gt;Official I2C specification&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-26T07:21:32.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13715" PostTypeId="1" AcceptedAnswerId="21015" CreationDate="2015-07-26T08:45:00.113" Score="-1" ViewCount="5394" Body="&lt;p&gt;I don't understand how to publish to mqtt with retain option (The fourth parameters)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that I need length in an byte array but I've try allot to determine how to calculate my payload message to an byte var.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my code to publish once I am connected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str;&#xA;char chBright[4];&#xA;str = String(ledBrightness); //converting integer into a string&#xA;str = str + '%';&#xA;str.toCharArray(chBright, 4);&#xA;MQTTClient.publish(&quot;/maison/GF/Escalier/stairLight/b&quot;, chBright);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;document ask the third parameter to be an byte&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;topic – the topic to publish to &lt;code&gt;char*&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;payload – the message to publish &lt;code&gt;byte array&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;length – the length of the message &lt;code&gt;byte&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;retained – whether the message should be retained &lt;code&gt;byte&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;&lt;code&gt;0&lt;/code&gt; – not retained&lt;/p&gt;&#xA;    &#xA;    &lt;p&gt;&lt;code&gt;1&lt;/code&gt; – retained&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://knolleary.net/arduino-client-for-mqtt/api/#publish3&quot; rel=&quot;nofollow&quot; title=&quot;Arduino client for mQTT info doc&quot;&gt;mqtt client for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How in c++ to get bytes from the message I want to publish?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tank you to clarify my knowledge&lt;/p&gt;&#xA;" OwnerUserId="78" LastEditorUserId="13432" LastEditDate="2016-02-23T12:45:40.733" LastActivityDate="2016-02-23T12:52:39.893" Title="How to Publish to MQTT with retain option" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13716" PostTypeId="2" ParentId="13715" CreationDate="2015-07-26T09:03:40.283" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How in c++ to get bytes length from the message I want to publish?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a String object, the method &lt;code&gt;length()&lt;/code&gt; tells you the length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int len = str.length ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a null-terminated C-type string, you can use &lt;code&gt;strlen&lt;/code&gt;, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char foo [20] = &quot;bar&quot;;&#xA;int len = strlen (foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-26T09:03:40.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13717" PostTypeId="1" CreationDate="2015-07-26T11:37:05.837" Score="2" ViewCount="1033" Body="&lt;p&gt;Overflow enthusiasts!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a balancing robot with two wheels, using the polulu gear motor as mentioned above. In order to have a strong motor driver,the monster moto shield is used in this project. Here is the components and datasheets which is used.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Components&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Li-poly RC Battery 2800mah 11.1V 35C.&#xA;Arduino saint smart&#xA;2x Pololu 12V, 29:1 Gear Motor w/Encoder &#xA;Monster moto shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, back to the issue.. Well, the first problem I encountered was my motor driver. It keeps getting hot after a while, whenever I use it ( I run 2 motors through 1 driver). And the most frustrating part is that the motors can stop for a while, and then restart again ( suspect a hardware reset here). Is there any way this can be solved?, I have checked the datasheet for the monster moto driver but can't understand whether the components are already on the PCB boad or I manually have to add new components like resistors, capacitors and etc. Would be glad if you guys directed me on this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, The other problem I have is that the motors are going fast CW and slow CCW whenever I reverse direction. I have also seen other ppl getting the same problem as I do and wonder why this happen. Could it be that the cables are to small for the current flow ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I add external components ? Then which components should I use in order to subdue this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some pictures in order to clarify the problem. Mostly using cables to connect inputs and etc. I would be glad if you wonder something and want me to post more information.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;pictures:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E6ASY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E6ASY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mwstL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mwstL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;a href=&quot;https://i.stack.imgur.com/yydCJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yydCJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  MonsterMoto Shield Example Sketch&#xA;  date: 5/24/11&#xA;  code by: Jim Lindblom&#xA;  hardware by: Nate Bernstein[![enter image description here][1]][1]&#xA;  SparkFun Electronics&#xA; This is really simple example code to get you some basic&#xA; functionality with the MonsterMoto Shield. The MonsterMote uses&#xA; two VNH2SP30 high-current full-bridge motor drivers.&#xA;&#xA; Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm) &#xA; function to get motors going in either CW, CCW, BRAKE[![enter image description here][1]][1]VCC, or &#xA; BRAKEGND. Use motorOff(int motor) to turn a specific motor off.&#xA;&#xA; The motor variable in each function should be either a 0 or a 1.&#xA; pwm in the motorGo function should be a value between 0 and 255.&#xA;&#xA;This code is beerware; if you see me (or any other SparkFun employee) at the&#xA;local, and you've found our code helpful, please buy us a round!&#xA;Distributed as-is; no warranty is given.&#xA; */&#xA;#define BRAKEVCC 0&#xA;#define CW   1&#xA;#define CCW  2&#xA;#define BRAKEGND 3&#xA;#define CS_THRESHOLD 100&#xA;&#xA;/*  VNH2SP30 pin definitions&#xA; xxx[0] controls '1' outputs&#xA; xxx[1] controls '2' outputs */&#xA;int inApin[2] = {7, 4};  // INA: Clockwise input&#xA;int inBpin[2] = {8, 9}; // INB: Counter-clockwise input&#xA;int pwmpin[2] = {5, 6}; // PWM input&#xA;int cspin[2] = {2, 3}; // CS: Current sense ANALOG input&#xA;int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)&#xA;&#xA;int statpin = 13;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(statpin, OUTPUT);&#xA;&#xA;  // Initialize digital pins as outputs&#xA;  for (int i=0; i&amp;lt;2; i++)&#xA;  {&#xA;    pinMode(inApin[i], OUTPUT);&#xA;    pinMode(inBpin[i], OUTPUT);&#xA;    pinMode(pwmpin[i], OUTPUT);&#xA;  }&#xA;  // Initialize braked&#xA;  for (int i=0; i&amp;lt;2; i++)&#xA;  {&#xA;    digitalWrite(inApin[i], LOW);&#xA;    digitalWrite(inBpin[i], LOW);&#xA;  }&#xA;  // motorGo(0, CW, 1022e3);&#xA;  // motorGo(1, CCW, 1023);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  motorGo(0, CW, 1023);&#xA;  motorGo(1, CW, 1023);&#xA;  delay(500);&#xA;  motorGo(0, CCW, 1023);&#xA;  motorGo(1, CCW, 1023);&#xA;  delay(50);&#xA;  if ((analogRead(cspin[0]) &amp;lt; CS_THRESHOLD) &amp;amp;&amp;amp; (analogRead(cspin[1]) &amp;lt; CS_THRESHOLD))&#xA;    digitalWrite(statpin, HIGH);&#xA;}&#xA;&#xA;void motorOff(int motor)&#xA;{&#xA;  // Initialize braked&#xA;  for (int i=0; i&amp;lt;2; i++)&#xA;  {&#xA;    digitalWrite(inApin[i], LOW);&#xA;    digitalWrite(inBpin[i], LOW);&#xA;  }&#xA;  analogWrite(pwmpin[motor], 0);&#xA;}&#xA;&#xA;/* motorGo() will set a motor going in a specific direction&#xA; the motor will continue going in that direction, at that speed&#xA; until told to do otherwise.&#xA;&#xA; motor: this should be either 0 or 1, will selet which of the two&#xA; motors to be controlled&#xA;&#xA; direct: Should be between 0 and 3, with the following result&#xA; 0: Brake to VCC&#xA; 1: Clockwise&#xA; 2: CounterClockwise&#xA; 3: Brake to GND&#xA;&#xA; pwm: should be a value between ? and 1023, higher the number, the faster&#xA; it'll go&#xA; */&#xA;void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)&#xA;{&#xA;  if (motor &amp;lt;= 1)&#xA;  {&#xA;    if (direct &amp;lt;=4)&#xA;    {&#xA;      // Set inA[motor]&#xA;      if (direct &amp;lt;=1)&#xA;        digitalWrite(inApin[motor], HIGH);&#xA;      else&#xA;        digitalWrite(inApin[motor], LOW);&#xA;&#xA;      // Set inB[motor]&#xA;      if ((direct==0)||(direct==2))&#xA;        digitalWrite(inBpin[motor], HIGH);&#xA;      else&#xA;        digitalWrite(inBpin[motor], LOW);&#xA;&#xA;      analogWrite(pwmpin[motor], pwm);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;regards, Volkan&lt;/p&gt;&#xA;" OwnerUserId="11433" LastEditorUserId="2881" LastEditDate="2015-07-27T12:24:40.853" LastActivityDate="2015-07-27T12:24:40.853" Title="Monster moto shield + Arduino +Pololu 12V, 29:1 Gear Motor Encoder hardware problem" Tags="|arduino-mega|motor|arduino-motor-shield|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13718" PostTypeId="1" AcceptedAnswerId="13722" CreationDate="2015-07-26T12:48:30.730" Score="3" ViewCount="7201" Body="&lt;p&gt;I want to build a remote sensor which will measure temperature (range 5-30°C) and humidity (range 20-90%) and provide regularly (in the range of one measurement every minute or tenth of minutes) the measurement via wireless. This sensor will be used indoor, mostly in dark areas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: measurement could be done every minutes and sending them could be done immediately or in batch of 10 measurements or more).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was looking to build this solution using an Arduino, DHT22 sensor and a radio transmitter using ZigBee or Z-Wave protocol, and power it via AA rechargeable batteries. But after studying this solution, I found that it would be challenging to even get &lt;strong&gt;a week of battery life&lt;/strong&gt;, this would require using the radio sparingly and to try to use as much as possible the power modes of the Arduino ATmel controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's &lt;strong&gt;not enough&lt;/strong&gt;, I want a battery life in the range of several months, 1 month would be &quot;acceptable&quot;, &lt;strong&gt;6 months would be the target&lt;/strong&gt;, breakthrough would be &gt; 1 year.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I don't want wifi, this seems to suck even more power than the other mentioned radio protocol&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Questions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is there another more power efficient way to wireless-ly transmit the data?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or shall I reconsider Arduino all together and look for another more power efficient controller?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there another way?&lt;/p&gt;&#xA;" OwnerUserId="11225" LastActivityDate="2017-09-09T15:45:36.937" Title="Remote temperature and humidity sensor with long battery life" Tags="|power|battery|temperature-sensor|wireless|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13719" PostTypeId="2" ParentId="13718" CreationDate="2015-07-26T13:50:09.910" Score="1" Body="&lt;p&gt;Sleep mode of a Zigbee is around 5uA. Power-down mode of an arduino is about the same. You can power the DHT22 via one of the digital pins, so it only uses power if you need it (though I thing you need to give it some time to &quot;warm up&quot;). So I don't see much of a problem. You just need to get the software working right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, don't use an Uno, but one of the more bare-bones boards (e.g. Pro Mini) that don't have an usb-to-serial chip on board. Remove the power-led. Maybe remove the voltage regulator, and use 3 AAs for 4.5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use blank ATMega328 chips, and build my own &quot;arduinos&quot; without all the unnecessary parts. I'm currently working on something similar, and plan on using an CR2032 coincell for power. &gt;1 Year should be possible as far as I can see. If not I'll switch to AAs (11 times more power).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-26T13:50:09.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13720" PostTypeId="1" AcceptedAnswerId="13723" CreationDate="2015-07-26T14:19:01.460" Score="1" ViewCount="678" Body="&lt;p&gt;I'm first time working with a Teensy 3.1. I have to connect this (MS5803-01BA: &lt;a href=&quot;http://www.amsys.de/products/ms5803.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.amsys.de/products/ms5803.htm&lt;/a&gt;) pressure sensor via SPI to my Teensy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is, that I don't have any reliable knowledge on SPI. I read the Wikipedia for it and also the Teensy-Manual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the pressure sensor I already got a C-Code but it is only working with the ATMEL ATmega644p microcontroller. I tried to get the code to work with my Teensy, but it seems like I don't get either any input nor any output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that one of you can help me with the following code and tell me what I'm missing out on. Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/xaWXfRUR&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/xaWXfRUR&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Datasheet of the pressure sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.amsys.de/sheets/amsys.de.ms5803_01b.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C-Code for the pressure sensor for the ATMEL ATmega644p microcontroller:&#xA;&lt;a href=&quot;http://www.amsys.de/sheets/amsys.de.an520_e.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.amsys.de/sheets/amsys.de.an520_e.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;PS: Please excuse my not perfect English for it's not my native language.&lt;/p&gt;&#xA;" OwnerUserId="11434" LastEditorUserId="10794" LastEditDate="2016-01-23T02:58:19.823" LastActivityDate="2016-03-23T03:18:27.483" Title="Teensy: SPI and Pressure Sensor" Tags="|sensors|spi|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13721" PostTypeId="1" CreationDate="2015-07-26T16:14:06.683" Score="2" ViewCount="224" Body="&lt;p&gt;I am attempting to interface an Arduino Mega 2560 with a system of four Black Jaguar motor controllers connected in CAN. I'm using the CAN shield from SeeedStudios to accomplish this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way Jaguars in CAN mode are configured, you must send a message every 100 ms to the network to keep the link active. However, I'm also getting input from Serial to another Arduino as well as sending other commands to the Jaguars, but not regularly enough to specifically time it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have the link message sent asynchronously in the background while I perform other code? I have looked into timers and interrupts, however I am unsure if this would truly solve the issue considering I have other processes that take more than 100 ms to complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my loop statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;  CAN.sendMsgBuf(HEARTBEAT,1,0,volModeEnable); //HEARTBEAT keeps CAN link active&#xA;  setVoltage(3,.5); //Sets voltage of Motor by percent&#xA;  setVoltage(4,.5);&#xA;  setVoltage(6,.5);&#xA;  setVoltage(8,.5);&#xA;  //GrabFromSerial(); Takes longer than 100ms&#xA;  //Control Statement for Additional Commands goes here... (also necessary to be &amp;gt; 100ms)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11436" LastEditorUserId="4628" LastEditDate="2018-04-16T10:54:09.753" LastActivityDate="2021-07-29T22:00:30.070" Title="Background processes - Arduino Mega and SeeedStudio CAN shield" Tags="|programming|can-bus|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13722" PostTypeId="2" ParentId="13718" CreationDate="2015-07-26T21:07:58.673" Score="4" Body="&lt;p&gt;I made a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;Temperature and humidity sensor - battery powered&lt;/a&gt; in 2013. It is powered from 3 x AA batteries, and lasted, as I recall, until a couple of months ago before I changed the batteries. That is, almost two years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It logs to an SD card every 15 minutes. You could change that interval of course, it would probably not last as long logging every minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uWSdG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uWSdG.png&quot; alt=&quot;Temperature and humidity sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I certainly wouldn't attempt it with a pre-made board, because of the drain by the power LEDs, the USB chip, the voltage regulator, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I measured 6 µA consumption when asleep. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Schematic&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f1AFf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f1AFf.png&quot; alt=&quot;Temperature logger schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(RH-click and &quot;View Image&quot; to see a larger version)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schematic is deliberately presented as &quot;blocks&quot; of parts of the circuit. To understand it from scratch, make up individual parts, test them and get the code working to your satisfaction. For example, the clock or the temperature sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the parts (like the clock) are already available as pre-assembled boards, if you prefer to reduce soldering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could manage without the 7-segment LED readout, however I found it useful for confirming it is working &quot;in the field&quot;. The readout LEDs can be purchased cheaply from eBay for around $US 3. Search for &lt;code&gt;MAX7219 8-Digit LED Display Module 7-Segment&lt;/code&gt; or similar.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Example output&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Example of measuring temperature and humidity every minute:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sl9ep.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sl9ep.png&quot; alt=&quot;Spreadsheet of temperatures&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fg5fZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fg5fZ.png&quot; alt=&quot;Graph of temperatures&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from the graph that I left the room at 9:30 pm, and the temperature slowly dropped until 6:30 am the next morning. The zig-zag effect is the central heating turning on and off.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Construction details&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;linked page&lt;/a&gt; for construction notes, schematic, and code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power saving details at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Estimated life at logging once a minute&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If my calculations are correct, logging every minute might reduce battery life to 7 months (these things are best tested of course), but that is because the consumption is much higher when you power up the SD card. It would probably be best to take 15 readings, and then write to the card every 15 minutes. The extra time writing would be minimal, and that would keep the need to power up the card low.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;The 7-segment LEDs&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To clarify, those 8 LEDs are not normally on. The battery wouldn't last long if they were! If you press the switch it gives an immediate reading through the LEDs, and also tells you how many writes to disk it has done, and how many write errors it has had. This confirms all is operating properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;busy&quot; LED is there to warn you to not remove the SD card while it is writing to it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Radio communication&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To transmit information you could use a NRF24L01 transceiver module. You get those for a couple of dollars on eBay. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qdss4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qdss4.jpg&quot; alt=&quot;NRF24L01 top&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Underneath:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qYYS6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qYYS6.jpg&quot; alt=&quot;NRF24L01 bottom&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need another one at the other end to receive (you would need two of whatever radio you chose).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12821&quot; rel=&quot;nofollow noreferrer&quot;&gt;solar powered project&lt;/a&gt; using a couple of those. The NRF24L01 uses about 0.9 µA in power-down mode, so that is pretty minimal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also uses SPI, so the connections would be very similar to the SD card connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest if you are going to attempt this to first get confident with a normal Uno, get the code tested, make sure you have the sleeping/waking going OK, then move it to a low-power board. There are places like &lt;a href=&quot;http://shop.evilmadscientist.com/directory&quot; rel=&quot;nofollow noreferrer&quot;&gt;Evil Mad Scientist&lt;/a&gt; that make &quot;bare&quot; boards, with a prototyping area, which you can use to put things like your temperature sensor on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iUkhM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iUkhM.jpg&quot; alt=&quot;Bare bones board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-27T04:51:02.707" LastActivityDate="2015-07-27T04:51:02.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13723" PostTypeId="2" ParentId="13720" CreationDate="2015-07-26T21:15:17.043" Score="1" Body="&lt;p&gt;Details about SPI at &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI - Serial Peripheral Interface - for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  SPI.transfer(CMD_ADC_READ); // send ADC read command&#xA;  SPDR = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)&#xA;  ret = SPDR;&#xA;  temp = 65536 * ret;&#xA;  SPDR = SPI.transfer(0x00); // send 0 to read 2nd byte&#xA;  ret = SPDR;&#xA;  temp = temp + 256 * ret;&#xA;  SPDR = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The SPI library handles SPDR for you. Writing to it yourself will corrupt its behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  SPI.transfer(CMD_ADC_READ); // send ADC read command&#xA;  ret = SPI.transfer(0x00); // send 0 to read 1st byte (MSB)&#xA;  temp = 65536 * ret;&#xA;  ret = SPI.transfer(0x00); // send 0 to read 2nd byte&#xA;  temp = temp + 256 * ret;&#xA;  ret = SPI.transfer(0x00); // send 0 to read 3rd byte (LSB)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ditto for elsewhere.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-26T21:15:17.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13724" PostTypeId="1" CreationDate="2015-07-26T21:28:00.913" Score="2" ViewCount="146" Body="&lt;p&gt;I started working on a small programming project just for fun and I have got stuck. I have been using the following tutorial to make an &lt;a href=&quot;https://i.stack.imgur.com/pXTU7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Amiibo Music Box&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now using the libraries the tutorial suggested, I successfully uploaded the sketch to the device. However when I put an Amiibo or NFC card on top and look at the Serial Monitor, I get lots of garble and no sound.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;¸ý×ÿòœy_ÿ#À–Yÿ›l°   _Yÿ8dÐa4’ÿ’Í�©ÿ›—Lµ›ú’áo°)h@’öþ8‚¤hþ:dÐ S4ê’ÉãÈô›l°É�°ò“ƒc¶ÿ™l±a“ùü8‚´hþ›l°É�´÷“ÅiØð&#xA;¶–t=Üý’ÉãÈôâd@àÉ‘ø8‚¤hþ&#xA;–e¼Õý’ÍÐPÿK¬ÀàÉ�ú8�·i™–e¼Õý8©Pòý’t=Üý“ƒf–ÿü’t=Ø9UY6þ›hX Cú’Í�©ÿ(l„±Ô_ü8‚´hþKìAÀò ý:‚´hþ8lÐaÓ4â’ÌcÈõ›hX Cú“ƒf–ÿKìEÀò ý’ÌiØõ8lÐaâtý“ƒ&amp;amp;–ÿè4@’âþ“ƒ&amp;amp;–ÿš’L²µšý8�·yÿ)l„úÈï’ÉãÈõ(l„±Ô_ü’ÍÙ:dÐ`S4ê2&quot;´žþ)l„úÈï2&quot;ßŸÿ›h±ÑªÛÖ’áoÞÿüÒt=Ø‘�&amp;amp;’ÿ�šA’âþ“ƒc¶þ›l±ÑªËÓ’Í�©ÿ8lÐaâtý’ÍÙ&#xA;––\5,ÿ’Í�©ÿè4@àâþ8©Pòý–t=Üý:‚´hþ&#xA;––t=Üý8‚´hþ8l€a¢tý’ÉãÈõš’L²µšýÜ,þÍ›þëÖÿÜ,þÜ,ÿÜ,ÿYÿ\ÿëòÿÜ,þêëòÿëòÿê4KÖÿ\ÿ]ÓÜ,ÿ\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried the card that comes with the kit and it does not work either. Has anyone got any idea why this has failed? I have put a link to the libraries and code I am using below.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ModusPwnin/Interactive-Amiibo-Stand&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ModusPwnin/Interactive-Amiibo-Stand&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ModusPwnin/Interactive-Amiibo-Stand/blob/master/Amiibo%20Stand%20v3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/ModusPwnin/Interactive-Amiibo-Stand/blob/master/Amiibo%20Stand%20v3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit_NFCShield_I2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/Adafruit_NFCShield_I2C&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://code.google.com/p/wavehc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://code.google.com/p/wavehc/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am new to this but I want to understand why this is not working as well. Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="11442" LastEditorUserId="2944" LastEditDate="2015-08-01T14:40:09.700" LastActivityDate="2015-08-01T14:40:09.700" Title="Arduino with NFC: Garbled Serial Monitor" Tags="|arduino-uno|serial|shields|library|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13725" PostTypeId="2" ParentId="13671" CreationDate="2015-07-26T21:29:21.337" Score="1" Body="&lt;p&gt;Thanks for your answers. I solved this problem, my Chinese copy has problems with power.&lt;/p&gt;&#xA;" OwnerUserId="11396" LastEditorUserId="11529" LastEditDate="2015-08-17T11:14:17.703" LastActivityDate="2015-08-17T11:14:17.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13727" PostTypeId="1" CreationDate="2015-07-26T22:18:30.570" Score="1" ViewCount="1042" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have an ATmega328 chip with the boot-loader installed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also have an Arduino Uno with the ATmega328 chip removed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I hooked this chip up to a breadboard with the proper 22pF caps, 16MHz crystal, and 10k&amp;Omega; pull-up resistor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The LED flasher was loaded prior, and this works fine when I hook an LED and resistor up to pin 19. I have confirmed my external crystal works by disconnecting it, and the flashing stops, when I reconnect the crystal, the flashing continues.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Power is fed from my Arduino Uno 5 V out to the DIY Arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I connected the reset wire, and data wires, ensuring pin 2 went to RX and pin 3 to TX. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In the software&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First to confirm everything works, I removed the chip from the breadboard and placed it in the Arduino. The sketch uploaded successfully using the settings:  Arduino Uno as board and AVRISP mkll as programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I move the chip to the breadboard, and ensure all the wires are connected. The LED starts to blink again, but when I try to upload the sketch, I get an error: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ensure continuity between the reset, TX, RX, and power connections and try different settings like Arduino as ISP and different boards under settings including the Duemilanove and nano but nothing seems to be working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on what to try next? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QIllx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QIllx.jpg&quot; alt=&quot;Photo of circuit on breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11444" LastEditorUserId="10794" LastEditDate="2015-07-29T06:26:04.023" LastActivityDate="2016-03-31T19:04:21.440" Title="Can't upload sketches to breadboard Arduino" Tags="|arduino-uno|programming|uploading|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13729" PostTypeId="2" ParentId="3929" CreationDate="2015-07-27T01:41:49.237" Score="5" Body="&lt;p&gt;You can setup interrupts on the Attiny with some different code, but it works the same way. It's important to note that PIN Change Interrupts are triggered at BOTH Rising and Falling Edge&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gpt63.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gpt63.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino-Tiny Cores&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a sample code which used a Pin Change Interrupt on PB1 which switches an LED on and off on PB4.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Includes&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;#define INTERRUPTPIN PCINT1 //this is PB1 per the schematic&#xA;#define PCINT_VECTOR PCINT0_vect  //this step is not necessary&#xA;#define DATADIRECTIONPIN DDB1 //Page 64 of data sheet&#xA;#define PORTPIN PB1 //Page 64&#xA;#define READPIN PINB1 //page 64&#xA;#define LEDPIN 4 //PB4&#xA;&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) //OR&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit)) //AND&#xA;&#xA;/*&#xA; * Alias for the ISR: &quot;PCINT_VECTOR&quot; (Note: There is only one PCINT ISR. &#xA; * PCINT0 in the name for the ISR was confusing to me at first, &#xA; * hence the Alias, but it's how the datasheet refers to it)&#xA; */&#xA;&#xA;static volatile byte LEDState; //variable used within ISR must be declared Volatile.&#xA;&#xA;void setup() {&#xA;    cli();//disable interrupts during setup&#xA;    pinMode(LEDPIN, OUTPUT); //we can use standard arduino style for this as an example&#xA;    digitalWrite(LEDPIN, LOW); //set the LED to LOW&#xA;    LEDState = 0; //we use 0 for Low state and 1 for High&#xA;    PCMSK |= (1 &amp;lt;&amp;lt; INTERRUPTPIN); //sbi(PCMSK,INTERRUPTPIN) also works but I think this is more clear // tell pin change mask to listen to pin2 /pb3 //SBI&#xA;    GIMSK |= (1 &amp;lt;&amp;lt; PCIE);   // enable PCINT interrupt in the general interrupt mask //SBI&#xA;&#xA;    DDRB &amp;amp;= ~(1 &amp;lt;&amp;lt; DATADIRECTIONPIN); //cbi(DDRB, DATADIRECTIONPIN);//  set up as input  - pin2 clear bit  - set to zero&#xA;    PORTB |= (1&amp;lt;&amp;lt; PORTPIN); //cbi(PORTB, PORTPIN);// disable pull-up. hook up pulldown resistor. - set to zero&#xA;    sei(); //last line of setup - enable interrupts after setup&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  //If you connect a debounced pushbutton to PB2 and to VCC you can tap the button and the LED will come on&#xA;  //tap the button again and the LED will turn off.&#xA;&#xA;}&#xA;&#xA;&#xA;//this is the interrupt handler&#xA;ISR(PCINT_VECTOR)&#xA;{&#xA;  //Since the PCINTn triggers on both rising and falling edge let's just looks for rising edge&#xA;  //i.e. pin goes to 5v&#xA;  byte pinState;&#xA;  pinState = (PINB &amp;gt;&amp;gt; READPIN)&amp;amp; 1; //PINB is the register to read the state of the pins&#xA;  if (pinState &amp;gt;0) //look at the pin state on the pin PINB register- returns 1 if high&#xA;  {&#xA;   if (LEDState == 0)&#xA;   {&#xA;    digitalWrite(LEDPIN,HIGH); //you can use Arduino Code or LowerLevel Code to write to the register&#xA;    LEDState = 1; &#xA;    }&#xA;   else&#xA;   {&#xA;    digitalWrite(LEDPIN,LOW);&#xA;    LEDState = 0;&#xA;    }&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're going to be using the ATTiny85, I highly suggest you read through the data sheet to understand better how to program these chips at a lower level of code....It took me a while for it to start to make sense.&lt;/p&gt;&#xA;" OwnerUserId="11075" LastEditorUserId="11075" LastEditDate="2015-07-27T23:00:53.610" LastActivityDate="2015-07-27T23:00:53.610" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="13730" PostTypeId="2" ParentId="13718" CreationDate="2015-07-27T03:43:21.150" Score="2" Body="&lt;p&gt;There is an excellent article on power reduction at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt; , but it's definitely worth looking at the parts of your project OTHER than the arduino - that is, your sensor, and your radio. These tend to use much more than your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some persistent storage on the Arduino - EEPROM - write all your data to that as you read it, then send it all in bulk. Most of the time your radio will spend will be start/end communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Making your board is not as daunting as it seems. Use a breadboard to develop &amp;amp; test your project, then use stripboard (aka veroboard) to build your project. You can cut the tracks with a sharp utility knife, or with a specialized stripboard cutting tool (accurate &amp;amp; easier than a knife).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are still nervous, find your local makerspace or hackerspace - there are people there that would be happy to teach you to solder, and help you work out your ideas.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-27T03:43:21.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13732" PostTypeId="1" AcceptedAnswerId="13745" CreationDate="2015-07-27T10:31:50.467" Score="0" ViewCount="78" Body="&lt;pre&gt;&lt;code&gt;int motor_forward1 = 7;&#xA;int motor_reverse1 = 6;&#xA;int motor_forward2 = 5;&#xA;int motor_reverse2 = 4;&#xA;int motor_forward3 = 3;&#xA;int motor_reverse3 = 2;&#xA;int sensor1 = A0;&#xA;int sensor2 = A1;&#xA;&#xA; void setup() &#xA;{&#xA;&#xA;   pinMode(motor_forward1, OUTPUT);&#xA;   pinMode(motor_reverse1, OUTPUT);&#xA;   pinMode(motor_forward2, OUTPUT);&#xA;   pinMode(motor_reverse2, OUTPUT);&#xA;   pinMode(motor_forward3, OUTPUT);&#xA;   pinMode(motor_reverse3, OUTPUT);&#xA;   pinMode(sensor1, INPUT);&#xA;   pinMode(sensor2, INPUT);&#xA; }&#xA;&#xA; void loop()&#xA; {&#xA;   if (digitalRead(A0) == HIGH)&#xA;   {&#xA;     digitalWrite(motor_forward1,1);&#xA;     digitalWrite(motor_reverse1,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward1,0);&#xA;     digitalWrite(motor_reverse1,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward1,0);&#xA;     digitalWrite(motor_reverse1,0);&#xA;     delay(1000);&#xA;   }&#xA;   else if (digitalRead(A1) == HIGH)&#xA;   {&#xA;     digitalWrite(motor_forward2,1); &#xA;     digitalWrite(motor_reverse2,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward2,0);&#xA;     digitalWrite(motor_reverse2,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward2,0);&#xA;     digitalWrite(motor_reverse2,0);&#xA;     delay(1000);&#xA;   }&#xA;   else&#xA;   {&#xA;     digitalWrite(motor_forward3,1); &#xA;     digitalWrite(motor_reverse3,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward3,0);&#xA;     digitalWrite(motor_reverse3,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward3,0);&#xA;     digitalWrite(motor_reverse3,0);&#xA;     delay(1000);&#xA;   }&#xA;   delay(5000);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Schematic &lt;a href=&quot;https://i.stack.imgur.com/Fz92a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="11449" LastEditDate="2015-07-27T18:29:37.780" LastActivityDate="2015-07-28T02:03:12.693" Title="that no matter what the inputs are Motor1 always moves" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="13733" PostTypeId="1" CreationDate="2015-07-27T12:38:30.407" Score="0" ViewCount="1726" Body="&lt;p&gt;How can I tackle self-diagnosis problem within my Arduino project?&#xA;For example, I have a temperature sensor and humidity sensor. How can I know if they work or not on Arduino start or inside the sketch loop?&lt;/p&gt;&#xA;" OwnerUserId="11447" LastEditorUserId="10794" LastEditDate="2015-07-27T20:40:58.677" LastActivityDate="2015-07-27T21:58:40.907" Title="Self-diagnose components in the circuit" Tags="|arduino-uno|sensors|debugging|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13734" PostTypeId="2" ParentId="13733" CreationDate="2015-07-27T14:00:26.280" Score="2" Body="&lt;p&gt;You could get your program to output messages to the serial pin on your board, Tx. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600) //baud rate of 9600&#xA;&#xA;Serial.print(&quot;Debug Message&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this to print out string and integers. Here is the link to further information on the Arduino website - &lt;a href=&quot;https://www.arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/reference/serial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are already using the Serial pins then you could use the SoftwareSerial Library - &lt;a href=&quot;https://www.arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/softwareSerial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This library allows you to make two other pins on your board Tx and Rx. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(12,13) //Makes pin 12 Rx and pin 13 Tx&#xA;&#xA;mySerial.begin(9600) //baud rate of 9600&#xA;&#xA;mySerial.println(&quot;Debug Message&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To read the output from any of the pins on your arduino - use a USB to TTL serial cable. Plug it into your computer and use a program like PuTTY to connect to the serial cable and read the messages coming from the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="11451" LastActivityDate="2015-07-27T14:00:26.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13735" PostTypeId="2" ParentId="12650" CreationDate="2015-07-27T17:53:32.857" Score="1" Body="&lt;p&gt;There is a difference between Wifi and Wireless. Wifi requires an already established network and uses the standard internet protocols. If this is what you mean, then the communication speed would only be influenced by the bandwidth of your network and the speed of the arduinos. I have not been able to find what the speeds of the modules are, but if they are 150 mB/s and your network is only 100, then you'll only get a speed of 100mB/s (which is a pretty decent speed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want wireless (they create their own network using the unlicensed 2.4ghz spectrum, then buy these: nRF24L01+ 2.4GHz. They seem pretty reliable at short distances, and have a low power and high power variant. These have a speed of (at tops) 2 mB/s, but you won't have to worry about having a Wifi connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally do not know much about Bluetooth modules, so I cannot comment there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helped.&lt;/p&gt;&#xA;" OwnerUserId="11238" LastActivityDate="2015-07-27T17:53:32.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13736" PostTypeId="1" AcceptedAnswerId="13753" CreationDate="2015-07-27T18:37:22.640" Score="2" ViewCount="4348" Body="&#xA;&#xA;&lt;p&gt;This is a part of my program which reads data from file stored in SD card and displays that on an LCD screen.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  File dataFile = SD.open(&quot;1165.txt&quot;);&#xA;&#xA;&#xA;  if (dataFile) {&#xA;    Serial.println(&quot;File Opened&quot;);&#xA;    lcd.clear();&#xA;       delay( 5 );  //LCD-specific M&#xA;       lcd.setCursor( 0,0 );&#xA;&#xA;&#xA;  while (dataFile.available()) {&#xA;      Serial.write(dataFile.read());&#xA;      lcd.write(dataFile.read());&#xA;      lcd.print(dataFile.read());&#xA;    }&#xA;  dataFile.close();&#xA;  } else {&#xA;    // if the file didn't open, print an error:&#xA;    Serial.println(&quot;error&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I look at the serial monitor it prints the contents of that file but none of these commands print what is printed in the serial monitor,&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;lcd.write(dataFile.read());&#xA;lcd.print(dataFile.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="11285" LastEditorUserId="10794" LastEditDate="2015-07-29T06:28:02.303" LastActivityDate="2021-03-26T18:22:10.707" Title="Printing SD card file contents on LCD" Tags="|arduino-mega|c++|lcd|sd-card|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13738" PostTypeId="2" ParentId="13733" CreationDate="2015-07-27T20:51:05.753" Score="1" Body="&lt;p&gt;If you can define &quot;it works&quot; in code (e.g. the temperature is between X and Y degrees, and changes no faster than 2 degrees per second), and all you need is a &quot;Yes&quot; or a &quot;No&quot;, then you can write this into code, then the easiest way is to use an LED. Make sure you blink it, rather than having it on steadily, so you can tell if it's frozen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you try unplugging your sensor, to understand what it does when it fails; this is one thing you specifically want to test for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you specifically do not want to do this in your main loop, you can do an interrupt-driven version, but that adds a lot of complexity. I suggest you do it in your main loop if you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the current time to blink the light regularly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (everything_is_working()) {&#xA;  if (millis()%10000&amp;lt;1000) {&#xA;     &amp;lt;turn led on&amp;gt;&#xA;  } else {&#xA;     &amp;lt;turn led off&amp;gt;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The two numbers let you control the flashes. I've used 10,000 and 1,000; this means that out of every 10,000 millis (10 seconds), the led is on 1,000 millis (1 second). Depending on your preference, you can adjust these to your liking. You can also add an else clause which blinks a different pattern depending on what is wrong - 9 seconds on out of 10 for a problem with the humidity sensor, and 5 seconds out of 10 for the temperature sensor having issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your sketch isn't running, the led will stay in it's current state - either on, or off, indefinitely. If your project has no power, the light will obviously be off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want more data, you can either make more complex blink codes - short-long-short-long, for example - or add multiple lights, or even a three-colour LED, with different colours indicating different problems.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-07-27T20:57:41.037" LastActivityDate="2015-07-27T20:57:41.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13739" PostTypeId="2" ParentId="1374" CreationDate="2015-07-27T21:35:23.967" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What I want to know is &quot;how do I write a program such that it is considered valid both by the Arduino IDE and g++.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to avoid the quirks of the IDE sketch file pre-preprocessing&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disregarding for the moment what the Makefile will look like, the simple answer to your question, as discussed in the above link, is to put everything into .cpp and .h tabs in the IDE, and leave the main &quot;sketch&quot; (.ino file) blank. That will still compile under the IDE, and will also therefore be normal C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you start your .cpp files with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you use libraries (eg, SPI) you must include them in the main sketch file, which triggers the IDE to copy them into the temporary project build file. The Makefile won't care about that, as you will make sure your Makefile includes all the necessary library files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see my answer here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-i-actually-need-to-use-them/13182#13182&quot;&gt;Classes and objects: how many and which file types do I actually need to use them?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-07-27T21:35:23.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13740" PostTypeId="2" ParentId="13733" CreationDate="2015-07-27T21:58:40.907" Score="1" Body=" &#xA;&#xA;&lt;p&gt;Another approach can be handy if you want to do detailed debugging (like outputting numbers) but your serial port is already in use for something, like a GPS. You can use a second Arduino as a &quot;debugging interface&quot; using SPI or I2C. For example, using SPI:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V0aI6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V0aI6.jpg&quot; alt=&quot;Debug via SPI&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or via I2C:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SLwei.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SLwei.jpg&quot; alt=&quot;Debug via I2C&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In these examples the &quot;debugging&quot; Uno also supplies power to the &quot;main&quot; Uno via the 5 V / Gnd pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a description about this method on &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11329&quot; rel=&quot;nofollow noreferrer&quot;&gt;Debugging using SPI/I2C and a second processor&lt;/a&gt;. Code is available at: &lt;a href=&quot;http://gammon.com.au/Arduino/SPI_Debugging.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://gammon.com.au/Arduino/SPI_Debugging.zip&lt;/a&gt; and &lt;a href=&quot;http://gammon.com.au/Arduino/I2C_Debugging.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://gammon.com.au/Arduino/I2C_Debugging.zip&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To demonstrate the idea, on the &quot;main&quot; Uno this is an example of sending debugging info via SPI:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// make true to debug, false to not&#xA;#define DEBUG true&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;// conditional debugging&#xA;#if DEBUG &#xA;&#xA;  #define beginDebug()  do { SPI.begin (); SPI.setClockDivider(SPI_CLOCK_DIV8); } while (0)&#xA;  #define Trace(x)      SPIdebug.print   (x)&#xA;  #define Trace2(x,y)   SPIdebug.print   (x,y)&#xA;  #define Traceln(x)    SPIdebug.println (x)&#xA;  #define Traceln2(x,y) SPIdebug.println (x,y)&#xA;  #define TraceFunc()   do { SPIdebug.print (F(&quot;In function: &quot;)); SPIdebug.println (__PRETTY_FUNCTION__); } while (0)&#xA;&#xA;  class tSPIdebug : public Print&#xA;  {&#xA;  public:&#xA;    virtual size_t write (const byte c)  &#xA;      { &#xA;      digitalWrite(SS, LOW); &#xA;      SPI.transfer (c); &#xA;      digitalWrite(SS, HIGH); &#xA;      return 1;&#xA;      }  // end of tSPIdebug::write&#xA;  }; // end of tSPIdebug&#xA;&#xA;  // an instance of the SPIdebug object&#xA;  tSPIdebug SPIdebug;&#xA;&#xA;#else&#xA;  #define beginDebug()  ((void) 0)&#xA;  #define Trace(x)      ((void) 0)&#xA;  #define Trace2(x,y)   ((void) 0)&#xA;  #define Traceln(x)    ((void) 0)&#xA;  #define Traceln2(x,y) ((void) 0)&#xA;  #define TraceFunc()   ((void) 0)&#xA;#endif // DEBUG&#xA;&#xA;&#xA;long counter;&#xA;unsigned long start;&#xA;&#xA;void setup() {&#xA;  start = micros ();&#xA;&#xA;  beginDebug ();&#xA;  Traceln (F(&quot;Commenced device-under-test debugging!&quot;));&#xA;  TraceFunc ();  // show current function name&#xA;&#xA;}  // end of setup&#xA;&#xA;void foo ()&#xA;  {&#xA;  TraceFunc (); // show current function name&#xA;  }&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  counter++;&#xA;  if (counter == 100000)&#xA;  {&#xA;    Traceln (F(&quot;100000 reached.&quot;));&#xA;    Trace (F(&quot;took &quot;));&#xA;    Traceln (micros () - start);&#xA;    counter = 0;&#xA;    foo ();&#xA;  }  // end of if&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If DEBUG is true then the debugging prints are activated. Otherwise they turn into &quot;no code&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The receiving end looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile char buf [1000];&#xA;volatile int inpoint, outpoint;&#xA;&#xA;void setup (void)&#xA;{&#xA;  Serial.begin (115200);   // debugging&#xA;&#xA;  Serial.println ();&#xA;  Serial.println (F(&quot;Commencing debugging session ...&quot;));&#xA;  Serial.println ();&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode(MISO, OUTPUT);&#xA;&#xA;  // turn on SPI in slave mode&#xA;  SPCR |= bit (SPE);&#xA;&#xA;  // now turn on interrupts&#xA;  SPCR |= bit (SPIE);&#xA;&#xA;}  // end of setup&#xA;&#xA;&#xA;// SPI interrupt routine&#xA;ISR (SPI_STC_vect)&#xA;{&#xA;byte c = SPDR;  // grab byte from SPI Data Register&#xA;int next = inpoint + 1;  // next insert point&#xA;&#xA;  // wrap-around at end of buffer&#xA;  if (next &amp;gt;= sizeof buf)&#xA;    next = 0;&#xA;&#xA;  if (next == outpoint)  // caught up with removal point?&#xA;    return;  // give up&#xA;&#xA;  // insert at insertion point&#xA;  buf [inpoint] = c;&#xA;  inpoint = next;  // advance to next&#xA;&#xA;}  // end of interrupt routine SPI_STC_vect&#xA;&#xA;void loop (void)&#xA;{&#xA;  // insertion and removal point the same, nothing there&#xA;  noInterrupts ();  // atomic test of a 16-bit variable&#xA;  if (outpoint == inpoint)&#xA;    {&#xA;    interrupts ();&#xA;    return;&#xA;    }&#xA;  interrupts ();&#xA;&#xA;  // display anything found in the circular buffer&#xA;  Serial.print (buf [outpoint]);&#xA;&#xA;  noInterrupts ();&#xA;  if (++outpoint &amp;gt;= sizeof buf)&#xA;    outpoint = 0;  // wrap around&#xA;  interrupts ();&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a 1000 byte buffer which will cope with bursts of incoming data, which is then sent out the serial port on the debugging Uno (that is, to your serial monitor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The linked library above includes code for SPI and I2C debugging interfaces.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said that, the simplest thing is just to do serial debugging prints inside your code on the main device, if that is practical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember to use the &lt;code&gt;F()&lt;/code&gt; macro, or your debugging code might take up so much RAM it causes a crash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.println (F(&quot;Temperature sensor working.&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-27T21:58:40.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13741" PostTypeId="1" CreationDate="2015-07-27T22:56:01.663" Score="0" ViewCount="187" Body="&lt;p&gt;Communicating to the antenna-less version from an extended range nRF2401 seems to produce some strange results... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a distance, the receiver seems to receive a number of values instead of one. For example, if I send a 1, I will receive a 1, but 30 times. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone had experience communicating across the two models, or is it just best practice to stick to communicating across same models? (Short range &amp;lt;-&gt; short range, long range &amp;lt;-&gt; long range)?&lt;/p&gt;&#xA;" OwnerUserId="11460" LastEditorUserId="6936" LastEditDate="2015-07-30T18:42:54.873" LastActivityDate="2016-01-27T03:24:16.973" Title="nRF2401 communication (extended vs normal)" Tags="|arduino-uno|arduino-mega|nrf24l01+|arduino-pro-micro|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13743" PostTypeId="2" ParentId="13741" CreationDate="2015-07-27T23:49:07.737" Score="1" Body="&lt;p&gt;I've run both version fine together&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your symptom of receiving the same value 30 times would be related to a failed ACK, so the sender thinks it hasn't been received and resends it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had potentially similar problems with the power amplified version running at full power causing interference in nearby circuity, try dialling down the power setting on it.&lt;/p&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="10794" LastEditDate="2015-07-28T00:14:37.927" LastActivityDate="2015-07-28T00:14:37.927" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13744" PostTypeId="2" ParentId="11737" CreationDate="2015-07-28T01:24:02.033" Score="1" Body="&lt;p&gt;If there is a conflict, could the slave switch between i2c and one wire?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how often your device needs to poll, but if you can get away with, say, once per minute, you could poll at regular intervals, and spend the rest of the time (99%) listening for the master. If it is not polled, the number read could be queued. When the master does manage to connect, it could collect the entire queue quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The master, from it's side, could poll more frequently - say once every 53 seconds. About once or twice an hour, it would fail - it would need to handle that gracefully. No matter, it would get the data next time round. Even failing several times in a row wouldn't be a problem; the data would be queued at the slave for later transfer.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-28T01:24:02.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13745" PostTypeId="2" ParentId="13732" CreationDate="2015-07-28T02:03:12.693" Score="1" Body="&lt;p&gt;The code isn't wrong, it's far too simple to be at fault.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error is from within Proteus. Those 'pushbutton' switches (and the other switch simulations) are not quite as straightforward as one would like. They have an OFF resistance, usually 100 Megaohms, but that's enough to trick the simulation into not behaving like it should do. You MUST pull the inputs to ground with a resistor - any sensible value will do as it's only required for the &lt;em&gt;simulation&lt;/em&gt;. As they are, they're in some odd floating/magic/unknown state; common sense does not apply here!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to swap the pushbutton for a SPDT switch; connect the common to the Arduino and the other contacts to the 7805 output and ground. You won't need the resistor in this case.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-07-28T02:03:12.693" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13746" PostTypeId="2" ParentId="10508" CreationDate="2015-07-28T02:23:53.157" Score="0" Body="&lt;p&gt;Someone has done exactly this, and written detailed instructions at &lt;a href=&quot;http://www.instructables.com/id/Autonomous-Control-of-RC-Car-Using-Arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Autonomous-Control-of-RC-Car-Using-Arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some remote control devices (usually not the really cheap ones, like the one shown here) will have a standard transmitter/receiver. See &lt;a href=&quot;http://www.alibaba.com/product-detail/3-channel-radio-control-receiver-box_311659816.html&quot; rel=&quot;nofollow&quot;&gt;http://www.alibaba.com/product-detail/3-channel-radio-control-receiver-box_311659816.html&lt;/a&gt; for a picture of the receiver. If you can find this in your remote control device, you should be able to unplug it, and replace it with an Arduino. You will need the &quot;Servo&quot; library - see &lt;a href=&quot;https://www.arduino.cc/en/reference/servo&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/reference/servo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably get away without soldering - you will probably need to strip some wires, and you can use crocodile clips, and/or breadboard jumpers to connect everything up. It won't be pretty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to learn to solder (I know it's intimidating, but it's not so bad) I recommend that you find a local hackspace/makerspace, and find someone there - they will probably be more than happy to teach you. They probably have everything you need, be nice to them, and if you want them to continue, join up &amp;amp; pay regular subs. And take every opportunity to teach the skills you have to anyone else who asks for help.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-28T02:23:53.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13747" PostTypeId="2" ParentId="6702" CreationDate="2015-07-28T02:31:21.217" Score="1" Body="&lt;p&gt;Try this: unplug the Arduino, hold down the reset button, and then plug it in to power. Hold down the reset button a few seconds after you power it on. If this works, you should get the &quot;blink&quot; sketch, and be able to reprogram it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you have an ICSP programmer (I use the FreeTronics USBASP), plug this in (you will need to wire up the appropriate 6 pins), and then use the Arduino IDE to burn the bootloader - select the board, serial port, and programmer,then select &quot;burn bootloader&quot; - all from the &quot;Tools&quot; pull-down menu. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-08-03T02:38:58.490" LastActivityDate="2015-08-03T02:38:58.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13748" PostTypeId="1" CreationDate="2015-07-28T02:31:27.650" Score="2" ViewCount="104" Body="&lt;p&gt;Recently I assembled my Shapeoko machine, we used Grbl shield with an Uno for the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 1-2 weeks everything worked perfectly then once when I tried to work the machine, the serial communication was not working. I tried to replace the 16 MHz oscillator because I thought the problem might be with the oscillator since the LEDs were not blinking but they were lighting up.&lt;/p&gt;&#xA;" OwnerDisplayName="Chris Thaliyath" LastEditorUserId="10794" LastEditDate="2015-07-29T06:26:53.967" LastActivityDate="2021-12-02T07:03:50.293" Title="Arduino UNO not working?" Tags="|arduino-uno|motor|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13749" PostTypeId="2" ParentId="6702" CreationDate="2015-07-28T03:43:24.537" Score="4" Body="&lt;p&gt;If your pro micro does not have a reset button, wire one between reset and ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Press reset twice, quickly, and immediately hit upload on the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, make sure you've downloaded and installed the Sparkfun board files for the pro micro. &lt;/p&gt;&#xA;" OwnerUserId="11460" LastActivityDate="2015-07-28T03:43:24.537" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13750" PostTypeId="2" ParentId="8898" CreationDate="2015-07-28T05:56:13.610" Score="3" Body="&lt;p&gt;If it does what you expect when the button is pressed, but behaves unpredictably when released, you almost certainly have a floating input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;Switches tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, this is a no-no:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KKfZD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KKfZD.png&quot; alt=&quot;Floating switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Random fluctuations in voltages will make the switch read HIGH and then LOW, and your servo will chase around trying to change positions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest fix (without changing anything else) is to add a pull-down resistor between the pin and ground, so now the pin reliably reads LOW when not pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/t7lxC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t7lxC.png&quot; alt=&quot;Pull-down resistor on switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other methods are discussed on that page, including debouncing.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-28T05:56:13.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13751" PostTypeId="2" ParentId="13706" CreationDate="2015-07-28T07:06:04.420" Score="1" Body="&lt;p&gt;You could try the intel galileo or the intel edison with arduino shield. They can be programmed with a variant of the arduino ide, but it is possible to call also programs from the native linux os. Or you could have a look at the esp826.&#xA;At least on the edison it is possible to run node.js, while the esp supports lua.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-28T07:06:04.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13752" PostTypeId="2" ParentId="2913" CreationDate="2015-07-28T07:10:01.400" Score="0" Body="&lt;p&gt;Take a look at this website:&#xA;&lt;a href=&quot;http://www.vwlowen.co.uk/arduino/current/current.html&quot; rel=&quot;nofollow&quot;&gt;http://www.vwlowen.co.uk/arduino/current/current.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It shows how to make a create a simple current sensor with just a few resistors.&lt;/p&gt;&#xA;" OwnerUserId="11469" LastActivityDate="2015-07-28T07:10:01.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13753" PostTypeId="2" ParentId="13736" CreationDate="2015-07-28T10:05:05.640" Score="2" Body="&lt;p&gt;When you call &lt;code&gt;dataFile.read()&lt;/code&gt;, the file pointer is advanced, so you always read different bytes in each &lt;code&gt;read&lt;/code&gt; call. Imagine the file like a book with many lines: Each time you read, you advance the current line, so with multiple calls, you never get the same data. The solution is to currently store the last read byte:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (dataFile.available()) {&#xA;  char readByte = dataFile.read();&#xA;  Serial.write(readByte);&#xA;  lcd.write(readByte);&#xA;  lcd.print(readByte);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have two calls for displaying data in the LCD, but be careful that the second call (&lt;code&gt;print&lt;/code&gt;) might interpret your data as a number, so just remove the &lt;code&gt;lcd.print(readByte)&lt;/code&gt; call altogether to be sure it's printing the raw character.&lt;/p&gt;&#xA;" OwnerUserId="2742" LastEditorUserId="2742" LastEditDate="2015-07-28T10:12:55.390" LastActivityDate="2015-07-28T10:12:55.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13754" PostTypeId="1" CreationDate="2015-07-28T12:19:51.277" Score="0" ViewCount="588" Body="&lt;p&gt;I want add an LCD display screen at output motor. When the motor runs the LCD display show like &quot;motor 1 run forward&quot; and &quot;motor 1 run reverse&quot;. I want it display for all motor but I don't know how code using arduino using 16x2 LCD display screen.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int motor_forward1 = 7;&#xA;int motor_reverse1 = 6;&#xA;int motor_forward2 = 5;&#xA;int motor_reverse2 = 4;&#xA;int motor_forward3 = 3;&#xA;int motor_reverse3 = 2;&#xA;int sensor1 = 13;&#xA;int sensor2 = 12;&#xA;&#xA; void setup() &#xA;{&#xA;&#xA;   pinMode(motor_forward1, OUTPUT);&#xA;   pinMode(motor_reverse1, OUTPUT);&#xA;   pinMode(motor_forward2, OUTPUT);&#xA;   pinMode(motor_reverse2, OUTPUT);&#xA;   pinMode(motor_forward3, OUTPUT);&#xA;   pinMode(motor_reverse3, OUTPUT);&#xA;   pinMode(sensor1, INPUT);&#xA;   pinMode(sensor2, INPUT);&#xA; }&#xA;&#xA; void loop()&#xA; {&#xA;   if (digitalRead(13) == HIGH)&#xA;   {&#xA;     print&#xA;     digitalWrite(motor_forward1,1);&#xA;     digitalWrite(motor_reverse1,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward1,0);&#xA;     digitalWrite(motor_reverse1,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward1,0);&#xA;     digitalWrite(motor_reverse1,0);&#xA;     delay(1000);&#xA;   }&#xA;   else if (digitalRead(12) == HIGH)&#xA;   {&#xA;     digitalWrite(motor_forward2,1); &#xA;     digitalWrite(motor_reverse2,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward2,0);&#xA;     digitalWrite(motor_reverse2,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward2,0);&#xA;     digitalWrite(motor_reverse2,0);&#xA;     delay(1000);&#xA;   }&#xA;   else&#xA;   {&#xA;     digitalWrite(motor_forward3,1); &#xA;     digitalWrite(motor_reverse3,0);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward3,0);&#xA;     digitalWrite(motor_reverse3,1);&#xA;     delay(5000);&#xA;     digitalWrite(motor_forward3,0);&#xA;     digitalWrite(motor_reverse3,0);&#xA;     delay(1000);&#xA;   }&#xA;   delay(5000);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11449" LastEditorUserId="2881" LastEditDate="2015-07-28T13:51:18.677" LastActivityDate="2015-07-28T15:56:02.733" Title="Want to add an LCD display screen for the output motor" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13755" PostTypeId="1" CreationDate="2015-07-28T12:46:04.010" Score="0" ViewCount="601" Body="&lt;p&gt;I want to buy an arduino development board which has facility to remove its chip and insert a new one anytime. I want to use multiple chips in a single board for different purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is not possible, Please suggest me any alternative.&lt;/p&gt;&#xA;" OwnerUserId="11475" LastEditorUserId="6936" LastEditDate="2015-07-30T21:11:27.213" LastActivityDate="2015-07-31T19:18:01.453" Title="Suggest me an Arduino development board, with a removable ATmega chip?" Tags="|multiplexer|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13756" PostTypeId="1" CreationDate="2015-07-28T12:53:02.753" Score="1" ViewCount="1227" Body="&lt;p&gt;For a physical activity monitoring project, I am developing a prototype based on an Arduino Due and several IMUs (BNO055 from Bosch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to collect the data from the sensors simultaneously (3 for the moment). I want to use a Serial connection (Since the Arduino Due has 4 hardware serial ports). &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Here comes the first issue : I use the &lt;a href=&quot;http://ae-bst.resource.bosch.com/media/products/shuttleboards/BNO055_Shuttleboard_Flyer.pdf&quot; rel=&quot;nofollow&quot;&gt;shuttleboard BNO0055&lt;/a&gt;, and because of my limited knowledge, I'm not sure I did the right wiring. As I understood in the &lt;a href=&quot;http://www.bosch-sensortec.com/en/homepage/products_3/sensor_hubs/iot_solutions/bno055_1/bno055_4&quot; rel=&quot;nofollow&quot;&gt;datasheets&lt;/a&gt;, the PS0 pin must be connected to the GND and PS1 to the incoming voltage. The COM0 to the RX of the Arduino and COM1 to TX. I am confused by the documentation, I can't figure out which pin of the shuttleboard are the COM0 and COM1. (I can't post the pictures of my wiring since it's my first post here).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And now there is a second problem: If the wiring is good, how can I communicate with the sensor to get the Euler angles? The BNO055 sensor does the fusion data itself, and gives the quaternions or the Euler angle. Bosch provides a &lt;a href=&quot;http://https:%20//github.com/BoschSensortec/BNO055_driver&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt;. I have never used a library, and I don't know the syntax to ask the sensor to give the Euler angles. Can someone give me a code to do this? Or at least explanations on the syntax I should use? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="6936" LastEditDate="2015-07-29T08:05:32.333" LastActivityDate="2015-07-29T08:05:32.333" Title="Arduino Due and BNO055" Tags="|serial|sensors|arduino-due|communication|uart|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13757" PostTypeId="2" ParentId="9509" CreationDate="2015-07-28T13:06:31.933" Score="0" Body="&lt;p&gt;Add a 100uf capacitor between ground and 3.3v directly on the nrf breakout. They're very susceptible to noise on the power supply. I had issues with the same thing and this solved it. Also, make sure you're powering from 3.3v. Also make sure you solder the negative to the negative!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1fm7e.jpg&quot; alt=&quot;see capacitor placement&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="11460" LastActivityDate="2015-07-28T13:06:31.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13758" PostTypeId="2" ParentId="13755" CreationDate="2015-07-28T13:36:16.623" Score="0" Body="&lt;p&gt;It is possible, you could probably do it on most of the Arduino boards too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page on the Arduino website may help you - &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have personally never attempted it but I know quite a few people who have and they have never had too many big issues.&lt;/p&gt;&#xA;" OwnerUserId="11451" LastActivityDate="2015-07-28T13:36:16.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13759" PostTypeId="2" ParentId="13755" CreationDate="2015-07-28T13:59:04.903" Score="4" Body="&lt;p&gt;Only the Arduino Uno has a socketed IC chip. All the rest are using soldered SMD ICs.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-28T13:59:04.903" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13760" PostTypeId="1" AcceptedAnswerId="16026" CreationDate="2015-07-28T14:45:36.860" Score="2" ViewCount="2960" Body="&#xA;&#xA;&lt;p&gt;I have two nRF24L01 modules, they are both attached to a sensor shield that has special ports for this type of module, on Arduino Unos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aungh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aungh.jpg&quot; alt=&quot;Sensor shield, with nRF24LO1 in it&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this code on the Arduino that is sending the signal:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;#include &amp;lt;MirfSpiDriver.h&amp;gt;&#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;//0 = stop, 1 = left, 2 = right, 3 = forward, 4 = backwards&#xA;long command;&#xA;long last_command;&#xA;&#xA;long Joystick_1_X;&#xA;long Joystick_1_Y;&#xA;long Joystick_1;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;  &#xA;  Mirf.init(); &#xA;  Mirf.setTADDR((byte *)&quot;serv1&quot;);&#xA;  Mirf.payload = sizeof(long);&#xA;  Mirf.config(); &#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  Joystick_1_X = analogRead(A0);&#xA;  Joystick_1_Y = analogRead(A1);&#xA;&#xA;  if(Joystick_1_X &amp;lt; 450){&#xA;     command = 1;&#xA;  }else if(Joystick_1_X &amp;gt; 600){&#xA;    command = 2;&#xA;  }else if(Joystick_1_Y &amp;gt; 600){&#xA;    command = 3;&#xA;  }else if(Joystick_1_Y &amp;lt; 400){&#xA;    command = 4;&#xA;  }else{&#xA;    command = 0;&#xA;  }&#xA;  if(command == last_command){&#xA;  }else{&#xA;    Mirf.send((byte *)&amp;amp;command);&#xA;    last_command = command;&#xA;   }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this code on the Arduino that is receiving &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;SPI.h&quot;&#xA;#include &quot;Mirf.h&quot;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;MirfHardwareSpiDriver.h&quot;&#xA;&#xA;int TN1= 3;&#xA;int TN2 = 4;&#xA;int ENA = 9;&#xA;&#xA;int TN4 = 5;&#xA;int TN3 = 6;&#xA;int ENB = 10;&#xA;&#xA;long data;&#xA;&#xA;void setup() {&#xA; pinMode(TN1, OUTPUT);&#xA; pinMode(TN2, OUTPUT);&#xA; pinMode(TN3, OUTPUT);&#xA; pinMode(TN4, OUTPUT);&#xA; pinMode(ENA, OUTPUT);&#xA; pinMode(ENB, OUTPUT);&#xA;&#xA; Mirf.spi = &amp;amp;MirfHardwareSpi;&#xA; Mirf.init();&#xA; Mirf.setRADDR((byte *)&quot;serv1&quot;);&#xA; Mirf.payload = sizeof(long);&#xA; Mirf.config();&#xA; Serial.begin(115200);&#xA; Serial.print(&quot;begin&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // put your main code here, to run repeatedly:&#xA;  receiveCommand();&#xA;  if(data == 1){&#xA;    left();&#xA;  }else if(data == 2){&#xA;    right();&#xA;  }else if(data == 3){&#xA;    forward();&#xA;  }else if(data == 4){&#xA;    backwards();&#xA;  }else if(data == 0){&#xA;    stop_rover();&#xA;  }&#xA;}&#xA;&#xA;void receiveCommand(){&#xA;  if(!Mirf.isSending() &amp;amp;&amp;amp; Mirf.dataReady()){&#xA;    Mirf.getData((byte *)&amp;amp;data);&#xA;    Mirf.rxFifoEmpty();&#xA;    Serial.print(data);&#xA;  }else{&#xA;    Serial.println(&quot;No data to be recieved&quot;);&#xA;  }&#xA;}&#xA;&#xA;void forward(){&#xA;  digitalWrite(ENB, HIGH);&#xA;  digitalWrite(ENA, HIGH);&#xA;  digitalWrite(TN4, HIGH);&#xA;  digitalWrite(TN3, LOW);&#xA;  digitalWrite(TN1, HIGH);&#xA;  digitalWrite(TN2, LOW);&#xA;}&#xA;&#xA;void backwards(){&#xA;  digitalWrite(ENB, HIGH);&#xA;  digitalWrite(ENA, HIGH);&#xA;  digitalWrite(TN4, LOW);&#xA;  digitalWrite(TN3, HIGH);&#xA;  digitalWrite(TN1, LOW);&#xA;  digitalWrite(TN2, HIGH);&#xA;}&#xA;&#xA;void left(){&#xA;   digitalWrite(ENA, HIGH);&#xA;   digitalWrite(TN1, HIGH);&#xA;   digitalWrite(TN2, LOW);&#xA;}&#xA;&#xA;void right(){&#xA;  digitalWrite(ENB, HIGH);&#xA;  digitalWrite(TN4, HIGH);&#xA;  digitalWrite(TN3, LOW);&#xA;}&#xA;&#xA;void stop_rover(){&#xA;  digitalWrite(ENB, LOW);&#xA;  digitalWrite(ENA, LOW);&#xA;  digitalWrite(TN4, LOW);&#xA;  digitalWrite(TN3, LOW);&#xA;  digitalWrite(TN1, LOW);&#xA;  digitalWrite(TN2, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was working, and the rover did spin its wheels when the remote broadcasted a signal, but then it just stopped. The sensor shield says that they are plugged into the 3V port, I tried using the RF24 library and that did not work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="10529" LastEditorUserId="10529" LastEditDate="2015-08-16T15:46:57.353" LastActivityDate="2019-11-11T19:09:49.667" Title="nRF24L01 module using Mirf library was working and then stopped" Tags="|arduino-uno|c++|nrf24l01+|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="13761" PostTypeId="2" ParentId="13754" CreationDate="2015-07-28T15:52:38.350" Score="1" Body="&lt;p&gt;From this &lt;a href=&quot;http://www.instructables.com/id/Connect-A-16x2-LCD-Display-To-An-Arduino/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;instructable&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot; **Text for line 1 of LCD**&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot; **Text for line 2 of LCD**&quot;);&#xA;  // THE REST OF YOUR SETUP&#xA;}&#xA;&#xA;void loop() {&#xA;    if (digitalRead(13) == HIGH) {&#xA;        // I assume this is the motor going forward&#xA;        lcd.print(&quot;motor 1 run forward&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7002" LastEditorUserId="7002" LastEditDate="2015-07-28T15:56:02.733" LastActivityDate="2015-07-28T15:56:02.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13762" PostTypeId="1" CreationDate="2015-07-28T19:23:02.713" Score="0" ViewCount="2075" Body="&lt;p&gt;I have been working on a project building a robot and using my own custom-built libraries to control it. However after converting all my old code into libraries Arduino can't find them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything thing I have seen says to save them in the 'libraries' folder in with the sketches in MyDocuments and to reboot the Arduino Environment so it will recognize them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It even recognizes them in the sketch menu as libraries that can be imported. However, when I click on them to be included, a new blank line is entered into the sketch instead of an include statement. Perhaps this is some clue? I am really out of ideas at this point as to what I have done wrong.&lt;/p&gt;&#xA;" OwnerUserId="10581" LastActivityDate="2017-01-24T03:44:39.303" Title="Arduino can't find my custom library: fatal error, Motor.h not found etc" Tags="|library|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13763" PostTypeId="1" AcceptedAnswerId="13767" CreationDate="2015-07-28T19:24:33.827" Score="1" ViewCount="1797" Body="&lt;p&gt;I'm working on an adaptation of Jason Leyrer's &lt;a href=&quot;http://www.jleyrer.net/blog/2008/03/wii-guitarduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Guitar Hero Library&lt;/a&gt; for Arduino.  My version is for a DJ Hero controller, and I've also borrowed some code from this Arduino forum thread: topic=120527 (sorry can't post links yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The protocol is i2c and I am successfully reading data from it, however I'm not 100% sure what to do with the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buttons are fine, as they are mapped to just one bit in a given byte.  However the other controls are a combination of 4, 5 and 6 bit longs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format according to Wiibrew is like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RVhDH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RVhDH.png&quot; alt=&quot;Table of DJ Hero dataframe format&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;BE&lt;/code&gt; is for Euphoria button&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;CS&lt;/code&gt; : Crossfade Slider, lower is left and upper is right&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;SX&lt;/code&gt; and &lt;code&gt;SY&lt;/code&gt; are the black analog stick.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ED&lt;/code&gt; is the Effect Dial&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;RTT&lt;/code&gt; is the turntable on the right as a 6-bit signed integer (positive = CW; negative = CCW)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;RBG&lt;/code&gt;,&lt;code&gt;RBR&lt;/code&gt;,&lt;code&gt;RBB&lt;/code&gt; are the Green, Red and Blue buttons on the right&lt;/li&gt;&#xA;&lt;li&gt;LTT is the turntable on the left as a 6-bit signed integer (positive = CW; negative = CCW)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LBG&lt;/code&gt;,&lt;code&gt;LBR&lt;/code&gt;,&lt;code&gt;LBB&lt;/code&gt; are the Green, Red and Blue buttons on the left&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm trying to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt; signed long DJ_ED()&#xA;{&#xA;  pack5 ED;&#xA;  ED[0] = (DJ_buf[3] &amp;gt;&amp;gt; 5) &amp;amp; 1;&#xA;  ED[1] = (DJ_buf[3] &amp;gt;&amp;gt; 6) &amp;amp; 1;&#xA;  ED[2] = (DJ_buf[3] &amp;gt;&amp;gt; 7) &amp;amp; 1;&#xA;  ED[3] = (DJ_buf[2] &amp;gt;&amp;gt; 5) &amp;amp; 1;&#xA;  ED[4] = (DJ_buf[2] &amp;gt;&amp;gt; 6) &amp;amp; 1;&#xA;&#xA;  return ED;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where pack5 is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define packet5&#xA;union pack5&#xA;{&#xA;   signed long value;&#xA;   int ints[5];&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I'm getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;no match for 'operator[]' (operand types are 'pack5' and 'int')&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="11423" LastActivityDate="2015-07-29T00:16:43.917" Title="Using union to return a range of bits from a data frame: wrong approach?" Tags="|arduino-mega|i2c|library|data-type|byte-order|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13764" PostTypeId="1" AcceptedAnswerId="13765" CreationDate="2015-07-28T08:35:54.760" Score="1" ViewCount="217" Body="&lt;p&gt;I just got a Mux Shield 2 and got it working as I expected. Now I started to find out how to actually connect the I/O cables to the board. Doesn't seem to be as simple as I thought. I don't want to solder cables into the board for maintenance reasons. So, does anyone have any good tips on how to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tHo9p.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tHo9p.jpg&quot; alt=&quot;Photo of shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="atonus" LastEditorUserId="10794" LastEditDate="2015-09-12T00:36:14.057" LastActivityDate="2015-09-12T00:36:14.057" Title="Good tips for how to connect cables into Mux Shield II?" Tags="|hardware|wires|multiplexer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13765" PostTypeId="2" ParentId="13764" CreationDate="2015-07-28T13:43:41.470" Score="1" Body="&lt;p&gt;Solder 100-mil male headers onto the board, then use 100-mil crimp terminals to connect the wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/edU2P.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/edU2P.jpg&quot; alt=&quot;100-mil male headers&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DRMxf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DRMxf.jpg&quot; alt=&quot;Female crimp terminals&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/L50td.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L50td.jpg&quot; alt=&quot;Connected&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-07-28T13:43:41.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13766" PostTypeId="2" ParentId="13639" CreationDate="2015-07-28T20:52:03.153" Score="0" Body="&lt;p&gt;Here is an example of a project that simultaneously drives 40 individually controllable LEDs directly connected to an ATTINY...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ognite.com&quot; rel=&quot;nofollow&quot;&gt;http://ognite.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same technique would also work directly connecting LEDs to the Arduino IO pins. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-07-28T20:52:03.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13767" PostTypeId="2" ParentId="13763" CreationDate="2015-07-28T21:04:47.307" Score="1" Body="&#xA;&#xA;&lt;p&gt;You are using a union so you have to specify which part of the union you want. Your function should read:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; signed long DJ_ED()&#xA;{&#xA;  pack5 ED;&#xA;  ED.ints[0] = (DJ_buf[3] &amp;gt;&amp;gt; 5) &amp;amp; 1;&#xA;  ED.ints[1] = (DJ_buf[3] &amp;gt;&amp;gt; 6) &amp;amp; 1;&#xA;  ED.ints[2] = (DJ_buf[3] &amp;gt;&amp;gt; 7) &amp;amp; 1;&#xA;  ED.ints[3] = (DJ_buf[2] &amp;gt;&amp;gt; 5) &amp;amp; 1;&#xA;  ED.ints[4] = (DJ_buf[2] &amp;gt;&amp;gt; 6) &amp;amp; 1;&#xA;&#xA;  return ED.value;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It still looks wrong because you are only putting a single bit into those 5 bytes (because of the &amp;amp; 1). And 5 x int will be a lot longer than one signed long.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The code below seems to match the data structure you posted an image of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;struct packedFields&#xA;{&#xA;  // byte 0&#xA;  unsigned int sx      : 5;&#xA;  unsigned int rtt_4_3 : 3;&#xA;&#xA;  // byte 1&#xA;  unsigned int sy      : 5;&#xA;  unsigned int rtt_2_1 : 3;&#xA;&#xA;  // byte 2&#xA;  unsigned int rtt_5   : 1;&#xA;  unsigned int cs      : 4;&#xA;  unsigned int ed_4_3  : 2;  &#xA;  unsigned int rtt_0   : 1;&#xA;&#xA;  // byte 3&#xA;  unsigned int ltt_4_0  : 5;&#xA;  unsigned int ed       : 3;&#xA;&#xA;  // byte 4&#xA;  unsigned int ltt_5    : 1;&#xA;  unsigned int rbr      : 1;&#xA;  unsigned int b_plus   : 1;&#xA;  unsigned int filler_2 : 1;&#xA;  unsigned int b_minus  : 1;&#xA;  unsigned int lbr      : 1;&#xA;  unsigned int filler_1 : 2;&#xA;&#xA;  // byte 5&#xA;  unsigned int filler_4 : 2;&#xA;  unsigned int rbb      : 1;&#xA;  unsigned int lbg      : 1;&#xA;  unsigned int be       : 1;&#xA;  unsigned int rbg      : 1;&#xA;  unsigned int filler_3 : 1;&#xA;  unsigned int lbb      : 1;&#xA;&#xA;};&#xA;&#xA;union packedFieldsUnion&#xA;  {&#xA;  packedFields a;&#xA;  byte b [6];&#xA;  };&#xA;&#xA;void doSomethingWithTheFields (packedFieldsUnion &amp;amp; theFields);  // prototype&#xA;void doSomethingWithTheFields (packedFieldsUnion &amp;amp; theFields)&#xA;  {&#xA;  theFields.a.rtt_4_3 = 3;&#xA;  theFields.a.ltt_4_0 = 2;&#xA;  }  // end of doSomethingWithTheFields&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.print (F(&quot;packedFields sized = &quot;));&#xA;  Serial.println (sizeof (packedFields));&#xA;&#xA;  packedFieldsUnion foo;&#xA;  memset (&amp;amp;foo, 0, sizeof foo);&#xA;&#xA;  doSomethingWithTheFields (foo);&#xA;&#xA;  Serial.println (F(&quot;-- packedFields bytes --&quot;));&#xA;  for (int i = 0; i &amp;lt; sizeof foo; i++)&#xA;    Serial.println ((int) foo.b [i], HEX);&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a bitwise struct, as Ignacio Vazquez-Abrams suggested. Testing indicates you put the low-order bits first. Then I made a union of this struct and 6 bytes. You can't fit the whole thing into a signed long anyway (a long is 4 bytes) so that part of your code was doomed to fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A small bit of test code proves that the bits are being accessed in the correct way. You still need to fiddle around with things like RTT which has individual bits scattered in different places.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you look at the data format you posted there are 6 bytes, not 5. They are numbered 0, 1, 2, 3, 4, 5. A total of six of them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-29T00:16:43.917" LastActivityDate="2015-07-29T00:16:43.917" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13768" PostTypeId="2" ParentId="13755" CreationDate="2015-07-28T21:26:25.613" Score="2" Body="&lt;p&gt;You could get an &lt;a href=&quot;http://shop.evilmadscientist.com/productsmenu/tinykitlist/74-atmegaxx8&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmegaXX8 target board&lt;/a&gt; from Evil Mad Scientist. That has (or can have) a ZIF socket so you can easily remove the chip without bending its legs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NaC8r.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NaC8r.jpg&quot; alt=&quot;AtmegaXX8 target board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's around $US 3 for the board, $2 for the ZIF socket, $1 for the crystal, 45 cents for the ICSP header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put an Atmega328P into the socket (same chip as on the Uno). Note that &lt;em&gt;some soldering is required&lt;/em&gt;. You would need to solder on the ZIF socket, the ISP header, and make up an FTDI header if you wanted to easily program it from the IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would also need (or it would be helpful to have) a 16 MHz crystal along with 2 x 18 pF capacitors. They have them for sale at that site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would also need a 10 k pull-up resistor for Reset, a couple of 0.1 µF decoupling capacitors, and another 0.1 µF capacitor for handling reset via the FTDI interface - if you use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to program serially (and do serial debugging) you need some sort of USB interface, such as an FTDI cable or board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example &lt;a href=&quot;http://www.adafruit.com/products/70&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTDI Serial TTL-232 USB Cable&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9KNFw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9KNFw.jpg&quot; alt=&quot;FTDI cable&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is around $US 18. (Of course, you only need to buy the cable once, so this is a one-time cost).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to solder in 6 header pins in a line to plug that into (on the prototyping area) and then run appropriate wires to Tx/Rx/Gnd/5V and Reset via the 0.1 µF capacitor I mentioned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit have an &lt;a href=&quot;http://www.adafruit.com/products/123&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino bootloader-programmed chip (Atmega328P)&lt;/a&gt; for $US 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All-up it would probably cost you around $US 30 to put it together. (The FTDI cable is a once-off cost, as you can use that on multiple projects).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Other vendors will probably have similar products.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-28T22:53:38.337" LastActivityDate="2015-07-28T22:53:38.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13769" PostTypeId="2" ParentId="13755" CreationDate="2015-07-28T22:39:27.833" Score="0" Body="&lt;p&gt;If the question is driven by need of minimizing the overall cost, well, on ebay you can find plenty of Arduino Mini Pro at about $2, shipment included. Add an USBASP programmer at the cost of $5 and you get a solution which is still pretty cheap and allows each board to be used, rather than having just one with multiple chips to insert/remove.&#xA;At a fraction of the cost of the other solutions described here.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-07-28T22:39:27.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13770" PostTypeId="2" ParentId="13755" CreationDate="2015-07-29T05:59:55.887" Score="2" Body="&lt;p&gt;The ultimate solution would be to build it yourself! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EYXT3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EYXT3.jpg&quot; alt=&quot;Standalone Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino has an excellent step by step guide on how to build a &lt;a href=&quot;https://www.arduino.cc/en/main/standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;standalone Arduino&lt;/a&gt;, using a ATMega328, on a breadboard. Now everything is removable, not just the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is one slight error in the guide, which I have highlighted here, &lt;a href=&quot;https://arduino.stackexchange.com/questions/10392/arduino-standalone-photo-shows-incorrect-pin-wired-to-mosi&quot;&gt;Arduino Standalone - photo shows incorrect pin wired to MOSI&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a video on how to achieve, more or less, the same thing, &lt;a href=&quot;https://www.youtube.com/watch?v=sNIMCdVOHOM&quot; rel=&quot;nofollow noreferrer&quot;&gt;1-Day Project: Build Your Own Arduino Uno for $5&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-31T19:18:01.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13771" PostTypeId="1" AcceptedAnswerId="13772" CreationDate="2015-07-29T06:08:58.253" Score="1" ViewCount="3536" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&quot; rel=&quot;nofollow&quot;&gt;Jeff Rowberg's MPU6050 library&lt;/a&gt;, and I simply don't understand what is going on in the following lines of the first example (MPU6050_raw.ino):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050.h&quot;&#xA;&#xA;// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE&#xA;// implementation is used in I2Cdev.h&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, what I got from that is, if I2Cdev is using Wire instead of some alternative I2C library, I should include Wire.h. I really don't see why that's necessary, so I removed the line in which Wire.h is included, and got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\Franco2500k\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:80:26: fatal error: Wire.h: No such file or directory&#xA;     #include &amp;lt;Wire.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, apparently, I2Cdev.h already tries to include Wire.h, but somehow fails? And another #include a few lines later goes back in time and fixes everything? Can someone explain what is going on?&lt;/p&gt;&#xA;" OwnerUserId="11488" LastActivityDate="2015-07-29T06:20:46.217" Title="I2Cdev #include weirdness" Tags="|mpu6050|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13772" PostTypeId="2" ParentId="13771" CreationDate="2015-07-29T06:20:46.217" Score="1" Body="&lt;p&gt;The Arduino IDE means well, really it does. It copies your source, the device core, and any libraries used by your source all to a separate directory so that it doesn't poison any of their original locations unintentionally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But of course, there's something missing from that list. The IDE &lt;em&gt;doesn't copy libraries used by other libraries&lt;/em&gt;. Therefore if you don't include Wire.h in your .ino file then Wire will be missing from the build and you get the error observed. Cracktastic.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-29T06:20:46.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13773" PostTypeId="1" AcceptedAnswerId="13794" CreationDate="2015-07-29T06:30:51.407" Score="2" ViewCount="334" Body="&lt;p&gt;I found this lovely decade box in a demolished house recently and want to turn it into an Ableton controller. As you see, there are 18 knobs, each with 12 individual states. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to have a program which can access the states of all the knobs at any time, and I have an arduino which I can use. Is this possible to do without a shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought is that, since many of the leads on the back already have resistors on them, I could use a sort of total-resistance-across-the-connection approach which would suit itself to the analog inputs. But I'm not sure that's the way to go, especially if I want very low latency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I wire up a board that has digital access to all the pins here? How does a multiplexer play into this? How many inputs would I need? I am super new to this kind of stuff, so I imagine this must be a pretty simple answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fUlgW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fUlgW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/64SC2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/64SC2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11490" LastActivityDate="2019-01-02T18:59:19.780" Title="How can I turn this into an (Ableton) controller?" Tags="|wires|prototype|multiplexer|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13775" PostTypeId="2" ParentId="13773" CreationDate="2015-07-29T09:07:33.153" Score="1" Body="&lt;p&gt;The hard part here is that you essentially have 216 inputs you need to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could multiplex the analog pins using two &lt;a href=&quot;http://playground.arduino.cc/Learning/4051&quot; rel=&quot;nofollow&quot;&gt;74HC4051&lt;/a&gt;. Analogread takes around 0.1ms, so around 2ms for all 18 knobs. Debouncing would however be pretty hard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd probably go with input shift registers, and remove all the resistors. You would however need 27 8-bit shift register (3 registers per 2 knobs). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reduce this you could encode the rotary position into 4-bit using a &lt;a href=&quot;http://www.allaboutcircuits.com/worksheets/encoders-and-decoders/&quot; rel=&quot;nofollow&quot;&gt;diode network&lt;/a&gt;. That way you can use only 1 shift register per 2 knobs. So 9 in total.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-29T09:07:33.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13776" PostTypeId="2" ParentId="13773" CreationDate="2015-07-29T09:08:47.047" Score="1" Body="&lt;p&gt;You can use the analog route by using a &lt;a href=&quot;https://www.sparkfun.com/products/9056&quot; rel=&quot;nofollow noreferrer&quot;&gt;CD74HC4067&lt;/a&gt;, then you can hook it up to a analog demultiplexer, such as the &lt;a href=&quot;https://www.sparkfun.com/products/9056&quot; rel=&quot;nofollow noreferrer&quot;&gt;CD74HC4067&lt;/a&gt;(breakout from SFE) which has 16 analog/digital inputs. You would use one of these and two analog pins, one from the breakout and one from the panel, as there are 17 dials from what I can see. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of a resistor ladder:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/kdWa3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 4067 is addressed using 4 digital pins to make up a binary address relating to each input. You would put this into a for loop and read from each address and put in an array of values each time you loop. And when leaving the loop read the last analog value.&#xA;I would use port manipulation to write the address as it would speed up the operation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have the values in the array you can then do the math require to get where the dial is or you can do that as you read the analog pin the the for loop, kind of keep it all in one function. You can find the calculation for converting in the Wikipedia article, the R-2R style.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://bildr.org/2011/02/cd74hc4067-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bildr&lt;/a&gt; have a nice write up with some code, an image of the basic setup: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/KCi3R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="27346" LastEditDate="2019-01-02T18:59:19.780" LastActivityDate="2019-01-02T18:59:19.780" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13777" PostTypeId="1" CreationDate="2015-07-29T10:15:10.937" Score="0" ViewCount="636" Body="&lt;p&gt;I am a beginner at AVR and programming. I am using ATtiny461 and asked to make code to use timer in PWM and CTC mode and use interrupts and pin toggle, this code worked for me with normal timer and toggle but I don't know how to make it work with CTC and PWM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;//Init PD6 pin as output&#xA;void InitPort(void)&#xA;{&#xA;    PORTB&amp;amp;=~(1&amp;lt;&amp;lt;PB1);//initial value 0&#xA;    DDRB|=(1&amp;lt;&amp;lt;PB1);&#xA;}&#xA;//Initialize Timer0&#xA;void InitTimer0(void)&#xA;{&#xA;    //Enable Timer0 overflow Interrupt&#xA;    TIMSK|=(1&amp;lt;&amp;lt;TOIE0);&#xA;    //Set Initial Timer value&#xA;    TCNT1=5;&#xA;}&#xA;void StartTimer0(void)&#xA;{&#xA;    //Set prescaller 64 and start timer&#xA;    TCCR0B|=(1&amp;lt;&amp;lt;CS01)|(1&amp;lt;&amp;lt;CS00);&#xA;    //Enable global interrupts&#xA;    sei();&#xA;}&#xA;//Timer0 Overflow ISR&#xA;ISR(TIMER0_OVF_vect)&#xA;{&#xA;    //Reset Initial Timer value&#xA;    TCNT1=5;&#xA;    //toggle PD6 pin&#xA;    PINB=(1&amp;lt;&amp;lt;PB1);&#xA;}&#xA;&#xA;int main(void)&#xA;{&#xA;    InitPort();&#xA;    InitTimer0();&#xA;    StartTimer0();&#xA;    while(1)&#xA;    {&#xA;        //doing nothing&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I know those commands for setting fast PWM and CTC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1D |= (0&amp;lt;&amp;lt;WGM10)|(0&amp;lt;&amp;lt;WGM11);&#xA;TCCR1A |= (1&amp;lt;&amp;lt;PWM1A)|(1&amp;lt;&amp;lt;COM1A0)|(0&amp;lt;&amp;lt;COM1A1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11493" LastEditorUserId="6936" LastEditDate="2015-07-29T14:56:55.953" LastActivityDate="2016-12-21T23:20:22.247" Title="ATtiny461 PWM CTC mode help" Tags="|pwm|attiny|avr|atmel-studio|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13778" PostTypeId="1" CreationDate="2015-07-29T10:29:03.443" Score="2" ViewCount="11385" Body="&lt;p&gt;I am working on a Project with:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;1 Arduino UNO&lt;/li&gt;&#xA;&lt;li&gt;5 micro 9g servos (Only one Working at a time)&lt;/li&gt;&#xA;&lt;li&gt;2 small LED bulbs&lt;/li&gt;&#xA;&lt;li&gt;1 MicroSD reader module&lt;/li&gt;&#xA;&lt;li&gt;1 Speaker&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Can I power my Arduino UNO with a common 9v Battery?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have in mind to use an external power supply for servos... but what to use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest me a perfect power supply system&lt;/p&gt;&#xA;" OwnerUserId="11475" LastEditorUserId="6936" LastEditDate="2015-07-30T18:44:06.833" LastActivityDate="2015-09-04T01:13:57.547" Title="Suggest me a power source for my Arduino UNO project" Tags="|power|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13779" PostTypeId="2" ParentId="13778" CreationDate="2015-07-29T11:22:20.643" Score="2" Body="&lt;p&gt;Unfortunately, the perfect power supply system doesn't exist yet. However, powering an Arduino is simple.  You have to main options 9V for standard &amp;quot;full size&amp;quot; Arduinos (such as the UNO that you mention), although you &lt;em&gt;could&lt;/em&gt; go for the low voltage 3.3V options.&lt;/p&gt;&#xA;&lt;p&gt;Covering just the 9V option, from the Power section of &lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Power&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Arduino Uno can be powered via the USB connection or with an&#xA;external power supply. The power source is selected automatically.&lt;/p&gt;&#xA;&lt;p&gt;External (non-USB) power can come either from an AC-to-DC adapter&#xA;(wall-wart) or battery. The adapter can be connected by plugging a&#xA;2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER&#xA;connector.&lt;/p&gt;&#xA;&lt;p&gt;The board can operate on an external supply of 6 to 20 volts. If&#xA;supplied with less than 7V, however, the 5V pin may supply less than&#xA;five volts and the board may be unstable. If using more than 12V, the&#xA;voltage regulator may overheat and damage the board. The recommended&#xA;range is 7 to 12 volts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You should probably also take a look at &lt;a href=&quot;http://playground.arduino.cc/Main/IntWithHW-PwrSup&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power Supplies&lt;/a&gt;, in particular the section on &lt;a href=&quot;http://playground.arduino.cc/Main/IntWithHW-PwrSup#prsoBat&quot; rel=&quot;nofollow noreferrer&quot;&gt;Batteries and cells&lt;/a&gt;, also from the following section &lt;a href=&quot;http://playground.arduino.cc/Main/IntWithHW-PwrSup#VoltConv&quot; rel=&quot;nofollow noreferrer&quot;&gt;Voltage conversion and regulation&lt;/a&gt;, it states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In a very simple scenario, you connect a disposable 9v battery&#xA;(probably one of the (approx) 4cm x 2.5cm x 1.5cm units with two snap&#xA;connectors on one end) to your Arduino, and the Arduino's built in&#xA;voltage regulator takes care of reducing the voltage to a consistent&#xA;5v or 3.3v, depending on the sort of Arduino you have.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So you have a couple of choices regarding 9V, either the P9 cell&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gs3TI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gs3TI.jpg&quot; alt=&quot;P9 9V Battery&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;or a pack that holds six 1.5V AA or AAA batteries.&lt;/p&gt;&#xA;&lt;p&gt;You may find this link, &lt;a href=&quot;https://hwstartup.wordpress.com/2013/04/15/how-to-run-an-arduino-clone-on-aa-batteries-for-over-a-year-part-2/&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to run an Arduino (clone) on (AA) batteries for over a year – part 2&lt;/a&gt;, an interesting read. Here the chap uses four AA batteries, which only gives 6V, to power an UNO:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n6S5U.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n6S5U.png&quot; alt=&quot;6V Battery Pack and UNO&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have just highlighted some information, you should take the time to read the links fully, and google for more information.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Regarding the servo motors, more current may be required. You &lt;em&gt;can&lt;/em&gt; use the same four AA battery pack, thusly:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/smgcs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/smgcs.jpg&quot; alt=&quot;4-cell battery hold pack with jr style connector&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;but the capacity of the batteries may leave something to be desired, especially if you use rechargeable batteries (which in today's eco-concious world, you should), so you &lt;em&gt;may&lt;/em&gt; require something more hefty. A quick &lt;a href=&quot;https://www.google.co.uk/search?q=servo%20battery&amp;amp;tbm=isch&quot; rel=&quot;nofollow noreferrer&quot;&gt;google&lt;/a&gt; will show you the options available.&lt;/p&gt;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&lt;p&gt;The video &lt;a href=&quot;https://www.youtube.com/watch?v=K6hGvXxFTFA&quot; rel=&quot;nofollow noreferrer&quot;&gt;Flite Test : RC Planes for Beginners: Batteries and Safety - Beginner Series - Ep. 7&lt;/a&gt; is an extremely useful video tutorial about LiPO batteries for RC projects.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-08-15T09:35:14.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13780" PostTypeId="1" CreationDate="2015-07-29T11:43:02.147" Score="1" ViewCount="397" Body="&lt;p&gt;I want to know how I can build a simple &quot;Smartwatch&quot; with an Arduino Pro Mini and a Display with a size from maybe 1,5&quot; what Display should I use for Touch and color?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only want simple things like synchonising the time with my Smartphone trough a HC-06 Bluetooth Module.&lt;/p&gt;&#xA;" OwnerUserId="11495" LastEditorUserId="2944" LastEditDate="2015-07-30T18:44:58.323" LastActivityDate="2015-07-30T18:44:58.323" Title="How can I build a simple &quot;Smartwatch&quot; with Arduino Pro Mini and Display?" Tags="|bluetooth|arduino-pro-mini|time|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13781" PostTypeId="2" ParentId="13777" CreationDate="2015-07-29T11:58:07.467" Score="1" Body="&lt;p&gt;PWM is only supported for timer1 on the ATTiny461. Not in timer0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;a href=&quot;http://www.atmel.com/images/atmel-2588-8-bit-avr-microcontrollers-tinyavr-attiny261-attiny461-attiny861_datasheet.pdf#page=112&quot; rel=&quot;nofollow&quot;&gt;TCCR1A&lt;/a&gt;; specifically the COM1xn bits.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-29T11:58:07.467" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13784" PostTypeId="1" CreationDate="2015-07-29T14:04:27.417" Score="6" ViewCount="43316" Body="&lt;p&gt;I am trying to upload this simple sketch into my arduino with a shield I made. It takes forever (note I have the right COM port on)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  int sensorValue = 0;&#xA;&#xA;  void setup(){ &#xA;     Serial.begin(9600); &#xA;  }&#xA;&#xA;  void loop(){&#xA;     sensorValue = analogRead(A4);&#xA;     delay(10000000);&#xA;     Serial.println(sensorValue); &#xA;     delay(10000000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="4131" LastEditDate="2015-07-31T08:25:04.170" LastActivityDate="2021-08-10T17:12:38.870" Title="Uploading a simple sketch takes forever" Tags="|arduino-uno|" AnswerCount="6" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13785" PostTypeId="2" ParentId="13780" CreationDate="2015-07-29T14:05:19.943" Score="1" Body="&lt;p&gt;If your goal is to make a watch you'll need a RTC (Real Time Clock) this can take the form of breakout board, or you can build the circuit yourself. The RTC is needed if you want the mini to display the time. The mini (in fact, most micros) have no internal clock (though they may have a crystal that can simulate time keeping, but this isn't as useful if you want the time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you want an OLED display. They come in watch-like sizes. There are a few small ones. None are touch displays. I have seen larger touch displays. Maybe combine an OLED with a clear capacitive surface?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-07-29T14:05:19.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13788" PostTypeId="2" ParentId="3479" CreationDate="2015-07-29T17:21:24.793" Score="0" Body="&lt;p&gt;hello sachleen try this code it working I edited from your code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This will store the last known state of the button&#xA;const int buttonPin = A15;   // change as per your button attached. &#xA;const int motorPin =  12;   // &#xA;const int ledPin = 13;&#xA; int x = 1;&#xA;// variables will change:&#xA;int buttonState = 0;         &#xA;int oldButtonState = LOW;&#xA;&#xA;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(motorPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);   &#xA;  pinMode(ledPin, OUTPUT);  &#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  // Get the current state of the button&#xA;  int newButtonState = digitalRead(buttonPin);&#xA;&#xA;  // Has the button gone high since we last read it?&#xA;  if (newButtonState == HIGH &amp;amp;&amp;amp; oldButtonState == LOW) {&#xA;&#xA;    if (x == 0) {&#xA;      // Toggle on&#xA;      digitalWrite(ledPin, HIGH);&#xA;      x = 1;&#xA;&#xA;    } else {&#xA;      // Toggle off&#xA;      digitalWrite(ledPin, LOW);&#xA;      x = 0;&#xA;    }&#xA;  }&#xA;&#xA;  // Store the button's state so we can tell if it's changed next time round&#xA;  oldButtonState = newButtonState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11500" LastEditorUserId="10794" LastEditDate="2015-07-29T20:41:42.943" LastActivityDate="2015-07-29T20:41:42.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13789" PostTypeId="2" ParentId="13784" CreationDate="2015-07-29T18:13:32.673" Score="9" Body="&lt;p&gt;Are you sure the problem is in the upload time? delay() takes the number of milliseconds you want to wait. In your code, it should take about 3 hours before the Arduino sends some data through the serial port.&lt;/p&gt;&#xA;" OwnerUserId="11488" LastActivityDate="2015-07-29T18:13:32.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13792" PostTypeId="2" ParentId="5022" CreationDate="2015-07-29T21:34:35.660" Score="1" Body="&lt;p&gt;There are two processors on the Uno board.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Atmega328P which is the &quot;main&quot; processor with your sketches on it&lt;/li&gt;&#xA;&lt;li&gt;The Atmega16U2 which handles the USB interface&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Firmware was located in /usr/share/arduino/hardware/arduino/firmwares/atmegaxxu2/Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hopefully you reflashed the &lt;strong&gt;Atmega16U2&lt;/strong&gt; with that file. Did you?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I tried loop-back mode, everything is fine.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Therefore the Atmega16U2 is OK. The problem may be with the Atmega328P.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I had problems with Arduino Uno and reseted firmware.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You shouldn't need to do this, I never reflash the firmware on my Atmega16U2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What problems did you have? Did it involve motors? LEDs? High voltages? Sparks? Flames? Screaming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see the steps described here, run through them, and see if that fixes the problem: &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-07-29T21:34:35.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13793" PostTypeId="2" ParentId="13784" CreationDate="2015-07-29T21:46:52.977" Score="1" Body="&lt;p&gt;If the problem does indeed lie in the upload (see DoubtBearer's answer), then you should turn on verbose output, to see exactly what part of the upload is giving issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your IDE, click File -&gt; preferences; look for the section &quot;Show verbose output during:&quot; and tick both Compilation and Upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Re-run your upload, and see what is taking up all the time. If you can't figure it out from that, please post the log (it will appear in the black area at the bottom of the IDE, you should be able to cut &amp;amp; paste).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-07-29T21:46:52.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13794" PostTypeId="2" ParentId="13773" CreationDate="2015-07-29T22:50:15.017" Score="1" Body="&lt;p&gt;The other answers are excellent, however I want to address this question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How does a multiplexer play into this? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just as an example of how multiplexing helps, I opened up a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12298&quot; rel=&quot;nofollow noreferrer&quot;&gt;scrolling LED sign&lt;/a&gt; which has 504 individual LEDs which &quot;appear&quot; to be all on at once (if wanted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internally were 10 x &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC595&lt;/a&gt; serial shift registers. 9 of them were hooked up to the individual columns (giving 72 columns), and the last one was connected to the 7 rows. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 9 * 8 =  72    columns&#xA;72 * 7 = 504    LEDs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus we could turn on 504 LEDs. However to have individual LEDs appear to come on the code has to turn on one row (out of the 7) and then output the pattern for that row to the 72 columns. Then it switches to another row, does the next pattern, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;https://vimeo.com/80312101&quot; rel=&quot;nofollow noreferrer&quot;&gt;video of this effect&lt;/a&gt; on Vimeo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do it fast enough, all the LEDs appear to be one at once.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now you can do this for switches too, just connect all the individual positions together, and then apply &quot;power&quot; to each switch in sequence, and read the results. This time you want an &lt;strong&gt;input&lt;/strong&gt; shift register, eg. the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11979&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC165&lt;/a&gt; for the reading, and an output register for powering each switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is with switches though, that you would get &quot;phantom&quot; reads because switches aren't diodes (or, worse, the inactive switches would short the power to ground). So you would need a &lt;strong&gt;diode&lt;/strong&gt; in series with each switch to prevent that. Ah well, diodes are cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is exactly the same concept as the way keypads work. Say, a 16-key keypad will have 8 wires: 4 rows and 4 columns.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said all that, you will still need quite a few chips unless you set up quite a complex &quot;simulated&quot; keypad array. Maybe it wouldn't be too bad. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 17 switches so that would be 2 x 74HC595 for activating each switch, plus one spare pin on the Arduino. And the switches seem to have around 12 positions, so that would be 2 x 74HC165 to read which position it was at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for each switch, you make that one HIGH and the others LOW. Current will flow through the diodes and the rotary switch, presenting a HIGH on one of the 12 &quot;reading&quot; pins. The diodes stop the current from shorting the HIGH to the LOW through other switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You take a reading, and move onto the next switch. This can be done quickly, in the same way the LED sign scrolls so fast you can't spot any flickering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This schematic illustrates the idea:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/na69k.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/na69k.png&quot; alt=&quot;Rotary switch example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example we apply a HIGH to the common part (rotor) of the left switch. It goes through the diode, and the selected position, to make input &quot;read 1&quot; high. The diode on the other switch prevents the HIGH from being shorted to the LOW, even though both switches are in the same position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need a pull-down resistor for each of the 12 &quot;reading&quot; lines, so that if they weren't being forced HIGH, they would read LOW. And one diode per rotary switch. So, not too many extra parts. And the wiring is simple, just connect each corresponding switch pin together (except for the common one, of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this will work, unless anyone can see a major flaw. :)&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-31T21:26:43.917" LastActivityDate="2015-07-31T21:26:43.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13795" PostTypeId="1" AcceptedAnswerId="13799" CreationDate="2015-07-30T00:47:01.337" Score="0" ViewCount="3368" Body="&#xA;&#xA;&lt;p&gt;I am trying to use two &lt;code&gt;4051&lt;/code&gt; ICs with an Arduino Micro right now. The idea was to have an 16-sensor demo station (8 sensors per &lt;code&gt;4051&lt;/code&gt;) wherein each &lt;code&gt;4051&lt;/code&gt; pin selection is controlled by a potentiometer as input. I am new to using MUX's, so I mocked the following up as a quick demo based on &lt;a href=&quot;http://playground.arduino.cc/Learning/4051&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; help document via Arduino (it's basically the same), which only uses one &lt;code&gt;4051&lt;/code&gt; and does not use a potentiometer as selector input. So, I should be able to set the variable &lt;code&gt;which&lt;/code&gt; to whatever number (0 - 7) to change the sensor selection that shows up at &lt;code&gt;A2&lt;/code&gt; on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting &lt;code&gt;which&lt;/code&gt; to 0 is fine, but when I have more than two sensors plugged into &lt;code&gt;4051&lt;/code&gt; and set the selector pin to any other number than 0 there is a strong likelihood that the output that shows up in the &lt;code&gt;Serial Monitor&lt;/code&gt; is both unresponsive to the selected sensor change and appears to be simply noise (random numbers around 200 or so). I have been trying to isolate where this noise is coming from and am totally stumped. Has anyone had this issue and, if so, any suggestions on how to further diagnose what is happening? I am currently powering everything off of the Arduino &lt;code&gt;5V&lt;/code&gt;, which I am under the impression should be okay, though I have tried this with external power supplies (&lt;code&gt;12V at 2A&lt;/code&gt;, for example) and gotten the same results (so I am fairly certain power is not the issue here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Measuring voltage on pins 2, 3, and 4, I am seeing 1mV on pin 2, 1mV on pin 3, and 0.9mV on pin 4 following the initial spike during upload. When comparing against the Arduino 4051 doc I linked to above, I see that in that file pins 2, 3, and 4 show a Voltage of 2.5V following the initial spike during upload. Any idea what I am doing incorrectly?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Sensor Station via MUX&#xA;&#xA; * code example for useing a 4051 * analog multiplexer / demultiplexer&#xA; * by david c. and tomek n.* for k3 / malmï¿½ hï¿½gskola&#xA; *&#xA; * edited by Ross R.&#xA; */&#xA;&#xA;int r0 = 0;      //value of select pin at the 4051 (s0)&#xA;int r1 = 0;      //value of select pin at the 4051 (s1)&#xA;int r2 = 0;      //value of select pin at the 4051 (s2)&#xA;int which = 0;   //which y pin we are selecting&#xA;int val;&#xA;&#xA;void setup() {&#xA;  pinMode(A2, INPUT);       // mux1 input&#xA;  pinMode(2, OUTPUT);    // s0&#xA;  pinMode(3, OUTPUT);    // s1&#xA;  pinMode(4, OUTPUT);    // s2&#xA;}&#xA;&#xA;void loop () {&#xA;&#xA;  which = (0);&#xA;&#xA;  // select the bit&#xA;  r0 = bitRead(which, 0);&#xA;  r1 = bitRead(which, 1);&#xA;  r2 = bitRead(which, 2);    // use this with arduino 0013 (and newer     versions)&#xA;&#xA;  digitalWrite(2, r0);&#xA;  digitalWrite(3, r1);&#xA;  digitalWrite(4, r2);&#xA;&#xA;  //Either read or write the multiplexed pin here&#xA;  // refactor, this should be digitalWrite with millis or something&#xA;  val = analogRead(A2);     // MUX ouputs here&#xA;&#xA;  Serial.print(&quot;sensor number &quot;);&#xA;  Serial.print(which);&#xA;  Serial.print('\t');&#xA;  Serial.print(&quot;val is &quot;);&#xA;  Serial.println(val);&#xA;&#xA;  delay(2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11506" LastEditorUserId="10794" LastEditDate="2015-07-30T05:20:46.437" LastActivityDate="2015-07-31T00:36:33.630" Title="Arduino + 4051 -&gt; noise on certain 4051 pins" Tags="|power|arduino-micro|multiplexer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13796" PostTypeId="1" CreationDate="2015-07-30T02:54:29.613" Score="2" ViewCount="1881" Body="&lt;p&gt;I am working on an Arduino UNO Project and running out of digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I convert the six analog pins to digital I/O and use them to drive servos?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest me a method&lt;/p&gt;&#xA;" OwnerUserId="11475" LastEditorUserId="6936" LastEditDate="2015-07-30T21:13:54.823" LastActivityDate="2015-07-30T21:13:54.823" Title="Converting Arduino UNO's analog pins to digital I/O" Tags="|pins|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13797" PostTypeId="2" ParentId="13796" CreationDate="2015-07-30T03:17:53.153" Score="4" Body="&lt;p&gt;A0 through A5 already have GPIO capability; treat them as you would &lt;a href=&quot;http://playground.arduino.cc/ComponentLib/Servo&quot; rel=&quot;nofollow&quot;&gt;any other non-PWM pin&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A6 and A7, found in similar boards that use a SMD package, do not have any GPIO capability whatsoever and can only be used for analog input.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-30T03:17:53.153" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13798" PostTypeId="1" AcceptedAnswerId="13810" CreationDate="2015-07-30T04:27:18.363" Score="0" ViewCount="399" Body="&lt;p&gt;Problem moving a stepper motor after reading a value from a webpage....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a project to move a stepper motor from an angle after reading a number from internet; I have a typical 28BYJ-48 stepper with the hardware driver and an arduino + ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested the motor alone with different library and it is working very well, the motor turn correctly to the proper angle and without shaking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also been able to read a specific page with a number on it with the Ethernet shield and library. I am able to light a led whenever a certain value is read from this webpage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I connect the 2 parts, either the stepper motot is vibrating a lot and moving from half the correct angle, either it is only shaking and not moving at all....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have powered it with an external power source thinking it was because of power issues but it doesn't change anything.....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't get it... Why would it work well before the etheret connection an not after?? Maybe it's late and I miss something obvious, but frankly I spent a lot of time looking online and checking my code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my sketch if it anyone could help... thanks a lot in advance, I know it's quite long....but i'm quite desperate :-(&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;////////////////////////////////////////////////////////////////////////&#xA;//CONFIGURE&#xA;////////////////////////////////////////////////////////////////////////&#xA;&#xA;#define HALFSTEP 8&#xA;&#xA;// Motor pin definitions&#xA;#define motorPin1  8     // IN1 on the ULN2003 driver 1&#xA;#define motorPin2  9     // IN2 on the ULN2003 driver 1&#xA;#define motorPin3  10     // IN3 on the ULN2003 driver 1&#xA;#define motorPin4  11    // IN4 on the ULN2003 driver 1&#xA;&#xA;// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48&#xA;AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);&#xA;const int stepsPerRev =  2038;&#xA;&#xA;&#xA;byte server[] = { 192,168,0,11 }; //ip Address of the server you will connect to&#xA;String serverIP = &quot;192.168.0.11&quot;;&#xA;&#xA;int port = 8888; // server port&#xA;&#xA;// if need to change the MAC address (Very Rare)&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;// byte ip[] = { 192, 168, 0, 188 }; // case we want to use fixed IP&#xA;&#xA;&#xA;//The location to go to on the server&#xA;//make sure to keep HTTP/1.0 at the end, this is telling it what type of file it is&#xA;String webPage = &quot;/index.php HTTP/1.0&quot;;&#xA;&#xA;EthernetClient client;&#xA;&#xA;char inString[32]; // string for incoming serial data&#xA;int stringPos = 0; // string index counter&#xA;boolean startRead = false; // is reading?&#xA;int ledPin = 5;&#xA;String pageValue;&#xA;&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////&#xA;// SETUP&#xA;//////////////////////////////////////////////////////////////////////////////&#xA;&#xA;// setup the stepper parameters&#xA;&#xA;void setup() {&#xA;  stepper1.setMaxSpeed(3000.0);&#xA;  stepper1.setAcceleration(1000.0);&#xA;  stepper1.setSpeed(500);&#xA;&#xA;&#xA;// start a full rotation ==&amp;gt; this is perfectly working!!&#xA;&#xA;int steps = degreesToSteps(360);&#xA;  stepper1.moveTo(steps);&#xA;  stepper1.runToPosition();&#xA;&#xA;&#xA;   Serial.begin(9600);&#xA;&#xA;   Serial.println(&quot;starting communication&quot;);&#xA;&#xA;  //Connect the Ethernet Shield by specifying the board's mac and ip address&#xA;&#xA;  if(Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;   }else{&#xA;    Serial.println(&quot;Ethernet shield connected &amp;amp; obtained IP address : &quot;);&#xA;    Serial.println(Ethernet.localIP());&#xA;&#xA;&#xA;   //Shield already connected during setup phase, now connect to the webpage and retrieve the value&#xA;&#xA;    //Connect to the server&#xA;    if(!connectToServer(server, port, webPage)){&#xA;        Serial.println(&quot;Failed to connect to server&quot;);&#xA;&#xA;        }else{&#xA;&#xA;               Serial.println(&quot;connected to server page&quot;);&#xA;&#xA;               //Read the output value written on the webpage&#xA;&#xA;              int angle = readPage().toInt();&#xA;              Serial.println(angle); &#xA;&#xA;              int steps = degreesToSteps(angle);&#xA;              Serial.println(steps);&#xA;&#xA;              stepper1.moveTo(steps);       &#xA;&#xA;              stepper1.runToPosition();&#xA;&#xA;              delay(1000);&#xA;&#xA;      //end of success case connection  &#xA;      } &#xA;&#xA;&#xA;&#xA;   }&#xA;&#xA; //end of setup&#xA; }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void loop(){}&#xA;&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////////////////&#xA;//Connect to a web page &#xA;////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;&#xA;boolean connectToServer(byte* server, int port, String webPage)&#xA;{&#xA;  //connect to the server&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  //port 8888 for our mamp server&#xA;  if (client.connect(server, port)) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    client.print(&quot;GET &quot;);&#xA;    client.println(webPage);&#xA;    client.println();&#xA;    return true;&#xA;  }else{&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    return false;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////////////////&#xA;//Parse a value located between a &amp;lt; and a &amp;gt;&#xA;////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;&#xA;&#xA;String readPage(){&#xA;  //read the page, and capture &amp;amp; return everything between '&amp;lt;' and '&amp;gt;'&#xA;&#xA;  stringPos = 0;&#xA;  memset( &amp;amp;inString, 0, 32 ); //clear inString memory&#xA;&#xA;  while(true){&#xA;&#xA;    if (client.available()) {&#xA;      char c = client.read();&#xA;&#xA;      if (c == '&amp;lt;' ) { //'&amp;lt;' is our begining character&#xA;        startRead = true; //Ready to start reading the part &#xA;      }else if(startRead){&#xA;&#xA;        if(c != '&amp;gt;'){ //'&amp;gt;' is our ending character&#xA;          inString[stringPos] = c;&#xA;          stringPos ++;&#xA;        }else{&#xA;          //got what we need here! We can disconnect now&#xA;&#xA;          startRead = false;&#xA;          client.stop();&#xA;          client.flush();&#xA;          Serial.println(&quot;disconnecting.&quot;);&#xA;          return inString;&#xA;&#xA;        }&#xA;&#xA;      }&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////////////////&#xA;//Convert the degrees into the closest number of steps relative to the step motor model.&#xA;////////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;int degreesToSteps(float angleDegrees) {&#xA;  //return the closest number of steps to accomplish to move the motor for the specified angle&#xA;&#xA;  const float stepsPerDegree = stepsPerRev/360.00;&#xA;  int steps = angleDegrees * stepsPerDegree + 0.5;  // we add 0.5 as when converting to an int the floating part is truncated, this allows to round the value to the nearest Int&#xA;  return steps;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11426" LastActivityDate="2015-07-30T14:41:35.693" Title="Strange comportment of stepper motor while connected to internet" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13799" PostTypeId="2" ParentId="13795" CreationDate="2015-07-30T05:20:21.020" Score="2" Body="&lt;p&gt;I have a post about that chip at &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC4051 multiplexer / demultiplexer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made up the circuit shown on my page above with modifications as described below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QD3j2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QD3j2.png&quot; alt=&quot;74HC4051 example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I moved the A/B/C and O/I pins to match your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A is the &lt;strong&gt;low-order bit&lt;/strong&gt; so pin 11 on the 74HC4051 should go to D2 on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;74HC4051  Arduino   Meaning&#xA;    11       D2        A&#xA;    10       D3        B&#xA;     9       D4        C&#xA;     3       A2        O/I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put a pot on I/O0 (pin 13 on the 74HC4051) and randomly set the other pins to +5 V or Gnd, as shown.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt; I added:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.begin (115200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also modified it to automatically sequence through all 8 possible ports, and then stop after 1000 iterations to stop flooding the USB port on my computer. Code is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int r0 = 0;      //value of select pin at the 4051 (s0)&#xA;int r1 = 0;      //value of select pin at the 4051 (s1)&#xA;int r2 = 0;      //value of select pin at the 4051 (s2)&#xA;int which = 0;   //which y pin we are selecting&#xA;int val;&#xA;&#xA;void setup() {&#xA;  Serial.begin (115200);&#xA;  pinMode(A2, INPUT);       // mux1 input&#xA;  pinMode(2, OUTPUT);    // s0&#xA;  pinMode(3, OUTPUT);    // s1&#xA;  pinMode(4, OUTPUT);    // s2&#xA;}  // end of setup&#xA;&#xA;unsigned long counter;&#xA;&#xA;void loop () {&#xA;&#xA;  // select the bit&#xA;  r0 = bitRead(which, 0);&#xA;  r1 = bitRead(which, 1);&#xA;  r2 = bitRead(which, 2);    // use this with arduino 0013 (and newer     versions)&#xA;&#xA;  digitalWrite(2, r0);&#xA;  digitalWrite(3, r1);&#xA;  digitalWrite(4, r2);&#xA;&#xA;  //Either read or write the multiplexed pin here&#xA;  // refactor, this should be digitalWrite with millis or something&#xA;  val = analogRead(A2);     // MUX ouputs here&#xA;&#xA;  Serial.print(&quot;sensor number &quot;);&#xA;  Serial.print(which);&#xA;  Serial.print('\t');&#xA;  Serial.print(&quot;val is &quot;);&#xA;  Serial.println(val);&#xA;&#xA;  delay(2);&#xA;&#xA;  if (++which &amp;gt; 7)&#xA;    which = 0;&#xA;&#xA;  if (++counter &amp;gt;= 1000)&#xA;    {&#xA;    Serial.flush ();&#xA;    exit (1);&#xA;    }   &#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The output from your sketch was as expected:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;sensor number 0 val is 781&#xA;sensor number 1 val is 0&#xA;sensor number 2 val is 1023&#xA;sensor number 3 val is 1023&#xA;sensor number 4 val is 0&#xA;sensor number 5 val is 0&#xA;sensor number 6 val is 0&#xA;sensor number 7 val is 1023&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suggest you check that your wiring agrees with mine.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-31T00:36:33.630" LastActivityDate="2015-07-31T00:36:33.630" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13800" PostTypeId="1" CreationDate="2015-07-30T05:56:12.560" Score="2" ViewCount="5153" Body="&lt;p&gt;I have followed the instructions to run the &lt;a href=&quot;http://playground.arduino.cc/Interfacing/Processing&quot; rel=&quot;nofollow&quot;&gt;Arduino processing examples&lt;/a&gt; but with no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Always &lt;code&gt;import processing.serial.*;&lt;/code&gt; does not name a type. Which is perhaps a library (processing-arduino) related error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch is a sketch that comes with processing-arduino library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched for a long time with no solution. Any suggestion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino_output:28: error: 'import' does not name a type&#xA;arduino_output:30: error: 'import' does not name a type&#xA;arduino_output:32: error: 'Arduino' does not name a type&#xA;arduino_output:34: error: 'color' does not name a type&#xA;arduino_output:35: error: 'color' does not name a type&#xA;arduino_output:37: error: expected unqualified-id before '[' token&#xA;arduino_output.pde: In function 'void setup()':&#xA;arduino_output:42: error: 'size' was not declared in this scope&#xA;arduino_output:45: error: 'Arduino' was not declared in this scope&#xA;arduino_output:45: error: 'println' was not declared in this scope&#xA;arduino_output:50: error: 'arduino' was not declared in this scope&#xA;arduino_output:50: error: expected type-specifier before 'Arduino'&#xA;arduino_output:50: error: expected `;' before 'Arduino'&#xA;arduino_output:58: error: expected unqualified-id before numeric constant&#xA;arduino_output.pde: In function 'void draw()':&#xA;arduino_output:62: error: 'off' was not declared in this scope&#xA;arduino_output:62: error: 'background' was not declared in this scope&#xA;arduino_output:63: error: 'on' was not declared in this scope&#xA;arduino_output:63: error: 'stroke' was not declared in this scope&#xA;arduino_output:66: error: 'values' was not declared in this scope&#xA;arduino_output:66: error: 'Arduino' was not declared in this scope&#xA;arduino_output:66: error: expected unqualified-id before numeric constant&#xA;arduino_output:66: error: expected `)' before numeric constant&#xA;arduino_output:67: error: 'fill' was not declared in this scope&#xA;arduino_output:69: error: 'fill' was not declared in this scope&#xA;arduino_output:71: error: 'rect' was not declared in this scope&#xA;arduino_output.pde: In function 'void mousePressed()':&#xA;arduino_output:77: error: 'mouseX' was not declared in this scope&#xA;arduino_output:80: error: 'values' was not declared in this scope&#xA;arduino_output:80: error: 'Arduino' was not declared in this scope&#xA;arduino_output:80: error: expected unqualified-id before numeric constant&#xA;arduino_output:80: error: expected `)' before numeric constant&#xA;arduino_output:81: error: 'arduino' was not declared in this scope&#xA;arduino_output:81: error: expected unqualified-id before numeric constant&#xA;arduino_output:82: error: expected unqualified-id before numeric constant&#xA;arduino_output:82: error: expected `;' before numeric constant&#xA;arduino_output:84: error: 'arduino' was not declared in this scope&#xA;arduino_output:84: error: expected unqualified-id before numeric constant&#xA;arduino_output:85: error: expected unqualified-id before numeric constant&#xA;arduino_output:85: error: expected `;' before numeric constant&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11511" LastEditorUserId="6936" LastEditDate="2015-07-30T18:43:58.597" LastActivityDate="2015-07-30T18:43:58.597" Title="Processing error with processing-arduino examples" Tags="|serial|processing-lang|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13801" PostTypeId="1" CreationDate="2015-07-30T06:32:57.153" Score="0" ViewCount="151" Body="&lt;p&gt;I am wondering why my Arduino program won't start its sketch to connect a bluesmirf to an android device and send data to the android whenever I use an external power supply. The sketch starts whenever i open the serial monitor, but using the power supply, it wont work.&lt;/p&gt;&#xA;" OwnerUserId="11513" LastActivityDate="2015-12-27T13:53:48.787" Title="Arduino Bluetooth connection with Android" Tags="|serial|programming|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13802" PostTypeId="2" ParentId="12312" CreationDate="2015-07-30T08:17:05.797" Score="2" Body="&lt;p&gt;The differrence is usablilty and, in some cases, the protection of your chip; if there is a surge of more than 5V to your driver it will fry, which is why some drivers have onboard voltage regulators and a heatsink for overheating problems. Advantage of motor driver is that you can use it as per your requirements, whereas a shield is fixed and you cannot change any aspects.&lt;/p&gt;&#xA;" OwnerUserId="11515" LastEditorUserId="10003" LastEditDate="2015-07-31T21:20:37.770" LastActivityDate="2015-07-31T21:20:37.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13803" PostTypeId="2" ParentId="13801" CreationDate="2015-07-30T08:36:14.497" Score="2" Body="&lt;p&gt;You'll probably find that you are not supplying enough power to operate the Arduino and the components attached to the Arduino. Your current (Amps) draw is most likely higher than your external power supply can output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had this problem when using a 9v battery to power an Arduino with an XBee chip and some LEDs attached. The 9v would be able to power the kit for a while but would then not output enough current to power the Arduino. In the end I had to scrap a few LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to find out how much current your Arduino and its components are using and use a suitable power supply that can output enough current to power your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also remember when you send and receive a packet out of a Bluetooth radio - more current is required than when the Bluetooth radio is idle.&lt;/p&gt;&#xA;" OwnerUserId="11451" LastActivityDate="2015-07-30T08:36:14.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13804" PostTypeId="2" ParentId="3890" CreationDate="2015-07-30T09:26:08.583" Score="1" Body="&lt;p&gt;Please check this tutorial if you want to upload sketches to Pro mini with Arduino UNO with SDM chip &#xA;&lt;a href=&quot;http://www.instructables.com/id/Uploading-sketches-to-Pro-Mini-using-Arduino-UNO-b&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Uploading-sketches-to-Pro-Mini-using-Arduino-UNO-b&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11516" LastActivityDate="2015-07-30T09:26:08.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13805" PostTypeId="2" ParentId="13800" CreationDate="2015-07-30T09:49:23.077" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: I am testing this on OS X, so my paths may differ slightly from yours.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have managed to reproduce your issue, by &lt;em&gt;incorrectly&lt;/em&gt; copying the &lt;code&gt;arduino&lt;/code&gt; directory, from the unzipped &lt;a href=&quot;http://playground.arduino.cc/uploads/Interfacing/processing2-arduino.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;processing2-arduino.zip&lt;/a&gt; package, to the &lt;code&gt;libraries&lt;/code&gt; directory under the &lt;code&gt;Arduino&lt;/code&gt; directory in my home directory, thus &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/user/Documents/Arduino/libraries/arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then opening the Arduino IDE and running the &lt;code&gt;arduino_output&lt;/code&gt; example, via the menu, &lt;code&gt;File -&amp;gt; Sketchbook -&amp;gt; Libraries -&amp;gt; Arduino -&amp;gt; arduino_output&lt;/code&gt;. When I hit the compile button, in the Arduino IDE, the compiler throws up the exact same errors that you describe in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this is not the correct usage of this package. This package is intended to be used in conjunction with the &lt;strong&gt;Processing&lt;/strong&gt; application, &lt;em&gt;not&lt;/em&gt; the &lt;strong&gt;Arduino IDE&lt;/strong&gt;. You should download &lt;a href=&quot;https://processing.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Processing&lt;/a&gt; and then follow the &lt;a href=&quot;http://playground.arduino.cc/Interfacing/Processing&quot; rel=&quot;nofollow noreferrer&quot;&gt;instructions&lt;/a&gt; again:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Unzip the library and copy the &quot;arduino&quot; folder into the &quot;libraries&quot; sub-folder of your Processing Sketchbook. (You can find&#xA;  the location of your Sketchbook by opening the Processing Preferences.&#xA;  If you haven't made a &quot;libraries&quot; sub-folder, create one.)&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, on OS X, the path should now be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/user/Documents/Processing/libraries/arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, as usual, the documentation on the Arduino website leaves a lot to be desired. Pay careful attention to the following paragraph if you are running OS X or Linux:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: if you run Linux, you need to change &lt;code&gt;Arduino.jar&lt;/code&gt; into&#xA;  &lt;code&gt;arduino.jar&lt;/code&gt;, because Linux is case sensitive and it does not work if&#xA;  you don't change this letter (Arduino.jar is in the folder &quot;library&quot;&#xA;  of this Processing Library).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/user/Documents/Arduino/libraries/arduino/library/Arduino.jar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/user/Documents/Arduino/libraries/arduino/library/arduino.jar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Relaunch the Processing application. &lt;code&gt;File -&amp;gt; Examples...&lt;/code&gt;, opens up a window, scroll down to &lt;code&gt;Contributed Libraries&lt;/code&gt;, open that, open &lt;code&gt;Arduino (Firmata)&lt;/code&gt;, open the &lt;code&gt;arduino_output&lt;/code&gt; example. Hit the &lt;strong&gt;Run&lt;/strong&gt; button, and after compiling you should see the window below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iO5s6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iO5s6.png&quot; alt=&quot;arduino_output window&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-07-30T12:07:45.813" LastActivityDate="2015-07-30T12:07:45.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13806" PostTypeId="1" CreationDate="2015-07-30T10:31:57.497" Score="1" ViewCount="3021" Body="&lt;p&gt;For my code I use a couple of static variables.&#xA;But when I search the internet, they seem &quot;evil&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: I have a function which will be executed every loop (5ms looptime).&#xA;to increase the speed I added some static variables to it.&#xA;Is the way I am doing this bad? Are there simple solutions for it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ProgFormula() {&#xA;  static int StartPosition;&#xA;  static int DeltaPosition;&#xA;  static int LoopTime = 5;&#xA;  static int AccelerationLoops;&#xA;  static int TotalLoops;&#xA;  static int EndOne;&#xA;&#xA;  static float VelocityLoop;&#xA;  static float VelocityFactor;&#xA;&#xA;  int Setpoint;&#xA;&#xA;  if (Iteration == -1) {&#xA;    StartPosition = PID.ActualPosition;&#xA;    DeltaPosition = abs(SetPosition - StartPosition);&#xA;    VelocityLoop = Velocity / (1000 / LoopTime);&#xA;    TotalLoops = DeltaPosition / VelocityLoop;&#xA;    if (TotalLoops &amp;lt;= (AccelerationLoops * 2)) {&#xA;      AccelerationLoops = (TotalLoops / 2);&#xA;      VelocityFactor = (VelocityLoop * 0.5 / AccelerationLoops) / 2;&#xA;    }&#xA;    else {&#xA;      AccelerationLoops = 70;&#xA;&#xA;      VelocityFactor = VelocityLoop * 0.5 / AccelerationLoops;&#xA;    }&#xA;    TotalLoops = DeltaPosition / VelocityLoop + AccelerationLoops;&#xA;    EndOne = (VelocityFactor * pow(AccelerationLoops, 2));&#xA;  }&#xA;  else if (Iteration &amp;gt;= 0 &amp;amp;&amp;amp; Iteration &amp;lt;= AccelerationLoops) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = VelocityFactor * pow(Iteration, 2) + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = -VelocityFactor * pow(Iteration, 2) + StartPosition;&#xA;    }&#xA;  }&#xA;  else if (Iteration &amp;gt; AccelerationLoops &amp;amp;&amp;amp; Iteration &amp;lt;= (TotalLoops - AccelerationLoops)) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = VelocityLoop * Iteration - EndOne + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = -VelocityLoop * Iteration + EndOne + StartPosition;&#xA;    }&#xA;  }&#xA;  else if (Iteration &amp;gt;= (TotalLoops - AccelerationLoops) &amp;amp;&amp;amp; Iteration &amp;lt;= TotalLoops) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = -VelocityFactor * pow((TotalLoops - Iteration), 2) + DeltaPosition + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = VelocityFactor * pow((TotalLoops - Iteration), 2) - DeltaPosition + StartPosition;&#xA;    }&#xA;  }&#xA;  else {&#xA;    Setpoint = Setpoint;&#xA;  }&#xA;  return(Setpoint);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it better to avoid statics? If so why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&#xA;Koen&lt;/p&gt;&#xA;" OwnerUserId="10700" LastEditorUserId="10794" LastEditDate="2015-07-31T02:55:24.910" LastActivityDate="2015-08-05T16:47:48.670" Title="Are static variables in a function bad?" Tags="|c++|arduino-ide|code-optimization|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13808" PostTypeId="1" AcceptedAnswerId="14009" CreationDate="2015-07-30T12:23:14.317" Score="0" ViewCount="844" Body="&lt;p&gt;I have to read the incoming SMS on my GSM module SIM900, and I want to print the sender number and message to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first configure the GSM module with AT commands and Response() function will give me the response to AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as any SMS will be in the following pattern&lt;/p&gt;&#xA;&#xA;&lt;p&gt;+CMT: &quot;[Mobile number]&quot;, &quot;[Date and Time]&gt;&quot;&#xA;   [message body]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I first extract +CMT and after that I will take mobile number and at last we have message body. The code I have used is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char RcvdMsg[200] = &quot;&quot;;&#xA;int RcvdCheck = 0;&#xA;int RcvdConf = 0;&#xA;int index = 0;&#xA;int RcvdEnd = 0;&#xA;char MsgMob[15];&#xA;char MsgTxt[50];&#xA;int MsgLength = 0;&#xA;&#xA;void Config() // This function is configuring our SIM900 module i.e. sending the initial AT commands&#xA;{&#xA;    delay(1000);&#xA;    Serial.print(&quot;ATE0\r&quot;);&#xA;    Response();&#xA;    Serial.print(&quot;AT\r&quot;);&#xA;    Response();&#xA;    Serial.print(&quot;AT+CMGF=1\r&quot;);&#xA;    Response();&#xA;    Serial.print(&quot;AT+CNMI=1,2,0,0,0\r&quot;);&#xA;    Response();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    Config();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  RecSMS();&#xA;}&#xA;&#xA;void Response() // Get the Response of each AT Command&#xA;{&#xA;    int count = 0;&#xA;    Serial.println();&#xA;    while(1)&#xA;    {&#xA;        if(Serial.available())&#xA;        {&#xA;            char data =Serial.read();&#xA;            if(data == 'K')&#xA;            {&#xA;                Serial.println(&quot;OK&quot;);&#xA;                break;&#xA;            }&#xA;            if(data == 'R')&#xA;            {&#xA;                Serial.println(&quot;GSM Not Working&quot;);&#xA;                break;&#xA;            }&#xA;        }&#xA;        count++;&#xA;        delay(10);&#xA;        if(count == 1000)&#xA;        {&#xA;            Serial.println(&quot;GSM not Found&quot;);&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void RecSMS() // Receiving the SMS and extracting the Sender Mobile number &amp;amp; Message Text&#xA;{&#xA;    if(Serial.available())&#xA;    {&#xA;        char data = Serial.read();&#xA;        if(data == '+'){RcvdCheck = 1;}&#xA;        if((data == 'C') &amp;amp;&amp;amp; (RcvdCheck == 1)) {RcvdCheck = 2;}&#xA;        if((data == 'M') &amp;amp;&amp;amp; (RcvdCheck == 2)) {RcvdCheck = 3;}&#xA;        if((data == 'T') &amp;amp;&amp;amp; (RcvdCheck == 3)) {RcvdCheck = 4;}&#xA;        if(RcvdCheck == 4)&#xA;        {&#xA;            RcvdConf = 1;&#xA;            RcvdCheck = 0;&#xA;        }&#xA;&#xA;        if(RcvdConf == 1)&#xA;        {&#xA;            if(data == '\n'){RcvdEnd++;}&#xA;            if(RcvdEnd == 3){RcvdEnd = 0;}&#xA;            RcvdMsg[index] = data;&#xA;&#xA;            index++;&#xA;            if(RcvdEnd == 2){RcvdConf = 0;MsgLength = index-2;index = 0;}&#xA;            if(RcvdConf == 0)&#xA;            {&#xA;                Serial.print(&quot;Mobile Number is: &quot;);&#xA;                for(int x = 4;x &amp;lt; 17;x++)&#xA;                {&#xA;                    MsgMob[x-4] = RcvdMsg[x];&#xA;                    Serial.print(MsgMob[x-4]);&#xA;                }&#xA;                Serial.println();&#xA;                Serial.print(&quot;Message Text: &quot;);&#xA;                for(int x = 46; x &amp;lt; MsgLength; x++)&#xA;                {&#xA;                    MsgTxt[x-46] = RcvdMsg[x];&#xA;                    Serial.print(MsgTxt[x-46]);&#xA;                }&#xA;&#xA;                Serial.println();&#xA;                Serial.flush();&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem of the code is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After receiving first SMS I am getting my mobile number and message body. After that I am only getting the sender number printed to my serial monitor but not the message body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where has it gone wrong. I could not understood.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me.......Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11518" LastEditorUserId="11518" LastEditDate="2015-08-01T12:53:59.890" LastActivityDate="2020-09-27T11:32:32.053" Title="Why I could not read the other sms's except the first SMS?" Tags="|arduino-uno|programming|gsm|debugging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13809" PostTypeId="2" ParentId="12540" CreationDate="2015-07-30T14:27:48.393" Score="0" Body="&lt;p&gt;Yes, I just had this problem myself..&#xA;Unless you use the Boards Manager Menu and install the Arduino SAM Boards (32Bits ARM cortex M3) board info you will not be able to upload your sketch.&#xA;After installing in the Boards Manager you will see the Arduio Due programming port and Arduino Native port as an extra options at the bottom or the TOOLS&gt;BOARD menu.&#xA;That should fix the problem.(Check which you are connected to and which COM port)&#xA;If you still have trouble, disconnect and reconnect the DUE and restart the IDE and if required restart you computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be a common problem when people switch from the Uno or MEGA to the Due. I'm surprised this is not installed as standard in the IDE. I am using 1.6.5r2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks also to Ignacio Vazquez-Abrams.&lt;/p&gt;&#xA;" OwnerUserId="11520" LastEditorUserId="10003" LastEditDate="2015-07-31T21:22:54.397" LastActivityDate="2015-07-31T21:22:54.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13810" PostTypeId="2" ParentId="13798" CreationDate="2015-07-30T14:41:35.693" Score="0" Body="&lt;p&gt;Pin 11 is used for SPI to communicate with the Ethernet Shield. And pin 10 is used for the ChipSelect.&#xA; So using the ethernet shield will toggle those pins, making the motor shake around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using pins 6, 7, 8, and 9 instead.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-07-30T14:41:35.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13811" PostTypeId="1" CreationDate="2015-07-30T16:13:24.343" Score="2" ViewCount="136" Body="&lt;p&gt;I am using the &lt;a href=&quot;http://www.trossenrobotics.com/p/arbotix-robot-controller.aspx&quot; rel=&quot;nofollow&quot;&gt;Arbotix-M&lt;/a&gt; (Atmega644p). I am trying to program it using an &lt;a href=&quot;http://www.trossenrobotics.com/p/USB-AVR-Programmer.aspx&quot; rel=&quot;nofollow&quot;&gt;ISP from Pololu&lt;/a&gt;. Until yesterday, everything seemed to be working okay and we were able to upload to it without problems. However, recently our board intermittently returns the error.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;avrdude: stk_500() initialization failed, rc =-1,&lt;br&gt;&#xA;    Double check connections and try again or use -F to override this check&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most of the other people who get this error appear to have damaged the microcontroller in some way, but our board appears to still be functioning because it can still run the code that is already installed on it. At the moment, it basically always fails to upload, so we aren't able to change the code on the board very easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked the voltage outputs from the device and they seem to be right. (12.5 from the main line and 5V from the auxiliary one). I don't have an oscilloscope to check the signals with, but it seems to be able to output commands fine. Thanks for reading.&lt;/p&gt;&#xA;" OwnerUserId="11189" LastActivityDate="2015-07-30T16:13:24.343" Title="Can't program Atmega644p over ISP" Tags="|arduino-ide|avrdude|isp|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13812" PostTypeId="2" ParentId="13692" CreationDate="2015-07-30T16:22:45.553" Score="1" Body="&lt;p&gt;There seem to be two issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Getting the IDE to fully function when launched from the command&#xA;line, and;&lt;/li&gt;&#xA;&lt;li&gt;Getting the IDE to fully function (i.e. compile) when launched from&#xA;the Fedora GUI menu.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have found a solution if I run the Arduino IDE from the command line, by adding the path to  one of the &lt;code&gt;cc1plus&lt;/code&gt; binaries to the &lt;code&gt;PATH&lt;/code&gt; environment variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[piebody@berrybody ~]$ PATH=${PATH}:/usr/libexec/gcc/avr/4.9.2&#xA;[piebody@berrybody ~]$ export PATH&#xA;[piebody@berrybody ~]$ arduino&amp;amp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I launch the Arduino IDE from the Fedora application menu, and then try to compile a sketch, it still can't locate &lt;code&gt;cc1plus&lt;/code&gt;. Maybe the &lt;code&gt;PATH&lt;/code&gt; needs to be added in my &lt;code&gt;.profile&lt;/code&gt;, or some other mechanism, to get an application launched from the Fedora menu to see the path?&lt;sup&gt;1&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, even with the command line launch, it still does not finish compiling.  I now get the following error when the IDE attempts to compile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from Blink.ino:18:0:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:23:20: fatal error: stdlib.h: No such file or directory&#xA; #include &amp;lt;stdlib.h&amp;gt;&#xA;                    ^&#xA;compilation terminated.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In verbose mode&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.0.6 (Linux), Board: &quot;Arduino Uno&quot;&#xA;avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /tmp/build1210300884764677972.tmp/Blink.cpp -o /tmp/build1210300884764677972.tmp/Blink.cpp.o &#xA;In file included from Blink.ino:18:0:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:23:20: fatal error: stdlib.h: No such file or directory&#xA; #include &amp;lt;stdlib.h&amp;gt;&#xA;                    ^&#xA;compilation terminated.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume that this is another &lt;code&gt;PATH&lt;/code&gt; issue. One that relates to the path to the Arduino libraries, or &lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=441404&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;libc&lt;/code&gt;&lt;/a&gt; libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=48232.0&quot; rel=&quot;nofollow&quot;&gt;can't locate avr libraries&lt;/a&gt;&lt;sup&gt;2&lt;/sup&gt;, I can't see why &lt;code&gt;avr-g++&lt;/code&gt; is not picking up the &lt;code&gt;avr&lt;/code&gt; directory in the &lt;code&gt;/usr&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual path to &lt;code&gt;stdlib.h&lt;/code&gt; is &lt;code&gt;/usr/avr/include/stdlib.h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of &lt;code&gt;avr-gcc&lt;/code&gt; (and &lt;code&gt;avr-g++&lt;/code&gt;) shows &lt;code&gt;--prefix=/usr&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE preference file (&lt;code&gt;~/.arduino/preference.txt&lt;/code&gt;) shows the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;last.ide.1.0.6.hardwarepath=/usr/share/arduino/hardware&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Linking the includes&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I manually link some header files to where the compiler actually is looking, then it works (until &lt;code&gt;avr-gcc&lt;/code&gt; needs a header that I have not linked to):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /usr/share/arduino/hardware/arduino/cores/arduino&#xA;sudo ln -s /usr/avr/include/stdlib.h stdlib.h&#xA;sudo ln -s /usr/avr/include/string.h string.h&#xA;sudo ln -s /usr/avr/include/math.h math.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I can not do this for &lt;em&gt;every&lt;/em&gt; header file, it is ridiculous. There must be a way of linking to &lt;code&gt;/usr/avr&lt;/code&gt; from &lt;code&gt;/usr/share/arduino/hardware/arduino/cores/arduino&lt;/code&gt;. I have tried linking the parent directories &lt;code&gt;/usr/avr&lt;/code&gt; and &lt;code&gt;/usr/avr/include&lt;/code&gt;, at various points along the directory hierarchy of &lt;code&gt;/usr/share/arduino/hardware/arduino/cores/arduino&lt;/code&gt;, but none of those seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Copying the include directory&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading &lt;a href=&quot;http://www.avrfreaks.net/forum/default-include-file-path&quot; rel=&quot;nofollow&quot;&gt;default include file path?&lt;/a&gt;, and running &lt;code&gt;avr-cpp -v&lt;/code&gt; I saw that the default &lt;code&gt;#include&lt;/code&gt; search path was &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;...&amp;gt; search starts here:&#xA; /bin/../lib/gcc/avr/4.9.2/include&#xA; /bin/../lib/gcc/avr/4.9.2/include-fixed&#xA;End of search list.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this, I could see that &lt;code&gt;avr-cpp&lt;/code&gt; was searching in &lt;code&gt;/lib/gcc/avr/4.9.2/include&lt;/code&gt;. I examined, and compared, the contents of &lt;code&gt;/lib/gcc/avr/4.9.2/include&lt;/code&gt; with &lt;code&gt;/usr/avr/include&lt;/code&gt; and they held similar (the same) files, except &lt;code&gt;/lib/gcc/avr/4.9.2/include&lt;/code&gt; was a subset, that is to say that it was missing the required files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ended up copying the &lt;code&gt;/usr/avr/include&lt;/code&gt; directory, which contains the required header files (&lt;code&gt;stdlid.h&lt;/code&gt; etc., to which I had linked previously), and replacing the original &lt;code&gt;include&lt;/code&gt; directory, in the directory where &lt;code&gt;avr-gcc&lt;/code&gt; seemed to be looking, which was in its own directory location &lt;code&gt;/lib/gcc/avr/4.9.2/&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd /lib/gcc/avr/4.9.2/&#xA;mv include include.old&#xA;cp -r /usr/avr/include .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the Arduino compiler seemed to work, until it then gave an assembler error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Assembler messages&#xA;Error: unrecognized option -mmcu=avr5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is an issue with &lt;code&gt;avr-as&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will update as I resolve these issues.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; I eventually resolved this by creating a script in &lt;code&gt;/usr/bin&lt;/code&gt; (where the &lt;code&gt;arduino&lt;/code&gt; binary was located) called &lt;code&gt;arduino.launch&lt;/code&gt; which contains the &lt;code&gt;PATH&lt;/code&gt; settings and a call to &lt;code&gt;arduino&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/sh&#xA;PATH=${PATH}:/usr/libexec/gcc/avr/4.9.2&#xA;export PATH&#xA;arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;setting it to be executable with &lt;code&gt;chmod +x arduino.launch&lt;/code&gt;. Then I edited the properties of the Fedora Arduino launch icon, by right-clicking on the icon and selecting &lt;strong&gt;Properties&lt;/strong&gt;, and changed the &lt;strong&gt;Command&lt;/strong&gt; entry from &lt;code&gt;arduino&lt;/code&gt; to &lt;code&gt;arduino.launch&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there must be a better way of doing this, as this seems to be a bit of a hack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;2&lt;/sup&gt; Other posts &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=49652.0&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=86852.0&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt; and &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=52129.0&quot; rel=&quot;nofollow&quot;&gt;3&lt;/a&gt;) that I have read, apart from providing useful paths to investigate, merely suggest reinstalling. However, as bone headed as I may seem, there must be a way of linking up what is already on the file system (everything is there - just in the &quot;wrong&quot; place), such that compiles work as they should.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2016-05-03T06:02:34.123" LastActivityDate="2016-05-03T06:02:34.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13813" PostTypeId="1" CreationDate="2015-07-30T07:00:26.830" Score="2" ViewCount="8581" Body="&lt;p&gt;I have an Arduino Nano and I’m trying to use it with Mac OS Yosemite (10.10). However, I’m having issues with the data transfer between the computer and the device. The Arduino is powered (LED is illuminated), however, I can’t upload anything to it. The serial port is not recognised and after installing a multitude of drivers, nothing seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a specific driver or process I need to follow to enable data transfer?&lt;/p&gt;&#xA;" OwnerUserId="11537" OwnerDisplayName="Rohan" LastEditorUserId="4628" LastEditDate="2017-01-10T06:35:25.413" LastActivityDate="2017-01-10T06:35:25.413" Title="Arduino Nano with Mac OS Yosemite 10.10" Tags="|arduino-nano|osx|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13815" PostTypeId="2" ParentId="13806" CreationDate="2015-07-30T16:49:21.377" Score="0" Body="&lt;p&gt;Any style recommendation is going to be a bit subjective and conditional, but the biggest problem I see here is that the function can only be running one set of variables at a time. What if you wanted to do two of the task your &lt;code&gt;ProgFormula&lt;/code&gt; function is a part of simultaneously? You have no way to switch the state of those variables between calls. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could make a struct to store the state that your function modifies, that way the calling code could swap out the state between calls. Or you could wrap it in a class so the calling code can make as many instances as it needs and not worry about the data each owns. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, &lt;a href=&quot;http://c2.com/cgi/wiki?PrematureOptimization&quot; rel=&quot;nofollow&quot;&gt;Premature optimization is the root of all evil&lt;/a&gt;. The state you are storing is built with a few subtractions and divisions, but the &lt;code&gt;pow&lt;/code&gt; function your loop sometimes calls may be the part dominating its running time.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-07-30T16:49:21.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13816" PostTypeId="1" AcceptedAnswerId="13817" CreationDate="2015-07-30T21:39:27.383" Score="0" ViewCount="1384" Body="&lt;p&gt;I've got &lt;a href=&quot;https://www.dropbox.com/s/3cp4am1f271odcm/max7456.tar?dl=0&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt; for communicating with the &lt;a href=&quot;https://www.sparkfun.com/datasheets/BreakoutBoards/MAX7456.pdf&quot; rel=&quot;nofollow&quot;&gt;MAX7456 chip&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library is abandoned and the only one I found that actually works, so I'd really like to use it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It compiles fine with Arduino IDE 1.0.5, but not with Arduino IDE 1.6.6 .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens with 1.6.6, I tried to fix it but I only made it worse.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.6 Hourly Build 2015/07/03 10:26 (Linux), Board: &quot;Arduino Nano, ATmega328&quot;&#xA;&#xA;Using library SPI at version 1.0.0 in folder: /home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/libraries/SPI &#xA;Using library max7456 in folder: /home/t/Dropbox/Arduino/libraries/max7456 (legacy)&#xA;&#xA;/home/t/Dropbox/Arduino-IDE/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/cores/arduino -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/variants/eightanaloginputs -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/libraries/SPI -I/home/t/Dropbox/Arduino/libraries/max7456 /tmp/build4912026784583215357.tmp/sketch/HelloWorld.cpp -o /tmp/build4912026784583215357.tmp/sketch/HelloWorld.cpp.o &#xA;In file included from HelloWorld.ino:2:0:&#xA;/home/t/Dropbox/Arduino/libraries/max7456/max7456.h:228:40: error: 'prog_uchar' does not name a type&#xA;static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c);&#xA;                                    ^&#xA;/home/t/Dropbox/Arduino/libraries/max7456/max7456.h:228:52: error: ISO C++ forbids declaration of 'table' with no type [-fpermissive]&#xA;static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c);&#xA;                                                ^&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How would one make the library compatible with 1.6.6?&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-13T20:53:58.953" LastActivityDate="2015-08-13T20:53:58.953" Title="Updating MAX7456 library to work with Arduino 1.6.6" Tags="|library|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13817" PostTypeId="2" ParentId="13816" CreationDate="2015-07-30T21:52:15.560" Score="5" Body="&#xA;&#xA;&lt;p&gt;In the file max7456.h at line 228 change it from:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;static void getCARACFromProgMem(const char *table, byte i,charact c);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the file max7456.cpp at line 484 change it from:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void Max7456::getCARACFromProgMem(const prog_uchar *table, byte i, charact car)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void Max7456::getCARACFromProgMem(const char *table, byte i, charact car)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Then it compiles OK (under 1.6.4 at least).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-31T00:14:42.140" LastActivityDate="2015-07-31T00:14:42.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13818" PostTypeId="1" AcceptedAnswerId="13820" CreationDate="2015-07-30T23:41:49.640" Score="0" ViewCount="3069" Body="&lt;p&gt;I have a Funduino joystick shield and it features a 4 pin bluetooth socket in the top right hand corner (just above the &lt;code&gt;D&lt;/code&gt;, &lt;code&gt;T&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;+&lt;/code&gt; legends).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WTA15.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WTA15.jpg&quot; alt=&quot;Joystick Shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, on eBay, 6 pin bluetooth modules are cheaper and more common than 4 pin bluetooth modules. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rjTEf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rjTEf.jpg&quot; alt=&quot;Bluetooth Module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The joystick shield's 4 pin socket is labelled &lt;code&gt;R T - +&lt;/code&gt;. Obviously these correspond with &lt;code&gt;RXD&lt;/code&gt;, &lt;code&gt;TXD&lt;/code&gt;, &lt;code&gt;GND&lt;/code&gt; and &lt;code&gt;VCC&lt;/code&gt; on the bluetooth module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the difference between the 4 pin and 6 pin modules?&lt;/li&gt;&#xA;&lt;li&gt;Can I use a 6 pin module in the four pin socket on the joystick shield?&lt;/li&gt;&#xA;&lt;li&gt;What is the function of additional &lt;code&gt;STATE&lt;/code&gt; and &lt;code&gt;EN&lt;/code&gt; pins on the bluetooth module?&lt;/li&gt;&#xA;&lt;li&gt;Are these two additional pins necessary as other modules do not have them? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-11-13T07:09:02.050" LastActivityDate="2015-11-13T07:09:02.050" Title="Can I use a 6 pin Bluetooth module in a 4 pin socket?" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13819" PostTypeId="2" ParentId="13818" CreationDate="2015-07-31T00:04:35.797" Score="4" Body="&lt;p&gt;After some more concerted searching I have found the answer on &lt;a href=&quot;http://www.instructables.com/id/Success-Using-the-JY-MCU-linvor-Bluetooth-Module/&quot; rel=&quot;nofollow&quot;&gt;Success Using the JY-MCU (linvor) Bluetooth Module&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The module has 6 pins labeled on the back, but most modules only have&#xA;  4 of those populated with pogo pins.  KEY &amp;amp; STATE seem to be not&#xA;  required, as KEY is used for flashing the device and STATE simply&#xA;  indicates if the device is awake or not.  So that leaves only GND,&#xA;  VCC, TXD, RXD.  Not shown is Pin 11 which is the RESET pin, resetting&#xA;  the module when pulled LOW.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, the answer is apparently yes, and you can buy a cheaper 6 pin module and remove (snip/desolder) the two additional pins.  The &lt;code&gt;EN&lt;/code&gt; pin is also apparently labelled as &lt;code&gt;KEY&lt;/code&gt; on some modules.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastActivityDate="2015-07-31T00:04:35.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13820" PostTypeId="2" ParentId="13818" CreationDate="2015-07-31T00:06:10.440" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;What is the difference between the 4 pin and 6 pin modules?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The 6-pin modules have more pins, used for other features.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Can I use a 6 pin module in the four pin socket on the joystick shield?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't see why not, as long as you tie/float the other pins appropriately.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;What is the function of additional STATE and EN pins on the bluetooth module?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Whatever the documentation says they do.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;4&quot;&gt;&#xA;  &lt;li&gt;Are these two additional pins necessary as other modules do not have them?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably not. But they provide additional functionality.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-31T00:06:10.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13821" PostTypeId="2" ParentId="13806" CreationDate="2015-07-31T02:54:47.040" Score="2" Body="&lt;p&gt;I made up a test by adding enough to the posted code to get it to compile:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;float ActualPosition, SetPosition, Velocity;&#xA;&#xA;int Iteration;&#xA;&#xA;int ProgFormula() {&#xA;&#xA;  static int StartPosition;&#xA;  static int DeltaPosition;&#xA;  static int LoopTime = 5;&#xA;  static int AccelerationLoops;&#xA;  static int TotalLoops;&#xA;  static int EndOne;&#xA;&#xA;  static float VelocityLoop;&#xA;  static float VelocityFactor;&#xA;&#xA;  int Setpoint;&#xA;&#xA;  if (Iteration == -1) {&#xA;    StartPosition = ActualPosition;&#xA;    DeltaPosition = abs(SetPosition - StartPosition);&#xA;    VelocityLoop = Velocity / (1000 / LoopTime);&#xA;    TotalLoops = DeltaPosition / VelocityLoop;&#xA;    if (TotalLoops &amp;lt;= (AccelerationLoops * 2)) {&#xA;      AccelerationLoops = (TotalLoops / 2);&#xA;      VelocityFactor = (VelocityLoop * 0.5 / AccelerationLoops) / 2;&#xA;    }&#xA;    else {&#xA;      AccelerationLoops = 70;&#xA;&#xA;      VelocityFactor = VelocityLoop * 0.5 / AccelerationLoops;&#xA;    }&#xA;    TotalLoops = DeltaPosition / VelocityLoop + AccelerationLoops;&#xA;    EndOne = (VelocityFactor * pow(AccelerationLoops, 2));&#xA;  }&#xA;  else if (Iteration &amp;gt;= 0 &amp;amp;&amp;amp; Iteration &amp;lt;= AccelerationLoops) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = VelocityFactor * pow(Iteration, 2) + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = -VelocityFactor * pow(Iteration, 2) + StartPosition;&#xA;    }&#xA;  }&#xA;  else if (Iteration &amp;gt; AccelerationLoops &amp;amp;&amp;amp; Iteration &amp;lt;= (TotalLoops - AccelerationLoops)) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = VelocityLoop * Iteration - EndOne + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = -VelocityLoop * Iteration + EndOne + StartPosition;&#xA;    }&#xA;  }&#xA;  else if (Iteration &amp;gt;= (TotalLoops - AccelerationLoops) &amp;amp;&amp;amp; Iteration &amp;lt;= TotalLoops) {&#xA;    if (StartPosition &amp;lt; SetPosition) {&#xA;      Setpoint = -VelocityFactor * pow((TotalLoops - Iteration), 2) + DeltaPosition + StartPosition;&#xA;    }&#xA;    else {&#xA;      Setpoint = VelocityFactor * pow((TotalLoops - Iteration), 2) - DeltaPosition + StartPosition;&#xA;    }&#xA;  }&#xA;  else {&#xA;    Setpoint = Setpoint;&#xA;  }&#xA;  return(Setpoint);&#xA;}&#xA;&#xA;void setup ()&#xA;  {&#xA;   ProgFormula ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Disassembling this I got the following assembler:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;000000a8 &amp;lt;_Z11ProgFormulav&amp;gt;:&#xA;  a8:   6f 92           push    r6&#xA;  aa:   7f 92           push    r7&#xA;  ac:   8f 92           push    r8&#xA;  ae:   9f 92           push    r9&#xA;  b0:   af 92           push    r10&#xA;  b2:   bf 92           push    r11&#xA;  b4:   cf 92           push    r12&#xA;  b6:   df 92           push    r13&#xA;  b8:   ef 92           push    r14&#xA;  ba:   ff 92           push    r15&#xA;  bc:   0f 93           push    r16&#xA;  be:   1f 93           push    r17&#xA;  c0:   cf 93           push    r28&#xA;  c2:   df 93           push    r29&#xA;  c4:   00 91 0c 01     lds r16, 0x010C&#xA;  c8:   10 91 0d 01     lds r17, 0x010D&#xA;  cc:   8f ef           ldi r24, 0xFF   ; 255&#xA;  ce:   0f 3f           cpi r16, 0xFF   ; 255&#xA;  d0:   18 07           cpc r17, r24&#xA;...&#xA; 4ec:   cb 01           movw    r24, r22&#xA; 4ee:   df 91           pop r29&#xA; 4f0:   cf 91           pop r28&#xA; 4f2:   1f 91           pop r17&#xA; 4f4:   0f 91           pop r16&#xA; 4f6:   ff 90           pop r15&#xA; 4f8:   ef 90           pop r14&#xA; 4fa:   df 90           pop r13&#xA; 4fc:   cf 90           pop r12&#xA; 4fe:   bf 90           pop r11&#xA; 500:   af 90           pop r10&#xA; 502:   9f 90           pop r9&#xA; 504:   8f 90           pop r8&#xA; 506:   7f 90           pop r7&#xA; 508:   6f 90           pop r6&#xA; 50a:   08 95           ret&#xA;&#xA;0000050c &amp;lt;setup&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that function (ProgFormula) has taken up:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;0x50a - 0xa8 = 1122 bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now by removing the &quot;static&quot; declarations, like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   int StartPosition;&#xA;   int DeltaPosition;&#xA;   int LoopTime = 5;&#xA;   int AccelerationLoops;&#xA;   int TotalLoops;&#xA;   int EndOne;&#xA;&#xA;   float VelocityLoop;&#xA;   float VelocityFactor;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It now compiles to:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;000000a8 &amp;lt;_Z11ProgFormulav&amp;gt;:&#xA;  a8:   6f 92           push    r6&#xA;  aa:   7f 92           push    r7&#xA;  ac:   8f 92           push    r8&#xA;  ae:   9f 92           push    r9&#xA;  b0:   af 92           push    r10&#xA;  b2:   bf 92           push    r11&#xA;  b4:   cf 92           push    r12&#xA;  b6:   df 92           push    r13&#xA;  b8:   ef 92           push    r14&#xA;  ba:   ff 92           push    r15&#xA;  bc:   0f 93           push    r16&#xA;  be:   1f 93           push    r17&#xA;  c0:   cf 93           push    r28&#xA;  c2:   df 93           push    r29&#xA;  c4:   c0 91 04 01     lds r28, 0x0104&#xA;  c8:   d0 91 05 01     lds r29, 0x0105&#xA;  cc:   8f ef           ldi r24, 0xFF   ; 255&#xA;  ce:   cf 3f           cpi r28, 0xFF   ; 255&#xA;  d0:   d8 07           cpc r29, r24&#xA;...&#xA; 27e:   cb 01           movw    r24, r22&#xA; 280:   df 91           pop r29&#xA; 282:   cf 91           pop r28&#xA; 284:   1f 91           pop r17&#xA; 286:   0f 91           pop r16&#xA; 288:   ff 90           pop r15&#xA; 28a:   ef 90           pop r14&#xA; 28c:   df 90           pop r13&#xA; 28e:   cf 90           pop r12&#xA; 290:   bf 90           pop r11&#xA; 292:   af 90           pop r10&#xA; 294:   9f 90           pop r9&#xA; 296:   8f 90           pop r8&#xA; 298:   7f 90           pop r7&#xA; 29a:   6f 90           pop r6&#xA; 29c:   08 95           ret&#xA;&#xA;0000029e &amp;lt;setup&amp;gt;:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is now:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;0x29e - 0xa8 = 502 bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Adding &quot;static&quot; has made the function over &lt;strong&gt;twice as long&lt;/strong&gt;. Presumably it is also slower. After all, those extra instructions have be doing &lt;em&gt;something&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;to increase the speed I added some static variables to it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your belief that making variables static increases the speed does not seem to be supported.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-07-31T02:54:47.040" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="13822" PostTypeId="1" AcceptedAnswerId="13867" CreationDate="2015-07-31T03:07:59.463" Score="0" ViewCount="391" Body="&lt;p&gt;Does anyone know of a way to DIY a digital camera by buying a sensor and lens and processing the image using an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="11531" LastActivityDate="2016-06-13T14:37:37.433" Title="Building a digital camera?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13823" PostTypeId="1" CreationDate="2015-07-31T03:52:28.537" Score="-1" ViewCount="778" Body="&lt;p&gt;I am trying to send an integer value from Python to Arduino. The integer value is a position given by a webcam, which will determine how many turns a stepper motor moves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;AccelStepper stepper(AccelStepper::DRIVER,8,9); &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  stepper.setMaxSpeed(1000.0);&#xA;  stepper.setAcceleration(700.0);&#xA;}&#xA;&#xA;void loop() {&#xA;  int val = 0;&#xA;  if(Serial.available()){&#xA;    val = map(Serial.parseInt(), 0, 1280, 0, 551); &#xA;    Serial.println(val);&#xA;  }&#xA;  stepper.runToNewPosition(val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# source: http://www.steinm.com/blog/motion-detection-webcam-python-opencv-differential-images/&#xA;&#xA;import cv2&#xA;import numpy as np&#xA;import serial&#xA;import time&#xA;&#xA;def diffImg(t0, t1, t2):&#xA;    d1 = cv2.absdiff(t2, t1)&#xA;    d2 = cv2.absdiff(t1, t0)&#xA;    dif = cv2.bitwise_and(d1, d2)&#xA;    return np.fliplr(dif)&#xA;&#xA;cam = cv2.VideoCapture(0)  &#xA;&#xA;#winName = &quot;Movement Indicator&quot; #camera window&#xA;#cv2.namedWindow(winName, cv2.WINDOW_NORMAL)&#xA;&#xA;# Read three images first:&#xA;t_minus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)&#xA;t = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)&#xA;t_plus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)&#xA;&#xA;h, w = t.shape&#xA;&#xA;winTest = &quot;Test Window&quot; #test window&#xA;cv2.namedWindow(winTest, cv2.WINDOW_NORMAL)&#xA;&#xA;thresh = 100&#xA;&#xA;ser=serial.Serial('/dev/cu.usbmodem1411',9600,timeout=0)&#xA;time.sleep(2)&#xA;&#xA;while True:&#xA;&#xA;    img = diffImg(t_minus, t, t_plus)&#xA;&#xA;#    cv2.imshow(winName, img )&#xA;&#xA;    nz = np.transpose(np.nonzero(img&amp;gt;thresh))&#xA;    a = 0&#xA;    b = 0&#xA;    c = 0&#xA;    d = 0&#xA;    avg=0&#xA;    if nz.size&amp;gt;0:&#xA;        a,b = nz[0]&#xA;        c,d = nz[-1]&#xA;        avg = (b+d)/2&#xA;        if 0&amp;lt;=avg and avg&amp;lt;=1280:&#xA;            print avg&#xA;            ser.write(str(int(avg))+&quot; &quot;) &#xA;&#xA;    test = np.zeros((h,w))&#xA;&#xA;    cv2.rectangle(test, ((avg-5),a), ((avg+5),c), (255), -1)&#xA;    cv2.imshow(winTest, test )&#xA;&#xA;    # Read next image&#xA;    t_minus = t&#xA;    t = t_plus&#xA;    t_plus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)&#xA;    print ser.readline();   &#xA;&#xA;&#xA;    key = cv2.waitKey(10)&#xA;    if key == 27:&#xA;       cv2.destroyWindow(winName)&#xA;       ser.close()&#xA;       break&#xA;&#xA;print &quot;Goodbye&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works OK but occasionally 'val' will take some ridiculous value, say 7182, and the motor spins out of control. I realize I can check values with an if statement before I actually write to the stepper motor, but I think my problem is with reading and writing to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other issue is I feel Arduino is not receiving some of the data sent to it via serial connection. This is hard to say, as Serial.print() is slow and mostly doesn't make it through to my terminal before it's already been rewritten.&lt;/p&gt;&#xA;" OwnerUserId="11532" LastActivityDate="2022-11-27T07:08:56.073" Title="Pyserial and Arduino" Tags="|serial|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13824" PostTypeId="2" ParentId="13813" CreationDate="2015-07-31T06:00:01.497" Score="3" Body="&lt;p&gt;Setting kext-dev-mode=1 allows unsigned kernel extensions to load, which is not recommended, as it lowers OS X security.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, try the signed 64-bit kernel extension from FTDI here: &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.ftdichip.com/Drivers/VCP.htm&lt;/a&gt; , version 2.3, which does require changing OS security permissions.&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2015-07-31T06:00:01.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13825" PostTypeId="2" ParentId="12133" CreationDate="2015-07-31T06:14:42.600" Score="5" Body="&lt;p&gt;Yosemite 10.9 (and OS X 10.10 and newer) requires a signed USB driver kext (kernel extension).  You can find one on the FTDI web site here: &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;noreferrer&quot;&gt;http://www.ftdichip.com/Drivers/VCP.htm&lt;/a&gt;&lt;br&gt;&#xA;Use version 2.3 for 64-bit OS X 10.9 or later.  Install and reboot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plug in your Arduino, and the Terminal command:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/usr/sbin/kextstat | grep FTDI&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;will tell you if the FTDI VCP driver actually loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a /dev/tty.usbserial-xxxxxxxx entry should appear in your /dev directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, the Mac USB port isn't talking to your Arduino.  So it's no use trying the Arduino IDE application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure your USB cable isn't for power only, but fully connected.&lt;/p&gt;&#xA;" OwnerUserId="651" LastActivityDate="2015-07-31T06:14:42.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13826" PostTypeId="1" CreationDate="2015-07-31T08:24:45.443" Score="0" ViewCount="5901" Body="&lt;p&gt;I have connected a RN-42 bluetooth (TX-D0, RX-D1, VCC-5V, GND_GND) to arduino.The problem is that when I run this code ,nothing happens it just upload to infinite or it doesn't. I am checking with tera term. Is there a problem with the connection of the pins? Also when I pair my android phone to the bluetooth it says paired on the phone but the blue light of the bluetooth doesn't switch on, like it's not connected.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  #include &amp;lt;SoftwareSerial.h&amp;gt;// import the serial library&#xA;   SoftwareSerial Genotronex(1, 0); // TX,RX&#xA;   int ledpin=13; // led on D13 will show blink on / off&#xA;   int BluetoothData; // the data given from Computer&#xA;&#xA;  void setup() {&#xA;  // put your setup code here, to run once:&#xA;   Genotronex.begin(9600);&#xA;   Genotronex.println(&quot;Bluetooth On please press 1 or 0 blink LED ..&quot;);&#xA;   pinMode(ledpin,OUTPUT);&#xA;  }&#xA;&#xA;  void loop() {&#xA;    // put your main code here, to run repeatedly:&#xA;  if (Genotronex.available()){&#xA;     BluetoothData=Genotronex.read();&#xA;   if(BluetoothData=='1'){   // if number 1 pressed ....&#xA;  digitalWrite(ledpin,1);&#xA;  Genotronex.println(&quot;LED  On D13 ON ! &quot;);&#xA;   }&#xA;  if (BluetoothData=='0'){// if number 0 pressed ....&#xA;   digitalWrite(ledpin,0);&#xA;   Genotronex.println(&quot;LED  On D13 Off ! &quot;);&#xA;   }&#xA;}&#xA;   delay(100);// prepare for next data ...&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="4131" LastEditDate="2015-07-31T09:34:13.220" LastActivityDate="2016-01-27T20:57:50.760" Title="Bluetooth connection and RX ,TX" Tags="|arduino-uno|bluetooth|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13827" PostTypeId="1" AcceptedAnswerId="13829" CreationDate="2015-07-31T09:38:00.020" Score="0" ViewCount="1935" Body="&lt;p&gt;I am trying to build a shield for an arduino mega.For that i need to know the type of the female connectors that are soldered in the pins of the arduino mega in order to choose the correct male connectors.&lt;/p&gt;&#xA;" OwnerUserId="7328" LastActivityDate="2015-07-31T13:57:48.397" Title="What are the connectors used in the arduino mega?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13829" PostTypeId="2" ParentId="13827" CreationDate="2015-07-31T13:26:55.740" Score="0" Body="&lt;p&gt;Look for male pin header strip, with 0.1 inch (2.54mm) pitch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In single and dual row form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically they are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;8x1 ADCL&lt;/li&gt;&#xA;&lt;li&gt;8x1 ADCH&lt;/li&gt;&#xA;&lt;li&gt;8x1 PWML       &lt;/li&gt;&#xA;&lt;li&gt;8x1 PWMH        &lt;/li&gt;&#xA;&lt;li&gt;8x1 Communication&lt;/li&gt;&#xA;&lt;li&gt;6x1 Power&lt;/li&gt;&#xA;&lt;li&gt;18x2   digital IO (on the side)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-mega-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Schematics&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11282" LastEditorUserId="11282" LastEditDate="2015-07-31T13:57:48.397" LastActivityDate="2015-07-31T13:57:48.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13830" PostTypeId="1" CreationDate="2015-07-31T13:34:00.060" Score="5" ViewCount="4035" Body="&lt;p&gt;I have a project where I need to have several IMUs, the BNO055 shuttle board (I explained my project &lt;a href=&quot;https://arduino.stackexchange.com/questions/13756/arduino-due-and-bno055&quot;&gt;here&lt;/a&gt;), I manage to get the Euler angles from one BNO055 sensor, which have the address 0x29, because I linked the I2C_MODE_ADR_SEL to a HIGH level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have another sensor with the address 0x28. As the datasheet says, I must link the I2C_MODE_ADR_SEL to a LOW level (to the GND) the i2c Scanner from the Arduino Playground does not recognize any i2c device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to change my sensor address, can anyone help me with this issue ?&lt;/p&gt;&#xA;" OwnerUserId="11477" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2017-05-14T19:58:24.617" Title="Arduino Due and BNO055 address in i2c mode" Tags="|sensors|arduino-due|i2c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13832" PostTypeId="1" CreationDate="2015-07-31T14:57:43.227" Score="2" ViewCount="279" Body="&lt;p&gt;I'm new to arduino and I'm trying to upload a fairly large (I think) program to a arduino yun which includes a 3 dimensional array. I'm using the bridge features of the yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I upload the first time after unplugging and plugging back in again it runs fine. When I try and upload a second time I get the following error regardless of which code I'm trying to upload (blink example for example)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; avrdude: verification error, first mismatch at byte 0x0000&#xA; 0xff != 0x0c avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the serial monitor I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Unable to connect: retrying (1)... &#xA;Unable to connect: retrying (2)... &#xA;Unable to connect: retrying (3)... &#xA;Unable to connect: retrying (4)... &#xA;Unable to connect: is the sketch using the bridge?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm currently developing as much as I can in another sketch but it's a pain.&#xA;I can provide the code if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help&lt;/p&gt;&#xA;" OwnerUserId="11539" LastActivityDate="2015-07-31T14:57:43.227" Title="Arduino yun strange uploading error" Tags="|arduino-yun|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13833" PostTypeId="2" ParentId="13830" CreationDate="2015-07-31T15:25:33.620" Score="1" Body="&lt;p&gt;According to Table 4-7 on page 90 of the &lt;a href=&quot;http://www.adafruit.com/datasheets/BST_BNO055_DS000_12.pdf&quot; rel=&quot;nofollow&quot;&gt;BNO055 datasheet at adafruit.com&lt;/a&gt;, the BNO055 supports three I2C addresses: 0x28 or 0x29 in slave mode (selected by COM3 being low or high, respectively), or 0x40 in the HID-I2C configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the diagram on page 2 in file &lt;a href=&quot;http://ae-bst.resource.bosch.com/media/products/shuttleboards/BNO055_Shuttleboard_Flyer.pdf&quot; rel=&quot;nofollow&quot;&gt;BNO055_Shuttleboard_Flyer.pdf&lt;/a&gt; (Bosch's description of the BNO055 Shuttle Board), COM3 on pin 17 of the BNO055 (or, PSERCOM3) is wired via 0Ω jumper R106 to the middle pin of J102.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you plan to get data from five different BNO055's, you may need to use a multiplexer (or several I/O's) to set COM3 on one BNO055 board to a different level than on the other four, to select one of the five boards for access.  For example, you could use a 7438 (eg, an MM74HC138 or DM74LS138).  When you set the 7438's address input to &lt;code&gt;j&lt;/code&gt;, line Yⱼ (from among Y₀ to Y₇) will go low while the the other Yᵢ remain high.  The BNO055 with COM3 attached to Yⱼ then would be the only BNO055 that would respond to I2C address 0x28.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For testing, you could set up several BNO055's and use several separate I/O lines to control several COM3 inputs.  Using separate I/O lines takes five I/O lines for five COM3's, vs three I/O lines using a 7438 multiplexer; saving two lines might not be worth the extra effort of obtaining and using a multiplexer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to use two more Arduino (eg Pro Mini or Micro) units to support separate I2C busses for additional BNO055's.  These auxiliary Arduinos could do some data reduction before sending data (via serial or I2C) to the principal Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, it is not clear to me that using more than one or two BNO055's makes sense.  If the assemblage of BNO055's moves through space more or less as a unit, but with attitudes, roll rates, etc differing between BNO055's, then 3/4 or so of the data from different BNO055's will be the same.  Possibly less-general sensors (eg, without magnetometer) with different I2C addresses could be used instead.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-07-31T15:40:03.810" LastActivityDate="2015-07-31T15:40:03.810" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13835" PostTypeId="1" AcceptedAnswerId="13836" CreationDate="2015-07-31T18:13:10.073" Score="1" ViewCount="619" Body="&lt;p&gt;just a quick question. I want to know if it is possible to use the TCS3200 color sensor without the 4 LEDs included on the breakout board. I want to get the sky colors. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="11116" LastActivityDate="2015-07-31T18:22:30.293" Title="Use the TCS3200 color sensor without the included LEDs" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13836" PostTypeId="2" ParentId="13835" CreationDate="2015-07-31T18:22:30.293" Score="2" Body="&lt;p&gt;The photodiodes in the device itself have filters so it should &lt;em&gt;theoretically&lt;/em&gt; be possible to use it without auxiliary light sources. Note, however, that the green and blue sensors have &lt;em&gt;two&lt;/em&gt; sensitivity peaks and so using it outdoors without an infrared filter is not advised.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-31T18:22:30.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13837" PostTypeId="2" ParentId="7912" CreationDate="2015-07-31T19:18:07.793" Score="2" Body="&lt;p&gt;If you take a look at the &lt;a href=&quot;https://www.arduino.cc/en/main/standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Standalone Arduino&lt;/a&gt; on the Arduino website, then this is what you require:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EYXT3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EYXT3.jpg&quot; alt=&quot;Standalone Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is one slight error in the guide, which I have highlighted here, &lt;a href=&quot;https://arduino.stackexchange.com/questions/10392/arduino-standalone-photo-shows-incorrect-pin-wired-to-mosi&quot;&gt;Arduino Standalone - photo shows incorrect pin wired to MOSI&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a video on how to achieve, more or less, the same thing, &lt;a href=&quot;https://www.youtube.com/watch?v=sNIMCdVOHOM&quot; rel=&quot;nofollow noreferrer&quot;&gt;1-Day Project: Build Your Own Arduino Uno for $5&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-07-31T19:18:07.793" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13838" PostTypeId="1" AcceptedAnswerId="13846" CreationDate="2015-07-31T19:49:38.873" Score="1" ViewCount="1144" Body="&lt;p&gt;I am trying to build an Arduino Mega shield. For that, I need to know the exact distances between the different connectors.&lt;/p&gt;&#xA;" OwnerUserId="7328" LastEditorUserId="11086" LastEditDate="2015-08-02T10:14:09.410" LastActivityDate="2015-08-02T10:14:09.410" Title="What are the distances between Arduino Mega connectors?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13839" PostTypeId="1" AcceptedAnswerId="13842" CreationDate="2015-07-31T20:24:52.960" Score="-1" ViewCount="7468" Body="&lt;p&gt;I am trying to get a spectrum analyser up and running. I found the following code on &lt;a href=&quot;https://communities.intel.com/docs/DOC-23406&quot; rel=&quot;nofollow&quot;&gt;Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * &#xA; * Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer&#xA; * https://communities.intel.com/docs/DOC-23406&#xA; * &#xA; * &#xA; * ERROR: analogReadResolution() ???&#xA; * &#xA; */&#xA;&#xA;&#xA;&#xA;#include &amp;lt;stdint.h&amp;gt;  //For New Arduino&#xA;#include &quot;PCD8544.h&quot;&#xA;#define pin_adc 0&#xA;#include &quot;fix_fft.h&quot;&#xA;char im[128];&#xA;char data[128];&#xA;int analog_value[128];&#xA;int i=0;&#xA;PCD8544 nokia = PCD8544(3, 4, 5, 7, 6);&#xA;// pin 7 - Serial clock out (SCLK) connects Dig3&#xA;// pin 6 - Serial data out (DIN) connects Dig4&#xA;// pin 5 - Data/Cmd. selct. (D/C) connects Dig5&#xA;// pin 4 - LCD reset (RST) connects Dig6&#xA;// pin 3 - LCD chip select (CS) connects Dig7&#xA;void setup() {&#xA;  nokia.init();&#xA;  nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);&#xA;  nokia.clear();&#xA;  analogReadResolution(8);&#xA;}&#xA;&#xA;void show_big_bars(char *spektrum) {&#xA;    int spek_for_draw;&#xA;    nokia.drawline(10, 15, 10, 39, BLACK);&#xA;    for (byte i = 1; i &amp;lt; 64; i++){ // Skip 0 Channel&#xA;      // Serial.print(spektrum[i],BYTE);&#xA;      spek_for_draw = 1.5*(spektrum[i]); // 0/2.5 ~ 255/2.5&#xA;      if (spek_for_draw &amp;gt; 39) spek_for_draw = 39;&#xA;      nokia.drawline(i+10, 39 - spek_for_draw, i+10, 39, BLACK);&#xA;    }&#xA;    //nokia.drawstring(5, 5, &quot;0 09 22 36 49&quot;);&#xA;    nokia.drawstring(5, 5, &quot;0&quot;);&#xA;    nokia.drawstring(21, 5, &quot;4&quot;);&#xA;    nokia.drawstring(37, 5, &quot;8&quot;);&#xA;    nokia.drawstring(48, 5, &quot;12&quot;);&#xA;    nokia.drawstring(67, 5, &quot;18&quot;);&#xA;    nokia.drawstring(5, 0, &quot;Spectrum&quot;);&#xA;    nokia.drawstring(5, 1,&quot;* 0.1KHz&quot;);&#xA;    nokia.display(); // Update Screen&#xA;    nokia.clear(); // Clear Screen for the animation&#xA;}&#xA;void loop(){&#xA;  static long tt;&#xA;  int val;&#xA;  if (i &amp;lt; 128){&#xA;      analog_value[i] = analogRead(pin_adc);&#xA;      i++;  &#xA;   }&#xA;   else{&#xA;        for (i=0; i&amp;lt; 128;i++){ //Prepare data for FFT&#xA;            data[i] = analog_value[i] - 128;&#xA;            im[i] = 0;&#xA;        }&#xA;   //this could be done with the fix_fftr function without the im array.&#xA;        fix_fft(data,im,7,0);&#xA;   // I am only interessted in the absolute value of the transformation&#xA;        for (i=0; i&amp;lt; 64;i++)&#xA;             data[i] = sqrt(data[i] * data[i] + im[i] * im[i]);&#xA;   //do something with the data values 1..64 and ignore im&#xA;        show_big_bars(data);&#xA;        i=0;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I attempt to compile the above code, I get the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Mac OS X), Board: &quot;Arduino Micro&quot;&#xA;&#xA;fft_galileo.ino: In function 'void setup()':&#xA;fft_galileo:31: error: 'analogReadResolution' was not declared in this scope&#xA;'analogReadResolution' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I search for the location of &lt;code&gt;analogReadResolution()&lt;/code&gt; on Google, I repeatedly get the information that it is only available for the Due and Zero. From &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReadResolution&quot; rel=&quot;nofollow&quot;&gt;Arduino - AnalogReadResolution&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;analogReadResolution() is an extension of the Analog API for the&#xA;  Arduino Due and Zero.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I was wondering if I needed to add an &lt;code&gt;#include&lt;/code&gt; statement but all of the code examples that I found do not have any specific &lt;code&gt;#include&lt;/code&gt; for the Analogue library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, thinking maybe it is board specific (as the video &lt;a href=&quot;https://www.youtube.com/watch?v=C_cQ7vYTnWw&quot; rel=&quot;nofollow&quot;&gt;Arduino Due error: 'analogReadResolution' was not declared in this scope&lt;/a&gt; suggests), I selected the &lt;strong&gt;&lt;em&gt;Duemilanove&lt;/em&gt;&lt;/strong&gt; board (as the &lt;strong&gt;&lt;em&gt;Due&lt;/em&gt;&lt;/strong&gt; is not on offer in my &quot;Board&quot; menu), but I still get the same error. I have even tried the &lt;strong&gt;&lt;em&gt;Arduino NG or older&lt;/em&gt;&lt;/strong&gt; Board menu item, but with the same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I get rid of this compile time error? Or, more poignantly, how can I compile this code for my Uno or Leonardo board.  Should I just comment it out? If I do comment the line out then the code &lt;em&gt;does&lt;/em&gt; compile, so does this mean that &lt;code&gt;analogReadResolution()&lt;/code&gt; is not required any longer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it isn't required, then why does this Uno specific example, &lt;a href=&quot;http://circuitdigest.com/microcontroller-projects/arduino-uno-adc-tutorial&quot; rel=&quot;nofollow&quot;&gt;How to Use ADC in Arduino Uno?&lt;/a&gt;, state:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As default we get the maximum board ADC resolution which is 10bits,&#xA;  this resolution can be changed by using instruction&#xA;  (“analogReadResolution(bits);”). This resolution change can come in&#xA;  handy for some cases.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can the resolution be changed if the method has, indeed, been deprecated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, why do I not have a &quot;Due&quot; in my &lt;strong&gt;Board&lt;/strong&gt; menu?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; For completeness &lt;code&gt;fix_fft.h&lt;/code&gt; and &lt;code&gt;fix_fft.cpp&lt;/code&gt; can be found on &lt;a href=&quot;https://github.com/TJC/arduino/tree/master/sketchbook/libraries/fix_fft&quot; rel=&quot;nofollow&quot;&gt;TJC's github&lt;/a&gt; and here is the &lt;a href=&quot;http://120.107.171.121/~tywua/sub/ISAR/Intel_Nokia5110.rar&quot; rel=&quot;nofollow&quot;&gt;PCD8544 Arduino library for Nokia 5510 LCD&lt;/a&gt; library. The password for decompressing &lt;code&gt;Intel_Nokia5110.rar&lt;/code&gt; file is 406. &lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="10794" LastEditDate="2015-08-26T04:37:19.307" LastActivityDate="2015-08-26T04:37:19.307" Title="Can I use analogReadResolution() on an Uno or Leonardo?" Tags="|arduino-uno|arduino-leonardo|analogread|adc|analogreadresolution|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13840" PostTypeId="5" CreationDate="2015-07-31T20:28:35.563" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogreadresolution&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino - AnalogReadResolution&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;h3&gt;Description&lt;/h3&gt;&#xA;&lt;p&gt;&lt;code&gt;analogReadResolution()&lt;/code&gt; is an extension of the Analog API for the&#xA;Arduino Due and Zero.&lt;/p&gt;&#xA;&lt;p&gt;Sets the size (in bits) of the value returned by analogRead(). It&#xA;defaults to 10 bits (returns values between 0-1023) for backward&#xA;compatibility with AVR based boards.&lt;/p&gt;&#xA;&lt;p&gt;The Due has 12-bit ADC capabilities that can be accessed by changing&#xA;the resolution to 12. This will return values from analogRead()&#xA;between 0 and 4095.&lt;/p&gt;&#xA;&lt;h3&gt;Syntax&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;analogReadResolution(bits)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Parameters&lt;/h3&gt;&#xA;&lt;p&gt;bits: determines the resolution (in bits) of the value returned by&#xA;&lt;code&gt;analogRead()&lt;/code&gt; function. You can set this 1 and 32. You can set&#xA;resolutions higher than 12 but values returned by analogRead() will&#xA;suffer approximation. See the note below for details.&lt;/p&gt;&#xA;&lt;h3&gt;Returns&lt;/h3&gt;&#xA;&lt;p&gt;None.&lt;/p&gt;&#xA;&lt;h3&gt;Note&lt;/h3&gt;&#xA;&lt;p&gt;If you set the &lt;code&gt;analogReadResolution()&lt;/code&gt; value to a value higher than&#xA;your board's capabilities, the Arduino will only report back at its&#xA;highest resolution padding the extra bits with zeros.&lt;/p&gt;&#xA;&lt;p&gt;For example: using the Due with analogReadResolution(16) will give you&#xA;an approximated 16-bit number with the first 12 bits containing the&#xA;real ADC reading and the last 4 bits padded with zeros.&lt;/p&gt;&#xA;&lt;p&gt;If you set the analogReadResolution() value to a value lower than your&#xA;board's capabilities, the extra least significant bits read from the&#xA;ADC will be discarded.&lt;/p&gt;&#xA;&lt;p&gt;Using a 16 bit resolution (or any resolution higher than actual&#xA;hardware capabilities) allows you to write sketches that automatically&#xA;handle devices with a higher resolution ADC when these become&#xA;available on future boards without changing a line of code.&lt;/p&gt;&#xA;&lt;h3&gt;Example&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // open a serial connection&#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop() {&#xA;  // read the input on A0 at default resolution (10 bits)&#xA;  // and send it out the serial connection &#xA;  analogReadResolution(10);&#xA;  Serial.print(&amp;quot;ADC 10-bit (default) : &amp;quot;);&#xA;  Serial.print(analogRead(A0));&#xA;&#xA;  // change the resolution to 12 bits and read A0&#xA;  analogReadResolution(12);&#xA;  Serial.print(&amp;quot;, 12-bit : &amp;quot;);&#xA;  Serial.print(analogRead(A0));&#xA;&#xA;  // change the resolution to 16 bits and read A0&#xA;  analogReadResolution(16);&#xA;  Serial.print(&amp;quot;, 16-bit : &amp;quot;);&#xA;  Serial.print(analogRead(A0));&#xA;&#xA;  // change the resolution to 8 bits and read A0&#xA;  analogReadResolution(8);&#xA;  Serial.print(&amp;quot;, 8-bit : &amp;quot;);&#xA;  Serial.println(analogRead(A0));&#xA;&#xA;  // a little delay to not hog serial monitor&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="27346" LastEditDate="2020-07-12T19:51:22.903" LastActivityDate="2020-07-12T19:51:22.903" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13841" PostTypeId="4" CreationDate="2015-07-31T20:28:35.563" Score="0" Body="analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.&#xD;&#xA;" OwnerUserId="6936" LastEditorUserId="27346" LastEditDate="2020-07-12T19:51:29.013" LastActivityDate="2020-07-12T19:51:29.013" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13842" PostTypeId="2" ParentId="13839" CreationDate="2015-07-31T20:41:37.390" Score="3" Body="&lt;p&gt;There is no point to having &lt;code&gt;analogReadResolution()&lt;/code&gt; on AVR devices since that function &lt;em&gt;only exists&lt;/em&gt; to provide/ensure backwards compatibility with the fixed 10-bit ADC that is found in AVR devices. If you want higher or lower resolution then you will need to perform the appropriate actions manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have a Due entry because you haven't installed Atmel SAM support in the Board Manager.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-07-31T20:41:37.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13843" PostTypeId="2" ParentId="7912" CreationDate="2015-07-31T21:20:17.813" Score="2" Body="&lt;p&gt;I have a page describing &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to make an Arduino-compatible minimal board&lt;/a&gt;. The minimal setup would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4NRfB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4NRfB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That excludes the circuitry for uploading your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, in the image in the question you have an LED with no resistor. That will damage both the LED and the Atmega328. You need a &lt;strong&gt;current-limiting resistor&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;do I still need oscillators&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not if you program the fuse to use the internal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Some have said 5v while some say 6v can someone clarify?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The datasheet says 1.8 to 5.5 V operating range with an &lt;strong&gt;absolute maximum rating&lt;/strong&gt; of 6 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what the datasheet says about absolute maximum ratings:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a stress rating only and functional operation of the device at these&#xA;  or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Page 2 of the datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Operating Voltage:&lt;/li&gt;&#xA;  &lt;li&gt;1.8 - 5.5V&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-07-31T23:07:33.380" LastActivityDate="2015-07-31T23:07:33.380" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13844" PostTypeId="2" ParentId="13778" CreationDate="2015-07-31T21:36:05.200" Score="1" Body="&lt;p&gt;Everything @Greenonline said plus...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 2 Cell Lipo battery is 7.4 V. A modest 500 mAH battery would run your project for several hours, perhaps days. If you're not satisfied with the run time, buy a battery with more mAH, they go well past 5000 mAH! After all, these are the same types of batteries used in all forms of Radio Control Aeromodeling (lots of servos and brushless DC motors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno can regulate the 7.4 V although you'll need to buy/build a cable to connect the battery to the Uno. I'm not sure how much current the Uno regulator can provide but I've driven two micro servos with mine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the servos chatter, hum, are otherwise not working right or if there is smoke coming out of the regulator, you probably need a separate power source for the servos. A BEC like this &lt;a href=&quot;https://en.wikipedia.org/wiki/Battery_eliminator_circuit&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Battery_eliminator_circuit&lt;/a&gt; is an inexpensive alternate and also a common RC part. :)&lt;/p&gt;&#xA;" OwnerUserId="7297" LastEditorUserId="7297" LastEditDate="2015-08-01T23:27:31.137" LastActivityDate="2015-08-01T23:27:31.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13845" PostTypeId="2" ParentId="13839" CreationDate="2015-08-01T00:11:44.607" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, why do I not have a &quot;Due&quot; in my Board menu?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EeYBw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EeYBw.png&quot; alt=&quot;Board manager menu item&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x4WJF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x4WJF.png&quot; alt=&quot;Board manager install&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I selected the Duemilanove board (as the Due is not on offer in my &quot;Board&quot; menu) ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Duemilanove and the Due are completely different boards, with different processors.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-01T00:11:44.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13846" PostTypeId="2" ParentId="13838" CreationDate="2015-08-01T01:06:36.067" Score="3" Body="&lt;p&gt;The pin layout and dimensions of the Mega are as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/a1uUG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a1uUG.png&quot; alt=&quot;Mega Board layout.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dimensions are in thousandths of an inch. &lt;a href=&quot;https://blog.arduino.cc/2011/01/05/nice-drawings-of-the-arduino-uno-and-mega-2560/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-01T01:06:36.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13847" PostTypeId="1" CreationDate="2015-08-01T01:34:43.810" Score="1" ViewCount="2305" Body="&lt;p&gt;I have the following snippet of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned long fiveMinutes = 5 * 60 * 1000UL;&#xA;unsigned long lastCheck = 0 - fiveMinutes;&#xA;unsigned long now = 0;&#xA;&#xA;void loop() {&#xA;  now = millis();&#xA;  if ( now - lastCheck &amp;gt;= fiveMinutes ) {&#xA;    doStuff();&#xA;    lastCheck = now;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;doStuff()&lt;/code&gt; routine is getting called on every &lt;code&gt;loop()&lt;/code&gt; iteration, because the value of &lt;code&gt;lastCheck&lt;/code&gt; isn't getting updated. I thought Icould update global variables inside subroutines, but the behavior I'm seeing says otherwise. What am I doing wrong? (&lt;code&gt;doStuff()&lt;/code&gt; is defined and works correctly, I'm not posting it here for brevity.)&lt;/p&gt;&#xA;" OwnerUserId="11545" LastActivityDate="2015-08-01T02:14:51.840" Title="Why is my variable not getting updated?" Tags="|c|sketch|variables|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13848" PostTypeId="2" ParentId="13847" CreationDate="2015-08-01T02:07:00.743" Score="1" Body="&lt;p&gt;I modified your code to produce a working example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned long fiveMinutes = 20 * 1000UL;&#xA;unsigned long lastCheck = 0 - fiveMinutes;&#xA;unsigned long now = 0;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (&quot;Starting.&quot;);&#xA;  Serial.println (fiveMinutes);&#xA;  }  // end of setup&#xA;&#xA;void doStuff ()&#xA;  {&#xA;  Serial.println (&quot;Doing stuff&quot;);&#xA;  }    &#xA;&#xA;void loop() {&#xA;  now = millis();&#xA;  if ( now - lastCheck &amp;gt;= fiveMinutes ) {&#xA;    doStuff();&#xA;    lastCheck = now;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I reduced the interval to 20 seconds, and Ignacio Vazquez-Abrams is correct about the initial test, however apart from that, I see &quot;Doing stuff&quot; every 20 seconds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I thought I could update global variables inside subroutines ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Are you sure you didn't have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  unsigned long lastCheck;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-01T02:14:51.840" LastActivityDate="2015-08-01T02:14:51.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13849" PostTypeId="1" CreationDate="2015-08-01T04:06:14.310" Score="0" ViewCount="228" Body="&lt;p&gt;My program is a bit large and I'm worried about stability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to print data to both a file and to my LCD. It's like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (hour&amp;lt;10) {&#xA;    dataFile.print(&quot;0&quot;);&#xA;}&#xA;dataFile.print(hour, DEC);&#xA;dataFile.print(&quot;:&quot;);&#xA;if (minute&amp;lt;10) {&#xA;    dataFile.print(&quot;0&quot;);&#xA;}&#xA;dataFile.print(minute, DEC);&#xA;dataFile.print(&quot;:&quot;);&#xA;if (second&amp;lt;10) {&#xA;    dataFile.print(&quot;0&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (hour&amp;lt;10) {&#xA;    lcd.print(&quot;0&quot;);&#xA;}&#xA;lcd.print(hour, DEC);&#xA;lcd.print(&quot;:&quot;);&#xA;if (minute&amp;lt;10) {&#xA;    lcd.print(&quot;0&quot;);&#xA;}&#xA;lcd.print(minute, DEC);&#xA;lcd.print(&quot;:&quot;);&#xA;if (second&amp;lt;10) {&#xA;    lcd.print(&quot;0&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is a smart way to make this shorter? Should I write a function to add the leading zero then another that does something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void printboth (thing) {&#xA;    dataFile.print(thing);&#xA;    lcd.print(thing);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;good idea?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="11086" LastEditDate="2015-08-01T13:23:40.753" LastActivityDate="2015-08-31T23:35:34.703" Title="lcd.print then dataFile.print" Tags="|programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13850" PostTypeId="2" ParentId="1844" CreationDate="2015-08-01T05:02:19.250" Score="4" Body="&lt;p&gt;You can take an analog (PWM) output from the Arduino and turn it into 0 to 10 V DC using something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6gU8Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6gU8Y.png&quot; alt=&quot;Op-amp buffer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Amplification&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The op-amp shown is hooked up as a non-inverting amplifier, where the gain is given by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;V&lt;sub&gt;Out&lt;/sub&gt; / V&lt;sub&gt;In&lt;/sub&gt; = 1 + (R2 / R1)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since R2 and R1 in this case are both 1 k then the output will be the input multiplied by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 + (1000/1000) = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, if we have 5 V coming from D3 we will have 10 V at the output of the op-amp. We need to supply a bit more than 10 V to the op-amp supply pin (pin 8) because this is not a rail-to-rail op-amp, that is, it cannot output all the way up to its supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Low-pass filter&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The resistor R3 and the 10 µF capacitor form a low-pass filter that filters the PWM signal from the Arduino into a more-or-less smooth DC voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shows the difference between the Arduino PWM output, and the output of the op-amp:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dFRE2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dFRE2.png&quot; alt=&quot;PWM and op-amp output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from the scope traces that the yellow line (the PWM output) has a 50% duty cycle, and the blue line (the op-amp output) is 5 V and has a slight ripple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 100% duty cycle, the output is 10 V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Ripple&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Switching the scope to AC coupling we can see how much ripple we have in the op-amp output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L4fbV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L4fbV.png&quot; alt=&quot;Ripple on PWM output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scale for the blue channel has changed in this image, and the cursor shows that we have around 140 mV of ripple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can reduce the ripple by using a larger resistor for R3. For example, making it 10 k reduces the ripple to 86 mV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The larger resistance make the output less responsive to changes at the input (it takes time to charge or discharge the capacitor) but in testing it still seems pretty responsive.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Test code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup () &#xA;  { &#xA;  }&#xA;&#xA;void loop () &#xA;  {&#xA;  analogWrite (3, analogRead (A0) / 4);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had a potentiometer connected to A0 and adjusted it to alter the duty cycle of the PWM output on pin D3.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Theory&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You might ask &quot;Why 138 mV of ripple? Why not 50 mV? Why not 200 mV?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's look at the theory. First, the image posted above looks a bit noisy, so let's take an average of the &lt;em&gt;input&lt;/em&gt; to the op-amp:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kI88i.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kI88i.png&quot; alt=&quot;Ripple averaged&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we can see that the ripple is about 57 mV (the output of the op-amp would be double that). Indeed, the averaged output is &lt;code&gt;57 * 2 = 114 mV&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xe3tR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xe3tR.png&quot; alt=&quot;Ripple on op-amp output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general formula for calculating the time taken by a RC network to reach a certain voltage is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t = -log((V-Vc)/V)R*C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &quot;exp&quot; is the natural exponent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://ladyada.net/library/rccalc.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ladyada - RC Delay Calculator&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &lt;a href=&quot;http://www.schoolphysics.co.uk/age16-19/Electricity%20and%20magnetism/Electrostatics/text/Capacitor_charge_and_discharge_mathematics/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mathematical treatment of charging and discharging a capacitor&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V  = supply voltage   (initial voltage)&#xA;Vc = output voltage   (target voltage)&#xA;R  = resistance in ohms&#xA;C  = capacitance in farads&#xA;t  = time in seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These figures will be on the RC discharge graph at roughly the point indicated:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Bg2mK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bg2mK.png&quot; alt=&quot;RC discharge graph&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://en.wikipedia.org/wiki/RC_circuit&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia - RC circuit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Introducing our values for the resistor and capacitor (using Lua) we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VS = 5.0       -- supply voltage&#xA;VMED = VS / 2  -- 50% duty cycle&#xA;VL = VMED - 27.2e-3   -- low voltage as measured&#xA;VH = VMED + 29.6e-3   -- high voltage as measured&#xA;RES = 4700            -- resistance in ohms&#xA;CAP = 10e-6           -- capacitance in farads&#xA;&#xA;T1 = -math.log ( (VS - VH) /VS) * RES * CAP &#xA;T2 = -math.log ( (VS - VL) /VS) * RES * CAP &#xA;&#xA;print (&quot;T1 =&quot;, T1)&#xA;print (&quot;T2 =&quot;, T2)&#xA;print (&quot;diff = &quot;, T1 - T2, &quot;seconds&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T1 = 0.0331&#xA;T2 = 0.0321&#xA;diff =  0.0010 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The time difference is 1 ms which agrees with the observations.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-07-09T07:40:36.587" LastActivityDate="2016-07-09T07:40:36.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13851" PostTypeId="1" AcceptedAnswerId="13854" CreationDate="2015-08-01T05:48:18.827" Score="4" ViewCount="403" Body="&lt;p&gt;After experiencing failures of my Arduino projects due to low memory, I decided to do some research into it so I could understand better where the problems were. I eventually came to this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  int len = 5000;&#xA;  byte *data = (byte *)malloc(len * sizeof(*data));&#xA;}&#xA;&#xA;void loop() {&#xA;  int timing = 1000;&#xA;  delay(timing);&#xA;  digitalWrite(13, HIGH);&#xA;  delay(timing);&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expected that since my Arduino Uno does not have enough RAM to hold an array of 5000 bytes (&lt;a href=&quot;http://www.atmel.com/devices/atmega328p.aspx?tab=parameters&quot; rel=&quot;nofollow&quot;&gt;Atmel's information&lt;/a&gt; on the Atmega328P shows us it only has 2KB of SRAM), the code in &lt;code&gt;void loop()&lt;/code&gt; would not be able to run due to lack of memory. As far as my understanding goes, once &lt;code&gt;malloc&lt;/code&gt; has allocated 5000 bytes (or as many as it could of the 5000 bytes), there would physically not be enough space left in memory for the variable &lt;code&gt;timing&lt;/code&gt; and the LED I attached on pin 13 would not flash on and off at intervals of 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my LED toggles at perfect intervals of 1 second. Why would this occur? Isn't memory allocated by &lt;code&gt;malloc&lt;/code&gt; unavailable for use by anything else until &lt;code&gt;free&lt;/code&gt; is called on it?&lt;/p&gt;&#xA;" OwnerDisplayName="user3933" LastActivityDate="2015-08-01T06:19:38.380" Title="Why does this code execute?" Tags="|c++|compile|memory-usage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13852" PostTypeId="1" AcceptedAnswerId="13859" CreationDate="2015-08-01T06:10:06.950" Score="1" ViewCount="1056" Body="&lt;p&gt;I've found a circuit board that has a couple of circuits (buttons, IR Receiver, LED, USB). The thing is that following the line for interfacing the buttons I came across what seems to be like buttons that are connected only to the ground line of the PCB while the other end is a free pin cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way for the arduino to detect the ground when the button is pressed or a way to detect a short of some kind? There is a smd and a resistor on both buttons. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main Ground-----Button-----SMD Capacitor-----Resistor(101)-----Free Pin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Circuit Board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6xpiZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6xpiZ.jpg&quot; alt=&quot;Circuit Description&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2015-08-01T07:36:26.030" LastActivityDate="2015-08-02T09:12:57.020" Title="Detect button on a ground line (reverse eng)" Tags="|button|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13853" PostTypeId="1" CreationDate="2015-08-01T06:12:33.647" Score="0" ViewCount="2909" Body="&lt;p&gt;The Arduino website suggests that only three boards are supported for the &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;Mouse and Keyboard library page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Leonardo&lt;/li&gt;&#xA;&lt;li&gt;Micro &lt;/li&gt;&#xA;&lt;li&gt;Due&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What is special about those boards, that the other boards in the Arduino family don't have? I thought they might have the same proceesing chip on them but only two of them do. The CPUs are correspondingly:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ATmega32u4&lt;/li&gt;&#xA;&lt;li&gt;ATmega32u4&lt;/li&gt;&#xA;&lt;li&gt;Atmel SAM3X8E ARM Cortex-M3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have Nanos, Unos and Duemilanoves. I am out of luck aren't I?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is: &lt;strong&gt;what do those three boards have that lets them support those libraries?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11509" LastEditorUserId="10794" LastEditDate="2015-08-01T10:19:52.130" LastActivityDate="2015-08-01T10:19:52.130" Title="Why do only specific arduinos support the keyboard and mouse libraries?" Tags="|arduino-due|arduino-leonardo|arduino-micro|arduino-duemilanove|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13854" PostTypeId="2" ParentId="13851" CreationDate="2015-08-01T06:19:38.380" Score="7" Body="&lt;p&gt;If you add a debugging print you will see what is happening:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  int len = 5000;&#xA;  byte *data = (byte *)malloc(len * sizeof(*data));&#xA;&#xA;  Serial.print (&quot;data = &quot;);&#xA;  Serial.println ((int) data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The malloc failed, it returned NULL, the rest of the program proceeded normally.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;once malloc has allocated 5000 bytes (or as many as it could of the 5000 bytes)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;malloc&lt;/code&gt; does not return with a partial allocation. It either allocates the amount you requested or none at all.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-01T06:19:38.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13855" PostTypeId="2" ParentId="13852" CreationDate="2015-08-01T06:50:08.613" Score="3" Body="&lt;p&gt;It sounds like you might have a PCB with debounced switches on them. One such circuit for debouncing switches looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vVFvF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vVFvF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That circuit and more about switch debouncing can be &lt;a href=&quot;http://www.ikalogic.com/de-bouncing-circuits/&quot; rel=&quot;nofollow noreferrer&quot;&gt;found here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A debouncer basically masks the problem of switch &quot;bounce&quot; which is what happens when the contacts get close and the circuit is quickly closed and opened in rapid succession until a firm connection is obtained. Its a natural problem  mechanical switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not quite right, maybe you could help us help you better by posting a photo of the board in question.&lt;/p&gt;&#xA;" OwnerUserId="11509" LastActivityDate="2015-08-01T06:50:08.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13856" PostTypeId="2" ParentId="13853" CreationDate="2015-08-01T06:54:05.953" Score="1" Body="&lt;p&gt;Those chips have hardware support built into them to handle the rather strict timing requirements for interpreting (and responding to) USB sequences. You will notice, for example, that on the Arduino Uno there is a &lt;em&gt;second&lt;/em&gt; chip (the Atmega16U2) which also can handle USB. In fact the chips with a &quot;U&quot; in the name generally can do this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have Nanos, Unos and Duemilanoves. I am out of luck aren't I?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have a couple of options. Some people reflash the USB chip on their Uno (for example), although personally I think that is a bit fiddly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, there is a library called VUSB (virtual USB) which lets you do some USB on the non USB chips. Google &lt;code&gt;vusb arduino&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need three resistors and two zener diodes to make up the hardware that lets this library do its stuff.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-01T06:54:05.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13857" PostTypeId="2" ParentId="13853" CreationDate="2015-08-01T07:58:42.487" Score="1" Body="&lt;p&gt;Another option is to use the &lt;a href=&quot;http://playground.arduino.cc/Main/PS2Keyboard&quot; rel=&quot;nofollow&quot;&gt;PS2Keyboard&lt;/a&gt; library, a PS2 connector and a PS2-to-USB converter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need only two digital pin of your Arduino and have keyboard solution. &lt;/p&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2015-08-01T07:58:42.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13858" PostTypeId="1" AcceptedAnswerId="14032" CreationDate="2015-08-01T08:41:01.650" Score="0" ViewCount="398" Body="&lt;p&gt;I want to use a TSL2561 light sensor and a DS1307 RTC and a couple of other sensors like DS18B20, AS3935, ML8511, MQ135, 433 mhz sender together with an Arduino.&#xA;However on Adafruit I read this today (Quote from Adafruit)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You may be wondering, how is it OK to connect a 3.3V chip like the&#xA;  TSL2561 to 5.0V data pins like the Arduino? Isn't that bad? Well, in&#xA;  this specific case its OK. I2c uses pullup lines to the 3.3V power&#xA;  pin, so the data is actually being sent at 3.3V. As long as all the&#xA;  sensors/device on the i2c bus are running on 3.3V power, we're fine.&#xA;  However, don't use a 5.0v powered i2c device (like the DS1307) with&#xA;  pullups at the same time as a 3.3V device like the TSL2561! If you&#xA;  want to use this sensor with a datalogger that uses the DS1307, remove&#xA;  any/all of the pullup resistors from the DS1307 SDA/SCL pins. The&#xA;  pullups built into the TSL2561 will then be active and keep the&#xA;  voltage at 3.3V which is safe for both the RTC and the sensor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't really understand the meaning of this. What am I supposed to do? It tells me to remove the pullup lines on the RTC, but what are they and where can I find them? Are there any other sensors where I have to do this? If I don't remove the pullup lines, will I damage anything? Can someone clarify those things to me? &lt;/p&gt;&#xA;" OwnerUserId="11116" LastEditorUserId="2881" LastEditDate="2015-08-01T09:53:08.520" LastActivityDate="2015-08-08T19:46:26.590" Title="Use TSL2561 and DS1307 RTC together" Tags="|sensors|i2c|pull-up|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13859" PostTypeId="2" ParentId="13852" CreationDate="2015-08-01T09:51:23.507" Score="3" Body="&lt;p&gt;Just connect the ground to the ground on the arduino, and the free pin to a IO pin. Enable the pull-up resistor on that pin using &lt;code&gt;pinMode(&amp;lt;nr&amp;gt;, INPUT_PULLUP);&lt;/code&gt;. If the button is not pressed, you will read a HIGH. If the button is pressed you will read a LOW.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-01T09:51:23.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13860" PostTypeId="2" ParentId="11850" CreationDate="2015-08-01T10:18:57.530" Score="1" Body="&lt;p&gt;Solution : The Arduino worked perfectly. When you connect the Arduino with an external power supply the Tx and Rx lights won't light up, Even when they are transmitting or receiving.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm adding this as the solution to stop this being re-added as an unsolved problem.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That is correct. The Tx and Rx LEDs are connected to the Atmega16U2 processor, and thus only flash if there is serial comms via USB.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-01T10:18:57.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13861" PostTypeId="1" CreationDate="2015-08-01T11:09:26.997" Score="1" ViewCount="382" Body="&lt;p&gt;Ok so I've used nicks code and have the code running once ok.... I the noticed however I had a fast 180 sweep and then it returned under control of code. I then noticed the comments wrt pulselen of 1000 being zero degrees and using 1500 as 90 degrees.... Wow so I get a single movement which holds but it doesn't go 90 degrees...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Adafruit servo shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can make my servo move. However, I want to stop it at 90 degrees &lt;em&gt;without&lt;/em&gt; it returning to 0 degrees each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I've used is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  pwm.begin();&#xA;  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for (uint16_t pulselen = SERVOMIN; pulselen &amp;lt; SERVOMAX; pulselen++)&#xA;  {&#xA;    pwm.setPWM(0, 0, pulselen);&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11551" LastEditorUserId="11551" LastEditDate="2015-08-15T20:32:39.897" LastActivityDate="2015-08-15T20:32:39.897" Title="I would like to control 16 motors with a servo shield" Tags="|arduino-uno|motor|servo|adafruit|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13862" PostTypeId="1" AcceptedAnswerId="13935" CreationDate="2015-08-01T12:03:12.747" Score="-1" ViewCount="411" Body="&lt;p&gt;I have an RFID reader RDM-630 with these specifications: &lt;a href=&quot;http://www.seeedstudio.com/depot/datasheet/RDM630-Spec..pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/datasheet/RDM630-Spec..pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I connect this to a Beaglebone Black?&lt;/p&gt;&#xA;" OwnerUserId="11553" LastActivityDate="2015-08-04T11:46:05.733" Title="RDM630 RFID Reader on Beaglebone Black?" Tags="|rfid|" AnswerCount="1" CommentCount="2" ClosedDate="2015-08-04T13:47:36.210" ContentLicense="CC BY-SA 3.0" />
  <row Id="13863" PostTypeId="1" CreationDate="2015-08-01T13:17:30.943" Score="0" ViewCount="148" Body="&lt;p&gt;I am living in India. I want to work on Arduino Projects with GPS Modules. But only a few countries like US, Russia, China etc. have their own GPS satellites. India is working on it. So I am hesitating to buy GPS sensors. Can I work normally with GPS modules in my country as shown in Online projects in my country ?&lt;/p&gt;&#xA;" OwnerUserId="11475" LastEditorUserId="2881" LastEditDate="2015-08-01T14:21:34.443" LastActivityDate="2015-08-01T14:21:34.443" Title="Can I use GPS sensors in a country (India) that doesn't have its own GPS Sattelites?" Tags="|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13864" PostTypeId="2" ParentId="13863" CreationDate="2015-08-01T13:46:58.147" Score="1" Body="&lt;p&gt;Each of the countries listed has their own &lt;em&gt;satnav system&lt;/em&gt;. GPS satellites cover the &lt;em&gt;entire world&lt;/em&gt; and the US government allows &lt;em&gt;anyone&lt;/em&gt; with a GPS receiver to use it, regardless of where on or above the surface they are located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/File:ConstellationGPS.gif&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/9/9c/ConstellationGPS.gif&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-01T13:46:58.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13866" PostTypeId="2" ParentId="13826" CreationDate="2015-08-01T16:17:08.487" Score="-1" Body="&lt;p&gt;Try taking off the bluetooth module, this will allow communication with&#xA;the computer, not the bluetooth module. I had the same problems with my &#xA;hc-06, and have not solved the ladder yet.&lt;/p&gt;&#xA;" OwnerUserId="11557" LastActivityDate="2015-08-01T16:17:08.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13867" PostTypeId="2" ParentId="13822" CreationDate="2015-08-01T16:30:04.417" Score="3" Body="&lt;p&gt;You can buy a camera module for the Arduino, and you can interface it fairly simply.  There are numerous modules around - ask Google, it knows more than me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have yet to work out why people do it.  All you can do with an Uno is to pass the data through to something else like a PC to process the image - so why wouldn't you just use a simple webcam?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino UNO has 2KB of RAM.  A 24-bit 640x480 image (VGA) requires (640*480*3)/1024 = 900KB to store it in memory.  If you really wanted to process an image on an Uno then you would be limited to (say 8-bit grayscale) 48x32 pixels (1.5KB) which is pretty pointless really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even a Due would only allow (again grayscale) around 320x240 (which is better) but nothing colour unless you want to start messing with CLUTs which aren't fun when receiving a truecolour (24-bit) image from a camera.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this kind of task you are better off with an embedded computer with plenty of RAM such as a Raspberry Pi or maybe a Galileo or something.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-01T16:30:04.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13868" PostTypeId="1" AcceptedAnswerId="13872" CreationDate="2015-08-01T17:03:39.413" Score="1" ViewCount="2624" Body="&lt;p&gt;I recently picked up an &lt;a href=&quot;http://www.avmicrotech.com/shop/product.php?id_product=123&quot; rel=&quot;nofollow&quot;&gt;Uno clone&lt;/a&gt; and noticed that if pin 12 is set to an output and I run the Blink sketch on it, the built in led (supposedly connected to pin 13) blinks. It's not as bright as it is when I run it on pin 13, but nonetheless it blinks. If I run it on any other pin, nothing happens, which is the behavior I expected with pin 12.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a common issue with arduino boards, the microcontrollers, etc. or did I get a bad board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall the board visibly appears to have solid construction and appears as the one on the site that I linked to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly as a side note, I'm currently living in India and won't have a problem going back to their factory for a replacement, if it is a bad board. They include a 6 month warranty.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 12;&#xA;int delayPeriod = 100;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(ledPin, HIGH);&#xA;  delay(delayPeriod);&#xA;  digitalWrite(ledPin,LOW);&#xA;  delay(delayPeriod);&#xA;  delayPeriod = delayPeriod + 100;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11556" LastActivityDate="2015-08-01T22:08:32.870" Title="Sending &quot;Blink&quot; to pin 12 is causing on-board led to blink?" Tags="|arduino-uno|led|pins|clones|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13871" PostTypeId="2" ParentId="13849" CreationDate="2015-08-01T21:41:47.643" Score="1" Body="&lt;p&gt;You could format the data with snprintf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char timestamp[9];&#xA;snprintf(timestamp, 9, &quot;%02d:%02d:%02d&quot;, hour, minute, second);&#xA;dataFile.print(timestamp);&#xA;lcd.print(timestamp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%02d&lt;/code&gt; in the snprintf &lt;em&gt;format&lt;/em&gt; means &quot;print at least 2 digits of this value and pad with leading zeros&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-01T21:41:47.643" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13872" PostTypeId="2" ParentId="13868" CreationDate="2015-08-01T22:08:32.870" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I state on that page, if pin 13 is set to input the LED may turn on due to being driven by an op-amp. A nearby pin turning on may be enough to cause that effect. Try adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; pinMode(13, OUTPUT);&#xA; digitalWrite (13, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See if that changes the behaviour.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-01T22:08:32.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13873" PostTypeId="1" AcceptedAnswerId="13881" CreationDate="2015-08-01T23:37:51.413" Score="0" ViewCount="235" Body="&lt;p&gt;I built a Arduino robot car which accepts instructions via bluetooth. The instructions are pretty simple, they tell the car to stop, go forward, reverse, turn left or turn right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I have the car powered through the computer USB (ie when I have just uploaded the sketch), all works fine. However, when I run off independent battery power, the arduino seems to restart whenever I give the car an instruction which means the motors have to operate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the sketch is restarting inside the Arduino because the blue tooth terminal displays the startup text which is inside the 'setup' function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going wrong here? What issue am I encountering?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is an Arduino UNO with an Arduino Motor Shield attached. The blue tooth and two sonic sensors are attached to the motor shield pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have a 9V battery attached to the motor shield. Plus 4 times 1.5V batteries powering the UNO. Am I screwing up the power at all? Getting too much? Or too little?&lt;/p&gt;&#xA;" OwnerUserId="10356" LastActivityDate="2015-08-02T08:03:41.237" Title="Arduino car on bluetooth remote appears to crash when motors started" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13874" PostTypeId="2" ParentId="13873" CreationDate="2015-08-02T01:00:33.060" Score="0" Body="&lt;p&gt;it sounds like the motors are pulling down the battery voltage enough to reboot the Arduino; and the USB-port is able to supply enough current without as much voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We'd need to see a schematic, but check that the power supplied to your Arduino and power supplied to the motors are completely independent; that the Arduino only supplies current to a switch or a relay in the motors' power circuit but not to the motors themselves.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-02T01:00:33.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13876" PostTypeId="1" AcceptedAnswerId="13878" CreationDate="2015-08-02T01:28:33.487" Score="2" ViewCount="696" Body="&lt;p&gt;I'm trying to make my sketch smaller. Right now I use an array for the AM/PM part of my time display. My thinking is this makes it easy to change the formatting:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char* ampms[]= {&quot;am&quot;, &quot;pm&quot;};&#xA;&#xA;void loop() // run over and over again&#xA;{     //get time from RTC          &#xA;     getDateDs1307(&amp;amp;second, &amp;amp;minute, &amp;amp;hour); &#xA;&#xA;      //change to 12 hour format.&#xA;      if (hour&amp;gt;12) { hr = hour - 12; ampm=1; } else { hr = hour; } &#xA;&#xA;      //add leading 0 for hours&#xA;      if (hr&amp;lt;10) { lcd.print(&quot;0&quot;); }&#xA;&#xA;      //print hour in 12 hour format.&#xA;      lcd.print(hr, DEC);&#xA;&#xA;      lcd.print(&quot;:&quot;);&#xA;&#xA;      //add leading 0 for minutes&#xA;      if (minute&amp;lt;10) { lcd.print(&quot;0&quot;);}&#xA;&#xA;      //print minutes&#xA;      lcd.print(minute, DEC); &#xA;&#xA;      //print am or pm using array.&#xA;      dataFile.print(ampms[ampm]);          &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could do this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop() // run over and over again&#xA;{     //get time from RTC          &#xA;     getDateDs1307(&amp;amp;second, &amp;amp;minute, &amp;amp;hour); &#xA;&#xA;      //change to 12 hour format.&#xA;      if (hour&amp;gt;12) { hr = hour - 12; } else { hr = hour; } &#xA;&#xA;      //add leading 0 for hours&#xA;      if (hr&amp;lt;10) { lcd.print(&quot;0&quot;); }&#xA;&#xA;      //print hour in 12 hour format.&#xA;      lcd.print(hr, DEC);&#xA;&#xA;      lcd.print(&quot;:&quot;);&#xA;&#xA;      //add leading 0 for minutes&#xA;      if (minute&amp;lt;10) { lcd.print(&quot;0&quot;);}&#xA;&#xA;      //print minutes&#xA;      lcd.print(minute, DEC); &#xA;&#xA;      //print am or pm using array.&#xA;      if (hour&amp;gt;12) { lcd.print(&quot;am&quot;);} else {lcd.print(&quot;pm&quot;); }        &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No more am/pm array. But, I have to add an if... is one better than the other for memory? Why?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="4131" LastEditDate="2015-08-02T15:31:06.563" LastActivityDate="2015-08-02T15:31:06.563" Title="What will use less memory, an array or if ... else?" Tags="|memory-usage|rtc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13877" PostTypeId="2" ParentId="13861" CreationDate="2015-08-02T03:31:50.087" Score="0" Body="&lt;p&gt;The variable &lt;code&gt;pulselen&lt;/code&gt; in your code corresponds to the angle you want the servo to turn to. For most servos the &lt;code&gt;pulselen&lt;/code&gt; is supposed to be a number from 1000 to 2000, where 1000 corresponds to 0 degrees and 2000 corresponds to 180 degrees, but some servos may be different. It's probably safe to assume that you want a value close to 1500.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course the servo takes a while to get to its position, so the best approach usually involves changing &lt;code&gt;pulselen&lt;/code&gt; gradually until you get to the desired position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get to 90 degrees stop changing &lt;code&gt;pulselen&lt;/code&gt;. At that point you should still be sending the PWM but keep it at 1500. You'll want to keep sending the PWM signal, or the servo will have no resistance to external forces.&lt;/p&gt;&#xA;" OwnerUserId="11509" LastActivityDate="2015-08-02T03:31:50.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13878" PostTypeId="2" ParentId="13876" CreationDate="2015-08-02T05:15:34.933" Score="1" Body="&lt;p&gt;As Ignacio says, if the compiled size is the same both ways, look for something else.  (But note that having the constants in flash memory (program memory) may still use about the same amount of RAM, and typically will take more program space.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I compile the code you showed (together with minor additions like declaration of variables) I show the array method using 4 bytes less code and 5 bytes more RAM than the &lt;code&gt;if&lt;/code&gt; method, so there are tradeoffs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can replace the clunky &lt;code&gt;if&lt;/code&gt; statement and its two &lt;code&gt;lcd.print&lt;/code&gt;s  with the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      lcd.print(hour&amp;gt;12? &quot;am&quot; : &quot;pm&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that that line retains the two bugs that your &lt;code&gt;if&lt;/code&gt; statement has, but it produces them more compactly. :) [One error is that your &lt;code&gt;if&lt;/code&gt; statement prints &lt;code&gt;pm&lt;/code&gt; for hours 0 through 12 and &lt;code&gt;am&lt;/code&gt; for hours 13 through 23.  Another error is that it prints zeroes instead of twelves for the hours after midnight and noon.  More properly, a program should print like 12:xx am during hour 0 of the day, and like 12:xx pm, 1:xx pm, ... 11:xx pm during hours 12 through 23.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that as Gerben mentions, moving the &quot;am&quot; and &quot;pm&quot; strings into program memory via&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(hour&amp;gt;12? F(&quot;am&quot;) : F(&quot;pm&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;saves 6 bytes of RAM.  However, that improvement in RAM usage is offset by 74 additional bytes of program space! The following saves 6 bytes of RAM while increasing program size by only 12 bytes so may be preferable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(hour&amp;gt;12? 'p' : 'a');&#xA;lcd.print('m');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following lines of C can replace much of the code you showed.  However, the &lt;code&gt;printf&lt;/code&gt; library uses about 1300 bytes of program space, so the following compact-source-code approach cannot be recommended unless you are already loading some &lt;code&gt;printf&lt;/code&gt; functions.  It replaces the lines from &lt;code&gt;if (hour&amp;gt;12) { hr = hour - 12; } ...&lt;/code&gt; to the end with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { bufsize=8 };&#xA;char buf[bufsize];&#xA;snprintf (buf, bufsize, &quot;%02:02%cm&quot;, hour%12, minute, hour&amp;gt;12? 'p' : 'a');&#xA;lcd.print(buf);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-08-02T15:27:54.137" LastActivityDate="2015-08-02T15:27:54.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13879" PostTypeId="1" AcceptedAnswerId="13884" CreationDate="2015-08-02T05:37:13.000" Score="-2" ViewCount="248" Body="&lt;p&gt;I am wondering if this Arduino Relay Shield design would be good enough to handle 120v 1amp The transistor is a 2n4401. Also The Two capacitors on the other 3 circuits would be going to ground opps its to late for this   &lt;a href=&quot;https://i.stack.imgur.com/qC6go.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qC6go.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11567" OwnerDisplayName="liljoey112" LastActivityDate="2015-08-02T10:05:13.790" Title="Arduino Relay Shield" Tags="|relay|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13880" PostTypeId="2" ParentId="13879" CreationDate="2015-08-02T05:55:30.743" Score="0" Body="&lt;p&gt;&lt;strong&gt;The critical part is the relay.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd want relays with rated to switch the load and and handle the cold current that the lamp wants.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to see a good creepage clearance distance between digital side and the relay outputs.  Relays which put the common contact between the coil terminals are probably a bad choice here, relays that instead have the contact terminals at one end and the coil terminals at the other make the PCB layout easier.&lt;/p&gt;&#xA;" OwnerUserId="11568" OwnerDisplayName="Jasen" LastEditorUserId="11568" LastEditDate="2015-08-02T06:45:29.623" LastActivityDate="2015-08-02T06:45:29.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13881" PostTypeId="2" ParentId="13873" CreationDate="2015-08-02T08:03:41.237" Score="0" Body="&lt;p&gt;You seem to be using your heavy-duty batteries for the Arduino and the light-duty 9 V battery for the motor. To me this seems backwards. Also the Vin pin to which you have the 9 V battery connected is by default connected to the Arduino as well. This means that if the motors draw a lot of current it will drag the Arduino's voltage down and it will probably reset (thus cutting power to the motors, and then it reboots). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoMotorShieldR3&quot; rel=&quot;nofollow&quot;&gt;Arduino Motor Shield page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Vin on the screw terminal block, is the input voltage to the motor connected to the shield. An external power supply connected to this pin also provide power to the Arduino board on which is mounted. By cutting the &quot;Vin Connect&quot; jumper you make this a dedicated power line for the motor. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You should cut that jumper so that the Arduino and the motor have dedicated supplies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, arrange better batteries for the motor. You may find you can run the Arduino from the 9 V battery, and then make sure you have enough AA batteries to drive the motors.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-02T08:03:41.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13882" PostTypeId="2" ParentId="13852" CreationDate="2015-08-02T09:12:57.020" Score="1" Body="&lt;p&gt;I did some research on the subjects and I came with a solution: &lt;a href=&quot;http://blog.kennyrasschaert.be/blog/2014/04/01/digital-input-on-an-arduino-using-a-push-button/&quot; rel=&quot;nofollow&quot;&gt;I borrowed the code from here&lt;/a&gt; and made some modifications to fit my needs. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 6;&#xA;const int buttonPin1 = 7;&#xA;&#xA;int previousReading = HIGH;&#xA;int previousReading1 = HIGH; &#xA;&#xA;void setup() {&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;  pinMode(buttonPin1, INPUT_PULLUP);&#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop() {&#xA;  int reading = digitalRead(buttonPin);&#xA;  int reading1 = digitalRead(buttonPin1);&#xA;&#xA;  if (previousReading == HIGH &amp;amp;&amp;amp; reading == LOW) {&#xA;     Serial.println(HIGH);         &#xA;  }&#xA;&#xA;  if (previousReading1 == HIGH &amp;amp;&amp;amp; reading1 == LOW) {&#xA;     Serial.println(LOW);&#xA;  }&#xA;&#xA;  previousReading = reading;&#xA;  previousReading1 = reading1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3626" LastActivityDate="2015-08-02T09:12:57.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13884" PostTypeId="2" ParentId="13879" CreationDate="2015-08-02T09:55:47.427" Score="0" Body="&lt;p&gt;As already mentioned, everything to the left of the relays is completely irrelevant when it comes to what the system can cope with.  It's purely down to the relays what voltage and current they can deal with.  As far as the circuit goes there's nothing wrong with it that I can see at first glance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to go from there to an actual physical shield there are a number of things you do need to consider:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Ensure that the relays have a rating &lt;em&gt;at least&lt;/em&gt; as high as the expected maximum voltage and current, ideally &lt;em&gt;derate&lt;/em&gt; it by &lt;em&gt;at least&lt;/em&gt; 50%.  For CFLs (which present an inductive load as well as a resistive load) you want to dereate it even more.&lt;/li&gt;&#xA;&lt;li&gt;Ensure that the mains voltage track layout is kept well away from the low voltage digital signals and ground plane.&lt;/li&gt;&#xA;&lt;li&gt;Ensure that the mains voltage tracks are sized appropriately and kept as short as reasonably possible.  Use a track width calculator to get the right width.&lt;/li&gt;&#xA;&lt;li&gt;Be sure to use appropriate connectors for the mains power.  They need to be able to cope with as much current and voltage as the relays and at the same time be &lt;em&gt;safe&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Keep all mains voltages away from human contact.  This means no exposed live metal on the upper side of your board where it can be inadvertently touched.  Any components with exposed leads that have mains voltage in them should have their leads insulated.&lt;/li&gt;&#xA;&lt;li&gt;Be absolutely certain that, since this is a shield, no mains voltages even come close to the Arduino the shield is plugged into.  This is especially critical around such areas as the USB socket where through-hole components (like screw terminal blocks) are likely to short circuit and cause very very nasty things to happen.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Remember: Mains voltages are dangerous, caution and safety should be your first concern over everything else!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more tip: Do all your mains experimentation as safe as possible.  Either ensure that you have an &lt;a href=&quot;https://en.wikipedia.org/wiki/Earth_leakage_circuit_breaker&quot; rel=&quot;nofollow&quot;&gt;ELCB&lt;/a&gt; &lt;em&gt;and&lt;/em&gt; an &lt;a href=&quot;https://en.wikipedia.org/wiki/Residual-current_device&quot; rel=&quot;nofollow&quot;&gt;RCD&lt;/a&gt; on your ring main / power outlet (with the former you must ensure that you have your earth wires connected properly), or even better (and what I would certainly recommend above all else), use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Isolation_transformer&quot; rel=&quot;nofollow&quot;&gt;Isolation Transformer&lt;/a&gt; to separate you from the mains circuit entirely.  With an Isolation Transformer electrocution is only possible if you contact &lt;em&gt;both&lt;/em&gt; terminals at once as opposed to just one terminal of the normal mains supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; One thing that does puzzle me with your circuit is how you have wired up the common pin of the relays.  That part of the circuit makes no sense to me at all.  You should have 2 connections to each relay - &lt;em&gt;in&lt;/em&gt; and &lt;em&gt;out&lt;/em&gt; where &lt;em&gt;in&lt;/em&gt; connects to the &lt;em&gt;NO&lt;/em&gt; and &lt;em&gt;out&lt;/em&gt; connects to the &lt;em&gt;common&lt;/em&gt; pin¹.  The only way your arrangement could work would be to designate one relay as a &lt;em&gt;master&lt;/em&gt; power control and that one has the main power coming in which then feeds through to the common rail to supply the other three relays.  If this is what you want, then you will have to ensure that the relay designated as master (and its connector) has &lt;em&gt;at least&lt;/em&gt; three times the capacity of the other three relays and connectors (or all four relays have &lt;em&gt;at least&lt;/em&gt; three times the capacity you would otherwise need).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;¹ Note: doing it this way around ensures that when the relay is in the &lt;em&gt;off&lt;/em&gt; position the &lt;em&gt;NC&lt;/em&gt; pin isn't live.  The only pin that would ever be live is the &lt;em&gt;common&lt;/em&gt; pin.  Safety first...!&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-02T10:05:13.790" LastActivityDate="2015-08-02T10:05:13.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13885" PostTypeId="1" AcceptedAnswerId="14251" CreationDate="2015-08-02T11:16:40.083" Score="5" ViewCount="115" Body="&lt;p&gt;I want to create a device that interfaces with the Light Strike Lasertag system using an Arduino Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Light Strike system uses not laser but regular infrared signals. According to a site that I found (&lt;a href=&quot;http://www.meatandnetworking.com/projects/hacking-at-the-light-strike-laser-tag-game/&quot; rel=&quot;noreferrer&quot;&gt;http://www.meatandnetworking.com/projects/hacking-at-the-light-strike-laser-tag-game/&lt;/a&gt;) it uses 37.8 khz signals. I only found IR-receivers using 37.9 or 38 khz. Can I use them? How far can the modulation frequency differ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything else I need to watch out for when creating an IR-interface?&lt;/p&gt;&#xA;" OwnerUserId="11571" LastEditorUserId="11571" LastEditDate="2015-08-02T11:46:53.537" LastActivityDate="2015-08-16T18:07:30.277" Title="IR frequency difference" Tags="|arduino-leonardo|ir|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13886" PostTypeId="2" ParentId="11937" CreationDate="2015-08-02T12:26:47.243" Score="3" Body="&lt;p&gt;I made this &lt;a href=&quot;https://www.youtube.com/watch?v=bTqk_QoeRmw&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; and &lt;a href=&quot;https://github.com/PhillyNJ/ArduinoParallaxJoystick&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt; just for this about a year ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ad4hZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ad4hZ.png&quot; alt=&quot;Breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;2-axis joystick connected to an Arduino Micro&#xA;to output 4 pins, up, down, left &amp;amp; right&#xA;&#xA;If you are using pull down resistors, change all the HIGHs to LOWs and LOWs to HIGH.&#xA;This skectch is using pull up resistors.&#xA;&#xA;*/&#xA;&#xA;int UD = 0;&#xA;int LR = 0;&#xA;/* Arduino Micro output pins*/&#xA;int DWN = 13;&#xA;int UP = 12;&#xA;int LEFT = 11;&#xA;int RT = 10;&#xA;/* Arduino Micro Input Pins */&#xA;int IUP=A0;&#xA;int ILR=A1;&#xA;&#xA;int MID = 10; // 10 mid point delta arduino, use 4 for attiny&#xA;int LRMID = 0;&#xA;int UPMID = 0;&#xA;void setup(){&#xA;&#xA;  pinMode(DWN, OUTPUT);&#xA;  pinMode(UP, OUTPUT);  &#xA;  pinMode(LEFT, OUTPUT); &#xA;  pinMode(RT, OUTPUT);&#xA;&#xA;  digitalWrite(DWN, HIGH);&#xA;  digitalWrite(UP, HIGH);&#xA;  digitalWrite(LEFT, HIGH);&#xA;  digitalWrite(RT, HIGH);&#xA;&#xA;  //calabrate center&#xA;  LRMID = analogRead(ILR);&#xA;  UPMID = analogRead(IUP);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  UD = analogRead(IUP);&#xA;  LR = analogRead(ILR);&#xA;  // UP-DOWN&#xA;  if(UD &amp;lt; UPMID - MID){&#xA;   digitalWrite(DWN, LOW);&#xA;  }else{&#xA;   digitalWrite(DWN, HIGH);&#xA;  }&#xA;&#xA;  if(UD &amp;gt; UPMID + MID){&#xA;   digitalWrite(UP, LOW);&#xA;  }else{&#xA;   digitalWrite(UP, HIGH);&#xA;  }&#xA;  // LEFT-RIGHT&#xA;  if(LR &amp;lt; LRMID - MID){&#xA;   digitalWrite(LEFT, LOW);&#xA;  }else{&#xA;   digitalWrite(LEFT, HIGH);&#xA;  }&#xA;&#xA;  if(LR &amp;gt; LRMID + MID){&#xA;   digitalWrite(RT, LOW);&#xA;  }else{&#xA;   digitalWrite(RT, HIGH);&#xA;  }&#xA;&#xA;  delay(400);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-08-02T12:26:47.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13887" PostTypeId="1" AcceptedAnswerId="13905" CreationDate="2015-08-02T14:44:46.953" Score="1" ViewCount="1011" Body="&lt;p&gt;I'm using an XL335B accelerometer in a GY-61 breakout board. I'm powering the device using the UNO's built-in 3.3V power supply. The following code should convert the readings to m/s² (SI); however, it returns (-0.43|-0.52|-5.83) instead of the expected (0|0|-9.81) when lying untouched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const float CYCLE_LENGHT_MILLIS = 1000;&#xA;&#xA;// REFERENCE_VOLTAGE 5 &amp;amp; STEP_COUNT 1024&#xA;// =&amp;gt; VOLTAGE_STEP 0.0048828125&#xA;// MAX_ACC_VOLTAGE 3.3&#xA;// =&amp;gt; MAX_ACC_VOLTAGE_STEP 675.84&#xA;// MIN_ACC_VOLTAGE 1.65 = 0.5 MAX_ACC_VOLTAGE&#xA;// =&amp;gt; MIN_ACC_VOLTAGE_STEP 337.92&#xA;// MAX_ACC_MEASUREMENT 29.43 = 3g&#xA;&#xA;// acceleration = (read()-MIN_ACC_VOLTAGE_STEP) * MAX_ACC_MEASUREMENT/(MAX_ACC_VOLTAGE_STEP-MIN_ACC_VOLTAGE_STEP)&#xA;//This can be simplified to: acceleration = read()*j - k&#xA;// =&amp;gt; j = MAX_ACC_MEASUREMENT / (MAX_ACC_VOLTAGE_STEP-MIN_ACC_VOLTAGE_STEP)&#xA;// =&amp;gt; k = MIN_ACC_VOLTAGE_STEP * j&#xA;&#xA;const float j = 29.43/(675.84-337.92);&#xA;const float k = 337.92*j;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  Serial.print(&quot;(&quot;);&#xA;  Serial.print(analogRead(0) * j - k);  //X-AXIS&#xA;  Serial.print(&quot;|&quot;);&#xA;  Serial.print(analogRead(1) * j - k);  //Y-AXIS&#xA;  Serial.print(&quot;|&quot;);&#xA;  Serial.print(analogRead(2) * j - k);  //Z-AXIS&#xA;  Serial.println(&quot;)&quot;);&#xA;  delay(CYCLE_LENGHT_MILLIS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11572" LastEditorUserId="11572" LastEditDate="2015-08-02T15:42:00.883" LastActivityDate="2016-11-23T13:43:57.357" Title="XL335B accelerometer reports false readings" Tags="|analogread|accelerometer|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13888" PostTypeId="1" AcceptedAnswerId="13894" CreationDate="2015-08-02T17:26:25.263" Score="0" ViewCount="1598" Body="&lt;p&gt;I have realised an electrical circuit that gives 5V in output. When I press a button, it gives 0V.&#xA;So I have in output a square wave (5V - 0V).&#xA;I would like to count how many times I press the button, by using an Arduino MEGA AT2560.&#xA;I have written this code below, but it doesn't work, because when I press the button, it increase the counter three or four times.&#xA;For example: I press the button 5 times, but the counter has arrived to 30!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;unsigned int count_hall_f = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  attachInterrupt(0, interrFront, RISING); //18  &#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;void interrFront() {&#xA;  count_hall_f++;&#xA;  Serial.println(count_hall_f);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example of the result is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &amp;lt;- I pressed here&#xA;2&#xA;3 &amp;lt;- I pressed here&#xA;4&#xA;5&#xA;6&#xA;7&#xA;8&#xA;9&#xA;10&#xA;11&#xA;12 &amp;lt;- I pressed here&#xA;13&#xA;14&#xA;15&#xA;16 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11574" LastActivityDate="2016-01-30T00:19:05.393" Title="Count RISING edges of a wave form by using ARDUINO" Tags="|interrupt|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13889" PostTypeId="1" CreationDate="2015-08-02T18:45:00.587" Score="1" ViewCount="1227" Body="&lt;p&gt;I found (from a previous life) an STK500 and a couple AT90S8515's in the recesses of my basement..  that I would like to put to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way in which I can write &quot;arduino code&quot; for the 8515?  I know that it's basically C/C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know that the 8515 doesn't have, or support, a bootloader like the Mega series of ICs do..  so I expect that I will need to program it using the STK500.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded AVR Studio, but I will admit, I became very lost, very quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any direction!&lt;/p&gt;&#xA;" OwnerUserId="11367" LastActivityDate="2016-01-21T04:35:43.013" Title="Programming &quot;Arduino&quot; code to AT90S8515?" Tags="|arduino-uno|avr|atmel-studio|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13890" PostTypeId="1" AcceptedAnswerId="13893" CreationDate="2015-08-02T18:48:42.533" Score="1" ViewCount="440" Body="&lt;p&gt;I am trying to debug a problem that I think may be related to the debug code itself and I tried to use theese macros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DEBUG_PRINT(x) { if (Serial) { Serial.print(x);} }&#xA;#define DEBUG_PRINTLN(x) { if (Serial) { Serial.println(x);} }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works a bit but everything starts running really slow and my sketch get to hung up quite fast. Maybe it is timing related but does not seems like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I change that by this the problem is gone:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DEBUG_PRINT(x) { if (true) { Serial.print(x);} }&#xA;#define DEBUG_PRINTLN(x) { if (true) { Serial.println(x);} }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using Arduino Pro Micro (Leonardo).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any problem about calling if (Serial) so many times?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full sketch &lt;a href=&quot;https://github.com/aalku/Arduino_ESP8266_HttpServer/tree/debugQuestion&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="11023" LastActivityDate="2015-08-04T12:56:36.783" Title="Is there any problem about calling if (Serial) many times?" Tags="|serial|arduino-leonardo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13892" PostTypeId="2" ParentId="13888" CreationDate="2015-08-02T19:53:21.137" Score="0" Body="&lt;p&gt;Simple way to do it: since the first interrupt, wait a pre-determined amount of time (depends on the button you use, could be 100us to few tens of ms) and check again that the value is what triggered the interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will kill the effect of the mechanical bounces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even disable interrupts during the delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are much more sophisticated way to do it, but this should be good enough to get you started on the way to debounce your inputs. &lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-02T19:53:21.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13893" PostTypeId="2" ParentId="13890" CreationDate="2015-08-02T19:54:10.487" Score="2" Body="&lt;p&gt;There is no &lt;em&gt;problem&lt;/em&gt;, no, but yes it will slow you down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the source code to the boolean operator for the Serial constructor for CDC:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial_::operator bool() {&#xA;    bool result = false;&#xA;    if (_usbLineInfo.lineState &amp;gt; 0)&#xA;        result = true;&#xA;    delay(10);&#xA;    return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see from that all it does is check the value of a variable.  However it also imposes a 10ms delay¹.  Personally I'd have written it as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial_::operator bool() {&#xA;    return (_usbLineInfo.lineState &amp;gt; 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on top of that I'd have made it inline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to experiment by editing CDC.cpp to replace the bool operator with that smaller, leaner, code and see if it improves things (or breaks them completely)².&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I have submitted a pull request to the Arduino GIT repository with a better method of monitoring the line state and imposing the &lt;code&gt;delay(10)&lt;/code&gt; when it is actually needed rather than at every call to the &lt;code&gt;bool&lt;/code&gt; operator regardless of need.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/pull/3624&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/pull/3624&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;¹ &lt;em&gt;This is done to allow the port to complete opening at the PC end before data is allowed to be sent.  A better system would only perform the &lt;code&gt;delay()&lt;/code&gt; at the moment of port opening rather than every call to the operator.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;² &lt;em&gt;Note that this would remove the delay which may be a bad thing as you may lose the first few bytes of the first debug message.  A better system is in the pull request mentioned in the edit to this answer.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-04T12:56:36.783" LastActivityDate="2015-08-04T12:56:36.783" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="13894" PostTypeId="2" ParentId="13888" CreationDate="2015-08-02T20:48:28.880" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have choosen the values of R and C by experiments. Do you have a suggest for choose these values?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about switches&lt;/a&gt; - somewhat down the page is a discussion of debouncing, including some calculations which show how you can calculate the debounce time. With the switch pin pulled high by the internal pull-up (something you don't appear to be doing), and a 1 µF capacitor, that gives you a debounce of about 35 ms.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Px1on.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Px1on.png&quot; alt=&quot;Hardware debounce&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Results on input pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IvUfI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IvUfI.png&quot; alt=&quot;Debounce scope image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Maths supporting that figure on the above page).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that it is important to have a pull-up or pull-down for your switch or it will read random values if not closed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-02T20:48:28.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13895" PostTypeId="1" AcceptedAnswerId="13897" CreationDate="2015-08-02T21:03:35.407" Score="0" ViewCount="3628" Body="&lt;p&gt;I have a file with numbers called &lt;code&gt;fginputs.txt&lt;/code&gt;. For example it could be something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;4958&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4154&#xA;4958&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want python to send each number to arduino via serial port. After each number is received, arduino should print back an acknowledgment number, indicating that it got a valid number, and then store that number in a dynamic array, because I could create larger files. When there are no more numbers left, send a '-1' to finish transmission.&lt;/p&gt;&#xA;&lt;p&gt;Here's my arduino code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// save some unsigned ints &#xA;uint16_t SIZE, *inputList, cont = 0;&#xA;boolean inputsReady = false;&#xA;&#xA;void setup()&#xA;{&#xA; // initialize serial communication at 9600 bits per second:&#xA; Serial.begin(9600);&#xA;  &#xA; //free dynamic array memory&#xA; free(inputList); &#xA; //counter for how many numbers I've received starts at 0&#xA; cont = 0;&#xA; //This is true when there are no more numbers to receive, meanwhile false&#xA; inputsReady = false;&#xA; setupInputList();&#xA; }&#xA;&#xA;/* If there's not enough space, resize the array by one unit and store the number &#xA;   */&#xA;void growAndInsert(int currentSize, int newInt){&#xA;    if(currentSize &amp;gt; SIZE)&#xA;        inputList = (uint16_t *)realloc(inputList, (currentSize + 1)*sizeof(uint16_t));&#xA;    inputList[currentSize] = newInt;&#xA;}&#xA;/**&#xA;  init inputList with 100 blocks&#xA; */&#xA;void setupInputList(){&#xA;  SIZE = 10;&#xA;  inputList = (uint16_t *)malloc(sizeof(uint16_t) * SIZE);&#xA;}&#xA;&#xA;void clearBuffer(){&#xA;while(Serial.available() &amp;gt; 0)&#xA;    Serial.read();&#xA;}&#xA;&#xA;/**&#xA;Listens in serial port for an integer that represents a new input and returns it.&#xA;If it doesn't get anything useful from serial, return 0&#xA;*/&#xA;  int getNewInputFromSerial(){&#xA;   if (Serial.available() &amp;gt; 0) {&#xA;    delay(100);&#xA;    // look for the next word &#xA;    int cmd = Serial.parseInt();&#xA;    clearBuffer();&#xA;&#xA;    if(cmd == 4958)&#xA;        Serial.write(&amp;quot;4&amp;quot;);&#xA;    else if(cmd == 4154)&#xA;        Serial.write(&amp;quot;5&amp;quot;);&#xA;    else&#xA;        Serial.write(&amp;quot;0&amp;quot;);&#xA;    return cmd;&#xA;   }&#xA;  return 0;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;     if(!inputsReady){&#xA;        int newInput = getNewInputFromSerial();&#xA;        if(newInput == 0)&#xA;            return;&#xA;        if(newInput != -1)&#xA;            growAndInsert(cont++, newInput);&#xA;        else{&#xA;            inputsReady = true;&#xA;            //initTimer(); &#xA;        }&#xA;    }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the python script:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;global arduino&#xA;PORT = '/dev/ttyACM0'&#xA;FILENAME = &amp;quot;fginputs.txt&amp;quot;&#xA;#Read file with inputs&#xA;with open(FILENAME) as f:&#xA;        content = f.readlines()&#xA;#init serial port&#xA;arduino = serial.Serial(PORT, 9600, timeout=1);&#xA;time.sleep(2);&#xA;&#xA;#write&#xA;for input in content:&#xA;    arduino.flush()&#xA;    arduino.write(input)&#xA;    time.sleep(.1);&#xA;    resp = arduino.read();&#xA;    print &amp;quot;i got &amp;quot; + resp&#xA;&#xA;#Finish transmission with -1&#xA;arduino.flush()&#xA;arduino.write(&amp;quot;-1&amp;quot;)&#xA;#done&#xA;arduino.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The fist time I execute the script I get this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;i got 4&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 5&#xA;i got 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which is great. But if I run it a second time I get this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;i got 0&#xA;i got 4&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;i got 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which is terribly wrong because the file hasn't changed. I don't know what is going on here. If I unplug and plug back in the USB cable, transmission works flawlessly again.&lt;/p&gt;&#xA;" OwnerUserId="11576" LastEditorUserId="69229" LastEditDate="2020-10-12T17:15:38.313" LastActivityDate="2020-10-12T17:15:38.313" Title="Send numbers to arduino via serial port using python" Tags="|serial|usb|python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="13896" PostTypeId="2" ParentId="13890" CreationDate="2015-08-02T21:40:06.520" Score="0" Body="&#xA;&#xA;&lt;p&gt;The real flaw is testing if Serial is available all the time. For one thing, that wouldn't work on a Uno etc. How about something like this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// make true to debug, false to not&#xA;#define DEBUG true&#xA;&#xA;// conditional debugging&#xA;#if DEBUG &#xA;&#xA;  #define beginDebug()  do { Serial.begin (115200); while (!Serial) { } } while (0)&#xA;  #define Trace(x)      Serial.print   (x)&#xA;  #define Trace2(x,y)   Serial.print   (x,y)&#xA;  #define Traceln(x)    Serial.println (x)&#xA;  #define Traceln2(x,y) Serial.println (x,y)&#xA;  #define TraceFunc()   do { Serial.print (F(&quot;In function: &quot;)); Serial.println (__PRETTY_FUNCTION__); } while (0)&#xA;&#xA;#else&#xA;  #define beginDebug()  ((void) 0)&#xA;  #define Trace(x)      ((void) 0)&#xA;  #define Trace2(x,y)   ((void) 0)&#xA;  #define Traceln(x)    ((void) 0)&#xA;  #define Traceln2(x,y) ((void) 0)&#xA;  #define TraceFunc()   ((void) 0)&#xA;#endif // DEBUG&#xA;&#xA;&#xA;long counter;&#xA;unsigned long start;&#xA;&#xA;void setup() {&#xA;  start = micros ();&#xA;&#xA;  beginDebug ();&#xA;  Traceln (F(&quot;Commenced debugging!&quot;));&#xA;  TraceFunc ();  // show current function name&#xA;&#xA;}  // end of setup&#xA;&#xA;void foo ()&#xA;  {&#xA;  TraceFunc (); // show current function name&#xA;  }&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  counter++;&#xA;  if (counter == 100000)&#xA;  {&#xA;    Traceln (F(&quot;100000 reached.&quot;));&#xA;    Trace (F(&quot;took &quot;));&#xA;    Traceln (micros () - start);&#xA;    counter = 0;&#xA;    foo ();&#xA;  }  // end of if&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That only does the Serial.begin() once, and the test for waiting for Serial to become available once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, depending on the DEBUG define, the debugging code is executed or not. The fancy &lt;code&gt;((void) 0)&lt;/code&gt; calls get optimized away completely by the compiler if DEBUG is false, thus making them have no effect if debugging is off (which wouldn't apply to your code).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;As you can deduce from my macros I wanted to debug IF the serial port is connected. I don't want to wait for it to be connected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well it wasn't &lt;em&gt;immediately&lt;/em&gt; obvious from your code. In that case I suggest you test in the main &lt;code&gt;loop&lt;/code&gt; function every second or so, to see if &lt;code&gt;Serial&lt;/code&gt; is true. If so, set a flag. Test that flag in your debug function. That way you aren't slowing down every single &lt;code&gt;Serial.print&lt;/code&gt; by 10 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this amended code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// make true to debug, false to not&#xA;#define DEBUG true&#xA;&#xA;// conditional debugging&#xA;#if DEBUG &#xA;&#xA;  #define beginDebug()  do { Serial.begin (115200); } while (0)&#xA;  #define Trace(x)      do { if (serialConnected) Serial.print   (x); }     while (0)&#xA;  #define Trace2(x,y)   do { if (serialConnected) Serial.print   (x, y); }  while (0)&#xA;  #define Traceln(x)    do { if (serialConnected) Serial.println (x); }     while (0)&#xA;  #define Traceln2(x,y) do { if (serialConnected) Serial.println (x, y); }  while (0)&#xA;  #define TraceFunc()   do { if (serialConnected) { Serial.print (F(&quot;In function: &quot;)); Serial.println (__PRETTY_FUNCTION__);} } while (0)&#xA;&#xA;#else&#xA;  #define beginDebug()  ((void) 0)&#xA;  #define Trace(x)      ((void) 0)&#xA;  #define Trace2(x,y)   ((void) 0)&#xA;  #define Traceln(x)    ((void) 0)&#xA;  #define Traceln2(x,y) ((void) 0)&#xA;  #define TraceFunc()   ((void) 0)&#xA;#endif // DEBUG&#xA;&#xA;const byte LED = 13;&#xA;&#xA;bool serialConnected;&#xA;unsigned long timeSerialLastTested;&#xA;&#xA;long counter;&#xA;unsigned long start;&#xA;&#xA;void setup() {&#xA;  start = micros ();&#xA;&#xA;  beginDebug ();&#xA;  Traceln (F(&quot;Commenced debugging!&quot;));&#xA;  TraceFunc ();  // show current function name&#xA;&#xA;  pinMode (LED, OUTPUT);&#xA;}  // end of setup&#xA;&#xA;void foo ()&#xA;  {&#xA;  TraceFunc (); // show current function name&#xA;  }&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  // every second, see if the Serial port is available&#xA;  if (millis () - timeSerialLastTested &amp;gt;= 1000)&#xA;    {&#xA;    timeSerialLastTested = millis (); &#xA;    serialConnected = Serial;  &#xA;    digitalWrite (LED, !digitalRead (LED));  // blink LED&#xA;    }&#xA;&#xA;  counter++;&#xA;  if (counter == 100000)&#xA;  {&#xA;    Traceln (F(&quot;100000 reached.&quot;));&#xA;    Trace (F(&quot;took &quot;));&#xA;    Traceln (micros () - start);&#xA;    counter = 0;&#xA;    foo ();&#xA;  }  // end of if&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-03T05:26:29.777" LastActivityDate="2015-08-03T05:26:29.777" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13897" PostTypeId="2" ParentId="13895" CreationDate="2015-08-02T21:55:14.170" Score="3" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// save some unsigned ints &#xA;uint16_t SIZE, *inputList, cont = 0;&#xA;boolean inputsReady = false;&#xA;&#xA;void setup()&#xA;{&#xA; // initialize serial communication at 9600 bits per second:&#xA; Serial.begin(9600);&#xA;&#xA; //free dynamic array memory&#xA; free(inputList); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are freeing a NULL pointer which is &lt;s&gt;an undefined operation&lt;/s&gt; not necessary here, since it was never allocated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  if (Serial.available() &amp;gt; 0) {&#xA;    delay(100);&#xA;    // look for the next word &#xA;    int cmd = Serial.parseInt();&#xA;    clearBuffer();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is going to just throw data away, I'm not surprised stuff goes missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read this: &lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;How to process incoming serial data without blocking&lt;/a&gt; - you need to get rid of the &lt;code&gt;delay&lt;/code&gt;, and the &lt;code&gt;clearBuffer()&lt;/code&gt; for a start.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code for reading from Serial without blocking and without using &lt;code&gt;delay&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 50;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  } // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data)&#xA;  {&#xA;  // for now just display it&#xA;  // (but you could compare it to some value, convert to an integer, etc.)&#xA;  Serial.println (data);&#xA;  }  // end of process_data&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;  {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte)&#xA;    {&#xA;&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;      // terminator reached! process input_line here ...&#xA;      process_data (input_line);&#xA;&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;    }  // end of switch&#xA;&#xA;  } // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;  {&#xA;  // if serial data available, process it&#xA;  while (Serial.available () &amp;gt; 0)&#xA;    processIncomingByte (Serial.read ());&#xA;&#xA;  // do other stuff here like testing digital input (button presses) ...&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;process_data&lt;/code&gt; in my example is where you would call &lt;code&gt;atoi&lt;/code&gt; to convert the incoming string into an int (or &lt;code&gt;atol&lt;/code&gt; if it is going to be longer).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-02T22:59:01.007" LastActivityDate="2015-08-02T22:59:01.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13898" PostTypeId="2" ParentId="13889" CreationDate="2015-08-02T21:59:56.780" Score="1" Body="&lt;p&gt;Theoretically yes, once you write a &lt;a href=&quot;https://code.google.com/p/arduino/wiki/Platforms&quot; rel=&quot;nofollow&quot;&gt;core&lt;/a&gt; (&lt;a href=&quot;https://code.google.com/p/arduino/wiki/Platforms1&quot; rel=&quot;nofollow&quot;&gt;1.5.x/1.6.x&lt;/a&gt;) for it. I'm not sure if the IDE has a configuration for the STK500, but it should be easy enough to add (since avrdude already supports it).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-02T21:59:56.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13899" PostTypeId="1" CreationDate="2015-08-03T00:14:35.787" Score="1" ViewCount="985" Body="&lt;p&gt;My question is related to &lt;a href=&quot;https://arduino.stackexchange.com/questions/13890/is-there-any-problem-about-calling-if-serial-many-times&quot;&gt;this one&lt;/a&gt;. My sketch seems to stop responding after some time if I run it with debug enabled and I don't open the serial port/monitor on the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the UART buffer fill up and block or something? Or, does it discard the excess data and keep working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find information about it.&lt;/p&gt;&#xA;" OwnerUserId="11023" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-13T02:41:27.237" Title="What happens if I don't open the USB serial port of Arduino Pro Micro / Leonardo?" Tags="|serial|arduino-leonardo|usb|uart|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13900" PostTypeId="2" ParentId="13895" CreationDate="2015-08-03T00:44:46.667" Score="1" Body="&lt;p&gt;You could have a look at &lt;a href=&quot;https://github.com/01org-AutomatedFlasherTester/pem&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a python program which does record/playback of key-presses, through an UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It already implements:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;serial communication with error checking&lt;/li&gt;&#xA;&lt;li&gt;ACK: each message has its own ID, so you can keep track of what was lost, should anything bad happen&lt;/li&gt;&#xA;&lt;li&gt;synchronization, in case your Arduino is powered up after the python program is started&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-03T00:44:46.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13902" PostTypeId="2" ParentId="13899" CreationDate="2015-08-03T05:38:05.123" Score="1" Body="&lt;p&gt;As far as I can see from CDC.cpp it attempts to see if the USB is available and if not, do not write anything but set the &quot;write error&quot; flag.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t Serial_::write(const uint8_t *buffer, size_t size)&#xA;{&#xA;    /* only try to send bytes if the high-level CDC connection itself &#xA;     is open (not just the pipe) - the OS should set lineState when the port&#xA;     is opened and clear lineState when the port is closed.&#xA;     bytes sent before the user opens the connection or after&#xA;     the connection is closed are lost - just like with a UART. */&#xA;&#xA;    // TODO - ZE - check behavior on different OSes and test what happens if an&#xA;    // open connection isn't broken cleanly (cable is yanked out, host dies&#xA;    // or locks up, or host virtual serial port hangs)&#xA;    if (_usbLineInfo.lineState &amp;gt; 0) {&#xA;        int r = USB_Send(CDC_TX,buffer,size);&#xA;        if (r &amp;gt; 0) {&#xA;            return r;&#xA;        } else {&#xA;            setWriteError();&#xA;            return 0;&#xA;        }&#xA;    }&#xA;    setWriteError();&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the same test as is done in &lt;code&gt;operator bool()&lt;/code&gt; without the 10 ms delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This operator is a convenient way for a sketch to check whether the&#xA;// port has actually been configured and opened by the host (as opposed&#xA;// to just being connected to the host).  It can be used, for example, in &#xA;// setup() before printing to ensure that an application on the host is&#xA;// actually ready to receive and display the data.&#xA;// We add a short delay before returning to fix a bug observed by Federico&#xA;// where the port is configured (lineState != 0) but not quite opened.&#xA;Serial_::operator bool() {&#xA;    bool result = false;&#xA;    if (_usbLineInfo.lineState &amp;gt; 0) &#xA;        result = true;&#xA;    delay(10);&#xA;    return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Judging by the comments above, this may not be the most reliable thing in the world.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-03T05:38:05.123" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13903" PostTypeId="1" CreationDate="2015-08-03T06:09:58.157" Score="0" ViewCount="202" Body="&lt;p&gt;Is arduino code Consume More power other than &quot;Avr Studio&quot; Code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell some key points for power saving.&#xA;Processor on $ off Methodology.&lt;/p&gt;&#xA;" OwnerUserId="11581" LastEditorUserId="10794" LastEditDate="2015-09-06T08:54:41.437" LastActivityDate="2015-09-06T08:54:41.437" Title="Power saving of atmega 2560" Tags="|power|" AnswerCount="1" CommentCount="1" ClosedDate="2015-08-04T13:46:58.673" ContentLicense="CC BY-SA 3.0" />
  <row Id="13904" PostTypeId="2" ParentId="13903" CreationDate="2015-08-03T07:02:43.553" Score="2" Body="&lt;p&gt;There is nothing about the Arduino code that would inherently consume more power than using a different compiler, so no, it doesn't. What the code does you can change in either development environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt; for a considerable number of tips about saving power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see related threads about this question such as &lt;a href=&quot;https://arduino.stackexchange.com/questions/6/what-are-or-how-do-i-use-the-power-saving-options-of-the-arduino-to-extend-bat&quot;&gt;What are (or how do I use) the power saving options of the Arduino to extend battery life?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-03T07:02:43.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13905" PostTypeId="2" ParentId="13887" CreationDate="2015-08-03T11:41:02.033" Score="1" Body="&lt;p&gt;You are assuming here that 3g will result in the maximum voltage of 3.3v. This is not correct. The datasheet says it's 0.3v/g so; 0g-voltage + 3 x 0.3v =&gt; 1.65 + 3*0.3 = 2.55volt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the g value use &lt;code&gt;(analogRead(0)-337.92)/61.44&lt;/code&gt; (337.92 is the 0g voltage in steps; 61.44 is 0.3V is steps).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the acceleration is m/s² just multiply by 9.81; so &lt;code&gt;(analogRead(0)-337.92)/61.44*9.81&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like you stated in the comments, the result isn't that accurate. Just have a look at the &lt;a href=&quot;http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;. e.g. Volt per G is typically 300, but can be anything from 270 to 330. Same thing goes for the 0g voltage; 1.35V to 1.65V. So quite a bit of difference can occur between one chip and the next. Even between the 3 axis inside one chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best thing is to calibrate all 3 axis. For the Z axis; just lay the sensor flat, and get the analogRead value (-1g value). Flip the sensor upside down and get the analogRead value (+1g value). Optionally place the sensor on it's side to get 0g value or just calculate the value in the middle of the above two value. The steps-per-g will be the difference between the two divided by 2 (&lt;code&gt;+1g - -1g = 2g&lt;/code&gt;). Put this value and the 0g step-value into the formula. Repeat the procedure for the other 2 axis.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-03T11:41:02.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13906" PostTypeId="1" AcceptedAnswerId="13914" CreationDate="2015-08-03T13:51:37.277" Score="2" ViewCount="84" Body="&lt;p&gt;I am fairly new to the whole concept of Arduino and electronic engineering in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently I bought myself an Arduino UNO and I'm wondering what &quot;non off the shelf&quot; components will work when I hook them up with the UNO. I have a lot  of old electronic stuff laying around containing pushbuttons, sliders, faders, knobs etc. wich if possible, I'd like to take apart to connect them to the UNO for some fun fuzzin' around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: this is my fist post ever on stackexchange so excuse me if the question is placed incorrectly or the tags are weird. Please DO correct me where I'm wrong.&lt;/p&gt;&#xA;" OwnerUserId="11586" LastActivityDate="2015-08-03T17:22:11.943" Title="What requirements should components have to work with Arduino (UNO in particular)" Tags="|arduino-uno|components|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13907" PostTypeId="2" ParentId="12397" CreationDate="2015-08-03T13:55:20.550" Score="3" Body="&lt;p&gt;You must use these libraries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;  --&amp;gt;  #include &amp;lt;Ethernet2.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp.h&amp;gt;  --&amp;gt;  #include &amp;lt;EthernetUdp2.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More info at this link &lt;a href=&quot;https://www.arduino.cc/en/Reference/Ethernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Ethernet Shield2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11587" LastEditorUserId="43363" LastEditDate="2018-03-03T08:35:32.527" LastActivityDate="2018-03-03T08:35:32.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13908" PostTypeId="1" AcceptedAnswerId="13928" CreationDate="2015-08-03T13:57:42.410" Score="0" ViewCount="672" Body="&lt;p&gt;I have a ethenet shield. I want to update my server page. Server page have to show current time. The code is given in this &lt;a href=&quot;https://drive.google.com/folderview?id=0BzuMgxouJ695flY2M0JQWFJrd0F5NGthMXhSTUFkQ2xPV3RpdzJ6X2dRc05mdENYOXJnMWc&amp;amp;usp=sharing&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. Code works but there is two problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- When i press the stop button in the browser, Arduino stops. After this i press refresh button and there is no response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- How can i synchronize the arduino time. From where? without setup another server. Is there any time stamp server that compatible with arduino? &lt;/p&gt;&#xA;" OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2015-08-03T14:03:24.243" LastActivityDate="2015-08-04T02:31:03.210" Title="Arduino Ethernet Shield Response Process, Time, and Synchronization" Tags="|ethernet|time|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13909" PostTypeId="1" AcceptedAnswerId="13911" CreationDate="2015-08-03T14:00:36.307" Score="0" ViewCount="7794" Body="&lt;p&gt;Short dumb question: can I connect the 3.3V pin and the analog reference pin (AREF) directly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've heard mentions of a 32K internal resistor but I'm not willing to risk a short circuit without confirmation. Should I add an external resistor? Won't that create a voltage divider?&lt;/p&gt;&#xA;" OwnerUserId="11572" LastActivityDate="2015-08-04T06:13:20.303" Title="Can I supply the board's 3.3V directly to the AREF pin?" Tags="|arduino-uno|analogread|resistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13911" PostTypeId="2" ParentId="13909" CreationDate="2015-08-03T15:41:05.503" Score="1" Body="&lt;p&gt;In Atmel's doc8271 pdf (with specification details for ATmega48A; ATmega48PA; ATmega88A; ATmega88PA; ATmega168A; ATmega168PA; ATmega328; and ATmega328P), table 29-20 on page 117 shows R_REF (the AREF input resistance) as 32KΩ (typical).  Section 24.5.2 on page 248 suggests that AREF is to be treated as a high-impedance input or output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... the reference voltage can be made more immune to noise by connecting a capacitor between the&#xA;  AREF pin and ground. VREF can also be measured at the AREF pin with a high impedance voltmeter. Note that&#xA;  VREF is a high impedance source, and only a capacitive load should be connected in a system.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also note that there is no reason to connect anything to AREF (pin 21), because on a standard Uno, AVCC (pin 20) is connected to VCC (pin 7), and one can select AVCC as the reference voltage during analog converter setup [as explained below].  Quoting again from section 24.5.2:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;VREF can be selected as either AVCC, internal 1.1V reference, or external AREF pin.  AVCC is connected to the ADC through a passive switch. The internal 1.1V reference is generated from the internal bandgap reference (VBG) through an internal amplifier. In either case, the external AREF pin is directly connected to the ADC...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Summary: you can connect the 3.3V pin and the analog reference pin (AREF) directly, but on a 3.3V system  there is no reason to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Selecting AVCC as the reference voltage:&lt;/em&gt;  Say &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;analogReference(DEFAULT)&lt;/a&gt; to select AVCC as the reference voltage.  According to arduino.cc, this will choose “the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)”.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-08-03T15:48:43.083" LastActivityDate="2015-08-03T15:48:43.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13912" PostTypeId="1" CreationDate="2015-08-03T16:44:36.370" Score="3" ViewCount="21778" Body="&lt;p&gt;I always asumed it was a different option to power the board, but it seems to act more like a 5V supply. What then is the difference between this pin and the 5V pin? &lt;/p&gt;&#xA;" OwnerUserId="4499" LastActivityDate="2016-05-23T21:59:23.647" Title="What is the Vin Pin for?" Tags="|arduino-uno|power|voltage-level|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13913" PostTypeId="2" ParentId="13912" CreationDate="2015-08-03T17:15:57.413" Score="9" Body="&lt;p&gt;The Vin pin serves the same purpose as the barrel jack.  The only difference is (usually) that it doesn't go through the schottky protection diode that causes a small voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally its voltage is at around 0.3-0.4V below whatever you feed into the barrel jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you power from USB then the USB voltage (~5V) is &quot;back-fed&quot; through the 5V regulator to appear on the Vin pin.  It's not safe to use that power for anything since you could damage the 5V regulator if you do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin is designed to either be used to power external higher voltage devices with power (almost) direct from the barrel jack (motors, etc), or to feed power in from an external source without using the barrel jack (great for a shield that can provide its own power source).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-03T17:15:57.413" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13914" PostTypeId="2" ParentId="13906" CreationDate="2015-08-03T17:22:11.943" Score="2" Body="&lt;p&gt;When it comes to electronics, hypothetically anything can be connected to anything else. The only real barriers are time, cost, and practicality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two major things to look out for though are voltage and current requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduinos operate at 5 volts, so it's often easiest to connect it to other electronic devices which also operate at 5 volts. That certainly doesn't mean you &lt;em&gt;can't&lt;/em&gt; connect an Arduino to something that operates at 3.3 volts (for example). However, it means you may need to add some voltage level conversion circuitry (although it's not always necessary, depending on the context).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding current, a critical issue to look out for is how much current something will draw. For example, a motor will often require more current than an Arduino can safely provide. That means you'd need some kind of external power supply which can be switched by the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most valuable thing to do is to learn to find and read datasheets. These give information about electronic components, specifying things like voltage, current, timing and so on. For situations where there's no datasheet available, you may find it useful to learn how to use a multimeter and an oscilloscope to monitor how equipment behaves.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-08-03T17:22:11.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13915" PostTypeId="1" AcceptedAnswerId="13922" CreationDate="2015-08-03T17:27:34.617" Score="0" ViewCount="4282" Body="&lt;p&gt;I made a circuit that takes humidity and temperature from DHT22 sensor and displays it on Lcd Screen. Simple enough but i get this error &quot;Failed to read from DHT&quot;. That happens because i have this code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (isnan(t) || isnan(h)) {&#xA;  delay(100);&#xA;    Serial.println(&quot;Failed to read from DHT&quot;);&#xA;  } else {&#xA;    delay(100);&#xA;    Serial.print(&quot;Humidity: &quot;);&#xA;    Serial.print(h);&#xA;    Serial.print(&quot; %\t&quot;);&#xA;    Serial.print(&quot;Temperature: &quot;);&#xA;    Serial.print(t);&#xA;    Serial.println(&quot; *C&quot;);&#xA;    //lcd.print(&quot;Temp: &quot;) ;&#xA;    //lcd.print(t);&#xA;    //lcd.setCursor(0, 1);&#xA;    //lcd.print(&quot;Hum: &quot;) ;&#xA;    //lcd.print(h);&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the values are &lt;strong&gt;NaN&lt;/strong&gt; . But 1 minute before it worked fine, and now again it doesnt. Everything is soldered the right way and nothing is false. Lcd is wired ok and it works but i dont get values from DHT22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some pics to help you out.&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ZG3Hi.jpg&quot; alt=&quot;Overview&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/yEfbl.jpg&quot; alt=&quot;Wiring&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/KvYZu.jpg&quot; alt=&quot;Wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the third Image we see its working. And now its not! &#xA;is the DHT sensor broken?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &quot;DHT.h&quot;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;`&#xA;&#xA;#define DHTPIN 2     &#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;DHT22 test!&quot;);&#xA;  lcd.begin(16, 2)&#xA;  dht.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  float h = dht.readHumidity();&#xA;  float t = dht.readTemperature();&#xA;&#xA;&#xA;  if (isnan(t) || isnan(h)) {&#xA;    Serial.println(&quot;Failed to read from DHT&quot;);&#xA;  } else {&#xA;&#xA;    lcd.print(&quot;Hum: &quot;);&#xA;    lcd.print(h);&#xA;    lcd.setCursor(0, 1);&#xA;&#xA;    lcd.print(&quot;Temp: &quot;);&#xA;    lcd.print(t);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thats my code by the way&lt;/p&gt;&#xA;" OwnerUserId="11593" LastEditorUserId="26717" LastEditDate="2017-05-07T22:36:02.320" LastActivityDate="2017-05-07T22:36:02.320" Title="What's Wrong with this DHT22?" Tags="|c++|temperature-sensor|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13916" PostTypeId="2" ParentId="8857" CreationDate="2015-08-03T18:54:30.863" Score="0" Body="&lt;p&gt;I think I figured out whats wrong: you need to reset the interrupt handling of the MCP in setup() (by reading from both INT pins). Otherwise the MCP may start in a state where it does not generate new interrupts, because it waits for the old ones to be handled...&lt;/p&gt;&#xA;" OwnerUserId="7536" LastActivityDate="2015-08-03T18:54:30.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13918" PostTypeId="1" AcceptedAnswerId="13940" CreationDate="2015-08-03T20:04:46.003" Score="1" ViewCount="969" Body="&lt;p&gt;I've researched a lot but I couldn't find a solution to my problem, which is that after properly following all steps from this Website: &lt;a href=&quot;http://www.danielealberti.it/2014/02/collegamento-diplay-lcd-ad-arduino-via.html&quot; rel=&quot;nofollow&quot;&gt;http://www.danielealberti.it/2014/02/collegamento-diplay-lcd-ad-arduino-via.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and after using the Library LIQUIDTWI2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://drive.google.com/file/d/0BwSP1-P3E2UJY1loYWtWQVRWNlU/edit?usp=sharing&quot; rel=&quot;nofollow&quot;&gt;https://drive.google.com/file/d/0BwSP1-P3E2UJY1loYWtWQVRWNlU/edit?usp=sharing&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for I2C connections, the LCD keeps displaying black boxes on the top row. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure that I have wired (as shown in the tutorial linked above) and programmed everything correctly but I'm still getting the black boxes. Is the problem related with the MCP23017 pin expander or with something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino UNO&lt;/p&gt;&#xA;" OwnerUserId="11595" LastEditorUserId="2881" LastEditDate="2015-08-04T09:11:07.390" LastActivityDate="2015-08-04T23:38:00.923" Title="MCP23017: 16x2 LCD showing black boxes" Tags="|arduino-uno|i2c|lcd|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="13920" PostTypeId="2" ParentId="13912" CreationDate="2015-08-03T20:57:58.223" Score="4" Body="&lt;p&gt;To answer this added question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;At the moment I am using it as a sort of 5V &quot;virtual ground&quot;. Is this an okay use without damaging it? I have a camera which triggers when two wires coming from it are connected, so it triggers on a short&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I certainly would &lt;strong&gt;not&lt;/strong&gt; be using it as a 5V &quot;virtual ground&quot; - whatever that means. The Vin pin could easily be up around the 10V mark, depending on what you plug into the barrel jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11671&quot; rel=&quot;nofollow noreferrer&quot;&gt;project&lt;/a&gt; a while ago where I wanted to trigger a camera flash. In the same way as you describe, two pins had to be shorted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wasn't sure what voltages would be on them, or if there would be a spike, so I used an opto-coupler like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uFbH1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uFbH1.png&quot; alt=&quot;Flash shoe activation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to identify by measuring with a meter which pin has the positive voltage on it. That would go to the collector of the transistor in the opto-coupler (pin 5 in this particular case).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm just not sure about connecting 5V directly to ground though. Do you think this will be safe?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;We can probably assume that the current will be low, after all they wouldn't short out the camera's battery through that pin. Put your meter in &lt;strong&gt;current&lt;/strong&gt; mode across the camera's pin and measure the current when the pin is shorted (ie. the meter will short it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is 20 mA or less then the Arduino digital pin can handle that. I imagine it will be a steady flow of current. I just measured my flash shoe with that method, and it seems to use a tiny fraction of current (0.1 mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that should be safe, safer than your method with Vin anyway.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Then, when I want to trigger it I need to change the digital in pin to a digital out pin and enable the internal pull down resistor on this pin, effectively connecting this pin to ground, and shorting the two wires.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sounds complex. Just make the pin LOW, and make it output to fire it. eg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite (cameraPin, LOW);  // default will be INPUT mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To activate camera:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode (cameraPin, OUTPUT);  // drive low&#xA;delay (500);  // or whatever&#xA;pinMode (cameraPin, INPUT);   // make high impedance&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure you measure the pin and get the correct polarity. You want the positive side to go to the Arduino pin, and the negative side to Ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And make sure it isn't higher than 5V. (Use &lt;strong&gt;voltage&lt;/strong&gt; mode on the meter to check that).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-03T21:35:05.467" LastActivityDate="2015-08-03T21:35:05.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13921" PostTypeId="2" ParentId="13909" CreationDate="2015-08-03T21:16:59.730" Score="1" Body="&#xA;&#xA;&lt;p&gt;I don't see any big objection to connecting the 3.3 V pin to AREF, providing you take precautions in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default for AREF is so-called DEFAULT (heh) as here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;uint8_t analog_reference = DEFAULT;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you do an &lt;code&gt;analogRead&lt;/code&gt; the analogRead code connects up the desired analog reference:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ADMUX = (analog_reference &amp;lt;&amp;lt; 6) | (pin &amp;amp; 0x07);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it starts the ADC conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;strong&gt;change&lt;/strong&gt; the analog reference voltage then this needs to be done &lt;strong&gt;before&lt;/strong&gt; doing the analogRead. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  analogReference (EXTERNAL);&#xA;  analogRead (A0);  // use external reference&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason they do it this way is so that it is safe to physically connect up the 3.3V pin to the AREF pin, because the initial state of the processor is to &lt;strong&gt;read&lt;/strong&gt; the AREF pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you do your first analogRead, and with the DEFAULT reference voltage used, you will find 5V at the AREF pin. If you had then connected that to something else like the 3.3V pin, it will short out and damage the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  pinMode (13, OUTPUT);&#xA;  delay (5000);&#xA;  digitalWrite (13, HIGH);&#xA;  int foo = analogRead (0);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Put your meter on AREF and you will see it jump to 5V after 5 seconds.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-04T06:13:20.303" LastActivityDate="2015-08-04T06:13:20.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13922" PostTypeId="2" ParentId="13915" CreationDate="2015-08-03T21:21:48.107" Score="2" Body="&lt;p&gt;Two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You need to put a delay in between your read requests. Currently you're reading way too fast, every few milliseconds you're hitting the DHT. Max interval should be every two seconds or so. &lt;/li&gt;&#xA;&lt;li&gt;Add a 10k resistor between pin 1 and 2 of the DHT. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd bet adding a delay, or using the simpleTimer library to control how frequently you read from the DHT will clear this up. &lt;/p&gt;&#xA;" OwnerUserId="11460" LastActivityDate="2015-08-03T21:21:48.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13923" PostTypeId="1" AcceptedAnswerId="13925" CreationDate="2015-08-04T00:11:32.433" Score="0" ViewCount="3420" Body="&lt;p&gt;I'm quite new to Arduino world and I'm trying to understand how shift registers work.&#xA;I built this construction : &#xA;&lt;a href=&quot;https://i.stack.imgur.com/dmFiN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dmFiN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, it is an Arduino Duemilanove with AtMega on it, but afaik it doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tutorial I try to follow use SPI library so I try to do it too. I kind of understood that data input, latch and clock had to be pins 7, 4 and 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, all I try to do is sending a byte to light the LEDs. As for me now, the sequence should light all LED, then no one, then one after another.&#xA;I know there is one more input ont the right side of the SR but I didn't plan this model so I ran out of LEDs...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code I use :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;StandardCplusplus.h&amp;gt;&#xA;#include &amp;lt;vector&amp;gt;&#xA;#include &amp;lt;iterator&amp;gt;&#xA;#include &amp;lt;size_type&amp;gt;&#xA;&#xA;using namespace std;&#xA;&#xA;&#xA;//pin du shift register&#xA;#define DATA_PIN 13&#xA;#define LATCH_PIN 4&#xA;#define CLOCK_PIN 11&#xA;//à utiliser plus tard&#xA;#define INPUT_PIN 2&#xA;&#xA;&#xA;void setup() {  &#xA;  pinMode(DATA_PIN, OUTPUT);&#xA;  pinMode(LATCH_PIN, OUTPUT);&#xA;  pinMode(CLOCK_PIN, OUTPUT);&#xA;  //pinMode(INPUT_PIN, INPUT);&#xA;&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  SPI.setDataMode(SPI_MODE0);&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV2);&#xA;  SPI.begin();&#xA;&#xA;  //SPI.transfer(getBit(3));&#xA;  //digitalWrite(LATCH_PIN, HIGH);&#xA;  //digitalWrite(LATCH_PIN, LOW);&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;start !&quot;);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  shift(B11111111);&#xA;  shift(B00000000);&#xA;  shift(B10000000);&#xA;  shift(B01000000);&#xA;  shift(B00100000);&#xA;  shift(B00010000);&#xA;  shift(B00001000);&#xA;  shift(B00000100);&#xA;  shift(B00000010);&#xA;  shift(B00000001);&#xA;}&#xA;&#xA;&#xA;void shift(int n){&#xA;  SPI.transfer(n);&#xA;  digitalWrite(LATCH_PIN, HIGH);&#xA;  digitalWrite(LATCH_PIN, LOW);&#xA;  Serial.print(&quot;shift : &quot;);&#xA;  Serial.println(n);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I upload this code, LEDs sequence has no sense, but serial output was totally OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I see (without the output 0 of course) is :&#xA;1111111, 0111111, 1011111, 1110111, 1111101 and then 1111111 without further changes, whereas serial output is 255, 0, 128, 64, 32, 16, 8, 4, 2, 1, 255, 0, 128 and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume I didn't understand something important, and it prevent me from finding answers in google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for helping, it's really disturbing for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDITS : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;changed the title, it is a 74HC595.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strangest behavior too (not gonna create another topic for that now), I dont have to connect both the gnd and VCC from my arduino for this to light LEDs. It changes a little the brighness of LEDs, but surprisingly VCC&amp;lt; GND&amp;lt; both&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the tutorial I use to understand shift registers : &lt;a href=&quot;https://youtu.be/6fVbJbNPrEU?t=195&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/6fVbJbNPrEU?t=195&lt;/a&gt;, and the one that uses SPI is nXl4fb_LbcI&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now aware that I should get one resistor for each LED but I don't have that much resistors and as far as I can see this don't harm my LEDs nor underpower them.&lt;/p&gt;&#xA;" OwnerUserId="11604" OwnerDisplayName="Dan Chaltiel" LastEditorUserId="11604" LastEditDate="2015-08-04T10:12:16.180" LastActivityDate="2015-08-04T10:12:16.180" Title="Simple Arduino - 74hc595 shift register construction [tmli5]" Tags="|shift-register|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13924" PostTypeId="2" ParentId="13861" CreationDate="2015-08-04T01:18:25.880" Score="1" Body="&#xA;&#xA;&lt;p&gt;The code in &lt;code&gt;loop&lt;/code&gt; is called repeatedly. Thus it does this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go from SERVOMIN to SERVOMAX very rapidly (I measured 72 ms)&lt;/li&gt;&#xA;&lt;li&gt;Pause half a second&lt;/li&gt;&#xA;&lt;li&gt;Repeat the above&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To make it pause at SERVOMAX you need to either not repeat the loop, or put it all in &lt;code&gt;setup&lt;/code&gt;, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_PWMServoDriver.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();&#xA;&#xA;#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)&#xA;#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)&#xA;void setup()&#xA;{&#xA;  pwm.begin();&#xA;  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates&#xA;  for (uint16_t pulselen = SERVOMIN; pulselen &amp;lt; SERVOMAX; pulselen++)&#xA;  {&#xA;    pwm.setPWM(0, 0, pulselen);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-04T02:06:03.837" LastActivityDate="2015-08-04T02:06:03.837" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13925" PostTypeId="2" ParentId="13923" CreationDate="2015-08-04T01:34:50.950" Score="1" Body="&#xA;&#xA;&lt;p&gt;You have a number of problems here. The first is the wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/idHuy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/idHuy.png&quot; alt=&quot;595 wiring diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My wiring diagram above is for the Uno / Duemilanove. Since that is what you have, you should follow that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins are fixed in hardware, except for the slave select pin. Thus D13 on the Duemilanove should go to pin 11 on the 595. D11 on the Duemilanove should go to pin 14 on the 595. And your slave select (which may as well be pin 10 on the Duemilanove) should go to pin 12 on the 595.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your code looks more complex than it needs to be. This code will exercise the 8 LEDs:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const byte LATCH = 10;&#xA;&#xA;void setup ()&#xA;{&#xA;  SPI.begin ();&#xA;}  // end of setup&#xA;&#xA;byte c;&#xA;void loop ()&#xA;{&#xA;  c++;&#xA;  digitalWrite (LATCH, LOW);&#xA;  SPI.transfer (c);&#xA;  digitalWrite (LATCH, HIGH);&#xA;  delay (20);&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As other responders have said, you should have a current-limiting resistor for &lt;strong&gt;each&lt;/strong&gt; LED. You can't share it like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the 595 ground (pin 8) should be wired to the Duemilanove ground, not via a resistor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using a 74HC595 output shift register as a port-expander&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-04T06:43:29.223" LastActivityDate="2015-08-04T06:43:29.223" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13926" PostTypeId="1" CreationDate="2015-08-04T01:38:22.103" Score="0" ViewCount="3808" Body="&lt;p&gt;linked to my old question, &lt;a href=&quot;https://arduino.stackexchange.com/questions/12775/pro-mini-5v-with-adafruit-motor-shield-v1-power-sharing-problems&quot;&gt;Pro Mini 5v with Adafruit motor shield v1 power sharing problems&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/srD93.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/srD93.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured out and use one 7.2v battery (6 AA cells), and link it with RAW pin to Pro mini and join its 5v pin to motor shield 5v. It works but as I have a servo on this shield, 2 distance sensors so servo does not work well all the times. Stops or does not move as directed, shaking etc. I figured out that pro mini output 5v but only 150mAh which is not sufficient to run a servo which while sharing same 5v for motor shield. I need to know if I want to supply 5v 2000mAh from AA cells or 5v regulator, should I use these pins on motor shield (5v, Gnd, 9v)? I tried but it did not work. I did not find it anywhere on net. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How can I use these pins shown in the picture.&lt;/li&gt;&#xA;&lt;li&gt;What is the min/max mAh value of current I can provide at these pins?&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If supplying input current at these pins, should I connect/disconnect power jumper?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am totally stuck. Need help. And here is the quick diagram how things are attached. All other pins are attached at shield connects to UNO when stack on it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V00dc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V00dc.jpg&quot; alt=&quot;My robotic car diagram.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7235" LastEditorUserId="7235" LastEditDate="2015-08-04T19:07:43.240" LastActivityDate="2019-12-16T06:02:25.450" Title="Motor shield power from Arduino pro mini 5v RAW Pin 150mAh cannot run servo" Tags="|power|shields|arduino-pro-mini|adafruit|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13927" PostTypeId="2" ParentId="13908" CreationDate="2015-08-04T01:40:22.350" Score="1" Body="&lt;p&gt;I don't have an answer for question 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For question 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can add a function to implement an NTP (network time protocol) client.  For example, see the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/UdpNtpClient&quot; rel=&quot;nofollow&quot;&gt;UdpNtpClient&lt;/a&gt; article on arduino.cc.  In your &lt;code&gt;setup()&lt;/code&gt; or &lt;code&gt;loop()&lt;/code&gt; code call the function initially or perhaps hourly or daily to set system time via an NTP time server.  The server's IP address can be hardcoded or otherwise as you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For lists of public time servers, see &lt;a href=&quot;http://www.ntp.org/&quot; rel=&quot;nofollow&quot;&gt;www.ntp.org&lt;/a&gt; and &lt;a href=&quot;http://www.pool.ntp.org/en/&quot; rel=&quot;nofollow&quot;&gt;pool.ntp.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, you could add a &lt;a href=&quot;http://playground.arduino.cc/Main/DS1302&quot; rel=&quot;nofollow&quot;&gt;DS1302&lt;/a&gt; or similar clock chip board to your hardware.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-08-04T01:40:22.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13928" PostTypeId="2" ParentId="13908" CreationDate="2015-08-04T02:31:03.210" Score="1" Body="&#xA;&#xA;&lt;h3&gt;Question 1.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your code looks odd:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void checkForClient(){&#xA;&#xA;  EthernetClient client = server.available();&#xA;&#xA;  if (client) {&#xA;    boolean sentHeader = false;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        if(!sentHeader){&#xA;          // send a standard http response header&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println();&#xA;          sentHeader = true;&#xA;        }&#xA;        durumBildir(client,50,ID);&#xA;      }&#xA;    }&#xA;  }&#xA;  delay(1); // give the web browser time to receive the data&#xA;&#xA;} &#xA;&#xA;void durumBildir(EthernetClient client, int deger,String ID){&#xA;  client.print(ID); &#xA;  client.print(&quot;-&quot;); &#xA;  client.print(deger);&#xA;  client.print(&quot;-&quot;);&#xA;  if (timeStatus()!= timeNotSet) {&#xA;    digitalClockDisplay( client);  &#xA;  } &#xA;&#xA;  client.print(&quot;&amp;lt;br&amp;gt;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You never &lt;strong&gt;read&lt;/strong&gt; from client, so it will &lt;strong&gt;always&lt;/strong&gt; be available (and thus you never leave your loop). I just tested it. Why are you sending the time out indefinitely? Even when you disconnect the poor Arduino is still sending the date and time out forever. No wonder you can't connect again.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-04T02:31:03.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13929" PostTypeId="1" AcceptedAnswerId="13942" CreationDate="2015-08-04T04:12:07.873" Score="0" ViewCount="522" Body="&lt;p&gt;Could the arduino Due take and send image data from 5MP camera module to PC in the following condition? &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;frame rate = 1fps &lt;/li&gt;&#xA;&lt;li&gt;resolution = 2592 x 1944 &lt;/li&gt;&#xA;&lt;li&gt;format = 10 bit bayer raw RGB&lt;/li&gt;&#xA;&lt;li&gt;interface : parallel ports (DVP) between camera and Due&#xA;           spi between Due and PC(or SD card)&lt;/li&gt;&#xA;&lt;li&gt;FIFO(frame buffer): would not be used &lt;/li&gt;&#xA;&lt;li&gt;SDRAM: would not be used&#xA;(But if it is needed, I would SDRAM via spi. Also I can use a frame buffer like AL422B. But if it is possible I would avoid using them.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The camera would send 50Mbit image data per second and they will be transferred via 8 parallel lines(D0~D7) to the Due. And then they would go to PC directly or after passing SDRAM. But how can one evaluate if the 84Mhz is enough to do this job by calculation? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Due specs&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/arduinoBoardDue&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;camera module example (OV5642)&#xA;&lt;a href=&quot;http://www.uctronics.com/cmos-camera-adapter-board-for-omnivision-image-sensor-p-248l.html&quot; rel=&quot;nofollow&quot;&gt;http://www.uctronics.com/cmos-camera-adapter-board-for-omnivision-image-sensor-p-248l.html&lt;/a&gt;&#xA;But this is not what I want to use. In my project I need to build a camera module and it would not include FIFO unless it's highly recommended. &lt;/p&gt;&#xA;" OwnerUserId="11080" LastEditorUserId="11080" LastEditDate="2015-08-04T04:40:52.783" LastActivityDate="2015-08-04T17:09:28.920" Title="Using arduino Due for camera control" Tags="|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13931" PostTypeId="1" CreationDate="2015-08-04T05:36:36.940" Score="0" ViewCount="659" Body="&lt;p&gt;Unfortunately I have yet to learn C++ though I have experience with C# and other non-C languages. After trying for the past 5 hours to pick up what I can from Stack and other sites I haven't found a workable solution that actually works with Arduino IDE (hence why I'm posting here and not stackoverflow).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im trying to create a simple library to handle some analog inputs. I need to be able to compare the value from a pin to a list of values and handle the result accordingly. I can easily send the number of the pin to the constructor and read it. My issue is actually defining that list from the &lt;code&gt;setup()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The list can be variable in length so I can't hard code an array in the library class and then pass values one by one. I can pass the length in the constructor but then I'm not really sure how to use it to initialize the array length without having the values to assign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C# or other languages I'd either use a list or pass the array directly. Neither of these seem to be an option with C++ (or at least I couldn't pass the array correctly). How could I solve this problem? If it helps I'm using a teensy++ 2.0.&lt;/p&gt;&#xA;" OwnerUserId="11602" LastActivityDate="2016-04-11T00:15:14.537" Title="Pass Several Values to Library" Tags="|c++|library|teensy|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13932" PostTypeId="2" ParentId="13931" CreationDate="2015-08-04T05:56:17.820" Score="2" Body="&#xA;&#xA;&lt;p&gt;If the list is a static list you could conceivably pass a pointer to it in the constructor. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class myClass {&#xA;  const int num_;&#xA;  const int * values_;&#xA;&#xA;  public:&#xA;&#xA;  // constructor&#xA;  myClass (const int num, const int * values) : num_ (num), values_ (values) { } &#xA;&#xA;  // other stuff here&#xA;&#xA;  // demo&#xA;  void printThem ();&#xA;};  // end of class myClass&#xA;&#xA;void myClass::printThem ()&#xA;  {&#xA;  for (int i = 0; i &amp;lt; num_; i++)&#xA;    Serial.println (values_ [i]);  &#xA;  } // end of myClass::printThem&#xA;&#xA;const int NUMBER_OF_VALUES = 6;&#xA;const int myValues [NUMBER_OF_VALUES] = { 22, 33, 44, 55, 66, 77 };&#xA;&#xA;// make an instance of the class with the wanted values&#xA;myClass foo (NUMBER_OF_VALUES, myValues);&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  foo.printThem ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the simple method. The values in the list are passed to the constructor as a pointer, the class remembers the list and uses it when necessary.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-04T05:56:17.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13933" PostTypeId="1" AcceptedAnswerId="13934" CreationDate="2015-08-04T10:42:08.283" Score="1" ViewCount="900" Body="&lt;p&gt;My need is to connect an Arduino board (any board that has around 3 UARTs support) to a host PC via USB and expose the 3 UART connections as 3 USB devices (say /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2) in the host PC. From my search, I found Arduino Mega 2560 supports upto 3 UARTs. My question is can we expose these UARTs into individual USB ports to the host system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Alexander&lt;/p&gt;&#xA;" OwnerUserId="11605" LastActivityDate="2015-08-04T11:39:30.260" Title="Arduino Mega as a USB device" Tags="|arduino-mega|usb|uart|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13934" PostTypeId="2" ParentId="13933" CreationDate="2015-08-04T11:39:30.260" Score="2" Body="&lt;p&gt;Not directly, no.  You have basically have 4 UARTs on the Mega2560 - one of them (USART0, pins 0&amp;amp;1) is connected to the USB interface chip, and the others are left unassigned for you to use as you like.  It's the USB interface chip that is being seen in your computer as /dev/ttyUSB0, not the UARTs in the Mega2560 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not to say that what you are after is not possible - it is perfectly possible, but it will require some clever programming on your part.  You will need to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Define a protocol that will multiplex 3 streams of serial data through the one USB serial connection&lt;/li&gt;&#xA;&lt;li&gt;Write a sketch that works with that protocol to direct the incoming data to the right UART ports and multiplex the UART traffic into the protocol stream you have defined&lt;/li&gt;&#xA;&lt;li&gt;Write software on your computer to perform a similar task - read in data and multiplex it, and read the multiplexed data stream and split it out to three separate destinations.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What the destinations on the PC end can be is a bit of a wooly area.  If you want to make it look like serial ports in /dev then you can use a &lt;em&gt;pty pair&lt;/em&gt;, which is a master/slave pair of pseudo TTY devices that you can use to pass data through.  On most Linux systems they are numbered devices in /dev/pts, so /dev/pts/1 would be an example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function &lt;a href=&quot;http://man7.org/linux/man-pages/man3/openpty.3.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;openpty(...)&lt;/code&gt;&lt;/a&gt; creates and opens a pty pair for you to use in your program.  You would do that 3 times to make three pairs and each one would be the endpoint to a sub-stream in your multiplexed data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, here is a bit of code I use to open a pty pair:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct termios options;&#xA;openpty(&amp;amp;_masterfd, &amp;amp;_slavefd, _dev, NULL, NULL);&#xA;fcntl(_masterfd, F_SETFL, 0);&#xA;tcgetattr(_masterfd, &amp;amp;_savedOptions);&#xA;tcgetattr(_masterfd, &amp;amp;options);&#xA;cfmakeraw(&amp;amp;options);&#xA;options.c_cflag |= (CLOCAL | CREAD);&#xA;if (tcsetattr(_masterfd, TCSANOW, &amp;amp;options) != 0) {&#xA;    fprintf(stderr, &quot;Can't set up PTY\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That makes it appear to almost be a serial connection in style.  Of course you don't have the concept of a baud rate over a pty connection, so it will be down to your software to define how you control the baud rate (probably easiest to have it hard coded to the baud rates you need).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that snippet you talk internally to the &lt;code&gt;_masterfd&lt;/code&gt; with normal &lt;code&gt;read()&lt;/code&gt; and &lt;code&gt;write()&lt;/code&gt; functions as you would any other device or file.  Some other piece of software would open the other end of the pty pair (the &lt;code&gt;_slavefd&lt;/code&gt;), the name of which is placed in &lt;code&gt;_dev&lt;/code&gt; when the pty pair are opened.  You could use that &lt;code&gt;_dev&lt;/code&gt; name to then create a symbolic link to a better named device instead of using the &lt;code&gt;/dev/pts/x&lt;/code&gt; name that could change without warning from one run to the next.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-04T11:39:30.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13935" PostTypeId="2" ParentId="13862" CreationDate="2015-08-04T11:46:05.733" Score="0" Body="&lt;p&gt;Found what I was looking for and the answer is yes.&lt;/p&gt;&#xA;" OwnerUserId="11553" LastActivityDate="2015-08-04T11:46:05.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13938" PostTypeId="1" CreationDate="2015-08-04T14:17:28.197" Score="0" ViewCount="1589" Body="&lt;p&gt;So i got that 2,5m cable wired with the LCD and the arduino, but i keep getting those weird characters showing up on the LCD. Clearly there is a signal loss between the components but there has to be a solution to the problem. Perhaps by connecting capacitors/resistors to the wires will help? Is there any solution other than not using this long cable?&lt;/p&gt;&#xA;" OwnerUserId="11595" LastActivityDate="2015-08-04T20:48:50.013" Title="2,5m cable too long for LCD connected to Arduino UNO?" Tags="|arduino-uno|communication|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13940" PostTypeId="2" ParentId="13918" CreationDate="2015-08-04T14:49:38.950" Score="0" Body="&lt;p&gt;Quite often such situation occurs when the display does not reset properly (the reset from the IDE does not necessarily reset the display!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, once the sktech has been uploaded to the board, I would first try to do a reset on the Uno board (using the RESET button). If that doesn't do the trick, I would recommend to make the contrast adjustable (all my LDC displays showed &quot;black boxes in the upper row&quot; on delivery and I had to ajust the contrast).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that also has not the desired effect, there is no alternative to debugging your code. Without the code itself, we cannot guess what might be wrong.&lt;/p&gt;&#xA;" OwnerUserId="11611" LastEditorUserId="10794" LastEditDate="2015-08-04T23:38:00.923" LastActivityDate="2015-08-04T23:38:00.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13942" PostTypeId="2" ParentId="13929" CreationDate="2015-08-04T17:09:28.920" Score="0" Body="&lt;p&gt;So a quick feasability assessment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2592 W * 1944 H * 10 bit = 50388480 bits&lt;/p&gt;&#xA;&#xA;&lt;p&gt;50388480 bits / 8 bit data bus = 6298560 packets&lt;/p&gt;&#xA;&#xA;&lt;p&gt;84000000 clocks per second / 6298560 packets = ~13 clock cycles per packet&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that by itself, from a purely data perspective, without looking too deep into datasheets, you could feasibly read data from a port and push it out the USB port, and clock the data in less than 13 cycles. But what this means is you'd have to get into the nitty gritty of the processor and figure out how to do that as low level as possible because &lt;code&gt;DigitalRead()&lt;/code&gt; and &lt;code&gt;Serial.print()&lt;/code&gt; aren't going to cut it as they won't be fast enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real challenge is that the above totally depends on being able to clock the data from the sensor yourself, which if I recall correctly, these sensors can actually be pretty picky about their clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would highly recommend a FIFO, that way the sensor data can be clocked to it as fast as it wants to be clocked, and then you could read from the FIFO at your own pace as it will clock data out at exactly the rate you want it. Also 1 FPS is a pretty lofty goal if you are only a beginner. Like I said, it is probably possible, but it requires a lot of optimizations and planning that are not very straightforward to implement, especially if you are just starting out.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-04T17:09:28.920" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13943" PostTypeId="2" ParentId="7980" CreationDate="2015-08-04T17:18:54.087" Score="1" Body="&lt;p&gt;I2C (SDA-SCL) line needs to be pull up (place resistor on both to 5v input from master- the uno), it works with the arduino code for master-slave I2C (uno on master-severino on slave) using the code from arduino website (just be sure you set the address for the slave on the slave sketch (any number 1-126), it works for me that way, my pull up resistor is 10kohm, the same goes for my breadboard, if this is not doing the trick, maybe there's something wrong (I wouldn't know the answer to, just tried the i2c yesterday) update : on august5th (today) I just finished reading i2c's on atmel site, it is a complex one, there are several factors on why something is doing something on your twi comm, post your code, and maybe I have an answer&lt;/p&gt;&#xA;" OwnerUserId="11614" LastEditorUserId="11614" LastEditDate="2015-08-05T18:26:21.593" LastActivityDate="2015-08-05T18:26:21.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13944" PostTypeId="2" ParentId="13938" CreationDate="2015-08-04T17:46:07.023" Score="1" Body="&lt;p&gt;If the interface you're using is I2C(only two cables from arduino to lcd, vice versa)you have a problem,you need to pull up the sda-scl channel with appropriate resistors, you could (maybe) boost the I2C signal using ti-p82b715 bus extender, I just assume you use I2C (2,5m length?), what interface do you use? SPI? I2C?&lt;/p&gt;&#xA;" OwnerUserId="11614" LastActivityDate="2015-08-04T17:46:07.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13945" PostTypeId="1" CreationDate="2015-08-04T18:54:10.257" Score="2" ViewCount="1254" Body="&lt;p&gt;My idea is to record the acceleration/altitude of a small model rocket launch using these sensors and record all the data onto a microSD card which I'll retrieve afterwards. I'd like to be able to plot all of the data to analyze the performance of the rocket. This data will also help compare the experimental results to the theoretical ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B008BOPN40&quot; rel=&quot;nofollow&quot;&gt;Accelerometer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00ADSNLMI&quot; rel=&quot;nofollow&quot;&gt;OpenLog/SD Card&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Was only allowed two links so couldn't include barometer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a few questions to make sure that my logic is sound when trying to design this circuit;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.) Since the OpenLog contains the ATmega328 microcontroller I was going to use the Arduino to write the instructions to this which will initialize the two sensors and start logging data. Is this the correct way to do this? From what I could tell the other sensors did not contain any EEPROM/Flash so there was no way to store any code on there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.) If I have multiple sensors running at the same time is this going to cause a data conflict when writing to the SD card? Would it be possible to save two different .txt files, one for each sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="11600" LastActivityDate="2019-03-26T19:36:05.083" Title="Model Rocket Sensors" Tags="|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13946" PostTypeId="1" CreationDate="2015-08-04T13:06:10.887" Score="-1" ViewCount="5203" Body="&lt;p&gt;&lt;strong&gt;Full disclosure&lt;/strong&gt;: I'm a newbie.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got an Arduino Nano and a Mega, and a pair of NRF24L01+ PA modules (exactly these: &lt;a href=&quot;http://www.elektrotedarik.com/Images/Urun/11122013173429.jpeg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.elektrotedarik.com/Images/Urun/11122013173429.jpeg&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get them to work. I am on this tutorial with the RF24 library: &lt;a href=&quot;https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino Nano, it works perfect. I wire everything as told, and set up my radio:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;fdevopen( &amp;amp;my_putc, 0);&#xA;radio.begin();&#xA;radio.setPALevel(RF24_PA_MAX);&#xA;radio.setDataRate(RF24_250KBPS);&#xA;radio.openWritingPipe(pipe);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I call &lt;code&gt;radio.printDetails();&lt;/code&gt; I get a nice output in serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0&#xA;RX_ADDR_P0-1    � = 0xe8e8f0f0e1 0xc2c2c2c2c2&#xA;RX_ADDR_P2-5    � = 0xc3 0xc4 0xc5 0xc6&#xA;TX_ADDR      = 0xe8e8f0f0e1&#xA;RX_PW_P0-6  � = 0x20 0x00 0x00 0x00 0x00 0x00&#xA;EN_AA        = 0x3f&#xA;EN_RXADDR   � = 0x03&#xA;RF_CH        = 0x4c&#xA;RF_SETUP    � = 0x27&#xA;CONFIG       = 0x0c&#xA;DYNPD/FEATURE   � = 0x00 0x00&#xA;Data Rate    = 250KBPS&#xA;Model        = nRF24L01+&#xA;CRC Length   = 16 bits&#xA;PA Power     = PA_HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything as expected. If I remove a wire (for testing), it displays all zeroes, when I plug it back, it displays right again, so I assume that it's in working condition. I then try the same with Mega, but even after re-checking the wiring after 4 times, it's not working. Here's what I get with the same code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS       = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0&#xA;RX_ADDR_P0-1    � = 0x0000000000 0x0000000000&#xA;RX_ADDR_P2-5    � = 0x00 0x00 0x00 0x00&#xA;TX_ADDR      = 0x0000000000&#xA;RX_PW_P0-6  � = 0x00 0x00 0x00 0x00 0x00 0x00&#xA;EN_AA        = 0x00&#xA;EN_RXADDR   � = 0x00&#xA;RF_CH        = 0x00&#xA;RF_SETUP    � = 0x00&#xA;CONFIG       = 0x00&#xA;DYNPD/FEATURE   � = 0x00 0x00&#xA;Data Rate    = 1MBPS&#xA;Model        = nRF24L01&#xA;CRC Length   = Disabled&#xA;PA Power     = PA_MIN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tried many times, no avail. Then I've came upon several threads talking about the different pins. Changed the pins to match Mega's MOSI, MISO, SCK, CE, CSN pins, no avail. I've tried exact same configuration with people who say that it's working, no avail. Then I've stumbled upon that Mega ironically can't supply enough current from the 3V3 pin (while Nano perfectly can) and it can't power the NRF24L01+ PA. I've tried drawing 3V from my power supply (my power supply has either 3 or 4.5 volts, I can't risk burning my transceiver with 4.5 volts). It still doesn't work, and it became extremely hot in seconds (the one attached to my nano doesn't heat up at all). I immediately turned it off, thought that I've burned something, swapped with the Nano's transceiver, and it (fortunatelly) works. So there's no problem with the NRF24L01+ PAs. Why would it not work with Mega (I've also tried the lowest power setting too), and why would it get extremely hot when attached to an external power supply? What else can I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I've added a 470uF decoupling capacitor to the receiving end (the one attached to Mega), it seems to be worse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very interesting observation: If I touch the receiver when it's not working, it starts receiving the signal excellently. If I let it go, signal is lost again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt; Nevermind the last &quot;when I touch...&quot; update, it appears to be related to wiring (haven't soldered them yet, just using jumper wires)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 3:&lt;/strong&gt; My initial assumption is correct, something happens when I touch the cables. Something more weird is going on. I soldered my module on a prototype board, and my module sometimes works even without CE pin plugged in. When I touch the cable, it transmits, and stops. Here, TX pin lighting up means it's receiving the signal (I'm writing data to serial). It receives the data (and yeah, the correct data) when I touch the CE pin's cable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gz7kO.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gz7kO.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How on Earth is this possible? Does the CE pin/cable (and myself) act as an antenna? Makes no sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 4:&lt;/strong&gt; If I plug that pin to 5V, the whole receiver starts working absolutely perfectly, with no errors/drops at all. But I can't get it: why? And would it overheat/short something?&lt;/p&gt;&#xA;" OwnerUserId="11617" OwnerDisplayName="Can Poyrazoğlu" LastEditorUserId="11617" LastEditDate="2015-08-05T14:58:06.363" LastActivityDate="2018-09-14T02:47:01.733" Title="NRF24L01+ PA not working with Arduino Mega (works with Nano)" Tags="|arduino-mega|nrf24l01+|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="13947" PostTypeId="2" ParentId="13945" CreationDate="2015-08-04T19:35:52.543" Score="1" Body="&lt;p&gt;The OpenLogger was designed to be paired with and Arduino Pro or Arduino Pro Mini and just log the serial output from one of those. You could theoretically use the OpenLogger itself to do the sensor reading and writing, however, the I2C pins that your sensor needs &lt;a href=&quot;https://www.sparkfun.com/datasheets/DevTools/Arduino/OpenLog-v11.pdf&quot; rel=&quot;nofollow&quot;&gt;haven't been broken out&lt;/a&gt; on the OpenLogger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means if you really wanted to make this happen, you would have to hand solder those pins and break them out yourself. After that the process is pretty straightforward. SparkFun provides both the &lt;a href=&quot;https://github.com/sparkfun/OpenLog/tree/master/firmware/OpenLog_v3&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt; and directions on &lt;a href=&quot;https://github.com/sparkfun/OpenLog/wiki/flashing-firmware&quot; rel=&quot;nofollow&quot;&gt;programming&lt;/a&gt; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If trying to break those out is a little too tricky, you can either pair it with one of those Arduino models and use it to read the data, or find another similar logger device that has more pins broken out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two answer the second part of your question, reading multiple sensors isn't a problem. Usually the way these sensors work is you send a request for data to them and they return the reading, so you would just request from the first sensor, request from the second sensor, write out to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write to two different files no problem eiteher. I would not however, recommend writing to two different files. Switching from one file to another, back and forth introduces a little extra overhead which will slow down your loop. In rocketry, things happen very fast, and you'll probably want keep your loop running as fast as possible. I would recommend just writing to a single file and include data from both sensors probably something along the lines of &lt;code&gt;time,accelX,accelY,accelZ,bar&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-08-04T20:04:24.783" LastActivityDate="2015-08-04T20:04:24.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13948" PostTypeId="1" AcceptedAnswerId="13949" CreationDate="2015-08-04T19:58:11.810" Score="1" ViewCount="1172" Body="&lt;p&gt;It is widely known that float arithmetic takes longer (that is, eats more cycles) than fixed-point (or integer, or bitwise arithmetic), and that surely is something to consider for speed- and time-critical applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: supposing I don't have any time-critical need (and I have enough program and RAM memory), should I be worried by any other disadvantage of using &lt;code&gt;float&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I wonder if the processor would be more power-hungry because of those extra CPU cycles.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE:   What will my application do meanwhile?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only goal of the application is to turn lights on and off (lots of them) based on push-button input. I am using &lt;code&gt;float&lt;/code&gt; to apply filtering to button inputs, in order to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=125297.0&quot; rel=&quot;nofollow&quot;&gt;debounce the buttons simulating a RC filter + schmitt-trigger&lt;/a&gt;. So the loop in pseudo-code would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read all inputs (digitalRead or direct port access);&lt;/li&gt;&#xA;&lt;li&gt;Filter the readings and decide if a button action has been detected;&lt;/li&gt;&#xA;&lt;li&gt;Set some control flags that determine which part of the cycle the lights are in;&lt;/li&gt;&#xA;&lt;li&gt;Check for elapsed time to actually turn blinkers on and off.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, since I plan to react to button input as realtime as possible, most time would be spent filtering (that is, performing floating point operations), since direct port access and flag-setting are supposed to be nearly instantaneous, right?&lt;/p&gt;&#xA;" OwnerUserId="8044" LastEditorUserId="10794" LastEditDate="2015-09-06T09:00:04.407" LastActivityDate="2015-09-06T09:00:04.407" Title="Float arithmetic vs. int arithmetic - is there any power penalty?" Tags="|power|avr|float|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13949" PostTypeId="2" ParentId="13948" CreationDate="2015-08-04T20:07:38.120" Score="4" Body="&lt;p&gt;It depends on what your processor is doing while it has no real work to do:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you put it to sleep, then yes, using floats will keep the CPU awake for a longer time and burn more energy.&lt;/li&gt;&#xA;&lt;li&gt;If you are instead doing busy-waits (e.g. with &lt;code&gt;delay()&lt;/code&gt;) it should make no difference, since the CPU is busy 100% of the time anyway.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: According to your update, it seems your program never&#xA;sleeps. Then I would expect no substantial difference in power&#xA;consumption between using floats or ints. As Majenko said, there can&#xA;theoretically be some small difference depending on the number of&#xA;transistor transitions involved in each instruction (and, I would add,&#xA;the capacitive loading of the involved transistors), but I do not expect&#xA;this to be very significant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really concerned about the consumption of your Arduino, I&#xA;would suggest you use it only for prototyping, then move your code to a&#xA;bare ATmega (or maybe even an ATtiny) chip. Also, add at least one call&#xA;to &lt;code&gt;sleep_mode()&lt;/code&gt; inside your main loop. Each such call will put your&#xA;CPU to sleep until the next timer interrupt, which typically happens&#xA;every 1024&amp;nbsp;µs. There is a lot more to say about power savings, see&#xA;for example this &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;excellent writeup by Nick&#xA;Gammon&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: When trying to minimize power consumption, one of the very&#xA;first things to do is figure out how much work has to be done, and make&#xA;sure your program never does more work than required. In your case, this&#xA;means you have to know how often your main loop should execute, and&#xA;prevent it from running more often than needed. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const unsigned long loop_period = 5;  // run the loop every 5 ms.&#xA;&#xA;void loop() {&#xA;&#xA;    /* Sleep while waiting for the next time slot. */&#xA;    static unsigned long last_time;&#xA;    while (millis() - last_time &amp;lt; loop_period)&#xA;        sleep_mode();&#xA;    last_time += loop_period;&#xA;&#xA;    /* Actual work goes here... */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the actual loop work takes significantly less time than the loop&#xA;period, your CPU will sleep most of the time, leading to significant&#xA;power savings. Then you can start digging into more advanced&#xA;power-saving techniques like those mentioned in the article linked&#xA;above.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-08-06T08:23:12.400" LastActivityDate="2015-08-06T08:23:12.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13950" PostTypeId="2" ParentId="13948" CreationDate="2015-08-04T20:20:14.090" Score="1" Body="&lt;p&gt;Yes, more power will (theoretically) be consumed.  That is, compared to doing nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Float operations will require more mathematical operations to perform compared with integer or fixed point.  That will mean more gates are being activated and deactivated etc, compared to doing nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would that increase in power be noticeable?  Probably not.  It'll be so tiny as to be negligible.  As Edgar Bonet has mentioned, if you are making use of sleep modes then the extra time taken to perform the float operations will impact the ratio of running to sleep time, but if all you are doing is a set of mathematical operations a few times a second and using the &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;delay()&lt;/code&gt; functions to control the timing then the difference will be so minimal you'll never notice it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect is more noticeable on a PC when you perform very complex operations (like 3D rendering) and the CPU gets hotter and the fan speeds up.  In this situation the CPU is entering an &lt;em&gt;idle&lt;/em&gt; state (like sleep, but less so) when it's not needing to perform any tasks which reduces both power consumption and heat dissipation.  When performing heavy tasks it has less time to be idle and so generates more heat. The more complex the operations the more transistors need to switch and so the more heat is dissipated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the power dissipation per op-code is not documented, but it should be possible to write some assembly code to execute a single instruction in a tight loop (start with NOP) and measure the current, then change that instruction for a different one and compare the current.  Using NOP as a baseline you should then be able to calculate the increase in current for each op-code.  Of course, the actual data the op-codes are operating on will also have a bearing on the power consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that would be pretty pointless unless you are budgeting for every single femtowatt of power.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-04T20:20:14.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13951" PostTypeId="2" ParentId="13938" CreationDate="2015-08-04T20:48:50.013" Score="1" Body="&lt;p&gt;I'm presuming this is I2C or SPI, because a Serial cable of 2.5 m should still work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can slow both I2C and SPI down.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the case of &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; you can call something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.setClockDivider(divider);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &quot;divider&quot; is one of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV2&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV4&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV8&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV16&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV32&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV64&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV128 &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The default is SPI_CLOCK_DIV4, so try a larger divider.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In the case of &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt; you can change the clock speed and the prescaler. The default frequency is 100 kHz, but you could make it slower.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TWBR   prescaler   Frequency&#xA;&#xA;  12       1       400   kHz  (the maximum supported frequency)&#xA;  32       1       200   kHz&#xA;  72       1       100   kHz  (the default)&#xA; 152       1        50   kHz&#xA;  78       4        25   kHz&#xA; 158       4        12.5 kHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, to run at half the frequency (50 kHz) use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Wire.begin ();&#xA;  TWBR = 152;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To run at 25 kHz you also need to change the prescaler, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Wire.begin ();&#xA;  TWBR = 78;  &#xA;  TWSR |= bit (TWPS0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the case of I2C make sure you have pull-up resistors on SDA and SCL in order to get a clean signal. 4.7 k is a reasonable value to try (for both of them) with the other ends connected to +5 V.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-04T20:48:50.013" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13952" PostTypeId="2" ParentId="13948" CreationDate="2015-08-04T21:15:13.433" Score="0" Body="&lt;p&gt;If you are interested in power saving, I think it would be more important to check that the standard Arduino library doesn't turn on HW blocks that you do not need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From an engineering perspective, though, the filter you are pursuing seems a bit overkill, if you only worry about bounces. Waiting for a reasonable amount of time after the first transition should be sufficient and would keep the code simpler to write, test and debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The mechanical switch is already a dampened system with its own intrinsic time constant.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-04T21:15:13.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13953" PostTypeId="1" CreationDate="2015-08-04T21:55:52.897" Score="-1" ViewCount="2857" Body="&lt;p&gt;I'm trying to control a large stepper motor with high frequency pulses (eventually around 4kHz), but what I get out of the simulink scope is super different from what the Arduino is putting out. I'm using this variable frequency PWM block: www.mathworks.com/matlabcentral/fileexchange/48563-variable-frequency-pwm-block&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LHwle.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LHwle.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(yes, I've tried it on pin 5/6, but if I do that there's no difference)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output from the Simulink scope (period of 0.01s):&lt;a href=&quot;https://i.stack.imgur.com/qxJLy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qxJLy.png&quot; alt=&quot;output from scope&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the Arduino is putting out pulses with a period of ~4 seconds. This is on pin 6 of the Uno, by the way. Why won't the Arduino output the same frequency as the Simulink program?&lt;/p&gt;&#xA;" OwnerUserId="11616" LastEditorUserId="11616" LastEditDate="2015-08-05T14:05:31.943" LastActivityDate="2016-05-06T08:58:04.207" Title="Arduino Uno &amp; Simulink - high frequency pulses" Tags="|arduino-uno|frequency|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13954" PostTypeId="1" CreationDate="2015-08-04T23:13:05.133" Score="1" ViewCount="514" Body="&lt;p&gt;I've been playing around with Arduino and understand that the standard runtime provides a single thread essentially.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if it is possible to write a thin layer (library) that allows one to write code that is non blocking and one where each task yields control manually which allows the master loop to implement some form of timesharing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Comments on existing frameworks that can allow me to write my programs this way&lt;/li&gt;&#xA;&lt;li&gt;Any comments on how hard implementing anything of this order of magnitude would be.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11569" LastEditorUserId="10794" LastEditDate="2015-08-04T23:38:50.807" LastActivityDate="2015-08-04T23:52:38.660" Title="Existence of a non blocking and task yield framework for Arduino programming" Tags="|programming|library|sketch|threads|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13955" PostTypeId="2" ParentId="13954" CreationDate="2015-08-04T23:39:30.233" Score="2" Body="&lt;p&gt;I would recommend &lt;a href=&quot;https://github.com/greiman/NilRTOS-Arduino&quot; rel=&quot;nofollow&quot;&gt;NilRTOS&lt;/a&gt;.&#xA;I like the fact that it's really minimal.&#xA;However, you might find that some libraries (which you would like to use) work in blocking mode and cannot be used with this RTOS, because they might do bad things (polling) or worse things (polling in interrupt context with other interrupts disabled).&#xA;But that will be the case regardless of the thread framework you choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to try also &lt;a href=&quot;http://www.femtoos.org/&quot; rel=&quot;nofollow&quot;&gt;femtoos&lt;/a&gt;.&#xA;I think that the code could be organized far better, which is one of the reasons I preferred NilRTOS.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-04T23:39:30.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13956" PostTypeId="2" ParentId="13954" CreationDate="2015-08-04T23:52:38.660" Score="2" Body="&lt;p&gt;My recommendation would be to simply code without needing blocking. I have examples &lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Petri Häkkinen coded a game - &lt;a href=&quot;https://www.youtube.com/watch?v=sLvgW_zb6bQ&quot; rel=&quot;nofollow&quot;&gt;Toorum's Quest&lt;/a&gt; - without using any real-time library. That game (on a Uno) has multiple sprites, TV output and sound effects, all interleaved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic technique is to know that you have multiple things you need to have done, from time to time, and check in the main loop if it is time to do one of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One issue with any sort of real-time library is, you only have limited resources. You need to be really aware, for example, of which bits of hardware are doing what (eg. timers, SPI, I2C, interrupt handlers, serial comms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even existing libraries suffer from the problem that one library may require (say) pin-change interrupts, and &quot;requisition&quot; the interrupt handlers needed for that, and another library also uses pin-change interrupts, and they cannot be linked together.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-04T23:52:38.660" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13957" PostTypeId="2" ParentId="13946" CreationDate="2015-08-05T01:38:21.697" Score="2" Body="&lt;p&gt;I have a NRF24L01 - not that exact model, mine looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f5V7b.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f5V7b.jpg&quot; alt=&quot;NRF24L01 with aerial&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin-outs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wg6a6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wg6a6.jpg&quot; alt=&quot;NRF24L01 pin-outs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hooked it up to my Mega2560 like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NRF24L01     Mega2560&#xA;----------   ----------------&#xA;&#xA;  VCC         3.3V pin&#xA;  Gnd         Gnd&#xA;  CSN         D10 &#xA;  CE          D9&#xA;  MOSI        D51 - (MOSI) &#xA;  SCK         D52 - (SCK)  &#xA;  IRQ         N/C&#xA;  MISO        D50 - (MISO)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used the &lt;a href=&quot;https://codeload.github.com/maniacbug/RF24/zip/master&quot; rel=&quot;nofollow noreferrer&quot;&gt;RF24 library&lt;/a&gt;. Then I hit a number of issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For one thing, the &quot;Getting Started&quot; sketch doesn't seem to work too well, even between two Unos, for reasons I haven't worked out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the &quot;pingpair&quot; sketch worked OK between two Unos. But &lt;strong&gt;not&lt;/strong&gt; when one device was moved to the Mega2560! I tried various things including a separate power supply, and moving the CSN/CE pins around, but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I had a look at Vcc/Gnd using the scope:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WvdeG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WvdeG.png&quot; alt=&quot;NRF24L01 Vcc&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's over half a volt of ripple! I soldered on a 0.1 µF capacitor between Vcc and Gnd on the NRF24L01 and the problems went away. Using the pingpair sketch I now have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Now sending 56...ok...Got response 56, round-trip delay: 23&#xA;Now sending 1080...ok...Got response 1080, round-trip delay: 21&#xA;Now sending 2103...ok...Got response 2103, round-trip delay: 21&#xA;Now sending 3126...ok...Got response 3126, round-trip delay: 21&#xA;Now sending 4148...ok...Got response 4148, round-trip delay: 22&#xA;Now sending 5171...ok...Got response 5171, round-trip delay: 22&#xA;Now sending 6194...ok...Got response 6194, round-trip delay: 22&#xA;Now sending 7217...ok...Got response 7217, round-trip delay: 22&#xA;Now sending 8240...ok...Got response 8240, round-trip delay: 21&#xA;Now sending 9263...ok...Got response 9263, round-trip delay: 21&#xA;Now sending 10286...ok...Got response 10286, round-trip delay: 21&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, my suggestion is a decoupling capacitor on the NRF24L01.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Extra&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I still had some weird issues where the above results actually came from a NRF24L01 &lt;strong&gt;without&lt;/strong&gt; the aerial. The one with the aerial had much more marginal results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the results &lt;strong&gt;with&lt;/strong&gt; the aerial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Now sending 181378...ok...Failed, response timed out.&#xA;Now sending 182581...ok...Failed, response timed out.&#xA;Now sending 183784...failed.&#xA;Failed, response timed out.&#xA;Now sending 185047...failed.&#xA;Failed, response timed out.&#xA;Now sending 186309...ok...Got response 186309, round-trip delay: 26&#xA;Now sending 187336...ok...Got response 187336, round-trip delay: 22&#xA;Now sending 188359...ok...Failed, response timed out.&#xA;Now sending 189561...ok...Got response 189561, round-trip delay: 22&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still, I think it is worth trying the decoupling capacitor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and why would it get extremely hot when attached to an external power supply? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Did you have the grounds connected?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-05T01:38:21.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13958" PostTypeId="2" ParentId="13948" CreationDate="2015-08-05T01:50:50.557" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The only goal of the application is to turn lights on and off (lots of them) based on push-button input. I am using float to apply filtering to button inputs, in order to debounce the buttons simulating a RC filter + schmitt-trigger. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using floats is &lt;strong&gt;way&lt;/strong&gt; overkill here. To debounce all you need to do is note when the switch changed state, and ignore further state changes during a certain interval, say 10 ms. It is even quite feasible to sleep during that debounce period. One of the watchdog timer intervals is 16 ms which would be about right for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, an application that turns lights on is hardly going to be one where you are worried about how much power floating point operations take. I would be 1000 times more worried about how much power the lights use.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-05T01:50:50.557" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13959" PostTypeId="2" ParentId="6709" CreationDate="2015-08-05T02:13:39.040" Score="0" Body="&lt;p&gt;What I am doing for similar is powering 7.2v to motorshield EXT_PWR and same to RAW pin of Arduino mini pro, where taking 5v out from vcc and input to motor shield 5v. It works for my car well.&lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2015-08-05T02:13:39.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13960" PostTypeId="1" CreationDate="2015-08-05T03:04:52.773" Score="1" ViewCount="162" Body="&lt;p&gt;How can I return a char array from a function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c[] = getFloat(val, valid);&#xA;&#xA;char getFloat(float val, bool valid){&#xA;      if(valid){&#xA;        char stringFloat[16];&#xA;        dtostrf(val, 10, 8, stringFloat);&#xA;        return stringFloat;&#xA;      } else Serial.print(&quot;No Float&quot;);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11152" LastActivityDate="2015-08-05T03:58:12.790" Title="Arrays and Functions" Tags="|arduino-ide|c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13961" PostTypeId="2" ParentId="13960" CreationDate="2015-08-05T03:10:20.520" Score="1" Body="&lt;p&gt;Allocate it in the heap. Don't forget to free it after.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;&#xA; ...&#xA;&#xA;char *c = getFloat(val, valid);&#xA;use(c);&#xA;free(c);&#xA;&#xA; ...&#xA;&#xA;char *getFloat(float val, bool valid){&#xA;  if(valid){&#xA;    char stringFloat[16], *ret;&#xA;    dtostrf(val, 10, 8, stringFloat);&#xA;    ret = strdup(stringFloat);&#xA;    return ret;&#xA;  } else {&#xA;    Serial.print(&quot;No Float&quot;);&#xA;    return NULL;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-05T03:10:20.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13962" PostTypeId="2" ParentId="13960" CreationDate="2015-08-05T03:58:12.790" Score="1" Body="&#xA;&#xA;&lt;p&gt;An alternative method would be to allocate the string &lt;strong&gt;statically&lt;/strong&gt; inside the function, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const char * getFloat(float val, bool valid){&#xA;      if (valid)&#xA;        {&#xA;        static char stringFloat[16];&#xA;        dtostrf(val, 10, 8, stringFloat);&#xA;        return stringFloat;&#xA;        }&#xA;      else &#xA;        return &quot;No Float&quot;;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we can use that string:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const char * c = getFloat(24.5678, true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However note that this is only good for one use &lt;strong&gt;at a time&lt;/strong&gt;! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would not work properly, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const char * c1 = getFloat(24.5678, true);&#xA;const char * c2 = getFloat(42.7654, true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now c1 and c2 both point to the same piece of memory, so only the last one would be correct. However this restriction may not matter to you. And it saves you having to free memory afterwards, and possibly saves you from heap fragmentation.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-05T03:58:12.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13963" PostTypeId="2" ParentId="9408" CreationDate="2015-08-05T05:56:09.330" Score="2" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My requirement of 125 kHz is satisfied, but I am just curious to know why the sketch not working as it should.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to my measurements, it is. Using this slightly modified version of your code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// A sketch that creates an 8 MHz, 50% duty cycle PWM and a 250 kHz,&#xA;// 6-bit resolution PWM with varying duty cycle (changes every 5 µs&#xA;// or about every period.&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;  pinMode(3, OUTPUT); // Output pin for OCR2B&#xA;  pinMode(5, OUTPUT); // Output pin for OCR0B&#xA;&#xA;  // Set up the 250 kHz output&#xA;  TCCR2A = bit(COM2A1) | bit(COM2B1) | bit(WGM21) | bit(WGM20);&#xA;  TCCR2B = bit(WGM22) | bit(CS20);&#xA;  OCR2A = 63;&#xA;  OCR2B = 31;&#xA;&#xA;  // Set up the 8 MHz output&#xA;  TCCR0A = bit(COM0A1) | bit(COM0B1) | bit(WGM01) | bit(WGM00);&#xA;  TCCR0B = bit(WGM02) | bit(CS00);&#xA;  OCR0A = 1;&#xA;  OCR0B = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the predicted 8 MHz output on pin 5:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xYt3y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xYt3y.png&quot; alt=&quot;8 MHz scope output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the 250 kHz output on pin 3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vTqVw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vTqVw.png&quot; alt=&quot;250 kHz scope output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="510" LastEditDate="2015-09-17T20:39:57.320" LastActivityDate="2015-09-17T20:39:57.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13964" PostTypeId="1" AcceptedAnswerId="18608" CreationDate="2015-08-05T08:04:26.250" Score="0" ViewCount="932" Body="&lt;p&gt;I'm trying to customize my Arduino Yún to work as an access-point (or hotspot) for providing services to clients directly connected and, alternatively, to work as a client on a wireless network for downloading resources from the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The access to such a wireless network is gained after the user submits a network SSID and password in the web control panel provided by Yún.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I recover from a user submitting a wrong password? At the moment the Yún stays stuck without any connection, and thus is unreachable via SSH to attempt any recover.&lt;/p&gt;&#xA;" OwnerUserId="11622" LastEditorUserId="510" LastEditDate="2017-11-05T14:10:48.490" LastActivityDate="2017-11-05T14:11:15.547" Title="Recover from wrong Wi-Fi password on Arduino Yún" Tags="|wifi|arduino-yun|wireless|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13965" PostTypeId="2" ParentId="9408" CreationDate="2015-08-05T08:17:47.557" Score="2" Body="&lt;p&gt;To your original question: You can reduce the delay, but there's a limit to how small the delay can be.&lt;/p&gt;&#xA;&lt;p&gt;Two reasons: Firstly, the loop() function does have some overhead, and secondly the code that you write takes time to execute. This is why the hardware PWM timer is valuable - it generates the pulses without much software intervention.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I used the code below and it resulted in 125 kHz and 1.6 MHz (measured with a CRO, not simulation).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is really just to add to Nick's answer...&#xA;(To understand what's going on, you need to refer to the datasheet. Based on your questions, I'm assuming you haven't stared at it long enough.)&lt;/p&gt;&#xA;&lt;h3&gt;In the first case: 125 kHz.&lt;/h3&gt;&#xA;&lt;p&gt;I am not sure if you're aware, but you're using a special mode of &amp;quot;Fast PWM&amp;quot; which is slightly different from the analogWrite() provided in Arduino.&lt;/p&gt;&#xA;&lt;p&gt;In this mode, your PWM period is determined by the time it takes your timer counter to match the value in OCR2A register. This means that with a 16 MHz clock, and your output is toggled at a rate of 16 MHz/63 = 250 kHz (roughly).&lt;/p&gt;&#xA;&lt;p&gt;So far so good, but what does the CRO see? The CRO considers a period to be made up of both high and low signal. It takes TWO 250 kHz cycles to toggle the signal up and down. Hence, the reading shows 125 kHz.&lt;/p&gt;&#xA;&lt;p&gt;As to why the rolling would make your reading difficult: Think what kind of wave will appear when OCR0B = 0. ;-)&lt;/p&gt;&#xA;&lt;h3&gt;Case 2: 8 MHz&lt;/h3&gt;&#xA;&lt;p&gt;The same applies in the seccond case, and you should expect a 16 MHz cycle that toggles the signal up and down (which gives a 8 MHz reading on the CRO). As to why you are getting 1.6 MHz - that's an odd case. Can you post your CRO reading?&lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-17T20:42:08.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13966" PostTypeId="1" CreationDate="2015-08-05T09:38:50.713" Score="0" ViewCount="231" Body="&lt;p&gt;I am lakshman a mechanical engineer,i have a question that is there any possibility of connecting ACCELEROMETER + ARDUINO UNO + GSM module together???&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so that i can take the output value from Accelerometer so that to make a call to a preprogrammed number???&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plz help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11623" LastActivityDate="2016-02-01T15:27:03.633" Title="is there any possibility of connecting ACCELEROMETER + ARDUINO UNO + GSM module together?" Tags="|arduino-uno|gsm|accelerometer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13967" PostTypeId="2" ParentId="13966" CreationDate="2015-08-05T10:03:52.140" Score="1" Body="&lt;p&gt;Yes, that is perfectly possible.  Typically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Accelerometer is either an analog, SPI or I2C interface.&lt;/li&gt;&#xA;&lt;li&gt;GSM is usually a UART interface&lt;/li&gt;&#xA;&lt;li&gt;The Arduino UNO has all four interfaces (analog, SPI, I2C and UART) available on separate pins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The rest is just a SMOP.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-05T10:03:52.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13968" PostTypeId="2" ParentId="13964" CreationDate="2015-08-05T10:06:48.937" Score="0" Body="&lt;p&gt;The simplest option is to provide a serial console interface which will either give full access to the OS (pipe through &lt;em&gt;Console&lt;/em&gt;) or a menu driven interface that sends instructions to the main chip (through &lt;em&gt;Bridge&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The user would then connect to the USB interface and use a terminal program to access the configuration in whatever way you have chosen.  This could either be via options within your installed sketch, or by uploading a special sketch through the USB connection.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-05T10:06:48.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13969" PostTypeId="2" ParentId="8917" CreationDate="2015-08-05T11:13:23.937" Score="0" Body="&lt;p&gt;You can not directly convert the reading to ppm because you do not know what value means what ppm. You'd need at least one calibration point to calculate how many particles per million there are. The sensor is both affected by temperature and humidity so you might wish to compensate that too. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-02-02T11:01:00.213" LastActivityDate="2016-02-02T11:01:00.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13970" PostTypeId="1" CreationDate="2015-08-05T11:36:20.970" Score="0" ViewCount="83" Body="&lt;p&gt;If I run the following code, I get the correct output, and the path is displayed on the serial monitor. However when I run the code together with the commented out portion (in the code below) I don't get any output; even the output that is printed before this code doesn't print completely. Why is that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have figured it out that this happens when the dijkstra functions runs more than once. But it shouldn't happen like this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   int *path1 = NULL;&#xA;    int no_of_nodes_1;&#xA;    dijkstra(graph, startingNode1, end1_start2, &amp;amp;path1, no_of_nodes_1);&#xA;&#xA;    /*int *path2 = NULL;&#xA;    int no_of_nodes_2;&#xA;    dijkstra(graph, end1_start2, end2_start3, &amp;amp;path2, no_of_nodes_2);&#xA;&#xA;    int *path3 = NULL;&#xA;    int no_of_nodes_3;&#xA;    dijkstra(graph, end2_start3, endingNode3, &amp;amp;path3, no_of_nodes_3);&#xA;        */&#xA;        delete graph;&#xA;&#xA;&#xA;    Serial.println();&#xA;&#xA;    Serial.println( &quot;PATH 1:&quot;);&#xA;    for (int k = 0; k &amp;lt; no_of_nodes_1; k++){&#xA;        Serial.print(path1[k]);Serial.print(&quot;..&quot;);&#xA;        }&#xA;&#xA;/*&#xA;    Serial.println();&#xA;        Serial.println( &quot;PATH 2:&quot;);&#xA;    for (int x = 0; x &amp;lt; no_of_nodes_2; x++){&#xA;        Serial.print(path2[x]);Serial.print(&quot;..&quot;);        &#xA;    }&#xA;&#xA;    Serial.println();&#xA;    Serial.println( &quot;PATH 3:&quot;);&#xA;    for (int y = 0; y &amp;lt; no_of_nodes_3; y++){&#xA;        Serial.print(path3[y]);Serial.print(&quot;..&quot;);&#xA;    }&#xA;&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;::UPDATE::&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/******************************************************************************/&#xA;    void getNextNode(int node, const int&amp;amp; src, const int predecessor[264], int temp_path[], int&amp;amp; i){&#xA;&#xA;        i = 1;&#xA;&#xA;        if (node == src)&#xA;        {&#xA;            temp_path[i] = src;&#xA;        }&#xA;&#xA;        else if (predecessor[node] == -1)&#xA;        {&#xA;                Serial.println(&quot;No path exists&quot;);&#xA;        }&#xA;        else {&#xA;            getNextNode(predecessor[node], src, predecessor, temp_path, i);&#xA;            temp_path[i] = node;&#xA;            i++;&#xA;        }&#xA;&#xA;        return;&#xA;    }&#xA;/********************************************************************************/&#xA;    int* savePath(int predecessor[264], const int&amp;amp; src, const int&amp;amp; targetnode, int &amp;amp; numofnodes){&#xA;&#xA;        int temp_path[200];&#xA;        temp_path[0] = src;&#xA;        int i;&#xA;&#xA;        if (targetnode == src)&#xA;        {&#xA;            temp_path[1] = src;&#xA;        }&#xA;        else&#xA;        {&#xA;            getNextNode(targetnode, src, predecessor, temp_path, i);&#xA;        }&#xA;&#xA;        numofnodes = i;&#xA;        int *path = new int[i];&#xA;&#xA;        for (int k = 0; k &amp;lt; i; k++){&#xA;            path[k] = temp_path[k];&#xA;        }&#xA;&#xA;        return path;&#xA;&#xA;&#xA;    }&#xA; /****************************************************************************/   &#xA;    void dijkstra(struct Graph* graph, int src, int target, int **path, int&amp;amp; numofnodes)&#xA;    {&#xA;        // The main function that calulates distances of shortest paths from src to all&#xA;        // vertices. It is a O(ELogV) function&#xA;&#xA;        int V = graph-&amp;gt;V;// Get the number of vertices in graph&#xA;        int* dist = new int[V];      // dist values used to pick minimum weight edge in cut&#xA;&#xA;        int predecessor[264]; //array to save nearest nodes&#xA;&#xA;        // minHeap represents set E&#xA;        struct MinHeap* minHeap = createMinHeap(V);&#xA;&#xA;        // Initialize min heap with all vertices. dist value of all vertices&#xA;        for (int v = 0; v &amp;lt; V; ++v)&#xA;        {&#xA;            dist[v] = INT_MAX;&#xA;            minHeap-&amp;gt;array[v] = newMinHeapNode(v, dist[v]);&#xA;            minHeap-&amp;gt;pos[v] = v;&#xA;            predecessor[v] = -1;&#xA;        }&#xA;&#xA;        // Make dist value of src vertex as 0 so that it is extracted first&#xA;        minHeap-&amp;gt;array[src] = newMinHeapNode(src, dist[src]);&#xA;        minHeap-&amp;gt;pos[src] = src;&#xA;        dist[src] = 0;&#xA;        decreaseKey(minHeap, src, dist[src]);&#xA;&#xA;        // Initially size of min heap is equal to V&#xA;        minHeap-&amp;gt;size = V;&#xA;&#xA;        // In the followin loop, min heap contains all nodes&#xA;        // whose shortest distance is not yet finalized.&#xA;        while (!isEmpty(minHeap))&#xA;        {&#xA;            // Extract the vertex with minimum distance value&#xA;            struct MinHeapNode* minHeapNode = extractMin(minHeap);&#xA;            int u = minHeapNode-&amp;gt;v; // Store the extracted vertex number&#xA;&#xA;            // Traverse through all adjacent vertices of u (the extracted&#xA;            // vertex) and update their distance values&#xA;            struct AdjListNode* pCrawl = graph-&amp;gt;array[u].head;&#xA;            while (pCrawl != NULL)&#xA;            {&#xA;                int v = pCrawl-&amp;gt;dest;&#xA;&#xA;                // If shortest distance to v is not finalized yet, and distance to v&#xA;                // through u is less than its previously calculated distance&#xA;                if (isInMinHeap(minHeap, v) &amp;amp;&amp;amp; dist[u] != INT_MAX &amp;amp;&amp;amp;&#xA;                    /*pCrawl-&amp;gt;weight*/1 + dist[u] &amp;lt; dist[v])&#xA;                {&#xA;                    dist[v] = dist[u] + 1 /*pCrawl-&amp;gt;weight*/; // 1 is the weight of the node&#xA;                    predecessor[v] = u;&#xA;                    // update distance value in min heap also&#xA;                    decreaseKey(minHeap, v, dist[v]);&#xA;                }&#xA;                pCrawl = pCrawl-&amp;gt;next;&#xA;            }&#xA;        }&#xA;&#xA;        delete[] dist;&#xA;        delete minHeap;&#xA;        *path = savePath(predecessor, src, target, numofnodes);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10955" LastEditorUserId="6936" LastEditDate="2017-01-19T08:17:03.210" LastActivityDate="2017-10-26T15:39:38.323" Title="Wrong code ouput, when the specific function runs more than once" Tags="|serial|programming|arduino-due|debugging|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13972" PostTypeId="2" ParentId="13806" CreationDate="2015-08-05T14:46:51.520" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;to increase the speed I added some static variables to it. Is the way&#xA;  I am doing this bad? ... Is it better to avoid statics? If so why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I use this technique too ... IMHO it is neither good nor bad.  In a logger, for instance, all the wall clock time stamp information has to be looked up (perhaps time(0)), and formatted at least once in any given second.  I use function static variables to prevent duplicating that effort for the 10's to 100's (or even more on a really fast machine) of log entries that happen in the &lt;strong&gt;same&lt;/strong&gt; second.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect your saying &quot;to increase speed&quot; is what the other answers focus on, and many contributors in SE jump on the 'premature optimization' concept. I think you unintentionally misled them.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe your audience would respond more positively to the term &lt;strong&gt;'memoize'&lt;/strong&gt; ... this technique avoids some work (when it can).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, just to be complete - Wikipedia agrees with you:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In computing, memoization is an optimization technique used primarily&#xA;  to speed up computer programs by storing the results of expensive&#xA;  function calls and returning the cached result when the same inputs&#xA;  occur again.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note 1. I think memoization implies that there is work that need not be duplicated every time through the function (sometimes only initialization) ... thus there often will be an if-clause to skip over the un-necessary work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 2. static is not the only way to hold onto previous values, but is probably somewhat more appropriate for a function when you do not want a class object (to hold the previous values). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 3. 'memoize' has impact because it avoids work, and this speeds up the whole system.&lt;/p&gt;&#xA;" OwnerUserId="11625" LastEditorUserId="11625" LastEditDate="2015-08-05T16:47:48.670" LastActivityDate="2015-08-05T16:47:48.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13974" PostTypeId="1" CreationDate="2015-08-05T15:30:02.273" Score="2" ViewCount="573" Body="&lt;p&gt;I'm building a weather station that sends the data to a webserver via GET request. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if you guys can look into my code and help me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked all over the internet and can't find what's wrong. I'm using an Arduino mega, an Arduino/Telefonica GSM shield and an EE sim card. Thank you very much!&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;GSM gsmAccess;&#xA;GPRS gprs;&#xA;GSMClient client;&#xA;&#xA;const boolean gprsCheck = true;&#xA;&#xA;char server[] = &quot;&quot;;&#xA;&#xA;int value = 112358132134;&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(19200);&#xA;&#xA;  if(gprsCheck) {&#xA;&#xA;    boolean notCon = true;&#xA;&#xA;    Serial.println(&quot;Establishing connection...&quot;);&#xA;&#xA;    while(notCon) {&#xA;&#xA;      if((gsmAccess.begin(&quot;&quot;) == GSM_READY) &amp;amp; (gprs.attachGPRS(&quot;everywhere&quot;,&quot;eesecure&quot;,&quot;secure&quot;) == GPRS_READY)) {&#xA;&#xA;        notCon = false;&#xA;&#xA;        Serial.println(&quot;GPRS connection successful.&quot;);&#xA;        Serial.println(&quot;&quot;);&#xA;      }&#xA;&#xA;      else {&#xA;&#xA;        Serial.println(&quot;GPRS connection failed. Trying again.&quot;);&#xA;        Serial.println(&quot;&quot;);&#xA;&#xA;        delay(1000);&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  if(!client.available() &amp;amp;&amp;amp; !client.connected()) {&#xA;&#xA;    client.stop();&#xA;  }&#xA;&#xA;  if (client.connect(server, 80)) {&#xA;&#xA;    Serial.println(&quot;Connection successful.&quot;);&#xA;&#xA;    client.print( &quot;GET /add.php?&quot;);&#xA;    client.print(&quot;value=&quot;);&#xA;    client.print(value);&#xA;    client.print(&quot; HTTP/1.1\n&quot;);&#xA;    client.print(&quot;Host: &quot;);&#xA;    client.print(server); &#xA;    client.print(&quot;\nConnection: close\n\n&quot;);&#xA;    client.stop();&#xA;    client.stop();&#xA;&#xA;    Serial.println(&quot;Data sent.&quot;);&#xA;  }&#xA;&#xA;  else {&#xA;&#xA;    Serial.println(&quot;Error.&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11627" LastEditorUserId="37523" LastEditDate="2019-08-07T15:24:19.560" LastActivityDate="2019-08-07T15:24:19.560" Title="Make a GET Request GPRS" Tags="|arduino-mega|gsm|web-server|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="13975" PostTypeId="1" AcceptedAnswerId="13990" CreationDate="2015-08-05T18:09:26.327" Score="1" ViewCount="2752" Body="&lt;p&gt;I'm porting the &lt;a href=&quot;http://www.waveshare.com/w/upload/5/5e/SH1106.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;SH1106&lt;/a&gt; driver to netmf and have found several libraries that more or less accomplish the same thing. A few were much easier to understand and had less abstraction so I followed those. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried the U8glib with my arduino and it works just fine. The ported display driver yields these results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vwQEM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vwQEM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;inverted:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tkkMc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tkkMc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you're looking at is the screen right after the initialization and attempting to draw a filled circle. You can see the bottom of the circle at the top of the screen. Somehow the origin or page is shifted, but I don't fully understand what's going on. I can send the invert display command and that works as well and turn the display on and off. My initialization code is this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;public void init()&#xA;{&#xA;    resetPin.Write(true);&#xA;    Thread.Sleep(1); // VDD (3.3V) goes high at start, &#xA;    resetPin.Write(false); // bring reset low&#xA;    Thread.Sleep(10); // wait 10ms&#xA;    resetPin.Write(true); // bring out of reset&#xA;&#xA;    dcPin.Write(DisplayCommand);&#xA;&#xA;    SendCommandB(0xAE);    /*display off*/&#xA;&#xA;    SendCommandB(0x02);    /*set lower column address*/&#xA;    SendCommandB(0x10);    /*set higher column address*/&#xA;&#xA;    SendCommandB(0x41);//0x40);    /*set display start line*/&#xA;    SendCommandB(0xB0);    /*set page address*/&#xA;    SendCommandB(0x81);    /*contract control*/&#xA;    SendCommandB(0x80);//contrast);    /*128*/&#xA;    SendCommandB(0xA1);    /*set segment remap*/&#xA;    SendCommandB(0xA6);//invertSetting);    /*normal / reverse*/&#xA;    SendCommandB(0xA8);    /*multiplex ratio*/&#xA;    SendCommandB(0x3F);    /*duty = 1/32*/&#xA;    SendCommandB(0xAD);    /*set charge pump enable*/&#xA;    SendCommandB(0x8B);     /*external VCC   */&#xA;    SendCommandB(0x30);    // | Vpp);    /*0X30---0X33  set VPP   9V liangdu!!!!*/&#xA;    SendCommandB(0xC8);    /*Com scan direction*/&#xA;    SendCommandB(0xD3);    /*set display offset*/&#xA;    SendCommandB(0x00);   /*   0x20  */&#xA;    SendCommandB(0xD5);    /*set osc division*/&#xA;    SendCommandB(0x80);&#xA;    SendCommandB(0xD9);    /*set pre-charge period*/&#xA;    SendCommandB(0x1F);    /*0x22*/&#xA;    SendCommandB(0xDA);    /*set COM pins*/&#xA;    SendCommandB(0x12);&#xA;    SendCommandB(0xDB);    /*set vcomh*/&#xA;    SendCommandB(0x40);&#xA;    SendCommandB(0xAF);    /*display ON*/&#xA;&#xA;    // Switch to 'data' mode&#xA;    dcPin.Write(Data);&#xA;    this.ClearScreen();&#xA;    this.Refresh();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have two methods to &quot;refreshing&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;public virtual void Refresh()&#xA;        {&#xA;            Spi.Write(displayBuffer);&#xA;        }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Send buffer to display&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;&#xA;public void Display()&#xA;        {&#xA;            //set column address&#xA;            dcPin.Write(DisplayCommand);&#xA;            SendCommandB(0x21);&#xA;            SendCommandB(0);&#xA;            SendCommandB((byte)(Width - 1));&#xA;&#xA;            //set page address&#xA;            SendCommandB(0x22);&#xA;            SendCommandB(0);&#xA;            SendCommandB((byte)(_pages - 1));&#xA;            dcPin.Write(Data);&#xA;&#xA;            //Spi.Write(displayBuffer);&#xA;&#xA;            for (ushort i = 0; i &amp;lt; displayBuffer.Length; i = (ushort)(i + 16))&#xA;            {&#xA;                //Spi.Write(displayBuffer);&#xA;                SendArray(displayBuffer, i, (ushort)(i + 16));&#xA;            }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this point I'm a little lost. My hunch is something to do with paging and or display RAM. I'm looking for some insight here on how to fix this as I know there's a lot of experience here with these displays. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11075" LastEditorUserId="11075" LastEditDate="2015-08-06T13:16:45.093" LastActivityDate="2015-08-06T13:16:45.093" Title="Porting SH1106 Oled Driver - 128 x 64 / 128 x 32 Screen is garbled but partially responsive" Tags="|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13978" PostTypeId="2" ParentId="3175" CreationDate="2015-08-05T19:54:01.050" Score="1" Body="&lt;p&gt;Immediately upon a function call entering the function, the first code that is executed is to decrement the stackpointer by an amount equal to the space required for temporary variables internal to the function. The brilliant thing about this is that all functions therefore become re-entrant and recursive, because their variables are built on the calling program's stack.&#xA;That means if an interrupt halts execution of one program and transfers execution to another, it too can call the same function without them interfering with eachother.&lt;/p&gt;&#xA;" OwnerUserId="11631" LastActivityDate="2015-08-05T19:54:01.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13980" PostTypeId="1" CreationDate="2015-08-05T19:20:05.787" Score="0" ViewCount="1266" Body="&lt;p&gt;I'm building an small CNC using &lt;code&gt;Protoneer CNC shield&lt;/code&gt;, &lt;code&gt;GRBL&lt;/code&gt; and &lt;code&gt;Arduino UNO&lt;/code&gt;.&lt;br&gt;&#xA;With this I need to connect the board to PC and send G-Code from there.&lt;br&gt;&#xA;My question is, is it possible to use the arduino itself to control the CNC shield?&lt;br&gt;&#xA;If yes how?&lt;br&gt;&#xA;If not is there any other way to send commands other than USB (as Arduino's USB port is not a host)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="7556" OwnerDisplayName="4r1y4n" LastEditorUserId="7556" LastEditDate="2015-08-07T00:15:46.080" LastActivityDate="2015-08-07T00:15:46.080" Title="Controlling Protoneer CNC shield without PC" Tags="|arduino-uno|shields|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13981" PostTypeId="2" ParentId="13980" CreationDate="2015-08-05T20:44:40.247" Score="1" Body="&lt;p&gt;An Arduino can talk directly to a shield, independent of a PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will, however, need a way to tell your Arduino to do it's thing. Depending on what you want it to do, this may require nothing (&quot;send this pre-defined g-code as soon as you are turned on&quot;), a memory card of some sort, one or more pushbuttons, or even a small screen. I have seen several 3d printers with memory cards, buttons (usually up/down/select/back), and a small screen that, once set up, can print anything you can load onto a memory card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other forms of communication, too - ethernet, wifi, etc., which you can use, with appropriate shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, of course, you still have to design your object - 3d graphics are well beyond the ability of an Arduino, so there will still be some form of computer involved.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-05T20:44:40.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13982" PostTypeId="2" ParentId="3175" CreationDate="2015-08-05T21:24:00.503" Score="1" Body="&#xA;&#xA;&lt;p&gt;I've been trying quite hard to make an example bit of code to demonstrate what the excellent answers here are saying, without success so far. The reason is that the compiler aggressively optimizes things. So far my tests have not used the stack at all, even with local variables in a function. The reasons are:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The compiler may &lt;strong&gt;in-line&lt;/strong&gt; the function call, thus the return address might not be pushed onto the stack at all. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void foo (byte a)&#xA;      {&#xA;      digitalWrite (13, a);&#xA;      }&#xA;    void loop ()&#xA;      {&#xA;      foo (5);&#xA;      }&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler turns that into:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void loop ()&#xA;      {&#xA;      digitalWrite (13, 5);&#xA;      }&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No function call, no stack used.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The compiler may pass arguments in &lt;strong&gt;registers&lt;/strong&gt;, thus saving it having to push them onto the stack. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;digitalWrite (13, 1);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compiles into:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;158:  8d e0         ldi r24, 0x0D ; 13&#xA;15a:  61 e0         ldi r22, 0x01 ; 1&#xA;15c:  0e 94 05 01   call  0x20a ; 0x20a &amp;lt;digitalWrite&amp;gt;&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arguments are put into registers and thus no stack is used (apart from the return address for calling digitalWrite).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Local variables may well be put into registers, again saving having to use RAM. This not only saves RAM but is faster.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The compiler optimizes away variables you don't use. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;void foo (byte a)&#xA;   {&#xA;   unsigned long bar [100];&#xA;   bar [1] = a;&#xA;   digitalWrite (9,  bar [1]);&#xA;   }&#xA; void loop ()&#xA;   {&#xA;   foo (3);&#xA;   }  // end of loop&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that's &lt;strong&gt;got&lt;/strong&gt; to allocate 400 bytes for &quot;bar&quot; doesn't it? Nope:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00000100 &amp;lt;_Z3fooh&amp;gt;:&#xA;   100: 68 2f         mov r22, r24&#xA;   102: 89 e0         ldi r24, 0x09 ; 9&#xA;   104: 0e 94 cd 00   call  0x19a ; 0x19a &amp;lt;digitalWrite&amp;gt;&#xA;   108: 08 95         ret&#xA; 0000010a &amp;lt;loop&amp;gt;:&#xA;   10a: 83 e0         ldi r24, 0x03 ; 3&#xA;   10c: 0e 94 80 00   call  0x100 ; 0x100 &amp;lt;_Z3fooh&amp;gt;&#xA;   110: 08 95         ret&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler optimized away the &lt;strong&gt;entire array&lt;/strong&gt;! It can tell that we are really just doing a &lt;code&gt;digitalWrite (9, 3)&lt;/code&gt; and that is what it generates.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Moral of the story: Don't try to out-think the compiler.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-05T21:24:00.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13983" PostTypeId="1" AcceptedAnswerId="13987" CreationDate="2015-08-05T21:39:22.100" Score="25" ViewCount="42722" Body="&lt;p&gt;Short and simple: What is the power consumption for an ATtiny85 running at 1 MHz and 8 MHz using the internal clock? Not using any sleep modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have googled a lot and can't find any info on this. I ask because I want to know if it is worth using 1 MHz to increase battery life.&lt;/p&gt;&#xA;" OwnerUserId="3464" LastEditorUserId="6936" LastEditDate="2015-08-11T06:55:39.980" LastActivityDate="2015-08-11T06:55:39.980" Title="ATtiny85: Power consumption vs clock speed" Tags="|power|attiny|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="13984" PostTypeId="1" AcceptedAnswerId="13986" CreationDate="2015-08-05T21:39:41.390" Score="1" ViewCount="59" Body="&lt;p&gt;I have an arduino webserver that uses the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(F(&quot;HTTP/1.1 200 OK&quot;));&#xA;client.println(F(&quot;Content-Type: text/html&quot;));&#xA;client.println();&#xA;client.println(F(&quot;&amp;lt;HTML&amp;gt;&amp;lt;HEAD&amp;gt;&quot;));&#xA;...&#xA;if (fan1Toggle == 0)&#xA;    client.print(F(&quot;Fan1&amp;lt;font color=\&quot;red\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&amp;lt;a href=\&quot;/?fan1on\&quot;&amp;gt;On&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&quot;));&#xA;else&#xA;    client.print(F(&quot;Fan1&amp;lt;font color=\&quot;green\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&amp;lt;a href=\&quot;/?fan1off\&quot;&amp;gt;Off&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&quot;));&#xA;&#xA;if (fan2Toggle == 0)&#xA;    client.print(F(&quot;Fan2&amp;lt;font color=\&quot;red\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&amp;lt;a href=\&quot;/?fan2on\&quot;&amp;gt;On&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&quot;));&#xA;else&#xA;    client.print(F(&quot;Fan2&amp;lt;font color=\&quot;green\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&amp;lt;a href=\&quot;/?fan2off\&quot;&amp;gt;Off&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&quot;));&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The page is pretty long, allowing the user to toggle over a dozen different switches. Some of the code checks to see the state of a certain switch, and then displays a green or red bullet (&quot;&amp;amp;#8226&quot;, like &amp;#8226;) on the page if the switch is on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the code for the colored bullet is repeating, I wanted to make a function for it. Then I would just call (for example) &quot;&lt;code&gt;displayBullet(fan1Toggle);&lt;/code&gt;&quot;, and it would determine if fan1 was on or off, and display the correct color depending on the state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to create the following function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void displayBullet(int toggle) {&#xA;if (toggle == 0)     //switch is off, so display red bullet&#xA;    client.print(F(&quot;&amp;lt;font color=\&quot;red\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&quot;));&#xA;else    //switch is on, so display green bullet&#xA;    client.print(F(&quot;&amp;lt;font color=\&quot;green\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&quot;));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But then I got an error saying that &quot;'client' is not declared in this scope&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to work around that error, so that I can get the displayBullet() function I want? Or is this something that can't be shortened like this, because the &quot;client&quot; function has to be inside the main loop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="11174" LastEditDate="2015-08-05T21:44:58.843" LastActivityDate="2015-08-05T21:52:27.657" Title="Is there any way to separate this short code into its own function? (webserver, trying to use client.print outside of main loop)" Tags="|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13986" PostTypeId="2" ParentId="13984" CreationDate="2015-08-05T21:52:27.657" Score="2" Body="&#xA;&#xA;&lt;p&gt;You can pass client to the function by reference, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void displayBullet(EthernetClient &amp;amp; client, int toggle) &#xA;  {&#xA;  if (toggle == 0)     //switch is off, so display red bullet&#xA;    client.print(F(&quot;&amp;lt;font color=\&quot;red\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&quot;));&#xA;  else    //switch is on, so display green bullet&#xA;    client.print(F(&quot;&amp;lt;font color=\&quot;green\&quot;&amp;gt;&amp;amp;#8226;&amp;lt;/font&amp;gt;&quot;));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it knows about &lt;code&gt;client&lt;/code&gt;. Make sure you pass client when you call it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;displayBullet(client, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-05T21:52:27.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="13987" PostTypeId="2" ParentId="13983" CreationDate="2015-08-05T21:59:09.950" Score="51" Body="&lt;p&gt;The datasheet shows that current decreases at lower frequencies. Around &lt;strong&gt;1 mA&lt;/strong&gt; at 1 MHz running at 5 V. More like 5 mA at 8 MHz running at 5 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sJkkV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sJkkV.png&quot; alt=&quot;Supply current vs frequency&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can save quite a bit by using lower voltages as well, as you can see. For really big savings use a sleep mode. Read about &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To amplify on my remarks, you should be able to get &lt;strong&gt;200 nA&lt;/strong&gt; consumption at 3.5 V in sleep mode with no watchdog timer. That will still respond to interrupts, such as closing a switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oagxo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oagxo.png&quot; alt=&quot;Supply current with watchdog disabled&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you need to do things periodically you can enable the watchdog, and then get around &lt;strong&gt;5 µA&lt;/strong&gt; consumption at 3.5 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZPVOo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZPVOo.png&quot; alt=&quot;Supply current with watchdog enabled&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is so much less current than the 1 mA mentioned above, that it is well worth exploring running in power-down mode, where possible.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-06T06:00:25.120" LastActivityDate="2015-08-06T06:00:25.120" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13988" PostTypeId="2" ParentId="13953" CreationDate="2015-08-06T04:37:00.983" Score="0" Body="&lt;p&gt;It seems clear from what you have described that this is a Simulink bug.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why won't the Arduino output the same frequency as the Simulink program?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino can output quite a lot of frequencies. I have a &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;page about Arduino timers&lt;/a&gt; which describes them in some detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However since Simulink is generating the code for the Arduino (which we are not being shown) and since it claims to be generating 0.01 s, and the code it is generating does not do this, that is a bug in Simulink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you contact their customer support.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could attempt to program the hardware timers yourself. The page I linked could be a good starting point for such an exercise.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-06T04:37:00.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13990" PostTypeId="2" ParentId="13975" CreationDate="2015-08-06T11:13:19.907" Score="1" Body="&lt;p&gt;While your initialization routine looks fine to me (comparing to the datasheet and as evidenced by the fact the display turns on), what doesn't look right is your drawing routine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//set column address&#xA;dcPin.Write(DisplayCommand);&#xA;SendCommandB(0x21);&#xA;SendCommandB(0);&#xA;SendCommandB((byte)(Width - 1));&#xA;&#xA;//set page address&#xA;SendCommandB(0x22);&#xA;SendCommandB(0);&#xA;SendCommandB((byte)(_pages - 1));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands 0x21 and 0x22 don't correspond to any commands I can see in the datasheet.  They look more like commands more commonly seen with ILIxxxx or SSDxxxx screens to create an &quot;addressable window&quot; from 0,0 to Width-1, _pages-1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should be using the same commands you used in the setup routine to set the current col / page coordinate in RAM to write to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands &lt;code&gt;(0x00 | (col &amp;amp; 0x0F))&lt;/code&gt; and &lt;code&gt;(0x10 | (col &amp;gt;&amp;gt; 4))&lt;/code&gt; set the column position, and &lt;code&gt;(0xB0 | (page &amp;amp; 0x0F))&lt;/code&gt; set the page number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then write all 128 bytes for the current page before moving on to the next page.  This means you will have to do it a page at a time, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (ushort page = 0; page &amp;lt; 4; page++) {&#xA;&#xA;    // Set the current RAM pointer to the start of the currently&#xA;    // selected page.&#xA;    dcPin.Write(DisplayCommand);&#xA;    sendCommandB(0x00); // Set column number 0 (low nibble)&#xA;    sendCommandB(0x10); // Set column number 0 (high nibble)&#xA;    sendCommandB(0xB0 | (page &amp;amp; 0x0F)); // Set page number&#xA;&#xA;    // Send a single page (128 bytes) of data.&#xA;    // Without knowing the rest of your program I don't know the right&#xA;    // data sending routines to use, so I made them up. Change it to&#xA;    // do it how your program expects.  Maybe with your SendArray&#xA;    // function.&#xA;&#xA;    dcPin.Write(DisplayData);&#xA;    for (ushort col = 0; col &amp;lt; 128; col++) {&#xA;        sendDataB(displayBuffer[page * 128 + col]);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this method is very similar to how the KS0108 GLCD drivers work.  Each byte of the page represents 8 pixels on the screen so the screen, at 32 pixels high, is split into 4 pages, where each page is 8 pixels, or one byte, high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The effect you are currently seeing is because you are never changing the current page number (0) so you are always writing your data to the first page.  This loops around multiple times, so you end up writing all 4 pages to the same strip of the display ending up with the last page being displayed, which is the last 8 lines of your display data.  The rest of the display is never being touched and just contains whatever random data was in the RAM at power-on.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-06T11:20:10.737" LastActivityDate="2015-08-06T11:20:10.737" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="13991" PostTypeId="1" AcceptedAnswerId="13992" CreationDate="2015-08-06T11:51:46.593" Score="0" ViewCount="2148" Body="&lt;p&gt;i recently purchased a DHT22's and tried to get it to work using &lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;Adafruit's DHT library&lt;/a&gt; on Github.&#xA;When i compile it with a Arduino DUE, it gives me the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\Moz\Documents\Arduino\libraries\DHT-sensor-library-master\DHT.cpp: In constructor 'DHT::DHT(uint8_t, uint8_t, uint8_t)':&#xA;C:\Users\Moz\Documents\Arduino\libraries\DHT-sensor-library-master\DHT.cpp:14:9: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]&#xA;   _port = digitalPinToPort(pin);&#xA;         ^&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It compiles on a Arduino Uno but not on the DUE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the reason for this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Below is the example code i use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DHT.h&quot;&#xA;&#xA;#define DHTPIN 2     // what pin we're connected to&#xA;&#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;DHTxx test!&quot;);&#xA;  dht.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  delay(2000);&#xA;  float h = dht.readHumidity();&#xA;  float t = dht.readTemperature();&#xA;  float f = dht.readTemperature(true);&#xA;&#xA;  if (isnan(h) || isnan(t) || isnan(f)) {&#xA;    Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // Compute heat index in Fahrenheit (the default)&#xA;  float hif = dht.computeHeatIndex(f, h);&#xA;  // Compute heat index in Celsius (isFahreheit = false)&#xA;  float hic = dht.computeHeatIndex(t, h, false);&#xA;&#xA;  Serial.print(&quot;Humidity: &quot;);&#xA;  Serial.print(h);&#xA;  Serial.print(&quot; %\t&quot;);&#xA;  Serial.print(&quot;Temperature: &quot;);&#xA;  Serial.print(t);&#xA;  Serial.print(&quot; *C &quot;);&#xA;  Serial.print(f);&#xA;  Serial.print(&quot; *F\t&quot;);&#xA;  Serial.print(&quot;Heat index: &quot;);&#xA;  Serial.print(hic);&#xA;  Serial.print(&quot; *C &quot;);&#xA;  Serial.print(hif);&#xA;  Serial.println(&quot; *F&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1378" LastActivityDate="2016-01-12T10:10:50.623" Title="Adafruit DHT22 Library + Arduino Due not compiling?" Tags="|arduino-due|library|compile|adafruit|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13992" PostTypeId="2" ParentId="13991" CreationDate="2015-08-06T11:54:59.140" Score="1" Body="&lt;p&gt;That library uses direct pin manipulation to make things faster.  However the Due is a completely different architecture to the Uno, so direct pin manipulation is done differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library would have to be written specifically to do it in the two different ways and select between them depending on which board is chosen for the compilation.  This hasn't been done, and it's unlikely it would ever be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is exactly why &lt;code&gt;digitalWrite()&lt;/code&gt;, &lt;code&gt;shiftIn()&lt;/code&gt;, &lt;code&gt;shiftOut()&lt;/code&gt; et al exists, so that you don't get these kind of problems.  By choosing not to use them Adafruit have basically decided that their library will never work on a Due.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-06T11:54:59.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13993" PostTypeId="1" CreationDate="2015-08-06T12:49:41.943" Score="0" ViewCount="644" Body="&lt;p&gt;I want to control AC bulb with Arduino, 5v-relay.&#xA;My connections are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iiZRK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iiZRK.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define RELAY1  7&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(RELAY1, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  digitalWrite(RELAY1,LOW); // Turns ON Relays 1&#xA;  Serial.println(&quot;Light OFF&quot;);&#xA;  delay(15000); // Wait 5 seconds&#xA;  digitalWrite(RELAY1,HIGH); // Turns Relay Off&#xA;  Serial.println(&quot;Light ON&quot;);&#xA;  delay(20000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Red LED is on according to AC bulb.&lt;/li&gt;&#xA;&lt;li&gt;Power LED (Green colored one) is also on as I have given 5v supply from Arduino.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The issues are&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Bulb is not following the delay given in the code. The output for the above code is 20sec ON - 15sec OFF -20sec ON - 15sec OFF- 20sec ON -15sec OFF -  1sec ON - 20sec ON - 15sec OFF etc. means apart from 20,15 sec duration there is a duration of 1sec is coming in between as noise. What might be the reason?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On monitor also, only first 3 actions are getting printed after that no printing is observed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;==&gt;The relay I am using is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KBLdr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KBLdr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11518" LastEditorUserId="46" LastEditDate="2015-10-23T10:12:22.197" LastActivityDate="2019-09-18T12:24:45.943" Title="Issues in interfacing relay with Arduino" Tags="|arduino-uno|relay|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="13994" PostTypeId="1" CreationDate="2015-08-06T13:13:00.063" Score="0" ViewCount="96" Body="&lt;pre&gt;&lt;code&gt;volatile byte _incomingFlag = 0;&#xA;&#xA;void onIncoming () {&#xA;    _incomingFlag = 1;&#xA;    Serial.println(F(&quot;You got an interrupt&quot;));&#xA;    mySerial.println(&quot;ATH0&quot;);&#xA;}   &#xA;&#xA;void setup () {&#xA;    /* First Start the module */&#xA;    Serial.begin(9600);&#xA;    Serial.println(F(&quot;Initializing module...&quot;));&#xA;&#xA;    powerOn();&#xA;&#xA;    mySerial.begin(9600);&#xA;&#xA;    sendcommand(F(&quot;AT&quot;), F(&quot;OK&quot;), 1000);&#xA;    sendcommand(F(&quot;AT+CLIP=1&quot;), F(&quot;OK&quot;), 1000);&#xA;    sendcommand(F(&quot;AT+CMGF=1&quot;), F(&quot;OK&quot;), 1000);&#xA;&#xA;    /* We need to attach ringing Interrupt */&#xA;    attachInterrupt(M_RING_INTERRUPT, onIncoming, FALLING);&#xA;&#xA;    delay(100);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (_incomingFlag == 1) {&#xA;        manageIncoming();&#xA;        Serial.print(F(&quot;_incomingFlag: &quot;));&#xA;        Serial.println(_incomingFlag);&#xA;    } else  {&#xA;        Serial.println(_incomingFlag);&#xA;        Serial.println(F(&quot;not getting value&quot;));&#xA;    }&#xA;    get_currentLocation();&#xA;    send_Location();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to check the value of &lt;code&gt;incomingFlag&lt;/code&gt; from the &lt;code&gt;loop()&lt;/code&gt; . When I get a call or an SMS the interrupt function is getting executed and &lt;code&gt;incomingFlag&lt;/code&gt; is set to 1 but I am not getting that value from the &lt;code&gt;loop()&lt;/code&gt;. Everytime it's getting 0 if I check the value while the &lt;code&gt;send_Location&lt;/code&gt; function is executing (data uploading part). How can I access the value of &lt;code&gt;incomingFlag&lt;/code&gt; from the main &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11643" LastEditorUserId="11086" LastEditDate="2015-08-07T20:51:30.787" LastActivityDate="2015-08-07T20:51:30.787" Title="Interrupt variable not getting called while executing another part" Tags="|arduino-uno|arduino-ide|c|interrupt|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="13996" PostTypeId="1" AcceptedAnswerId="13997" CreationDate="2015-08-06T16:34:34.633" Score="2" ViewCount="2001" Body="&lt;p&gt;In the example below, I have two functions that write numbers to two different files on an SD card. I'm using the &lt;a href=&quot;https://github.com/greiman/SdFat&quot; rel=&quot;nofollow&quot;&gt;SdFat library&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can combine the two functions into one, so that I can call (for example): &lt;code&gt;writeToFile(int t, FileName &quot;filename1.txt&quot;);&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example below, to write a value to the &quot;temperature.txt&quot; file, I would like to be able to call: &lt;code&gt;writeToFile(7, &quot;temperature.txt&quot;);&lt;/code&gt; In my sketch I have about a dozen functions that are writing to a dozen different files, so it would be very handy to be able to combine them into one function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the main part I'm stuck on is I have no idea what the filename variable would be, or how to pass the filename to the function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SdFat.h&amp;gt;&#xA;SdFat sd;&#xA;&#xA;void setup() {&#xA;  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {&#xA;    sd.initErrorHalt();&#xA;  }&#xA;&#xA;  setTemperature(7);&#xA;  setFanSpeed(4);&#xA;}&#xA;&#xA;void setTemperature(int t) {&#xA;  SdFile rdfile(&quot;temperature.txt&quot;, O_WRITE);&#xA;  rdfile.rewind();&#xA;  rdfile.println(t);&#xA;  rdfile.close();&#xA;}&#xA;&#xA;void setFanSpeed(int t) {&#xA;  SdFile rdfile(&quot;fanspeed.txt&quot;, O_WRITE);&#xA;  rdfile.rewind();&#xA;  rdfile.println(t);&#xA;  rdfile.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="6936" LastEditDate="2015-08-11T12:07:49.483" LastActivityDate="2015-08-11T12:07:49.483" Title="How to pass a filename to a function? What type of variable is the filename?" Tags="|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="13997" PostTypeId="2" ParentId="13996" CreationDate="2015-08-06T16:42:53.827" Score="5" Body="&lt;p&gt;String literals are of type &lt;code&gt;const char *&lt;/code&gt;. Ordinary &lt;code&gt;char *&lt;/code&gt;s can be passed to it though; the &lt;code&gt;const&lt;/code&gt; means that the compiler will make sure that the function doesn't attempt to change the contents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setFileParameter(const char *filename, int value)&#xA;{&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-06T16:42:53.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="13998" PostTypeId="1" AcceptedAnswerId="22471" CreationDate="2015-08-06T17:29:20.230" Score="3" ViewCount="2814" Body="&lt;p&gt;I installed OS X El Capitan beta on my Macbook. Now my Nano-sized Chinese Arduino operating on CH340 chip reboots the laptop when USB is unplugged. While plugged, it works fine, I can upload sketches and send/receive data via Serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried reinstalling the CH340 driver and running the following command as per &lt;a href=&quot;https://www.reddit.com/r/arduino/comments/3dfr2e/ch340g_arduinos_with_osx_el_capitan/&quot; rel=&quot;nofollow&quot;&gt;this solution&lt;/a&gt; and it didn't help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1 rootless=0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I appreciate any ideas...&lt;/p&gt;&#xA;" OwnerUserId="10837" LastActivityDate="2018-04-25T08:20:51.217" Title="Arduino Nano with CH340 reboots on OS X El Capitan" Tags="|arduino-nano|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="13999" PostTypeId="2" ParentId="13994" CreationDate="2015-08-06T21:24:55.760" Score="1" Body="&lt;pre&gt;&lt;code&gt;volatile byte _incomingFlag = 0;       &#xA; void onIncoming () {&#xA;             _incomingFlag = 1;&#xA;            Serial.println(F(&quot;You got an interrupt&quot;));&#xA;            mySerial.println(&quot;ATH0&quot;);&#xA;&#xA;&#xA;        }   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regardless of what your purpose is there, you &lt;strong&gt;cannot successfully do serial prints inside an ISR&lt;/strong&gt;. All bets are off if you do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact you are doing two prints - is one SoftwareSerial?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you must have a debugging &quot;flag&quot; turn on an LED. Doing serial printing requires interrupts to be on, and they are off inside an ISR. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You may get the display once, and therefore you think it works. As soon as the serial buffer fills up (probably 64 bytes) then it will just block indefinitely. Your message &quot;You got an interrupt&quot; is already 22 bytes if you count the trailing carriage-return/linefeed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;More detailed explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In your main loop, every time through it, you are printing either:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_incomingFlag: 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;not getting value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore the serial buffer will be &lt;strong&gt;definitely full&lt;/strong&gt; (or almost full). It can't empty the buffer if you are cramming this stuff into it every time through loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have an incoming call. You set _incomingFlag to 1, then try to do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Serial.println(F(&quot;You got an interrupt&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That blocks, because if can't fit all that into the output buffer, and the program then hangs, because the buffer is not emptied inside an ISR.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-06T22:41:54.260" LastActivityDate="2015-08-06T22:41:54.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14000" PostTypeId="2" ParentId="10335" CreationDate="2015-08-06T23:41:50.793" Score="-1" Body="&lt;p&gt;It's difficult to answer this without seeing any code, but I will take a wild guess and assume you are not using any sort of FFT processing on the input. You could try looking into &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT?action=AttachFile&amp;amp;do=view&amp;amp;target=ArduinoFFT2.zip&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; library. Alternately, people seem to have good luck with &lt;a href=&quot;http://elm-chan.org/works/akilcd/report_e.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; one too.&lt;/p&gt;&#xA;" OwnerUserId="11506" LastActivityDate="2015-08-06T23:41:50.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14001" PostTypeId="2" ParentId="13053" CreationDate="2015-08-07T02:39:22.947" Score="1" Body="&lt;p&gt;Many vehicles with manual transmission use two push rods or cables to transmit gear selection to the gearbox. It may be easier to detect the position of those rods/cables than to attempt to filter out the g-forces involved in a moving vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use the ratio of vehicle speed to engine revs (if you can retrieve these from OBDII in your vehicle). Given that these two are directly related when a specific gear is selected and the clutch is engaged, a simple division should give you a ratio you could use to decide which gear is selected.&lt;/p&gt;&#xA;" OwnerUserId="4007" LastActivityDate="2015-08-07T02:39:22.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14002" PostTypeId="1" AcceptedAnswerId="14003" CreationDate="2015-08-07T05:06:24.320" Score="0" ViewCount="6285" Body="&lt;p&gt;I'm trying to flash the Marlin Firmware to my Prusa i3 3D Printer, which uses Melzi 2.0 board. Melzi is a variation of Sanguino, and Sanguino is a variation of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the version I'm using of Marlin (&lt;a href=&quot;https://github.com/MarlinFirmware/Marlin&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;, development branch) only works with Arduino Mega. I saw that the file &lt;code&gt;pins_RAMPS_13.h&lt;/code&gt; says the following (line 15-17):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if !defined(__AVR_ATmega1280__) &amp;amp;&amp;amp; !defined(__AVR_ATmega2560__)&#xA;   #error Oops!  Make sure you have 'Arduino Mega' selected from the 'Tools -&amp;gt; Boards' menu.&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I tried to make this part to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if !defined(__AVR_ATmega1280__) &amp;amp;&amp;amp; !defined(__AVR_ATmega2560__) &amp;amp;&amp;amp; !defined(__AVR_Melzi_ATmega1284p16mhz__)&#xA;   #error Oops!  Make sure you have 'Arduino Mega' selected from the 'Tools -&amp;gt; Boards' menu.&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody know if there's another repository made for the Melzi board?&lt;br&gt;&#xA;Or if I should use another firmware, like Repetier (I tried, fail)?&lt;br&gt;&#xA;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="8592" LastActivityDate="2015-08-07T06:49:49.063" Title="Uploading Marlin Firmware To Melzi-ATmega1284p" Tags="|arduino-mega|c++|firmware|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14003" PostTypeId="2" ParentId="14002" CreationDate="2015-08-07T06:49:49.063" Score="1" Body="&lt;p&gt;It looks like the Marlin firmware supports two versions of the Melzi board, although it isn't clear if it specifically includes the 2.0 version. The best thing to do is just try it. In the &lt;code&gt;Configuration.h&lt;/code&gt; file find the section where it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MOTHERBOARD&#xA;  #define MOTHERBOARD BOARD_ULTIMAKER&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now replace &lt;code&gt;BOARD_ULTIMAKER&lt;/code&gt; with &lt;code&gt;BOARD_MELZI_1284&lt;/code&gt; and try that. If that doesn't work you can try just &lt;code&gt;BOARD_MELZI&lt;/code&gt;. If neither of those work, you are out of luck, unless you are willing to dig in and do the pin mappings yourself.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-07T06:49:49.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14004" PostTypeId="2" ParentId="12687" CreationDate="2015-08-07T07:12:56.930" Score="2" Body="&lt;p&gt;Did you make sure the battery is charged? Does it have enough voltage to power the board? Remember that Arduino has internal voltage regulator, so you need something little more than 5V in order to get it working okay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Comment by bpinhosilva re-purposed as an answer so this will stop showing up as unanswered).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;@bpinhosilva you are right, the battery was not supplying enough power to make arduino work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please accept this so that the number of unanswered questions goes down. :)&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-07T07:12:56.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14005" PostTypeId="2" ParentId="13998" CreationDate="2015-08-07T07:20:26.473" Score="1" Body="&lt;p&gt;The command you ran only disables driver signing verification, which means OSX stops blocking it. If it is crashing it is likely to be either a bug in OSX, or a bug in the driver. My guess is it is a bug in the driver and you'll probably have to wait until they release an updated version that is compatible with El Capitan.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-07T07:20:26.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14006" PostTypeId="2" ParentId="5169" CreationDate="2015-08-07T07:24:05.853" Score="2" Body="&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/jprodgers/LoLshield&quot; rel=&quot;nofollow noreferrer&quot;&gt;LoL shield library&lt;/a&gt; now supports exactly&lt;sup&gt;1&lt;/sup&gt; what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you choose the &lt;code&gt;LoLShield_FontTest&lt;/code&gt; example it will scroll &quot;HELLO WORLD!&quot; across your shield. Change your text as required.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;static const char test[]=&quot;HELLO WORLD!   &quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Example of the word &quot;WORLD&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HauiP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HauiP.jpg&quot; alt=&quot;Hello World&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in higher contrast to make it more obvious:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BoRrB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BoRrB.jpg&quot; alt=&quot;Hello World high contrast&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(1) Except for the potentiometer. In the example code where it automatically scrolls:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  for (int8_t x=DISPLAY_COLS, i=0; ; x--) {&#xA;    LedSign::Clear();&#xA;    for (int8_t x2=x, i2=i; x2&amp;lt;DISPLAY_COLS;) {&#xA;       int8_t w = Font::Draw (test[i2], x2, 0);&#xA;       x2 += w, i2 = (i2+1) % strlen(test);&#xA;       if (x2 &amp;lt;= 0)  // off the display completely?&#xA;         x = x2, i = i2;&#xA;       }&#xA;       delay(500);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would amend it to do an analogRead to set the position of &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example of using a potentiometer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Based on the Charliplexing example, the code below uses a pot connected to A0 to control the scroll position:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Charliplexing.h&quot;&#xA;#include &quot;Myfont.h&quot;&#xA;&#xA;char * test = &quot;full ASCII charset: $ % &amp;amp; ! [ ] { }&quot;;&#xA;int len; // length of this string&#xA;&#xA;void setup()                    // run once, when the sketch starts&#xA;{&#xA;  LedSign::Init();&#xA;  len = strlen (test);&#xA;}&#xA;&#xA;void loop()                     // run over and over again&#xA;{&#xA;  // start empty&#xA;  LedSign::Clear(); &#xA;&#xA;  int potReading = analogRead (0);  // read A0&#xA;  int i = map (potReading, 0, 1023, 0, len * 6);  // starting pixel&#xA;&#xA;  for (int j = 0; j &amp;lt; 14; j += 6) &#xA;    Myfont::Draw(j, test[(i + j) / 6]); &#xA;&#xA;  delay(100);   // hold that image for a moment&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-12-14T22:32:35.827" LastActivityDate="2016-12-14T22:32:35.827" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14007" PostTypeId="1" CreationDate="2015-08-07T07:27:14.750" Score="0" ViewCount="5009" Body="&lt;p&gt;I want to make a HUD Helmet similar to the one shown in Ironman movies. Please suggest me some links and parts needed for this type of project&lt;/p&gt;&#xA;" OwnerUserId="11475" LastActivityDate="2018-05-15T00:48:48.360" Title="Heads Up Display Helmet With arduino" Tags="|arduino-uno|" AnswerCount="4" CommentCount="1" ClosedDate="2018-05-15T08:49:12.453" ContentLicense="CC BY-SA 3.0" />
  <row Id="14009" PostTypeId="2" ParentId="13808" CreationDate="2015-08-07T08:39:36.027" Score="1" Body="&lt;p&gt;It looks like &lt;code&gt;RcvdEnd&lt;/code&gt; never gets reset back to zero because &lt;code&gt;RcvdConf&lt;/code&gt; is set to zero when &lt;code&gt;RcvdEnd&lt;/code&gt; is 2, which means it will never get to 3 and reset it (at least not when you are expecting it to). I'm not sure how many new lines you are supposed to be checking for but the way it is set up now or is looking for two on the first message, and three for every message thereafter. You might want to rework the logic and maybe move where that value gets reset.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-07T08:39:36.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14010" PostTypeId="1" AcceptedAnswerId="14023" CreationDate="2015-08-07T09:07:10.773" Score="0" ViewCount="756" Body="&lt;p&gt;I've got an Arduino Mega, an Arduino Nano, two NRF24L01 wireless modules and a old Multiplex Transmitter system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to get the PWM signal and send it to the other arduino which should control the servos and the motor controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a good instruction or know somebody how to do that easily?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need it for a rc plane and the range should be 1km.&lt;/p&gt;&#xA;" OwnerUserId="8644" LastActivityDate="2015-08-07T22:58:11.733" Title="how to build rc transmitter and receiver with an old rc transmitter" Tags="|arduino-mega|pwm|arduino-nano|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14011" PostTypeId="1" CreationDate="2015-08-07T09:21:53.570" Score="-1" ViewCount="934" Body="&#xA;&#xA;&lt;p&gt;I get the data from a sensor which is in RS485. I am using RS485-RS232 Converter. Then its given to uart usb converter and I get the data in TTL. I am able to receive the data in uart (hyperterminal). I have connected the TX, RX, GND pins to 10, 11, GND pins of Arduino UNO.&#xA;I want to communicate it with Arduino UNO through SoftSerial and here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define rxPin 10&#xA;#define txPin 11&#xA;&#xA;SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);&#xA;&#xA;void setup() {   &#xA;    pinMode(rxPin, INPUT);&#xA;    pinMode(txPin, OUTPUT);&#xA;    mySerial.begin(9600);&#xA;    Serial.begin(9600);  &#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;    while (mySerial.available() &amp;gt; 0) {&#xA;        Serial.println(&quot;Data is available&quot;);&#xA;        Serial.println(mySerial.read());&#xA;    }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm not able to see the data on serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="11659" LastEditorUserId="11086" LastEditDate="2015-08-07T17:02:55.230" LastActivityDate="2017-03-04T04:14:34.773" Title="Arduino Software serial not showing the received data" Tags="|arduino-uno|softwareserial|datalogging|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="14012" PostTypeId="2" ParentId="14007" CreationDate="2015-08-07T11:31:04.987" Score="0" Body="&lt;p&gt;You can't.  You can't even simulate it or even begin to approach that style of display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try it.  Print something out then hold it in front of your face the distance the visor is away from you.  Now try and focus on it.  You can't.  The human eyes are unable to focus that closely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to focus the vision through lenses (which is what VR headsets do) or directly project through prisms and lenses into the eye (which is what Google Glass does) in order for you to be able to see the images you generate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do it if you required the user to wear special glasses to focus their vision, however they then wouldn't be able to focus on anything else much and would keep walking into things and tripping over their own feet.  The rest of the world would just be a complete blur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole depiction of those kind of HUD displays are impractical.  In military HUD systems the image is either fed via a single eyepiece (and it takes lots of practice and brain training to get the brain to superimpose the two images), or it's projected on to the cockpit window.  The only way it could be done as they depict it would be to directly project the images into both eyes (to create a 3D effect) superimposing it over the natural light entering the eyes.  That would then of course mean that it would be invisible to anyone except the user, so still wouldn't be quite the same.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-07T11:31:04.987" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="14013" PostTypeId="2" ParentId="13243" CreationDate="2015-08-07T11:46:14.643" Score="1" Body="&lt;p&gt;I hate to be the wet blanket here but maybe the job is too simple for this much technology. Wouldn't a suitably placed curved mirror give you the information you need?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or put a PIR sensor around the corner where it can see the car, and put the flashing light where you can see it while backing.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-07T11:46:14.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14014" PostTypeId="1" AcceptedAnswerId="14015" CreationDate="2015-08-07T11:56:07.437" Score="1" ViewCount="178" Body="&lt;p&gt;Will this code read the values properly ?&#xA;Using &lt;a href=&quot;https://github.com/sparkfun/MPU-9150_Breakout/blob/master/firmware/MPU6050/MPU6050.h&quot; rel=&quot;nofollow&quot;&gt;MPU6050.h&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MPU6050.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  MPU6050.initialize();&#xA;}&#xA;&#xA;void loop() {&#xA;  MPU6050.getWaitForExternalSensorEnabled();&#xA;  float X = getRotationX();&#xA;  float Y = getRotationY();&#xA;  float Z = getRotationZ();&#xA;  Serial.print(&quot;X:&quot;);&#xA;  Serial.println(X);&#xA;  Serial.print(&quot;Y:&quot;);&#xA;  Serial.println(Y);&#xA;  Serial.print(&quot;Z:&quot;);&#xA;  Serial.println(Z);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please be patient. I know nothing about gyroscope's working.&#xA;I'm stupid.&lt;/p&gt;&#xA;" OwnerUserId="11660" LastActivityDate="2015-08-07T12:13:07.917" Title="Will it work ? MPU6050 Gyro etc. etc. module" Tags="|arduino-uno|accelerometer|gyroscope|magnetometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14015" PostTypeId="2" ParentId="14014" CreationDate="2015-08-07T12:07:17.090" Score="1" Body="&lt;p&gt;Code would normally look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MPU6050.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;MPU6050 mpu;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  mpu.initialize();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  //what is this doing for you?&#xA;  mpu.getWaitForExternalSensorEnabled();&#xA;&#xA;  if(mpu.getIntDataReadyStatus() == 1) { &#xA;        float X = mpu.getRotationX();&#xA;        float Y = mpu.getRotationY();&#xA;        float Z = mpu.getRotationZ();&#xA;        Serial.print(&quot;X:&quot;);&#xA;        Serial.println(X);&#xA;        Serial.print(&quot;Y:&quot;);&#xA;        Serial.println(Y);&#xA;        Serial.print(&quot;Z:&quot;);&#xA;        Serial.println(Z);    &#xA;  } else&#xA;  {&#xA;        Serial.println(&quot;MPU not ready&quot;);    &#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-08-07T12:13:07.917" LastActivityDate="2015-08-07T12:13:07.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14016" PostTypeId="1" CreationDate="2015-08-07T18:54:18.867" Score="0" ViewCount="693" Body="&lt;p&gt;I tried to to upload a hex file I generated for the Arduino Nano using avrdude but I keep getting the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_2_ReceiveMessage(): timeout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First the arduino board stops doing whatever it is programmed to do, in this case powering a vibration motor .&#xA;Then this error keeps showing up in delays of around 10 seconds.&#xA;That error is then followed by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_recv(): read error: The I/O operation has been aborted because of either a thread exit or an application re&#xA;quest.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which appears to be caused by me pulling out the USB cable after waiting a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="10904" LastEditorUserId="25788" LastEditDate="2016-09-15T07:58:08.563" LastActivityDate="2016-09-15T07:58:08.563" Title="Unable to upload code to the Arduino Nano" Tags="|arduino-nano|avr|avrdude|flash|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14017" PostTypeId="2" ParentId="13998" CreationDate="2015-08-07T19:01:47.503" Score="1" Body="&lt;p&gt;It turns out I didn't have the latest Beta. I now updated to the latest and now my CH340-based Arduino doesn't get detected at all! Pretty much in line with everyone else complaining all over internet.&lt;/p&gt;&#xA;" OwnerUserId="10837" LastActivityDate="2015-08-07T19:01:47.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14018" PostTypeId="1" CreationDate="2015-08-07T19:04:01.257" Score="3" ViewCount="8066" Body="&lt;p&gt;Since I updated to El Capitan Public Beta, my Arduino Uno doesn't show up in the serial devices list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The System Information utility shows an Arduino connected on the USB port (as 'Communication Device'), but a serial port does not get created at &lt;code&gt;/dev&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board works on Windows and the previous versions of El Capitan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem persists on beta 6.&lt;/p&gt;&#xA;" OwnerUserId="11648" LastEditorUserId="11648" LastEditDate="2015-09-06T16:57:53.847" LastActivityDate="2016-08-10T15:34:12.890" Title="Arduino not detected On El Capitan Public Beta 6" Tags="|arduino-uno|serial|ftdi|osx|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14019" PostTypeId="2" ParentId="14016" CreationDate="2015-08-07T21:32:55.653" Score="2" Body="&lt;p&gt;I suggest you disconnect the motor while you are uploading. The power it is using, or the electrical noise it is generating, may intefere with the uploading process.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-07T21:32:55.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14020" PostTypeId="1" AcceptedAnswerId="14021" CreationDate="2015-08-07T21:50:39.657" Score="0" ViewCount="7633" Body="&#xA;&#xA;&lt;p&gt;I have a Yun that accepts commands via the bridge (note the below code is part of a very simple virtual keyboard that accepts commands then runs &lt;code&gt;Keyboard.println&lt;/code&gt; on them:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;HardwareSerial *port;&#xA;&#xA;void setup() {&#xA;  port = &amp;amp;Serial1;&#xA;  port-&amp;gt;begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (port-&amp;gt;available()) {&#xA;    String cmd = port-&amp;gt;readString();&#xA;&#xA;    if(cmd.length() &amp;gt; 1){&#xA;      String instruction = cmd;&#xA;      int arg_comma_index = 0;&#xA;      arg_comma_index = instruction.indexOf(&quot;,&quot;);&#xA;      String func = instruction.substring(0, arg_comma_index);&#xA;      String args = instruction.substring(arg_comma_index + 1, instruction.length() + 1 );&#xA;&#xA;      Keyboard.begin();&#xA;      Keyboard.println(args);&#xA;      Keyboard.end();&#xA;    }&#xA;    port-&amp;gt;read(); // Try to throw away whatever's left to prevent looping (which is still happening).&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I send it a short string:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first time, immediately after starting the sketch, it works.&lt;/li&gt;&#xA;&lt;li&gt;The second time, it works but loops anywhere from 1-5 times.&lt;/li&gt;&#xA;&lt;li&gt;The third time, it loops more times still.&lt;/li&gt;&#xA;&lt;li&gt;If I leave the device running (even if not operating it), the number of times it loops goes up &lt;em&gt;when&lt;/em&gt; I finally do send it an instruction. I'm seeing 20-75 loops after less than 15 minutes of uptime.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Clearly the loops where no instruction is being received are still building up something here. I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Restarting the port each &lt;code&gt;void loop()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Flushing the port at the top and/or bottom of each &lt;code&gt;void loop()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Setting &lt;code&gt;cmd = &quot;&quot;&lt;/code&gt; at the end of each &lt;code&gt;void loop()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Checking &lt;code&gt;peek()&lt;/code&gt;, &lt;code&gt;available()&lt;/code&gt;, and &lt;code&gt;readString()&lt;/code&gt; - after I send it one instruction, they return the same values every single time they loop.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10236" LastEditorUserId="10794" LastEditDate="2015-08-08T01:30:02.757" LastActivityDate="2015-08-09T00:35:00.553" Title="How to empty the buffer for Serial port?" Tags="|serial|arduino-yun|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14021" PostTypeId="2" ParentId="14020" CreationDate="2015-08-07T21:56:32.007" Score="1" Body="&lt;p&gt;It's quite simple to empty the serial buffer - you just read all the data that is in the buffer and throw it away:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (port-&amp;gt;available()) {&#xA;    port-&amp;gt;read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-07T21:56:32.007" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14022" PostTypeId="2" ParentId="14018" CreationDate="2015-08-07T22:43:28.790" Score="4" Body="&lt;p&gt;As noted &lt;a href=&quot;https://arduino.stackexchange.com/questions/13998/arduino-nano-with-ch340-reboots-on-os-x-el-capitan/14005#14005&quot;&gt;elsewhere&lt;/a&gt;, there have been plenty of problems with the CH340 driver and the OSX El Capitan betas, culminating into the driver flat out not working in the latest beta. This is either a bug with OSX or a bug in the driver. I would lean towards this being a bug in the driver, which hasn't been updated since late 2013.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other 3rd party drivers that might work on El Capitan. &lt;a href=&quot;https://www.mac-usb-serial.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;mac-usb-serial.com&lt;/a&gt; is the most reliable looking one that I could find, and it does appear to be &lt;a href=&quot;https://twitter.com/osxpl2303&quot; rel=&quot;nofollow noreferrer&quot;&gt;actively developed&lt;/a&gt;. It does cost money, but it is signed (which the mfg. driver isn't) and it has a test utility you can use before purchasing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other options after that are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Hope that WCH update their driver (don't hold your breath).&lt;/li&gt;&#xA;&lt;li&gt;Program using an external programmer&lt;/li&gt;&#xA;&lt;li&gt;Buy an Arduino not using the CH340&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-07T22:43:28.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14023" PostTypeId="2" ParentId="14010" CreationDate="2015-08-07T22:58:11.733" Score="1" Body="&lt;p&gt;If you are controlling an RC plane, you should probably just buy a transmitter and receiver specifically designed for that. They are cheap and reliable and will generate PWM signals on their own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you must use an Arduino for some reason, NRF24L01 are not going to cut it as they are not powerful enough to reach 1 km. You should probably look into something like an XBee Series 1. With about 60 mW transmit power, its range is up to 1.6 km.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-07T22:58:11.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14024" PostTypeId="2" ParentId="4942" CreationDate="2015-08-08T01:24:52.203" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;To be as little invasive as possible, I'd remove just the &lt;a href=&quot;http://www.seeedstudio.com/depot/05w-solar-panel-55x70-p-632.html?cPath=155&quot; rel=&quot;nofollow&quot;&gt;solar panel&lt;/a&gt; and replace it with a power supply with the same typical voltage (5.5V) and at least the same typical power output (0.5W). It should not be too difficult, nor too expensive. Any USB charger that can provide 5V should do. You can just cut the USB connector and attach the wires to the board. Or be more elegant and create an adapter. Either way should work. And the price should be about a couple of bucks.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes, I think it would work, although linear regulators 9V -&gt; 5V are really inefficient. See my proposed solution from the previous point.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On ebay there's &lt;a href=&quot;http://www.ebay.com/sch/i.html?_from=R40&amp;amp;_trksid=p2050601.m570.l1313.TR0.TRC0.H0.Xlipo+3.7v.TRS0&amp;amp;_nkw=lipo+3.7v&amp;amp;_sacat=0&quot; rel=&quot;nofollow&quot;&gt;plenty&lt;/a&gt; of options, but they might not fit in the box of the seeduino. You have to compare the dimensions of the battery vs whatever extra space might be available.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-08T01:24:52.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14025" PostTypeId="2" ParentId="14007" CreationDate="2015-08-08T01:34:43.330" Score="3" Body="&lt;p&gt;There is a fairly inexpensive solution, but it's not Arduino based.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://www.google.com/get/cardboard/&quot; rel=&quot;nofollow&quot;&gt;Google Cardboard sdk&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;a fairly modern and powerful Android phone (I have a OnePlusOne and it works well with Cardboard apps) - assuming you already own something similar, this is where the big saving happens :-)&lt;/li&gt;&#xA;&lt;li&gt;a compatible head unit: there are &lt;a href=&quot;http://www.ebay.com/sch/i.html?_from=R40&amp;amp;_trksid=p2050601.m570.l1313.TR0.TRC0.H0.Xgoogle%20cardboard.TRS0&amp;amp;_nkw=google%20cardboard&amp;amp;_sacat=0&quot; rel=&quot;nofollow&quot;&gt;many&lt;/a&gt; available on ebay (on some you might have to drill a hole where the camera of the phone is located.) price got from about $5 to $25&lt;/li&gt;&#xA;&lt;li&gt;some high level programming skills to write your augmented reality application, but there's no way around it :-) - you might even find some demo on the net.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here the basic of the solution I'm proposing is to take the video stream from the front camera on the phone, use the CardBoard API to create a view for each eye (yes, you will loose stereoscopy, since each eye will see the same image from the camera) and overlay it with whatever info you would like to show. The simpler case could be a compass, where you show N-W-S-E at the top of the field of view. Or you could even add a map, like in a FPS :-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part where the arduino might come useful is if you want to create some (bluetooth, for example) sensor and/or controller (using the usb port from the phone requires both a phone with HW that supports host mode and a rooted device).&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-08-08T01:41:14.827" LastActivityDate="2015-08-08T01:41:14.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14026" PostTypeId="5" CreationDate="2015-08-08T05:03:46.483" Score="0" Body="&lt;p&gt;There are two main models of usage of Firmata. In one model, the author of the Arduino sketch uses the various methods provided by the Firmata library to selectively send and receive data between the Arduino device and the software running on the host computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second and more common model is to load a general purpose sketch called StandardFirmata on the Arduino board and then use the host computer exclusively to interact with the Arduino board. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;https://github.com/firmata/arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/firmata/arduino&lt;/a&gt; and &lt;a href=&quot;https://github.com/firmata/protocol&quot; rel=&quot;nofollow&quot;&gt;https://github.com/firmata/protocol&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-10T00:01:46.017" LastActivityDate="2015-08-10T00:01:46.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14027" PostTypeId="4" CreationDate="2015-08-08T05:03:46.483" Score="0" Body="Firmata is a protocol for communicating with micro-controllers from software on a host computer" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-10T00:01:48.930" LastActivityDate="2015-08-10T00:01:48.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14028" PostTypeId="1" AcceptedAnswerId="14029" CreationDate="2015-08-08T08:08:29.177" Score="2" ViewCount="941" Body="&#xA;&#xA;&lt;p&gt;I am attempting to make an I2C slave out of my Arduino and I can't get past the Wire.onReceive function. Here is my code. The documentation says to just add a function that has the style of void myHandler(int bytes) but I can't figure out why my readPI function does not meet these requirements.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    #include &quot;piCom.h&quot;&#xA;    #include &quot;WireAddresses.h&quot;&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;    pi::pi(){&#xA;       Wire.begin(NB_INFO); // is 0x04&#xA;       Wire.onReceive( readPI );&#xA;       //Wire.onRequest(sendPI);&#xA;    }&#xA;&#xA;    void pi::readPI(int byteCount){&#xA;       while( Wire.available() ){&#xA;&#xA;             ref_IMU = Wire.read();&#xA;&#xA;       }//end while&#xA;&#xA;    }//end readPI&#xA;&#xA;    void pi::sendPI(){&#xA;&#xA;       Wire.write(1);&#xA;       //use to send pressure info to pi&#xA;&#xA;    }//end sendPI&#xA;&#xA;&#xA;    //double pi::getref_IMU(){return ref_IMU;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then here is the error&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;piCom.cpp: In constructor 'pi::pi()':&#xA;piCom.cpp:7: error: no matching function for call to'TwoWire::onReceive(&amp;lt;unresolved overloaded function type&amp;gt;)'&#xA; Wire.onReceive( readPI );&#xA;                        ^&#xA;&#xA;no matching function for call to 'TwoWire::onReceive(&amp;lt;unresolved overloaded function type&amp;gt;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="11676" LastEditorUserId="10794" LastEditDate="2015-08-08T09:03:10.563" LastActivityDate="2015-08-08T09:03:10.563" Title="unresolved overloaded function type for Wire.onReceive" Tags="|arduino-mega|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14029" PostTypeId="2" ParentId="14028" CreationDate="2015-08-08T09:00:12.017" Score="2" Body="&lt;pre&gt;&lt;code&gt;    void pi::sendPI(){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is a class function (method) which has an implicit &lt;strong&gt;this&lt;/strong&gt; pointer. You can't use it as a static ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, classes cannot implement ISRs for this reason. There are a few workarounds, one being to make it a &lt;strong&gt;static&lt;/strong&gt; class function. However then it will affect the entire class, not just one instance.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-08T09:00:12.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14030" PostTypeId="1" AcceptedAnswerId="14099" CreationDate="2015-08-08T11:40:06.327" Score="0" ViewCount="274" Body="&lt;p&gt;I'm writing a project where an Arduino board that is connected to a servo engine receives commands from another Arduino. The possible commands are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Move 10 degrees&lt;/li&gt;&#xA;&lt;li&gt;Reset position&lt;/li&gt;&#xA;&lt;li&gt;Sweep until you're told to stop&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My problem is with the sweep-mode, when I get the sweep command, I get into a while loop, that first checks for a sweep-terminator and then sweeps.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;} else if (message == sweep) {&#xA;  Serial.println(&quot;sweep&quot;);&#xA;  while (msg1 != sweep_term) {&#xA;    // set the direction for the servo to move&#xA;    if (val == 750){&#xA;      val = 2250;&#xA;    } else {&#xA;      val = 750;&#xA;    }&#xA;&#xA;    // move the servo&#xA;    myservo.write(val);&#xA;    // wait for the servo to move&#xA;    delay(15);&#xA;&#xA;    // wait for a message&#xA;    if (vw_get_message(buf1, &amp;amp;buflen1)) {&#xA;      buf1[buflen1] = '\0';&#xA;      msg1 = (char*)buf1;&#xA;      memset(buf1,'0',VW_MAX_MESSAGE_LEN);&#xA;      Serial.print(buflen1);&#xA;      Serial.print(&quot; [sweep] Got: &quot;);&#xA;      Serial.println(msg1);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason, when I'm in this loop I don't get the sweep terminator message, or I get a part of it. I suspect that the servo is responsible for this, since when I run the same program without &lt;code&gt;myservo.write()&lt;/code&gt;s I &lt;em&gt;do&lt;/em&gt; receive those terminators.&lt;/p&gt;&#xA;" OwnerUserId="11678" LastEditorUserId="11678" LastEditDate="2015-08-08T12:06:18.240" LastActivityDate="2015-08-11T21:51:37.287" Title="Receiving partial messages when using VirtualWire and ServoTimer2" Tags="|servo|rf|virtualwire|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14031" PostTypeId="1" AcceptedAnswerId="14169" CreationDate="2015-08-08T16:56:08.523" Score="0" ViewCount="337" Body="&lt;p&gt;Overflow enthusiasts!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to log accelerometer and gyro data using Serial.print. I have enabled the FIFO_Overflow interrupt. Whenever I log data, the serial port freezes. I am suspecting an interrupt issue while I am using Serial.print. Is there any way to get continuous data for debugging purposes? I know that the Serial library can affect interrupts and wonder whether you guys could help me a little bit ?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Wire.h&quot;    &#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU9150.h&quot;&#xA;#include &quot;helper_3dmath.h&quot;&#xA;&#xA;// class default I2C address is 0x68&#xA;// specific I2C addresses may be passed as a parameter here&#xA;// AD0 low = 0x68 (default for InvenSense evaluation board)&#xA;// AD0 high = 0x69&#xA;MPU9150 accelGyroMag;    &#xA;#define LED_PIN 13&#xA;volatile boolean state_fifo_int = false;&#xA;uint16_t fifo_count;&#xA;uint8_t fifo_buffer[8];&#xA;int16_t acc_temp[3];&#xA;int16_t gyro_x;&#xA;&#xA;void setup(){&#xA;    // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;    Wire.begin();    &#xA;    // initialize serial communication&#xA;    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but&#xA;    // it's really up to you depending on your project)&#xA;    Serial.begin(115200);&#xA;    // initialize device&#xA;    Serial.println(&quot;Initializing I2C devices...&quot;);&#xA;    accelGyroMag.initialize();&#xA;    // verify connection&#xA;    Serial.println(&quot;Testing device connections...&quot;);&#xA;    Serial.println(accelGyroMag.testConnection() ? &quot;MPU9150 connection successful&quot; : &quot;MPU9150 connection failed&quot;);&#xA;    // configure Arduino LED for&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    attachInterrupt(0,fifo_int,CHANGE);&#xA;}&#xA;&#xA;void fifo_int() {&#xA;  state_fifo_int = true; &#xA;}&#xA;&#xA;void loop(){&#xA;  while(!state_fifo_int) {&#xA;    accelGyroMag.setIntFIFOBufferOverflowEnabled(true);&#xA;    // enable fifo_interrupt&#xA;    accelGyroMag.setFIFOEnabled(true);&#xA;    accelGyroMag.setAccelFIFOEnabled(true);&#xA;    accelGyroMag.getXGyroFIFOEnabled();&#xA;    accelGyroMag.getAccelFIFOEnabled();&#xA;    fifo_count = accelGyroMag.getFIFOCount();&#xA;    accelGyroMag.getFIFOBytes(fifo_buffer,8); // fill in fifo bytes&#xA;    acc_temp[0] = (((int16_t)fifo_buffer[0]) &amp;lt;&amp;lt; 8) | fifo_buffer[1];&#xA;    acc_temp[1] = (((int16_t)fifo_buffer[2]) &amp;lt;&amp;lt; 8) | fifo_buffer[3];&#xA;    acc_temp[2] = (((int16_t)fifo_buffer[4]) &amp;lt;&amp;lt; 8) | fifo_buffer[5];&#xA;    gyro_x = (((int16_t)fifo_buffer[6]) &amp;lt;&amp;lt; 8) | fifo_buffer[7];&#xA;    Serial.print((float)acc_temp[0]/16384);&#xA;    Serial.print(&quot;  &quot;);&#xA;    Serial.print((float)acc_temp[1]/16384);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print((float)acc_temp[2]/16384);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(gyro_x);&#xA;   }&#xA;   accelGyroMag.setIntFIFOBufferOverflowEnabled(false);&#xA;   // disable fifo_interrupt&#xA;   accelGyroMag.resetFIFO();&#xA;   state_fifo_int = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The library for the MPU9150 is by Jeff Rowberg.&lt;/p&gt;&#xA;" OwnerUserId="11433" LastEditorUserId="4131" LastEditDate="2015-08-10T13:09:44.517" LastActivityDate="2016-02-09T22:10:38.903" Title="MPU9150 (JEFF LIB) + FIFO_OVERFLOW INTERRUPT + SERIAL PRINT" Tags="|serial|interrupt|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14032" PostTypeId="2" ParentId="13858" CreationDate="2015-08-08T19:46:26.590" Score="2" Body="&lt;p&gt;You can use the DS1307 itself just fine, but you are probably using a breakout board. These boards have (pull-up) resistors on it that will pull-up the I2C lines to 5v, while you only want 3.3v. This will not damage the arduino, but could damage chips like the  TSL2561, that can only handle 3.3v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nXxvD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nXxvD.jpg&quot; alt=&quot;RTC breakout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the board you indicated you are using, you need to remove R2 and R3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other 5v sensor breakout might also have pull-ups to 5v. Easiest way to check, is to connect 5v and ground, and then measure the voltage on the SDA and SCL pins. If it's 5v, then it has pull-up resistors that need to be removed.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-08T19:46:26.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14033" PostTypeId="2" ParentId="14020" CreationDate="2015-08-08T23:19:30.860" Score="0" Body="&#xA;&#xA;&lt;p&gt;How do you send your commands, char by char or one shot ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is nothing to read, &lt;code&gt;port-&amp;gt;available()&lt;/code&gt; may return -1 error code after 1 sec, but you already checked, isn't it ? Anyway, you should check if it returns something &lt;code&gt;&amp;gt; 0&lt;/code&gt; instead of something &lt;code&gt;!= 0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;readString()&lt;/code&gt; doesn't take any parameter (&lt;a href=&quot;https://www.arduino.cc/en/Reference/StreamReadString&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/StreamReadString&lt;/a&gt;). I suspect this function not acting as &lt;code&gt;read()&lt;/code&gt; to decrease the number returned by &lt;code&gt;available();&lt;/code&gt;&#xA;If you want to catch \n, use &lt;code&gt;readStringUntil('\n')&lt;/code&gt; instead (&lt;a href=&quot;https://www.arduino.cc/en/Serial/ReadStringUntil&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/ReadStringUntil&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to put the full code (&lt;strong&gt;with the loop&lt;/strong&gt;) given by Majenko at the end of your loop() function.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;HardwareSerial *port;&#xA;&#xA;void setup() {&#xA;  port = &amp;amp;Serial1;&#xA;  port-&amp;gt;begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (port-&amp;gt;available() &amp;gt; 0) {&#xA;    String cmd = port-&amp;gt;readString();&#xA;&#xA;    if (cmd.length() &amp;gt; 1) { // Why not 0 ?&#xA;      String instruction = cmd;&#xA;      int arg_comma_index = 0;&#xA;      arg_comma_index = instruction.indexOf(&quot;,&quot;);&#xA;      String func = instruction.substring(0, arg_comma_index);&#xA;      String args = instruction.substring(arg_comma_index + 1, instruction.length() + 1 );&#xA;&#xA;      Keyboard.begin();&#xA;      Keyboard.println(args);&#xA;      Keyboard.end();&#xA;    }&#xA;    while (port-&amp;gt;available() &amp;gt; 0) {&#xA;        port-&amp;gt;read();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11681" LastEditorUserId="10794" LastEditDate="2015-08-09T00:26:35.180" LastActivityDate="2015-08-09T00:26:35.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14034" PostTypeId="2" ParentId="14030" CreationDate="2015-08-08T23:54:42.407" Score="1" Body="&lt;p&gt;If &lt;code&gt;msg1&lt;/code&gt; is of type &lt;code&gt;char*&lt;/code&gt; (as is implied by the cast in &lt;code&gt;msg1 = (char*)buf1;&lt;/code&gt;), then it seems to me that that statement will copy the address of &lt;code&gt;buf1&lt;/code&gt; to &lt;code&gt;msg1&lt;/code&gt;.  Then, when you fill &lt;code&gt;buf1&lt;/code&gt; with ascii zeroes (ie, characters &lt;code&gt;'0'&lt;/code&gt;) &lt;code&gt;msg1&lt;/code&gt; ends up being a string of ascii zeroes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if &lt;code&gt;msg1&lt;/code&gt; is of type &lt;code&gt;String&lt;/code&gt; (to go along with your comment about &lt;code&gt;buf1&lt;/code&gt; being of type &lt;code&gt;String&lt;/code&gt;) the cast should be unnecessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if you don't give the source for the &lt;code&gt;vw_get_message()&lt;/code&gt; routine and the declarations for all of the constants and variables used in the code extract, it's unlikely anyone can definitively answer your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the &lt;code&gt;while&lt;/code&gt; test, &lt;code&gt;msg1 != sweep_term&lt;/code&gt;, may not be well-defined on entry to the while loop.  Or, if &lt;code&gt;msg1&lt;/code&gt; is left over from a previous use, you won't enter the loop at all.  Consider writing the loop in the form &lt;code&gt;do { ... } while (msg1 != sweep_term);&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if (as said in a comment) &lt;code&gt;buf1&lt;/code&gt; is of type &lt;code&gt;String&lt;/code&gt;, then the statement &lt;code&gt;memset(buf1,'0',VW_MAX_MESSAGE_LEN);&lt;/code&gt; is a line of code I'd recommend against, because it treats &lt;code&gt;buf1&lt;/code&gt; as a simple array rather than as an object.  (In this case it &lt;em&gt;should&lt;/em&gt; make no difference, but it requires some research to be sure of that. [&lt;a href=&quot;https://stackoverflow.com/questions/422830/structure-of-a-c-object-in-memory-vs-a-struct&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;https://stackoverflow.com/questions/1632600/memory-layout-c-objects&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_cplusplus&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;,&lt;a href=&quot;http://databasefaq.com/index.php/answer/111791/c-c-11-move-which-rules-determine-whether-an-object-is-trivially-copyable&quot; rel=&quot;nofollow noreferrer&quot;&gt;4&lt;/a&gt;,&lt;a href=&quot;https://stackoverflow.com/questions/29034121/what-will-happen-on-memcpy-of-structures-with-c-string&quot;&gt;5&lt;/a&gt;])&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-08-09T01:00:00.317" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14035" PostTypeId="2" ParentId="1726" CreationDate="2015-08-09T00:21:40.273" Score="7" Body="&lt;h2&gt;Receiving&lt;/h2&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;You can see from the source of HardwareSerial that if an incoming byte finds the ring buffer full it is discarded:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;inline void store_char(unsigned char c, ring_buffer *buffer)&#xA;{&#xA;  int i = (unsigned int)(buffer-&amp;gt;head + 1) % SERIAL_BUFFER_SIZE;&#xA;&#xA;  // if we should be storing the received character into the location&#xA;  // just before the tail (meaning that the head would advance to the&#xA;  // current location of the tail), we're about to overflow the buffer&#xA;  // and so we don't write the character or advance the head.&#xA;  if (i != buffer-&amp;gt;tail) {&#xA;    buffer-&amp;gt;buffer[buffer-&amp;gt;head] = c;&#xA;    buffer-&amp;gt;head = i;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I get the impression that if I transmit data to the Arduino and don't have an active &quot;puller&quot; of data on the Arduino side then if more data arrives than can fit in the buffer, it will be discarded. Can you confirm that? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes it will be discarded. There is no software or hardware flow control, unless you implement your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However with a 64-byte buffer, and receiving data at (say) 9600 baud, you get one byte every 1.04 ms, and thus it takes 66.6 ms to fill up the buffer. On a 16 MHz processor you should be able to check the buffer often enough that it doesn't fill up. All you really have to do is move the data from the HardwareSerial buffer to your own, if you don't want to process it right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from the &lt;code&gt;#if (RAMEND &amp;lt; 1000)&lt;/code&gt; check that the processors with 1000+ bytes of RAM get the 64-byte buffer, the ones will less RAM get the 16-byte buffer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sending&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Data that you write is placed in a same-sized buffer (16 or 64 bytes). In the case of sending if the buffer fills up the code &quot;blocks&quot; waiting for an interrupt to send the next byte out the serial port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If interrupts are turned off this will never happen, thus you do &lt;strong&gt;not&lt;/strong&gt; do Serial prints inside an Interrupt Service Routine.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-09T00:21:40.273" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14036" PostTypeId="2" ParentId="14020" CreationDate="2015-08-09T00:35:00.553" Score="1" Body="&#xA;&#xA;&lt;p&gt;I wouldn't be using readString myself. In fact I wouldn't be using the String class at all. &lt;code&gt;readString&lt;/code&gt; keeps reading until it times out (by default after one second), so it may read more - or less even - than you want. It will also introduce a one-second delay while it sits around waiting for that second to elapse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are much better off doing a non-blocking loop, and then processing data when you get a known delimiter, like a newline or comma, or whatever you designate as &quot;ending the stream&quot;. Example code that uses a newline delimiter:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 50;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  } // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data)&#xA;  {&#xA;  // for now just display it&#xA;  // (but you could compare it to some value, convert to an integer, etc.)&#xA;  Serial.println (data);&#xA;  }  // end of process_data&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;  {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte)&#xA;    {&#xA;&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;      // terminator reached! process input_line here ...&#xA;      process_data (input_line);&#xA;&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;    }  // end of switch&#xA;&#xA;  } // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;  {&#xA;  // if serial data available, process it&#xA;  while (Serial.available () &amp;gt; 0)&#xA;    processIncomingByte (Serial.read ());&#xA;&#xA;  // do other stuff here like testing digital input (button presses) ...&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my example code you would do whatever-it-is you want in &lt;code&gt;process_data&lt;/code&gt; which is called once an entire line arrives. Then you don't need to discard incoming data (empty the serial buffer), which seems to me to be a bad idea anyway.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-09T00:35:00.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14037" PostTypeId="1" CreationDate="2015-08-09T03:28:35.247" Score="0" ViewCount="247" Body="&lt;p&gt;I noticed that my Arduino Mega performs differently in how it presents values from say analog input A0, depending on whether it is being powered by USB or by a fresh 9V battery wired and connected through the barrel connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must be some sort of difference to what happens when both USB and the barrel connector are employed vs. just USB being used for power. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be specific, when running just on USB power, the analog inputs seem to flicker more allowing for oversampling and measurements beyond the 10 bit accuracy of the DAC. In fact with analogReference(DEFAULT) it is possible with 64x oversampling to see 100uV level changes when only USB power is employed. Note that these changes are not just noise, they actually correspond to 100uV level changes in the input connected to A0 with high correlation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I connect the barrel connector, the picture changes significantly. Values coming out of the ADC seem to pretty much snap and there is far less flicker. The ADC becomes, well, discrete and you get your 1,024 levels and that's about it. There may be a tiny bit of flicker as you increase or decrease voltage and approach the next increment, but this is not significant enough to actually increase the ADC resolution reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even going so far as setting the analogReference to EXTERNAL while the barrel connector is employed and connecting the AREF pin to the 5v connector directly, which by the way reads at 5.004 V  (unlike the 4.992 V it reads when USB is powering the device) still reproduces the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary: Effectively, when running on USB power only I can oversample the analog inputs and get significantly more than 10-bit resolution. While when running using the barrel connector, with the USB still attached, I can only get the 10-bit resolution natively provided by the ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has any ideas on what is causing this difference in behavior, I am all ears. If I failed to explain anything or perhaps created some confusion, I would be more than happy to clarify.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This is an authentic Arduino Mega board.&lt;/p&gt;&#xA;" OwnerUserId="11684" LastEditorUserId="11684" LastEditDate="2015-08-09T03:33:44.553" LastActivityDate="2015-08-09T05:34:31.133" Title="Analog input weirdness (barrel connector vs USB power)" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14038" PostTypeId="2" ParentId="871" CreationDate="2015-08-09T03:31:08.703" Score="0" Body="&lt;p&gt;They all do with oversampling. You can evaluate the quality of doing this for your own use.&lt;/p&gt;&#xA;" OwnerUserId="11684" LastActivityDate="2015-08-09T03:31:08.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14040" PostTypeId="2" ParentId="14037" CreationDate="2015-08-09T05:34:31.133" Score="1" Body="&lt;p&gt;Looking at the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-mega-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt; the barrel plug has a couple of linear voltage regulators (top left of schematic), while the USB input just has a couple of MOSFETs (bottom right of schematic) which are basically just there to switch off the USB power if there is something plugged into the barrel jack (and also maybe provide a little input protection). So the Arduino is relying on the USB power to be pre-regulated. For the most part this is correct, but USB voltage can vary widely depending on the cable length (voltage drop), the power source it is connected to (no two computers or wall warts are the same), and how many devices are the same hub (if connected to a computer or hub). I would not rely on the two power sources being matched at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flicker you are talking about sounds like the power coming from USB could have significant ripple. I doubt that the USB power is allowing you to &quot;oversample&quot;. The way ADCs in AVRs work is they have a reference voltage and when sampling, will give you a reading of where the voltage is between 0 and the voltage reference. With a 10-bit ADC there are ~1000 steps, so to measure 100uV changes, you would have to have a 100 mV reference voltage, which according to the &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/ATMega1280.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; (p.379), the minimum is 1.0 V. Basically, it is physically impossible for the Arduino Mega to measure those kinds of changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is more likely to be happening is that you are probably getting some weird aliasing between the ripple frequency of your USB voltage and the sampling frequency of your code. The best way to debug this kind of thing would be to pull out an oscilloscope and check if and how much ripple is coming off the USB power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If accuracy is important to your project, and being able to accept both power inputs is a requirement, you might look into maybe getting your own external voltage reference and piping it into VREF. Otherwise, I would stick to only using the barrel plug as it is regulated and will be consistent.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-08-09T05:34:31.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14041" PostTypeId="2" ParentId="9238" CreationDate="2015-08-09T08:26:23.710" Score="3" Body="&lt;p&gt;As far as I know, the 1-wire library you linked in your question allows only to act as a master, not a slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've just released a library to turn an Arduino board into a 1-wire slave, here: &lt;strike&gt;&lt;a href=&quot;https://github.com/neuoy/OneWireArduinoSlave&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/neuoy/OneWireArduinoSlave&lt;/a&gt;&lt;/strike&gt; (edit: moved here &lt;a href=&quot;https://gitea.youb.fr/youen/OneWireArduinoSlave&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gitea.youb.fr/youen/OneWireArduinoSlave&lt;/a&gt;). I use it in my custom home automation system, and it works flawlessly in my setup (the 1-wire master, a DS9490R, is connected to a laptop via USB, and also provides power to the Arduino, which is an Arduino Uno). The library handles low level details: match rom, byte send and receive (which is actually quite hard to get right, mostly impossible without a logic analyzer). The rest is up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's entirely implemented with interrupts, all communications are performed in background, you can execute other code as usual, in parallel, and are notified by callbacks when bytes are received etc. Sending bytes to the master is also asynchronous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know at least one other library exists, &lt;a href=&quot;https://github.com/MarkusLange/OneWireSlave&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/MarkusLange/OneWireSlave&lt;/a&gt;, as commented above by Ryu_hayabusa. It didn't work for me (don't know if it's because of my hardware setup or for another reason), but it definitely work for others, so also worth a try. It seems this library is not implemented with interrupts, so your program is blocked while waiting for master activity (which is perfectly acceptable in a lot of scenarios).&lt;/p&gt;&#xA;" OwnerUserId="11688" LastEditorUserId="11688" LastEditDate="2018-11-14T13:51:14.593" LastActivityDate="2018-11-14T13:51:14.593" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14044" PostTypeId="1" CreationDate="2015-08-09T12:55:15.387" Score="0" ViewCount="964" Body="&lt;p&gt;Is it possible to accept input from an end user via terminal, or some other application? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to create a prototype for a friend, but he'd need to enter his wireless network and password to complete the setup of the project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11460" LastActivityDate="2015-08-13T18:19:38.383" Title="Arduino User Input" Tags="|arduino-uno|arduino-mega|arduino-ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14045" PostTypeId="1" AcceptedAnswerId="14046" CreationDate="2015-08-09T14:11:48.620" Score="2" ViewCount="1395" Body="&lt;p&gt;I'm pretty much a beginner when it comes to programming and have only recently started learning C++. Right now I'm stuck trying to covert a bitmap into a binary array. This is for a Robotics competition I've entered. The bitmap is a 54*96 pixel monochromatic 1 bpp image. I'm confused with the offset positions while trying to read the header. This is the code I've written so far and would greatly appreciate any help. I think the error lies in increment of the &lt;code&gt;lineNo&lt;/code&gt; variable which needs to be in hex, but how to increment such values? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to ultimately achieve is to read only some parts of the bitmap particularly the boxes with cross on them (see image below). How do I find out the pixel locations? &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;File bMap;&#xA;File Text;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ;&#xA;  }&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;  pinMode(10, OUTPUT);&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;initialization done.&quot;);&#xA;  int height = 0;&#xA;  int width = 0;&#xA;  int  bitmapOffset = 0xa;&#xA;  bMap = SD.open(&quot;map.bmp&quot;, FILE_READ);&#xA;  Text = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;  \\bMap.seek(0xa);&#xA;  \\bitmapOffset = bMap.read();&#xA;  \\Serial.println(bitmapOffset, BIN);&#xA;  \\Serial.println(bMap, HEX);&#xA;  bMap.seek(0x16);&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    height += (bMap.read() &amp;lt;&amp;lt; (8 * i));&#xA;    Serial.println(height);&#xA;    int lineNo;&#xA;    int fileposition = 0;&#xA;    for (lineNo = 0; lineNo &amp;lt; height; lineNo++)&#xA;      fileposition = bitmapOffset + (lineNo);&#xA;    bMap.seek(fileposition);&#xA;    //Serial.print(lineNo);&#xA;    Serial.print(fileposition);&#xA;    //Serial.print(bitmapOffset);&#xA;&#xA;  }&#xA;&#xA;  bMap.seek(0x12);&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    width += (bMap.read() &amp;lt;&amp;lt; (8 * i));&#xA;    Serial.println(width);&#xA;    if (Text) {&#xA;      Text.println(height, width);&#xA;      Text.close();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hSEHx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hSEHx.png&quot; alt=&quot;Maze&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="11691" LastEditorUserId="26916" LastEditDate="2017-09-08T09:47:17.680" LastActivityDate="2017-09-08T09:47:17.680" Title="Reading a part of bitmap image on Arduino" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14046" PostTypeId="2" ParentId="14045" CreationDate="2015-08-09T14:40:40.283" Score="2" Body="&lt;p&gt;Any coordinate in a bitmap (note: the term bitmap here [all lower case] refers to the concept of a grid of pixels, not the Windows BMP file format which I will always refer to as BMP all in capitals) can easily be calculated as long as you know the width.  The height is only needed to stop you going too far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pixel offset in a buffer of pixels is calculated as &lt;code&gt;y * width + x&lt;/code&gt; assuming a &lt;em&gt;left-right / top-down&lt;/em&gt; pixel arrangement in the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The information you are really interested in with your bitmap is actually considerably less than is in the BMP that you show.  Your BMP is 56x96 pixels, but the information you actually care about is actually only in a resolution of 7x12 blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be far simpler if you could pre-process the provided BMP on a PC to create an array of 84 entries each with a different tag or value to represent what it is.  Your image there could then be represented as the array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ 3, 3, 3, 3, 3, 3, 3,&#xA;  3, 1, 0, 0, 0, 1, 3,&#xA;  3, 0, 0, 0, 0, 1, 3,&#xA;  0, 0, 1, 1, 0, 0, 3,&#xA;  3, 2, 1, 0, 0, 0, 3,&#xA;  3, 1, 0, 0, 1, 0, 3,&#xA;  3, 0, 1, 0, 0, 0, 3,&#xA;  3, 0, 0, 0, 2, 0, 3,&#xA;  3, 0, 0, 1, 0, 0, 3,&#xA;  3, 1, 1, 0, 1, 0, 3,&#xA;  3, 0, 0, 0, 0, 0, 3,&#xA;  3, 3, 3, 0, 3, 3, 3 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 0 is an open white space, 1 is a closed black space, 2 is a black space with a cross and 3 is a border space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two crosses would then be calculated as &lt;code&gt;(1,4) = 4 * 7 + 1 = 29&lt;/code&gt; and &lt;code&gt;(4,7) = 7 * 7 + 4 = 53&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working with BMP files is somewhat more tricky.  They come in multiple depths and multiple bit arrangements, as well as different versions with different header sizes.  They also have different padding requirements for different line lengths and bit depths, and are generally a rather nasty file format all round.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And on top of that they are upside down.  BMP is the only file format I know of where 0,0 is at the bottom left instead of the top left.  Consequently you have to invert all your Y coordinates to make sense of it, and parsing a BMP file from the top down is really slow because you have to keep jumping backwards in the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it would be much better if you could write a program on a PC using software which already understands the BMP format and can render it into a buffer for your program to then parse each block to work out what it is and build up a small 84 byte file of the actual information you need for your robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you must read the BMP file directly on the Arduino then I have code you use to help you.  It's not designed for the Arduino but for the chipKIT boards (though it's very similar) and is designed as part of my DisplayCore framework for chipKIT (and other more powerful) boards, but you are welcome to take whatever bits you like, or just use bits to give you more insight into how BMP files work.  You can get the code from Github here: &lt;a href=&quot;https://github.com/MajenkoLibraries/DisplayCore/tree/master/ImageReaders/BMPFile&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/DisplayCore/tree/master/ImageReaders/BMPFile&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To parse your bitmap into an array you would have to take each 8x8 block of pixels and work out what shape is in it - whether it's all black, all white, a cross, or a border piece.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-09T14:46:28.193" LastActivityDate="2015-08-09T14:46:28.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14047" PostTypeId="1" AcceptedAnswerId="14050" CreationDate="2015-08-09T16:41:47.307" Score="3" ViewCount="10983" Body="&lt;p&gt;I'm working on modifying this &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Switch&quot; rel=&quot;nofollow noreferrer&quot;&gt;example&lt;/a&gt; from the Arduino website to read the state of 3 toggle (SPDT) switches. If I have one toggle switch hooked up, my sketch works as expected...the sketch will log the state of the switch in the serial debugger every-time the state changes, and only when the state changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I add in two more switches, the serial debugger will continuously output my log messages, without detecting if the state has changed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code from my sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int  switchOnePin = 2;    // digital in 2 (pin the switch one is attached to)&#xA;const int  switchTwoPin = 3;    // digital in 3 (pin the switch two is attached to)&#xA;const int  switchThreePin = 4;  // digital in 4 (pin the switch three is attached to)&#xA;&#xA;int switchOneState = 0;         // current state of the switch&#xA;int lastSwitchOneState = 0;     // previous state of the switch&#xA;&#xA;int switchTwoState = 0;         &#xA;int lastSwitchTwoState = 0;     &#xA;&#xA;int switchThreeState = 0;         &#xA;int lastSwitchThreeState = 0;     &#xA;&#xA;&#xA;void setup() {&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;&#xA;  int switchOneState = 0;         // current state of the switch&#xA;  int lastSwitchOneState = 0;     // previous state of the switch switch pins as an input&#xA;  pinMode(switchOnePin, INPUT);&#xA;  pinMode(switchTwoPin, INPUT);&#xA;  pinMode(switchThreePin, INPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  // read the switch input pins:&#xA;  switchOneState   = digitalRead(switchOnePin);&#xA;  delay(50);&#xA;  switchTwoState   = digitalRead(switchTwoPin);&#xA;  delay(50);&#xA;  switchThreeState = digitalRead(switchThreePin);&#xA;&#xA;  // compare the switchState to its previous state&#xA;  if (switchOneState != lastSwitchOneState) {&#xA;  // if the state has changed, increment the counter&#xA;    if (switchOneState == HIGH) {&#xA;    // if the current state is HIGH then the button&#xA;    // went from off to on:&#xA;    Serial.println(&quot;Switch one is on&quot;);&#xA;  }&#xA;  else {&#xA;    // if the current state is LOW then the button&#xA;    // went from on to off:&#xA;    Serial.println(&quot;Switch one is off&quot;);&#xA;  }&#xA;&#xA;&#xA;&#xA;&#xA;  if (switchTwoState != lastSwitchTwoState) {&#xA;    if (switchTwoState == HIGH) {&#xA;    Serial.println(&quot;Switch two is on&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;Switch two is off&quot;);&#xA;  }&#xA;&#xA;  if (switchThreeState != lastSwitchThreeState) {&#xA;    if (switchThreeState == HIGH) {&#xA;    Serial.println(&quot;Switch three is on&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;Switch thre is off&quot;);&#xA;  }&#xA; }&#xA;}&#xA;  // Delay a little bit to avoid bouncing&#xA;  delay(50);  &#xA;}&#xA;// save the current state as the last state,&#xA;//for next time through the loop&#xA;lastSwitchOneState   = switchOnePin;&#xA;lastSwitchTwoState   = switchTwoPin;&#xA;lastSwitchThreeState = switchThreePin;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's what my circuit looks like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZLAB6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZLAB6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Does anyone have any insight into what I may be doing wrong? I'm not quite sure if it's a circuit or a sketch issue (or both). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; I tried adding a delay of 50ms between each digital input read, but that still did not seem to help the problem. &lt;/p&gt;&#xA;" OwnerUserId="4137" LastEditorUserId="4137" LastEditDate="2015-08-09T18:41:18.080" LastActivityDate="2015-08-09T20:13:11.070" Title="Reading states of multiple toggle switches" Tags="|serial|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14049" PostTypeId="2" ParentId="14047" CreationDate="2015-08-09T19:25:47.747" Score="4" Body="&lt;pre&gt;&lt;code&gt;lastSwitchOneState   = switchOnePin;&#xA;lastSwitchTwoState   = switchTwoPin;&#xA;lastSwitchThreeState = switchThreePin;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastSwitchOneState   = switchOneState;&#xA;lastSwitchTwoState   = switchTwoState;&#xA;lastSwitchThreeState = switchThreeState;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-09T19:25:47.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14050" PostTypeId="2" ParentId="14047" CreationDate="2015-08-09T20:13:11.070" Score="5" Body="&lt;p&gt;The problem was two pronged---both the copy/paste error that @Gerben pointed out, as well as the incorrect if-else statements that @BrettAM pointed out. Below is the working code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int  switchOnePin = 2;    // digital in 2 (pin the switch one is attached to)&#xA;const int  switchTwoPin = 3;    // digital in 3 (pin the switch two is attached to)&#xA;const int  switchThreePin = 4;  // digital in 4 (pin the switch three is attached to)&#xA;&#xA;int switchOneState = 0;         // current state of the switch&#xA;int lastSwitchOneState = 0;     // previous state of the switch&#xA;&#xA;int switchTwoState = 0;&#xA;int lastSwitchTwoState = 0;&#xA;&#xA;int switchThreeState = 0;&#xA;int lastSwitchThreeState = 0;&#xA;&#xA;&#xA;void setup() {&#xA;    //initialize serial communication at 9600 bits per second:&#xA;    Serial.begin(9600);&#xA;&#xA;    int switchOneState = 0;         // current state of the switch&#xA;    int lastSwitchOneState = 0;     // previous state of the switch switch pins as an input&#xA;    pinMode(switchOnePin, INPUT);&#xA;    pinMode(switchTwoPin, INPUT);&#xA;    pinMode(switchThreePin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    // read the switch input pins:&#xA;    switchOneState   = digitalRead(switchOnePin);&#xA;    switchTwoState   = digitalRead(switchTwoPin);&#xA;    switchThreeState = digitalRead(switchThreePin);&#xA;&#xA;    // compare the switchState to its previous state&#xA;    if (switchOneState != lastSwitchOneState) {&#xA;        // if the state has changed, increment the counter&#xA;        if (switchOneState == HIGH) {&#xA;        // if the current state is HIGH then the button&#xA;        // went from off to on:&#xA;            Serial.println(&quot;Switch one is on&quot;);&#xA;        } else {&#xA;            // if the current state is LOW then the button&#xA;            // went from on to off:&#xA;            Serial.println(&quot;Switch one is off&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    if (switchTwoState != lastSwitchTwoState) {&#xA;        if (switchTwoState == HIGH) {&#xA;            Serial.println(&quot;Switch two is on&quot;);&#xA;        } else {&#xA;            Serial.println(&quot;Switch two is off&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    if (switchThreeState != lastSwitchThreeState) {&#xA;        if (switchThreeState == HIGH) {&#xA;            Serial.println(&quot;Switch three is on&quot;);&#xA;        } else {&#xA;            Serial.println(&quot;Switch thre is off&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    // Delay a little bit to avoid bouncing&#xA;    delay(50);&#xA;&#xA;    // save the current state as the last state,&#xA;    //for next time through the loop&#xA;    lastSwitchOneState   = switchOneState;&#xA;    lastSwitchTwoState   = switchTwoState;&#xA;    lastSwitchThreeState = switchThreeState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4137" LastActivityDate="2015-08-09T20:13:11.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14051" PostTypeId="2" ParentId="9481" CreationDate="2015-08-09T21:10:22.343" Score="2" Body="&lt;p&gt;On the ATmega1280/2560, only ports B, J, F, and K have pin change interrupt capability. These map approximately to pins 10 through 15, 50 through 53, and A6 through A15 (although part of port J is unmapped to Arduino pins, therefore PCINT11 through PCINT15 are unavailable on the Arduino Mega/Mega 2560).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-09T21:10:22.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14052" PostTypeId="1" AcceptedAnswerId="14056" CreationDate="2015-08-09T21:16:12.260" Score="0" ViewCount="1337" Body="&lt;p&gt;I have installed the STL for arduino, and it has been working fine. Then I tried to create a vector using a custom class, and it gave me a massive error message. When using it on primitive data types (ex. int) it works fine, but in any one of my own classes (including classes from sample code) it gives this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.3 (Windows 8.1), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Build options changed, rebuilding all&#xA;&#xA;&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w - fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD   -std=gnu++11 -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -  DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files   (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files   (x86)\Arduino\hardware\arduino\avr\variants\standard   C:\Users\OWNER\AppData\Local\Temp\build7240665633604233053.tmp\Navigation.cpp -o    C:\Users\OWNER\AppData\Local\Temp\build7240665633604233053.tmp\Navigation.cpp.o &#xA;&#xA;In file included from c:\program files     (x86)\arduino\hardware\tools\avr\avr\include\vector:33:0,&#xA;&#xA;                 from Navigation.ino:2:&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h: In instantiation   of 'void std::__destroy_aux(_ForwardIterator, _ForwardIterator, __false_type)   [with _ForwardIterator = Obstacle*]':&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h:78:55:   required  from 'void std::__destroy(_ForwardIterator, _ForwardIterator, _Tp*) [with  _ForwardIterator = Obstacle*; _Tp = Obstacle]'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h:83:51:   required from 'void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = Obstacle*]'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h:115:27:   required  from 'void std::destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = Obstacle*]'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:284:42:   required from 'std::vector&amp;lt;_Tp, _Alloc&amp;gt;::~vector() [with _Tp = Obstacle; _Alloc = std::allocator&amp;lt;Obstacle&amp;gt;]'&#xA;&#xA;Navigation.ino:36:23:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h:66:22: error: 'destroy' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]&#xA;&#xA;     destroy(&amp;amp;*__first);&#xA;&#xA;                  ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_construct.h:114:13: note: 'template&amp;lt;class _ForwardIterator&amp;gt; void std::destroy(_ForwardIterator, _ForwardIterator)' declared here, later in the translation unit&#xA;&#xA; inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {&#xA;&#xA;             ^&#xA;&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;iterator&amp;gt;&#xA;#include &amp;lt;vector&amp;gt;&#xA;#include &amp;lt;pnew.cpp&amp;gt;&#xA;&#xA;class Test {&#xA;public:&#xA;    int i;&#xA;};&#xA;std::vector&amp;lt;Test&amp;gt; test;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change the last line to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;std::vector&amp;lt;Test&amp;amp;&amp;gt; test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Arduino: 1.6.3 (Windows 8.1), Board: &quot;Arduino Uno&quot;&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -std=gnu++11 -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\OWNER\AppData\Local\Temp\build7240665633604233053.tmp\Navigation.cpp -o C:\Users\OWNER\AppData\Local\Temp\build7240665633604233053.tmp\Navigation.cpp.o &#xA;&#xA;In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\vector:35:0,&#xA;&#xA;                 from Navigation.ino:2:&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h: In instantiation of 'class std::_Vector_alloc_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;, true&amp;gt;':&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:101:8:   required from 'struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:155:7:   required from 'class std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;'&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:89:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   _Tp* _M_start;&#xA;&#xA;        ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:90:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   _Tp* _M_finish;&#xA;&#xA;        ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:91:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   _Tp* _M_end_of_storage;&#xA;&#xA;        ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:94:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   _Tp* _M_allocate(size_t __n)&#xA;&#xA;        ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:96:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   void _M_deallocate(_Tp* __p, size_t __n)&#xA;&#xA;        ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h: In instantiation of 'class std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;':&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:165:23: error: forming pointer to reference type 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::value_type {aka Obstacle&amp;amp;}'&#xA;&#xA;   typedef value_type* pointer;&#xA;&#xA;                       ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:166:29: error: forming pointer to reference type 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::value_type {aka Obstacle&amp;amp;}'&#xA;&#xA;   typedef const value_type* const_pointer;&#xA;&#xA;                             ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:167:23: error: forming pointer to reference type 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::value_type {aka Obstacle&amp;amp;}'&#xA;&#xA;   typedef value_type* iterator;&#xA;&#xA;                       ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:168:29: error: forming pointer to reference type 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::value_type {aka Obstacle&amp;amp;}'&#xA;&#xA;   typedef const value_type* const_iterator;&#xA;&#xA;                             ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:178:49: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   typedef std::reverse_iterator&amp;lt;const_iterator&amp;gt; const_reverse_iterator;&#xA;&#xA;                                                 ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:179:43: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   typedef std::reverse_iterator&amp;lt;iterator&amp;gt; reverse_iterator;&#xA;&#xA;                                           ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:189:16: error: no members matching 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}::_M_allocate' in 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}'&#xA;&#xA;   using _Base::_M_allocate;&#xA;&#xA;                ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:190:16: error: no members matching 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}::_M_deallocate' in 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}'&#xA;&#xA;   using _Base::_M_deallocate;&#xA;&#xA;                ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:191:16: error: no members matching 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}::_M_start' in 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}'&#xA;&#xA;   using _Base::_M_start;&#xA;&#xA;                ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:192:16: error: no members matching 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}::_M_finish' in 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}'&#xA;&#xA;   using _Base::_M_finish;&#xA;&#xA;                ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:193:16: error: no members matching 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}::_M_end_of_storage' in 'std::vector&amp;lt;Obstacle&amp;amp;&amp;gt;::_Base {aka struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;}'&#xA;&#xA;   using _Base::_M_end_of_storage;&#xA;&#xA;                ^&#xA;&#xA;In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\iosfwd:22:0,&#xA;&#xA;                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\iterator:35,&#xA;&#xA;                 from Navigation.ino:1:&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_alloc.h: In instantiation of 'class std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;':&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_alloc.h:638:22: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   typedef _Tp*       pointer;&#xA;&#xA;                      ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_alloc.h:639:22: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   typedef const _Tp* const_pointer;&#xA;&#xA;                      ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_alloc.h:658:8: error: forming pointer to reference type 'Obstacle&amp;amp;'&#xA;&#xA;   _Tp* allocate(size_type __n, const void* = 0) {&#xA;&#xA;        ^&#xA;&#xA;Navigation.ino: In constructor 'std::vector&amp;lt;_Tp, _Alloc&amp;gt;::vector(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::vector&amp;lt;_Tp, _Alloc&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]':&#xA;&#xA;Navigation.ino:36:24: note:   when instantiating default argument for call to std::vector&amp;lt;_Tp, _Alloc&amp;gt;::vector(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::vector&amp;lt;_Tp, _Alloc&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]&#xA;&#xA;In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\vector:35:0,&#xA;&#xA;                 from Navigation.ino:2:&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h: In instantiation of 'std::_Vector_base&amp;lt;_Tp, _Alloc&amp;gt;::~_Vector_base() [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]':&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:240:16:   required from 'std::vector&amp;lt;_Tp, _Alloc&amp;gt;::vector(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::vector&amp;lt;_Tp, _Alloc&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]'&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:117:21: error: 'struct std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;' has no member named '_M_deallocate'&#xA;&#xA;   ~_Vector_base() { this-&amp;gt;_M_deallocate(_Base::_M_start, _Base::_M_end_of_storage - _Base::_M_start); }&#xA;&#xA;                     ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:117:21: error: '_M_start' is not a member of 'std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;::_Base {aka std::_Vector_alloc_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;, true&amp;gt;}'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:117:83: error: '_M_start' is not a member of 'std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;::_Base {aka std::_Vector_alloc_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;, true&amp;gt;}'&#xA;&#xA;   ~_Vector_base() { this-&amp;gt;_M_deallocate(_Base::_M_start, _Base::_M_end_of_storage - _Base::_M_start); }&#xA;&#xA;                                                                                   ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:117:83: error: '_M_end_of_storage' is not a member of 'std::_Vector_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt; &amp;gt;::_Base {aka std::_Vector_alloc_base&amp;lt;Obstacle&amp;amp;, std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;, true&amp;gt;}'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h: In instantiation of 'std::_Vector_alloc_base&amp;lt;_Tp, _Allocator, true&amp;gt;::_Vector_alloc_base(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Allocator = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::_Vector_alloc_base&amp;lt;_Tp, _Allocator, true&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]':&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:110:54:   required from 'std::_Vector_base&amp;lt;_Tp, _Alloc&amp;gt;::_Vector_base(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::_Vector_base&amp;lt;_Tp, _Alloc&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:240:16:   required from 'std::vector&amp;lt;_Tp, _Alloc&amp;gt;::vector(const allocator_type&amp;amp;) [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;; std::vector&amp;lt;_Tp, _Alloc&amp;gt;::allocator_type = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]'&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:85:53: error: using invalid field 'std::_Vector_alloc_base&amp;lt;_Tp, _Allocator, true&amp;gt;::_M_start'&#xA;&#xA;     : _M_start(0), _M_finish(0), _M_end_of_storage(0) &#xA;&#xA;                                                     ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:85:53: error: using invalid field 'std::_Vector_alloc_base&amp;lt;_Tp, _Allocator, true&amp;gt;::_M_finish'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:85:53: error: using invalid field 'std::_Vector_alloc_base&amp;lt;_Tp, _Allocator, true&amp;gt;::_M_end_of_storage'&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h: In instantiation of 'std::vector&amp;lt;_Tp, _Alloc&amp;gt;::~vector() [with _Tp = Obstacle&amp;amp;; _Alloc = std::allocator&amp;lt;Obstacle&amp;amp;&amp;gt;]':&#xA;&#xA;Navigation.ino:36:24:   required from here&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:284:42: error: '_M_start' was not declared in this scope&#xA;&#xA;   ~vector() { destroy(_M_start, _M_finish); }&#xA;&#xA;                                          ^&#xA;&#xA;c:\program files (x86)\arduino\hardware\tools\avr\avr\include\stl_vector.h:284:42: error: '_M_finish' was not declared in this scope&#xA;&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11697" LastEditorUserId="11697" LastEditDate="2015-08-09T22:10:04.090" LastActivityDate="2015-08-10T00:19:37.467" Title="Using STL vector to create an array causes an error" Tags="|programming|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14053" PostTypeId="2" ParentId="9481" CreationDate="2015-08-09T21:33:03.447" Score="4" Body="&lt;p&gt;Only &lt;strong&gt;some&lt;/strong&gt; ports on the Atmega2560 support pin-change interrupts, specifically ports B, E (bit 0), J (bits 0 to 6) and K.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the reference schematic that means that these pins on the board are supported:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     Chip&#xA;Name  Pin  Pin on board&#xA;-----------------------&#xA;&#xA;Port B&#xA;&#xA;PB0 - 19 - D53 (SS)&#xA;PB1 - 20 - D52 (SCK)&#xA;PB2 - 21 - D51 (MOSI)&#xA;PB3 - 22 - D50 (MISO)&#xA;PB4 - 23 - D10 &#xA;PB5 - 24 - D11&#xA;PB6 - 25 - D12&#xA;PB7 - 26 - D13&#xA;&#xA;Port E&#xA;&#xA;PE0 - 2 - D0 (RXD0)&#xA;&#xA;Port J&#xA;&#xA;PJ0 - 63 - D15 (RXD3)&#xA;PJ1 - 64 - D14 (TXD3)&#xA;PJ2 to PJ6 - not connected on board&#xA;&#xA;Port K&#xA;&#xA;PK0 - PK7 - (89 - 82)  - A8 - A15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus you can see that D10 to D12, which you say works, are in that list. Other random ones would not be.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;SoftwareSerial&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can see confirmation on the page for &lt;a href=&quot;https://www.arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;SoftwareSerial&lt;/a&gt; where it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is because SoftwareSerial uses pin-change interrupts to detect incoming serial data, and thus the disclaimer on that page about which pins it will work with.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Atmega2560 pin-outs&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N3mkj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N3mkj.png&quot; alt=&quot;Atmega2560 pin-outs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;PinchangeInt should work on any digital pin&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the Atmega328P (as used in the Uno) has less ports, and all are available for pin-change interrupts on that board.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-09T21:33:03.447" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14054" PostTypeId="1" AcceptedAnswerId="14055" CreationDate="2015-08-09T22:58:55.517" Score="1" ViewCount="2700" Body="&lt;p&gt;In order to finish a synth project that I'm working on I built a MIDI interface. To test it, I drew up some code which (is supposed to) light up an LED when any key is pressed. The light turns off again when the key is released. This will later be merged with another branch of code &lt;a href=&quot;https://arduino.stackexchange.com/questions/13354/writing-midi-notes-more-quickly-to-a-shift-register-with-arduino/13362#13362&quot;&gt;here&lt;/a&gt; to tell me &lt;em&gt;which&lt;/em&gt; note is playing. This sounds simple enough but the devil's in the details. Due to my project's size constraints I am using ATMEL's ATtiny85 chip instead of my Arduino Uno. The ATtiny doesn't support the Arduino Serial library and by extension the standard MIDI library. As I can't make use of simple functions like MIDI.read() I've opted to work with an alternative Software Serial technique I adapted from an &lt;a href=&quot;http://www.instructables.com/id/Send-and-Receive-MIDI-with-Arduino/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instructable&lt;/a&gt;. Unfortunately, the results have been less than exemplary. Simply put, the LED almost never lights up. I have conducted two test only 1 of which &lt;em&gt;somewhat&lt;/em&gt; succeeded:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(velocityByte &amp;gt; 0 ){digitalWrite(LED, HIGH);}&#xA;if(velocityByte == 0 ){digitalWrite(LED, LOW);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Initially, I had figured that would be the most successful of my options. My keyboard* is binary about its ouput velocity. There are no pressure sensors so &quot;on&quot; is on and &quot;off&quot; is off. Unfortunately, however, the code seems to think otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(commandByte == noteOn ){digitalWrite(LED, HIGH);}&#xA;if(commandByte != noteOff ){digitalWrite(LED, LOW);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though originally less sure of this one, I've found it to be better than the other at catching notes. noteOn is the integer 144. While it does in fact trigger it does so only very rarely - once every 10 presses or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe I have however, whittled down the possible number of problems to 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Something is up with one or more of my calls to Serial. I've never really felt super confident with the author's method of obtaining data from Serial. For one, I have no confidence that I can insure I have collected the correct byte. If the code were to somehow &quot;miss&quot; counting a byte would it not assign, say, a commandByte to a noteByte? Is a better method available?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) My keyboard's MIDI protocol is incompatible with my if-statement cases.&#xA;At first I was under the assumption that my keyboard never sends a true &quot;note off&quot; message of any kind but instead a velocity = 0 message. But my test casts much doubt on this being the case and because of this, I don't &lt;em&gt;really&lt;/em&gt; know how the keyboard handles note off messages. Does anyone else know?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*A Yamaha YPT-230 &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//MIDI INPUT LED TEST&#xA;//Adapted from code written&#xA;//by Instructables user Amanda Ghassaei&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(0, 1);  //RX, TX&#xA;&#xA;#define LED 2&#xA;&#xA;byte commandByte;&#xA;byte noteByte;&#xA;byte velocityByte;&#xA;&#xA;byte noteOn = 144;&#xA;byte noteOff = 128;&#xA;&#xA;void setup(){&#xA;  mySerial.begin(31250);&#xA;  digitalWrite(LED, LOW); &#xA;  delay(1000);&#xA;}&#xA;&#xA;void checkMIDI(){&#xA;  do{&#xA;    commandByte = mySerial.read();//read first byte&#xA;    noteByte = mySerial.read();//read next byte&#xA;    velocityByte = mySerial.read();//read final byte&#xA;&#xA;    if (commandByte == noteOn){&#xA;      digitalWrite(LED, HIGH);&#xA;    }&#xA;    if(commandByte != noteOn){&#xA;      digitalWrite(LED, LOW);&#xA;    }  &#xA;&#xA;  }&#xA;  while (mySerial.available() &amp;gt; 2);//when at least three bytes available&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  checkMIDI();&#xA;}&#xA;/*&#xA;void gotNoteOn(commandByte, noteByte, velocityByte){&#xA;  digitalWrite(LED,HIGH);&#xA;}&#xA;&#xA;void gotNoteOff(commandByte, noteByte, velocityByte){&#xA;  digitalWrite(LED,LOW);&#xA;}&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; Following a suggesting, I have replaced the do .. while loop with an ordinary while loop. Relevant changes below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void checkMIDI(){&#xA;  while(mySerial.available() &amp;gt; 2){&#xA;    commandByte = mySerial.read();&#xA;    if (velocityByte &amp;gt; 0x00){//if note on message&#xA;      digitalWrite(LED, HIGH);&#xA;    }&#xA;    if(velocityByte == 0x00){&#xA;      digitalWrite(LED, LOW);&#xA;    }  &#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to think it's an improvement but if so only a slight one. Curiously, it almost works backwards - The default state of the LED is on while pressing a key produces no change pressing and &lt;em&gt;holding&lt;/em&gt; causes the light to briefly shut off. But even this is sporadic. It may also be worth noting that I elected to use hex '0x00' as opposed to decimal '0'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE II / NOTE&lt;/strong&gt; Having slept on the problem I think I now understand why I am encountering this issue in the first place. The author of the Instructables code I adapted used an Arduino for both MIDI In as well as MIDI Out. Had they simply hooked one Arduino Uno to the other in an in/out configuration they could have perfectly ensured there were no running status issues by just never sending any running status messages. This would explain the lack of conformity to the actual realities of MIDI on the input side. If you can control exactly what data you are sending on one end (MIDI Out) it becomes fairly trivial to receive that data on the other end (MIDI In). Generalizing, the author may have assumed that a true keyboard behave the same thing and failed to actually verify this. Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE III&lt;/strong&gt; Following the lead of CL but deviating somewhat because I didn't fully understand what CL was doing, I have written up a highly derivative, new code. It is based around what I now know to be the highly fluid nature of MIDI messages and seeks to intelligently discriminate important messages from non-important messages based on content. It does not work (except for LED test at the beginning) but seems like a promising step nonetheless.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//MIDI Input LED Test&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(0, 1);  //RX, TX&#xA;&#xA;#define LED 2  //Test LED&#xA;&#xA;void setup(){&#xA;  mySerial.begin(31250);&#xA;  digitalWrite(LED, HIGH); //Test&#xA;  delay(1000);&#xA;  digitalWrite(LED, LOW); &#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop(){&#xA;  checkMIDI();&#xA;} &#xA;&#xA;void checkMIDI(){&#xA;/*Two of the three independent types of bytes are always&#xA;distinct and can be identified simply by their values.&#xA;A Status byte (on channel 1 at least) is always either&#xA;0x80 (off) or 0x90 (on). No other type of message&#xA;(Note, Velocity) can ever take this value and so if&#xA;this is the value of the byte received I can be&#xA;assured it is a Status byte.&#xA;&#xA;The Note and Velocity bytes are a bit (haha) dicier.&#xA;They have overlapping ranges with both taking values of&#xA;anywhere between 0x00 to 0x7F. *Ordinarily*. A caveat&#xA;is that my Yamaha YPT-230 is binary as far as velocity&#xA;goes. A YPT-230 data is either 0x00 (full off) or 0x7F&#xA;(full on). As long as a Note byte is never 0 or 127 I can&#xA;use this to discriminate between these two types&#xA;in this manner.&#xA;*/   &#xA;&#xA;  if(mySerial.available() &amp;gt; 0){&#xA;    byte b = mySerial.read();&#xA;&#xA;    if(b == 0x80 || 0x90){&#xA;      byte commandByte = b;&#xA;    }else if(b == 0x00 || 0x7F){&#xA;      if(b == 0x00){&#xA;        digitalWrite(LED, LOW);  //If vel = 0 turn LED off&#xA;      }else if(b == 0x7F){&#xA;        digitalWrite(LED, HIGH); //If vel = 127 turn LED on&#xA;      }&#xA;      //velocityByte = b;&#xA;    }else{&#xA;      byte noteByte = b;  //Do nothing with this for right now.&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11165" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2017-11-02T20:42:34.883" Title="Interfacing an ATtiny85 with MIDI via Software Serial" Tags="|led|attiny|softwareserial|midi|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="14055" PostTypeId="2" ParentId="14054" CreationDate="2015-08-09T23:31:21.480" Score="4" Body="&#xA;&#xA;&lt;p&gt;I suggest you first find what your Yamaha is sending you. I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12746&quot; rel=&quot;nofollow noreferrer&quot;&gt;sketch that decodes MIDI&lt;/a&gt; for the Uno (assuming you have a Uno lying around). Run that, and see if you got note on with velocity zero, or note off. Then you are a little closer to solving the problem.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This part is quite wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  do{&#xA;    commandByte = mySerial.read();//read first byte&#xA;    noteByte = mySerial.read();//read next byte&#xA;    velocityByte = mySerial.read();//read final byte&#xA;&#xA;  ...&#xA;&#xA;  }&#xA;  while (mySerial.available() &amp;gt; 2);//when at least three bytes available&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are reading 3 bytes, even if none are available. At least change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;while (mySerial.available() &amp;gt; 2)&#xA;  {&#xA;        commandByte = mySerial.read();//read first byte&#xA;        noteByte = mySerial.read();//read next byte&#xA;        velocityByte = mySerial.read();//read final byte&#xA;&#xA;      ...&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;do ... while&lt;/code&gt; construct tests at the end of the loop. You must ensure you have 3 bytes &quot;available&quot; &lt;strong&gt;before&lt;/strong&gt; reading 3 of them, not after.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example code for ATtiny85&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The code below is an adaptation of the MIDI decoder in my link above. This one just reads the incoming MIDI and turns on the LED on a &quot;note on&quot; and turns it off on a &quot;note off&quot; (or note on with velocity zero). Tested, works perfectly.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//  MIDI_decoder for ATtiny85&#xA;//  &#xA;// ATMEL ATTINY 25/45/85 / ARDUINO&#xA;// Pin 1 is /RESET&#xA;//&#xA;//                  +-\/-+&#xA;// Ain0 (D 5) PB5  1|    |8  Vcc&#xA;// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1 &#xA;// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1&#xA;//            GND  4|    |5  PB0 (D 0) pwm0&#xA;//                  +----+&#xA;&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte LED = 0;   // pin 5 on ATtiny85&#xA;&#xA;// Plug MIDI into pin D2 (MIDI in serial) (pin 7 on ATtiny85)&#xA;&#xA;SoftwareSerial midi (2, 3);  // Rx, Tx&#xA;&#xA;const int noRunningStatus = -1;&#xA;&#xA;int runningStatus;&#xA;unsigned long lastRead;&#xA;byte lastCommand;&#xA;&#xA;void setup() {&#xA;  //  Set MIDI baud rate:&#xA;  midi.begin(31250);&#xA;  runningStatus = noRunningStatus;&#xA;  pinMode (LED, OUTPUT);&#xA;} // end of setup&#xA;&#xA;void RealTimeMessage (const byte msg)&#xA;  {&#xA;    // ignore realtime messages&#xA;  } // end of RealTimeMessage&#xA;&#xA;// get next byte from serial (blocks)&#xA;int getNext ()&#xA;  {&#xA;&#xA;  if (runningStatus != noRunningStatus)&#xA;    {&#xA;    int c = runningStatus;&#xA;    // finished with look ahead&#xA;    runningStatus = noRunningStatus;&#xA;    return c;&#xA;    }&#xA;&#xA;  while (true)&#xA;    {&#xA;    while (midi.available () == 0)&#xA;      {}&#xA;    byte c = midi.read ();&#xA;    if (c &amp;gt;= 0xF8)  // RealTime messages&#xA;      RealTimeMessage (c);&#xA;    else&#xA;      return c;&#xA;    }&#xA;  } // end of getNext&#xA;&#xA;const char * notes [] = { &quot;C &quot;, &quot;C#&quot;, &quot;D &quot;, &quot;D#&quot;, &quot;E &quot;, &quot;F &quot;, &quot;F#&quot;, &quot;G &quot;, &quot;G#&quot;, &quot;A &quot;, &quot;A#&quot;, &quot;B &quot; };&#xA;&#xA;byte note;&#xA;byte octave;&#xA;byte velocity;&#xA;&#xA;// interpret a note in terms of note name and octave&#xA;void getNote ()&#xA;  {&#xA;  note = getNext ();&#xA;  octave = note / 12;&#xA;  note %= 12;&#xA;  }  // end of getNote&#xA;&#xA;void getVelocity ()&#xA;  {&#xA;  velocity = getNext ();&#xA;  }&#xA;&#xA;// show a control message &#xA;void showControlMessage ()&#xA;  {&#xA;   byte message =  getNext () &amp;amp; 0x7F;&#xA;   byte param = getNext ();&#xA;  }  // end of showControlMessage&#xA;&#xA;// read a system exclusive message &#xA;void showSystemExclusive ()&#xA;  {&#xA;  int count = 0;&#xA;  while (true)&#xA;    {&#xA;    while (midi.available () == 0)&#xA;      {}&#xA;    byte c = midi.read ();&#xA;    if (c &amp;gt;= 0x80)&#xA;      {&#xA;      runningStatus = c;&#xA;      return;  &#xA;      }&#xA;&#xA;    } // end of reading until all system exclusive done&#xA;  }  // end of showSystemExclusive&#xA;&#xA;void loop() &#xA;{&#xA;  byte c = getNext ();&#xA;  unsigned int parameter;&#xA;&#xA;  if (((c &amp;amp; 0x80) == 0) &amp;amp;&amp;amp; (lastCommand &amp;amp; 0x80))&#xA;    {&#xA;    runningStatus = c;&#xA;    c = lastCommand; &#xA;    }&#xA;&#xA;  // channel is in low order bits&#xA;  int channel = (c &amp;amp; 0x0F) + 1;&#xA;&#xA;  // messages start with high-order bit set&#xA;  if (c &amp;amp; 0x80)&#xA;    {&#xA;    lastCommand = c;&#xA;    switch ((c &amp;gt;&amp;gt; 4) &amp;amp; 0x07)&#xA;      {&#xA;      case 0:   // Note off&#xA;        getNote ();&#xA;        getVelocity ();&#xA;        digitalWrite (LED, LOW);&#xA;        break;&#xA;&#xA;      case 1:   // Note on&#xA;        getNote ();&#xA;        getVelocity ();&#xA;        if (velocity == 0)&#xA;          digitalWrite (LED, LOW);&#xA;        else&#xA;          digitalWrite (LED, HIGH);&#xA;        break;&#xA;&#xA;      case 2:  // Polyphonic pressure&#xA;        getNote ();&#xA;        parameter = getNext ();  // pressure&#xA;        break;&#xA;&#xA;      case 3: // Control change&#xA;        showControlMessage ();&#xA;        break;&#xA;&#xA;      case 4:  // Program change&#xA;        parameter = getNext ();  // program&#xA;        break;&#xA;&#xA;      case 5: // After-touch pressure&#xA;        parameter = getNext (); // value&#xA;        break;&#xA;&#xA;      case 6: // Pitch wheel change &#xA;        parameter = getNext () |  getNext () &amp;lt;&amp;lt; 7; &#xA;        break;&#xA;&#xA;      case 7:  // system message&#xA;        {&#xA;        lastCommand = 0;           // these won't repeat I don't think&#xA;        switch (c &amp;amp; 0x0F)&#xA;          {&#xA;          case 0: // Exclusive&#xA;            parameter = getNext (); // vendor ID&#xA;            showSystemExclusive ();&#xA;            break;&#xA;&#xA;          case 1: // Time code&#xA;            parameter = getNext () ;&#xA;            break;&#xA;&#xA;          case 2:  // Song position &#xA;            parameter = getNext () |  getNext () &amp;lt;&amp;lt; 7; &#xA;            break;&#xA;&#xA;          case 3: // Song select&#xA;            parameter = getNext () ;  // song&#xA;            break;&#xA;&#xA;          case 4:    // reserved&#xA;          case 5:    // reserved&#xA;          case 6:    // tune request&#xA;          case 7:    // end of exclusive&#xA;          case 8:    // timing clock&#xA;          case 9:    // reserved&#xA;          case 10:   // start&#xA;          case 11:   // continue&#xA;          case 12:   // stop&#xA;          case 13:   // reserved&#xA;          case 14:   // active sensing&#xA;          case 15:   // reset&#xA;             break;&#xA;&#xA;          }  // end of switch on system message  &#xA;&#xA;        }  // end system message&#xA;        break;&#xA;      }  // end of switch&#xA;    }  // end of if&#xA;  else&#xA;    {&#xA;    // unexpected, ignore &#xA;    }&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Suggested schematic&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WZxOG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WZxOG.png&quot; alt=&quot;MIDI schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;From a comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the 4N35 is too slow to work reliably with MIDI signals&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Below is an updated schematic that uses a faster opto-coupler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TNCq2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TNCq2.png&quot; alt=&quot;MIDI schematic with 6N137&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Admittedly the 4N35 is below spec for its rise time (it is supposed to be  less than 2 μs rise time, however the 4N35 is slower at between 3 µs and 7 µs). However during my testing it worked OK. It sounds like the faster rise time is specified to allow for multiple devices to be connected in series, a slow rise time will introduce distortion.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2017-11-02T20:42:34.883" LastActivityDate="2017-11-02T20:42:34.883" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="14056" PostTypeId="2" ParentId="14052" CreationDate="2015-08-10T00:19:37.467" Score="0" Body="&lt;pre&gt;&lt;code&gt;std::vector&amp;lt;Test&amp;amp;&amp;gt; test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes, well I doubt you can make a vector of references. A vector of &lt;strong&gt;pointers&lt;/strong&gt; I could believe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See, for example: &lt;a href=&quot;https://stackoverflow.com/questions/922360/why-cant-i-make-a-vector-of-references&quot;&gt;https://stackoverflow.com/questions/922360/why-cant-i-make-a-vector-of-references&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-08-10T00:19:37.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14057" PostTypeId="1" CreationDate="2015-08-10T02:04:54.070" Score="0" ViewCount="583" Body="&lt;p&gt;I'm new to Arduino shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to stack these two shields on an arduino uno for a home automation project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - Arduino Wifi Shield: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - Red Bear Lab BLE shield: &lt;a href=&quot;http://redbearlab.com/bleshield/&quot; rel=&quot;nofollow&quot;&gt;http://redbearlab.com/bleshield/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have pin contention, between the two shields:&#xA;The WiFi shield uses pins: 4, 7, 10, 11, 12, 13.&#xA;The BLE shield uses pins: 10, 11, 12, 13. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a hardware or software way to allow the two shields to work together?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw in a similar thread, someone reccomended a go-between shield: &lt;a href=&quot;https://www.sparkfun.com/products/11002&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11002&lt;/a&gt;, would this be something that I could use in this case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's not possible, are there other shields that will work together?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15552" OwnerDisplayName="atkHOBO" LastActivityDate="2023-02-13T11:01:20.160" Title="How to setup Arduino Wifi Shield with Red Bear Lab BLE Shield?" Tags="|bluetooth|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14058" PostTypeId="2" ParentId="14057" CreationDate="2015-08-10T02:43:59.480" Score="1" Body="&lt;p&gt;The way the Arduino talks to each of the shields is by first telling the device that it wants to communicate with it, and then by exchanging information with that device. The Arduino uses 3 pins, 11, 12, and 13, to communicate to both the shields, and a 4th pin which it uses to select which of the devices it wants to use. This way the Arduino can use connect to two shields at once, by just selecting one at a time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did some research, and found that the selection pin on the WiFi shield (which I believe is the same as yours: &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoWiFiShield&lt;/a&gt;) are pins 10 and 4; pin 4 for the SD card selection, and pin 10 for the WiFi selection. Now since pin 10 is used as a selection pin for both the WiFi shield and the BLE shield, you run into some problems: both the boards will be selected at the same time when pin 10 is used. In this case, you can use the Sparkfun go-between board you linked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've never used it myself, but it appears to be able to change what pin is attached where on the shield it's attached to. In this case, you want to put the WiFi shield on the bottom, then the Sparkfun go-between shield, then the BLE on the top. You want to set up the go-between shield to change pin numver 10 to another pin that's not being used (any pin but 11, 12, 13, 7, 4, or 10). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino code you will at some point declare which pin is being used to select which board. In this case, set the WiFi selection to 10 (default), the SD card selection to 4 (default), and the BLE selection to whatever pin you changed pin 10 from with the go-between shield. This way, when you select the shield on pin 10, it will only select one shield, rather than two.&lt;/p&gt;&#xA;" OwnerUserId="11699" LastActivityDate="2015-08-10T02:43:59.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14059" PostTypeId="1" CreationDate="2015-08-10T04:10:06.020" Score="0" ViewCount="1239" Body="&lt;p&gt;I been trying to interface MPU6050 and HMC5883 with an Arduino Pro Mini/Nano. I²C scanner works just fine and identifies the device with no issues. I let the I²C scanner run like for 5 minutes and I see fumes coming out of the chips and sometimes the Arduino itself is burnt. I tried pull up resistors 2.2k, 7k without any luck. Has anyone got any inputs to this issue. Really frustrating to spend a weekend on this :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To rule out the possibility of 5V supply causing the burn out I tried 3.3V from Nano and made promini 3.3V from 5V. Please see the pictures below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Nano 3.3v was used to power up the I²C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i4V9s.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i4V9s.jpg&quot; alt=&quot;Arduino Nano Circuit&quot;&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CSc0h.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CSc0h.jpg&quot; alt=&quot;Pro Mini Circuit&quot;&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pro Mini jumper was desoldered from 5V to 3.3V to see if the I²C chips are saved from being burnt. In both these setup voltage accross the I²C chip was measured and it was 3.3V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still no luck!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you guys are to make the same circuit how would you do it and where would you get the components from? I must be doing something wrong and hope we together can figure it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Components are bought from eBay and the links are here.&#xA;GY521 = goo.gl/Y4aDph &#xA;HMC5883 = goo.gl/DfrC9l&lt;br&gt;&#xA;Arduino Nano = goo.gl/CaAykI &#xA;PROMINI = goo.gl/79PVOM&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is some background of why this issue resolution is so important to me:&lt;/strong&gt;&#xA;Just give you a backgroud of why I am doing this: I am building a quadcopter myself. Infact built one using GY80, but the module was expensive also it eventually got burnt out for the same reason mentioned above. Here is the first successful test flight of my first quadcopter goo.gl/rn6xWG (add https:// since I am rookie there is limitation on how many links I can post). If I can make the same thing work using GY521 and HMC5883 it would be awesome and cheaper. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update on 08/11 @12:45 PM CST&#xA;I think it is because of the Pro Mini, I²C chips are getting fried. When using Nano, I think it is because of the voltage level difference between the SDA/SCL lines causing the problem. With Pro Mini tripped for 3.3V, I was not able to see any serial data from the chip too. To end all these I placed an order for 3.3V 8 MHz Pro Mini from amazon goo.gl/FjgTGj Let see how that goes.&lt;/p&gt;&#xA;" OwnerUserId="11701" LastEditorUserId="11529" LastEditDate="2015-12-14T13:59:07.387" LastActivityDate="2015-12-14T13:59:07.387" Title="MPU6050 or GY521/HMC5883 chips are burnt for no reason" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="14060" PostTypeId="1" CreationDate="2015-08-10T04:44:36.797" Score="0" ViewCount="115" Body="&#xA;&#xA;&lt;p&gt;It seems that I can't get the DC Motor function to work while also having servos driven off the other ports :(&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int pinI1=8;//define I1 interface&#xA;int pinI2=11;//define I2 interface &#xA;int speedpinA=9;//enable motor A&#xA;int pinI3=12;//define I3 interface &#xA;int pinI4=13;//define I4 interface &#xA;int speedpinB=10;//enable motor &#xA;int spead =220;//define the spead of motor&#xA;&#xA;Servo SteeringServo;  // create servo object to control a servo &#xA;&#xA;void setup()&#xA;{&#xA;  // Steering servo pin setup&#xA;  SteeringServo.attach(5);  // attaches the servo on pin 9 to the servo object&#xA;&#xA;  pinMode(pinI1,OUTPUT);&#xA;  pinMode(pinI2,OUTPUT);&#xA;  pinMode(speedpinA,OUTPUT);&#xA;  pinMode(pinI3,OUTPUT);&#xA;  pinMode(pinI4,OUTPUT);&#xA;  pinMode(speedpinB,OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void forward()&#xA;{&#xA;     analogWrite(speedpinA,spead);//input a simulation value to set the speed&#xA;     analogWrite(speedpinB,spead);&#xA;     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise&#xA;     digitalWrite(pinI3,LOW);&#xA;     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise&#xA;     digitalWrite(pinI1,HIGH);&#xA;}&#xA;void backward()//&#xA;{&#xA;     analogWrite(speedpinA,spead);//input a simulation value to set the speed&#xA;     analogWrite(speedpinB,spead);&#xA;     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise&#xA;     digitalWrite(pinI3,HIGH);&#xA;     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise&#xA;     digitalWrite(pinI1,LOW);&#xA;}&#xA;void left()//&#xA;{&#xA;     analogWrite(speedpinA,spead);//input a simulation value to set the speed&#xA;     analogWrite(speedpinB,spead);&#xA;     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise&#xA;     digitalWrite(pinI3,LOW);&#xA;     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise&#xA;     digitalWrite(pinI1,LOW);&#xA;}&#xA;void right()//&#xA;{&#xA;     analogWrite(speedpinA,spead);//input a simulation value to set the speed&#xA;     analogWrite(speedpinB,spead);&#xA;     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise&#xA;     digitalWrite(pinI3,HIGH);&#xA;     digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise&#xA;     digitalWrite(pinI1,HIGH);&#xA;}&#xA;void stop()//&#xA;{&#xA;     digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor. &#xA;     digitalWrite(speedpinB,LOW);&#xA;     delay(1000);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  left();&#xA;  delay(15000);  &#xA;  stop();&#xA;  right();&#xA;  delay(1000);&#xA; stop();&#xA; // delay(2000); Already commented out&#xA;  //forward();&#xA; // delay(2000);&#xA; // stop();&#xA;// backward();&#xA;  delay(12000); &#xA;  stop(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11702" LastEditorUserId="10794" LastEditDate="2015-08-10T05:47:34.867" LastActivityDate="2015-08-10T05:51:53.250" Title="Arduino Motor Shield" Tags="|motor|servo|arduino-motor-shield|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14061" PostTypeId="2" ParentId="14060" CreationDate="2015-08-10T05:51:53.250" Score="1" Body="&lt;p&gt;Your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int speedpinA=9;//enable motor A&#xA;...&#xA;int speedpinB=10;//enable motor &#xA;...&#xA; analogWrite(speedpinA,spead);//input a simulation value to set the speed&#xA; analogWrite(speedpinB,spead);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/reference/servo&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/reference/servo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On boards other than the Mega, use of the library &lt;strong&gt;disables analogWrite() (PWM) functionality on pins 9 and 10&lt;/strong&gt;, whether or not there is a Servo on those pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(My emphasis).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can't do that, exactly. Perhaps choose other pins for the analogWrite, pins that analogWrite supports, that are not 9 and 10.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-10T05:51:53.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14062" PostTypeId="2" ParentId="14054" CreationDate="2015-08-10T09:22:47.177" Score="2" Body="&lt;p&gt;This is not how the &lt;a href=&quot;http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/midispec.htm&quot; rel=&quot;nofollow&quot;&gt;MIDI protocol&lt;/a&gt; works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The incoming stream can contain other commands than note-on or note-off, and with running status, it is impossible to predict the length of any single command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need at least some kind of state machine to remember where in the command you are:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;byte nr;&#xA;&#xA;for (;;) {&#xA;    byte b = mySerial.read();&#xA;    if (b &amp;amp; 0x80) { // status byte&#xA;        if (b &amp;gt;= 0xf8) {&#xA;            // real-time command; ignore&#xA;        } else {&#xA;            commandByte = b;&#xA;            nr = 1;&#xA;        }&#xA;    } else { // data byte&#xA;        if ((commandByte &amp;amp; 0xf0) == 0x80 ||&#xA;            (commandByte &amp;amp; 0xf0) == 0x90) {&#xA;            if (nr == 1) {&#xA;                noteByte = b;&#xA;                nr = 2;&#xA;            } else if (nr == 2) {&#xA;                velocityByte = b;&#xA;                nr = 1;&#xA;&#xA;                if ((commandByte &amp;amp; 0xf0) == 0x90 &amp;amp;&amp;amp;&#xA;                    velocityByte &amp;gt; 0) {&#xA;                    // note on&#xA;                } else {&#xA;                    // note off&#xA;                }&#xA;            } &#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6802" LastActivityDate="2015-08-10T09:22:47.177" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14064" PostTypeId="1" AcceptedAnswerId="14065" CreationDate="2015-08-10T09:45:59.630" Score="0" ViewCount="8363" Body="&lt;p&gt;I would like to use an Arduino to make tasks in my life automatic - maybe to rotate every morning a motor, or to open a door. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can I run an Arduino as solo with no pc needed? Can i connect it to the Internet and can I setup software like PHP and Apache on it to control it over the internet? Has it any protocols like SSH like a normal server? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example: I will send over any protocol a signal to my Arduino with a certification and then the Arduino would run a function...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks ahead&lt;/p&gt;&#xA;" OwnerUserId="11708" LastEditorUserId="4143" LastEditDate="2015-08-10T10:34:44.470" LastActivityDate="2024-03-18T07:22:54.257" Title="Run an Arduino without a PC" Tags="|programming|remote-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14065" PostTypeId="2" ParentId="14064" CreationDate="2015-08-10T10:32:28.150" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I will use arduino to make tasks in my life automatic maybe to let rotate every morning a motor or to open the door.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's the kind of thing it's designed for.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So i will ask can i run arduino as solo so no pc needed, &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you only need a PC to program it, once programmed it will run without the PC.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I connect it to the internet &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, there are Ethernet and WiFi shields available for connecting it to a network.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and can I setup PHP and Apache on it to control it over it; has it any protocols like SSH like an normal server ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.  The Arduino isn't powerful enough to run software like that.  You would normally connect it via the network / internet to a server to process data.  It would just receive simple instructions or send data to the server for processing.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;as example: I will send over any protocol a signal to my Arduino with a certification and then the Arduino is running a function...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I assume by &quot;a certification&quot; you want to run SSL on the Arduino. That's not going to happen since it's way too underpowered for that.  As I mentioned earlier, the Arduino would connect to a server on the internet to receive its instructions, or you could interface to it directly within your local network (say from a smart phone) through a simple web server interface (very simplistic due to lack of memory - a few buttons and text, that sort of thing).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-10T10:32:28.150" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14066" PostTypeId="2" ParentId="14031" CreationDate="2015-08-10T14:16:15.127" Score="1" Body="&lt;p&gt;When I've gotten into a bind with data being generated faster than I can dump it, or the process cannot tolerate the printing delays, I've made a memory buffer to store as much raw data as I can and print it after the test-run. If you're not using a debugger (which can print memory contents), you'll still need to have serial print code in your sketch but it can execute after the you run the code under test. Store the minimum size raw data (to maximize the amount you can store) and do the formatting on your PC.&lt;br&gt; &#xA;If you need to be able see what happened prior to an unusual event your code can detect, use a ring buffer (FIFO) in memory and let it wrap around (don't even bother to detect wrap-around). As soon as your code detects the event, print the ring-buffer contents. &lt;br&gt;&#xA;It's not continuous capture but often, it's enough.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-10T14:16:15.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14068" PostTypeId="1" CreationDate="2015-08-10T16:41:51.873" Score="3" ViewCount="118" Body="&lt;p&gt;I want to connect a magnetic door open/closed sensor to a device that can transmit (or be queried for, whichever) the state of the door to a hub inside (probably RaspberryPi). The outside unit should...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Operate on as little power as possible (outside unit will consist of board, open/closed sensor, power, and transmitter)&lt;/li&gt;&#xA;&lt;li&gt;Be able to transmit from my back yard to inside my house (~15 meters to house &amp;amp; 1 or 2 walls).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am new to this and pretty &lt;strong&gt;confused as to whether I should use BLE, Zig/xbee, or 2.4ghz rf&lt;/strong&gt; (is that different? I am not even sure...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other considerations are cost (of course) and ease of use. I am a novice with hardware &amp;amp; want something easy to get up and running.&lt;/p&gt;&#xA;" OwnerUserId="11714" LastActivityDate="2015-08-10T20:01:49.660" Title="Which wireless technology should I use for my outside &quot;check-if-door-is-open&quot; project?" Tags="|bluetooth|xbee|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14069" PostTypeId="2" ParentId="14068" CreationDate="2015-08-10T18:25:56.890" Score="5" Body="&lt;p&gt;I agree with &lt;a href=&quot;https://arduino.stackexchange.com/users/2881/gerben&quot;&gt;@Gerben&lt;/a&gt; - the &lt;strong&gt;nRF24L01+&lt;/strong&gt; would probably be the most suitable for your application.  It should have enough range to go 15m through a few walls, and the cost is about as cheap as you can get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pick up cheap Chinese clone modules (not real nRF24L01+ but another chip that operates exactly the same) for around $2 each on eBay.  I by them by the bag full.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few good libraries around for controlling them with an Arduino so programming really isn't much of a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They even have the advantage that they can operate in a mesh network mode if you ever expand your system to incorporate other things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The connection to the module is a simple 5-wire SPI interface - SDC, MOSI, MISO, Chip Enable and Command Select pins, so you don't even need to mess with lots of wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about using them here: &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best library in existence is the RF24Network library: &lt;a href=&quot;https://github.com/maniacbug/RF24Network&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/maniacbug/RF24Network&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are looking for something more self-contained and stand-alone, you might look at the &lt;strong&gt;ESP8266&lt;/strong&gt; modules which are a programmable WiFi module.  They can either interface with an Arduino to be controlled through &lt;em&gt;AT&lt;/em&gt; commands, which is quite nasty, or they can be programmed directly using an Arduino-like API which can be obtained here: &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These modules are a little more expensive, but that cost is offset by not then needing an Arduino in the mix as well.  The &lt;a href=&quot;http://nodemcu.com/index_en.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NodeMCU&lt;/a&gt; is probably the easiest to work with since it contains the USB serial interface on board like an Arduino.  It also has its own &lt;em&gt;Lua&lt;/em&gt; based programming environment if you don't mind learning another new language, but you can use it with the Arduino API for ESP8266 above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 is also supported by the beta version of &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow noreferrer&quot;&gt;UECIDE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-08-10T20:01:49.660" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14070" PostTypeId="2" ParentId="7947" CreationDate="2015-08-10T18:36:37.127" Score="1" Body="&lt;p&gt;&lt;code&gt;sprintf()&lt;/code&gt; is a nicer way to do that (imo), however, there's nothing wrong with what you've done-- if you don't have a ton more code, I'd continue to use it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's simple and that's a lot more important that speed most of the time. Also, the likely memory usage isn't enough to worry about. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience, once I got past 1500 bytes SRAM (dynamic) memory usage, I ran into trouble. But my projects have a ton of code. I've read through the &lt;code&gt;String&lt;/code&gt; class code and it's totally reasonable-- you're not likely to experience lag there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Serial/SetTimeout&quot; rel=&quot;nofollow&quot;&gt;My bet is that the lag is due to the timeout period&lt;/a&gt;, try making it smaller.&lt;/p&gt;&#xA;" OwnerUserId="7236" LastEditorUserId="11086" LastEditDate="2015-08-11T12:07:16.460" LastActivityDate="2015-08-11T12:07:16.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14074" PostTypeId="1" CreationDate="2015-08-10T22:39:07.527" Score="1" ViewCount="2204" Body="&lt;p&gt;I'm quite new to Arduino and have looked at many tutorials featuring an Arduino requesting data from a web server through a Wifi Shield, but haven't seen one featuring the sending of data from a website/server to an Arduino. I'm attempting to use a JavaScript then PHP script to send a string variable to the Arduino, which would then of course run its code at this point. Is this possible if I have a Wifi Shield and the Arduino's IP address? &lt;/p&gt;&#xA;" OwnerUserId="11716" LastActivityDate="2015-10-11T04:35:36.277" Title="Sending A String from a Website to Arduino" Tags="|shields|wifi|web-server|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14075" PostTypeId="1" CreationDate="2015-08-11T01:30:39.267" Score="1" ViewCount="150" Body="&lt;p&gt;I am currently working on a wireless home automation system. The system is connected to a wireless network in the home via the ethernet cable connected the ethernet shield and router. Hence, I need more pins on the Arduino to connect the appliances to be controlled in the home.&lt;/p&gt;&#xA;" OwnerUserId="11718" LastEditorUserId="6936" LastEditDate="2015-08-11T12:07:37.343" LastActivityDate="2015-08-11T12:07:37.343" Title="Can a shift register be used to extend the Arduino pins when an ethernet shield is mounted on the Arduino?" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14076" PostTypeId="2" ParentId="14075" CreationDate="2015-08-11T02:03:12.070" Score="3" Body="&lt;p&gt;You can control a shift register with &lt;a href=&quot;https://www.arduino.cc/en/Reference/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;shiftOut&lt;/a&gt; or bit-banged SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My page about &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; has a small library that does bit-banged SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to control a shift register using the &lt;strong&gt;same&lt;/strong&gt; pins (MOSI/MISO/SCK) that the Ethernet interface uses, as long as you use a different SS (slave select) pin for your shift register. This may not be practical if the Ethernet card is active all the time. It is probably easier to do the bit-banged SPI or use &lt;code&gt;shiftOut&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-11T02:03:12.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14078" PostTypeId="1" AcceptedAnswerId="14081" CreationDate="2015-08-10T21:10:57.727" Score="0" ViewCount="2158" Body="&lt;p&gt;Maybe a simple question, but I can't seem to find it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parity check is simple error detection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But is in done in hardware on the arduino and is the data discarded before i can read it from software?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I ask this quote from Thomas&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1  Command bit, set on the first character of each datagram. Reflected in the parity bit of most UARTs. Not compatible with NMEA0183 but well suited for the multiprocessor communications mode of 8051-family microcontrollers (bit SM2 in SCON set).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;http://www.thomasknauf.de/rap/seatalk1.htm#Dat&quot; rel=&quot;nofollow&quot;&gt;http://www.thomasknauf.de/rap/seatalk1.htm#Dat&lt;/a&gt; which might have confused me. So I guess this is not an option ... after the feedback from users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i need to read the 9 bit and since the hardware support it. The Arduino team won't implement it, since it has a bigger overhead and it's really not used anymore ... I agree ... but the SeaTalk bus uses it ... so I'm stuck here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But after more seaching I found this GitHub repo: &lt;a href=&quot;https://github.com/rob42/FreeboardPLC_v1_2&quot; rel=&quot;nofollow&quot;&gt;https://github.com/rob42/FreeboardPLC_v1_2&lt;/a&gt; which have made changes to the HardwareSerial.h and HardwareSerial.cpp but only for version 1.5.7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think I will go for this version unless someone have done the mods to 1.6.x ... have searched the web. Later I will try to see if I can get it to work with 1.6.x ... but since this is all new. I'm taking small steps.&lt;/p&gt;&#xA;" OwnerUserId="11723" OwnerDisplayName="Syska" LastEditorUserId="11723" LastEditDate="2015-08-11T08:21:10.717" LastActivityDate="2015-08-11T10:35:12.070" Title="Is parity check hardware only or can I read it? ( Arduino Mega )" Tags="|serial|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14079" PostTypeId="2" ParentId="14078" CreationDate="2015-08-10T22:45:49.457" Score="2" Body="&lt;p&gt;AVR devices with a hardware USART have a real 9-bit mode; there is no need to &quot;fake&quot; it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to answer your question, it is done in hardware; the appropriate USART Parity Error bit is set and while the datasheet is vague about it, it is implied that the data is stored in the receive buffer.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-08-10T22:45:49.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14080" PostTypeId="2" ParentId="602" CreationDate="2015-08-11T08:55:56.333" Score="1" Body="&lt;p&gt;I had faced similar problems and the solution that worked for me was to power the burning circuit with the Arduino onboard 5 volt. 3.3 Volt does work but at times it gives these errors especially while burning the bootloader. &lt;/p&gt;&#xA;" OwnerUserId="11725" LastActivityDate="2015-08-11T08:55:56.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14081" PostTypeId="2" ParentId="14078" CreationDate="2015-08-11T10:35:12.070" Score="3" Body="&#xA;&#xA;&lt;p&gt;This came up a while back on &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=91377.0&quot; rel=&quot;nofollow&quot;&gt;the Arduino Forum&lt;/a&gt; - talking about &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=54120&quot; rel=&quot;nofollow&quot;&gt;Asynchronous SeaTalk&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a modified version of HardwareSerial which can be downloaded from &lt;a href=&quot;http://gammon.com.au/Arduino/HardwareSerial9bit.zip&quot; rel=&quot;nofollow&quot;&gt;http://gammon.com.au/Arduino/HardwareSerial9bit.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changes are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The internal buffers have been changed from 8-bit characters to 16-bit characters (to hold the 9th bit). Thus the buffers double in size.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a new argument to the Serial.begin() function, which is a boolean, whether or not you want 9-bit mode. It defaults to false.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a new function &lt;code&gt;Serial.write9bit ()&lt;/code&gt;. This takes an unsigned int argument, letting you supply a character with the 9th bit set. I didn't want to change the existing write function because it is used in the Print class.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The read function, which already returns an int, now will return the 9th bit where required.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;{&#xA; Serial.begin (115200);  // debugging prints&#xA; Serial1.begin (115200, true);  // 9 bit mode&#xA; Serial2.begin (115200, true);  // 9 bit mode&#xA; Serial.println (&quot;--- starting ---&quot;);&#xA;}  // end of setup&#xA;&#xA;int i;&#xA;&#xA;void loop ()&#xA;{&#xA;&#xA; Serial1.write9bit (i++);  // send another byte&#xA;&#xA; // display incoming on Serial2&#xA; if (Serial2.available ())&#xA;   Serial.println ((int) Serial2.read (), HEX);&#xA;&#xA; // check if we have sent all possible characters&#xA; if (i &amp;gt;= 0x200)&#xA;   {&#xA;   delay (100);&#xA;   while (Serial2.available ())&#xA;     Serial.println ((int) Serial2.read (), HEX);&#xA;   delay (5000);&#xA;   i = 0;&#xA;   }  // end of sent 512 bytes&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Ignacio Vazquez-Abrams said, the hardware supports this 9-bit mode natively, it just takes a bit of fiddling around to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the way that hardware serial is integrated into the IDE it is, unfortunately, necessary to find your existing files:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;HardwareSerial.cpp&lt;/li&gt;&#xA;&lt;li&gt;HardwareSerial.h&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;... and replace them with the ones in the download.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note that this is for version &lt;strong&gt;1.0.1&lt;/strong&gt; of the IDE. No guarantees are given that this will work with other versions. This was written a while back, I'm not sure what changes have been made to HardwareSerial in the meantime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual changes are here: &lt;a href=&quot;http://gammon.com.au/Arduino/hardwareSerial_diffs.txt&quot; rel=&quot;nofollow&quot;&gt;http://gammon.com.au/Arduino/hardwareSerial_diffs.txt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use those to guide your implementation on more recent versions, if the file download does not work &quot;as is&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-11T10:35:12.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14082" PostTypeId="1" CreationDate="2015-08-11T10:44:08.977" Score="1" ViewCount="1328" Body="&lt;p&gt;Hi everyone I recently bought an Arduino Mega and Arduino Ethernet Shield. There are lots of forum posts that say the shield should have a MAC address that is written on the back side of shield, but I don't have any sticker which has the MAC address. Does anyone know how I can get my MAC address or configure it with a new MAC address? Thanks &lt;/p&gt;&#xA;" OwnerUserId="11728" LastEditorUserId="11086" LastEditDate="2015-08-11T22:16:07.277" LastActivityDate="2015-08-12T08:39:16.257" Title="Ethernet shield not have MAC address sticker" Tags="|arduino-uno|arduino-mega|ethernet|" AnswerCount="1" CommentCount="1" ClosedDate="2015-08-14T21:08:57.937" ContentLicense="CC BY-SA 3.0" />
  <row Id="14085" PostTypeId="1" AcceptedAnswerId="14086" CreationDate="2015-08-11T15:21:31.470" Score="4" ViewCount="174" Body="&lt;p&gt;I'm looking at the datasheet of the ATMega328, and I see the different channels you can select for AD conversion. ADC0..7, ADC8 (temperature), 1.1V (V&lt;sub&gt;BG&lt;/sub&gt;), and lastly &lt;strong&gt;0V (GND)&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What would be the use of measuring 0V? &lt;/li&gt;&#xA;&lt;li&gt;Would it ever result in a reading other than &lt;code&gt;0&lt;/code&gt;? I find it very intriguing. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The datasheet doesn't seem to give any additional information about it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc8444.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR126&lt;/a&gt; seems to give a hint:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;configure 0V (GND) in ADC by setting Mux bitfield (MUX3:0) equal to 1111. This is done to discharge the capacitor of ADC. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Though I find the document rather strange (incomplete, lacking certain info, running the ADC at 500kHz while the datasheet says to not exceed 200kHz). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it to protect the ADC from to high a voltage in the ADC capacitor, when changing to a different (lower) reference voltage? Rather odd you need software to protect the IC, and it's not even mentioned in the datasheet. Also I've never seen anyone do this (e.g. when measuring the internal temperature of the ATMega).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-11T22:00:00.593" Title="Usefulness of measuring 0v using ADC" Tags="|atmega328|analogread|adc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14086" PostTypeId="2" ParentId="14085" CreationDate="2015-08-11T15:32:08.637" Score="4" Body="&lt;p&gt;That quote you mention says it all really.  It's purpose is to discharge the Sample And Hold capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That capacitor is used (as I'm sure you are aware) to store the incoming voltage while it's being sampled by the ADC.  The ADC operated in two main phases:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Acquisition&lt;/li&gt;&#xA;&lt;li&gt;Sampling&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;During acquisition the capacitor is connected to the incoming voltage.  During sampling it is disconnected from the incoming voltage and the voltage it stores is read into the internal registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes a certain amount of time for the voltage in the capacitor to equal that of the incoming voltage.    If you try reading at higher speeds then what voltage was in the capacitor from the previous sample can affect the new reading.  However, if you do each sample always from a known voltage in the capacitor (0V) then you get much more stable results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another good use for it is when using the ADC as a Charge Time Measurement Unit.  This is the proper way of performing capacitative sensing.  You apply a constant (tiny) current to an external capacitor (the sensing plates) for a specific period of time.  When that time is up you disconnect the constant current source and measure the voltage that has developed across that capacitance.  The capacitances and currents are small, and if there is a charge in your S&amp;amp;H capacitor at the time you do the sampling that will be back-fed into the touch sensor capacitative plates changing the voltage.  By ensuring that the S&amp;amp;H capacitor is at 0V before you sample the plates you won't be adversely affecting the voltage on the plates with successive readings (well, you will, but it will be consistently in the same way every time so it won't affect your overall results).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-11T15:32:08.637" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14088" PostTypeId="1" CreationDate="2015-08-11T17:28:03.313" Score="3" ViewCount="337" Body="&lt;p&gt;How do I enable debugging using Adafruit CC3000?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit_CC3000_Library&lt;/a&gt;.  I've followed the &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/examples/WebClient/WebClient.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;WebClient.ino example sketch&lt;/a&gt;.  I'm able to make 300 to 400 HTTP requests, but eventually the connection will hang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at the CC3000 &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/Adafruit_CC3000.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt; and &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library/tree/master/utility&quot; rel=&quot;nofollow noreferrer&quot;&gt;utilities&lt;/a&gt; and found that the &lt;code&gt;Adafruit_CC3000_Library&lt;/code&gt; has a &lt;code&gt;&amp;amp;Printer&lt;/code&gt; reference in a local variable called &lt;code&gt;CC3KPrinter&lt;/code&gt;.  I can't figure out how to enable or activate &lt;code&gt;CC3KPrinter&lt;/code&gt;, as it is in a code block contingent on &lt;code&gt;CHECK_PRINTER&lt;/code&gt;.  I thought that &lt;code&gt;#define&lt;/code&gt;-ing some variables in my sketch would help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// None of these flags seem to enable debug within the CC3000 code.&#xA;#define _CC3000_DEBUG  1&#xA;#define DEBUG_MODE     1&#xA;#define ENABLE_CC3K_PRINTER 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example code snippet within the CC3000 library that I'm trying to enable is at &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/Adafruit_CC3000.cpp#L916&quot; rel=&quot;nofollow noreferrer&quot;&gt;line 916&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  CHECK_PRINTER {&#xA;    CC3KPrinter-&amp;gt;println(F(&quot;Timed out waiting to connect&quot;));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11505" LastEditorUserId="11505" LastEditDate="2017-08-07T16:05:02.920" LastActivityDate="2019-08-28T14:02:15.630" Title="CC3000 Wifi: Enable Debug" Tags="|arduino-uno|serial|c++|wifi|library|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14090" PostTypeId="2" ParentId="8879" CreationDate="2015-08-11T17:44:04.567" Score="1" Body="&lt;p&gt;Just one correction. The the first 24 bits of the data are shifted into the first WS2812. That device loads those 24 bits into its PWM registers. If more data is transmitted, the first WS2812 shifts that out to the following WS2812. So the first data sent stays in the first WS2812, the 2nd data stays in the 2nd WS2812, and so on. This is explained in the data sheet.&#xA;Data-wise, it's a one-wire device. Power connections don't count.&lt;/p&gt;&#xA;" OwnerUserId="11735" LastActivityDate="2015-08-11T17:44:04.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14091" PostTypeId="2" ParentId="14074" CreationDate="2015-08-11T17:52:28.023" Score="1" Body="&lt;p&gt;On the yun, this functionality is built-in via the bridge. &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Bridge&quot; rel=&quot;nofollow&quot;&gt;Here's an example.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Via the shield, you now end up &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;writing your own webserver&lt;/a&gt; and responding appropriately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing it makes more sense to use the client (the web browser) to make the calls than the backend php, but in either case, once the webserver is up and going on the arduino, you're just using it like any other server.&lt;/p&gt;&#xA;" OwnerUserId="7236" LastActivityDate="2015-08-11T17:52:28.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14092" PostTypeId="2" ParentId="14082" CreationDate="2015-08-11T18:09:07.467" Score="2" Body="&lt;p&gt;According to &lt;a href=&quot;https://www.arduino.cc/en/Reference/EthernetBegin&quot; rel=&quot;nofollow&quot;&gt;this documentation&lt;/a&gt;, you can just provide your own.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;mac: the MAC (Media access control) address for the device (array of 6 bytes). this is the Ethernet hardware address of your shield. Newer Arduino Ethernet Shields include a sticker with the device's MAC address. For older shields, choose your own.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="407" LastEditorUserId="407" LastEditDate="2015-08-11T18:40:58.663" LastActivityDate="2015-08-11T18:40:58.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14093" PostTypeId="1" CreationDate="2015-08-11T18:35:36.163" Score="-1" ViewCount="108" Body="&lt;p&gt;Is there a way to make a yun an Ethernet-wifi bridge? Applications include giving wifi to raspberry pi and other Ethernet only devices and vice versa.&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2016-02-08T02:27:49.200" Title="Yum as eth-&gt;wlan adaptor" Tags="|wifi|arduino-yun|ethernet|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14094" PostTypeId="2" ParentId="14093" CreationDate="2015-08-11T19:17:15.607" Score="0" Body="&lt;p&gt;Yes, you can.  I use one to connect my Sky box (Ethernet only) to my WiFi network,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not an easy task though and you have to have a good understanding of networking and routing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you have to set the Yun up as a router to route packets between the Ethernet and the WiFi interfaces.  You set the Ethernet interface up on a separate subnet to your existing WiFi network, and set a static route on your main router to send traffic destined to your new Ethernet subnet to the Yun's WiFi IP address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Ethernet devices can then be allocated an IP address on the Ethernet subnet (turn on DCHP for that interface on the Yun) and will use the Yun as the default gateway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are probably ways you can enable bridging on the Yun to tie the Ethernet and WiFi interfaces together so it becomes transparent but I haven't investigated that yet.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-11T19:17:15.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14095" PostTypeId="1" CreationDate="2015-08-11T20:05:00.910" Score="1" ViewCount="1714" Body="&lt;p&gt;I am a beginner trying to upload the &lt;a href=&quot;https://github.com/GreyGnome/PinChangeInt/blob/master/Examples/SimpleExample328/SimpleExample328.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;SimpleExample328.ino sketch&lt;/a&gt; on my Arduino Uno. When I verify my sketch however, I run into the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'AttachPinChangeInterrupt' was not declared in this scope.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would assume the header file &lt;code&gt;PinChangeInt.h&lt;/code&gt; is not in the correct location; currently the &lt;code&gt;PinChangeInt&lt;/code&gt; folder (that contains &lt;code&gt;PinChangeInt.h&lt;/code&gt;) is placed in the &lt;code&gt;Arduino IDE libraries&lt;/code&gt; folder, which I believe is the correct location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did I place the header file in the wrong location or does this error result from another cause? Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="11737" LastEditorUserId="19409" LastEditDate="2018-04-12T07:41:49.280" LastActivityDate="2023-08-14T21:01:55.257" Title="'AttachPinChangeInterrupt' was not declared in this scope" Tags="|arduino-uno|compilation-errors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14096" PostTypeId="2" ParentId="12775" CreationDate="2015-08-11T20:55:36.097" Score="1" Body="&lt;p&gt;Sounds good, a more capable linear regulator with heat sink. Another possibility is to get a DC to DC converter (buck regulator from 12 volts to 5 volts), that way is more energy efficient than a linear regulator. They cost just slightly more than a linear regulator on ebay, and don't need a heat sink.&lt;/p&gt;&#xA;" OwnerUserId="10736" LastActivityDate="2015-08-11T20:55:36.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14097" PostTypeId="1" CreationDate="2015-08-10T10:13:09.040" Score="1" ViewCount="1022" Body="&lt;p&gt;I have a 16x2 LCD display that is connected to an Arduino microcontroller.&#xA;It is working fine but the LCD display flickers when I connect the Vin and GND of the main board to its slave GSM Shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used main board Vin and GND to power up the GSM Shield so I only have one power supply. I was able to power up GSM Shield by adding jumper to Vin and GSM +Vin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In additional question, is there any other way to power up Arduino GSM Shield without connecting it to another power source to still keep having only one plug for power?&lt;/p&gt;&#xA;" OwnerUserId="7788" OwnerDisplayName="Ivory Santos" LastEditorUserId="10794" LastEditDate="2015-08-16T01:22:08.047" LastActivityDate="2016-01-13T10:52:49.670" Title="LCD Display Flicker When Arduino Main Board Supply Voltage to GSM Shield Board" Tags="|lcd|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14098" PostTypeId="2" ParentId="14097" CreationDate="2015-08-11T09:04:06.927" Score="1" Body="&lt;p&gt;This sounds like either your GSM Shield is drawing to much power (from time to time) and thus your Vin drops resulting in flickering or your GSM Shield induces ripple on top of your Vin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To debug this I would recommed to have a look at Vin with an oscilloscope and see how stable Vin is. Additionally some capacitors between Vin and GND (100nF and 10-100µF) and a ferrit between Vin and the GSM Shields Vin might help.&lt;/p&gt;&#xA;" OwnerUserId="11752" OwnerDisplayName="Tobias Müller" LastActivityDate="2015-08-11T09:04:06.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14099" PostTypeId="2" ParentId="14030" CreationDate="2015-08-11T21:51:37.287" Score="0" Body="&lt;p&gt;I simply connected the servo to an external power 5V power source, and everything works perfectly fine. It seems like the servo's resistance was too much for the RF receiver to be able to work as well.&lt;/p&gt;&#xA;" OwnerUserId="11678" LastActivityDate="2015-08-11T21:51:37.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14100" PostTypeId="1" CreationDate="2015-08-11T15:43:02.677" Score="0" ViewCount="4129" Body="&lt;p&gt;I wrote some code in C++ (Used libraries like fstream, vectors etc.) Now when I transferred the code to Arduino it wouldn't compile so I added the following library: &lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus&quot; rel=&quot;nofollow&quot;&gt;https://github.com/maniacbug/StandardCplusplus&lt;/a&gt; I downloaded the IDE from here: &lt;a href=&quot;https://www.arduino.cc/en/main/software&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/main/software&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now almost all my code works: All the libraries I've used work except for fstream which I've used to read a specific file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now is there a certain problem with the 'StandardCplusplus' library and how can I counter this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus can someone give me an alternative for fstream that works with Arduino. Was reading a bmp image using C++. Now fstream works in a certain way (reads the file in a certain way). Is there some alternative to fstream.&lt;/p&gt;&#xA;" OwnerUserId="11827" OwnerDisplayName="George Adams" LastActivityDate="2015-08-28T20:19:05.477" Title="How to make C++ code compatible with Arduino IDE?" Tags="|c++|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14101" PostTypeId="2" ParentId="14100" CreationDate="2015-08-11T15:47:54.487" Score="4" Body="&lt;p&gt;When you run that library on the Arduino and ask it to open a file, where do you imagine it would read the file from? Your Arduino has no hard disk or other file system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way to solve this is to include a library that emulates a read-only file system in the Arduino's flash. I dunno whether this exists (such libs do exist for for some other targets, for instance for the Nintendo DS), but it would be a bit of overkill IMO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to include the data that is in the file in your program, as a const (expr) array of bytes, and read from that array instead of from the file. But if you have a library that is coded to use file read calls this would require some rewriting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third approach would be to do the reading and interpreting of the file on your host PC, output the &lt;em&gt;interpreted&lt;/em&gt; content to a const (expr) byte array, and include that in your application. This frees you from having to include the bmp-read code in your image.&lt;/p&gt;&#xA;" OwnerUserId="43104" OwnerDisplayName="Wouter van Ooijen" LastEditorUserId="4628" LastEditDate="2015-08-12T13:38:22.137" LastActivityDate="2015-08-12T13:38:22.137" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14102" PostTypeId="2" ParentId="14100" CreationDate="2015-08-11T15:48:19.257" Score="2" Body="&lt;p&gt;If you want to write C++ for an Arduino, I'd recommend you cease using the Arduino IDE and instead use Atmel Studio. The microcontroller on board is an Atmel AVR, and you can write for that using the gcc-avr toolchain that comes with Atmel studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll lose the spiffy libraries that come with the arduino platform that abstract away a lot of the intricacies of the hardware, and you'll instead be looking at the AVR datasheet and the schematic of the arduino, but you'll learn quite a bit in the process and have direct control over the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all that said though, the AVR does not have a file system so using fstream doesn't make any sense to begin with.&lt;/p&gt;&#xA;" OwnerDisplayName="whatsisname" LastActivityDate="2015-08-11T15:48:19.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14103" PostTypeId="2" ParentId="14085" CreationDate="2015-08-11T22:00:00.593" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Though I find the document rather strange (incomplete, lacking certain info, running the ADC at 500kHz while the datasheet says to not exceed 200kHz). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The document actually says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The ADC can prescale the system clock to  provide an ADC clock that is between 50kHz and 200kHz &lt;strong&gt;to get maximum resolution&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(My emphasis)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It goes on to say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If ADC resolution of less than 10 bits required, then the ADC clock frequency can be higher than 200kHz. At 1MHz it is possible to achieve eight bits of resolution maximum.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I did some testing on &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; with different prescalers. The results showed that reasonable results could be obtained even with a 1 MHz ADC clock:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Prescaler 2&#xA;&#xA;Analog port = 0, average result = 1023&#xA;Analog port = 1, average result = 1023&#xA;Analog port = 2, average result = 1023&#xA;Analog port = 3, average result = 1022&#xA;Time taken = 26220&#xA;&#xA;Prescaler 4&#xA;&#xA;Analog port = 0, average result = 673&#xA;Analog port = 1, average result = 718&#xA;Analog port = 2, average result = 512&#xA;Analog port = 3, average result = 193&#xA;Time taken = 32780&#xA;&#xA;Prescaler 8&#xA;&#xA;Analog port = 0, average result = 842&#xA;Analog port = 1, average result = 677&#xA;Analog port = 2, average result = 509&#xA;Analog port = 3, average result = 34&#xA;Time taken = 46040&#xA;&#xA;Prescaler 16&#xA;&#xA;Analog port = 0, average result = 1022&#xA;Analog port = 1, average result = 672&#xA;Analog port = 2, average result = 509&#xA;Analog port = 3, average result = 0&#xA;Time taken = 73164&#xA;&#xA;Prescaler 32&#xA;&#xA;Analog port = 0, average result = 1022&#xA;Analog port = 1, average result = 672&#xA;Analog port = 2, average result = 508&#xA;Analog port = 3, average result = 0&#xA;Time taken = 128040&#xA;&#xA;Prescaler 64&#xA;&#xA;Analog port = 0, average result = 1022&#xA;Analog port = 1, average result = 672&#xA;Analog port = 2, average result = 508&#xA;Analog port = 3, average result = 0&#xA;Time taken = 240972&#xA;&#xA;Prescaler 128&#xA;&#xA;Analog port = 0, average result = 1022&#xA;Analog port = 1, average result = 672&#xA;Analog port = 2, average result = 508&#xA;Analog port = 3, average result = 0&#xA;Time taken = 448108&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The four test voltages were, and their results &lt;em&gt;should have&lt;/em&gt; been:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;5V (should return 1023)&lt;/li&gt;&#xA;&lt;li&gt;3.3V (should return 674)&lt;/li&gt;&#xA;&lt;li&gt;2.5V (should return 511)&lt;/li&gt;&#xA;&lt;li&gt;0V (should return 0)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The tests were done in rapid succession, no allowing for the ADC to recharge or anything:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; unsigned long startTime = micros ();&#xA;  for (int i = 0; i &amp;lt; ITERATIONS; i++)&#xA;    {&#xA;    for (int whichPort = lowPort; whichPort &amp;lt;= highPort; whichPort++)&#xA;       {&#xA;       int result = analogRead (whichPort);&#xA;       totals [whichPort - lowPort] += result;&#xA;       } &#xA;    }&#xA;  unsigned long endTime = micros ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-11T22:00:00.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14104" PostTypeId="2" ParentId="14100" CreationDate="2015-08-11T22:08:57.503" Score="1" Body="&lt;p&gt;The Arduino IDE &lt;em&gt;does&lt;/em&gt; compile your code using the avr-g++ compiler. In other words, it &lt;em&gt;is&lt;/em&gt; C++.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Was reading a bmp image using C++. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This isn't practical on the smaller Arduinos, at least, because they have so little RAM. They also don't have a file system. There is a &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow&quot;&gt;streaming&lt;/a&gt; library for output, which is very handy for streaming out things to Serial, LCDs, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the replies here mentioned that if you switch to Atmel Studio you can look at the datasheet and get down to the intricacies of the hardware. Well, you can certainly do that as well with the IDE. All the hardware registers are available for use. I often use the &quot;bare&quot; registers for timers, watchdog, interrupts etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also Atmel Studio only runs on Windows. You are out of luck if you use a Mac or Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a port of the &lt;a href=&quot;http://andybrown.me.uk/wk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;Standard Template Library&lt;/a&gt; for the Arduino, if you want to use vectors, lists, maps etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus&quot; rel=&quot;nofollow&quot;&gt;another port of the STL&lt;/a&gt; which may work better and be easier to install.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-12T05:40:47.677" LastActivityDate="2015-08-12T05:40:47.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14105" PostTypeId="2" ParentId="9656" CreationDate="2015-08-11T22:37:21.617" Score="0" Body="&lt;p&gt;first of all, I apologize for the English, I can understand it but i use google translator to express myself in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't use arduino, It's a interesting platform (for the ide, which is apparently object oriented programming POO), but extremely limited by the hardware &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, entering the subject, I am also developing an implementation for the MRFC522, and the datasheet does not give examples of how do it, but indicates how enable interrupts (although I have not tried ,yet) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;but if I'm not wrong, the following registers are involved: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ComIEnReg--&gt; Control register bits to enable and disable the passing of interrupt requests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DivIEnReg--&gt; control bits to enable and disable the passing of interrupt requests. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ComIrqReg--&gt; register Interrupt request bits. (I think it's read only)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DivIrqReg--&gt; register bit descriptions (I think it's read only)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's just properly setting the first two should be able to generate the interrupt on the pin irq. &#xA;i don't know if the following is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;set ComIEnReg to --&gt; (in binary) 0b01111111 //enables all al interrupts &lt;/p&gt;&#xA;&#xA;&lt;p&gt;set DivIEnReg to --&gt; 0b10000100  //I don't understand complete about MFIN (bit4) and set it to 0  but i set CRCIEn to 1 (bit 2) and bit7  to 1 &quot;pin IRQ is a standard CMOS output pin&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;// the different posible configuration to DivIEnReg&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;yours--&gt; 0b00010100 --&gt;0x14&lt;/li&gt;&#xA;&lt;li&gt;try 1 --&gt; 0b00000100 --&gt;0x04&lt;/li&gt;&#xA;&lt;li&gt;try 2 --&gt; 0b10010100 --&gt;0X94&lt;/li&gt;&#xA;&lt;li&gt;try 3 --&gt; 0b10000100 --&gt;0X84&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;if you manage to the module to do the interruption, it would be kind enough to comment on how you did&lt;/p&gt;&#xA;" OwnerUserId="11738" LastEditorUserId="11738" LastEditDate="2015-08-11T23:11:50.073" LastActivityDate="2015-08-11T23:11:50.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14106" PostTypeId="1" AcceptedAnswerId="14152" CreationDate="2015-08-11T22:39:16.320" Score="0" ViewCount="649" Body="&lt;p&gt;I have a folder of mostly .h and .cpp files for the Marlin firmware (3D Printing) from &lt;a href=&quot;https://nwreprap.com/software/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I compile that so I can upload it to my Arduino Mega with Ramps?&lt;/p&gt;&#xA;" OwnerUserId="11739" LastActivityDate="2015-08-13T10:01:25.767" Title="How do I compile the Marlin firmware?" Tags="|arduino-mega|compile|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14107" PostTypeId="1" AcceptedAnswerId="14119" CreationDate="2015-08-12T00:52:37.247" Score="0" ViewCount="759" Body="&lt;p&gt;I have an Arduino with ethernet shield and there are 8 different URLs that can be called to perform different actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program loads and runs as expected for the most part, but, if it is busy doing an action, it won't accept the next one until the current action has finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, the code's main loop listens for a client connection, then has a bunch of ifs that look in the URL that was called (for a query string) and then process the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at a few answers on here, but none deal with listening to HTTP requests. One recommended a library, but, I couldn't quickly get it to compile, and the other answer recommended a state machine - I do like this approach, however, I haven't had time to implement and it doesn't &quot;feel&quot; right as the listening for a HTTP request works on a &lt;code&gt;if(client)&lt;/code&gt; basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if anyone has done this before and/or has any advice?&lt;/p&gt;&#xA;" OwnerUserId="11740" LastActivityDate="2015-08-12T12:11:06.413" Title="Is it possible to accept multiple web requests at once?" Tags="|web-server|threads|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14108" PostTypeId="2" ParentId="9656" CreationDate="2015-08-12T02:21:07.613" Score="4" Body="&#xA;&#xA;&lt;p&gt;From your code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void isr()&#xA;{&#xA;  Serial.println(F(&quot;Interrupt&quot;));&#xA;  mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not do serial prints inside an ISR! They will eventually hang it. What you need to do is have a volatile variable (eg. a bool), set that in the ISR, and then check that in &lt;code&gt;loop&lt;/code&gt;. If it changes, display it. Eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile bool cardPresent;&#xA;&#xA;void loop() &#xA;{&#xA;  if (cardPresent)&#xA;    {&#xA;    Serial.println(F(&quot;Interrupt&quot;));&#xA;    mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts&#xA;    cardPresent = false;&#xA;    }&#xA;&#xA;}&#xA;&#xA;void isr()&#xA;{&#xA;  cardPresent = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The other thing I would do is put a scope or logic analyzer on the IRQ pin and see if it is actually changing. It &lt;em&gt;should&lt;/em&gt; trigger the interrupt if it does.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-12T02:21:07.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14109" PostTypeId="2" ParentId="14074" CreationDate="2015-08-12T02:40:44.893" Score="1" Body="&lt;p&gt;If you really want the Arduino to be a &lt;strong&gt;web server&lt;/strong&gt; (that is, you connect to it with your web browser) then I made a library a little while back to simplify processing the get/post/pathname/cookie arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12942&quot; rel=&quot;nofollow&quot;&gt;Tiny web server for Arduino or similar&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code (that comes with the library) turns on various LEDs (presumably connected to pins on the Arduino) upon getting a &quot;get&quot; request like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://10.0.0.241/?on=4&amp;amp;off=5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would turn on pin 4 and turn off pin 5. Obviously you change the IP address to suit your network, and use a suitable MAC address.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Tiny web server demo&#xA;// Author: Nick Gammon&#xA;// Date:  20 July 2015&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;HTTPserver.h&amp;gt;&#xA;&#xA;const int LOW_PIN = 3;&#xA;const int HIGH_PIN = 5;&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0x2D, 0xA1 };&#xA;&#xA;// The IP address will be dependent on your local network:&#xA;byte ip[] = { 10, 0, 0, 241 };&#xA;&#xA;// the router's gateway address:&#xA;byte gateway[] = { 10, 0, 0, 1 };&#xA;&#xA;// the subnet mask&#xA;byte subnet[] = { 255, 255, 255, 0 };&#xA;&#xA;// Initialize the Ethernet server library&#xA;EthernetServer server(80);&#xA;&#xA;// derive an instance of the HTTPserver class with custom handlers&#xA;class myServerClass : public HTTPserver&#xA;  {&#xA;  virtual void processPostType        (const char * key, const byte flags);&#xA;  virtual void processGetArgument     (const char * key, const char * value, const byte flags);&#xA;  };  // end of myServerClass&#xA;&#xA;myServerClass myServer;&#xA;&#xA;// -----------------------------------------------&#xA;//  User handlers&#xA;// -----------------------------------------------&#xA;&#xA;void myServerClass::processPostType (const char * key, const byte flags)&#xA;  {&#xA;  println(F(&quot;HTTP/1.1 200 OK&quot;));&#xA;  println(F(&quot;Content-Type: text/html\n&quot;&#xA;            &quot;Connection: close\n&quot;&#xA;            &quot;Server: HTTPserver/1.0.0 (Arduino)&quot;));&#xA;  println();   // end of headers&#xA;  println (F(&quot;&amp;lt;!DOCTYPE html&amp;gt;\n&quot;&#xA;             &quot;&amp;lt;html&amp;gt;\n&quot;&#xA;             &quot;&amp;lt;head&amp;gt;\n&quot;&#xA;             &quot;&amp;lt;title&amp;gt;Arduino test&amp;lt;/title&amp;gt;\n&quot;&#xA;             &quot;&amp;lt;/head&amp;gt;\n&quot;&#xA;             &quot;&amp;lt;body&amp;gt;\n&quot;));&#xA;&#xA;  } // end of processPostType&#xA;&#xA;void myServerClass::processGetArgument (const char * key, const char * value, const byte flags)&#xA;  {&#xA;&#xA;  int which = atoi (value);&#xA;  if (which &amp;gt;= LOW_PIN &amp;amp;&amp;amp; which &amp;lt;= HIGH_PIN)&#xA;    {&#xA;    if (strcmp (key, &quot;on&quot;) == 0)&#xA;      {&#xA;      digitalWrite (which, HIGH);&#xA;      print (F(&quot;&amp;lt;p&amp;gt;Turning on pin &quot;));&#xA;      println (which);&#xA;      }&#xA;    else  if (strcmp (key, &quot;off&quot;) == 0)&#xA;      {&#xA;      digitalWrite (which, LOW);&#xA;      print (F(&quot;&amp;lt;p&amp;gt;Turning OFF pin &quot;));&#xA;      println (which);&#xA;      }&#xA;    else&#xA;      {&#xA;      print (F(&quot;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Bad action: &quot;));&#xA;      fixHTML (value);&#xA;      println (F(&quot;&amp;lt;/b&amp;gt;&quot;));&#xA;      }&#xA;    }&#xA;  else&#xA;    {&#xA;    print (F(&quot;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Bad pin number: &quot;));&#xA;    fixHTML (value);&#xA;    println (F(&quot;&amp;lt;/b&amp;gt;&quot;));&#xA;    }&#xA;&#xA;  }  // end of processGetArgument&#xA;&#xA;// -----------------------------------------------&#xA;//  End of user handlers&#xA;// -----------------------------------------------&#xA;&#xA;void setup ()&#xA;  {&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac, ip, gateway, subnet);&#xA;&#xA;  for (int i = LOW_PIN; i &amp;lt;= HIGH_PIN; i++)&#xA;    pinMode (i, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // listen for incoming clients&#xA;  EthernetClient client = server.available();&#xA;  if (!client)&#xA;    {&#xA;    // do other processing here&#xA;    return;&#xA;    }&#xA;&#xA;  myServer.begin (&amp;amp;client);&#xA;  while (client.connected() &amp;amp;&amp;amp; !myServer.done)&#xA;    {&#xA;    while (client.available () &amp;gt; 0 &amp;amp;&amp;amp; !myServer.done)&#xA;      myServer.processIncomingByte (client.read ());&#xA;&#xA;    // do other stuff here&#xA;&#xA;    }  // end of while client connected&#xA;&#xA;  client.println(F(&quot;&amp;lt;hr&amp;gt;OK, done.&quot;));&#xA;&#xA;  client.println (F(&quot;&amp;lt;/body&amp;gt;\n&quot;&#xA;                    &quot;&amp;lt;/html&amp;gt;&quot;));&#xA;&#xA;  // give the web browser time to receive the data&#xA;  delay(1);&#xA;  // close the connection:&#xA;  client.stop();&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Library source on GitHub at &lt;a href=&quot;https://github.com/nickgammon/HTTPserver&quot; rel=&quot;nofollow&quot;&gt;nickgammon/HTTPserver&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library is designed to allow you to receive cookies, POST data, pathnames (on the URL) and GET parameters.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-12T02:40:44.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14110" PostTypeId="2" ParentId="14100" CreationDate="2015-08-12T04:27:17.537" Score="1" Body="&lt;p&gt;Are you using Arduino UNO? Look at the datasheet and see how much RAM the Arduino has. Assuming you are using Arduino Uno, it should be around 2kilobyte or less. So it is highly likely not to have enough memory to read the BMP file. Even if you are trying to read very small BMP file, the code reading the file would vary depending where you are reading the BMP file from (SD Card, SPI Flash memory, etc.) It cannot read files directly from your computer using just fstream. &lt;/p&gt;&#xA;" OwnerUserId="11742" LastEditorUserId="11742" LastEditDate="2015-08-12T06:33:15.127" LastActivityDate="2015-08-12T06:33:15.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14111" PostTypeId="1" AcceptedAnswerId="14114" CreationDate="2015-08-12T05:08:07.277" Score="0" ViewCount="718" Body="&lt;p&gt;I'd like to assemble a device that could accomplish the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connect to my home &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;wifi&lt;/a&gt; (WPA2-Personal)&lt;/li&gt;&#xA;&lt;li&gt;Connect to my home PC with via Ethernet cable&lt;/li&gt;&#xA;&lt;li&gt;Able to send &lt;a href=&quot;https://en.wikipedia.org/wiki/Wake-on-LAN&quot; rel=&quot;nofollow&quot;&gt;WoL&lt;/a&gt; signal to the PC when getting a signal over wireless connection&lt;/li&gt;&#xA;&lt;li&gt;The whole set up needs to be less than 45USD, desirably much less, otherwise I'd just buy a wireless bridge.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The goal is both to have a useful device (that will allow me to wake up my pc remotely) but also have fun learning something new (arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no background in Arduino or Electronics in general. I program well though and learn fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think Adruino is adequate for the above? Is soldering required (I'd rather not, or at least not a lot)? &lt;/p&gt;&#xA;" OwnerUserId="11791" LastEditorUserId="7856" LastEditDate="2015-08-13T15:51:17.573" LastActivityDate="2019-02-16T12:28:59.740" Title="Arduino for delivering a WoL signal over ethernet, when receiving a specific command over WiFi" Tags="|wifi|ethernet|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14112" PostTypeId="2" ParentId="14111" CreationDate="2015-08-12T05:29:20.600" Score="1" Body="&lt;p&gt;I doubt if you will do it in that price range. Buying genuine products (as opposed to clones from eBay) you would be paying something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno: $US 25&lt;/li&gt;&#xA;&lt;li&gt;WiFi shield: $US 40&lt;/li&gt;&#xA;&lt;li&gt;Ethernet shield: $US 45&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Prices from &lt;a href=&quot;http://www.adafruit.com/&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt; - other suppliers would have the same or similar for similar prices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see there is a &lt;a href=&quot;http://www.adafruit.com/products/418&quot; rel=&quot;nofollow&quot;&gt;Arduino Ethernet&lt;/a&gt; which combines the Uno and the Ethernet shield for $US 65.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The whole set up needs to be less than 45USD, desirably much less ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Maybe someone else can suggest a cheaper option, but I think you will be pushing it here.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-12T05:29:20.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14114" PostTypeId="2" ParentId="14111" CreationDate="2015-08-12T07:19:52.007" Score="3" Body="&lt;p&gt;&lt;strong&gt;The Arduino might not be a choice for you.&lt;/strong&gt; The reason why microcontroller boards(like Arduino) become popular is the simplicity and the easiness of control peripherals through GPIO pins, like output PWM signal to control motors, reading sensors through SPI or I2C, reading analog voltage, and etc. Most microcontrollers on Arduino boards itself, however, is not designed for networking features and does not have even enough performance for it. This means that it would cost you much more money on additional networking devices like WIFI shield, Ethernet shield and microprocessor for networking (Arduino Yun).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, &lt;strong&gt;if you are looking for just a pure networking device like what you have in mind, I would highly recommend you Raspberry Pi&lt;/strong&gt;(2 Model B for $39 and 1 Model B+ for $30), which has enough capability of networking itself. All you need is a USB WIFI dongle($9) with the Raspberry Pi, I guess. I am pretty sure you won't have a cheaper option using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the raspberry Pi as a web server, a NAS, a media server along with the features you mentioned.&lt;/p&gt;&#xA;" OwnerUserId="11742" LastEditorUserId="11742" LastEditDate="2015-08-12T07:41:16.713" LastActivityDate="2015-08-12T07:41:16.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14117" PostTypeId="2" ParentId="14111" CreationDate="2015-08-12T12:01:27.020" Score="2" Body="&lt;p&gt;The Raspberry Pi is definitely the easiest way to do this, however it will use more power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do it within your budget by using Arduino clone hardware from places like AliExpress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind the extra effort, it certainly can be done using the Arduino and a wireless and ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A WiFi shield is around $17, an ethernet shield is less than $6 and an Arduino Uno clone is around $3. Make sure you can combine these shields (I haven't checked). There's also a combined Linux, Ethernet + Wifi Yun shield for around $30.&lt;/p&gt;&#xA;" OwnerUserId="11750" LastActivityDate="2015-08-12T12:01:27.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14119" PostTypeId="2" ParentId="14107" CreationDate="2015-08-12T12:11:06.413" Score="2" Body="&lt;p&gt;It can be done. The Arduino is a single tasking environment so you have to make sure your code is non-blocking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BlinkWithoutDelay is a good starting point (thanks @Majenko) but you should also look at the &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;Timer1&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically your programs needs to do all the steps it can right away and whenever it does something that could block, it must do it asynchronously and during a later loop() run check if it's finished and continue with the next task. The alternative (if you know how long your task will take) is to use the timer interrupt with the library mentioned above.&lt;/p&gt;&#xA;" OwnerUserId="11750" LastActivityDate="2015-08-12T12:11:06.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14121" PostTypeId="1" CreationDate="2015-08-12T13:52:53.737" Score="0" ViewCount="336" Body="&lt;p&gt;I have a plan to operate 5MP camera module with the arduino Due. But I wonder if I can use the arduino libraries that include digitalRead, digitalWrite and so on. But some people said that it is a bad idea. Especially I found that people wrote values on registers instead of using the library, when they control ov7670 with Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Contrary to this, ArduCam uses the libraries, even for OV5642!. Here is the link &#xA;&lt;a href=&quot;https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_Mini_OV5642_Video_Streaming/ArduCAM_Mini_OV5642_Video_Streaming.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_Mini_OV5642_Video_Streaming/ArduCAM_Mini_OV5642_Video_Streaming.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So could anyone please let me know, if it is okay to use such library and never to use register directly? With 'register' I mean arduino's register, not camera's. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the system clock and existence of FIFO would affect the answer. But still I don't know how to evaluate their effect analytically. &lt;/p&gt;&#xA;" OwnerUserId="10070" LastActivityDate="2018-06-16T21:19:12.337" Title="Is the Arduino library so slow?" Tags="|library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14122" PostTypeId="1" CreationDate="2015-08-12T13:53:10.593" Score="0" ViewCount="707" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1WL2E.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1WL2E.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//testing the light sensor;&#xA;int sensor=A0; // setting as input is by default;&#xA;int sensorval;&#xA;int pin=13;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(pin,OUTPUT);&#xA;  pinMode(sensor,INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  sensorval=analogRead(sensor);&#xA;  Serial.println(sensorval);&#xA;  if(sensorval&amp;gt;900)&#xA;    digitalWrite(pin,HIGH);&#xA;  else  digitalWrite(pin,LOW);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a photocell, a temperature sensor and a potentiometer with an Arduino Uno and it always gives me &lt;code&gt;1023 0 1023 0 1023 0 1023 ......&lt;/code&gt;. All my wires are connected properly and I tried all this stuff online and they are working correctly.&lt;/p&gt;&#xA;" OwnerUserId="11751" LastEditorUserId="84" LastEditDate="2016-12-10T09:11:21.240" LastActivityDate="2017-04-09T10:49:16.133" Title="Why are my sensors not working (the reaction time is so slow)?" Tags="|arduino-uno|sensors|potentiometer|photoresistor|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14123" PostTypeId="2" ParentId="13691" CreationDate="2015-08-12T14:07:00.383" Score="2" Body="&lt;p&gt;If i understand your question correctly, what you want to do is measure the current consumed from the mains by whatever load is connected to it (Fan, AC, computer etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need is basically a current sensor, have a look at &lt;a href=&quot;https://www.sparkfun.com/products/8883&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8883&lt;/a&gt; and &lt;a href=&quot;https://www.sparkfun.com/products/11005&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11005&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Please understand that you are playing with the mains and unless you take the required precautions, you can get seriously injured&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-12T14:07:00.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14124" PostTypeId="2" ParentId="14122" CreationDate="2015-08-12T14:16:55.390" Score="1" Body="&lt;p&gt;Have you tried with a different trimmer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont seem to be able to find any issue with your code or your schematic, so can you please cross verify that the trimmer is not spoilt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you also check if, when A0 is left floating (nothing connected) it give a random value. &lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-12T14:16:55.390" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="14125" PostTypeId="1" AcceptedAnswerId="14127" CreationDate="2015-08-12T16:28:26.320" Score="6" ViewCount="28459" Body="&lt;p&gt;Is it ok to use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pin, 1) instead of digitalWrite(pin, HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pin, 0) instead of digitalWrite(pin, LOW)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want it that way to make the coding lesser because I save values on EEPROM with 1's and 0's. So if I want to use EEPROM value, I can call it this way&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pin, EEPROM.read(1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7788" LastActivityDate="2015-08-12T22:41:18.683" Title="Arduino digitalWrite 1 or 0 instead of HIGH or LOW" Tags="|eeprom|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14126" PostTypeId="2" ParentId="14121" CreationDate="2015-08-12T17:16:31.183" Score="1" Body="&lt;p&gt;Unless you have a really large number of read/write operations and very tight time constraints, I doubt you are going to have any significant advantage in terms of speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accessing the bits in a port together, rather than individually is certainly more efficient, both in terms of time and space, but it might cost in readability, depending on how comfortable you are with leaving the Arduino libraries behind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have also a look at &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=86060.0&quot; rel=&quot;nofollow&quot;&gt;this thread&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the maximum gain happens only when all the pins you have to read or write belong to the same register.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-12T17:16:31.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14127" PostTypeId="2" ParentId="14125" CreationDate="2015-08-12T17:59:11.800" Score="8" Body="&lt;p&gt;Yes, that is fine.  LOW is 0 and HIGH is 1.  &lt;code&gt;digitalWrite()&lt;/code&gt; sets the output to off if it receives a 0 and on if it receives anything of 1 or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that these are all equivalent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pin, HIGH);&#xA;digitalWrite(pin, 1);&#xA;digitalWrite(pin, 69);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's especially useful when you are examining a variable for, say, a certain bit being set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pin, bytevar &amp;amp; 0x80);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will set the pin to high on any value from 128 to 255 in the byte variable, and low for anything below 128.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-12T17:59:11.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14128" PostTypeId="1" CreationDate="2015-08-12T18:06:32.630" Score="1" ViewCount="1518" Body="&lt;p&gt;I'm using a 12v fan and 12v LED modules in my project, so I need about 400mA by their combined specs. I have a 12.6v dc regulated power source that can give ~700mA I wish to use, and since it has a rather small form factor I would also like to power my Arduino Diecimila with it. I'm using PWM from pins 10 and 6 to go through N-channel MOSFETs in order to control both the LEDs and the fan. Anyway, in the Arduino Diecimila board page it says the recommended voltages are between 7-12v, and beyond that it can handle 6-20v, but it might cause the voltage regulator to heat too much, which might damage the board. So, my question is that: will 12.6v really damage my board, or is it within some margin of error? The actual voltage I got when I checked my power supply was 12.55V. Can I maybe just dial it down a bit somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UriSh.&lt;/p&gt;&#xA;" OwnerUserId="11758" LastActivityDate="2015-08-12T18:15:38.300" Title="Will 12.6v really damage my arduino?" Tags="|power|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14129" PostTypeId="2" ParentId="14128" CreationDate="2015-08-12T18:15:38.300" Score="3" Body="&lt;p&gt;As you have already noticed, it may cause the 5V regulator to get hotter than would be normally considered reasonable.  However, how hot depends entirely on how much current your board is drawing (not including the 12V devices)- the more current you draw the hotter it will get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even at 12V it can get uncomfortably hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For running off voltages greater than about 9V I usually recommend using an external 5V switching regulator.  These can be easily and cheaply obtained under the name &quot;UBEC&quot; (Universal Battery Elimination Circuit) and are used extensively in the model aircraft arena.  They don't get hot, can handle large currents, and don't waste power like the on-board linear regulator does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you'd connect that to your 12.6V supply, then the 5V output of the UBEC (make sure you get a 5V one) would go straight to the 5V pin of the Arduino, and you wouldn't connect the barrel jack or Vin to anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also pick up cheap switching regulators on eBay - some are adjustable, so you'd want to make sure you adjust it to 5V first before connecting the Arduino, or if you can adjust it to around 7V then you could power the Arduino through the barrel jack (or Vin) with it and avoid too much heat from the on-board linear regulator.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-12T18:15:38.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14130" PostTypeId="1" AcceptedAnswerId="14131" CreationDate="2015-08-12T18:35:50.853" Score="0" ViewCount="2690" Body="&lt;p&gt;I have recently started working on esp8266 wifi module and arduino uno.&#xA;I am a little confused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created a small Web page with esp8266 AT commands.&#xA;Now I want use it for receiving data such as changes on the Arduino inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen many similar implementations using jQuery for that purpose,&#xA;but I don't know where to place that jQuery file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, is it possible to use NODEMCU firmware and still toggle arduino pins and transmit data to esp8266?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use Arduino for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;reading voltage levels&lt;/li&gt;&#xA;&lt;li&gt;publish the values read to the Web page&lt;/li&gt;&#xA;&lt;li&gt;toggle a relay when a button on the Web page is pressed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please kindly help me out or point me in the right direction to search&lt;/p&gt;&#xA;" OwnerUserId="11759" LastEditorUserId="7856" LastEditDate="2015-08-13T15:51:08.383" LastActivityDate="2015-08-13T15:51:08.383" Title="NODEMCU vs AT for esp8266" Tags="|arduino-uno|wifi|web-server|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14131" PostTypeId="2" ParentId="14130" CreationDate="2015-08-12T19:06:54.537" Score="4" Body="&lt;p&gt;This is quite a huge topic to cover in one answer, but I will do my best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The NodeMCU can be used in three distinctly different ways.  First is the &lt;em&gt;AT&lt;/em&gt; mode, where you have installed the &lt;em&gt;AT&lt;/em&gt; firmware.  In this mode the NodeMCU is purely a slave device to the Arduino.  Once you have got the Arduino to configure the NodeMCU in the right way to receive data on a socket it will send that data back to the Arduino verbatim through the serial port with special tags added (indicating what the data is, and which socket it arrived on, etc).  It is then up to you to receive that data, interpret it in whatever way you desire (as a HTTP GET request most likely) and craft the correct response (if any) and send it to the NodeMCU to send back (again using the &lt;em&gt;AT&lt;/em&gt; commands).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you send through the socket is entirely up to you.  By the sounds of things you will be making a simple GET request from a web browser to perform an operation, and maybe respond with some data to display in the web page.  That can be easy, or it can be hard - it's as hard as you want to make it.  The simplest way is to rely on an external web server to serve the main content and structure of the page, then use jQuery or Prototype to make an AJAX call to your NodeMCU and receive back any data there may be.  In this case everything will be on your external web server except the single (or few) URL(s) that perform operations and return data.  That includes the jQuery (which is just Javascript, it's loaded from your web server into the browser and executed), any code for buttons, images, HTML, everything (on the web server, that is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other two ways the NodeMCU can operate are both very different to that.  They differ mainly in the language that is used with them.  You can use the NodeMCU with its own LUA language to get it to do almost anything you want.  That includes receiving the HTTP GET request and serving the data for it, all without the help of the Arduino.  In fact, doing that, there is little need for the Arduino any more - the NodeMCU has an analog input and multiple digital IO lines - it also has SPI available for interfacing with external ADC chips if you want more than one analog input.  So you can have everything internal to the NodeMCU without needing the Arduino at all.  If you do want to keep the Arduino then you can interface to it through the serial port (as you would in &lt;em&gt;AT&lt;/em&gt; mode) but using your own custom protocol in whatever way you see fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third way is to program the NodeMCU as if it were itself an Arduino.  There is an ESP8266 core for the Arduino IDE (and for &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow&quot;&gt;UECIDE Beta&lt;/a&gt; as well) which allows you to program the NodeMCU in the same language and with a similar API, as the Arduino.  This even more removes the need for the Arduino.  You can get the Arduino core from Github here: &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, the Xtensa core in the ESP8266 is considerably more powerful than your typical Arduino, being 32-bit, having its own DSP, and with much more RAM and Flash memory.  It kind of makes the Arduino redundant.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-12T19:06:54.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14132" PostTypeId="2" ParentId="14059" CreationDate="2015-08-12T19:13:38.687" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KoDhN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KoDhN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;Fixed the issue with a dedicated 3.3V power supply.  I2C scanner is running for 30 minutes with no issues so far. &lt;/p&gt;&#xA;" OwnerUserId="11701" LastEditorUserId="11701" LastEditDate="2015-08-12T20:21:59.733" LastActivityDate="2015-08-12T20:21:59.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14133" PostTypeId="1" AcceptedAnswerId="14143" CreationDate="2015-08-12T19:46:29.923" Score="0" ViewCount="906" Body="&lt;p&gt;Following configuration:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino UNO R3&lt;/li&gt;&#xA;&lt;li&gt;Real Time Clock DS1307RTC&lt;/li&gt;&#xA;&lt;li&gt;LCD1602 Shield with buttons&lt;/li&gt;&#xA;&lt;li&gt;Photo resistor&lt;/li&gt;&#xA;&lt;li&gt;DHT11 (Temp &amp;amp; Humidity Sensor)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I need the function delay(1000) to display the seconds properly from the RTC to the LCD.&#xA;But, that way I always have to keep the buttons pressed for up to 1 second until they react.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I workaround or solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Idea 1: Multitasking would come in handy here :-) pseudocode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;task 1: listen for LCD buttons&#xA;task 2: display seconds with a delay of 1000ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But there isn’t a way Arduino could multitask, isn’t it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Idea 2: As far as I saw in the header files for the RTC, the smallest readable unit is seconds. Otherwise I could have used something like a millisecond reader in a while condition to listen for the buttons; pseudocode:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;while (RTC-millisecond &amp;lt; 1000ms) {&#xA;    // listen for buttons&#xA;    // so a second passes, which gives the RTC time to display the seconds values&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;updated code, thanks to @NickGammon and Gerben:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;DS1307RTC.h&amp;gt;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;//                RS  E  D4 D5 D6 D7 (maybe wrong order)&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;// pins on which the sensor is connected&#xA;#define DHTPIN A1 &#xA;#define PHOTOPIN A2&#xA;&#xA;// initialize DHT sensor&#xA;#define DHTTYPE DHT11&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;// define some values used by the panel and buttons&#xA;int lcd_key     = 0;&#xA;int adc_key_in  = 0;&#xA;//#define btnRIGHT  0&#xA;//#define btnUP     1&#xA;//#define btnDOWN   2&#xA;//#define btnLEFT   3&#xA;//#define btnSELECT 4&#xA;//#define btnNONE   5&#xA;&#xA;// FSM&#xA;unsigned long previousMillis1 = 0; &#xA;unsigned long previousMillis2 = 0; &#xA;const long interval = 3000; &#xA;&#xA;// prototypes&#xA;void print2digits(int number);&#xA;int read_LCD_buttons();&#xA;&#xA;&#xA;void setup() {&#xA;  // open a serial connection to display values on PC&#xA;  Serial.begin(9600);&#xA;&#xA;  // set up the number of columns and rows on the LCD&#xA;  lcd.begin(16, 2);&#xA;&#xA;  // start DHT sensor&#xA;  dht.begin();&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // set variable from struct tmElements_t&#xA;  tmElements_t tm;&#xA;&#xA;&#xA;/********* Reading from sensors *********/  &#xA;  /*** DHT sensor ***/&#xA;  // Reading temp or RH takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  float humid = dht.readHumidity();&#xA;  float tempC = dht.readTemperature();  &#xA;  // Check if any reads failed and exit early (to try again).&#xA;  if (isnan(humid) || isnan(tempC)) {&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;DHT reading failed!&quot;);&#xA;    Serial.println(&quot;DHT reading failed!&quot;);&#xA;    return;&#xA;  }&#xA;  // Compute heat index in Celsius (isFahreheit = false)&#xA;  float hiC = dht.computeHeatIndex(tempC, humid, false);  &#xA;&#xA;  /*** Photo resistor ***/&#xA;  int lightReading = analogRead(PHOTOPIN);&#xA;&#xA;&#xA;/********* Print to PC over serial connection *********/ &#xA;  // ...&#xA;&#xA;&#xA;/********* Print values to LCD *********/ &#xA;  /* --- first line on LCD --- */&#xA;  /*** RTC ***/  &#xA;  // set the cursor to LCD column 4, line 0 to center the clock&#xA;  lcd.setCursor(4, 0);&#xA;&#xA;  // starts RTC reading and checks if it's working&#xA;  if (RTC.read(tm)) {&#xA;    static byte oldSecond = 60; // 60, because there is no 60'th second in a clock&#xA;    // display only if time changes&#xA;    if (tm.Second != oldSecond) {&#xA;      oldSecond = tm.Second;&#xA;      print2digits(tm.Hour);&#xA;      lcd.print(':');&#xA;      print2digits(tm.Minute);&#xA;      lcd.print(':');&#xA;      print2digits(tm.Second);&#xA;    }&#xA;  }&#xA;  else {&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    if (RTC.chipPresent()) {&#xA;      lcd.print(&quot;Please run SetTime function&quot;);&#xA;    } else {&#xA;      lcd.print(&quot;DS1307 read error!&quot;);&#xA;    }&#xA;    delay(9000);&#xA;  }&#xA;&#xA;&#xA;  /* --- second line on LCD according to button --- */&#xA;  lcd_key = ((lcd_key + read_LCD_buttons()) %3);  // call button function, modulo 3 to cycle through&#xA;    /** // Test buttons:&#xA;    lcd.setCursor(1, 1);&#xA;    lcd.print(&quot;lcd var:&quot;);&#xA;    lcd.print(lcd_key); */&#xA;&#xA;  unsigned long currentMillis = millis(); // FSM used for displaying DHT and photo values without flikering&#xA;&#xA;  switch (lcd_key) {&#xA;    case 0:&#xA;      /*** Weekday and Date ***/&#xA;      // display only if day changed&#xA;      static byte oldDay = 99;&#xA;      if (tm.Day != oldDay) {&#xA;        oldDay = tm.Day; &#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;                &quot;); // 16 spaces to clear second line before printing&#xA;        lcd.setCursor(0, 1);&#xA;        //lcd.print(dayShortStr((weekday() + 1) % 7 )); // (day+1)%7 calculation for Swiss layout&#xA;        lcd.print(tm.Wday); // TEST&#xA;        lcd.print(weekday()); // TEST&#xA;        lcd.print(&quot;, &quot;);&#xA;        print2digits(tm.Day);&#xA;        lcd.print('.');&#xA;        print2digits(tm.Month);&#xA;        lcd.print('.');&#xA;        lcd.print(tmYearToCalendar(tm.Year));&#xA;      }&#xA;      break;&#xA;&#xA;    case 1:&#xA;      /*** DHT Sensor ***/&#xA;      if (currentMillis - previousMillis1 &amp;gt;= interval) {&#xA;        previousMillis1 = currentMillis;   &#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;                &quot;); // 16 spaces to clear second line before printing&#xA;        lcd.setCursor(1, 1);&#xA;        lcd.print(hiC);&#xA;        lcd.print(&quot;*C &quot;);  &#xA;        lcd.setCursor(10, 1);&#xA;        lcd.print(humid); &#xA;        lcd.setCursor(12, 1); &#xA;        lcd.print(&quot;%RH &quot;);&#xA;      }&#xA;      break;&#xA;&#xA;    case 2:&#xA;      /*** Photo resistor ***/&#xA;      if (currentMillis - previousMillis2 &amp;gt;= interval) {&#xA;        previousMillis2 = currentMillis;    &#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;                &quot;); // 16 spaces to clear second line before printing&#xA;        lcd.setCursor(0, 1);&#xA;        lcd.print(&quot;Light &quot;);  &#xA;        lcd.setCursor(6, 1);&#xA;        lcd.print(lightReading);&#xA;      }&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;&#xA;// used to print 2 digits in the time values&#xA;void print2digits(int number) {&#xA;  if (number &amp;gt;= 0 &amp;amp;&amp;amp; number &amp;lt; 10) {&#xA;    lcd.print('0'); &#xA;  }&#xA;  lcd.print(number);&#xA;}&#xA;&#xA;// read the buttons&#xA;int read_LCD_buttons() {&#xA;  adc_key_in = analogRead(0); &#xA;  //if (adc_key_in &amp;gt; 1000) return btnNONE; // 1st option since it will be the most likely result (speed reasons)&#xA;  //if (adc_key_in &amp;lt; 50)   return btnRIGHT;  &#xA;  //if (adc_key_in &amp;lt; 195)  return btnUP; // replaced by below one&#xA;  if (adc_key_in &amp;lt; 195)  return 1; // my button up !&#xA;  //if (adc_key_in &amp;lt; 380)  return btnDOWN; &#xA;  //if (adc_key_in &amp;lt; 555)  return btnLEFT; &#xA;  //if (adc_key_in &amp;lt; 790)  return btnSELECT;   &#xA;  //return btnNONE;  // when all others fail, return this...&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11760" LastEditorUserId="11760" LastEditDate="2015-08-14T15:14:23.783" LastActivityDate="2015-08-14T15:14:23.783" Title="Delay workaround needed for RTC and LCD-shield buttons" Tags="|lcd|button|rtc|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14134" PostTypeId="2" ParentId="14125" CreationDate="2015-08-12T20:01:16.277" Score="2" Body="&lt;p&gt;From the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L40-L41&quot; rel=&quot;nofollow&quot;&gt;arduino source code&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define HIGH 0x1&#xA;#define LOW  0x0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;HIGH&lt;/code&gt; is &lt;strong&gt;exactly&lt;/strong&gt; the same as &lt;code&gt;1&lt;/code&gt;. And &lt;code&gt;LOW&lt;/code&gt; exactly the same as &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-12T20:01:16.277" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14135" PostTypeId="2" ParentId="14133" CreationDate="2015-08-12T20:01:16.883" Score="1" Body="&lt;p&gt;You need to learn a different way of programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things you need to understand:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Non-blocking code.  Read and understand the BlinkWithoutDelay example sketch (in the Arduino IDE's File -&gt; Examples menu)&lt;/li&gt;&#xA;&lt;li&gt;Finite State Machines.  Stop thinking purely linear, and start thinking about the different states your program can be in at any one time.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Once you have those cracked you'll be an Elite Arduino Programmer (EAP™).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-12T20:01:16.883" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14136" PostTypeId="2" ParentId="14125" CreationDate="2015-08-12T22:41:18.683" Score="0" Body="&lt;p&gt;When you look at the source code of Arduino, HIGH is defined as 1 and LOW is defined as 0 using #define.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may heard about &lt;strong&gt;Preprocessor, Compiler, and Linker&lt;/strong&gt;. When you build the project, preprocessor do its job before the code is compiled. What the preprocessor does is basically converting defined words into corresponding value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example when you write a syntax like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(1, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you build your project, the preprocessor converts the above like into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(1, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the code is compiled. Therefore, there is no difference between HIGH and 1.&#xA;So, if the result of &lt;code&gt;EEPROM.read(1)&lt;/code&gt; is either 0 or 1, there should be no problem.&lt;/p&gt;&#xA;" OwnerUserId="11742" LastActivityDate="2015-08-12T22:41:18.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14137" PostTypeId="1" AcceptedAnswerId="14144" CreationDate="2015-08-12T23:04:36.800" Score="2" ViewCount="804" Body="&lt;p&gt;I have two arduinos (uno) and I would like to send the results of a key press on a 5X4 matrix pad to the other arduino. The matrix keypad works great. I can identify which key was pressed with a switch function. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (keypad())  &#xA;//switch used to specify which button&#xA;     {&#xA;      case 0:&#xA;        Serial.print(&quot;Key A Pressed&quot;);&#xA;        Serial.print(keypad());&#xA;        messageToSend = 0;&#xA;      break;  &#xA;        case 1:&#xA;        Serial.print(&quot;Key B Pressed&quot;);&#xA;        Serial.print(keypad());&#xA;        messageToSend = 1;&#xA;      break;&#xA;        case 2:&#xA;        Serial.print(&quot;Key C Pressed&quot;);&#xA;        Serial.print(keypad());&#xA;        messageToSend = 2;&#xA;      break;&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My RF units are both nrf24l01. I have tried working with the sample code and I think the issue is I don't understand how the unit works well enough.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the nature of the data sent between units? I want to send&#xA;integers, possibly even text. Is that possible? Do I need to convert&#xA;to binary or something?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;My understanding of &quot;ping&quot; and &quot;pong&quot; is that ping sends a message&#xA;then pong sends that same message back to ping... is this correct?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are RF units very different? Is this one particularly difficult?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I just want to send with one receive with the other shouldn't&#xA;this simplify the code?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What are pipes? How many can I open? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I have 3 or more of these what changes will I need to make to the&#xA;code?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2017-07-05T15:37:35.907" Title="Need help understanding how RF communication works with 2 arduinos" Tags="|nrf24l01+|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14138" PostTypeId="1" AcceptedAnswerId="14141" CreationDate="2015-08-13T02:09:14.517" Score="0" ViewCount="707" Body="&lt;p&gt;I have been using a library to control a LED Strip with buttons. My current code does not execute properly. It skips the if statement and just runs the code in a loop with no regard to the button and I'm uncertain why. I'm using an Arduino Uno with an LPD8806.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;LPD8806.h&quot;&#xA;#include &quot;SPI.h&quot; // Comment out this line if using Trinket or Gemma&#xA;#ifdef __AVR_ATtiny85__&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#endif&#xA;&#xA;int nLEDs = 160;&#xA;&#xA;// Chose 2 pins for output; can be any valid output pins:&#xA;int dataPin  = 2;&#xA;int clockPin = 3;&#xA;&#xA;// First parameter is the number of LEDs in the strand.  The LED strips&#xA;// are 32 LEDs per meter but you can extend or cut the strip.  Next two&#xA;// parameters are SPI data and clock pins:&#xA;LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin);&#xA;&#xA;&#xA;int inPin = 4;&#xA;boolean lastState = LOW;//storage for last button state&#xA;&#xA;void setup(){&#xA;   pinMode(inPin, INPUT);//this time we will set the pin as INPUT&#xA;   Serial.begin(9600);//initialize Serial connection&#xA;   #if defined(__AVR_ATtiny85__) &amp;amp;&amp;amp; (F_CPU == 16000000L)&#xA;   clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket&#xA;   #endif&#xA;&#xA;   strip.begin();&#xA;   // Update the strip, to start they are all 'off'&#xA;   strip.show();&#xA;&#xA; }&#xA;&#xA;void loop(){&#xA;&#xA;   if (digitalRead(inPin) == HIGH &amp;amp;&amp;amp; lastState == LOW){//if button has just       &#xA;   been pressed&#xA;   // Start up the LED strip&#xA;        theaterChase(strip.Color(127, 127, 127), 50); // White&#xA;        delay(100);&#xA;    } else if(digitalRead(inPin) == LOW &amp;amp;&amp;amp; lastState == HIGH){&#xA;        digitalWrite(dataPin, LOW);&#xA;        digitalWrite(clockPin, LOW);&#xA;    }&#xA;    lastState = digitalRead(inPin);&#xA;    }&#xA;&#xA;    //Theatre-style crawling lights.&#xA;    void theaterChase(uint32_t c, uint8_t wait) {&#xA;         for (int j=0; j&amp;lt;10; j++) {  //do 10 cycles of chasing&#xA;              for (int q=0; q &amp;lt; 3; q++) {&#xA;                   for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;                      strip.setPixelColor(i+q, c);    //turn every third pixel on&#xA;      }&#xA;      strip.show();&#xA;&#xA;      delay(wait);&#xA;&#xA;      for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;      strip.setPixelColor(i+q, 0);        //turn every third pixel off&#xA;      }&#xA;    }&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11765" LastActivityDate="2015-08-13T05:04:29.767" Title="Toggle Button For LED Strip not executing properly" Tags="|arduino-uno|led|c++|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14139" PostTypeId="1" AcceptedAnswerId="14148" CreationDate="2015-08-13T03:03:30.507" Score="0" ViewCount="272" Body="&lt;p&gt;My code is designed to play a tone when ever pin 3 is high on my Arduino. When I am examine the pins voltage with a multimeter it is always reading below 1 volt. When I examined the voltage off of a osiliscope it is reading the voltage pretty steady at 0.2 to 0.3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My multimeter reads at 0.26&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VDZrq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VDZrq.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My code is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;int input = digitalRead(3);&#xA;Serial.println(input);&#xA;if(input == 1){&#xA;  tone(A5,4000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My board looks like:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WxcKw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WxcKw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;strong&gt;The bottom of the board looks like:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VmlpH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VmlpH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8167" LastActivityDate="2015-08-13T08:23:33.317" Title="Arduino LED lighting up when signal is reading low on multimeter" Tags="|sketch|arduino-pro-mini|signal-processing|prototype|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14141" PostTypeId="2" ParentId="14138" CreationDate="2015-08-13T05:04:29.767" Score="1" Body="&#xA;&#xA;&lt;p&gt;If you have just connected a switch to the Arduino pin, like the image below, it will just return &quot;random&quot; undefined results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dbixU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dbixU.png&quot; alt=&quot;Floating input on switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are various ways of avoiding this, including using a pull-down resistor to ensure that, if the switch is open, it will read LOW. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eYepo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eYepo.png&quot; alt=&quot;Pull-down resistor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other possible techniques as discussed on &lt;a href=&quot;http://gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is to change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   pinMode(inPin, INPUT);//this time we will set the pin as INPUT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   pinMode(inPin, INPUT_PULLUP);//this time we will set the pin as INPUT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then wire the switch to &lt;strong&gt;ground&lt;/strong&gt;, not +5 V. That way the pull-up resistor pulls the switch HIGH, and when you close the switch it is LOW.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-13T05:04:29.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14142" PostTypeId="2" ParentId="5178" CreationDate="2015-08-13T05:22:51.097" Score="3" Body="&lt;p&gt;It is highly likely that the sketch you loaded is causing this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, when I press the restart button on the Arduino, the PC will detect it as an Arduino Leonardo bootloader(com 7) but after few seconds it disappears.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a few seconds after reset the bootloader will configure the board as a USB serial device, awaiting upload of a new sketch. Once that times out it runs the existing code. If the existing code does not configure the USB port (eg. by doing &lt;code&gt;Serial.begin&lt;/code&gt;) then it will cease to enumerate as a USB device. This is perfectly normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;fix&quot; is to upload a sketch that uses the USB interface. For example, open a serial port, open the keyboard (&lt;code&gt;Keyboard.begin()&lt;/code&gt;) or similar.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-13T05:22:51.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14143" PostTypeId="2" ParentId="14133" CreationDate="2015-08-13T05:40:42.153" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // clean up screen before printing a new reply&#xA;  lcd.clear();&#xA;&#xA;  /* --- first line on LCD --- */&#xA;  /*** RTC ***/  &#xA;  // set the cursor to LCD column 4, line 0 to center the clock&#xA;  lcd.setCursor(4, 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Straight away, that will cause flicker, right? For a few milliseconds the screen will go blank, and then get gradually redrawn. Why not omit the clear? You could put it in if you are changing display types (eg. from date to temperature) but you don't need to clear the screen every time. So:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't call &lt;code&gt;delay()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't clear the screen unless changing to displaying a different type of thing&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Only update the display at all if the new number (or time, or temperature, etc.) is &lt;strong&gt;different&lt;/strong&gt; from what you just displayed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Just do the &lt;code&gt;setCursor()&lt;/code&gt; to position the cursor and &lt;strong&gt;overwrite&lt;/strong&gt; the information there previously. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Preferably follow by a space or two in case a large number is replaced by a smaller one.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Side-benefit: Since you have removed the delay, your project will now be much more responsive to key presses. Win win!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;State machines&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;How to do multiple things at once ... like cook bacon and eggs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am not quite sure how to do it &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; if (RTC.read(tm)) &#xA;  {&#xA;  static byte oldSecond = 99;&#xA;  // display if time changes&#xA;  if (tm.Second != oldSecond)  &#xA;    {&#xA;    oldSecond = tm.Second;&#xA;    print2digits(tm.Hour);&#xA;    lcd.print(':');&#xA;    print2digits(tm.Minute);&#xA;    lcd.print(':');&#xA;    print2digits(tm.Second);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly further down where you display the date / sensor.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-13T20:48:09.483" LastActivityDate="2015-08-13T20:48:09.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14144" PostTypeId="2" ParentId="14137" CreationDate="2015-08-13T05:49:30.823" Score="3" Body="&lt;p&gt;Many questions so broad answers, but hopefully informative for your research&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the nature of the data sent between units? I want to send integers, possibly even text. Is that possible? Do I need to convert to binary or something?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It depends broadly on what you use. If you use an ethernet peripheral then the communications will be entire ethernet packets with whatever protocol stack you have above it in payload. For simple RF communication modules it may be as simple as a serial stream delivered 8 bits at a time. The simplest rf (buzzer-style) would simply interrupt (or drive a pin high) when the transmitter is sending a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Your case the transmitter uses an addressed protocol with a payload packet of between 1 and 25 Bytes of data. This means that you will need code to read and store the necessary payload, maintain configuration data and keep track of addresses of the other systems to message. You also need to poll (or handle interrupts from) the rf module to make sure there aren't messages from the transmit node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How you convert the data is up to you, a string can be represented by a sequence of bytes and can be send and read as a string on the receivers end. Your rf module will deliver you data in 1-25 byte chunks, what you send in that chunk and how to encode it is entirely up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the low level,the way this module is configured, the MCU sends data into the rf ic using a serial protocol, the module incorporates a buffer to allow the MCU (slow - 8 bit) to send the data and not have to keep up with the 1Mbps throughput of the rf. On a physical level the signals of the chip look thus:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2yKFf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2yKFf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding of &quot;ping&quot; and &quot;pong&quot; is that ping sends a message then pong sends that same message back to ping... is this correct?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Ping Pong is a game and not a well defined technical term. For precision you can define ping-pong as an &lt;code&gt;echo&lt;/code&gt; where the transmitter effectively acknowledges the message by re-transmitting it back to you.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are RF units very different? Is this one particularly difficult?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;RF units can be very different depending on what high level protocol they offer. This unit is somewhere half way between full blown wifi and simple and modulated RF communications. It gives you addressing and error correction as well as a robust communication scheme&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This particular unit is made to be relatively &quot;modern&quot;, it uses &lt;a href=&quot;https://en.wikipedia.org/wiki/Gaussian_frequency-shift_keying&quot; rel=&quot;nofollow noreferrer&quot;&gt;GFSK&lt;/a&gt; - a frequency modulation scheme -to transmit and receive data to uniquely addressable nodes on a number of channels. At 2.4 GHz it is high throughput, &lt;a href=&quot;https://en.wikipedia.org/wiki/ISM_band&quot; rel=&quot;nofollow noreferrer&quot;&gt;legal&lt;/a&gt;.  It is not the simplest toy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of simplicity, this module has a lot of examples and documentation, given that it has an arduino library it has a high likelihood of working and succeeding, but you will need to use more advanced microcontroller features to fully utilize the device (e.g. interrupts, DMA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other RF options there are lots of things to consider. Going up to wifi requires you to maintain a much more complex stack, meaning more processing power and code, if you want to offer TCP/IP services (say webserver) it is even more code but can be done on an 8 bit arduino. Going down to simpler protocol may win you less power and simpler code but a headache to expand.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I just want to send with one receive with the other shouldn't this simplify the code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You will still need to implement both a receiving and a transmitting application so the work is still all there, it will simplify the higher level logic into separate application which is easier.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;What are pipes? How many can I open?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I see nothing about pipes from a cursory glance at the docs, perhaps you can illuminate more on what you are confused about?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general pipes are a &quot;hole&quot; where an application (in the broadest sense) can stream data and it will be consumed by whoever is on the other end, a black hole of a serial data stream. You can implement a pipe as a high level software construct that will buffer and consume data from peripherals and wait to send it out the RF transmitter, it may also be implemented on a hardware level with discrete buffers and additional logic around the rf transmitter etc. As a conceptual element you can probably use a &quot;pipe&quot; concept for communication between the different devices in your code (e.g. move byte to pipe 1 for device 1, move byte to pipe 2 for device 2, let the &quot;driver&quot; handle order), this is a design paradigm that makes software development easier.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;6&quot;&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I have 3 or more of these what changes will I need to make to the code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The rf module is fully capable of addressing up to 65,536 unique hosts, so the device is fully ready to talk to 3 of your hosts, however the software logic needs to track the addresses and other comms data about each host as well as process the data for them (if its different) in enough time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are expecting this in advance, good design decisions early on (e.g. small API or library) will make this much easier on yourself to add features in the future. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Final Thought&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a simple echo, this may be a bit overkill for your system, however it is relatively powerful and may make it easier for you to program since you can work with &quot;real-world&quot; data units and send multiple byte packets easily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would &lt;strong&gt;highly recommend&lt;/strong&gt; you read and understand the &lt;a href=&quot;https://www.sparkfun.com/datasheets/IC/nRF2401A.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; for the RF chip, be thankful that the nice library takes care of the messy details for you, but understanding how it works will certainly help you understand how to use it best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An 8 bit Atmega may not be powerful enough to process and transmit 3 separate streams together (if they are identical its less difficult) if you require a constant high rate transmission or if you do a significant amount of processing on the arduino before sending you will feel the limitations of the chip and a 32 bit board may be worth looking at.&lt;/p&gt;&#xA;" OwnerUserId="11257" LastEditorUserId="11257" LastEditDate="2015-08-13T06:21:01.600" LastActivityDate="2015-08-13T06:21:01.600" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14145" PostTypeId="1" CreationDate="2015-08-13T07:26:26.797" Score="3" ViewCount="876" Body="&lt;p&gt;I want to read the SMS using Arduino and GSM module, I want to perform conditional programming based on the received SMS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I found really interesting is SMS format is different if I send message from different phones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of my code is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 1:(From a smartphone)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mobile Number is: +91954xxxxxxx &#xA;Message Text: 5+22&quot; Hello Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case 2:(From a normal phone)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mobile Number is: +91984yyyyyyy &#xA;Message Text: Hello Arduino&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Does it really depend on the sender's mobile phone? If yes, how to move further to make my code independent on the sender mobile.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My code is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//===final code&#xA;&#xA;char RcvdMsg[200] = &quot;&quot;;&#xA;int RcvdCheck = 0;&#xA;int RcvdConf = 0;&#xA;int index = 0;&#xA;int RcvdEnd = 0;&#xA;char MsgMob[15];&#xA;char MsgTxt[50];&#xA;int MsgLength = 0;&#xA;&#xA;void Config() // This function is configuring our SIM900 module i.e. sending the initial AT commands&#xA;{&#xA;   delay(1000);&#xA;   Serial.print(&quot;ATE0\r&quot;);&#xA;   Response();&#xA;   Serial.print(&quot;AT\r&quot;);&#xA;   Response();&#xA;   Serial.print(&quot;AT+CMGF=1\r&quot;);&#xA;   Response();&#xA;   Serial.print(&quot;AT+CNMI=1,2,0,0,0\r&quot;);&#xA;   Response();&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   Config();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   RecSMS();&#xA;}&#xA;&#xA;&#xA;void Response() // Get the Response of each AT Command&#xA;{&#xA;   int count = 0;&#xA;   Serial.println();&#xA;   while(1)&#xA;   {&#xA;      if(Serial.available())&#xA;      {&#xA;         char data =Serial.read();&#xA;         if(data == 'K'){Serial.println(&quot;OK&quot;);break;}&#xA;         if(data == 'R'){Serial.println(&quot;GSM Not Working&quot;);break;}&#xA;      }&#xA;      count++;&#xA;      delay(10);&#xA;      if(count == 1000){Serial.println(&quot;GSM not Found&quot;);break;}&#xA;&#xA;   }&#xA;}&#xA;&#xA;void RecSMS() // Receiving the SMS and extracting the Sender Mobile number &amp;amp; Message Text&#xA;{&#xA;   if(Serial.available())&#xA;   {&#xA;      char data = Serial.read();&#xA;      if(data == '+'){RcvdCheck = 1;}&#xA;      if((data == 'C') &amp;amp;&amp;amp; (RcvdCheck == 1)){RcvdCheck = 2;}&#xA;      if((data == 'M') &amp;amp;&amp;amp; (RcvdCheck == 2)){RcvdCheck = 3;}&#xA;      if((data == 'T') &amp;amp;&amp;amp; (RcvdCheck == 3)){RcvdCheck = 4;}&#xA;      if(RcvdCheck == 4){RcvdConf = 1; RcvdCheck = 0;}&#xA;&#xA;      if(RcvdConf == 1)&#xA;      {&#xA;         if(data == '\n'){RcvdEnd++;}&#xA;         if(RcvdEnd == 3){RcvdEnd = 0;}&#xA;         RcvdMsg[index] = data;&#xA;&#xA;         index++;&#xA;         if(RcvdEnd == 2){RcvdConf = 0;MsgLength = index-2;index = 0;}&#xA;         if(RcvdConf == 0)&#xA;         {&#xA;            Serial.print(&quot;Mobile Number is: &quot;);&#xA;            for(int x = 4;x &amp;lt; 17;x++)&#xA;            {&#xA;               MsgMob[x-4] = RcvdMsg[x];&#xA;               Serial.print(MsgMob[x-4]);&#xA;            }&#xA;            Serial.println();&#xA;            Serial.print(&quot;Message Text: &quot;);&#xA;            for(int x = 46; x &amp;lt; MsgLength; x++)&#xA;            {&#xA;               MsgTxt[x-46] = RcvdMsg[x];&#xA;               Serial.print(MsgTxt[x-46]);&#xA;            }&#xA;&#xA;            Serial.println();&#xA;&#xA;            //****Resetting all the variables*****//&#xA;&#xA;            //RcvdMsg[200]={0};&#xA;            RcvdCheck = 0;&#xA;            RcvdConf = 0;&#xA;            index = 0;&#xA;            RcvdEnd = 0;&#xA;            MsgMob[15];&#xA;            MsgTxt[50];&#xA;            MsgLength = 0;&#xA;&#xA;            Serial.flush();&#xA;&#xA;&#xA;         }&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11518" LastEditorUserId="313" LastEditDate="2015-08-30T21:46:51.243" LastActivityDate="2015-10-29T22:57:13.057" Title="Does SMS format depend on the sender's mobile?" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14146" PostTypeId="2" ParentId="1569" CreationDate="2015-08-13T07:41:59.177" Score="23" Body="&lt;p&gt;A picture is worth 1000 words, so they say, (1024 words if you work with computers) so I'll post some pictures ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set up my Uno to send &quot;Fab&quot; at 9600 baud and captured the results on a logic analyzer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/djsrz.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/djsrz.png&quot; alt=&quot;Serial comms - 3 letters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The parts shaded in red are the &quot;idle&quot; period between bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the above graphic note that the Tx (transmit) data line is normally high (1) until it drops low to indicate the start of a character (byte). This is the &lt;em&gt;start bit&lt;/em&gt;. Then the 8 data bits (indicated by white dots) appear at the baud rate (9600 samples per second). After that the line is brought high again. This is the stop bit (the red part). Then we see the start bit for the next character, and so on. The &quot;stop&quot; portion can be indefinitely long, however it has to be at least one bit length.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More detail for the first character (the letter &quot;F&quot; or 0x46 or 0b01000110) can be seen here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GYiby.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GYiby.png&quot; alt=&quot;Serial comms - a single byte&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A - no data (Tx is high)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;B - The &quot;start bit&quot;. The line is taken low to tell the receiver that a character (byte) is commencing to be sent. The receiver waits for one and a half clock times before sampling the line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;C - First character arrives (the letter &quot;F&quot; or 0x46 or 0b01000110). There is no clock bit as such, the incoming data is simply sampled at the baud (transmission) rate. In contrast to SPI communication the data arrives least-significant bit first (in case you are not sending 8 bits per byte). Thus we see 01100010 (rather than 01000110).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;D - The stop bit. This is always high, to ensure that we can distinguish between the end of this byte, and the start of the next one. Since the start bit is a zero, and the stop bit is a one, there is always a clear transition from one byte to the next.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;E - The start bit for the next character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can see from the logic analyzer capture that &lt;code&gt;T1 - T2&lt;/code&gt; is 0.1041667 ms, and as it happens that is 1/9600:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 / 9600 = 0.00010416666 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus the rate of 9600 gives you the number of &lt;strong&gt;bits per second&lt;/strong&gt; and the inverse is the &lt;strong&gt;time interval between bits&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Other considerations&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Serial comms is not self-clocked (unlike SPI or I2C, and others) hence both sender and receiver have to agree on a clock rate.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The clock rate is not exact on the Arduino, because the hardware has to divide the system clock down to get a serial clock, and the division is not always exact. There is almost always an error, the amount is given in the datasheet (figures quoted for a 16 MHz system clock, such as on the Uno):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3iVaW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3iVaW.png&quot; alt=&quot;Serial baud rate error&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can vary the number of data bits, you don't have to send 8 of them, in fact you can send 5 to 9 bits.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There can optionally be a &lt;em&gt;parity&lt;/em&gt; bit sent after the data bits. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you specify &quot;odd&quot; parity, the parity bit is set in such a way that the total number of 1-bits is odd. &lt;/li&gt;&#xA;&lt;li&gt;If you specify &quot;even&quot; parity, the parity bit is set in such a way that the total number of 1-bits is even.&lt;/li&gt;&#xA;&lt;li&gt;If you specify no parity, the parity bit is omitted.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This can help the receiver detect if the data arrived correctly or not.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The parity bit is sent before the stop bit.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the case of 9 data bits (as used in the SeaTalk protocol) the parity bit is re-purposed as a 9th data bit. Therefore you can't have both 9 data bits and a parity bit.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can also have two stop bits. This basically just lengthens the time between bytes. In the &quot;olden days&quot; this was so that slow electromechanical equipment could process the previous byte (eg. to print it).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Possible corruption&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you start listening to serial data in the middle of a stream, it is quite possible that a 0-bit in the middle of the stream will be interpreted as a start bit, and then the receiver will interpret everything after that incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only real way to recover from this is to have a large enough gap, from time to time, (eg. 10 bits long) that this cannot happen.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Inverted logic&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The bits shown here (logic-level) are not inverted. That is, a 1-bit is HIGH and a 0-bit is LOW. If you have RS232 equipment that will probably be sending something like -12 V for a 1-bit, and +12 V for a 0-bit. This is inverted because a one is less than a zero, voltage-wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have such devices you need to do voltage conversion and logic inversion. Chips like the &lt;a href=&quot;http://www.maximintegrated.com/en/products/interface/transceivers/MAX232A.html&quot; rel=&quot;noreferrer&quot;&gt;MAX232&lt;/a&gt; will do both for you. They can also provide the -12 V needed to drive such equipment by generating it internally with the help of a few user-supplied capacitors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Speed rule-of-thumb&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since, with one start bit, 8 data bits, and one stop bit we have a total of 10 bits, as a quick rule of thumb, you can calculate the number of &lt;strong&gt;bytes&lt;/strong&gt; you can transmit in a second by dividing the bit rate by 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg. At 9600 BPS you can send 960 bytes per second.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Code to reproduce:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() &#xA;  { &#xA;  Serial.begin(9600); &#xA;  Serial.print(&quot;Fab&quot;); &#xA;  } &#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-13T07:41:59.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14147" PostTypeId="1" CreationDate="2015-08-13T07:47:05.853" Score="0" ViewCount="147" Body="&lt;p&gt;I have an Arduino Uno. The story is I installed Arduino IDE and Drivers before even buying an Arduino Board. I used it a little and when I bought and connected an arduino board, I was unable to make it detect. I smacked a little usimg google and was able to somehow Fix this. but again another day, It worked a little and started creatimg problems. now its not detecting. Please suggest me a way To make it work...&#xA;Should I format my windows 7 and Reinstall all the drivers as per rules?&lt;/p&gt;&#xA;" OwnerUserId="11772" LastActivityDate="2015-11-11T13:16:10.363" Title="Arduino Uno not Detecting on Laptop" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14148" PostTypeId="2" ParentId="14139" CreationDate="2015-08-13T08:23:33.317" Score="1" Body="&lt;p&gt;You left pin 3 floating. The multimeter will lower the voltage, resulting the the led lighting. Try enabling the pull-up resistor in pin 3 by adding &lt;code&gt;pinMode(3, INPUT_PULLUP)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS you might want to add a resistor in series with that led, or it will burn out and/or damage pin 3 on the arduino.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-13T08:23:33.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14149" PostTypeId="1" CreationDate="2015-08-13T09:28:41.923" Score="0" ViewCount="487" Body="&lt;p&gt;I have an Arduino Mega2560 and a Raspberry Pi hooked up through I2C. The Pi is acting as the master, while the Arduino is the slave. While sending data over I2C, the int message gets messed up and will either send the address or the data. Then I can't even receive any useful data from the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if I turn the receiving function off it sends the data just fine, but when I ask the Pi to start receiving data again it slows down the entire bus and data starts conflicting between the Pi and Arduino. Also it only happens with the Arduino. Every other device works flawlessly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what my code looks like on the Pi side. I'm using SMBus to send and receive bytes. I didn't bother to put up code for it because I don't have the source code for SMBus. I just trust that they work because my other I2C devices work without a hitch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while True:&#xA;    #if alternating == true then get the imu if not then get the motor speed&#xA;    if alternating == True:&#xA;        try: #need the try because an error will stop the program completely&#xA;            ypr = IMU.getYPR()&#xA;            yaw = int(ypr['yaw'] * 180 / math.pi)&#xA;            savedYaw = yaw&#xA;        except:&#xA;            yaw = savedYaw&#xA;            #print &quot;exception&quot;&#xA;            pass&#xA;            #write yaw to arduino&#xA;            i2c.writeByte(yaw)&#xA;            alternating = False&#xA;        else:&#xA;            #start reading data from arduino&#xA;            #readArduino()&#xA;            alternating = True&#xA;            pass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then on the Arduino side these are my &lt;code&gt;onReceive&lt;/code&gt; and &lt;code&gt;onRequest&lt;/code&gt; functions:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void readPI(int byteC) {&#xA;    if(Wire.available()) {&#xA;        reference = Wire.read();&#xA;    }&#xA;    pid1.getReference(reference);&#xA;    pid2.getReference(reference);&#xA;}&#xA;&#xA;void sendPI() {&#xA;    int values[] = {(int)out, (int)outReversed  };&#xA;    Wire.write(values[count]);&#xA;    count++;&#xA;    if(count &amp;gt; 1) {&#xA;        count = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something about the Arduino that I don't know? Maybe it's a timing issue? Is there a way to set up registers? I can either receive or send, but I can't do both, and Googling the problem only leads to an example of someone sending 1 - 9 over the Pi. I can't find examples of anyone actually doing something complicated with an Arduino and a Rasp Pi over I2C. Any and all help would be amazing!&lt;/p&gt;&#xA;" OwnerUserId="11676" LastEditorUserId="4628" LastEditDate="2017-01-07T13:07:48.647" LastActivityDate="2017-01-07T13:07:48.647" Title="Arduino messing up as slave over I2C" Tags="|arduino-mega|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14150" PostTypeId="2" ParentId="14147" CreationDate="2015-08-13T09:38:32.230" Score="1" Body="&lt;p&gt;under the IDE make sure you have set the correct board and comm port. go to tools&gt;&gt;board then choose your board then tools&gt;&gt;Comm to choose the correct comm port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;is the IDE saying anything about having problems connecting to the board? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and no re-installing all drivers should not be necessary. &lt;/p&gt;&#xA;" OwnerUserId="11676" LastActivityDate="2015-08-13T09:38:32.230" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14152" PostTypeId="2" ParentId="14106" CreationDate="2015-08-13T10:01:25.767" Score="2" Body="&lt;p&gt;You need to open the .ino file. that is the project file for the Marlin Firmware. then upload that. Also do some research about the settings for Marlin. It isn't just plug and play, you have to enter some information about your individual stepper motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://solidutopia.com/marlin-firmware-user-guide-basic/&quot; rel=&quot;nofollow&quot;&gt;http://solidutopia.com/marlin-firmware-user-guide-basic/&lt;/a&gt; - heres a guide for Marlin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the cpp and h files are c++ files that are apart of the project. the Arduino IDE cannot open these individually. the .ino file is the project file that will allow you to open up the entire project and not just one portion of it.&lt;/p&gt;&#xA;" OwnerUserId="11676" LastActivityDate="2015-08-13T10:01:25.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14153" PostTypeId="1" AcceptedAnswerId="14155" CreationDate="2015-08-13T11:40:34.860" Score="0" ViewCount="2520" Body="&lt;p&gt;Looking at my Arduino Uno board, it appears the digital PWM pins are #11, #10, #9, #6, #5 and #3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When playing around with the Theremin, it seems that the &lt;code&gt;Tone()&lt;/code&gt; message works on all pins regardless of whether they are marked PWM or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain what is happening or how this is possible?&lt;/p&gt;&#xA;" OwnerUserId="11775" LastActivityDate="2015-08-13T15:00:50.997" Title="Tone() working on all digital pins?" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14154" PostTypeId="1" CreationDate="2015-08-13T12:00:41.230" Score="2" ViewCount="296" Body="&lt;p&gt;I had an old duemilanove lying around (Which was not working because i accidentially busted the atmega) and I recently bought some atmegas pre-flashed with the UNO bootloader. So I tried to put one of those in it, and it seems to work fine except that I have to select the UNO board in the arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Is there anything problematic to be aware of when using the UNO bootloader in an duemilanove?&lt;/p&gt;&#xA;" OwnerUserId="11776" LastEditorUserId="8" LastEditDate="2015-08-13T15:07:13.907" LastActivityDate="2015-08-13T22:29:22.423" Title="Will the Uno bootloader work in the Duemilanove?" Tags="|arduino-uno|bootloader|arduino-duemilanove|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14155" PostTypeId="2" ParentId="14153" CreationDate="2015-08-13T12:07:15.260" Score="2" Body="&lt;p&gt;The Tone library doesn't use the PWM mode timer functions on the atmega, instead it uses an interrupt routine to toggle the pins. You can find the source code for Tone libary here for reference:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/johnmccombs/arduino-libraries/blob/master/Tone/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/johnmccombs/arduino-libraries/blob/master/Tone/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11776" LastEditorUserId="11776" LastEditDate="2015-08-13T15:00:50.997" LastActivityDate="2015-08-13T15:00:50.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14156" PostTypeId="2" ParentId="14154" CreationDate="2015-08-13T13:09:20.803" Score="3" Body="&lt;p&gt;So I researched it a bit, and there does not seem to be any problems with running the UNO bootloader on a Duemilanove board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest difference between the two seems to be the USB interface: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;USB interface&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Duemilanove uses FTDI, UNO uses another microcontroller (ATmega8u2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the USB to serial is transparent for me as an end user for the most parts, it doesn't really matter to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Leaner bootloader&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UNO bootloader is smaller than the duemilanove.&lt;/p&gt;&#xA;" OwnerUserId="11776" LastEditorUserId="11754" LastEditDate="2015-08-13T22:29:22.423" LastActivityDate="2015-08-13T22:29:22.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14157" PostTypeId="1" AcceptedAnswerId="14164" CreationDate="2015-08-13T13:55:08.927" Score="5" ViewCount="26463" Body="&lt;p&gt;I need to pass a class member function to server.on, unfortunately i get an error.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: no matching function for call to 'ESP8266WebServer::on&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have done some searching but could not understand anything I found. No simple explanation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void handleRoot(){}&#xA;server.on(&quot;/&quot;, handleRoot);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void myClass::handleRoot(){}&#xA;void myClass::setup(){&#xA;    server.on(&quot;/&quot;, handleRoot);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second argument to server.on is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef std::function&amp;lt;void(void)&amp;gt; THandlerFunction;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I have no idea what it means.&lt;/p&gt;&#xA;" OwnerUserId="10956" LastEditorUserId="7389" LastEditDate="2015-10-03T18:40:18.347" LastActivityDate="2019-01-21T02:00:37.707" Title="Passing class member function as argument" Tags="|c++|arduino-ide|esp8266|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14158" PostTypeId="2" ParentId="14137" CreationDate="2015-08-13T13:59:27.657" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My RF units are both nrf24l01. I have tried working with the sample&#xA;  code and I think the issue is I don't understand how the unit works&#xA;  well enough.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&quot; rel=&quot;nofollow&quot;&gt;Start here, this is the absolutely best resource&lt;/a&gt; I could find. I use MIRF libary and there are &lt;a href=&quot;https://arduino-info.wikispaces.com/nRF24L01-Mirf-Examples&quot; rel=&quot;nofollow&quot;&gt;send and receive examples&lt;/a&gt;.  They are really, really simple. Get them working first.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the nature of the data sent between units? I want to send&#xA;  integers, possibly even text. Is that possible? Do I need to convert&#xA;  to binary or something?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Technically&lt;/em&gt;, you send between 1 and 32 &lt;em&gt;bytes&lt;/em&gt; of information. However, the libraries (see examples above) will take care of the technicality and allow you to send nums, chars or strings. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My understanding of &quot;ping&quot; and &quot;pong&quot; is that ping sends a message&#xA;  then pong sends that same message back to ping... is this correct?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not necessarily. Since &lt;a href=&quot;/questions/tagged/nrf24l01%2b&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;nrf24l01+&amp;#39;&quot; rel=&quot;tag&quot;&gt;nrf24l01+&lt;/a&gt; does all the signal checking for you, and you know that your TX device is the only one sending, you can just reply with &quot;data received&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, why are even concerned with this? Pinging and ponging have nothing to do with your task at hand.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are RF units very different? Is this one particularly difficult?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, they are different in frequencies, protocols, power etc. No, this one isn't. It's an amazing, cheap and robust piece of Norwegian ingenuity.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I just want to send with one receive with the other shouldn't this&#xA;  simplify the code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simplify compared to what exactly? It will simplify the code compared to a two-way communication, obviously.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What are pipes? How many can I open?&#xA;  As someone said before me, read the bloody manual, or a tutorial, or the data sheet, or something. The answer is 6.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any unit can send on ONE pipe and receive on SIX pipes. Imagine having 6 phones on your table. You can simultaneously listen to all 6 phones but you can only TALK INTO ONE. You can choose which one to talk into to, at any point. Unless you have a lot of devices talking to each other (more than TWO), don't bother, forget the pipes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I have 3 or more of these what changes will I need to make to the&#xA;  code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Get two Arduinos talking to each other first. No one has succeeded at making anything work by getting ahead of themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here is &lt;a href=&quot;https://www.youtube.com/watch?v=plDPBVjcckw&quot; rel=&quot;nofollow&quot;&gt;a video of two Arduinos talking&lt;/a&gt;. There's only one button but you can easily change it to a 20-button setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code for sending:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;#include &amp;lt;MirfSpiDriver.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;&#xA;const int buttonPin = 2;   &#xA;const int ledPin =  3;&#xA;&#xA;// sends a string via the nRF24L01&#xA;void transmit(const char *string)&#xA;{&#xA;  byte c; &#xA;&#xA;  for( int i=0 ; string[i]!=0x00 ; i++ )&#xA;  { &#xA;    c = string[i];&#xA;    Mirf.send(&amp;amp;c);&#xA;    while( Mirf.isSending() ) ;&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA;  //RADIO&#xA;  Serial.begin(9600);&#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;&#xA;  Mirf.init();&#xA;  Mirf.payload = 1;&#xA;  Mirf.channel = 90;&#xA;  Mirf.config();&#xA;  Mirf.configRegister(RF_SETUP,0x06);&#xA;  Mirf.setTADDR((byte *)&quot;serv1&quot;);&#xA;&#xA;  //BUTTON AND LED&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;  pinMode(ledPin, OUTPUT);&#xA;&#xA;  Serial.println(&quot;Sending ... &quot;);   &#xA;}&#xA;&#xA;void loop() {&#xA;  int buttonState = digitalRead(buttonPin);&#xA;   if (buttonState == LOW) { //pressed&#xA;    digitalWrite(ledPin, HIGH);&#xA;    transmit(&quot;X&quot;);&#xA;  }&#xA;  else {&#xA;    digitalWrite(ledPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code for receiving:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Mirf.h&amp;gt;&#xA;#include &amp;lt;MirfHardwareSpiDriver.h&amp;gt;&#xA;#include &amp;lt;MirfSpiDriver.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;&#xA;unsigned long lasttime;&#xA;unsigned long delaytime;&#xA;unsigned long time;&#xA;const int ledPin = 3;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;&#xA;  //RADIO  &#xA;  Mirf.spi = &amp;amp;MirfHardwareSpi;&#xA;  Mirf.init();&#xA;  Mirf.setRADDR((byte *)&quot;serv1&quot;); &#xA;  Mirf.payload = 1;&#xA;  Mirf.channel = 90;&#xA;  Mirf.config();&#xA;  Mirf.configRegister(RF_SETUP,0x06);&#xA;&#xA;  //LED &#xA;  pinMode(ledPin, OUTPUT);&#xA;  digitalWrite(ledPin, HIGH);   &#xA;  Serial.println(&quot;Listening ... &quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte c;&#xA;&#xA;  if( Mirf.dataReady() ) {&#xA;    Mirf.getData(&amp;amp;c);&#xA;    Serial.write(c);&#xA;&#xA;    if (c == 'X') {&#xA;      digitalWrite(ledPin, HIGH);    &#xA;    }&#xA;  } else {&#xA;      digitalWrite(ledPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10837" LastEditorUserId="10794" LastEditDate="2015-08-16T01:20:14.380" LastActivityDate="2015-08-16T01:20:14.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14159" PostTypeId="1" AcceptedAnswerId="14161" CreationDate="2015-08-13T14:10:44.683" Score="1" ViewCount="372" Body="&lt;p&gt;I am completely new to this technology, but I'm hoping to build a fairly simple program through the Arduino IDE that takes the serial numbers of RFID cards read through my ID-20LA Innovations RFID reader and send those serial numbers to an API endpoint all through the IDE (as in without using a physical Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? Are there any tutorials out there that walk through a stripped down version of this? I don't know where to start code wise, and all tutorials I've found use physical Arduinos to accomplish this.&lt;/p&gt;&#xA;" OwnerUserId="11781" LastActivityDate="2015-08-13T15:19:03.863" Title="Reading RFID tags with Arduino IDE, not using Arduino" Tags="|arduino-ide|rfid|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14161" PostTypeId="2" ParentId="14159" CreationDate="2015-08-13T15:19:03.863" Score="1" Body="&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt;&#xA;NO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long Answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1:&#xA; Use a USB RFID reader and create a basic processing/python/ app to read from the USB RFID reader and post it where ever you want it to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 2:&#xA;Use the arduino to read from the ID-20LA and send the data via UART to your computer and then create a windows app using processing/python/ to send it to your API endpoint&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 3: &#xA;Use the arduino YUN to read from the ID-20LA and then create a basic python program to run on the YUN itself. Such that it will read data from the atmel microcontroller (on the YUN) and post it to your API endpoint. This is a much cleaner yet slightly more expensive way of doing this. &lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-13T15:19:03.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14162" PostTypeId="1" CreationDate="2015-08-13T15:53:25.253" Score="1" ViewCount="4182" Body="&lt;p&gt;I can't believe I am stumped by this, but this is my issue and I can't see any other solution for this anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an official Arduino Leonardo loaded up with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  char keyToPress = random('A', 'Z'); // choose a random letter between 'A' and 'Z'&#xA;  delay(1900);&#xA;  Keyboard.press(keyToPress); &#xA;  delay(100);&#xA;  Keyboard.release(keyToPress); // overall loop time is ~2s, with a 100mS keypress length&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On OSX and Linux, I get a predictable output - random capital letters typed by a keyboard, two seconds apart: FWTDXJP etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on Windows 7(x64), I get... nothing. I have the Leonardo appear correctly as a CDC COM port, drivers were installed from the latest 1.6.5 installer on their website. I have tried uninstalling the Leonardo in device manager while checking the &quot;remove software&quot; box so as to be sure that the driver I install is the one being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone seen this before? A search of the Arduino forum reveals some people having the same issue, a bit of a discussion and then usually &quot;I don't know what I did but the problem has gone now&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the output from &lt;a href=&quot;http://www.uwe-sieber.de/usbtreeview_e.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB Device Tree Viewer&lt;/a&gt;, which seems to correctly show the USB HID descriptor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    =========================== USB Port2 ===========================&#xA;&#xA;Connection Status        : 0x01 (Device is connected)&#xA;Port Chain               : 1-2&#xA;&#xA;      ======================== USB Device ========================&#xA;&#xA;        +++++++++++++++++ Device Information ++++++++++++++++++&#xA;Friendly Name            : Arduino Leonardo (COM3)&#xA;Device Description       : Arduino Leonardo&#xA;Device Path              : \\?\usb#vid_2341&amp;amp;pid_8036#5&amp;amp;18f54cb7&amp;amp;0&amp;amp;2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}&#xA;Device ID                : USB\VID_2341&amp;amp;PID_8036\5&amp;amp;18F54CB7&amp;amp;0&amp;amp;2&#xA;Driver KeyName           : {4d36e978-e325-11ce-bfc1-08002be10318}\0001 (GUID_DEVCLASS_PORTS)&#xA;Driver                   : C:\Windows\system32\DRIVERS\usbser.sys (Version: 6.1.7601.18247  Date: 2013-08-29)&#xA;Driver Inf               : C:\Windows\inf\oem6.inf&#xA;Legacy BusType           : PNPBus&#xA;Class                    : Ports&#xA;Service                  : usbser&#xA;Enumerator               : USB&#xA;Location Info            : Port_#0002.Hub_#0001&#xA;Location IDs             : PCIROOT(0)#PCI(0600)#USBROOT(0)#USB(2)&#xA;Container ID             : {2d5fa232-297c-11e5-9565-080027ccdb00}&#xA;Manufacturer Info        : Arduino LLC (www.arduino.cc)&#xA;Capabilities             : 0x84 (Removable, SurpriseRemovalOK)&#xA;Address                  : 2&#xA;Problem Code             : 0&#xA;Power State              : D0 (supported: D0, D3, wake from D0)&#xA;COM-Port                 : COM3 (\Device\USBPDO-3)&#xA;&#xA;        ---------------- Connection Information ---------------&#xA;Connection Index         : 0x02 (2)&#xA;Connection Status        : 0x01 (DeviceConnected)&#xA;Current Config Value     : 0x01&#xA;Device Address           : 0x02 (2)&#xA;Is Hub                   : 0x00 (no)&#xA;Number Of Open Pipes     : 0x04 (4)&#xA;Device Bus Speed         : 0x01 (Full-Speed)&#xA;Pipe0ScheduleOffset      : 0x04 (4)&#xA;Pipe1ScheduleOffset      : 0x00 (0)&#xA;Pipe2ScheduleOffset      : 0x00 (0)&#xA;Pipe3ScheduleOffset      : 0x00 (0)&#xA;&#xA;        ------------------ Device Descriptor ------------------&#xA;bLength                  : 0x12 (18 bytes)&#xA;bDescriptorType          : 0x01 (Device Descriptor)&#xA;bcdUSB                   : 0x200 (USB Version 2.00)&#xA;bDeviceClass             : 0x02 (Communications and CDC Control)&#xA;bDeviceSubClass          : 0x00&#xA;bDeviceProtocol          : 0x00&#xA;bMaxPacketSize0          : 0x40 (64 bytes)&#xA;idVendor                 : 0x2341&#xA;idProduct                : 0x8036&#xA;bcdDevice                : 0x100&#xA;iManufacturer            : 0x01 (String Descriptor 1)&#xA; Language 0x0409         : &quot;Arduino LLC&quot;&#xA;iProduct                 : 0x02 (String Descriptor 2)&#xA; Language 0x0409         : &quot;Arduino Leonardo&quot;&#xA;iSerialNumber            : 0x00 (No String Descriptor)&#xA;bNumConfigurations       : 0x01&#xA;&#xA;        ------------------ String Descriptors -----------------&#xA;             ------ String Descriptor 0 ------&#xA;bLength                  : 0x04 (4 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language ID[0]           : 0x0409 (English - United States)&#xA;             ------ String Descriptor 1 ------&#xA;bLength                  : 0x18 (24 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language 0x0409          : &quot;Arduino LLC&quot;&#xA;             ------ String Descriptor 2 ------&#xA;bLength                  : 0x22 (34 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language 0x0409          : &quot;Arduino Leonardo&quot;&#xA;&#xA;        -------------- Configuration Descriptor ---------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x02 (Configuration Descriptor)&#xA;wTotalLength             : 0x0064 (100 bytes)&#xA;bNumInterfaces           : 0x03&#xA;bConfigurationValue      : 0x01&#xA;iConfiguration           : 0x00 (No String Descriptor)&#xA;bmAttributes             : 0x80&#xA; D7: Reserved, set 1     : 0x01&#xA; D6: Self Powered        : 0x00 (no)&#xA; D5: Remote Wakeup       : 0x00 (no)&#xA; D4..0: Reserved, set 0  : 0x00&#xA;MaxPower                 : 0xFA (500 mA)&#xA;&#xA;        ------------------- IAD Descriptor --------------------&#xA;bLength                  : 0x08 (8 bytes)&#xA;bDescriptorType          : 0x0B&#xA;bFirstInterface          : 0x00&#xA;bInterfaceCount          : 0x02&#xA;bFunctionClass           : 0x02 (Communications and CDC Control)&#xA;bFunctionSubClass        : 0x02&#xA;bFunctionProtocol        : 0x01&#xA;iFunction                : 0x00 (No String Descriptor)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x00&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x01 (1 Endpoint)&#xA;bInterfaceClass          : 0x02 (Communications and CDC Control)&#xA;bInterfaceSubClass       : 0x02&#xA;bInterfaceProtocol       : 0x00&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x00 (Header Functional Descriptor)&#xA;bcdCDC                   : 0x110 (CDC Version 1.10)&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)&#xA;bmCapabilities           : 0x01&#xA;bDataInterface           : 0x01&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x04 (4 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)&#xA;bmCapabilities           : 0x06&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x06 (Union Functional Descriptor)&#xA;bControlInterface        : 0x00&#xA;bSubordinateInterface[0] : 0x01&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x81 (Direction=IN  EndpointID=1)&#xA;bmAttributes             : 0x03 (TransferType=Interrupt)&#xA;wMaxPacketSize           : 0x0010 (16 bytes) (16 bytes)&#xA;bInterval                : 0x40 (64 ms)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x01&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x02 (2 Endpoints)&#xA;bInterfaceClass          : 0x0A (CDC-Data)&#xA;bInterfaceSubClass       : 0x00&#xA;bInterfaceProtocol       : 0x00&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x02 (Direction=OUT  EndpointID=2)&#xA;bmAttributes             : 0x02 (TransferType=Bulk)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x00 (ignored)&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x83 (Direction=IN  EndpointID=3)&#xA;bmAttributes             : 0x02 (TransferType=Bulk)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x00 (ignored)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x02&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x01 (1 Endpoint)&#xA;bInterfaceClass          : 0x03 (HID - Human Interface Device)&#xA;bInterfaceSubClass       : 0x00 (None)&#xA;bInterfaceProtocol       : 0x00 (None)&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        ------------------- HID Descriptor --------------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x21 (HID Descriptor)&#xA;bcdHID                   : 0x0101 (HID Version 1.01)&#xA;bCountryCode             : 0x00 (00 = not localized)&#xA;bNumDescriptors          : 0x01&#xA;Descriptor 1:&#xA;bDescriptorType          : 0x22 (Class=Report)&#xA;wDescriptorLength        : 0x0065 (101 bytes)&#xA;  05 01             Usage Page (Generic Desktop Controls)&#xA;  09 02             Usage (Mouse)&#xA;  A1 01             Collection (Application)&#xA;  09 01               Usage (Pointer)&#xA;  A1 00               Collection (Physical)&#xA;  85 01                 Report ID (0x01)&#xA;  05 09                 Usage Page (Buttons)&#xA;  19 01                 Usage Minimum (1)&#xA;  29 03                 Usage Maximum (3)&#xA;  15 00                 Logical Minimum (0)&#xA;  25 01                 Logical Maximum (1)&#xA;  95 03                 Report Count (3)&#xA;  75 01                 Report Size (1)&#xA;  81 02                 Input (Var)&#xA;  95 01                 Report Count (1)&#xA;  75 05                 Report Size (5)&#xA;  81 03                 Input (Const, Var)&#xA;  05 01                 Usage Page (Generic Desktop Controls)&#xA;  09 30                 Usage (Direction-X)&#xA;  09 31                 Usage (Direction-Y)&#xA;  09 38                 Usage (Wheel)&#xA;  15 81                 Logical Minimum (-127)&#xA;  25 7F                 Logical Maximum (127)&#xA;  75 08                 Report Size (8)&#xA;  95 03                 Report Count (3)&#xA;  81 06                 Input (Var, Rel)&#xA;  C0                  End Collection&#xA;  C0                End Collection&#xA;  05 01             Usage Page (Generic Desktop Controls)&#xA;  09 06             Usage (Keyboard)&#xA;  A1 01             Collection (Application)&#xA;  85 02               Report ID (0x02)&#xA;  05 07               Usage Page (Keyboard)&#xA;  19 E0               Usage Minimum (-32)&#xA;  29 E7               Usage Maximum (-25)&#xA;  15 00               Logical Minimum (0)&#xA;  25 01               Logical Maximum (1)&#xA;  75 01               Report Size (1)&#xA;  95 08               Report Count (8)&#xA;  81 02               Input (Var)&#xA;  95 01               Report Count (1)&#xA;  75 08               Report Size (8)&#xA;  81 03               Input (Const, Var)&#xA;  95 06               Report Count (6)&#xA;  75 08               Report Size (8)&#xA;  15 00               Logical Minimum (0)&#xA;  25 65               Logical Maximum (101)&#xA;  05 07               Usage Page (Keyboard)&#xA;  19 00               Usage Minimum (0)&#xA;  29 65               Usage Maximum (101)&#xA;  81 00               Input ()&#xA;  C0                End Collection&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x84 (Direction=IN  EndpointID=4)&#xA;bmAttributes             : 0x03 (TransferType=Interrupt)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x01 (1 ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is a screenshot from Device Manager, showing just one HID device (my keyboard / trackpad on my laptop):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HPEeG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HPEeG.png&quot; alt=&quot;Device Manager screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? I have obviously tried the example USB keyboard code from the Arduino IDE too - my code was just to get a minimum system to simplify testing. All help gratefully received.&lt;/p&gt;&#xA;" OwnerUserId="11729" LastEditorUserId="11729" LastEditDate="2015-08-13T15:58:52.613" LastActivityDate="2015-08-16T22:14:09.873" Title="Can't get Arduino Leonardo working as a USB keyboard in Windows 7" Tags="|arduino-leonardo|keyboard|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14163" PostTypeId="1" AcceptedAnswerId="14167" CreationDate="2015-08-13T16:19:32.230" Score="0" ViewCount="560" Body="&lt;p&gt;Can I make a USB 2x16 display using an Arduino?&#xA;I want to control a 2x16 character lcd display using USB, not com port/serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need it to appear as a HID device when connected to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please advise me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="11784" LastActivityDate="2015-08-13T17:41:47.277" Title="How do I use an Arduino as a USB output device for a 2x16 display?" Tags="|display|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14164" PostTypeId="2" ParentId="14157" CreationDate="2015-08-13T16:41:25.520" Score="3" Body="&lt;p&gt;It's quite common question related to C++ programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The extensive explanation can be found &lt;a href=&quot;http://www.parashift.com/c++-faq/pointers-to-members.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short answer is: it's very different from taking the address of a regular function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Workarounds (that might or might not work for you, depending on what else you need that function to do) are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make it static&lt;/li&gt;&#xA;&lt;li&gt;declare it as friend function, rather than member function&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Either way, the point is that it should not be something associated to an instance of the class, but rather to the class as a whole.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-13T16:41:25.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14165" PostTypeId="1" CreationDate="2015-08-13T17:24:38.197" Score="1" ViewCount="109" Body="&lt;p&gt;I am trying to find cheap options for displays about 3 x 6 inches to display time, weather, simple clip-art type images, and other marquee messages.  What are my best options to work with arduino if my goal is cost-cutting?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2&quot; x 4&quot; or greater in size&lt;/li&gt;&#xA;&lt;li&gt;40 dpi minimum&lt;/li&gt;&#xA;&lt;li&gt;readable from 15 feet in normal indoor conditions&lt;/li&gt;&#xA;&lt;li&gt;everything else is unimportant to me at this point: RGB, pitch, power draw, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8451" LastEditorUserId="8451" LastEditDate="2015-08-13T18:37:55.620" LastActivityDate="2015-08-14T00:38:09.920" Title="Solutions for displays?" Tags="|lcd|display|components|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14166" PostTypeId="2" ParentId="14165" CreationDate="2015-08-13T17:39:02.760" Score="1" Body="&lt;p&gt;www.aliexpress.com would be your first go for cheap stuff. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always chat with the guys and bargain a bit on the price. Do remember that the free shipping option means that it will take nearly a month to arrive&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-13T17:39:02.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14167" PostTypeId="2" ParentId="14163" CreationDate="2015-08-13T17:41:47.277" Score="2" Body="&lt;p&gt;HID's generally are input devices to your computer, if you do want your computer to send data to the device you will need an application to do it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your best bet is to have a windows app to communicate with your arduino using a virtual com port ( as it does already) and send data as you require&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-13T17:41:47.277" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="14168" PostTypeId="2" ParentId="14044" CreationDate="2015-08-13T18:14:33.040" Score="1" Body="&lt;p&gt;Since you have mentioned that all that you want your friend to do is enter the WiFi SSID and password, I am gonna assume that its where his interaction with the device ends. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I would recommend using the arduino YUN, it cant get simpler than that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The YUN is capable of creating an AP network, your friend can connect to it and then go to the arduino home page and then connect to his WiFi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use a matrix keypad and LCD screen and have your friend manually enter the details&lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="11754" LastEditDate="2015-08-13T18:19:38.383" LastActivityDate="2015-08-13T18:19:38.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14169" PostTypeId="2" ParentId="14031" CreationDate="2015-08-13T19:01:26.387" Score="1" Body="&lt;p&gt;After reading the datasheet on the PS manual, I found out that the INT1 pulse had a width of 50uS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I simply did was to declare a global integer and check it at the end of the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever I checked the incremented variable at the end, it was 48!.I personally suspected that my loop speed was to slow. Additionally the timeout value 14 ms per loop arbitrary. Clearly a disparity exists in the interrupt routine for the sensor and the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I simply did was to reconfigure the sensor output to a latched signal which clearly solved the problem. I am now getting synchronized interrupt with convincing results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;    &#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU9150.h&quot;&#xA;#include &quot;helper_3dmath.h&quot;&#xA;&#xA;#define LED_BUILTIN 13&#xA;&#xA;MPU9150 accelGyroMag; &#xA;&#xA;volatile boolean state_fifo_int = false;&#xA;int x = 0;&#xA;&#xA;void blink(uint16_t offTime, uint16_t onTime){&#xA;digitalWrite(LED_BUILTIN,HIGH);&#xA;if(onTime) delay(onTime);&#xA;digitalWrite(LED_BUILTIN,LOW);&#xA;if(offTime) delay(offTime);&#xA;}&#xA;&#xA;void resetSensor(){&#xA;  accelGyroMag.reset();&#xA;  delay(50);&#xA;  accelGyroMag.initialize();&#xA;  //Serial.println(&quot;Initialize if connection test failed&quot;);&#xA;&#xA;  if(accelGyroMag.testConnection()){ //disable interrupts&#xA;     accelGyroMag.setIntFIFOBufferOverflowEnabled(false);&#xA;     // disable fifo_interrupt&#xA;     accelGyroMag.resetFIFO();&#xA;        // verify connection&#xA;&#xA;     //Serial.println(&quot;Connection tested successfully, Disabling interrupts&quot;);&#xA;     }&#xA;if(!accelGyroMag.testConnection()){ // try to recover sensor&#xA;  accelGyroMag.initialize();&#xA;    //Serial.println(&quot;Initialize if connection test failed&quot;);&#xA;  }&#xA;if(accelGyroMag.testConnection()){  // reconfigure sensor for Fifo and interrupts&#xA;&#xA;   accelGyroMag.setFIFOEnabled(true);&#xA;   accelGyroMag.setXGyroFIFOEnabled(true);&#xA;   accelGyroMag.setAccelFIFOEnabled(true);&#xA;   accelGyroMag.setInterruptMode(false);// Set interrupt logic level mode 0 = active-high&#xA;   accelGyroMag.setInterruptLatch(true); //set interrupt 1=latch-until-int-cleared ( latch after INT_STATUS READ)&#xA;   accelGyroMag.setIntFIFOBufferOverflowEnabled(true);&#xA;&#xA;   }&#xA;else {&#xA; // Serial.println(&quot;MPU9150 connection failed&quot;);&#xA;  //Serial.println(&quot;locking UP&quot;);&#xA;  while(true){&#xA;     for(uint8_t i=0;i&amp;lt;3;i++){blink(50,100);} // S&#xA;     delay(250);&#xA;     for(uint8_t i=0;i&amp;lt;3;i++){blink(50,300);} // O&#xA;     delay(250);&#xA;     for(uint8_t i=0;i&amp;lt;3;i++){blink(50,100);} // S&#xA;     delay(500);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void setup(){&#xA;  Wire.begin();    &#xA;  Serial.begin(115200);&#xA;  pinMode(LED_BUILTIN, OUTPUT);&#xA;// other stuff&#xA;  attachInterrupt(0,fifo_int,RISING);&#xA;  resetSensor();&#xA;}&#xA;&#xA;void fifo_int() {&#xA;  x++;&#xA;  state_fifo_int = true;&#xA;&#xA;}&#xA;&#xA;static unsigned long timeout = 0; // used to detect dead sensor/connection&#xA;uint16_t fifo_count;&#xA;uint8_t fifo_buffer[8];&#xA;int16_t acc_temp[3];&#xA;int16_t gyro_x;&#xA;&#xA;void loop(){&#xA;&#xA;  if(state_fifo_int){ // interrupt has triggered&#xA;    blink(0,1);  // really quick blink // really quick blink&#xA;    //Serial.println(x);&#xA;    state_fifo_int = false;&#xA;    accelGyroMag.resetFIFO();&#xA;    accelGyroMag.getFIFOBytes(fifo_buffer,8); // fill in fifo bytes&#xA;    accelGyroMag.getIntFIFOBufferOverflowStatus(); // read the INT_STATUS reg in order to clear the Latch. &#xA;    acc_temp[0] = (((int16_t)fifo_buffer[0]) &amp;lt;&amp;lt; 8) | fifo_buffer[1];&#xA;    acc_temp[1] = (((int16_t)fifo_buffer[2]) &amp;lt;&amp;lt; 8) | fifo_buffer[3];&#xA;    acc_temp[2] = (((int16_t)fifo_buffer[4]) &amp;lt;&amp;lt; 8) | fifo_buffer[5];&#xA;    gyro_x = (((int16_t)fifo_buffer[7]) &amp;lt;&amp;lt; 8) | fifo_buffer[8];&#xA;&#xA;    timeout = millis();&#xA;&#xA;  }&#xA;&#xA; if((millis()-timeout)&amp;gt;1000){ //last interrupt was over 1 second ago! better reset Sensor!&#xA;   blink(100,500);&#xA;   blink(100,500);&#xA;&#xA;   resetSensor();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11433" LastActivityDate="2015-08-13T19:01:26.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14170" PostTypeId="1" AcceptedAnswerId="14211" CreationDate="2015-08-13T19:08:11.780" Score="0" ViewCount="2506" Body="&lt;p&gt;The company where I work wants to do a proof of concept for our new product, a force-sensing platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The platform contains four three-axial load cells, so we have 12 channels, which are to be digitized at 2kHz and 16bits. This gives us 2.000 dataframes per second, with 24 bytes of payload each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our proposed architecture is as following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The analog signals from the cells is acquired by a dedicated data-acquisition board;&lt;/li&gt;&#xA;&lt;li&gt;The digital stream is sent to the ATmega on Yún over SPI;&lt;/li&gt;&#xA;&lt;li&gt;The data is then relayed to the Atheros over Serial;&lt;/li&gt;&#xA;&lt;li&gt;Finally, the data is transmitted over UDP (or TCP).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I wonder if it is a sensible way of doing it, with the following questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How would one normally use the Ethernet functionality? Can I call a function on the sketch, or do I need to put some program or script in the Linux, calling it from the sketch?&lt;/li&gt;&#xA;&lt;li&gt;What would be the maximum transmission speed (in bytes per second) from the ATmega side to the Linux side?&lt;/li&gt;&#xA;&lt;li&gt;What would be the maximum throughput of the Ethernet?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have calculated 24 bytes * 2000 = 480 bytes per second, or a baud rate of 480 * 8 = 3840bps. Is that right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate any help, it could be just a link to the proper information resources.&lt;/p&gt;&#xA;" OwnerUserId="8044" LastActivityDate="2015-08-15T05:06:02.720" Title="Streaming sensor data over UDP using an Arduino Yún - how to do it and how fast could it be?" Tags="|serial|arduino-yun|ethernet|baud-rate|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14171" PostTypeId="2" ParentId="8129" CreationDate="2015-08-13T20:12:02.227" Score="0" Body="&lt;p&gt;Try updating your library to the new TMRh20 fork. That improves the old maniacbug's version a lot (possibly also fixing the bug). tmrh20.github.io/RF24&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's also worth noting that after you've read the message, it will print out &quot;no data&quot; until you receive new message.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-10-24T17:18:29.663" LastActivityDate="2015-10-24T17:18:29.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14172" PostTypeId="1" AcceptedAnswerId="14246" CreationDate="2015-08-13T20:16:18.507" Score="0" ViewCount="606" Body="&lt;p&gt;I've got a &lt;a href=&quot;https://www.sparkfun.com/datasheets/BreakoutBoards/MAX7456.pdf&quot; rel=&quot;nofollow&quot;&gt;MAX7456 chip&lt;/a&gt; and I am using &lt;a href=&quot;https://www.dropbox.com/s/3cp4am1f271odcm/max7456.tar?dl=1&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; library with it. &#xA;But the issue is that the character table is not the one the library needs to function like it should. The &quot;Hello world&quot; example is nowhere near to what it should display, because the character table is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the instructions that talk about character set updating require a USB FTDI cable (I don't have one), I am able to  program the board with &lt;a href=&quot;http://www.fischl.de/usbasp/&quot; rel=&quot;nofollow&quot;&gt;USBASP&lt;/a&gt; programmer but that's it. I also have a few Nanos, if that helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I update the character table to what the library needs (without a FTDI cable) or how to make the sketch included to update the character set work properly?&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-15T15:05:11.587" LastActivityDate="2015-11-15T13:53:23.510" Title="How to update the character table of MAX7456" Tags="|atmega328|" AnswerCount="1" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="14174" PostTypeId="2" ParentId="6456" CreationDate="2015-08-13T20:33:19.757" Score="1" Body="&lt;p&gt;I am too building a RF24 based network there were two issues I encountered:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Update your libraries, use &lt;a href=&quot;http://tmrh20.github.io/RF24/&quot; rel=&quot;nofollow&quot;&gt;TMRh20 fork of RF24&lt;/a&gt; (to make your life easier, use &lt;a href=&quot;http://tmrh20.github.io/RF24Mesh/&quot; rel=&quot;nofollow&quot;&gt;RF24Mesh&lt;/a&gt; too)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Add a decoupling cap to the NRF24L01+ power pins. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2015-08-13T20:33:19.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14175" PostTypeId="2" ParentId="14165" CreationDate="2015-08-13T23:28:50.220" Score="2" Body="&lt;p&gt;One possible option would be these 8x8 pixel displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hw5UO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hw5UO.jpg&quot; alt=&quot;8x8 pixel LED&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got that from eBay for $8.50 (for the 4 modules).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They come pre-assembled, this is the back:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NFmlK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NFmlK.jpg&quot; alt=&quot;8x8 pixel LED back&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the data direction. You can connect them together like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aIW09.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aIW09.jpg&quot; alt=&quot;8x8 pixel LED - 3 modules&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That one (3 lots of 4 modules) is 25.4 cm long (10 inches) and 3.2 cm high (about 1.25 inches).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's 96 pixels (8 x 4 x 3) in 10 inches, which is a lot less than 40 DPI, but really, if you want to read them from 15 feet away, that is probably OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: These were single-colour only.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want 40 DPI x 6 inches that means you must want 240 pixels horizontally and 120 pixels vertically. That would be &lt;code&gt;240 / 8&lt;/code&gt; modules horizontally (30 modules) and &lt;code&gt;120 / 8&lt;/code&gt; vertically (15 modules). That's a total of 450 modules. Since they come in lots of four that would be 116 in total (rounded up). 116 x $8.50 = $US 986.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if that is what you have in mind by &quot;cost cutting&quot; but that is one option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to assemble them yourself, connect them together, supply power, and have a suitable driver. I have some &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;code&lt;/a&gt; that drives those boards, although I certainly have not tested it with 450 of them at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see those boards come with mounting holes on the back, and are designed to be physically adjacent to each other. Mounting 450 of them could be quite tedious. The LED modules on the front pull off to give access to the mounting holes, but it would be a long job.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can get larger modules, as mentioned in another reply, I expect they would be more expensive, but you would of course get more pixels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;a href=&quot;http://www.adafruit.com/products/2278&quot; rel=&quot;nofollow noreferrer&quot;&gt;64x32 RGB LED Matrix - 4mm pitch&lt;/a&gt;. That one is 64x32 pixels for around $US 80.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would probably need 4 of those horizontally (256 pixels) and 4 vertically (128 pixels). Thus, a total of 16 which would cost you around $US 1280. However for that at least you get RGB. Note that the Adafruit page mentions you cannot drive that many pixels with a Uno.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-13T23:28:50.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14176" PostTypeId="2" ParentId="14165" CreationDate="2015-08-14T00:38:09.920" Score="2" Body="&lt;p&gt;How about just a computer monitor? That would be reasonably large, have high resolution, and could display whatever you want it to. That would only be a few hundred dollars (if that). You could drive it from a cheap PC, or from an Arduino using something like the &lt;a href=&quot;http://www.microvga.com/&quot; rel=&quot;nofollow&quot;&gt;MicroVGA&lt;/a&gt; board. That has 800x600 pixels resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would be cheaper, and less fiddly, than putting together a lot of LED display modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://playground.arduino.cc/Main/MicroVGA&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/MicroVGA&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-14T00:38:09.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14177" PostTypeId="2" ParentId="9658" CreationDate="2015-08-14T01:27:25.350" Score="1" Body="&#xA;&#xA;&lt;p&gt;I modified your Uno sketch slightly to add a delay:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDR 0x50&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Wire.requestFrom(SLAVE_ADDR, 1);&#xA;&#xA;  if (Wire.available())&#xA;  { &#xA;    byte byteReceived = Wire.read();&#xA;    Serial.println(byteReceived, DEC);&#xA;  }&#xA;&#xA; delay (1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upon testing, it worked perfectly!&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;23&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suggest a wiring error. Check you have:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Uno    ATtiny85&#xA;--------------------&#xA;A4      pin 5  (SDA)&#xA;A5      pin 7  (SCL)&#xA;+5V     pin 8&#xA;Gnd     pin 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-14T01:27:25.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14178" PostTypeId="1" CreationDate="2015-08-14T01:40:35.630" Score="0" ViewCount="549" Body="&lt;p&gt;Does anyone know (1) how much transient current can be output from a pin and (2) how much (and how long) reverse current an output pin can take?  For instance, consider the following circuit (driven by a series of 10 ms pulses at 5V):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  o----------------&#xA;       |          |&#xA;       = 10µF    1k LOAD&#xA;       |          |&#xA;  o----------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would be a classical filtered (smoothed) PWM circuit.  When the pin goes to +5V, the capacitor would act like a short and allow very high current (assuming about 20 ohm impedance, maybe 250 mA) for a millisecond or so.  Similarly, when the voltage drops to 0V, the charged capacitor will discharge, leading to a reverse current until it bleeds through the load.  Will either of these damage the diodes in the pin or even the IC?  Thanks.  (Worse comes to worse, does this mean that a resistor and diode are needed to protect the pin?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)  It's 10µF.  10 pF would be useless in a power supply, it would only store 0.05 µC of electricity at most, which would only be able to smooth the output for a few microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)  The load is resistance, 1 k ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3)  A diode would be handy if you wanted to prevent reverse current, since you could put a much larger diode outside than the protective diodes in the Arduino.  They are classically used with motors (inductive load) as a clamp diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4)  My general question is about high transient current or reverse currents.  A capacitor is just an example of a situation that could cause this.  Another example would be a pin that is putting out only occasional (for example) 1ms long 100 mA pulses, separated by many seconds.  Such a circuit is really not delivering much power, but for very short periods it exceeds that recommended 40 mA.  Would this burn out the pin or not?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5)  A capacitor in parallel with the load is pretty much the classic filtered DC power supply.  Open any wall wart you have and you'll see a transformer, a rectifier and several large (electrolytic) capacitors (along with a couple small ones) and a voltage regulator.  Closer to this example, say you want to deliver current at 2 volts DC.  You can do this by alternating 2 ms pulses (at 5V) with 3 ms at 0V.  Then have a capacitor in series to smooth it to closer to DC, making it more like analog output.  That is, in fact, exactly how adjustable power supplies often work.&lt;/p&gt;&#xA;" OwnerUserId="11797" LastEditorUserId="7280" LastEditDate="2015-08-19T13:33:59.120" LastActivityDate="2021-02-22T03:06:30.747" Title="Transient and reverse current" Tags="|arduino-uno|pins|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14179" PostTypeId="1" AcceptedAnswerId="14180" CreationDate="2015-08-14T04:02:29.370" Score="0" ViewCount="1412" Body="&lt;p&gt;Hoping someone can help me out in my conundrum here...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently am testing the SoftwareSerial library out to understand how I may use it in my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a wire running from pin 6 to pin 9, so that the TX talks straight to the RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(6,9); //RX = 6 TX = 9&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(1200);&#xA;  mySerial.begin(1200);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  mySerial.write('F');&#xA;  delay(100); // attempting to allow time between write and read commands&#xA;&#xA;  while (mySerial.available()&amp;gt;0) {&#xA;  Serial.println(mySerial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The whole point is just to see 'F' return in the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output, unfortunately, is absolutely nothing! If I omit the &lt;code&gt;while(mySerial.available&amp;gt;0)&lt;/code&gt; I just get -1 's down the lines of the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="11800" LastActivityDate="2015-08-14T05:39:30.330" Title="SoftwareSerial Write to return Read in Serial Monitor?" Tags="|serial|softwareserial|software|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14180" PostTypeId="2" ParentId="14179" CreationDate="2015-08-14T04:45:45.277" Score="3" Body="&#xA;&#xA;&lt;p&gt;SoftwareSerial cannot talk to itself. Since it is implemented in software and not hardware it can either send or receive at one time, but not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at the code for &lt;code&gt;write&lt;/code&gt; in SoftwareSerial:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;size_t SoftwareSerial::write(uint8_t b)&#xA;{&#xA;&#xA;...&#xA;&#xA;  cli();  // turn off interrupts for a clean txmit&#xA;&#xA;...&#xA;&#xA;&#xA;  // Write each of the 8 bits&#xA;  for (uint8_t i = 8; i &amp;gt; 0; --i)&#xA;  {&#xA;    if (b &amp;amp; 1) // choose bit&#xA;      *reg |= reg_mask; // send 1&#xA;    else&#xA;      *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;    tunedDelay(delay);&#xA;    b &amp;gt;&amp;gt;= 1;&#xA;  }&#xA;&#xA;...&#xA;&#xA;  SREG = oldSREG; // turn interrupts back on&#xA;&#xA;...&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since it turns interrupts off, and interrupts are needed for it to detect incoming data, therefore it cannot detect incoming data while it is sending.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-14T05:39:30.330" LastActivityDate="2015-08-14T05:39:30.330" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14181" PostTypeId="1" AcceptedAnswerId="14186" CreationDate="2015-08-14T07:22:30.677" Score="23" ViewCount="5019" Body="&lt;p&gt;Why do people use a variable to specify a pin number when the pin is unlikely to change throughout the execution of the code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many times I see an &lt;code&gt;int&lt;/code&gt; being used for a pin definition,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when the use of a &lt;code&gt;const int&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int led = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;a href=&quot;http://playground.arduino.cc/Code/Enum&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;enum&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&quot;https://www.arduino.cc/en/Reference/Define&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;#define&lt;/code&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;makes much more sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is even in tutorials on the Arduino site, for example, the first tutorial that most people run, &lt;a href=&quot;https://www.arduino.cc/en/tutorial/blink&quot; rel=&quot;noreferrer&quot;&gt;Blink&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;a href=&quot;https://stackoverflow.com/questions/16889213/how-to-use-define-to-assign-pins-in-arduino#comment-24383545&quot;&gt;read somewhere&lt;/a&gt; that &lt;code&gt;const int&lt;/code&gt; is preferred over &lt;code&gt;#define&lt;/code&gt;. Why isn't this encouraged right from the beginning, rather than allowing people to develop bad habits, from the outset? I noticed it a while back, but recently it has started to irritate me, hence the question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Memory/processing/computing wise is a &lt;code&gt;const int&lt;/code&gt;, &lt;code&gt;enum&lt;/code&gt;, or for that matter &lt;code&gt;#define&lt;/code&gt;, better than a plain &lt;code&gt;int&lt;/code&gt;, i.e. occupies less memory, stored in &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Memory&quot; rel=&quot;noreferrer&quot;&gt;different memory&lt;/a&gt; (Flash, EEPROM, SRAM), faster execution, quicker to compile?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This may appear to be a duplicate of &lt;a href=&quot;https://arduino.stackexchange.com/questions/506/is-it-better-to-use-define-or-const-int-for-constants&quot;&gt;Is it better to use #define or const int for constants?&lt;/a&gt;, but I am addressing the question of why people use variables, and how does the performance improve when they don't, rather than which type of constant is better.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2019-03-18T22:12:59.877" Title="Why use an int variable for a pin when const int, enum or #define makes much more sense" Tags="|variables|c-preprocessor|constants|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14182" PostTypeId="5" CreationDate="2015-08-14T07:23:23.227" Score="0" Body="&lt;p&gt;The C preprocessor or &lt;code&gt;cpp&lt;/code&gt; is the macro preprocessor for the &lt;a href=&quot;/questions/tagged/c&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;c&amp;#39;&quot; rel=&quot;tag&quot;&gt;c&lt;/a&gt; and &lt;a href=&quot;/questions/tagged/c%2b%2b&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;c++&amp;#39;&quot; rel=&quot;tag&quot;&gt;c++&lt;/a&gt; computer programming languages, although it is often used in conjunction with other languages. The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Resources&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://gcc.gnu.org/onlinedocs/cpp/index.html&quot; rel=&quot;nofollow&quot;&gt;GNU CPP online manual&lt;/a&gt; describes the syntax and use of the C preprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://sourceforge.net/apps/mediawiki/predef/index.php?title=Main_Page&quot; rel=&quot;nofollow&quot;&gt;Pre-defined C/C++ Compiler Macros project&lt;/a&gt; lists pre-defined compiler macros that can be used to identify standards, compilers, operating systems and hardware architectures at compile-time.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-14T22:06:14.830" LastActivityDate="2015-08-14T22:06:14.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14183" PostTypeId="4" CreationDate="2015-08-14T07:23:23.227" Score="0" Body="the macro preprocessor for the C and C++ computer programming languages." OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-14T22:05:37.463" LastActivityDate="2015-08-14T22:05:37.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14184" PostTypeId="5" CreationDate="2015-08-14T07:24:46.407" Score="0" Body="&lt;p&gt;In programming, a constant is an identifier whose associated value cannot typically be altered by the program during its execution (though in some cases this can be circumvented, e.g. using self-modifying code). Many programming languages make an explicit syntactic distinction between constant and variable symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although a constant's value is specified only once, a constant may be referenced many times in a program. Using a constant instead of specifying a value multiple times in the program cannot only simplify code maintenance, but it can also supply a meaningful name for it and consolidate such constant bindings to a standard code location (for example, at the beginning).&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-14T21:09:23.397" LastActivityDate="2015-08-14T21:09:23.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14185" PostTypeId="4" CreationDate="2015-08-14T07:24:46.407" Score="0" Body="Constants in programming are definitions whose value is fixed throughout a program's execution. Literals in most languages are constants, for example. In referentially transparent programming styles, all definitions are constant." OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2015-08-14T22:06:30.913" LastActivityDate="2015-08-14T22:06:30.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14186" PostTypeId="2" ParentId="14181" CreationDate="2015-08-14T09:03:03.433" Score="20" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int led = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the correct method. Or even:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte led = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How many pins do you have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the tutorials did not quite go through as much quality control as they might have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Performance will be better using &lt;code&gt;const byte&lt;/code&gt;, compare to &lt;code&gt;int&lt;/code&gt; however the compiler may be smart enough to realize what you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is gently encourage people to use more efficient techniques by using them in your own code.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Responses to comments&lt;/h3&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;A commenter has suggested that &lt;code&gt;byte&lt;/code&gt; is not standard C. This is correct, however this is an Arduino StackExchange site, and I believe using standard types supplied by the Arduino IDE is acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Arduino.h there is this line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;typedef uint8_t byte;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this is not exactly the same as &lt;code&gt;unsigned char&lt;/code&gt;. See &lt;a href=&quot;https://stackoverflow.com/questions/1725855/uint8-t-vs-unsigned-char&quot;&gt;uint8_t vs unsigned char&lt;/a&gt; and &lt;a href=&quot;https://stackoverflow.com/questions/16138237/when-is-uint8-t-%E2%89%A0-unsigned-char&quot;&gt;When is uint8_t ≠ unsigned char?&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another commenter has suggested that using byte will not necessarily improve performance, because numbers smaller than &lt;code&gt;int&lt;/code&gt; will be promoted to &lt;code&gt;int&lt;/code&gt; (see Integer Promotion Rules if you want more on this).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However in the context of a &lt;strong&gt;const&lt;/strong&gt; identifier, the compiler will generate efficient code in any case. For example, disassembling &quot;blink&quot; gives this in the original form:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;00000086 &amp;lt;loop&amp;gt;:&#xA;  86:   8d e0           ldi r24, 0x0D   ; 13&#xA;  88:   61 e0           ldi r22, 0x01   ; 1&#xA;  8a:   1b d1           rcall   .+566       ; 0x2c2 &amp;lt;digitalWrite&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact it generates the same code whether the &lt;code&gt;13&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is a literal&lt;/li&gt;&#xA;&lt;li&gt;Is a &lt;code&gt;#define&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is a &lt;code&gt;const int&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is a &lt;code&gt;const byte&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The compiler know when it can fit a number into one register and when it can't. However it is &lt;em&gt;good practice&lt;/em&gt; to use coding that indicates your &lt;em&gt;intent&lt;/em&gt;. Making it &lt;code&gt;const&lt;/code&gt; makes it clear that the number won't change, and making it &lt;code&gt;byte&lt;/code&gt; (or &lt;code&gt;uint8_t&lt;/code&gt;) makes it clear that you are expecting a small number.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Confusing error messages&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Another major reason to avoid &lt;code&gt;#define&lt;/code&gt; is the error messages you get if you make a mistake. Consider this &quot;blink&quot; sketch which has an error:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define LED = 13;&#xA;&#xA;void setup() {&#xA;  pinMode(LED, OUTPUT);      // &amp;lt;---- line with error&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(LED, HIGH);   // &amp;lt;---- line with error &#xA;  delay(1000);             &#xA;  digitalWrite(LED, LOW);    // &amp;lt;---- line with error&#xA;  delay(1000);              &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the surface it looks OK, but it generates these error messages:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Blink.ino: In function ‘void setup()’:&#xA;Blink:4: error: expected primary-expression before ‘=’ token&#xA;Blink:4: error: expected primary-expression before ‘,’ token&#xA;Blink:4: error: expected `;' before ‘)’ token&#xA;Blink.ino: In function ‘void loop()’:&#xA;Blink:8: error: expected primary-expression before ‘=’ token&#xA;Blink:8: error: expected primary-expression before ‘,’ token&#xA;Blink:8: error: expected `;' before ‘)’ token&#xA;Blink:10: error: expected primary-expression before ‘=’ token&#xA;Blink:10: error: expected primary-expression before ‘,’ token&#xA;Blink:10: error: expected `;' before ‘)’ token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You look at the first highlighted line (line 4) and &lt;em&gt;don't even see&lt;/em&gt; a &quot;=&quot; symbol. Plus, the line looks fine. Now it's fairly obvious what the problem is here (&lt;code&gt;= 13&lt;/code&gt; is being substituted for &lt;code&gt;LED&lt;/code&gt;), but when the line is 400 lines further down in the code, it isn't obvious the problem is with the way LED is defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen people fall for this many times (including myself).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2017-04-02T06:53:55.010" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14187" PostTypeId="2" ParentId="14181" CreationDate="2015-08-14T09:12:23.187" Score="20" Body="&lt;p&gt;As Ignacio has rightly states, it's basically because they don't know better.  And they don't know better because the people who taught them (or the resources they used when learning) didn't know better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much of the Arduino code and tutorials are written by people who have never had any training in programming and are very much &quot;self taught&quot; from resources by people who themselves are very much self taught with no proper training in programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many of the snippets of tutorial code I see around the place (and especially those that are only available within YouTube videos --- urgh) would be a fail mark if I were marking them in an exam.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, a &lt;code&gt;const&lt;/code&gt; is preferred over a non-const, and even over a &lt;code&gt;#define&lt;/code&gt;, because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &lt;code&gt;const&lt;/code&gt; (like a &lt;code&gt;#define&lt;/code&gt;, unlike a non-const) does not allocate any RAM&lt;/li&gt;&#xA;&lt;li&gt;A &lt;code&gt;const&lt;/code&gt; (like a non-const, but unlike a &lt;code&gt;#define&lt;/code&gt;) gives the value an explicit &lt;em&gt;type&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The second point there is of particular interest.  Unless specifically told otherwise with embedded type-casting (&lt;code&gt;(long)3&lt;/code&gt;) or a type suffix (&lt;code&gt;3L&lt;/code&gt;) or the presence of a decimal point (&lt;code&gt;3.0&lt;/code&gt;), a &lt;code&gt;#define&lt;/code&gt; of a number will always be an integer and all mathematics performed on that value will be as if it were an integer.  Most of the time that's not a problem, but you can run into interesting scenarios when you try to &lt;code&gt;#define&lt;/code&gt; a value that is larger than an integer can store, such as &lt;code&gt;#define COUNT 70000&lt;/code&gt; and then perform a mathematical operation with other &lt;code&gt;int&lt;/code&gt; values on it.  By using a &lt;code&gt;const&lt;/code&gt; you get to tell the compiler &quot;This value is to be treated as this variable type&quot; - so you would instead use: &lt;code&gt;const long count = 70000;&lt;/code&gt; and all would work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also has the knock-on effect that it checks the type when passing the value around the place.  Try passing a &lt;code&gt;const long&lt;/code&gt; to a function that expects an &lt;code&gt;int&lt;/code&gt; and it would complain about narrowing the variable range (or even completely fail to compile depending on the scenario).  Do that with a &lt;code&gt;#define&lt;/code&gt; and it would just silently carry on giving you the wrong results and leave you scratching your head for hours.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2019-03-18T22:12:59.877" LastActivityDate="2019-03-18T22:12:59.877" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="14188" PostTypeId="1" AcceptedAnswerId="14190" CreationDate="2015-08-14T10:58:26.263" Score="2" ViewCount="1232" Body="&lt;p&gt;Hi my lcd doesnt display that i was expected. Can anyone help me???&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS--&gt;22&#xA;RW--&gt;GROUND&#xA;E--&gt;23&#xA;D4--&gt;24&#xA;D5--&gt;25&#xA;D6--&gt;26&#xA;D7--&gt;27&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(22, 23, 24, 25, 26, 27);&#xA;void setup() {&#xA;&#xA;lcd.begin(16,2);&#xA;&#xA;lcd.setCursor(0,1);&#xA;lcd.print(&quot;Hello!&quot;);&#xA;delay(1000);&#xA;}&#xA;void loop() {&#xA;lcd.setCursor(0,1);&#xA;lcd.print(millis()/1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O8XnG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O8XnG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11803" LastActivityDate="2015-08-15T03:54:08.013" Title="Arduino LCD Simple Problem" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14189" PostTypeId="1" AcceptedAnswerId="43314" CreationDate="2015-08-14T12:46:43.843" Score="4" ViewCount="19843" Body="&lt;p&gt;I'm not sure if I should split this question in two.&#xA;I had to edit some libraries and I plan to make some myself but didn't try yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Editing a library seems very laborious comared to editing a sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to use an external editor and then compile on the Arduino IDE with the help of a test sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish to use the Arduino IDE to edit the libraries but it seems it is not easy, maybe in future reales it is supported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The libraries used to be on %home%/Arduino/libraries/etc. but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries and it seems these packages might get updated so maybe it is not a good idea to edit them there but I am not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about GitHub and conflicts? I clone the library and edit it but then I have two versions and you can't choose one of them. So I have to delete the original from the arduino instalation or wherever it is to avoid the conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also wish to post the progress to GitHub and maybe receive collaboration there. Do you have any hint about the clone process or something to avoid any trouble with it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what about the .h/.o? Arduino precompile the headers on startup so if I edit a .h I have to find and delete the .o or restart the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you do all of this? Is there any trick that helps?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11023" LastActivityDate="2017-08-04T04:17:28.270" Title="How to develop or edit an Arduino library?" Tags="|library|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14190" PostTypeId="2" ParentId="14188" CreationDate="2015-08-14T12:55:23.600" Score="3" Body="&lt;p&gt;I Had a similar problem with a different display, It looks like you are printing the value without clearing the display so all the numbers print on top of each other creating those squares. try adding lcd.clear() in the loop to clear the display before it prints another value.&lt;/p&gt;&#xA;" OwnerUserId="11676" LastActivityDate="2015-08-14T12:55:23.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14191" PostTypeId="1" AcceptedAnswerId="14200" CreationDate="2015-08-14T13:55:41.583" Score="0" ViewCount="1933" Body="&#xA;&#xA;&lt;p&gt;I use a single MCP23S17 connected to an Arduino Uno. I use its port B for output and port A for input. When I first started to use this device I noticed, I could read pins, but using them as output failed. After a lot of debugging and trial and error I found out, that the IODIRx Register was never programmed. I then copied the respective code from the setup() routine — where it belongs IMHO — to the loop() routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And miraculously the IODIRx Register was written correctly. The code below contains the IODIRx programming snippet in the setup() as well as in loop(). But only in loop() it yields an effect. This means: The output will work only after the first traversal of loop() in my example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rest of the setup() routine obviously works, which means it is called at least. SPI is initialised correctly there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This drives me nuts. What the hell is a setup routine for, if you can't setup things there. And why on earth doesn't it work then? I don't do strange things there. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;   &#xA;#include &amp;lt;inttypes.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;flanschcontrol.h&quot;&#xA;#define DEBUGOUTPUT&#xA;#define PROTOV2&#xA;typedef int elem_type;&#xA;#define ADDRESS (0)   &#xA;#define    OPCODEW       (0b01000000)  // Opcode for MCP23S17 with LSB (bit0) set to write (0), address OR'd in later, bits 1-3&#xA;#define    OPCODER       (0b01000001)  // Opcode for MCP23S17 with LSB (bit0) set to read (1), address OR'd in later, bits 1-3&#xA;#define    ADDR_ENABLE   (0b00001000)  // Configuration register for MCP23S17, the only thing we change is enabling hardware addressing&#xA;uint8_t PexSSPin=7;&#xA;&#xA;void setup() {&#xA;   Serial.begin(9600);&#xA;    pinMode(PexSSPin, OUTPUT);&#xA;    SPI.begin();                          &#xA;    SPI.setClockDivider(2);   &#xA;    SPI.setBitOrder(MSBFIRST);            &#xA;    SPI.setDataMode(SPI_MODE0);           &#xA;&#xA;    delay(1000);    &#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1)); &#xA;    SPI.transfer(IODIRB);&#xA;    SPI.transfer(0b10101010);&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    delay(1000);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1));             // Send the MCP23S17 opcode, chip address, and write bit&#xA;    SPI.transfer(GPIOB);&#xA;    SPI.transfer(0b00000000);&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    Serial.println(&quot;0&quot;);&#xA;    delay(1000);&#xA;&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1));             // Send the MCP23S17 opcode, chip address, and write bit&#xA;    SPI.transfer(GPIOB);&#xA;    SPI.transfer(0b11111111);&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    Serial.println(&quot;ff&quot;);&#xA;    delay(1000);&#xA;&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1));             // Send the MCP23S17 opcode, chip address, and write bit&#xA;    SPI.transfer(GPIOB);&#xA;    SPI.transfer(0b00001111);&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    Serial.println(&quot;0f&quot;);&#xA;    delay(1000);&#xA;&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1));             // Send the MCP23S17 opcode, chip address, and write bit&#xA;    SPI.transfer(GPIOB);&#xA;    SPI.transfer(0b11110000);&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    Serial.println(&quot;f0&quot;);&#xA;    delay(1000);&#xA;&#xA;    int value;&#xA;&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODER | (ADDRESS &amp;lt;&amp;lt; 1));  // Send the MCP23S17 opcode, chip address, and read bit&#xA;    SPI.transfer(GPIOA);                      // Send the register we want to read&#xA;    value = SPI.transfer(0x00);               // Send any byte, the function will return the read value (register address pointer will auto-increment after write)&#xA;    value |= (SPI.transfer(0x00) &amp;lt;&amp;lt; 8);       // Read in the &quot;high byte&quot; (portB) and shift it up to the high location and merge with the &quot;low byte&quot;&#xA;    PORTD |= 0b10000000;    // Slaveselect high&#xA;    Serial.print(&quot;pindata: &quot;);&#xA;    Serial.println(value);&#xA;    delay(1000);    &#xA;&#xA;    PORTD &amp;amp;= 0b01111111;    // Slaveselect low&#xA;    SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1)); &#xA;    SPI.transfer(IODIRB);&#xA;    SPI.transfer(0b10101010);&#xA;    PORTD |= 0b10000000;    // Slaveselect high     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Definitions of some preprocessor thingies:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define    IODIRA    (0x00)      // MCP23x17 I/O Direction Register&#xA;#define    IODIRB    (0x01)      // 1 = Input (default), 0 = Output&#xA;#define    GPIOA     (0x12)      // MCP23x17 GPIO Port Register&#xA;#define    GPIOB     (0x13)      // Value on the Port - Writing Sets Bits in the Output Latch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="10794" LastEditDate="2015-08-15T01:39:54.083" LastActivityDate="2018-02-02T10:27:13.760" Title="MCP23S17: Programming IODIRx-Register works in loop(), but not in setup()" Tags="|spi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14193" PostTypeId="1" AcceptedAnswerId="14202" CreationDate="2015-08-14T15:47:28.337" Score="0" ViewCount="8935" Body="&lt;p&gt;I'm attempting to connect two Arduino boards to eachother using SotwareSerial as the title suggests! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two boards are 1) Arduino UNO and 2)MultiWii Controller (MWC) FLIP 1.5 (Uses ATMega328 chip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea, is to get Serial TX on the &lt;em&gt;&quot;MWC&quot;&lt;/em&gt; FLIP 1.5 to Serial RX on the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are my connections thus far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MWC Pin -------&gt;UNO Pin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital 3 (TX)---&gt;Digital 6 (RX)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital 9 (RX)---&gt;Digital 9 (TX)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code on the MWC Chip -- the TX chip. (NOTE: These functions are called to run in a header file)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;attout.h&quot;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;&#xA;SoftwareSerial altSerial(9,3); // RX=9 TX=3 &#xA;&#xA;void startaltserial(){&#xA;&#xA;  altSerial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void attout(){&#xA;&#xA;pinMode(3,HIGH);&#xA;pinMode(9,HIGH);&#xA;&#xA;  altSerial.print('1');&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: I also tried &lt;code&gt;altSerial.write('1')&lt;/code&gt;. Same result (or lack of one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, the RX Code on the UNO Board:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(6,9); // RX=6 TX=9 &#xA;&#xA;void setup()  &#xA;{&#xA;  // Open serial communications:&#xA;  Serial.begin(9600);&#xA;&#xA;  // Set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  while (mySerial.available()&amp;gt;0) {&#xA;    Serial.println(mySerial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open Serial Monitor for the UNO board, I get nothing but zeroes streaming down. Curiously, if I disconnect the TX OUT wire from MWC, the Serial stream stops!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means, as far as I can tell, that the UNO is doing its job of receiving, and the MWC is doing it's job of transmitting, but something is wrong with the formatting inbetween, so that I end up with zeroes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if I change the baud rate, the Serial Monitor output changes. When I go to 1200 baud, I get nothing but '4' followed quickly by '1' and then carriage return, so it looks like '41'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope we can find a solution to these quandaries. My next course of action is trying I2C, but I'm not sure about it yet...&lt;/p&gt;&#xA;" OwnerUserId="11800" LastEditorUserId="11800" LastEditDate="2015-08-14T21:29:48.170" LastActivityDate="2016-09-21T17:43:28.253" Title="Sending Data between two boards using SoftwareSerial" Tags="|arduino-uno|serial|communication|softwareserial|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14194" PostTypeId="2" ParentId="14189" CreationDate="2015-08-14T16:37:13.597" Score="1" Body="&lt;p&gt;I am going to split my answer into 2 parts &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Editing an Arduino library:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It &lt;strong&gt;doesn't&lt;/strong&gt; matter how you edit your library, you can do it in notepad for all I care. It just doesn't matter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Version Control:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Git is a version control software used to track software/code changes and ensure that people don't screw up the files by adding code that's not tested. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to contribute to a certain library here is what you need to do &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1: create a github.com account since most people host it there &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 2: &lt;strong&gt;fork&lt;/strong&gt; the required library, this basically creates a clone of the library in your account. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 3: &lt;strong&gt;clone&lt;/strong&gt; the forked repo from your account to your computer. So now you have the files on your computer to mess around&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 4: create a &lt;strong&gt;branch&lt;/strong&gt; a branch is your personal workspace to mess around as you wish. The advantage of have a branch is that if you screw up.  You could always go to the main branch (master) and start over :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 5: once you are done editing and testing and are sure the file is perfect, you &lt;strong&gt;commit&lt;/strong&gt; your changes and then you create **pull request ** with the original author so  that he can review your work and if he is happy will accept your change and merge it to master. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: read about adding remote to your git repo and fetching from remote repo, once you understand these basics you will understand the power of git :)  &lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="11754" LastEditDate="2015-08-14T18:21:18.963" LastActivityDate="2015-08-14T18:21:18.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14198" PostTypeId="2" ParentId="14189" CreationDate="2015-08-14T23:09:29.620" Score="1" Body="&lt;p&gt;This is the common process for all open source projects, not just arduino (example using github svn)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Fork a project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you fork a project, you create a separate &quot;project&quot; of your own from the original project on the SVN. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Clone your project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clone your fork down to your local directory so you can make changes and use it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git clone https://github.com/&amp;lt;your-repo&amp;gt;/&amp;lt;project&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. Push changes up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Push your changes up to your repo regularly. At this point your changes are not affecting the original project in any way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git push -u origin &amp;lt;branch&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4. Pull updates from the original project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original author(s) can make changes and improve his/her code. You can make sure your fork is up-to-date by pulling/merging those updates into your fork.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;git pull https://github.com/&amp;lt;original-author&amp;gt;/&amp;lt;repo&amp;gt; &amp;lt;branch&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some time there will be conflicts, which are normal since your changes and the author's may collide. You'll be prompted to fix the conflicts before committing your changes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&#xA;    # this portion is your code at the current HEAD&#xA;=======&#xA;    # this portion is the one from the original branch master&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; master&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll have to fix the conflict manually by either accepting your change and deleting the master's or deleting your change, and get rid of the marks before committing to your svn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4. Creat a pull request&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After using your supercharged version of the project for a while, you think it might be useful for others. To contribute, you create a pull request to the original author. It works similar to you pulling in his changes, just he will review your changes then merge in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the while, others can do all these with your project too!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To edit the project/make changes, you can use any editor to open your local project, code away, save it and commit. It is not ideal to use Arduino IDE since it is an environment to run the code (but otherwise possible).&lt;/p&gt;&#xA;" OwnerUserId="11757" LastActivityDate="2015-08-14T23:09:29.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14199" PostTypeId="1" CreationDate="2015-08-14T23:56:27.647" Score="1" ViewCount="96" Body="&lt;p&gt;I'm looking to build a motion sensor which detects if an object is in the monitored area. Doing some researched I found out that I can use &lt;a href=&quot;http://www.adafruit.com/products/189?&amp;amp;main_page=product_info&amp;amp;cPath=35&amp;amp;products_id=189&quot; rel=&quot;nofollow&quot;&gt;PIR motion sensor&lt;/a&gt; for this but it seems the area it monitors is pretty small. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need something that can monitor about 3 feet x 1 feet area. Is there something else that I can use for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to light up some LED lights when an object is detected in that area. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11815" LastActivityDate="2015-08-15T19:30:00.650" Title="Motion sensor large areas" Tags="|led|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14200" PostTypeId="2" ParentId="14191" CreationDate="2015-08-15T00:54:39.233" Score="1" Body="&#xA;&#xA;&lt;p&gt;You've fallen for the old &quot;slave select pin is already low&quot; trick!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me show you. First we add a line to bring pin 2 high before starting the sequence (for logic analyzer triggering):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;pinMode (2, OUTPUT);     // &amp;lt;--- pin 2 output&#xA;delay(1000);    &#xA;PORTD |= bit (2);        // &amp;lt;--- pin 2 HIGH&#xA;PORTD &amp;amp;= 0b01111111;     // Slaveselect low&#xA;SPI.transfer(OPCODEW | (ADDRESS &amp;lt;&amp;lt; 1)); &#xA;SPI.transfer(IODIRB);&#xA;SPI.transfer(0b10101010);&#xA;PORTD |= 0b10000000;    // Slaveselect high&#xA;delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the logic analyzer output of running your sketch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/c2IPr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c2IPr.png&quot; alt=&quot;Slave select low&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice how SS is low all the time, and thus the chip does not respond to the command?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now we add a line &lt;strong&gt;before&lt;/strong&gt; the &lt;code&gt;SPI.begin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PORTD |= 0b10000000;    // Slaveselect high&#xA;SPI.begin();                          &#xA;SPI.setClockDivider(2);   &#xA;SPI.setBitOrder(MSBFIRST);            &#xA;SPI.setDataMode(SPI_MODE0);           &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now look at the results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xu2HN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xu2HN.png&quot; alt=&quot;Slave select high&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This time you get the transition of SS from high to low, the chip notices it, and we have a valid SPI transaction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So without bringing SS high, the &lt;strong&gt;first&lt;/strong&gt; thing you sent was always going to fail.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It was nothing to do with it being in &lt;code&gt;setup&lt;/code&gt; - it couldn't be. After all the logic is basically this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;init ();&#xA;setup ();&#xA;while (true) &#xA;  loop ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Personally I wouldn't hard code all those bit patterns throughout the code. What if you change the slave select pin one day?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (PexSSPin, LOW);&#xA;/// write to chip&#xA;digitalWrite (PexSSPin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Isn't that much more readable? And easier to change later?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-15T01:00:10.977" LastActivityDate="2015-08-15T01:00:10.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14202" PostTypeId="2" ParentId="14193" CreationDate="2015-08-15T01:54:59.113" Score="1" Body="&lt;p&gt;Your problem here is that you are streaming out serial data non-stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my answer in this thread: &lt;a href=&quot;https://arduino.stackexchange.com/questions/1569/what-is-serial-begin9600/14146#14146&quot;&gt;What is Serial.begin(9600)?&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without having a pause, the receiver just latches onto somewhere in the middle of the data stream and tries to make sense of it, often unsuccessfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you add one &quot;character time&quot; delay to the &lt;strong&gt;sender&lt;/strong&gt;, the receiver works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  altSerial.print('1');&#xA;  delay (2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might get the first one wrong, but now the receiver has 2 ms to resynchronize on the data stream. At 9600 baud the delay should be 1/960 (second) at least, I used twice that to be sure.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-08-15T01:54:59.113" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14204" PostTypeId="2" ParentId="14199" CreationDate="2015-08-15T02:35:27.340" Score="2" Body="&lt;p&gt;A standard PIR motion sensor will work fine.  It can monitor motion in a very room.  You just need to make sure the PIR sensor is far enough away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one article that states it should work up to 10 meters away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.mobotix.com/eng_US/Support/FAQ/Configuration2/What-is-the-range-of-the-PIR-Passive-Infrared-motion-detector&quot; rel=&quot;nofollow&quot;&gt;https://www.mobotix.com/eng_US/Support/FAQ/Configuration2/What-is-the-range-of-the-PIR-Passive-Infrared-motion-detector&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the device that the PIR sensor is mounted on must be stationary.  It will not work on a robot of anything that is moving.&lt;/p&gt;&#xA;" OwnerUserId="4519" LastActivityDate="2015-08-15T02:35:27.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14205" PostTypeId="2" ParentId="4233" CreationDate="2015-08-15T02:45:18.940" Score="-1" Body="&lt;p&gt;You might also want to consider purchasing a simple and popular L293D motor driver chip.  I teach basic Arduino classes and learning to use this chip is much easier than using transistors and diodes.  The other advantage is the motors can go both forward and backward!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the following link you can purchase one chip for under $1.00 USD and each chip will driver two motors both forward and backward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/New-L293D-L293-L293B-DIP-SOP-Push-Pull-4-CH-Four-Channel-Motor-Driver-IC-/371198300958&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/New-L293D-L293-L293B-DIP-SOP-Push-Pull-4-CH-Four-Channel-Motor-Driver-IC-/371198300958&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4519" LastActivityDate="2015-08-15T02:45:18.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14208" PostTypeId="1" CreationDate="2015-08-15T04:17:33.720" Score="1" ViewCount="8472" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qB9Jv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qB9Jv.jpg&quot; alt=&quot;This is how it looks.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on a project that will log data to an SD card and display a user interface on an OLED. &lt;a href=&quot;https://learn.sparkfun.com/tutorials/photon-oled-shield-hookup-guide&quot; rel=&quot;nofollow noreferrer&quot;&gt;The SparkFun OLED breakout&lt;/a&gt; was super easy to set up. I was also able to get the &lt;a href=&quot;https://github.com/technobly/SparkCore-SD&quot; rel=&quot;nofollow noreferrer&quot;&gt;SD-Card library&lt;/a&gt; working independently, though that was harder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trouble is when I combine these examples the SD card &lt;em&gt;only&lt;/em&gt; writes during &quot;setup&quot; after that it isn't writing to the SD card as the loop continues. The OLED still works just fine.  I've read up on SPI a bit and tried various things to get &quot;chip select&quot; to work (I suspect this is the problem) I even tried setting the CS pins to LOW or HIGH using digitalWrite, but this had no impact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My pins are connected as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          SD CARD      OLED  &#xA;MOSI        A5            A5     same pin&#xA;MISO        A4            --     just SD connected&#xA;SCK         A3            A3     same pin&#xA;CS          A1            A2     different pins&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The SD card writes in the main loop if I comment out all of the code that runs the OLED. The OLED works either way.  What could I try next?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; #include &quot;application.h&quot;&#xA; #include &quot;sd-card-library/sd-card-library.h&quot;&#xA; #include &quot;SparkFunMicroOLED/SparkFunMicroOLED.h&quot;&#xA; #include &quot;math.h&quot;&#xA;&#xA; //////////////////////////////////&#xA; // MicroOLED Object Declaration //&#xA; //////////////////////////////////&#xA; // Declare a MicroOLED object. If no parameters are supplied, &#xA; // default pins are used, which will work for the Photon Micro &#xA; // OLED Shield (RST=D7, DC=D6, CS=A2)&#xA; // Since I use A1 as the chip select pin for the SD card these&#xA; // defaults seem fine.&#xA;&#xA;    MicroOLED oled;&#xA;&#xA; // Declare a file object?&#xA;&#xA;    File myFile;&#xA;&#xA; // These are the pins for the SD card. A5, A4, and A3 are all &#xA; // shared by the OLED.&#xA;&#xA;    const uint8_t chipSelectSD = A1;&#xA;    const uint8_t mosiPin = A5;&#xA;    const uint8_t misoPin = A4;&#xA;    const uint8_t clockPin = A3;&#xA;&#xA; ////////////&#xA; // setup //&#xA; ////////////&#xA; void setup() {&#xA;  delay(500);&#xA;&#xA;  SD.begin(mosiPin, misoPin, clockPin, chipSelectSD);&#xA;  File dataFile = SD.open(&quot;data.txt&quot;, FILE_WRITE);&#xA;  dataFile.println(&quot;this text was printed to the SD card during setup&quot;);&#xA;  dataFile.close();&#xA;&#xA;  oled.begin();  // Initialize the OLED&#xA;  oled.clear(ALL); // Clear the display's internal memory&#xA;  delay(1000);  // Delay 1000 ms&#xA;  oled.clear(PAGE); // Clear the buffer.&#xA;  randomSeed(analogRead(A0) + analogRead(A7)); //seed to make test pattern random.&#xA;&#xA;               }//end setup&#xA;&#xA;&#xA;//////////////////&#xA;// main loop //&#xA;//////////////////&#xA;void loop()  {&#xA;&#xA;  SD.begin(mosiPin, misoPin, clockPin, chipSelectSD);&#xA;  File dataFile = SD.open(&quot;data.txt&quot;, FILE_WRITE);&#xA;  dataFile.println(&quot;The text was added during the loop.&quot;);&#xA;  dataFile.close();&#xA;&#xA;//test the display with text and pixels. &#xA;  printTitle(&quot;Pixels&quot;, 1);&#xA;  for (int i=0; i&amp;lt;512; i++)&#xA;  { oled.pixel(random(oled.getLCDWidth()),  random(oled.getLCDHeight()));&#xA;  oled.display(); }&#xA;   delay(9000);&#xA;&#xA;               } //end loop&#xA;&#xA;&#xA;//-------------------------//&#xA;// function to print titles //&#xA;//-------------------------//&#xA;  void printTitle(String title, int font) {&#xA;  int middleX = oled.getLCDWidth() / 2;&#xA;  int middleY = oled.getLCDHeight() / 2;&#xA;  oled.clear(PAGE);&#xA;  oled.setFontType(font);&#xA;  // Try to set the cursor in the middle of the screen&#xA;  oled.setCursor(middleX - (oled.getFontWidth() * (title.length()/2)),&#xA;  middleY - (oled.getFontWidth() / 2));&#xA;  // Print the title:&#xA;  oled.print(title);&#xA;  oled.display();&#xA;  delay(1500);&#xA;  oled.clear(PAGE);&#xA;                                           } //end title function &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qfxAr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qfxAr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how the SD card is hooked up.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;  oled.begin();  // Initialize the OLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any attempt to use the SD card after this line will not work. I've looked for something like &quot;oled.end()&quot; but have not found a way to reset to the state where the SD card works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried commenting out all of the OLED code and then the SD card writes fine in the main loop. So, I started adding the OLED code back in. This line of code breaks the SD card writing in the main loop:&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="37523" LastEditDate="2019-08-07T15:23:01.670" LastActivityDate="2021-03-25T16:11:55.347" Title="Making CS (chip select) work in SPI (for and SD card and OLED)" Tags="|sd-card|spi|display|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="14211" PostTypeId="2" ParentId="14170" CreationDate="2015-08-15T04:59:07.250" Score="1" Body="&lt;p&gt;The Yun is really two different computers (one AVR and on Linux) connected by a serial link. Basically the AVR is connected to a serial console on the Linux machine, so you can &quot;type&quot; commands into Linux by sending strings out the serial port from the AVR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial link normally comes up at 250,000 buad, so that should not be a bottleneck for your application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, the AVR will &quot;type&quot; a command to run a Python program on the Linux side (called the Bridge) that will then communicate with AVR code using a high level protocol. Unfortunately, this &quot;bridge&quot; connections tends to be slow and flaky. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you could do what you want very easily by just pumping netcat commands into the Linux machine from the AVR machine every time you wanted to send a UDP packet out. The overhead would only be a few serial bytes per packet (you'd send &quot;nc -u   \r&quot; where everything but data is likely the same for every packet). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of a program that runs on thew AVR and periodically reads some data from temperature sensors connected via 1-Wire, and then runs a &quot;curl&quot; command on the linux console to record  the readings to a server...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/bigjosh/SimpleTempLoggerYun/blob/master/Arduino/SimpleTempLoggerYun/SimpleTempLoggerYun.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/bigjosh/SimpleTempLoggerYun/blob/master/Arduino/SimpleTempLoggerYun/SimpleTempLoggerYun.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, your replace the 1-Wire reading code with SPI reading code, and replace the &quot;curl&quot; that sends HTTP data command with an &quot;&lt;a href=&quot;http://linux.die.net/man/1/nc&quot; rel=&quot;nofollow&quot;&gt;nc&lt;/a&gt;&quot; command that would send a UDP packet (using the &quot;-u&quot; parameter). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this technique, I think you could get something working very very quickly and likely easily meet your data rate requirements. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that while this is a great technique for getting a proof-of-concept working quickly, I would not use a setup like this in production. Instead consider something like a BeagleBone Black where you could read the SPI data and send the UDP pack in a single C program that ran as a normal Linux process. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="7859" LastEditDate="2015-08-15T05:06:02.720" LastActivityDate="2015-08-15T05:06:02.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14212" PostTypeId="2" ParentId="14178" CreationDate="2015-08-15T06:31:31.660" Score="-1" Body="&lt;p&gt;I have had fairly lengthy discussions with &lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/LEDs.html&quot; rel=&quot;nofollow&quot;&gt;Mike Cook&lt;/a&gt; from the Arduino forum about this sort of thing. I asked, for example, if it was OK to drive LEDs by PWM providing the duty cycle was short enough that &quot;on average&quot; the pins put out a current in specified range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;His answer always is: &lt;strong&gt;no&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet does not say you can exceed the &lt;em&gt;absolute maximum ratings&lt;/em&gt; for a certain amount of time (like 1 µs). You are not supposed to exceed them at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't take a particularly large series resistor to limit current to the recommended 20 mA (250 Ω at 5 V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can probably &quot;get away with&quot; not using it, but you are basically moving into unsupported territory. If the chip fails after a year, don't blame the manufacturer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's 10 microFarad = 10mmF. 10 picoFarad would be useless in a power supply&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to &lt;a href=&quot;https://en.wikipedia.org/wiki/Farad&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A &quot;micro-microfarad&quot; (μμF, and confusingly often mmf or MMF), an obsolete unit sometimes found in older texts, is the equivalent of a picofarad. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your use of mmF as a replacement for µF is confusing. I suggest either copying and pasting &quot;my&quot; µ from this post, or using a simple &quot;u&quot; instead.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... useless in a power supply&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Surely you are not seriously suggesting that you are going to make a power supply, powered by an Arduino output pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am presuming not, so perhaps if you describe your application?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-15T06:31:31.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14213" PostTypeId="1" AcceptedAnswerId="14214" CreationDate="2015-08-15T09:56:19.527" Score="1" ViewCount="913" Body="&lt;p&gt;I am currently building a project involving a laser scanner (two galvanometers with mirrors that deflect a laser beam) that I want to control. The galvos need +-10V differential signals (and I'd like to have a least 12Bit) that I want create with some small board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduinos I know use PWM to create an analog output which is not usable for this project. I found the Teensy3.1 which has at least one 12Bit DAC so that also doesn't work. An alternative would be a DAC breakout board like &lt;a href=&quot;https://www.adafruit.com/products/935&quot; rel=&quot;nofollow&quot; title=&quot;MCP4725&quot;&gt;&quot;MCP4725&quot;&lt;/a&gt; but it would be nicer to just have a single board with no additional parts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best thing would be a small board with already two 12Bit DACs. (even If I had to upscale the voltage +-10v)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a board I haven't found so far? Or have I missed a completely different approach?&lt;/p&gt;&#xA;" OwnerUserId="50158" LastActivityDate="2015-08-15T10:10:31.777" Title="Which board/shield to generate (non-PWM) analog outputs?" Tags="|analogwrite|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14214" PostTypeId="2" ParentId="14213" CreationDate="2015-08-15T10:10:31.777" Score="2" Body="&lt;p&gt;For 12-bit dual DAC you want the &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf&quot; rel=&quot;nofollow&quot;&gt;MCP4822&lt;/a&gt; which has two channels of 0-4.095V in 1mV steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of that you would then need to pass through a suitable amplifier arrangement with an op-amp giving a gain of 5 and adding an offset of -10V.  The gain would change the 0-4.095V to 0-20.475V, and the -10V offset would change that to -10V to +10.475V.  If you want to get more precise you could use an offset of -10.2375V (it's not easy to make an offset voltage that precise) then you would get -10.2375V to 10.2375V in 12-bit resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's doubtful you'll find a board already made up with that specific arrangement (it's fairly specialised) but it's not something that's hard to make - all the components are available as DIP or other through hole components, and the circuit for the amplification stage is pretty simple (check for non-inverting op-amp circuits online, there's millions), so building it up on strip board or matrix board would be easy enough.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-15T10:10:31.777" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14215" PostTypeId="1" CreationDate="2015-08-15T10:27:22.610" Score="1" ViewCount="10332" Body="&lt;p&gt;I got a copy of Arduino from a local retailer here (it's a local copy and I'm pretty confused with how the pins actually work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know basic electronics so far, there should be two pins for every node one acting as the negative terminal and other as the positive terminal. If I were to connect an LED with my Arduino board which pins would I be utilizing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here let me tell you how pins are arranged on mine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IOREF                                                                         GND                                  &#xA;&#xA;                                         13  &#xA;RESET                                                                         12  &#xA;3.3V     //this left group marked power                                        .&#xA;5V                                  //right group marked PWM                   2&#xA;GND            //right groupmarked communication                          TX0 -1  &#xA;GND                                                                       RX0- 0                                   &#xA;&#xA;&#xA;V1N                                                                       TX3-14       &#xA;                                                                         RX2 -15&#xA;A0                                                                         ..&#xA;A1                                                                      SCL -21&#xA;..   //THIS left GROUP MARKED ANALOG IN&#xA;A7&#xA;&#xA;&#xA;A8&#xA;A9 //I believe it is part of the above group&#xA;..&#xA;A14&#xA;A15&#xA;&#xA;     //the pins below marked DIGITAL&#xA;     52-50-`48-46...........................................................22`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11823" LastEditorUserId="10794" LastEditDate="2015-08-15T22:40:48.963" LastActivityDate="2016-01-13T08:52:46.697" Title="How do pins on an arduino mega 2560 work?" Tags="|arduino-mega|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14216" PostTypeId="2" ParentId="14215" CreationDate="2015-08-15T11:21:39.823" Score="3" Body="&lt;p&gt;Any IO pin can be set to either be an input, where it reports to your program if the voltage present on that pin (relative to ground) is above or below a certain threshold (HIGH or LOW voltage), or it can be an output, where it can either be set to be a HIGH output (pin is connected internally to +5V) or a LOW output (pin is connected internally to GND).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To drive an LED you would connect one side of a small resistor (say 470Ω) to any IO pin you choose.  The other side of the resistor would connect to the anode of the LED.  The cathode of the LED would then connect to ground.  When you set the IO pin to HIGH it will provide 5V to the LED through the resistor (which is needed to limit the current as the LED is a non-linear, current driven, component) and the circuit is completed by the return path through ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SlqIV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SlqIV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you &lt;em&gt;must not&lt;/em&gt; exceed 40mA going into or out of any IO pin, and you &lt;em&gt;should not&lt;/em&gt; exceed 25mA going into or out of any IO pin.  The total current going into or out of &lt;em&gt;all&lt;/em&gt; IO pins &lt;em&gt;must not&lt;/em&gt; exceed 200mA.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-15T11:21:39.823" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14217" PostTypeId="1" AcceptedAnswerId="14236" CreationDate="2015-08-15T13:56:20.633" Score="0" ViewCount="258" Body="&lt;p&gt;I've created a very basic POV project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has a 12V DC motor with a piece of wood on it.&#xA;The wood has 6 LEDs on it as well as a copper ring.&#xA;The power is delivered to the LEDs from brushes connecting to the copper ring and from the shaft of the motor (the ground is attached to the base of the motor.) I'm using a TCRT5000L Sensor to count the RPM and have attached the LEDs to pin 13 and ground of the Arduino. (I've attached white tape to one side of the wood so that the sensor only counts one rev.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help (please) with the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 13; &#xA;volatile  int tcnt = 0; &#xA;volatile  int lastcount = 0; &#xA;volatile int state = LOW; &#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA;  pinMode(pin, OUTPUT); &#xA;  attachInterrupt(1, blink, RISING); &#xA;} &#xA;&#xA;void loop() { &#xA;  Serial.println(tcnt); &#xA;  if (tcnt != lastcount)&#xA;  {&#xA;     digitalWrite(pin, HIGH);&#xA;     delay(10);&#xA;     digitalWrite(pin, LOW);&#xA;     delay(10);&#xA;     lastcount = tcnt;&#xA;  }&#xA;&#xA;&#xA;   delay(10);&#xA;&#xA;} &#xA;&#xA;void blink() { &#xA;  tcnt = tcnt + 1; &#xA;  state = !state; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My first issue is that the when I use the code above, the lights don't seem to switch on / off on the exact same area. They are within 30 degrees but certainly not precise. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second issue (and the biggest) is that I'm sure that this code is not the best way to do what I need. For example, if I wanted to use this as an analog clock, so that the lights would only show on the current hour / minute, how would I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mtp02.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mtp02.jpg&quot; alt=&quot;Side View&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rmGd4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rmGd4.jpg&quot; alt=&quot;Top View&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11025" LastActivityDate="2015-08-16T06:07:32.517" Title="Need assistance with program for POV Project" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14218" PostTypeId="2" ParentId="3781" CreationDate="2015-08-15T15:14:05.173" Score="1" Body="&lt;p&gt;Add the board and their fuse description from what is already set and it will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For adding just &lt;code&gt;C:\Program Files\Arduino\hardware\arduino\avr\boards.txt&lt;/code&gt; and add the board description.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;########&#xA;############ Definitions for ATmega 8MHz &#xA;##############################################################&#xA;atmega16-8.name=Atmega16 (internal 8MHz clock)&#xA;&#xA;atmega16-8.upload.tool=avrdude&#xA;&#xA;atmega16-8.upload.protocol=stk500v1&#xA;&#xA;atmega16-8.upload.maximum_size=14336&#xA;atmega16-8.upload.speed=19200&#xA;&#xA;atmega16-8.bootloader.low_fuses=0xE8&#xA;atmega16-8.bootloader.high_fuses=0x99&#xA;&#xA;atmega16-8.build.mcu=atmega16&#xA;atmega16-8.build.f_cpu=8000000L&#xA;atmega16-8.build.core=arduino:arduino&#xA;atmega16-8.build.variant=mega16&#xA;&#xA;##############################################################&#xA;############################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used it.&lt;/p&gt;&#xA;" OwnerUserId="11826" LastEditorUserId="6936" LastEditDate="2019-05-08T22:32:33.057" LastActivityDate="2019-05-08T22:32:33.057" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14219" PostTypeId="1" AcceptedAnswerId="14234" CreationDate="2015-08-15T16:16:43.583" Score="0" ViewCount="60" Body="&lt;p&gt;I've been scouring the internet looking for a small Arduino that can power two sensors and a servo. Is there a way of getting a custom one? Does anyone know if theres software out there for creating custom Arduinos and having them made?&lt;/p&gt;&#xA;" OwnerUserId="7837" LastActivityDate="2015-08-16T04:54:18.590" Title="I'm looking for a real small but decent Arduino, that can fit in a watch but power a servo and a gyroscope" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14220" PostTypeId="2" ParentId="14219" CreationDate="2015-08-15T16:50:54.540" Score="0" Body="&lt;p&gt;Look at the ATtiny85 MCU. It's a small 8pin device, and pretty easy to get up and running using Arduino code. You could also use the ATtiny84 which has more pins and still very small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start here: &lt;a href=&quot;https://code.google.com/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-tiny/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there are plenty of tutorials on setting up and programming them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding a custom board, your least expensive route would be to design your own. Otherwise you would need to outsource the design. &lt;/p&gt;&#xA;" OwnerUserId="11075" LastActivityDate="2015-08-15T16:50:54.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14221" PostTypeId="2" ParentId="14219" CreationDate="2015-08-15T17:11:43.077" Score="0" Body="&lt;p&gt;No, there is no software specifically for designing custom Arduinos.  However, the Arduino is open source, so you can design your own if you have the skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can download the schematics for your chosen base design from the Arduino website, then use any PCB design software you like to design your own PCB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then send that PCB design off to China (for example) to have it fabricated, and when you get them back you can solder the components on and hope it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, designing and building very small circuits well is a talent that few possess. Hand building circuits with the very tiny components you will need to make it fit into a watch is very difficult and normally requires specialist equipment.  That is unless you want your watch to be the size of a dinner plate, like most of the watch kits you can buy.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-15T17:11:43.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14222" PostTypeId="1" CreationDate="2015-08-15T18:35:31.260" Score="-2" ViewCount="370" Body="&lt;p&gt;I've been getting involved with arduino recently as a means of improving a heating device which is quite small, a box about 15x10x5cm which I would like to rig with an &lt;a href=&quot;http://www.melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx&quot; rel=&quot;nofollow&quot;&gt;MLX90614&lt;/a&gt; infrared sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The box is already &quot;wired&quot; with many small flexible tubes, so I would like to set up the sensor so that I can read from it wirelessly, to keep it from getting anymore complicated than it needs to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the most compact way to set up a transceiver capable of I2C (ideally with arduino uno coding compatibility) and to then communicate with another arduino? (I already have an Uno to act as the base station)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I mention that the device should be codable with Arduino is that the MLX90614 uses a communication protocol that is beyond my skill level and which I can only operate with open source code libraries for arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been doing some research and the best thing I've found so far is the &lt;a href=&quot;http://www.panstamp.com/products/&quot; rel=&quot;nofollow&quot;&gt;PanStamp&lt;/a&gt;, but I have never soldered before, and they are not in business at the moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another limitation is size. I would prefer not to use another entire arduino Uno, with shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course low cost is a plus :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if any of you have worked on something like this before and you have a recommendation, it would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Ryan&lt;/p&gt;&#xA;" OwnerUserId="11830" LastActivityDate="2016-02-12T08:16:12.497" Title="How to wirelessly communicate with I2C infrared thermometer" Tags="|i2c|datalogging|wireless|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14223" PostTypeId="1" AcceptedAnswerId="14231" CreationDate="2015-08-15T18:37:01.237" Score="0" ViewCount="291" Body="&lt;p&gt;I am doing simple proof of concept trying to send C++ program output to Adafruit CC3000 WiFi Shield (using Visual Studio 2013 Desktop Edition on Windows 8.1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my design laptop is connected to UNO via USB, UNO is connected to WiFi Shield, and WiFi Shield is connected to D-Link router running Adafruit example sketch (&quot;EchoServer&quot;). These connections are working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I am using TCP client sample code from Microsoft for WiFi connectivity with client code running on the laptop to connect to WiFi Shield. Tested this code with sample TCP server code from Microsoft, and client was able to communicate with server code but for some reason this client is not able to find WiFi Shield TCP Server. I get &quot;Unable to connect to server&quot; error with CC3000 continue to show it is listening for connections but never finds one&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure it is due to my lack of understanding TCP/networking world. Below is the client code I am running on laptop using Visual Studio:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define WIN32_LEAN_AND_MEAN&#xA;&#xA;#include &amp;lt;windows.h&amp;gt;&#xA;#include &amp;lt;WinSock2.h&amp;gt;&#xA;#include &amp;lt;ws2tcpip.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include&amp;lt;iostream&amp;gt;&#xA;&#xA;// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib&#xA;#pragma comment (lib, &quot;Ws2_32.lib&quot;)&#xA;#pragma comment (lib, &quot;Mswsock.lib&quot;)&#xA;#pragma comment (lib, &quot;AdvApi32.lib&quot;)&#xA;&#xA;&#xA;#define DEFAULT_BUFLEN 512          //Default buffer length of port&#xA;#define DEFAULT_PORT &quot;7&quot;        //Change this to change port&#xA;&#xA;int main()//int argc, char **argv&#xA;{&#xA;    WSADATA wsaData;&#xA;    SOCKET ConnectSocket = INVALID_SOCKET;&#xA;    struct addrinfo *result = NULL,&#xA;        *ptr = NULL,&#xA;        hints;&#xA;    char *sendbuf = &quot;100&quot;;&#xA;    char recvbuf[DEFAULT_BUFLEN];&#xA;    int iResult;&#xA;    int recvbuflen = DEFAULT_BUFLEN;&#xA;    /*&#xA;    // Validate the parameters - not necessary for use&#xA;    if (argc != 2) {&#xA;        printf(&quot;usage: %s server-name\n&quot;, argv[0]);&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;    */&#xA;&#xA;    // Initialize Winsock&#xA;    iResult = WSAStartup(MAKEWORD(2, 2), &amp;amp;wsaData);&#xA;    if (iResult != 0) {&#xA;        printf(&quot;WSAStartup failed with error: %d\n&quot;, iResult);&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;&#xA;    ZeroMemory(&amp;amp;hints, sizeof(hints));&#xA;    hints.ai_family = AF_UNSPEC;&#xA;    hints.ai_socktype = SOCK_STREAM;&#xA;    hints.ai_protocol = IPPROTO_TCP;&#xA;&#xA;    // Resolve the server address and port&#xA;    iResult = getaddrinfo(NULL, DEFAULT_PORT, &amp;amp;hints, &amp;amp;result);&#xA;    if (iResult != 0) {&#xA;        printf(&quot;getaddrinfo failed with error: %d\n&quot;, iResult);&#xA;        WSACleanup();&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;&#xA;    // Attempt to connect to an address until one succeeds&#xA;    for (ptr = result; ptr != NULL; ptr = ptr-&amp;gt;ai_next) {&#xA;&#xA;        // Create a SOCKET for connecting to server&#xA;        ConnectSocket = socket(ptr-&amp;gt;ai_family, ptr-&amp;gt;ai_socktype,&#xA;            ptr-&amp;gt;ai_protocol);&#xA;        if (ConnectSocket == INVALID_SOCKET) {&#xA;            printf(&quot;socket failed with error: %ld\n&quot;, WSAGetLastError());&#xA;            WSACleanup();&#xA;            system(&quot;pause&quot;); return 1;&#xA;        }&#xA;&#xA;        // Connect to server.&#xA;        iResult = connect(ConnectSocket, ptr-&amp;gt;ai_addr, (int)ptr-&amp;gt;ai_addrlen);&#xA;        if (iResult == SOCKET_ERROR) &#xA;        {&#xA;            closesocket(ConnectSocket);&#xA;            ConnectSocket = INVALID_SOCKET;&#xA;            continue;&#xA;        }&#xA;        break;&#xA;    }&#xA;&#xA;    freeaddrinfo(result);&#xA;&#xA;    if (ConnectSocket == INVALID_SOCKET) //If failed to get a socket, end program&#xA;    {&#xA;        printf(&quot;Unable to connect to server!\n&quot;);&#xA;        WSACleanup();&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;&#xA;    // Send an initial buffer&#xA;    iResult = send(ConnectSocket, sendbuf, (int)strlen(sendbuf), 0);&#xA;    if (iResult == SOCKET_ERROR) {&#xA;        printf(&quot;send failed with error: %d\n&quot;, WSAGetLastError());&#xA;        closesocket(ConnectSocket);&#xA;        WSACleanup();&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;&#xA;    printf(&quot;Bytes Sent: %ld\n&quot;, iResult);&#xA;&#xA;&#xA;&#xA;    // Receive until the peer closes the connection&#xA;    do {&#xA;&#xA;        iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);&#xA;        if (iResult &amp;gt; 0)&#xA;        {&#xA;            printf(&quot;Bytes received: %d\n&quot;, iResult);&#xA;            std::cout &amp;lt;&amp;lt; recvbuf &amp;lt;&amp;lt; std::endl;&#xA;        }&#xA;        else if (iResult == 0)&#xA;            printf(&quot;Connection closed\n&quot;);&#xA;        else&#xA;            printf(&quot;recv failed with error: %d\n&quot;, WSAGetLastError());&#xA;&#xA;    } while (iResult &amp;gt; 0);&#xA;    // shutdown the connection since no more data will be sent&#xA;    iResult = shutdown(ConnectSocket, SD_SEND);&#xA;    if (iResult == SOCKET_ERROR) {&#xA;        printf(&quot;shutdown failed with error: %d\n&quot;, WSAGetLastError());&#xA;        closesocket(ConnectSocket);&#xA;        WSACleanup();&#xA;        system(&quot;pause&quot;); return 1;&#xA;    }&#xA;    // cleanup&#xA;    closesocket(ConnectSocket);&#xA;    WSACleanup();&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11829" LastEditorUserId="11829" LastEditDate="2015-08-15T20:22:50.250" LastActivityDate="2015-08-16T00:46:12.833" Title="Having issues with sending output to WiFi Shield" Tags="|arduino-uno|c++|wifi|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14224" PostTypeId="1" CreationDate="2015-08-15T19:23:35.930" Score="-1" ViewCount="2148" Body="&lt;p&gt;Disabling a push button after being under pressure for some time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to disable a button where the user is pressing for a time it is disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13; &#xA;&#xA;int inPin = 7; &#xA;&#xA;int val = 0; &#xA;&#xA;void setup() {&#xA;&#xA;pinMode(ledPin, OUTPUT); &#xA;&#xA;pinMode(inPin, INPUT); &#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;val = digitalRead(inPin);&#xA;&#xA;if (val == HIGH) {&#xA;&#xA;digitalWrite(ledPin, LOW);&#xA;&#xA;} else {&#xA;&#xA;digitalWrite(ledPin, HIGH); &#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11015" LastActivityDate="2015-08-15T22:34:08.153" Title="Disabling a push button after being under pressure for some time?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14225" PostTypeId="2" ParentId="14199" CreationDate="2015-08-15T19:30:00.650" Score="0" Body="&lt;p&gt;It sounds like what you want is an ultrasonic distance (&quot;ping&quot;) sensor over the area where the car is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the car isn't there it will measure the height of the garage (say 3m).  With the car there it will measure the distance from the ceiling to the top of the car (say 1.5m).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultrasonic sensors have a limit to their range.  The cheap ones are usually around 2m, so may not work for you, or you may get away with it if it will return &quot;infinite&quot; for anything outside its range, in which case anything that is not &quot;infinite&quot; will be something present under the sensor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-15T19:30:00.650" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14226" PostTypeId="2" ParentId="14224" CreationDate="2015-08-15T19:32:19.750" Score="1" Body="&lt;pre&gt;&lt;code&gt;int ledPin = 13; &#xA;int inPin = 7; &#xA;int val = 0;&#xA;int oldVal = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT); &#xA;  pinMode(inPin, INPUT); &#xA;}&#xA;&#xA;void loop(){&#xA;  val = digitalRead(inPin);&#xA;  if (val == HIGH &amp;amp;&amp;amp; oldVal == LOW) {&#xA;    digitalWrite(ledPin, LOW);&#xA;    oldVal = HIGH;&#xA;  } else if (val == LOW &amp;amp;&amp;amp; oldVal == HIGH) {&#xA;    digitalWrite(ledPin, HIGH); &#xA;    oldVal = LOW;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-15T19:32:19.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14228" PostTypeId="2" ParentId="14224" CreationDate="2015-08-15T22:17:59.250" Score="0" Body="&#xA;&#xA;&lt;p&gt;I think the question is about activating something on a switch push, but only for x seconds. For example, you press a button to sound an alarm, but it stops after 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte ledPin = 13; &#xA;const byte inPin = 7; &#xA;&#xA;const unsigned long MAX_PUSH_TIME = 2000;  // ms&#xA;const unsigned long DEBOUNCE_TIME = 20;    // ms&#xA;unsigned long whenPushed;&#xA;&#xA;bool switchState; &#xA;bool awaitingRelease;&#xA;&#xA;void setup() &#xA;  {&#xA;  pinMode(ledPin, OUTPUT); &#xA;  pinMode(inPin, INPUT_PULLUP); &#xA;  }  // end of setup&#xA;&#xA;void switchPushed ()&#xA;  {&#xA;  // we want them to let go now, ignore it&#xA;  if (awaitingRelease) &#xA;    return;&#xA;&#xA;  // is LED already on?&#xA;  if (digitalRead (ledPin) == HIGH)&#xA;    {&#xA;    // held for too long? turn off LED, remember it &#xA;    if (millis () - whenPushed &amp;gt;= MAX_PUSH_TIME)&#xA;      {&#xA;      awaitingRelease = true;&#xA;      digitalWrite(ledPin, LOW); &#xA;      }  &#xA;    return;  // all done&#xA;    }&#xA;&#xA;  // turn LED on, remember when    &#xA;  digitalWrite(ledPin, HIGH); &#xA;  whenPushed = millis (); &#xA;  delay (DEBOUNCE_TIME);&#xA;  }  // end of switchPushed&#xA;&#xA;void switchReleased ()&#xA;  {&#xA;  digitalWrite(ledPin, LOW); &#xA;  awaitingRelease = false;  // they released it! &#xA;  delay (DEBOUNCE_TIME);&#xA;  }  // end of switchReleased&#xA;&#xA;void loop()&#xA;  {&#xA;  switchState = digitalRead(inPin);&#xA;  if (switchState == LOW) &#xA;    switchPushed ();&#xA;  else&#xA;    switchReleased ();&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I used an input pull-up resistor on the switch to avoid having to use extra components. Thus the switch is wired between pin 7 and &lt;strong&gt;ground&lt;/strong&gt;. That is why the test for the switch being pressed is for it to be LOW.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;Switches tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-15T22:34:08.153" LastActivityDate="2015-08-15T22:34:08.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14229" PostTypeId="2" ParentId="14215" CreationDate="2015-08-15T23:00:39.133" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;there should be two pins for every node one acting as the negative terminal and other as the positive terminal. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, there is one pin per node, and a &lt;strong&gt;common&lt;/strong&gt; &quot;Ground&quot; pin which is the negative terminal. On your Mega2560 are 5 ground pins (effectively equivalent because they are connected). They are circled on the photo below, and marked &lt;strong&gt;GND&lt;/strong&gt; on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EWFnD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EWFnD.jpg&quot; alt=&quot;Mega2560 board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Majenko says in his answer you must use a resistor in series with any LED you connect, or you will damage both the LED and the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find a &quot;breadboard&quot; handy for making connections, most prototyping boards have a long connected strip for sharing the Ground wire between different places, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ArXKq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ArXKq.jpg&quot; alt=&quot;Prototyping board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The continuous blue lines indicate pins which are connected together (for Ground) and the continuous red lines are connected together for +5 V (usually).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Btw can you tell me why there are two pins on the bottom horizontal row? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just for convenience. You often want an extra ground pin, for example if you are trying to connect up two LEDs.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Secondly, yes each pin can be set as input or output but is there any specific difference in the type of pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some of the pins can optionally be used for extra hardware-supported features.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PWM: Pulse-width-modulated output&lt;/li&gt;&#xA;&lt;li&gt;COMMUNICATION: Serial input/output (4 serial ports)&lt;/li&gt;&#xA;&lt;li&gt;ANALOG IN: Analog-to-digital converter (ADC) input&lt;/li&gt;&#xA;&lt;li&gt;DIGITAL: Digital (not analog) input/output&lt;/li&gt;&#xA;&lt;li&gt;SDA/SCL: I2C communications&lt;/li&gt;&#xA;&lt;li&gt;Pins 50-53: SPI communications (not marked on the board)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However &lt;strong&gt;all&lt;/strong&gt; pins, as you noted, can - if you wish - be used for digital input or output.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-16T04:48:28.477" LastActivityDate="2015-08-16T04:48:28.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14230" PostTypeId="1" CreationDate="2015-08-16T00:19:54.007" Score="1" ViewCount="67" Body="&lt;p&gt;I installed the Arduino IDE 1.6.4, and used the &quot;boards manager&quot; to install the package for Arduino Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using c++11 in my project so i need to add the &lt;code&gt;compiler.cpp.extra_flags=-std=gnu++11&lt;/code&gt; like i did in the &lt;code&gt;/Applications/Arduino.app/Contents/Java/hardware/arduino/platform.txt&lt;/code&gt; file (i am on MacOSX).&#xA;It seems that arduino is ignoring that file and using a configuration coming from somewhere else. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where is the downloaded package installed? Can it be configured?&lt;/p&gt;&#xA;" OwnerUserId="11834" LastActivityDate="2015-08-17T15:17:07.097" Title="arduino boards manager configuration" Tags="|c++|arduino-due|compile|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14231" PostTypeId="2" ParentId="14223" CreationDate="2015-08-16T00:46:12.833" Score="0" Body="&lt;p&gt;At no point in your program are you telling it where to connect to.  You are requesting service &quot;7&quot;, which of course is resolved to port number 7, but you aren't giving it an IP address or host name to connect to.  Ergo, it is trying to connect to port 7 of the same computer that the program is running on - which will fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to specify the IP address of the WiFi shield as the first parameter to &lt;code&gt;getaddrinfo()&lt;/code&gt; (currently &lt;code&gt;NULL&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);&lt;/code&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;code&gt;node&lt;/code&gt; specifies either a numerical network address (for IPv4, numbers-and-dots notation as supported by &lt;code&gt;inet_aton(3)&lt;/code&gt;; for IPv6, hexadecimal  string format  as  supported  by  &lt;code&gt;inet_pton(3)&lt;/code&gt;),  or  a network hostname, whose network addresses are looked up and resolved.  If &lt;code&gt;hints.ai_flags&lt;/code&gt; contains the &lt;code&gt;AI_NUMERICHOST&lt;/code&gt; flag, then node must be a numerical network address.  The  &lt;code&gt;AI_NUMERICHOST&lt;/code&gt;  flag suppresses any potentially lengthy network host address lookups.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If the &lt;code&gt;AI_PASSIVE&lt;/code&gt; flag is not set in &lt;code&gt;hints.ai_flags&lt;/code&gt;, then the returned socket addresses will be suitable for use with &lt;code&gt;connect(2)&lt;/code&gt;, &lt;code&gt;sendto(2)&lt;/code&gt;, or &lt;code&gt;sendmsg(2)&lt;/code&gt;.  &lt;strong&gt;If node is &lt;code&gt;NULL&lt;/code&gt;, then the network address  will  be  set  to  the  loopback  interface address&lt;/strong&gt;  (&lt;code&gt;INADDR_LOOPBACK&lt;/code&gt;  for  IPv4 addresses, &lt;code&gt;IN6ADDR_LOOPBACK_INIT&lt;/code&gt; for IPv6 address); this is used by applications that intend to communicate with peers running on the same host.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-- Extract from the &lt;code&gt;getaddrinfo(3)&lt;/code&gt; manual page&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-16T00:46:12.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14232" PostTypeId="2" ParentId="14222" CreationDate="2015-08-16T01:02:04.907" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So if any of you have worked on something like this before and you have a recommendation, it would be greatly appreciated.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12821&quot; rel=&quot;nofollow&quot;&gt;Solar powered Arduino&lt;/a&gt; - I used a standalone Atmega328P on a prototyping board for that. That used the NRF24L01 to send information (the current voltage in this case) to another Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For small and simple you could get an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano&lt;/a&gt; or &lt;a href=&quot;http://www.adafruit.com/products/2378&quot; rel=&quot;nofollow&quot;&gt;Arduino Pro Mini&lt;/a&gt;. The Pro Mini is around $US10, and is quite small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have the same processor (Atmega328P) so you can connect your I2C sensor to it, and the NRF24L01 as well.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have never soldered before ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think you will have to do a little soldering, to connect up the sensor, and the transmitter, but soldering on connecting wires isn't too onerous.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-16T01:02:04.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14233" PostTypeId="2" ParentId="14149" CreationDate="2015-08-16T01:18:06.653" Score="1" Body="&#xA;&#xA;&lt;p&gt;I find your onRequest function obscure:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void sendPI(){&#xA;     int values[] = {(int)out, (int)outReversed  };&#xA;&#xA;     Wire.write(values[count]);&#xA;     count++;&#xA;     if(count &amp;gt; 1){&#xA;     count = 0;&#xA;&#xA;     }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why only send one byte? I think you have a number of problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The size of &lt;code&gt;int&lt;/code&gt; on the Arduino Uno is 2 bytes, on a Pi it is 4 bytes. So there is a mismatch there for a start.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;Wire.write&lt;/code&gt; (written like that) sends one byte, so that is only going to be half of your &lt;code&gt;int&lt;/code&gt;. So that is even less. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It isn't obvious what the Pi end is doing, but to make the &lt;code&gt;int&lt;/code&gt; sizes match, I would be sending the lot in one hit like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void sendPI(){&#xA;     long values[] = {(int)out, (int)outReversed  };&#xA;     Wire.write((byte *) &amp;amp;values, sizeof values);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you just read 8 bytes on the Pi (two ints).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-16T01:18:06.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14234" PostTypeId="2" ParentId="14219" CreationDate="2015-08-16T04:54:18.590" Score="0" Body="&lt;p&gt;You might look into building a circuit, on a breadboard, from basic components. Think Atmel, AtMega instead of Arduino. Depending on your experience and willingness to read datasheets, this might be easier than you imagine. After you have a large-scale working prototype, find miniature surface-mount versions of all of the components. Designing an actual circuit board to connect these things might be the real trick, but if you can get it done then you can have the board made. I believe, am uncertain about this, that there are software tools available that help turn schematics into circuit board designs. This part might be expensive. Getting to the point of having a large-scale working prototype, on the other hand, would be inexpensive and fun. Once you have a board designed you'll have to get it made. Testing this prototype might be difficult and perhaps expensive as well. (Engineers are paid well because they tend to know before construction if a design will work.) If you come up with something that works then selling the extras might pay for having it made.&lt;/p&gt;&#xA;" OwnerUserId="11837" LastActivityDate="2015-08-16T04:54:18.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14235" PostTypeId="2" ParentId="14162" CreationDate="2015-08-16T05:11:46.070" Score="2" Body="&lt;p&gt;Let me try to help. This isn't a definitive &quot;answer&quot; but I need to post screenshots etc., so I am making it an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried your code with my Arduino Micro. I believe it is the same as the Leonardo except for a byte difference in the bootloader identification (for the USB device).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First the &lt;s&gt;good&lt;/s&gt; bad news. It worked under Windows 7. And let me tell you something: It is incredibly annoying to try to use the Windows 7 device manager when something is typing a key every two seconds! I recompiled it to type a key every minute to save my sanity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't usually use Windows 7 (I use Ubuntu normally) so the device driver was not installed. It offered to install it, I told it to skip going to Windows Update, and it installed it thus:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UaMY1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UaMY1.png&quot; alt=&quot;USB installation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I did &lt;strong&gt;not&lt;/strong&gt; use the device drivers (if any) supplied with the Arduino installation. I never got asked that question.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Locating the device in the Device Manager I see I got Windows drivers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GdZZS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GdZZS.png&quot; alt=&quot;Driver names&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It showed up under Human Interface Devices as a USB Input Device:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fDf0Q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fDf0Q.png&quot; alt=&quot;USB input device&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;These were the hardware IDs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RTyBp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RTyBp.png&quot; alt=&quot;Hardware IDs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It also showed up as a Composite Device:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0j2jH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0j2jH.png&quot; alt=&quot;USB composite device&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This was the report from the program you linked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    =========================== USB Port1 ===========================&#xA;&#xA;Connection Status        : 0x01 (Device is connected)&#xA;Port Chain               : 1-1-3-1&#xA;&#xA;      ======================== USB Device ========================&#xA;&#xA;        +++++++++++++++++ Device Information ++++++++++++++++++&#xA;Device Description       : USB Composite Device&#xA;Device Path              : \\?\usb#vid_2341&amp;amp;pid_8037#7&amp;amp;171b751b&amp;amp;0&amp;amp;1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}&#xA;Device ID                : USB\VID_2341&amp;amp;PID_8037\7&amp;amp;171B751B&amp;amp;0&amp;amp;1&#xA;Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0026 (GUID_DEVCLASS_USB)&#xA;Driver                   : C:\Windows\system32\DRIVERS\usbccgp.sys (Version: 6.1.7601.18328  Date: 2013-11-27)&#xA;Driver Inf               : C:\Windows\inf\usb.inf&#xA;Legacy BusType           : PNPBus&#xA;Class                    : USB&#xA;Service                  : usbccgp&#xA;Enumerator               : USB&#xA;Location Info            : Port_#0001.Hub_#0005&#xA;Location IDs             : PCIROOT(0)#PCI(1D00)#USBROOT(0)#USB(1)#USB(3)#USB(1)&#xA;Container ID             : {821d8eeb-43cd-11e5-b4e1-10c37b50593b}&#xA;Manufacturer Info        : (Standard USB Host Controller)&#xA;Capabilities             : 0x84 (Removable, SurpriseRemovalOK)&#xA;Address                  : 1&#xA;Problem Code             : 0&#xA;Power State              : D0 (supported: D0, D2, D3, wake from D0, wake from D2)&#xA; Child Device 1          : Arduino Micro&#xA;  Device ID              : USB\VID_2341&amp;amp;PID_8037&amp;amp;MI_00\8&amp;amp;6467A9E&amp;amp;0&amp;amp;0000&#xA;  Class                  : Ports&#xA;  COM-Port               : COM8 (\Device\USBSER000)&#xA; Child Device 2          : USB Input Device&#xA;  Device ID              : USB\VID_2341&amp;amp;PID_8037&amp;amp;MI_02\8&amp;amp;6467A9E&amp;amp;0&amp;amp;0002&#xA;  Class                  : HIDClass&#xA;   Child Device 1        : HID-compliant mouse&#xA;    Device ID            : HID\VID_2341&amp;amp;PID_8037&amp;amp;MI_02&amp;amp;COL01\9&amp;amp;F900E83&amp;amp;0&amp;amp;0000&#xA;    Class                : Mouse&#xA;   Child Device 2        : HID Keyboard Device&#xA;    Device ID            : HID\VID_2341&amp;amp;PID_8037&amp;amp;MI_02&amp;amp;COL02\9&amp;amp;F900E83&amp;amp;0&amp;amp;0001&#xA;    Class                : Keyboard&#xA;&#xA;        ---------------- Connection Information ---------------&#xA;Connection Index         : 0x01 (1)&#xA;Connection Status        : 0x01 (DeviceConnected)&#xA;Current Config Value     : 0x01&#xA;Device Address           : 0x08 (8)&#xA;Is Hub                   : 0x00 (no)&#xA;Number Of Open Pipes     : 0x04 (4)&#xA;Device Bus Speed         : 0x01 (Full-Speed)&#xA;Pipe0ScheduleOffset      : 0x01 (1)&#xA;Pipe1ScheduleOffset      : 0x00 (0)&#xA;Pipe2ScheduleOffset      : 0x00 (0)&#xA;Pipe3ScheduleOffset      : 0x00 (0)&#xA;&#xA;        ------------------ Device Descriptor ------------------&#xA;bLength                  : 0x12 (18 bytes)&#xA;bDescriptorType          : 0x01 (Device Descriptor)&#xA;bcdUSB                   : 0x200 (USB Version 2.00)&#xA;bDeviceClass             : 0x00 (defined by the interface descriptors)&#xA;bDeviceSubClass          : 0x00&#xA;bDeviceProtocol          : 0x00&#xA;bMaxPacketSize0          : 0x40 (64 bytes)&#xA;idVendor                 : 0x2341&#xA;idProduct                : 0x8037&#xA;bcdDevice                : 0x100&#xA;iManufacturer            : 0x01 (String Descriptor 1)&#xA; Language 0x0409         : &quot;Arduino LLC&quot;&#xA;iProduct                 : 0x02 (String Descriptor 2)&#xA; Language 0x0409         : &quot;Arduino Micro&quot;&#xA;iSerialNumber            : 0x00 (No String Descriptor)&#xA;bNumConfigurations       : 0x01&#xA;&#xA;        ------------------ String Descriptors -----------------&#xA;             ------ String Descriptor 0 ------&#xA;bLength                  : 0x04 (4 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language ID[0]           : 0x0409 (English - United States)&#xA;             ------ String Descriptor 1 ------&#xA;bLength                  : 0x18 (24 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language 0x0409          : &quot;Arduino LLC&quot;&#xA;             ------ String Descriptor 2 ------&#xA;bLength                  : 0x1C (28 bytes)&#xA;bDescriptorType          : 0x03 (String Descriptor)&#xA;Language 0x0409          : &quot;Arduino Micro&quot;&#xA;&#xA;        -------------- Configuration Descriptor ---------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x02 (Configuration Descriptor)&#xA;wTotalLength             : 0x0064 (100 bytes)&#xA;bNumInterfaces           : 0x03&#xA;bConfigurationValue      : 0x01&#xA;iConfiguration           : 0x00 (No String Descriptor)&#xA;bmAttributes             : 0x80&#xA; D7: Reserved, set 1     : 0x01&#xA; D6: Self Powered        : 0x00 (no)&#xA; D5: Remote Wakeup       : 0x00 (no)&#xA; D4..0: Reserved, set 0  : 0x00&#xA;MaxPower                 : 0xFA (500 mA)&#xA;&#xA;        ------------------- IAD Descriptor --------------------&#xA;bLength                  : 0x08 (8 bytes)&#xA;bDescriptorType          : 0x0B&#xA;bFirstInterface          : 0x00&#xA;bInterfaceCount          : 0x02&#xA;bFunctionClass           : 0x02 (Communications and CDC Control)&#xA;bFunctionSubClass        : 0x02&#xA;bFunctionProtocol        : 0x01&#xA;iFunction                : 0x00 (No String Descriptor)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x00&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x01 (1 Endpoint)&#xA;bInterfaceClass          : 0x02 (Communications and CDC Control)&#xA;bInterfaceSubClass       : 0x02&#xA;bInterfaceProtocol       : 0x00&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x00 (Header Functional Descriptor)&#xA;bcdCDC                   : 0x110 (CDC Version 1.10)&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)&#xA;bmCapabilities           : 0x01&#xA;bDataInterface           : 0x01&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x04 (4 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)&#xA;bmCapabilities           : 0x06&#xA;&#xA;        -------------- CDC Interface Descriptor ---------------&#xA;bFunctionLength          : 0x05 (5 bytes)&#xA;bDescriptorType          : 0x24 (Interface)&#xA;bDescriptorSubType       : 0x06 (Union Functional Descriptor)&#xA;bControlInterface        : 0x00&#xA;bSubordinateInterface[0] : 0x01&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x81 (Direction=IN  EndpointID=1)&#xA;bmAttributes             : 0x03 (TransferType=Interrupt)&#xA;wMaxPacketSize           : 0x0010 (16 bytes) (16 bytes)&#xA;bInterval                : 0x40 (64 ms)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x01&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x02 (2 Endpoints)&#xA;bInterfaceClass          : 0x0A (CDC-Data)&#xA;bInterfaceSubClass       : 0x00&#xA;bInterfaceProtocol       : 0x00&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x02 (Direction=OUT  EndpointID=2)&#xA;bmAttributes             : 0x02 (TransferType=Bulk)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x00 (ignored)&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x83 (Direction=IN  EndpointID=3)&#xA;bmAttributes             : 0x02 (TransferType=Bulk)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x00 (ignored)&#xA;&#xA;        ---------------- Interface Descriptor -----------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x04 (Interface Descriptor)&#xA;bInterfaceNumber         : 0x02&#xA;bAlternateSetting        : 0x00&#xA;bNumEndpoints            : 0x01 (1 Endpoint)&#xA;bInterfaceClass          : 0x03 (HID - Human Interface Device)&#xA;bInterfaceSubClass       : 0x00 (None)&#xA;bInterfaceProtocol       : 0x00 (None)&#xA;iInterface               : 0x00 (No String Descriptor)&#xA;&#xA;        ------------------- HID Descriptor --------------------&#xA;bLength                  : 0x09 (9 bytes)&#xA;bDescriptorType          : 0x21 (HID Descriptor)&#xA;bcdHID                   : 0x0101 (HID Version 1.01)&#xA;bCountryCode             : 0x00 (00 = not localized)&#xA;bNumDescriptors          : 0x01&#xA;Descriptor 1:&#xA;bDescriptorType          : 0x22 (Class=Report)&#xA;wDescriptorLength        : 0x0065 (101 bytes)&#xA;  05 01             Usage Page (Generic Desktop Controls)&#xA;  09 02             Usage (Mouse)&#xA;  A1 01             Collection (Application)&#xA;  09 01               Usage (Pointer)&#xA;  A1 00               Collection (Physical)&#xA;  85 01                 Report ID (0x01)&#xA;  05 09                 Usage Page (Buttons)&#xA;  19 01                 Usage Minimum (1)&#xA;  29 03                 Usage Maximum (3)&#xA;  15 00                 Logical Minimum (0)&#xA;  25 01                 Logical Maximum (1)&#xA;  95 03                 Report Count (3)&#xA;  75 01                 Report Size (1)&#xA;  81 02                 Input (Var)&#xA;  95 01                 Report Count (1)&#xA;  75 05                 Report Size (5)&#xA;  81 03                 Input (Const, Var)&#xA;  05 01                 Usage Page (Generic Desktop Controls)&#xA;  09 30                 Usage (Direction-X)&#xA;  09 31                 Usage (Direction-Y)&#xA;  09 38                 Usage (Wheel)&#xA;  15 81                 Logical Minimum (-127)&#xA;  25 7F                 Logical Maximum (127)&#xA;  75 08                 Report Size (8)&#xA;  95 03                 Report Count (3)&#xA;  81 06                 Input (Var, Rel)&#xA;  C0                  End Collection&#xA;  C0                End Collection&#xA;  05 01             Usage Page (Generic Desktop Controls)&#xA;  09 06             Usage (Keyboard)&#xA;  A1 01             Collection (Application)&#xA;  85 02               Report ID (0x02)&#xA;  05 07               Usage Page (Keyboard)&#xA;  19 E0               Usage Minimum (-32)&#xA;  29 E7               Usage Maximum (-25)&#xA;  15 00               Logical Minimum (0)&#xA;  25 01               Logical Maximum (1)&#xA;  75 01               Report Size (1)&#xA;  95 08               Report Count (8)&#xA;  81 02               Input (Var)&#xA;  95 01               Report Count (1)&#xA;  75 08               Report Size (8)&#xA;  81 03               Input (Const, Var)&#xA;  95 06               Report Count (6)&#xA;  75 08               Report Size (8)&#xA;  15 00               Logical Minimum (0)&#xA;  25 65               Logical Maximum (101)&#xA;  05 07               Usage Page (Keyboard)&#xA;  19 00               Usage Minimum (0)&#xA;  29 65               Usage Maximum (101)&#xA;  81 00               Input ()&#xA;  C0                End Collection&#xA;&#xA;        ----------------- Endpoint Descriptor -----------------&#xA;bLength                  : 0x07 (7 bytes)&#xA;bDescriptorType          : 0x05 (Endpoint Descriptor)&#xA;bEndpointAddress         : 0x84 (Direction=IN  EndpointID=4)&#xA;bmAttributes             : 0x03 (TransferType=Interrupt)&#xA;wMaxPacketSize           : 0x0040 (64 bytes) (64 bytes)&#xA;bInterval                : 0x01 (1 ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hopefully you can compare this to your situation and see what is different.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried today on my son's Windows 7 PC, which I don't think had Arduino ever installed on it. Also I used my Leonardo instead of the Micro, just to be sure. First Windows tried to install the device drivers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yQnhu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yQnhu.png&quot; alt=&quot;Leonard device driver install&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Then it only succeeded with the composite device and the keyboard:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4gC41.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4gC41.png&quot; alt=&quot;Leonard device driver install - keyboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However the keyboard worked (eg. in Notepad).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wc8xs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wc8xs.png&quot; alt=&quot;Input device description&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It shows up in the Device Manager:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A9kfk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A9kfk.png&quot; alt=&quot;Peripheral ID&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-16T22:14:09.873" LastActivityDate="2015-08-16T22:14:09.873" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14236" PostTypeId="2" ParentId="14217" CreationDate="2015-08-16T06:07:32.517" Score="0" Body="&#xA;&#xA;&lt;p&gt;Your &lt;strong&gt;third&lt;/strong&gt; delay is the issue. It means you have up to 10 ms before you notice the need to turn on the light. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte pin = 13; &#xA;volatile bool detected; &#xA;&#xA;void setup() { &#xA;  pinMode(pin, OUTPUT); &#xA;  attachInterrupt(1, blink, RISING); &#xA;} &#xA;&#xA;void loop() { &#xA;  if (detected)&#xA;    {&#xA;    delay(10);&#xA;    digitalWrite(pin, LOW);&#xA;    detected = false;&#xA;    }&#xA;&#xA;} &#xA;&#xA;void blink() { &#xA;  digitalWrite(pin, HIGH);&#xA;  detected = true; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now that immediately turns on the LED, so it will always happen at the same time. Then in the main loop you notice it is on, wait 10 ms, and then turn it off.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-16T06:07:32.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14237" PostTypeId="2" ParentId="14088" CreationDate="2015-08-16T07:11:38.800" Score="0" Body="&lt;p&gt;Poor workaround: since I was trying to solve a connection hang, I opted to use a &lt;a href=&quot;https://tushev.org/articles/arduino/5/arduino-and-watchdog-timer&quot; rel=&quot;nofollow&quot;&gt;watchdog timer&lt;/a&gt; solution, leveraging the lightly documented &lt;code&gt;&amp;lt;avr/wdt.h&amp;gt;&lt;/code&gt; library.&lt;/p&gt;&#xA;" OwnerUserId="11505" LastActivityDate="2015-08-16T07:11:38.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14238" PostTypeId="1" AcceptedAnswerId="14239" CreationDate="2015-08-16T08:34:22.983" Score="0" ViewCount="355" Body="&lt;p&gt;I tried to flash my ATmega328P-PU not over the Arduino but over a self-made programming board and an USBasp. The problem is, I made the board a while ago and didn't mark which direction the 10-pin connector has to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, can I fry the ATmega if I connect the 10-pin connector the wrong way around? Also, can this harm the USBasp in any way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting it the wrong way around would give me the following connections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USBasp  ---  ATmega&#xA;&#xA;MOSI    -|&#xA;NC      -|-  GND&#xA;RST     -|&#xA;SCK     -|&#xA;&#xA;MISO    ---  Vcc&#xA;Vcc     ---  MISO&#xA;&#xA;         |-  MOSI&#xA;GND     -|-  NC&#xA;         |-  RST&#xA;         |-  SCK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11571" LastEditorUserId="11571" LastEditDate="2015-08-16T08:39:46.663" LastActivityDate="2015-08-16T10:03:28.630" Title="ISP - Wrong direction frying ATmega" Tags="|isp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14239" PostTypeId="2" ParentId="14238" CreationDate="2015-08-16T10:03:28.630" Score="3" Body="&lt;p&gt;No, connecting it backwards shouldn't do any damage, it just won't work.  The clue is in these two connections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NC      -|-  GND&#xA;GND     -|-  NC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With it backwards the ground connection doesn't go anywhere.  Without that ground connection there's no circuit.  With no circuit, no current flows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible danger is to the protection diodes in the IO pins when you try and operate the programmer.  The lack of a ground connection could cause some current to flow the wrong way through the circuit (in through the ATMega's MISO pin and out through the MCU's Vcc pin) through the ESD protection diode.  That could cause damage to that diode and maybe the rest of the MISO pin's logic, but it's not that likely since the currents involved would be somewhat limited by the route the power then takes through the MISO pin of the programmer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-16T10:03:28.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14240" PostTypeId="1" CreationDate="2015-08-16T11:20:23.890" Score="0" ViewCount="960" Body="&lt;p&gt;Recently I've bought an Arduino Mega 2560 R3 and a Shield Model Wireless SD R3 from &lt;a href=&quot;http://www.amazon.de/Arduino-A000065-Netzwerkkarte-Wireless-SD-Shield/dp/B00L1FO860&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.de/Arduino-A000065-Netzwerkkarte-Wireless-SD-Shield/dp/B00L1FO860&lt;/a&gt;. I try to run the example from &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ConnectWithWPA&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ConnectWithWPA&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before running the sketch I turn the DIP switch to the position USB.&#xA;It seems like the WIfi Shield is correct connected to the Arduino since the LEDs TX and RX are blinking during upload the Sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly as output I got only:&#xA;    WiFi shield not present&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I'm not sure if the hardware itself provide Wifi functionality. Does somebody know if it should work with this hardware?&lt;/p&gt;&#xA;" OwnerUserId="11839" LastActivityDate="2015-09-15T12:54:11.237" Title="Arduino Mega 2560 R3 with Shield Model Wireless SD R3 not working" Tags="|arduino-mega|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14241" PostTypeId="2" ParentId="14240" CreationDate="2015-08-16T11:29:13.403" Score="1" Body="&lt;p&gt;You see that double row of 10 pin headers?  That's an XBee connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/pages/xbee_guide&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/pages/xbee_guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use it to connect your XBee module of choice (there's a few to choose from) to communicate wirelessly between Arduinos using the special XBee system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that XBee is not WiFi, it's Wireless.  The two are very different things (Wireless refers to any wire-free communication system, WiFi is one specific protocol on one specific set of frequencies using a specific set of encodings, etc).  XBee &lt;em&gt;cannot&lt;/em&gt; talk WiFi in the same way that I can't talk Chinese.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For WiFi you need a WiFi shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoWiFiShield&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-16T11:29:13.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14243" PostTypeId="1" AcceptedAnswerId="15976" CreationDate="2015-08-16T12:06:54.510" Score="0" ViewCount="5646" Body="&lt;p&gt;I would like to detect signals in nanosecond scale. For that, an ADC with at least 500 MSPS is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is if its possible to use an external ADC with 500 MSPS with a 16MHz Arduino Mega? If not, is there any additional hardware like FIFO buffer to overcome this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help, thanks!&lt;/p&gt;&#xA;" OwnerUserId="9999" LastActivityDate="2021-07-07T10:35:15.177" Title="Hi-speed external ADC" Tags="|arduino-mega|adc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14244" PostTypeId="2" ParentId="14243" CreationDate="2015-08-16T12:31:29.463" Score="3" Body="&lt;p&gt;No, it's certainly not possible to directly sample at 500Msps on an Arduino using an external ADC.  Simple maths:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino can perform 16 million instructions (best case) per second&lt;/li&gt;&#xA;&lt;li&gt;The ADC performs 500 million samples per second.&lt;/li&gt;&#xA;&lt;li&gt;500 / 16 = 31.25&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Therefore the ADC would be generating 31.25 samples for every clock of the Arduino, so unless you can build in a time compressor (maybe with a flux capacitor too), it just ain't gonna do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will have to think creatively instead.  A possible solution would involve:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A high speed &lt;em&gt;flash&lt;/em&gt; or &lt;em&gt;pipelined&lt;/em&gt; ADC, ideally with parallel output.&lt;/li&gt;&#xA;&lt;li&gt;A large chunk of memory to act as a buffer.&lt;/li&gt;&#xA;&lt;li&gt;A high speed clock source to set the timing (500MHz?).&lt;/li&gt;&#xA;&lt;li&gt;Glue logic and counters to take one sample, store it in the buffer, and increment the buffer address.&lt;/li&gt;&#xA;&lt;li&gt;More glue logic and interfacing to allow the Arduino access to the buffer memory and to control the operation of the sampling system.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This, to me, sounds like a job for an FPGA, and at 500MHz, quite a fast FPGA.  You should investigate some of the FPGA development boards from Xilinx and Altera.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-16T12:31:29.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14245" PostTypeId="1" AcceptedAnswerId="14249" CreationDate="2015-08-16T13:12:19.737" Score="0" ViewCount="275" Body="&lt;p&gt;I've got a MAX7456 chip and I am using &lt;a href=&quot;https://www.dropbox.com/s/3cp4am1f271odcm/max7456.tar?dl=1&quot; rel=&quot;nofollow&quot;&gt;this (this is the unmodified one)&lt;/a&gt; library with it. &#xA;There's a sketch inside the examples folder (Max7456WriteTable) that I need to get to work to update the character table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified three lines and then I got really stuck as I do not know how to continue. &lt;a href=&quot;https://www.dropbox.com/s/sljvyngc27zver4/max7456_new.tar?dl=1&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; is the modified one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from Max7456Write.ino:2:0:&#xA;/tmp/build4608284042510222737.tmp/sketch/Max7456WriteTable.h:29:69153: warning: narrowing conversion of '243' from 'int' to 'const char' inside { } is ill-formed in C++11 [-Wnarrowing]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens for every item in the array. But that is not the only problem. (I'll skip a few hundred lines)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/build8855411239666100148.tmp/sketch/Max7456Write.cpp.o: In function `setup':&#xA;/home/t/Max7456Write.ino:13: undefined reference to `Max7456::Max7456(unsigned char)'&#xA;/home/t/Max7456Write.ino:19: undefined reference to `Max7456::activateOSD(bool)'&#xA;/home/t/Max7456Write.ino:44: undefined reference to `Max7456::getCARACFromProgMem(char const*, unsigned char, unsigned char*)'&#xA;/home/t/Max7456Write.ino:46: undefined reference to `Max7456::sendCharacter(unsigned char const*, unsigned char, unsigned char)'&#xA;collect2: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes a huge amount of time for it to abort the compilation.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-17T09:29:26.907" LastActivityDate="2015-08-17T09:29:26.907" Title="Updating a sketch to work with IDE 1.6.6" Tags="|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14246" PostTypeId="2" ParentId="14172" CreationDate="2015-08-16T13:52:49.633" Score="2" Body="&lt;p&gt;To solve this problem one would need to get the builtin character updating sketch work (Max456WriteTable.cpp in examples folder). After the sketch has been compiled one would have to connect either FTDI cable or a USBASP programmer to the board and upload the sketch to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The character set (array) itself used in the code can be updated with the appropriate program available at &lt;a href=&quot;http://theboredengineers.com/2012/12/a-max7456-library-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;this site&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: In the end I solved it &lt;a href=&quot;https://arduino.stackexchange.com/questions/14739/character-updating-sketch-not-working&quot;&gt;this way&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks to Charlie Hanson &amp;amp; Nick Gammon.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-11-15T13:53:23.510" LastActivityDate="2015-11-15T13:53:23.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14248" PostTypeId="1" CreationDate="2015-08-16T14:41:18.823" Score="2" ViewCount="3863" Body="&lt;p&gt;I asked a previous question about esp8266 that made a lot of things clear for me that esp8266 is very powerful and can be independently used as the webserver now, I have used the following library(&lt;a href=&quot;https://github.com/sandeepmistry/esp8266-Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sandeepmistry/esp8266-Arduino&lt;/a&gt;) to achieve this thing as I found a tutorial(&lt;a href=&quot;https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code&lt;/a&gt;) to help me out.&#xA;Now this is the code that was in the tutorial and is working fine&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* DHTServer - ESP8266 Webserver with a DHT sensor as an input&#xA;&#xA;   Based on ESP8266Webserver, DHTexample, and BlinkWithoutDelay (thank you)&#xA;&#xA;   Version 1.0  5/3/2014  Version 1.0   Mike Barela for Adafruit Industries&#xA;*/&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;#include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;#define DHTTYPE DHT22&#xA;#define DHTPIN  2&#xA;&#xA;const char* ssid     = &quot;--MYRouterID&quot;;&#xA;const char* password = &quot;--MYRouterPassword&quot;;&#xA;&#xA;ESP8266WebServer server(80);&#xA;&#xA;// Initialize DHT sensor &#xA;// NOTE: For working with a faster than ATmega328p 16 MHz Arduino chip, like an ESP8266,&#xA;// you need to increase the threshold for cycle counts considered a 1 or 0.&#xA;// You can do this by passing a 3rd parameter for this threshold.  It's a bit&#xA;// of fiddling to find the right value, but in general the faster the CPU the&#xA;// higher the value.  The default for a 16mhz AVR is a value of 6.  For an&#xA;// Arduino Due that runs at 84mhz a value of 30 works.&#xA;// This is for the ESP8266 processor on ESP-01 &#xA;DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266&#xA;&#xA;float humidity, temp_f;  // Values read from sensor&#xA;String webString=&quot;&quot;;     // String to display&#xA;// Generally, you should use &quot;unsigned long&quot; for variables that hold time&#xA;unsigned long previousMillis = 0;        // will store last temp was read&#xA;const long interval = 2000;              // interval at which to read sensor&#xA;&#xA;void handle_root() {&#xA;  server.send(200, &quot;text/plain&quot;, &quot;Hello from the weather esp8266, read from /temp or /humidity&quot;);&#xA;  delay(100);&#xA;}&#xA;&#xA;void setup(void)&#xA;{&#xA;  // You can open the Arduino IDE Serial Monitor window to see what the code is doing&#xA;  Serial.begin(115200);  // Serial connection from ESP-01 via 3.3v console cable&#xA;  dht.begin();           // initialize temperature sensor&#xA;&#xA;  // Connect to WiFi network&#xA;  WiFi.begin(ssid, password);&#xA;  Serial.print(&quot;\n\r \n\rWorking to connect&quot;);&#xA;&#xA;  // Wait for connection&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;DHT Weather Reading Server&quot;);&#xA;  Serial.print(&quot;Connected to &quot;);&#xA;  Serial.println(ssid);&#xA;  Serial.print(&quot;IP address: &quot;);&#xA;  Serial.println(WiFi.localIP());&#xA;&#xA;  server.on(&quot;/&quot;, handle_root);&#xA;&#xA;  server.on(&quot;/temp&quot;, [](){  // if you add this subdirectory to your webserver call, you get text below :)&#xA;    gettemperature();       // read sensor&#xA;    webString=&quot;Temperature: &quot;+String((int)temp_f)+&quot; F&quot;;   // Arduino has a hard time with float to string&#xA;    server.send(200, &quot;text/plain&quot;, webString);            // send to someones browser when asked&#xA;  });&#xA;&#xA;  server.on(&quot;/humidity&quot;, [](){  // if you add this subdirectory to your webserver call, you get text below :)&#xA;    gettemperature();           // read sensor&#xA;    webString=&quot;Humidity: &quot;+String((int)humidity)+&quot;%&quot;;&#xA;    server.send(200, &quot;text/plain&quot;, webString);               // send to someones browser when asked&#xA;  });&#xA;&#xA;  server.begin();&#xA;  Serial.println(&quot;HTTP server started&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  server.handleClient();&#xA;} &#xA;&#xA;void gettemperature() {&#xA;  // Wait at least 2 seconds seconds between measurements.&#xA;  // if the difference between the current time and last time you read&#xA;  // the sensor is bigger than the interval you set, read the sensor&#xA;  // Works better than delay for things happening elsewhere also&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt;= interval) {&#xA;    // save the last time you read the sensor &#xA;    previousMillis = currentMillis;   &#xA;&#xA;    // Reading temperature for humidity takes about 250 milliseconds!&#xA;    // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)&#xA;    humidity = dht.readHumidity();          // Read humidity (percent)&#xA;    temp_f = dht.readTemperature(true);     // Read temperature as Fahrenheit&#xA;    // Check if any reads failed and exit early (to try again).&#xA;    if (isnan(humidity) || isnan(temp_f)) {&#xA;      Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;      return;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this is my modification of code(of esp8266) as I am willing to communicate it over serial with my arduino which will further send data to the esp8266 when it requests using the attached sensor to the batteries(I am making a solar related project).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its only a basic code but the problem is that it compiles and runs ok but I am only able to access the web page once and that is also only the root. The other links do not open up or when I try to even reload the web page root it stuck and browser says error timed out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void handle_root() {&#xA;  //server.send(208, &quot;text/plain&quot;, &quot;&amp;lt;h1&amp;gt;Hello from the weather esp8266, read from /temp or /humidity&amp;lt;/h1&amp;gt;&quot;);&#xA;  String sendx = &quot;&amp;lt;h1&amp;gt;This Page Shows the Basic Info&amp;lt;/h1&amp;gt;&quot;;&#xA;//  Serial.write(&quot;MP&quot;);&#xA;//  delay(20);&#xA;&#xA;//  while(Serial.available()&amp;gt;0)&#xA; // {&#xA;  //  rec = Serial.readString();&#xA;  //}&#xA;  rec = &quot;TESt&quot;;&#xA;  if(rec[0] == AllMain)&#xA;  {&#xA;     sendx += &quot;&amp;lt;h2&amp;gt;Running on Main Power Now&amp;lt;/h2&amp;gt;&quot;;&#xA;     sendx += &quot;&amp;lt;p&amp;gt;&quot; + rec + &quot;&amp;lt;/p&amp;gt;&quot;;&#xA;  }&#xA;  else if(rec[0] == HouseMain)&#xA;  {&#xA;    sendx += &quot;&amp;lt;h2&amp;gt;Home on Main Power&amp;lt;/h2&amp;gt;&quot;; &#xA;    sendx += &quot;&amp;lt;p&amp;gt;&quot; + rec + &quot;&amp;lt;/p&amp;gt;&quot;;&#xA;    sendx += &quot;&amp;lt;a href =\&quot;/thos\&quot;&amp;gt;Turn on Hospital Main&amp;lt;/a&amp;gt;&quot;;&#xA;  }&#xA;  else if(rec[0]==HospitalMain)&#xA;  {&#xA;    sendx += &quot;&amp;lt;h2&amp;gt;Hospital on Main Power&amp;lt;/h2&amp;gt;&quot;; &#xA;    sendx += &quot;&amp;lt;p&amp;gt;&quot; + rec + &quot;&amp;lt;/p&amp;gt;&quot;;&#xA;    sendx += &quot;&amp;lt;a href =\&quot;/thm\&quot;&amp;gt;Turn on House Main&amp;lt;/a&amp;gt;&quot;;&#xA;  }&#xA;  else&#xA;  {&#xA;    sendx += &quot;&amp;lt;p&amp;gt;&quot; + rec + &quot;&amp;lt;/p&amp;gt;&quot;;&#xA;    sendx += &quot;&amp;lt;h4&amp;gt;&amp;lt;a href =\&quot;/thm\&quot;&amp;gt;Turn on House Main&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&quot;;&#xA;    sendx += &quot;&amp;lt;h4&amp;gt;&amp;lt;a href =\&quot;/thos\&quot;&amp;gt;Turn on Hospital Main&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&quot;;&#xA;  }&#xA;// sendx +=  &quot;&amp;lt;a href =\&quot;&quot;+&quot;..&quot;+&quot;/temp\&quot;&amp;gt;Temp&amp;lt;/a&amp;gt;&quot;;&#xA;&#xA;&#xA;    server.send(200,&quot;text/html&quot;,sendx);&#xA;  delay(100);&#xA;}&#xA;void thm()&#xA;{&#xA; // if(Serial.available())&#xA;  {&#xA;//    Serial.println(&quot;thm&quot;);&#xA;    String sendx = &quot;signal sent... go back to previous page to verify&quot;;&#xA;  //  sendx += &quot;&amp;lt;a href=\&quot;javascript:history.back()\&quot;&amp;gt;Go Back&amp;lt;/a&amp;gt;&quot;;&#xA;    server.send(200,&quot;text/html&quot;,sendx);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;void thos()&#xA;{&#xA; // if(Serial.available())&#xA;  {&#xA;//    Serial.println(&quot;thos&quot;);&#xA;    String sendx = &quot;signal sent... go back to previous page to verify&quot;;&#xA; //   sendx += &quot;&amp;lt;a href=\&quot;javascript:history.back()\&quot;&amp;gt;Go Back&amp;lt;/a&amp;gt;&quot;;&#xA;    server.send(200,&quot;text/html&quot;,sendx);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;void setup(void)&#xA;{&#xA;  // You can open the Arduino IDE Serial Monitor window to see what the code is doing&#xA;  Serial.begin(115200);  // Serial connection from ESP-01 via 3.3v console cable&#xA;&#xA;  // Connect to WiFi network&#xA;  WiFi.begin(ssid, password);&#xA;  if(debug)&#xA;    Serial.print(&quot;\n\r \n\rWorking to connect&quot;);&#xA;&#xA;  // Wait for connection&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    if(debug)&#xA;      Serial.print(&quot;.&quot;);&#xA;  }&#xA;  if(debug)&#xA;  {&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.println(&quot;DHT Weather Reading Server&quot;);&#xA;    Serial.print(&quot;Connected to &quot;);&#xA;    Serial.println(ssid);&#xA;    Serial.print(&quot;IP address: &quot;);&#xA;    Serial.println(WiFi.localIP());&#xA;  }&#xA;  if (mdns.begin(&quot;esp8266&quot;, WiFi.localIP())) {&#xA;    Serial.println(&quot;MDNS responder started&quot;);&#xA;  }&#xA;&#xA;  server.on(&quot;/&quot;, handle_root);&#xA;&#xA; server.on(&quot;/thm&quot;, thm);&#xA; /*server.on(&quot;/thm&quot;, [](){  ===== I have tried this inline as well no luck ====&#xA;   Serial.println(&quot;thos&quot;);&#xA;    String sendx = &quot;signal sent... go back to previous page to verify&quot;;&#xA;    server.sendContent(sendx);&#xA; });*/&#xA;  server.on(&quot;/thos&quot;,thos);&#xA;&#xA;  server.begin();&#xA;  if(debug)&#xA;    Serial.println(&quot;HTTP server started&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;&#xA;  server.handleClient();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now please I would also appreciate your help for the commented portion of my code dealing with serial communication in function &lt;code&gt;handle_root&lt;/code&gt; but it would be more than enough if you can point out my misconception or error or point me in right direction&lt;/p&gt;&#xA;" OwnerUserId="11759" LastActivityDate="2015-08-16T14:41:18.823" Title="ESP8266 problem as Web server" Tags="|arduino-uno|arduino-ide|wifi|web-server|esp8266|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14249" PostTypeId="2" ParentId="14245" CreationDate="2015-08-16T15:10:16.657" Score="1" Body="&lt;p&gt;If I change &lt;code&gt;prog_uchar&lt;/code&gt; to &lt;code&gt;unsigned char&lt;/code&gt; in both max7456.h and max7456.cpp the hello world example sketch compiles. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Max7456WriteTable change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Max7456::getCARACFromProgMem(i,currentChar); //Because the table is too big for ram memory&#xA;&#xA;osd-&amp;gt;sendCharacter(currentChar,i); //We send currentChar at address i.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Max7456::getCARACFromProgMem(tableOfAllCharacters, i,currentChar); //Because the table is too big for ram memory&#xA;&#xA;osd-&amp;gt;sendCharacter(currentChar,i, 0); //We send currentChar at address i.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0&lt;/code&gt; is probably the wrong value, but at least it compiles.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-16T15:10:16.657" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14250" PostTypeId="1" CreationDate="2015-08-16T16:03:31.280" Score="2" ViewCount="1268" Body="&lt;p&gt;-edit-&lt;br&gt;&#xA;This is a simplified recreation of personal learning project I have ongoing.  My issue is in accessing data in flash, the path to which includes multiple layers of indirection.  When the data was in RAM I found accessing it easy and all worked as expected.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In flash I have created a struct mylist, aa in the example, containing a pointer to an char* array (item_list[ ])(in flash) pointing to char[ ] (in flash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem: (refer to example) Given a pointer to struct aa (pml) and an index into item_list[] (ndx), how to correctly retrieve the string from flash.  My example illustrates the only method I can find that works. It seems kludgy at best, in particular needing to twice read pointers from flash as well as calculating the array item offset.  Have I missed a proper cast or perhaps become confused about 32 vs 16 bit pointers? Or, as strange as it seems, is this the correct and/or best approach?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All help and constructive criticism will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;const char x[] PROGMEM = {&quot;Item x&quot;};&#xA;const char y[] PROGMEM = {&quot;Item y&quot;};&#xA;const char* const item_list[] PROGMEM = {x, y};&#xA;&#xA;struct mylist {&#xA;  uint8_t nitems;&#xA;  const char** const list;&#xA;};&#xA;const mylist aa PROGMEM = {2,(const char** const)item_list};&#xA;&#xA;const mylist* pml = &amp;amp;aa;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  char cbuf[11] = {&quot;__________&quot;};&#xA;&#xA;  // two line with declared intermediate pointer&#xA;  uint8_t ndx = 0;&#xA;  const char* pitem = (const char*)pgm_read_ptr_near(&amp;amp;pml-&amp;gt;list) + (ndx * sizeof(const char*));&#xA;  strcpy_P(cbuf, (const char*)pgm_read_ptr_near(pitem));&#xA;  Serial.print(&quot;item[0]: /&quot;);&#xA;  Serial.print(cbuf);&#xA;  Serial.println(&quot;/&quot;);&#xA;&#xA;  // one line without declared intermediate pointer&#xA;  ndx++;&#xA;  strcpy_P(cbuf, (const char*)pgm_read_ptr_near(pgm_read_ptr_near(&amp;amp;pml-&amp;gt;list)&#xA;                                                + (ndx * sizeof(const char*))));&#xA;  Serial.print(&quot;item[1]: /&quot;);&#xA;  Serial.print(cbuf);&#xA;  Serial.println(&quot;/&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;item[0]: /Item x/&#xA;item[1]: /Item y/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-edit-  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After many more hours trying many more variations, I feel the approach shown in the following example is workable for me. I have chosen to keep the extra level of indirection to maintain all the flash data for a particular Field in one struct ‘package’. @NickGammon and his excellent examples greatly helped my understanding and comfort level with pointers in and to flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The listing is meant to give context to my point in question and is summarized in the method _copyitem( ) (hope the underscore is ok):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Field::_copyitem(uint8_t ndx){&#xA;  PGM_VOID_P plist = pgm_read_ptr(&amp;amp;_fp-&amp;gt;list);&#xA;  PGM_P pitem = (PGM_P)pgm_read_ptr(plist + ndx * sizeof(char*));&#xA;  strlcpy_P(_value, pitem, getLength());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This listing recreates a very small subset of the overall codebase, but the one part that has stopped my progress. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;struct FieldDefinition {&#xA;  uint8_t nitems;&#xA;  const char** list;&#xA;  uint8_t row;&#xA;  uint8_t column;&#xA;  uint8_t length;&#xA;  // etc, etc&#xA;};&#xA;&#xA;class Field {&#xA;public:&#xA;  Field(const FieldDefinition*  /* other parameters */);&#xA;  ~Field();  // -edit-&#xA;  char * selectItem(uint8_t);&#xA;  uint8_t getLength();&#xA;  char * selectItem(uint8_t);&#xA;  uint8_t getLength();&#xA;private:&#xA;  const FieldDefinition * _fp;&#xA;  char * _value;&#xA;  uint8_t _ndx;&#xA;  void _copyitem(uint8_t);&#xA;};&#xA;&#xA;Field::Field(const FieldDefinition* fp ) : _fp(fp) {&#xA;  _ndx = 0;&#xA;  char * _value = new char[getLength()];&#xA; _copyitem(_ndx);&#xA;};&#xA;Field::~Field(){  // -edit-&#xA;  delete _value;&#xA;};&#xA;char * Field::selectItem(uint8_t ndx){&#xA;  _ndx = ndx;&#xA;  _copyitem(_ndx);&#xA;  // display item&#xA;  // do more here . . .&#xA; return _value;&#xA;}&#xA;uint8_t Field::getLength(){&#xA;  return pgm_read_byte(&amp;amp;_fp-&amp;gt;length);&#xA;}&#xA;void Field::_copyitem(uint8_t ndx){&#xA;  PGM_VOID_P plist = pgm_read_ptr(&amp;amp;_fp-&amp;gt;list);&#xA;  PGM_P pitem = (PGM_P)pgm_read_ptr(plist + ndx * sizeof(char*));&#xA;  strlcpy_P(_value, pitem, getLength());&#xA;}&#xA;&#xA;// Setup flash data&#xA;// selection list&#xA;const char f1_0[] PROGMEM = {&quot;Item 0&quot;};&#xA;const char f1_1[] PROGMEM = {&quot;Item 1&quot;};&#xA;const char f1_2[] PROGMEM = {&quot;Item 2&quot;};&#xA;const char* const f1_list[] PROGMEM = {f1_0, f1_1, f1_2};&#xA;// create in-flash struct&#xA;const FieldDefinition f1 PROGMEM = {4,(const char**)f1_list,1,1,10};&#xA;// global instance and pointer to Field&#xA;Field * s1f1 = new Field(&amp;amp;f1);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println();&#xA;&#xA;  Serial.println();&#xA;  Serial.print(&quot;Field Length: &quot;);&#xA;  Serial.println(s1f1-&amp;gt;getLength());&#xA;  Serial.println();&#xA;  for (uint8_t i = 0 ; i &amp;lt; 3; i++) {&#xA;    Serial.print(&quot;Selection at index &quot;);&#xA;    Serial.print(i); Serial.print(&quot; : &quot;);&#xA;    Serial.println(s1f1-&amp;gt;selectItem(i));&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Field Length: 10&#xA;&#xA;Selection at index 0 : Item 0&#xA;Selection at index 1 : Item 1&#xA;Selection at index 2 : Item 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could very wrong (as previously demonstrated) so comments please.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;-edit-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point taken and completely understood.  Destructor added for completeness.  In my actual application, multiple fields are constructed by a screen class when a screen is displayed, user interaction accepted, configuration data stored in EEPROM (my next endeavor), then destroyed on screen exit. Selecting from a list is one method available to populate the field value. The whole interface consists of multiple fields, for multiple screens, driven by an underlying state engine, stepped during each ‘loop’ to minimize impact. It functions as expected in an Xcode simulation, and has been a wonderful learning experience moving it to Arduino.  I thought all this was non sequitur to my question and regret any confusion I may have caused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To restate my issue: how to get from  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ram based&#xA;strcpy(value, _fp-&amp;gt;list[ndx]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// flash based&#xA;PGM_VOID_P plist = pgm_read_ptr(&amp;amp;_fp-&amp;gt;list);&#xA;PGM_P pitem = (PGM_P)pgm_read_ptr(plist + ndx * sizeof(char*));&#xA;strcpy_P(value, pitem);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using best/correct form with multiple layers of indirection as posted. Is it possible I have missed a proper cast or other mechanism that would allow the compiler to handle the ‘pointer magic’? It appears I have not. @NickGammon I greatly appreciate your input.&lt;/p&gt;&#xA;" OwnerUserId="11838" LastEditorUserId="11838" LastEditDate="2015-08-18T22:25:20.790" LastActivityDate="2015-12-17T05:26:08.460" Title="Better method for PROGMEM data access with multiple indirection?" Tags="|flash|progmem|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14251" PostTypeId="2" ParentId="13885" CreationDate="2015-08-16T17:50:08.133" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use 37.9 or 38 kHz IR-receivers for 37.8 khz communication?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes you can, it should be close enough. (I am assuming you are talking about some kind of prebuilt receiver that just receives the IR data and transmits it via RS232 or something like that)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'd suggest you'd use a phototransistor and a IR diode for the communication. You will have a lot more control over what frequencies you are operating on. Altho it might take a bit more work to program it, the end result will be exactly how you wish.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-16T18:07:30.277" LastActivityDate="2015-08-16T18:07:30.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14253" PostTypeId="1" AcceptedAnswerId="14262" CreationDate="2015-08-16T18:47:19.663" Score="0" ViewCount="391" Body="&lt;p&gt;I installed LininoIO (OS dated 02 06 2015).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to work fine - but nothing works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a running Linux - but when I try to use GPIO, as described on Lilino.org -&lt;a href=&quot;http://wiki.linino.org/doku.php?id=wiki:lininoio_sysfs&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPIO on lininoIO&lt;/a&gt;, I run into the first problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D13 doesn't exist (this should be the little red LED on board of the Yún).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next I tested reading the analog inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can for example use &lt;code&gt;cat /sys/bus/iio/devices/iio:device0/in_voltage_A0_raw&lt;/code&gt;. There are no errors, but I always get the value &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking with &lt;code&gt;/etc/linino/test_avrdude.sh&lt;/code&gt; shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Testing AVRDUDE on ATMEL 32U4 ...&#xA;&#xA;avrdude: Version 6.1-20140519, compiled on Jun  2 2015 at 12:34:59&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2014 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/root/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : unknown&#xA;         Using Programmer              : linuxgpio&#xA;Can't export GPIO 11, already exported/busy?: Device or resource busy&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe this is &quot;by design&quot; or another sign of an error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way - when I start a serial console I get the message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-uart: switched to uart mode: mcuio&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further in kernel log I found:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[   42.480000] fuse init (API version 7.18)&#xA;[   42.620000] spi_tty_plain spi1.0: spi_tty_probe&#xA;[   45.380000] No need to change console settings&#xA;[   49.550000] mcuio-hc 0:0.0: unexpected reply&#xA;[   49.600000] gpiochip_add: registered GPIOs 100 to 139 on device: generic&#xA;[   49.630000] mcuio adc is 0:1:1&#xA;[   49.750000] mcuio-adc 0:1.1: 6 input channels detected&#xA;[   49.910000] mcuio-hc 0:0.0: unexpected reply&#xA;[   49.970000] mcuio pwm is 0:1:2&#xA;[   49.970000] mcuio-pwm 0:1.2: 6 pwm outputs detected&#xA;[   55.790000] busybox: sending ioctl 5310 to a partition!&#xA;[   55.800000] busybox: sending ioctl 5310 to a partition!&#xA;[   55.820000] busybox: sending ioctl 5310 to a partition!&#xA;[   55.830000] busybox: sending ioctl 5310 to a partition!&#xA;[   56.290000] EXT4-fs (sda2): couldn't mount as ext3 due to feature incompatibilities&#xA;[   56.310000] EXT4-fs (sda2): couldn't mount as ext2 due to feature incompatibilities&#xA;[   56.360000] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)&#xA;[   58.520000] cfg80211: Calling CRDA for country: AT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems as if there are problems with &lt;code&gt;mcuio-hc&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last thing - when I ran &lt;code&gt;run-avrdude /etc/linino/bathos-one.hex&lt;/code&gt;&#xA;I get an error when comparing the written data (I found information that this can be ignored).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this / find out what to fix / what's going wrong?&lt;/p&gt;&#xA;" OwnerUserId="11847" LastEditorUserId="6936" LastEditDate="2016-12-10T14:05:04.000" LastActivityDate="2017-01-09T18:01:31.397" Title="LininoIO running &quot;partially&quot;" Tags="|arduino-yun|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14254" PostTypeId="1" CreationDate="2015-08-16T19:21:10.103" Score="2" ViewCount="540" Body="&lt;p&gt;I have a Gboard module (from &lt;a href=&quot;http://imall.itead.cc/gboard.html&quot; rel=&quot;nofollow&quot;&gt;Itead&lt;/a&gt;) configured to recieve data from Xbee sensors, and log data to a server DB on inet (via GPRS). This module is programmed with Arduino IDE.&#xA;I turn on the module (without any xbee sending, to check that the GPRS is working). The module works fine; The GPRS part sends some &quot;control&quot; packages to the DB to inet as expected. The problem appears after 1'5 hours because module is still on but the GPRS doesn't seem to be working (doesn't send any more packages to inet). &#xA;Excuse me for my messy code, I´m newbie! (a lot of copy/pastes from others!). Thank you in advance for your tipps and recomendations!. &#xA;Note: I use a power supply 12v and 2Amp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;elapsedMillis.h&amp;gt;///para controles&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Streaming.h&amp;gt; ///para xbee&#xA;#include &amp;lt;XBee.h&amp;gt;      ///para xbee&#xA;int xbeeRecibido;&#xA;char urlArreglo[100];&#xA;uint8_t slCmd[] = {'S', 'L'};&#xA;uint8_t dbCmd[] = {'D', 'B'};&#xA;char adr_part[8];&#xA;char rssiValor_part[8];&#xA;String adr = &quot;&quot;;&#xA;String rssiValor = &quot;&quot;;&#xA;AtCommandRequest atRequest = AtCommandRequest();&#xA;AtCommandResponse atResponse = AtCommandResponse();&#xA;elapsedMillis timeElapsed = 0;&#xA;unsigned long interval = 180000 ;////en milisegundos  cada 3 min.&#xA;String direccionRed;&#xA;int bateria;&#xA;String valorRssi;&#xA;int actividadPir;&#xA;String datosHttp; ///concatenacion de datos para enviar por HTTP&#xA;int8_t answer;&#xA;char data[512];&#xA;int data_size;&#xA;char aux_str[100];&#xA;char aux;&#xA;int x = 0;&#xA;XBee xbee = XBee();                //XBee object&#xA;Rx16Response rx = Rx16Response();&#xA;SoftwareSerial mySerial(2, 3); // RX, TX (ahora puesto en TX, RX)&#xA;int b01;&#xA;int b02;&#xA;int b03;&#xA;int b04; //source network adress 64Bit&#xA;int b05; //source network adress 64Bit&#xA;int b06; //source network adress 64Bit&#xA;int b07; //source network adress 64Bit&#xA;int b08; //source network adress 64Bit&#xA;int b09; //source network adress 64Bit&#xA;int b10; //source network adress 64Bit&#xA;int b11; //source network adress 64Bit&#xA;int b12; //source network adress 16Bit&#xA;int b13; //source network adress 16Bit&#xA;int b14;&#xA;int b15; //pir digital&#xA;int b16; //bateria&#xA;int b17; //checksum&#xA;char response[100];&#xA;unsigned long previous;&#xA;&#xA;void setup() {&#xA;  pinMode(6, OUTPUT);///para encender SIM900 ...en pin6 HIGH de arduino GBOARD&#xA;  digitalWrite(6, HIGH);///para encender SIM900 ...en pin6 HIGH de arduino GBOARD&#xA;  mySerial.begin(9600);&#xA;  Serial.begin(9600);&#xA;  ///////GPRS////////&#xA;  power_on();&#xA;  delay(3000);&#xA;  sendATcommand(&quot;AT+ipr=9600&quot;, &quot;OK&quot;, 2000);///////MIO PARA BAUDERATE A 9600 (por defecto 0=auto..¿se apaga?)&#xA;  // sets the PIN code&#xA;  sendATcommand(&quot;AT+CPIN=****&quot;, &quot;OK&quot;, 2000);&#xA;  delay(3000);&#xA;  while (sendATcommand2(&quot;AT+CREG?&quot;, &quot;+CREG: 0,1&quot;, &quot;+CREG: 0,5&quot;, 2000) == 0);&#xA;  sendATcommand(&quot;AT+SAPBR=3,1,\&quot;Contype\&quot;,\&quot;GPRS\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;  sendATcommand(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;gprs.lebaramobile.es\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;  sendATcommand(&quot;AT+SAPBR=3,1,\&quot;USER\&quot;,\&quot;\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;  sendATcommand(&quot;AT+SAPBR=3,1,\&quot;PWD\&quot;,\&quot;\&quot;&quot;, &quot;OK&quot;, 2000);&#xA;  while (sendATcommand(&quot;AT+SAPBR=1,1&quot;, &quot;OK&quot;, 20000) == 0)&#xA;  {&#xA;    delay(5000);&#xA;  }&#xA;  ////FIN GPRS////&#xA;  ////PRIMER AUTOCONTROL!&#xA;  lanzarHttpAutoControl();&#xA;  delay(15000);&#xA;}&#xA;&#xA;void loop() {&#xA;  // PARA AUTOCONTROL!&#xA;  if (timeElapsed &amp;gt; interval)&#xA;  {&#xA;    lanzarHttpAutoControl();&#xA;    timeElapsed = 0;             // reset the counter to 0 so the counting starts over...&#xA;  }&#xA;  if (Serial.available() == 18) { //make sure the frame is all there&#xA;    if (Serial.read() == 0x7E) {&#xA;      b01 = Serial.read();&#xA;      b02 = Serial.read();&#xA;      b03 = Serial.read();&#xA;      b04 = Serial.read(); //source network adress 64Bit&#xA;      b05 = Serial.read(); //source network adress 64Bit&#xA;      b06 = Serial.read(); //source network adress 64Bit&#xA;      b07 = Serial.read(); //source network adress 64Bit&#xA;      b08 = Serial.read(); //source network adress 64Bit&#xA;      b09 = Serial.read(); //source network adress 64Bit&#xA;      b10 = Serial.read(); //source network adress 64Bit&#xA;      b11 = Serial.read(); //source network adress 64Bit&#xA;      b12 = Serial.read(); //source network adress 16Bit&#xA;      b13 = Serial.read(); //source network adress 16Bit&#xA;      b14 = Serial.read();&#xA;      b15 = Serial.read(); //pir digital&#xA;      b16 = Serial.read(); //bateria&#xA;      b17 = Serial.read();  //checksum&#xA;      direccionRed =  String(b04, HEX);&#xA;      direccionRed +=  String(b05, HEX);&#xA;      direccionRed +=  String(b06, HEX);&#xA;      direccionRed +=  String(b07, HEX);&#xA;      direccionRed +=  String(b08, HEX);&#xA;      direccionRed +=  String(b09, HEX);&#xA;      direccionRed +=  String(b10, HEX);&#xA;      direccionRed +=  String(b11, HEX);&#xA;      actividadPir = b15;&#xA;      bateria = int(b16);&#xA;      xbeeRecibido = 1;&#xA;    } //fin if 0x7E&#xA;  }///fin recorrer bytes&#xA;  Serial.flush();&#xA;  Serial.end();&#xA;  Serial.begin(9600);///paro el serial para evitar solapaciones, y hacer esperar a los sensores (al no recibir resp. del gateway)&#xA;  if (xbeeRecibido == 1) {///si se ha recibido info de xbee sensor&#xA;    colectorDatos();&#xA;    xbeeRecibido = 0;&#xA;  }&#xA;}//fin loop&#xA;&#xA;///FUNCION PARA RSSI XBEE///&#xA;void rss() {  ///PARA RSSI&#xA;  /* returns received signal strength value for the last RF data packet */&#xA;  union {&#xA;    byte B;&#xA;    char C;&#xA;  } atCmd[3];&#xA;  AtCommandRequest atCmdReq;&#xA;  AtCommandResponse atResp;&#xA;  byte respLen, *resp, dBm;&#xA;  strcpy(&amp;amp;atCmd[0].C, &quot;DB&quot;);&#xA;  atCmdReq = AtCommandRequest(&amp;amp;atCmd[0].B);&#xA;  atResp = AtCommandResponse();&#xA;  xbee.send(atCmdReq);&#xA;  if (xbee.readPacket(5000)) {&#xA;    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {&#xA;      xbee.getResponse().getAtCommandResponse(atResp);&#xA;      if (atResp.isOk()) {&#xA;        respLen = atResp.getValueLength();&#xA;        if (respLen == 1) {&#xA;          resp = atResp.getValue();&#xA;          dBm = resp[0];&#xA;          valorRssi = (String)dBm;&#xA;&#xA;        }&#xA;        else {&#xA;        }&#xA;      }&#xA;      else {&#xA;&#xA;      }&#xA;    }&#xA;    else {&#xA;    }&#xA;  }&#xA;  else {&#xA;  }&#xA;}///fin rss()&#xA;&#xA;&#xA;void power_on() {&#xA;  uint8_t answer = 0;&#xA;  // checks if the module is started&#xA;  answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);&#xA;  if (answer == 0)&#xA;  {&#xA;    // waits for an answer from the module&#xA;    while (answer == 0) {&#xA;      // Send AT every two seconds and wait for the answer&#xA;      answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout) {&#xA;  uint8_t x = 0,  answer = 0;&#xA;  memset(response, 0, sizeof(response));///a cero el array ///15-08-2015&#xA;  memset(response, '\0', 100);    // Initialize the string&#xA;  delay(100);&#xA;  while ( mySerial.available() &amp;gt; 0) mySerial.read();   // Clean the input buffer&#xA;  mySerial.println(ATcommand);    // Send the AT command&#xA;  x = 0;&#xA;  previous = millis();&#xA;  do {&#xA;    if (mySerial.available() != 0) {&#xA;      response[x] = mySerial.read();&#xA;      x++;&#xA;      if (strstr(response, expected_answer1) != NULL)&#xA;      {&#xA;        answer = 1;&#xA;      }&#xA;    }&#xA;  }&#xA;  while ((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));&#xA;  return answer;&#xA;}&#xA;&#xA;int8_t sendATcommand2(char* ATcommand, char* expected_answer1,&#xA;                      char* expected_answer2, unsigned int timeout) {&#xA;  uint8_t x = 0,  answer = 0;&#xA;  memset(response, 0, sizeof(response));///a cero el array ///15-08-2015&#xA;  memset(response, '\0', 100);    // Initialize the string&#xA;  delay(100);&#xA;  while ( mySerial.available() &amp;gt; 0) mySerial.read();   // Clean the input buffer&#xA;  mySerial.println(ATcommand);    // Send the AT command&#xA;  x = 0;&#xA;  previous = millis();&#xA;  do {&#xA;    if (mySerial.available() != 0) {&#xA;      response[x] = mySerial.read();&#xA;      x++;&#xA;      // check if the desired answer 1 is in the response of the module&#xA;      if (strstr(response, expected_answer1) != NULL)&#xA;      {&#xA;        answer = 1;&#xA;      }&#xA;      // check if the desired answer 2 is in the response of the module&#xA;      if (strstr(response, expected_answer2) != NULL)&#xA;      {&#xA;        answer = 2;&#xA;      }&#xA;    }&#xA;    // Waits for the asnwer with time out&#xA;  } while ((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));&#xA;  return answer;&#xA;}&#xA;&#xA;void colectorDatos() {&#xA;  rss(); ////recupero rssi que se pone en variable valorRssi&#xA;  datosHttp = direccionRed + &quot;;&quot;; ///cualquier valor del array, todos deverian tener mismo valor (direccion64bits)&#xA;  datosHttp += bateria;&#xA;  datosHttp += &quot;;&quot;;&#xA;  datosHttp += valorRssi;&#xA;  datosHttp += &quot;;&quot;;&#xA;  datosHttp += actividadPir; //pir&#xA;  envio(datosHttp); ///envio por gprs&#xA;}///fin colectorDatos&#xA;&#xA;void lanzarHttpAutoControl() {&#xA;  adr = &quot;&quot;;&#xA;  // set command to SL to get low part of MAC address&#xA;  atRequest.setCommand(slCmd);&#xA;  while (!sendAtCommand()) {};&#xA;  for (int i = 0; i &amp;lt; atResponse.getValueLength(); i++) {&#xA;    mySerial.print(atResponse.getValue()[i], HEX);&#xA;    sprintf(adr_part, &quot;%lX&quot;, (unsigned long)(atResponse.getValue()[i]));&#xA;    if (atResponse.getValue()[i] &amp;lt;= 0xF)&#xA;      adr += 0;&#xA;    adr += adr_part;&#xA;  }&#xA;  envio(adr); ///envio por gprs&#xA;}&#xA;&#xA;///envio GPRS...recibe String con datos (o control o sensor)&#xA;void envio(String entrada) {&#xA;  Serial.end();///paro el serial para evitar solapaciones, y hacer esperar a los sensores (al no recibir resp. del gateway)&#xA;  memset(urlArreglo, 0, sizeof(urlArreglo));///a cero el array&#xA;  answer = sendATcommand(&quot;AT+HTTPINIT&quot;, &quot;OK&quot;, 10000);&#xA;  if (answer == 1)&#xA;  {&#xA;    // Sets CID parameter&#xA;    answer = sendATcommand(&quot;AT+HTTPPARA=\&quot;CID\&quot;,1&quot;, &quot;OK&quot;, 5000);&#xA;    if (answer == 1)&#xA;    {&#xA;      //char urlArreglo[100];&#xA;      sprintf(urlArreglo,  &quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;www.pestmonitors.com/dream/prueba_gsm_get.php?datos=%s\&quot;&quot;, entrada.c_str());&#xA;      answer = sendATcommand(urlArreglo, &quot;OK&quot;, 5000);&#xA;      delay(5000);&#xA;      if (answer == 1)&#xA;      {&#xA;        answer = sendATcommand(&quot;AT+HTTPACTION=0&quot;, &quot;+HTTPACTION:0,200&quot;, 10000);&#xA;      }&#xA;      else&#xA;      {&#xA;      }&#xA;      sendATcommand(&quot;AT+HTTPTERM&quot;, &quot;OK&quot;, 5000);&#xA;      delay(5000);&#xA;    }&#xA;  }&#xA;  Serial.begin(9600);///paro el serial para evitar solapaciones, y hacer esperar a los sensores (al no recibir resp. del gateway)&#xA;}&#xA;&#xA;// used here to sens AT command to the Xbee to get information such as the MAC address&#xA;int sendAtCommand() {&#xA;  xbee.send(atRequest);&#xA;  if (xbee.readPacket(5000)) {&#xA;    if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {&#xA;      xbee.getResponse().getAtCommandResponse(atResponse);&#xA;      if (atResponse.isOk()) {&#xA;        if (atResponse.getValueLength() &amp;gt; 0) {&#xA;          mySerial.println(atResponse.getValueLength(), DEC);&#xA;          for (int i = 0; i &amp;lt; atResponse.getValueLength(); i++) {&#xA;            mySerial.print(atResponse.getValue()[i], HEX);&#xA;          }&#xA;        }&#xA;        return 1;&#xA;      }&#xA;      else {&#xA;      }&#xA;    } else {&#xA;      mySerial.print(xbee.getResponse().getApiId(), HEX);&#xA;    }&#xA;  } else {&#xA;    if (xbee.getResponse().isError()) {&#xA;    }&#xA;    else {&#xA;    }&#xA;  }&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4889" LastEditorUserId="4889" LastEditDate="2015-08-17T15:00:04.110" LastActivityDate="2015-08-17T15:00:04.110" Title="SIM 900 stop after 1'5 hours; what's wrong?" Tags="|arduino-uno|gsm|atmega328|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14255" PostTypeId="1" CreationDate="2015-08-16T19:34:06.883" Score="0" ViewCount="2066" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xNSRT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xNSRT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a circuit with preferably long wires that get data from thermistors. The Arduino sends this data (formatted in JSON) to a web server where it can be collected by another program.&#xA;Some of these values appear correct, while others do not.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[&#xA;{&#xA;    &quot;dht11&quot;: {&#xA;        &quot;temperature&quot;: 73.4,&#xA;        &quot;humidity&quot;: 41,&#xA;        &quot;heat-index&quot;: 77.15&#xA;    },&#xA;    &quot;thermistors&quot;: {&#xA;        &quot;therm1&quot;: {&#xA;            &quot;temp&quot;: 71.21,&#xA;            &quot;resistance&quot;: 12727.27&#xA;        },&#xA;        &quot;therm2&quot;: {&#xA;            &quot;temp&quot;: 76.22,&#xA;            &quot;resistance&quot;: 12045.51&#xA;        },&#xA;        &quot;therm3&quot;: {&#xA;            &quot;temp&quot;: nan,&#xA;            &quot;resistance&quot;: -19393.41&#xA;        }&#xA;    }&#xA;}&#xA;]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define THERMISTORPIN A0&#xA;#define THERMISTORNOMINAL 10000&#xA;#define TEMPERATURENOMINAL 25&#xA;#define NUMSAMPLES 25&#xA;#define BCOEFFICIENT 4050&#xA;#define SERIESRESISTOR 10000&#xA;#define THERMISTORPIN2 A5&#xA;#define THERMISTORPIN3 A3&#xA;#define DHTPIN 2&#xA;#define PHOTORESISTOR 3&#xA;#define DHTTYPE DHT11&#xA;int samples[NUMSAMPLES];&#xA;int samples_two[NUMSAMPLES];&#xA;int samples_three[NUMSAMPLES];&#xA;int stuckintime;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &quot;DHT.h&quot;&#xA;byte mac[] = {&#xA;  0x00, 0x00, 0x00, 0x00, 0x00, 0xEE&#xA;};&#xA;IPAddress ip(192, 168, 1, 3);&#xA;EthernetServer server(80);&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;  dht.begin();&#xA;  analogReference(EXTERNAL);&#xA;}&#xA;&#xA;void loop() {&#xA;  uint8_t i;&#xA;          float average;&#xA;          float average_two;&#xA;          float average_three;&#xA;          float stuckintime;&#xA;          for (i = 0; i &amp;lt; NUMSAMPLES; i++) {&#xA;            samples[i] = analogRead(THERMISTORPIN);&#xA;            samples_two[i] = analogRead(THERMISTORPIN2);&#xA;            samples_three[i] = analogRead(THERMISTORPIN3);&#xA;            delay(10);&#xA;          }&#xA;          for (i = 0; i &amp;lt; NUMSAMPLES; i++) {&#xA;            average += samples[i];&#xA;            average_two += samples_two[i];&#xA;            average_three += samples_three[i];&#xA;          }&#xA;          average /= NUMSAMPLES;&#xA;          average = 1023 / average - 1;&#xA;          average = SERIESRESISTOR / average;&#xA;          float tempreading;&#xA;          tempreading = average / 10975;&#xA;          tempreading = log(tempreading);&#xA;          tempreading /= BCOEFFICIENT;&#xA;          tempreading += 1.0 / (TEMPERATURENOMINAL + 273.15);&#xA;          tempreading = 1.0 / tempreading;&#xA;          tempreading -= 273.15;&#xA;          tempreading = tempreading * 9 / 5 + 32;&#xA;          average_two /= NUMSAMPLES;&#xA;          average_two = 1023 / average_two - 1;&#xA;          average_two = SERIESRESISTOR / average_two;&#xA;          average_two = average_two;&#xA;          float tempreadtwo;&#xA;          tempreadtwo = average_two / 11811;&#xA;          tempreadtwo = log(tempreadtwo);&#xA;          tempreadtwo /= BCOEFFICIENT;&#xA;          tempreadtwo += 1.0 / (TEMPERATURENOMINAL + 273.15);&#xA;          tempreadtwo = 1.0 / tempreadtwo;&#xA;          tempreadtwo -= 273.15;&#xA;          tempreadtwo = tempreadtwo * 9 / 5 + 32;  &#xA;          average_three /= NUMSAMPLES;&#xA;          average_three = 1023 / average_three - 1;&#xA;          average_three = SERIESRESISTOR / average_three;&#xA;          float tempreadthree;&#xA;          tempreadthree = average_three / THERMISTORNOMINAL;&#xA;          tempreadthree = log(tempreadthree);&#xA;          tempreadthree /= BCOEFFICIENT;&#xA;          tempreadthree += 1.0 / (TEMPERATURENOMINAL + 273.15);&#xA;          tempreadthree = 1.0 / tempreadthree;&#xA;          tempreadthree -= 273.15;&#xA;          tempreadthree = tempreadthree * 9 / 5 + 32;&#xA;          float h = dht.readHumidity();&#xA;          float t = dht.readTemperature();&#xA;          float f = dht.readTemperature(true);&#xA;          float hif = dht.computeHeatIndex(f, h);&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: application/json&quot;);&#xA;          client.println(&quot;Connection: close&quot;);&#xA;          client.println(&quot;Refresh: 0&quot;);&#xA;          client.println(&quot;&quot;);&#xA;          client.println(&quot;[&quot;);&#xA;          client.println(&quot;   {&quot;);&#xA;          client.println(&quot;    \&quot;dht11\&quot;: {&quot;);&#xA;          client.print(&quot;          \&quot;temperature\&quot;: &quot;);  client.print(f);        client.println(&quot;,&quot;);&#xA;          client.print(&quot;          \&quot;humidity\&quot;: &quot;);         client.print(h);        client.println(&quot;,&quot;);&#xA;          client.print(&quot;          \&quot;heat-index\&quot;: &quot;);   client.print(hif);  client.println(&quot;&quot;);&#xA;          client.println(&quot;     },&quot;);&#xA;          client.println(&quot;    \&quot;thermistors\&quot;: {&quot;);&#xA;          client.println(&quot;        \&quot;under-bed\&quot;: {&quot;);&#xA;          client.print(&quot;             \&quot;temp\&quot;: &quot;);          client.print(tempreading);      client.println(&quot;,&quot;);&#xA;          client.print(&quot;             \&quot;resistance\&quot;: &quot;);    client.print(average);  client.println(&quot;&quot;);&#xA;          client.println(&quot;       },&quot;);&#xA;          client.println(&quot;        \&quot;side-bed\&quot;: {&quot;);&#xA;          client.print(&quot;             \&quot;temp\&quot;: &quot;);          client.print(tempreadtwo);      client.println(&quot;,&quot;);&#xA;          client.print(&quot;             \&quot;resistance\&quot;: &quot;);    client.print(average_two);  client.println(&quot;&quot;);&#xA;          client.println(&quot;       },&quot;);        &#xA;          client.println(&quot;        \&quot;top-bed\&quot;: {&quot;);&#xA;          client.print(&quot;             \&quot;temp\&quot;: &quot;);          client.print(tempreadthree);        client.println(&quot;,&quot;);&#xA;          client.print(&quot;             \&quot;resistance\&quot;: &quot;);    client.print(average_three);    client.println(&quot;&quot;);&#xA;          client.println(&quot;       }&quot;);&#xA;          client.println(&quot;     }&quot;);&#xA;          client.println(&quot;   }&quot;);&#xA;          client.println(&quot;]&quot;);&#xA;          break;&#xA;        }&#xA;        if (c == '\n') {&#xA;          currentLineIsBlank = true;&#xA;        }&#xA;        else if (c != '\r') {&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    delay(1);&#xA;    client.stop();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea what is causing this to happen - pushing RESET doesn't fix it at all, reconnecting wires does not fix it, any help?&lt;br&gt;&#xA;(Please tell me what else to include if you need it.)&lt;/p&gt;&#xA;" OwnerUserId="10442" LastEditorUserId="10442" LastEditDate="2015-08-16T20:05:34.413" LastActivityDate="2015-08-16T20:56:36.867" Title="Getting values from multiple thermistors - one value glitches all over the place" Tags="|arduino-uno|ethernet|web-server|analog-sampling|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14256" PostTypeId="1" AcceptedAnswerId="25142" CreationDate="2015-08-16T19:41:37.393" Score="3" ViewCount="14710" Body="&lt;p&gt;I have a number of temperature sensors connected up to an Arduino - I've split it into 3 sections, with each section having a 2-4 sensors on it (due to distances).   This works, but the code I'm using would seem to me to be very inefficient - particularly with respect of how long it takes to read all the sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got 3 code blocks one after each other (which are modified from some code online) which look as below - save, of-course, for the name of the 1wire class.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Dallas 1 Wire (Main Area):&#xA;&#xA; //  ds.reset_search();&#xA; //  delay(250);&#xA;  while (ds.search(addr))&#xA;  {&#xA;    for( i = 0; i &amp;lt; 8; i++) {&#xA;      Serial.print(addr[i], HEX);&#xA;    }&#xA;&#xA;    if (OneWire::crc8(addr, 7) != addr[7]) {&#xA;        Serial.println(&quot;CRC is not valid!&quot;);&#xA;        return;&#xA;    }&#xA;&#xA;    ds.reset();&#xA;    ds.select(addr);&#xA;    ds.write(0x44, 0);        // start conversion, with parasite power on at the end&#xA;&#xA;    delay(1000);     // maybe 750ms is enough, maybe not&#xA;    // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;    present = ds.reset();&#xA;    ds.select(addr);    &#xA;    ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;    for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;      data[i] = ds.read();&#xA;    }&#xA;    raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;    if (type_s) {&#xA;      raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;      if (data[7] == 0x10) {&#xA;        // &quot;count remain&quot; gives full 12 bit resolution&#xA;        raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;      }&#xA;    } else {&#xA;      byte cfg = (data[4] &amp;amp; 0x60);&#xA;      // at lower res, the low bits are undefined, so let's zero them&#xA;      if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;      else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;      else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;      //// default is 12 bit resolution, 750 ms conversion time&#xA;    }&#xA;    celsius = (float)raw / 16.0;&#xA;    Serial.print(&quot;:&quot;);&#xA;    Serial.print(celsius);&#xA;    Serial.print(&quot;,&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I note that there is a 1000ms delay after each sensor is read, and I'm wondering if I can reduce this to a single 750ms delay for all the sensors.  My initial attempts to do this did not meet with success - but I confess that I can't quite get my head around the ds.reset, ds.select etc - and my initial attempts to do this have all failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to remove this delay after reading each sensor ?&lt;/p&gt;&#xA;" OwnerUserId="8144" LastActivityDate="2023-05-18T01:17:35.950" Title="Reducing read time for reading DS18B20 temp sensors" Tags="|programming|temperature-sensor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14257" PostTypeId="1" AcceptedAnswerId="14259" CreationDate="2015-08-16T12:40:24.907" Score="0" ViewCount="110" Body="&lt;p&gt;I am working in my project and I want to see the output of my sensors as (0 or 5).&#xA;The maximum read was 770 and the minimum read was 0. So, how can I see the  value (0 or 5) on my screen, where I connected my sensors output to analog input A0, A1 pins.&#xA;I did the following code, but it didn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup(){&#xA;Serial.begin(9600);   &#xA;}&#xA;void loop()&#xA;{&#xA;if (analogRead(0)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA; else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;if (analogRead(1)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;   else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;if (analogRead(2)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;  else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;if (analogRead(3)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;  else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;if (analogRead(4)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;  else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;if (analogRead(5)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;  else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&#xA;delay(1500); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I have 5 light sensors in my circuit. &lt;/p&gt;&#xA;" OwnerUserId="11856" OwnerDisplayName="user119436" LastEditorUserId="4131" LastEditDate="2015-08-18T08:43:35.753" LastActivityDate="2015-08-18T08:43:35.753" Title="Arduino ,How I can see the value (0 or 5) on my screen, where I connected my sensors output to analog input A0,A1.. pins" Tags="|serial|analogread|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14258" PostTypeId="2" ParentId="14257" CreationDate="2015-08-16T13:25:40.290" Score="0" Body="&lt;p&gt;You can use DigitaRead command instead of analogread. It will give result in only 1 or 0. Hopefully this will help you.&lt;/p&gt;&#xA;" OwnerDisplayName="user5230499" LastActivityDate="2015-08-16T13:25:40.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14259" PostTypeId="2" ParentId="14257" CreationDate="2015-08-16T13:35:31.007" Score="0" Body="&lt;p&gt;Try this code - it should help you see what is going on more clearly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int threshold = 385;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);   &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int reading = analogRead(0);&#xA;  Serial.print(&quot;Analog 0 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }    &#xA;&#xA;  reading = analogRead(1);&#xA;  Serial.print(&quot;Analog 1 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }    &#xA;&#xA;  reading = analogRead(2);&#xA;  Serial.print(&quot;Analog 2 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }    &#xA;&#xA;  reading = analogRead(3);&#xA;  Serial.print(&quot;Analog 3 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }    &#xA;&#xA;  reading = analogRead(4);&#xA;  Serial.print(&quot;Analog 4 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }    &#xA;&#xA;  reading = analogRead(5);&#xA;  Serial.print(&quot;Analog 5 reads &quot;);&#xA;  Serial.print(reading);&#xA;  Serial.print(&quot; - this maps to &quot;);&#xA;  if (reading &amp;lt; threshold){&#xA;    Serial.println(&quot;0&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;5&quot;);&#xA;  }                                &#xA;&#xA;  Serial.println();&#xA;&#xA;  delay(1500); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11729" OwnerDisplayName="stefandz" LastActivityDate="2015-08-16T13:55:29.050" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14260" PostTypeId="2" ParentId="14255" CreationDate="2015-08-16T20:56:36.867" Score="3" Body="&#xA;&#xA;&lt;p&gt;Here's a major problem:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;&#xA;  uint8_t i;&#xA;          float average;&#xA;          float average_two;&#xA;          float average_three;&#xA;          float stuckintime;&#xA;          for (i = 0; i &amp;lt; NUMSAMPLES; i++) {&#xA;            samples[i] = analogRead(THERMISTORPIN);&#xA;            samples_two[i] = analogRead(THERMISTORPIN2);&#xA;            samples_three[i] = analogRead(THERMISTORPIN3);&#xA;            delay(10);&#xA;          }&#xA;          for (i = 0; i &amp;lt; NUMSAMPLES; i++) {&#xA;            average += samples[i];&#xA;            average_two += samples_two[i];&#xA;            average_three += samples_three[i];&#xA;          }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variables &lt;em&gt;average&lt;/em&gt;, &lt;em&gt;average_two&lt;/em&gt;, and &lt;em&gt;average_three&lt;/em&gt; have &lt;strong&gt;undefined&lt;/strong&gt; values. Thus it isn't surprising that when you add something to them, they are still undefined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Local variables must be initialized (eg. to zero in your case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you have two variables named &lt;em&gt;stuckintime&lt;/em&gt; - I would do something about that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-16T20:56:36.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14261" PostTypeId="2" ParentId="14256" CreationDate="2015-08-16T21:08:44.217" Score="2" Body="&lt;p&gt;Doing a search every time is quite inefficient. The search function is for if you don't know the device address - and it takes a while to do. In your case, presumably the addresses will never change. Find the addresses and hard-code them into your code. Or if that isn't practical, store them in EEPROM. And if even that isn't practical find the addresses once in setup.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Next, you need a delay while you take the temperature readings. Why not parallel those up? In a loop, tell all the devices to take a reading. Then wait one second. Then read them all (in another loop). That way the one-second delay is shared between all your sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However from &lt;a href=&quot;http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library&quot; rel=&quot;nofollow&quot;&gt;the page Gerben linked&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And it is NOT possible to run DS1820 sensors on a simple pull-up resistor. During the &quot;Conversion&quot; phase, it needs more power. And there are Application Note discussing this in length. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That suggest that if you are using parasitic power, my suggestion won't work too well (having multiple devices taking readings would make it worse).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I found this code on my disk from a couple of years ago. There don't seem to be any delays between reading sensors. There is a delay at the end of the main loop, mainly to stop spamming the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the comment:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See if that works for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;// Data wire is plugged into port 10 on the Arduino&#xA;const byte ONE_WIRE_BUS = 10;&#xA;const byte TEMPERATURE_PRECISION = 10;&#xA;// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;&#xA;// Pass our oneWire reference to Dallas Temperature. &#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;// arrays to hold device addresses&#xA;DeviceAddress myThermometer [10];&#xA;int deviceCount;&#xA;&#xA;void setup(void)&#xA;{&#xA;&#xA;  // start serial port&#xA;  Serial.begin (115200);&#xA;  Serial &amp;lt;&amp;lt; &quot;Dallas Temperature IC Control Library Demo&quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;  // Start up the library&#xA;  sensors.begin();&#xA;&#xA;  // locate devices on the bus&#xA;  Serial &amp;lt;&amp;lt; &quot;Locating devices...&quot; &amp;lt;&amp;lt; endl;&#xA;  deviceCount = sensors.getDeviceCount();&#xA;&#xA;  Serial &amp;lt;&amp;lt; &quot;Found &quot; &amp;lt;&amp;lt; deviceCount &amp;lt;&amp;lt; &quot; devices.&quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;  // report parasite power requirements&#xA;  Serial &amp;lt;&amp;lt; &quot;Parasite power is: &quot; &amp;lt;&amp;lt; (sensors.isParasitePowerMode() ? &quot;ON&quot; : &quot;OFF&quot;) &amp;lt;&amp;lt; endl; &#xA;&#xA;  // method 1: by index&#xA;&#xA;  for (int i = 0; i &amp;lt; deviceCount; i++)&#xA;  {&#xA;    if (sensors.getAddress(myThermometer [i], i))&#xA;    { &#xA;      Serial &amp;lt;&amp;lt; &quot;Device &quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; Address: &quot;;&#xA;      printAddress(myThermometer [i]);&#xA;      Serial &amp;lt;&amp;lt; endl;&#xA;      sensors.setResolution(myThermometer [i], TEMPERATURE_PRECISION);&#xA;    }&#xA;    else&#xA;      Serial &amp;lt;&amp;lt; &quot;Unable to find address for Device &quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;&#xA;  }  // end of for loop&#xA;&#xA;}&#xA;&#xA;// function to print a device address&#xA;void printAddress(DeviceAddress deviceAddress)&#xA;{&#xA;  for (uint8_t i = 0; i &amp;lt; 8; i++)&#xA;  {&#xA;    // zero pad the address if necessary&#xA;    if (deviceAddress[i] &amp;lt; 16) Serial.print(&quot;0&quot;);&#xA;    Serial.print(deviceAddress[i], HEX);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop(void)&#xA;{ &#xA;&#xA;  // call sensors.requestTemperatures() to issue a global temperature &#xA;  // request to all devices on the bus&#xA;  sensors.requestTemperatures();&#xA;&#xA;  // now get all temperatures&#xA;  for (int i = 0; i &amp;lt; deviceCount; i++)&#xA;  {&#xA;    float tempC = sensors.getTempC(myThermometer [i]);&#xA;    if (tempC &amp;gt; -80)&#xA;    { &#xA;      Serial &amp;lt;&amp;lt; &quot;Device &quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &quot; Temperature: &quot; &amp;lt;&amp;lt; tempC &amp;lt;&amp;lt; endl;&#xA;    }&#xA;    else&#xA;      Serial &amp;lt;&amp;lt; &quot;Unable to find temperature for Device &quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;&#xA;  }  // end of for loop&#xA;&#xA;  delay (1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-17T06:53:45.837" LastActivityDate="2015-08-17T06:53:45.837" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14262" PostTypeId="2" ParentId="14253" CreationDate="2015-08-16T21:46:58.177" Score="0" Body="&lt;p&gt;finally I got it (somehow) working.&#xA;After a reset and another run of run-avrdude /etc/linino/bathos-yun.hex (the first was a mistake by copy and past - not bathos-one I already ran bathos-yun before) and a reboot again I was able to read analog IO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But still the digitals were missing.&#xA;Than I found the command gpioexport an ran it.&#xA;After that the correct entries (D13, D14...) were present in sys/class...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But an echo out &gt; D13/direction resulted in a timeout error message.&#xA;Again reboot - again the Dxxx entries were gone.&#xA;Another gpioexport made them appear again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this time not timeouts - instead I could turn on / of D13 (for test).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess all I have to do to make the things better is include gpioexport in &quot;startup code&quot; so that it runs after a reboot.&lt;/p&gt;&#xA;" OwnerUserId="11847" LastActivityDate="2015-08-16T21:46:58.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14263" PostTypeId="2" ParentId="4927" CreationDate="2015-08-16T23:44:47.950" Score="1" Body="&lt;p&gt;May I suggest the following. I found this fork of the Adafruit library which works better than the one they have on their website &lt;a href=&quot;https://github.com/Miyeah/Arduino-Dormitory-Assistant/tree/master/library/Adafruit_ssd1306syp&quot; rel=&quot;nofollow&quot;&gt;Adafruit_ssd1306syp&lt;/a&gt;. The original &lt;code&gt;Adafruit_ssd1306&lt;/code&gt; library doesn't play nice with SPI and when you want to have your OLED running on i2c and use the SPI for something else. This is a great resource. Download, unzip to your libraries directory. Then run this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_ssd1306syp.h&amp;gt;&#xA;&#xA;#define SDA_PIN A4&#xA;#define SCL_PIN A5&#xA;&#xA;Adafruit_ssd1306syp display(SDA_PIN, SCL_PIN);&#xA;&#xA;void setup() {&#xA;&#xA;  display.initialize();&#xA;  display.setTextSize(1);&#xA;  display.setTextColor(WHITE);&#xA;  printM(&quot;Starting Demo...&quot;);&#xA;&#xA;}&#xA;&#xA;void printM(String mess) {&#xA;&#xA;  display.println(mess);&#xA;  display.update();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  printM(&quot;working&quot;);&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-08-16T23:44:47.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14264" PostTypeId="1" CreationDate="2015-08-17T03:03:11.340" Score="2" ViewCount="1211" Body="&lt;p&gt;Can anyone explain why the standard Arduino IDE 1.6 distribution does not include support for the popular CH341G USB/serial drivers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using these USB/serial chips in several teaching projects for CoderDojo and it is somewhat difficult to have each student download the drivers and reboot their PCs for each class. It seems like both Mac and PC users would benefit from having these drivers loaded directly into the standard Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there possibly some security concern? I know that the latest Mac requires that the drivers are digitally signed. In fact for many modern Macs to use the drivers we have to disable the digital signature checks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link to &lt;a href=&quot;http://www.wch.cn/download/CH341SER_MAC_ZIP.html&quot; rel=&quot;nofollow&quot;&gt;the official drivers&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;a good article&lt;/a&gt; on how to download the drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, the command to disable the digital signature check on the mac we need to do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Mac &quot;Terminal&quot; application enter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we must reboot the mac. Then when we want to re-enable the checks change the 1 to 0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we don't do this command, the Arduino App will not show the serial ports. Do to this go to Tools -&gt; Port Menu within the Arduino application.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.SerialPort&#xA;/dev/cu.SerialPort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I should mention that the CH340G are also used in many &quot;Arduino Nano&quot; clones from China. Perhaps that is why the drivers are not included?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tags: Driver CH340 Setup Installation &lt;/p&gt;&#xA;" OwnerUserId="4519" LastEditorUserId="4628" LastEditDate="2015-08-17T11:13:59.010" LastActivityDate="2017-11-23T23:42:42.823" Title="Why does the standard Arduino IDE not include the CH341G USB Drivers?" Tags="|ide|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14265" PostTypeId="2" ParentId="14257" CreationDate="2015-08-17T03:09:53.817" Score="0" Body="&lt;p&gt;Your code has multiple issues.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (analogRead(1)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;   else&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print('  ');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;Serial.print('  ');&lt;/code&gt; is not at all the same as &lt;code&gt;Serial.print(&quot;  &quot;);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, by the indentation it looks like you should be using braces. Amended code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (analogRead(1)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;   else&#xA;      {&#xA;      Serial.print(&quot;5&quot;);&#xA;      Serial.print(&quot;  &quot;);&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without the braces only the first statement after the &lt;em&gt;else&lt;/em&gt; is conditionally executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I am wrong about that, you should indent differently, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (analogRead(1)&amp;lt;385)&#xA;      Serial.print(&quot;0&quot;);&#xA;   else&#xA;      Serial.print(&quot;5&quot;);&#xA;Serial.print(&quot;  &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-17T03:09:53.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14266" PostTypeId="1" AcceptedAnswerId="21020" CreationDate="2015-08-17T04:09:34.267" Score="3" ViewCount="1624" Body="&lt;p&gt;I want to use eclipse for arduino programming, so I followed the guides to set up a static project for the arduino core library. Then I added the library file (.a) and the .h and .cpp files to my new project in the settings.&lt;br&gt;&#xA;So far, so good.&lt;br&gt;&#xA;But now I am trying to add the SPI library to my project without success (I only have the .h and .cpp files, &lt;strong&gt;no&lt;/strong&gt; .a)!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sample code  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;int main(void) {&#xA;    init();&#xA;    pinMode(13, OUTPUT);&#xA;    for (;;) {&#xA;        digitalWrite(13,1);&#xA;        SPI.setBitOrder(0);&#xA;    }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pinMode and digitalWrite parts work, but with the SPI method I get an error:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;05:33:26 **** Build of configuration Debug for project ArduinoTestProject ****&#xA;make all &#xA;Building file: ../main.cpp&#xA;Invoking: AVR C++ Compiler&#xA;avr-g++ -I/home/fabio/Workspace/arduinoLIB/SPI -I/home/fabio/Workspace/arduinoCORE -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF&quot;main.d&quot; -MT&quot;main.d&quot; -c -o &quot;main.o&quot; &quot;../main.cpp&quot;&#xA;Finished building: ../main.cpp&#xA;&#xA;Building target: ArduinoTestProject.elf&#xA;Invoking: AVR C++ Linker&#xA;avr-gcc -s -Os -o&quot;ArduinoTestProject.elf&quot;  ./main.o   -l&quot;arduinoUNO&quot; -l&quot;m&quot; -lm -Wl,-Map,ArduinoTestProject.map,--cref -mrelax -Wl,--gc-sections -L/home/fabio/Workspace/arduinoCORE/lib -mmcu=atmega328p; avr-nm -C -n &quot;ArduinoTestProject.elf&quot; &amp;gt;ArduinoTestProject.symbol&#xA;./main.o: In function `main':&#xA;../main.cpp:38: undefined reference to `SPIClass::setBitOrder(unsigned char)'&#xA;collect2: error: ld returned 1 exit status&#xA;avr-nm: 'ArduinoTestProject.elf': No such file&#xA;make: *** [ArduinoTestProject.elf] Error 1&#xA;&#xA;05:33:26 Build Finished (took 72ms)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone see the problem?&lt;/p&gt;&#xA;" OwnerUserId="7280" LastActivityDate="2016-02-23T15:32:55.553" Title="Arduino in Eclipse IDE: How to add SPI library (core library already added)?" Tags="|arduino-uno|spi|eclipse|avr-toolchain|" AnswerCount="1" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14267" PostTypeId="2" ParentId="14250" CreationDate="2015-08-17T05:16:53.607" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const char x[] PROGMEM = {&quot;Item x&quot;};&#xA;const char y[] PROGMEM = {&quot;Item y&quot;};&#xA;const char* const item_list[] PROGMEM = {x, y};&#xA;&#xA;struct mylist {&#xA;  uint8_t nitems;&#xA;  const char** const list;&#xA;};&#xA;const mylist aa PROGMEM = {2,(const char** const)item_list};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems to me this is way too wordy for what appears to be trying to store a list of a couple of strings. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const char* const item_list[] PROGMEM = {x, y};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have a array of pointers to strings. OK.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;struct mylist {&#xA;  uint8_t nitems;&#xA;  const char** const list;&#xA;};&#xA;const mylist aa PROGMEM = {2,(const char** const)item_list};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have a &lt;em&gt;list&lt;/em&gt; of an &lt;em&gt;array&lt;/em&gt;? This is where I am confused.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Compare to an adaptation of the code on &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_ELEMENTS = 2;&#xA;&#xA;const char Message0000 [] PROGMEM = &quot;Item X&quot;; &#xA;const char Message0001 [] PROGMEM = &quot;Item Y&quot;; &#xA;&#xA;const char * const messages[NUMBER_OF_ELEMENTS] PROGMEM = &#xA;   { &#xA;   Message0000, &#xA;   Message0001, &#xA;   };&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  for (int i = 0; i &amp;lt; NUMBER_OF_ELEMENTS; i++)&#xA;    {&#xA;    char * ptr = (char *) pgm_read_word (&amp;amp;messages [i]);&#xA;    char buffer [80]; // must be large enough!&#xA;    strcpy_P (buffer, ptr);&#xA;    Serial.println (buffer);&#xA;    }   // end of for loop&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop () { } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Edited to comment on new code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You have a major problem here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Field::Field(const FieldDefinition* fp ) : _fp(fp) {&#xA;  _ndx = 0;&#xA;  char * _value = new char[getLength()];&#xA; _copyitem(_ndx);&#xA;};&#xA;char * Field::selectItem(uint8_t ndx){&#xA;  _ndx = ndx;&#xA;  _copyitem(_ndx);&#xA;  // display item&#xA;  // do more here . . .&#xA; return _value;&#xA;}&#xA;uint8_t Field::getLength(){&#xA;  return pgm_read_byte(&amp;amp;_fp-&amp;gt;length);&#xA;}&#xA;void Field::_copyitem(uint8_t ndx){&#xA;  PGM_VOID_P plist = pgm_read_ptr(&amp;amp;_fp-&amp;gt;list);&#xA;  PGM_P pitem = (PGM_P)pgm_read_ptr(plist + ndx * sizeof(char*));&#xA;  strlcpy_P(_value, pitem, getLength());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I gather you are doing here is, to get the string for an item (for printing) doing a &lt;code&gt;new&lt;/code&gt; (which allocates memory), copying from PROGMEM into that memory, displaying that item, and then ignoring the allocated memory. Well, you can't do that. You will run out of RAM very quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code doesn't even have the word &lt;code&gt;delete&lt;/code&gt; in it. Every &lt;code&gt;new&lt;/code&gt; should have a corresponding &lt;code&gt;delete&lt;/code&gt;. It's a fundamental principle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks too complex still. Make a function that just displays the item (menu or whatever it is) without actually making a copy of it. Certainly don't allocate memory and not free it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-18T05:14:35.653" LastActivityDate="2015-08-18T05:14:35.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14268" PostTypeId="2" ParentId="14253" CreationDate="2015-08-17T06:08:51.547" Score="0" Body="&lt;p&gt;Have a look at the schematics of the YUN &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-Yun-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/uploads/Main/arduino-Yun-schematic.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will notice that most of the GPIO pins on the Atheros is not available to you. You only have access to the GPIO pins of the atmega.&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-17T06:08:51.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14269" PostTypeId="2" ParentId="14264" CreationDate="2015-08-17T06:19:23.677" Score="5" Body="&lt;p&gt;This is simply because the CH340G is not supported officially. The Arduino IDE is meant primarily for genuine Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do is repackage the Arduino zip file with the required library and create a basic script file to install the drivers with just a couple of clicks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could shift to another board that uses the ATMEGA32u4 as this &lt;strong&gt;might&lt;/strong&gt; not require anything special. Have a look &lt;a href=&quot;http://www.aliexpress.com/item/Mini-Leonardo-Pro-Micro-ATmega32U4-5V-16MHz-Module-For-Arduino-Best-Quality/32284746884.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I don't have tested this board so you will need to check the quality and whether it works with your projects.&lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="27346" LastEditDate="2017-11-23T23:30:17.257" LastActivityDate="2017-11-23T23:30:17.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14270" PostTypeId="1" CreationDate="2015-08-17T06:35:21.697" Score="-1" ViewCount="4628" Body="&lt;p&gt;This questions has been formulated several times with not clear answer, and I wonder if there is one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it is well stablished from several sources that measuring the voltage of a battery alone is not good indicator of the State of Charge (SOC) of the battery because voltage does not decline proportional to the soc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution (&lt;a href=&quot;http://fritzing.org/projects/battery-charge-level/&quot; rel=&quot;nofollow&quot;&gt;http://fritzing.org/projects/battery-charge-level/&lt;/a&gt;) suggest measuring the voltage (with analogread) between two resistors connected to the gnd and vcc of the circuit (I presume this constantly draw power) and then choose what is the critical voltage of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my question is how to measure the SOC of a battery using units of 0 to 100% in arduino?&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2016-02-13T12:30:28.007" Title="How to measure the state of charge of a battery in arduino" Tags="|voltage-level|battery|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14271" PostTypeId="2" ParentId="14264" CreationDate="2015-08-17T06:46:57.903" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I should mention that the CH340G are also used in many &quot;Arduino Nano&quot; clones from China.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe that the Arduino company already has concerns about the number of unofficial clones (many pretending to be genuine) and have lost a considerable amount of revenue to those knock-off products. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine they are not going to make things worse for themselves by including drivers for unofficial boards, so that the job of the clone-makers is even easier.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-17T06:46:57.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14272" PostTypeId="2" ParentId="14270" CreationDate="2015-08-17T07:33:30.620" Score="1" Body="&lt;p&gt;To do it correctly, you need a coulomb counter. Something like &lt;a href=&quot;http://www.maximintegrated.com/en/products/power/battery-management/DS2740.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even that is not fully sufficient, as the charge that can be obtained from a battery depends on various factors, such as temperature and ageing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More recent batteries have somewhat flat discharge curve, when it comes to voltage, till they run flat, then the voltage drops significantly.&#xA;Which means that you would need a very accurate voltage meter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the starting point is that you must be able to count how much charge is going in and out.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-17T07:33:30.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14273" PostTypeId="1" CreationDate="2015-08-17T08:04:34.537" Score="1" ViewCount="2958" Body="&#xA;&#xA;&lt;p&gt;I am working in my project and i want to use Timer2 interrupt every 100ms to get new measurement from the output of my 5 sensors which connected to pins A1,A2,A3,A4,A5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read in some article that using delay instruction is not as good as using timers'Interruptions so, I tried this code put it didn't work properly :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup(){&#xA;&#xA;cli();&#xA;&#xA;  TCCR2A = 0;&#xA;  TCCR2B = 0;&#xA;  TCNT2  = 0;&#xA;  OCR2A = 99;&#xA;  TCCR2A |= (1 &amp;lt;&amp;lt; WGM21);&#xA;  TCCR2B |= (1 &amp;lt;&amp;lt; CS21);   &#xA;  TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A);&#xA;sei();&#xA;&#xA;Serial.begin(9600);  &#xA;}&#xA;void loop()&#xA;{&#xA;Serial.print(digitalRead(1));&#xA;Serial.print(' ');&#xA;Serial.print(digitalRead(2));&#xA;Serial.print(' ');&#xA;Serial.print(digitalRead(3));&#xA;Serial.print(' ');&#xA;Serial.print(digitalRead(4));&#xA;Serial.print(' ');&#xA;Serial.print(digitalRead(5));&#xA;Serial.println(' ');&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11856" LastEditorUserId="10794" LastEditDate="2015-08-18T03:50:13.953" LastActivityDate="2015-12-16T06:10:34.470" Title="Timer 2 interrupt with ATmega328p and make measurement in ISR" Tags="|arduino-uno|interrupt|atmega328|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14274" PostTypeId="1" CreationDate="2015-08-17T09:14:13.573" Score="1" ViewCount="241" Body="&lt;p&gt;I have an Arduino Micro and I want to connect an LCD and Bluetooth module to it. The problem I face is that there are not enough power pins for them both. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that I probably need some external power supply for them, but I have no idea how to do this properly.&lt;/p&gt;&#xA;" OwnerUserId="11858" LastEditorUserId="220" LastEditDate="2015-08-21T01:24:33.573" LastActivityDate="2016-07-16T09:18:36.197" Title="Connect multiple modules to arduino micro" Tags="|power|arduino-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14275" PostTypeId="2" ParentId="14274" CreationDate="2015-08-17T09:21:00.110" Score="1" Body="&lt;p&gt;You can design/build/deploy a power supply that provides to each board (arduino included) the voltage it needs (but it's advisable to have modules working at the same voltage level) and that should be sufficient.&#xA;As long as you have a shared Vcc-to-GND reference, it's enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To verify that the power supply you choose is ok, do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;check that the modules are compatible with its voltage (ex: all at 5V)&lt;/li&gt;&#xA;&lt;li&gt;check that the combined power consumption of each module (you get that from the datasheet) is lower than the total power output of the power supply.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additional checks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;check that the maximum voltage ripple provided by the power supply is lower than what the modules can tolerate&lt;/li&gt;&#xA;&lt;li&gt;check that the peak current the power supply can provide is larger than the combined peak current of all the other devices.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-17T09:21:00.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14276" PostTypeId="1" AcceptedAnswerId="14277" CreationDate="2015-08-17T12:01:25.610" Score="1" ViewCount="386" Body="&lt;p&gt;Why would someone buy a &lt;a href=&quot;http://1sheeld.com/&quot; rel=&quot;nofollow&quot;&gt;1sheeld&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not connect an Arduino to their smartphone using HC-06 bluetooth module and find an appropriate Android app, like for example RoboRemo. What is the advantage of using a 1sheeld?&lt;/p&gt;&#xA;" OwnerUserId="11859" LastEditorUserId="10003" LastEditDate="2015-08-21T01:21:52.387" LastActivityDate="2015-08-21T01:21:52.387" Title="HC-06 module versus 1sheeld" Tags="|bluetooth|shields|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14277" PostTypeId="2" ParentId="14276" CreationDate="2015-08-17T12:52:53.647" Score="1" Body="&lt;p&gt;Why would you buy a car when you can cobble something together from some old pram wheels, a lawnmower engine, some old scaffolding, gaffer tape and chewing gum?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because buying a car is considerably easier and more reliable.  Plus your &quot;friends&quot; don't laugh at you when they see you trying to drive it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you could cobble something together that might work using random components and other bits of software, but the work involved would be considerably more than plugging in a shield and downloading an app that is guaranteed to work perfectly with that shield.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-17T12:52:53.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14278" PostTypeId="1" CreationDate="2015-08-17T13:19:24.483" Score="1" ViewCount="152" Body="&lt;p&gt;I am struggling to choose servo motor for my project. There are two servos on ebay. Th First one is named Only &quot;Towerpro micro 9g servo&quot; and the second one that is cheaper is named as a &quot;Towerpro 9g Digital servo&quot;.&#xA;The Links are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo1: &lt;a href=&quot;http://www.ebay.in/itm/TowerPro-SG90-9g-Mini-Servo-9-gram-Servo-RC-Robotics-/201386256243?hash=item2ee38e6773&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.in/itm/TowerPro-SG90-9g-Mini-Servo-9-gram-Servo-RC-Robotics-/201386256243?hash=item2ee38e6773&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo2: &lt;a href=&quot;http://www.ebay.in/itm/251928442829?aff_source=Sok-Goog&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.in/itm/251928442829?aff_source=Sok-Goog&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Problem is that &lt;strong&gt;I am confused with the name &quot;Digital Servo&quot;&lt;/strong&gt;. Its cheaper but I a afraid that will it work as normal.&#xA;Please help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are both the &lt;strong&gt;same&lt;/strong&gt; product, but with a different name?&lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="2881" LastEditDate="2015-08-17T14:36:31.807" LastActivityDate="2015-08-17T14:36:31.807" Title="Help choosing a servo motor" Tags="|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14279" PostTypeId="2" ParentId="14278" CreationDate="2015-08-17T13:48:37.170" Score="1" Body="&lt;p&gt;Servos are digital by definition.  All you have there is two sellers that are selling the same product, but they are describing them slightly differently.  They are both SG90 servos. They are both digital (they require a digital PWM signal to control them, hence they are digital).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, here's a little hint: Add the postage costs on to the cost of the servo - you'll see there's not that much difference in price - only 3 rupees between them.  That's about ¢5 or 3p.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-17T13:48:37.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14280" PostTypeId="2" ParentId="14230" CreationDate="2015-08-17T15:17:07.097" Score="1" Body="&lt;p&gt;Ok, as @IgnacioVazquez-Abrams suggested: the configuration files for the plugins can be found in the Arduino ide preferences directory. Click the menu Arduino-&gt;Preferences (under macosx) at the bottom of the window there is the clickable path of the &lt;code&gt;preferences.txt&lt;/code&gt; file. In the same folder as that file you will find a &lt;code&gt;packages&lt;/code&gt; folder, where the plugins are downloaded.&lt;/p&gt;&#xA;" OwnerUserId="11834" LastActivityDate="2015-08-17T15:17:07.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14281" PostTypeId="1" AcceptedAnswerId="14284" CreationDate="2015-08-17T16:23:11.293" Score="1" ViewCount="822" Body="&lt;p&gt;Since it is not right to use millis() in an ISR to calculate duration of the input, Is it correct to use pulseIn()?&lt;/p&gt;&#xA;" OwnerUserId="11861" LastActivityDate="2015-09-16T21:11:14.187" Title="Is it correct to use pulseIn() in ISRs?" Tags="|isr|millis|pulsein|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14282" PostTypeId="2" ParentId="14281" CreationDate="2015-08-17T17:06:42.177" Score="0" Body="&lt;p&gt;You shouldn't really use anything much in interrupts.  Using anything that runs for a period of time is usually bad since no other interrupts can happen at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is more normal to use the interrupt to set a flag that is then checked within your main loop to determine what should be done.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-17T17:06:42.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14283" PostTypeId="1" AcceptedAnswerId="14290" CreationDate="2015-08-17T18:33:34.650" Score="1" ViewCount="364" Body="&lt;p&gt;I want to see the voltage data using &lt;code&gt;void volt();&lt;/code&gt;, when I go to the &quot;Item2SubItem3&quot; within &lt;code&gt;void menuChanged&lt;/code&gt;. Now I can only see the data &lt;em&gt;at that time&lt;/em&gt;: how can I refresh the value every second?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    // setup()...&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    //loop()...&#xA;}&#xA;&#xA;// DC Voltometer&#xA;float vPow = 4.7;&#xA;float r1 = 100000;&#xA;float r2 = 10000;&#xA;&#xA;void volt()&#xA;{&#xA;    lcd.clear();&#xA;    float v = (analogRead(0) * vPow) / 1024.0;&#xA;    float v2 = v / (r2 / (r1 + r2));&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;DC VOLTOMETER&quot;);&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(v2);&#xA;    delay(1000);&#xA;}&#xA;&#xA;void menuChanged(MenuChangeEvent changed)&#xA;{&#xA;    MenuItem newMenuItem = changed.to; // get the destination menu&#xA;    lcd.setCursor(0, 1);            // set start position for lcd&#xA;                                 // printing to the second row&#xA;&#xA;    if (newMenuItem.getName() == menu.getRoot())&#xA;    {&#xA;        lcd.print(&quot;Main Menu       &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item1&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item1           &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item1SubItem1&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item1SubItem1&quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item1SubItem2&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item1SubItem2   &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item2&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item2           &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item2SubItem1&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item2SubItem1   &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item2SubItem2&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item2SubItem2   &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item2SubItem3&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item2SubItem3   &quot;);&#xA;        delay(2000);&#xA;        volt();&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item3&quot;)&#xA;    {&#xA;        lcd.print(&quot;Item3           &quot;);&#xA;    }&#xA;    else if (newMenuItem.getName() == &quot;Item4&quot;)&#xA;    {&#xA;        lcd.clear();&#xA;        lcd.setCursor(0, 0);&#xA;        lcd.print(&quot;Item4           &quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11803" LastEditorUserId="10003" LastEditDate="2015-08-19T13:33:02.890" LastActivityDate="2015-08-21T18:28:20.667" Title="Help with LCD's menu and seeing values continuously" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14284" PostTypeId="2" ParentId="14281" CreationDate="2015-08-17T20:42:01.027" Score="1" Body="&#xA;&#xA;&lt;p&gt;It is quite OK to use &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; inside an ISR. In fact that is an excellent time to do it, because you are recording the time of the event shortly after it happened. Make sure the variable you are saving it to is &lt;code&gt;unsigned long&lt;/code&gt; and &lt;code&gt;volatile&lt;/code&gt;. Eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile unsigned long whenItHappened;&#xA;volatile bool eventHappened;&#xA;&#xA;void myISR ()&#xA;  {&#xA;  whenItHappened = millis ();&#xA;  eventHappened = true;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in your main loop you can test the &lt;code&gt;eventHappened&lt;/code&gt; flag, so you will know if this event has happened, and &lt;code&gt;whenItHappened&lt;/code&gt; is when.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is &lt;strong&gt;not&lt;/strong&gt; a good idea to use &lt;code&gt;pulseIn()&lt;/code&gt; because that can wait quite a long time for a pulse. The default timeout for &lt;code&gt;pulseIn&lt;/code&gt; is 1 second, which is far too long to wait inside an ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to time something (eg. how long it takes a ball to cross a sensor) use the interrupt twice, once to find the first event, and again to find the second.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Example code which times how long a ball passes a sensor:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte LED = 12;&#xA;const byte photoTransistor = 2;&#xA;&#xA;unsigned long startTime;&#xA;volatile unsigned long elapsedTime;&#xA;volatile boolean done;&#xA;&#xA;void ballPasses ()&#xA;{&#xA;  // if low, ball is in front of light&#xA;  if (digitalRead (photoTransistor) == LOW)&#xA;    {&#xA;    startTime = micros (); &#xA;    }&#xA;  else&#xA;    {&#xA;    elapsedTime = micros () - startTime;  &#xA;    done = true;&#xA;    }&#xA;&#xA;  digitalWrite (LED, !digitalRead (LED));  &#xA;}&#xA;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Timer sketch started.&quot;);  &#xA;  pinMode (LED, OUTPUT);&#xA;  attachInterrupt (0, ballPasses, CHANGE);&#xA;}&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (!done)&#xA;    return;&#xA;&#xA;  Serial.print (&quot;Time taken = &quot;);&#xA;  Serial.print (elapsedTime);&#xA;  Serial.println (&quot; uS&quot;);&#xA;  done = false;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That code used &lt;code&gt;micros()&lt;/code&gt; for a more accurate timing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-17T20:42:01.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14285" PostTypeId="2" ParentId="14273" CreationDate="2015-08-17T20:55:06.067" Score="1" Body="&#xA;&#xA;&lt;p&gt;Well let's start from the start ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Analog readings&lt;/h2&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;to get new measurement from the output of my 5 sensors which connected to pins A1,A2,A3,A4,A5.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.print(digitalRead(1));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is not reading &lt;strong&gt;analog&lt;/strong&gt; pin A1, it is reading &lt;strong&gt;digital&lt;/strong&gt; pin 1. If you want to read A1 you need:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.print(analogRead(1));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Check the time&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;By far the simplest thing would be to simply check the time and take a reading when 100 ms is up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(115200);  &#xA;}  // end of setup&#xA;&#xA;unsigned long lastReading;&#xA;const unsigned long INTERVAL = 100;  // ms&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  // is time up?&#xA;  if (millis () - lastReading &amp;gt;= INTERVAL)&#xA;    {&#xA;    lastReading = millis ();  // when we took this reading&#xA;    Serial.print(analogRead(1));&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(analogRead(2));&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(analogRead(3));&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(analogRead(4));&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(analogRead(5));&#xA;    Serial.println();&#xA;    }  // end of if time up&#xA;&#xA;  // do other things here&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I increased the baud rate to 115200. Why use 9600 when you are trying to print 5 x 4 characters every 100 ms? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Using timers&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you really want to use timers (and I don't see what they achieve here) I have a &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;page about timers&lt;/a&gt; that describes using them, and interrupts, in some depth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The very least you would need is a timer 2 &quot;compare A&quot; interrupt like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR (TIMER2_COMPA_vect) &#xA;  {&#xA;  // Timer 2 has reached its comparison value&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-17T20:55:06.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14286" PostTypeId="2" ParentId="10152" CreationDate="2015-08-17T23:08:29.243" Score="2" Body="&lt;p&gt;The pins could be wrong for ATMega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NRF24L01 - Arduino UNO&lt;br&gt;&#xA;GND - GND&lt;br&gt;&#xA;VCC - 3.3V&lt;br&gt;&#xA;CE - 7&lt;br&gt;&#xA;CSN - 8&lt;br&gt;&#xA;SCK - 13&lt;br&gt;&#xA;MOSI - 11&lt;br&gt;&#xA;MISO - 12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or B. You need to connect a 500uF electrolytic capacitor to your NRF24L01+ VCC and GND pins directly. To reduce noise related issues. With clone arduinos/cheap regulators/clone NRFs then noise might start creating issues especially with receiving. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-01-31T14:28:25.677" LastActivityDate="2016-01-31T14:28:25.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14287" PostTypeId="2" ParentId="8508" CreationDate="2015-08-17T23:10:36.757" Score="3" Body="&lt;p&gt;Your payload is too big. You will have to split it to smaller pieces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: If you'd use a library like RF24Mesh then you'd not have to worry about it.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-10-17T20:13:30.750" LastActivityDate="2015-10-17T20:13:30.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14288" PostTypeId="2" ParentId="13291" CreationDate="2015-08-17T23:15:28.577" Score="-1" Body="&lt;p&gt;It seems to me you are running out of memory (SRAM).  &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Memory&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Memory&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2015-08-17T23:15:28.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14289" PostTypeId="2" ParentId="12450" CreationDate="2015-08-17T23:18:44.767" Score="0" Body="&lt;p&gt;The issue here is that the Ethernet chip locks the SPI bus thus making it impossible for NRF24L01+ to communicate with the arduino properly. Please use softSPI to fix this.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2015-08-17T23:18:44.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14290" PostTypeId="2" ParentId="14283" CreationDate="2015-08-18T00:03:53.547" Score="0" Body="&lt;p&gt;As Gerben implied in a comment, &lt;code&gt;menuChangeEvent&lt;/code&gt; is called only when the menu selection changes.  Thus, your voltmeter readout will print only whenever you change the menu selection to Item2SubItem3.  The code shown below illustrates how to modify your &lt;code&gt;loop()&lt;/code&gt; so that it checks the menu selection once per second.  Each second the main loop will do whatever function is currently selected, such as displaying a current voltmeter reading.  Note, you can make the menu decoding shorter and less tedious as shown in the answer, and can put variable declarations near where they are used instead of in random places.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;}  // setup()...&#xA;&#xA;// DC voltmeter reading&#xA;void volt () {&#xA;  const float vPow = 4.7, r1 = 100000, r2 = 10000;&#xA;  lcd.clear();&#xA;  float v = (analogRead(0) * vPow) / 1024.0;&#xA;  float v2 = v / (r2 / (r1 + r2));&#xA;  lcd.setCursor (0,0);&#xA;  lcd.print(&quot;DC Voltmeter&quot;);&#xA;  lcd.setCursor (0,1);&#xA;  lcd.print (v2);&#xA;  // Don't delay(1000) since loop() takes care of delay.&#xA;}&#xA;&#xA;long int second = 0;&#xA;uint8_t itemcode = 0; // Will be number nm for Item n, Subitem m&#xA;int passnumber = 0;&#xA;void menuChanged(MenuChangeEvent changed) {&#xA;  MenuItem menuitem = changed.to; //get the destination menu&#xA;  String itemname = menuitem.getName();&#xA;  lcd.clear();        // Make printing spaces at line ends unnecessary&#xA;  lcd.setCursor(0,1);         //set lcd printing position = second row&#xA;  if(newMenuItem.getName() == menu.getRoot()){&#xA;    lcd.print(&quot;Main Menu&quot;);&#xA;    itemcode = 0;&#xA;  } else {&#xA;    lcd.print(itemname);&#xA;    itemcode = 10*(itemname[4] &amp;amp; 7);&#xA;    if (itemname.length() &amp;gt; 5)&#xA;      itemcode += itemname[itemname.length()-1] &amp;amp; 7;&#xA;  }&#xA;  passnumber = 0; // Actions can test passnumber if they like&#xA;  second = 0; // Cause actions to take place now&#xA;}&#xA;&#xA;void loop() {&#xA;  long int now = millis()/1000; // Get elapsed-seconds&#xA;  if (now == second) return;    // Only do stuff once per second&#xA;  // Update to current second and do chosen menu item&#xA;  second = now;&#xA;  switch (itemcode) {&#xA;  case  0: break;&#xA;  case 10: break;&#xA;  case 11: break; // Fill in with code for different cases&#xA;  case 12: break;&#xA;  case 20: break;&#xA;  case 21: break;&#xA;  case 22: break;&#xA;  case 23:    // Item 2, subitem 3, read voltmeter&#xA;    volt();&#xA;    break;&#xA;  case 30: break;&#xA;  case 40: break;&#xA;  }&#xA;  // You can test passnumber to control for cases that only go once&#xA;  ++passnumber;&#xA;} // end of loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; I moved the declaration of &lt;code&gt;second&lt;/code&gt; and added &lt;code&gt;second = 0&lt;/code&gt; within &lt;code&gt;menuChanged()&lt;/code&gt; to decrease latency between a menu item being selected and its action taking place.  Without &lt;code&gt;second&lt;/code&gt; being zeroed in &lt;code&gt;menuChanged()&lt;/code&gt;, up to a second could pass between an item's selection and its action; latency would average 0.5 seconds, which is undesirable in a user interface. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-08-21T18:28:20.667" LastActivityDate="2015-08-21T18:28:20.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14291" PostTypeId="2" ParentId="14276" CreationDate="2015-08-18T02:22:51.743" Score="0" Body="&lt;p&gt;Giving an equally biased answer as @Majenko, from the other side:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because they're lazy, they don't know anything about electronics, and they don't want to. And they have more money than they know what to do with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am horrified at people shelling out for an &quot;Arduino Temperature Sensor&quot;, &quot;Arduino Shift Register&quot;, or &quot;Arduino LED&quot;, each of which is a generic component soldered on to a board, with pins, at a 1000% markup&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also question the claim that &quot;cobbled together&quot; items are more reliable, or are less likely to have people laugh at you - if you want it to look nice, put it in a nice box (this applies both to &quot;pre-made&quot; items, and to cobbled together).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also learn a lot more from making it yourself; you will learn how things work, and you have a better idea and have the opportunity to fix when things go wrong. Your projects will also be a lot smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want something that &quot;just works&quot;, go buy an ipad. Then, when it doesn't work, throw it in the rubbish and buy a new one. And if you want it to do something it doesn't do, tough luck.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-18T02:22:51.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14292" PostTypeId="2" ParentId="13778" CreationDate="2015-08-18T02:34:51.783" Score="0" Body="&lt;p&gt;I have had a lot of success using an off-the-shelf power bank - they're easy to get, already have charging circuits (from USB), and are at the right voltage (+5V). You can plug the power bank directly into the USB port of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem I've had is that some power banks shut down if there is not enough current being drawn - a resistor from +5V to GND solves that problem (make sure you work out how many watts your resistor is letting through, to make sure it can dissipate the heat - I used a 100Ohm resistor, at 5v; I put &quot;Ohms Law calculator&quot; into google, filled in 5V &amp;amp; 100 Ohm, and found that it needed to be a 1/4 watt resistor - perfect! I also noted that it drew 50 milli amps AKA 0.05 amps. I tried resistors with a higher resistance e.g. 200 Ohm, and the power bank powered down. If your project is drawing more power (continuously!) then you might get away with a higher resistance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My power bank can supply 1.5 Amps, which should be plenty for your project. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-18T02:34:51.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14293" PostTypeId="1" CreationDate="2015-08-18T03:46:15.597" Score="0" ViewCount="256" Body="&lt;p&gt;I am A Newbie to Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Windows 7 PC. Last Time I bought an Arduino Uno Clone but after working for a day, it stopped detecting on the port. So I bought a new Clone Of different brand. Now I Want in which sequence should I install its drivers, Coonect it, Unzip Arduino IDE...Reboot??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont want a problem this time. Another question is Should I first connect the clone and then Install its drivers Or first install drivers and then plug the board? When Is the reboot required?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product Link : &lt;a href=&quot;https://m.ebay.in/itm?itemId=121708881208&quot; rel=&quot;nofollow&quot;&gt;https://m.ebay.in/itm?itemId=121708881208&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please Explain...&#xA;Thanks In Advance&lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="11772" LastEditDate="2015-08-18T03:52:37.247" LastActivityDate="2016-02-24T02:44:37.357" Title="Help Connecting Arduino Uno To Computer" Tags="|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14294" PostTypeId="2" ParentId="14293" CreationDate="2015-08-18T06:24:13.143" Score="0" Body="&lt;p&gt;I would like to start by pointing out that you are using a clone. The arduino IDE by default does support clones. Just install your port drivers that's far enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason your board got spoilt the last time definitely was not cause you did not install the drivers in the right order. It could be due to many reasons, few listed below:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Poor PCB quality&lt;/li&gt;&#xA;&lt;li&gt;Humidity&lt;/li&gt;&#xA;&lt;li&gt;Cheap USB to UART converter. &lt;/li&gt;&#xA;&lt;li&gt;Short circuit in your connection&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So what I recommend is the either the use of genuine arduino boards if you can afford. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Most likely its only the USB to UART (CH340G) that has been destroyed, you could buy a hot air station and replace the IC, it is a much cheaper solution. &lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="-1" LastEditDate="2015-10-24T19:40:32.773" LastActivityDate="2015-10-24T19:40:32.773" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14295" PostTypeId="1" CreationDate="2015-08-18T06:58:15.853" Score="0" ViewCount="432" Body="&lt;p&gt;I have an 2 analog signal, and I want to calculate the difference between 2 signals (A0 and A1), then integrate an analog, but it doesn't work (I just started studying Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please could you show me how to deal with this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float analogInPin = A0;&#xA;float analogInPin1 = A1;&#xA;float analogOutPin = DAC1;&#xA;float FeqIn, FeqIn1, FeqIn2, FeqIn3, FeqOut, w, Triarea, Recarea, area, n, y, t;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); // use the serial port &#xA;}&#xA;&#xA;void loop() {&#xA;  FeqIn1 = analogRead(analogInPin);&#xA;  FeqIn2 = analogRead(analogInPin1);&#xA;  FeqIn3 = FeqIn1 - FeqIn2&#xA;  // integration&#xA;  area(1) = 0;&#xA;  y(1) = 0;&#xA;  for (n = 1; n = t; t++) {&#xA;    Triarea(n+1) = (0.5*t(2))*(FeqIn3(n+1) - FeqIn3(n));&#xA;    Recarea(n+1) = t(2)*(FeqIn3(n));&#xA;    area(n+1) = (Triarea(n+1) + Recarea(n+1)) + area(n);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error message is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Windows 8.1), Board: &quot;Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;&#xA;&#xA;_02.ino:3: error: 'DAC1' was not declared in this scope&#xA;_02.ino.ino: In function 'void loop()':&#xA;_02.ino:20: error: expected ';' before 'area'&#xA;_02.ino:21: error: 'y' cannot be used as a function&#xA;_02.ino:24: error: 'Triarea' cannot be used as a function&#xA;_02.ino:24: error: 't' cannot be used as a function&#xA;_02.ino:24: error: 'FeqIn3' cannot be used as a function&#xA;_02.ino:24: error: 'FeqIn3' cannot be used as a function&#xA;_02.ino:25: error: 'Recarea' cannot be used as a function&#xA;_02.ino:25: error: 't' cannot be used as a function&#xA;_02.ino:25: error: 'FeqIn3' cannot be used as a function&#xA;_02.ino:26: error: 'area' cannot be used as a function&#xA;_02.ino:26: error: 'Triarea' cannot be used as a function&#xA;_02.ino:26: error: 'Recarea' cannot be used as a function&#xA;_02.ino:26: error: 'area' cannot be used as a function&#xA;'DAC1' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11873" LastEditorUserId="10003" LastEditDate="2015-08-21T12:16:18.477" LastActivityDate="2015-08-24T11:55:03.370" Title="Integrating an analog signal using Arduino Due" Tags="|arduino-due|signal-processing|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14296" PostTypeId="2" ParentId="13778" CreationDate="2015-08-18T07:50:12.683" Score="1" Body="&lt;p&gt;Selecting a power supply involves considering the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Voltage Requirement&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Current Required&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. Running duration&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4. Cost&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Voltage Requirement:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the list of items specified all of your items except the microSD card (which works at 3.3V) works at 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Current Requirement:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO: &lt;a href=&quot;http://gadgetmakersblog.com/arduino-power-consumption/&quot; rel=&quot;nofollow noreferrer&quot;&gt;about 50mA&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9G servo motor: &lt;a href=&quot;http://www.addicore.com/2pcs-Addicore-SG90-Mini-Servo-p/113.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;730mA peak&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED 5mm: &lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/LED/COM-09590-YSL-R531R3D-D2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;20mA*2 = 40mA&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;microSD Card Reader: &lt;a href=&quot;http://media.digikey.com/pdf/Data%20Sheets/M-Systems%20Inc%20PDFs/SD%20Card%20Prod%20Family%20OEM%20Manual.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;200mA peak&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaker: &lt;a href=&quot;https://electronics.stackexchange.com/questions/129277/how-many-volts-can-a-1-watt-8-ohm-speaker-take&quot;&gt;350mA&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Total Current: 1.370 Amps&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Running Duration:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I want this device to run for 1 hour straight, in order to this I will need a battery supplying 5V 1370mAh and a &lt;a href=&quot;http://www.revolectrix.com/tech_data/lipoCalc/Battery_C_Rating.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;1C rating&lt;/a&gt;. So if you want your device to run longer you will need to get a battery with a higher capacity (for 2 hours 2740 mAh and so on)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont think i need to mention much in this criteria&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these requirements your easiest solution is to use a USB power bank with 2000mAh or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a protoboard solder 1x USB male, 1x USB female, 2x header pins. Solder All the positives together and all the negative together. And now you have a breakout for the power rails from the USB as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power the Arduino via usb, microsd card via the 3.3V on the arduino and the rest via the breakout pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using lipo batteries. Lipo batteries have the advantage of having a large capacity in a small package (or a high power to weight ratio). In order to use this you will need a voltage regulator to get 5V. Please note that as per the calculation you will need a total of 1.37A to power your device at peak, this &lt;strong&gt;cannot&lt;/strong&gt; be done via the on board regulator of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In total you will the following components to get this to work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LiPo battery&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltage regulator&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LiPo Charger&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution 3:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Alkaline battery. You can refer to the &lt;a href=&quot;https://learn.adafruit.com/minty-boost/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;Minty Boost&lt;/a&gt; tutorial over at Adafruit to learn about this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a &lt;strong&gt;headache free solution&lt;/strong&gt; to your problem, buy a &lt;strong&gt;USB power bank&lt;/strong&gt; , but if you want a more &lt;strong&gt;customizable and low cost solution&lt;/strong&gt; go for the &lt;strong&gt;LiPo battery&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you dont need a portable solution. Go for a wall adapter 5V/2A, thats pretty much every high end mobile phone charger&lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-08-18T07:50:12.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14298" PostTypeId="1" AcceptedAnswerId="14317" CreationDate="2015-08-18T09:25:05.253" Score="1" ViewCount="10271" Body="&lt;p&gt;&lt;strong&gt;Where do I find the pins relative to timers of each individual Arduino microcontroller?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I like Arduino's I already have various samples of them. The one I mostly use is the Uno and Micro for now... I'm planning to also get a Mega and others. Most simple things work on all devices, but if you start with complex code to fasten up things, every device is a little different.&#xA;A problem I could not solve for days now is the relation between pins and timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot find any information about the Arduino Micro. I also don't know exactly what the proper keywords are that I need to find the relation between timers and pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&#xA;A PWM driver multiplexing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I for now just got some stuff from my local dealer I have no access to shift registers, PWM drivers and other proper integrated circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I used the Arduino as a PWM driver for 8 RGB or 24 (3*8) white LEDs.&#xA;The code works on Arduino Uno. But as the &lt;strong&gt;Arduino Micro has no &lt;em&gt;Timer2&lt;/em&gt;&lt;/strong&gt;, &lt;code&gt;TCCR2B&lt;/code&gt;, I cannot use the same code on the Arduino Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I understand the code (I wrote a lot in other languages...), some of the Atmel chip specific parameters are not clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This function sets the prescaler of the timer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setPwmFrequency(int pin, int divisor){&#xA;&#xA;  byte mode;&#xA;  if(pin==5||pin==6||pin==9||pin==10){&#xA;    switch(divisor){&#xA;      case 1:mode=0x01;break;&#xA;      case 8:mode=0x02;break;&#xA;      case 64:mode=0x03;break;&#xA;      case 256:mode=0x04;break;&#xA;      case 1024:mode=0x05;break;&#xA;      default:return;&#xA;    }&#xA;    if(pin==5||pin==6){&#xA;      TCCR0B=TCCR0B&amp;amp;0b11111000|mode;&#xA;    } else{&#xA;      TCCR1B=TCCR1B&amp;amp;0b11111000|mode;&#xA;    }&#xA;  }else if(pin==3||pin==11){&#xA;    switch(divisor){&#xA;      case 1:mode=0x01;break;&#xA;      case 8:mode=0x02;break;&#xA;      case 32:mode=0x03;break;&#xA;      case 64:mode=0x04;break;&#xA;      case 128:mode=0x05;break;&#xA;      case 256:mode=0x06;break;&#xA;      case 1024:mode=0x7;break;&#xA;      default:return;&#xA;    }&#xA;    TCCR2B=TCCR2B&amp;amp;0b11111000|mode;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First of all, I probably don't even need this function as soon I know what frequency I want, and so I probably need only two lines to set my three (RGB) pins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Arduino Uno timer setup for pin 9, 10, and 11&#xA;TCCR1B=TCCR1B&amp;amp;0b11111000|0x01; // Pin 9,10&#xA;TCCR2B=TCCR2B&amp;amp;0b11111000|0x01; // Pin 11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Correct, I need to set &lt;code&gt;TCCR1B&lt;/code&gt; only one time?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What does the &lt;code&gt;0b11111000&lt;/code&gt; refer to?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In the setup function there is also this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TIMSK2 = 1&amp;lt;&amp;lt;TOIE2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;What does this do?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;While the above three questions are not so important until it works, &lt;strong&gt;I need to understand how I can convert those timers to work with Arduino Micro&lt;/strong&gt;, but also later with other Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;On Arduino Micro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no timer 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do pin 9, 10, and 12 have the same timer?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;??????=??????&amp;amp;0b11111000|0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also if I understand correctly the Arduino Micro has:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A higher PWM range 1024 vs 255 (UNO)??&lt;/li&gt;&#xA;&lt;li&gt;A much higher frequency available in on Timer4 only for pin 13&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So is there somewhere a table describing the differences between all Arduino timers?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Full working (on Arduino Uno) code.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char Prescaler=0;&#xA;unsigned char CurrentLED=0;&#xA;unsigned char LEDValues[8][3];&#xA;unsigned char ports[8]={&#xA;  0b00000100,&#xA;  0b00001000,&#xA;  0b00010000,&#xA;  0b00100000,&#xA;  0b01000000,&#xA;  0b10000000,&#xA;  0b00000001,&#xA;  0b00010000&#xA;};//PINS 2,3,4,5,6,7,8,12&#xA;&#xA;#define PrescalerOverflowValue 4&#xA;&#xA;ISR(TIMER2_OVF_vect){&#xA;  if(Prescaler&amp;lt;PrescalerOverflowValue){&#xA;    Prescaler++;&#xA;  }else {&#xA;    Prescaler=0;&#xA;    Multiplex();&#xA;  }&#xA;}&#xA;&#xA;void Multiplex(void){&#xA;  PORTD&amp;amp;=0b00000011;&#xA;  PORTB&amp;amp;=0b11101110;&#xA;  analogWrite(9,255-LEDValues[CurrentLED][0]);&#xA;  analogWrite(10,255-LEDValues[CurrentLED][1]);&#xA;  analogWrite(11,255-LEDValues[CurrentLED][2]);&#xA;  CurrentLED&amp;lt;6?(PORTD|=ports[CurrentLED]):(PORTB|=ports[CurrentLED]);&#xA;  CurrentLED++;&#xA;  if(CurrentLED&amp;gt;7)CurrentLED=0;&#xA;}&#xA;void setPwmFrequency(int pin, int divisor){&#xA;  byte mode;&#xA;  if(pin==5||pin==6||pin==9||pin==10){&#xA;    switch(divisor){&#xA;      case 1:mode=0x01;break;&#xA;      case 8:mode=0x02;break;&#xA;      case 64:mode=0x03;break;&#xA;      case 256:mode=0x04;break;&#xA;      case 1024:mode=0x05;break;&#xA;      default:return;&#xA;    }&#xA;    if(pin==5||pin==6){&#xA;      TCCR0B=TCCR0B&amp;amp;0b11111000|mode;&#xA;    }else{&#xA;      TCCR1B=TCCR1B&amp;amp;0b11111000|mode;&#xA;    }&#xA;  }else if(pin==3||pin==11){&#xA;    switch(divisor){&#xA;      case 1:mode=0x01;break;&#xA;      case 8:mode=0x02;break;&#xA;      case 32:mode=0x03;break;&#xA;      case 64:mode=0x04;break;&#xA;      case 128:mode=0x05;break;&#xA;      case 256:mode=0x06;break;&#xA;      case 1024:mode=0x7;break;&#xA;      default:return;&#xA;    }&#xA;    TCCR2B=TCCR2B&amp;amp;0b11111000|mode;&#xA;  }&#xA;}&#xA;&#xA;void setup(void){&#xA;&#xA;  pinMode(2,OUTPUT);//1&#xA;  pinMode(3,OUTPUT);//2&#xA;  pinMode(4,OUTPUT);//3&#xA;  pinMode(5,OUTPUT);//4&#xA;  pinMode(6,OUTPUT);//5&#xA;  pinMode(7,OUTPUT);//6&#xA;  pinMode(8,OUTPUT);//7&#xA;  pinMode(12,OUTPUT);//8&#xA;  pinMode(9,OUTPUT);//red&#xA;  pinMode(10,OUTPUT);//green&#xA;  pinMode(11,OUTPUT);//blue&#xA;  setPwmFrequency(9,8);&#xA;  setPwmFrequency(10,8);&#xA;  setPwmFrequency(11,8);&#xA;  TIMSK2=1&amp;lt;&amp;lt;TOIE2;&#xA;}&#xA;&#xA;void loop(void){&#xA;  for(int i=0;i&amp;lt;8;i++){&#xA;    //LEDValues[i][0]; // Red&#xA;    //LEDValues[i][1]; // Green&#xA;    //LEDValues[i][2]; // Blue&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11876" LastEditorUserId="510" LastEditDate="2017-04-28T07:19:17.553" LastActivityDate="2018-04-05T14:15:09.173" Title="Arduino Uno vs Arduino Micro timers → pins" Tags="|arduino-uno|timers|arduino-micro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14299" PostTypeId="2" ParentId="14295" CreationDate="2015-08-18T09:29:43.357" Score="0" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;float FeqIn, FeqIn1, FeqIn2, FeqIn3, FeqOut, w, Triarea, Recarea, area, n, y, t;&#xA;&#xA;...&#xA;&#xA;      Triarea(n+1) = (0.5*t(2))*(FeqIn3(n+1) - FeqIn3(n));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I honestly don't know what you are doing here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Triarea is a float, right? A single variable of type &lt;em&gt;float&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;      Triarea(n+1) = (0.5*t(2))*(FeqIn3(n+1) - FeqIn3(n));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Triarea(n+1)&lt;/code&gt; looks like you are calling a function called Triarea with the argument n+1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That doesn't make any sense because it isn't a function.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Maybe you mean to treat it as an array?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Triarea[n+1] = (0.5*t[2])*(FeqIn3[n+1] - FeqIn3[n]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you have not declared those variables as arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is pure guesswork what is going on in your mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However your syntax certainly explains the error messages, for example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;_02.ino:24: error: 'Triarea' cannot be used as a function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If I may suggest, read a tutorial on basic C++ programming.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-18T09:29:43.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14300" PostTypeId="2" ParentId="14295" CreationDate="2015-08-18T09:32:50.043" Score="1" Body="&lt;p&gt;I think your main problem here is a fundamental lack of understanding about C++.  There's numerous basic errors in your code.  Let's take a look at them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FeqIn3 = FeqIn1 - FeqIn2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All C++ statements must be terminated by a &lt;code&gt;;&lt;/code&gt; otherwise it doesn't know where one statement finishes and the next one begins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;area(1) = 0;&#xA;(and many others)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have declared a bunch of float variables in the global scope.  You are then trying to use those float variables as functions, and on top of that you are then trying to assign a value to the return value of that function.  That makes absolutely no logical sense whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you meant to be using arrays of float values.  Arrays are denoted by &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; not &lt;code&gt;(&lt;/code&gt; and &lt;code&gt;)&lt;/code&gt;.  Further, they have to be defined as arrays, including the size of the array, not a single value.  Also in C++ arrays are &lt;em&gt;zero based&lt;/em&gt; (i.e., they start at index 0 not index 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, &lt;code&gt;area&lt;/code&gt; could be defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float area[1024]; // 1024 floating point values in an array&#xA;// ...&#xA;area[0] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Recarea(n+1) = t(2)*(FeqIn3(n));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't even know what to make of this bit...  If I assume you should replace &lt;code&gt;(...)&lt;/code&gt; with &lt;code&gt;[...]&lt;/code&gt; for indices to arrays, it still makes no sense.  You're calculating a single value (&lt;code&gt;FreqIn3 = FreqIn1 - FreqIn2&lt;/code&gt;) then using that as an array (&lt;code&gt;FreqIn3[n]&lt;/code&gt;) which makes absolutely no sense to me at all.  Then you're using another value &lt;code&gt;t&lt;/code&gt; which you are incrementing (incorrectly, more on that later), which again you are then trying to use as an array (&lt;code&gt;t[2]&lt;/code&gt;).  Which is it - arrays or single values? And how do you increment an entire array?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the incrementing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (n = 1; n = t; t++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;n&lt;/code&gt; starts at the value 1.  While &lt;code&gt;n&lt;/code&gt; is assigned the value &lt;code&gt;t&lt;/code&gt;, increment &lt;code&gt;t&lt;/code&gt;.  Now, does that sound logical?  And what is &lt;code&gt;t&lt;/code&gt;? when that loop starts?  It has no defined value, so it could be anything at all.  And when does the loop end?  Well, since you're using float values for your counters (which is idiotic at best) you won't ever get any integer wraparound, so &lt;code&gt;t&lt;/code&gt; will never equal &lt;code&gt;0&lt;/code&gt; and consequently the result of assigning &lt;code&gt;t&lt;/code&gt; to &lt;code&gt;n&lt;/code&gt; will never be &lt;code&gt;0&lt;/code&gt;, so the loop will never end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you need to go back to absolute basics and learn a bit more about syntax of C++, arrays, functions, loops, etc, before embarking on something complex like signal integration.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-18T09:32:50.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14302" PostTypeId="1" CreationDate="2015-08-18T10:37:07.313" Score="-1" ViewCount="850" Body="&lt;p&gt;Im making a small, controllable toy car. Im using the L239D motor controller to drive 2 6V DC motors, which I intend to control with a joystick. Using the L239D state table (shown below), I can make the car move forward, backward, left and right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thats all good, but I want the car to do all the bits in between those movements (drifting slightly left/right etc depending on joystick location). So far I have two separate functions that look at the x-axis and y-axis value from the joystick, scale them and apply a pwm signal. This works fine when only one function is on but ofcourse, they overwrite each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea then was to create a variable that takes the displacement of the joystick in both axis and divides them, this will be the duty cycle. I then have a delay at the end of each loop which is sized by this duty cycle. The only problem is that the motor stutters a lot and it dosent work very well at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if anyone has a better idea for getting full motor control with the joy stick rather than the simple block movements (full right, full left, full forward, full backward). Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Aw5R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Aw5R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/JFiwV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JFiwV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11326" LastActivityDate="2015-08-18T12:13:57.977" Title="Using L239D with a joystick" Tags="|arduino-uno|motor|remote-control|electronics|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14303" PostTypeId="2" ParentId="14302" CreationDate="2015-08-18T11:10:06.953" Score="3" Body="&lt;p&gt;The problem here is that you lack the concept of speed with your motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not enough to turn the motors on or off in the right direction, you have to control the speed of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your left/right control is fine as it is (without the delay in your loop), which is controlled by the inputs being either on or off to define the flow of current through the motor.  Now all you need to do is control the speed of the motors while they are in those states.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately there is another pair of inputs to the driver chip that you have completely overlooked: &lt;code&gt;ENABLE1&lt;/code&gt; and &lt;code&gt;ENABLE2&lt;/code&gt;.  These can accept a PWM signal and define the ratio of on-to-off for the motor on that channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can connect a PWM signal to each of those inputs (all the other inputs are just straight digital ON/OFF signals), and setting the duty cycle of those PWM signals defines the speed of the motor (0 = stop, 255 = full speed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now all you need to do is interpret the joystick properly, for instance:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Between centre and half-left: Left = Stop, Right = Forward, Enable Right = percentage of half the joystick range&lt;/li&gt;&#xA;&lt;li&gt;Between half-left and full-left: Left = Reverse, Right = Forward, Enable Right = 100%, Enable Left = percentage of half the remaining joystick range&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And of course reversed for right turns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could incorporate into that the forward/backward position of the joystick to add an overall forward or backward speed to the motors so you have full 2D motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be better to visualise the joystick in &lt;a href=&quot;https://en.wikipedia.org/wiki/Polar_coordinate_system&quot; rel=&quot;nofollow&quot;&gt;Polar&lt;/a&gt; space instead of simple Cartesian space.  Convert the X/Y coordinates of the joystick's position into an angle and distance from the centre point.  The distance defines the overall speed, and the angle defines how that speed is split between the left and right motors (enable pins), and the direction of those motors (input pins).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-18T12:13:57.977" LastActivityDate="2015-08-18T12:13:57.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14304" PostTypeId="2" ParentId="14054" CreationDate="2015-08-18T12:26:51.397" Score="0" Body="&lt;p&gt;Got it! After doing the requisite amount of research... I've developed a &lt;em&gt;much&lt;/em&gt; improved checking system which allows me to truly demarcate between messages during running status much like Nick Gammon's code. While the code seems to work perfectly now it was still a bit glitchy when I tried it the other day. Perhaps I accidentally fixed it, most likely it'll crop back up again. How does it look?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//MIDI_Input_0x01    &#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(0,1);&#xA;&#xA;const int LED = 2;&#xA;&#xA;int isStatus();&#xA;int isAftertouch();&#xA;int isRealTimeCategory();&#xA;&#xA;int dataByte;&#xA;int velocityByte;&#xA;int result;&#xA;&#xA;void setup()&#xA;{&#xA;  mySerial.begin(31250);&#xA;  pinMode(LED, OUTPUT);&#xA;&#xA;&#xA;  digitalWrite(LED, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LED, LOW);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  while(mySerial.available())&#xA;  {&#xA;    //This is the protocol for reading new stuff&#xA;    byte myByte = mySerial.read();&#xA;    if(isRealTimeCategory(myByte))&#xA;    {&#xA;      ;&#xA;    }&#xA;    else&#xA;    {&#xA;      if(isStatus(myByte))&#xA;      {&#xA;&#xA;        result = (myByte | 0x80);       //0b10000000&#xA;        switch(result)&#xA;        {&#xA;          case 0b10000000:&#xA;            digitalWrite(LED, LOW);&#xA;            break;&#xA;          case 0b10010000:&#xA;            digitalWrite(LED, HIGH);&#xA;            break;  &#xA;          case 0b10100000:&#xA;            break;&#xA;          case 0b10110000:&#xA;            break;&#xA;          case 0b11000000:&#xA;            break;&#xA;          case 0b11010000:&#xA;            break;&#xA;          case 0b11100000:&#xA;            break;&#xA;          case 0b11110000:&#xA;            break;&#xA;        }&#xA;      }&#xA;      else&#xA;      {&#xA;        byte myByte = mySerial.read();  //This is the protocol for reading new stuff&#xA;        if(isRealTimeCategory(myByte))&#xA;        {&#xA;          ;&#xA;        }&#xA;        else&#xA;        {&#xA;          if(myByte &amp;gt; 0)&#xA;      {&#xA;        digitalWrite(LED, HIGH);&#xA;      }&#xA;      else&#xA;      {&#xA;        digitalWrite(LED, LOW);&#xA;      }&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}  //END&#xA;&#xA;/**********************&#xA;//function declarations&#xA;**********************/&#xA;&#xA;int isStatus(int b)&#xA;{&#xA;  if( (b &amp;amp; 0x80) == 0x80)&#xA;  {&#xA;    return 1;&#xA;  }&#xA;  else if( (b &amp;amp; 0x80) == 0)&#xA;  {&#xA;  return 0;&#xA;  }&#xA;}   &#xA;&#xA;int isAftertouch(int b)&#xA;{&#xA;  if( (b &amp;amp; 0xf0) == 0xa0)&#xA;  {&#xA;    return 1;&#xA;  }&#xA;  else //if( (b &amp;amp; 0xf0) != 0xa0)&#xA;  {&#xA;    return 0;&#xA;  }&#xA;}&#xA;&#xA;int isRealTimeCategory(int b)&#xA;  {&#xA;    if(b &amp;gt;= 0xF8)&#xA;    {&#xA;      return 1;&#xA;    }&#xA;    else&#xA;    {&#xA;      return 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On top of this, I managed to tweak the code to output particular values to a shift register as I had initially intended. The method I use to differentiate between note and velocity bytes is less than ideal but works on my keyboard. Because of certain limitations it only works over a range of 13 notes but that's fine for now. Code and flowchart below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//              MIDI_Input_0x02&#xA;&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;             //The Attiny does not natively support the Serial library so this&#xA;                        //is the work-around.&#xA;SoftwareSerial mySerial(0,1);&#xA;&#xA;const int latchPin = 2;&#xA;const int clockPin = 3;&#xA;const int dataPin = 4;&#xA;&#xA;const int gate = 1;             //Note that initially, this was the tx pin.&#xA;                                //In this configuration absolutely every Attiny85 pin is used.&#xA;int isStatus();&#xA;int isAftertouch();&#xA;int isRealTimeCategory();&#xA;&#xA;int result;&#xA;int dataByte;&#xA;int velocityByte;&#xA;&#xA;//int noteApprox[13] = {1,3,5,7,9,12,14,17,20,23,26,29,32};&#xA;int noteApprox[13] = {32, 29, 26, 23, 20, 17, 14, 12, 9, 7, 5, 3, 1};&#xA;    //The above numbers are approximately 100 cents&#xA;    //apart from one another. This corresponds to notes of a scale.&#xA;    //They descend here because their corresponding&#xA;    //voltages will later become inverted in the circuit.&#xA;&#xA;void setup()&#xA;{&#xA;  mySerial.begin(31250);&#xA;&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);  &#xA;  pinMode(gate, OUTPUT);        //'Gate' controls the level of the&#xA;                    //envelope generators. The signal&#xA;                    //becomes inverted later.&#xA;&#xA;  digitalWrite(gate, HIGH);     //A simple test to ensure the&#xA;  delay(1000);              //circuit is wired correctly&#xA;  digitalWrite(gate, LOW);&#xA;  delay(1000);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  while(mySerial.available())&#xA;  {&#xA;    //This is the protocol for reading new stuff&#xA;    byte myByte = mySerial.read();      //Read the oldest byte in the buffer&#xA;    if(isRealTimeCategory(myByte))      //See Function Notes&#xA;    {&#xA;      ;&#xA;    }&#xA;    else&#xA;    {&#xA;      if(isStatus(myByte))               //See Function Notes&#xA;      {&#xA;        result = (myByte | 0x80);       //0b10000000&#xA;        switch(result)&#xA;        {&#xA;          case 0b10000000:&#xA;            digitalWrite(gate, LOW);            //0b10000000 is the note Off&#xA;            break;                      //message&#xA;          case 0b10010000:&#xA;            digitalWrite(gate, HIGH);           //10010000 is the note On&#xA;            break;                      //message&#xA;          case 0b10100000:          //Absolutely none of these are important.&#xA;            break;&#xA;          case 0b10110000:&#xA;            break;&#xA;          case 0b11000000:&#xA;            break;&#xA;          case 0b11010000:&#xA;            break;&#xA;          case 0b11100000:&#xA;            break;&#xA;          case 0b11110000:&#xA;            break;&#xA;        }&#xA;      }&#xA;      else                                     //This is the part where I assume it's a data byte.&#xA;      {                                        //this might be causing problems...&#xA;        if( (myByte &amp;gt; 48) &amp;amp;&amp;amp; (myByte &amp;lt; 61) )         //&amp;lt;-- That's 13 notes. An octave and an extra &#xA;        {&#xA;          digitalWrite(latchPin, LOW);&#xA;          shiftOut(dataPin, clockPin, MSBFIRST, noteApprox[myByte - 48]);   //Write to the shift&#xA;          digitalWrite(latchPin, HIGH);                     //register.&#xA;        }&#xA;        else&#xA;        {&#xA;          digitalWrite(gate, LOW);&#xA;        }&#xA;&#xA;        byte myByte = mySerial.read();&#xA;        if(isRealTimeCategory(myByte))&#xA;        {&#xA;          ;&#xA;        }&#xA;        else&#xA;        {&#xA;          if(myByte &amp;gt; 0)                &#xA;      {&#xA;        digitalWrite(gate, HIGH);  //Velocity Byte&#xA;      }&#xA;      else&#xA;      {&#xA;        digitalWrite(gate, LOW);&#xA;          }&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}  //END&#xA;&#xA;/***************************&#xA;    function Declarations&#xA;***************************/&#xA;&#xA;int isStatus(int b)         //Determines if the incoming byte is a Status Byte of some sort.&#xA;                    //Returns 1 if so and 0 if not.&#xA;{&#xA;  if( (b &amp;amp; 0x80) == 0x80)&#xA;  {&#xA;    return 1;&#xA;  }&#xA;  else if( (b &amp;amp; 0x80) == 0)&#xA;  {&#xA;  return 0;&#xA;  }&#xA;}   &#xA;&#xA;int isRealTimeCategory(int b)           //Determines if the incoming byte is a Real Time Category byte&#xA;  {                 //I'm not positive what these *are* but they are only 1 byte long&#xA;    if(b &amp;gt;= 0xF8)           //a piece and easily detected (they're all greater than 11111000).&#xA;    {                           &#xA;      return 1;&#xA;    }&#xA;    else&#xA;    {&#xA;      return 0;&#xA;    }&#xA;}&#xA;&#xA;/*              Bit Math Notes&#xA;&#xA;    if(b &amp;amp; 0x80) == 0x80)&#xA;&#xA;b    =  10000000&#xA;0x80 =  10010000&#xA;      &amp;amp; ________&#xA;        10000000 =/= 10010000&#xA;&#xA;        Not a Note On byte. &#xA;        Return 0.&#xA;&#xA;&#xA;b    =  10010000&#xA;0x80 =  10010000&#xA;      &amp;amp; ________&#xA;        10010000 == 10010000&#xA;&#xA;        A Note On byte! Hooray!&#xA;        Return 1. &#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NwdwV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NwdwV.jpg&quot; alt=&quot;Flowchart&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11165" LastActivityDate="2015-08-18T12:26:51.397" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14306" PostTypeId="2" ParentId="460" CreationDate="2015-08-18T12:41:11.517" Score="0" Body="&lt;p&gt;If the arduino board is connected to any other device then unplug everything and just connect the arduino with the computer using the usb cable and try to upload new sketch i hope it will help.&lt;/p&gt;&#xA;" OwnerUserId="11878" LastActivityDate="2015-08-18T12:41:11.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14308" PostTypeId="2" ParentId="13778" CreationDate="2015-08-18T15:02:21.063" Score="-1" Body="&lt;p&gt;You can use 9v battery and use separate one for servos. Due to voltage being &quot;relative,&quot; you still need to connect the grounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect the + of the battery to the VIN of the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="220" LastEditDate="2015-09-04T01:13:57.547" LastActivityDate="2015-09-04T01:13:57.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14309" PostTypeId="1" CreationDate="2015-08-18T18:22:42.303" Score="-1" ViewCount="2715" Body="&lt;p&gt;Joysticks usually have two outputs, one for the x-axis and one for the y-axis. Most of the bluetooth modules I have found only have one tx line.. Is there a way to set them up to use one bluetooth module to connect to arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im thinking of buying another but I'm wondering if anyone has a better idea than this, or if what I'm thinking is even possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11326" LastActivityDate="2016-04-15T10:37:35.087" Title="Sending joystick data via bluetooth" Tags="|arduino-uno|bluetooth|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14310" PostTypeId="1" CreationDate="2015-08-18T19:13:20.973" Score="0" ViewCount="212" Body="&lt;p&gt;I was looking for a GPS/OBD2 data logger that logs data to an SD card and eventually arrived at the Arduino powered &lt;a href=&quot;http://freematics.com/pages/products/freematics-obd-adapter/&quot; rel=&quot;nofollow&quot;&gt;Freematics Vehicle Data Logger&lt;/a&gt;. It's great that it's programmable, but I have no experience with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading the documentation, it says that I program the device &lt;a href=&quot;http://blog.freematics.com/2014/freematics-obd-ii-adapter-programming-guide/&quot; rel=&quot;nofollow&quot;&gt;either by USBasp or Arduino as ISP&lt;/a&gt;. The USBasp is a dongle programmer, but I don't know what is meant by Arduino as ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to use this device to log data. I don't plan to extensive write programs for it. What is the minimum equipment that I need to have in order to be able to write a bit of code and flash it to the device?&lt;/p&gt;&#xA;" OwnerUserId="11884" LastActivityDate="2015-11-16T21:38:16.603" Title="What minimum equipment is needed to program the Freematics Vehicle Data Logger?" Tags="|programmer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14311" PostTypeId="2" ParentId="14309" CreationDate="2015-08-18T19:22:02.337" Score="1" Body="&lt;p&gt;Unless you have a very special joystick and a very special bluetooth module you can't just connect a joystick to the TX pin of a bluetooth module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you have to have the joystick (I am assuming a 2D analog joystick) to a pair of analog inputs on (for instance) an Ardiuno, which then samples the analog values.  It is then up to you to decide what you do with that sampled data - in your case you want to send it out via serial to the bluetooth module (I assume something like a HC-05 or HC-06).  What that data is, and how you interpret it, is up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could send the data as plain text, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;512,512&#xA;512,512&#xA;384,512&#xA;229,512&#xA;83,512&#xA;83,938&#xA;82,1012&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each line specifies a pair of analog values and is terminated by a line-feed.  The receiving end then needs to read each line, split it on the &lt;code&gt;,&lt;/code&gt;, and interpret the two values as X/Y readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's quite inefficient, though, and there are better &quot;binary&quot; methods that use less bytes to send the readings, but that is more advanced.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-18T19:22:02.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14312" PostTypeId="2" ParentId="14309" CreationDate="2015-08-18T19:22:20.940" Score="0" Body="&lt;p&gt;So your joystick is sending bt signals?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't find an appropiate data sheet to that i advise you link it with your pc, start hterm and analyse what exactly is sent.(requires to link the bt devices)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your joystick is not able to out bt signals I'm not sure what you are trying to do there and need more info&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I already did the following: control a robot with your smartphone via bt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;control a robot with an old ps2 joystick via cable&lt;/p&gt;&#xA;" OwnerUserId="11885" LastEditorUserId="11885" LastEditDate="2015-08-18T19:27:54.437" LastActivityDate="2015-08-18T19:27:54.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14313" PostTypeId="2" ParentId="14310" CreationDate="2015-08-18T19:23:49.720" Score="1" Body="&lt;p&gt;&quot;Arduino as ISP&quot; refers to using an Arduino board in place of a USBasp.  It involves loading a specific sketch onto the Arduino then using the SPI port (and a few other pins) as the programming interface to the target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is most often used to program blank chips for use in breadboards by people who don't have a USBasp.  Great for moving your project from the Arduino board to a breadboard without having to buy a hardware programmer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-18T19:23:49.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14314" PostTypeId="2" ParentId="460" CreationDate="2015-08-18T21:59:16.170" Score="1" Body="&lt;p&gt;The major thing that can go wrong is if you put your Arduino aside for a couple of weeks, forget what sketch (code) is loaded onto it, then get back to work on it, plug in hardware (like a switch, LED or motor) and have it unexpectedly light up / turn on, because the previous code addressed the pin it was connected to.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Solution 1. Load the new code first.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A simple and safe technique is to load the new code that you are working on today &lt;strong&gt;before&lt;/strong&gt; you plug any hardware in. Now you know what the code does, what pins it uses, and you then plug the hardware in afterwards (preferably turning the Arduino off first by unplugging it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then when you reconnect power, it runs the sketch you uploaded, you have your hardware connected and all should be well.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Solution 2. Load a &quot;do nothing&quot; sketch.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You can upload this short sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It &quot;does nothing&quot;. All pins will remain as inputs, so you can safely then attach your hardware, and then start coding your new project.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Safety first&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A good rule is to not plug or unplug hardware (eg. LEDs, switches, motors) with the power applied. If you get distracted and plug into the wrong socket on the board you might immediately damage either what you are connected, or the Arduino, or both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the power off, you can then do a last-minute check that everything is connected to the right place, you have your polarities correct, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also make sure you don't have static electricity on your body, particularly if you are wearing a jumper or something fluffy, or are sitting on carpet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I always reach over and touch some metal part nearby to &quot;ground&quot; myself, before reaching for the Arduino. An example is the metal case of a PC, a headphone socket, or something like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, after connecting power to the Arduino (eg. by the USB cable) you do not immediately see the power LED come on, disconnect the power immediately! You may have shorted something out, and the less time you do that for, the better.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-18T21:59:16.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14316" PostTypeId="2" ParentId="13114" CreationDate="2015-08-18T23:14:36.627" Score="1" Body="&lt;p&gt;Call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( ! mfrc522.PICC_IsNewCardPresent()) return false;&#xA;if ( ! mfrc522.PICC_ReadCardSerial()) return false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before every re-authenticate.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;According to NXPs application note (&lt;a href=&quot;https://www.nxp.com/docs/en/application-note/AN1304.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AN1304&lt;/a&gt;) regarding MIFARE CLASSIC cards (page 24/25):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Each time an Authentication operation, a Read operation or a Write operation fails, the MIFARE Classic or MIFARE Plus remains silent and it does not respond anymore to any commands. In this situation in order to continue the NDEF Detection Procedure the MIFARE Classic or MIFARE Plus needs to be re-activated and selected.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;PICC_IsNewCardPresent&lt;/code&gt; resets modulation parameters and performs RequestA - activates the PICC (Card).&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PICC_ReadCardSerial&lt;/code&gt; basically just performs Select - with anti-collision algorithm.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In case there are multiple cards present it would be better to manually call &lt;code&gt;mfrc522.PICC_Select(&amp;amp;mfrc522.uid, mfrc522.uid.size * 8)&lt;/code&gt;, the second argument tells it that you already know all of the bits for UID, thus it will select the same PICC that was selected previously.&lt;/p&gt;&#xA;" OwnerUserId="11888" LastEditorUserId="60064" LastEditDate="2019-10-09T21:15:31.290" LastActivityDate="2019-10-09T21:15:31.290" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14317" PostTypeId="2" ParentId="14298" CreationDate="2015-08-18T23:26:47.193" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I cannot find any information about the arduino micro. I also don't know exactly what the proper keywords are that i need to find the relation between timers and pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMicro&quot; rel=&quot;noreferrer&quot;&gt;products page for the Micro&lt;/a&gt; on the Arduino web site. You will find that the processor is the ATmega32U4. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf&quot; rel=&quot;noreferrer&quot;&gt;datasheet for the ATmega32U4&lt;/a&gt; - it's on that page.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;reference schematic for the Micro&lt;/a&gt; - also on that page.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now we know the processor, the datasheet tells you about the timers, and the schematic tells you which ATmega32U4 pins are connected to which pins on the Micro board.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But as the Arduino Micro has no Timer2 TCCR2B i cannot use the same code on the Arduino micro.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;True. But it has Timer 1, Timer 3 and Timer 4. You just need to adjust the registers a bit.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Correct, I need to set TCCR1B only one time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes you can do that. Personally I normally stop the timer and then set the parameters in case setting them when it is running has a different effect. eg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1A = 0;  // stop timer 1&#xA;TCCR1B = 0;&#xA;TCCR1C = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;   TCCR1B=TCCR1B&amp;amp;0b11111000|0x01; //pin 9,10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;What do the 0b1111000 refer to?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In this case the first part &lt;code&gt;TCCR1B &amp;amp; 0b11111000&lt;/code&gt; clears the low-order 3 bits (the rest are ANDed in with 1 so they stay the same as before).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it sets the lower-order bit. In this particular case you are setting up a prescaler of 1 times the clock rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/09JE7.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/09JE7.png&quot; alt=&quot;TCCR1b&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pqJhv.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pqJhv.png&quot; alt=&quot;Clock pre-scalers for timer 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;   TIMSK2=1&amp;lt;&amp;lt;TOIE2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;what does this ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;TIMSK2 is a timer register. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yYVe8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yYVe8.png&quot; alt=&quot;TIMSK2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By shifting 1 left &quot;TOIE2&quot; bits it sets that bit (ie., TOIE2 in TIMSK2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, it enables the overflow interrupt for Timer 2.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On Arduino Micro&#xA;  There is no timer 2&#xA;  Pin 9,10,12 have the same timer ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Look at the reference schematic. Yes it looks like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CMnIB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CMnIB.png&quot; alt=&quot;Micro schematic part&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from that pin 30 (on the chip) is labelled &lt;code&gt;OC4B&lt;/code&gt; which means it is the &quot;output compare timer 4: B output&quot;. That pin has the net name &quot;IO10*&quot; which I presume means it is connected to board pin 10 (pin 30 on the chip).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also if I understand correctly the Arduino micro has:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;a higher PWM range 1024 vs 255 (UNO)??&lt;/li&gt;&#xA;  &lt;li&gt;a much higher frequency available in on timer4 only for pin 13&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, the Uno has Timer 1 which is 16 bits (up to 65536). The Micro has Timer 4 which is 10 bits and therefore can count up to 1024. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the frequency is a function of the clock speed. On either chip, by using a prescaler of 1, and counting up to 1, you can get an 8 MHz frequency (one up, one down from 16 MHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The higher number of bits in the timer, the &lt;em&gt;finer the resolution&lt;/em&gt; - that is you can adjust the frequency in finer steps, and you can adjust the PWM duty cycle in finer steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt; with Timer 4 on the Micro you can, apparently, clock it with 6 times the clock rate (96 MHz) which is used for the USB part of the chip. Setting appropriate bits (I haven't done this personally) you could get that higher frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can apparently get 96 MHz, 64 MHz or 48 MHz clock frequencies on Timer 4 (as well as the normal ones).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Added in response to comments&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pin 12 on the chip has 2 timers, OC0A &amp;amp; OC1C?? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, from the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Output Compare unit 1C and Output Compare unit 2 shares the PB7 port pin for output. The outputs of the Output Compare units (OC1C and OC0A) overrides the normal PORTB7 Register when one of them is enabled (i.e., when COMnx1:0 is not equal to zero). When both OC1C and OC0A are enabled at the same time, the modulator is automatically enabled.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What timer do i need to use for let's say pin 9,10,12 on arduino micro?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looks like Timer 4.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;in arduino ide i can only write analogWrite(255) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is changing the PWM duty cycle for the timers configured in their default way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look in wiring.c:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// timers 1 and 2 are used for phase-correct hardware pwm&#xA;// this is better for motors as it ensures an even waveform&#xA;// note, however, that fast pwm mode can achieve a frequency of up&#xA;// 8 MHz (with a 16 MHz clock) at 50% duty cycle&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;analogWrite changes the duty cycle, not the frequency.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can apparently get 96 MHz... so at the end arduino micro can go faster on timer 4 &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you mean by &quot;go faster&quot; here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but I actually did not solve the problem. I hope you give me a hint to how to make it work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It isn't clear really what you want to happen.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What devices are you driving?&lt;/li&gt;&#xA;&lt;li&gt;Why do you need high frequencies?&lt;/li&gt;&#xA;&lt;li&gt;What is the underlying problem?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;noreferrer&quot;&gt;Timers and counters&lt;/a&gt; - mainly about the Atmega328P, however a lot of it applies to the other chips as well.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-19T09:22:49.383" LastActivityDate="2015-08-19T09:22:49.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14318" PostTypeId="1" AcceptedAnswerId="14319" CreationDate="2015-08-18T23:31:53.200" Score="1" ViewCount="3073" Body="&lt;p&gt;I've been communicating with a teensy arduino over USB using pySerial--which has been simple, but slow. With simple write commands from Python and a corresponding read command on the teensy, I can only achieve 200kHz transfer rates. I'm hoping to get over 1MHz at least, but I don't see a path towards that rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are Ethernet shields capable of augmenting for rates over the MHz range? How can I get faster data transfer rates between my computer and arduino? I'm mainly interested in one-way communications (computer directs teensy).&lt;/p&gt;&#xA;" OwnerUserId="11889" LastActivityDate="2015-08-19T04:59:44.990" Title="Fast Python to arduino communications" Tags="|serial|usb|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14319" PostTypeId="2" ParentId="14318" CreationDate="2015-08-19T00:16:01.647" Score="3" Body="&lt;p&gt;The fastest means of communicating with the Arduino is &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt;. Ethernet shields use that (as do SD cards). It's quite fast, but it has limits. The fastest the SPI clock can go is the CPU (MCU) clock rate divided by 2 (per bit), that is one byte every 16 CPU clock cycles. There is also an overhead of a couple of clock cycles between bytes, so you can reckon on 888,888 bytes absolute maximum (ie. about 868 kHz) on an Arduino running at 16 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However that's just throwing the data away. It needs to be stored somewhere, compared to something, acted upon. That all takes clock cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is for the 16 MHz Arduinos. The Teensy 3.1 apparently runs at 72 MHz which is somewhat faster. I haven't timed SPI on that, presumably you can get a faster transmission rate, but I suspect that the ARM processors also take more instructions to do the same thing, so the 72 MHz might not be quite as fast as it looks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have the issue of how fast you can get data in and out of the Ethernet card, and how fast you can do whatever-it-is you want to do with it, in the processor.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-19T04:59:44.990" LastActivityDate="2015-08-19T04:59:44.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14320" PostTypeId="1" AcceptedAnswerId="14322" CreationDate="2015-08-19T04:16:26.780" Score="0" ViewCount="1050" Body="&lt;p&gt;I am trying to use different buttons to activate different methods for an LED strip. However, when one button is pressed after another has been pressed, I want it to interrupt the first buttons method and begin the second. For example: one button sends a rainbow pattern through the LED strip when pressed, however, while it is cycling through the rainbow, the second button is pressed which sends a white cycle through the LED strip. There will be 24 buttons total. I have gotten this to work with 2 buttons but am having trouble getting it to work for a third. The code is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     void loop(){&#xA;&#xA;       if (digitalRead(inPin(1)) == HIGH &amp;amp;&amp;amp; lastState == LOW){//if button has just been pressed&#xA;           stopCycle();&#xA;           theaterChaseRainbow(50);&#xA;       }&#xA;       if (digitalRead(inPin(2)) == HIGH){&#xA;           stopCycle();&#xA;           theaterChase(strip.Color(127, 127, 127), 50); // White&#xA;       }&#xA;       if (digitalRead(inPin(3)) == HIGH){&#xA;           stopCycle();&#xA;           rainbowCycle(0); &#xA;       }&#xA;&#xA;     }&#xA;&#xA;     //Theatre-style crawling lights.&#xA;void theaterChase(uint32_t c, uint8_t wait) {&#xA;  for (int j=0; j&amp;lt;100; j++) {  //do 100 cycles of chasing&#xA;    if (digitalRead (inPin(1)) == LOW) { //checks that other button(s) have not been pressed&#xA;      if (digitalRead (inPin(3) == LOW)){&#xA;      for (int q=0; q &amp;lt; 3; q++) {&#xA;        for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;          strip.setPixelColor(i+q, c);    //turn every third pixel on&#xA;        }&#xA;        strip.show();&#xA;&#xA;        delay(wait);&#xA;&#xA;        for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;          strip.setPixelColor(i+q, 0);        //turn every third pixel off&#xA;        }&#xA;      }&#xA;    }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void rainbow(uint8_t wait) {&#xA;  int i, j;&#xA;&#xA;  for (j=0; j &amp;lt; 384; j++) {   &#xA;   if (digitalRead (inPin(2)) == LOW) { // 3 cycles of all 384 colors in the wheel&#xA;    if (digitalRead (inPin(3) == LOW)){&#xA;    for (i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, Wheel( (i + j) % 384));&#xA;    }  &#xA;    strip.show();   // write all the pixels out&#xA;    delay(wait);&#xA;   }&#xA;   }  &#xA;  }&#xA;}&#xA;&#xA;uint32_t Wheel(uint16_t WheelPos)&#xA;{&#xA;  byte r, g, b;&#xA;  switch(WheelPos / 128)&#xA;  {&#xA;    case 0:&#xA;      r = 127 - WheelPos % 128;   //Red down&#xA;      g = WheelPos % 128;      // Green up&#xA;      b = 0;                  //blue off&#xA;      break; &#xA;    case 1:&#xA;      g = 127 - WheelPos % 128;  //green down&#xA;      b = WheelPos % 128;      //blue up&#xA;      r = 0;                  //red off&#xA;      break; &#xA;    case 2:&#xA;      b = 127 - WheelPos % 128;  //blue down &#xA;      r = WheelPos % 128;      //red up&#xA;      g = 0;                  //green off&#xA;      break; &#xA;  }&#xA;  return(strip.Color(r,g,b));&#xA;}&#xA;&#xA;void rainbowCycle(uint8_t wait) {&#xA;  uint16_t i, j;&#xA;&#xA;  for (j=0; j &amp;lt; 384 * 5; j++) {     // 5 cycles of all 384 colors in the wheel&#xA;    if (inPin(1) == LOW) {&#xA;      if (inPin(2) == LOW) {&#xA;    for (i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;      // tricky math! we use each pixel as a fraction of the full 384-color wheel&#xA;      // (thats the i / strip.numPixels() part)&#xA;      // Then add in j which makes the colors go around per pixel&#xA;      // the % 384 is to make the wheel cycle around&#xA;      strip.setPixelColor(i, Wheel( ((i * 384 / strip.numPixels()) + j) % 384) );&#xA;    }  &#xA;    strip.show();   // write all the pixels out&#xA;    delay(wait);&#xA;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void stopCycle(){&#xA;    int i;&#xA;    for (i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, 0);&#xA;    }  &#xA;    strip.show();   // write all the pixels out&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11765" LastActivityDate="2015-08-19T05:13:39.993" Title="Multiple buttons activating different methods for an LED strip" Tags="|arduino-mega|led|c++|button|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14321" PostTypeId="2" ParentId="14318" CreationDate="2015-08-19T04:48:14.797" Score="1" Body="&lt;p&gt;First of all, khz and mhz are not data transfer rates. They are frequencies - &quot;something per second&quot; - did you mean kilobits/second or kilobytes/second (both, confusingly, abbreviated to kbps by various people).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have not already done so, you can specify a bitrate for your communications - serial.begin takes a parameter which specifies the speed - most example seem to use 9600 bits/second, you can crank this all the way up to 115,200 bits/second - 12 times the speed. I don't know if this will work with a Teensy, and/or USB. You will probably at least need to specify this in your terminal program and/or pySerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder what you are doing that requires 1Mbyte/second communication with an Arduino, and if you can do that a little smarter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At that rate, the 64kbytes of memory can be filled up in 1/16th of a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a faster &quot;information transfer&quot; by increasing the information density - for example, the English word &quot;True&quot; takes up 4 characters = 32 bits , but a logical true value only takes up 1 bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are processing the data on the Arduino, at 1mbyte/second, you have 72 instructions to do something with that byte before the next one is there - not much time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could increase the data rate by pushing the data in in parallel, using multiple pins - e.g. 32 bits in parallel, one on each of 32 pins, one data point per cycle. There would be no practical way to assimilate data at that speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are sending this from a PC, perhaps some of the data could be processed on the PC before sending?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to divide the work over multiple Teensies, with the PC combining the work - e.g. if you have temperature sensors that output 4 byte values, you want to read 250 of them at a rate of 1000 samples per second (= total of 1mbyte/second), then you might be able to run 25 Teensies, each sampling 10 sensors, and each pushing data at 40kbytes/second, rather than one running at 1mbyte/second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quite frankly, these are all fairly contrived examples - most sensors can't be read that quickly; even an Arduino's analog read is limited to 10,000 reads per second - if you do nothing else. This produces 100 kbits/second, or 20kbytes per second (each 10-bit read is returned as two bytes, with the remaining 6 bits being 0). &lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-08-19T04:55:09.193" LastActivityDate="2015-08-19T04:55:09.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14322" PostTypeId="2" ParentId="14320" CreationDate="2015-08-19T05:13:26.457" Score="0" Body="&#xA;&#xA;&lt;p&gt;Inside each inner loop, just test the switches and &lt;code&gt;return&lt;/code&gt; if they are pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//Theatre-style crawling lights.&#xA;void theaterChase(uint32_t c, uint8_t wait) {&#xA;  for (int j=0; j&amp;lt;100; j++) {  //do 100 cycles of chasing&#xA;    for (int q=0; q &amp;lt; 3; q++) {&#xA;      for (int i=0; i &amp;lt; strip.numPixels(); i=i+3)&#xA;      {&#xA;        strip.setPixelColor(i+q, c);    //turn every third pixel on&#xA;      }&#xA;      strip.show();&#xA;      delay(wait);&#xA;&#xA;      // give up if switches pressed&#xA;      if (digitalRead (inPin(1)) == HIGH || &#xA;          digitalRead (inPin(2)) == HIGH ||&#xA;          digitalRead (inPin(3)) == HIGH )&#xA;        return;&#xA;&#xA;      for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;        strip.setPixelColor(i+q, 0);        //turn every third pixel off&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;am having trouble getting it to work for a third&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help please explain the nature of this &quot;trouble&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You may need to debounce the switch presses. And you may need to wait for them to release the switch, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; if (digitalRead(inPin(1)) == HIGH &amp;amp;&amp;amp; lastState == LOW){//if button has just been pressed&#xA;           stopCycle();&#xA;           while (digitalRead(inPin(1)) == HIGH)&#xA;              {  }   // wait for switch release&#xA;           delay (10);  // debounce&#xA;           theaterChaseRainbow(50);&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-19T05:13:26.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14323" PostTypeId="2" ParentId="14320" CreationDate="2015-08-19T05:13:39.993" Score="0" Body="&lt;p&gt;I would normally do this (pseudocode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    static state=state_off;&#xA;    if (button_1_pushed) {&#xA;        state=state_1;&#xA;    } elseif (button_2_pushed) {&#xA;        state=state_2;&#xA;    }&#xA;    if (state==state_off) {&#xA;        turn_all_leds_off();&#xA;    } elseif (state==state_2) {&#xA;        shownextframe_rainbow();&#xA;    } elseif (state==state_2) {&#xA;        shownextframe_chaser();&#xA;    }&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In shownextframe_chaser/shownextframe_rainbow, I would probably work out what should be shown based on the current millis() - e.g. if your chaser has 10 lights, and you want it to pulse over 1 second, then each led should be on for 100 millis, so at any instant, the led that should be on is &lt;code&gt;(millis()/100)%10&lt;/code&gt; (assuming the led's are numbered for 0 to 9).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-19T05:13:39.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14325" PostTypeId="2" ParentId="14295" CreationDate="2015-08-19T06:03:39.833" Score="0" Body="&lt;p&gt;As previous answers have pointed out, your understanding of C syntax has shortcomings, and you should study C further.  Besides those syntax issues, you may need to revise some of your concepts of how to program.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, the references you looked at regarding integration may have shown forms like Tₓ₊₁ = (δ/2)·(Vₓ₊₁ – Vₓ) for “triangle area” and Rₓ₊₁ = δ·Vₓ for “rectangle area” [where I've written δ in place of your t(2)].  In spite of the use of subscripts in these formulas, the array concepts mentioned in other answers are not relevant here.  Instead of saving voltage data in arrays, just save and work with two voltage values:  the current differential voltage reading and the previous differential voltage reading.  Letting Vᵣ and Vₓ stand for previous and new voltage differences, use Vᵣ where Vₓ is called for, and Vₓ where Vₓ₊₁ is called for.  At the end of each step, set Vᵣ = Vₓ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, making separate computations of “triangle area” and “rectangle area” is verbose, unnecessary, and less accurate than a properly combined computation.  Note that Tₓ₊₁ + Rₓ₊₁, as used in computing areaₓ₊₁, is equal to  (δ/2)·(Vₓ₊₁ – Vₓ) + δ·Vₓ = (δ/2)·Vₓ₊₁ – (δ/2)·Vₓ + δ·Vₓ = (δ/2)·Vₓ₊₁ + (δ/2)·Vₓ = δ·(Vₓ₊₁ + Vₓ)/2.  Thus, instead of those three lines of code using two temporary variables and lots of indices, use code like the following for the integral:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;area += deltaT*(Volt_r + Volt_s)/2;&#xA;Volt_r = Volt_s;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(In the above, &lt;code&gt;Volt_s&lt;/code&gt; corresponds to your &lt;code&gt;FeqIn3&lt;/code&gt; value.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thirdly, your attempted &lt;code&gt;for&lt;/code&gt; loop needs to be replaced by an actual &lt;code&gt;for&lt;/code&gt; loop; and in addition, &lt;code&gt;deltaT&lt;/code&gt;, a time-step delta, needs to be computed.  (Your &lt;code&gt;t(2)&lt;/code&gt; needs to represent a change in time, not an absolute time, to represent the time-width of the rectangle and triangle you are adding to the total.)  To get a &lt;code&gt;deltaT&lt;/code&gt;, read &lt;code&gt;millis()&lt;/code&gt; after the &lt;code&gt;analogRead&lt;/code&gt; lines.  For example, you could say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Volt_s = analogRead(analogInPin) - analogRead(analogInPin1);&#xA;t_s = millis();&#xA;deltaT = t_s - t_r;&#xA;area += deltaT*(Volt_r + Volt_s)/2;&#xA;t_r = t_s;&#xA;Volt_r = Volt_s;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fourthly, using two &lt;code&gt;analogRead&lt;/code&gt;s to get a differential voltage has two problems:  first, any common-mode voltage wastes bits of ADC resolution, so contributes to error; second, the two reads occur at different times so their voltages are not comparable.  Instead, you could use an external op-amp to subtract voltages, or could use the Due's differential-front-end ADC mode, per Section 43.6.8, &lt;em&gt;Differential Inputs&lt;/em&gt;, on page 1326 in the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ARM Cortex M3 Processor manual&lt;/a&gt;, plus possibly a gain of 1, 2, or 4 (per Section 43.6.9).  Also see: &lt;a href=&quot;http://www.djerickson.com/arduino/&quot; rel=&quot;nofollow&quot;&gt;Analog performance ... of Due's 12 bit ADC&lt;/a&gt; (including how to speed up &lt;code&gt;analogReads&lt;/code&gt; on the Cortex), &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=147830.0&quot; rel=&quot;nofollow&quot;&gt;Differential Sensing with Arduino&lt;/a&gt;, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=194770.0&quot; rel=&quot;nofollow&quot;&gt;Setting ADC compare mode in a differential input&lt;/a&gt;, and &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=132130.0&quot; rel=&quot;nofollow&quot;&gt;Due pinout diagram&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="10003" LastEditDate="2015-08-24T11:55:03.370" LastActivityDate="2015-08-24T11:55:03.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14326" PostTypeId="1" CreationDate="2015-08-19T07:26:02.227" Score="2" ViewCount="270" Body="&lt;p&gt;I'm trying to communicate with some industrial hardware, on ModBusRTU, from my Intel Galileo Gen2 board. I use this board to convert UART to RS485 &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=RS485_Shield_V2.1_for_Arduino&quot; rel=&quot;nofollow&quot;&gt;http://linksprite.com/wiki/index.php5?title=RS485_Shield_V2.1_for_Arduino&lt;/a&gt; and I can talk serially between Arduino (with SoftwareSerial on pin 2/3) and Galileo (with Serial1 on pin 0/1). So I know the RS485's link is working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With Arduino Uno I can talk with my devices using ModBusRTU, thanks to this library &lt;a href=&quot;https://github.com/4-20ma/ModbusMaster&quot; rel=&quot;nofollow&quot;&gt;https://github.com/4-20ma/ModbusMaster&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On galileo gen2 I received this warning &lt;code&gt;WARNING: library ModbusMaster claims to run on [avr, sam] architecture(s) and may be incompatible with your current board which runs on [i586] architecture(s).&lt;/code&gt; because of the different architecture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm trying to use the examples of cooking hack's tutorial about modbus and rs485 for Arduino, Raspberry and Galileo but I can't make it works for me. I received tons of compiling errors like these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp: In member function 'uint8_t ModbusMaster485::ModbusMasterTransaction(uint8_t)': C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:701:50: error: '_crc16_update' was not declared in this scope&#xA;C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:814:52: error: '_crc16_update' was not declared in this scope&#xA;C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp: At global scope:&#xA;C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:881:14: error: prototype for 'unsigned int ModbusMaster485::makeWord(unsigned int)' does not match any in class 'ModbusMaster485'&#xA;In file included from C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:25:0: C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.h:302:11: error: candidates are: uint16_t ModbusMaster485::makeWord(uint8_t, uint8_t)&#xA;C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.h:301:14: error: uint16_t ModbusMaster485::makeWord(uint16_t) C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:887:14: error: prototype for 'unsigned int ModbusMaster485::makeWord(uint8_t, uint8_t)' does not match any in class 'ModbusMaster485'&#xA;In file included from C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.cpp:25:0: C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.h:302:11: error: candidates are: uint16_t ModbusMaster485::makeWord(uint8_t, uint8_t) C:\Intel\arduino-1.6.4\libraries\ModBusMaster485\ModbusMaster485.h:301:14: error: uint16_t ModbusMaster485::makeWord(uint16_t) Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did someone has got ModBus working on Galileo Gen2?&lt;/p&gt;&#xA;" OwnerUserId="11892" LastEditorUserId="10794" LastEditDate="2015-08-19T09:29:43.847" LastActivityDate="2015-08-19T09:29:43.847" Title="Anyone using ModBus RTU on Galileo gen 2?" Tags="|arduino-galileo|modbus|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14327" PostTypeId="2" ParentId="13620" CreationDate="2015-08-19T07:33:49.037" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/news/1629&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/news/1629&lt;/a&gt;&#xA;Maybe your windows update has installed new drivers for your FTDI chip.&#xA;You can check that your usb device PID is set to 0x0000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You probably have the &quot;Gravitech Nano V3.0&quot; (with FTDI chip on the back)? I have, and this worked for me.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you should download &lt;a href=&quot;http://www.ftdichip.com/Support/Utilities.htm#MProg&quot; rel=&quot;nofollow&quot;&gt;M_PROG from FTDI&lt;/a&gt;&#xA;And then check for the chip, when found, you set the PID to FTDI default (0x6001).&#xA;Then simply press program, and it will re-set your device PID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you should download the &lt;a href=&quot;https://www.youtube.com/watch?v=SPdSKT6KdF8&quot; rel=&quot;nofollow&quot;&gt;&quot;CDM-v2.12.00-WHQL-Certified.zip&quot;&lt;/a&gt; drivers.&#xA;&lt;a href=&quot;http://www.theinquirer.net/inquirer/news/2377473/windows-update-bricks-fake-usb-chips&quot; rel=&quot;nofollow&quot;&gt;Another source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-08-19T07:33:49.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14329" PostTypeId="1" CreationDate="2015-08-19T08:17:24.277" Score="0" ViewCount="448" Body="&lt;p&gt;I am trying to make a 24 button board that assigns different methods to each button. When a button is pressed, it should interrupt the method of the previous button and begin the new method. Currently, the button has to be held down in order to work. I'm not sure why since the methods should continue without being held down. All 24 methods are similar to the one posted below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop(){&#xA;  if (digitalRead(inPin(5)) == HIGH){&#xA;    fifthButtonTheatreChaseRedSlow(strip.Color(127,   0,   0), 100); // Red&#xA;  }&#xA;&#xA;void fifthButtonTheatreChaseRedSlow(uint32_t c, uint8_t wait) {&#xA;  for (int j=0; j&amp;lt;100; j++) {  //do 100 cycles of chasing&#xA;    for (int q=0; q &amp;lt; 3; q++) {&#xA;      for (int i=0; i &amp;lt; strip.numPixels(); i=i+3)&#xA;      {&#xA;        strip.setPixelColor(i+q, c);    //turn every third pixel on&#xA;      }&#xA;      strip.show();&#xA;      delay(wait);&#xA;&#xA;      // give up if switches pressed&#xA;      if (digitalRead (inPin(1)) == HIGH || &#xA;             digitalRead (inPin(2)) == HIGH ||&#xA;             digitalRead (inPin(3)) == HIGH ||&#xA;             digitalRead (inPin(4)) == HIGH || &#xA;             digitalRead (inPin(6)) == HIGH ||&#xA;             digitalRead (inPin(7)) == HIGH || &#xA;             digitalRead (inPin(8)) == HIGH ||&#xA;             digitalRead (inPin(9)) == HIGH || &#xA;             digitalRead (inPin(10)) == HIGH ||&#xA;             digitalRead (inPin(11)) == HIGH || &#xA;             digitalRead (inPin(12)) == HIGH ||&#xA;             digitalRead (inPin(13)) == HIGH || &#xA;             digitalRead (inPin(14)) == HIGH ||&#xA;             digitalRead (inPin(15)) == HIGH || &#xA;             digitalRead (inPin(16)) == HIGH ||&#xA;             digitalRead (inPin(17)) == HIGH || &#xA;             digitalRead (inPin(18)) == HIGH ||&#xA;             digitalRead (inPin(19)) == HIGH || &#xA;             digitalRead (inPin(20)) == HIGH ||&#xA;             digitalRead (inPin(21)) == HIGH ||&#xA;             digitalRead (inPin(22)) == HIGH || &#xA;             digitalRead (inPin(23)) == HIGH ||&#xA;             digitalRead (inPin(24)) == HIGH)&#xA;               return;&#xA;&#xA;      for (int i=0; i &amp;lt; strip.numPixels(); i=i+3) {&#xA;        strip.setPixelColor(i+q, 0);        //turn every third pixel off&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure if it's a hardware issue or a software issue.&lt;/p&gt;&#xA;" OwnerUserId="11765" LastActivityDate="2015-12-17T12:31:06.483" Title="Buttons for LED strip only work when held down" Tags="|arduino-mega|led|c++|button|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14331" PostTypeId="2" ParentId="14329" CreationDate="2015-08-19T09:50:08.600" Score="1" Body="&lt;p&gt;It's a software issue.  You are basically saying &quot;If this button is currently pressed down then run this sequence once&quot;, rather than &quot;If this button has transitioned from OFF to ON then set my current sequence to X&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to learn about the &lt;a href=&quot;http://hacking.majenko.co.uk/finite-state-machine&quot; rel=&quot;nofollow&quot;&gt;Finite State Machine&lt;/a&gt; and about switching from one state to another (or one selected sequence to another) when a button &lt;em&gt;changes&lt;/em&gt; state not when it is &lt;em&gt;in&lt;/em&gt; a state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically the whole logic of your program is flawed and needs re-working.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-19T09:50:08.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14332" PostTypeId="2" ParentId="14329" CreationDate="2015-08-19T10:00:17.923" Score="1" Body="&lt;p&gt;Related to &lt;a href=&quot;https://arduino.stackexchange.com/questions/14320/multiple-buttons-activating-different-methods-for-an-led-strip&quot;&gt;Multiple buttons activating different methods for an LED strip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // give up if switches pressed&#xA;  if (digitalRead (inPin(1)) == HIGH || &#xA;         digitalRead (inPin(2)) == HIGH ||&#xA;         digitalRead (inPin(3)) == HIGH ||&#xA;         digitalRead (inPin(4)) == HIGH || &#xA;         digitalRead (inPin(6)) == HIGH ||&#xA;         digitalRead (inPin(7)) == HIGH || &#xA;         digitalRead (inPin(8)) == HIGH ||&#xA;         digitalRead (inPin(9)) == HIGH || &#xA;         digitalRead (inPin(10)) == HIGH ||&#xA;         digitalRead (inPin(11)) == HIGH || &#xA;         digitalRead (inPin(12)) == HIGH ||&#xA;         digitalRead (inPin(13)) == HIGH || &#xA;         digitalRead (inPin(14)) == HIGH ||&#xA;         digitalRead (inPin(15)) == HIGH || &#xA;         digitalRead (inPin(16)) == HIGH ||&#xA;         digitalRead (inPin(17)) == HIGH || &#xA;         digitalRead (inPin(18)) == HIGH ||&#xA;         digitalRead (inPin(19)) == HIGH || &#xA;         digitalRead (inPin(20)) == HIGH ||&#xA;         digitalRead (inPin(21)) == HIGH ||&#xA;         digitalRead (inPin(22)) == HIGH || &#xA;         digitalRead (inPin(23)) == HIGH ||&#xA;         digitalRead (inPin(24)) == HIGH)&#xA;           return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Time to learn about loops, buddy. How about:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 1; i &amp;lt;= 24; i++)&#xA;  if (digitalRead (inPin (i)) == HIGH)&#xA;    return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My guess about this particular problem is that you are not debouncing. You enter the function, one of the bounces is detected, and you leave the function. I mentioned debouncing in your other, closely-related, thread.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Let me show you what a switch bounce looks like. Using a normal switch from my parts drawer, this is what you see when you press it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tr6LT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tr6LT.png&quot; alt=&quot;Switch bounce&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See that? It looks to the (fast) Arduino that you pressed the switch 20 or 30 times. That is the physical metal bouncing back and forwards. So if you test for one press, and then stop when you get another, your chances of it working are rather slim. That's why a simple delay of (say) 10 ms after detecting a change in state of the switch can help debounce it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;Switches tutorial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-19T10:32:56.277" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14333" PostTypeId="1" AcceptedAnswerId="14335" CreationDate="2015-08-19T11:41:43.053" Score="3" ViewCount="13019" Body="&lt;p&gt;&lt;strong&gt;Explain this line in simple words.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B=TCCR0B&amp;amp;0b11111000|0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the variuos arduinos have different chips. They also have different timers and different pins which use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lately i want to rewrite a code(Arduino Uno) to make it work on a Arduino Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to understand how this works in simple words. I normally write web based code(javascript,php...). Just lately i started writing in c++ or a &quot;simplified&quot; c++ in the arduino ide. It's not that hard. But some specific parameters are hard to understand for me.&#xA;Shortcuts like the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B=TCCR0B&amp;amp;0b11111000|0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCCR&lt;/code&gt; = Prefix for timers. Correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0&lt;/code&gt; = Timer1 or 0 call it however you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;B&lt;/code&gt; = &lt;strong&gt;What is A,B,C and sometimes D for?&lt;/strong&gt; What does this?why in that code is the programmer using B and not A,C or D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCCR0B=&lt;/code&gt; Timer 0 B is equal to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TCCR0B&amp;amp;&lt;/code&gt; &lt;strong&gt;if Timer 0 B return True .. exists &quot;&amp;amp;&quot; ?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0b11111000&lt;/code&gt; &lt;strong&gt;What is this?&lt;/strong&gt; i already asked this and the answer was something like &quot;clears the low-order 3 bits&quot;. Like i said, i'm not very familiar with c++, bits and other stuff regarding the arduino. I now less about the various chips and also about how they implemented the various parameters from arduino ide to work with those chips. I know that i have here 8 values that i can change from 0 to 1. What does those values change relative to the timer. Please think of me as a 6 year old.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;|0x01;&lt;/code&gt; I got this... it sets the prescaler... 1,8,32.. some timers have differnet values... no problem. I need it at 1.&lt;/p&gt;&#xA;" OwnerUserId="11876" LastActivityDate="2022-01-03T19:22:09.123" Title="Arduino timers. How they work" Tags="|timers|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14335" PostTypeId="2" ParentId="14333" CreationDate="2015-08-19T12:23:09.660" Score="12" Body="&lt;p&gt;First I'll tackle what&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B=TCCR0B&amp;amp;0b11111000|0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;means from a pure programming perspective:&lt;/p&gt;&#xA;&lt;p&gt;Let's break it down into parts:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;TCCR0B&lt;/code&gt; is a register. It could be any variable really - it's just &amp;quot;a value&amp;quot; in this context. Just because it happens to control one of the timers is besides the point.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;0b11111000&lt;/code&gt; is a binary representation of a value.  It's the same as the hexadecimal number &lt;code&gt;0xF8&lt;/code&gt;.  F is 15.  15 in binary is 1111.  8 is 8 in both hexadecimal and decimal.  8 in binary is 1000.  Put the two together and you have 11111000.  Incidentally, in decimal that is 248.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;0x01&lt;/code&gt; is hexadecimal for 1 in decimal - it's also 1 in binary.&lt;/p&gt;&#xA;&lt;p&gt;Between them are &lt;em&gt;bitwise&lt;/em&gt; operators - &lt;code&gt;&amp;amp;&lt;/code&gt; is a bitwise &lt;code&gt;AND&lt;/code&gt; operation, and &lt;code&gt;|&lt;/code&gt; is a bitwise &lt;code&gt;OR&lt;/code&gt; operation.  &lt;code&gt;AND&lt;/code&gt; calculates which bits in a pair of binary numbers are both on, and &lt;code&gt;OR&lt;/code&gt; calculates which bits in a pair of binary numbers are on in either of the numbers.&lt;/p&gt;&#xA;&lt;p&gt;So take the first one first.  Say the &lt;code&gt;TCCR0B&lt;/code&gt; register contains the value &lt;code&gt;0x6F&lt;/code&gt;, which is 157 in decimal, or 01101111 in binary.  The first operation is to &lt;code&gt;AND&lt;/code&gt; that with 11111000:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;01101111&#xA;11111000 AND&#xA;--------&#xA;01101000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can see that the last three bits of the value have been cleared because they aren't 1 in both the left and right operands to the &lt;code&gt;&amp;amp;&lt;/code&gt; operator.&lt;/p&gt;&#xA;&lt;p&gt;Ok, so the next operation is to &lt;code&gt;OR&lt;/code&gt; it with 0x01:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;01101000&#xA;00000001 OR&#xA;--------&#xA;01101001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Effectively the two operands have been overlaid on each other and any bits that are set in either operand will be reflected in the result.&lt;/p&gt;&#xA;&lt;p&gt;So finally the value is then stored in &lt;code&gt;TCCR0B&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In summary that specific operation &lt;em&gt;clears the lower three bits then sets the lowest bit&lt;/em&gt; of TCCR0B.&lt;/p&gt;&#xA;&lt;p&gt;Now what that actually means with respect to what the TCCR0B register does can be gleaned from the datasheet for the chip.  For instance, take the ATMega328P chip from the Arduino UNO board.  Section 14.9.2 &amp;quot;TCCR0B – Timer/Counter Control Register B&amp;quot; of &lt;a href=&quot;https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the datasheet&lt;/a&gt; describes that register in detail.  The bit-wise overview looks like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eQKLG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eQKLG.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Those bits all correspond 1:1 to the binary bits from above in the same order.  So the first stage, clearing of the lowest three bits, sets CS02, CS01 and CS00 to 0.  The second stage, ORing 0x01, then sets CS00 to 1.&lt;/p&gt;&#xA;&lt;p&gt;The datasheet goes on to tell you what those mean:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bits 2:0 – CS02:0: Clock Select&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The three Clock Select bits select the clock source to be used by the Timer/Counter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;And a table to show the different meanings of the possible values:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eMoHl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eMoHl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The value that has been masked and created for those three bits is, of course, 001, which in that table is &amp;quot;CLK I/O / (No prescaling)&amp;quot;, which is the timer running at the frequency of the IO clock.  If you were to set those bits to 010, you'd get &amp;quot;CLK I/O / 8 (From prescaler)&amp;quot;.  So your masking would change to:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0x02;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or more explicitly so you can see the bits easier:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0b010;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As to what the &amp;quot;A&amp;quot; and &amp;quot;B&amp;quot; mean (TCCR0A and TCCR0B), there are two registers that are used to control the timer.  They each serve a different purpose.  TCCR0A has bits that control PWM, and TCCR0B has bits that control the timer itself.&lt;/p&gt;&#xA;&lt;p&gt;Not to be confused with OCR0A and OCR0B which are two separate numeric values that are compared to the timer's counter value TCNT0 to provide two separate PWM outputs (OC0A as Uno pin D6, and OC0B as Uno pin D5) synchronised from the same timebase. (See sections 14.9.4 OCR0A – Output Compare Register A and 14.9.4 OCR0B – Output Compare Register B in the datasheet)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="6628" LastEditDate="2022-01-03T19:22:09.123" LastActivityDate="2022-01-03T19:22:09.123" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="14337" PostTypeId="2" ParentId="14333" CreationDate="2015-08-19T13:20:20.020" Score="1" Body="&lt;p&gt;The answer, at high level, is: each bit (or group of bits) in a register is, in practice, like a knob that can configure certain parts of the HW.&#xA;For each peripheral you want to control, you have to understand the block diagrams, the related knobs and in which registers those knobs are located.&#xA;Sometimes there are multiple (almost) identical instances of a certain HW block and in the ATMega case these instances are often addressed with letters.&#xA;So registers that have almost identical names, apart from A, B, C, are basically identical, but each of them will affect a separate instance of a certain peripheral.&#xA;Depending on which pins or interrupt you want to use, you can choose the specific instance of a certain peripheral.&#xA;You should check the ATMega328p programmer's manual (it's 2k pages, but it's easy to find the desired section.)&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-19T13:20:20.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14338" PostTypeId="1" CreationDate="2015-08-19T13:35:53.243" Score="1" ViewCount="700" Body="&lt;p&gt;I was wondering if I can use the Rx and Tx Hardware on the Arduino Uno and also add another Rx/Tx pins using SoftwareSerial at the same time ? cause I need two to communicate with two motor Controllers (Roboclaw controller)&#xA;Thx &lt;/p&gt;&#xA;" OwnerUserId="11897" LastActivityDate="2015-08-19T18:54:07.517" Title="Arduino Uno Rx/Tx + Arduino Serial" Tags="|arduino-uno|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14339" PostTypeId="2" ParentId="14338" CreationDate="2015-08-19T14:59:09.543" Score="3" Body="&lt;p&gt;Yes, you can.  That's the purpose of the SoftwareSerial - to allow you to complement the hardware TX/RX with other pins defined by software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note with SoftwareSerial - it's half duplex. It can either send or receive, it can't receive while it's sending.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-19T14:59:09.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14340" PostTypeId="2" ParentId="14338" CreationDate="2015-08-19T18:42:34.027" Score="2" Body="&lt;p&gt;You can, but be aware that SoftwareSerial can cause problems if you need strict timing, as it will keep the Arduino stuck while it is receiving, as it polls in interrupt context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend to check which one of the two serial channels is more likely to receive data and use the real HW Serial port for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The duration of the polling of the SoftwareSerial library is also influenced by the bitrate used on the port: the higher the bitrate, the shorter the duration of the lockups, so try to use the highest bitrate you can afford, on the Software Serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you find out that you cannot afford letting SW handle one of the 2 serial ports, you can try the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 250&lt;/a&gt;, which has several UART HW blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the specific use case: if either of your motor controllers supports I2C or SPI, you could consider using that, as alternative to the SoftwareSerial.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-08-19T18:54:07.517" LastActivityDate="2015-08-19T18:54:07.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14341" PostTypeId="1" AcceptedAnswerId="14344" CreationDate="2015-08-19T12:19:34.060" Score="0" ViewCount="1949" Body="&lt;p&gt;I want to calculate the number of pulses coming from motor1 encoder pin2 (Int0) as input , and motor 2 encoder pin3 (Int1), I am working now for the first motor (just for the first motor ) so I set timer 2 to count 50 ms then throw flag in this moment I have to send the number of pulses to my screen, but not succeeded cause i see   on my screen zeros and ascii caracters but not the  number of pulses.:this my code .&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; volatile int  pulses = 0;&#xA;&#xA; int flag=0;&#xA; int setbit = 0;&#xA; int encoder_in = 2;&#xA; void count() {&#xA;&#xA;       pulses++;&#xA;     }&#xA;&#xA;  void setup()&#xA;   {&#xA;&#xA;&#xA;&#xA; Serial.begin(115200);&#xA; pinMode(encoder_in, INPUT);&#xA;digitalWrite(2, HIGH); //Enable pullup&#xA;&#xA;// initialize timer2&#xA; noInterrupts();           // disable all interrupts&#xA;&#xA;TCCR2A = 0x00;&#xA; TCCR2B = 0x07;  &#xA;TCNT2 = 0x64;&#xA;//EIMSK = 0x03;     // Enable external interrupt INT0&#xA;//EICRA = 0x0f;    // Trigger INT0 on falling edge &#xA;&#xA; TIMSK2 |= 0x01;  // enable timer compare interrupt&#xA;interrupts();             // enable all interrupts&#xA;attachInterrupt(0,count,RISING);&#xA;&#xA; }&#xA;  ISR(TIMER2_OVF_vect)        &#xA;{&#xA;TCNT2 = 0x64;            // preload timer&#xA; setbit=setbit+1;&#xA;  if(setbit==5)&#xA;  {&#xA;  flag=1;&#xA; setbit=0;&#xA;&#xA;   }&#xA;}&#xA;&#xA; //ISR(EXT_INT0_vect)&#xA; //{ pulses++; }&#xA;&#xA;&#xA;&#xA; void loop()&#xA;{&#xA;&#xA; if (flag==1)&#xA; {&#xA;&#xA;   Serial.println(pulses);&#xA;    pulses=0; &#xA;&#xA;&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11856" OwnerDisplayName="omran" LastEditorUserId="10794" LastEditDate="2015-09-12T00:29:18.423" LastActivityDate="2015-09-12T00:29:18.423" Title="counting pulses from encoder on interrupt 0 pin every 50 ms" Tags="|c++|interrupt|timers|rotary-encoder|" AnswerCount="2" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14342" PostTypeId="2" ParentId="14341" CreationDate="2015-08-19T12:38:32.127" Score="0" Body="&lt;p&gt;Check the Baud Rate in Serial Monitor. If baud rate is not correct i.e. 9600 bps then it will show garbage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove the Timer and Wire Libs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;add this code in void setup()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0,void_counter,RISING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the above is for the the external interrupt input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and attach your sensor/incoming pulse wire on Pin 2 on arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;make a new function like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void_counter(){ &#xA;pulses++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15089" OwnerDisplayName="ammar.cma" LastActivityDate="2015-08-19T12:46:34.670" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14344" PostTypeId="2" ParentId="14341" CreationDate="2015-08-19T21:48:12.777" Score="0" Body="&#xA;&#xA;&lt;p&gt;Your technique looks convoluted to me. How about this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile bool counting;&#xA;volatile unsigned long events;&#xA;&#xA;unsigned long startTime;&#xA;const unsigned long INTERVAL = 50;  // ms&#xA;&#xA;void eventISR ()&#xA;  {&#xA;  if (counting)&#xA;    events++;    &#xA;  }  // end of eventISR&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  pinMode (2, INPUT_PULLUP);&#xA;  attachInterrupt (0, eventISR, RISING);&#xA;  }  // end of setup&#xA;&#xA;void showResults ()&#xA;  {&#xA;  Serial.print (&quot;I counted &quot;);&#xA;  Serial.println (events);&#xA;  }  // end of showResults&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (counting)&#xA;    {&#xA;    // is time up?&#xA;    if (millis () - startTime &amp;lt; INTERVAL)&#xA;      return;  &#xA;    counting = false;&#xA;    showResults ();&#xA;    }  // end of if&#xA;&#xA;  noInterrupts ();&#xA;  events = 0;&#xA;  startTime = millis ();&#xA;  EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;  counting = true;&#xA;  interrupts ();&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Explanation&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Using a timer to detect when 50 ms is up isn't particularly helpful in this case. You can't do printing inside an ISR, so you would have to set a flag that can be checked in the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to check a flag anyway, you may as well just check if the time is up, as my code does. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the ISR, I stop adding to &lt;code&gt;events&lt;/code&gt; if the flag &lt;code&gt;counting&lt;/code&gt; is false. This is to stop &lt;code&gt;events&lt;/code&gt; being changed at the exact moment it is being printed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-20T02:31:31.330" LastActivityDate="2015-08-20T02:31:31.330" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14345" PostTypeId="1" CreationDate="2015-08-19T21:49:16.577" Score="0" ViewCount="3527" Body="&lt;p&gt;I want to add the following boards:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://redbearlab.github.io/arduino/package_redbearlab_index.json&quot; rel=&quot;nofollow&quot;&gt;https://redbearlab.github.io/arduino/package_redbearlab_index.json&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which I can add in the Arduino IDE by going to File -&gt; Preferences -&gt; Additional Boards Manager URLs and just pasting it there&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where is the equivalent function in Eclipse, or how do I configure Eclipse to allow me to develop for those boards? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Eclipse, I have tried Window-&gt; Properties -&gt; Arduino and from there &quot;Private Library Path&quot; and &quot;Private hardware path&quot;, and I have tried pointing them to &quot;C:\Program Files (x86)\Arduino\hardware&quot; and &quot;C:\Program Files (x86)\Arduino\libraries&quot;, but that didn't seem to change anything (i.e. no new board options, even after running Eclipse as admin) - while the boards show up (examples and all) in the Arduino IDE&lt;/p&gt;&#xA;" OwnerUserId="10606" LastActivityDate="2016-02-23T16:34:34.407" Title="How can I add additional boards to Eclipse with the Arduino add-on with only a URL, not a zip file" Tags="|eclipse|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14346" PostTypeId="1" AcceptedAnswerId="14347" CreationDate="2015-08-19T21:57:24.283" Score="5" ViewCount="15172" Body="&lt;p&gt;I have an &lt;strong&gt;Arduino Uno&lt;/strong&gt; &lt;em&gt;(a SainSmart model, actually)&lt;/em&gt;. I intend to power it with three 1.5V batteries. I measured them and they yield 4.67V in total. The Arduino requires 5V.&lt;/p&gt;&#xA;&lt;h1&gt;The question is, if the arduino will work this way.&lt;/h1&gt;&#xA;&lt;p&gt;I'm not powering complicated microcontroller components here. These components are used:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A buzzer&lt;/li&gt;&#xA;&lt;li&gt;An LED&lt;/li&gt;&#xA;&lt;li&gt;A unit of 4 seven segment displays&lt;/li&gt;&#xA;&lt;li&gt;A couple of buttons as input elements&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If the volume or brightness of these components is slightly decreased, it doesn't matter at all. But I would like to know if it will work in the first place.&lt;/p&gt;&#xA;&lt;h1&gt;And also...&lt;/h1&gt;&#xA;&lt;p&gt;Where exactly do I plug the power source in? The power jack, the USB jack, pins, somewhere else?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;The schematic looks like this&lt;/strong&gt;, just to illustrate it. I'm not a good drawer, but you'll get the idea...&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6OazX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6OazX.png&quot; alt=&quot;schematic&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8762" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-01-23T05:47:38.340" Title="How to power an Arduino Uno with 3 1.5V batteries?" Tags="|arduino-uno|power|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14347" PostTypeId="2" ParentId="14346" CreationDate="2015-08-19T22:06:39.097" Score="11" Body="&lt;p&gt;The Arduino doesn't &lt;em&gt;require&lt;/em&gt; 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmel chip on the board &lt;em&gt;requires&lt;/em&gt; somewhere between 1.8V and 5.5V, the Arduino just happens to have chosen 5V as a good common widely used voltage to run at.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you provide a voltage within that range to the +5V pin the board will operate.  There's a couple of caveats though:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Anything below about 4V will mean the 3.3V regulator won't be working right, so the 3.3V pin won't be functioning properly&lt;/li&gt;&#xA;&lt;li&gt;At lower voltages the Atmel chip can't operate reliably at higher frequencies, which is why 3.3V Arduino boards operate at 8MHz instead of 16Mhz.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So 3 x AA batteries is a perfect power source for running the Arduino, direct into the 5V pin.  Just make sure that you don't power it any other way at the same time or you'll be pumping 5V into your batteries.  You may want to add a Schottky diode in series with your battery + (between battery + and the 5V pin) to stop that ever causing a problem.  Choose one with a very low forward voltage drop though, otherwise you could end up dropping too much of your precious voltage over the diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, when you're powering it from USB the 5V could be anywhere between 4.75V and 5.25V.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-19T22:06:39.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14348" PostTypeId="2" ParentId="14346" CreationDate="2015-08-19T22:29:51.940" Score="3" Body="&lt;p&gt;As per @Majenko's answer, yes, this will work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some caveats: the Atmel chip at the center of the Arduino has brown-out detection - if it drops below a certain voltage, the chip will shut down. This voltage is selectable: 4.3v, 2.7v, 1.8v, or off. The factory default for the chip is &quot;off&quot;, I found a reference that the Uno sets this at 2.7V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you are powering anything else with your battery, e.g. a motor, the voltage is will drop - if it drops below the brownout, the arduino will shut down (usually also shutting down the external device, causing the voltage to rise again, causing it to power up again). An LED (with a correct resistor) should be fine.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-19T22:29:51.940" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14349" PostTypeId="1" CreationDate="2015-08-20T00:16:45.583" Score="0" ViewCount="544" Body="&lt;p&gt;I have a Adafruit Pro Trinket. I'm having issues getting GPS and and SD card working together. The trinket can be connected via USB but there is no serial connection do debugging my program is hard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/p0OBI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/p0OBI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I purchased an FTDI connector from sparkfun, installed the FTDI software and connected to the trinket. My code complies but it won't flash. The error is confusing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone please help me figure out how to get it to flash?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.4 (Mac OS X), Board: &quot;Pro Trinket 3V/12MHz (FTDI)&quot;&#xA;&#xA;Sketch uses 19,896 bytes (69%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 1,476 bytes of dynamic memory.&#xA;avrdude: ser_open(): can't open device &quot;/dev/cu.usbmodem1a21&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the &quot;verbose&quot; version of the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.4 (Mac OS X), Board: &quot;Pro Trinket 3V/12MHz (FTDI)&quot;&#xA;&#xA;Using library SPI in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI &#xA;Using library Adafruit GPS Library in folder: /Users/futurebird/Documents/Arduino/libraries/Adafruit-GPS-Library-master &#xA;Using library SoftwareSerial in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial &#xA;Using library SdFat in folder: /Users/futurebird/Documents/Arduino/libraries/SdFat (legacy)&#xA;&#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=12000000L -DARDUINO=10604 -DARDUINO_AVR_PROTRINKET5FTDI -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/eightanaloginputs -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI -I/Users/futurebird/Documents/Arduino/libraries/Adafruit-GPS-Library-master -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial -I/Users/futurebird/Documents/Arduino/libraries/SdFat /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp -o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.o &#xA;Using previously compiled file: /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SPI/SPI.cpp.o&#xA;&#xA;(^^repeats many times for different files)&#xA;&#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -Wall -Os -Wl,--gc-sections -mmcu=atmega328p -o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.elf /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SPI/SPI.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/Adafruit GPS Library/Adafruit_GPS.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SoftwareSerial/SoftwareSerial.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/MinimumSerial.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdFatBase.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdFatUtil.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdSpiCard.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdSpiSAM3X.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdSpiSTM32F1.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/SdSpiTeensy3.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FatFile.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FatFileLFN.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FatFilePrint.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FatFileSFN.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FatVolume.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/FmtNumber.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/fstream.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/istream.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/ostream.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/SdFat/utility/StdioStream.cpp.o /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/core.a -L/var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp -lm &#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.elf /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.eep &#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.elf /var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.hex &#xA;&#xA;Sketch uses 19,896 bytes (69%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 1,476 bytes of dynamic memory.&#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem1a21 -b115200 -D -Uflash:w:/var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build4892553004123204558.tmp/little_GPS.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/futurebird/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/cu.usbmodem1a21&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: ser_open(): can't open device &quot;/dev/cu.usbmodem1a21&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;UPDATE&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I looked in the /dev/ directory and found these which match the menu in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cu.Bluetooth-Incoming-Port&lt;br&gt;&#xA;cu.Bluetooth-Modem&lt;br&gt;&#xA;cu.JabraREVOa400-SPPDev &#xA;cu.LightBlue-Bean&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WKYpG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WKYpG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above files are int the dev folder but not cu.usbmodem1a21. How can I get it? Or is it looking for the wrong file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what my board selection looks like. I think the issue is the port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u2wsB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u2wsB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="8769" LastEditDate="2015-08-20T00:39:42.423" LastActivityDate="2015-09-19T00:47:45.587" Title="I can upload via USB but not FTDI" Tags="|ftdi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14350" PostTypeId="2" ParentId="14349" CreationDate="2015-08-20T00:22:57.837" Score="1" Body="&lt;p&gt;Things to check:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Does the file exist? check with &lt;code&gt;ls&lt;/code&gt; if the file that avrdude tries to open is actually there&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do you have the right to open it? Opening a serial port requires having the appropriate rights, iow you user belongs to the same group that the device belongs to.&#xA;On linux this is usually wheel or dialout, depending on the distro. Again, &lt;code&gt;ls -la&lt;/code&gt; is your friend.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is your device identified correctly? Meaning that you are not trying to have avrdude address the device wit the wrong protocol.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-20T00:22:57.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14351" PostTypeId="1" AcceptedAnswerId="14366" CreationDate="2015-08-20T01:21:55.930" Score="1" ViewCount="111" Body="&lt;p&gt;Lets say I have something that sends a command to the Arduino (for example, a PC sending through serial, Ethernet, etc). I want the Arduino to &quot;check&quot; what command it is and run a specific function linked to that command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't need a very explanatory answer, just give me something so I can learn from. A sketch that shows a similar idea would be good, I can try to interpret it and adapt/remake for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to use the Arduino for a lot of different things. Let's say:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Turn a bunch of leds on/off;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read data from a sensor and send it through Ethernet/I2C/Serial;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Control a servo. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;But I want the Arduino to do that when I tell it to (in this case, sending the command through serial, etc). So let's say I send it 1, I'll want it to run the 1 function (turning the LEDs on/off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already took a &lt;a href=&quot;http://sheepdogguides.com/arduino/FA1main.htm&quot; rel=&quot;nofollow&quot;&gt;tutorial course on Arduino programming&lt;/a&gt;, but I'm clueless on how to do this job.&lt;/p&gt;&#xA;" OwnerUserId="11905" LastEditorUserId="10794" LastEditDate="2015-08-20T03:36:15.247" LastActivityDate="2015-08-20T15:24:50.913" Title="Run a part of code upon call" Tags="|serial|programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14352" PostTypeId="2" ParentId="14351" CreationDate="2015-08-20T02:25:32.357" Score="0" Body="&lt;p&gt;If you just want some example code, here is a smallish sketch I wrote that controls some LEDs via a shift register. Exactly how the shift register works isn't important, but you can see the basic idea for taking input from the serial port and decoding it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const byte LATCH = 10;&#xA;&#xA;const byte numberOfChips = 4;&#xA;const byte maxLEDs = numberOfChips * 8;&#xA;&#xA;byte LEDdata [numberOfChips] = { 0 };  // initial pattern&#xA;&#xA;void refreshLEDs ()&#xA;  {&#xA;  digitalWrite (LATCH, LOW);&#xA;  for (int i = numberOfChips - 1; i &amp;gt;= 0; i--)&#xA;    SPI.transfer (LEDdata [i]); &#xA;  digitalWrite (LATCH, HIGH);&#xA;  } // end of refreshLEDs&#xA;&#xA;&#xA;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 10;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin(115200);&#xA;  SPI.begin ();&#xA;  refreshLEDs ();&#xA;} // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (char * data)&#xA;  {&#xA;  Serial.print (&quot;Got command: &quot;);&#xA;  Serial.println (data);&#xA;&#xA;  // C: clear all bits&#xA;  switch (toupper (data [0]))&#xA;    {&#xA;     case 'C':&#xA;        {&#xA;        for (int i = 0; i &amp;lt; numberOfChips; i++) &#xA;          LEDdata [i] = 0;&#xA;        Serial.println (&quot;All bits cleared.&quot;);&#xA;        refreshLEDs ();&#xA;        return;&#xA;        }&#xA;&#xA;    // S: set all bits&#xA;    case 'S':&#xA;        {&#xA;        for (int i = 0; i &amp;lt; numberOfChips; i++) &#xA;          LEDdata [i] = 0xFF;&#xA;        Serial.println (&quot;All bits set.&quot;);&#xA;        refreshLEDs ();&#xA;        return;&#xA;        }&#xA;&#xA;    // I: invert all bits&#xA;    case 'I':&#xA;        {&#xA;        for (int i = 0; i &amp;lt; numberOfChips; i++) &#xA;          LEDdata [i] ^= 0xFF;&#xA;        Serial.println (&quot;All bits inverted.&quot;);&#xA;        refreshLEDs ();&#xA;        return;&#xA;        }&#xA;    } // end of switch&#xA;&#xA;  // otherwise: nnx &#xA;  //   where nn is 1 to 89 and x is 0 for off, or 1 for on&#xA;&#xA;  // check we got numbers&#xA;  for (int i = 0; i &amp;lt; 3; i++)&#xA;    if (!isdigit (data [i]))&#xA;      {&#xA;      Serial.println (&quot;Did not get 3 digits.&quot;);&#xA;      return;&#xA;      }&#xA;&#xA;  // convert first 2 digits to the LED number&#xA;  byte led = (data [0] - '0') * 10 + (data [1] - '0');&#xA;&#xA;  // convert third digit to state (0 = off)&#xA;  byte state = data [2] - '0';  // 0 = off, otherwise on&#xA;&#xA;  if (led &amp;gt; maxLEDs)&#xA;      {&#xA;      Serial.println (&quot;LED # too high.&quot;);&#xA;      return;&#xA;      }&#xA;&#xA;   led--;  // make zero relative&#xA;&#xA;   // divide by 8 to work out which chip&#xA;   byte chip = led / 8;  // which chip&#xA;&#xA;   // remainder is bit number&#xA;   byte bit = 1 &amp;lt;&amp;lt; (led % 8);&#xA;&#xA;   // turn bit on or off&#xA;   if (state)&#xA;     LEDdata [chip] |= bit;&#xA;   else&#xA;     LEDdata [chip] &amp;amp;= ~ bit;&#xA;&#xA;  Serial.print (&quot;Turning &quot;);&#xA;  Serial.print (state ? &quot;on&quot; : &quot;off&quot;);&#xA;  Serial.print (&quot; bit &quot;);&#xA;  Serial.print (led &amp;amp; 0x7, DEC);&#xA;  Serial.print (&quot; on chip &quot;);&#xA;  Serial.println (chip, DEC);&#xA;&#xA;  refreshLEDs ();&#xA;  }  // end of process_data&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;static char input_line [MAX_INPUT];&#xA;static unsigned int input_pos = 0;&#xA;&#xA;  if (Serial.available () &amp;gt; 0) &#xA;    {&#xA;    char inByte = Serial.read ();&#xA;&#xA;    switch (inByte)&#xA;      {&#xA;&#xA;      case '\n':   // end of text&#xA;        input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;        // terminator reached! process input_line here ...&#xA;        process_data (input_line);&#xA;&#xA;        // reset buffer for next time&#xA;        input_pos = 0;  &#xA;        break;&#xA;&#xA;      case '\r':   // discard carriage return&#xA;        break;&#xA;&#xA;      default:&#xA;        // keep adding if not full ... allow for terminating null byte&#xA;        if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;          input_line [input_pos++] = inByte;&#xA;        break;&#xA;&#xA;      }  // end of switch&#xA;&#xA;  }  // end of incoming data&#xA;&#xA;  // do other stuff here like testing digital input (button presses) ...&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example of commands understood by the above code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C    &amp;lt;-- clear all LEDs&#xA;S    &amp;lt;-- set (turn on ) all LEDs&#xA;I    &amp;lt;-- invert all LEDs (turn off if on, and vice-versa)&#xA;021  &amp;lt;-- turn LED 02 on&#xA;020  &amp;lt;-- turn LED 02 off&#xA;161  &amp;lt;-- turn LED 16 on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code processes a 3-digit string as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nnS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &quot;nn&quot; is the LED number and S is the new state (1 = on, 0 = off).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Other examples&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is a more elaborate example on my page about &lt;a href=&quot;http://gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow&quot;&gt;using a 74HC595 output shift register as a port-expander&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;How to process incoming serial data without blocking&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;State machines&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-20T02:25:32.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14353" PostTypeId="1" CreationDate="2015-08-20T02:29:11.563" Score="1" ViewCount="1220" Body="&lt;p&gt;I have an Arduino Uno and a Texas Instruments CC3000 WiFi shield. I need to connect the Arduino to a local network which has no Internet access so that it can send information to a computer also connected to the same local network. I am using a Linksys WRT120N for the local network. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't use the Internet access WiFi because it is WPA2 Enterprise which is why I created the local network. Currently the computer is connected to the local network via WiFi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have downloaded and installed the correct library but when I run the connection test, it searches for Internet access which doesn't exist and sends back errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I verify that it is connecting to the local network? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, I have almost no experience coding an Arduino but I have access to people who are proficient; However, they have no experience with a WiFi shield.&lt;/p&gt;&#xA;" OwnerUserId="11906" LastEditorUserId="10794" LastEditDate="2015-08-20T03:03:58.057" LastActivityDate="2015-08-20T03:16:49.713" Title="Can wifi shield connect to local network without internet?" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14354" PostTypeId="2" ParentId="14353" CreationDate="2015-08-20T03:16:49.713" Score="1" Body="&lt;p&gt;If you have created your own local network, you may need a DHCP server to give it an IP address, or you will have to configure your Arduino with a static ip. I can't think of a reason why it would need internet access, but it is not uncommon for devices to refer (incorrectly) to connectivity issues on the local network as &quot;internet&quot; issues. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-20T03:16:49.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14359" PostTypeId="1" AcceptedAnswerId="14360" CreationDate="2015-08-20T09:29:41.840" Score="0" ViewCount="2829" Body="&lt;p&gt;I learned, that SPI-code uses interrupts. So is it true then, that I can't use SPI related code inside an ISR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Background: I want to capture one or more revolution speeds with an MCP23S17. I rewired the interrupt lines to INT1 and INT2 accordingly to get the interrupts at the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it was good to fetch the port registers from the MCP23S17 inside the ISR, but this apparently doesn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the only thing I can do in my ISR set a flag for another test in the main loop? And let a routine called from lood() then poll the registers from the port expander? This opposes the idea to fetch the relevant data which issued the interrupt ASAP. &lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-08-20T09:45:20.237" Title="Usage of SPI inside an ISR" Tags="|interrupt|spi|isr|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14360" PostTypeId="2" ParentId="14359" CreationDate="2015-08-20T09:45:20.237" Score="4" Body="&lt;p&gt;SPI doesn't use interrupts.  It references the interrupt flag to know if a transfer has been completed, but it doesn't actually have interrupts enabled:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPDR = data;&#xA;asm volatile(&quot;nop&quot;);&#xA;while (!(SPSR &amp;amp; _BV(SPIF))) ; // wait&#xA;return SPDR;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be perfectly possible to use SPI within the interrupt - indeed there is portions of the SPI API that deal specifically with this - see &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPIusingInterrupt&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/SPIusingInterrupt&lt;/a&gt; for instance.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-20T09:45:20.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14361" PostTypeId="1" CreationDate="2015-08-20T11:08:23.927" Score="4" ViewCount="1092" Body="&lt;p&gt;I'm trying to connect my Arduino Mega via Wifi to my XAMPP server. My main objective is get a value from my database and store it on a variable in Arduino code. With this new variable I'll be able to control the rest of the program... So I need your help. Can someone give me advice?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried every thing that I found on the internet but it just doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the simple way is to send a GET request to the server and read its response... But for some reason I can't send a GET request through...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it on the browser directly and the value shows up, so I think that the server side is all right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &quot;WiFly.h&quot;&#xA;#include &quot;HTTPClient.h&quot;&#xA;&#xA;#define SSID      &quot;mySSID&quot;&#xA;#define KEY       &quot;myKEY&quot;&#xA;#define AUTH      WIFLY_AUTH_WPA2_PSK&#xA;#define HTTP_GET_URL &quot;http://192.168.1.80/xampp/training/send_data_db.php/?temp=0&quot;&#xA;&#xA;// Pins' connection&#xA;// Arduino       WiFly&#xA;//  2    &amp;lt;----&amp;gt;    TX&#xA;//  3    &amp;lt;----&amp;gt;    RX&#xA;SoftwareSerial uart(10, 11);&#xA;WiFly wifly(uart);&#xA;HTTPClient http;&#xA;char get;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;------- WIFLY HTTP --------&quot;);&#xA;  uart.begin(9600); // WiFly UART Baud Rate: 9600&#xA;  // Wait WiFly to init&#xA;  //  delay(3000);&#xA;&#xA;  // check if WiFly is associated with AP(SSID)&#xA;  if (!wifly.isAssociated(SSID)) {&#xA;    while (!wifly.join(SSID, KEY, AUTH)) {&#xA;      Serial.println(&quot;Failed to join &quot; SSID);&#xA;      Serial.println(&quot;Wait 0.1 second and try again...&quot;);&#xA;      delay(100);&#xA;    }&#xA;    wifly.save(); // save configuration,&#xA;  }&#xA;  Serial.println(&quot;\r\nTry to get url - &quot; HTTP_GET_URL);&#xA;  Serial.println(&quot;------------------------------&quot;);&#xA;  while (http.get(HTTP_GET_URL, 10000) &amp;lt; 0) {&#xA;  }&#xA;  while (wifly.receive((uint8_t *)&amp;amp;get, 1, 1000) == 1) {&#xA;    Serial.print(get);&#xA;  }&#xA;  if (wifly.commandMode()) {&#xA;    Serial.println(&quot;\r\n\r\nEnter command mode. Send \&quot;exit\&quot;(with \\r) to exit command mode&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  int c;&#xA;  while (wifly.available()) {&#xA;    c = wifly.read();&#xA;    if (c &amp;gt; 0) {&#xA;      Serial.write((char)c);&#xA;    }&#xA;  }&#xA;  while (Serial.available()) {&#xA;    c = Serial.read();&#xA;    if (c &amp;gt;= 0) {&#xA;      wifly.write((char)c);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is my PHP code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;? php&#xA;include(&quot;./connection/database_connect.php&quot;);&#xA;include(&quot;./top_table.php&quot;);&#xA;&#xA;if ((isset($_SESSION[&quot;ID&quot;])) AND (isset($_GET[&quot;temp&quot;]))) {&#xA;  $id = $_SESSION[&quot;ID&quot;];&#xA;  $sql = &quot;SELECT temp FROM perfil, client WHERE perfil.ID ='$id'&quot;;&#xA;  $consult = mysqli_query($connect, $sql);&#xA;  $result = mysqli_num_rows($consult);&#xA;  if (($result == 1)) {&#xA;    $person_data = mysqli_fetch_array($consult, MYSQLI_ASSOC);&#xA;    $temp = $person_data[&quot;temp&quot;];&#xA;    header(&quot;HTTP/1.1&quot; . &quot; &quot; . 200 . &quot;OK&quot;);&#xA;    header(&quot;Content-Type: text/html; charset=UTF-8&quot;);&#xA;    header(&quot;Content-Length: 1112&quot;);&#xA;    header(&quot;Connection: close&quot;);&#xA;    header(&quot;/r/n&quot;);&#xA;    echo $temp;&#xA;  } else {&#xA;    //se user dosen't exist on data base&#xA;    header(&quot;Location: http://192.168.1.80/xampp/training/login.php&quot;);&#xA;    exit;&#xA;  }&#xA;} else {&#xA;  header(&quot;Location: http://192.168.1.80/xampp/training/login.php&quot;);&#xA;  exit;&#xA;}&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11914" LastEditorUserId="4628" LastEditDate="2018-04-08T02:40:39.957" LastActivityDate="2019-10-13T19:02:40.417" Title="How can an Arduino Mega 2560+Wifi Shield 2.0 (SeeedStudio) receive data from database in a XAMPP server on my PC?" Tags="|programming|arduino-mega|shields|wifi|web-server|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14363" PostTypeId="1" AcceptedAnswerId="14367" CreationDate="2015-08-20T12:53:31.490" Score="0" ViewCount="318" Body="&lt;p&gt;I was having an issue very similar to this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/3324/arduino-compatibles-serial-port-not-showing-mac-osx&quot;&gt;Arduino compatible&amp;#39;s serial port not showing Mac OSX&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I have a clone (VISduino) and it's made with a different USB chip so it needed a driver. Installing the driver didn't help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;didn't help. So I decided to delete Arduino and reinstall. Then I went through all of the steps again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well.... now nothing works. Before doing this I could use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adafruit metro &lt;/li&gt;&#xA;&lt;li&gt;An uno clone &lt;/li&gt;&#xA;&lt;li&gt;My genuine uno&lt;/li&gt;&#xA;&lt;li&gt;lightBlue Bean&lt;/li&gt;&#xA;&lt;li&gt;adafruit trinket and trinket pro &lt;/li&gt;&#xA;&lt;li&gt;adafruit trinket pro via USB&lt;/li&gt;&#xA;&lt;li&gt;digikey&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TSdpy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TSdpy.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've reinstalled the drivers for these but NOTHING is working now. They were all working before. It just says Arduino Uno on COM1, or digikey on COM1 etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/c6Z1i.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/c6Z1i.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course my clone (vis duino) isn't working either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2VQUA.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2VQUA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The com ports just are not there.&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-12-18T19:10:24.917" Title="Tried to fix ports on Mac OS X Yosemite. Now nothing works" Tags="|mac-os|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14364" PostTypeId="1" AcceptedAnswerId="14365" CreationDate="2015-08-20T13:30:21.727" Score="0" ViewCount="891" Body="&lt;p&gt;I'm very new to Arduino, and I'm trying to read data from a LaCrosse TX23 V02(X) anemometer. It's supposed to behave like this &lt;a href=&quot;https://www.john.geek.nz/2012/08/la-crosse-tx23u-anemometer-communication-protocol/&quot; rel=&quot;nofollow&quot;&gt;https://www.john.geek.nz/2012/08/la-crosse-tx23u-anemometer-communication-protocol/&lt;/a&gt;, but it's not...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have an oscilloscope, so I made this code, using micros() to try to trace the output from the TX23:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  collectData();&#xA;}&#xA;&#xA;&#xA;int collectData(void){&#xA;   if (bitLength &amp;lt; 0){&#xA;      bitLength = 1200;// length of bit is equal to approx 1230 micro seconds;&#xA;   }&#xA;  // init sequence&#xA;  pinMode(dataPin, OUTPUT);&#xA;  Serial.print(&quot;Send LOW\n&quot;);&#xA;  digitalWrite(dataPin, LOW );&#xA;  Serial.print(&quot;Send HIGH\n&quot;);&#xA;  digitalWrite(dataPin, HIGH);&#xA;  delay(100);&#xA;  Serial.print(&quot;Send LOW\n&quot;);&#xA;  digitalWrite(dataPin, LOW );&#xA;  delay(500);&#xA;&#xA;  Serial.print(&quot;Begin input mode\n&quot;);&#xA;  pinMode(dataPin, INPUT);&#xA;&#xA;  int state = 0;&#xA;  int oldstate = 0;&#xA;  unsigned long oldmicros = micros();&#xA;  for (int i = 1; i&amp;lt;5250 ; i++) {&#xA;    state = (digitalRead(dataPin) == LOW)? 0:1;&#xA;    if (i%10 != 0) {&#xA;      Serial.print(&quot;-&quot;);&#xA;    } else {&#xA;      Serial.print(&quot;+&quot;);&#xA;    }&#xA;&#xA;    delayMicroseconds(10);&#xA;    if (state != oldstate) {&#xA;      oldstate = state;&#xA;      i = 1;&#xA;      Serial.print(oldstate);&#xA;      Serial.print(&quot; @&quot;);&#xA;      Serial.print(micros() - oldmicros);&#xA;      oldmicros = micros();&#xA;      Serial.print(&quot;\n&quot;);&#xA;    } &#xA;  }&#xA;  Serial.print(state);&#xA;  Serial.println(micros()-oldmicros);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does it have a chance to provide a quite accurate monitoring of the TX23 output? (eg is using micros() or delayMicroseconds(10) accurate ?)&lt;/p&gt;&#xA;" OwnerUserId="11917" LastActivityDate="2015-08-21T04:03:13.467" Title="Can I use micros() to analyze TX23 anemometer signal?" Tags="|arduino-uno|programming|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14365" PostTypeId="2" ParentId="14364" CreationDate="2015-08-20T13:49:02.593" Score="1" Body="&lt;p&gt;You should really make use of &lt;code&gt;pulseIn()&lt;/code&gt; to work out the bit rate of the signal.  The first HIGH pulse in the header is there for timing so you know how often to poll the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step one, after sending your outgoing initiation pulse, should be to wait for that first pulse (you might need a slight delay first before it starts transmitting - wait for the line to be low first):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (digitalRead(dataPin) == HIGH); // Wait for TX start&#xA;uint32_t pulseWidth = pulseIn(dataPin, HIGH); // Get first pulse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That gives you the width of the first pulse in microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can read 45 times at that period.  If you first delay by half that amount before your first sample you will be roughly in the middle of the bit so you can cope with a slight amount of drift.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Wait for the middle of the first bit&#xA;delayMicroseconds(pulseWidth / 2);&#xA;&#xA;uint32_t highBlock = 0;&#xA;uint32_t lowBlock = 0;&#xA;for (int i = 0; i &amp;lt; 45; i++) {&#xA;    // Shift the high 32-bits left one bit&#xA;    highBlock &amp;lt;&amp;lt;= 1;&#xA;    // Place in the highest bit of the low block as the lowest&#xA;    // bit of the high block&#xA;    highBlock |= (lowBlock &amp;amp; 0x80000000UL ? 1 : 0); &#xA;    // Shift the low 32-bits left one bit&#xA;    lowBlock &amp;lt;&amp;lt;= 1;&#xA;    // Add in the value of the bit from the data pin&#xA;    lowBlock |= digitalRead(dataPin);&#xA;    // Wait for the next bit&#xA;    delayMicroseconds(pulseWidth);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should now have two 32-bit words which, when put together, form the entire datagram.  You can now use bitwise operators to pull out the parts you are interested in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better, though more complex, method of doing it would be to employ a timer with an overflow period equal to the pulse width. That will afford you much more accurate timing than a simple loop with delays.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-20T13:49:02.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14366" PostTypeId="2" ParentId="14351" CreationDate="2015-08-20T15:09:22.887" Score="1" Body="&lt;p&gt;If you want it really barebones and easy, you can checkout the Arduino &quot;Dimmer&quot; example sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of changing the brightness of an attached pin, you could take the input you send it over the serial console and execute various functions, depending on what you receive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean newCommand = false;&#xA;void setup()&#xA;{&#xA;  // initialize the serial communication:&#xA;  Serial.begin(9600);&#xA;&#xA;  // other setup stuff here&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  byte command;&#xA;&#xA;  // check if data has been sent from the computer:&#xA;  if (Serial.available()) &#xA;  {&#xA;    // read the most recent byte (which will be from 0 to 255):&#xA;    command = Serial.read();&#xA;    // say that you received a new command&#xA;    newCommand = true;&#xA;  }&#xA;&#xA;  // is there a new command?&#xA;  if (newCommand == true)&#xA;  {&#xA;    // do something depending on what command you received&#xA;    switch(command)&#xA;    {&#xA;      // if you receive command &quot;1&quot;, do something&#xA;      case 1: functionWhatever();&#xA;              break;  // &quot;break&quot; out of the switch. otherwise it would continue executing the following commands as well&#xA;      case 2: functionWhatever2();&#xA;              break;&#xA;      //for cases that are not caught, send out an error&#xA;      default: Serial.write(&quot;invalid command&quot;);&#xA;              break;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to use an existing library, you might want to check out: &#xA;&lt;a href=&quot;https://github.com/madsci1016/Arduino-EasyTransfer&quot; rel=&quot;nofollow&quot;&gt;EasyTransfer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be used for communication between two Arduinos, which you then can use to execute functions on the other side of the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code itself is relatively simple, so you might be able to adapt it to communicate with a processing script on your computer for example.&lt;/p&gt;&#xA;" OwnerUserId="11915" LastEditorUserId="11915" LastEditDate="2015-08-20T15:24:50.913" LastActivityDate="2015-08-20T15:24:50.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14367" PostTypeId="2" ParentId="14363" CreationDate="2015-08-20T15:55:00.607" Score="0" Body="&lt;p&gt;I solved this issue by deleting all of the Arduino files and the Arduino app. I put my sketched folder aside but deleted all libraries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarted the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Installed Arduino fresh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarted the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Installed the drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ran the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarted the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarted the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarted the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it worked.&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-08-20T15:55:00.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14368" PostTypeId="2" ParentId="14364" CreationDate="2015-08-20T17:10:59.303" Score="1" Body="&lt;p&gt;Majenko showed a method for digitally recording the waveform, after measuring &lt;code&gt;pulseWidth&lt;/code&gt; at the outset, and mentioned use of a timer for delays.   I'll address the part of your question about using &lt;code&gt;micros()&lt;/code&gt; while tracing TX23 output:  “Does it have a chance to provide a quite accurate monitoring of the TX23 output?” &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the serial output that your method produces as it goes along will affect evenness of timing.  For example, the &lt;code&gt;Serial.print()&lt;/code&gt; of + after every tenth reading introduces a small timing irregularity (the two branches of the &lt;code&gt;if&lt;/code&gt; may differ a few cycles in execution time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More seriously, your double-read of &lt;code&gt;micros()&lt;/code&gt; (after you print &lt;code&gt;oldstate&lt;/code&gt;, you print &lt;code&gt;micros() - oldmicros&lt;/code&gt; and then read &lt;code&gt;micros()&lt;/code&gt; again) introduces a few cycles of timing error.  It probably amounts to a few microseconds total over the course of recording the pulse train.  Instead of reading &lt;code&gt;micros()&lt;/code&gt; twice, say something like &lt;code&gt;newmicros = micros()&lt;/code&gt; directly after detecting a state change, before doing any serial printing, then use &lt;code&gt;newmicros&lt;/code&gt; in place of other &lt;code&gt;micros()&lt;/code&gt; calls.  Having serial prints before &lt;code&gt;oldmicros = micros();&lt;/code&gt; causes an offset error, which will be microseconds or milliseconds depending on the data rate you set in &lt;code&gt;setup()&lt;/code&gt;.  It mostly affects the reported length only of the first pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would do for debug monitoring of the pulse train is along the following lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { timelen=44, maxpause=50000 };&#xA;unsigned long int times[timelen];&#xA;&#xA;int collectData() {&#xA;  byte ntimes = 0, state=LOW;&#xA;  unsigned long int prevtime;&#xA;  pinMode(dataPin, OUTPUT);&#xA;  digitalWrite(dataPin, LOW ); // Pull DTR low to trigger conversion&#xA;  delay(500);&#xA;  pinMode(dataPin, INPUT_PULLUP); // Release DTR and set pullup&#xA;  delay(1);           // Let TX23U pull DTR low&#xA;  prevtime = micros();&#xA;  while (micros() - prevtime &amp;lt; maxpause &amp;amp;&amp;amp; ntimes &amp;lt; timelen) {&#xA;    if (digitalRead(dataPin) != state) {&#xA;      times[ntimes++] = prevtime = micros();&#xA;      state = 1-state;&#xA;    }&#xA;  }&#xA;  return ntimes;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code is intended to record times at which state changes occur.  After &lt;code&gt;loop()&lt;/code&gt; calls &lt;code&gt;collectData()&lt;/code&gt;, it can call a &lt;code&gt;reportData()&lt;/code&gt; routine that will print out pulse lengths by subtracting adjacent entries of &lt;code&gt;times[]&lt;/code&gt;.  Even-indexed array entries are times of rising edges in the pulse train; odd-indexed entries are times of falling edges.  Because the &lt;code&gt;if (digitalRead(dataPin) != state) {...}&lt;/code&gt; statement isn't executed atomically, the data pin can change after being tested but before being recorded a couple of lines later.  Using &lt;code&gt;state = 1-state;&lt;/code&gt; instead of &lt;code&gt;state = digitalRead(dataPin);&lt;/code&gt; guarantees that even indexes are for rising edges, but does not guarantee that adjacent entries correspond to the same pulse edge.  That is, a noisy signal can produce misleading results. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-08-20T17:10:59.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14369" PostTypeId="1" AcceptedAnswerId="14370" CreationDate="2015-08-20T17:11:54.273" Score="5" ViewCount="6947" Body="&#xA;&#xA;&lt;p&gt;Now the code I'm writing in Arduino (Using Arduino) uses multiple 2-dimensional arrays. Now when I print some thing using the Serial Monitor it prints it correctly but when I declare and initialize the 2-dimentional array it won't print it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  int image_width = 56;&#xA;  int image_height = 96;&#xA;&#xA;&#xA;  int image_result[image_width][image_height];&#xA;  for (int i=0; i&amp;lt;image_height; i++) {&#xA;    for (int j=0; j&amp;lt;image_width; j++) {&#xA;      image_result[j][i] = 5;&#xA;    }&#xA;  }&#xA;&#xA;  Serial.print(&quot;code works&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in this case &quot;code works&quot; does not print but when I remove the array declaration and initialization code works is printed. What is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do 2 dimensional arrays work differently in Arduino or is it a space issue?&lt;/p&gt;&#xA;" OwnerUserId="11827" LastEditorUserId="10794" LastEditDate="2015-08-20T20:51:18.803" LastActivityDate="2015-08-28T08:04:55.337" Title="Arduino Uno not able to handle 2-dimensional array" Tags="|arduino-uno|serial|" AnswerCount="6" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14370" PostTypeId="2" ParentId="14369" CreationDate="2015-08-20T17:36:53.483" Score="9" Body="&lt;p&gt;2D arrays work fine on arduino, but you run out of space very quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An uno has 2 kilobytes of ram; your array has 56*96 = 5376 2-byte elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would guess that you are writing over some critical memory value with a 5 at some point causing the program to fail.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-08-20T17:36:53.483" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14371" PostTypeId="1" AcceptedAnswerId="14372" CreationDate="2015-08-16T09:46:34.717" Score="0" ViewCount="1155" Body="&lt;p&gt;On an Arduino you can have several different interrupt types, two of them being RISING and FALLING. Looking past that RISING is from LOW to HIGH, and FALLING is the opposite, what are the benefits of using one or the other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify; why would you use a RISING interrupt or a FALLING interrupt?&lt;/p&gt;&#xA;" OwnerDisplayName="Chrizmo" LastEditorUserId="11729" LastEditDate="2015-08-21T01:24:41.610" LastActivityDate="2015-08-21T01:24:41.610" Title="What's the benefits between different interrupts on Arduino" Tags="|pins|interrupt|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14372" PostTypeId="2" ParentId="14371" CreationDate="2015-08-16T10:16:11.650" Score="8" Body="&lt;p&gt;Imagine that you have the circuit below:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/RFd8S.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fRFd8S.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;noreferrer&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that you wanted to catch the user pressing the button. The input signal will go from high to low, which is a falling edge. So you would use a FALLING interrupt to catch this event. Easy, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's say you wanted to catch a user releasing the button instead. This time the inverse is true, so you want to use a RISING interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should note that since these interrupts are edge triggered, the simple circuit below would not be ideal. Without any debouncing, there may be several edges to trigger from, resulting in repeated interrupts. Also, given the analogue nature of the design, we can't be sure that the rise / fall times will be fast enough to trigger the edge interrupt. We can get around this by adding a 100nF capacitor across the switch and following by a Schmitt trigger (which I can't find a symbol for in the circuit editor!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to answer your question, you use the interrupt that is correct for the event you are trying to catch. The Arduino MCU implements both edges for completeness and flexibility in your design, so if this interrupt was coming from an external IC you have no control over the design of, you can easily match the interrupt to its behaviour without having to add in an inverter.&lt;/p&gt;&#xA;" OwnerUserId="11729" OwnerDisplayName="stefandz" LastActivityDate="2015-08-17T04:41:45.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14373" PostTypeId="2" ParentId="14371" CreationDate="2015-08-16T10:21:30.857" Score="1" Body="&lt;p&gt;Suppose you have a pushbutton that connects Arduino pin to the ground. The pin is also pulled up  to VCC (may be internally in Atmega chip, or through external resistor). Now, when the switch is open, Arduino sees HIGH, and when you press the button it sees LOW. If you would like to perform an action when the button is pressed, you would use FALLING interrupt. If you would like to know when the button is released, you would use RISING. There are no general benefits of using one over another.&lt;/p&gt;&#xA;" OwnerUserId="10591" OwnerDisplayName="mactro" LastActivityDate="2015-08-16T10:21:30.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14374" PostTypeId="2" ParentId="14371" CreationDate="2015-08-20T19:53:19.433" Score="0" Body="&lt;p&gt;The interrupt will be generated by an external circuit.  In many cases, you have the control over the design of the external circuit, and you can choose whether it will be generating low-to-high edges or high-to-low edges.  But in some cases you don't have the control over the design of the external circuit which generates the interrupt.  Then you have to adapt your firmware code to the interrupt source.&lt;/p&gt;&#xA;" OwnerDisplayName="Nick Alexeev" LastActivityDate="2015-08-20T19:53:19.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14375" PostTypeId="1" CreationDate="2015-08-20T20:01:59.830" Score="2" ViewCount="237" Body="&lt;p&gt;I am in the process of developing an Arduino application that can read keystrokes from a PS/2 keyboard. I was wondering if it would be possible to upload a C# program onto the Arduino to interpret the keystrokes from the keyboard and write an Arduino program to perform operations based on the keystrokes.&lt;/p&gt;&#xA;" OwnerUserId="11926" OwnerDisplayName="user83489" LastEditorUserId="10794" LastEditDate="2015-08-20T22:49:48.523" LastActivityDate="2015-08-21T07:41:25.070" Title="Using C# Program to Interpret Keystrokes" Tags="|c++|keyboard|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14376" PostTypeId="2" ParentId="14375" CreationDate="2015-08-20T20:18:42.617" Score="1" Body="&lt;p&gt;The answer is actually, surprisingly, yes! C# requires &lt;code&gt;.NET CLR&lt;/code&gt; for execution, I had assumed that &lt;code&gt;.NET&lt;/code&gt; exists only in microsoft desktop land, but it has in fact been ported to &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/jj610646.aspx&quot; rel=&quot;nofollow&quot;&gt;microcontrollers and released open source&lt;/a&gt; as &lt;code&gt;.NET micro&lt;/code&gt;, it can even run baremetal with no OS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this is not possible on an 8 bit regular arduino, it requires one of the larger 32 bit models. There is a prebuilt clone that has the &lt;code&gt;.NET micro CLR&lt;/code&gt; framework ported to it on an STM32F4 cpu called the &lt;a href=&quot;http://www.netduino.com/&quot; rel=&quot;nofollow&quot;&gt;netduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the footprint for .Net Micro is too large to run on a regular 8bit arduino and probably hasn't been built for 8bit systems. It is possible with the arduino Due (in theory) and on other micrcontroller platforms that support &lt;code&gt;.NET micro&lt;/code&gt; to run C# code outside of the windows platform.&lt;/p&gt;&#xA;" OwnerUserId="11257" LastEditorUserId="11257" LastEditDate="2015-08-20T21:10:08.713" LastActivityDate="2015-08-20T21:10:08.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14377" PostTypeId="2" ParentId="8153" CreationDate="2015-08-20T21:03:03.920" Score="3" Body="&lt;p&gt;I know it's an old thread, but others are likely to have this problem.  If you check &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;the open source schematics&lt;/a&gt;, there are a couple of nearby capacitors that connect pin 1 (GND) to pin 2 (+5V) of the regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would check C2 and PC2 (top right of the diagram) as well as C1 (top left of schematic diagram), and any other components you can find that bridge the rails between +5V and ground.  Capacitors are more likely to fail shorted than many other components.  You will have to remove at least one pin of each capacitor to test it since you don't know where the short is, or you can simply remove capacitors until the short goes away.&lt;/p&gt;&#xA;" OwnerUserId="11610" LastActivityDate="2015-08-20T21:03:03.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14378" PostTypeId="2" ParentId="14364" CreationDate="2015-08-20T22:30:16.213" Score="1" Body="&#xA;&#xA;&lt;p&gt;I'm going to present a third way of working on this. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, since I don't have a TX23 I wrote a TX23-simulator:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte TESTPIN = 2;&#xA;&#xA;const byte test [6] = { &#xA;    0b00000011,&#xA;    0b01111011,&#xA;    0b01010100,&#xA;    0b00010100,&#xA;    0b01001010,&#xA;    0b10111111 };&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (TESTPIN, INPUT);&#xA;  delay (100);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // wait for host to pull pin low&#xA;  while (digitalRead (TESTPIN) == HIGH)&#xA;    { }&#xA;  // wait for host to release it&#xA;  while (digitalRead (TESTPIN) == LOW)&#xA;    { }&#xA;  digitalWrite (TESTPIN, HIGH);&#xA;  pinMode (TESTPIN, OUTPUT);&#xA;  for (byte i = 0; i &amp;lt; 6; i++)&#xA;    for (byte j = 0; j &amp;lt; 8; j++)&#xA;      {&#xA;      delayMicroseconds (1100);&#xA;      digitalWrite (TESTPIN, test [i] &amp;amp; bit (7 - j));&#xA;      }&#xA;  pinMode (TESTPIN, INPUT);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on your &lt;a href=&quot;https://www.john.geek.nz/2012/08/la-crosse-tx23u-anemometer-communication-protocol/&quot; rel=&quot;nofollow noreferrer&quot;&gt;linked page about the TX23&lt;/a&gt; it outputs a series of low/high pulses corresponding to the example on that page, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pGCKr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pGCKr.png&quot; alt=&quot;TX23 simulator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you need a 10 k pull-up resistor for this to work properly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now the reading code uses interrupts to detect state changes:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte READ_PIN = 2;&#xA;const byte NUMBER_OF_CHANGES = 48;&#xA;&#xA;volatile unsigned long bitTime [NUMBER_OF_CHANGES];&#xA;volatile byte state [NUMBER_OF_CHANGES];&#xA;volatile byte count;&#xA;&#xA;void stateChange ()&#xA;  {&#xA;  unsigned long now = micros ();&#xA;  if (count &amp;gt;= NUMBER_OF_CHANGES)&#xA;    return;  // array full&#xA;  state [count] = digitalRead (READ_PIN);&#xA;  bitTime [count++] = now;&#xA;  } // end of stateChange&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  }  // end of setup&#xA;&#xA;void takeReading ()&#xA;  {&#xA;  count = 0;&#xA;  digitalWrite (READ_PIN, LOW);  // start reading&#xA;  pinMode (READ_PIN, OUTPUT);   &#xA;  delay (20);  // pulse width&#xA;  pinMode (READ_PIN, INPUT);     // release line&#xA;  EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;  attachInterrupt (0, stateChange, CHANGE);&#xA;  delay (55);  // let readings fill up array&#xA;  detachInterrupt (0);&#xA;  }  // end of takeReading&#xA;&#xA;void loop ()&#xA;  {&#xA;  takeReading ();&#xA;  if (count == 0)&#xA;    return;  // nothing!&#xA;&#xA;  delay (500);&#xA;  for (byte i = 0; i &amp;lt; count; i++)&#xA;    {&#xA;    Serial.print (&quot;count: &quot;);&#xA;    Serial.print ((int) i);&#xA;    Serial.print (&quot; = &quot;);&#xA;    Serial.print (bitTime [i]);&#xA;    Serial.print (&quot;, state = &quot;);&#xA;    Serial.print (state [i]);&#xA;    if (i &amp;gt; 0)&#xA;      {&#xA;      Serial.print (&quot;, width = &quot;);  &#xA;      unsigned long width = bitTime [i] - bitTime [i - 1];&#xA;      Serial.print (width);&#xA;      Serial.print (&quot; (&quot;);&#xA;      int bits = width / 1000;&#xA;      for (byte k = 0; k &amp;lt; bits; k++)&#xA;       Serial.print (state [i - 1]);&#xA;      Serial.print (&quot;)&quot;);&#xA;      }&#xA;    Serial.println ();&#xA;    }&#xA;    Serial.println ();&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Results were:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;count: 0 = 10952804, state = 1&#xA;count: 1 = 10953928, state = 0, width = 1124 (1)&#xA;count: 2 = 10960616, state = 1, width = 6688 (000000)&#xA;count: 3 = 10962844, state = 0, width = 2228 (11)&#xA;count: 4 = 10963960, state = 1, width = 1116 (0)&#xA;count: 5 = 10968412, state = 0, width = 4452 (1111)&#xA;count: 6 = 10969524, state = 1, width = 1112 (0)&#xA;count: 7 = 10971752, state = 0, width = 2228 (11)&#xA;count: 8 = 10972876, state = 1, width = 1124 (0)&#xA;count: 9 = 10973988, state = 0, width = 1112 (1)&#xA;count: 10 = 10975104, state = 1, width = 1116 (0)&#xA;count: 11 = 10976216, state = 0, width = 1112 (1)&#xA;count: 12 = 10977328, state = 1, width = 1112 (0)&#xA;count: 13 = 10978440, state = 0, width = 1112 (1)&#xA;count: 14 = 10984012, state = 1, width = 5572 (00000)&#xA;count: 15 = 10985124, state = 0, width = 1112 (1)&#xA;count: 16 = 10986244, state = 1, width = 1120 (0)&#xA;count: 17 = 10987356, state = 0, width = 1112 (1)&#xA;count: 18 = 10990700, state = 1, width = 3344 (000)&#xA;count: 19 = 10991812, state = 0, width = 1112 (1)&#xA;count: 20 = 10994040, state = 1, width = 2228 (00)&#xA;count: 21 = 10995156, state = 0, width = 1116 (1)&#xA;count: 22 = 10996268, state = 1, width = 1112 (0)&#xA;count: 23 = 10997380, state = 0, width = 1112 (1)&#xA;count: 24 = 10998500, state = 1, width = 1120 (0)&#xA;count: 25 = 10999616, state = 0, width = 1116 (1)&#xA;count: 26 = 11000728, state = 1, width = 1112 (0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This seems to agree with the test data.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-21T04:03:13.467" LastActivityDate="2015-08-21T04:03:13.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14379" PostTypeId="2" ParentId="12071" CreationDate="2015-08-20T23:02:07.180" Score="6" Body="&#xA;&#xA;&lt;p&gt;There are &lt;strong&gt;five&lt;/strong&gt; buffers used by the TWI and Wire library. They are defined as 32 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In wire.h:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define BUFFER_LENGTH 32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Wire.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;uint8_t TwoWire::rxBuffer[BUFFER_LENGTH];&#xA;...&#xA;uint8_t TwoWire::txBuffer[BUFFER_LENGTH];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In twi.h:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  #define TWI_BUFFER_LENGTH 32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In twi.c:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];&#xA;...&#xA;static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];&#xA;...&#xA;static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So immediately you are using 5 x 32 bytes (160 bytes).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could increase that to (say) 64 bytes, bearing in mind your 160 byte overhead is now 320 bytes, and you don't have a lot of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The comments about &lt;code&gt;endTransmission()&lt;/code&gt; are correct. After a &lt;code&gt;Wire.beginTransmission()&lt;/code&gt; nothing is actually transmitted until the &lt;code&gt;endTransmission()&lt;/code&gt; call. This lets you fill up the buffer at your leisure, and then let the library do the writes in a fairly timing-specific way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;noreferrer&quot;&gt;I2C&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;noreferrer&quot;&gt;Wire Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-20T23:02:07.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14380" PostTypeId="2" ParentId="14181" CreationDate="2015-08-20T23:18:50.637" Score="0" Body="&lt;p&gt;My answer is... they do it because it works. I'm having a hard time not asking a question in my answer such as &quot;why does it have to be 'wrong'?&quot;&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-08-20T23:18:50.637" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14381" PostTypeId="5" CreationDate="2015-08-20T23:35:18.873" Score="0" Body="&lt;p&gt;The Arduino processor chips have a number of timers/counters. Basically they are hardware that &lt;strong&gt;count&lt;/strong&gt; things, however if they count pulses from the system clock (which runs at a known speed) they can also be used to &lt;strong&gt;time&lt;/strong&gt; things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timers have an &lt;em&gt;input&lt;/em&gt; which can be an external signal, or the system clock. If counting an external signal they can be used to count something like how many pulses are detected on a pin. If counting the system clock they can be used as an elapsed-time timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input can go through a &lt;em&gt;prescaler&lt;/em&gt; which divides down the input (eg. by 64). This lets you have the counter &quot;tick over&quot; more slowly than it otherwise might.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timers are usually described as 8-bit, 10-bit, 16-bit and so on. The number of bits indicates the maximum the counter/timer can count to before overflowing. For example, an 8-bit counter can count to 256.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timers can be configured to raise &lt;em&gt;interrupts&lt;/em&gt; on various events, for example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Timer overflow&lt;/li&gt;&#xA;&lt;li&gt;A certain count has been reached&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The timers can also be used to generate &lt;a href=&quot;/questions/tagged/pwm&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pwm&amp;#39;&quot; rel=&quot;tag&quot;&gt;pwm&lt;/a&gt; pulses. PWM (pulse-width-modulation) can be configured to have a certain frequency, and a certain duty cycle, depending on the way the timer registers are set.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-21T01:22:09.093" LastActivityDate="2015-08-21T01:22:09.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14382" PostTypeId="4" CreationDate="2015-08-20T23:35:18.873" Score="0" Body="Timers are the hardware in the processor used to count and time events. Use this tag for questions about the hardware timers." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-21T01:23:01.533" LastActivityDate="2015-08-21T01:23:01.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14383" PostTypeId="5" CreationDate="2015-08-21T00:13:03.080" Score="0" Body="&lt;p&gt;Most Arduinos have one or more UART ports. The smaller Arduinos (such as the Uno) have one UART port. Larger Arduinos (such as the Mega2560) have multiple UART ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UART takes a serial stream of bits and assembles it into a byte, effectively turning serial data into parallel data (and vice-versa for sending). Generally speaking the Arduino UARTs are used for implementing the &lt;code&gt;HardwareSerial&lt;/code&gt; class, of which an instance called &lt;code&gt;Serial&lt;/code&gt; (and possibly &lt;code&gt;Serial1&lt;/code&gt;, &lt;code&gt;Serial2&lt;/code&gt;, etc.) is available on many boards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UART has a send and receive buffer, so it can be sending and receiving simultaneously, while the main program code can be doing something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UART can generate interrupts if desired, for events like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Transmit buffer empty (so more data can be sent)&lt;/li&gt;&#xA;&lt;li&gt;Receive buffer filled (so the last-received byte can be retrieved)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some of the smaller chips (such as the ATtiny85) have a &lt;strong&gt;USI&lt;/strong&gt; (Universal Serial Interface) instead of a UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related tags: &lt;a href=&quot;/questions/tagged/uno&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;uno&amp;#39;&quot; rel=&quot;tag&quot;&gt;uno&lt;/a&gt; &lt;a href=&quot;/questions/tagged/mega&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;mega&amp;#39;&quot; rel=&quot;tag&quot;&gt;mega&lt;/a&gt; &lt;a href=&quot;/questions/tagged/serial&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;serial&amp;#39;&quot; rel=&quot;tag&quot;&gt;serial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter&quot; rel=&quot;nofollow&quot;&gt;UART: Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-21T01:23:31.647" LastActivityDate="2015-08-21T01:23:31.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14384" PostTypeId="4" CreationDate="2015-08-21T00:13:03.080" Score="0" Body="A UART is a Universal Asynchronous Receiver/Transmitter. This refers to the &quot;hardware&quot; serial port in the processor. Use this tag for questions about hardware serial." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-21T01:24:03.337" LastActivityDate="2015-08-21T01:24:03.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14385" PostTypeId="2" ParentId="14369" CreationDate="2015-08-21T01:03:32.617" Score="0" Body="&#xA;&#xA;&lt;p&gt;This is what I fed my Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define IMAGEWIDTH 56&#xA;#define IMAGEHEIGHT 96&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  int i, j;&#xA;  int image_result[IMAGEWIDTH][IMAGEHEIGHT];&#xA;&#xA;  for (i = 0; i &amp;lt; IMAGEWIDTH; i++) {&#xA;    Serial.print(&quot;\nIMAGEWIDTH &quot;);&#xA;    Serial.print(i + 1);&#xA;    Serial.println(&quot;:&quot;);&#xA;    for (j = 0; j &amp;lt; IMAGEHEIGHT; j++) {&#xA;      image_result[i][j] = i + j;&#xA;      Serial.print(&quot;image_result[&quot;);&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot;][&quot;);&#xA;      Serial.print(j + 1);&#xA;      Serial.print(&quot;]: &quot;);&#xA;      Serial.println(image_result[i][j]);&#xA;    }&#xA;  }&#xA;  Serial.println(F(&quot;\nDone!&quot;));&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will run over the whole array, while printing progress over Serial, which then print &quot;Done!&quot; once it is. I suggest changing:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define IMAGEWIDTH 56&#xA;#define IMAGEHEIGHT 96&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To lesser values, unless you have a few good minutes at hand.&lt;/p&gt;&#xA;" OwnerUserId="11925" LastEditorUserId="10794" LastEditDate="2015-08-21T05:58:52.613" LastActivityDate="2015-08-21T05:58:52.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14386" PostTypeId="1" CreationDate="2015-08-21T01:54:59.907" Score="3" ViewCount="1842" Body="&lt;p&gt;I want to &quot;connect&quot; two Arduinos, without using wires. The range is ~0.2 miles (300 meters). Using Google, I saw too many options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to build something like a beacon, so the bandwidth can be small. I want to send 32 or 64 bits/second of data (32 bits for the application + 32 bits for checksum if the module does not guarantee consistency of data). &#xA;The communication between Arduinos is bi-directional, and I'm looking for something cheaper than 50 US dollars per module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use a serial WiFi module for this, without using a router? Do you recommend a 2.4GHz module? Or a RF module?&lt;/p&gt;&#xA;" OwnerUserId="11927" LastEditorUserId="10794" LastEditDate="2015-08-21T21:23:48.087" LastActivityDate="2015-08-21T21:23:48.087" Title="Wirelessly communicate between two Arduinos without router" Tags="|wifi|rf|remote-control|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14387" PostTypeId="2" ParentId="14386" CreationDate="2015-08-21T02:48:37.740" Score="3" Body="&lt;p&gt;I can highly recommend &lt;a href=&quot;http://smile.amazon.com/gp/product/B00INTI8R2/ref=ox_sc_sfl_title_6&quot; rel=&quot;nofollow&quot;&gt;these cheap little 433Mhz radios&lt;/a&gt;.  You can get them on amazon, ebay, etc. and they work pretty well for me. Your distances are a bit longer than my situation but I have to go through several walls.&lt;/p&gt;&#xA;" OwnerUserId="3688" LastActivityDate="2015-08-21T02:48:37.740" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14388" PostTypeId="1" CreationDate="2015-08-21T03:06:10.477" Score="1" ViewCount="178" Body="&lt;p&gt;There are all sorts of Arduino and Arduino-compatible boards out there. They come in all form factors and they come with all sorts of different I/O. They even come with memory specs and different kinds of microcontrollers, from the ATmega328P to &lt;a href=&quot;https://www.arduino.cc/en/ArduinoCertified/IntelGalileo&quot; rel=&quot;nofollow&quot;&gt;Intel-based&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is it that imbues a board to become &quot;Arduino Compatible&quot; ? Must it be pin-compatible? Must it be possible to compile Arduino source code for the board? Or must the board be binary-compatible? Must it emulate some specific processor instruction set? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very curious. Please reference specifications if possible. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="11928" LastActivityDate="2015-08-21T11:02:44.840" Title="What makes a board &quot;Arduino Compatible&quot;?" Tags="|clones|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14389" PostTypeId="5" CreationDate="2015-08-21T03:28:26.697" Score="0" Body="&lt;p&gt;This tag is for the hardware side of your Arduino project, particularly electronics questions. Relevant questions would be about:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Transistors&lt;/li&gt;&#xA;&lt;li&gt;MOSFETs&lt;/li&gt;&#xA;&lt;li&gt;Diodes&lt;/li&gt;&#xA;&lt;li&gt;Resistors&lt;/li&gt;&#xA;&lt;li&gt;Capacitors&lt;/li&gt;&#xA;&lt;li&gt;Inductors&lt;/li&gt;&#xA;&lt;li&gt;Current-limiting resistors&lt;/li&gt;&#xA;&lt;li&gt;Ohm's Law&lt;/li&gt;&#xA;&lt;li&gt;Power calculations&lt;/li&gt;&#xA;&lt;li&gt;Switching devices on and off&lt;/li&gt;&#xA;&lt;li&gt;Input protection circuits&lt;/li&gt;&#xA;&lt;li&gt;Output protection circuits&lt;/li&gt;&#xA;&lt;li&gt;Opto-couplers&lt;/li&gt;&#xA;&lt;li&gt;Choice of components&lt;/li&gt;&#xA;&lt;li&gt;Other electronics-related questions&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also see: &lt;a href=&quot;/questions/tagged/led&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;led&amp;#39;&quot; rel=&quot;tag&quot;&gt;led&lt;/a&gt; &lt;a href=&quot;/questions/tagged/wiring&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;wiring&amp;#39;&quot; rel=&quot;tag&quot;&gt;wiring&lt;/a&gt; &lt;a href=&quot;/questions/tagged/sensor&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;sensor&amp;#39;&quot; rel=&quot;tag&quot;&gt;sensor&lt;/a&gt; &lt;a href=&quot;/questions/tagged/transistor&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;transistor&amp;#39;&quot; rel=&quot;tag&quot;&gt;transistor&lt;/a&gt; &lt;a href=&quot;/questions/tagged/mosfet&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;mosfet&amp;#39;&quot; rel=&quot;tag&quot;&gt;mosfet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:11.303" LastActivityDate="2015-08-30T20:37:11.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14390" PostTypeId="4" CreationDate="2015-08-21T03:28:26.697" Score="0" Body="Use this tag to ask about electronics-related issues with your Arduino. For example: driver transistors, Ohm's Law, current-limiting resistors." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:54.510" LastActivityDate="2015-08-30T20:37:54.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14391" PostTypeId="2" ParentId="14388" CreationDate="2015-08-21T03:45:00.660" Score="0" Body="&lt;p&gt;I think the practical answer is: it is not defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For peripherals, it seems to mean that it can interact with an Arduino compatible board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For boards, as far as I can tell, it has to be: instruction-set compatible, OR pin (layout) compatible with another board which was previously defined as Arduino compatible.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-21T03:45:00.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14392" PostTypeId="5" CreationDate="2015-08-21T03:53:57.943" Score="0" Body="&lt;h2&gt;Digital Inputs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Digital inputs are read as being HIGH or LOW in the Arduino code. There are no intermediate values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet specifies voltage levels:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A certain level below which a signal is considered LOW&lt;/li&gt;&#xA;&lt;li&gt;Another level, above which a signal is considered HIGH&lt;/li&gt;&#xA;&lt;li&gt;There is normally an in-between level where the signal is undefined (it might be HIGH or LOW randomly).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As an example, on the Atmega328P, operating at 5 volts supply, the levels for most pins are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-0.5 V to 1.5 V - considered &lt;strong&gt;LOW&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Above 1.5 and below 3 V - undefined&lt;/li&gt;&#xA;&lt;li&gt;3 V to 5.5 V - considered &lt;strong&gt;HIGH&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Digital Outputs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Digital outputs are written as HIGH or LOW in the Arduino code. There are no intermediate values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The driver transistors in the processor attempt to bring the corresponding output pin to 0 V for LOW and V&lt;sub&gt;CC&lt;/sub&gt; for HIGH (where V&lt;sub&gt;CC&lt;/sub&gt; is the supply voltage for the chip, typically 3.3 V or 5 V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, the datasheet for the Atmega328P specifies that (at an ambient temperature of 85°C, driving 20 mA, and running at 5 V) the output pin should be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A maximum of 0.9 V when driven &lt;strong&gt;LOW&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;A minimum of 4.2 V when driven &lt;strong&gt;HIGH&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Analog inputs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Contrast the above to the analog inputs on the Arduino which use an ADC (Analog to Digital Converter) to read a range of values on an input pin, and return a number corresponding to where that voltage lies in the range 0 to the analog reference voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;/questions/tagged/analogread&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;analogread&amp;#39;&quot; rel=&quot;tag&quot;&gt;analogread&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:20.557" LastActivityDate="2015-08-30T20:37:20.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14393" PostTypeId="4" CreationDate="2015-08-21T03:53:57.943" Score="0" Body="Digital refers to signals which are either on or off (high or low, one or zero). This contrasts with analog signals which have a range of values." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:28.093" LastActivityDate="2015-08-30T20:37:28.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14394" PostTypeId="2" ParentId="14388" CreationDate="2015-08-21T04:12:49.540" Score="0" Body="&lt;p&gt;I think you could say it is &lt;strong&gt;Arduino-compatible&lt;/strong&gt; if it contains a processor found on an Arduino board. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Atmega328P (found on the Uno, Duemilanove, Pro Mini, amongst others)&lt;/li&gt;&#xA;&lt;li&gt;The Atmega32U4 (found on the Leonardo, Micro, amongst others)&lt;/li&gt;&#xA;&lt;li&gt;The Atmega2560 (found on the Mega2560)&lt;/li&gt;&#xA;&lt;li&gt;Other processors used by Arduinos such as the Atmel SAM3X8E ARM Cortex-M3 CPU used on the Arduino Due.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With a processor used on an Arduino, you will find that you can almost certainly compile code using the Arduino IDE, and the Arduino libraries, that will work on such chips.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could say it is &lt;strong&gt;Arduino-Uno-compatible&lt;/strong&gt; if the board physically was compatible with the Arduino Uno (ditto for other boards). In other words, if it was possible to plug a shield, designed for the Uno, onto such a board. That could be called &quot;plug compatible&quot; I suppose.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for other boards, like sensors, relay boards, etc., I have seen a lot of those on eBay advertised as &quot;Arduino compatible&quot;, but of course they would also be compatible with other micro-controllers as well. I'm waiting for the day someone advertises &quot;Arduino compatible&quot; resistors.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T04:12:49.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14395" PostTypeId="2" ParentId="10243" CreationDate="2015-08-21T04:27:36.587" Score="2" Body="&lt;p&gt;Judging by a datasheet (that I found on the web) that has a resistance of:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;100 k to 200 k in the light&lt;/li&gt;&#xA;&lt;li&gt;1 M in the dark&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Given that V&lt;sub&gt;out&lt;/sub&gt; =  V&lt;sub&gt;in&lt;/sub&gt; * R2 / (R1 + R2) we can work out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Light:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = 5 * 200000 / (200000 + 5600) = 4.86 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Dark:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = 5 * 1000000 / (1000000 + 5600) = 4.97 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I have to use a greater resistor than 5.6k to achieve more difference in the sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, I would measure the resistance in the light, and choose a similar resistor for the other side of the voltage divider. So if you measure 100 k on the sensor, another 100 k will at least divide the voltage in two nicely.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T04:27:36.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14396" PostTypeId="2" ParentId="14369" CreationDate="2015-08-21T05:34:44.953" Score="3" Body="&lt;p&gt;You are trying to use more memory than you have available: 96 * 56 * 2 = 10.752KBytes. Not much that the MCU can do when this happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look into the &lt;a href=&quot;http://www.atmel.com/Images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;, you'll see that your microcontroller (ATmega328p) only has 2KBytes of RAM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess the question then, is to ask yourself if you really need that large an array. You may consider getting an external flash chip or an SDcard shield. If you only need it for read-only purposes (such as a lookup table), you can use some of your &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;flash program memory&lt;/a&gt; (you have 32KBytes).&lt;/p&gt;&#xA;" OwnerUserId="7282" LastActivityDate="2015-08-21T05:34:44.953" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14398" PostTypeId="2" ParentId="14386" CreationDate="2015-08-21T07:22:38.140" Score="0" Body="&lt;p&gt;It's a bit unorthodox solution, but have you considered toy walkie-talkies?&#xA;They cover the distance you reported, even if some obstacles are in the path and they are relatively cheap, if you go for some sales.&#xA;It requires a bit of hacking to connect the arduino to the mic/speaker and the push button, but it shouldn't be too difficult.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-21T07:22:38.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14400" PostTypeId="2" ParentId="14375" CreationDate="2015-08-21T07:36:24.470" Score="0" Body="&lt;p&gt;I hope this answer doesn't get voted down just because it addresses the generic need (do something upon input from a PS/2 keyboard), rather than the (too) specific question that was asked (use c# on Arduino), but here it comes ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a PS/2 to USB adapter for the keyboard, you can select a much easier solution, based, for example, on raspberry PI (or anything that runs linux and has a USB master port) and use any simple scripting language - even shell. The overall cost would not be much higher and the ease of implementation would be definitely more likely to succeed. And in a short time.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-08-21T07:41:25.070" LastActivityDate="2015-08-21T07:41:25.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14401" PostTypeId="1" AcceptedAnswerId="14405" CreationDate="2015-08-21T08:33:01.673" Score="1" ViewCount="3220" Body="&#xA;&#xA;&lt;p&gt;I am using an Arduino Due to collect a large amount of data from an encoder (about 1kb). Afterwards I need to send the collected data to a C# application I wrote over the serial port. I serialized my tx data into a byte buffer and simply used this code to transmit:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void sendEncoderData()&#xA;{&#xA;  byte buffer[1024];&#xA;&#xA;  /*** some code that populates buffer ***/&#xA;&#xA;  int bytesToSend = 1024;&#xA;  Serial.write(buffer, bytesToSend);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the code, nothing seems to get received by the C# application. In fact, I never see the Tx LED light up. However, if I change &lt;code&gt;bytesToSend&lt;/code&gt; to a value smaller than 64 bytes everything works. Is this a limitation of &lt;code&gt;Serial.write()&lt;/code&gt; or is it something else? What are ways I can work around this limitation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information： &lt;code&gt;sendEncoderData()&lt;/code&gt; is called by an interrupt service routine. However prior to the call, I made sure to 'detachInterrupt()` on all pins including the pin associated with said ISR.&lt;/p&gt;&#xA;" OwnerDisplayName="user11933" LastEditorDisplayName="user11933" LastEditDate="2015-08-21T10:04:09.320" LastActivityDate="2015-08-21T10:46:37.700" Title="Arduino Serial.write sending more than 64 bytes" Tags="|serial|arduino-due|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14403" PostTypeId="2" ParentId="8615" CreationDate="2015-08-21T09:27:14.477" Score="1" Body="&lt;p&gt;You cannot send larger values because byte only covers the range from 0-255. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To send larger values, you can break your int variable into 2 byte variables. Here's an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// On Arduino&#xA;int myVar = -123;&#xA;byte myVar_HighByte = myVar&amp;gt;&amp;gt;8; // get the high byte&#xA;byte myVar_LowByte = myVar; // get the low byte&#xA;// x86 compatible machines are little-endian so we send the low byte first&#xA;Serial.write(myVar_LowByte); &#xA;Serial.write(myVar_HighByte);&#xA;&#xA;% On MATLAB&#xA;s = serial('COM10')&#xA;fopen(s)&#xA;myVar = fread(s,1,'int16')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: Syntax might not be entirely correct, since I have no MATLAB or Arduino near me when I typed this. But you should get the idea. ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: On second thought, it might be easier to use a pointer. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// On Arduino&#xA;float myFloat = 3.14159265359;&#xA;byte* ptr = (byte*) (&amp;amp;myFloat);&#xA;Serial.write(*ptr++);&#xA;Serial.write(*ptr++);&#xA;Serial.write(*ptr++);&#xA;Serial.write(*ptr);&#xA;&#xA;% On MATLAB&#xA;s = serial('COM10')&#xA;fopen(s)&#xA;myVar = fread(s,1,'float')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having said that, you will still have to take care of the endianness, if you use a different microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="7282" LastEditDate="2015-11-20T01:23:50.207" LastActivityDate="2015-11-20T01:23:50.207" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14404" PostTypeId="2" ParentId="8420" CreationDate="2015-08-21T10:36:07.467" Score="3" Body="&lt;p&gt;If you're ok with starting with square wave signals, this can be done on an Arduino. &#xA;You need to do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Configure a 16-bit Timer to &lt;strong&gt;CTC&lt;/strong&gt; mode&lt;/li&gt;&#xA;&lt;li&gt;Select the right prescaling&lt;/li&gt;&#xA;&lt;li&gt;Add a RC low pass filter to the output and voltage divider&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Configure a 16-bit Timer to &lt;strong&gt;CTC&lt;/strong&gt; mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Assuming I'm using &lt;strong&gt;Timer 1&lt;/strong&gt; and &lt;strong&gt;OCR1A&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1A |= (1&amp;lt;&amp;lt;COM1A0); // Toggle OC1A on match&#xA;TCCR1B |= (1&amp;lt;&amp;lt;WGM12); // Clear to Compare mode&#xA;TCCR1B |= (1&amp;lt;&amp;lt;CS10); // No prescale&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Select the right prescaling&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In case you're wondering, prescales are used when the MCU clock is much faster than the output you desire. &#xA;Without prescaling, the highest frequency is 16MHz/2 = 8MHz, and the lowest frequency would be 8MHz / 2^16 = 122Hz . Which covers the range of frequencies that we want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting OCR1A value to 80 gives you a frequency of 100kHz&#xA;Setting OCR1A value to 2667 gives you a frequency of 2.9996kHz&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then control the chirp like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Linear rise in wave period&#xA;int x = 10;&#xA;for (int x=80; x &amp;lt; 2668; ++x){&#xA;  OCR1A = x; &#xA;  delay(10); // 10ms delay&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Add a RC low pass filter to the output and voltage divider&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Making the perfect sine waves may be too troublesome, so we'll resort to the poor man's sine wave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the &lt;a href=&quot;http://www.ti.com/lit/an/sbfa003/sbfa003.pdf&quot; rel=&quot;nofollow&quot;&gt;poor man's implementation&lt;/a&gt; by TI (still require quite a few parts.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I'm cheap so I'd go for the &lt;a href=&quot;http://www.wenzel.com/documents/waveform.html&quot; rel=&quot;nofollow&quot;&gt;RLC approach&lt;/a&gt;. ;-)&lt;/p&gt;&#xA;" OwnerUserId="7282" LastActivityDate="2015-08-21T10:36:07.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14405" PostTypeId="2" ParentId="14401" CreationDate="2015-08-21T10:46:37.700" Score="2" Body="&lt;p&gt;Here's the problem:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sendEncoderData() is called by an interrupt service routine.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is an internal 64 byte serial transmit buffer that is filled by Serial.write().  That buffer is empted by sending the data a byte at a time using an interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are in an interrupt (at a higher priority than the serial interrupt) then the interrupt that sends the data can never happen, so the buffer just fills up and stops when it gets to 64 bytes.  It will hang until there is room for more bytes in the buffer, and that will never happen because you're not allowing the data to be sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer (as I and others have said many times in the past): &lt;strong&gt;Never use Serial in an interrupt.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-21T10:46:37.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14406" PostTypeId="2" ParentId="14388" CreationDate="2015-08-21T11:02:44.840" Score="1" Body="&lt;p&gt;The problem here is that &quot;compatible&quot; can mean so many things in different contexts and to different people.  For instance, it may mean any of the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can be used with the Arduino IDE without any need for additional board installation of other modifications&lt;/li&gt;&#xA;&lt;li&gt;Can be used with the Arduino IDE after modification (boards installed)&lt;/li&gt;&#xA;&lt;li&gt;Uses the same (or very similar) API to the Arduino system&lt;/li&gt;&#xA;&lt;li&gt;Has the same footprint as an existing official Arduino board&lt;/li&gt;&#xA;&lt;li&gt;Is a device which will work with an Arduino board and has software available to operate it&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All very different meanings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point 1 could be a board that is based on the design of an existing Arduino board (say the Uno) but built into a new form factor, maybe with additional hardware and peripherals added.  It is still treated as if it was the board the design was based on though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point 2 would be a board that is similar, though not the same, as an existing board.  A different board definition may be required to map the IO pins properly, for instance.  It could use a slightly different chip in the same supported family. You still use it as an Arduino, but it's not the same as an existing Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point 3 may mean it's based on a completely different chip.  The programming environment may be almost the same, but it's hard to get 100% API compatibility.  Arduino sketches and libraries &lt;em&gt;may&lt;/em&gt; work out of the box, or may not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point 4 could be a board that, internally, is completely different to the Arduino, uses a different programming language, IDE, etc, yet the layout of the board is the same as, say, an Arduino Uno.  A good example is the Mecanique Firewing - an Uno footprint, but a PIC32 chip instead of an Atmel, and Basic instead of C++.  Most Arduino shields would just plug in and work though, software permitting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Point 5 is from the completely opposite direction.  This is a device which &quot;is compatible with&quot; in that &quot;it will work with&quot; and Arduino.  That could be on an electrical level (it's a 5V device and will connect to the Arduino) or that it has full software support (&lt;em&gt;&quot;Download our Arduino library...&quot;&lt;/em&gt;).  It has nothing to do with how the device works or what it is though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer to use specific terms, respectively:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Based on the Ardino UNO&lt;/li&gt;&#xA;&lt;li&gt;Programmable with the Arduino IDE&lt;/li&gt;&#xA;&lt;li&gt;Compatible with the Arduino API&lt;/li&gt;&#xA;&lt;li&gt;Footprint compatible with the Arduino UNO&lt;/li&gt;&#xA;&lt;li&gt;Suitable for use with Arduino boards&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That way it states exactly in what way this device relates to the official Arduino boards.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-21T11:02:44.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14407" PostTypeId="1" CreationDate="2015-08-21T11:35:59.607" Score="15" ViewCount="99669" Body="&lt;p&gt;&lt;strong&gt;Increase the number of digital pins&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many post that explain how to use more than just the standard pins on the various arduinos but none of them explain the limitations and the proplems properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dVkQU.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dVkQU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.You can&lt;/strong&gt; use the analog pins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pin 14 = Analog in 0&#xA;Pin 15 = Analog in 1&#xA;Pin 16 = Analog in 2&#xA;Pin 17 = Analog in 3&#xA;Pin 18 = Analog in 4&#xA;Pin 19 = Analog in 5&#xA;&#xA;digitalWrite(14,HIGH);&#xA;or&#xA;digitalWrite(A0,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.You can't&lt;/strong&gt; use both SDA , SCL &amp;amp; A4 , A5 as they are basically the same (18,19).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.You can&lt;/strong&gt; also use the TX/RX. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Don't do it, you break the serial communication...&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;Never use pins 0 and 1&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;you can't use the TX/Rx Pins&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;You can... but you need to take precautions. Which ones?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should have software serial over USB, right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do i break the USB serial?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there internal Chip problems if i use TX/RX?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i use those TX/RX pins in the code i probably should not use &lt;code&gt;Serial.print()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens if i forget to remove &lt;code&gt;Serial.print()&lt;/code&gt; after uploading the code that use pins 0,1?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to hardware reset the arduino/bootloader if something goes wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As there are various other Arduino's that use different chips, is the above valid for all Atmel chips?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So, what shuold i know before using those TX/RX or also maybe the other analog pins?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are cheap shiftregisters, pwm drivers, led drivers, spi, i2c and&#xA;  more ic's to expand your I/O&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But if there are not to big problems it means that the arduino has 20 I/O pins...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You could theoretically control:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;17x3 = 51 = 17 RGB leds (multiplexing, pwm sourcing&amp;amp;sinking);&#xA;14x6 = 84 leds (multiplexing, pwm on 6 rows/colums );&#xA;10x10 = 100 leds (multiplexing, high low);&#xA;20x(20-1) = 380 leds (charlieplexing, high low);&#xA;// yes it would flicker&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Correct me if i'm wrong. That means you are able to control 380 &quot;Whatever&quot; using diodes and one arduino.&lt;/p&gt;&#xA;" OwnerUserId="11876" LastEditorUserId="11876" LastEditDate="2015-08-21T11:48:58.300" LastActivityDate="2023-09-27T12:28:39.517" Title="Use all pins As digital I/O" Tags="|arduino-uno|serial|pins|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14408" PostTypeId="1" CreationDate="2015-08-21T14:26:37.313" Score="0" ViewCount="1787" Body="&lt;p&gt;I want to make a game of &lt;a href=&quot;https://en.wikipedia.org/wiki/Tic-tac-toe&quot; rel=&quot;nofollow&quot;&gt;Tic-tac-toe&lt;/a&gt; using an Arduino, LEDs and bouncy buttons. Hence I need nine inputs and nine outputs. But you see that an Arduino only has 13 I/O pins. So is there a way I can use the analog pins or a way to reduce the number of I/O pins using an ingenious way?&lt;/p&gt;&#xA;" OwnerUserId="10408" LastEditorUserId="510" LastEditDate="2015-12-26T20:48:58.210" LastActivityDate="2015-12-26T20:48:58.210" Title="Increasing the numbers of I/O pins on Arduino Uno" Tags="|arduino-uno|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14409" PostTypeId="2" ParentId="14407" CreationDate="2015-08-21T14:33:27.040" Score="13" Body="&lt;p&gt;The main issue is with pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many pins have multiple functions assigned to them, such as A4 and A5 are also the I2C pins, pins 10/11/12/13 are also the SPI pins, etc.  But pins 0 and 1 are the only multi-function pins that actually have something attached to them on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the other pins, while being multi-function, have their function defined basically by what you attach to them.  Since the pins 0 and 1 are already attached on the board to the USB interface chip their usage possibilities are somewhat more limited.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As soon as you enable Serial in your sketch (&lt;code&gt;Serial.begin()&lt;/code&gt;) those two pins can no longer be reliably used for digital IO.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That means that you can &lt;em&gt;either&lt;/em&gt; use the hardware serial port &lt;em&gt;or&lt;/em&gt; you can use the pins for digital IO, but not both.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Devices connected to pins 0 and 1 can interfere with the serial connection&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That includes uploading of sketches.  You have serial data coming in from the PC while the same pins are being affected by other things connected to them.  The most common one is things like GPS modules which connect to those pins and constantly send serial data.  That serial data will conflict with the PC's serial data and neither will arrive right.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How do you upload sketches if the serial is being interfered with by your sketch? How do you &quot;reset&quot; the board?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You don't.  It's not your sketch that's interfering with the serial, it's what is physically connected to those two IO pins that are interfering.  Just disconnect those two pins from whatever is connected and you will be able to upload sketches again.  Many shields now are starting to add a small switch on them to disconnect those pins so you can upload sketches without unplugging the shield.  You can also use the same trick with other devices you wire up to those pins - add a double-pole-single-throw or double-pole-double-throw (and not use one position) to easily isolate both pins from the rest of your hardware when you need to.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Does this affect all Arduino boards?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;No, only those that use a USB to Serial bridge chip - that's things like the Uno, Due, Mega, etc.  Boards that have a direct USB connection don't use the TX and RX pins for uploading sketches - they use the dedicated USB D+ and D- pins.  That's boards like the Leonardo, some of the smaller (mini? micro? I forget which) boards, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-21T14:33:27.040" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="14410" PostTypeId="2" ParentId="14408" CreationDate="2015-08-21T14:42:38.190" Score="4" Body="&lt;p&gt;Yes, just use the analog pins. The analog pins are both analog inputs and digital I/O pins. The functions happen to be shared on the pins, in the same way that the interrupt pins are shared with digital I/O, the TX and RX pins are shared with digital I/O and the SPI pins are shared with digital I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every I/O pin (analog or digital, etc.) can be used as digital I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also reduce your required number of I/O pins by using a technique known as &lt;em&gt;multiplexing&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, to read nine buttons you could have them arranged (as in Tic-tac-toe) in three rows of three buttons. You then have three I/O pins for the columns and three I/O pins for the rows - that's just six I/O pins for nine buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The technique is widely used for keypads, but they are just buttons, so the same technique can be applied to any buttons.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/KeypadTutorial&quot; rel=&quot;nofollow&quot;&gt;The Matrix Keypad how-to&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The same can go for LEDs. There are various specialist LED multiplexing techniques that allow for many LEDs to be driven from just a handful of I/O pins.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=MmCGDJ90Qt4&quot; rel=&quot;nofollow&quot;&gt;How to Multiplex an LED Grid...&lt;/a&gt;&lt;/em&gt; (YouTube)&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/Charlieplex&quot; rel=&quot;nofollow&quot;&gt;Charlieplex Library for Arduino&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="510" LastEditDate="2015-12-26T20:48:50.383" LastActivityDate="2015-12-26T20:48:50.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14411" PostTypeId="1" AcceptedAnswerId="14412" CreationDate="2015-08-21T15:00:25.287" Score="6" ViewCount="2870" Body="&lt;p&gt;I noticed something unusual using the Low Power library today.&#xA;When printing text in the loop and using &lt;code&gt;LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);&lt;/code&gt; to sleep for one second, all the text in the loop gets messed up in the Serial Monitor as if you chose the wrong baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;LowPower.h&quot;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(F(&quot;HELLO&quot;));&#xA;  Serial.println(F(&quot;HELLO&quot;)); &#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(F(&quot;HELLO&quot;));&#xA;  LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code just prints &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;����11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=C!�11=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;even when using different baud rates. (I used the same baud rate on both the arduino and the monitor).&#xA;Replacing the low power command with &lt;code&gt;delay(1000);&lt;/code&gt; works fine&lt;/p&gt;&#xA;" OwnerUserId="11116" LastEditorUserId="4131" LastEditDate="2015-08-24T11:55:36.567" LastActivityDate="2015-08-24T11:55:36.567" Title="Low Power library messing up serial text" Tags="|serial|power|baud-rate|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14412" PostTypeId="2" ParentId="14411" CreationDate="2015-08-21T15:08:07.263" Score="12" Body="&lt;p&gt;The problem is most likely that the system is going to sleep &lt;em&gt;while&lt;/em&gt; it's still sending the serial data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forcing all the serial data to be sent before you go to sleep should fix the problem (serial data is sent in the background using an interrupt so as to keep sketch slowdown to a minimum):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.flush();&#xA;LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-21T15:08:07.263" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14414" PostTypeId="1" CreationDate="2015-08-21T18:44:41.307" Score="2" ViewCount="1588" Body="&lt;p&gt;Has someone experience with interfacing the AS3935 lightning sensor using I2C? I found a library but it only works with SPI as far as I can tell. I really don't want to give up 4 pins for SPI as I need those for other things. I2C would be great as I use a couple more sensors with I2C so no extra pins only for AS3935.&lt;/p&gt;&#xA;" OwnerUserId="11116" LastEditorUserId="2881" LastEditDate="2015-08-21T19:09:20.133" LastActivityDate="2018-05-04T01:32:49.203" Title="Use AS3935 with I2C?" Tags="|pins|i2c|spi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14415" PostTypeId="1" AcceptedAnswerId="14417" CreationDate="2015-08-21T18:54:56.197" Score="0" ViewCount="504" Body="&lt;p&gt;I have a small light metal platform about 30 cm square mounted on horizontal rails. It is well lubricated and slides easily from side to side. I would like to build a device to connect to the underside of the platform that will allow me to programatically move the platform left or right by a defined distance at the touch of a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I've never used an Arduino, I've been aware of its existence for a while and felt this might be a good project to begin experimenting with it. For context, I'm a computer programmer by trade, but have limited exposure to electronics in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where would be a good place to start?  Are there books that are considered the &quot;bible&quot; of Arduino development? Are there existing projects that  basically do what I'm hoping to achieve? Am I barking up the wrong tree and shouldn't be attempting to find a solution for this with an Arduino? Any input would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="11937" LastEditorUserId="11937" LastEditDate="2015-08-21T19:04:18.917" LastActivityDate="2015-08-21T21:15:01.857" Title="Controlling a sliding tray - beginners project" Tags="|motor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14416" PostTypeId="2" ParentId="14408" CreationDate="2015-08-21T19:11:27.927" Score="2" Body="&lt;p&gt;If multiplexing is too complicated for you, you can wire all buttons to one analog pin using resistors. This way you only need 9 pins for LEDs and 1 analog pin for buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cxlSz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cxlSz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6372" LastActivityDate="2015-08-21T19:11:27.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14417" PostTypeId="2" ParentId="14415" CreationDate="2015-08-21T21:15:01.857" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Am I barking up the wrong tree and shouldn't be attempting to find a solution for this with an Arduino? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not at all. For example see &lt;a href=&quot;http://reprap.org/&quot; rel=&quot;nofollow&quot;&gt;Reprap&lt;/a&gt; - a 3D printer using an Atmega1280 as the controller. As it says &lt;a href=&quot;http://reprap.org/wiki/Generation_2_Electronics&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino is an open source project that has created an easy and powerful microcontroller board based on the Atmel ATmega168. It is the brain of the RepRap electronics.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you can make a 3D printer with an Arduino, then you can make your sliding platform gadget, which sounds simpler if anything.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there existing projects that basically do what I'm hoping to achieve?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Reprap, for one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there books that are considered the &quot;bible&quot; of Arduino development?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is a broad question, and your original question already has a couple of &quot;flags&quot; that it is &lt;em&gt;too&lt;/em&gt; broad. I suggest you narrow it down a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of books about learning Arduino. My advice is to start doing some simple projects (simpler than the platform initially) to get the hang of compiling, uploading, and generally working with microcontrollers. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also try Google and YouTube. There are a &lt;strong&gt;lot&lt;/strong&gt; of Arduino projects out there.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T21:15:01.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14418" PostTypeId="2" ParentId="13226" CreationDate="2015-08-21T21:19:56.960" Score="0" Body="&lt;p&gt;You missed something bro!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino          ESP8266&#xA;Rxd       -&gt;     Txd&#xA;Txd       -&gt;     Rxd&#xA;3.3 V     -&gt;     VCC&#xA;GND       -&gt;     GND&#xA;3.3 V     -&gt;     CH_PD&lt;/p&gt;&#xA;" OwnerUserId="11942" LastActivityDate="2015-08-21T21:19:56.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14419" PostTypeId="2" ParentId="14407" CreationDate="2015-08-21T21:58:22.903" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;20x(20-1) = 380 leds (charlieplexing, high low);&#xA;  Correct me if i'm wrong. That means you are able to control 380 &quot;Whatever&quot; using diodes and one Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, the figure of 380 is correct for 20 pins (20&lt;sup&gt;2&lt;/sup&gt; - 20) however pins 0 and 1 are connected to pull-up resistors on the Atmega16U2, so they are never really at 0V. If you load a blank sketch, you will measure 5 V on pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you can't drive 380 &quot;whatevers&quot; you can drive 380 &lt;strong&gt;LEDs&lt;/strong&gt; via Charlieplexing. The property of the LED, that current only flows one way through it, is important to the way it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related question &lt;a href=&quot;https://arduino.stackexchange.com/questions/117/is-there-a-way-to-have-more-than-14-output-pins-on-arduino&quot;&gt;Is there a way to have more than 14 Output pins on arduino?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-21T21:58:22.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14420" PostTypeId="2" ParentId="11769" CreationDate="2015-08-21T22:51:42.983" Score="0" Body="&#xA;&#xA;&lt;p&gt;If you have a logic-converter between the Arduino and the GPS then you won't have any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The warning was about having the output from the Tx pin on the GPS possibly being damaged by +5 V from the Arduino, if a previously loaded sketch made it an output and HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you could just as easily upload a &quot;do nothing&quot; sketch like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is sound practice anyway, if you are connecting up new hardware and are not sure what the currently-loaded sketch does.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-26T04:34:11.290" LastActivityDate="2015-08-26T04:34:11.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14422" PostTypeId="2" ParentId="5194" CreationDate="2015-08-21T23:26:45.183" Score="1" Body="&lt;p&gt;Once the bootloader transfers control to the main code (sketch) it may as well not exist any more. It does &lt;strong&gt;not affect&lt;/strong&gt; the way the sketch runs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've written a simple echo program using RXC interrupt vector ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please post this code. For you to print &quot;READY&quot; you are (presumably) using the Serial port, in which case the HardwareSerial interrupt vectors are being used. I don't know how you managed to take over those vectors. Seeing your code might answer that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T23:26:45.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14424" PostTypeId="2" ParentId="13400" CreationDate="2015-08-21T23:44:23.150" Score="0" Body="&#xA;&#xA;&lt;p&gt;You can write char arrays? What makes you think you can't? Example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;char dataBuffer [80];&#xA;strcpy (dataBuffer, &quot;Hello, world&quot;);&#xA;&#xA;File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;if (dataFile) {&#xA;  dataFile.println(dataBuffer);&#xA;  dataFile.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T23:44:23.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14425" PostTypeId="2" ParentId="13727" CreationDate="2015-08-21T23:48:54.607" Score="2" Body="&lt;p&gt;Answered by Skyler440:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Never mind, found the problem. My software switched to the bluetooth for some reason after I changed some other settings. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Converted to answer to reduce unanswered questions.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-18T19:35:13.920" LastActivityDate="2016-02-18T19:35:13.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14426" PostTypeId="2" ParentId="8179" CreationDate="2015-08-21T23:54:31.837" Score="1" Body="&#xA;&#xA;&lt;p&gt;Example bit-banged SPI using port manipulation:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bitBangedSPIfast.h&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class bitBangedSPIfast&#xA;  {&#xA;  // addresses of output ports - NULL if not applicable&#xA;  volatile byte * const mosiPort_;&#xA;  volatile byte * const misoPin_;&#xA;  volatile byte * const sckPort_;&#xA;&#xA;  // bit masks for above&#xA;  const byte mosiBit_;&#xA;  const byte misoBit_;&#xA;  const byte sckBit_;&#xA;&#xA;  // addresses of data direction register ports&#xA;  volatile byte * const mosiDDR_;&#xA;  volatile byte * const misoDDR_;&#xA;  volatile byte * const sckDDR_;&#xA;&#xA;  // bit masks for above&#xA;  const byte mosiDDRBit_;&#xA;  const byte misoDDRBit_;&#xA;  const byte sckDDRBit_;&#xA;&#xA;  // delay for clock being high&#xA;  unsigned long delayUs_;&#xA;&#xA;  public:&#xA;    // constructor&#xA;    bitBangedSPIfast (&#xA;          // output ports&#xA;          volatile byte &amp;amp; mosiPort, &#xA;          const    byte mosiBit,&#xA;          volatile byte &amp;amp; misoPin, &#xA;          const    byte misoBit,&#xA;          volatile byte &amp;amp; sckPort,&#xA;          const    byte sckBit,&#xA;&#xA;          // data direction register ports&#xA;          volatile byte &amp;amp; mosiDDR, &#xA;          const    byte mosiDDRBit,&#xA;          volatile byte &amp;amp; misoDDR, &#xA;          const    byte misoDDRBit,&#xA;          volatile byte &amp;amp; sckDDR,&#xA;          const    byte sckDDRBit,&#xA;&#xA;          const unsigned long delayUs = 1)&#xA;       : &#xA;         mosiPort_ (&amp;amp;mosiPort), &#xA;         mosiBit_  (1 &amp;lt;&amp;lt; mosiBit),&#xA;         misoPin_  (&amp;amp;misoPin), &#xA;         misoBit_  (1 &amp;lt;&amp;lt; misoBit), &#xA;         sckPort_  (&amp;amp;sckPort), &#xA;         sckBit_   (1 &amp;lt;&amp;lt; sckBit), &#xA;&#xA;         mosiDDR_     (&amp;amp;mosiDDR), &#xA;         mosiDDRBit_  (1 &amp;lt;&amp;lt; mosiDDRBit),&#xA;         misoDDR_     (&amp;amp;misoDDR), &#xA;         misoDDRBit_  (1 &amp;lt;&amp;lt; misoDDRBit), &#xA;         sckDDR_      (&amp;amp;sckDDR), &#xA;         sckDDRBit_   (1 &amp;lt;&amp;lt; sckDDRBit), &#xA;&#xA;        delayUs_ (delayUs) { }&#xA;&#xA;    void begin ();&#xA;    byte transfer (byte input);&#xA;&#xA;  };  // end of bitBangedSPIfast&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bitBangedSPIfast.cpp&lt;/strong&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;bitBangedSPIfast.h&amp;gt;&#xA;&#xA;void bitBangedSPIfast::begin ()&#xA;  {&#xA;  if (mosiPort_)&#xA;    *mosiDDR_ |= mosiDDRBit_;    // output&#xA;  if (misoPin_)&#xA;    *misoDDR_ &amp;amp;= ~misoDDRBit_;   // input&#xA;  *sckDDR_ |= sckDDRBit_;        // output&#xA;  }   // end of bitBangedSPIfast::begin&#xA;&#xA;&#xA;// Bit Banged SPI transfer&#xA;byte bitBangedSPIfast::transfer (byte c)&#xA;{       &#xA;  // loop for each bit  &#xA;  for (byte bit = 0; bit &amp;lt; 8; bit++) &#xA;    {&#xA;    // set up MOSI on falling edge of previous SCK (sampled on rising edge)&#xA;    if (mosiPort_)&#xA;      {&#xA;      if (c &amp;amp; 0x80)&#xA;        *mosiPort_ |= mosiBit_;&#xA;      else&#xA;        *mosiPort_ &amp;amp;= ~mosiBit_;&#xA;      }&#xA;&#xA;    // finished with MS bit, get read to receive next bit      &#xA;    c &amp;lt;&amp;lt;= 1;&#xA;&#xA;    // read MISO&#xA;    if (misoPin_)&#xA;      c |= (*misoPin_ &amp;amp; misoBit_) != 0;&#xA;&#xA;    // clock high&#xA;    *sckPort_ |= sckBit_;&#xA;&#xA;    // delay between rise and fall of clock&#xA;    delayMicroseconds (delayUs_);&#xA;&#xA;    // clock low&#xA;    *sckPort_ &amp;amp;= ~sckBit_;&#xA;&#xA;    // delay between rise and fall of clock&#xA;    delayMicroseconds (delayUs_);&#xA;    }  // end of for loop, for each bit&#xA;&#xA;  return c;&#xA;  }  // end of bitBangedSPIfast::transfer  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Example usage&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;bitBangedSPIfast.h&amp;gt;&#xA;&#xA;bitBangedSPIfast bbSPI (PORTD,  5, PIND,  6, PORTD, 7,    // MOSI port (D5), MISO pin (D6), SCK port (D7)&#xA;                        DDRD,   5, DDRD,  6, DDRD,  7);   // MOSI ddr  (D5), MISO ddr (D6), SCK ddr  (D7)&#xA;const byte mySS =  8;  // slave select&#xA;&#xA;void setup (void)&#xA;  {&#xA;  bbSPI.begin ();&#xA;  pinMode (mySS, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop (void)&#xA;  {&#xA;  char c;&#xA;&#xA;  // enable Slave Select&#xA;  digitalWrite(mySS, LOW); &#xA;&#xA;  // send test string&#xA;  for (const char * p = &quot;Hello, world!&quot; ; c = *p; p++)&#xA;    bbSPI.transfer (c);&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(mySS, HIGH);&#xA;&#xA;  delay (100); &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Reference&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI - Serial Peripheral Interface - for Arduino&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-21T23:54:31.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14427" PostTypeId="2" ParentId="14369" CreationDate="2015-08-22T01:27:51.533" Score="0" Body="&lt;p&gt;Indeed, this is an issue of RAM available. If you do not need 8 bits per piece of data (if you are perhaps willing to reduce image quality, for example), consider compacting your data such that you have multiple piece of data per bit. For example, hex values or BCD (binary coded decimals) could work, depending on the size of each piece of data.&lt;/p&gt;&#xA;" OwnerUserId="11929" LastEditorUserId="11929" LastEditDate="2015-08-22T20:36:44.983" LastActivityDate="2015-08-22T20:36:44.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14428" PostTypeId="2" ParentId="10076" CreationDate="2015-08-22T01:40:20.600" Score="0" Body="&#xA;&#xA;&lt;p&gt;Using the source from &lt;a href=&quot;http://arcfn.com/files/arduino-tv-b-gone-1.2.zip&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; I got it to compile following these steps.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before opening the sketch in the Arduino:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Rename TVB.pde to TVB.ino&lt;/li&gt;&#xA;&lt;li&gt;Rename WORLDcodes.cpp to WORLDcodes.h&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open the sketch (TVB.ino) in the Arduino IDE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit main.h and change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// The structure of compressed code entries&#xA;struct IrCode {&#xA;  uint8_t timer_val;&#xA;  uint8_t numpairs;&#xA;  uint8_t bitcompression;&#xA;  uint16_t const *times;&#xA;  uint8_t const*codes;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// The structure of compressed code entries&#xA;struct IrCode {&#xA;  uint8_t timer_val;&#xA;  uint8_t numpairs;&#xA;  uint8_t bitcompression;&#xA;  uint16_t const *times;&#xA;  uint8_t const*codes PROGMEM;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, add &lt;code&gt;PROGMEM&lt;/code&gt; to the &lt;code&gt;codes&lt;/code&gt; line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit TVB.ino and change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;extern PGM_P *NApowerCodes[] PROGMEM;&#xA;extern PGM_P *EUpowerCodes[] PROGMEM;&#xA;extern uint8_t num_NAcodes, num_EUcodes;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;WORLDcodes.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This avoids some linker problems in the original code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Edit WORLDcodes.h and delete the line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; #include &quot;main.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Continue editing WORLDcodes.h and change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const struct IrCode *NApowerCodes[] PROGMEM = {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const struct IrCode * const NApowerCodes[] PROGMEM = {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And also change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const struct IrCode *EUpowerCodes[] PROGMEM = {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const struct IrCode * const EUpowerCodes[] PROGMEM = {&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It should now compile OK.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T01:40:20.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14429" PostTypeId="1" AcceptedAnswerId="14438" CreationDate="2015-08-22T01:41:14.610" Score="0" ViewCount="1009" Body="&lt;p&gt;I have two devices connected to my Arduino using the SoftwareSerial library. However, it seems that they cannot communicate at the same time. I can only communiate with both by switching between which one I am listening to every 1000ms (they poll for 1500ms), but this slows down overall communication significantly. Is there anyway to communiate with both at the same time? Could this be achieved by using SoftwareSerial with one and the hardware serial port with the other?&lt;/p&gt;&#xA;" OwnerUserId="11929" LastActivityDate="2015-08-22T06:54:53.033" Title="Serial communication with two devices" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14430" PostTypeId="2" ParentId="4139" CreationDate="2015-08-22T01:59:04.683" Score="1" Body="&lt;p&gt;&lt;em&gt;Comment by olls converted to an answer&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did get it working. The schematic isn't mine to share unfortunately, but it consisted of some transistors to shift the PWM up to 20v, which then went into an inverter circuit (not made by me, quite complex) which merged the two PWM signals together into a AC signal. Then there was a transformer and RC filter to smooth out and amplify the PWM. Sorry I can't be more help, but it was a while ago, and I didn't make all of it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T01:59:04.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14431" PostTypeId="2" ParentId="3701" CreationDate="2015-08-22T02:03:35.167" Score="3" Body="&#xA;&#xA;&lt;p&gt;I have a library for driving the MAX7219 chip connected to a 7-segment display. It is at: &lt;a href=&quot;https://github.com/nickgammon/MAX7219&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/nickgammon/MAX7219&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of use:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;bitBangedSPI.h&amp;gt;&#xA;#include &amp;lt;MAX7219.h&amp;gt;&#xA;&#xA;const byte chips = 1;&#xA;&#xA;// 1 chip, bit banged SPI on pins 6, 7, 8&#xA;MAX7219 display (chips, 6, 7, 8);  // Chips / LOAD / DIN / CLK&#xA;&#xA;void setup ()&#xA;  {&#xA;  display.begin ();&#xA;  display.sendString (&quot;HELLO&quot;);&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In operation displaying a number:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nrocm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nrocm.jpg&quot; alt=&quot;MAX7219 display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details at: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interfacing LED displays with the MAX7219 driver&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T02:03:35.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14432" PostTypeId="2" ParentId="11757" CreationDate="2015-08-22T02:05:06.463" Score="0" Body="&lt;p&gt;&lt;em&gt;Comment by SR1 turned into an answer&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the suggestions. It finally worked. It was because of my HC-06 Bluetooth module. I don't know if the mistake was mine or if it is a fault with the module.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;(Done to reduce &quot;unanswered questions&quot; on this site).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T02:05:06.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14433" PostTypeId="2" ParentId="5339" CreationDate="2015-08-22T02:09:22.360" Score="7" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The device ID and every other stuff is working fine. The only issue being that my code gets stuck at Wire.endTransmission().&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Nothing is transmitted until you call &lt;code&gt;Wire.endTransmission()&lt;/code&gt; so that is where it will hang.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You should not try to do Wire transmissions inside an ISR (if you are doing that).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is an alternative to the Wire library which times-out rather than hanging. It is at: &lt;a href=&quot;https://github.com/rambo/I2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino I2C Master Library&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you have pull-up resistors on SDA and SCL. Typically 4.7 k from both to +5 V.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If none of that helps, please post your code.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2020-10-21T06:28:48.167" LastActivityDate="2020-10-21T06:28:48.167" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="14434" PostTypeId="2" ParentId="8536" CreationDate="2015-08-22T02:22:50.947" Score="2" Body="&#xA;&#xA;&lt;p&gt;Looking at the library at &lt;a href=&quot;https://github.com/thijse/Arduino-EEPROMEx/blob/master/EEPROMex.cpp&quot; rel=&quot;nofollow&quot;&gt;https://github.com/thijse/Arduino-EEPROMEx/blob/master/EEPROMex.cpp&lt;/a&gt; it seems they limit the number of writes to 100:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;EEPROMClassEx::EEPROMClassEx()&#xA;  :  _allowedWrites(100)&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There seems to be a way of changing that:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Set global maximum of allowed writes&#xA; */&#xA;void EEPROMClassEx::setMaxAllowedWrites(int allowedWrites) {&#xA;#ifdef _EEPROMEX_DEBUG&#xA;    _allowedWrites = allowedWrites;&#xA;#endif          &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T02:22:50.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14435" PostTypeId="2" ParentId="13064" CreationDate="2015-08-22T02:24:56.547" Score="1" Body="&lt;p&gt;&lt;em&gt;Comment by Glen Cashen turned into an answer&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just found out about the pullup resistors and how exactly the INPUT works it's all fixed now thanks :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just made them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; pinMode(pin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T02:24:56.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14436" PostTypeId="2" ParentId="117" CreationDate="2015-08-22T02:47:24.880" Score="1" Body="&lt;p&gt;With a bit of work (installing a different bootloader) an additional seven I/O lines are available on an Uno, on the ICSP1 and JP2 headers.  The replacement bootloader is called &lt;a href=&quot;http://blog.atmel.com/2014/12/01/using-the-power-of-two-mcus-on-an-arduino-board/&quot; rel=&quot;nofollow&quot;&gt;HoodLoader2&lt;/a&gt;.  It allows you to install sketches on both the Atmega328 and Atmega16U2 on an Uno.  Dealing with multiple processors would be the main complication from using this method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On an Uno, the ICSP1 and JP2 headers connect to pins PB1...PB7 of the Atmega16U2.  In addition the Atmega16U2 has about 9 I/O pins with no connection to the circuit board.  A person working under a microscope might be able to attach wires to a total of 18 I/O pins on the 16U2, while leaving three other I/O pins attached to their ordinary connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HoodLoader2 also works on Mega boards.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-08-22T02:47:24.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14437" PostTypeId="2" ParentId="9421" CreationDate="2015-08-22T02:50:12.767" Score="2" Body="&lt;p&gt;By my calculations you are sinking 6 amps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;72 W / 12 V = 6 A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have some doubt that the Arduino board is designed to handle that amount of current through its ground plane. Try running a separate ground wire to the MOSFET sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also be concerned about the gauge of wire you are using, and whether the prototyping board can handle that amount of current.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T02:50:12.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14438" PostTypeId="2" ParentId="14429" CreationDate="2015-08-22T05:11:11.403" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/14179/softwareserial-write-to-return-read-in-serial-monitor/14180#14180&quot;&gt;SoftwareSerial Write to return Read in Serial Monitor?&lt;/a&gt; - SoftwareSerial cannot both read and write at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However HardwareSerial can.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Could this be achieved by using SoftwareSerial with one and the hardware serial port with the other?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So, likewise, there is no way to read from both devices using only SoftwareSerial?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is correct. Not at the same time. SoftwareSerial uses an interrupt to detect the start bit of incoming data. So far so good. But once it gets it, it leaves interrupts disabled while it goes into a timed loop to read all the bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, it is impossible for it to react to another incoming byte on another pin at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, you could receive on SoftwareSerial on one pin, and HardwareSerial on another. With HardwareSerial the hardware will run in the background, receiving the byte.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-08-22T06:54:53.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14439" PostTypeId="2" ParentId="11689" CreationDate="2015-08-22T05:51:40.390" Score="4" Body="&lt;p&gt;I don't see any objection to using &lt;a href=&quot;http://dsscircuits.com/articles/arduino-i2c-master-library&quot; rel=&quot;nofollow&quot;&gt;DSS Circuits I2C Master Library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may not have been updated for a couple of years, but if it works it doesn't need to be. It's not as if libraries for micro-controllers have to support new printer drivers, video drivers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it works, it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chip hasn't changed, and the only real reason for updates these days is if the IDE changes (or the compiler changes) in such a way that it introduces compile errors. Such things have happened fairly recently with things like PROGMEM having tighter rules, for example.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T05:51:40.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14440" PostTypeId="2" ParentId="9149" CreationDate="2015-08-22T06:05:16.090" Score="1" Body="&lt;p&gt;First, I would do what Edgar Bonet suggested, call the normal constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MB_GFX_SPI mbGFX (Period, numCathodeLeds, numAnodeLeds, CathodeSSPin, AnodeSSPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, I'm not keen on what you are doing in the constructor for a variable which appears to be at global scope (mbGFX).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.parashift.com/c++-faq/static-init-order.html&quot; rel=&quot;nofollow&quot;&gt;What's the &quot;static initialization order fiasco&quot;?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you cannot assume that constructors in different compilation units are called in any defined sequence, you also cannot assume that the system has been initialized yet (ie. &lt;code&gt;init()&lt;/code&gt; called).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, things that address the hardware (eg. &lt;code&gt;clearScreen(0);&lt;/code&gt;) may not work properly, or at all.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T06:05:16.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14441" PostTypeId="2" ParentId="13131" CreationDate="2015-08-22T06:18:42.613" Score="1" Body="&lt;p&gt;Tests show that connecting Reset to Ground on a Uno reduces the power consumption from 47 mA to 41 mA. So it is hardly &quot;off&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that would do is stop the currently-loaded sketch running, and save a few milliamps.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T06:18:42.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14443" PostTypeId="2" ParentId="8708" CreationDate="2015-08-22T09:15:17.830" Score="0" Body="&lt;p&gt;I wonder for which purpose you would use a micro controller at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a fixed frequency circuit, you could design just that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a generator with variable frequency, that would justify the Arduino, but in this case I would use the Arduino to control the frequency indirectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ex: create a &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage-controlled_oscillator&quot; rel=&quot;nofollow&quot;&gt;VCO&lt;/a&gt; and use the Arduino to adjust the voltage, through a &lt;a href=&quot;https://en.wikipedia.org/wiki/Digital-to-analog_converter&quot; rel=&quot;nofollow&quot;&gt;DAC&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-22T09:15:17.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14445" PostTypeId="2" ParentId="11757" CreationDate="2015-08-22T15:29:54.477" Score="1" Body="&lt;p&gt;From your code, I assume that the bluetooth module is connected to pins 0 &amp;amp; 1 on the arduino. These pins are to be kept free/floating/not connected to anything if you need to upload code to your board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use software serial in such cases reduces the headache&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-22T15:29:54.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14446" PostTypeId="1" CreationDate="2015-08-22T16:04:47.937" Score="3" ViewCount="1124" Body="&lt;p&gt;I'm using an Adafruit NRF8001 Low Energy Bluetooth module and a Real Time Clock module with my Arduino board. I want to connect to the BLE module using UART to set the clock. I'll also be using UART to set alarms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure which is the best way to take a string from the UART receiver and pull it apart into the hours, minutes, second, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? I did look at the Arduino JSON library but it seems a little buggy, and possibly overkill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be very much appreciated :)&lt;/p&gt;&#xA;" OwnerUserId="11584" LastActivityDate="2015-10-21T19:39:05.380" Title="Using UART to Set RTC" Tags="|string|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14447" PostTypeId="2" ParentId="14446" CreationDate="2015-08-22T16:31:04.743" Score="2" Body="&lt;p&gt;The simplest method is to keep it as a fixed format string with line termination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read one line in from serial into a character array (aka C string) and then chop it up.  As long as the string is in the correct format you can easily chop it around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, assume you chose the format &lt;code&gt;YYYY-MM-DD HH:MM:SS\n&lt;/code&gt; which is quite common and easy to use, you may have data like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *indata = &quot;2015-08-22 17:23:48\n&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;code&gt;\n&lt;/code&gt; is the new-line character)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using simple char pointers you can get each substring quite easily:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First slice the string up into the component parts by replacing the separator tokens with character 0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;indata[4] = 0;&#xA;indata[7] = 0;&#xA;indata[10] = 0;&#xA;indata[13] = 0;&#xA;indata[16] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can assign pointers to each segment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *year = indata;&#xA;char *month = indata + 5;&#xA;char *day = indata + 8;&#xA;char *hour = indata + 11;&#xA;char *minute = indata + 14;&#xA;char *second = indata + 17;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or if you want it as integers, you can pass it straight to &lt;code&gt;atoi&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int year = atoi(indata);&#xA;int month = atoi(indata + 5);&#xA;int day = atoi(indata + 8);&#xA;int hour = atoi(indata + 11);&#xA;int minute = atoi(indata + 14);&#xA;int second = atoi(indata + 17);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact, if passing it direct to &lt;code&gt;atoi()&lt;/code&gt; you shouldn't need to even do the first stage, since it will stop parsing at the first non-numeric character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are more flexible ways of parsing the string too, using &lt;code&gt;strtok()&lt;/code&gt;, but that is somewhat more advanced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this method is highly intolerant to invalid strings being passed, so you may want to first ensure that a) the string is the right length, and that b) there are the right separator tokens in the right placed, to validate that the string is properly formatted before proceeding.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-22T16:31:04.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14448" PostTypeId="1" AcceptedAnswerId="14450" CreationDate="2015-08-22T19:44:00.340" Score="2" ViewCount="16968" Body="&lt;p&gt;I have an &lt;strong&gt;Arduino Mega&lt;/strong&gt; and the &lt;strong&gt;CL5642BH&lt;/strong&gt;, a &lt;strong&gt;4-digit 7-segment display.&lt;/strong&gt; I found very helpful code &lt;a href=&quot;http://www.hobbytronics.co.uk/arduino-4digit-7segment&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, but I don't understand how to wire it up on the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display has 12 pins: 6 on the top and 6 on the bottom. First I guess I need to find out which one is GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then (see the link) there is this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int digit1 = 11; //PWM Display pin 1&#xA;int digit2 = 10; //PWM Display pin 2&#xA;int digit3 = 9; //PWM Display pin 6&#xA;int digit4 = 6; //PWM Display pin 8&#xA;&#xA;int segA = A1; //Display pin 14&#xA;int segB = 3; //Display pin 16&#xA;int segC = 4; //Display pin 13&#xA;int segD = 5; //Display pin 3&#xA;int segE = A0; //Display pin 5&#xA;int segF = 7; //Display pin 11&#xA;int segG = 8; //Display pin 15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's 11 pins, that's the correct amount so far. But &lt;strong&gt;how do I wire it up?&lt;/strong&gt; The pins on the display are in no way labeled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: I'm a software developer, but as far as electronics go, I'm still a beginner.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="8762" LastActivityDate="2016-05-04T07:08:49.983" Title="How to wire up 4-digit 7-segment display?" Tags="|arduino-mega|pins|display|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14449" PostTypeId="2" ParentId="14448" CreationDate="2015-08-22T19:51:22.863" Score="1" Body="&lt;p&gt;As page 2 of the datasheet shows, there are 5 anode pins (4 digit and 1 aux) and 8 cathode pins (7 segments and 1 DP). Connect the digit lines to the digit anodes and the segment lines to &lt;a href=&quot;https://electronics.stackexchange.com/questions/17179/correct-formula-for-led-current-limiting-resistor&quot;&gt;resistors&lt;/a&gt; connected to the segment cathodes. The location of pin 1 is shown on the top right of page 2, and as always they go counter clockwise from there. Segments are lit by putting the anode high and the cathode low.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-08-22T19:51:22.863" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14450" PostTypeId="2" ParentId="14448" CreationDate="2015-08-22T19:55:31.177" Score="5" Body="&lt;p&gt;The first thing you do is ask Google for a datasheet.  It tells you: &lt;a href=&quot;http://www.robotshop.com/media/files/pdf/datasheet-com-09483.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.robotshop.com/media/files/pdf/datasheet-com-09483.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can read the datasheet and find the pin diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TnON4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TnON4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That tells you that it is a &lt;em&gt;Common Anode&lt;/em&gt; LED display - which means that for each digit all the &lt;em&gt;Anodes&lt;/em&gt; (positive pins) of the LEDs are wired together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, all the &lt;em&gt;cathode&lt;/em&gt; (negative) pins of the LEDs for the same segments across the digits are connected (that is the cathode for segment A on digit 1 is connected to the cathode for segment A on digit 2, digit 3 and digit 4, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that you can then infer that you need to provide current for each digit in turn through its common anode pin, and sink current from the segments you want to have lit for the digit that is currently having its current sourced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diagram also shows you which pin on the display is for what function - the common anodes are pins 9, 10, 12 and 13, with pin 11 the common anode for the extra dots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet also tells you which pin is pin 1 - in this case the one in the bottom left when you have the display facing you and the numbers the right way up.  The pins count anti-clockwise from there, so 2 is to its right and 13 is above it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/16F42.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/16F42.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the sounds of it though you may not have the same display as in that datasheet.  If your display lacks the extra dots then it may not have the LEDs on pin 11, and pin 12-13 may be moved down one, so you have 4 commons on 9, 10, 11 and 12 with no pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the four digit select pins in your program are wired to pins 9, 10, 12 and 13, and the segment select pins connect to pins 1, 2, 3, 4, 5, 6, and 7.  Don't forget the resistors on all the segment pins to limit the LED current or you will damage the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do some manual testing of the display by using two wires and a resistor (say 1KΩ).  Connect the resistor to +5V, and one wire to the other end of the resistor.  The other wire you connect to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then take the loose ends of the wires and try probing pins.  Start with the 5V wire touching pin 9 and connect the other one in turn to pins 1-8 to see if the first digit's segments light up.  Repeat with the 5V wire on pins 10-12.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this (&lt;a href=&quot;http://mklec.com/displays/7-segment-4-digit-12-pin-common-anode-display&quot; rel=&quot;noreferrer&quot;&gt;http://mklec.com/displays/7-segment-4-digit-12-pin-common-anode-display&lt;/a&gt;) is indeed the same display as yours you can ignore the numbers I mention above and work from the pin numbers on that page.  The same principle applies though, just the pin numberings are different.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-22T20:02:14.680" LastActivityDate="2015-08-22T20:02:14.680" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14451" PostTypeId="2" ParentId="14448" CreationDate="2015-08-22T22:18:40.220" Score="1" Body="&lt;p&gt;From the datasheet found by Ignacio Vazquez-Abrams:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RUUEq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RUUEq.png&quot; alt=&quot;7-segment display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now one segment will light up if there is a positive (eg. 5 V) on the anode, and a negative (eg. ground) on the cathode. You need a resistor (eg. 330 ohm) to protect the LED and the output pin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hopefully it is clear from the original question which Arduino pins go to which LED pins.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Then the code which I presume you found will have to multiplex the display. That is, it will ground (send LOW) to the appropriate cathode pins for the number of segments it needs to light up (all of them, for example, for the number 8, except the decimal point). And then it will raise to 5 V (send HIGH) to DIG 1. That will make some segments on digit 1 light up. Then it repeats that for digits 2 to 4, fast enough that they will all appear to be on at once.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-22T22:18:40.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14452" PostTypeId="2" ParentId="9351" CreationDate="2015-08-23T02:56:54.690" Score="7" Body="&lt;h2&gt;Testing a single byte write&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I ran some test code overnight to try to get to the bottom of this. Somewhat surprisingly perhaps, I got up to over 11 million writes before a read-back failed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current count = 11514199&#xA;Writes per minute: 17550&#xA;....................&#xA;Current count = 11538199&#xA;Writes per minute: 17550&#xA;....................&#xA;Current count = 11562199&#xA;Writes per minute: 17549&#xA;...................&#xA;Failed readback!&#xA;Expected: FF&#xA;Got: 7F&#xA;Current count = 11585314&#xA;Halted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, 11.5 M writes. Still, as pointed out on the &lt;a href=&quot;http://www.avrfreaks.net/comment/529996#comment-529996&quot; rel=&quot;noreferrer&quot;&gt;AVR Freaks thread&lt;/a&gt;, the guarantee of 100,000 writes to EEPROM gives you a data retention time of 20 years. Possibly if you exceed that limit, the data retention time will go down. It isn't particularly practical for me to test whether or not the EEPROM will still be valid after 20 years. ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, the next day (as I write this) the EEPROM seems to have recovered and is now still writing and reading back OK. So it would appear that after 11 M writes you may &lt;em&gt;sometimes&lt;/em&gt; get a bad read-back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the AVR Freaks thread they seemed to get somewhere between 5 M and 8 M writes before failure.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A number of hours later (2.4 hours), the same byte failed again, after a further 2,559,219 writes!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current count = 14033314&#xA;Writes per minute: 17549&#xA;....................&#xA;Current count = 14057314&#xA;Writes per minute: 17549&#xA;....................&#xA;Current count = 14081314&#xA;Writes per minute: 17549&#xA;....................&#xA;Current count = 14105314&#xA;Writes per minute: 17549&#xA;....................&#xA;Current count = 14129314&#xA;Writes per minute: 17549&#xA;............&#xA;Failed readback!&#xA;Expected: FF&#xA;Got: 7F&#xA;Current count = 14144533&#xA;Halted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Somewhat more quickly the third failure after a further 149,703 writes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current count = 14312533&#xA;Writes per minute: 17550&#xA;....&#xA;Failed readback!&#xA;Expected: FF&#xA;Got: 7F&#xA;Current count = 14318236&#xA;Halted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And another failure (in 2.3 minutes) after a further 41757 writes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting.&#xA;Current count = 14318236&#xA;Waiting for pin 2 to go LOW.&#xA;Started.&#xA;....................&#xA;Current count = 14342236&#xA;Writes per minute: 17551&#xA;..............&#xA;Failed readback!&#xA;Expected: FF&#xA;Got: 7F&#xA;Current count = 14359993&#xA;Halted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Testing the adjacent byte&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now that I got a failure fairly quickly on the somewhat overworked byte, I adjusted the code to write to the next one up (1021) which would be in the same 4-byte &quot;page&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Four hours later, the adjacent byte has been written to 4.36 million times without any errors, so this would appear to support the idea that each byte of EEPROM can be written individually without affecting its neighbours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Next morning&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The adjacent byte (address 1021) finally failed after 12,161,565 writes. So the proposition that each byte can be individually addressed, and has an individual lifetime, seems to be supported.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current count = 12120000&#xA;Writes per minute: 17562&#xA;....................&#xA;Current count = 12144000&#xA;Writes per minute: 17562&#xA;..............&#xA;Failed readback!&#xA;Expected: FF&#xA;Got: 7F&#xA;Current count = 12161565&#xA;Halted.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;h3&gt;Main sketch&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// EEPROM tester&#xA;&#xA;// Author: Nick Gammon&#xA;// Date: 22 August 2015&#xA;&#xA;// Connect a jumper from GND to pin D2 when ready to run.&#xA;// Remove the jumper for a clean wrap-up (saving the current count into EEPROM)&#xA;&#xA;// Single flash, repeated every half second: ready to go&#xA;// Two flashes, stopped on request&#xA;// Three flashes, error&#xA;// Occasional flash: working&#xA;&#xA;#include &amp;lt;EEPROMAnything.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;const unsigned int WRITE_COUNT_ADDRESS = 1010;&#xA;const unsigned int TEST_ADDRESS = 1020;&#xA;const unsigned int ITERATIONS = 200;&#xA;const unsigned long MAX_DOTS = 20;&#xA;const byte TESTS [] = { 0x55, 0x00, 0xFF, 0x66, 0xAA, 0x11 };&#xA;const byte ACTIVATE_PIN = 2;&#xA;const byte LED = 13;&#xA;&#xA;unsigned long dots = 0;&#xA;unsigned long writeCount;&#xA;unsigned long startTime;&#xA;unsigned long initialCount;&#xA;&#xA;void showCount ()&#xA;  {&#xA;  Serial.print (&quot;Current count = &quot;);&#xA;  Serial.println (writeCount);&#xA;  } // end of showCount&#xA;&#xA;// flash the LED the required number of times&#xA;void flashLED (const int times,&#xA;               const unsigned long interval = 100,&#xA;               const unsigned long delayTime = 500)&#xA;  {&#xA;  for (int i = 0; i &amp;lt; times; i++)&#xA;    {&#xA;    digitalWrite (LED, HIGH);&#xA;    delay (interval);&#xA;    digitalWrite (LED, LOW);&#xA;    delay (interval);&#xA;    }  // end of for each iteration&#xA;  delay (delayTime);  // delay between iterations&#xA;  }  // end of flashLED&#xA;&#xA;// check our memory agrees with what we expect&#xA;void checkMemory (const byte target)&#xA;  {&#xA;  byte found = EEPROM.read (TEST_ADDRESS);&#xA;  if (found != target)&#xA;    {&#xA;    Serial.println ();&#xA;    Serial.println (&quot;Failed readback!&quot;);&#xA;    Serial.print (&quot;Expected: &quot;);&#xA;    Serial.println ((int) target, HEX);&#xA;    Serial.print (&quot;Got: &quot;);&#xA;    Serial.println ((int) found, HEX);&#xA;    showCount ();&#xA;    EEPROM_writeAnything (WRITE_COUNT_ADDRESS, writeCount);&#xA;    Serial.print (&quot;Halted.&quot;);&#xA;    Serial.flush ();&#xA;    while (true)&#xA;      flashLED (3);  // three flashes&#xA;    }&#xA;  }   // end of checkMemory&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  // get write count from previous run&#xA;  EEPROM_readAnything (WRITE_COUNT_ADDRESS, writeCount);&#xA;  initialCount = writeCount;&#xA;&#xA;  // if all 1 bits, variable was never initialized&#xA;  if (writeCount == 0xFFFFFFFF)&#xA;    writeCount = 0;&#xA;&#xA;  // tell them we are starting&#xA;  Serial.println (&quot;Starting.&quot;);&#xA;  pinMode (2, INPUT_PULLUP);&#xA;  pinMode (LED, OUTPUT);&#xA;  showCount ();&#xA;&#xA;  // wait for them to unplug pin 2&#xA;  Serial.println (&quot;Waiting for pin 2 to go LOW.&quot;);&#xA;  while (digitalRead (ACTIVATE_PIN) == HIGH)&#xA;    flashLED (1);  // one flash&#xA;&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  startTime = millis ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  // write to EEPROM, checking each write&#xA;  for (unsigned int i = 0; i &amp;lt; ITERATIONS; i++)&#xA;    {&#xA;    for (unsigned int j = 0; j &amp;lt; sizeof (TESTS); j++)&#xA;      {&#xA;      EEPROM.write (TEST_ADDRESS, TESTS [j]);&#xA;      writeCount++;&#xA;      checkMemory (TESTS [j]);&#xA;      }  // end of doing each test pattern&#xA;    }  // end of loop of x ITERATIONS&#xA;&#xA;  // save the current write count so we can pick up the count next time&#xA;  EEPROM_writeAnything (WRITE_COUNT_ADDRESS, writeCount);&#xA;  Serial.print (&quot;.&quot;);&#xA;  dots++;&#xA;&#xA;  // confirming we are working&#xA;  flashLED (1, 10, 0);  // flash once, for 10 ms, no extra delay&#xA;&#xA;  // newline, show counter&#xA;  if (dots &amp;gt;= MAX_DOTS)&#xA;    {&#xA;    Serial.println ();&#xA;    dots = 0;&#xA;    showCount ();&#xA;    unsigned long writes = writeCount - initialCount;&#xA;    unsigned long timeTaken = millis () - startTime;&#xA;    float writesPerMinute = float (writes) / float (timeTaken) * 60.0 * 1000.0;&#xA;    Serial.print (&quot;Writes per minute: &quot;);&#xA;    Serial.println ((int) writesPerMinute);&#xA;    }  // end of needing a newline and counter output&#xA;&#xA;  // check if user wants us to stop by disconnecting the jumper from Gnd to D2&#xA;  if (digitalRead (ACTIVATE_PIN) == HIGH)&#xA;    {&#xA;    Serial.println ();&#xA;    Serial.println (&quot;Stop request detected.&quot;);&#xA;    showCount ();&#xA;    Serial.print (&quot;Halted.&quot;);&#xA;    Serial.flush ();&#xA;    while (true)&#xA;      flashLED (2);  // two flashes&#xA;    }&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;EEPROMAnything.h&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;  // for type definitions&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;template &amp;lt;typename T&amp;gt; unsigned int EEPROM_writeAnything (int ee, const T&amp;amp; value)&#xA;{&#xA;    const byte* p = (const byte*)&amp;amp;value;&#xA;    unsigned int i;&#xA;    for (i = 0; i &amp;lt; sizeof(value); i++)&#xA;        EEPROM.write(ee++, *p++);&#xA;    return i;&#xA;}&#xA;&#xA;template &amp;lt;typename T&amp;gt; unsigned int EEPROM_readAnything (int ee, T&amp;amp; value)&#xA;{&#xA;    byte* p = (byte*)&amp;amp;value;&#xA;    unsigned int i;&#xA;    for (i = 0; i &amp;lt; sizeof(value); i++)&#xA;        *p++ = EEPROM.read(ee++);&#xA;    return i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The code is designed to wait until you connect pin 2 (digital pin 2) to ground before starting. This is to stop it executing immediately after being uploaded, before you start the serial monitor. So, upload the code, open the serial monitor, and then connect Gnd to pin D2, and watch the results.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Error correction&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If the concern is that the EEPROM reads may deteriorate, once could use &lt;a href=&quot;https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction&quot; rel=&quot;noreferrer&quot;&gt;Reed Solomon&lt;/a&gt; error correction to recover. That is the method used for correcting bad reads on compact disks, and also QR codes. It can recover from a number of errors (you choose the level of error correction you want - the more error correction, the more memory it takes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My tests so far have shown that failure involves single bits (as did the AVR Freaks tests) so this may well be a way of extending EEPROM life and reliability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing of some Reed Solomon code that I found, would appear to indicate that adding the encoding and decoding would take around 4800 bytes of program memory, plus around 600 bytes of RAM (512 bytes needed for the internal tables, plus some extra work space). In addition you need 256 bytes of RAM for the code block. Those figures could be reduced by using less bits per &quot;symbol&quot;. For example, if you stored 4-bit symbols (such as BCD numbers) then the memory requirements would reduce somewhat.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-23T20:29:45.900" LastActivityDate="2015-08-23T20:29:45.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14453" PostTypeId="2" ParentId="5378" CreationDate="2015-08-23T03:19:05.290" Score="3" Body="&lt;p&gt;Sorry for the delay. I posted this question on the EE board as suggested and forgot to come back here and close this out. It was an issue with the fuses. My initial attempt to setup the 16u2 missed the step where I was supposed to change the fuses. I thought this was accomplished when loading the firmware, but was mistaken.&lt;/p&gt;&#xA;" OwnerUserId="5145" LastActivityDate="2015-08-23T03:19:05.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14454" PostTypeId="1" AcceptedAnswerId="14456" CreationDate="2015-08-22T19:16:51.677" Score="2" ViewCount="2159" Body="&lt;p&gt;I have a pair of 433 MHz transmitter and receiver:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xXjyL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xXjyL.jpg&quot; alt=&quot;Transmitter / receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transmitter is connected to Arduino pro mini, receiver to Arduino Uno R3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output of receiver on serial looks like that (it doesn't change much):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basicly I am getting either 75x or zero regardless of transmitter is on or off.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;in &amp;gt; upper&#xA;756&#xA;in &amp;gt; upper&#xA;758&#xA;0&#xA;0&#xA; 0&#xA;in &amp;gt; upper&#xA;758&#xA;0&#xA;in &amp;gt; upper&#xA;757&#xA;in &amp;gt; upper&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Transmitter code:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define rfTransmitPin 4  &#xA;#define ledPin 6&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(rfTransmitPin, OUTPUT);     &#xA;    pinMode(ledPin, OUTPUT);    &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    for(;;)&#xA;    {&#xA;         digitalWrite(rfTransmitPin, HIGH);     //Transmit a HIGH signal&#xA;         analogWrite(ledPin, 255);              //Turn the LED on&#xA;         delay(500);                            //Wait for 1 second&#xA;&#xA;         digitalWrite(rfTransmitPin,LOW);       //Transmit a LOW signal&#xA;         analogWrite(ledPin, 0);                //Turn the LED off&#xA;         delay(500);                            //Variable delay&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const unsigned int upperThreshold = 70;  //upper threshold value&#xA;const unsigned int lowerThreshold = 0;  //lower threshold value&#xA;const int ledPin = 13;&#xA;&#xA;#define ReceiverPin  A0&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(19200);&#xA;&#xA;    pinMode(ledPin, OUTPUT);&#xA;&#xA;    DiodeTest();&#xA;}&#xA;&#xA;&#xA;&#xA;void loop() &#xA;{&#xA;   int data = analogRead(ReceiverPin);&#xA;   delay(50);&#xA;&#xA;   if(data&amp;gt;upperThreshold)&#xA;   {&#xA;       digitalWrite(ledPin, LOW);   //If a LOW signal is received, turn LED OFF&#xA;       Serial.println(&quot;in &amp;gt; upper&quot;);&#xA;   }&#xA;&#xA;   if(data&amp;lt;lowerThreshold)&#xA;   {&#xA;       digitalWrite(ledPin, HIGH);   //If a HIGH signal is received, turn LED ON&#xA;       Serial.println(&quot;in &amp;lt; lower&quot; );&#xA;   }&#xA;&#xA;   Serial.println(data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14023" OwnerDisplayName="toomasz" LastEditorUserId="46" LastEditDate="2015-08-29T00:24:07.147" LastActivityDate="2016-11-06T08:48:00.973" Title="433MHz transmitter and receiver pair doesnt work" Tags="|remote-control|electronics|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14455" PostTypeId="2" ParentId="14454" CreationDate="2015-08-22T21:00:18.327" Score="0" Body="&lt;p&gt;You also need to attach a piece of insulated wire as a 1/4 wave length antenna to each of the receiver and transmitter boards. For the 433 MHz type antenna's this would be a piece of wire ~6.8&quot; (17.3cm) long. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference if you were using the other popular type of low cost RF link pair at 315 MHz the antennas would be ~9.37&quot; (23.8cm) long.&lt;/p&gt;&#xA;" OwnerUserId="15149" OwnerDisplayName="Michael Karas" LastEditorUserId="84" LastEditDate="2016-11-06T08:48:00.973" LastActivityDate="2016-11-06T08:48:00.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14456" PostTypeId="2" ParentId="14454" CreationDate="2015-08-23T00:02:17.900" Score="3" Body="&lt;p&gt;These types of receivers are AC coupled so you will not be able to do what you are doing as you need to have regular transitions in the signal and not stay in one state for too long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are also limited in the speed at which they will work, I expect 19200 bps is too fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use a modulation technique such as Manchester Encoding or other technique that guarantees a suitable density of transitions, can synchronize the data and perform error checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One popular software library that does this is &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/VirtualWire.pdf&quot; rel=&quot;nofollow&quot;&gt;VirtualWire Arduino Library&lt;/a&gt; that is designed for Arduino and the type of transmitters and receivers you are using.&lt;/p&gt;&#xA;" OwnerUserId="29866" OwnerDisplayName="Kevin White" LastActivityDate="2015-08-23T00:02:17.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14457" PostTypeId="2" ParentId="14454" CreationDate="2015-08-23T04:29:14.050" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11506&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post about a radio-controlled car&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found when using what looks like a similar receiver to yours, that the received data looked like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eJWAd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eJWAd.jpg&quot; alt=&quot;Radio receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cyan line was the receiver, the yellow line is what is being transmitted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trouble turned out to be the pull-up resistor on the Arduino Rx pin (from the USB chip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even with SoftwareSerial it wasn't too great:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7aJQe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7aJQe.jpg&quot; alt=&quot;Radio receiver software serial&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that using an op-amp as a buffer helped a lot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qBQiR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qBQiR.png&quot; alt=&quot;Op-amp buffer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I also agree with the comments about adding an aerial wire, just a short length of hookup wire should do it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-23T04:29:14.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14458" PostTypeId="5" CreationDate="2015-08-23T04:54:53.863" Score="0" Body="&lt;h2&gt;Output shift register&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An &lt;strong&gt;output&lt;/strong&gt; shift register such as the 74HC595 lets you stream data from an Arduino data pin, where it is &quot;latched&quot; by the shift register into (typically 8) ports simultaneously. Normally you communicate with a shift register using three control signals, in addition to power and ground:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MOSI (Master Out, Slave In) - that is, the data&lt;/li&gt;&#xA;&lt;li&gt;SCK (Serial clock) - this tells the register when a new data bit arrives&lt;/li&gt;&#xA;&lt;li&gt;LATCH - tells the register to transfer the current bit pattern from a holding register to the output pins.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Shift registers can be daisy-chained, they typically have an &quot;overflow&quot; pin which is used to transfer the oldest incoming bit from one register to the next. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, to send 16 bits you would bring the LATCH pin low, transfer 16 bits (the first 8 would be pushed out of the first shift register into the second one) and then when the LATCH pin goes high, both registers now have the appropriate parts of the 16 bits on their output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical applications of the 74HC595 are to control banks of LEDs, or other similar devices.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Input shift register&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An &lt;strong&gt;input&lt;/strong&gt; shift register such as the 74HC165 lets you stream data from the register to an Arduino input pin. Normally you communicate with an input shift register using three control signals, in addition to power and ground:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MISO (Master In, Slave Out) - that is, the data&lt;/li&gt;&#xA;&lt;li&gt;SCK (Serial clock) - this tells the register when to send a new bit&lt;/li&gt;&#xA;&lt;li&gt;LOAD - tells the register to transfer the current bit pattern from the input pins to its holding register.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Shift registers can be daisy-chained, they typically have an &quot;overflow&quot; pin which is used to transfer the oldest incoming bit from one register to the next. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Shift registers are easily coded for by using &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; (Serial Peripheral Interface) because that supports the clocking of bits in or out in hardware.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Shiftin / ShiftOut&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;An alternative to SPI is using software &lt;em&gt;bit-banged&lt;/em&gt; bit transfer such as &lt;a href=&quot;https://www.arduino.cc/en/Reference/ShiftIn&quot; rel=&quot;nofollow&quot;&gt;shiftIn&lt;/a&gt; and &lt;a href=&quot;https://www.arduino.cc/en/Reference/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;shiftOut&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;/questions/tagged/spi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;spi&amp;#39;&quot; rel=&quot;tag&quot;&gt;spi&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:37:37.467" LastActivityDate="2015-08-30T20:37:37.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14459" PostTypeId="4" CreationDate="2015-08-23T04:54:53.863" Score="0" Body="Shift registers are used to convert a serial string of bits into parallel data, or vice-versa." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-27T22:38:18.987" LastActivityDate="2015-08-27T22:38:18.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14460" PostTypeId="5" CreationDate="2015-08-23T05:35:48.093" Score="0" Body="&lt;p&gt;Modern micro-controllers are designed to be able to be used in battery-powered applications where conservation of power can be paramount. By &quot;putting the processor to sleep&quot; substantial power savings can be achieved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also some sleep modes are useful for managing things like processing timing-critical events, or doing ADC conversions without too much digital noise.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sleep modes&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Atmega328P processor, used in the Arduino Uno, Duemilanove, Pro Mini, Nano, and others, for example has the following sleep modes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Idle Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically useful for waking from an interrupt in a controlled way. Useful for highly timing-critical applications like generating video data.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ADC Noise Reduction Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This improves the noise environment for the Analog to Digital Converter (ADC), enabling higher resolution measurements. If the ADC is enabled, a conversion starts automatically when this mode is entered.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Power-save Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same as power-down mode, except if Timer 2 is enabled, it keeps running. Useful for saving some power, but still timing an event with Timer 2.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extended Standby Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mode is identical to Power-save with the exception that&#xA;the Oscillator is kept running. From Extended Standby mode, the device wakes up in six clock cycles.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Standby Mode&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This mode is identical to Power-down with the exception that the&#xA;Oscillator is kept running. From Standby mode, the device wakes up in six clock cycles. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(That's what the datasheet says - the difference between Standby Mode and Extended Standby Mode seems subtle)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Power-down Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this mode, the external Oscillator is stopped, while the external interrupts, the 2-wire Serial Interface address watch, and the Watchdog continue operating (if enabled). Only an External Reset, a Watchdog System Reset, a Watchdog Interrupt, a Brown-out Reset, a 2-wire Serial Interface address match, an external interrupt on INT0 or INT1, or a pin change interrupt can wake up the MCU. This sleep mode basically halts all generated&#xA;clocks, allowing operation of asynchronous modules only.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Waking&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, enabled interrupts will wake the processor. These include things like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pin change interrupts&lt;/li&gt;&#xA;&lt;li&gt;External interrupts&lt;/li&gt;&#xA;&lt;li&gt;Watchdog timer interrupt&lt;/li&gt;&#xA;&lt;li&gt;Brown-out detected&lt;/li&gt;&#xA;&lt;li&gt;Timer interrupts (if timers are running)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;reset&lt;/strong&gt; will always wake the processor.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T20:38:03.880" LastActivityDate="2015-08-30T20:38:03.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14461" PostTypeId="4" CreationDate="2015-08-23T05:35:48.093" Score="0" Body="Sleep refers to a form of power management, where the processor can be instructed to enter various levels of &quot;sleep&quot;. Use this tag for discussions about sleep mode." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-27T22:38:31.257" LastActivityDate="2015-08-27T22:38:31.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14463" PostTypeId="1" CreationDate="2015-08-23T09:58:05.277" Score="0" ViewCount="79" Body="&lt;p&gt;I am working on a Project with&#xA;(a) Arduino Uno Clone (6 PWM Pins i.e, 3,5,6,9,10,11)&#xA;(b) 6 Servos&#xA;(c) MicroSD Reader Module&#xA;(d) Speaker&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As We Know that MicroSD reader modules uses pins 10, 11, 12 of an Arduino board, but &lt;strong&gt;my pin 11 is already being used by a servo motor&lt;/strong&gt;.&#xA;1. Then how can I connect the MicroSD reader in my project ?&#xA;2. Which pin can I use for the speaker in this case ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me plus Provide me some additional information if needed.&lt;/p&gt;&#xA;" OwnerUserId="11772" LastActivityDate="2015-08-23T10:21:25.783" Title="Connecting MicroSd Reader with arduino uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14464" PostTypeId="2" ParentId="14463" CreationDate="2015-08-23T10:21:25.783" Score="3" Body="&lt;p&gt;The best answer is: &lt;em&gt;don't use pin 11 for your servo motor - move it to another pin&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SD card needs SPI.  SPI is pins 10/11/12/13.  You can't change that.  You can much more easily move the servo to a different pin, since there are multiple PWM pins that can support the servo in hardware. If they are all taken then software PWM is easy and there are libraries available to do it for you, so you can use any IO pin you like for that.  Much simpler than re-writing the SD card software to use bit-banged SPI on other pins (which would also be incredibly slow).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-23T10:21:25.783" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14465" PostTypeId="1" AcceptedAnswerId="14466" CreationDate="2015-08-23T11:27:46.697" Score="1" ViewCount="2855" Body="&lt;p&gt;I noticed something today. I am powering the Arduino Nano from a battery and a 5v step up converter. That works just fine and I'm getting a stable 5v output. I have a second cable coming out from the battery which plugs right into analog input A0 set as input so I can measure the battery voltage. However when I disconnect the battery from the usb plug and leave the voltage sensing cable connected to the analog input the power led stays on. I want it to shut down and be disconnected from the power source and have the voltage sensing cable still connected.&#xA;How can I fix this? &lt;/p&gt;&#xA;" OwnerUserId="11116" LastActivityDate="2020-05-17T19:25:10.890" Title="Arduino nano getting powered through analog input?" Tags="|power|analogread|input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14466" PostTypeId="2" ParentId="14465" CreationDate="2015-08-23T11:52:42.073" Score="2" Body="&lt;p&gt;Power is flowing from the analog pin, through the internal clamping diodes, to the Vcc line. Those diodes are however not designed to handle that much current, so don't continue doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either also disconnect the ground wire from the battery, or simply add a resistor between the battery and the analog pin. Something like 10k. That way less than a mA of current will be clamped, and the arduino will stay off.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-23T11:52:42.073" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14467" PostTypeId="2" ParentId="3455" CreationDate="2015-08-23T17:06:39.907" Score="1" Body="&lt;p&gt;I had the same issue, turns out that i had configured the BJT wrong. I had confused the drain for the collector.&lt;/p&gt;&#xA;" OwnerUserId="11956" LastActivityDate="2015-08-23T17:06:39.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14469" PostTypeId="2" ParentId="8661" CreationDate="2015-08-23T20:00:57.273" Score="0" Body="&lt;p&gt;It can be done, however, it is inadvisable. In order to implement this, one must implement the Objective-C runtime, which, though not insurmountable, is very near insurmountable as far as difficulty is concerned. Perhaps someday some brave soul will see fit to grace the world with their custom Arduino Objective-C runtime, but until that day, the rest of us mere mortals have naught to do but wait for the coming of the Objective-C prophet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are any brave souls in the audience who wish to take on this ultimate challenge, then let them. But otherwise, keep the code in C and hold your peace.&lt;/p&gt;&#xA;" OwnerUserId="2899" LastEditorUserId="2899" LastEditDate="2016-09-15T01:43:01.680" LastActivityDate="2016-09-15T01:43:01.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14470" PostTypeId="1" AcceptedAnswerId="14471" CreationDate="2015-08-23T23:43:38.603" Score="0" ViewCount="158" Body="&lt;p&gt;I've got an Arduino with an ATmega328 processor. It can be operated at 3.3V which nets a clock signal frequency of about 12 MHz respectively 16 Mhz at 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got an IMU connected to the Arduino and a AHRS algorithm turning accelerometer, gyroscope and magnetometer data into orientation data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does the higher frequency of 16 MHz actually mean in this context?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will the AHRS be calculated faster so I get a lower latency? Can I poll the sensors more often? I want a deeper understanding of what I'm doing here.&lt;/p&gt;&#xA;" OwnerUserId="10636" LastActivityDate="2015-08-24T00:30:13.857" Title="What does a higher clock signal frequency actually mean for my AHRS?" Tags="|arduino-uno|accelerometer|gyroscope|frequency|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14471" PostTypeId="2" ParentId="14470" CreationDate="2015-08-24T00:30:13.857" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What does the higher frequency of 16 MHz actually mean in this context?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino will run a bit faster (33% faster). Therefore it could calculate things faster. Whether you can poll the sensors more often might depend on the sensor. Limiting factors could be how fast you can communicate with the sensor, how often the sensor takes readings, what you are going to do with the readings, and whether it matters if calculations are a bit slower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a better response I suggest you post a link to the particular sensor, the AHRS algorithm you are using, and describe the application you are using it for.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T00:30:13.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14472" PostTypeId="2" ParentId="10366" CreationDate="2015-08-24T00:55:53.657" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Not only that I got an error, now, I can't bootload the internal clock again !&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need an external clock source, such as a crystal and two capacitors. Once you switch the fuses to the external clock it won't work any more unless you have such a clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&quot; rel=&quot;nofollow&quot;&gt;bootloader uploader&lt;/a&gt; sketch that also provides a clock signal if you need it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T00:55:53.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14473" PostTypeId="2" ParentId="8736" CreationDate="2015-08-24T01:13:34.507" Score="2" Body="&lt;p&gt;I don't think it is particularly practical, unless you make your own RFID scanner. The off-the-shelf ones generally only respond once when a particular card is in range, so you can't even detect if the card is left next the reader, or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as the range is usually quite limited (a few cm) I don't see how it could tell the difference between you being out of the house, or taking a bath.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might work better would be to have an active transmitter (eg. a nrf24l01) in your pocket, which every minute or so sent a &quot;I'm home!&quot; message to a central place. The absence of such a message after 10 minutes could indicate you are out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other approach would be to &quot;check out&quot; with your RFID scanner. I did an &lt;a href=&quot;http://gammon.com.au/forum/?id=12869&quot; rel=&quot;nofollow&quot;&gt;RFID event management system&lt;/a&gt; a little while back. You use a special &quot;admin&quot; card to indicate that a person was leaving an event for a while (a pass-out). You could do that, or have a button by the door, which you press. The &quot;I am leaving&quot; button.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T01:13:34.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14474" PostTypeId="1" AcceptedAnswerId="14476" CreationDate="2015-08-24T01:22:43.523" Score="3" ViewCount="20930" Body="&lt;p&gt;I'm currently working with a digital output gyroscope. Its sensitivity is given as 120 least-significant bit per degree per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While every single component of that unit is easy to understand I don't quite get what it means altogether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can you explain it to me?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="10636" LastActivityDate="2022-02-11T10:55:51.143" Title="What does “LSB per degree per second” mean?" Tags="|programming|digital|gyroscope|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14475" PostTypeId="2" ParentId="10361" CreationDate="2015-08-24T01:29:41.423" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have few SPI ADC which have forced SPI bus down to 1 Mhz. I understand that the shiftout works at 14Khz which is too slow.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can change the SPI speed at any time. Once the device is selected (Slave Select asserted) then reconfigure the SPI bus for high speed operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.setClockDivider(SPI_CLOCK_DIV2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SPI is definitely the fastest way you can communicate with a shift register.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T01:29:41.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14476" PostTypeId="2" ParentId="14474" CreationDate="2015-08-24T01:33:51.907" Score="5" Body="&lt;p&gt;Let us say we have a number, &quot;4025&quot;. The &quot;most significant digit&quot; of the number is the 4 in the thousands position, since it tells us the most about the magnitude of the number (&quot;in the four thousands&quot;). Consequently, the &quot;least significant digit&quot; is the 5 in the units position, since it tells us almost nothing about the magnitude of the number. &quot;Most/least significant bit&quot; is the same, except it applies to binary numbers (which the MCU cares about, of course; we can still use any radix we like to talk about them). So the device's output count can change by up to 120 per degree per second.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-24T01:33:51.907" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14477" PostTypeId="2" ParentId="4734" CreationDate="2015-08-24T01:39:06.230" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;@TMa: seems to work! I totally missed the necessity of referencing the array element. Thanks a lot. But I did not get any compiler warnings without the reference operator. Why isn't this call type-safe?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The PROGMEM word is an &lt;strong&gt;attribute&lt;/strong&gt;, not a &lt;strong&gt;type&lt;/strong&gt;. It might be type-safe but not attribute-safe (if there is such a thing). See &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;Data in Program Space&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T01:39:06.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14478" PostTypeId="2" ParentId="5028" CreationDate="2015-08-24T01:44:27.217" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Any way I can avoid this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think the whole concept of reading &quot;n&quot; bytes is flawed. It will indeed hang if you don't get the number you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not just do what normal serial comms does. Accept bytes as they arrive in an ISR, and put them in a buffer? Then use the line-terminator to know when you have enough to process.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So what can I do if the UART ISR is always called and prevents the rest of the board from functioning?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The UART ISR won't be called if there is no data, so it won't be &quot;always called&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T01:44:27.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14479" PostTypeId="2" ParentId="12881" CreationDate="2015-08-24T06:11:47.387" Score="0" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  if(i==0 &amp;amp;&amp;amp; ++ptrButton-&amp;gt;debounceTics == DBNC_TICS) //swtich went down&#xA;    {&#xA;        ptrButton-&amp;gt;buttonState = SW_DOWN;&#xA;        ptrButton-&amp;gt;debounceTics = 0;&#xA;        return SW_TRANS_UD;       &#xA;    }&#xA;    ptrButton-&amp;gt;debounceTics = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm going to agree with user3877595 but explain why, as his/her answer got a downvote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;DBNC_TICS&lt;/code&gt; has to be &gt; 1, right? Otherwise what is the point?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want to debounce after &quot;x&quot; ticks, and let's assume that the number of ticks is initially zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;DBNC_TICS&lt;/code&gt; is == 1 then this is always true:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;++ptrButton-&amp;gt;debounceTics == DBNC_TICS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Therefore that test is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;DBNC_TICS&lt;/code&gt; &gt; 1 then it will not execute the &quot;if&quot; block and execute this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    ptrButton-&amp;gt;debounceTics = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;ptrButton-&amp;gt;debounceTics&lt;/code&gt; is back to zero, and we are back to square 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore the test will always be false.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No matter how I rearrange this, the increment compare always returns false....&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As stated in the question.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-24T06:11:47.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14480" PostTypeId="1" AcceptedAnswerId="14484" CreationDate="2015-08-24T08:33:31.823" Score="0" ViewCount="10412" Body="&lt;p&gt;I'm currently working on my own arduino library and I'm becoming exasperated with the following problem: I want to store data with the extended database library (&lt;a href=&quot;https://code.google.com/p/arduino-edb/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/arduino-edb/&lt;/a&gt;) on a sd card. I tried to follow and adapt the instructions on &lt;a href=&quot;http://blog.brauingenieur.de/2014/01/20/extended-database-library-using-an-sd-card/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; page and I gave my custom library a property &quot;File dbFile&quot; as well as a property &quot;EDB db&quot;. Additionally I have to pass two function pointers to the constructor of the EDB library. So my custom library got two more properties: a writer and a reader function. My class looks roughly like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class myLib&#xA;{&#xA;   public:&#xA;      myLib();&#xA;      ~myLib();&#xA;      void configWriter( unsigned long address, byte data );&#xA;      byte configReader( unsigned long address );&#xA;      File dbFile;&#xA;      EDB configDB;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...so far so good. But here comes the pain in the ... When I'm trying to instantiate a new EDB object in the constructor of my class by passing two pointers to the member functions I'm constantly getting an error. Here is how I call the constructor of the EDB library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;configDB = new EDB( &amp;amp;myLib::configWriter, &amp;amp;myLib::configReader );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;no matching function for call to 'EDB::EDB()'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...] note: candidates are:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;note: EDB::EDB(void (&lt;em&gt;)(long unsigned int, uint8_t), uint8_t (&lt;/em&gt;)(long&#xA;  unsigned int))&#xA;       EDB(EDB_Write_Handler *, EDB_Read_Handler *);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The prototype of the EDB constructor looks like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;EDB(EDB_Write_Handler *, EDB_Read_Handler *);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;EDB_Write_Handler and EDB_Read_Handler are defined like so:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;typedef void EDB_Write_Handler(unsigned long, const uint8_t);&#xA;  typedef uint8_t EDB_Read_Handler(unsigned long);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I assume that my constructor call doesn't work because the functions that I'm passing are from a foreign class: (myLib::&lt;em&gt;) and not just (&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea how to solve that problem. Does someone of you have any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Andy&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Here is a Minimal, Complete, and Verifiable example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;myLib.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef myLib_h&#xA;#define myLib_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;EDB.h&amp;gt;&#xA;&#xA;#define SD_CS 4&#xA;#define SD_SS 10&#xA;&#xA;class myLib&#xA;{&#xA;  public:&#xA;    myLib();&#xA;    ~myLib();&#xA;    void begin();&#xA;    void configWriter( unsigned long address, byte data );&#xA;    byte configReader( unsigned long address );&#xA;    File dbFile;&#xA;    EDB * configDB;&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;myLib.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;myLib.h&quot;&#xA;&#xA;myLib::myLib( void )&#xA;{}&#xA;&#xA;myLib::~myLib()&#xA;{}&#xA;&#xA;void myLib::begin()&#xA;{&#xA;  // Init SD  &#xA;  pinMode(SS, OUTPUT);&#xA;  SD.begin(SD_CS);&#xA;&#xA;  // Load Config&#xA;  configDB = new EDB( &amp;amp;myLib::configWriter, &amp;amp;myLib::configReader );&#xA;  dbFile = SD.open(&quot;config.db&quot;, FILE_WRITE);&#xA;}&#xA;&#xA;void myLib::configWriter( unsigned long address, byte data )&#xA;{&#xA;  dbFile.seek(address);&#xA;  dbFile.write(data);&#xA;  dbFile.flush();&#xA;}&#xA;&#xA;byte myLib::configReader( unsigned long address )&#xA;{&#xA;  dbFile.seek(address);&#xA;  return dbFile.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;EDB.h&amp;gt;&#xA;#include &quot;myLib.h&quot;&#xA;&#xA;myLib* a;&#xA;&#xA;void setup()&#xA;{&#xA;  a = new myLib();&#xA;  a-&amp;gt;begin();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11966" LastEditorUserId="11966" LastEditDate="2015-08-24T09:36:00.463" LastActivityDate="2015-08-24T10:46:35.853" Title="Pass a member function pointer to a method of a foreign class (EDB Lib)" Tags="|c++|library|class|pointer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14481" PostTypeId="2" ParentId="14480" CreationDate="2015-08-24T08:54:35.103" Score="0" Body="&lt;p&gt;Can you post a  &lt;a href=&quot;https://stackoverflow.com/help/mcve&quot;&gt;Minimal, Complete, and Verifiable example&lt;/a&gt;? We don't care what the functions do, just make up an example that demonstrates the message. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said that, this looks wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class myLib&#xA;{&#xA;   public:&#xA;      myLib();&#xA;      ~myLib();&#xA;      void configWriter( unsigned long address, byte data );&#xA;      byte configReader( unsigned long address );&#xA;      File dbFile;&#xA;      EDB configDB;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Here is how I call the constructor of the EDB library:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; configDB = new EDB( &amp;amp;myLib::configWriter, &amp;amp;myLib::configReader );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK so myLib is a &lt;strong&gt;class&lt;/strong&gt;, not an &lt;strong&gt;instance of a class&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The prototype of the EDB constructor looks like this:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    EDB(EDB_Write_Handler *, EDB_Read_Handler *);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you want an &lt;strong&gt;instance&lt;/strong&gt; of EDB_Write_Handler.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Let's say that EDB needed a dog and a cat. You don't pass &quot;dog&quot; and &quot;cat&quot; you pass &quot;Fido&quot; and &quot;Fluffy&quot;. They are instances of the classes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;configDB = new EDB( &amp;amp;myLib::configWriter, &amp;amp;myLib::configReader );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The constructor for EDB expects two functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EDB(EDB_Write_Handler *, EDB_Read_Handler *);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are declared like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void EDB_Write_Handler(unsigned long, const uint8_t);&#xA;typedef uint8_t EDB_Read_Handler(unsigned long);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are &lt;strong&gt;static&lt;/strong&gt; functions, that is, they cannot be class functions. Why not? Because a class function has an implicit pointer &lt;strong&gt;this&lt;/strong&gt; which points to this instance of the class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you cannot pass a non-static class-function to the EDB constructor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can make the functions configWriter and configReader static, but then they can't access class variables (eg. dbFile) because they belong to an &lt;strong&gt;instance&lt;/strong&gt; of the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried fiddling around with your code, but without a clear understanding of your intentions, I can't get it to compile. Do you mean to &lt;strong&gt;derive&lt;/strong&gt; your class from EDB? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do you even want a class &lt;code&gt;myLib&lt;/code&gt;? Are you planning to have multiple instances of it? If so, why? If not, why make a class?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-08-24T10:20:15.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14482" PostTypeId="2" ParentId="14474" CreationDate="2015-08-24T09:52:42.200" Score="4" Body="&lt;p&gt;With further elaboration on Ignacia's answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A gyroscope itself is generally an analog device in the sense that in reality, it will have a continous output. This output is digitized using some form of Analog to Digital A/D converter where the analog output is converted to a digital number. The output from the gyroscope is a measurement of angular speed, generally millidegrees/sec. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number read by your Arduino from the gyroscope will be a digital version of your current angular speed at the time of measurement. For example, if you're getting an 8bit number back equal to 121, this in binary is equivalent to 01111001, where the '1' furthest to the right is the least significant bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The term &quot;lsb per degree per second&quot; means how many bits change with your angular speed. For example, with a gain of 1 (meaning 1 degree/second = 1 bit), an angular speed of 90 degrees/sec will produce a read value of 90 or 01011010. Therefore, 1 bit changes per degree/second. Increasing the essential &quot;gain&quot; (which will most likely be referred to as &quot;dps&quot; will change how many lsb's change per degree/second.&lt;/p&gt;&#xA;" OwnerUserId="11967" LastEditorUserId="55689" LastEditDate="2019-04-10T14:09:02.553" LastActivityDate="2019-04-10T14:09:02.553" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="14484" PostTypeId="2" ParentId="14480" CreationDate="2015-08-24T10:46:35.853" Score="2" Body="&lt;p&gt;The problem here is a common one with C++.  It basically boils down to how C++ handles member functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You define a member function as, say,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class myLib {&#xA;    void myFunc(int val);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you call the function it's actually not defined as that - it's instead had its definition change to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void myFunc(myLib *this, int val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The addition of the &lt;code&gt;myLib *this&lt;/code&gt; is an &lt;em&gt;implicit&lt;/em&gt; parameter, and it's how C++ keeps track of its object instances when calling different functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a function which expects a parameter of &lt;code&gt;void (*func)(int)&lt;/code&gt; won't accept your method because it's actually &lt;code&gt;void (*func)(myLib *, int)&lt;/code&gt;.  Hence the error you are seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no easy, clean, way around it that I have found as yet, I am afraid.  The closest you can do is to move the reader and writer functions outside of your class and store a global pointer to the actual class, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static myLib *globalLib;&#xA;void globalConfigWriter( unsigned long address, byte data ) {&#xA;    globalLib-&amp;gt;congigWriter(address, data);&#xA;}&#xA;byte globalConfigReader( unsigned long address ) {&#xA;    return globalLib-&amp;gt;configReader(address);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in the constructor for your lib you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myLib::myLib() {&#xA;    globalLib = this;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You then register the global reader and writer functions with the EDB constructor instead of the class member functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does have the rather major down-side that there can only be one instance of your class since there is only one global pointer and only one pair of reader / writer functions.  There are ways of supporting a finite number of instances, but it basically involves having a reader/writer pair for each instance and allocating one to an instance when it's constructed and de-allocating it when its destructed.  Keeping track of them and knowing which object is associated with which function pair is tricky at best...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-24T10:46:35.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14485" PostTypeId="1" AcceptedAnswerId="14486" CreationDate="2015-08-24T11:12:22.980" Score="2" ViewCount="487" Body="&lt;p&gt;I have a problem with Servo library. This is my (very short XD) &quot;code&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Servo.attach(9, 554, 2400);&#xA;}&#xA;&#xA;void loop() {&#xA;  Servo.write(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino:1.6.5 (Windows 7), Board:&quot;Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;&#xA;&#xA;sketch_aug24a.ino: In function 'void setup()':&#xA;sketch_aug24a:4: error: expected unqualified-id before '.' token&#xA;sketch_aug24a.ino: In function 'void loop()':&#xA;sketch_aug24a:8: error: expected unqualified-id before '.' token&#xA;expected unqualified-id before '.' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Like there is no included library. What can I do with it ?&lt;/p&gt;&#xA;" OwnerUserId="11660" LastEditorUserId="42" LastEditDate="2015-08-24T11:17:26.623" LastActivityDate="2015-08-24T11:17:26.623" Title="Arduino Servo.h library returns error in compilation" Tags="|c++|servo|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14486" PostTypeId="2" ParentId="14485" CreationDate="2015-08-24T11:15:12.737" Score="2" Body="&lt;p&gt;&lt;code&gt;Servo&lt;/code&gt; is a class not an object. You have to instantiate it, and then call the functions on the instance. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo sv;&#xA;&#xA;void setup() {&#xA;  sv.attach(9, 554, 2400);&#xA;}&#xA;&#xA;void loop() {&#xA;  sv.write(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Unlike some other libraries, it's done this way so that you can use more than one servo at the same time. You'd make one instance for each servo you want to control.)&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-08-24T11:15:12.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14487" PostTypeId="1" CreationDate="2015-08-24T13:01:14.777" Score="1" ViewCount="5702" Body="&lt;p&gt;I've got an ESP8266 that takes instructions from a web page and sets a series of NeoPixels to flash in different sequences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed that when the Wi-Fi got data and parsed it, my LEDs would &quot;stutter&quot; as the processor ignored them for a moment while processing the incoming instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I added a 2nd ESP8266. This one just handles the LEDs. So the 1st ESP gets the Wi-Fi data and parses it. It then sends an interrupt to the 2nd ESP which breaks out of the LED display loop, checks the interrupt pin for HIGH or LOW and sets the LEDS based on HIGH/LOW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would like to send more data from the Wi-Fi ESP to the LED driving ESP. e.g. Colour data, transition speed, rotation direction etc. All of these settings I can send to the ESP from a web page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I2C (the wire library) would help but all comments seem to say that the ESP8266 cannot act as a slave so I can't send to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it appears I'm left with Serial comms (the interrupt is over by the time comm start because I realize Serial does not work in an interrupt).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Am I right that I2C will not work?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I am wrong does anyone have a working end to end example?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I am right is there an approved way to do ESP to ESP serial comms?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11471" LastEditorUserId="6936" LastEditDate="2016-02-17T06:43:24.677" LastActivityDate="2016-05-18T20:02:35.837" Title="ESP8266 as I2C client" Tags="|i2c|esp8266|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14488" PostTypeId="2" ParentId="14487" CreationDate="2015-08-24T13:57:16.077" Score="1" Body="&lt;p&gt;I assume that you are using the Arduino core for the ESP8266 (&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Am I right that ic2 will not work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am not certain, but I get the same impression as you.  It seems that the Expressif SDK only supports master mode.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I am right is there an approved way to do ESP to ESP serial comms.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no &quot;approved way&quot;, but there are many ways you can do it.  A direct serial link will give you a simple pipe of data - what you put in at one end comes out the other.  It's up to you to decide how you format and interpret that data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ICSC library may help you with that - I use it to connect an ESP8266 to an BeagleBone Black through serial: &lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/ICSC&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-24T13:57:16.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14489" PostTypeId="1" AcceptedAnswerId="14490" CreationDate="2015-08-24T14:31:30.077" Score="5" ViewCount="13394" Body="&lt;p&gt;I got this question from my teacher the other day and I can't figure it out:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you have two sensors from two different outputs but want them to go into one input, what do you need, and how can you read the input?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Xb7N2.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xb7N2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, the project includes an Arduino Uno with two ultrasonic sensors.&lt;/p&gt;&#xA;" OwnerUserId="11974" LastActivityDate="2017-07-08T07:07:43.103" Title="Two sensors on one input" Tags="|arduino-uno|sensors|" AnswerCount="8" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14490" PostTypeId="2" ParentId="14489" CreationDate="2015-08-24T14:56:09.607" Score="3" Body="&lt;p&gt;There are two basic solutions to your problem, an active one and a passive one, and which is best (or will even work) depends on the rest of your setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The active solution requires a device called a &lt;em&gt;multiplexer&lt;/em&gt;.  This is basically a switch and it selects one of its inputs to route through to its output, so it can be used to connect your input pin to the output of one of the sensors.  It requires an extra IO pin, though, so is pretty pointless as you could just use that IO pin as an input from the second sensor.  It does mean, though, that both sensors can be active at once and you just select one to read the output from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The passive solution is called &lt;em&gt;open drain&lt;/em&gt; or &lt;em&gt;open collector&lt;/em&gt; (if you are using TTL not CMOS terminology).  This means you convert each of the outputs of the sensors into a switch using a transistor (NPN BJT or N-Channel MOSFET) to connect your input pin to ground.  When then transistors are off the input pin is pulled up through a pullup resistor (could be internal or external to the IO pin).  When one sensor's output activates it turns on the transistor which then pulls the input pin low.  This means that you can only have one sensor active at a time, so they have to be triggered by separate output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z7pDQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z7pDQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Drain is how things like I2C support multiple devices on the same bus without any voltage conflicts.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-24T14:56:09.607" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="14491" PostTypeId="1" CreationDate="2015-08-24T15:21:11.160" Score="1" ViewCount="1411" Body="&lt;p&gt;Just looking for a second opinion on my circuit below. Wired up everything works great, but last night as i was unplugging the FTDI programmer something seemed to have happend, and the mini was bricked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if it has to do with my wiring below, or if it was me unplugging the cable in a haphazard manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm attempting to do is run my arduino from 12v wall supply, but also drive an LED strip with it. I'm just unsure if this is the best way to go about it, any advice is welcome. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&#xA;Justin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4VmOx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4VmOx.png&quot; alt=&quot;example layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11460" LastEditorUserId="11460" LastEditDate="2015-08-24T15:34:35.900" LastActivityDate="2015-08-25T01:50:39.663" Title="Powering Arduino Pro Mini + Driving LED Strip" Tags="|led|mosfet|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14492" PostTypeId="2" ParentId="14491" CreationDate="2015-08-24T17:49:35.317" Score="1" Body="&lt;p&gt;According to the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/using-the-arduino-pro-mini-33v&quot; rel=&quot;nofollow&quot;&gt;schematics&lt;/a&gt;, the Pro Mini uses the &lt;a href=&quot;http://www.micrel.com/_PDF/mic5205.pdf&quot; rel=&quot;nofollow&quot;&gt;MIC5205&lt;/a&gt;, which is a linear regulator.&#xA;Using it directly with 12V is not a very good idea, in terms of power efficiency, as it will dissipate 35mW vs 25mW provided to the ATMega board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this perspective, I'd recommend a &lt;a href=&quot;http://www.ebay.com/itm/LM2596S-ADJ-Power-Module-DC-DC-Buck-Regulator-3A-Adjustable-5V-12V-24V-/171819436954?hash=item28013c8b9a&quot; rel=&quot;nofollow&quot;&gt;step-down converter&lt;/a&gt; for powering the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it will not cause any damage, at least at room temperature, as the power dissipation is well within operating margins, see calculation at page 8 of the MIC datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; detailed pros and cons, power wise.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-08-25T01:50:39.663" LastActivityDate="2015-08-25T01:50:39.663" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14493" PostTypeId="1" AcceptedAnswerId="14500" CreationDate="2015-08-24T18:40:40.737" Score="1" ViewCount="1441" Body="&lt;p&gt;I am making a new library that will utilize PinChangeInt's library. &#xA;My intention is to further simplify repetitive code by creating a library. (This is to allow for multiple PPM channels without rewriting a bunch of code for each channel i decide to add.)&#xA;Since i understand OOP i knew that i could go the route of make my own library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem i'm having right now, is that the library is returning an undefined reference. The IDE i'm using is UECIDE with QTcreator on the side to help me with my syntax. The compiler is avr-gcc. The chip is an Arduino Uno. The problem i'm recieving is &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:...\RCRoomba_TestPulseV2.cpp.o: In function '__static_initialization_and_destruction_0':&#xA;  &lt;br&gt;C:...\RCRoomba_TestPulseV2.ino:5: undefined reference to 'PPMintIn::PPMintIn(int)'&#xA;  &lt;br&gt;C:...\RCRoomba_TestPulseV2.cpp.o: In function 'setup':&#xA;  &lt;br&gt;C:...\RCRoomba_TestPulseV2.ino:9: undefined reference to 'PPMintIn::begin()'&#xA;  &lt;br&gt;Failed linking sketch&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried to define the variables in my h and cpp files but it doesn't seem to be fixing the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the .ino code.&#xA;&lt;br&gt;for some reason UECIDE can't see the Pinchange and PPMint libraries&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;arduino.h&quot;&#xA;#include &quot;C:\Users\User\Documents\UECIDE\libraries\PinChangeInt\PinChangeInt.h&quot;&#xA;#include &quot;C:\Users\User\Documents\UECIDE\libraries\PPMintIn\PPMintIn.h&quot;&#xA;&#xA;PPMintIn CH1(A0);&#xA;&#xA;void setup(){&#xA;    Serial.begin(115200);&#xA;    CH1.begin();&#xA;}&#xA;&#xA;void loop(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the .cpp code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;arduino.h&quot;&#xA;#include &quot;ppmintin.h&quot;&#xA;#include &quot;PinChangeInt.h&quot;&#xA;//defined these&#xA;volatile int pwm_value = 0; &#xA;volatile int prev_time = 0;&#xA;uint8_t latest_interrupted_pin = 0;&#xA;&#xA;PPMintIn::PPMintIn(int pin){&#xA;    pinMode(pin, INPUT);\&#xA;    digitalWrite(pin, HIGH);&#xA;    _pin = pin;&#xA;}&#xA;&#xA;void PPMintIn::rising(){&#xA;    PPMintIn::latest_interrupted_pin = PCintPort::arduinoPin;&#xA;    PCintPort::attachInterrupt(latest_interrupted_pin, &amp;amp;rising, RISING);&#xA;    PPMintIn::pwm_value = micros()-PPMintIn::prev_time;&#xA;}&#xA;&#xA;void PPMintIn::falling(){&#xA;    PPMintIn::latest_interrupted_pin=PCintPort::arduinoPin;&#xA;    PCintPort::attachInterrupt(latest_interrupted_pin, &amp;amp;rising, RISING);&#xA;    PPMintIn::pwm_value = micros()-PPMintIn::prev_time;&#xA;}&#xA;&#xA;void PPMintIn::begin(){&#xA;    PCintPort::attachInterrupt(_pin, &amp;amp;rising, RISING);&#xA;}&#xA;&#xA;void PPMintIn::getSignal(){&#xA;    return(PPMintIn::pwm_value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the .h code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef PPMINTIN_H&#xA;#define PPMINTIN_H&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;  #include &quot;Arduino.h&quot;&#xA;  #else&#xA;  #include &quot;WProgram.h&quot;&#xA;#endif&#xA;#include &quot;PinChangeInt.h&quot;&#xA;&#xA;class PPMintIn{&#xA;public:&#xA;    PPMintIn(int pin);&#xA;    void begin();&#xA;    void getSignal();&#xA;    int _pin;&#xA;    volatile int pwm_value;&#xA;    volatile int prev_time;&#xA;    uint8_t latest_interrupted_pin;&#xA;private:&#xA;    void rising();&#xA;    void falling();&#xA;};&#xA;&#xA;#endif // PPMINTIN_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the full thing in github in case I didn't supply it here. &#xA;&lt;a href=&quot;https://github.com/tisaconundrum2/PPMintIn&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tisaconundrum2/PPMintIn&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11978" LastEditorUserId="37523" LastEditDate="2019-12-03T21:00:49.620" LastActivityDate="2019-12-03T21:00:49.620" Title="undefined reference to `PPMintIn::PPMintIn(int)'" Tags="|arduino-uno|library|compile|avr-gcc|" AnswerCount="1" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="14494" PostTypeId="1" CreationDate="2015-08-24T19:10:20.983" Score="1" ViewCount="71" Body="&lt;p&gt;I'm trying to save SRAM on my Arduino pro mini by going through some libraries. I've noticed that to use my Arduino as a ROS node the library stores the topic name and message type as constants. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Publisher&#xA;{&#xA;public:&#xA;  Publisher( const char * topic_name, Msg * msg, int    endpoint=rosserial_msgs::TopicInfo::ID_PUBLISHER) :&#xA;    topic_(topic_name), &#xA;    msg_(msg),&#xA;    endpoint_(endpoint) {};&#xA;&#xA;  int publish( const Msg * msg ) { return nh_-&amp;gt;publish(id_, msg); };&#xA;  int getEndpointType(){ return endpoint_; }&#xA;&#xA;  const char * topic_;&#xA;  Msg *msg_;&#xA;  // id_ and no_ are set by NodeHandle when we advertise &#xA;  int id_;&#xA;  NodeHandleBase_* nh_;&#xA;&#xA;private:&#xA;  int endpoint_;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I store the constants to PROGMEM? Thank you&lt;/p&gt;&#xA;" OwnerUserId="11979" LastActivityDate="2015-09-26T12:49:28.730" Title="How to change the topic_name string to PROGMEM?" Tags="|arduino-uno|programming|arduino-ide|library|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14495" PostTypeId="2" ParentId="14494" CreationDate="2015-08-24T19:35:18.197" Score="1" Body="&lt;p&gt;My take on this is that you cannot save more memory on &lt;code&gt;topic-name&lt;/code&gt; nor &lt;code&gt;msg&lt;/code&gt; parameters. Their memory usage is already optimized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;const&lt;/code&gt; keyword in the constructor declaration &lt;code&gt;Publisher( const char * topic_name, Msg * msg, ...&lt;/code&gt; just tells the compiler that the parameter won't be changed throughout their life cycle. But their values will be defined at run-time during object creation when you issue something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Publisher pb = new Publisher(&quot;topic&quot;, &quot;message&quot;, ...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, they cannot be put into flash memory if they are not there already. But if the strings you pass on to the constructor are already in flash, then you're already saving those bits of RAM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;Finally, I just wanted to warn you not to modify 3rd party lib code extensively without comprehensive testing, like you are trying to do. You'll start to get strange behavior in your code. The slightest and simplest of changes may have unforeseen consequences.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2015-08-27T12:01:00.413" LastActivityDate="2015-08-27T12:01:00.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14496" PostTypeId="1" CreationDate="2015-08-24T19:44:56.593" Score="0" ViewCount="191" Body="&lt;p&gt;How do I figure out how to connect to my arduino using ethernet shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It prints the IP in the serial monitor, but it doesn't work, and adding the port doesn't make a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The client example works, so it's not broken or anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;code&gt;Arduino 1.6.5&lt;/code&gt; IDE on a &lt;code&gt;Mega 2560&lt;/code&gt;. I'm trying to run the &lt;code&gt;Examples/Ethernet/WebServer&lt;/code&gt; example.&lt;/p&gt;&#xA;" OwnerUserId="11981" LastEditorUserId="11981" LastEditDate="2015-08-24T22:34:41.407" LastActivityDate="2016-02-22T05:14:03.080" Title="Connecting to Arduino Ethernet Shield" Tags="|shields|ethernet|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14497" PostTypeId="2" ParentId="14489" CreationDate="2015-08-24T21:24:39.057" Score="1" Body="&lt;p&gt;This solution only actually uses one pin, but only works with simple things like push buttons (which are either open, or closed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect a (different) resistor in series (end-to-end) with each switch. Connect the loose end of each resistor together to +5V. Connect the loose end of those two switches together, then via another resistor to ground. Where the two switches meet, connect them to an analog pin on your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you might use a 20k resistor with button A, and a 10k resistor with button B, and a 10k resistor connected to ground. They should be pretty close to the same value, and at least 1k each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the ReadAnalogVoltage sketch to measure the voltage with different combinations of button presses (no button pressed, A, B, A+B), then, in your final sketch, you can compare the value read with the values in this table - pick the closest one, because actual readings may vary slightly. For the resistors above, you should get about: (no button = 0v; A=1.7v, B=2.5v, both 3v). Sort these numerically (which in this case they already are), and work out the values exactly between each pair (up to 0.85 is closest to 0=&gt; no button; else up to 2.1=&gt; button A; else up to 2.75 is closest to B; otherwise, both are pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit described looks like this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LjsPo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LjsPo.png&quot; alt=&quot;Switch circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wire leading off to the right goes to the analog pin on the Arduino. Switch A is on the left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The results can be used either in a table, with a loop, or in an if/else if statement (I used this technique on a 12-key keypad, so the list was a lot longer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read up about voltage dividers &lt;a href=&quot;https://learn.sparkfun.com/tutorials/voltage-dividers&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/voltage-dividers&lt;/a&gt; and, for both buttons being pressed at the same time, resistors in parallel &lt;a href=&quot;https://learn.sparkfun.com/tutorials/series-and-parallel-circuits&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/series-and-parallel-circuits&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-24T21:24:39.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14498" PostTypeId="2" ParentId="9629" CreationDate="2015-08-24T21:33:38.443" Score="1" Body="&#xA;&#xA;&lt;p&gt;Since I wrote that example, I'll try to answer this. First I tested with the code from &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;my page about SPI&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI Master&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is the master:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup (void)&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  digitalWrite(SS, HIGH);  // ensure SS stays high for now&#xA;&#xA;  // Put SCK, MOSI, SS pins into output mode&#xA;  // also put SCK, MOSI into LOW state, and SS into HIGH state.&#xA;  // Then put SPI hardware into Master mode and turn SPI on&#xA;  SPI.begin ();&#xA;&#xA;  // Slow down the master a bit&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV8);&#xA;&#xA;}  // end of setup&#xA;&#xA;byte transferAndWait (const byte what)&#xA;{&#xA;  byte a = SPI.transfer (what);&#xA;  delayMicroseconds (20);&#xA;  return a;&#xA;} // end of transferAndWait&#xA;&#xA;void loop (void)&#xA;{&#xA;&#xA;  byte a, b, c, d;&#xA;&#xA;  // enable Slave Select&#xA;  digitalWrite(SS, LOW);    &#xA;&#xA;  transferAndWait ('a');  // add command&#xA;  transferAndWait (10);&#xA;  a = transferAndWait (17);&#xA;  b = transferAndWait (33);&#xA;  c = transferAndWait (42);&#xA;  d = transferAndWait (0);&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(SS, HIGH);&#xA;&#xA;  Serial.println (&quot;Adding results:&quot;);&#xA;  Serial.println (a, DEC);&#xA;  Serial.println (b, DEC);&#xA;  Serial.println (c, DEC);&#xA;  Serial.println (d, DEC);&#xA;&#xA;  // enable Slave Select&#xA;  digitalWrite(SS, LOW);   &#xA;&#xA;  transferAndWait ('s');  // subtract command&#xA;  transferAndWait (10);&#xA;  a = transferAndWait (17);&#xA;  b = transferAndWait (33);&#xA;  c = transferAndWait (42);&#xA;  d = transferAndWait (0);&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(SS, HIGH);&#xA;&#xA;  Serial.println (&quot;Subtracting results:&quot;);&#xA;  Serial.println (a, DEC);&#xA;  Serial.println (b, DEC);&#xA;  Serial.println (c, DEC);&#xA;  Serial.println (d, DEC);&#xA;&#xA;  delay (1000);  // 1 second delay &#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SPI Slave&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;And this is the slave:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// what to do with incoming data&#xA;volatile byte command = 0;&#xA;&#xA;void setup (void)&#xA;{&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode(MISO, OUTPUT);&#xA;&#xA;  // turn on SPI in slave mode&#xA;  SPCR |= _BV(SPE);&#xA;&#xA;  // turn on interrupts&#xA;  SPCR |= _BV(SPIE);&#xA;&#xA;}  // end of setup&#xA;&#xA;&#xA;// SPI interrupt routine&#xA;ISR (SPI_STC_vect)&#xA;{&#xA;  byte c = SPDR;&#xA;&#xA;  switch (command)&#xA;  {&#xA;  // no command? then this is the command&#xA;  case 0:&#xA;    command = c;&#xA;    SPDR = 0;&#xA;    break;&#xA;&#xA;  // add to incoming byte, return result&#xA;  case 'a':&#xA;    SPDR = c + 15;  // add 15&#xA;    break;&#xA;&#xA;  // subtract from incoming byte, return result&#xA;  case 's':&#xA;    SPDR = c - 8;  // subtract 8&#xA;    break;&#xA;&#xA;  } // end of switch&#xA;&#xA;}  // end of interrupt service routine (ISR) SPI_STC_vect&#xA;&#xA;void loop (void)&#xA;{&#xA;&#xA;  // if SPI not active, clear current command&#xA;  if (digitalRead (SS) == HIGH)&#xA;    command = 0;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Test results&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Testing gave the expected results:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Adding results:&#xA;25&#xA;32&#xA;48&#xA;57&#xA;Subtracting results:&#xA;2&#xA;9&#xA;25&#xA;34&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;So, what is different in your code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your slave ISR:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR(SPI_STC_vect)&#xA; {&#xA;   c = SPDR;&#xA;  switch(c)&#xA;    {&#xA;      case 0:&#xA;      SPDR = 0;&#xA;      break;&#xA;&#xA;     case 'a':&#xA;     SPDR = c + 15;&#xA;     break;&#xA;   }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't quite the same, is it? In my code you get the command in one session (one interrupt) and what to use it for in another one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence I had this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  byte c = SPDR;&#xA;&#xA;  switch (command)&#xA;  {&#xA;  // no command? then this is the command&#xA;  case 0:&#xA;    command = c;&#xA;    SPDR = 0;&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sending a &quot;command&quot; of zero clears the current command. So the sequence being sent is like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;0    &amp;lt;-- start a new command&#xA;command  (ie. 'a' or 's')&#xA;22   &amp;lt;-- what to add to&#xA;33   &amp;lt;-- what to add to&#xA;44&#xA;55&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps confusingly, I didn't send in that order, because I knew that the command would be zero initially&lt;sup&gt;(1)&lt;/sup&gt;, so I actually sent:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;command  (ie. 'a' or 's')&#xA;22   &amp;lt;-- what to add to&#xA;33   &amp;lt;-- what to add to&#xA;44&#xA;55&#xA;0    &amp;lt;-- start a new command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There would be other ways of achieving this, but the fact is you changed the way the slave interpreted the incoming data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I knew it would be zero because the slave sets the command to zero in the main loop if SS is not asserted.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-24T21:38:49.040" LastActivityDate="2015-08-24T21:38:49.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14499" PostTypeId="1" AcceptedAnswerId="14512" CreationDate="2015-08-24T21:52:43.960" Score="0" ViewCount="1947" Body="&lt;p&gt;So I have this project where the component &quot;buzzer&quot; is implementet. I was wondering if the voltage is changing along the change of frequency given to the buzzer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the project just says &quot;buzzer&quot; - not any more details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Project: &lt;a href=&quot;http://www.instructables.com/id/Arduino-Distance-Detector-with-a-Buzzer-and-LEDs/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-Distance-Detector-with-a-Buzzer-and-LEDs/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11974" LastEditorUserId="11974" LastEditDate="2015-08-24T22:19:38.030" LastActivityDate="2015-08-25T10:20:59.557" Title="Buzzer - Does the voltage change with the frequency?" Tags="|frequency|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14500" PostTypeId="2" ParentId="14493" CreationDate="2015-08-24T22:07:03.373" Score="0" Body="&#xA;&#xA;&lt;p&gt;As both Majenko and I tried to explain in &lt;a href=&quot;https://arduino.stackexchange.com/questions/14480/pass-a-member-function-pointer-to-a-method-of-a-foreign-class-edb-lib&quot;&gt;Pass a member function pointer to a method of a foreign class (EDB Lib)&lt;/a&gt; you can't pass a class member function where a static function is expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your error is on:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PCintPort::attachInterrupt(latest_interrupted_pin, &amp;amp;rising, RISING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;/home/nick/sketchbook/libraries/PPMintIn/ppmintin.cpp: In member function ‘void PPMintIn::rising()’:&#xA;/home/nick/sketchbook/libraries/PPMintIn/ppmintin.cpp:22: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say ‘&amp;amp;PPMintIn::rising’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;PCintPort::attachInterrupt expects a &lt;code&gt;PCIntvoidFuncPtr&lt;/code&gt; variable:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int8_t PCintPort::attachInterrupt(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, int mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;typedef void (*PCIntvoidFuncPtr)(void);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is a static function (not a class function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you have it as a class function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class PPMintIn{&#xA;public:&#xA;    PPMintIn(int pin);&#xA;    void begin();&#xA;    void getSignal();&#xA;    int _pin;&#xA;    volatile int pwm_value;&#xA;    volatile int prev_time;&#xA;    uint8_t latest_interrupted_pin;&#xA;private:&#xA;    void rising();&#xA;    void falling();&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can make &lt;code&gt;rising&lt;/code&gt; and &lt;code&gt;falling&lt;/code&gt; static but now they can't access any of the class variables (eg. pwm_value, prev_time, latest_interrupted_pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole thing needs a redesign. You could try making PPMintIn a namespace rather than a class.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding one of the comments:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sm1q3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sm1q3.png&quot; alt=&quot;Error message&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless your class implements &lt;code&gt;operator()&lt;/code&gt; this line doesn't make sense:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;chan1(15);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please copy and paste error messages into the post, don't make people go to Imgur to find a screenshot of some text.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-08-24T22:12:58.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14501" PostTypeId="2" ParentId="5155" CreationDate="2015-08-24T22:10:51.660" Score="2" Body="&lt;p&gt;I am using KiCad. It's a full EDA/PCB design suite that is &lt;strong&gt;free&lt;/strong&gt;. It's a really nice multi-platform package. It doesn't do circuit simulation(to my knowledge). It's relatively easy to learn via some youtube tutorials and there's a healthy development community and discussion board as well. It outputs industry standard gerber files so you can quote out your designs to pcb manufacturers.&lt;/p&gt;&#xA;&lt;p&gt;link:&#xA;&lt;a href=&quot;http://www.kicad.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.kicad.org/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11075" LastEditorUserId="-1" LastEditDate="2021-10-20T16:59:06.457" LastActivityDate="2021-10-20T16:59:06.457" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14503" PostTypeId="2" ParentId="5012" CreationDate="2015-08-25T04:34:44.163" Score="1" Body="&lt;p&gt;I got a fresh 9 V out of a packet and measured it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 9.58 volts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now with a load of 500 mA (which you quite likely would get with a robot) it dropped to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 7.4 volts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With a load of 750 mA the voltage dropped to 6.6 V which is below what you are supposed to supply via the power jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that was with a fresh battery, testing for a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those 9 V batteries are just not designed to drive motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest a somewhat heavier-duty battery, like 5 x AA batteries, at least for the robot part.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-25T04:34:44.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14504" PostTypeId="2" ParentId="6490" CreationDate="2015-08-25T04:44:12.873" Score="1" Body="&#xA;&#xA;&lt;p&gt;You are using the USB interface, right? So you just use Serial to send data back. For example, this would send the distance every second:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long lastSent;&#xA;void loop() {&#xA;  distance = Dist.getDistanceCentimeter();&#xA;  if (millis () - lastSent &amp;gt;= 1000)  // every second&#xA;  {&#xA;    lastSent = millis ();&#xA;    Serial.println (distance);&#xA;  }&#xA;&#xA;  if (distance &amp;lt;= 5 &amp;amp; distance &amp;gt; 1)&#xA;  {&#xA;    if (Serial.available()) {&#xA;      command = Serial.read();&#xA;      switch (command) {&#xA;        case 'a':&#xA;          forward();&#xA;          servoX.write(90);&#xA;          command = 0;&#xA;          break;&#xA;      }  // end of switch&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-25T04:44:12.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14506" PostTypeId="1" AcceptedAnswerId="14513" CreationDate="2015-08-25T06:53:29.267" Score="3" ViewCount="6221" Body="&lt;p&gt;I am onto a simple project with Arduino, SR04 and a buzzer for &quot;Car reverse parking assistance&quot;. The aim here is to make a buzz when the car gets too close to the objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking what if it's raining when a person is driving (assuming I somehow achieved to water proof the sensor) - will the buzzer make continuous sounds?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any alternative solution for ultrasonic sensors?&lt;/p&gt;&#xA;" OwnerUserId="11916" LastEditorUserId="10794" LastEditDate="2015-08-25T22:14:49.827" LastActivityDate="2020-11-09T04:16:56.323" Title="UltraSonic sensor in rain?" Tags="|arduino-uno|sensors|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14507" PostTypeId="1" AcceptedAnswerId="14520" CreationDate="2015-08-25T07:13:21.210" Score="2" ViewCount="4475" Body="&lt;p&gt;I want to enable pin 13 on my SAM3X8E using direct port manipulation. On this chip the pin is bit 27 in port B, so I used &lt;code&gt;PIOB-&amp;gt;PIO_PER = 1&amp;lt;&amp;lt;27;&lt;/code&gt; to enable this pin, but it doesn't work. This pin keeps at 3.08V, the default value of non-initialized pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my complete code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;asf.h&amp;gt;&#xA;&#xA;int main (void) {&#xA;  // Insert system clock initialization code here (sysclk_init()).&#xA;  board_init();&#xA;  sysclk_init();&#xA;  delay_init(sysclk_get_cpu_hz());&#xA;  PIOB-&amp;gt;PIO_PER = 1&amp;lt;&amp;lt;27;&#xA;  PIOB-&amp;gt;PIO_OER = 1&amp;lt;&amp;lt;27;&#xA;  while(1) {&#xA;    REG_PIOB_ODSR = 1&amp;lt;&amp;lt;27;&#xA;    delay_ms(1000);&#xA;    REG_PIOB_ODSR = 0&amp;lt;&amp;lt;27;&#xA;    delay_ms(1000);     &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me how I can get this to work?&lt;/p&gt;&#xA;" OwnerUserId="11980" LastEditorUserId="4628" LastEditDate="2017-03-07T11:56:02.867" LastActivityDate="2017-03-07T11:56:02.867" Title="Enabling pins of Arduino Due with direct port manipulation" Tags="|arduino-due|port-mapping|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14508" PostTypeId="2" ParentId="14489" CreationDate="2015-08-25T07:35:22.723" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xhtgM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xhtgM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the above logic use a 555 timer with  C1: 10uF, R2: 300k and R1: 30k for 1.1 sec switching time,now for approx every one second data from USS1 goes to SIN(Arduino IN) when the timer OUT is high and  similarly when timer OUT is LOW signal from USS2 goes to SIN(Arduino),,,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you will not be able to know from which sensor is the output coming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to know from which sensor the output is coming you can just add one INVERTER to one of the branch so so both the sensors will give different states i.e one will return HIGH and other will return LOW&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hope this helps&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited:Please note 555 timer design part is not complete ,,i am just giving an idea :)&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2015-08-25T07:35:22.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14509" PostTypeId="1" AcceptedAnswerId="14511" CreationDate="2015-08-25T09:07:15.210" Score="0" ViewCount="125" Body="&lt;p&gt;I have written a codebender project which returns this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Oops! Looks like there was a serious issue with your project. &#xA;&#xA;If you are not sure what could be wrong please contact us&#xA;&#xA;/mnt/tmp/compiler.amxHJ9/files/Many Games.o: In function `gamesMaster::gamesMaster()':&#xA;Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xa): undefined reference to `vtable for gamesMaster'&#xA;Many Games.cpp:(.text._ZN11gamesMasterC2Ev+0xc): undefined reference to `vtable for gamesMaster' &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does it mean by &lt;code&gt;vtable&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code uses basic classes and inheritance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is designed to select and play the game of your choice.  I have only programmed the basic structure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Class &lt;code&gt;games&lt;/code&gt; contains a ref to the class &lt;code&gt;gamesMaster&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Class &lt;code&gt;gamesMaster&lt;/code&gt; contains a ref to &lt;code&gt;simpleTimer&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Classes &lt;code&gt;playHiLow&lt;/code&gt; and &lt;code&gt;playSimon&lt;/code&gt; are children of &lt;code&gt;gamesMaster&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Class &lt;code&gt;games&lt;/code&gt; handles and input and outputs, &lt;code&gt;win&lt;/code&gt; and &lt;code&gt;lose&lt;/code&gt; control and keeps track of lives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Class &lt;code&gt;gamesMaster&lt;/code&gt; handles the &lt;code&gt;simpleTimer&lt;/code&gt;, displays a new round, checks for the correct answer, and checks if game has finished successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;main()&lt;/code&gt; function runs a routine in the &lt;code&gt;games&lt;/code&gt; class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is listed here: &lt;a href=&quot;https://codebender.cc/sketch:144869&quot; rel=&quot;nofollow&quot;&gt;https://codebender.cc/sketch:144869&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class simpleTimer&#xA;{&#xA;private:&#xA;    unsigned long _previousMillis;&#xA;    unsigned long _interval;&#xA;&#xA;public:&#xA;    simpleTimer()&#xA;    {&#xA;&#xA;    }&#xA;    void start(float mins)&#xA;    {&#xA;        _interval = (unsigned long) (mins * 60 * 1000);&#xA;        _previousMillis = millis();&#xA;    }&#xA;    bool stillRunning()&#xA;    {&#xA;        return (millis() - _previousMillis &amp;lt; _interval);&#xA;    }&#xA;};&#xA;&#xA;class gamesMaster&#xA;{&#xA;public:&#xA;    unsigned short lives;&#xA;    gamesMaster()&#xA;    {&#xA;        timeOutTimer = new simpleTimer();&#xA;        gameTimer = new simpleTimer();&#xA;        gameTimer-&amp;gt;start(1.5);&#xA;        lives = 5;&#xA;    }&#xA;    void right()&#xA;    {&#xA;        Serial.println(&quot;Correct&quot;);&#xA;    }&#xA;    void wrong()&#xA;    {&#xA;        Serial.println(&quot;Wrong&quot;);&#xA;    }&#xA;    void winGame()&#xA;    {&#xA;        Serial.println(&quot;**********&quot;);&#xA;        Serial.println(&quot;* WINNER *&quot;);&#xA;        Serial.println(&quot;**********&quot;);&#xA;    }&#xA;    void loseGame()&#xA;    {&#xA;        Serial.println(&quot;\\ /          \\ /&quot;);&#xA;        Serial.println(&quot; X    LOST    X&quot;);&#xA;        Serial.println(&quot;/ \\          / \\&quot;);&#xA;    }&#xA;    void startTimeOut(float mins)&#xA;    {&#xA;        timeOutTimer-&amp;gt;start(mins);&#xA;    }&#xA;    bool notTimedOut()&#xA;    {&#xA;        return timeOutTimer-&amp;gt;stillRunning();&#xA;    }&#xA;    bool gameTimerOver()&#xA;    {&#xA;        return !gameTimer-&amp;gt;stillRunning();&#xA;    }&#xA;    simpleTimer *timeOutTimer;&#xA;    simpleTimer *gameTimer;&#xA;&#xA;    virtual void setupForNewRound(void);&#xA;    virtual bool checkAnswer(unsigned short);&#xA;    virtual bool reachedEnd(void);&#xA;};&#xA;&#xA;class gameHiLow: public gamesMaster&#xA;{&#xA;public:&#xA;    gameHiLow() : gamesMaster() {}&#xA;    void setupForNewRound()&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(HiLow) New round&quot;);&#xA;    }&#xA;    bool checkAnswer(unsigned short answer)&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(HiLow) Correct Answer&quot;);&#xA;        return HIGH;&#xA;    }&#xA;    bool reachedEnd()&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(HiLow) End of game&quot;);&#xA;        return HIGH;&#xA;    }&#xA;};&#xA;&#xA;class gameSimon: public gamesMaster&#xA;{&#xA;public:&#xA;    gameSimon() : gamesMaster() {}&#xA;    void setupForNewRound()&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(Simon) New round&quot;);&#xA;    }&#xA;    bool checkAnswer(unsigned short answer)&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(Simon) Correct Answer&quot;);&#xA;        return HIGH;&#xA;    }&#xA;    bool reachedEnd()&#xA;    {&#xA;        Serial.println(&quot;  -&amp;gt;(Simon) End of game&quot;);&#xA;        return HIGH;&#xA;    }&#xA;};&#xA;&#xA;&#xA;class games&#xA;{&#xA;private:&#xA;    unsigned short _gameToPlay;&#xA;    unsigned short _levelToPlay;&#xA;    gamesMaster *myGame;&#xA;    unsigned short _getAnswer()&#xA;    {&#xA;        if (Serial.available() &amp;gt; 0)&#xA;        {&#xA;            int inByte = Serial.read();&#xA;            Serial.println(&quot;  -&amp;gt;(games) Decode Answer&quot;);&#xA;&#xA;            switch (inByte)&#xA;            {&#xA;                case '&amp;lt;':&#xA;                    return 1;&#xA;                    break;&#xA;                case '&amp;gt;':&#xA;                    return 2;&#xA;                    break;&#xA;            }&#xA;&#xA;        }&#xA;        return 0;&#xA;&#xA;    }&#xA;    bool _respond()&#xA;    {&#xA;        unsigned short answer;&#xA;        while(myGame-&amp;gt;notTimedOut())&#xA;        {&#xA;            if((answer = _getAnswer()) != 0)&#xA;            {&#xA;                if(myGame-&amp;gt;checkAnswer(answer) == HIGH) return HIGH;&#xA;            }&#xA;        }&#xA;        return LOW;&#xA;    }&#xA;public:&#xA;    games(unsigned short gameToPlay, unsigned short levelToPlay)&#xA;    {&#xA;        _gameToPlay = gameToPlay;&#xA;        _levelToPlay = levelToPlay;&#xA;        switch(_gameToPlay)&#xA;        {&#xA;            case 1:&#xA;                myGame = new gameHiLow();&#xA;                Serial.println(&quot; -&amp;gt;(game) play Higher or Lower Game&quot;);&#xA;                break;&#xA;            case 2:&#xA;                myGame = new gameSimon();&#xA;                Serial.println(&quot; -&amp;gt;(game) play Simon Game&quot;);&#xA;                break;&#xA;        }&#xA;    }&#xA;    void play()&#xA;    {&#xA;        unsigned short answer;&#xA;        while(!myGame-&amp;gt;gameTimerOver())&#xA;        {&#xA;            myGame-&amp;gt;setupForNewRound();&#xA;            myGame-&amp;gt;startTimeOut(.5);&#xA;            if(_respond() == HIGH)&#xA;            {&#xA;                myGame-&amp;gt;right();&#xA;                if(myGame-&amp;gt;reachedEnd())&#xA;                {&#xA;                    myGame-&amp;gt;winGame();&#xA;                    return;&#xA;                }&#xA;            }&#xA;            else&#xA;            {&#xA;                myGame-&amp;gt;wrong();&#xA;                if(--myGame-&amp;gt;lives &amp;lt;= 0)&#xA;                {&#xA;                    myGame-&amp;gt;loseGame();&#xA;                    return;&#xA;                }&#xA;            }&#xA;        }&#xA;        myGame-&amp;gt;loseGame();&#xA;    }&#xA;};&#xA;&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////////&#xA;games *game;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    unsigned short gameToPlay = 1;&#xA;    unsigned short levelToPlay = 1;&#xA;    game = new games(gameToPlay, levelToPlay);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(&quot;Let the games begin&quot;);&#xA;    game-&amp;gt;play();&#xA;    Serial.println(&quot;Program Complete&quot;);&#xA;    delay(5000);&#xA;    exit(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11988" LastEditorUserId="10794" LastEditDate="2015-08-28T21:54:41.380" LastActivityDate="2015-08-28T21:54:41.380" Title="Problem with codebender project not compiling" Tags="|programming|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14510" PostTypeId="2" ParentId="14509" CreationDate="2015-08-25T09:37:22.297" Score="0" Body="&lt;p&gt;As discussed here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable&quot;&gt;https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;declare these functions pure virtual:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;virtual void setupForNewRound(void) = 0;&#xA;virtual bool checkAnswer(unsigned short) = 0;&#xA;virtual bool reachedEnd(void) = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11989" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-08-25T09:37:22.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14511" PostTypeId="2" ParentId="14509" CreationDate="2015-08-25T10:13:48.263" Score="1" Body="&lt;p&gt;I agree with @GeryOshlike.  But that's not the only option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you can make them &lt;em&gt;pure virtual&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;virtual void setupForNewRound(void) = 0;&#xA;virtual bool checkAnswer(unsigned short) = 0;&#xA;virtual bool reachedEnd(void) = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can make them virtual with a default function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;virtual void setupForNewRound(void) { }&#xA;virtual bool checkAnswer(unsigned short) { return false; }&#xA;virtual bool reachedEnd(void) { return false; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pure virtual will complain when you compile if you haven't implemented those functions in your child class.  By providing a default function body it will not complain if you haven't implemented it, and will just use the default body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's a function which you know will always have to be implemented at the child level (will always be different) then go the pure virtual route.  If it's a function that will be the same in a number of children but differ in only a few, then providing the default body and overriding with different ones when needed is the better way to go.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-25T10:13:48.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14512" PostTypeId="2" ParentId="14499" CreationDate="2015-08-25T10:20:59.557" Score="1" Body="&lt;p&gt;No, the frequency of the &quot;buzzer&quot; has no relationship to the voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;duty cycle&lt;/em&gt; of the generated tone is proportional to the &lt;em&gt;average voltage&lt;/em&gt; though.  Typically the duty cycle is 50% - that is it's turned on for half the time, and turned off the other half the time, to make a square wave.  This means that the &lt;em&gt;average&lt;/em&gt; voltage is 50% of the supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to low-pass filter the signal (say through an RC filter as many people do to create a crude DAC) you would end up with a voltage around 2.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing the frequency doesn't change the duty cycle, it only changes the audio pitch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only caveat to that is that if the buzzer draws more current that the IO pin (or the power supply) can source then it may cause the voltage on that IO pin to &lt;em&gt;droop&lt;/em&gt;.  That has nothing to do with the frequency though and it would droop just the same at all frequencies.  Basically the IO pin has a small resistance to Vcc through the MOSFET that drives it internally - the higher the current the more voltage is dropped across that resistance, and the lower your resultant output voltage.  Draw too much current and the heat dissipated by that MOSFET's resistance becomes too great and damages the chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-25T10:20:59.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14513" PostTypeId="2" ParentId="14506" CreationDate="2015-08-25T11:06:26.990" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;will the buzzer make continuous sounds&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you mean the sensor will detect the rain drops in the air&#xA;Nop it's tiny to read it in the air&#xA;But if there is drops on the sensor your sensor will not gives you the right reading&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a water proof ultrasonic sensors available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on water level devices, after long path of searching in different ultrasonic sensors and after I tried a lot of method like using water proof Cloth, I found the best way is using water proof sensors PLUS water proof cloth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;water proof sensors work perfectly in high humidity but at the same time if there is a water drop on the sensor the reading will be different, and for that some cars manufacturers used not only one sensor, to avoid the errors. and calculate the differences. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MF7Cp.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MF7Cp.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The left car used old technology with separate sensors, but that's make errors the only good thing was to detect more things, in the next generation they mix them together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;water proof cloth will make the water drops not stuck at the sensor, but you will need to replace it every 5-6 months. &quot;in your case because the sun will destroy the cloth&quot; in my case and because my sensor inside tanks that's will least more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to spray the sensor with a different material to make my sensor not catch any water drops, it dose not work too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to make my cheap sensor water proof, I tried to use ceramic layers, and that's not work too, they use it with ultrasonic fog maker, these layers not work with cheap ultrasonic sensors, it's need a lot of power to vibrate it and different frequency. and of course you need to replace the layers &quot;depending on the environment&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find ultrasonic car sensor with special material for water drops just let me know, I am searching on that too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; These days car manufacturer use different ways, in the past the cover was vibrate itself and made from aluminum, now they cover it and make different filters to ignore the plastic cover, How?! maybe it's different plastic or material maybe they find away to vibrate the plastic! sorry I could not find the secret.&lt;/p&gt;&#xA;" OwnerUserId="9815" LastEditorUserId="9815" LastEditDate="2015-08-25T18:09:39.380" LastActivityDate="2015-08-25T18:09:39.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14514" PostTypeId="2" ParentId="14489" CreationDate="2015-08-25T12:14:38.540" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If you have two sensors from two different outputs but want them to go&#xA;  into one input, what do you need, and how can you read the input?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want your teacher lose his mind answer his question with this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I need? :)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A wire&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QhnyU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QhnyU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to use one trig for both ultrasonic sensor and two echos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or one echo and two triggers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ultrasonic sensor sends the pulse &gt; pulse back &gt; now echo pin is connected to second sensors trig &gt; the Second Ultrasonic sensor sends the pulse then starts listening. When the second ultrasonic echo back, it sends to other Arduino pin, reverse it if you want it on one input pin :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin 6&#xA;#define echoPin 4&#xA;#define echoPin2 7&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;   pinMode(echoPin2, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  long duration, distance, distance2;&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(20);&#xA;  digitalWrite(trigPin, LOW);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;  distance = (duration/2) / 29.1;&#xA;  duration = duration + pulseIn(echoPin2, HIGH);&#xA;  distance2 = (duration/2) / 29.1;&#xA;  if (distance &amp;gt;= 200 || distance &amp;lt;= 0){ &#xA;    Serial.println(&quot;Out of range&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.print(distance);&#xA;    Serial.println(&quot;cm&quot;);&#xA;       Serial.print(distance2);&#xA;    Serial.println(&quot; cm&quot;);&#xA;        Serial.println(&quot;HHH&quot;);&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that's it.&lt;/p&gt;&#xA;" OwnerUserId="9815" LastEditorUserId="9815" LastEditDate="2015-08-25T14:24:43.570" LastActivityDate="2015-08-25T14:24:43.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14515" PostTypeId="1" AcceptedAnswerId="14516" CreationDate="2015-08-25T13:50:35.720" Score="1" ViewCount="269" Body="&lt;p&gt;I'm thinking about making my own &quot;arduino&quot; low power board but I have a question about the atmega328. Is the output voltage on the pins always 5v or it depends on the input voltage I gave to the atmega?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11995" LastActivityDate="2015-08-25T13:52:57.890" Title="Atmega328 board output voltage" Tags="|atmega328|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14516" PostTypeId="2" ParentId="14515" CreationDate="2015-08-25T13:52:57.890" Score="2" Body="&lt;p&gt;It depends on the input voltage you give it.  If you run the ATMega328p at 3.3V then you get 3.3V out.  If you run it at 5V you get 5V out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A word of caution about running at lower voltages:  The chip can't run as fast when it has a lower supply voltage - that's why you will see the 3.3V Arduino boards running at 8MHz (or 12MHz at a pinch).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-25T13:52:57.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14517" PostTypeId="1" CreationDate="2015-08-25T14:47:46.567" Score="2" ViewCount="301" Body="&lt;p&gt;I'm trying to make two Arduino cards communicate, one is a sender and the other only receive packet from the first one and then display them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that the first recieved packet is not displayed unlike the other packets(displayed normally) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here's the output of my code :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YaLat.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YaLat.png&quot; alt=&quot;serial monitor for both device&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code of the reciever :&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void handle_rx() {&#xA;&#xA;Serial.print(&quot;received a packet &quot;);Serial.print(mrf.get_rxinfo()-&amp;gt;frame_length, DEC);Serial.println(&quot; bytes long&quot;);&#xA;&#xA;if(mrf.get_bufferPHY()){&#xA;  Serial.println(&quot;Packet data (PHY Payload):&quot;);&#xA;  for (int i = 0; i &amp;lt; mrf.get_rxinfo()-&amp;gt;frame_length; i++) {&#xA;      Serial.print(mrf.get_rxbuf()[i]);&#xA;  }&#xA;}&#xA;&#xA;Serial.println(&quot;\r\nASCII data (relevant data):&quot;);&#xA;for (int i = 0; i &amp;lt; mrf.rx_datalength(); i++) {&#xA;    Serial.write(mrf.get_rxinfo()-&amp;gt;rx_data[i]);&#xA;}&#xA;&#xA;Serial.print(&quot;\r\nLQI/RSSI=&quot;);&#xA;Serial.print(mrf.get_rxinfo()-&amp;gt;lqi, DEC);&#xA;Serial.print(&quot;/&quot;);&#xA;Serial.println(mrf.get_rxinfo()-&amp;gt;rssi, DEC);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the complete sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/**&#xA; * Example code for using a microchip mrf24j40 module to send and receive&#xA; * packets using plain 802.15.4&#xA; * Requirements: 3 pins for spi, 3 pins for reset, chip select and interrupt&#xA; * notifications&#xA; * This example file is considered to be in the public domain&#xA; * Originally written by Karl Palsson, karlp@tweak.net.au, March 2011&#xA; */&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;mrf24j.h&amp;gt;&#xA;&#xA;const int pin_reset = 6;&#xA;const int pin_cs = 7; // default CS pin on ATmega8/168/328&#xA;const int pin_interrupt = 2; // default interrupt pin on ATmega8/168/328&#xA;&#xA;Mrf24j mrf(pin_reset, pin_cs, pin_interrupt);&#xA;&#xA;long last_time;&#xA;long last_time2;&#xA;long tx_interval = 1000;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  mrf.reset();&#xA;  mrf.init();&#xA;&#xA;  mrf.set_pan(0xcafe);&#xA;  // This is _our_ address&#xA;  mrf.address16_write(0x4201); &#xA;&#xA;  // uncomment if you want to receive any packet on this channel&#xA;  //mrf.set_promiscuous(true);&#xA;&#xA;  // uncomment if you want to enable PA/LNA external control&#xA;  //mrf.set_palna(true);&#xA;&#xA;  // uncomment if you want to buffer all PHY Payload&#xA;  //mrf.set_bufferPHY(true);&#xA;&#xA;  attachInterrupt(0, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2(INT0) on ATmega8/168/328&#xA;  last_time = millis();&#xA;  interrupts();&#xA;}&#xA;&#xA;void interrupt_routine() {&#xA;    mrf.interrupt_handler(); // mrf24 object interrupt routine&#xA;}&#xA;&#xA;void loop() {&#xA;    mrf.check_flags(&amp;amp;handle_rx, &amp;amp;handle_tx);&#xA;    unsigned long current_time = millis();&#xA;    if (current_time - last_time &amp;gt; tx_interval) {&#xA;        last_time = current_time;&#xA;        Serial.println(&quot;txxxing...&quot;);&#xA;        mrf.send16(0x4202, &quot;abcd&quot;);&#xA;    }&#xA;}&#xA;&#xA;void handle_rx() {&#xA;    Serial.print(&quot;received a packet &quot;);Serial.print(mrf.get_rxinfo()-&amp;gt;frame_length, DEC);Serial.println(&quot; bytes long&quot;);&#xA;&#xA;    if(mrf.get_bufferPHY()){&#xA;      Serial.println(&quot;Packet data (PHY Payload):&quot;);&#xA;      for (int i = 0; i &amp;lt; mrf.get_rxinfo()-&amp;gt;frame_length; i++) {&#xA;          Serial.print(mrf.get_rxbuf()[i]);&#xA;      }&#xA;    }&#xA;&#xA;    Serial.println(&quot;\r\nASCII data (relevant data):&quot;);&#xA;    for (int i = 0; i &amp;lt; mrf.rx_datalength(); i++) {&#xA;        Serial.write(mrf.get_rxinfo()-&amp;gt;rx_data[i]);&#xA;    }&#xA;&#xA;    Serial.print(&quot;\r\nLQI/RSSI=&quot;);&#xA;    Serial.print(mrf.get_rxinfo()-&amp;gt;lqi, DEC);&#xA;    Serial.print(&quot;/&quot;);&#xA;    Serial.println(mrf.get_rxinfo()-&amp;gt;rssi, DEC);&#xA;}&#xA;&#xA;void handle_tx() {&#xA;    if (mrf.get_txinfo()-&amp;gt;tx_ok) {&#xA;        Serial.println(&quot;TX went ok, got ack&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;TX failed after &quot;);Serial.print(mrf.get_txinfo()-&amp;gt;retries);Serial.println(&quot; retries\n&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11996" LastEditorUserId="37523" LastEditDate="2019-08-06T16:35:17.737" LastActivityDate="2019-08-06T16:35:17.737" Title="First recieved packet not displayed (Arduino with MRF24j40MA)" Tags="|arduino-due|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="14520" PostTypeId="2" ParentId="14507" CreationDate="2015-08-25T16:07:31.883" Score="0" Body="&lt;p&gt;I suggest the following test:  Use &lt;code&gt;REG_PIOB_SODR = 1&amp;lt;&amp;lt;27;&lt;/code&gt; to set the bit, and  &lt;code&gt;REG_PIOB_CODR = 1&amp;lt;&amp;lt;27;&lt;/code&gt; to clear it.  If that works ok, see about enabling synchronous data output via the port's PIO_OWSR register.  (If it doesn't work ok, perhaps review section 31.6, “I/O Lines Programming Example”, on page 629 of Atmel document 11057, the Cortex datasheet.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Section 31.5.5, “Synchronous Data Output”, on page 623 says in part:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After reset, the synchronous data output is disabled on all the I/O lines as PIO_OWSR resets at 0x0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I imagine that writes to REG_PIOB_SODR and  REG_PIOB_CODR should have effect after you enabled output by setting bits in PIOB-&gt;PIO_PER and PIOB-&gt;PIO_OER, which you did.  However, with the bit in PIO_OWSR being clear, synchronous data output isn't available, so writes to REG_PIOB_ODSR have no effect.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-08-25T16:07:31.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14521" PostTypeId="1" CreationDate="2015-08-25T16:58:37.173" Score="1" ViewCount="3002" Body="&lt;p&gt;Is there a sketch that supports the receiving of email using the Arduino environment on the ESP8266? I can only find support for sending email. I know it's possible because the NodeMCU environment supports it. Any help is appreciated!&lt;/p&gt;&#xA;" OwnerUserId="1671" LastActivityDate="2017-07-11T07:21:06.200" Title="Arduino ESP8266 receive email?" Tags="|wifi|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14522" PostTypeId="1" CreationDate="2015-08-25T17:32:48.913" Score="0" ViewCount="668" Body="&lt;p&gt;I have a motor and gearbox that has limits and a pot built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some code what drives the motor one way to when it hits its limits takes a value and drives the other way and takes a value, then map the range from 0 to 100, that all works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a analog input map to 0 to 100 what I would like to do is to drive the motor to where ever the analog input is at, which is what I have done with the code below but when the motor gets close it starts hunting backwards and forwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to add some sort of dead band (where + 0.5 / where - 0.5) it just seems to just move the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did try -+ but this still did not help, so what I need to do is aim for the target value and stop then if I'm within 0.5 ether way then that is good enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;sensor       = pot on motor,&#xA;where        = 0 to 5 input,&#xA;vent1UPlim   = limits,&#xA;vent1DOWNlim = limits &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS. I know the map of 0 to 100 could do with being bigger but it's just easier to get my head around at the moment. &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;        //            pot           0-10v     ONE WAY&#xA;          if (sensorValue &amp;gt; (where + 0.5)) {&#xA;          if (digitalRead(vent1UPlim)==    HIGH) {&#xA;            DoneInitializationA=false;                    &#xA;            digitalWrite(vent1enable,      HIGH);&#xA;            delay(50);&#xA;            digitalWrite(vent1PWMA ,       HIGH);&#xA;            mydisp.drawStr(0, 2, &quot;-close-|&quot;);          &#xA;          } &#xA;          else {&#xA;            digitalWrite(vent1PWMA ,       LOW);&#xA;            delay(50);&#xA;            digitalWrite(vent1enable,      LOW);&#xA;            mydisp.drawStr(0, 2, &quot;       |&quot;);&#xA;          }&#xA;        }&#xA;        else {&#xA;          if (!DoneInitializationA) &#xA;          {&#xA;            digitalWrite(vent1PWMA ,       LOW);&#xA;            delay(50);&#xA;            digitalWrite(vent1enable,      LOW);&#xA;            mydisp.drawStr(0, 2, &quot;       |&quot;);&#xA;            DoneInitializationA=true;                &#xA;          }&#xA;        }&#xA;&#xA;           //                                   OTHER WAY&#xA;          if (sensorValue &amp;lt; (where - 0.5)) {&#xA;          if (digitalRead(vent1DOWNlim)==  HIGH) {&#xA;            DoneInitializationB=false;                       &#xA;            digitalWrite(vent1enable,      HIGH);&#xA;            delay(50);&#xA;            digitalWrite(vent1PWMB ,       HIGH);&#xA;            mydisp.drawStr(0, 2, &quot;-open -|&quot;);&#xA;          } &#xA;          else {&#xA;            digitalWrite(vent1PWMB ,       LOW);&#xA;            delay(50);&#xA;            digitalWrite(vent1enable,      LOW);&#xA;            mydisp.drawStr(0, 2, &quot;       |&quot;); &#xA;          }&#xA;        }&#xA;        else {&#xA;          if (!DoneInitializationB) &#xA;          {&#xA;            digitalWrite(vent1PWMB ,       LOW);&#xA;            delay(50);&#xA;            digitalWrite(vent1enable,      LOW);&#xA;            mydisp.drawStr(0, 2, &quot;       |&quot;);  &#xA;            DoneInitializationB=true;                           &#xA;          }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11998" LastEditorUserId="10794" LastEditDate="2015-08-25T21:00:37.567" LastActivityDate="2015-08-29T21:40:25.540" Title="adding a dead band to my motor and gearbox" Tags="|programming|arduino-mega|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14523" PostTypeId="1" CreationDate="2015-08-25T17:37:35.430" Score="0" ViewCount="170" Body="&lt;p&gt;I have ordered my Arduino, but it is not going to arrive until 2 months, and I would like to be able to emulate a COM connection to the emulated Arduino. I am writing a program that listens on the com port, and would like to test it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program needs to run on Windows, and emulate a COM connection, and a breadboard with a LED, and motors on it.&lt;/p&gt;&#xA;" OwnerUserId="11999" LastActivityDate="2020-08-27T12:59:10.420" Title="Can I program the Arduino without having an actual board with the able to emulate a COM connection to the computer?" Tags="|led|motor|communication|emulation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14524" PostTypeId="1" CreationDate="2015-08-25T19:01:59.270" Score="0" ViewCount="2841" Body="&lt;p&gt;I've an Arduino Mega 2560 R3 and recently bought a Wifi Shield CC3000 from ebay &lt;a href=&quot;http://www.ebay.de/itm/201405512301&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.de/itm/201405512301&lt;/a&gt;&#xA;They write that the firmware has the version ServicePack 1.11.1.&#xA;The WiFi shield is connected to the Arduino and green status light is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to run this example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;}&#xA;&#xA;// check for the presence of the shield:&#xA;if (WiFi.status() == WL_NO_SHIELD) {&#xA;  Serial.println(&quot;WiFi shield not present&quot;);&#xA;    // don't continue:&#xA;  while(true);&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that Wifi.status() always returns WL_NO_SHIELD.&#xA;What can I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for help.&lt;/p&gt;&#xA;" OwnerUserId="11839" LastActivityDate="2016-01-05T00:30:58.140" Title="Wifi.status() always returns WL_NO_SHIELD" Tags="|arduino-mega|wifi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14525" PostTypeId="2" ParentId="14523" CreationDate="2015-08-25T19:15:12.550" Score="2" Body="&lt;p&gt;You could use the &lt;a href=&quot;http://www.atmel.com/webdoc/simulator/simulator.wb_Simulator_Use.html&quot; rel=&quot;nofollow&quot;&gt;Simulator&lt;/a&gt; in &lt;a href=&quot;http://www.atmel.com/microsite/atmel_studio6/&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt; or something like &lt;a href=&quot;http://www.virtualbreadboard.com/&quot; rel=&quot;nofollow&quot;&gt;Virtual Breadboard&lt;/a&gt; which looks good&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.atmel.com/microsite/atmel_studio6/&quot; rel=&quot;nofollow&quot;&gt;Atmel Studio&lt;/a&gt; simulator might take a bit of work to simulate your devices but if you have 2 months then maybe that's okay :) If you want to use the simulator in Atmel Studio then you might also find the &lt;a href=&quot;http://www.visualmicro.com/page/Arduino-for-Atmel-Studio.aspx&quot; rel=&quot;nofollow&quot;&gt;Arduino plugin for Atmel Studio&lt;/a&gt; useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think there are quite a few other solutions if you search google.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-08-26T14:52:46.137" LastActivityDate="2015-08-26T14:52:46.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14526" PostTypeId="1" AcceptedAnswerId="14532" CreationDate="2015-08-25T19:58:06.570" Score="0" ViewCount="100" Body="&lt;p&gt;On the barrel connector I accidentally reversed the input voltage to an Arduino Mega. The center post received ground while the outer connection received +12DVC, basically I have the Arduino -12VDC. I have since fixed this problem. When I power the Arduino with the USB I am able to program the Arduino without a problem. When I power the Arduino with the +12VDC the program still runs (confirmed by programming the blink sketch). If I have the +12VDC connected and try to program the Arduino then I get the timeout communication error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I just need to re-burn the bootloader? The Arduino's symptoms match those listed here when both cables are connected: &lt;a href=&quot;https://arduino.stackexchange.com/questions/864/arduino-mega-timeout-communication-with-programmer-error&quot;&gt;Arduino Mega timeout communication with programmer error&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything else I should verify? Or is the Arduino always going to be damaged?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also as a note I did the same thing to an Arduino Uno (same rail going to both) and the Uno has no problems when both USB and power are connected.&lt;/p&gt;&#xA;" OwnerUserId="12000" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-08-26T08:44:26.327" Title="Reversed Input Voltage Arduino Mega timeout communication with programmer error" Tags="|arduino-mega|power|bootloader|avrdude|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14527" PostTypeId="1" AcceptedAnswerId="14530" CreationDate="2015-08-25T20:23:20.060" Score="1" ViewCount="2199" Body="&lt;p&gt;My project is battery powered and it has it's own usb port for charging. Can I snip off the HUGE DC barrel jack which is making it hard for me to fit this into an enclosure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or could that cause problems? &lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-08-26T18:13:17.713" Title="Removing the barrel jack connector?" Tags="|power|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14528" PostTypeId="2" ParentId="14527" CreationDate="2015-08-25T20:29:20.283" Score="2" Body="&lt;p&gt;You can remove it safely without any issues, just make sure that there are no short circuits or any other components damaged while doing so&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-25T20:29:20.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14529" PostTypeId="2" ParentId="14526" CreationDate="2015-08-25T20:55:48.343" Score="0" Body="&lt;p&gt;Chances are you have blown up the circuitry that performs the switching between barrel jack and USB power sources.  As a result the USB interface chip isn't getting power when it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short: &lt;em&gt;&quot;It's dead, Jim!&quot;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-25T20:55:48.343" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14530" PostTypeId="2" ParentId="14527" CreationDate="2015-08-25T21:06:48.170" Score="5" Body="&lt;p&gt;You'll likely do less damage de-soldering it than trying to snip it off. Use a de-soldering pump to remove as much molten solder as you can, then heat again with de-soldering braid to wick up the remainder. If the jack's solder terminals were bent over (to stabilize the part before it was soldered) you may need to straighten them with a tweezer-nosed plier. Then you should be able to lift the part off the board. Don't overheat the board or heat any other parts or solder joints than those you intend to remove.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-08-26T17:46:00.647" LastActivityDate="2015-08-26T17:46:00.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14531" PostTypeId="2" ParentId="14522" CreationDate="2015-08-25T21:07:24.503" Score="1" Body="&lt;p&gt;The simple way is to just subtract one from the other, take the absolute value and see if it exceeds your hysteresis range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if (abs (sensorValue - where) &amp;gt;= 0.5) {&#xA;  {&#xA;  // do something&#xA;&#xA;  if (sensorValue &amp;gt; where)&#xA;    {&#xA;    // one way&#xA;    }&#xA;  else&#xA;    {&#xA;    // other way&#xA;    }&#xA;  } // end of large enough to worry about&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In response to this (since deleted):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;would this not have the same problem as mine as instead of hunting round its target it will just do it 0.5 away from the target? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;By subtracting and taking the absolute value, we create a band of +0.5 and -0.5 where, if the sensor is in that range, we do nothing. It hasn't moved the problem because it can't move in two directions at once (both up &lt;strong&gt;and&lt;/strong&gt; down).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-29T21:40:25.540" LastActivityDate="2015-08-29T21:40:25.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14532" PostTypeId="2" ParentId="14526" CreationDate="2015-08-25T21:12:43.303" Score="0" Body="&lt;p&gt;&lt;em&gt;Don't reprogram the bootloader.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can upload sketches that is unnecessary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will probably be fiddly to identify and fix what has failed, but since you can reprogram it via USB it is still 99% working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you get one of those USB charging wall-warts that provide 5 V, and just plug that into the USB port if you want to run it away from the PC. You know that the USB power part works.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-25T21:12:43.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14533" PostTypeId="1" CreationDate="2015-08-25T21:37:14.343" Score="2" ViewCount="369" Body="&lt;p&gt;I have a shapeoko 2, and have been wanting to create a jogging pendant for it for a while.  Currently GRBL (the G code interpreter for arduino) doesn't support jogging the machine with a pendant.  I was wondering if it was possible to emulate arrow key inputs on the keyboard through an arduino.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2015-08-25T21:37:14.343" Title="Using an arduino to emulate keyboard inputs" Tags="|serial|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14534" PostTypeId="2" ParentId="14527" CreationDate="2015-08-25T21:38:47.660" Score="1" Body="&lt;p&gt;De sdering would be safer.  You can then use the Vin pin to supply sour voltage (IIRC you can run as high as 12 volts with the uno)&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2015-08-25T21:38:47.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14535" PostTypeId="2" ParentId="14506" CreationDate="2015-08-25T21:40:51.643" Score="1" Body="&lt;p&gt;It would probably be easier to use an IR distance sensor.  That would also be easier to waterproof.&lt;/p&gt;&#xA;" OwnerUserId="12003" LastActivityDate="2015-08-25T21:40:51.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14536" PostTypeId="2" ParentId="14496" CreationDate="2015-08-25T21:59:04.853" Score="1" Body="&lt;p&gt;Your question is kind of trivial, but from what I understood you're typing the IP address (that the Arduino displays on the serial monitor)  into your browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, make sure you connect your Ethernet shield to your router using an ethernet cable. (Now it's connected locally...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, even if you type in your Arduino's IP address into the browser, the browser will return nothing because the Arduino simply has nothing to display, and hasn't been programmed to accept requests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To actually have the Arduino display something you can try the Webserver example sketch or you can follow this great &lt;a href=&quot;http://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/&quot; rel=&quot;nofollow&quot;&gt;Tutorial&lt;/a&gt; that I found very useful for beginners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW ports are only used to expose your Arduino to the Internet, in other words if you don't portforward to your Arduino, your Arduino won't be able to get requests from outside your local network (Wi-Fi,Ethernet). &lt;/p&gt;&#xA;" OwnerUserId="11982" LastEditorUserId="10794" LastEditDate="2015-08-25T22:08:37.210" LastActivityDate="2015-08-25T22:08:37.210" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14537" PostTypeId="2" ParentId="10326" CreationDate="2015-08-25T22:20:22.667" Score="0" Body="&lt;p&gt;I'm sorry to tell you but i think you damaged your board severely that's because you took more energy from the pins than an arduino can handle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;150 LEDs takes way too much power for the arduino to handle as you can see &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you likely burnt something on your board and might have to replace it :/&#xA;make sure which board is damaged(the arduino itself or the shield) before replacing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the ATmega328P(The chip on the arduino) is damaged then this should be an easy fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of what you did, you shoud have powered the LED strip from another power supply(not from the arduino pins) and used the arduino to turn &quot;this power supply&quot; on and off(probably using transistors).&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2015-08-25T22:20:22.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14538" PostTypeId="1" CreationDate="2015-08-25T23:13:25.350" Score="0" ViewCount="37" Body="&lt;p&gt;Would it be possible to use to of &lt;a href=&quot;http://www.ebay.com/itm/Bluetooth-Serial-Transceiver-Module-Base-Board-clear-button-For-Arduino-SWTG-/231608470902?hash=item35ecf0cd76&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; on two separate arduino's, to send and receive information? I am having difficulties understanding the chinese-english descriptions and haven't seen any documentation on doing this. There would be no phone involved. There would only be two arduino's with a Bluetooth module on each of them sending and receiving data from each other. &lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2016-03-28T05:22:46.150" Title="Bluetooth Trancievers for arduinos" Tags="|bluetooth|arduino-nano|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14540" PostTypeId="2" ParentId="2931" CreationDate="2015-08-26T01:44:31.930" Score="0" Body="&lt;p&gt;See screenshot below. The Rx on the Uno (incoming data) should flash first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7tqmH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7tqmH.png&quot; alt=&quot;Uno boot sequence&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The programmer sends &lt;code&gt;STK_GET_SYNC&lt;/code&gt; and the board replies &lt;code&gt;STK_INSYNC&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sent: STK_GET_SYNC / CRC_EOP  (30/20)&#xA;Got: STK_INSYNC / STK_OK (14/10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Afterwards you see the bigger blocks on the lower line as the programmer sends the hex code to the board. Then about half-way through the bigger blocks are on the top as the board sends back the verification data (by reading the flash back).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The little blips would be the other side acknowledging a packet of data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-09-25T05:50:48.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14541" PostTypeId="2" ParentId="815" CreationDate="2015-08-26T06:05:47.257" Score="4" Body="&lt;p&gt;Try an LED driver. Their typical output is 11.8V DC, which is in perfect specs for the Arduino. You can find them nowadays in all shapes and sizes, round or square, low profile or boxy. A 500ma version (6W) is more than enough for your needs.&lt;/p&gt;&#xA;" OwnerUserId="12006" LastActivityDate="2015-08-26T06:05:47.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14542" PostTypeId="1" CreationDate="2015-08-26T06:13:44.110" Score="0" ViewCount="71" Body="&lt;h1&gt;Context&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I first ran a sketch (&lt;strong&gt;on Arduino Uno&lt;/strong&gt;) without any custom data structure and list, so I was using a bunch of arrays, methods and other primitive variables. And it worked perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My program acts like a menu which takes serial user input to perform actions. So you could have serial input &quot;man r+(100,0,345)&quot;. Or just &quot;man&quot; to set this mode active, and later &quot;r+(100,0,345)&quot; to actualize the data in the &quot;r&quot; field in the &quot;man&quot; instance. I use a custom data structure to manage the input (class called Mode), and a linked list (class called ModeList).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I implemented some data structures (an object and a list) to manage incoming serial data, without modifying the rest of the program. But now, serial communication is not working properly: If I add &lt;code&gt;Serial.print(&quot;Allo&quot;)&lt;/code&gt; &lt;em&gt;anywhere&lt;/em&gt; in the sketch, it will print spaces for a while and stop, before I send any serial data. If it is in the &lt;code&gt;setup()&lt;/code&gt; function, it prints spaces continuously with some characters from &quot;Allo&quot; from time to time. There's always a different problem along those lines, depending on where I put that simple print statement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here follows the sketch, the header files of the Mode and ModeList classes... By the way, I suspect a memory management problem.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The sketch&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Mode.h&quot;&#xA;#include &quot;ModeList.h&quot;&#xA;&#xA;const int inputSize=12;&#xA;const int nbModes=4;&#xA;int input;&#xA;int toSet[inputSize];&#xA;int i;&#xA;&#xA;char manName[3]={'m','a','n'};&#xA;char cutName[3]={'c','u','t'};&#xA;char levName[3]={'l','e','v'};&#xA;char autName[3]={'a','u','t'};&#xA;&#xA;Mode m=Mode(0,manName);&#xA;Mode c=Mode(1,cutName);&#xA;Mode l=Mode(2,levName);&#xA;Mode a=Mode(3,autName);&#xA;Mode* man=&amp;amp;m;&#xA;Mode* cut=&amp;amp;c;&#xA;Mode* lev=&amp;amp;l;&#xA;Mode* aut=&amp;amp;a;&#xA;ModeList modeList=ModeList();&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.print(&quot;Allo&quot;);&#xA;  modeList.add(man);&#xA;  modeList.add(cut);&#xA;  modeList.add(lev);&#xA;  modeList.add(aut);&#xA;  }&#xA;&#xA;void loop() {&#xA;  for(int j=0;j&amp;lt;inputSize;j++)&#xA;  {&#xA;    toSet[j]=NULL;&#xA;  }&#xA;  i=0;&#xA;  if(Serial.available()&amp;gt;0)&#xA;  {&#xA;    while(Serial.available())&#xA;    {&#xA;      if(i&amp;lt;inputSize)&#xA;      {&#xA;        input=Serial.read();&#xA;        if(input!=' ' &amp;amp;&amp;amp; input!='(' &amp;amp;&amp;amp; input !=')' &amp;amp;&amp;amp; input!=',' &amp;amp;&amp;amp; input!='\n')&#xA;        {&#xA;          toSet[i]=input;&#xA;          i++;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  if(serialMode(man)||man-&amp;gt;getStatus())&#xA;  {&#xA;    //Set man on&#xA;    modeList.setMode(man);&#xA;&#xA;    if(toSet[3]=='r')&#xA;    {&#xA;      if(toSet[4]=='+')&#xA;      {&#xA;        //Set ypr rate&#xA;        Serial.println(&quot;Set ypr rate +&quot;);&#xA;      }&#xA;      else if(toSet[4]=='-')&#xA;      {&#xA;        //Set ypr rate&#xA;        Serial.println(&quot;Set ypr rate -&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        //Set ypr rate&#xA;        Serial.println(&quot;Set ypr rate&quot;);&#xA;      }&#xA;    }&#xA;    else if(toSet[3]=='a')&#xA;    {&#xA;      if(toSet[4]=='+')&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle +&quot;);&#xA;      }&#xA;      else if(toSet[4]=='-')&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle -&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle&quot;);&#xA;      }&#xA;    }&#xA;    else if(toSet[3]=='t')&#xA;    {&#xA;      if(toSet[4]=='+')&#xA;      {&#xA;        //Set thrust&#xA;        Serial.println(&quot;Set thrust +&quot;);&#xA;      }&#xA;      else if(toSet[4]=='-')&#xA;      {&#xA;        //Set thrust&#xA;        Serial.println(&quot;Set thrust -&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        //Set thrust&#xA;        Serial.println(&quot;Set thrust&quot;);&#xA;      }&#xA;    }&#xA;  }&#xA;  if(serialMode(cut)||cut-&amp;gt;getStatus())&#xA;  {&#xA;    //Cut engines&#xA;    modeList.setMode(cut);&#xA;    if(serialMode(cut))&#xA;      Serial.println(&quot;Cut&quot;);&#xA;  }&#xA;  if(serialMode(lev)||lev-&amp;gt;getStatus())&#xA;  {&#xA;    //Stabilize axes&#xA;    modeList.setMode(lev);&#xA;    if(serialMode(lev))&#xA;      Serial.println(&quot;Level&quot;);&#xA;  }&#xA;  if(serialMode(aut)||aut-&amp;gt;getStatus())&#xA;  {&#xA;    //Set aut on&#xA;    modeList.setMode(aut);&#xA;    if(serialMode(aut))&#xA;      Serial.println(&quot;Set aut on&quot;);&#xA;    if(toSet[3]=='s')&#xA;    {&#xA;      if(toSet[4]=='+')&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle +&quot;);&#xA;      }&#xA;      else if(toSet[4]=='-')&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle -&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        //Set ypr angle&#xA;        Serial.println(&quot;Set ypr angle&quot;);&#xA;      }&#xA;    }&#xA;    else if(toSet[3]=='A')&#xA;    {&#xA;      if(toSet[4]=='+')&#xA;      {&#xA;        //Set altitude&#xA;        Serial.println(&quot;Set altitude +&quot;);&#xA;      }&#xA;      else if(toSet[4]=='-')&#xA;      {&#xA;        //Set altitude&#xA;        Serial.println(&quot;Set altitude -&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        //Set altitude&#xA;        Serial.println(&quot;Set altitude&quot;);&#xA;      }&#xA;    }&#xA;  }&#xA;  delay(10);&#xA;}&#xA;&#xA;bool serialMode(Mode* inputMode)&#xA;{&#xA;  char* modeName;&#xA;  modeName=inputMode-&amp;gt;getName();&#xA;  Serial.print(&quot;ALLO&quot;);&#xA;  if(toSet[0]==*modeName&amp;amp;&amp;amp;toSet[1]==*(modeName+1)&amp;amp;&amp;amp;toSet[2]==*(modeName+2))&#xA;  {&#xA;    Serial.print(&quot;Set &quot;);&#xA;    for(int i=0;i&amp;lt;3;i++)&#xA;    {&#xA;      Serial.print(*(modeName+i));&#xA;    }&#xA;    Serial.println(&quot; on&quot;);&#xA;    return true;&#xA;  }&#xA;  else&#xA;    return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;The Mode class header&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;class Mode&#xA;{&#xA;    public:&#xA;        Mode(int id, char* name);&#xA;        int getId();&#xA;        Mode* getNext();&#xA;        void setNext(Mode m);&#xA;        void setStatus(bool status);&#xA;        bool getStatus();&#xA;        char* getName();&#xA;    private:&#xA;        char *_name;&#xA;        int _id;&#xA;        Mode* _next;&#xA;        bool _status;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;The ModeList class header&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class ModeList&#xA;{&#xA;    public:&#xA;        void add(Mode* input);&#xA;        int get(int pos);&#xA;        ModeList();&#xA;        void setMode(Mode* inputMode);&#xA;    private:&#xA;        Mode* start;&#xA;        Mode* end;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7304" LastEditorUserId="7304" LastEditDate="2015-08-26T06:54:38.377" LastActivityDate="2016-01-23T17:17:49.650" Title="Serial problem after implementing data structures" Tags="|arduino-uno|serial|c++|communication|memory-usage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14543" PostTypeId="1" AcceptedAnswerId="14544" CreationDate="2015-08-26T06:44:00.013" Score="0" ViewCount="835" Body="&lt;p&gt;I am using an Arduino UNO to drive a UART throughput test and to also test the latency of the slave microcontroller.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The setup is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino|---UART--------------------------|MCU2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino|---FLOW_CONTROL_PIN---|MCU2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sending data to the MCU2 over the UART with a specified delay between writes, and in MCU2 I have a certain buffer threshold where I set an overflow pin indicator back to the Arduino (using INT0), where when the interrupt is triggered, I stop sending data (hardware based flow control).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I log the amount of bytes sent and compare that to the buffer threshold level.  If the bytes sent are equal to the threshold point, I know the latency of the path (threshold--&gt;toggle flow pin--&gt;Arduino interrupt and stop transmit) is ok (if not, we are having latency issues and probably need to do a software based flow control). I then do the whole process again, with a shorter delay.  I then can find the delay point that will result in the fastest continuous transfer rate (this is testing throughput as well as latency of the slave MCU).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A problem can arise if the Arduino api is providing more latency than the path under test.  I believe this is most likely the case, but wanted to see if there has been any concrete numbers on the overhead of Arduino, particularly in regard to its Serial api.  I used Arduino to get something running quickly, but if it doesn't allow me to actually test the system, need to go to using all AVR C or use another MCU for the transmit side.&lt;/p&gt;&#xA;" OwnerUserId="1370" LastActivityDate="2015-08-26T08:18:25.567" Title="What is the overhead time of using Serial library compared to coding it up in AVR C (not using Arduino code)?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14544" PostTypeId="2" ParentId="14543" CreationDate="2015-08-26T07:05:24.427" Score="1" Body="&#xA;&#xA;&lt;p&gt;There's no reason to doubt the Arduino hardware. We need to put some figures on what you are experiencing, such as the baud rate and buffer sizes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would expect with this sort of hardware flow-control that you would potentially send a byte or so more than expected, because it takes a finite time to react to the flow-control signal. This is to be expected, particularly as the hardware has a buffer, so it can be starting to send a byte at the moment you get the signal to stop sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect you would have a leeway (say of 10 bytes) where you expect the sender to stop sending within that time.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A problem can arise if the Arduino API is providing more latency than the path under test&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you mean by this. However the HardwareSerial class has a 64-byte buffer (if you are using a Uno) which means you potentially have put 64 bytes into it, before noticing that the sender wants you to stop sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is probably what you are experiencing. See HardwareSerial.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Define constants and variables for buffering incoming serial data.  We're&#xA;// using a ring buffer (I think), in which head is the index of the location&#xA;// to which to write the next incoming character and tail is the index of the&#xA;// location from which to read.&#xA;#if (RAMEND &amp;lt; 1000)&#xA;  #define SERIAL_BUFFER_SIZE 16&#xA;#else&#xA;  #define SERIAL_BUFFER_SIZE 64&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For this test you might want to edit that file and reduce that number, substantially.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, use SoftwareSerial. I don't think that buffers writes (as it doesn't have hardware to do them in the background) so that would reduce the latency to a single byte.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I believe this is most likely the case, but wanted to see if there has been any concrete numbers on the overhead of Arduino, particularly in regard to its Serial API.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not an overhead, it's a design issue. If you do what I suggested it should work fine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What I mean by Arduino API overhead is the fact that the actual hardware interface is substantially abstracted away from the register level implementation ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, not really. When you write a byte it puts it into a circular buffer, as you would expect. When the hardware is free to output another byte (generally called by an interrupt) it outputs it. What else could it do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you are absolutely free to address the hardware registers yourself and not use HardwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To keep things simple though, what you really need to do here is &lt;strong&gt;not buffer&lt;/strong&gt; because that makes reacting to the flow-control flag somewhat slow. And here is how to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.write ('a');  // or whatever&#xA;Serial.flush ();  // wait until everything is sent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have thrown away the buffering, and you can just send at the rate that the hardware can (probably slightly less).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-26T08:18:25.567" LastActivityDate="2015-08-26T08:18:25.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14545" PostTypeId="2" ParentId="14542" CreationDate="2015-08-26T07:14:42.843" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If I add Serial.print(&quot;Allo&quot;) anywhere in the sketch, it will print spaces for a while and stop, before I send any serial data. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Classic symptoms of using up all available RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a workaround I would use the &lt;code&gt;F()&lt;/code&gt; macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Serial.println(F(&quot;Set ypr rate +&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do that in all places where you are printing string literals. That would save you a couple of hundred bytes.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-26T07:14:42.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14546" PostTypeId="1" CreationDate="2015-08-26T08:11:22.633" Score="5" ViewCount="1773" Body="&lt;p&gt;I have a few RTC modules with a batteries. All of them have this same issue with my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They work fine when connected via USB. But if I disconnect the power then reconnect they reset to Jan 1 2000. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read several posts about similar problems. But, none seem to apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SFE_MicroOLED.h&amp;gt;  // Include the SFE_MicroOLED library&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &quot;Wire.h&quot;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;RTC_DS1307 RTC;&#xA;#define BUTTON_PIN       0 // Button&#xA;#define LONGPRESS_LEN    25  // Min nr of loops for a long press&#xA;#define DELAY            20  // Delay per loop in ms&#xA;&#xA;enum { EV_NONE=0, EV_SHORTPRESS, EV_LONGPRESS };&#xA;&#xA;boolean button_was_pressed; // previous state&#xA;int button_pressed_counter; // press running duration&#xA;&#xA;byte zero = 0x00; //workaround for issue #527&#xA;&#xA;char* modes[]={&quot;Walk&quot;, &quot;Bike&quot;, &quot;Subway&quot;, &quot;Train&quot;, &quot;Bus&quot;, &quot;X-Bus&quot;, &quot;Waiting&quot;, &quot;Other&quot;};&#xA;byte mode=0;&#xA;int modeRead;&#xA;&#xA;// Chip Select for SD&#xA;#define chipSelect 10&#xA;&#xA;//MicroOLED oled(PIN_RESET, PIN_DC, PIN_CS);&#xA;MicroOLED oled(9, 8, 5); // SPI declaration&#xA;&#xA;void setup()  &#xA;{ &#xA;    pinMode(BUTTON_PIN, INPUT);&#xA;    digitalWrite(BUTTON_PIN, HIGH); // pull-up&#xA;    Serial.begin(9600);&#xA;    button_was_pressed = false;&#xA;    button_pressed_counter = 0;&#xA;&#xA;    SD.begin(chipSelect);&#xA;&#xA;    Wire.begin();&#xA;    RTC.begin();&#xA;    //RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;&#xA;    oled.begin();    // Initialize the OLED   &#xA;    oled.clear(PAGE);     // Clear the screen&#xA;    oled.setFontType(1);  // Set font to type 0&#xA;    oled.setCursor(0, 0); // Set cursor to top-left&#xA;    oled.println(F(&quot;co'mute&quot;));&#xA;    oled.display();  // Display what's in the buffer &#xA;}&#xA;&#xA;int handle_button()&#xA;{&#xA;    int event;&#xA;    int button_now_pressed = !digitalRead(BUTTON_PIN); // pin low -&amp;gt; pressed&#xA;&#xA;    if (!button_now_pressed &amp;amp;&amp;amp; button_was_pressed) {&#xA;        if (button_pressed_counter &amp;lt; LONGPRESS_LEN)&#xA;            event = EV_SHORTPRESS;&#xA;        else&#xA;            event = EV_LONGPRESS;&#xA;    }&#xA;    else&#xA;        event = EV_NONE;&#xA;&#xA;    if (button_now_pressed)&#xA;        ++button_pressed_counter;&#xA;    else&#xA;        button_pressed_counter = 0;&#xA;&#xA;    button_was_pressed = button_now_pressed;&#xA;    return event;&#xA;}&#xA;&#xA;void printDate () &#xA;{    &#xA;    oled.clear(PAGE);     // Clear the screen&#xA;    oled.setFontType(0);  // Set font to type 0&#xA;    oled.setCursor(0, 0); // Set cursor to top-left&#xA;&#xA;    DateTime now = RTC.now();&#xA;&#xA;    oled.print(now.year(), DEC);&#xA;    oled.print('/');&#xA;    oled.print(now.month(), DEC);&#xA;    oled.print('/');&#xA;    oled.print(now.day(), DEC);&#xA;    oled.print(' ');&#xA;    oled.print(now.hour(), DEC);&#xA;    oled.print(':');&#xA;    if (now.minute()&amp;lt;10) {&#xA;        oled.print(&quot;0&quot;);&#xA;    }&#xA;    oled.print(now.minute(), DEC);&#xA;    oled.print(':');&#xA;    if (now.second()&amp;lt;10) {&#xA;        oled.print(&quot;0&quot;);&#xA;    }&#xA;    oled.print(now.second(), DEC);&#xA;    oled.println();&#xA;    oled.setFontType(1);  // Set font to type 0&#xA;    oled.println(modes[mode]);&#xA;    oled.display();   // Display what's in the buffer (splashscreen)&#xA;}&#xA;&#xA;void writeFile() &#xA;{&#xA;    File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;    // If the file is available, write to it:&#xA;    if (dataFile) {&#xA;        DateTime now = RTC.now();&#xA;        //print the date EG   3/1/11 23:59:59&#xA;        dataFile.print(now.year(), DEC);&#xA;        dataFile.print('/');&#xA;        dataFile.print(now.month(), DEC);&#xA;        dataFile.print('/');&#xA;        dataFile.print(now.day(), DEC);&#xA;&#xA;        printDate ();&#xA;        oled.print(&quot;*SAVED*&quot;);&#xA;        oled.display();&#xA;        delay(3000);&#xA;    }&#xA;} &#xA;&#xA;void loop()          // run over and over again&#xA;{&#xA;    // handle button&#xA;    boolean event = handle_button();&#xA;&#xA;    // do other things&#xA;    switch (event) {&#xA;        case EV_NONE:&#xA;        oled.print(&quot;.&quot;);&#xA;        break;&#xA;&#xA;        case EV_SHORTPRESS:&#xA;        oled.print(&quot;S&quot;);&#xA;        //modeRead = analogRead(0);    // read the value from the sensor&#xA;        writeFile(); &#xA;        break;&#xA;&#xA;        case EV_LONGPRESS:&#xA;        oled.print(&quot;L&quot;);&#xA;        break;&#xA;    }&#xA;&#xA;    static int counter = 0;&#xA;    if ((++counter &amp;amp; 0X016) == 0) {&#xA;        printDate ();&#xA;    }&#xA;    modeRead = analogRead(A0);    // read the value from the sensor&#xA;    delay(DELAY);&#xA;&#xA;    int c=1020/(sizeof(modes)/sizeof(modes[0]));&#xA;    for (int i = 0; i &amp;lt; c; i++) { &#xA;        if (i*c &amp;lt; modeRead &amp;amp;&amp;amp; (i+1)*c &amp;lt; modeRead) {&#xA;            mode = i;&#xA;        }&#xA;    }     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vEt71.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vEt71.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this diagram the &quot;pressure sensor&quot; is really a OLED that operates via MOSI and MISO.&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="84" LastEditDate="2016-10-28T07:48:51.143" LastActivityDate="2017-05-10T12:45:58.743" Title="RTC resets when power is off" Tags="|time|rtc|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14547" PostTypeId="2" ParentId="14465" CreationDate="2015-08-26T08:27:02.283" Score="0" Body="&lt;p&gt;This addresses a subset of your question which was covered in your added comment-question. I've addressed use of a 20V full scale input range to make the answer more general. The results would be &quot;even better&quot; for your 5V input case. Note that is Vin ~= 5V you would want a measurenet range somewhat above 5V max so that you can handle typical voltage variations. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do you know any transistors/FETs with a very low voltage drop which I need for switching off a sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you used a say 10k resistor in the upper leg of a voltage divider and added a MOSFET switch with an on resistance (Rdson) of 2 Ohms (a terrible spec) between Vin and the divider then the error introduced would be about 2/10k = 1:5000. If measuring a say 12V  battery and using a Vinmax voltage of 20V the error in voltage measurement would be in the order of 20V/5000 = 4 mV. If using an Arduino Nano with a 10 but ADC the resolution (not accuracy) is 1 in 2^10 = 1:1024 or 20V/1024  = about 19 mV for a 20V input range. ie the resistor introduces an error of about 1/5th of a bit of available measuring accuracy. &#xA;Worse (or better) - if you use 1% resistors they will swamp errors caused by ADC resolution. Even use of say 0.1% resistors or calibration is liable to produce a result where ADC resolution is not the main limiting factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even with no resistive divider, getting accuracies that are doinated by the 1:1024 ADC resolution and not other factors takes care and effort. At 5V in ax ADC resolution of 1:1024 means that a variation of 1 part in 2048 could cause an erroneous reading. Input offset voltages, thermal effects, board and connector resistances and ground voltage dropsm and offsets can easily provide greater error magnitufes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test: Take a working design. Set meter to lowest voltage range such that 1 mV can easily be seen. (Ideally 200 mV range. 2V range marginally OK). Measure ground voltages between various &quot;ground&quot; points at various locations in the system. Differences ofm mV to 10's of mV can often be found. Differences are poptentially higher if power current are present - say 10's of mA or more. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2015-08-26T08:27:02.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14548" PostTypeId="1" AcceptedAnswerId="14555" CreationDate="2015-08-26T08:32:27.097" Score="4" ViewCount="752" Body="&lt;p&gt;I'm building a home automation product and want to measure AC current using Arduino (as of now). I've used ACS712 5A Hall Effect Current module but there's a lot of electrical noise and also the accuracy is not good. There's a lot of deflection in value when no current passes through it. I want to pack the whole kit in a box. So how to make sure that there will be no magnetic interference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you suggest some other module to use for the same? Also that can last long enough.&lt;/p&gt;&#xA;" OwnerUserId="10040" LastActivityDate="2015-08-26T12:46:49.587" Title="Which device to use to measure AC current using Arduino?" Tags="|arduino-uno|sensors|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14549" PostTypeId="2" ParentId="14526" CreationDate="2015-08-26T08:44:26.327" Score="0" Body="&lt;p&gt;The Mega has a reverse polarity protection diode (&lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-mega-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;D1&lt;/a&gt;) on the board, so you plugging in the wrong polarity barrel didn't damage anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your current problem in unrelated to this.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-26T08:44:26.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14550" PostTypeId="1" CreationDate="2015-08-26T10:40:07.903" Score="-1" ViewCount="19219" Body="&lt;p&gt;When I try to compile the following code in Arduino ,I get the error &quot;expected initializer before 'void'&quot;.How can I get the code to work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void setup() {  &#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;float area = 0.0f,pre_area = 0.0f,tarea = 0.0f,rarea = 0.0f;&#xA;int x = 0,pre_x = 0,t = 0,pre_t = 0;&#xA;&#xA;&#xA;long unsigned int t&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  x = analogRead(A0);&#xA;  t = millis();&#xA;  float diff_t = (float)(t - pre_t)/1000.0f;&#xA;  area = (0.5 * (pre_x + x) * diff_t) + pre_area;&#xA;&#xA;  Serial.print(area);&#xA;  analogWrite(DAC0, area);&#xA;  pre_x = x;&#xA;  pre_area = area;&#xA;  pre_time = t;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11873" LastActivityDate="2017-03-29T05:37:23.620" Title="expected initializer before void arduino" Tags="|arduino-due|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14551" PostTypeId="2" ParentId="14550" CreationDate="2015-08-26T10:47:34.430" Score="1" Body="&lt;p&gt;You add the semicolon that is missing at the end of &lt;code&gt;long unsigned int t&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-26T10:47:34.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14552" PostTypeId="2" ParentId="14550" CreationDate="2015-08-26T10:49:26.010" Score="1" Body="&lt;p&gt;&lt;strong&gt;Why have you written t = 0 here and declared it again below??&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x = 0,pre_x = 0,t = 0,pre_t = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Semi Colon Missing&lt;/strong&gt;    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long unsigned int t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Where have you declared pre_time??&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  pre_time = t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-26T10:49:26.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14553" PostTypeId="2" ParentId="14550" CreationDate="2015-08-26T10:53:27.893" Score="0" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;long unsigned int t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No semicolon.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Plus, make up your mind what type &quot;t&quot; is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int x = 0,pre_x = 0,t = 0,pre_t = 0;&#xA;long unsigned int t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;long unsigned int&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I get the code to work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Avoid C++ syntax errors.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-26T10:53:27.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14554" PostTypeId="1" CreationDate="2015-08-26T11:01:34.813" Score="2" ViewCount="2433" Body="&lt;p&gt;According to the following image it is possible to use a second SPI bus on the Arduino Due by using Serial1 and SCL1 as SCK0 for SPI (or Serial2 and SCK1).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VuNPu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VuNPu.png&quot; alt=&quot;Arduino Due Pinout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=132130.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I did not find the code necessary to set up the additional SPI interfaces. I would prefer using these SPI interfaces as they are accessible on the stacking headers in contrast to the default SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally can a SD-Card be accessed using these SPI buses while still using the corresponding Arduino Library?&lt;/p&gt;&#xA;" OwnerUserId="12008" LastActivityDate="2016-01-03T04:06:17.783" Title="How to use the additional SPIs on Arduino Due" Tags="|arduino-due|sd-card|spi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14555" PostTypeId="2" ParentId="14548" CreationDate="2015-08-26T12:46:49.587" Score="2" Body="&lt;p&gt;Some sort of Current Transformer usually does the trick.  You run the AC line (not the neutral) through a ferrite core and it converts current into an output voltage.  You can find them packaged like &lt;a href=&quot;http://www.dx.com/p/yqj010504-single-phase-ac-current-sensor-module-w-active-output-deep-blue-5a-294209#.Vd20A_lVhBc&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; with a &lt;a href=&quot;https://www.google.com/search?q=ac%20current%20sensor&quot; rel=&quot;nofollow&quot;&gt;web search&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12010" LastActivityDate="2015-08-26T12:46:49.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14557" PostTypeId="2" ParentId="12079" CreationDate="2015-08-26T15:01:12.850" Score="0" Body="&lt;p&gt;You can use the new particle dev platform to do this &lt;a href=&quot;https://www.particle.io/dev&quot; rel=&quot;nofollow&quot;&gt;https://www.particle.io/dev&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-26T15:01:12.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14558" PostTypeId="2" ParentId="10257" CreationDate="2015-08-26T15:07:39.967" Score="0" Body="&lt;p&gt;You havent mentioned what exactly your robot does, for now I am going to assume it is something as simple as switching on a light etc and not something like a rover. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest way would be to make the YUN read from a db (like mysql, etc.) and depending on the value perform a task. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could have a row called &lt;strong&gt;light&lt;/strong&gt;, if the value of it is &lt;strong&gt;1&lt;/strong&gt; then turn on the light else turn off the light&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you are going to face is the power consumption as you will constantly be polling from the database. You could also look into push notifications ( I am not sure if it is applicable here)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also look into creating a private VPN and connecting the YUN and your other devices to it and then control it. &lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-26T15:07:39.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14559" PostTypeId="2" ParentId="3335" CreationDate="2015-08-26T15:16:22.143" Score="2" Body="&lt;p&gt;For this application the Arduino YUN is the worst possible solution because&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Low&lt;/strong&gt; RAM&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Terrible&lt;/strong&gt; Processor&lt;/li&gt;&#xA;&lt;li&gt;No storage (you can add a microSD card though)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;High&lt;/strong&gt; Cost&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The raspberry Pi 2, UDOO, RADXA, Ordio, pretty much anything with a &lt;strong&gt;quad core processor&lt;/strong&gt; and &lt;strong&gt;1GB of RAM&lt;/strong&gt; will do a &lt;strong&gt;decent job&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Face detection is RAM intensive, so you will need to worry about it lagging. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could also have the image processing part be done elsewhere like on a server (on a local network this could be your laptop) or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Personally&lt;/strong&gt;,I would never recommend the Arduino YUN because it just simply isnt worth paying the 75$ for when for about the same price you could have a arduino pro micro and a raspberry pi (with a WiFi adapter, mircoSD card etc.) which is capable of doing probably way more than you actually need to.&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-26T15:16:22.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14560" PostTypeId="1" AcceptedAnswerId="14574" CreationDate="2015-08-26T15:29:28.070" Score="1" ViewCount="941" Body="&lt;p&gt;I am building a simple arduino based midi controller to send cc midi messages. However I am able to send messages only through A0 (analog input).. Any help on this will be appreciated,..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;MIDI.h&amp;gt;&#xA;int pot[] = {A0,A1,A2};&#xA;int AnaPinsNum = 3;&#xA;int potIn[] = {0,0,0};&#xA;int analogValue = 0;&#xA;&#xA;int lastAnalogValue[] = {0,0,0};&#xA;&#xA;&#xA; void setup() &#xA; {&#xA;  MIDI.begin(4);&#xA;  // 115200 hairless MIDI&#xA;  Serial.begin(115200);&#xA;  int i;&#xA;  for (i = 0; i &amp;lt; 3; i++);&#xA; }&#xA; void loop() {&#xA;&#xA;  int i;&#xA;  for (i = 0; i &amp;lt; AnaPinsNum; i++)&#xA;&#xA;  potIn[i] = analogRead(pot[i])/8;&#xA;&#xA;  // potentiometer could be too sensitive and&#xA;  // give different (+-1) values.&#xA;  // send CC only when the difference between last value&#xA;  // is more than 1&#xA;  if ((potIn[i]-lastAnalogValue[i]) &amp;gt; 1 || (potIn[i]-lastAnalogValue[i]) &amp;lt; -1) {&#xA;    // value changed?&#xA;    if (potIn[i] != lastAnalogValue[i]) {&#xA;      // send serial value (ControlNumber 1, ControlValue = analogValue, Channel 1)&#xA;      // more info: http://arduinomidilib.sourceforge.net/a00001.html&#xA;      MIDI.sendControlChange(1, potIn[i], 1);&#xA;      lastAnalogValue[i] = potIn[i];&#xA;    }&#xA;  }&#xA;&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10547" LastActivityDate="2015-08-27T09:00:27.287" Title="Unable to add multiple potentiometer in Midi controller" Tags="|arduino-uno|midi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14561" PostTypeId="2" ParentId="4419" CreationDate="2015-08-26T15:33:20.947" Score="0" Body="&lt;p&gt;Answered by OP in the comments&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;fixed, I have remvoed some of the ending code thought. They were just functions for the lcd&quot;&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-08-26T15:33:20.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14562" PostTypeId="1" CreationDate="2015-08-26T15:47:59.570" Score="2" ViewCount="996" Body="&lt;p&gt;I am currently using the following code&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;IRrecv irrecv(RECV_PIN);&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; if (irrecv.decode(&amp;amp;results))&#xA;  {&#xA;   Serial.println(results.value, HEX);&#xA;   irrecv.resume(); // Receive the next value&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Serial Monitor is always returning &quot;FFFFFFFF&quot; no matter which button I press.&#xA;So I am unable to replicate the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems that the IR library doesn't support my LG remote. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I save and replicate the signal in this case?&lt;/p&gt;&#xA;" OwnerUserId="12015" LastEditorUserId="37523" LastEditDate="2019-08-06T16:31:31.727" LastActivityDate="2019-08-06T16:31:31.727" Title="How do I save IR codes from my LG Air Conditioner remote and replay them?" Tags="|serial|remote-control|ir|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 4.0" />
  <row Id="14563" PostTypeId="2" ParentId="4015" CreationDate="2015-08-26T15:48:46.840" Score="2" Body="&lt;p&gt;I think you made a mistake in the program design.  You have things backwards, and your tach interrupts are messing with program flow because they are happening too fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tachometer runs 0~100 rev/sec.  Send the pulses to the counter and, twice a second, multiply the count by 120 and display the RPM.  You only care what the RPM is to the nearest hundred, anyway, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get an ECU pulse every ~0.4m traveled.  Record the interval (x ms) between pulses in your interrupt routine.  0.4m/x ms * 1 km/1000 m * 3,600,000 ms/hr = ~1448/x km/hr.  Do the (expensive) division, using the last interval recorded, twice a second when you update the RPM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your interrupt routine is getting called every 12ms, tops, instead of 8ms typical.  And, your main loop is running at a steady 500 ms.&lt;/p&gt;&#xA;" OwnerUserId="12010" LastActivityDate="2015-08-26T15:48:46.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14564" PostTypeId="1" AcceptedAnswerId="14570" CreationDate="2015-08-26T16:34:43.963" Score="1" ViewCount="108" Body="&lt;p&gt;I am trying to make a program for my Arduino that will run 4 motors with random actions (forward,backward,left,right) and execution is determined by a random number generator. When I compile there is no errors, and The COM port is connected correctly to my Arduino Mega, but when it uploads the log says this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 668 bytes (0%) of program storage space. Maximum is 253,952 bytes.&#xA;&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 8,183 bytes for local variables. Maximum is 8,192 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means only 677 B is being used, but the Arduino file is &lt;em&gt;6 KB&lt;/em&gt;. I know that the program gets somewhat smaller when it is compiled, but not ten times smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's happening here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Arduino pins for the shift register&#xA;#define MOTORLATCH 12&#xA;#define MOTORCLK 4&#xA;#define MOTORENABLE 7&#xA;#define MOTORDATA 8&#xA;&#xA;// 8 bit bus&#xA;&#xA;#define MOTOR1_A 2&#xA;#define MOTOR1_B 3&#xA;#define MOTOR2_A 1&#xA;#define MOTOR2_B 4&#xA;#define MOTOR3_A 5&#xA;#define MOTOR3_B 7&#xA;#define MOTOR4_A 0&#xA;#define MOTOR4_B 6&#xA;&#xA;// Motor pins:&#xA;&#xA;#define MOTOR1_PWM 11&#xA;#define MOTOR2_PWM 3&#xA;#define MOTOR3_PWM 6&#xA;#define MOTOR4_PWM 5&#xA;&#xA;// LED Pins&#xA;&#xA;#define led_r 22&#xA;#define led_l 23&#xA;&#xA;// Actions&#xA;&#xA;#define RIGHT 0&#xA;#define LEFT 1&#xA;#define FORWARD 2&#xA;#define STOP 3&#xA;&#xA;// Codes for the motor function.&#xA;#define GO 1&#xA;#define REVERSE 2&#xA;#define BRAKE 3&#xA;#define RELEASE 4&#xA;&#xA;// Probability&#xA;&#xA;#define rProb 5&#xA;#define lProb 5&#xA;#define fProb 88&#xA;#define stopProb 2&#xA;&#xA;// other globals&#xA;&#xA;#define defSpd 255&#xA;&#xA;void setup() {}&#xA;&#xA;void execute(int action) {&#xA;&#xA; if (action == FORWARD) {&#xA;&#xA;  motor(1,FORWARD,defSpd);&#xA;  motor(2,FORWARD,defSpd);&#xA;  motor(3,FORWARD,defSpd);&#xA;  motor(4,FORWARD,defSpd);&#xA;&#xA;  digitalWrite(led_r, LOW);&#xA;  digitalWrite(led_l, LOW);&#xA; } else if (action == RIGHT) {&#xA;&#xA;  motor(1,REVERSE,defSpd);&#xA;  motor(2,REVERSE,defSpd);&#xA;  motor(3,FORWARD,defSpd);&#xA;  motor(4,FORWARD,defSpd);&#xA;&#xA;  digitalWrite(led_l, LOW);&#xA;  digitalWrite(led_r, HIGH);&#xA;  delay(150);&#xA;&#xA; } else if (action == LEFT) {&#xA;&#xA;  motor(1,FORWARD,defSpd);&#xA;  motor(2,FORWARD,defSpd);&#xA;  motor(3,REVERSE,defSpd);&#xA;  motor(4,REVERSE,defSpd);&#xA;&#xA;  digitalWrite(led_l, HIGH);&#xA;  digitalWrite(led_r, LOW);&#xA;&#xA;  delay(150);&#xA;&#xA; } else if (action == STOP) {&#xA;&#xA;  motor(1,BRAKE,defSpd);&#xA;  motor(2,BRAKE,defSpd);&#xA;  motor(3,BRAKE,defSpd);&#xA;  motor(4,BRAKE,defSpd);&#xA;&#xA;  digitalWrite(led_r, HIGH);&#xA;  digitalWrite(led_l, HIGH);&#xA;&#xA;  delay(1000);&#xA;&#xA; } &#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  // Random action&#xA;  int i = (1, 101);&#xA;&#xA;  if (i &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt;= rProb) {&#xA;&#xA;    execute(RIGHT);&#xA;&#xA;  } else if (i &amp;gt; rProb &amp;amp;&amp;amp; i &amp;lt;= rProb + lProb) {&#xA;&#xA;    execute(LEFT);&#xA;&#xA;  } else if (i &amp;gt; rProb + lProb &amp;amp;&amp;amp; i &amp;lt;= rProb + lProb + fProb) {&#xA;&#xA;    execute(FORWARD);&#xA;&#xA;  } else if (i &amp;gt; rProb + lProb + fProb &amp;amp;&amp;amp; i &amp;lt;= rProb + lProb + fProb + stopProb) {&#xA;&#xA;    execute(STOP);&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void motor(int nMotor, int command, int speed)&#xA;{&#xA;  int motorA, motorB;&#xA;&#xA;  if (nMotor &amp;gt;= 1 &amp;amp;&amp;amp; nMotor &amp;lt;= 4)&#xA;  {  &#xA;    switch (nMotor)&#xA;    {&#xA;    case 1:&#xA;      motorA   = MOTOR1_A;&#xA;      motorB   = MOTOR1_B;&#xA;      break;&#xA;    case 2:&#xA;      motorA   = MOTOR2_A;&#xA;      motorB   = MOTOR2_B;&#xA;      break;&#xA;    case 3:&#xA;      motorA   = MOTOR3_A;&#xA;      motorB   = MOTOR3_B;&#xA;      break;&#xA;    case 4:&#xA;      motorA   = MOTOR4_A;&#xA;      motorB   = MOTOR4_B;&#xA;      break;&#xA;    default:&#xA;      break;&#xA;    }&#xA;&#xA;    switch (command)&#xA;    {&#xA;    case GO:&#xA;      motor_output (motorA, HIGH, speed);&#xA;      motor_output (motorB, LOW, -1);     // -1: no PWM set&#xA;      break;&#xA;    case REVERSE:&#xA;      motor_output (motorA, LOW, speed);&#xA;      motor_output (motorB, HIGH, -1);    // -1: no PWM set&#xA;      break;&#xA;    case BRAKE:&#xA;      // The AdaFruit library didn't implement a brake.&#xA;      // The L293D motor driver ic doesn't have a good&#xA;      // brake anyway.&#xA;      // It uses transistors inside, and not mosfets.&#xA;      // Some use a software break, by using a short&#xA;      // reverse voltage.&#xA;      // This brake will try to brake, by enabling &#xA;      // the output and by pulling both outputs to ground.&#xA;      // But it isn't a good break.&#xA;      motor_output (motorA, LOW, 255); // 255: fully on.&#xA;      motor_output (motorB, LOW, -1);  // -1: no PWM set&#xA;      break;&#xA;    case RELEASE:&#xA;      motor_output (motorA, LOW, 0);  // 0: output floating.&#xA;      motor_output (motorB, LOW, -1); // -1: no PWM set&#xA;      break;&#xA;    default:&#xA;      break;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void motor_output (int output, int high_low, int speed)&#xA;{&#xA;  int motorPWM;&#xA;&#xA;  switch (output)&#xA;  {&#xA;  case MOTOR1_A:&#xA;  case MOTOR1_B:&#xA;    motorPWM = MOTOR1_PWM;&#xA;    break;&#xA;  case MOTOR2_A:&#xA;  case MOTOR2_B:&#xA;    motorPWM = MOTOR2_PWM;&#xA;    break;&#xA;  case MOTOR3_A:&#xA;  case MOTOR3_B:&#xA;    motorPWM = MOTOR3_PWM;&#xA;    break;&#xA;  case MOTOR4_A:&#xA;  case MOTOR4_B:&#xA;    motorPWM = MOTOR4_PWM;&#xA;    break;&#xA;  default:&#xA;    // Use speed as error flag, -3333 = invalid output.&#xA;    speed = -3333;&#xA;    break;&#xA;  }&#xA;&#xA;  if (speed != -3333)&#xA;  {&#xA;    // Set the direction with the shift register &#xA;    // on the MotorShield, even if the speed = -1.&#xA;    // In that case the direction will be set, but&#xA;    // not the PWM.&#xA;    shiftWrite(output, high_low);&#xA;&#xA;    // set PWM only if it is valid&#xA;    if (speed &amp;gt;= 0 &amp;amp;&amp;amp; speed &amp;lt;= 255)    &#xA;    {&#xA;      analogWrite(motorPWM, speed);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void shiftWrite(int output, int high_low)&#xA;{&#xA;  static int latch_copy;&#xA;  static int shift_register_initialized = false;&#xA;&#xA;  // Do the initialization on the fly, &#xA;  // at the first time it is used.&#xA;  if (!shift_register_initialized)&#xA;  {&#xA;    // Set pins for shift register to output&#xA;    pinMode(MOTORLATCH, OUTPUT);&#xA;    pinMode(MOTORENABLE, OUTPUT);&#xA;    pinMode(MOTORDATA, OUTPUT);&#xA;    pinMode(MOTORCLK, OUTPUT);&#xA;&#xA;    // Set pins for shift register to default value (low);&#xA;    digitalWrite(MOTORDATA, LOW);&#xA;    digitalWrite(MOTORLATCH, LOW);&#xA;    digitalWrite(MOTORCLK, LOW);&#xA;    // Enable the shift register, set Enable pin Low.&#xA;    digitalWrite(MOTORENABLE, LOW);&#xA;&#xA;    // start with all outputs (of the shift register) low&#xA;    latch_copy = 0;&#xA;&#xA;    shift_register_initialized = true;&#xA;  }&#xA;&#xA;  // The defines HIGH and LOW are 1 and 0.&#xA;  // So this is valid.&#xA;  bitWrite(latch_copy, output, high_low);&#xA;&#xA;  // Use the default Arduino 'shiftOut()' function to&#xA;  // shift the bits with the MOTORCLK as clock pulse.&#xA;  // The 74HC595 shiftregister wants the MSB first.&#xA;  // After that, generate a latch pulse with MOTORLATCH.&#xA;  shiftOut(MOTORDATA, MOTORCLK, MSBFIRST, latch_copy);&#xA;  delayMicroseconds(5);    // For safety, not really needed.&#xA;  digitalWrite(MOTORLATCH, HIGH);&#xA;  delayMicroseconds(5);    // For safety, not really needed.&#xA;  digitalWrite(MOTORLATCH, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12016" LastEditorUserId="12016" LastEditDate="2015-08-26T18:20:04.053" LastActivityDate="2015-08-26T18:27:30.537" Title="Arduino Program uses less RAM then expected and doesn't run" Tags="|programming|arduino-mega|sketch|arduino-motor-shield|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14565" PostTypeId="1" AcceptedAnswerId="14566" CreationDate="2015-08-26T17:10:01.027" Score="0" ViewCount="1503" Body="&lt;p&gt;I recently created a circuit to read the value from two sets of buttons using only two analog pins. It involves setting one pin &lt;code&gt;HIGH&lt;/code&gt; and reading the input on the other pin and then swapping. With both pins set to &lt;code&gt;OUTPUT&lt;/code&gt; I can still read in values with &lt;code&gt;analogRead()&lt;/code&gt; without having to keep switching pin modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is why is that the case? What is the point of setting a pin to &lt;code&gt;INPUT&lt;/code&gt; if &lt;code&gt;OUTPUT&lt;/code&gt; can still read in values? Are there any disadvantages of doing so?&lt;/p&gt;&#xA;" OwnerUserId="11602" LastActivityDate="2020-09-20T03:06:14.887" Title="Why should a pin be set as an input if it can read input when set as output?" Tags="|pins|input|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14566" PostTypeId="2" ParentId="14565" CreationDate="2015-08-26T17:12:07.323" Score="1" Body="&lt;p&gt;The reason for this is because &lt;code&gt;analogRead()&lt;/code&gt; has absolutely nothing to do with what mode the pin is in.  That mode only has any meaning in the scope of &lt;em&gt;digital&lt;/em&gt; operations - i.e., when using &lt;code&gt;digitalRead()&lt;/code&gt; and &lt;code&gt;digitalWrite()&lt;/code&gt;.  When using &lt;code&gt;analogRead()&lt;/code&gt; the Arduino code switches the pin into analog mode first and then reads from it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-26T17:12:07.323" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14567" PostTypeId="1" CreationDate="2015-08-26T17:45:35.100" Score="2" ViewCount="1014" Body="&lt;p&gt;I would like to create some QNX applications and test them in a hardware different than my virtual machine. Since Arduino Due board is based on the Atmel SAM3X8E ARM Cortex-M3 CPU and QNX® Neutrino® RTOS supports that processor, I was wondering if it is possible make them work together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the challenges to make it work?&lt;/p&gt;&#xA;" OwnerDisplayName="user12018" LastActivityDate="2016-02-06T12:04:12.153" Title="Is it possible to setup a system based on Arduino Due running QNX?" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14568" PostTypeId="2" ParentId="14565" CreationDate="2015-08-26T18:01:40.587" Score="0" Body="&lt;p&gt;Because I/O pins can be used for either digital input or digital output and can be switched to perform in a given direction. Some of the pins also have an analog capability, either A-to-D conversion (input) or PWM (kind of a psuedo-analog output) but only in one direction permanently assigned by the hardware and therefore not switchable from one to the other. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-26T18:01:40.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14569" PostTypeId="2" ParentId="14527" CreationDate="2015-08-26T18:13:17.713" Score="0" Body="&lt;p&gt;Unless you have some really specific reason to use a UNO, for example using the 2nd ATMega on the board, you would be much better off with an Micro Pro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On ebay you can find both 3.3V and 5V versions.&#xA;You can even find ones that have redundant pins, to accommodate for a permanent installation of the ISP programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you happen to have a shield that is compatible with the UNO pinout, you could still wire it with a flat cable and save space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Said this, using mechanical means on a PCB is always putting at risk the tracks, which might come off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Desoldering is better, since it's reversible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you might find that it takes an unusually powerful soldering iron, compared to what is used nowadays for smd components, as you will have to heat up simultaneously several large pads, which have connected large tracks and ground areas that act as heat sink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you do not have desoldering braid and or pump, there's a hackish method to remove large components with multiple pads: flood them in molten solder and literally shake them off the board by hitting the workbench sideways, while the solder is still fluid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not nice and at risk of adding splash shorts to the board, not to mention the splash damage to the operator: it can cause burns on unprotected skin or organs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if done correctly, it works without pump or braid.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-26T18:13:17.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14570" PostTypeId="2" ParentId="14564" CreationDate="2015-08-26T18:27:30.537" Score="3" Body="&lt;p&gt;What is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Random action&#xA;int i = (1, 101);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;supposed to achieve?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/tmp/untitled1/untitled1.ino: In function 'void loop()':&#xA;/tmp/untitled1/untitled1.ino:110:13: warning: left operand of comma operator has no effect [-Wunused-value]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ergo, &lt;code&gt;i&lt;/code&gt; is always going to be 101.  So all the &lt;code&gt;if&lt;/code&gt; constructs will be false, so they get optimized out (they are all constants).  Because of that the other functions are never getting called, so they are optimized out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you are left with next to nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you may have missed the word &lt;code&gt;random&lt;/code&gt; out from there...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Program size: 2798 bytes&lt;/li&gt;&#xA;&lt;li&gt;Memory size: 17 bytes&lt;/li&gt;&#xA;&lt;li&gt;Compilation took 0.227 seconds&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-26T18:27:30.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14571" PostTypeId="2" ParentId="14567" CreationDate="2015-08-26T18:40:06.300" Score="0" Body="&lt;p&gt;Typically the challenge in porting a new OS to a board is to configure stuff like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;system clock (to drive the scheduler of the OS at the right frequence)&lt;/li&gt;&#xA;&lt;li&gt;board specific I/O&lt;/li&gt;&#xA;&lt;li&gt;components that are not part of the SoC (but iirc DUE doesn't have any of these)&lt;/li&gt;&#xA;&lt;li&gt;individual HW blocks (like on which serial port redirect the character interface, if your application has any)&lt;/li&gt;&#xA;&lt;li&gt;wakeup sources, in case you have/want low power modes and you need the board to wake up when something specific happens&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;None of these are impossible tasks and they are all good to learn more about the system, but otoh it's unlikely you can rush through them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good news is that probably you will not need them all and not immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But some you will have to perform and they will require understanding how your OS works and having the technical reference manual of your board and SoC.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-26T18:40:06.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14572" PostTypeId="1" CreationDate="2015-08-26T20:10:59.413" Score="1" ViewCount="5275" Body="&lt;p&gt;I have an ATmeg328 TQFP on a board (in system). I use an Arduino Uno as an ISP to programm the chip. However, i would like to use Serial Communication with the chip through the Arduino board. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is this possible?&lt;/li&gt;&#xA;&lt;li&gt;If yes, how can i realize this?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;EDIT: i have the tx and RX pins not available. The chip is on a board. With through arduino board, I mean that I would like to use the miso mosi sck pins to do this.&lt;/p&gt;&#xA;" OwnerUserId="12020" LastEditorUserId="12020" LastEditDate="2015-08-27T20:06:19.033" LastActivityDate="2020-09-13T04:39:42.590" Title="Arduino as ISP with serial monitor for ATmega328" Tags="|serial|atmega328|arduinoisp|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14573" PostTypeId="1" CreationDate="2015-08-26T20:27:14.910" Score="1" ViewCount="354" Body="&lt;p&gt;I have a pretty complicated setup: an ATMEGA328p chip (found in the Uno, Duemilanove, etc.) on a Diavolino board (from EvilMadScientist) running at 8 MHz (instead of the normal 16 MHz).  This should be basically the same thing as the 3.3V arduino pro from the code's point of view.  On top of this is a custom shield including a bunch of digital and analog devices with SPI, I2C, and serial interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is supposed to run for days or weeks at a time.  In normal conditions--on the ground outside--it does fine.  However, in two recent tests, it lost its program and stopped working.  One of these was in a cold low-pressure chamber (-40 C/F).  The other was outside mounted on a flying quadcopter.  Reprogramming it fixed the problem; before reprogramming, neither a reset nor power-cycling would get any response from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone ever heard of an arduino bricking itself like that?  My best idea for how this could happen is that somehow the chip was put into a state where it treated incoming serial data as a new program to run.  Also, I'm speculating that connections between the two boards could have been disrupted by thermal contraction or vibration in those tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;" OwnerUserId="7419" LastActivityDate="2015-08-27T00:03:31.110" Title="Arduino loses its program under unusual conditions" Tags="|serial|shields|uploading|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14574" PostTypeId="2" ParentId="14560" CreationDate="2015-08-26T20:55:48.517" Score="0" Body="&#xA;&#xA;&lt;p&gt;Your logic is flawed here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  int i;&#xA;  for (i = 0; i &amp;lt; AnaPinsNum; i++)&#xA;    potIn[i] = analogRead(pot[i]) / 8;&#xA;&#xA;  // potentiometer could be too sensitive and&#xA;  // give different (+-1) values.&#xA;  // send CC only when the difference between last value&#xA;  // is more than 1&#xA;  if ((potIn[i] - lastAnalogValue[i]) &amp;gt; 1 || (potIn[i] - lastAnalogValue[i]) &amp;lt; -1) {&#xA;    // value changed?&#xA;    if (potIn[i] != lastAnalogValue[i]) {&#xA;      // send serial value (ControlNumber 1, ControlValue = analogValue, Channel 1)&#xA;      // more info: http://arduinomidilib.sourceforge.net/a00001.html&#xA;      MIDI.sendControlChange(1, potIn[i], 1);&#xA;      lastAnalogValue[i] = potIn[i];&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first three lines read all three analog pins:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  int i;&#xA;  for (i = 0; i &amp;lt; AnaPinsNum; i++)&#xA;&#xA;    potIn[i] = analogRead(pot[i]) / 8;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However then, outside the loop, you are using the value of &lt;code&gt;i&lt;/code&gt; which will now be 4, and outside the array bounds. You need to bracket the whole lot, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  int i;&#xA;  for (i = 0; i &amp;lt; AnaPinsNum; i++)&#xA;    {   // &amp;lt;------------------------------- add this&#xA;    potIn[i] = analogRead(pot[i]) / 8;&#xA;&#xA;    // potentiometer could be too sensitive and&#xA;    // give different (+-1) values.&#xA;    // send CC only when the difference between last value&#xA;    // is more than 1&#xA;    if ((potIn[i] - lastAnalogValue[i]) &amp;gt; 1 || (potIn[i] - lastAnalogValue[i]) &amp;lt; -1) &#xA;      {&#xA;      // value changed?&#xA;      if (potIn[i] != lastAnalogValue[i]) &#xA;        {&#xA;        // send serial value (ControlNumber 1, ControlValue = analogValue, Channel 1)&#xA;        // more info: http://arduinomidilib.sourceforge.net/a00001.html&#xA;        MIDI.sendControlChange(1, potIn[i], 1);&#xA;        lastAnalogValue[i] = potIn[i];&#xA;        }  // end of not same as before&#xA;      }   // end of value changed&#xA;    }   // &amp;lt;----------------- add this&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If pot one is sending out Controller number 1 and channel number 1, 2nd pot should send Controller number 2 and channel no 2.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I understand your question correctly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;MIDI.sendControlChange(1, potIn[i], 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;MIDI.sendControlChange(i, potIn[i], i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-27T09:00:27.287" LastActivityDate="2015-08-27T09:00:27.287" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14575" PostTypeId="2" ParentId="14565" CreationDate="2015-08-26T22:03:53.423" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is why is that the case? What is the point of setting a pin to INPUT if OUTPUT can still read in values? Are there any disadvantages of doing so?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you do a &lt;code&gt;digitalRead&lt;/code&gt; you can read the current latched state of an &lt;strong&gt;output&lt;/strong&gt; pin (it doesn't change it to input). In other words, you read what was last written to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do a &lt;code&gt;digitalWrite&lt;/code&gt; of HIGH to an &lt;strong&gt;input&lt;/strong&gt; pin it sets the internal pull-up. If you write LOW it disables the internal pull-up. If it switched it to output for you, you wouldn't be able to enable or disable the pull-up. (Note: this applies to older versions of the IDE, newer ones have a pinMode setting of INPUT_PULLUP).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the point of setting a pin to INPUT if OUTPUT can still read in values? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That certainly won't work with &lt;code&gt;digitalRead&lt;/code&gt; because you are writing a value to the pin in OUTPUT mode, so you will merely read back what you are writing. In other words, you have activated the driver transistors, which will override whatever value you are trying to read.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-26T22:03:53.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14576" PostTypeId="1" AcceptedAnswerId="14579" CreationDate="2015-08-26T22:42:46.753" Score="1" ViewCount="10787" Body="&lt;p&gt;Im getting this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iotHook.ino: In function 'void setup()':&#xA;iotHook:13: error: request for member 'begin' in 'esp', which is of non-class type 'Esp8266()'&#xA;request for member 'begin' in 'esp', which is of non-class type 'Esp8266()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to lunch my begin function of my class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Esp8266 {&#xA;&#xA;  public:&#xA;    Esp8266();&#xA;    void begin(HardwareSerial *wifiCom, HardwareSerial *debugCom);&#xA;    ...&#xA;  private:&#xA;&#xA;    HardwareSerial *wifiCom;&#xA;    HardwareSerial *debugCom;&#xA;    ...&#xA;&#xA;}&#xA;&#xA;Esp8266::Esp8266() {&#xA;}&#xA;&#xA;void Esp8266::begin(HardwareSerial *wifiCom, HardwareSerial *debugCom) {&#xA;  this-&amp;gt;wifiCom = wifiCom;&#xA;  this-&amp;gt;debugCom = debugCom;&#xA;&#xA;  this-&amp;gt;debugCom-&amp;gt;begin(115200);&#xA;  while (!this-&amp;gt;debugCom) {&#xA;  ;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LsAdO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LsAdO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1:&#xA;Updated image with new code&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Io6tr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Io6tr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is not picking up the begin function?&lt;/p&gt;&#xA;" OwnerUserId="12021" LastEditorUserId="12021" LastEditDate="2015-08-26T22:51:41.590" LastActivityDate="2015-08-27T09:49:41.317" Title="Request for member is Non-class type" Tags="|c++|arduino-leonardo|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14577" PostTypeId="2" ParentId="14576" CreationDate="2015-08-26T22:47:20.217" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/a/877538/20862&quot;&gt;You've confused the compiler&lt;/a&gt; by making it think that &lt;code&gt;esp&lt;/code&gt; is a function that takes no arguments and returns a &lt;code&gt;Esp8266&lt;/code&gt;. But the no-argument constructor is called by default, so you don't need the parens there regardless.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Esp8266 esp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-08-26T22:47:20.217" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14578" PostTypeId="2" ParentId="14576" CreationDate="2015-08-26T22:52:21.057" Score="0" Body="&#xA;&#xA;&lt;p&gt;The line: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;esp.begin (Serial, Serial1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;esp.begin (&amp;amp;Serial, &amp;amp;Serial1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is expecting a &lt;strong&gt;pointer&lt;/strong&gt; to a HardwareSerial instance.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also make the instantiation line:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Esp8266 esp;   // &amp;lt;--------- no brackets!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This compiles without errors for me:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class Esp8266 {&#xA;&#xA;  public:&#xA;    Esp8266();&#xA;    void begin(HardwareSerial *wifiCom, HardwareSerial *debugCom);&#xA;  private:&#xA;&#xA;    HardwareSerial *wifiCom;&#xA;    HardwareSerial *debugCom;&#xA;&#xA;};&#xA;&#xA;Esp8266::Esp8266() {&#xA;}&#xA;&#xA;void Esp8266::begin(HardwareSerial *wifiCom, HardwareSerial *debugCom) {&#xA;  this-&amp;gt;wifiCom = wifiCom;&#xA;  this-&amp;gt;debugCom = debugCom;&#xA;&#xA;  this-&amp;gt;debugCom-&amp;gt;begin(115200);&#xA;  while (!this-&amp;gt;debugCom) {&#xA;  ;&#xA;  }&#xA;}&#xA;&#xA;Esp8266 esp;&#xA;&#xA;void setup ()&#xA;  {&#xA;  esp.begin (&amp;amp;Serial, &amp;amp;Serial1);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would rework to use references anyway, saves all that mucking around with pointers:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class Esp8266 {&#xA;  public:&#xA;    Esp8266(HardwareSerial &amp;amp; wifiCom, HardwareSerial &amp;amp; debugCom);&#xA;    void begin();&#xA;  private:&#xA;    HardwareSerial &amp;amp; wifiCom;&#xA;    HardwareSerial &amp;amp; debugCom;&#xA;  };&#xA;&#xA;// constructor&#xA;Esp8266::Esp8266(HardwareSerial &amp;amp;wifiCom_, HardwareSerial &amp;amp;debugCom_)&#xA;  : wifiCom (wifiCom_), debugCom (debugCom_)&#xA;  {&#xA;  }&#xA;&#xA;// initialize stuff&#xA;void Esp8266::begin()&#xA;{&#xA;  debugCom.begin(115200);&#xA;  while (!debugCom)&#xA;  {&#xA;  }&#xA;}&#xA;&#xA;Esp8266 esp (Serial, Serial1);&#xA;&#xA;void setup ()&#xA;{&#xA;  esp.begin ();&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Corrected for Leonardo&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Sorry, my reply above was compiled for the Mega2560, I didn't notice the Leonardo tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Majenko is quite right, you need to rework for the Leonardo. My example using references can reduce down to this now:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class Esp8266 {&#xA;  public:&#xA;    Esp8266(Stream &amp;amp; wifiCom, Stream &amp;amp; debugCom)&#xA;      : wifiCom_ (wifiCom), debugCom_ (debugCom) { }&#xA;&#xA;  private:&#xA;    Stream &amp;amp; wifiCom_;&#xA;    Stream &amp;amp; debugCom_;&#xA;  };&#xA;&#xA;Esp8266 esp (Serial, Serial1);&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  while (!Serial) { }&#xA;  Serial1.begin (115200);&#xA;  while (!Serial1) { }&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By storing a Stream type you can still print to them, however you need to initialize in &lt;code&gt;setup&lt;/code&gt;, not in the &lt;code&gt;begin&lt;/code&gt; function, which now becomes redundant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree about not using &lt;code&gt;this-&amp;gt;&lt;/code&gt; although my preference is for trailing underscores as the use of leading underscores is reserved in quite a few cases, depending on the location and capitalization.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-26T23:23:30.697" LastActivityDate="2015-08-26T23:23:30.697" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14579" PostTypeId="2" ParentId="14576" CreationDate="2015-08-26T23:06:55.017" Score="2" Body="&lt;p&gt;Your current problem is that the USB Serial interface of the Leonardo isn't a hardware serial device, it's a CDC/ACM device, and the class for that isn't HardwareSerial, it's Serial_.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can't pass it to a function that expects a HardwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should be using, instead, is the Stream class.  That will allow you to pass any object that is based on the Stream class, such as HardwareSerial, Serial_, Client, etc.  Many different things, including serial and networking protocols, use Stream as their base class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does have the down side, though, that you have to initialize the Stream objects in your sketch (that is, do the Serial.begin(...) and Serial1.begin(...) in your sketch not your class) because the Stream class doesn't have the concept of a baud rate, and so no begin(baud) function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Esp8266 {&#xA;&#xA;public:&#xA;    Esp8266();&#xA;    void begin(Stream &amp;amp;wifiCom, Stream &amp;amp;debugCom);&#xA;private:&#xA;&#xA;    Stream *_wifiCom;&#xA;    Stream *_debugCom;&#xA;&#xA;};&#xA;&#xA;Esp8266::Esp8266() {&#xA;}&#xA;&#xA;void Esp8266::begin(Stream &amp;amp;wifiCom, Stream &amp;amp;debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;&#xA;    while (!_debugCom) {&#xA;        ;&#xA;    }&#xA;}&#xA;&#xA;Esp8266 esp;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    Serial1.begin(115200);&#xA;    esp.begin(Serial, Serial1);&#xA;}  // end of setup&#xA;&#xA;void loop() {&#xA;}  // end of&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, as well, my use of pass-by-reference (Stream &amp;amp;whatever) so you don't have to pass a pointer in your begin function.  Also notice the use of unique variable names in the class (I always prefix my member variables with &lt;code&gt;_&lt;/code&gt;) so you don't have to keep putting &lt;code&gt;this-&amp;gt;&lt;/code&gt; in everywhere.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To be able to move the &lt;code&gt;.begin()&lt;/code&gt; function inside your class you will have to use both &lt;code&gt;HardwareSerial&lt;/code&gt; and &lt;code&gt;Serial_&lt;/code&gt; object types within your class.  There's two ways this may be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First is &lt;a href=&quot;http://en.cppreference.com/w/cpp/language/dynamic_cast&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;dynamic casting&lt;/em&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Esp8266::begin(Stream &amp;amp;wifiCom, Stream *debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;&#xA;    HardwareSerial *hard;&#xA;    Serial_ *cdc;&#xA;&#xA;    if (hard = dynamic_cast&amp;lt;HardwareSerial*&amp;gt;(_wifiCom)) {&#xA;        hard-&amp;gt;begin(115200);&#xA;    } else if (cdc = dynamic_cast&amp;lt;Serial_*&amp;gt;(_wifiCom)) {&#xA;        cdc-&amp;gt;begin(115200);&#xA;    }&#xA;&#xA;    if (hard = dynamic_cast&amp;lt;HardwareSerial*&amp;gt;(_debugCom)) {&#xA;        hard-&amp;gt;begin(115200);&#xA;    } else if (cdc = dynamic_cast&amp;lt;Serial_*&amp;gt;(_debugCom)) {&#xA;        cdc-&amp;gt;begin(115200);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested this, and I don't know if the Arduino's cut-down C++ library is even capable of it, but it's worth a try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other method is to &lt;em&gt;overload&lt;/em&gt; the &lt;code&gt;.begin()&lt;/code&gt; function of your class with multiple versions that take different parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Esp8266::begin(Serial_ &amp;amp;wifiCom, HardwareSerial *debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;    wifiCom.begin(115200);&#xA;    debugCom.begin(115200);&#xA;}&#xA;&#xA;void Esp8266::begin(HardwareSerial &amp;amp;wifiCom, HardwareSerial *debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;    wifiCom.begin(115200);&#xA;    debugCom.begin(115200);&#xA;}&#xA;&#xA;void Esp8266::begin(HardwareSerial &amp;amp;wifiCom, Serial_ *debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;    wifiCom.begin(115200);&#xA;    debugCom.begin(115200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're still storing them internally as &lt;code&gt;Stream&lt;/code&gt; objects in all cases, but within the &lt;code&gt;begin()&lt;/code&gt; function itself you also have them available as their child classes.  It does mean you have duplicate code copied between the different versions of &lt;code&gt;begin()&lt;/code&gt;.  You could modularize it a little more though by moving the duplicated code into functions which would only need to be duplicated twice, not three times - one to act on a single &lt;code&gt;Serial_&lt;/code&gt; object and one to act on a single &lt;code&gt;HardwareSerial&lt;/code&gt; object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Esp8266::initSerial(Serial_ *ser) {&#xA;    ser-&amp;gt;begin(115200);&#xA;}&#xA;&#xA;void Esp8266::initSerial(HardwareSerial *ser) {&#xA;    ser-&amp;gt;begin(115200);&#xA;}&#xA;&#xA;void Esp8266::begin(Serial_ &amp;amp;wifiCom, HardwareSerial *debugCom) {&#xA;    _wifiCom = &amp;amp;wifiCom;&#xA;    _debugCom = &amp;amp;debugCom;&#xA;    initSerial(&amp;amp;wifiCom);&#xA;    initSerial(&amp;amp;debugCom);&#xA;}&#xA;... etc x3 ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-08-27T09:49:41.317" LastActivityDate="2015-08-27T09:49:41.317" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14580" PostTypeId="2" ParentId="14573" CreationDate="2015-08-27T00:03:31.110" Score="1" Body="&lt;p&gt;I would suggest that you reproduce the issue and then use a device capable of &lt;em&gt;reading&lt;/em&gt; the flash, to confirm that it's still identical to the .hex file that was used to program the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the AVRDragon can do it and maybe also cheaper USB ISP programmers can do it too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it seems that &lt;a href=&quot;https://www.physicsforums.com/threads/nor-flash-failures-at-extreme-low-temperatures.207832/&quot; rel=&quot;nofollow&quot;&gt;you are not alone&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flash memories like those used in uC work by trapping electrons in wells of charge, so that they pseudo-permanently affect the silicon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very low temperatures can change the properties of the insulation, letting many more electrons than usual to escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to wrap the board in a thermal airtight insulator, possibly providing local heating. That should solve your problems.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-27T00:03:31.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14581" PostTypeId="1" CreationDate="2015-08-27T02:24:53.563" Score="1" ViewCount="1191" Body="&lt;p&gt;I have an application that requires reading sensors and moving a stepper motor.&#xA;The sensors draw about 200mA between them, and need 5V to work. (Too much to draw through the Arduino, I thought) The stepper is recommended to run off 12V, and is driven through a BigEasy board. And, of course, the Arduino needs 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My actual setup has an old laptop power brick, which puts out nominally 12V. This is fed into a voltage regulator (one of the cheap ones with a voltmeter built in) which outputs a steady 5V, even if the input voltage changes a bit. So, I've got a reasonable 12V supply and a fairly fixed 5V supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the 5V supply, I run wiring to the sensors, and from the 12V supply I wire the stepper driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, to power the Arduino, I thought I could just wire up a USB socket (only the power lines) and wire the USB socket to the 5V regulated output. Then I could either plug my arduino into my computer to program it, or plug it into the dummy usb socket to power it standalone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This arrangement seemed to work for a while, but I've noticed strange behaviour with the 2x16 LCD board which is also attached. I should point out that the LCD takes it's power from the regulated 5V, not from the 5V rail of the Arduino, although the data lines go to the Arduino. The LCD has gone into a &quot;lock-down&quot; mode whereby it only displays half blocks on the top line and nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if it could be related to effectively powering the system with 2 supplies; one for the majority of the load through the old laptop power brick, and the Arduino through the USB port of my (also laptop) PC. Somewhere along the line, ground get connected to ground, but are all grounds equal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a standard solution for having the Arduino plugged into your development PC (so as to get debug messages through the Serial COM monitor) whilst still be able to safely power the high-draw loads of the rest of the system. I did consider powering the Arduino through it's barrel jack, but then I'll need an additional 7V supply. (The 5V regulated supply would be too much, and the 12V &quot;semi-regulated&quot; supply would be too much).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And can I do something to protect the next LCD that I use? (Stick a 5.2V Zener across the power pins to prevent spikes??)&lt;/p&gt;&#xA;" OwnerUserId="11984" LastActivityDate="2015-08-31T00:58:16.207" Title="Powering arduino and sensors and motor damaging 16x2 LCD?" Tags="|power|lcd|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14582" PostTypeId="1" CreationDate="2015-08-27T03:56:35.457" Score="2" ViewCount="706" Body="&lt;p&gt;I have extracted a speaker frim a cheap radio. And I want to connect it to arduino uno. But, I dont know the rating of the speaker. And I am Afraid that If it is over rated, it can fry my arduino. The diameter of the speaker is 9 cm (approx). Whether this Speaker is more likely to be  of 4 ohms, 8 ohms, or 16 ohms ???&#xA;I dont have a multimeter...What cam be the probable value of speaker ?&lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="11772" LastEditDate="2015-08-27T04:19:24.313" LastActivityDate="2015-08-27T04:46:41.993" Title="Knowing the Ohms of a Radio Speaker" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14583" PostTypeId="2" ParentId="14582" CreationDate="2015-08-27T04:15:02.897" Score="1" Body="&lt;p&gt;I googled &quot;measure speaker resistance&quot; and found &lt;a href=&quot;http://www.wikihow.com/Measure-Speaker-Impedance&quot; rel=&quot;nofollow&quot;&gt;http://www.wikihow.com/Measure-Speaker-Impedance&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step by step instructions&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need a multimeter - a great thing to have in any case.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-27T04:15:02.897" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14584" PostTypeId="2" ParentId="14582" CreationDate="2015-08-27T04:41:21.573" Score="1" Body="&lt;p&gt;I'm not aware of any simple rule that relates speaker diameter to speaker impedance.  Traditionally, 8 Ω is quite likely for typical cheap speakers, with 4 Ω not far behind in likelihood. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the &lt;a href=&quot;http://www.wikihow.com/Measure-Speaker-Impedance&quot; rel=&quot;nofollow&quot;&gt;Measure Speaker Impedance&lt;/a&gt; link that AMADANON gave, the DC resistance of the speaker's coil will be somewhat lower than the speaker's AC  impedance.  The link suggests 6 Ω DC resistance for a speaker with 8 Ω impedance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as driving the speaker from an Arduino output pin, all of the likely values of speaker impedance are too low to allow driving it directly.  Dividing the maximum allowed pin current of 40 mA into 5 V gives 125 Ω as the least resistance an Arduino output should ever see.  When I attach a speaker to an Arduino output, I usually put a 200 to 400 Ω resistor in series with it.  For my purposes (eg alert-buzzers) that gives enough volume without overstressing the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still have the radio, look for a small transformer near the speaker connection.  If the radio has an audio output transformer, it probably will have a few KΩ of resistance in the primary and a low-resistance secondary.  If you attach the primary of that transformer to the Arduino pin you can deliver slightly more power to the speaker, but may need some  &lt;a href=&quot;https://www.google.com/search?q=clipping+diodes&amp;amp;biw=1112&amp;amp;bih=593&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0CCwQsARqFQoTCNXa8qC6yMcCFckziAodpccJmw&quot; rel=&quot;nofollow&quot;&gt;clipping diodes&lt;/a&gt; or &lt;a href=&quot;https://www.google.com/search?q=clipping+diodes&amp;amp;biw=1112&amp;amp;bih=593&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0CCwQsARqFQoTCNXa8qC6yMcCFckziAodpccJmw#tbm=isch&amp;amp;q=flyback+diodes&quot; rel=&quot;nofollow&quot;&gt;flyback diodes&lt;/a&gt; in the circuit to prevent damage from overvoltages.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-08-27T04:46:41.993" LastActivityDate="2015-08-27T04:46:41.993" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14585" PostTypeId="1" CreationDate="2015-08-27T07:14:13.210" Score="2" ViewCount="118" Body="&lt;p&gt;I have the following problem and wonder if anyone may have some inside into what may be happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an array of 20 leds that i manage to multiplex using the attiny88 using only 9 pins (4 columns by 5 rows). At any given time only one led is on. The different leds are activated with a pushbutton. Initially, i used five transistors with a 1k resistor to turn on and off the rows of the led array. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything worked like a charm even at voltages as low as 2.5 vol. I then decided to remove the transistors to free-up some space in my pcb. Now the circuit works well at voltages above four but at 2.5v it makes leds to turn on randomly, when pressing the pushbutton. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I presume this behavior is because the one led is taking to much current, but i wonder why could be the case if the chip is only driving one led at a time. Also keep in mind that the circuit works very well at 4vol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clue about this and how could i fix it? I like the idea of not using the transistors.&lt;/p&gt;&#xA;" OwnerUserId="11802" LastEditorUserId="2881" LastEditDate="2015-08-27T11:56:00.100" LastActivityDate="2015-08-27T11:56:00.100" Title="Attiny88 problem with LEDs and voltage" Tags="|voltage-level|attiny|current|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14586" PostTypeId="1" CreationDate="2015-08-27T10:22:08.233" Score="3" ViewCount="7419" Body="&lt;p&gt;I want to create a structure called CarSpeed it has 4 int FR,FL,BR,BL (FrontRight,..) ; and i would like to create a function that returns this structure : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ActualSpeed Readspeed(void)&#xA;{&#xA;   code to read the speed of the car(already done)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone help me define a function that returns this structure  ? only the way how I should define it, the usual C way doesnt work :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedefstruct CarSpeed{...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CarSpeed ActualSpeed;&#xA;ActualSpeed Readspeed(void){.. }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11897" LastEditorUserId="42" LastEditDate="2015-08-27T10:52:38.473" LastActivityDate="2015-08-27T11:03:17.570" Title="Function that returns a Structure" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14587" PostTypeId="2" ParentId="14586" CreationDate="2015-08-27T10:29:45.983" Score="1" Body="&lt;p&gt;I would recommend to use pointers, it's faster and has the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this (disclaimer - I did not compile it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct {&#xA;   int a;&#xA;   int b;&#xA;} pair;&#xA;&#xA;&#xA;int init_pair(pair *ptr) {&#xA;   if (!ptr)&#xA;      return -1;&#xA;   ptr-&amp;gt;a = 6;&#xA;   ptr-&amp;gt;b = 9;&#xA;   return 0;&#xA;}&#xA;&#xA;int do_something() {&#xA;   pair mypair;&#xA;   return init_pair(&amp;amp;mypair);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-27T10:29:45.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14588" PostTypeId="1" CreationDate="2015-08-27T10:46:59.470" Score="2" ViewCount="2424" Body="&lt;p&gt;Hi i would like to implement a sensor and control system for my home. Basically, i would like to send and receive data to my arduino uno using esp8266. I am able program the esp8266 using at commands to send http request to my server. How can i make my server send commands to my arduino uno using esp8266?&lt;/p&gt;&#xA;" OwnerUserId="12029" LastActivityDate="2015-08-27T10:46:59.470" Title="Send and Receive with ESP8266 and arduino" Tags="|esp8266|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14589" PostTypeId="2" ParentId="14586" CreationDate="2015-08-27T11:03:17.570" Score="3" Body="&lt;p&gt;Since you're (probably) using a C++ compiler, it's usually easier to declare structures like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;struct CarSpeed&#xA;{&#xA;    int fr, fl, br, bl;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Note that there's no need for &lt;code&gt;typedef&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then return an instance of it directly from your function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;CarSpeed ReadSpeed()&#xA;{&#xA;    CarSpeed data;&#xA;&#xA;    data.fr = ...;&#xA;    data.fl = ...;&#xA;    data.br = ...;&#xA;    data.bl = ...;&#xA;&#xA;    return data;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can call it from another function like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;CarSpeed speed = ReadSpeed();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will copy the contents of the structure into an object called &lt;code&gt;speed&lt;/code&gt;. In this example, it's an 8 byte structure so it's a non-trivial copy. That shouldn't be a big problem unless you're calling it very frequently though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted in another answer, using a pointer (or a reference) can be more efficient if necessary.&lt;/p&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-08-27T11:03:17.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14590" PostTypeId="1" AcceptedAnswerId="14593" CreationDate="2015-08-27T12:20:40.447" Score="1" ViewCount="641" Body="&lt;p&gt;I need my Arduino to connect to my web server through HTTPS, can the Arduino handle it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It only has to act as a client.&lt;/p&gt;&#xA;" OwnerUserId="12031" LastActivityDate="2015-08-27T13:30:43.667" Title="Can a WiFi enabled Arduino make a HTTPS request to my Web Server?" Tags="|wifi|web|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14591" PostTypeId="2" ParentId="14572" CreationDate="2015-08-27T12:28:25.910" Score="1" Body="&lt;p&gt;Just burn the arduino bootloader to your tqfp. Then connect the tx and rx on the tqfp to the tx and rx on your arduino, and pull the reset line on the arduino low. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Downside is you have to do a manual reset on the tqfp before programming. If you have an Uno you could remove the atmega from the socket, and connect the reset on the uno to the reset on the tqfp. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to connect the TX on the tqfp to the TX pin on the Arduino using a resistor. But for this to work you have to modify the ArduinoISP sketch to make it release TX pin (&lt;code&gt;UCSRnB &amp;amp;= ~_BV(UCSRnB);&lt;/code&gt;) and set it to input. And reverse it when data is received on the RX. Not trivial, and only works one way (tqfp to PC).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-27T12:28:25.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14592" PostTypeId="1" CreationDate="2015-08-27T12:52:21.837" Score="0" ViewCount="378" Body="&lt;p&gt;My intent with this sketch is to have motors run for one minute, then stand by for 18 minutes. In practice, the sketch starts the motor state at &quot;low&quot; for the OffTime interval, then goes to the OnTime interval and loops. The desired result is exactly the opposite: the &quot;high&quot; interval first, followed by the &quot;low&quot;. I have tried setting the &lt;code&gt;motorState&lt;/code&gt; to &quot;HIGH&quot; in the constructor and played with the order of the IF statements to no avail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate any insight into this problem, as well as an intuition for the practical use of &lt;code&gt;millis()&lt;/code&gt;. I need a solution which doesn't use &lt;code&gt;delay&lt;/code&gt; but am having trouble wrapping my head around the logic of &lt;code&gt;millis()&lt;/code&gt; as used. (I adapted this code from a tutorial.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class LifeTest&#xA;{&#xA;  // Class member variables initialized at startup&#xA;  int motorPin;                                 &#xA;  long OnTime;                                  &#xA;  long OffTime;                                 &#xA;  // These maintain the current state&#xA;  int motorState;                               // Used to set the motor.&#xA;  unsigned long previousMillis;                 // Stores last time motor was updated. &#xA;&#xA;&#xA;  public:&#xA;  LifeTest(int pin, long on, long off)&#xA;  {&#xA;    motorPin = pin;&#xA;    pinMode(motorPin, OUTPUT);&#xA;&#xA;    OnTime = on;&#xA;    OffTime = off;&#xA;&#xA;    motorState = LOW;&#xA;    previousMillis = 0;&#xA;  }&#xA;&#xA;  void Update()&#xA;  {&#xA;    unsigned long currentMillis = millis();     // Check to see if it's time to change the motor state.&#xA;    if((motorState == HIGH) &amp;amp;&amp;amp; (currentMillis - previousMillis &amp;gt;= OnTime))&#xA;    { &#xA;    motorState = LOW;                         // Turn off motor.&#xA;    previousMillis = currentMillis;           // Remember the time.&#xA;    digitalWrite(motorPin, motorState);       // Update the motors.&#xA;    }&#xA;    else if((motorState == LOW) &amp;amp;&amp;amp; (currentMillis - previousMillis &amp;gt;= OffTime))&#xA;    { &#xA;    motorState = HIGH;                        // Turn on motor.&#xA;    previousMillis = currentMillis;           // Remember the time.&#xA;    digitalWrite(motorPin, motorState);       // Update the motors.&#xA;    }&#xA;  }&#xA;};&#xA;&#xA;LifeTest motor1(50, 60000, 1080000);&#xA;LifeTest motor2(51, 60000, 1080000);&#xA;LifeTest motor3(52, 60000, 1080000);&#xA;LifeTest motor4(53, 60000, 1080000);&#xA;&#xA;void setup()&#xA;{&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  motor1.Update();&#xA;  motor2.Update();&#xA;  motor3.Update();&#xA;  motor4.Update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6236" LastActivityDate="2015-12-26T08:28:32.097" Title="How do I set the motor state to &quot;HIGH&quot; at the beginning of this sketch?" Tags="|motor|millis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14593" PostTypeId="2" ParentId="14590" CreationDate="2015-08-27T13:30:43.667" Score="0" Body="&lt;p&gt;It sounds like a better way to do it would be to have a PHP script act as handoff server (maybe protected by originating IP address) to access the HTTPS site and provide the data over a less processor-intensive protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/4/how-to-get-https-on-arduino&quot;&gt;How to get HTTPS on Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, another answer suggests that we are working towards a solution to your issue, but it's not quite there yet (~12 seconds to encrypt a packet). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://evothings.com/is-it-possible-to-secure-micro-controllers-used-within-iot/&quot; rel=&quot;nofollow&quot;&gt;https://evothings.com/is-it-possible-to-secure-micro-controllers-used-within-iot/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12032" LastActivityDate="2015-08-27T13:30:43.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14594" PostTypeId="2" ParentId="14592" CreationDate="2015-08-27T14:55:12.933" Score="0" Body="&lt;p&gt;just change the constructor to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  LifeTest(int pin, long on, long off)&#xA;  {&#xA;    motorPin = pin;&#xA;    OnTime = on;&#xA;    OffTime = off;&#xA;&#xA;    previousMillis = 0;&#xA;&#xA;    motorState = HIGH;&#xA;    pinMode(motorPin, OUTPUT);&#xA;    digitalWrite(motorPin, motorState);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-27T14:55:12.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14596" PostTypeId="1" AcceptedAnswerId="14685" CreationDate="2015-08-27T16:09:34.493" Score="-2" ViewCount="99" Body="&lt;p&gt;I am planning to do a project on Sequential tilt motion lock using Arduino uno and accelerometer. I would like to present the accelerometer &lt;strong&gt;within&lt;/strong&gt; a rotatable object. So what other components do i have to add to be able to do it i.e.. for wireless transmission of data from the object(that has the acc. meter) to the Uno board. &lt;a href=&quot;https://i.stack.imgur.com/QHbnk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QHbnk.jpg&quot; alt=&quot;Tilt lock circuit &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11957" LastEditorUserId="11957" LastEditDate="2015-08-30T03:47:39.367" LastActivityDate="2015-08-30T18:10:30.557" Title="Need help in modifying the design" Tags="|arduino-uno|accelerometer|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14597" PostTypeId="1" AcceptedAnswerId="14598" CreationDate="2015-08-27T16:16:07.750" Score="0" ViewCount="78" Body="&lt;p&gt;I am an undergrad in ICE. I was searching for ideas to do mini projects on and found this Arduino boards and programs. So actually what are the basics to develop our own gadgets? Any guidelines...?   &lt;/p&gt;&#xA;" OwnerUserId="11957" LastActivityDate="2015-08-29T02:48:14.277" Title="What are the basics in writing a program in Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ClosedDate="2015-09-05T15:26:45.653" ContentLicense="CC BY-SA 3.0" />
  <row Id="14598" PostTypeId="2" ParentId="14597" CreationDate="2015-08-27T17:04:30.070" Score="2" Body="&lt;p&gt;There are some excellent books available as well as videos and articles on the Internet which will walk you through basic projects.  The most common method of programming is to use the free &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE&lt;/a&gt; which will talk to the board from your Mac or PC.  You can run the board straight from the USB port's power, or from an external source if you need it to be portable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The programming language is very similar to C.  The program structure is basically a setup portion and then a continuous main loop that runs until the board is powered off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to experiment without actually purchasing one, there are some emulators available which will let you build entire project on a virtual breadboard before buying any actual components.  &lt;a href=&quot;http://fritzing.org/&quot; rel=&quot;nofollow&quot;&gt;Fritzing&lt;/a&gt; is a great board planner that you can install, or if you would rather, you can use &lt;a href=&quot;https://123d.circuits.io/&quot; rel=&quot;nofollow&quot;&gt;123D Circuits&lt;/a&gt; from your web browser which will let you edit and simulated the circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basic knowledge of electrical circuits will be helpful for getting started, and is a great asset when designing larger projects.&lt;/p&gt;&#xA;" OwnerUserId="11610" LastEditorUserId="11610" LastEditDate="2015-08-29T02:48:14.277" LastActivityDate="2015-08-29T02:48:14.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14599" PostTypeId="1" CreationDate="2015-08-27T18:35:04.223" Score="1" ViewCount="352" Body="&lt;p&gt;I'm making a few experiments with a quite simple rover car I made using Arduino UNO and a few spare parts. Just for the heck of it I made it waterproof and now I want to toss it in my pool to make some underwater exploration. Maybe I'll fit some scrubers under it to make it easer to clean the floor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is: my rover navigates on its own, avoiding walls and objects using an ultrasonic sensor. But underwater the speed of sound goes up, and different qualities of water make it even harder for this system to work. Sometimes the pool is full of particles, and the scruber will probably worse the water quality around the robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: what kind of system is better to navigate underwater, simply avoiding walls? The current behavor (on dry ground) is to turn to the right and go on when it finds a wall, I would like to keep this behavior, but underwater. As it's a simple toy, I'm hardly willing to spend a hundred bucks on a fancy laser proximity sensor, neither I need to map the entire pool with a single pulse, it should be a simple wall avoiding system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="12038" LastActivityDate="2015-08-27T19:28:03.513" Title="Underwater positioning system (swimming pool)" Tags="|arduino-uno|sensors|proximity|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14600" PostTypeId="1" AcceptedAnswerId="14614" CreationDate="2015-08-27T19:03:55.827" Score="5" ViewCount="405" Body="&lt;p&gt;I have 2 Arduino Micro based devices that I want to use on my Ubuntu Linux machine.  I need them to have unique serial ports.  Unfortunately, both have the same serial number which makes identification through udev rules difficult (if not impossible).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the serial number that I get for both:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ udevadm info -a -p  $(udevadm info -q path -n /dev/ttyACM0) | grep -i serial&#xA;  ATTRS{serial}==&quot;0000:00:14.0&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any way to manually set the serial number on an Arduino Micro?  Or is there any other unique identifying properties I can use for udev rules?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, I do something like this in my &lt;code&gt;/etc/udev/rules.d/99-usb-serial.rules&lt;/code&gt; file: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEM==&quot;tty&quot;, ATTRS{product}==&quot;Arduino Uno&quot;, ATTRS{serial}==&quot;64936333936351911191&quot;, SYMLINK+=&quot;MyDevice&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Side note: I also have a Due, that has the same serial number as the Micros, but since ATTRS{product} is different, I can differentiate it.&lt;/p&gt;&#xA;" OwnerUserId="12037" LastActivityDate="2019-01-07T06:00:25.137" Title="How to differentiate between 2 Micros on Linux" Tags="|arduino-micro|linux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14601" PostTypeId="2" ParentId="14599" CreationDate="2015-08-27T19:28:03.513" Score="1" Body="&lt;p&gt;How about a tilt switch?  The bottom corners of a pool should allow the car to ride up the wall a little, when it tilts past 5 or 10 degrees, turn it left.....&lt;/p&gt;&#xA;" OwnerUserId="8349" LastActivityDate="2015-08-27T19:28:03.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14602" PostTypeId="1" CreationDate="2015-08-27T19:32:23.317" Score="1" ViewCount="320" Body="&lt;p&gt;I have a section of code that I am unsure of what it is doing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static int bufindw = 0;&#xA;static char buffer[4][96];&#xA;static char *strchr_pointer;&#xA;int result;&#xA;&#xA;result = (int)strtod(&amp;amp;buffer[bufindw][strchr_pointer - buffer[bufindw] + 1], NULL)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The part where I don't understand what is happening is &lt;code&gt;strchr_pointer - buffer[bufindw] + 1&lt;/code&gt;. &lt;code&gt;strchr_pointer&lt;/code&gt; and &lt;code&gt;buffer[bufindw]&lt;/code&gt; will be strings. It gives the result I expect it to give because I know in the end it needs the correct index value in &lt;code&gt;buffer[][]&lt;/code&gt; and in addition the number 1 is being added to it as well. How can a string minus a string?&lt;/p&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2015-08-27T21:22:25.687" Title="String operators" Tags="|string|pointer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14603" PostTypeId="1" CreationDate="2015-07-16T02:48:17.410" Score="2" ViewCount="15706" Body="&lt;p&gt;I have an LED strip that I am trying to turn on with a magnetic switch when a door opens. I want the LEDs to fade on when I open the door and fade off when I close it, which is where the Arduino comes in. I am using PWM for the fading. I can get each component to work separately. The fading LEDs work with the MOSFET without the switch. I tested the switch with serial output on the Arduino and it works fading a single LED without the MOSFET.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno R3&lt;/li&gt;&#xA;&lt;li&gt;Magnetic Switch&lt;/li&gt;&#xA;&lt;li&gt;N-Channel MOSFET IRLB3034&lt;/li&gt;&#xA;&lt;li&gt;5 Meter White LED Strip&lt;/li&gt;&#xA;&lt;li&gt;12VDC 30W Power Supply&lt;/li&gt;&#xA;&lt;li&gt;10k Ohm Resistors  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My setup looks like this:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/lDJYg.png&quot; alt=&quot;breadboard diagram&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/y3mX4.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code (if it helps):  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 2;     // the number of the switch pin&#xA;const int ledPin =  9;      // the number of the LED pin&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the switch status&#xA;int brightness = 0;&#xA;int fadeAmount = 5;&#xA;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPin, OUTPUT);      &#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);     &#xA;}&#xA;&#xA;void loop(){&#xA;  // read the state of the switch value:&#xA;  buttonState = digitalRead(buttonPin);&#xA;&#xA;  // check if the switch is ON.&#xA;  // if it is, the buttonState is LOW:&#xA;  if (buttonState == LOW) {     &#xA;    // fade LED on:    &#xA;    analogWrite(ledPin, brightness);  &#xA;    if (brightness &amp;lt; 255) {&#xA;      brightness = brightness + fadeAmount;&#xA;    }&#xA;  } &#xA;  else {&#xA;    // fade LED off:&#xA;    analogWrite(ledPin, brightness); &#xA;    if (brightness &amp;gt; 0) {&#xA;      brightness = brightness - fadeAmount;&#xA;    }&#xA;  }&#xA;  delay(30);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a feeling the problem is with the common ground on the MOSFET and the switch. Any solutions/suggestions are appreciated.&lt;/p&gt;&#xA;" OwnerDisplayName="Zack Hunter" LastActivityDate="2015-08-27T19:33:54.807" Title="Connecting a switch and a MOSFET to an Arduino?" Tags="|led|mosfet|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14604" PostTypeId="2" ParentId="14603" CreationDate="2015-07-16T05:53:55.540" Score="0" Body="&lt;p&gt;There is no need for the 10KOhm. MOSFETs are voltage controlled devices unlike transistors which need controlled current. I think your problem might be in debouncing of switch. You are probably getting some false positives which might be making your software go awry. &#xA;I recommend having a small debouncing routine. For eg - only if you find 3 successive positives will the switch press be termed a true positive or so. &lt;/p&gt;&#xA;" OwnerDisplayName="Vinod Karuvat" LastActivityDate="2015-07-16T05:53:55.540" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14605" PostTypeId="2" ParentId="14603" CreationDate="2015-07-16T06:29:47.817" Score="1" Body="&lt;p&gt;I think you should keep the R2 resistor, but make it 1k and put before it a pull-down resistor of 10k so that any charges stored in the NMOS Cgate capacitance are discharged, whenever there is High-Z at the port D9. Also never forget the resistor limiting the diode forward current, which is typically 20 mA, but you should check that every time in datasheet. In case of LED strip there are usually internal resistors, but if you are using higher voltage still you need to restrict the current. Could you tell us more about why you are using PWM not a simple output port with an integrator for example and what you exactly observe and measure when you turn-on-off (fade-on-off) the LED?&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FbvYW.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fFbvYW.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make the diagram a bit smaller?&lt;/p&gt;&#xA;" OwnerDisplayName="lalamer" LastActivityDate="2015-07-16T10:45:11.410" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14607" PostTypeId="1" CreationDate="2015-08-27T20:25:37.427" Score="0" ViewCount="1506" Body="&lt;p&gt;I recently purchased a batch of Due boards and find that they are cosmetically different. After attaching the Atmel-ICE and reading the firmware from both processors, I find that the firmware is different. The green masked one had a sticker indicating a new IDE should be downloaded from arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The back of the board shows silkscreen changes to the logo (DUE in an oval rather than rectangle) but both boards say BOARD MODEL DUE R3-E. The traces appear the same, the placement of parts appears the same, and other than different colored headers the parts are similar. The main processor has the same part number, but distinctly different markings. Internally the processors report the same device signature and revision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What has changed in the firmware? Are there other changes I've missed? Other than needing an even newer IDE are there changes that will affect my sketches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I load the older firmware onto the newer Due processors, should it operate the same, allowing use of the old IDE, and in case my sketches do face a problem with the new version?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/0RZid.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tla7u.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-08-27T20:50:04.760" Title="What changed in the new Due?" Tags="|arduino-due|bootloader|firmware|revisions|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14609" PostTypeId="2" ParentId="3565" CreationDate="2015-08-27T20:39:48.133" Score="1" Body="&lt;p&gt;This is a very complicated situation.  In short, the module itself does not provide Assisted GPS without both the handset's help, and the help of the carrier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the module is sold as an OEM or embeddable object, the manufacturer either hasn't included such functionality, or hasn't enabled it, or hasn't documented it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if it were included, enabled, and documented, it has to work with the carrier, and each carrier provides different services for different modules.  Some locate solely based on triangulation using cell towers and the module's command channel.  Others depend on the module capturing a short sequence of RF from the GPS network, sending it to the carrier's AGPS server to be processed, which then reports back a very accurate position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At any rate, this is not a standardized function for embedded cellular modules because cellular networks and carriers vary in how they've chosen to implement AGPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use AGPS in an embedded cellular module, you'll need to work with both the module manufacturer and the cellular carrier to enable that functionality.  It usually involves additional charges - renting an AGPS server, for instance.  These often involve a monthly fee in addition to a per-request fee.  Some companies set up their own AGPS servers to do the processing, but the cellular company still has to provide gross location information based on the tower signal reception.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suffice to say, this is not something that is common or cheap enough for low volume projects.  Unless you're going to be working with thousands of these devices it's typically cheaper to integrate a standalone GPS chipset in your device.&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-08-27T20:39:48.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14610" PostTypeId="2" ParentId="14369" CreationDate="2015-08-27T20:42:37.677" Score="0" Body="&lt;p&gt;As others have noted, your array is larger than the available RAM in your Arduino. Others mentioned Flash memory which could be a solution for you. Your Arduino has 32 KB of memory which could hold your array. See the following reference for more info about Flash memory. Keep in mind that Flash and EEPROM have a limited number of write cycles before becoming unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/EEPROM-Flash&quot; rel=&quot;nofollow&quot;&gt;Hidden Powers - storing data in Flash and EEPROM&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-08-27T20:42:37.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14611" PostTypeId="2" ParentId="14607" CreationDate="2015-08-27T20:50:04.760" Score="1" Body="&lt;p&gt;The 'new' board with green soldermask and the lighter headers is made by arduino.org.  The old one was probably made by the same company, but prior to the split in the founders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now there is arduino.cc (the original website) and arduino.org (the website set up by the company that split from Arduino).  There is a lot of different perspectives about who really owns &lt;code&gt;Arduino&lt;/code&gt; and I won't attempt to weigh in here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The changes in firmware are still unknown.  It's likely that they are simple strings or response changes so the boards can be differentiated in software.  The &lt;code&gt;new&lt;/code&gt; IDE is in alpha, and is yet another attempt to differentiate between the two Arduino groups.  I haven't attempted to program either with either group's IDE, but if I do I'll update this answer with the results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least there's a way to visually identify the difference once received - wish they had given them different part numbers so Digikey wouldn't have sent me a mixture...&lt;/p&gt;&#xA;" OwnerUserId="349" LastActivityDate="2015-08-27T20:50:04.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14612" PostTypeId="2" ParentId="14489" CreationDate="2015-08-27T20:51:50.453" Score="0" Body="&lt;p&gt;A SPDT switch would fit nicely in your diagram where the question mark is.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-08-27T20:51:50.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14613" PostTypeId="2" ParentId="14602" CreationDate="2015-08-27T21:22:25.687" Score="1" Body="&lt;p&gt;Let's break it down logically for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 4 strings, each capable of containing 96 characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char buffer[4][96];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is a block of RAM that covers 4*96=384 bytes.  Let's say that block of ram starts at address 0x100.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;result = (int)strtod(&amp;amp;buffer[bufindw][strchr_pointer - buffer[bufindw] + 1], NULL)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The phrase &lt;code&gt;buffer[x]&lt;/code&gt; returns the address of the string number &lt;code&gt;x&lt;/code&gt; in your array of strings.  It's the same as &lt;code&gt;&amp;amp;buffer[x][0]&lt;/code&gt; - the address of the first character in string x.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also have a pointer &lt;code&gt;strchr_pointer&lt;/code&gt; which contains something - what that is I don't know because you haven't told us.  Chances are it's the result of a &lt;code&gt;strchr()&lt;/code&gt; call, which:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;returns a pointer to the first occurrence of the character c in the string s.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you have looked for a character in a string and found that it's at a specific address.  Let's say that's address 0x111 for the sake of argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so if we take &lt;code&gt;bufindw&lt;/code&gt; as 0 for the first string in your array, and work from the inside out, we have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;buffer[bufindw] = 0x100&lt;/li&gt;&#xA;&lt;li&gt;strchr_pointer = 0x111&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;strchr_pointer - buffer[bufindw] = 0x111 - 0x100 = &lt;strong&gt;0x11&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;strchr_pointer - buffer[bufindw] + 1 = 0x100 - 0x111 + 1 = &lt;strong&gt;0x12&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Replace that into the function's parameters:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&amp;amp;buffer[bufindw][strchr_pointer - buffer[bufindw] + 1] = &amp;amp;buffer[bufindw][0x12]&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you have the address of the 0x12'th (18th) character (or character number 16 since they count from 0 not 1), which is address 0x112.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That address is then passed to strtod() to convert it into a double-precision number:&#xA;    strtod(0x112, NULL);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That value is then cast to an integer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(int)strtod(0x112, NULL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the decimal portion is discarded (not rounded, chopped off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say your string contains: &quot;&lt;code&gt;This is the value:23.83589743&lt;/code&gt;&quot; and is located at 0x100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use strchr() to find the first occurrence of ':', and it finds it at address 0x111, which is the 18th character of the string, so 0x100 + 17 = 256 + 17 = 273 = 0x111.  You subtract the start of the string and add one to it, so you end up with 18, which is the start of the numeric value (the 18th character).  The string from that point on contains &quot;&lt;code&gt;23.83589743&lt;/code&gt;&quot;.  That is then passed to &lt;code&gt;strtod()&lt;/code&gt; and cast to an integer, and so is truncated to &lt;code&gt;23&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not surprising you're confused, the whole thing can be re-written much simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strchr_pointer = strchr(buffer[bufdindw], ':');&#xA;result = (int)strtod(strchr_pointer, NULL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All that manipulating of the buffer address is like doing &quot;x = 6 + y - 3 + 4 - 7&quot; - completely pointless, since you might just as well write &quot;x = y&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-27T21:22:25.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14614" PostTypeId="2" ParentId="14600" CreationDate="2015-08-27T21:38:57.140" Score="3" Body="&lt;p&gt;The USB VID, PID and Serial Number are all programmed into the chip when you upload your sketch.  The VID and PID are tied to the board, and the serial number is always the same regardless of which board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no matter which board you program it will get the same details as any other board of the same kind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no option to change the serial number (there is, IIRC, actually no serial number defined) but the VID and PID are provided as a pair of macros on the compilation command line: &lt;code&gt;USB_VID&lt;/code&gt; and &lt;code&gt;USB_PID&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you could (cheakily) create a new board definition (based on the existing Micro one) that is &quot;The other Micro&quot; and provide a different (unofficial) PID to that board.  You can then differentiate the two boards in udev using the VID/PID combination.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you have to then ensure that you have the right board selected when you program them, and the act of entering the bootloader on the &quot;other&quot; board would revert back to the old PID which is programmed into the bootloader, but I'm sure you can cope with that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-27T21:38:57.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14615" PostTypeId="1" CreationDate="2015-08-27T22:44:04.287" Score="2" ViewCount="83" Body="&lt;p&gt;I'm starting with Leonardo and I'm a bit confuse about the serial modem function. As you know on boot the Leonardo for the first 8 seconds wait for a program on the USB port and then it goes in serial modem mode while my program runs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm designing a consumer product (open source) and I will like to make some modifications to my board in order to make it more friendly:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;On boot it has to go into &lt;em&gt;programming mode&lt;/em&gt; only if a jumper is set. Otherwise it goes directly into &lt;em&gt;serial modem&lt;/em&gt;.&lt;/li&gt;&#xA;&lt;li&gt;I need to change to &lt;em&gt;modem name&lt;/em&gt;, instead of:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zRSig.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zRSig.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Have the operating system pickup the serial modem with no drivers request.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For 1 and 2, is it possible? should I try to modify Caterina or it will be easier to work with &lt;a href=&quot;https://github.com/Optiboot/optiboot&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optiboot&lt;/a&gt;? Number 3 works already in linux distributions, but in Windows some pcs ask for drivers are, and even worse, some windows 64bits + usb3 requires some minors hacks to pick up the Leonardo serial drivers, is it possible to improve? Ideally I want the board to be connected to a PC/Mac/Linux and get configured as a serial com with no user intervention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this are questions that every person trying to create a consumer product with Arduino needs to answer before producing the actual product. So, and resources, references and &lt;em&gt;where to start&lt;/em&gt; guides will help me and other people in the community.&lt;/p&gt;&#xA;" OwnerUserId="12021" LastActivityDate="2015-08-27T22:44:04.287" Title="Is serial modem routine written on the Arduino Leonardo bootloader?" Tags="|serial|arduino-leonardo|bootloader|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14616" PostTypeId="1" AcceptedAnswerId="14622" CreationDate="2015-08-28T03:08:12.267" Score="0" ViewCount="1230" Body="&#xA;&#xA;&lt;p&gt;I tried to use a function that could smooth out the PPM by using 10 input values and finding the averages. But even this still doesn't seem to be a good way prevent the noise that is occurring when using my Remote. Is there any way to fix this?&#xA;Here is the code from the smoothing project. (Although i feel it's not really necessary to add it here, but here it is anyways.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is using the PPMrcIn library. An int is created and then using if statements I make an object do work. My problem is that i have a very small window for work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My values are between 50 and 200&#xA;&lt;br&gt;Where 140 is the preferred midpoint i'd like to work with.&#xA;&lt;br&gt;This is my somewhat cryptic number line.&#xA;&lt;br&gt;140 is in the middle. Where my window of stability is between 130 and 150&#xA;&lt;br&gt;and values below 100 and above 180 are where the robot does some work.&#xA;&lt;br&gt;&#xA;50 ---x---&amp;lt;100-----130--&amp;lt;140&gt;--150----180&gt;---x---200&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  /*&#xA;&#xA;    Smoothing&#xA;&#xA;    Reads repeatedly from an analog input, calculating a running average&#xA;    and printing it to the computer.  Keeps ten readings in an array and &#xA;    continually averages them.&#xA;&#xA;    The circuit:&#xA;      * Analog sensor (potentiometer will do) attached to analog input 0&#xA;&#xA;    Created 22 April 2007&#xA;    By David A. Mellis  &amp;lt;dam@mellis.org&amp;gt;&#xA;    modified 9 Apr 2012&#xA;    by Tom Igoe&#xA;    http://www.arduino.cc/en/Tutorial/Smoothing&#xA;&#xA;    This example code is in the public domain.&#xA;&#xA;&#xA;  */&#xA;&#xA;&#xA;  // Define the number of samples to keep track of.  The higher the number,&#xA;  // the more the readings will be smoothed, but the slower the output will&#xA;  // respond to the input.  Using a constant rather than a normal variable lets&#xA;  // use this value to determine the size of the readings array.&#xA;  const int numReadings = 10;&#xA;&#xA;  int readings[numReadings];      // the readings from the analog input&#xA;  int index = 0;                  // the index of the current reading&#xA;  int total = 0;                  // the running total&#xA;  int average = 0;                // the average&#xA;&#xA;  int inputPin = A0;&#xA;&#xA;  void setup()&#xA;  {&#xA;    // initialize serial communication with computer:&#xA;    Serial.begin(9600);                   &#xA;    // initialize all the readings to 0: &#xA;    for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++)&#xA;      readings[thisReading] = 0;          &#xA;  }&#xA;&#xA;  void loop() {&#xA;    // subtract the last reading:&#xA;    total= total - readings[index];         &#xA;    // read from the sensor:  &#xA;    readings[index] = analogRead(inputPin); &#xA;    // add the reading to the total:&#xA;    total= total + readings[index];       &#xA;    // advance to the next position in the array:  &#xA;    index = index + 1;                    &#xA;&#xA;    // if we're at the end of the array...&#xA;    if (index &amp;gt;= numReadings)              &#xA;      // ...wrap around to the beginning: &#xA;      index = 0;                           &#xA;&#xA;    // calculate the average:&#xA;    average = total / numReadings;         &#xA;    // send it to the computer as ASCII digits&#xA;    Serial.println(average);   &#xA;    delay(1);        // delay in between reads for stability            &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also link to my code in github&#xA;&lt;a href=&quot;https://github.com/tisaconundrum2/RCRoomba/blob/master/RCRoomba2.2.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tisaconundrum2/RCRoomba/blob/master/RCRoomba2.2.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is being asked. Let me clarify on this black voodoo thing called a PPM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many RC Transmitters and Receivers provide access to the PPM Stream, this is a single stream of pulses which includes the information for all of the receiver channels in a single connection.&lt;br&gt;&#xA;The stream is made up of a series of short pulses, the first pulse is the start marker. The time between the start marker and the start of the next pulse defines the pulse length for channel one. The time to the next pulse defines the pulse length for channel 2 and so on. The end of the pulse stream is marked by a gap know as the frame space. This gap indicates that there are no more channels to receive and the next pulse will be the start of a new frame. Each frame contains the pulse widths for all of your receiver channels.&#xA;Note - unlike servo signals, in a PPM Stream it is the gaps between pulses that defines the pulse width for a channel, not the duration of the pulse itself which can be very short.&#xA;-&lt;a href=&quot;http://rcarduino.blogspot.com/2012/11/how-to-read-rc-receiver-ppm-stream.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.com/2012/11/how-to-read-rc-receiver-ppm-stream.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As discussed above. My PPM signal is highly varied. I want to be able to just get a solid 140. However, the signal will jump irratically between 135 and 142 for reasons I do not completely understand. In an attempt to clear this fuzziness I tried to go for smoothing.&lt;/p&gt;&#xA;" OwnerUserId="11978" LastEditorUserId="10794" LastEditDate="2015-08-28T09:11:05.847" LastActivityDate="2015-08-28T20:57:08.637" Title="PPM from remote control is very noisy" Tags="|arduino-uno|c++|remote-control|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14618" PostTypeId="2" ParentId="14592" CreationDate="2015-08-28T06:58:41.213" Score="1" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would appreciate any insight into this problem, as well as an intuition for the practical use of millis().&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have a lengthy tutorial about this at &lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;How to do multiple things at once ... like cook bacon and eggs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However as this site frowns upon link-only answers (the link might go down) I'll try to explain as well, here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;millis()&lt;/code&gt; is like having a wristwatch. You glance at it from time to time to see if it is time to do something, like catch a bus to work, put the dinner on, take the cake out of the oven, that sort of thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;code&gt;delay()&lt;/code&gt; all the time, you can only do one thing at a time. For example, if your cake takes 30 minutes to cook, and you do this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PutCakeInOven ();&#xA;delay (30UL * 60 * 1000);  // delay 30 minutes&#xA;TakeCakeOutOfOven ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is fine, but you aren't also cooking some eggs at the same time, or doing the dishes, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;millis()&lt;/code&gt; you can do lots of things! Win-win! The basic technique is to note the time when you started, and then when time is up, you do whatever-it-is you need to do. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long BakeStartTime;&#xA;const unsigned long CookingTime = 30UL * 60 * 1000;  // 30 minutes&#xA;bool CakeInOven = false;&#xA;&#xA;void setup ()&#xA;  {&#xA;  PutCakeInOven ();&#xA;  BakeStartTime = millis ();  // when the cake went into the oven&#xA;  CakeInOven = true;&#xA;  }&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (CakeInOven &amp;amp;&amp;amp; (millis () - BakeStartTime &amp;gt;= CookingTime))&#xA;    {&#xA;    TakeCakeOutOfOven ();&#xA;    CakeInOven = false;&#xA;    }&#xA;&#xA;  // do a whole lot of other stuff, like cooking some eggs&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can expand this technique to do dozens of things &quot;at once&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-28T06:58:41.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14619" PostTypeId="1" AcceptedAnswerId="14626" CreationDate="2015-08-28T07:34:28.320" Score="0" ViewCount="656" Body="&lt;p&gt;How do I split a string into two based on it's length to display on a 2x16 LCD?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen a function called length() to get the length of a string. But, any ideas how to split it in to 2x16 and trim the rest of the string?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="11784" LastEditorUserId="25788" LastEditDate="2016-09-18T14:10:22.633" LastActivityDate="2016-09-18T14:10:22.633" Title="Split a string as 2x16 for LCD" Tags="|lcd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14620" PostTypeId="2" ParentId="14619" CreationDate="2015-08-28T07:44:35.843" Score="2" Body="&lt;p&gt;That's what &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringSubstring&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;String::substring()&lt;/code&gt;&lt;/a&gt; is for. Simply take the first 16 characters and the characters from 16 to 32, and output them.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-28T07:44:35.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14621" PostTypeId="2" ParentId="14369" CreationDate="2015-08-28T08:04:55.337" Score="0" Body="&lt;p&gt;In case the matrix is mostly empty or anyway has values that can be calculated programmatically, &lt;a href=&quot;https://en.wikipedia.org/wiki/Sparse_array&quot; rel=&quot;nofollow&quot;&gt;sparse arrays&lt;/a&gt; might come to the rescue. It requires memory allocation and hopping, so the access time to individual elements is not deterministic, but you can calculate the worst-case scenario.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-28T08:04:55.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14622" PostTypeId="2" ParentId="14616" CreationDate="2015-08-28T08:23:15.327" Score="1" Body="&#xA;&#xA;&lt;p&gt;First, I want to thank you for making this post. I have a few remote-controlled cars/boats/helicopters, and I've often wondered how the remote control works. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To answer your question - and because I was too lazy to work out how to connect to an actual controller - I made a &quot;remote simulator&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// PPM generator&#xA;&#xA;const byte SIGNAL_PIN = 3;&#xA;const int SIGNAL_COUNT = 6;&#xA;const unsigned long PULSE_WIDTH = 300;  // µs&#xA;const unsigned long BLANK_TIME = 25;    // ms&#xA;const int widths [SIGNAL_COUNT] = { 600, 2000, 1000, 1500, 2200, 2400 };&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (SIGNAL_PIN, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  delay (BLANK_TIME); &#xA;  digitalWrite (SIGNAL_PIN, HIGH);  // start&#xA;  delayMicroseconds (PULSE_WIDTH);  &#xA;  digitalWrite (SIGNAL_PIN, LOW);   // end of start pulse&#xA;&#xA;  for (byte i = 0; i &amp;lt; SIGNAL_COUNT; i++)&#xA;    {&#xA;    delayMicroseconds (widths [i] - PULSE_WIDTH);&#xA;    digitalWrite (SIGNAL_PIN, HIGH);  // start of pulse&#xA;    delayMicroseconds (PULSE_WIDTH);  &#xA;    digitalWrite (SIGNAL_PIN, LOW);   // end of pulse&#xA;    }  // end of for loop&#xA;&#xA;  delay (1000);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is intended to generate a series of pulses (six in this case) which might be generated by some fancy &lt;s&gt;toy&lt;/s&gt; fun device.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Output from it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XBAjj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XBAjj.png&quot; alt=&quot;PPM generator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from the cursor, it is doing what it is bid. The pulse width shown by the scope cursor is indeed 2000 µs, as per the table of widths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Output on pin 3 on the Uno.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now we need a decoder. So let's use interrupts:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte SIGNAL_PIN = 2;&#xA;const int SIGNAL_COUNT = 6;&#xA;&#xA;volatile unsigned long widths [SIGNAL_COUNT + 1];&#xA;volatile byte count;&#xA;&#xA;unsigned long lastPulse;&#xA;&#xA;// ISR&#xA;void gotPulse ()&#xA;  {&#xA;  unsigned long now = micros ();&#xA;&#xA;  // a long gap means we start again&#xA;  if ((now - lastPulse) &amp;gt;= 25000)&#xA;    count = 0;&#xA;&#xA;  lastPulse = now;&#xA;  if (count &amp;gt;= (SIGNAL_COUNT + 1))&#xA;    return;&#xA;&#xA;  widths [count++] = now;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  attachInterrupt (0, gotPulse, RISING);&#xA;  EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (count &amp;gt;= SIGNAL_COUNT)&#xA;    {&#xA;    Serial.println (F(&quot;Got sequence.&quot;));  &#xA;    for (int i = 1; i &amp;lt; SIGNAL_COUNT + 1; i++)&#xA;      {&#xA;      Serial.print (&quot;Channel &quot;);&#xA;      Serial.print (i);&#xA;      Serial.print (&quot; = &quot;);&#xA;      Serial.println (widths [i] - widths [i - 1]);&#xA;      }&#xA;    count = 0;      &#xA;    }&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This uses an interrupt (on pin 2 on the Uno) on the rising edge to detect the start of the pulses. It stores them, and then works out their widths later.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Results?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Got sequence.&#xA;Channel 1 = 612&#xA;Channel 2 = 2020&#xA;Channel 3 = 1016&#xA;Channel 4 = 1512&#xA;Channel 5 = 2220&#xA;Channel 6 = 2428&#xA;Got sequence.&#xA;Channel 1 = 612&#xA;Channel 2 = 2020&#xA;Channel 3 = 1016&#xA;Channel 4 = 1512&#xA;Channel 5 = 2220&#xA;Channel 6 = 2424&#xA;Got sequence.&#xA;Channel 1 = 616&#xA;Channel 2 = 2020&#xA;Channel 3 = 1012&#xA;Channel 4 = 1516&#xA;Channel 5 = 2220&#xA;Channel 6 = 2424&#xA;Got sequence.&#xA;Channel 1 = 616&#xA;Channel 2 = 2020&#xA;Channel 3 = 1012&#xA;Channel 4 = 1516&#xA;Channel 5 = 2216&#xA;Channel 6 = 2432&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Highly consistent results, with a small error factor of around 16 µs compared to &lt;code&gt;600, 2000, 1000, 1500, 2200, 2400&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In case it isn't clear, this test required two Unos. One to generate the pulses and a second one to decode them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DxH0K.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DxH0K.jpg&quot; alt=&quot;PPM Test setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one with the USB cable is the decoder, which writes to the serial port. The other one is powered by 5V/Gnd from the first one, and the white wire is the data with the pulses.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-28T20:57:08.637" LastActivityDate="2015-08-28T20:57:08.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14623" PostTypeId="1" CreationDate="2015-08-28T09:26:20.623" Score="1" ViewCount="279" Body="&lt;p&gt;How to make arduino sense mobile signal coming into a room and display the calling number on an LCD screen&lt;/p&gt;&#xA;" OwnerUserId="12053" LastActivityDate="2015-08-28T10:19:43.120" Title="How to sense mobile signal coming to a room using arduino uno" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14624" PostTypeId="2" ParentId="14623" CreationDate="2015-08-28T10:12:04.727" Score="3" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mobile phone signals don't respect artificial boundaries like a room's walls.  You can detect the mobile phone signal from the local cell, but you can't narrow it down to &quot;what is talking to a device in this room&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you could just intercept the signals and find out who was calling whom there wouldn't be much security, would there? It's all encrypted and locked down - you can't get at that sort of information &quot;from the air&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you &lt;em&gt;could&lt;/em&gt; do though, is to have your mobile phone send out the phone number of an incoming call via bluetooth (many hands free kits already use this kind of facility) and have your Arduino receive that information to display it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-28T10:12:04.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14626" PostTypeId="2" ParentId="14619" CreationDate="2015-08-28T10:38:55.447" Score="3" Body="&lt;p&gt;String::Substring does take a start and an end value. So you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String s1 = longtext.substring(0,15);&#xA;String s2 = longtext.substring(16,31);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12054" LastActivityDate="2015-08-28T10:38:55.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14627" PostTypeId="2" ParentId="13826" CreationDate="2015-08-28T10:52:24.453" Score="1" Body="&lt;p&gt;As commenter by RSM&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue you are facing is because you are using pins &lt;strong&gt;0&lt;/strong&gt; and &lt;strong&gt;1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are used by the arduino for uart. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for starters please use any pin other that &lt;strong&gt;0&lt;/strong&gt; and &lt;strong&gt;1&lt;/strong&gt;.  But if you insist that you do need to use these pins,  then you don't need softwareserial you can use the default serial itself, but you will need to disconnect the bluetooth while programming. &lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="11754" LastEditDate="2015-08-28T12:05:48.410" LastActivityDate="2015-08-28T12:05:48.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14628" PostTypeId="1" CreationDate="2015-08-28T13:51:56.197" Score="0" ViewCount="622" Body="&lt;p&gt;I'm using an arduino uno, and an 16x2 LCD that is connected to the arduino uno with a 1m long UTP cable to transmit data and as well power the LCD screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to test my code and my wiring with short wires and everything worked perfectly, as soon as I used the UTP cable to move my lcd a bit away from the arduino, the same code and wiring doesn't work, all i see is gibberish text (nonsense characters on the screen).&#xA;I have other components in the circuit, but I have disabled them all and checked again (quadruplechecked) everything, including the LCD alone, but the problem remians. I also gave the lcd a whole separate powering line, as I thought it could have run low in energy bcs of other components using the same 5v line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone has any idea of what could the problem be? Has anyone tried connecting components with UTP cables? Should I maybe use STP instead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="12056" LastActivityDate="2016-01-26T20:12:08.060" Title="Arduino, lcd 16x2 and UTP cable shows gibberish text?" Tags="|arduino-uno|lcd|wires|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14629" PostTypeId="1" CreationDate="2015-08-28T15:13:41.610" Score="0" ViewCount="137" Body="&lt;p&gt;If I have a basic electronic board with some LEDs and sound fx and I want to program them (I'm a beginner, learning about arduino), does the arduino board always have to be connected to the actual electronic board I'm running or is there a way to &quot;upload&quot; the programming to the circuit board? &lt;/p&gt;&#xA;" OwnerUserId="12060" LastActivityDate="2015-08-28T20:22:33.133" Title="Does the arduino board have to be always physically connected to the electronic device you are running?" Tags="|arduino-uno|programming|electronics|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14630" PostTypeId="2" ParentId="14629" CreationDate="2015-08-28T15:15:59.327" Score="2" Body="&lt;p&gt;If the &quot;basic electronic board&quot; is programmable, then yes, you can upload a program to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, though, &quot;some LEDs&quot; and similar devices are not programmable, and without something to &lt;em&gt;drive&lt;/em&gt; them (i.e., the Arduino) they won't do anything at all.  The Arduino is what has the program and it tells the &quot;basic electronic board&quot;, moment by moment, what it should be doing.  It is the &lt;em&gt;brain&lt;/em&gt; of the operation.  Remove the brain from someone and you'll find their body no longer functions.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-28T15:15:59.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14631" PostTypeId="1" AcceptedAnswerId="14774" CreationDate="2015-08-28T16:05:38.263" Score="1" ViewCount="179" Body="&lt;p&gt;I am working on a project with an Arduino Nano that includes a keypad, screen, and the NRF4001 transceiver. The keypad requires 7 digital pins to operate, the wireless transceiver uses pins D9 - D13 with the RF24 library I am using. Now, that leaves me with 1 Digital Pin left for a screen unless there is an I2C screen I could use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would be easy enough to find except that I have some limitations. If at all possible I would like the screen to be under 5 dollars and about the size of a Nokia 5110. The Nokia uses to many pins and does not tolerate 5v logic levels I've heard. An OLED 0.96 inch is only a 4 bucks and is I2C, but it is too small. I could make a board for the keypad that used different values of resistors and one analog pin to detect different buttons but would rather not go that route if there is any easier way to get around this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any options out there that would suffice my pin, cost and size conditions or am I being too picky?&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2015-09-03T02:56:39.333" Title="Cheap LCD with Few Pins" Tags="|lcd|hardware|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14632" PostTypeId="1" AcceptedAnswerId="14724" CreationDate="2015-08-28T16:27:54.497" Score="0" ViewCount="223" Body="&lt;p&gt;I messed around with the &lt;a href=&quot;https://www.sparkfun.com/datasheets/BreakoutBoards/MAX7456.pdf&quot; rel=&quot;nofollow&quot;&gt;MAX7456&lt;/a&gt; chip for a while, even the character set updating sketch seemed to work after a few modifications. But now it is not displaying anything with the Hello World sketch that worked before. No signal seems to pass through it, the screen is just black.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet says that one must write Video Mode 0 Register (VM0) at address 00H bit 1 to 1 via SPI to reset it, how would I do it? Also, how would one verify that the chip indeed did reset itself and responds to the commands given to it afterwards? (The board looks like &lt;a href=&quot;http://www.ebay.co.uk/itm/On-Screen-Ardupilot-Mega-Display-MinimOSD-Rev-1-1-OSD-diy-drones-APM2-2-5-2-6-/321843140980&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-31T22:09:15.537" LastActivityDate="2015-09-01T01:05:38.063" Title="How to do a software reset on MAX7456?" Tags="|atmega328|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14633" PostTypeId="2" ParentId="14629" CreationDate="2015-08-28T18:34:11.387" Score="0" Body="&lt;p&gt;And Arduino UNO is basically a ATMega328 chip (with some extras) on a circuit board. So if you add an ATMega328 to your own circuitboard, you don't need an Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-08-28T18:34:11.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14634" PostTypeId="1" AcceptedAnswerId="14635" CreationDate="2015-08-28T18:39:16.417" Score="0" ViewCount="1125" Body="&lt;p&gt;I just got my Arduino Pro Mini and GDEW0154T1 ePaper display (&lt;a href=&quot;http://www.good-display.com/products_detail/&amp;amp;productId=305.html&quot; rel=&quot;nofollow&quot;&gt;GDEW0154T1 display)&lt;/a&gt; and I'm trying to figure out a way to make them &quot;talk&quot;. I started reading documentation and multiple sites but I still have no idea. I bought Breadboard, USB connector for Arduino and cables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need some port to connect display to Breadboard. Could you tell me where to look for it? What next?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for any advice!&lt;/p&gt;&#xA;" OwnerUserId="12062" LastActivityDate="2015-08-28T19:16:20.487" Title="Arduino Pro Mini and GDEW0154T1 ePaper (e ink) display" Tags="|display|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14635" PostTypeId="2" ParentId="14634" CreationDate="2015-08-28T19:16:20.487" Score="2" Body="&lt;p&gt;You need to build a special driver board.  Most of the drive circuitry is on the main chip built into the display, which is convenient, but it requires a number of capacitors (which are too big to fit into the display itself) on the various voltage pins, and a special power control circuit to ensure that the different voltages get enabled at the right time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet details the capacitors that need connecting (Figure 7.5(2)), as well as the power control circuit (Figure 7.5(4)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is another small circuit snippet there as well (Figure 7.5(3), temperature sensor) but I haven't worked out the relevance of that yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you will need the right FPC connector, and a surface mount PCB to solder it on to, as well as the ability to solder it (reflow oven), so it's not a trivial task.  You may be able to find the right connector already soldered onto a breakout board if you look around - but make sure it &lt;em&gt;is&lt;/em&gt; the right one, since there are many variations - number of pins, pitch of pins, upper or lower connection, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-28T19:16:20.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14636" PostTypeId="2" ParentId="14100" CreationDate="2015-08-28T20:19:05.477" Score="0" Body="&lt;p&gt;To answer your compile problem.. Are you using c++11? The issue could be that Arduino Compiler may not support entire C++11 features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you cant find an alternative for fstream (I dont know any) then you have to find a different way compile the C++11 code and upload it. You can do this with a Makefile, avr-gcc. Its plenty of generators out there.  &lt;/p&gt;&#xA;" OwnerUserId="12063" LastActivityDate="2015-08-28T20:19:05.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14637" PostTypeId="2" ParentId="14629" CreationDate="2015-08-28T20:22:33.133" Score="0" Body="&lt;p&gt;If the question is &quot;Can I program the Arduino without anything else connected to it?&quot;, then yes, you can program it with out the sound and light board connected. But the program will start running shortly after the upload finishes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If some devices were connected to it and some were not, it's possible the program won't function properly at that point (and obviously the not-connected devices won't function at all!), so you should make sure the Arduino can't or won't try to do anything to the few connected ones that might be harmful when some others are not connected, in case that is possible (this would be an unusual, but plausible, situation).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-28T20:22:33.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14638" PostTypeId="1" CreationDate="2015-08-28T21:01:20.560" Score="2" ViewCount="1488" Body="&lt;p&gt;I need help with wiring this current sensor so that I can read the output voltage as an analogue input. - &lt;a href=&quot;http://www.tamuracorp.com/clientuploads/pdfs/engineeringdocs/L03SXXXD15.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.tamuracorp.com/clientuploads/pdfs/engineeringdocs/L03SXXXD15.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I have it wired right now - &#xA;1 - +15v &#xA;2 - 15v ground &#xA;3 - output to arduino &#xA;4 - arduino ground &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seemed simple but reviewing the wiring diagram again I have a hunch that this is not at all how I should be wiring this up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks &lt;/p&gt;&#xA;" OwnerUserId="12064" LastActivityDate="2015-08-29T02:39:16.933" Title="Hall Effect Current Sensor Wiring" Tags="|sensors|analogread|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14639" PostTypeId="2" ParentId="14638" CreationDate="2015-08-28T21:23:49.303" Score="2" Body="&lt;p&gt;Looking at the datasheet the output is +/- 4 volts, so this is not suitable to connect directly to the Arduino, because the input pin will not tolerate -4 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am no Hall Effect sensor expert, but a quick search on Google showed another potential problem: If you are planning to measure AC current, and you try to sample the output on the Arduino, the reading will average out to zero (half of the time positive, half of the time negative).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What may help - and this is a bit of a guess - is to put a diode in series with the sensor output, oriented so that you only get the positive pulses. That is, the anode connected to the Hall Effect sensor, and the cathode (with the black line) on the Arduino side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you probably want to smooth the voltage so you can read the average voltage with the ADC converter, rather than what it is at a particular millisecond. A low-pass filter will take an average, which you can then read with &lt;code&gt;analogRead&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3P4pr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3P4pr.png&quot; alt=&quot;Hall effect sensor wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I made up that circuit driven by a signal generator (8 V peak to peak, i.e. +/- 4 V) and found a 400 mV drop over the diode using a 1N4148 normal diode, and a 160 mV drop using a BAT85 Schottky diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 3 V peak-to-peak signal the voltage drop with the Schottky diode reduced to 120 mV, so it wasn't totally linear.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Majenko pointed out, there is a voltage drop over the diode. You can make a &lt;a href=&quot;https://en.wikipedia.org/wiki/Precision_rectifier&quot; rel=&quot;nofollow noreferrer&quot;&gt;Precision Rectifier&lt;/a&gt; out of an op-amp and a few other parts, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dn3JC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dn3JC.png&quot; alt=&quot;Precision Rectifier&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This avoids the problem of the voltage drop (put this in place of the diode in the earlier circuit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the signal is AC then the smoothing circuit I described above will only give you an average voltage, not a peak one. You may want to sample rapidly in order to find the peak values.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-29T02:39:16.933" LastActivityDate="2015-08-29T02:39:16.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14640" PostTypeId="2" ParentId="13347" CreationDate="2015-08-28T22:40:32.930" Score="0" Body="&lt;p&gt;Seems like wrong baud-rate. Change baud-rate in the Arduino IDE serial monitor. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2015-08-28T22:40:32.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14641" PostTypeId="2" ParentId="14638" CreationDate="2015-08-28T23:16:13.550" Score="2" Body="&lt;p&gt;To read the sensor properly you have to convert the output signal into something the Arduino can work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At full current the output will swing between +4V and -4V, and over-current will cause that to be nearer +6V to -6V.  The frequency of that swing will be the frequency of the input voltage - so typically 50 or 60Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino can only read between 0V and 5V, so you will need to convert the provided voltage to fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to first reduce the voltage by about a half, so it fits into +/- 2V, and then you need to add a 2.5V offset voltage to it so that it swings between 0.5V and 4.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have done that you then need to sample the incoming signal fast enough that you can get the peak values, from which you can then calculate the incoming current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often for this kind of thing you would use a simple voltage divider with an offset voltage applied to it, but the output impedance of the sensor (set by R&lt;sub&gt;L&lt;/sub&gt;) is 10KΩ which is around the upper limit for the input impedance of the Arduino's input.  A voltage divider that wouldn't adversely affect the output accuracy would be using resistors in the order of 1MΩ, which would be way too high for the ADC on the Arduino to be able to sample accurately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to buffer the signal with a high impedance buffer.  That can be achieved most simply with an inverting op-amp circuit with a gain of 0.5.  You want a rail-to-rail op-amp which is capable of running from a single supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1cws0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1cws0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this circuit the output current is converted into a voltage by the 10KΩ resistor R&lt;sub&gt;L&lt;/sub&gt;.  It is then &lt;em&gt;AC coupled&lt;/em&gt; to the rest of the circuit through C&lt;sub&gt;1&lt;/sub&gt; which has to be high enough in value as to not reject the frequency you are working with (it acts like a high-pass filter).  R&lt;sub&gt;1&lt;/sub&gt; and R&lt;sub&gt;2&lt;/sub&gt; set the gain of 50/100, or 1/2, so the voltage is halved.  R&lt;sub&gt;3&lt;/sub&gt; and R&lt;sub&gt;4&lt;/sub&gt; form a voltage divider to provide a V&lt;sub&gt;CC&lt;/sub&gt;/2 offset voltage into the non-inverting input of the op-amp.  This is known as the &lt;em&gt;virtual ground&lt;/em&gt; voltage and is the voltage the output of the op-amp will swing around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is the input voltage inverted, halved and off-set by 2.5V, which can be read directly by the Arduino's ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the magic word &lt;em&gt;inverted&lt;/em&gt; there, though.  The values you read will be upside down.  Anything read above 512 from the ADC will equate to a negative voltage.  Anything read below 512 will be a positive voltage.  So it is necessary to first &quot;invert&quot; the reading, which can simply be done by subtracting it from 1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it's just a matter of sampling often enough and recording the peak (and negative peak) values over a short period.  The faster you can sample the better your results will be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From those peak values you can then do all sorts of calculations and things.  You can use them &quot;as is&quot; to directly give you the &quot;peak-to-peak&quot; current, or calculate the RMS voltage to then give you the RMS current.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-28T23:16:13.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14644" PostTypeId="1" AcceptedAnswerId="14646" CreationDate="2015-08-29T06:59:56.187" Score="0" ViewCount="83" Body="&lt;p&gt;I want to make an LED one digit display using 14 leds used in pairs so I have 7 pairs which show number. (Similar to the display in calculators). Now the problem is that my code won't function properly. The problem that is arising is that the leds won't go off, all of them would work at the same time, here's the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a = 2;&#xA;int b = 3;&#xA;int c = 4;&#xA;int d = 5;&#xA;int e = 6;&#xA;int f = 7;&#xA;int g = 8;&#xA;&#xA;void setup()&#xA;{&#xA;   for(int i = 2; i++ ; i&amp;lt;9)&#xA;   {&#xA;      pinMode (i, OUTPUT);&#xA;   }&#xA;}&#xA;void _1()&#xA;{&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _2()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( e, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _3()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _4()&#xA;{&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _5()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _6()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( e, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _7()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _8()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( e, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _9()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( d, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void _0()&#xA;{&#xA;   digitalWrite ( a, HIGH);&#xA;   digitalWrite ( b, HIGH);&#xA;   digitalWrite ( c, HIGH);&#xA;   digitalWrite ( e, HIGH);&#xA;   digitalWrite ( f, HIGH);&#xA;   digitalWrite ( g, HIGH);&#xA;   delay(1000);&#xA;}&#xA;void wait()&#xA;{&#xA;   digitalWrite ( a, LOW);&#xA;   digitalWrite ( b, LOW);&#xA;   digitalWrite ( c, LOW);&#xA;   digitalWrite ( d, LOW);  &#xA;   digitalWrite ( e, LOW);&#xA;   digitalWrite ( f, LOW);&#xA;   digitalWrite ( g, LOW);&#xA;   delay(100);&#xA;}&#xA;void loop()&#xA;{&#xA;   _0();&#xA;   wait();&#xA;   _1();&#xA;   wait();&#xA;   _2();&#xA;   wait();&#xA;   _3();&#xA;   wait();&#xA;   _4();&#xA;   wait();&#xA;   _5();&#xA;   wait();&#xA;   _6();&#xA;   wait();&#xA;   _7();&#xA;   wait();&#xA;   _8();&#xA;   wait();&#xA;   _9();&#xA;   wait();  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that it stays at _0 and then never changes. Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="10408" LastEditorUserId="313" LastEditDate="2015-08-29T13:49:55.900" LastActivityDate="2015-08-29T13:49:55.900" Title="Arduino code of making a LED digit display not functioning properly" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14646" PostTypeId="2" ParentId="14644" CreationDate="2015-08-29T07:31:36.050" Score="2" Body="&lt;p&gt;The &lt;code&gt;for&lt;/code&gt; loop in your &lt;code&gt;setup()&lt;/code&gt; function isn't quite right. The condition (&lt;code&gt;i&amp;lt;9&lt;/code&gt;) and the iterator (&lt;code&gt;i++&lt;/code&gt;) need to be the other way round, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 2; i&amp;lt;9; i++)&#xA;{&#xA;  pinMode (i, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="42" LastActivityDate="2015-08-29T07:31:36.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14647" PostTypeId="1" AcceptedAnswerId="14649" CreationDate="2015-08-29T07:51:06.133" Score="8" ViewCount="10316" Body="&lt;p&gt;I'm trying to build a system where if a cable gets disconnected from a pin (any pin), an action is executed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering how to set this up. Can I simply wire the 5V to a pin and read its status or will this mess up the Arduino? Should I use any resistors? How should I connect this to the GND? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please bear in mind that I'm pretty new to all of this.&lt;/p&gt;&#xA;" OwnerUserId="11586" LastEditorUserId="6936" LastEditDate="2016-02-21T08:17:28.247" LastActivityDate="2017-10-21T11:43:30.810" Title="How can I detect a disconnected pin?" Tags="|pins|arduino-nano|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14648" PostTypeId="2" ParentId="14647" CreationDate="2015-08-29T08:51:27.637" Score="1" Body="&lt;p&gt;You can connect all pins through a 1M resistor to a rail. Once in a while you set all your outputs to inputs and toggle the rail HIGH and LOW, if the inputs are HIGH and LOW in the sequence you toggled the rail, there is no wire. The same question was asked at Arduino Forums so read &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=183977.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; thread.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question's answer was provided by johnwasser@forum.arduino.cc.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-08-29T14:56:39.387" LastActivityDate="2015-08-29T14:56:39.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14649" PostTypeId="2" ParentId="14647" CreationDate="2015-08-29T09:59:34.037" Score="9" Body="&lt;p&gt;The way to do this, since there is no digital value in between HIGH and LOW, is to actively create a signal on the pin you can recognise.  Note that if the signal coming in to the pin is a datastream (a sequence of HIGH and LOW) that runs all the time this may not work reliably, but it's good for things like buttons and other simple sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any signal on a wire has a &lt;em&gt;drive strength&lt;/em&gt;.  This is basically how powerful the signal is and how good it is at overriding other things happening on the same wire.  It is closely related to the output impedance of the source (what is sending the signal).  For things like buttons and switches that is basically the value of the pullup resistor used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To actively sense if a pin is disconnected or not you need to temporarily connect it to a known signal level &lt;em&gt;at the same time&lt;/em&gt; as it's connected to the wire (or not connected if it happens to be not connected).  This known signal level has to be of a &lt;em&gt;weaker&lt;/em&gt; drive than the source signal by several orders of magnitude.  This ensures that if you try superimposing your test signal over the incoming signal the incoming signal swamps out the test signal and you don't see it at all.  For instance, if your source has 10KΩ impedance (say a button with 10KΩ pullup resistor) then a test signal with source impedance of 1MΩ would be suitable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each pin to be tested can be connected to its own 1MΩ (in this example) resistor, and those resistors are all connected to the same extra IO pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/soUQi.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/soUQi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example pin D2 is the test pin, and pins D4-D7 are your inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So under normal circumstances pin D2 is set as an input and completely ignored.  When you come to test the pins, though, you set it as an output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then set D2 to be HIGH and read each of D4 through D7.  Any that read as HIGH are candidates for being not connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then set D2 to be LOW and read the pins that read HIGH before.  Any that now read as LOW are disconnected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then set D2 back to being an input again so it doesn't interfere with normal operations.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you just want to know if current is flowing in a wire you can use what is called a &lt;em&gt;shunt resistor&lt;/em&gt;.  This is a small resistor (maybe 1Ω) that is placed in-line with the wire and you measure the voltage (using Arduino analog inputs) at both sides of the resistor.  The voltage dropped across the resistor is directly proportional to the current flowing through it thanks to Ohm's Law:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I=V/R&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MKALi.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MKALi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the voltage read by A1 should be 5V (the voltage the wire is connected to) and the voltage read by A0 should be 4.93V, the voltage &lt;em&gt;dropped&lt;/em&gt; by the resistor would be 5-4.93 = 0.07v.  With the 1Ω resistor the current would be 0.07/1 = 0.07A, or 70mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the wire at OUT disconnected there will be zero current flowing since there is no circuit.  So re-arranging the formula above we can prove that we can tell it's disconnected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I=V/R then V = RI.  Therefore V = 1Ω × 0A = 0V.  So the voltage dropped across the resistor would be 0V, so A0 and A1 would be equal (discounting any noise). A0 and A1 would both read 5V.  Similarly, if the wire IN was disconnected instead then A0 and A1 would both read 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For sensing higher currents you use a smaller resistance, and for sensing smaller currents you use a larger resistance - this allows for a voltage drop to be generated that is within a suitable range for the sensitivity of the ADC doing the reading.  For the Arduino that's a 10-bit ADC, so it can sense (with a 5V V&lt;sub&gt;REF&lt;/sub&gt;) 5/1024=4.882813mV per LSB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you are working with voltages above that at which the Arduino operates you will need to separate or otherwise scale those voltages.  There are special devices designed especially for this task called &lt;em&gt;high side current shunt amplifiers&lt;/em&gt;.  They also allow you to use a smaller resistance than you would otherwise need which is less intrusive to your circuit (less voltage drop).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T09:59:34.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14650" PostTypeId="1" CreationDate="2015-08-29T10:22:52.510" Score="0" ViewCount="68" Body="&lt;p&gt;I have one Arduino uno, and one atmega8a 1337 ic. Can i replace the Arduino uno ic with 1337 to program the 1337 one?&lt;/p&gt;&#xA;" OwnerUserId="10408" LastActivityDate="2015-08-29T10:31:50.423" Title="Replacing Atmega8a pu 1440 arduino Ic with 1337" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14651" PostTypeId="2" ParentId="14650" CreationDate="2015-08-29T10:31:50.423" Score="2" Body="&lt;p&gt;If you have a bootloader installed on the 8A then yes, you can.  The two chips are pin and electrically compatible.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T10:31:50.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14652" PostTypeId="1" CreationDate="2015-08-29T14:24:26.417" Score="1" ViewCount="401" Body="&lt;p&gt;I am Trying to make a MicroSD .wav file player using Arduino Uno. I have ordered a MicroSD Card Module from ebay today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product Link : &lt;a href=&quot;http://www.ebay.in/itm/Micro-SD-Card-Module-SD-Storage-Board-TF-Card-Memory-Shield-SPI-For-Arduino-/161696480012&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.in/itm/Micro-SD-Card-Module-SD-Storage-Board-TF-Card-Memory-Shield-SPI-For-Arduino-/161696480012&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As You can See in the Product Image, there is &lt;strong&gt;not mentioned on the PCB that which Pin Is ground&lt;/strong&gt; or VCC Or any other SPI pin. &#xA;1. How will I identify the correct pins of the MicroSD Module ?&#xA;2. How can I connect a speaker to arduino to play .wav files. Is Amplifier neccessary? I am weak when it comes to electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have listened that when I connect a Capacitor in series with speaker, it will boost the output volume. There will not be music but only voice recordings in .wav files. I want to listen it clearly only.&lt;/p&gt;&#xA;" OwnerUserId="11772" LastActivityDate="2015-09-04T03:54:37.173" Title="Help Connecting MicroSD Module with Arduino Uno" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14653" PostTypeId="2" ParentId="14652" CreationDate="2015-08-29T14:33:04.190" Score="1" Body="&lt;p&gt;OMG, what a vile listing!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I think you'll probably find they are in the order listed in the description when the connector is facing south. It's probably printed on the rear of the board which they don't show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, from left to right, GND, VCC, MISO, MOSI, SCK, CS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for connecting a speaker, that depends if you want low quality (PWM) audio, or high quality (DAC) audio.  The latter requires the addition of an audio shield, most of which have an SD card slot on them already thus alleviating the need for this SD card breakout board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the former there is a library and instructions here: &lt;a href=&quot;http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio&quot; rel=&quot;nofollow&quot;&gt;http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T14:33:04.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14654" PostTypeId="1" AcceptedAnswerId="14657" CreationDate="2015-08-29T15:23:50.307" Score="0" ViewCount="1280" Body="&lt;p&gt;How would i capture the following serial data, and split it into parts?&#xA;&lt;code&gt;&amp;lt;Alarm,MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the parts i need from this is&#xA;Alarm - This is a state. i.e Alarm, Idle, Paused, Working&#xA;MPos: - This is a series of positions X,Y,Z&#xA;WPos: - This is a series of positions X,Y,Z&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i want to do is capture the string from serial (See above for formatting)&#xA;Then display the information on the LCD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e.&#xA;X: 0.000  Y:0.000&#xA;Z: 0.000  Idle&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've managed to figure out how to do all the LCD display stuff, and send commands to the serial, but it appears there are so many variations on how to split the data up, that i't really confusing to me, as well, almost all of the examples i find use loop to do this, but i would like to have this done in a function, that way i can display this info only when needed, not constantly, as i'll be useing the LCD for a menu system.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="12076" LastEditDate="2015-08-29T15:37:45.950" LastActivityDate="2015-08-29T16:03:16.917" Title="How would i capture and split serial data?" Tags="|arduino-uno|serial|arduino-mega|arduino-ide|lcd|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14655" PostTypeId="2" ParentId="14628" CreationDate="2015-08-29T15:34:05.590" Score="1" Body="&lt;p&gt;Is the cable shielded? &#xA;Have to performed continuity test on all leads of the cable to ensure there no break internally that could be causing an issue, or a short?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the impedance of your total length of cable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These sorts of checks will help you further narrow down the issue. If you are certain your wiring is correct, then the most probable issue is either a hardware failure (continuity test)&#xA;a hardware limitation (Too much resistance for accurate data travel)&#xA;Improper Hardware, unshielded wires can be subject to crosstalk, or signal corruption/distortion due to external signals interfering. &lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-08-29T15:34:05.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14656" PostTypeId="1" CreationDate="2015-08-29T16:00:45.857" Score="0" ViewCount="159" Body="&lt;p&gt;I've had an idea for an Arduino project, but I'm not sure where to start. My idea is this: have an Arduino Nano connected to an HC-SR04 ultrasonic sensor, as well as an nRF24L01+ radio. This will be the tripwire module, which will send an alert to a second Arduino (connected to another nRF24L01+ of course) whenever something passes by. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This wouldn't be a stationary unit, it would need to be able to be placed and sense in a variety of locations so the distance would need to be set on power up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue I'm running into is getting the nRF24L01+ units to work for this purpose. I want to know that the units are wirelessly connected, so having a packet sent every second or so lets the receiving unit know that they're connected, and an additional packet for the tripwire trigger sets off an indicator led.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this even possible?&lt;/p&gt;&#xA;" OwnerUserId="12077" LastActivityDate="2015-08-29T17:27:19.773" Title="Remote Wireless Tripwire" Tags="|nrf24l01+|remote-control|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14657" PostTypeId="2" ParentId="14654" CreationDate="2015-08-29T16:03:16.917" Score="2" Body="&lt;p&gt;This string is actually fairly easy to split up, because everything is separated by commas nice and regularly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you have the string in a char array (aka a C string) and not a String object (I and most other programmers abhor the String class) you can use the function &lt;code&gt;strtok()&lt;/code&gt; to split the string up into parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char string[] = &quot;&amp;lt;Alarm,MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000&amp;gt;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;code&gt;strtok()&lt;/code&gt; takes, on its first call, the string you want to split and the delimiter that you want to split on.  It returns a pointer to the chunk:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *alarm = strtok(string, &quot;,&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;alarm&lt;/code&gt; now contains &lt;code&gt;&amp;lt;Alarm&lt;/code&gt; and &lt;code&gt;strtok()&lt;/code&gt; moves its internal pointer to point at the next character, so it sees the string as &lt;code&gt;MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the next and subsequent calls to &lt;code&gt;strtok()&lt;/code&gt; you don't give it the string, or it will reset its internal pointer.  You just pass it &lt;code&gt;NULL&lt;/code&gt; and it gives you the next block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *mposX = strtok(NULL, &quot;,&quot;);&#xA;char *mposY = strtok(NULL, &quot;,&quot;);&#xA;char *mposZ = strtok(NULL, &quot;,&quot;);&#xA;char *wposX = strtok(NULL, &quot;,&quot;);&#xA;char *wposY = strtok(NULL, &quot;,&quot;);&#xA;char *wposZ = strtok(NULL, &quot;&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I changed the delimiter on the last one to &lt;code&gt;&amp;gt;&lt;/code&gt; so it chops off that extra character that we don't want (and there is no &lt;code&gt;,&lt;/code&gt; after the last part).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have 7 variables that point to chunks of the string, which has internally been chopped up and modified into individual substrings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*alarm = &quot;&amp;lt;Alarm&quot;;&#xA;*mposX = &quot;MPos:0.000&quot;;&#xA;*mposY = &quot;0.000&quot;;&#xA;*mposZ = &quot;0.000&quot;;&#xA;*wposX = &quot;WPos:0.000&quot;;&#xA;*wposY = &quot;0.000&quot;;&#xA;*wposZ = &quot;0.000&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now we can clean up the three entries that have extra stuff in them, and that is a simple as adding an offset value to the pointers we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;alarm += 1;&#xA;mposX += 5;&#xA;wposX += 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Our list of pointers now looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*alarm = &quot;Alarm&quot;;&#xA;*mposX = &quot;0.000&quot;;&#xA;*mposY = &quot;0.000&quot;;&#xA;*mposZ = &quot;0.000&quot;;&#xA;*wposX = &quot;0.000&quot;;&#xA;*wposY = &quot;0.000&quot;;&#xA;*wposZ = &quot;0.000&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The position variables can now be passed through strtod() to convert them to float values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float mx = strtod(mposX, NULL);&#xA;float my = strtod(mposY, NULL);&#xA;float mz = strtod(mposZ, NULL);&#xA;float wx = strtod(wposX, NULL);&#xA;float wy = strtod(wposY, NULL);&#xA;float wz = strtod(wposZ, NULL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can do different things depending on the content of the &lt;code&gt;*alarm&lt;/code&gt; string by using &lt;code&gt;strcmp()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (strcmp(alarm, &quot;Busy&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can just use it to print the content to the LCD.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T16:03:16.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14658" PostTypeId="2" ParentId="14656" CreationDate="2015-08-29T17:27:19.773" Score="1" Body="&lt;p&gt;This sounds very doable. The first point, tuning the distance threshold at startup, could be done with a bank of DIP switches or a potentiometer on an analog pin to set the value. You might include some startup code continuously pings the transducer and displays the result on an LED, until you press a button to tell it &quot;use this&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second, is a very typical communication technique - sending &quot;hello&quot; packets periodically to confirm that communication is up. In your case, the same packet could carry a hit/no-hit bit within it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-29T17:27:19.773" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14659" PostTypeId="1" AcceptedAnswerId="14660" CreationDate="2015-08-29T18:56:10.477" Score="1" ViewCount="2325" Body="&lt;p&gt;After creating a working prototype with DIP ATMega328 chip/ Arduino UNO I recently got PCBs assembled with SMD components and ATMega328P TQFP soldered onto them, but now I'm having a hard time trying to upload the Arduino program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is the schematic of the PCB with ATMega328P TQFP with ISP headers for programming:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/agw3N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/agw3N.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using USBasp programmer with upgraded firmware to upload the code. The chip gets detected and also I can upload sketches to it but the problem is the code runs slow, which I found out is due to the default 8MHz internal clock.(the blink program makes LED blink every 16 seconds instead of 1 second,i.e. with delay(1000))&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to switch to the external 16MHz clock which I want to use I found out &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=71580.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; that I have to change the fuse values from the default &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;lfuse: 0x62   hfuse: 0xD9   efuse: 0x3F&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;lfuse: 0xFF   hfuse: 0xDE   efuse: 0x05&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried it two times and both the times it screwed up the ATMega328P chip&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\p&amp;gt;avrdude -p m328p -c usbasp -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efu&#xA;se:w:0x05:m&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: reading input file &quot;0xFF&quot;&#xA;avrdude: writing lfuse (1 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.02s&#xA;&#xA;avrdude: 1 bytes of lfuse written&#xA;avrdude: verifying lfuse memory against 0xFF:&#xA;avrdude: load data lfuse data from input file 0xFF:&#xA;avrdude: input file 0xFF contains 1 bytes&#xA;avrdude: reading on-chip lfuse data:&#xA;&#xA;Reading | ################################################## | 100% 0.01s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 1 bytes of lfuse verified&#xA;avrdude: reading input file &quot;0xDE&quot;&#xA;avrdude: writing hfuse (1 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: 1 bytes of hfuse written&#xA;avrdude: verifying hfuse memory against 0xDE:&#xA;avrdude: load data hfuse data from input file 0xDE:&#xA;avrdude: input file 0xDE contains 1 bytes&#xA;avrdude: reading on-chip hfuse data:&#xA;&#xA;Reading | ################################################## | 100% 0.01s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 1 bytes of hfuse verified&#xA;avrdude: reading input file &quot;0x05&quot;&#xA;avrdude: writing efuse (1 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: 1 bytes of efuse written&#xA;avrdude: verifying efuse memory against 0x05:&#xA;avrdude: load data efuse data from input file 0x05:&#xA;avrdude: input file 0x05 contains 1 bytes&#xA;avrdude: reading on-chip efuse data:&#xA;&#xA;Reading | ################################################## | 100% 0.01s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 1 bytes of efuse verified&#xA;&#xA;avrdude: safemode: Fuses OK&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;&#xA;C:\Users\p&amp;gt;avrdude -p m328p -c usbasp&#xA;&#xA;avrdude: error: programm enable: target doesn't answer. 1&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both of the PCBs are not responding to the USBasp programmer and now I have only got one PCB left. I desperately want to get the final one working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my first time using the SMD ATMega328P chips and any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="12072" LastEditorUserId="46" LastEditDate="2015-09-02T13:45:56.760" LastActivityDate="2016-07-09T19:05:03.870" Title="Cannot upload sketch to Atmega328p TQFP soldered on PCB" Tags="|arduino-uno|arduino-ide|atmega328|programmer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14660" PostTypeId="2" ParentId="14659" CreationDate="2015-08-29T19:05:39.797" Score="3" Body="&lt;p&gt;It looks like the capacitors on your crystal are considerably bigger than they should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are switching the clock to the external crystal, and because you have such massive capacitors on it it's failing to oscillate.  Without that oscillation the chip can't run, and so it can't respond to the programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The crystal capacitors should be roughly 2x the &quot;load capacitance&quot; of the crystal you are using.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C&lt;sub&gt;X1&lt;/sub&gt; = C&lt;sub&gt;X2&lt;/sub&gt; = 2(C&lt;sub&gt;L&lt;/sub&gt; - C&lt;sub&gt;STRAY&lt;/sub&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T19:05:39.797" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="14661" PostTypeId="1" AcceptedAnswerId="14664" CreationDate="2015-08-29T19:15:10.747" Score="1" ViewCount="96" Body="&lt;p&gt;I need to parse text coming into my MC (Leonardo) over the hardware serial port. The data comes in burst, and the parsing routine manage the data flow with easy when it is less than the serial buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will like to be able to receive around 512Kb of serial data, save it somewhere (not in the arduino memory of course) and the execute the parsing routine on it. I think saving the stream to an external EEPROM and then retrieving it slowly so my parsing code can actually fallows will do the trick. I can control the speed of the serial stream from 300 bauds (not optimal) up to 112000 bauds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the approach correct? Can I write to the EEPROM faster than a 9600 bauds serial stream without collapsing the arduino?&lt;/p&gt;&#xA;" OwnerUserId="12021" LastActivityDate="2015-08-29T22:59:41.383" Title="Handling serial streams biggers than the available ram" Tags="|serial|arduino-leonardo|eeprom|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14662" PostTypeId="1" AcceptedAnswerId="14663" CreationDate="2015-08-29T21:35:16.160" Score="1" ViewCount="2477" Body="&lt;p&gt;I, once again have difficulties including libraries from code files other than my .ino file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several .cpp and .h files in my project to keep it sorted and clean. &#xA;However one of my header files starting like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef DPLANDEF&#xA;#define DPLANDEF&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &quot;syssettings.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yields the following errors:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In file included from&#xA;  /var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build4605486877500371361.tmp/dplan.cpp:2:0:&#xA;  /var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build4605486877500371361.tmp/dplan.h:5:20:&#xA;  fatal error: EEPROM.h: No such file or directory  #include &#xA;                      ^ compilation terminated. Fehler beim Kompilieren.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;EEPROM.h should be known to the IDE, because I can find it in the libraries menu, too. If it was a custom library, I might have botched something during installation, but this is a standard library. It should work out of the box. What's the problem here?&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-08-29T21:58:11.573" Title="Including libraries from header files sometimes doesn't work" Tags="|arduino-ide|core-libraries|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14663" PostTypeId="2" ParentId="14662" CreationDate="2015-08-29T21:58:11.573" Score="2" Body="&lt;p&gt;The problem here is that it's a header file.  The IDE doesn't treat header files like it does INO files - it doesn't parse them for included libraries, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for it to work you must also include EEPROM.h in your main INO file so that the IDE knows that you want to include it in the rest of your files.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-29T21:58:11.573" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="14664" PostTypeId="2" ParentId="14661" CreationDate="2015-08-29T22:59:41.383" Score="2" Body="&lt;p&gt;You can parse indefinitely large amounts of data with a state machine parser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;General description: &lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;State machines&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, I wrote recently an &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12942&quot; rel=&quot;nofollow&quot;&gt;HTTP server&lt;/a&gt; which parses incoming HTTP data (eg. cookies, parameters, POST data, GET data) on-the-fly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need enough RAM for &lt;strong&gt;one&lt;/strong&gt; item of data, naturally. But then you act upon it, and then discard it. In the case of the web server, you could conceivably process a complex form with thousands of actions on it (eg. turn on switch 5, pump 3, heater 22). It parses each action, and then you act on it, then you parse another action.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can even consider the Arduino bootloader as an example of this. The Optiboot bootloader is 512 bytes on a Uno, but it can re-flash 32 KB of program memory. How? The programming data comes down in bursts (packets, if you like) and it processes each packet at a time, then discards it and reads the next one.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-29T22:59:41.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14665" PostTypeId="1" CreationDate="2015-08-30T01:24:09.200" Score="1" ViewCount="3912" Body="&#xA;&#xA;&lt;p&gt;I googled solutions and tried, but I still cannot get it working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried BlinkwithoutDelay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel it is very confusing to track timing of two motors (i.e., step, direction, speed) for the following routine loop:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;step 1: run motorA_forward() for 10 seconds; &lt;/li&gt;&#xA;&lt;li&gt;step 2: run motorAB_stop() for 1 seconds; &lt;/li&gt;&#xA;&lt;li&gt;step 3: run motorB_backward() for 3 seconds&lt;/li&gt;&#xA;&lt;li&gt;step 4: run motorAB_stop() for 1 seconds&lt;/li&gt;&#xA;&lt;li&gt;step 5: run motorA_backward() for 10 seconds&lt;/li&gt;&#xA;&lt;li&gt;step 6: run motorAB_stop() for 1 seconds&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please help me on this!! I really appreciate your time and comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is my working code. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// ----------LIBRARIES--------------&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LIDARLite.h&amp;gt;&#xA;LIDARLite myLidarLite;&#xA;&#xA;&#xA;// ----------CONSTANTS--------------&#xA;&#xA;const int motorA_pin_1 = 8;           // the pin numbers for the motors&#xA;const int motorA_pin_2 = 11;&#xA;const int motorA_pin_speed = 9;&#xA;const int motorB_pin_1 = 12;&#xA;const int motorB_pin_2 = 13;&#xA;const int motorB_pin_speed = 10;&#xA;&#xA;//------------VARIABLES--------------&#xA;&#xA;byte motorA_state_1 = LOW;             // used to record whether the motots are on or off&#xA;byte motorA_state_2 = LOW;             // LOW = off&#xA;byte motorB_state_1 = LOW;             &#xA;byte motorB_state_2 = LOW;             &#xA;&#xA;int currentMillis               = 0;     // stores the value of millis() in each iteration of loop()&#xA;int motorA_Forward_Interval     = 5000;  // will store last time the motor was moved&#xA;int motorA_Backward_Interval    = 5000; // will store last time the motor was moved&#xA;int motorA_Stop_Interval        = 2000;  // will store last time the motor was moved&#xA;int motorB_Stop_Interval        = 2000;  // will store last time the motor was moved&#xA;int motorAB_BreakTime_Interval  = 2000;&#xA;&#xA;unsigned long motorA_Forward_Timer      = 0;     // will store last time motorA start was updated&#xA;unsigned long motorA_Backward_Timer     = 0;     // will store last time motorA start was updated&#xA;unsigned long motorB_Forward_Timer      = 0;     // will store last time motorA start was updated&#xA;unsigned long motorB_Backward_Timer     = 0;     // will store last time motorA start was updated&#xA;unsigned long BreakTime_timer   = 0;     // will store last time motorA/B break time was updated&#xA;&#xA;&#xA;//------------INITIALIZATION--------------&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(115200);&#xA;  myLidarLite.begin();&#xA;&#xA;  pinMode(motorA_pin_1,OUTPUT);         // set the motor pins as output:&#xA;  pinMode(motorA_pin_2,OUTPUT); &#xA;  pinMode(motorA_pin_speed,OUTPUT); &#xA;  pinMode(motorB_pin_1,OUTPUT); &#xA;  pinMode(motorB_pin_2,OUTPUT); &#xA;  pinMode(motorB_pin_speed,OUTPUT);&#xA;&#xA;&#xA;}&#xA;&#xA;//------------LOOPING----------------------&#xA;// Notice that none of the action happens in loop() apart from reading millis()&#xA;// It just calls the functions that have the action code&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(myLidarLite.distance());&#xA;&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    motorA_forward();  // for 10 seconds&#xA;    motorAB_stop();    // for 1 seconds&#xA;    motorB_backward(); // for 3 seconds&#xA;    motorAB_stop();    // for 1 seconds&#xA;    motorA_backward(); // for 10 seconds&#xA;    motorAB_stop();    // for 1 seconds&#xA;&#xA;}&#xA;&#xA;//------------SUBROUTINE----------------------&#xA;&#xA;&#xA;void motorA_forward()&#xA;{   &#xA;  if(currentMillis - motorA_Forward_Timer &amp;lt;= motorA_Forward_Interval)&#xA;  {&#xA;    motorA_state_1 = HIGH;   // Turn motor A on - backward&#xA;    motorA_state_2 = LOW;  // &#xA;    motorB_state_1 = LOW;   // Turn motor B off&#xA;    motorB_state_2 = LOW;   // &#xA;&#xA;    analogWrite(motorA_pin_speed,255);&#xA;    digitalWrite(motorA_pin_1,motorA_state_1);&#xA;    digitalWrite(motorA_pin_2,motorA_state_2);&#xA;    analogWrite(motorB_pin_speed,255);&#xA;    digitalWrite(motorB_pin_1,motorB_state_1);&#xA;    digitalWrite(motorB_pin_2,motorB_state_2);&#xA;&#xA;    motorA_Forward_Timer = currentMillis;&#xA;  }&#xA;}&#xA;&#xA;void motorA_backward()&#xA;{&#xA;    if(currentMillis - motorA_Backward_Timer &amp;lt;= motorA_Backward_Interval)&#xA;  {&#xA;    motorA_state_1 = LOW;   // Turn motor A on - backward&#xA;    motorA_state_2 = HIGH;  // &#xA;    motorB_state_1 = LOW;   // Turn motor B off&#xA;    motorB_state_2 = LOW;   // &#xA;&#xA;    analogWrite(motorA_pin_speed,255);&#xA;    digitalWrite(motorA_pin_1,motorA_state_1);&#xA;    digitalWrite(motorA_pin_2,motorA_state_2);&#xA;    analogWrite(motorB_pin_speed,255);&#xA;    digitalWrite(motorB_pin_1,motorB_state_1);&#xA;    digitalWrite(motorB_pin_2,motorB_state_2);&#xA;&#xA;    motorA_Backward_Timer += currentMillis;&#xA;  }&#xA;}&#xA;&#xA;void motorB_forward()&#xA;{&#xA;    motorA_state_1 = LOW;   // Turn motor A off&#xA;    motorA_state_2 = LOW;   // &#xA;    motorB_state_1 = HIGH;  // Turn motor B on - forward&#xA;    motorB_state_2 = LOW;   // &#xA;&#xA;    analogWrite(motorA_pin_speed,255);&#xA;    digitalWrite(motorA_pin_1,motorA_state_1);&#xA;    digitalWrite(motorA_pin_2,motorA_state_2);&#xA;    analogWrite(motorB_pin_speed,255);&#xA;    digitalWrite(motorB_pin_1,motorB_state_1);&#xA;    digitalWrite(motorB_pin_2,motorB_state_2);&#xA;&#xA;    motorB_Forward_Timer = currentMillis;&#xA;}&#xA;&#xA;void motorB_backward()&#xA;{&#xA;    motorA_state_1 = LOW;   // Turn motor A off&#xA;    motorA_state_2 = LOW;   // &#xA;    motorB_state_1 = LOW;   // Turn motor B on - backward&#xA;    motorB_state_2 = HIGH;  // &#xA;&#xA;    analogWrite(motorA_pin_speed,255);&#xA;    digitalWrite(motorA_pin_1,motorA_state_1);&#xA;    digitalWrite(motorA_pin_2,motorA_state_2);&#xA;    analogWrite(motorB_pin_speed,255);&#xA;    digitalWrite(motorB_pin_1,motorB_state_1);&#xA;    digitalWrite(motorB_pin_2,motorB_state_2);&#xA;&#xA;    motorB_Backward_Timer = currentMillis;&#xA;}&#xA;&#xA;void motorAB_stop()&#xA;{&#xA;    motorA_state_1 = LOW;   // Turn motor A off&#xA;    motorA_state_2 = LOW;   // &#xA;    motorB_state_1 = LOW;   // Turn motor B off&#xA;    motorB_state_2 = LOW;  // &#xA;&#xA;    analogWrite(motorA_pin_speed,0);&#xA;    digitalWrite(motorA_pin_1,motorA_state_1);&#xA;    digitalWrite(motorA_pin_2,motorA_state_2);&#xA;    analogWrite(motorB_pin_speed,0);&#xA;    digitalWrite(motorB_pin_1,motorB_state_1);&#xA;    digitalWrite(motorB_pin_2,motorB_state_2);&#xA;&#xA;    BreakTime_timer = currentMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12083" LastEditorUserId="10794" LastEditDate="2015-08-30T02:25:45.450" LastActivityDate="2015-09-29T11:51:24.933" Title="run two motors in turns without using delay()" Tags="|arduino-uno|c++|motor|millis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14666" PostTypeId="5" CreationDate="2015-08-30T02:00:24.223" Score="0" Body="&lt;h2&gt;What is a PID controller?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A PID controller continuously calculates an &quot;error value&quot; as the difference between a measured process variable and a desired setpoint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The letters PID stand for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Proportional&lt;/li&gt;&#xA;&lt;li&gt;Integral&lt;/li&gt;&#xA;&lt;li&gt;Derivative&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically a PID algorithm takes two variables:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The current measured value (eg. current fish tank temperature)&lt;/li&gt;&#xA;&lt;li&gt;The desired (target) temperature (eg. 25 °C)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The output is the &lt;strong&gt;manipulated variable&lt;/strong&gt; (eg. in this case the amount of power to a heater).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if the measured temperature was 20 °C and the target temperature was 25 °C, then the manipulated variable might be 5 (being the difference between the target and the actual).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;proportional&lt;/strong&gt; configuration parameter simply multiplies the error by a fixed (proportional) amount. So in this case as the temperature of the tank approaches the target it would reduce the power to the heater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;derivative&lt;/strong&gt; configuration parameter multiplies the error by a derivative of the error (that is, the rate of change of the error). This means you might reduce the power as the temperature approaches the target, so as to not overshoot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;integral&lt;/strong&gt; configuration parameter multiplies the error by the accumulation of past errors, to compensate for the corrections being applied too slowly or too quickly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Library&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There is an Arduino PID library (see Reference below) which allows you to supply the appropriate variables (target, error) and your tuning parameters (P, I and D).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You call the &lt;code&gt;Compute&lt;/code&gt; function from time to time (eg. when going through the main loop) and it calculates a new manipulated variable, which you would then use to control your heater / motor / cooler / light or whatever-it-is you are controlling.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/PID_controller&quot; rel=&quot;nofollow&quot;&gt;Wikipedia: PID controller&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow&quot;&gt;Arduino Playground: PID library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/br3ttb/Arduino-PID-Library/&quot; rel=&quot;nofollow&quot;&gt;Arduino-PID-Library on GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/&quot; rel=&quot;nofollow&quot;&gt;Improving the Beginner’s PID – Introduction / Documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:58:03.323" LastActivityDate="2015-08-30T23:58:03.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14667" PostTypeId="4" CreationDate="2015-08-30T02:00:24.223" Score="0" Body="A PID controller is a control loop feedback mechanism (controller) commonly used in industrial control systems. Use this tag for discussions about PID algorithms and libraries." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:43.217" LastActivityDate="2015-08-30T23:57:43.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14668" PostTypeId="2" ParentId="6617" CreationDate="2015-08-30T02:18:14.173" Score="2" Body="&lt;p&gt;If what you want is to tell apart 2 devices that are basically identical, you have 2 ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;always plug them in the same ports and use the USB tree to differentiate them&lt;/li&gt;&#xA;&lt;li&gt;create an handshake protocol, where each Arduino uses a code that you have previously stored in their respective EEPROMs. It might even be possible to write a helper function for UDEV, so that the helper function does the handshake and tells UDEV the serial that is stored in each EEPROM. That would allow to write a UDEV rule for your devices.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-30T02:18:14.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14669" PostTypeId="2" ParentId="14665" CreationDate="2015-08-30T02:23:32.857" Score="2" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int currentMillis               = 0;     // stores the value of millis() in each iteration of loop()&#xA;...&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(myLidarLite.distance());&#xA;    unsigned long currentMillis = millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have &lt;strong&gt;two&lt;/strong&gt; &lt;code&gt;currentMillis&lt;/code&gt; variables. The global one never changes. You change a &lt;strong&gt;different&lt;/strong&gt; one inside &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Remove the data definition. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    Serial.println(myLidarLite.distance());&#xA;    currentMillis = millis();  // change the global variable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also make the &lt;strong&gt;global&lt;/strong&gt; one unsigned long:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long currentMillis               = 0;     // stores the value of millis() in each iteration of loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-30T02:23:32.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14670" PostTypeId="2" ParentId="12133" CreationDate="2015-08-30T02:49:22.300" Score="0" Body="&lt;p&gt;Stumbled across this. It worked for Mac OS X Yosemite 10.10.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;install the CH340 driver&#xA;Run the command in Terminal:&#xA;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&#xA;Reboot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I installed:&#xA;MAC system：www.wch.cn/downfile/178&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so YMMV&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a user here:&#xA;&lt;a href=&quot;http://forum.makeblock.cc/t/mac-os-x-yosemite-arduino-1-0-6-doesnt-recognize-makeblock-orion/728&quot; rel=&quot;nofollow&quot;&gt;http://forum.makeblock.cc/t/mac-os-x-yosemite-arduino-1-0-6-doesnt-recognize-makeblock-orion/728&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;found the solution, there:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=261375.15&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=261375.15&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so kudos - to all that sweated out the driver, uninstall, install, and activation...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ted&lt;/p&gt;&#xA;" OwnerUserId="12085" LastEditorUserId="12085" LastEditDate="2015-08-30T02:58:50.367" LastActivityDate="2015-08-30T02:58:50.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14671" PostTypeId="5" CreationDate="2015-08-30T05:27:34.740" Score="0" Body="&lt;p&gt;A pull-up resistor is used to avoid having a pin &quot;float&quot; with undefined voltages, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ll2Tm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ll2Tm.png&quot; alt=&quot;Pull-up resistor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example the Arduino pin is kept at a &lt;code&gt;HIGH&lt;/code&gt; level by the resistor. However if the switch is closed the pin becomes &lt;code&gt;LOW&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally a high-value resistor (like, 10 k or more, possibly 100 k or even 1 M ohms) is used. When the switch is closed the 5 V line will be connected to Ground via the pull-up resistor, so you don't want too high a current to flow. In the above example the current would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I = V / R&#xA;I = 5 / 10000&#xA;I = 0.5 mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Open-drain&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Pull-up resistors are also used for &quot;open-drain&quot; designs, such as used in I&lt;sup&gt;2&lt;/sup&gt;C. In such designs the data or clock lines are &quot;pulled high&quot; by a pull-up resistor, with multiple devices connected to the bus. When one of them wants to send a 0-bit they drive the line low, overriding the pull-up resistor. To send a 1-bit they let the pull-up resistor bring the line high again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing it this way avoids having multiple devices &quot;fighting&quot; a bus, with some trying to drive it high, and some trying to drive it low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of I&lt;sup&gt;2&lt;/sup&gt;C a resistor of 4.7 k is commonly used for SDA (serial data) and SCL (serial clock). Thus the I&lt;sup&gt;2&lt;/sup&gt;C devices only have to be able to sink 10.6 mA (5 / 4700) which is usually within their design capabilities.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Internal pull-up&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The AVR Arduinos have built-in pull-up capabilities. This lets you design a pull-up into a circuit (such as a switch) without actually having to wire in a resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The internal pull-up is specified for the Atmega328P (as used in the Uno) at being between 30 k and 50 k ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can activate the pull-up in code like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;pinMode (3, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Open_collector&quot; rel=&quot;nofollow noreferrer&quot;&gt;Open collector - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino reference - pinMode&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:57.250" LastActivityDate="2015-08-30T23:57:57.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14672" PostTypeId="4" CreationDate="2015-08-30T05:27:34.740" Score="0" Body="Refers to pull-up resistors, which are commonly used to &quot;weakly&quot; pull a signal line to a high state. Use this tag for discussing pull-ups." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:40.263" LastActivityDate="2015-08-30T23:57:40.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14673" PostTypeId="5" CreationDate="2015-08-30T05:53:33.350" Score="0" Body="&lt;p&gt;The MAX7219 chip is designed to drive an 8x8 LED display quite simply. It automatically and rapidly turns on display segments by progressively activating a row in the display, with a certain pattern for each column. It then moves onto the next row, repeating rapidly so that all of the rows and columns appear to be on at once (or at least, as many as are wanted).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rows are activated at around 800 Hz, which provides a flicker-free display. The output is also current-limited, avoiding the need for current-limiting resistors for the LEDs. The actual current is set by a single &quot;current-set&quot; resistor.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Suitable displays&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Typically two different sorts of displays can be driven. One is an 8x8 &quot;matrix&quot; like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YJRFV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YJRFV.jpg&quot; alt=&quot;8x8 matrix&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MAX7219 chip is visible in the above photo, below the LED matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second type is a 7-segment display (the 8th row being the decimal place) like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sUvnc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sUvnc.jpg&quot; alt=&quot;7-segment display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the MAX7219 chip is mounted on the back of the circuit board.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Communication&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Arduino controls the MAX7219 by using SPI, or just shifting bits out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data is sent using the following signals:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MOSI (Master Out, Slave In) from the Arduino to the Din (Data In) pin&lt;/li&gt;&#xA;&lt;li&gt;SCK (Serial Clock) from the Arduino to the CLK (clock) pin&lt;/li&gt;&#xA;&lt;li&gt;SS (Slave Select) from the Arduino to the LOAD pin&lt;/li&gt;&#xA;&lt;li&gt;+5 V&lt;/li&gt;&#xA;&lt;li&gt;Gnd&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Interfacing with the 7-segment displays is easy, because the MAX7219 has inbuilt patterns for the standard digits (0-9, plus a few others like &quot;H&quot;, &quot;E&quot;, &quot;L&quot;, &quot;P&quot;, space, and &quot;-&quot;) - that is, 16 standard characters. You can choose to use your own patterns if you want to display things like hexadecimal numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To drive the 8x8 matrix a program would typically include a 8x8 font in the form of a table of appropriate bit patterns, usually stored in PROGMEM to save wasting RAM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Daisy-chaining&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The chip also has a Dout pin (data out), so that multiple chips can be daisy-chained. If more than 8 bits are clocked in, they start appearing on the Dout pin, which can be connected to the Din (data in) pin if the next chip in the chain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this way multiple displays can be connected up, making it possible to display whole sentences. For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h5qFP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h5qFP.jpg&quot; alt=&quot;Multiple 8x8 displays&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Multiplexed_display&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multiplexed display - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:57:50.420" LastActivityDate="2015-08-30T23:57:50.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14674" PostTypeId="4" CreationDate="2015-08-30T05:53:33.350" Score="0" Body="Refers to the MAX7219 chip, a multiplexing LED driver. Use this tag for discussing the MAX7219 chip." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-30T23:58:00.660" LastActivityDate="2015-08-30T23:58:00.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14675" PostTypeId="1" CreationDate="2015-08-30T07:04:25.633" Score="0" ViewCount="3887" Body="&lt;p&gt;This code we are using only one motor and one hc-sr04 ultrasonic sensor, the code is shown below:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define trigPin 7&#xA;#define echoPin 6&#xA;#define motorPin 5&#xA;&#xA;void setup()&#xA;{ &#xA;  Serial.begin(9600);// to use the serial monitor&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int duration,distance;&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trigPin, LOW);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;  distance = (duration/2)/29.1;&#xA;  Serial.print(distance);//to print the distance on the serial monitor&#xA;  Serial.println(&quot;cm&quot;);&#xA;&#xA;  // to make the motor vibrate depending on the distance&#xA;  // if the ultrasonic sensor is too far from the obstacle it will vibrate slowly&#xA;  // if the ultrasonic sensor is very close to the obstacle it will vibrate very fast&#xA;&#xA;    if(distance &amp;lt;= 60 &amp;amp;&amp;amp; distance &amp;gt;= 45)&#xA;    {&#xA;      // to make the motor vibrate&#xA;    digitalWrite(motorPin, HIGH); // making the motor on&#xA;&#xA;    delay(200);&#xA;    digitalWrite(motorPin, LOW);// making the motor off&#xA;    delay(200);&#xA;    } &#xA;&#xA;    else if(distance &amp;lt; 45 &amp;amp;&amp;amp; distance &amp;gt;= 30)&#xA;    {&#xA;    digitalWrite(motorPin, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(motorPin, LOW);&#xA;    delay(100);&#xA;   }&#xA;    else if(distance &amp;lt; 30){&#xA;&#xA;    digitalWrite(motorPin, HIGH);&#xA;    delay(50);&#xA;    digitalWrite(motorPin, LOW);&#xA;    delay(50); &#xA;  } &#xA;  else &#xA;  {&#xA;    digitalWrite(motorPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We want you to tell us your comment about the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And we want to add two more motors and two ultrasonic sensors, one of them in the left and the other in the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want you to help us in the code, because we don't know how we can change it for two other motors.&lt;/p&gt;&#xA;" OwnerUserId="12087" LastEditorUserId="10794" LastEditDate="2015-08-30T07:39:32.393" LastActivityDate="2016-05-11T15:10:11.487" Title="How do I use 3 Hc-sr04 ultrasonic sensors to control 3 vibration dc motor?" Tags="|arduino-uno|sensors|c++|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14676" PostTypeId="2" ParentId="4753" CreationDate="2015-08-30T08:32:32.170" Score="0" Body="&lt;p&gt;I would recommend &lt;a href=&quot;http://www.chibios.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ChibiOS&lt;/a&gt;: albeit it just got support for Arduino and it lacks a few drivers (I'm writing one for INTx and PCINT), it's got a fundamentally healthy design, a community around it and the author himself is very responsive.&lt;/p&gt;&#xA;&lt;p&gt;You might have to write or port the drivers for external shields, however the upside is to get rid of the cruft that plagues most of the Arduino libraries.&lt;/p&gt;&#xA;&lt;p&gt;You can even choose between 2 RTOS:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ChibiOS RT, a full fledged RTOS.&lt;/li&gt;&#xA;&lt;li&gt;ChibiOS NIL, a minimalistic OS, actually almost a scheduler, which leaves more space and execution time for your own code. -&#xA;But if you check the amount of FLASH taken up by a typical binary built with the default Arduino libraries, you will see that it pulls in a large amount of typically unused stuff, so you could trade that for the use of the full fledged RT.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Disclaimer: I'm just a very happy user of the OS, I do not have any other involvement with it, especially the commercial part.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-08-30T08:40:01.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14677" PostTypeId="2" ParentId="8383" CreationDate="2015-08-30T08:43:02.890" Score="1" Body="&lt;p&gt;I have the same problem and  I just saw that they fixed a bug in a library used by SleepyPi&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specific, the RTC library file &lt;a href=&quot;https://github.com/SpellFoundry/DS1374RTC/blob/master/DS1374RTC.cpp&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;DS1374RTC.cpp&lt;/code&gt;&lt;/a&gt; reads since March: '2015&lt;br&gt;&#xA;(which is after the question was asked)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Releases&lt;br&gt;&#xA;    ========&lt;br&gt;&#xA;    V1_0 - 10 Aug 2013 - Initial release&lt;br&gt;&#xA;    V1_1 - 11 Mar 2015 - Mod:    Added &quot;ackAlarm&quot; and &quot;ackRTCOSF&quot; functions to aid Alarm use&lt;br&gt;&#xA;  - Bugfix: &lt;strong&gt;Changed the way the &quot;SetAlarm(tmElements_t   &amp;amp;tm)&quot; was updating the Alarm time.&lt;/strong&gt; It wasn't mapping correctly&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They also added a new example to wake up the Pi: &lt;a href=&quot;https://github.com/SpellFoundry/SleepyPi/blob/master/examples/WakePeriodicallySimple/WakePeriodicallySimple.ino&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;WakePeriodicallySimple.ino&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12090" LastEditorUserId="12090" LastEditDate="2015-08-30T08:50:20.230" LastActivityDate="2015-08-30T08:50:20.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14678" PostTypeId="2" ParentId="14665" CreationDate="2015-08-30T11:41:44.733" Score="2" Body="&lt;p&gt;This is a classic example where Object Oriented Programming (OOP) can make your life so much easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The principle behind OOP is to define a &lt;em&gt;Class&lt;/em&gt; which contains all the actions you want to perform on something - in this case a motor.  The &lt;em&gt;Class&lt;/em&gt; contains all the instructions on how to do things like set the motor speed, the direction, start it, stop it, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that &lt;em&gt;Class&lt;/em&gt; you then create &lt;em&gt;Objects&lt;/em&gt;.  The beauty is there is only one &lt;em&gt;Class&lt;/em&gt; which has the abstract concept of &quot;Motor Control&quot;, but that &lt;em&gt;Class&lt;/em&gt; is used to create one &lt;em&gt;Object&lt;/em&gt; for each motor you want to control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;em&gt;Class&lt;/em&gt;, and hence the &lt;em&gt;Objects&lt;/em&gt; derived from it, are all completely self contained, which makes it so much easier to manage.  All the variables associated with a single motor are wrapped up inside the &lt;em&gt;Class&lt;/em&gt; and you don't need to worry about unique names for them all on a per-motor basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you might define a class like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Motor {&#xA;    private:&#xA;        int _speedPin;&#xA;        int _directionPin1;&#xA;        int _directionPin2;&#xA;&#xA;    public:&#xA;        Motor(int sp, int dp1, int dp2) {&#xA;            _speedPin = sp;&#xA;            _directionPin1 = dp1;&#xA;            _directionPin2 = dp2;&#xA;        }&#xA;        void begin() {&#xA;            analogWrite(_speedPin, 0);&#xA;            pinMode(_directionPin1, OUTPUT);&#xA;            pinMode(_directionPin2, OUTPUT);&#xA;            digitalWrite(_directionPin1, LOW);&#xA;            digitalWrite(_directionPin2, LOW);&#xA;        }&#xA;        void forward() {&#xA;            digitalWrite(_directionPin1, HIGH);&#xA;            digitalWrite(_directionPin2, LOW);&#xA;        }&#xA;        void reverse() {&#xA;            digitalWrite(_directionPin1, LOW);&#xA;            digitalWrite(_directionPin2, HIGH);&#xA;        }&#xA;        void speed(int speed) {&#xA;            analogWrite(_speedPin, speed);&#xA;        }&#xA;        void stop() {&#xA;            analogWrite(_speedPin, 0);&#xA;            digitalWrite(_directionPin1, LOW);&#xA;            digitalWrite(_directionPin2, LOW);&#xA;        }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything you need to control a motor is in there.  Then you could use that to create two motor objects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Motor leftMotor(3, 4, 5);&#xA;Motor rightMotor(6, 7, 8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You provide the pins that control the motor to the &lt;em&gt;constructor&lt;/em&gt; of the object - that is pin 3 is the speed pin of the first motor, and pins 4 and 5 are the direction control pins, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now control the motors very simply.  Configure the pins by calling the begin function defined in the class above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    leftMotor.begin();&#xA;    rightMotor.begin();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now you can use similar decision making as normal to decide when to do what.  The main difference is that your motor control code now looks as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leftMotor.forward();&#xA;rightMotor.reverse();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;leftMotor.stop();&#xA;rightMotor.forward();&#xA;rightMotor.speed(30);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You then end up with a program that is much cleaner and easier to follow.  And adding a third or forth motor is as simple as defining more Motor objects with their pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This video is a good introduction to what OOP is and how it differs from the &quot;traditional&quot; approach:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=MTfWr7o7Q4U&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=MTfWr7o7Q4U&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-30T11:41:44.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14679" PostTypeId="2" ParentId="14675" CreationDate="2015-08-30T12:08:00.257" Score="1" Body="&lt;p&gt;There's a few things you need to consider when making multiple things happen at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly is timing. You can't make two things happen concurrently with different timings if you have &lt;code&gt;delay()&lt;/code&gt; in there, since nothing else can happen while &lt;code&gt;delay()&lt;/code&gt; is executing.  So you have to get rid of all &lt;code&gt;delay()&lt;/code&gt; calls and replace them with examining the difference between successive calls to &lt;code&gt;millis()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, imagine you're in the kitchen and you want to boil and egg and make a cup of tea at the same time.  You fill the kettle and turn it on.  You put a pan of water on the stove with an egg in it to boil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you could sit and stare at the egg until it's boiled enough for you to eat, but what happens to the kettle while you're doing that?  It's boiled, turned itself off, and started to go cold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead you put the egg in the pan and look at the clock.  Then you think &quot;in 5 minutes I will take the egg out of the boiling water&quot;.  You might set an alarm for 5 minutes time if you have one, or you may keep glancing at the clock periodically to see if the 5 minutes have past yet.  Meanwhile the kettle has boiled and you've made your cup of tea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the 5 minutes have passed.  You know that because &lt;em&gt;you remembered what time you put the egg on to boil&lt;/em&gt; and &lt;em&gt;you know what the time is now&lt;/em&gt;, so you can subtract one from the other to find that 5 minutes have passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's make it a little more complex.  Imagine you want two eggs - one soft boiled and one hard boiled.  The hard boiled one may want 8 minutes, the soft boiled one 5 minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you put one egg on to boil and remember the time.  Roughly three minutes later you put the other egg in and also remember that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once enough time has passed that the first egg has been in 8 minutes you take it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once enough time has passed that the second egg has been in 5 minutes you take it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have had to remember two start times which you then compare separately to decide what to do with each egg when.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To translate that to your program - you have to remember a start time for each action for your motors, along with the state of the motors - and when the right time has elapsed you change the state of the motor (motor on -&gt; motor off - egg in pan -&gt; egg on plate) and remember the time at which you changed the state so you can know when to change the state again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's exactly what the BlinkWithoutDelay example does to make an LED change state (on -&gt; off -&gt; on) at certain times by remembering &lt;em&gt;when&lt;/em&gt; it last changed state so you know &lt;em&gt;when&lt;/em&gt; to change the state next.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-30T12:08:00.257" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14680" PostTypeId="1" CreationDate="2015-08-30T13:12:46.130" Score="1" ViewCount="4600" Body="&lt;p&gt;Im using a potentiometer to control the speed of two generic 6-8V DC motors. The potentiometer input is scaled from 0-1023 to 0-255, I then use the analogWrite() function to write this value to the enable pins on my L293D motor controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im sure this should control the speed but it doesn't, I have the code printing the value it sends to the enable pins and this is correct, but no speed increase, the motors either move at one speed or don't move at all. My enable pins are 12 and 13 on my Arduino Uno, previously 5 and 6 but I moved them to see if that was the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a problem with the PWM frequency maybe? I don't understand why it won't go faster and slower after days of troubleshooting.. The inputs are all set correctly, allowing both motors to move in the forward direction..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Speed = analogRead(speedChange);&#xA;int SpeedMap = map(Speed,0,1023,0,255);&#xA;analogWrite(enable1, SpeedMap);&#xA;analogWrite(enable2, SpeedMap);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QHx48.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QHx48.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its a long shot but does anyone know enough about PWM control on DC motors to think of any things I may be missing while trying to do this? Ill provide any info ASAP, thanks&lt;/p&gt;&#xA;" OwnerUserId="11326" LastActivityDate="2017-09-26T12:54:52.763" Title="Varying motor speed with the L293D" Tags="|arduino-uno|motor|h-bridge|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14681" PostTypeId="1" AcceptedAnswerId="14682" CreationDate="2015-08-30T15:08:51.390" Score="1" ViewCount="4036" Body="&lt;p&gt;This is not a duplicate of my other question. This question deals with reading specific data within a serial stream. The other question deals with reading and adding data into a manageable data string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is send a command to serial, get the response, and put it into a string, and then break that string up into usable parts of data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having, is there is a delay between the time the serial command is sent, and the response. meaning the serial data isn't being captured before the function moves onto the next line. Using delay() doesn't appear to work, as i believe it halts everything for that delay period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm hoping to do, is read the data from serial and if the character '&amp;lt;' is received, place it, and everything after it into the buffer until the character &quot;&gt;&quot; is received.  After the last character is received, and placed into the buffer, continue on with the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless of coarse someone has a better idea on how to approach this. &#xA;i would also like to note that this is just a part of a larger project. If you need to see the entire project, please let me know and i will provide a link where you can download it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The string i'm expecting as a response would be similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;Alarm,MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code i have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float mx;&#xA;float my;&#xA;float mz;&#xA;float wx;&#xA;float wy;&#xA;float wz;&#xA;String dAlarm;&#xA;char buffer;&#xA;void gPos() {&#xA;  Serial1.print(&quot;?\n&quot;);&#xA;  buffer = Serial1.read();&#xA;  char string[80];&#xA;  string[buffer];&#xA;  char *alarm = strtok(string, &quot;,&quot;);&#xA;  char *mposX = strtok(NULL, &quot;,&quot;);&#xA;  char *mposY = strtok(NULL, &quot;,&quot;);&#xA;  char *mposZ = strtok(NULL, &quot;,&quot;);&#xA;  char *wposX = strtok(NULL, &quot;,&quot;);&#xA;  char *wposY = strtok(NULL, &quot;,&quot;);&#xA;  char *wposZ = strtok(NULL, &quot;&amp;gt;&quot;);&#xA;  alarm += 1;&#xA;  mposX += 5;&#xA;  wposX += 5;&#xA;  mx = strtod(mposX, NULL);&#xA;  my = strtod(mposY, NULL);&#xA;  mz = strtod(mposZ, NULL);&#xA;  wx = strtod(wposX, NULL);&#xA;  wy = strtod(wposY, NULL);&#xA;  wz = strtod(wposZ, NULL);&#xA;&#xA;  if (strcmp(alarm, &quot;Idle&quot;) == 0) {&#xA;    dAlarm = &quot;Idle&quot;;&#xA;  } else if (strcmp(alarm, &quot;Run&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;Run&quot;;&#xA;  } else if (strcmp(alarm, &quot;Hold&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;Hold&quot;;&#xA;  } else if (strcmp(alarm, &quot;Door&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;Door&quot;;&#xA;  } else if (strcmp(alarm, &quot;Home&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;Home&quot;;&#xA;  } else if (strcmp(alarm, &quot;Alarm&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;ALARM!&quot;;&#xA;  } else if (strcmp(alarm, &quot;Check&quot;) == 0) {&#xA;    // Something to do when Busy&#xA;    dAlarm = &quot;Check&quot;;&#xA;  }&#xA;  dispPos();&#xA;}&#xA;&#xA;void dispPos() {&#xA;  int state = 0;&#xA;  int x = analogRead (0);&#xA;  if (x &amp;lt; 800) {&#xA;    state = 1;&#xA;  }&#xA;  if (state == 1) {&#xA;    dPos = false;&#xA;  }&#xA;&#xA;  if (dPos == true) {&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;X&quot;);&#xA;    lcd.print(mx);&#xA;    lcd.setCursor(8, 0);&#xA;    lcd.print(&quot;Y&quot;);&#xA;    lcd.print(my);&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;Z&quot;);&#xA;    lcd.print(mz);&#xA;    lcd.setCursor(8, 1);&#xA;    //lcd.print(&quot; &quot;);&#xA;    lcd.print(dAlarm);&#xA;    delay(3000);&#xA;  } else {&#xA;    mainMenu();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="12076" LastEditDate="2015-08-31T03:29:17.473" LastActivityDate="2015-08-31T03:29:17.473" Title="How can i read serial data into a string until a certain character is recieved?" Tags="|serial|arduino-mega|arduino-ide|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14682" PostTypeId="2" ParentId="14681" CreationDate="2015-08-30T15:25:35.187" Score="1" Body="&lt;p&gt;What you need to do here is implement a small &lt;em&gt;finite state machine&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you need to look at each character as it comes in and make a decision what to do with it &lt;em&gt;depending on what state you're in at the moment&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the operational decisions you need to make are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is the character a &amp;lt; and am I currently not reading a string?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes, start reading the string.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is the character a &gt; and am I currently reading a string?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes, finish reading the string and process it&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Is it any other character and I am currently reading the string?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes, add it to the buffer.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you can see there some common questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is the character?&lt;/li&gt;&#xA;&lt;li&gt;What am I doing at the moment?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So you need to have a simple state variable that remembers if you're reading the string or not, and something to say where in the buffer you are so you know where in the buffer to add any incoming characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean readingString = false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A simple true/false will suffice to depict if we're reading the string or not.  Start off not reading the string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[80] = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A buffer to store the text - maximum of 80 characters (&lt;em&gt;including the NULL terminating character&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int charPointer = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something to know where in the buffer are currently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to read the characters:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First get the next character from the serial port:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;    if (Serial.available()) {&#xA;        int incoming = Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now decide what to do with it.  We have a number of possible situations, some of which can be combined into single options.  For instance, if we get a &quot;&amp;lt;&quot; while reading a string it's an error condition - but do we really care?  It could be that we lost the end of the last string and have just started a fresh one - so we can just treat it as the start of a string regardless of what state we're in.  Let's use a &lt;code&gt;switch&lt;/code&gt; for this since it's nice and tidy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        switch (incoming) {&#xA;            case '&amp;lt;':&#xA;                readingString = true; // Start reading string&#xA;                charPointer = 0; // Set the buffer pointer to the start&#xA;                buffer[0] = 0; // Make the string empty&#xA;                break;&#xA;&#xA;            case '&amp;gt;':&#xA;                if (readingString) {&#xA;                    processBufferData(); // Do something with the buffer&#xA;                }&#xA;                readingString = false; // Finish reading&#xA;                break;&#xA;&#xA;            default: // Anything that's not &amp;gt; or &amp;lt;&#xA;                // If we are reading the string and the buffer isn't full&#xA;                if (readingString &amp;amp;&amp;amp; charPointer &amp;lt; 78) {&#xA;                    // Add the character to the buffer and increment the pointer&#xA;                    buffer[charPointer++] = incoming;&#xA;                    buffer[charPointer] = 0; // Don't forget to terminate the string&#xA;                }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the reception of a &amp;lt; starts the string reading, the reception of a &gt; stops it and triggers the processing of the string, and anything else (while we are reading the string) gets added to the buffer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-30T15:25:35.187" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="14683" PostTypeId="1" CreationDate="2015-08-30T15:33:07.730" Score="1" ViewCount="914" Body="&lt;p&gt;The author of the PinChangeInt library and the EnableInterrupt library states at &lt;a href=&quot;https://github.com/GreyGnome/EnableInterrupt/issues/13&quot; rel=&quot;nofollow&quot;&gt;github&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the PinChangeInt was in a .h and .cpp file, the Arduino IDE tried&#xA;  to compile it twice. I have a technique that you can use- #define&#xA;  LIBCALL_ENABLEINTERRUPT - that if you put it ahead of your #include in&#xA;  all files but the sketch, then you should be able to use the library&#xA;  without conflicts. If you know how to make it work in another way-&#xA;  remember, this is a library and will not compile in the same directory&#xA;  as the sketch and any other .h/.cpp/.ino files- then I'm all ears.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I came there, because both libraries failed to build with linker errors due to double definitions. So far so good. I split the PinChangeInt library in .h and .cpp myself and it compiled flawlessly. I did not try to split the other library yet because it looks like much work to me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now my question(s): Is GreyGnome right with his statement, that library code gets compiled twice when split in code and headers? And if so, what are the consequences? Memory waste? Runtime errors? What about the many other (working) libraries exhibiting separate code and header files?&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2016-01-11T20:22:25.947" Title="Arduino IDE not handling library code correctly?" Tags="|arduino-ide|library|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14684" PostTypeId="2" ParentId="14683" CreationDate="2015-08-30T18:03:59.283" Score="1" Body="&lt;p&gt;Header files are parsed by the preprocessor and the compiler wherever they are included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing weird about that.&#xA;One can avoid multiple inclusions by using header guards.&#xA;That's pretty standard too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not looked at the library, but, for example,  a typical error is to &lt;em&gt;not&lt;/em&gt; declare variables as extern in the header and instead leave the real declaration in the header, which will lead to multiple instances, possibly clashing at link time.&#xA;Variables that are part of the library API should be declared as extern in the header and the real declaration should be done only in the .C/.CPP file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are an even more special case: the AVR gcc relies on very specific names to identify interrupt handlers and each of them can be present at most once.&#xA;So there are even more chances for having linker problems, if not declared correctly.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-30T18:03:59.283" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14685" PostTypeId="2" ParentId="14596" CreationDate="2015-08-30T18:10:30.557" Score="0" Body="&lt;p&gt;If you do a google search for &quot;arduino wireless serial&quot; you'll get several results. Plugging them into the arduino should be trivial. Most suppliers (other than ebay) will also have examples for you to reference where it comes to coding your project to use the module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also be aware that you will usually need a transceiver, and a receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might take a look into the XBEE solutions, as they appear to be popular. &lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-08-30T18:10:30.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14686" PostTypeId="1" AcceptedAnswerId="14689" CreationDate="2015-08-30T19:42:51.560" Score="0" ViewCount="887" Body="&lt;p&gt;Distance is about 3m. IR or visible light - does not matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that object/obstacle can be shiny, so for correct detection necessary large amount of reflected light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe for this task better to use specific retroreflector?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;there will be two sensors with distance about 3-4 cm between.&#xA;Object must cross 1st sensor's reflector but do not cross the 2nd one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scheme of this sensor should be this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/TXiTh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TXiTh.png&quot; alt=&quot;Scheme of sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the use will be this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WYjFY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WYjFY.png&quot; alt=&quot;scheme of use&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9913" LastEditorUserId="9913" LastEditDate="2015-09-03T16:15:19.920" LastActivityDate="2020-10-25T04:09:26.027" Title="Which sensor is best for obstacle detecting with retroreflector?" Tags="|sensors|hardware|system-design|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14687" PostTypeId="1" CreationDate="2015-08-30T20:18:25.873" Score="0" ViewCount="1214" Body="&lt;p&gt;I've been trying to control a relay with a GSM shield for an Arduino project. I haven't had any success with either the Software Serial or the GSM library. I've declared the GSM variable in debug mode and it gives me the error AT%13%.&#xA;Using Software Serial, it hangs at SIM900.read().&#xA;The SIM card connects to the network, I can see that on the board - the LED flashes every 3 seconds and gives me signals for incoming calls and SMSs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't tell if the error is with the SIM card, the connections to the Arduino board, the power supply (12V) or something completely different. Here are the two code examples I'm using with the different libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone else getting this error? What is the best way to make it go away?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SoftwareSerial.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; &#xA;char inchar; // Will hold the incoming character from the GSM shield&#xA;SoftwareSerial SIM900(7, 8);&#xA;&#xA;int Relay1 = A2;&#xA;int Relay2 = A3;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(19200);&#xA;  //Set up relay control pins&#xA;  pinMode(Relay1, OUTPUT);&#xA;  digitalWrite(Relay1, HIGH);&#xA;  // wake up the GSM shield&#xA;  SIM900.begin(19200);&#xA;  delay(10000);  // give time to log on to network.&#xA;  SIM900.print(&quot;AT+CMGF=1\r&quot;);  // set SMS mode to text&#xA;  delay(100);&#xA;  SIM900.print(&quot;AT+CNMI=2,2,0,0,0\r&quot;); &#xA;  // output contents of new SMS upon receipt to the GSM shield's serial out&#xA;  delay(100);&#xA;  Serial.println(&quot;Ready...&quot;);&#xA;  }&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  //If a character comes in from the cellular module...&#xA;  if(SIM900.available() &amp;gt;0)&#xA;  {&#xA;    inchar=SIM900.read();&#xA;    Serial.println(inchar);&#xA;    if (inchar=='#')&#xA;    {...}&#xA;    SIM900.println(&quot;AT+CMGD=1,20&quot;); // delete all SMS&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;GSM.h&lt;/strong&gt; - in this case I haven't even gotten past the .begin() command. This code is from the example at &lt;a href=&quot;http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;// PIN Number for the SIM&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;// initialize the library instances&#xA;GSM gsmAccess(true);&#xA;GSM_SMS sms;&#xA;GSM3_NetworkStatus_t   gsmStatus;&#xA;// Array to hold the number a SMS is retreived from&#xA;char senderNumber[20];&#xA;&#xA;void setup()&#xA;{&#xA;  // initialize serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;  char code = 'X';&#xA;  Serial.flush();&#xA;  gsmStatus = gsmAccess.begin(PINNUMBER,false,false);&#xA;&#xA;  int retrycount = 60;&#xA;  while (gsmStatus != GSM_READY &amp;amp;&amp;amp; retrycount-- &amp;gt; 0) {&#xA;    delay(1000);  // lower delay value could lead to unstable state  &#xA;    theGSM3ShieldV1ModemCore.manageReceivedData();&#xA;    gsmStatus = gsmAccess.getStatus();&#xA;  }&#xA;&#xA;  if (gsmStatus != GSM_READY) {&#xA;    Serial.println(&quot;\n[ERR]: GSM connection failed\n&quot;);&#xA;    Serial.flush();&#xA;    gsmAccess.shutdown();&#xA;    delay(250);&#xA;    digitalWrite(3,LOW);&#xA;  }&#xA;&#xA;  Serial.println(&quot; [DONE]&quot;);&#xA;&#xA;  // connection state&#xA;  boolean notConnected = true;&#xA;  // Start GSM connection&#xA;  while (notConnected)&#xA;  {&#xA;    if (gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;  {&#xA;      notConnected = false;&#xA;  }&#xA;    else&#xA;    {&#xA;      Serial.println(&quot;\nNot connected&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;GSM initialized&quot;);&#xA;  Serial.println(&quot;Waiting for messages&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12097" LastActivityDate="2019-10-26T16:02:50.380" Title="Error AT%13% With GSM/GPRS Shield" Tags="|arduino-uno|shields|gsm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14688" PostTypeId="2" ParentId="14145" CreationDate="2015-08-30T22:00:45.477" Score="1" Body="&lt;p&gt;If you're not trying to capture the mobile number or whatever SMS text was sent, but only react to specific SMS messages, then don't try to parse the whole message, but design the protocol between any arbitrary phone and your Arduino to be detectable independent of everything else, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#L 5 on        ; set an LED state&amp;lt;br&amp;gt;&#xA;#M 3 137       ; set a motor speed&amp;lt;br&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-08-30T22:00:45.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14689" PostTypeId="2" ParentId="14686" CreationDate="2015-08-30T23:24:35.697" Score="0" Body="&lt;p&gt;I think the question is worded to get a specific answer; I do not know if this is the answer you want. I'll give you that answer first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd say an infrared LED, and an infrared detector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strobe the LED, then measure the difference between when it's (known to be) on, and when it's (known to be) off, to compensate for ambient light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I was doing this, I'd consider an ultrasound sensor - no retroreflector needed; instead you get the distance to the (obstacle or reflector). &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-08-30T23:24:35.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14690" PostTypeId="2" ParentId="14687" CreationDate="2015-08-31T00:42:38.917" Score="1" Body="&lt;p&gt;Check your baud rates. They appear to be different. That will cause problems.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-08-31T00:42:38.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14691" PostTypeId="2" ParentId="10179" CreationDate="2015-08-31T00:44:00.730" Score="0" Body="&lt;p&gt;I had the same problem until I ran it as:&#xA;sudo ./file&lt;/p&gt;&#xA;" OwnerUserId="12099" LastActivityDate="2015-08-31T00:44:00.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14692" PostTypeId="1" AcceptedAnswerId="14701" CreationDate="2015-08-31T00:48:13.003" Score="1" ViewCount="1605" Body="&lt;p&gt;Is it possible to simultaneously output a clock signal and it's inverse using the timer register(s)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following code in arduino to output a 1MHz signal on OC1A:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Use Timer/Counter1 to generate a 1MHz square wave on Arduino pin 9.&#xA;//J.Christensen 27Apr2012&#xA;&#xA;void setup(void)&#xA;{&#xA;    DDRB = _BV(DDB1);                  //set OC1A/PB1 as output (Arduino pin D9, DIP pin 15)&#xA;    TCCR1A = _BV(COM1A0);              //toggle OC1A on compare match&#xA;    OCR1A = 7;                         //top value for counter&#xA;    TCCR1B = _BV(WGM12) | _BV(CS10);   //CTC mode, prescaler clock/1&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12120" OwnerDisplayName="rob" LastEditorUserId="12120" LastEditDate="2015-09-01T01:12:46.670" LastActivityDate="2015-10-22T10:54:56.457" Title="How to program a CLK signal and its inverse with Arduino/AVR" Tags="|avr|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14693" PostTypeId="2" ParentId="14581" CreationDate="2015-08-31T00:58:16.207" Score="1" Body="&lt;p&gt;In some instances, it is a known issue that certain LCD's pull more power from the arduino than is sustainable depending on the power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put something like a 100-200 ohm resister in the 5V to the LCD and connect just that and GND, then measure the voltage drop across said resister.  That will give you the current with ohms law, if its much more than 4mA its a faulty LCD or a fault in your wiring. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also check the pins for continuity errors, or shorts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea, is to make sure the voltage, and amperage coming from the 5vdc step down you are using is adequate for the task at hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And finally, you'll need to calculate the complete pull on your power source. i.e. you'll need to know how much load your bigeasy driver pulling from the 12vdc power supply, as well as how much your 5v stepdown is using. if they are exceeding the output of the PSU, you can run into issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ran into a similar issue with my own project, using an arduino Uno with grbl + 3x easydriver motor controllers, &amp;amp; mega 2560 + lcdkeypad shield. Powering the easydrivers with 12vdc &amp;amp; using a voltage stepdown module also gave me issues, as it didn't provide enough current for the stepper motor drivers and the LCD + mega + uno from the 5vdc. I was overloading the power supply, and the 5v wasn't producing the correct power requirements. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought a better power supply that had 24, 12, 7, and 5v on it, and haven't had an issue since.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-08-31T00:58:16.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14694" PostTypeId="2" ParentId="14692" CreationDate="2015-08-31T01:04:06.690" Score="0" Body="&lt;p&gt;What about also setting COM1B0 and then setting the initial values of OC1A and OC1B to opposites by writing to PORTB?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I presume you mean 1 MHz and not 1 mHz?&lt;/p&gt;&#xA;" OwnerUserId="3832" LastActivityDate="2015-08-31T01:04:06.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14695" PostTypeId="2" ParentId="12616" CreationDate="2015-08-31T01:11:06.963" Score="1" Body="&lt;p&gt;If the Arduino doesn't show up on multiple computers, and others do, it may be bricked, or dead. You might try reflashing the chip, and hope that solves your issue. If it doesn't, chances are it's toast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If however the device simply doesn't show up on one computer, but does on another. It's either a software issue, or a USB issue with that computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If winblows OS, try reinstalling, or updating the drivers for the USB, as well as the Arduino. And check your power management on the USB as well. I've seen Windows USB poop the bed if a device is connected / disconnected, or restarted several times in rapid succession. When this happens, sometimes Windows will think the port or device is faulty, and simply stop responding to its presence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If *nix, make sure you've configured it properly.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="3917" LastEditDate="2015-11-29T20:47:59.310" LastActivityDate="2015-11-29T20:47:59.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14696" PostTypeId="2" ParentId="14692" CreationDate="2015-08-31T01:40:25.053" Score="1" Body="&lt;p&gt;Various AVRs have the capability to output both the normal and inverted timer waveform from a single output compare register simultaneously on two pins. These devices include, but are not limited to, ATtinyX5/V, ATtiny26/L, ATtinyX61A, and ATmegaXXU4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATmega328P does not have this capability, therefore the smallest primary source Arduino that does is the Leonardo (ATmega32U4) and comparable devices. The Adafruit Trinket and the Digispark (both ATtiny85-based) also offer this.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-08-31T01:40:25.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14697" PostTypeId="2" ParentId="14692" CreationDate="2015-08-31T02:19:08.527" Score="0" Body="&lt;p&gt;Another option is to do this in hardware - it's trivial to invert a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, see the selected answer for &lt;a href=&quot;https://electronics.stackexchange.com/questions/30238/how-to-invert-a-digital-signal&quot;&gt;https://electronics.stackexchange.com/questions/30238/how-to-invert-a-digital-signal&lt;/a&gt; - the second diagram - connect Vs to your clock, and Vo will be your inverted clock. For the two resistors, anything over 1k should be fine. Or use an inverter (which is the same thing, in one component, but is much less likely to be in your random-part box).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: There will be a very short delay going through this circuit - one place I saw suggested 1.5ns, but see the spec sheet of your transistor. A 1mhz clock &quot;ticks&quot; at 1,000ns (I guess, 500ns on, 500ns off), so this delay shouldn't be significant.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-08-31T02:19:08.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14698" PostTypeId="1" CreationDate="2015-08-31T03:26:07.133" Score="2" ViewCount="7418" Body="&lt;p&gt;When reading the MPU 6050 has accelerometer and gyro, I assumed it was linear acceleration, but now I second guess that.  From this video &lt;a href=&quot;https://www.youtube.com/watch?v=qmd6CVrlHOM&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=qmd6CVrlHOM&lt;/a&gt; it seems like they are using acceleration and gyro to make one rotation direction.  I need to know what direction the mpu is moving, not just a rotational value.  Is there a way to extract this information?&lt;/p&gt;&#xA;" OwnerUserId="11089" LastActivityDate="2020-08-27T17:24:55.870" Title="Linear acceleration from MPU 6050" Tags="|accelerometer|mpu6050|gyroscope|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14699" PostTypeId="2" ParentId="14698" CreationDate="2015-08-31T03:58:22.453" Score="1" Body="&lt;p&gt;The MPU6050 has an accelerometer and a rate gyro (which tells you how fast it is rotating). The accelerometer will tell you which direction is down and in a motionless situation, that is all the information you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll probably want something like the MPU9150, it has a compass, which will give you the directional information you're asking for.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-08-31T03:58:22.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14700" PostTypeId="1" CreationDate="2015-08-31T06:16:19.873" Score="2" ViewCount="1033" Body="&lt;p&gt;I'm trying to run a simple Hello World program from &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino 1.6.5&lt;/a&gt; from terminal. When I run it in Arduino IDE, it works good. When I'm trying to get it by &lt;code&gt;avr-g++&lt;/code&gt; I have hard way to figure out how to include all libraries - so far I got this script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o main.o main.cpp &#xA;-I&quot;../arduino-1.6.5-r5/libraries/LiquidCrystal/src/&quot;&#xA;-I&quot;../arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino/&quot;&#xA;avr-g++ -mmcu=atmega328p main.o -o main&#xA;avr-objcopy -O ihex -R .eeprom main main.hex&#xA;sudo avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM1 -b 115200 -U flash:w:main.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First line (with both &lt;code&gt;-I&lt;/code&gt; flags) compiles, but after running second line, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main.o: In function `main':&#xA;main.cpp:(.text.startup+0xa): undefined reference to `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)'&#xA;main.cpp:(.text.startup+0x16): undefined reference to `Print::print(char const*)'&#xA;main.o: In function `_GLOBAL__sub_I_lcd':&#xA;main.cpp:(.text.startup+0x3a): undefined reference to `LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I also include some libraries? I need the exact bash script.&lt;/p&gt;&#xA;" OwnerUserId="12096" LastEditorUserId="37523" LastEditDate="2019-11-13T17:23:33.940" LastActivityDate="2019-11-13T17:23:33.940" Title="avr-g++ (or avr-gcc) and LiquidCrystal library" Tags="|arduino-uno|avrdude|avr-gcc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14701" PostTypeId="2" ParentId="14692" CreationDate="2015-08-31T06:44:20.060" Score="4" Body="&#xA;&#xA;&lt;p&gt;How about this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;  {&#xA;  // Defining PB1 and PB2 as outputs by setting PORTB1 and PORTB2&#xA;  // Setting DDB1 and DDB2&#xA;  DDRB |= bit (DDB1) | bit (DDB2);&#xA;&#xA;  // stop timer 1&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;&#xA;  TCCR1A = bit (COM1B0) | bit (COM1B1)  // Set OC1B on Compare Match, clear&#xA;                                        // OC1B at BOTTOM (inverting mode)&#xA;         | bit (COM1A1)                 // Clear OC1A on Compare Match, set&#xA;                                        // OC1A at BOTTOM (non-inverting mode)&#xA;         | bit (WGM11);                 // Fast PWM, top at ICR1&#xA;  TCCR1B = bit (WGM12)  | bit (WGM13)   //       ditto&#xA;         | bit (CS11);                  // Start timer, prescaler of 8&#xA;&#xA;  // Initialize OCR1A = 300 (pulse_width = 150us), OCR1B, and ICR1&#xA;  ICR1 = 0xFFFF;&#xA;  OCR1B = 299;&#xA;  OCR1A = ICR1 - OCR1B;&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results on a Uno:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mc8Sk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mc8Sk.png&quot; alt=&quot;Normal and inverted timer output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output on Uno pins 9 and 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change the prescalers and counters to your desired frequency.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The screenshot doesn't show one signal exactly the inverse of the other. The &lt;em&gt;pattern&lt;/em&gt; is inverted. If you had a 50% duty cycle, it would be an exact inverse.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It looks good except they overlap (slightly) by 50ns. If I set them to 16 and 8, respectively, they don't overlap but they are slightly asymmetrical&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;OK, make OCR1A and OCR1B both 7:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  ICR1 = 15;&#xA;  OCR1B = 7;&#xA;  OCR1A = 7;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Why 7? And why 15?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The counts are zero-relative. So by counting to 15 on a 16 MHz processor we are actually getting 1/16th of the clock, namely 1 MHz. And half of that is 8 (which, zero-relative, is 7). So we are really doing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Period: 16 ticks of the 16 MHz clock&lt;/li&gt;&#xA;&lt;li&gt;Duty cycle: 8 ticks of the 16 MHz clock&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now, one cycle:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YefHP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YefHP.png&quot; alt=&quot;Scope shot 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They change over at the same instant - pulse width exactly 500 ns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dNPMd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dNPMd.png&quot; alt=&quot;Scope shot 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And they change back at the same moment - pulse width also 500 ns.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-01T04:13:08.410" LastActivityDate="2015-09-01T04:13:08.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14702" PostTypeId="1" AcceptedAnswerId="14731" CreationDate="2015-08-31T06:56:59.760" Score="1" ViewCount="1836" Body="&lt;p&gt;I'm having a small issue with the CD74HC4067 multiplexer/demultiplexer: I am using it to receive data from an array of sensors (at the moment I have only 2, but in a near future they will grow). Specifically I have a light sensor and a sound sensor.&lt;/p&gt;&#xA;&lt;p&gt;Mux output is connected to A0 since the readings I do are analog. The pins I use to switch the channels are A3 and A2 (when the other sensors will arrive also A1 will be dedicated to that).&lt;/p&gt;&#xA;&lt;p&gt;My problem is that when switching between one channel and another, my readings highly fluctuate, but only when the reading value is &amp;gt; 500 or so, and I don't understand why. In a simple sketch I've tried adding some delay (40 msec) and the issue goes away. But in my project which is far more complex and uses also other analog channels I need a delay of ~1 second to get a correct reading, which is absolutely unacceptable since I need it to run in real-time(ish). I also tried using the digital pins to control the mux but to no avail. The only thing that seems to stabilize everything is connecting a capacitor between the MUX out and ground, and using a 20msec delay, but it only works for a bit.&lt;/p&gt;&#xA;&lt;p&gt;I hope I've been clear enough and that someone can point me the right way!&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&lt;p&gt;Here is the schematic&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NQGZI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NQGZI.png&quot; alt=&quot;Schematic&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Error in the drawing: &amp;quot;temp&amp;quot; is actually a &amp;quot;light sensor&amp;quot; as in the bottom of the post...)&lt;/p&gt;&#xA;&lt;p&gt;And my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MUX A0&#xA;#define S0 A2&#xA;#define S1 A3&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(S0, OUTPUT);&#xA;  pinMode(S1, OUTPUT);&#xA;  &#xA;  selectMux(1);&#xA;}&#xA;&#xA;void loop() {&#xA;  &#xA;  //selectMux(0);&#xA;  //Serial.println(analogRead(MUX));&#xA;  //selectMux(1);&#xA;  Serial.println(analogRead(MUX));&#xA;&#xA;}&#xA;&#xA;void selectMux(byte port) {&#xA;//  pinMode(MUX, mode);&#xA;  int r0 = bitRead(port, 0);&#xA;  int r1 = bitRead(port, 1);&#xA;  &#xA;  digitalWrite(S0, r0);&#xA;  digitalWrite(S1, r1);&#xA;  analogRead(MUX);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the &lt;code&gt;analogRead(MUX)&lt;/code&gt; in the selectMux function was added because I read in a post that they suggested to do that in order to get a more accurate reading.&#xA;With this code only the results already fluctuate:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Output:&#xA;76&#xA;41&#xA;77&#xA;76&#xA;76&#xA;75&#xA;36&#xA;75&#xA;74&#xA;76&#xA;77&#xA;106&#xA;76&#xA;76&#xA;76&#xA;76&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;but it goes crazy when the input is higher, close to 5V:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Output:&#xA;948&#xA;780&#xA;340&#xA;948&#xA;948&#xA;635&#xA;437&#xA;949&#xA;948&#xA;499&#xA;551&#xA;949&#xA;950&#xA;396&#xA;684&#xA;950&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you enable the commented code that starts to switch the outputs it is even worse. As I said, adding delays helps, but in my final application I cannot afford to have 1s delays.&lt;/p&gt;&#xA;&lt;p&gt;I also show that in the circuit there is a timer that uses other Analog pins, but in the code I didn't include that part. If you need I'll add that too.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dx.com/p/157205&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sound Sensor&lt;/a&gt;,&#xA;&lt;a href=&quot;http://www.dx.com/p/152409&quot; rel=&quot;nofollow noreferrer&quot;&gt;Light Sensor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12102" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-02-24T10:46:34.813" Title="Issue with CD74HC4067 MUX on high values" Tags="|arduino-uno|analogread|multiplexer|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="14703" PostTypeId="2" ParentId="14700" CreationDate="2015-08-31T07:16:58.797" Score="1" Body="&lt;p&gt;I made a Makefile to compile the Blink program a little while back. It wasn't trivial.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;&#xA;# where you installed the Arduino app&#xA;ARDUINO_DIR = C:/Documents and Settings/Nick/Desktop/arduino-1.0.6/&#xA;&#xA;# various programs&#xA;CC = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&quot;&#xA;CPP = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&quot;&#xA;AR = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&quot;&#xA;OBJ_COPY = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&quot;&#xA;&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &quot;-I$(ARDUINO_DIR)hardware/arduino/cores/arduino&quot; &quot;-I$(ARDUINO_DIR)hardware/arduino/variants/standard&quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &quot;$(ARDUINO_DIR)hardware/arduino/cores/arduino/&quot;&#xA;&#xA;build:&#xA;&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o&#xA;    rm core.a&#xA;    $(AR) rcs core.a malloc.c.o&#xA;    $(AR) rcs core.a realloc.c.o&#xA;    $(AR) rcs core.a WInterrupts.c.o&#xA;    $(AR) rcs core.a wiring.c.o&#xA;    $(AR) rcs core.a wiring_analog.c.o&#xA;    $(AR) rcs core.a wiring_digital.c.o&#xA;    $(AR) rcs core.a wiring_pulse.c.o&#xA;    $(AR) rcs core.a wiring_shift.c.o&#xA;    $(AR) rcs core.a CDC.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial.cpp.o&#xA;    $(AR) rcs core.a HID.cpp.o&#xA;    $(AR) rcs core.a IPAddress.cpp.o&#xA;    $(AR) rcs core.a main.cpp.o&#xA;    $(AR) rcs core.a new.cpp.o&#xA;    $(AR) rcs core.a Print.cpp.o&#xA;    $(AR) rcs core.a Stream.cpp.o&#xA;    $(AR) rcs core.a Tone.cpp.o&#xA;    $(AR) rcs core.a USBCore.cpp.o&#xA;    $(AR) rcs core.a WMath.cpp.o&#xA;    $(AR) rcs core.a WString.cpp.o&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I basically did this by observing what the IDE does (as Ignacio Vazquez-Abrams suggested) and replicated it. Now to add libraries you have to add even more steps.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-31T07:16:58.797" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14704" PostTypeId="1" CreationDate="2015-08-31T10:02:23.513" Score="2" ViewCount="2946" Body="&lt;p&gt;I want to make the vibration motor vibrate depending on the distance to an obstacle, for example if the distance is too short it should vibrate quickly and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i make motor vibrate using arduino depending on the distance?&#xA;Can you explain for me how can I use the delay in the vibration code?&#xA;I found this code in the internet for vibration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(y, HIGH);&#xA;delay(50);&#xA;digitalWrite(y, LOW);&#xA;delay(50); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that I can change the delay, but how can we do it depending on our purpose?&#xA;Please help me .. I don't know the use of the delay :(&lt;/p&gt;&#xA;" OwnerUserId="12105" LastEditorUserId="313" LastEditDate="2015-08-31T12:30:41.170" LastActivityDate="2016-01-29T17:18:07.923" Title="How can I make motor vibrate using arduino depending on the ultrasonic distance?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14705" PostTypeId="2" ParentId="14704" CreationDate="2015-08-31T11:03:59.340" Score="1" Body="&lt;p&gt;You could just replace the &quot;50&quot; in the first delay with the ultrasonic distance variable, I'll explain a bit more below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume your ultrasonic sensor outputs an analogue value between 0V and 5V. The output is connected to analog pin A0. Then you just set pinMode(A0, INPUT) and analogRead the value from the pin and store it in the variable X or whatever. Then you just use the variable X as a delay and it will do what you want. The higher the value gets the longer it will vibrate. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;val = analogRead(A0);&#xA;digitalWrite(5, HIGH);&#xA;delay(val);&#xA;digitalWrite(5, LOW);&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second option, if you only wish to turn it on if it is above or under a certain limit, would be using an if condition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(variable &amp;gt; 50){&#xA;  // if the variable named variable is over 50 this code is going to be executed&#xA;} else {&#xA;  // If the variable is below 50 this is executed&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are unfamiliar with if conditions then I suggest reading &lt;a href=&quot;https://www.arduino.cc/en/Reference/if&quot; rel=&quot;nofollow&quot;&gt;this too&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-01-29T17:18:07.923" LastActivityDate="2016-01-29T17:18:07.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14706" PostTypeId="1" CreationDate="2015-08-31T11:35:26.300" Score="5" ViewCount="3215" Body="&lt;p&gt;I have a device built with an Arduino uno:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino software installed on an Arduino uno&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;can be controlled via serial commands&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;can be controlled via physical buttons and sensors&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;on any button/sensor state change it writes the current state to serial&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if no message has been sent within 5 seconds, it sends a no-change serial message&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What is needed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an ESP8266 to provide a bridge between current Arduino software and MQTT / web&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can program the ESP8266 as a web server, MQTT client, etc with the Arduino IDE or Lua (but I prefer the Arduino IDE since I can reuse parts of the code to generate / interpret communication). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the ESP8266 will handle everything that is required for wifi / web / MQTT; without the MQTT module the Arduino part will work stand-alone, only the remote control will be missing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would like to make minimal changes to the Arduino code (or none, if possible). Any changes would involve extensive re-testing, which I try to avoid.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the ESP8266 can be missing in some installs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What options I found:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Serial&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;ESP8266 can read the serial output and be a bridge between web/MQTT and serial, will store the current state in memory to be sent when requested to avoid polling the device every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the benefits is no code changes / testing required for the Arduino part.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;I2C&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Make the Arduino the I2C master and the ESP8266 the slave (or the other way around) and implement bi-directional communication. Got the idea by reading &lt;a href=&quot;https://arduino.stackexchange.com/questions/3042/i2c-2-way-communication-between-arduino-uno-and-arduino-mega&quot;&gt;this thread&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some other information about the serial commands:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A data packet (command or state description) consists of 1 to 20 characters, with a possible peak of 20 packets in 5 seconds, and an average of one packet every 3 seconds. If needed, I can make this send 5 unsigned integers instead of alphanumeric characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If more than the I2C / serial pins are needed I can upgrade to an Arduino Mega (so the number of free pins is not an issue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any other options for this? (protocols, pre-made libraries for serial communication, etc). I'm trying not to reinvent the wheel..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your time!&lt;/p&gt;&#xA;" OwnerUserId="709" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2020-01-06T22:33:49.927" Title="Protocol options for data exchange between Arduino and ESP8266" Tags="|arduino-uno|arduino-ide|i2c|esp8266|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14707" PostTypeId="1" CreationDate="2015-08-31T12:33:27.853" Score="1" ViewCount="238" Body="&lt;p&gt;I am looking for something like a &lt;strong&gt;multiway &quot;relay dimmer&quot;&lt;/strong&gt;.&#xA;Which lets me dim a light using an Arduino and a manual dimmer.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/d4pff.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d4pff.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The manual dimmer should work without any computer!)&lt;/p&gt;&#xA;" OwnerUserId="12108" LastEditorUserId="12108" LastEditDate="2015-08-31T12:58:08.860" LastActivityDate="2015-09-09T12:46:42.280" Title="Multiway Relay Dimmer" Tags="|relay|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14708" PostTypeId="1" AcceptedAnswerId="14716" CreationDate="2015-08-31T12:38:42.890" Score="1" ViewCount="531" Body="&lt;p&gt;I'm planning use Roboteq motor driver for 24V brushed DC motor but I can't be sure that it's true or wrong. You know, Roboteq controller is too expensive and I don't want to spend money in vain. Have you any experience this controller? Are they compatible with Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.roboteq.com/index.php/roboteq-products-and-services/brushed-dc-motor-controllers/mdc2230-detail&quot; rel=&quot;nofollow&quot;&gt;http://www.roboteq.com/index.php/roboteq-products-and-services/brushed-dc-motor-controllers/mdc2230-detail&lt;/a&gt;  Roboteq Controller Link&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also think, Pololu RoboClaw driver. &lt;a href=&quot;https://www.pololu.com/product/1499&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/product/1499&lt;/a&gt; I don't know is it enough for wheelchair. Because, I already have used Pololu VNH5019 and it is not enough. (synchronicity and noise problems etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have any ideas, I will be glad. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="10196" LastEditorUserId="11529" LastEditDate="2015-08-31T20:44:11.910" LastActivityDate="2015-09-02T13:58:45.370" Title="Is Roboteq motor driver compatible with Arduino?" Tags="|arduino-mega|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14709" PostTypeId="2" ParentId="14707" CreationDate="2015-08-31T12:43:56.510" Score="2" Body="&lt;p&gt;You could use a rotary encoder for that purpose!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the rotary encoder is a knob that, for every &quot;tick&quot; you give it, it returns a different value to your Arduino. With a bit of programming you can sense the direction of the turn, if it is positive then you lighten up the LED, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used that to control a RGB led, it works very well! &lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; some more information on the rotary encoder and the code needed to use it.&lt;/p&gt;&#xA;" OwnerUserId="12102" LastActivityDate="2015-08-31T12:43:56.510" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14710" PostTypeId="1" CreationDate="2015-08-31T13:10:49.653" Score="2" ViewCount="187" Body="&lt;p&gt;I am trying to get a reading from my Cotek through my Arduino and have it display on an LCD screen. When I run the code, though, nothing shows up. I am EXTREMELY new to using pretty much all this equipment so honestly, I have little to no idea what I'm doing. I am not sure if it is a wiring issue, an issue with the code or both. Any and all help is appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how the cotek is wired to the Arduino. The middle red wire (in the middle of the two resistors) is connected to AUX from the cotek. The two outer red wires are connected to the SDA and SCL of the cotek and their corresponding blue wires are connected to the SDA and SCL of the Arduino (the two resistors are 2KOhm pull-up resistors). The blue wire on the bottom is connected to the GRND of the cotek which is also connected to GRND of the Arduino. &#xA;&lt;img src=&quot;https://i.stack.imgur.com/IfYBp.jpg&quot; alt=&quot;connection from cotek to arduino&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code using the I2C protocol:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int analogPin = 5;&#xA;char address= 0;&#xA;int numBytes = 2;&#xA;char val = 0;&#xA;int debug = 5;&#xA;LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  lcd.begin(16, 2);&#xA;  lcd.clear();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  Wire.requestFrom(address, numBytes);&#xA;  while(Wire.available())&#xA;  {&#xA;    val = Wire.read();&#xA;    Serial.print(val);&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(val);&#xA;  }&#xA;  //perform function to change val from hexadecimal to decimal number here&#xA;  delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am pretty sure the LCD is wired correctly to the Arduino as I was able to communicate to it previously without using the Cotek. In any case, it doesn't matter as 'val' doesn't even appear on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, any help would be appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="12113" LastEditorUserId="37523" LastEditDate="2019-08-05T15:27:00.587" LastActivityDate="2019-08-05T15:27:00.587" Title="Basic communication between Cotek and Arduino UNO" Tags="|arduino-uno|i2c|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14711" PostTypeId="1" CreationDate="2015-08-31T14:07:03.820" Score="3" ViewCount="3934" Body="&lt;p&gt;I'm in the echopen association, our goal is to create a low cost, open source echographic probe. In order to do that, we use an arduino due for the first step. For doing acoustic imaging, we use ultrasonic transducer wich works at high frequency, typically 5 MHz. So, for our purpose we need to send and receive analogic signal at high frequencies.&#xA;We want to connect a 80 Msps DAC and a 80 Msps ADC to the arduino due so we can generate and mesure analog signal up to 42 MHz. I have found here (&lt;a href=&quot;http://www.instructables.com/id/Arduino-Timer-Interrupts/#step0&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-Timer-Interrupts/#step0&lt;/a&gt;) how to use arduino timer interrupts in order to send and receive data at 84 MHz. I haven't connect my converters for the moment, but I have preliminary questions. &#xA;First, is the definition of the timer is the same for the arduino due (i.e. timer1 is a 16 bits timer) ? Morever, my ADC and DAC are 14 bits converters, can I tell to the arduino to sent only 14 bits digital signal ?&#xA;Secondly, as we work at high frequencies we will have to send a lot of data from the microcontroller to a computer via the serial port. I have make a test and at 250000 bauds it takes nearly 0.5 second to transfer 4300*8 bits datas. It is to slow for our purpose, how can I do it faster ?&lt;/p&gt;&#xA;" OwnerUserId="12110" LastActivityDate="2017-01-14T05:38:28.853" Title="Connecting high sampling rate DAC and ADC to arduino DUE, timer consideration" Tags="|arduino-due|timers|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14712" PostTypeId="2" ParentId="14711" CreationDate="2015-08-31T15:04:38.570" Score="1" Body="&lt;p&gt;I'm sorry, but by your description you are doomed to failure from the start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due runs at 84MHz.  That doesn't mean that it can communicate at 84MHz, only that it can process its instructions at around 84 million per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for you to transmit or receive 80 million samples per second you have to be able to a) transmit sample words (14 bits) 80 million times per second, and b) process the information between each sample.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means you are going to require a processor that operates considerably faster than 84MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, assuming you are using high speed synchronous serial communication (say, SPI) to transfer the data.  For 16 bits of data (you won't get it to do just 14 bits using hardware and software would be way too slow) would require a transmission clock of (80000000 * 16) 1.28GHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using a 16-bit parallel interface then you would only need an 80MHz communication clock to move the data around, but receiving that data and storing it somewhere and also processing it would require many many more instructions between each clock.  Far more than the Due could perform.  Certainly it's way way outside the scope of a timer interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest instead investigating systems that run in the high hundreds of Megahertz or even Gigahertz range.  Maybe one of the newer &quot;version 2&quot; Raspberry Pi embedded computers may be suitable.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-31T15:04:38.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14713" PostTypeId="1" AcceptedAnswerId="14723" CreationDate="2015-08-31T16:08:25.937" Score="1" ViewCount="259" Body="&lt;p&gt;I have this simple code who send a signal to a android phone when I press a button:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int botonPinD = 8;&#xA;const int relayPin =  12;  &#xA;int retardo = 100;&#xA;int finBoton=1000;&#xA;&#xA;void setup() {&#xA;  pinMode(relayPin, OUTPUT);      &#xA;&#xA;  pinMode(botonPinA, INPUT); &#xA;  pinMode(botonPinB, INPUT);  &#xA;  pinMode(botonPinC, INPUT); &#xA;  pinMode(botonPinD, INPUT);  &#xA;}&#xA;void loop(){&#xA;    botonD = digitalRead(botonPinD);&#xA;    if (botonD == HIGH){&#xA;   // for simplicity remove botonA, botonB and botonC code, but it's the same with a few digitalWrite&#xA;        digitalWrite(relayPin, HIGH);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, HIGH);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, HIGH);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, HIGH);&#xA;        delay(retardo);&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(retardo);&#xA;        delay(finBoton);&#xA;      }&#xA;      else{&#xA;        digitalWrite(relayPin, LOW);&#xA;      }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I press the button fast (maybe a half a second between clicks) I only receive once the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not very sure about what's happened here (I'm an Arduino newbie). The first signal, has it locked the channel? Can signals be queued? Can I control the way that they are queued?&lt;/p&gt;&#xA;" OwnerUserId="12119" LastEditorUserId="10794" LastEditDate="2015-08-31T22:05:18.067" LastActivityDate="2015-08-31T23:07:06.263" Title="digitalWrite queued signals?" Tags="|programming|arduino-mega|c++|signal-processing|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14714" PostTypeId="2" ParentId="14713" CreationDate="2015-08-31T16:26:52.757" Score="2" Body="&lt;p&gt;The main problem I guess you are suffering from is the good old &lt;code&gt;delay()&lt;/code&gt; blockage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;delay()&lt;/code&gt; is a terrible function and should be avoided at all costs.  Nothing at all can happen while you are running &lt;code&gt;delay()&lt;/code&gt; - that means you can't be reading the state of your button - until all your &lt;code&gt;delay()&lt;/code&gt; calls have finished.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to queue the pressed of the button you will need to do three things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You will need to recognise when the button changes from LOW to HIGH, not just &quot;when it is HIGH&quot; as you do now.&lt;/li&gt;&#xA;&lt;li&gt;You will have to queue that button press somewhere. The simplest way is to maintain a count of how many times the button has been pressed.&lt;/li&gt;&#xA;&lt;li&gt;You will have to process any pending button presses (&quot;while the count &gt; 0&quot;) by triggering your output with the right timing without using &lt;code&gt;delay()&lt;/code&gt;, which means using &lt;code&gt;millis()&lt;/code&gt; and maintaining state information.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-31T16:26:52.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14715" PostTypeId="2" ParentId="14704" CreationDate="2015-08-31T17:52:09.060" Score="0" Body="&lt;p&gt;I want to show you my thinking, and tell me please if it is right or wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I build an relationship between the distance and the speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that (speed = distance/time) and if the obstacle is too close to the ultrasonic sensor the speed of the motor should be maximum, so I have decrease the time which is the delay, right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I make the code according what i said above and it is shown below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if(distance &amp;lt;= 60 &amp;amp;&amp;amp; distance &amp;gt;= 45)// the distance is too large&#xA;    {&#xA;    digitalWrite(motorPin, HIGH);&#xA;&#xA;    delay(200);// I increase the delay to make the motor vibrate slowly&#xA;&#xA;    digitalWrite(motorPin, LOW);&#xA;&#xA;    delay(200);&#xA;&#xA;    } &#xA;&#xA;    else if(distance &amp;lt; 45 &amp;amp;&amp;amp; distance &amp;gt;= 30)&#xA;    {&#xA;    digitalWrite(motorPin, HIGH);&#xA;&#xA;    delay(100);&#xA;&#xA;    digitalWrite(motorPin, LOW);&#xA;&#xA;    delay(100);&#xA;&#xA;   }&#xA;    else if(distance &amp;lt; 30){&#xA;&#xA;    digitalWrite(motorPin, HIGH);&#xA;&#xA;    delay(50);&#xA;&#xA;    digitalWrite(motorPin, LOW);&#xA;&#xA;    delay(50); &#xA;&#xA;  } &#xA;  else &#xA;  {&#xA;    digitalWrite(motorPin, LOW);// If the distance is too large the motor will be off&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12121" LastEditorUserId="11529" LastEditDate="2015-08-31T20:43:29.043" LastActivityDate="2015-08-31T20:43:29.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14716" PostTypeId="2" ParentId="14708" CreationDate="2015-08-31T18:35:19.570" Score="0" Body="&lt;p&gt;It is not directly supported. But the device description lists RS232 port that can be interfaced with an Arduino using a TTL to RS232 converter. The description also mentions &quot;several Analog, Pulse and Digital I/Os which can be remapped as command or feedback inputs, limit switches, or many other functions&quot; so it is totally possible to control the controller with an Arduino, but depending on the method you choose it may require some effort.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-09-02T13:58:45.370" LastActivityDate="2015-09-02T13:58:45.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14717" PostTypeId="2" ParentId="10531" CreationDate="2015-08-31T19:00:57.290" Score="0" Body="&lt;p&gt;You could try an &lt;a href=&quot;https://www.arduino.cc/en/ArduinoCertified/IntelEdison&quot; rel=&quot;nofollow&quot;&gt;Intel Edison Arduino Kit&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's 64 bit and can be programmed with a variant of the Arduino IDE.&#xA;You can interleave Arduino code with system calls to the Linux OS, depending on which approach better suits a specific need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running an RTOS inside Edison seems a bit overkill, however it should be doable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otoh you could just rely on the much higher clock to provide quasi-deterministic response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or just ditch the Arduino IDE and write a normal program with your programming language of choice.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-08-31T19:00:57.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14718" PostTypeId="1" AcceptedAnswerId="14719" CreationDate="2015-08-31T19:16:55.830" Score="2" ViewCount="892" Body="&lt;p&gt;I was wondering if its possible to send code to the Arduino, and then have it execute this code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is use an Arduino Mega with a bunch of stuff connected to it send code to an Uno with a TFT LCD display to do whatever the Mega tells it to do with the Adafruit GFX Library.  I want to add things to this 'system' gradually so I want the whole program hosted on the Arduino Mega, and a minimal amount of code on the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry I'm really new at this so if its not possible at all let me know!&lt;br&gt;&#xA;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Will&lt;/p&gt;&#xA;" OwnerUserId="12123" LastActivityDate="2015-08-31T19:21:41.073" Title="Execute Code sent over Serial" Tags="|arduino-uno|serial|arduino-mega|adafruit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14719" PostTypeId="2" ParentId="14718" CreationDate="2015-08-31T19:21:41.073" Score="0" Body="&lt;p&gt;No, it's not possible as you describe it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's main chip, the ATMega328p, is what is known as &lt;em&gt;Harvard Architecture&lt;/em&gt;.  This means that the Flash memory and RAM both occupy completely separate memory address spaces.  The CPU in the chip is only able to fetch its instructions from the memory space the Flash is connected to (the &lt;em&gt;Instruction Bus&lt;/em&gt;) and not the memory space the RAM is connected to (the &lt;em&gt;Data Bus&lt;/em&gt;).  This means it can only run instructions that are in Flash and not RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to re-program the flash on the fly - after all, that's what the bootloader does, and while the actual act of reprogramming flash is fairly trivial, generating the instructions in the right way is far from trivial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other options though.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use an interpreted language.  I believe there are versions of BASIC available for the Arduino that would allow you to upload a program through the serial port and execute it.&lt;/li&gt;&#xA;&lt;li&gt;Define a protocol (or use an existing protocol) to send pre-defined control commands to the Uno.  Firmata might be of use here.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-31T19:21:41.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14720" PostTypeId="1" CreationDate="2015-08-31T19:52:02.920" Score="1" ViewCount="748" Body="&lt;p&gt;I am currently building a self balancing robot using an L298N motors driver,and MPU6050 using an arduino microcontroller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to control my motors movements with no issues. After I extracted the data from my MPU6050 which was easy by using MPU6050 library I faced a problem: When linking the motors movement according to MPU6050 readings, the sensor freezes and stops showing its data on the serial monitor after giving couple of readings, the motors keep moving. I even have capacitors soldered into my motors to filter the noise. I am definitely sure my sensor works perfectly because it was tested before implemented into the motors drivers circuit and code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone can give me any hints why does the MPU sensor stop giving readings please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="12124" LastEditorUserId="11529" LastEditDate="2015-08-31T20:51:17.617" LastActivityDate="2021-04-03T21:53:21.570" Title="Student Project Inquiry(Building a Self Balancing robot)" Tags="|sensors|arduino-motor-shield|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14721" PostTypeId="2" ParentId="14704" CreationDate="2015-08-31T20:53:57.020" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I know that I can change the delay, but how can we do it depending on our purpose?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Are you asking how to use a &lt;em&gt;variable&lt;/em&gt;? An example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int LED = 13;&#xA;&#xA;void setup() &#xA;  {&#xA;  pinMode (LED, OUTPUT);&#xA;  }&#xA;&#xA;void loop() &#xA;  {&#xA;  int amount = analogRead (A0);   // get a reading&#xA;  digitalWrite(LED, HIGH);&#xA;  delay(amount);&#xA;  digitalWrite(LED, LOW);&#xA;  delay(amount);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That code reads some analog device, and adjusts the delay based on the figure it read.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-08-31T20:53:57.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14722" PostTypeId="2" ParentId="14720" CreationDate="2015-08-31T20:54:21.783" Score="1" Body="&lt;p&gt;The MPU6050 is an I2C device.  By default the Arduino uses the internal pullup resistors in the IO pins for the pullups on the I2C bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is bad - it makes the I2C bus &lt;em&gt;very&lt;/em&gt; susceptible to noise, and motors are &lt;em&gt;very&lt;/em&gt; noisy devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to make sure you have appropriate pullup resistors on the I2C bus (3.3KΩ is good) and keep the I2C wires as short as you reasonably can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also keeping power sources as separate as possible is essential.  Don't be tempted to use the 5V power from the Arduino to power your motors - you must use an external power source, or the motors will cause havoc with the microcontroller circuitry and communications.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-08-31T20:54:21.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14723" PostTypeId="2" ParentId="14713" CreationDate="2015-08-31T22:02:57.943" Score="1" Body="&lt;p&gt;The code below is closer to what you seem to be asking about:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// For Mega2560&#xA;&#xA;const int BUTTONS = 4;&#xA;const int FIRST_SWITCH = 18;&#xA;const int FIRST_RELAY =  41;  &#xA;const int CLICKS = 5;&#xA;const unsigned long DEBOUNCE_TIME = 20;  // ms&#xA;&#xA;int retardo  = 300;&#xA;int finBoton = 1000;&#xA;&#xA;volatile byte counts [BUTTONS];&#xA;unsigned long lastPress [BUTTONS];&#xA;&#xA;void doInterrupts (const int which)&#xA; {&#xA; // debounce&#xA; if (millis () - lastPress [which] &amp;lt; DEBOUNCE_TIME)&#xA;   return;&#xA;&#xA; lastPress [which] = millis ();&#xA; counts [which]++;&#xA; }  // end of doInterrupts&#xA;&#xA;void pin18Pressed ()&#xA;  {&#xA;  doInterrupts (0);  &#xA;  }  // end of pin18Pressed&#xA;&#xA;void pin19Pressed ()&#xA;  {&#xA;  doInterrupts (1);  &#xA;  }  // end of pin19Pressed&#xA;&#xA;void pin20Pressed ()&#xA;  {&#xA;  doInterrupts (2);  &#xA;  }  // end of pin20Pressed&#xA;&#xA;void pin21Pressed ()&#xA;  {&#xA;  doInterrupts (3);  &#xA;  }  // end of pin21Pressed&#xA;&#xA;void setup() &#xA;  {&#xA;  // configure inputs / outputs&#xA;  for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;    {&#xA;    pinMode (FIRST_SWITCH + i, INPUT_PULLUP);&#xA;    pinMode (FIRST_RELAY + i, OUTPUT);&#xA;    }&#xA;&#xA;  attachInterrupt (5, pin18Pressed, FALLING);&#xA;  attachInterrupt (4, pin19Pressed, FALLING);&#xA;  attachInterrupt (3, pin20Pressed, FALLING);&#xA;  attachInterrupt (2, pin21Pressed, FALLING);&#xA;&#xA;  } // end of setup&#xA;&#xA;// turn relay on for a particular switch&#xA;void handleSwitchPress (const int which)&#xA;  {&#xA;  for (int i = 0; i &amp;lt; CLICKS; i++)&#xA;  {&#xA;    digitalWrite(FIRST_RELAY + which, HIGH);&#xA;    delay(retardo);&#xA;    digitalWrite(FIRST_RELAY + which, LOW);&#xA;    delay(retardo);&#xA;  }&#xA;  delay(finBoton);&#xA;  } // end of handleSwitchPress&#xA;&#xA;// main loop&#xA;void loop()&#xA;  {&#xA; for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;   if (counts [i] &amp;gt; 0)&#xA;     {&#xA;     handleSwitchPress (i);&#xA;     counts [i]--;  &#xA;     }&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'll explain parts of it from above:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Interrupts&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;To queue up switch presses we can use an interrupt. The Mega has quite a few external interrupts (See: &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;attachInterrupt()&lt;/a&gt;) so I'll use those. You can read about interrupts on my page about interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code attaches four interrupts handlers:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  attachInterrupt (5, pin18Pressed, FALLING);&#xA;  attachInterrupt (4, pin19Pressed, FALLING);&#xA;  attachInterrupt (3, pin20Pressed, FALLING);&#xA;  attachInterrupt (2, pin21Pressed, FALLING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because of the way the hardware works we have to use pins 18, 19, 20 and 21 (there are a couple more but these are in sequence).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I set the switches to be INPUT_PULLUP so that they are normally HIGH when not pressed, and go LOW when you press them. Hence the interrupts are looking for a FALLING edge.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Handle one interrupt&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;An interrupt handler is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void pin18Pressed ()&#xA;  {&#xA;  doInterrupts (0);  &#xA;  }  // end of pin18Pressed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since they all do much the same thing I put all of the switch management into one function and used an array of switches, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile byte counts [BUTTONS];&#xA;unsigned long lastPress [BUTTONS];&#xA;&#xA;void doInterrupts (const int which)&#xA; {&#xA; // debounce&#xA; if (millis () - lastPress [which] &amp;lt; DEBOUNCE_TIME)&#xA;   return;&#xA;&#xA; lastPress [which] = millis ();&#xA; counts [which]++;&#xA; }  // end of doInterrupts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to &quot;queue&quot; presses the interrupt handler adds one to a counter, for that array item. (So, pin 18 is position 0, pin 19 is position 1 and so on).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Debouncing&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Debouncing of the switches is done by ignoring multiple presses in quick succession:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; // debounce&#xA; if (millis () - lastPress [which] &amp;lt; DEBOUNCE_TIME)&#xA;   return;&#xA;&#xA; lastPress [which] = millis ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Handling a queued press&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Now in the main loop we just check if the counter has gone up, for each switch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;   if (counts [i] &amp;gt; 0)&#xA;     {&#xA;     handleSwitchPress (i);&#xA;     counts [i]--;  &#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If so, we call &lt;code&gt;handleSwitchPress&lt;/code&gt; which toggles the relay for the desired number of times.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Code for Uno&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you are using a Uno instead of a Mega2560 you don't have four external interrupts. The alternative version below uses &lt;em&gt;pin change interrupts&lt;/em&gt; instead of external interrupts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin change interrupts work on all pins of the Uno, however they are in batches of three: Pins A0 to A5, pins D0 to D7 and pins D8 to D13. In the code below I use pins 2, 3, 4 and 5 which are in the batch D0 to D7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a pin-change interrupt you only get notification of a &lt;em&gt;change&lt;/em&gt; to the pin, so the code has to detect whether the pin changed from high to low or low to high.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// For Atmega328 (eg. Uno)&#xA;&#xA;const int BUTTONS = 4;&#xA;const int FIRST_BUTTON = 2;&#xA;const int FIRST_RELAY =  8;  &#xA;const int CLICKS = 5;&#xA;const unsigned long DEBOUNCE_TIME = 20;  // ms&#xA;&#xA;int retardo  = 300;&#xA;int finBoton = 1000;&#xA;&#xA;volatile bool oldState [BUTTONS];&#xA;volatile byte counts [BUTTONS];&#xA;unsigned long lastPress;&#xA;&#xA;// handle pin change interrupt for D0 to D7 here&#xA;ISR (PCINT2_vect)&#xA; {&#xA;&#xA; // debounce&#xA; if (millis () - lastPress &amp;lt; DEBOUNCE_TIME)&#xA;   return;&#xA;&#xA; lastPress = millis ();&#xA;&#xA; // check each switch&#xA; for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;   {&#xA;   byte state = digitalRead (FIRST_BUTTON + i);&#xA;   if (state != oldState [i])&#xA;     {&#xA;     oldState [i] = state;  // detect state changes&#xA;     if (state == LOW)&#xA;       counts [i]++;&#xA;     }   // end of state change&#xA;   }  // end of for each button&#xA;&#xA; }  // end of PCINT2_vect&#xA;&#xA;&#xA;void setup() &#xA;  {&#xA;&#xA;  // configure inputs / outputs&#xA;  for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;    {&#xA;    pinMode (FIRST_BUTTON + i, INPUT_PULLUP);&#xA;    oldState [i] = HIGH;&#xA;    pinMode (FIRST_RELAY + i, OUTPUT);&#xA;    }&#xA;&#xA;  // pin change interrupt (example for D9)&#xA;  PCMSK2 |= bit (PCINT18) | bit (PCINT19) | bit (PCINT20) | bit (PCINT21);  // want pins 2, 3, 4, 5&#xA;  PCIFR  |= bit (PCIF2);   // clear any outstanding interrupts&#xA;  PCICR  |= bit (PCIE2);   // enable pin change interrupts for D0 to D7&#xA;  } // end of setup&#xA;&#xA;// turn relay on for a particular switch&#xA;void handleSwitchPress (const int which)&#xA;  {&#xA;  for (int i = 0; i &amp;lt; CLICKS; i++)&#xA;  {&#xA;    digitalWrite(FIRST_RELAY + which, HIGH);&#xA;    delay(retardo);&#xA;    digitalWrite(FIRST_RELAY + which, LOW);&#xA;    delay(retardo);&#xA;  }&#xA;  delay(finBoton);&#xA;  } // end of handleSwitchPress&#xA;&#xA;// main loop&#xA;void loop()&#xA;  {&#xA; for (int i = 0; i &amp;lt; BUTTONS; i++)&#xA;   if (counts [i] &amp;gt; 0)&#xA;     {&#xA;     handleSwitchPress (i);&#xA;     counts [i]--;  &#xA;     }&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-08-31T23:07:06.263" LastActivityDate="2015-08-31T23:07:06.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14724" PostTypeId="2" ParentId="14632" CreationDate="2015-09-01T01:05:38.063" Score="1" Body="&#xA;&#xA;&lt;p&gt;The datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The SPI commands are 16 bits long with the 8 most significant bits (MSBs) representing the register address and the 8 least significant bits (LSBs) representing the data ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus, you need to write address / data after selecting the chip.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (SS, LOW);  // select the chip &#xA;SPI.transfer (0x00);     // select address 0x00 (Video Mode 0)&#xA;SPI.transfer (bit (1));  // write bit 1 (Software Reset Bit)&#xA;digitalWrite (SS, HIGH); // done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to the datasheet you need to wait around 20 µs for the operation to complete. You could, of course, just wait 20 µs but it might be nice to see if the bit gets cleared.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  byte result;&#xA;&#xA;  do &#xA;    {&#xA;    digitalWrite (SS, LOW);      // select the chip &#xA;    SPI.transfer (0x80);         // select address 0x00 (Video Mode 0) - read mode&#xA;    result = SPI.transfer (0);   // read it&#xA;    digitalWrite (SS, HIGH);     // done&#xA;    } while (result &amp;amp; bit (1));  // loop while not reset yet&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, how would one verify that the chip indeed did reset itself and responds to the commands given to it afterwards?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure, without the chip in hand, what other tests you can make, but if you added a counter into the above loop, you could probably verify that it was doing something. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // reset chip&#xA;  digitalWrite (SS, LOW);  // select the chip &#xA;  SPI.transfer (0x00);     // select address 0x00 (Video Mode 0) - write mode&#xA;  SPI.transfer (bit (1));  // write bit 1 (Software Reset Bit)&#xA;  digitalWrite (SS, HIGH); // done&#xA;&#xA;  byte result;&#xA;  unsigned int counter = 0;&#xA;&#xA;  // wait for it to become ready, or time-out      &#xA;  do &#xA;    {&#xA;    digitalWrite (SS, LOW);      // select the chip &#xA;    SPI.transfer (0x80);         // select address 0x00 (Video Mode 0) - read mode&#xA;    result = SPI.transfer (0);   // read it&#xA;    digitalWrite (SS, HIGH);     // done&#xA;    if ((result &amp;amp; bit (1)) == 0)&#xA;      counter++;     // count times not ready&#xA;    } while ((result &amp;amp; bit (1)) &amp;amp;&amp;amp; (counter &amp;lt; 1000) );  // loop while not reset yet&#xA;&#xA;  if (counter == 0 || counter &amp;gt;= 1000)&#xA;    {&#xA;    // chip does not seem to be responding&#xA;    }&#xA;  else&#xA;    {&#xA;    // all OK!&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-01T01:05:38.063" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14725" PostTypeId="1" AcceptedAnswerId="14730" CreationDate="2015-08-31T22:42:09.187" Score="2" ViewCount="541" Body="&lt;p&gt;I am working on project and using Arduino Pro Mini (Atmega328p running on 2xAA) to measure the time to charge a capacitor (when the volt level is high). This is the code I used while testing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int counter = 0;&#xA;&#xA;// Charge the capacitor&#xA;digitalWrite(8,HIGH);&#xA;&#xA;while (digitalRead(7) == LOW) {&#xA;    counter = counter +1;&#xA;    if (counter &amp;gt; 250) {&#xA;        break; // CHARGING FAILED!&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code was working fine when the board was running at 16MHz since the loop was fast enough to give good result. ( counter =~ 28 when the test cap is charged). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the intention is to run the system on a battery with clock of 1MHz (to reduce power consumption) and when tested at that speed the counter only reaches 2~3 because the loop it too slow now that the cap will charge in about two to three cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I did two changes which are using byte instead of int for the counter, and reading the value of the pin directly from the PIND register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte counter = 0;&#xA;&#xA;// Charge the capacitor&#xA;digitalWrite(8,HIGH);&#xA;&#xA;while ((PIND &amp;amp; (1&amp;lt;&amp;lt;PD7)) == 0) {&#xA;    counter = counter +1;&#xA;    if (counter &amp;gt; 250) {&#xA;        break; // CHARGING FAILED!&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both of these changes increased the speed and now counter reads ~20 which is much better and almost close to the 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any further optimizations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use one of the general registers instead of the counter, if yes then how? and will that improve the speed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a more clever and faster way to do this loop?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Update:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am going to follow the suggested answer and use the analog comparator, but I also wanted to add to my finding which might help others with general optimization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of incrementing the counter and comparing if it is larger than some value, it is faster to decrements and compare if it is equal to zero. The counter improved to ~23.&lt;/p&gt;&#xA;" OwnerUserId="4906" OwnerDisplayName="Fahad Alduraibi" LastEditorUserId="4906" LastEditDate="2015-09-01T15:50:20.267" LastActivityDate="2015-09-02T22:16:25.060" Title="Optimizing an Arduino code" Tags="|avr|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14726" PostTypeId="2" ParentId="14725" CreationDate="2015-09-01T08:43:46.243" Score="2" Body="&lt;p&gt;Get rid of the loop altogether. Instead of twiddling and checking bits manually, use timer 1 to trigger the output and capture the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you perform the output on pin 10 and the input on pin 8 then you can use timer 1's output compare to send the pulse out and its input capture to detect when the capacitor has charged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Untested:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;void setup(void)&#xA;{&#xA;  cli();&#xA;  DDRB |= _BV(PB2); // Configure OC1B as output&#xA;  TCCR1B &amp;amp;= ~(_BV(CS12) | _BV(CS11) | _BV(CS10)); // Stop timer 1&#xA;  TCNT1 = 0; // Initialize timer count&#xA;  OCR1A = 0xffff; // Reset the timer at this count&#xA;  OCR1B = 0xf000; // Upper limit of the timed value, plenty of time before timer reset&#xA;  ICR1 = 0xff00; // Set to an invalid initial value&#xA;  TCCR1A = _BV(COM1B1); // Trigger output at 0, clear at upper limit&#xA;  TCCR1B = _BV(ICES1); // Capture on leading edge&#xA;  TCCR1B |= _BV(WGM13) | _BV(WGM12); // High bits for 16-bit fast PWM&#xA;  TCCR1A |= _BV(WGM11) | _BV(WGM10); // Low bits for 16-bit fast PWM&#xA;  TIMSK = _BV(ICIE1) | _BV(OCIE1B); // Enable input capture and limit interrupts&#xA;  sei();&#xA;  TCCR1B |= _BV(CS10); // Start the timer at its highest clock speed&#xA;}&#xA;&#xA;ISR(TIMER1_CAPT_vect)&#xA;{&#xA;  TIMSK &amp;amp;= ~(_BV(ICIE1) | _BV(OCIE1B)); // Disable input and limit interrupts&#xA;  TCCR1B &amp;amp;= ~(_BV(CS12) | _BV(CS11) | _BV(CS10)); // Stop the timer&#xA;  PORTB &amp;amp;= ~_BV(PB2); // Kill the charging output&#xA;  // Check ICR1 for the captured value&#xA;}&#xA;&#xA;ISR(TIMER1_COMPB_vect)&#xA;{&#xA;  if (ICR1 == 0xff00)&#xA;  {&#xA;    // WELL CRAP, charging is taking too long&#xA;    // Maybe try with a slower clock?&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Do other stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-01T08:43:46.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14727" PostTypeId="1" CreationDate="2015-09-01T09:09:36.633" Score="0" ViewCount="475" Body="&lt;p&gt;I planning to add an anemometer to my small solar weather station.&#xA;I designed this system to run from a single 3.7v rechargeable battery and a solar panel so I have to calculate in more power drain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I don't really understand is do these anemometers consume any external power or just give out a voltage by themselves?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one doesn't even have consumption specified:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/products/1733&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1733&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this Supply voltage : 5V - 24VDC:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/JL-FSX2-4-20MA-0-5V-Output-Wind-Speed-Sensor-Wind-Speed-Transmitter-Anemometer-/331521148973?hash=item4d3033482d&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/JL-FSX2-4-20MA-0-5V-Output-Wind-Speed-Sensor-Wind-Speed-Transmitter-Anemometer-/331521148973?hash=item4d3033482d&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12128" LastActivityDate="2015-09-01T09:23:13.527" Title="Does Anemometer consumes power?" Tags="|arduino-uno|power|solar|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14728" PostTypeId="2" ParentId="14727" CreationDate="2015-09-01T09:23:13.527" Score="1" Body="&lt;p&gt;If it runs on electricity it definitely consumes power, its only how much the real question is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are working with electronics I am going to assume that you have a multimeter, if you dont have one. Its about time you did, doesnt cost much and will save you a ton of time debugging. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nearly every multimeter has an onboard ammeter (the accuracy will be mentioned in the instructions manual). You can use this to determine the current consumed, have a look at a tutorial from &lt;a href=&quot;https://learn.sparkfun.com/tutorials/how-to-use-a-multimeter/measuring-current&quot; rel=&quot;nofollow&quot;&gt;sparkfun&lt;/a&gt; on how to do this&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-09-01T09:23:13.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14729" PostTypeId="1" CreationDate="2015-09-01T11:52:26.637" Score="0" ViewCount="2314" Body="&#xA;&#xA;&lt;p&gt;I'm new to arduino and currently trying to build a small program with multiple screens and buttons and a counter. when I try to convert a int to a chararray it messes up the world. with out it what I have so far works any suggestions on what I'm doing wrong? with the code to convert the int to chararray it seems to lock up the program when I switch from main screen to options screen then back. I put some serial outs to narrow down where the flaw is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My results are it is between&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   test1++;  Serial.println(&quot;oops check&quot;);&#xA;   str = String(test1); Serial.println(&quot;sanity check&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something hangs it up after it outputs &quot;oops check&quot; so I figure it is &lt;code&gt;str = String(test1);&lt;/code&gt; I have been searching and trying every thing I can find. if someone can give me a kick in the right direction. I'm usin the tft seedstudio v2 display with the modified tft library for text direction.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   /* &#xA;  Title: TouchScreenButton Tutorial&#xA;  About: Example/tutorial file for how to create buttons with the TouchScreenButtons library&#xA;  Author: Richard Kirkpatrick&#xA;  Date: 20 July 2014&#xA;*/&#xA;&#xA;// Libraries&#xA;#include &amp;lt;stdint.h&amp;gt;  &#xA;#include &amp;lt;SeeedTouchScreen.h&amp;gt;  // Library for the Seeed Studio TFT Touch Shield &#xA;#include &amp;lt;TFTv2.h&amp;gt;      // Library for the Seeed Studio TFT Touch Shield &#xA;#include &amp;lt;TouchScreenGeometry.h&amp;gt; // Library for drawing geometric shapes for the touch screen&#xA;#include &amp;lt;TouchScreenStrings.h&amp;gt; // Library for drawing strings for the touch screen&#xA;#include &amp;lt;TouchScreenButtons.h&amp;gt; // Library for creating buttons for the keypad&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;//Measured ADC values for (0,0) and (210-1,320-1)&#xA;//TS_MINX corresponds to ADC value when X = 0&#xA;//TS_MINY corresponds to ADC value when Y = 0&#xA;//TS_MAXX corresponds to ADC value when X = 240 -1&#xA;//TS_MAXY corresponds to ADC value when Y = 320 -1&#xA;#define TS_MINX 890*2&#xA;#define TS_MAXX 116*2&#xA;#define TS_MINY 913*2&#xA;#define TS_MAXY 83*2&#xA;&#xA;TouchScreen ts = TouchScreen(XP, YP, XM, YM);&#xA;&#xA;// Global variables&#xA;String str;&#xA;Button bigButton;&#xA;Button buttons[12];&#xA;Button reset;&#xA;Button back;&#xA;int screen = 1;&#xA;int test;&#xA;int test1 = 0;&#xA;char b[5];&#xA;&#xA;void setup() &#xA;{&#xA;  // Initializes the TFT library&#xA;   Tft.TFTinit();      &#xA;&#xA;  // Start the Serial port. Used to determine which button was pressed.&#xA;  Serial.begin(9600); &#xA; screen = 1; &#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{ test1++;  Serial.println(&quot;oops check&quot;);&#xA;  str = String(test1); Serial.println(&quot;sanity check&quot;);&#xA;  str.toCharArray(b,5);&#xA;&#xA;  Serial.print(&quot;screen = &quot;); Serial.print(screen );&#xA;  // A point objects holds x, y, and z coordinates&#xA;  Point p = ts.getPoint(); &#xA;  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);&#xA;  p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);&#xA;&#xA;  // Determine which button was pressed&#xA;  int userInput = -1; // -1 means no button is pressed&#xA;  if (p.z &amp;gt; __PRESURE){ &#xA;    userInput = getButtonNumber(p.x, p.y); &#xA;     Serial.print(&quot;X = &quot;); Serial.print(p.x);&#xA;     Serial.print(&quot;\tY = &quot;); Serial.print(p.y);&#xA;     Serial.print(&quot;\tPressure = &quot;); Serial.println(p.z);&#xA;  }&#xA;&#xA;   // Show which button was pressed on the Serial monitor&#xA;&#xA;   if (userInput == 13) {&#xA;    Serial.println(&quot;Options button was pressed!&quot;);&#xA;    bigButton.buttonDisplay();&#xA;  }&#xA;   if (userInput == 15) {&#xA;    Serial.println(&quot;back button was pressed!&quot;);&#xA;    back.buttonDisplay();&#xA;  }&#xA;  else if (userInput == 14) {&#xA;    Serial.println(&quot;reset button was pressed!&quot;);&#xA;    reset.buttonDisplay();&#xA;  } &#xA;&#xA;&#xA;&#xA;  delay(10);&#xA;&#xA;if (screen == 1)  {&#xA;&#xA;if (test == 1) {&#xA;&#xA;    Tft.fillScreen();    }&#xA;&#xA;&#xA;  Serial.print(&quot;test1 =  &quot;); Serial.println(b);      // prints &quot;Hello String&quot;&#xA;&#xA;    // Draw reset button&#xA;   reset.setValues(75, 215, 35, 100);&#xA;  reset.draw();&#xA;&#xA; // Draw the big button&#xA;  bigButton.setValues(15, 185, 35, 130);&#xA;  bigButton.draw();&#xA;Tft.drawRectangle(40, 15, 70, 120,BLUE);&#xA;&#xA;&#xA;Tft.setDisplayDirect(UP2DOWN);&#xA;&#xA;&#xA;  Tft.drawString(&quot;Frays&quot;,100,20,2,RED);&#xA;&#xA;   Tft.drawString(b,65,20, 2, BLUE);&#xA;&#xA;&#xA;  //Draw reset buttons text&#xA;  TouchScreenString resetText(&quot;RESET&quot;, 100, 230, 2, RED);&#xA;  resetText.drawText();&#xA; Serial.println(&quot;a&quot;);      // prints &quot;Hello String&quot;&#xA;&#xA;  // Draw the big button's text&#xA;  TouchScreenString bigButtonText(&quot;OPTIONS&quot;, 40, 197, 2, WHITE);&#xA;  bigButtonText.drawText();&#xA;test = 0;&#xA;&#xA;}&#xA;&#xA;if (screen == 2)  {&#xA;&#xA;  if (test == 0) {Tft.fillScreen();}&#xA; // draw back button&#xA;  back.setValues(15, 15, 35, 85);&#xA;  back.draw();&#xA;&#xA;&#xA;Tft.setDisplayDirect(UP2DOWN);&#xA;&#xA;&#xA;   // Draw the back button's text&#xA;  TouchScreenString backText(&quot;BACK&quot;, 40, 30, 2, WHITE);&#xA;  backText.drawText();&#xA;test = 1;&#xA;}}&#xA;&#xA;// Gets which button was pressed.  If no button is pressed, -1 is returned.&#xA;int getButtonNumber(int xInput, int yInput)&#xA;{&#xA;&#xA;&#xA;&#xA;if (screen == 1) {&#xA;  if (bigButton.isPressed(xInput, yInput)) {&#xA;    screen = 2;&#xA;    return 13; // Signifies big button was pressed&#xA;  } }&#xA;  if (screen ==2) {&#xA;  if (back.isPressed(xInput, yInput)) {&#xA;    screen = 1;&#xA;    return 15; // Signifies big button was pressed&#xA;  }}&#xA;  if (screen == 1) {&#xA;  if (reset.isPressed(xInput, yInput)) {&#xA;    test1 = 0;&#xA;    return 14; // Signifies reset button was pressed&#xA;  }}&#xA;  else {&#xA;  return -1; // Signifies no button was pressed&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12129" LastEditorUserId="10794" LastEditDate="2015-09-01T22:32:24.690" LastActivityDate="2015-09-01T22:32:24.690" Title="problem with using String()" Tags="|arduino-uno|c++|display|string|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14730" PostTypeId="2" ParentId="14725" CreationDate="2015-09-01T12:00:02.133" Score="3" Body="&#xA;&#xA;&lt;p&gt;It looks like Ignacio Vazquez-Abrams and I have been doing similar things. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a page about making a capacitor tester:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=12075&quot; rel=&quot;nofollow noreferrer&quot;&gt;Turn your Arduino into a capacitor tester&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However since link-only replies are frowned on (the link might go down) I'll summarize it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple approach is to charge the capacitor until it reaches 63.2% of the charging voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is because:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;1 - e^(-1) = 0.63212&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://en.wikipedia.org/wiki/RC_time_constant&quot; rel=&quot;nofollow noreferrer&quot;&gt;RC Time constant - Wikipedia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can use the Analog Comparator to trigger an interrupt when the voltage reaches that level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need the capacitor to be on pin D6 on the Uno and a reference voltage on pin D7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11916&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using the Arduino Analog Comparator&lt;/a&gt; for more details about the Analog Comparator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is much faster than using analogRead, because it triggers on an exact voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your basic objective is to find how long it takes to reach 63.2% of the supplied voltage (in the example being 1 volt):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3uMaN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3uMaN.png&quot; alt=&quot;Capacitor tester 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this particular example it took 47 µs for a 47 nF capacitor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K1r42.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K1r42.png&quot; alt=&quot;Capacitor tester 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using an exact reference voltage (ie. 63.2% of 5 volts) you can do some fancy maths instead. Here is my test circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/snZkL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/snZkL.png&quot; alt=&quot;Capacitor test circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;DUT = Device Under Test&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We plug the values of the resistors into the code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const float Rc = 10000;    // charging resistor&#xA;const float R1 = 1000;     // between ground and D7&#xA;const float R2 = 1800;     // between +5V and D7&#xA;const float clockRate_us = 16;  // 16 MHz&#xA;const float k = 1000 / (clockRate_us * Rc * log ((R1 + R2) / R2));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: For high accuracy you should use the &lt;em&gt;measured&lt;/em&gt; resistance values, not just the nominal ones.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now with some fairly simple code we can use the constant &lt;strong&gt;k&lt;/strong&gt; to work out the capacitance:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Capacitance meter&#xA;&#xA;Author: Nick Gammon&#xA;Date:   2 July 2013&#xA;&#xA;Pulse pin (D2): Connect to capacitor via 10K resistor (Rc)&#xA;&#xA;Reference voltage connected to D7 (AIN1) as per below.&#xA;&#xA;Measure pin (D6 - AIN0) connected to first leg of capacitor, other leg connected to Gnd.&#xA;&#xA;Like this:&#xA;&#xA;Capacitor to test:&#xA;&#xA;D2  ----&amp;gt; Rc ----&amp;gt; D6 ----&amp;gt; capacitor_under_test ----&amp;gt; Gnd&#xA;&#xA;Reference voltage:&#xA;&#xA;+5V ----&amp;gt; R2 ---&amp;gt; D7 ---&amp;gt; R1 ----&amp;gt; Gnd&#xA;&#xA;*/&#xA;&#xA;const byte pulsePin = 2;   // the pin used to pulse the capacitor&#xA;const float Rc = 10000;    // charging resistor&#xA;const float R1 = 1000;     // between ground and D7&#xA;const float R2 = 1800;     // between +5V and D7&#xA;const float clockRate_us = 16;  // 16 MHz&#xA;&#xA;const float k = 1000 / (clockRate_us * Rc * log ((R1 + R2) / R2));&#xA;&#xA;volatile boolean triggered;&#xA;volatile boolean active;&#xA;&#xA;volatile unsigned long timerCounts;&#xA;volatile unsigned long overflowCount;&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;{&#xA;  ++overflowCount;               // count number of Counter 1 overflows  &#xA;}  // end of TIMER1_OVF_vect&#xA;&#xA;ISR (TIMER1_CAPT_vect)&#xA;  {&#xA;  // grab counter value before it changes any more&#xA;  unsigned int timer1CounterValue;&#xA;  timer1CounterValue = ICR1;  // see datasheet, page 117 (accessing 16-bit registers)&#xA;  unsigned long overflowCopy = overflowCount;&#xA;&#xA;  if (active)&#xA;    {&#xA;    // if just missed an overflow&#xA;    if ((TIFR1 &amp;amp; bit (TOV1)) &amp;amp;&amp;amp; timer1CounterValue &amp;lt; 0x7FFF)&#xA;      overflowCopy++;&#xA;    // calculate total count&#xA;    timerCounts = (overflowCopy &amp;lt;&amp;lt; 16) + timer1CounterValue;  // each overflow is 65536 more&#xA;    triggered = true;&#xA;    digitalWrite (pulsePin, LOW);  // start discharging capacitor&#xA;    TCCR1B = 0;    // stop the timer&#xA;    }  // end if active&#xA;  }  // end of TIMER1_CAPT_vect&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (pulsePin, OUTPUT);&#xA;  digitalWrite (pulsePin, LOW);&#xA;&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  ADCSRB = 0;           // (Disable) ACME: Analog Comparator Multiplexer Enable&#xA;  ACSR = bit (ACIC);    // Analog Comparator Input Capture Enable&#xA;  DIDR1 |= bit (AIN1D) | bit (AIN0D); // Disable digital buffer on comparator inputs&#xA;  PRR = 0;&#xA;  }  // end of setup&#xA;&#xA;void startTiming ()&#xA;  {&#xA;  active = true;&#xA;  triggered = false;&#xA;  noInterrupts ();&#xA;&#xA;  // prepare timer&#xA;  overflowCount = 0;            // no overflows yet&#xA;  // reset Timer 1&#xA;  TCCR1A = 0;             &#xA;  TCCR1B = 0;   &#xA;  TCNT1 = 0;      // Counter to zero&#xA;  // Timer 1 - counts clock pulses&#xA;  TIMSK1 = bit (TOIE1) | bit (ICIE1);   // interrupt on Timer 1 overflow and input capture&#xA;&#xA;  // get on with it&#xA;  digitalWrite (pulsePin, HIGH);  // start charging capacitor&#xA;  // start Timer 1, no prescaler&#xA;  TCCR1B =  bit (CS10) | bit (ICES1);  // plus Input Capture Edge Select&#xA;  interrupts ();&#xA;&#xA;  } // end of startTiming&#xA;&#xA;void finishTiming ()&#xA;  {&#xA;  active = false;&#xA;  Serial.print (&quot;Capacitance = &quot;);&#xA;  float capacitance = (float) timerCounts * k;&#xA;  Serial.print (capacitance);&#xA;  Serial.println (&quot; nF&quot;);&#xA;  triggered = false;&#xA;  delay (3000);&#xA;  }  // end of finishTiming&#xA;&#xA;void loop ()&#xA;  {&#xA;  // start another test?&#xA;  if (!active)&#xA;    startTiming ();&#xA;&#xA;  // if the ISR noted the time interval is up, display results&#xA;  if (active &amp;amp;&amp;amp; triggered)&#xA;    finishTiming ();&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For extra accuracy the code uses the Input Capture Unit, which is something that remembers the exact value in Timer 1 when the match occurs. This avoids the delay of 2 to 3 µs while the ISR kicks into action.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Results&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I measured a few values using a capacitance-substitution box. To check on the box I measured also with a high-precision multimeter. The value on the right is what the sketch gave (rounded).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(All values in nF)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Nominal    Meter     Sketch&#xA;Value      Measure   Measure&#xA;&#xA;    40         42        42&#xA;   100         98       102&#xA;   200        202       201&#xA;   300        312       313&#xA;   400        389       391&#xA;  1000       1004      1010&#xA;  2000       2011      2012&#xA;  3000       2950      2953&#xA;  4000       4160      4170&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch output certainly seems to be close to the nominal and measured values.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What about using the internal voltage reference (1.1v) instead of AIN0? which one will be better as the 2xAA batteries voltage drops over time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The voltage doesn't matter as it is not in the equation. It is the &lt;strong&gt;ratio&lt;/strong&gt; that matters, and that will scale with battery drop (ie. the ratio between the two resistors will always be the same).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use Vcc because it is turned on and off at an output pin (to start charging the capacitor).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also what is the difference between TIMER1_CAPT_vect which you used here and ANALOG_COMP_vect which you used in the example in your site? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you are &lt;strong&gt;not&lt;/strong&gt; using the Input Capture Unit, then you need to get the Analog Comparator interrupt. However if you use the Input Capture Unit then you use the Timer1 Capture Event which is triggered when you get the capture.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-02T22:16:25.060" LastActivityDate="2015-09-02T22:16:25.060" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14731" PostTypeId="2" ParentId="14702" CreationDate="2015-09-01T12:53:08.683" Score="2" Body="&lt;p&gt;I don't think you should leave s2 and s3 floating. A floating pin does not mean nor 0 nor 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect them both to ground. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-09-01T12:53:08.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14732" PostTypeId="2" ParentId="13462" CreationDate="2015-09-01T14:13:41.087" Score="2" Body="&lt;p&gt;The SIM900 allows creation of TCP sockets through an AT style command language, so this addresses point #1 of the previous comments concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is only half the story though, you'll still need to learn how to create the requests, and handle the responses of the MQTT protocol using the SIM900's protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be usable examples to start from in the ESP8266 community, as their style of TCP API looks similar to the SIM900.&lt;/p&gt;&#xA;" OwnerUserId="4082" LastActivityDate="2015-09-01T14:13:41.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14734" PostTypeId="1" AcceptedAnswerId="19119" CreationDate="2015-09-01T16:35:59.837" Score="0" ViewCount="492" Body="&lt;p&gt;I have an amplifier circuit for a microphone.The output of the circuit(the microphone signal amplified) is connected to the arduino A0 .Now the circuit works(I think ,the output voltage is 4.30 V) and the arduino serial monitor output 875 874... fluctuates with one or 1,2 or more points.The problem is that this value just goes down from 875....800.... .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a correct value?(circuit taken from here &lt;a href=&quot;http://wiring.org.co/learning/basics/microphone.html&quot; rel=&quot;nofollow&quot;&gt;http://wiring.org.co/learning/basics/microphone.html&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If I put my finger on it the values go up a bit like 792 ,794,800&lt;/p&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="10794" LastEditDate="2015-09-02T01:46:52.903" LastActivityDate="2015-12-31T16:48:19.400" Title="Microphone input into Arduino uno R3" Tags="|arduino-uno|audio|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14736" PostTypeId="2" ParentId="3634" CreationDate="2015-09-01T17:19:11.557" Score="0" Body="&lt;p&gt;Check the Chips for any solder mistake, I found that my serial chip had two pins soldered together, probably cause i bought it for cheap :D&lt;/p&gt;&#xA;" OwnerUserId="12136" LastActivityDate="2015-09-01T17:19:11.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14737" PostTypeId="1" AcceptedAnswerId="14741" CreationDate="2015-09-01T19:17:42.040" Score="1" ViewCount="213" Body="&lt;p&gt;I would like to make a device that can take a photo, and send it to a website over wifi. I'm using an Arduino Uno, a ArduCam OV2640 module, and ESP8266 Serial WIFI module. Eventually I'd like to take it off the board as a stand alone project for permanent use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wifi works fine, but requires a serial communication to configure. I would like to make it so that I can plug the device into a computer (via something like micro usb), change the WIFI settings, and save those settings for future reboots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there anyway I can do this with an Arduino interface? If not, what could I use instead?&lt;/p&gt;&#xA;" OwnerUserId="12138" LastActivityDate="2015-09-01T21:37:25.320" Title="How can I configure Arduino after programming it (for post upload wifi configuration)?" Tags="|wifi|communication|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14738" PostTypeId="1" CreationDate="2015-09-01T20:01:46.787" Score="1" ViewCount="784" Body="&lt;p&gt;I am looking for a simple way to detect nitrogen gas flow through a tube. I don't even need any sort of precision, just really need to know if flow exists or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some options I could pursue to easily measure this with the arduino?&lt;/p&gt;&#xA;" OwnerUserId="12139" LastEditorUserId="11529" LastEditDate="2015-09-01T21:01:51.947" LastActivityDate="2015-09-02T19:54:16.373" Title="How to measure nitrogen flow through a tube?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14740" PostTypeId="2" ParentId="14711" CreationDate="2015-09-01T21:30:40.523" Score="2" Body="&lt;p&gt;If I'm interpreting the datasheet correctly, you might be able to use the Static Memory Controller (SMC) capability of the Cortex M3 Sam3X to attach some 128K x 8 SRAM devices to your Due.  If your ADC and DAC support tri-state outputs then they could be attached the same way as memories (but ignoring address lines as irrelevant), allowing memory-to-memory DMA transfers.  Ie one could either input and store batches of ADC results at 42 MSPS, or could output batches of data to DAC at 42 MSPS, or could do simultaneous I/O at 21 MSPS.  I haven't read the DMA section closely enough to verify that this will work with the M3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See Figure 25-2 in Section 25.6.2 of the datasheet regarding memory controllers, and Section 26, “Peripheral DMA Controller (PDC)”, regarding DMA.  Also see the eevblog.com page, “&lt;a href=&quot;http://www.eevblog.com/forum/microcontrollers/looking-for-cortex-m3-or-m4-with-dma-to-gpio-capability/&quot; rel=&quot;nofollow&quot;&gt;Looking for Cortex M3 or M4 with DMA to GPIO capability&lt;/a&gt;”.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-01T21:30:40.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14741" PostTypeId="2" ParentId="14737" CreationDate="2015-09-01T21:37:25.320" Score="0" Body="&lt;p&gt;I like Gerben's suggestion about putting the ESP8266 into Wireless Access Point mode and then providing access to your configuration settings via a web interface.  I've been dealing with the same question myself and this might be a workable solution.  The only downside is the amount of code required to get an ESP8266 to function as a WAP, provide a web-based UI, switch between configuration and running mode, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea that isn't as elegant, but would require a lot less code: Just store your configuration on an SD card, and add an SD card to your project using a separate board or shield.  You could edit the configuration by plugging it into a PC and editing the configuration file, then plug the card into your project which would read its configuration from the SD Card.&lt;/p&gt;&#xA;" OwnerUserId="9853" LastActivityDate="2015-09-01T21:37:25.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14742" PostTypeId="2" ParentId="14738" CreationDate="2015-09-01T21:38:31.993" Score="1" Body="&lt;p&gt;You can use a &lt;a href=&quot;http://www.trossenrobotics.com/p/phidget-differential-gas-pressure-sensor.aspx?feed=Froogle&amp;amp;gclid=CjwKEAjwmZWvBRCCqrDK_8atgBUSJACnib3l5u8e1KI9v_tjJWO6weY6IH03922kPj8-jWhzubchsBoCtErw_wcB&quot; rel=&quot;nofollow&quot;&gt;pressure sensor&lt;/a&gt; for gas and measure the pressure differential between two points and if there is a large pressure differential then you know a flow exists.&lt;/p&gt;&#xA;" OwnerUserId="12141" LastActivityDate="2015-09-01T21:38:31.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14743" PostTypeId="1" CreationDate="2015-09-01T22:18:38.470" Score="0" ViewCount="354" Body="&lt;p&gt;I'm trying to controll an AC unit but the issue is space - right now, I store the data like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp30[] = {233,636,17884,3032,8944,500,496,492,1496,524,472,548,452,544,448,552,444,552,444,548,444,552,444,552,1436,556,444,552,444,548,1440,552,472,524,472,520,1472,492,1496,520,1468,556,1436,552,1440,552,444,548,448,548,444,552,448,548,448,548,448,548,472,524,468,524,472,524,476,520,472,520,476,520,476,520,472,524,472,552,444,548,452,548,444,552,444,548,448,548,444,552,448,544,452,544,448,552,472,524,468,524,472,524,472,524,472,520,476,520,476,520,472,524,1468,552,1436,556,1436,556,1436,552,2944,3028,8920,548,1440,552,448,548,472,524,468,524,472,524,472,472,524,516,476,552,444,548,1444,552,444,548,448,552,440,556,440,556,1432,556,1440,548,452,544,1444,552,1464,524,1464,472,1520,524,1464,556,1436,552,1440,552,1436,556,440,552,448,548,444,552,1440,552,1440,552,1464,524,472,496,496,472,524,520,476,548,444,552,448,552,1440,548,1440,556,1432,556,1440,548,448,548,444,552,448,548,472,524,472,524,1464,472,524,472,524,516,476,552,444,552,444,552,1440,552,1440,552,1436,556,1436,552};&#xA;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp29[] = {233,636,17896,3032,8916,552,468,524,1468,524,468,500,496,472,528,520,476,544,448,552,444,552,444,548,1440,556,440,552,448,548,1440,552,444,548,452,544,1444,548,1468,524,1464,472,1520,520,1468,552,444,552,448,548,444,552,444,548,448,548,444,552,444,556,444,548,448,548,444,552,448,544,472,524,472,524,472,524,472,468,528,520,476,544,448,552,444,552,444,548,444,556,440,556,444,548,448,548,444,552,444,552,444,548,452,544,476,524,472,524,468,524,472,492,1496,520,1472,548,1440,556,1440,548,2944,3032,8916,552,1436,552,444,552,444,548,452,544,448,548,476,524,468,524,472,524,472,492,1496,520,476,524,472,548,448,552,444,552,1440,548,1440,548,448,548,1440,556,1440,548,1440,552,1464,524,1464,500,1496,520,1468,552,1440,548,444,556,444,552,444,548,1440,552,1440,548,1444,544,476,524,472,524,472,524,468,524,472,492,1496,524,476,548,1444,548,1440,548,1444,552,444,552,444,548,448,548,444,552,448,544,1448,544,476,524,468,524,472,524,472,492,504,516,1472,548,1444,552,1440,548,1440,548};&#xA;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp28[] = {233,636,17880,3056,8912,524,476,544,1444,552,444,548,448,552,440,556,440,556,444,552,444,548,444,552,1440,552,444,552,468,524,1468,524,468,472,524,520,1476,544,1444,548,1440,556,1432,556,1440,548,448,548,444,552,448,548,448,548,472,524,472,520,472,524,472,496,500,472,524,492,504,544,452,548,444,552,444,552,444,548,448,552,440,556,444,548,448,548,444,552,448,544,452,544,476,524,472,524,468,524,472,524,472,492,500,520,476,548,452,544,448,552,444,552,1440,548,1440,552,1440,552,1440,548,2944,3028,8924,544,1444,552,468,524,472,496,500,492,504,516,476,552,444,548,452,548,444,552,1440,548,444,552,444,552,1444,548,444,552,1440,548,1444,544,476,520,1472,492,1496,520,1468,552,1444,548,1440,552,1436,552,1440,552,1440,552,444,548,452,544,476,520,1468,524,1468,492,1496,520,480,544,448,548,448,552,444,548,444,552,444,548,452,548,1440,552,1436,552,1444,544,476,520,476,524,468,524,472,496,500,492,1496,524,476,544,452,548,444,552,444,548,448,548,1444,548,1440,552,1440,548,1444,520};&#xA;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp27[] = {233,640,17892,3032,8916,552,448,548,1464,528,468,528,468,468,528,468,528,520,472,552,444,552,444,552,1440,548,448,548,444,556,1436,552,444,552,444,552,1436,552,1444,548,1468,492,1496,472,1516,552,448,548,448,548,448,548,444,552,444,552,444,552,440,556,444,552,444,548,444,552,448,548,448,548,472,524,472,524,468,468,528,472,524,520,472,524,472,552,448,548,448,548,444,552,444,548,448,548,444,556,440,552,448,548,444,552,444,552,448,544,472,524,472,528,1464,468,1520,520,1472,552,1436,556,2944,3028,8912,556,1440,548,448,548,444,552,448,548,448,548,444,552,472,520,472,524,472,524,1464,472,528,488,508,544,448,552,444,552,1436,556,1436,552,448,548,1440,548,1440,556,1440,548,1440,552,1464,524,1464,472,1524,544,1444,552,444,552,448,548,444,552,1440,548,1440,552,1444,548,444,552,448,544,472,524,472,524,468,500,1492,492,1500,548,452,544,1440,556,1436,552,444,552,444,552,444,548,448,548,448,548,1444,548,472,524,468,524,472,524,472,472,528,468,1520,520,1468,552,1440,552,1436,552};&#xA;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp26[] = {233,640,17884,2980,8992,528,472,524,1464,472,524,520,476,548,444,556,440,556,444,548,444,552,444,552,1440,552,440,556,444,548,1440,552,444,552,468,524,1468,528,1460,472,1520,548,1444,548,1440,556,444,548,448,548,444,552,444,552,444,552,444,552,444,552,444,548,448,548,472,524,468,524,472,472,528,468,528,488,504,548,448,552,444,548,444,556,440,556,444,548,444,552,444,552,444,548,448,548,448,552,444,548,448,548,472,524,472,520,472,524,472,472,524,520,1468,548,1444,552,1440,552,1436,556,2944,3024,8920,552,1440,552,444,548,444,552,448,548,468,524,472,528,472,468,524,468,528,520,1472,548,444,556,444,548,1440,552,444,548,1440,556,1440,548,444,552,1440,548,1444,552,1464,492,1496,520,1472,548,1440,556,1440,548,1440,552,444,552,444,552,444,548,1440,552,1444,548,1440,548,472,524,472,472,524,472,520,520,480,544,452,548,1440,548,448,548,1440,552,1440,552,444,548,448,548,448,552,444,552,468,524,1464,524,472,472,528,468,524,468,528,544,452,548,1440,556,1436,552,1440,548,1440,556};&#xA;consts PROGMEM unsigned int Signal_Heat_Fan0_Temp25[] = {233,644,17892,3028,8916,552,444,548,1440,556,440,552,448,548,444,552,444,548,448,548,448,548,472,528,1464,468,528,520,472,548,1448,544,444,556,440,556,1440,548,1440,548,1440,556,1440,548,1440,552,448,544,472,528,472,524,468,468,528,468,528,544,448,552,444,552,444,552,444,552,444,552,444,552,444,548,444,552,444,552,444,552,448,548,444,552,468,524,472,524,472,524,468,472,524,472,528,520,476,544,448,552,444,548,448,548,444,556,440,556,444,548,444,552,1440,548,1440,556,1440,548,1468,548,2920,3052,8920,472,1516,548,452,548,444,552,444,548,448,548,444,556,440,556,444,548,448,548,1440,548,452,544,448,552,1440,548,472,524,1464,472,1516,552,448,544,1444,552,1444,548,1440,552,1436,552,1440,552,1440,552,1440,548,1464,528,472,496,500,468,524,520,1472,548,1440,556,1436,552,444,552,444,556,440,552,444,552,444,552,1436,552,448,544,452,548,1468,524,1464,468,528,520,472,552,448,548,448,548,448,548,1440,548,448,548,444,552,444,556,444,548,444,552,1440,548,1440,552,1464,500,1496,548};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first item is the length of the array and the rest is data I can send with IRemote library with the raw send libray. I've mapped most of the buttons and now I'm at&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 95.286 bytes of program storage space&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better encoding that could take less space? I'd like to add at least 3 times more commands to the Sketch, but I'm already at 37% on an Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know ideally I should generate the array, not store it, but I haven't gotten that far (yet, I'm working on it) and for me this is an interesting issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit 1: Code uploaded on GitHub - &lt;a href=&quot;https://github.com/vladbabii/SamsungACIrControll/tree/master/AC_IrControll&quot; rel=&quot;nofollow&quot;&gt;https://github.com/vladbabii/SamsungACIrControll/tree/master/AC_IrControll&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="709" LastEditorUserId="709" LastEditDate="2015-09-01T23:20:04.827" LastActivityDate="2015-09-02T02:48:14.600" Title="How to store IR data needed for AC controll in less space?" Tags="|arduino-mega|code-optimization|progmem|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="14744" PostTypeId="2" ParentId="14743" CreationDate="2015-09-01T22:24:00.197" Score="1" Body="&lt;p&gt;Do you need all of the data accessible at once? How about storing it on a file device or external memory? SDcards are slow but huge. &lt;a href=&quot;https://www.adafruit.com/products/1895&quot; rel=&quot;nofollow&quot;&gt;FRAM&lt;/a&gt; devices a fast but not as huge and typically aren't formatted for a file system. They act more like an independent memory space accessed by a function. (The Adafruit product is one example; I'm sure there are more).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-01T22:24:00.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14745" PostTypeId="2" ParentId="14729" CreationDate="2015-09-01T22:30:57.913" Score="1" Body="&#xA;&#xA;&lt;p&gt;My guess is you are running out of RAM. Your various string constants alone take up 202 bytes. Then there is this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  test1++;  &#xA;  str = String(test1); &#xA;  str.toCharArray(b,5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is very likely to fragment memory, as &lt;code&gt;test1&lt;/code&gt; gets larger and larger. So you are fragmenting RAM, of which you don't have much to start with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are you even converting test1 into a String object? And then converting it back into an array?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array &lt;code&gt;b&lt;/code&gt; can only hold 4 digits as it needs one byte for the trailing null-terminator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you stop doing that String stuff, and also use the &lt;code&gt;F()&lt;/code&gt; macro like this ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    Serial.println(&quot;Options button was pressed!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    Serial.println(F(&quot;Options button was pressed!&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ditto for all the other places you are displaying stuff.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-01T22:30:57.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14746" PostTypeId="2" ParentId="14743" CreationDate="2015-09-01T23:33:38.430" Score="2" Body="&lt;p&gt;I have analysed your codes with a small Lua script:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;function pairsByKeys (t, f)&#xA;  local a = {}&#xA;  -- build temporary table of the keys&#xA;  for n in pairs (t) do&#xA;    table.insert (a, n)&#xA;  end&#xA;  table.sort (a, f)  -- sort using supplied function, if any&#xA;  local i = 0        -- iterator variable&#xA;  return function () -- iterator function&#xA;    i = i + 1&#xA;    return a[i], t[a[i]]&#xA;  end  -- iterator function&#xA;end -- pairsByKeys&#xA;&#xA;&#xA;nums = {233,636,17884,3032,8944,&#xA;-- and so on ... &#xA;548,444,552,444,556,444,548,444,552,1440,548,1440,552,1464,500,1496,548}&#xA;&#xA;uniq = { }&#xA;&#xA;for k, v in ipairs (nums) do&#xA;  if uniq [v] then&#xA;    uniq [v] = uniq [v] + 1&#xA;  else&#xA;    uniq [v] = 1&#xA;  end -- else&#xA;end -- for&#xA;&#xA;count = 0&#xA;&#xA;for k, v in pairsByKeys (uniq) do&#xA;  print (string.format (&quot;%8i = %3i&quot;, k, v))&#xA;  count = count + 1&#xA;end&#xA;&#xA;&#xA;print (&quot;count = &quot;, count)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;     233 =   6&#xA;     440 =  18&#xA;     444 = 154&#xA;     448 =  86&#xA;     452 =  20&#xA;     468 =  42&#xA;     472 = 103&#xA;     476 =  27&#xA;     480 =   2&#xA;     488 =   2&#xA;     492 =  15&#xA;     496 =   8&#xA;     500 =  10&#xA;     504 =   4&#xA;     508 =   1&#xA;     516 =   4&#xA;     520 =  41&#xA;     524 =  97&#xA;     528 =  26&#xA;     544 =  39&#xA;     548 = 189&#xA;     552 = 196&#xA;     556 =  56&#xA;     636 =   3&#xA;     640 =   2&#xA;     644 =   1&#xA;    1432 =   3&#xA;    1436 =  24&#xA;    1440 =  91&#xA;    1444 =  26&#xA;    1448 =   2&#xA;    1460 =   1&#xA;    1464 =  21&#xA;    1468 =  16&#xA;    1472 =   8&#xA;    1476 =   1&#xA;    1492 =   1&#xA;    1496 =  12&#xA;    1500 =   1&#xA;    1516 =   3&#xA;    1520 =   5&#xA;    1524 =   1&#xA;    2920 =   1&#xA;    2944 =   5&#xA;    2980 =   1&#xA;    3024 =   1&#xA;    3028 =   4&#xA;    3032 =   4&#xA;    3052 =   1&#xA;    3056 =   1&#xA;    8912 =   2&#xA;    8916 =   4&#xA;    8920 =   3&#xA;    8924 =   1&#xA;    8944 =   1&#xA;    8992 =   1&#xA;   17880 =   1&#xA;   17884 =   2&#xA;   17892 =   2&#xA;   17896 =   1&#xA;count =     60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Assuming there is some jitter I rounded them to the nearest 50:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;for k, v in ipairs (nums) do&#xA;&#xA;  v = math.floor (v / 50)    -- &amp;lt;--- add this&#xA;  v = v * 50                 -- &amp;lt;--- add this&#xA;  if uniq [v] then&#xA;    uniq [v] = uniq [v] + 1&#xA;  else&#xA;    uniq [v] = 1&#xA;  end -- else&#xA;end -- for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;     200 =   6&#xA;     400 = 258&#xA;     450 = 219&#xA;     500 = 411&#xA;     550 = 252&#xA;     600 =   6&#xA;    1400 = 146&#xA;    1450 =  60&#xA;    1500 =  10&#xA;    2900 =   6&#xA;    2950 =   1&#xA;    3000 =   9&#xA;    3050 =   2&#xA;    8900 =  11&#xA;    8950 =   1&#xA;   17850 =   6&#xA;count =     16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, 16 different lengths. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So now you can use 4 bits per code (and a lookup table) rather than 16 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://learn.adafruit.com/tv-b-gone-kit/design-notes&quot; rel=&quot;nofollow&quot;&gt;TV-B-Gone design notes&lt;/a&gt; for how they compressed the IR codes for lots of TV brands into a small table in an ATtiny85.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-01T23:33:38.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14747" PostTypeId="2" ParentId="10013" CreationDate="2015-09-02T00:55:30.700" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, after answering the SPI, I want to go back to loop() instead of continue func().&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is an extremely bad idea, and not what ISRs are for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is all very well wanting to go back to loop, but you would also have to discard whatever is on the stack, since loop started. The suggested method of using &lt;code&gt;setjmp&lt;/code&gt; / &lt;code&gt;longjmp&lt;/code&gt; may possibly achieve that, but almost certainly you are doing this for the wrong reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Jumping back to &lt;code&gt;loop&lt;/code&gt; is like saying:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't care what was happening when the interrupt occurred&lt;/li&gt;&#xA;&lt;li&gt;I don't care if it is half-way through sending some message&lt;/li&gt;&#xA;&lt;li&gt;I don't care if it is half-way through turning on or off some device&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition to this memory which was allocated (eg. by String objects) might not be freed. In fact the interrupt might occur during memory allocation in which case variables used by the memory allocation routine could be in an indeterminate state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I strongly disagree with any suggested work-arounds. You simply should not be &quot;jumping out of&quot; an ISR and going somewhere else. Re-think the design.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-02T00:55:30.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14748" PostTypeId="2" ParentId="14743" CreationDate="2015-09-02T02:48:14.600" Score="1" Body="&lt;p&gt;Another form of storage is the EEPROM. There are between 512 bytes and 4K of EEPROM per Arduino, depending on the model of Arduino - see &lt;a href=&quot;https://www.arduino.cc/en/Reference/EEPROM&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/EEPROM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EEPROM is persistent when the power gets cut, and MAY or may not be overwritten when the program is changed - I have not tried. If it is not overwritten, you can write a sketch just to set it, then overwrite it with your IR sketch; otherwise, you may have to set up some way to &quot;upload&quot; the data into your sketch (e.g. if you press a special button, it will listen on the serial port, any bytes it reads it will write to the EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have an ISP (aka ICSP) programmer such as the USBasp (see google), which are very inexpensive, then you can read/write the EEPROM directly - all you need is 6 pins exposed. You can also use the USBasp to reprogram an AtMega/AtTiny which is not on an Arduino board (this also gives you a little extra program space, since it no longer requires a bootloader).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-02T02:48:14.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14749" PostTypeId="1" CreationDate="2015-09-02T04:44:59.987" Score="0" ViewCount="2391" Body="&lt;p&gt;Burning question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'm trying to burn the Arduino Leo bootloader onto a ATmega32U4 that's on 3.3V and the internal 8MHz clock.  Do I have to modify and rebuild the bootloader to set the fuses correctly, and can this be done with AVR Studio?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the references on doing this are dated.  The folder structure for the Arduino IDE has changed. I've done it in the past with 5V 16MHz 32U4s using an Arduino as ISP, but never with the AVRISP mkII on the Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the good side, I do have it up and running with Atmel Studio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="12147" LastActivityDate="2015-09-21T00:42:48.473" Title="Burning Arduino Leonardo Bootloader to ATmega32U4 with 8MHz internal clock" Tags="|arduino-leonardo|bootloader|atmega32u4|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="14750" PostTypeId="2" ParentId="14749" CreationDate="2015-09-02T05:00:20.013" Score="2" Body="&lt;p&gt;If you have an appropriate crystal attached then you can do this in the Arduino IDE. Select your board and programmer in the IDE menu, connect the programmer to the board, and choose &lt;code&gt;Burn Bootloader&lt;/code&gt; from the menu. This will both burn the prebuilt bootloader image and set the fuses in a single operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you cannot use USB on the '32U4 if you are running off either a ceramic resonator or the internal oscillator, and so you should not attempt to use the Leonardo bootloader in either case.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-02T05:00:20.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14751" PostTypeId="2" ParentId="14734" CreationDate="2015-09-02T10:32:04.960" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://courses.edx.org/asset-v1:BerkeleyX+EE40LX+2T2015+type@asset+block/robot_schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;This schematic&lt;/a&gt; contains also the OpAmp stage for a microphone.&#xA;You could take it as reference against the design you are using.&#xA;The LM386 is basically a more integrated version, iirc.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-02T10:32:04.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14753" PostTypeId="1" CreationDate="2015-09-02T13:44:35.163" Score="0" ViewCount="120" Body="&lt;p&gt;I will like to implement a serial communication protocol, using javascript in a mobile browser to make the browser background blink (alternating the color from black to white) according to the bits, to communicate a few bytes to an Arduino using some kind of light sensor (photo diode or resistor) to parse. Electric Imp did something with &lt;a href=&quot;https://electricimp.com/platform/blinkup/&quot; rel=&quot;nofollow&quot;&gt;https://electricimp.com/platform/blinkup/&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any library or implementation or where to start guide?, if not, how would you implement it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I fear one of the problems of using a mobile browser with javascript to light-encode the bits will be timing issues, since setTimeInterval is not perfect, I could split the screen, one half blinking continuously (clock) and the other half the data, but that will require two light sensors.&lt;/p&gt;&#xA;" OwnerUserId="12021" LastActivityDate="2016-07-12T16:05:32.740" Title="Light communication from pc/app to arduino" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14754" PostTypeId="1" AcceptedAnswerId="14761" CreationDate="2015-09-02T14:15:03.823" Score="1" ViewCount="90" Body="&#xA;&#xA;&lt;p&gt;I am working on a project where the end result is to count the number of cycles of a moving piece of metal using an inductive sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now I am using an Arduino Uno and have created a breadboard version for testing. The sensor has been replaced by a momentary push button. To check the count data I am viewing the number using Serial Monitor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the elements of this set-up are working, apart from one major issue. When pressing the button the incrementer (++) occasionally adds 2 instead of 1 from only one button press. As a rough guide to the error frequency, it seems to count 11 for every 10 button presses. The error has never presented as not counting enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to software, as such I cannot seem to see the error&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help and guidance would be greatly appreciated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I have written so far:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//Libraries&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;//Constants&#xA;const int counterPin = 2;   //Input from counter (looking for HIGH as external pulldown resistor is used)&#xA;const int EEPROMadress = 3; //holds the EEPROM address&#xA;&#xA;//Variables&#xA;int counterState = 0;       //current button state&#xA;int counterStatePrv = 0;    //previous button state&#xA;int storedValue;            &#xA;int presetCount = 100;&#xA;&#xA;unsigned long countNumber;      //unsigned 32bit variable&#xA;&#xA;void setup() {&#xA;&#xA;    for (int i = 0; i &amp;lt; 255; i++) {&#xA;        // this performs as EEPROM.write(i, i)&#xA;        EEPROM.update(i, i);&#xA;    }&#xA;    for (int i = 0; i &amp;lt; 255; i++) {&#xA;        // write &quot;presetCount&quot; value to cell &quot;EEPROMaddress&quot; only the first time&#xA;        // will not write the cell the remaining 254 times&#xA;        EEPROM.update(EEPROMadress, presetCount);&#xA;    }&#xA;&#xA;    pinMode(counterState, INPUT);&#xA;    Serial.begin(9600);&#xA;&#xA;    countNumber = EEPROM.read(3);   //Start the counter at the presetCount value&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    counterState = digitalRead(counterPin);   //Read the status of the counter input&#xA;    storedValue = EEPROM.read(EEPROMadress);&#xA;&#xA;    if (counterState != counterStatePrv) {      //check that pulse went off&#xA;        if (counterState == HIGH) {             //check for pulse&#xA;            countNumber++;                      //increment (add 1) to the stored count value&#xA;            delay(10);&#xA;            Serial.print(&quot;Count  Value: &quot;);&#xA;            Serial.println(countNumber);&#xA;&#xA;            Serial.print(&quot;Stored Value: &quot;);&#xA;            Serial.println(storedValue);&#xA;            Serial.println();&#xA;&#xA;        }&#xA;    }&#xA;    counterStatePrv = counterState;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12133" LastEditorUserId="10794" LastEditDate="2015-09-02T20:55:03.393" LastActivityDate="2015-09-02T20:55:03.393" Title="Can anyone identify why this incrementer is losing count?" Tags="|arduino-uno|c++|debounce|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14755" PostTypeId="2" ParentId="14753" CreationDate="2015-09-02T14:20:36.633" Score="1" Body="&lt;p&gt;Doing bit stuffing can prevent timing problems when you are sending a lot of &lt;code&gt;0&lt;/code&gt;s or &lt;code&gt;1&lt;/code&gt;s in an row. Alternatively use Manchester encoding (slower).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the browser side, I'd suggest using &lt;code&gt;&amp;lt;Canvas&amp;gt;&lt;/code&gt;. Combine this with &lt;code&gt;requestAnimationFrame&lt;/code&gt; which gives you a very accurate timestamp as an argument. Though you have to check for support as older browsers don't support that.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-09-02T14:56:39.697" LastActivityDate="2015-09-02T14:56:39.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14756" PostTypeId="2" ParentId="14753" CreationDate="2015-09-02T15:56:49.473" Score="0" Body="&lt;p&gt;You should investigate communication protocols and encoding techniques that embed the clock signal into the same data stream as the data signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One common method is called &lt;em&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Manchester_code&quot; rel=&quot;nofollow&quot;&gt;Manchester Coding&lt;/a&gt;&lt;/em&gt;.  This entails splitting each bit into two halves.  A 1 sends light followed by dark, and a 0 sends a dark followed by a light.  It's then up to you to work out which transitions are which and where in a bit they occur (is a high transition the start of a 1 or mid-way through a 0?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular method (used in things like Ethernet) is called 8b/10b.  That involves sending 10 bits to represent every 8 - more efficient than manchester coding (that could be considered 8b/16b) and can be read about here: &lt;a href=&quot;https://en.wikipedia.org/wiki/8b/10b_encoding&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/8b/10b_encoding&lt;/a&gt; It's somewhat harder to implement than Manchester Code, so although it's less efficient I'd recommend the simplicity of Manchester Code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="19174" LastEditDate="2016-07-12T16:05:32.740" LastActivityDate="2016-07-12T16:05:32.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14757" PostTypeId="2" ParentId="14720" CreationDate="2015-09-02T16:36:05.697" Score="0" Body="&lt;p&gt;This answer addresses the additional questions in Salah's comment:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I am using a 12V battery to power my motors and the ground of the battery is linked to the ground of my motor driver then mounted onto the arduino. So you mean i must use 3.3K resistors and connect them to the SDA and SCL pins on the MPU6050??to prevent any oscillations affecting the sensor is that right ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The MPU-6050 will work ok with Vdd = 3.3 V.  More specifically, page 14 of the 1788002.pdf datasheet for MPU-6000/MPU-6050 products shows&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;VDD = 2.375V-3.46V, VLOGIC (MPU-6050 only) = 1.8V±5% or VDD, TA = 25°C&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The wiring diagram on page 39 shows SDA and SCL being pulled up to VLOGIC (which is either 1.8 V or VDD, say 3.3 V).&lt;/p&gt;&#xA;&lt;p&gt;One suitable choice would be to operate an 8 MHz Mega and the 6050 at 3.3 V and pull SDA and SCL up to 3.3 V via 3.3 KΩ resistors.&lt;/p&gt;&#xA;&lt;p&gt;Another choice would be to operate a 16 MHz Mega at 5 V, operate the 6050 at 3.3 V, pull SDA and SCL up to 3.3 V via 3.3 KΩ resistors, and use 3.3V/5V level translations on SDA and SCL into the Mega.&lt;/p&gt;&#xA;&lt;p&gt;Built-in pullups for I/O pins on Mega2560 and similar devices are spec'd at 20 KΩ min, 50 KΩ max, so will provide less restoring current when a device releases a pin, than will a 3.3 KΩ resistor, and thus may be less noise-resistant or operate less speedily.&lt;/p&gt;&#xA;&lt;p&gt;The important issues for your power wiring are these:&lt;/p&gt;&#xA;&lt;p&gt;1, Isolate the motor drive and logic drives.  They can use the same ground point but motor current should not be running through the ground lead or leads that connect to the Arduino and the MPU-6050.  And use &lt;a href=&quot;https://en.wikipedia.org/wiki/Decoupling_capacitor&quot; rel=&quot;nofollow noreferrer&quot;&gt;decoupling capacitors&lt;/a&gt; as necessary.&lt;/p&gt;&#xA;&lt;p&gt;2, Power the MPU-6050 with 3.3 V or less; pull up SDA and SCL to that level via 3.3 KΩ resistors; use level translators if the Mega operates at a different voltage than the MPU-6050.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Edit: About Grounding –&lt;/em&gt; For a detailed discussion, see &lt;a href=&quot;http://www.analog.com/library/analogDialogue/archives/46-06/staying_well_grounded.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Staying Well Grounded&lt;/a&gt;, an analog.com article.  For overviews, see &lt;a href=&quot;http://web.archive.org/web/20141030161947/http://www.lh-electric.net/tutorials/gnd_loop.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Star Grounding&lt;/a&gt; at lh-electric.net, or at wikipedia, &lt;a href=&quot;https://en.wikipedia.org/wiki/Ground_noise&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ground Noise&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Ground_bounce&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ground Bounce&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Ground_%28electricity%29#Electronics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ground (electricity) Electronics&lt;/a&gt;.  By “motor current should not be running through the ground lead or leads that connect to the Arduino and the MPU-6050” I refer to the use of separate wires for conducting ground current.  Typically, this will matter only if your motor current is high or noisy.  The idea is to have a heavy wire from the ground post of the battery to the motors, and a separate wire from the ground post of the battery to the Arduino and the MPU-6050.  Voltage across a wire changes as current in the wire changes.  Using separate ground wires, the Arduino and the MPU-6050 are less affected by ground wire voltage changes caused by motor current.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="27346" LastEditDate="2021-04-03T21:53:21.570" LastActivityDate="2021-04-03T21:53:21.570" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="14758" PostTypeId="2" ParentId="9009" CreationDate="2015-09-02T17:54:10.613" Score="1" Body="&lt;p&gt;I'm currently using the ESP8266 modules. They are available for little money on eBay and the like and they provide a pretty nice Wifi-Module. You can even (and I would recommend that) be programmed by the Arduino IDE using some clever core that a few people built here: &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using that you got a Wifi-Server built into the delivered Libraries that can provide basic functions. It can also output files from an SD card if available, there is an example for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from that the module has a lot of Flash and you might not even need the Arduino if you don't need a lot of I/O, if you need a lot of I/O then you might want to communicate across a serial link. You will need to make sure to lower the voltage for the ESP, either use a 3.3V Arduino or build a level converter between the Arduino and the ESP, like this: &lt;a href=&quot;http://www.hobbytronics.co.uk/mosfet-voltage-level-converter&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/mosfet-voltage-level-converter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not as easy as using a Wifi-Shield but it's very cheap to use.&lt;/p&gt;&#xA;" OwnerUserId="12054" LastActivityDate="2015-09-02T17:54:10.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14759" PostTypeId="2" ParentId="9111" CreationDate="2015-09-02T18:03:11.597" Score="0" Body="&lt;p&gt;You could create the character data yourself. I've built a little script for a similar prospect a while ago that does translate a matrix of checkboxes to a bit-array: &lt;a href=&quot;http://jsfiddle.net/qrsye920/&quot; rel=&quot;nofollow&quot;&gt;http://jsfiddle.net/qrsye920/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12054" LastActivityDate="2015-09-02T18:03:11.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14760" PostTypeId="1" CreationDate="2015-09-02T18:23:26.993" Score="0" ViewCount="796" Body="&lt;p&gt;Servo goes to one end, and immediately travels back without a 2s delay inbetween. After it travels back there is a 2s delay before it loops. Why isn't there a 2s delay before the travel back?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo testservo;&#xA;&#xA;void setup() {&#xA;    testservo.attach(9);&#xA;}&#xA;&#xA;void loop() {  &#xA;    testservo.writeMicroseconds(700);&#xA;    delay(2000);&#xA;    testservo.writeMicroseconds(2300);&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12156" LastEditorUserId="4143" LastEditDate="2015-09-02T18:37:09.887" LastActivityDate="2015-10-02T22:07:45.837" Title="'Simple' problem. Delay not working?" Tags="|servo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14761" PostTypeId="2" ParentId="14754" CreationDate="2015-09-02T19:46:46.167" Score="0" Body="&lt;p&gt;Buttons bounce (at least they appear to, electrically), meaning that if you're fast enough, you can detect multiple pulses per button-press. Usually we don't count the button as being pressed until we read the same value {n} times in a row or for {m} mSec, or some similar technique. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because you call &lt;code&gt;EEPROM.read()&lt;/code&gt; immediately after testing the button, perhaps most times the bouncing will have ceased when the call returns, but once in a while one last bounce slips through. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon, a regular contributer here, has a good discussion of &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;de-bouncing&lt;/a&gt; on his web site. Have a look at that and pick a technique that's compatible with what you're trying to do.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-02T19:46:46.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14762" PostTypeId="2" ParentId="14738" CreationDate="2015-09-02T19:54:16.373" Score="1" Body="&lt;p&gt;What you are looking for is a mass flow sensor&lt;a href=&quot;https://en.wikipedia.org/wiki/Mass_flow_sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt; (MAF)&lt;/a&gt;, or something along those lines as you mention wanting to know if there is flow, this gives you the &lt;em&gt;'speed'&lt;/em&gt; of the flow. There are various types available according to size, flow rate, type of element, and accuracy. Just search for mass flow sensor, you can even hack them off cars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you just want to detect only the presence of the N&lt;sub&gt;2&lt;/sub&gt; as you say then you can split your pipe somewhere,and then add a T-piece to that. You then put a gas sensor in the T part, and seal it off so there is no leaks. You would then hook that up to the Arduino board and interpret the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't recommend any specific sensors though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an image for the idea:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gAuqj.png&quot; alt=&quot;RSM_design&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-09-02T19:54:16.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14763" PostTypeId="1" AcceptedAnswerId="14765" CreationDate="2015-09-02T20:02:23.707" Score="0" ViewCount="4281" Body="&lt;p&gt;I'm having some difficulty assigning a value to a variable in a struct array outside the loop and setup functions. Assigning a value to an int or char array works completely fine but this doesn't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example code and error message returned after trying to compile are below. Any help is greatly appriciated. Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;}&#xA;&#xA;struct trap_game_detail {&#xA;    byte flush_quantity;&#xA;    byte flush_interval;&#xA;    byte random_min;&#xA;    byte random_max;&#xA;    byte random_quantity;&#xA;} trap_game_details[2];&#xA;&#xA;trap_game_details[0].random_min = 1;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;src/sketch.ino:13:5: error: ‘trap_game_details’ does not name a type&#xA;     trap_game_details[0].random_min = 1;&#xA;     ^&#xA;.build/uno/Makefile:166: recipe for target '.build/uno/src/sketch.o' failed&lt;/p&gt;&#xA;" OwnerUserId="8726" LastActivityDate="2015-09-02T22:17:55.157" Title="Assigning value inside structure array outside setup and loop functions" Tags="|c++|struct|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14764" PostTypeId="2" ParentId="14763" CreationDate="2015-09-02T20:13:46.920" Score="1" Body="&lt;p&gt;You can't access array contents in the global scope like that.  You have to assign the entire block of data in one go:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct trap_game_detail {&#xA;    byte flush_quantity;&#xA;    byte flush_interval;&#xA;    byte random_min;&#xA;    byte random_max;&#xA;    byte random_quantity;&#xA;};&#xA;&#xA;struct trap_game_details trap_game_details[2] = {&#xA;    { 10, 5, 1, 100, 4 },&#xA;    { 8, 23, 5, 95, 8 }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Items in the &lt;em&gt;global scope&lt;/em&gt; aren't executed - only things in functions are executed.  Accessing individual parts of an array or struct like you are trying to is a programatic operation, so can't be executed since it's not in a function.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-02T20:13:46.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14765" PostTypeId="2" ParentId="14763" CreationDate="2015-09-02T20:51:06.580" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Assigning a value to an int or char array works completely fine but this doesn't. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It only works fine if you do it on the declaration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo = 42;  &amp;lt; ---- declare and define with initial value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int foo;   // &amp;lt; ---- declare and define&#xA;&#xA;foo = 42;  // &amp;lt; ---- assignment statement&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code was like the second example.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Majenko has shown one way. He split the declaration into two parts. The first part declared the &lt;strong&gt;type&lt;/strong&gt; trap_game_detail, and the second part is an &lt;strong&gt;instance&lt;/strong&gt; of that type, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct trap_game_detail {&#xA;    byte flush_quantity;&#xA;    byte flush_interval;&#xA;    byte random_min;&#xA;    byte random_max;&#xA;    byte random_quantity;&#xA;};&#xA;&#xA;struct trap_game_details trap_game_details[2] = {&#xA;    { 10, 5, 1, 100, 4 },&#xA;    { 8, 23, 5, 95, 8 }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, and a bit closer to what you were doing, just keep going with the initialization values after you define the structure, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct trap_game_detail {&#xA;    byte flush_quantity;&#xA;    byte flush_interval;&#xA;    byte random_min;&#xA;    byte random_max;&#xA;    byte random_quantity;&#xA;} trap_game_details[2] =  &#xA;  {&#xA;    { 10, 5, 1, 100, 4 },&#xA;    { 8, 23, 5, 95, 8 }&#xA;  }; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-02T22:17:55.157" LastActivityDate="2015-09-02T22:17:55.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14766" PostTypeId="2" ParentId="14760" CreationDate="2015-09-02T22:01:18.677" Score="2" Body="&lt;p&gt;Your description (“Servo goes to one end, and immediately travels back without a 2s delay... After it travels back there is a 2s delay before it loops”) implies an overall cycle time of 2 seconds, which appears to be inconsistent with the overall 4-second cycle implied by the code shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are things you can do to debug the problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Turn on an LED before one &lt;code&gt;writeMicroseconds()&lt;/code&gt; call, and turn it off before the other.  For example, add &lt;code&gt;pinMode(13, OUTPUT);&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt;, and revise &lt;code&gt;loop()&lt;/code&gt; as follows:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {  &#xA;    testservo.writeMicroseconds(700);&#xA;    digitalWrite(13, HIGH);&#xA;    delay(2000);&#xA;    testservo.writeMicroseconds(2300);&#xA;    digitalWrite(13, LOW);&#xA;    delay(2000);&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may allow you to find out which end the servo is going to.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Besides adding LED signals, try slightly-less extreme times in the &lt;code&gt;writeMicroseconds()&lt;/code&gt; calls; eg 1000 and 2000 microseconds rather than 700 and 2300.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;See if a neutral servo setting works, eg via code like the following.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { LEDpin=13, dtime=2000}&#xA;void stest(angletime, tHi, tLo) {&#xA;    testservo.writeMicroseconds(angletime);&#xA;    digitalWrite(LEDpin, HIGH);&#xA;    delay(tHi);&#xA;    digitalWrite(LEDpin, LOW);&#xA;    delay(tLo);&#xA;}&#xA;void loop() {&#xA;    stest(1000, dtime-50, 50); // Go CCW&#xA;    stest(1500, 50, dtime-50); // Middle&#xA;    stest(2000, 50, dtime-50); // Go CW&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this code runs, the LED should stay on about 2 seconds with the servo fully (or nearly so) counterclockwise.  Then the LED should blip and the servo should move to center position and stay there about 2 seconds.  Then the LED should blip and the servo should stay fully clockwise about 2 seconds.  This three-part cycle should repeat every six seconds.  If it works ok, then try modifying it, eg by changing 1000 us to 700, 2000 to 2300, etc, or by decreasing the &lt;code&gt;dtime&lt;/code&gt; value to see how quickly the servo can respond, etc.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-02T22:01:18.677" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14767" PostTypeId="2" ParentId="10390" CreationDate="2015-09-02T22:14:11.007" Score="1" Body="&lt;p&gt;What about measuring this with two resistive probes - the electricity will go through down one probe to the top of the water, across the water, and up the other probe. You can measure how much of the probe it went down, by measuring the resistance. You would need the probes to be a specific, very consistent distance apart, and be made of resistance wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use a float of some kind, and measure it this way. This is a lot easier if all you need to know is full/not full.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-02T22:14:11.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14768" PostTypeId="1" CreationDate="2015-09-02T14:58:04.150" Score="0" ViewCount="371" Body="&lt;p&gt;I didn't find answers which solves my problem with the max232 yet.&#xA;I connected it like this to my Arduino uno, so my Arduino provides the +5V VCC and the ground:&#xA;&lt;a href=&quot;https://www.google.be/search?q=max232&amp;amp;biw=2144&amp;amp;bih=1127&amp;amp;tbm=isch&amp;amp;imgil=fyy0lqGALI9HtM%253A%253BcH09mn8Z6FvbpM%253Bhttp%25253A%25252F%25252Fsodoityourself.com%25252Fmax232-serial-level-converter%25252F&amp;amp;source=iu&amp;amp;pf=m&amp;amp;fir=fyy0lqGALI9HtM%253A%252CcH09mn8Z6FvbpM%252C_&amp;amp;dpr=0.9&amp;amp;usg=__KByygPTJOBdI1tDfqv3X0dFdvZ4%3D&amp;amp;ved=0CDEQyjdqFQoTCOG0i8i32McCFYtVPgodYpMMFg&amp;amp;ei=pfbmVaHODour-QHiprKwAQ#imgrc=fyy0lqGALI9HtM%3A&amp;amp;usg=__KByygPTJOBdI1tDfqv3X0dFdvZ4%3D&quot; rel=&quot;nofollow noreferrer&quot;&gt;max232 connection&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/B2iBp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B2iBp.jpg&quot; alt=&quot;Connection on board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing what is differences are that I do a loopback at the RS232 side and I use 1µF for every capacitor even for the bypass one. I did a loopback so I can see if the max232 works. I don't get anything out of it when I send some data to it.&#xA;I measure +8.7V on pin2 and -8.15V on pin 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Software serial multiple serial test&#xA;&#xA; Receives from the hardware serial, sends to software serial.&#xA; Receives from software serial, sends to hardware serial.&#xA;&#xA; The circuit: &#xA; * RX is digital pin 10 (connect to TX of other device)&#xA; * TX is digital pin 11 (connect to RX of other device)&#xA;&#xA; created back in the mists of time&#xA; modified 25 May 2012&#xA; by Tom Igoe&#xA; based on Mikal Hart's example&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; */&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.print(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong or is my max232 broken?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the serial monitor (same baudrate) doesn't write to the ports so I rewrite some code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;loop code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i = 0;&#xA;void loop() // run over and over&#xA;{&#xA;  if(i == 10)&#xA;    i = 0;&#xA;&#xA;  mySerial.write(i);&#xA;  Serial.print(mySerial.read());&#xA;  i++;&#xA;  delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In serial monitor I get strange values back for a cascade counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Values:&#xA;-1 45 49 52 53 52 57 53 ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These numbers aren't ascii code for ectual numbers I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the loopback works thanks to the answer below.&#xA;Now I replaced the loopback with the module FUM DCF-U.&#xA;The loop code has changed to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() // run over and over&#xA;{&#xA;  if(Serial.available())&#xA;    Serial.println(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the result is '000000000000000000000000000000000...' in a fast rate and not every second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The module gets its 3.3V and is connected to the same GND as the MAX232.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin connections:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino - MAX232&lt;/p&gt;&#xA;&#xA;&lt;p&gt;11 - 11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0 - 12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MAX232 - FUM DCF-U&lt;/p&gt;&#xA;&#xA;&lt;p&gt;14 - 3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;13 - 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="13391" OwnerDisplayName="Daan Mouha" LastEditorUserId="13391" LastEditDate="2015-09-15T08:36:20.290" LastActivityDate="2021-06-22T00:09:00.857" Title="Can't get values of max232 with loopback" Tags="|max232|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="14769" PostTypeId="2" ParentId="14768" CreationDate="2015-09-02T22:05:36.290" Score="1" Body="&lt;p&gt;SoftwareSerial cannot both send and receive at the same time, as it does receiving inside an ISR, and turns interrupts off when sending. Thus this will never work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you switch to HardwareSerial. Or, if you want to see the results, send using SoftwareSerial and receive using HardwareSerial. For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial (10, 11); // RX, TX&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  mySerial.begin (115200);&#xA;  }  // end of setup&#xA;&#xA;unsigned long lastSend;&#xA;char c = ' ';&#xA;void loop ()&#xA;  {&#xA;  // time for another test send?&#xA;  if (millis () - lastSend &amp;gt;= 500)&#xA;    {&#xA;    mySerial.print (c++);&#xA;    if (c &amp;gt; 'z')&#xA;      {&#xA;      c = ' ';&#xA;      Serial.println ();&#xA;      }    &#xA;    lastSend = millis ();&#xA;    }&#xA;&#xA;  // check for response&#xA;  if (Serial.available ())&#xA;    Serial.print (char (Serial.read ()));&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested that as a simple loopback and it worked fine. Connect pin 11 (Tx) to pin 0 (Rx). Disconnect the wire to pin 0 whilst uploading.&lt;/p&gt;&#xA;" OwnerUserId="10794" OwnerDisplayName="Nick Gammon" LastActivityDate="2015-09-02T22:05:36.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14771" PostTypeId="1" CreationDate="2015-09-02T22:58:54.957" Score="2" ViewCount="802" Body="&lt;p&gt;I am building a Travis CI job to test my Arduino Library and it needs to install external board definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way that I can set the boardsmanager.additional.urls from the command prompt like it would have been done in the Preferences window?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or should I create preferences.txt file? (If so where does that live in a Linux environment)&lt;/p&gt;&#xA;" OwnerUserId="10303" LastActivityDate="2015-09-03T00:49:07.353" Title="Arduino Command Line Interface - How to change boardsmanager.additional.urls" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14772" PostTypeId="2" ParentId="5383" CreationDate="2015-09-02T23:56:59.653" Score="1" Body="&lt;p&gt;I think the problem is that there is more to serial I/O than just bits coming in. Otherwise, if nothing was sending, you would always read 0 from the serial port. Serial has a start and stop bit, for example. I doubt you could use the hardware serial to read in random bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to do this in software, you will have less than 16 clock cycles per bit - enough time to run about 15 instructions. It is not impossible, but very difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two ways to read the data in code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Option 1: Disable interrupts, and hand-write assembler that takes exactly the right amount of time. If you branch, make sure all branches take the same amount of time. I think all assembler instructions on Atmel take 1 cycle. You will need to pad out your loop to a predictable size. At 1.024mhz, the clock will drift by 2.4%, which means you'll either have to supersample (e.g. take one sample every 12 instructions, then throw away the samples closest to the clock interval) or you'll have to make some loops longer than others. If you store 8 bits per byte (as opposed to having an array of 77 bytes, storing 1 bit in each, which would be quicker), then you might get away with making &quot;move to next byte&quot; a different length.  Try to measure each sample in the MIDDLE of the allowed period, or as close to it as you can. You may have to unroll your loops (i.e. instead of &quot;repeat this 77 times&quot;, do &quot;do it, do it again, do it again....). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you might be able to write an ISR - Your ISR would have to be very short, basically &quot;write the current time to a pre-defined array&quot;. Now you have 15 instructions to get the data out, but padding it OUT isn't so critical. With this method, you will get one datapoint per CHANGE (rising or falling signal). I don't know if micros() would be quick enough. Then, once the read is complete, you can post-process the data at your leisure. The ISR will be called at the start of the clock cycle following the change in signal, so this is likely to be easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Micros only has a resolution of 4 microseconds, so you will have to make your own &quot;clock&quot;. The easiest way to do this, is to set a counter with about how long you think it will take (, then hand-code a loop to decrement this, until zero. As far as I can make out, the decrement loop should take 2 cycle (decrement the counter, if-not-zero jump back to decrement). So if you start it at 800, it should take 100ms to reach zero. Remember that the ISR will stop the counter for the duration, you will need to compensate. Make sure that this loop isn't optimized out! Your ISR will be: copy the (above) counter into an array, increment your array pointer by 1 (so next time you put it in a different slot in your array). After the counter reaches zero, disable your ISR, and find the difference between each number and the next; add a constant (worked out by trial and error), round to the nearest 8 (which should be pretty close). Divide by 8. The first result should be the delay to the start of the data (first 1); the second will be the number of consecutive 1's, then the number of consecutive 0's, etc.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-09-03T00:10:58.147" LastActivityDate="2015-09-03T00:10:58.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14773" PostTypeId="2" ParentId="14771" CreationDate="2015-09-03T00:49:07.353" Score="5" Body="&lt;p&gt;Found the solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino --pref &quot;boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10303" LastActivityDate="2015-09-03T00:49:07.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14774" PostTypeId="2" ParentId="14631" CreationDate="2015-09-03T02:56:39.333" Score="2" Body="&lt;p&gt;You can use a single analog pin to read an entire keypad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, read up on voltage dividers - they let you convert a resistance into a voltage. You will need to know this later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A keypad typically has 4 inputs, and 3 outputs (or vice-versa). Label the 4 pins A,B,C,D and the 3 pins E, F, G. You will be wiring A up to a voltage supply, and G up to an analog pin, and via a suitable resistor to ground. This becomes your voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, put a resistor between A+B, B+C, C+D, and between E+F, F+G. So, if you press the button that connects A to G, there will be no resistance (=+5V). If you press the button that connects A to F, then the resistance will be that of the resistance F-&gt;G. If you press the button that connect D and E, the circuit goes: VCC-A-resistor-B-resistor-C-resistor-D-pushbutton-E-resistor-F-resistor-G - Arduino analog pin. With no button pressed, the voltage will be 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to work out different resistors in advance, to give you as even a range as possible between 0 and 5 volts (the critical thing being the smallest difference). You can calculate the resistance of any combination here: &lt;a href=&quot;http://www.calculator.net/resistor-calculator.html&quot; rel=&quot;nofollow&quot;&gt;http://www.calculator.net/resistor-calculator.html&lt;/a&gt; and you can use Ohm's law to calculate the final voltage. This depends on what you have in your kit. I ended up making a spreadsheet, and then trying random resistor values until I got a good spread.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DO NOT use any resistors under 1kOhm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have the right spread, make it up on a solderless breadboard. Measure the voltage with your arduino (use the &quot;readanalogvoltage&quot; sketch, take out &lt;code&gt;* (5.0 / 1023.0)&lt;/code&gt; , and make up a table - press button 1, you get a reading if A, press button 2, get a reading of B. Include the reading when no button is pressed, which should be 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then find the numbers exactly in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if the lowest three readings are 0,20,37 for no button, A, and B pressed, respectively, then in your code, you will say: if the pin measures less than (half way between 0 and 20=) 10, then no button is pressed; else if the pin measures less than (half way between 20 and 37=) 29, then button A is pressed... and so forth.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-03T02:56:39.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14775" PostTypeId="1" CreationDate="2015-09-03T00:53:42.130" Score="2" ViewCount="1010" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/01Cvv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/01Cvv.png&quot; alt=&quot;arduino&quot;&gt;&lt;/a&gt;&#xA;Please, iam a junior in arduino and i want to know what is the importance of the resistors that connect to push buttons? can i replace them by wires?&#xA;thanks in advance.&lt;/p&gt;&#xA;" OwnerDisplayName="Muhammed R. Hafez" LastEditorUserId="10794" LastEditDate="2015-09-12T00:34:24.747" LastActivityDate="2015-09-12T00:34:24.747" Title="what is the importance of the resistors that connect to push buttons ? can i replace them by wires?" Tags="|led|wires|electronics|resistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14776" PostTypeId="2" ParentId="14775" CreationDate="2015-09-03T01:01:03.493" Score="6" Body="&lt;p&gt;They are what is known as Pull-Up resistors.  The circuit will not work if you replace them with wires.  Not only that but you will short circuit the power supply when you press a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why don't you want to use resistors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value is not important - you could use the same value as you are using for the LED if you don't have the 10k resistors shown in the drawing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that an alternative is to leave them out and instead activate the internal pull-ups within the processor on the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT);           // set pin to input&#xA;digitalWrite(pin, HIGH);       // turn on pullup resistors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="29866" OwnerDisplayName="Kevin White" LastActivityDate="2015-09-03T02:34:00.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14777" PostTypeId="1" CreationDate="2015-09-02T04:47:22.757" Score="0" ViewCount="1314" Body="&lt;p&gt;Burning question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'm trying to burn the Arduino Leo bootloader onto a ATmega32U4 that's on 3.3V and the internal 8MHz clock.  Do I have to modify and rebuild the bootloader to set the fuses correctly, and can this be done with AVR Studio?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the references on doing this are dated.  The folder structure for the Arduino IDE has changed. I've done it in the past with 5V 16MHz 32U4s using an Arduino as ISP, but never with the AVRISP mkII on the Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the good side, I do have it up and running Atmel Studio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:  Sorry for double posting, I posted in electronics before I noticed there was an Arduino specific section.  &lt;/p&gt;&#xA;" OwnerUserId="12147" OwnerDisplayName="BlackJester" LastEditorUserId="12147" LastEditDate="2015-09-04T05:30:21.870" LastActivityDate="2015-09-04T05:30:21.870" Title="Burning Arduino Leonardo Bootloader to ATmega32U4 with 8MHz internal clock" Tags="|bootloader|" AnswerCount="1" CommentCount="2" ClosedDate="2015-09-04T01:01:55.657" ContentLicense="CC BY-SA 3.0" />
  <row Id="14778" PostTypeId="2" ParentId="14777" CreationDate="2015-09-02T04:57:58.717" Score="1" Body="&lt;p&gt;If you have an appropriate crystal attached then you can do this in the Arduino IDE. Select your board and programmer in the IDE menu, connect the programmer to the board, and choose &lt;code&gt;Burn Bootloader&lt;/code&gt; from the menu. This will both burn the prebuilt bootloader image and set the fuses in a single operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you cannot use USB on the '32U4 if you are running off either a ceramic resonator or the internal oscillator, and so you should not attempt to use the Leonardo bootloader in either case.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-09-02T04:57:58.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14779" PostTypeId="1" CreationDate="2015-09-03T04:04:07.937" Score="0" ViewCount="389" Body="&lt;p&gt;i want to know that if i use atmega328-pu instead of atmega8 on this design provided by &quot;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardSerialSingleSided3&lt;/a&gt;&quot;, will it works fine on this design or i have to use only atmega8 ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DBFsm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DBFsm.jpg&quot; alt=&quot;ArduiniBoardSerialSingleSided&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Junaid Maqsood" LastEditorUserId="10794" LastEditDate="2015-09-12T00:33:29.503" LastActivityDate="2015-09-12T00:33:29.503" Title="Replacing atmega8 with atmega328 on Arduino Single-Sided Serial Board" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14780" PostTypeId="2" ParentId="14779" CreationDate="2015-09-03T04:16:57.903" Score="2" Body="&lt;p&gt;Yes and no. It will work on this board, but won't get programmed by arduino IDE directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATmega328 and ATmega8 are fully pin compatible. ATmega328 is like bigger and powerful in terms of onchip resources. However, if you want to program ATmega328 on the arduino board, you must install bootloader. Otherwise you will have to program it everytime using ISP programmers such as USBASP. This will connect to the ICSP socket shown on the above board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refer to: &lt;a href=&quot;http://tutorial.cytron.com.my/2011/09/30/how-to-program-arduino-by-using-avr-usbasp-programmer/&quot; rel=&quot;nofollow&quot;&gt;http://tutorial.cytron.com.my/2011/09/30/how-to-program-arduino-by-using-avr-usbasp-programmer/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12161" LastActivityDate="2015-09-03T04:16:57.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14781" PostTypeId="2" ParentId="279" CreationDate="2015-09-03T06:25:10.810" Score="2" Body="&lt;p&gt;I doubt that the USB interface on the Uno gives you a unique serial number. Any number would be part of the code uploaded to the chip which would therefore be the same amongst multiple Unos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach is the DS2401 &quot;Silicon Serial Number&quot; chip which uses the One-wire interface. That would only require one free pin, and some code (the code would be the problem, possibly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The least intrusive method, and probably the most reliable, would be to simply read back the code and sum-check it. That is exactly what I do with my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow&quot;&gt;chip signature detector&lt;/a&gt;. However that only detects (as currently written) the bootloader signature. A fairly minor change and it could MD5-sum the entire sketch code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Signature detector.&#xA;Written by Nick Gammon.&#xA;Signature = 1E  95  0F &#xA;Fuses&#xA;Low = FF High = D6 Ext = FF Lock = CF&#xA;&#xA;Processor = ATmega328P&#xA;Flash memory size = 32768&#xA;Bootloader in use: Yes&#xA;EEPROM preserved through erase: Yes&#xA;Watchdog timer always on: No&#xA;Bootloader is 512 bytes starting at 7E00&#xA;&#xA;Bootloader:&#xA;&#xA;7E00: 02 01 02 03 0405 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7E10: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7E20: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7E30: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;...&#xA;7FB0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7FC0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7FD0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7FE0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;7FF0: 02 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F &#xA;&#xA;MD5 sum of bootloader = 56 72 75 2D 5D B5 0D BA 25 10 DF BE 87 D2 A1 27 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That MD5 sum (last line) is effectively the signature of that particular bootloader. In fact the most recent version looks them up in a table:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MD5 sum of bootloader = FB F4 9B 7B 59 73 7F 65 E8 D0 F8 A5 08 12 E7 9F &#xA;Bootloader name: optiboot_atmega328&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So what you could do is, when uploading a sketch, generate a MD5 sum of the hex code. There are fairly simple ways of doing that. Then you could do a &quot;git tag&quot; operation on your source code, and then (using some automated or manual process) remember that a particular MD5 sum of hex code represents the sketch code at a particular moment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some sort of database like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Chip: Uno&#xA;MD5 sum: D8 8C 70 6D FE 1F DC 38 82 1E CE AE 23 B2 E6 E7 &#xA;Sketch: My_robot_sketch_42.ino&#xA;Git tag: version666&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to locate the source from the board, you establish the MD5 sum of the code (by reading it back from the board) and then look it up in your database.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-03T06:25:10.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14782" PostTypeId="1" CreationDate="2015-09-03T06:58:06.440" Score="0" ViewCount="5245" Body="&lt;p&gt;I have one PC running Visual Studio and a program that will be sending commands to Arduinos via serial COM Ports. So, in 11 Nano MCUs, I will have motor drivers L293D/L298N ICs, while in other Nanos I will have sensors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to do is have a program in Visual Studio which sends commands via serial to actuate motors to each and every MCU on board. This is a robotic application and everything I mentioned above will be enclosed within the Humanoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some examples of what I'm thinking of doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char data = Serial.read();&#xA;if (data == 'A') &#xA;{&#xA;  digitalWrite(13, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servodata = Serial.read();&#xA;if (servodata == '1') // Single Quote! This is a character.&#xA;{&#xA;  SERVO.write(pos); &#xA;}             &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, Arduinos will have something like this running and waiting for Visual Studio to send commands via serial to one or multiple MCUs simultaneously. I'm thinking 30 char dividing/spiting that number across each Rx Arduino.&lt;/p&gt;&#xA;" OwnerUserId="9881" LastEditorUserId="6936" LastEditDate="2016-02-01T06:21:11.233" LastActivityDate="2018-06-29T13:43:52.260" Title="I'm looking for a way to serially communicate with a multi mesh Arduino slave network" Tags="|serial|softwareserial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="14785" PostTypeId="2" ParentId="279" CreationDate="2015-09-03T07:20:07.327" Score="1" Body="&lt;p&gt;I connected a one wire temp sensor that each come with an unique I'd.  All the sketches read the I'd on boot and wrote the address on every serial connection. I made a shield with all the hardware I needed so if I needed to upgrade from Uno to Mega the device kept its unique I'd. &lt;/p&gt;&#xA;" OwnerUserId="709" LastActivityDate="2015-09-03T07:20:07.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14786" PostTypeId="2" ParentId="14782" CreationDate="2015-09-03T07:31:52.947" Score="6" Body="&lt;p&gt;It's not obvious what the exact query is but answering the subject line question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily multidrop connect multiple serial / RS232 COM ports by having all slave RX inputs and the master TX output on one line, and all slave TX outputs connected by an OR network to a single line to the master's RX input.   The master 'talks' to all slaves at once. Each slave talks to only the master. Only one slave can usefully talk at once. Message destination assignment and slave-talking arbitration is carried out in software. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As shown below, the OR network at each slave can be as simple as a diode with cathode (bar side) to TX line and anode to common line to master RX.  A single pullup resistor (or an internal pullup in the master on the RX line) pulls the line high when all slave TX lines are high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This diagram shows how simple multidrop communications can be.&lt;br&gt;&#xA;&lt;strong&gt;NB - As shown the diodes polarity is for true RS232 with logical 1 = low = negative.&lt;/strong&gt;&lt;br&gt;&#xA;&lt;strong&gt;When connecting directly between UART TTL lvel (5V/0V) outputs reverse the diodes.&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, add a pullup from +5V to the Blue RX line to the master - 10k to 5V is probably OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JkH5A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JkH5A.png&quot; alt=&quot;Multidrop network for RS232&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;From here - &lt;a href=&quot;http://cool-emerald.blogspot.co.nz/2009/10/multidrop-network-for-rs232.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;Multidrop network for RS232&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a slave TX pin is high its diode is &quot;blocked&quot; and it does not affect the common slave to master level. When any slave TX line goes low the common line is pulled low via its diode and the master sees the low. Normal RS232 COMs can occur between slave and master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the master sends all slaves see the transmission at once. A basic protocol must be established to allow messages to be handled by the intended recipient. This could consist of, e.g. sending an address word + command word or words. You can have a single slave act on a message or all slaves or a sunset, based on your addressing system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The slave to master direction allows only one slave to send at one and you must ensure either that only one slave ever sends at a time and/or that collisions are able to be resolved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite the obvious limitations of such a system it can work very well and is cheap and simple to implement. If there are many slaves the loadings should be checked so that e.g. the master TX is able to drive all slave RXs at once. As the circuit is unidirectional it is easy to add a basic buffer.&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="6936" LastEditDate="2015-09-14T20:34:43.657" LastActivityDate="2015-09-14T20:34:43.657" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="14788" PostTypeId="2" ParentId="14782" CreationDate="2015-09-03T09:24:50.417" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow&quot;&gt;RS-485&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/RS-422&quot; rel=&quot;nofollow&quot;&gt;RS-422&lt;/a&gt; are the normal industrial ways of having one serial port talk to many devices, especially in noisy environments with lots of motors.  It requires a driver chip for each device to get the right electrical interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS-485 provides bi-directional communication if you want to receive data back from your remote nodes, and RS-422 provides &quot;simplex&quot; or uni-directional communication if you just want to blindly send commands with no feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for software, my &lt;a href=&quot;http://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;nofollow&quot;&gt;ICSC library&lt;/a&gt; would probably be the easiest route to take - it allows you to address individual devices on an RS422 or RS485 bus and send commands to them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-03T09:24:50.417" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14789" PostTypeId="1" CreationDate="2015-09-03T15:03:28.437" Score="1" ViewCount="1031" Body="&lt;p&gt;I am using my Arduino UNO rev 3 to control other devices via the digital output pins. On startup or reset, I find that these pins are all briefly turned on (perhaps as part of a self test). This interferes with my application. How can I suppress this?&lt;/p&gt;&#xA;" OwnerUserId="12165" LastEditorUserId="10794" LastEditDate="2015-09-04T04:34:54.087" LastActivityDate="2015-09-04T04:34:54.087" Title="How can I stop my Arduino UNO rev 3 from briefly turning on digital output pins on startup or reset?" Tags="|arduino-uno|digital|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14790" PostTypeId="1" AcceptedAnswerId="14793" CreationDate="2015-09-03T16:24:04.787" Score="1" ViewCount="1879" Body="&lt;p&gt;Just a quick question. Picking up some stepper motors, but confused at what voltage/current things are running off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ordering:&lt;br&gt;&#xA;2 x &lt;a href=&quot;https://www.sparkfun.com/products/9238&quot; rel=&quot;nofollow&quot;&gt;Stepper Motor&lt;/a&gt;&lt;br&gt;&#xA;2 x &lt;a href=&quot;https://www.sparkfun.com/products/12779&quot; rel=&quot;nofollow&quot;&gt;EasyDriver&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An article says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You need some 12V source to the EasyDriver (the motor in this article&#xA;  is 12V) - This will be powering the stepper - Im using a 12V adapter -&#xA;  similar to the one in the illustration. Just make sure it is rated at&#xA;  least 750ma - A higher rating is better, and just means it wont burn&#xA;  out.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So does that mean if I got a plug which is regulated 12V 1A and powered the Arduino from that I could power a rail with VIN pin and that would safely supply the EasyDrivers? And I could then use the 5V pin to power everything else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just don't want to break anything! Thanks&lt;/p&gt;&#xA;" OwnerUserId="12166" LastActivityDate="2017-12-15T05:25:21.360" Title="Stepper Motor Power Supply" Tags="|power|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="14791" PostTypeId="1" AcceptedAnswerId="14802" CreationDate="2015-09-03T16:49:07.837" Score="1" ViewCount="2052" Body="&lt;p&gt;My attempt is to know how to identify the board I'll be sending parameters to in a serial connection like rs485.  I'm asking because I will have about 11 or so mcu's as &quot;Rx slaves&quot; while my pc is the Master &quot;Tx&quot;. I want to know how my code block is being sent to a specific board will be received by just that board and not all the other boards connected to that Rx port COM? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I send 'LT2|LP3|LM5|LR4|LI6' and I want that to be for one specific Arduino, I don't want all the other 10 arduinos to take those parameters in this serial Rx line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Federico Fissore you mentioned in another post &quot;Some boards, when connected to a computer, publish their serial number. My Arduino Uno R3 says&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[16818.451423] usb 3-2: SerialNumber: 85235353137351E02242&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;how and where can i find this info? &lt;/p&gt;&#xA;" OwnerUserId="9881" LastEditorUserId="490" LastEditDate="2015-09-04T13:15:27.773" LastActivityDate="2015-09-04T13:15:27.773" Title="How can I get a unique address for all my Arduino boards while in RS485?" Tags="|serial|rs485|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="14792" PostTypeId="2" ParentId="14791" CreationDate="2015-09-03T17:11:27.507" Score="1" Body="&lt;p&gt;Just assign every node a variable like &quot;const int ID = 5&quot; and so on and then before sending the instructions send a line terminator, the ID, line terminator and the data you need to send to the nodes. Every device listens but they all wait their ID to accept the commands. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write('\n');&#xA;Serial.print(ID);&#xA;Serial.write('\n');&#xA;Serial.print(|LT2|LP3|LM5|LR4|LI6);&#xA;Serial.write('\n');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE: This is the easiest way. Most likely not the most reliable or optimized.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2015-09-03T17:45:43.077" LastActivityDate="2015-09-03T17:45:43.077" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14793" PostTypeId="2" ParentId="14790" CreationDate="2015-09-03T17:41:44.273" Score="0" Body="&lt;p&gt;As generic rule: avoid powering one device through another.&#xA;It can cause strain on the middle-man device and it &lt;em&gt;will&lt;/em&gt; be inefficient.&#xA;The only few cases where this might make sense are when it's topologically inconvenient to connect everything to the centralized power supply.&#xA;Or if the cascaded device requires a voltage that is not available from the power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you can power both the easy driver and the Arduino from the regulated 12v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you won't risk drawing too much current through the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-03T17:41:44.273" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14794" PostTypeId="1" AcceptedAnswerId="14800" CreationDate="2015-09-03T18:27:00.797" Score="2" ViewCount="111" Body="&lt;p&gt;I am using both Arduino nano and Arduino mega boards in my projects.  I got a nasty surprise the other day when I learned that, on the nano, Analog pins 6 and 7 can not be used as digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any Analog pins on the mega that can not be used as Digital?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="10794" LastEditDate="2015-09-04T04:33:37.463" LastActivityDate="2015-09-04T04:33:37.463" Title="Are there any Analog pins on the mega that can not be used as Digital?" Tags="|arduino-mega|pins|analogread|digital-in|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14795" PostTypeId="2" ParentId="692" CreationDate="2015-09-03T20:29:18.347" Score="0" Body="&lt;p&gt;Same here. I can add that if interruptions are turned off, the time measured is &quot;real time&quot;. Anyway, I dont understand why this delay, because if the loop take too long, anyway the millis() should return real time values (only with more distance between each value) &lt;/p&gt;&#xA;" OwnerUserId="12169" LastActivityDate="2015-09-03T20:29:18.347" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="14796" PostTypeId="2" ParentId="14790" CreationDate="2015-09-03T20:50:00.587" Score="0" Body="&lt;p&gt;The V&lt;sub&gt;in&lt;/sub&gt; pin is after the M7 protection diode, so you won't get quite 12 V out of V&lt;sub&gt;in&lt;/sub&gt;. Also, depending on the load, the diode might get warm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also found that powering an Arduino from 12 V input (the maximum recommended) tends to get the voltage regulator hot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your other issue is that the motor power will be going through the Arduino board, to an extent (in the plug, through the diode, and out V&lt;sub&gt;in&lt;/sub&gt;) so any noise generated by the motor will be close to the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think your idea would &lt;em&gt;break&lt;/em&gt; anything, it just might not be particularly reliable.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-03T20:50:00.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14797" PostTypeId="2" ParentId="14789" CreationDate="2015-09-03T20:56:56.767" Score="1" Body="&lt;p&gt;Digital pin 13 will be turned on briefly as part of the bootloading process (it flashes a few times). Thus this is not a good choice of pin for a device like a motor to be connected to. Also if you are uploading a new sketch the Tx pin (digital pin 1) will be turned on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the processor fuses to not use the bootloader, which would avoid these issues, however then you have to change them back to upload a new sketch - unless you upload using ICSP instead of the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Gerben and Majenko have pointed out, any other issues could be from &quot;floating&quot; pins which some devices might interpret as having a HIGH on them, possibly. Pull-down resistors could help there (or pull-up if that is more appropriate).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal thing could be to structure your system in such a way that the two pins (1 and 13) which come on during the bootloading process are connected to something &quot;harmless&quot; (eg. an LED) rather than &quot;harmful&quot; (eg. a motor).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-03T20:56:56.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14798" PostTypeId="1" CreationDate="2015-09-03T21:27:46.650" Score="3" ViewCount="1847" Body="&lt;p&gt;I am new to the Leonardo, having only used a duemilanove before, and I am interested in using it's USB capabilities for a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I need it to be an input and output device, communicating to an app on the PC (probably written in C#). I need to be able to handle button presses on the arduino and get data back from the PC to display on a display connected to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have the basics done hardware wise (getting the keypad and displays working as I want them to), but now the tricky part is the USB communication. The only things I can find seem aimed at emulating a keyboard and mouse - I need 2 way communication data wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any examples of something like this? I am sort of looking for the arduino equivalent of this: &lt;a href=&quot;http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device&quot; rel=&quot;nofollow&quot;&gt;http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to just use serial, but I don't want to be fiddling with COM ports on the PC side - it just needs to be plugged in and work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would be grateful for any input on this subject, if it is even possible!&lt;/p&gt;&#xA;" OwnerUserId="12170" LastActivityDate="2015-09-03T21:27:46.650" Title="Using USB on a Leonardo to receive data from PC" Tags="|arduino-leonardo|usb|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="14799" PostTypeId="2" ParentId="14794" CreationDate="2015-09-03T21:35:55.647" Score="2" Body="&lt;p&gt;On &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardNano&lt;/a&gt; it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Analog pins 6 and 7 cannot be used as digital pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no such corresponding statement on &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&lt;/a&gt; and judging by the datasheet all of the analog pins can be used as digital pins.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-03T21:35:55.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14800" PostTypeId="2" ParentId="14794" CreationDate="2015-09-03T21:38:19.427" Score="3" Body="&lt;p&gt;No, the ATmegaXXX0 has no analog pins without GPIO capability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, the ATmegaXX8P&lt;strong&gt;B&lt;/strong&gt; &lt;em&gt;adds&lt;/em&gt; GPIO capability to the other analog pins plus a couple of the supply pins, so if you can convince someone to slip one of those on instead then you will gain two GPIOs (a respin will be required to access the ones on supply pins). Note that the core will also need to be modified, but it's only a couple of quick changes.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-09-03T21:44:13.593" LastActivityDate="2015-09-03T21:44:13.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14801" PostTypeId="2" ParentId="286" CreationDate="2015-09-03T21:57:26.207" Score="3" Body="&lt;p&gt;From a previous incantation of this forum, the following question/answer was moved to Electrical Engineering.  It has sample arduino code to blink an LED using a timer interrupt while using the main loop to do serial IO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/67089/how-can-i-control-things-without-using-delay/67091#67091&quot;&gt;https://electronics.stackexchange.com/questions/67089/how-can-i-control-things-without-using-delay/67091#67091&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repost:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are a common way to get things done while something else is going on.  In the example below, the LED is blinking without using &lt;code&gt;delay()&lt;/code&gt;.  Whenever &lt;code&gt;Timer1&lt;/code&gt; fires, the interrupt service routine (ISR) &lt;code&gt;isrBlinker()&lt;/code&gt; is called.  It switches the LED on/off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To show that other things can simultaneously happen, &lt;code&gt;loop()&lt;/code&gt; repeatedly writes foo/bar to the serial port independent of the LED blinking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;&#xA;int led = 13;&#xA;&#xA;void isrBlinker()&#xA;{&#xA;  static bool on = false;&#xA;  digitalWrite( led, on ? HIGH : LOW );&#xA;  on = !on;&#xA;}&#xA;&#xA;void setup() {                &#xA;  Serial.begin(9600);&#xA;  Serial.flush();&#xA;  Serial.println(&quot;Serial initialized&quot;);&#xA;&#xA;  pinMode(led, OUTPUT);&#xA;&#xA;  // initialize the ISR blinker&#xA;  Timer1.initialize(1000000);&#xA;  Timer1.attachInterrupt( isrBlinker );&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;foo&quot;);&#xA;  delay(1000);&#xA;  Serial.println(&quot;bar&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a very simple demo.  ISRs can be much more complex and can be triggered by timers and external events (pins).  Many of the common libraries are implemented using ISRs.&lt;/p&gt;&#xA;" OwnerUserId="842" LastActivityDate="2015-09-03T21:57:26.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14802" PostTypeId="2" ParentId="14791" CreationDate="2015-09-04T00:32:12.467" Score="1" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I dont think that could have sounded more advanced for me then anything thus far. Any links on how to go about that? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, run a sketch like this for each board:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;const int SERIAL_NUMBER_ADDRESS = 1023;&#xA;const byte SERIAL_NUMBER = 42;&#xA;void setup ()&#xA;  {&#xA;  // don't do it if it has been done before&#xA;  if (EEPROM.read(SERIAL_NUMBER_ADDRESS) != SERIAL_NUMBER)&#xA;    EEPROM.write(SERIAL_NUMBER_ADDRESS, SERIAL_NUMBER);&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial number &lt;strong&gt;address&lt;/strong&gt; can be any address in range for that chip - a Uno has 1024 bytes. I chose 1023 to leave the other addresses free, but it could be 0. Anything you don't need for any other purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then write a different serial number to each board (eg. 42, 43, 44, 45). Obviously you change the sketch each time you upload to a different board.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Once you have done this (once per board) now each board &quot;knows&quot; its serial number. You can detect this in your main sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;const int SERIAL_NUMBER_ADDRESS = 1023;&#xA;byte serialNumber;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  serialNumber = EEPROM.read(SERIAL_NUMBER_ADDRESS);&#xA;  Serial.print (F(&quot;Serial number of this board is: &quot;));&#xA;  Serial.println (int (serialNumber));&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Output for me in this case was:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Serial number of this board is: 42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also I have a post about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;RS485&lt;/a&gt; on my forum.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-04T00:32:12.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="14803" PostTypeId="1" AcceptedAnswerId="15803" CreationDate="2015-09-04T00:43:17.163" Score="0" ViewCount="152" Body="&#xA;&#xA;&lt;p&gt;I'm trying to obtain the sensors' readings as well as making the LED strips to light up at this particular pattern, if the sensor readings reaches certain values. But since both of these codes are inside the void &lt;code&gt;loop()&lt;/code&gt;, there will be a problem. How can I do this correctly?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{    &#xA;    currentSensorReading = analogRead(sensorPin);&#xA;    Serial.println(currentSensorReading );&#xA;&#xA;    if(currentSensorReading is in range of certain values){&#xA;        rainbowCycle(20);&#xA;    } else { turn LEDs off }&#xA;}&#xA;&#xA;void rainbowCycle(uint8_t wait) {&#xA;  uint16_t i, j;&#xA;&#xA;  for(j=0; j&amp;lt;256*5; j++) { // 5 cycles of all colors on wheel&#xA;    for(i=0; i&amp;lt; strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) &amp;amp; 255));&#xA;    }&#xA;    strip.show();&#xA;    delay(wait);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12172" LastEditorUserId="6936" LastEditDate="2015-09-17T11:29:03.030" LastActivityDate="2015-09-17T11:29:03.030" Title="Running both sensor and addressable LED strips at a same time?" Tags="|arduino-uno|sensors|led|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15802" PostTypeId="2" ParentId="1083" CreationDate="2015-09-04T01:39:57.187" Score="1" Body="&lt;p&gt;My testing indicates that the slave &lt;strong&gt;is&lt;/strong&gt; responding. I made up a master from &lt;a href=&quot;http://playground.arduino.cc/Code/ModbusMaster&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Code/ModbusMaster&lt;/a&gt; and tested it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fKKFq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fKKFq.png&quot; alt=&quot;Modbus response&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Channel 0 is master to slave.&lt;/li&gt;&#xA;&lt;li&gt;Channel 1 is slave to master.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Zooming in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mEgz6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mEgz6.png&quot; alt=&quot;Modbus response 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-04T01:39:57.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15803" PostTypeId="2" ParentId="14803" CreationDate="2015-09-04T01:52:27.040" Score="0" Body="&#xA;&#xA;&lt;p&gt;Rewrite without using &lt;code&gt;delay()&lt;/code&gt;. Or alternatively, do the test inside the &lt;code&gt;for&lt;/code&gt; loop as well, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void rainbowCycle(uint8_t wait) {&#xA;  uint16_t i, j;&#xA;&#xA;  for(j=0; j&amp;lt;256*5; j++) { // 5 cycles of all colors on wheel&#xA;    for(i=0; i&amp;lt; strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) &amp;amp; 255));&#xA;    }&#xA;    strip.show();&#xA;    delay(wait);&#xA;&#xA;    // ----------- ADD THESE THREE LINES ---------------&#xA;    currentSensorReading = analogRead(sensorPin);&#xA;    if(currentSensorReading is NOT in range of certain values)&#xA;        return;&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-04T01:52:27.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15804" PostTypeId="5" CreationDate="2015-09-04T02:03:30.637" Score="0" Body="&lt;p&gt;A multiplexer uses back-to-back MOSFETs to choose a signal from a group of signals. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Multiplexing input&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For example, for inputting to an analog pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SHzPR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SHzPR.png&quot; alt=&quot;Multiplexer input&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The A/B/C pins tell the multiplexer which signal to forward (in this case, signal 2). Any voltage present then appears on the O/I pin (output/input) which can be connected to an analog input pin on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Multiplexing output&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cnj76.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cnj76.png&quot; alt=&quot;Multiplexer output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The A/B/C pins tell the multiplexer which signal to forward the output to (in this case, signal 7). Data written to the O/I pin (output/input) is then sent to the selected pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strictly speaking, this operation is called &lt;strong&gt;demultiplexing&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;How do you switch directions?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The multiplexing is bidirectional. What the driver MOSFETs really do is present a low resistance for the selected signal line (around 80 Ω) and a very high resistance for the other lines. Thus the bulk of the current (input or output) goes to or from the selected signal line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Reference&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Multiplexer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Multiplexer - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T02:03:30.637" LastActivityDate="2015-09-04T02:03:30.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15805" PostTypeId="4" CreationDate="2015-09-04T02:03:30.637" Score="0" Body="A multiplexer lets you select one signal out of a group of (typically) 8 or 16, for both input and output purposes. Use this tag for discussing multiplexer chips." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T02:03:30.637" LastActivityDate="2015-09-04T02:03:30.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15806" PostTypeId="5" CreationDate="2015-09-04T02:42:29.923" Score="0" Body="&#xA;&#xA;&lt;p&gt;The Arduino libraries simplify accessing the processor hardware by providing high-level functions, such as &lt;code&gt;pinMode&lt;/code&gt;, &lt;code&gt;digitalRead&lt;/code&gt; and &lt;code&gt;digitalWrite&lt;/code&gt; (amongst others).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whilst they are easy to use, the simplicity generally has an overhead of loss of speed. Programmers who wish to access the hardware quickly will do &quot;direct port access&quot;. For example (for the Atmega328P, such as used on the Arduino Uno):&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;pinMode&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;pinMode (3, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;DDRD |= bit (3);  // Port D, bit 3 to output mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;pinMode (13, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;DDRB &amp;amp;= ~bit (5);  // Port B, bit 5 to input mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;pinMode (8, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;DDRB &amp;amp;= ~bit (0);  // Port B, bit 0 to input mode&#xA;PORTB |= bit (0);  // Make Port B, bit 0 HIGH, to turn on pull-up resistor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;digitalWrite&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (7, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PORTD |= bit (7);  // Make port D, bit 7, HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (6, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PORTD &amp;amp;= ~bit (6);  // Make port D, bit 6, LOW&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;digitalRead&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte foo = digitalRead (5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte foo = (PIND &amp;amp; bit (5)) ? HIGH : LOW;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Warning&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The port letters (eg. PINB, PINC, PIND) and the bit numbers (eg. bit(1), bit(2) etc.) are specific to each processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For ease of use, the library functions save working out exactly which port and bit numbers to use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Timing&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;pinMode (2, OUTPUT);&lt;/code&gt; : 4.5625 µs  (73 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;DDRD |= bit (3);&lt;/code&gt; : 250 ns (4 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;pinMode (13, INPUT);&lt;/code&gt; : 4.9375 µs  (79 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;DDRD &amp;amp;= ~bit (5);&lt;/code&gt; : 250 ns (4 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;pinMode (8, INPUT_PULLUP);&lt;/code&gt; : 5 µs (80 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;DDRB &amp;amp;= ~bit (0); PORTB |= bit (0);&lt;/code&gt; : 375 ns (6 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;digitalWrite (7, HIGH);&lt;/code&gt; : 3.9375 µs (63 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PINB |= bit (4);&lt;/code&gt; : 250 ns (4 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;digitalWrite (6, LOW);&lt;/code&gt; : 4.875 µs (78 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;PINB &amp;amp;= ~bit (6);&lt;/code&gt; : 250 ns (4 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;digitalRead (5);&lt;/code&gt; : 4.625 µs (74 clock cycles)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;(PIND &amp;amp; bit (5)) ? HIGH : LOW;&lt;/code&gt; : 125 ns (2 clock cycles)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;digitalWriteFast library&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can have the convenience of easy-to-use function calls and the speed of port mapping by using the digitalWriteFast library. Providing your pin numbers are &lt;strong&gt;constants&lt;/strong&gt; (that is, not &lt;strong&gt;variables&lt;/strong&gt; which might change at run-time) digitalWriteFast will automatically substitute the appropriate port-mapped I/O where appropriate. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;digitalWriteFast.h&amp;gt;&#xA;&#xA;void foo ()&#xA;  {&#xA;  digitalWriteFast (7, HIGH);&#xA;  byte bar = digitalReadFast (3);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, &lt;code&gt;digitalWriteFast&lt;/code&gt; and &lt;code&gt;digitalReadFast&lt;/code&gt; are as fast as the port-mapped access.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/watterott/Arduino-Libs/tree/master/digitalWriteFast&quot; rel=&quot;nofollow&quot;&gt;digitalWriteFast on GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://code.google.com/archive/p/digitalwritefast/&quot; rel=&quot;nofollow&quot;&gt;digitalWriteFast on Google Code&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T04:30:49.670" LastActivityDate="2015-09-04T04:30:49.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15807" PostTypeId="4" CreationDate="2015-09-04T02:42:29.923" Score="0" Body="Port-mapping refers to directly accessing the hardware registers (ports), in particular the input/output ports. Use this tag for discussing direct port access." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T02:42:29.923" LastActivityDate="2015-09-04T02:42:29.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15808" PostTypeId="5" CreationDate="2015-09-04T03:30:35.863" Score="0" Body="&#xA;&#xA;&lt;h2&gt;Timing with millis/micros&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can, generally-speaking, time code execution by calling &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; before and after some event of interest. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long startTime = millis();  // note start time&#xA;someLengthyThing();                  // do the thing we want to time&#xA;unsigned long endTime = millis();    // note end time&#xA;unsigned long elapedTime = endTime - startTime;  // calculate elapsed time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more precise measurements use &lt;code&gt;micros()&lt;/code&gt; (returns elapsed time in microseconds) rather than &lt;code&gt;millis()&lt;/code&gt; (returns elapsed time in milliseconds).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Timing with digitalWrite&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If calling millis/micros is not practical (you may have no way of seeing what the results are) you can also time by turning on and off a digital pin. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (13, HIGH);  // we are about to time something - turn D13 on&#xA;someLengthyThing();       // do the thing we want to time&#xA;digitalWrite (13, LOW);   // we are done - turn D13 off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can put an oscilloscope or logic analyser on pin 13 (or whatever pin you choose, which naturally should be set to &lt;code&gt;OUTPUT&lt;/code&gt; mode) and then see how long the signal is high for.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Timing with writing to a port&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, digitalWrite itself takes about 4 µs to execute, so for more accurate timing, do direct port access. For example on the Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;PORTB = bit (5);     // we are about to time something - turn D13 on&#xA;someLengthyThing();  // do the thing we want to time&#xA;PORTB &amp;amp;= ~bit (5);   // we are done - turn D13 off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These port accesses only take 250 ns which is a much lower overhead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;/questions/tagged/timers&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;timers&amp;#39;&quot; rel=&quot;tag&quot;&gt;timers&lt;/a&gt; &lt;a href=&quot;/questions/tagged/port-mapping&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;port-mapping&amp;#39;&quot; rel=&quot;tag&quot;&gt;port-mapping&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T03:30:35.863" LastActivityDate="2015-09-04T03:30:35.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15809" PostTypeId="4" CreationDate="2015-09-04T03:30:35.863" Score="0" Body="This tag is for questions about timing code execution, or external events." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-04T03:30:35.863" LastActivityDate="2015-09-04T03:30:35.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15810" PostTypeId="2" ParentId="12735" CreationDate="2015-09-04T03:52:17.893" Score="1" Body="&lt;p&gt;Yes, I did a project yesterday to play recorded voice.&#xA;You don't need a speaker module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just connect the speaker via a resistor to one of Arduino PWM output. Then Connect a micro-sd card module. Format your micro-sd card with FAT32 Option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Sample wave converter to convert your sound files and select the options as 16,000Hz Mono 8Bit. You are all done. Use &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki&quot; rel=&quot;nofollow&quot;&gt;tmrpcm&lt;/a&gt; library. It's all easy. &lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="21257" LastEditDate="2016-05-21T13:28:36.287" LastActivityDate="2016-05-21T13:28:36.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15811" PostTypeId="2" ParentId="14652" CreationDate="2015-09-04T03:54:37.173" Score="0" Body="&lt;p&gt;I got my MicroSD Module today. The labels were printed At the bottom side. Dont confuse, CLK = SCK. The VCC goes to arduino 5v.&lt;/p&gt;&#xA;" OwnerUserId="11772" LastActivityDate="2015-09-04T03:54:37.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15812" PostTypeId="2" ParentId="286" CreationDate="2015-09-04T09:22:55.753" Score="5" Body="&lt;p&gt;I also came to this topic while implementing a matrix LED display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In one word, you may build a polling scheduler by using millis() function and timer interrupt in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest the following articles from Bill Earl:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-1/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/multi-tasking-the-arduino-part-1/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-2/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/multi-tasking-the-arduino-part-2/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-3/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/multi-tasking-the-arduino-part-3/overview&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13176" LastEditorUserId="13176" LastEditDate="2015-09-14T09:42:39.767" LastActivityDate="2015-09-14T09:42:39.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15814" PostTypeId="1" AcceptedAnswerId="15909" CreationDate="2015-09-04T12:30:33.713" Score="0" ViewCount="318" Body="&lt;p&gt;Recently I've started playing around with an Arduino Uno (rev 3), and I've set up a communication bridge between the Arduino and my computer using Python. So I send a command in Python (&quot;ping&quot; for instance), which is then read and interpreted. I've had it working before, using the Python commands to control a motor, but today it became non-responsive. However, only if I boot the serial monitor from the Arduino IDE, it suddenly accepts my commands again. Further inspection reveals that the Arduino is probably reading empty or corrupted data, interpreting it as &lt;code&gt;ð&lt;/code&gt;, &lt;code&gt;à&lt;/code&gt; and &lt;code&gt;ÿ&lt;/code&gt; and such.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an excerpt of the Python code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import sys, glob, serial, time, re&#xA;&#xA;class interface:&#xA;&#xA;     timeout = 2    # 10 second time-out&#xA;&#xA;    def __init__(self):&#xA;        port = &quot;/dev/ttyACM0&quot;&#xA;        self.connect(port)&#xA;        pass&#xA;&#xA;    def connect(self, port=&quot;/dev/ttyACM0&quot;):&#xA;        global arduino&#xA;        arduino = serial.Serial(port, baudrate=115200, bytesize=8, parity=serial.PARITY_NONE, stopbits=1, timeout=0.1)  # Establishing connection&#xA;        time.sleep(3) # Allowing the connection to settle&#xA;        arduino.flush()&#xA;        print &quot;Connection established...&quot;&#xA;&#xA;    def ping(self):&#xA;        arduino.flush()&#xA;        arduino.write(&quot;ping&quot;)&#xA;        msg = self.listen_arduino()&#xA;        print msg&#xA;        if msg == &quot;ping_ok&quot;:&#xA;            print &quot;pinged&quot;&#xA;            return True&#xA;        return False&#xA;&#xA;    def listen_arduino(self):&#xA;        timeout = self.timeout&#xA;        matcher = re.compile(&quot;\n&quot;)&#xA;        buff = &quot;&quot;&#xA;        t0 = time.time()&#xA;        buff += arduino.read(128)&#xA;&#xA;        while (time.time() - t0) &amp;lt; timeout and (not matcher.search(buff)):&#xA;            buff += arduino.read(128)&#xA;        return buff.strip()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the Arduino C code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String readString;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200); // use the same baud-rate as the python side&#xA;}&#xA;&#xA;void loop() {&#xA;    readString = listen(); // listen for any commands&#xA;    if (readString.length() &amp;gt; 0) {&#xA;&#xA;        Serial.println(readString); // print the command&#xA;&#xA;        if(readString == &quot;ping&quot;) {&#xA;          Serial.write(&quot;ping_ok&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;String listen() {&#xA;    String readString;&#xA;    while (!Serial.available());&#xA;    while (Serial.available()) {&#xA;        delay(1); // Allow the buffer to fill&#xA;        if (Serial.available() &amp;gt; 0) {&#xA;            char c = Serial.read();&#xA;            readString += c;&#xA;        }&#xA;    }&#xA;    return readString;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect there is something fishy with the connection I'm making on the Python side, as the Arduino IDE serial monitor works just fine. I hope anyone can spot the problem in this code, I'm willing to provide more details on request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2015-09-08T05:48:27.913" Title="Arduino reads bogus from serial" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15815" PostTypeId="1" AcceptedAnswerId="15816" CreationDate="2015-09-04T12:30:59.900" Score="0" ViewCount="1307" Body="&lt;p&gt;is there another way to replace &lt;strong&gt;delayMicroseconds(BassTab[note_index])&lt;/strong&gt; as I cannot have delays in my loop due to the need of having multi-tasking in my sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Grove speaker: &lt;a href=&quot;http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*macro definition of Speaker pin*/&#xA;#define SPEAKER 8&#xA;&#xA;int BassTab[]={1911,1702,1516,1431,1275,1136,1012};//bass 1~7&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(SPEAKER,OUTPUT);&#xA;  digitalWrite(SPEAKER,LOW);&#xA;}&#xA;void loop()&#xA;{&#xA;    sound(5);&#xA;    delay(5000); //Wait 5second and play the sound again&#xA;}&#xA;&#xA;void sound(uint8_t note_index)&#xA;{&#xA;  for(int i=0;i&amp;lt;100;i++)   &#xA;  {&#xA;    digitalWrite(SPEAKER,HIGH);&#xA;    delayMicroseconds(BassTab[note_index]);&#xA;    digitalWrite(SPEAKER,LOW);&#xA;    delayMicroseconds(BassTab[note_index]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12172" LastActivityDate="2015-09-04T12:44:57.443" Title="How to use a grove speaker without using delayMicroseconds?" Tags="|arduino-uno|programming|frequency|sound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15816" PostTypeId="2" ParentId="15815" CreationDate="2015-09-04T12:44:57.443" Score="1" Body="&lt;p&gt;It's just a small amplifier and speaker - what you put into the SIG pin gets amplified and sent out the speaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of doing the audio generation manually like that I would suggest using the &lt;code&gt;tone()&lt;/code&gt; function which will generate an audio tone at a desired frequency in the background.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Tone&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-04T12:44:57.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15817" PostTypeId="1" AcceptedAnswerId="15830" CreationDate="2015-09-04T13:58:13.777" Score="-6" ViewCount="23312" Body="&lt;p&gt;I am very much new to Arduino. I recently bought an adruino uno. i can blink an LED alternately. Such as, 1st blink red, then blink green, then blue like that. once only one LED should blink. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have provided the code blinking an LED. How to modify this to blink multiple LED one after another.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(13, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(13, LOW);&#xA;  delay(1000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13181" LastEditorUserId="10794" LastEditDate="2015-09-04T21:29:54.263" LastActivityDate="2017-07-16T14:54:59.067" Title="How to blink a series of LED alternately only one at a time" Tags="|arduino-uno|programming|led|c++|digital|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15818" PostTypeId="1" AcceptedAnswerId="15819" CreationDate="2015-09-04T14:13:17.283" Score="0" ViewCount="120" Body="&lt;ul&gt;&#xA;&lt;li&gt;Grove speaker:&#xA;&lt;a href=&quot;http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;ws2812-led strip&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hi, I have been working to produce tones on a speaker and it works with the following code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3, NOTE_B3, NOTE_C4};&#xA;    ...&#xA;    ...&#xA;    tone(pin, melody[pitch]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After I included my addressable LED strip sketch codes, the speaker does not produce the same tone as normally it does. It sounded distorted this time round.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  strip.Update(); //NeoPatterns strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800, &amp;amp;StripComplete);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// NeoPattern Class - derived from the Adafruit_NeoPixel class&#xA;class NeoPatterns : public Adafruit_NeoPixel&#xA;{&#xA;  public:&#xA;&#xA;// Member Variables:&#xA;    ...&#xA;    ...&#xA;&#xA;void (*OnComplete)();  // Callback on completion of pattern&#xA;&#xA;// Constructor - calls base-class constructor to initialize strip&#xA;NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)())&#xA;  : Adafruit_NeoPixel(pixels, pin, type)&#xA;{&#xA;  OnComplete = callback;&#xA;}&#xA;&#xA;// Update the pattern&#xA;void Update()&#xA;{&#xA;  if ((millis() - lastUpdate) &amp;gt; Interval) // time to update&#xA;  {&#xA;    lastUpdate = millis();&#xA;    switch (ActivePattern)&#xA;    {&#xA;      case RAINBOW_CYCLE:&#xA;        RainbowCycleUpdate();&#xA;        break;&#xA;      default:&#xA;        break;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;// Initialize for a RainbowCycle&#xA;void RainbowCycle(uint8_t interval, direction dir = FORWARD)&#xA;{&#xA;  ActivePattern = RAINBOW_CYCLE;&#xA;  Interval = interval;&#xA;  TotalSteps = 255;&#xA;  Index = 0;&#xA;  Direction = dir;&#xA;}&#xA;&#xA;// Update the Rainbow Cycle Pattern&#xA;    void RainbowCycleUpdate()&#xA;    {&#xA;      for (int i = 0; i &amp;lt; numPixels(); i++)&#xA;      {&#xA;        setPixelColor(i, Wheel(((i * 256 / numPixels()) + Index) &amp;amp; 255));&#xA;      }&#xA;      show(); // When I comment this line, the speaker will work properly. What is happening?&#xA;      Increment();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12172" LastActivityDate="2015-09-04T14:23:39.767" Title="Speaker not producing the right sound after a led strip was introduced" Tags="|arduino-uno|led|sound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15819" PostTypeId="2" ParentId="15818" CreationDate="2015-09-04T14:23:39.767" Score="0" Body="&lt;p&gt;The &lt;code&gt;tone()&lt;/code&gt; command is interrupt driven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the tight timing needed by the LED strips interrupts are disabled while sending the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means the tone() command stops while you're updating the LED strips and starts again afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end result will be the sound is corrupted - maybe sounding like it's bubbly or underwater or just &quot;rough&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two basically can't work together and I'm not sure what to suggest to make them work together on a low-end MCU like the AVR.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-04T14:23:39.767" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15820" PostTypeId="1" CreationDate="2015-09-04T16:30:56.537" Score="0" ViewCount="3205" Body="&lt;p&gt;Four our project, I want to send data mesured by an Arduino due to a computer via Pyton very vast. So I tried to make a simple benchmark by sending 10240 int datas to determine the time it take. In order to do this, I first try using the programming port and execute this simple script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i=1;&#xA;int maxv=10240;&#xA;int value[10240];&#xA;int deb, fin;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(250000); //serial initialisation&#xA;  for (i=0 ; i&amp;lt;maxv ; i++){&#xA;    value[i]=i;&#xA;  }&#xA;  delay(200);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  Serial.println(&quot;starti&quot;); //flag&#xA;  deb=micros();&#xA;  for (i=0 ; i&amp;lt;maxv ; i++) { // sending loop&#xA;      Serial.println(value[i]);&#xA;  }&#xA;  fin=micros();&#xA;  Serial.println(&quot;stopi&quot;);&#xA;  Serial.println((fin-deb)/1000000.0);&#xA;  delay(2000); //waiting  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So with this I can mesure the time it take to send all the datas. And I receive it with this Python's script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import serial&#xA;ser = serial.Serial('/dev/ttyACM0', 250000)&#xA;&#xA;value=np.empty(10240)&#xA;&#xA;temp=ser.readline()&#xA;&#xA;while temp!='starti\r\n': #search for the flag&#xA;    temp=ser.readline()&#xA;&#xA;for j in range(10240):&#xA;    value[j]=int(ser.readline())&#xA;&#xA;ser.readline()&#xA;&#xA;time=float(ser.readline())&#xA;print time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with this beaudrate, it take nearly 2.4s which too slow for my purpose. If  try another baudrate, 500000 for example I read data like this : &lt;code&gt;�Ë&lt;/code&gt;$Pd@s`¥š... I have this for all baudrate higher than 250000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried the native port which normaly send the data as fast as he can, but we this it took nearly 1.3s, and it's again too slow for my purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked that it is not python wich is too slow, by doing the same than in the last example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import time&#xA;import numpy as np&#xA;&#xA;value=np.empty(10240)&#xA;&#xA;deb1 = time.clock()&#xA;&#xA;for j in range(10240):&#xA;    value[j]=j&#xA;&#xA;fin1= time.clock()&#xA;print fin1-deb1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it took only 4ms. So is it clearly the arduino wich send the data to slowly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I increase the data flux? I have seen the serial.write(buf,len) function which seems does not convert the data into ascii caracters. Does this function will be faster by putting the correct arguments? And, if it's the cas, how can I read this with Python?&lt;/p&gt;&#xA;" OwnerUserId="12110" LastActivityDate="2015-11-03T20:49:09.387" Title="arduino due-Python interfacing for high speed data rate" Tags="|serial|arduino-due|usb|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15822" PostTypeId="2" ParentId="8511" CreationDate="2015-09-04T17:29:56.543" Score="0" Body="&lt;p&gt;On my board, the voltage regulator is marked F34V.  On the back is listed &quot;The Simple&quot; and Arduino-Pro-Mini&quot;  I purchased it as a 3.3 v board off e-Bay, and I assume it is.  I have not yet applied vcc to it and measured the output.  &lt;/p&gt;&#xA;" OwnerUserId="13185" LastActivityDate="2015-09-04T17:29:56.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15824" PostTypeId="2" ParentId="15820" CreationDate="2015-09-04T18:14:27.327" Score="1" Body="&lt;p&gt;There's two things you need to know:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Serial.write(buf, len) function sends the raw data - one byte for every &quot;len&quot; count.&lt;/li&gt;&#xA;&lt;li&gt;On the Due integers are 32-bits, so each one takes 4 bytes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So first you need to define how big the numbers are you'll be dealing with and use data types that are big enough without being wasteful - you have 3 choices: char, short and int - 8, 16 and 32 bits respectively.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Values between 0 and 255 use an unsigned char (uint8_t)&lt;/li&gt;&#xA;&lt;li&gt;Values between -128 and 127 use a signed char (int8_t)&lt;/li&gt;&#xA;&lt;li&gt;Values between 0 and 65535 use an unsigned short (uint16_t)&lt;/li&gt;&#xA;&lt;li&gt;Values between -32768 and 32767 use a signed short (int16_t)&lt;/li&gt;&#xA;&lt;li&gt;Values between 0 and 4,294,967,295 use an unsigned int (uint32_t)&lt;/li&gt;&#xA;&lt;li&gt;Values between −2,147,483,648 and 2,147,483,647 a signed int (int32_t)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One very tricky thing with this kind of &lt;em&gt;binary&lt;/em&gt; data transfer is knowing where a value starts and ends.  You don't get that kind of issue with ASCII representations as you have a line feed and/or a carriage return after each full value and the range of valid characters that make up a value is very narrow and can never contain the delimiting character.  You don't have that luxury with binary transfers as there is no byte value that can't appear in a data stream.  However, there could be byte sequences that could never appear in the data stream - numbers you know you'll never be using that could form part of a synchronizing header (say, in hexadecimal, 0xFF 0xFF 0xFF 0xFF 0x00 0x00 0x00 0x00 - or in signed shorts that would be a sequence of 65535 65535 0 0) - once you see that sequence of bytes you know you're lined up with your data stream and can receive it byte by byte and build up the right sized values from that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can estimate your transfer time by working with the baud rate and knowing the data size.  For instance, to transfer 1000 short (16 bit) values at 250000 baud should take around:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1000 * 2 = 2000 bytes&lt;/li&gt;&#xA;&lt;li&gt;250000 baud = 25000 bytes per second (8 bits for the byte, 2 bits for the start and stop bit)&lt;/li&gt;&#xA;&lt;li&gt;2000 / 25000 = 0.08s&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-04T18:14:27.327" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15825" PostTypeId="2" ParentId="15817" CreationDate="2015-09-04T18:19:23.250" Score="0" Body="&lt;p&gt;Have you considered connecting another LED and turning one on and the other off sequentially?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;  pinmode(NewLEDPin, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(NewLEDPin,LOW);&#xA;  digitalWrite(13, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(NewLEDPin,HIGH);&#xA;  digitalWrite(13, LOW);&#xA;  delay(1000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13188" LastActivityDate="2015-09-04T18:19:23.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15827" PostTypeId="1" CreationDate="2015-09-04T19:26:33.997" Score="2" ViewCount="2964" Body="&lt;p&gt;I am quite new to the Arduino stuff. I have got the Arduino IDE installed side by side with Eclipse. I am using Eclipse with the Arduino plugin, which is working well for me, including the SerialMonitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using Eclipse with the Arduino plugin, it'll also add two new views. One is the serial monitor, the other one is called scope. Scope is a 6 channel Oscilloscope. But I don't know how to get values displayed there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am just curious how to use the scope there. I can't find any tutorial for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody explain how to show something inside the scope?&lt;/p&gt;&#xA;" OwnerUserId="11938" LastEditorUserId="19409" LastEditDate="2016-12-19T09:51:24.217" LastActivityDate="2016-12-28T18:24:41.363" Title="How to use the eclipse arduino scope?" Tags="|arduino-uno|eclipse|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15828" PostTypeId="1" AcceptedAnswerId="15829" CreationDate="2015-09-04T20:01:32.960" Score="0" ViewCount="986" Body="&lt;p&gt;First time Arduino user here.&lt;/p&gt;&#xA;&lt;p&gt;We have a microphone set-up which feeds back loudly on particular frequencies and need an equalizer to (preferably automatically) detect spikes in particular frequency bands and attenuate them before sending them on to the speakers. The dB level that has been cut from that frequency channel would then be displayed on an LED matrix such as this one:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Uk5b1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Uk5b1.jpg&quot; alt=&quot;LED Matrix&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Does the Arduino have the processing capabilities to keep up with the audio without noticeable lag? As the LEDs will only be a visual indication of the affect the attenuation is having on the frequencies, it is not particularly important that these be fast. Unfortunately, as the audio stream will be vocals, even a slight delay will render the thing useless. What delay might I expect with a single mono channel going through the arduino?&lt;/p&gt;&#xA;&lt;p&gt;I expect that I will eventually have to revert to the less-interesting project of an RTA which takes a split of the audio sends to the speakers and simply displays the frequency band intensities rather than altering them.&lt;/p&gt;&#xA;&lt;p&gt;I'd appreciate any thoughts.&lt;/p&gt;&#xA;" OwnerUserId="13192" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-04T20:17:15.970" Title="Advice on setting up a real-time audio equaliser" Tags="|led|audio|signal-processing|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15829" PostTypeId="2" ParentId="15828" CreationDate="2015-09-04T20:17:15.970" Score="1" Body="&lt;p&gt;Somewhat possible if you accept that the Arduino won't be doing most of the work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes, the Arduino can sample audio and perform FFT on it, though not fast and not at high frequencies&lt;/li&gt;&#xA;&lt;li&gt;Yes, the Arduino can decide what to do depending on the power of different buckets&lt;/li&gt;&#xA;&lt;li&gt;Yes, the Arduino can display the results&lt;/li&gt;&#xA;&lt;li&gt;No, the Arduino cannot do realtime audio filtering.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you accept that the filtering will have to be done with a bank of analogue band-cut filters that the Arduino turns on and off as needed then it may be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due might be a more suitable candidate since it will be able to sample and do the FFT much faster so you'll be able to respond to the peaks much quicker, and the displaying won't get in the way so much, but actively filtering inside the chip really requires a DSP.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-04T20:17:15.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15830" PostTypeId="2" ParentId="15817" CreationDate="2015-09-04T21:28:57.857" Score="3" Body="&#xA;&#xA;&lt;p&gt;You could always copy and paste:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;&#xA;  pinMode(11, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(11, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(11, LOW);&#xA;  delay(1000);&#xA;&#xA;  digitalWrite(12, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(12, LOW);&#xA;  delay(1000);&#xA;&#xA;  digitalWrite(13, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(13, LOW);&#xA;  delay(1000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A bit better would be to learn about functions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;&#xA;  pinMode(11, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void blink (const byte which)&#xA;  {&#xA;  digitalWrite(which, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(which, LOW);&#xA;  delay(1000);&#xA;  }  // end of blink&#xA;&#xA;void loop() {&#xA;  blink (11);&#xA;  blink (12);&#xA;  blink (13);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And you could learn about loops:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  for (int i = 11; i &amp;lt;= 13; i++)&#xA;    pinMode(i, OUTPUT);&#xA;}&#xA;&#xA;void blink (const byte which)&#xA;  {&#xA;  digitalWrite(which, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(which, LOW);&#xA;  delay(1000);&#xA;  }  // end of blink&#xA;&#xA;void loop() {&#xA;  for (int i = 11; i &amp;lt;= 13; i++)&#xA;     blink (i);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is a whole world of stuff to learn. Enjoy the process!&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-04T21:28:57.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15831" PostTypeId="1" CreationDate="2015-09-04T21:46:22.133" Score="2" ViewCount="144" Body="&lt;p&gt;I have a 30 button matrix and I would like to use a keyboard encoder to decipher what button was pressed. I would like that information (what button was pressed) to be wirelessly sent to my arduino uno nearby. What is the easiest solution? Can/how can I incorporate Arduino's Bluetooth shield to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="13194" LastActivityDate="2015-09-04T21:46:22.133" Title="Creating a keypad matrix that will communicate wirelessly with an Arduino Uno" Tags="|arduino-uno|bluetooth|button|wireless|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15832" PostTypeId="1" CreationDate="2015-09-04T08:07:01.930" Score="0" ViewCount="2946" Body="&lt;p&gt;I wrote a simple serial program using Arduino Mega 2560, it is connected to COMPORT 10. Here is the program I Wrote,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{           &#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  Serial.println(&quot;HELLO&quot;); &#xA;  delay(1000); //Send every one second           &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I tried to send this message &quot;Hello&quot; to TeraTerm (COMPORT 1, for this I just hooked up Tx and Rx to the Arduino's Rx0 and Tx0. Doing this I do receive message in my TeraTerm screen but the received message doesn't make sense, its receiving garbage. Its not the case of mismatch of baud rate I am using 9600 on both the side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I do receive message &quot;HELLO&quot; in the serial monitor. Is there something I am doing wrong that I am not receiving message on TeraTerm.   &lt;/p&gt;&#xA;" OwnerUserId="13204" OwnerDisplayName="Electronic Curious" LastActivityDate="2015-09-05T14:11:19.257" Title="Serial communication using Arduino and TeraTerm" Tags="|serial|communication|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15833" PostTypeId="2" ParentId="15832" CreationDate="2015-09-04T08:09:08.363" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... I just hooked up Tx and Rx to the Arduino's Rx0 and Tx0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But neither device knows what voltage they are. You need to connect ground as well so that they have a common reference.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-09-04T08:09:08.363" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15834" PostTypeId="1" AcceptedAnswerId="15835" CreationDate="2015-09-04T23:37:32.057" Score="10" ViewCount="7904" Body="&lt;p&gt;While planning the lightning infrastructure (wall-switches and lights) of my new home (it's still under-construction) I choosed to go through the &quot;automated route&quot; way and due to my background (I'm an &quot;old&quot; system/network administrator with programming skills and plenty of Open-Source &quot;passion&quot; and &quot;advocacy&quot;) I'm seriously trying to implement it with three Arduinos and one RPi2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to number/location of wall-push-buttons and lights, I'd like to use three MEGA interfacing both wall-push-buttons and lights of surrouding rooms. Furthermore, a RPi2 (or similar) will be used as a &quot;controller&quot; to properly programs MEGAs, when needed, and interfacing some other equipments (touch-screen; wifi tablet/smartphone; remote-controls; etc.) via the IP-network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schema I'm trying to implement is similar to this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eyX3P.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eyX3P.png&quot; alt=&quot;Draft Schema&quot;&gt;&lt;/a&gt;&#xA;where you see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;9 lights (L1 to L9) each one controlled by its own dedicated relay (R1 to R9);&lt;/li&gt;&#xA;&lt;li&gt;7 wall push-buttons (WPB1 to WPB7), to be used to turn on/off one or more lights;&lt;/li&gt;&#xA;&lt;li&gt;3 MEGAs interfacing wall-push-buttons and lights;&lt;/li&gt;&#xA;&lt;li&gt;1 RPi2, acting as &quot;supervisor&quot; and &quot;Internet/Ethernet gateway&quot;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My main architectural problem relates to the interconnection between RPI2 and MEGAs. As each device will be located several tens of meters aways from each other, I ended with two only option (please, correct me if I'm wrong):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Ethernet&lt;/li&gt;&#xA;&lt;li&gt;RS485&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;BTW: I'm explicitely excluding &quot;wireless connections&quot;, as I've already placed all the electrical pipes in a &quot;compatible&quot; way. In other words: I'd like to avoid wireless technologies within the &quot;controlling network&quot;&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for Ethernet, I'll choose it as a 2nd option, due both to a slightly higher cost and complexity (need a switch to be powered on; additional cabling issues; etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've extensively researched the &quot;&lt;strong&gt;RS485 bus&lt;/strong&gt;&quot; and found that it's relatively easy --from a physical point of view-- to implement it with &lt;a href=&quot;https://arduino-info.wikispaces.com/RS485-Modules&quot; rel=&quot;noreferrer&quot;&gt;two wires in a multidrop configuration&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, from an &quot;application point of view&quot;, things are more complex as it supports only &quot;half-duplex&quot; communications and, even worse, there is &lt;strong&gt;no&lt;/strong&gt; provision to avoid &quot;collisions&quot; when communicating (that's why, probably, the MODBUS protocol --tipically employed on RS485 bus-- provides a &quot;single-master; multiple-slaves&quot; scenario).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before the questions, I need to add another constraint: I want the infrastructure to be &quot;as much fault-tolerant as possible&quot;, expecially towards problems with the BUS and/or with the &quot;controller&quot; (the RPI2). In other words:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;each MEGA should allow to turn on its own lights when one of its own push-button requires this. For example:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if WPB1 controls L2 and L3, it need to be working even if the BUS is broken or the RPI2 is powered off;&lt;/li&gt;&#xA;&lt;li&gt;if WPB3 controls L4 and L9, then should the bus/RPI2 have problems, only L4 will be powered on when WPB3 is pressed;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, after all of the above, here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;is a two-wire RS485 multidrop bus, a suitable choice for my scenario?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if not, which (possibly cheap and simple) other solutions may I investigate?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if yes, which is the logic that I need to implement on MEGAs, as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a) they need to act as &quot;slave&quot;, with respect to RPI2 when turning on lights commanded by push-button connected to other MEGAs or when the RP2 decide to turn-on some lights (for example, due to remote/Internet access);&lt;/li&gt;&#xA;&lt;li&gt;b) they need to act as &quot;master&quot;, when one of their push-buttons is pressed and... this need to be communicated to RPI2 so to send commands to other MEGAs so to turn on &quot;hosted&quot; lights;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;as for 3b), insted of having MEGAs acting as master when a WPB is pressed, may I implement a &quot;frequent-polling&quot; logic on the RPI2? If yes, which is a reasonable value for such a polling (1 poll per second? 5 polls per second? too much? too low?)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I understand that this is a too-wide question, but I really did &lt;strong&gt;lots&lt;/strong&gt; of researches and despite lots, and lots, and lots of on-line documentation, I've been unable to find an answer to those questions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Update 1&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;in terms of total numbers, I'll have 31 lights to be controlled by 46 wall push-buttons, more or less equally distributed in 4 distinct panel-boards;&lt;/li&gt;&#xA;&lt;li&gt;As for the choise of MEGA (vs. UNO), I've choosed MEGA due to the bigger number of I/O PINs. I simply choosed the board with the maximun number of PINs;&lt;/li&gt;&#xA;&lt;li&gt;As for the RPI2, I choosed to employ a proper &quot;computer&quot; (vs. an additional microcontroller), 'cause I want a sort of &quot;decoupling&quot; between the &quot;physical controlling network&quot; and the &quot;User Management Interface&quot;. In other words, I want the management of physical buttons/relais to be handled by PLC-like device (Arduino: very quick power on; sort of real-time performance; very reliable; minor/no external &quot;computing&quot; factors introducing delays/problems); while, at the same time, all the user-interface be handled by a real-computer where I can easily write powerful HTTP web-services and/or really complex &quot;logics&quot;, using technologies and languages that doesn't fit well with Arduino (later on --much later on--, I plan to add several 150$ full-HD 10.1&quot; android tablets allaround the house, that will act as wireless &quot;clients&quot; towards what need to be a &quot;powerful&quot; (in terms of computing capacities) web-server; Also I plan to add various sensors [temperature; humidity; contacts; power-meters; etc.] whose data need to be stored for trending/archiving reasons). Hence, I tought about RPi2, than can easily be replaced with something more powerful, should it be needed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="13193" LastEditDate="2015-09-05T07:58:20.740" LastActivityDate="2018-05-05T16:07:10.187" Title="How to interconnect multiple Arduinos with a Rpi to control home-lights/switches" Tags="|arduino-mega|ethernet|modbus|rs485|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15835" PostTypeId="2" ParentId="15834" CreationDate="2015-09-05T01:00:09.170" Score="10" Body="&#xA;&lt;p&gt;I did a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;noreferrer&quot;&gt;lengthy post about RS485&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;First, your use of Megas seems an overkill, unless you already have them to hand. A Uno, or one of the smaller form-factor boards would seem to be perfectly adequate to monitor a few switches and turn on a couple of lights.&lt;/p&gt;&#xA;&lt;p&gt;Even the Rpi seems unnecessary. Another Uno could easily monitor your RS485 lines and connect via Ethernet (an Ethernet shield) to the rest of your house or whatever you are doing.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;... there is no provision to avoid &amp;quot;collisions&amp;quot; when communicating ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Well, you build that in. You give each Mega an address (eg. stored in EEPROM) and then you &amp;quot;address&amp;quot; the one you want, and then wait for a response. For example, in the code from my page above:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Master&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;quot;RS485_protocol.h&amp;quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte ENABLE_PIN = 4;&#xA;const byte LED_PIN = 13;&#xA;&#xA;SoftwareSerial rs485 (2, 3);  // receive pin, transmit pin&#xA;&#xA;// callback routines&#xA;  &#xA;void fWrite (const byte what)&#xA;  {&#xA;  rs485.write (what);  &#xA;  }&#xA;  &#xA;int fAvailable ()&#xA;  {&#xA;  return rs485.available ();  &#xA;  }&#xA;&#xA;int fRead ()&#xA;  {&#xA;  return rs485.read ();  &#xA;  }&#xA;&#xA;void setup()&#xA;{&#xA;  rs485.begin (28800);&#xA;  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable&#xA;  pinMode (LED_PIN, OUTPUT);  // built-in LED&#xA;}  // end of setup&#xA;  &#xA;byte old_level = 0;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  // read potentiometer&#xA;  byte level = analogRead (0) / 4;&#xA;  &#xA;  // no change? forget it&#xA;  if (level == old_level)&#xA;    return;&#xA;      &#xA;  // assemble message&#xA;  byte msg [] = { &#xA;     1,    // device 1&#xA;     2,    // turn light on&#xA;     level // to what level&#xA;  };&#xA;&#xA;  // send to slave  &#xA;  digitalWrite (ENABLE_PIN, HIGH);  // enable sending&#xA;  sendMsg (fWrite, msg, sizeof msg);&#xA;  digitalWrite (ENABLE_PIN, LOW);  // disable sending&#xA;&#xA;  // receive response  &#xA;  byte buf [10];&#xA;  byte received = recvMsg (fAvailable, fRead, buf, sizeof buf);&#xA;  &#xA;  digitalWrite (LED_PIN, received == 0);  // turn on LED if error    &#xA;  &#xA;  // only send once per successful change&#xA;  if (received)&#xA;    old_level = level;&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You configure the RS485 transceiver to either send or receive. Normally it is in receive mode, and you switch to send mode to send a &amp;quot;packet&amp;quot; of data. (See &amp;quot;enable sending&amp;quot; above).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Now the addressed device turns its transceiver into &amp;quot;send&amp;quot; mode and replies. The code in the library I wrote has a time-out, so if that particular slave is dead, the receive times out. You might remember that at the master end and try to communicate with it less often. Or you may not care if the time-out is short.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Slave&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;quot;RS485_protocol.h&amp;quot;&#xA;&#xA;SoftwareSerial rs485 (2, 3);  // receive pin, transmit pin&#xA;const byte ENABLE_PIN = 4;&#xA;&#xA;void fWrite (const byte what)&#xA;  {&#xA;  rs485.write (what);  &#xA;  }&#xA;  &#xA;int fAvailable ()&#xA;  {&#xA;  return rs485.available ();  &#xA;  }&#xA;&#xA;int fRead ()&#xA;  {&#xA;  return rs485.read ();  &#xA;  }&#xA;  &#xA;void setup()&#xA;{&#xA;  rs485.begin (28800);&#xA;  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  byte buf [10];&#xA;  &#xA;  byte received = recvMsg (fAvailable, fRead, buf, sizeof (buf));&#xA;  &#xA;  if (received)&#xA;    {&#xA;    if (buf [0] != 1)&#xA;      return;  // not my device&#xA;      &#xA;    if (buf [1] != 2)&#xA;      return;  // unknown command&#xA;    &#xA;    byte msg [] = {&#xA;       0,  // device 0 (master)&#xA;       3,  // turn light on command received&#xA;    };&#xA;    &#xA;    delay (1);  // give the master a moment to prepare to receive&#xA;    digitalWrite (ENABLE_PIN, HIGH);  // enable sending&#xA;    sendMsg (fWrite, msg, sizeof msg);&#xA;    digitalWrite (ENABLE_PIN, LOW);  // disable sending&#xA;    &#xA;    analogWrite (11, buf [2]);  // set light level&#xA;   }  // end if something received&#xA;   &#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: The example code from my linked page does not read the address from EEPROM, however that is trivial to implement.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I can't see any particular reason why you could not interrogate the slaves quite frequently. What else would the master be doing? You could also set up the master as a HTTP server so you could talk to it from your laptop, or some other part of the house.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;My wiring:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/unAvv.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/unAvv.png&quot; alt=&quot;RS485 wiring&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;To demonstrate the idea, I set up two Unos, connected via about 8 m of bell-wire (not even twisted pair, and certainly not shielded).&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7Kttu.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Kttu.jpg&quot; alt=&quot;RS485 demo&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;One Uno was running the standard ASCII table sketch (at 9600 baud), its Tx pin went into the LTC1480, and then the A/B pins went to the bell wire.&lt;/p&gt;&#xA;&lt;p&gt;The other Uno was connected as a USB interface (Reset connected to ground) and it was just echoing whatever arrived on the Tx pin to the USB.&lt;/p&gt;&#xA;&lt;p&gt;As far as I could see, it worked perfectly.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I will not need any poll at all, as with your approach I can implement a &amp;quot;single-master/multiple-slave&amp;quot; context... but with a &amp;quot;moving&amp;quot; master. Is this right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;My answer above assumed that the slaves were more likely to fail than the master (can't quite think why this would happen, but perhaps based on the fact that there are more slaves than masters, and the master doesn't control things like lights).&lt;/p&gt;&#xA;&lt;p&gt;I find my Arduinos extremely reliable when doing simple things (like unlocking a door when a RFID card is presented).&lt;/p&gt;&#xA;&lt;p&gt;You could conceivably build a fall-back position into the slaves. After all, if they get polled every second, and then no poll arrives, they could conceivably attempt to take over as master, perhaps in ascending order of device number, to avoid conflicts. Part of this polling by the &amp;quot;new master&amp;quot; could be to check the &amp;quot;original master&amp;quot; to see if it was ready to resume its duties.&lt;/p&gt;&#xA;&lt;p&gt;The library I described on my linked page has error checking built into it, the idea being that by checking a CRC on the packet you ensure that you don't come in half-way through a packet and misinterpret the data in it.&lt;/p&gt;&#xA;&lt;p&gt;You could also build in some randomness of poll times to resolve a deadlock if two slaves attempted to become master at once. If a slave failed it could wait for a random (and increasing) time before trying again to give another slave a chance to do it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I just wanted to note that the chance of packet collisions is rather low. You only send packets when a switch is pressed, or when a light needs to turn on.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Gerben is right, but I would be worried that a notification about a switch had gone unnoticed. One possible work-around here is rather than the slaves replying with state changes to a query, they reply with the current state. So it might go:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Master: Slave 3, what is your status?&#xA;Slave 3: Lights 1 and 4 on, lights 2 and 3 off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I will not need any poll at all, as with your approach I can implement a &amp;quot;single-master/multiple-slave&amp;quot; context... but with a &amp;quot;moving&amp;quot; master. Is this right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I've been thinking about this a bit, and I think now you could make a system that is basically master-free. It could work like this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Each device has its own address, which it gets from EEPROM (or DIP switches). eg. 1, 2, 3, 4, 5 ...&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You choose a range of addresses you are going to use (eg. maximum of 10)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When the device powers up it first listens for other devices &amp;quot;talking&amp;quot; on the bus. Hopefully it will hear at least one other (if not, see below).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;We decide on a fixed &amp;quot;message packet&amp;quot;, say of 50 bytes including address, CRC, etc. At 9600 baud that would take 52 ms to send.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each device gets a &amp;quot;slot&amp;quot; of time, and waits its turn to talk to the bus.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When its timeslot arrives, it goes into output mode, and broadcasts its packet which includes its own address. Therefore all the other devices can now read its status (and act upon it if necessary). Eg. device 1 might report that switch 3 is closed, which means device 2 must turn a light on.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ideally, you know your timeslot has arrived because your device address is one greater than the packet you just listened to. Eg. You are device 3. You just heard device 2 announce its status. Now it's your turn. Of course, you wrap around at the maximum number, so after device 10 you go back to device 1.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If a device is missing and does not respond, you give it (say) half a timeslot to respond, and then assume it is dead, and every device on the bus now assumes the next timeslot has started. (eg. You heard device 2, device 3 should respond, after 25 ms of inactivity, device 4 can now respond). This rule gives a device 25 ms to respond, which should be plenty even if it is servicing an interrupt or something like that.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If multiple devices in sequence are missing you count a 25 ms gap for each missing device, until it is your turn.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once you get at least one response the timing is resynchronized, so any drift in clocks would be cancelled.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The only difficulty here is that upon initial power-up (which might happen simultaneously if the power to the building is lost and then restored) there is no device currently broadcasting its status, and thus nothing to synchronize to.&lt;/p&gt;&#xA;&lt;p&gt;In that case:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If after listening long enough for all devices to be heard (eg. 250 ms) and hearing nothing, the device tentatively assumes it is the first one and makes a broadcast. However possibly two devices will do that at the same time, and thus never hear each other.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If a device has not heard from another device, it staggers the time between broadcasts randomly (perhaps seeding the random-number generator from its device number, to avoid all devices &amp;quot;randomly&amp;quot; staggering the broadcasts by the same amount).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This random staggering by additional amounts of time won't matter, because there is no-one listening anyway.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sooner or later one device will get exclusive use of the bus and the other ones can then synchronize with it in the usual way.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This random gap between attempts to communicate is similar to what Ethernet used to do when multiple devices shared one coaxial cable.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Demo of master-free system&lt;/h2&gt;&#xA;&lt;p&gt;This was an interesting challenge, so I put together a demo of doing this without having any specific master, as described above.&lt;/p&gt;&#xA;&lt;p&gt;First you need to set up the current device address, and the number of devices, in EEPROM, so run this sketch, changing &lt;code&gt;myAddress&lt;/code&gt; for each Arduino:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;const byte myAddress = 3;&#xA;const byte numberOfDevices = 4;&#xA;&#xA;void setup ()&#xA;  {&#xA;  if (EEPROM.read (0) != myAddress)&#xA;    EEPROM.write (0, myAddress);&#xA;  if (EEPROM.read (1) != numberOfDevices)&#xA;    EEPROM.write (1, numberOfDevices);&#xA;    &#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now upload this to each device:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; Multi-drop RS485 device control demo.&#xA; &#xA; Devised and written by Nick Gammon.&#xA; Date: 7 September 2015&#xA; Version: 1.0&#xA; &#xA; Licence: Released for public use.&#xA; &#xA; For RS485_non_blocking library see: http://www.gammon.com.au/forum/?id=11428&#xA; For JKISS32 see: http://forum.arduino.cc/index.php?topic=263849.0&#xA;*/&#xA;&#xA;#include &amp;lt;RS485_non_blocking.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;// the data we broadcast to each other device&#xA;struct&#xA;  {&#xA;  byte address;&#xA;  byte switches [10];&#xA;  int  status;&#xA;  }  message;&#xA;&#xA;const unsigned long BAUD_RATE = 9600;&#xA;const float TIME_PER_BYTE = 1.0 / (BAUD_RATE / 10.0);  // seconds per sending one byte&#xA;const unsigned long PACKET_LENGTH = ((sizeof (message) * 2) + 6); // 2 bytes per payload byte plus STX/ETC/CRC&#xA;const unsigned long PACKET_TIME =  TIME_PER_BYTE * PACKET_LENGTH * 1000000;  // microseconds&#xA;&#xA;// software serial pins&#xA;const byte RX_PIN = 2;&#xA;const byte TX_PIN = 3;&#xA;// transmit enable&#xA;const byte XMIT_ENABLE_PIN = 4;&#xA;&#xA;// debugging pins&#xA;const byte OK_PIN = 6;&#xA;const byte TIMEOUT_PIN = 7;&#xA;const byte SEND_PIN = 8;&#xA;const byte SEARCHING_PIN = 9;&#xA;const byte ERROR_PIN = 10;&#xA;&#xA;// action pins (demo)&#xA;const byte LED_PIN = 13;&#xA;const byte SWITCH_PIN = A0;&#xA;&#xA;&#xA;// times in microseconds&#xA;const unsigned long TIME_BETWEEN_MESSAGES = 3000;  &#xA;unsigned long noMessagesTimeout;                  &#xA;&#xA;byte nextAddress;&#xA;unsigned long lastMessageTime;&#xA;unsigned long lastCommsTime;&#xA;unsigned long randomTime;&#xA;&#xA;SoftwareSerial rs485 (RX_PIN, TX_PIN);  // receive pin, transmit pin&#xA;  &#xA;// what state we are in&#xA;enum {&#xA;   STATE_NO_DEVICES,&#xA;   STATE_RECENT_RESPONSE,&#xA;   STATE_TIMED_OUT,&#xA;} state;&#xA;&#xA;// callbacks for the non-blocking RS485 library&#xA;size_t fWrite (const byte what)&#xA;  {&#xA;  rs485.write (what);  &#xA;  }&#xA;  &#xA;int fAvailable ()&#xA;  {&#xA;  return rs485.available ();  &#xA;  }&#xA;&#xA;int fRead ()&#xA;  {&#xA;  lastCommsTime = micros ();&#xA;  return rs485.read ();  &#xA;  }&#xA;  &#xA;// RS485 library instance&#xA;RS485 myChannel (fRead, fAvailable, fWrite, 20);&#xA;&#xA;// from EEPROM&#xA;byte myAddress;        // who we are&#xA;byte numberOfDevices;  // maximum devices on the bus&#xA;&#xA;// Initial seed for JKISS32&#xA;static unsigned long x = 123456789,&#xA;                     y = 234567891,&#xA;                     z = 345678912,&#xA;                     w = 456789123,&#xA;                     c = 0;&#xA;&#xA;// Simple Random Number Generator&#xA;unsigned long JKISS32 ()&#xA;  {&#xA;  long t;&#xA;  y ^= y &amp;lt;&amp;lt; 5; &#xA;  y ^= y &amp;gt;&amp;gt; 7; &#xA;  y ^= y &amp;lt;&amp;lt; 22;&#xA;  t = z + w + c; &#xA;  z = w; &#xA;  c = t &amp;lt; 0; &#xA;  w = t &amp;amp; 2147483647;&#xA;  x += 1411392427;&#xA;  return x + y + w;&#xA;  }  // end of JKISS32&#xA;  &#xA;void Seed_JKISS32 (const unsigned long newseed)&#xA;  {&#xA;  if (newseed != 0)&#xA;    {&#xA;    x = 123456789;&#xA;    y = newseed;&#xA;    z = 345678912;&#xA;    w = 456789123;&#xA;    c = 0;&#xA;    }&#xA;  }  // end of Seed_JKISS32&#xA;  &#xA;void setup ()&#xA;  {&#xA;  // debugging prints&#xA;  Serial.begin (115200);&#xA;  // software serial for talking to other devices&#xA;  rs485.begin (BAUD_RATE);&#xA;  // initialize the RS485 library&#xA;  myChannel.begin ();&#xA;  &#xA;  // debugging prints&#xA;  Serial.println ();&#xA;  Serial.println (F(&amp;quot;Commencing&amp;quot;));&#xA;  myAddress = EEPROM.read (0);&#xA;  Serial.print (F(&amp;quot;My address is &amp;quot;));&#xA;  Serial.println (int (myAddress));&#xA;  numberOfDevices = EEPROM.read (1);&#xA;  Serial.print (F(&amp;quot;Max address is &amp;quot;));&#xA;  Serial.println (int (numberOfDevices));  &#xA;&#xA;  if (myAddress &amp;gt;= numberOfDevices)&#xA;    Serial.print (F(&amp;quot;** WARNING ** - device number is out of range, will not be detected.&amp;quot;));&#xA;  &#xA;  Serial.print (F(&amp;quot;Packet length = &amp;quot;));&#xA;  Serial.print (PACKET_LENGTH);  &#xA;  Serial.println (F(&amp;quot; bytes.&amp;quot;));&#xA;&#xA;  Serial.print (F(&amp;quot;Packet time = &amp;quot;));&#xA;  Serial.print (PACKET_TIME);  &#xA;  Serial.println (F(&amp;quot; microseconds.&amp;quot;));&#xA;  &#xA;  // calculate how long to assume nothing is responding&#xA;  noMessagesTimeout = (PACKET_TIME + TIME_BETWEEN_MESSAGES) * numberOfDevices * 2;&#xA;&#xA;  Serial.print (F(&amp;quot;Timeout for no messages = &amp;quot;));&#xA;  Serial.print (noMessagesTimeout);  &#xA;  Serial.println (F(&amp;quot; microseconds.&amp;quot;));&#xA;  &#xA;  // set up various pins&#xA;  pinMode (XMIT_ENABLE_PIN, OUTPUT);&#xA;  &#xA;  // demo action pins&#xA;  pinMode (SWITCH_PIN, INPUT_PULLUP);&#xA;  pinMode (LED_PIN, OUTPUT);&#xA;  &#xA;  // debugging pins&#xA;  pinMode (OK_PIN, OUTPUT);&#xA;  pinMode (TIMEOUT_PIN, OUTPUT);&#xA;  pinMode (SEND_PIN, OUTPUT);&#xA;  pinMode (SEARCHING_PIN, OUTPUT);&#xA;  pinMode (ERROR_PIN, OUTPUT);&#xA;  &#xA;  // seed the PRNG&#xA;  Seed_JKISS32 (myAddress + 1000);&#xA;  &#xA;  state = STATE_NO_DEVICES;&#xA;  nextAddress = 0;&#xA;&#xA;  randomTime = JKISS32 () % 500000;  // microseconds&#xA;  }  // end of setup&#xA;&#xA;// set the next expected address, wrap around at the maximum&#xA;void setNextAddress (const byte current)&#xA;  {&#xA;  nextAddress = current;  &#xA;  if (nextAddress &amp;gt;= numberOfDevices)&#xA;    nextAddress = 0;&#xA;  }  // end of setNextAddress&#xA;&#xA;&#xA;// Here to process an incoming message&#xA;void processMessage ()&#xA;  {&#xA;  &#xA;  // we cannot receive a message from ourself&#xA;  // someone must have given two devices the same address&#xA;  if (message.address == myAddress)&#xA;    {&#xA;    digitalWrite (ERROR_PIN, HIGH);&#xA;    while (true)&#xA;      { }  // give up  &#xA;    }  // can't receive our address&#xA;    &#xA;  digitalWrite (OK_PIN, HIGH);&#xA;  &#xA;  // handle the incoming message, depending on who it is from and the data in it&#xA;  &#xA;  // make our LED match the switch of the previous device in sequence&#xA;  if (message.address == (myAddress - 1))&#xA;    digitalWrite (LED_PIN, message.switches [0]);&#xA;    &#xA;  digitalWrite (OK_PIN, LOW);&#xA;  } // end of processMessage&#xA;  &#xA;// Here to send our own message  &#xA;void sendMessage ()&#xA;  {&#xA;  digitalWrite (SEND_PIN, HIGH);&#xA;  memset (&amp;amp;message, 0, sizeof message);&#xA;  message.address = myAddress;&#xA;  &#xA;  // fill in other stuff here (eg. switch positions, analog reads, etc.)&#xA;  &#xA;  message.switches [0] = digitalRead (SWITCH_PIN);&#xA;  &#xA;  // now send it&#xA;  digitalWrite (XMIT_ENABLE_PIN, HIGH);  // enable sending  &#xA;  myChannel.sendMsg ((byte *) &amp;amp;message, sizeof message);&#xA;  digitalWrite (XMIT_ENABLE_PIN, LOW);  // disable sending&#xA;  setNextAddress (myAddress + 1);&#xA;  digitalWrite (SEND_PIN, LOW);&#xA;  &#xA;  lastCommsTime = micros ();   // we count our own send as activity&#xA;  randomTime = JKISS32 () % 500000;  // microseconds&#xA;  }  // end of sendMessage&#xA;  &#xA;void loop ()&#xA;  {&#xA;  // incoming message?&#xA;  if (myChannel.update ())&#xA;    {&#xA;    memset (&amp;amp;message, 0, sizeof message);&#xA;    int len = myChannel.getLength ();&#xA;    if (len &amp;gt; sizeof message)&#xA;      len = sizeof message;&#xA;    memcpy (&amp;amp;message, myChannel.getData (), len);&#xA;    lastMessageTime = micros ();&#xA;    setNextAddress (message.address + 1);&#xA;    processMessage ();&#xA;    state = STATE_RECENT_RESPONSE;&#xA;    }  // end of message completely received&#xA;   &#xA;  // switch states if too long a gap between messages&#xA;  if  (micros () - lastMessageTime &amp;gt; noMessagesTimeout)&#xA;    state = STATE_NO_DEVICES;&#xA;  else if  (micros () - lastCommsTime &amp;gt; PACKET_TIME)&#xA;    state = STATE_TIMED_OUT;&#xA;    &#xA;  switch (state)&#xA;    {&#xA;    // nothing heard for a long time? We'll take over then&#xA;    case STATE_NO_DEVICES:&#xA;      if (micros () - lastCommsTime &amp;gt;= (noMessagesTimeout + randomTime))&#xA;        {&#xA;        Serial.println (F(&amp;quot;No devices.&amp;quot;));&#xA;        digitalWrite (SEARCHING_PIN, HIGH);&#xA;        sendMessage ();&#xA;        digitalWrite (SEARCHING_PIN, LOW);&#xA;        }&#xA;      break;&#xA;      &#xA;    // we heard from another device recently&#xA;    // if it is our turn, respond&#xA;    case STATE_RECENT_RESPONSE:  &#xA;      // we allow a small gap, and if it is our turn, we send our message&#xA;      if (micros () - lastCommsTime &amp;gt;= TIME_BETWEEN_MESSAGES &amp;amp;&amp;amp; myAddress == nextAddress)&#xA;        sendMessage ();&#xA;      break;&#xA;      &#xA;    // a device did not respond in its slot time, move onto the next one&#xA;    case STATE_TIMED_OUT:&#xA;      digitalWrite (TIMEOUT_PIN, HIGH);&#xA;      setNextAddress (nextAddress + 1);&#xA;      lastCommsTime += PACKET_TIME;&#xA;      digitalWrite (TIMEOUT_PIN, LOW);&#xA;      state = STATE_RECENT_RESPONSE;  // pretend we got the missing response&#xA;      break;&#xA;      &#xA;    }  // end of switch on state&#xA;    &#xA;  }  // end of loop&#xA;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As it currently stands, if you close a switch on A0 (short to ground) it will turn off a LED (pin 13) on the next highest device in sequence. This proves that the devices are talking to each other. Of course in practice you would have something more sophisticated in the packet which is being broadcast.&lt;/p&gt;&#xA;&lt;p&gt;I found in testing that the LED appeared to come on and off instantly.&lt;/p&gt;&#xA;&lt;p&gt;With all devices disconnected the first one connected will &amp;quot;hunt&amp;quot; for other devices. If you have debugging LEDs connected as I did you can see the &amp;quot;search&amp;quot; LED come on at random intervals as it broadcasts its packet with randomly-varying gaps. Once you have a second one connected they settle down and just exchange information. I tested with three connected at once.&lt;/p&gt;&#xA;&lt;p&gt;It would probably be more reliable with HardwareSerial - I used SoftwareSerial to help with debugging. A few small changes would accomplish that.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Amended schematic&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IbHz8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IbHz8.png&quot; alt=&quot;RS485 moving master schematic&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Screen-shots of the code in action&lt;/h2&gt;&#xA;&lt;p&gt;These images show the code working. First, with only one device connected:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3vqnR.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3vqnR.png&quot; alt=&quot;RS485 - one device&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can see from the pulses there that the device is broadcasting its data at randomly-varying intervals, to avoid continuing to clash with another device that powered up at the same moment.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4KZCZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4KZCZ.png&quot; alt=&quot;RS485 - two devices&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now we see blocks of data from two devices, with roughly the same size gaps in the middle. I configured it for four devices, but only two are present, so we see two blocks of data, and two gaps.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gPYau.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gPYau.png&quot; alt=&quot;RS485 - three devices&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now with three devices online, we see three blocks of data, and one gap, as the missing device is bypassed.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;If you are checking the figures, these were taken with the baud rate doubled, as a test, to 19200 baud.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Cable run test&lt;/h2&gt;&#xA;&lt;p&gt;For a proper hardware test, I connected the devices up to my in-house UTP cabling. I have cat-5 cable running from various rooms to a central plug-board. Going from one end of the house to another (a reasonable length run) it still works fine. There is 5 m cable between the Arduino and the wall socket, for a start. Plus another 5 m cable at the other end. Then there are about 2 x 15 m runs from the rooms to the switch room, and inside that there is a short bridging cable to connect them together.&lt;/p&gt;&#xA;&lt;p&gt;This was with the boards still programmed to run at 19200 baud.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-07T22:39:58.360" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15836" PostTypeId="1" CreationDate="2015-09-05T01:21:53.187" Score="0" ViewCount="418" Body="&lt;p&gt;I want to build a project that contains multiple Arduino nano's, each connected to one controlling Raspberry Pi.  I would like to send one signal (a string of characters or numbers) which would be the master state, which the other Arduinos would react to based on their programming.  What is the best way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the Arduino support a protocol for this, or will it need additional hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Max distance: 30 meters&lt;/p&gt;&#xA;" OwnerUserId="7572" LastEditorUserId="7572" LastEditDate="2015-09-05T04:07:44.787" LastActivityDate="2015-10-26T16:44:10.447" Title="How to network multiple Arduinos so they react to the same signal" Tags="|arduino-nano|communication|networking|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15837" PostTypeId="1" AcceptedAnswerId="17121" CreationDate="2015-09-05T03:43:17.777" Score="0" ViewCount="100" Body="&lt;p&gt;I have two Arduino Yuns that are not accessible &lt;em&gt;at all&lt;/em&gt; on the network. I can't go to the arduinoname.local, ssh arduinoname.local, as I previously could. I know at least one it working because it sends emails as I programmed it, yet it seems there is no longer a way to ssh into it. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I have unplugged, plugged in the router,  and the yuns.&lt;/p&gt;&#xA;" OwnerUserId="10780" LastEditorUserId="10780" LastEditDate="2015-09-12T05:26:18.990" LastActivityDate="2015-10-23T02:00:12.037" Title="SSH and web interface broken on Yun" Tags="|wifi|arduino-yun|ssh|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15838" PostTypeId="1" CreationDate="2015-09-05T04:23:11.133" Score="0" ViewCount="1660" Body="&lt;p&gt;I bought 10 Arduino Nanos for a project, each with all of their headers soldered in place.  Each was going to go into a tiny space, so I found myself needing do desolder the ICSP headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This led to a bit of a moral conundrum.  What would I lose by removing these useful looking headers.  They cover quite a lot of space on the nano, so they must be important right?  Am I going to regret removing these things when I finally realize how useful they are (I thought to myself.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, I did remove the ICSP headers, but the event got my thoughts going.  What is this header all about?  Why is it there?  What can I do with it?  I began to search for things that I could do with the ICSP header, but engaging results were not forthcoming ( except for this project:  &lt;a href=&quot;https://www.arduino.cc/en/Hacking/ParallelProgrammer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Hacking/ParallelProgrammer&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I was more interesting in things that flash, move, jump, sing, and such, so are there any interesting things that can be done with the ICSP header?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-09-05T16:04:16.570" Title="What are some fun things you can do using the ICSP header?" Tags="|icsp|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15839" PostTypeId="2" ParentId="15838" CreationDate="2015-09-05T04:30:16.370" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use &lt;em&gt;every single last byte&lt;/em&gt; of flash on the device.&lt;/p&gt;&#xA;&lt;p&gt;Since you're performing low-level programming of the device you get the entire chip to play on, without having to worry about bootloaders and such.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can debug (breakpoint, single-step, watch, disassemble, etc.) the code on the chip using software on your computer.&lt;/p&gt;&#xA;&lt;p&gt;Admittedly the devices you'd need in order to do so are more expensive than a simple ISP programmer and it only works with specific pieces of software, but it can be done.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-05T04:30:16.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15840" PostTypeId="1" AcceptedAnswerId="15841" CreationDate="2015-09-05T04:59:56.950" Score="0" ViewCount="3616" Body="&lt;p&gt;I notice problems with my output pins when I use this method of setting their &lt;code&gt;pinMode&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int allOutputPins[] = {3, 4, 9, 10, 5, A3, 11, 12, 7, 8, A1, A2};&#xA;&#xA;&#xA;for(int a = 0; a &amp;lt; sizeof(allOutputPins); a++){&#xA;   pinMode(allOutputPins[a], OUTPUT); &#xA;  }//end for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong?&lt;/p&gt;&#xA;" OwnerUserId="7806" LastActivityDate="2015-09-05T05:41:38.037" Title="Using for loop to set pinMode" Tags="|code-optimization|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15841" PostTypeId="2" ParentId="15840" CreationDate="2015-09-05T05:41:38.037" Score="2" Body="&lt;p&gt;Re  “Am I doing something wrong?”, yes :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sizeof(allOutputPins)&lt;/code&gt; expression returns the size of &lt;code&gt;allOutputPins[]&lt;/code&gt; in terms of bytes, so is 24 because the array contains 12 two-byte integers.  The loop's last 12 &lt;code&gt;pinMode()&lt;/code&gt; calls will be garbage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Among other ways of fixing the problem, you could change the expression to &lt;code&gt;sizeof(allOutputPins)/sizeof(int)&lt;/code&gt; [which has the same value, 12, as &lt;code&gt;(sizeof allOutputPins)/sizeof(int)&lt;/code&gt;; eg see the syntax entries for the &lt;a href=&quot;http://en.cppreference.com/w/cpp/language/sizeof&quot; rel=&quot;nofollow&quot;&gt;sizeof operator&lt;/a&gt; at cppreference.com] or you could change the base type of the array to &lt;code&gt;byte&lt;/code&gt; or &lt;code&gt;uint8_t&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-05T05:41:38.037" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15842" PostTypeId="1" AcceptedAnswerId="15843" CreationDate="2015-09-05T07:55:01.570" Score="0" ViewCount="500" Body="&lt;p&gt;I want to write a library for the RGBDigit shield (&lt;a href=&quot;http://rgbdigit.com/&quot; rel=&quot;nofollow&quot;&gt;http://rgbdigit.com/&lt;/a&gt;), which essentially is an Adafruit Neopixel strip, packed as a 7 segment display. The shield also has a DS3231 clock and an IR receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my plan was to make a class &lt;em&gt;RGBDigit&lt;/em&gt;, which inherits from the &lt;em&gt;Adafruit_NeoPixel&lt;/em&gt; class and add private objects &lt;em&gt;DS3231&lt;/em&gt; and &lt;em&gt;IRrecv&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my RGBDigit.h:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#ifndef RGBDigit_h&#xA;#define RGBDigit_h&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;Wire.h&quot;&#xA;#include &quot;../Adafruit_NeoPixel/Adafruit_NeoPixel.h&quot;&#xA;#include &quot;../IRremote/IRremote.h&quot;&#xA;#include &quot;../DS3231/DS3231.h&quot;&#xA;&#xA;class RGBDigit : public Adafruit_NeoPixel {&#xA;    public:&#xA;        RGBDigit(int nDigits);&#xA;        ~RGBDigit();&#xA;    private:&#xA;        int _nDigits;&#xA;        DS3231 _clock;&#xA;        IRrecv* _ir;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is RGBDigit.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;RGBDigit.h&quot;&#xA;&#xA;&#xA;RGBDigit::RGBDigit(int nDigits)&#xA;    : Adafruit_NeoPixel(8 * nDigits, 12, NEO_GRB + NEO_KHZ800),&#xA;    _nDigits(nDigits)&#xA;{&#xA;    _ir = new IRrecv(10);&#xA;    _ir-&amp;gt;enableIRIn(); // Start the receiver&#xA;    Adafruit_NeoPixel::begin();&#xA;}&#xA;&#xA;RGBDigit::~RGBDigit()&#xA;{&#xA;    delete _ir;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is my Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RGBDigit.h&amp;gt;&#xA;&#xA;RGBDigit display = RGBDigit(4);&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get al lot of &quot;undefined reference&quot; errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RGBDigit/RGBDigit.cpp.o: In function `RGBDigit::RGBDigit(int)':&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:23: undefined reference to `Adafruit_NeoPixel::Adafruit_NeoPixel(unsigned int, unsigned char, unsigned char)'&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:23: undefined reference to `DS3231::DS3231()'&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:25: undefined reference to `IRrecv::IRrecv(int)'&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:26: undefined reference to `IRrecv::enableIRIn()'&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:27: undefined reference to `Adafruit_NeoPixel::begin()'&#xA;RGBDigit/RGBDigit.cpp.o: In function `RGBDigit::~RGBDigit()':&#xA;/home/ralph/Arduino/libraries/RGBDigit/RGBDigit.cpp:30: undefined reference to `Adafruit_NeoPixel::~Adafruit_NeoPixel()'&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don' t understand why. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="13199" LastEditorUserId="4131" LastEditDate="2015-09-05T15:24:59.057" LastActivityDate="2015-09-05T15:24:59.057" Title="Inheritance: error in calling the constructor of the base class?" Tags="|class|rgb-led|neopixel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15843" PostTypeId="2" ParentId="15842" CreationDate="2015-09-05T10:08:47.033" Score="0" Body="&lt;pre&gt;&lt;code&gt;#include &quot;../Adafruit_NeoPixel/Adafruit_NeoPixel.h&quot;&#xA;#include &quot;../IRremote/IRremote.h&quot;&#xA;#include &quot;../DS3231/DS3231.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you're doing there is telling the &lt;em&gt;compiler&lt;/em&gt; where, relative to where it's performing the compiling (or one of its include directories), the header files you list are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you're &lt;em&gt;not&lt;/em&gt; doing is telling the &lt;em&gt;IDE&lt;/em&gt; where the CPP files are to compile and link with your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When including &lt;em&gt;anything&lt;/em&gt; external to the sketch folder that is &lt;em&gt;more&lt;/em&gt; than &lt;em&gt;just a header file&lt;/em&gt; you &lt;em&gt;must&lt;/em&gt; treat it as an Arduino library - that is, place it in one of the standard library folders and name it properly (libraries should be named &lt;code&gt;LibraryName/LibraryName.h&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you include the libraries properly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;#include &amp;lt;DS3231.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You must do that in &lt;em&gt;both&lt;/em&gt; your sketch &lt;em&gt;and&lt;/em&gt; your custom library.  That way the IDE knows where to look for the files to compile - the compiler doesn't understand the concept of an Arduino library (and thus the CPP files associated with a header file) - that is purely down to the IDE gathering the data by examining your sketch and locating the right files to then pass to the compiler.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-05T10:08:47.033" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15844" PostTypeId="1" CreationDate="2015-09-05T11:27:17.457" Score="1" ViewCount="67302" Body="&lt;p&gt;I need some code to pause the Arduino code until a button is pressed. I have a long program and at point I need a condition that if a Button on pin A2 is pressed then go forward, otherwise wait.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using &lt;code&gt;if&lt;/code&gt; with a condition but it failed for my purpose. I think this is because when &lt;code&gt;if(...)&lt;/code&gt; detects that the button is not pressed, it moves to next lines (as usual). But I have a long program and I want to wait forever until the button is pressed.&lt;/p&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="19409" LastEditDate="2019-06-24T04:57:12.410" LastActivityDate="2022-11-22T07:36:11.727" Title="Pause code untill a button is pressed" Tags="|arduino-uno|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="15846" PostTypeId="2" ParentId="15844" CreationDate="2015-09-05T12:02:14.643" Score="3" Body="&lt;p&gt;The construct you are looking for is called &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Instead of doing &amp;quot;If the button is pressed then continue&amp;quot; you need to do &amp;quot;while the button is not pressed do nothing&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Assuming you have an &amp;quot;active low&amp;quot; button (that is, a resistor pulling it up to +5V when not pressed, so &lt;code&gt;digitalRead(A2) == LOW&lt;/code&gt; is &amp;quot;pressed&amp;quot;), you can do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;while (digitalRead(A2) == HIGH) {&#xA;  // Do nothing&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So while it's not pressed (&lt;code&gt;digitalRead(A2) == HIGH&lt;/code&gt;) don't do anything.  As soon as &lt;code&gt;digitalRead(A2)&lt;/code&gt; returns LOW (so it is not &lt;code&gt;== HIGH&lt;/code&gt; any more) the &lt;code&gt;while&lt;/code&gt; loop will finish and your sketch can continue.&lt;/p&gt;&#xA;&lt;p&gt;I write all about the &lt;code&gt;while&lt;/code&gt; loop in an article &lt;a href=&quot;https://majenko.co.uk/blog/while-loop&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2021-04-27T13:31:24.500" LastActivityDate="2021-04-27T13:31:24.500" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="15847" PostTypeId="2" ParentId="3331" CreationDate="2015-09-05T12:18:22.123" Score="8" Body="&lt;p&gt;This can also happen if you have saved a version of the code (for example duplicate file for backup) within the current sketch folder.&lt;/p&gt;&#xA;" OwnerUserId="13202" LastActivityDate="2015-09-05T12:18:22.123" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15848" PostTypeId="2" ParentId="15844" CreationDate="2015-09-05T12:32:07.407" Score="1" Body="&lt;p&gt;Here are two ways you might have wired the button. If you wired it with a pullup, you will need to test for LOW (the button will ground its output when pressed). If pulldown, the button will raise its output when pressed and you would test for HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you will be testing the button again within less than a second, don't forget to debounce it. Switches send a bunch (technical term :) of pulses for a significant fraction of a second during a make or bread. See Nick Gammon's &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Switches&quot; page&lt;/a&gt; for a thorough discussion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sVu2L.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sVu2L.jpg&quot; alt=&quot;Pullup vs. Pulldown Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-05T12:32:07.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15849" PostTypeId="2" ParentId="15832" CreationDate="2015-09-05T14:11:19.257" Score="0" Body="&lt;p&gt;Hello everyone thanks for your reply, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the problem :D and was also able to solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was directly connecting the Tx and Rx pin of Arduino to the Rx and Tx pin of DB9 connector on PC. Since, DB9 on the PC operates on higher voltage than the operating voltage of the Arduino which is 5V. This mis-match of the voltage was causing the problem, So in order to solve this i added a level shifter in between (MAX232) and now it works perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks everyone for replying.&lt;/p&gt;&#xA;" OwnerUserId="13204" LastActivityDate="2015-09-05T14:11:19.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15850" PostTypeId="2" ParentId="15838" CreationDate="2015-09-05T16:04:16.570" Score="1" Body="&lt;p&gt;One interesting thing I just came up with: you could use this header to attach a simple control panel for your Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imbed the Arduino in any place/box/machine you like. Then use a cable with a 6 pin connector to connect the header to a small control panel.  The panel could have 3 buttons or LEDs, a reset button and a power plug.&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-09-05T16:04:16.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15851" PostTypeId="1" CreationDate="2015-09-05T16:21:13.520" Score="1" ViewCount="4744" Body="&lt;p&gt;I’m sorry if I sound ignorant and naive, but I’m brand new to Arduino;  very keen, but know very little.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started with a Sainsmart Arduino Uno clone board.  I downloaded the software, which opened OK (or at least seemed to), but the Serial Monitor kept telling me that there was a communication error, and a yellow light kept flashing on the Sainsmart board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got hold of a genuine Arduino (from Jameco), uninstalled everything Arduino, and started again from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I get the message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And after enabling the verbose output, got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tried again, and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I’m using a MacBook Pro, using Yosemite 10.10.5.&lt;/p&gt;&#xA;" OwnerUserId="12160" LastEditorUserId="10794" LastEditDate="2015-09-05T21:18:46.733" LastActivityDate="2015-12-04T23:05:55.160" Title="Error opening serial port '/dev/cu.Bluetooth-Modem'. (Port busy)" Tags="|arduino-uno|serial|uploading|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15852" PostTypeId="1" AcceptedAnswerId="15853" CreationDate="2015-09-05T09:26:50.617" Score="0" ViewCount="1820" Body="&lt;p&gt;I would like to program an arduino leonardo board with atmega32u4 on win8.1 x64.&#xA;I have the latest AVRdude.&#xA;I installed the necessary drivers, after reset it can be enter programming mode, and I can program with &lt;strong&gt;arduino studio&lt;/strong&gt;.&#xA;But now, the avrude gives this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    C:\&amp;gt;avrdude -carduino -P COM5 -n -p m32u4 -b19200 -v&#xA;&#xA;avrdude: Version 6.1-svn-20131205, compiled on Dec  5 2013 at 17:34:22&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;c:\GNU_GCC_ARM\bin\avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM5&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 19200&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x3f&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x3f&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried also with 57600 baud.&#xA;Any idea? Thanks.&lt;/p&gt;&#xA;" OwnerDisplayName="nolex" LastActivityDate="2015-09-05T16:57:19.547" Title="AVRdude + Arduino leonardo: can't flash over bootloader, not in sync: resp=0x3f" Tags="|avrdude|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15853" PostTypeId="2" ParentId="15852" CreationDate="2015-09-05T10:43:47.520" Score="1" Body="&lt;p&gt;You're specifying the wrong bootloader protocol via -carduino. The Arduino bootloader is for boards using the Diecimila bootloader. The Leonardo uses the &quot;AVR109&quot; bootloader - named after the &lt;a href=&quot;http://www.atmel.com/Images/doc1644.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmel Application Note&lt;/a&gt; which describes its protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this command on for size:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -cavr109 -P COM5 -n -p m32u4 -b57600 -v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't forget to press the reset button (or open and close COM5 at 1200 baud) first to run the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="11729" OwnerDisplayName="stefandz" LastActivityDate="2015-09-05T10:43:47.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15854" PostTypeId="2" ParentId="15851" CreationDate="2015-09-05T17:39:20.380" Score="3" Body="&lt;p&gt;You are not selecting the correct port to upload to - hence the strange message about the Bluetooth modem. Start by unplugging your Uno and running Arduino. Select Tools -&gt; Port from the menu bar. You should see a list of options. Now plug in your Uno and do the same again. You should see an extra port listed now - this will be the Uno. Select it. You will need to check this every time you connect a board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, before you click Upload, make sure you have Arduino Uno selected under Tools -&gt; Board in the menu bar. &lt;/p&gt;&#xA;" OwnerUserId="11729" LastActivityDate="2015-09-05T17:39:20.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15855" PostTypeId="1" CreationDate="2015-09-05T18:14:49.240" Score="0" ViewCount="728" Body="&lt;p&gt;I am currently trying to see the result of a query to a thingspeak field. &#xA;This works great when I just use a empty sketch and type the commands manually, but using the following sketch I cannot see the value of +IDP,0,1:1 &#xA;This means, at field 1, the value 1 is stored. If 0 was stored, it would be +IDP,0,1:0&#xA;How it is possible to &quot;ask&quot; if &quot;+IDP,0,1:0&quot; exists at the serial message from the ESP8266? Serial.find does not work....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here my sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial monitor(2,3); //rx tx &#xA;#define SSID &quot;WLAN-0E0265&quot;&#xA;#define PASS &quot;2738564673200634&quot;&#xA;int ledPin = 13;&#xA;String c;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  monitor.begin(9600);&#xA;  monitor.println(&quot;AT&quot;);&#xA;  delay(1000);&#xA;  monitor.println(&quot;AT+CIPMUX=1&quot;);&#xA;  delay(1000);&#xA;  monitor.println(&quot;AT+CWJAP=\&quot;WLAN-0E0265\&quot;,\&quot;2738564673200634\&quot;&quot;);&#xA;  delay(5000);&#xA;  if(monitor.find(&quot;OK&quot;))&#xA;    Serial.println(&quot;JAP worked&quot;);&#xA;&#xA;  monitor.println(&quot;AT+CIPSTART=0,\&quot;TCP\&quot;,\&quot;api.thingspeak.com\&quot;,80&quot;);&#xA;  delay(2000);&#xA;  if(monitor.find(&quot;OK&quot;))&#xA;    Serial.println(&quot;CIPSTART worked&quot;);&#xA;  monitor.println(&quot;AT+CIPSEND=0,110&quot;);&#xA;  delay(2000);&#xA;  if(monitor.find(&quot;&amp;gt;&quot;))&#xA;    Serial.println(&quot;CIPSEND worked&quot;);&#xA;  monitor.print(&quot;GET https://api.thingspeak.com/channels/54209/fields/1/last \r\n&quot;);&#xA;  delay(10000);&#xA;  monitor.println(&quot;GET https://api.thingspeak.com/channels/54209/fields/1/last&quot;);&#xA;  delay(2000);  &#xA;  String readString;&#xA;  ledPin = 13;&#xA;  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++&#xA;//SEARCH FOR THE :0 or :1                           &amp;lt;-- Here is the problem, rest works fine&#xA;  if(Serial.find(&quot;:0&quot;)){&#xA; //turn pin off&#xA;}&#xA;  if(Serial.find(&quot;:1&quot;)){&#xA; //turn pin on&#xA;} &#xA;&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13207" LastEditorUserId="10794" LastEditDate="2015-09-05T21:16:09.343" LastActivityDate="2016-04-28T06:44:40.960" Title="Arduino Serial Monitor" Tags="|arduino-uno|serial|c++|softwareserial|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15856" PostTypeId="2" ParentId="15855" CreationDate="2015-09-05T18:54:10.480" Score="1" Body="&lt;p&gt;The problem is that you can't use serial's &lt;code&gt;find&lt;/code&gt; function to look for one thing &lt;em&gt;or&lt;/em&gt; another.  It is a greedy function and it will consume everything coming in to the serial port until it finds what it's looking for or until it times out.  That includes the &lt;code&gt;:1&lt;/code&gt; if you are using &lt;code&gt;find&lt;/code&gt; to look for the &lt;code&gt;:0&lt;/code&gt; at the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you either need to receive the whole string into memory and examine the string to see what it contains, or you need to manually process the data as it comes in character by character to decide what there is.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-05T18:54:10.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15857" PostTypeId="2" ParentId="6712" CreationDate="2015-09-05T21:08:52.620" Score="1" Body="&lt;p&gt;Yes, in IDE 1.6.x, libraries are defined &quot;per board&quot;, they reside in special folders and are provided by the atuhor of the board-bundle. &#xA;Digispark's library is named SoftSerial and is included. In IDE Check File/Examples/DigisparkSoftSerial. Also check &lt;a href=&quot;https://digistump.com/wiki/digispark/tutorials/debugging&quot; rel=&quot;nofollow&quot;&gt;https://digistump.com/wiki/digispark/tutorials/debugging&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, you have to include:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   #include &amp;lt;SoftSerial.h&amp;gt;&#xA;   #include &amp;lt;TinyPinChange.h&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then define RX and TX pins (could be also the same in special cases):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   SoftSerial mySerial(SOFT_RX_PIN, SOFT_TX_PIN); // RX, TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use &lt;code&gt;mySerial.println()&lt;/code&gt; &amp;amp; co.&lt;/p&gt;&#xA;" OwnerUserId="13211" LastActivityDate="2015-09-05T21:08:52.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15858" PostTypeId="5" CreationDate="2015-09-06T02:56:19.477" Score="0" Body="&lt;p&gt;Adafruit is one of the companies supplying Arduinos and Arduino-compatible products. Their web page is &lt;a href=&quot;http://www.adafruit.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit has a &lt;a href=&quot;https://forums.adafruit.com/&quot; rel=&quot;nofollow&quot;&gt;forum&lt;/a&gt; - initial queries about their products or tutorials would be appropriately directed to there.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T02:56:19.477" LastActivityDate="2015-09-06T02:56:19.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15859" PostTypeId="4" CreationDate="2015-09-06T02:56:19.477" Score="0" Body="Adafruit Industries is an open-source hardware company founded by Limor Fried in 2005. Use this tag to mention issues with Adafruit products or tutorials." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T02:56:19.477" LastActivityDate="2015-09-06T02:56:19.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15860" PostTypeId="5" CreationDate="2015-09-06T03:06:24.577" Score="0" Body="&lt;p&gt;There are three types of memory on an Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;EEPROM &lt;/li&gt;&#xA;&lt;li&gt;RAM&lt;/li&gt;&#xA;&lt;li&gt;PROGMEM (Flash Memory - where your program goes)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On an Arduino Uno you have 1 KB of EEPROM, 2 KB of RAM, and 32 KB of program memory.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;EEPROM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Electrically Erasable Programming Read Only Memory&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This retains its value after power-off, so it can be used to retain configuration parameters, serial numbers, and similar things, even while the device is powered down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EEPROM has a limited erase/rewrite life-span. It is typically quoted as 100,000 erase/write cycles. This is still a lot for things like serial numbers, which would change rarely. It can be &lt;strong&gt;read&lt;/strong&gt; an indefinite number of times without wearing out.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;RAM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Random Access Memory&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This memory is lost at power-down, and has undefined values when the chip is powered up. It can be read from, and written to, an indefinite number of times. Your program variables are stored in RAM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;PROGMEM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Program Memory&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise known as &quot;flash memory&quot;. This is where your program code is stored. It has a separate address space to RAM (variables) due to the Arduino AVR range being &lt;a href=&quot;https://en.wikipedia.org/wiki/Harvard_architecture&quot; rel=&quot;nofollow&quot;&gt;Harvard Architecture&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PROGMEM has a limited erase/rewrite life-span. It is typically quoted as 10,000 erase/write cycles. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;During normal program operation PROGMEM is only read from (to read program instructions) - this can be done an unlimited number of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program memory is normally changed when &quot;uploading&quot; a new program, either by using the bootloader, or an ICSP programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;/questions/tagged/progmem&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;progmem&amp;#39;&quot; rel=&quot;tag&quot;&gt;progmem&lt;/a&gt; &lt;a href=&quot;/questions/tagged/bootloader&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;bootloader&amp;#39;&quot; rel=&quot;tag&quot;&gt;bootloader&lt;/a&gt; &lt;a href=&quot;/questions/tagged/icsp&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;icsp&amp;#39;&quot; rel=&quot;tag&quot;&gt;icsp&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T03:06:24.577" LastActivityDate="2015-09-06T03:06:24.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15861" PostTypeId="4" CreationDate="2015-09-06T03:06:24.577" Score="0" Body="Use this tag for questions about memory usage on the Arduino." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T03:06:24.577" LastActivityDate="2015-09-06T03:06:24.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15862" PostTypeId="5" CreationDate="2015-09-06T03:18:06.017" Score="0" Body="&lt;h2&gt;What happens at reset&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When a processor is powered on, it goes through a &quot;reset&quot; process, which means that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The hardware is set to a defined initial configuration (eg. all pins to inputs)&lt;/li&gt;&#xA;&lt;li&gt;The program counter is set to either address zero (the start of your program code), or the address of the bootloader code, depending on how the processor fuses are set.&lt;/li&gt;&#xA;&lt;li&gt;The program then starts running.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;How does a reset occur?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Resets can be caused by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Powering on the chip&lt;/li&gt;&#xA;&lt;li&gt;Pressing the reset button (this brings the &lt;code&gt;/RESET&lt;/code&gt; pin low, which resets the chip)&lt;/li&gt;&#xA;&lt;li&gt;Bringing the &lt;code&gt;/RESET&lt;/code&gt; pin low by other means (eg. another chip forcing &lt;code&gt;/RESET&lt;/code&gt; low)&lt;/li&gt;&#xA;&lt;li&gt;The watchdog timer timing out, if it is configured to do so, and if it is configured to reset the processor when it times out&lt;/li&gt;&#xA;&lt;li&gt;A brown-out (low-voltage) condition being detected, if configured to do so&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;When does the processor start?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If the reset was caused by the &lt;code&gt;/RESET&lt;/code&gt; pin going low, the processor starts a defined time after the &lt;code&gt;/RESET&lt;/code&gt; pin goes high again. This time depends on various fuse settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, for a power-on reset, the processor is also designed to wait for a certain time (depending on the fuse settings) to allow any external crystal to come up to speed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Can you make a software reset?&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Some people claim that jumping to the reset address (address zero) &quot;resets&quot; the processor. This is not true, because the &lt;strong&gt;hardware&lt;/strong&gt; has not been reset. All that does is restart the code running.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another method some authors suggest is using an output pin to bring &lt;code&gt;/RESET&lt;/code&gt; low. This is also not recommended, as one of the first things the reset sequence does is make all the pins high-impedance (input) and thus the &lt;code&gt;/RESET&lt;/code&gt; pin is not held low long enough.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The only reliable way of doing a software-initiated reset, as recommended by Atmel, is to set up the watchdog timer, and then allow it to time-out and invoke a proper hardware reset.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T03:18:06.017" LastActivityDate="2015-09-06T03:18:06.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15863" PostTypeId="4" CreationDate="2015-09-06T03:18:06.017" Score="0" Body="Use this tag for discussing resetting the processor." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-06T03:18:06.017" LastActivityDate="2015-09-06T03:18:06.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15864" PostTypeId="2" ParentId="5318" CreationDate="2015-09-06T08:57:53.960" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What I am wondering is whether there exists an elegant solution for this, with (highly) accurate results (I would most likely quote the power values, so accuracy is a must for me)? Something I can dynamically measure on the Uno itself?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Uno cannot measure its own power consumption. Indeed, a Uno which has a voltage regulator, power LED, and USB interface chip is not your ideal solution for low-power applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-06T08:57:53.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15865" PostTypeId="1" CreationDate="2015-09-06T09:25:40.453" Score="2" ViewCount="66" Body="&lt;p&gt;I'm working on wireless uploader for Arduino over BLE.&#xA;I've managed to make it working for Arduino Mega 2560 using GPIO and HM-10 AT commands to control GPIO pins. I'm using pretty the same &lt;a href=&quot;https://electronics.stackexchange.com/questions/9330/how-does-the-arduino-deumilanove-auto-reset-function-work&quot;&gt;schematics&lt;/a&gt; to perform reset just like for USB is done (wire GPIO to capacitor, resistor and MCU reset pin). The problem that it does work for Mega 2560 and it does not work for Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is log file for Mega 2560:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-05 14:53:01.055 xctest[59735:7704704] [DEBUG  ] [   ]: BleSerialDevice: open()&#xA;2015-09-05 14:53:01.055 xctest[59735:7704704] [DEBUG  ] [   ]: Connecting to service=0xFFE0, rx=0xFFE1, tx=0xFFE1&#xA;2015-09-05 14:53:01.055 xctest[59735:7704704] [INFO   ] [   ]: Start discovering peripherals ...&#xA;2015-09-05 14:53:01.056 xctest[59735:7704704] [DEBUG  ] [   ]: Waiting for peripheral to be discovered ...&#xA;2015-09-05 14:53:01.326 xctest[59735:7704747] [INFO   ] [   ]: Found peripheral: &amp;lt;CBPeripheral: 0x100407e30 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-05 14:53:01.326 xctest[59735:7704747] [DEBUG  ] [   ]: Stop scanning&#xA;2015-09-05 14:53:01.326 xctest[59735:7704747] [INFO   ] [   ]: Connecting to &amp;lt;CBPeripheral: 0x100407e30 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-05 14:53:01.548 xctest[59735:7704747] [DEBUG  ] [   ]: Connected to peripheral &amp;lt;CBPeripheral: 0x100407e30 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-05 14:53:01.551 xctest[59735:7704747] [TRACE  ] [   ]: Discovered services for peripheral &amp;lt;CBPeripheral: 0x100407e30 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-05 14:53:01.551 xctest[59735:7704747] [DEBUG  ] [   ]: Discovered service &amp;lt;CBService: 0x10020d510&amp;gt;&#xA;2015-09-05 14:53:01.692 xctest[59735:7704747] [TRACE  ] [   ]: Discovered characteristics for service &amp;lt;CBService: 0x10020d510&amp;gt;&#xA;2015-09-05 14:53:01.693 xctest[59735:7704747] [TRACE  ] [   ]: Discovered characteristic &amp;lt;CBCharacteristic: 0x1001076a0&amp;gt;&#xA;2015-09-05 14:53:01.693 xctest[59735:7704747] [DEBUG  ] [   ]: Tx characteristic supports WriteWithResponse: NO&#xA;2015-09-05 14:53:01.693 xctest[59735:7704747] [TRACE  ] [   ]: Subscribing to Rx value&#xA;2015-09-05 14:53:01.704 xctest[59735:7704704] [INFO   ] [   ]: Connected successfully&#xA;2015-09-05 14:53:01.705 xctest[59735:7704704] [DEBUG  ] [   ]: WiringProtocol:open: releasing DTR/RTS&#xA;2015-09-05 14:53:01.705 xctest[59735:7704704] [TRACE  ] [   ]: Waiting until subscribed to Rx value ...&#xA;2015-09-05 14:53:02.932 xctest[59735:7704747] [DEBUG  ] [IN ]: Updated notifications state for RX characteristic: isNotifying=YES&#xA;2015-09-05 14:53:02.971 xctest[59735:7704704] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-05 14:53:02.972 xctest[59735:7704704] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31] &#xA;2015-09-05 14:53:02.972 xctest[59735:7704704] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 14:53:03.027 xctest[59735:7704704] [DEBUG  ] [   ]: WiringProtocol:open: asserting DTR/RTS&#xA;2015-09-05 14:53:03.027 xctest[59735:7704704] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-05 14:53:03.028 xctest[59735:7704704] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30] &#xA;2015-09-05 14:53:03.028 xctest[59735:7704704] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 14:53:03.083 xctest[59735:7704704] [DEBUG  ] [   ]: Draining for 300 ms ...&#xA;2015-09-05 14:53:03.083 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.341 xctest[59735:7704746] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-05 14:53:03.341 xctest[59735:7704747] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-05 14:53:03.385 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.385 xctest[59735:7704704] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 14:53:03.385 xctest[59735:7704704] [DEBUG  ] [IN ]: Drained 18 bytes&#xA;2015-09-05 14:53:03.386 xctest[59735:7704704] [DEBUG  ] [OUT]: Sending 7 bytes&#xA;2015-09-05 14:53:03.386 xctest[59735:7704704] [TRACE  ] [OUT]: Send: . [0x1B] . [0x01] . [0x00] . [0x01] . [0x0E] . [0x01] . [0x14] &#xA;2015-09-05 14:53:03.386 xctest[59735:7704704] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 7&#xA;2015-09-05 14:53:03.387 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.387 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.453 xctest[59735:7704747] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-05 14:53:03.453 xctest[59735:7704747] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-05 14:53:03.454 xctest[59735:7704746] [TRACE  ] [IN ]: Rx value received 17 bytes: . [0x1B] . [0x01] . [0x00] . [0x0B] . [0x0E] . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.455 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.455 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x1B] &#xA;2015-09-05 14:53:03.456 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 17 bytes&#xA;2015-09-05 14:53:03.456 xctest[59735:7704704] [TRACE  ] [IN ]: 16 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.456 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.456 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x01] . [0x00] . [0x0B] . [0x0E] . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52]  ... +6 bytes&#xA;2015-09-05 14:53:03.457 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.457 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.457 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x01] &#xA;2015-09-05 14:53:03.457 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 16 bytes&#xA;2015-09-05 14:53:03.458 xctest[59735:7704704] [TRACE  ] [IN ]: 15 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.458 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.458 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x00] . [0x0B] . [0x0E] . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49]  ... +5 bytes&#xA;2015-09-05 14:53:03.459 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.459 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.459 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x00] &#xA;2015-09-05 14:53:03.459 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 15 bytes&#xA;2015-09-05 14:53:03.460 xctest[59735:7704704] [TRACE  ] [IN ]: 14 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.460 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.460 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x0B] . [0x0E] . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53]  ... +4 bytes&#xA;2015-09-05 14:53:03.460 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.461 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.461 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x0B] &#xA;2015-09-05 14:53:03.461 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 14 bytes&#xA;2015-09-05 14:53:03.461 xctest[59735:7704704] [TRACE  ] [IN ]: 13 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.462 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.462 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x0E] . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50]  ... +3 bytes&#xA;2015-09-05 14:53:03.462 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.462 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.462 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x0E] &#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 13 bytes&#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [TRACE  ] [IN ]: 12 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x01] . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F]  ... +2 bytes&#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.463 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.464 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x01] &#xA;2015-09-05 14:53:03.464 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 12 bytes&#xA;2015-09-05 14:53:03.464 xctest[59735:7704704] [TRACE  ] [IN ]: 11 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.464 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.464 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x00] . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32]  ... +1 bytes&#xA;2015-09-05 14:53:03.465 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.465 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.465 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x00] &#xA;2015-09-05 14:53:03.465 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 11 bytes&#xA;2015-09-05 14:53:03.465 xctest[59735:7704704] [TRACE  ] [IN ]: 10 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: . [0x08] A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: . [0x08] &#xA;2015-09-05 14:53:03.466 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 10 bytes&#xA;2015-09-05 14:53:03.467 xctest[59735:7704704] [TRACE  ] [IN ]: 9 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.467 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.467 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: A [0x41] V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.467 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.467 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.468 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: A [0x41] &#xA;2015-09-05 14:53:03.468 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 9 bytes&#xA;2015-09-05 14:53:03.468 xctest[59735:7704704] [TRACE  ] [IN ]: 8 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.468 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.468 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: V [0x56] R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: V [0x56] &#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 8 bytes&#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [TRACE  ] [IN ]: 7 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.469 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.470 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: R [0x52] I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.470 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.470 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.470 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: R [0x52] &#xA;2015-09-05 14:53:03.470 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 7 bytes&#xA;2015-09-05 14:53:03.471 xctest[59735:7704704] [TRACE  ] [IN ]: 6 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.471 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.471 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: I [0x49] S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.471 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.471 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: I [0x49] &#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 6 bytes&#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [TRACE  ] [IN ]: 5 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: S [0x53] P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.472 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.473 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.473 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: S [0x53] &#xA;2015-09-05 14:53:03.473 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 5 bytes&#xA;2015-09-05 14:53:03.473 xctest[59735:7704704] [TRACE  ] [IN ]: 4 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.473 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: P [0x50] _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: P [0x50] &#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 4 bytes&#xA;2015-09-05 14:53:03.474 xctest[59735:7704704] [TRACE  ] [IN ]: 3 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.475 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.475 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: _ [0x5F] 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.475 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.475 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.475 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: _ [0x5F] &#xA;2015-09-05 14:53:03.476 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 3 bytes&#xA;2015-09-05 14:53:03.476 xctest[59735:7704704] [TRACE  ] [IN ]: 2 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.476 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.476 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: 2 [0x32] t [0x74] &#xA;2015-09-05 14:53:03.476 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: 2 [0x32] &#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 14:53:03.477 xctest[59735:7704704] [TRACE  ] [IN ]: Having current receive buffer: t [0x74] &#xA;2015-09-05 14:53:03.478 xctest[59735:7704704] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 14:53:03.478 xctest[59735:7704704] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 14:53:03.478 xctest[59735:7704704] [TRACE  ] [IN ]: Receive: t [0x74] &#xA;2015-09-05 14:53:03.478 xctest[59735:7704704] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-05 14:53:03.478 xctest[59735:7704704] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 14:53:03.479 xctest[59735:7704704] [DEBUG  ] [   ]: Found programmer: 'PGMTYPE_AVRISP'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is Uno log file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-05 15:51:34.667 xctest[60180:7754033] [DEBUG  ] [   ]: BleSerialDevice: open()&#xA;2015-09-05 15:51:34.667 xctest[60180:7754033] [DEBUG  ] [   ]: Connecting to service=0xFFE0, rx=0xFFE1, tx=0xFFE1&#xA;2015-09-05 15:51:34.667 xctest[60180:7754033] [INFO   ] [   ]: Start discovering peripherals ...&#xA;2015-09-05 15:51:34.668 xctest[60180:7754033] [DEBUG  ] [   ]: Waiting for peripheral to be discovered ...&#xA;2015-09-05 15:51:35.411 xctest[60180:7754082] [INFO   ] [   ]: Found peripheral: &amp;lt;CBPeripheral: 0x1003335d0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-05 15:51:35.412 xctest[60180:7754082] [DEBUG  ] [   ]: Stop scanning&#xA;2015-09-05 15:51:35.412 xctest[60180:7754082] [INFO   ] [   ]: Connecting to &amp;lt;CBPeripheral: 0x1003335d0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-05 15:51:35.676 xctest[60180:7754084] [DEBUG  ] [   ]: Connected to peripheral &amp;lt;CBPeripheral: 0x1003335d0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-05 15:51:35.678 xctest[60180:7754084] [TRACE  ] [   ]: Discovered services for peripheral &amp;lt;CBPeripheral: 0x1003335d0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-05 15:51:35.678 xctest[60180:7754084] [DEBUG  ] [   ]: Discovered service &amp;lt;CBService: 0x10011fff0&amp;gt;&#xA;2015-09-05 15:51:35.836 xctest[60180:7754084] [TRACE  ] [   ]: Discovered characteristics for service &amp;lt;CBService: 0x10011fff0&amp;gt;&#xA;2015-09-05 15:51:35.836 xctest[60180:7754084] [TRACE  ] [   ]: Discovered characteristic &amp;lt;CBCharacteristic: 0x10040b8f0&amp;gt;&#xA;2015-09-05 15:51:35.836 xctest[60180:7754084] [DEBUG  ] [   ]: Tx characteristic supports WriteWithResponse: NO&#xA;2015-09-05 15:51:35.837 xctest[60180:7754084] [TRACE  ] [   ]: Subscribing to Rx value&#xA;2015-09-05 15:51:35.846 xctest[60180:7754033] [INFO   ] [   ]: Connected successfully&#xA;2015-09-05 15:51:35.846 xctest[60180:7754033] [TRACE  ] [   ]: DTR/RTS supported by Serial, resetting&#xA;2015-09-05 15:51:35.846 xctest[60180:7754033] [TRACE  ] [   ]: Waiting until subscribed to Rx value ...&#xA;2015-09-05 15:51:36.655 xctest[60180:7754082] [DEBUG  ] [IN ]: Updated notifications state for RX characteristic: isNotifying=YES&#xA;2015-09-05 15:51:36.682 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-05 15:51:36.682 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31] &#xA;2015-09-05 15:51:36.682 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 15:51:36.735 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-05 15:51:36.736 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30] &#xA;2015-09-05 15:51:36.736 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 15:51:36.788 xctest[60180:7754033] [DEBUG  ] [   ]: Draining for 300 ms ...&#xA;2015-09-05 15:51:36.788 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.053 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-05 15:51:37.053 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [DEBUG  ] [IN ]: Drained 18 bytes&#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-05 15:51:37.095 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.096 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-05 15:51:37.453 xctest[60180:7754033] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 15:51:37.453 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-05 15:51:37.456 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-05 15:51:37.456 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-05 15:51:37.457 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.457 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.701 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-05 15:51:37.701 xctest[60180:7754084] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-05 15:51:38.451 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 5 bytes: h [0x68] e [0x65] l [0x6C] l [0x6C] o [0x6F]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is arduino sketch used for Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(115200);&#xA;  Serial.print(&quot;hello&quot;);&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see Uno's bootloader skips waiting for upload commands and goes right to sketch (see 'hello' in incoming buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it Uno's bootloader feature? Can i walkaround it by wiring GPIO directly to USB's DTR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: can i wire HM-10 GPIO directly to pin 13 of USB's ATmega's (see &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematics&lt;/a&gt;) to make HM's GPIO act exactly like USB's DTR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if uploading to Uno over USB if goes further after &lt;code&gt;Send: A [0x41] . [0x81]   [0x20]&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-06 15:47:10.452 xctest[1042:33659] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-06 15:47:10.453 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-06 15:47:10.592 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.596 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-09-06 15:47:10.596 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.596 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-09-06 15:47:10.596 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.596 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-09-06 15:47:10.597 xctest[1042:33659] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-06 15:47:10.597 xctest[1042:33659] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-09-06 15:47:10.597 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.600 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-09-06 15:47:10.600 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [DEBUG  ] [   ]: STK500:initialize: n_extparms = 4&#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [DEBUG  ] [OUT]: Sending 22 bytes&#xA;2015-09-06 15:47:10.601 xctest[1042:33659] [TRACE  ] [OUT]: Send: B [0x42] . [0x86] . [0x00] . [0x01] . [0x00] . [0x01] . [0x01] . [0x01] . [0x03] . [0xFF] . [0xFF] . [0xFF] . [0xFF] . [0x00] . [0x80] . [0x04] . [0x00] . [0x00] . [0x00] . [0x80] . [0x00]   [0x20] &#xA;2015-09-06 15:47:10.602 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.604 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-09-06 15:47:10.604 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.605 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-09-06 15:47:10.616 xctest[1042:33659] [DEBUG  ] [OUT]: Sending 7 bytes&#xA;2015-09-06 15:47:10.617 xctest[1042:33659] [TRACE  ] [OUT]: Send: E [0x45] . [0x05] . [0x04] . [0xD7] . [0xC2] . [0x00]   [0x20] &#xA;2015-09-06 15:47:10.617 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.621 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-09-06 15:47:10.621 xctest[1042:33659] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-09-06 15:47:10.621 xctest[1042:33659] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-09-06 15:47:10.621 xctest[1042:33659] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-06 15:47:10.622 xctest[1042:33659] [TRACE  ] [OUT]: Send: P [0x50]   [0x20] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8327" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-09-06T10:48:19.110" Title="How to reset Arduino Uno over BLE?" Tags="|arduino-uno|arduino-mega|bluetooth|usb|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15867" PostTypeId="1" CreationDate="2015-09-06T12:31:26.450" Score="2" ViewCount="42212" Body="&lt;p&gt;My computer cannot detect my Arduino Uno anymore,&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reset button- &amp;gt; L led light blinks and it turns on forever&lt;/li&gt;&#xA;&lt;li&gt;Arduino 1.6.5: Tools-&amp;gt;Port (greyed out) I remembered that previously it wasn't like this&lt;/li&gt;&#xA;&lt;li&gt;Unable to upload any sketch codes into the Uno anymore&lt;/li&gt;&#xA;&lt;li&gt;The existing code uploaded onto the Uno is FastLED(FirstLight) and it will work on my LEDs when I plugged them in&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I have tried to .... but none fix my issue&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Restart my computer&lt;/li&gt;&#xA;&lt;li&gt;Press the reset button on the Uno&lt;/li&gt;&#xA;&lt;li&gt;Using the device mananger to change COM ports&lt;/li&gt;&#xA;&lt;li&gt;Device manager -&amp;gt; Other devices -&amp;gt; (nothing about Arduino Uno is found here)&lt;/li&gt;&#xA;&lt;li&gt;Plugged Uno into another computer but still doesn't work&lt;/li&gt;&#xA;&lt;li&gt;Reinstalled IDE&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Problem shown in sketch,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;avrdude: ser_open(): can't open device &amp;quot;\.\COM3&amp;quot;: The system cannot find the file specified.&lt;/p&gt;&#xA;&lt;p&gt;Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="12172" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-08-17T20:59:34.970" Title="avrdude: ser_open(): can't open device &quot;\\.\COM3&quot;?" Tags="|arduino-uno|hardware|" AnswerCount="2" CommentCount="2" ClosedDate="2017-08-18T08:32:40.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="15868" PostTypeId="1" CreationDate="2015-09-06T12:39:15.447" Score="1" ViewCount="204" Body="&lt;p&gt;I have an arduino schematic from here  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino-hacks.com/arduino-vu-meter-lm386electret-microphone-condenser/&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino-hacks.com/arduino-vu-meter-lm386electret-microphone-condenser/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a problem, the output of the circuit (the pin which is going to connect to the analog pin of the Arduino), from what I have measured has 4.5 V (I think it is a bit high). If I print on the serial it gives me something like 827, 826. However when I clap my hands near the microphone or put music on, the data that I get doesn't change a lot (like 1 -2 units). Should I worry about the schematic or about my microphone?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;  After I rebuilt the circuit and when playing a song at a medium volume, I get values like this: 419-670. I think it is working, though I would like more opinions about these values (the output voltage is now around 3.20 V).&lt;/p&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="10907" LastEditDate="2016-01-08T16:38:36.113" LastActivityDate="2016-04-07T20:21:52.357" Title="Arduino microphone" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15870" PostTypeId="2" ParentId="15868" CreationDate="2015-09-06T13:19:43.080" Score="1" Body="&lt;p&gt;The schematic seems to have both inputs of the opamp at 0V (the one connected to the microphone would actually swing a small amount ±). The opamp also seems to be running open loop, with no feedback and would have a very high gain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is poor circuit design, ideally the inputs should be biassed at Vcc/2. At best the output would be severely distorted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you search for a more suitable circuit. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-09-06T13:19:43.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15871" PostTypeId="2" ParentId="14524" CreationDate="2015-09-06T14:33:55.947" Score="1" Body="&lt;p&gt;The problem is solved now. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I imported the Adafruit_CC3000 library which can be downloaded here: &lt;a href=&quot;https://github.com/adafruit/Adafruit_CC3000_Library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_CC3000_Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;I run the example but the output was chinese nonsense&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Instead of &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial.begin(115200);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial.begin(9600);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;then the examples run without any problem&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks @Majenko. His question was very helpful.&lt;/p&gt;&#xA;" OwnerUserId="11839" LastActivityDate="2015-09-06T14:33:55.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15873" PostTypeId="2" ParentId="15867" CreationDate="2015-09-06T20:52:01.740" Score="-1" Body="&lt;p&gt;Try a different arduino w/ your first computer, see if that will work.&lt;/p&gt;&#xA;" OwnerUserId="11557" LastActivityDate="2015-09-06T20:52:01.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15874" PostTypeId="1" AcceptedAnswerId="15876" CreationDate="2015-09-05T13:27:24.363" Score="0" ViewCount="8336" Body="&lt;p&gt;I want to drive this 12V piezo buzzer:&#xA;&lt;a href=&quot;http://www.conrad.com/ce/en/product/130256/Kemo-L001-High-Freqeuncy-Piezo-Speaker-Component-12-24-V&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.conrad.com/ce/en/product/130256/Kemo-L001-High-Freqeuncy-Piezo-Speaker-Component-12-24-V&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the circuit I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dIxDl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dIxDl.png&quot; alt=&quot;Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is powered by a 12V DC adapter trough the DC IN jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;  int pinOut = 9;&#xA;  int freq = 10;&#xA;  int duration = 100;&#xA;  while(1)&#xA;  {&#xA;    for(int i=0; i&amp;lt;1000 ; i++)&#xA;    {&#xA;      tone(pinOut, freq*i, duration);&#xA;      delay(duration * 1);&#xA;      noTone(pinOut);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When run I can hear the tones changing but is really really low. I have measured the voltage between buzzer pins and it is 12V (as expected) so the MOSFET seems to be properly working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This piezo buzzer should be louder (I have tested it with this 12V tone generator &lt;a href=&quot;http://www.kemo-electronic.de/en/Car/Modules/M048N-Ultrasonic-Generator.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.kemo-electronic.de/en/Car/Modules/M048N-Ultrasonic-Generator.php&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am making any mistake?&#xA;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="13643" OwnerDisplayName="soyxan" LastEditorUserId="4131" LastEditDate="2015-09-08T12:40:58.343" LastActivityDate="2015-09-08T12:40:58.343" Title="Drive 12V Piezo Buzzer (Arduino)" Tags="|arduino-uno|piezo|buzzer|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15875" PostTypeId="2" ParentId="15874" CreationDate="2015-09-05T15:23:34.770" Score="0" Body="&lt;p&gt;The usable frequency range of the speaker is 2500 - 45000 Hz. In your script, you sweep from 10Hz to 10kHz which is a bit low. Try to change the start frequency to a higher value: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;  int pinOut = 9;&#xA;  int freq = 2500;&#xA;  int duration = 100;&#xA;  while(1)&#xA;  {&#xA;    for(int i=0; i&amp;lt;1000 ; i++)&#xA;    {&#xA;      tone(pinOut, freq+(i*50));&#xA;      delay(duration);&#xA;      noTone(pinOut);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Martin" LastActivityDate="2015-09-05T15:23:34.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15876" PostTypeId="2" ParentId="15874" CreationDate="2015-09-05T17:42:41.520" Score="2" Body="&lt;p&gt;The piezo element acts like a capacitor, not like a more-or-less resistive element as in a conventional speaker. You need to discharge the capacitor during the 'off' time or you just get a click and little sound after that. That's why your resistor helps. Push-pull would be much better, and an H-bridge would give you much more output (maybe too much for the speaker). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the IRZ44 is not specified to be driven from 5V (it's specified at 10V Vgs) so you may not get much current. Further, if you're trying to get 10's of kHz, you won't be able to drive the MOSFET gate that fast with a 1K resistor, in fact the Arduino may not be able to source enough current and you may have to use a gate driver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can measure the capacitance and provide the frequency of interest, more specific recommendations would be possible. At 2kHz about 3K would be okay with a 10nF element, but that resistance would decrease with increasing resistance and with increasing capacitance, and at some point the power dissipation in the resistor will become excessive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: You can do something like the below with a 10nF/20kHz requirement: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/PhsXe.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fPhsXe.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even duplicate the above circuit and add an inverter in series with one of the halves and get 24Vpp across the piezo, but you might want to use somewhat beefier transistors (Zetex perhaps). &lt;/p&gt;&#xA;" OwnerUserId="5080" OwnerDisplayName="Spehro Pefhany" LastActivityDate="2015-09-06T01:53:35.890" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="15879" PostTypeId="2" ParentId="13243" CreationDate="2015-09-07T06:29:42.830" Score="2" Body="&lt;p&gt;I would try the PIR sensor before writing it off.  It detects changes in infrared radiation from an initial baseline that it reads, so whenever the ambient heat that it sees changes by some threshold, it notifies you.  They might be sensitive enough to see a car coming through, as suggested by others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more robust solution could be the ultrasonic proximity sensor, like Majenko mentioned.  Here's one as a starting point: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E0NXTJW&quot; rel=&quot;nofollow&quot;&gt;ultrasonic distance sensor&lt;/a&gt;.  This will be best if you know that the car will be passing in front of where you point the sensor.  If it's hard to point the sensor to a point where you're sure the car will be coming through, then that's where a PIR would have advantages, as it &quot;sees&quot; a wider area.&lt;/p&gt;&#xA;" OwnerUserId="8611" LastActivityDate="2015-09-07T06:29:42.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15882" PostTypeId="1" CreationDate="2015-09-07T09:23:37.967" Score="2" ViewCount="4054" Body="&lt;p&gt;I have been searching for a way to upgrade the sketch on my Arduino Uno wirelessly (preferable WiFi, but not a must). Does the Uno support such function?&#xA;If not - are there any other boards that might support it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to further extend on the problem - I wouldn't want to upload a new sketch through the Arduino IDE but rather do it programmatically (trying to integrate it with a version management system of my own).&lt;/p&gt;&#xA;" OwnerUserId="13228" LastActivityDate="2020-06-05T10:19:44.050" Title="Programatic FOTA (Firmware-Over-The-Air) upgrades with Uno R3" Tags="|arduino-uno|bluetooth|wifi|firmware|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15883" PostTypeId="2" ParentId="15882" CreationDate="2015-09-07T09:33:55.743" Score="4" Body="&lt;p&gt;There's two ways you can go about this - hardware and software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do it in software would mean writing a new bootloader that supported whatever wireless medium you chose.  The bootloader might end up quite large and thus restrict the size of sketch you are able to support.  It may also require advanced programming techniques in order to fit it into memory.  Not a task for a beginner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing it in hardware is easier but more restrictive.  You need a wireless medium that can emulate a serial device &lt;em&gt;including the ability to perform a reset of the Arduino&lt;/em&gt;.  There are bluetooth interfaces for the Arduino that can perform this kind of functionality, but I am not aware of anything WiFi or Ethernet that even remotely comes close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are Arduino boards available with this kind of bluetooth interface built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible third option is something in between - you have two Arduinos (or some other external MCU based system, like an ATTiny for instance), the &quot;target&quot; and the &quot;programmer&quot;.  The &quot;programmer&quot; is what is connected to the wireless and accepts instructions and commands over the air.  It is then capable of putting the &quot;target&quot; into bootloader mode (reset it) and pass data through to its serial port for programming.  It does mean the &quot;target&quot; isn't directly connected to the wireless though, so it is up to the &quot;programmer&quot; to support whatever wireless functionality is needed and communicate properly with the &quot;target&quot; to get it to do everything it should.  There is no way to do FOTA to the &quot;programmer&quot; though, so you're back at square one if you want to reprogram that...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-07T09:33:55.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15884" PostTypeId="2" ParentId="15882" CreationDate="2015-09-07T10:05:21.620" Score="3" Body="&lt;p&gt;There are plenty of examples of Arduinos being used to reprogram Arduinos:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Using an Arduino as an AVR ISP (In-System Programmer)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/462&quot; rel=&quot;nofollow&quot;&gt;Standalone AVR ISP Programmer Shield Kit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow&quot;&gt;Atmega chip stand-alone programmer to upload .hex files&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;Atmega bootloader programmer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So the obvious choice here is to have &lt;strong&gt;two&lt;/strong&gt; chips. One does the real work, the other one programs the first one, when required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;programmer&quot; chip could be written to read from a disk file, accept data over Ethernet, WiFi or whatever. And it could be programmed to reprogram the target chip at a certain time of day, or on command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this system the &quot;main&quot; chip gets on with whatever-it-is it is doing, and the &quot;programmer&quot; chip just monitors its source of new code.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does the Uno support such function? If not - are there any other boards that might support it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't know of any boards that directly support that. These boards are generally built as educational tools, not as ready to deploy in the field as robust auto-upgrading devices. For one thing, keeping things cheap enough for students to purchase, perhaps one for each student in a classroom of 30, was one of the design criteria.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-07T10:05:21.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15887" PostTypeId="2" ParentId="13243" CreationDate="2015-09-07T15:22:13.657" Score="0" Body="&lt;p&gt;I would use an &lt;a href=&quot;http://playground.arduino.cc/Main/UltrasonicSensor&quot; rel=&quot;nofollow&quot;&gt;ultrasonic distance sensor&lt;/a&gt;. They are quite accurate, and are common to use for this kind of problem. You will get all kinds of noise in your data, from all the different surfaces that the ultrasonic sound will bounce off from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be &lt;a href=&quot;https://encrypted.google.com/search?q=infrared%20distance%20sensor%20arduino&quot; rel=&quot;nofollow&quot;&gt;infrared distance sensor&lt;/a&gt;. Make sure you find one with a long enough range, because the 'usual' one used with arduino examples goes to about 30cm. They are less precise, but very easy to use with arduino. And if I remember correctly they have less problems of getting interference if you have a bunch of them together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pir sensors are made to detect the difference in infrared heat coming off a human skin (comparing to when the person is not there). So I would not recommend that.&lt;/p&gt;&#xA;" OwnerUserId="13239" LastActivityDate="2015-09-07T15:22:13.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15888" PostTypeId="1" AcceptedAnswerId="15889" CreationDate="2015-09-07T15:28:17.170" Score="2" ViewCount="10598" Body="&lt;p&gt;I suspect this is a very Naive question.&lt;br&gt;&#xA;But the answer will teach me a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ButtonStateChange&quot; rel=&quot;nofollow&quot;&gt;this circuit&lt;/a&gt; work when I connect the Digital Input (Digial Pin 2) to Pin 4 of the push button. But does not when I connect the push button to Pin 3. I missing something about how power flows when the button is pushed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ray K&lt;/p&gt;&#xA;" OwnerUserId="13240" LastActivityDate="2018-06-04T19:55:54.823" Title="Newbie Question with 4 pin button" Tags="|arduino-uno|button|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15889" PostTypeId="2" ParentId="15888" CreationDate="2015-09-07T15:44:32.823" Score="4" Body="&lt;p&gt;Internally those little tactile switches look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/74KLh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/74KLh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that the two pins on the same &lt;em&gt;long&lt;/em&gt; side are connected together.  So you can use, when you hold the switch vertically as in the image on the page you link to the two left-hand pins are linked together, and the two right-hand pins are linked together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can use either both the top pins, both the bottom pins, or the top left and bottom right or the top right and bottom left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using either both left hand pins or both right hand pins will be as if you were sat on the button and it was permanently pressed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-07T15:44:32.823" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15890" PostTypeId="1" AcceptedAnswerId="15891" CreationDate="2015-09-07T17:20:55.763" Score="2" ViewCount="5643" Body="&lt;p&gt;I'm working on an Arduino sketch that will read in values from two potentiometers. The code for this is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int lastPotentiometerOneValue = 0;&#xA;int lastPotentiometerTwoValue = 0;&#xA;&#xA;void setup() {&#xA;  // initialize serial communication at 57600 bits per second:&#xA;  Serial.begin(57600);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(10);&#xA;  readAndSendPotentiometerDataIfChanged();&#xA;}&#xA;&#xA;void readAndSendPotentiometerDataIfChanged(void) {&#xA;&#xA;  //Potentiometer One&#xA;  int newPotentiometerOneValue = analogRead(A0) / 10.2;   &#xA;  if (newPotentiometerOneValue == lastPotentiometerOneValue) return;&#xA;&#xA;  Serial.print(&quot;!pos1&quot;);&#xA;  Serial.print(newPotentiometerOneValue);&#xA;  Serial.print(&quot;;&quot;);&#xA;  lastPotentiometerOneValue = newPotentiometerOneValue;&#xA;&#xA;  //Potentiometer Two&#xA;  int newPotentiometerTwoValue = analogRead(A1) / 10; &#xA;  if (newPotentiometerTwoValue == lastPotentiometerTwoValue) return;&#xA;&#xA;  Serial.print(&quot;!pos2&quot;);&#xA;  Serial.print(newPotentiometerTwoValue);&#xA;  Serial.print(&quot;;&quot;);&#xA;  lastPotentiometerTwoValue = newPotentiometerTwoValue;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The schematic for my circuit is below (I've left out the code for reading the state of the push-button in my listing above, as that's in a separate method from the method that reads in the potentiometer data):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y3X7R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y3X7R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there seems to be a rather subtle error I'm experiencing. If I turn Potentiometer One, it will display the correct output in the serial monitor. If I turn Potentiometer Two, no value will be displayed. &lt;em&gt;However&lt;/em&gt;, if I remove Potentiometer Two from the circuit board and turn Potentiometer One, then the serial monitor will display the Potentiometer Two as having the same data as Potentiometer Two. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure the problem is with my circuit, but I'm not quite sure what I'm doing wrong. Does anyone have some insight? Thank you! &lt;/p&gt;&#xA;" OwnerUserId="4137" LastActivityDate="2015-09-07T17:41:58.730" Title="Problem with reading multiple potentiometer values on Arduino Uno" Tags="|arduino-uno|serial|potentiometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15891" PostTypeId="2" ParentId="15890" CreationDate="2015-09-07T17:41:58.730" Score="2" Body="&lt;p&gt;One problem is that if the value for pot1 has not changed, the value for pot2 will never be sent, even if it has changed, due to the early return when checking the value of pot1. You could fix this by changing to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readAndSendPotentiometerDataIfChanged(void) {&#xA;&#xA;  //Potentiometer One&#xA;  int newPotentiometerOneValue = analogRead(A0) / 10.2;   &#xA;  if (newPotentiometerOneValue != lastPotentiometerOneValue) {&#xA;      Serial.print(&quot;!pos1&quot;);&#xA;      Serial.print(newPotentiometerOneValue);&#xA;      Serial.print(&quot;;&quot;);&#xA;      lastPotentiometerOneValue = newPotentiometerOneValue;&#xA;  }&#xA;&#xA;  //Potentiometer Two&#xA;  int newPotentiometerTwoValue = analogRead(A1) / 10.2; &#xA;  if (newPotentiometerTwoValue != lastPotentiometerTwoValue) {&#xA;      Serial.print(&quot;!pos2&quot;);&#xA;      Serial.print(newPotentiometerTwoValue);&#xA;      Serial.print(&quot;;&quot;);&#xA;      lastPotentiometerTwoValue = newPotentiometerTwoValue;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11692" LastActivityDate="2015-09-07T17:41:58.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15892" PostTypeId="1" CreationDate="2015-09-07T17:50:49.483" Score="2" ViewCount="157" Body="&lt;p&gt;I'm looking to connect an old GPSlim236 device to my Arduino via serial comms. I have seen references online on how to connect the device but in the data sheet it says TTL level between 3V - 5V.  Does this mean that the GPS can automatically switch between logic level 5V -3V when needed? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link to data sheet for the GPS - &lt;a href=&quot;http://www.holux.com/JCore/UploadFile/3205400.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.holux.com/JCore/UploadFile/3205400.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13242" LastEditorDisplayName="user24204" LastEditDate="2016-09-29T15:39:48.460" LastActivityDate="2016-09-29T15:39:48.460" Title="Arduino GPSlim 236" Tags="|arduino-uno|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15893" PostTypeId="1" AcceptedAnswerId="88216" CreationDate="2015-09-07T19:13:34.227" Score="30" ViewCount="56427" Body="&lt;p&gt;Interfacing an Arduino Uno (uploading etc.) with the Arduino IDE (using the Fedora package) works fine under Fedora 21.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I rather want to use vim + make + vim-quickfix-mode etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preferably via the tools available from the Fedora repositories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume that the IDE calls externals command line utilities for the uploading etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The equivalent to the IDE's serial monitor is probably connecting a terminal emulator (e.g. &lt;code&gt;screen&lt;/code&gt;) to &lt;code&gt;/dev/ttyACM0&lt;/code&gt;, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps there is a good example project one can look at the makefile?&lt;/p&gt;&#xA;" OwnerUserId="13174" LastActivityDate="2022-01-02T11:24:18.283" Title="How to compile, upload and monitor via the Linux command line?" Tags="|compile|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15894" PostTypeId="2" ParentId="15893" CreationDate="2015-09-07T19:40:22.933" Score="6" Body="&lt;p&gt;What you need is a Makefile.  There are a few Makefile projects around for Arduino.  Googling for &quot;Arduino Makefile&quot; returns many results including what looks like a good one on Github: &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sudar/Arduino-Makefile&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compiling from the command line isn't trivial due to the way the Arduino IDE handles libraries.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The equivalent to the IDE's serial monitor is probably connecting a terminal emulator (e.g. screen) to /dev/ttyACM0, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For the serial monitor I would recommend minicom. It is a fully functional terminal emulator (vt102) on the command line.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;minicom -D /dev/ttyACM0 -b 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... for example.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-02T11:20:22.720" LastActivityDate="2016-06-02T11:20:22.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15895" PostTypeId="2" ParentId="15892" CreationDate="2015-09-07T20:34:05.600" Score="1" Body="&lt;p&gt;The datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Power Supply &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;External Voltage: 5VDC +/- 10% &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I take that to mean you supply 5V to it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Later on it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Transmit Data. From organizer to peripheral. (Voltage Level is 3.3V ~ 5.0V)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I presume that means that it will supply (or accept) 3.3V to 5V as a high level, and less than 3.3V as a low level. This is perfectly normal for an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does this mean that the GPS can automatically switch between logic level 5v -3v when needed ? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No I would not read it like that. If you read the datasheet for the Arduino processor chips it states things like an output high is a range of voltages, similar to what this device is saying. A &quot;high&quot; is not necessarily 5V exactly, it might be 4.7V, for example. However the Arduino input pins are similarly designed to take a range of voltages.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My confusion here is that the datasheet says 3-5v but what if I connect the device to a raspberry pi which (I think) only accepts 3v, would it still work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, the datasheet says 5V +/- 10% for charging the internal battery. I'm not sure what your situation is if you are trying to run it from a Pi.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-08T04:05:39.527" LastActivityDate="2015-09-08T04:05:39.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15896" PostTypeId="1" AcceptedAnswerId="15900" CreationDate="2015-09-07T20:34:08.650" Score="1" ViewCount="539" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h&quot; rel=&quot;nofollow&quot;&gt;NeoPixel&lt;/a&gt; Ring from Adafruit and trying to pulse though and array of colors. However, I'm having trouble with having the loop go to the next color at the end of each pulse (end of loop). Here is what I currently have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t color[] = {red, green, blue,yellow,teal,magenta};&#xA;&#xA;void pulseUp(uint8_t speed){&#xA;  int fadeAmount = 10; //how much to increase each loop&#xA;  int n = 0; //get first color&#xA;  for(int b = 100; b &amp;gt;= 10; b = b - fadeAmount) { //start pulse for loop&#xA;    for (int i = 0; i &amp;lt; strip.numPixels(); i++) { //select all pixels&#xA;      strip.setPixelColor(i, color[n]); //set color from our array&#xA;      }&#xA;    strip.setBrightness(b); //set brightness based on b&#xA;    strip.show(); // send the changes to the strip&#xA;    delay(speed); //wait before running again&#xA;    //if at the end of the loop (brightness is 10) change color    &#xA;    if (b == 10){&#xA;      if( n &amp;gt; 6){ //if we are at last color in our loop start over&#xA;        n = 0; &#xA;      }&#xA;      else{ &#xA;        n++; //auto increment color value&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm sure the problem is with the if statements but not sure how to fix it. &lt;/p&gt;&#xA;" OwnerUserId="13210" LastActivityDate="2015-09-07T20:55:55.957" Title="Loop though array values at end of each for loop cycle" Tags="|neopixel|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15897" PostTypeId="1" CreationDate="2015-09-07T20:36:26.997" Score="0" ViewCount="982" Body="&lt;p&gt;How do I best connect with Arduino programmers who are willing to design small projects for some extra cash?&lt;/p&gt;&#xA;" OwnerUserId="13247" LastActivityDate="2019-04-27T08:28:37.197" Title="Arduino programmers for hire?" Tags="|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15898" PostTypeId="2" ParentId="15893" CreationDate="2015-09-07T20:44:36.490" Score="11" Body="&lt;p&gt;I would suggest Googling for Makefile projects. I did one a while back for the Blink program, by basically seeing what got generated by the IDE and replicating that in a more general way.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;&#xA;# where you installed the Arduino app&#xA;ARDUINO_DIR = C:/Documents and Settings/Nick/Desktop/arduino-1.0.6/&#xA;&#xA;# various programs&#xA;CC = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&quot;&#xA;CPP = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&quot;&#xA;AR = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&quot;&#xA;OBJ_COPY = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&quot;&#xA;&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &quot;-I$(ARDUINO_DIR)hardware/arduino/cores/arduino&quot; &quot;-I$(ARDUINO_DIR)hardware/arduino/variants/standard&quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &quot;$(ARDUINO_DIR)hardware/arduino/cores/arduino/&quot;&#xA;&#xA;build:&#xA;&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o&#xA;    rm core.a&#xA;    $(AR) rcs core.a malloc.c.o&#xA;    $(AR) rcs core.a realloc.c.o&#xA;    $(AR) rcs core.a WInterrupts.c.o&#xA;    $(AR) rcs core.a wiring.c.o&#xA;    $(AR) rcs core.a wiring_analog.c.o&#xA;    $(AR) rcs core.a wiring_digital.c.o&#xA;    $(AR) rcs core.a wiring_pulse.c.o&#xA;    $(AR) rcs core.a wiring_shift.c.o&#xA;    $(AR) rcs core.a CDC.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial.cpp.o&#xA;    $(AR) rcs core.a HID.cpp.o&#xA;    $(AR) rcs core.a IPAddress.cpp.o&#xA;    $(AR) rcs core.a main.cpp.o&#xA;    $(AR) rcs core.a new.cpp.o&#xA;    $(AR) rcs core.a Print.cpp.o&#xA;    $(AR) rcs core.a Stream.cpp.o&#xA;    $(AR) rcs core.a Tone.cpp.o&#xA;    $(AR) rcs core.a USBCore.cpp.o&#xA;    $(AR) rcs core.a WMath.cpp.o&#xA;    $(AR) rcs core.a WString.cpp.o&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would need to change &lt;code&gt;ARDUINO_DIR&lt;/code&gt; at least, to reflect where you installed the IDE. If you use other things like the Wire library you would need to expand it somewhat to compile additional libraries. Again, you can use what the IDE generates itself to guide your changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lines with the leading spaces above would need the &lt;strong&gt;tab&lt;/strong&gt; character instead of spaces, as is normal for a Makefile.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-07T20:44:36.490" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15899" PostTypeId="2" ParentId="15897" CreationDate="2015-09-07T20:46:01.840" Score="1" Body="&lt;p&gt;The Arduino Forum has a &lt;a href=&quot;https://forum.arduino.cc/index.php?board=26.0&quot; rel=&quot;nofollow&quot;&gt;Gigs and Collaborations&lt;/a&gt; section where such questions are welcome.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-07T20:46:01.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15900" PostTypeId="2" ParentId="15896" CreationDate="2015-09-07T20:55:55.957" Score="1" Body="&#xA;&#xA;&lt;p&gt;I can't quite make out what your &lt;code&gt;if&lt;/code&gt; test is supposed to be doing, but don't you want a loop within a loop? Like this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;uint32_t color[] = {red, green, blue,yellow,teal,magenta};&#xA;&#xA;void pulseUp(uint8_t speed)&#xA;  {&#xA;  const int fadeAmount = 10; //how much to increase each loop&#xA;  for (int currentColor = 0; currentColor &amp;lt; 6; currentColor++)&#xA;    {&#xA;    for (int i = 0; i &amp;lt; strip.numPixels(); i++)&#xA;      { //select all pixels&#xA;      strip.setPixelColor(i, color[currentColor]); //set color from our array&#xA;      }&#xA;    for(int brightness = 100; brightness &amp;gt;= 10; brightness -= fadeAmount)&#xA;      { //start pulse for loop&#xA;      strip.setBrightness(brightness); //set brightness based on brightness&#xA;      strip.show(); // send the changes to the strip&#xA;      delay(speed); //wait before running again&#xA;      }  // end of brightness loop&#xA;    }  // end of colour loop&#xA;  }  // end of pulseUp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-07T20:55:55.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15903" PostTypeId="1" AcceptedAnswerId="15906" CreationDate="2015-09-08T02:46:18.423" Score="-1" ViewCount="1205" Body="&lt;p&gt;I am trying to interface with a mouse sensor and am not able to get data back.&#xA;&lt;a href=&quot;http://prototypejax.com/datasheets/Agilent%20ADNS-3080.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet link&lt;/a&gt;&#xA;I have it still soldered to the original PCB but have cut the traces to pins 1-4,6,7 (NCS [SS], MISO, SCLK, MOSI, RESET, NPD [power down {set to 3.3v}])&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PLEASE LET ME KNOW IF ANYTHING SEEMS WRONG HERE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the Datasheet, by default the sensor is setup with the pull-up resistors enabled [pg. 29] which enables the open-drain, allowing me to directly connect NCS,MISO,SCLK,MOSI directly to the 5v microcontroller [pg. 15]. This also requires the SPI speed set to 500khz [pg. 10]. RESET is in a (10k)(10k+10k) resistor bridge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI should be set to Mode3 as SCLK is normally high and data should be captured on the rising edge of the clock pulse [pg. 16]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;const int MOUSEVERSION = 0x00; //mouse version&#xA;const int CSmouse = 10;&#xA;const int mouseReset = 2;&#xA;char val;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE3));&#xA;  pinMode(CSmouse, OUTPUT);&#xA;  pinMode(mouseReset, OUTPUT);&#xA;  digitalWrite(CSmouse, HIGH);&#xA;  //pull reset pin high for a half second to make sure mouse is ready to go after powering on [pg. 22]&#xA;  digitalWrite(mouseReset, HIGH);&#xA;  Serial.println(&quot;setup&quot;);&#xA;  delay(500); //half a second&#xA;  digitalWrite(mouseReset, LOW);&#xA;  Serial.println(&quot;end setup&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Start loop&quot;);&#xA;  digitalWrite(CSmouse, LOW); //CS enable&#xA;  SPI.transfer(MOUSEVERSION); //0x00 = read register Product_ID, should reply 0x17&#xA;  delayMicroseconds(75);&#xA;  Serial.println(SPI.transfer(0)); //actually just gives 0&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13251" LastEditorUserId="10794" LastEditDate="2015-09-08T04:17:17.230" LastActivityDate="2015-09-08T04:17:17.230" Title="Arduino Uno and Agilent ADNS-3080 not reading from SPI" Tags="|arduino-uno|c++|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15904" PostTypeId="2" ParentId="4681" CreationDate="2015-09-08T02:56:17.393" Score="3" Body="&lt;p&gt;Is it not that case that &lt;code&gt;setup()&lt;/code&gt; is called once and &lt;code&gt;loop()&lt;/code&gt; is called repeatedly?&#xA;i.e. that there is an &lt;strong&gt;unseen&lt;/strong&gt; &lt;code&gt;main()&lt;/code&gt; which might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void main(){&#xA;  setup();&#xA;  while(True){&#xA;    loop();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Apologies as I'm just looking into the Arduino and have almost no C/C++ experience; I'm trying to get a handle on this &lt;code&gt;loop()&lt;/code&gt; situation myself.&lt;/p&gt;&#xA;" OwnerUserId="13253" LastEditorUserId="13253" LastEditDate="2015-09-17T09:22:21.543" LastActivityDate="2015-09-17T09:22:21.543" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15905" PostTypeId="2" ParentId="501" CreationDate="2015-09-08T03:24:42.523" Score="1" Body="&lt;p&gt;I have used FM antenna cable successfully as soil moisture sensor and as fluid level sensor. Dip the bottom end into melted glue stick to insulate.&#xA;For permanent installation in a water tank I would also dip the cable into a paint tin and hang it up to dry for extra insulation. Antenna cable without any extra waterproofing was used for soil moisture measuring for 3 years with no problems.&#xA;The top end is connected to two parts of a LM393. The first one is a Schmitt trigger with 470K feeback and 1M series. The neg side is fed back with 220K. The second one is simply an inverter, and the output feeds back through a 220K. The two 220ks get connected to the sensor cable, and a parallel 100pf cap.The cable is thus excited differentially.&#xA;The ciruit oscillates according to the capacitance of the sensor cable. The frequency is measured by your favourite micro. The extra 100pf is only there to keep the frequency in a range where the oscillations can be fed over a line. &#xA;A bucket of water is enough to calibrate the setup.&lt;/p&gt;&#xA;" OwnerUserId="13254" LastActivityDate="2015-09-08T03:24:42.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15906" PostTypeId="2" ParentId="15903" CreationDate="2015-09-08T04:16:41.827" Score="0" Body="&lt;p&gt;You have &lt;code&gt;SPI.beginTransaction&lt;/code&gt; but no &lt;code&gt;SPI.begin()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SPI.begin()&lt;/code&gt; is needed to initialize the SPI hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details about SPI at &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI - Serial Peripheral Interface - for Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-08T04:16:41.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15908" PostTypeId="1" CreationDate="2015-09-08T04:24:22.767" Score="2" ViewCount="806" Body="&lt;p&gt;I am looking for a way of defining multiple pins for my RGB strips. Currently the defined variable is set with the pin within it. This works just fine if I only had one RGB strip connected to the Arduino but I have 4 so I will need to define.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently run this code here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;int rgb1 = 18;&#xA;int rgb2 = 17;&#xA;int LEDs = 11;&#xA;int ledFadeTime = 5;&#xA;&#xA;Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(LEDs, rgb1, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(LEDs, rgb2, NEO_GRB + NEO_KHZ800);&#xA;&#xA;void setup() {&#xA;  strip1.begin();&#xA;  strip1.show(); // Initialize all pixels to 'off'&#xA;  strip2.begin();&#xA;  strip2.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  rgbFadeInAndOutStrip1(0, 0, 255, ledFadeTime); // Blue&#xA;  rgbFadeInAndOutStrip2(255, 0, 0, ledFadeTime); // red&#xA;}&#xA;&#xA;void rgbFadeInAndOutStrip1(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  for(uint8_t b = 0; b &amp;lt;255; b++) {&#xA;     for(uint8_t i=0; i &amp;lt; strip1.numPixels(); i++) {&#xA;        strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;&#xA;     strip1.show();&#xA;     delay(wait);&#xA;  };&#xA;&#xA;  for(uint8_t b=255; b &amp;gt; 0; b--) {&#xA;     for(uint8_t i = 0; i &amp;lt; strip1.numPixels(); i++) {&#xA;        strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;     strip1.show();&#xA;     delay(wait);&#xA;  };&#xA;};&#xA;&#xA;void rgbFadeInAndOutStrip2(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  for(uint8_t b = 0; b &amp;lt;255; b++) {&#xA;     for(uint8_t i=0; i &amp;lt; strip2.numPixels(); i++) {&#xA;        strip2.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;&#xA;     strip2.show();&#xA;     delay(wait);&#xA;  };&#xA;&#xA;  for(uint8_t b=255; b &amp;gt; 0; b--) {&#xA;     for(uint8_t i = 0; i &amp;lt; strip2.numPixels(); i++) {&#xA;        strip2.setPixelColor(i, red * b/255, green * b/255, blue * b/255);&#xA;     }&#xA;     strip2.show();&#xA;     delay(wait);&#xA;  };&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which works when trying out just one out of the 2. But when the LEDs fade out it has a pause (i still see a hint of blue on the strip). If i comment all the code out for the second strip2 and run that, it pulses just fine without the hint of blue or the delay to start bright again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could I be doing incorrectly?&lt;/p&gt;&#xA;" OwnerUserId="5133" LastActivityDate="2016-01-09T20:27:17.140" Title="Adafruit_NeoPixel define pin for different setups" Tags="|arduino-ide|arduino-leonardo|adafruit|rgb-led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15909" PostTypeId="2" ParentId="15814" CreationDate="2015-09-08T05:48:27.913" Score="0" Body="&lt;p&gt;I've discovered that there was another program trying to access the Arduino, interfering with the code above and causing corruption of the signal. After terminating the intrusive program, the code worked just fine.&lt;/p&gt;&#xA;" OwnerUserId="13179" LastActivityDate="2015-09-08T05:48:27.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15910" PostTypeId="1" CreationDate="2015-09-08T06:45:42.080" Score="1" ViewCount="2104" Body="&lt;p&gt;Trying to write 2 values coming from &lt;code&gt;analogread(A0)&lt;/code&gt; and &lt;code&gt;analogread(A1)&lt;/code&gt; by &lt;code&gt;EEPROM.write&lt;/code&gt;  and retrieve the values by &lt;code&gt;EEPROM.read&lt;/code&gt;. I tried the following sketch for each write and read. However, could not get the values. Any help please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For writing to EEPROM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROMex.h&amp;gt;&#xA;int addr = 0;&#xA;int array[] = {0, 0};&#xA;char a;&#xA;void setup() {&#xA;}&#xA;void loop() {&#xA;    array[0] = analogRead(0) / 4;&#xA;    array[1] = analogRead(1) / 4;&#xA;    EEPROM.write(addr, a);&#xA;    addr = addr + 1;&#xA;&#xA;    if (addr == 512) {&#xA;        addr = 0;&#xA;    }&#xA;&#xA;    delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For reading from EEPROM is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;int address = 0;&#xA;int value[2];&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;    while (!Serial) {&#xA;        ;&#xA;    }&#xA;}&#xA;void loop() {&#xA;    value = EEPROM.read(address);&#xA;    Serial.print(address);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(value[0]);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(value[1]);&#xA;    Serial.println();&#xA;    address = address + 1;&#xA;&#xA;    if (address == 512) {&#xA;        address == 0;&#xA;    }&#xA;&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4103" LastEditorDisplayName="user24204" LastEditDate="2016-09-29T14:07:45.353" LastActivityDate="2016-09-29T14:07:45.353" Title="How to Store 2 analogRead values and read using EEPROM for Arduino Uno?" Tags="|arduino-uno|c++|analogread|eeprom|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15911" PostTypeId="1" AcceptedAnswerId="15917" CreationDate="2015-09-08T08:06:18.410" Score="2" ViewCount="333" Body="&lt;p&gt;I'm trying to write a library for an accelerometer/magnetometer sensor.  The sensor is a LSM303D chip (&lt;a href=&quot;https://www.pololu.com/file/0J703/LSM303D.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/file/0J703/LSM303D.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written a function, &lt;code&gt;readRegister()&lt;/code&gt; (below) that's supposed to get the data from the sensor.  However, I put in many different registers into the function into the function, but it always returns the same number.  That number changes every time I unplug my Arduino from my computer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte fp::readRegister(byte register_address, int numBytes) {&#xA;  Wire.requestFrom(register_address, numBytes);&#xA;  byte c;&#xA;  Serial.println(Wire.read());&#xA;  while (Wire.available()) {&#xA;    c = Wire.read();&#xA;  }&#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.print(register_address, HEX);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(c);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.println(millis());&#xA;  return c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's an example of the problem output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x8 190 2 &#xA;0x9 190 3&#xA;0xA 190 11&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is something more like what I'd expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x8 193 [time]&#xA;0x9 189 [time]&#xA;0xA 195 [time]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the Git repo with the rest of the code: &lt;a href=&quot;https://github.com/fpdotmonkey/fp_accel&quot; rel=&quot;nofollow&quot;&gt;https://github.com/fpdotmonkey/fp_accel&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for your help.&lt;/p&gt;&#xA;" OwnerUserId="13257" LastEditorUserId="13257" LastEditDate="2015-09-09T04:18:25.917" LastActivityDate="2015-09-10T05:03:22.630" Title="Function not successfully reading sensor registers" Tags="|arduino-uno|sensors|i2c|accelerometer|wire-library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15913" PostTypeId="2" ParentId="15910" CreationDate="2015-09-08T09:19:19.733" Score="0" Body="&lt;p&gt;You write the read value directly to &lt;code&gt;value&lt;/code&gt;, while value is actually and array. Try this instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    value[0] = EEPROM.read(address);&#xA;    value[1] = EEPROM.read(address + 1);&#xA;    Serial.print(address);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(value[0]);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(value[1]);&#xA;    Serial.println();&#xA;    address = address + 2;&#xA;&#xA;    if (address == 512) {&#xA;        address = 0;&#xA;    } // not address==0;&#xA;&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="4143" LastEditDate="2015-09-09T10:24:29.793" LastActivityDate="2015-09-09T10:24:29.793" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="15914" PostTypeId="1" AcceptedAnswerId="15918" CreationDate="2015-09-08T09:44:41.533" Score="2" ViewCount="436" Body="&lt;p&gt;I have an Arduino code which runs decently.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Read in 10-bits Magnetic Encoder AEAT-6010-A06  into Arduino Uno&#xA;// Sampling&#xA;&#xA;// Declarate&#xA;&#xA;const int CSn = 4; // Chip select&#xA;const int CLK = 7; // Clock signal&#xA;const int DO = 8; // Digital Output from the encoder which delivers me a 0 or 1, depending on the bar angle..&#xA;int analogPin = 3;&#xA;int val = 0;&#xA;unsigned int sensorWaarde = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  //Fix de tris&#xA;&#xA;  pinMode(CSn, OUTPUT);&#xA;  pinMode(CLK, OUTPUT);&#xA;  pinMode(DO, INPUT);&#xA;&#xA;  //Let's start here&#xA;  digitalWrite(CLK, HIGH);&#xA;  digitalWrite(CSn, HIGH);&#xA;}&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  val = analogRead(analogPin);&#xA;  // val = val - 670;&#xA;  sensorWaarde = readSensor();&#xA;  delayMicroseconds(1); //Tcs waiting for another read in&#xA;}&#xA;&#xA;unsigned int readSensor() {&#xA;  unsigned int dataOut = 0;&#xA;&#xA;  digitalWrite(CSn, LOW);&#xA;  delayMicroseconds(1); //Waiting for Tclkfe&#xA;&#xA;  //Passing 10 times, from 0 to 9&#xA;  for (int x = 0; x &amp;lt; 10; x++) {&#xA;    digitalWrite(CLK, LOW);&#xA;    delayMicroseconds(1); //Tclk/2&#xA;    digitalWrite(CLK, HIGH);&#xA;    delayMicroseconds(1); //Tdo valid, like Tclk/2&#xA;    dataOut = (dataOut &amp;lt;&amp;lt; 1) | digitalRead(DO); //shift all the entering data to the left and past the pin state to it. 1e bit is MSB&#xA;  }&#xA;&#xA;  digitalWrite(CSn, HIGH); //&#xA;  Serial.print(dataOut);&#xA;  Serial.print(&quot;&quot;);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.println(val);&#xA;  Serial.print(&quot; &quot;);&#xA;&#xA;  delay(2);&#xA;  return dataOut;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the delay data i assumed that i will be having approximately a sampling rate of 500 Hz, however it seems that the sampling rate is approximately 300+- Hz, without a proper confirmation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My system is to be run in a Magnetic Encoder by Avago, but i have difficulties determining the sampling rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, may i know what code should i use to indicate the time and sampling number?&lt;/p&gt;&#xA;" OwnerUserId="13259" LastActivityDate="2015-09-08T10:50:49.487" Title="Sampling rate issue" Tags="|rotary-encoder|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15915" PostTypeId="2" ParentId="15910" CreationDate="2015-09-08T10:10:30.377" Score="1" Body="&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://playground.arduino.cc/Code/EEPROMWriteAnything&quot; rel=&quot;nofollow&quot;&gt;Reading and Writing Data Structures to EEPROM&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;EEPROM.write(addr,a);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't &lt;em&gt;directly&lt;/em&gt; write arrays. See the link for how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;EEPROMAnything.h&amp;gt;&#xA;&#xA;int array[2];&#xA;int addr=0;&#xA;&#xA;void setup()&#xA;{  &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  array[0] = analogRead(0)/4;&#xA;  array[1] = analogRead(1)/4; &#xA;  EEPROM_writeAnything(addr, array);&#xA;  addr += sizeof (array);&#xA;&#xA;  if(addr &amp;gt;= 512)&#xA;    exit (1);&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your posted code is a bit flawed anyway. You know EEPROM has a limited life? If you have a sketch that writes to EEPROM indefinitely you will wear it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code above stops once it reaches address 512.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-08T10:10:30.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15916" PostTypeId="1" CreationDate="2015-09-08T10:11:11.260" Score="2" ViewCount="1669" Body="&lt;p&gt;I have this assignment and I have been tinkering a long time about it. I need to make a simulation of a parking lot where servos would represent the ramps.&lt;br&gt;&lt;br&gt;&#xA;I will be using 2 Arduinos running the same script, one representing the entry ramp and the other one the exit. &#xA;Servos are controlled by reading a json request of an web application and manually by buttons. I have connected two LED's when the buttons are pressed. I would also need to make state when servo would be always up or always down (that would represent the off times of parking lot), should I add extra buttons for that? Any idea would be appreciated.&lt;br&gt;&lt;br&gt;&#xA;The problem I'm having with this project is that servos are not responding well on push buttons. They are shaking and very slow moving. And I think that it isn't a good solution to move the servos while they are sending application request because it can lead to conflict. Please help me there.&lt;br&gt;&lt;br&gt;&#xA;I have written pretty major piece of script, but it still needs adjusments. Any help is welcomed.&#xA;Here is the code: &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;Servo.h&amp;gt;&#xA;#include&amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;Servo myservo;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;char server[] = &quot;ramp-rampcontrol.rhcloud.com&quot;; &#xA;EthernetClient client;&#xA;IPAddress ip(192,168,1,17);&#xA;&#xA;int button_5 = 5;&#xA;int button_6 = 6;&#xA;const int ledPin = 3;&#xA;const int ledPinG = 2;&#xA;int time = 5*1000;&#xA;int val=0;&#xA;String content = &quot;&quot;;&#xA;boolean begin1 = false;&#xA;&#xA;void setup() {&#xA;&#xA;Serial.begin(9600);&#xA;pinMode(button_5, INPUT);&#xA;pinMode(button_6, INPUT);&#xA;pinMode(ledPin, OUTPUT);&#xA;pinMode(ledPinG, OUTPUT);&#xA;myservo.attach(9);&#xA;if (Ethernet.begin(mac) == 0) {&#xA;Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;// no point in carrying on, so do nothing forevermore:&#xA;// try to congifure using IP address instead of DHCP:&#xA;Ethernet.begin(mac, ip);&#xA;}&#xA;// give the Ethernet shield a second to initialize:&#xA;delay(1000);&#xA;Serial.println(&quot;connecting...&quot;);&#xA;&#xA;// if you get a connection, report back via serial:&#xA;if (client.connect(server, 80)) {&#xA;Serial.println(&quot;connected&quot;);&#xA;// Make a HTTP request:&#xA;client.println(&quot;GET /api/actions?parking_id=39 HTTP/1.1&quot;);&#xA;client.println(&quot;Host: ramp-rampcontrol.rhcloud.com&quot;);&#xA;client.println(&quot;Connection: close&quot;);&#xA;client.println();&#xA;}&#xA;else {&#xA;// kf you didn't get a connection to the server:&#xA;Serial.println(&quot;connection failed&quot;);&#xA; }  &#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;&#xA;val = digitalRead(button_5);&#xA;if (val == HIGH)&#xA;{&#xA;  performServoAction(&quot;up&quot;);&#xA;&#xA;      digitalWrite(ledPin, HIGH);&#xA;      delay(1000);&#xA;      digitalWrite(ledPin, LOW);&#xA;      delay(1000);&#xA;&#xA;}&#xA;&#xA;val = digitalRead(button_6);&#xA;if (val == HIGH)&#xA;{&#xA;  performServoAction(&quot;down&quot;);&#xA;&#xA;      digitalWrite(ledPinG, HIGH);&#xA;      delay(1000);&#xA;      digitalWrite(ledPinG, LOW);&#xA;      delay(1000);    &#xA; }&#xA;&#xA; while(client.available()) {&#xA; char c = client.read();   &#xA;    if(c == '{'){&#xA;      begin1 = true;&#xA;    }&#xA;&#xA;  if (begin1) { &#xA;    content += c;&#xA;   }&#xA;&#xA;  if (c == '}') {&#xA;      break; &#xA;    }&#xA; }&#xA;&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;    performAction();&#xA;  }&#xA;  }&#xA;&#xA;bool performServoAction(String action_type) {&#xA;if (action_type == &quot;up&quot;) {&#xA;    Serial.println(&quot;doing up&quot;);&#xA;    myservo.write(95);&#xA;    delay(time);&#xA;   // lastRampStatus = action_type ;&#xA;   // notifyServerAboutAction(&quot;true&quot;, action_id);&#xA;    return true;&#xA;  }&#xA;&#xA;  if (action_type == &quot;down&quot;) {&#xA;    Serial.println(&quot;doing down&quot;);&#xA;    myservo.write(135);&#xA;    delay(time);&#xA;    //lastRampStatus = action_type;&#xA;  // notifyServerAboutAction(&quot;true&quot;, action_id);&#xA;    return true;&#xA;  }&#xA;}&#xA;&#xA; void performAction() {&#xA;  int nstart = content.indexOf(&quot;action_id&quot;) + 12;&#xA;  int nend = content.indexOf(&quot;,&quot;, nstart);&#xA;  String actionID = content.substring(nstart, nend);&#xA;&#xA;    int nstart1 = content.indexOf(&quot;action_type&quot;) + 14;  &#xA;   //Get position of &quot;action_type&quot; in a string, increment by 13 &#xA;    (length of 'action_type&quot;:&quot;')&#xA;    int nend1 = content.indexOf(&quot;\&quot;&quot;, nstart1); // Get next position &#xA;    of '&quot;' starting from nstart&#xA;    String actionType = content.substring(nstart1, nend1); &#xA;    //Return substring between this position&#xA;    performServoAction(actionType);&#xA;    Serial.println(nstart1);&#xA;    Serial.println(nend1);&#xA;    Serial.println(actionID);&#xA;    Serial.println(actionType);&#xA;    Serial.println(content);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10439" LastEditorUserId="4131" LastEditDate="2015-09-09T10:43:42.950" LastActivityDate="2015-09-17T20:41:38.763" Title="Control servo motors with buttons and via web application" Tags="|arduino-uno|led|ethernet|servo|button|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15917" PostTypeId="2" ParentId="15911" CreationDate="2015-09-08T10:19:07.580" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Wire.requestFrom(register_address, numBytes);&#xA;  byte c;&#xA;  Serial.println(Wire.read());&#xA;  while (Wire.available()) {&#xA;    c = Wire.read();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has a number of problems. For one thing your (I presume) debugging print consumes the data from Wire.read, so when you go to get it into c, you have already printed it. In other words, you are reading byte #1 and printing it, but using byte #2. This seems an odd thing to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, what is this doing?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  while (Wire.available()) {&#xA;    c = Wire.read();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are reading an indefinite number of bytes, and retaining the last one. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible rework:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte fp::readRegister(byte register_address, int numBytes) {&#xA;  Wire.requestFrom(register_address, numBytes);&#xA;  byte c = Wire.read()&#xA;  Serial.println(c);&#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.print(register_address, HEX);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(c);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.println(millis());&#xA;  return c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Here is the Git repo with the rest of the code: &lt;a href=&quot;https://github.com/fpdotmonkey/fp_accel&quot; rel=&quot;nofollow&quot;&gt;https://github.com/fpdotmonkey/fp_accel&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From your linked code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  byte xlm = readRegister(fp::OUT_X_L_M, 1);&#xA;  byte xhm = readRegister(fp::OUT_X_H_M, 1);&#xA;  byte ylm = readRegister(fp::OUT_Y_L_M, 1);&#xA;  byte yhm = readRegister(fp::OUT_Y_H_M, 1);&#xA;  byte zlm = readRegister(fp::OUT_Z_L_M, 1);&#xA;  byte zhm = readRegister(fp::OUT_Z_H_M, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have the wrong end of the stick here.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Wire.requestFrom(register_address, numBytes);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You request from the &lt;strong&gt;I2C address&lt;/strong&gt; - that is the device address. The register is something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Judging by the datasheet you first have to send the register address, and then request the data. Something along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte fp::readRegister(byte register_address, int numBytes) {&#xA;  Wire.beginTransmission (DEVICE_ADDRESS);&#xA;  Wire.write (register_address);&#xA;  Wire.endTransmission (false);  // repeated start&#xA;  Wire.requestFrom(DEVICE_ADDRESS, 1);&#xA;  byte c = Wire.read()&#xA;  Serial.println(c);&#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.print(register_address, HEX);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(c);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.println(millis());&#xA;  return c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly for writing to a register:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void fp::writeRegister(byte register_address, byte val) {&#xA;  Wire.beginTransmission(DEVICE_ADDRESS);&#xA;  Wire.write (register_address);&#xA;  Wire.write(val);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is untested because I don't have the device here, but I know that what you had won't work. To check the actual device address run the &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C scanner&lt;/a&gt; I mentioned before.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-10T05:03:22.630" LastActivityDate="2015-09-10T05:03:22.630" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="15918" PostTypeId="2" ParentId="15914" CreationDate="2015-09-08T10:43:34.303" Score="3" Body="&#xA;&#xA;&lt;p&gt;At 115200 baud your serial prints will take 1/11520 seconds per byte.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.print(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does that do?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I count 14 bytes here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Serial.print(dataOut);  // 5 bytes, say&#xA;  Serial.print(&quot;&quot;);       // zero bytes, lol&#xA;  Serial.print(&quot; &quot;);      // one byte&#xA;  Serial.println(val);    // 5 bytes + cr/lf = 7 bytes&#xA;  Serial.print(&quot; &quot;);      // 1 byte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Multiply 1/11520 (0.0000868) by 14 and you get 1215 µs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now add in your delays: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  delay(2);  // 2000 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; for (int x = 0; x &amp;lt; 10; x++) {&#xA;    ...&#xA;    delayMicroseconds(1); //Tclk/2&#xA;    ...&#xA;    delayMicroseconds(1); //Tdo valid, like Tclk/2&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another 20 µs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  val = analogRead(analogPin);   // 104 µs&#xA;  ...&#xA;  delayMicroseconds(1); // 1 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Total:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;1215 + 2000 + 20 + 104 + 1 = 3340 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inverse:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;1 / 0.003340 = 299&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So yes, I would expect around 299 iterations per second. That isn't counting the time for the other code to execute.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Suggestions&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Get rid of the serial prints&lt;/li&gt;&#xA;&lt;li&gt;Get rid of &lt;code&gt;delay(2)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-08T10:50:49.487" LastActivityDate="2015-09-08T10:50:49.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15919" PostTypeId="1" CreationDate="2015-09-08T12:11:37.767" Score="1" ViewCount="354" Body="&lt;p&gt;Why when I press the reset button it takes 2 second before I see my sketch start? &#xA;The model of Arduino is UNO, and the text in serial communication. &lt;/p&gt;&#xA;" OwnerUserId="13265" LastEditorUserId="10794" LastEditDate="2015-09-08T22:58:53.183" LastActivityDate="2015-09-08T22:58:53.183" Title="Why when I press the reset button" Tags="|arduino-uno|serial|bootloader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15920" PostTypeId="2" ParentId="15919" CreationDate="2015-09-08T12:55:25.933" Score="3" Body="&lt;p&gt;Because first the bootloader is executed and takes 2 seconds (or more on a Leonardo) to time out when it doesn't receive a proper response from the computer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-08T12:55:25.933" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15921" PostTypeId="1" AcceptedAnswerId="15929" CreationDate="2015-09-08T17:07:34.457" Score="1" ViewCount="1400" Body="&lt;p&gt;I am trying to get an Arduino Mini (R5, mega 328p) working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just connecting it to power has following effect: the on-board LED lights up. It's the power-on-led, I presume.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since other Arduino devices often come with the blink-example pre-flashed I hooked up a LED to pin 13 - result: no blinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Curiously, connecting the LED to pin 12: blinking&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the Mini come pre-flashed with a blink 'sketch' that blinks pin 12 instead of 13?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test uploading I've connected it to an Arduino USB2Serial module. The module is labeled with 'made in Italy' and has printed 'USB2SERIAL LIGHT' on it where the LIGHT is overwritten with a blue marker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected it like described in the &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoMini&quot; rel=&quot;nofollow&quot;&gt;arduino mini guide&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the IDE I've selected the board 'Arduino Mini' and the '328' CPU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, uploading fails with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The external reset is connected like in the guide. But I also tried to manually press the reset button (immediately before the upload, or long press and release after upload button is clicked). Still, the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the manual reset is pressed the pin-12-blinking stops for a while (perhaps the bootloader is then executed) but then starts again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino2serial has 3 LEDs. The ON-LED lights up when connected to the USB. When hitting the upload button in the IDE, the RX-LED flashed shortly one time after a while. That's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus my question: How to I troubleshoot this? Can I test the arduino usb2serial on its own? What's up with the pin-12 blinking of the mini?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case this matters, I am on Fedora Linux, uploading to other Arduino devices (Uno, Micro) works as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update usb2serial&lt;/strong&gt;: I just hooked up the Arduino usb2serial and connected the TX/RX pins via a jumper cable - a minicom session then results in text being displayed and the rapid flashing of the RX/TX LEDs. Disconnecting RX/TX again shows no display of any text inside minicom, and no flashing of the RX/TX LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used following command line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ minicom -D /dev/ttyACM0 -b 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, the usb2serial module seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update:&lt;/strong&gt; I've checked all the jumper cables and there was a faulty one. With that replaced flashing works. After hitting the reset-button. The 'ext reset' pin is connected but the remote-reset does seem to work. Anyways, hitting the reset-button is easy-enough, for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;final update:&lt;/strong&gt; The root cause for remote-reset (a.k.a. auto reset) that the capacity of the used capacitor was too small. After exchanging it with a 100 nF one (as specified in the guide) the remote-reset works as expected. That means just hitting the upload button in the IDE automatically resets the device and the sketch is uploaded.&lt;/p&gt;&#xA;" OwnerUserId="13174" LastEditorUserId="13174" LastEditDate="2015-09-09T07:02:18.620" LastActivityDate="2015-09-09T07:05:03.887" Title="How to troubleshoot the Arduino Mini and Arduino usb2serial?" Tags="|serial|arduino-mini|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15922" PostTypeId="1" AcceptedAnswerId="15932" CreationDate="2015-09-08T17:36:58.913" Score="0" ViewCount="1357" Body="&lt;p&gt;I just bought a new Arduino Leonardo Eth, and, it was working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I probably uploaded about 30 different sketches, and it did everything as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic sketch was using the fade demo on pin 9 to ground with a LED attached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was then curious on how long the unit takes to restart, so, I unplugged the USB and put it back in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it started back up, the LED was on solid. I then restarted it again, and I honestly can't remember the state of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug it in, it gets detected in the Arduino application and I see the port, but, after about 20 seconds, I get a popup on Windows saying about a malfunctioning USB device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pressing reset on the Arduino or unplugging/plugging it back does the same - I get about 20 seconds, and then it &quot;goes bad&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I am real quick in the IDE, or press restart after compiling/before upload, it just hangs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm really annoyed with myself if I did break it, but, I'm not really sure what else I could have done differently... after all, there isn't an off switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what I have done, and, is there anyway to fix it?&lt;/p&gt;&#xA;" OwnerUserId="11740" LastActivityDate="2015-09-09T20:41:00.380" Title="Did I break my new Arduino Leonardo Eth by restarting it?" Tags="|arduino-leonardo|uploading|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15923" PostTypeId="1" AcceptedAnswerId="15925" CreationDate="2015-09-08T19:26:16.540" Score="3" ViewCount="145" Body="&lt;p&gt;I wrote an interface to a radio about 1-year ago. I have since rebuilt that machine. Is there any way to retrieve the code. Now I do not expect it to be sources code.&#xA;I know the radio code still works as I tried it the other day. Part of the problem is that I am using about 30 wires all on the rear end of the card&#xA;and  have to figure out which pins that they go to in my radio. My interface has two DB25 connectors. And the decoder 2 of 5 negative going signals.  &lt;/p&gt;&#xA;" OwnerUserId="3379" LastActivityDate="2015-09-08T19:39:33.647" Title="Lost Source Sketch" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15924" PostTypeId="1" CreationDate="2015-09-08T19:27:45.867" Score="1" ViewCount="1280" Body="&lt;p&gt;I want to create a Wi-Fi hotspot and redirect all connections to a custom login page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if the Arduino Yún is a good choice in this case?&lt;/p&gt;&#xA;" OwnerUserId="13269" LastEditorUserId="6936" LastEditDate="2016-02-21T08:00:03.037" LastActivityDate="2016-02-21T08:00:03.037" Title="Arduino for Wi-Fi hotspot?" Tags="|arduino-yun|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15925" PostTypeId="2" ParentId="15923" CreationDate="2015-09-08T19:39:33.647" Score="1" Body="&lt;p&gt;Asusming the lock bits on the MCU haven't been set, you can use avrdude to download the contents of flash and EEPROM to your system. From there you can use avr-objdump to disassemble the .hex file and try to figure out how it works. I recommend looking at the disassembly of a .elf file from a current project as well as having both the avr-gcc and avr-libc documentation as well as the ATmegaXXX0 datasheet close at hand at all times.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-08T19:39:33.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15926" PostTypeId="1" AcceptedAnswerId="15927" CreationDate="2015-09-08T19:51:24.563" Score="1" ViewCount="266" Body="&lt;p&gt;I want to run an atmega328 on a breadboard at 2MHz and upload to it via the serial pins (pins 2 and 3). So I am setting the clock divide by 8 fuse bit to enable this, meaning the atmega runs at 2MHz eith the 16MHz crystal. But I can't upload, probably because the bootloader is not expecting the clock to be running at 2MHz. The baud rates are probably mismatched by 8 times, the IDE is trying to upload at 57600 but since the bootloader code is not aware its being clocked at 2MHz, its probably running 8 times too slow. I've messed around a bit with the arduino conf files changing baud rates but had no joy. I was wondering if anyone knows how to do this off the top of their head.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, Pete&lt;/p&gt;&#xA;" OwnerUserId="13270" LastActivityDate="2015-09-08T20:00:36.047" Title="Uploading to atmega328 over serial with arduino bootloader running at 2MHz" Tags="|atmega328|bootloader|frequency|fuses|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15927" PostTypeId="2" ParentId="15926" CreationDate="2015-09-08T20:00:36.047" Score="2" Body="&lt;p&gt;Unprogram the CKDIV8 fuse and add the following to the sketch instead, near the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;void setprescaler(void) __attribute__ ((naked)) \&#xA;  __attribute__ ((section(&quot;.init1&quot;)));&#xA;&#xA;void setprescaler(void)&#xA;{&#xA;  clock_prescale_set(clock_div_8);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will do essentially the same thing as the fuse, but won't interfere with the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-08T20:00:36.047" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="15929" PostTypeId="2" ParentId="15921" CreationDate="2015-09-08T20:20:49.470" Score="0" Body="&lt;p&gt;As always, it makes sense to check the parts in isolation, if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Host system (Linux):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tail the system log for errors&lt;/li&gt;&#xA;&lt;li&gt;Check that ModemManager does not occupies the &lt;code&gt;/dev/ttyACM0&lt;/code&gt; device&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;USB2Serial:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connect it via USB to the host without anything else connected -&gt; the ON-LED should be on, the RX/TX LEDs should be off, the system log should display some udev progress messages (including vendor ids), the system should have a new serial device, e.g. &lt;code&gt;/dev/ttyACM0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open the serial port with a terminal (e.g. via &lt;code&gt;minicom -D /dev/ttyACM0 [-b baudrate]&lt;/code&gt;, disable local echo and type something -&gt; nothing should be displayed&lt;/li&gt;&#xA;&lt;li&gt;Connect the RX/TX pins to each other with a jumper cable -&gt; typing in the terminal session should now result in rapid flashing of the TX/RX LEDs and the echoing of the text&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Arduino Mini:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connect just the minimum, e.g. just power from a 9V battery/5V power supply and the reset pin to +5 (with a 10KOhm resistor in series) -&gt; the power-on led should turn on&lt;/li&gt;&#xA;&lt;li&gt;The chance is high that the device comes with a pre-flashed blink examples that either uses pin 12 or 13 -&gt; connect external LEDs to pin 12 and 13 (in series with 220 Ohm resistors) -&gt; one LED blinks after power on&lt;/li&gt;&#xA;&lt;li&gt;Hit the reset button on the mini -&gt; any LED blinking should stop for a while and then continue&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Arduino Mini with USB2Serial:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure that both RX/TX pairs are crosslinked (like a nullmodem cable), i.e. RX &amp;lt;-&gt; TX and TX &amp;lt;-&gt; RX.&lt;/li&gt;&#xA;&lt;li&gt;Follow the mini guide on &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoMini&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; or &lt;a href=&quot;http://labs.arduino.org/Getting+Started+with+Arduino+Mini&quot; rel=&quot;nofollow&quot;&gt;arduino.org&lt;/a&gt; it includes a picture of the cabling&lt;/li&gt;&#xA;&lt;li&gt;Verify that the capacitor connected between the USB2Serial 'ext reset' pin and the Mini reset pin has a capacity of 100 nF, otherwise, the auto-reset might not work&lt;/li&gt;&#xA;&lt;li&gt;In case the automatic reset does not work, press the on-board-reset-button just before the upload&lt;/li&gt;&#xA;&lt;li&gt;In case the error persists, check for dodgy cables with a multi-meter&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;IDE:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure that it works with 'easier' stuff, e.g. flashing to a Uno (the Uno is easier because the USB-2-Serial part is integrated)&lt;/li&gt;&#xA;&lt;li&gt;Enable verbose logging during upload (in the preferences)&lt;/li&gt;&#xA;&lt;li&gt;Update the IDE in case it is very old&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13174" LastEditorUserId="13174" LastEditDate="2015-09-09T07:05:03.887" LastActivityDate="2015-09-09T07:05:03.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15930" PostTypeId="1" AcceptedAnswerId="15931" CreationDate="2015-09-08T20:26:12.143" Score="1" ViewCount="175" Body="&lt;p&gt;I've got a little proof of concept thing going here with an arduino &amp;amp; Ethernet shield. The basic idea is for it to ping out much like a heartbeat monitor every so often so I can see if my house still has internet connectivity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino works nicely and does exactly what I want. I've ordered a board to be made with just the basic components needed and now want to put the code on to it. They gave me an option to load the code (Dragon AVR) during checkout and I'd love to try that out. So, the question is - how on earth do I package up code for something like that? I've seen a number of people ask the same thing for large manufacturing scales / similar setup where they don't fancy using the arduino &amp;amp; IDE as a programmer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've asked around on IRC and various other places but nobody seems to be able to give me specific and clear advice on whether it's possible and how to go about doing it. &lt;/p&gt;&#xA;" OwnerUserId="13271" LastActivityDate="2015-09-08T20:38:06.470" Title="Going from arduino &amp; sketch to production" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15931" PostTypeId="2" ParentId="15930" CreationDate="2015-09-08T20:38:06.470" Score="3" Body="&lt;p&gt;&quot;Intel Hex&quot; is pretty much an industry standard and I'm quite certain the .hex files produced by the GNU AVR tools is Intel Hex format. Your vendor is almost certainly prepared to load your sketch from the .hex file.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-08T20:38:06.470" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="15932" PostTypeId="2" ParentId="15922" CreationDate="2015-09-08T22:19:12.320" Score="1" Body="&lt;p&gt;You should be able to use my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow noreferrer&quot;&gt;board detector&lt;/a&gt; sketch on one of your other Arduinos to check out the problem board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also my &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;bootloader uploader&lt;/a&gt; sketch will reflash bootloaders on quite a few devices. I'm assuming that the &quot;Arduino Leonardo Eth&quot; has the same bootloader as the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hmmm - I see that the &quot;Arduino Leonardo Eth&quot; is from Arduino.org, not Arduino.cc. The bootloader is probably slightly different. I'm really not an expert on what those boards use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Before worrying too much, try the approach of holding down Reset and then uploading a sketch, letting go of Reset as the sketch starts to actually upload.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Comment by William Hilsum&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I didn't realise there was a difference between .org and .cc, and, I guess by using the leonardo template from .cc, I broke &quot;something&quot;. The moment I downloaded the IDE from .org, &amp;amp; uploaded with the eth template , it worked flawlessly. I guess there are some changes between leonardo and leonardo eth. I wanted an arduino with ethernet, so I didn't need a separate shield. No idea if I picked the right &quot;side&quot; after reading all the crap with cc vs org! &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is very annoying that the split of the Arduino camps now produces a support nightmare for people who just want to use their virtually identical products, but have to go through this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the update.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-09-09T20:41:00.380" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="15933" PostTypeId="1" CreationDate="2015-09-08T22:42:40.003" Score="3" ViewCount="2721" Body="&lt;p&gt;How I can find the data field on oscilloscope at 300 baud or at 9600 baud? &#xA;Could someone show me picture on oscilloscope plase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the picture &lt;a href=&quot;https://i.stack.imgur.com/EvCSC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EvCSC.jpg&quot; alt=&quot;Oscilloscope image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;at 9600 Baud&lt;/p&gt;&#xA;" OwnerUserId="13265" LastEditorUserId="10794" LastEditDate="2015-09-09T23:35:00.310" LastActivityDate="2015-09-09T23:43:44.703" Title="What does serial data look like on an oscilloscope?" Tags="|arduino-uno|serial|baud-rate|rs232|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15934" PostTypeId="2" ParentId="15933" CreationDate="2015-09-08T23:11:05.500" Score="4" Body="&lt;p&gt;I had these images lying around so here is an example of &quot;Fab&quot; being sent at 9600 baud:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sJ7kd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sJ7kd.png&quot; alt=&quot;RS232 - 3 letters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now a single byte (the letter &quot;F&quot;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T6R1D.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T6R1D.png&quot; alt=&quot;RS232 - one byte&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;A - no data (Tx is high)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;B - The &quot;start bit&quot;. The line is taken low to tell the receiver that a character (byte) is commencing to be sent. The receiver waits for one and a half clock times before sampling the line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;C - First character arrives (the letter &quot;F&quot; or 0x46 or 0b01000110). There is no clock bit as such, the incoming data is simply sampled at the baud (transmission) rate. In contrast to SPI communication the data arrives least-significant bit first (in case you are not sending 8 bits per byte). Thus we see 01100010 (rather than 01000110).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;D - The stop bit. This is always high, to ensure that we can distinguish between the end of this byte, and the start of the next one. Since the start bit is a zero, and the stop bit is a one, there is always a clear transition from one byte to the next.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;E - The start bit for the next character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The time for one bit is shown on the logic analyzer as 0.1041667 ms (that is, 0.0001041667 seconds). This agrees with the inverse of the baud rate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 / 9600 bits per second = 0.0001041667 seconds per bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Looking at your photo, my guess is you have inverted logic here. That is, RS232 levels (where 5V is a 0-bit and 0V is a 1-bit). Thus (and this is a guess because all the bytes are close together):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mQOaS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mQOaS.jpg&quot; alt=&quot;One RS232 byte&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I marked the start and stop bits, and put a dot for each bit inbetween.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://arduino.stackexchange.com/questions/1569/what-is-serial-begin9600/&quot;&gt;What is Serial.begin(9600)?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-09-09T23:43:44.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15935" PostTypeId="1" CreationDate="2015-09-08T07:59:07.670" Score="1" ViewCount="719" Body="&lt;p&gt;I need help developing a simple sketch that can read data simultaneously from 3 analog accelerometers and send it in 'burst mode' to be stored on an SD card, to reduce the effect of latency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;a href=&quot;http://github.com/jeroendoggen/Arduino-MMA7361-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;this library&lt;/a&gt; to get my accelerometers to work properly, but I'm just having difficulty coming up with a sketch in the code to getting all the acceleration data out in bursts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your help will be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I meant by 'burst mode' is that all acceleration data from all three sensors connected to the Arduino should be saved at once to the file on the SD card (a temporary measure, as I'll have to send this data via Bluetooth to a base station as I build the system up to be able to receive more data from multiple Arduinos).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although there would be a delay of about 1/10th of a second between each reading from the three sensors, the idea behind it is to be able to read and write off the data in this said simultaneous burst mode at a high sample rate (this will be adjusted with an oscilloscope at a later stage) to prevent data from being lost or chunked up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a &lt;a href=&quot;http://www.freescale.com/files/sensors/doc/data_sheet/MMA7361L.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;link to the datasheet&lt;/a&gt; as requested.&lt;/p&gt;&#xA;" OwnerUserId="13285" OwnerDisplayName="dragondada" LastEditorUserId="4628" LastEditDate="2018-04-16T16:21:56.553" LastActivityDate="2021-07-30T09:00:20.027" Title="Writing data from multiple sensors in burst mode to an Arduino Due" Tags="|sensors|bluetooth|arduino-due|sd-card|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15936" PostTypeId="1" AcceptedAnswerId="15937" CreationDate="2015-09-09T03:15:53.653" Score="15" ViewCount="4986" Body="&lt;p&gt;When I upload a new sketch to my Arduino Uno using the Optiboot bootloader, what &lt;em&gt;really&lt;/em&gt; happens?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What is sent to the Arduino?&lt;/li&gt;&#xA;&lt;li&gt;How does it respond?&lt;/li&gt;&#xA;&lt;li&gt;What does &quot;not in sync mean&quot;?&lt;/li&gt;&#xA;&lt;li&gt;What is &quot;in sync&quot; anyway?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note: This is intended as a &quot;reference question&quot;&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2018-09-27T16:09:18.420" Title="What happens when code is uploaded using the bootloader?" Tags="|arduino-uno|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15937" PostTypeId="2" ParentId="15936" CreationDate="2015-09-09T03:15:53.653" Score="22" Body="&lt;p&gt;When you reset a Uno running the Optiboot loader, the bootloader first flashes pin 13 three times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/py9om.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/py9om.png&quot; alt=&quot;Pin 13 being flashed&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Top line (gray) is sent &lt;strong&gt;to&lt;/strong&gt; the Arduino, middle line (orange) is sent &lt;strong&gt;from&lt;/strong&gt; the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While that is happening, the program &lt;code&gt;avrdude&lt;/code&gt; running on your computer is sending a query to the device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STK_GET_SYNC / CRC_EOP  (0x30/0x20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino doesn't notice the first &quot;get sync&quot; because it is busy flashing pin 13. Once it is done it notices the &quot;get sync&quot; (it would be buffered by the serial hardware) and replies:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STK_INSYNC / STK_OK (0x14/0x10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like avrdude got a bit impatient, and timed out, because it tries again with the &quot;get sync&quot; query. This time Optiboot responds immediately.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The rest of the uploading is described in the next image. Example produced uploading the stock &quot;Blink&quot; program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9htH8.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9htH8.png&quot; alt=&quot;Optiboot upload process&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Click on the image above for a larger version)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The steps are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Query: Get Sync? Reply: In Sync.&lt;/li&gt;&#xA;&lt;li&gt;Query: Get parameter? (major version) Reply: version 4.&lt;/li&gt;&#xA;&lt;li&gt;Query: Get parameter? (minor version) Reply: version 4.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set device parameters. The following device parameters are sent to the chip:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x42  // STK_SET_DEVICE&#xA;0x86  // device code&#xA;0x00  // revision&#xA;0x00  // progtype: “0” – Both Parallel/High-voltage and Serial mode&#xA;0x01  // parmode: “1” – Full parallel interface&#xA;0x01  // polling: “1” – Polling may be used&#xA;0x01  // selftimed: “1” – Self timed&#xA;0x01  // lockbytes: Number of Lock bytes.&#xA;0x03  // fusebytes: Number of Fuse bytes&#xA;0xFF  // flashpollval1&#xA;0xFF  // flashpollval2&#xA;0xFF  // eeprompollval1&#xA;0xFF  // eeprompollval2&#xA;0x00  // pagesizehigh&#xA;0x80  // pagesizelow&#xA;0x04  // eepromsizehigh&#xA;0x00  // eepromsizelow&#xA;0x00  // flashsize4&#xA;0x00  // flashsize3&#xA;0x80  // flashsize2&#xA;0x00  // flashsize1&#xA;0x20  // Sync_CRC_EOP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Optiboot &lt;strong&gt;ignores all those&lt;/strong&gt; and replies with In Sync/OK. :)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Set extended device parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x45  // STK_SET_DEVICE_EXT&#xA;0x05  // commandsize: how many bytes follow&#xA;0x04  // eeprompagesize: EEPROM page size in bytes.&#xA;0xD7  // signalpagel: &#xA;0xC2  // signalbs2: &#xA;0x00  // ResetDisable: Defines whether a part has RSTDSBL Fuse &#xA;0x20  // Sync_CRC_EOP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Optiboot &lt;strong&gt;ignores all those&lt;/strong&gt; as well and replies with In Sync/OK.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Enter program mode. Reply: In Sync/OK.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read signature. Optiboot replies with &lt;code&gt;0x1E 0x95 0x0F&lt;/code&gt; &lt;strong&gt;without actually reading the signature&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Write fuses (four times). Optiboot &lt;strong&gt;does not write the fuse&lt;/strong&gt; but just replies In Sync/OK.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Load address (initially 0x0000). The address is in words (ie. a word is two bytes). This sets the address for where the next page of data will be written.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Program page (up to 128 bytes are sent). Optiboot replies &quot;In Sync&quot; immediately. Then there is a pause of about 4 ms while it actually programs the page. Then it replies &quot;OK&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Load address (now 0x0040). This is address 64 in decimal, ie. 128 bytes from the start of program memory.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another page is written. This sequence continues until all the pages are written.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Load address (back to 0x0000). This is for verifying the write.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read page (up to 128 bytes are read). This is for verifying. Note that even if the verify fails, the bad data has already been written to the chip.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Leave programming mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;What does &quot;not in sync&quot; mean?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As you can see from the above, every step through the programming sequence the Arduino is expected to reply with &quot;In Sync&quot; (0x14), possibly followed by some data, followed by &quot;OK&quot; (0x10). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is &quot;not in sync&quot; that means that avrdude did not get the &quot;in sync&quot; response. Possible reasons could be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Wrong baud rate used &lt;/li&gt;&#xA;&lt;li&gt;Wrong serial port selected in IDE&lt;/li&gt;&#xA;&lt;li&gt;Wrong board type selected in IDE&lt;/li&gt;&#xA;&lt;li&gt;No bootloader installed&lt;/li&gt;&#xA;&lt;li&gt;Wrong bootloader installed&lt;/li&gt;&#xA;&lt;li&gt;Board not configured to use the bootloader (in the fuses)&lt;/li&gt;&#xA;&lt;li&gt;Some device plugged into pins D0 and D1 on the Arduino, interfering with serial commications&lt;/li&gt;&#xA;&lt;li&gt;The USB interface chip (ATmega16U2) not working properly&lt;/li&gt;&#xA;&lt;li&gt;Wrong clock for the board&lt;/li&gt;&#xA;&lt;li&gt;Wrong fuse settings on the Atmega328P (eg. &quot;divide clock by 8&quot;)&lt;/li&gt;&#xA;&lt;li&gt;Board/chip damaged&lt;/li&gt;&#xA;&lt;li&gt;Faulty USB cable (some USB cables provide power only, and are not for data, eg. cheap cables for USB fans)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;What is &quot;in sync&quot;?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As mentioned above, the response &quot;In sync&quot; means that the Arduino (bootloader) is synchronised with the uploading program.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;What protocol is being used?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The protocol is the STK500 protocol as documented by Atmel. See the references below.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/Optiboot/optiboot&quot; rel=&quot;noreferrer&quot;&gt;Optiboot source code - GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc2525.pdf&quot; rel=&quot;noreferrer&quot;&gt;AVR061: STK500 Communication Protocol&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc2591.pdf&quot; rel=&quot;noreferrer&quot;&gt;AVR068: STK500 Communication Protocol version 2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://savannah.nongnu.org/projects/avrdude&quot; rel=&quot;noreferrer&quot;&gt;AVR Downloader/UploaDEr - avrdude&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: STK500 Version 2 is not used in Optiboot, but it is included for information in case you are using boards like the Mega2560.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;h2&gt;STK500 constants&lt;/h2&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/* STK500 constants list, from AVRDUDE */&#xA;#define STK_OK              0x10&#xA;#define STK_FAILED          0x11  // Not used&#xA;#define STK_UNKNOWN         0x12  // Not used&#xA;#define STK_NODEVICE        0x13  // Not used&#xA;#define STK_INSYNC          0x14  // ' '&#xA;#define STK_NOSYNC          0x15  // Not used&#xA;#define ADC_CHANNEL_ERROR   0x16  // Not used&#xA;#define ADC_MEASURE_OK      0x17  // Not used&#xA;#define PWM_CHANNEL_ERROR   0x18  // Not used&#xA;#define PWM_ADJUST_OK       0x19  // Not used&#xA;#define CRC_EOP             0x20  // 'SPACE'&#xA;#define STK_GET_SYNC        0x30  // '0'&#xA;#define STK_GET_SIGN_ON     0x31  // '1'&#xA;#define STK_SET_PARAMETER   0x40  // '@'&#xA;#define STK_GET_PARAMETER   0x41  // 'A'&#xA;#define STK_SET_DEVICE      0x42  // 'B'&#xA;#define STK_SET_DEVICE_EXT  0x45  // 'E'&#xA;#define STK_ENTER_PROGMODE  0x50  // 'P'&#xA;#define STK_LEAVE_PROGMODE  0x51  // 'Q'&#xA;#define STK_CHIP_ERASE      0x52  // 'R'&#xA;#define STK_CHECK_AUTOINC   0x53  // 'S'&#xA;#define STK_LOAD_ADDRESS    0x55  // 'U'&#xA;#define STK_UNIVERSAL       0x56  // 'V'&#xA;#define STK_PROG_FLASH      0x60  // '`'&#xA;#define STK_PROG_DATA       0x61  // 'a'&#xA;#define STK_PROG_FUSE       0x62  // 'b'&#xA;#define STK_PROG_LOCK       0x63  // 'c'&#xA;#define STK_PROG_PAGE       0x64  // 'd'&#xA;#define STK_PROG_FUSE_EXT   0x65  // 'e'&#xA;#define STK_READ_FLASH      0x70  // 'p'&#xA;#define STK_READ_DATA       0x71  // 'q'&#xA;#define STK_READ_FUSE       0x72  // 'r'&#xA;#define STK_READ_LOCK       0x73  // 's'&#xA;#define STK_READ_PAGE       0x74  // 't'&#xA;#define STK_READ_SIGN       0x75  // 'u'&#xA;#define STK_READ_OSCCAL     0x76  // 'v'&#xA;#define STK_READ_FUSE_EXT   0x77  // 'w'&#xA;#define STK_READ_OSCCAL_EXT 0x78  // 'x'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2018-02-07T02:42:43.790" LastActivityDate="2018-02-07T02:42:43.790" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15938" PostTypeId="2" ParentId="15924" CreationDate="2015-09-09T08:56:02.973" Score="2" Body="&lt;p&gt;Better use a regular router and flash DD-WRT or OpenWRT to it (check the supported router list on their websites). Next use something like NoCatSplash, to create a captive portal with login. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;Arduino's just are not fast enough for this.&lt;/strike&gt; Arduino Yuns are typically more expensive.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-09-09T15:28:49.570" LastActivityDate="2015-09-09T15:28:49.570" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15939" PostTypeId="1" CreationDate="2015-09-09T12:12:04.323" Score="0" ViewCount="476" Body="&lt;p&gt;As a PIN goes high I need to trigger an event that will send the IP or MAC of the arduino and the PIN state over the wired Ethernet to a local computer. I am using an Ethernet shield to send and receive from the arduino but I am stumped on how to send and process the information at the PC. I will have 42 Arduinos on the network all set to send PIN information over the wired Ethernet. Sounds simple but after a days research I am now looking at other solutions.  I currently have the faithful Uno with the network shield as my prototype. For the final install I can purchase any of the arduino range like the Yun,Duo etc. if this would help. Any direction would be welcomed. &lt;/p&gt;&#xA;" OwnerUserId="13282" LastActivityDate="2015-09-09T20:16:33.370" Title="How do I send an arduino PIN state to a local PC using the ethernet connection?" Tags="|arduino-uno|programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15940" PostTypeId="2" ParentId="14707" CreationDate="2015-09-09T12:46:42.280" Score="0" Body="&lt;p&gt;I add another answer because I think I found something. After a few days searching on various sites that sell arduino stuff I found this &lt;a href=&quot;http://www.dx.com/p/8-channel-5v-relay-module-extension-board-for-arduino-avr-arm-51-140703&quot; rel=&quot;nofollow&quot;&gt;http://www.dx.com/p/8-channel-5v-relay-module-extension-board-for-arduino-avr-arm-51-140703&lt;/a&gt; that might be what you're looking for. One of the customers in the review states it can be used even without Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know it's a relay, not a dimmer, but maybe you could add something to your circuit...&lt;/p&gt;&#xA;" OwnerUserId="12102" LastActivityDate="2015-09-09T12:46:42.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15941" PostTypeId="2" ParentId="15939" CreationDate="2015-09-09T13:07:42.270" Score="1" Body="&lt;p&gt;The simplest method is to set up a web server on your PC.  You haven't mentioned what OS you run (which is kind of critical), so looking into WAMP or LAMP (&quot;Windows/Apache/MySQL/PHP&quot;, or &quot;Linux/Apache/MySQL/PHP&quot;) is probably your best option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have a working web server you can pretty much use verbatim the Ethernet examples for connecting to a remote website (&quot;Web Client&quot;).  That website would be your local PC address, and you send whatever parameters you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then write a small PHP script (or whatever language you program your chosen web server in) to accept that web request and process it accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general you never need to explicitly send the IP address since it is encapsulated as part of the actual socket connection information and is generally made available through various means to your web page (see &lt;code&gt;$_SERVER&lt;/code&gt; in PHP for example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to get more &quot;low level&quot; and lighter weight then you would most likely be looking at writing a UDP server on your computer which receives UDP requests from the Arduinos and processes them as needed.  The content of a UDP request is entirely up to you, but programming a server for dealing with it is beyond the scope of an answer here - suffice it to say there are plenty of resources online available for all the major operating systems and programming languages on how to write UDP servers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-09T13:07:42.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15942" PostTypeId="1" CreationDate="2015-09-09T14:47:32.207" Score="1" ViewCount="1809" Body="&lt;p&gt;On Arduino due, Is this possible to get the current time in nano seconds?&#xA;At 84Mhz, I guess it will always be a multiple of ~12ns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a perfect solution would read a register/variable rather than call a function. Because I want to avoid the cost of calling a function which is in order of microseconds.&#xA;what about counting clocks since start of execution. is this possible?&lt;/p&gt;&#xA;" OwnerUserId="10740" LastEditorUserId="10740" LastEditDate="2015-09-10T08:43:45.160" LastActivityDate="2016-09-29T10:59:49.577" Title="get current time in nanoseconds" Tags="|arduino-due|oscillator-clock|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15943" PostTypeId="1" AcceptedAnswerId="15952" CreationDate="2015-09-09T15:32:23.797" Score="3" ViewCount="2826" Body="&lt;p&gt;I am using ultrasonic HC-SO04, not giving reading on fabric. I lost many hours on testing my obstacle avoidance robot car in front of my sofa, every time it hits hard but works fine on other hard surfaces. Is there any other distance sensor which can detect soft objects like fabric from long or short distance? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also looking any other accurate long distance cheap sensor which can work easily with Arduino. Please let me know.  Thanks&lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2016-08-23T08:18:52.197" Title="Distance sensor - Not working on fabric surface" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15945" PostTypeId="1" AcceptedAnswerId="16167" CreationDate="2015-09-08T09:00:35.793" Score="1" ViewCount="529" Body="&lt;p&gt;I'm working on wireless upload to Arduino and i've succeed for Mega2560. But when trying to upload to Uno it does not wait for upload commands. I'm doing reset using GPIO and HM-10 BLE module wired with capacitor and resistor and wired to MCU's reset pin just it's done for USB. I think it remembers somehow how it was reset - by pressing hardware RESET button, by USB DTR/RTS or other way. The problem is that when resetting for USB it waits for upload commands after reset and for BLE it does not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've viewed optiboot bootloader code but i'm not sure i understand it correctly. Any clue on how to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-05 15:51:36.682 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31] &#xA;2015-09-05 15:51:36.682 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 15:51:36.735 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-05 15:51:36.736 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30] &#xA;2015-09-05 15:51:36.736 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-05 15:51:36.788 xctest[60180:7754033] [DEBUG  ] [   ]: Draining for 300 ms ...&#xA;2015-09-05 15:51:36.788 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.053 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-05 15:51:37.053 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 15:51:37.093 xctest[60180:7754033] [DEBUG  ] [IN ]: Drained 18 bytes&#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-05 15:51:37.094 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-05 15:51:37.095 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.096 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-05 15:51:37.450 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-05 15:51:37.452 xctest[60180:7754033] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-05 15:51:37.453 xctest[60180:7754033] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-05 15:51:37.453 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.454 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-05 15:51:37.455 xctest[60180:7754033] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-05 15:51:37.456 xctest[60180:7754033] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-05 15:51:37.456 xctest[60180:7754033] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-05 15:51:37.457 xctest[60180:7754033] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-05 15:51:37.457 xctest[60180:7754033] [TRACE  ] [IN ]: Start reading&#xA;2015-09-05 15:51:37.701 xctest[60180:7754084] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-05 15:51:37.701 xctest[60180:7754084] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-05 15:51:38.451 xctest[60180:7754082] [TRACE  ] [IN ]: Rx value received 5 bytes: h [0x68] e [0x65] l [0x6C] l [0x6C] o [0x6F] &#xA;2015-09-05 15:51:38.452 xctest[60180:7754033] [TRACE  ] [IN ]: Finish reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update 2 (this is uploading to Uno over USB log):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-06-29 16:34:10.829 xctest[36585:3703900] [TRACE  ] [   ]: DTR/RTS supported by Serial, resetting&#xA;2015-06-29 16:34:11.140 xctest[36585:3703900] [DEBUG  ] [IN ]: Draining ...&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG  ] [IN ]: Drain done&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.392 xctest[36585:3703900] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-06-29 16:34:11.393 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.531 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.531 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-06-29 16:34:11.532 xctest[36585:3703900] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-06-29 16:34:11.533 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.535 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.536 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-06-29 16:34:11.537 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x04] &#xA;2015-06-29 16:34:11.540 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [DEBUG  ] [   ]: STK500:initialize: n_extparms = 4&#xA;2015-06-29 16:34:11.541 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 22 bytes&#xA;2015-06-29 16:34:11.542 xctest[36585:3703900] [TRACE  ] [OUT]: Send: B [0x42] . [0x86] . [0x00] . [0x01] . [0x00] . [0x01] . [0x01] . [0x01] . [0x03] . [0xFF] . [0xFF] . [0xFF] . [0xFF] . [0x00] . [0x80] . [0x04] . [0x00] . [0x00] . [0x00] . [0x80] . [0x00]   [0x20] &#xA;2015-06-29 16:34:11.542 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.548 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 7 bytes&#xA;2015-06-29 16:34:11.549 xctest[36585:3703900] [TRACE  ] [OUT]: Send: E [0x45] . [0x05] . [0x04] . [0xD7] . [0xC2] . [0x00]   [0x20] &#xA;2015-06-29 16:34:11.549 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.552 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [TRACE  ] [OUT]: Send: P [0x50]   [0x20] &#xA;2015-06-29 16:34:11.553 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] &#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 1 bytes&#xA;2015-06-29 16:34:11.556 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x10] &#xA;2015-06-29 16:34:11.569 xctest[36585:3703900] Reading |                                                    | 0% 0ms&#xA;2015-06-29 16:34:11.570 xctest[36585:3703900] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-06-29 16:34:11.571 xctest[36585:3703900] [TRACE  ] [OUT]: Send: u [0x75]   [0x20] &#xA;2015-06-29 16:34:11.571 xctest[36585:3703900] [DEBUG  ] [IN ]: Receiving 5 bytes&#xA;2015-06-29 16:34:11.572 xctest[36585:3703900] [TRACE  ] [IN ]: Received: . [0x14] . [0x1E] . [0x95] . [0x0F] . [0x10] &#xA;2015-06-29 16:34:11.572 xctest[36585:3703900] Reading | ################################################## | 100% 2ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Update 3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i've modified bootloader (optiboot) to wait 4 seconds (instead of 1 second by default) and added blinking when character 0x41 (STK_GET_PARAMETER) arrives. Also i've uploaded 'echo' sketch to return what back everything that is sent to the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;bootloader modifications (part):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Set up watchdog to trigger after 4s&#xA;  watchdogConfig(WATCHDOG_4S); // 4ntoine: was WATCHDOG_1s&#xA;&#xA;  /* Set LED pin as output */&#xA;  LED_DDR |= _BV(LED);&#xA;&#xA;#ifdef SOFT_UART&#xA;  /* Set TX pin as output */&#xA;  UART_DDR |= _BV(UART_TX_BIT);&#xA;#endif&#xA;&#xA;// #if LED_START_FLASHES &amp;gt; 0&#xA;  /* Flash onboard LED to signal entering of bootloader */&#xA;  // flash_led(2); // 4ntoine&#xA;// #endif&#xA;&#xA;  /* Forever loop */&#xA;  for (;;) {&#xA;    /* get character from UART */&#xA;    ch = getch();&#xA;&#xA;    if(ch == STK_GET_PARAMETER) {&#xA;      flash_led(2); // 4ntoine&#xA;&#xA;      unsigned char which = getch();&#xA;      verifySpace();&#xA;&#xA;      if (which == 0x82) {&#xA;         /*&#xA;           * Send optiboot version as &quot;minor SW version&quot;&#xA;           */&#xA;         putch(OPTIBOOT_MINVER);&#xA;      } else if (which == 0x81) {&#xA;           putch(OPTIBOOT_MAJVER);&#xA;      } else {&#xA;    /*&#xA;     * GET PARAMETER returns a generic 0x03 reply for&#xA;         * other parameters - enough to keep Avrdude happy&#xA;     */&#xA;    putch(0x03);&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;uploaded arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LED = 13;&#xA;&#xA;void setup() {&#xA;  // avoid misleading blinking&#xA;  pinMode(LED, OUTPUT);&#xA;  digitalWrite(LED, LOW);&#xA;&#xA;  // to let us know when sketch starts&#xA;  Serial.begin(115200);&#xA;  Serial.write(&quot;hello&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial.available()) {&#xA;    int incomingByte = Serial.read();&#xA;    Serial.write(incomingByte);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-13 20:52:57.011 xctest[55099:2968978] [INFO   ] [   ]: Found peripheral: &amp;lt;CBPeripheral: 0x100400af0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-13 20:52:57.011 xctest[55099:2968978] [DEBUG  ] [   ]: Stop scanning&#xA;2015-09-13 20:52:57.012 xctest[55099:2968978] [INFO   ] [   ]: Connecting to &amp;lt;CBPeripheral: 0x100400af0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = disconnected&amp;gt;&#xA;2015-09-13 20:52:57.236 xctest[55099:2968989] [DEBUG  ] [   ]: Connected to peripheral &amp;lt;CBPeripheral: 0x100400af0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-13 20:52:57.238 xctest[55099:2968989] [TRACE  ] [   ]: Discovered services for peripheral &amp;lt;CBPeripheral: 0x100400af0 identifier = D92ECAAB-51A5-44D5-8C6C-536CD797867E, Name = &quot;BleIos&quot;, state = connected&amp;gt;&#xA;2015-09-13 20:52:57.238 xctest[55099:2968989] [DEBUG  ] [   ]: Discovered service &amp;lt;CBService: 0x10010d950&amp;gt;&#xA;2015-09-13 20:52:57.381 xctest[55099:2968989] [TRACE  ] [   ]: Discovered characteristics for service &amp;lt;CBService: 0x10010d950&amp;gt;&#xA;2015-09-13 20:52:57.381 xctest[55099:2968989] [TRACE  ] [   ]: Discovered characteristic &amp;lt;CBCharacteristic: 0x100304d10&amp;gt;&#xA;2015-09-13 20:52:57.382 xctest[55099:2968989] [DEBUG  ] [   ]: Tx characteristic supports WriteWithResponse: NO&#xA;2015-09-13 20:52:57.382 xctest[55099:2968989] [TRACE  ] [   ]: Subscribing to Rx value&#xA;2015-09-13 20:52:57.392 xctest[55099:2968940] [INFO   ] [   ]: Connected successfully&#xA;2015-09-13 20:52:57.392 xctest[55099:2968940] [TRACE  ] [   ]: DTR/RTS supported by Serial, resetting&#xA;2015-09-13 20:52:57.392 xctest[55099:2968940] [TRACE  ] [   ]: Waiting until subscribed to Rx value ...&#xA;2015-09-13 20:52:58.387 xctest[55099:2968989] [DEBUG  ] [IN ]: Updated notifications state for RX characteristic: isNotifying=YES&#xA;2015-09-13 20:52:58.408 xctest[55099:2968940] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-13 20:52:58.408 xctest[55099:2968940] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 1 [0x31] &#xA;2015-09-13 20:52:58.408 xctest[55099:2968940] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-13 20:52:58.463 xctest[55099:2968940] [DEBUG  ] [OUT]: Sending 8 bytes&#xA;2015-09-13 20:52:58.463 xctest[55099:2968940] [TRACE  ] [OUT]: Send: A [0x41] T [0x54] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] 0 [0x30] &#xA;2015-09-13 20:52:58.463 xctest[55099:2968940] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 8&#xA;2015-09-13 20:52:58.518 xctest[55099:2968940] [DEBUG  ] [   ]: Draining for 300 ms ...&#xA;2015-09-13 20:52:58.518 xctest[55099:2968940] [TRACE  ] [IN ]: Start reading&#xA;2015-09-13 20:52:58.784 xctest[55099:2968989] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-13 20:52:58.785 xctest[55099:2968989] [WARNING] [IN ]: Removing 'OK+PIO2:1' (9 bytes) from incoming buffer (9 bytes)&#xA;2015-09-13 20:52:58.785 xctest[55099:2968989] [WARNING] [IN ]: Got 0 bytes in incoming buffer&#xA;2015-09-13 20:52:58.786 xctest[55099:2968989] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-13 20:52:58.786 xctest[55099:2968989] [WARNING] [IN ]: Removing 'OK+PIO2:0' (9 bytes) from incoming buffer (9 bytes)&#xA;2015-09-13 20:52:58.787 xctest[55099:2968989] [WARNING] [IN ]: Got 0 bytes in incoming buffer&#xA;2015-09-13 20:52:58.820 xctest[55099:2968940] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-13 20:52:58.820 xctest[55099:2968940] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-13 20:52:58.821 xctest[55099:2968940] [DEBUG  ] [IN ]: Drained 0 bytes&#xA;2015-09-13 20:52:58.821 xctest[55099:2968940] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-13 20:52:58.821 xctest[55099:2968940] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-13 20:52:58.821 xctest[55099:2968940] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-13 20:52:58.822 xctest[55099:2968940] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-13 20:52:58.822 xctest[55099:2968940] [TRACE  ] [IN ]: Start reading&#xA;2015-09-13 20:52:59.193 xctest[55099:2968978] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-13 20:52:59.193 xctest[55099:2968978] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-13 20:52:59.193 xctest[55099:2968978] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-09-13 20:52:59.194 xctest[55099:2968978] [WARNING] [IN ]: Got 2 bytes in incoming buffer&#xA;2015-09-13 20:52:59.194 xctest[55099:2968940] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-13 20:52:59.195 xctest[55099:2968940] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-13 20:52:59.195 xctest[55099:2968940] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-13 20:52:59.195 xctest[55099:2968940] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-13 20:52:59.196 xctest[55099:2968940] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-13 20:52:59.196 xctest[55099:2968940] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-13 20:52:59.196 xctest[55099:2968940] [TRACE  ] [IN ]: Start reading&#xA;2015-09-13 20:52:59.196 xctest[55099:2968940] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-13 20:52:59.197 xctest[55099:2968940] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-13 20:52:59.197 xctest[55099:2968940] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-13 20:52:59.197 xctest[55099:2968940] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-13 20:52:59.198 xctest[55099:2968940] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-13 20:52:59.198 xctest[55099:2968940] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-13 20:52:59.198 xctest[55099:2968940] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-13 20:52:59.199 xctest[55099:2968940] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-13 20:52:59.199 xctest[55099:2968940] [TRACE  ] [IN ]: Start reading&#xA;2015-09-13 20:52:59.268 xctest[55099:2968978] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-13 20:52:59.268 xctest[55099:2968978] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-13 20:53:02.955 xctest[55099:2968940] [ERROR  ] [OUT]: BLE read timeout: 3.000965 (timeout = 3.000000)&#xA;2015-09-13 20:53:02.955 xctest[55099:2968940] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-13 20:53:02.955 xctest[55099:2968940] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-13 20:53:02.955 xctest[55099:2968940] [ERROR  ] [IN ]: STK500:receive: programmer is not responding&#xA;2015-09-13 20:53:02.956 xctest[55099:2968940] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-13 20:53:02.956 xctest[55099:2968940] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-09-13 20:53:02.956 xctest[55099:2968940] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-13 20:53:02.956 xctest[55099:2968940] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-13 20:53:02.957 xctest[55099:2968940] [TRACE  ] [IN ]: Start reading&#xA;2015-09-13 20:53:03.018 xctest[55099:2968978] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-13 20:53:03.018 xctest[55099:2968978] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-13 20:53:03.280 xctest[55099:2968989] [TRACE  ] [IN ]: Rx value received 5 bytes: h [0x68] e [0x65] l [0x6C] l [0x6C] o [0x6F] &#xA;2015-09-13 20:53:03.280 xctest[55099:2968989] [WARNING] [IN ]: Got 5 bytes in incoming buffer&#xA;2015-09-13 20:53:03.281 xctest[55099:2968940] [TRACE  ] [IN ]: Finish reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i can see blinking so the character arrives so the characters arrive correctly to the board. also i've tested wiring (sketch returns exactly the same as it was sent and it sends 'hello' after start). So i'm pretty sure:&#xA;1. characters arrive correctly to the bootloader&#xA;2. wiring is correct (as i can see back what i've sent - i'm using LightBlue mac app to open HM-10 as BLE device, subscribe to the characteristics and send characters and i can see it's changing to what i've sent).&#xA;3. bootloader waits for 4 seconds (i can see it in Arduino IDE terminal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 4 :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my understanding now is that optiboot sets wrong baud rate for 115200 passed in bootloader mode as it replies with 0x11 and transmits characters correctly in sketch mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-17 09:39:25.628 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-17 09:39:25.628 xctest[60179:4253160] [WARNING] [IN ]: Got 9 bytes in incoming buffer&#xA;2015-09-17 09:39:25.629 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-17 09:39:25.629 xctest[60179:4253160] [WARNING] [IN ]: Got 9 bytes in incoming buffer&#xA;2015-09-17 09:39:25.630 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:25.630 xctest[60179:4253160] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-17 09:39:27.351 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:27.351 xctest[60179:4253117] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-17 09:39:27.351 xctest[60179:4253117] [DEBUG  ] [IN ]: Drained 18 bytes&#xA;2015-09-17 09:39:27.352 xctest[60179:4253117] [DEBUG  ] [   ]: Draining incoming buffer (0 bytes)&#xA;2015-09-17 09:39:27.352 xctest[60179:4253117] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-17 09:39:27.352 xctest[60179:4253117] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-17 09:39:27.353 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-17 09:39:27.353 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:27.353 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:27.424 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:27.424 xctest[60179:4253160] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-17 09:39:27.424 xctest[60179:4253149] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x11] . [0xFC] &#xA;2015-09-17 09:39:27.425 xctest[60179:4253149] [WARNING] [IN ]: Got 2 bytes in incoming buffer&#xA;2015-09-17 09:39:27.425 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:27.425 xctest[60179:4253117] [TRACE  ] [IN ]: Receive: . [0x11] &#xA;2015-09-17 09:39:27.425 xctest[60179:4253117] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-17 09:39:27.426 xctest[60179:4253117] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-17 09:39:27.426 xctest[60179:4253117] [ERROR  ] [   ]: STK500:synchronize: attempt 1 of 3: no sync: received [0x11]&#xA;2015-09-17 09:39:27.426 xctest[60179:4253117] [DEBUG  ] [   ]: Draining incoming buffer (1 bytes)&#xA;2015-09-17 09:39:27.426 xctest[60179:4253117] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-17 09:39:27.427 xctest[60179:4253117] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-17 09:39:27.427 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-17 09:39:27.427 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:27.427 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:27.499 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:27.499 xctest[60179:4253160] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-17 09:39:27.500 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-09-17 09:39:27.500 xctest[60179:4253160] [WARNING] [IN ]: Got 2 bytes in incoming buffer&#xA;2015-09-17 09:39:27.500 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:27.501 xctest[60179:4253117] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-17 09:39:27.501 xctest[60179:4253117] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-17 09:39:27.501 xctest[60179:4253117] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-17 09:39:27.501 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:27.501 xctest[60179:4253117] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-17 09:39:27.502 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:27.502 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:27.502 xctest[60179:4253117] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-17 09:39:27.508 xctest[60179:4253117] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-17 09:39:27.509 xctest[60179:4253117] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-17 09:39:27.509 xctest[60179:4253117] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-17 09:39:27.509 xctest[60179:4253117] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-17 09:39:27.509 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-17 09:39:27.510 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:27.510 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:27.574 xctest[60179:4253149] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:27.574 xctest[60179:4253149] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-17 09:39:31.325 xctest[60179:4253117] [ERROR  ] [OUT]: BLE read timeout: 3.000965 (timeout = 3.000000)&#xA;2015-09-17 09:39:31.326 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:31.326 xctest[60179:4253117] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-17 09:39:31.326 xctest[60179:4253117] [ERROR  ] [IN ]: STK500:receive: programmer is not responding&#xA;2015-09-17 09:39:31.327 xctest[60179:4253117] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-17 09:39:31.327 xctest[60179:4253117] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-09-17 09:39:31.327 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-17 09:39:31.328 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:31.328 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:31.399 xctest[60179:4253160] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:31.400 xctest[60179:4253160] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-17 09:39:35.173 xctest[60179:4253117] [ERROR  ] [OUT]: BLE read timeout: 3.000965 (timeout = 3.000000)&#xA;2015-09-17 09:39:35.173 xctest[60179:4253117] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-17 09:39:35.174 xctest[60179:4253117] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-17 09:39:35.174 xctest[60179:4253117] [ERROR  ] [IN ]: STK500:receive: programmer is not responding&#xA;2015-09-17 09:39:35.174 xctest[60179:4253117] [DEBUG  ] [   ]: STK500:initialize: n_extparms = 3&#xA;2015-09-17 09:39:35.175 xctest[60179:4253117] [DEBUG  ] [OUT]: Sending 22 bytes&#xA;2015-09-17 09:39:35.175 xctest[60179:4253117] [TRACE  ] [OUT]: Send: B [0x42] . [0x86] . [0x00] . [0x01] . [0x00] . [0x01] . [0x01] . [0x01] . [0x03] . [0xFF] . [0xFF] . [0xFF] . [0xFF] . [0x00] . [0x80] . [0x04] . [0x00] . [0x00] . [0x00] . [0x80] . [0x00]   [0x20] &#xA;2015-09-17 09:39:35.175 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 20&#xA;2015-09-17 09:39:35.176 xctest[60179:4253117] [TRACE  ] [OUT]: BLE sending bytes range from 20 length 2&#xA;2015-09-17 09:39:35.177 xctest[60179:4253117] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-17 09:39:35.177 xctest[60179:4253117] [TRACE  ] [IN ]: Start reading&#xA;2015-09-17 09:39:35.224 xctest[60179:4253149] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-17 09:39:35.224 xctest[60179:4253149] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should it work if i wire pins 0 and 1 at Uno to RX/TX (it does work for Mega2560)? Here is soft uart code from optiboot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef SOFT_UART&#xA;#ifdef __AVR_ATmega8__&#xA;  UCSRA = _BV(U2X); //Double speed mode USART&#xA;  UCSRB = _BV(RXEN) | _BV(TXEN);  // enable Rx &amp;amp; Tx&#xA;  UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1&#xA;  UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );&#xA;#else&#xA;  UCSR0A = _BV(U2X0); //Double speed mode USART0&#xA;  UCSR0B = _BV(RXEN0) | _BV(TXEN0);&#xA;  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);&#xA;  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );&#xA;#endif&#xA;#endif&#xA;&#xA;#ifdef SOFT_UART&#xA;  /* Set TX pin as output */&#xA;  UART_DDR |= _BV(UART_TX_BIT);&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should RX be set as input separately too (like Tx as output)? Why it tries to set 'Double speed'?&lt;/p&gt;&#xA;" OwnerUserId="8327" OwnerDisplayName="4ntoine" LastEditorUserId="8327" LastEditDate="2015-09-17T04:43:55.093" LastActivityDate="2015-09-18T05:39:32.997" Title="How to reset Arduino Uno over BLE just like over USB?" Tags="|usb|bootloader|reset|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15946" PostTypeId="2" ParentId="15945" CreationDate="2015-09-08T11:01:58.340" Score="1" Body="&lt;p&gt;The reset procedure for the Arduino Uno works this way:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If supported, toggle USB DTR/RTS or if not, open the Serial port at 1200 baud &amp;amp; close it&lt;/li&gt;&#xA;&lt;li&gt;The Atmega8u2 or Atmega16u2 (which is acting as the USB-UART bridge) detects one of these two events, and pulls PD7 (which is capacitively coupled to the pulled-up reset pin on the main Atmega328 IC) low, causing a low pulse on the reset pin, putting the Uno into bootloader mode.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Although microcontrollers do generally have a register which records the reset event reason (for example brownout detect, watchdog timer overflow, power-on reset or external reset) to allow for differentiation in startup routines, this isn't at play here because the Atmega328 can't know whether it was the Atmega8/16u2 which pulled the line low, or if you did it, or if it was a very focused beam of ionising radiation from outer space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this in mind, there are two possible reasons for the problem you are having:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The reset isn't actually happening. You can write your own code that has a particular startup routine to detect this, along with watching the reset pin with a scope to observe the pulse.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The onboard bootloader timeout is kicking in before you are passing data to it. From looking at the optiboot code (and the makefiles in the Arduino Github repo) it seems that you have a timeout of 1 second from reset to pass your first valid character to the bootloader. This is longer for other boards (8 seconds for the Arduino Leonardo, for example). Are you certain that you are getting data there that fast?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the issue is a timing one (and you can't improve your timing), you could always consider flashing your own compiled version of Optiboot based on the Arduino makefile options for the atmega328 target but with an additional -DTIMEOUT_MS=XXXX in the CFLAGS definition, where XXXX is the timeout in ms chosen from the supported list of 500, 1000, 2000, 4000, 8000.&lt;/p&gt;&#xA;" OwnerUserId="11729" OwnerDisplayName="stefandz" LastActivityDate="2015-09-08T11:57:12.553" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="15947" PostTypeId="2" ParentId="15939" CreationDate="2015-09-09T19:35:37.150" Score="1" Body="&lt;p&gt;In my opinion, a perfect solution for the &quot;&lt;em&gt;As a PIN goes high I need to trigger an event&lt;/em&gt;&quot; problem is brought by &lt;strong&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Interrupt&quot; rel=&quot;nofollow&quot;&gt;interrupts&lt;/a&gt;&lt;/strong&gt;. In the &lt;a href=&quot;http://playground.arduino.cc/Code/Interrupts&quot; rel=&quot;nofollow&quot;&gt;official documentation&lt;/a&gt; I read: &quot;...&lt;em&gt;Arduino has two different kinds of interrupts: &lt;code&gt;external&lt;/code&gt;, and &lt;code&gt;pin change&lt;/code&gt;...&lt;/em&gt;&quot; and the latter seems very suited for your needs. So my idea (but, please, be aware that I'm not at all an Arduino developer... yet) is to simply develop an &quot;interrupt-handler routine&quot;, and properly attach such a routine to your PINs. There are plenty of details to analyze (as well as &lt;a href=&quot;https://www.google.it/search?q=arduino%20interrupt%20handling&amp;amp;ie=utf-8&quot; rel=&quot;nofollow&quot;&gt;plenty of documentation about Arduino interrupt handling&lt;/a&gt;) but... the idea should be clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, while developing such a routine &lt;strong&gt;DON'T&lt;/strong&gt; be tempted to push all of your networking code inside the routine itself: for reasons &lt;a href=&quot;http://gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;deeply and clearly explained by @NickGammon&lt;/a&gt;, interrupt handlers should be executed as fast as possible. Here follow an important part of Nick's article:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Hints for writing ISRs&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;In brief, keep them short! While an ISR is executing other interrupts cannot be processed. So you could easily miss button presses, or incoming serial communications, if you try to do too much. In particular, you should not try to do debugging &quot;prints&quot; inside an ISR. The time taken to do those is likely to cause more problems than they solve.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;A reasonable thing to do is set a single-byte flag, and then test that flag in the main loop function&lt;/strong&gt;. Or, store an incoming byte from a serial port into a buffer. The inbuilt timer interrupts keep track of elapsed time by firing every time the internal timer overflows, and thus you can work out elapsed time by knowing how many times the timer overflowed.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;[...]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for the &quot;&lt;em&gt;...will send the IP or MAC of the arduino and the PIN state over the wired Ethernet to a local computer...&lt;/em&gt;&quot;, @Majenko already answered that &quot;source IP&quot; and &quot;source MAC&quot; (of your Arduino) are &lt;strong&gt;not&lt;/strong&gt; needed to be sent explicitely by your application, as if you're using an Ethernet shield (...and, on top of it, the IP protocol stack) it will be the shield itself in dealing with the &quot;encapsulation&quot; process, by which your data (the data &quot;sent&quot; by your own code) will be encapsulated in a proper &lt;a href=&quot;https://en.wikipedia.org/wiki/Ethernet_frame&quot; rel=&quot;nofollow&quot;&gt;Ethernet frame&lt;/a&gt; (that will include the source MAC) and a containing IPv4 packet (that will include the &quot;source IP&quot;). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for the &quot;&lt;em&gt;...send [the] state over the wired Ethernet to a local computer...&lt;/em&gt;&quot; you're missing some very important details, like which operating system your local computer will be running and, more important, which programming language are you using to write your &quot;server-application code&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LAMP/WAMP approach proposed by @Majenko is relatively easy to implement, as the WebServer (Apache) will bring you a ready-made approach to handle network requests: afterall, you need a &quot;server&quot; application (an application &quot;listening&quot; to a socket, waiting for incoming messages/requests coming from network clients) and a web-server like Apache is exactly such an application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, should you need something more specifically suited for your needs, nothing prevent you to write your own &quot;server&quot;. There are plenty of libraries for plenty of programming-languages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm confident with PERL, I suggest you checking one of the many tutorial describing &lt;a href=&quot;https://www.google.it/search?q=perl%20client%20server%20example&amp;amp;ie=utf-8&quot; rel=&quot;nofollow&quot;&gt;PERL client-server programming&lt;/a&gt;. Please note that PERL is a cross-platform language, supported also on Windows systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A final note: While implementing your &quot;server-code&quot;, please check/consider if you need a &quot;blocking server&quot; (one who can handle only one single request at a time) or a &quot;non-blocking server&quot; (one who can handle multiple requests, coming from multiple arduinos, at the same time).&lt;/p&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="13193" LastEditDate="2015-09-09T20:16:33.370" LastActivityDate="2015-09-09T20:16:33.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15949" PostTypeId="1" AcceptedAnswerId="15950" CreationDate="2015-09-09T22:10:03.410" Score="4" ViewCount="4643" Body="&lt;p&gt;I want to know if there is a way to write like in C programming:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  printf(&quot;the num is %d&quot;,num);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that to print a line or a variable the command will be Serial.println&#xA;when I write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Serial.println(&quot;the num is %d&quot;,num);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to write it in just one line?  &lt;/p&gt;&#xA;" OwnerUserId="13290" LastEditorUserId="220" LastEditDate="2015-09-11T21:09:30.490" LastActivityDate="2015-09-13T20:05:13.663" Title="How to print a line with a variable in it?" Tags="|arduino-uno|c++|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15950" PostTypeId="2" ParentId="15949" CreationDate="2015-09-09T22:43:48.657" Score="2" Body="&lt;pre&gt;&lt;code&gt;Serial.print(&quot;the num is &quot;); Serial.println(num);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is how you do it with the Serial object. There is a printf in the library and it's a lot easier to use (as you already know) but a little bit more work to set up. Here is a simple program using printf:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Define a file descriptor for the serial output:&#xA;static FILE uartout = { 0 };&#xA;&#xA;// Declare our put-character function:&#xA;static int uart_putchar (char c, FILE *stream);&#xA;&#xA;&#xA;void setup() {&#xA;   // Fill in UART file descriptor with pointer to my char-out func.&#xA;   fdev_setup_stream(&amp;amp;uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);&#xA;   stdout = &amp;amp;uartout;&#xA;&#xA;   Serial.begin(9600);   // open serial port, sets baud rate&#xA;}&#xA;&#xA;void loop( void ){&#xA;   printf(&quot;Run time: %ld\n&quot;, millis());&#xA;   delay(1000);          // wait 1 sec&#xA;}&#xA;&#xA;// My char output function&#xA;static int uart_putchar (char c, FILE *stream)&#xA;{&#xA;   if( c == '\n' )&#xA;      Serial.write('\r');&#xA;   Serial.write(c) ;&#xA;   return 0 ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-09-09T23:14:30.327" LastActivityDate="2015-09-09T23:14:30.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15951" PostTypeId="2" ParentId="12564" CreationDate="2015-09-10T02:41:08.203" Score="2" Body="&lt;p&gt;I have run into problems like this before, often it can actually be that the voltage is not steady due to the LEDs sourcing current from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to solve the problem by adding a capacitor inline with the power input (from the +12v to GND). I would probably start with a value of around 10 &amp;mu;F and increase it if the interference continues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Capacitive sensors and very sensitive to voltage fluctuations, you may even want to put a second capacitor across the V&lt;sub&gt;CC&lt;/sub&gt; and Gnd of the sensor.&lt;/p&gt;&#xA;" OwnerUserId="13294" LastEditorUserId="6936" LastEditDate="2015-09-17T11:27:41.157" LastActivityDate="2015-09-17T11:27:41.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15952" PostTypeId="2" ParentId="15943" CreationDate="2015-09-10T03:45:28.417" Score="2" Body="&lt;p&gt;There are three types of commercially viable sensors for small scale projects:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Ultrasonic sensors(HC-SO04 and similar):&lt;/strong&gt; These sensors use ultrasound much like a submarine uses its sonar to locate things by sending out a sound wave(trigger pin) and then measuring the time it takes for the sound wave to bounce back by reading the echo.There are two problems with this sensor. It needs a pretty solid object to bounce sound of thus walls are good but cloth absorbs the sound wave and the echo never bounces back. The second is you can encounter ghost echos when the sound wave strikes a corner and creates a echo for an object that is not really there. These sensors typically have a range of around 250cm to 600cm however some sensors can sense up to 7 meters away. Thus while it has good range it can not reliably detect all things and you might have false positives on it as well.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;IR(Infrared) Sensors:&lt;/strong&gt; These work like the ultrasonic ones but with light instead of sound. The sensor sends out a pulse/beam of IR light and measures the time it takes to reflect the light pulse/beam. This sensor is much faster than the ultrasonic ones but they have a much smaller range than ultrasonic sensors with a normal range of about 1.5 meters. While they work on most obstacles some might be missed due to the ability of some materials to absorb the IR light pulse thus there is no echo to measure.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;LIDAR(Laser Range Sensors):&lt;/strong&gt; There are various models of these but the principle is the same as the IR sensor. These can have massive range but they also come in at a massive prices. You can find cheaper ones around I saw a model for $80 that has a 40 meter range. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3897" LastEditorUserId="3897" LastEditDate="2015-09-20T20:52:31.257" LastActivityDate="2015-09-20T20:52:31.257" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="15953" PostTypeId="1" CreationDate="2015-09-10T05:18:05.867" Score="2" ViewCount="346" Body="&lt;p&gt;I want to check each cell voltage using arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and how to calculate dc current using CT Sensor using Arduino?&lt;/p&gt;&#xA;" OwnerUserId="7642" LastEditorUserId="7642" LastEditDate="2015-09-25T03:26:51.180" LastActivityDate="2015-09-25T03:26:51.180" Title="How to calculate voltage?" Tags="|arduino-leonardo|voltage-level|battery|current|arduino-mini|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15954" PostTypeId="1" CreationDate="2015-09-10T07:23:57.687" Score="1" ViewCount="87" Body="&lt;p&gt;I have an Arduino Uno connected to a LCD. When I try to write to it using the LCD library and the following sketch, it will keep shifting the output around, sometimes drastically.&lt;/p&gt;&#xA;&lt;p&gt;The sketch:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 10, 11, 9, 8, 7, 6, 5, 4, 3, 2);&#xA;&#xA;void setup () &#xA;{&#xA;  lcd.begin (16, 2);&#xA;}&#xA;&#xA;void loop () &#xA;{&#xA;  lcd.clear ();&#xA;  lcd.home ();&#xA;  &#xA;  for (int i = 0; i &amp;lt; 2; i++)&#xA;  {&#xA;    for (int j = 0; j &amp;lt; 16; j++)&#xA;    {&#xA;      lcd.setCursor (j, i);&#xA;      lcd.print (&amp;quot;s&amp;quot;);&#xA;    }&#xA;  }&#xA;&#xA;  delay (1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You would expect it to print&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SSSSSSSSSSSSSSSS&lt;/p&gt;&#xA;&lt;p&gt;SSSSSSSSSSSSSSSS&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But it will often print&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SSSSSSSSSSSSSSS&lt;/p&gt;&#xA;&lt;p&gt;SSSSSSSSSSSSSSS&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As in, it skips the first line. And, occasionally, it will even print like this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;SSSSSSSSSSS&lt;/p&gt;&#xA;&lt;p&gt;SSSSSSSSSSS&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Is it the LCD's fault, or might there be something wrong with the way it is connected?&lt;/p&gt;&#xA;&lt;p&gt;EDIT:&#xA;It is a common Hitachi HD44780-compatible LCD.&lt;/p&gt;&#xA;&lt;p&gt;EDIT 2:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9bkyh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9bkyh.png&quot; alt=&quot;Fritzing View&quot; /&gt;&lt;/a&gt; Hopefully it is correctly wired up.&lt;/p&gt;&#xA;" OwnerUserId="13296" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-10T18:09:02.280" Title="Output to LCD is sometimes shifted to the side" Tags="|arduino-uno|c++|lcd|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="15955" PostTypeId="2" ParentId="15953" CreationDate="2015-09-10T07:30:16.493" Score="2" Body="&lt;p&gt;You have two problems here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to take 24 readings on an Arduino with only 6 analog inputs.&lt;/li&gt;&#xA;&lt;li&gt;How to get the voltage in the range of 0 to 5 volts.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To take 24 readings you can use an &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot; rel=&quot;nofollow noreferrer&quot;&gt;analog multiplexer&lt;/a&gt; or two. For example the 74HC4051 (8 channels) or the 74HC4067 (16 channels). With both of those you could handle 24 channels.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To read the voltages you could successively read each cell, relative to ground (eg. the first one should be 2 V, the second should be 4 V, and so on up to 48 V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cells 1 and 2 are fine, they are lower than 5 V. Cells 3 to 24 are not. You need to set up a voltage divider to divide down the voltage into the range 0 to 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula for a voltage divider is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = Vin * R2/(R1+R2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's make R1 to be 10k ohms, and solve for R2 (given that we want Vout to be 5).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R2 = Vout * R1/(Vin - Vout)&#xA;R2 = 5 * 10000 / (Vin - 5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plugging that into a spreadsheet we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vin    R&#xA;6  50000&#xA;8  16667&#xA;10 10000&#xA;12  7143&#xA;14  5556&#xA;16  4545&#xA;18  3846&#xA;20  3333&#xA;22  2941&#xA;24  2632&#xA;26  2381&#xA;28  2174&#xA;30  2000&#xA;32  1852&#xA;34  1724&#xA;36  1613&#xA;38  1515&#xA;40  1429&#xA;42  1351&#xA;44  1282&#xA;46  1220&#xA;48  1163&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;These aren't particularly easy resistor values to work with, so we'll use standard values and calculate what the output voltage should be (with the spreadsheet):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vin   R   volts   Scale&#xA;2     &#xA;4     &#xA;6   47000 4.9474  1.2128    &amp;lt;--- R2 is 47 k&#xA;8   16000 4.9231  1.6250    &amp;lt;--- R4 is 16 k&#xA;10  10000 5.0000  2.0000&#xA;12   6800 4.8571  2.4706&#xA;14   5100 4.7285  2.9608&#xA;16   4300 4.8112  3.3256&#xA;18   3600 4.7647  3.7778&#xA;20   3300 4.9624  4.0303&#xA;22   2700 4.6772  4.7037&#xA;24   2400 4.6452  5.1667&#xA;26   2200 4.6885  5.5455&#xA;28   2000 4.6667  6.0000&#xA;30   2000 5.0000  6.0000&#xA;32   1800 4.8814  6.5556&#xA;34   1600 4.6897  7.2500&#xA;36   1600 4.9655  7.2500&#xA;38   1500 4.9565  7.6667&#xA;40   1300 4.6018  8.6923&#xA;42   1300 4.8319  8.6923&#xA;44   1200 4.7143  9.3333&#xA;46   1200 4.9286  9.3333&#xA;48   1100 4.7568 10.0909&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;Scale&quot; column will be explained in a moment.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now we are ready to make up a circuit along these lines:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qdFww.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qdFww.png&quot; alt=&quot;Multiplexer circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't shown all the battery cells here - I don't have that much energy! But the principle is the same.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The 2V and 4V inputs we can read directly. From 6V upwards we need to apply the scaling factor from the voltage divider network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is shown in the &quot;Scale&quot; column above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula for the voltage on the pin is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltage = ((float) rawADC  + 0.5 ) / 1024.0 * Vref;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So assuming Vref is 5V, and you have a reading of 512, then you apply it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ( 512  + 0.5 ) / 1024.0 * 5 = 2.502 volts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you multiply by the scale factor above, so if this was the 34 V input, the scale factor would be 7.25, and the voltage from the battery would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2.502 * 7.25 = 18.14  volts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The stage is now set to work out each voltage:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the multiplexer &quot;select&quot; pins to choose one of the battery inputs&lt;/li&gt;&#xA;&lt;li&gt;Take an analog reading&lt;/li&gt;&#xA;&lt;li&gt;Scale it by the appropriate amount from the table&lt;/li&gt;&#xA;&lt;li&gt;Work out what the charge in the cell is (by comparing it to the previous one)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, if the first cell read 1.9V and the second cell read 3.85V then you know that the difference is 3.85 - 1.9 which is 1.95 volts.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-10T07:30:16.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15956" PostTypeId="2" ParentId="15942" CreationDate="2015-09-10T08:53:33.727" Score="1" Body="&lt;p&gt;Yes, it &lt;em&gt;should&lt;/em&gt; be.  At least according to the Cortex M3 Technical Reference Manual that I think I downloaded from ARM.  (DDI0337E_cortex_m3_r1p1_trm.pdf)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In section 11.5 of said manual, there is a register called &lt;code&gt;DWT_CYCCNT&lt;/code&gt; (Data Watchpoint and Trace Cycle Count Register) which is incremented once per clock cycle when the appropriate flag of the &lt;code&gt;DTW_CTRL&lt;/code&gt; (DWT Control) register is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This flag is unset on reset of the CPU so it needs to be set manually (unless it is done by the Arduino IDE, but checking the header files of the IDE, it doesn't look like it as unlike many other CPU registers, there is no Arduino &lt;code&gt;REG_&lt;/code&gt; define for these registers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This untested code should be usable as the basis for your own code.  I suggest you add some serial initialisation in there and dump the value of &lt;code&gt;currentCycles&lt;/code&gt; to the serial log to test it.  I am away from my hardware at the moment so can only test that it compiles.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define REG_DWT_CTRL (*(unsigned int*)0xE0001000U)      /* Data Watchpoint and Trace Control Register */&#xA;#define REG_DWT_CYCCNT (*(unsigned int*)0xE0001004U)    /* Data Watchpoint and Trace Cycle Count Register */&#xA;&#xA;#define CYCCNTENA ( 1 &amp;lt;&amp;lt; 0 )                            /* DWT CTRL Cycle Count Enable Bit */&#xA;&#xA;void setup()&#xA;{&#xA;    REG_DWT_CTRL |= CYCCNTENA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    unsigned int currentCycles = REG_DWT_CYCCNT;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Note that the counter is a 32 bit register, so at 84 MHz it will reset every 51.13 seconds.  It is a read only register so writing to it will have no effect (you cannot manually reset it that way).&lt;/p&gt;&#xA;" OwnerUserId="8616" LastEditorDisplayName="user24204" LastEditDate="2016-09-29T10:59:49.577" LastActivityDate="2016-09-29T10:59:49.577" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15957" PostTypeId="2" ParentId="15949" CreationDate="2015-09-10T09:33:17.223" Score="2" Body="&lt;p&gt;You can try &quot;extending&quot; the Print class to include a printf() function.  It requires modification of the Arduino core to add it, and it's something I have been meaning to suggest to the Arduino guys as a permanent modification, but I often manually add a function such as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Print::printf(const char *fmt, ...) {&#xA;    va_list va;&#xA;    va_start(va, fmt);&#xA;    char temp[1];&#xA;    uint32_t slen = vsnprintf(temp, 1, fmt, va);&#xA;    va_end(va);&#xA;    char out[slen + 2];&#xA;    va_start(va, fmt);&#xA;    vsnprintf(out, slen+1, fmt, va);&#xA;    va_end(va);&#xA;    print(out);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to my core.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not wonderfully efficient from a processing point of view - it first runs a &lt;code&gt;vsnprintf()&lt;/code&gt; to a single byte target.  This allows it to work out how long the formatted string will need to be:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If the output was truncated due to this limit, then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it then knows how much memory is needed to store the formatted string.  It then goes ahead and allocates that much memory on the stack and re-formats the string again into that newly allocated memory.  It can then go ahead and send that data to the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a &quot;quick and dirty&quot; hack, but it works.  A better solution would be to re-write the &lt;code&gt;printf()&lt;/code&gt; parser in the function and instead of formatting to memory then printing, to format the data stream directly to the &lt;code&gt;Serial&lt;/code&gt; device, thus saving the double-processing and memory allocation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then quite happily do things like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.printf(&quot;The temperature is %d degrees C\n&quot;, temperature);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-10T09:33:17.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15958" PostTypeId="2" ParentId="9300" CreationDate="2015-09-10T10:06:05.120" Score="-1" Body="&lt;p&gt;Try using this code and run it on your Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;Serial.print('hello world');&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After uploading the code open the serial monitor and see if it shows the string '&lt;code&gt;hello world&lt;/code&gt;' and make sure that the baud rate of the serial monitor is set on 9600. If nothing shows this could mean that there is something wrong with your Arduino board.&lt;/p&gt;&#xA;" OwnerUserId="13298" LastEditorUserId="6936" LastEditDate="2015-09-17T11:27:14.187" LastActivityDate="2015-09-17T11:27:14.187" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15960" PostTypeId="1" AcceptedAnswerId="17205" CreationDate="2015-09-10T13:55:26.133" Score="0" ViewCount="1034" Body="&lt;p&gt;I've been using an Arduino UNO to log data: it's queried by a LabView VI over a VISA connection. It'll happily sit there and log for days, but very occasionally one of the VISA functions will fail. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this, I can't open the COM port again (in LabView or elsewhere) and the only way to restore communication is to unplug and replug the USB cable. The Arduino hasn't crashed because I can see the other results of the program it's running working fine, but Serial comms are a gonner. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone experienced this? Do you know if this is an Arduino problem, a Labview problem, a Windows problem? Or something else? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm writing a minimum working example to try and catch this happening in the most simple code possible, but since the error usually takes several days to show up I can't tell you the results yet!&lt;/p&gt;&#xA;" OwnerUserId="13301" LastEditorUserId="13301" LastEditDate="2015-09-10T16:12:51.003" LastActivityDate="2015-10-26T21:02:35.153" Title="Serial comms failure after long time - can't open COM port" Tags="|arduino-uno|serial|programming|usb|communication|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15962" PostTypeId="1" CreationDate="2015-09-10T15:39:38.540" Score="2" ViewCount="130" Body="&lt;p&gt;I have a function which returns a float value. &#xA;I want to see what value is returned so I print it just before the return statement. &#xA;Surprisingly, the value is &lt;code&gt;0&lt;/code&gt; (it shouldn't be &lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I want to debug the function and print more things, the value is correct. I do not change anything, I just add a couple of &lt;code&gt;printl()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;float func() {&#xA;  float a = some math calculation;&#xA;&#xA;  some easy math&#xA;  Serial.println(a); &#xA;  some easy math&#xA;  Serial.println(a);&#xA;&#xA;  Serial.println(a);&#xA;  return a;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I comment out &lt;code&gt;println()&lt;/code&gt; lines, I get &lt;code&gt;0&lt;/code&gt;, which is a wrong value.&#xA;If the lines stay uncommented, I get a correct value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have idea why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Arduino Due.&lt;/p&gt;&#xA;" OwnerUserId="13305" LastEditorUserId="37523" LastEditorDisplayName="user24204" LastEditDate="2019-08-04T19:12:47.200" LastActivityDate="2019-08-04T19:12:47.200" Title="println() changes values of variables" Tags="|serial|arduino-due|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="15963" PostTypeId="1" AcceptedAnswerId="15968" CreationDate="2015-09-10T16:31:16.560" Score="2" ViewCount="345" Body="&lt;p&gt;I am having trouble getting my head around pointers in C++, specifically how they behave when passed around or used within objects. As far as my understanding goes as long as pointers, or more specifically values/objects pointed &lt;em&gt;to&lt;/em&gt; - do not go out of scope, I should be able to use that pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been playing around with some test code on my Arduino Uno and I am bumping into behaviour I cannot explain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read rather a lot on the topic of pointers in C++ and thought I had a good grasp of it. However, practice doesn't seem to match the theory in my head. I don't know if this is a lack of understanding or if the Arduino platform has idiosyncrasies that I am not aware of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my test code I have created two classes, &lt;code&gt;Alpha&lt;/code&gt; and &lt;code&gt;Beta&lt;/code&gt;. Alpha simply holds a C-type string in a member variable called &lt;code&gt;alpha&lt;/code&gt;. &lt;code&gt;Beta&lt;/code&gt; is designed to hold two &lt;code&gt;Alpha&lt;/code&gt; instances in an array*. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*While this is &quot;toy&quot; code, the general structure mirrors my actual project. I have used this toy code as it more succinctly describes the set up and the issue I am facing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;pointers.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#import &quot;Arduino.h&quot;&#xA;class Alpha {&#xA;    private:&#xA;        char alpha[20];&#xA;    public:&#xA;        Alpha();&#xA;        ~Alpha();&#xA;        char* getAlpha(char* s, int size=20);&#xA;        void setAlpha(char* value, int size=20);&#xA;        void debug();&#xA;};&#xA;&#xA;class Beta {&#xA;    private:&#xA;        Alpha** alphas;&#xA;    public:&#xA;        Beta();&#xA;        ~Beta();&#xA;        Alpha* getAlpha(int index);&#xA;        void setAlpha(Alpha* alpha, int index);&#xA;        void doStuffWithAlpha(int index);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;pointers.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#import &quot;pointers.h&quot;&#xA;&#xA;Alpha::Alpha() {&#xA;    setAlpha(&quot;Initial&quot;);&#xA;}&#xA;&#xA;Alpha::~Alpha() {}&#xA;&#xA;char* Alpha::getAlpha(char* s, int size/*=20*/) {&#xA;    *s = *alpha;&#xA;    return s; //return not strictly needed here since s is passed in&#xA;}&#xA;&#xA;void Alpha::setAlpha(char* value, int size/*=20*/) {&#xA;    strncpy(alpha, value, size-1);&#xA;    alpha[size-1] = '\0';&#xA;}&#xA;&#xA;void Alpha::debug() {&#xA;    Serial.println(alpha);&#xA;}&#xA;&#xA;&#xA;Beta::Beta() {&#xA;    alphas = new Alpha*[2];&#xA;}&#xA;&#xA;Beta::~Beta() {}&#xA;&#xA;Alpha* Beta::getAlpha(int index) {&#xA;    return alphas[index];&#xA;}&#xA;&#xA;void Beta::setAlpha(Alpha* alpha, int index) {&#xA;    alphas[index] = alpha;&#xA;}&#xA;&#xA;void Beta::doStuffWithAlpha(int index) {&#xA;    Alpha* alpha = getAlpha(index);&#xA;    /* Alpha* alpha = alphas[index]; */ //This doesn't work either - same outcome.&#xA;    alpha-&amp;gt;debug();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;sketch.ino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#import &quot;pointers.h&quot;&#xA;Alpha a1;&#xA;Alpha a2;&#xA;Beta b1;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;SETUP()&quot;);&#xA;    Serial.println();&#xA;&#xA;    a1 = Alpha();&#xA;    a1.setAlpha(&quot;Hello&quot;);&#xA;&#xA;    Serial.println(&quot;----- a1.debug -----&quot;);&#xA;    Serial.println(&quot;Expected: Hello&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); a1.debug();&#xA;    Serial.println();&#xA;&#xA;    a2 = Alpha();&#xA;    a2.setAlpha(&quot;Goodbye&quot;);&#xA;&#xA;    Serial.println(&quot;----- a2.debug -----&quot;);&#xA;    Serial.println(&quot;Expected: Goodbye&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); a2.debug();&#xA;    Serial.println();&#xA;&#xA;    Beta b1 = Beta();&#xA;    b1.setAlpha(&amp;amp;a1, 0);&#xA;    b1.setAlpha(&amp;amp;a2, 1);&#xA;&#xA;    Serial.println(&quot;----- b1.doStuffWithAlpha -----&quot;);&#xA;    Serial.println(&quot;Expected: Hello&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); b1.doStuffWithAlpha(0);&#xA;    Serial.println(&quot;Expected: Goodbye&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); b1.doStuffWithAlpha(1);&#xA;    Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;LOOP()&quot;);&#xA;    Serial.println();&#xA;&#xA;    Serial.println(&quot;----- a1.debug -----&quot;);&#xA;    Serial.println(&quot;Expected: Hello&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); a1.debug();&#xA;    Serial.println();&#xA;&#xA;    Serial.println(&quot;----- b1.doStuffWithAlpha(0) ------&quot;);&#xA;    Serial.println(&quot;Expected: Hello&quot;);&#xA;    Serial.print(&quot;Actual: &quot;); b1.doStuffWithAlpha(0);&#xA;    Serial.println();&#xA;&#xA;    Serial.println(&quot;----- a2.debug -----&quot;);&#xA;    Serial.println(&quot;Expected: Goodbye&quot;);&#xA;    Serial.print(&quot;Actual:   &quot;); a2.debug();&#xA;    Serial.println();&#xA;&#xA;    Serial.println(&quot;----- b1.doStuffWithAlpha(1) ------&quot;);&#xA;    Serial.println(&quot;Expected: Goodbye&quot;);&#xA;    Serial.print(&quot;Actual:   &quot;); b1.doStuffWithAlpha(1);&#xA;    Serial.println();&#xA;&#xA;    delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sketch is quite straight-forward. It creates 2 &lt;code&gt;Alpha&lt;/code&gt; objects and a &lt;code&gt;Beta&lt;/code&gt; object and passes the two Alphas into Beta. The myriad &lt;code&gt;Serial.print()&lt;/code&gt; statements produces the output below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SETUP()&#xA;&#xA;----- a1.debug -----&#xA;Expected: Hello&#xA;Actual:   Hello&#xA;&#xA;----- a2.debug -----&#xA;Expected: Goodbye&#xA;Actual:   Goodbye&#xA;&#xA;----- b1.doStuffWithAlpha -----&#xA;Expected: Hello&#xA;Actual:   Hello&#xA;&#xA;Expected: Goodbye&#xA;Actual:   Goodbye&#xA;&#xA;//everything is fine up to this point...&#xA;&#xA;LOOP()&#xA;&#xA;----- a1.debug -----&#xA;Expected: Hello&#xA;Actual:   Hello&#xA;&#xA;----- b1.doStuffWithAlpha(0) ------&#xA;Expected: Hello&#xA;Actual:   CÃoçëyc=Lä^ÜŽYw¸Nv†Ý¿  //uh oh...&#xA;&#xA;----- a2.debug -----&#xA;Expected: Goodbye&#xA;Actual:   Goodbye&#xA;&#xA;----- b1.doStuffWithAlpha(1) ------&#xA;Expected: Goodbye&#xA;Actual:   ÿß/ï //uh oh again...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything works as expected when running &lt;code&gt;a1&lt;/code&gt; or &lt;code&gt;a2.debug()&lt;/code&gt; or &lt;code&gt;b1.doStuffWithAlpha()&lt;/code&gt; in the &lt;code&gt;setup()&lt;/code&gt; function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result of &lt;code&gt;a1.debug()&lt;/code&gt; and &lt;code&gt;a2.debug()&lt;/code&gt; works as expected in the &lt;code&gt;loop()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue, as you can see, is when running &lt;code&gt;b1.doStuffWithAlpha(0)&lt;/code&gt; or &lt;code&gt;b1.doStuffWithAlpha(1)&lt;/code&gt;. The output is usually junk, which suggests to me the pointer has been mangled and points in the wrong place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand what is happening between the transition from &lt;code&gt;setup()&lt;/code&gt; to &lt;code&gt;loop()&lt;/code&gt;. At first I thought the issue was the &quot;Hello&quot; and &quot;Goodbye&quot; strings going out of scope, but &lt;code&gt;Alpha::setAlpha()&lt;/code&gt; makes a copy of the C-string. Also, accessing &lt;code&gt;Alpha::debug()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt; works, as shown above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried variations on the above code, such as using a struct or an int for &lt;code&gt;alpha&lt;/code&gt; instead of a C-string and the results are the same: Mangled values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have I done something obviously silly that my scant C++ experience hasn't picked up on, or is there some fundamental Arduino shenanigans at play?&lt;/p&gt;&#xA;" OwnerUserId="4530" LastActivityDate="2015-09-10T18:12:13.357" Title="C++ Pointer Issues - Mangled Data" Tags="|arduino-uno|c++|pointer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15964" PostTypeId="1" AcceptedAnswerId="15965" CreationDate="2015-09-10T17:17:36.987" Score="2" ViewCount="1237" Body="&lt;p&gt;Is it possible to measure the width of a pulse which is longer than 3 minutes? The pulseIn function can only measure duration of maximum 3 minutes accurately.&#xA;I've tried using interrupts but haven't come up with a correct solution yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm measuring the duration of pulse (HIGH) generated by AND gate connected to the outputs of two comparators. AND gate output voltage is around &lt;strong&gt;4.9 volts&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any logical solution or idea would be appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13306" LastActivityDate="2015-09-10T21:08:56.647" Title="Measurement of pulse duration greater than 3mins" Tags="|arduino-uno|millis|pulsein|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15965" PostTypeId="2" ParentId="15964" CreationDate="2015-09-10T17:26:13.023" Score="1" Body="&lt;p&gt;The concept is actually quite simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to record the time when the signal goes high, and record the time when it goes low. The pulse width is the difference between the two times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you can do it with interrupts, but you don't need to if you're not trying to do anything else at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple polling code could be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (digitalRead(pin) == LOW); // Wait for input to go high&#xA;unsigned long startTime = millis(); // Record start time&#xA;while (digitalRead(pin) == HIGH); // Wait for input to go low&#xA;unsigned long endTime = millis(); // Record end time&#xA;unsigned long pulseDuration = endTime - startTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You basically sit doing nothing until the leading rising edge of your pulse.  You then record the time, and again sit doing nothing - this time while looking for the trailing falling edge of the pulse.  Then record the end time and subtract the two.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-10T21:08:56.647" LastActivityDate="2015-09-10T21:08:56.647" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15966" PostTypeId="1" AcceptedAnswerId="15978" CreationDate="2015-09-10T17:34:00.400" Score="0" ViewCount="94" Body="&lt;p&gt;When I plug in my Yun, Windows pops up a box saying &lt;code&gt;Windows needs to install driver software for your Arduino Yun&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does Windows use to identify my device as an Arduino Yun? Is it written in a file somewhere, so I could for example, &lt;i&gt;remove&lt;/i&gt; that driver prompt, or &lt;i&gt;change&lt;/i&gt; it to &lt;code&gt;Windows needs to install driver software for your Foo Bar?&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2015-09-10T21:41:25.783" Title="How does Yun identify itself to Windows?" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15968" PostTypeId="2" ParentId="15963" CreationDate="2015-09-10T18:12:13.357" Score="4" Body="&lt;p&gt;Problem is local shadow variable &lt;code&gt;b1&lt;/code&gt; in setup() function declared as &lt;code&gt;Beta b1 = Beta();&lt;/code&gt;. In &lt;code&gt;loop()&lt;/code&gt; is considered uninitialized global variable &lt;code&gt;b1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-09-10T18:12:13.357" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15970" PostTypeId="2" ParentId="10160" CreationDate="2015-09-10T19:28:47.283" Score="4" Body="&lt;p&gt;The other answers have really good info in them, but I'd still like to expound a bit on the different types of serial protocols, and how they vary in speed. I'll also mention a few devices and show some comparisons. &lt;strong&gt;For &lt;em&gt;synchronous&lt;/em&gt; vs &lt;em&gt;asynchronous&lt;/em&gt; and what that means, see Majenko's really good answer.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Clarification:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Your phrasing of &quot;receive a pulse train at a minimum speed of 10MHz&quot; is quite confusing to me. Perhaps this is because when I hear &quot;pulse train&quot; I think you mean you want to read pulse widths in order to obtain data, ie: like the PPM pulse train used in Radio Control communication signals. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is what you mean simply that you want 10Mbps (megabit per second) transmission rates? If so, the Arduino Intel Galileo can do &lt;a href=&quot;https://www.arduino.cc/en/ArduinoCertified/IntelGalileo&quot; rel=&quot;nofollow noreferrer&quot;&gt;SPI serial communication at a rate of up to &lt;strong&gt;25MHz&lt;/strong&gt;&lt;/a&gt;, or you can do Ethernet communication with this board up to &lt;strong&gt;10 MHz&lt;/strong&gt; or &lt;strong&gt;100 MHz&lt;/strong&gt; (see previous link as well). Note that some Ethernet devices can communicate up to &lt;strong&gt;1000 MHz&lt;/strong&gt; (like the &lt;a href=&quot;http://www.orangepi.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Orange Pi Plus&lt;/a&gt;), but the Intel Galileo only goes up to &lt;strong&gt;100 MHz&lt;/strong&gt;, according to the link above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB3.1 serial communication, if a device supports it, however, can be done up to &lt;strong&gt;10Gbps&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Standard RS-232 0-5V (TTL) Serial, and example:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Now, as for standard RS-232-type serial done with TTL logic levels (ie: signal voltage levels 0 to 5V), via a UART (piece of hardware that allows this type of asynchronous communication protocol), I have written C++ code on a PC and on a standard Arduino (ex: Nano, Uno, or Pro Mini--under $10 cost + $2 external UART) which communicates at &lt;strong&gt;250kbaud&lt;/strong&gt; (though &lt;strong&gt;2Mbaud&lt;/strong&gt; is possible on an Arduino Uno--see Connor Wolf's answer &lt;a href=&quot;https://arduino.stackexchange.com/questions/296/how-high-of-a-baud-rate-can-i-go-without-errors&quot;&gt;here&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When communicating via a serial UART type device, plugged into a PC via a USB plug, a Windows-based computer sees it as a &quot;COM&quot; port. The UART simply does USB to RS-232 TTL data conversion, so I can use this COM port as a serial port on the PC. Since pretty much every Arduino supports standard Serial communication, even the cheapest ones, this is very appealing to me to learn how to write C++ code to do this. I spent the last couple weeks working on my communication code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a serial communication speed of &lt;strong&gt;250kbaud&lt;/strong&gt; (&lt;strong&gt;250kbps&lt;/strong&gt; in my case) I am able to transfer 25-byte binary data packets from my PC to my sub-$10 Arduino at a rate of up to &lt;strong&gt;1000 packets/sec&lt;/strong&gt;, while doing error checking on the Arduino receiving the data. In my case, each packet contains 8 commands, plus error checking bytes and a couple other things, to control an RC vehicle.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Here's a few key serial protocols, and their associated speeds, to be aware of.&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;All of these are different types of serial communication protocols:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;h2&gt;I2C:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Normal Arduino (ex: Uno) default speed is 100kbps; it can be increased to 400kbps. Some non-Arduino devices can do 1Mbps or 3.4Mbps.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h2&gt;SPI:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Arduino default speed is 4Mbps. Normal Arduinos can go up to 8Mbps; Galileo can do 25Mbps. I have seen some devices (ex: Wiznet W5200 Ethernet chip), which can do SPI serial communication up to 80Mbps (&lt;a href=&quot;http://feilipu.me/2013/08/03/wiznet-w5200-arduino-shield/&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h2&gt;RS-232 TTL via UART:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is what most people mean I think when they just use the word &quot;serial&quot; without specifying it further by saying &quot;SPI,&quot; &quot;I2C,&quot; etc. Whenever you see the term &quot;baud&quot; or &quot;baudrate,&quot; this is the type of serial communication they are referring to too. Hardware (UART)-based serial communication is done via pins 0 and 1 on most Arduinos. Normally, the &quot;high-end&quot; speed is considered 115200bps, but I regularly use 250kbps on an Arduino. Up to 2 Mbps is theoretically possible under the right conditions for the Atmel AVR-based Arduinos, like the Uno. See Connor Wolf's answer &lt;a href=&quot;https://arduino.stackexchange.com/questions/296/how-high-of-a-baud-rate-can-i-go-without-errors&quot;&gt;here&lt;/a&gt;. Arduino also includes a software serial library for this type of serial communication on any of the Arduino's pins, and I have used it up to 250kbps. I haven't yet tested it beyond that speed, but being software-based, I'd expect it to become unreliable much beyond that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h2&gt;USB:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;USB Speeds (&lt;a href=&quot;https://en.wikipedia.org/wiki/USB&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/USB&lt;/a&gt;)&lt;br&gt;&#xA;USB 1.0: Low Speed mode (1.5Mbps), Full Speed mode (12Mbps)&lt;br&gt;&#xA;USB 2.0: High Speed (480Mbps)&lt;br&gt;&#xA;USB 3.0: SuperSpeed (5Gbps)&lt;br&gt;&#xA;USB 3.1: SuperSpeed+ (10Gbps)  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;h2&gt;Ethernet:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Standard rates are 10/100/1000 Mbps. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Conclusions:&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you must have a minimum of 10MHz (AKA mbps) communication rates, you can use the SPI, USB, or Ethernet protocols. I2C and RS-232 TTL serial are too slow. &lt;/li&gt;&#xA;&lt;li&gt;If you really want the ~500MHz communication rate, you can use USB 2.0 or higher, or Ethernet 1000Mbps. All the rest are too slow. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note that embedded boards and devices, microcontrollers, etc, can &lt;em&gt;all&lt;/em&gt; do some type of serial communication, even if it's just slow &lt;a href=&quot;https://en.wikipedia.org/wiki/Bit_banging&quot; rel=&quot;nofollow noreferrer&quot;&gt;bit-banged&lt;/a&gt; RS-232 TTL-type or SPI-type serial. Nevertheless, some high-end devices can do really high speed serial communication via USB, USB 3.0, high-speed Ethernet, high-speed SPI, etc. When it comes to really fast serial communication methods (~3Mbps and higher), &lt;em&gt;synchronous&lt;/em&gt; techniques must generally be used rather than &lt;em&gt;asynchronous&lt;/em&gt; techniques, as the errors in clock-rates caused by using separate clocks begin to be too pronounced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just need to look at your actual needs. For most of my needs, 250kbaud is plenty fast using the built-in UART inside every cheapo low-end AVR-based Arduino device. Your needs, however may be different.&lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-09-15T15:13:11.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15971" PostTypeId="1" AcceptedAnswerId="15975" CreationDate="2015-09-10T19:41:55.150" Score="3" ViewCount="148" Body="&lt;p&gt;I'm using Arduino clones, which have pin headers the same as Arduino's shields have (with extended &quot;legs&quot; below the board to be stackable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I stack my Arduino (Mega) clone to an Arduino (Uno) clone without destroying both? Wouldn't it explode or something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just asking before trying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13308" LastActivityDate="2015-09-10T23:48:49.467" Title="Can I stack an Arduino to another Arduino?" Tags="|arduino-uno|arduino-mega|clones|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15973" PostTypeId="2" ParentId="15949" CreationDate="2015-09-10T20:27:01.907" Score="3" Body="&lt;p&gt;I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;The temperature is &quot; + String(temperature) + &quot; degrees C&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this solution you can't format the variable's value but I find this quick and dirty for debug messages.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-09-10T20:27:01.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15974" PostTypeId="2" ParentId="15964" CreationDate="2015-09-10T20:53:30.140" Score="1" Body="&#xA;&#xA;&lt;p&gt;Here is some code I used to time a ball running down a ramp:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte LED = 12;&#xA;const byte photoTransistor = 2;&#xA;&#xA;unsigned long startTime;&#xA;volatile unsigned long elapsedTime;&#xA;volatile boolean done;&#xA;&#xA;void ballPasses ()&#xA;{&#xA;  // if high, start timing&#xA;  if (digitalRead (photoTransistor) == HIGH)&#xA;    {&#xA;    startTime = micros (); &#xA;    }&#xA;  else&#xA;    {&#xA;    elapsedTime = micros () - startTime;  &#xA;    done = true;&#xA;    }&#xA;&#xA;  digitalWrite (LED, !digitalRead (LED));  &#xA;}&#xA;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Timer sketch started.&quot;);  &#xA;  pinMode (LED, OUTPUT);&#xA;  attachInterrupt (0, ballPasses, CHANGE);&#xA;}&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (!done)&#xA;    return;&#xA;&#xA;  Serial.print (&quot;Time taken = &quot;);&#xA;  Serial.print (elapsedTime);&#xA;  Serial.println (&quot; uS&quot;);&#xA;  done = false;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;micros()&lt;/code&gt; here is probably overkill, but that should be good for an interval up to 71 minutes.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-10T20:53:30.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="15975" PostTypeId="2" ParentId="15971" CreationDate="2015-09-10T21:09:35.813" Score="5" Body="&lt;p&gt;No, I don't think that is a good idea. You would basically short the pins of each of them together, plus their power supplies. The only way it might conceivably work was if one Arduino had all its pins as inputs and the other as outputs, otherwise they would be &quot;fighting&quot; each other to drive a pin high or low. You would also have connected together their Reset pins so they would both reset at the same time. And doing serial comms would be problematic as the serial ports would be fighting each other.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, uploading sketches would be virtually impossible, as when you started the upload, both would be reset, both bootloaders would try to read the incoming data, and reply at the same time. Plus, the Mega and the Uno have different uploading protocols. So at the very least, you would have to separate them every time you uploaded new code, to either one.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-10T23:48:49.467" LastActivityDate="2015-09-10T23:48:49.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15976" PostTypeId="2" ParentId="14243" CreationDate="2015-09-10T21:28:06.540" Score="3" Body="&lt;p&gt;From the Arduino reference on AnalogRead:&#xA;&quot;It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;500msps is an awfully high rate - my first instinct is, perhaps you need to revisit what you are after, and why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are indeed chips that will do this for you. It is still not possible with an Arduino, since the Arduino can't even receive the data this fast, let alone process it. Assuming 8-bit sampling, this would generate a stream of data at 4gigabits/second - I doubt any disk drive could write that fast (SATA3 is 4.8gbit/sec, which is 20% more, I suspect that the 20% would be eaten up by overhead - you can't just send raw data to a drive, you also have to tell it where to put it. That just accounts for getting the data to the drive circuitry, not actually storing it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps what you're looking for is an oscilloscope. An oscilloscope takes high speed readings and displays them. Oscilloscopes are often used for testing circuits (e.g. looking at what an Arduino puts out/reads in when it's being programmed). Looking on National Instruments' websites, their cheapest one I could find that does &gt; 500msps is worth about US$8,000 (ballpark). You will still not be able to store this to disk, or process it in any meaningful way, in realtime - a board like this will typically capture data (based on a trigger, sample until the memory is full, then slowly move the data to the PC to process.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-10T21:28:06.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15977" PostTypeId="1" CreationDate="2015-09-10T21:34:35.840" Score="0" ViewCount="1216" Body="&lt;p&gt;I have a very simple sketch which I'm using to (try to) prove out an ethernet shield. The complete sketch is below. When I upload the sketch, the IP address that the shield gets is 0.140.140.140, which is incorrect. I just received the shield today from SparkFun, it is &lt;a href=&quot;https://www.sparkfun.com/products/11166&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. Am I doing something wrong, or is my shield  and/or Arduino broken? The Arduino is an Uno R3. The sketch works otherwise (the LED blinks as expected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Network information&#xA;byte mac[] = {0xDE, 0xAD, 0xBE, 0xCF, 0xFE, 0xEE };&#xA;byte ip[] = { 172, 31, 42, 201 };&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(4,OUTPUT);&#xA;  digitalWrite(4, HIGH);&#xA;  delay(1);&#xA;&#xA;  // initialize serial:&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting sketch...&quot;);&#xA;  Ethernet.begin(mac,ip);&#xA;  delay(1000);&#xA;  Serial.println(Ethernet.localIP());&#xA;  Serial.println(&quot;Setup done.&quot;);&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  digitalWrite(13,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(13,LOW);&#xA;  delay(1000);&#xA;  Serial.println(Ethernet.localIP());   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11545" LastActivityDate="2015-09-10T21:49:09.497" Title="Arduino ethernet shield not getting correct IP" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15978" PostTypeId="2" ParentId="15966" CreationDate="2015-09-10T21:41:25.783" Score="1" Body="&lt;p&gt;It is written in what is called the &lt;em&gt;USB String Descriptor&lt;/em&gt;.  I don't have my Yun to hand right now (it's acting as a wireless bridge temporarily), but all USB devices have these &lt;em&gt;USB String Descriptors&lt;/em&gt;.  Here's an example for the Leonardo (which you can easily inspect on Linux):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo lsusb -v -d 2341:0036&#xA;&#xA;Bus 001 Device 015: ID 2341:0036 Arduino SA &#xA;Device Descriptor:&#xA;  bLength                18&#xA;  bDescriptorType         1&#xA;  bcdUSB               1.10&#xA;  bDeviceClass            2 Communications&#xA;  bDeviceSubClass         0 &#xA;  bDeviceProtocol         0 &#xA;  bMaxPacketSize0         8&#xA;  idVendor           0x2341 Arduino SA&#xA;  idProduct          0x0036 &#xA;  bcdDevice            0.01&#xA;  iManufacturer           2 Arduino LLC      &amp;lt;&amp;lt;== String descriptor ID 2&#xA;  iProduct                1 Arduino Leonardo &amp;lt;&amp;lt;== String descriptor ID 1&#xA;  iSerial                 0 &#xA;  ... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Internally the strings are stored as an indexed table - there's two there, ID 1 and ID 2.  The &lt;em&gt;Device Descriptor&lt;/em&gt; then has a couple of bytes in it that says &quot;The manufacturer is string ID 2, and the product name is string ID 1&quot;.  The operating system then requests those string descriptors so it can display the friendly message for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to change that name you basically have to both re-program the bootloader (which has the USB descriptors when in program upload mode) and the Arduino core (that has the string descriptors programmed into it).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-10T21:41:25.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15979" PostTypeId="2" ParentId="15977" CreationDate="2015-09-10T21:49:09.497" Score="1" Body="&lt;p&gt;The sketch you have written works perfectly with a cheap Ethernet Shield clone from eBay.  Those (and the older Arduino Ethernet Shields) use the Wiznet W5100 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The new shields, of which you have one, use the newer, more powerful, Wiznet W5500 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't use the old Ethernet library with the new Wiznet W5500 chip.  It doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to use the &quot;Ethernet 2&quot; library as described here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://labs.arduino.org/Ethernet+2+Library&quot; rel=&quot;nofollow&quot;&gt;http://labs.arduino.org/Ethernet+2+Library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: this library is used to work with the new Ethernet shield (version 2) and Leonardo Eth that uses a new Controller W5500.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That page is linked from the product page you link to above.  If you had read the product page you would already know this.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-10T21:49:09.497" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="15980" PostTypeId="1" AcceptedAnswerId="15987" CreationDate="2015-09-11T03:17:41.450" Score="0" ViewCount="436" Body="&lt;p&gt;So I have a teensy and an arduino uno connected together via I2C, however some very odd behavior is occurring, when monitoring the serial connection for shorter data sent over I2C I receive the expected serial output. However if the data is longer I only receive 2 characters. More strange even is that if I send the longer data again I receive none, but if I send the shorter data I receive the expected output. After sending the shorter data again sending the longer data will result is the odd 2 characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uno code&#xA;     //#include &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;boolean pinout = 0;&#xA;byte current[512];&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Wire.begin(1);&#xA;  Serial.begin(115200);&#xA;  Wire.onReceive(data);&#xA;  //DmxSimple.usePin(3);&#xA;  //DmxSimple.maxChannel(30);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&#xA;void data(int numBytes){&#xA;//Serial.println(&quot;DATA RECIVED&quot;);&#xA;&#xA; delay(500);&#xA;&#xA; char input[20];&#xA; int pos = 0;&#xA;&#xA; while(Wire.available()){&#xA;   input[pos++] = Wire.read();&#xA;  }&#xA;  input[pos++] = '\0';&#xA;&#xA;  Serial.print(&quot;Recived \&quot;&quot;);&#xA;  Serial.print(input);&#xA;  Serial.println(&quot;\&quot;&quot;);&#xA;&#xA;  char* next = strchr(input, ',');&#xA;  while(next != 0){  &#xA;  *next = 0;&#xA;  next++;&#xA;  char* splitter = strchr(next, ':');&#xA;  if(splitter != 0){&#xA;  *splitter = 0;&#xA;  splitter++;&#xA;  int channel = atoi(next);&#xA;  int value = atoi(splitter);&#xA;      //DmxSimple.write(channel,value);&#xA;      Serial.print(channel); Serial.print(&quot;:&quot;); Serial.println(value);&#xA;    }&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Teensy code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            #include &amp;lt;i2c_t3.h&amp;gt;&#xA;            //#include &amp;lt;ArduinoPebbleSerial.h&amp;gt;&#xA;&#xA;     /*&#xA;    static const uint16_t SERVICE_ID = 0x1001;&#xA;static const uint16_t UPTIME_ATTRIBUTE_ID = 0x0002;&#xA;static const size_t UPTIME_ATTRIBUTE_LENGTH = 4;&#xA;static const uint16_t LAMP_ATTRIBUTE_ID = 0x0003;&#xA;static const size_t LAMP_ATTRIBUTE_LENGTH = 20;&#xA;&#xA;static const uint16_t SERVICES[] = {SERVICE_ID};&#xA;static const uint8_t NUM_SERVICES = 1;&#xA;&#xA;static const uint8_t PEBBLE_DATA_PIN = 1;&#xA;static uint8_t buffer[GET_PAYLOAD_BUFFER_SIZE(4)];&#xA;&#xA;typedef struct __attribute__((packed)){&#xA;  uint8_t channel;&#xA;  uint8_t value;&#xA;} DMXP;*/&#xA;&#xA;void setup() {&#xA;  pinMode(LED_BUILTIN, OUTPUT);&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  /*&#xA; #if defined(__MK20DX256__) || defined(__MK20DX128__)&#xA;  // Teensy 3.0/3.1 uses hardware serial mode (pins 0/1) with RX/TX shorted together&#xA; ArduinoPebbleSerial::begin_hardware(buffer, sizeof(buffer), Baud57600, SERVICES, NUM_SERVICES);&#xA;#elif defined(__AVR_ATmega32U4__)&#xA; // Teensy 2.0 uses the one-wire software serial mode&#xA; ArduinoPebbleSerial::begin_software(PEBBLE_DATA_PIN, buffer, sizeof(buffer), Baud57600, SERVICES,&#xA;                                  NUM_SERVICES);&#xA;#else&#xA;#error &quot;This example will only work for the Teensy 2.0, 3.0, or 3.1 boards&quot;&#xA;#endif&#xA;*/&#xA;/*for(int i = 1; i &amp;lt; 8; i++){&#xA;  sendChannel(i,0);&#xA;}&#xA;*/&#xA;&#xA;}&#xA;&#xA;/*&#xA;void handle_dmx_request(RequestType type, size_t length) {&#xA;if (type != RequestTypeWrite) {&#xA;  return;&#xA;}&#xA;&#xA;DMXP cmd = *(DMXP*)buffer;&#xA;sendChannel(cmd.channel, cmd.value);&#xA;&#xA;// ACK that the write request was received&#xA;ArduinoPebbleSerial::write(true, NULL, 0);&#xA;ArduinoPebbleSerial::notify(SERVICE_ID, UPTIME_ATTRIBUTE_ID);&#xA;}&#xA;*/&#xA;&#xA;void loop() {&#xA;&#xA;  /*&#xA;  if (ArduinoPebbleSerial::is_connected()) {&#xA;  digitalWrite(13,true);&#xA;} else {&#xA;  digitalWrite(13,false);&#xA;}&#xA;&#xA;uint16_t service_id;&#xA;uint16_t attribute_id;&#xA;size_t length;&#xA;RequestType type;&#xA;if (ArduinoPebbleSerial::feed(&amp;amp;service_id, &amp;amp;attribute_id, &amp;amp;length, &amp;amp;type)) {&#xA;  // process the request&#xA;  if (service_id == SERVICE_ID) {&#xA;    switch (attribute_id) {&#xA;      case LAMP_ATTRIBUTE_ID:&#xA;        handle_dmx_request(type, length);&#xA;        break;&#xA;      default:&#xA;        break;&#xA;    }&#xA;  }&#xA;}&#xA;*/&#xA;&#xA;}&#xA;&#xA;void serialEvent(){&#xA;  if(Serial.read() == 't'){&#xA;  digitalWrite(13,true);&#xA;  Serial.println(&quot;Starting Controller&quot;);&#xA;  int chans[8] = {1,2,3,4,5,6,7,8};&#xA;  int vals[8] = {2,4,6,8,16,32,64,128};&#xA;  sendChannel(chans,vals,4);&#xA;  } else {&#xA;    sendChannel(1,1);&#xA;  }&#xA;  while(Serial.available()){&#xA;    Serial.println(Serial.read());&#xA;  }&#xA;}&#xA;&#xA;&#xA;void sendChannel(int chan, int val){&#xA; char chno[8];&#xA;  itoa(chan,chno,10);&#xA;  char vano[8];&#xA; itoa(val,vano,10);&#xA; char message[20];&#xA; int messagei = 0;&#xA; for(int i = 0; i &amp;lt; 7; i++){&#xA; if(chno[i] == '\0'){&#xA;   break;&#xA;  }&#xA; message[messagei++] = chno[i];&#xA;}&#xA; message[messagei++] = ':';&#xA; for(int i = 0;i &amp;lt; 7; i++){&#xA; if(vano[i] == '\0'){&#xA;  break;&#xA; }&#xA; message[messagei++] = vano[i];&#xA; }&#xA;  //message[messagei++] = '\n';&#xA;//message[messagei++] = '\r';&#xA;message[messagei++] = '\0';&#xA;&#xA;Serial.println(message);&#xA;&#xA;Wire.beginTransmission(1);&#xA;Wire.write(message);&#xA;Wire.endTransmission();&#xA;}&#xA;&#xA;void sendChannel(int chan[], int val[], int num){&#xA; char message[20*num + 1];&#xA; int at = 0;&#xA;&#xA; for(int i = 0; i &amp;lt; num; i++){&#xA;char chno[8];&#xA;itoa(chan[i],chno,10);&#xA;char vano[8];&#xA;itoa(val[i],vano,10);&#xA;for(int i = 0; i &amp;lt; 7; i++){&#xA;  if(chno[i] == '\0'){&#xA;    break;&#xA;  }&#xA;  message[at++] = chno[i];&#xA;}&#xA;message[at++] = ':';&#xA;for(int i = 0;i &amp;lt; 7; i++){&#xA;  if(vano[i] == '\0'){&#xA;    break;&#xA;  }&#xA;  message[at++] = vano[i];&#xA;  }&#xA;  if(i+1!=num){&#xA;  message[at++] = ',';&#xA;  } else {&#xA;  message[at++] = 0;&#xA; }&#xA; }&#xA;&#xA; char finalMessage[at+1];&#xA; for(int i = 0; i &amp;lt;= at; i++){&#xA;finalMessage[i] = message[i];&#xA; }&#xA;&#xA; Serial.println(finalMessage);&#xA;&#xA;Wire.beginTransmission(1);&#xA;Wire.write(message);&#xA;Wire.endTransmission();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(If modifying the teensy code to run on a second arduino replace the line &lt;code&gt;#include &amp;lt;i2c_t3.h&amp;gt;&lt;/code&gt; with &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt; no other changes should be necessary)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the Teensy code open a serial terminal to access it, press 't' to send a long packet, or any other character to send a shorter one.&lt;/p&gt;&#xA;" OwnerUserId="13294" LastEditorUserId="13294" LastEditDate="2015-09-11T11:10:20.830" LastActivityDate="2015-09-11T11:10:20.830" Title="Unexpected output form Serial.println" Tags="|arduino-uno|serial|i2c|teensy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15982" PostTypeId="2" ParentId="13291" CreationDate="2015-09-11T05:07:11.193" Score="1" Body="&lt;p&gt;I could not figure out what was wrong, but I changed to this library for NRF24: &lt;a href=&quot;http://tmrh20.github.io/RF24/&quot; rel=&quot;nofollow&quot;&gt;http://tmrh20.github.io/RF24/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I started using the GY-85 with the FreeIMU Library : &lt;a href=&quot;http://www.varesano.net/projects/hardware/FreeIMU&quot; rel=&quot;nofollow&quot;&gt;http://www.varesano.net/projects/hardware/FreeIMU&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following this advice:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=164222.msg1539961#msg1539961&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=164222.msg1539961#msg1539961&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works now, so if it was SRAM as @Avamander suggested, it was not on my side.&lt;/p&gt;&#xA;" OwnerUserId="11089" LastActivityDate="2015-09-11T05:07:11.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15984" PostTypeId="1" AcceptedAnswerId="16028" CreationDate="2015-09-11T05:32:57.027" Score="0" ViewCount="2632" Body="&lt;p&gt;I am new to hobby electronics and have hit a dead end with my Intel Edison (which hopefully will not join the pile of useless components I have wasted my money on), and would appreciate some help with the setup procedure. The main problem is that I cannot connect to my Edison via the middle (lets call it &quot;A&quot;) micro-USB port in order to get it into a working condition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My objective is to connect to it's build-in Linux via SSH with the USB cables connected after installing the latest flash image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Edison with an Arduino breakout board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sequence of steps I followed:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I connected a 12V 2.6A AC to DC adapter to power the board. (Via the barrel connector). The green light came on to indicate it is powered.&lt;/li&gt;&#xA;&lt;li&gt;I connected the &quot;A&quot; micro-USB port (i.e. not the one on the edge) to my computer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this point I could access the drive through Windows Explorer, however this changed when I executed the next step:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;I installed the software from step 2 at &lt;a href=&quot;https://software.intel.com/en-us/iot/library/edison-getting-started&quot; rel=&quot;nofollow&quot;&gt;https://software.intel.com/en-us/iot/library/edison-getting-started&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Something went wrong during the subsequent installation process. I don't know what.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this point I could no longer access the drive. It would only appear as an &quot;Unknown device&quot; in Windows Device Manager. In order to try and fix this I gave up on the option where it is mounted as a Windows Drive.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;I connected to the micro-USB port at the edge of the Arduino board and disconnected A.&lt;/li&gt;&#xA;&lt;li&gt;I went to Windows Device Manager and found the connected device on COM6&lt;/li&gt;&#xA;&lt;li&gt;I installed Putty and connected to COM6 with a baud of 115200.&lt;/li&gt;&#xA;&lt;li&gt;The console showed a blank screen with a green cursor in the top left.&lt;/li&gt;&#xA;&lt;li&gt;I waited 30 seconds for it to boot.&lt;/li&gt;&#xA;&lt;li&gt;I hit Cntrl+C because I still saw the same screen from step 9.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I then saw this on the console:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&#xA;Unknown boot mode: boot&#xA;Saving Environment to MMC...&#xA;Writing to MMC(0)... done&#xA;Resetting to default boot mode and reboot...&#xA;resetting ...&#xA;&#xA;&#xA;******************************&#xA;PSH KERNEL VERSION: b0182b2b&#xA;                WR: 20104000&#xA;******************************&#xA;&#xA;SCU IPC: 0x800000d0  0xfffce92c&#xA;&#xA;PSH miaHOB version: TNG.B0.VVBD.0000000c&#xA;&#xA;microkernel built 11:24:08 Feb  5 2015&#xA;&#xA;******* PSH loader *******&#xA;PCM page cache size = 192 KB&#xA;Cache Constraint = 0 Pages&#xA;Arming IPC driver ..&#xA;Adding page store pool ..&#xA;PagestoreAddr(IMR Start Address) = 0x04899000&#xA;pageStoreSize(IMR Size)          = 0x00080000&#xA;&#xA;*** Ready to receive application ***&#xA;&#xA;&#xA;U-Boot 2014.04 (Jun 19 2015 - 12:05:55)&#xA;&#xA;       Watchdog enabled&#xA;DRAM:  980.6 MiB&#xA;MMC:   tangier_sdhci: 0&#xA;In:    serial&#xA;Out:   serial&#xA;Err:   serial&#xA;Hit any key to stop autoboot:  0&#xA;Target:ifwi&#xA;Partitioning already done...&#xA;Partitioning already done...&#xA;Saving Environment to MMC...&#xA;Writing to redundant MMC(0)... done&#xA;GADGET DRIVER: usb_dnl_dfu&#xA;&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea what to do next.&lt;/p&gt;&#xA;" OwnerUserId="13319" LastActivityDate="2015-09-12T13:25:36.853" Title="Unable to set up Intel Edison on Windows" Tags="|edison|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15985" PostTypeId="1" AcceptedAnswerId="15986" CreationDate="2015-09-11T05:31:40.527" Score="2" ViewCount="2602" Body="&lt;p&gt;I have something strange going on with an output. When the following code is called the LED goes on, but it stays on, there is no blinking. If I comment out the set HIGH statement the LED never comes on (as expected). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define devicePin 10&#xA;&#xA;void setup() {&#xA;  pinMode(devicePin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(devicePin, HIGH);&#xA;    delay(2000);&#xA;    digitalWrite(devicePin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could I have damaged the board in some way?&lt;/p&gt;&#xA;" OwnerUserId="13330" OwnerDisplayName="P Hemans" LastEditorUserId="10794" LastEditDate="2015-09-12T00:26:43.247" LastActivityDate="2015-09-12T00:26:43.247" Title="Arduino Pin won't go LOW" Tags="|c++|led|digital|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15986" PostTypeId="2" ParentId="15985" CreationDate="2015-09-11T05:40:34.133" Score="5" Body="&lt;p&gt;After you drive the pin low, you immediately go to the beginning of the loop and set the pin high (if you have an oscilloscope, you might see a very short downward pulse).&lt;br&gt;&#xA;So, add another delay after &lt;code&gt;digitalWrite(devicePin, LOW)&lt;/code&gt;.  &lt;/p&gt;&#xA;" OwnerDisplayName="Nick Alexeev" LastActivityDate="2015-09-11T05:40:34.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15987" PostTypeId="2" ParentId="15980" CreationDate="2015-09-11T05:51:01.017" Score="1" Body="&#xA;&#xA;&lt;p&gt;Your code which I will reproduce here as it wasn't in the question has a major issue:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//#include &amp;lt;DmxSimple.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;boolean pinout = 0;&#xA;byte current[512];&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Wire.begin(1);&#xA;  Serial.begin(115200);&#xA;  Wire.onReceive(data);&#xA;  //DmxSimple.usePin(3);&#xA;  //DmxSimple.maxChannel(30);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&#xA;void data(int numBytes){&#xA;  //Serial.println(&quot;DATA RECIVED&quot;);&#xA;&#xA;  delay(500);&#xA;&#xA;  char input[20];&#xA;  int pos = 0;&#xA;&#xA;  while(Wire.available()){&#xA;    input[pos++] = Wire.read();&#xA;  }&#xA;  input[pos++] = '\0';&#xA;&#xA;  Serial.print(&quot;Recived \&quot;&quot;);&#xA;  Serial.print(input);&#xA;  Serial.println(&quot;\&quot;&quot;);&#xA;&#xA;  char* next = strchr(input, ',');&#xA;  while(next != 0){  &#xA;   *next = 0;&#xA;   next++;&#xA;    char* splitter = strchr(next, ':');&#xA;    if(splitter != 0){&#xA;      *splitter = 0;      Wire.onReceive(data);&#xA;  //DmxSimple.usePin(3);&#xA;  //DmxSimple.maxChannel(30);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your function &lt;code&gt;data&lt;/code&gt; does &lt;code&gt;Serial.print&lt;/code&gt;s. It is called as an interrupt service routine effectively, and thus should not do serial prints:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;      Wire.onReceive(data);&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;    }&#xA;&#xA;    void data(int numBytes){&#xA;&#xA;...&#xA;&#xA;      Serial.print(&quot;Recived \&quot;&quot;);&#xA;      Serial.print(input);&#xA;      Serial.println(&quot;\&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;More strange even is that if I send the longer data again I receive none, ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yep, that will definitely happen. The serial printing &quot;blocks&quot; if you print a lot, and thus the code will hang indefinitely.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You definitely should not use &lt;code&gt;delay&lt;/code&gt; in an interrupt routine. It will almost certainly hang because the timer interrupts which are needed for &lt;code&gt;delay&lt;/code&gt; to work are not being serviced.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Wire.begin(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should not be choosing to use I2C address 1. It is reserved. See:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.totalphase.com/support/articles/200349176&quot; rel=&quot;nofollow&quot;&gt;7-bit, 8-bit, and 10-bit I2C Slave Addressing&lt;/a&gt; and &lt;a href=&quot;http://www.nxp.com/documents/user_manual/UM10204.pdf&quot; rel=&quot;nofollow&quot;&gt;I2C specification (pdf)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Slave Address   R/W Bit     Description&#xA;000 0000    0   General call address&#xA;000 0000    1   START byte(1)&#xA;000 0001    X   CBUS address(2)&#xA;000 0010    X   Reserved for different bus format (3)&#xA;000 0011    X   Reserved for future purposes&#xA;000 01XX    X   Hs-mode master code&#xA;111 10XX    X   10-bit slave addressing&#xA;111 11XX    X   Reserved for future purposes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(1) No device is allowed to acknowledge at the reception of the START byte.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(2) The CBUS address has been reserved to enable the inter-mixing of CBUS compatible and I2C-bus compatible devices in the same system. I2C-bus compatible devices are not allowed to respond on reception of this address.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(3) The address reserved for a different bus format is included to enable I2C and other protocols to be mixed. Only I2C-bus compatible devices that can work with such formats and protocols are allowed to respond to this address.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-11T06:22:51.593" LastActivityDate="2015-09-11T06:22:51.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15988" PostTypeId="1" AcceptedAnswerId="15995" CreationDate="2015-09-11T06:01:46.790" Score="0" ViewCount="174" Body="&lt;p&gt;Sorry that I repeat my question, I can't enter to my user...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the project I'm doing, I connect an arduino mega with ethernet and Post some Strings to the server. The arduino mega has a receiver(315MHz). I have some arduinos nano connected with PIR sensors that sends a some int with transmitters (315MHz). What I want to do is a list in my arduino mega that stores the values sent by the arduinos nanos to use them to my server (using POST). my question is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I had an empty array, what I would like to do is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;listOfSensors[]={}&#xA;&#xA;void funtion (String sensor){&#xA;    if (sensor is inside listOfSensors){&#xA;         //dont do anything&#xA;    }&#xA;    else {&#xA;         add sensor to listOfSensors&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have been looking for hours, but I haven't found anything so far... Anyone has any idea? Thanks!!&lt;/p&gt;&#xA;" OwnerUserId="13316" LastActivityDate="2015-09-11T13:18:55.440" Title="Consulting and inserting a string into an array if it doesn't exist (Arduino IDE) 1" Tags="|arduino-ide|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15989" PostTypeId="2" ParentId="15985" CreationDate="2015-09-11T06:50:35.420" Score="3" Body="&lt;p&gt;you forgot to add a delay after digitalWrite(devicePin, LOW);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define devicePin 10&#xA;&#xA;void setup() {&#xA;  pinMode(devicePin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(devicePin, HIGH);&#xA;    delay(2000);&#xA;    digitalWrite(devicePin, LOW);&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13197" LastActivityDate="2015-09-11T06:50:35.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15990" PostTypeId="2" ParentId="8672" CreationDate="2015-09-11T06:53:35.573" Score="1" Body="&lt;p&gt;&lt;code&gt;Wire.endTransmission()&lt;/code&gt; is where the action is. Nothing is actually sent until that point. &lt;code&gt;Wire.beginTransmission&lt;/code&gt; just gets ready for sending and &lt;code&gt;Wire.write&lt;/code&gt; (if used) adds stuff to an internal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it hangs at that point you probably have dodgy hardware. Check the connections are correct (ie. SDA/SCL the right way around, and that it is powered, and that you have a common ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then try a pull-up resistor between SDA and +5V, and SCL and +5V. A typical value resistor (for both resistors) would be 4.7k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see from the linked page that the board already has 10k resistors. Hopefully you did not cut the jumper links. Whether or not you did you might want to augment them with 4.7k resistors. Also keep the cable runs short.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-11T06:53:35.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15991" PostTypeId="1" AcceptedAnswerId="15994" CreationDate="2015-09-11T08:12:29.793" Score="0" ViewCount="1464" Body="&lt;p&gt;I'm working with VirtualWire and I'm trying to get a string value out of the Serial.println in the loop. I've tried create a string and add the message[i] , but surprisingly message[i] becomes an int when added. Serial.println outputs the string correctly, but the string that I get from message[i] is just numbers...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages&#xA;byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message&#xA;String sensorname;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Device is ready&quot;);&#xA;  // Initialize the IO and ISR&#xA;  vw_setup(2000); // Bits per sec&#xA;  vw_rx_start(); // Start the receiver&#xA;  }&#xA;void loop(){&#xA;&#xA;  if (vw_get_message(message, &amp;amp;messageLength)){&#xA;    Serial.print(&quot;Received: &quot;);&#xA;    for (int i = 0; i &amp;lt; messageLength; i++){&#xA;      Serial.write(message[i]);&#xA;      sensorname += message[i];&#xA;      }&#xA;      Serial.println();&#xA;      Serial.pintln(&quot;Name of sensor: &quot; + sensorname);&#xA;      sensorname=&quot;&quot;;  //Reestart the string&#xA;      }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm quite new with VirtualWire so I don't know if there is command to get the message and pass it directly to string...Any help will be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; &#xA;I think I dind't express myself well. In my original question I didn't add the String sensor name&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Response I get in the Serial is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Device is ready    &#xA;SensorA&#xA;Name of sensor: 8310111011511111465&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My aim is to instead of having as sensorname=8310111011511111465, have sensorname=SensorA&lt;/p&gt;&#xA;" OwnerUserId="13316" LastEditorUserId="13316" LastEditDate="2015-09-11T09:11:11.823" LastActivityDate="2015-09-11T09:47:47.660" Title="Convert the Serial.Println to string" Tags="|virtualwire|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15994" PostTypeId="2" ParentId="15991" CreationDate="2015-09-11T09:47:47.660" Score="0" Body="&lt;p&gt;Those numbers are the numerical ASCII representation of the characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;83 = S&#xA;101 = e&#xA;110 = n&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Find the whole list here: &lt;a href=&quot;http://www.asciitable.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.asciitable.com/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason you are ending up with numbers is because of the &lt;em&gt;type&lt;/em&gt; of variable you are receiving the data into - a &lt;em&gt;byte&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;em&gt;byte&lt;/em&gt; stores a number between 0 and 255.  When you add that &lt;em&gt;byte&lt;/em&gt; to a &lt;em&gt;String&lt;/em&gt; the compiler assumes you want to append a number, since it is a numerical type that you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you instead tell it to use a &lt;em&gt;char&lt;/em&gt; type then the compiler should realise &quot;Ah, this is the numeric representation of a character - I will add the character instead&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either change the whole array type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &lt;em&gt;cast&lt;/em&gt; the variable to be the right type when you append it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  sensorname += (char)message[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or better still, don't use the String class since it is really too heavyweight and prone to memory issues for use on a little microcontroller.  Stick to C strings. They take a little more getting used to, but are so much more microcontroller friendly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-11T09:47:47.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="15995" PostTypeId="2" ParentId="15988" CreationDate="2015-09-11T10:11:17.257" Score="0" Body="&lt;p&gt;In C there is no such thing as an &quot;empty array&quot;.  All arrays have a finite pre-defined size.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String sensors[10]; // Room for up to 10 sensors&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The usual way of storing an unknown number of entries that will be added to &quot;as and when&quot; is to use a &lt;em&gt;linked list&lt;/em&gt; or &lt;em&gt;doubly-linked list&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;em&gt;linked list&lt;/em&gt; is a list of items where each item also contains a pointer to say where the next item in the list is located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you shouldn't use the String class as it is not good when working with linked lists (or in general - stick to C strings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning: linked lists aren't for the faint of heart.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you would define a &lt;em&gt;struct&lt;/em&gt; to store the data you want in the linked list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct sensor {&#xA;    char *name;&#xA;    int currentValue;&#xA;    struct sensor *next;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would store the name of the sensor (&quot;name&quot;), the current value from the sensor (&quot;currentValue&quot;) and also contains a pointer (&quot;*next&quot;) to the next entry in the list.  That last bit is the most important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you create a &quot;head&quot; pointer variable to start your list off:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct sensor *mySensors = NULL;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That starts out as &lt;em&gt;NULL&lt;/em&gt; to say &quot;This variable has nothing in it at the moment&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that was the easy part.  The hard part is adding entries to the list...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of &lt;em&gt;helper&lt;/em&gt; functions can be of use here.  Let's start by defining a function that will look for a specific entry by name in the list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct sensor *findSensor(const char *name) {&#xA;    for (struct sensor *scan = mySensors; *scan; scan = scan-&amp;gt;next) {&#xA;        if (strcmp(scan-&amp;gt;name , name) == 0) {&#xA;            return scan;&#xA;        }&#xA;    }&#xA;    return NULL;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will start off with a pointer variable &lt;em&gt;scan&lt;/em&gt; pointing to the first entry in the linked list (mySensors).  While it's pointing to a valid entry (not NULL) compare the name to the given string and if they match then return the entry we are pointing to.  Next point to whatever the &quot;next&quot; pointer is pointing to, so you move down the list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to add a sensor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct sensor *addSensor(const char *name, int value) {&#xA;    // First look to see if it exists:&#xA;    struct sensor existing = findSensor(name);&#xA;    if (existing != NULL) { // We found it&#xA;        existing-&amp;gt;currentValue = value; // Update the value&#xA;        return existing;&#xA;    }&#xA;    // We haven't got it in our list, so create a new entry:&#xA;    struct sensor newsensor = (struct sensor *)malloc(sizeof(struct sensor));&#xA;    // And fill in the data:&#xA;    newsensor-&amp;gt;name = strdup(name); // Create a COPY of the string&#xA;    newsensor-&amp;gt;currentValue = value; // Store the value&#xA;    newsensor-&amp;gt;next = NULL; &#xA;    // IMPORTANT: The new entry must point to NULL to mark the end of the list:&#xA;    newsensor-&amp;gt;next = NULL; &#xA;&#xA;    // Now where to add it in the list? Is there even a list?&#xA;    if (mySensors == NULL) {&#xA;        // No? Then we just make our new entry the head of the list:&#xA;        mySensors = newsensor;&#xA;        return newsensor;&#xA;    }&#xA;    // Otherwise we need to scan through the whole list to find&#xA;    // where the tail of the list is:&#xA;&#xA;    struct sensor *scan = mySensors;&#xA;    // While the current entry points to a valid next entry&#xA;    while (scan-&amp;gt;next) {&#xA;        // move on to that next entry&#xA;        scan = scan-&amp;gt;next;&#xA;    }&#xA;    // There must be no valid next entry now (scan-&amp;gt;next == NULL), so&#xA;    //  add our new sensor as the next valid entry:&#xA;    scan-&amp;gt;next = newsensor;&#xA;    return newsensor;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Removing a sensor from the list is a much more involved process (even more than adding a sensor).  You need to &quot;splice&quot; the list around the deleted entry.  I'll add detail on that if you need it, but by the sound of things you won't be removing entries, only adding them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The routines shown there (I haven't actually tested them, but it is standard code I write all the time) aren't as efficient as they could be.  If you are adding and removing entries all the time and you end up with quite a large list it can take longer and longer to scan right through the list to find the last entry to add to.  If that is the case you can maintain a &quot;tail&quot; pointer that you always update to point to the last added entry whenever you add one.  That can then be used to rapidly add to the end of the list without having to scan through the whole list every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another optimisation if you do a lot of scanning around within a list is to make a &lt;em&gt;doubly linked list&lt;/em&gt;.  This is just like the linked list above except it works in both directions.  Not only do you store a &lt;em&gt;next&lt;/em&gt; pointer, you also store a &lt;em&gt;previous&lt;/em&gt; pointer.  You can now scan in either direction - from head to tail or from tail to head, or hopping around at will inside the list.  That is especially useful if you want to do things like ordering the list alphabetically.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-11T10:11:17.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="15996" PostTypeId="2" ParentId="8715" CreationDate="2015-09-11T10:30:13.143" Score="0" Body="&lt;p&gt;Windows troubleshooter is just trying to tell you that you've plugged a USB2 device into a USB3 port, thus wasting its USB3 capabilities which could be useful for another device. Of course, if you only have USB3, you can't do otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB3 is fully backward-compatible with USB2, so whatever your problem is, it is not related to the fact that you plug the Nano into a USB3 port. Perhaps your problem comes from the fact that your Nano is &quot;third party&quot; - I suppose that means it's not the original device and thus it may not be fully compatible. If my guess is right, try to find out what programmer your Nano clone supports: chances are you just need to select a different programmer type in Arduino settings, or buy a separate programmer supported by your device.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastEditorUserId="13327" LastEditDate="2015-09-11T10:35:57.100" LastActivityDate="2015-09-11T10:35:57.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="15999" PostTypeId="2" ParentId="15988" CreationDate="2015-09-11T13:18:55.440" Score="0" Body="&lt;p&gt;If you only need to add items of a fixed size to your sensor list (i.e. you don't need to delete items or sort them), you can use an uninitialized array large enough for the maximum number of items it will need to hold: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAXSENSORS 30               // max sensor count&#xA;#define SNAMELEN 12                 // max sensor name length&#xA;&#xA;struct sensorData {&#xA;    char sname[SNAMELEN+1];&#xA;    uint16_t svalue;&#xA;};                                  // defines data for 1 sensor&#xA;&#xA;uint8_t sensorCount = 0;&#xA;struct sensorData listOfSensors[MAXSENSORS]={0}; // array of sensor data, initialized to 0, 0, ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll also need an unsigned int (perhaps only a byte) to keep track of the count of items in the array, which you'll increment every time you add another sensor (up to the maximum number).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is what you meant by &quot;empty array&quot;. You would add your next sensor data at &lt;code&gt;listOfSensors[i]&lt;/code&gt;, then increment i. Likewise, you would search for a sensor in the array from &lt;code&gt;listOfSensors[0]&lt;/code&gt; to &lt;code&gt;listOfSensors[i-1]&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-11T13:18:55.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16000" PostTypeId="2" ParentId="15924" CreationDate="2015-09-11T13:48:37.147" Score="0" Body="&lt;p&gt;Here is a project where I make a Yun into a hotspot and even have it act like a captive portal so users can control things though the Yun...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://wp.josh.com/2014/05/01/a-platform-for-casual-encounters-with-interactive-technology/&quot; rel=&quot;nofollow&quot;&gt;http://wp.josh.com/2014/05/01/a-platform-for-casual-encounters-with-interactive-technology/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though it does work, I can not recommend using the Yun for something like this unless you have no other choice. It is just not a good platform and you end up wasting huge amounts of time on unnecessary problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much better to use something like a BeagleBone or Raspberry PI to handle to Wifi stuff. You can then connect these to a normal Arduino if necessary to deal with your hardware. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-09-11T13:48:37.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16001" PostTypeId="1" AcceptedAnswerId="16003" CreationDate="2015-09-11T13:58:03.633" Score="0" ViewCount="1915" Body="&lt;p&gt;I am working on a project in which i have to send commands using sms (GSM shield) to the arduino uno to control dc motor. What i want to know is that how can i define the instruction strings that i can send in form of sms and arduino uno reads it and executes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I am a total beginner at arduino coding so please help me out.&lt;/p&gt;&#xA;" OwnerUserId="13332" LastActivityDate="2015-09-12T21:23:28.197" Title="How does arduino fetch instruction string from sms and execute?" Tags="|arduino-uno|gsm|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16002" PostTypeId="2" ParentId="15908" CreationDate="2015-09-11T16:36:41.250" Score="1" Body="&lt;p&gt;The “hint of blue on the strip” is a consequence of your second loop in &lt;code&gt;rgbFadeInAndOutStrip1()&lt;/code&gt; ending with the test &lt;code&gt;b &amp;gt; 0&lt;/code&gt;.  Because of that, the last &lt;code&gt;strip1.setPixelColor()&lt;/code&gt; call sets the color to (0,0,1), a faint blue, instead of (0,0,0), off.  Here is some revised code that works ok:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;enum { rgbPin1=8, rgbPin2=7, LEDcount=11, ledFadeTime=5};&#xA;&#xA;Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(LEDcount, rgbPin1);&#xA;Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(LEDcount, rgbPin2);&#xA;&#xA;void setup() {&#xA;  strip1.begin();&#xA;  strip1.show(); // Initialize all pixels to 'off'&#xA;  strip2.begin();&#xA;  strip2.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  rgbFadeInAndOutStrip1(0, 0, 255, ledFadeTime); // Blue&#xA;  rgbFadeInAndOutStrip2(255, 0, 0, ledFadeTime); // red&#xA;}&#xA;&#xA;void fadeStrip(Adafruit_NeoPixel *strip, int bval, int bdir, uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  for(uint8_t b=0; b&amp;lt;255; ++b) {&#xA;    bval += bdir;&#xA;    for(uint8_t i=0; i&amp;lt;strip-&amp;gt;numPixels(); ++i) {&#xA;      strip-&amp;gt;setPixelColor(i, red * bval/255, green * bval/255, blue * bval/255);&#xA;    }&#xA;    strip-&amp;gt;show();&#xA;    delay(wait);&#xA;  } &#xA;}&#xA;&#xA;void rgbFadeInAndOutStrip1(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  fadeStrip(&amp;amp;strip1, -1, 1,   red, green, blue, wait);&#xA;  fadeStrip(&amp;amp;strip1, 255, -1, red, green, blue, wait);&#xA;}&#xA;&#xA;void rgbFadeInAndOutStrip2(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {&#xA;  fadeStrip(&amp;amp;strip2, -1, 1,   red, green, blue, wait);&#xA;  fadeStrip(&amp;amp;strip2, 255, -1, red, green, blue, wait);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, since I ran tests on an Uno rather than a Leonardo, I attached pixel strings to pins 7 and 8 rather than 17 and 18.  I used &lt;code&gt;enum&lt;/code&gt; to define constants, rather than declaring constants as variables, and factored some common code into functions rather than reduplicating it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is another program (which I call neocycle6) you can use to test two strips.  Note, it only counts colors down to 1 rather than 0 because I like the effect of leftover pixels glowing faintly.  Also note: the round boards I used have only 7 LEDs each, so I set &lt;code&gt;PixelCount&lt;/code&gt; to 7, not 11; this uses pins 7 and 8, not 17 and 18; I don't drive the brightness beyond 77 since the LEDs are so bright anyway; and it doesn't have an&#xA;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&lt;/code&gt; statement, which you can add if needed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Drive 2 sets of 7 ea. WS2812 NeoPixels through sets of colors.&#xA;// jw 11 September 2015  &#xA;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;// Select pin# connected to NeoPixels strand, and number of NeoPixels.&#xA;enum { PixelPinA=7, PixelPinB=8, PixelCount=7 };&#xA;// Create a NeoPixels device structure&#xA;Adafruit_NeoPixel pixelA = Adafruit_NeoPixel(PixelCount, PixelPinA);&#xA;Adafruit_NeoPixel pixelB = Adafruit_NeoPixel(PixelCount, PixelPinB);&#xA;&#xA;void setup() {&#xA;  byte i, j=0;&#xA;  pixelA.begin();               // Init. NeoPixel data structure&#xA;  pixelB.begin();               // Init. NeoPixel data structure&#xA;}&#xA;&#xA;uint8_t c=1, d=1, p=0, v=1;&#xA;void loop() {&#xA;  c += d;&#xA;  if (c&amp;gt;76)&#xA;    d = -1;                     // Go down when done going up&#xA;  else {&#xA;    if (c&amp;lt;2) {                  // Set up for next pixel&#xA;      d = 1; p = (p+1)%PixelCount;&#xA;      if (!p) ++v;              // Rotate the weights to next color&#xA;    }&#xA;  }&#xA;&#xA;  pixelA.setPixelColor(p, c*(v&amp;amp;1), c*((v&amp;amp;2)/2), c*((v&amp;amp;4)/4));&#xA;  pixelB.setPixelColor(p, c*((v&amp;amp;2)/2), c*(v&amp;amp;1), c*((v&amp;amp;4)/4));&#xA;  pixelA.show();               // Show updated colors&#xA;  pixelB.show();               // Show updated colors&#xA;  delay(9 + 300/c);            // Ramp small numbers more slowly&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-09-11T17:04:16.510" LastActivityDate="2015-09-11T17:04:16.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16003" PostTypeId="2" ParentId="16001" CreationDate="2015-09-11T16:57:43.937" Score="1" Body="&lt;p&gt;Your GSM shield will receive the SMS which your Arduino code can retrieve as a string of characters (that description hides a mountain of detail, most of which you won't need to know). It doesn't care what the content of the SMS message is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Arduino code will have to translate from the message text to motor-control commands so you want some text commands that will be easy to parse, but not so trivial that any random message might wrongly be interpreted as legitimate commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The digit pair &quot;15&quot; might command motor 1 to speed 5. But you wouldn't want any message with a couple of digits in it to change a motor. (You didn't say you had multiple motors, and if not you can leave that part out).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's make the message distinctive enough that it's unlikely to appear in some other context, yet simple enough to distinguish as legitimate. It would be nice if it's simple to thumb-type, too!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;motor,1,5&quot; could convey the same information as the &quot;15&quot; in our first example, doesn't limit you one-digit values, isn't likely to appear in a &quot;Hey Dude, lunch at 12:15?&quot; type of conversation, is easy to parse and isn't too long to type on a tiny keyboard. You could extend it later, so &quot;motor,1,+2&quot; could mean to increase motor 1's speed by two units, &quot;motor,1,off&quot; could mean power it down (not just zero speed), and &quot;motor,all,off&quot;, well, that's probably obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look up the function &lt;code&gt;sscanf()&lt;/code&gt; [oops: not sprintf()] for one way to parse the incoming strings and collect their data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: sscanf() does the reverse of sprintf(): It reads a string, collects values from it, and assigns them to variables. Search sscanf on the web for a description of its use.&#xA;&lt;br&gt;Here is a sample program that reads a few possible SMS messages, checks whether they are motor commands (according to my simple example SMS above), and if it is, assigns the contained values to some variables in your program. You can see by the return values of sscanf() whether and how many conversions it made from each message, thus your code can tell whether a received SMS looks like a motor command, as well as what the command values are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * sscanf example - Uses sscanf to test and collect data from a&#xA; * a command string.&#xA; */&#xA;&#xA;#include &amp;lt;WProgram.h&amp;gt;&#xA;&#xA;void test_sscanf(const char *sms);&#xA;&#xA;// Sample of SMS messages to test whether our sscanf() format string&#xA;// can recognize good ones and reject bad ones. Experiment by adding&#xA;// ones of your own:&#xA;const char *SMS[] =&#xA;{&#xA;   &quot;motor,1,5&quot;,&#xA;   &quot;Hello World,3,2&quot;,&#xA;   &quot;motor 123 456&quot;,&#xA;   &quot;moto, 7, 13&quot;,&#xA;   &quot;motorized, 4, 11&quot;&#xA;};&#xA;&#xA;&#xA;void setup() {&#xA;   Serial.begin(9600);&#xA;&#xA;   delay(1000);     // delay for user to launch a terminal (if you're quick)&#xA;&#xA;   // Test each SMS example in the SMS array&#xA;   for( uint8_t s = 0; s &amp;lt; sizeof(SMS)/sizeof(char *); ++s ){&#xA;      test_sscanf(SMS[s]);  // test one SMS string&#xA;   }&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;   ;            // nothing to do here&#xA;}&#xA;&#xA;&#xA;// Tests a sample SMS, prints the number of variables it assigned, and what&#xA;// their values were. '0' means it didn't assign any, probably because the&#xA;// command-word failed to match.&#xA;void test_sscanf(const char *sms)&#xA;{&#xA;   int16_t assigned, values[2];&#xA;&#xA;   // Print the SMS and convert it.&#xA;   Serial.print(&quot;\nSMS: \&quot;&quot;); Serial.print(sms); Serial.println(&quot;\&quot;&quot;);&#xA;   assigned = sscanf(sms, &quot;motor,%d,%d&quot;, &amp;amp;values[0], &amp;amp;values[1]);&#xA;&#xA;   // Display the results&#xA;   Serial.print(assigned);  Serial.println(&quot; values assigned&quot;); // How many values? A good command has 2.&#xA;   if( assigned &amp;gt; 0 ){&#xA;      for( uint8_t i = 0; i &amp;lt; assigned; ++i){&#xA;     Serial.print(&quot;value[&quot;); Serial.print(i+1); Serial.print(&quot;] = &quot;); // print each assigned value&#xA;     Serial.println(values[i]);&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-09-12T21:23:28.197" LastActivityDate="2015-09-12T21:23:28.197" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16004" PostTypeId="1" AcceptedAnswerId="16006" CreationDate="2015-09-11T17:51:15.463" Score="0" ViewCount="85" Body="&lt;p&gt;When I upload this code LED at pin 13 goes HIGH and that's it. My goal is to make it blink in the order specified in the array. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Array[] = {1,1,1,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0};&#xA;int Data = 13;&#xA;int i = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(Data, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    int x = Array[i];&#xA;    delay(200);&#xA;    digitalWrite(Data, x);&#xA;    i = i+1;&#xA;    if (i==23) {&#xA;        i=0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13333" LastEditorUserId="10794" LastEditDate="2015-09-11T22:56:00.677" LastActivityDate="2015-09-11T22:56:00.677" Title="Simple Arduino Code Not Working" Tags="|arduino-uno|c++|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16005" PostTypeId="1" AcceptedAnswerId="16007" CreationDate="2015-09-11T17:53:11.730" Score="0" ViewCount="71" Body="&lt;p&gt;I'm experimenting with buttons and LEDs and I would like my code to change a LED's brightness once a button is pressed. I connect the LED to the PWD digital pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My circuit looks like this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ptv4v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ptv4v.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int switchPin = 8;&#xA;int ledPin = 11;&#xA;boolean lastButton = LOW;&#xA;boolean currentButton = LOW;&#xA;int ledLevel = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(switchPin, INPUT);&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;boolean debounce(boolean last) {&#xA;    boolean current = digitalRead(switchPin);&#xA;    if (last != current) {&#xA;        delay(5);&#xA;        current = digitalRead(switchPin);&#xA;    }&#xA;return current;&#xA;}&#xA;&#xA;void loop() {&#xA;    currentButton = debounce(lastButton);&#xA;    if (lastButton == LOW &amp;amp;&amp;amp; currentButton == HIGH) {&#xA;        ledLevel = ledLevel + 51;&#xA;    }&#xA;    lastButton = currentButton;&#xA;&#xA;    if (ledLevel &amp;gt; 255) ledLevel = 0;&#xA;    analogWrite(ledPin, ledLevel);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though, the LED never turns on, but the light on the Arduino is on. I made sure the leads of the LED were in the right spot. Why doesn't the LED turn on?&lt;/p&gt;&#xA;" OwnerUserId="13334" LastEditorUserId="13334" LastEditDate="2015-09-12T20:47:31.330" LastActivityDate="2015-09-12T20:47:31.330" Title="Why doesn't the LED turn on in this circuit?" Tags="|c++|led|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16006" PostTypeId="2" ParentId="16004" CreationDate="2015-09-11T17:53:52.213" Score="1" Body="&lt;p&gt;What you're doing wrong is living your life at a normal speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LED will be blinking, but so fast you can't see it change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without adding some delays in there you will just see the LED light up.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-11T17:53:52.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16007" PostTypeId="2" ParentId="16005" CreationDate="2015-09-11T17:55:30.457" Score="2" Body="&lt;p&gt;Because you don't actually &lt;em&gt;have&lt;/em&gt; a circuit?  One side of the LED doesn't connect to anything.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-11T17:55:30.457" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16009" PostTypeId="1" AcceptedAnswerId="16010" CreationDate="2015-09-11T18:06:25.010" Score="1" ViewCount="834" Body="&lt;p&gt;I'm trying the following code on an Uno. I'm pulling the high side of a pull down 10K resistor to 5V, but it can only be woken once. Just once. Does anyone know why this might be the case?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine if I use &lt;code&gt;LOW&lt;/code&gt; for &lt;code&gt;attachInterrupt&lt;/code&gt; along with a pull-up resistor though. Just not with &lt;code&gt;RISING&lt;/code&gt; and a pull-down.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;int pin2 = 2;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  /* Setup the pin direction. */&#xA;  pinMode(pin2, INPUT);&#xA;&#xA;  Serial.println(&quot;Initialisation complete.&quot;);&#xA;&#xA;}&#xA;&#xA;void pin2Interrupt(void)&#xA;{&#xA;  /* This will bring us back from sleep. */&#xA;&#xA;  /* We detach the interrupt to stop it from &#xA;   * continuously firing while the interrupt pin&#xA;   * is high.&#xA;   */&#xA;  detachInterrupt(digitalPinToInterrupt(pin2));&#xA;}&#xA;&#xA;void enterSleep(void)&#xA;{  &#xA;&#xA;  sleep_enable();&#xA;&#xA;  /* Setup pin2 as an interrupt and attach handler. */&#xA;  attachInterrupt(digitalPinToInterrupt(pin2), pin2Interrupt, RISING);&#xA;  delay(100);&#xA;&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;&#xA;  sleep_mode();&#xA;&#xA;  /* The program will continue from here. */&#xA;&#xA;  /* First thing to do is disable sleep. */&#xA;  sleep_disable(); &#xA;}&#xA;&#xA;int seconds=0;&#xA;void loop()&#xA;{&#xA;  delay(1000);&#xA;  seconds++;&#xA;&#xA;  Serial.print(&quot;Awake for &quot;);&#xA;  Serial.print(seconds, DEC);&#xA;  Serial.println(&quot; second&quot;);&#xA;&#xA;  if(seconds &amp;gt;= 3)&#xA;  {&#xA;    Serial.println(&quot;Entering sleep&quot;);&#xA;    delay(200);&#xA;    seconds = 0;&#xA;    enterSleep();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2015-09-11T18:23:39.063" LastActivityDate="2015-09-12T01:04:03.843" Title="Not waking up more than once?" Tags="|c|interrupt|sleep|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="16010" PostTypeId="2" ParentId="16009" CreationDate="2015-09-11T18:45:38.450" Score="1" Body="&lt;p&gt;For a &lt;code&gt;RISING&lt;/code&gt; interrupt you never need to disconnect the interrupt to prevent repeat triggering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;code&gt;RISING&lt;/code&gt; interrupt specifically only triggers the once when the input pin transitions from &lt;code&gt;LOW&lt;/code&gt; to &lt;code&gt;HIGH&lt;/code&gt; rather than all the time it's in a state like a &lt;em&gt;level&lt;/em&gt; interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attach the interrupt once in setup() and leave it alone after that.  Your interrupt handler routine can be completely empty.  It will only ever be triggered at the exact moment you press the button.  To trigger it again you will just need to press the button again.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-11T18:45:38.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16011" PostTypeId="1" CreationDate="2015-09-11T19:54:18.170" Score="0" ViewCount="660" Body="&lt;p&gt;So I have two Arduinos (Arduino Nano) and I'm trying to get them to communicate via SoftwareSerial.  I have the 'sending' Arduino's D10 pin connected to the 'recieving' Arduino's D11 pin, and vice versa.  On my sending Arduino, I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11);&#xA;&#xA;void setup() {&#xA;  pinMode(2, OUTPUT);&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (mySerial.isListening()){&#xA;    digitalWrite(2, HIGH);&#xA;  }&#xA;  mySerial.write(5);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and on my receiving Arduino, I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(11, 10);&#xA;&#xA;void setup() {&#xA;  pinMode(2, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  mySerial.listen();&#xA;  if (mySerial.available()&amp;gt;0) {&#xA;    digitalWrite(2, HIGH);&#xA;    char inByte = mySerial.read();&#xA;    Serial.write(inByte);&#xA;  }&#xA;  digitalWrite(2, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(with D2 being hooked up to an LED for both).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't get it to read anything.  Nothing seems to be available for the receiving Arduino (the LED is off).  What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="13336" LastEditorUserId="10794" LastEditDate="2015-09-11T23:04:57.407" LastActivityDate="2019-01-04T19:28:59.797" Title="Can't get software serial to work" Tags="|serial|c++|softwareserial|software|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16012" PostTypeId="1" AcceptedAnswerId="16013" CreationDate="2015-09-11T20:01:38.617" Score="0" ViewCount="4686" Body="&lt;p&gt;I have an array of a lot of numbers (1 and 0) but i can't store them since arduino does not have enough space. How can i save an array of example 00110 in PROGMEM, then read from PROGMEM and set x to be equal lets say, third int in the array?&lt;/p&gt;&#xA;" OwnerUserId="13337" LastActivityDate="2015-09-12T07:22:49.950" Title="Storing array in PROGMEM" Tags="|arduino-uno|progmem|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="16013" PostTypeId="2" ParentId="16012" CreationDate="2015-09-11T21:08:35.757" Score="1" Body="&lt;p&gt;Store them with &lt;code&gt;const byte PROGMEM&lt;/code&gt; with bit 0 as MSb and bit 7 as LSb per byte. E.g. 011100100101001010101011 would become &lt;code&gt;const byte[] var PROGMEM {0x72, 0x52, 0xab}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the following macro to retrieve them (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define loadbit(mem, pos) ((pgm_read_byte(&amp;amp;(mem[pos / 8])) &amp;gt;&amp;gt; (7 - (pos % 8))) &amp;amp; 0x01)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you had &lt;code&gt;const byte[] data PROGMEM {0x72, 0x52, 0xab};&lt;/code&gt; you would call &lt;code&gt;loadbit(data, 3)&lt;/code&gt; and it would return bit 3 starting with 0 on the left, i.e. &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally if you needed more than one bit at a time there are probably situation-specific routines that could be used, but without knowing anything about the actual program the above will work.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-11T21:08:35.757" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16014" PostTypeId="2" ParentId="16009" CreationDate="2015-09-11T21:34:24.273" Score="1" Body="&#xA;&#xA;&lt;p&gt;Probably your switch is bouncing and giving two interrupts. The first wakens it, and the second is lying there waiting until you attach the interrupt again. Then it fires, detaches the interrupt, then you go to sleep, never to awaken.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clear any pending interrupt &lt;strong&gt;before&lt;/strong&gt; doing the attachInterrupt:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also wise to have interrupts off while setting up for sleep.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;                  &#xA;&#xA;const byte LED = 13;&#xA;&#xA;// interrupt service routine in sleep mode&#xA;void wake ()&#xA;{&#xA;  sleep_disable ();         // first thing after waking from sleep&#xA;}  // end of wake&#xA;&#xA;void sleepNow ()&#xA;{&#xA;  set_sleep_mode (SLEEP_MODE_PWR_DOWN);   &#xA;  noInterrupts ();          // make sure we don't get interrupted before we sleep&#xA;  sleep_enable ();          // enables the sleep bit in the mcucr register&#xA;  EIFR = bit (INTF0);       // clear flag for interrupt 0&#xA;  attachInterrupt (0, wake, RISING);  // wake up on rising edge&#xA;  interrupts ();           // interrupts allowed now, next instruction WILL be executed&#xA;  sleep_cpu ();            // here the device is put to sleep&#xA;  detachInterrupt (0);      // stop this interrupt until next time&#xA;}  // end of sleepNow&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (LED, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  sleepNow ();&#xA;  digitalWrite (LED, HIGH);&#xA;  delay (1000);&#xA;  digitalWrite (LED, LOW);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tested and works OK.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note: Since this is a rising interrupt you should have a &lt;strong&gt;pull-down&lt;/strong&gt; resistor on the pin, and you trigger the interrupt by connecting the pin to +5 V.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-12T01:04:03.843" LastActivityDate="2015-09-12T01:04:03.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16015" PostTypeId="2" ParentId="16012" CreationDate="2015-09-11T21:43:32.237" Score="1" Body="&lt;p&gt;As noted in Ignacio's answer, you can pack your bits of data into bytes and access them via &lt;code&gt;pgm_read_byte()&lt;/code&gt; calls.  If (for coding convenience, not for efficiency) you prefer to pack the bits into larger units, you can use &lt;code&gt;word&lt;/code&gt; and &lt;code&gt;dword&lt;/code&gt; access functions, as listed in &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;AVR pgmspace.h&lt;/a&gt; documentation.  The &lt;code&gt;_near&lt;/code&gt; and &lt;code&gt;_far&lt;/code&gt; suffixes denote 16 or 32 bit pointers, respectively; for an Uno with its 32K flash memory, &lt;code&gt;_near&lt;/code&gt; is always suitable.  See &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;PROGMEM documentation&lt;/a&gt; at arduino.cc for further discussion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example program that accesses and prints data from program memory in 16-bit chunks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);         // initialize serial port&#xA;}&#xA;int k=0;&#xA;const uint16_t fnums[] PROGMEM {191, 272, 353, 434, 515, 646, 767, 888};&#xA;void loop() {&#xA;  uint16_t b = pgm_read_word_near(fnums+k);&#xA;  Serial.print(k);  Serial.print(&quot; &quot;);&#xA;  Serial.print(b);  Serial.println();&#xA;  k = (k+1)%8;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To pack your 4000 bits of data in the first place, write a C or Python program that runs on a host computer and writes out array definitions that you can cut and paste into a sketch.  Here's an example (in Python) that packs bits into bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data = [1,1,0,0,0,1,0,1,0,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,1]&#xA;&#xA;first = 1; byt = 0&#xA;for i, b in enumerate(data):&#xA;  if i%8==0:&#xA;    if first:&#xA;       print 'const uint8_t fnums[] PROGMEM {',&#xA;       first = 0&#xA;    else:&#xA;       print '{},'.format(byt),&#xA;       byt = 0&#xA;  byt = (byt&amp;lt;&amp;lt;1) | b        # add bit into byte being built&#xA;&#xA;print byt&amp;lt;&amp;lt;(8-i%8), '};'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is what the program produces:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t fnums[] PROGMEM { 197, 43, 32, 200, 47, 197, 30, 119, 153, 37, 180, 117, 48, 218, 214, 212, 170, 262 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want that code to instead pack bits into 16-bit words, change 8 to 16 in four places.  Note, the code stores bits in the “bit 0 as MSb and bit 7 as LSb” order mentioned in Ignacio's answer.  Thus, &lt;code&gt;data[0]&lt;/code&gt; is stored in the high bit of &lt;code&gt;fnums[0]&lt;/code&gt;, &lt;code&gt;data[8]&lt;/code&gt; is stored in the high bit of &lt;code&gt;fnums[1]&lt;/code&gt; , and so forth.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-09-12T06:02:57.687" LastActivityDate="2015-09-12T06:02:57.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16016" PostTypeId="2" ParentId="16011" CreationDate="2015-09-11T23:06:13.227" Score="1" Body="&lt;p&gt;Sender:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(10, 11);  // Rx, Tx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(11, 10);  // Rx, Tx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have the 'sending' Arduino's D10 pin connected to the 'receiving' Arduino's D11 pin, and vice versa. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you have the sending Arduino's Rx connected to the receiving Arduino's Rx. Therefore it won't work. You need to connect Rx to Tx.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  mySerial.listen();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't need that in this simple example.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-11T23:06:13.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16017" PostTypeId="2" ParentId="15985" CreationDate="2015-09-11T23:25:43.313" Score="2" Body="&lt;p&gt;Yes, the pin is going low. I tested it for you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qDZxx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qDZxx.png&quot; alt=&quot;Pin 10 going low&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It went low for 6 µs, once every 2 seconds. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Overall, this is the effect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3QuPS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3QuPS.png&quot; alt=&quot;Pin 10 mainly high&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, high for most of the time.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-11T23:25:43.313" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16018" PostTypeId="2" ParentId="14189" CreationDate="2015-09-12T00:25:09.767" Score="4" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm not accepting any answer because they are only focused on versioning/git/github fork-&gt;edit-&gt;share and I am very interested on all the things that I have to do to make the development.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I will run through the basics of making a library. It's really quite simple, and they persist through upgrades to the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's imagine I have a useful function (or lots of functions) that I want to use in lots of sketches. For example, something that blinks an LED:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void blinkLED (const byte which, const int times)&#xA;  {&#xA;  for (int i = 0; i &amp;lt; times; i++)&#xA;    {&#xA;    digitalWrite (which, HIGH);&#xA;    delay (500);&#xA;    digitalWrite (which, LOW);&#xA;    delay (500);&#xA;    }  // end of for loop&#xA;  } // end of blinkLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And some test code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  pinMode (13, OUTPUT);&#xA;  blinkLED (13, 5);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Make a library&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To turn that into a library we need three steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a folder for the library. This should be placed inside the &lt;strong&gt;libraries&lt;/strong&gt; folder &lt;strong&gt;in your sketchbook folder&lt;/strong&gt;. This folder:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gdxgk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gdxgk.png&quot; alt=&quot;Sketchbook folder&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case: &lt;code&gt;/home/nick/sketchbook/libraries&lt;/code&gt;. It does &lt;strong&gt;not&lt;/strong&gt; go into anywhere associated with the IDE download.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, &lt;strong&gt;not&lt;/strong&gt; there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will call my library &lt;code&gt;blinkLED&lt;/code&gt;. So I make that folder, which is now: &lt;code&gt;/home/nick/sketchbook/libraries/blinkLED&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a function prototype for any functions your library is going to &quot;expose&quot; to the end-user, and put that into a .h file, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;blinkLED.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void blinkLED (const byte which, const int times);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: You must include &lt;code&gt;&amp;lt;Arduino.h&amp;gt;&lt;/code&gt; as in the example, or you will get compile errors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Put the C++ code into a .cpp file, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;blinkLED.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;blinkLED.h&amp;gt;&#xA;&#xA;void blinkLED (const byte which, const int times)&#xA;  {&#xA;  for (int i = 0; i &amp;lt; times; i++)&#xA;    {&#xA;    digitalWrite (which, HIGH);&#xA;    delay (500);&#xA;    digitalWrite (which, LOW);&#xA;    delay (500);&#xA;    }  // end of for loop&#xA;  } // end of blinkLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: You must include the .h file created in step 2, as in the example, or you will get compile errors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That's it! Restart the IDE now so it notices the new folder with the library in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now our test sketch can just use the new library.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;blinkLED.h&amp;gt;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  pinMode (13, OUTPUT);&#xA;  blinkLED (13, 5);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Testing&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For testing I just keep the library files open in a separate text editor (I am using Geany these days, but whatever your favourite editor is).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make changes to the library source and save them. You &lt;strong&gt;do not&lt;/strong&gt; need to restart the IDE if you do this. It will always pick up the latest version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the IDE you alter your calling code, upload and test. It is really quite fast and simple.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Git&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once you have put a bit of work into your library you probably want to put it under source control. Using a terminal/command window, navigate to the library folder and put it into a Git repository:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;git init&#xA;git add *.cpp&#xA;git add *.h&#xA;git commit -m &quot;Initial commit&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-12T00:25:09.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16019" PostTypeId="1" AcceptedAnswerId="16020" CreationDate="2015-09-12T01:58:34.610" Score="2" ViewCount="1083" Body="&lt;p&gt;I want to write a little library;&lt;br&gt;&#xA;the unlibrarized functionality does:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;checking in every loop-cycle some inputs,&lt;br&gt;&#xA;doing some calculations with it&lt;br&gt;&#xA;and finally setting a boolean to either true or false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I periodically check the inputs inside the library?&lt;/strong&gt;&lt;br&gt;&#xA;I know that I could add a function-call  to the library in the loop()-function. But I would prefer to just check the boolean in the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way, to instantiate a class and start an periodically function by doing so?&lt;/strong&gt; And if, how does this constant checking affect/coexist with my 'normal' loop()-function?&lt;/p&gt;&#xA;" OwnerUserId="13343" LastEditorUserId="13343" LastEditDate="2015-09-12T02:44:47.257" LastActivityDate="2015-09-12T04:44:06.363" Title="Can I automatically loop inside a library?" Tags="|programming|c++|library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16020" PostTypeId="2" ParentId="16019" CreationDate="2015-09-12T02:20:10.853" Score="1" Body="&lt;p&gt;Generally speaking, no, you can not take control of the processor away from the main &quot;thread&quot; in a library. The normal solution is to provide an &lt;code&gt;update&lt;/code&gt; method or something like that. you could do the calculations in a function that returns your boolean answer, then the loop code is basically the same with or without asynchronous updating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can use interrupts to read your input, either as an external interrupt or on an internal timer interrupt, then what you want could be achieved because the interrupt would take control away from the main execution context and give it to you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupt routines need to be fast and simple though, and it makes the &quot;cost&quot; of using the library higher, since there is a limited number of interrupts/timers and other libraries may require the one you code yours to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the more powerful arduinos that actually run an os will have support for multiprocessing which you could leverage to get the behavior you want. This answer is intended for a standard AVR based arduino (uno, mega, etc.)&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2015-09-12T04:44:06.363" LastActivityDate="2015-09-12T04:44:06.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16021" PostTypeId="2" ParentId="16019" CreationDate="2015-09-12T02:47:36.863" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I know that I could add a function-call to the library in the loop()-function. But I would prefer to just check the boolean in the loop.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What's the difference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;loop&lt;/code&gt; you can call something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop ()&#xA;  {&#xA;...&#xA;  if (mylibrary.ready ())&#xA;    {&#xA;    // it's time to act!&#xA;    }&#xA;...&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can make a function, that returns a boolean type, which tells you if the thing you need to do is ready. That function &lt;em&gt;does the checking&lt;/em&gt; before returning true or false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After all, you are planning to check the boolean periodically, presumably often enough to notice it changing, why not have that be the point of noticing whatever-it-is you need to notice?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-12T02:47:36.863" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16022" PostTypeId="1" CreationDate="2015-09-12T05:58:25.873" Score="1" ViewCount="2798" Body="&lt;p&gt;I have a 2008 Mac that hardly ever crashes. But from time to time (not always) it crashes (the whole computer shuts down as if the power has been cut off) when I plug in an Arduino via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could cause this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've done some testing and the constant in when this occurs seems to be a cheap PIR sensor from eBay. It works some of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I get another sensor? Or is there something about PIR sensors that makes them prone to this? It has a lot of caps... Is there another kind of motion sensor?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="8769" LastEditDate="2015-09-12T07:22:03.143" LastActivityDate="2019-02-13T23:12:07.673" Title="Arduino crashed my computer when I plug in the USB cable" Tags="|usb|mac-os|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="16023" PostTypeId="2" ParentId="16012" CreationDate="2015-09-12T07:22:49.950" Score="1" Body="&lt;p&gt;Building on the excellent other answers by jwpat7 and &#xA;Ignacio Vazquez-Abrams, you could conceivably convert your bits into a table using Lua:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-lua prettyprint-override&quot;&gt;&lt;code&gt;data = { 1,1,0,0,0,1,0,1,0,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,0,0,1,&#xA;         0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,1,0,0,1,&#xA;         1,1,0,1,1,1,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,1,0,1,1,0,1,0,&#xA;         0,0,1,1,1,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,1,1,0,1,&#xA;         0,1,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,1 }&#xA;&#xA;output = 0&#xA;bit = 0&#xA;&#xA;for _, num in ipairs (data) do&#xA;  assert (num == 0 or num == 1, &quot;Number must be 0 or 1&quot;)&#xA;  output = (output * 2) + num&#xA;  bit = bit + 1&#xA;  if bit &amp;gt;= 8 then&#xA;    io.write (output .. &quot;, &quot;)&#xA;    output = 0&#xA;    bit = 0&#xA;  end -- if&#xA;end --for&#xA;&#xA;print &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Output from above:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;197, 43, 32, 200, 47, 197, 30, 119, 153, 37, 180, 117, 48, 218, 214, 212, 170, 131,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Now you can make a simple function to pull a particular bit out of PROGMEM:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte myTable [] PROGMEM = {&#xA;  197, 43, 32, 200, 47, 197, 30, 119, 153, 37, 180, 117, 48, 218, 214, 212, 170, 131, &#xA;  };&#xA;&#xA;bool getBit (const unsigned int which)&#xA;  {&#xA;  const unsigned int whichByte = which / 8;&#xA;  const byte whichBit = which &amp;amp; 0x07;&#xA;  return bitRead (pgm_read_byte (&amp;amp;myTable [whichByte]), 7 - whichBit);&#xA;  }  // end of getBit&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Starting&quot;);&#xA;&#xA;  for (int i = 0; i &amp;lt; sizeof (myTable) * 8; i++)&#xA;    {&#xA;    Serial.print (int (getBit (i)));&#xA;    Serial.print (&quot;, &quot;);&#xA;    }&#xA;  Serial.println ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output from above:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Starting&#xA;1,1,0,0,0,1,0,1,0,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,1,0,0,1,1,1,0,1,1,1,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,1,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-12T07:22:49.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16024" PostTypeId="1" AcceptedAnswerId="16046" CreationDate="2015-09-12T08:04:19.603" Score="0" ViewCount="907" Body="&lt;p&gt;I try to use power down mode to extend battery life, but no matter what sleep library I use, the power consumption never goes below 3.4-3.6 mA. I'm using a chinese pro mini board with VCC input (but using the RAW results the same).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr/power sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;void setup()&#xA;{          &#xA;  Serial.begin(9600);      &#xA;  byte i;&#xA;&#xA;  // Ensure no floating pins&#xA;  for(i=0; i&amp;lt;20 ; i++)&#xA;  {&#xA;    pinMode(i, OUTPUT);&#xA;    digitalWrite(i, LOW);&#xA;  }&#xA;&#xA;  // Power-down board&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;&#xA;  sleep_enable();&#xA;&#xA;  // Disable ADC&#xA;  ADCSRA &amp;amp;= ~(1 &amp;lt;&amp;lt; ADEN);&#xA;&#xA;  // Power down functions&#xA;  PRR = 0xFF;&#xA;&#xA;  // Enter sleep mode&#xA;  sleep_mode();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;rocketscream/Low-Power sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LowPower.h&amp;gt;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13345" LastActivityDate="2015-09-13T05:00:40.680" Title="High power consumption during power down mode" Tags="|power|arduino-pro-mini|sleep|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16025" PostTypeId="1" CreationDate="2015-09-12T10:28:17.280" Score="0" ViewCount="276" Body="&lt;p&gt;I  have connected a circuit to analog pin 0 in the Arduino.I have this code ,which I understand partially(online resources).The problem is that it prints nothing neither on Tera Term nor on Cool Term .Where am I mistaking ?(I am new to AVR programming).Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include&amp;lt;stdio.h&amp;gt;&#xA; void InitADC()&#xA; {&#xA; ADMUX=(1&amp;lt;&amp;lt;REFS0);// For Aref=AVcc;&#xA; ADCSRA=(1&amp;lt;&amp;lt;ADEN)|(7&amp;lt;&amp;lt;ADPS0);&#xA;  }  &#xA;&#xA; uint16_t ReadADC(uint8_t ch)&#xA; {&#xA;&#xA;    //Select ADC Channel ch must be 0-7&#xA;     ch=ch&amp;amp;0b00000111;&#xA;     ADMUX|=ch;&#xA;&#xA;     //Start Single conversion&#xA;&#xA;     ADCSRA|=(1&amp;lt;&amp;lt;ADSC);&#xA;&#xA;      //Wait for conversion to complete&#xA;      while(!(ADCSRA &amp;amp; (1&amp;lt;&amp;lt;ADIF)));&#xA;&#xA;      //Clear ADIF by writing one to it&#xA;      ADCSRA|=(1&amp;lt;&amp;lt;ADIF);&#xA;&#xA;     return(ADC);&#xA;}&#xA;&#xA;int main()&#xA;&#xA;  {&#xA;&#xA;uint16_t adc_value;&#xA;&#xA;InitADC();&#xA;&#xA;&#xA;while(1)&#xA;&#xA;{&#xA;&#xA;  adc_value = ReadADC(0);&#xA;  printf(&quot;%d&quot;,adc_value);&#xA;&#xA;  } &#xA;&#xA;   return 0;&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="10794" LastEditDate="2015-09-13T04:43:04.350" LastActivityDate="2015-10-13T19:38:31.493" Title="AVR+Arduino ADC problem" Tags="|arduino-uno|sensors|c++|analogread|avr|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16026" PostTypeId="2" ParentId="13760" CreationDate="2015-09-12T11:10:28.583" Score="1" Body="&lt;p&gt;Using the MIRF Library that I got from &lt;a href=&quot;http://www.sainsmart.com/zen/documents/20-011-401/Codes_for_Self-balancing_robot.zip&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, and then using this code to send &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Mirf.send((byte *)&amp;amp;command);&#xA;    while(Mirf.isSending()){&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this code to receive&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if(!Mirf.isSending() &amp;amp;&amp;amp; Mirf.dataReady()){&#xA;    Mirf.getData((byte *)&amp;amp;data);&#xA;    Mirf.rxFifoEmpty();&#xA;else(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to get it to work&lt;/p&gt;&#xA;" OwnerUserId="10529" LastEditorUserId="10529" LastEditDate="2015-09-12T14:30:44.023" LastActivityDate="2015-09-12T14:30:44.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16027" PostTypeId="1" AcceptedAnswerId="16031" CreationDate="2015-09-12T12:51:21.043" Score="1" ViewCount="348" Body="&lt;p&gt;I've searched the forum for similar problems and still can't see my obvious issue. I'm working on a simple Halloween prop and I'm using an Arduino for the first time. I've tested each individual 'event' (i.e. fog machine, mp3, actuator, and LED strip) with a loop and all four have worked on continuous loop with no issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As soon as I combine them all together, the program runs successfully exactly one time. After that final 10 second delay, when I expect the program to start the loop again, it crashes. If it helps, right during the start of the next loop, the relay light turns on on the relay board for RELAY_1_A and sort of just flickers while the actuator hums. I usually shut it down quickly at this point. As soon as I turn the system back on, it successfully runs through another iteration until the loop hangs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm happy to provide pictures or even a video of the issue if that helps. My guess is that you guys will spot my coding issue right away. Maybe some kind of memory overflow or something like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know my code could be much more efficient but I'm just looking for the glaring problem that is keeping the loop from working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SdFat.h&amp;gt;&#xA;#include &amp;lt;SdFatUtil.h&amp;gt; &#xA;#include &amp;lt;SFEMP3Shield.h&amp;gt;&#xA;&#xA;const int RELAY_1_A = 7; //the one with the issue&#xA;const int RELAY_1_B = 8;&#xA;&#xA;SdFat sd;&#xA;SFEMP3Shield MP3player;&#xA;void setup() {                &#xA;  // initialize the digital pins as an output.&#xA;  pinMode(10, OUTPUT); //Fog machine on Relay1 on 5V relay board&#xA;  pinMode(3, OUTPUT); //LED strip off breadboard MOSFET  &#xA;   pinMode(RELAY_1_A, OUTPUT); //12V relay for actuator on Relay1 on 12V relay board&#xA;   pinMode(RELAY_1_B, OUTPUT); //12V relay for actuator on Relay2 on 12V relay board&#xA;&#xA;  //start the shield&#xA;  sd.begin(SD_SEL, SPI_FULL_SPEED);&#xA;  MP3player.begin();&#xA;  MP3player.setVolume(10, 10);&#xA;}&#xA;&#xA;void loop() {&#xA;  MP3player.playTrack(2);  // Play MP3. Track 1 is coffin and track 2 is bird&#xA;  delay(5000);              // wait for 5 seconds&#xA;  digitalWrite(10, LOW);   // Turns ON fog machine&#xA;  delay(3000);&#xA;  digitalWrite(10, HIGH);   // Turns OFF fog machine &#xA;  digitalWrite(3, HIGH);   // Turn the LED on (HIGH is the voltage level)&#xA;&#xA;  delay(5000);              // wait for 5 seconds&#xA;&#xA;  retractActuator();       //Open coffin&#xA;  delay (9000);&#xA;  stopActuator();      //Close coffin&#xA;  delay (9000);&#xA;  extendActuator();      //Close coffin&#xA;  delay(8000);              &#xA;  digitalWrite(RELAY_1_B, HIGH);  //Turns off this relay during the wait period before next loop&#xA;&#xA;  digitalWrite(3, LOW);    // Turn the LED off by making the voltage LOW&#xA;  delay(10000);              // wait for 20 seconds&#xA;&#xA;}&#xA;void extendActuator() {&#xA;  //Set one relay one and the other off&#xA;  //this will move extend the actuator&#xA;  digitalWrite(RELAY_1_A, HIGH);&#xA;  digitalWrite(RELAY_1_B, LOW);&#xA;}&#xA;&#xA;void retractActuator() { &#xA;  //Set one relay off and the other on &#xA;  //this will move retract the actuator &#xA;  digitalWrite(RELAY_1_A, LOW);&#xA;  digitalWrite(RELAY_1_B, HIGH); &#xA;}&#xA;&#xA;void stopActuator() {&#xA; //Set both relays off&#xA; //this will stop the actuator in a braking&#xA; digitalWrite(RELAY_1_A, HIGH);&#xA; digitalWrite(RELAY_1_B, HIGH); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13347" LastEditorUserId="6936" LastEditDate="2015-09-17T11:26:58.687" LastActivityDate="2015-09-17T11:26:58.687" Title="Very easy Arduino code challenge for you brainiacs to solve" Tags="|arduino-uno|c++|shields|relay|system-design|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16028" PostTypeId="2" ParentId="15984" CreationDate="2015-09-12T13:25:36.853" Score="0" Body="&lt;p&gt;I fixed it by following these steps (through trial and error, I don't really understand what I did but it works ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Windows 8.1, 64 bit edition.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Download the Edison firmware from &lt;a href=&quot;https://software.intel.com/en-us/iot/hardware/edison/downloads&quot; rel=&quot;nofollow&quot;&gt;https://software.intel.com/en-us/iot/hardware/edison/downloads&lt;/a&gt;. For me it was &lt;a href=&quot;http://downloadmirror.intel.com/25028/eng/edison-image-ww25.5-15.zip&quot; rel=&quot;nofollow&quot;&gt;http://downloadmirror.intel.com/25028/eng/edison-image-ww25.5-15.zip&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Extract the zip file.&lt;/li&gt;&#xA;&lt;li&gt;Start the Windows Command Prompt as Administrator.&lt;/li&gt;&#xA;&lt;li&gt;The extracted archive should contain a file called &quot;flashall.bat&quot;. Change to the directory containing the file.&lt;/li&gt;&#xA;&lt;li&gt;Connect all micro-USB ports and the barrel connector. At this point Windows did not recognize the Edison as a flash disk. This is part of what I was fixing.&lt;/li&gt;&#xA;&lt;li&gt;Follow the steps in my question until the output on the console (also from my question) appears.&lt;/li&gt;&#xA;&lt;li&gt;Run &quot;flashall --recovery&quot;&lt;/li&gt;&#xA;&lt;li&gt;Run &quot;flashall&quot;. When &quot;Please plug and reboot the board&quot; appears, disconnect the A (or middle) USB port and the barrel connector for the power. At this point everything is switched off. Then reconnect A and the barrel connector to reboot the board.&lt;/li&gt;&#xA;&lt;li&gt;Wait about 5 minutes for the rest of the process to run automatically.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this point everything should work again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should see this on the command line in Windows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;C:\Users\_\Desktop\edison-image-ww25.5-15&gt;flashall --recovery&#xA;Starting Recovery mode&#xA;Please plug and reboot the board&#xA;Flashing IFWI&#xA;!!! You should install xfstk tools, please visit http://xfstk.sourceforge.net/&#xA;&#xA;C:\Users\_\Desktop\edison-image-ww25.5-15&gt;flashall&#xA;Using U-boot target: edison-blankrndis&#xA;Now waiting for dfu device 8087:0a99&#xA;Please plug and reboot the board&#xA;Dfu device found&#xA;Flashing IFWI&#xA;Download        [=========================] 100%      4194304 bytes&#xA;Download done.&#xA;Download        [=========================] 100%      4194304 bytes&#xA;Download done.&#xA;Flashing U-Boot&#xA;Download        [=========================] 100%       237568 bytes&#xA;Download done.&#xA;Flashing U-Boot Environment&#xA;Download        [=========================] 100%        65536 bytes&#xA;Download done.&#xA;Flashing U-Boot Environment Backup&#xA;Download        [=========================] 100%        65536 bytes&#xA;Download done.&#xA;Rebooting to apply partiton changes&#xA;Dfu device found&#xA;Flashing boot partition (kernel)&#xA;Download        [=========================] 100%      6111232 bytes&#xA;Download done.&#xA;Flashing rootfs, (it can take up to 5 minutes... Please be patient)&#xA;Download        [=========================] 100%    566330368 bytes&#xA;Download done.&#xA;Rebooting&#xA;U-boot &amp; Kernel System Flash Success...&#xA;Your board needs to reboot to complete the flashing procedure, please do not unplug it for 2 minutes.&#xA;&#xA;C:\Users\_\Desktop\edison-image-ww25.5-15&gt;&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="13319" LastActivityDate="2015-09-12T13:25:36.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16031" PostTypeId="2" ParentId="16027" CreationDate="2015-09-12T14:41:34.007" Score="4" Body="&lt;p&gt;You are attempting to use IO pins that are already in use by the MP3 shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to your subsequent research, only digital pins 0,1,5, and 10 are available for use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should shy away from using pins 0 and 1 since they are also connected to the computer through the USB interface and are used for uploading sketches.  You will find that either you can't upload sketches with the relays connected to those pins, or the relays will &quot;randomly&quot; switch on and off while you're uploading a sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget that the analog pins A0-A5 can also be used as digital pins, so you can quite happily drive your relays using any of those.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-12T14:41:34.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16032" PostTypeId="1" AcceptedAnswerId="16036" CreationDate="2015-09-12T16:36:19.190" Score="0" ViewCount="208" Body="&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt; on on digital ouput/input I would like to communicate with a 1-wire device, whose protocol requires precision to ~15 microseconds. My question is if Arduino Uno's serial communication can be as quick as to support to map the digital pin via serial-&gt;USB to my host computers app which should implement the 1-wire protocol?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;long version&lt;/strong&gt;&#xA;The mode in which I thought to use my Arduino was, to attach it to a host computer and run the logic of what should be done on the host computer, having the Arduino only receive the data (for the pins) and return the state of the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The challenge which prompts me to this question is that the Serial communication is not really that quick, compared to the timing requirement of some protocols (e.g. 1 wire) I wish to implement.&lt;br&gt;&#xA;For example: 1-wire-protocol's timing requirements (i.e. range of micorseconds) could easily be kept from code running on the Arduino Uno's Atmega328 directly, which at 16Mhz and assumed 2 cycles per command would allow somewhat a resolution of 2/16Mhz = 0,125 us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If alternatively the data/instruction for the 1-wire protocol should be mapped via the serial interface to an application running on an PC attached to the Arduino I wonder if the time requirements of the 1-wire protocal can be reached?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It boils down to a question if the Serial communication can have a temporal granularity as small as the about 1 to 15 microseconds needed to implement the 1-wire protocol - not within arduino itself - but in the attached PC's application.&lt;/p&gt;&#xA;" OwnerUserId="11779" LastActivityDate="2015-09-13T05:31:34.270" Title="Can Arduino Uno's serial handle to foward push through 1-wire protocol?" Tags="|serial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16033" PostTypeId="1" CreationDate="2015-09-12T16:45:20.720" Score="2" ViewCount="2497" Body="&lt;p&gt;My understanding has been that the Serial transmission is indeed done (on the Arduino Uno) via the pins named &lt;code&gt;TX-&amp;gt;1&lt;/code&gt; and &lt;code&gt;RX&amp;lt;-0&lt;/code&gt;?&#xA;With this I assume that the Atmega has a machine code that would allow in 1 or processor cycles (125 or 62.5 ns) to set a byte (i.e. Port byte &lt;code&gt;DDRD&lt;/code&gt;) as to forward exactly one bit of information for further processing to the &lt;code&gt;ATmega16U2&lt;/code&gt; &quot;serial to USB&quot; chip?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is true I would expect that 1 Byte = being 8 bits would require a discouragingly slow 8 to 12 cpu cycles (500ns to 1us)? Is this true?&lt;/p&gt;&#xA;" OwnerUserId="11779" LastActivityDate="2015-09-12T23:06:41.767" Title="how many processor cycles/time does it minimaly take to transmit 1 Byte via Serial?" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16034" PostTypeId="1" AcceptedAnswerId="16088" CreationDate="2015-09-12T17:20:34.883" Score="2" ViewCount="991" Body="&lt;p&gt;I want to make a device that will take a Bluetooth stream and play it on speakers via the USB port for speakers that do not have Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it may be possible by taking the stream and using an Arduino to convert the stream to a virtual file so that the speaker will see the USB as a mass storage and play the file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure that is just an idea, any thoughts or solutions?&lt;/p&gt;&#xA;" OwnerUserId="13354" LastEditorUserId="6936" LastEditDate="2015-09-22T12:06:45.537" LastActivityDate="2016-07-30T21:17:39.377" Title="Bluetooth Stream to USB" Tags="|bluetooth|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16035" PostTypeId="2" ParentId="16033" CreationDate="2015-09-12T17:27:13.013" Score="6" Body="&lt;p&gt;No, it is not true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are assuming (wrongly) that the CPU is doing the UART communication.  It isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UART is a completely separate piece of hardware inside the chip.  It runs by itself.  The CPU merely places the byte to transfer into a &lt;em&gt;special function register&lt;/em&gt; (&lt;em&gt;SFR&lt;/em&gt;).  The UART then takes that and clocks it out through the IO pins at the right rate for the serial communication.  While that is going on the CPU is free to perform other operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CPU can then either consult another &lt;em&gt;SFR&lt;/em&gt; to determine if the transmission has finished, or utilize an interrupt that the UART will trigger when the transfer has been completed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-12T17:27:13.013" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16036" PostTypeId="2" ParentId="16032" CreationDate="2015-09-12T17:39:08.940" Score="1" Body="&lt;p&gt;Ok, so there's two issues at stake here.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can the Arduino generate a 1-wire protocol with enough accuracy?&lt;/li&gt;&#xA;&lt;li&gt;Can you transfer the data fast enough through the UART to tell it to do that generation?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can't just stream a 1-wire protocol through serial and expect it to work.  The low-level serial protocol would very much get in the way.  So you have to send instructions to the Arduino to say &quot;Raise the IO pin&quot; and &quot;Lower the IO pin&quot; and &quot;Tell me when the IO pin changes level&quot;, and &quot;Set the IO pin to input&quot; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of those actions would be a discrete item that you would have to send.  Given that you could have a single byte per action (send &quot;I&quot; for set to input, send &quot;O&quot; for set to output, send &quot;L&quot; for set to low, etc - Arduino sends &quot;H&quot; if the pin goes high, or &quot;L&quot; if it goes low, etc), what kind of response could you expect?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, at 8 bits + start + stop per byte (so 10 bits) at a good fast rate (say 1MBaud), you would expect one byte to take (1/(1000000/10) = 0.00001s (10µs) to transfer.  That's raw transfer speed.  On top of that you then have to add the processing of that incoming data - the Arduino adds it to a circular buffer to allow your sketch to read it, and that takes time, and your program then interpreting it, you could expect a latency of say 15µs.  At maximum stream rate (no breaks between characters being sent at all) you would have a basic granularity of 10µs (processing the last incoming character while the next one is being received).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not counting any other factors such as the UART buffers on your computer, latency before the character even gets to the USB port's endpoint, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all in all there &lt;em&gt;might&lt;/em&gt; be a slim chance that you could do it, but it would be &lt;em&gt;very&lt;/em&gt; slim and not easy to achieve a stable result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Far better would be to implement the 1-Wire protocol on the Arduino and just send/receive the control information to tell it to go ahead and do the work and return the results.  After all, that's what the Arduino is designed for - low level interfacing like that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-12T17:39:08.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16037" PostTypeId="1" AcceptedAnswerId="20520" CreationDate="2015-09-12T18:24:47.850" Score="0" ViewCount="754" Body="&lt;p&gt;I mistakenly posted this on stack overflow first.  The community was kind enough to point me to this forum.  I apologize for the double-post. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been working on an Arduino Uno r3 + WiFi Shield project for a few months now building up the complexity as I go. I've hit a wall. I started this project with exactly zero experience writing code of any kind and exactly zero experience working with boards. If you have any doubts as to whether or not I'll understand your response, please dumb it down!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made a simple arduino + wifi shield setup that can report a button push to a MySql database. All of the .php stuff on the backend works and the database is managed with phpmyadmin. I'm trying to add a second button but can't seem to make it work and need some help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have settled on a four-field database table as the output:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1st column: the key. A sequential, unique identifier for each entry&lt;/li&gt;&#xA;&lt;li&gt;2nd column: the pin number that the sensor is connected to &lt;/li&gt;&#xA;&lt;li&gt;3rd column: the sensor value&lt;/li&gt;&#xA;&lt;li&gt;4th column: the date and time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Notice that I'm not using a dedicated column for each sensor. By using the sensor pin input, I want to simply print the sensor pin number in a column. This (a) saves space in the table and (b) allows the Arduino to use as many sensors as it has pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is that each button press (even if two are pressed simultaneously) will get it's own line, sensor pin source, value, and timestamp. No values will be sent unless a button is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't the foggiest idea of how to implement this! Help!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I ask the sketch to retrieve the pin from which a signal originates and write it to the db as a number in the second column? The 13th line of code is what will write the pin number (I think). The &quot;senseval=&quot; needs to be a variable that reports the source pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to set this up and google has led to nothing but dead ends. I'd like this thread to answer the questions I'm sure a few more people have/will have!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My sketch is included below and the insert_php_doc below that. I'm using the Silinas/Benoit &quot;Arduino /Post&quot; example from github:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;linksys&quot;;&#xA;int status = WL_IDLE_STATUS;&#xA;WiFiClient client;&#xA;IPAddress server(xxx,xxx,xxx,xxx);&#xA;&#xA;int inPin_0 = A0; // choose the input pin (sensor #1)&#xA;int inPin_1 = A1; // choose the input pin (sensor #2) //ADDED FOR SECOND BUTTON//&#xA;int sensorSense_0 = 0; //variable&#xA;int sensorSense_1 = 0; //variable //ADDED FOR SECOND BUTTON//&#xA;String SensorVal = &quot;senseval=&quot;;// &quot;yourdata=&quot;&#xA;String senseval;//yourdata //MUST KEEP sensval for PHP&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(inPin_0,INPUT);&#xA;  pinMode(inPin_1,INPUT);  //ADDED FOR SECOND BUTTON//&#xA;  connectWifi();&#xA;}&#xA;&#xA;void loop() {&#xA;  sensorSense_0=analogRead(inPin_0);&#xA;  if (sensorSense_0 == LOW){&#xA;    postData();&#xA;    delay(5000);  &#xA;  }&#xA;  sensorSense_1=analogRead(inPin_1); //ADDED FOR SECOND BUTTON//&#xA;  if (sensorSense_1 == LOW){ //ADDED FOR SECOND BUTTON//&#xA;    postData(); //ADDED FOR SECOND BUTTON//&#xA;    delay(5000); //ADDED FOR SECOND BUTTON//&#xA;  }&#xA;&#xA;void connectWifi() {&#xA;  while ( status != WL_CONNECTED) {&#xA;    Serial.print(&quot;Attempting to connect to SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    status = WiFi.begin(ssid);&#xA;&#xA;    delay(7000);&#xA;  }&#xA;}&#xA;}&#xA;void postData() {&#xA;  senseval=SensorVal+String(inPin_0);&#xA;  senseval=SensorVal+String(inPin_1); //ADDED FOR SECOND BUTTON//&#xA;&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;&#xA;    client.println(&quot;POST /insert_mysql_doc.php? HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.&amp;lt;domain&amp;gt;.com&quot;);&#xA;    client.println(&quot;User-Agent: Arduino/1.0&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println(&quot;Content-Type: application/x-www-form-urlencoded;&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(senseval.length());//yourdata&#xA;    client.println();&#xA;    client.println(senseval);//yourdata&#xA;    client.stop();&#xA;  } &#xA;  else {&#xA;    Serial.println(&quot;Connection failed&quot;);&#xA;    Serial.println(&quot;Disconnecting.&quot;);&#xA;    client.stop();&#xA;    connectWifi();&#xA;    printWifiStatus();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;The insert PHP from &lt;a href=&quot;https://github.com/ericbenwa/POST-Arduino-Data-Wireless&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ericbenwa/POST-Arduino-Data-Wireless&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;foreach ($_REQUEST as $key =&amp;gt; $value)&#xA;{&#xA;    if ($key == &quot;senseval&quot;) {&#xA;        $senseval = $value;&#xA;    }&#xA;}&#xA;&#xA;// EDIT: Your mysql database account information&#xA;$username = &quot;test_user&quot;;&#xA;$password = &quot;test_password&quot;;&#xA;$database = &quot;test_db_name_here&quot;;&#xA;$tablename = &quot;test_table_name_here&quot;;&#xA;$localhost = &quot;localhost&quot;;&#xA;&#xA;// Check Connection to Database&#xA;if (mysql_connect($localhost, $username, $password))&#xA;  {&#xA;    @mysql_select_db($database) or die (&quot;Unable to select database&quot;);&#xA;&#xA;    // Next two lines will write into your table 'test_table_name_here' with 'yourdata' value from the arduino and will timestamp that data using 'now()'&#xA;    $query = &quot;INSERT INTO $tablename VALUES ($senseval,now())&quot;;&#xA;    $result = mysql_query($query);&#xA;  } else {&#xA;    echo('Unable to connect to database.');&#xA;  }&#xA;&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="10794" LastEditDate="2016-02-10T03:41:02.067" LastActivityDate="2016-02-10T04:30:16.563" Title="Printing arduino pin numbers to MySQL" Tags="|arduino-uno|c++|wifi|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16038" PostTypeId="2" ParentId="16037" CreationDate="2015-09-12T20:25:09.767" Score="1" Body="&lt;p&gt;First of all, your statement: &quot;&lt;em&gt;I've made a simple arduino + wifi shield setup that can report a button push to a MySql database.&lt;/em&gt;&quot; is incorrect (or, at best, misleading) as the code you're running in Arduino is &lt;strong&gt;not&lt;/strong&gt; talking with MySQL at all, but simply calling a remote PHP script via an HTTP/POST request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now your problem can be split in two parts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;checking if your arduino (via its own wifi shield) is correctly talking with remote HTTP server (invoking proper PHP script with related parameters);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;checking if your PHP script is correctly dealing with MySQL.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As for 1), my first suggestion is to check web-server log files. Unfortunately you didn't tell us which web server (Apache? IIS? Other) are you running, as well as which operating system are you relying on (Linux? Windows? Other?). With Apache running on linux, tipically log files are stored in &lt;code&gt;/var/log/apache&lt;/code&gt; or &lt;code&gt;/var/log/httpd&lt;/code&gt; folders. There are plenty of other troubleshooting approaches but... please, let's start checking log files, ensuring that PHP script is invoked;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for 2), your PHP script is lacking basic error-handling: should the &lt;code&gt;insert&lt;/code&gt; (launched by the &lt;code&gt;mysql_query&lt;/code&gt; function call) fail, you'll never know. I &lt;strong&gt;strongly&lt;/strong&gt; suggest you to add proper error-handling code. &#xA;Based on &lt;a href=&quot;http://php.net/manual/en/function.mysql-query.php&quot; rel=&quot;nofollow&quot;&gt;official documentation&lt;/a&gt; it's as easy as checking the result value of the &lt;code&gt;mysql_query&lt;/code&gt; call: &quot;&lt;em&gt;...For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error....&lt;/em&gt;&quot; so what you have to do to improve your code (...and being notified about errors raised by MySQL via PHP) is to use something like following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$result = mysql_query($query);&#xA;if (!$result) {&#xA;   die('Invalid query: ' . mysql_error());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having said all the above, let me add a couple of other notes.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;in your OP, you wrote: &quot;&lt;em&gt;I'm trying to add a second button but can't seem to make it work&lt;/em&gt;&quot;. So it seems that previously you were testing with only one button and, in such a case, everything worked. Is it right? If yes, please, can you tell us what you changed to add proper handling of second button?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;in your code I see following lines:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;senseval=SensorVal+String(inPin_0);&#xA;senseval=SensorVal+String(inPin_1);&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that they are probably wrong, as the second line will override the assignment of the first one. So, with such lines, you'll surely/always loose the value related to &lt;code&gt;inPin_0&lt;/code&gt; (in other words: the first line, is useless).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;giving a look to the server-side PHP script, I noted that it has been built to handle only &lt;strong&gt;one&lt;/strong&gt; parameter (&lt;code&gt;sensval&lt;/code&gt; passed to PHP via GET/POST parameter; with PHP storing it in the &lt;code&gt;$sensval&lt;/code&gt; variable). So... to change the behaviour so to handle two different values... it's not trivial (in other words: such a change require a minimun understanding of web-programming and... getting deep to analyze such requirement is out of scope --I think-- of this answer).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13193" LastActivityDate="2015-09-12T20:25:09.767" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16040" PostTypeId="2" ParentId="16032" CreationDate="2015-09-12T21:02:53.360" Score="1" Body="&lt;p&gt;Your idea seems wrong-headed, if I may say so without giving offence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is quite capable of generating 1-wire protocol. It certain reads it easily enough with bit-banging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to send down HLHLHHHLL through serial because your PC is &quot;more powerful&quot; is just not the right way of doing it. Next you'll be wanting to generate PWM on the PC and have the Arduino relay it to an output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember, the Arduino (Uno) runs at 16 MHz. The original IBM PC ran at 4.77 MHz (if I remember correctly) so you can regard the Arduino as being as powerful as an early PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple solution is to send from the PC the data you actually want communicated by 1-wire, and let the Arduino do the actual bit-banging.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-12T21:02:53.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16041" PostTypeId="2" ParentId="16033" CreationDate="2015-09-12T23:06:41.767" Score="1" Body="&lt;p&gt;According to the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pXJhh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pXJhh.png&quot; alt=&quot;Baud rates at 16 MHz&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running at 16 MHz (as the Uno does) you can get up to 2 Mbps.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If this is true I would expect that 1 Byte = being 8 bits would require a discouragingly slow 8 to 12 cpu cycles (500ns to 1us)? Is this true?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For a bit or a  byte? At 2 Mbps that is a bit every 8 clock cycles. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;would you know what would the UART be?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The UART is built into the processor chip. I suggest you read the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I thought it was unable to tell more than 16 million times a second something to the UART, which then could have baud rates higher than what could be indicated by the Atmega328 on the Uno, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can't do &lt;em&gt;anything&lt;/em&gt; more than 16 million times a second at 16 MHz. And the clocking out of bits (in SPI, serial, or I2C) itself requires clock cycles, although they are done in parallel with the processor instructions by the hardware.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is related to your other thread &lt;a href=&quot;https://arduino.stackexchange.com/questions/16032/can-arduino-unos-serial-handle-to-foward-push-through-1-wire-protocol&quot;&gt;Can Arduino Uno&amp;#39;s serial handle to foward push through 1-wire protocol?&lt;/a&gt; isn't it? Your end objective, I am guessing, is to try to implement 1-wire reading/writing via sending each bit via serial. This is just not the right way to achieve that objective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact this thread in particular is coming across as an &lt;a href=&quot;http://xyproblem.info/&quot; rel=&quot;nofollow noreferrer&quot;&gt;X-Y problem&lt;/a&gt; - your stated objective of wanting high-speed serial, is not really the problem you are trying to solve, is it?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-09-12T23:06:41.767" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16042" PostTypeId="1" CreationDate="2015-09-13T00:30:38.550" Score="1" ViewCount="1632" Body="&lt;p&gt;I'm a newbie trying to control something through a relay. I've tried two relays with two different setups.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Setup 1&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;External 12V dc input to the relay (SRD-12VDC-SL-C) and signal pin from arduino to the IN pin, GND of ext. power supply to the GND of the Arduino, NO and COM to the load object (i.e. an LED).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Setup 2&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Similar to setup 1, but using SRD-05VDC-SL-C, 5V from Arduino (Vin from Arduino also tested).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Test program&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Modified version of the 'blink' example.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Symptom&lt;/h1&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The load object has been verified to be working before the testing.&lt;/li&gt;&#xA;&lt;li&gt;Both setup can be verify the input is working, the power led and switch led of the two relay module are lighted as expected, and I can hear the click sound while switching.&lt;/li&gt;&#xA;&lt;li&gt;No output can be obtained, both from the load object and using a multimeter.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zQwqC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zQwqC.jpg&quot; alt=&quot;relay setup&quot;&gt;&lt;/a&gt;&#xA;&lt;br&gt;&#xA;Sorry, I'm supposed to upload a Fritzing schematic, but I can't find a proper relay as I'm using.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The DC+ (red) of the relay is connected to the external ATX 12V.&lt;/li&gt;&#xA;&lt;li&gt;The DC- (black) of the relay is connected to the external ATX ground.&lt;/li&gt;&#xA;&lt;li&gt;The IN (blue) of the relay is connected to the Arduino pin 8.&lt;/li&gt;&#xA;&lt;li&gt;The external ATX ground (white) is connected to the Arduino ground.&lt;/li&gt;&#xA;&lt;li&gt;The NO (red) of the relay is connected to the load object Vcc.&lt;/li&gt;&#xA;&lt;li&gt;The COM (black) of the relay is connected to the load object ground.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h1&gt;Sketch&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;A simple modified version of Blink example is used for testing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int relaySignalPin = 8;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(relaySignalPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  digitalWrite(relaySignalPin, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(relaySignalPin, LOW);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Question&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I have no idea on why there's no voltage can be obtain between NO and COM while the switch is on, what's wrong with my setup?&lt;/p&gt;&#xA;" OwnerUserId="11843" LastEditorUserId="6936" LastEditDate="2015-09-17T11:27:27.913" LastActivityDate="2016-05-06T11:34:30.753" Title="Arduino connecting relay has no power output" Tags="|arduino-uno|relay|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16043" PostTypeId="1" CreationDate="2015-09-13T00:31:19.193" Score="0" ViewCount="1199" Body="&lt;p&gt;Can a Ethernet USB Dongle be instead of Ethernet shield for arduino in order to cut costs?&lt;/p&gt;&#xA;" OwnerDisplayName="cmschu" LastActivityDate="2015-09-13T11:18:07.743" Title="Can a Ethernet USB Dongle be instead of ethernet shield for arduino?" Tags="|ethernet|hardware|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16044" PostTypeId="2" ParentId="16043" CreationDate="2015-09-13T00:33:22.097" Score="2" Body="&lt;p&gt;No.  Arduino can't behave as USB host.&lt;/p&gt;&#xA;" OwnerDisplayName="corecode" LastActivityDate="2015-09-13T00:33:22.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16045" PostTypeId="2" ParentId="16025" CreationDate="2015-09-13T04:43:59.880" Score="1" Body="&lt;p&gt;Your code compiles, but as Gerben said, the printf won't do anything in its current state, as no output handlers are defined for it. Why go to all that trouble when you can do this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;  {&#xA;  Serial.begin (115200);&#xA;  }&#xA;&#xA;void loop() &#xA;  {&#xA;  uint16_t adc_value;&#xA;  adc_value = analogRead (0);&#xA;  Serial.println (adc_value);&#xA;  delay (100);  // stop output spamming your monitor&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could conceivably make &lt;code&gt;printf&lt;/code&gt; work by following the tutorial here: &lt;a href=&quot;http://playground.arduino.cc/Main/Printf&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/Printf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I don't really see the point, when what I posted is much easier.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If performance is an issue, you might want to use the &quot;advanced&quot; code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That &quot;advanced&quot; code above doesn't give you any more performance, because is still blocks. You can do a non-blocking version easily and readably enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte adcPin = 0;  // A0&#xA;&#xA;bool working;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  ADCSRA =  bit (ADEN);   // turn ADC on&#xA;  ADCSRA |= bit (ADPS0) |  bit (ADPS1) | bit (ADPS2);  // Prescaler of 128&#xA;  ADMUX =   bit (REFS0) | (adcPin &amp;amp; 0x07);  // AVcc   &#xA;  }  // end of setup&#xA;&#xA;void loop () &#xA;  { &#xA;  if (!working)&#xA;    {&#xA;    bitSet (ADCSRA, ADSC);  // start a conversion&#xA;    working = true;&#xA;    }&#xA;&#xA;  // the ADC clears the bit when done&#xA;  if (bit_is_clear(ADCSRA, ADSC))&#xA;    {&#xA;    int value = ADC;  // read result&#xA;    working = false;&#xA;    Serial.println (value);&#xA;    delay (500);  &#xA;    }&#xA;&#xA;  // do other stuff here&#xA;&#xA;  }  // end of loop  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now &lt;strong&gt;that&lt;/strong&gt; code (which admittedly fiddles with the registers) doesn't block so you could be doing other things during the conversion. I don't see any reason you wouldn't use that on a commercial product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;ADC conversion on the Arduino (analogRead)&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-13T19:38:31.493" LastActivityDate="2015-10-13T19:38:31.493" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16046" PostTypeId="2" ParentId="16024" CreationDate="2015-09-13T05:00:40.680" Score="3" Body="&lt;p&gt;I tried your first sketch on my &quot;bare-bones&quot; board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OWnJk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OWnJk.jpg&quot; alt=&quot;Bare-bones board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the sketch exactly as written, it used 197 µA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wondered why it was that high, so I commented out this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That reduced consumption to 122 nA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to get rid of any &quot;power&quot; LEDs, and disconnect any voltage regulators. If you want really low consumption you need to have minimal hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you &lt;em&gt;need&lt;/em&gt; the voltage regulator, well so be it. But don't expect 100 nA consumption if you use it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-13T05:00:40.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16047" PostTypeId="2" ParentId="16032" CreationDate="2015-09-13T05:31:34.270" Score="1" Body="&lt;p&gt;It certainly is possible for an Arduino to do this.  For example, source code for Atmel's implementations of &lt;a href=&quot;https://en.wikipedia.org/wiki/1-Wire&quot; rel=&quot;nofollow&quot;&gt;1-Wire protocol&lt;/a&gt; via bit-banging, via polling UART, and via interrupt-driven UART, is available at &lt;a href=&quot;https://github.com/semicontinuity/embedded/tree/master/target/card-terminal/firmware/one-wire-thermometer&quot; rel=&quot;nofollow&quot;&gt;github.com&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 21-page PDF file, &lt;a href=&quot;http://www.atmel.com/images/doc2579.pdf&quot; rel=&quot;nofollow&quot;&gt;doc2579.pdf&lt;/a&gt;, available at Atmel.  It documents how the different implementations work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the notion of communicating faster than serial via the 1-Wire protocol seems like a mistaken notion.  As I understand it, the serial implementations above use one serial character per 1-Wire bit, so necessarily are slower than serial.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-13T05:31:34.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16048" PostTypeId="1" CreationDate="2015-09-13T06:57:58.957" Score="2" ViewCount="3435" Body="&lt;p&gt;Can we use serial communication in arduino only for RX pin, so that I am free to use pin 1(TX) as digital I/O:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Serial.write('a');&#xA;pinMode(1,OUTPUT);&#xA;digitalWrite(1,LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13358" LastEditorUserId="4131" LastEditDate="2015-09-13T07:25:36.300" LastActivityDate="2015-10-13T21:57:33.127" Title="Can we use serial communication in arduino only for RX pin" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16049" PostTypeId="2" ParentId="16048" CreationDate="2015-09-13T07:33:38.353" Score="2" Body="&#xA;&#xA;&lt;p&gt;HardwareSerial takes over the Tx and Rx pins. However you can use SoftwareSerial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino forum user whiteglint143 made an adaptation of SoftwareSerial that does read-only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/Arduino/ReceiveOnlySoftwareSerial.zip&quot; rel=&quot;nofollow&quot;&gt;http://gammon.com.au/Arduino/ReceiveOnlySoftwareSerial.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=240741.0&quot; rel=&quot;nofollow&quot;&gt;Receive Only Software Serial  - Arduino Forum&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can regain control over the TX or RX pins by unsetting the TXENn or RXENn bit in the UCSRnB register.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Like this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte LED = 1;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  UCSR0B &amp;amp;= ~bit (TXEN0);  // disable transmit&#xA;  Serial.println (&quot;Testing&quot;);&#xA;  pinMode (LED, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  digitalWrite (LED, HIGH);&#xA;  delay (500);&#xA;  digitalWrite (LED, LOW);&#xA;  delay (500);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gerben's suggestion works, in a sense. The pin flashes, but rather disconcertingly, the Tx LED on the board also flashes, out of sync with pin 1. Clearly the signal is making its way to the ATmega16U2 chip, which then flashes the indicator LED. This may not be desirable if you have something connected to the serial port, as it may be interpreted as low-speed serial communications.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-13T21:29:41.783" LastActivityDate="2015-09-13T21:29:41.783" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16051" PostTypeId="1" AcceptedAnswerId="16055" CreationDate="2015-09-13T08:18:04.650" Score="0" ViewCount="280" Body="&lt;p&gt;I would love to get rid of Intel's heavy XDK software, and be able to quickly push the updates of my node.js code into my Intel Edison (arduino compatible) board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this: &lt;code&gt;rsync -avz ./ root@192.168.100.177:/node_app_slot/&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;rsync&lt;/code&gt; is not installed on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you do this?&lt;/p&gt;&#xA;" OwnerUserId="13360" LastActivityDate="2015-09-13T09:19:45.430" Title="How to rsync my node.js project to my intel edison board, through ssh?" Tags="|uploading|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16052" PostTypeId="2" ParentId="16042" CreationDate="2015-09-13T08:47:07.300" Score="1" Body="&lt;p&gt;It sounds, from your textual description (&lt;em&gt;please&lt;/em&gt; post a schematic or at least a photo of your setup) that you aren't providing power to the relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A relay doesn't have a &lt;em&gt;power output&lt;/em&gt;.  It never &lt;em&gt;provides&lt;/em&gt; power - it is merely a magnetically operated switch.  It is used to switch an external source of power on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Treat the NO and COM pins as either side of a normal button or switch and wire it accordingly - that is (for example) connect COM to the positive of your power supply, NO to one side of your load, and the other side of your load to the negative of your power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can share the same power supply as you are feeding to the logic / drive side of the relays.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-13T08:47:07.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16053" PostTypeId="2" ParentId="16043" CreationDate="2015-09-13T08:58:38.860" Score="1" Body="&lt;p&gt;Possibly with an Arduino Due in USB OTG mode if you want to spend months and months (or even years) delving into the USB specs, reverse engineering the driver for the USB dongle and writing the software to get it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Possible&quot; but certainly not worth it when you can use a simple Ethernet shield and have it all working within a day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And definitely not possible on anything like an Uno, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it's possible on an Arduino that runs a full operating system (Linux) like the Edison or (possibly) the Yun (OpenWRT side of the operations, not the Arduino side).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-13T08:58:38.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16054" PostTypeId="2" ParentId="16051" CreationDate="2015-09-13T08:59:15.710" Score="1" Body="&lt;p&gt;rsync works by talking to the rsync executable running on the remote target; without said executable you will need to drop to either scp or a tar pipe.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-13T08:59:15.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16055" PostTypeId="2" ParentId="16051" CreationDate="2015-09-13T09:19:45.430" Score="1" Body="&lt;p&gt;You have few options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;use the Yocto sdk to compile rsync and then deploy it&lt;/li&gt;&#xA;&lt;li&gt;switch to &lt;a href=&quot;https://learn.sparkfun.com/tutorials/loading-debian-ubilinux-on-the-edison&quot; rel=&quot;nofollow noreferrer&quot;&gt;Debian&lt;/a&gt; and then use the standard way to deploy rsync&lt;/li&gt;&#xA;&lt;li&gt;use scp, like the OP wrote, using the &lt;a href=&quot;https://unix.stackexchange.com/questions/105140/how-to-copy-only-new-files-using-scp-command&quot;&gt;answer&lt;/a&gt; from Rick&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you are already looking for a more typical Unix way of doing things, option 2 might be the most efficient for you, in the long run.&#xA;I have not tried it, but AFAIK it should be possible to revert easily, since Edison uses dfu for system upgrades, so you should be able to go back to the stock SW, in case you do not like the Debian installation.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.270" LastActivityDate="2015-09-13T09:19:45.430" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16057" PostTypeId="2" ParentId="16043" CreationDate="2015-09-13T11:18:07.743" Score="2" Body="&lt;p&gt;No, not directly. As @Majenko pointed out its possible but most likely over your head. I am not a big fan of the ethernet shield as I like to use my Arduino for prototyping and then build the project with the components. There are a 2 easy alternatives which are inexpensive options for accessing a network or internet via the Arduino&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ENC28J60 Ethernet LAN Network Module&lt;/li&gt;&#xA;&lt;li&gt;Esp8266 Serial Wifi Wireless Transceiver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Both are inexpensive (between $5 and $7 USD). There are tons of tutorials on line to get you up and running&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-09-13T11:18:07.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16059" PostTypeId="1" CreationDate="2015-09-13T15:53:06.883" Score="0" ViewCount="107" Body="&lt;p&gt;Arduino Uno based on 328p micro-controller board only works while I am inserting the serial cable between the board and the computer and I can control the speed of my two motors and every thing is work properly, but when I eject the serial cable it works badly and there is no control, is that some thing occurs like auto Reset?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is always 5 volt feeding the Arduino, I get 5 volt regulated from the battery using &quot;5v regulator&quot;, this regulated voltage is always connected to the Arduino board. &lt;/p&gt;&#xA;" OwnerUserId="11856" LastEditorUserId="10794" LastEditDate="2015-09-13T21:19:24.087" LastActivityDate="2016-02-11T17:54:23.327" Title="Why did my program stop working when I eject the serial cable like it did an auto reset?" Tags="|arduino-uno|motor|arduino-ide|reset|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16060" PostTypeId="2" ParentId="12133" CreationDate="2015-09-13T16:17:50.437" Score="0" Body="&lt;p&gt;In my case, there was some kind of incompatibility with the ESP8266 connected to the Nano board. As soon as I removed it the Serial Port appeared again.&lt;/p&gt;&#xA;" OwnerUserId="13366" LastActivityDate="2015-09-13T16:17:50.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16062" PostTypeId="1" AcceptedAnswerId="16064" CreationDate="2015-09-13T17:30:08.507" Score="1" ViewCount="11178" Body="&lt;p&gt;Apologies if this a relatively simple question, but I am rather new to Arduino's and cannot seem to find any concise information on the topic.&lt;br /&gt;&#xA;This is my XBee, mounted on a shield and placed onto a MEGA 2560. I want to leave Serial for USB debugging and use the Serial1 for XBee communication.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UyKUE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UyKUE.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Just to confirm, the two XBee's do communicate if I use SoftwareSerial.   This is the code that works using SoftwareSerial:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;// XBee's DOUT (TX) is connected to pin 10 (Arduino's Software RX)&#xA;// XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX)&#xA;SoftwareSerial serial1(10, 11); // RX, TX&#xA;boolean nextLine = false;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  serial1.begin(9600);&#xA;}&#xA; &#xA;void loop() &#xA;{&#xA;   while(serial1.available()){ // there is data being sent from the xBee&#xA;    char read = char(serial1.read());&#xA;    if(read == 'A'){&#xA;      //Where ~ is the EOT character&#xA;      serial1.write(&amp;quot;55.134~&amp;quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;How do I communicate using Serial1?&lt;/p&gt;&#xA;" OwnerUserId="12166" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-13T18:29:47.000" Title="Communicating Via Serial1 on Arduino Mega" Tags="|serial|arduino-mega|xbee|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16063" PostTypeId="2" ParentId="16062" CreationDate="2015-09-13T18:25:45.190" Score="0" Body="&lt;p&gt;There is a good &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MultiSerialMega&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt; on the Arduino site, but in short, you'd use the Serial1 (or -2 or -3) object the same way you use the Serial object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.begin(9600);&#xA;if( Serial1.available() ){ ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-13T18:25:45.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16064" PostTypeId="2" ParentId="16062" CreationDate="2015-09-13T18:29:47.000" Score="3" Body="&lt;p&gt;If you take a look at the headers on the Mega, you'll notice that one of them has labels of &quot;RX1&quot; and &quot;TX1&quot; through &quot;RX3&quot; and &quot;TX3&quot;. You'll also notice that the XBee shield &lt;em&gt;does not&lt;/em&gt; connect to that header, therefore you &lt;em&gt;cannot&lt;/em&gt; use &lt;code&gt;Serial1&lt;/code&gt; through &lt;code&gt;Serial3&lt;/code&gt; with the shield. Either switch to a breakout board that you can connect manually or stick to software serial.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-13T18:29:47.000" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16066" PostTypeId="1" CreationDate="2015-09-13T20:14:05.363" Score="1" ViewCount="237" Body="&lt;p&gt;I bought a 10 V Piezzo electric buzzer and I wonder how to connect it to an Arduino (in my case a Lilypad USB, but the question stands for any Arduino I guess...).&#xA;I hadn't realized this was a 10V buzzer, whereas the Arduino will support at most 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a simple layout such as below, with &lt;a href=&quot;https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v32/experiment-11-using-a-piezo-buzzer&quot; rel=&quot;nofollow noreferrer&quot;&gt;the sample code from a sparksfun tutoral&lt;/a&gt;, but that's not working!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PaTyG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PaTyG.png&quot; alt=&quot;lilypad connected to buzzer&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I do it? ... or should I use another buzzer ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="13371" LastEditorUserId="13371" LastEditDate="2015-09-19T18:51:13.697" LastActivityDate="2015-09-19T18:51:13.697" Title="Using Piezzo Electric buzzer 10V with an Arduino Lilypad USB" Tags="|usb|voltage-level|piezo|buzzer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16067" PostTypeId="2" ParentId="16066" CreationDate="2015-09-13T20:20:56.827" Score="1" Body="&lt;p&gt;Your options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try it anyway with 5V: the buzzer might still produce loud enough sounds for your needs.&lt;/li&gt;&#xA;&lt;li&gt;Use the line from the arduino to drive an &quot;amplifying&quot; stage (ex: 2N2222 in ON/OFF mode) - but this will also require a 10V source (like a step-up voltage converter)&lt;/li&gt;&#xA;&lt;li&gt;Get a piezo that is designed to operate at 5V&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-13T20:20:56.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16068" PostTypeId="1" AcceptedAnswerId="16070" CreationDate="2015-09-13T21:28:48.113" Score="2" ViewCount="13941" Body="&lt;p&gt;I'm trying to use a LCD Display with my Arduino, but I don't have a potentiometer and all of the guides I find always require one, usually a 10k ohm potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is that I'm not very good at this stuff, but I understand that the potentiometer is actually a resistor that can vary, am I correct? In that case, if I use a simple 10k resistor I would have the same result as if I was using that potentiometer at the higher resistance (10k).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be correct to use the resistor instead of the potentiometer? Then I would have to plug the positive on one side of the resistor and both the negative and output to the LCD on the other side of the resistor?&lt;/p&gt;&#xA;" OwnerUserId="11486" LastEditorUserId="10794" LastEditDate="2015-09-14T04:33:01.740" LastActivityDate="2020-03-26T11:58:56.803" Title="10k ohm Potentiometer vs 10k ohm Resistor on LCD Display" Tags="|lcd|display|electronics|resistor|potentiometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16069" PostTypeId="1" AcceptedAnswerId="16071" CreationDate="2015-09-13T21:32:47.763" Score="0" ViewCount="1287" Body="&lt;p&gt;I need to hard reset (or seriously breathe life into) a stuck Arduino clone (Sunfounder UNO) which doesn't get recognized by Windows (error 43) after installing the wrong sketch. I am using the latest Arduino toolset and, before today, the setup was functional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is probably that I am writing to the serial in the &lt;code&gt;setup()&lt;/code&gt; section like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  pinMode(a0, OUTPUT);&#xA;  pinMode(a1, OUTPUT);&#xA;  pinMode(a2, OUTPUT);&#xA;  pinMode(b1, OUTPUT);&#xA;  pinMode(m0, OUTPUT);&#xA;  pinMode(m1, OUTPUT);&#xA;  pinMode(m2, OUTPUT);&#xA;  pinMode(OK, OUTPUT);&#xA;  pinMode(KO, OUTPUT);&#xA;&#xA;  pinMode(carry, INPUT);&#xA;  pinMode(result, INPUT);&#xA;  delay(1000);&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.write(&quot;Arduino Tester v. 0.1\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino seems to be running the code. The problem is that Windows doesn't recognize it and doesn't set up a COM port for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So: i'd like to nuke it and restart from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is this done?&lt;/p&gt;&#xA;" OwnerUserId="14" LastEditorUserId="4131" LastEditDate="2015-09-14T08:34:04.903" LastActivityDate="2015-09-14T08:34:04.903" Title="Hard-resetting an arduino" Tags="|serial|reset|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16070" PostTypeId="2" ParentId="16068" CreationDate="2015-09-13T21:33:41.513" Score="3" Body="&lt;p&gt;No, it would not be correct to use a single resistor to replace a potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On an LCD the potentiometer is used to adjust the &lt;em&gt;bias level&lt;/em&gt; of the LCD - that is the contrast.  You need to use it to set a voltage between Vcc and Vee, which you feed into Vo.  That is, a voltage somewhere between +5V and -5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't do that with one resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, however, do it with two resistors.  Some experimentation will provide the right values to use.  Pick a pair of resistors which add up to around 10K (the exact value doesn't matter that much) and join them together end to end.  The two ends are the equivalent to the ends of the track of the potentiometer, and the join in the middle is the wiper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the &quot;value&quot; of the potentiometer you then need to change the value of both resistors.  If you reduce one resistor you need to increase the other so that they still add up to around the same value.  What you are working with here is not the actual values of the resistors, but the ratio of the values of the two resistors.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-13T21:33:41.513" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16071" PostTypeId="2" ParentId="16069" CreationDate="2015-09-13T21:42:35.290" Score="2" Body="&lt;p&gt;The word &quot;clone&quot; immediately rings alarm bells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, for a &quot;normal&quot; Arduino (like an Uno, etc) the sketch cannot influence whether Windows detects the board or not.  All that is handled by a completely separate chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of the cheap clones these days are coming out of China with a really really cheap USB serial adapter chip.  These barely work at the best of times.  Looking at the pictures I have found of your clone (the manufacturer's site is considerably lacking in any information whatsoever) it doesn't look like it's one of those chips, but one never can tell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they have followed the reference designs for the Arduino then it will be an Atmel ATMega32U4 (IIRC) chip that deals with the interface to the computer.  That has firmware of its own on it, and if that has become corrupted (very unlikely) or damaged (possible) then it could cause it to not be recognised.  If that is the case the in the former instance (corrupted) you will need to replace the firmware on it. For that you will need either a hardware ICSP programmer or another Arduino.  In the latter instance you're stuffed, since you would need to replace the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I say that is unlikely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead your problem is most likely actually with either Windows or the USB cable.  You may need to remove and reinstall the Arduino drivers, or try a difference USB cable.  Also try your &quot;Arduino&quot; on another computer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-13T21:42:35.290" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16072" PostTypeId="1" CreationDate="2015-09-13T21:37:46.080" Score="0" ViewCount="179" Body="&lt;p&gt;I recently bought a Smart Servo Shield controller from DFrobot to use with my new AX-12A Dynamixel servos. The shield is attached to an Arduino Uno. The shield itself works fine, but it does not support all of the functions that I need. The shield has an AtMega8 on board, and they also give you the slave code that it runs to look over. If I were to modify said slave code, is there a way for me to upload to the shield's controller? If so, how would I go about doing that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Smart Servo Shield&#xA;&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=958#.VfXqzxFVhBc&quot; rel=&quot;nofollow&quot;&gt;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=958#.VfXqzxFVhBc&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Nick Ellas" LastActivityDate="2022-11-29T06:08:16.177" Title="Smart Servo Shield: How to upload code to AtMega8" Tags="|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16073" PostTypeId="2" ParentId="16072" CreationDate="2015-09-13T21:44:18.257" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Digital_Servo_Shield_for_Arduino_SKU:DRI0027#Pin_Out&quot; rel=&quot;nofollow&quot;&gt;Like the wiki says&lt;/a&gt;, remove the solder jumpers from the &quot;UART SELECT&quot; jumpers and connect to the &quot;UART FOR Atmega8&quot; connector in order to program it via serial. Don't forget to replace the solder jumpers after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use ISP instead then make sure to remove the shield from the Arduino first since the shield connects all the ATmega8 ISP lines directly to the Arduino ISP lines.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-09-13T21:44:18.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16074" PostTypeId="1" AcceptedAnswerId="16075" CreationDate="2015-09-13T23:43:54.003" Score="0" ViewCount="2188" Body="&lt;p&gt;Is it possible to combine an Arduino µC with a GSM shield and an ethernet shield such that a device connected via ethernet to the Arduino has internet access over the GSM network?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a system with an ethernet port to connect to the internet. It works fine if I plug it into my switch at home. However, I would like this system to have its own cellular internet connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have found so far:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm basically trying to replicate the following:&#xA;&lt;a href=&quot;https://nimbelink.com/e2clink-ethernet2cellular/#parts&quot; rel=&quot;nofollow&quot;&gt;https://nimbelink.com/e2clink-ethernet2cellular/#parts&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the following reddit post:&#xA;&lt;a href=&quot;https://www.reddit.com/r/arduino/comments/3azxs6/create_gsm_cellular_ethernet_modem_with_arduino/&quot; rel=&quot;nofollow&quot;&gt;https://www.reddit.com/r/arduino/comments/3azxs6/create_gsm_cellular_ethernet_modem_with_arduino/&lt;/a&gt;&#xA;is any indication, I would think the answer is &quot;no&quot; but I am hoping to confirm from the expertise available here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6548" LastActivityDate="2015-09-14T00:00:39.410" Title="Ethernet to Cellular Modem Possible? | GSM + Ethernet + Arduino" Tags="|ethernet|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16075" PostTypeId="2" ParentId="16074" CreationDate="2015-09-14T00:00:39.410" Score="1" Body="&lt;p&gt;No, it's not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chiefly because the normal Ethernet shield is not capable of routing.  The Arduino never talks to the ethernet - it talks to the chip on the shield and tells it how to handle the ethernet connection - everything else is then done by the ethernet chip and the results passed back to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly with GSM - you make requests to it and it goes off and does the work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To link the two together you would need raw access to the incoming ethernet packets, and you would then have to perform NAT (Network Address Translation) and maintain internal state tables for current streams and such, and pass reformatted packets on to a GSM modem that could accept raw data like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Way outside the scope of a lowly Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe possible with one of the higher end Arduino-ish systems like the Edison, Galileo or Yun (just) since they run Linux and have a real Ethernet port and a proper USB port to communicate with a proper celular modem.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-14T00:00:39.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16079" PostTypeId="2" ParentId="16059" CreationDate="2015-09-14T03:56:50.883" Score="1" Body="&lt;p&gt;Try increasing the voltage of the power supply. Maybe there might be a problem with the current. The Arduino has a 5V regulator on-board, try using a 9V battery. MAKE SURE THAT YOU CONNECT TO THE DC BARREL CONNECTOR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="13376" LastActivityDate="2015-09-14T03:56:50.883" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16083" PostTypeId="1" AcceptedAnswerId="21572" CreationDate="2015-09-14T17:35:51.030" Score="2" ViewCount="402" Body="&lt;p&gt;I'm having a problem with the intel galileo gen2 ethernet. I am trying to get a webpage, but I can only connect to the ethernet, not the webpage.&#xA;I get this in the Serial monitor:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ciBPt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ciBPt.png&quot; alt=&quot;Serial monitor output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Web client&#xA;&#xA; This sketch connects to a website (http://www.google.com)&#xA; using an Arduino Wiznet Ethernet shield.&#xA;&#xA; Circuit:&#xA; * Ethernet shield attached to pins 10, 11, 12, 13&#xA;&#xA; created 18 Dec 2009&#xA; by David A. Mellis&#xA; modified 9 Apr 2012&#xA; by Tom Igoe, based on work by Adrian McEwen&#xA;&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address for your controller below.&#xA;// Newer Ethernet shields have a MAC address printed on a sticker on the shield&#xA;byte mac[] = { 0x98, 0x4f, 0xee, 0x01, 0x8d, 0xdf };&#xA;// if you don't want to use DNS (and reduce your sketch size)&#xA;// use the numeric IP instead of the name for the server:&#xA;IPAddress server(216, 58, 217, 206); // numeric IP for Google (no DNS)&#xA;//char server[] = &quot;www.google.com&quot;;    // name address for Google (using DNS)&#xA;&#xA;// Set the static IP address to use if the DHCP fails to assign&#xA;IPAddress ip(192, 168, 0, 177);&#xA;IPAddress dns(192, 168, 1, 122);&#xA;IPAddress gateway(192, 168, 1, 1);&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server&#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  delay(5000);&#xA;  // start the Ethernet connection:&#xA;&#xA;  Ethernet.begin(mac, ip, dns, gateway, subnet);&#xA;  Serial.println(&quot;connected to ethernet&quot;);&#xA;  // give the Ethernet shield a second to initialize:&#xA;  delay(1000);&#xA;  Serial.println(&quot;connecting...&quot;);&#xA;&#xA;  // if you get a connection, report back via serial:&#xA;  int ch = client.connect(server, 80);&#xA;  if (ch) {&#xA;    Serial.println(&quot;connected&quot;);&#xA;    // Make a HTTP request:&#xA;    client.println(&quot;GET /search?q=arduino HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.google.com&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;  }&#xA;  else {&#xA;    // kf you didn't get a connection to the server:&#xA;    Serial.print(&quot;connection failed, error code &quot;);&#xA;    Serial.println(ch);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // if there are incoming bytes available&#xA;  // from the server, read them and print them:&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;&#xA;  // if the server's disconnected, stop the client:&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;&#xA;    // do nothing forevermore:&#xA;    while (true);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="8722" LastEditorUserId="10794" LastEditDate="2015-09-15T03:56:19.433" LastActivityDate="2016-03-08T18:45:32.303" Title="Client.connect galileo gen2 not working" Tags="|c++|ethernet|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16084" PostTypeId="1" AcceptedAnswerId="16085" CreationDate="2015-09-14T18:58:08.953" Score="-3" ViewCount="84" Body="&lt;p&gt;Please help me with this code it's shows some error [but I can't be bothered to tell you what].&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA;/**&#xA;&#xA; Analog Clock&#xA;&#xA; Paul Cox Dec 2010&#xA;&#xA;*/&#xA;&#xA;#define    PI       3.141592653589793e-06;&#xA;&#xA;byte rows[8] = {9, 14, 8, 12, 1, 7, 2, 5};&#xA;&#xA;byte cols[8] = {13, 3, 4, 10, 6, 11, 15, 16};&#xA;&#xA;byte pins[16] = {5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};&#xA;&#xA;byte screen[8] = {0, 0, 0, 0, 0, 0, 0, 0};&#xA;&#xA;volatile byte screenRow = 0;&#xA;&#xA;volatile byte screenCol = 0;&#xA;&#xA;int iHour = 0;&#xA;&#xA;int iMin = 0;&#xA;&#xA;int iSec = 0;&#xA;&#xA;void setup()&#xA;&#xA;{&#xA;&#xA;  Timer1.initialize(100);&#xA;&#xA;  for (int i = 2; i &amp;lt;= 17; i++)&#xA;&#xA;  {&#xA;&#xA;     pinMode(i, OUTPUT);&#xA;&#xA;  }&#xA;&#xA;  Timer1.attachInterrupt(doubleBuffer);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  resetAnim();&#xA;&#xA;}&#xA;&#xA;void doubleBuffer()&#xA;&#xA;{&#xA;&#xA;  digitalWrite(translatePin(rows[screenRow]), LOW);&#xA;&#xA;  digitalWrite(translatePin(cols[screenCol]), HIGH);&#xA;&#xA;  screenCol++;&#xA;&#xA;  if (screenCol &amp;gt;= 8)&#xA;&#xA;  {&#xA;&#xA;     screenCol = 0;&#xA;&#xA;     screenRow++;&#xA;&#xA;     if (screenRow &amp;gt;= 8)&#xA;&#xA;     {&#xA;&#xA;       screenRow = 0;&#xA;&#xA;     }&#xA;&#xA;   }&#xA;&#xA;   if((screen[screenRow] &amp;gt;&amp;gt; screenCol) &amp;amp; B1 == B1)&#xA;&#xA;   {&#xA;&#xA;     digitalWrite(translatePin(rows[screenRow]), HIGH);&#xA;&#xA;     digitalWrite(translatePin(cols[screenCol]), LOW);&#xA;&#xA;   }&#xA;&#xA;   else&#xA;&#xA;   {&#xA;&#xA;     digitalWrite(translatePin(rows[screenRow]), LOW);&#xA;&#xA;     digitalWrite(translatePin(cols[screenCol]), HIGH);&#xA;&#xA;   }&#xA;&#xA;}&#xA;&#xA;byte translatePin(byte original)&#xA;&#xA;{&#xA;&#xA;  return pins[original - 1];&#xA;&#xA;}&#xA;&#xA;void allOFF()&#xA;&#xA;{&#xA;&#xA;  for (int i = 0; i &amp;lt; 8; i++)&#xA;&#xA;  {&#xA;&#xA;     screen[i] = 0;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void on(byte row, byte column)&#xA;&#xA;{&#xA;&#xA;  screen[column-1] |= (B1 &amp;lt;&amp;lt; (row - 1));&#xA;&#xA;}&#xA;&#xA;void off(byte row, byte column)&#xA;&#xA;{&#xA;&#xA;  screen[column-1] &amp;amp;= ~(B1 &amp;lt;&amp;lt; (row - 1));&#xA;&#xA;}&#xA;&#xA;void resetAnim()&#xA;&#xA;{&#xA;&#xA;  for (int i = 0; i &amp;lt; 8; i++)&#xA;&#xA;  {&#xA;&#xA;     screen[i] = B11111111;&#xA;&#xA;     delay(25);&#xA;&#xA;  }&#xA;&#xA;  for (int i = 0; i &amp;lt; 8; i++)&#xA;&#xA;  {&#xA;&#xA;     screen[i] = B00000000;&#xA;&#xA;     delay(25);&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;&#xA;  drawClock();&#xA;&#xA;  iSec++;&#xA;&#xA;  if (iSec == 60)&#xA;&#xA;  {&#xA;&#xA;    iSec = 1;&#xA;&#xA;    iMin++;&#xA;&#xA;    if (iMin == 60)&#xA;&#xA;    {&#xA;&#xA;       iMin = 0;&#xA;&#xA;       iHour++;&#xA;&#xA;       if (iHour == 12)&#xA;&#xA;       {&#xA;&#xA;          iHour = 0;&#xA;&#xA;       }&#xA;&#xA;    }&#xA;&#xA;  }&#xA;&#xA;  delay(10);&#xA;&#xA;}&#xA;&#xA;void drawClock()&#xA;&#xA;{&#xA;&#xA;  allOFF();&#xA;&#xA;  setHand(iHour,12,3);&#xA;&#xA;  setHand(iMin,60,4);&#xA;&#xA;  setHand(iSec,60,5);&#xA;&#xA;}&#xA;&#xA;// work out the pixel for a hand - val is out of a possible max val&#xA;&#xA;// radius is distance from the centre&#xA;&#xA;void setHand(int iVal, int iMax, int iRadius)&#xA;&#xA;{&#xA;&#xA;  double  dAngle = (iVal * 2 * PI) / iMax;&#xA;&#xA;  double  dPosX = 4.5 + (iRadius * cos(dAngle));&#xA;&#xA;  double  dPosY = 4.5 + (iRadius * sin(dAngle));&#xA;&#xA;  drawLine(5,5,constrain(round(dPosX),1,8),constrain(round(dPosY),1,8));&#xA;&#xA;}&#xA;&#xA;void drawLine(int x0, int y0, int x1, int y1)&#xA;&#xA;{&#xA;&#xA;  int      iTemp;&#xA;&#xA;  boolean  bSteep = abs(y1 - y0) &amp;gt; abs(x1 - x0);&#xA;&#xA;  if (bSteep)&#xA;&#xA;  {&#xA;&#xA;     iTemp = x0; x0 = y0; y0 = iTemp;    // swap x0,y0&#xA;&#xA;     iTemp = x1; x1 = y1; y1 = iTemp;    // swap x1,y1&#xA;&#xA;  }&#xA;&#xA;  if (x0 &amp;gt; x1)&#xA;&#xA;  {&#xA;&#xA;     iTemp = x0; x0 = x1; x1 = iTemp;    // swap x0,x1&#xA;&#xA;     iTemp = y1; y1 = y0; y0 = iTemp;    // swap y0,y1&#xA;&#xA;  }&#xA;&#xA;  int deltax = x1 - x0;&#xA;&#xA;  int deltay = abs(y1 - y0);&#xA;&#xA;  int error = deltax / 2;&#xA;&#xA;  int ystep = ((y0 &amp;lt; y1) ? 1 : -1);&#xA;&#xA;  int y = y0;&#xA;&#xA;  int x = x0;&#xA;&#xA;  while(x &amp;lt;= x1)&#xA;&#xA;  {&#xA;    if (bSteep)&#xA;    {&#xA;       on(y,x);&#xA;    }&#xA;    else&#xA;    {&#xA;       on(x,y);&#xA;    }&#xA;    error = error - deltay;&#xA;    if (error &amp;lt; 0)&#xA;    {&#xA;       y = y + ystep;&#xA;       error = error + deltax;&#xA;    }&#xA;    x++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13389" LastEditorUserId="10794" LastEditDate="2015-09-14T20:43:40.320" LastActivityDate="2015-09-14T20:43:40.320" Title="Problem with Arduino code" Tags="|arduino-uno|c++|timers|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16085" PostTypeId="2" ParentId="16084" CreationDate="2015-09-14T19:08:54.973" Score="3" Body="&lt;p&gt;It's amazing the difference one character can make:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You must NEVER terminate a #define with a &lt;code&gt;;&lt;/code&gt; unless you absolutely know that you need one when it is expanded.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You have a macro defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define    PI       3.141592653589793e-06;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That macro is then used here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double  dAngle = (iVal * 2 * PI) / iMax;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expand the macro PI and you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double  dAngle = (iVal * 2 * 3.141592653589793e-06;) / iMax;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which obviously is a syntax error - you have a rogue &lt;code&gt;;&lt;/code&gt; in there where you really don't want one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and one other thing - you shouldn't define PI - the Arudino core already defines it for you to a greater accuracy than you are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino/Arduino.h:#define PI 3.1415926535897932384626433832795&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... though you seem to be working in microPi's whatever those are...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-14T19:08:54.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16086" PostTypeId="1" AcceptedAnswerId="16087" CreationDate="2015-09-14T19:03:41.090" Score="1" ViewCount="2914" Body="&lt;p&gt;I am a software engineer who is new(er) to electronics, I only started a couple of months ago. I've built a bunch of custom circuits, then some arduino nodes that are around my apartment that communicate with a C# server. So I've at least got the breadboarding part down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now I am working on a controller board that connects to my home automation system and determines the color on the LED light strips I installed into my bookshelf. So I want to transfer from working with pre-built Arduinos to building my own full node, there are some things I think I'm missing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed that there are duplicate parts on the schematic for the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mega2560 schematic&lt;/a&gt; (such as there being 2 voltage regulators - one is replacement if the other is not available). I couldn't find any such description however for why there are 3 crystals located on the board. I see 3 different circuits for crystals (all of which are 16MHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I am referencing the following&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ylfe5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ylfe5.jpg&quot; alt=&quot;Crystal 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3vI1B.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3vI1B.jpg&quot; alt=&quot;Crystal 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11920" OwnerDisplayName="clamport" LastEditorUserId="11920" LastEditDate="2015-09-14T19:22:09.460" LastActivityDate="2015-09-14T19:22:09.460" Title="Why are there 3 crystals on the Mega2560 schematic?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16087" PostTypeId="2" ParentId="16086" CreationDate="2015-09-14T19:08:10.503" Score="1" Body="&lt;p&gt;One of the crystals is for the ATMega8U2 chip which is being used for USB-Serial conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other two crystals are both for the ATMega2560. Why two? Basically they only populate one of the two, but they have two different footprints. One is for a surface mount resonator, the other for a through-hole crystal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having two footprints gives the option during assembly to go for the cheapest package at the time. It also means that the hobbyist can replaces the low accuracy resonator with a high accuracy crystal if their project requires. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As a side note, if you look at Y1, you will notice it is not the symbol for a crystal, it is of a resonator.&lt;/p&gt;&#xA;" OwnerUserId="6860" OwnerDisplayName="Tom Carpenter" LastActivityDate="2015-09-14T19:08:10.503" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16088" PostTypeId="2" ParentId="16034" CreationDate="2015-09-14T19:30:51.390" Score="1" Body="&lt;p&gt;If your target is a USB audio device - like a USB headset or USB speakers (NOT an MP3 player with USB interface) then you could connect it to something which can act as a USB host with USB audio device drivers.  That means &lt;em&gt;not&lt;/em&gt; an Arduino, but something much more powerful like a Raspberry Pi or BeagleBone Black for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your target is basically an MP3 player that allows you to connect a USB stick with songs on it then you're completely out of luck.  There's this small thing called &lt;em&gt;time&lt;/em&gt; that gets in your way.  You can't stream data to something that expects the data to already be there. You can't seek in a file that doesn't exist until the moment you try to read from it. Also you have to act as if you were a USB memory stick, and that's not easy, and certainly not something an Arduino can do. Even things like the Pi would have a lot of difficulty in managing that since they are hosts, not devices, as far as USB is concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key word here is &lt;em&gt;stream&lt;/em&gt;.  Your target as to be able to receive a &lt;em&gt;stream&lt;/em&gt; of data rather than request blocks of data from a file.  USB audio &lt;em&gt;devices&lt;/em&gt; can do that, but USB audio &lt;em&gt;hosts&lt;/em&gt; cannot.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-14T19:30:51.390" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16089" PostTypeId="1" AcceptedAnswerId="16094" CreationDate="2015-09-14T19:44:44.960" Score="0" ViewCount="92" Body="&lt;p&gt;I want to create a LED Sunrise/Sundown alarm clock. Therefore, I will use a Raspberry Pi that is sending commands over serial to a Teensy 3.1. Like: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&quot;30 Minute Sunrise starting with Color(255,140,0)&quot;&lt;/li&gt;&#xA;&lt;li&gt;&quot;20 Minute Sundown with Color(255,140,0)&quot;&lt;/li&gt;&#xA;&lt;li&gt;&quot;start something else with these 3 parameter.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I don't even get the basic serial part working. E.g. I tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  strip.begin();&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    if (Serial.read() == 'A'){&#xA;      int inte1 = Serial.parseInt();&#xA;      int inte2 = Serial.parseInt();&#xA;      int inte3 = Serial.parseInt();&#xA;      int inte4 = Serial.parseInt();&#xA;      int inte5 = Serial.parseInt();&#xA;      if (Serial.read() == '\n') {&#xA;        Serial.print(inte1);&#xA;        Serial.print(inte2);&#xA;        Serial.print(inte3);&#xA;        Serial.print(inte4);&#xA;        Serial.println(inte5);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I planned to do a &lt;code&gt;case&lt;/code&gt; switch afterwards. &lt;code&gt;Inte1&lt;/code&gt; should define sunrise/sundown, &lt;code&gt;Inte2&lt;/code&gt; the minutes, 'Inte3-5' the rgb color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I enter &quot;A 1 100 100 100&quot; it is not printing anything at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way do get this working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="13390" LastEditorUserId="11086" LastEditDate="2015-09-18T11:35:45.377" LastActivityDate="2015-09-18T11:35:45.377" Title="How do I start a function with serial input?" Tags="|serial|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16090" PostTypeId="2" ParentId="11981" CreationDate="2015-09-14T20:32:15.703" Score="2" Body="&lt;p&gt;If you draw too much current from an Arduino microcontroller it can reset itself (brownout), that results in it not responding. To solve this do not power your servo directly from the Arduino, use an external power supply. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2017-08-24T14:20:55.290" LastActivityDate="2017-08-24T14:20:55.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16091" PostTypeId="1" CreationDate="2015-09-14T21:19:22.820" Score="0" ViewCount="115" Body="&lt;p&gt;Does anyone know where I can get the potentiometer that comes with the Arduino kit? You can see them &lt;a href=&quot;http://www.arduino.cc/documents/datasheets/Potentiometer.PDF&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://store.arduino.cc/product/C000013&quot; rel=&quot;nofollow&quot;&gt;They are sold out on their website&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7806" LastEditorUserId="4143" LastEditDate="2015-09-14T21:29:25.057" LastActivityDate="2015-09-14T21:29:25.057" Title="Where to get the potentiometer that comes with Arduino kit" Tags="|potentiometer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16092" PostTypeId="2" ParentId="16091" CreationDate="2015-09-14T21:23:03.270" Score="2" Body="&lt;p&gt;It's just any old trimmer pot. It's nothing special. Why do you feel you need that specific one? Any pot (of the right value) will do.  What value is it? (That datasheet is a generic one for all values).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Visit your favourite electronics retailer (IRL or on line) and pick a pot that is a suitable value and jiffles your tipples.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-14T21:23:03.270" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="16093" PostTypeId="1" AcceptedAnswerId="16095" CreationDate="2015-09-14T21:47:11.600" Score="0" ViewCount="118" Body="&lt;p&gt;How can I evaluate a pulsed signal in Arduino? The signal comes from an car alarm system and is called (-) output 200 mA. Arduino and the car have the same GND. Can I attach the output through a resistor to PB0 (D8) or PD5 (D5)?&#xA;Alarm system is called Ampire. Probably the same as Viper. I just wanted to read these pulses, but I do not know exactly how I connect this output correctly with Arduino.&#xA;This is the description for this Output:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HN1/9 BROWN/WHITE – 200mA (-) Horn honk output: This wire supplies a 200mA (-) output that can be used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used to interface with the vehicle’s horn circuit&lt;/strong&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="13392" LastEditorUserId="13392" LastEditDate="2015-09-14T23:08:34.283" LastActivityDate="2015-09-15T03:54:24.183" Title="Looking for circuit diagram for evaluation of a pulsed signal" Tags="|signal-processing|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16094" PostTypeId="2" ParentId="16089" CreationDate="2015-09-14T21:47:59.557" Score="1" Body="&lt;p&gt;Okay, as Majenko and Nick Gammon have suggested. The &lt;code&gt;\n&lt;/code&gt; had not arrived in the serial buffer. That way the if clause was not fulfilled and nothing was printed. This code has worked for me now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available() &amp;gt; 0) {&#xA; if (Serial.read() == 'A'){&#xA;  char inte1 = Serial.read();&#xA;  int inte2 = Serial.parseInt();&#xA;  int inte3 = Serial.parseInt();&#xA;  int inte4 = Serial.parseInt();&#xA;  int inte5 = Serial.parseInt();&#xA;  Serial.print(inte1);&#xA;  Serial.print(inte2);&#xA;  Serial.print(inte3);&#xA;  Serial.print(inte4);&#xA;  Serial.println(inte5);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although i read quite a bit now, serial input is still a mystery to me.&lt;/p&gt;&#xA;" OwnerUserId="13390" LastActivityDate="2015-09-14T21:47:59.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16095" PostTypeId="2" ParentId="16093" CreationDate="2015-09-14T23:13:59.760" Score="1" Body="&lt;p&gt;I found a user manual at &lt;a href=&quot;http://www.ampire.de/Security-Systems/Security-for-CAN-Bus-System/AUDI/AUDI-A3/from-model-year-2013/AMPIRE-Car-Alarm-System-for-High-Speed-CAN-Bus.htm?shop=ampire_en&amp;amp;SessionId=&amp;amp;a=article&amp;amp;ProdNr=CAN3903V&amp;amp;t=2899&amp;amp;c=16941&amp;amp;p=16941&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMPIRE Car Alarm System for High-Speed CAN-Bus&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;N1/9 BROWN/WHITE – 200mA (-) Horn honk output:&lt;/strong&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This wire supplies a 200mA (-) output that can be &#xA;  used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed &#xA;  and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the &#xA;  vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used &#xA;  to interface with the vehicle’s horn circuit. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;IMPORTANT!&lt;/strong&gt;&#xA;   Never use this wire to drive anything but a relay or a low-current input! This transistorized output can only supply (-) 200mA and connecting directly to a solenoid, motor or other high current device will cause the module to fall&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Judging by that this output will sink up to 200 mA. You could conceivably set an Arduino pin to INPUT_PULLUP and let this output drive it low to indicate it is active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I think I would use an optocoupler, in case there were unexpected voltages on that pin. You would need a series resistor to limit current through the LED in the optocoupler, say 1 k would be about right if you were connecting it to the 12V car system.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vf = 1.2V (say)&#xA;Voltage over resistor = 12 - 1.2 = 10.8 volts&#xA;Current through LED = 10 mA&#xA;Limiting resistor = 10.8 / 0.01 = 1080 ohms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the output of the optocoupler can sink your Arduino pin, which you have configured as input pullup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write a test sketch to see what you are getting through it, but a multimeter should probably tell you, if it just flashes it slowly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Suggested schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SiiN1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SiiN1.png&quot; alt=&quot;Schematic for optocoupler&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-15T03:54:24.183" LastActivityDate="2015-09-15T03:54:24.183" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16096" PostTypeId="1" CreationDate="2015-09-15T00:59:55.803" Score="1" ViewCount="529" Body="&lt;p&gt;After researching other posts I can see how to make a servo spin continually and remove the ability to set to a specific angle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is make a small project that has a spinning 'game wheel', each segment of the wheel has a prize on it (think almost wheel of fortune). The catch is when someone has landed on a prize once it cannot be landed on again so I want to manipulate the spin slightly so it doesn't stop on the same prize. Do do this I need to be able to get the spin AND know where the needle is pointing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a component that will allow both a full rotation AND the ability to control the location of the needle at the same time? I suspect servos can do one, or the either but not both. &lt;/p&gt;&#xA;" OwnerUserId="13394" LastActivityDate="2015-09-16T11:20:36.417" Title="Making servo spin and able to detect angle" Tags="|motor|servo|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16098" PostTypeId="1" CreationDate="2015-09-15T03:51:13.263" Score="2" ViewCount="339" Body="&lt;p&gt;I've built a bareduino. The blink sketch that it came preprogrammed with worked. I was also able to program the ATmega328 by putting it into a arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I can't do is upload a sketch directly. I've tried both of the methods described here: &lt;a href=&quot;https://www.virtuabotix.com/bareduino328-programming-guide/&quot; rel=&quot;nofollow&quot;&gt;https://www.virtuabotix.com/bareduino328-programming-guide/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used FTDI before and I know that my drivers work. I've tried suggestions from many forums and after 3 hours I'm running out of options. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue seems to be the reset pin. But the fixes here have not worked. I must admit I'm confused about how to un-ground the reset pin. I tried unplugging the power. When I tried to upload with FTDI I had a capacitor... so shouldn't that fix this error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Verbose Error Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 7,920 bytes (24%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 383 bytes (18%) of dynamic memory, leaving 1,665 bytes for local variables. Maximum is 2,048 bytes.&#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem1d11 -b115200 -D -Uflash:w:/var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build7068227750495702499.tmp/webclient.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/futurebird/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/cu.usbmodem1d11&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-09-15T03:51:13.263" Title="Can't program bareduino. &quot;avrdude: stk500_recv(): programmer is not responding&quot;" Tags="|uploading|atmega328|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16099" PostTypeId="1" CreationDate="2015-09-15T08:53:24.350" Score="0" ViewCount="704" Body="&lt;p&gt;I'm trying to get the potentiometer seen at the top left of the photo to work, essentially as a dimmer. I've managed to upload the Arduino sketch, but it isn't working. Any help would be greatly appreciated!&#xA;NB: I have little-to-no electronics experience so my understanding of jargon is limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; SENSOR_LIGHTS: Potentiometer &amp;gt;&amp;gt; LED (Single Channel Script)&#xA;&#xA; This example dims light levels using an LED on pin 11&#xA; and a potentiometer on A0. &#xA;&#xA; Created by Ryan Achten | SOMA | somavisions.com&#xA;&#xA; This example code is in the public domain.&#xA; */&#xA;&#xA;int potentLevel;&#xA;int ledLevel;&#xA;&#xA;//*************************CHECK*****************************&#xA;&#xA;int led = 11;           // the pin that the LED is attached to&#xA;int inputPin = A0;      // the pin that the potentiometer is attached to&#xA;&#xA;//*************************CALIBRATE*************************&#xA;&#xA;const int numReadings = 1;  //change this to alter the number of values to be averaged&#xA;int potentMin = 280; &#xA;int potentMax = 700;        //maximum output from potentiometer&#xA;int loopDelay = 100;       //delay time between loops. Too low may cause overclocking  &#xA;//                            while too high may cause delayed sensor response&#xA;&#xA;//***********************************************************&#xA;&#xA;int potentAve = 0;&#xA;int readings[numReadings];&#xA;int index = 0;&#xA;int total = 0;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup()  { &#xA;&#xA;  //*************************POTENT &amp;gt;&amp;gt; LED SETUP CODE*************************&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(led, OUTPUT);&#xA;&#xA;&#xA;  //***************************SMOOTH SETUP CODE*****************************&#xA;  // initialise all the readings to 0: &#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++)&#xA;    readings[thisReading] = 0;  &#xA;&#xA;} &#xA;&#xA;&#xA;//****************************SMOOTH LOOP CODE****************************&#xA;&#xA;void loop()  { &#xA;&#xA;  total= total - readings[index];         &#xA;  readings[index] = analogRead(inputPin); &#xA;  total= total + readings[index];       &#xA;  index = index + 1;  &#xA;&#xA;  if (index &amp;gt;= numReadings)              &#xA;    index = 0;                           &#xA;&#xA;  potentAve = total / numReadings;         &#xA;  Serial.print(&quot;Average Potentiometer Readings: &quot;);&#xA;  Serial.println(potentAve);   &#xA;&#xA;&#xA;&#xA;  //*************************POTENT &amp;gt;&amp;gt; LED LOOP CODE*************************&#xA;&#xA;  ledLevel = map(potentAve, potentMin, potentMax, 0, 255);&#xA;  Serial.print(&quot;LED Level: &quot;);&#xA;  Serial.println(ledLevel, DEC);&#xA;  analogWrite(led, ledLevel);&#xA;&#xA;  Serial.println();&#xA;  delay(loopDelay);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9idR0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9idR0.jpg&quot; alt=&quot;Electronics Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Oq9U7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oq9U7.jpg&quot; alt=&quot;Photo of electronics&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13398" LastEditorUserId="2881" LastEditDate="2015-09-15T09:51:00.100" LastActivityDate="2015-09-15T10:00:53.133" Title="Potentiometer won't work" Tags="|potentiometer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16101" PostTypeId="1" AcceptedAnswerId="16104" CreationDate="2015-09-15T09:26:50.427" Score="1" ViewCount="861" Body="&lt;p&gt;I make simple code to read web page by &lt;a href=&quot;http://imall.itead.cc/gboard.html&quot; rel=&quot;nofollow&quot;&gt;ITEAD Gboard&lt;/a&gt;. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.write(&quot;\nStarting..........\n&quot;);&#xA;  mySerial.print(&quot;AT+CSQ&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----1-----\n&quot;);&#xA;&#xA;  mySerial.println(&quot;AT+CGATT=1&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----2-----\n&quot;);&#xA;&#xA;  mySerial.println(&quot;AT+CGATT?&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());    &#xA;&#xA;  Serial.write(&quot;\n-----3-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+SAPBR=3,1,\&quot;CONTYPE\&quot;,\&quot;GPRS\&quot;&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----4-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;internet\&quot;&quot;);&#xA;  delay(2000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----5-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+SAPBR=1,1&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----6-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+HTTPINIT&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----7-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;xx.xx.xx.xx/my/web/site\&quot;&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----8-----\n&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+HTTPDATA=100,1000&quot;);&#xA;  delay(10000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\n-----9-----\n&quot;);&#xA;&#xA;  mySerial.println(&quot;AT+HTTPREAD&quot;);&#xA;  delay(1000);&#xA;&#xA;  while(mySerial.available()!=0)&#xA;    Serial.write(mySerial.read());&#xA;&#xA;  Serial.write(&quot;\nend.\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which i get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting..........&#xA;AT+CSQ&#xA;-----1-----&#xA;AT+CGATT=1&#xA;&#xA;ERROR&#xA;&#xA;-----2-----&#xA;AT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;&#xA;-----3-----&#xA;AT+SAPBR=3,1,&quot;CONTYPE&quot;,&quot;GPRS&quot;&#xA;-----4-----&#xA;AT+SAPBR=3,1,&quot;APN&quot;,&quot;internet&quot;&#xA;-----5-----&#xA;AT+SAPBR=1,1&#xA;-----6-----&#xA;AT+HTTPINIT&#xA;-----7-----&#xA;AT+HTTPPARA=&quot;URL&quot;,&quot;xx.xx.xx.xx/my/web/site&quot;&#xA;-----8-----&#xA;AT+HTTPDATA=100,1000&#xA;-----9-----&#xA;AT+HTTPREAD&#xA;&#xA;ERROR&#xA;&#xA;end.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AT+HTTPREAD return error. What wrong with me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;xx.xx.xx.xx/my/web/site is my web page. The error is still there for all web page.&lt;/p&gt;&#xA;" OwnerUserId="7828" LastActivityDate="2015-09-15T10:57:12.150" Title="Problem in SIM900 GPRS connection" Tags="|gsm|arduino-duemilanove|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16102" PostTypeId="2" ParentId="16099" CreationDate="2015-09-15T10:00:53.133" Score="1" Body="&lt;p&gt;Assuming the brown board in your drawing is stripboard, I have to as the question:&lt;/p&gt;&#xA;&lt;p&gt;What is this?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dVdT7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dVdT7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If those five wires in that column are all ground, that link is basically short circuiting your MOSFET via the green wire next to it, thus rendering your whole circuit pointless.  The LEDs will just be on full brightness permanently since the current just flows from the input power, through the LED strip, through the red/white wire, through that little white link wire, then through the green/white and/or the brown/white wires to ground.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-15T10:00:53.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16103" PostTypeId="1" AcceptedAnswerId="16116" CreationDate="2015-09-15T10:39:49.807" Score="3" ViewCount="5090" Body="&lt;p&gt;Stumbled upon this weirdest behavior, from time to time, my Arduino (UNO) runs gode really slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching this issue didn't clarify anything, most people have problems with IDE itself. My issue is related to actual board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heres a sample of my flow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I compile &amp;amp; upload my sketch, all good&lt;/li&gt;&#xA;&lt;li&gt;first initiation of program on the board seems to be &quot;fast&quot;&lt;/li&gt;&#xA;&lt;li&gt;when I start to &quot;animate&quot; the neopixels it goes 3-4 times slower than it should&lt;/li&gt;&#xA;&lt;li&gt;I'll touch the board, and animation goes fast again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=B-7562YRjLU&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's a clip of that, at the end you'll see the &quot;slowness&quot;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Test environment:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9HW7S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9HW7S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Live environment:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bAezE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bAezE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The Touching part, is almost like if I &quot;add&quot; static electricity from my finger to the board, it wakes up and behaves normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For you who are curious about (non related) what animation I'm doing on neopixels, I'm turning on 15 pixels from 0 to 54. Like a &quot;slide effect&quot;.&#xA;(I'm not using delay, only a delay(30) in the loop, rest of the delays are based on &lt;code&gt;millis()&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any general info / explanation that would explain this behavior, like in electronics, arduino boards specifically ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I should also add, when printing logs into serial monitor, that slowness also affects the  outputs... they appear as &quot;slow&quot; as the pixels flow. When all works normally, I see pixels change and logs 50 times per second (roughly), but in this slow motion, I see pixels change and logs around 20 times per second.  Taking out the &lt;code&gt;Serial&lt;/code&gt; entirely from the code doesn't seem to have effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#define LEFT_BLINK_IN 2&#xA;#define RIGHT_BLINK_IN 3&#xA;#define PIN           6&#xA;#define NUMPIXELS     54&#xA;Adafruit_NeoPixel     leftLight = Adafruit_NeoPixel(NUMPIXELS, 6, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel     rightLight = Adafruit_NeoPixel(NUMPIXELS, 10, NEO_GRB + NEO_KHZ800);&#xA;int leftBlinkCount   = 0;&#xA;int rightBlinkCount  = 0;&#xA;int PIXELTOSHOW      = 20;&#xA;bool OEM_RIGHT_ON    = false;&#xA;bool OEM_LEFT_ON     = false;&#xA;int R_PIXEL          = -1;&#xA;int L_PIXEL          = -1;&#xA;int G_PIXEL          = -1;&#xA;int D_PIXEL          = -1;&#xA;char LAST_COMMAND;&#xA;bool DRL_ON         = false;&#xA;int DRL_STARTPIXEL  = 35;&#xA;uint32_t COLOR_YEL = rightLight.Color(240, 120, 0);&#xA;uint32_t COLOR_RED = rightLight.Color(255, 0, 0);&#xA;uint32_t COLOR_BLU = rightLight.Color(0, 0, 255);&#xA;uint32_t COLOR_NON = rightLight.Color(0, 0, 0);&#xA;uint32_t COLOR_WHI = rightLight.Color(255, 255, 255);&#xA;&#xA;unsigned long rightPrevMillis = 0;&#xA;unsigned long leftPrevMillis = 0;&#xA;unsigned long generalPrevMillis = 0;&#xA;const long PIXEL_SWITCH_INTERVAL = 5;&#xA;&#xA;int DRL_RESETER_LEFT = 0;&#xA;int DRL_RESETER_RIGHT = 0;&#xA;&#xA;void welcome()&#xA;{&#xA;  int totalPixels = (NUMPIXELS + PIXELTOSHOW);&#xA;  while (G_PIXEL &amp;lt; totalPixels) {&#xA;    unsigned long leftCurrentMillis = millis();&#xA;    if (leftCurrentMillis - leftPrevMillis &amp;gt;= 12) {&#xA;      leftLight.setPixelColor(totalPixels - G_PIXEL, COLOR_WHI);&#xA;      rightLight.setPixelColor(totalPixels - G_PIXEL, COLOR_WHI);&#xA;      if (G_PIXEL &amp;gt;= 10) {&#xA;        leftLight.setPixelColor(totalPixels - G_PIXEL + PIXELTOSHOW , COLOR_NON);&#xA;        rightLight.setPixelColor(totalPixels - G_PIXEL + PIXELTOSHOW , COLOR_NON);&#xA;      }&#xA;      leftLight.show();&#xA;      rightLight.show();&#xA;      G_PIXEL++;&#xA;      leftPrevMillis = leftCurrentMillis;&#xA;    }&#xA;  }&#xA;  G_PIXEL = 0;&#xA;  while (G_PIXEL &amp;lt; totalPixels) {&#xA;    unsigned long leftCurrentMillis = millis();&#xA;    if (leftCurrentMillis - leftPrevMillis &amp;gt;= 12) {&#xA;      leftLight.setPixelColor(G_PIXEL, COLOR_WHI);&#xA;      rightLight.setPixelColor(G_PIXEL, COLOR_WHI);&#xA;      if (G_PIXEL &amp;gt;= 10) {&#xA;        leftLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;        rightLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;      }&#xA;      leftLight.show();&#xA;      rightLight.show();&#xA;      G_PIXEL++;&#xA;      leftPrevMillis = leftCurrentMillis;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void blinkRight()&#xA;{&#xA;&#xA;  //slidePixels(rightBlinkCount, R_PIXEL, rightLight);&#xA;  if (rightBlinkCount &amp;gt; 0 &amp;amp;&amp;amp; R_PIXEL &amp;gt; -1)&#xA;  {&#xA;      //Serial.println(&quot;RIGHT &quot;+String(rightBlinkCount));&#xA;    LAST_COMMAND = ' ';&#xA;    unsigned long rightCurrentMillis = millis();&#xA;    if (rightCurrentMillis - rightPrevMillis &amp;gt;= PIXEL_SWITCH_INTERVAL) {&#xA;      rightLight.setPixelColor(R_PIXEL, COLOR_YEL);&#xA;      if (R_PIXEL &amp;gt;= PIXELTOSHOW)&#xA;      {&#xA;        rightLight.setPixelColor(R_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;        if (G_PIXEL &amp;gt; -1 &amp;amp;&amp;amp; DRL_ON == false) {&#xA;          leftLight.setPixelColor(R_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;        }&#xA;      }&#xA;      leftLight.show();&#xA;      rightLight.show();&#xA;      R_PIXEL++;&#xA;      rightPrevMillis = rightCurrentMillis;&#xA;    }&#xA;    if ( R_PIXEL &amp;gt;= (NUMPIXELS + PIXELTOSHOW)) {&#xA;      rightBlinkCount--;&#xA;      if ( rightBlinkCount &amp;gt; -1 ) {&#xA;        R_PIXEL = DRL_RESETER_RIGHT = 0;&#xA;      } else {&#xA;        L_PIXEL = G_PIXEL = -1;&#xA;      }&#xA;      if(DRL_ON){&#xA;        D_PIXEL=DRL_STARTPIXEL;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  }&#xA;&#xA;  void blinkLeft() {&#xA;  //  slidePixels(leftBlinkCount, L_PIXEL, leftLight);&#xA;&#xA;    if (leftBlinkCount &amp;gt; 0 &amp;amp;&amp;amp; L_PIXEL &amp;gt; -1)&#xA;  {&#xA;          //Serial.println(&quot;left  &quot;+String(rightBlinkCount));&#xA;    LAST_COMMAND = ' ';&#xA;    unsigned long leftCurrentMillis = millis();&#xA;    if (leftCurrentMillis - leftPrevMillis &amp;gt;= PIXEL_SWITCH_INTERVAL) {&#xA;      leftLight.setPixelColor(L_PIXEL, COLOR_YEL);&#xA;      if (L_PIXEL &amp;gt;= PIXELTOSHOW)&#xA;      {&#xA;        Serial.print(&quot; &quot;+String(L_PIXEL));&#xA;        leftLight.setPixelColor(L_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;        if (G_PIXEL &amp;gt; -1 &amp;amp;&amp;amp; DRL_ON == false) {&#xA;          rightLight.setPixelColor(L_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;&#xA;        }&#xA;      }&#xA;      rightLight.show();&#xA;      leftLight.show();&#xA;      L_PIXEL++;&#xA;      leftPrevMillis = leftCurrentMillis;&#xA;    }&#xA;    if ( L_PIXEL &amp;gt;= (NUMPIXELS + PIXELTOSHOW) ) {&#xA;      leftBlinkCount--;&#xA;      Serial.println(&quot;Count &quot;+leftBlinkCount);&#xA;      if ( leftBlinkCount &amp;gt; -1 ) {&#xA;        L_PIXEL = DRL_RESETER_LEFT = 0;&#xA;      } else {&#xA;        L_PIXEL = G_PIXEL = -1;&#xA;      }&#xA;      if(DRL_ON){&#xA;        D_PIXEL=DRL_STARTPIXEL;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&#xA;/*void slidePixels(int &amp;amp;blinkCount, int &amp;amp;blinkPixel, Adafruit_NeoPixel &amp;amp;sideLight){&#xA;  if (blinkCount &amp;gt; 0 &amp;amp;&amp;amp; blinkPixel &amp;gt; -1)&#xA;  {&#xA;    LAST_COMMAND = ' ';&#xA;    unsigned long leftCurrentMillis = millis();&#xA;    if (leftCurrentMillis - leftPrevMillis &amp;gt;= PIXEL_SWITCH_INTERVAL) {&#xA;      sideLight.setPixelColor(blinkPixel, COLOR_YEL);&#xA;      if (blinkPixel &amp;gt;= PIXELTOSHOW)&#xA;      {&#xA;        if(G_PIXEL&amp;gt;-1){&#xA;          rightLight.setPixelColor(blinkPixel - PIXELTOSHOW, COLOR_NON);&#xA;          leftLight.setPixelColor(blinkPixel - PIXELTOSHOW, COLOR_NON);&#xA;        }&#xA;      }&#xA;      rightLight.show();&#xA;      leftLight.show();&#xA;      blinkPixel++;&#xA;      leftPrevMillis = leftCurrentMillis;&#xA;    }&#xA;    if ( blinkPixel &amp;gt;= (NUMPIXELS + PIXELTOSHOW) ) {&#xA;      blinkCount--;&#xA;      if ( blinkCount &amp;gt; -1 ) {&#xA;        blinkPixel = 0;&#xA;      } else {&#xA;        blinkPixel = -1;&#xA;        if(DRL_ON){&#xA;          G_PIXEL = -1;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}*/&#xA;&#xA;int switchRB = 0; // 0 = red, 1 = blue&#xA;void slideBlueRed() {&#xA;  unsigned long currentMillis = millis();&#xA;  if (currentMillis - generalPrevMillis &amp;gt;= 100) {&#xA;    if (switchRB == 0) {&#xA;      leftLight.setPixelColor(G_PIXEL, COLOR_RED);&#xA;      rightLight.setPixelColor(G_PIXEL, COLOR_RED);&#xA;    } else {&#xA;      leftLight.setPixelColor(G_PIXEL, COLOR_BLU);&#xA;      rightLight.setPixelColor(G_PIXEL, COLOR_BLU);&#xA;    }&#xA;    if (G_PIXEL &amp;gt;= 10) {&#xA;      leftLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;      rightLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);&#xA;    }&#xA;    leftLight.show();&#xA;    rightLight.show();&#xA;    G_PIXEL++;&#xA;    generalPrevMillis = currentMillis;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void drlLight(){&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;  if (D_PIXEL &amp;lt; NUMPIXELS) {&#xA;    leftLight.setPixelColor(NUMPIXELS-DRL_RESETER_LEFT, DRL_ON == true ? COLOR_WHI : COLOR_NON);&#xA;    rightLight.setPixelColor(NUMPIXELS-DRL_RESETER_RIGHT, DRL_ON == true ? COLOR_WHI : COLOR_NON);&#xA;    rightLight.setBrightness(128);&#xA;    leftLight.setBrightness(128);&#xA;    rightLight.show();&#xA;    leftLight.show();&#xA;    D_PIXEL++;&#xA;   //x //Serial.println(String(DRL_RESETER_LEFT) + &quot; &quot;+ String(NUMPIXELS - DRL_STARTPIXEL));&#xA;    if(DRL_RESETER_LEFT+1 &amp;lt; (NUMPIXELS - DRL_STARTPIXEL)){&#xA;      DRL_RESETER_LEFT++;&#xA;    }&#xA;    if(DRL_RESETER_RIGHT+1 &amp;lt; (NUMPIXELS - DRL_STARTPIXEL)){&#xA;      DRL_RESETER_RIGHT++;&#xA;    }&#xA;    generalPrevMillis = currentMillis;&#xA;  }&#xA;&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  leftLight.begin();&#xA;  rightLight.begin();&#xA;  pinMode(LEFT_BLINK_IN, INPUT);&#xA;  pinMode(RIGHT_BLINK_IN, INPUT);&#xA;  delay(50);&#xA;  welcome();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (digitalRead(LEFT_BLINK_IN) == HIGH) {&#xA;    if ( OEM_LEFT_ON == false ) {&#xA;      OEM_LEFT_ON = true;&#xA;      leftBlinkCount++;&#xA;      //Serial.println(&quot;LEFT &quot;+String(leftBlinkCount));&#xA;      if (leftBlinkCount == 1) {&#xA;        L_PIXEL = 0;&#xA;      }&#xA;    }&#xA;  } else {&#xA;    OEM_LEFT_ON = false;&#xA;  }&#xA;&#xA;  if (digitalRead(RIGHT_BLINK_IN) == HIGH) {&#xA;    if ( OEM_RIGHT_ON == false ) {&#xA;      OEM_RIGHT_ON = true;&#xA;      rightBlinkCount++;&#xA;&#xA;      if (rightBlinkCount == 1) {&#xA;        R_PIXEL = 0;&#xA;      }&#xA;    }&#xA;  } else {&#xA;    OEM_RIGHT_ON = false;&#xA;  }&#xA;&#xA;  if(DRL_ON &amp;amp;&amp;amp; leftBlinkCount &amp;lt; 1 &amp;amp;&amp;amp; rightBlinkCount &amp;lt; 1){&#xA;    drlLight();&#xA;  }&#xA;&#xA;  blinkRight();&#xA;  blinkLeft();&#xA;  if(rightBlinkCount &amp;lt; 1 || leftBlinkCount &amp;lt; 1){&#xA;    delay(30);&#xA;    switch (LAST_COMMAND) {&#xA;      case 'q':&#xA;      case '?': {&#xA;        for ( int gp = 0; gp &amp;lt; NUMPIXELS + PIXELTOSHOW; gp++) {&#xA;          leftLight.setPixelColor(gp, COLOR_NON);&#xA;          rightLight.setPixelColor(gp, COLOR_NON);&#xA;        }&#xA;        leftLight.show();&#xA;        rightLight.show();&#xA;        G_PIXEL = -1;&#xA;        break;&#xA;      }&#xA;      case 's': {&#xA;        slideBlueRed();&#xA;        //Serial.println(&quot;bluuu&quot;);&#xA;        if (G_PIXEL &amp;gt;= NUMPIXELS ) {&#xA;          G_PIXEL = -1;&#xA;          switchRB = switchRB == 0 ? 1 : 0;&#xA;        }&#xA;        break;&#xA;      }&#xA;      case 'w': {&#xA;        welcome();&#xA;        if (G_PIXEL &amp;gt;= NUMPIXELS + PIXELTOSHOW) {&#xA;          G_PIXEL = -1;&#xA;        }&#xA;        break;&#xA;      }&#xA;      case 'd': {&#xA;        if(DRL_ON==false){&#xA;          D_PIXEL = DRL_STARTPIXEL;&#xA;          DRL_ON = true;&#xA;          LAST_COMMAND = '-';&#xA;        }else{&#xA;          D_PIXEL = 0;&#xA;          DRL_ON = false;&#xA;        }&#xA;        break;&#xA;      }&#xA;    }&#xA;    if (Serial.available()) {&#xA;      LAST_COMMAND = '-';&#xA;      while (Serial.available()) {&#xA;        char command = Serial.read();&#xA;        G_PIXEL=-1;&#xA;        LAST_COMMAND = command;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="220" LastEditDate="2015-09-22T22:46:57.527" LastActivityDate="2019-07-20T02:30:42.227" Title="Arduino code (on board) runs really slow" Tags="|arduino-uno|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16104" PostTypeId="2" ParentId="16101" CreationDate="2015-09-15T10:57:12.150" Score="0" Body="&lt;p&gt;The problem (I believe) is that half way through your program you switched from using &lt;code&gt;println()&lt;/code&gt; to using &lt;code&gt;print()&lt;/code&gt;, thus the commands from that point on aren't being executed until right at the end where you switch back to &lt;code&gt;println()&lt;/code&gt;, so the whole of the text you send from point 3 onwards is being run as one single command - which of course is in the wrong format:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+SAPBR=3,1,&quot;CONTYPE&quot;,&quot;GPRS&quot;AT+SAPBR=3,1,&quot;APN&quot;,&quot;internet&quot;AT+SAPBR=1,1AT+HTTPINITAT+HTTPPARA=&quot;URL&quot;,&quot;xx.xx.xx.xx/my/web/site&quot;AT+HTTPDATA=100,1000AT+HTTPREAD&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-15T10:57:12.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16105" PostTypeId="1" CreationDate="2015-09-15T12:23:32.657" Score="0" ViewCount="540" Body="&lt;p&gt;I am creating a program that turns on and off an led. When two buttons are considered &quot;high&quot;. But there is a twist, The first button needs to stay &quot;high&quot; until the second button is pressed and the led turns on. Here is my code so far.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Boolean logic for Button Switch &#xA;boolean currentState = LOW;    //stroage for current button state&#xA;boolean lastState = LOW;      //storage for last button state&#xA;boolean ifcondState = LOW;    //storage for the current state of the ifturn  (off/on)&#xA;&#xA;&#xA;// set pin numbers:&#xA;const int buttonPinA = 3;     // the number of the pushbutton pin&#xA;const int buttonPin1 = 4;     // the number of the pushbutton pin&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;const int ifcond =  12;      // the number of the ifcond pin&#xA;const int ifturn =  11;      // the number of the ifturn pin&#xA;&#xA;// variables will change:&#xA;int buttonStateA = 0;         // variable for reading the pushbutton status&#xA;int buttonState1 = 0;         // variable for reading the pushbutton status&#xA;int buttonStateIf = 0;         // variable for reading the If Condition status&#xA;&#xA;void setup() {&#xA;//initialize Serial connection  &#xA;Serial.begin(9600);&#xA;// initialize the LED pin as an output:&#xA;pinMode(ledPin, OUTPUT);&#xA;// initialize the pushbutton pin as an input:&#xA;pinMode(buttonPinA, INPUT);&#xA;// initialize the pushbutton pin as an input:&#xA;pinMode(buttonPin1, INPUT);&#xA;// If Condictional Pin&#xA;pinMode(ifcond, OUTPUT);&#xA;// If Turnon Pin&#xA;pinMode(ifturn, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the pushbutton values:&#xA;  currentState = digitalRead(buttonPinA);&#xA;  buttonState1 = digitalRead(buttonPin1);&#xA;  buttonStateIf = digitalRead(ifturn);&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (currentState == HIGH &amp;amp;&amp;amp; lastState == LOW){    //  if button has just been pressed    &#xA;    Serial.println(&quot;pressed&quot;);&#xA;    //delay(1);&#xA;&#xA;    //toggle the state of the ifcond&#xA;    if (ifcondState == HIGH){&#xA;      digitalWrite(ifcond, LOW);&#xA;      ifcondState = LOW;&#xA;    }&#xA;    else {&#xA;      digitalWrite(ifcond, HIGH);&#xA;      ifcondState = HIGH;&#xA;    }&#xA;  }&#xA;  lastState = currentState;&#xA;&#xA;  if (ifturn == HIGH &amp;amp;&amp;amp; buttonState1 == HIGH) {&#xA;    digitalWrite(ledPin, HIGH);&#xA;  }&#xA;  else ();&#xA;  digitalWrite(ledPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have Pin 12 (ifcond) And pin 11(ifturn) Jumped together. Pin 12 acts like a button to pin 11, When it goes high pin 11 reads the change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code works like this, When ButtonpinA goes high  pin 12 goes high and stays high until the next button push. This is the part that doesn't work Pin 11 should read if pin 12 if high or not. If it reads high and Button1 is also high it should turn on ledpin which it does not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sorry for any confusion Thanks     &lt;/p&gt;&#xA;" OwnerUserId="11567" LastEditorUserId="2881" LastEditDate="2015-09-15T12:32:36.383" LastActivityDate="2018-04-30T18:23:59.337" Title="Buttons and LED" Tags="|arduino-uno|led|button|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16106" PostTypeId="2" ParentId="16105" CreationDate="2015-09-15T14:15:29.043" Score="1" Body="&lt;pre&gt;&lt;code&gt;if (ifturn == HIGH &amp;amp;&amp;amp; buttonState1 == HIGH) {&#xA;  digitalWrite(ledPin, HIGH);&#xA;}&#xA;else ();&#xA;digitalWrite(ledPin, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you have made a small mistake here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are saying there is &quot;If both these inputs are high then turn on the LED - otherwise don't do anything&quot;, and immediately after that &quot;Turn off the LED&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the LED is turned on when they are both high, and immediately turned off again, so fast you never see the LED lighting up at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what you meant to have was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (ifturn == HIGH &amp;amp;&amp;amp; buttonState1 == HIGH) {&#xA;  digitalWrite(ledPin, HIGH);&#xA;} else {&#xA;  digitalWrite(ledPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way it will turn the LED on if both are HIGH, otherwise it will turn the LED off &lt;em&gt;only if the test for both being high fails&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-15T14:15:29.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16107" PostTypeId="2" ParentId="790" CreationDate="2015-09-15T15:08:43.583" Score="0" Body="&lt;p&gt;I have the same problem with arduino pro mini and HC-06, only change the baud rate of your BTserial port... try diferent baud rates in my case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);   &#xA;Serial.println(&quot;AT&quot;);&#xA;&#xA;BTSerial.begin(2400);&#xA;BTSerial.println(&quot;AT&quot;); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Works fine, it happens because the arduino try to &quot;understand&quot; the module, but if the module speaks other leanguage, the arduino will never understand the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;like me... sorry for my bad english. se ya.&lt;/p&gt;&#xA;" OwnerUserId="13407" LastEditorUserId="10794" LastEditDate="2015-09-15T21:25:30.413" LastActivityDate="2015-09-15T21:25:30.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16108" PostTypeId="2" ParentId="5388" CreationDate="2015-09-15T17:04:23.293" Score="0" Body="&lt;p&gt;I would suggest trying this with only one Arduino using Software Serial at first. Try using the receiver board's Hardware Serial to listen, possibly using its Software Serial for the debug output. The Hardware Serial is full duplex - it can talk and listen at the same time. Software Serial is not; only xmit or recv can run at one time, and nothing else on the board runs while it does. That can make synchronizing your two boards difficult if the communication needs to be bi-directional.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-09-15T17:04:23.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16109" PostTypeId="1" AcceptedAnswerId="16132" CreationDate="2015-09-15T17:27:18.277" Score="0" ViewCount="862" Body="&lt;p&gt;So I've been browsing around for a whole looking for a good microcontroller that's super small. So far the smallest one I found was an Arduino Nano. But before I go buying it, there are some questions I have about it. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is Bluetooth compatible with it and if so where would I get the Bluetooth code?&lt;/li&gt;&#xA;&lt;li&gt;Is there anything smaller than it that's Bluetooth compatible?&lt;/li&gt;&#xA;&lt;li&gt;Would an Arduino Nano (Or the device in the question above) be able to play sounds?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13427" OwnerDisplayName="Rowan Harley" LastActivityDate="2015-09-17T01:42:26.250" Title="Would Arduino Nano be good for Bluetooth + Sound" Tags="|bluetooth|sound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16110" PostTypeId="1" AcceptedAnswerId="16113" CreationDate="2015-09-15T19:21:27.510" Score="0" ViewCount="153" Body="&lt;p&gt;I am using the following setup on my Arduino UNO to measure cpu fan RPMs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pP1oM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pP1oM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is set to bring the trigger pin for each transistor high when it is checking that fan's RPM and FreqMeasure.h is then used to check the frequency of the signal on pin 8 which is then translated to RPM and sent to the LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am experiencing reading issues and suspect that the signal is remaining on the measuring bus during the subsequent reads, however before revamping my code I simply wonder:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my circuit logic sturdy? I am just getting my feet back under me with microprocessors and have always found transistors to be a tricky subject, thanks in advance for your help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd like to see more info all can be found on &lt;a href=&quot;https://github.com/msashlee/fanMon/&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13411" LastEditorUserId="4143" LastEditDate="2015-09-15T19:40:08.197" LastActivityDate="2015-09-15T20:15:16.940" Title="Transistors to switch monitor inputs" Tags="|frequency|transistor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16111" PostTypeId="1" CreationDate="2015-09-15T19:40:53.800" Score="0" ViewCount="1538" Body="&lt;p&gt;I am familiar with using PWM on Arduino and have done so with simple 3-pin interfaces: e.g. PWM, DIR (direction) and GND pins. Choose a direction with DIR, set speed with PWM in software (0 - 255), simple stuff. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But this board I'm buying seems different:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/DC-43A-Double-BTS7960B-Stepper-Motor-Driver-H-Bridge-PWM-for-Arduino-Smart-Car-/141485439094&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/DC-43A-Double-BTS7960B-Stepper-Motor-Driver-H-Bridge-PWM-for-Arduino-Smart-Car-/141485439094&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seems to be 6 control pins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;R_IS, R_EN, RPWM, L_IS, L_EN, LPWM&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But from what I understand this board would only be used for controlling one motor bidirectionally, so why is there a distinction between left and right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how would I go about using this motor driver board in a similar way to my &lt;code&gt;PWM, DIR, GND&lt;/code&gt; boards that I've used before to control the motor direction and speed? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13415" OwnerDisplayName="JDS" LastActivityDate="2015-09-15T19:51:37.947" Title="How to connect this motor driver board to Arduino to drive bidirectional motor?" Tags="|current|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16112" PostTypeId="2" ParentId="16111" CreationDate="2015-09-15T19:51:06.857" Score="2" Body="&lt;p&gt;I guess you have used DC Motor for your earlier cases? Or Step Motor with a logic on the stepper controllers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you have two H Bridges which drives one Step Motor. So as I understand it, you have two PWM Inputs, one for each output channel to the coil windings of the stepper motor. Like an encoder signal you can set the direction with setting one pwm before the other. So the step motor is controlled via unipolar stepping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For further help you need to say which motor you want to use with this card. But first I would look at the different stepping modes (unipolar and the two bipolar and maybe microstepping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Greets&lt;/p&gt;&#xA;" OwnerDisplayName="Sider" LastActivityDate="2015-09-15T19:51:06.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16113" PostTypeId="2" ParentId="16110" CreationDate="2015-09-15T20:15:16.940" Score="0" Body="&lt;p&gt;I have &lt;a href=&quot;http://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+10.20027730826997+50+5+43%0AR+240+160+208+160+0+2+721+6+6+0+0.5%0Ag+288+176+288+208+0%0Af+240+160+288+160+0+1.5%0AR+432+80+432+48+0+0+40+5+0+0+0.5%0Ar+432+80+432+144+0+10000%0At+336+96+336+144+0+1+-4.999999997500001+-0.0000049995+100%0Aw+288+144+320+144+0%0Aw+352+144+432+144+0%0Aw+432+144+496+144+0%0Ar+336+96+160+96+0+10000%0Ar+336+240+160+240+0+10000%0AL+160+240+128+240+0+0+false+5+0%0Aw+352+288+432+288+0%0Aw+288+288+320+288+0%0At+336+240+336+288+0+1+-4.999999997500001+-0.0000049995+100%0Af+240+304+288+304+0+1.5%0Ag+288+320+288+352+0%0AR+240+304+208+304+0+2+382+6+6+0+0.5%0Aw+432+144+432+288+0%0AL+160+96+128+96+0+0+false+5+0%0Ap+496+240+496+144+0%0Ag+496+240+496+256+0%0Ao+20+64+0+558+5+0.00009765625+0+-1%0A&quot; rel=&quot;nofollow&quot;&gt;simulated your circuit&lt;/a&gt; and it seems sound enough to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a little confusing having the transistors there though.  I would prefer to convert the three open drain outputs to logic level outputs (each having its own pullup resistor) then use a digital 3:1 MUX (or discrete logic gates) to select the signal to sample.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-15T20:15:16.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16114" PostTypeId="1" AcceptedAnswerId="16115" CreationDate="2015-09-15T20:43:40.773" Score="2" ViewCount="1052" Body="&lt;p&gt;I bought today an Arduino Uno R3, and I'm looking forward to make it an HID device. I have seen many projects using a serial USB type B port. As I want to build a little gamepad, I would like to use the smaller USB mini type B port to achieve similar results. Looking it up did not seem to bring significant results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing anything? Do I have to use a serial port similar to the one used by Arduino or can I reproduce the project using the aforementioned port?&lt;/p&gt;&#xA;" OwnerUserId="13414" LastEditorUserId="6936" LastEditDate="2015-09-17T11:28:55.083" LastActivityDate="2015-09-17T11:28:55.083" Title="USB mini type B port on Arduino Uno" Tags="|arduino-uno|usb|arduino-mini|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16115" PostTypeId="2" ParentId="16114" CreationDate="2015-09-15T21:15:16.907" Score="2" Body="&lt;p&gt;It sounds like you are going to be attempting software &quot;bit-banged&quot; USB.  That, while possible, is severely frowned upon, especially when you have the resources to do it properly at your fingertips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In answer to your question, yes, you can use a USB mini B connector.  It is no different to a USB B connector except it is much smaller and contains one extra pin - USBID - which you can completely ignore (it's only used on USB On-The-Go devices).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB is quite a heavy protocol to do in pure software - it won't leave much &quot;room&quot; for you to do much else.  Better would be to re-program the ATMega16U2 chip that is used for the current USB interface.  You will need some form of hardware programmer for it - you can use another Arduino Uno, and once done you won't be able to directly program the ATMega328P chip through the USB, so you would need some other method for connecting that (external USB serial adapter cable, or another Arduino), but the ATMega16U2 chip is specifically designed to work with the USB.  Offloading the USB portion of your project onto that chip and using the serial interface that is already wired up to communicate commands and instructions to/from the ATMega328P would be a much more powerful (and reliable) system.  There's plenty of tutorials and links around to show you how to reprogram that chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-15T21:38:03.887" LastActivityDate="2015-09-15T21:38:03.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16116" PostTypeId="2" ParentId="16103" CreationDate="2015-09-15T21:23:24.297" Score="4" Body="&lt;p&gt;This kind of behavior is almost always caused by floating digital input pins. &quot;floating&quot; means not connected to either power or ground, so their voltage is free to float. These input puts have very high impedance (typically less than 1uA of leakage current), so bringing a charged object near them is more enough to change their state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the easiest way to nail down (and sometimes fix) this problem is to enable the pull-up resistors on the digital inputs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In you program, this could be as easy changing the mode on the digital input pins from &lt;code&gt;INPUT&lt;/code&gt; to &lt;code&gt;INPUT-PULLUP&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;  leftLight.begin();&#xA;  rightLight.begin();&#xA;  pinMode(LEFT_BLINK_IN, INPUT_PULLUP );&#xA;  pinMode(RIGHT_BLINK_IN, INPUT_PULLUP );&#xA;  delay(50);&#xA;  welcome();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will almost certainly eliminate the intermittent behavior you are seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you end up with might not be what you want (you might want the pin to dault to 0 when not connected), in which case you can add an external pull-down resistor or change the software to work with default pull-up. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-09-15T21:23:24.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16117" PostTypeId="2" ParentId="16114" CreationDate="2015-09-15T21:32:49.830" Score="2" Body="&lt;p&gt;As an alternative to Majenko's suggestion you can implement Virtual USB as described at &lt;a href=&quot;http://www.practicalarduino.com/projects/virtual-usb-keyboard&quot; rel=&quot;nofollow&quot;&gt;Virtual USB Keyboard&lt;/a&gt;. You just need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3 resistors&lt;/li&gt;&#xA;&lt;li&gt;2 zener diodes&lt;/li&gt;&#xA;&lt;li&gt;a bit of wire&lt;/li&gt;&#xA;&lt;li&gt;a suitable USB socket&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The advantage is you haven't modified your Uno's USB chip (the ATMega16U2) so you can continue to upload sketches in the normal way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disadvantage is that the software USB may be more flaky than a hardware-implemented one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I don't like reprogramming my ATMega16U2 because I may as well have used one of the chips with a ATmega32U4 chip on it in the first place (like the Micro) which is designed for easy reprogramming.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-15T21:32:49.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16119" PostTypeId="1" CreationDate="2015-09-16T01:35:58.390" Score="0" ViewCount="1713" Body="&lt;p&gt;I've asked another question in electronics about what to use to compare 2 input voltages, the answer was to use comparators.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digging around a bit, turns out most of the comparators outputs are pull-up, which makes it quite difficult to translate (probably due lack of general electronics knowledge, self-learned) and I'm not able to distinguish from maker's PDFs which comparators have pull-up or pull-down outputs.&#xA;I've figured PD comparators illustrate in PDF a resistor right after the output... but many illustrations I've seen doesn't clarify PD / PU, or I'm just missig that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my question is, are there any PD comparators (well known) where it's output can be connected to the digital pins or arduino (while those are defined as INPUT mode)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate any guidance on this topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just a side note, I want to switch on a led, when ever external source is at 12V and turn that same led off when it's below 11.5V...&lt;/p&gt;&#xA;" OwnerUserId="13402" LastEditorUserId="4358" LastEditDate="2015-09-16T12:45:13.703" LastActivityDate="2015-09-18T04:16:06.470" Title="Comparators for digital input mode" Tags="|arduino-uno|digital-in|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16120" PostTypeId="2" ParentId="16119" CreationDate="2015-09-16T02:30:10.990" Score="2" Body="&lt;p&gt;You can't put 12 volts into a Uno input pin in any case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could run it into a &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;voltage divider&lt;/a&gt; and divide it down to somewhere on the range 0 to 5 V, and then do an analogRead to see exactly (or almost exactly) what the resulting voltage is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really see where comparators come into it in this particular case. I mean, you could use a comparator to turn the LED on, but then where does the Arduino come into it?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've actually tried with voltage divider, I went pretty high on my resistors, taking the 12V source and hooked in 4x1M resistors but the 12V never came down significantly.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need a voltage divider like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PkZhk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PkZhk.png&quot; alt=&quot;Voltage divider&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those values give you 4 V on the Arduino pin if there is 12 V on the input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;V&lt;sub&gt;out&lt;/sub&gt; = (R2 / (R1 + R2) ) * V&lt;sub&gt;in&lt;/sub&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(1000 / 3000) * 12V = 4V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-18T04:16:06.470" LastActivityDate="2015-09-18T04:16:06.470" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16121" PostTypeId="1" CreationDate="2015-09-16T04:59:07.857" Score="1" ViewCount="6962" Body="&lt;p&gt;I build a simple HTTP GET request by SIM900. Here is it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-----1-----&#xA;AT+CSQ&#xA;&#xA;+CSQ: 25,0&#xA;&#xA;OK&#xA;&#xA;-----2-----&#xA;AT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;&#xA;-----3-----&#xA;AT+SAPBR=3,1,&quot;CONTYPE&quot;,&quot;GPRS&quot;&#xA;&#xA;OK&#xA;&#xA;-----4-----&#xA;AT+SAPBR=3,1,&quot;APN&quot;,&quot;indosatgprs&quot;&#xA;&#xA;OK&#xA;&#xA;-----5-----&#xA;AT+SAPBR=1,1&#xA;&#xA;OK&#xA;&#xA;-----6-----&#xA;AT+HTTPINIT&#xA;&#xA;ERROR&#xA;&#xA;-----6.1-----&#xA;AT+HTTPPARA=&quot;CID&quot;,1&#xA;&#xA;OK&#xA;&#xA;-----7-----&#xA;AT+HTTPPARA=&quot;URL&quot;,&quot;http://www.minimalsites.com&quot;&#xA;&#xA;OK&#xA;&#xA;-----8-----&#xA;AT+HTTPACTION=0&#xA;&#xA;OK&#xA;&#xA;-----9-----&#xA;AT+HTTPREAD&#xA;&#xA;OK&#xA;&#xA;-----10-----&#xA;AT+HTTPTERM&#xA;&#xA;ERROR&#xA;&#xA;+HTTPACTION:0,200,1240&#xA;&#xA;-----10.0-----&#xA;AT+SAPBR=0,1&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The step 9 AT+HTTPREAD I supposed to see some html from &lt;a href=&quot;http://www.minimalsites.com&quot; rel=&quot;nofollow&quot;&gt;http://www.minimalsites.com&lt;/a&gt;. But i dont see anything, What wrong with me?&lt;/p&gt;&#xA;" OwnerUserId="7828" LastActivityDate="2019-02-14T10:04:14.563" Title="SIM900 AT command HTTP GET request not show the web page" Tags="|gsm|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16122" PostTypeId="1" AcceptedAnswerId="16123" CreationDate="2015-09-16T05:54:07.050" Score="0" ViewCount="2982" Body="&lt;p&gt;Could someone help me how to output the numbers from 1 to 10 via Serial, without having to write out each command by hand?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my sketch - I need it concise instead of a long sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&#xA;//setup&#xA;void setup() {&#xA; Serial. begin(9600);//The faster the better&#xA;}//Close the sertup&#xA;&#xA;//main loop &#xA;void loop() { &#xA;&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(1) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial&amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(2) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(3) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(4) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(5) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(6) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(7) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(8) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(9) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(10) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(11) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(12) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(13) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(14) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(15) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(16) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(17) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(18) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(19) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(20) &amp;lt;&amp;lt; endl;&#xA;   delay(1000);&#xA;  while(1){}//freeze the main loop&#xA;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13265" LastEditorUserId="10003" LastEditDate="2015-09-22T12:06:41.743" LastActivityDate="2020-03-06T17:09:36.790" Title="How I can print several numbers via Serial with very few lines of code?" Tags="|arduino-uno|serial|c++|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16123" PostTypeId="2" ParentId="16122" CreationDate="2015-09-16T06:11:53.363" Score="3" Body="&lt;p&gt;&lt;em&gt;[This replaces my earlier answer, and addresses information added to the question.]&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You apparently want a sketch that outputs 1, 2, 3 ... 100 to serial output, where each number string is embedded within a control sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are two ways.  The first program outputs the sequence once, using ordinary Arduino &lt;code&gt;Serial.write()&lt;/code&gt;, &lt;code&gt;Serial.print()&lt;/code&gt; and &lt;code&gt;Serial.println()&lt;/code&gt; statements:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program 1.  Output 1, 2, 3 ... 100 once&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  for (int j=1; j&amp;lt;=100; ++j) {&#xA;    Serial.write(27); // Send escape character&#xA;    Serial.print(&quot;[2J&quot;); // Send erase-screen command&#xA;    Serial.print(&quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot;);&#xA;    Serial.println(j); // Send j in decimal format&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other program will output the sequence repeatedly.  It uses the &lt;code&gt;Streaming.h&lt;/code&gt; library, but in a  rational manner; for example, instead of quoting every character separately like the program in the photo, it quotes character sequences in strings.  Note, Esc [2J is an &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes&quot; rel=&quot;nofollow&quot;&gt;ANSI escape code sequence&lt;/a&gt; that erases the screen it is directed to, if the screen device is ANSI compliant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program 2.  Output 1, 2, 3 ... 100 repeatedly&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt; // or &quot;Streaming.h&quot; if appropriate&#xA;byte j=0;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;  ++j;&#xA;  // Send Esc [2J which will erase screen&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; &quot;[2J&quot;;&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; j;&#xA;  if (j &amp;gt;= 100) j=0;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-09-18T01:00:01.287" LastActivityDate="2015-09-18T01:00:01.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16124" PostTypeId="2" ParentId="16122" CreationDate="2015-09-16T06:27:32.817" Score="3" Body="&#xA;&#xA;&lt;p&gt;Ah, a challenge!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have to write from 1 to 100, and I don't want to repeat it all 100 times&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your question did not make that clear. Anyway:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main () { &#xA;  Serial.begin (9600); &#xA;  for (int i = 1; i &amp;lt;= 100; i++) &#xA;    Serial.println (i); &#xA;  while (true); &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can probably make it shorter at the expense of readability. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main(){Serial.begin(9600);for(int i=1;i&amp;lt;=100;i++)Serial.println(i);while(1);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-16T06:27:32.817" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16125" PostTypeId="2" ParentId="4667" CreationDate="2015-09-16T07:30:14.077" Score="2" Body="&lt;p&gt;The DHT11 sensor is available as-is and integrated on a break-out board. The break-out board shows following differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the order of PINs is changed, e.g. in one version: 1 -&gt; signal, 2 -&gt; &lt;code&gt;+&lt;/code&gt;, 3 -&gt; GND (left-to-right, pins down, looking at the front)&lt;/li&gt;&#xA;&lt;li&gt;the unused pin is not connected&lt;/li&gt;&#xA;&lt;li&gt;the board already has a 10 KOhm pull-up resistor connected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus, when you have a DHT11 on a break-out board you have to adjust schematics that use it as-is - e.g. in this &lt;a href=&quot;https://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt; you have to remove the external pull-up resistor and connect the pins in the correct order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware that there may be different versions of DHT11 breakout boards available - i.e. ones where the order of pins is different. You can look out for PIN markings like &lt;code&gt;S&lt;/code&gt; (-&gt; signal) and &lt;code&gt;-&lt;/code&gt; (-&gt; GND). Also, you can look at both sides of the breakout board to trace the connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistor usually comes as SMD on such a board - and if it has a marking it uses a special code. For example, &lt;code&gt;103&lt;/code&gt; means &lt;code&gt;10 * 10^3&lt;/code&gt; Ohm, i.e. 10 KOhm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;adafruit DHT library&lt;/a&gt; comes with an example sketch that prints the sensor values over serial.&lt;/p&gt;&#xA;" OwnerUserId="13174" LastActivityDate="2015-09-16T07:30:14.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16126" PostTypeId="2" ParentId="16096" CreationDate="2015-09-16T07:41:39.143" Score="1" Body="&lt;p&gt;The way I'd do it is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use an optical encoder with an &lt;a href=&quot;http://img.diytrade.com/smimg/1033354/32796591-447715-0/Optical_Endstop_for_3D_printer_use_together_with_RAMPS_1_4_controller/ed5e.jpg&quot; rel=&quot;nofollow&quot;&gt;endstop&lt;/a&gt;, they come @ 1€ on ebay, bought 4 today :-) - this will tell you the angular speed and incremental position&lt;/li&gt;&#xA;&lt;li&gt;use a photo transistor to detect a specific point on the wheel (make a small hole or paint a spot in a different colour) - this will give you &#xA;the absolute position of the wheel, to calibrate the previous step.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;With this solution you do not even need a step motor, a DC motor will do it and probably has better characteristics, for the same cost.&#xA;So you could explore the DC option if it turns out that the stepper is not good enough.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-16T07:41:39.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16127" PostTypeId="2" ParentId="16119" CreationDate="2015-09-16T08:52:08.793" Score="0" Body="&lt;p&gt;Many comparators come with open collector output. OC output means, it can pull down a potential, but cannot generate a voltage higher than ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a high impedance input like your Arduino has, and you connect a OC output to it, nothing will happen unless you add a pullup resistor providing a positive voltage. Otherwise there won't be a closed electric circuit where any measurable voltages can be generatet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lucky you: Arduino input pins can generate a positive voltage by providing an internal pullup resistor. Read the documentation on input pins and pin direction to make use of this. This way you can connect an open collector output to your input pin without additional components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But beware: This doesn't work with a comparator with a pullup output (I guess these are rather rare). In this case you have to provide an additional pulldown resistor to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Caveat: You can use a comparator with totem pole or tristate output without pullup or down as long as its output swing does not exceed maximum allowable voltages of the input pin. I.e. you cannot connect a comparator supplied with 15 V and a totem pole output to the input of an arduino, because the high level will exceed 5 volts (I assume an Arduino Uno).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now. How to learn from a datasheet, if the output is pulldown, pullup, totempole or tristate? &#xA;If a device features a pulldown stage, you will find a value for something called &quot;Output Sink Current&quot; in the section &quot;electrical characteristics&quot;. For a pulldown stage this will likely be named &quot;Output source current&quot;. A tristate output will be denominated somewhere in the datasheet for sure, because this is an extra feature. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at lm339!&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-09-16T08:52:08.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16128" PostTypeId="1" CreationDate="2015-09-16T09:00:24.943" Score="1" ViewCount="130" Body="&lt;p&gt;I have a &lt;code&gt;String content=&quot;&quot;&lt;/code&gt; and if I put an HTTP request like this:         &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;GET /api/actions?parking_id=39 HTTP/1.1&quot;);&#xA;client.println(&quot;Host: ramp-rampcontrol.rhcloud.com&quot;);&#xA;client.println(&quot;Connection: close&quot;);&#xA;client.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the output I get is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; [{&quot;action_id&quot;:35,&quot;action_type&quot;:&quot;up&quot;,&quot;parking_id&quot;:39,&quot;user_id&quot;:17,&quot;ramp&quot;:&quot;exit&quot;,&quot;created_at&quot;:&quot;2015-07-10 18:02:40&quot;,&quot;updated_at&quot;:&quot;2015-07-10 18:02:40&quot;},{&quot;action_id&quot;:41,&quot;action_type&quot;:&quot;up&quot;,&quot;parking_id&quot;:39,&quot;user_id&quot;:17,&quot;ramp&quot;:&quot;entry&quot;,&quot;created_at&quot;:&quot;2015-08-16 20:50:14&quot;,&quot;updated_at&quot;:&quot;2015-08-16 20:50:14&quot;},{&quot;action_id&quot;:42,&quot;action_type&quot;:&quot;down&quot;,&quot;parking_id&quot;:39,&quot;user_id&quot;:17,&quot;ramp&quot;:&quot;entry&quot;,&quot;created_at&quot;:&quot;2015-08-16 20:50:21&quot;,&quot;updated_at&quot;:&quot;2015-08-16 20:50:21&quot;},{&quot;action_id&quot;:43,&quot;action_type&quot;:&quot;down&quot;,&quot;parking_id&quot;:39,&quot;user_id&quot;:17,&quot;ramp&quot;:&quot;exit&quot;,&quot;created_at&quot;:&quot;2015-08-16 20:50:22&quot;,&quot;updated_at&quot;:&quot;2015-08-16 20:50:22&quot;}]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The little parser I created is this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(client.available()) {&#xA; char c = client.read();   &#xA;    if(c == '{'){&#xA;      begin1 = true;&#xA;    }&#xA;&#xA;  if (begin1) { &#xA;    content += c;&#xA;   }&#xA;&#xA;  if (c == '}') {&#xA;      break; &#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to store only the first action in JSON output, because the actions are updated, and if the number of chars extends 256 than I get errors while working with the &lt;code&gt;String content&lt;/code&gt;? &lt;/p&gt;&#xA;" OwnerUserId="10439" LastActivityDate="2015-09-17T11:29:12.353" Title="GET the first result in HTTP request" Tags="|arduino-uno|c++|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16129" PostTypeId="2" ParentId="16128" CreationDate="2015-09-16T11:15:37.620" Score="-1" Body="&lt;p&gt;Your question is not clear to me. First of all does your parser get the whole response? And second by first action do you mean &quot;action_id&quot;:35&quot;?&#xA;If both are true then your solution is simple. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you separate every comma &quot;, &quot; and put in a string array then you further split each index by &quot;:&quot; so the first part is the name &quot;action_id&quot; and the second is the value &quot;35&quot;. I hope that helps . You can look up the split function, it's easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if the above is not what you needed then I am afraid you &lt;em&gt;cannot&lt;/em&gt; get only the first response, because that has to do with the server itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a solution, do try it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found an &lt;a href=&quot;https://github.com/bblanchon/ArduinoJson&quot; rel=&quot;nofollow&quot;&gt;easier solution&lt;/a&gt;. Follow the example and replace the content and fields with your response content and you will be done in minutes.&lt;/p&gt;&#xA;" OwnerUserId="13422" LastEditorUserId="6936" LastEditDate="2015-09-17T11:29:12.353" LastActivityDate="2015-09-17T11:29:12.353" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16130" PostTypeId="2" ParentId="16096" CreationDate="2015-09-16T11:20:36.417" Score="0" Body="&lt;p&gt;As for Me the Best Way to To Use a Position Servo with the Feedback in it ( it comes with 6 wire ) then You put all Your Positions For the prizes in An Array and if Anytime You Land on An Index then You Should but it in an Array that Holds all the prizes angle visited Which you will use as a check Before Turning the Servo&lt;/p&gt;&#xA;" OwnerUserId="13422" LastActivityDate="2015-09-16T11:20:36.417" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16131" PostTypeId="2" ParentId="16121" CreationDate="2015-09-16T11:25:07.890" Score="0" Body="&lt;p&gt;Check Your Connection Try Pinging the IP of Your Arduino and INstead of Using the AT commands use this library its easier and Nice &lt;a href=&quot;https://github.com/amcewen/HttpClient&quot; rel=&quot;nofollow&quot;&gt;https://github.com/amcewen/HttpClient&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13422" LastActivityDate="2015-09-16T11:25:07.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16132" PostTypeId="2" ParentId="16109" CreationDate="2015-09-16T13:45:54.080" Score="0" Body="&lt;p&gt;There are &lt;a href=&quot;https://www.adafruit.com/products/1588&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bluetooth boards&lt;/a&gt; and chips that you can connect to a Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can play sounds with a Nano. Crudely with PWM and a direct connection, for finely with an external digital-to-analog converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if super-smallness is what you are after, there may be better options. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.makershed.com/products/lightblue-bean-bluetooth-4-0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blue Bean&lt;/a&gt; is a complete  BLE microcontroller on a single board that is smaller than a Nano+board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want even smaller, you could get something like the new Cypress EZ-BLE module...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mlfYc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mlfYc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://www.cypress.com/products/ez-ble-module-bluetooth-smart&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.cypress.com/products/ez-ble-module-bluetooth-smart&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a complete programmable BLE system on a tiny module. It is hard to imagine anything smaller than that!&lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="7859" LastEditDate="2015-09-17T01:42:26.250" LastActivityDate="2015-09-17T01:42:26.250" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16133" PostTypeId="1" AcceptedAnswerId="16134" CreationDate="2015-09-16T05:37:27.083" Score="3" ViewCount="200" Body="&lt;p&gt;I'm new to Arduino so this may be a really silly doubt but I'm not finding an explanation for it anywhere online. I first uploaded this code (to blink 5 LEDs) on my Arduino Uno :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup(){&#xA; pinMode(12, OUTPUT);&#xA; pinMode(11, OUTPUT);&#xA; pinMode(10, OUTPUT);&#xA; pinMode(9, OUTPUT);&#xA; pinMode(8, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;digitalWrite(12, HIGH);&#xA;delay(1000);&#xA;digitalWrite(12, LOW);&#xA;delay(1000);&#xA;digitalWrite(11, HIGH);&#xA;delay(1000);&#xA;digitalWrite(11, LOW);&#xA;delay(1000);&#xA;digitalWrite(10, HIGH);&#xA;delay(1000);&#xA;digitalWrite(10, LOW);&#xA;delay(1000);&#xA;digitalWrite(9, HIGH);&#xA;delay(1000);&#xA;digitalWrite(9, LOW);&#xA;delay(1000);&#xA;digitalWrite(8, HIGH);&#xA;delay(1000);&#xA;digitalWrite(8, LOW);&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 5 LEDs glowed brightly. But when I uploaded the following code (using an if statement to reduce the size of the previous one), the LEDs glowed dimly. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LEDpin = 13;&#xA;void setup(){&#xA;pinMode(LEDpin, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;digitalWrite(LEDpin, HIGH);&#xA;delay(1000);&#xA;digitalWrite(LEDpin,LOW);&#xA;delay(1000);&#xA;if(LEDpin &amp;gt;= 8){&#xA;LEDpin--;&#xA;} else {&#xA;  LEDpin = 8;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, when I just typed the &lt;code&gt;if&lt;/code&gt; statement without the &lt;code&gt;else&lt;/code&gt; part, nothing happened after the LED at pin 8 had glowed on and off. Can someone please tell me why the LEDs glowed dimly in the second one and why nothing glowed after LED 8 when I skipped the &lt;code&gt;else&lt;/code&gt; part?&lt;/p&gt;&#xA;" OwnerUserId="16192" OwnerDisplayName="ayerhs7" LastEditorUserId="37523" LastEditDate="2018-07-26T22:19:03.577" LastActivityDate="2018-07-26T22:19:03.577" Title="Unexpected behaviour of blinking LED code" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16134" PostTypeId="2" ParentId="16133" CreationDate="2015-09-16T05:45:11.117" Score="0" Body="&lt;p&gt;The problem with your code is that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;you have not initialised all the LED pins as output&lt;/strong&gt;. Only pin 13 is initialised as output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, initialise all the pins to output. A correct code would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LEDpin = 13;&#xA;void setup(){&#xA;pinMode(8, OUTPUT);&#xA;pinMode(9, OUTPUT);&#xA;pinMode(10, OUTPUT);&#xA;pinMode(11, OUTPUT);&#xA;pinMode(12, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;digitalWrite(LEDpin, HIGH);&#xA;delay(1000);&#xA;digitalWrite(LEDpin,LOW);&#xA;delay(1000);&#xA;if(LEDpin &amp;gt;= 8){&#xA;LEDpin--;&#xA;} else {&#xA;  LEDpin = 12;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13455" OwnerDisplayName="Abhishek Jain" LastActivityDate="2015-09-16T13:45:33.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16135" PostTypeId="2" ParentId="16133" CreationDate="2015-09-16T06:30:52.217" Score="1" Body="&lt;p&gt;As Abhishek Jain explained, the pin's need to be initialised for OUTPUT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there is another error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in &lt;code&gt;loop()&lt;/code&gt; counts down to 8, once, flashing the LEDs, &lt;strong&gt;but&lt;/strong&gt; then only lights an LED on pin 8 because it always goes through the &lt;code&gt;else&lt;/code&gt; which maintains LEDpin's value as 8. LEDpin needs to be reset to 12, after it passes 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better code might be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LEDpin = 12;&#xA;void setup(){&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  digitalWrite(LEDpin, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(LEDpin,LOW);&#xA;  delay(1000);&#xA;  if(LEDpin &amp;gt;= 8){&#xA;    LEDpin--;&#xA;  } else {&#xA;    LEDpin = 12;   // &amp;lt;---- start with the first LED again&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For what its worth, I wouldn't do the code this way. I would write something using for loops, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int firstLED = 8;&#xA;const int lastLED = 12;&#xA;int LEDpin;&#xA;&#xA;void setup() {&#xA;  for (LEDpin = firstLED; LEDpin &amp;lt;= lastLED; ++LEDpin) {&#xA;     pinMode(LEDpin, OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  for (LEDpin = firstLED; LEDpin &amp;lt;= lastLED; ++LEDpin) {&#xA;    digitalWrite(LEDpin, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(LEDpin,LOW);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastEditorUserId="3493" LastEditDate="2015-09-17T16:31:31.753" LastActivityDate="2015-09-17T16:31:31.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16136" PostTypeId="2" ParentId="16133" CreationDate="2015-09-16T06:36:22.663" Score="5" Body="&lt;p&gt;As Abhishek mentioned in his answer is correct, but the better way is to use for loops while dealing with many led's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say you have led's connected from pin 2 to 8.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 2;&#xA;void setup() &#xA;{&#xA;   for (Pin = 2; Pin &amp;lt; 8; Pin++) &#xA;   {&#xA;     pinMode(Pin, OUTPUT);&#xA;   } &#xA;}&#xA;void loop() &#xA;{&#xA;   for (int Pin = 2; Pin &amp;lt; 8; Pin++) &#xA;   {&#xA;     digitalWrite(Pin, HIGH);&#xA;     delay(1000);&#xA;     digitalWrite(Pin, LOW);&#xA;     delay(1000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13197" OwnerDisplayName="CZAbhinav" LastActivityDate="2015-09-16T06:36:22.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16138" PostTypeId="2" ParentId="4347" CreationDate="2015-09-16T17:40:02.543" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow&quot;&gt;Cosa&lt;/a&gt; supports a large number of mechanisms for multi-tasking. The latest addition is an abstract class for &lt;a href=&quot;https://dl.dropboxusercontent.com/u/993383/Cosa/doc/html/da/d10/classJob.html&quot; rel=&quot;nofollow&quot;&gt;Jobs&lt;/a&gt; (delayed or periodic functions) and Job Schedulers. This abstraction allows functions to be scheduled on micro-, milli- and seconds level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get started please see the Cosa example sketches. If you have an Logic Analyzer (Salea Logic for instance) there are a number of example sketches that show pulse generation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a binding of the Job Scheduler to a seconds tick level. This is abstracted to Clock and Alarms. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For higher abstraction of multi-tasking Cosa also implements FSM, Proto-threads, Threads (multi-stacks), UML Capsules, and more.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="6936" LastEditDate="2015-09-17T11:28:59.670" LastActivityDate="2015-09-17T11:28:59.670" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16139" PostTypeId="1" AcceptedAnswerId="16142" CreationDate="2015-09-16T19:34:11.043" Score="1" ViewCount="2199" Body="&lt;p&gt;In the following code from an Arduino sketch will it run the first &quot;for&quot; statement before enacting the second &quot;for&quot; statement. Also how does it know go run the first stamens again? Will it continue to run till both statements are true? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int r = 0; r &amp;lt; 8; r++){&#xA;    for(int c = 0; c &amp;lt; 8; c++){&#xA;        lc.setLed(0, r, c, HIGH);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7061" LastEditorUserId="337" LastEditDate="2015-09-17T00:04:26.620" LastActivityDate="2015-09-17T00:04:26.620" Title="How do nested for loops work?" Tags="|programming|c++|sketch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16140" PostTypeId="2" ParentId="4347" CreationDate="2015-09-16T20:49:38.817" Score="1" Body="&#xA;&#xA;&lt;p&gt;Here's an example of blinking two LEDs independently:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Which pins are connected to which LED&#xA;const byte greenLED = 12;&#xA;const byte redLED = 13;&#xA;&#xA;// Time periods of blinks in milliseconds (1000 to a second).&#xA;const unsigned long greenLEDinterval = 500;&#xA;const unsigned long redLEDinterval = 1000;&#xA;&#xA;// Variable holding the timer value so far. One for each &quot;Timer&quot;&#xA;unsigned long greenLEDtimer;&#xA;unsigned long redLEDtimer;&#xA;&#xA;void setup () &#xA;  {&#xA;  pinMode (greenLED, OUTPUT);&#xA;  pinMode (redLED, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void toggleLED (const byte which, unsigned long &amp;amp; whenToggled)&#xA;  {&#xA;   if (digitalRead (which) == LOW)&#xA;      digitalWrite (which, HIGH);&#xA;   else&#xA;      digitalWrite (which, LOW);&#xA;  // remember when we toggled it&#xA;  whenToggled = millis ();  &#xA;  }  // end of toggleLED&#xA;&#xA;void loop ()&#xA;  {&#xA;  // Handling the blink of one LED.&#xA;  if ( (millis () - greenLEDtimer) &amp;gt;= greenLEDinterval)&#xA;     toggleLED (greenLED, greenLEDtimer);&#xA;&#xA;  // The other LED is controlled the same way. Repeat for more LEDs&#xA;  if ( (millis () - redLEDtimer) &amp;gt;= redLEDinterval) &#xA;    toggleLED (redLED, redLEDtimer);&#xA;&#xA;/* Other code that needs to execute goes here.&#xA;   It will be called many thousand times per second because the above code&#xA;   does not wait for the LED blink interval to finish. */&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that instead of copying and pasting the blinking code, I made a generic function. That way any bugs are easily fixed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more LEDs you could use an array:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_LEDS = 5;&#xA;// Which pins are connected to which LED&#xA;const byte LED_PINS [NUMBER_OF_LEDS] = { 8, 9, 10, 11, 12 };&#xA;// Time periods of blinks in milliseconds (1000 to a second).&#xA;const unsigned long LED_INTERVALS [NUMBER_OF_LEDS] = { 200, 400, 100, 1000, 2000};&#xA;// Variable holding the timer value so far. One for each &quot;Timer&quot;&#xA;unsigned long timeLEDtoggled [NUMBER_OF_LEDS];&#xA;&#xA;void setup () &#xA;  {&#xA;  for (int i = 0; i &amp;lt; NUMBER_OF_LEDS; i++)&#xA;    pinMode (LED_PINS [i], OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void toggleLED (const byte which, unsigned long &amp;amp; whenToggled)&#xA;  {&#xA;   if (digitalRead (which) == LOW)&#xA;      digitalWrite (which, HIGH);&#xA;   else&#xA;      digitalWrite (which, LOW);&#xA;  // remember when we toggled it&#xA;  whenToggled = millis ();  &#xA;  }  // end of toggleLED&#xA;&#xA;void loop ()&#xA;  {&#xA;  // see if it is time to toggle the LEDs    &#xA;  for (int i = 0; i &amp;lt; NUMBER_OF_LEDS; i++)&#xA;    if ( (millis () - timeLEDtoggled [i]) &amp;gt;= LED_INTERVALS [i])&#xA;       toggleLED (LED_PINS [i], timeLEDtoggled [i]);&#xA;&#xA;  /* Other code that needs to execute goes here. */&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If anything, the above code is simpler, but it blinks 5 LEDs at different rates. Now you can have more sophisticated tests than that, but the general concept is the same.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;How to do multiple things at once ... like cook bacon and eggs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;State machines&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-16T20:49:38.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16141" PostTypeId="2" ParentId="16139" CreationDate="2015-09-16T21:31:28.107" Score="2" Body="&lt;p&gt;What you have there is a nested loop. The first &lt;code&gt;for&lt;/code&gt; statement runs 8 times, incrementing &lt;code&gt;r&lt;/code&gt; from 0 to 7. For &lt;em&gt;each&lt;/em&gt; of those 8 iterations the second &lt;code&gt;for&lt;/code&gt; statement runs, incrementing &lt;code&gt;c&lt;/code&gt; from 0 to 7. Thus the &lt;code&gt;setLed&lt;/code&gt; statement is executed 64 times.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Will it continue to run till both statements are true? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. Unless you have a &lt;code&gt;break&lt;/code&gt; or &lt;code&gt;return&lt;/code&gt; statement somewhere in the part of the code you haven't shown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strictly-speaking, a &lt;em&gt;statement&lt;/em&gt; does not become true. They will run while the test inside the &lt;code&gt;for&lt;/code&gt; remains true (both tests).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is standard C++ or C programming. You may wish to consult a C tutorial if you find this sort of thing puzzling.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="368" LastEditDate="2015-09-16T22:37:07.987" LastActivityDate="2015-09-16T22:37:07.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16142" PostTypeId="2" ParentId="16139" CreationDate="2015-09-17T00:02:57.063" Score="3" Body="&lt;p&gt;A &lt;code&gt;for&lt;/code&gt; statement repeats everything between &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;, (or just the next line if there is no &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; a certain number of times.  It's not as simple as you might at first think, but it makes more sense if you write it out as a &lt;code&gt;while&lt;/code&gt; loop explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;code&gt;for (a; b; c) { ... }&lt;/code&gt; could be re-written as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a;&#xA;while (b) {&#xA;    c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you had: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 100; i++) { &#xA;    Serial.println(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it could be re-written as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i = 0;&#xA;while (i &amp;lt; 100) {&#xA;    Serial.println(i);&#xA;    i++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The two mean exactly the same thing.  A &lt;code&gt;for&lt;/code&gt; has the three elements - initializer, comparison and iterator.  The initializer is run before the loop starts, the comparison is used to work out when the loop should finish, and the iterator is used to move through each iteration of the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To re-write your specific example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int r = 0; r &amp;lt; 8; r++){&#xA;    for(int c = 0; c &amp;lt; 8; c++){&#xA;        lc.setLed(0, r, c, HIGH);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int r = 0;&#xA;while (r &amp;lt; 8) {&#xA;    int c = 0;&#xA;    while (c &amp;lt; 8) {&#xA;        lc.setLed(0, r, c, HIGH);&#xA;        c++;&#xA;    }&#xA;    r++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if we were to do away with the loops altogether and write it all out longhand, what would it look like?  Well, let's start with the inner &lt;code&gt;c&lt;/code&gt; loop.  That loops from 0 to 7 (while less than 8), so replacing that loop with 8 discrete calls to the function replacing &lt;code&gt;c&lt;/code&gt; each time would end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int r = 0;&#xA;while (r &amp;lt; 8) {&#xA;    lc.setLed(0, r, 0, HIGH);&#xA;    lc.setLed(0, r, 1, HIGH);&#xA;    lc.setLed(0, r, 2, HIGH);&#xA;    lc.setLed(0, r, 3, HIGH);&#xA;    lc.setLed(0, r, 4, HIGH);&#xA;    lc.setLed(0, r, 5, HIGH);&#xA;    lc.setLed(0, r, 6, HIGH);&#xA;    lc.setLed(0, r, 7, HIGH);&#xA;    r++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We could take it a step further and &lt;em&gt;unroll&lt;/em&gt; the outer &lt;code&gt;r&lt;/code&gt; loop.  A subset of what you would end up with would be like this (note, I have skipped a lot of the middle ones):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lc.setLed(0, 0, 0, HIGH);&#xA;lc.setLed(0, 0, 1, HIGH);&#xA;lc.setLed(0, 0, 2, HIGH);&#xA;lc.setLed(0, 0, 3, HIGH);&#xA;lc.setLed(0, 0, 4, HIGH);&#xA;lc.setLed(0, 0, 5, HIGH);&#xA;lc.setLed(0, 0, 6, HIGH);&#xA;lc.setLed(0, 0, 7, HIGH);&#xA;lc.setLed(0, 1, 0, HIGH);&#xA;lc.setLed(0, 1, 1, HIGH);&#xA;... skipped a lot ...&#xA;lc.setLed(0, 6, 6, HIGH);&#xA;lc.setLed(0, 6, 7, HIGH);&#xA;lc.setLed(0, 7, 0, HIGH);&#xA;lc.setLed(0, 7, 1, HIGH);&#xA;lc.setLed(0, 7, 2, HIGH);&#xA;lc.setLed(0, 7, 3, HIGH);&#xA;lc.setLed(0, 7, 4, HIGH);&#xA;lc.setLed(0, 7, 5, HIGH);&#xA;lc.setLed(0, 7, 6, HIGH);&#xA;lc.setLed(0, 7, 7, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There would, of course, be 8 × 8 = 64 entries in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;for&lt;/code&gt; loops can be used in lots of other fun ways too.  It's not just a simple &quot;run this X number of times&quot;.  For instance, you can loop through a C string until you reach the NULL character at the end of the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (char *p = str; *p != 0; p++) {&#xA;    ... do something with *p&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can iterate through the entries in a linked list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (struct mylist *scan = myListHead; scan; scan = scan-&amp;gt;next) {&#xA;    ... do something to scan-&amp;gt;whatever ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can even embed functions in there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (char c = 0; c != '\n'; c = Serial.read()) {&#xA;    ... Do something with character `c` until `c` is a line feed ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see &lt;code&gt;for&lt;/code&gt; is an incredibly powerful and flexible tool that is often overlooked in favour of the more explicit &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-17T00:02:57.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16143" PostTypeId="1" AcceptedAnswerId="16144" CreationDate="2015-09-17T00:11:13.363" Score="0" ViewCount="202" Body="&lt;p&gt;Is possible the communication between several Arduinos to one serial port in the PC ?&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;If I have ARD_A, ARD_B,... ARD_Z running with some code like this&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    while (Serial.available() &amp;gt; 0)&#xA;    {&#xA;       String stringID = Serial.read()&#xA;       int nFound = stringID.indexOf(&quot;@ARD_01&quot;); &#xA;                    // ---&amp;gt; Id is unique for each arduino&#xA;       if ( nFound &amp;gt; 0 )&#xA;          Serial.print(&quot;this is @ARD_01 responding sending some data&quot;);&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the pc there is an exe sending a string:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;&quot;@ARD_01 I want your data&quot; &#xA;   process the data&#xA;&quot;@ARD_02 I want your data&quot; &#xA;   process the data&#xA;&quot;@ARD_03 I want your data&quot; &#xA;   process the data&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13435" LastEditorUserId="10794" LastEditDate="2015-09-17T05:19:07.537" LastActivityDate="2015-09-17T05:19:07.537" Title="serial communication between several arduinos to pc" Tags="|serial|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16144" PostTypeId="2" ParentId="16143" CreationDate="2015-09-17T00:16:57.620" Score="2" Body="&lt;p&gt;Not directly, no.  A PC's serial port - either a &quot;real&quot; one or a USB one, can only communicate with one device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino, though, is a USB device, so you can just plug them all into a USB hub or a bunch of hubs - each one will get its own COM port.  Managing all those COM ports can be kind of tricky though, especially when you have a lot of devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, one that is more widely used when you want to communicate with a lot of &lt;em&gt;slave&lt;/em&gt; devices from one &lt;em&gt;master&lt;/em&gt; device is to use a &lt;em&gt;multidrop&lt;/em&gt; network.  RS-485 is the most popular of these.  It allows you to connect many slave devices to one set of serial wires and the master sends instructions to a slave, and the slave may respond with data and information on request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS-485 requires special hardware to interface normal TTL level RS-232 (UART) ports to the bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more about RS-485 here: &lt;a href=&quot;https://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/RS-485&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-17T00:16:57.620" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16145" PostTypeId="1" AcceptedAnswerId="16148" CreationDate="2015-09-17T05:08:47.530" Score="1" ViewCount="1964" Body="&lt;p&gt;Is it possible to have the NRF24 module on an Arduino Mini transmitting to an NRF24 with SMA antenna on a Mega?  In that case, would the antenna on the Mega help pickup the signal of the transmitting Arduino Mini?&lt;/p&gt;&#xA;" OwnerUserId="11089" LastEditorUserId="7090" LastEditDate="2015-09-17T20:42:16.433" LastActivityDate="2015-09-17T20:42:16.433" Title="NRF24 Mixing with/without antenna" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16146" PostTypeId="1" CreationDate="2015-09-17T06:57:43.813" Score="1" ViewCount="2406" Body="&lt;p&gt;I've written a script in Python which sends data through the PC's Bluetooth to HC-06 on Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;state&lt;/code&gt; is an integer from 0 to 1000 (it is controlled through the potentiometer).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;...&#xA;gaugeSocket.send(str(state))&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't get the right character-to-integer conversion on Arduino (from HC-06 serial).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;char buf[2];&#xA;int i=0;&#xA;int data;&#xA;int ledPin = 9;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.begin(57600);&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (mySerial.available()) {&#xA;    for(;i&amp;lt;2;){&#xA;      buf = mySerial.read();&#xA;      i++;&#xA;    }&#xA;    i = 0;&#xA;    Serial.print(buf);&#xA;    data = atoi(buf);&#xA;  }&#xA;    analogWrite(ledPin, data/10); //To see how code behaves on LED&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial print gives me this (if I turn potentiometer from 0 to 1000):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0ÿ(0ÿ(0ÿ(0ÿ(0ÿ(0ÿ(0ÿ(60(1ÿ(00(16(0ÿ(23(0ÿ(30(0ÿ(3ÿ(60(43(0ÿ(49(0ÿ(53(0ÿ(5ÿ(90(69(0ÿ(88(0ÿ(10(00(10(00(10(&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What am I missing? Is it because I'm sending it as a string? Or is my buffer not the correct size?&lt;/p&gt;&#xA;" OwnerUserId="13436" LastEditorUserId="510" LastEditDate="2018-03-11T16:59:19.430" LastActivityDate="2018-03-11T16:59:19.430" Title="HC-06 data receiving" Tags="|serial|c++|bluetooth|softwareserial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16147" PostTypeId="2" ParentId="16146" CreationDate="2015-09-17T08:27:47.377" Score="0" Body="&lt;p&gt;Use &lt;code&gt;itoa&lt;/code&gt; instead of &lt;code&gt;str&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;str&lt;/code&gt; just converts the byte to an ASCII character. So &lt;code&gt;48&lt;/code&gt; will become &lt;code&gt;'0'&lt;/code&gt;, &lt;code&gt;195&lt;/code&gt; will become &lt;code&gt;'ÿ'&lt;/code&gt;, and &lt;code&gt;191&lt;/code&gt; will become &lt;code&gt;'('&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="510" LastEditDate="2018-03-11T16:26:35.283" LastActivityDate="2018-03-11T16:26:35.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16148" PostTypeId="2" ParentId="16145" CreationDate="2015-09-17T09:48:16.643" Score="3" Body="&lt;p&gt;Yes, and yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A module without an antenna is exactly the same as a module with an antenna, it's just that the antenna is part of the PCB. Yes, the module with the antenna will have more sensitivity (able to receive fainter signals) as well as more transmitting power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same is true of the modules with the power amplifier.  They again have even more sensitivity and transmitting power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is quite common to have a single powerful transceiver with power amplifier and antenna as a base station and then smaller modules as the remote slave devices.  Especially if you couple the base station with a suitable parabolic or uni-directional high gain antenna to point directly at where the slave devices are.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-17T09:48:16.643" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16149" PostTypeId="2" ParentId="16146" CreationDate="2015-09-17T09:50:42.750" Score="1" Body="&lt;p&gt;Here is your main problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (mySerial.available()) {&#xA;    for(;i &amp;lt; 2;){&#xA;        buf = mySerial.read();&#xA;        i++;&#xA;    }&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There you are saying &quot;If there is at least one character available in the buffer then read lots of characters from the buffer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You can't read characters that aren't there yet.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your stream of data is interspersed with the integer &lt;code&gt;-1&lt;/code&gt; which means &quot;I don't have any data to read!&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I explain it all here: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way - character -1 looks like this: ÿ&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are sending your data as text.  That means, to send the value 348 you are first sending the byte representation of the ASCII character &quot;3&quot;, which is the decimal byte value 51.  Then you send the byte representation of the ASCII character &quot;4&quot;, which is the decimal value 52, and finally you send the byte representation of the ASCII character &quot;8&quot;, which is the decimal value 56.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You look to see if there is one byte available (if(mySerial.available())) and then read that byte into &quot;buf&quot; and increment &quot;i&quot; (by the way, &quot;i&quot; is never reset to 0 - your whole loop strategy is completely wrong, but that's a completely different issue).  You then read a second character and assign that to buf instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you have the character &quot;3&quot; in the serial buffer you then place that in &quot;buf&quot;.  You then read whatever is next in the buffer, which 9 times out of 10 will be nothing, so &lt;code&gt;read()&lt;/code&gt; returns -1.  So you just assign that to &quot;buf&quot; instead, replacing the &quot;3&quot; that was in there before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But &quot;buf&quot; is a character array, and you are assigning a character to the whole array, which makes absolutely no sense (does the code even compile as you have shown it?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically your whole reading routine is completely wrong and can never work no matter how much tweaking and advising we do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link I provided above describes not only how you should do the reading on the Arduino, but also how you should do the sending from the other end.  It is vitally important that you send something that says &quot;This is the end of the number I am sending&quot; so that the Arduino knows where one number ends and the next starts.  Normally that is done, when sending a textual representation of the number like this, by adding a line feed and/or carriage return at the end of your number.  So instead of sending &quot;348&quot; you send &quot;248\n&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino then checks to see if there is one character available, and then it adds &lt;em&gt;just that one&lt;/em&gt; character to the end of the buffer.  If, and only  if, that character is the &lt;em&gt;delimiting&lt;/em&gt; character then you can take the buffer and translate it into an actual number and reset your buffer to be empty ready to receive the next number.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link above has good example code showing you exactly how to do that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-17T14:28:10.177" LastActivityDate="2015-09-17T14:28:10.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16150" PostTypeId="1" CreationDate="2015-09-17T13:42:49.110" Score="2" ViewCount="3965" Body="&lt;p&gt;The main idea is to create trigger which can be switched on by touching 2 plates on opposite walls. And these should be performed by few peoples holding each other hands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously human body has big resistance so I couldn't just connect these plates to ground and to one of Arduino pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a toy that do almost what I what (&lt;a href=&quot;http://www.stevespanglerscience.com/energy-stick.html&quot; rel=&quot;nofollow&quot;&gt;see it there&lt;/a&gt;). But I haven't found any information about how to create it by myself.&#xA;Do you have any ideas how to create it?&lt;/p&gt;&#xA;" OwnerUserId="13442" LastEditorUserId="10794" LastEditDate="2015-09-17T20:56:36.373" LastActivityDate="2018-04-29T12:20:43.973" Title="Human circuit trigger" Tags="|arduino-uno|wires|system-design|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16151" PostTypeId="2" ParentId="16150" CreationDate="2015-09-17T13:59:59.230" Score="-1" Body="&lt;p&gt;You can do it with an Arduino !&#xA;Use any of the ADC pins &#xA;There will be change in the ADC i/p when there is some resistance b/w the pins !&#xA;Try both &#xA;+ve &gt; (people) &gt; ADC &#xA;-ve &gt; (people) &gt; ADC &#xA;Just do some trials and probably will notice the change in ADC pin outputs .&#xA;If you want to make  it more sensitive &#xA;Add a high resistance to the ADC pin &#xA;if you are giving +ve to touch plates add a resistance from ground to that ADC pin &lt;/p&gt;&#xA;" OwnerUserId="13426" LastActivityDate="2015-09-17T13:59:59.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16152" PostTypeId="2" ParentId="16150" CreationDate="2015-09-17T18:22:48.187" Score="-1" Body="&lt;p&gt;The idea is intriguing, but you are not limited to use electricity.&#xA;You could experiment with some other type of signal. Sound, for example.&#xA;That would be safer.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-17T18:22:48.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16153" PostTypeId="1" AcceptedAnswerId="16155" CreationDate="2015-09-17T18:29:05.103" Score="2" ViewCount="1061" Body="&lt;p&gt;I'm trying to use the watchdog timer to prevent the atmel from being stuck in a loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I have the watchdog timer in System Reset Mode, with a 8sec timer. I reset the timer in every loop while the system is active. But when it goes to sleep, it cannot clear the timer and the whole system resets. Essentially, the system sleeps &gt; System Reset every 8 sec &gt; goes back to sleep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this works, I initialize a lot of other hardware with the atmel, and doing it every 8 second seems like a waste of resources. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use the watchdog interrupt somehow only to wake the system up briefly and stop the full system reset. Only if it's truly stuck, it will do a full system reboot. But i'm not sure how the ISR will work or how to reset the timer or toggle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here a basic rundown of what I was thinking about.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(wdt_timer)&#xA;{&#xA;    how to stop the full system reboot?&#xA;    how to make the interrupt start again?&#xA;}&#xA;ISR(button_press)&#xA;{&#xA;      gotoSleep=0;&#xA;}&#xA;&#xA;void watchdog_init()&#xA;{&#xA;    /* Reset the wdt. */&#xA;  wdt_reset(); //from wdt.h&#xA;&#xA;  /* In order to change WDE or the prescaler, we need to&#xA;   * set WDCE (This will allow updates for 4 clock cycles).&#xA;   */&#xA;  WDTCSR |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE);&#xA;&#xA;  /* set new watchdog timeout prescaler value */&#xA;  WDTCSR = 1&amp;lt;&amp;lt;WDP0 | 1&amp;lt;&amp;lt;WDP3; /* 8.0 seconds */&#xA;&#xA;  /* Enable the WD interrupt (note both interrupt and reset). */&#xA;  WDTCSR |= (1&amp;lt;&amp;lt;WDIE) | (1&amp;lt;&amp;lt;WDE);&#xA;}&#xA;&#xA;void main ()&#xA;{&#xA;    watchdog_init();&#xA;    //and initialize all the other hardware and power supply&#xA;&#xA;    while (true) //no need to step out of this loop&#xA;    {&#xA;        reset_watchdog();&#xA;&#xA;        //&#xA;        //main program&#xA;        //&#xA;&#xA;        if(go_to_sleep=1)  //command received through serial&#xA;        gotoSleep();  &#xA;&#xA;        //wake up here&#xA;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3925" LastEditorUserId="3925" LastEditDate="2015-09-17T20:05:09.130" LastActivityDate="2015-09-17T20:05:09.130" Title="Atmega168 Watchdog timer" Tags="|interrupt|atmega328|timers|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16154" PostTypeId="1" AcceptedAnswerId="16162" CreationDate="2015-09-17T19:03:03.477" Score="0" ViewCount="718" Body="&lt;p&gt;I am trying to integrate two different Arduino Ethernet libraries, EtherShield and UIPEthernet in one sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EtherShield library is used to control LEDs via Android mobile application. While UIPEthernet is used to control the same LEDs via Web Server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both codes run perfectly when they're uploaded individually. But I need them to run in a single sketch. So I combined them in one sketch. That's where my problem is. They're not running smoothly anymore. My mobile app can only turn one LED off then the app will crash. Accessing my Arduino's web server gives me error as well (but before it is really, really working T.T)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help me, please.&#xA;This is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ========== UIPEthernet library&#xA;#include &amp;lt;Dhcp.h&amp;gt;&#xA;#include &amp;lt;Dns.h&amp;gt;&#xA;#include &amp;lt;ethernet_comp.h&amp;gt;&#xA;#include &amp;lt;UIPClient.h&amp;gt;&#xA;#include &amp;lt;UIPEthernet.h&amp;gt;&#xA;#include &amp;lt;UIPServer.h&amp;gt;&#xA;#include &amp;lt;UIPUdp.h&amp;gt;&#xA;&#xA;// ========== EtherShield library&#xA;#include &quot;EtherShield.h&quot;&#xA;#include &quot;ETHER_28J60.h&quot;&#xA;&#xA;// ========== MOBILE&#xA;//static uint8_t mac[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};                                                    &#xA;//static uint8_t ip[4] = {192, 168, 15, 97};                       &#xA;static uint16_t port = 80;                                      &#xA;&#xA;ETHER_28J60 e;&#xA;&#xA;// ========== WEB&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;byte ip[] = { 192, 168, 15, 97 };&#xA;byte gateway[] = { 192, 168, 15, 1 };&#xA;byte subnet[] = { 255, 255, 255, 0 };&#xA;&#xA;String inString = String(35);&#xA;&#xA;int i;  // Used for looping&#xA;String Room;&#xA;&#xA;int pin[] = { 0, 2, 3, 4, 5 }; // Lock pin num 0 in array is not used&#xA;int numOfRooms = 4; // Number of rooms&#xA;String value[] = { &quot;OPEN&quot;, &quot;OPEN&quot;, &quot;OPEN&quot;, &quot;OPEN&quot;, &quot;OPEN&quot; }; // Startup all rooms are closed&#xA;&#xA;EthernetServer server(port);&#xA;String data;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  // ========== MOBILE&#xA;  e.setup(mac, ip, port);&#xA;&#xA;  // ========== WEB  &#xA;  Ethernet.begin(mac, ip, gateway, subnet);&#xA;  server.begin();&#xA;&#xA;  // Set pin mode&#xA;  for (int j = 1; j &amp;lt; (numOfRooms + 1); j++)&#xA;  {&#xA;    pinMode(pin[j], OUTPUT);&#xA;  }&#xA;&#xA;  Serial.println(&quot;\n[ WEB + MOBILE ]\n&quot;);&#xA;  Serial.println(&quot;Serial READY&quot;);&#xA;  Serial.println(&quot;Ethernet READY&quot;);&#xA;  Serial.println(&quot;Server READY\n&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  webModule();&#xA;  mobileAppModule();&#xA;}&#xA;&#xA;void mobileAppModule()&#xA;{&#xA;char* params;&#xA;if (params = e.serviceRequest())&#xA;{&#xA;&#xA;  //ROOM 311&#xA;  if (strcmp(params, &quot;?cmd=1&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[1], HIGH);&#xA;        Serial.println(&quot;ROOM311 is OPEN\n&quot;);&#xA;  }&#xA;  if (strcmp(params, &quot;?cmd=2&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[1], LOW);&#xA;        Serial.println(&quot;ROOM311 is CLOSE\n&quot;);&#xA;  }&#xA;&#xA;  //ROOM 312 &#xA;  if (strcmp(params, &quot;?cmd=3&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[2], HIGH);&#xA;        Serial.println(&quot;ROOM312 is OPEN\n&quot;);&#xA;  }&#xA;  if (strcmp(params, &quot;?cmd=4&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[2], LOW);  &#xA;        Serial.println(&quot;ROOM312 is CLOSE\n&quot;);&#xA;  }&#xA;&#xA;  //ROOM 313 &#xA;  if (strcmp(params, &quot;?cmd=5&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[3], HIGH);&#xA;        Serial.println(&quot;ROOM313 is OPEN\n&quot;);&#xA;  }&#xA;  if (strcmp(params, &quot;?cmd=6&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[3], LOW);&#xA;        Serial.println(&quot;ROOM313 is CLOSE\n&quot;);   &#xA;  }&#xA;&#xA;  //ROOM 314 &#xA;  if (strcmp(params, &quot;?cmd=7&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[4], HIGH);&#xA;        Serial.println(&quot;ROOM314 is OPEN\n&quot;);&#xA;  }&#xA;  if (strcmp(params, &quot;?cmd=8&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[4], LOW);&#xA;        Serial.println(&quot;ROOM314 is CLOSE\n&quot;);   &#xA;  }&#xA;&#xA;  //&#xA;  if (strcmp(params, &quot;?cmd=9&quot;) == 0)&#xA;  {&#xA;        digitalWrite(pin[1], LOW);  &#xA;        digitalWrite(pin[2], LOW);  &#xA;        digitalWrite(pin[3], LOW);  &#xA;        digitalWrite(pin[4], LOW);&#xA;        Serial.println(&quot;All rooms are now CLOSED\n&quot;);   &#xA;  }&#xA;&#xA;&#xA;  e.respond();&#xA;  }&#xA;}&#xA;&#xA;void webModule()&#xA;{&#xA;     EthernetClient client = server.available();&#xA;&#xA; if (client)&#xA; {&#xA; // An HTTP request ends with a blank line&#xA; boolean current_line_is_blank = true;&#xA;&#xA; while (client.connected())&#xA; {&#xA;  if (client.available())&#xA;  {&#xA;    char c = client.read();&#xA;    // If users have gotten to the end of the line (received a newline&#xA;    // character) and the line is blank, the HTTP request has ended,&#xA;    // so users can send a reply&#xA;&#xA;    if (inString.length() &amp;lt; 35)&#xA;    {&#xA;      inString.concat(c);&#xA;    }&#xA;&#xA;    if (c == '\n' &amp;amp;&amp;amp; current_line_is_blank)&#xA;    {&#xA;&#xA;      // Send a standard HTTP response header&#xA;      client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;      client.println(&quot;Content-Type: text/html&quot;);&#xA;      client.println();&#xA;&#xA;      client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;CONTROL PANEL&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;body style='padding: 0; margin: 0;' onunload='window.opener.document.getElementById('controlPanel').disabled = false;'&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;div style='width: 100%; height: auto; background-color: #000000;'&amp;gt;&amp;lt;center style='font-size: 18px; font-family: Impact; color: white;'&amp;gt;POLYTECHNIC UNIVERSITY OF THE PHILIPPINES&amp;lt;br /&amp;gt;COLLEGE OF ENGINEERING&amp;lt;br /&amp;gt;COMPUTER ENGINEERING DEPARTMENT&amp;lt;br /&amp;gt;&amp;lt;/center&amp;gt;&amp;lt;center style='font-size: 30px; font-family: Impact; color: #FF9600;'&amp;gt;COMPUTER ENGINEERING LABORATORY&amp;lt;/center&amp;gt;&amp;lt;/div&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;div style='width: 100%; height: 10px; background-color: gray;'&amp;gt;&amp;lt;/div&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;div style='width: 100%; height: 10px; background-color: #FF9600;'&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;div style='width: 80%; height: auto; background-color: #FF9600; border-radius: 20px; margin: auto; padding: 5px;'&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;div style='width: auto; height: auto; background-color: #FFFFFF; border-radius: 20px; margin: auto; padding: 5px;'&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;center style='font-size: 30px; font-family: Impact;'&amp;gt;CONTROL PANEL&amp;lt;/center&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;hr /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;      client.println(&quot;&amp;lt;form method=get&amp;gt;&quot;);&#xA;&#xA;      for (i = 1; i &amp;lt; (numOfRooms + 1) ; i++)&#xA;      {&#xA;        Room = String(&quot;ROOM&quot;) + (i + 310);&#xA;&#xA;        if (inString.indexOf(Room + &quot;=OPEN&quot;) &amp;gt; 0 || inString.indexOf(&quot;All=OPEN&quot;) &amp;gt; 0)&#xA;        {&#xA;          Serial.println(&quot;\n&quot; + Room + &quot; is OPEN&quot;);&#xA;          digitalWrite(pin[i], HIGH);&#xA;          value[i] = &quot;CLOSE&quot;;&#xA;        }&#xA;        else if (inString.indexOf(Room + &quot;=CLOSE&quot;) &amp;gt; 0 || inString.indexOf(&quot;All=CLOSE&quot;) &amp;gt; 0)&#xA;        {&#xA;          Serial.println(&quot;\n&quot; + Room + &quot; is CLOSE&quot;);&#xA;          digitalWrite(pin[i], LOW);&#xA;          value[i] = &quot;OPEN&quot;;&#xA;        }&#xA;&#xA;        client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;center style='font-family: Impact;'&amp;gt;&quot; + Room + &quot;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;input type='submit' name=&quot; + Room + &quot; value=&quot; + value[i] + &quot; style='height: 50px; width:100px;' /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;      }&#xA;&#xA;      client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;All &amp;lt;input type='submit' name='All' value='OPEN' style='height: 50px; width:100px;' /&amp;gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;input type='submit' name='All' value='CLOSE' style='height: 50px; width:100px;' /&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;/center&amp;gt;&amp;lt;/form&amp;gt;&quot;);&#xA;&#xA;      for (i = 1; i &amp;lt; (numOfRooms + 1); i++)&#xA;      {&#xA;        if (value[i] == &quot;ON&quot;)&#xA;        {&#xA;          i = i + 310;&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;p&amp;gt;Room &quot; + String(i + 310) + &quot; is OPEN&amp;lt;/p&amp;gt;&quot;);&#xA;        }&#xA;        else if (value[i] == &quot;OFF&quot;)&#xA;        {&#xA;          client.println(&quot;&amp;lt;p&amp;gt;&amp;lt;p&amp;gt;Room &quot; + String(i + 310) + &quot; is CLOSE&quot;);&#xA;        }&#xA;      }&#xA;      client.println(&quot;&amp;lt;/div&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;/div&amp;gt;&quot;);&#xA;      client.println(&quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;);&#xA;      break;&#xA;    }&#xA;&#xA;    if (c == '\n')&#xA;    {&#xA;      // we're starting a new line&#xA;      current_line_is_blank = true;&#xA;    }&#xA;    else if (c != '\r')&#xA;    {&#xA;      // we've gotten a character on the current line&#xA;      current_line_is_blank = false;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;    // give the web browser time to receive the data&#xA;    delay(1);&#xA;    inString = &quot;&quot;;&#xA;    client.stop();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MOBILE means code for Arduino-Android&#xA;WEB means the code for Web Server&lt;/p&gt;&#xA;" OwnerUserId="13308" LastActivityDate="2015-09-18T02:31:25.113" Title="Integrating two Arduino Ethernet libraries in one sketch" Tags="|arduino-uno|arduino-ide|ethernet|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16155" PostTypeId="2" ParentId="16153" CreationDate="2015-09-17T19:06:55.817" Score="3" Body="&lt;p&gt;Each time the watchdog interrupt triggers, WDIE is reset. You will need to set it again in the loop if you want to continue capturing the interrupt rather than resetting the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, consider using &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;avr/wdt.h&amp;gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;avr/sleep.h&amp;gt;&lt;/code&gt;&lt;/a&gt; to handle (most of) the watchdog and sleep functionality.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EMPTY_INTERRUPT(WDT_vect);&#xA;&#xA;void main ()&#xA;{&#xA;    watchdog_init();&#xA;    set_sleep_mode(SLEEP_MODE_STANDBY);&#xA;    //and initialize all the other hardware and power supply&#xA;&#xA;    while (true) //no need to step out of this loop&#xA;    {&#xA;        wdt_reset()&#xA;&#xA;        //&#xA;        //main program&#xA;        //&#xA;&#xA;        if(go_to_sleep=1)  //command received through serial&#xA;        {&#xA;            sleep_enable();&#xA;            sleep_cpu();&#xA;            sleep_disable();&#xA;            WDTCSR |= _BV(WDIE);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-17T19:06:55.817" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16156" PostTypeId="1" CreationDate="2015-09-17T19:09:40.980" Score="1" ViewCount="1725" Body="&lt;p&gt;I posted a couple weeks ago about having a GSM error. I moved past it and the code seemed to be working on my GSM module (I think a SIMCOM). But then I needed to create some more systems and out of a total of 8 GSM modules, my code and setup only work on two of them - despite the fact that they should be identical and from the same supplier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code (thanks to &lt;a href=&quot;http://www.theengineeringprojects.com/2015/02/receive-sms-commands-using-sim900-arduino.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this genius post&lt;/a&gt;) works without error to send and receive SMS on two of the boards:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; &#xA;char inchar; // Will hold the incoming character from the GSM shield&#xA;SoftwareSerial SIM900 = SoftwareSerial(2,3);&#xA;&#xA;void setup() {&#xA;  Serial.begin(19200);&#xA;  initializeGSM();&#xA;}&#xA;&#xA;void initializeGSM() {&#xA;  SIM900.begin(19200);&#xA;  Serial.println(&quot;Turned on&quot;);&#xA;  SIM900.print(&quot;ATEO\r&quot;);&#xA;  Response();&#xA;  SIM900.print(&quot;AT\r&quot;);&#xA;  delay(1000);&#xA;  Response();&#xA;  SIM900.println(&quot;AT+CMGF=1\r&quot;);  // set SMS mode to text&#xA;  Response();&#xA;  delay(1000);&#xA;  SIM900.println(&quot;AT+CNMI=1,2,0,0,0\r&quot;);&#xA;  delay(100);&#xA;  Response();&#xA;  delay(5000);  // give time to log on to network.&#xA;  Serial.println(&quot;Ready...&quot;);&#xA;}&#xA;&#xA;void Response() {&#xA;  int count = 0;&#xA;  delay(1000);&#xA;  Serial.println(SIM900.available());&#xA;  while(1) {&#xA;    if(SIM900.available()) {&#xA;      char data =SIM900.read();&#xA;      if(data == 'K'){Serial.println(&quot;OK&quot;);break;}&#xA;      if(data == 'R'){Serial.println(&quot;GSM Not Working&quot;);break;}&#xA;    }&#xA;    count++;&#xA;    if(count == 100){Serial.println(&quot;GSM not Found&quot;);break;}&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  RecSMS();&#xA;  delay(2000);&#xA;}&#xA;&#xA;void RecSMS(){...}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So again, the above code works to set up the module on 2 modules. On the other 6, it simply hangs during the &lt;code&gt;Response()&lt;/code&gt; call. &lt;code&gt;SIM900.available()&lt;/code&gt; returns 0 and then says &quot;GSM Not Found.&quot; So I tried to initialize the TX pin during setup as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(2, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which then gives me a promising &lt;code&gt;SIM900.available()&lt;/code&gt; value of about 63, which corresponds to what a confirmation would be. However, when I print the &quot;data&quot; variable containing the byte read off the GSM module/SIM card, I get a couple bits of garbage like the following output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iWlsl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iWlsl.png&quot; alt=&quot;Garbage output from printing the data char during the Response function&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone experienced this problem and knows a way to properly initialize the GSM module?&lt;/p&gt;&#xA;" OwnerUserId="12097" LastEditorUserId="4628" LastEditDate="2017-04-29T07:07:49.480" LastActivityDate="2017-10-27T05:08:34.517" Title="Why are some of my GSM modules not taking commands?" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16157" PostTypeId="2" ParentId="1569" CreationDate="2015-09-17T20:13:09.987" Score="2" Body="&lt;p&gt;;TLDR; It initializes the serial communication port and sets the baud rate. The device you're communicating with (or Arduino IDE Serial Monitor) have to be set to a matching baud rate. Once you've initialized the port you can begin sending or receiving characters. &lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Reference&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2015-09-17T20:13:09.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16158" PostTypeId="2" ParentId="15916" CreationDate="2015-09-17T20:41:38.763" Score="1" Body="&lt;p&gt;Instead of using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myservo.write(135);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myservo.writeMicroseconds();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/ServoWriteMicroseconds&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/ServoWriteMicroseconds&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13447" LastActivityDate="2015-09-17T20:41:38.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16159" PostTypeId="1" CreationDate="2015-09-17T21:06:12.717" Score="3" ViewCount="692" Body="&lt;p&gt;I have been struggling with a LCD for 6 hours straight - I've had many problems including random characters showing up, and this time (not quite sure what changed, I tried so many things) as soon as I instantiate a LiquidCrystal object the Arduino stops sending on the Serial port. On the following code, commenting the instantiation of lcd makes &quot;Starting&quot; and &quot;Printing&quot; appear in the serial terminal - otherwise nothing is displayed. Either way, the LCD is desperately blank (black spaces on the entire first line, and I tuned the contrast when random characters were displayed).&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;//RS EN D4 D5 D6 D7&#xA;//LiquidCrystal lcd(2, 3, 4, 5, 9, A5);&#xA;//RW to GND, VSS to GND, VCC to 5V, V0 to wiper of 5V-to-GND 10k potentiometer&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting&quot;);&#xA;  //lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop() {&#xA;  //lcd.setCursor(0, 1);&#xA;  //lcd.print(millis() / 1000);&#xA;  Serial.println(&quot;Printing&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this &lt;a href=&quot;http://hobbycomponents.com/boards/140-arduino-compatible-5v-pro-mini-?search_query=pro%20mini&amp;amp;results=53&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Pro Mini&lt;/a&gt;, and this &lt;a href=&quot;http://uk.farnell.com/midas/mc21605h6w-sptly/lcd-2x16-stn-led-b-l-blk-on-y/dp/2342641&quot; rel=&quot;nofollow noreferrer&quot;&gt;LCD&lt;/a&gt;. Note that on the Arduino, pins 10 11 12 and 13 are used for a SD (which works), and 6 7 8 are used for a RS232 driver (which is disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Honestly I'm sending a message in a bottle, I'm out of ideas...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring is as explained in the code, I checked it 5 times and it is matching. There is a 10k pot on GND-VO-5V of the LCD, and I haven't wired the backlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit1:&lt;/strong&gt; With the LCD active (all lines uncommented) I probed all LCD pins with a 'scope and when it is triggered in Normal, I can see that they all have a pulse every time the LCD is updated (I added a delay in the loop to make it more obvious). HOWEVER pins 9 and A5 take much longer than the others to get back to a high state, around 3 microseconds. Why? It might explain why the LCD doesn't work, but I don't see how it can explain the apparent freeze.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit2:&lt;/strong&gt; Okay, I desoldered pins 9 and A5 and placed the wires on pins A2 A3 instead. The square waves are all square now, and the Serial works - no idea why. And back to square 1, as the LCD prints random characters now... &lt;/p&gt;&#xA;" OwnerUserId="13448" OwnerDisplayName="user42875" LastEditorUserId="37523" LastEditDate="2019-05-15T08:25:58.887" LastActivityDate="2019-05-15T08:25:58.887" Title="Serial does not work when LiquidCrystal library is used" Tags="|lcd|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16161" PostTypeId="1" AcceptedAnswerId="16164" CreationDate="2015-09-18T02:30:47.743" Score="2" ViewCount="2737" Body="&lt;p&gt;I am trying to pass the input from one pin to another pin as output. Effectively I want to create a blind passthrough. The end goal is to connect two Arduinos and a series of test points together like the diagram below. I want Arduino B to shuffle which test points are connected to which pins on Arduino A on startup.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-----------+       +-----------+     +-------------+&#xA;|           |       |           |     |             |&#xA;| Arduino A &amp;lt;-------&amp;gt; Arduino B &amp;lt;-----&amp;gt; Test Points |&#xA;|           |       |           |     |             |&#xA;+-----------+       +-----------+     +-------------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I figure one way to do this is to poll the input pins in the loop() and then change the output pins accordingly but I would prefer if the voltage changes just passed right through without it affecting timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;For some clarification:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All signaling is digital&lt;/li&gt;&#xA;&lt;li&gt;I'm looking to &quot;route&quot; around 10-12 test points to Arduino A ideally but 6 at a minimum&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13452" LastEditorUserId="13452" LastEditDate="2015-09-18T16:53:53.893" LastActivityDate="2015-09-18T20:26:27.937" Title="Passing the input from one pin to another as output without polling?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16162" PostTypeId="2" ParentId="16154" CreationDate="2015-09-18T02:31:25.113" Score="0" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The code has both libraries trying to run on the same port which is not allowed (in fact you couldn't even do that on a computer). You could try setting one to one port and the other to another port, but that might not work because...&lt;/li&gt;&#xA;&lt;li&gt;These libraries most likely are both expecting to be the only code accessing the hardware and they will step over each other and cause problems. Sharing hardware between different pieces of code is an advanced programming topic not suited for beginners and would involve rewriting significant portions of these libraries.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The best course of action is to either re-implement your app functionality to use the UIPEthernet Library, or re-implement the webpage using the EtherShield library. You should be able to do this because your app interface is supplying parameters (e.g the &quot;?cmd=&quot; part) and the webpage is not. You should be able to set it up so that if it has &quot;?cmd=&quot; in the request, it should perform the command, otherwise it should return the webpage.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-09-18T02:31:25.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16163" PostTypeId="2" ParentId="16161" CreationDate="2015-09-18T02:35:31.790" Score="2" Body="&lt;p&gt;No Arduino is capable of doing this. You need to be looking at a &lt;a href=&quot;https://en.wikipedia.org/wiki/Crossbar_switch&quot; rel=&quot;nofollow&quot;&gt;crossbar/crosspoint/matrix switch&lt;/a&gt; IC instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-18T02:35:31.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16164" PostTypeId="2" ParentId="16161" CreationDate="2015-09-18T03:21:59.867" Score="4" Body="&lt;p&gt;You could use an analog multiplexer such as the 74HC4051 (8 channels) or the 74HC4067 (16 channels) like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FmwtJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FmwtJ.png&quot; alt=&quot;74HC4051 multiplexer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino B could alter the multiplex selector (A/B/C) pins to route the signal from the test points to a specific pin on Arduino A. If you are wanting to see the result of the signal on a different pin then a second multiplexer would be required (ie. one to send data to a pin, the second to see the result on a different pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a post about the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC4051 multiplexer / demultiplexer&lt;/a&gt; which gives more details about using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tested it I found only about a 5 ns delay in timing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CShlX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CShlX.png&quot; alt=&quot;Multiplexer timing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ignacio's answer about a crossbar switch sounds like a more elaborate form of multiplexer. Personally I haven't used one of them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-18T03:21:59.867" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16165" PostTypeId="1" AcceptedAnswerId="16175" CreationDate="2015-09-17T22:26:57.280" Score="3" ViewCount="12219" Body="&lt;p&gt;I've been struggling with my LCD for hours, and after solving more different issues than I can remember, I'm out of ideas for this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My LCD is showing random characters, see the picture below (the last character blinks, some characters change and over time there are slowly more and more characters). I'm starting to wonder if the LCD I chose has a driver compatible with the LiquidCrystal library, what do you think? If so what can I do to avoid buying another one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DYED4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DYED4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;//RS EN D4 D5 D6 D7&#xA;LiquidCrystal lcd(2, 3, 4, 5, A2, A3);&#xA;//RW to GND, VSS to GND, VCC to 5V, V0 to wiper of 5V-to-GND 10k potentiometer&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting&quot;);&#xA;  lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop() {&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(millis() / 1000);&#xA;  Serial.println(&quot;Printing&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this &lt;a href=&quot;http://hobbycomponents.com/boards/140-arduino-compatible-5v-pro-mini-?search_query=pro%20mini&amp;amp;results=53&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino&lt;/a&gt; and this &lt;a href=&quot;http://uk.farnell.com/midas/mc21605h6w-sptly/lcd-2x16-stn-led-b-l-blk-on-y/dp/2342641&quot; rel=&quot;nofollow noreferrer&quot;&gt;LCD&lt;/a&gt;. Note that I'm using pins 10,11,12,13 for a SD (which works) and 6 7 8 for a MAX232 (which is disabled).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="13448" OwnerDisplayName="user42875" LastEditorUserId="13448" LastEditDate="2015-09-18T09:57:32.853" LastActivityDate="2023-06-10T03:48:08.383" Title="Why does my LCD display random characters?" Tags="|lcd|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="16166" PostTypeId="2" ParentId="16146" CreationDate="2015-09-18T05:06:21.860" Score="0" Body="&lt;p&gt;I think you should check your baud rates. A mismatch in baud rates usually makes that symbol get printed on the screen.&lt;/p&gt;&#xA;" OwnerUserId="11916" LastEditorUserId="510" LastEditDate="2018-03-11T16:26:48.417" LastActivityDate="2018-03-11T16:26:48.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16167" PostTypeId="2" ParentId="15945" CreationDate="2015-09-18T05:32:51.233" Score="1" Body="&lt;p&gt;Eventually i've found the reason. And it was bug in HM-10 firmware.&#xA;In mode 0 it does not accept control commands and in modes 1 and 2 it accepts AT commands to control PIO and commands are look like 'AT+...', f.e. 'PIO set value 1 to pin 1' command is 'AT+PIO11' and change mode to 0 look like 'AT+MODE0'. I need mode 1 to set PIO to 1 and 0 to reset arduino board. The problem is that some of upload commands look like 'A [0x41] . [0x81]   [0x20]' (starts from 'A' too) and it makes HM-10 think it's control command which also starts from 'A'. If i add changing mode to 0 after pin control commands (in order to make HM-10 stop accepting control commands) it starts uploading:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2015-09-18 10:27:32.144 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 1 [0x31] &#xA;2015-09-18 10:27:32.145 xctest[94852:4603627] [WARNING] [IN ]: Got 9 bytes in incoming buffer&#xA;2015-09-18 10:27:32.145 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 9 bytes: O [0x4F] K [0x4B] + [0x2B] P [0x50] I [0x49] O [0x4F] 2 [0x32] : [0x3A] 0 [0x30] &#xA;2015-09-18 10:27:32.146 xctest[94852:4603627] [WARNING] [IN ]: Got 9 bytes in incoming buffer&#xA;2015-09-18 10:27:32.146 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 8 bytes: O [0x4F] K [0x4B] + [0x2B] S [0x53] e [0x65] t [0x74] : [0x3A] 0 [0x30] &#xA;2015-09-18 10:27:32.147 xctest[94852:4603627] [WARNING] [IN ]: Got 8 bytes in incoming buffer&#xA;2015-09-18 10:27:32.147 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-18 10:27:32.147 xctest[94852:4603627] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-18 10:27:32.207 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.208 xctest[94852:4603578] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-18 10:27:32.208 xctest[94852:4603578] [DEBUG  ] [IN ]: Drained 26 bytes&#xA;2015-09-18 10:27:32.208 xctest[94852:4603578] [DEBUG  ] [   ]: Draining incoming buffer (0 bytes)&#xA;2015-09-18 10:27:32.208 xctest[94852:4603578] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-18 10:27:32.208 xctest[94852:4603578] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-18 10:27:32.209 xctest[94852:4603578] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-18 10:27:32.209 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.209 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.561 xctest[94852:4603630] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-18 10:27:32.561 xctest[94852:4603630] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-18 10:27:32.561 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x11] . [0xFC] &#xA;2015-09-18 10:27:32.561 xctest[94852:4603627] [WARNING] [IN ]: Got 2 bytes in incoming buffer&#xA;2015-09-18 10:27:32.563 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.563 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x11] &#xA;2015-09-18 10:27:32.563 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-18 10:27:32.563 xctest[94852:4603578] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-18 10:27:32.563 xctest[94852:4603578] [ERROR  ] [   ]: STK500:synchronize: attempt 1 of 3: no sync: received [0x11]&#xA;2015-09-18 10:27:32.564 xctest[94852:4603578] [DEBUG  ] [   ]: Draining incoming buffer (1 bytes)&#xA;2015-09-18 10:27:32.564 xctest[94852:4603578] [DEBUG  ] [OUT]: Sending 2 bytes&#xA;2015-09-18 10:27:32.564 xctest[94852:4603578] [TRACE  ] [OUT]: Send: 0 [0x30]   [0x20] &#xA;2015-09-18 10:27:32.564 xctest[94852:4603578] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 2&#xA;2015-09-18 10:27:32.565 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.565 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.636 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-18 10:27:32.636 xctest[94852:4603627] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-18 10:27:32.636 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 2 bytes: . [0x14] . [0x10] &#xA;2015-09-18 10:27:32.636 xctest[94852:4603627] [WARNING] [IN ]: Got 2 bytes in incoming buffer&#xA;2015-09-18 10:27:32.638 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.638 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-18 10:27:32.638 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-18 10:27:32.638 xctest[94852:4603578] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-18 10:27:32.639 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.639 xctest[94852:4603578] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-18 10:27:32.639 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.639 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.640 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-18 10:27:32.644 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-18 10:27:32.644 xctest[94852:4603578] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-18 10:27:32.645 xctest[94852:4603578] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-18 10:27:32.645 xctest[94852:4603578] [TRACE  ] [OUT]: Send: A [0x41] . [0x81]   [0x20] &#xA;2015-09-18 10:27:32.645 xctest[94852:4603578] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-18 10:27:32.645 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.646 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.711 xctest[94852:4603630] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-18 10:27:32.711 xctest[94852:4603630] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-18 10:27:32.711 xctest[94852:4603630] [TRACE  ] [IN ]: Rx value received 3 bytes: . [0x14] . [0x04] . [0x10] &#xA;2015-09-18 10:27:32.711 xctest[94852:4603630] [WARNING] [IN ]: Got 3 bytes in incoming buffer&#xA;2015-09-18 10:27:32.712 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.713 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x14] &#xA;2015-09-18 10:27:32.713 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 3 bytes&#xA;2015-09-18 10:27:32.713 xctest[94852:4603578] [TRACE  ] [IN ]: 2 bytes in incoming buffer remaining for next receive&#xA;2015-09-18 10:27:32.713 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.713 xctest[94852:4603578] [TRACE  ] [IN ]: Having current receive buffer: . [0x04] . [0x10] &#xA;2015-09-18 10:27:32.714 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.714 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.728 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x04] &#xA;2015-09-18 10:27:32.728 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 2 bytes&#xA;2015-09-18 10:27:32.729 xctest[94852:4603578] [TRACE  ] [IN ]: 1 bytes in incoming buffer remaining for next receive&#xA;2015-09-18 10:27:32.729 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.729 xctest[94852:4603578] [TRACE  ] [IN ]: Having current receive buffer: . [0x10] &#xA;2015-09-18 10:27:32.729 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.730 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.730 xctest[94852:4603578] [TRACE  ] [IN ]: Receive: . [0x10] &#xA;2015-09-18 10:27:32.730 xctest[94852:4603578] [DEBUG  ] [IN ]: Read 1 bytes, actually received 1 bytes&#xA;2015-09-18 10:27:32.730 xctest[94852:4603578] [TRACE  ] [IN ]: Ble clear buffer&#xA;2015-09-18 10:27:32.731 xctest[94852:4603578] [DEBUG  ] [OUT]: Sending 3 bytes&#xA;2015-09-18 10:27:32.731 xctest[94852:4603578] [TRACE  ] [OUT]: Send: A [0x41] . [0x82]   [0x20] &#xA;2015-09-18 10:27:32.731 xctest[94852:4603578] [TRACE  ] [OUT]: BLE sending bytes range from 0 length 3&#xA;2015-09-18 10:27:32.732 xctest[94852:4603578] [DEBUG  ] [IN ]: Reading 1 bytes ...&#xA;2015-09-18 10:27:32.732 xctest[94852:4603578] [TRACE  ] [IN ]: Start reading&#xA;2015-09-18 10:27:32.786 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 1 bytes: . [0x00] &#xA;2015-09-18 10:27:32.786 xctest[94852:4603627] [TRACE  ] [IN ]: Ignoring single 0x00 char &#xA;2015-09-18 10:27:32.787 xctest[94852:4603627] [TRACE  ] [IN ]: Rx value received 3 bytes: . [0x14] . [0x04] . [0x10] &#xA;2015-09-18 10:27:32.787 xctest[94852:4603627] [WARNING] [IN ]: Got 3 bytes in incoming buffer&#xA;2015-09-18 10:27:32.788 xctest[94852:4603578] [TRACE  ] [IN ]: Finish reading&#xA;2015-09-18 10:27:32.788 xctest[94&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was working for Mega2560 since it uses different bootloader and upload commands do not start from 'A'. It's definitely HM-10 firmware bug as it can understand it's not control command since the second byte is not 'T'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i had oscilloscope i'd find the reason in 1 hour but for casual engineering i don't need it. I've reported a bug to HM-10 manufacturer but i'm not sure when they fix it. HM-10 firmware version is v532.&lt;/p&gt;&#xA;" OwnerUserId="8327" LastEditorUserId="8327" LastEditDate="2015-09-18T05:39:32.997" LastActivityDate="2015-09-18T05:39:32.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16168" PostTypeId="1" AcceptedAnswerId="16169" CreationDate="2015-09-18T03:39:12.387" Score="0" ViewCount="258" Body="&lt;p&gt;I'm working on a project where I need my arduino to detect the value of encoder at the instant the reading of the joystick change to 128.  When the joystick is at rest, the reading is 128 which also means, my robot will hold its position/brake. Values above or below 128 correspond to the motor moving forward or backward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I actually want to record the encoder value exactly at the first instant my arduino reads 128, so that I can apply PID position control so that my robot can brake or hold its position against gravity. The first instant when the joystick reads 128, that is the encoder value that I'd like to set as the Setpoint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some explanations for implementing PID in Arduino. &#xA;&lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibraryConstructor&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/PIDLibraryConstructor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the joystick readings go from 140, 137, 131, [128], 128, 128, 133, 139, 131, [128], 128 and at the same time, the encoder gives out corresponding values. I need the encoder values at the Joystick value of 128 in the square bracket, [] in the example above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the code below, it will just run the statements in {} whenever it sees 128, which is not what I want. FYI, the motor sometimes tend to backdrive, and this gives different encoder value also at 128. What I only need is the first encoder value at the first reading of 128 whenever I encounter it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;&#xA;  int pwmSpeed;&#xA;&#xA;  int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);&#xA;&#xA;  Input = encoder0Pos;&#xA;&#xA;  if (Y_axis == 128)&#xA;  {&#xA;&#xA;    Setpoint = encoder0Pos;&#xA;    myPID.Compute();&#xA;    analogWrite(pwm, Output);&#xA;&#xA;  }&#xA;&#xA;  else if (Y_axis &amp;gt; 128)&#xA;  {&#xA;    pwmSpeed = Y_axis;&#xA;    digitalWrite(dir,HIGH);           // set DIR pin HIGH or LOW&#xA;    analogWrite(pwm, pwmSpeed);            //analogWrite(pin, value)     &#xA;  }&#xA;  else&#xA;  {&#xA;    pwmSpeed = abs(Y_axis-255);&#xA;    digitalWrite(dir, LOW);&#xA;    analogWrite(pwm, pwmSpeed);&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//New edited code is shown below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you think of the code? Did I do it correctly? I will test it once I get back to the lab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 128 is detected, encoder value is stored in Setpoint and then Pid.compute() is executed for as long as 128 is detected. For this duration, Pid.compute() will compute the error = Setpoint - Input and use Pid formula to calculate the Output that can be found in the analogWrite(pwm, Output). Motor will work to maintain its position at Setpoint. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if other than 128 is encountered, it will just execute the 'else if' and 'else' statement to move the robot forward or backward.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;global g_detect128 = false;&#xA;&#xA;void setup() &#xA;    {&#xA;//any code here&#xA;    }&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  int pwmSpeed;    &#xA;  int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);&#xA;&#xA;  Input = encoder0Pos;&#xA;&#xA; if (!g_detect128 &amp;amp;&amp;amp; Y_axis == 128)&#xA;    {&#xA;    Setpoint = encoder0Pos;&#xA;    g_detect128 = true;&#xA;    }&#xA;&#xA;&#xA;  if (Y_axis == 128)&#xA;  {&#xA;&#xA;    myPID.Compute();&#xA;    analogWrite(pwm, Output);&#xA;&#xA;  }&#xA;&#xA;  else if (Y_axis &amp;gt; 128)&#xA;  {&#xA;    pwmSpeed = Y_axis;&#xA;    digitalWrite(dir,HIGH);           // set DIR pin HIGH or LOW&#xA;    analogWrite(pwm, pwmSpeed);            //analogWrite(pin, value)     &#xA;  }&#xA;  else&#xA;  {&#xA;    pwmSpeed = abs(Y_axis-255);&#xA;    digitalWrite(dir, LOW);&#xA;    analogWrite(pwm, pwmSpeed);&#xA;&#xA;  }&#xA;&#xA; if(Y_axis != 128)&#xA;    {&#xA;    g_detect128 = false;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13456" OwnerDisplayName="goddar" LastEditorUserId="13456" LastEditDate="2015-09-19T17:58:53.860" LastActivityDate="2015-09-19T17:58:53.860" Title="Arduino: Record value of the encoder only once at the instant the PS2 joystick reads 128 (when at rest)" Tags="|programming|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16169" PostTypeId="2" ParentId="16168" CreationDate="2015-09-18T04:29:29.107" Score="2" Body="&lt;p&gt;If you only want to catch this event once - when it first hits 128, you just need a global variable to flag when you've seen it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean g_bSeen128 = false;&#xA;&#xA;void setup()&#xA;{&#xA;    // ... whatever&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // ... your existing code&#xA;&#xA;    // catch first time we see 128&#xA;    if (!g_bSeen128 &amp;amp;&amp;amp; Y_axis == 128)&#xA;    {&#xA;        // ... do whatever you need here. e.g.&#xA;        Setpoint = encoder0Pos;&#xA;        myPID.Compute();&#xA;        analogWrite(pwm, Output);&#xA;&#xA;        // stop the event being caught next time&#xA;        g_bSeen128 = true;&#xA;    }&#xA;&#xA;    // from comments below - to just ignore consecutive 128's, add this:&#xA;    if (Y_axis != 128) g_bSeen128 = false;&#xA;&#xA;    // ... your existing code&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you only want to do something if the input changes, no matter what it is, you can keep track of the last input:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int g_nLastInput = -1;&#xA;&#xA;void setup()&#xA;{&#xA;    // ... whatever&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // get input&#xA;    int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);&#xA;&#xA;    // if input has changed ...&#xA;    if (Y_axis != g_nLastInput)&#xA;    {&#xA;        // ... save latest input&#xA;        g_nLastInput = Y_axis;&#xA;&#xA;        // now process the change, e.g.&#xA;        if (Y_axis == 128)&#xA;        {&#xA;            // ... do something special for 128&#xA;        }&#xA;        else&#xA;        {&#xA;            // ... do something else for other inputs&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you're trying to do with the PWM when you get inputs either side of 128, it seems to me that you might want to go in one direction if the input is less than 128 and go in the other direction if it's greater than 128. In either case, the magnitude of your PWM speed should just reflect how far you are from 128 in either direction. So subtracting 128 from your input will give a delta that is +/- 128 and we can scale its absolute value to 0..255 for the PWM setting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's correct, an alternative way of coding your original logic might be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    // get input&#xA;    int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);&#xA;&#xA;    Input = encoder0Pos;&#xA;&#xA;    // if input has changed ...&#xA;    if (Y_axis != g_nLastInput)&#xA;    {&#xA;        // ... save latest input&#xA;        g_nLastInput = Y_axis;&#xA;&#xA;        // now process the change&#xA;        int nDelta = Y_axis - 128;&#xA;&#xA;        if (nDelta == 0)&#xA;        {&#xA;            // i.e. Y_axis is 128&#xA;            Setpoint = encoder0Pos;&#xA;            myPID.Compute();&#xA;            analogWrite(pwm, Output);&#xA;        }&#xA;        else&#xA;        {&#xA;            // choose direction&#xA;            digitalWrite(dir, (nDelta &amp;gt; 0) ? HIGH : LOW);&#xA;&#xA;            // set PWM speed scaled to 0..255&#xA;            analogWrite(pwm, abs(nDelta) * 2);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5063" OwnerDisplayName="Roger Rowland" LastEditorUserId="5063" LastEditDate="2015-09-19T06:16:56.627" LastActivityDate="2015-09-19T06:16:56.627" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16170" PostTypeId="1" CreationDate="2015-09-18T09:39:32.330" Score="0" ViewCount="12390" Body="&lt;p&gt;I am having Issue while connecting ESP8266 with Arduino Mega. It always says &quot;Module have no response.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check and correct me if I am wrong anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using below code and and wiring diagram is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dwucL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dwucL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;   //use mega Serial 2 for serial monitor; Serial 1 on pins 19 (RX) and 18 (TX);// Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX).&#xA;   #define SSID &quot;SopraSteria&quot;&#xA;   #define PASS &quot;1234567890&quot;&#xA;   #define DST_IP &quot;220.181.111.85&quot; //baidu.com&#xA;   //SoftwareSerial dbgSerial(10, 11); // RX, TX&#xA;   void setup()&#xA;   {&#xA;     // Open serial communications and wait for port to open:&#xA;     //serial 2 is to esp8266 &#xA;     Serial2.begin(115200);//9600 (mine), 57600, 115200&#xA;     Serial2.setTimeout(2000);&#xA;&#xA;     //serial 0 is to usb&#xA;     Serial.begin(115200);&#xA;&#xA;&#xA;     while(!Serial); &#xA;     while(!Serial2);&#xA;&#xA;     //dbgSerial.begin(9600); //can't be faster than 19200 for softserial&#xA;     //dbgSerial.println(&quot;ESP8266 Demo&quot;);&#xA;     Serial.println(&quot;ESP8266 Demo on Mega2560&quot;);&#xA;&#xA;    while(Serial2.available()&amp;gt;0)&#xA;    Serial2.read();&#xA;&#xA;     delay(1000);&#xA;       //test if the module is ready&#xA;     Serial2.println(&quot;AT+RST&quot;);&#xA;     //delay(1000);&#xA;     //delay(1000);&#xA;     Serial.println(&quot;Resetting module&quot;);&#xA;     Serial2.flush();&#xA;     //Serial.println(Serial2.read());&#xA;     //if(Serial2.find(&quot;ready&quot;))&#xA;     if(Serial2.find(&quot;Ready&quot;)||Serial2.find(&quot;ready&quot;))&#xA;     {&#xA;       //dbgSerial.println(&quot;Module is ready&quot;);&#xA;       Serial.println(&quot;Module is ready&quot;);&#xA;     }&#xA;     else&#xA;     {&#xA;       //dbgSerial.println(&quot;Module have no response.&quot;);&#xA;       Serial.println(&quot;Module have no response.&quot;);&#xA;       //while(1);&#xA;     }&#xA;     delay(1000);&#xA;     //connect to the wifi&#xA;     boolean connected=false;&#xA;     for(int i=0;i&amp;lt;5;i++)&#xA;     {&#xA;       if(connectWiFi())&#xA;       {&#xA;         connected = true;&#xA;         break;&#xA;       }&#xA;     }&#xA;     if (!connected){&#xA;      //while(1);&#xA;      Serial.println(&quot;Not Connected.&quot;);&#xA;     }&#xA;     delay(1000);&#xA;     //print the ip addr&#xA;&#xA;   Serial2.println(&quot;AT+CIFSR&quot;);&#xA;     Serial.println(&quot;ip address:&quot;);&#xA;     while (Serial2.available())&#xA;     Serial.write(Serial2.read());&#xA;&#xA;&#xA;     //set the single connection mode&#xA;     Serial2.println(&quot;AT+CIPMUX=0&quot;);&#xA;   }&#xA;   void loop()&#xA;   {&#xA;    //connectWiFi();&#xA;     String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;     cmd += DST_IP;&#xA;     cmd += &quot;\&quot;,80&quot;;&#xA;     Serial2.println(cmd);&#xA;     Serial.println(cmd);&#xA;     Serial.println(cmd);&#xA;     if(Serial2.find(&quot;Error&quot;)) return;&#xA;     cmd = &quot;GET / HTTP/1.0\r\n\r\n&quot;;&#xA;     Serial2.print(&quot;AT+CIPSEND=&quot;);&#xA;     Serial2.println(cmd.length());&#xA;     if(Serial2.find(&quot;&amp;gt;&quot;))&#xA;     {&#xA;       //dbgSerial.print(&quot;&amp;gt;&quot;);&#xA;       Serial.print(&quot;&amp;gt;&quot;);&#xA;       }else&#xA;       {&#xA;         Serial2.println(&quot;AT+CIPCLOSE&quot;);&#xA;         //dbgSerial.println(&quot;connect timeout&quot;);&#xA;         Serial.println(&quot;connect timeout&quot;);&#xA;         delay(1000);&#xA;         return;&#xA;       }&#xA;       Serial2.print(cmd);&#xA;       delay(2000);&#xA;       //Serial.find(&quot;+IPD&quot;);&#xA;       while (Serial2.available())&#xA;       {&#xA;         char c = Serial2.read();&#xA;         //dbgSerial.write(c);&#xA;         Serial.write(c);&#xA;         //if(c=='\r') dbgSerial.print('\n');&#xA;         if(c=='\r') Serial.print('\n');&#xA;       }&#xA;       //dbgSerial.println(&quot;====&quot;);&#xA;       Serial.println(&quot;====&quot;);&#xA;       delay(1000);&#xA;     }&#xA;     boolean connectWiFi()&#xA;     {&#xA;       Serial2.println(&quot;AT+CWMODE=1&quot;);&#xA;       String cmd=&quot;AT+CWJAP=\&quot;&quot;;&#xA;       cmd+=SSID;&#xA;       cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;       cmd+=PASS;&#xA;       cmd+=&quot;\&quot;&quot;;&#xA;       //dbgSerial.println(cmd);&#xA;       Serial2.println(cmd);&#xA;       Serial.println(cmd);&#xA;       delay(2000);&#xA;       if(Serial2.find(&quot;OK&quot;))&#xA;       {&#xA;         //dbgSerial.println(&quot;OK, Connected to WiFi.&quot;);&#xA;         Serial.println(&quot;OK, Connected to WiFi.&quot;);&#xA;         return true;&#xA;         }else&#xA;         {&#xA;           //dbgSerial.println(&quot;Can not connect to the WiFi.&quot;);&#xA;           Serial.println(&quot;Can not connect to the WiFi.&quot;);&#xA;           return false;&#xA;         }&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13457" LastActivityDate="2016-12-21T21:19:54.867" Title="Issue while connecting ESP8266 with Arduino Mega. It always says “Module have no response.”" Tags="|arduino-mega|wifi|esp8266|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16171" PostTypeId="2" ParentId="13160" CreationDate="2015-09-18T11:33:52.027" Score="1" Body="&lt;h1&gt;Part 1: Can I increase the speed of the servo motor?&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;Solution #1 :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can run your servo motor at its maximum rated voltage, which will give you the fastest response. If angle is all you want, that should be ok. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solution #2 :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If speed control is just as important, you're better off using a &lt;a href=&quot;https://www.parallax.com/product/28819&quot; rel=&quot;nofollow&quot;&gt;DC motor with an encoder&lt;/a&gt;. You will have to write a PI control loop, but in return you will be granted a fine-tune control and potentially superior performance.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Solution #3 :&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you need to hold a physical load accurately at a certain angle, then I would go for a &lt;a href=&quot;http://www.adafruit.com/products/324&quot; rel=&quot;nofollow&quot;&gt;stepper motor&lt;/a&gt;. But you need to make sure that you do not overload it, as it will cause a misstep. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Part 2: Can I measure the current?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The simplest and cheapest method, is to connect a current sensing resistor to your servo and measure the potential difference using the analog input. Since the resistance is known, you can calculate the current using the formula I = V/R.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things to make sure: &#xA;1) Your resistor power rating is not exceeded.&#xA;2) The voltage difference has to be large enough to be measurable. (e.g. 2 ohm resistor gives .05V @ 100mA, .5V @ 1A and your Arduino analog input may have the resolution of roughly 0.005V)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What? Did I hear you say that the accuracy isn't good enough? Well actually you can buy an op amp to amplify to the scale that you need. Or to make life easier: buy one from &lt;a href=&quot;https://www.adafruit.com/products/904&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt;. :p &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="7282" LastEditDate="2015-09-18T11:48:14.003" LastActivityDate="2015-09-18T11:48:14.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16172" PostTypeId="1" CreationDate="2015-09-18T12:45:56.837" Score="1" ViewCount="2127" Body="&lt;p&gt;I wants to do in Arduino countdown that shows how many days, hours and minutes remaining to Friday 12:00.&#xA;In my program I used a function in php &lt;code&gt;strtotime('next friday')&lt;/code&gt; which thus could calculate differential timestamp and show how much time is left until Friday 12:00.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a function &lt;code&gt;strtotime('next friday')&lt;/code&gt; in Arduino?&#xA;I have RTC which gives me just the current date and time, but does not show the current day of the week.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&#xA;I have a solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have day of week. We multiplied by 86400.&lt;br /&gt;&#xA;We have an hour. We multiply by 3600.&lt;br /&gt;&#xA;We have a minute. We multiplied by 60.&lt;br /&gt;&#xA;Add everything.&lt;br /&gt;&#xA;Subtract this from 604800.&lt;br /&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;nextFriday  = 604800-((dayofweek * 86400)+(now.hour()*3600)+(now.minute()*60)+now.second());&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important, Friday is the number of the week &quot;0&quot;. Friday = 0; Saturday = 1; etc...&lt;/p&gt;&#xA;" OwnerUserId="2871" LastEditorUserId="2871" LastEditDate="2015-09-28T17:05:04.443" LastActivityDate="2019-05-13T15:45:10.927" Title="How to count the time until the next day of the week?" Tags="|programming|rtc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16173" PostTypeId="2" ParentId="16172" CreationDate="2015-09-18T13:11:16.573" Score="1" Body="&lt;p&gt;The key to working with time is to have a known &quot;base&quot; time to calculate everything relative to.  This is called the &lt;em&gt;epoch&lt;/em&gt;.  Different systems use different epochs, and each has advantages and disadvantages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I generally use the UNIX epoch in my programming (chiefly because I am a UNIX nut), which is the first of January, 1970 (01/01/1970).  This is year, month, day, hour, minute and second 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that you can then calculate the number of seconds between the epoch and any other time you choose as long as it is later than the epoch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate the day of the week for any given date you first need to know the day of the week for the epoch (for UNIX that's a Thursday) then work out how many days there are between the epoch and the target time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calculating real times in terms of seconds can be somewhat tricky due to leap years and daylight savings, but there are plenty of algorithms in the public domain, and many RTC libraries include functions to convert to/from epoch times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the &lt;a href=&quot;http://playground.arduino.cc/code/time&quot; rel=&quot;nofollow&quot;&gt;Arduino Time Library&lt;/a&gt; has functions to calculate weekdays, and to convert to &quot;time_t&quot; format (seconds since epoch) which can be used to work out differences in times.  For instance, if you know that it's Tuesday and you want next Friday then you know that Friday is 3 days in the future - so you can get the current time in seconds from the epoch then add to that 3 days' worth of seconds (3 × 60 × 60 × 24) to that time to get the same time of day next Friday.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-18T13:11:16.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16174" PostTypeId="2" ParentId="16161" CreationDate="2015-09-18T14:26:18.930" Score="1" Body="&lt;p&gt;You can reduce latency by using interrupts to detect input changes instead of polling in loop(), if you're dead set on using an Arduino instead of adding switching hardware (as suggested in other answers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;attachInterrupt()&lt;/a&gt; for details, and beware that different Arduino models differ greatly in how many pins support interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, you can speed up the polling approach by using &lt;a href=&quot;http://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;direct port access&lt;/a&gt; (e.g., PORTB and PORTD registers) instead of the simpler Arduino read and write functions.  This will bypass some wrapper code and also let you manipulate multiple pins in parallel.&lt;/p&gt;&#xA;" OwnerUserId="13461" LastActivityDate="2015-09-18T14:26:18.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16175" PostTypeId="2" ParentId="16165" CreationDate="2015-09-18T14:45:31.813" Score="3" Body="&lt;p&gt;It could be because &quot;millis()/1000&quot; generates a &quot;number&quot;, and not the &quot;string&quot; (or &quot;char&quot;). Try to add &quot;,DEC&quot; in your lcd.print(), something like &quot;millis()/1000,DEC&quot; to convert it to &quot;decimal&quot;. Generally, it depends on the library, how they implement this function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mike&lt;/p&gt;&#xA;" OwnerUserId="13462" LastActivityDate="2015-09-18T14:45:31.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16176" PostTypeId="1" AcceptedAnswerId="17077" CreationDate="2015-09-18T15:49:53.407" Score="1" ViewCount="1522" Body="&lt;p&gt;I'm trying to use my 30A ACS712 on my OSD (it has ATMEGA16L). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it is very unstable, 0 amps goes from 450 to 445, but that isn't that bad, but when I put 10A of current through it jumps from 440 to 380. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already searched on google and tried to add filter cap between acc and gnd, but it didn't help and acs712 and osd have different power supply than the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is welcome.&lt;/p&gt;&#xA;" OwnerUserId="13463" LastActivityDate="2016-01-29T04:37:22.763" Title="ACS712 inacurrate reading. Wild jumping" Tags="|current|adc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16177" PostTypeId="1" AcceptedAnswerId="16186" CreationDate="2015-09-18T17:39:21.900" Score="0" ViewCount="949" Body="&lt;p&gt;I'm using an Arduino Yun to read from a data file, which will then populate a data structure. The &lt;code&gt;file.read()&lt;/code&gt; function &quot;&lt;em&gt;returns: The next byte (or character), or -1 if none is available.&lt;/em&gt;&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This functionality is identical to the &lt;code&gt;SD.read()&lt;/code&gt; function in the SD card library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data file will never have any value that exceeds 1 byte with all numbers in the range 0-255. If I print these numbers as a long string in the data file, each character is read as a byte. So I need to call &lt;code&gt;file.read()&lt;/code&gt; 3 times to read in a single 0-255 value. And then do some additional processing to construct the final 8-bit value for storing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could reduce this to 2 calls by printing the Hex code in the data file, but this isn't much of an improvement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is there a way to encode a full byte in a single character?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Effectively , is there a particular way I can format my data file so that I can read in an &lt;code&gt;8-bit unsigned&lt;/code&gt; value in a single call to &lt;code&gt;file.read()&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11537" LastEditorUserId="4628" LastEditDate="2015-09-22T12:08:11.493" LastActivityDate="2015-09-22T12:08:11.493" Title="Encoding an entire Byte for File Reading" Tags="|arduino-yun|sd-card|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16179" PostTypeId="2" ParentId="16177" CreationDate="2015-09-18T18:07:37.053" Score="0" Body="&lt;p&gt;This is a fragment (untested) of how you can do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char datafile[512];&#xA;int ch;&#xA;int index = 0;&#xA;&#xA;while ((ch = file.read()) != -1) {&#xA;  datafile[i] = (char)ch;&#xA;  if (++i == 512)&#xA;    break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-18T18:07:37.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16180" PostTypeId="2" ParentId="16161" CreationDate="2015-09-18T20:26:27.937" Score="0" Body="&lt;p&gt;Because this is digital I would like to add a third option in addition to Ignacio's and Nick's great suggestions. Use a logic device such as an FPGA or CPLD. This will require some extra knowledge and set up to get it working, but it is well suited for the functionality you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-09-18T20:26:27.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16181" PostTypeId="1" CreationDate="2015-09-18T20:50:19.303" Score="2" ViewCount="1133" Body="&lt;p&gt;I'm looking to create a USB device that would  be basically a HID keyboard. I am able to do that with Uno. I flash new firmware with a HID keyboard descriptor and on the arduino side I loop and check for button presses. Based on butotn presses I send the report.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to add to this is option to send some data from a PC and based on that data do something (like turn an LED on.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;  check_and_send_buttons();&#xA;  uint8_t inputByte = get_input(); //new&#xA;  handle_input(inputByte); //new&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm on Linux and I tried sending some data via hidrawX but that did not work out.&#xA;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm willing to also write new device driver for Linux if needed.&lt;/p&gt;&#xA;" OwnerUserId="13465" LastActivityDate="2015-09-18T21:56:13.707" Title="Uno as a composite USB HID keyboard" Tags="|arduino-uno|serial|usb|keyboard|input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16183" PostTypeId="2" ParentId="16172" CreationDate="2015-09-18T21:25:46.403" Score="0" Body="&lt;p&gt;&#xA;There are generic examples, e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week&quot; rel=&quot;nofollow noreferrer&quot;&gt;Determination of the day of the week - Wikipedia&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the C language expressions below, &lt;strong&gt;y&lt;/strong&gt;, &lt;strong&gt;m&lt;/strong&gt; and &lt;strong&gt;d&lt;/strong&gt; are, respectively, integer variables representing the year (e.g., 1988), month (1-12) and day of the month (1-31).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;        (d+=m&amp;lt;3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://stackoverflow.com/questions/6054016/c-program-to-find-day-of-week-given-date&quot;&gt;StackOverflow - C Program to find day of week given date&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="50940" LastEditDate="2019-05-13T15:45:10.927" LastActivityDate="2019-05-13T15:45:10.927" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="16184" PostTypeId="2" ParentId="16181" CreationDate="2015-09-18T21:56:13.707" Score="1" Body="&lt;p&gt;On UNO R3 the HID protocol is handled by the secondary AVR present on the board. Which is the one talking to the PC. So what you should modify is the code implementing the USB protocol on the secondary AVR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main (328p) AVR interacts with it through the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not need to alter the Linux driver, since it already supports the driving of the usual LEDs (CAPS, Num Lock, Scroll Lock), if these are enough for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to recap:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) enhance the HID implementation to understand LED status commands coming from the PC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) report such changes over serial&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) on the primary AVR, monitor for such messages coming over serial port from the secondary AVR and use them to drive the LEDs.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-18T21:56:13.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16185" PostTypeId="2" ParentId="2967" CreationDate="2015-09-19T00:32:13.303" Score="1" Body="&lt;p&gt;&lt;strong&gt;blah&lt;/strong&gt; reported:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So I was just hacking around and I finally figured out what went wrong! Apparently, there's a switch &quot;XBEE/USB&quot; that needs to be switched to XBEE for BOTH shields. After that, everything works as planned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can someone vote this up please to remove it from the unanswered queue?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-19T00:32:13.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16186" PostTypeId="2" ParentId="16177" CreationDate="2015-09-19T09:48:25.540" Score="0" Body="&lt;p&gt;There's two parts to what you want to do, writing the file in the right form, and reading that format file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format of file is known as &lt;em&gt;raw binary&lt;/em&gt;. Every byte in the file can store a separate value between 0 and 255, or between -128 and 127, dependin on how you interpret the data.  At the end of the day, every byte in a file is just a collection of 8 bits yielding 2^8 = 256 combinations. What those combinations actually mean is more of a human thing than a machine thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We, as humans, have decided upon three main representations of those bytes: &lt;em&gt;unsigned&lt;/em&gt; numbers from 0 to 255, &lt;em&gt;signed&lt;/em&gt; numbers from -128 to 127 (lookup two's complement) and finally ASCII characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ASCII characters are more of a lookup table placed over one of the other two representations. Some systems use unsigned bytes and some signed bytes for the basis of that lookup tabe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing text into the file results in looking up the corresponding byte values for each character in that text and placing those values in the file. When you read the file the reverse is done - the byte values are read and you look them up in the ASCII table to find the corresponding letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To store just numbers between 0 and 255 it is far more efficient to bypass that ASCII table and store the values directly as bytes. How you do that is entirely dependent on what language you are writing your software in. Since you haven't mentioned what that language is I can't advise you on that front' only give some examples in languages I know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such as in C you would store your data in an array of &lt;em&gt;unsigned char&lt;/em&gt; or &lt;em&gt;uint8_t&lt;/em&gt;. You then use the &lt;code&gt;write()&lt;/code&gt; function to write raw data to the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Perl you might use the &lt;code&gt;pack()&lt;/code&gt; function to store your values as bytes in a string then write that string to a file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When reading the data you are presented with a raw value. That may be given to you as a signed or an unsigned value depending on the underlying system. I don't know what the yun is off hand. Converting from whatever is handed to you by thr &lt;code&gt;file.read()&lt;/code&gt; function to what you expect it to be though is a very simple matter, and is called &lt;em&gt;casting&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int in = file.read();&#xA;uint8_t bval = (uint8_t)in;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The bit in brackets is the &lt;em&gt;cast&lt;/em&gt; which converts the value in the integer &lt;em&gt;in&lt;/em&gt; into a uint8_t (Unsigned INTeger 8-bit Type) which corresponds to whatever you wrote as an unsigned char or uint8_t at the other end.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-19T09:48:25.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16188" PostTypeId="1" AcceptedAnswerId="16189" CreationDate="2015-09-19T11:28:49.523" Score="0" ViewCount="107" Body="&lt;p&gt;I'm preparing &lt;a href=&quot;http://www.ebay.com/cln/stancheg/rgb-led-cube/234958035011&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; kit on eBay to create the following instructable - &lt;a href=&quot;http://www.instructables.com/id/4x4x4-RGB-LED-Cube/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/4x4x4-RGB-LED-Cube/&lt;/a&gt;&#xA;But I have doubts about 0.1uF and 22pF capacitors since the once on eBay are 50v. Also MOSFETs - instructable uses IRF9531 but the ones I found on eBay are IRF9540N.&#xA;Is the equipment I added on eBay compatible with instructable?&lt;/p&gt;&#xA;" OwnerUserId="13475" LastEditorUserId="13475" LastEditDate="2015-09-19T11:47:44.577" LastActivityDate="2015-09-19T14:02:49.153" Title="Verify RGB Led Cube equipment" Tags="|arduino-uno|rgb-led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16189" PostTypeId="2" ParentId="16188" CreationDate="2015-09-19T12:21:10.453" Score="1" Body="&lt;p&gt;Capacitor ratings don't really matter in your case, as you are using only 5 volt. Only their values (F) do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though the crystal you selected has an indication it needs 20pF load capacitors, not 22pF. 22pF is probably still fine. (Also note the ±20% accuracy, so between 17.6 and 26.4pF)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IRF9531 and IRF9540N have the same pinout. They are also pretty similar in specs. The IRF9540N is slightly better even.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the ATMega328p doesn't have the bootloader pre-installed. It's not that hard to do yourself though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The EEPROM you selected is an SMD version. Kind of hard to work with if you are still a beginner. Better use a &lt;a href=&quot;http://www.ebay.com/itm/2PCS-AT24C256-10PU-2-7-DIP-8-24C256-PU27-2-Wire-Serial-EEPROM-GOOD-QUALIITY-/311362511891?hash=item487ea6e413&quot; rel=&quot;nofollow&quot;&gt;DIP version&lt;/a&gt; instead (that one is a bit more expensive, but 4 times the size)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest you add an &lt;a href=&quot;http://www.ebay.com/itm/FT232RL-FTDI-Serials-Adapter-Module-Mini-Port-f-Arduino-USB-TTL-3-3V-5-5V-/311406775045?hash=item48814a4b05&quot; rel=&quot;nofollow&quot;&gt;USB to Serials Adapter&lt;/a&gt; to the list, so you don't need the Arduino Uno every time you want to reprogram it, and use the Uno for something more useful.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-09-19T12:21:10.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16190" PostTypeId="2" ParentId="9857" CreationDate="2015-09-19T13:02:33.223" Score="2" Body="&lt;p&gt;Yet another solution is to implement a dummy Serial device. That would be a class that as HardwareSerial inherits from Stream and implements the necessary virtual member functions with dummy functions. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class NullSerial : public Stream {&#xA;public:&#xA;  virtual size_t write(uint8_t) { return (1); }&#xA;  virtual int available() { return (0); }&#xA;  virtual int read() { return (0); }&#xA;  virtual int peek() { return (0); }&#xA;  virtual void flush() {}&#xA;  ...&#xA;  void begin(unsigned long, uint8_t) {}&#xA;  void end() {}&#xA;  ...&#xA;};&#xA;&#xA;NullSerial Serial;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As Serial is not defined as a weak symbol the application would need to use a Steam variable for output. And bind this to the HardwareSerial or the NullSerial.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(DEBUG)&#xA;Stream&amp;amp; trace = Serial;&#xA;#else&#xA;NullSerial noSerial;&#xA;Stream&amp;amp; trace = noSerial;&#xA;#else&#xA;&#xA;#endif&#xA;...&#xA;trace.print(42);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not complete as all the HardwareSerial member functions (that the sketch uses) are needed but gives the general idea how to use OOP to solve the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-09-19T13:02:33.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16191" PostTypeId="2" ParentId="16188" CreationDate="2015-09-19T14:02:49.153" Score="1" Body="&lt;p&gt;For a crystal with 20pF load capacitance you need 40pF capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula used is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cx1 = Cx2 = 2(CL - Cpara)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;CL is 20pF and Cpara is the parasitic capacitance of the circuitry involved. Under most amateur circumstances that can be ignored.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-19T14:02:49.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16192" PostTypeId="1" CreationDate="2015-09-19T14:39:06.030" Score="3" ViewCount="5534" Body="&lt;p&gt;I'm supplying power to Arduino via PC USB.&lt;/p&gt;&#xA;" OwnerUserId="13478" LastEditorUserId="10794" LastEditDate="2015-09-19T21:20:12.673" LastActivityDate="2015-09-19T21:20:12.673" Title="Can both the 3.3V and 5V pins on the Arduino be used at once for power?" Tags="|arduino-uno|power|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16193" PostTypeId="2" ParentId="16192" CreationDate="2015-09-19T15:46:45.513" Score="5" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a block diagram of how the Arduino power is arranged:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xhngd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xhngd.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the USB power is fed through a FET (P-channel MOSFET) to isolate it when there is external power applied (as decided by the comparator &lt;em&gt;COMP&lt;/em&gt;).  External power is fed through a 5V regulator and is fed to the same point as the USB power.  Thus you get the same 5V at the same point regardless of if you have USB or Barrel Jack power.  From there the 5V (wherever it comes from) is fed into a 3.3V regulator.  The 5V pin on the Arduino is connected directly to the 5V point where the USB and the 5V regulated input are connected. The 3.3V pin is connected directly to the output of the 3.3V regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no matter what input power arrangement you use - barrel jack, USB power, battery connected to the V IN pin (not shown, but connects to the barrel jack), or regulated 5V into the 5V pin, you get access to the same 5V and 3.3V power on the 5V and 3.3V power pins.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-19T20:28:22.123" LastActivityDate="2015-09-19T20:28:22.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16194" PostTypeId="1" AcceptedAnswerId="16197" CreationDate="2015-09-19T15:57:20.720" Score="2" ViewCount="19186" Body="&lt;p&gt;I'm trying to get a ESP8266 board with 2x4 pins to work. I'm connecting it to an Olimexino 32u4 (Leonardo-compatible), configured to use 3.3V. This simple snippet I use to transfer everything to the PC (CH_PD is connected to D8, /RST to D9):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  digitalWrite(8, LOW);&#xA;  digitalWrite(9, LOW);&#xA;  delay(2000);&#xA;  // initialize both serial ports:&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(115200);&#xA;  delay(10000);&#xA;  digitalWrite(9, HIGH);&#xA;  digitalWrite(8, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read from port 1, send to port 0:&#xA;  if (Serial1.available()) {&#xA;    int inByte = Serial1.read();&#xA;    Serial.write(inByte);&#xA;  }&#xA;&#xA;  // read from port 0, send to port 1:&#xA;  if (Serial.available()) {&#xA;    int inByte = Serial.read();&#xA;    Serial1.write(inByte);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When launching, I see following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&quot;random&quot; bytes&amp;gt;&#xA;Ai-Thinker Technology Co. Ltd.&#xA;&#xA;invalid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Performing a reset shows more:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RST&#xA;&#xA;&#xA;OK&#xA;&#xA; ets Jan  8 2013,rst cause:2, boot mode:(3,6)&#xA;&#xA;load 0x40100000, len 1396, room 16 &#xA;tail 4&#xA;chksum 0x89&#xA;load 0x3ffe8000, len 776, room 4 &#xA;tail 4&#xA;chksum 0xe8&#xA;load 0x3ffe8308, len 540, room 4 &#xA;tail 8&#xA;chksum 0xc0&#xA;csum 0xc0&#xA;&#xA;2nd boot version : 1.4(b1)&#xA;  SPI Speed      : 40MHz&#xA;  SPI Mode       : QIO&#xA;  SPI Flash Size &amp;amp; Map: 8Mbit(512KB+512KB)&#xA;jump to run user1 @ 1000&#xA;&#xA;ŒÂÕ�MEM CHECK FAIL!!!&#xA;äsl�‚rô&#xA;Ai-Thinker Technology Co. Ltd.&#xA;&#xA;invalid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mode is set to station:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWMODE?&#xA;&#xA;+CWMODE:1&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Listing the access points works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWLAP&#xA;&#xA;+CWLAP:(3,&quot;ap-1&quot;,-91,&quot;01:23:45:67:89:ab&quot;,1)&#xA;+CWLAP:(3,&quot;ap-2&quot;,-88,&quot;cd:ef:01:23:45:67&quot;,2)&#xA;+CWLAP:(3,&quot;ap-3&quot;,-74,&quot;89:ab:cd:ef:01:23&quot;,11)&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But logging in to my Fritzbox router fails (WPA2):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWJAP=&quot;ap-2&quot;,&quot;mypassword&quot;&#xA;WIFI CONNECTED&#xA;+CWJAP:1&#xA;&#xA;FAIL&#xA;WIFI DISCONNECT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First I thought the reason is the low signal, but even moving directly beside the Fritzbox shows the same result (though with higher signal value in &lt;code&gt;AT+CWLAP&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried nearly everything, e.g. &lt;code&gt;AT+CWMODE=3&lt;/code&gt;, &lt;code&gt;AT+RST&lt;/code&gt;, &lt;code&gt;AT+RESTORE&lt;/code&gt;). Nothing changes. When using a wrong password, I'm getting no &quot;WIFI CONNECTED&quot; messages at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could it be a power problem (that the Olimexino can't provide up to 200mA at the 3.3V line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting from my smartphone to the ESP8266 in one of its access point modes (2 or 3) works fine. If there were power problems, wouldn't then the access point mode fails as well?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2015-09-19T19:44:36.583" LastActivityDate="2020-09-16T18:41:46.567" Title="ESP8266 failure to connect to router" Tags="|esp8266|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16195" PostTypeId="1" AcceptedAnswerId="16199" CreationDate="2015-09-19T17:07:26.590" Score="0" ViewCount="2026" Body="&lt;p&gt;I just changed the router for my webserver and I'm having trouble to connect my arduino with the LAN.&#xA;I'm using a router which uses Zhone technology, and I've been working with NetGear for a while without problems.&#xA;The procedure I've done so far is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect the arduino with the ethernet and run the DhcpAdressPrinter example&lt;/li&gt;&#xA;&lt;li&gt;Once I got the adress, in my case 192.168.1.125 I run the WebServer example, using the IP assigned by the DHCP.&lt;/li&gt;&#xA;&lt;li&gt;In the serial monitor, I see it has started the program with the correct IP.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Problem: WHEN PUTTING THE IP INTO A BROWSER, NOTHING CHARGES&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In my router page (192.168.1.1) I can see that each ethernet port has&#xA;assigned a MAC adress, I don't really understand why.  &lt;/li&gt;&#xA;&lt;li&gt;I also can see that the arduino has been successfully added to the DHCP with the IP assigned and the MAC adress that I wrote on the code&lt;/li&gt;&#xA;&lt;li&gt;Finally, add that I've read in another website that sometimes the problem is due to the fact that the router just let the access to some specific MAC adress, but i'm not sure. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any help will be apreciated! Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13316" LastActivityDate="2015-09-20T09:53:23.883" Title="Connect my arduino with ethernet shield to new router" Tags="|ethernet|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16197" PostTypeId="2" ParentId="16194" CreationDate="2015-09-19T20:25:06.500" Score="5" Body="&lt;p&gt;It looks like the ESP8266 could not obtain the IP address over DHCP (it was enabled in the ESP8266, but the Fritzbox was configured for a limited range only .200 - .209). When setting the IP explicitly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CIPSTA=&quot;192.168.92.82&quot;,&quot;192.168.92.254&quot;,&quot;255.255.255.0&quot;&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then trying to connect, it worked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWJAP=&quot;ap-2&quot;,&quot;mypassword&quot;&#xA;WIFI CONNECTED&#xA;WIFI GOT IP&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pinging also works now: :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+PING=&quot;arduino.stackexchange.com&quot;&#xA;&#xA;+39&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2015-09-19T20:25:06.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16198" PostTypeId="1" CreationDate="2015-09-19T22:28:17.560" Score="2" ViewCount="158" Body="&lt;p&gt;I'm using a DOGM163 Display. It works in a DEMO sketch provided by the manufacturer but not in my sketch. This is strange, because I am using the same library specific commands as in the example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think of the following possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Something inside the other libraries I use in my sketch is hindering the dogm from working (perhaps by fiddling around with the ports connected to the display).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I've got a power problem which surfaces when doing more than just that demo.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Timing is botched.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Something with my wiring is wrong. Perhaps in conjunction with 1). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;newsched.h&quot;&#xA;#include &quot;dplan.h&quot;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;PinChangeInt.h&amp;gt;&#xA;#include &amp;lt;dogm_7036.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &quot;lampcontrol.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Power seems to be ok, as I'm receiving all debug messages via serial correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display is sharing its port with a port expander and a SD-port. But removing the SD-port doesn't change the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update (Part1)&lt;/strong&gt;&#xA;Here comes the code, which works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/eXUVzeV8&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://pastebin.com/eXUVzeV8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a slightly modified manufacturer example. But it does what it should do. It displays the demo text. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here comes, what doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/MCsyDUXL&quot; rel=&quot;nofollow noreferrer&quot;&gt;Main sketch&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/1xSNGhCs&quot; rel=&quot;nofollow noreferrer&quot;&gt;newsched.h&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/UCPuyG08&quot; rel=&quot;nofollow noreferrer&quot;&gt;newsched.cpp&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/cKCErjHR&quot; rel=&quot;nofollow noreferrer&quot;&gt;display.h&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/dvVWdJAK&quot; rel=&quot;nofollow noreferrer&quot;&gt;display.cpp&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/278UYXGu&quot; rel=&quot;nofollow noreferrer&quot;&gt;menu.h&lt;/a&gt;&#xA;&lt;a href=&quot;http://pastebin.com/PhYikzBP&quot; rel=&quot;nofollow noreferrer&quot;&gt;menu.cpp&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other source files, 19 in total!, can be posted on request, but as you can see from newsched.cpp I already disabled most of the code to narrow down the error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What exactly means &quot;not work&quot;? Not work means, the display seems to be turned off. The LED backlight is on, but you cannot see the grey character boxes (due to display bias), which appear in the working code sample. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;&#xA;Schematic: &lt;a href=&quot;https://i.stack.imgur.com/PcBLd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PcBLd.jpg&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2015-09-20T09:41:27.240" LastActivityDate="2015-09-20T09:41:27.240" Title="Display unresponsive in one sketch, while working in another" Tags="|arduino-uno|display|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16199" PostTypeId="2" ParentId="16195" CreationDate="2015-09-20T09:53:23.883" Score="0" Body="&lt;p&gt;Finally, I was capable to solve it by just creating a port forwarding with the IP that was assigned by the DCHP. &#xA;It looks like my router for security reasons don't let you comunicate with other devices within the lan, so it's necessary to open a port and access the device through it!&lt;/p&gt;&#xA;" OwnerUserId="13316" LastActivityDate="2015-09-20T09:53:23.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16200" PostTypeId="1" AcceptedAnswerId="16201" CreationDate="2015-09-20T10:43:44.467" Score="0" ViewCount="95" Body="&lt;p&gt;I'm quite new to Arduino. I have build a number of projects successfully, like potentiometers, serial communication, DAC, sensors, motors etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a laptop to power my Arduino project and Atmel Studio to program and upload to the Arduino. I have created a project with 2 motors and I have successfully used a separate power supply (a transformer) to power the motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to continue my experiments but I'm afraid of the possibility to cause any problem to my laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I made the circuit with the 2 power sources (laptop for the Arduino, transformer for the motors) I had to connect the 2 grounds together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Can someone explain me or point me to some information about power electronics so to be absolutely sure that I won't cause any problem to the laptop?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I use optocouplers, or diodes etc? Is there a way to avoid the 2 grounds connection? What is the reason to connect both grounds (of the 2 power supplies) in the first place? &lt;/p&gt;&#xA;" OwnerDisplayName="user13309" LastEditorUserId="10794" LastEditDate="2015-09-20T22:33:17.847" LastActivityDate="2015-09-20T22:33:17.847" Title="safety for power electronics" Tags="|power|hardware|electronics|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16201" PostTypeId="2" ParentId="16200" CreationDate="2015-09-20T11:39:26.357" Score="3" Body="&lt;p&gt;Connecting the grounds together is required since without that there would be no circuit for the current to flow through.  Take this simple block diagram for instance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0uyFv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0uyFv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the top diagram there are two complete circuits - the green one (Arduino's 5V power) and the blue one (device's 12V power).  The communication between the Arduino and the Device can't happen because there is no circuit (red).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the bottom diagram the red circuit has been completed by joining the grounds together.  That means that the current has some way to get back to where it came from (which current always &lt;em&gt;has&lt;/em&gt; to do) so the signals you send can actually get through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid having to connect the grounds together you need something called &lt;em&gt;Galvanic Isolation&lt;/em&gt;.  This involves using some method that is not electricity to connect the two circuits together.  That could be using light in the form of an opto-coupler, or magnetism in the form of a transformer, or even something even more physical like a relay.  In that situation you have an arrangement like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/G9hvY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G9hvY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ground connection that was part of the red circuit above has now been sliced in half (red and orange now) and the isolation device is responsible for passing the signal from one side to the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Galvanic isolation is highly desirable when:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are controlling a different &lt;em&gt;type&lt;/em&gt; of current (e.g., using DC to switch AC)&lt;/li&gt;&#xA;&lt;li&gt;You are working with voltages considerably higher than your drive voltage (e.g., switching mains)&lt;/li&gt;&#xA;&lt;li&gt;You have different ground potentials (e.g., you have a long distance connection)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-20T11:39:26.357" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16203" PostTypeId="1" CreationDate="2015-09-20T12:26:50.580" Score="3" ViewCount="4379" Body="&#xA;&#xA;&lt;p&gt;I'm trying to connect Arduino with MySQL database on my online server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I manage my project to work on WampServer locally on localhost, but when I try to move everything online I have problem... on the serial monitor I get the message that the server is connected and my sensor readings, but I can't put them in to my database on my online sever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;dbconnect.php&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?php&#xA;$MyUsername = &quot;*******&quot;;  // enter your username for mysql&#xA;$MyPassword = &quot;*******%&quot;;  // enter your password for mysql&#xA;$MyHostname = &quot;*************&quot;;      // this is usually &quot;localhost&quot; unless your database resides on a different server&#xA;&#xA;$dbh = mysql_pconnect($MyHostname , $MyUsername, $MyPassword);&#xA;$selected = mysql_select_db(&quot;tanjamayaarduino&quot;,$dbh);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;add_data.php&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;&amp;lt;?php&#xA;    // Connect to MySQL&#xA;    include(&quot;dbconnect.php&quot;);&#xA;&#xA;    // Prepare the SQL statement&#xA;    $SQL = &quot;INSERT INTO tanjamayaarduino.temperature (sensor ,celsius, light, moisture1, moisture2) VALUES ('&quot;.$_GET[&quot;serial&quot;].&quot;', '&quot;.$_GET[&quot;temperature&quot;].&quot;','&quot;.$_GET[&quot;light&quot;].&quot;','&quot;.$_GET[&quot;moisture1&quot;].&quot;','&quot;.$_GET[&quot;moisture2&quot;].&quot;')&quot;;     &#xA;&#xA;    // Execute SQL statement&#xA;    mysql_query($SQL);&#xA;&#xA;    // Go to the review_data.php (optional)&#xA;    header(&quot;Location: review_data.php&quot;);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;Ethernet.h&amp;gt;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;const int temperaturePin = A3;    //LM35 Temperature sensor&#xA;const int lightPin = A2;          //LDR photoresistor sensor&#xA;const int moisture1Pin = A4;          //Moisture1 sensor&#xA;const int moisture2Pin = A5;          //Moisture2 sensor&#xA;&#xA;// **** ETHERNET SETTING ****&#xA;// Arduino Uno pins: 10 = CS, 11 = MOSI, 12 = MISO, 13 = SCK&#xA;// Ethernet MAC address - must be unique on your network - MAC Reads T4A001 in hex (unique in your network)&#xA;byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x3A, 0xDC };&#xA;// For the rest we use DHCP (IP address and such)&#xA;IPAddress ip(192, 168, 2, 121);&#xA;EthernetClient client;&#xA;//IPAddress server(192, 168, 2, 100); // IP Adres (or name) of server to dump data to  &#xA;// IP Adres (or name) of server to dump data to  (godaddy baza server 37.148.204.140) (User: tanjamayaarduino@188.121.42.33) (goddady glavna adresa na hostingot 188.121.46.1) &#xA;//IPAddress server(188, 121, 46, 1); &#xA;char server[] = &quot;188.121.46.1&quot;;&#xA;&#xA;&#xA;int  interval = 5000; // Wait between dumps&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    // try to congifure using IP address instead of DHCP:&#xA;    Ethernet.begin(mac, ip);&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Tweaking4All.com - Temperature Drone - v2.0&quot;);&#xA;  Serial.println(&quot;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n&quot;);&#xA;  Serial.print(&quot;IP Address        : &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;  Serial.print(&quot;Subnet Mask       : &quot;);&#xA;  Serial.println(Ethernet.subnetMask());&#xA;  Serial.print(&quot;Default Gateway IP: &quot;);&#xA;  Serial.println(Ethernet.gatewayIP());&#xA;  Serial.print(&quot;DNS Server IP     : &quot;);&#xA;  Serial.println(Ethernet.dnsServerIP());&#xA;}&#xA;&#xA;void loop() {&#xA;  // if you get a connection, report back via serial:&#xA;  if (client.connect(server, 80)==1) {&#xA;    float tem = getTemp();&#xA;    Serial.println( tem );&#xA;    float lig = getLight();&#xA;    Serial.println( lig );&#xA;    float mois1 = getMoisture1();&#xA;    Serial.println( mois1 );&#xA;    float mois2 = getMoisture2();&#xA;    Serial.println( mois2 );&#xA;&#xA;    Serial.println(&quot;-&amp;gt; Connected&quot;);&#xA;    if (client.connected()) {&#xA;      // Make a HTTP request:&#xA;      client.print( &quot;GET /advertacs/test/arproekt/add_data.php?&quot;);&#xA;      Serial.println(&quot;-&amp;gt; add_data&quot;);&#xA;      client.print(&quot;serial=&quot;);&#xA;      client.print( &quot;TempSensor&quot; );&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;temperature=&quot;);&#xA;      client.print( tem);&#xA;      Serial.println(&quot;-&amp;gt; add_temp&quot;);&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;light=&quot;);&#xA;      client.print( lig);&#xA;      Serial.println(&quot;-&amp;gt; add_light&quot;);&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;moisture1=&quot;);&#xA;      client.print( mois1);&#xA;      Serial.println(&quot;-&amp;gt; add_mois1&quot;);&#xA;      client.print(&quot;&amp;amp;&amp;amp;&quot;);&#xA;      client.print(&quot;moisture2=&quot;);&#xA;      client.print( mois2);&#xA;      Serial.println(&quot;-&amp;gt; add_moi2&quot;);&#xA;&#xA;      client.println( &quot; HTTP/1.1&quot;);&#xA;      client.println( &quot;Host:&quot; );&#xA;      client.println(server);&#xA;      client.println( &quot;Connection: close&quot; );&#xA;      client.println();&#xA;      client.println();&#xA;      client.stop();&#xA;    }&#xA;  }&#xA;  else {&#xA;    // you didn't get a connection to the server:&#xA;    Serial.println(&quot;--&amp;gt; connection failed/n&quot;);&#xA;  }&#xA;&#xA;  delay(interval);&#xA;}&#xA;float getTemp() {&#xA;  float temperatureC = (5.0 * analogRead(temperaturePin) * 100.0) / 1024; //converting from a 0 to 1023 digital range to 0 to 5 volts (each 1 reading equals ~ 5 millivolts&#xA;  return temperatureC;&#xA;}&#xA;float getLight() {&#xA;  float light;&#xA;  light = analogRead(lightPin) ;&#xA;  return light;&#xA;}&#xA;&#xA;float getMoisture1() {&#xA;  float moisture1;&#xA;  moisture1 = analogRead(moisture1Pin) ;&#xA;  return moisture1;&#xA;}&#xA;float getMoisture2() {&#xA;  float moisture2;&#xA;  moisture2 = analogRead(moisture2Pin) ;&#xA;  return moisture2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13497" LastEditorUserId="10794" LastEditDate="2015-09-20T22:13:03.243" LastActivityDate="2018-12-31T07:08:03.597" Title="Connect Arduino to MySQL database online problem" Tags="|arduino-uno|sensors|c++|datalogging|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="16204" PostTypeId="1" AcceptedAnswerId="16212" CreationDate="2015-09-20T14:59:10.593" Score="0" ViewCount="3778" Body="&lt;p&gt;I'm not sure if this is more of an C++ question, but I've looked up both and still have no idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a sketch which controls 6 stepper motors using the AccelStepper library and in order to shorten the code, I would like to simply loop over them, or pass them to a function individually. They are all initialised with different parameters and then placed in an array. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I get the error &quot;conversion from ‘SomeClass()’ to non-scalar type ‘SomeClass’ requested&quot; or &quot;conversion from ‘SomeClass (*)()’ to non-scalar type ‘SomeClass’ requested&quot; depending on what I try. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got experience with C and Java, not much C++ and I thought it would be a straightforward array of pointers, but I can't get the right combination. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made a cut down version that I try to compile with gcc to demonstrate either approach. I've removed all attempts at pointers with &amp;amp; or * to explain what I want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SomeClass classA();&#xA;SomeClass classB();&#xA;&#xA;// error: conversion from ‘SomeClass()’ to non-scalar type ‘SomeClass’ requested&#xA;SomeClass things[2] = {classA, classB};&#xA;&#xA;int init(class SomeClass thing) {&#xA;    std::cout &amp;lt;&amp;lt; &quot;Setting up thing &quot;;&#xA;    thing.setFoo(100);&#xA;}&#xA;&#xA;int main() {&#xA;&#xA;    for (int i=0; i &amp;lt; 2; i++) {&#xA;        things[i].setFoo(100);&#xA;    }&#xA;&#xA;    // could not convert ‘classA’ from ‘SomeClass (*)()’ to ‘SomeClass’&#xA;    init(classA);&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And just for completeness my class files which are simplified versions of the AccelStepper class:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SomeClass.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;class SomeClass&#xA;{&#xA;public:&#xA;    SomeClass();&#xA;&#xA;    void    setFoo(float foo);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SomeClass.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;#include &quot;SomeClass.h&quot;&#xA;&#xA;SomeClass::SomeClass()&#xA;{&#xA;}&#xA;&#xA;void SomeClass::setFoo(float foo)&#xA;{&#xA;    std::cout &amp;lt;&amp;lt; &quot;foo &quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope someone doesn't mind explaining what is probably really simple and obvious! :) &lt;/p&gt;&#xA;" OwnerUserId="13498" LastEditorUserId="37523" LastEditDate="2019-12-03T17:06:30.383" LastActivityDate="2019-12-03T17:06:30.383" Title="How to loop over objects or pass object to function?" Tags="|c++|class|gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16205" PostTypeId="1" AcceptedAnswerId="16208" CreationDate="2015-09-20T15:30:12.173" Score="0" ViewCount="160" Body="&lt;p&gt;I connected 4x716 Coreless DC Motors on pin 13,12,11,10 and 1xGY-521 to  Arduino Pro Mini 328, 5v but speed of propellers is not enough to produce enough torque to lift the quad whereas when i connect then  directly to 3.3v LiPo battery the quad has lift but because of no flight control it moves randomly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the voltage of pin 13,12... they have output as 0.5-0.6v, I think this is the reason quad is not lifting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using following code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MPU-6050 Short Example Sketch&#xA;// By Arduino User JohnChi&#xA;// August 17, 2014&#xA;// Public Domain&#xA;#include&amp;lt;Wire.h&amp;gt;&#xA;const int MPU=0x68;  // I2C address of the MPU-6050&#xA;int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;&#xA;&#xA;&#xA;int p1 = 13;&#xA;int p2 = 12;&#xA;int p3 = 11;&#xA;int p4 = 10;&#xA;&#xA;void setup(){&#xA;  Wire.begin();&#xA;  Wire.beginTransmission(MPU);&#xA;  Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;  Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;  Wire.endTransmission(true);&#xA;    pinMode(p1, OUTPUT);&#xA;  pinMode(p2, OUTPUT);&#xA;  pinMode(p3, OUTPUT);&#xA;  pinMode(p4, OUTPUT);&#xA;  digitalWrite(p1, 0);&#xA;  analogWrite(p2, 0);&#xA;  analogWrite(p3, 0);&#xA;  analogWrite(p4, 0);&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;void loop(){&#xA;  Wire.beginTransmission(MPU);&#xA;  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)&#xA;  Wire.endTransmission(false);&#xA;  Wire.requestFrom(MPU,14,true);  // request a total of 14 registers&#xA;  AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C (ACCEL_XOUT_L)    &#xA;  AcY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;  AcZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;  Tmp=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x41 (TEMP_OUT_H) &amp;amp; 0x42 (TEMP_OUT_L)&#xA;  GyX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x43 (GYRO_XOUT_H) &amp;amp; 0x44 (GYRO_XOUT_L)&#xA;  GyY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x45 (GYRO_YOUT_H) &amp;amp; 0x46 (GYRO_YOUT_L)&#xA;  GyZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x47 (GYRO_ZOUT_H) &amp;amp; 0x48 (GYRO_ZOUT_L)&#xA;  Serial.print(&quot;AcX = &quot;); Serial.print(AcX);&#xA;  Serial.print(&quot; | AcY = &quot;); Serial.print(AcY);&#xA;  Serial.print(&quot; | AcZ = &quot;); Serial.print(AcZ);&#xA;  Serial.print(&quot; | Tmp = &quot;); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet&#xA;  Serial.print(&quot; | GyX = &quot;); Serial.print(GyX);&#xA;  Serial.print(&quot; | GyY = &quot;); Serial.print(GyY);&#xA;  Serial.print(&quot; | GyZ = &quot;); Serial.println(GyZ);&#xA;&#xA;   digitalWrite(p1, HIGH);&#xA;  analogWrite(p2, 250);&#xA;  analogWrite(p3, 255);&#xA;  analogWrite(p4, 255);&#xA;&#xA;&#xA;  delay(333);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13500" LastActivityDate="2015-09-23T06:02:40.540" Title="Arduino Delivering less power" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16206" PostTypeId="2" ParentId="16203" CreationDate="2015-09-20T15:36:04.590" Score="2" Body="&lt;p&gt;There are two basic things wrong with your code.  First is the formatting of your headers - you have mistakenly used &lt;code&gt;client.println&lt;/code&gt; for sending the first part of the Host: header, so it becomes split onto two lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println( &quot;Host:&quot; );&#xA;client.println(server);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Secondly you are using the server's IP address instead of the actual host name in the Host: header. That means the server can't work out which website you are wanting to talk to and just rejects your request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to have something more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.print(&quot;Host: &quot;);&#xA;client.println(servername);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;servername&lt;/code&gt; is the &lt;em&gt;name&lt;/em&gt; of the server (&lt;code&gt;www.website.com&lt;/code&gt;) &lt;em&gt;not&lt;/em&gt; the IP address.  You can put it all in one line if you don't ever want to change the website name, since it makes it slightly harder to find and edit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;Host: www.mywebsite.com&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-20T15:36:04.590" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16207" PostTypeId="1" AcceptedAnswerId="16221" CreationDate="2015-09-20T15:36:05.993" Score="1" ViewCount="4146" Body="&lt;pre&gt;&lt;code&gt;if (Serial.available()) {&#xA;        digitalWrite(7, HIGH);&#xA;} else {&#xA;        digitalWrite(7, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't seem to be so simple.&#xA;My testing LED turns on when the USB connection with another program is established, but it doesn't turn off (LOW) when that program exits.&lt;/p&gt;&#xA;" OwnerUserId="13501" LastEditorUserId="6936" LastEditDate="2015-09-22T12:08:06.313" LastActivityDate="2015-09-22T12:08:06.313" Title="To know the state of USB (Serial) connection (connected or not connected)" Tags="|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16208" PostTypeId="2" ParentId="16205" CreationDate="2015-09-20T15:45:17.410" Score="2" Body="&lt;p&gt;Atmega328 output pins are rated at 40 mA absolute-maximum current, and the 328's total current through Vcc and ground pins is 200 mA absolute max.  Eg, see table 29.1 in the Atmega328 specs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although &lt;a href=&quot;http://www.quadkopters.com/product/diy-kit/716-coreless-dc-motor-high-speed-x-4/&quot; rel=&quot;nofollow&quot;&gt;some sources&lt;/a&gt; rate a high-speed 716 coreless dc motor at 40 mA, &lt;a href=&quot;http://www.seeedstudio.com/depot/37V-50000RPM-Small-Coreless-Motor-716-p-1884.html&quot; rel=&quot;nofollow&quot;&gt;other sources&lt;/a&gt; rate it at 100 mA.  In either case, it exceeds normal I/O pin capability. You should use FETs or other drivers between Arduino output pins and the motors rather than trying to drive the motors directly from digital output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Regarding the comment, “But most projects i've seen don't use any drivers, Why so ?” I replied:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Perhaps they are using slightly higher voltage to the Pro Mini, eg 3.7 V up to 5 V, which after accounting for voltage drop in the i/o pin circuits may deliver enough voltage to the motors. Note that a driverless circuit ie direct drive from the i/o pins operates the 328 out of its safe operating area (SOA), but it may be close enough to the safe area to usually work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For example, some of the 716-based quadcopter pages I looked at say they used 4.2 V LiPo batteries.  Also note, 716 seems to be a fairly generic motor designation; it refers to the motor's 7 mm diameter and 16 mm length.  As a generic designation it has been used for several different motors, some of which produce less power.  For example, in &lt;a href=&quot;http://www.rcgroups.com/forums/showthread.php?t=1710948&amp;amp;page=35&quot; rel=&quot;nofollow&quot;&gt;thread #1710948&lt;/a&gt; on rcgroups.com, people refer to different RPMs, less lift, etc. for various motors, and the importance of shaving grams off of the copter's weight to allow it to fly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another item that matters when drawing high current from an Atmega328 is which ports are used; and for some devices, it matters whether drive is high-side or low-side, ie whether current is sourced or sunk.  The Atmega328 spec sheet (Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf) says “Each output buffer has symmetrical drive characteristics with both high sink and source capability”, but for several kinds of drivers less voltage is lost with low-side drive than with high-side.  Ie, you could try connecting the motor's V+ lead to Vcc and its V- lead to the i/o pin, and inverting the on-off logic in the sketch. (I don't know if this will make any difference at all in how well things work.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding which ports are used, the footnotes to Table 30-1, “Common DC characteristics”, spell out various combinations of ports where total current draw must not exceed a limit (100 mA in some cases, 150 mA in others).  On the Uno and Pro-Mini, digital outputs marked 10 through 13 (as used for motor control in the question's sketch) are port B Atmega pins, with a footnoted total-current limit for the group.  If you move two of the motor drives to outputs marked 2...4 or D2...D4, then a different total-current limit will apply.  (Again, I don't know if this will make any difference at all in how well things work.)  Refer to Table 30-1 footnotes for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted in Gerben's comment, having &lt;a href=&quot;https://en.wikipedia.org/wiki/Flyback_diode&quot; rel=&quot;nofollow&quot;&gt;flyback-diodes&lt;/a&gt; for the motor circuits is a good idea. This consists of placing power diodes across the motors, cathode to V+, anode to V-, to prevent energy stored in the motor's inductance from producing extreme i/o pin voltages each time the motor is turned off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit 2:&lt;/em&gt; Regarding “which diode, FET to use and where [to] learn about them”, &lt;a href=&quot;http://www.electronics-tutorials.ws/transistor/tran_7.html&quot; rel=&quot;nofollow&quot;&gt;electronics-tutorials.ws&lt;/a&gt; is an accurate and helpful presentation about FET digital circuits.  In particular, see the section called “An example of using the MOSFET as a switch”.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which FETs to consider depends in part on your electronic-circuits fabrication skills.  Note that surface mount devices (SMD parts) usually weigh less than other versions of parts, which is important for a lightweight quadcopter.  However, some people find SMD parts difficult to work with.  In my opinion, the main difficulty is holding parts in their proper places while soldering them, due to small size.  (Eg, a SOT-23 SMD transistor package is on the order of 3mm x 2mm x 1mm, and a diode may be half as big.)  If you have good soldering skills and a way to hold parts in place while soldering, you should be ok, either using a printed circuit board or air-wiring parts using wire-wrap wire (ie, 30 AWG wire, about 0.25mm diameter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some typical logic-level-input SMD FETs are shown in &lt;a href=&quot;http://www.mouser.com/Search/Refine.aspx?N=1323043&amp;amp;Keyword=logic+level+mosfet&amp;amp;Ns=Pricing|0&amp;amp;FS=True&quot; rel=&quot;nofollow&quot;&gt;mouser.com's online catalog&lt;/a&gt;.  Note that in that list, RDS_on decreases a bunch as unit price increases slightly.  For example, the &lt;a href=&quot;http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/FDN359BN_F095/?qs=sGAEpiMZZMshyDBzk1%2fWiwbr802GNVlLdK7ZHbmE8eQ%3d&quot; rel=&quot;nofollow&quot;&gt;FDN359BN&lt;/a&gt; would have under 0.1 ohm resistance when operated with Vcc = 3.7 V and currents &amp;lt; 100 mA.  Voltage drop running a 40 mA motor should be about 4 millivolts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some typical SMD Schottky diodes also are shown in &lt;a href=&quot;http://www.mouser.com/Semiconductors/Discrete-Semiconductors/Diodes-Rectifiers/Schottky-Diodes-Rectifiers/_/N-ax1mj?P=1yzxl0uZ1yrhh8nZ1z0z5meZ1z0xoywZ1z0sou6Z1yzolw2Z1z0z5mmZ1yzteijZ1z0j8z5Z1yztawsZ1z0z4y2Z1yx5tfjZ1yrgsggZ1z0z7utZ1z0z458Z1yzolt6Z1yzsp1rZ1yzsbarZ1yuythpZ1yzspgbZ1z0z4yl&quot; rel=&quot;nofollow&quot;&gt;mouser.com's online catalog&lt;/a&gt;.  I think even the cheapest of these would work ok.  Of course you'll need to adapt all these suggestions to your own skills, sources of parts supply, and budget.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-09-23T06:02:40.540" LastActivityDate="2015-09-23T06:02:40.540" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16209" PostTypeId="2" ParentId="16207" CreationDate="2015-09-20T15:48:15.110" Score="2" Body="&lt;p&gt;The problem here is twofold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, on Arduinos that don't have a direct USB connection, (i.e., boards like the Uno, Mega, etc that use a separate chip to manage the USB connection) you have no way of knowing if the USB is open or not.  That information simply isn't there. The main chip just receives UART serial data (&lt;em&gt;not&lt;/em&gt; USB data) as it arrives and that is that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, even on the boards that have a direct USB connection (Leonardo, etc) there is no &lt;em&gt;proper&lt;/em&gt; way to know if the port has been opened or not.  The CDC/ACM protocol simply doesn't have that kind of information (a bit short sighted of them really).  The closest you can do is monitor the DTR and/or RTS signals that are encapsulated in the USB data stream.  It is down to the host operating system (and maybe even your own program) to exert those signals properly, so isn't foolproof even then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check the status of those lines in your sketch you can examine the &lt;em&gt;boolean operator&lt;/em&gt; of the &lt;code&gt;Serial&lt;/code&gt; object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial) {&#xA;  // I am connected&#xA;} else {&#xA;  // I am not connected&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But as I say that can only work on boards like the Leonard - the other indirect boards think they are always connected, since there is no such thing as a &lt;em&gt;connection&lt;/em&gt; in UART terminology, only data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-20T15:48:15.110" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="16210" PostTypeId="1" CreationDate="2015-09-20T15:48:52.793" Score="1" ViewCount="156" Body="&lt;p&gt;I am junior high teacher teaching students how to program using Arduino. I know the basics of programing but the students wanted to program a game which is a little above my skill set. I am using the following sketch (&lt;a href=&quot;http://www.itopen.it/arduino-pong-with-8x8-led-matrix-and-max7219/&quot; rel=&quot;nofollow&quot;&gt;http://www.itopen.it/arduino-pong-with-8x8-led-matrix-and-max7219/&lt;/a&gt;) to introduce them to programing games. Thanks to this site I understand most of the code. However I would like to add a line of code that will make a piezo buzzer buzz every time the &quot;ball&quot; hits the pad. I think the code should look something like the code bellow, but I am not sure if it is correct or where I would put it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define buz 8 // number of pin buzzer connected to &#xA;     if (HIT_CENTER || HIT_RIGHT || HIT_LEFT) {&#xA;        digitalWrite(buz, HIGH);&#xA;        delay(100);&#xA;        digiralWrite(buz, LOW);&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated. &lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-10-21T09:34:43.387" Title="How Add Piezo Buzz to Pong Sketch" Tags="|c++|sketch|piezo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16212" PostTypeId="2" ParentId="16204" CreationDate="2015-09-20T16:00:56.357" Score="1" Body="&lt;p&gt;There's a couple of fundamental errors in your sketch.  Mainly your construction of your class instances:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SomeClass classA();&#xA;SomeClass classB();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those are taken as functions that return a SomeClass object, not SomeClass constructors.  Instead they should just read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SomeClass classA;&#xA;SomeClass classB;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for the rest, you are much better off using pointers to the classes - it makes passing them around so much easier.  For instance, your array would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SomeClass *things[2] = {&amp;amp;classA, &amp;amp;classB};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is an array of pointers to the objects.  It just stores the addresses that they are at, rather than duplicating the objects into new objects within the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your loop would then run like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i=0; i &amp;lt; 2; i++) {&#xA;    things[i]-&amp;gt;setFoo(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of &lt;code&gt;-&amp;gt;&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt; because you are using a pointer to the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly your &lt;code&gt;init()&lt;/code&gt; function would be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int init(SomeClass *thing) {&#xA;    Serial.println(&quot;Setting up thing&quot;);&#xA;    thing-&amp;gt;setFoo(100);&#xA;}&#xA;&#xA;init(&amp;amp;classA);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you're never going to use the contents of your array with it you could use a reference instead of a pointer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int init(SomeClass &amp;amp;thing) {&#xA;    Serial.println(&quot;Setting up thing&quot;);&#xA;    thing.setFoo(100);&#xA;}&#xA;&#xA;init(classA);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That performs the same job as a pointer but leaves you with what looks like a real object rather than a pointer to the object - in fact it's just aliased the object name to a new one at the same address so you can still access it the same using &lt;code&gt;.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-20T16:00:56.357" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16213" PostTypeId="2" ParentId="16210" CreationDate="2015-09-20T16:25:13.120" Score="1" Body="&lt;p&gt;The condition &lt;code&gt;HIT_CENTER || HIT_RIGHT || HIT_LEFT&lt;/code&gt; will always be true.  (All three of those &lt;code&gt;HIT_&lt;/code&gt; values are non-zero constants.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you need to test if &lt;code&gt;getHit()&lt;/code&gt; is non-zero.  (To see this, search the sketch for occurrences of &lt;code&gt;HIT_RIGHT&lt;/code&gt; or &lt;code&gt;HIT_LEFT&lt;/code&gt;.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch sets up an event timer (via &lt;code&gt;ball_timer = timer.every(BALL_DELAY, moveBall);&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt;) so that ball position will update every 200 ms.  The &lt;code&gt;loop()&lt;/code&gt; sequence is: Use &lt;code&gt;timer.update()&lt;/code&gt; to service timer events.  Use &lt;code&gt;setPad()&lt;/code&gt; to read the paddle position.  Use &lt;code&gt;drawGame()&lt;/code&gt; to update the game picture. Somehow use &lt;code&gt;checkLoose()&lt;/code&gt; to see if game is over.  Use &lt;code&gt;delay(GAME_DELAY)&lt;/code&gt; to wait 10 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that structure of &lt;code&gt;loop()&lt;/code&gt;, throwing in a 100 ms delay to wait for a buzzer would mess up the game play.  You could turn on the buzzer and set up a timer event for turning it off, each time the ball hits the paddle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More straightforwardly, since a 10 ms beep is likely to be adequately long, you could test for a hit just before &lt;code&gt;delay(GAME_DELAY)&lt;/code&gt;, and always turn the buzzer off just after that delay.  In other words, before the delay say:&#xA;&lt;code&gt;if (getHit()) digitalWrite(buz, HIGH);&lt;/code&gt; and after the delay say &lt;code&gt;digitalWrite(buz, LOW);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This supposes that writing HIGH to &lt;code&gt;buz&lt;/code&gt; turns on the buzzer and that writing LOW turns it off.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-20T16:25:13.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16215" PostTypeId="1" AcceptedAnswerId="16217" CreationDate="2015-09-20T17:36:46.200" Score="0" ViewCount="1047" Body="&lt;p&gt;Here's the Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(7, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;    int val = digitalRead(7);&#xA;    if (val == HIGH) {&#xA;        Serial.print(&quot;1&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;0&quot;);    &#xA;    }&#xA;    Serial.println(&quot;&quot;);  // new line&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import time&#xA;import serial&#xA;&#xA;# setup Arduino USB communication&#xA;try:&#xA;    arduinoSerialData = serial.Serial('com3', 9600)&#xA;&#xA;except: # not connected/damaged&#xA;    pass&#xA;&#xA;while True:&#xA;    if arduinoSerialData.inWaiting() &amp;gt; 0:&#xA;        datastr = arduinoSerialData.readline()&#xA;        print datastr&#xA;        time.sleep(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;WHat I want to add is, if Python program exits, or crashes, let the Arduino know somehow. More specifically turn on a LED in pin 8.&lt;/p&gt;&#xA;" OwnerUserId="13501" LastEditorUserId="13501" LastEditDate="2015-09-20T18:23:12.177" LastActivityDate="2015-09-20T18:58:23.560" Title="make Arduino tell when the Python program stops reading from the Serial (crash, etc)" Tags="|serial|arduino-nano|python|" AnswerCount="1" CommentCount="20" ContentLicense="CC BY-SA 3.0" />
  <row Id="16216" PostTypeId="2" ParentId="16122" CreationDate="2015-09-20T18:05:41.667" Score="2" Body="&lt;p&gt;Fixing the typos in your original code, so that it should probably read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;//setup&#xA;void setup() {&#xA; Serial.begin(9600);  //The faster the better&#xA;}   //Close the setup&#xA;&#xA;//main loop &#xA;void loop() { &#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(1) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial&amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(2) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(3) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(4) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(5) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(6) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(7) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(8) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(9) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(10) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(11) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(12) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(13) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(14) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(15) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(16) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(17) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(18) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(19) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27)&amp;lt;&amp;lt; _BYTE(91)&amp;lt;&amp;lt; _BYTE(50)&amp;lt;&amp;lt; _BYTE(74);//CLR&#xA;  Serial&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt;&quot;\n&quot;&amp;lt;&amp;lt; endl;&#xA;  Serial&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt;&quot;\t&quot;&amp;lt;&amp;lt; _DEC(20) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  while(1){} //freeze the main loop&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then condensing the &lt;em&gt;cursor positioning&lt;/em&gt; lines, gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;//setup&#xA;void setup() {&#xA; Serial.begin(9600);  //The faster the better&#xA;}   //Close the setup&#xA;&#xA;//main loop &#xA;void loop() { &#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(1) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(2) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(3) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(4) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(5) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(6) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(7) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(8) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(9) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(10) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(11) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(12) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(13) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(14) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(15) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(16) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(17) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(18) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(19) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n&quot; &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(20) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  while(1){} //freeze the main loop&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then joining the two &lt;em&gt;cursor positioning&lt;/em&gt; lines, gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;//setup&#xA;void setup() {&#xA; Serial.begin(9600);  //The faster the better&#xA;}   //Close the setup&#xA;&#xA;//main loop &#xA;void loop() { &#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(1) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(2) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(3) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(4) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(5) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(6) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(7) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(8) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(9) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(10) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(11) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(12) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(13) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(14) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(15) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(16) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(17) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(18) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(19) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;  Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(20) &amp;lt;&amp;lt; endl;&#xA;  delay(1000);&#xA;  while(1){} //freeze the main loop&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then putting each repeated line in a &lt;code&gt;for&lt;/code&gt; loop, and adding a &lt;em&gt;Maximum Count&lt;/em&gt; &lt;code&gt;const&lt;/code&gt; variable, gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;const int MaxCount = 20;&#xA;&#xA;//setup&#xA;void setup() {&#xA; Serial.begin(9600);  //The faster the better&#xA;}   //Close the setup&#xA;&#xA;//main loop &#xA;void loop() { &#xA;  for (int n = 1; n &amp;lt; 20; n++) {&#xA;    Serial &amp;lt;&amp;lt; _BYTE(27) &amp;lt;&amp;lt; _BYTE(91) &amp;lt;&amp;lt; _BYTE(50) &amp;lt;&amp;lt; _BYTE(74); //CLR&#xA;    Serial &amp;lt;&amp;lt; &quot;\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t&quot; &amp;lt;&amp;lt; _DEC(n) &amp;lt;&amp;lt; endl;&#xA;    delay(1000);&#xA;  }&#xA;&#xA;  while(1){} //freeze the main loop&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, &lt;a href=&quot;https://arduino.stackexchange.com/questions/16122/how-i-can-make-serial-output-print-short#answer-16123&quot;&gt;jwpat7's answer&lt;/a&gt; is much better, and &lt;a href=&quot;https://arduino.stackexchange.com/questions/16122/how-i-can-make-serial-output-print-short#answer-16124&quot;&gt;Nick's answer&lt;/a&gt; is the shortest.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-09-20T18:22:50.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16217" PostTypeId="2" ParentId="16215" CreationDate="2015-09-20T18:45:20.060" Score="1" Body="&lt;p&gt;There is no way to know if the connection has closed or not, you can only know if the connection &lt;em&gt;was&lt;/em&gt; working at some point in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your communication protocol as shown is only &lt;em&gt;half duplex&lt;/em&gt; (i.e., it's only one way - the Arduino sends to Python but never the other way around) which simplifies things somewhat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of strategies you can employ in your case, and any number of them can be combined to create a system as robust (and complex) as you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you would need to make your protocol &lt;em&gt;full duplex&lt;/em&gt;.  This is, you need your Python program to be able to send information to the Arduino.  Since you aren't doing that at the moment the implementation of it can be in any way you like.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One method you can use is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Keepalive&quot; rel=&quot;nofollow&quot;&gt;Keepalive&lt;/a&gt;.  In this system the Python program will periodically send an &quot;I am here&quot; message to the Arduino.  The Arduino receives these messages and remembers when the last one was (hint: use the &lt;code&gt;millis()&lt;/code&gt; function).  If a message hasn't been received for more than a pre-defined timeout period the link is assumed to be dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another method which is good if you are sending data very regularly from the Arduino to the Python program is to use a system of &lt;em&gt;acknowledgements&lt;/em&gt;.  In this situation every bit of data sent to the Python program is followed by the Python replying with an &quot;I got that&quot; message.  If the Arduino doesn't get that response after sending its data within a certain timeout period (can be much shorter than for a keepalive timeout) then the link is assumed to be dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wrapped around both these methods you can add an &quot;I have arrived&quot; and an &quot;I am leaving&quot; message.  These are sent by the Python program when it starts and just before it's about to exit so the Arduino knows when the link &lt;em&gt;should&lt;/em&gt; be alive and when it &lt;em&gt;shouldn't&lt;/em&gt;.  If it gets an &quot;I am leaving&quot; message then it knows that it shouldn't care whether it gets any acknowledgement or keepalive messages, so it doesn't need to think about timeouts. Only after it has received an &quot;I have arrived&quot; message should it start caring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for instance your protocol, with all these things implemented, might look like this (&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; = message from Arduino to Python, &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is message from Python to Arduino):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; 1&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;gt;&amp;gt; 0&#xA;&amp;gt;&amp;gt; 0&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;lt;&amp;lt; A    - I have arrived&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;lt;&amp;lt; Y    - Yes, I got that&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;lt;&amp;lt; Y    - Yes, I got that&#xA;&amp;gt;&amp;gt; 0&#xA;&amp;lt;&amp;lt; Y    - Yes, I got that&#xA;&amp;lt;&amp;lt; K    - keepalive - we know the link is alive and working.&#xA;&amp;gt;&amp;gt; 0&#xA;&amp;lt;&amp;lt; Y    - Yes, I got that&#xA;&amp;gt;&amp;gt; 1&#xA;&amp;lt;&amp;lt; Y    - Yes, I got that&#xA;(Program crashes now.)&#xA;&amp;gt;&amp;gt; 1&#xA;*no Y received - assume connection is closed*&#xA;&amp;gt;&amp;gt; 1&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this instance the 0 and 1 are what you are sending at the moment.  A is an &quot;I have &lt;strong&gt;A&lt;/strong&gt;rrived&quot; message, Y is a &quot;&lt;strong&gt;Y&lt;/strong&gt;es I got that&quot; message, K is a &quot;&lt;strong&gt;K&lt;/strong&gt;eepalive&quot; message, and if the program had exited cleanly an L would have been an &quot;I am &lt;strong&gt;L&lt;/strong&gt;eaving&quot; message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keeping the messages simple (single characters) means it's really easy for the Arduino to parse those messages and work out what is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a certain amount of balancing act to be performed when implementing your system between how often you are sending data and how long you are willing to wait for a valid response or message to flag the connection closed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expanding your existing example program to incorporate these messages might look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastKA = 0;&#xA;unsigned long lastSent = 0;&#xA;boolean isConnected = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(7, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // Check the timeouts if we are connected&#xA;    if (isConnected) {&#xA;&#xA;        // First check to see if the Keepalive timeout has passed&#xA;        if (millis() - laskKA &amp;gt; 5000) { // 5 second keepalive timeout)&#xA;            isConnected = false;&#xA;        }&#xA;&#xA;        // If we have sent data...&#xA;        if (lastSent &amp;gt; 0) { &#xA;            // ... check that we got a response in time&#xA;            if (millis() - lastSent &amp;gt; 100) { // 100ms Y timeout&#xA;                isConnected = false;&#xA;            }&#xA;        }&#xA;&#xA;    }&#xA;&#xA;    // If we are connected then send some data&#xA;    if (isConnected) {&#xA;&#xA;        int val = digitalRead(7);&#xA;        if (val == HIGH) {&#xA;            Serial.print(&quot;1&quot;);&#xA;        } else {&#xA;            Serial.print(&quot;0&quot;);    &#xA;        }&#xA;        Serial.println(&quot;&quot;);  // new line&#xA;&#xA;        // and set the timer for the response&#xA;        lastSent = millis();&#xA;    }&#xA;&#xA;    // Now process incoming messages.&#xA;    if (Serial.available()) {&#xA;        int c = Serial.read();&#xA;&#xA;        // If the message is an A then turn on the connection and&#xA;        // treat it as a Keepalive as well.&#xA;        if (c == 'A') { // Arrived&#xA;            isConnected = true;&#xA;            lastKA = millis();&#xA;&#xA;        // If it's a Leaving message then turn off the connection.&#xA;        } else if (c == 'L') { // Leaving&#xA;            isConnected = false;&#xA;&#xA;        // If it's a Keepalive then reset the timer.&#xA;        } else if (c == 'K') { // Keepalive&#xA;            lastKA = millis();&#xA;&#xA;        // A Y acknowledgement will disable the sent timer.&#xA;        } else if (c == 'Y') { // Yes&#xA;            lastSent = 0; // Cancel the sent timer&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-20T18:58:23.560" LastActivityDate="2015-09-20T18:58:23.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16218" PostTypeId="1" AcceptedAnswerId="16219" CreationDate="2015-09-20T20:41:59.720" Score="0" ViewCount="1408" Body="&#xA;&#xA;&lt;p&gt;I want to get a low voltage on output pin of Arduino mega. I have connected Pin 46 to A3, and wrote 120 value to 46 port. Expected was to get 2-3v on A3 input pin. Instead I always get 1023 values as input. Am I doing something wrong ?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;  pinMode(46, OUTPUT);&#xA;  pinMode(A3,INPUT);&#xA;  }&#xA;&#xA;void loop(){&#xA;  analogWrite(46,120);&#xA;  Serial.println(analogRead(A3));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13502" LastEditorUserId="10794" LastEditDate="2015-09-20T22:36:18.433" LastActivityDate="2015-09-20T22:36:18.433" Title="AnalogWrite custom voltage" Tags="|arduino-mega|pwm|hardware|analogwrite|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16219" PostTypeId="2" ParentId="16218" CreationDate="2015-09-20T21:09:12.577" Score="1" Body="&lt;p&gt;The analog outputs aren't real analog outputs, they are PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that they rapidly switch from OFF to ON and back to OFF again.  The analog value is the ration of OFF time to ON time, known as the &lt;em&gt;Duty Cycle&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can convert that rapid switching to a real voltage by passing the signal through a &lt;em&gt;low pass filter&lt;/em&gt;.  The simplest form is the RC filter:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YALYT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YALYT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-20T21:09:12.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16220" PostTypeId="1" CreationDate="2015-09-20T21:51:05.647" Score="0" ViewCount="14235" Body="&lt;p&gt;I need to communicate with an Arduino. When I use &lt;code&gt;serial.readline()&lt;/code&gt; to read what Arduino has to say it works fine. But when I use&lt;code&gt;serial.write('something')&lt;/code&gt; doesn't seem to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interesting thing is that if I write the same code in the console or command-line, it works as expected...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Python 2.7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import time&#xA;&#xA;arduinoSerialData = serial.Serial('com6', 9600)&#xA;time.sleep(1)&#xA;&#xA;while True:&#xA;    arduinoSerialData.write('AAA')&#xA;    arduinoSerialData.flush()&#xA;    sleep(0.5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;if (Serial.readString().startsWith(&quot;AAA&quot;)) {&#xA;    digitalWrite(7, LOW);&#xA;} else {&#xA;    digitalWrite(7, HIGH);&#xA;}&#xA;&#xA;delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, Python code runs fine from the console, so no idea why this happens.&lt;/p&gt;&#xA;" OwnerUserId="13501" LastEditorUserId="35247" LastEditDate="2017-12-13T09:59:34.937" LastActivityDate="2017-12-13T09:59:34.937" Title="Pyserial serial.write() doesn't work" Tags="|serial|python|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16221" PostTypeId="2" ParentId="16207" CreationDate="2015-09-20T21:51:36.920" Score="1" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How about having the other program send data to Arduino and Arduino knowing the connection is lost when new data isn't received? I have no idea what Arduino code would do that but just an idea.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That sounds simple enough.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const unsigned long MESSAGE_TIMEOUT = 10UL * 1000;  // 10 seconds&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  while (!Serial) ;  // wait for Serial to become active&#xA;  Serial.println (&quot;Starting&quot;);&#xA;&#xA;  }  // end of setup&#xA;&#xA;unsigned long lastMessage;&#xA;&#xA;void processInput ()&#xA;  {&#xA;  while (Serial.available ())&#xA;    {&#xA;    char c = Serial.read ();&#xA;    // do something with the data&#xA;    }  // end of while loop&#xA;  }  // end of processInput&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (Serial.available ())&#xA;    {&#xA;    lastMessage = millis ();  // remember when we last got input&#xA;    processInput ();  // now handle the input&#xA;    }  &#xA;&#xA;  if (millis () - lastMessage &amp;gt;= MESSAGE_TIMEOUT)&#xA;    {&#xA;    // we don't seem to be receiving data  &#xA;    }&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-20T21:51:36.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16222" PostTypeId="2" ParentId="16220" CreationDate="2015-09-20T22:02:52.683" Score="2" Body="&#xA;&#xA;&lt;p&gt;Closely related to &lt;a href=&quot;https://arduino.stackexchange.com/questions/16207/know-the-state-of-usb-serial-connection-coonected-or-not-connected&quot;&gt;To know the state of USB (Serial) connection (connected or not connected)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would not be using &lt;code&gt;Serial.readString()&lt;/code&gt; personally. How do you know where the string starts and ends? Just check for three &quot;A&quot; in a row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const unsigned long MESSAGE_TIMEOUT = 10UL * 1000;  // 10 seconds&#xA;const byte LED = 7;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  while (!Serial) ;  // wait for Serial to become active&#xA;  Serial.println (&quot;Starting&quot;);&#xA;  pinMode (LED, OUTPUT);&#xA;}  // end of setup&#xA;&#xA;unsigned long lastMessage;&#xA;unsigned int countOfA;&#xA;&#xA;void processInput ()&#xA;{&#xA;  while (Serial.available ())&#xA;  {&#xA;    char c = Serial.read ();&#xA;    if (c == 'A')&#xA;      countOfA++;&#xA;    else&#xA;      countOfA = 0;&#xA;    // do something with the data&#xA;  }  // end of while loop&#xA;}  // end of processInput&#xA;&#xA;void loop ()&#xA;{&#xA;  if (Serial.available ())&#xA;  {&#xA;    lastMessage = millis ();  // remember when we last got input&#xA;    processInput ();  // now handle the input&#xA;  }  &#xA;&#xA;  if (millis () - lastMessage &amp;gt;= MESSAGE_TIMEOUT)&#xA;  {&#xA;    countOfA = 0;&#xA;  }&#xA;&#xA;  // warn if no keepalive received&#xA;  if (countOfA &amp;gt;= 3) &#xA;    digitalWrite(LED, LOW);&#xA;  else&#xA;    digitalWrite(LED, HIGH);&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this will fail (ie. it will light the LED) if it gets something other than &quot;A&quot; which would include newlines, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it does it count the number of times it gets the letter &quot;A&quot;. If it gets something else it resets the count. If 10 seconds elapse without receiving something, the count resets.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-09-20T22:02:52.683" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16223" PostTypeId="1" CreationDate="2015-09-21T00:39:41.900" Score="1" ViewCount="1362" Body="&lt;p&gt;I am currently using ATMega32U4 running at 16MHz using Leonardo. I can only supply 3.7V (I use LiPo batteries) and everything seems fine but this is not as per specs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To run at 16 MHz, I have to supply 5V but I can't. I do not want to do any step-up. I am thinking of of using 8 MHz crystal so the processor will require only 3.3V, but I need to use a Leonardo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone been successful in doing this? &lt;/p&gt;&#xA;" OwnerUserId="13504" LastEditorUserId="6936" LastEditDate="2015-09-22T01:19:22.923" LastActivityDate="2016-02-19T07:35:02.803" Title="Loading Leonardo bootloader to Atmega32U4 running at 8 MHz" Tags="|arduino-leonardo|atmega32u4|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16226" PostTypeId="2" ParentId="16210" CreationDate="2015-09-21T07:03:04.183" Score="0" Body="&lt;p&gt;&lt;strong&gt;Method 1:&lt;/strong&gt;&#xA;here is what i would have done is use this code snippet we can get the state of HIT,,,if it is not equal to HIT_NONE ,buzz it&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #define buz 8 &#xA; if(getHit()!=HIT_NONE){&#xA;    digitalWrite(buz, HIGH);&#xA;    delay(10);&#xA;    digitalWrite(buz, LOW);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the simpler version where in delay is small,Beaware using delay will completely halt processor operation ,buttons ,joystick serial ports etc everything will be halted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Method 2:With Flexible Delay&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #define buz 8&#xA;  unsigned long previousMillis = 0; &#xA;  const long interval = 200;   /////Specify the delay you want here&#xA;  void loop()&#xA;   {&#xA;     unsigned long currentMillis = millis();  //start timer&#xA;     /*&#xA;         Remaining Code Is Left As It Is&#xA;     */&#xA;   }&#xA;&#xA;&#xA;&#xA;       ///////////Code Snippet Without Using Delay&#xA;   if(getHit()!=HIT_NONE){&#xA;   digitalWrite(buz, HIGH);&#xA;   if (currentMillis - previousMillis &amp;gt;= interval) &#xA;        {&#xA;            previousMillis = currentMillis;&#xA;            digitalWrite(buz, LOW);&#xA;        }&#xA;   }   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But where to add these functions???&#xA;Use &lt;strong&gt;&lt;em&gt;getHit()&lt;/em&gt;&lt;/strong&gt; to implement ,,,just like below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int getHit() {&#xA;  if(yball != 6 || xball &amp;lt; xpad || xball &amp;gt; xpad + PADSIZE){&#xA;    return HIT_NONE;          //returns in case of hit failure so no &#xA;                              // buzzer ring&#xA;     } &#xA;        digitalWrite(buz, HIGH);    //If it has not returned yet makes&#xA;        delay(10);                  //sure that it is a successful hit&#xA;        digitalWrite(buz, LOW);     //buzzer ring&#xA;  if(xball == xpad + PADSIZE / 2){&#xA;    return HIT_CENTER;&#xA;     }&#xA;   return xball &amp;lt; xpad + PADSIZE / 2 ? HIT_LEFT : HIT_RIGHT;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;yet again u can replace those 3 lines with below one to be more flexible &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(buz, HIGH);&#xA;if (currentMillis - previousMillis &amp;gt;= interval) &#xA;     {&#xA;         previousMillis = currentMillis;&#xA;         digitalWrite(buz, LOW);&#xA;     }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="11916" LastEditorUserId="11916" LastEditDate="2015-09-21T07:15:17.383" LastActivityDate="2015-09-21T07:15:17.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16227" PostTypeId="1" AcceptedAnswerId="16232" CreationDate="2015-09-21T07:18:15.620" Score="5" ViewCount="26007" Body="&lt;p&gt;I wonder if it is possible to send a value from one  arduino to another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I have one arduino measuring let's say weight, but I want to display that value using an lcd in another arduino. &#xA;Is it possible to  send the value to a pin using analogwrite or digital write in the arduino doing the measurement and use analogread/digitalread at the other arduino making the display? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know if this is possible but what is attractive is that one can have several arduino making weight measurements, all showing up in the display of just one central one...&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2019-02-05T18:40:00.660" Title="Sending a value from one arduino to another" Tags="|arduino-uno|lcd|analogread|communication|analogwrite|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16228" PostTypeId="2" ParentId="16227" CreationDate="2015-09-21T07:32:16.163" Score="2" Body="&lt;p&gt;Yes it is possible,The answer provides one of the basic methods to do so&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Arduino1          Arduino2&#xA;     TX---------------&amp;gt;RX&#xA;     RX---------------&amp;gt;TX   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino1 Sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA; Serial.begin(9600);&#xA; delay(2000);&#xA;}&#xA;&#xA;void loop() {&#xA; ////read sensor data to a variable &#xA; Serial.println(sensorDataVariable);&#xA; delay(2000); //Not to flood serial port&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino2 Sketch :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int byteRead;&#xA;void setup(){&#xA; Serial.begin(9600);&#xA; delay(2000);&#xA;}&#xA;&#xA;void loop() {&#xA;  /* check if data has been sent from the computer: */&#xA;  while (Serial.available()) {&#xA;    /* read the most recent byte */&#xA;    byteRead = Serial.read(); //now byteRead will have latest sensor &#xA;                              // data sent from Arduino1&#xA;  }&#xA;  //Write code to display the values to LCD&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hope this helps&lt;/p&gt;&#xA;" OwnerUserId="11916" LastEditorUserId="53682" LastEditDate="2019-02-05T18:40:00.660" LastActivityDate="2019-02-05T18:40:00.660" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="16230" PostTypeId="2" ParentId="16227" CreationDate="2015-09-21T09:25:31.480" Score="1" Body="&lt;p&gt;To tie multiple Arduinos together you need to come up with some kind of networking topology and some form of networking protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Requirements are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Arduinos must not (electrically) interfere with each other&lt;/li&gt;&#xA;&lt;li&gt;There must be some way to know which Arduino is sending what and where to&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The two points could be addressed by having a separate connection for each Arduino but that ends up complicated, and there are only limited resources on an Arduino for creating such connections (you really need to use the hardware UART ports and the Uno has only 1. The Mega has 4).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better solution is to use a &lt;em&gt;bus&lt;/em&gt; system (also known as a &lt;em&gt;multi-drop network&lt;/em&gt;).  There are a number of existing and well supported methods for doing this.  In the automotive system the &lt;a href=&quot;https://en.wikipedia.org/wiki/CAN_bus&quot; rel=&quot;nofollow&quot;&gt;CAN Bus&lt;/a&gt; is used.  In industry the &lt;a href=&quot;https://en.wikipedia.org/wiki/RS-485&quot; rel=&quot;nofollow&quot;&gt;RS-485&lt;/a&gt; system is heavily used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I prefer RS-485 since it is well established.  There are a number of standard protocols that run on RS-485, such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Modbus&quot; rel=&quot;nofollow&quot;&gt;MODBUS&lt;/a&gt;, but for the Arduino world I wrote my own light weight protocol specially which is far simpler to get going with.  You can find out more here: &lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/ICSC&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-21T09:25:31.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16231" PostTypeId="2" ParentId="16223" CreationDate="2015-09-21T12:44:16.530" Score="1" Body="&lt;p&gt;&lt;strike&gt;The bootloader does USB. I don't think you can do USB on the 32u4 on only 8mHz. &lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can however set the system clock prescaler to divide the main clock by 2, making it run at 8mHz. The bootloader will however still run at 16mHz, but that's probably still fine (though out of spec). &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The AVR USB has a system clock prescaler, and the system clock can be divided by setting the “CLKPR – Clock Prescaler Register” on page 38. This feature can be used to decrease the sys- tem clock frequency and the power consumption when the requirement for processing power is low. This can be used with all clock source options, and it will affect the clock frequency of the CPU and all synchronous peripherals. clkI/O, clkADC, clkCPU, and clkFLASH are divided by a factor as shown in Table 6-10.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To divide the system clock by 2, set the CLKPS0 bit in the CLKPR register. The code for this would be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  cli();&#xA;  CLKPR = _BV(CLKPCE);&#xA;  CLKPR = _BV(CLKPS0);&#xA;  sei();&#xA;&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;just note that everything runs twice as slow. So &lt;code&gt;delay(1000)&lt;/code&gt; will take 2 seconds. You'll have to update F_CPU somehow to fix this if this causes a problem.  &lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-09-21T18:18:07.050" LastActivityDate="2015-09-21T18:18:07.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16232" PostTypeId="2" ParentId="16227" CreationDate="2015-09-21T14:25:38.813" Score="4" Body="&lt;p&gt;You could have the LCD Arduino be an I2C master and all the weighing Arduinos be slaves. There's an example of master/slave communication and wiring here: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterReader&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/MasterReader&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I2C supports up to 128 devices and the wiring is very simple.&lt;/p&gt;&#xA;" OwnerUserId="13513" LastActivityDate="2015-09-21T14:25:38.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16233" PostTypeId="1" CreationDate="2015-09-21T14:41:30.360" Score="1" ViewCount="24008" Body="&lt;p&gt;I have just ordered MFRC 522 RFID reader from amzon, and I have also orders 5 RFID tags with keychains and a arduino uno board for my project, I have received RFID reader and tags and I have tested the tags with my Sony xperia NFC. The tags that I received with the readers are working fine but the key chain ones are not working. I think because of the frequency difference 13.56 MHz and 125 KHz. So, please tell will this key chain tags work with the Reader &lt;/p&gt;&#xA;" OwnerUserId="13514" LastActivityDate="2018-06-23T09:48:31.793" Title="how to detect 125khz tags with mfrc 522" Tags="|rfid|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16234" PostTypeId="1" CreationDate="2015-09-21T14:44:44.540" Score="2" ViewCount="422" Body="&lt;p&gt;When examined we find that Yun is still in master mode and 0% signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any procedure known to solve this problem manually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can access Linux command under Mater mode AP-mode and print WiFi status&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/bin/pretty-wifi-info.lua&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We know procedure to change REST API access&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Method II:  config file&#xA;&#xA;opkg update&#xA;opkg install nano&#xA;nano /etc/config/arduino&#xA;&#xA;config arduino&#xA;        option password '775e9f944188a7bcb36e9ca5dc51672b44bcceeb7d56d89dfb914e$&#xA;        option wifi_reset_step 'clear'&#xA;        option secure_rest_api 'true'&#xA;...&#xA;&#xA;Merhod 1:  UCI API    need access to the Linux system by YSM program&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PASSWORD&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uci set arduino.@arduino[0].secure_rest_api=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OPEN:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uci commit arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any procedure manually to perform the configuration by hand for the mode:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;change to client?&lt;/li&gt;&#xA;&lt;li&gt;then restart?&lt;/li&gt;&#xA;&lt;li&gt;from master mode where we have access to Linux command line?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This question has been left unanswered before in all forums examined.&#xA;Maybe someone knows the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem lies in the Linux not in the hardware or routers or PC, as proven by testing.&lt;/p&gt;&#xA;" OwnerUserId="13515" LastEditorUserId="10794" LastEditDate="2015-09-21T23:32:29.157" LastActivityDate="2019-12-26T02:01:35.293" Title="Yun did not connect to WiFi after configuration and restart" Tags="|wifi|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16235" PostTypeId="2" ParentId="16233" CreationDate="2015-09-21T14:49:51.237" Score="2" Body="&lt;p&gt;You are correct NFC is 13.56MHz the key chain ones you are referring to are most likely 125kHz The reader you have will only read 13.56MHz this is the NFC and HID cards. If you want to read the Key Chain ones you will need a reader like this one. &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0075DTXYY&quot; rel=&quot;nofollow&quot;&gt;Weigand 26 Card Reader&lt;/a&gt; Most Phones will not read the 125kHz&lt;/p&gt;&#xA;" OwnerUserId="1115" LastActivityDate="2015-09-21T14:49:51.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16236" PostTypeId="1" CreationDate="2015-09-21T15:07:49.137" Score="2" ViewCount="425" Body="&lt;p&gt;I need to monitor voltages of several DC circuits in a generator's contact box.  Whenever the generator has an alarm, a LED is lit in the box and voltage on the line drops to zero.  I successfully get readings using analogRead(), but whenever I connect a line it shorts to ground (which is shared between the contact box and the Arduino) and triggers the contact box's alarm.  I need to devise a way to monitor voltages without triggering the alarm.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each 5V line and ground from the generator has a bus bar termination point that connects to a point in the proprietary alarm box that houses the LEDs and buzzer. I connected Arduino ground to generator ground, then used A0-A7 on a Nano to connect to individual lines on the bus bar. Arduino VCC is connected to 5V regulated DC power.&lt;/p&gt;&#xA;" OwnerUserId="11615" LastEditorUserId="10907" LastEditDate="2016-01-12T05:19:13.103" LastActivityDate="2018-02-22T18:48:19.890" Title="Arduino as voltage monitor shorts to ground" Tags="|analogread|voltage-level|electricity|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16237" PostTypeId="1" CreationDate="2015-09-21T06:23:49.070" Score="0" ViewCount="277" Body="&lt;p&gt;Can we connect 4 4-digit 7 segment LED Displays to a single Arduino board ? Is it possible without another component in between ?&lt;/p&gt;&#xA;" OwnerDisplayName="Kirtivr" LastEditorUserId="27346" LastEditDate="2018-11-30T22:40:41.797" LastActivityDate="2018-11-30T22:40:41.797" Title="Can we connect 4 4-digit 7 segment LED Displays to a single Arduino board?" Tags="|led|display|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16238" PostTypeId="2" ParentId="16237" CreationDate="2015-09-21T09:22:04.620" Score="0" Body="&lt;p&gt;You need 4*4+7 = 23 pins in common cathode configuration or 4 +7*4 = 32 in common anode and arduino uno only have 20 output/input pins so if you don't want to use any external component you are going to need an Arduino mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the best idea is to use a max7219 matrix led driver. look for it in google.&lt;/p&gt;&#xA;" OwnerUserId="13511" OwnerDisplayName="victor" LastActivityDate="2015-09-21T09:22:04.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16239" PostTypeId="1" AcceptedAnswerId="16249" CreationDate="2015-09-21T18:52:39.603" Score="4" ViewCount="1193" Body="&lt;p&gt;What would be the simplest way of making an Arduino emit EM waves using PWM (or without)? Theoretically, oscillating a current through a wire would result in an electromagnetic wave, but I don't know if this is possible using an Arduino and if so, how?&lt;/p&gt;&#xA;" OwnerUserId="13188" LastActivityDate="2015-09-26T21:31:18.217" Title="Is it possible to create an electromagnetic wave using PWM?" Tags="|arduino-uno|serial|bluetooth|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16240" PostTypeId="1" AcceptedAnswerId="16248" CreationDate="2015-09-21T18:57:28.310" Score="0" ViewCount="6187" Body="&lt;p&gt;I have connected BMP180 sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lWCYy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lWCYy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to Arduino and was able to read its values with appropriate samples (from &lt;a href=&quot;https://github.com/adafruit/Adafruit-BMP085-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Adafruit BMP085 Library&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/adafruit/Adafruit_BMP085_Unified&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Adafruit BMP085 Unified&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, this sensor is sending information via &lt;a href=&quot;https://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C bus&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I2C protocol assumes addresses of connected devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are addresses in my case? How to know and/or change them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to connect several BMP180 to a single Arduino?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="26916" LastEditDate="2017-11-04T23:03:33.287" LastActivityDate="2017-11-04T23:03:33.287" Title="What is the I2C address of a sensor?" Tags="|i2c|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="16241" PostTypeId="2" ParentId="16240" CreationDate="2015-09-21T19:39:15.543" Score="1" Body="&lt;p&gt;Line 30 in &lt;a href=&quot;https://github.com/adafruit/Adafruit-BMP085-Library/blob/master/Adafruit_BMP085.h&quot; rel=&quot;nofollow&quot;&gt;Adafruit_BMP085.h&lt;/a&gt; clearly give you the address of sensor. Looks like the address is fixed meaning the only way you can connect several of these sensors is using a i2c multiplexer&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2015-09-21T19:39:15.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16242" PostTypeId="1" CreationDate="2015-09-21T20:15:31.140" Score="0" ViewCount="64" Body="&lt;p&gt;I'm trying to generate an arbitrary lake bottom sonar returns using my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to seed a function with a &quot;depth.&quot; This would be the starting depth. I would then like to randomize a set of parameters each time the function is called. &lt;strong&gt;The output would look something like a time-truncated sine wave. The parameters would include:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Randomized Amplitude of waveform (which wouldn't vary too much)&lt;/li&gt;&#xA;&lt;li&gt;Randomized Period (or frequency) of waveform (also wouldn't vary too much)&lt;/li&gt;&#xA;&lt;li&gt;Randomized exit point. Say the period is 10 seconds but function ends at 7 seconds. This would allow for a changing in depth over time even if random.&lt;/li&gt;&#xA;&lt;li&gt;If possible, I would like to low pass filter the output to smooth any hard transitions. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on where to get started? &lt;/p&gt;&#xA;" OwnerUserId="13520" LastEditorUserId="10794" LastEditDate="2015-09-21T21:45:06.803" LastActivityDate="2015-09-23T02:13:15.347" Title="Is it possible to make an arbitrary lake bottom generator?" Tags="|sensors|c++|system-design|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16243" PostTypeId="1" CreationDate="2015-09-21T21:11:43.230" Score="0" ViewCount="151" Body="&lt;p&gt;After trying to upgrade firmware of ESP8266, it failed. I am not finding any response from it. It's just blinking a red LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will I do now?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I had tried to upgrade the firmwire in different ways...but couldn't.The result is that i am not finding any wifi signal response in the network connection ...What's now?&lt;/p&gt;&#xA;" OwnerUserId="13522" LastEditorUserId="220" LastEditDate="2015-09-22T22:21:05.760" LastActivityDate="2015-09-22T22:21:05.760" Title="What's wrong with my ESP8266?" Tags="|esp8266|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16244" PostTypeId="1" AcceptedAnswerId="16246" CreationDate="2015-09-21T21:20:12.110" Score="0" ViewCount="733" Body="&lt;p&gt;I work with a marching band, and we want to use fog machines for a particular part of the show. I know how to code/program in Arduino, however I am not great in the electrical and technical end. I own two fog machines, and the issue is that we need them to start fogging on command without delay (at least not a long delay, just not early and not late). We cannot exactly stop the show in the middle of a competition to say &quot;wait, the fog is coming soon.&quot; We also need them to stop fogging on command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read this article, &lt;a href=&quot;http://www.instructables.com/id/Motion-Triggered-Fog-Machine/step1/The-Relay/&quot; rel=&quot;nofollow&quot;&gt;Motion Triggered Fog Machine&lt;/a&gt; and it seems simple enough, however, I do not need or want it to work with a motion sensor. I suppose the easiest way you could help me is to either point me to a tutorial or tell me how to modify that tutorial to my own needs.&lt;/p&gt;&#xA;" OwnerUserId="13523" LastEditorUserId="10794" LastEditDate="2015-09-21T21:53:24.573" LastActivityDate="2015-09-23T21:19:05.120" Title="Fog Machine - On Command" Tags="|arduino-uno|hardware|system-design|wireless|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16245" PostTypeId="2" ParentId="16243" CreationDate="2015-09-21T21:40:14.187" Score="2" Body="&lt;p&gt;The upgrade firmware on the ESP8266 is hardcoded. Attempting to reflash it with known good firmware should restore functionality.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-21T21:40:14.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16246" PostTypeId="2" ParentId="16244" CreationDate="2015-09-21T21:52:23.593" Score="1" Body="&lt;p&gt;Perhaps use a small wireless board like the NRF24L01 (available for around $1 each on eBay). Have one at the fogging machine, similar to the Instructable, but instead of a sensor, you turn the machine on and off when a command arrives. For example, send &quot;0&quot; to turn it off and &quot;1&quot; to turn it on. There are examples with the &lt;a href=&quot;http://tmrh20.github.io/RF24/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;NRF24L01 library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4AmYT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4AmYT.jpg&quot; alt=&quot;NRF24L01 module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you have an Arduino in the wings nearby where you press a switch when you need to turn the fogging machine on (this would transmit the signal).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-23T21:19:05.120" LastActivityDate="2015-09-23T21:19:05.120" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16247" PostTypeId="2" ParentId="9421" CreationDate="2015-09-21T23:43:24.517" Score="0" Body="&lt;p&gt;Your MOSFETs may not be appropriate for driving from a 5V device. I had a similar problem and someone suggested I need to use a MOSFET with a low turn-on voltage, specifically IRLB8743 (&lt;a href=&quot;http://www.irf.com/product-info/datasheets/data/irlb8743pbf.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.irf.com/product-info/datasheets/data/irlb8743pbf.pdf&lt;/a&gt;) which is fully enabled at 4.5V. You might also find that your MOSFETS are getting warm because they are acting as resistors if not fully engaged. &#xA;In the above datasheet it says &quot;Very low RDS(on) at 4.5V&quot; meaning low resistance when VGS (arduino output voltage) is at 4.5V or more. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your datasheet is here &lt;a href=&quot;http://pdf.datasheetcatalog.com/datasheet2/8/0iyt26iogeofcyaowtrx4z7iwiky.pdf&quot; rel=&quot;nofollow&quot;&gt;http://pdf.datasheetcatalog.com/datasheet2/8/0iyt26iogeofcyaowtrx4z7iwiky.pdf&lt;/a&gt; and I'd love to be able to tell you how to compare but I'm not sure which values to look at :/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The breadboard itself may also be introducing resistance. If you wiggle the mosfets around and the lights change brightness this is likely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDs have a set forward (turn on) voltage. You can expect to see that voltage drop over LEDs and not more, which does not indicate the problem (current). &lt;/p&gt;&#xA;" OwnerUserId="13498" LastActivityDate="2015-09-21T23:43:24.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16248" PostTypeId="2" ParentId="16240" CreationDate="2015-09-21T23:48:36.867" Score="1" Body=" &#xA;&#xA;&lt;p&gt;From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;4.2 Device and register address&lt;/strong&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The BMP085 module address is shown below. The LSB of the device address distinguishes between read (1) and write (0) operation, corresponding to address 0xEF (read) and 0xEE (write). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the Wire library you divide that by 2 (because it handles the read/write bit) so the address for using with Wire is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;0xEE / 2 = 0x77&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is mentioned in the Adafruit library:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define BMP085_I2CADDR 0x77&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to connect several BMP180 to a single Arduio?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can certainly connect &lt;strong&gt;two&lt;/strong&gt; of them. From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There is an easy way to connect two BMP085 to the same I2C bus: You can use the XCLR input of BMP085 to set one BMP085 part silent while you communicate with the other BMP085 part via I2C and vice versa. The signals can be provided by two digital outputs of the microcontroller, or one digital output and one inverter. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have access to the XCLR input (the Adafruit board broke it out, I can't tell with the board in your photo) you could use that method. Otherwise do what some of the other answers suggested, and use an I2C multiplexer.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-21T23:48:36.867" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="16249" PostTypeId="2" ParentId="16239" CreationDate="2015-09-21T23:54:20.560" Score="5" Body="&#xA;&#xA;&lt;p&gt;I had a toy project a while ago that generated AM radio. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Code for Uno or any Atmega328 based boards:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte ANTENNA = 9;&#xA;&#xA;void setup() &#xA;  {&#xA;  // set up Timer 1&#xA;  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match&#xA;  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaler&#xA;  OCR1A =  9;       // compare A register value to 10 (zero relative)&#xA;  }  // end of setup&#xA;&#xA;void loop() &#xA;  {&#xA;  pinMode (ANTENNA, OUTPUT);&#xA;  delay (500);&#xA;  pinMode (ANTENNA, INPUT);&#xA;  delay (300);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Wiring&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Plug a wire into digital pin 9:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qHyEP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qHyEP.jpg&quot; alt=&quot;AM radio&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Theory&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The 16 MHz clock is divided by 10 (that is, 1.6 MHz) and that is used to toggle pin 9 at that rate, giving a frequency of 800 kHz, since one toggle turns the output on, and second toggle turns it off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then by turning the output pin on and off slowly you effectively have &quot;keyed&quot; output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this would not have a long range, but you could amplify the output signal.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does the timer code do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's a bit easier to understand if you look at the datasheet. I did a summary for Timer 1 (and the other two timers on the Atmega328) a while back.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Timer 1&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TflBq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TflBq.png&quot; alt=&quot;Timer 1 chart&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lines assigning to TCCR1A and TCCR1B set various bits as per the chart / datasheet. Then OCR1A is the value that the timer counts to, zero-relative, so it counts to 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The prescaler is set to 1, so each &quot;tick&quot; is 1/16000000 of a second (62.5 ns). Count 10 of them and you have 625 ns per tick. The timer is configured to toggle an output pin automatically. Since it takes two toggles (on and off) for one frequency &quot;cycle&quot; the period is 1.250 µs. The inverse of that is 800000. Thus the output frequency is 800000 Hz (800 kHz).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-26T21:31:18.217" LastActivityDate="2015-09-26T21:31:18.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16250" PostTypeId="2" ParentId="16233" CreationDate="2015-09-22T00:13:01.747" Score="1" Body="&lt;p&gt;You can buy a 125 kHz reader from eBay for around $7. I got one like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HCB9J.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HCB9J.jpg&quot; alt=&quot;RFID reader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can communicate with it (listen to it) with a single serial pin (plus ground and power of course). I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12849&quot; rel=&quot;nofollow noreferrer&quot;&gt;post about that board&lt;/a&gt; which describes the connections.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So, please tell will this key chain tags work with the Reader &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, the 125 kHz tags won't work with the 13.56 MHz reader. However you can work around this (if you want to) by using the 125 kHz tags with a different reader.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-22T00:13:01.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16251" PostTypeId="2" ParentId="13499" CreationDate="2015-09-22T01:55:37.237" Score="2" Body="&lt;p&gt;You can absolutely make a PLL using an ATMega microcontroller, and I have made one myself using a ATTiny45. The way I did it is by setting the clock source to the internal RC oscillator, and using that as my VCO (or in this case, Numerically Controlled Oscillator). The internal oscillator can be tuned between 50% and 200% of its nominal frequency by adjusting the OSCCAL register, which can safely be done without stopping the processor. I used the ADC to read the input signal. For the phase detector I programmed the MCU to alternatively add, then subtract the ADC registers from an accumulator register. This is mathematically equivalent to multiplying the incoming signal by a square wave from the local oscillator, and integrating the result. After a fixed number of cycles, I checked to see if the accumulator was negative or positive. If its negative, I set OSCCAL to a &quot;high frequency&quot; which is definitely higher than the input signal. If its positive, I set it to a &quot;low frequency&quot;, which is definitely too low. Of course this is a form of Bang–bang control, so its never stable per se, but I found works perfectly. Its much better than my attempts at a PID controller. Looking on my oscilloscope, the is almost no jitter visible between the input system and the internal RC clock, which I outputted on the CLKO pin by setting the appropriate fuse bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I used GCC and USBTinyISP, I see no reason why my system can't be implemented on Arduino. Setting the fuse bits will require a bit of work though, you can read more here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=124879.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=124879.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is enough interest, I can add more detailed information to my answer.&lt;/p&gt;&#xA;" OwnerUserId="13526" LastActivityDate="2015-09-22T01:55:37.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16252" PostTypeId="2" ParentId="9862" CreationDate="2015-09-22T04:38:20.190" Score="7" Body="&#xA;&#xA;&lt;p&gt;This is what I have managed to achieve ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Library&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/cyborg5/IRLib/&quot; rel=&quot;noreferrer&quot;&gt;IRLib - GitHub&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Version 1.51 March 2015 &#xA;  Copyright 2013-2015 by Chris Young &lt;a href=&quot;http://tech.cyborg5.com/irlib/&quot; rel=&quot;noreferrer&quot;&gt;http://tech.cyborg5.com/irlib/&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This library is a major rewrite of IRemote by Ken Shirriff which was covered by GNU LESSER GENERAL PUBLIC LICENSE ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Modified code (from the demo IRrecord example):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/* Example program for from IRLib – an Arduino library for infrared encoding and decoding&#xA; * Version 1.5  June 2014&#xA; * Copyright 2014 by Chris Young http://cyborg5.com&#xA; * Based on original example sketch for IRremote library &#xA; * Version 0.11 September, 2009&#xA; * Copyright 2009 Ken Shirriff&#xA; * http://www.righto.com/&#xA; */&#xA;&#xA;/*&#xA; * IRrecord: records IR signals &#xA; * An IR detector/demodulator must be connected to the input RECV_PIN.&#xA; * Record a value by pointing your remote at the device &#xA; */&#xA;&#xA;#include &amp;lt;IRLib.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;const byte LED_PIN = 8;&#xA;const byte RECV_PIN = 11;&#xA;const unsigned long BAUD_RATE = 115200;&#xA;const unsigned long NO_ACTIVITY_TIMEOUT = 2000;  // milliseconds&#xA;&#xA;IRrecv My_Receiver(RECV_PIN);&#xA;IRdecode My_Decoder;&#xA;IRsend My_Sender;&#xA;/*&#xA; * Because this version of the library separated the receiver from the decoder,&#xA; * technically you would not need to &quot;store&quot; the code outside the decoder object&#xA; * for this overly simple example. All of the details would remain in the object.&#xA; * However we are going to go ahead and store them just to show you how.&#xA; */&#xA;// Storage for the recorded code&#xA;IRTYPES codeType;          // The type of code&#xA;unsigned long codeValue;   // The data bits if type is not raw&#xA;int codeBits;              // The length of the code in bits&#xA;&#xA;// These values are only stored if it's an unknown type and we are going to use&#xA;// raw codes to resend the information.&#xA;unsigned int rawCodes[RAWBUF]; // The durations if raw&#xA;int rawCount;                   //The number of interval samples&#xA;&#xA;bool GotOne, GotNew; &#xA;&#xA;// added by Nick Gammon&#xA;EMPTY_INTERRUPT (PCINT0_vect);&#xA;&#xA;void setup()&#xA;{&#xA;  GotOne=false; GotNew=false;&#xA;  codeType=UNKNOWN; &#xA;  codeValue=0; &#xA;  Serial.begin(BAUD_RATE);&#xA;  while(!Serial);//delay for Leonardo&#xA;  Serial.println(F(&quot;Send a code from your remote and we will record it.&quot;));&#xA;  Serial.println(F(&quot;Type any character and press enter. We will send the recorded code.&quot;));&#xA;  My_Receiver.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;// Stores the code for later playback&#xA;void storeCode(void) {&#xA;&#xA;  // added by Nick Gammon&#xA;  pinMode (LED_PIN, OUTPUT);&#xA;  digitalWrite (LED_PIN, HIGH);&#xA;&#xA;  GotNew=true;&#xA;  codeType = My_Decoder.decode_type;&#xA;  if (codeType == UNKNOWN) {&#xA;    Serial.println(&quot;Received unknown code, saving as raw&quot;);&#xA;    // To store raw codes:&#xA;    // Drop first value (gap)&#xA;    // As of v1.3 of IRLib global values are already in microseconds rather than ticks&#xA;    // They have also been adjusted for overreporting/underreporting of marks and spaces&#xA;    rawCount = My_Decoder.rawlen-1;&#xA;    for (int i = 1; i &amp;lt;=rawCount; i++) {&#xA;      rawCodes[i - 1] = My_Decoder.rawbuf[i];&#xA;    };&#xA;    My_Decoder.DumpResults();&#xA;    codeType=UNKNOWN;&#xA;  }&#xA;  else {&#xA;    Serial.print(F(&quot;Received &quot;));&#xA;    Serial.print(Pnames(codeType));&#xA;    if (My_Decoder.value == REPEAT) {&#xA;      // Don't record a NEC repeat value as that's useless.&#xA;      Serial.println(F(&quot;repeat; ignoring.&quot;));&#xA;     }&#xA;     else {&#xA;       codeValue = My_Decoder.value;&#xA;       codeBits = My_Decoder.bits;&#xA;     }&#xA;     Serial.print(F(&quot; Value:0x&quot;));&#xA;     Serial.println(My_Decoder.value, HEX);&#xA;  }&#xA;&#xA;  // added by Nick Gammon&#xA;  pinMode (LED_PIN, INPUT);&#xA;  digitalWrite (LED_PIN, LOW);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  // added by Nick Gammon&#xA;  static unsigned long lastActivity;  // when we last woke&#xA;  // sleep if no activity for a while&#xA;  if (millis () - lastActivity &amp;gt;= NO_ACTIVITY_TIMEOUT)&#xA;    {&#xA;    Serial.flush ();  // wait for Serial to finish outputting&#xA;    Serial.end ();    // shut down Serial&#xA;    noInterrupts ();  // timed sequence coming up&#xA;&#xA;    // pin change interrupt for D11&#xA;    PCMSK0 |= bit (PCINT3);  // want pin 11&#xA;    PCIFR  |= bit (PCIF0);   // clear any outstanding interrupts&#xA;    PCICR  |= bit (PCIE0);   // enable pin change interrupts for D8 to D13&#xA;&#xA;    set_sleep_mode (SLEEP_MODE_STANDBY);  &#xA;    sleep_enable();&#xA;&#xA;    byte old_ADCSRA = ADCSRA;&#xA;    // disable ADC to save power&#xA;    ADCSRA = 0;  &#xA;    power_all_disable ();  // turn off various modules&#xA;    interrupts ();&#xA;    sleep_cpu ();  &#xA;    sleep_disable();&#xA;    power_all_enable ();   // enable modules again&#xA;    ADCSRA = old_ADCSRA;   // re-enable ADC conversion&#xA;    Serial.begin(BAUD_RATE);&#xA;    lastActivity = millis ();&#xA;    }  // end of no activity for a couple of seconds&#xA;&#xA;&#xA; if (My_Receiver.GetResults(&amp;amp;My_Decoder)) {&#xA;    My_Decoder.decode();&#xA;    GotOne=true;&#xA;    storeCode();&#xA;    delay(500);&#xA;    My_Receiver.resume(); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Explanation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Main changes are in &lt;code&gt;loop&lt;/code&gt; (near the bottom) where it sleeps if there is no activity for two seconds. This &quot;no activity&quot; test gives it time to catch an incoming pulse stream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before sleeping it turns off Serial (to save power), and sets up to detect the pin-change interrupt. It also turns off the ADC, and calls &lt;code&gt;power_all_disable&lt;/code&gt; to disable various internal modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it uses pin-change interrupts on Arduino pin D11 (pin 17 on the chip). For a different processor than the Atmega328P, or a different input pin, you would have to change which pin-change interrupt is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that I had to use SLEEP_MODE_STANDBY rather than SLEEP_MODE_PWR_DOWN, otherwise it seemed to take too long to wake up and handle the incoming pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For testing, I flashed D8 pin to make sure it was working when hooked up in low-power configuration.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Power consumption&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I tested with an AX-1838T IR-receiver that I had to hand (same pin-outs as in the Adafruit article).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Measured stand-alone (ie. not connected to the Arduino) it consumed 630 µA, so therefore we could not expect lower power consumption than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connected up to a &quot;bare-bones&quot; board (ie. just the Atmega328P chip, decoupling capacitors, etc.) I measured 1.158 mA when idle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IMWJJ.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IMWJJ.jpg&quot; alt=&quot;Bare bones board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My tests on &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;noreferrer&quot;&gt;my page about power&lt;/a&gt; indicate that SLEEP_MODE_STANDBY uses 480 µA more power than SLEEP_MODE_PWR_DOWN, so this sounds about right.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;630 + 480 = 1110 µA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You might be able to save more power by operating at a lower voltage. This particular receiver can operate at a lower voltage. As an indication, I tried the setup at 3.3 V (which is out of spec for the processor, but whatever, I was just testing) and it consumed 978 µA when idle. This is a modest saving over the 5 V test.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;noreferrer&quot;&gt;Power saving&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;noreferrer&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/using-an-infrared-library/hardware-needed&quot; rel=&quot;noreferrer&quot;&gt;Adafruit IR library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/cyborg5/IRLib/&quot; rel=&quot;noreferrer&quot;&gt;IR library source&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-22T07:54:14.993" LastActivityDate="2015-09-22T07:54:14.993" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16255" PostTypeId="2" ParentId="16243" CreationDate="2015-09-22T12:23:01.807" Score="0" Body="&lt;p&gt;Make sure you have the correct firmware depending on the version of the board you have, the family seems quite big:&#xA;&lt;a href=&quot;http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family&quot; rel=&quot;nofollow&quot;&gt;esp8266 wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing stopping you from experimenting and flashing different versions until you find the one that works.&lt;/p&gt;&#xA;" OwnerUserId="13532" LastActivityDate="2015-09-22T12:23:01.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16257" PostTypeId="2" ParentId="16243" CreationDate="2015-09-22T13:47:21.327" Score="0" Body="&lt;p&gt;Make sure that GPIO0 is not shorted to ground. Otherwise, try to reflash the firmware and when finished, leave GPIO0 floating to get out of firmware upgrading mode.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-09-22T13:47:21.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16258" PostTypeId="2" ParentId="11673" CreationDate="2015-09-22T13:49:24.767" Score="2" Body="&lt;p&gt;Make sure the RX, TX pins are not connected to any other circuit when uploading sketches.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-09-22T13:49:24.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16261" PostTypeId="1" AcceptedAnswerId="16262" CreationDate="2015-09-22T14:58:41.813" Score="0" ViewCount="1113" Body="&lt;p&gt;I'm trying to use a MIFARE 1K RFID card with RC522 RFID reader/writer for my college project.&#xA;I'm trying to understand about memory organization of MIFARE 1K.A documentation() that supplied with a RFID Arduino library() says like this.&#xA;I will very appreciate if someone explain me this portion clearly.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The MIFARE Classic 1K offers 1024 bytes of data storage, split into 16 sectors; each sector is protected by two different keys, called A and B. Each key can be&#xA;  programmed to allow operations such as reading, writing, increasing valueblocks,&#xA;  etc. MIFARE Classic 4K offers 4096 bytes split into forty sectors, of which 32 are same size as in the 1K with eight more that are quadruple size sectors. MIFARE Classic mini offers 320 bytes split into five sectors. &#xA;  For each of these card types, &lt;strong&gt;16 bytes per sector&lt;/strong&gt; are reserved for the keys and access conditions and can not normally be used for user data. Also, the very first 16 bytes contain the serial number of the card and certain other manufacturer data and are read only. That brings the net storage capacity of these cards down to 752 bytes for MIFARE Classic 1k, 3440 bytes for MIFARE Classic 4k, and 224 bytes for Mini. It uses an NXP proprietary security protocol (Crypto-1) for authentication and ciphering.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Accordind to above quote,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For each of these card types, &lt;strong&gt;16 bytes per sector&lt;/strong&gt; are reserved for the keys and access conditions and can not normally be used for user data.&#xA;  Blockquote&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Explain how to divide 1024 bytes like this.It has 16 sectors.So,total memory should be 16*16=256 bytes.This is impossible. Please explain this.&lt;/p&gt;&#xA;" OwnerUserId="13536" LastActivityDate="2016-01-18T22:23:47.150" Title="Memory organisation of MIFARE 1K" Tags="|rfid|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16262" PostTypeId="2" ParentId="16261" CreationDate="2015-09-22T15:03:56.880" Score="5" Body="&lt;p&gt;You're reading (and doing your sums) backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 1024 bytes of data space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That data space is split into 16 sectors, so 1024 / 16 = 64 bytes per sector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each sector has 16 bytes reserved for keys etc, so each sector has 64 - 16 = 48 bytes of user data space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;48 bytes of user data space per sector multiplied by 16 sectors is 768 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally 1024 - 768 = 256, which is what you were calculating before.  What you calculated was the amount of the 1024 bytes that is reserved &lt;em&gt;in total&lt;/em&gt; for the keys and access controls.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-22T15:03:56.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16263" PostTypeId="2" ParentId="16261" CreationDate="2015-09-22T15:04:09.423" Score="2" Body="&lt;p&gt;Divide 1024 bytes into 16 sectors -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1024 bytes / 16 sectors = 64 bytes per sector&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first 16 bytes of each sector are used for 'management' and thus reserved. This leaves -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;64 - 16 = 48 bytes (per sector) for general storage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-09-22T15:04:09.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16265" PostTypeId="1" AcceptedAnswerId="20512" CreationDate="2015-09-21T15:26:00.583" Score="2" ViewCount="6626" Body="&lt;p&gt;Below i have an example of a temperature sensor.What i need to be able to set the username an password dynamically before connecting to my home router.It would ask me for the ssid and password for example.example. Ive seen a couple of posts about this with no definitive code to show how it would work.If anyone has experience with this could they comment here please.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &#xA;#include &#xA;#include&#xA;#define ONE_WIRE_BUS 8&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;#define SSID &quot;[YOUR_SSID]&quot;&#xA;#define PASS &quot;[YOUR_PASSWORD]&quot;&#xA;#define IP &quot;184.106.153.149&quot; // thingspeak.com&#xA;String GET = &quot;GET /update?key=[THINGSPEAK_KEY]&amp;amp;field1=&quot;;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  sensors.begin();&#xA;  Serial.println(&quot;AT&quot;);&#xA;  delay(5000);&#xA;  if(Serial.find(&quot;OK&quot;)){&#xA;    connectWiFi();&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA;  sensors.requestTemperatures();&#xA;  float tempC = sensors.getTempCByIndex(0);&#xA;  tempC = DallasTemperature::toFahrenheit(tempC);&#xA;  char buffer[10];&#xA;  String tempF = dtostrf(tempC, 4, 1, buffer);&#xA;  updateTemp(tempF);&#xA;  delay(60000);&#xA;}&#xA;&#xA;void updateTemp(String tenmpF){&#xA;  String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;  cmd += IP;&#xA;  cmd += &quot;\&quot;,80&quot;;&#xA;  Serial.println(cmd);&#xA;  delay(2000);&#xA;  if(Serial.find(&quot;Error&quot;)){&#xA;    return;&#xA;  }&#xA;  cmd = GET;&#xA;  cmd += tenmpF;&#xA;  cmd += &quot;\r\n&quot;;&#xA;  Serial.print(&quot;AT+CIPSEND=&quot;);&#xA;  Serial.println(cmd.length());&#xA;  if(Serial.find(&quot;&amp;gt;&quot;)){&#xA;    Serial.print(cmd);&#xA;  }else{&#xA;    Serial.println(&quot;AT+CIPCLOSE&quot;);&#xA;  }&#xA;}&#xA;&#xA;&#xA;boolean connectWiFi(){&#xA;  Serial.println(&quot;AT+CWMODE=1&quot;);&#xA;  delay(2000);&#xA;  String cmd=&quot;AT+CWJAP=\&quot;&quot;;&#xA;  cmd+=SSID;&#xA;  cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;  cmd+=PASS;&#xA;  cmd+=&quot;\&quot;&quot;;&#xA;  Serial.println(cmd);&#xA;  delay(5000);&#xA;  if(Serial.find(&quot;OK&quot;)){&#xA;    return true;&#xA;  }else{&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13542" OwnerDisplayName="Maria88" LastActivityDate="2016-02-10T04:56:17.960" Title="Esp8266 Arduino smart connect" Tags="|wifi|esp8266|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16266" PostTypeId="2" ParentId="16265" CreationDate="2015-09-21T18:51:24.050" Score="2" Body="&lt;p&gt;The following code can do what you want (&lt;a href=&quot;https://gist.github.com/dogrocker/f998dde4dbac923c47c1&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;), all that is needed is to combine it with the sensor code. The default behaviour is to create an access point when it can't connect to the eeprom stored WiFi station but you can modify it to trigger with a button/jumper or any other way you prefer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;ESP8266WebServer server(80);&#xA;&#xA;const char* ssid = &quot;test&quot;;&#xA;const char* passphrase = &quot;test&quot;;&#xA;String st;&#xA;String content;&#xA;int statusCode;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  EEPROM.begin(512);&#xA;  delay(10);&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  Serial.println(&quot;Startup&quot;);&#xA;  // read eeprom for ssid and pass&#xA;  Serial.println(&quot;Reading EEPROM ssid&quot;);&#xA;  String esid;&#xA;  for (int i = 0; i &amp;lt; 32; ++i)&#xA;    {&#xA;      esid += char(EEPROM.read(i));&#xA;    }&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(esid);&#xA;  Serial.println(&quot;Reading EEPROM pass&quot;);&#xA;  String epass = &quot;&quot;;&#xA;  for (int i = 32; i &amp;lt; 96; ++i)&#xA;    {&#xA;      epass += char(EEPROM.read(i));&#xA;    }&#xA;  Serial.print(&quot;PASS: &quot;);&#xA;  Serial.println(epass);  &#xA;  if ( esid.length() &amp;gt; 1 ) {&#xA;      WiFi.begin(esid.c_str(), epass.c_str());&#xA;      if (testWifi()) {&#xA;        launchWeb(0);&#xA;        return;&#xA;      } &#xA;  }&#xA;  setupAP();&#xA;}&#xA;&#xA;bool testWifi(void) {&#xA;  int c = 0;&#xA;  Serial.println(&quot;Waiting for Wifi to connect&quot;);  &#xA;  while ( c &amp;lt; 20 ) {&#xA;    if (WiFi.status() == WL_CONNECTED) { return true; } &#xA;    delay(500);&#xA;    Serial.print(WiFi.status());    &#xA;    c++;&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;Connect timed out, opening AP&quot;);&#xA;  return false;&#xA;} &#xA;&#xA;void launchWeb(int webtype) {&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;WiFi connected&quot;);&#xA;  Serial.print(&quot;Local IP: &quot;);&#xA;  Serial.println(WiFi.localIP());&#xA;  Serial.print(&quot;SoftAP IP: &quot;);&#xA;  Serial.println(WiFi.softAPIP());&#xA;  createWebServer(webtype);&#xA;  // Start the server&#xA;  server.begin();&#xA;  Serial.println(&quot;Server started&quot;); &#xA;}&#xA;&#xA;void setupAP(void) {&#xA;  WiFi.mode(WIFI_STA);&#xA;  WiFi.disconnect();&#xA;  delay(100);&#xA;  int n = WiFi.scanNetworks();&#xA;  Serial.println(&quot;scan done&quot;);&#xA;  if (n == 0)&#xA;    Serial.println(&quot;no networks found&quot;);&#xA;  else&#xA;  {&#xA;    Serial.print(n);&#xA;    Serial.println(&quot; networks found&quot;);&#xA;    for (int i = 0; i &amp;lt; n; ++i)&#xA;     {&#xA;      // Print SSID and RSSI for each network found&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot;: &quot;);&#xA;      Serial.print(WiFi.SSID(i));&#xA;      Serial.print(&quot; (&quot;);&#xA;      Serial.print(WiFi.RSSI(i));&#xA;      Serial.print(&quot;)&quot;);&#xA;      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?&quot; &quot;:&quot;*&quot;);&#xA;      delay(10);&#xA;     }&#xA;  }&#xA;  Serial.println(&quot;&quot;); &#xA;  st = &quot;&amp;lt;ol&amp;gt;&quot;;&#xA;  for (int i = 0; i &amp;lt; n; ++i)&#xA;    {&#xA;      // Print SSID and RSSI for each network found&#xA;      st += &quot;&amp;lt;li&amp;gt;&quot;;&#xA;      st += WiFi.SSID(i);&#xA;      st += &quot; (&quot;;&#xA;      st += WiFi.RSSI(i);&#xA;      st += &quot;)&quot;;&#xA;      st += (WiFi.encryptionType(i) == ENC_TYPE_NONE)?&quot; &quot;:&quot;*&quot;;&#xA;      st += &quot;&amp;lt;/li&amp;gt;&quot;;&#xA;    }&#xA;  st += &quot;&amp;lt;/ol&amp;gt;&quot;;&#xA;  delay(100);&#xA;  WiFi.softAP(ssid, passphrase, 6);&#xA;  Serial.println(&quot;softap&quot;);&#xA;  launchWeb(1);&#xA;  Serial.println(&quot;over&quot;);&#xA;}&#xA;&#xA;void createWebServer(int webtype)&#xA;{&#xA;  if ( webtype == 1 ) {&#xA;    server.on(&quot;/&quot;, []() {&#xA;        IPAddress ip = WiFi.softAPIP();&#xA;        String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);&#xA;        content = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\r\n&amp;lt;html&amp;gt;Hello from ESP8266 at &quot;;&#xA;        content += ipStr;&#xA;        content += &quot;&amp;lt;p&amp;gt;&quot;;&#xA;        content += st;&#xA;        content += &quot;&amp;lt;/p&amp;gt;&amp;lt;form method='get' action='setting'&amp;gt;&amp;lt;label&amp;gt;SSID: &amp;lt;/label&amp;gt;&amp;lt;input name='ssid' length=32&amp;gt;&amp;lt;input name='pass' length=64&amp;gt;&amp;lt;input type='submit'&amp;gt;&amp;lt;/form&amp;gt;&quot;;&#xA;        content += &quot;&amp;lt;/html&amp;gt;&quot;;&#xA;        server.send(200, &quot;text/html&quot;, content);  &#xA;    });&#xA;    server.on(&quot;/setting&quot;, []() {&#xA;        String qsid = server.arg(&quot;ssid&quot;);&#xA;        String qpass = server.arg(&quot;pass&quot;);&#xA;        if (qsid.length() &amp;gt; 0 &amp;amp;&amp;amp; qpass.length() &amp;gt; 0) {&#xA;          Serial.println(&quot;clearing eeprom&quot;);&#xA;          for (int i = 0; i &amp;lt; 96; ++i) { EEPROM.write(i, 0); }&#xA;          Serial.println(qsid);&#xA;          Serial.println(&quot;&quot;);&#xA;          Serial.println(qpass);&#xA;          Serial.println(&quot;&quot;);&#xA;&#xA;          Serial.println(&quot;writing eeprom ssid:&quot;);&#xA;          for (int i = 0; i &amp;lt; qsid.length(); ++i)&#xA;            {&#xA;              EEPROM.write(i, qsid[i]);&#xA;              Serial.print(&quot;Wrote: &quot;);&#xA;              Serial.println(qsid[i]); &#xA;            }&#xA;          Serial.println(&quot;writing eeprom pass:&quot;); &#xA;          for (int i = 0; i &amp;lt; qpass.length(); ++i)&#xA;            {&#xA;              EEPROM.write(32+i, qpass[i]);&#xA;              Serial.print(&quot;Wrote: &quot;);&#xA;              Serial.println(qpass[i]); &#xA;            }    &#xA;          EEPROM.commit();&#xA;          content = &quot;{\&quot;Success\&quot;:\&quot;saved to eeprom... reset to boot into new wifi\&quot;}&quot;;&#xA;          statusCode = 200;&#xA;        } else {&#xA;          content = &quot;{\&quot;Error\&quot;:\&quot;404 not found\&quot;}&quot;;&#xA;          statusCode = 404;&#xA;          Serial.println(&quot;Sending 404&quot;);&#xA;        }&#xA;        server.send(statusCode, &quot;application/json&quot;, content);&#xA;    });&#xA;  } else if (webtype == 0) {&#xA;    server.on(&quot;/&quot;, []() {&#xA;      IPAddress ip = WiFi.localIP();&#xA;      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);&#xA;      server.send(200, &quot;application/json&quot;, &quot;{\&quot;IP\&quot;:\&quot;&quot; + ipStr + &quot;\&quot;}&quot;);&#xA;    });&#xA;    server.on(&quot;/cleareeprom&quot;, []() {&#xA;      content = &quot;&amp;lt;!DOCTYPE HTML&amp;gt;\r\n&amp;lt;html&amp;gt;&quot;;&#xA;      content += &quot;&amp;lt;p&amp;gt;Clearing the EEPROM&amp;lt;/p&amp;gt;&amp;lt;/html&amp;gt;&quot;;&#xA;      server.send(200, &quot;text/html&quot;, content);&#xA;      Serial.println(&quot;clearing eeprom&quot;);&#xA;      for (int i = 0; i &amp;lt; 96; ++i) { EEPROM.write(i, 0); }&#xA;      EEPROM.commit();&#xA;      WiFi.disconnect();&#xA;    });&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  server.handleClient();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The configuration access point ssid and password are set in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* ssid = &quot;test&quot;;&#xA;const char* passphrase = &quot;test&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default IP is 192.168.4.1. When you open it from a browser you see a screen which lists the available WiFi stations (ESP8266 scan result), the signal strength and an asterisk on locked stations. There are also two text boxes where you enter the ssid and password of the station you want to connect to and submit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/imsTv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/imsTv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is a &lt;a href=&quot;https://github.com/tzapu/WiFiManager&quot; rel=&quot;nofollow noreferrer&quot;&gt;link to a similar library&lt;/a&gt; in the comments of the source link, that didn't work for me but you can try it.&lt;/p&gt;&#xA;" OwnerUserId="470" OwnerDisplayName="alexan_e" LastEditorUserId="470" LastEditDate="2015-09-22T21:53:36.210" LastActivityDate="2015-09-22T21:53:36.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16269" PostTypeId="1" CreationDate="2015-09-22T17:38:57.400" Score="7" ViewCount="10166" Body="&lt;p&gt;I'm new to Arduino and electronics. I want to make a project including SD data-logger, but I had a problem. I would appreciate if someone show me where I made a mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, circuit  was set up as in picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Htgk6.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Htgk6.jpg&quot; alt=&quot;Hardware setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using 8 Gb micro SDHC card with SD adapter. I formatted in FAT32. I can play audio files which are in appropriate format and read and the print contents of text files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I want to create a new file, strange file is obtained in SD card as in pic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CxVEy.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CxVEy.jpg&quot; alt=&quot;Directory listing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I reformat SD card. the code that is used while creating file is as this;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// open a new file and immediately close it:&#xA;Serial.println(&quot;Creating example.txt...&quot;);&#xA;myFile = SD.open(&quot;example.txt&quot;, FILE_WRITE);&#xA;myFile.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Somewhere I read SDHC card with more than 2 Gb capacity  is not supported in Arduino and I bought 2 Gb SD micro with SD adaptor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in this case aurduino does not detect SD card. please someone help me.&lt;/p&gt;&#xA;" OwnerUserId="13539" LastEditorUserId="10794" LastEditDate="2015-09-22T21:39:40.267" LastActivityDate="2017-05-30T02:23:18.503" Title="arduino creates strange files in SD card" Tags="|arduino-uno|c++|sd-card|datalogging|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16270" PostTypeId="1" CreationDate="2015-09-22T18:55:28.200" Score="2" ViewCount="7084" Body="&lt;p&gt;Is it possible to create a set of ultrasonics frequencies using only the Arduino? What code to be used? And how am I going to do for it to work? For this project I need to focus in  the emitter side; all resources on Google are only on sensor and distance detector. I just want to use ultrasonic on other field just like for example on repelling rats. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13535" LastEditorUserId="4628" LastEditDate="2017-08-05T13:52:40.583" LastActivityDate="2017-08-06T17:54:56.260" Title="Sets of Ultrasonic frequencies using arduino uno" Tags="|arduino-uno|frequency|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16272" PostTypeId="2" ParentId="16270" CreationDate="2015-09-22T20:50:57.647" Score="1" Body="&lt;p&gt;There are three parts to this project, one of which you asked:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I need to generate a frequency greater than 40 khz using arduino uno?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This one is easy: Yes. You can use the tone() library call. You can specify a frequency up to 8mhz. You can call this in the &lt;code&gt;void setup{}&lt;/code&gt; part of your code, and (if you don't want to do anything else), leave the &lt;code&gt;void loop() {}&lt;/code&gt; empty. You might want to generate an audible tone for a short period first, to show that it is working.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;You need something to actually make the sound. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Depending on the frequency, most speakers won't do the trick, or will do it at a very low volume. Speakers are made to work with audible frequencies. Even then, some speakers (larger ones) are better at low frequencies; others (smaller ones) are better at higher audible frequencies. I think piezoelectric buzzers would give you a better response at higher frequencies. In any case, whatever you buy find out the frequency response for the specific part, find the frequency you intend to use along the bottom, then see what the volume (db) is for that frequency - this will give you an indication of how loud it will be. Remember that you won't be able to hear it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit is pretty trivial. Google piezo arduino&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Efficacy: &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://en.wikipedia.org/wiki/Electronic_pest_control#Effects_on_rodents&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Electronic_pest_control#Effects_on_rodents&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Rodents adjust to the ultrasound (or any new sound) and eventually ignore it. At best, ultrasonic waves have only a partial or temporary effect on rodents. Numerous studies have rejected ultrasonic sound as a practical means of rodent control.Tests of commercial ultrasonic devices have indicated that rodents may be repelled from the immediate area of the ultrasound device for a few minutes to a few days, but they will nearly always return and resume normal activities. Other tests have shown that the degree of repellance depends on the frequency, intensity, and pre-existing condition of the rodent infestation. The intensity of such sounds must be so great that damage to humans or domestic animals would also be likely; commercial ultrasonic pest control devices do not produce sounds of such intensity.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-22T20:50:57.647" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16274" PostTypeId="2" ParentId="16242" CreationDate="2015-09-23T02:13:15.347" Score="1" Body="&lt;p&gt;A common method of generating realistic-ish 3d terrain is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start with a square (as seen top-down), described by the lengths of it's side (all the same), and the height of each of the corners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Divide each edge in half; for example, add a new point halfway between the north-west point and the north-east point; it's altitude will be the average of the altitude of the two existing points, plus or minus a random number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now add a point in the center of the existing square; it's altitude being the average of the north, east, west and south points you've just created, plus or minus a random number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now have 4 smaller squares. Repeat this process on the four smaller squares, then the smaller squares within that, and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to manually do the first few points, tweaking it to get the shape you want, then leave the details to the algorithm. Your random number for the adjustments of the &quot;middle point&quot; heights should be proportionate to the length of the sides; for example, the random altitude adjustment might be a random number up to X% the length; then subtract half of X% of the length. Adjusting X% will give you an area that is more or less &quot;pointy&quot;.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-23T02:13:15.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16275" PostTypeId="1" CreationDate="2015-09-23T06:50:18.857" Score="1" ViewCount="1790" Body="&lt;p&gt;I enable messages about new SMS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CNMI=2,2,0,0,0&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when received sms, output like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+CMT: &quot;+79XXXXXXXXX&quot;,&quot;1&quot;,&quot;15/09/23,01:34:03+24&quot;&#xA;Test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I read message, output only before &lt;code&gt;&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt;&#xA;I don't see text of message.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CMGR=1&#xA;&#xA;+CMGR: &quot;REC READ&quot;,&quot;+79XXXXXXXXX&quot;,&quot;1&quot;,&quot;15/09/23,00:34:17+24&quot;&#xA;&#xA;AT+CMGL=&quot;ALL&quot;&#xA;&#xA;+CMGL: 1,&quot;REC READ&quot;,&quot;+79XXXXXXXXX&quot;,&quot;1&quot;,&quot;15/09/23,00:34:17+24&quot;&#xA;+CMGL: 2,&quot;REC READ&quot;,&quot;+79XXXXXXXXX&quot;,&quot;1&quot;,&quot;15/09/23,01:34:03+24&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use &lt;a href=&quot;https://gist.github.com/YokiToki/9d5e730c0c196ebaf3cf&quot; rel=&quot;nofollow&quot;&gt;following&lt;/a&gt;  (via SoftwareSerial) code for test this.&#xA;&lt;code&gt;SMSGSM.GetSMS&lt;/code&gt; and &lt;code&gt;SMSGSM.GetAuthorizedSMS&lt;/code&gt; of &lt;a href=&quot;https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield&quot; rel=&quot;nofollow&quot;&gt;GSM GPRS GPS Shield Library&lt;/a&gt; receive only phone number without sms text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this shield:&#xA;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/1845813/10030856/50090b88-6193-11e5-916b-5f58ac58e6d8.JPG&quot; alt=&quot;_57&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+GSV&#xA;&#xA;SIMCOM_Ltd&#xA;SIMCOM_SIM900&#xA;Revision:1137B05SIM900M64_ST_ENHAN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13553" LastActivityDate="2016-11-07T03:40:08.503" Title="SIM900 Shield read only sms headers without text" Tags="|serial|gsm|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16276" PostTypeId="1" CreationDate="2015-09-23T07:40:23.377" Score="2" ViewCount="265" Body="&lt;p&gt;I have two Arduino Leonardos here. They do different things, but basically they both emulate a keyboard. Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte SWITCH = 12;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Keyboard.begin();&#xA;  pinMode (SWITCH, INPUT_PULLUP);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (digitalRead (SWITCH) == LOW)&#xA;    {&#xA;    Keyboard.println (&quot;foo&quot;);&#xA;    delay (2000);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I program a second Leonardo with the same code but send &quot;bar&quot; rather than &quot;foo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I plug these into my PC (running Ubuntu 14.04) using different USB ports, everything works. When the switch is closed I see &quot;foo&quot; and &quot;bar&quot; being typed into whatever application is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I plug them both into a D-Link 4-port USB hub (model DUB-1340) only the first one works. The other is ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing &lt;code&gt;lsusb&lt;/code&gt; shows this (along with other irrelevant devices):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb&#xA;Bus 003 Device 040: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)&#xA;Bus 003 Device 039: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens in both cases (if they are both in the USB hub or not).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;My question&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Is this proper behaviour that two Leonardos on a USB hub fail to both work? (Perhaps you aren't supposed to plug two identical USB devices in at once).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, is this a bug in either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Leonardo USB interface?&lt;/li&gt;&#xA;&lt;li&gt;My USB hub?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Further testing revealed that the setup worked OK when plugged into my Mac running OS/X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I went back to Ubuntu and it worked as well! However a mouse that I had plugged into the USB hub now stopped working!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further investigation reveals that the fourth port on my USB hub is faulty in some way. If I swap the mouse and the Leonardo the Leonardo works but not the mouse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following Majenko's suggestion:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can try running usb-devices from the usbutils package (should be already installed since lsusb is in the same package) and look for the two Leonardo blocks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T:  Bus=03 Lev=02 Prnt=50 Port=00 Cnt=01 Dev#= 66 Spd=12  MxCh= 0&#xA;D:  Ver= 2.00 Cls=02(commc) Sub=00 Prot=00 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=2341 ProdID=8036 Rev=01.00&#xA;S:  Manufacturer=Arduino LLC&#xA;S:  Product=Arduino Leonardo&#xA;C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm&#xA;I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm&#xA;I:  If#= 2 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T:  Bus=03 Lev=02 Prnt=50 Port=03 Cnt=04 Dev#= 72 Spd=12  MxCh= 0&#xA;D:  Ver= 2.00 Cls=02(commc) Sub=00 Prot=00 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=2341 ProdID=8036 Rev=01.00&#xA;S:  Manufacturer=Arduino LLC&#xA;S:  Product=Arduino Leonardo&#xA;C:  #Ifs= 0 Cfg#= 0 Atr= MxPwr=&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bInterfaceNumber: No such file or directory&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bAlternateSetting: No such file or directory&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bNumEndpoints: No such file or directory&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bInterfaceClass: No such file or directory&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bInterfaceSubClass: No such file or directory&#xA;cat: /sys/bus/usb/devices/usb3/3-3/3-3.4/3-*:?.*/bInterfaceProtocol: No such file or directory&#xA;/usr/bin/usb-devices: line 79: printf: (none): invalid number&#xA;I:  If#= 0 Alt= 0 #EPs= 0 Cls=() Sub= Prot= Driver=&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Tentative conclusion&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Perhaps I somehow damaged that USB port by drawing too much current during testing at some earlier point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although ... now the mouse is working in the port where it was not working before, and the Leonardo has stopped working in the 3rd port, when it was previously not working in the 4th port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those error messages above must be relevant, but I don't know enough about it to say in what way.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-23T22:08:35.743" LastActivityDate="2015-09-23T22:08:35.743" Title="Two Leonardos on one USB hub - not working properly" Tags="|c++|arduino-leonardo|usb|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16277" PostTypeId="1" CreationDate="2015-09-23T09:38:11.583" Score="-1" ViewCount="166" Body="&lt;p&gt;I followed instructions to get my TFT to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VtD3P.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VtD3P.jpg&quot; alt=&quot;TFT photo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use other pins on the Arduino Uno for other I/O, so how can I use 4-bit data transfer for the TFT touchscreen?&lt;/p&gt;&#xA;" OwnerUserId="13555" LastEditorUserId="10003" LastEditDate="2015-09-25T22:05:53.310" LastActivityDate="2015-09-25T22:05:53.310" Title="TFT touch, 4bit data transfer" Tags="|1-wire|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16278" PostTypeId="2" ParentId="16276" CreationDate="2015-09-23T09:42:46.267" Score="1" Body="&lt;p&gt;There is no reason I can think of that would stop it working as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;lsusb&lt;/code&gt; is showing both the devices, so they are being detected by the kernel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can try running &lt;code&gt;usb-devices&lt;/code&gt; from the &lt;em&gt;usbutils&lt;/em&gt; package (should be already installed since &lt;code&gt;lsusb&lt;/code&gt; is in the same package) and look for the two Leonardo blocks. You should get two blocks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;T:  Bus=01 Lev=03 Prnt=07 Port=00 Cnt=01 Dev#= 11 Spd=12  MxCh= 0&#xA;D:  Ver= 2.00 Cls=00(&amp;gt;ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1&#xA;P:  Vendor=2341 ProdID=0036 Rev=01.00&#xA;S:  Manufacturer=Arduino LLC&#xA;S:  Product=USB IO Board    &#xA;C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA&#xA;I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm&#xA;I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm&#xA;I:  If#= 2 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The important bit is the &lt;code&gt;I:&lt;/code&gt; lines - they show the individual USB interfaces and what kernel driver has been associated with them.   For the keyboard, of course, it's the last entry, which is assigned to the &lt;code&gt;usbhid&lt;/code&gt; driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another good diagnostic is &lt;code&gt;dmesg -w&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run that with both Leonardos disconnected.  Plug one in and it should show it registering as a USB device.  A few moments later you should get a pair of lines like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 2106.937086] input: Arduino LLC USB IO Board     as /devices/pci0000:00/0000:00:1a.7/usb1/1-1/1-1.4/1-1.4.1/1-1.4.1:1.2/0003:2341:0036.0006/input/input21&#xA;[ 2106.990523] hid-generic 0003:2341:0036.0006: input,hidraw4: USB HID v1.01 Mouse [Arduino LLC USB IO Board    ] on usb-0000:00:1a.7-1.4.1/input2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is the board being associated with an input device (in this case input 2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat it with the second Leonardo and see if the same appears, but this time with a higher input number (it would be 3 on mine if I had a second Leonardo).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that the two Leonardos work together normally means that they should be working fine in any arrangement, so if the OS is seeing it all fine but the data isn't getting through, then my money is on the hub.  It looks quite a new hub, so it may have a few bugs in it that are yet to be ironed out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB devices are identified to the drivers using the VID and PID, but to the kernel the USB device is just a chain of bus/port numbers.  For instance my Leonardo above is identified as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1-1.4.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's USB bus 1, downstream port 1 (root hub - normally only has 1 port), which connects to a hub (the one built into the computer to drive multiple ports) which then has downstream port 4 connecting to a hub (on my desk) which then has downstream port 1 connecting to the device.  Nothing else can be connected to that same combination of downstream ports - it's physically impossible, so it's uniquely identified.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-23T11:10:23.910" LastActivityDate="2015-09-23T11:10:23.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16279" PostTypeId="2" ParentId="16277" CreationDate="2015-09-23T09:47:55.210" Score="1" Body="&lt;p&gt;You read the datasheet for the chip that is on your TFT display (whatever that is) and find if it even supports a 4-bit mode.  It probably doesn't. I have a large number of TFT screens here and I don't recall any of them using parallel 4-bit.  It sounds like you actually want a TFT screen that works of SPI rather than a parallel interface.  Those &lt;em&gt;are&lt;/em&gt; available, but by using SPI the screen updates are considerably slower.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-23T09:47:55.210" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16280" PostTypeId="1" AcceptedAnswerId="19448" CreationDate="2015-09-23T11:09:58.313" Score="2" ViewCount="7111" Body="&lt;p&gt;I'm looking for a way to wait for a response from an AT command to return OK or CONNECTED or whatever the command returns when it's true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can check if the serial is available, but that means I have to manually guess what time between commands to give them time to connect or start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ModemCommand(String command) {&#xA;  //Send command to modem&#xA;  mySerial.println(command);&#xA;  Serial.println(command);&#xA;  delay(100);&#xA;  while (!mySerial.available()) {&#xA;    //Wait for Response from modem&#xA;    Serial.println(F(&quot;No response yet&quot;));&#xA;    delay(1000);&#xA;  }&#xA;  while (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;    //Print response from modem&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;  //Linefeed after reponse&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ModemCommand(F(&quot;ATE0&quot;));&#xA;//Turn on echo&#xA;ModemCommand(F(&quot;AT+CFUN=1&quot;));&#xA;//Turn modem functions on&#xA;waitSec(8,F(&quot;turning on Modem functions&quot;));&#xA;ModemCommand(F(&quot;AT+CGREG?&quot;));&#xA;//GSM attached?&#xA;ModemCommand(F(&quot;AT+CSQ&quot;));&#xA;//Signal Quality&#xA;ModemCommand(F(&quot;AT+CSTT=\&quot;internet\&quot;&quot;));&#xA;//Set APN&#xA;ModemCommand(F(&quot;AT+CIICR&quot;));&#xA;//Connect to APN GPRS&#xA;waitSec(8,F(&quot;connecting to APN GPRS&quot;));&#xA;ModemCommand(F(&quot;AT+CIFSR&quot;));&#xA;//Get IP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how to do this?&lt;/p&gt;&#xA;" OwnerUserId="13557" LastEditorUserId="10907" LastEditDate="2016-01-11T13:10:26.827" LastActivityDate="2016-03-11T16:29:22.523" Title="Waiting for an AT command to complete" Tags="|serial|c++|arduino-pro-mini|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16281" PostTypeId="1" CreationDate="2015-09-23T11:52:18.393" Score="2" ViewCount="750" Body="&lt;p&gt;To reduce the components amount I don't want to put the  32.768 kHz oscillator on my own Due.&#xA;Can I leave the corresponding XTAL inputs unconnected?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the main target of the slow clock?&#xA;What I can not do with the high clock but can do with the slow one?&#xA;Will I face to any issues if I don't use the low freq. oscillator?&lt;/p&gt;&#xA;" OwnerUserId="11351" LastActivityDate="2015-09-24T12:33:57.117" Title="Arduino due slow clock" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16282" PostTypeId="1" CreationDate="2015-09-23T12:51:05.360" Score="3" ViewCount="876" Body="&lt;p&gt;Arduino does not recommend to program the Due board via Native port  as it is not reliable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If the MCU crashed for some reason it is likely that the soft erase procedure won't work as this procedure happens entirely in software on the SAM3X&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately Arduino doesn't say what is crash and how to solve this issue if your home made Due has only the Native port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have only several assumptions but not sure that they are correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due boot-loader starts only if the Flash is not programmed. If the code is programmed to the flash but is damaged the boot-loader will not&#xA;start. As the MCU is hanged it can not erase the flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be done in this situation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just push the erase button on the board. It will the erase the content of the memory and allow boot-loader to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the programming via the Native port should be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please correct me if I'm wrong.&lt;/p&gt;&#xA;" OwnerUserId="11351" LastActivityDate="2015-09-23T12:51:05.360" Title="Arduino Due native programming port" Tags="|arduino-due|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16283" PostTypeId="2" ParentId="16281" CreationDate="2015-09-23T13:22:12.980" Score="4" Body="&lt;p&gt;The slow clockr is primarily used for the real time clock (RTC) module inside the SAM3X chip.  It can also be routed to other places when you want a low speed clock source, but the only places it is actually &lt;em&gt;required&lt;/em&gt; are the RTC and the watchdog. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The slow clock can be generated from an internal RC oscillator instead of requiring an external crystal, but the accuracy and stability of the RC oscillator is many orders of magnitude worse than a crystal.  Trying to use that for the RTC module will result in the clock drifting over time.  The watchdog won't really care if the clock isn't perfectly accurate.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-23T13:22:12.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16284" PostTypeId="1" AcceptedAnswerId="16287" CreationDate="2015-09-23T18:38:19.543" Score="0" ViewCount="1378" Body="&lt;p&gt;I need to control about 6 RGB Led Strips from an Arduino Board. The problem is that i need 3 PWM outputs for each led strip, but each will have probably the same colors. I was wondering if i could put two strips receiving a signal from the same PWM output, then i would have to use half the PWM outputs but send the same signal for each pair of strips.&lt;/p&gt;&#xA;&lt;p&gt;The scheme i found is this one:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/system/assets/assets/000/002/693/medium800/led_strips_ledstripbjt.gif?1396785837&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://learn.adafruit.com/system/assets/assets/000/002/693/medium800/led_strips_ledstripbjt.gif?1396785837&quot; alt=&quot;arduino schematic&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And what i want is something like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/yokZr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yokZr.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Is this possible? What should i modify to make it work?&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="11486" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-23T22:22:52.910" Title="Light multiple RGB Led Strips from same 3 RGB PWM outputs" Tags="|led|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16285" PostTypeId="2" ParentId="9163" CreationDate="2015-09-23T19:00:01.153" Score="5" Body="&lt;p&gt;Industruino just came out a couple days ago: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://blog.arduino.cc/2015/09/21/industruino-makes-industrial-automation-easy-now-atheart/&quot; rel=&quot;noreferrer&quot;&gt;https://blog.arduino.cc/2015/09/21/industruino-makes-industrial-automation-easy-now-atheart/&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://industruino.com/page/home&quot; rel=&quot;noreferrer&quot;&gt;https://industruino.com/page/home&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?t=200&amp;amp;v=MhE1zlwsUu0&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/watch?t=200&amp;amp;v=MhE1zlwsUu0&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://industruino.com/shop/product/industruino-ind-i-o-kit-2&quot; rel=&quot;noreferrer&quot;&gt;https://industruino.com/shop/product/industruino-ind-i-o-kit-2&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also:&lt;br&gt;&#xA;1. &lt;a href=&quot;http://www.rugged-circuits.com/ruggeduino/&quot; rel=&quot;noreferrer&quot;&gt;Ruggeduino&lt;/a&gt; has much better pin protection than a standard Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the above may meet your need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(No, I am not affiliated in any way with the above links; I just saw the Industruino the other day on the Arduino website and wanted to point out a couple other options).&lt;/p&gt;&#xA;" OwnerUserId="7727" LastEditorUserId="7727" LastEditDate="2015-09-24T00:32:26.513" LastActivityDate="2015-09-24T00:32:26.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16286" PostTypeId="1" AcceptedAnswerId="16299" CreationDate="2015-09-23T20:02:07.137" Score="5" ViewCount="2950" Body="&lt;p&gt;I'm making a simple Infrared detector using a thermopile. I have a few extra capacitors than what that schematic says. I'm currently following another, but this is the gist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic and Breadboard- &lt;a href=&quot;https://i.stack.imgur.com/cvHXe.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cvHXe.jpg&quot; alt=&quot;Breadboard and Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I can add breadboard picture if needed. I don't have 10 points in this Stack so I can't post more than 2.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a 9V battery through a 24v - 5v regulator (had one around) to power my op amp and schematic. The signal from the OPAMP will be between 0-5V so voltage hasn't damaged the Arduino Uno. The final project will be something like: output &gt; A then power green, A &amp;lt; output &amp;lt; B power yellow, B &amp;lt; output red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that I'm getting an oscillating value from my Serial Monitor that goes from 0 to 1023 (or I have a conversion to change it back to output voltage. So 0V to 5V. See code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does this oscillation when I have the board connected to any of the AX pins (X=0-5) or nothing plugged in at all (I understand it will output weird numbers with the pin floating).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I had a picture of the serial monitor but I don't have 10 points to add more than 2 pictures. Please see image below&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the output from the OPAMP works because when I use a VoltMeter to read the output, it works fine. 0.3XXV when no flame, 5V when flame is directly on top of my theromopile. &lt;a href=&quot;https://i.stack.imgur.com/rIZ78.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rIZ78.jpg&quot; alt=&quot;Serial Monitor and VM&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would anyone happen to have a suggestion to why the Arduino is acting this way? The volt meter reading is directly out of the Op amp pin 1. &lt;strong&gt;no more than 2 links. AD822 op amp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code before adding if statements for the LED's. It was incorrect.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int TP=A2; // Assign Thermopile to pin A2&#xA;int val; // Declare readValue Variable&#xA;float Voltage; // Declare real world voltage variable - Float = in between variable&#xA;int ledG = 11;&#xA;int ledY = 12;&#xA;int ledR = 13;&#xA;&#xA;void setup() {&#xA; pinMode(TP,INPUT); // Declare Thermopile pin as input&#xA; pinMode(ledG, OUTPUT);&#xA; pinMode(ledR, OUTPUT);&#xA; pinMode(ledY, OUTPUT);&#xA; Serial.begin(9600); // Start your Serial Port&#xA;}&#xA;&#xA;void loop() {&#xA;  val = analogRead(TP); // Read Thermopile pin and place value into readValue&#xA;&#xA;  Voltage = (5./1023.)*val; // To do &quot;floating point math&quot; have a &quot;.&quot; //after the number. If not, it will return real number (5/1023 = 0) according to Arduino&#xA;&#xA;&#xA;Serial.println(Voltage); // Print readValue to Serial Monitor&#xA;  delay(100); // Delayed output to 1/4 a second  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6451" LastEditorUserId="6451" LastEditDate="2015-09-23T20:38:10.207" LastActivityDate="2015-09-24T12:43:32.827" Title="Arduino Analog Input Oscillating" Tags="|input|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16287" PostTypeId="2" ParentId="16284" CreationDate="2015-09-23T20:28:22.243" Score="0" Body="&lt;p&gt;You have few options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;do as you represented in the drawing: it should work, as I expect the transistors to not load too much the input.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;add a &lt;a href=&quot;http://www.digikey.com/product-search/en/integrated-circuits-ics/logic-buffers-drivers-receivers-transceivers/2556308&quot; rel=&quot;nofollow&quot;&gt;logic buffer&lt;/a&gt; inbetween the arduino and the driver stage&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use other pins from the arduino for driving the additional strips and bitbang the PWM, instead of using the HW blocks&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Whether the solution you propose (1) will work or not depends entirely on the max current that each PWM pin can output vs the total load from the 3 transistors it will have to drive.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-23T20:28:22.243" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16288" PostTypeId="2" ParentId="16270" CreationDate="2015-09-23T21:02:35.287" Score="0" Body="&lt;p&gt;Another answer to generating ultrasonic frequencies is to ditch the Arduino altogether - use a 555 timer circuit (for lower range frequency, probably up to low mHz), or a resonator. A quick search found a 2.4 gHz resonator for less than an Arduino. 555 timers can be tuned, resonators cannot. I think you could build a 555 square-wave generator for about $1-$2. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-23T21:02:35.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16290" PostTypeId="1" AcceptedAnswerId="16291" CreationDate="2015-09-24T06:31:16.523" Score="0" ViewCount="844" Body="&lt;p&gt;I would like to place analog sensor in a place, that is impractical to reach with a wire. But it looks like an overkill to use a separate small Arduino board to read and transmit sensor signal to main Arduino board at a close range (~1 m). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a cheap practical way to setup such sensor signal broadcast over RF without using Arduino board? Something that could work for considerable duration with a small tablet like battery?&lt;/p&gt;&#xA;" OwnerUserId="13576" LastEditorUserId="10794" LastEditDate="2015-09-24T07:07:48.103" LastActivityDate="2015-09-24T11:27:07.630" Title="Is there a away to transmit sensor signal over RF without Arduino?" Tags="|sensors|c++|power|analogread|rf|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16291" PostTypeId="2" ParentId="16290" CreationDate="2015-09-24T07:06:42.143" Score="1" Body="&lt;p&gt;You don't have to use a $30 Arduino. You can make a &quot;breadboard&quot; one for a few dollars, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jBTgZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jBTgZ.jpg&quot; alt=&quot;Breadboard Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;$5 for the chip and a couple of dollars for a couple of capacitors and resistors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Add to that a NRF24L01 transceiver like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WDHUg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WDHUg.jpg&quot; alt=&quot;NRF24L01&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Available from eBay for around $1 each. You need two, as you need to transmit from one and receive from another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the whole thing could be done for under $10.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Something that could work for considerable duration with a small tablet like battery?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-24T07:06:42.143" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16292" PostTypeId="1" AcceptedAnswerId="16329" CreationDate="2015-09-24T08:00:39.833" Score="7" ViewCount="65838" Body="&lt;p&gt;I have found a few good tutorials on how to send and receive data via I2C in connected arduinos. My limitation is now how to transmit different types of data like for instance, long, float, etc. Right now the communication via I2C using the wire library only allows transmission of numbers between 0 and 255. How can one transmit different types of numbers?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my code a master receives three types of data from the slave, and it send data of a fourth variable to the slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the code for the master&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;const int SLAVE_ADDRESS = 8; //Slave arduino ID&#xA;int table[]={0,0,0}; //the data will be transmited via table as to allow different data to be transfer.&#xA;void setup ()&#xA;{&#xA;Wire.begin ();   &#xA;Serial.begin (9600);  // start serial for output&#xA;}  // end of setup&#xA;void loop()&#xA;{&#xA;Wire.requestFrom(SLAVE_ADDRESS, 3);// request 3 bytes from slave device #8&#xA;&#xA;for(int i=0;i&amp;lt;3;i++)//organizes the data from the slave in the table&#xA;{&#xA;int c = Wire.read(); // receive a byte as character&#xA;table[i]=c;&#xA;}&#xA;//displays the data&#xA; Serial.print('\n');&#xA;   Serial.print(table[0]);&#xA;    Serial.print('\t');&#xA;   Serial.print(table[1]);&#xA;    Serial.print('\t');&#xA;   Serial.print(table[2]);&#xA;   Serial.print('\n');&#xA;&#xA;delay (500);   &#xA;&#xA;// transmit just this variable to the slave&#xA;int Work=1;&#xA;Wire.beginTransmission (8);&#xA;Wire.write (Work);&#xA;Wire.endTransmission ();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the code for the slave&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;int table[]={0,0,0};&#xA;int Work=0;&#xA;&#xA;void setup() {&#xA;Wire.begin(8);                // join i2c bus with address #8&#xA;Wire.onRequest(requestEvent); // register event&#xA;Wire.onReceive(receiveEvent); // register event&#xA;}&#xA;&#xA;void loop() {&#xA;int x=120;  &#xA;int y=1200;// gets converted to an strange # because is larger than 255&#xA;int z=3;&#xA;  table[0]=x;&#xA;  table[1]=y;&#xA;  table[2]=z;&#xA;}&#xA;&#xA;&#xA;void requestEvent()&#xA;{&#xA;  uint8_t Buffer[3];&#xA;  Buffer[0]=table[0];&#xA;  Buffer[1]=table[1];&#xA;  Buffer[2]=table[2];&#xA;  Wire.write(Buffer,3);&#xA;}&#xA;&#xA;void receiveEvent(int howMany)&#xA;{Work = Wire.read();}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2020-08-19T12:48:58.350" Title="Sending and receiving different types of data via I2C in Arduino" Tags="|arduino-uno|i2c|wire-library|float|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16293" PostTypeId="2" ParentId="13662" CreationDate="2015-09-24T08:29:04.093" Score="2" Body="&lt;p&gt;Nick gives some great advice, I am trying to answer your questions more directly.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do I need a stepper motor for slow rotations, instead of a normal brushed motor?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Many kinds of motors can be made to work.  I advise starting with the same type as in the Instructables you mention below.  You can change the speed with gears if the motor speed range is not good enough. &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Do I need to connect the arduino to computer to make it run? Can I run it off battery, if so, does it have an 'ON' button?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You only need to connect the Arduino to a computer to load or change the program. The motor is probably your biggest battery user, I would connect it to a separate battery from the Arduino. One advantage of the servo motors Nick mentions is that they are used by model car and airplane enthusiasts and there are lots of motors, batteries and battery chargers available.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;How long will a standard 9V battery last?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Not long!&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;For the code, I thought of using the simple one here: &lt;a href=&quot;http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;Arduino Motor Shield Tutorial&lt;/a&gt;. Would it be able to allow me to control the amount of rotation, speed and the ability to reverse its rotation?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I looked through this code and it should work well as long as you use the same type of motor. You may have to modify things if you need the stop and start points to be very precise, but this will get you started and is a big step beyond scanning by hand.&lt;/p&gt;&#xA;" OwnerUserId="13577" LastEditorUserId="6936" LastEditDate="2015-09-25T15:03:37.950" LastActivityDate="2015-09-25T15:03:37.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16294" PostTypeId="2" ParentId="16292" CreationDate="2015-09-24T08:50:49.160" Score="0" Body="&lt;p&gt;I believe that for your scenario, i.e. sending different types of variables, the EasyTransfer library (by Bill Porter) would be an elegant solution. The library can be found here: &lt;a href=&quot;https://github.com/madsci1016/Arduino-EasyTransfer&quot; rel=&quot;nofollow&quot;&gt;https://github.com/madsci1016/Arduino-EasyTransfer&lt;/a&gt;. There are implementations for serial, I2C, and VirtualWire and the examples provided are pretty self-explanatory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The handling is very easy. After including the library, you create an EasyTransfer object, define a data structure that basically represents a &quot;container&quot; of your data and this can consist of different variables. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct RECEIVE_DATA_STRUCTURE{&#xA;  //put your variable definitions here for the data you want to receive&#xA;  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO&#xA;  int blinks;&#xA;  int pause;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once the &quot;container&quot; is filled, i.e. the variables are set on the sender side, they are sent with a simple command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ET.sendData(I2C_SLAVE_ADDRESS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the receiver side, you define an identiacl data structureand receive the data by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ET.receiveData();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2015-09-24T08:50:49.160" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16295" PostTypeId="1" CreationDate="2015-09-24T10:46:50.017" Score="2" ViewCount="153" Body="&lt;p&gt;I have a piece of a broken camera flash (an old Yongnuo one) that has a single pin that tells the flash when to fire. The pin looks like this :&lt;a href=&quot;https://i.stack.imgur.com/pIQwm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pIQwm.jpg&quot; alt=&quot;bottom of flash module&quot;&gt;&lt;/a&gt;&#xA;(I guess the ring is the return/ground?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other side of the piece looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GP7am.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GP7am.jpg&quot; alt=&quot;circuit side of flash module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my guess isn't completely wrong, those four wires are the only thing that tell the rest of the flash unit what's going on, when. So if I plugged (two, three, all four?) of those pins into my arduino I could use it as an input, yes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I.e. Arduino would detect when the camera has taken a picture via this unit, and do something else (in my case open the gate on a mos for a length of time). No actual camera flash involved (just the signal)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: how do I determine which of these four wires carry the signal to the rest of the circuit, and can I plug this into my Arduino input pin? My multimeter is a cheap crappy one so I don't think it would react fast enough to measure a pulse like that...&lt;/p&gt;&#xA;" OwnerUserId="7635" LastActivityDate="2015-09-24T10:46:50.017" Title="can this piece of a camera flash send an input signal to my arduino?" Tags="|arduino-leonardo|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16296" PostTypeId="1" AcceptedAnswerId="16340" CreationDate="2015-09-24T10:55:17.627" Score="1" ViewCount="370" Body="&lt;p&gt;How do I make an electrical switch using Arduino, that when it receives signal (wirelessly or through a LAN port) to switch off it disconnects the switch and then again told to turn on turns the switch on? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem I am facing is that I need to give a 5V output to turn off the transmission between two wires having voltage rating of 230V.&lt;/p&gt;&#xA;" OwnerUserId="13579" LastEditorUserId="6936" LastEditDate="2015-09-25T12:28:53.410" LastActivityDate="2015-09-27T17:48:25.483" Title="Using an Arduino as a electrical mains switch" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16297" PostTypeId="2" ParentId="16290" CreationDate="2015-09-24T11:27:07.630" Score="1" Body="&lt;p&gt;I would recommend investigating the ESP8266 modules.  Many people use them as a WiFi interface to an Arduino, but they are also capable of being used completely standalone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can pick up a cheap module and program it using a readily available USB to TTL UART adapter using the ESP8266 plugin to the Aduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like having an Arduino and a WiFi interface all embedded in one chip, and the modules are tiny too - perfect for embedding in a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many different modules available, some with more pins than others for IO.  The best one is the NodeMCU since it has the programming interface built in (go for version 1.0 not version 0.9 since it has better IO options), but the higher end ESP8266 modules on carrier boards (ESP-12, etc) are as good, if a little harder to work with.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-24T11:27:07.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16298" PostTypeId="2" ParentId="16281" CreationDate="2015-09-24T12:33:57.117" Score="0" Body="&lt;p&gt;Atmel datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If the user does not need the crystal oscillator, the XIN32 and XOUT32 pins can be left unconnected&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11351" LastActivityDate="2015-09-24T12:33:57.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16299" PostTypeId="2" ParentId="16286" CreationDate="2015-09-24T12:43:32.827" Score="3" Body="&lt;p&gt;It seems you haven't connected the circuit ground to the Arduino ground.  This is essential to complete the circuit between your breadboard and the Arduino.  Without the ground connection the electrons that you send to the Arduino have no way of getting back again.&lt;/p&gt;&#xA;&lt;p&gt;Here's a couple of diagrams that I drew for another question which deals with the Arduino driving a remote device, but the theory holds true no matter which way around it is.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gFtVI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gFtVI.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In that diagram the red arrows (&lt;em&gt;not the aerial display team I hasten to add&lt;/em&gt;) represent the connection between your breadboard circuit and the Arduino.  Without the ground connection there is no circuit, and a circuit is always needed for current to flow (and hence your signal).  With the ground connection the red arrows become a loop which allows the current to flow and transfer your signal.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-24T12:43:32.827" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16300" PostTypeId="2" ParentId="4753" CreationDate="2015-09-24T12:49:59.847" Score="1" Body="&lt;p&gt;I recommend writing your own in C++.  Arduino works well with C++ as it is written in C.  You can focus on getting the asynchronous behavior to do what you need instead of writing drivers.  I don't think it will take any longer to learn enough C++ to make this work than it will to learn to use, and possibly fix, a library. Your C++ knowledge will be much more generally useful than knowing a specific library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Igor points out the advantages of going to a real time operating system.  I agree and think that, if you want to work on robots long term, you should go with an RTOS and get away from Arduino. Working with C++ and Arduino is one way to get started.&lt;/p&gt;&#xA;" OwnerUserId="13577" LastActivityDate="2015-09-24T12:49:59.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16301" PostTypeId="1" CreationDate="2015-09-24T13:52:39.557" Score="1" ViewCount="4321" Body="&lt;p&gt;I am making a counting device, and I would like to be ensure that the count is not lost if the power is lost.&#xA;As I need to count to many millions I cannot use EEPROM writes as I will trash the nvm after ripping through the 100,000 max write cycles. I also need to ensure the count is accurate, so can't update 'every-so-often' either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to write to EEPROM when the Arduino detects power down. I am reading on an Analogue input pin and am then planning on using a capacitor to hold the power on to complete the write. I have this set up but am having issues testing as I have found that when Ground is connected to GND pins and then when 5v is supplied to any I/O pin the device powers up. I have now tested a Nano and Uno and have found the same thing on both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked through the arduino site and tried looking for forums where this has been discussed, but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this damaging to the Arduino if powered in this way? Does this pass the sanity check as a way of achieving my main objective of not loosing the count on power down?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks in advance :)&lt;/p&gt;&#xA;" OwnerUserId="12133" LastActivityDate="2016-07-20T00:28:09.487" Title="Write to EEPROM during power down" Tags="|power|eeprom|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16302" PostTypeId="1" CreationDate="2015-09-24T14:09:37.420" Score="1" ViewCount="1372" Body="&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO&lt;/a&gt; is 5V, 16 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB 1.1 Low Speed spec operate:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;at 5V level - so we avoid to maintain voltage level&lt;/li&gt;&#xA;&lt;li&gt;at 1.5 Mb/s - so we have 16/1.5 ~= 10 instructions per elementary protocol signal&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make Arduino as slave USB device from UART lines connected to USB D+/D- interface with careful timing and assembler programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doesn't familiar with ATmega328P pin I/O capabilities, may be them can't operate at 1.5 MHz so project isn't possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; I found &lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow&quot;&gt;V-USB&lt;/a&gt; library that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;implementation of a low-speed USB device for Atmel’s AVR® microcontrollers,&#xA;making it possible to build USB hardware with almost any AVR® microcontroller,&#xA;not requiring any additional chip.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Still dig into docs to realize possibilities.&lt;/p&gt;&#xA;" OwnerUserId="13583" LastEditorUserId="13583" LastEditDate="2015-09-24T14:16:47.537" LastActivityDate="2015-09-24T15:33:51.920" Title="USB 1.1 Low Speed project for Arduino UNO/ATmega328P to learn USB protocol" Tags="|usb|project|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16303" PostTypeId="1" AcceptedAnswerId="16389" CreationDate="2015-09-24T14:11:21.420" Score="1" ViewCount="370" Body="&lt;p&gt;My project is having Arduino with my WiFi shield connect to Twitter and look for any messages that other users have tweeted at me that contain a certain color, (I.E. @myTwitterHandle I want red) and then changes an RGB LED to become that color. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been searching online for different methods, and found a few different solutions which I could use as a starting point. However, these apparently call to an old Twitter API that is not supported anymore (support stopped mid 2013).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution I came across was to use node-red as well as MQTT.  I am not too familiar with these programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to have Arduino parse a twitter account for mentions containing certain strings and have it print to LED? Any help with be appreciated &lt;/p&gt;&#xA;" OwnerUserId="13585" LastActivityDate="2015-09-28T23:00:20.467" Title="Linking Arduino With Twitter" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16304" PostTypeId="1" AcceptedAnswerId="16307" CreationDate="2015-09-24T14:18:27.240" Score="0" ViewCount="197" Body="&lt;p&gt;I am new to Arduino and this forum, so please forgive me if I am asking something really trivial and stupid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino board which collects sensor readings from an MPU6050 sensor (acceleration+gyroscope). The next step for me would be to process these data directly on the board. I want to somehow store N last sensor values and then query this set (collection, vector, array, whatever you call it) to fetch certain values. This set will be constantly updated with new values, whereas older values will be pushed out, so that only the most up-to-date values are stored in the set. For example, I want to know if the acceleration exceeded 10 m/s in the last minute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the literature this kind of set with most recent values is sometimes called &lt;em&gt;window&lt;/em&gt; - this approach allows limiting an unbounded sequence of constantly generated tuples to a bounded bag and then apply traditional SQL-like query operators. For example, Oracle has come with &lt;a href=&quot;http://docs.oracle.com/cd/E16764_01/doc.1111/e12048/intro.htm&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;CQL&quot;&gt;CQL&lt;/a&gt; - an engine and a query language for handling streaming data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I start implementing this, I am wondering if there is a similar (and, of course, much simpler) library for Arduino? If not, which data structure should I use to implement such functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, my intention is to query not just individual values, but certain patterns and sequences - e.g., I want to know if the acceleration first decreased and then increased again (something similar to the WHERE condition of an SQL query). Does it look realistic to implement with Arduino?&lt;/p&gt;&#xA;" OwnerUserId="13584" LastEditorUserId="26916" LastEditDate="2017-11-04T08:06:22.363" LastActivityDate="2017-11-04T08:06:22.363" Title="Querying streaming sensor data on the Arduino board" Tags="|programming|sensors|c++|library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16305" PostTypeId="2" ParentId="16296" CreationDate="2015-09-24T14:22:22.810" Score="1" Body="&lt;p&gt;As pointed out in the comments, I would need to use something known as a relay with my Arduino.&lt;/p&gt;&#xA;" OwnerUserId="13579" LastEditorUserId="220" LastEditDate="2015-09-27T17:48:25.483" LastActivityDate="2015-09-27T17:48:25.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16306" PostTypeId="2" ParentId="16301" CreationDate="2015-09-24T14:24:31.853" Score="0" Body="&lt;p&gt;The arduino chips have clamping diodes on all the GPIO pins. So if the voltage on one of the pins is above Vcc (which is 0v is there is no power applied to the chip), the internal diode will 'redirect' this voltage to the Vcc line. This will damage the chip, is too much current is going through the clamping diodes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, connect the 5v signal via a large resistor (e.g. 100k) to the input pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a capacitor (plus diode to prevent backfeeding) will work. You just have to be careful if you have connected anything to an output pin that uses current. An led running at 20mA will drain a charged capacitor pretty quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've done in the past is use the entire EEPROM space to store a single value. Just write every next value to a higher address. On powerup read the entire EEPROM till you find two adjacent address that don't contain successive numbers. Then you know where the last written value was, and you can read this last value, and continue writing the the address right after that one. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-09-24T14:24:31.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16307" PostTypeId="2" ParentId="16304" CreationDate="2015-09-24T14:31:32.757" Score="0" Body="&lt;p&gt;It sounds like you are after my Average library:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/Average&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/Average&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It allows you to store a rolling set of data where you get to &quot;push&quot; values into it and the oldest one drops off the end. (It's implemented internally using a circular buffer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then do various forms of analysis on the data - get the &lt;em&gt;mean&lt;/em&gt; average, the &lt;em&gt;mode&lt;/em&gt; average, calculate the standard deviation, find the maximum and minimum values of the set, and even access individual entries within the set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a fully templated library, so you can use it with any numerical data type (float, double, int, long, etc).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-24T14:31:32.757" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16308" PostTypeId="1" AcceptedAnswerId="16309" CreationDate="2015-09-24T14:53:45.417" Score="0" ViewCount="13764" Body="&lt;p&gt;Someone posted a solution for a problem I had which used Serial.read() .Why doesn't readString() seem to work though? From the docs it seems it reads the data as a String object which would make things a bit cleaner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But here's my Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;&#xA;arduinoSerialData = serial.Serial('com7', 9600, timeout=0)&#xA;&#xA;while True:&#xA;    arduinoSerialData.write('ALIVE\r\n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Serial.readString() == &quot;ALIVE&quot;) {&#xA;        digitalWrite(13, HIGH);&#xA;    } else {&#xA;        digitalWrite(13, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If this was right, the green LED on the Arduino would light up when the Python program would run, but it doesn't. What is Serial.readString() expecting that it doesn't get?&#xA;I even tried &lt;code&gt;if (Serial.readString().startsWith(&quot;ALIVE&quot;))&lt;/code&gt; instead, as well as &lt;code&gt;arduinoSerialData.flush()&lt;/code&gt; before &lt;code&gt;arduinoSerialData.write()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13501" LastEditorUserId="13501" LastEditDate="2015-09-24T15:42:01.620" LastActivityDate="2015-09-24T15:42:01.620" Title="Serial.readString() - how does it work exactly?" Tags="|serial|python|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16309" PostTypeId="2" ParentId="16308" CreationDate="2015-09-24T15:00:14.180" Score="3" Body="&lt;p&gt;&lt;code&gt;readString()&lt;/code&gt; will read characters from the serial (or other Stream) device until a timeout occurs.  That timeout is, by default, 1 second.  It is only appropriate to use &lt;code&gt;readString()&lt;/code&gt; if your data is arriving in chunks with a minimum time between each chunk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is more appropriate to use &lt;code&gt;readStringUntil()&lt;/code&gt; which will read characters from the serial device until &lt;em&gt;either&lt;/em&gt; it times out, &lt;em&gt;or&lt;/em&gt; it receives a certain character.  It is most common to use either the line feed (&lt;code&gt;\n&lt;/code&gt;) or carriage return (&lt;code&gt;\r&lt;/code&gt;) characters as the end of string marker.  You must, of course, ensure that your sending program sends the string terminated in the right way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that all said, you really should avoid using String objects when possible, since the constant creation and destruction of temporary objects all over the place can make a real mess of your heap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is far better to learn to use character arrays and fill them using &lt;code&gt;Serial.read()&lt;/code&gt;.  A tutorial I wrote for that is here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-24T15:00:14.180" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="16310" PostTypeId="2" ParentId="16302" CreationDate="2015-09-24T15:33:51.920" Score="1" Body="&lt;p&gt;Not exactly the answer to your question, but have you tried the &lt;a href=&quot;http://smartinteractionlab.com/lufa-example-turning-your-arduino-into-a-keyboard/&quot; rel=&quot;nofollow&quot;&gt;typical&lt;/a&gt; way to emulate slave devices with Arduino UNO?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses the 2nd ATMega present onboard (this applies only to UNO, afaik) and lets you use the main ATMega for other tasks, delegating the USB protocol to the smaller ATMega16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any specific reason why you would use the serial lines?&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-24T15:33:51.920" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16312" PostTypeId="1" AcceptedAnswerId="16319" CreationDate="2015-09-24T16:11:43.723" Score="0" ViewCount="209" Body="&lt;p&gt;I'm both sending and receiving strings to Arduino from my Python program on the PC and the opposite. I don't check by code if one is finished before doing the other. Are they seprate buffers, or is it just pure luck my program has been running fine until now and each program has been reading the right string ?&lt;/p&gt;&#xA;" OwnerUserId="13501" LastEditorUserId="13501" LastEditDate="2015-09-24T16:17:40.530" LastActivityDate="2018-01-16T00:37:44.707" Title="Is the Serial buffer going from Arduino to PC and from PC to Arduino different?" Tags="|serial|arduino-nano|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16313" PostTypeId="1" CreationDate="2015-09-24T17:24:10.840" Score="0" ViewCount="190" Body="&lt;p&gt;I have bricked a few AT328P by invalid fuse settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anybody used the above sketches and the associated circuitry to perform high voltage programming?&lt;/p&gt;&#xA;" OwnerUserId="13590" LastEditorUserId="9962" LastEditDate="2016-02-25T20:20:42.013" LastActivityDate="2016-02-25T20:20:42.013" Title="Is it difficult to do high voltage parallel programming using Nick Gammon library?" Tags="|arduino-uno|fuses|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16314" PostTypeId="1" AcceptedAnswerId="16326" CreationDate="2015-09-24T18:09:22.717" Score="0" ViewCount="143" Body="&lt;p&gt;I'm new to the arduino and to EE in general. I've built the basic examples and a, now trying to get a deeper understanding of what the physics is doing. As such, I'd like some help in understanding the diagram here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Blink&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically,it seems that the flow is going from Pin 13 to Ground. Is the diagram using the conventional flow or the electron flow approach. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, is it the &lt;em&gt;electrons&lt;/em&gt; flowing from Pin 13 to ground or does the diagram show protons flowing? It seems that its showing the electron flow as the diagram has the anode attached to the resistor so the electrons flow from the pin to the resistor to the positive end (anode) of the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 2:&lt;/strong&gt;&#xA;This is about bread boards, like one shown here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.com/search?q=arduino+breadboard&amp;amp;biw=1696&amp;amp;bih=988&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0CFEQsARqFQoTCIjsw5WhkMgCFdWYiAodttcKIw#tbm=isch&amp;amp;q=breadboard&amp;amp;imgrc=KwnTrtjnYJdB1M%3A&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com/search?q=arduino+breadboard&amp;amp;biw=1696&amp;amp;bih=988&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0CFEQsARqFQoTCIjsw5WhkMgCFdWYiAodttcKIw#tbm=isch&amp;amp;q=breadboard&amp;amp;imgrc=KwnTrtjnYJdB1M%3A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Would I connect Pin 13 (or say the 5V pin) to the + (the red line). Then I would connect the blue line (the -) to the ground on the arduino? Do I need to connect the blue line? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Also, is it again the electron flow notation so that from Pin 13, the electrons flow to the + (red), then to one of the lettered columns and then to whatever component I have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help! I realize these are basic questions but I want to go a little beyond building the examples and start trying things out myself. As such I want to make sure I'm getting the theory behind it right!&lt;/p&gt;&#xA;" OwnerUserId="13592" LastActivityDate="2015-09-24T22:14:32.390" Title="Arduino circuit diagram help" Tags="|arduino-uno|electronics|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16315" PostTypeId="1" AcceptedAnswerId="16316" CreationDate="2015-09-24T12:59:18.570" Score="0" ViewCount="150" Body="&lt;p&gt;I had a very common question. Why a additional MEGA used in most of the Arduino Boards. Arduino board Mega2560 also have a MEGA16U2 controller on board which i think is used for programming via USB. Is there any other specific usage of atmega16 on arduino board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16206" OwnerDisplayName="srj0408" LastActivityDate="2015-09-24T18:42:55.970" Title="atmega16 in Arduino Board" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16316" PostTypeId="2" ParentId="16315" CreationDate="2015-09-24T13:06:59.043" Score="3" Body="&lt;p&gt;It's an ATmegaU2, which has USB hardware and handles the USB communication. It passes the hex file on to the bootloader in the main microcontroller. That is its only job.&lt;/p&gt;&#xA;" OwnerDisplayName="Matt Young" LastActivityDate="2015-09-24T14:09:28.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16317" PostTypeId="2" ParentId="16314" CreationDate="2015-09-24T18:57:16.253" Score="2" Body="&lt;p&gt;It doesn't matter whether you use conventional current or electron current to describe a circuit; in the end they give the same results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Protons are not a charge carrier in 99.99999% of circuits; positive charge carriers are the quasiparticles known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Electron_hole&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;holes&lt;/strong&gt;&lt;/a&gt;, but they only flow in semiconductors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power rails on a breadboard should be used for power only, never signals. It is possible to use them for other things, and it is possible to not use them at all, but when they are used they should only be used for supply in order to cause the least confusion.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-24T18:57:16.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16318" PostTypeId="2" ParentId="16313" CreationDate="2015-09-24T18:57:47.200" Score="1" Body="&lt;p&gt;I have not tried with those instructions, as I have an AVRDragon, but it's a good exercise for precision, since you have to wire lots of pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;20+ iirc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that if anything fails, it's likely to be because of a mistake in the wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are planning to do it often, you might consider soldering the wires and the ZIF socket to a prototype board, to preserve your mental sanity.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-24T18:57:47.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16319" PostTypeId="2" ParentId="16312" CreationDate="2015-09-24T19:16:48.597" Score="0" Body="&lt;p&gt;There shall be separate buffers for Tx and Rx (in Arduino Serial library). The actual buffer size may vary, &lt;strike&gt;but shall be around 8-16 bytes and there is also hardware buffer in MCU&lt;/strike&gt;. Please try to increase serial baudrate, if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD:&lt;/strong&gt; In HardwareSerial.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if (RAMEND &amp;lt; 1000)&#xA;#define SERIAL_TX_BUFFER_SIZE 16&#xA;#else&#xA;#define SERIAL_TX_BUFFER_SIZE 64&#xA;#endif&#xA;&#xA;....&#xA;&#xA;unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];&#xA;unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;It seems for Atmega328 the buffers are 16 bytes each&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD:&lt;/strong&gt; As Nick pointed, for Atmega328:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RAMEND       0x8FF     /* Last On-Chip SRAM Location */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the buffers are 64 byte each.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="612" LastEditDate="2018-01-16T00:37:44.707" LastActivityDate="2018-01-16T00:37:44.707" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16322" PostTypeId="2" ParentId="12927" CreationDate="2015-09-24T19:45:47.750" Score="1" Body="&lt;p&gt;If you would like to use more than 1 Wiegand reader, technically it should be possible to use &lt;strong&gt;AVR pin change interrupt&lt;/strong&gt;. In this case you can use ANY 2 pins, even analog pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, see &lt;a href=&quot;http://thewanderingengineer.com/2014/08/11/arduino-pin-change-interrupts/&quot; rel=&quot;nofollow&quot;&gt;http://thewanderingengineer.com/2014/08/11/arduino-pin-change-interrupts/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPD:&lt;/strong&gt; There is informationon Wiegand timing, might be useful:&#xA;&lt;a href=&quot;http://proxclone.com/wiegand.html&quot; rel=&quot;nofollow&quot;&gt;http://proxclone.com/wiegand.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="13594" LastEditDate="2015-09-24T20:01:07.150" LastActivityDate="2015-09-24T20:01:07.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16323" PostTypeId="2" ParentId="4672" CreationDate="2015-09-24T20:07:13.063" Score="-1" Body="&lt;p&gt;A google search for DC6688F2SC  returns spec sheet under Dragonchip (&lt;a href=&quot;http://www.dragonchip.com/TechDoc/DC6688F2SCN/Help.htm&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). It's actually a rather nice chip when you look up the specs on it.&lt;/p&gt;&#xA;" OwnerUserId="13596" LastEditorUserId="220" LastEditDate="2015-09-27T17:50:54.557" LastActivityDate="2015-09-27T17:50:54.557" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16324" PostTypeId="1" CreationDate="2015-09-24T20:53:47.500" Score="0" ViewCount="930" Body="&lt;p&gt;My name is Gianni, I live in Olbia Sardinia Italy and I have some experience in electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For several years I have been passionate about Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are now engaged in a project to counter with hall sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The slave sends data to the master via I2C, for my project. I'm using the &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;sketch of Gammon&lt;/a&gt; which uses a structure enum to send a request to the slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the need to send a reset command from master to slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I edited the sketch and I can see the command on the slave but will not let me use it to reset the counter.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Master code section&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   void RstCounter() &#xA;  {&#xA;&#xA;  Serial.println (&quot;funzione azzera attivata&quot;);  &#xA;   Serial.println (sensor);&#xA;  char key = keypad.getKey();   &#xA;  if (key !='A')  &#xA;  {&#xA;&#xA;   char cmdrst = 'a';&#xA;   //set=key; &#xA;&#xA;     if (sensor==11)&#xA;    {&#xA;    sendCommand (CMD_WRITE_D2, 1);&#xA;&#xA;    Wire.beginTransmission(SLAVE_ADDRESS); // testiamo questa istruzione&#xA;    Wire.write(cmdrst);    &#xA;    Wire.endTransmission();&#xA;&#xA;    delay(100);&#xA;    Serial.println (cmdrst);  &#xA;    }&#xA;&#xA;   else &#xA;  {&#xA;  m=0;&#xA;  }&#xA;&#xA;   azzera =true; &#xA;  }&#xA;   else if (key=='A') &#xA;    { &#xA;   Serial.println(&quot;&quot;);&#xA;   Serial.println(&quot;AZZERA close&quot;);&#xA;   azzera = false;&#xA;   }&#xA;     delay(100);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;SLAVE code section&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;const byte MY_ADDRESS = 42; // address in valore esadecimale&#xA;&#xA;/************  VARIABILI SENSORI **********************/&#xA;&#xA;#define Sensor11 2  &#xA;int lastValueSensor11 =0;&#xA;int ValueSensor11=0;&#xA;int contatore11=0;&#xA;int counter11;&#xA;&#xA;&#xA;&#xA;// various commands we might get&#xA;/************  VARIABILI ENUMERATORE **********************/&#xA;enum {&#xA;    CMD_ID = 1,&#xA;    CMD_READ_D2  = 2,&#xA;    CMD_READ_D3 = 3,&#xA;    CMD_READ_D4 = 4,&#xA;    CMD_WRITE_D2 = 5&#xA;    };&#xA;&#xA;char command;&#xA;int sensor;&#xA;char cmdrst;&#xA;&#xA;/************  SETUP **********************/&#xA;void setup() &#xA;  {&#xA;  command = 0;&#xA;&#xA;  pinMode (Sensor11, INPUT);&#xA;  digitalWrite (Sensor11, HIGH);  // enable pull-up&#xA;&#xA;  Serial.begin(9600);&#xA;  Wire.begin (MY_ADDRESS);&#xA;  Wire.onReceive (receiveEvent);  // interrupt handler for incoming messages&#xA;  Wire.onRequest (requestEvent);  // interrupt handler for when data is wanted&#xA;&#xA;  }  // end of setup&#xA;&#xA;/************  LOOP **********************/&#xA;void loop() &#xA;  {&#xA;        /************************ CONTATORE SENSOR 1 ***********************/&#xA;   ValueSensor11  = digitalRead(Sensor11); &#xA;&#xA;            if ( ValueSensor11 != lastValueSensor11) &#xA;               { if ( ValueSensor11 == LOW)&#xA;                    { &#xA;                      contatore11 = contatore11 + 1; &#xA;&#xA;                        }&#xA;                     }&#xA;   lastValueSensor11 = ValueSensor11;&#xA;&#xA;&#xA;&#xA;/************  I2C RECEIVE **********************/&#xA;void receiveEvent (int howMany)&#xA;  {&#xA;&#xA;  command = Wire.read ();  // remember command for when we get request&#xA;  //Serial.println(command);&#xA;  switch (command)&#xA;     {&#xA;     case CMD_WRITE_D2:  &#xA;     Serial.println(&quot;comando 5 ricevuto&quot;);     &#xA;     char cmdrst=Wire.read();&#xA;     delay(100);        &#xA;     Serial.println (cmdrst);&#xA;     break;&#xA;    }&#xA;} // end of receiveEvent&#xA;&#xA;&#xA;void sendSensor1 (const byte which)&#xA;  {&#xA;  int val11 = contatore11;&#xA;  Serial.println(contatore11);&#xA;  byte buf11 [2];&#xA;&#xA;    buf11 [0] = val11 &amp;gt;&amp;gt; 8;&#xA;    buf11 [1] = val11 &amp;amp; 0xFF;&#xA;    Wire.write (buf11, 2);&#xA;  }  // end of sendSensor&#xA;&#xA;&#xA;&#xA;void requestEvent ()&#xA;  {&#xA;  switch (command)&#xA;     {&#xA;     case CMD_ID:       &#xA;     Wire.write (0x55); &#xA;     break;   // send our ID &#xA;&#xA;&#xA;     case CMD_READ_D2:  &#xA;     sendSensor1 (2);    &#xA;     break;  // send A0 value&#xA;&#xA;&#xA;     case CMD_READ_D3:  &#xA;     sendSensor2 (3); &#xA;     break;    // send D8 value&#xA;&#xA;&#xA;     case CMD_READ_D4:  &#xA;     sendSensor3 (4); &#xA;     break;&#xA;&#xA;     }  // end of switch&#xA;&#xA;  }  // end of requestEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13597" LastEditorUserId="10794" LastEditDate="2015-09-24T21:37:24.990" LastActivityDate="2016-02-22T00:04:45.307" Title="I2C Master send reset command to the slave counter" Tags="|c++|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16325" PostTypeId="2" ParentId="16314" CreationDate="2015-09-24T21:25:31.373" Score="1" Body="&lt;p&gt;Protons don't flow. They are part of the atom nucleus. If they flowed the copper wire would be flowing. Electrons are what flow, particularly if there are some free ones hanging around, like teenagers hanging around a mall.&lt;/p&gt;&#xA;&lt;p&gt;You don't need to worry about that however. Most people think of current as flowing from positive to negative (ie. pin 13 to ground) even if in fact the electrons are flowing from ground to pin 13.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.allaboutcircuits.com/textbook/direct-current/chpt-1/conventional-versus-electron-flow/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Conventional Versus Electron Flow&lt;/a&gt;. I quote:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When Benjamin Franklin made his conjecture regarding the direction of charge flow (from the smooth wax to the rough wool), he set a precedent for electrical notation that exists to this day, despite the fact that we know electrons are the constituent units of charge, and that they are displaced from the wool to the wax—not from the wax to the wool—when those two substances are rubbed together. This is why electrons are said to have a negative charge: because Franklin assumed electric charge moved in the opposite direction that it actually does, and so objects he called “negative” (representing a deficiency of charge) actually have a surplus of electrons.&lt;/p&gt;&#xA;&lt;p&gt;By the time the true direction of electron flow was discovered, the nomenclature of “positive” and “negative” had already been so well established in the scientific community that no effort was made to change it, although calling electrons “positive” would make more sense in referring to “excess” charge. You see, the terms “positive” and “negative” are human inventions, and as such have no absolute meaning beyond our own conventions of language and scientific description. Franklin could have just as easily referred to a surplus of charge as “black” and a deficiency as “white,” in which case scientists would speak of electrons having a “white” charge (assuming the same incorrect conjecture of charge position between wax and wool).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Quote courtesy of Design Science under &lt;a href=&quot;https://www.gnu.org/licenses/dsl.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this license&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Would I connect Pin 13 (or say the 5V pin) to the + (the red line). Then I would connect the blue line (the -) to the ground on the arduino? Do I need to connect the blue line?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;When using a breadboard I connect the 5V pin to the red line, the Gnd pin to the blue line, and other things (signals) to the internal (numbered) holes. The internal ones are connected cross-ways, so that is useful, for example, to put a series resistor for the LED there.&lt;/p&gt;&#xA;&lt;p&gt;I trust you are using a resistor for the LED, if not you might damage both the LED and the Arduino. See &lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/LEDs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The care and feeding of LEDs&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-09-24T21:25:31.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16326" PostTypeId="2" ParentId="16314" CreationDate="2015-09-24T21:38:13.823" Score="5" Body="&lt;p&gt;The thing to remember about electrons is they are a negative charge.  That means that the direction of current flow (positive charge) is opposite to the direction of flow of the actual electrons (negative charge). Picture it like those &quot;compression jams&quot; you get on the motorway (freeway) where cars that are travelling too close together have to slam their breaks on to avoid running into each other.  The one at the front slams its breaks on briefly then carries on. The one behind has to do the same, and so on and so forth.  You then get a wave effect travelling in the opposite direction to the direction of travel of cars as they slam their breaks on in turn.  The cars are moving forwards, but the compression jam is moving backwards.  Similar in a circuit - the electrons are moving forward, but the charge is moving backwards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to visualize it is as a bubble in a pipe of stationary water.  The bubble moves in one direction, but in order for it to do that the water has to flow past the bubble in the opposite direction.&lt;sup&gt;*&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the current flows out of pin 13 through the LED and to ground, but the electrons themselves are actually flowing from ground through the LED and in to pin 13 (where they eventually return back to ground through the power supply).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For how the IO pin works it's best to picture it as a pair of switches - one connected to Vcc and one connected to GND.  For instance, this is the LED wired up with the IO pin set to HIGH:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gWOUn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gWOUn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that S1, being on, forms a circuit between the battery and the LED to allow the current to flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the IO pin is set to LOW the circuit looks a bit like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Atfxx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Atfxx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You see that S1 is now turned off, and S2 is turned on.  the connection from that battery is now broken, and current can't flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, you ask, what is the point of S2 here? It doesn't actually do anything.  No, not in that circuit it doesn't. But consider if you re-arrange the circuit to be like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uaV1O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uaV1O.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it's S2 that is controlling the connection to the battery.  S1 is now the redundant switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads to some terminology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When S1 is closed the IO pin is said to &lt;em&gt;source&lt;/em&gt; current since it is pretty much connected directly to the positive power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When S2 is closed instead the IO pin is said to &lt;em&gt;sink&lt;/em&gt; current since it is connected to ground, so current can &quot;sink&quot; down to ground through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as breadboards are concerned - they are just collections of metal strips that are used to join wires and component leads together in whatever way you need to.  There is no one part of it that is any different to any other, and there is nothing that says you must use this bit in a certain way, or that bit in another way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your typical breadboard has sprung metal clips that are arranged in this pattern:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u220p.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u220p.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use any collection of holes for any purpose you choose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, normally the blue (or black) marked line of holes down each side is used for ground, and the red line of holes is used for power.  As both sides of the board are separate it is possible to use different voltages on each side, or the same voltage on both sides, etc.  That can be especially useful when you're working on a circuit that has, say, +3.3V and +5V in it.  Another common split usage is for a positive voltage on one side and a negative voltage on the other - common when working with op-amps.  Just remember which is which.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt; This is a complete lie, but it's as close as you need to know at this point in your education. &lt;a href=&quot;https://en.wikipedia.org/wiki/Lie-to-children&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Lie-to-children&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-09-24T22:14:32.390" LastActivityDate="2015-09-24T22:14:32.390" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="16327" PostTypeId="2" ParentId="16324" CreationDate="2015-09-24T21:42:08.240" Score="1" Body="&lt;pre&gt;&lt;code&gt;void receiveEvent (int howMany)&#xA;  {&#xA;&#xA;  command = Wire.read ();  // remember command for when we get request&#xA;  //Serial.println(command);&#xA;  switch (command)&#xA;     {&#xA;     case CMD_WRITE_D2:  &#xA;     Serial.println(&quot;comando 5 ricevuto&quot;);     &#xA;     char cmdrst=Wire.read();&#xA;     delay(100);        &#xA;     Serial.println (cmdrst);&#xA;     break;&#xA;    }&#xA;} // end of receiveEvent&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't do serial prints inside an interrupt service routine (ISR). That is, not here. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't do &lt;code&gt;delay&lt;/code&gt; inside an ISR.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (key !='A')  &#xA;  {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would be checking for NO_KEY first, otherwise you will assume that no key press is not 'A' and be doing that transmission to the slave &lt;strong&gt;a lot&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-24T21:42:08.240" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16329" PostTypeId="2" ParentId="16292" CreationDate="2015-09-25T01:58:14.913" Score="3" Body="&lt;p&gt;I2C is truly a powerful option of Arduino, for too many reasons; yet the amount of tutorials available are not that many and unfortunately are too complicated for the average person. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After working on this for 2 days, I think I have a way to transfer pretty much anything between master and slaves and viceversa. Note that I2C does not transfer floats or even integers larger than 255, there are several ways to go about this and here is a good tutorial &#xA;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/i2c&lt;/a&gt;&#xA;and even a library: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=171682.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=171682.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution I found was simpler. Basically we convert any value, string, number, text, float, you name it, and turn into a variable char, which can be transferred via I2C. Once transferred, you can convert back to a number although in my case below, I just wanted to display the data from the slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code. I provide comments on different parts for clarity. I hope this helps. it worked for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//master&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;char t[10]={};//empty array where to put the numbers comming from the slave&#xA;volatile int Val; // varaible used by the master to sent data to the slave&#xA;&#xA;void setup() {&#xA;  Wire.begin();        // join i2c bus (address optional for master)&#xA;  Serial.begin(9600);  // start serial for output&#xA;}&#xA;&#xA;void loop() {&#xA;  Wire.requestFrom(8, 3);    // request 3 bytes from slave device #8&#xA;&#xA;//gathers data comming from slave&#xA;int i=0; //counter for each bite as it arrives&#xA;  while (Wire.available()) { &#xA;    t[i] = Wire.read(); // every character that arrives it put in order in the empty array &quot;t&quot;&#xA;    i=i+1;&#xA;  }&#xA;&#xA;Serial.println(t);   //shows the data in the array t&#xA;delay(500); //give some time to relax&#xA;&#xA;// send data to slave. here I am just sending the number 2&#xA;  Val=2;&#xA;  Wire.beginTransmission (8);&#xA;  Wire.write (Val);&#xA;  Wire.endTransmission ();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here the other part&#xA;    //slave&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;char t[10]; //empty array where to put the numbers going to the master&#xA;volatile int Val; // variable used by the master to sent data to the slave&#xA;&#xA;void setup() {&#xA;  Wire.begin(8);                // Slave id #8&#xA;  Wire.onRequest(requestEvent); // fucntion to run when asking for data&#xA;  Wire.onReceive(receiveEvent); // what to do when receiving data&#xA;  Serial.begin(9600);  // serial for displaying data on your screen&#xA;}&#xA;&#xA;void loop() {&#xA;  int aRead = analogRead(A0); //plug a potentiometer or a resistor to pin A0, so you can see data being transfer&#xA;  float x = aRead/1024.0*5.0; //generate a float number, with this method you can use any time of data pretty much &#xA;&#xA;  dtostrf(x, 3, 2, t); //convers the float or integer to a string. (floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, empty array);&#xA;  Serial.println(Val);         // print the character&#xA; delay(500);&#xA;}&#xA;&#xA;// function: what to do when asked for data&#xA;void requestEvent() {&#xA;Wire.write(t); &#xA;}&#xA;&#xA;// what to do when receiving data from master&#xA;void receiveEvent(int howMany)&#xA;{Val = Wire.read();}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2015-09-25T01:58:14.913" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16330" PostTypeId="1" AcceptedAnswerId="19426" CreationDate="2015-09-25T03:09:21.167" Score="1" ViewCount="355" Body="&lt;p&gt;This is a broad question but I want advice on what type of hardware I should look for to make a device that could measure the velocity of an object attached via a string/wire to some sort of rotary wheel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of this is to attach it to a barbell and measure mean-velocity for weightlifting atheletes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a software engineer by trade but know nothing about hardware. I will obviously need to start with simple projects to learn, but I would like to know which hardware I should lean towards buying, so I don't have to re-buy anything?&lt;/p&gt;&#xA;" OwnerUserId="13605" LastActivityDate="2016-01-11T13:16:57.127" Title="Hardware to measure velocity via string/wire attatchment? beginner" Tags="|accelerometer|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16334" PostTypeId="1" AcceptedAnswerId="16335" CreationDate="2015-09-25T07:03:14.473" Score="0" ViewCount="70" Body="&lt;p&gt;I'm playing with a 7 segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following works on my breadboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5V -&amp;gt; 330 Ohm Resistor (same row, row 9)&#xA;330 Ohm Resistor -&amp;gt; Com Port (row 9 to row 15)&#xA;h led (the dot/row 17) -&amp;gt; ground rail&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the dot to light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the following does not light up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5V -&amp;gt; h led (the dot/row 17)&#xA;Com Port -&amp;gt; 330 Ohm Resistor (Row 15 -&amp;gt; row 38). &#xA;330 Ohm Resistor to negative rail (row 38 -&amp;gt; negative rail)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I realize that the row numbers are meaningless -- things just need to be on the same row. I've included them to make it easier to visualize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, if the circuit goes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5V -&gt; Resistor -&gt; Com, then I can use the ground wire to light up any part I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the circuit goes Com -&gt; Resistor to Ground, I can't use the 5V to light up any part. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why given that all the stuff is in serial?&lt;/p&gt;&#xA;" OwnerUserId="13592" LastEditorUserId="13592" LastEditDate="2015-09-25T07:09:36.237" LastActivityDate="2015-09-25T07:13:00.943" Title="help with 7- segment display" Tags="|serial|led|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16335" PostTypeId="2" ParentId="16334" CreationDate="2015-09-25T07:13:00.943" Score="2" Body="&lt;p&gt;Because you have a common-anode display and you're trying to use it as a common-cathode display. LEDs, like all diodes, only conduct freely in one direction.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-25T07:13:00.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16339" PostTypeId="1" CreationDate="2015-09-25T12:57:41.783" Score="1" ViewCount="1575" Body="&lt;p&gt;I want to print Bitmap image from thermal printer, but image data is from Serial Input. But I am not getting valid print. What wrong i am doing ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is code i wrote &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_Thermal.h&quot;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;// PIN 6 -&amp;gt; Yellow&#xA;// PIN 5 -&amp;gt; Green&#xA;// GND -&amp;gt; Black &#xA;&#xA;#define TX_PIN 6 &#xA;#define RX_PIN 5&#xA;&#xA;SoftwareSerial mySerial(RX_PIN, TX_PIN);&#xA;Adafruit_Thermal printer(&amp;amp;mySerial);&#xA;&#xA;int count =0;&#xA;void setup() {&#xA;  pinMode(7, OUTPUT); &#xA;  digitalWrite(7, LOW);&#xA;  mySerial.begin(9600);  // Initialize SoftwareSerial&#xA;  printer.begin();        // Init printer (same regardless of serial type)&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.print(&quot;1&quot;);&#xA;&#xA;&#xA;  //printer.printBitmap(384, 5, image);&#xA;&#xA;  //printer.feed(2);&#xA;&#xA;  printer.sleep();      // Tell printer to sleep&#xA;&#xA;  delay(3000L);         // Sleep for 3 seconds&#xA;  printer.wake();       // MUST wake() before printing again, even if reset&#xA;  printer.setDefault(); // Restore printer to defaults&#xA;}&#xA;&#xA;void loop() {&#xA;    if(Serial.available()&amp;gt;48){&#xA;      uint8_t image[50];&#xA;      Serial.readBytes(image,48);&#xA;      printer.printBitmap(384, 1, image);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13500" LastActivityDate="2015-09-25T12:57:41.783" Title="Printing bitmap image from thermal printer using Serial input" Tags="|arduino-uno|serial|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16340" PostTypeId="2" ParentId="16296" CreationDate="2015-09-25T13:53:37.080" Score="4" Body="&lt;p&gt;You need to use &lt;a href=&quot;https://en.wikipedia.org/wiki/Relay&quot; rel=&quot;nofollow&quot;&gt;Relays&lt;/a&gt;.  There all kind of relays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regular and Solid state ... for controlling a Regular Relay using Arduino you will need a transistor (so you will able to provide the right current to the relay to close a circle)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a lot of guides for Arduino and Relays (for &lt;a href=&quot;http://www.instructables.com/id/Arduino-Controlled-Relay-Box/&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="13614" LastEditorUserId="10794" LastEditDate="2015-09-25T22:07:05.480" LastActivityDate="2015-09-25T22:07:05.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16342" PostTypeId="2" ParentId="10257" CreationDate="2015-09-25T17:06:35.993" Score="1" Body="&lt;p&gt;I have accomplished this, first by reading &lt;a href=&quot;http://babaawesam.com/2014/11/06/control-input-output-of-arduino-yun-with-ajax/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; on controlling a Yun through a web-browser &lt;em&gt;on the same network&lt;/em&gt;. From there it was a matter of allowing my Yun to be accessed &lt;em&gt;externally&lt;/em&gt; (setting up port-forwarding on my router) and changing a few lines of code to reflect the new location reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the necessary files and code are included under the heading &quot;Project Files&quot; in the above link and no modification is needed to get it working within the same network. That said, I had to convert the two &lt;code&gt;.jpg&lt;/code&gt; files to &lt;code&gt;.png&lt;/code&gt; (and change the filenames in &lt;code&gt;index.html&lt;/code&gt;) - I don't know why they wouldn't show up in my browser.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;In brief:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Yun hosts a webpage (index.html) which contains some indicators and control inputs. These objects are linked to the 32u4 using &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Bridge&quot; rel=&quot;nofollow&quot;&gt;Bridge&lt;/a&gt; and the REST API - nothing special. The bulk of the html code is for visual purposes, and the actual REST calls are nice and simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is good is that the webpage can be accessed from anywhere with the right jiggery-pokery, and with a little more determination can be &lt;em&gt;hosted&lt;/em&gt; from anywhere.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;External Access&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once you have that working, you need to do the following to allow access externally. I tested this using my smartphone - disconnected from my home WiFi of course - to ensure the link was over the Internet, not intranet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Set up port forwarding and a static IP for the Yun. This is the fundamental step if you simply want to control your Yun over the Internet. However, I can't actually tell you how to do this because I don't know what equipment you have! Information is all over Google for setting up both DHCP static IP and port forwarding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Get a static IP from your ISP for your home/work, or set up a Dynamic DNS service (&lt;a href=&quot;https://www.dnsdynamic.org/&quot; rel=&quot;nofollow&quot;&gt;these people&lt;/a&gt; offer it free, but I've never actually needed to use an external service). Most commercial ISPs tend to dish out static IPs, but that's no guarantee that yours will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Access your Yun with a browser via: &lt;code&gt;http://YOUR.IP.ADD.RES:PORT/arduino/&amp;lt;SketchName&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;External Hosting&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want to host the webpage on something other than the Yun, you can! You will of course need a server to host this, either your work's central server or an external hosting service. You'll need to change some more lines in the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;s&gt;In the Yun sketch change &lt;code&gt;server.ListenOnLocalhost();&lt;/code&gt; to &lt;code&gt;server.noListenOnLocalhost();&lt;/code&gt; - the subtle difference is the 'no', and is essential for external control.&lt;/s&gt; &lt;em&gt;Sorry, that's incorrect without a little more explanation than is required at the moment to answer your original question.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) In the &lt;code&gt;.html&lt;/code&gt; file, you need to change each instance of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;server = &quot;/arduino/&amp;lt;SOMETHING&amp;gt;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;server = &quot;YOUR.IP.ADD.RES:PORT/arduino/&amp;lt;SOMETHING&amp;gt;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you have the REST password set to ON then you have to incorporate the username/password in there too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;server = &quot;username:password@YOUR.IP.ADD.RES:PORT/arduino/&amp;lt;SOMETHING&amp;gt;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;three&lt;/em&gt; occurences in the original file, so be sure to catch them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) When making changes to the &lt;code&gt;.html&lt;/code&gt; file, make sure you re-upload it to the external host, not the Yun - that mistake took me hours to figure out.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;A little more...&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While searching for the URL of the article in the opening paragraph I found &lt;a href=&quot;https://grallator.wordpress.com/2014/01/13/json-and-the-arduino-yun/&quot; rel=&quot;nofollow&quot;&gt;this atricle on a similar theme&lt;/a&gt;. It looks to have plenty of information although I haven't read it yet fully yet; I've been busy writing an answer on Stack Exchange. External Access should be no different, and if you want the 'External Hosting' version you just need to find any line that references the 'server' as &lt;code&gt;&quot;/arduino/...&quot;&lt;/code&gt; and change it to &lt;code&gt;&quot;YOUR.IP.ADD.RES:PORT/arduino...&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2015-09-25T19:17:49.793" LastActivityDate="2015-09-25T19:17:49.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16343" PostTypeId="1" CreationDate="2015-09-25T18:09:00.667" Score="0" ViewCount="78" Body="&lt;p&gt;If I wanted to throw together a simple burglar-alarm system that had wireless sensors talking to an Arduino (which would then send me an SMS message via cellular shield as a silent alarm telling me which alarm sensor had changed state_)... what technology would you recommend for the sensor-to-arduino signalling? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs to be something that draws little or no power until the alarm is triggered, resistant to radio interference, and as always cheap is a huge plus.... but I haven't gotten much beyond that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Of course if anyone's already implemented something like this and there are descriptions/sketches I can adopt and adapt, feel free to point me in the right direction.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: To provide more info,this is a wood-framed house, 2 storey plus basement, brick chimney possibly in the way. No straight-line distances greater than 60 feet. Wifi, wireless phone, usual electronics and a wood shop I'm still putting together. Shouldn't be difficult, I just want a robust solution in case a friend asks me to replicate it... and for purely aesthetic reasons.&lt;/p&gt;&#xA;" OwnerUserId="11767" LastEditorUserId="11767" LastEditDate="2015-09-25T22:45:04.077" LastActivityDate="2015-09-25T22:45:04.077" Title="Just sanity-checking a concept... poor man's self-monitored alarm system" Tags="|sensors|power|system-design|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16344" PostTypeId="2" ParentId="16343" CreationDate="2015-09-25T19:19:02.000" Score="4" Body="&lt;p&gt;NRF24L01+ for communication. Extreme low power if not sending. Detects packet loss, and automatically resend the packet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would however need a small arduino board at the sensor, to read the sensor, and signal to NRF24L01 to send a message. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to put the arduino in to low power sleep mode to get some good battery life. Either have the sensor wake the arduino up with an interrupt, of poll the sensor like every half second, and immediately go back to sleep.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-09-25T19:19:02.000" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16345" PostTypeId="2" ParentId="16330" CreationDate="2015-09-25T19:44:27.337" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/photoelectric-speed-sensor-encoder-coded-disc-code-wheel-for-freescale-smart-/231699340055?hash=item35f25b5b17&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; is an example of the optical encoder.&#xA;You want to use interrupt detection, rather than polling.&#xA;Or maybe even an HW counter.&#xA;That's all you really need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using 4 of them for a car.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am in the process of refactoring the code, but you could already have a look at the driver &amp;amp; example I wrote for ChibiOS, &lt;a href=&quot;https://github.com/ChibiOS/ChibiOS/pull/10&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-09-27T18:48:04.007" LastActivityDate="2015-09-27T18:48:04.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16347" PostTypeId="1" AcceptedAnswerId="36473" CreationDate="2015-09-25T20:30:09.740" Score="0" ViewCount="12900" Body="&lt;p&gt;I started a project with my Arduino Mega 2560 that gets some values from sensors. I'm using MySQL Connector, &lt;a href=&quot;https://launchpad.net/mysql-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://launchpad.net/mysql-arduino&lt;/a&gt;, and this library allows me to connect to a server using the IP address, and it worked on localhost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Setup for all libraries */&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;sha1.h&amp;gt;&#xA;#include &amp;lt;mysql.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;/* Setup for Ethernet Library */&#xA;byte mac_addr[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xB3, 0x05 }; // MAC address must be unique; this is the Ethernet shield address&#xA;IPAddress server_addr( 177, 156, 122, 113 ); // Server addr&#xA;&#xA;/* Setup for all others variables */&#xA;int DS18S20_Pin = 2; // Temperature sensor&#xA;float temperature;&#xA;float placasTensao;&#xA;float placasCorrente;&#xA;float geradorEolicoTensao;&#xA;float geradorEolicoCorrente;&#xA;float bateriaTensao;&#xA;float bateriaTemp;&#xA;float correnteSaidaControlador;&#xA;float correnteSaidaConsumo;&#xA;&#xA;OneWire ds(DS18S20_Pin);  // On digital pin 2&#xA;&#xA;/* Setup for the Connector/Arduino */&#xA;Connector my_conn; // The Connector/Arduino reference&#xA;&#xA;/* Setup for connection and all variables of the database */&#xA;char user[] = &quot;&quot;;&#xA;char password[] = &quot;&quot;;&#xA;char INSERT_SQL[1000];&#xA;char temperature_convt[10], placasTensao_convt[10], placasCorrente_convt[10], geradorEolicoTensao_convt[10],&#xA;     geradorEolicoCorrente_convt[10], bateriaTensao_convt[10], bateriaTemp_convt[10], correnteSaidaControlador_convt[10],&#xA;     correnteSaidaConsumo_convt[10];&#xA;&#xA;void setup(){&#xA;  Ethernet.begin(mac_addr);&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop(){&#xA;  temperature = getTemp();&#xA;  convert(temperature, temperature_convt);&#xA;  snprintf(INSERT_SQL, &quot;INSERT INTO data.data VALUES (%s, 1, 1, 1, 1, 1, 1, 1, NULL)&quot;, temperature_convt);&#xA;  sendData();&#xA;  delay(20000);&#xA;}&#xA;&#xA;// Convert a float variable to string&#xA;void convert(float data, char *value){&#xA;  dtostrf(data, 7, 3, value);&#xA;}&#xA;&#xA;// Saves all data on database&#xA;void sendData(){&#xA;  Serial.println(&quot;Connecting...&quot;);&#xA;  if (my_conn.mysql_connect(server_addr, 3306, user, password)){&#xA;    delay(500);&#xA;    Serial.println(&quot;Starting SQL!&quot;);&#xA;    Serial.println(INSERT_SQL);&#xA;    my_conn.cmd_query(INSERT_SQL);&#xA;    Serial.println(&quot;Query Success!&quot;);&#xA;    my_conn.disconnect();&#xA;    Serial.println(&quot;\n&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Connection failed!&quot;);&#xA;    Serial.println(&quot;Make sure all cables are properly connected!\nIf they are, restart the Arduino!\n&quot;);&#xA;  }&#xA;}&#xA;&#xA;// Returns the temperature from one DS18S20 in degree Celsius&#xA;float getTemp(){&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  if (!ds.search(addr)) {&#xA;      // No more sensors on chain, reset search&#xA;      ds.reset_search();&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( OneWire::crc8( addr, 7) != addr[7]) {&#xA;      Serial.println(&quot;CRC is not valid!&quot;);&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( addr[0] != 0x10 &amp;amp;&amp;amp; addr[0] != 0x28) {&#xA;      Serial.print(&quot;Device is not recognized&quot;);&#xA;      return -1000;&#xA;  }&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44,1);&#xA;  // Start conversion, with parasite power on at the end&#xA;  byte present = ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0xBE); // Read Scratchpad&#xA;  for (int i = 0; i &amp;lt; 9; i++) { // We need 9 bytes&#xA;    data[i] = ds.read();&#xA;  }&#xA;  ds.reset_search();&#xA;  byte MSB = data[1];&#xA;  byte LSB = data[0];&#xA;  float tempRead = ((MSB &amp;lt;&amp;lt; 8) | LSB); // Using two's complement&#xA;  float TemperatureSum = tempRead / 16;&#xA;  return TemperatureSum;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, how can I connect to a server using the URL? Is there a library like MySQL Connector that allows me to use the URL instead of the IP address?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I want is to do exactly the same thing that I'm doing with MySQL Connector, but using the URL of the server instead of the IP address.&lt;/p&gt;&#xA;" OwnerUserId="13595" LastEditorUserId="4628" LastEditDate="2017-04-29T14:18:03.363" LastActivityDate="2017-04-29T14:18:03.363" Title="How do I connect Arduino directly to MySQL server using the URL?" Tags="|arduino-mega|c++|arduino-ide|ethernet|datalogging|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16348" PostTypeId="1" AcceptedAnswerId="16349" CreationDate="2015-09-26T01:06:58.590" Score="67" ViewCount="225264" Body="&lt;p&gt;With reference to the Arduino Uno, Mega2560, Leonardo and similar boards:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How does SPI work?&lt;/li&gt;&#xA;&lt;li&gt;How fast is SPI?&lt;/li&gt;&#xA;&lt;li&gt;How do I connect between a master and a slave?&lt;/li&gt;&#xA;&lt;li&gt;How do I make an SPI slave?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please note: This is intended as a reference question.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2023-05-07T15:45:19.163" Title="How do you use SPI on an Arduino?" Tags="|arduino-uno|arduino-mega|c++|arduino-leonardo|spi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16349" PostTypeId="2" ParentId="16348" CreationDate="2015-09-26T01:06:58.590" Score="113" Body="&lt;h2&gt;Introduction to SPI&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot; rel=&quot;noreferrer&quot;&gt;Serial Peripheral Interface Bus&lt;/a&gt; (SPI) interface is used for communication between multiple devices over short distances, and at high speed.&lt;/p&gt;&#xA;&lt;p&gt;Typically there is a single &amp;quot;master&amp;quot; device, which initiates communications and supplies the clock which controls the data transfer rate. There can be one or more slaves. For more than one slave, each one has its own &amp;quot;slave select&amp;quot; signal, described later.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;SPI signals&lt;/h2&gt;&#xA;&lt;p&gt;In a full-blown SPI system you will have four signal lines:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Master Out, Slave In (&lt;strong&gt;MOSI&lt;/strong&gt;) - which is the data going from the master to the slave&lt;/li&gt;&#xA;&lt;li&gt;Master In, Slave Out (&lt;strong&gt;MISO&lt;/strong&gt;) - which is the data going from the slave to the master&lt;/li&gt;&#xA;&lt;li&gt;Serial Clock (&lt;strong&gt;SCK&lt;/strong&gt;) - when this toggles both the master and the slave sample the next bit&lt;/li&gt;&#xA;&lt;li&gt;Slave Select (&lt;strong&gt;SS&lt;/strong&gt;) - this tells a particular slave to go &amp;quot;active&amp;quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When multiple slaves are connected to the MISO signal they are expected to tri-state (keep at high impedance) that MISO line until they are selected by Slave Select being asserted. Normally Slave Select (SS) goes low to assert it. That is, it is active low. Once a particular slave is selected it should configure the MISO line as an output so it can send data to the master.&lt;/p&gt;&#xA;&lt;p&gt;This image shows the way that data is exchanged as one byte is sent:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6cTce.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6cTce.png&quot; alt=&quot;SPI protocol showing 4 signals&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Note that three signals are outputs from the master (MOSI, SCK, SS) and one is an input (MISO).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Timing&lt;/h2&gt;&#xA;&lt;p&gt;The sequence of events is:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;SS&lt;/code&gt; goes low to assert it and activate the slave&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;SCK&lt;/code&gt; line toggles to indicate when the data lines should be sampled&lt;/li&gt;&#xA;&lt;li&gt;The data is sampled by both master and slave on the &lt;strong&gt;leading&lt;/strong&gt; edge of &lt;code&gt;SCK&lt;/code&gt; (using the default clock phase)&lt;/li&gt;&#xA;&lt;li&gt;Both master and slave prepare for the next bit on the &lt;strong&gt;trailing&lt;/strong&gt; edge of &lt;code&gt;SCK&lt;/code&gt; (using the default clock phase), by changing &lt;code&gt;MISO&lt;/code&gt; / &lt;code&gt;MOSI&lt;/code&gt; if necessary&lt;/li&gt;&#xA;&lt;li&gt;Once the transmission is over (possibly after multiple bytes have been sent) then &lt;code&gt;SS&lt;/code&gt; goes high to de-assert it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Note that:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The most significant bit is sent first (by default)&lt;/li&gt;&#xA;&lt;li&gt;Data is sent and received at the same instant (full duplex)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Because data is sent and received on the same clock pulse it is not possible for the slave to respond to the master immediately. SPI protocols usually expect the master to request data on one transmission, and get a response on a subsequent one.&lt;/p&gt;&#xA;&lt;p&gt;Using the SPI library on the Arduino, doing a single transfer looks like this in code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; byte outgoing = 0xAB;&#xA; byte incoming = SPI.transfer (outgoing);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Sample code&lt;/h2&gt;&#xA;&lt;p&gt;Example of sending only (ignoring any incoming data):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup (void)&#xA;  {&#xA;  digitalWrite(SS, HIGH);  // ensure SS stays high&#xA;  SPI.begin ();&#xA;  } // end of setup&#xA;&#xA;void loop (void)&#xA;  {&#xA;  byte c;&#xA;&#xA;  // enable Slave Select&#xA;  digitalWrite(SS, LOW);    // SS is pin 10&#xA;&#xA;  // send test string&#xA;  for (const char * p = &amp;quot;Fab&amp;quot; ; c = *p; p++)&#xA;    SPI.transfer (c);&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(SS, HIGH);&#xA;&#xA;  delay (100);&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Wiring for output-only SPI&lt;/h2&gt;&#xA;&lt;p&gt;The above code (which sends only) might be used to drive an output serial shift register. These are output-only devices, so we don't need to worry about any incoming data. In their case the SS pin might be called the &amp;quot;store&amp;quot; or &amp;quot;latch&amp;quot; pin.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bbmei.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bbmei.png&quot; alt=&quot;SPI protocol showing 3 signals&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Examples of this are the 74HC595 serial shift register, and various LED strips, just to mention a couple. For example, this 64 pixel LED display driven by a MAX7219 chip:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OeBsB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OeBsB.png&quot; alt=&quot;64 pixel LED display&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this case you can see that the board maker has used slightly different signal names:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DIN (Data In) is MOSI (Master Out, Slave In)&lt;/li&gt;&#xA;&lt;li&gt;CS (Chip Select) is SS (Slave Select)&lt;/li&gt;&#xA;&lt;li&gt;CLK (Clock) is SCK (Serial Clock)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Most boards will follow a similar pattern. Sometimes DIN is just DI (Data In).&lt;/p&gt;&#xA;&lt;p&gt;Here is another example, this time a 7-segment LED display board (also based on the MAX7219 chip):&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CvhRc.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CvhRc.jpg&quot; alt=&quot;7-segment LED display&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This uses exactly the same signal names as the other board. In both of these cases you can see that the board only needs 5 wires to it, the three for SPI, plus power and ground.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Clock phase and polarity&lt;/h2&gt;&#xA;&lt;p&gt;There are four way you can sample the SPI clock.&lt;/p&gt;&#xA;&lt;p&gt;The SPI protocol allows for variations on the polarity of the clock pulses. CPOL is clock polarity, and CPHA is clock phase.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 0 (the default) - clock is normally low (CPOL = 0), and the data is sampled on the transition from low to high (leading edge) (CPHA = 0)&lt;/li&gt;&#xA;&lt;li&gt;Mode 1 - clock is normally low (CPOL = 0), and the data is sampled on the transition from high to low (trailing edge) (CPHA = 1)&lt;/li&gt;&#xA;&lt;li&gt;Mode 2 - clock is normally high (CPOL = 1), and the data is sampled on the transition from high to low (leading edge) (CPHA = 0)&lt;/li&gt;&#xA;&lt;li&gt;Mode 3 - clock is normally high (CPOL = 1), and the data is sampled on the transition from low to high (trailing edge) (CPHA = 1)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;These are illustrated in this graphic:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MHkRd.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MHkRd.png&quot; alt=&quot;SPI clock phase and polarity&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You should refer to the datasheet for your device to get the phase and polarity correct. There will usually be a diagram which shows how to sample the clock. For example, from the datasheet for the 74HC595 chip:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IdlVA.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IdlVA.png&quot; alt=&quot;74HC595 clock&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see the clock is normally low (CPOL = 0) and it is sampled on the leading edge (CPHA = 0) so this therefore is SPI mode 0.&lt;/p&gt;&#xA;&lt;p&gt;You can change the clock polarity and phase in code like this (choose one only, of course):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.setDataMode (SPI_MODE0);&#xA;SPI.setDataMode (SPI_MODE1);&#xA;SPI.setDataMode (SPI_MODE2);&#xA;SPI.setDataMode (SPI_MODE3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This method is deprecated in versions 1.6.0 onwards of the Arduino IDE. For recent versions you change the clock mode in the &lt;code&gt;SPI.beginTransaction&lt;/code&gt; call, like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.beginTransaction (SPISettings (2000000, MSBFIRST, SPI_MODE0));  // 2 MHz clock, MSB first, mode 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Data order&lt;/h2&gt;&#xA;&lt;p&gt;The default is most-significant bit first, however you can tell the hardware to process the least significant bit first like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.setBitOrder (LSBFIRST);   // least significant bit first&#xA;SPI.setBitOrder (MSBFIRST);   // most significant bit first&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Again, this is deprecated in versions 1.6.0 onwards of the Arduino IDE. For recent versions you change the bit order in the &lt;code&gt;SPI.beginTransaction&lt;/code&gt; call, like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.beginTransaction (SPISettings (1000000, LSBFIRST, SPI_MODE2));  // 1 MHz clock, LSB first, mode 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Speed&lt;/h2&gt;&#xA;&lt;p&gt;The default setting for SPI is to use the system clock speed divided by four, that is, one SPI clock pulse every 250 ns, assuming a 16 MHz CPU clock. You can change the clock divider by using &lt;code&gt;setClockDivider&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.setClockDivider (divider);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where &amp;quot;divider&amp;quot; is one of:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV2&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV4&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV8&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV16&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV32&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV64&lt;/li&gt;&#xA;&lt;li&gt;SPI_CLOCK_DIV128&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The fastest rate is &amp;quot;divide by 2&amp;quot; or one SPI clock pulse every 125 ns, assuming a 16 MHz CPU clock. This would therefore take 8 * 125 ns or 1 µs to transmit one byte.&lt;/p&gt;&#xA;&lt;p&gt;This method is deprecated in versions 1.6.0 onwards of the Arduino IDE. For recent versions you change the transfer speed in the &lt;code&gt;SPI.beginTransaction&lt;/code&gt; call, like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.beginTransaction (SPISettings (4000000, MSBFIRST, SPI_MODE0));  // 4 MHz clock, MSB first, mode 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However empirical testing shows that it is necessary to have two clock pulses between bytes, so the maximum rate at which bytes can be clocked out is 1.125 µs each (with a clock divider of 2).&lt;/p&gt;&#xA;&lt;p&gt;To summarize, each byte can be sent at a maximum rate of one per 1.125 µs (with a 16 MHz clock) giving a theoretical maximum transfer rate of 1/1.125 µs, or 888,888 bytes per second (excluding overhead like setting SS low and so on).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Connecting to Arduino&lt;/h2&gt;&#xA;&lt;h3&gt;Arduino Uno&lt;/h3&gt;&#xA;&lt;p&gt;Connecting via digital pins 10 to 13:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QJx5X.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QJx5X.jpg&quot; alt=&quot;Arduino Uno SPI pins&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Connecting via the ICSP header:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0c2a8.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0c2a8.jpg&quot; alt=&quot;ICSP pinouts - Uno&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NH4o9.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NH4o9.png&quot; alt=&quot;ICSP header&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h3&gt;Arduino Atmega2560&lt;/h3&gt;&#xA;&lt;p&gt;Connecting via digital pins 50 to 52:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zEhcv.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zEhcv.jpg&quot; alt=&quot;Arduino Mega2560 SPI pins&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You can also use the ICSP header, similar to the Uno above.&lt;/p&gt;&#xA;&lt;h3&gt;Arduino Leonardo&lt;/h3&gt;&#xA;&lt;p&gt;The Leonardo and Micro do not expose the SPI pins on the digital pins, unlike the Uno and Mega. Your only option is to use the ICSP header pins, as illustrated above for the Uno. However the Leonardo and ProMicro don't expose the SS pin and thus cannot be used as an SPI slave.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Multiple slaves&lt;/h2&gt;&#xA;&lt;p&gt;A master can communicate with multiple slaves (however only one at a time). It does this by asserting SS for one slave and de-asserting it for all the others. The slave which has SS asserted (usually this means LOW) configures its MISO pin as an output so that slave, and that slave alone, can respond to the master. The other slaves ignore any incoming clock pulses if SS is not asserted. Thus you need one additional signal for each slave, like this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x4uKM.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x4uKM.png&quot; alt=&quot;Multiple SPI slaves&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this graphic you can see that MISO, MOSI, SCK are shared between both slaves, however each slave has its own SS (slave select) signal.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Protocols&lt;/h2&gt;&#xA;&lt;p&gt;The SPI spec does not specify protocols as such, so it is up to individual master/slave pairings to agree on what the data means. Whilst you can send and receive bytes simultaneously, the received byte cannot be a direct response to the sent byte (as they are being assembled simultaneously).&lt;/p&gt;&#xA;&lt;p&gt;So it would be more logical for one end to send a request (eg. 4 might mean &amp;quot;list the disk directory&amp;quot;) and then do transfers (perhaps just sending zeros outwards) until it receives a complete response. The response might terminate with a newline, or 0x00 character.&lt;/p&gt;&#xA;&lt;p&gt;Read the datasheet for your slave device to see what protocol sequences it expects.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;How to make an SPI slave&lt;/h2&gt;&#xA;&lt;p&gt;The earlier example shows the Arduino as the master, sending data to a slave device. This example shows how the Arduino can be a slave.&lt;/p&gt;&#xA;&lt;h3&gt;Hardware setup&lt;/h3&gt;&#xA;&lt;p&gt;Connect two Arduino Unos together with the following pins connected to each other:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;10 (SS)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;11 (MOSI)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;12 (MISO)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;13 (SCK)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;+5v (if required)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;GND (for signal return)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;On the Arduino Mega, the pins are 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS).&lt;/p&gt;&#xA;&lt;p&gt;In any case, MOSI at one end is connected to MOSI at the other, you &lt;strong&gt;don't&lt;/strong&gt; swap them around (that is you &lt;strong&gt;do not have&lt;/strong&gt; MOSI &amp;lt;-&amp;gt; MISO). The software configures one end of MOSI (master end) as an output, and the other end (slave end) as an input.&lt;/p&gt;&#xA;&lt;p&gt;On some boards (like Leonardo, ProMicro — see above) the SS pin isn't exposed (rather it is connected to RX_LED). It is not possible to remap SS to another pin to be able to use those boards as an SPI slave as the AVR uses fixed SPI pins according to the datasheets (PB0-PB3 on 32U4).&lt;/p&gt;&#xA;&lt;h3&gt;Master example&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup (void)&#xA;{&#xA;&#xA;  digitalWrite(SS, HIGH);  // ensure SS stays high for now&#xA;&#xA;  // Put SCK, MOSI, SS pins into output mode&#xA;  // also put SCK, MOSI into LOW state, and SS into HIGH state.&#xA;  // Then put SPI hardware into Master mode and turn SPI on&#xA;  SPI.begin ();&#xA;&#xA;  // Slow down the master a bit&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV8);&#xA;&#xA;}  // end of setup&#xA;&#xA;&#xA;void loop (void)&#xA;{&#xA;&#xA;  char c;&#xA;&#xA;  // enable Slave Select&#xA;  digitalWrite(SS, LOW);    // SS is pin 10&#xA;&#xA;  // send test string&#xA;  for (const char * p = &amp;quot;Hello, world!\n&amp;quot; ; c = *p; p++)&#xA;    SPI.transfer (c);&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(SS, HIGH);&#xA;&#xA;  delay (1000);  // 1 seconds delay&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Slave example&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;char buf [100];&#xA;volatile byte pos;&#xA;volatile bool process_it;&#xA;&#xA;void setup (void)&#xA;{&#xA;  Serial.begin (115200);   // debugging&#xA;&#xA;  // turn on SPI in slave mode&#xA;  SPCR |= bit (SPE);&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode (MISO, OUTPUT);&#xA;&#xA;  // get ready for an interrupt&#xA;  pos = 0;   // buffer empty&#xA;  process_it = false;&#xA;&#xA;  // now turn on interrupts&#xA;  SPI.attachInterrupt();&#xA;&#xA;}  // end of setup&#xA;&#xA;&#xA;// SPI interrupt routine&#xA;ISR (SPI_STC_vect)&#xA;{&#xA;byte c = SPDR;  // grab byte from SPI Data Register&#xA;&#xA;  // add to buffer if room&#xA;  if (pos &amp;lt; sizeof buf)&#xA;    {&#xA;    buf [pos++] = c;&#xA;&#xA;    // example: newline means time to process buffer&#xA;    if (c == '\n')&#xA;      process_it = true;&#xA;&#xA;    }  // end of room available&#xA;}  // end of interrupt routine SPI_STC_vect&#xA;&#xA;// main loop - wait for flag set in interrupt routine&#xA;void loop (void)&#xA;{&#xA;  if (process_it)&#xA;    {&#xA;    buf [pos] = 0;&#xA;    Serial.println (buf);&#xA;    pos = 0;&#xA;    process_it = false;&#xA;    }  // end of flag set&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The slave is entirely interrupt-driven, thus it can doing other stuff. The incoming SPI data is collected in a buffer, and a flag set when a &amp;quot;significant byte&amp;quot; (in this case a newline) arrives. This tells the slave to get on and start processing the data.&lt;/p&gt;&#xA;&lt;h3&gt;Example of connecting master to slave using SPI&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PB7Ob.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PB7Ob.jpg&quot; alt=&quot;Arduino SPI master and slave&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;How to get a response from a slave&lt;/h2&gt;&#xA;&lt;p&gt;Following on from the code above which sends data from an SPI master to a slave, the example below shows sending data to a slave, having it do something with it, and return a response.&lt;/p&gt;&#xA;&lt;p&gt;The master is similar to the example above. However an important point is that we need to add a slight delay (something like 20 microseconds). Otherwise the slave doesn't have a chance to react to the incoming data and do something with it.&lt;/p&gt;&#xA;&lt;p&gt;The example shows sending a &amp;quot;command&amp;quot;. In this case &amp;quot;a&amp;quot; (add something) or &amp;quot;s&amp;quot; (subtract something). This is to show that the slave is actually doing something with the data.&lt;/p&gt;&#xA;&lt;p&gt;After asserting slave-select (SS) to initiate the transaction, the master sends the command, followed by any number of bytes, and then raises SS to terminate the transaction.&lt;/p&gt;&#xA;&lt;p&gt;A very important point is that the slave cannot respond to an incoming byte at the same moment. The response has to be in the next byte. This is because the bits which are being sent, and the bits which are being received, are being sent simultaneously. Thus to add something to four numbers we need five transfers, like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;transferAndWait ('a');  // add command&#xA;transferAndWait (10);&#xA;a = transferAndWait (17);&#xA;b = transferAndWait (33);&#xA;c = transferAndWait (42);&#xA;d = transferAndWait (0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;First we request action on number 10. But we don't get a response until the next transfer (the one for 17). However &amp;quot;a&amp;quot; will be set to the reply to 10. Finally we end up sending a &amp;quot;dummy&amp;quot; number 0, to get the reply for 42.&lt;/p&gt;&#xA;&lt;h3&gt;Master (example)&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  #include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;  void setup (void)&#xA;    {&#xA;    Serial.begin (115200);&#xA;    Serial.println ();&#xA;&#xA;    digitalWrite(SS, HIGH);  // ensure SS stays high for now&#xA;    SPI.begin ();&#xA;&#xA;    // Slow down the master a bit&#xA;    SPI.setClockDivider(SPI_CLOCK_DIV8);&#xA;    }  // end of setup&#xA;&#xA;  byte transferAndWait (const byte what)&#xA;    {&#xA;    byte a = SPI.transfer (what);&#xA;    delayMicroseconds (20);&#xA;    return a;&#xA;    } // end of transferAndWait&#xA;&#xA;  void loop (void)&#xA;    {&#xA;&#xA;    byte a, b, c, d;&#xA;&#xA;    // enable Slave Select&#xA;    digitalWrite(SS, LOW);&#xA;&#xA;    transferAndWait ('a');  // add command&#xA;    transferAndWait (10);&#xA;    a = transferAndWait (17);&#xA;    b = transferAndWait (33);&#xA;    c = transferAndWait (42);&#xA;    d = transferAndWait (0);&#xA;&#xA;    // disable Slave Select&#xA;    digitalWrite(SS, HIGH);&#xA;&#xA;    Serial.println (&amp;quot;Adding results:&amp;quot;);&#xA;    Serial.println (a, DEC);&#xA;    Serial.println (b, DEC);&#xA;    Serial.println (c, DEC);&#xA;    Serial.println (d, DEC);&#xA;&#xA;    // enable Slave Select&#xA;    digitalWrite(SS, LOW);&#xA;&#xA;    transferAndWait ('s');  // subtract command&#xA;    transferAndWait (10);&#xA;    a = transferAndWait (17);&#xA;    b = transferAndWait (33);&#xA;    c = transferAndWait (42);&#xA;    d = transferAndWait (0);&#xA;&#xA;    // disable Slave Select&#xA;    digitalWrite(SS, HIGH);&#xA;&#xA;    Serial.println (&amp;quot;Subtracting results:&amp;quot;);&#xA;    Serial.println (a, DEC);&#xA;    Serial.println (b, DEC);&#xA;    Serial.println (c, DEC);&#xA;    Serial.println (d, DEC);&#xA;&#xA;    delay (1000);  // 1 second delay&#xA;    }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code for the slave basically does almost everything in the interrupt routine (called when incoming SPI data arrives). It takes the incoming byte, and adds or subtracts as per the remembered &amp;quot;command byte&amp;quot;. Note that the response will be &amp;quot;collected&amp;quot; next time through the loop. This is why the master has to send one final &amp;quot;dummy&amp;quot; transfer to get the final reply.&lt;/p&gt;&#xA;&lt;p&gt;In my example I am using the main loop to simply detect when SS goes high, and clear the saved command. That way, when SS is pulled low again for the next transaction, the first byte is considered the command byte.&lt;/p&gt;&#xA;&lt;p&gt;More reliably, this would be done with an interrupt. That is, you would physically connect SS to one of the interrupt inputs (eg, on the Uno, connect pin 10 (SS) to pin 2 (an interrupt input), or use a pin-change interrupt on pin 10.&lt;/p&gt;&#xA;&lt;p&gt;Then the interrupt could be used to notice when SS is being pulled low or high.&lt;/p&gt;&#xA;&lt;h3&gt;Slave (example)&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// what to do with incoming data&#xA;volatile byte command = 0;&#xA;&#xA;void setup (void)&#xA;  {&#xA;&#xA;  // have to send on master in, *slave out*&#xA;  pinMode(MISO, OUTPUT);&#xA;&#xA;  // turn on SPI in slave mode&#xA;  SPCR |= _BV(SPE);&#xA;&#xA;  // turn on interrupts&#xA;  SPCR |= _BV(SPIE);&#xA;&#xA;  }  // end of setup&#xA;&#xA;&#xA;// SPI interrupt routine&#xA;ISR (SPI_STC_vect)&#xA;  {&#xA;  byte c = SPDR;&#xA;&#xA;  switch (command)&#xA;    {&#xA;    // no command? then this is the command&#xA;    case 0:&#xA;      command = c;&#xA;      SPDR = 0;&#xA;      break;&#xA;&#xA;    // add to incoming byte, return result&#xA;    case 'a':&#xA;      SPDR = c + 15;  // add 15&#xA;      break;&#xA;&#xA;    // subtract from incoming byte, return result&#xA;    case 's':&#xA;      SPDR = c - 8;  // subtract 8&#xA;      break;&#xA;&#xA;    } // end of switch&#xA;&#xA;  }  // end of interrupt service routine (ISR) SPI_STC_vect&#xA;&#xA;void loop (void)&#xA;  {&#xA;&#xA;  // if SPI not active, clear current command&#xA;  if (digitalRead (SS) == HIGH)&#xA;    command = 0;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Example output&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Adding results:&#xA;25&#xA;32&#xA;48&#xA;57&#xA;Subtracting results:&#xA;2&#xA;9&#xA;25&#xA;34&#xA;Adding results:&#xA;25&#xA;32&#xA;48&#xA;57&#xA;Subtracting results:&#xA;2&#xA;9&#xA;25&#xA;34&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3&gt;Logic analyzer output&lt;/h3&gt;&#xA;&lt;p&gt;This shows the timing between sending and receiving in the above code:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3qtCV.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3qtCV.png&quot; alt=&quot;SPI master and slave timing&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;New functionality in IDE 1.6.0 onwards&lt;/h2&gt;&#xA;&lt;p&gt;Version 1.6.0 of the IDE has changed the way SPI works, to an extent. You &lt;strong&gt;still need to do&lt;/strong&gt; &lt;code&gt;SPI.begin()&lt;/code&gt; before using SPI. That sets up the SPI hardware. However now, when you are about to start communicating with a slave you &lt;strong&gt;also&lt;/strong&gt; do &lt;code&gt;SPI.beginTransaction()&lt;/code&gt; to set up SPI (for this slave) with the correct:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Clock speed&lt;/li&gt;&#xA;&lt;li&gt;Bit order&lt;/li&gt;&#xA;&lt;li&gt;Clock phase and polarity&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When you are done communicating with the slave, you call &lt;code&gt;SPI.endTransaction()&lt;/code&gt;. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SPI.beginTransaction (SPISettings (2000000, MSBFIRST, SPI_MODE0));&#xA;digitalWrite (SS, LOW);        // assert Slave Select&#xA;byte foo = SPI.transfer (42);  // do a transfer&#xA;digitalWrite (SS, HIGH);       // de-assert Slave Select&#xA;SPI.endTransaction ();         // transaction over&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Why use SPI?&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I would add one preliminary question: when/why would you use SPI? A need for multi-master configuration or a very large number of slaves would tilt the scale toward I2C.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is an excellent question. My answers are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some devices (quite a few) only support the SPI transfer method. For example the 74HC595 output shift register, the 74HC165 input shift register, the MAX7219 LED driver, and quite a few LED strips that I have seen. So, you might use it because the target device only supports it.&lt;/li&gt;&#xA;&lt;li&gt;SPI is really the fastest method available on the Atmega328 (and similar) chips. The fastest rate quoted above is 888,888 bytes per second. Using I&lt;sup&gt;2&lt;/sup&gt;C you can only get around 40,000 bytes per second. The overhead of the I&lt;sup&gt;2&lt;/sup&gt;C is quite substantial, and if you are trying to interface really quickly, SPI is the preferred choice. Quite a few chip families (eg. MCP23017 and MCP23S17) actually support both I&lt;sup&gt;2&lt;/sup&gt;C and SPI so you often can choose between speed, and the ability to have multiple devices on a single bus.&lt;/li&gt;&#xA;&lt;li&gt;The SPI and I&lt;sup&gt;2&lt;/sup&gt;C devices are both supported in hardware on the Atmega328 so you could conceivably be doing a transfer via SPI simultaneously with I&lt;sup&gt;2&lt;/sup&gt;C which would give you a speed boost.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Both methods have their place. I&lt;sup&gt;2&lt;/sup&gt;C lets you connect many devices to a single bus (two wires, plus ground) so it would be the preferred choice if you needed to interrogate a substantial number of devices, perhaps fairly infrequently. However the speed of SPI could be more relevant for situations where you need to output rapidly (eg. a LED strip) or input rapidly (eg. an ADC converter).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;noreferrer&quot;&gt;My page about SPI&lt;/a&gt; - also has details about bit-banged SPI, and using the USART to gain a second hardware SPI on the Atmega328 chip.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&quot; rel=&quot;noreferrer&quot;&gt;Serial Peripheral Interface Bus - Wikipedia&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;noreferrer&quot;&gt;Arduino SPI library reference pages&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_SPI.html&quot; rel=&quot;noreferrer&quot;&gt;SPI documentation at PJRC&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi&quot; rel=&quot;noreferrer&quot;&gt;SPI protocol - Sparkfun&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2021-03-18T06:37:38.367" LastActivityDate="2021-03-18T06:37:38.367" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="16352" PostTypeId="1" AcceptedAnswerId="16356" CreationDate="2015-09-26T10:24:59.570" Score="1" ViewCount="975" Body="&lt;p&gt;For an battery driven application I want to measure the Vcc (using an Atmega 32u4). That is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int readBandGap() {&#xA;  ADMUX = (B01 &amp;lt;&amp;lt; REFS0)    // VCC&#xA;        | (0 &amp;lt;&amp;lt; ADLAR)      // right-adjusted result&#xA;        | (B011110 &amp;lt;&amp;lt; MUX0) // 1.1V&#xA;        ;&#xA;  // switch off any ADC conversion&#xA;  ADCSRA &amp;amp;= ~(1 &amp;lt;&amp;lt; ADEN);&#xA;  // enable ADC&#xA;  ADCSRA |= 1 &amp;lt;&amp;lt; ADEN;&#xA;  // start ADC&#xA;  ADCSRA |= 1 &amp;lt;&amp;lt; ADSC;&#xA;  // wait until finished&#xA;  while (bit_is_set(ADCSRA, ADSC));&#xA;  // first read low, then high!&#xA;  uint8_t low = ADCL;&#xA;  uint8_t high = ADCH;&#xA;  // switch off any ADC conversion&#xA;  ADCSRA &amp;amp;= ~(1 &amp;lt;&amp;lt; ADEN);&#xA;  return (high &amp;lt;&amp;lt; 8) | low;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int value = readBandGap();&#xA;  float vcc = 1.1 * 1023 / value;&#xA;  Serial.print(value);&#xA;  Serial.print(&quot;  &quot;);&#xA;  Serial.println(vcc);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Olimexino 32u4 board has the ability to switch the voltage between 5V and 3.3V. There are two strange things: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;the first measurement is always significantly different than the later measurements&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;with 5V I'm getting 450, followed by ~367; with 3.3V I'm getting 422, followed by ~395. I would have expected a higher Vcc resulting in a lower measured value (bandgap should be measured compared to Vcc).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any ideas what is wrong with my approach?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="10794" LastEditDate="2015-09-26T21:47:05.847" LastActivityDate="2015-09-26T21:47:05.847" Title="Measure Vcc using 1.1V bandgap" Tags="|c++|voltage-level|adc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16354" PostTypeId="2" ParentId="699" CreationDate="2015-09-26T13:05:19.073" Score="9" Body="&lt;p&gt;I also wanted to get a high sampling rate, for a project. turns out that the ADPS2,ADPS1,ADPS0 bits of the ADCSRA register can be configured to get a sampling rate of 76923 s/s or 76.8 ks/s. But, beware that I am running my arduino's ADC in free running mode, the following lines worked for me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;void setup() {&#xA;// Set the Prescaler to 16 (16000KHz/16 = 1MHz)&#xA;// WARNING: Above 200KHz 10-bit results are not reliable.&#xA;//ADCSRA |= B00000100;&#xA;sbi(ADCSRA, ADPS2);&#xA;cbi(ADCSRA, ADPS1);&#xA;cbi(ADCSRA, ADPS0);&#xA;&#xA;// Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt.&#xA;// Without this, the internal interrupt will not trigger.&#xA;//ADCSRA |= B00001000;&#xA;sbi(ADCSRA,ADIE)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At this frequency the usual 10-bit results are not reliable. It means that increasing the sample rate will decrease the precision of the results. So I only use the upper 8 bits because at this prescalar the upper 8-bits are reliable. You can go into more detail on this page, this dude rocks! he made a high sample rate oscilloscpe using UNO &lt;a href=&quot;http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/&quot; rel=&quot;noreferrer&quot;&gt;http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13628" LastActivityDate="2015-09-26T13:05:19.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16355" PostTypeId="1" AcceptedAnswerId="20545" CreationDate="2015-09-26T13:34:23.033" Score="0" ViewCount="613" Body="&lt;p&gt;I have the Dagu Mini Driver board which is based on the atmega8 and I uploaded the code &lt;a href=&quot;http://blog.dawnrobotics.co.uk/2013/11/getting-started-with-the-dagu-arduino-mini-driver-board/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. It uploaded perfectly and I wired 4x AA pack to the battery terminals making sure to observe polarity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then attached two DC motors to the ML and MR pins just like it said in the picture. I turned the board on, making sure the switch was set to on also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red light lighted up and the blue light flickered for a second. The motors did not move. I tried different motors. To check if it was a corrupt bootloader I tried to upload the hello world blink sketch. That worked perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got my multi-meter out and tested the wires I was using...all good! Tested the battery...6.31v! That's within specs. I have the jumpers correctly inserted on the D7 - 10 pins. Here's my setup:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Q5tGn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Q5tGn.png&quot; alt=&quot;http://blog.dawnrobotics.co.uk/wp-content/uploads/2013/11/circuit_diagram.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What in the world could be wrong? The code is supposed to make it turn in a rough square. I checked it over and over and it looks right. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2016-03-19T08:47:59.230" Title="Dagu Mini Driver Board Issues" Tags="|motor|hardware|robotics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16356" PostTypeId="2" ParentId="16352" CreationDate="2015-09-26T13:46:03.697" Score="0" Body="&lt;p&gt;After tweaking a lot, I've now have found following code to work quite good.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float readVcc() {&#xA;  ADMUX = (B01 &amp;lt;&amp;lt; REFS0)    // VCC&#xA;        | (0 &amp;lt;&amp;lt; ADLAR)      // right-adjusted result&#xA;        | (B011110 &amp;lt;&amp;lt; MUX0) // 1.1V&#xA;        ;&#xA;  // enable ADC&#xA;  ADCSRA |= (1 &amp;lt;&amp;lt; ADEN);&#xA;  // seems necessary&#xA;  delay(2);&#xA;  // start ADC&#xA;  ADCSRA |= 1 &amp;lt;&amp;lt; ADSC;&#xA;  // wait until finished&#xA;  while (bit_is_set(ADCSRA, ADSC));&#xA;  // first read low, then high!&#xA;  long value = ADCL;&#xA;  value |= ADCH &amp;lt;&amp;lt; 8;&#xA;  return 1.1 / value * 1023;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3237" LastActivityDate="2015-09-26T13:46:03.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16357" PostTypeId="2" ParentId="16352" CreationDate="2015-09-26T17:46:09.293" Score="1" Body="&lt;p&gt;The bandgap voltage reference needs some time to stabilize, after you enable it. See &lt;a href=&quot;http://jeelabs.org/2012/05/12/improved-vcc-measurement/&quot; rel=&quot;nofollow&quot;&gt;http://jeelabs.org/2012/05/12/improved-vcc-measurement/&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing 3 dummy measurements, gives it enough time to do that.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-09-26T17:46:09.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16358" PostTypeId="2" ParentId="16347" CreationDate="2015-09-26T17:46:58.010" Score="0" Body="&lt;p&gt;You are using DHCP, so this step might be optional.&#xA;Specify your network addresses (actually we want to specify DNS only but have to specify IP in 2nd argument, so likely have to specify gateway and subnet too):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IPAddress dns_addr( 8, 8, 8, 8); // GOOGLE DNS server, could be any DNS&#xA;IPAddress gateway_addr( , , , );   // put your gateway addr&#xA;IPAddress ip_addr( , , , );   // put your IP addr&#xA;IPAddress subnet( , , , );   // put your subnet mask&#xA;&#xA;void setup(){&#xA;                  Ethernet.begin(mac_addr, ip_addr, dns_addr, gateway_addr, subnet);...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you could modify &lt;strong&gt;Connector::mysql_connect&lt;/strong&gt; method (or create new method) as follows (only function declaration is changed, body is not):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean Connector::mysql_connect(/*IPAddress server*/const char *server, int port, char *user, char *password)&#xA;{&#xA;  int connected = 0;&#xA;  int i = -1;&#xA;&#xA;  // Retry up to MAX_CONNECT_ATTEMPTS times 1 second apart.&#xA;  do {&#xA;    delay(1000);&#xA;    connected = client.connect(server, port);&#xA;    i++;&#xA;  } while (i &amp;lt; MAX_CONNECT_ATTEMPTS &amp;amp;&amp;amp; !connected);&#xA;&#xA;  if (connected) {&#xA;    read_packet();&#xA;    parse_handshake_packet();&#xA;    send_authentication_packet(user, password);&#xA;    read_packet();&#xA;    if (check_ok_packet() != 0) {&#xA;      parse_error_packet();&#xA;      return false;&#xA;    }&#xA;    print_message(CONNECTED);&#xA;    Serial.println(server_version);&#xA;    free(server_version); // don't need it anymore&#xA;    return true;&#xA;  }&#xA;  return false;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Modify the header file also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean mysql_connect(/*IPAddress server*/const char *server, int port,&#xA;                                 char *user, char *password)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can supply URL:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (my_conn.mysql_connect(&quot;http:\\www.mysqlserver.com&quot;, 3306, user, password))...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="13594" LastEditDate="2015-09-26T18:01:25.070" LastActivityDate="2015-09-26T18:01:25.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16359" PostTypeId="2" ParentId="16355" CreationDate="2015-09-26T18:39:32.123" Score="0" Body="&lt;p&gt;This is a generic debugging advice, but maybe it can still be of help:&#xA;have you tried driving the led from the loop, to check that it doesn't get stuck for some reason?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other thing you could do is to get the datasheet of the motor driver, find out the inputs from the ATMega and see how they look like.&#xA;At least that would allow you to bisect the problem answering the question:&#xA;&quot;Does the ATMega generate the expected signal?&quot;&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-26T18:39:32.123" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16360" PostTypeId="1" CreationDate="2015-09-26T20:29:46.057" Score="0" ViewCount="630" Body="&lt;p&gt;I'm new to Arduino and I'm trying to get my MPU 6050  chip to work. The simple code runs fine but when I use the downloaded example I get the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino: 1.6.5 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;....&#xA;&#xA;g.cpp.o &#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp/MPU6050_DMP6.cpp.elf C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050_DMP6.cpp.o C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\Wire\Wire.cpp.o C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\Wire\utility\twi.c.o C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp/core.a -LC:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp -lm &#xA;&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setRate(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:133: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setExternalFrameSync(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:175: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setDLPFMode(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:218: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setFullScaleGyroRange(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:253: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setFullScaleAccelRange(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:387: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setMotionDetectionThreshold(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:531: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setMotionDetectionDuration(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:561: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setZeroMotionDetectionThreshold(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:601: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setZeroMotionDetectionDuration(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:632: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setSlaveAddress(unsigned char, unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:972: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o:C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:1558: more undefined references to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)' follow&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getIntStatus()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:1687: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:1687: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:1687: undefined reference to `I2Cdev::readByte(unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setFIFOEnabled(bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2351: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setI2CMasterModeEnabled(bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2375: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::resetFIFO()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2391: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::resetI2CMaster()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2400: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::reset()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2426: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o:C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2450: more undefined references to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)' follow&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setClockSource(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2543: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getFIFOCount()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2708: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2708: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2708: undefined reference to `I2Cdev::readBytes(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getFIFOBytes(unsigned char*, unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2744: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2744: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2744: undefined reference to `I2Cdev::readBytes(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getDeviceID()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2764: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2764: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2764: undefined reference to `I2Cdev::readBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getOTPBankValid()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2785: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2785: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2785: undefined reference to `I2Cdev::readBit(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setOTPBankValid(bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2789: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getXGyroOffsetTC()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2792: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2792: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2792: undefined reference to `I2Cdev::readBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setXGyroOffsetTC(signed char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2796: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getYGyroOffsetTC()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2802: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2802: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2802: undefined reference to `I2Cdev::readBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setYGyroOffsetTC(signed char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2806: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::getZGyroOffsetTC()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2812: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2812: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2812: undefined reference to `I2Cdev::readBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setZGyroOffsetTC(signed char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2816: undefined reference to `I2Cdev::writeBits(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setZAccelOffset(int)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2876: undefined reference to `I2Cdev::writeWord(unsigned char, unsigned char, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setXGyroOffset(int)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2886: undefined reference to `I2Cdev::writeWord(unsigned char, unsigned char, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setYGyroOffset(int)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2896: undefined reference to `I2Cdev::writeWord(unsigned char, unsigned char, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setZGyroOffset(int)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2906: undefined reference to `I2Cdev::writeWord(unsigned char, unsigned char, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setDMPEnabled(bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2971: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::resetDMP()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2974: undefined reference to `I2Cdev::writeBit(unsigned char, unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setMemoryBank(unsigned char, bool, bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2983: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setMemoryStartAddress(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2989: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::readMemoryByte()':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2995: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2995: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:2995: undefined reference to `I2Cdev::readByte(unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::readMemoryBlock(unsigned char*, unsigned int, unsigned char, unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3016: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3016: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3016: undefined reference to `I2Cdev::readBytes(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::writeMemoryBlock(unsigned char const*, unsigned int, unsigned char, unsigned char, bool, bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3060: undefined reference to `I2Cdev::writeBytes(unsigned char, unsigned char, unsigned char, unsigned char*)'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3066: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3066: undefined reference to `I2Cdev::readTimeout'&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3066: undefined reference to `I2Cdev::readBytes(unsigned char, unsigned char, unsigned char, unsigned char*, unsigned int)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::writeDMPConfigurationSet(unsigned char const*, unsigned int, bool)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3170: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setDMPConfig1(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3198: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;C:\Users\Emma\AppData\Local\Temp\build2536911660206936106.tmp\MPU6050\MPU6050.cpp.o: In function `MPU6050::setDMPConfig2(unsigned char)':&#xA;C:\Users\Emma\Documents\Arduino\libraries\MPU6050/MPU6050.cpp:3208: undefined reference to `I2Cdev::writeByte(unsigned char, unsigned char, unsigned char)'&#xA;collect2.exe: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Help would be most appreciated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13633" LastEditorUserId="10794" LastEditDate="2015-09-26T21:45:49.390" LastActivityDate="2017-08-23T07:28:25.827" Title="Trying to get my MPU chip to work" Tags="|arduino-uno|c++|mpu6050|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16361" PostTypeId="1" CreationDate="2015-09-26T21:51:25.483" Score="3" ViewCount="1490" Body="&lt;p&gt;I have an IR receiver and an IR LED I got from a kit (I don't have the datasheets for them).&lt;br&gt;&#xA;I uploaded an Arduino sketch to record my A/Cs IR codes. Those were NEC encoded 32bit integers.&lt;br&gt;&#xA;After recording the codes, I tried retransmitting them. The A/C unit failed to detect the signals.&lt;br&gt;&#xA;Troubleshooting a bit, I sent the code from the Arduino the receiver sketch from the previous step - it received them successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the above steps used the &lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;IRRemote Arduino library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, what could explain this behavior?&#xA;A few possibilities I had in mind:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;IR frequency. Could it be that the detection circuit worked with the default settings but transmitting wouldn't?&lt;/li&gt;&#xA;&lt;li&gt;IR wavelength. Any chance the A/C side doesn't detect my IR pulses at all?&lt;/li&gt;&#xA;&lt;li&gt;Decoding/Encoding of the NEC protocol in IRRemote. If there is no standard for the NEC protocol, the Arduino and A/C implementation might be a little different.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13634" LastActivityDate="2021-04-13T00:04:40.427" Title="A/C doesn't detect IR codes sent from Arduino" Tags="|ir|home-automation|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16362" PostTypeId="2" ParentId="16360" CreationDate="2015-09-27T00:20:11.987" Score="1" Body="&lt;p&gt;You seem to be missing the I2C header.&#xA;If you are using the Arduino IDE, beware that it has its own whacky idea of where headers should be. Try adding the #include to the .ino file.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-09-27T00:20:11.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16364" PostTypeId="1" CreationDate="2015-09-27T09:48:59.850" Score="1" ViewCount="165" Body="&lt;p&gt;I have an Arduino Uno and I am using arduino 1.0.5 IDE. I followed he procedures for bootloading an atmega328P-PU on a breadboard using an Arduino Uno from the link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the ArduinoISP sketch first, made the connections(using the External Oscillator) and then wired it up. Then, I selected the programmer as Arduino as ISP, selected the board as Arduino duemilanove w/ Atmega328P . Then I selected the correct serial port and clicked Burn Bootloader. I got the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude.exe: stk500_program_enable(): protocol error, expect=0x14,&#xA;resp=0x50avrdude.exe: initialization failed, rc=-1 Double check&#xA;connections and try again, or use -F to override this&#xA;check.avrdude.exe: stk500_disable(): protocol error, expect=0x14,&#xA;resp=0x51&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to solve this issue? Also, can I upload the bootloader directly by using it on the Uno in place of the original chip. If so, how?&lt;/p&gt;&#xA;" OwnerUserId="13639" LastEditorUserId="10794" LastEditDate="2015-09-27T21:57:17.390" LastActivityDate="2015-10-28T03:32:02.460" Title="Standalone Arduino" Tags="|arduino-uno|arduino-ide|atmega328|bootloader|icsp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16365" PostTypeId="1" AcceptedAnswerId="16420" CreationDate="2015-09-27T17:49:04.570" Score="3" ViewCount="9217" Body="&lt;p&gt;I have a rotary encoder KY-040 connected to a Digispark like this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rJiAQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rJiAQ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CLK go to p0 and and DT go to p2, SW is disconnected for now (it's just a button).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did everything like the instructions here: &lt;a href=&quot;http://henrysbench.capnfatz.com/henrys-bench/keyes-ky-040-arduino-rotary-encoder-user-manual/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://henrysbench.capnfatz.com/henrys-bench/keyes-ky-040-arduino-rotary-encoder-user-manual/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DigiKeyboard.h&amp;gt;&#xA;&#xA; int pinA = 0;  // Connected to CLK on KY-040&#xA; int pinB = 2;  // Connected to DT on KY-040&#xA; int encoderPosCount = 0; &#xA; int pinALast;  &#xA; int aVal;&#xA; boolean bCW;&#xA;&#xA; void setup() { &#xA;   pinMode (pinA,INPUT);&#xA;   pinMode (pinB,INPUT);&#xA;   /* Read Pin A&#xA;   Whatever state it's in will reflect the last position   &#xA;   */&#xA;   pinALast = digitalRead(pinA);   &#xA;   Serial.begin (9600);&#xA; } &#xA;&#xA; void loop() { &#xA;   aVal = digitalRead(pinA);&#xA;   if (aVal != pinALast){ // Means the knob is rotating&#xA;     // if the knob is rotating, we need to determine direction&#xA;     // We do that by reading pin B.&#xA;     if (digitalRead(pinB) != aVal) {  // Means pin A Changed first - We're Rotating Clockwise&#xA;       encoderPosCount ++;&#xA;       bCW = true;&#xA;     } else {// Otherwise B changed first and we're moving CCW&#xA;       bCW = false;&#xA;       encoderPosCount--;&#xA;     }&#xA;     Serial.println(&quot;Rotated: &quot;);&#xA;     if (bCW){&#xA;       //Serial.println (&quot;clockwise&quot;);&#xA;       DigiKeyboard.sendKeyStroke(KEY_V); //or DigiKeyboard.write(&quot;1&quot;);&#xA;     }else{&#xA;       //Serial.println(&quot;counterclockwise&quot;);&#xA;        DigiKeyboard.println(&quot;cc&quot;);     &#xA;     }&#xA;     Serial.print(&quot;Encoder Position: &quot;);&#xA;     Serial.println(encoderPosCount);&#xA;&#xA;   } &#xA;   pinALast = aVal;&#xA; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I only changed the pin numbers in the code and the &lt;code&gt;Serial.println (...&lt;/code&gt; to any of the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DigiKeyboard.write(&quot;1&quot;);&#xA;DigiKeyboard.println(&quot;1&quot;);&#xA;DigiKeyboard.sendKeyStroke(KEY_V);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of them didn't do anything when rotating the knob... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&#xA;Maybe the 10K resistors are too much?&lt;/p&gt;&#xA;" OwnerUserId="13642" LastEditorUserId="13642" LastEditDate="2015-09-29T08:49:59.370" LastActivityDate="2016-01-28T23:10:07.097" Title="Reading from a KY-040 rotary encoder with Digispark" Tags="|attiny|rotary-encoder|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16366" PostTypeId="2" ParentId="16364" CreationDate="2015-09-27T21:56:23.063" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow&quot;&gt;How to make an Arduino-compatible minimal board&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, can I upload the bootloader directly by using it on the Uno in place of the original chip. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, a blank chip cannot install its own bootloader. You use a second chip. My page above describes how to do that. An alternative is a stand-alone ICSP programmer, which can be purchased for around $20. The tutorial page you linked uses your Uno as a stand-alone programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think my method of &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;using a Uno as a programmer&lt;/a&gt; is easier, frankly. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-27T21:56:23.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16367" PostTypeId="2" ParentId="16365" CreationDate="2015-09-27T22:05:06.677" Score="2" Body="&lt;pre&gt;&lt;code&gt; int pinA = 0;  // Connected to CLK on KY-040&#xA; ...&#xA;   Serial.begin (9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hardware Serial uses pins 0 and 1. I would try other pins. (Oh, it's an ATtiny - well I'm not sure about HardwareSerial on that, but it looks suspicious).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11130&quot; rel=&quot;nofollow&quot;&gt;my page about rotary encoders&lt;/a&gt; for more ideas.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I only changed the pin numbers in the code and the Serial.println (... to any of the following:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Maybe post the code you actually used, that would be helpful. Not some code you didn't use.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Maybe the 10K resistors are too much?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, that looks fine.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-27T22:05:06.677" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16368" PostTypeId="2" ParentId="16364" CreationDate="2015-09-28T02:53:07.247" Score="0" Body="&lt;p&gt;I had the same problem; I never figured it out. I eventually threw down some cash for am ICSP (I got the FreeTronics USBASP), and have never looked back. In fact, with an ICSP, you don't even need a bootloader. It's also real easy to solder a 6-pin header onto your custom soldered board; then you will realize you don't need an Arduino at all, just an Atmel chip. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-09-28T02:53:07.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16369" PostTypeId="1" AcceptedAnswerId="16378" CreationDate="2015-09-28T03:10:26.707" Score="0" ViewCount="72" Body="&lt;p&gt;I am having a little trouble with a program of mine. My circuit consists of (mainly) an arduino UNO, two RGB LEDs, and a photoresistor. My current code(programmed in c#) operates the hardware as so: When the lights in the room are on, the two LEDs alternate blue/off once per second in a loop. When the lights are off, or the photoresistor is not sensing any light, both LEDs turn on, and stay on, red.&#xA;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int prPin = A0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(5,OUTPUT);&#xA;  pinMode(6,OUTPUT);&#xA;  pinMode(7,OUTPUT);&#xA;  pinMode(8,OUTPUT);&#xA;  pinMode(9,OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(prPin,INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int prVal = analogRead(prPin);&#xA;  Serial.write(prVal);&#xA;    if(prVal&amp;gt;450)&#xA;    {&#xA;      digitalWrite(5,HIGH);&#xA;      digitalWrite(6,HIGH);&#xA;      digitalWrite(7,HIGH);&#xA;      digitalWrite(8,LOW);&#xA;      digitalWrite(9,HIGH);&#xA;      digitalWrite(10,HIGH);&#xA;      delay(1000);&#xA;      digitalWrite(5,LOW);&#xA;      digitalWrite(6,HIGH);&#xA;      digitalWrite(7,HIGH);&#xA;      digitalWrite(8,HIGH);&#xA;      digitalWrite(9,HIGH);&#xA;      digitalWrite(10,HIGH);&#xA;      delay(1000);&#xA;    }&#xA;    else&#xA;    {&#xA;      digitalWrite(5,HIGH);&#xA;      digitalWrite(6,HIGH);&#xA;      digitalWrite(7,LOW);&#xA;      digitalWrite(8,HIGH);&#xA;      digitalWrite(9,HIGH);&#xA;      digitalWrite(10,LOW);&#xA;      delay(10);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I am having is when the lights turn off, the LEDs will not operate according to the &quot;else&quot; statement/loop until it finishes going through the &quot;if&quot; statement/loop.&#xA;Any suggestions or answers are appreciated. I'm an open book, so I'll take anything you guys give me.&lt;/p&gt;&#xA;" OwnerUserId="13650" LastActivityDate="2015-09-28T18:12:08.087" Title="RGBs, photoresistors, and delays" Tags="|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16370" PostTypeId="1" AcceptedAnswerId="16374" CreationDate="2015-09-28T03:58:58.197" Score="0" ViewCount="90" Body="&lt;p&gt;First a little background on me and my project. Most of my programming experience is with PHP and javascript. I have just recently started looking at C and C++ for this Arduino project. My project is a weather station that feeds its data to a web based database in real time. I will be writing the code for a web site that will access this data base and present the data in realtime. I am currently working on the temperature section of my weather station. It is an RTD coupled to a constant current circuit and feeds a varying voltage to analog pin 5 on my Arduino Uno. My problem is with the code. I have a working code but I decided to make it object oriented so that I could reuse it in other projects. Here is the code that works.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned int RTD_PIN = A5;&#xA;const float MVOLTS_CTS = 4.882813;&#xA;const float OHMS_DEGREE = 0.3851;&#xA;const unsigned int SAMPLES = 10;&#xA;const float MILLI_AMPS = 19.125;&#xA;unsigned long currentMillis;&#xA;unsigned long oldMillis = 0;&#xA;unsigned long timeBetweenSamples = 1000; // milliseconds between samples&#xA;int measurement[SAMPLES];&#xA;int read_index = 0;&#xA;int total = 0;&#xA;int average_cts = 0;&#xA;boolean initialized = false;&#xA;float degC = 0;&#xA;float degF = 0;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  for (int i = 0; i &amp;lt; SAMPLES; i++) {&#xA;    measurement[i] = 0;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Reset the counter when we go over the&#xA;  // set number of samples&#xA;  if (read_index &amp;gt;= SAMPLES) {&#xA;    read_index = 0;&#xA;    initialized = true;&#xA;  }&#xA;&#xA;  // only take a measurement if one second has passed&#xA;  currentMillis = millis();&#xA;&#xA;  if (currentMillis - oldMillis &amp;gt;= timeBetweenSamples) {&#xA;    // subtract one element from the total&#xA;    total = total - measurement[read_index];&#xA;&#xA;    // take a measurement&#xA;    measurement[read_index] = analogRead(RTD_PIN);&#xA;&#xA;    // add the new measurement back into the total&#xA;    total = total + measurement[read_index];&#xA;&#xA;    // take an average of the readings&#xA;    average_cts = total / SAMPLES;&#xA;&#xA;    // calculate degrees&#xA;    degC = (average_cts * MVOLTS_CTS / MILLI_AMPS -100) / OHMS_DEGREE;&#xA;    degF = degC * 1.8 + 32;&#xA;&#xA;    // print results only if all elements of measurement[] are filled&#xA;    if (initialized) {&#xA;      Serial.print(degC);&#xA;      Serial.print(&quot; degrees C &quot;);&#xA;      Serial.print(degF);&#xA;      Serial.print(&quot; degrees F &quot;);&#xA;      Serial.println(average_cts);&#xA;    }&#xA;&#xA;    read_index++;&#xA;    oldMillis = currentMillis;&#xA;&#xA;&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the code that doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Sensor.h&quot;&#xA;&#xA;    Sensor::Sensor (int analogPin, int numSamplesInAverage, unsigned long sampleRate) {&#xA;&#xA;     sensorPin = analogPin;&#xA;     samples = numSamplesInAverage;&#xA;    _sampleRate = sampleRate;&#xA;     int measurement[samples];&#xA;&#xA;     // initialize the measurement array&#xA;     for (int i = 0; i &amp;gt;= samples; i++) {&#xA;       measurement[i] = 0;&#xA;     }&#xA;&#xA;  }&#xA;&#xA;  int Sensor::update() {&#xA;&#xA;    if (read_index &amp;gt;= samples) {&#xA;       read_index = 0;&#xA;     }&#xA;&#xA;     // only take a measurement if sample rate has been exceeded&#xA;     // and return a rolling average&#xA;     currentMillis = millis();&#xA;&#xA;     if (currentMillis - oldMillis &amp;gt;= _sampleRate) {&#xA;       //subtract one element from the total&#xA;       total = total - measurement[read_index];&#xA;&#xA;       // take a measurement&#xA;     measurement[read_index] = analogRead(sensorPin);&#xA;&#xA;       // add the new measurement into the total&#xA;       total = total + measurement[read_index];&#xA;&#xA;       // take an average of the readings&#xA;       average_cts = total / samples;&#xA;&#xA;       // increment the read_index&#xA;       read_index++;&#xA;       oldMillis = currentMillis;&#xA;&#xA;      return average_cts;&#xA;     }&#xA;&#xA;     // return false if the sample rate has not expired &#xA;     return false;     &#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like the issue is with this one line of code on line 34.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;measurement[read_index] = analogRead(sensorPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this line has not been remarked out the read_index only goes to 4 before it resets to 0 and it does it at the rate of program execution instead of every second like expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this line is remarked out the the read_index is incremented from 0 to 9 once every second as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is where the read_index is defined.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef Sensor_h&#xA;#define Sensor_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;class Sensor&#xA;{&#xA;   public:&#xA;     Sensor(int analogPin, int numSamplesInAverage, unsigned long sampleRate);&#xA;     int update();&#xA;&#xA;   private:&#xA;     unsigned int sensorPin;&#xA;     unsigned long currentMillis;&#xA;     unsigned long oldMillis;&#xA;     unsigned long sampleRate; // milliseconds between samples&#xA;     int read_index = 0;&#xA;     int total = 0;&#xA;     int average_cts = 0;&#xA;     int samples;&#xA;     unsigned long _sampleRate;&#xA;     int measurement[];&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is the Arduino sketch that calls update()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Sensor.h&amp;gt;&#xA;&#xA;&#xA;Sensor rtd(4, 10, 1000);  // instantiate a Sensor object&#xA;int cts;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  rtd.update();&#xA;&#xA;  Serial.println(rtd.read_index);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can anyone tell me why this works in my procedural code but not the objected oriented code?&lt;/p&gt;&#xA;" OwnerUserId="13651" LastEditorUserId="13651" LastEditDate="2015-09-28T07:42:16.847" LastActivityDate="2015-09-29T01:51:16.823" Title="Identical statements, different outcome" Tags="|arduino-uno|programming|c++|analogread|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16371" PostTypeId="1" AcceptedAnswerId="16387" CreationDate="2015-09-28T05:55:16.683" Score="0" ViewCount="255" Body="&lt;p&gt;I'm trying to get &lt;a href=&quot;http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf&quot; rel=&quot;nofollow&quot;&gt;MMA8452Q&lt;/a&gt; to trigger an interrupt when motion is detected and wonder if I'm missing something very obvious here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I setup CTRL_REG4 to 0x0B with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MMA8452Q::setupISR()&#xA;{&#xA;    writeRegister(CTRL_REG4, 0x0B);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then I setup FF_MT with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MMA8452Q::setupFF_MT()&#xA;{&#xA;    writeRegister(FF_MT_CFG, 0xF8);&#xA;    writeRegister(FF_MT_THS, 0x0F);&#xA;    writeRegister(FF_MT_COUNT, 0x00);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I read ISR with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SRC_PULSE 2&#xA;#define SRC_FF_MT 1&#xA;&#xA;byte MMA8452Q::readISR()&#xA;{&#xA;    byte intStat = readRegister(INT_SOURCE);&#xA;&#xA;    if (intStat &amp;amp; 0x0B)&#xA;    {&#xA;        readRegister(FF_MT_SRC);&#xA;        return intStat &amp;amp; 0x0B;&#xA;    }&#xA;    else&#xA;        return 0;&#xA;}&#xA;&#xA;void printISR()&#xA;{&#xA;  byte isr = (accel.readISR() &amp;gt;&amp;gt; 2);&#xA;  if (isr &amp;amp; SRC_PULSE)&#xA;    Serial.print(&quot;(ISR) Tap&quot;);&#xA;  else&#xA;    Serial.print(&quot;(ISR) No Tap&quot;);&#xA;&#xA;  Serial.print(&quot;\t&quot;);&#xA;&#xA;  if (isr &amp;amp; SRC_FF_MT)&#xA;    Serial.print(&quot;(ISR) Motion&quot;);&#xA;  else&#xA;    Serial.print(&quot;(ISR) No Motion&quot;);&#xA;&#xA;  Serial.print(&quot;\t&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AFAIK, that should already have FF/MT interrupt enabled. Even when I'm getting readings in &lt;code&gt;FF_MT_SRC&lt;/code&gt;, I'm not picking up an interrupt in &lt;code&gt;INT_SOURCE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are fired on (most) taps, but not on motion at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="13302" LastEditorUserId="13302" LastEditDate="2015-10-01T12:04:03.357" LastActivityDate="2015-10-01T12:04:03.357" Title="Interrupt not firing on motion" Tags="|arduino-uno|sensors|c|accelerometer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16372" PostTypeId="1" CreationDate="2015-09-28T07:10:04.477" Score="0" ViewCount="841" Body="&lt;p&gt;I'd like to get a TCP based connection from an arduino to a node.JS server. I found an example, I've tried to run it but its throwing the errors below, would appreciate any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Error Messages&#xA;    Arduino: 1.6.6 Hourly Build 2015/09/24 05:43 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WARNING: Category '' in library ArduinoJson is not valid. Setting to 'Uncategorized'&#xA;socketio.ino: In function 'void hello(Client&amp;amp;, const char*)':&#xA;&#xA;socketio:19: error: expected unqualified-id before '.' token&#xA;&#xA;socketio.ino: In function 'void setup()':&#xA;&#xA;socketio:38: error: invalid conversion from 'void (*)(Client&amp;amp;, const char*)' to 'void (*)(Client&amp;amp;, ArduinoJson::JsonArray&amp;amp;)' [-fpermissive]&#xA;&#xA;In file included from socketio.ino:6:0:&#xA;&#xA;C:\arduino_1.6.6\libraries\socket.io-arduino-client.2/SocketIOClient.h:56:8: error:   initializing argument 2 of 'void SocketIOClient::setEventHandler(const char*, void (*)(Client&amp;amp;, ArduinoJson::JsonArray&amp;amp;))' [-fpermissive]&#xA;&#xA;   void setEventHandler(const char* eventName, void (*handler)(Client&amp;amp; client, JsonArray&amp;amp; data));&#xA;&#xA;        ^&#xA;&#xA;socketio:39: error: invalid conversion from 'void (*)(Client&amp;amp;, const char*)' to 'void (*)(Client&amp;amp;, ArduinoJson::JsonArray&amp;amp;)' [-fpermissive]&#xA;&#xA;In file included from socketio.ino:6:0:&#xA;&#xA;C:\arduino_1.6.6\libraries\socket.io-arduino-client.2/SocketIOClient.h:56:8: error:   initializing argument 2 of 'void SocketIOClient::setEventHandler(const char*, void (*)(Client&amp;amp;, ArduinoJson::JsonArray&amp;amp;))' [-fpermissive]&#xA;&#xA;   void setEventHandler(const char* eventName, void (*handler)(Client&amp;amp; client, JsonArray&amp;amp; data));&#xA;&#xA;        ^&#xA;&#xA;exit status 1&#xA;expected unqualified-id before '.' token&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino Code&#xA;    #include &#xA;    #include &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;#include &amp;lt;SocketIOClient.h&amp;gt;&#xA;&#xA;EthernetClient ethClient;&#xA;SocketIOClient client(ethClient);&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;char hostname[] = &quot;192.168.100.40&quot;;&#xA;int port = 3000;&#xA;&#xA;// Socket.io &quot;hello&quot; EVENT handler&#xA;void hello(Client&amp;amp; client, char const * data) {&#xA;    Serial.print(&quot;[hello] event happening: &quot;);&#xA;    Serial.println(data);&#xA;    Client.emit(&quot;goodbye&quot;, &quot;Arduino here, goodbye!&quot;);&#xA;}&#xA;&#xA;// Socket.io &quot;goodbye&quot; EVENT handler&#xA;void goodbye(Client&amp;amp; client, char const * data) {&#xA;    Serial.print(&quot;[goodbye] event happening: &quot;);&#xA;    Serial.println(data);&#xA;    Serial.println(&quot;That is all.&quot;);&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Ethernet.begin(mac);&#xA;&#xA;    if(!client.connect(hostname, port)) {&#xA;        Serial.println(F(&quot;Not connected.&quot;));&#xA;    }&#xA;&#xA;    //Event hanlders&#xA;    client.setEventHandler(&quot;hello&quot;, hello);&#xA;    client.setEventHandler(&quot;goodbye&quot;, goodbye);&#xA;&#xA;    //Say hello to the server&#xA;    client.emit(&quot;hello&quot;, &quot;Arduino here, hello!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    client.monitor();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SocketIO.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;    socket.io-arduino-client: a Socket.IO client for the Arduino&#xA;&#xA;    Based on Bill Roy's Arduino Socket.IO Client (which is based on &#xA;    Kevin Rohling's Arduino WebSocket Client) with event handling by&#xA;    @dantaex&#xA;&#xA;    Copyright 2014 Quentin Pigné&#xA;&#xA;    Permission is hereby granted, free of charge, to any person&#xA;    obtaining a copy of this software and associated documentation&#xA;    files (the &quot;Software&quot;), to deal in the Software without&#xA;    restriction, including without limitation the rights to use,&#xA;    copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;    copies of the Software, and to permit persons to whom the&#xA;    Software is furnished to do so, subject to the following&#xA;    conditions:&#xA;&#xA;    The above copyright notice and this permission notice shall be&#xA;    included in all copies or substantial portions of the Software.&#xA;&#xA;    THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,&#xA;    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES&#xA;    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND&#xA;    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT&#xA;    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,&#xA;    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING&#xA;    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR&#xA;    OTHER DEALINGS IN THE SOFTWARE.&#xA;*/&#xA;&#xA;#ifndef SocketIOClient_H&#xA;#define SocketIOClient_H&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Client.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;&#xA;#include &quot;HashMap.h&quot;&#xA;&#xA;//Length of static data buffers&#xA;#define DATA_BUFFER_LEN 200&#xA;#define SID_LEN 24&#xA;&#xA;//Max size of the HashTable&#xA;#define HASH_SIZE 20&#xA;&#xA;class SocketIOClient {&#xA;    public:&#xA;        SocketIOClient(Client&amp;amp; client);&#xA;        //Public connection methods&#xA;        bool connect(const char* hostname, int port = 80, const char* resource = &quot;socket.io&quot;, const char* nsp = &quot;/&quot;);&#xA;        //Public event handling methods&#xA;        void setEventHandler(const char* eventName, void (*handler)(Client&amp;amp; client, JsonArray&amp;amp; data));&#xA;        //Public data emitting methods&#xA;        void emit(const char* event, const char* data);&#xA;        //Monitoring for incoming data&#xA;        void monitor();&#xA;&#xA;    private:&#xA;        //Connection attributes&#xA;        Client&amp;amp; client;&#xA;        char* hostname;&#xA;        int port;&#xA;        char* resource;&#xA;        char* nsp;&#xA;        char sid[SID_LEN];&#xA;        //Incoming data reading attributes&#xA;        char databuffer[DATA_BUFFER_LEN];&#xA;        char* dataptr;&#xA;        //Event handling attributes&#xA;        int nbEvent;&#xA;        static HashType&amp;lt;const char*, void(*)(Client&amp;amp; client, JsonArray&amp;amp; data)&amp;gt; hashRawArray[HASH_SIZE];&#xA;        static HashMap&amp;lt;const char*, void(*)(Client&amp;amp; client, JsonArray&amp;amp; data)&amp;gt; eventHandlers;&#xA;&#xA;        //Private incoming data reading methods&#xA;        bool waitForInput();&#xA;        void eatHeader();&#xA;        void readInput();&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4597" LastEditorUserId="4597" LastEditDate="2015-09-29T05:27:19.170" LastActivityDate="2015-09-29T05:27:19.170" Title="Help with socketIO Example" Tags="|node.js|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16373" PostTypeId="2" ParentId="16372" CreationDate="2015-09-28T09:38:45.457" Score="1" Body="&lt;p&gt;Make your &lt;code&gt;char *&lt;/code&gt; parameters &lt;code&gt;const char *&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-28T09:38:45.457" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16374" PostTypeId="2" ParentId="16370" CreationDate="2015-09-28T09:57:53.027" Score="1" Body="&lt;p&gt;You have made a few fundamental errors with your class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly you have not provided a storage size (number of elements) for the &lt;code&gt;measurement&lt;/code&gt; array class member variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Sensor&#xA;{&#xA;   public:&#xA;     Sensor(int analogPin, int numSamplesInAverage, unsigned long sampleRate);&#xA;     int update();&#xA;&#xA;   private:&#xA;     // ... cut ...&#xA;     int measurement[];           // &amp;lt;&amp;lt;-- How big is this?!&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it seems like you try to dynamically allocate the space for it in your constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sensor::Sensor (int analogPin, int numSamplesInAverage, unsigned long sampleRate) {&#xA;&#xA;    sensorPin = analogPin;&#xA;    samples = numSamplesInAverage;&#xA;    _sampleRate = sampleRate;&#xA;    int measurement[samples];    // &amp;lt;&amp;lt;-- Here&#xA;    // ... cut ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BUT that's &lt;em&gt;not&lt;/em&gt; what you are doing.  What you are doing there is creating a &lt;em&gt;new&lt;/em&gt; local variable (local to &lt;em&gt;just that one single function&lt;/em&gt;) called &lt;code&gt;measurement&lt;/code&gt; with an array size of &lt;code&gt;samples&lt;/code&gt;.  As soon as you leave the constructor that variable is thrown away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't touched the class member variable &lt;code&gt;measurement&lt;/code&gt; at all.  So, when you do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;measurement[read_index] = analogRead(sensorPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you are storing the read value into an array of no size that points nowhere.  And of course that then causes a crash because you're writing to memory that you shouldn't be writing to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be specifying the number of array elements in the constructor you need to be learning about &lt;em&gt;dynamic memory allocation&lt;/em&gt; using &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt; and all the pitfalls that go along with using those on a small microcontroller with very tight RAM constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an example of how it can be done you should take a look at my &lt;a href=&quot;https://github.com/MajenkoLibraries/Average&quot; rel=&quot;nofollow&quot;&gt;Average Library&lt;/a&gt; which uses dynamic allocation to allocate the array memory in the constructor and free it in the destructor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-28T09:57:53.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16376" PostTypeId="1" AcceptedAnswerId="16460" CreationDate="2015-09-28T12:35:37.710" Score="2" ViewCount="6755" Body="&lt;p&gt;NOOB Question: when my Uno is connected to an external power source it will not start running the uploaded sketch. The Arduino web site says it's because the RX pin is not connected and then gets random data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The site suggests grounding the RX pin using a resistor (granted it suggests a 10K and I used a smaller one ) or connecting it to the TX pin.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting#toc19&quot; rel=&quot;nofollow&quot;&gt;Why doesn't my sketch start when I power up or reset the Arduino board?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Most likely because you are sending serial data to the board when it&#xA;  firsts turns on. During the first few seconds, the bootloader (a&#xA;  program pre-burned onto the chip on the board) listens for the&#xA;  computer to send it a new sketch to be uploaded to the board. After a&#xA;  few seconds without communication, the bootloader will time out and&#xA;  start the sketch that's already on the board. If you continue to send&#xA;  data to the bootloader, it will never time out and your sketch will&#xA;  never start. You'll either need to find a way to stop serial data from&#xA;  arriving for the first few seconds when the board powers (e.g. by&#xA;  enabling the chip that sends the data from within your setup()&#xA;  function) or burn your sketch onto the board with an external&#xA;  programmer, replacing the bootloader.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting#toc6&quot; rel=&quot;nofollow&quot;&gt;Why doesn't my sketch start when I'm powering the board with an external power supply? (Arduino Diecimila or earlier)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because the RX pin is unconnected, the bootloader on the board may be&#xA;  seeing garbage data coming in, meaning that it never times out and&#xA;  starts your sketch. Try tying the RX pin to ground with a 10K resistor&#xA;  (or connecting RX directly to the TX pin).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Both failed for me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="13657" LastEditorUserId="6936" LastEditDate="2016-03-29T06:25:30.750" LastActivityDate="2020-11-23T21:30:36.120" Title="Sketch will not start with external power source" Tags="|arduino-uno|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16378" PostTypeId="2" ParentId="16369" CreationDate="2015-09-28T15:49:10.170" Score="0" Body="&lt;p&gt;Instead of the two delays of one second, have the program check if the current time is an even or odd number of seconds.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int prPin = A0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(5,OUTPUT);&#xA;  pinMode(6,OUTPUT);&#xA;  pinMode(7,OUTPUT);&#xA;  pinMode(8,OUTPUT);&#xA;  pinMode(9,OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(prPin,INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int prVal = analogRead(prPin);&#xA;    Serial.write(prVal);&#xA;    if(prVal&amp;gt;450)&#xA;    {&#xA;      if( (millis()/1000)%2 == 0 ) // check if even or odd number of seconds have passes since the program started&#xA;      {&#xA;        digitalWrite(5,HIGH);&#xA;        digitalWrite(6,HIGH);&#xA;        digitalWrite(7,HIGH);&#xA;        digitalWrite(8,LOW);&#xA;        digitalWrite(9,HIGH);&#xA;        digitalWrite(10,HIGH);&#xA;      } &#xA;      else &#xA;      {&#xA;        digitalWrite(5,LOW);&#xA;        digitalWrite(6,HIGH);&#xA;        digitalWrite(7,HIGH);&#xA;        digitalWrite(8,HIGH);&#xA;        digitalWrite(9,HIGH);&#xA;        digitalWrite(10,HIGH);&#xA;      }&#xA;    }&#xA;    else&#xA;    {&#xA;      digitalWrite(5,HIGH);&#xA;      digitalWrite(6,HIGH);&#xA;      digitalWrite(7,LOW);&#xA;      digitalWrite(8,HIGH);&#xA;      digitalWrite(9,HIGH);&#xA;      digitalWrite(10,LOW);&#xA;      delay(10);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-09-28T18:12:08.087" LastActivityDate="2015-09-28T18:12:08.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16379" PostTypeId="1" AcceptedAnswerId="16411" CreationDate="2015-09-28T15:50:04.737" Score="0" ViewCount="762" Body="&lt;p&gt;I bought a GPS module with GPS antenna SIM39EA online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manual for the GPS module is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vis-plus.ee/pdf/SIM39EA_Hardware_Design_V1.00.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.vis-plus.ee/pdf/SIM39EA_Hardware_Design_V1.00.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino board. It has 3 ground pin, one Vcc and two input/output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know how can I connect this module to Arduino GPS module and get GPS coordinates?&lt;/p&gt;&#xA;" OwnerUserId="13661" LastEditorUserId="26916" LastEditDate="2017-11-04T06:17:36.487" LastActivityDate="2017-11-04T06:17:36.487" Title="Connect GPS module with GPS antenna SIM39EA to Arduino Uno" Tags="|arduino-uno|hardware|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16380" PostTypeId="1" CreationDate="2015-09-28T16:25:05.447" Score="0" ViewCount="3217" Body="&lt;p&gt;Connected a generic ESP8266 to an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can send AT commands fine and generate a normal response, but cannot upload sketches to the ESP8266. I have &quot;Generic ESP8266 Module selected as the board. Tried everything e.g. switching Tx and Rx, connecting GPIO0 and GPIO2 to to Vcc or ground, but to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino IDE spits this out -&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;esptool v0.4.5 - (c) 2014 Ch. Klippel &amp;lt;ck@atelier-klippel.de&amp;gt;&#xA;    setting board to ck&#xA;    setting baudrate from 115200 to 115200&#xA;    setting port from COM1 to COM3&#xA;    setting address from 0x00000000 to 0x00000000&#xA;    espcomm_upload_file&#xA;    stat C:\Users\Michael\AppData\Local\Temp\build7227402767538495982.tmp/wifi_setup.cpp.bin success&#xA;    setting serial port timeouts to 1000 ms&#xA;opening bootloader&#xA;resetting board&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    read 0, requested 1&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;resetting board&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    read 0, requested 1&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;resetting board&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    read 0, requested 1&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;trying to connect&#xA;    flush start&#xA;    setting serial port timeouts to 1 ms&#xA;    setting serial port timeouts to 1000 ms&#xA;    flush complete&#xA;    espcomm_send_command: sending command header&#xA;    espcomm_send_command: sending command payload&#xA;    espcomm_send_command: receiving 2013 bytes of data&#xA;    read 0, requested 1&#xA;error: failed reading byte&#xA;warning: espcomm_send_command: cant receive slip payload data&#xA;warning: espcomm_sync failed&#xA;error: espcomm_open failed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13663" LastActivityDate="2016-10-24T17:38:46.433" Title="Can send AT+ commands, but can't upload sketch to ESP8266 via Arduino Uno" Tags="|arduino-uno|wifi|esp8266|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16383" PostTypeId="1" AcceptedAnswerId="21766" CreationDate="2015-09-28T06:41:24.407" Score="2" ViewCount="2195" Body="&lt;p&gt;I am designing a PCB in which I am using the MCU used in &lt;strong&gt;&lt;code&gt;Arduino UNO&lt;/code&gt;&lt;/strong&gt; which is &lt;strong&gt;&lt;code&gt;Atmega328P&lt;/code&gt;&lt;/strong&gt; and some other components as per my project requirements. I have almost designed the circuit but I am confused with the USB programming part. I want my MCU to be programmed using &lt;strong&gt;&lt;code&gt;USB B Type&lt;/code&gt;&lt;/strong&gt; just like we do it in &lt;strong&gt;&lt;code&gt;Arduino UNO&lt;/code&gt;&lt;/strong&gt;. My friend suggests me to purchase an &lt;strong&gt;&lt;code&gt;Arduino UNO&lt;/code&gt;&lt;/strong&gt; device and program that MCU and then put it in my circuit. But I don't want to do it like this. I have found the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;schematic design&lt;/strong&gt;&lt;/a&gt; but its very confusing. Can anyone help me out with this.? &lt;/p&gt;&#xA;" OwnerUserId="13197" OwnerDisplayName="CZAbhinav" LastActivityDate="2016-03-14T12:48:11.263" Title="How to make an Arduino USB programming circuit?" Tags="|usb|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16384" PostTypeId="2" ParentId="16383" CreationDate="2015-09-28T07:33:44.257" Score="2" Body="&lt;p&gt;Looking at the schematic design, you need atmega8 to make a usb programming connection. Design your circuit exactly like in the schematic.You will also need bootloader for it, so use any programmer like usbasp, connect its pins to mosi, miso sck, rst,vcc,gnd and click on burn boot loader in arduino ide&lt;/p&gt;&#xA;" OwnerUserId="13321" OwnerDisplayName="anna carolina" LastActivityDate="2015-09-28T07:33:44.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16385" PostTypeId="1" CreationDate="2015-09-28T20:40:56.500" Score="2" ViewCount="1019" Body="&lt;p&gt;Im new here. Anyone that could give a code or sample that would generate I wanted to use a frequency in range of 35k-43kHz. Please help me.&lt;/p&gt;&#xA;" OwnerUserId="13535" OwnerDisplayName="user13535" LastEditorUserId="10794" LastEditDate="2015-09-29T07:43:17.823" LastActivityDate="2015-09-29T19:21:44.950" Title="Arduino coding of producing frequency" Tags="|arduino-uno|c++|frequency|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16386" PostTypeId="2" ParentId="16385" CreationDate="2015-09-28T21:19:07.790" Score="-1" Body="&lt;p&gt;This is meant to be a comment, but I can't put (pseudo) code in a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 40 kHz square wave? Simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(;;){&#xA;   wait ( 1 / 2 * 40.000 );&#xA;   make pin high;&#xA;   wait ( 1 / 2 * 40.000 );&#xA;   make pin low;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="43104" OwnerDisplayName="Wouter van Ooijen" LastActivityDate="2015-09-28T21:19:07.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16387" PostTypeId="2" ParentId="16371" CreationDate="2015-09-28T21:40:23.857" Score="0" Body="&lt;p&gt;Here's an extract from page 39 of MMA8452Q-rev8.1.pdf, the MMA8452 spec sheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4kWQL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4kWQL.jpg&quot; alt=&quot;interrupt enable bits&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than saying &lt;code&gt;writeRegister(CTRL_REG4, 0x0B);&lt;/code&gt; in &lt;code&gt;MMA8452Q::setupISR()&lt;/code&gt;, try &lt;code&gt;writeRegister(CTRL_REG4, 0xD);&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;0xB is 1011 in binary, while 0xD is 1101, which turns on INT_EN_FF_MT to enable freefall/motion interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above should answer your question as asked.  The following expands on my earlier comment which said&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Absent other info, it looks like MMA8452Q::readISR() is not an interrupt processing routine, but instead a routine that polls an interrupt-source register to find out what source would have triggered an interrupt if correctly wired and initialized.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&quot;Interrupt&quot; as used in your question (and code) refers to when the MMA8452 signals (via an I1 or I2 output line) that an interrupt-worthy condition has occurred.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Interrupt&quot; as in the question does not refer to an interrupt from the Uno's point of view, because (per diagram) neither of I1 or I2 connects to the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If speed of response becomes important, you may wish to hook I1 or I2 to one of the Uno's Digital Pins With Interrupts, ie pin 2 or 3, as noted in the &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow noreferrer&quot;&gt;AttachInterrupt&lt;/a&gt; page at arduino.cc.  Then you'd replace the polling loop that now periodically reads the MMA8452's ISR (interrupt status register) to check for set bits, with an interrupt service routine which would set a flag to cause loop() to use Wire.read to get ISR data.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-09-28T21:40:23.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16388" PostTypeId="2" ParentId="16370" CreationDate="2015-09-28T21:58:31.813" Score="0" Body="&lt;p&gt;I was going to add to Majenko's excellent answer, but what I want to say is too long. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int measurement[];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int * measurement;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then in the constructor do: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;measurement = new int [samples];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And check that measurement is not NULL, in case there is not enough memory.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, this is wrong in two ways:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// initialize the measurement array&#xA;for (int i = 0; i &amp;gt;= samples; i++) {&#xA;  measurement[i] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// initialize the measurement array&#xA;for (int i = 0; i &amp;lt; samples; i++) {&#xA;  measurement[i] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to test less than, and you don't test equals (that would initialize one too many).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should also have a destructor that frees the memory, ie.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete [] measurement;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When would this destructor come into play? How and when should I call it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The destructor is automatically called when an instance of the class is destroyed. This is when you do things like free memory you allocated. You don't call it directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Sensor&#xA;{&#xA;public:&#xA;  // constructor&#xA;  Sensor(int analogPin, int numSamplesInAverage, unsigned long mysampleRate);&#xA;  // destructor&#xA;  ~Sensor (); &#xA;  // call to update samples&#xA;  int update();&#xA;&#xA;private:&#xA;  unsigned int sensorPin;&#xA;  unsigned long currentMillis;&#xA;  unsigned long oldMillis;&#xA;  unsigned long sampleRate; // milliseconds between samples&#xA;  int read_index;&#xA;  int total;&#xA;  int average_cts;&#xA;  int samples;&#xA;  int * measurement;&#xA;};&#xA;&#xA;Sensor::Sensor (int analogPin, int numSamplesInAverage, unsigned long mysampleRate) &#xA;  {&#xA;  sensorPin = analogPin;&#xA;  samples = numSamplesInAverage;&#xA;  sampleRate = mysampleRate;&#xA;  read_index = 0;&#xA;  total = 0;&#xA;  average_cts = 0;&#xA;  measurement = new int [samples];&#xA;&#xA;  if (measurement == NULL)&#xA;    exit (1);  // can't continue&#xA;&#xA;  // initialize the measurement array&#xA;  for (int i = 0; i &amp;lt; samples; i++) {&#xA;    measurement[i] = 0;&#xA;  }&#xA;&#xA;}  // end of constructor&#xA;&#xA;// destructor&#xA;Sensor::~Sensor ()&#xA;  {&#xA;  delete [] measurement; &#xA;  }  // end of destructor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you please explain how these two line of code work &lt;code&gt;int * measurement&lt;/code&gt; and &lt;code&gt;measurement = new int [samples];&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int * measurement&lt;/code&gt; creates a pointer to an int (called &lt;code&gt;measurement&lt;/code&gt;). However pointers can also point to the start of an array (or indeed, to the middle of an array) of ints. So this variable will hold the start of your array of ints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;measurement = new int [samples];&lt;/code&gt; allocates the memory for this array - in this case &quot;samples&quot; lots of ints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the memory is allocated you can treat the pointer as an array, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;measurement [5] = 42;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more detail about this see &lt;a href=&quot;http://c-faq.com/aryptr/aryptrequiv.html&quot; rel=&quot;nofollow&quot;&gt;So what is meant by the &quot;equivalence of pointers and arrays&quot; in C?&lt;/a&gt; and also Google: &lt;code&gt;pointer vs array&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also Google: &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; with reference to the C++ language.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-09-29T01:51:16.823" LastActivityDate="2015-09-29T01:51:16.823" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16389" PostTypeId="2" ParentId="16303" CreationDate="2015-09-28T23:00:20.467" Score="0" Body="&lt;p&gt;The new Twitter 1.1 API requires OAuth authorization over SSL, for which Arduino is under-powered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to write a proxy application, which would parse the tweets and then send a RGB color value to your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should split your project into three parts.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Retrieving tweets with the &lt;a href=&quot;https://dev.twitter.com/overview/documentation&quot; rel=&quot;nofollow&quot;&gt;Twitter API&lt;/a&gt;.&lt;br&gt;&#xA;You can get some library to do it for you.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Communicating with your Arduino.&lt;br&gt;&#xA;Just try to send an arbitrary color to your Arduino over internet.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And finally joining first two pieces of code together.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And if you get stuck somewhere, you can always ask for help here on StackExchenge.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-09-28T23:00:20.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16390" PostTypeId="1" AcceptedAnswerId="16391" CreationDate="2015-09-28T22:39:11.607" Score="5" ViewCount="460" Body="&lt;p&gt;I have a small piece of code here that I hope to run on Arduino. Basically what this code is doing is, it takes a nibble from the user, appends a &lt;code&gt;startbit&lt;/code&gt; to it, and transmits the code through a transmitter module. The receiver end receives the bits and checks if &lt;code&gt;startbit&lt;/code&gt; is being received. If &lt;code&gt;startbit&lt;/code&gt; is not being received, then it prints out whatever was transmitted. If &lt;code&gt;startbit&lt;/code&gt; is received, then it doesn't print the startbit, just the nibble all in one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: is it convention/clever to use the bool array or should I not do that? Second, is there a way to make my code more efficient? Where can I clean it up? Also, is my code legible or very convoluted? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;WirelessComm.h&amp;gt;&#xA;&#xA;int tx_pin;&#xA;int rx_pin;&#xA;WirelessComm::WirelessComm(int rxPin, int txPin)&#xA;{&#xA;    pinMode(rxPin, INPUT);&#xA;    tx_pin = txPin;&#xA;    rx_pin = rxPin; &#xA;}&#xA;&#xA;int countDigit(long n)&#xA;{&#xA;    int count = 0;&#xA;    while (n &amp;gt; 0)&#xA;    {&#xA;        n /= 10;&#xA;        count++;&#xA;    }&#xA;    return count;&#xA;}&#xA;&#xA;void getDigit(bool *data, long num)&#xA;{&#xA;    int cd = countDigit(num);&#xA;    long shift = 1;&#xA;    for (int i = 0; i &amp;lt; cd; i++)&#xA;    {&#xA;        data[i] = (num / shift) % 10;&#xA;        shift *= 10;&#xA;    }&#xA;}&#xA;&#xA;int WirelessComm::writeTx(long nibble)&#xA;{   &#xA;    int i;&#xA;    bool data[11]; // warning: I didn't check for buffer overrun!&#xA;    int32_t startBit = 110101L; // larger than 32767, so cannot be in int&#xA;    if(nibble != 0)&#xA;    {&#xA;        int sbLen = countDigit(startBit);&#xA;        for (int i = 0; i &amp;lt; (int)(sizeof(data) / sizeof(data[0])); i++) &#xA;            data[i] = 0;&#xA;        getDigit(data, startBit);&#xA;        getDigit(data + sbLen, nibble);&#xA;    }&#xA;    else&#xA;        return -1;&#xA;&#xA;    for(i = 0; i &amp;lt; 10; i++)&#xA;    {&#xA;        if(data[i] == 1)&#xA;        {&#xA;            digitalWrite(tx_pin, HIGH);&#xA;        }&#xA;        else&#xA;        {&#xA;            digitalWrite(tx_pin, LOW);&#xA;        }&#xA;&#xA;    }&#xA;    return 1;&#xA;}&#xA;&#xA;int WirelessComm::readRx(long nibble)&#xA;{&#xA;    bool first = 0;&#xA;    bool second = 2; //initially set to some random value&#xA;    bool third = 2;&#xA;    bool fourth = 2;&#xA;    bool fifth = 2;&#xA;    bool sixth = 2;&#xA;    bool counter = 0;&#xA;    bool val = 0;&#xA;    while(true)&#xA;    {&#xA;        first = digitalRead(rx_pin);&#xA;        if(first == 1);&#xA;        {&#xA;            second = digitalRead(rx_pin);&#xA;            if(second == 1)&#xA;            {&#xA;                third = digitalRead(rx_pin);&#xA;                if(third == 0)&#xA;                {&#xA;                    fourth = digitalRead(rx_pin);&#xA;                    if(fourth == 1)&#xA;                    {&#xA;                        fifth = digitalRead(rx_pin);&#xA;                        if(fifth == 0)&#xA;                        {&#xA;                            sixth = digitalRead(rx_pin);&#xA;                            if(sixth == 1)&#xA;                            {&#xA;                                while(counter &amp;lt; 4)&#xA;                                {&#xA;                                    val = digitalRead(rx_pin);&#xA;                                    Serial.print(val);&#xA;                                    counter++;&#xA;                                }&#xA;                                Serial.println();&#xA;&#xA;                            }&#xA;                            else&#xA;                                Serial.println(first);&#xA;                                first = digitalRead(rx_pin);  &#xA;                        }&#xA;                        else&#xA;                            Serial.println(first);&#xA;                            first = digitalRead(rx_pin);  &#xA;                    }&#xA;                    else&#xA;                        Serial.println(first);&#xA;                        first = digitalRead(rx_pin);  &#xA;                }&#xA;                else&#xA;                    Serial.println(first);&#xA;                    first = digitalRead(rx_pin);  &#xA;            }&#xA;            else&#xA;                Serial.println(first);&#xA;                first = digitalRead(rx_pin);  &#xA;        }&#xA;        else&#xA;            Serial.println(first);&#xA;            first = digitalRead(rx_pin);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13674" OwnerDisplayName="Jonathan Smit" LastEditorUserId="13674" LastEditDate="2015-09-29T04:31:46.560" LastActivityDate="2015-09-29T05:37:55.757" Title="Basic Serial Transmission Protocol" Tags="|c++|wireless|project-critique|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="16391" PostTypeId="2" ParentId="16390" CreationDate="2015-09-29T02:20:35.167" Score="5" Body="&lt;p&gt;What you are doing is called &quot;bit-banging&quot; &lt;a href=&quot;https://en.wikipedia.org/wiki/Bit_banging&quot; rel=&quot;noreferrer&quot;&gt;(wikipedia link)&lt;/a&gt; but you have no guarantees about the timing of your bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;writeTx&lt;/code&gt; routine you are changing &lt;code&gt;tx_pin&lt;/code&gt; at some rate which depends on:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the clock speed of your MCU&lt;/li&gt;&#xA;&lt;li&gt;the code that the C compiler generates&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Moreover, the timing will be all screwed up if you happen to get an interrupt while sending the bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same applies to your read routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino (really the Atmel MCU) has special hardware to perform both synchronous and asynchronous serial IO. The set up is rather complex because the hardware&#xA;is very versatile and capable of a lot of different functions.&#xA;In particular, it can deliver the bits at a specific baud rate for you so your code doesn't have to do it. It can also read in a serial stream and set a flag or invoke an interrupt when a complete word has been received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This article can give you an idea of what the USART in an Atmel processor is capable of:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://maxembedded.com/2013/09/the-usart-of-the-avr/&quot; rel=&quot;noreferrer&quot;&gt;http://maxembedded.com/2013/09/the-usart-of-the-avr/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13673" LastActivityDate="2015-09-29T02:20:35.167" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16392" PostTypeId="1" AcceptedAnswerId="16395" CreationDate="2015-09-29T05:00:53.473" Score="1" ViewCount="13478" Body="&lt;p&gt;I have the Arduino Pro Micro and I would like to use all the &lt;strong&gt;analog&lt;/strong&gt; pins that I can on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It currently looks like it has a total of &lt;strong&gt;9 Analog pins&lt;/strong&gt; that can be used.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SEiwb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SEiwb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A0, A1, A2, A3, A6, A7, A8, A9 and A10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am unsure how to call these pins since all of those are also &lt;strong&gt;digital pins&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would A0-A3 be defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define analog1 A0;&#xA;#define analog2 A1;&#xA;#define analog3 A2;&#xA;#define analog4 A3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While the other pins would be this?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define analog5 4;&#xA;#define analog6 6;&#xA;#define analog7 8;&#xA;#define analog8 9;&#xA;#define analog9 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then just call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogRead(analog1);&#xA;analogRead(analog2);&#xA;.....&#xA;analogRead(analog8);&#xA;analogRead(analog10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would that be the correct way of defining the 9 analog pins?&lt;/p&gt;&#xA;" OwnerUserId="5133" LastEditorUserId="972" LastEditDate="2018-12-22T07:10:36.647" LastActivityDate="2018-12-22T07:10:36.647" Title="Arduino Pro Micro Analog Pinouts" Tags="|arduino-ide|arduino-leonardo|analogread|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16393" PostTypeId="1" AcceptedAnswerId="16396" CreationDate="2015-09-29T05:37:53.947" Score="0" ViewCount="212" Body="&lt;p&gt;I have a transmitter(simple &lt;a href=&quot;http://www.ebay.com/itm/433Mhz-RF-transmitter-and-receiver-kit-for-Arduino-ARM-MCU-WL-/261041100836&quot; rel=&quot;nofollow&quot;&gt;433 MHz transmitter&lt;/a&gt;) connected via digital pins on the Arduino. The receiver is connected to another arduino. &#xA;Now, I kept that pin on HIGH for 1 second, and it transmits only 1000 ones. &#xA;But I've seen different example transmitter sketches having baud rates of 1200, 9600, etc. &#xA;So the situation is, when the transmitter is transmitting at maximum capacity(just HIGH for a whole second), it can only transmit 1000 ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to read that it only transmits 1000 ones because my receiver just has a simple read function that reads and prints the data. and it prints 1000 ones every second. Give or take one or two. &#xA;So when you specify a baud rate of 1200, is it useless? how will it transmit 1200 bits/sec?&#xA;Does the baud rate actually increase the hardware limit or what exactly is going on? Can someone please provide me some insight into this? I'd be glad to clarify this question more if need be. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-09-29T06:09:09.030" LastActivityDate="2015-09-29T06:17:40.367" Title="How to fix baud rate when hardware capacity has a low limit?" Tags="|communication|softwareserial|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16394" PostTypeId="2" ParentId="16390" CreationDate="2015-09-29T05:37:55.757" Score="3" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So to clarify, SoftwareSerial uses bit-bang? How are you able to tell? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;By reading the code. For example, this is how it reads 8 bits. It does a delay (which you don't) for the exact amount of time, and then reads the pin, and &quot;ors&quot; it into the variable which is the assembled byte.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Read each of the 8 bits&#xA;for (uint8_t i=0x1; i; i &amp;lt;&amp;lt;= 1)&#xA;{&#xA;  tunedDelay(_rx_delay_intrabit);&#xA;  DebugPulse(_DEBUG_PIN2, 1);&#xA;  uint8_t noti = ~i;&#xA;  if (rx_pin_read())&#xA;    d |= i;&#xA;  else // else clause added to ensure function timing is ~balanced&#xA;    d &amp;amp;= noti;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And to write the 8 bits:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Write each of the 8 bits&#xA;for (byte mask = 0x01; mask; mask &amp;lt;&amp;lt;= 1)&#xA;{&#xA;  if (b &amp;amp; mask) // choose bit&#xA;    tx_pin_write(HIGH); // send 1&#xA;  else&#xA;    tx_pin_write(LOW); // send 0&#xA;&#xA;  tunedDelay(_tx_delay);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your rather elaborate nested &lt;code&gt;if&lt;/code&gt; just seems complete overkill, when you see how SoftwareSerial does it in half a dozen lines.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another typo:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if(first == 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't want that semicolon.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Second, is there a way to make my code more efficient?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use loops, like SoftwareSerial does.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, is my code legible or very convoluted? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Very convoluted.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Where can I clean it up?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I suggest you browse through the SoftwareSerial library for ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile, HardwareSerial is available, so you don't need to write any of this. For that matter, SoftwareSerial is available too. If you are just doing it to learn, well and good.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You really should read about loops. Whenever I have to do something 8 times I have a loop of 8 (or even for &quot;x&quot; times, a loop of &quot;x&quot;). Unrolling into 8 different variables is just confusing and prone to errors. As you had, before you fixed it, doing &lt;code&gt;if(fourth = 1)&lt;/code&gt; instead of &lt;code&gt;if(fourth == 1)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-29T05:37:55.757" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16395" PostTypeId="2" ParentId="16392" CreationDate="2015-09-29T05:38:07.440" Score="4" Body="&lt;p&gt;Assuming you have the &lt;a href=&quot;https://github.com/sparkfun/SF32u4_boards&quot; rel=&quot;nofollow&quot;&gt;Pro Micro core&lt;/a&gt;, they are called A0, A1, A2, A3, A6, A7, A8, A9 and A10. There is no need to &quot;special case&quot; the others, since the pins are known as both.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-29T05:38:07.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16396" PostTypeId="2" ParentId="16393" CreationDate="2015-09-29T06:17:40.367" Score="1" Body="&lt;p&gt;The transmitter you're using is very basic, and only transmits &quot;on&quot; and &quot;off&quot;. As such it is &lt;em&gt;protocol-agnostic&lt;/em&gt;. In order to use it effectively we use it with a protocol that uses &quot;on&quot; and &quot;off&quot; as its signalling, but also includes framing information so that we can know when the data flow starts and stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One such protocol is the UART protocol consisting of 1 start bit, 5 to 9 data bits, an even, odd, or no parity bit, and 1, 1.5, or 2 stop bits, all being generated at a specific rate. This rate is the &quot;baud rate&quot;, and must match in both the sending device's and the receiving device's UART in order for them to communicate. This is true whether the devices are connected by a wire, an optical link, or a radio link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX and RX pins on an Arduino are connected to a hardware UART which will handle the framing and signal generation for you. The hardware UART(s) can be accessed via &lt;a href=&quot;https://www.arduino.cc/en/reference/serial&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Serial&lt;/code&gt;&lt;/a&gt; on non-USB-native Arduinos as well as &lt;code&gt;Serial1&lt;/code&gt;, &lt;code&gt;Serial2&lt;/code&gt;, and &lt;code&gt;Serial3&lt;/code&gt; on Arduinos where they are present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;SoftwareSerial&lt;/code&gt;&lt;/a&gt; can be used to generate a UART signal on arbitrary pins in software, but you're almost always better off using a hardware UART when possible.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-29T06:17:40.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16397" PostTypeId="2" ParentId="16385" CreationDate="2015-09-29T06:57:46.463" Score="1" Body="&lt;p&gt;use the 'tone' function:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;arduino tone function&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//tone(pinNumber, FrequencyInHertz);&#xA;tone(6, 35000); //generate a 35kHz tone on pin 6&#xA;delay(10);&#xA;tone(6, 43000); //generate a 43kHz tone on pin 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7566" LastEditorUserId="7566" LastEditDate="2015-09-29T19:21:44.950" LastActivityDate="2015-09-29T19:21:44.950" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16398" PostTypeId="1" CreationDate="2015-09-29T07:20:00.603" Score="-3" ViewCount="1778" Body="&lt;p&gt;Please give me a code and diagram use makeblock i.r sensor V2.1 and makeblock remote. It should be connected to a d.c motor that works with a h-bridge.It also has to be a dual motor which combines these two codes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1:This one for the movement&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int controlPin1 = 2; // connected to pin 7 on the H-bridge&#xA;const int controlPin2 = 3; // connected to pin 2 on the H-bridge&#xA;const int enablePin = 9; // connected to pin 1 on the H-bridge&#xA;const int directionSwitchPin = 4; // connected to the switch for direction&#xA;const int onOffSwitchStateSwitchPin = 5; // connected to the switch for turning the motor on and off&#xA;const int potPin = A0; // connected to the potentiometer's output&#xA;&#xA;// create some variables to hold values from your inputs&#xA;int onOffSwitchState = 0; // current state of the On/Off switch&#xA;int previousOnOffSwitchState = 0; // previous position of the on/off switch&#xA;int directionSwitchState = 0; // current state of the direction switch&#xA;int previousDirectionSwitchState = 0; // previous state of the direction switch&#xA;&#xA;int motorEnabled = 0; // Turns the motor on/off&#xA;int motorSpeed = 0; // speed of the motor&#xA;int motorDirection = 1; // current direction of the motor&#xA;&#xA;void setup()&#xA;{&#xA;    // intialize the inputs and outputs&#xA;    pinMode(directionSwitchPin, INPUT);&#xA;    pinMode(onOffSwitchStateSwitchPin, INPUT);&#xA;    pinMode(controlPin1, OUTPUT);&#xA;    pinMode(controlPin2, OUTPUT);&#xA;    pinMode(enablePin, OUTPUT);&#xA;&#xA;    // pull the enable pin LOW to start&#xA;    digitalWrite(enablePin, LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // read the value of the on/off switch&#xA;    onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);&#xA;    delay(1);&#xA;&#xA;    // read the value of the direction switch&#xA;    directionSwitchState = digitalRead(directionSwitchPin);&#xA;&#xA;    // read the value of the pot and divide by 4 to get &#xA;    // a value that can be used for PWM&#xA;    motorSpeed = analogRead(potPin) / 4;&#xA;&#xA;    // if the on/off button changed state since the last loop()&#xA;    if (onOffSwitchState != previousOnOffSwitchState)&#xA;    {&#xA;        // change the value of motorEnabled if pressed&#xA;        if (onOffSwitchState == HIGH)&#xA;        {&#xA;            motorEnabled = !motorEnabled;&#xA;        }&#xA;    }&#xA;&#xA;    // if the direction button changed state since the last loop()&#xA;    if (directionSwitchState != previousDirectionSwitchState)&#xA;    {&#xA;        // change the value of motorDirection if pressed &#xA;        if (directionSwitchState == HIGH)&#xA;        {&#xA;            motorDirection = !motorDirection;&#xA;        }&#xA;    }&#xA;&#xA;    // change the direction the motor spins by talking&#xA;    // to the control pins on the H-Bridge&#xA;    if (motorDirection == 1)&#xA;    {&#xA;        digitalWrite(controlPin1, HIGH);&#xA;        digitalWrite(controlPin2, LOW);&#xA;    }&#xA;    else&#xA;    {&#xA;        digitalWrite(controlPin1, LOW);&#xA;        digitalWrite(controlPin2, HIGH);&#xA;    }&#xA;&#xA;    // if the motor is supposed to be on&#xA;    if (motorEnabled == 1)&#xA;    {&#xA;        // PWM the enable pin to vary the speed&#xA;        analogWrite(enablePin, motorSpeed);&#xA;    }&#xA;    else&#xA;    { // if the motor is not supposed to be on&#xA;        //turn the motor off&#xA;        analogWrite(enablePin, 0);&#xA;    }&#xA;    // save the current On/Offswitch state as the previous &#xA;    previousDirectionSwitchState = directionSwitchState;&#xA;    // save the current switch state as the previous&#xA;    previousOnOffSwitchState = onOffSwitchState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2: This one for the IR:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;IRremote.h&quot;  //-----( Import needed libraries )-----&#xA;int receiver = 11; // ----- DAT pin of IR receiver to Arduino digital pin 11&#xA;&#xA;/*-----( Declare objects )-----*/&#xA;IRrecv irrecv(receiver);           // create instance of 'irrecv'&#xA;decode_results results;            // create instance of 'decode_results'&#xA;&#xA;void setup()    /*----( SETUP: RUNS ONCE )----*/&#xA;{&#xA;    Serial.begin(9600);  // Begin serial communication&#xA;    Serial.println(&quot;IR Receiver Raw Data + Button Decode Test&quot;);&#xA;    irrecv.enableIRIn(); // Start the receiver&#xA;}               /*--(end setup )---*/&#xA;&#xA;&#xA;void loop()     /*----( LOOP: RUNS CONSTANTLY )----*/&#xA;{&#xA;    if (irrecv.decode(&amp;amp;results)) // have we received an IR signal?&#xA;    {&#xA;        //    Serial.println(results.value);  // Uncomment to print raw decimal values&#xA;        translateIR(); // run function &quot;translateIR&quot;&#xA;        irrecv.resume(); // receive the next value&#xA;    }&#xA;}               /* --(end main loop )-- */&#xA;&#xA;/*-----( Declare User-written Functions )-----*/&#xA;void translateIR()  // translate Makeblock remote raw values to keys&#xA;{&#xA;    switch (results.value)&#xA;    {&#xA;        case 4219133059:      Serial.println(&quot; A &quot;);     break;&#xA;        case 667718909:       Serial.println(&quot; B &quot;);     break;&#xA;        case 3478241646:      Serial.println(&quot; C &quot;);     break;&#xA;        case 1322193145:      Serial.println(&quot; D &quot;);     break;&#xA;        case 3689098103:      Serial.println(&quot; ^ &quot;);     break;&#xA;        // case 3478241646:      Serial.println(&quot; E &quot;);     break;&#xA;        case 1776008254:      Serial.println(&quot; &amp;lt; &quot;);     break;&#xA;        case 1803700378:      Serial.println(&quot; * &quot;);     break;&#xA;        case 3495019267:      Serial.println(&quot; &amp;gt; &quot;);     break;&#xA;        case 1943112141:      Serial.println(&quot; 0 &quot;);     break;&#xA;&#xA;        case 3444686410:      Serial.println(&quot; v &quot;);     break;&#xA;        case 2806989789:      Serial.println(&quot; F &quot;);     break;&#xA;        case 3689098101:      Serial.println(&quot; 1 &quot;);     break;&#xA;        // case 3689098103:      Serial.println(&quot; 2 &quot;);     break;&#xA;        case 1943112142:      Serial.println(&quot; 3 &quot;);     break;&#xA;        case 3689098102:      Serial.println(&quot; 4 &quot;);     break;&#xA;        // case 3689098102:      Serial.println(&quot; 5 &quot;);     break;&#xA;        case 2181502997:      Serial.println(&quot; 6 &quot;);     break;&#xA;        case 650941290:       Serial.println(&quot; 7 &quot;);     break;&#xA;        case 402038415:       Serial.println(&quot; 8 &quot;);     break;&#xA;        case 945450753:       Serial.println(&quot; 9 &quot;);     break;&#xA;        default:     Serial.println(&quot; other button   &quot;);&#xA;    }&#xA;&#xA;    delay(250);&#xA;} //END translateIR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13675" LastEditorUserId="10003" LastEditDate="2015-10-06T20:30:17.773" LastActivityDate="2015-10-06T20:30:17.773" Title="How do you make the arduino go forward,backward and stop using Infrared?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ClosedDate="2015-09-29T20:32:25.947" ContentLicense="CC BY-SA 3.0" />
  <row Id="16399" PostTypeId="2" ParentId="16385" CreationDate="2015-09-29T07:43:57.390" Score="3" Body="&lt;p&gt;The code below generates 38 kHz and modulates its duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example of modulating a 38 kHz frequency duty cycle by reading a potentiometer&#xA;// Author: Nick Gammon&#xA;// Date: 24 September 2012&#xA;&#xA;const byte POTENTIOMETER = A0;&#xA;const byte LED = 10;  // Timer 1 &quot;B&quot; output: OC1B&#xA;&#xA;// Clock frequency divided by 38 kHz frequency desired&#xA;const long timer1_OCR1A_Setting = F_CPU / 38000L;&#xA;&#xA;void setup() &#xA; {&#xA;  pinMode (LED, OUTPUT);&#xA;&#xA;  // set up Timer 1 - gives us 38.005 kHz &#xA;  // Fast PWM top at OCR1A&#xA;  TCCR1A = bit (WGM10) | bit (WGM11) | bit (COM1B1); // fast PWM, clear OC1B on compare&#xA;  TCCR1B = bit (WGM12) | bit (WGM13) | bit (CS10);   // fast PWM, no prescaler&#xA;  OCR1A =  timer1_OCR1A_Setting - 1;                 // zero relative  &#xA;  }  // end of setup&#xA;&#xA;void loop()&#xA;  {&#xA;  // alter Timer 1 duty cycle in accordance with pot reading&#xA;  OCR1B = (((long) (analogRead (POTENTIOMETER) + 1) * timer1_OCR1A_Setting) / 1024L) - 1;&#xA;&#xA;  // do other stuff here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-29T07:43:57.390" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16400" PostTypeId="1" AcceptedAnswerId="16405" CreationDate="2015-09-29T07:59:49.610" Score="1" ViewCount="410" Body="&lt;p&gt;I am trying to use external voltage reference in Intel Galileo gen 2 operating in Arduino mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I created a setup code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // We'll send debugging information via the Serial monitor&#xA;  Serial.begin(9600);   &#xA;&#xA;  // If you want to set the aref to something other than 5v&#xA;  analogReference(EXTERNAL); // use AREF for reference voltage&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I selected the board as Intel Galileo Gen 2 in Tools option. When I compiled I am getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LM35_temp_sensor.ino:21:19: error: 'EXTERNAL' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I change the board to Arduino Uno in Tools option, the program in compiling fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that Intel Galileo Gen 2 does not support external analog voltage reference?&lt;/p&gt;&#xA;" OwnerUserId="13676" LastActivityDate="2015-09-29T11:15:53.060" Title="Enternal Analog Reference mode not compiling in Arduino + Intel Galileo Gen 2" Tags="|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16402" PostTypeId="1" AcceptedAnswerId="16409" CreationDate="2015-09-29T09:00:36.320" Score="0" ViewCount="126" Body="&lt;p&gt;I want to controll some ambient lights in my living room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I got some 433mhz outlets which can be turned on or off with an remote, a 433mhz transmitter and receiver on the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino receives the remotes signals and knows which lamp has which state and will turn any lamp off at specific times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to turn on the lights automatically when I close the shutter, but I have no idea how I could do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A light sensor behind the window won't do the job. I don't want to turn on the lights when it get's dark, but when the shuhtter get's closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;What came to my mind first was an light sensor inside the window, facing outside, and a IR LED. I'd attach some tinfoil to the inside of the shutter to return the IR light, which the sensor will notice. But maybe the're are some simpler solutions? Also, the tinfoil would fall off quickly...&lt;/p&gt;&#xA;" OwnerUserId="4849" LastActivityDate="2015-09-29T14:53:13.133" Title="Detect closed shutter" Tags="|remote-control|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16403" PostTypeId="2" ParentId="815" CreationDate="2015-09-29T09:40:02.197" Score="3" Body="&lt;p&gt;Try something like &lt;a href=&quot;http://www.ebay.com/itm/1PCS-AC-DC-Isolated-Power-Supply-Module-220v-to-5v-Step-down-Power-module-/181777324025&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. It's 29x15mm and does 220V AC to 5V/3W DC.&lt;/p&gt;&#xA;" OwnerUserId="13677" LastActivityDate="2015-09-29T09:40:02.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16404" PostTypeId="1" CreationDate="2015-09-29T10:30:04.513" Score="2" ViewCount="997" Body="&lt;p&gt;So I decided it would be a good idea to flash a firmware onto my mega 2560 for a project. I ended up flashing the wrong side of the ICSP header (one near the usb plug/ M16U2) and killed my arduino for the most part. I'm a newb for the most part when it comes to this. I plug it in and the 'L' light is on with the 'ON' light as well. Wont show up in device manager, can't load sketches and can't get into DFU mode.(REV3 has DFU right?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have both a usbasp and USBtinyisp programmer and have tried 5 - 10 firmwares on both sides of the headers in hopes I can get it to work again.Literally almost tried everything I could find to get it to flash back. One guide I did find that got me somewhere was this though:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=96706.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=96706.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears to flash correctly with whatever firmware I use, but cannot pull the firmware off it to check or do the rest of what it says.My guess is that 1 or 2 of the firmware's are gone. Have erased the firmware/relfashed and tried to flash in the IDE with no luck in it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did use this command to read the firmware(or lack of) on both sides of the header to get a better idea of what might be going on:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.ca/3177996&quot; rel=&quot;nofollow noreferrer&quot;&gt;M16U2/M2560&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if I'm supposed to flash one side first then the other or flashing one will be able to do both at the same time. Here is an example of how I would flash from avrdude:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C avrdude.conf -P usb -p m16u2 -b 1200 -c usbasp flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With each side I would set the correct the fuses from what that file pulled up. So if anyone knows what I'm doing wrong for why it is not working I'd appreciate the help. Just don't know if I can save this or it's gonna end up in the garbage.Thanks&lt;/p&gt;&#xA;" OwnerUserId="13678" LastEditorUserId="42418" LastEditDate="2018-02-14T07:41:01.603" LastActivityDate="2018-02-14T07:41:01.603" Title="Any chance of repairing Mega 2560?" Tags="|arduino-mega|avrdude|programmer|firmware|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16405" PostTypeId="2" ParentId="16400" CreationDate="2015-09-29T11:15:53.060" Score="1" Body="&lt;p&gt;There is no such thing as an external analog reference on the Galileo.  If you look at the block diagram that is on the Galiley Arduino.cc page you can clearly see that the Aref pin goes nowhere:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lwFWt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lwFWt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, it won't support the EXTERNAL analog reference function.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-29T11:15:53.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16406" PostTypeId="1" CreationDate="2015-09-29T13:56:57.233" Score="-1" ViewCount="1178" Body="&lt;p&gt;i am a student from 2nd semester BCA (Bachelor in Computer Application). My group need some project for presentation from c programming language so i thought of using #ARDUINO project for our presentation . i really don't have any idea in this project so any ideas, answer, guides will be helpful to us.&lt;/p&gt;&#xA;" OwnerUserId="13681" LastActivityDate="2015-09-29T18:00:33.163" Title="arduino project for c programming language" Tags="|programming|arduino-mega|c|" AnswerCount="2" CommentCount="2" ClosedDate="2015-10-27T03:56:41.267" ContentLicense="CC BY-SA 3.0" />
  <row Id="16407" PostTypeId="2" ParentId="16406" CreationDate="2015-09-29T14:41:12.227" Score="0" Body="&lt;p&gt;I am not going to list example-projects as the possibilities with an arduino are endless. If you are looking for inspiration: take a look at websites like www.instructables.com and www.hackaday.io. Those are websites with mostly starter arduino projects that contain step-by-step guides on how they are created. I would suggest that you browse through those projects and look for something that peaks your interest and then think of your own similar project. You should however think of a project with a certain complexity as it is for your bachelor's. Most projects on instrucables lack the challenge. For getting parts: take a look at ebay. Ebay has some webshops that sell arduino's and arduino extension modules really cheap.&#xA;Good luck&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-09-29T14:41:12.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16408" PostTypeId="2" ParentId="16398" CreationDate="2015-09-29T14:48:01.777" Score="2" Body="&lt;p&gt;You should be able to search on Google and get a library to interface with the sensor.  Then you will need some motors, a motor controller, and a library to control that.  Then you will need to stick it all together using your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Search for your IR library and a tutorial.&lt;/li&gt;&#xA;&lt;li&gt;Search for a Stepper motor tutorial and library.&lt;/li&gt;&#xA;&lt;li&gt;Then post a question when you are stuck with that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-29T14:48:01.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16409" PostTypeId="2" ParentId="16402" CreationDate="2015-09-29T14:53:13.133" Score="1" Body="&lt;p&gt;I would go for a normally open read switch (should cost &gt;$0.1) and a magnet on the shutter (again should cost &gt;$0.1).  There are formulas to work out the distance that the reed switch will operate at, and it depends on the magnet, but the common ones are about 40mm.&#xA;(If you can wait 2 weeks for delivery you can get the parts off AliExpress.com)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-29T14:53:13.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16410" PostTypeId="2" ParentId="16380" CreationDate="2015-09-29T14:58:22.970" Score="0" Body="&lt;p&gt;I have been hooking the ESP8266 straight up to my PC and programming it in NodeLua.  Of course it depends on what you want to do, but consider dropping the Arduino and just using the ESP8266.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-29T14:58:22.970" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16411" PostTypeId="2" ParentId="16379" CreationDate="2015-09-29T15:06:45.253" Score="0" Body="&lt;p&gt;Your data comes back via the GPS's UART port.&lt;br&gt;&#xA;Use the softserial library to create a second serial port on your Arduino (means you can still use the normal serial to read the console).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then write a program that sucks data from the GPS and squirts it out of the Arduino serial port back to your PC using printf.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only had a quick flick through and didn't see the default serial speed, so start with 9600 and experiment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should come out is probably a line of comma separated values which is in NEMA format.  Google for the specification and you will be able to find out the bits of interest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-29T15:06:45.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16412" PostTypeId="2" ParentId="12256" CreationDate="2015-09-29T15:36:31.310" Score="1" Body="&lt;p&gt;It sounds like you need a debouncing circuit.&lt;br&gt;&#xA;You can do it in code, but you are then trying to execute more code in you interrupt handler.&#xA;I would go for a hardware version.  I don't have the circuit to hand but if you search for a 'Schmidtt Trigger' based debouncing circuit.  You can implement it with 5 resistors, a capacitor, a LM386 OpAmp and a CMOS XOR IC (Inverts the signal which the inverting Schmidtt trigger inverts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens is the Schmidtt trigger goes low when the input passes a certain voltage.  It remains low until the voltage passes the low voltage threshold at which point it goes high.  The CMOS XOR IC (I think its a 4004??) takes two inputs and inverts them.  It also adds extra hysteresis which further damps the bouncing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The values of your resistors affect the thresholds, but there are plenty of calculators on the web that will solve the values for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LM386 has two channels and the CMOS usually has 4 so it becomes quite easy to debounce multiple signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-29T15:36:31.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16413" PostTypeId="1" CreationDate="2015-09-29T17:25:45.530" Score="0" ViewCount="6943" Body="&lt;p&gt;Hi i am writing a code where, i have to switch a variable called toggle from 0 to 1 to 0.... every time the button is pressed (the button is on a 2 pin). I am a little lost as I am new to arduino need some help. Thank you&lt;/p&gt;&#xA;" OwnerUserId="13685" LastActivityDate="2019-10-02T05:25:10.403" Title="how to change variable when a button connected to pin 2 is pressed" Tags="|arduino-uno|serial|programming|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16414" PostTypeId="2" ParentId="16413" CreationDate="2015-09-29T17:40:25.913" Score="2" Body="&lt;p&gt;Go &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/HomePage&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; --&gt; Built-In Examples. Read the examples for Button, Debounce, and Digital Input Pullup. Digital Input Pullup is the best single one of those 3 I think, but read them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those 3 are key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I wrote a buttonReader (debouncing) library &lt;a href=&quot;http://www.electricrcaircraftguy.com/2014/05/ercaguybuttonreader-library-for-arduino.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sounds like you're a beginner, so check out Adafruit's tutorials &lt;a href=&quot;https://learn.adafruit.com/category/learn-arduino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And lastly, I've compiled links to all my knowledge at the bottom of my article &lt;a href=&quot;http://www.electricrcaircraftguy.com/2014/01/the-power-of-arduino.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7727" LastActivityDate="2015-09-29T17:40:25.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16415" PostTypeId="2" ParentId="16398" CreationDate="2015-09-29T17:52:02.580" Score="1" Body="&lt;p&gt;You need a good IR Library, or tons of low-level knowledge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ken Shirriff wrote the best IR library out there! &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow&quot;&gt;Here it is&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit writes awesome tutorials too. &lt;a href=&quot;https://learn.adafruit.com/using-an-infrared-library/hardware-needed&quot; rel=&quot;nofollow&quot;&gt;Here's one&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7727" LastActivityDate="2015-09-29T17:52:02.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16416" PostTypeId="2" ParentId="16406" CreationDate="2015-09-29T18:00:33.163" Score="2" Body="&lt;p&gt;Good luck with this! Arduino is awesome. I really enjoy using it. You may find this at least a little insightful: &lt;a href=&quot;http://www.electricrcaircraftguy.com/2014/01/the-power-of-arduino.html&quot; rel=&quot;nofollow&quot;&gt;http://www.electricrcaircraftguy.com/2014/01/the-power-of-arduino.html&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is a small computer. It can do essentially whatever you want it to do: drive robots, fly airplanes, control motors, turn on or off TVs, get on the internet, make a home alarm, buzz a speaker, make a touch lamp, fade LEDs, play music (even with &lt;em&gt;no&lt;/em&gt; music chip; just using a skillfully-written library), control HollyWood action cameras, talk to your smartphone, read your heartbeat, make a bike speedometer or odometer, read a GPS receiver, etc. Cool stuff!&lt;/p&gt;&#xA;" OwnerUserId="7727" LastActivityDate="2015-09-29T18:00:33.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16417" PostTypeId="2" ParentId="8129" CreationDate="2015-09-29T18:39:37.593" Score="1" Body="&lt;p&gt;I had the same problem. My solution is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First make &lt;code&gt;.stopListening()&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;then &lt;code&gt;.write(&amp;amp;data, sizeof(data))&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and behind the &lt;code&gt;write&lt;/code&gt; command an &lt;code&gt;.startListening()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can delay for longer times.&lt;/p&gt;&#xA;" OwnerUserId="13686" LastEditorUserId="6936" LastEditDate="2015-10-22T21:04:22.980" LastActivityDate="2015-10-22T21:04:22.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16419" PostTypeId="2" ParentId="16404" CreationDate="2015-09-29T21:02:11.883" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://altlab.org/d/m/jpralves/recover_atmega2560/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://altlab.org/d/m/jpralves/recover_atmega2560/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change fuses/firmware depending on which side you are flashing (M2560/M16U2)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firmwares: Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex / stk500boot_v2_mega2560.hex&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1st command: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C avrdude.conf -P usb -p m16U2 -b 57600 -c usbtiny -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2nd command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c usbtiny -p m16U2 -P usb -b 115200 -V -U flash:w:Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3rd command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c usbtiny -p m16U2 -P usb -b 115200 -U lock:w:0x0F:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.ca/3178420&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://pastebin.ca/3178420&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13678" LastEditorUserId="42418" LastEditDate="2018-02-14T07:40:37.997" LastActivityDate="2018-02-14T07:40:37.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16420" PostTypeId="2" ParentId="16365" CreationDate="2015-09-29T21:40:29.903" Score="4" Body="&lt;p&gt;Shown below is a KY-040 test program that in my tests doesn't lose any counts and is more accurate than some other software; it picks up the counts between detents as well as those at detents.  You may be able to adapt it to your DigiKeyboard ATtiny system.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  roto_jw4.ino -- JW, 29 September 2015 -- &#xA; *  A 4-state state-machine implementation of rotary&#xA; *  encoding for KY-040 rotary knobs.  The state-machine picture at&#xA; *  https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/318762&#xA; *  in a Feb 4, 2014 7:40 PM post by Anthony Seely shows counts&#xA; *  increasing on transitions 10 -&amp;gt; 11 -&amp;gt; 01 -&amp;gt; 00 -&amp;gt; 10 and&#xA; *  decreasing on transitions the other way.  Transitions between 00&#xA; *  and 11 or 10 and 01 are invalid.  This code detects valid&#xA; *  transitions by (abOld xor abNew) equaling 1 or 2.  It detects&#xA; *  up-count events by the tri-bit value ABA' (where A' is the new&#xA; *  reading on pin A) being equal to 1, 2, 5, or 6 (a bit mask of&#xA; *  0x66), and down-count events by ABA' being equal to 0, 3, 4, or 7&#xA; *  (a bit mask of 0x99).&#xA; *&#xA; *  On a KY-040 unit I tested, there are 30 detent positions per turn.&#xA; *  With this unit the code generates 60 counts per turn, which can be&#xA; *  seen individually as one turns the rotor slowly.  Odd counts&#xA; *  appear between detents, even counts at detents.&#xA; *&#xA; *  Set quadrature-signal pin numbers, via PinA and PinB constants.&#xA; *  Set IPINMODE to INPUT_PULLUP if there are no external pull-ups&#xA; *  on encoder AB pins, else set IPINMODE to INPUT&#xA; */&#xA;enum { PinA=2, PinB=3, IPINMODE=INPUT };&#xA;&#xA;static  byte abOld;     // Initialize state&#xA;volatile int count;     // current rotary count&#xA;         int old_count;     // old rotary count&#xA;&#xA;void setup() {&#xA;  pinMode(PinA, IPINMODE);&#xA;  pinMode(PinB, IPINMODE);&#xA;  attachInterrupt(0, pinChangeISR, CHANGE); // Set up pin-change interrupts&#xA;  attachInterrupt(1, pinChangeISR, CHANGE);&#xA;  abOld = count = old_count = 0;&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting Rotary Encoder Test&quot;);&#xA;}&#xA;&#xA;// On interrupt, read input pins, compute new state, and adjust count&#xA;void pinChangeISR() {&#xA;  enum { upMask = 0x66, downMask = 0x99 };&#xA;  byte abNew = (digitalRead(PinA) &amp;lt;&amp;lt; 1) | digitalRead(PinB);&#xA;  byte criterion = abNew^abOld;&#xA;  if (criterion==1 || criterion==2) {&#xA;    if (upMask &amp;amp; (1 &amp;lt;&amp;lt; (2*abOld + abNew/2)))&#xA;      count++;&#xA;    else count--;       // upMask = ~downMask&#xA;  }&#xA;  abOld = abNew;        // Save new state&#xA;}&#xA;&#xA;void loop() {&#xA;  if (old_count != count) {&#xA;    Serial.print(millis());&#xA;    Serial.print(&quot;  &quot;);&#xA;    Serial.println(count);&#xA;    old_count = count;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since some ATtiny's only have one external-interrupt pin, it may be necessary to use two pin-change interrupts instead of two external-interrupt pins.&#xA;(Six of the pins on an ATtiny45, for example, support pin-change interrupts, and only one is an external-interrupt pin.) Change PinA and PinB to appropriate pin numbers, and replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  attachInterrupt(0, pinChangeISR, CHANGE); // Set up pin-change interrupts&#xA;  attachInterrupt(1, pinChangeISR, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  enableInterrupt(PinA, pinChangeISR, CHANGE); // Set up pin-change interrupts&#xA;  enableInterrupt(PinB, pinChangeISR, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and add the following &lt;code&gt;#include&lt;/code&gt; near the beginning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EnableInterrupt.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To install the .h file for use via the Arduino IDE, unpack an &lt;code&gt;EnableInterrupt&lt;/code&gt; zip file (for example, &lt;code&gt;enableinterrupt-0.8.2.zip&lt;/code&gt; from &lt;a href=&quot;https://bintray.com/greygnome/generic/EnableInterrupt/view#files&quot; rel=&quot;nofollow&quot;&gt;bintray.com/greygnome&lt;/a&gt;) in the directory &lt;code&gt;~/sketchbook/libraries&lt;/code&gt;.  I think the package works with ATtiny's as well as more-standard Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-09-30T19:45:45.160" LastActivityDate="2015-09-30T19:45:45.160" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16421" PostTypeId="2" ParentId="16413" CreationDate="2015-09-29T21:44:20.423" Score="2" Body="&lt;p&gt;What you need is to detect a &lt;em&gt;transition&lt;/em&gt;. That is, either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It was closed and is now open.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It was open and is now closed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do that you need to &quot;remember&quot; the previous state of the switch and detect a change, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte switchPin = 8;&#xA;byte oldSwitchState = HIGH;  // assume switch open because of pull-up resistor&#xA;bool toggle;&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (switchPin, INPUT_PULLUP);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // see if switch is open or closed&#xA;  byte switchState = digitalRead (switchPin);&#xA;&#xA;  // has it changed since last time?&#xA;  if (switchState != oldSwitchState)&#xA;    {&#xA;    oldSwitchState =  switchState;  // remember for next time &#xA;    toggle = !toggle;   // toggle the variable&#xA;    delay (10);         // debounce&#xA;    }  // end of state change&#xA;&#xA;  // other code here ...&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more information see my post about &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;switches&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-29T21:44:20.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16422" PostTypeId="1" AcceptedAnswerId="16431" CreationDate="2015-09-30T01:09:28.530" Score="0" ViewCount="1766" Body="&lt;p&gt;Is there any compact piston-like devices on the market that can apply pressure safely various parts of the head? I can further expound if needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal size would be something within the 1-2 inch length range  &lt;/p&gt;&#xA;" OwnerUserId="13691" LastActivityDate="2015-09-30T12:30:01.470" Title="Arduino &quot;piston&quot; device" Tags="|project|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16423" PostTypeId="2" ParentId="12133" CreationDate="2015-09-30T07:11:31.323" Score="5" Body="&lt;p&gt;This site fixed the problem for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;noreferrer&quot;&gt;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...somebody else has made an alternative to the ftdi drivers, and this website show you how to install them correctly.&lt;/p&gt;&#xA;" OwnerUserId="13695" LastActivityDate="2015-09-30T07:11:31.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16424" PostTypeId="1" CreationDate="2015-09-30T07:23:25.733" Score="2" ViewCount="472" Body="&lt;p&gt;According to the Atmega328P-PU Datasheet (side: 589) the current consumption of the microcontroller should be around 9.5mA (at 16MHz and 5V).&lt;br&gt;&#xA;But I measured 15mA. (Nick Gammon who did some pretty good power saving research(gammon.com.au/power) got the same)&lt;br&gt;&#xA;There is nothing connected to the outputs. The code I ran was this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;void setup () {}&lt;br&gt;&#xA;   void loop () {}&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now I'm wondering if this is just a normal deviation (datasheet to real world) or if Atmel measured their current consumption in a state that is different from mine?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I forgot to mention.. I didn't use it with the Arduino Uno board but as standalone device. There was only a 16Mhz oscillator with two capacitors connected. Power came directly form Power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that I think about it..  Datasheet says this regarding the current measurement: &quot;A sine wave generator with rail-to-rail output is used as clock source.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible that the oscillator needs that extra 5mA?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of my schematic:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GZBCx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GZBCx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a screenshot of the ATmega328P-PU Datasheet:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ae11H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ae11H.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13696" LastEditorUserId="13696" LastEditDate="2015-09-30T14:02:34.010" LastActivityDate="2015-09-30T21:47:19.360" Title="Deviation of power consumption between datasheet and real world?" Tags="|power|current|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16425" PostTypeId="2" ParentId="3042" CreationDate="2015-09-30T07:27:59.650" Score="2" Body="&lt;p&gt;I went through this problem recently. Your slave needs two functions: one for sending and the other for receiving data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// function: what to do when asked for data&#xA;void requestEvent() {&#xA;Wire.write(t); &#xA;}&#xA;&#xA;// what to do when receiving data from master&#xA;void receiveEvent(int howMany)&#xA;{Val = Wire.read();}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a code that works both ways of i2c communication in a single code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/16292/sending-and-receiving-different-types-of-data-via-i2c-in-arduino&quot;&gt;Sending and receiving different types of data via I2C in Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11802" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-09-30T07:34:08.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16426" PostTypeId="2" ParentId="1595" CreationDate="2015-09-30T07:48:41.723" Score="0" Body="&lt;p&gt;The arduino has its on voltage regulator, so feeing 9v to the arduino is not a problem. But the arduino will not drive the motor directly. You need to use a transistor big enough  to  hundle the amperage of your motor (e.g.tip120). The diagram above is a good indication of how to connect it. Yet the diagram is missing a diode (1n4001 or 1n4004) from the GnD to Vcc, as to avoid back voltage from the motor, which may damage your arduino.&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2015-09-30T07:48:41.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16427" PostTypeId="2" ParentId="16424" CreationDate="2015-09-30T08:31:30.710" Score="0" Body="&lt;p&gt;Probably Atmel measured the chip consumption without any code. An empty sketch has some code in it (believe it or not).&#xA;Another possibility is the remaining components like voltage regulator, usb chip are also consuming some current.&#xA;Try to test in a bare minimum configuration.&lt;/p&gt;&#xA;" OwnerUserId="4971" LastEditorUserId="4971" LastEditDate="2015-09-30T08:38:46.070" LastActivityDate="2015-09-30T08:38:46.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16429" PostTypeId="1" CreationDate="2015-09-30T10:50:57.170" Score="0" ViewCount="1510" Body="&lt;p&gt;Is it possible to capture good sound with Aduino? I need to record street / birds / nature sounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/a/701/6841&quot;&gt;As I found&lt;/a&gt;, maximal sample rate, achievable with built-in ADC is 9kHz, which is to low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I require to use some external hardware. But wave shields I saw are to expensive (comparable by price with Arduino itself), probably, because of excess functions (including not only ADC but also DAC and so on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simultaneously, there are ICs, providing ADC functionality and even MP3 encoding functionality for relatively low price. But here a schematic design required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how to find appropriate solution here?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-21T18:02:46.363" Title="How to capture good sound with Arduino?" Tags="|sound|adc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16431" PostTypeId="2" ParentId="16422" CreationDate="2015-09-30T12:30:01.470" Score="1" Body="&lt;p&gt;It sounds like this is nothing to do with an Arduino, just a general Electrical/Mechanical engineering question that you want to control from and Arduino. &#xA;I think you wan a device that when signalled by your Arduino can extend itself by up to 2 inches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is right then I think what you are looking for is a Linear Actuator.  There are plenty out there and some do handle the small stroke you want, but most of them appear to be 9 to 12V.  This means you would require a Darlington transistor or relay to control them from an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you require an extremely precise stoke length then I would recommend a stepper motor with a screw axel.  This would allow you much finer control over how far you pushed, but it would impose limits on what you could do and how it could be mounted.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can you provide more details on what you want to move?   &lt;/li&gt;&#xA;&lt;li&gt;List item&lt;/li&gt;&#xA;&lt;li&gt;Is it heavy? Do you need lots of Torque?&lt;/li&gt;&#xA;&lt;li&gt;Are you pushing straight or do you need to push in an arc (i.e. a door)?  &lt;/li&gt;&#xA;&lt;li&gt;What voltage supplies do you have available? &lt;/li&gt;&#xA;&lt;li&gt;How fast do you want it to move? &lt;/li&gt;&#xA;&lt;li&gt;Do you want it to move exactly the same distance every time?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The more info you can provide the better, but in answer to your original question Yes, it sounds like there might be so you plan is still on the rails.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-30T12:30:01.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16432" PostTypeId="2" ParentId="3382" CreationDate="2015-09-30T12:36:29.737" Score="2" Body="&lt;p&gt;Am I missing the point here or wouldn't the C# just have to open a Serial connection to the board and read and write to that to control the program running on the Arduino?&#xA;Yes the board is connected by USB, but that's only so it can open a serial connection.&#xA;To be honest I don't think you will be able to sample at that speed, you might be better looking at ICs that directly interface with GPIO and RS232/USB.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-09-30T12:36:29.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16433" PostTypeId="1" CreationDate="2015-09-30T16:45:55.897" Score="0" ViewCount="312" Body="&lt;p&gt;What is the use of noTone() function as the duration for which the note must be played can be specified using the third argument of note() function.&lt;/p&gt;&#xA;" OwnerUserId="13703" LastActivityDate="2015-09-30T16:57:13.803" Title="actual use of noTone() in arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16434" PostTypeId="2" ParentId="16433" CreationDate="2015-09-30T16:57:13.803" Score="2" Body="&lt;p&gt;So that you can terminate the output prematurely, e.g. during an interrupt.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-09-30T16:57:13.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16435" PostTypeId="1" AcceptedAnswerId="16446" CreationDate="2015-09-30T17:01:15.073" Score="1" ViewCount="849" Body="&lt;p&gt;I have a program where the Arduino receives hex Strings that represent a RGBW color (similar to css for example). My goal is to create that color by using pwm, so I need to convert that one hex string into four integer values between 0..255 to use for the pwm.&#xA;Whats the best/easiest way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void incomingMessage(const MyMessage &amp;amp;message) {&#xA;&#xA;    // h = hex value&#xA;    // message = e.g. (h) #112233AB&#xA;    redval = ?; // h11 =&amp;gt; 17&#xA;    greenval = ?; // h22 =&amp;gt; 34&#xA;    blueval = ?; // h33 = 51&#xA;    whiteval = ?; //AB = 171&#xA;&#xA;    analogWrite(RED_PIN, redval);     &#xA;    analogWrite(GREEN_PIN, greenval);&#xA;    analogWrite(BLUE_PIN, blueval);&#xA;    analogWrite(WHITE_PIN, whiteval);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13704" LastActivityDate="2015-10-31T00:15:17.647" Title="Split RGBW hex String into integers" Tags="|c++|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16436" PostTypeId="2" ParentId="16435" CreationDate="2015-09-30T17:31:27.897" Score="0" Body="&lt;p&gt;So you basically want to convert a pair of hexadecimal digits into a numeric value.  You also want to extract those values from a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter can be done using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringCharAt&quot; rel=&quot;nofollow&quot;&gt;String.charAt()&lt;/a&gt; method.  That allows you to extract individual characters from your string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to convert those into a number.  There's a number of ways that could be done.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;strtol()&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The strtol() function takes three parameters - the first is a C string (NULL-terminated char array) which contains the number you want to convert, the second you can ignore, and the third is the &lt;em&gt;base&lt;/em&gt; to convert from.  So you could use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp[3] = { char1, char2, NULL };&#xA;int val = strtol(temp, NULL, 16);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Discrete functions&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It's simple enough to write a function that converts a single hex digit into a value 0-15:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char h2d(unsigned char hex)&#xA;{&#xA;    if(hex &amp;gt; 0x39) hex -= 7; // adjust for hex letters upper or lower case&#xA;    return(hex &amp;amp; 0xf);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's then simple enough to use that to make a function that takes two hex digits and converts them into a number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char h2d2(unsigned char h1, unsigned char h2)&#xA;{&#xA;    return (h2d(h1)&amp;lt;&amp;lt;4) | h2d(h2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's as many ways of doing it as there are of skinning a cat (as the saying goes).  Every way has benefits and drawbacks though.  Of the two I have shown, to compare them:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first is &quot;safer&quot; as it has more error checking and can cope with other things besides hex values&lt;/li&gt;&#xA;&lt;li&gt;The second results in much smaller code but results with values other than hex digits are undefined.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-09-30T17:31:27.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16438" PostTypeId="1" AcceptedAnswerId="16439" CreationDate="2015-09-30T19:59:12.673" Score="0" ViewCount="4738" Body="&lt;p&gt;I have an Arduino (Arduino A) hooked up to an external FRAM chip and I want to be able to pull the Arduino A's reset pin to ground to keep it in a constant reset state. Then I want to hook up another Arduino (Arduino B) up to the same lines going from Arduino A to the external FRAM chip and pull data off of the FRAM chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am worried that when I hook Arduino B to the lines running between the FRAM and Arduino A that it will damage Arduino A. If the digital pins are in a high impedance state while I do this though, then it should be fine. I can't find the necessary documentation to figure this out though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All Arduinos involved are Uno Rev 3s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated, thanks!&lt;/p&gt;&#xA;" OwnerUserId="13452" LastActivityDate="2015-10-01T13:13:14.890" Title="When the Arduino is in reset mode are the digital pins high impedance?" Tags="|arduino-uno|pins|reset|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16439" PostTypeId="2" ParentId="16438" CreationDate="2015-09-30T21:03:37.640" Score="1" Body="&lt;p&gt;From the ATMEGAxx8 datasheet...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;11.1 Resetting the AVR&lt;/p&gt;&#xA;&lt;p&gt;... The I/O ports of the AVR are &lt;strong&gt;immediately&lt;/strong&gt; reset to their initial state&#xA;when a reset source goes active. This does not require any clock&#xA;source to be running.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(bold added)&lt;/p&gt;&#xA;&lt;p&gt;Looking over the register descriptions for the Data Direction Registers, all bits have an initial value of &lt;code&gt;0&lt;/code&gt;, corresponding to high impedance input.&lt;/p&gt;&#xA;&lt;p&gt;...so it is safe to assume that all IO pins will be in a high impedance state a very short time after the &lt;code&gt;RESET&lt;/code&gt; pin goes low.&lt;/p&gt;&#xA;&lt;p&gt;Caveats:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The clamping diodes are in-circuit even when pins are in high impedance state, so current will flow if the voltage on the pin is higher than Vcc or lower than Ground (at least until the diode blows up!).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Some Arduino pins are connected to other things besides just the pin on the MPU. For example, digital pin 13 is connected to ground though a resistor and diode, so current will flow into it if you connect a voltage higher than the threshold for the diode. On the Uno there are also resistors on the RX and TX pins connected to the serial communications link, so current can flow there too.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The MISO pin can inadvertently become an output while &lt;code&gt;RESET&lt;/code&gt; is held low if the Programming Enable command ($AC $53 xx yy) is transmitted over the MOSI &amp;amp; SCK lines. This process is described in &lt;a href=&quot;http://www.atmel.com/images/doc0943.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;App Note AVR910&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-10-01T13:13:14.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16440" PostTypeId="1" CreationDate="2015-09-30T21:08:21.527" Score="2" ViewCount="4023" Body="&lt;p&gt;I have about 10 Arduinos that have sensors attached, which report information back around my house. I would like to have a RPi 2, because they have nice screen and GUI options, to collect the information and display it accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for success stories on what wireless parts you used to get these two working. The the wireless must be able to penetrate a brick wall about 120ft away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for replying, I edited the response above.&lt;/p&gt;&#xA;" OwnerUserId="13709" LastEditorUserId="4628" LastEditDate="2015-12-06T12:14:01.580" LastActivityDate="2016-09-27T20:07:18.667" Title="Wireless Communication Between Raspberry Pi 2 and multiple Arduinos" Tags="|wireless|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16441" PostTypeId="1" AcceptedAnswerId="16462" CreationDate="2015-09-30T21:46:50.517" Score="0" ViewCount="157" Body="&lt;p&gt;I am compiling the sketch found &lt;a href=&quot;https://github.com/huytd/arduino-flappybird&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. I just downloaded the .ino and .h files and opened them, so I have not modded the code at all. I keep getting the following error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from flappyDuino.ino:7:0:&#xA;Sprite.h:3: error: variable 'flappybird_frame_1' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA; static unsigned char PROGMEM flappybird_frame_1[] = { 0x03, 0xF0, 0x0C, 0x48, 0x10, 0x84, 0x78, 0x8A, 0x84, 0x8A, 0x82, 0x42, 0x82, 0x3E, 0x44, 0x41,0x38, 0xBE, 0x20, 0x41, 0x18, 0x3E, 0x07, 0xC0 };&#xA;&#xA;                                                 ^&#xA;In file included from flappyDuino.ino:7:0:&#xA;Sprite.h:4: error: variable 'flappybird_frame_2' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA; static unsigned char PROGMEM flappybird_frame_2[] = { 0x03, 0xF0, 0x0C, 0x48, 0x10, 0x84, 0x20, 0x8A, 0x40, 0x8A, 0x40, 0x42, 0x7C, 0x3E, 0x82, 0x41, 0x84, 0xBE, 0x88, 0x41, 0x78, 0x3E, 0x07, 0xC0 };&#xA;&#xA;                                                 ^&#xA;Sprite.h:5: error: variable 'bar_bottom' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA; static unsigned char PROGMEM bar_bottom[] = { 0xFF, 0xFF, 0xFF, 0x42, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E };&#xA;&#xA;                                         ^&#xA;Sprite.h:6: error: variable 'bar_top' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA; static unsigned char PROGMEM bar_top[] = { 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x42, 0xFF, 0xFF, 0xFF };&#xA;&#xA;                                      ^&#xA;variable 'flappybird_frame_1' must be const in order to be put into read-only section by means of '__attribute__((progmem))'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any help. &lt;/p&gt;&#xA;" OwnerUserId="7061" LastEditorUserId="10794" LastEditDate="2015-10-01T06:43:14.373" LastActivityDate="2015-10-01T18:06:58.940" Title="Help with Flappy Bird Sketch" Tags="|arduino-uno|programming|c++|sketch|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16442" PostTypeId="2" ParentId="16424" CreationDate="2015-09-30T21:47:19.360" Score="1" Body="&#xA;&#xA;&lt;p&gt;According to the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;All current consumption measurements are performed with all I/O pins configured as inputs and with internal pull-ups enabled.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That was the critical point. Trying this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  for (int i = 0; i &amp;lt; 20; i++)&#xA;    pinMode (i, INPUT_PULLUP);&#xA;  }  // end of setup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that timers are not running (your sketch would have timer 0 running):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that sketch, even using the crystal and capacitors (I actually had a resonator) the consumption at 5 V at around 20 °C was 9.2 mA which is within spec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fuses:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Signature = 0x1E 0x95 0x0F &#xA;Processor = ATmega328P&#xA;Flash memory size = 32768 bytes.&#xA;LFuse = 0xFF &#xA;HFuse = 0xDF &#xA;EFuse = 0xFF &#xA;Lock byte = 0xFF &#xA;Clock calibration = 0x96 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;If we turn pull-ups off:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  }  // end of setup&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it consumes 14.4 mA, closer to what you measured.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And with your actual test sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup () {}&#xA;void loop () {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It consumes 15.5 mA, which is more, because Timer 0 is running (started in the &lt;code&gt;init&lt;/code&gt; function). It is also close to what I had on my &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;page about power&lt;/a&gt; - 15.15 mA.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, working as expected. Those pull-ups are important, to stop the input drivers consuming current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did mention further down in my page the importance of configuring the pins:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Testing in SLEEP_MODE_PWR_DOWN:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;strong&gt;All pins as outputs&lt;/strong&gt;, and LOW: 0.35 µA (same as before).&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;strong&gt;All pins as outputs&lt;/strong&gt;, and HIGH: 1.86 µA.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;strong&gt;All pins as inputs, and LOW&lt;/strong&gt; (in other words, internal pull-ups disabled): 0.35 µA (same as before).&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;&lt;strong&gt;All pins as inputs, and HIGH&lt;/strong&gt; (in other words, internal pull-ups enabled): 1.25 µA.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Notice the difference there of 0.9 µA when asleep. It would appear that there is an ever greater difference if the processor is awake.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-30T21:47:19.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16443" PostTypeId="2" ParentId="16440" CreationDate="2015-09-30T22:16:48.117" Score="2" Body="&lt;p&gt;There's many options you could use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest, though most expensive, would be to equip all your Arduinos with WiFi shields and connect a USB WiFi dongle to the Pi.  The Pi could run in AP mode (investigate &lt;a href=&quot;http://google.com/?q=hostapd+raspberry+pi&quot; rel=&quot;nofollow&quot;&gt;hostapd&lt;/a&gt;) so you don't have to connect them all to your internet router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A cheaper option, though harder to work with on the Pi, would be to use the incredibly cheap but popular &lt;a href=&quot;http://google.com/?q=nrf24l01+&quot; rel=&quot;nofollow&quot;&gt;nRF24L01+&lt;/a&gt; modules.  There are libraries aplenty for the Arduino, but I am not aware of code for the Pi (though there probably is somewhere if you google for it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there are options in between which vary in price and complexity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you haven't mentioned range, only a brick wall.  The right choice could well be affected by the range of communication you need - do you go for the bare nRF28L01+ with a range of maybe 10m, or the one with the power amplifier and SMA antenna with a range of many hundreds of meters? Is WiFi going to be long enough range? Would a 433mHz module be a better choice?  All these questions and more need to be answered, and the best way is for you to describe your setup in detail, including what the longest range is you need to deal with, what amount of data you will be sending, do you need ultra low power to save batteries, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-02T21:10:06.390" LastActivityDate="2015-11-02T21:10:06.390" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16445" PostTypeId="1" CreationDate="2015-09-30T23:01:24.767" Score="1" ViewCount="745" Body="&lt;p&gt;My arduino robot has two dc motors as two wheels and have mounted an IR led on it. I get current position of the robot as (x,y) coordinates in the arena using camera which is mounted at the top of the arena.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My robot communicates with PC through bluetooth. I can read current position of robot on pc with the help of camera. Robot uses arduino motor shield to drive DC motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the best method to move robot through the waypoints for a robot with DC motors without encoders?&lt;/p&gt;&#xA;" OwnerUserId="13710" LastActivityDate="2015-10-02T01:11:08.097" Title="Move robot through the waypoints" Tags="|arduino-mega|arduino-motor-shield|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16446" PostTypeId="2" ParentId="16435" CreationDate="2015-09-30T23:34:15.977" Score="1" Body="&lt;p&gt;I don't like using the String class because it can cause memory fragmentation. This would do it by just using C-style strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte fromhex (const char * str)&#xA;  {&#xA;  char c = str [0] - '0';&#xA;  if (c &amp;gt; 9)&#xA;    c -= 7;&#xA;  int result = c;&#xA;  c = str [1] - '0';&#xA;  if (c &amp;gt; 9)&#xA;    c -= 7;&#xA;  return (result &amp;lt;&amp;lt; 4) | c;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  const char * test = &quot;#112233AB&quot;;&#xA;&#xA;  byte redval   = fromhex (&amp;amp; test [1]);&#xA;  byte greenval = fromhex (&amp;amp; test [3]);&#xA;  byte blueval  = fromhex (&amp;amp; test [5]);&#xA;  byte whiteval = fromhex (&amp;amp; test [7]);&#xA;&#xA;  Serial.println ((int) redval);&#xA;  Serial.println ((int) greenval);&#xA;  Serial.println ((int) blueval);&#xA;  Serial.println ((int) whiteval);&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever   &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;17&#xA;34&#xA;51&#xA;171&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does not do any validation (that the string is indeed 9 characters long, and contain hex characters) but I'll leave that for you to do. :)&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-09-30T23:34:15.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16447" PostTypeId="1" AcceptedAnswerId="16452" CreationDate="2015-09-30T23:43:06.320" Score="0" ViewCount="228" Body="&lt;p&gt;I am looking for a large ePaper Display for the Arduino. The issue is is that I cannot seem to find one any larger than 4.5 inches in size. That will be compatible with arduino. Even with a controller board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any companies that sell controller boards for these displays? Is there anyone who can manufacture these epd displays upon request?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to take this project to a pcb board after I prototype it so do I need to build my own controller? If what parts would you need? Is it easy for a designer with intermediate capability? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can find all kinds of display like at &lt;a href=&quot;http://www.pervasivedisplays.com/&quot; rel=&quot;nofollow&quot;&gt;pervasivedisplays.com&lt;/a&gt; and &lt;a href=&quot;http://mouser.com&quot; rel=&quot;nofollow&quot;&gt;Mouser.com&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end goal is to create a Arduino based project that I can score skeet with to keep track of my average score. &lt;/p&gt;&#xA;" OwnerUserId="8167" LastActivityDate="2015-11-30T14:17:19.177" Title="Are there any ePaper modules that are bigger than 2.7 inches for arduino" Tags="|arduino-mega|display|components|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16449" PostTypeId="2" ParentId="16445" CreationDate="2015-10-01T09:59:54.433" Score="2" Body="&lt;p&gt;With the arrangement you have described I would say it's very very hard to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You know where the robot is&lt;/li&gt;&#xA;&lt;li&gt;You know where the robot has to get to&lt;/li&gt;&#xA;&lt;li&gt;You can easily calculate the direction the robot has to go in (simple trigonometry from school)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't know what direction the robot is facing, so you don't know how to turn the robot to get it to drive in the direction you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So either you need some kind of &lt;em&gt;calibration&lt;/em&gt; procedure whereby the computer moves the robot in different directions and watches what the IR LED does to determine what direction the robot is facing so it can move it to face the right way (tricky to do, and rather messy), or some way for the computer to visually calculate the direction of the robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter is probably the easiest.  Instead of just one IR LED on the top of the robot you would need an array of IR LEDs on top of the robot forming a shape.  What that shape is can be up to you, but there is one big constraint: &lt;em&gt;It must have a clear direction to it&lt;/em&gt; (i.e., it must have &lt;em&gt;no rotational symmetry&lt;/em&gt;.  Triangles are good since they only need 3 LEDs.  An equilateral triangle though wouldn't work since in three different rotations it would look the same.  However, a single LED at the front of the robot, with two LEDs at the back of the robot, with the two back LEDs closer together than the distance from the front to the back, would not have any rotational symmetry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could then, (theoretically, assuming you have control over the camera software), get the three points from the play area and calculate the direction the robot is facing (tangent from mid-way between the two close points passing through the distant point) so you can then calculate the angle the robot would need to turn through so it is facing the direction you need it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember in math class, doing trigonometry (sin, cos, tan, pythagoras, etc) thinking &quot;Why the hell do we need to know this stuff?!&quot;, well, now you know.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-01T09:59:54.433" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16450" PostTypeId="1" AcceptedAnswerId="16454" CreationDate="2015-10-01T10:42:19.457" Score="1" ViewCount="1216" Body="&lt;p&gt;I have found a relatively small 12V switching power supply that I want to build into my device, using it to power both the Arduino Pro Mini and a couple of 12V cpu fans.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct in assuming that I can have the Arduino RAW pin and Fan+ on the same power supply lead? Or do I need to protect the Raw pin in any way? Also, I need to power 2x cpu fans, can this be done with one transistor or do I need one for each fan?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I stay within the Current specs of my supply (6A) could I keep adding other 12V components on the same +lead as in the diagram below?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/st4Or.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/st4Or.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13718" LastEditorUserId="10794" LastEditDate="2015-10-02T05:42:44.510" LastActivityDate="2021-11-11T08:51:38.303" Title="Powering arduino and 12V Fan from same supply" Tags="|power|hardware|arduino-pro-mini|system-design|electricity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16451" PostTypeId="2" ParentId="16450" CreationDate="2015-10-01T11:01:07.153" Score="1" Body="&lt;p&gt;The board will take 12V, but the regulator will have to dissipate (as in heat) the excess power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how much do you trust your power supply to not exceed the 12V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same applies to the other loads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About max current, you should do the math for both typical case and peak case. Ex: the fan will draw much more current if for any reason it is stopped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use only 1 transistor, you will get both fans to behave in the same way, because you will be using only 1 control line. Is this what you want?&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-01T11:01:07.153" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16452" PostTypeId="2" ParentId="16447" CreationDate="2015-10-01T12:20:49.177" Score="1" Body="&lt;p&gt;I would suggest you to start the other way: find a sw stack that is known to work and check if any of the controllers/displays it already supports fits your needs. This is how I would do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ugfx.org/platforms&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a starting point.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-01T12:20:49.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16454" PostTypeId="2" ParentId="16450" CreationDate="2015-10-01T14:39:45.450" Score="1" Body="&lt;p&gt;Sounds fine.&lt;/p&gt;&#xA;&lt;p&gt;You can connect the two fans in &lt;strong&gt;parallel&lt;/strong&gt;, as long as they don't use more than 5A combined, as that is the maximum of the TIP120. Though you definitely need to attach a heatsink to the TIP120, if you are using a largish amount of current. Though in that case, I'd suggest using a MOSFET instead of a Darlington Transistor (TIP120), as MOSFETs don't heat up that much.&lt;/p&gt;&#xA;&lt;p&gt;The diode is not needed if you use the TIP120, as there is already a diode inside the package.&lt;/p&gt;&#xA;&lt;p&gt;Since you are using 12V as a power supply, the voltage regulator has to convert 7v into heat. Depending on the amount of current you use, this could result in the voltage regulator getting very hot. If you are only powering the ATMega328 and maybe some LEDs from the 5v line, you'll be fine. Just don't connect something like a 5v fan.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="56438" LastEditDate="2021-11-11T08:51:38.303" LastActivityDate="2021-11-11T08:51:38.303" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16455" PostTypeId="1" AcceptedAnswerId="16457" CreationDate="2015-10-01T15:02:35.490" Score="0" ViewCount="1862" Body="&lt;p&gt;I got the following device&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HNSIF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HNSIF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(sorry for imperfect focus)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and found, that it can measure not only pressure, but also a temperature too. The code was taken from common sketches for Adafruit BMP085 and they were working. I checked, that temperature value rises if I touch sensor with finger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simultaneously, on &lt;a href=&quot;https://www.bosch-sensortec.com/en/homepage/products_3/environmental_sensors_1/bmp180_1/bmp180&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bosch site for BMP180&lt;/a&gt; I can't find any notes it can measure temperature, only pressure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can it be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Bosch's BMP180 has undocumented feature to measure a temperature&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) The device on picture has additional component to measure temperature&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) The device on picture has completely different sensor, which has the name of &quot;BMP180&quot; just by coincidence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Something else....&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2015-10-03T09:38:20.413" Title="How can BMP180 measure a temperature too?" Tags="|sensors|temperature-sensor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16456" PostTypeId="2" ParentId="16455" CreationDate="2015-10-01T15:08:48.630" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://www.adafruit.com/products/391&quot; rel=&quot;nofollow&quot;&gt;BMP085 Barometric Pressure/Temperature/Altitude Sensor- 5V ready&lt;/a&gt; page at adafruit.com says the BMP180 is a drop-in replacement for the BMP085.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The  &lt;a href=&quot;http://www.adafruit.com/products/1603&quot; rel=&quot;nofollow&quot;&gt;BMP180 Barometric Pressure/Temperature/Altitude Sensor- 5V ready&lt;/a&gt; page at adafruit.com says the BMP180  is completely identical to the BMP085 in terms of firmware/software/interfacing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, while &lt;a href=&quot;https://www.bosch-sensortec.com/en/homepage/products_3/environmental_sensors_1/bmp180_1/bmp180&quot; rel=&quot;nofollow&quot;&gt;Bosch's web page for the BMP085&lt;/a&gt; doesn't mention temperature, the data sheet itself – the final reference, typically, for a device like this – says “Temperature measurement included” on page 2, and on page 14 refers to measuring temperature in steps of 0.1°C, and on other pages shows temperature register numbers, etc.  To get the data sheet, click the Documents &amp;amp; Drivers tab, then the BST-BMP180-DS000-12 Datasheet link.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-10-01T15:24:02.800" LastActivityDate="2015-10-01T15:24:02.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16457" PostTypeId="2" ParentId="16455" CreationDate="2015-10-01T15:10:44.990" Score="3" Body="&lt;p&gt;If you read the data sheet (on the site you point to) you see plenty of references to temperature:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The BMP180 is designed to be connected directly to a microcontroller of a mobile device via the I 2 C&#xA;  bus. The pressure and &lt;strong&gt;temperature&lt;/strong&gt; data has to be compensated by the calibration data of the&#xA;  E 2 PROM of the BMP180.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The BMP180 consists of a piezo-resistive sensor, an analog to digital converter and a control unit with EEPROM and a serial I2C interface. The BMP180 delivers the uncompensated value of pressure and &lt;strong&gt;temperature&lt;/strong&gt;. The E 2 PROM has stored 176 bit of individual calibration data. This is used to&#xA;  compensate offset, temperature dependence and other parameters of the sensor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And many many more.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-01T15:10:44.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16459" PostTypeId="1" AcceptedAnswerId="16466" CreationDate="2015-10-01T15:45:46.053" Score="0" ViewCount="182" Body="&lt;p&gt;I have an Arduino Mega which is driving a board. On the board is a quad optocoupler (K847PH). Pins 42 - 45 of the Arduino are each attached to the Anode of a opto. The cathode goes to ground through a 50ohm resistor. I've used multiple boards and have had no issues with this part of the circuitry so far. I recently attached a new board (same circuit) and began testing. I noticed I had ~1.1V on pin 1 of the opto (Anode). After some debugging I checked the voltage coming out of the Arduino to that pin (42 on the Mega) and noticed it was 5V. I ran a new sketch to drive and hold the voltage low but the voltage remains at 5V.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(42, OUTPUT);&#xA;  digitalWrite(42, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(42, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the schematic of the Mega it appears pin 42 is directly connected to the ATMEGA1280-16AU. Is there anything I can do to fix the Mega? Should I just replace the ATMEGA1280-16AU? Is there something I can probe to check? It does appear there is &gt; 1Mohm of isolation between pin 42 and the 5V rail.&lt;/p&gt;&#xA;" OwnerUserId="12000" LastActivityDate="2015-10-01T20:13:19.710" Title="Mega pin stuck high after driving optocoupler" Tags="|arduino-mega|power|pins|hardware|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16460" PostTypeId="2" ParentId="16376" CreationDate="2015-10-01T15:49:22.723" Score="4" Body="&lt;p&gt;The problem was, as Gerben said, the battery was too weak to run the engine.&lt;/p&gt;&#xA;" OwnerUserId="13657" LastEditorUserId="10794" LastEditDate="2015-10-01T21:04:57.797" LastActivityDate="2015-10-01T21:04:57.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16461" PostTypeId="2" ParentId="13099" CreationDate="2015-10-01T16:25:51.897" Score="0" Body="&lt;p&gt;As JRobert mentioned in a comment, you could use a &lt;a href=&quot;http://www.ebay.com/sch/i.html?_odkw=solenoid+valve&amp;amp;_osacat=0&amp;amp;_from=R40&amp;amp;_trksid=p2045573.m570.l1313.TR0.TRC0.H0.TRS0&amp;amp;_nkw=solenoid+valve&amp;amp;_sacat=0&quot; rel=&quot;nofollow&quot;&gt;solenoid valve&lt;/a&gt;, some of which you can get for about $5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to water one line at a time, get Normally Closed, one per line. Naturally, since most of them are 12v DC, you can't directly power them from your Arduino. You'll need some power transistors or some relays, and a 12v supply capable of steadily powering the solenoid.&lt;/p&gt;&#xA;" OwnerUserId="3720" LastActivityDate="2015-10-01T16:25:51.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16462" PostTypeId="2" ParentId="16441" CreationDate="2015-10-01T18:06:58.940" Score="1" Body="&lt;p&gt;The arrays need to be tagged with the keyword &lt;code&gt;const&lt;/code&gt;.  It is possible that the original sketch was written using an earlier version of the IDE that you are using (or a later version?) and your version requires the &lt;code&gt;const&lt;/code&gt; keyword whereas the author's doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically any arrays that are &lt;code&gt;PROGMEM&lt;/code&gt; need the word &lt;code&gt;const&lt;/code&gt; adding to them.  For instance, lines that start:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static unsigned char PROGMEM ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;need changing to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const unsigned char PROGMEM ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-01T18:06:58.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16464" PostTypeId="2" ParentId="2911" CreationDate="2015-10-01T19:21:31.663" Score="1" Body="&lt;p&gt;The articles and tutorials I've read on the subject say that the HB100 module produces a very weak signal which needs to be amplified before your Arduino can read it. They recommend building an op amp. This post on the Arduino forums, for example: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=61989.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=61989.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT looking at your picture and linked article, I find that your device already includes the signal amplification and filtering you need in the backpack board. I found the &lt;a href=&quot;https://www.tindie.com/products/limpkin/hb100-doppler-module-with-backpack-1/&quot; rel=&quot;nofollow&quot;&gt;store page&lt;/a&gt; for this module, which has a more noob-friendly explanation. From what I gather:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;VCC: provide the module with a 5v supply.&lt;/li&gt;&#xA;&lt;li&gt;VOUT: analog reading of the &lt;em&gt;amount&lt;/em&gt; of return signal being received. My guess is you could use this with &lt;code&gt;analogRead()&lt;/code&gt; to get a rough estimate of the size or distance of the object being read. If you want only the speed reading, you don't need this pin.&lt;/li&gt;&#xA;&lt;li&gt;FOUT: digital output of the speed that the sensor is reading. Thanks to @sachleen's &lt;a href=&quot;https://tushev.org/articles/arduino/9/measuring-frequency-with-arduino&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;, you can use either &lt;code&gt;pulseIn()&lt;/code&gt; or FreqCounter library to measure the frequency and then convert it to a MPH or KPH speed.&lt;/li&gt;&#xA;&lt;li&gt;GND - ground, aka common, aka &lt;code&gt;-&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So connect VCC to 5v, GND to ground, and FOUT to an input pin on your Arduino. If you use &lt;code&gt;pulseIn()&lt;/code&gt;, frequency &lt;strong&gt;f&lt;/strong&gt; = 1 / &lt;strong&gt;t&lt;/strong&gt;, t being the return value from &lt;code&gt;pulseIn()&lt;/code&gt;. If you use the FreqCounter library, it no doubt has documentation on its usage.&lt;/p&gt;&#xA;" OwnerUserId="3720" LastActivityDate="2015-10-01T19:21:31.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16465" PostTypeId="1" CreationDate="2015-10-01T19:28:07.773" Score="0" ViewCount="65" Body="&lt;p&gt;I'm making a game where there are three LEDs and three buttons: 1 LED for 1 button. One has to press the button that has its LED lit. If it is correct, another (random) LED will light up and the game continues. However, if one presses one that isn't lit, one has points taken from one's score.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example image: &lt;a href=&quot;https://i.stack.imgur.com/gtnUm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/gtnUm.png&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having trouble figuring out how to find out when the wrong one is pressed. With the code below it will print &quot;Ouch&quot; whenever the led switches numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code that switches LED:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led = random(1, 4);&#xA;switch(led) {&#xA;  case 1:&#xA;    ledLeftState = HIGH;&#xA;    break;&#xA;  case 2:&#xA;    ledMiddleState = HIGH;&#xA;    break;&#xA;  case 3:&#xA;    ledRightState = HIGH;&#xA;    break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code that checks if the wrong button is pressed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if(digitalRead(BUTTON_LEFT) == LOW &amp;amp;&amp;amp; led != 1 || digitalRead(BUTTON_MIDDLE) == LOW &amp;amp;&amp;amp; led != 2 || digitalRead(BUTTON_RIGHT) == LOW  &amp;amp;&amp;amp; led != 3) {&#xA;    static unsigned long lastTime = 0;&#xA;    if(millis() - lastTime &amp;gt; 400) {&#xA;      Serial.println(&quot;Ouch, minus ten miliseconds!&quot;);&#xA;      hurt += 10;&#xA;      lastTime = millis();&#xA;    }&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully you can figure this scenario out in your heads, otherwise simply tell me that you'd like code instead of downvoting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time!&lt;/p&gt;&#xA;" OwnerUserId="13730" LastEditorUserId="4628" LastEditDate="2015-12-05T22:08:11.807" LastActivityDate="2016-02-28T03:28:47.673" Title="Arduino ethernet need help with game logic!" Tags="|c|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16466" PostTypeId="2" ParentId="16459" CreationDate="2015-10-01T20:13:19.710" Score="1" Body="&lt;p&gt;Re “Is there anything I can do to fix the Mega?”, if the condition persists when trying it after removing power from the Mega and discharging it, probably not. (Aside from not using that pin.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the IR LEDs in the K847PH are rated at 60 mA max each, and typically drop 1.25 volts at 50 mA current.  If you drive them with 5 V through a 50Ω resistor, typical current will be 3.75/50 = 75 mA, which exceeds K847PH ratings and Mega2560 ratings (typically 40 mA max, 20 mA working).  Consider using a 125Ω or more resistor, to stress the Mega pins at 30 mA or less.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(From Fig. 8 - Collector Current vs. Forward Current, in the K847PH data sheet, you might be ok with 10 to 20 mA current through the IR LEDs.)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-01T20:13:19.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16467" PostTypeId="1" AcceptedAnswerId="18304" CreationDate="2015-10-01T22:53:47.160" Score="1" ViewCount="340" Body="&lt;p&gt;I'm trying to get a strip of Neopixels to circle through its length, one LED at a time, I want it to do it faster as the value received from the sensor increases&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS    34&#xA;#define DATA_PIN    6&#xA;#define SENSOR_PIN  A0&#xA;&#xA;int airPressure,&#xA;    barometricToRGB,&#xA;    frequency       = 0,&#xA;    high            = 0,&#xA;    low             = 600,&#xA;    interval        = 50;&#xA;&#xA;long previousMillis = 0;&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(SENSOR_PIN,INPUT);  &#xA;  FastLED.addLeds&amp;lt;NEOPIXEL, DATA_PIN&amp;gt;(leds, NUM_LEDS);&#xA;}&#xA;&#xA;void loop() {&#xA;  airPressure = analogRead(SENSOR_PIN);&#xA;  autoTune();&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;  Serial.print(&quot;frequency &quot;);&#xA;  Serial.println(frequency);&#xA;  Serial.print(&quot;Time to beat &quot;);&#xA;  Serial.println(frequency*interval);&#xA;  Serial.print(&quot;Last Called &quot;);&#xA;  Serial.println(currentMillis - previousMillis);&#xA;&#xA;  if(currentMillis - previousMillis &amp;gt; (frequency/interval)) {&#xA;    previousMillis = currentMillis;&#xA;&#xA;    for (int i=0; i&amp;lt;NUM_LEDS; i++) {&#xA;          leds[i].setRGB( barometricToRGB, 68, 255/barometricToRGB);&#xA;          FastLED.show();&#xA;        }&#xA;  }&#xA;}&#xA;&#xA;void autoTune() {&#xA;  if (airPressure &amp;lt; low) {&#xA;    low = airPressure;&#xA;  }&#xA;  if (airPressure &amp;gt; high) {&#xA;    high = airPressure;&#xA;  }&#xA;  barometricToRGB = map(airPressure, low, high, 1, 255);&#xA;  barometricToRGB = constrain(barometricToRGB, 1, 255);&#xA;  frequency = map(airPressure, low, high, 1, 100);&#xA;  frequency = constrain(frequency, 1, 100);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I had managed to cause the color to change based on the sensor, I can't seem to understand how to control how fast it will go, every how long.&lt;/p&gt;&#xA;" OwnerUserId="10652" LastEditorUserId="3917" LastEditDate="2015-12-03T22:04:02.173" LastActivityDate="2015-12-03T22:04:02.173" Title="Using a state machine" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16469" PostTypeId="1" AcceptedAnswerId="16470" CreationDate="2015-10-01T23:55:29.407" Score="2" ViewCount="129" Body="&lt;p&gt;Im trying out &lt;a href=&quot;http://www.adafruit.com/products/1332?gclid=CjwKEAjw7aiwBRCPgdu70arX70wSJADK6iDD89H4xAIdw88_bv9K8EcrhdbdzERDU0gKJgrRwAcO2xoClM_w_wcB&quot; rel=&quot;nofollow&quot;&gt;this membrane&lt;/a&gt; from Adafruit that i bought last week but i have a little issue. ITS SO SENSITIVE! i as so just touch it with my finger and it transmits!. Anyone that has worked with this membrane have the same issue? is there some sort of &quot;fix&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its really simple. But one weird thing, not sure if its supposed to be like that, but by default, the buttons are on &lt;code&gt;HIGH&lt;/code&gt;. i used &lt;code&gt;Serial.println(digitalRead(one));&lt;/code&gt; to verify that and the output was 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int two =  8;&#xA;int one = 9;&#xA;int four = 10;&#xA;int three = 11;&#xA;&#xA;void setup() {&#xA;  pinMode(one, INPUT);&#xA;  pinMode(two, INPUT);&#xA;  pinMode(three, INPUT);&#xA;  pinMode(four, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(digitalRead(one) == LOW){&#xA;    Serial.println(&quot;One&quot;);&#xA;  }else if(digitalRead(two) == LOW){&#xA;    Serial.println(&quot;Two&quot;);&#xA;  }else if(digitalRead(three) == LOW){&#xA;    Serial.println(&quot;Three&quot;);&#xA;  }else if(digitalRead(four) == LOW){&#xA;    Serial.println(&quot;Four&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13732" LastEditorUserId="13732" LastEditDate="2015-10-02T01:02:53.053" LastActivityDate="2015-10-02T01:06:50.047" Title="1x4 Button membrane help" Tags="|button|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16470" PostTypeId="2" ParentId="16469" CreationDate="2015-10-02T01:06:50.047" Score="4" Body="&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(one, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have configured the input with no pullup. Since it is a CMOS input and hence very high impedance, it effectively acts as an antenna picking up random signals including that of your finger becoming capacitively coupled to it. You &lt;em&gt;must&lt;/em&gt; enable the pullup on the pins (and connect the common to ground) if you want correct operation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; pinMode(one, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-02T01:06:50.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16471" PostTypeId="2" ParentId="16445" CreationDate="2015-10-02T01:11:08.097" Score="0" Body="&lt;p&gt;This depends if you want the hypothetical best solution, or if good enough is good enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If good enough is good enough, I'd take the following approach:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Work out the distance from your robot to the first waypoint; move forward. Work out how fast you're moving towards (away from) the goal. Turn left a bit, go forwards again; did things improve (less away from/more towards)? If not, turn slightly right. Keep turning this way (left or right), and going forward a bit; whenever your speed towards to the goal gets worse, change your turning direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should get you to where you are going.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, start making improvements. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are moving away from the goal (distance is increasing), your rotates can be quite sharp; as your approach speed to the goal increases, make the rotates smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try rotating while driving - if you are driving forward, and want to turn slightly left, run your left wheel at 90% of the speed of the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a bit of trial and error, you should be able to end up with a table - work out your approach speed, look up in a table (or formula) how fast your slower wheel should go - from 0% (or even 100% reverse!) if moving away from your goal, to 100% if you are going at your driving speed towards your goal. Remember that if you are turning, you will approach it more slowly than if you are going straight. And if you start to turn and things get worse, then you are turning the wrong way.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-02T01:11:08.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16472" PostTypeId="2" ParentId="16467" CreationDate="2015-10-02T01:50:10.833" Score="1" Body="&lt;p&gt;Are these reversed?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;high            = 0,&#xA;low             = 600,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks like high and low both get set to airPressure on the first pass through autoTune(). If the pressure drops after this, for example, low will track airPressure and high will stay the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, with frequency 1 to 100 and interval 50 the largest time difference is 2 milliseconds and the smallest is 0.  Your loop could be taking 2 ms without the if statement. &lt;/p&gt;&#xA;" OwnerUserId="13577" LastActivityDate="2015-10-02T01:50:10.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16476" PostTypeId="1" AcceptedAnswerId="16484" CreationDate="2015-10-02T03:58:26.333" Score="0" ViewCount="4445" Body="&lt;p&gt;I have some existing code that I've been using with an Uno and a HC-SR04. In order to make my project less expensive, I'm trying to port everything over to a ESP8266-01.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last hang up I've been running into is that it appears that the ESP8266 doesn't support the pulseIn function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;duration = pulseIn(echoPin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea on how I can change the pulseIn function with interrupts or something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly I've done a lot of searching for using a HC-SR04 with a ESP8266 and while there are a couple examples out there, I haven't seen anyone do it with Arduino code...&lt;/p&gt;&#xA;" OwnerUserId="11556" LastActivityDate="2019-03-02T04:37:53.777" Title="Can a ESP8266 and a HC-SR04 be friends?" Tags="|sensors|arduino-ide|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16478" PostTypeId="2" ParentId="10536" CreationDate="2015-10-02T05:39:41.043" Score="1" Body="&lt;p&gt;I made debug code before all the if statements, and those aren't working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(val2 = LOW)&#xA;{&#xA;  pos = pos - 15;&#xA;}&#xA;if(val3 = LOW)&#xA;{&#xA;  pos2 = 180;&#xA;}&#xA;if(val3 = HIGH){&#xA;  pos2 = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's because they are coded wrongly. Doing &lt;code&gt;val2 = LOW&lt;/code&gt; &lt;strong&gt;assigns&lt;/strong&gt; LOW to val2 and then tests it (which means it will fail the test). They should read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(val2 == LOW)&#xA;{&#xA;  pos = pos - 15;&#xA;}&#xA;if(val3 == LOW)&#xA;{&#xA;  pos2 = 180;&#xA;}&#xA;if(val3 == HIGH){&#xA;  pos2 = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-02T05:39:41.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16479" PostTypeId="1" AcceptedAnswerId="17398" CreationDate="2015-10-02T07:32:48.730" Score="0" ViewCount="714" Body="&lt;p&gt;I intend to create a DIY dust sensor, specifically Particulate Matter up to 10 micrometer in size (PM10) using Arduino UNO for the region surrounding a building which is located next to a factory that produces wood-based products. Is there any specific sensor that should suit my need, that is to collect and measure dust particles in an open environment and possibly a windy condition?&#xA;Any implementation ideas are also welcome.  &lt;/p&gt;&#xA;" OwnerUserId="13736" LastActivityDate="2015-11-01T14:54:50.140" Title="Dust sensor for Arduino in open and windy environment" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16480" PostTypeId="1" CreationDate="2015-10-02T07:21:58.690" Score="0" ViewCount="1659" Body="&lt;p&gt;I have learned Arduino for a month, and I want to bulid a car with 2 modes,&#xA;Remote and Auto. Auto mode needs to have while() loop, so it can receive data from sensors. When I choose Auto mode via bluetooth, it keeps looping and it won't stop when I choose the Remote mode. Here's the part code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char mode;&#xA;&#xA;void loop()&#xA;{&#xA;    while(serial1.available())&#xA;    {&#xA;        char control = serial.read();&#xA;        if(control == 'r') mode = 'r';     // r stand for Remote Mode&#xA;        if(control == 'a') mode = 'a';     // a stand for Auto Mode&#xA;&#xA;        if(mode == 'r') remoteMode(control);&#xA;&#xA;        while(mode = 'a')&#xA;        {&#xA;            int IR = analogRead(A10);&#xA;            float U1cmMsec,U2cmMsec;&#xA;            long U1microsec = u1.timing();&#xA;            long U2microsec = u2.timing();&#xA;            U1cmMsec = u1.convert(U1microsec, Ultrasonic::CM);&#xA;            U2cmMsec = u2.convert(U2microsec, Ultrasonic::CM);&#xA;&#xA;            robot(U1cmMsec, U2cmMsec,IR);&#xA;&#xA;            /*&#xA;            Here is the code to stop while() that I don't know how&#xA;            to program.&#xA;            I have tried:&#xA;&#xA;            if(serial1.read() != 'a') break; &#xA;&#xA;            But it will stop while(), because it will waits for&#xA;            bluetooth send data to arduino board. &#xA;            And if I take this line off, it will keeps while() and&#xA;            nothing can stop it.&#xA;            So, what am I supposed to do?&#xA;            */&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="徐理芳" LastEditorUserId="10003" LastEditDate="2015-10-02T21:45:50.760" LastActivityDate="2015-10-02T21:45:50.760" Title="Arduino: how can I stop while() when bluetooth send a data?" Tags="|c++|code-optimization|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16481" PostTypeId="2" ParentId="16480" CreationDate="2015-10-02T09:52:41.363" Score="1" Body="&lt;p&gt;Your problem is with this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(mode = 'a') {                 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you are saying there is not what you think you are saying.  You are confusing &lt;code&gt;=&lt;/code&gt; (assignment) with &lt;code&gt;==&lt;/code&gt; (comparison).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are basically saying &quot;While I assign 'a' to the variable 'mode' and 'a' is not 0 ...&quot;, which of course will always be true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (mode == 'a') {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, &quot;While the variable 'mode' contains the letter 'a' ...&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you just need to program in some way of changing the value of &lt;code&gt;mode&lt;/code&gt; within your while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more on while loops here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hacking.majenko.co.uk/the-while-loop&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/the-while-loop&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-02T09:52:41.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16482" PostTypeId="2" ParentId="16480" CreationDate="2015-10-02T09:53:44.483" Score="0" Body="&lt;p&gt;The &lt;code&gt;while(serial1.available())&lt;/code&gt; can be turned into an &lt;code&gt;if&lt;/code&gt;: the loop function is already executed in a loop, as the name hints :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And unnest the inner &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here it is at high level, which is probably easier to understand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&#xA;void loop() {&#xA;  static char mode; /*notice the &quot;static&quot;*/&#xA;  if (character_available())&#xA;    update_mode();&#xA;  if (mode == 'r')&#xA;    do_one_iteration_in_remote_mode();&#xA;  else if (mode == 'a')&#xA;    do_one_iteration_in_auto_mode();&#xA;}&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just make sure that you do not loop inside neither &lt;code&gt;do_one_iteration_in_remote_mode()&lt;/code&gt; nor &lt;code&gt;do_one_iteration_in_auto_mode()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-02T09:53:44.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16483" PostTypeId="2" ParentId="16480" CreationDate="2015-10-02T09:54:43.450" Score="0" Body="&lt;p&gt;I have replaced both 'mode' and 'control' (they were identical) with a single variable, &lt;code&gt;btChar&lt;/code&gt;. At the end of &lt;code&gt;setup()&lt;/code&gt;, wait for a transmission to be received before entering the main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the main loop begins, a while loop executes until the serial receives a new transmission. Once it is received it is read, btChar is updated and the main loop starts again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char btChar;&#xA;&#xA;void setup()&#xA;{&#xA;/* AT THE END OF SETUP() */&#xA;&#xA;// Wait in setup for first BT transmission&#xA;&#xA;    while (!serial1.available())&#xA;    { /* do nothing */ }&#xA;    btChar = serial1.read();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    while(!serial1.available())&#xA;    {&#xA;    // Program will stay in this 'while' loop until&#xA;    //    a new BT character is recv'd&#xA;&#xA;        switch(btChar)&#xA;        {&#xA;            case('a'):&#xA;            {&#xA;            // do the 'auto' stuff&#xA;                break;&#xA;            }&#xA;            case('r'):&#xA;            {&#xA;            // do the 'remote' stuff&#xA;                break;&#xA;            }&#xA;            default: // this 'block' is not essential&#xA;            {&#xA;            // you end up here if neither 'a' nor 'r' was received&#xA;            }&#xA;        }&#xA;    }&#xA;    btChar = serial1.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can adapt the setup while-loop further to make sure that the main loop doesn't begin until the a correct character is received - change the line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while ((!serial1.available())&amp;amp;&amp;amp;(btChar != 'a')&amp;amp;&amp;amp;(btChar != 'r'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using a &lt;code&gt;switch-case&lt;/code&gt; statement within the main while-loop is not essential, and I included it out of interest more than necessity. You can use &lt;code&gt;if&lt;/code&gt; statements instead, with one for 'a' and one for 'r'. However, in the event that you have a third or fourth (or more-th) mode then a switch-case statement, in my view, looks easier to read.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2015-10-02T10:07:18.390" LastActivityDate="2015-10-02T10:07:18.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16484" PostTypeId="2" ParentId="16476" CreationDate="2015-10-02T09:57:59.937" Score="1" Body="&lt;p&gt;&lt;code&gt;pulseIn()&lt;/code&gt; is actually a very simple function.  As long as there is a microseconds counter of some form available you can easily enough roll your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't know which implementation of the ESP8266 plugin you are using, but &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;the one I use&lt;/a&gt; has &lt;a href=&quot;https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_wiring_pulse.c&quot; rel=&quot;nofollow&quot;&gt;pulseIn available&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-02T09:57:59.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16486" PostTypeId="2" ParentId="16479" CreationDate="2015-10-02T12:17:09.140" Score="0" Body="&lt;p&gt;It depends on how far you want to go.  If you are looking for something cheap, than a GP2Y1010AU0F will only cost you a few pounds.  Or you could step up to £30 GBP or even £1000GBP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are looking at using an Arduino and not a PC then I'm guessing the GP2Y1010AU0F would be a good idea.  I haven't tried it but this site should steer you the right way: &lt;a href=&quot;http://arduinodev.woofex.net/2012/12/01/standalone-sharp-dust-sensor/&quot; rel=&quot;nofollow&quot;&gt;http://arduinodev.woofex.net/2012/12/01/standalone-sharp-dust-sensor/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="2881" LastEditDate="2015-10-02T13:36:15.857" LastActivityDate="2015-10-02T13:36:15.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16488" PostTypeId="2" ParentId="13991" CreationDate="2015-10-02T12:25:34.223" Score="0" Body="&lt;p&gt;The same library works with the Due if you use the older version 1.1.13 from the same Github repo, which is the last version that officially supported the Due.&lt;/p&gt;&#xA;&lt;p&gt;Here are the changelog entries that show the relevant changes:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;update: 0.1.13 added support for DHT33 and DHT44 - LAST DUE VERSION&lt;/p&gt;&#xA;&lt;p&gt;update: 0.1.14 replaced digitalRead with faster code (AVR ONLY!!! better support for lower Mhz devices)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-10-02T12:25:34.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16489" PostTypeId="2" ParentId="16465" CreationDate="2015-10-02T12:34:03.920" Score="0" Body="&lt;p&gt;Off the top of my head and without a compiler would something like this work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int BasePin = 3;&#xA;int BaseButton = 7;&#xA;&#xA;int led = random (1, 4); // Are you sure its 4??&#xA;digitalWrite(BasePin+led, HIGH);&#xA;&#xA;if (digitalRead(BaseButton+led))&#xA;{&#xA;  // Success&#xA;}&#xA;else if (millis() - lastTime &amp;gt; 400))&#xA;{&#xA;  // Out of time&#xA;}&#xA;else if (  digitalRead(BaseButton+1)&#xA;        || digitalRead(BaseButton+2)&#xA;        || digitalRead(BaseButton+3)&#xA;{&#xA;  // Wrong button &#xA;  // (The right one will have been handled by the earlier clause)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK the last clause is a bit of a hack, but it should give you a starting point to tidy up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are probably going to get issues unless you debounce the switches.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-02T12:34:03.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16490" PostTypeId="2" ParentId="16465" CreationDate="2015-10-02T14:59:20.460" Score="1" Body="&lt;p&gt;The line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(millis() - lastTime &amp;gt; 400)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is supposed to test that the button press does not come right after the&#xA;LED switches. This means the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastTime = millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be right when you change the displayed LED.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2015-10-02T14:59:20.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16492" PostTypeId="1" CreationDate="2015-10-02T15:29:35.940" Score="0" ViewCount="205" Body="&lt;p&gt;Hi I have problem with school project. I have 3 Arduino - 1 Transmiter with NRF; 2,3 - NRF receiver and wire slave receiver.&#xA;I can't send data via &quot;Wire&quot; library (in code char &quot;datar&quot;) to receiver arduino. I won't get anything, but when I want to send like &lt;code&gt;Wire.write(&quot;blablabla&quot;);&lt;/code&gt; it pass. But when in char is NRF data code crashing when go to &quot;Wire.write&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;*/&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;&#xA;char datar = '';&#xA;&#xA;//Konfiguracja&#xA;const uint64_t pipes[2] = {0xF1F2F3F0F7/*odbieranie*/, 0xF1F2F3F0F8/*wysylanie*/};&#xA;RF24 radio(9, 10); //Piny nrf (SPI) 9 i 10&#xA;//-- Konfiguracja&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;LOL&quot;);&#xA;  Wire.begin();&#xA;  radio.begin();&#xA;  radio.setPALevel(RF24_PA_MAX);&#xA;  radio.setDataRate(RF24_250KBPS);&#xA;  radio.openReadingPipe(1, pipes[0]);&#xA;  radio.openWritingPipe(pipes[1]);&#xA;  radio.setChannel(78);&#xA;  radio.setAutoAck(true); &#xA;  radio.startListening();&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  int len; &#xA;  if(radio.available())&#xA;  {&#xA;  len = radio.getDynamicPayloadSize();&#xA;  radio.read(&amp;amp;datar, len);&#xA;  delay(5);&#xA;  Serial.println(datar);&#xA;  Wire.beginTransmission(7);&#xA;  Wire.write(&amp;amp;datar);&#xA;  Wire.endTran345smission();&#xA;  radio.printDetails();&#xA;  }&#xA;  delay(5);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13739" LastEditorUserId="10794" LastEditDate="2015-10-02T16:08:50.457" LastActivityDate="2015-10-02T16:26:17.937" Title="Arduino wire can't send char" Tags="|c++|i2c|nrf24l01+|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16493" PostTypeId="1" CreationDate="2015-10-02T15:36:38.107" Score="5" ViewCount="1733" Body="&lt;p&gt;I'm looking for a library to decode RAW IR signals from an IR sensor (looks like a black LED, two legged) rather than an IR module (3 legged, rated for a particular frequency - such as 38kHz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a library that supports IR sensors?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A picture of the two possibilities can be seen &lt;a href=&quot;http://www.instructables.com/id/How-to-use-IR-Sensor-using-Op-amp-and-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: This isn't a duplicate of &lt;a href=&quot;https://arduino.stackexchange.com/questions/16361/a-c-doesnt-detect-ir-codes-sent-from-arduino&quot;&gt;my previous post&lt;/a&gt;, it is related to the same project however.&#xA;On my previous question I asked what could be the cause. I've found out what it is - frequency. My previous IR detector was an IR module and not an IR sensor. The difference could be seen &lt;a href=&quot;http://www.instructables.com/id/How-to-use-IR-Sensor-using-Op-amp-and-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13634" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2018-05-02T06:20:18.400" Title="Decoding IR codes with IR sensor rather than IR receiver module" Tags="|library|ir|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="16494" PostTypeId="2" ParentId="16492" CreationDate="2015-10-02T16:01:22.647" Score="1" Body="&lt;p&gt;The  code crash because you pass an memory address to the write function if you look to the arduino doc you pass a variable to the function therefore just writing datar as argument will end your problem&lt;/p&gt;&#xA;" OwnerUserId="11732" LastActivityDate="2015-10-02T16:01:22.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16495" PostTypeId="2" ParentId="16492" CreationDate="2015-10-02T16:10:48.387" Score="2" Body="&lt;p&gt;Your problem is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char datar = '';&#xA;&#xA;...&#xA;&#xA; len = radio.getDynamicPayloadSize();&#xA; radio.read(&amp;amp;datar, len);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable &quot;datar&quot; is one byte long. You then find the payload size (presumably greater than one byte) and read into &lt;code&gt;datar&lt;/code&gt; more than one byte. This overwrites other parts of memory and the program crashes. You need to make &lt;code&gt;datar&lt;/code&gt; larger, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char datar [50];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The exact size would depend on your maximum payload size.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-02T16:10:48.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16497" PostTypeId="2" ParentId="16492" CreationDate="2015-10-02T16:26:17.937" Score="1" Body="&lt;p&gt;I think the answer is a combination of Nick and Mathieu's answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like Nick said you haven't assigned any memory to datar, so this is probably causing a crash because of buffer overrun.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to the call to read.  Mathieu said you are passing a pointer into the function when you probably didn't mean to.  But if you put Nicks change in then you &lt;strong&gt;do&lt;/strong&gt; need to pass in a pointer to the character array.  You can do this by &lt;code&gt;radio.read(datar, len);&lt;/code&gt; because the character array is a character pointer.&lt;br&gt;&#xA;You &lt;strong&gt;do not&lt;/strong&gt; want to pass a pointer to a character pointer &lt;code&gt;&amp;amp;datar&lt;/code&gt; because that would mean the function was able to move the memory that you have allocated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you need to prevent buffer overflows in the &quot;new improved&quot; code by checking that the value of &lt;code&gt;len&lt;/code&gt; is less than or equal to the value you allocated when you declared the data buffer (i.e. 50).  Because you are using a number in two places you should declare it as a constant at the top of the file.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MaxBufferSize = 50;&#xA;char datar[MaxBufferSize];&#xA;...&#xA;len = radio.getDynamicPayloadSize();&#xA;if (len &amp;gt; MaxBufferSize)&#xA;  len = MaxBufferSize;&#xA;radio.read(datar, len);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-02T16:26:17.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16498" PostTypeId="1" AcceptedAnswerId="16505" CreationDate="2015-10-02T18:02:57.563" Score="0" ViewCount="269" Body="&lt;p&gt;I need to hook up &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/getting-started-with-the-nrf8001-bluefruit-le-breakout.pdf&quot; rel=&quot;nofollow&quot;&gt;Bluefruit LE Breakout&lt;/a&gt; (nRF8001-based) to ATMega328 chip (to use it as wireless UART), and it seems like the &lt;a href=&quot;https://github.com/adafruit/Adafruit_nRF8001/archive/master.zip&quot; rel=&quot;nofollow&quot;&gt;library provided&lt;/a&gt; is for Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have is just bare ATMega328 (note the lack of &quot;p&quot;), which I am going to program (using avrispmkii directly). As I already have the MCU assembled, I do not want to change to, say, Arduino Uno to be able to use the library. Most likely, I will &quot;play&quot; with the Bluefruit on Arduino first to get the feel of it, but the code needs to be run on the &quot;bare&quot; ATMega328. The other part of the program (which prepare data to be sent from atmega) is trivial, so I will have no problem to rewrite it from C to Arduino. Porting Adafruit library from C++ to C is probably much more difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, one of the possible approaches is to compile the my code + Bluefruit LE code for Arduino, but upload to the ATMega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is where I need help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to make Arduino (command line tool is ok) to compile to the MCU I have? I guess, the result should be some kind of hex-file for flash (and eeprom?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, may be useful, which flags to use with avrdude, if there is anything specific for the Arduino-generated code. (I do not need any bootloaders on the chip, just the program, and I do not have UART-USB connected to atmega).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, please, mention if there are better ways I overlooked, like some Arduino-compatible gcc toolchain to compile C++/C mix into avr code (avr-g++?). Or maybe there is some C-library for the component atmega needs to talk to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: Similar question: &lt;a href=&quot;http://www.avrfreaks.net/forum/using-arduino-ide-general-atmel-microcontroller-no-bootloader-no-cristal&quot; rel=&quot;nofollow&quot;&gt;http://www.avrfreaks.net/forum/using-arduino-ide-general-atmel-microcontroller-no-bootloader-no-cristal&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="12167" LastEditorUserId="37523" LastEditDate="2019-12-05T21:55:28.720" LastActivityDate="2019-12-05T21:55:28.720" Title="Running Arduino code for Bluefruit LE on bare ATMega328" Tags="|atmega328|adafruit|avrdude|avr-gcc|gcc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16500" PostTypeId="1" AcceptedAnswerId="16502" CreationDate="2015-10-02T18:06:50.627" Score="0" ViewCount="187" Body="&lt;p&gt;So I am working with the SoftwareSerial library. I'm looking at the write function and I see a *reg value being manipulate. I want to find the value of *reg so I traced the value by stepping into each function call.so here we go.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*reg = _transmitPortRegister&#xA;_transmitPortRegister = portOutputRegister(port) //I'm working with pin 1 in register D&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Continuing...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )&#xA;&#xA;const uint16_t PROGMEM port_to_output_PGM[] = {&#xA;    NOT_A_PORT,&#xA;    NOT_A_PORT,&#xA;    (uint16_t) &amp;amp;PORTB,&#xA;    (uint16_t) &amp;amp;PORTC,&#xA;    (uint16_t) &amp;amp;PORTD,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My first question is what is the point of (uint16_t) &amp;amp;PORTD? I am assuming that's just the value of PORTD's register because it is being anded with an empty 16 bit int. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Continuing on, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PORTB _SFR_IO8(0x05)&#xA;#define PORTC _SFR_IO8(0x08)&#xA;#define PORTD _SFR_IO8(0x0B)&#xA;&#xA;#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)&#xA;#define __SFR_OFFSET 0x20&#xA;&#xA;#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I followed it all the way here. But how do I find out what actually is the deferenced value? Since this is all IDE, i'm not sure how to GDB this either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LASTLY, the write function takes in a parameter b, which is a byte. Now in the write function, this is the code to write.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Write each of the 8 bits&#xA;for (uint8_t i = 8; i &amp;gt; 0; --i)&#xA;{&#xA;  if (b &amp;amp; 1) // choose bit&#xA;    *reg |= reg_mask; // send 1&#xA;  else&#xA;    *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;  tunedDelay(delay);&#xA;  b &amp;gt;&amp;gt;= 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that block of code, I am not quite sure why they are doing b &amp;amp; 1. Are they just anding the whole byte with 1? If so, then why comment it as &quot;choose byte&quot; &#xA;and inside the if-else blocks, they're just oring *reg with reg_mask. How does that translate to sending a one? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for any confusion, i am glad to clarify any confusing parts of this question. Please let me know. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-10-02T18:13:49.573" LastActivityDate="2015-10-02T21:42:55.927" Title="How to find the deferenced value of a transmit Port Register?" Tags="|arduino-uno|c++|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16501" PostTypeId="1" AcceptedAnswerId="16503" CreationDate="2015-10-02T18:13:49.920" Score="0" ViewCount="531" Body="&lt;p&gt;I'm trying to connect a 2.8&quot; display but it uses all the pins. That similar to this post (here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/12076/2-8-tft-touchscreen-prohibits-access-to-unused-pins&quot;&gt;2.8&amp;quot; TFT Touchscreen Prohibits Access to Unused Pins&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, they recommend a proto screw shield (show here: &lt;a href=&quot;http://www.mouser.com/ProductDetail/Adafruit/196/?qs=GURawfaeGuDa14An8N8oeg%3D%3D&amp;amp;gclid=CKjBqd2xpMgCFQiVfgodN5wCbA&amp;amp;kpid=1480459155&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.mouser.com/ProductDetail/Adafruit/196/?qs=GURawfaeGuDa14An8N8oeg%3D%3D&amp;amp;gclid=CKjBqd2xpMgCFQiVfgodN5wCbA&amp;amp;kpid=1480459155&lt;/a&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how would that work? I'm a bit of a noob -- does anyone have any diagrams of it being connected, etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13592" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-02T18:26:46.430" Title="2.8&quot; tft screen arduino all pins used" Tags="|arduino-uno|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16502" PostTypeId="2" ParentId="16500" CreationDate="2015-10-02T18:16:41.407" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My first question is what is the point of (uint16_t) &amp;amp;PORTD? I am assuming that's just the value of PORTD's register because it is being anded with an empty 16 bit int. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.  You're mistaking the operator.  In this context &lt;code&gt;&amp;amp;&lt;/code&gt; means &lt;em&gt;the address of&lt;/em&gt;, so it is getting the address of the variable called &lt;code&gt;PORTD&lt;/code&gt; and casting it to an unsigned 16-bit integer, which it's then storing in the array.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, I followed it all the way here. But how do I find out what actually is the deferenced value? Since this is all IDE, i'm not sure how to GDB this either. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, we're talking addresses.  The port register number is (for port D) 0x0B.  Add that to 0x20 and you get 0x2B which is the address of the register in memory.  Then comes the tricky bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expand that out with 0x2B and you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(*(volatile uint8_t *)(0x2B))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, working from the inside out we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(volatile uint8_t *)(0x2B)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That says &lt;em&gt;this is a pointer to address 0x2B&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then that is de-referenced to get the value from that pointer with a &lt;code&gt;*&lt;/code&gt; operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*(volatile uint8_t *)(0x2B)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you end up with &quot;The value that is in the address 0x2B&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we then feed that back into the first part of your question, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PORTD = (*(volatile uint8_t *)(0x2B))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then &lt;code&gt;&amp;amp;PORTD&lt;/code&gt; would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;amp;(*(volatile uint8_t *)(0x2B))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The initial &amp;amp; and * cancel each other out (you can think of them as opposites - one is get the address from a value, the other get a value from an address), so you effectively end up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(volatile uint8_t *)0x2B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-02T18:22:09.437" LastActivityDate="2015-10-02T18:22:09.437" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="16503" PostTypeId="2" ParentId="16501" CreationDate="2015-10-02T18:26:46.430" Score="1" Body="&lt;p&gt;You're confusing the idea of &lt;em&gt;using&lt;/em&gt; all the pins to that of &lt;em&gt;plugging into&lt;/em&gt; all the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, your shield may well have all the pins on it which then fill all the available holes.  Only some of them will actually be connected to anything on the circuit board though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The breakout board you link to basically provides a &quot;tee&quot; connection to all the pins, so that you can then get to the pins that, while they may have a lump of metal plugged into them, don't electrically connect to anything at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should look at the schematic for your TFT screen to see exactly which pins are in use and which are there but not wired to anything.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-02T18:26:46.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16504" PostTypeId="1" AcceptedAnswerId="16527" CreationDate="2015-10-02T18:13:26.433" Score="1" ViewCount="152" Body="&lt;p&gt;&lt;em&gt;Please see the comments section if confused.&lt;/em&gt;&#xA;I am trying to turn a motor on and off once per second, and when the motor is on, the RGB turns green. When the motor is off, the RGB is red. Everything is connected to an arduino UNO.I have the motor connected to pins 0 and 1, and to the 5V and GND. The RGB is connected to pins 4, 5, and 6, and the 5V.&#xA;I have two codes; one with a bunch of screwing around with a bunch of different loops and everything else I've tried, and one with the simple motor on/off code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  pinMode(0,OUTPUT); //IB1&#xA;  pinMode(1,OUTPUT); //IA1&#xA;////  pinMode(2,OUTPUT); //IB2&#xA;////  pinMode(3,OUTPUT); //IA2&#xA;//  pinMode(4,OUTPUT); //RGB&#xA;//  pinMode(5,OUTPUT); //RGB&#xA;//  pinMode(6,OUTPUT); //RGB&#xA;//  pinMode(A0,INPUT); //lMotor&#xA;////  pinMode(A1,INPUT); //rMotor&#xA;//  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  digitalWrite(0,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(0,LOW);&#xA;  delay(1000);&#xA;&#xA;//  int lMotor = analogRead(A0);&#xA;//  Serial.write(lMotor);&#xA;////  int lMotor = analogRead(A1);&#xA;////  Serial.write(lMotor);&#xA;//  &#xA;//  if (lMotor&amp;gt;10)&#xA;//  {&#xA;//    digitalWrite(4,HIGH);&#xA;//    digitalWrite(5,HIGH);&#xA;//    digitalWrite(6,LOW);&#xA;//  }&#xA;//  else&#xA;//  {&#xA;//    digitalWrite(4,HIGH);&#xA;//    digitalWrite(5,LOW);&#xA;//    digitalWrite(6,HIGH);&#xA;//  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  pinMode(0,OUTPUT); &#xA;  pinMode(1,OUTPUT); &#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  digitalWrite(0,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(0,LOW);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What do I need to do? Should I use a &quot;while&quot; loop? If so, how?&#xA;Is my circuit put together properly? I'm using a motor relay switch to turn the motor on/off, but I'm pretty sure it's hooked up right.&#xA;Any help is appreciated, even if it doesn't answer all of my questions. &#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="13650" OwnerDisplayName="Shiori_Toshiko" LastActivityDate="2015-10-04T09:04:34.587" Title="Programming a motor with an RGB" Tags="|motor|relay|programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16505" PostTypeId="2" ParentId="16498" CreationDate="2015-10-02T18:44:56.580" Score="1" Body="&lt;p&gt;The UNO is basically just an ATMega328(P). So you can run the same compiled code for the UNO just fine on a bare ATMega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to worry about the P versus non-P version. They are basically the same except for some minor differences concerning low power settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can just select the Arduino UNO board as you target. Select the avrispmkii as programmer. Then instead of &lt;code&gt;Upload&lt;/code&gt;, choose &lt;code&gt;Upload using Programmer&lt;/code&gt; (in the &lt;code&gt;Sketch&lt;/code&gt; menu).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-02T18:44:56.580" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16506" PostTypeId="1" CreationDate="2015-10-02T20:08:54.800" Score="1" ViewCount="53" Body="&lt;p&gt;In my project I need to add some storage space and I don't want to use an SD card, because in the &quot;final product&quot; the user shouldn't be able to access the data on their own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was considering the options here &lt;a href=&quot;http://playground.arduino.cc/Main/InterfacingWithHardware#Storage&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/InterfacingWithHardware#Storage&lt;/a&gt; but many of the technologies are either outdated, for example as reads &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=298022.0#msg2356709&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; ADESTO is discontinuing production of dataflash, or they give too little memory, like the I2C EEPROM (which is 128KByte per chip and I would rather not go through the hassle of multiplexing lots of memory chips since I'd like to have 1MByte of storage at least), or are extremely overpriced and cannot be found on retail: some sites require you to buy 2000$ worth of chips or charge you 30$ for delivery, which kind of kills the fun of prototyping something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I am being picky not wanting to use an SD for the prototype, but I would like to know if you ever faced this problem and how you solved it, or if you know some alternative solution which gives a good amount of memory (~1 or 2 MBytes at least) within reasonable costs.&lt;/p&gt;&#xA;" OwnerUserId="12102" LastActivityDate="2015-10-03T03:58:57.727" Title="Cost-effective storage for prototyping" Tags="|datalogging|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16507" PostTypeId="1" AcceptedAnswerId="16522" CreationDate="2015-10-02T18:03:48.080" Score="1" ViewCount="10428" Body="&lt;p&gt;I want to know how exactly do I program (upload arduino sketches) an ATMEGA2560 which is boot loaded with an Arduino Bootloader using a FTDI programmer and an Arduino IDE, is there any capacitors/resistors required?  &lt;/p&gt;&#xA;" OwnerUserId="13744" OwnerDisplayName="Rakshith Gb" LastEditorUserId="10794" LastEditDate="2015-10-03T05:10:32.110" LastActivityDate="2020-04-02T13:45:43.353" Title="Programming an ATMEGA2560 using FTDI" Tags="|arduino-mega|uploading|bootloader|ide|ftdi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16508" PostTypeId="2" ParentId="16506" CreationDate="2015-10-02T20:28:31.897" Score="1" Body="&lt;p&gt;There are plenty of serial flash products available.  They are generally SPI chips (8 pin) and range in sizes up to about 64MBit (8MByte).  And they're cost effective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a selection: &lt;a href=&quot;http://www.microchip.com/pagehandler/en-us/products/memory/flashmemory/sfhome.html&quot; rel=&quot;nofollow&quot;&gt;http://www.microchip.com/pagehandler/en-us/products/memory/flashmemory/sfhome.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plenty of other manufacturers as well.  Your best bet is to hit your favourite online electronics store (mouser, digikey, etc) and shop around.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-02T20:28:31.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16509" PostTypeId="1" AcceptedAnswerId="16511" CreationDate="2015-10-02T20:37:37.630" Score="0" ViewCount="827" Body="&lt;p&gt;So I'm trying to understand a read method. In this method, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Read data from buffer&#xA;int SoftwareSerial::read()&#xA;{&#xA;if (!isListening())&#xA;  return -1;&#xA;&#xA;// Empty buffer?&#xA;if (_receive_buffer_head == _receive_buffer_tail)&#xA;  return -1;&#xA;&#xA;// Read from &quot;head&quot;&#xA;uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte&#xA;_receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;&#xA;return d;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it looks it receives buffer head. But in the write only a 1 or 0 is being sent as the data packet's header. Nothing else. So how does the arduino know how big of an buffer to create?&#xA;also, there is no stop bit being transmitted, so how does it look at a buffer tail? Or is this all created regardless of the transmitter? and then, all the values just get read into the buffer, and then read again from there? Also I don't see a delay in this read method. Wouldn't that cause errors in the data flow? How is that being handled? &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-10-02T20:43:14.917" LastActivityDate="2016-03-31T20:04:40.300" Title="how to create a specific buffer when there is no buffer message in the data packet?" Tags="|arduino-uno|c++|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16511" PostTypeId="2" ParentId="16509" CreationDate="2015-10-02T20:43:05.407" Score="1" Body="&lt;p&gt;That read method just retrieves bytes that have already been received from an internal buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buffer is pre-allocated to a specific size (64 bytes) and that is how many bytes can be received before you start to lose data as it gets overwritten.  You have to be sure to read your data from the buffer before it overflows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function that actually receives each UART bit from the IO port, builds them into bytes, and stores them in the internal buffer, is this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SoftwareSerial::recv()&#xA;{&#xA;&#xA;#if GCC_VERSION &amp;lt; 40302&#xA;// Work-around for avr-gcc 4.3.0 OSX version bug&#xA;// Preserve the registers that the compiler misses&#xA;// (courtesy of Arduino forum user *etracer*)&#xA;  asm volatile(&#xA;    &quot;push r18 \n\t&quot;&#xA;    &quot;push r19 \n\t&quot;&#xA;    &quot;push r20 \n\t&quot;&#xA;    &quot;push r21 \n\t&quot;&#xA;    &quot;push r22 \n\t&quot;&#xA;    &quot;push r23 \n\t&quot;&#xA;    &quot;push r26 \n\t&quot;&#xA;    &quot;push r27 \n\t&quot;&#xA;    ::);&#xA;#endif&#xA;&#xA;  uint8_t d = 0;&#xA;&#xA;  // If RX line is high, then we don't see any start bit&#xA;  // so interrupt is probably not for us&#xA;  if (_inverse_logic ? rx_pin_read() : !rx_pin_read())&#xA;  {&#xA;    // Wait approximately 1/2 of a bit width to &quot;center&quot; the sample&#xA;    tunedDelay(_rx_delay_centering);&#xA;    DebugPulse(_DEBUG_PIN2, 1);&#xA;&#xA;    // Read each of the 8 bits&#xA;    for (uint8_t i=0x1; i; i &amp;lt;&amp;lt;= 1)&#xA;    {&#xA;      tunedDelay(_rx_delay_intrabit);&#xA;      DebugPulse(_DEBUG_PIN2, 1);&#xA;      uint8_t noti = ~i;&#xA;      if (rx_pin_read())&#xA;        d |= i;&#xA;      else // else clause added to ensure function timing is ~balanced&#xA;        d &amp;amp;= noti;&#xA;    }&#xA;&#xA;    // skip the stop bit&#xA;    tunedDelay(_rx_delay_stopbit);&#xA;    DebugPulse(_DEBUG_PIN2, 1);&#xA;&#xA;    if (_inverse_logic)&#xA;      d = ~d;&#xA;&#xA;    // if buffer full, set the overflow flag and return&#xA;    if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head)&#xA;    {&#xA;      // save new data in buffer: tail points to where byte goes&#xA;      _receive_buffer[_receive_buffer_tail] = d; // save new byte&#xA;      _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;&#xA;    }&#xA;    else&#xA;    {&#xA;#if _DEBUG // for scope: pulse pin as overflow indictator&#xA;      DebugPulse(_DEBUG_PIN1, 1);&#xA;#endif&#xA;      _buffer_overflow = true;&#xA;    } &#xA;  } &#xA;&#xA;#if GCC_VERSION &amp;lt; 40302&#xA;// Work-around for avr-gcc 4.3.0 OSX version bug&#xA;// Restore the registers that the compiler misses&#xA;  asm volatile(&#xA;    &quot;pop r27 \n\t&quot;&#xA;    &quot;pop r26 \n\t&quot;&#xA;    &quot;pop r23 \n\t&quot;&#xA;    &quot;pop r22 \n\t&quot;&#xA;    &quot;pop r21 \n\t&quot;&#xA;    &quot;pop r20 \n\t&quot;&#xA;    &quot;pop r19 \n\t&quot;&#xA;    &quot;pop r18 \n\t&quot;&#xA;    ::);&#xA;#endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To show you how the timing of the routine works, here is a little diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HIwQ3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HIwQ3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-31T20:04:40.300" LastActivityDate="2016-03-31T20:04:40.300" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16512" PostTypeId="1" AcceptedAnswerId="16577" CreationDate="2015-10-02T20:57:58.243" Score="0" ViewCount="577" Body="&lt;p&gt;I've had a project running successfully for months on an Arduino Mega, and today I tried to swap the Mega for a Due to increase the speed. After making the change, the entire project is working successfully except for a strange problem with the pushbuttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 5 momentary pushbuttons that toggle different controls (they simply send a wireless signal to toggle different AC outlets). After moving the project to the Due, when 1 button is pressed, it ends up toggling 2 other buttons at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally I was using the internal pullups to detect when the buttons were low, but also I've tried connecting them to the Due's 3.3v to detect when they're high, and both times I experienced the exact same behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any reason why there would be this difference in pushbutton-reading behavior between the Mega and the Due? Could it be that the Due is more sensitive to noise? How could I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wires connecting to the pushbuttons run about 8 feet. I never had a problem with this setup while running the sketch on the Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the relevant code that detects button presses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;RCSwitch.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Event.h&amp;gt;&#xA;#include &amp;lt;Timer.h&amp;gt;&#xA;#include &amp;lt;dht.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;&#xA;const byte nl1ButtonPin = 40, nl2ButtonPin = 42, nl3ButtonPin = 44,  pumpButtonPin = 5, irButtonPin = 27,&#xA;&#xA;unsigned long buttonPressTime1, buttonPressTime2, buttonPressTime3, buttonPressTime4, buttonPressTime5;  // when the switch last changed state&#xA;&#xA;byte oldButtonState1 = HIGH, oldButtonState2 = HIGH, oldButtonState3 = HIGH, oldButtonState4 = HIGH, oldButtonState5 = HIGH;&#xA;&#xA;const unsigned long debounceTime = 100;&#xA;&#xA;void setup() {&#xA;  pinMode(nl1ButtonPin, INPUT_PULLUP); pinMode(nl2ButtonPin, INPUT_PULLUP); pinMode(nl3ButtonPin, INPUT_PULLUP); pinMode(pumpButtonPin, INPUT_PULLUP); pinMode(irButtonPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA; byte buttonState1 = digitalRead(nl1ButtonPin);&#xA;  if (buttonState1 != oldButtonState1)&#xA;  {&#xA;    if (millis () - buttonPressTime1 &amp;gt;= debounceTime)&#xA;    {&#xA;  buttonPressTime1 = millis ();  // when we closed the switch&#xA;  oldButtonState1 = buttonState1;  // remember for next time&#xA;  if (buttonState1 == LOW) {&#xA;    Serial.println(&quot;button1 LOW!&quot;);&#xA;    toggleLight1();&#xA;   }&#xA; }&#xA;}&#xA;&#xA;   byte buttonState2 = digitalRead(nl2ButtonPin);&#xA;  if (buttonState2 != oldButtonState2)&#xA;  {&#xA;    if (millis () - buttonPressTime2 &amp;gt;= debounceTime)&#xA;    {&#xA;      buttonPressTime2 = millis ();  // when we closed the switch&#xA;      oldButtonState2 = buttonState2;  // remember for next time&#xA;      if (buttonState2 == LOW) {&#xA;        Serial.println(&quot;button2 LOW!&quot;);&#xA;        toggleLight2();&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;byte buttonState3 = digitalRead(nl3ButtonPin);&#xA;if (buttonState3 != oldButtonState3)&#xA;{&#xA;  if (millis () - buttonPressTime3 &amp;gt;= debounceTime)&#xA;  {&#xA;    buttonPressTime3 = millis ();  // when we closed the switch&#xA;    oldButtonState3 = buttonState3;  // remember for next time&#xA;    if (buttonState3 == LOW) {&#xA;      Serial.println(&quot;button3 LOW!&quot;);&#xA;      toggleLight3();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;byte buttonState4 = digitalRead(pumpButtonPin);&#xA;if (buttonState4 != oldButtonState4)&#xA;{&#xA;  if (millis () - buttonPressTime4 &amp;gt;= debounceTime)&#xA;  {&#xA;    buttonPressTime4 = millis ();  // when we closed the switch&#xA;    oldButtonState4 = buttonState4;  // remember for next time&#xA;    if (buttonState4 == LOW) {&#xA;      Serial.println(&quot;button4 LOW!&quot;);&#xA;      togglePump();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;byte buttonState5 = digitalRead(irButtonPin);&#xA;if (buttonState5 != oldButtonState5)&#xA;{&#xA;  if (millis () - buttonPressTime5 &amp;gt;= debounceTime)&#xA;  {&#xA;    buttonPressTime5 = millis ();  // when we closed the switch&#xA;    oldButtonState5 = buttonState5;  // remember for next time&#xA;    if (buttonState5 == LOW) {&#xA;      Serial.println(&quot;button5 LOW!&quot;);&#xA;      toggleHeater();&#xA;    }&#xA;   }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the serial output, pressing one button shows 2 other buttons as low. So, for example, pressing button2 might show: &quot;Button2 LOW!, Button4 LOW!, Button1 LOW!&quot;. There doesn't seem to be any clear patterns with which other 2 buttons get simultaneously pressed. Remember that this exact same code and hardware setup was working perfectly for months on the Mega, which makes me believe maybe it's something related to the Due (maybe 3.3v, maybe stronger PU resistors, etc).&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="11174" LastEditDate="2015-10-03T14:09:03.853" LastActivityDate="2015-10-06T01:36:27.893" Title="After moving project from Arduino Mega to Due, pushbuttons now erratically toggle multiple buttons" Tags="|arduino-mega|arduino-due|button|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16514" PostTypeId="1" CreationDate="2015-10-02T21:15:55.010" Score="3" ViewCount="2126" Body="&lt;p&gt;I'm trying to connect a WiFi module, ESP8266-01 to an Arduino Uno. But, as I've understood, this module will only work with 3.3 V. Since all of the data pins use 5 V, one of the solutions is to use a voltage regulator, such as LM2596.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Does anyone know if there already exists a tutorial that describes the way this WiFi module can be connected to an Arduino Uno?&lt;/li&gt;&#xA;&lt;li&gt;For a simple server, would I need to use several voltage regulators (since there are quite many pins)?&lt;/li&gt;&#xA;&lt;li&gt;Since Rx is the receiver, it would not need a voltage regulator because that pin can handle up to 5 volts? &lt;/li&gt;&#xA;&lt;li&gt;Is there any need for an external power source, such as a cell?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7753" LastEditorUserId="653" LastEditDate="2015-10-02T21:52:15.150" LastActivityDate="2016-07-13T02:44:56.360" Title="WiFi module ESP8266 + Arduino Uno" Tags="|arduino-uno|wifi|pins|voltage-level|esp8266|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16515" PostTypeId="2" ParentId="16500" CreationDate="2015-10-02T21:42:55.927" Score="1" Body="&lt;pre&gt;&lt;code&gt;// Write each of the 8 bits&#xA;for (uint8_t i = 8; i &amp;gt; 0; --i)&#xA;{&#xA;  if (b &amp;amp; 1) // choose bit&#xA;    *reg |= reg_mask; // send 1&#xA;  else&#xA;    *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;  tunedDelay(delay);&#xA;  b &amp;gt;&amp;gt;= 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In that block of code, I am not quite sure why they are doing b &amp;amp; 1. Are they just anding the whole byte with 1? If so, then why comment it as &quot;choose byte&quot; and inside the if-else blocks,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The comment is: choose &lt;strong&gt;bit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, variable &lt;code&gt;b&lt;/code&gt; is the &lt;strong&gt;byte&lt;/strong&gt; that is being set. Now, since async serial sends the least-significant bit first, at the start of the loop of 8 iterations, it takes the low-order bit to see if it is set or not:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (b &amp;amp; 1) // choose bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If set, it sets the output port to HIGH (by ORing in the appropriate mask to the appropriate register), otherwise it sets the port to LOW (by ANDing in the appropriate inverted mask to the appropriate register). The inverted mask would be set to every bit &lt;strong&gt;but&lt;/strong&gt; one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now look at this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  b &amp;gt;&amp;gt;= 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That shifts the bits right one, throwing away the low-order bit. Now what was previously the second lowest-order bit is now the low-order bit. Then the loop repeats. Now the next bit is sent. And so on for 8 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine we were sending 0x39 (0b00111001). For the 8 iterations of the loop we would see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00111001  --&amp;gt; 1 sent, then &quot;b&quot; shifted right one&#xA;00011100  --&amp;gt; 0 sent, then &quot;b&quot; shifted right one&#xA;00001110  --&amp;gt; 0 sent, then &quot;b&quot; shifted right one&#xA;00000111  --&amp;gt; 1 sent, then &quot;b&quot; shifted right one&#xA;00000011  --&amp;gt; 1 sent, then &quot;b&quot; shifted right one&#xA;00000001  --&amp;gt; 1 sent, then &quot;b&quot; shifted right one&#xA;00000000  --&amp;gt; 0 sent, then &quot;b&quot; shifted right one&#xA;00000000  --&amp;gt; 0 sent, then &quot;b&quot; shifted right one&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that the right-most bit is sent (the low-order bit) and then &lt;code&gt;b&lt;/code&gt; is shifted right (introducing zeroes at the left), until all 8 bits are sent.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-02T21:42:55.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16516" PostTypeId="2" ParentId="16514" CreationDate="2015-10-02T22:01:55.573" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Since all of the data pins use 5 V, one of the solutions is to use a voltage regulator, such as LM2596.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You do not want a voltage regulator you need a &lt;strong&gt;level shifter&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can buy them cheaply or make them up with a transistor or MOSFET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I gather the ESP8266 has a Tx (transmit) &lt;strong&gt;to&lt;/strong&gt; the Arduino. You probably don't need to level-shift that, as the Arduino Uno will interpret 3V upwards as a HIGH. For the Rx (receive) &lt;strong&gt;from&lt;/strong&gt; the Arduino you need to level-shift the data pin (possibly a voltage-divider might work) since the 5V from the Arduino needs to be converted down to 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 Vcc and CH_PD can go to the Arduino &lt;strong&gt;3.3V&lt;/strong&gt; pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer - I haven't done this, I am summarizing what I read on various web pages. Read some of the answers on the pages you get when you do a Google search for more details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;Voltage divider - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/42727/what-is-the-difference-between-level-shifter-voltage-regulator-and-dc-dc-conver&quot;&gt;Level shifter - StackExchange&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow noreferrer&quot;&gt;SparkFun Logic Level Converter - Bi-Directional&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/757&quot; rel=&quot;nofollow noreferrer&quot;&gt;4-channel I2C-safe Bi-directional Logic Level Converter - Adafruit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/datasheets/an97055.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bi-directional level shifter for I²C-bus and other systems - PDF&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.esp8266.com/viewforum.php?f=25&quot; rel=&quot;nofollow noreferrer&quot;&gt;ESP8266 Community Forum&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-10-02T22:51:53.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16517" PostTypeId="1" CreationDate="2015-10-02T22:54:29.233" Score="2" ViewCount="3434" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7fein.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7fein.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;I am using the Arduino Starter Kit and I am on project 8. The picture of the sketch in the book is not clear because it shows the tilt sensor seemingly resting sideways, which is not the way that it connects. If you insert the pins into the board the sensor will always be standing and there will be no way to turn it. I was thinking you might have to solder wires to the pins. Does anyone know? &#xA;-Thanks &#xA;Edit: Perhaps this picture will help:&lt;/p&gt;&#xA;" OwnerUserId="13748" LastEditorUserId="13748" LastEditDate="2015-10-03T02:20:17.167" LastActivityDate="2018-01-03T07:08:35.927" Title="Do I need to solder wires to my tilt sensor?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16519" PostTypeId="2" ParentId="16517" CreationDate="2015-10-03T01:47:56.140" Score="1" Body="&lt;p&gt;I don't have the starter kit but I have a tilt ball sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oEmYQ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oEmYQ.jpg&quot; alt=&quot;Tilt ball sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My guess is that there is a ball inside it, and it connects the wires, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VjBDl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VjBDl.png&quot; alt=&quot;Tilt ball sensor design&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is confirmed by measurement.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suggest you either solder wires to it, or push the wires into your breadboard. As you can imagine from the diagram, the contacts will be closed if the ball (or mercury or whatever it is) is downwards. In other words, if the leads are facing down. As you tilt it, the ball will move away from the two wires, breaking the connection. You may have to tilt it quite a lot for this to happen.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see from the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoStarterKit&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Starter Kit page&lt;/a&gt; that the tilt sensor works like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ghQnl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ghQnl.png&quot; alt=&quot;Arduino Starter Kit tilt sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shows that my guess was pretty accurate. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are four pins, so I imagine that the ball would connect four of them if held upright, and various combinations if tilted forwards or sideways.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you insert the pins into the board the sensor will always be standing and there will be no way to turn it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, you could tilt the breadboard, yes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I agree that if you want to tilt just the sensor, then soldering wires to it would seem quite sensible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the starter kit is there to show you the concepts. There is nothing stopping you tilting the entire breadboard to see how it works. In practice you would mount the sensor in such a way that it activated when moved from position A to position B, whatever that is.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-03T06:40:12.213" LastActivityDate="2015-10-03T06:40:12.213" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16520" PostTypeId="1" CreationDate="2015-10-03T02:56:32.767" Score="0" ViewCount="7075" Body="&lt;p&gt;Please help me w/ my 2.4 mcufriend TFT on my Mega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've followed any instructions I can find, including: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/1138/2-4-tft-lcd-shield-isnt-working-on-arduino-mega/4537#4537&quot;&gt;2.4&amp;quot; TFT LCD Shield isn&amp;#39;t working on Arduino Mega&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still get a show white screen. I wonder if my TFT is different or is it broken? Mine looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R9dzG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R9dzG.jpg&quot; alt=&quot;TFT image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did run the example code from SWtft. I got this output on serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TFT LCD test&#xA;&#xA;LCD driver chip: 6TFT LCD test&#xA;LCD driver chip: 6767&#xA;Benchmark                Time (microseconds)&#xA;Screen fill              1786024&#xA;Text                     413024&#xA;Lines                    2569212&#xA;Horiz/Vert Lines         226196&#xA;Rectangles (outline)     176972&#xA;Rectangles (filled)      4682244&#xA;Circles (filled)         2703104&#xA;Circles (outline)        1119540&#xA;Triangles (outline)      815028&#xA;Triangles (filled)       2867288&#xA;Rounded rects (outline)  469268&#xA;Rounded rects (filled)   5733992&#xA;Done!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13750" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2024-03-01T15:52:58.947" Title="mcufriend 2.4 tft mega 2560" Tags="|arduino-mega|shields|lcd|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16521" PostTypeId="2" ParentId="16506" CreationDate="2015-10-03T03:58:57.727" Score="2" Body="&lt;p&gt;You may not want to hear this, but the cheapest option would be an SD card, or a micro-SD card. You could solder it into place, thus making it quite hard for the end user to take it out and plug it into a reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you had this micro-SD card glued onto your board (making it hard to remove in the first place):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DpWka.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DpWka.jpg&quot; alt=&quot;Micro-SD card&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It isn't particularly obvious what it is, unless you recognize the shape. You could cover it with a blob of plastic to hide that. Then with the SPI wires soldered to the contacts, removing would be even harder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That gives you gigabytes of storage, a file system, the works. And all for a few dollars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A technically sophisticated user could probably prise it loose and get at the data (although if you used strong glue this could be quite hard) but they could also get at the contents of another storage chip too.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-03T03:58:57.727" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16522" PostTypeId="2" ParentId="16507" CreationDate="2015-10-03T05:09:40.503" Score="1" Body="&lt;p&gt;If you have a bootloader, you just need to connect up four wires from the FTDI cable:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pin 1 (black) -&gt; Ground&lt;/li&gt;&#xA;&lt;li&gt;Pin 2 (CTS)   -&gt; not connected&lt;/li&gt;&#xA;&lt;li&gt;Pin 3 (Vcc)   -&gt; 5V&lt;/li&gt;&#xA;&lt;li&gt;Pin 4 (TxD)   -&gt; Rx (Mega pin D0)&lt;/li&gt;&#xA;&lt;li&gt;Pin 5 (RxD) -&gt; Tx (Mega pin D1)&lt;/li&gt;&#xA;&lt;li&gt;Pin 6 (green) -&gt; not connected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GcK9K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GcK9K.png&quot; alt=&quot;FTDI connections&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will not auto-reset, so you will have to press (and release) the Reset button on the board at the moment that the sketch starts to upload.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to make it auto reset?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What you &lt;em&gt;should&lt;/em&gt; be able to do is connect RTS to Reset on the board, using a 0.1 µF capacitor (in series). I found in practice that this did not bring Reset low enough to trigger it - I'm not sure why, except maybe the board has a stronger pull-up resistor on /RESET than expected. That technique works for me on breadboard Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it didn't work for me, I did not put it in my original answer. You could try that, and if it works, well and good.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-03T06:46:18.153" LastActivityDate="2015-10-03T06:46:18.153" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16523" PostTypeId="2" ParentId="14157" CreationDate="2015-10-03T08:44:41.667" Score="4" Body="&lt;p&gt;I've ben hitting this same problem.&lt;br&gt;&#xA;Some further research on c++ syntax helped me find this clean solution, based on the  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;std::bind syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;server.on(&quot;/&quot;, std::bind(&amp;amp;myClass::handleRoot, this));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13755" LastActivityDate="2015-10-03T08:44:41.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16524" PostTypeId="2" ParentId="16455" CreationDate="2015-10-03T09:38:20.413" Score="1" Body="&lt;p&gt;See, for example, &lt;a href=&quot;https://github.com/adafruit/Adafruit_BMP085_Unified&quot; rel=&quot;nofollow&quot;&gt;Adafruit BMP085 library&lt;/a&gt; (it's work with BMP180 too), function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_BMP085_Unified::getTemperature(float *temp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in file Adafruit_BMP085_u.cpp line 330&lt;/p&gt;&#xA;" OwnerUserId="3109" LastActivityDate="2015-10-03T09:38:20.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16525" PostTypeId="1" CreationDate="2015-10-03T14:26:57.567" Score="0" ViewCount="8161" Body="&lt;p&gt;I am wondering why should I put a 10K resistor with an LDR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I put a &quot;stronger&quot; resistor with another resistor (in this case the LDR), I'd get a lower voltage, and then I'd, too, get a lower value in the &lt;code&gt;analogRead()&lt;/code&gt;. I'd like to know in what I'm doing wrong. Can someone help me?&lt;/p&gt;&#xA;" OwnerUserId="13758" LastEditorUserId="4628" LastEditDate="2015-11-22T14:51:26.393" LastActivityDate="2015-12-22T19:28:29.233" Title="Why should I put a 10K resistor with an LDR?" Tags="|sensors|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16527" PostTypeId="2" ParentId="16504" CreationDate="2015-10-03T16:52:14.003" Score="3" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  pinMode(0,OUTPUT); //IB1&#xA;  pinMode(1,OUTPUT); //IA1&#xA;//  pinMode(2,OUTPUT); //IB2&#xA;//  pinMode(3,OUTPUT); //IA2&#xA;  pinMode(4,OUTPUT); //RGB red&#xA;  pinMode(5,OUTPUT); //RGB green&#xA;  pinMode(6,OUTPUT); //RGB blue&#xA;  boolean motorOn = false;&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  digitalWrite(0,motorOn);&#xA;  if(motorOn) {&#xA;    digitalWrite(4,HIGH);  // red on&#xA;    digitalWrite(5,LOW);   // green off&#xA;    digitalWrite(6,LOW);   // blue off&#xA;  }&#xA;    digitalWrite(4,LOW);   // red off&#xA;    digitalWrite(5,HIGH);  // green on&#xA;    digitalWrite(6,LOW);   // blue off&#xA;  }&#xA;  delay(1000);             // wait&#xA;  motorOn = !motorOn;      // toggle the status of the motor.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above has the disadvantage that the on-time is the same as the off-time. We can make the code more flexible and a little more like your original by doing the LED related code in a subroutine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  pinMode(0,OUTPUT);   //IB1&#xA;  pinMode(1,OUTPUT);   //IA1&#xA;//  pinMode(2,OUTPUT); //IB2&#xA;//  pinMode(3,OUTPUT); //IA2&#xA;  pinMode(4,OUTPUT);   //RGB red&#xA;  pinMode(5,OUTPUT);   //RGB green&#xA;  pinMode(6,OUTPUT);   //RGB blue&#xA;  boolean motorOn = false;&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  motorOn = false;&#xA;  digitalWrite(0,motorOn);&#xA;  updateLEDs();            // update the LED status&#xA;  delay(1000);             // wait&#xA;  motorOn = true;          // toggle the status of the motor.&#xA;  digitalWrite(0,motorOn);&#xA;  updateLEDs();            // update the LED status&#xA;  delay(750);              // wait a different time&#xA;}&#xA;&#xA;void updateLEDs(){&#xA;  // This routine updates the LEDs based on status of motorOn.&#xA;  if(motorOn) {&#xA;    digitalWrite(4,HIGH);  // red on&#xA;    digitalWrite(5,LOW);   // green off&#xA;    digitalWrite(6,LOW);   // blue off&#xA;  }&#xA;    digitalWrite(4,LOW);   // red off&#xA;    digitalWrite(5,HIGH);  // green on&#xA;    digitalWrite(6,LOW);   // blue off&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13749" LastEditorUserId="13749" LastEditDate="2015-10-04T09:04:34.587" LastActivityDate="2015-10-04T09:04:34.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16530" PostTypeId="1" AcceptedAnswerId="26713" CreationDate="2015-10-03T20:24:17.803" Score="3" ViewCount="3130" Body="&lt;p&gt;It seems to me like Photon is 'winning' on the price front and ease of programming and of course the cheap wifi connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize the cloud portion (even the local cloud server) could be considered a disadvantage, but what about things like ability to drive dc/stepper motors or some exotic sensor? Perhaps not enough analog and/or digital pins? etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One disadvantage I can think of is the lack of resources whereas the Arduino has a ton of references online with working with all kinds of motors and sensors. &lt;/p&gt;&#xA;" OwnerUserId="13767" LastActivityDate="2016-07-26T08:54:46.300" Title="Any disadvantages on using Particle Photon over an Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16532" PostTypeId="2" ParentId="16525" CreationDate="2015-10-03T21:56:52.447" Score="1" Body="&lt;p&gt;LDRs themselves come in a considerable range of resistances. Search LDR specs and you will see what I mean. For example, from eBay I found one:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Bright Resistance(10Lux)(KΩ):20-230&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Dark Resistance: 2 MΩ&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This particular one, for example, seems to range from around 20k to 2M ohms. A reasonable series resistor would then seem to be somewhere in the middle of that range, otherwise all your readings would be skewed at one end of the scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in this case if you used 10k and the LDR had 20 k resistance in very bright light, then the voltage would be 3.33 V&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;20000 / (20000 + 10000) * 5 = 3.33 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then if it got slightly darker and the LDR was 230 k, you would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;230000 / (230000 + 10000) * 5 = 4.79 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if it was really dark you would get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2000000 / (2000000 + 10000) * 5 = 4.98 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see from those figures that you will never get a reading less than 3.33 V with this particular LDR and a 10k resistor. Thus a higher value resistor would give you a better range of readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this totally depends on what resistance your particular LDR has.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-03T21:56:52.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16533" PostTypeId="1" AcceptedAnswerId="16982" CreationDate="2015-10-03T22:27:41.267" Score="0" ViewCount="298" Body="&lt;p&gt;I'm currently working on a project with the ESP8266 and Arduino Nano, and when I power the device via USB they talk to each other via SoftwareSerial just fine. I use the Arduino IDE Serial Monitor to monitor this communication. But when I power it with a 15 V wall wart to Vin it returns mostly garbage, again I can tell this with the Arduino IDE Serial Monitor (I know I shouldn't connect two power supplies at a time). When powered over 5 V USB everything is great. Why would I have a problem only when connected to an external power supply?&lt;/p&gt;&#xA;" OwnerUserId="13770" LastEditorUserId="26916" LastEditDate="2017-09-09T23:55:12.140" LastActivityDate="2017-09-09T23:55:12.140" Title="SoftwareSerial returns garbage when powered externally" Tags="|arduino-nano|softwareserial|esp8266|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16534" PostTypeId="1" AcceptedAnswerId="16536" CreationDate="2015-10-03T22:57:37.897" Score="0" ViewCount="171" Body="&lt;p&gt;I want to connect an Arduino Nano to an Intel Minnowboard Max (it's like a Raspberry Pi). I know Arduino can draw up to 500 mA current through the USB connection. Since I already need the USB to communicate the Arduino with the Minnowboard, it would be nice to not power the Arduino separately as well. However, I wouldn't want the current the Arduino draws from the Minnowboard to overheat Minnowboard's 2.5A 12V power supply.&#xA;I only have 8 buttons connected to the digital pins of the Arduino Nano. Nano sends the state of the buttons to the Minnowboard via USB (serial). How much current is Arduino drawing in this case?&lt;/p&gt;&#xA;" OwnerUserId="13771" LastActivityDate="2015-10-03T23:14:17.840" Title="how much current does Arduino Nano draw when only using 8 digital pins?" Tags="|serial|usb|arduino-nano|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16536" PostTypeId="2" ParentId="16534" CreationDate="2015-10-03T23:14:17.840" Score="0" Body="&lt;p&gt;I would guess around 50 mA, to power the processor and the USB converter. I notice that &lt;a href=&quot;https://electronics.stackexchange.com/questions/68938/power-consumption-of-arduino-nano-current-draw-low-power&quot;&gt;this question&lt;/a&gt; suggests more like 20 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be certain, you could measure it, but probably 20 to 50 mA would be a ball-park figure.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-10-03T23:14:17.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16538" PostTypeId="1" AcceptedAnswerId="17163" CreationDate="2015-10-04T02:55:04.777" Score="2" ViewCount="93" Body="&lt;p&gt;My mega usb/serial adapter died some time ago, so I bought an external FTDI programer wich I got working on 1.0.1 IDE. I can load any program to the mega, even complex led matrix driver I wrote myself so the ATmega works fine and the external FTDI board does too. Strangely enough I if I want to update the IDE (tried once on 1.0.5 and yesterday downloaded 1.6.5) I get an&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this problem occurs, I see that the programmer board recieves something (it has Rx and Tx LED's) the Mega resets but never sends any data back, which does happen on 1.0.1 IDE.&#xA;This happens on my pc, and on a laptop son no pc related problems.&#xA;I'd keep using this version but now I got an OLED display I want to drive (SSD1306 from waveshare) but I can't compile u8glib on 1.0.1 but I can on 1.6.5, however I can't get a simple blink example to upload with this IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect the DTR pin (reset pin) is handled differently and that makes the mega stay resetting until it times out.&#xA;What can be the problem here? How can I get more info from the console to solve this?&lt;/p&gt;&#xA;" OwnerUserId="13774" LastActivityDate="2015-10-25T00:08:46.437" Title="My mega only works on 1.0.1 IDE" Tags="|arduino-mega|arduino-ide|ftdi|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16539" PostTypeId="1" AcceptedAnswerId="16543" CreationDate="2015-10-04T05:13:18.167" Score="-1" ViewCount="248" Body="&lt;p&gt;I have been successfully programming UNO boards. I wanted to transfer the project to a Pro Mini. I am using a FTDI breakout. It wouldn't show the device port. I found the device driver I was using was supplied by MatterControl. So I updated the driver from FTDI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connected it I see the port available, but cannot program it. I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;not in sync: resp=0x01 avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked in the device manager and see &quot;USB Serial Port (COM5)&quot; and properties shows &quot;This device is working properly.&quot; the provider is FTDI. &lt;/p&gt;&#xA;" OwnerUserId="13330" LastEditorUserId="13330" LastEditDate="2016-04-25T19:17:27.347" LastActivityDate="2017-07-10T22:23:26.910" Title="FTDI breakout connection" Tags="|arduino-pro-mini|ftdi|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16540" PostTypeId="2" ParentId="3286" CreationDate="2015-10-04T07:52:11.077" Score="0" Body="&lt;p&gt;Of course, &lt;code&gt;9&lt;/code&gt; means &lt;code&gt;D9&lt;/code&gt; and not &lt;code&gt;A9&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everytime Arduino projects assign a pin with no prefix, it is denoted as data I/O and if the Analog pins are used then it would say &lt;code&gt;A9&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nRF24L01 handles data I/O and not analog input.&lt;/p&gt;&#xA;" OwnerUserId="13779" LastEditorUserId="6936" LastEditDate="2016-02-01T07:53:10.613" LastActivityDate="2016-02-01T07:53:10.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16541" PostTypeId="2" ParentId="16514" CreationDate="2015-10-04T08:00:37.463" Score="2" Body="&lt;p&gt;Check out the ESP-Link project over on Github. It has a pretty decent implementation of communicating with an Arduino via UART. As mentioned in another comment you will need a 5v-3.3v level shifter. But if you want to make things a little less messy you could just get a 3.3v Arduino mini for probably around the same price as the level shifter. Esp-link is built with the esp-open-sdk so you will have to spend some time setting up the toolchain if you haven't already. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working on a project right now using a Moteino + ESP-12E and it's working great. However I'm planning on porting the RFM69 library and removing the Arduino portion completely. I would recommend doing the same if you can. The link below shows how to use the ESP with a port-expander (using SPI) so you can have more GPIO with the ESP. &#xA;&lt;a href=&quot;https://github.com/MetalPhreak/ESP8266_MCP23S17&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MetalPhreak/ESP8266_MCP23S17&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13780" LastActivityDate="2015-10-04T08:00:37.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16542" PostTypeId="1" AcceptedAnswerId="17074" CreationDate="2015-10-04T10:21:09.460" Score="0" ViewCount="240" Body="&lt;p&gt;I am using a 40v 2amp 3300rpm DC motor for my motor control project via arduino. But i don't know what driver ic to use for driving the motor.any help would be appreciated..&lt;/p&gt;&#xA;" OwnerUserId="13332" LastEditorUserId="13332" LastEditDate="2015-10-05T15:15:39.573" LastActivityDate="2015-10-21T21:35:07.557" Title="What Driver IC to use for 40v 2amp DC motor?" Tags="|motor|" AnswerCount="1" CommentCount="28" ContentLicense="CC BY-SA 3.0" />
  <row Id="16543" PostTypeId="2" ParentId="16539" CreationDate="2015-10-04T13:08:00.793" Score="0" Body="&lt;p&gt;This error can come from a number of sources and you'll find this is a common question on arduino.stackexchange. The most likely reasons are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the board wasn't reset, the bootloader didn't run;&lt;/li&gt;&#xA;&lt;li&gt;Rx &amp;amp; Tx connections between the FTDI and the board may be reversed;&lt;/li&gt;&#xA;&lt;li&gt;Avrdude may be using a different baud rate than the bootloader expects. 57600 baud used to be standard for Atmega328p bootloaders. More recent firmware is using 115200 baud. I've been bitten by this one regularly; my chips have older bootloaders and one of my PCs has a very recent Arduino IDE.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-04T13:08:00.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16544" PostTypeId="1" AcceptedAnswerId="16549" CreationDate="2015-10-04T14:31:47.590" Score="0" ViewCount="89" Body="&lt;p&gt;How can I do this sentence show me in arduino.&quot;WARNING: Category 'USB' in library Mouse/keyboard is not valid.Setting to 'Uncategorized'&lt;/p&gt;&#xA;" OwnerUserId="13783" LastActivityDate="2015-10-04T16:57:07.137" Title="How can I do this sentence show me in arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ClosedDate="2015-10-30T17:21:50.190" ContentLicense="CC BY-SA 3.0" />
  <row Id="16545" PostTypeId="1" CreationDate="2015-10-04T14:45:47.970" Score="0" ViewCount="319" Body="&lt;p&gt;I'm working to make a simple pedometer with Arduino, and after managing to find an algorithm that correctly finds the steps, I added a bluetooth extension (the overly popular and cheap JY-MCU) to check the steps via bluetooth.&lt;/p&gt;&#xA;&lt;p&gt;I am facing a strange issue, though: when the bluetooth device is powered and waiting for a connection (red led blinking) the analog read function that reads data from the accelerometer goes crazy (thus the pedometer finds a step each second or so). When the bluetooth is powered down or connected to a device such as a mobile phone this doesn't happen.&lt;/p&gt;&#xA;&lt;p&gt;Did anyone have this problem before? What could be the issue? My setup is easy, you can see it on the image.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PDG2n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PDG2n.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I had other sensors as well but since the problem stays even when there are only those two connected I posted the bare minimum setup.&#xA;At first I thought I could use some kind of pull-ups to stabilise the signal, but I really have no idea on where to tie them and if they can really be helpful at all...&lt;/p&gt;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="12102" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-01T20:33:57.727" Title="Bluetooth distorts analog read?" Tags="|bluetooth|analogread|accelerometer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16547" PostTypeId="2" ParentId="16545" CreationDate="2015-10-04T15:41:00.243" Score="1" Body="&lt;p&gt;You can try decoupling the power for the bluetooth:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/unllb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/unllb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistor value should be tiny - 10Ω is a good value to use - don't go much higher than that.  The capacitor should be nice and big - I have shown 100µF, but bigger is better - whatever you have that's nice and big.  (Make sure you wire it the right way round - check which pin is marked as -)  You might also want to add a small capacitor (say 100nF) in parallel with the large one. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-04T15:41:00.243" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16548" PostTypeId="1" AcceptedAnswerId="16623" CreationDate="2015-10-04T16:33:03.197" Score="1" ViewCount="823" Body="&lt;p&gt;Now I am &lt;a href=&quot;https://arduino.stackexchange.com/questions/16498/running-arduino-code-for-bluefruit-le-on-bare-atmega328&quot;&gt;Running Arduino code for Bluefruit LE on bare ATMega328&lt;/a&gt; with 8MHz internal clock, with Bluefruit connected, pin 0 and 1 RX/TX unused, and AT42QT1011-based capsense circuits (logical input to pins 1, 2, 3).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There appeared one problem: when I try to switch the device ON (with 4.5 V batteries, but the same with 5 V USB power), it happens only after three or more attempts. Each time &quot;loop&quot; stops after a second of what appears to be correct operation. For example, if I touch one of the capsensors on the first second of operation, and LED is on, it stays ON, which means, the &quot;loop&quot; is not run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to put back the Serial (it was in use in the original echoDemo example), tried to put pollACI after digitalWrite to LED pins. See pin assignments defined in the sketch, those were re-checked with actual circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Measured power supply current and voltage - there were no significant changes in it, even if both LEDs were on. BLE module at startup or while transmitting, was not causing any brownouts. In addition, checked input current and voltage with oscilloscope, and there were no anomalies as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB, this is atmega328, without &quot;p&quot;, so for the record I am using 0x07 efuse, 0xE2 lfuse and 0xD9 hfuse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if the device starts up, it will work fine for at least an hour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be other reasons for such random early failure? (in average, about four attempts to switch on, sometimes starts even on first, second time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch in question:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*********************************************************************&#xA;This is an example for our nRF8001 Bluetooth Low Energy Breakout&#xA;&#xA;  Pick one up today in the adafruit shop!&#xA;  ------&amp;gt; http://www.adafruit.com/products/1697&#xA;&#xA;Adafruit invests time and resources providing this open source code, &#xA;please support Adafruit and open-source hardware by purchasing &#xA;products from Adafruit!&#xA;&#xA;Written by Kevin Townsend/KTOWN  for Adafruit Industries.&#xA;MIT license, check LICENSE for more information&#xA;All text above, and the splash screen below must be included in any redistribution&#xA;*********************************************************************/&#xA;&#xA;//#define F_CPU 8000000&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;Adafruit_BLE_UART.h&quot;&#xA;&#xA;// Connect CLK/MISO/MOSI to hardware SPI&#xA;// e.g. On UNO &amp;amp; compatible: CLK = 13, MISO = 12, MOSI = 11&#xA;#define ADAFRUITBLE_REQ 10&#xA;#define ADAFRUITBLE_RDY 2     // This should be an interrupt pin, on Uno thats #2 or #3&#xA;#define ADAFRUITBLE_RST 7&#xA;&#xA;#define REDLED 8&#xA;#define BLUELED 9&#xA;#define LEFTPAD A2&#xA;#define RIGHTPAD A3&#xA;#define BADPAD A1&#xA;&#xA;Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);&#xA;&#xA;unsigned int leftcnt, rightcnt;&#xA;&#xA;void setup(void)&#xA;{ &#xA;  pinMode(REDLED, OUTPUT);&#xA;  pinMode(BLUELED, OUTPUT);&#xA;  pinMode(LEFTPAD, INPUT_PULLUP);&#xA;  pinMode(RIGHTPAD, INPUT_PULLUP);&#xA;  pinMode(BADPAD, INPUT_PULLUP);&#xA;  digitalWrite(BLUELED, LOW);&#xA;  digitalWrite(REDLED, LOW);        &#xA;  delay(300);&#xA;  BTLEserial.setDeviceName(&quot;MYUART&quot;); /* 7 characters max! */&#xA;  BTLEserial.begin();&#xA;  digitalWrite(REDLED, HIGH);        &#xA;  delay(300);&#xA;  digitalWrite(BLUELED, HIGH);&#xA;  leftcnt = 0;&#xA;  rightcnt = 0;&#xA;}&#xA;&#xA;aci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED;&#xA;&#xA;void loop()&#xA;{&#xA;  BTLEserial.pollACI();&#xA;&#xA;  if (digitalRead(LEFTPAD)) {&#xA;    leftcnt++;&#xA;    digitalWrite(BLUELED, LOW);&#xA;  } else {&#xA;    leftcnt = 0;&#xA;    digitalWrite(BLUELED, HIGH);&#xA;  }&#xA;  if (digitalRead(RIGHTPAD)) {&#xA;    rightcnt++;&#xA;    digitalWrite(REDLED, LOW);&#xA;  } else {&#xA;    rightcnt = 0;&#xA;    digitalWrite(REDLED, HIGH);        &#xA;  }&#xA;&#xA;  aci_evt_opcode_t status = BTLEserial.getState();&#xA;&#xA;  if (status == ACI_EVT_CONNECTED) {&#xA;    boolean inp = false;&#xA;    while (BTLEserial.available()) {&#xA;      char c = BTLEserial.read();&#xA;      inp = true;&#xA;    }&#xA;    if (inp) {&#xA;      if (leftcnt &amp;gt; 5) {&#xA;        BTLEserial.print(&quot;LEFT&quot;);&#xA;      }&#xA;      if (rightcnt &amp;gt; 5) {&#xA;        BTLEserial.print(&quot;RIGHT&quot;);&#xA;      }&#xA;      if (digitalRead(BADPAD)) {&#xA;        BTLEserial.print(&quot;CENTRAL&quot;);&#xA;      }     &#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: MCU's reset pin is pulled-up by a resistor. Bluefruit's RST connected to PD7 on atmega328 (also known as arduino digital pin 7). Also, 3.3 uF capacitor on the power lines near MCU's IC. (there are more near capsense circuits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I disconnect Bluefruit's power, the rest of the circuit (LEDs showing cap sensors state) works without failures after startup. So it looks like under some circumstances, control never leaves BLE code to return to the loop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;: Found long list of reset causes (not sure yet whether relevant here): &lt;a href=&quot;https://stackoverflow.com/questions/23377948/arduino-avr-atmega-microcontroller-random-resets-jumps-or-variable-data-corrup&quot;&gt;Arduino/AVR ATmega microcontroller, random resets, jumps or variable/data corruption ...&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 3&lt;/strong&gt;: Added two 100nF bypass capacitors near GND / VCC pins on both sides. The problem is still there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 4&lt;/strong&gt;: Performed all kinds of experiments, placing BLE module's power lines in different places, with different capacitors. Only in the case of separate power (common ground) the problems were different (but may be due to different times of turning module and MCU on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 5&lt;/strong&gt;: May be relevant or not, but when I run MCU on 1MHz (8 MHz internal clock, divided by 8 - lfuse 0x62), success rate is better than 70%. The speed seem to be enough for my application, but of course near 100% turn-on success should be achieved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MAY BE IMPORTANT&lt;/strong&gt;: I have added watchdog to sketch (thanks to the &quot;Make: Sensors&quot; book by Karvinen &amp;amp; Karvinen, Valtokari):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  WDTCSR |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE);&#xA;  WDTCSR = 1&amp;lt;&amp;lt;WDP0 | 1&amp;lt;&amp;lt;WDP3;&#xA;  WDTCSR |= _BV(WDIE);&#xA;  MCUSR &amp;amp;= ~( 1 &amp;lt;&amp;lt; WDRF);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the respective ISR red led is turned on or off once in about 8 seconds or so. And ISR code works (thus, MCU works all the time too, right?), even though the &quot;loop&quot; runs no longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this still be attributed to trouble with power or is it more likely control flow is stuck somewhere in the BLE library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: Well... As advised here, while trying out Serial (via microbot USB adapter), I understood, that it does not work reliably (if at all, sometimes eats characters, prints garbage, ...). Not sure whether SPI is sensitive to clock accuracy, but if it is, it may be the problem. Also, the circuit turns on always when powered from USB3 port 5V.&lt;/p&gt;&#xA;" OwnerUserId="12167" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-10-07T17:17:10.920" Title="ATMega328 + Bluefruit LE stops working soon after power on (not consistently)" Tags="|bluetooth|atmega328|adafruit|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16549" PostTypeId="2" ParentId="16544" CreationDate="2015-10-04T16:57:07.137" Score="1" Body="&lt;p&gt;Your question is unclear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;Mouse and Keyboard libraries&lt;/a&gt; are suitable for use with Arduino Due and Zero boards, or with 32u4-based boards like Arduino Leonardo or Micro.   They are not relevant when using an Uno.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-04T16:57:07.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16550" PostTypeId="1" CreationDate="2015-10-04T18:51:52.560" Score="3" ViewCount="318" Body="&lt;p&gt;I have Arduino Due on SAM3x8e. I'm on Ubuntu 14.04. Before today I uploaded firmware via terminal using those commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ stty -F /dev/ttyACM0 speed 1200 cs8 -cstopb -parenb&#xA;$ /home/q/apps/devel/arduino/arduino-1.5.7/hardware/tools/bossac --port=ttyACM0 -U false -e -w -v -b /home/q/work/gk/j-v2/embedded/smib/Release/smib.bin -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It was good, but now it stopped working. Bossac just hangs up '-d' displays nothing. That is all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded arduino IDE 1.6.5, but this doesn't matter. In ide's console I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 11,000 bytes (2%) of program storage space. Maximum is 524,288 bytes.&#xA;Forcing reset using 1200bps open/close on port /dev/ttyACM0&#xA;/home/q/.arduino15/packages/arduino/tools/bossac/1.3a-arduino/bossac -i -d --port=ttyACM0 -U false -e -w -v -b /tmp/build238086227206829290.tmp/AnalogReadSerial.cpp.bin -R&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It sticks, no leds blinking on Arduino board. It seems it actually hangs up, due to it loads 99% of CPU... May be Ubuntu update caused this issue...?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;dmesg&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 5168.658692] usb 3-3: new full-speed USB device number 7 using xhci_hcd&#xA;[ 5168.676969] usb 3-3: New USB device found, idVendor=2341, idProduct=003d&#xA;[ 5168.676979] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[ 5168.676985] usb 3-3: Product: Arduino Due Prog. Port&#xA;[ 5168.676989] usb 3-3: Manufacturer: Arduino (www.arduino.cc)&#xA;[ 5168.676994] usb 3-3: SerialNumber: 75438313633351A07051&#xA;[ 5168.677225] usb 3-3: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes&#xA;[ 5168.677652] cdc_acm 3-3:1.0: ttyACM0: USB ACM device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;syslog&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Oct  4 21:49:01 4xybook kernel: [ 5356.553290] usb 3-3: new full-speed USB device number 8 using xhci_hcd&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571623] usb 3-3: New USB device found, idVendor=2341, idProduct=003d&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571635] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571643] usb 3-3: Product: Arduino Due Prog. Port&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571649] usb 3-3: Manufacturer: Arduino (www.arduino.cc)&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571655] usb 3-3: SerialNumber: 75438313633351A07051&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.571923] usb 3-3: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes&#xA;Oct  4 21:49:01 4xybook kernel: [ 5356.572506] cdc_acm 3-3:1.0: ttyACM0: USB ACM device&#xA;Oct  4 21:49:01 4xybook mtp-probe: checking bus 3, device 8: &quot;/sys/devices/pci0000:00/0000:00:14.0/usb3/3-3&quot;&#xA;Oct  4 21:49:01 4xybook mtp-probe: bus: 3, device: 8 was not an MTP device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lsusb&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 001 Device 004: ID 8087:07da Intel Corp. &#xA;Bus 001 Device 003: ID 064e:c336 Suyin Corp. &#xA;Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 004 Device 002: ID 152d:0567 JMicron Technology Corp. / JMicron USA Technology Corp. &#xA;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&#xA;Bus 003 Device 008: ID 2341:003d Arduino SA &#xA;Bus 003 Device 002: ID 1a2c:0e24 China Resource Semico Co., Ltd &#xA;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be really appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;strace gives this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;execve(&quot;/home/q/apps/devel/arduino/arduino-1.5.7/hardware/tools/bossac&quot;, [&quot;/home/q/apps/devel/arduino/ardui&quot;..., &quot;--port=ttyACM0&quot;, &quot;-U&quot;, &quot;false&quot;, &quot;-e&quot;, &quot;-w&quot;, &quot;-v&quot;, &quot;-b&quot;, &quot;-d&quot;, &quot;/home/q/work/gamekeeper/jackpot-&quot;..., &quot;-R&quot;], [/* 78 vars */]) = 0&#xA;brk(0)                                  = 0x22a5000&#xA;access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)&#xA;mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f468e385000&#xA;access(&quot;/etc/ld.so.preload&quot;, R_OK)      = -1 ENOENT (No such file or directory)&#xA;open(&quot;/etc/ld.so.cache&quot;, O_RDONLY|O_CLOEXEC) = 3&#xA;fstat(3, {st_mode=S_IFREG|0644, st_size=169535, ...}) = 0&#xA;mmap(NULL, 169535, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f468e35b000&#xA;close(3)                                = 0&#xA;access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)&#xA;open(&quot;/usr/lib/x86_64-linux-gnu/libstdc++.so.6&quot;, O_RDONLY|O_CLOEXEC) = 3&#xA;read(3, &quot;\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&amp;gt;\0\1\0\0\0 \266\5\0\0\0\0\0&quot;..., 832) = 832&#xA;fstat(3, {st_mode=S_IFREG|0644, st_size=979056, ...}) = 0&#xA;mmap(NULL, 3159040, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f468de61000&#xA;mprotect(0x7f468df47000, 2093056, PROT_NONE) = 0&#xA;mmap(0x7f468e146000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe5000) = 0x7f468e146000&#xA;mmap(0x7f468e150000, 82944, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f468e150000&#xA;close(3)                                = 0&#xA;access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)&#xA;open(&quot;/lib/x86_64-linux-gnu/libgcc_s.so.1&quot;, O_RDONLY|O_CLOEXEC) = 3&#xA;read(3, &quot;\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&amp;gt;\0\1\0\0\0\260*\0\0\0\0\0\0&quot;..., 832) = 832&#xA;fstat(3, {st_mode=S_IFREG|0644, st_size=90080, ...}) = 0&#xA;mmap(NULL, 2185952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f468dc4b000&#xA;mprotect(0x7f468dc61000, 2093056, PROT_NONE) = 0&#xA;mmap(0x7f468de60000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7f468de60000&#xA;close(3)                                = 0&#xA;access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)&#xA;open(&quot;/lib/x86_64-linux-gnu/libc.so.6&quot;, O_RDONLY|O_CLOEXEC) = 3&#xA;read(3, &quot;\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&amp;gt;\0\1\0\0\0\320\37\2\0\0\0\0\0&quot;..., 832) = 832&#xA;fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0&#xA;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f468e35a000&#xA;mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f468d886000&#xA;mprotect(0x7f468da41000, 2093056, PROT_NONE) = 0&#xA;mmap(0x7f468dc40000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7f468dc40000&#xA;mmap(0x7f468dc46000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f468dc46000&#xA;close(3)                                = 0&#xA;access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)&#xA;open(&quot;/lib/x86_64-linux-gnu/libm.so.6&quot;, O_RDONLY|O_CLOEXEC) = 3&#xA;read(3, &quot;\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&amp;gt;\0\1\0\0\0\20V\0\0\0\0\0\0&quot;..., 832) = 832&#xA;fstat(3, {st_mode=S_IFREG|0644, st_size=1071552, ...}) = 0&#xA;mmap(NULL, 3166568, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f468d580000&#xA;mprotect(0x7f468d685000, 2093056, PROT_NONE) = 0&#xA;mmap(0x7f468d884000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x104000) = 0x7f468d884000&#xA;close(3)                                = 0&#xA;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f468e359000&#xA;mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f468e357000&#xA;arch_prctl(ARCH_SET_FS, 0x7f468e357780) = 0&#xA;mprotect(0x7f468dc40000, 16384, PROT_READ) = 0&#xA;mprotect(0x7f468d884000, 4096, PROT_READ) = 0&#xA;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f468e356000&#xA;mprotect(0x7f468e146000, 32768, PROT_READ) = 0&#xA;mprotect(0x7f468e387000, 4096, PROT_READ) = 0&#xA;munmap(0x7f468e35b000, 169535)          = 0&#xA;brk(0)                                  = 0x22a5000&#xA;brk(0x22c6000)                          = 0x22c6000&#xA;openat(AT_FDCWD, &quot;/dev&quot;, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3&#xA;open(&quot;/dev/ttyACM0&quot;, O_RDWR|O_NOCTTY|O_NONBLOCK) = 4&#xA;ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 opost isig icanon echo ...}) = 0&#xA;ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 opost isig icanon echo ...}) = 0&#xA;ioctl(4, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0&#xA;ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0&#xA;nanosleep({0, 500000000}, NULL)         = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99992})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99994})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99996})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99997})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99997})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;select(5, [4], NULL, NULL, {0, 100000}) = 1 (in [4], left {0, 99997})&#xA;read(4, &quot;&quot;, 1024)                       = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It indefinitely polls the descriptor. select = 1 means there is a data, but read returns 0. It seems like something on lower level is broken... may be because of system update (&lt;/p&gt;&#xA;" OwnerUserId="7695" LastEditorUserId="7695" LastEditDate="2015-10-05T20:30:50.220" LastActivityDate="2015-10-05T20:30:50.220" Title="Arduino Due upload firmware issue" Tags="|arduino-due|ubuntu|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16551" PostTypeId="1" AcceptedAnswerId="16554" CreationDate="2015-10-04T21:27:06.873" Score="2" ViewCount="772" Body="&lt;p&gt;When the sketch shown at end-of-question is compiled and uploaded to an Arduino board, it is supposed to Serial-print a list of available digital pins, showing for each pin whether it supports PWM or PCINT.  (For the latter items, it should indicate whether it has timer-supported PWM, and whether it can cause a hardware-supported pin-change-interrupt.)  For example, for an ATmega-2560 board, the program's output includes lines like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Pin# Port Mask  PWM  PCINT&#xA;  11   PB5  0x20  PWM  PCINT5  PCINT0_vect&#xA;  46   PL3  0x08  PWM&#xA;  52   PB1  0x02       PCINT1  PCINT0_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using arduino 1.6.3 on my Ubuntu 14.04 system with an ATmega-2560 board, the program's output for pins 14 and 15 is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  14   PJ1  0x02     &#xA;  15   PJ0  0x01     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As I understand it, those pins should be shown⁽¹⁾ as supporting PCINT9 and PCINT10, with vector PCINT1_vect, but the program doesn't report them as such.  What is this problem due to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;⁽¹⁾See, for example, table 13.3.9, Alternate Functions of Port J, in doc2549.pdf, the spec sheet for ATmega640/1280/1281/2560/2561.  Also see &lt;a href=&quot;https://arduino.stackexchange.com/q/9481&quot;&gt;Why is my interrupt code not working?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch pinsList.ino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  pinsList -- JW, 4 October 2015 --&#xA; *&#xA; *  Displays a list of Arduino pin numbers for current kind of Arduino&#xA; *  board, along with port codes, pin-change-interrupt numbers, and&#xA; *  pin-change-interrupt vector numbers.&#xA; *&#xA; *  Here are two examples of output lines for pin 11, the first for an&#xA; *  Uno, the second for a Mega:&#xA; *&#xA; *        11   PB3   0x04   PWM   PCINT3  PCINT0_vect&#xA; *        11   PB5   0x20   PWM   PCINT5  PCINT0_vect&#xA; */&#xA;//-----------------------------------------------------------&#xA;// Given a value with 1 bit set, return bit #.  Else return 9.&#xA;byte getBitfromBV (byte m) {&#xA;  byte b=0, v=1;&#xA;  while (v) {&#xA;    if (m==v)&#xA;      return b;&#xA;    ++b; v &amp;lt;&amp;lt;= 1;&#xA;  }&#xA;  return 9;&#xA;}&#xA;//-----------------------------------------------------------&#xA;void processPinNumber(byte pin) {&#xA;  char buffi[128];      // We create text-to-write in buffi&#xA;  byte nbuff=0;         // #chars used in buffi&#xA;  byte nPCICR;          // 0, 1, or 2 for mask-register #&#xA;  byte bitInByte;       // 0 to 7 for bit in I/O mask&#xA;  byte pinPort;         // pin's port #, in range 1 to 12&#xA;  byte PCInum;          // PCINT# if pin is a PCI pin&#xA;  char *portLet = &quot;?ABCDEFGHIJKL&quot;;&#xA;&#xA;  if (pin &amp;gt;= NUM_DIGITAL_PINS) return;&#xA;&#xA;  pinPort = digitalPinToPort(pin); // Get port #, in range 1 to 12&#xA;  bitInByte = getBitfromBV(digitalPinToBitMask(pin));&#xA;&#xA;  nbuff = snprintf(buffi, sizeof(buffi), &quot;  %2d   P%c%d  0x%02x&quot;, &#xA;           pin, portLet[pinPort], bitInByte, 1&amp;lt;&amp;lt;bitInByte);&#xA;&#xA;  // Indicate if it's a PWM pin&#xA;  if (digitalPinHasPWM(pin)) {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;  PWM&quot;);&#xA;  } else {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;     &quot;);&#xA;  }&#xA;&#xA;  // If it's a PCINT pin, show its PCINT number and 0, 1, 2 for its vector #&#xA;  if (digitalPinToPCICR(pin)) {      // Is it a PCint pin?&#xA;    nPCICR = digitalPinToPCICRbit(pin); // 0, 1, 2 for pin's PCICR bit#&#xA;    PCInum = nPCICR*8 + bitInByte;&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff,&#xA;             &quot;  PCINT%d  PCINT%d_vect&quot;,  PCInum,  nPCICR);&#xA;  }&#xA;  Serial.println(buffi);&#xA;}&#xA;void setup() {&#xA;  delay(50);&#xA;  Serial.begin(115200);&#xA;  delay(50);&#xA;  while (!Serial) ;             // wait for serial stream to connect&#xA;  Serial.println(&quot;\nPin#  Port  Mask  PWM   PCINT&quot;);&#xA;  for (byte p=0; p&amp;lt;NUM_DIGITAL_PINS; ++p)&#xA;    processPinNumber(p);&#xA;  Serial.end();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-05T00:15:06.570" Title="Why PJ0 and PJ1 are not reporting as PCINT pins" Tags="|arduino-mega|arduino-ide|pins|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16552" PostTypeId="2" ParentId="16551" CreationDate="2015-10-04T21:37:22.860" Score="2" Body="&lt;p&gt;It's because of this entry in the board's pins_arduino.h file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define digitalPinToPCICR(p)    ( (((p) &amp;gt;= 10) &amp;amp;&amp;amp; ((p) &amp;lt;= 13)) || \&#xA;                                  (((p) &amp;gt;= 50) &amp;amp;&amp;amp; ((p) &amp;lt;= 53)) || \&#xA;                                  (((p) &amp;gt;= 62) &amp;amp;&amp;amp; ((p) &amp;lt;= 69)) ? (&amp;amp;PCICR) : ((uint8_t *)0) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically your program isn't reporting what the pins can do - it's reporting &lt;em&gt;what the Arduino system has been programmed to support for those pins&lt;/em&gt;.  Basically it hasn't been programmed to support PCINT on those pins.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-04T21:37:22.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16553" PostTypeId="1" AcceptedAnswerId="16588" CreationDate="2015-10-04T23:38:43.910" Score="1" ViewCount="440" Body="&lt;p&gt;I try to learn assembly and use an arduino uno R3 to act as a programmer. i have build a standalone circuit with an atmega328p, can upload usual sketches (written in c) and have also sucessfully burned the bootloader to the external chip with the arduino as an isp but i cant bring my assembly code onto the chip on the breadboard. i tried it with avrdude and the following command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C avrdude.conf -p atmega328p -c avrisp -P /dev/ttyACM0 -b 115200 -D -U flash:w:test.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C avrdude.conf -p atmega328p -c arduino -P /dev/ttyACM0 -b 115200 -D -U flash:w:test.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the code is always uploaded to the chip on the arduino - not to the one on the breadboard. can anyone lead me how to upload my assembly programm to the standalone chip on the breadboard using the arduino as isp? is this possible anyway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT This command worked for me&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C avrdude.conf -v -v -v -v -p atmega328p -c stk500v1 -P /dev/ttyACM0 -b19200 -Uflash:w:test.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13731" LastEditorUserId="13731" LastEditDate="2015-10-06T16:33:09.877" LastActivityDate="2015-10-06T16:33:09.877" Title="Upload Assembly to AVR on a breadboard using Arduino as ISP" Tags="|arduino-uno|assembly|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16554" PostTypeId="2" ParentId="16551" CreationDate="2015-10-04T23:51:41.377" Score="2" Body="&lt;p&gt;Majenko was &lt;em&gt;very close&lt;/em&gt; but seems to have missed the explanatory comment from the source code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)&#xA;// Pins: 10, 11, 12, 13,  50, 51, 52, 53,  62, 63, 64, 65, 66, 67, 68, 69&#xA;&#xA;#define digitalPinToPCICR(p)    ( (((p) &amp;gt;= 10) &amp;amp;&amp;amp; ((p) &amp;lt;= 13)) || \   &#xA;                                  (((p) &amp;gt;= 50) &amp;amp;&amp;amp; ((p) &amp;lt;= 53)) || \&#xA;                                  (((p) &amp;gt;= 62) &amp;amp;&amp;amp; ((p) &amp;lt;= 69)) ? (&amp;amp;PCICR) : ((uint8_t *)0) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which seems like it may apply to the fact that the USART3 pins PJ1 (14) and PJ0 (15) are missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why providing mappings to the hardware USART pins &quot;seems senseless&quot; a little playing with git blame will show that these lines were added to this file &lt;a href=&quot;https://github.com/arduino/Arduino/commit/f179794a45c33edcb48c493bc03fb0e39dba11db&quot; rel=&quot;nofollow&quot;&gt;in commit f179794&lt;/a&gt;  in response to &lt;a href=&quot;http://code.google.com/p/arduino/issues/detail?id=490&quot; rel=&quot;nofollow&quot;&gt;issue 490&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The SoftwareSerial library defines macros that map Arduino pin numbers to the pin changes interrupts on the pins.  We should pull this up into the board-specific pin definition header file so that the SoftwareSerial library can work on any AVR for which those macros (and the pin-change interrupts) are defined.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which is to say that David Mellis didn't write those lines for generic interrupt use as part of pins_arduino.h, but rather moved code &lt;strong&gt;originally written as part of the software serial library&lt;/strong&gt; to this file to make things more portable (and, though perhaps incidentally, generally usable for other purposes).  It's not exactly clear who the original author speaking as &quot;I&quot; in the comment is - the Mega-specific code in question appears to come most immediately from Mikal Hart's extension of Ladyada's Uno-only interrupt soft serial code (which did not have it) but there's also a comment in that seemingly crediting Paul Stoffregen (Teensy boards) for at least some aspect of the macro...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does kind of make sense that someone writing a software serial library could consider using it on hardware serial pins pointless.  But counterarguments could also be made - for one example, the 16u2 core either uses or has experimented with software serial at some baud rates, and for another a software serial implementation could be a plausible way of overcoming swapped RX &amp;amp; TX wiring, or a way of implementing inverted signalling logic when using simplified level shifters or talking to something which expects to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that in its current location the code is no longer necessarily only for software serial use, it seems plausible that a carefully written and fully validated patch to make it more general might be favorably received.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-10-05T00:15:06.570" LastActivityDate="2015-10-05T00:15:06.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16555" PostTypeId="2" ParentId="16539" CreationDate="2015-10-04T23:53:22.767" Score="0" Body="&lt;p&gt;The problem was resolved by changing &quot;set RTS on close&quot; in the device manager properties as stated here&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/a/87955/80377&quot;&gt;https://electronics.stackexchange.com/a/87955/80377&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13330" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-10-04T23:53:22.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16556" PostTypeId="2" ParentId="14554" CreationDate="2015-10-05T02:39:52.923" Score="1" Body="&lt;p&gt;I think the information you are looking for can be found at &lt;a href=&quot;https://www.arduino.cc/en/Reference/DueExtendedSPI&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/DueExtendedSPI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two other alternatives that I can see: if your device supports slave select (which I think they are supposed to), then you can use a different pin to select either device 1 or device 2 (or 3...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other options is that if you can connect the clock to only one slave at a time (again, with another pin), you should get the same result - you should be able to use a MOSFET between the Arduino's clock-out and the slave's clock-in, and hook the MOSFET's gate to a spare pin; repeat the procedure, using a separate MOSFET, connected to a different spare pin, to the second slave; then bring one or the other &quot;spare pin&quot; high, to select which way the clock goes. If a slave does not receive a clock, it will not listen for incoming signal. This last one I dreamed up; I don't know if it will work.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-05T02:39:52.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16559" PostTypeId="1" CreationDate="2015-10-05T09:29:00.867" Score="0" ViewCount="177" Body="&lt;p&gt;If it matters, I'm talking about the arduino uno v3.&lt;/p&gt;&#xA;" OwnerUserId="13798" LastActivityDate="2015-11-18T16:13:34.430" Title="Why can only some digital ports output PWM and the others not?" Tags="|arduino-uno|pwm|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16560" PostTypeId="2" ParentId="16559" CreationDate="2015-10-05T09:47:09.027" Score="1" Body="&lt;p&gt;Check out the ATMega328p &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;: each of the 3 timer/counter blocks can generate PWM (2 PWM signals per timer) and on top of that, typically Timer1 (16 bits) is used by the OS/scheduler/whatever, unless you are really running on bare metal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a limitation, but so is everything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not like it, you can always choose a different microcontroller, either AVR or something else.&#xA;Certain models might  be designed to have more units of a specific type than you would find on generic microcontrollers.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-05T09:47:09.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16561" PostTypeId="2" ParentId="13186" CreationDate="2015-10-05T12:15:38.917" Score="0" Body="&lt;p&gt;Sorry if these are stupid questions but these are the things I would check.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why are you connecting to an Arduino, why not connect directly to the&#xA;HOST and use a terminal emulator program? &lt;/li&gt;&#xA;&lt;li&gt;What ESP8266 are you using?&lt;/li&gt;&#xA;&lt;li&gt;Are you connecting the Vcc connector of the ESP8266 to 3.3v?&lt;/li&gt;&#xA;&lt;li&gt;I think you need to pull the RST pin high to enable normal running, &#xA;is it high?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-05T12:15:38.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16563" PostTypeId="1" CreationDate="2015-10-05T12:52:43.847" Score="0" ViewCount="145" Body="&lt;p&gt;I am following this link from Instructables site:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Audio-Input/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-Audio-Input/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using the Microphone Radioshack 33-3038, which is listed in the tutorial, can I use &lt;a href=&quot;https://www.sparkfun.com/products/9964&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/9964&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly suggest if there any modifications required in other parts for the circuitry, if I go for Electret Microphone.&lt;/p&gt;&#xA;" OwnerUserId="10894" LastEditorUserId="972" LastEditDate="2018-06-15T03:00:49.430" LastActivityDate="2018-06-15T03:00:49.430" Title="Need help in the project &quot;Arduino for audio processing&quot;" Tags="|arduino-uno|audio|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16564" PostTypeId="2" ParentId="16563" CreationDate="2015-10-05T13:02:45.580" Score="3" Body="&lt;p&gt;The replacement microphone you link to contains all the circuitry in that instructable&lt;sup&gt;*&lt;/sup&gt;.  You can do away with the op-amp and all the associated stuff, and just connect it direct to the analog input of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt;Actually it's better circuitry since they do it right, unlike the Destructable that is a rubbish circuit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-05T13:02:45.580" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16565" PostTypeId="1" CreationDate="2015-10-05T13:10:13.623" Score="-1" ViewCount="220" Body="&lt;p&gt;I'm trying to get warning with buzzer while I get same values on 3 seconds. But first warning doesn't wait 3 seconds. Second warning is correct. Code is attached. BlinkLED1() method is same BlinkLED2. Probably, I'm missing crowning touch. Can you help me?&#xA;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void initialsettings(double roll,double pitch){&#xA;  if(level==0){&#xA;    if(roll&amp;gt;=34 &amp;amp;&amp;amp; timerstatus==false){&#xA;&#xA;        Timer1.initialize(3000000);&#xA;        timerstatus=true;&#xA;        Timer1.attachInterrupt(blinkLED);&#xA;    } else{&#xA;         Timer1.stop();&#xA;         timerstatus=false;&#xA;         level=0;&#xA;    }&#xA;&#xA;   }else if(level==1){&#xA;      if(roll&amp;lt;=-34 &amp;amp;&amp;amp; timerstatus==false){&#xA;&#xA;        Timer1.initialize(3000000);&#xA;        timerstatus=true;&#xA;         Timer1.attachInterrupt(blinkLED2);&#xA;      } else{&#xA;           Timer1.stop();&#xA;         timerstatus=false;&#xA;&#xA;      }&#xA;&#xA;  }else if(level==2){&#xA;&#xA;&#xA;  }&#xA;}&#xA;&#xA;void blinkLED(void)&#xA;{&#xA;    noInterrupts();&#xA;    Timer1.stop();&#xA;&#xA;    //Timer1.restart();&#xA;    digitalWrite(buzzerpin,HIGH);&#xA;    delay(7000);&#xA;    digitalWrite(buzzerpin,LOW);&#xA;    timerstatus=false;&#xA;    interrupts();&#xA;    if(level==0){&#xA;      level=1;&#xA;      Serial.println(&quot;level 1&quot;);&#xA;    }&#xA;  Serial.println(&quot;Sag &quot;);&#xA;    //Serial.print(&quot;\n&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10196" LastEditorUserId="10794" LastEditDate="2015-10-06T04:55:29.580" LastActivityDate="2022-11-29T12:07:55.947" Title="How to use TimerOne while calculating time?" Tags="|arduino-mega|c++|timers|buzzer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16566" PostTypeId="1" AcceptedAnswerId="16568" CreationDate="2015-10-05T14:51:53.527" Score="0" ViewCount="3242" Body="&lt;p&gt;I've a joystick and a servo connected to my UNO, but for some reason my calculations keep on being wrong? I'm trying to calculate how the rotation should be of my servo (Tower Pro 9g, max value of 180 I think) with my Joystick (Keyes_SJoys, max value of 1023 on any axis) and example would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;y = 500;&lt;br&gt;&#xA;servo.write(y * 180 / 1023); // should equal to 87.97, but in reality it's 24?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo;&#xA;int d2 = 2;&#xA;int a0 = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  servo.attach(d2);&#xA;}&#xA;&#xA;void loop() {&#xA;  int y = analogRead(a0);&#xA;  Serial.print(&quot;y: &quot;); Serial.println(y);&#xA;&#xA;  servo.write(y * 180 / 1023);&#xA;  Serial.println(y * 180 / 1023);&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS. It's a Robotale UNO; I don't know if that makes any difference or not, but.&lt;/p&gt;&#xA;" OwnerUserId="13801" LastActivityDate="2015-10-05T17:38:40.260" Title="Wrong calculation UNO" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16567" PostTypeId="1" AcceptedAnswerId="16571" CreationDate="2015-10-05T14:57:12.110" Score="1" ViewCount="149" Body="&lt;p&gt;I have no idea what difference is there between the revisions and how it affects me. I have a pdf and this pic was in there: &#xA;&lt;img src=&quot;https://i.stack.imgur.com/7ARQA.jpg&quot; alt=&quot;arduino pic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;which arduino revision is this?&lt;/li&gt;&#xA;&lt;li&gt;Does it matter which revision i    buy?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13803" LastActivityDate="2015-10-05T22:39:18.130" Title="Beginner here. Which arduino revision should i buy?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16568" PostTypeId="2" ParentId="16566" CreationDate="2015-10-05T14:58:11.067" Score="2" Body="&lt;p&gt;What you are experiencing is a common pitfall.&#xA;You are probably expecting floating point calculations, but what you are writing are only integer ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try with:  y * 180. / 1023.   (notice the dots).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will work only with constants.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it work with anything, use a cast:  y * 180 / (float) 1023&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Happy hacking.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-05T14:58:11.067" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16569" PostTypeId="2" ParentId="16567" CreationDate="2015-10-05T15:06:12.273" Score="0" Body="&lt;p&gt;That looks like an UNO R2, the type with DIP micro controller (you can extract it and replace it with another one, in case of problems).&#xA;The R3 version is probably the best choice to get started.&#xA;You might want one that has a connector where this one has only the 3x2 empty pads on the top left (close to the vertical writing AREF).&#xA;Have a look on ebay/aliexpress/amazon. You can find it for as little as $5-$6. Just search for UNOR3, if you elect to buy this type.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-05T22:39:18.130" LastActivityDate="2015-10-05T22:39:18.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16570" PostTypeId="2" ParentId="16566" CreationDate="2015-10-05T16:04:53.023" Score="1" Body="&lt;p&gt;The reason you're getting completely the wrong value (not just losing the decimal portion) is because of a problem called &lt;em&gt;integer overflow&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the Arduino is an 8-bit device the default integer size is double that.  That means that an integer value can store 16 bits, and when signed that's -32768 to 32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any calculations, unless you specify otherwise, have to fit into that range.  If you take your calculation step by step you will see how it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;500 * 180 = 90,000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Represented in Hexadecimal (for ease of demonstration) 90,000 is 0x15F90.  That is 17 bits (4 bits per digit, the left hand is just one bit since it's only the value 1), and 17 is more than the maximum 16 allowed.  So we have to &quot;overflow&quot; that value and discard the lefthand-most digit to keep it at 16 bits.  So we end up with 0x5F90.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0x5F90 in decimal is 24464.  Now we divide that by 1023 and we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;24464 / 1023 = 23.914&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because it's integers we have no decimal portion of it, so that just ends up as the 23 that you are seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solutions?  Change the data type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @IgorStoppa has pointed out you can use floating point values which gives you big values and the decimal portion.  As long as one value in your sum is floating point all the values will be. This is known as &lt;em&gt;promotion&lt;/em&gt;.  There's numerous ways you can force floating values:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Represent your literals as a floating point value - that means adding a decimal place. You could have (as Igor shows) things like &lt;code&gt;1023.&lt;/code&gt;, but I find that a little obscure.  It's better to explicitly show a decimal value since it's obvious what it is then, such as &lt;code&gt;y * 180.0 / 1023.0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Use a floating point &lt;em&gt;literal suffix&lt;/em&gt;.  You can add certain letters after a number to describe what that number is.  &lt;code&gt;f&lt;/code&gt; is for floating point: &lt;code&gt;y * 180f / 1023f&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Floating point is quite heavy weight though and can cause your program to get bigger than you'd like.  If you're not interested in the decimal portion you can instead use &lt;em&gt;long&lt;/em&gt; variables.  The best way to do that is with the &lt;em&gt;long&lt;/em&gt; literal suffix &lt;code&gt;L&lt;/code&gt;:  &lt;code&gt;y * 180L / 1023L&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Promotion&lt;/em&gt; means that all the variables are &lt;em&gt;promoted&lt;/em&gt; to the size of the biggest variable (not greatest value, the variable with the largest storage space).  Long and Float are both 32 bits in size, so using either of those will force the other values to both be &lt;em&gt;promoted&lt;/em&gt; to equivalent types.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-05T17:38:40.260" LastActivityDate="2015-10-05T17:38:40.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16571" PostTypeId="2" ParentId="16567" CreationDate="2015-10-05T18:05:45.703" Score="0" Body="&lt;p&gt;That looks like an early-version Uno, rather than an Uno R3 as shown below. (Image is from dxcdn.com and is one of the first few images in a &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1002&amp;amp;bih=626&amp;amp;q=UNO+R3&amp;amp;oq=UNO+R3&amp;amp;gs_l=img.12..0l7j0i5i30l3.1757.1757.0.2961.1.1.0.0.0.0.92.92.1.1.0.ecynfh...0...1..64.img..0.1.91.PlZ5WbbvIEA#imgrc=gYQV8pLWKcYuZM%3A&quot; rel=&quot;nofollow noreferrer&quot;&gt;google images for Uno R3&lt;/a&gt; search.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jhKAV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jhKAV.jpg&quot; alt=&quot;Uno R3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a beginner, replacing a DIP ATMEGA328P may be a chip too far.  I suggest that rather than looking for an Uno with a replacable chip, get any Uno you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that for beginning projects, it makes sense to use the same kind of Arduino – an Uno, a Mega, a Pro Mini, a Nano, etc. – as the guide you are following uses, so that you won't have to adapt any pin numbers and wiring pictures.  As you gain experience, it should become easy to adapt designs to different boards.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-05T18:05:45.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16572" PostTypeId="1" CreationDate="2015-10-05T18:07:05.570" Score="1" ViewCount="10697" Body="&lt;p&gt;I would like to control 6 stepper motors (0.225A, 2 V) with Arduino. I was thinking to use motor drivers from Pololu website, for example &lt;a href=&quot;https://www.pololu.com/product/2134/resources&quot; rel=&quot;nofollow&quot;&gt;DRV8834&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion for another type of motor driver?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to limit the current, but I also got the advice to use the PWM signal to control the stepper motor. Any advice for this?&lt;/p&gt;&#xA;" OwnerUserId="13810" LastEditorUserId="6936" LastEditDate="2016-02-18T12:32:28.287" LastActivityDate="2022-12-07T20:31:42.063" Title="How to control 6 stepper motors with Arduino?" Tags="|arduino-uno|motor|pwm|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16573" PostTypeId="1" AcceptedAnswerId="16600" CreationDate="2015-10-05T18:30:06.770" Score="0" ViewCount="1497" Body="&lt;p&gt;I am making a simple Li-Ion battery Tester. Basically its two 5R1 resistor in series and a relay (used to cut off the battery when it reaches cutoff voltage). Arduino is connected with ground to the battery and with A3 to the end of the resistors. But when I try to read the analog value, I receive something like 870, which is about 4.24V. BUT the real voltage is about 3.90V (according to my multimeter). How is that possible? Thanks for any suggestions.&lt;a href=&quot;https://i.stack.imgur.com/CelLF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CelLF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12154" LastEditorUserId="12154" LastEditDate="2015-10-05T18:58:55.263" LastActivityDate="2015-10-06T17:53:14.107" Title="Wrong analog reading" Tags="|analogread|voltage-level|battery|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16575" PostTypeId="2" ParentId="16512" CreationDate="2015-10-05T20:45:11.480" Score="0" Body="&lt;p&gt;I finally got it working. The problem was with this 5-way tact switch being initially incompatible with the Due: &lt;a href=&quot;http://www.ebay.com/itm/5-Channel-Way-Tactile-Switch-Breakout-Module-Converter-Adapter-Board-Arduino-/141745152805&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/5-Channel-Way-Tactile-Switch-Breakout-Module-Converter-Adapter-Board-Arduino-/141745152805&lt;/a&gt; . As you can see from the picture and the description on that page, the switch includes pullup resistors on the board. I measured those resistors at 10k Ohms. For some reason the switch worked perfectly fine with the Mega's pullup resistors, but didn't work with the Due's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4JQRJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4JQRJ.jpg&quot; alt=&quot;5-way tact switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After much experimentation, I found that the switch will start working if I add a 14.7k resistor between the switch and ground. The Due's internal pullups still had to be activated, otherwise it seemed the switch was firing constantly. When I used a 10k resistor, the center button on the switch wasn't working. And when I used 20k and higher resistors, many of the buttons weren't working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I posted this as an answer because the switch is finally working the way I want it to. But I'm still curious to know if anyone has a reason why there would be a necessity to have a 14.7k resistor on the ground of this switch in order to make it work with the Due. Note that I don't have anything connected to the VCC of the switch (though I have experimented with it before).&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-05T20:45:11.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16576" PostTypeId="1" CreationDate="2015-10-05T22:24:54.503" Score="1" ViewCount="125" Body="&lt;p&gt;I'm currently battling with a LinkSprite GPRS shield (it's based on the SIMCom SIM900 chip) and seem to have absolutely no luck trying to connect to the network.  I've got two SIMs, both of which should be active, but I cannot get the connection light on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got a serial connection going and it's responding to various AT commands, but I can't connect:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+COPS=?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is working, and giving me a list of networks, so I think my antenna is good, but &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+COPS=-whatever-&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;immediately gives me +CREG: 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm now wondering whether there's a fault with my board, and that it's not seeing the SIM cards.  A few commands that I thought would work aren't, for example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+CPIN?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;just returns ERROR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, when trying to read SMS data:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+CMGL=&quot;ALL&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;returns ERROR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have I proved that the board isn't seeing the SIM, or is there something definitive I can try?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="13815" LastEditorUserId="13815" LastEditDate="2015-10-05T22:35:09.370" LastActivityDate="2016-04-22T06:46:56.607" Title="GPRS shield - Hayes commands to identify a faulty SIM connection" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16577" PostTypeId="2" ParentId="16512" CreationDate="2015-10-05T23:38:00.690" Score="1" Body="&lt;p&gt;I think I can explain this. You have set up a rather complex (and incorrectly wired) network of resistors. Your switch has pull-up resistors, clearly connected together, and then to the &quot;+&quot; pin. The other side of the switches would go to ground. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that I don't have anything connected to the VCC of the switch ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Right, so your setup looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZDmo9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZDmo9.png&quot; alt=&quot;Pull-up resistors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with no switch pressed they will all read high due to the Due's pull-up (which by the way is around 100 k compared to the Mega's 50 k.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you press a switch. The naturally grounds that switch so it reads LOW. However it also pulls down neighbouring switches through the 10 k resistor network. So each switch now is in the middle of a voltage divider. There is 20 k going to ground and a couple of 100 k going to Vcc, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nZNKC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nZNKC.png&quot; alt=&quot;Multiple presses&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This voltage divider would be enough for that pin to register as LOW, and indeed that would be repeated for each pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding your carefully calculated resistor between the &quot;-&quot; pin and ground is just changing the voltages a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct solution is to connect the &quot;+&quot; pin to Vcc so that it acts as a proper pull-up. And get rid of that resistor in series with ground.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It probably worked on the Mega because of the different pull-up resistance when you activated the internal pull-up which would have changed the calculations for the voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've worked out what I think the voltages will be. Note that the supposedly open switches will actually have 1.1 V on them, which as far as I can tell from the datasheet is in the &quot;undefined&quot; territory between LOW (max 0.99 V) and HIGH (minimum 2.31 V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reasoning: You can effectively consider that the 4 open switches have 4 x 110 k between them and 3.3 V in parallel. In other words, 27.5 k. With a voltage divider now between that and the 10 k to ground, you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10 / (10 + 27.5) * 3.3 = 880 mV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, there will be 880 mV on the common point (which is &quot;+&quot; on the board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for each switch you have a voltage divider of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10 / 110 * (3.3 - 0.880) = 220 mV&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to that the 880 mV at the common point and we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.88 + 0.22 = 1.10 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-06T01:36:27.893" LastActivityDate="2015-10-06T01:36:27.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16578" PostTypeId="1" CreationDate="2015-10-06T01:51:42.297" Score="2" ViewCount="2738" Body="&lt;p&gt;When using a digital pin as input, one has the option of using the internal arduino resistor, which is connected to VCC; that is setting the digital pin as INPUT_PULLUP, and then the pin reads HIGH. Does this uses electricity?. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mean the resistor is connected directly to VCC and I presume electricity is constantly flowing through the system, no?.&#xA;as oppose to having the pin as just INPUT?&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2015-10-06T08:40:40.403" Title="does INPUT_PULLUP uses power?" Tags="|resistor|input|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16579" PostTypeId="2" ParentId="16578" CreationDate="2015-10-06T02:00:33.120" Score="2" Body="&lt;p&gt;Only the leakage current on the input itself is constantly consumed if there is no external connection. This is usually much less than the waste &lt;a href=&quot;http://www.ti.com/lit/an/scba004c/scba004c.pdf&quot; rel=&quot;nofollow&quot;&gt;caused by having the input floating&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If a voltage between 0.8 V and 2 V is applied to the input for a prolonged period of time, this situation becomes critical and&#xA;  should not be ignored, especially with higher bit count and more dense packages [...]. For example, if an 18-bit&#xA;  transceiver has 36 I/O pins floating at the threshold, the current from VCC can be as high as 150 mA to 200 mA.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-06T02:00:33.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16581" PostTypeId="2" ParentId="16578" CreationDate="2015-10-06T03:25:52.780" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/16424/deviation-of-power-consumption-between-datasheet-and-real-world&quot;&gt;Deviation of power consumption between datasheet and real world?&lt;/a&gt; - there we established that leaving the pins input consumed considerably more power than input_pullup. That was with the pins not connected to anything.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-06T03:25:52.780" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16582" PostTypeId="1" CreationDate="2015-10-06T03:30:18.767" Score="1" ViewCount="342" Body="&lt;p&gt;I'd like to be able to change variables on the Arduino by adjusting a set of knobs.  When I get to a desirable setting I'd like to be able to save those settings on the Arduino... and then I'd like to be able to load those settings back, and have the knobs turn themselves back to the correct positions.  Specifically I'm thinking of using this with a synthesizer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand how to do all of this, except, I don't know if there are knobs that allow this type of behavior.&lt;/p&gt;&#xA;" OwnerUserId="13818" LastActivityDate="2015-10-07T05:44:21.217" Title="A knob that can be turned by hand, have the position read, and turned by software to another position?" Tags="|arduino-uno|hardware|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16583" PostTypeId="2" ParentId="16565" CreationDate="2015-10-06T04:56:20.633" Score="0" Body="&lt;pre&gt;&lt;code&gt;    Timer1.attachInterrupt(blinkLED);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void blinkLED(void)&#xA;{&#xA;    noInterrupts();&#xA;    Timer1.stop();&#xA;&#xA;    //Timer1.restart();&#xA;    digitalWrite(buzzerpin,HIGH);&#xA;    delay(7000);&#xA;    digitalWrite(buzzerpin,LOW);&#xA;    timerstatus=false;&#xA;    interrupts();&#xA;    if(level==0){&#xA;      level=1;&#xA;      Serial.println(&quot;level 1&quot;);&#xA;    }&#xA;  Serial.println(&quot;Sag &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't do serial prints inside an interrupt service routine (ISR).&lt;/li&gt;&#xA;&lt;li&gt;Don't use &lt;code&gt;delay()&lt;/code&gt; inside an ISR.&lt;/li&gt;&#xA;&lt;li&gt;Don't turn interrupts on or off inside an ISR.&lt;/li&gt;&#xA;&lt;li&gt;Variables shared between an ISR and the main code should be &lt;code&gt;volatile&lt;/code&gt; (I can't see from your &lt;a href=&quot;http://snippets-r-us.com/&quot; rel=&quot;nofollow&quot;&gt;snippet&lt;/a&gt; whether they are or not).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Reference: &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-06T04:56:20.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16584" PostTypeId="2" ParentId="16582" CreationDate="2015-10-06T06:01:18.483" Score="0" Body="&lt;p&gt;If you can't get a motorised potentiometer could you use a rotary encoder, a motor, a shaft and some cogs.  Press the shaft and rotate manually then release and it disengages the manual cog and moves back to the motor cog.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-06T06:01:18.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16585" PostTypeId="2" ParentId="16582" CreationDate="2015-10-06T06:17:17.373" Score="2" Body="&lt;p&gt;If you attach a knob to the &lt;a href=&quot;https://www.adafruit.com/products/1450&quot; rel=&quot;nofollow&quot;&gt;Analog Feedback Micro Servo&lt;/a&gt;, either directly or via gears, then you can use the pot output to measure the current position and use the normal servo control protocol to turn it under software control.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-06T06:17:17.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16586" PostTypeId="2" ParentId="9009" CreationDate="2015-10-06T07:25:25.360" Score="1" Body="&lt;p&gt;The Arduino in combination with a wifi/ethernet module will not give you a lot of options to work with. There are currently no libraries that will give you features like including stylesheets, AJAX or websockets. If your project allows it, due to the number of I/O pins you need etc: replace your Arduino with a ESP8266&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to produce something fancy: go with the ESP8266. Getting everything setup and working will be a bit harder than with the Arduino, but it will be worth the effort. You can program it in Lua, but that will only give you access to some basic functions. Just write your program in C like you did on the Arduino. There is a thing called Sming framework which allows you to import Arduino libraries with only changing in few lines of code. The Sming framework also includes a HTTPserver with AJAX, websocket, POST/GET, pre-processing, and style/js-file inclusion features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The web framework is easier than it is in most webframeworks for the pc! The hard part is installing the toolchain and uploading your first bit of code, but once you've got that done it will be easy to figure out the rest. The Sming framework also contains examples for everything you think of. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are planning on buying an ESP8266 I recommend you get a few. The basic ESP-01 cost around $2,40 on ebay, but get a fancier one too with a few extra IO pins. I have also got a development version which can be programmed with a USB cable. It is really usefull for developing your program since you don't have to connect a USB-serial device every time just plug a USB cable. When I think my program is done, I upload it to a more basic and replaceable version of the ESP8266 and fix it in my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a summary: It will be harder to figure everything out, but once you've got everything done it will be worth the effort! Here are a few links:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will show you the power of a ESP8266:&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=8ISbmQTbjDI&quot; rel=&quot;nofollow&quot;&gt;ESP8266 oscilloscope with websockets video&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sming framework:&#xA;&lt;a href=&quot;https://github.com/SmingHub/Sming&quot; rel=&quot;nofollow&quot;&gt;Sming framework github repo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-10-06T07:25:25.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16587" PostTypeId="2" ParentId="16582" CreationDate="2015-10-06T08:23:42.383" Score="1" Body="&lt;p&gt;Alternatively, just add an LED/LCD display on top of each knob (or have a larger LCD showing info for all the knobs) to show the value.&#xA;Then you can have the knobs implemented with an optical rotary encoder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each knob is unmarked and doesn't need to be reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution doesn't put any mechanical part under strain.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-06T17:26:25.533" LastActivityDate="2015-10-06T17:26:25.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16588" PostTypeId="2" ParentId="16553" CreationDate="2015-10-06T08:29:23.070" Score="1" Body="&lt;p&gt;Try uploading the blink sketch to the standalone atmega328 first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get that to work you can get the right command form the console (after enabling verbose output, in the settings). &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-06T08:29:23.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16589" PostTypeId="2" ParentId="16578" CreationDate="2015-10-06T08:40:40.403" Score="2" Body="&lt;p&gt;The pullups have a value between 20k and 50kOhm. If the input is connected to ground (button pressed), between 0.1mA and 0.25mA is flowing through the resistor. So bare anything.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-06T08:40:40.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16590" PostTypeId="2" ParentId="15827" CreationDate="2015-10-06T10:37:11.483" Score="1" Body="&lt;p&gt;Given that two bytes are short, you send:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;SCOPE_START_DATA&lt;/code&gt; &lt;code&gt;short&lt;/code&gt; flag: &lt;code&gt;0xCDAB&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;short&lt;/code&gt; number of following bytes to read (for example, &lt;code&gt;0x0002&lt;/code&gt; for only one channel)&lt;/li&gt;&#xA;&lt;li&gt;one &lt;code&gt;short&lt;/code&gt; per channel&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;P.S. This is shamelessly stolen from it.baeyens.arduino.monitor.views.ScopeListener&lt;/p&gt;&#xA;" OwnerUserId="13821" LastEditorUserId="6936" LastEditDate="2016-02-20T19:44:12.313" LastActivityDate="2016-02-20T19:44:12.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16591" PostTypeId="1" AcceptedAnswerId="16592" CreationDate="2015-10-06T10:59:21.647" Score="0" ViewCount="383" Body="&lt;p&gt;I'm a beginner in creating my own libraries so the following might contain some stupid stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, I'm using NRF24L01+ modules for wireless communication and I've been utilizing the magnificent RF24 library (&lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24&lt;/a&gt;) to operate these modules using Arduino. I wanted to clean up my code and decided to write my own library that uses the R24 library. My own library would contain all the subroutines that handle TX and RX functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem is that the RF24 library is initialized using e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 &amp;amp; 8 */&#xA;RF24 radio(7,8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To begin using the NRF24L01+ one would the use the RF24 library like for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte addresses[][6] = {&quot;1Node&quot;,&quot;2Node&quot;}; // Radio pipe addresses for the 2 nodes to communicate.&#xA;Serial.begin(57600);&#xA;printf_begin();&#xA;radio.begin();&#xA;&#xA;radio.setPALevel(RF24_PA_HIGH);&#xA;radio.setCRCLength(RF24_CRC_16);&#xA;&#xA;radio.setRetries(2,15);&#xA;radio.setChannel(RFChannel); &#xA;if(radioNumber){&#xA;radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses&#xA;radio.openReadingPipe(1,addresses[0]); // Open a reading pipe on address 0, pipe 1&#xA;}else{&#xA;radio.openWritingPipe(addresses[0]);&#xA;radio.openReadingPipe(1,addresses[1]);&#xA;}&#xA;&#xA;if(radioNumber == 1){&#xA;radio.startListening(); // Start listening&#xA;}&#xA;radio.printDetails(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well, now I would like to make a library that would allow me just to call setup to handle all of the above. My library would be called RadioComm so I would call in my main code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm rComm();&#xA;&#xA;setup() {&#xA;rComm.setup();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that how do I use the RF24 library and all its functions in my library? To initialize the RF24 library in my own library I would have to call somehow this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24 radio(7,8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and use all the radio. commands. How do I tell my own library that everything starting with &quot;radio.&quot; is related to RF24 library because right now I'm getting this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm.cpp: In member function 'void RadioComm::setup()':&#xA;RadioComm.cpp:20:18: error: 'radio' was not declared in this scope&#xA;radio(pin1,pin2); // Set up nRF24L01 radio on SPI bus plus pins 9 &amp;amp; 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below are my .h .cpp and .ino files  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lib_test.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RadioComm.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;RadioComm rComm;&#xA;&#xA;void setup() {&#xA;&#xA;rComm.setup();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RadioComm.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef RadioComm_h&#xA;#define RadioComm_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;&#xA;struct dataStruct{&#xA;unsigned long id;&#xA;float value1;&#xA;float value2;&#xA;float value3;&#xA;float value4;&#xA;};&#xA;&#xA;&#xA;class RadioComm&#xA;{&#xA;&#xA;public:&#xA;&#xA;RadioComm();&#xA;void setup(void);&#xA;&#xA;private:&#xA;int pin1;&#xA;int pin2;&#xA;&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RadioComm.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;RadioComm.h&quot;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &quot;printf.h&quot;&#xA;&#xA;&#xA;RadioComm::RadioComm(void)&#xA;{}&#xA;&#xA;&#xA;void RadioComm::setup()&#xA;{&#xA;byte addresses[][6] = {&quot;1Node&quot;,&quot;2Node&quot;}; // Radio pipe addresses for the 2 nodes to communicate.&#xA;radio(pin1,pin2); // Set up nRF24L01 radio on SPI bus plus pins 9 &amp;amp; 10&#xA;Serial.begin(57600);&#xA;printf_begin();&#xA;radio.begin();&#xA;radio.setPALevel(RF24_PA_HIGH);&#xA;radio.setCRCLength(RF24_CRC_16);&#xA;&#xA;&#xA;radio.setRetries(2,15);&#xA;radio.setChannel(RFChannel); &#xA;if(radioNumber){&#xA;radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses&#xA;radio.openReadingPipe(1,addresses[0]); // Open a reading pipe on address 0, pipe 1&#xA;}else{&#xA;radio.openWritingPipe(addresses[0]);&#xA;radio.openReadingPipe(1,addresses[1]);&#xA;}&#xA;&#xA;if(radioNumber == 1){&#xA;radio.startListening(); // Start listening&#xA;}&#xA;radio.printDetails(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="13824" LastEditorUserId="13824" LastEditDate="2015-10-06T11:12:35.793" LastActivityDate="2015-10-06T11:12:35.793" Title="A question about including libraries" Tags="|arduino-ide|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16592" PostTypeId="2" ParentId="16591" CreationDate="2015-10-06T11:08:39.367" Score="1" Body="&lt;p&gt;Firstly, to address your compilation error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm rComm();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is not a constructor, that is a function prototype. When you have no parameters to a constructor you &lt;em&gt;must not&lt;/em&gt; include the brackets or it confuses the poor little compiler.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm rComm;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now - to address your main question.  Well, there's many ways of doing it, but the way I always tackle this is to have your sketch define the RF24 object and pass it to the library for later use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the class definition, in the &lt;code&gt;private&lt;/code&gt; section, add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24 *radio;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then change the constructor to have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm(RF24 &amp;amp;r);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The constructor itself would then read:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RadioComm::RadioComm(RF24 &amp;amp;r) {&#xA;    radio = &amp;amp;r;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now throughout your library, instead of working with &lt;code&gt;radio.whatever&lt;/code&gt; you need to work with &lt;code&gt;radio-&amp;gt;whatever&lt;/code&gt; since you are now using a pointer to an object not the object itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in your sketch you need to adjust your constructor to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24 myRadio(7, 8);&#xA;RadioComm rComm(myRadio);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The beauty of this is it decouples the configuration of the RF24 class from the RadioComm class, so you can use the same library in a different situation on a different board with different pins without having to change the library - just change the RF24 constructor in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also gives you direct access to the RF24 class in your sketch so you can do any advanced manual tweaks outside the library should you wish to.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-06T11:08:39.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16594" PostTypeId="1" CreationDate="2015-10-06T13:22:38.507" Score="0" ViewCount="461" Body="&lt;p&gt;I am using arduino uno and window7 64bit.I can't upload my program to arduino uno.When I upload it the warning message is show me.The warning message is&quot;WARNING:Category 'USB' in library keyboard and mouse is not valid. Setting to 'Uncategorized'.What can I do?&lt;/p&gt;&#xA;" OwnerUserId="13783" LastActivityDate="2015-10-06T22:49:54.070" Title="Can't upload my sketch from arduino IDE" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16595" PostTypeId="1" AcceptedAnswerId="16598" CreationDate="2015-10-06T13:50:46.487" Score="3" ViewCount="5361" Body="&lt;p&gt;I'm using Arduino Uno with MPU-9250 to find roll, pitch and yaw. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything works fine but I want to covert pitch from (+90/-90) to 360 degree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vec.setX(atan2(2.0 * (m_data[2] * m_data[3] + m_data[0] * m_data[1]),&#xA;        1 - 2.0 * (m_data[1] * m_data[1] + m_data[2] * m_data[2])));&#xA;&#xA;vec.setY(asin(2.0 * (m_data[0] * m_data[2] - m_data[1] * m_data[3])));&#xA;&#xA;vec.setZ(atan2(2.0 * (m_data[1] * m_data[2] + m_data[0] * m_data[3]),&#xA;        1 - 2.0 * (m_data[2] * m_data[2] + m_data[3] * m_data[3])));     &#xA;&#xA;m_data[0] = scalar;&#xA;&#xA;m_data[1] = x;&#xA;&#xA;m_data[2] = y;&#xA;&#xA;m_data[3] = z;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="13828" LastEditorUserId="10794" LastEditDate="2015-10-06T20:56:38.833" LastActivityDate="2015-10-07T04:02:54.737" Title="MPU-9250 : How to convert pitch (+90/-90) to 360 degree?" Tags="|arduino-uno|programming|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16596" PostTypeId="1" CreationDate="2015-10-06T16:30:15.443" Score="2" ViewCount="181" Body="&lt;p&gt;I have an arduino that I programmed a PWM signal on pin 5. When I power the arduino with 12v or USB5v, pin 5 has the PWM signal. Iam checking it with a oscilloscope. Oddly enough the arduino is not recognisable to a windows PC or MAC, the device never shows up on the usb. The LED on the device seem to give all the right signals. The Green ON LED is on. And the L LED is also on. The program is not using serial so the RX and TX are not on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try another Arduino it works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could I have broke? I am guessing the ATmega328 is fine?&lt;/p&gt;&#xA;" OwnerUserId="13832" LastEditorUserId="13832" LastEditDate="2015-10-06T17:12:32.790" LastActivityDate="2016-08-01T22:07:42.060" Title="Burned Arduino?" Tags="|arduino-uno|power|usb|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16597" PostTypeId="2" ParentId="16596" CreationDate="2015-10-06T16:40:48.957" Score="1" Body="&lt;p&gt;Just a guess, if anything else work fine, my (first) guess would be the serial to usb adapter. I damaged one a while ago on a breadboard but also dont know how. But it could also be almost everything else. The pwm sketch, in which language is it written and burned? Does the Atmega have a bootloader on it?&lt;/p&gt;&#xA;" OwnerUserId="13731" LastActivityDate="2015-10-06T16:40:48.957" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16598" PostTypeId="2" ParentId="16595" CreationDate="2015-10-06T17:05:02.453" Score="0" Body="&lt;p&gt;I assume you want to map the range &lt;code&gt;-90...-1&lt;/code&gt; to &lt;code&gt;270...359&lt;/code&gt; and the range &lt;code&gt;0...90&lt;/code&gt; to &lt;code&gt;0...90&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's simple enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (angle &amp;lt; 0) &#xA;    angle = 360 + angle;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you are &lt;em&gt;adding the negative value&lt;/em&gt; to 360, which is the same as &lt;em&gt;subtracting the positive value&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Or&lt;/em&gt; do you want to map it so that -90 is 0 and +90 is 360?  In that case you need to offset and scale it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;angle = angle + 90; // Angle is now 0..180&#xA;angle = angle * 2; // angle is now 0...360&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or in one line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;angle = (angle + 90) * 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-06T17:05:02.453" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16599" PostTypeId="1" AcceptedAnswerId="16604" CreationDate="2015-10-06T17:46:48.190" Score="1" ViewCount="244" Body="&lt;p&gt;I'm working a design project that measures the tiny changes of conductivity in a plant. (To visualize how a plant reacts to its environment) I'm working with Arduino to realize that. Two wires are hooked up to the plant to measure the changes and are connected to the Arduino. I haven't worked with Arduino before but a friend got me the code from his plant reader (he got help too and doesn't know how to build it anymore). I do understand most of it but I just don't manage to translate the code he gave me into a circuit on the Arduino bread board. I use processing to visualize the measurements afterwards.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IrmNL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IrmNL.png&quot; alt=&quot;Code plant reader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Who can help me building the circuit. I don't get what's happening at pin13. Thank you for helping me :)&lt;/p&gt;&#xA;" OwnerUserId="13834" LastActivityDate="2015-10-06T19:56:32.337" Title="Help understanding code to build circuit for plant reader" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16600" PostTypeId="2" ParentId="16573" CreationDate="2015-10-06T17:53:14.107" Score="0" Body="&lt;p&gt;I have found the answer. I am not an arduino-newbie, but I was thinking that probably I am making a stupid mistake somewhere. But the problem is in &lt;strong&gt;my arduino&lt;/strong&gt;. I tried setting pin D13 (and then all other pins) to HIGH, and I only measured &lt;strong&gt;4.60V&lt;/strong&gt;! I measured my USB port and it outputs 5.00V exactly, so there must be a problem in the arduino. So the solution - &lt;strong&gt;the ADC takes 4.60V as 1023, and therefore if you calculate it you get that the real voltage is 3.90V&lt;/strong&gt;, which is exactly the same as my DMM said. Thanks Majenko, you were pointing the right way :) By the way, I was using a cheap Arduino Nano from China, I bought it only for 2.2 USD from Ebay. When I used original Arduino, the code and circuit perfectly works. Do you think that this can limit the functionality of my board?&lt;/p&gt;&#xA;" OwnerUserId="12154" LastActivityDate="2015-10-06T17:53:14.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16602" PostTypeId="1" AcceptedAnswerId="16614" CreationDate="2015-10-06T18:27:41.587" Score="1" ViewCount="356" Body="&lt;p&gt;I am new to Arduino, also, I am not fluent in english.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish to create a controller for several circuits. All of those circuits are &quot;in parallel&quot; with additional circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do a Relay Shield protects the Arduino board from the current and voltage from the power supply?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Suppose the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EhmwY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EhmwY.png&quot; alt=&quot;Eletric wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The retangular boxes are &quot;parallel switches&quot; connected to the devices.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R = Power Supply Phase&#xA;&#xA;S = Another Power Supply Phase&#xA;&#xA;N = power Supply Neutral&#xA;&#xA;Arduino, C2 and C3 are 127 Volts, (S+N)&#xA;&#xA;C0 and C1 are 220 Volts (R+S)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Are the Shields safe from oscilations from the eletrical supply?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What / Where / How should I look on what to ground? Local regulations state that I cannot let R and/or S be grounded.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13833" LastEditorUserId="10794" LastEditDate="2015-10-06T20:36:12.047" LastActivityDate="2015-10-07T09:46:07.117" Title="Arduino and 127/220 Volts: Relay and Isolation" Tags="|arduino-mega|power|hardware|relay|system-design|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16603" PostTypeId="1" CreationDate="2015-10-06T18:06:29.690" Score="0" ViewCount="981" Body="&lt;p&gt;I'm connecting Arduino UNO to Xbee S2 Zigbee module directly, and X-CTU cannot find Xbee module via arduino. i'm not using shield, it finds with non-arduino board connecter, but not by arduino UNO board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i checked all parameters like baud rate, etc.., wirings, and it seems no problem at all, but it keeps msg like 'reset your radio module' and even i swtiched pin 5 and GND, it doesn't works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what i have to do?&lt;/p&gt;&#xA;" OwnerUserId="13867" OwnerDisplayName="HM11" LastActivityDate="2016-09-01T17:30:44.770" Title="Why I cannot connect directly Arduino UNO and Xbee S2?" Tags="|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16604" PostTypeId="2" ParentId="16599" CreationDate="2015-10-06T19:56:32.337" Score="2" Body="&lt;p&gt;Pin13 is attached to the onboard LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you see a reference to it, it means that the program is turning the light ON/OFF. You do not need to do any wiring with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the logic seems strange: it turns the LED off only when the analog reading is out of range (and it resets the stress).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to imply that once the plant is stressed, it will stay stressed :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, as side note: posting the code in ASCII form would allow people to quote/comment on it. The screenshot is not very good for that purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What cannot be figured out from the code, is how to instrument your plant.&#xA;If your friend has a working setup, you could try to replicate it.&#xA;At least post a few pictures.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-06T19:56:32.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16605" PostTypeId="2" ParentId="16594" CreationDate="2015-10-06T22:49:54.070" Score="1" Body="&lt;p&gt;Arduino IDEs v.1.6.x have recently been causing such kind of trouble on windows and mac systems. These problems seem to be caused by Java issues. Arduino IDE comes with java suit for it to work, installing java separately will cause problems. I suggest you uninstall java completely(by that i mean even the residue files that are not removed after uninstalling. For removing java completely you can use third party java remover like JavaRa ( &lt;a href=&quot;https://singularlabs.com/software/javara/&quot; rel=&quot;nofollow&quot;&gt;https://singularlabs.com/software/javara/&lt;/a&gt; ).&#xA;After doing so you can install the IDE again (i suggest to use .zip download of the IDE). &#xA;If it does'nt help it check this out &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=341144.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=341144.0&lt;/a&gt;&#xA;its possible that problem is caused by out dated executables after updating the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="13332" LastActivityDate="2015-10-06T22:49:54.070" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16606" PostTypeId="1" AcceptedAnswerId="16613" CreationDate="2015-10-07T00:41:41.917" Score="0" ViewCount="239" Body="&lt;p&gt;I was conducting some research on wireless communication between a simple transmitter and receiver module using an Arduino. Now, I tested the channel accuracy and i received 14% error for a delay of one micro second. For a delay of 2 microseconds, my error was 0%, and for three microseconds, my error rate was 30%. I am not quite sure why the data would result in this. I think it possibly has something to do with the gain on the receiver and the delay time. Some sweet spot perhaps? Can anyone offer me some ideas/explanations? Also, sorry for any confusion in this question. I am happy to clarify. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hey Everyone, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also had a question regarding what purpose each of the following delay serves in wireless communication. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Write each of the 8 bits&#xA;for (uint8_t i = 8; i &amp;gt; 0; --i)&#xA;{&#xA;  if (b &amp;amp; 1) // choose bit&#xA;    *reg |= reg_mask; // send 1&#xA;  else&#xA;    *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;  tunedDelay(delay);// line in question ---------------------&#xA;  b &amp;gt;&amp;gt;= 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the delay used in the regular blink program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The regular delay used in the blink programs was what set the 2 microsecond delays.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, I am looking at the read and recv methods in the software serial library and i don't see any checks for start bits, so what's the point of writing one in the write method? &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-10-07T01:08:17.797" LastActivityDate="2015-10-07T09:35:26.193" Title="What is the relationship between the gain on the receiver and the delay time" Tags="|arduino-uno|communication|softwareserial|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16607" PostTypeId="2" ParentId="16606" CreationDate="2015-10-07T02:02:26.273" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am looking at the read and recv methods in the software serial library and I don't see any checks for start bits, so what's the point of writing one in the write method? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The start bit is absolutely essential in serial comms. In the graphic below, the start bit is marked &quot;B&quot; - which distinguishes it from &quot;idle&quot; data which is &quot;A&quot;. Once received, the receiver then waits 1.5 bit times and starts clocking in the remaining bits. (Starting at &quot;C&quot; in the diagram, and then moving on for a total of 8 bits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xmEc6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xmEc6.png&quot; alt=&quot;One serial byte&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a start bit, how would the receiver know when the byte started? Imagine you wanted to send 0xFF (all 1 bits). Without a start bit that would be indistinguishable from the idle state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the graphic, &quot;D&quot; is the stop bit. Why have a stop bit? We need one (which is a &quot;1&quot; bit), so that we can detect the transition from the stop bit in the previous byte (a &quot;1&quot;) and the start bit in the next byte (a &quot;0&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the graphic, &quot;E&quot; is the start bit for the next byte.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't see any checks for start bits ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial has a pin-change interrupt set up to detect that the receiving pin has changed state (to a zero usually). &lt;strong&gt;That&lt;/strong&gt; is your start bit. You don't see it in the loop, because it has already arrived, otherwise you wouldn't be in the receive loop in the first place.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-07T02:02:26.273" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16608" PostTypeId="2" ParentId="16595" CreationDate="2015-10-07T04:02:54.737" Score="1" Body="&lt;p&gt;The equations in you example convert a quaternion representation of rotation into euler angles correctly; The &quot;pitch&quot; euler angle only has a valid range of +90/-90 and changing it will make your angular representation invalid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Euler angles specify an arbitrary rotation by 3 consecutive turns. You may want &quot;apparent angle with the horizon&quot;, which is not the same thing, and does not define a sequential set of turns to get from rotation A to B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get pitch and roll with the horizon from a quaternion, I think you want something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float x = 2*m_data[1]*m_data[3] - 2*m_data[2]*m_data[0];&#xA;float y = 2*m_data[1]*m_data[0] + 2*m_data[2]*m_data[3];&#xA;float z = 1 - 2*m_data[2]*m_data[2] - 2*m_data[1]*m_data[1];&#xA;&#xA;float pitch = atan2(y,z);&#xA;float roll  = atan2(x,z);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got this by rotating the vector &amp;lt;0,0,1&gt; by the quaternion and then measuring the angles of the result around x and y axis. This kind of freaks out when one of the angles is close to 90 degrees though; there are probably better equations out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Yaw vs the horizon&quot; doesn't make any sense, and people usually want the same &quot;style&quot; of yaw you are getting from the euler angle equations, so that shouldn't change.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2015-10-07T04:02:54.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16609" PostTypeId="1" AcceptedAnswerId="16611" CreationDate="2015-10-07T04:26:39.903" Score="1" ViewCount="636" Body="&lt;p&gt;So I'd like to connect two of these sensors to an Adafruit Flora (&lt;a href=&quot;https://www.adafruit.com/products/2020&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2020&lt;/a&gt;). In the product page it says you can only connect one but in the forum an admin said that you could do it but it required a bit of hacking. I'm new to arduinos and circuits in general. Can someone tell me how I could do this, or at least point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to use this multiplexer to use LSM9DS0's with the Flora.&#xA;&lt;a href=&quot;https://www.adafruit.com/products/2717&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2717&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2015-10-09T00:19:34.847" LastActivityDate="2015-10-09T00:19:34.847" Title="Connect 2 LSM9DS0 to Flora" Tags="|i2c|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16611" PostTypeId="2" ParentId="16609" CreationDate="2015-10-07T05:40:04.330" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-lsm9ds0-accelerometer-gyro-magnetometer-9-dof-breakouts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit's rectangular 9DOF&lt;/a&gt; device, unlike &lt;a href=&quot;https://www.adafruit.com/products/1059&quot; rel=&quot;nofollow noreferrer&quot;&gt;their round 9DOF&lt;/a&gt;, brings several more signals out to pads.  When using I²C with the rectangular 9DOF board, as I understand it signal pin SA0_G can be set low or high to modify the device address:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The SDO/SA0 pins (SDO_XM/SA0_XM or SDO_G/SA0_G) can be used to modify the least significant bit of the device address. If the SA0 pin is connected to the voltage supply, LSb is 1 (ex. address 0011101b) else if SA0 pad is connected to ground, the LSb value is 0 (ex. address 0011110b).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Controlling that signal should let you put multiple 9DOF's on one system.  (See my answer to  &lt;a href=&quot;https://arduino.stackexchange.com/questions/13830/arduino-due-and-bno055-address-in-i2c-mode/13833#13833&quot;&gt;question 13830&lt;/a&gt; for some additional comments on setting an I²C address.) Also see tables 15 and 16 on page 33 in the spec sheet (DM00087365.pdf) regarding addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you insist on using round 9DOFs for this application, you would need to find the trace from pin 22&lt;sup&gt;¤&lt;/sup&gt; of the LSM9DS0 to Vcc on &lt;em&gt;one&lt;/em&gt; of your 9DOF boards; working under a microscope with miniature tools, cut the trace and rewire the pin end of the trace to Ground.  This will change that board from using addresses 0x1D and 0x6B to 0x1E and 0x6C, if I correctly understand the spec sheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It probably would be a good idea to get one of the rectangular 9DOF's so that you could experiment with changing its addresses, before modifying one of the round ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;¤&lt;/sup&gt; Looking at the top of the chip, pin 24 is just clockwise from the depressed round dot marking pin 1; pin 22 is 1.75 mm from the corner.  See Figure 21, LGA 4x4x1 mm 24-lead outline, in the spec sheet.  That figure shows the underside of the chip.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-10-07T05:48:43.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16612" PostTypeId="2" ParentId="16582" CreationDate="2015-10-07T05:44:21.217" Score="2" Body="&lt;p&gt;Not a knob, but depending on your application, would a &lt;a href=&quot;https://www.sparkfun.com/products/10976&quot; rel=&quot;nofollow&quot;&gt;motorized slider like this be applicable&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would read it just as you would a potentiality, and you have a motor that you can use to drive it to a specific position when you make a change in your software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for knobs, I have seen very few if any &lt;em&gt;motorized knobs&lt;/em&gt;. What I would recommend here would be a continuous rotation encoder so that the position of the knob actually doesn't matter.&lt;/p&gt;&#xA;" OwnerUserId="407" LastActivityDate="2015-10-07T05:44:21.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16613" PostTypeId="2" ParentId="16606" CreationDate="2015-10-07T09:35:26.193" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, I tested the channel accuracy and i received 14% error for a delay of one micro second. For a delay of 2 microseconds, my error was 0%, and for three microseconds, my error rate was 30%.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Microsecond resolution delays on an Arduino are tenuous at best.  They aren't that accurate.  Simply because you're hitting the limit of the speed of the CPU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At 16MHz you have a clock period of 1/16000000 seconds.  That's 63ns.  That's the &lt;em&gt;granularity&lt;/em&gt; of the delays you can achieve - and that can only be achieved by inserting a precise number of &lt;code&gt;NOP&lt;/code&gt; assembly instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for the best 1µs delay possible you would need (0.000001 / 0.000000063) 15.87 &lt;code&gt;NOP&lt;/code&gt; instructions.  Of course, you can't have that many, so you have to round it either up or down.  Normal integer truncation would result in 15.  So that would actually be a delay of 945ns, which is an error of 5.5%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2µs would be (0.000002 / 0.000000063) 31.74 &lt;code&gt;NOP&lt;/code&gt; instructions, which would round to 31, so 1.953µs, or an error of 2.35%.  As you can see increasing the length generally reduces the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;HOWEVER&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The delay function on the Arduino for microsecond accuracy (&lt;code&gt;delayMicroseconds()&lt;/code&gt;) is maybe not as accurate as it could be.  Simply because it's impossible to just have an exact number of NOP instructions for a delay since you can't know how long the delay should be until the function is called with a parameter detailing how long the delay should be.  So it has to perform a number of calculations and &lt;em&gt;make a number of assumptions&lt;/em&gt;.  It tries to come close, but it was written for one specific version of the compiler and compilers change. Things may have been changed in how the function gets called, and how long parts of it take (what registers are pushed and popped may change with different compiler versions, for instance).  So it's not a perfectly reliable delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more detail you can look at the source code of it (it's in &lt;code&gt;wiring.c&lt;/code&gt;) and you can see how for small delays it's very hard to get it right. For instance, this couple of lines highlights the problem nicely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // for a one-microsecond delay, simply return.  the overhead&#xA;    // of the function call yields a delay of approximately 1 1/8 us.&#xA;    if (--us == 0)&#xA;        return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of the word &lt;em&gt;approximately&lt;/em&gt; there...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you need to note that the delay functions are just that - a delay &lt;em&gt;at that specific moment in time from the start of the call to its finish&lt;/em&gt;.  It doesn't take into account anything else that's going on in your code, so a delay of 1µs in a loop of code that does other things will end up in a loop that takes &lt;code&gt;X + 1µs&lt;/code&gt; where &lt;code&gt;X&lt;/code&gt; is the amount of time that the rest of the code takes to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's where the &lt;code&gt;tunedDelay()&lt;/code&gt; function comes in.  It has been specially written to be used in that specific circumstance to provide a delay that &lt;em&gt;takes into account the time the rest of the loop takes to run&lt;/em&gt;.  That is, the loop's time plus the &lt;code&gt;tunedDelay&lt;/code&gt; time equate to the final period you want for the whole loop.  For asynchronous serial communications the timing accuracy is important.  Since there is no separate (or even embedded) clock to get the timing from both ends have to agree what speed the communication happens at (the baud rate), and any deviation from that can cause communication errors.  So the timing has to be as close as possible. A normal &lt;code&gt;delayMicroseconds()&lt;/code&gt; function call just wouldn't cut the mustard - they needed it more precise than that.  Manually tuned to have specific delay values that are as precise as possible, and that was done for specific baud rates on specific speed chips.  Each supported frequency has a table such as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const DELAY_TABLE PROGMEM table[] =&#xA;{&#xA;  //  baud    rxcenter   rxintra    rxstop    tx&#xA;  { 115200,   1,         17,        17,       12,    },&#xA;  { 57600,    10,        37,        37,       33,    },&#xA;  { 38400,    25,        57,        57,       54,    },&#xA;  { 31250,    31,        70,        70,       68,    },&#xA;  { 28800,    34,        77,        77,       74,    },&#xA;  { 19200,    54,        117,       117,      114,   },&#xA;  { 14400,    74,        156,       156,      153,   },&#xA;  { 9600,     114,       236,       236,      233,   },&#xA;  { 4800,     233,       474,       474,      471,   },&#xA;  { 2400,     471,       950,       950,      947,   },&#xA;  { 1200,     947,       1902,      1902,     1899,  },&#xA;  { 600,      1902,      3804,      3804,     3800,  },&#xA;  { 300,      3804,      7617,      7617,     7614,  },&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's the value to send to the &lt;code&gt;tunedDelay()&lt;/code&gt; function in the four different situations where its used for each of the baud rates at that specific clock frequency (16MHz in that example).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tunedDelay()&lt;/code&gt; itself is written in assembly code and is a very tight loop for the number of iterations specified in the parameter.  The shortest possible piece of code with the minimum of overhead to get the maximum accuracy and finest granularity (least number of clock cycles for one iteration) out of it.  &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-07T09:35:26.193" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16614" PostTypeId="2" ParentId="16602" CreationDate="2015-10-07T09:46:07.117" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Do a Relay Shield protects the Arduino board from the current and voltage from the power supply?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A relay provides &lt;em&gt;galvanic isolation&lt;/em&gt; in the circuit.  The mains power is electrically isolated from the rest of the circuit since the device that performs the actual switching (the contacts in the relay) have no physical connection to the rest of the circuit - they are merely acted upon by magnetism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That doesn't mean that it's &lt;em&gt;safe&lt;/em&gt;, however.  There are a number of things you still need to deal with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino cannot directly drive a relay - it can't provide enough current. You must use a drive circuit.&lt;/li&gt;&#xA;&lt;li&gt;Back-EMF from the relay coil as the magnetic field collapses can damage sensitive semiconductors - good snubber circuit design is important here.&lt;/li&gt;&#xA;&lt;li&gt;Mains electricity is dangerous and must be treated with respect.  Proper circuit design is paramount to ensure that the mains is kept away from the rest of the circuit. Proper connectors must be used and exposed high voltage points must be rendered inaccessible, either by the project housing or by the addition of plastic insulating shielding.&lt;/li&gt;&#xA;&lt;li&gt;Relays as they turn on and off cause sparks. Sparks cause EMI. EMI causes induced currents. Induced currents cause damage to electronics.  Minimizing the spark generation not only prolongs the life of your relay but the life of everything else around. Ensure your relays can switch fast enough for the currents you are dealing with, or consider using &lt;em&gt;solid state relays&lt;/em&gt; (SSRs) that don't suffer from this issue.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-07T09:46:07.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16615" PostTypeId="2" ParentId="16603" CreationDate="2015-10-07T10:12:16.367" Score="1" Body="&lt;p&gt;If you want X-CTU to see the Xbee while it's connected to the Arduino, you have to connect the Arduino's reset pin to ground. This bypasses the Arduino's MCU and allows the Arduino to act as a USB to serial adapter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also don't forget to connect the Arduino's Tx to the Xbee's Tx when it's connected like this, and likewise with the 2 Rx's.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-07T10:12:16.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16616" PostTypeId="1" CreationDate="2015-10-07T12:29:52.993" Score="0" ViewCount="2264" Body="&lt;p&gt;In my project I want to retrieve the Latitude and longitude and then transmit to a cell phone through GSM module. But the GSM as well as GPS modules uses the same pins i.e. Tx and Rx, so is it possible to use both modules at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link to products&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GSM - &lt;a href=&quot;http://www.ebay.co.uk/itm/SIM800L-GPRS-GSM-Module-SIM-Board-Quadband-PCB-Antenna-for-MCU-Arduino-/191611848583?hash=item2c9cf4c787&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/SIM800L-GPRS-GSM-Module-SIM-Board-Quadband-PCB-Antenna-for-MCU-Arduino-/191611848583?hash=item2c9cf4c787&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS-- &lt;a href=&quot;http://www.ebay.co.uk/itm/New-1PC-Ublox-NEO6MV2-GPS-Module-Aircraft-Flight-Controller-For-Arduino-/400830328802?hash=item5d53596fe2&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/New-1PC-Ublox-NEO6MV2-GPS-Module-Aircraft-Flight-Controller-For-Arduino-/400830328802?hash=item5d53596fe2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="4437" LastActivityDate="2016-12-20T07:49:12.150" Title="Can I use GSM and GPS modules at the same time?" Tags="|gsm|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16617" PostTypeId="2" ParentId="16616" CreationDate="2015-10-07T12:33:50.220" Score="2" Body="&lt;p&gt;Yes.  Use SoftwareSerial for one of them.  That way you can use any pins you like for that module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd recommend using the GPS module on the SoftwareSerial since it's (mainly) half duplex, and SoftwareSerial can't both transmit and receive at the same time like the hardware UART can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either that or switch to a different Arduino board that has more than one hardware UART.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-07T12:33:50.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16619" PostTypeId="1" CreationDate="2015-10-07T14:54:28.000" Score="0" ViewCount="3433" Body="&lt;p&gt;I have followed all the instructions provided on  &lt;a href=&quot;http://allaboutee.com/2015/01/20/esp8266-android-application-for-arduino-pin-control/&quot; rel=&quot;nofollow&quot;&gt;http://allaboutee.com/2015/01/20/esp8266-android-application-for-arduino-pin-control/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have got the correct setup, I have got the message &quot;Server Ready&quot; in the serial monitor, i have an app similar to this, means the only thing i have done different from the web page is removing two buttons from the app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then also whenever i use my app to send request parameters to arduino it says &quot;connection to 192.168.x.x:xx refused&quot; , when i put the same ip and port in chrome, it says Server not reachable, the website may be down, What to do ? , Please help...&lt;/p&gt;&#xA;" OwnerUserId="13514" LastActivityDate="2019-06-15T10:51:18.160" Title="Esp8266 server unreachable. Port doesn't open" Tags="|arduino-uno|wifi|esp8266|android|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16620" PostTypeId="1" AcceptedAnswerId="18414" CreationDate="2015-10-07T10:24:07.170" Score="0" ViewCount="258" Body="&lt;p&gt;I am working on a project which includes Arduino and a fingerprint scanner. It is completely based on embedded system. But then, I have downloaded a library for the fingerprint scanner. When I run the program I get an error which maps to the cpp file of the library file. See below to see the error and the library file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Error&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;FPS_GT511C3\FPS_GT511C3.c.cpp.o: In function&#xA;  Command_Packet::GetPacketBytes()':&#xA;  C:\Users\Dipti\Documents\Arduino\libraries\FPS_GT511C3/FPS_GT511C3.c.cpp:17:&#xA;  undefined reference tooperator new[](unsigned int)'&#xA;  FPS_GT511C3\FPS_GT511C3.c.cpp.o: In function&#xA;  FPS_GT511C3::GetResponse()':&#xA;  C:\Users\Dipti\Documents\Arduino\libraries\FPS_GT511C3/FPS_GT511C3.c.cpp:735:&#xA;  undefined reference tooperator new[](unsigned int)' collect2.exe:&#xA;  error: ld returned 1 exit status&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Library File (CPP)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;byte* packetbytes= new byte[12];&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;byte* resp = new byte[12];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13872" OwnerDisplayName="Abel Luke" LastActivityDate="2015-12-04T01:15:57.367" Title="Error in Arduino Library file" Tags="|c++|library|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16621" PostTypeId="1" CreationDate="2015-10-07T16:08:43.947" Score="0" ViewCount="1413" Body="&lt;p&gt;I'm a web developer and I started building a small environment logger that will post to my website`s API. I'm really new to this kind of coding so bare with me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since yesterday, the whole Arduino started to acting funny. After the first or second request to the server(with already tested code), I started sending corrupted JSON data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;:12&quot;: &quot;module3&quot;,&#xA;  &quot;10-7 18:26&quot;: {&#xA;    &quot;1&quot;: {&#xA;      &quot;&quot;: 21.50,&#xA;      &quot;26:12&quot;: 55.50,&#xA;      &quot;measured_at&quot;: &quot;2015-10-7 18:26:12&quot;&#xA;    },&#xA;    &quot;2&quot;: {&#xA;      &quot;&quot;: 21.10,&#xA;      &quot;26:12&quot;: 55.70,&#xA;      &quot;measured_at&quot;: &quot;2015-10-7 18:26:12&quot;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where it should be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  &quot;modulename&quot;: &quot;module3&quot;,&#xA;  &quot;environments&quot;: {&#xA;    &quot;1&quot;: {&#xA;      &quot;temperature&quot;: 21.40,&#xA;      &quot;humidity&quot;: 55.60,&#xA;      &quot;measured_at&quot;: &quot;2015-10-7 18:25:52&quot;&#xA;    },&#xA;    &quot;2&quot;: {&#xA;      &quot;temperature&quot;: 21.20,&#xA;      &quot;humidity&quot;: 55.80,&#xA;      &quot;measured_at&quot;: &quot;2015-10-7 18:25:52&quot;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second JSON is from the initial request to the server. The first one is the corrupted one. I tried stopping all kinds of parts from the code, without any luck, except when I enter the measured_at manually (without getting the data from the RTC.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DHT.h&amp;gt;&#xA;&#xA;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;&#xA;#include &amp;lt;DS3231.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;//Json Library&#xA;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // RESERVED MAC ADDRESS&#xA;EthernetClient client;&#xA;&#xA;const String module_name = &quot;module3&quot;;&#xA;&#xA;DHT dht1;&#xA;DHT dht2;&#xA;&#xA;DS3231 clock;&#xA;RTCDateTime dt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;&#xA;LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;&#xA;elapsedMillis timer0;&#xA;const long interval = 10000; // READING INTERVAL&#xA;&#xA;int connected_sensors = 0;&#xA;float t1 = 0;  // TEMPERATURE VAR&#xA;float h1 = 0; // HUMIDITY VAR&#xA;float t2 = 0;&#xA;float h2 = 0;&#xA;&#xA;int nc = 0; //Network connection simulation INI&#xA;&#xA;&#xA;byte temp[8] = { //icon for thermometer&#xA;&#xA;  B00100,&#xA;  B01010,&#xA;  B01010,&#xA;  B01110,&#xA;  B01110,&#xA;  B11111,&#xA;  B11111,&#xA;  B01110&#xA;};&#xA;&#xA;byte humi[8] = { //icon for water droplet&#xA;  B00100,&#xA;  B00100,&#xA;  B01010,&#xA;  B01010,&#xA;  B10001,&#xA;  B10001,&#xA;  B10001,&#xA;  B01110,&#xA;};&#xA;&#xA;byte sconnect[8] = { //icon for connection&#xA;  0b00000,&#xA;  0b11111,&#xA;  0b10001,&#xA;  0b10001,&#xA;  0b11111,&#xA;  0b00100,&#xA;  0b11111,&#xA;  0b00000&#xA;};&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  clock.begin();&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  Serial.println(&quot;Terrarium Serial&quot;);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;Weather v0.1&quot;);&#xA;  delay(1000);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Sensor loading...&quot;);&#xA;&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Network check...&quot;);&#xA;&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;); //There is a problem with DHCP&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;DHCP ERROR&quot;);&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;Please Restart&quot;);&#xA;    for (;;)&#xA;      ;&#xA;  }&#xA;  nc = 1;&#xA;&#xA;  delay(2000);&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(Ethernet.localIP());&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.println(&quot;Ready!&quot;);&#xA;&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;  Serial.println(Ethernet.localIP());&#xA;&#xA;  delay(4000);&#xA;  lcd.clear();&#xA;&#xA;  lcd.createChar(1, temp);&#xA;  lcd.createChar(2, humi);&#xA;  lcd.createChar(3, sconnect);&#xA;&#xA;  dht1.setup(15); &#xA;  dht2.setup(16);&#xA;&#xA;  h1 = dht1.getHumidity();&#xA;  t1 = dht1.getTemperature();&#xA;&#xA;  h2 = dht2.getHumidity();&#xA;  t2 = dht2.getTemperature();&#xA;&#xA;  delay(2000);&#xA;&#xA;  //Display the statics on the display&#xA;  lcd.setCursor(2, 0);&#xA;  lcd.print(module_name);&#xA;  lcd.setCursor(9, 1);&#xA;  lcd.write(2);&#xA;  lcd.setCursor(15, 1);&#xA;  lcd.print(&quot;%&quot;);&#xA;  lcd.setCursor(2, 1);&#xA;  lcd.write(1);&#xA;  lcd.setCursor(8, 1);&#xA;  lcd.print((char)223);&#xA;&#xA;  timer0 = 0; // clear the timer at the end of startup&#xA;&#xA;}&#xA;void CheckSensors() {&#xA;&#xA;  if (timer0 &amp;gt;= interval) { // READ ONLY ONCE PER INTERVAL&#xA;    timer0 -= interval;&#xA;&#xA;    dt = clock.getDateTime(); //get current time&#xA;&#xA;    h1 = dht1.getHumidity();&#xA;    t1 = dht1.getTemperature();&#xA;&#xA;    h2 = dht2.getHumidity();&#xA;    t2 = dht2.getTemperature();&#xA;&#xA;    DataSend(); //send data&#xA;  }&#xA;}&#xA;&#xA;//Print the changeable values on the display&#xA;void LcdPint() {&#xA;  lcd.setCursor(0, 0);&#xA;  if (nc == 1) {&#xA;    lcd.write(3);&#xA;  } else if (nc == 0) {&#xA;    lcd.print(&quot; &quot;);&#xA;  } else if (nc == 2) {&#xA;    lcd.print(&quot;E&quot;);&#xA;  }&#xA;&#xA;  lcd.setCursor(10, 1);&#xA;  lcd.print(h1);&#xA;&#xA;  lcd.setCursor(3, 1);&#xA;  lcd.print(t1);&#xA;&#xA;}&#xA;&#xA;//Construct the JSON response&#xA;JsonObject&amp;amp; prepareResponse(JsonBuffer&amp;amp; jsonBuffer, String measured_at) {&#xA;&#xA;  JsonObject&amp;amp; root = jsonBuffer.createObject();&#xA;  root[&quot;modulename&quot;] = module_name;&#xA;&#xA;  JsonObject&amp;amp; environmentsObject = root.createNestedObject(&quot;environments&quot;);&#xA;&#xA;&#xA;    JsonObject&amp;amp; environmentsOne = environmentsObject.createNestedObject(&quot;1&quot;); &#xA;    environmentsOne[&quot;temperature&quot;] = t1;&#xA;    environmentsOne[&quot;humidity&quot;] = h1;&#xA;    environmentsOne[&quot;measured_at&quot;] =  measured_at;&#xA;&#xA;    JsonObject&amp;amp; environmentsTwo = environmentsObject.createNestedObject(&quot;2&quot;);&#xA;    environmentsTwo[&quot;temperature&quot;] = t2;&#xA;    environmentsTwo[&quot;humidity&quot;] = h2;&#xA;    environmentsTwo[&quot;measured_at&quot;] =  measured_at;&#xA;&#xA;  return root;&#xA;}&#xA;&#xA;void writeResponse(EthernetClient&amp;amp; client, JsonObject&amp;amp; json) {&#xA;&#xA;  char buffer[256];&#xA;  json.printTo(buffer, sizeof(buffer));&#xA;&#xA;  if (client.connect(&quot;api.terrariums.eu&quot;, 80)) { // REPLACE WITH YOUR SERVER ADDRESS&#xA;    client.println(&quot;POST /v1/sensors HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: api.terrariums.eu&quot;); // SERVER ADDRESS HERE TOO&#xA;    client.println(&quot;Content-Type: application/json&quot;);&#xA;    client.println(&quot;Authorization: Basic bW9kdWxlMzoxMzIxMzI=&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(strlen(buffer));&#xA;    client.println();&#xA;    client.println(buffer);&#xA;&#xA;    nc = 1;&#xA;  } else {&#xA;    nc = 2;&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;&#xA;  while (client.connected())&#xA;  {&#xA;    if ( client.available() )&#xA;    {&#xA;      char c = client.read();&#xA;      Serial.print(c);&#xA;    }&#xA;  }&#xA;  Serial.println();&#xA;  client.stop();&#xA;  //End  post request&#xA;&#xA;}&#xA;void DataSend() {&#xA;&#xA;    //This is the part that I think crashes my entire code. I tried using the helper with the RTC library that I use&#xA;    //but that made things worse.&#xA;&#xA;    String measured_at = (String) dt.year + &quot;-&quot; + dt.month + &quot;-&quot; + dt.day  + &quot; &quot; + dt.hour   + &quot;:&quot; + dt.minute + &quot;:&quot; + dt.second;&#xA;&#xA;    StaticJsonBuffer&amp;lt;200&amp;gt; jsonBuffer;&#xA;    JsonObject&amp;amp; json = prepareResponse(jsonBuffer, measured_at);&#xA;    json.prettyPrintTo(Serial);&#xA;&#xA;    writeResponse(client, json);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  CheckSensors();&#xA;  LcdPint();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13855" LastEditorUserId="10794" LastEditDate="2015-10-07T20:06:26.477" LastActivityDate="2016-02-05T00:48:22.073" Title="Json gets corrupted after first HTTP request" Tags="|arduino-uno|c++|ethernet|rtc|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="16622" PostTypeId="2" ParentId="16619" CreationDate="2015-10-07T16:28:33.463" Score="1" Body="&lt;p&gt;The ESP module is not that difficult to work with, if you send the correct parameters to it AND you have the correct power it should work as expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main suspicions will be cabling (just triple check that connections are as expected) and power source (the ESP is VERY power hungry, if you are powering the ESP from the Arduino that is your problem, you need a very good and stable power for the ESP to work (it might show up on your network but will not have enough power to actually send anything and it will disconnect (that will still show up on your router, it depends on how fast it connects/disconnects but won't be able to send anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This link can provide some good information about this subject:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://bbs.espressif.com/viewtopic.php?t=133&quot; rel=&quot;nofollow&quot;&gt;http://bbs.espressif.com/viewtopic.php?t=133&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13856" LastActivityDate="2015-10-07T16:28:33.463" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16623" PostTypeId="2" ParentId="16548" CreationDate="2015-10-07T17:17:10.920" Score="0" Body="&lt;p&gt;The main problem cause was inaccurate internal clock. As soon, as external 8MHz crystal has been attached to XTAL pins (with a pair of 22pF capacitors to GND), problems with turning the board on disappeared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I found&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;loop in the Adafruit's nRF8001 library, which runs whenever problems with the Bluefruit LE board are encountered. That is possibly why interrupts worked fine, but the whole MCU never returned to the main loop. &lt;/p&gt;&#xA;" OwnerUserId="12167" LastActivityDate="2015-10-07T17:17:10.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16624" PostTypeId="2" ParentId="16621" CreationDate="2015-10-07T17:32:25.950" Score="1" Body="&lt;p&gt;In all probability you are either running out of memory, or the libraries you are using (and the fact that you are abusing String objects) is fragmenting your heap to such an extent that your whole 2KB of RAM is being used and you are ending up with a stack-and-heap collision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to remember that the Arduino Uno only has 2KB of RAM.  It's not a computer, and has no OS, and as such you have to unlearn much of what you know about programming and do things slightly differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first problem you have is with your String abuse.  This line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String measured_at = (String) dt.year + &quot;-&quot; + dt.month + &quot;-&quot; + dt.day  + &quot; &quot; + dt.hour   + &quot;:&quot; + dt.minute + &quot;:&quot; + dt.second;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be doing horrible things to your heap.  The String class dynamically allocates memory on the heap to store the string content.  The operations you have there inadvertently create a rather alarming number of temporary Strings which are then thrown away at the end.  Every temporary String dynamically allocates RAM on the heap and can potentially lead to heap fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the numeric value &lt;code&gt;dt.second&lt;/code&gt; is first converted to a String and memory allocated to store the content.  Every concatenation results in a new String with its dynamic allocation, etc.  Quite messy really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, who knows what dynamic memory the &lt;code&gt;ArduinoJSON&lt;/code&gt; library is using - quite a lot would be my guess - every tag, every value, etc, would need to be stored in memory somewhere, and unless they statically allocate a huge chunk of RAM (wasting most of your precious resource) they will be doing dynamic allocation - and that will make matters much worse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how would you get around it? It's actually quite simple - you need to think more about spoon-feeding a baby instead of preparing a 5 course banquet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of building up big objects with lots of data in them and sending them all out in one big chunk you need to just send little bits at a time.  There is absolutely no reason to use things like ArduinoJSON if all you are doing is sending data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance to send the JSON data you could do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (client.connect(&quot;api.terrariums.eu&quot;, 80)) { // REPLACE WITH YOUR SERVER ADDRESS&#xA;    client.println(&quot;POST /v1/sensors HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: api.terrariums.eu&quot;); // SERVER ADDRESS HERE TOO&#xA;    client.println(&quot;Content-Type: application/json&quot;);&#xA;    client.println(&quot;Authorization: Basic bW9kdWxlMzoxMzIxMzI=&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;&#xA;    client.println(&quot;{&quot;);&#xA;    client.println(&quot;    \&quot;modulename\&quot;: \&quot;module3\&quot;,&quot;);&#xA;    client.println(&quot;    \&quot;environments\&quot;: {&quot;);&#xA;    client.println(&quot;        \&quot;1\&quot;: {&quot;);&#xA;    client.print(&quot;            \&quot;temperature\&quot;:&#xA;    client.print(t1);&#xA;    client.println(&quot;,&quot;);&#xA;    client.print(&quot;            \&quot;humidity\&quot;:&#xA;    client.print(h1);&#xA;    client.println(&quot;,&quot;);&#xA;    client.println(&quot;        },&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Etc.  You get the drift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You notice I removed the &lt;code&gt;Content-length&lt;/code&gt; header?  That's because you don't know how long the content will be now (one drawback), so to signal the end of the transmission you will have to close the connection (I don't recall if &lt;code&gt;client&lt;/code&gt; has a way of only half closing - just the TX portion) to signal to the web server that you have finished.  However, if you know how long your numbers will be (say you format them to a specific number of characters) then your body size would always be the same and you can hard code a &lt;code&gt;Content-length&lt;/code&gt; header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also - do you really need to send the time and date?  Surely the computer has a better idea of what the current time and date is than the Arduino - just use the computer's internal clock.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-07T17:32:25.950" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16625" PostTypeId="1" AcceptedAnswerId="16626" CreationDate="2015-10-07T19:02:52.590" Score="0" ViewCount="845" Body="&lt;p&gt;I found two cheap GSM module on ebay but didn't know that I can use them with Arduino or not.&#xA;Will you help me please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the link-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/Smallest-SIM800L-GSM-Module-Micro-SIM-Board-Quad-band-Port-Onboard-Antenna-/111789339320?hash=item1a0729f2b8&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/Smallest-SIM800L-GSM-Module-Micro-SIM-Board-Quad-band-Port-Onboard-Antenna-/111789339320?hash=item1a0729f2b8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/SIM900A-Development-Board-Extension-Module-GSM-GPRS-Antenna-TTL-e/281517486292?_trksid=p2045573.c100033.m2042&amp;amp;_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20131017132637%26meid%3D70128bc79b60410d862b64d36cc479b3%26pid%3D100033%26rk%3D1%26rkt%3D4%26sd%3D281517486292&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/SIM900A-Development-Board-Extension-Module-GSM-GPRS-Antenna-TTL-e/281517486292?_trksid=p2045573.c100033.m2042&amp;amp;_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20131017132637%26meid%3D70128bc79b60410d862b64d36cc479b3%26pid%3D100033%26rk%3D1%26rkt%3D4%26sd%3D281517486292&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4437" LastActivityDate="2016-05-09T21:28:50.577" Title="Can I use these cheap GSM module with arduino?" Tags="|arduino-uno|gsm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16626" PostTypeId="2" ParentId="16625" CreationDate="2015-10-07T19:09:35.353" Score="0" Body="&lt;p&gt;Both seem to have the pin header for a serial port. So chances are that they can take standard AT commands.&#xA;I've seen many modems using additional AT commands for special functions, but they all supported also the basic AT commands.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-07T19:09:35.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16628" PostTypeId="2" ParentId="16621" CreationDate="2015-10-07T20:08:37.753" Score="2" Body="&lt;p&gt;You have used 461 out of 2048 of your RAM bytes for string literals alone. At the very least, use the &lt;code&gt;F()&lt;/code&gt; macro where you can, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(F(&quot;POST /v1/sensors HTTP/1.1&quot;));&#xA;client.println(F(&quot;Host: api.terrariums.eu&quot;)); // SERVER ADDRESS HERE TOO&#xA;client.println(F(&quot;Content-Type: application/json&quot;));&#xA;client.println(F(&quot;Authorization: Basic bW9kdWxlMzoxMzIxMzI=&quot;));&#xA;client.println(F(&quot;Connection: close&quot;));&#xA;client.print(F(&quot;Content-Length: &quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ditto for &lt;code&gt;Serial.print&lt;/code&gt; and &lt;code&gt;lcd.print&lt;/code&gt; where you are printing strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, what Majenko suggested is a good idea. Using a custom library is well and good, but JSON is easy enough to output directly. Just make a small function to do it for you.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Problem now is the Content-length... How do I calculate it ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Do you absolutely need it? If you do, instead of building up the entire content first, I suggest two passes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First pass outputs to a dummy class which simply calculates the length, second pass actually outputs. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// outputting class that just counts output&#xA;class DummyOutput : public Print&#xA;{&#xA;private:&#xA;  unsigned long length_;&#xA;&#xA;public:&#xA;  void begin () &#xA;    { &#xA;    length_ = 0; &#xA;    }&#xA;  virtual size_t write (byte c)&#xA;    {&#xA;    length_++;&#xA;    return 1;&#xA;    }&#xA;  unsigned long getLength () const { return length_; }&#xA;&#xA;};  // end of DummyOutput&#xA;&#xA;DummyOutput countOutput;  // instance of DummyOutput&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (&quot;Starting&quot;);&#xA;&#xA;  Print * outputter;  // where to write to&#xA;&#xA;  for (int pass = 1; pass &amp;lt;= 2; pass++)&#xA;    {&#xA;    randomSeed (1);&#xA;    switch (pass)&#xA;     {&#xA;     case 1: outputter = &amp;amp;countOutput;&#xA;             countOutput.begin ();&#xA;             break;&#xA;&#xA;     case 2: outputter = &amp;amp;Serial;&#xA;             break;&#xA;     } // end of switch&#xA;&#xA;    // generate some output&#xA;    for (int i = 0; i &amp;lt; 25; i++)&#xA;      {&#xA;      outputter-&amp;gt;print (random (5000));&#xA;      outputter-&amp;gt;print ('\n');&#xA;      }&#xA;&#xA;    switch (pass)&#xA;     {&#xA;     case 1: Serial.print (F(&quot;Content-length: &quot;));&#xA;             Serial.println (countOutput.getLength ());&#xA;             break;&#xA;&#xA;     case 2: break;&#xA;     } // end of switch&#xA;&#xA;    }  // end of for loop&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting&#xA;Content-length: 121&#xA;1807&#xA;249&#xA;73&#xA;3658&#xA;3930&#xA;1272&#xA;2544&#xA;878&#xA;2923&#xA;2709&#xA;4440&#xA;3165&#xA;4492&#xA;3042&#xA;2987&#xA;2503&#xA;2327&#xA;1729&#xA;3840&#xA;2612&#xA;4303&#xA;3169&#xA;2709&#xA;2157&#xA;4560&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By generating the same output in two passes you can first just calculate the length (without outputting) and the second time you can output that length first, and then output the actual data.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-07T22:08:06.090" LastActivityDate="2015-10-07T22:08:06.090" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16629" PostTypeId="2" ParentId="11946" CreationDate="2015-10-07T20:59:20.037" Score="1" Body="&lt;p&gt;The sensor you have in your scale are a simple voltage dividers. Each consist of one resistor and one extensiometer, both connected in series. One wire (E+) is VDD another (E-) is GND and the third is divider output(S). You can not directly use it with HX711 which needs a bridge sensors not just dividers. You can try to set a 1/2vdd on S- and connect the signal from the sensor to S+. In case you get a negative weight, simply swap these connections. Your assumption that your scale uses full bridge, because it has four sensors, is completly wrong. You can read the signals  from the scale sensors using analog inputs in you arduino (without HX711) but you should amplify it before to get reasonable resolution. Good luck!&#xA;Greg&lt;/p&gt;&#xA;" OwnerUserId="13860" LastActivityDate="2015-10-07T20:59:20.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16631" PostTypeId="2" ParentId="14018" CreationDate="2015-10-07T21:48:02.463" Score="1" Body="&lt;p&gt;I have the OS X 10.11 installed and was unable to upload to my Arduino board. I always got stuck with the error code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude stk500_getsync() not in sync resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After installing the &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;FTDI driver&lt;/a&gt; it didnt't work either. So I figured out Apple provides it's own FTDI driver kernel extension since OS X 10.9, named &lt;em&gt;AppleUSBFTDI.kext&lt;/em&gt;. So the AppleUSBFTDI kernel extension interferes with the FTDI driver. An USB port shows up in the Arduino Application, but no communication involving avrdude is possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution (without modifying or disabling any system security options introduced in 10.11):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Open a terminal&lt;/li&gt;&#xA;&lt;li&gt;Execute: &lt;em&gt;sudo kextunload /System/Library/Extensions/AppleUSBFTDI.kext/&lt;/em&gt; -&gt; this will unload the Apple FTDI Kernel extension.&lt;/li&gt;&#xA;&lt;li&gt;Reinstall the &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow&quot;&gt;FTDI driver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Start the Arduino IDE, select a Com Port, the correct Arduino board&lt;/li&gt;&#xA;&lt;li&gt;Compile and upload your sketch to the board.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please note that &lt;em&gt;kextunload&lt;/em&gt; will only temporarily unload the module. When your system gets rebooted, you have to do this step again. It's possible to remove the kernel extension, but out of security reasons I don't describe how to do it in this post. If you're familiar with the console, you know how to do this :)&lt;/p&gt;&#xA;" OwnerUserId="13861" LastEditorUserId="6936" LastEditDate="2016-02-12T03:55:19.780" LastActivityDate="2016-02-12T03:55:19.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16633" PostTypeId="2" ParentId="8659" CreationDate="2015-10-08T01:58:51.617" Score="0" Body="&lt;p&gt;I know this is after the fact but &quot;Back EMF &quot; is more than likely the issue with the starting and stopping of the servo's and most likely the DC motors.&#xA;The power supply could receive a pulse 4 to 5 times its supply voltage. The cpu could be scrambled or reset. Or pulses sent to servos corrupted. Divert the energy of a motor's collapsing magnetic field back into itself with a diode, cathode to the positive supply rail. Basically any time you stop or start a motor its magnetic field has to go somewhere.Digital hates that.&lt;/p&gt;&#xA;" OwnerUserId="13868" LastActivityDate="2015-10-08T01:58:51.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16634" PostTypeId="2" ParentId="11690" CreationDate="2015-10-08T04:57:01.137" Score="0" Body="&lt;p&gt;Not directly stacking, no. You could do a dirty trick where you bend the serial pins out sideways, letting the stack handle all the power and ground and wakeup pins and stuff. Then handle the serial communications with each module separately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno and similar only have a single UART (serial port) each, but you can emulate more with &quot;software serial&quot;, aka &quot;bit-bang&quot; techniques. These are full of caveats and I wouldn't wish them on a newbie.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Mega2560 has four UARTs, so you're getting closer. You'd need to use wires coming off those sideways-bent pins to bring the signals down to the different tx/rx pins per UART, but I could see it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also add UARTs over SPI/I2C, but that's getting into a good bit of program complexity. Look at the SC16IS750 or the MAX3100 for starters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There's also a horrible, horrible hack emerging in my mind: Connect a single transmit line to a demux chip, so you can pick a single TC35 to talk to at any given moment. Bus all the receive lines together with resistors/diodes. Hope you never end up in a situation where two are talking at once.) &lt;/p&gt;&#xA;" OwnerUserId="13869" LastActivityDate="2015-10-08T04:57:01.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16635" PostTypeId="2" ParentId="13255" CreationDate="2015-10-08T05:26:29.360" Score="3" Body="&lt;p&gt;Since you only need to know the 4 largest values in the array you don't need to sort the array, you just need to iterate through it and find the four largest values. This can be done in &lt;code&gt;O(n*k)&lt;/code&gt; which is faster than any sorting algorithm you could use. However there is an issue of space since you would use an array to hold the previous largest numbers. Fortunately we can get around this by swapping the current largest value to the end of the array and ignoring it. So you can find the &lt;code&gt;k&lt;/code&gt; largest values in an size &lt;code&gt;n&lt;/code&gt; array in &lt;code&gt;O(n*k)&lt;/code&gt; time complexity with &lt;code&gt;O(1)&lt;/code&gt; space complexity. For fixed values if &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; the time complexity is &lt;code&gt;O(1)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;    void swap (int&amp;amp; a, int&amp;amp; b);&#xA;&#xA;    int main () {&#xA;&#xA;        int sum = 0;&#xA;        int max = -1; // I'm assuming your array will have non-negative numbers&#xA;        int maxIndex;&#xA;        int nums = 4; // we want the top &quot;num&quot; values in the array&#xA;&#xA;        const int arrSize = 9;&#xA;        int arr[arrSize] = {36, 33, 19, 42, 47, 26, 50, 37, 38}; // random numbers&#xA;&#xA;        for (int i = 0; i &amp;lt; num; ++i){ &#xA;            // arrSize - i lets us ignore the previous max values&#xA;            for (int j = 0; j &amp;lt; arrSize - i; j++){&#xA;                if(arr[j] &amp;gt; max){&#xA;                    max = arr[j]; // store current max&#xA;                    maxIndex = j; // store the current max's index&#xA;                }&#xA;            }&#xA;            sum += max; // running total&#xA;            max = -1;   // reset max&#xA;            swap(arr[maxIndex], arr[arrSize-1-i]); // move current max to the end&#xA;        }&#xA;&#xA;        float top4Avg = sum / 4.0;&#xA;        printf(&quot;\nTop 4 average: %f\n&quot;, top4Avg);&#xA;&#xA;    }&#xA;&#xA;    // swaps a and b without a temp variable&#xA;    void swap (int&amp;amp; a, int&amp;amp; b){&#xA;        a = a ^ b; // ^ is the bitwise xor&#xA;        b = a ^ b;&#xA;        a = a ^ b;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First iteration: &lt;code&gt;{36, 33, 19, 42, 47, 26, 38, 37, 50}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second iteration: &lt;code&gt;{36, 33, 19, 42, 37, 26, 38, 47, 50}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third iteration: &lt;code&gt;{36, 33, 19, 38, 37, 26, 42, 47, 50}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fourth iteration: &lt;code&gt;{36, 33, 19, 26, 37, 38, 42, 47, 50}&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also this was a really fun question I'd upvote but my rep isn't high enough.&lt;/p&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2017-05-12T08:26:10.853" LastActivityDate="2017-05-12T08:26:10.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16636" PostTypeId="2" ParentId="16625" CreationDate="2015-10-08T08:33:24.447" Score="1" Body="&lt;p&gt;The SIM900A won't work in the UK, it's dual band.&lt;br&gt;&lt;br&gt;&#xA;The SIM800L is cheap as there is no power regulation on board. IIRC it requires 3.4V - 4.5V, min 2 amp supply. Check the data sheet to be sure.&lt;/p&gt;&#xA;" OwnerUserId="781" LastActivityDate="2015-10-08T08:33:24.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16638" PostTypeId="1" CreationDate="2015-10-08T09:59:54.170" Score="3" ViewCount="2360" Body="&lt;p&gt;Is it possible to use digital pin 6 (PD6_PCINT22/AIN0) to read an analog voltage with analogRead()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the ATMega datasheet, this should be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If yes how is it done ? (pin configuration)&lt;/p&gt;&#xA;" OwnerUserId="13880" LastEditorUserId="11529" LastEditDate="2016-02-25T08:18:53.207" LastActivityDate="2016-02-25T08:18:53.207" Title="Reading analog signal from digital pin #6" Tags="|analogread|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16639" PostTypeId="2" ParentId="16638" CreationDate="2015-10-08T10:16:00.100" Score="3" Body="&lt;p&gt;That is not possible. AIN0 is an input to the analog &lt;em&gt;comparator&lt;/em&gt;, not the analog-to-digital converter. Only ADC0 through ADC8 (connected to the internal temperature sensor), the 1.1V reference, and ground can be connected to the ADC.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-08T10:16:00.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16644" PostTypeId="2" ParentId="16638" CreationDate="2015-10-08T14:32:27.743" Score="1" Body="&lt;p&gt;Maybe. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega) and the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in the image below the pin PD6 is not an analog input. To be an analog pin it should be write ADCx, like the PC0..5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GNTeU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GNTeU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if you are not using and Arduino Uno you can't use PD6 as analog input but you can use PC0..5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read an analog value using &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow noreferrer&quot;&gt;analogRead()&lt;/a&gt; method you can do like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int analogPin = 3;                           &#xA;int val = 0;           // variable to store the value read&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);          //  setup serial&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  val = analogRead(analogPin);    // read the input pin&#xA;&#xA;  Serial.println(val);             // debug value&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3" LastActivityDate="2015-10-08T14:32:27.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16646" PostTypeId="1" AcceptedAnswerId="16647" CreationDate="2015-10-08T15:02:09.557" Score="1" ViewCount="68" Body="&lt;p&gt;Using the Arduino tutorial &quot;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Button&quot; rel=&quot;nofollow noreferrer&quot;&gt;Button&lt;/a&gt;&quot;, I have noticed that if I totally disconnect Pin2 from the circuit, the LED comes on dimly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to understand HOW this happens.  Is it simply due to being a floating ground?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/St0Tc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/St0Tc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13886" LastActivityDate="2015-10-08T15:25:01.060" Title="How is LED powered when PIN 2 is disconnected?" Tags="|arduino-uno|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16647" PostTypeId="2" ParentId="16646" CreationDate="2015-10-08T15:25:01.060" Score="1" Body="&lt;p&gt;The &lt;code&gt;pinMode(buttonPin, INPUT);&lt;/code&gt; line tells the board to set the &lt;code&gt;buttonPin&lt;/code&gt; in high impedance mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you disconnect the wire the state of that pin becomes unknown; usually it oscillates.&#xA;Since it is oscillating, the LED turns on and off randomly: you see it &quot;dimly light&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual solution is to use a pull-up or pull-down. I suggest you to wire your buttons towards the ground, declare the pins as &lt;code&gt;pinMode(buttonPin, INPUT_PULLUP);&lt;/code&gt; and invert the logic (i.e. &lt;code&gt;buttonState = !digitalRead(buttonPin);&lt;/code&gt;). This way it will never oscillate again.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-10-08T15:25:01.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16648" PostTypeId="1" AcceptedAnswerId="16654" CreationDate="2015-10-08T17:11:02.023" Score="1" ViewCount="11676" Body="&lt;p&gt;I am working on building a wordclock using one of the several design ideas that you can find all over the Internet. Something like a mix of this one: &lt;a href=&quot;http://www.instructables.com/id/Sleek-word-clock/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Sleek-word-clock/&lt;/a&gt; and this one: &lt;a href=&quot;http://www.instructables.com/id/Personalised-Word-Clock/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Personalised-Word-Clock/&lt;/a&gt; A lot of the guides suggested building your own Arduino to save money, but I found these Arduino Nano clones for $7/apiece: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00SGMEH7G&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/gp/product/B00SGMEH7G&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done a few simple projects before, but nothing with the same kind of power demand. How can I figure out the power requirements? My plan is to use approximately 64 3mm LEDs via shift register, or possibly the equivalent segments of an LED strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nano clone does not have a barrel connector for external power adaptor. Should I directly solder on the power cables from an external adaptor? Use a screw terminal or similar? Is the USB adaptor a good enough source of power for 64 LEDs? Or do I have to do something else to supply external power to that many LEDs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any advice! I am experienced in programming but not in electrical engineering so many of the concepts are something I don't have a good handle on yet.&lt;/p&gt;&#xA;" OwnerUserId="4937" LastActivityDate="2015-10-08T20:12:28.850" Title="Using an Arduino Nano, how many LEDs can I safely power?" Tags="|power|led|arduino-nano|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16649" PostTypeId="1" CreationDate="2015-10-08T19:07:05.213" Score="2" ViewCount="228" Body="&lt;p&gt;I was using displays with serial communication (SPI), but sending bytes to draw a tile-based picture was way too slow so I'd like find one with a parallel port, enough fast bandwidth to receive fast pictures at a speed at least 10FPS (but I'd like 50FPS or 60FPS) from Arduino Mega (ATMEGA2560) and which has a library compatible with the Arduino's C++ compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I've seen somewhere how to connect a display onto the XMEM pins of the Mega and send bytes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*(0x12)=0x34 // Sends 0x1234&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I couldn't find where to buy that specific one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was searching on eBay, but only found displays of unsupported drivers or drivers with broken links that I couldn't download, and displays that are ridiculously large like a shovel!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resolution it needs to have is minimum 128x64, aspect ratio must be X:Y where X is greater than Y (unless it's possible to send bytes sideways while the screen is physically placed in a different orientation on the PCB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It must be a touch display sensitive on anything (like Nintendo DSi when drawing Flipnotes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Monochrome&lt;/li&gt;&#xA;&lt;li&gt;Color display with MS Paint colors if it has equal to or less than 256 colors&lt;/li&gt;&#xA;&lt;li&gt;Color display with 16-bit color input mode if it has a lot of colors&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It should be no bigger than 2.5&quot; because this is for a little handheld console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone knows where to buy it, please comment.&#xA;&lt;br&gt;Thank you for your time.&lt;/p&gt;&#xA;" OwnerUserId="13891" LastActivityDate="2015-10-08T23:28:01.673" Title="Looking for a game application oriented display for Arduino Mega" Tags="|arduino-mega|display|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16650" PostTypeId="1" AcceptedAnswerId="16653" CreationDate="2015-10-08T19:37:35.773" Score="2" ViewCount="1389" Body="&lt;p&gt;For my project I need a GPS module, it should be cheap and I should be able to use it with arduino, after some search I got a product on ebay, I'm a 16 year old school boy and I didn't know that it will work with Arduino or not. Help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link--&#xA;&lt;a href=&quot;http://www.ebay.co.uk/itm/DIYMALL-VK16E-Module-Gmouse-GPS-Module-SIRF3-Chip-with-Ceramic-Antenna-TTL-Level-/181594912168?hash=item2a47e675a8&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/DIYMALL-VK16E-Module-Gmouse-GPS-Module-SIRF3-Chip-with-Ceramic-Antenna-TTL-Level-/181594912168?hash=item2a47e675a8&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4437" LastActivityDate="2015-10-08T20:03:37.280" Title="Can I use this cheap GPS module with arduino" Tags="|arduino-uno|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16651" PostTypeId="2" ParentId="16649" CreationDate="2015-10-08T19:56:38.950" Score="1" Body="&lt;p&gt;I'd suggest, if you haven't done it already, to take a look at what is supported by &lt;a href=&quot;http://ugfx.org/&quot; rel=&quot;nofollow&quot;&gt;uGFX&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find any HW meeting your needs, you can at least be sure that it is supported.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-08T19:56:38.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16652" PostTypeId="2" ParentId="16650" CreationDate="2015-10-08T20:00:41.680" Score="1" Body="&lt;p&gt;Yes.  You can tell that from two entries in the specification:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;TTL Level 9600 Baud Rate&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That tells you it uses standard TTL (5V) serial to communicate, so on an Uno that would be pins 0 and 1 and the Serial object, or any pins of your choice and the SoftwareSerial library.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Output SiRF binary system OR &lt;strong&gt;nmea0183 V3.0&lt;/strong&gt;(GGA, GSA, GSV, RMC, VTG)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It outputs NMEA encoded data (bold added by me) which is what most of the Arduino GPS libraries are written to use.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-08T20:00:41.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16653" PostTypeId="2" ParentId="16650" CreationDate="2015-10-08T20:03:37.280" Score="1" Body="&lt;p&gt;After some research it seems you can use that gps module with an Arduino. Here's a link to the data sheet for it: &lt;a href=&quot;http://www.hanssummers.com/images/stories/ultimategps/vk16e.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.hanssummers.com/images/stories/ultimategps/vk16e.pdf&lt;/a&gt;. Also it seems like you have to use the TinyGPSPlus library to get it to work. Here's a link to learn more about it: &lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;http://arduiniana.org/libraries/tinygpsplus/&lt;/a&gt;. You may have to use the protocols in this data sheet: &lt;a href=&quot;https://www.sparkfun.com/datasheets/GPS/NMEA%20Reference%20Manual-Rev2.1-Dec07.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/GPS/NMEA%20Reference%20Manual-Rev2.1-Dec07.pdf&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this information was taken from this thread: &lt;a href=&quot;https://www.linkedin.com/grp/post/4573843-5806249757395406852&quot; rel=&quot;nofollow&quot;&gt;https://www.linkedin.com/grp/post/4573843-5806249757395406852&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13840" LastActivityDate="2015-10-08T20:03:37.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16654" PostTypeId="2" ParentId="16648" CreationDate="2015-10-08T20:12:28.850" Score="4" Body="&lt;p&gt;If you are running the LEDs from shift registers then the power rating of the Nano is irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are wanting to use the Nano as the power source (not recommended) then you would need to know both your expected current and what the regulator on the Nano would be able to supply.  My immediate guess is &quot;not enough&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;64 LEDs at full brightness would be expected to use a maximum of say 20mA each, so 1.28A just for the LEDs.  That's a huge amount, and way more than any linear regulator can be expected to supply without melting everything around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can reduce your current requirements by not having the LEDs as bright.  Half the current does not equate to half the apparent brightness. In fact at half the current you probably won't notice much difference at all.  At a tenth of the current you will see them a bit dimmer, but not as much as you would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can come up with a compromise between the brightness you desire and the current consumed by each LED.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you end up deciding on (as Gerben has suggested) a current of 5mA per LED.  When all LEDs are on that would be (5 × 64) 320mA.  That's reasonable for a linear regulator, but still will generate more heat than is really advisable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you should, for this project (assuming you aren't going to be using multiplexing, which is a whole other ballgame), investigate using a switching (aka &quot;buck&quot;) regulator.  You can pick these up on eBay for just a couple of dollars and can quite happily supply amps as opposed to milliamps and will allow you to run far more LEDs without going into thermonuclear meltdown.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important consideration to think about is how much current an individual shift register can provide - both through its output pins and in total for the whole chip.  There are special constant current LED driving shift registers that remove the need for individual resistors on each LED and give much better control over the LEDs than traditional logic output shift registers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-08T20:12:28.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16655" PostTypeId="2" ParentId="16649" CreationDate="2015-10-08T23:28:01.673" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I was using displays with serial communication (SPI)  ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Personally I regards serial and SPI as different things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=10894&quot; rel=&quot;nofollow&quot;&gt;Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;SPI is somewhat faster than serial.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... sending bytes to draw a tile-based picture was way too slow ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How slow was it? What was your target speed?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The resolution it needs to have is minimum 128x64 ... It should be no bigger than 2.5&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Something like &lt;a href=&quot;http://www.adafruit.com/products/1480&quot; rel=&quot;nofollow&quot;&gt;2.2&quot; 18-bit color TFT LCD display&lt;/a&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fast bandwidth to receive fast pictures at a speed at least 10FPS ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12623&quot; rel=&quot;nofollow&quot;&gt;Toorum's Quest II - Retro video game and console&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That guy made a sideways scrolling game outputting to video with a display resolution of 104x80 with 256 colors. He also had sound generation and managed input from a NES controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.youtube.com/watch?v=sLvgW_zb6bQ&quot; rel=&quot;nofollow&quot;&gt;video of it in operation on YouTube&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-08T23:28:01.673" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16656" PostTypeId="1" CreationDate="2015-10-09T00:58:13.233" Score="3" ViewCount="1912" Body="&lt;p&gt;I want to connect an RFID reader to an Arduino board. The RFID reader has several wires attached, and the manual mentions them as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Red: VCC +12V&lt;/li&gt;&#xA;&lt;li&gt;Black: GND&lt;/li&gt;&#xA;&lt;li&gt;Green: D 0/RX/4R+&lt;/li&gt;&#xA;&lt;li&gt;White: D 1/TX/4R−&lt;/li&gt;&#xA;&lt;li&gt;Blue: LED/CS&lt;/li&gt;&#xA;&lt;li&gt;Yellow: Beep&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is also another black wire attached, but the manual does not mention it.&#xA;This is an image of it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OHCWM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OHCWM.jpg&quot; alt=&quot;Image of RFID reader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the red wire connected to the 5V pin and the black wire to the GND pin on Arduino board. Then I have the white wire connected to the RX pin on the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to Serial-read the RX port using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;        int b = Serial.read();&#xA;        Serial.print(b);&#xA;        Serial.print(&quot; &quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to read a keyfob, only this is printed – nineteen times &lt;code&gt;248&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To me it looks like there's something wrong with the connection somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I properly read this RFID reader? If above assumption is not correct, is there something I should know?&lt;/p&gt;&#xA;" OwnerUserId="6273" LastEditorUserId="6273" LastEditDate="2015-10-09T09:48:47.557" LastActivityDate="2017-08-24T17:41:58.663" Title="How to read an RFID reader?" Tags="|rfid|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16659" PostTypeId="1" AcceptedAnswerId="16661" CreationDate="2015-10-09T06:27:50.767" Score="1" ViewCount="5156" Body="&lt;p&gt;I am trying to make a workaround for the delay function. I am trying to use the function in the Analog Write Mega example, by replacing delay with the function i made. However, whenever i use my function instead of delay i get incorrect led behaviour. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link to the example: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/AnalogWriteMega&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/AnalogWriteMega&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int currmillis = 0; //used in my function to find the current millis()&#xA;int prevmillis = 0; //used to hold previous value of currmillis&#xA;int boolval = 0;    //used to control whether to write the brightness value to the led or not&#xA;int time = 0;     //used in the delay function, difference between currmillis and prevmillis&#xA;&#xA;int timeloop(int); //the function i wrote, it is at the bottom of the code&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  for ( int i = 2; i &amp;lt;= 13; i++)&#xA;  {&#xA;        pinMode(i,OUTPUT); &#xA;  }&#xA;}//Setting the pins to output and allowing serial communication.&#xA;&#xA;&#xA;void loop (){&#xA;&#xA;  for ( int thisPin = 2; thisPin &amp;lt;= 13; thisPin++ ) //to move from one led to the next&#xA;  { &#xA;&#xA;    for ( int brightness = 0 ; brightness &amp;lt;= 255; brightness++) //change the brightness of the led&#xA;    {&#xA;&#xA;      boolval = timeloop(2); //the delay function returns the time passed, if the time is greater than or equal to 2, the analogWrite will write the brightness to the led&#xA;&#xA;      if (boolval &amp;gt;= 2){ &#xA;            analogWrite(thisPin, brightness);   &#xA;      }// if 2 ms pass, the led brightness will increase from 0 to 255 and then decrease in the following loop from 255 to 0, Once it reaches 0, the main loop moves to the next led.&#xA;&#xA;    }&#xA;&#xA;    for ( int brightness = 255 ; brightness &amp;gt;= 0 ; brightness--)&#xA;    {&#xA;      boolval = timeloop(2);&#xA;&#xA;      if (boolval &amp;gt;= 2){ &#xA;            analogWrite(thisPin, brightness);  &#xA;      }&#xA;    }&#xA;          timeloop(100); // a delay of 100 ms using the function&#xA;  }&#xA;}&#xA;&#xA;int timeloop (int interval){ // the delay function&#xA;&#xA;  do{&#xA;    prevmillis = currmillis; //hold previous value&#xA;    currmillis = millis(); //find current value &#xA;    time = (currmillis-prevmillis); &#xA;  }while(time &amp;lt; interval); &#xA;&#xA;  return time;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="13899" LastEditorUserId="10794" LastEditDate="2015-10-09T06:57:41.793" LastActivityDate="2015-10-09T12:45:52.180" Title="Alternative to delay function" Tags="|arduino-uno|c++|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16660" PostTypeId="2" ParentId="16659" CreationDate="2015-10-09T07:00:10.523" Score="0" Body="&lt;p&gt;What's the point? Why rewrite &lt;code&gt;delay()&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int timeloop (int interval){ // the delay function&#xA;&#xA;  do{&#xA;    prevmillis = currmillis; //hold previous value&#xA;    currmillis = millis(); //find current value &#xA;    time = (currmillis-prevmillis); &#xA;  }while(time &amp;lt; interval); &#xA;&#xA;  return time;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In every iteration of that loop you are updating &lt;code&gt;prevmillis&lt;/code&gt;. So you will never reach the wanted delay interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from the fact that you may as well use the inbuilt &lt;code&gt;delay&lt;/code&gt; rather than writing your own, and getting it wrong.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to make a workaround for the delay function&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://xyproblem.info/&quot; rel=&quot;nofollow&quot;&gt;The XY Problem&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-09T07:00:10.523" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16661" PostTypeId="2" ParentId="16659" CreationDate="2015-10-09T07:37:17.590" Score="1" Body="&lt;pre&gt;&lt;code&gt;// You don't need to return anything since it's just a delay&#xA;// also I changed the parameters to long ints because millis()&#xA;// returns a long int&#xA;void timeLoop (long int startMillis, long int interval){ // the delay function&#xA;&#xA;    // this loops until 2 milliseconds has passed since the function began&#xA;    while(millis() - startMillis &amp;lt; interval){} &#xA;}&#xA;&#xA;// Your call for a 2 millisecond delay would be&#xA;timeLoop(millis(), 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also the leds may be acting weird because this schematic is wrong. As you can see one of the led's anode isn't connected to ground. It's circled in red.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/iH0su.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iH0su.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want it to return something you could use this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long int timeLoop (long int startMillis, long int interval){ // the delay function&#xA;&#xA;    while(millis() - startMillis &amp;lt; interval){} &#xA;    return millis() - startMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it really isn't needed.&lt;/p&gt;&#xA;" OwnerUserId="13840" LastActivityDate="2015-10-09T07:37:17.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16662" PostTypeId="1" AcceptedAnswerId="16685" CreationDate="2015-10-09T11:22:26.837" Score="1" ViewCount="20989" Body="&lt;p&gt;I am using following code for my arduino project in which i have to control a dc motor using arduino uno via text messages.&#xA;my question is that i have used multiple number of 'If' statements and only one else statement at the last, i compiled this code and gives no error, is it ok to use multiple If statements one after another without using else after each if?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal595.h&amp;gt;&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;GSM gsmAccess;&#xA;GSM_SMS sms;&#xA;char sendernumber[20];  &#xA;int Enable_m=11;&#xA;int Control_2=12;&#xA;int Control_7=10;&#xA;LiquidCrystal595 lcd(7,8,9);&#xA;void setup() &#xA;{&#xA;   Serial.begin(9600);&#xA;   pinMode(Enable_m,OUTPUT);&#xA;   pinMode(Control_2,OUTPUT);&#xA;   pinMode(Control_7,OUTPUT);&#xA;&#xA;   digitalWrite(Enable_m,LOW);&#xA;   digitalWrite(Control_2,LOW);&#xA;   digitalWrite(Control_7,LOW);&#xA;&#xA;   lcd.begin(16,2);&#xA;   lcd.clear();&#xA;   lcd.setCursor(0,0);&#xA;   lcd.print(&quot;Hello&quot;);&#xA;   lcd.setCursor(0,1);&#xA;   lcd.print(&quot;Everyone&quot;);&#xA;   delay(2000);&#xA;&#xA;   while (!Serial) &#xA;      Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;   boolean notConnected = true;&#xA;   while(notConnected)&#xA;   {&#xA;      if(gsmAccess.begin(&quot;0000&quot;)==GSM_READY)&#xA;         notConnected = false;&#xA;      else&#xA;      {&#xA;         Serial.println(&quot;Not connected&quot;);&#xA;         delay(1000);&#xA;      }&#xA;   }  &#xA;   Serial.println(&quot;GSM initialized&quot;);&#xA;   Serial.println(&quot;Waiting for messages&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   // put your main code here, to run repeatedly:&#xA;   char c;&#xA;   int val=0;&#xA;   val=digitalRead(Enable_m);&#xA;   if (val==LOW){&#xA;      digitalWrite(Enable_m,HIGH);&#xA;   }&#xA;   if (sms.available())&#xA;   {&#xA;      Serial.println(&quot;Message received from:&quot;);&#xA;      sms.remoteNumber(sendernumber, 20);&#xA;      Serial.println(sendernumber);&#xA;&#xA;      if(sms.peek()=='#')&#xA;      {&#xA;         Serial.println(&quot;Discarded SMS&quot;);&#xA;         sms.flush();&#xA;      }&#xA;      while(c=sms.read())&#xA;         if(c=='motoroff'){&#xA;            analogWrite(Enable_m, 0);&#xA;            digitalWrite(Control_2,LOW);&#xA;            digitalWrite(Control_7,LOW);&#xA;&#xA;         }&#xA;      if(c=='motoronclockwise'){&#xA;         analogWrite(Enable_m, 255);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      if(c=='motoronanticlockwise'){&#xA;         analogWrite(Enable_m, 255);&#xA;         digitalWrite(Control_2,HIGH);&#xA;         digitalWrite(Control_7,LOW);&#xA;      }&#xA;      if(c=='speedhalf'){&#xA;         analogWrite(Enable_m, 128);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      if(c=='speedquarter'){&#xA;         analogWrite(Enable_m, 65);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      if(c=='speed75'){&#xA;         analogWrite(Enable_m, 192);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      else{&#xA;         digitalWrite(Enable_m,HIGH);&#xA;         Serial.print(c);&#xA;      }&#xA;      Serial.println(&quot;\nEND OF MESSAGE&quot;);&#xA;      sms.flush();&#xA;      Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;   }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13332" LastEditorUserId="313" LastEditDate="2015-10-09T12:11:44.440" LastActivityDate="2018-06-16T05:05:10.600" Title="Multiple If statements" Tags="|arduino-uno|gsm|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16663" PostTypeId="1" AcceptedAnswerId="16666" CreationDate="2015-10-09T11:32:43.673" Score="3" ViewCount="2296" Body="&lt;p&gt;I want to log GPS positions to an external EEPROM over I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;Latitude: 51.0000&#xA;Longitude: 4.0000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the decimal place then each of these addresses would consume up to two bytes each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: &lt;strong&gt;&lt;em&gt;How can I log each new set of GPS data to a new memory address on the EEPROM each time?&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bearing in mind that the Arduino might be switched off between entries.&lt;/p&gt;&#xA;" OwnerUserId="276" LastActivityDate="2023-02-06T12:10:54.020" Title="How do you write to a free location on an external EEPROM?" Tags="|eeprom|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16664" PostTypeId="2" ParentId="16662" CreationDate="2015-10-09T11:52:16.793" Score="1" Body="&lt;p&gt;Two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;else&lt;/code&gt; will only be subject to the last &lt;code&gt;if&lt;/code&gt; being false, the rest of the &lt;code&gt;if&lt;/code&gt; statements are completely separate and can affect the &lt;code&gt;else&lt;/code&gt; in no way whatsoever.  To chain them you need &lt;code&gt;if (...) { blah blah } else if (...) { blah blah }&lt;/code&gt; etc.&lt;/li&gt;&#xA;&lt;li&gt;You cannot compare characters and strings like that (and in fact they're not even strings, they're lots of characters squeezed into a single character through the use of the wrong kind of quotes).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So basically no, your whole program there is completely wrong and won't do what you think it will and you need to completely re-thing how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some tips:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use &lt;code&gt;strcmp()&lt;/code&gt; to compare strings.&lt;/li&gt;&#xA;&lt;li&gt;If reading strings from serial store them in character &lt;em&gt;arrays&lt;/em&gt; not a single character.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You might find this useful:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-09T11:52:16.793" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16665" PostTypeId="2" ParentId="16663" CreationDate="2015-10-09T12:06:49.673" Score="1" Body="&lt;p&gt;You could assign the first byte(s) of the EEPROM as the address of the next free location in which to store GPS coordinates, and update it before the Arduino sleeps. At wake-up, retrieve the address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could keep the pointer in RAM, too; RAM keeps its contents across a sleep. But using EEPROM would even let you power off the Arduino, and still pick up where you left off after the power-up reset. (Of course, other parts of your program would have to be restart-tolerant as well; I'm just looking at the coordinate storage here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, two bytes isn't sufficient to store a GPS coordinate to four decimals unless their range is limited such that you can scale them into [0 - 65535].&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-09T12:06:49.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16666" PostTypeId="2" ParentId="16663" CreationDate="2015-10-09T12:06:50.160" Score="6" Body="&lt;p&gt;The trick you are looking to implement here is the ability to look through the EEPROM and say &quot;This is the last place I wrote to - I will write to the next place now.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's two ways of doing it, the easy way and the right way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easy way is to maintain a single address in the EEPROM that says where you wrote to last.  If you are trying to implement some form of wear levelling to extend the life of your EEPROM then this would basically negate it, since that one cell in the EEPROM will wear out before the rest of it and become useless.  So it's really not a good idea although it may sound like it at first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;right&lt;/em&gt; way to do it is to store &lt;em&gt;more&lt;/em&gt; information in the EEPROM every time.  Not only do you need to store the data, but also some kind of identifying &lt;em&gt;sequence&lt;/em&gt; number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you have 4 bytes of data to write each time.  Add a fifth byte to it.  That fifth byte increases by one each time you write.  Before you write you scan through the EEPROM looking at every fifth byte looking for the &quot;end&quot; of the sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you may end up with (&lt;code&gt;xx&lt;/code&gt; is your data bytes) in hexadecimal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00: 00 xx xx xx xx&#xA;05: 01 xx xx xx xx&#xA;0A: 02 xx xx xx xx&#xA;0F: 03 xx xx xx xx&#xA;14: FF FF FF FF FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You see that at address 0x14 the nice sequence of numbers breaks.  Therefore your next write must be at that point.  Now, if you then loop through the EEPROM many times after a while, you may end up with something that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00: FE xx xx xx xx&#xA;05: FF xx xx xx xx&#xA;0A: 00 xx xx xx xx&#xA;0F: 01 xx xx xx xx&#xA;14: 58 xx xx xx xx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see a clear sequence here of &lt;code&gt;0xFE 0xFF 0x01&lt;/code&gt; where they increase by 1 each time (0xFF + 1 = 0x00) so you can see that you have looped through your sequence numbers. You don't care though because it's still just plus one.  Only when you get the jump from 0x01 to 0x58 does the sequence break, so you know where the last write would have been.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are only a couple of small gotchas here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can only use 5*n cells in the EEPROM since the last 5-byte packet of data may not fit within the last bit of EEPROM (say it's a 1024 byte EEPROM you would have room for 204.8 packets - so 204 packets and 4 bytes left over).&lt;/li&gt;&#xA;&lt;li&gt;You must ensure that you don't end up with exactly 256 packets fitting in the EEPROM before you loop the address - otherwise the sequence won't &quot;break&quot; so you will never know where the last write was after the first loop.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-09T12:06:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16668" PostTypeId="2" ParentId="16662" CreationDate="2015-10-09T12:19:08.473" Score="0" Body="&lt;p&gt;If you intend each &lt;code&gt;if&lt;/code&gt; statement to be executed, regardless of the whether the prior one(s) did, then yes, they do not require &lt;code&gt;else&lt;/code&gt; clauses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you mean to try each condition until you find one that is true, and execute that one and only that one, then the second and subsequent &lt;code&gt;if&lt;/code&gt;s need to be &lt;code&gt;else if&lt;/code&gt;s. The final one may be just an &lt;code&gt;else&lt;/code&gt;, if you want a catch-all clause; or an &lt;code&gt;else if&lt;/code&gt; if it is possible that none of the clauses might need to be run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: To execute at most one clause, you need to use &lt;code&gt;if&lt;/code&gt;, some &lt;code&gt;else if&lt;/code&gt;s, and maybe a final &lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're trying to match strings, you can use an array of strings or use literal strings as you've tried to do. Strings have to be enclosed in double-quotes (&lt;code&gt;&quot;&lt;/code&gt;) however, not the single quotes you've used. And the variable &lt;code&gt;char c;&lt;/code&gt; you tried to use to hold the SMS message is really only one character. You'll need to make it an array of characters such as &lt;code&gt;char c[140+1];&lt;/code&gt;,  the size of the longest SMS message + one more for a  zero-character string-terminator. C doesn't directly compare strings as simple variables so &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;!=&lt;/code&gt; won't work here. You'll need to compare them with strcmp().&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-10-09T19:03:00.117" LastActivityDate="2015-10-09T19:03:00.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16669" PostTypeId="2" ParentId="9180" CreationDate="2015-10-09T12:35:00.447" Score="1" Body="&lt;p&gt;A build-your-own-duino isn't hard to do and it is quite inexpensive. It will make your life (or the part it you're about to spend creating custom hardware) much, much easier! I have built &lt;a href=&quot;http://jpralves.net/cseduino/&quot; rel=&quot;nofollow&quot;&gt;Joao Alves' CSE-duino&lt;/a&gt; for example and it has everything an UNO has except for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;on-board USB (use an FTDI cable that has USB &amp;lt;-&gt; Serial in the cable head)&lt;/li&gt;&#xA;&lt;li&gt;a 3.3v power supply; and&lt;/li&gt;&#xA;&lt;li&gt;an ISP (high-voltage programming) connector;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;, none of which you should need to drive a servo.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-09T12:35:00.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16670" PostTypeId="2" ParentId="16659" CreationDate="2015-10-09T12:45:52.180" Score="0" Body="&lt;p&gt;Depending on what you want the alternative function to do, there are a megaton of timer libraries at the &lt;a href=&quot;http://playground.arduino.cc/Main/LibraryList#Timing&quot; rel=&quot;nofollow&quot;&gt;Arduino playground&lt;/a&gt;. One of them is likely to provide what you need.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-09T12:45:52.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16671" PostTypeId="1" CreationDate="2015-10-08T22:00:59.260" Score="1" ViewCount="6037" Body="&lt;p&gt;I have an Arduino Mega AT2560 and need to have real DAC. I purchased the &lt;a href=&quot;https://www.sparkfun.com/products/12918&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun 12 bit DAC&lt;/a&gt;, however I don't think it is working properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Arduino wire library to communicate with the DAC. When I write 0, I am expecting to see 0v from the DAC's OUT pin. However, I see some seemingly random constant voltage. In reverse, when I write 4095 to the DAC I see the same voltage as when I write 0. I expected to see 5v.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can someone verify that I hooked it up correctly?&lt;/li&gt;&#xA;&lt;li&gt;Can someone verify the code I am using?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YXl7l.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YXl7l.jpg&quot; alt=&quot;12 Bit DAC with Arduino ATMega 2560&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define MCP4725_ADDR 0x60 // [0000 0110]&#xA;/*&#xA;* 12 Bit DAC MCP4725 gives a range of 4096 possible values.&#xA;* &#xA;*/&#xA;void setup() {&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Wire.beginTransmission(MCP4725_ADDR);&#xA;  Wire.write(64);            // cmd to update the DAC [0100 0000]&#xA;  Wire.write(4095 &amp;gt;&amp;gt; 4);        // the 8 most significant bits...&#xA;  Wire.write((4095 &amp;amp; 15) &amp;lt;&amp;lt; 4); // the 4 least significant bits...&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Michael Vo" LastEditorUserId="27346" LastEditDate="2018-11-30T22:42:11.053" LastActivityDate="2018-11-30T22:42:11.053" Title="Arduino with 12 bit DAC (MCP4725) Not Working" Tags="|atmega2560|digital-analog-conversion|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16672" PostTypeId="1" AcceptedAnswerId="16673" CreationDate="2015-10-09T14:27:18.870" Score="0" ViewCount="42802" Body="&lt;p&gt;I'm gettng an error &quot;error: expected primary-expression before ',' token&quot; in the following line of code - I have initialized an array with 220 ints. What am I doing wrong here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const PROGMEM int P7Val[] = {1635,1635,1635,1635,1635,1630,1630,1630,1630,1630,1625,1625,1625,1625,1620,1620,1620,1620,1615,1615,1615,1610,1610,1610,1605,1605,1605,1600,1600,1600,1595,1595,1595,1590,1590,1590,1585,1585,1580,1580,1580,1575,1575,1570,1570,1570,1565,1565,1560,1560,1555,1555,1555,1550,1550,1545,1545,1540,1540,1535,1535,1535,1530,1530,1525,1525,1520,1520,1515,1515,1510,1510,1505,1505,1500,1500,1495,1495,1490,1490,1490,1485,1485,1480,1480,1475,1475,1470,1470,1465,1465,1460,1460,1455,1455,1450,1450,1445,1445,1440,1440,1435,1435,1430,1430,1425,1425,1420,1420,1415,1415,1410,1410,1405,1405,1400,1400,1395,1395,1390,1390,1385,1385,1380,1380,1380,1375,1375,1370,1370,1365,1365,1360,1360,1355,1355,1350,1350,1345,1345,1345,1340,1340,1335,1335,1330,1330,1325,1325,1320,1320,1320,1315,1315,1310,1310,1305,1305,1305,1300,1300,1295,1295,1290,1290,1290,1285,1285,1280,1280,1275,1275,1275,1270,1270,1265,1265,1265,1260,12601635,1635,1635,1635,1635,1630,1630,1630,1630,1630,1625,1625,1625,1625,1620,1620,1620,1620,1615,1615,1615,1610,1610,1610,1605,1605,1605,1600,1600,1600,1595,1595,1595,1590,1590,1590,1585,1585,1580,1580,1580,1575,1575,1570,1570,1570,1565,1565,1560,1560,1555,1555,1555,1550,1550,1545,1545,1540,1540,1535,1535,1535,1530,1530,1525,1525,1520,1520,1515,1515,1510,1510,1505,1505,1500,1500,1495,1495,1490,1490,1490,1485,1485,1480,1480,1475,1475,1470,1470,1465,1465,1460,1460,1455,1455,1450,1450,1445,1445,1440,1440,1435,1435,1430,1430,1425,1425,1420,1420,1415,1415,1410,1410,1405,1405,1400,1400,1395,1395,1390,1390,1385,1385,1380,1380,1380,1375,1375,1370,1370,1365,1365,1360,1360,1355,1355,1350,1350,1345,1345,1345,1340,1340,1335,1335,1330,1330,1325,1325,1320,1320,1320,1315,1315,1310,1310,1305,1305,1305,1300,1300,1295,1295,1290,1290,1290,1285,1285,1280,1280,1275,1275,1275,1270,1270,1265,1265,1265,1260,1260,1255,1255,1255,1250,1250,1245,1245,1245,1240,1240,1235,1235,1235,1230,1230,1225,1225,1225,1220,1220,1215,1215,1215,1210,1210,1210,1205,1205,1200,1200,1200,1195,1195,1195,1190,1190,1185,1185,1185,1180,1180,,1255,1255,1255,1250,1250,1245,1245,1245,1240,1240,1235,1235,1235,1230,1230,1225,1225,1225,1220,1220,1215,1215,1215,1210,1210,1210,1205,1205,1200,1200,1200,1195,1195,1195,1190,1190,1185,1185,1185,1180,1180};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13907" LastEditorUserId="10794" LastEditDate="2015-10-10T02:24:12.773" LastActivityDate="2021-04-05T23:42:47.767" Title="error: expected primary-expression before ',' token" Tags="|c++|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16673" PostTypeId="2" ParentId="16672" CreationDate="2015-10-09T14:35:19.280" Score="3" Body="&lt;p&gt;Two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have a comma missing: &lt;code&gt;1260,12601635,1635,&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You have an extra comma: &lt;code&gt;1180,1180,,1255,1255&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you reformat your list into a nice regular table (say 10 entries per line) across multiple lines these things instantly become apparent.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-09T14:35:19.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16675" PostTypeId="1" CreationDate="2015-10-02T07:06:44.520" Score="0" ViewCount="540" Body="&lt;p&gt;First question: Since we can control the volts that we can throw via PWM pins on Arduino, can we use it to power the 3.3 V ESP8266?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second question: Can we also use these PWM pins as software serial pins i.e. they will be sending instructions at 3.3 V?&lt;/p&gt;&#xA;" OwnerUserId="51945" OwnerDisplayName="Talha" LastEditorUserId="26916" LastEditDate="2017-09-09T15:18:51.133" LastActivityDate="2017-09-09T15:18:51.133" Title="Can I run ESP8266 via Arduino using the PWM pins?" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16676" PostTypeId="2" ParentId="16675" CreationDate="2015-10-02T07:13:10.620" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;First question, Since we can control the volts that we can throw via PWM pins on Arduino, can we use it to power the 3.3v ESP8266?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. The ESP8266 draws &lt;em&gt;far&lt;/em&gt; too much current (in excess of 200mA) to use anything other than a proper supply.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Second question, Can we also use these PWM pins as Software serial pins i.e. they will be sending instructions at 3.3v?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;We'll drop the &quot;also&quot;, since we've decided that you're not doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use SoftwareSerial on any GPIO pins you like, provided the RX pin supports pin change interrupts.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-10-02T07:13:10.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16677" PostTypeId="2" ParentId="4453" CreationDate="2015-10-09T17:52:02.073" Score="1" Body="&lt;p&gt;This worked for me dude :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Bootloading-ATmega328-with-Arduino-Mega2560/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Bootloading-ATmega328-with-Arduino-Mega2560/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13911" LastEditorUserId="10794" LastEditDate="2015-10-10T02:22:11.680" LastActivityDate="2015-10-10T02:22:11.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16678" PostTypeId="1" CreationDate="2015-10-09T18:34:15.703" Score="0" ViewCount="661" Body="&lt;p&gt;I want to connect my Arduino UNO to a serial device that once powered displays signature numbers. I want to then display those numbers on an LCD display. I have my 16x2 LCD wired correctly and it works fine even when I use the SerialDisplay example code from the library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I use a USB to TTL serial cable to connect the RX/TX pins of the serial device to the TX/RX pins of the arduino?&lt;/li&gt;&#xA;&lt;li&gt;The two numbers are more than 16 characters. How can I cut the numbers down and then display the two numbers on two seperate lines of the LCD display?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Let me know if I should provide further details.&lt;/p&gt;&#xA;" OwnerUserId="13913" LastActivityDate="2015-10-09T20:26:54.523" Title="Arduino Interface with Serial device and LCD display" Tags="|arduino-uno|serial|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16679" PostTypeId="2" ParentId="16678" CreationDate="2015-10-09T18:48:19.857" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;If the device &lt;em&gt;is&lt;/em&gt; serial and you want to connect it to the Arduino &lt;em&gt;serial&lt;/em&gt; port, why would you use a usb-to-serial converter?&#xA;For a serial to serial connection, you have to connect TX, RX and GND.&#xA;This is the bare minimum for bidirectional communication, if your device is really read only, you can use just the TX and GND.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;it depends how you receive data from your &quot;serial device&quot; - btw, what is it? If the data comes as either ascii or individual characters, then it's easy: treat them as strings and display them separately. If the numbers arrive in binary format, you have to perform the conversion to string.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Questions like this should have attached at least a snippet, if not all, of code.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-09T20:26:54.523" LastActivityDate="2015-10-09T20:26:54.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16680" PostTypeId="1" AcceptedAnswerId="16686" CreationDate="2015-10-10T00:07:25.753" Score="2" ViewCount="139" Body="&lt;p&gt;I'm teaching this &lt;a href=&quot;https://www.dropbox.com/s/1hxxvueidqjoi09/flappyDuino.zip?dl=0&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; in my class. I understand most of the sketch and can see the class that makes the bird move, but I still don't quite understand how the code makes the sprite &quot;move.&quot; I can also see what generates the Pipes but I don't how the code creates them or randomizes them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code for both:    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bird&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Chym {&#xA;&#xA;private:&#xA;  int frameCount;&#xA;  int x; &#xA;  int y;&#xA;  int deltaIde;&#xA;  int delayFrame;&#xA;&#xA;  int jumpCount; &#xA;  int maxJumpCount;&#xA;  int moveSpeed;&#xA;&#xA;  bool _isDead;&#xA;public: &#xA;  void respawn() {&#xA;    x = 24; &#xA;    y = 20;&#xA;    deltaIde = -1;&#xA;    moveSpeed = 1;&#xA;    jumpCount = 0;&#xA;    _isDead = false;&#xA;  }&#xA;&#xA;  Chym() {&#xA;    frameCount = 0;&#xA;    delayFrame = 0;&#xA;    maxJumpCount = 20;&#xA;    respawn();&#xA;  }&#xA;&#xA;  void render() {&#xA;    if (frameCount &amp;lt; ANIM_FRAME / 2) {&#xA;      display.drawBitmap(x, y, flappybird_frame_1, 16, 12, 1);      &#xA;    } &#xA;    else {&#xA;      display.drawBitmap(x, y, flappybird_frame_2, 16, 12, 1);          &#xA;    }&#xA;  }&#xA;&#xA;  void update() {&#xA;    delayFrame++;&#xA;    if (delayFrame == DELAY_FRAME) {&#xA;      y += deltaIde * moveSpeed;&#xA;      delayFrame = 0;&#xA;    }&#xA;&#xA;    if (y &amp;gt; 35) {&#xA;      _isDead = true;&#xA;    }&#xA;&#xA;    frameCount++;&#xA;    if (frameCount &amp;gt;= ANIM_FRAME) frameCount = 0;&#xA;  }&#xA;&#xA;  bool isDead() {&#xA;    return _isDead;&#xA;  }&#xA;&#xA;  void die() {&#xA;    _isDead = true;&#xA;  }&#xA;&#xA;  void cancelJump() {&#xA;    jumpCount = 0;&#xA;    flyDown();&#xA;  }&#xA;&#xA;  void flyUp() {&#xA;    if (jumpCount &amp;lt; maxJumpCount) {&#xA;      deltaIde = -1; &#xA;      moveSpeed = 3;    &#xA;      jumpCount++;&#xA;    } &#xA;    else {&#xA;      flyDown();&#xA;    }&#xA;  }&#xA;&#xA;  void flyDown() {&#xA;    deltaIde = 1; &#xA;    moveSpeed = 1;&#xA;  }&#xA;&#xA;  int getX() {&#xA;    return x;&#xA;  }&#xA;&#xA;  int getY() {&#xA;    return y;&#xA;  }&#xA;&#xA;};    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pipe&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Bar {&#xA;&#xA;private:&#xA;  int x; &#xA;  int y;&#xA;  int delayFrame;&#xA;  int moveSpeed;&#xA;public:   &#xA;  Bar() {&#xA;    delayFrame = 0;&#xA;    x = 0; y = 24;&#xA;    moveSpeed = 2;&#xA;  }&#xA;&#xA;  void setPos(int sx, int sy) {&#xA;    x = sx; y = sy;&#xA;  }&#xA;&#xA;  void render() {&#xA;    display.drawBitmap(x, y - 30, bar_top, 8, 20, 1); &#xA;    display.drawBitmap(x, y + 10, bar_bottom, 8, 20, 1); &#xA;  }&#xA;&#xA;  void update() {&#xA;    delayFrame++;&#xA;    if (delayFrame == DELAY_FRAME) {&#xA;&#xA;      x -= moveSpeed;&#xA;      if (x &amp;lt; -10) x = 95;&#xA;&#xA;      delayFrame = 0;&#xA;    }&#xA;  }&#xA;&#xA;  int hitTest(int tx, int ty) {&#xA;    int hitX = ((tx &amp;gt;= x - 16) &amp;amp;&amp;amp; (tx &amp;lt;= x))?1:0;&#xA;    int hitY = ((ty &amp;lt;= (y - 10)) || (ty + 12 &amp;gt;= y + 10))?1:0;&#xA;    if (hitX != 0) {&#xA;      return hitY;&#xA;    }&#xA;    return 0;&#xA;  }&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=04cY78Y2d3g&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=04cY78Y2d3g&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-10-20T03:01:06.707" Title="How does this code move the bird sprite in this sketch?" Tags="|programming|c|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16683" PostTypeId="1" CreationDate="2015-10-09T23:00:47.153" Score="1" ViewCount="2302" Body="&lt;p&gt;I have an Arduino UNO. It has VoltageIN on a pin. Is there any difference between powering my UNO through VIN or powering it through the DC port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;docs only say this&lt;/a&gt;,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it seems to imply VIN/USB/DC in all go through the voltage regulator? Is there any difference then?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any advantage to running a variable power supply through an adapter like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MkPhim.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MkPhim.jpg&quot; alt=&quot;DC-in&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or should I just go through VIN?&lt;/p&gt;&#xA;" OwnerUserId="13972" OwnerDisplayName="Evan Carroll" LastEditorUserId="220" LastEditDate="2015-12-30T01:37:51.983" LastActivityDate="2015-12-30T01:37:51.983" Title="Arduno Uno voltage in via VIN pin or DC power?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16684" PostTypeId="2" ParentId="16683" CreationDate="2015-10-09T23:35:49.180" Score="5" Body="&lt;p&gt;DC Jack has a Reverse Protection Diode, that drops 0.7V at usable currents. The VIN does not. Both go through the on board LM7805 or similar linear regulator. The USB does not, but it does go through a P-Channel Mosfet used to switch between USB and DC/VIN power before connecting to the 5V rail. The 5V pin bypasses the regulator, Diode, and P-Channel Mosfet completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantage of the DC jack is that the Reverse Protection Diode is used, preventing reverse voltage problems if you wire it wrong.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastActivityDate="2015-10-09T23:35:49.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16685" PostTypeId="2" ParentId="16662" CreationDate="2015-10-10T02:47:25.430" Score="1" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;GSM gsmAccess;&#xA;GSM_SMS sms;&#xA;char sendernumber[20]; &#xA;int Enable_m=11;&#xA;int Control_2=12;&#xA;int Control_7=10;&#xA;LiquidCrystal lcd(7,8,9,8,1,2,3,4,5,6);&#xA;&#xA;void setup() &#xA;{&#xA;   Serial.begin(9600);&#xA;   pinMode(Enable_m,OUTPUT);&#xA;   pinMode(Control_2,OUTPUT);&#xA;   pinMode(Control_7,OUTPUT);&#xA;&#xA;   digitalWrite(Enable_m,LOW);&#xA;   digitalWrite(Control_2,LOW);&#xA;   digitalWrite(Control_7,LOW);&#xA;&#xA;   lcd.begin(16,2);&#xA;   lcd.clear();&#xA;   lcd.setCursor(0,0);&#xA;   lcd.print(&quot;Hello&quot;);&#xA;   lcd.setCursor(0,1);&#xA;   lcd.print(&quot;Everyone&quot;);&#xA;   delay(2000);&#xA;&#xA;   while (!Serial) &#xA;      Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;   boolean notConnected = true;&#xA;   while(notConnected)&#xA;   {&#xA;      if(gsmAccess.begin(&quot;0000&quot;)==GSM_READY)&#xA;         notConnected = false;&#xA;      else&#xA;      {&#xA;         Serial.println(&quot;Not connected&quot;);&#xA;         delay(1000);&#xA;      }&#xA;   }  &#xA;   Serial.println(&quot;GSM initialized&quot;);&#xA;   Serial.println(&quot;Waiting for messages&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   // put your main code here, to run repeatedly:&#xA;&#xA;   // I chose 160 since that is max size for sms&#xA;   char message [160]; &#xA;   // this fills message with null characters&#xA;   memset( message, '\0', sizeof(char)*160 ); &#xA;&#xA;   int val=0;&#xA;   val=digitalRead(Enable_m);&#xA;   if (val==LOW){&#xA;      digitalWrite(Enable_m,HIGH);&#xA;   }&#xA;   if (sms.available())&#xA;   {&#xA;      Serial.println(&quot;Message received from:&quot;);&#xA;      sms.remoteNumber(sendernumber, 20);&#xA;      Serial.println(sendernumber);&#xA;&#xA;      // you used single qoutes properly here&#xA;      // single qoutes denote a char which is a single character&#xA;      if(sms.peek()=='#')&#xA;      {&#xA;         Serial.println(&quot;Discarded SMS&quot;);&#xA;         sms.flush();&#xA;      }&#xA;&#xA;&#xA;      // this will add the characters to messages[]&#xA;      for(int i = 0; message[i] = sms.read(); i++){}&#xA;&#xA;      // I changed this to double qoutes since you need double&#xA;      // qoutes to denote a string literal&#xA;      if(strcmp(message, &quot;motoroff&quot;) == 0){&#xA;         analogWrite(Enable_m, 0);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,LOW);&#xA;      }&#xA;      else if(strcmp(message, &quot;motoronclockwise&quot;) == 0){&#xA;         analogWrite(Enable_m, 255);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      else if(strcmp(message, &quot;motoronanticlockwise&quot;) == 0){&#xA;         analogWrite(Enable_m, 255);&#xA;         digitalWrite(Control_2,HIGH);&#xA;         digitalWrite(Control_7,LOW);&#xA;      }&#xA;      else if(strcmp(message, &quot;speedhalf&quot;) == 0){&#xA;         analogWrite(Enable_m, 128);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      else if(strcmp(message, &quot;speedquarter&quot;) == 0){&#xA;         analogWrite(Enable_m, 65);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      else if(strcmp(message, &quot;speed75&quot;) == 0){&#xA;         analogWrite(Enable_m, 192);&#xA;         digitalWrite(Control_2,LOW);&#xA;         digitalWrite(Control_7,HIGH);&#xA;      }&#xA;      // This else will only be executed if the previous if and else if statements are false&#xA;      else{&#xA;         digitalWrite(Enable_m,HIGH);&#xA;         Serial.print(message);&#xA;      }&#xA;      Serial.println(&quot;\nEND OF MESSAGE&quot;);&#xA;      sms.flush();&#xA;      Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;   }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I've made some edits to your code. For example this code &lt;code&gt;'motoronanticlockwise'&lt;/code&gt; isn't correct. Single quotes are used for &lt;code&gt;char&lt;/code&gt; data types and double quotes are used for string literals. You should use double quotes since there are multiple characters &lt;code&gt;&quot;motoronanticlockwise&quot;&lt;/code&gt;. Also as Majenko said you would have to use &lt;code&gt;strcmp()&lt;/code&gt; in order to compare &lt;code&gt;c-strings&lt;/code&gt;&#xA;c-strings are &lt;code&gt;char&lt;/code&gt; arrays that have a null terminator &lt;code&gt;'\0'&lt;/code&gt;. Also &lt;code&gt;strcmp()&lt;/code&gt; returns &lt;code&gt;0&lt;/code&gt; if the two strings are equal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your last &lt;code&gt;else&lt;/code&gt; statement will only executed if the previous &lt;code&gt;if&lt;/code&gt; statement is &lt;code&gt;false&lt;/code&gt;. It seems like you only want it to execute if &lt;strong&gt;all&lt;/strong&gt; of the previous &lt;code&gt;if&lt;/code&gt; statement are false. To do this you make the first &lt;code&gt;if&lt;/code&gt; statement and then make a chain of &lt;code&gt;if else&lt;/code&gt; statements followed by a single &lt;code&gt;else&lt;/code&gt; statement. You can have a single &lt;code&gt;if&lt;/code&gt; statement with no &lt;code&gt;else&lt;/code&gt; or &lt;code&gt;if else&lt;/code&gt; statements however, if you want &lt;code&gt;else&lt;/code&gt; or &lt;code&gt;if else&lt;/code&gt; statements then you need to have an &lt;code&gt;if&lt;/code&gt; statement. I've made the necessarily edits to your code already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, this part of the program is the biggest problem &lt;code&gt;while(c=sms.read())&lt;/code&gt; This is because &lt;code&gt;sms.read()&lt;/code&gt; returns a &lt;code&gt;char&lt;/code&gt; so you can only read the sms message one character at a time. To do this properly you should make a character array and store the values returned by &lt;code&gt;sms.read()&lt;/code&gt; in it. This can be done like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char message [160]; // I chose 160 since that is max size for sms&#xA;memset( message, '\0', sizeof(char)*160 ); // this fills message with null characters&#xA;// this will add the characters to messages[]&#xA;for(int i = 0; message[i] = sms.read(); i++){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a &lt;code&gt;for&lt;/code&gt; loop to iterate through &lt;code&gt;message[]&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the above and get back to me if there are any problems with it.&lt;/p&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2015-10-16T02:18:52.220" LastActivityDate="2015-10-16T02:18:52.220" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16686" PostTypeId="2" ParentId="16680" CreationDate="2015-10-10T03:23:22.537" Score="2" Body="&lt;p&gt;This part of your code is what changes the sprite's y-value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;y += deltaIde * moveSpeed;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you click the &quot;jump&quot; button or when the bird falls the y-value is changed to reflect either an upward movement or a downward movement. When your &lt;code&gt;render()&lt;/code&gt; method is called the bird will either be drawn higher up on the y-axis (it's flying) or lower on the y-axis (it's falling).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the bars, if you watch closely in the video you can see that they aren't actually randomized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Compound Assignment Operators&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+=&lt;/code&gt; is the &quot;plus assign&quot; operator. It adds whatever is on the right side to the variable on the left side. Here is a table of other compound assignment operators: &lt;a href=&quot;https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Compound_assignment_operators&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Compound_assignment_operators&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x = 5;&#xA;x += 2; // equals 7; equivalent to x = x + 2;&#xA;x = 5;&#xA;x = x + 2; // also equals 7; equivalent to x += 2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2015-10-20T03:01:06.707" LastActivityDate="2015-10-20T03:01:06.707" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16687" PostTypeId="2" ParentId="16683" CreationDate="2015-10-10T05:16:23.177" Score="0" Body="&lt;p&gt;If you have a &quot;variable power supply&quot; just set it to 5.00v and connect to the 5v pins.  Eg like the this &lt;a href=&quot;http://blog.unixbigot.id.au/2015/10/make-5-volt-battery-supply-for-any.html?m=1&quot; rel=&quot;nofollow&quot;&gt;http://blog.unixbigot.id.au/2015/10/make-5-volt-battery-supply-for-any.html?m=1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13921" LastActivityDate="2015-10-10T05:16:23.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16688" PostTypeId="1" AcceptedAnswerId="16693" CreationDate="2015-10-10T07:16:40.450" Score="0" ViewCount="528" Body="&lt;p&gt;I have successfully made a voltage measurement circuit on my Teensy 3.1 that reads a voltage coming out of digital pin 0 set high and coming back into an analog pin A0 to read voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int timer = 100;&#xA;int ColA = 0;&#xA;int Output;&#xA;&#xA;// Setting digital pin functions&#xA;&#xA;void setup()&#xA;{                &#xA;  Serial.begin(38400);&#xA;  pinMode(0, OUTPUT);&#xA;&#xA;}&#xA;&#xA;// Program&#xA;&#xA;void loop()                     &#xA;{ &#xA;  digitalWrite(0, HIGH);&#xA;  delay(timer);&#xA;  Output = analogRead(A0);&#xA;  Serial.println(Output);&#xA;  delay(timer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works fine with my circuit on a Teensy 3.1 running 3.3v however when i run this code on an Arduino Uno running 5v wired exactly the same way I just get this print out of numbers that cycles back and forth from ~128 down to 0 and back constantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight on the differences here would be great. I need the 5v micro-controller to run a 4051 multiplexer!&lt;/p&gt;&#xA;" OwnerUserId="13923" LastEditorUserId="4131" LastEditDate="2015-10-12T18:36:20.417" LastActivityDate="2015-10-12T18:36:20.417" Title="Why does my analogRead work on Teensy but not Arduino Uno?" Tags="|arduino-uno|analogread|teensy|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16689" PostTypeId="2" ParentId="4835" CreationDate="2015-10-10T07:21:33.440" Score="1" Body="&lt;p&gt;It takes me some time to make it work : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) update drivers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;opkg update &#xA;&#xA;opkg install kmod-bluetooth bluez-libs bluez-utils&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) add configuration files in directory /etc/bluetooth&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root@Arduino:~# cat /etc/bluetooth/hcid.conf&#xA;&#xA;options {&#xA;  autoinit yes;&#xA;  security auto;&#xA;  pairing multi;&#xA;  passkey &quot;0000&quot;;&#xA;   }&#xA;device {&#xA;  name &quot;OpenWrt&quot;;&#xA;  class 0x000100;&#xA;  lm accept,master;&#xA;  lp rswitch,hold,sniff,park;&#xA;  }&#xA;&#xA;root@Arduino:~# cat /etc/bluetooth/rfcomm.conf &#xA;&#xA;rfcomm0{&#xA; bind yes;&#xA; device 00:1B:C1:02:B0:F5;&#xA; channel 1;&#xA; comment &quot;Holux M-1000&quot;;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) Reboot the card&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) test if all is OK&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hciconfig&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;5) put the interface up&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hciconfig hci0 up&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;6) Search for devices&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hcitool scan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;7) Look for Serial Port capability on the devices&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sdptool search SP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;8) bind the serial dev&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rfcomm -i hci0 connect /dev/rfcomm0 00:1B:C1:02:B0:F5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;9) see the information comming from the device (bluetooth GPS in my case)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat /dev/rfcomm0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13924" LastEditorUserId="10794" LastEditDate="2015-10-10T20:12:12.647" LastActivityDate="2015-10-10T20:12:12.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16692" PostTypeId="1" AcceptedAnswerId="17149" CreationDate="2015-10-10T08:55:27.703" Score="0" ViewCount="1043" Body="&lt;p&gt;&lt;strong&gt;I just bought the SmartEverything FOX Board which is Arduino compatible&lt;/strong&gt; &lt;a href=&quot;http://www.smarteverything.it/wp-content/uploads/2015/10/SmartEverything-User-Guide-Ver-1.01.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.smarteverything.it/wp-content/uploads/2015/10/SmartEverything-User-Guide-Ver-1.01.pdf&lt;/a&gt; and simply tried to get started with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My OS is Ubuntu 14.04, my laptop DELL XPS 13 bought in 2014&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I cannot upload sketches on it, when I try, it gets stuck on uploading&lt;/strong&gt;, whether it is a basic script (blinkRBG) or even the default one with empty setup and loop methods, my laptop processor keeps running at 100% and nothing happens. &#xA;&lt;strong&gt;The board does not do anything, tx/rx leds do not flash.&lt;/strong&gt; &#xA;&lt;strong&gt;I can access to it with a Windows 7 laptop  (UPDATE: and another UBUNTU laptop) from a frien&lt;/strong&gt;d, I could upload the basic blinkRGB sketch. If I try to upload from my Ubuntu laptop after, it does erase the contents and stop the blinking but nothing follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to upload, I only get the compiling logs:&#xA;Quote&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 13,368 bytes (5%) of program storage space. Maximum is 262,144 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I could still upload sketches to another board from my Ubuntu laptop: to an Arduino micro.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I am connecting directly from my board to my laptop through USB 3.0&lt;/strong&gt;, I don't have USB2.0 plugs on my laptop, and I currently don't have any programmer device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with different versions of arduino IDE (1.6.4 1.6.5 nightly), same issue every time.&#xA;The IDE sees that my board is connected on /dev/ttyACM0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to run in command line but it gets stuck as well&#xA;Quote&#xA;/home/jcharlet/.arduino15/packages/arduino/tools/bossac/1.6-arduino/bossac --port=ttyACM0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I've been googling the world but could not find anything, could anyone help me to troubleshoot it please?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="13925" LastEditorUserId="13925" LastEditDate="2015-10-10T09:34:29.207" LastActivityDate="2016-01-26T17:34:03.260" Title="Stuck on upload" Tags="|uploading|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16693" PostTypeId="2" ParentId="16688" CreationDate="2015-10-10T11:27:18.377" Score="1" Body="&lt;p&gt;If you're still using D0 as your output on the Uno then yes you are doomed to failure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D0 and D1 are the serial port. You are using that to communicate with the PC. You cannot use them for any other purpose at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pick a different IO pin to be your voltage source.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-10T11:27:18.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16694" PostTypeId="1" CreationDate="2015-10-10T12:10:51.813" Score="2" ViewCount="88" Body="&lt;p&gt;I'm trying to write a state machine for my robot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the robot is moving around I would like to read the values of the sensors, but after some time the reading stops working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the first half hour it's ok, then I don't know what changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like it halts when jumping from one state to another, or when the sensor value has a big jump... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to move the debugOutput function inside the main loop, but the behavior is the same..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the serial halting, also the state machine itself seems to stop working good, since even if the sensor value change, the state is not updated..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please help me with this? &#xA;Thanks a lot! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // motor one&#xA;    int enA = 13;&#xA;    int in1 = 12;&#xA;    int in2 = 11;&#xA;    // motor two&#xA;    int enB = 9;&#xA;    int in3 = 10;&#xA;    int in4 = 8;&#xA;&#xA;    int sens1 = 0; //ingresso sensore bobina 1&#xA;    int sens2 = 1; //ingresso sensore bobina 2&#xA;&#xA;    float soglia_barriera_norm = 1.5; &#xA;    float soglia_barriera_scarico = 390;&#xA;&#xA;&#xA;    // define the states&#xA;    #define DRIVE_FORWARD     0&#xA;    #define TURN_LEFT         1&#xA;    #define RADDRIZZA         2&#xA;    #define SCARICO           3 //Scarico cerca il filo&#xA;&#xA;    int state = 3; //to start from state 3&#xA;&#xA;&#xA;    void setup()&#xA;    {&#xA;      // set all the motor control pins to outputs&#xA;      pinMode(enA, OUTPUT);&#xA;      pinMode(enB, OUTPUT);&#xA;      pinMode(in1, OUTPUT);&#xA;      pinMode(in2, OUTPUT);&#xA;      pinMode(in3, OUTPUT);&#xA;      pinMode(in4, OUTPUT);&#xA;      pinMode(53, OUTPUT);&#xA;      Serial.begin(9600);&#xA;&#xA;    }&#xA;&#xA;    //------------------------ LETTURA SENSORI ---------------------------&#xA;    //average of n readings&#xA;&#xA;    float sensorReadDX(int n_medie) {&#xA;      int i, temp = 0;&#xA;      for (i = 0; i &amp;lt; n_medie; i++) {&#xA;        int sensorValue1 = analogRead(sens1);&#xA;        temp += sensorValue1;&#xA;      }&#xA;      float volt = (temp / n_medie);&#xA;      return volt;&#xA;    }&#xA;&#xA;    float sensorReadSX(int n_medie) {&#xA;      int i, temp = 0;&#xA;      for (i = 0; i &amp;lt; n_medie; i++) {&#xA;        int sensorValue2 = analogRead(sens2);&#xA;        temp += sensorValue2;&#xA;      }&#xA;      float volt2 = (temp / n_medie);&#xA;      return volt2;&#xA;    }&#xA;&#xA;    float differenza(float volt1, float volt2) {&#xA;      float D = volt1 - volt2;&#xA;      return D;&#xA;    }&#xA;    //----------------------------------------------------------------------&#xA;&#xA;    //----------- MOTOR MOVEMENTS ---------------------------------------------&#xA;&#xA;    void moto_dx_forward(int vel) {&#xA;      digitalWrite(in1, LOW);&#xA;      digitalWrite(in2, HIGH);&#xA;      analogWrite(enA, vel);&#xA;    }&#xA;&#xA;    void moto_dx_backward(int vel) {&#xA;      digitalWrite(in1, HIGH);&#xA;      digitalWrite(in2, LOW);&#xA;      analogWrite(enA, vel);&#xA;    }&#xA;&#xA;    void moto_sx_forward(int vel) {&#xA;      digitalWrite(in3, LOW);&#xA;      digitalWrite(in4, HIGH);&#xA;      analogWrite(enB, vel);&#xA;    }&#xA;&#xA;    void moto_sx_backward(int vel) {&#xA;      digitalWrite(in3, HIGH);&#xA;      digitalWrite(in4, LOW);&#xA;      analogWrite(enB, vel);&#xA;    }&#xA;&#xA;    // to stop motors&#xA;    void moto_dx_stop() {&#xA;      digitalWrite(in1, LOW);&#xA;      digitalWrite(in2, LOW);&#xA;      analogWrite(enA, 0);&#xA;    }&#xA;&#xA;    void moto_sx_stop() {&#xA;      digitalWrite(in3, LOW);&#xA;      digitalWrite(in4, LOW);&#xA;      analogWrite(enB, 0);&#xA;    }&#xA;&#xA;    //---------------------------------------------------------&#xA;&#xA;    void debugOutput() {&#xA;      Serial.print(millis());&#xA;      Serial.print(&quot;\t&quot;);&#xA;      Serial.print(sensorReadSX(50));&#xA;      Serial.print(&quot;\t&quot;);&#xA;      Serial.print(sensorReadDX(30));&#xA;      Serial.print(&quot;\t&quot;);&#xA;      Serial.println(state);&#xA;    }&#xA;&#xA;&#xA;    void stateMachine() {&#xA;      float sensSX = sensorReadSX(30);&#xA;      float sensDX = sensorReadDX(30);&#xA;&#xA;      if (state == DRIVE_FORWARD) {&#xA;        debugOutput();&#xA;&#xA;        if (sensSX &amp;lt;= soglia_barriera_norm || sensDX &amp;lt;= soglia_barriera_norm) {&#xA;          moto_dx_forward(255);&#xA;          moto_sx_forward(255);&#xA;        } else {&#xA;          state = RIMBALZA;&#xA;        }&#xA;      }&#xA;&#xA;      else if (state == SCARICO) {&#xA;        debugOutput();&#xA;        if (sensorReadSX(50) &amp;lt; soglia_barriera_scarico){ //|| sensorReadDX(20) &amp;lt; soglia_barriera_scarico) {&#xA;          moto_dx_forward(255);&#xA;          moto_sx_forward(255);&#xA;        } else {&#xA;          moto_dx_stop(); //ferma i due motori e poi raddrizza&#xA;          moto_sx_stop();&#xA;          state = RADDRIZZA;&#xA;        }&#xA;      }&#xA;&#xA;      else if (state == RADDRIZZA) {&#xA;        debugOutput();&#xA;         while ( sensorReadDX(30) &amp;lt;= 490){ &#xA;          //ruota su se stesso&#xA;          moto_sx_stop();&#xA;          moto_dx_forward(255);&#xA;        }&#xA;&#xA;        moto_dx_stop();&#xA;        moto_sx_stop();&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    void loop() {&#xA;      stateMachine();&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13926" LastEditorUserId="10794" LastEditDate="2015-10-10T20:21:01.470" LastActivityDate="2015-10-10T20:21:01.470" Title="Serial print and sensor readings halts" Tags="|serial|sensors|c++|robotics|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16696" PostTypeId="1" AcceptedAnswerId="16810" CreationDate="2015-10-10T13:06:07.313" Score="3" ViewCount="2913" Body="&lt;p&gt;When reading analogue sensors - e.g. load cells, accelerometers - via a microcontroller's Analogue to Digital Converter, there are many sources of potential measurement error including:&lt;br&gt;&#xA;a) Warm-up time for electronics&lt;br&gt;&#xA;b) Mechanical inertia and resonance&lt;br&gt;&#xA;c) Spurious random readings (due to e.g. vibration, electrical interference).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current software hack for a) and b) is to simply add a suitable time delay before reading the sensors; however there must be a more robust way of detecting and screening for resonance... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My hack for c) is to take the mean of a given number of consecutive readings, but discard any individual readings which exceed a given percentage range from the current mean (pseudocode example below). The trouble with this approach is that it requires an inital `baseline' sensor reading, and if this happens to be spuriously high or low, it can cause subsequent correct readings to be rejected. &#xA;Another approach might incorporate a weighted moving average, but this would still be skewed by spurious random readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any robust and elegant approaches / algorithms for the above which are commonly applied in commercial devices (e.g. domestic or laboratory weighing scales) that I could include in my code to improve the accuracy and reliability of measurements?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in anticipation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Take mean of multiple sensor readings excluding outliers:&#xA;&#xA;# define SAMPLES 100 // number of samples to take mean of&#xA;# define TOLERANCE 0.1 // % range of allowable deviation         &#xA;                       //between current mean and new values, expressed as decimal&#xA;&#xA;n = 1; // loop variable&#xA;total = analogRead(analogPin); // Running total for calculation of mean &amp;amp; baseline reading&#xA;mean = total; // mean of all current data&#xA;&#xA;while (n &amp;lt; SAMPLES) {&#xA;    new = analogRead(analogPin);&#xA;    if (new &amp;lt; (1 + TOLERANCE) * mean) and (new &amp;gt; (1 - TOLERANCE) * mean){&#xA;        total += new; // if new reading is within range, calculate new mean&#xA;        n += 1;&#xA;        mean = total / n;&#xA;        }&#xA;    // (else ignore new reading)&#xA;}&#xA;Serial.print mean;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13929" LastActivityDate="2015-10-15T20:31:39.657" Title="Algorithms to reduce measurement error from analogue sensors" Tags="|sensors|adc|algorithm|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16697" PostTypeId="1" CreationDate="2015-10-10T15:37:18.283" Score="4" ViewCount="711" Body="&lt;p&gt;If I use some IC which requires clock frequency like 16MHz, can I take one from Arduino? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or this it too high frequency to travel to neighboring board?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2021-10-20T02:05:37.410" Title="Can I reuse crystal frequency of Arduino?" Tags="|oscillator-clock|" AnswerCount="2" CommentCount="4" ClosedDate="2021-10-20T05:45:48.070" ContentLicense="CC BY-SA 3.0" />
  <row Id="16698" PostTypeId="1" AcceptedAnswerId="16705" CreationDate="2015-10-10T15:55:44.803" Score="4" ViewCount="25256" Body="&lt;p&gt;I am controlling an ADC with my Arduino Uno. I would like the clock of the ADC to be the same frequency of the Arduino.&#xA;Is there any way that I can have a constant clock output from one of the Arduino pin ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Liam&lt;/p&gt;&#xA;" OwnerUserId="10908" LastActivityDate="2020-01-03T15:06:56.097" Title="Arduino constant clock output" Tags="|frequency|oscillator-clock|adc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16699" PostTypeId="1" CreationDate="2015-10-10T16:22:09.523" Score="-1" ViewCount="1314" Body="&lt;p&gt;I am using a SIM800 GSM/GPRS module. I connected it using 4 wires: Vcc 3.7 volt (2 amp supply), RX and TX and GND.  Whenever I try to send a command it shows me nothing. Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//Serial Relay - Arduino will patch a&#xA;//serial link between the computer and the GPRS Shield&#xA;//at 19200 bps 8-N-1&#xA;//Computer is connected to Hardware UART&#xA;//GPRS Shield is connected to the Software UART&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial GPRS(7, 8);&#xA;&#xA;unsigned char buffer[64];  // buffer array for data receive over serial port&#xA;int count=0;               // counter for buffer array&#xA;&#xA;void setup() {&#xA;  GPRS.begin(19200);&#xA;  Serial.begin(19200);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (GPRS.available()) {&#xA;    while(GPRS.available()) {&#xA;      buffer[count++]=GPRS.read();&#xA;      if(count == 64)break;&#xA;    }&#xA;    Serial.write(buffer,count);&#xA;    clearBufferArray();&#xA;    count = 0;&#xA;  }&#xA;  if (Serial.available())&#xA;    GPRS.write(Serial.read());&#xA;}&#xA;&#xA;void clearBufferArray() {&#xA;  for (int i=0; i&amp;lt;count;i++) {&#xA;    buffer[i]=NULL;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is an independent module. I've already read the hardware manual and AT command manual. I did everything according to the manual.&lt;/p&gt;&#xA;" OwnerUserId="13661" LastEditorUserId="3917" LastEditDate="2015-12-13T20:03:34.037" LastActivityDate="2016-02-11T22:55:43.520" Title="GSM GPRS module not getting any output from Rx , Tx" Tags="|gsm|softwareserial|uart|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16700" PostTypeId="2" ParentId="16698" CreationDate="2015-10-10T16:36:37.703" Score="3" Body="&lt;p&gt;You can use one of the PWM pins on Arduino to output a PWM signal.&#xA;If you want a constant clock, you need to set the duty cycle of the PWM to be 0.5, i.e. 50%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Syntax: analogWrite(pin, value) where the parameter &quot;value&quot; is the duty cycle ranges from 0 (always off) to 255 (always on) since it is a 8-bit PWM generator inside Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a PWM wave with duty cycle of 0.5, you need to set the &quot;value&quot; above to be 127, which is exactly in middle of 0 and 255:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(clkpin, 127);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13931" LastEditorUserId="13931" LastEditDate="2015-10-11T07:00:02.563" LastActivityDate="2015-10-11T07:00:02.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16701" PostTypeId="1" AcceptedAnswerId="16708" CreationDate="2015-10-10T16:39:09.193" Score="0" ViewCount="115" Body="&lt;p&gt;I was trying to make an Arduino Robot that is Bluetooth controlled but I've some problems!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out how to parse strings in Arduino like c++/java/python!&#xA;I tried this, If the first letter is L, set the next value to left motor, same for R&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but for example &quot;L255&quot; is received as L - 2 - 5 - 5 and it sets L to 2 and ignores 5 - 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what I should do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Thought of something else, Sending L or R will toggle the motors! but that's just terrible, it'll be my last option&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: This is how it works now:&#xA;L(0-5) means Left motor speed 5 * 51, 6-9 are backwards! its go backwards at (L(6-9) -5 * 51)&lt;/p&gt;&#xA;" OwnerUserId="13932" LastEditorUserId="13932" LastEditDate="2015-10-12T15:40:47.807" LastActivityDate="2015-10-12T15:40:47.807" Title="Can't figure out how to send Motor Values over Bluetooth, Arduino Bluetooth-controller robot" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16702" PostTypeId="1" AcceptedAnswerId="16703" CreationDate="2015-10-10T16:43:02.597" Score="0" ViewCount="239" Body="&lt;p&gt;I am looking for a very low power Micro-controller to interface with the RockBlock Iridium modem. The MCU I am thinking of purchasing is the Gecko Zero by Silicon Labs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know if it is possible to compile the Rockblock-IridiumSBD Arduino library for the Gecko Zero. The Gecko Zero is a 32 bit ARM MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mikalhart/IridiumSBD&quot; rel=&quot;nofollow&quot;&gt;IridiumSBD Library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.silabs.com/products/mcu/lowpower/Pages/efm32zg-stk3200.aspx&quot; rel=&quot;nofollow&quot;&gt;Gecko Zero MCU&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13934" OwnerDisplayName="J. Clark" LastEditorUserId="612" LastEditDate="2015-10-10T17:13:25.843" LastActivityDate="2015-10-10T17:40:41.320" Title="Can Arduino libraries be compiled for ARM MCU's?" Tags="|compile|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16703" PostTypeId="2" ParentId="16702" CreationDate="2015-10-10T17:40:41.320" Score="1" Body="&lt;p&gt;Depending on the rest of your application, you might find the easiest path is to use the Gecko with the mbed.org tools. There already seem to be &lt;a href=&quot;https://developer.mbed.org/teams/SiliconLabs/&quot; rel=&quot;nofollow&quot;&gt;mbed Gecko development boards&lt;/a&gt; so the task is, to port the &lt;a href=&quot;http://arduiniana.org/libraries/iridiumsbd/&quot; rel=&quot;nofollow&quot;&gt;Rockblock-IridiumSBD Arduino library&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The benefit of using mbed with the Gecko is it looks like mbed have all of the libraries, including low-power control implemented.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://arduiniana.org/libraries/iridiumsbd/&quot; rel=&quot;nofollow&quot;&gt;Rockblock-IridiumSBD Arduino library&lt;/a&gt; won't compile 'out of the packet' on mbed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the &lt;a href=&quot;http://arduiniana.org/libraries/iridiumsbd/&quot; rel=&quot;nofollow&quot;&gt;Rockblock-IridiumSBD Arduino library&lt;/a&gt; appears to be a serial interface over a few wires. They recommend 'soft serial' which uses digitalWrite, under program control, and no deep access to Arduino peripherals. That should be relatively straightforward to port to mbed. Mbed has equivalent library calls for digitalWrite, so a first attempt might be a few global search and replace edits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative would be to use Gecko with an Open Source or commercial development system. However, mbed would provide a faster start, if you have good internet access and are not too paranoid about security, because the tools are 'cloud based', saving you time to set up the tools, and their is an mbed community who might help you over the initial hurdles. &lt;/p&gt;&#xA;" OwnerUserId="3493" LastActivityDate="2015-10-10T17:40:41.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16704" PostTypeId="1" CreationDate="2015-10-10T18:38:49.640" Score="0" ViewCount="495" Body="&lt;p&gt;I have an arduino uno Rs board and when connected to USB the board is dead. Yet when connected to the external supply the board will come to live. Power LED on and led near pin 13 blink on and off all time. I tried another computer and other new usb lead. Still computer will not see the board. When usb lead is on checked the 5 volt on the board and it is ok. Even checked the usb lead with multi meter and all  four connection are ok &#xA;Can you give me some advice&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;1.Yes I bought the new board from different source but still waiting for it to arrive.&#xA;2.  My clone board Arduino uno using microcontroller Atmega329P-PU and interphase chip Atmega16U2]&#xA;3 but the video link is still of help as my new board is as the one shown in the video. Will use it late. Great!!!&#xA;There should be a similar explanation for the one I have in the picture&lt;a href=&quot;https://i.stack.imgur.com/ngtdr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ngtdr.jpg&quot; alt=&quot;Uno board as descripted&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13937" LastEditorUserId="220" LastEditDate="2015-10-15T01:23:00.483" LastActivityDate="2016-02-12T10:16:22.150" Title="Arduino Uno R3 board dead" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16705" PostTypeId="2" ParentId="16698" CreationDate="2015-10-10T20:30:04.183" Score="9" Body="&#xA;&#xA;&lt;p&gt;This outputs 8 MHz on pin 9:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#ifdef __AVR_ATmega2560__&#xA;  const byte CLOCKOUT = 11;  // Mega 2560&#xA;#else&#xA;  const byte CLOCKOUT = 9;   // Uno, Duemilanove, etc.&#xA;#endif&#xA;&#xA;void setup ()&#xA;  {&#xA;  // set up 8 MHz timer on CLOCKOUT (OC1A)&#xA;  pinMode (CLOCKOUT, OUTPUT); &#xA;  // set up Timer 1&#xA;  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match&#xA;  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaling&#xA;  OCR1A =  0;       // output every cycle&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can add a prescaler?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You change the prescaler bits. You can look at the datasheet or my cheat sheet here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ftmib.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ftmib.png&quot; alt=&quot;Timer 1 bits&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may not need a prescaler, depending on the frequency. Change OCR1A to some number between 0 and 65535 to slow it down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit by Edgar: I tested the OCR1A values with an oscilloscope. At the end of this answer are the frequencies.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;you use TCR1A, COM1A0 and similar variables. Are these always present and implicitly defined when running code on the ATmega&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Registers like TCCR1A and so on are defined in files which are automatically included by the Arduino IDE. If you use another toolchain they may be also automatically included. The start point is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define &amp;lt;avr/io.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside that file it checks your processor type (from a symbol passed to the compiler) and then includes an appropriate sub-file. Inside those files are defines which relate the register names to their address in the address-space of that particular chip. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define TCCR1A _SFR_MEM8(0x80)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The _SFR_MEM8 basically generates a pointer to a &lt;code&gt;volatile&lt;/code&gt; address (because it might change without the compiler knowing it) and then dereferences that variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the number 0x80 in that define agrees with the number shown on my chart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Underneath that define in the appropriate file are also the bit positions for the bits in that register, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#define TCCR1A _SFR_MEM8(0x80)&#xA;#define WGM10 0&#xA;#define WGM11 1&#xA;#define COM1B0 4&#xA;#define COM1B1 5&#xA;#define COM1A0 6&#xA;#define COM1A1 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Secondly, do I correctly understand that the output pin is defined in TCR1A, Output A and Output B, to be on Digital Pin 9 and 10 respectively? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, in effect. The datasheet says that if you set the appropriate bits in TCCR1A (note the spelling) then OC1A (board pin 9 on the Uno) or OC1B (board pin 10 on the Uno) will be unchanged/toggled/cleared/set depending on the bits. You can find these names on the datasheet for the Atmega328P (and other devices) and then use the Arduino schematic to find which &lt;em&gt;processor&lt;/em&gt; pins are connected to which &lt;em&gt;board&lt;/em&gt; pins.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Atmega328P datasheet snippet:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bHk4y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bHk4y.png&quot; alt=&quot;Atmega328P datasheet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Uno datasheet snippet:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a0MjE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a0MjE.png&quot; alt=&quot;Uno datasheet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why do you set it to &quot;Toggle&quot; rather than &quot;Set&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because every time the counter matches I want to flip the pin. That is, on/off/on/off etc.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does CTC stand for?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Clear Timer on Compare. What this means is that (unlike other modes) once the compare match is made, the timer is cleared, thus it starts counting up from zero again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit by Edgar: OCR1A values and frequencies&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Value, MHz&#xA; 0 8.00&#xA; 1 4.00&#xA; 2 2.67&#xA; 3 2.00&#xA; 4 1.60&#xA; 5 1.33&#xA; 6 1.14&#xA; 7 1.00&#xA; 8 0.889&#xA; 9 0.800&#xA;10 0.727&#xA;11 0.667&#xA;12 0.615&#xA;13 0.571&#xA;14 0.533&#xA;15 0.500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="47431" LastEditDate="2020-01-03T15:06:56.097" LastActivityDate="2020-01-03T15:06:56.097" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="16706" PostTypeId="2" ParentId="16704" CreationDate="2015-10-10T20:49:49.533" Score="1" Body="&lt;p&gt;Does the Arduino show up at all in device manager or in mac/linux.(not sure what you are using)Is your board authentic or a clone? Did this happen the first time you plugged the arduino in or after uploading sketches etc? I had screwed up my firmware for my board that acted similar to what you describe.(I was trying to flash a different firmware) Eventually i ended up reflashing the right firmware and it went back to working again.Maybe it's that, maybe it isn't.&lt;/p&gt;&#xA;" OwnerUserId="13678" LastActivityDate="2015-10-10T20:49:49.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16707" PostTypeId="2" ParentId="16704" CreationDate="2015-10-10T22:32:13.250" Score="0" Body="&lt;p&gt;You are happy the lead is ok. Good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you test another Arduino on the PC? (Is it a driver issue?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you connect to the serial pins on the Arduino and read the console output, is anything coming out on USB? (Is the USB socket on the board broken?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you selected the right board type on the ide? (I know it's a dumb question but...)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-10T22:32:13.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16708" PostTypeId="2" ParentId="16701" CreationDate="2015-10-10T22:52:51.843" Score="0" Body="&lt;p&gt;A state machine is the right way to go if you are sending multibyte commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However do you need to send 4 bytes for every turn? Do you need accuracy to one degree? Are you going to make regular turns of greater than 60 degrees?  If not I would consider encoding the dAta into a single byte.  You will reduce the radio bandwidth by 3/4, it will improve the responsiveness of. Your software and it will remove the need to have a handler for incomplete messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course there are probably other requirements that I don't know that will stop you doing this, but in case you haven't thought of it.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-10T22:52:51.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16709" PostTypeId="1" CreationDate="2015-10-10T22:56:53.383" Score="0" ViewCount="108" Body="&lt;p&gt;I'm trying my best attempt here after failing in Googling the answer, but here goes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get a separate instance to start running &lt;em&gt;in the background&lt;/em&gt; when a pin goes HIGH. How should I attempt this? PLEASE explain your answer, so that I can learn as well. I'm using an Arduino Uno R3 with a Commercial Ir RX-Tx.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Basically:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor -&gt; Low -&gt; Loop&#xA;&lt;br&gt;Sensor -&gt; High -&gt; Start Other Event for 5 min -&gt; Loop while Counting down to reset state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thoughts here are:&lt;br&gt;&#xA;Do this via 555-timer OR get some functional coding (anyone maybe want to share here what solutions they have found?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="4457" LastActivityDate="2021-08-05T22:06:45.670" Title="Separate Timer Instance" Tags="|arduino-uno|timers|ir|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16710" PostTypeId="2" ParentId="16699" CreationDate="2015-10-10T23:00:06.447" Score="0" Body="&lt;p&gt;There doesn't seem to be anything wrong with your code.  I'm going to assume you have got the right VCC and the right Serial speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have a way of connecting the device directly to your PC and then using a terminal emulator to see if the device is talking? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a library that you could use?  Maybe there is some setting that you need that isn't documented.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-10T23:00:06.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16711" PostTypeId="1" CreationDate="2015-10-10T23:19:25.390" Score="1" ViewCount="162" Body="&lt;p&gt;I am trying to use more than 8 temperature DS18b20 on one bus. Is there any problem to make it work?&lt;/p&gt;&#xA;" OwnerUserId="13893" LastActivityDate="2015-10-10T23:33:54.453" Title="using more than 8 temperature probe of DS18B20 on Arduino" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16712" PostTypeId="2" ParentId="16709" CreationDate="2015-10-10T23:28:14.817" Score="1" Body="&lt;p&gt;Arduino Uno has two interrupt pins: 2 and 3, and by hooking up the output of your IR, which goes from LOW to HIGH, it will trigger the function that you defined in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example this is a piece of code that runs when the pin 2 RISING:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    attachInterrupt(0, doSomething, RISING);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;void doSomething() {&#xA;    //Do your stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Look here for further information &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13940" LastEditorUserId="10794" LastEditDate="2015-10-11T03:50:21.353" LastActivityDate="2015-10-11T03:50:21.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16713" PostTypeId="2" ParentId="16711" CreationDate="2015-10-10T23:33:17.180" Score="2" Body="&lt;p&gt;As far as I can see there is no limit on the number of sensors you can have on a bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you are having problems does your code work with less sensors? Try one and work up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a current issue are you pulling to much from the board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the problem with the one wire library? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you got 4.7k pull ups on each sensor?&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-10T23:33:17.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16714" PostTypeId="2" ParentId="16711" CreationDate="2015-10-10T23:33:54.453" Score="0" Body="&lt;p&gt;As long as you connect each sensor on a different pin, you should be able to collect the data without any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise try to search for a I2C temperature sensor and use a demux to control 8 sensors.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-10-10T23:33:54.453" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16715" PostTypeId="2" ParentId="16280" CreationDate="2015-10-10T23:38:17.110" Score="1" Body="&lt;p&gt;You would need to create a buffer which will populate over each loop so you dont block the main loop while waiting the all string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you get the string or your buffer is full, just check whatever is the response, and based on that you can make your decision.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-10-10T23:38:17.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16716" PostTypeId="2" ParentId="16275" CreationDate="2015-10-10T23:41:50.443" Score="0" Body="&lt;p&gt;Could you confirm that any of the commands sent over your &lt;code&gt;SoftwareSerial&lt;/code&gt; are responding?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably need to add a &lt;code&gt;&quot;\n&quot;&lt;/code&gt; (new line) at the end of your messages or just use &lt;code&gt;println()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, add your code to the question so we can be of better assistance.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastEditorUserId="8033" LastEditDate="2016-05-09T09:20:02.707" LastActivityDate="2016-05-09T09:20:02.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16717" PostTypeId="2" ParentId="10261" CreationDate="2015-10-10T23:44:44.117" Score="1" Body="&lt;p&gt;You need to attach an interrupt to the pin which is getting HIGH and then the function connected to the interrupt will have the code to send the SMS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just init the GPRS with connecting to the network then just wait for the interrupt to send anything.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-10-10T23:44:44.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16718" PostTypeId="2" ParentId="9031" CreationDate="2015-10-10T23:49:20.207" Score="1" Body="&lt;p&gt;Are you using one module bought from Adafruit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the connection is correct between the sensor and Arduino, then make sure that the script doesn’t get stuck when the Wire is begun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing that you need to make sure, is to have the correct address, it depends from board and each one can have a different one or a selector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/lsm303-accelerometer-slash-compass-breakout/assembly-and-wiring&quot; rel=&quot;nofollow&quot;&gt;This can be helpful to figure out what the wiring is&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13940" LastEditorUserId="10794" LastEditDate="2015-10-11T03:52:07.697" LastActivityDate="2015-10-11T03:52:07.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16719" PostTypeId="2" ParentId="1471" CreationDate="2015-10-11T01:32:28.507" Score="1" Body="&lt;p&gt;You also may want to try the &quot;&lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt;&quot; library.  That way you can use almost any pins you want for serial comms.  As a matter of fact, you can have a couple of serial ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please do read up on the SoftwareSerial library though.  It does have some restrictions.&lt;/p&gt;&#xA;" OwnerUserId="13941" LastEditorUserId="19157" LastEditDate="2016-05-08T20:17:31.083" LastActivityDate="2016-05-08T20:17:31.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16721" PostTypeId="1" CreationDate="2015-10-11T02:18:53.593" Score="-1" ViewCount="91" Body="&lt;p&gt;I have an indescribable bug where read and write commands give back an array of numbers that are the digits of the input number except +48. Kinda hard to explain. Basically if I type 0 into this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void setup(){&#xA;      Serial.begin(9600); //Begin serial connection&#xA;    }&#xA;    void loop(){&#xA;      if(Serial.available()){ //If serial available...&#xA;        double ser = Serial.read(); //Read serial value and write it to 'ser'&#xA;        Serial.println(ser); //Print 'ser'&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I receive 48. 1 means 49, 2 means 50, 3 means 51... And then two digit numbers, which are the same except for each digit. 10 returns 49 48, 33 returns 51 51, 22 returns 50 50.&lt;/p&gt;&#xA;" OwnerUserId="13942" LastEditorUserId="10794" LastEditDate="2015-10-11T03:40:57.987" LastActivityDate="2016-02-08T10:34:04.020" Title="Sending Something to Serial and Writing it Returns a Correlated but Strange Number" Tags="|serial|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16722" PostTypeId="1" CreationDate="2015-10-11T02:21:32.377" Score="3" ViewCount="4365" Body="&lt;p&gt;I'm planning to monitor voltage of a 12V battery with an Arduino's ADC pin connected via a voltage divider. Since I don't want the circuit itself to drain the battery when not in use, I want to use a transistor to &quot;enable&quot; it via an Arduino DIO pin like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TMzN2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TMzN2.png&quot; alt=&quot;voltage divider&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a safe circuit to use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set EN low to disable the divider, will that risk putting 12V directly on the ADC pin and burn it out? I've found &lt;a href=&quot;http://www.microbuilder.eu/Tutorials/Fundamentals/MeasuringBatteryVoltage.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;alternative designs&lt;/a&gt;, but they seem overly complicated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The battery is a Lipo which is also powering the Arduino through a step-down DC converter.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="4478" LastEditDate="2015-10-11T15:04:23.033" LastActivityDate="2019-08-24T12:32:18.727" Title="Safely enabling voltage divider on a 12V battery" Tags="|analogread|voltage-level|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16723" PostTypeId="2" ParentId="16721" CreationDate="2015-10-11T03:41:38.147" Score="1" Body="&lt;p&gt;Serial.read returns a character. The &lt;strong&gt;character&lt;/strong&gt; '0' is 48 in decimal. So this is doing what you expect (or what I expect, anyway). I suggest not using &lt;code&gt;double&lt;/code&gt; there, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char ser = Serial.read(); //Read serial value and write it to 'ser'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-11T03:41:38.147" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16724" PostTypeId="1" CreationDate="2015-10-11T01:36:32.573" Score="2" ViewCount="3325" Body="&lt;p&gt;I am trying to output a 25&amp;nbsp;kHz software PWM on at least four pins simultaneously with variable duty cycles on each pin individualy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got all the actual PWM outputs via internal timers 2x8 1x16 with variable duty cycles and am looking for a way to output a 25&amp;nbsp;kHz PWM on the four pins (any pins) via an external timer if necessary. How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="13944" OwnerDisplayName="Trevor Nichols" LastEditorUserId="510" LastEditDate="2015-10-11T10:26:24.493" LastActivityDate="2017-10-14T07:44:24.043" Title="Get 25 kHz PWM on a 16 MHz Arduino" Tags="|pwm|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16725" PostTypeId="2" ParentId="16724" CreationDate="2015-10-11T01:59:40.937" Score="5" Body="&lt;p&gt;At 16 MHz, your instruction cycle is 62.5 ns, and your PWM period is 40 \$\mu\$s. This is only 640 instruction cycles per PWM period. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have any hope of doing this, the first thing you need to do is forget using anything Arduino other than the hardware. Download the datasheet for the AVR in question and start getting familiar with it. Your best bet is to use 8 bit timers to reduce the overhead of loading them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My approach would be to use every 8 bit timer available, and divide the outputs up among the timers. Load the shorest pulse width output in the 8 bit tiemrs. Keep a 16 bit timer available to use for the PWM period. Start all the timers at once. On the first 8-bit timer interrupts, toggle the output, and reload the timers with the time between the next shorest pulse width. Rinse and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could run one timer, and write a little scheduler that puts the outputs in order from shortest to longest pulse width, constantly poll the timer, and toggle the bits as needed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these options have a ton of software overhead, and the pulse widths will all be semi-deterministic. Neither would be good for any application where the micro has to do anything else in a timely fashion, such as communication or drive a LCD.&lt;/p&gt;&#xA;" OwnerDisplayName="Matt Young" LastActivityDate="2015-10-11T01:59:40.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16726" PostTypeId="2" ParentId="16724" CreationDate="2015-10-11T02:17:55.443" Score="1" Body="&lt;p&gt;Look into using one of the AVR chips that have more PWM outputs. For example, &lt;a href=&quot;http://www.atmel.com/devices/AT90PWM81.aspx&quot; rel=&quot;nofollow&quot;&gt;AT90PWM81&lt;/a&gt; which includes six hardware PWM outputs.&lt;/p&gt;&#xA;" OwnerUserId="11568" OwnerDisplayName="Jasen" LastEditorUserId="510" LastEditDate="2015-10-11T11:02:01.373" LastActivityDate="2015-10-11T11:02:01.373" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16728" PostTypeId="2" ParentId="16722" CreationDate="2015-10-11T09:09:59.750" Score="4" Body="&lt;p&gt;I'd use some very large resistors (e.g. 1 and 2 Mega Ohm), and add a small capacitor to the center, to stabilize the value during sampling. Using 1 and 2 MOhm would result in 10uA of current loss, which is probably negligible in your cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GQIIi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GQIIi.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2019-08-24T12:32:18.727" LastActivityDate="2019-08-24T12:32:18.727" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="16729" PostTypeId="2" ParentId="16722" CreationDate="2015-10-11T09:54:22.480" Score="5" Body="&lt;p&gt;I use a similar system on a product I recently worked on to monitor the battery voltage - and of course I didn't want it on all the time to drain the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick, though, is to do the exact opposite of what you are doing.  Instead of isolating the ground (&lt;em&gt;which leaves the battery then directly connected to the Arduino&lt;/em&gt;) you need to completely isolate the battery from the divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be accomplished by using a P-channel MOSFET which you can then drive with an N-channel MOSFET:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Ktsx.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Ktsx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The theory is, when the Arduino DOUT is either LOW or not connected (&lt;em&gt;pulled low by 10K resistor&lt;/em&gt;) the N channel MOSFET is turned off.  That means the gate of the P channel MOSFET is being pulled up to the battery voltage by the other 10K resistor, so the P channel MOSFET is off, which isolates the whole divider from the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When DOUT goes HIGH it turns on the N channel MOSFET which then pulls the gate of the P channel MOSFET down to ground which then turns it on, thus connecting the divider to the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the P channel is OFF the only circuit connected to the ADC is the connection between the ADC input and ground through a 10K resistor, so everything is happy and safe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should not use resistors greater than around 10K in size on the input to the ADC because the ADC itself has a resistance (the &lt;em&gt;impedance&lt;/em&gt;) which is placed in parallel to the lower resistor of the divider.  If the divider's resistors are too large that impedance will affect the accuracy of your readings because the total resistance of the lower resistor will be skewed slightly.  Yes, it's possible to compensate in software, but as long as you keep to a limit of 10K or so for the resistors you won't need to worry about doing such things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it is important to use a P-channel MOSFET for this, not a PNP transistor.  A P-channel MOSFET, when on, looks like a very small resistor.  A PNP transistor is seen as a fixed voltage drop skewing your results.  The N-channel MOSFET can be replaced by an NPN transistor if you wish, it makes no real difference. I nearly always use MOSFETS these days instead of BJTs though as a matter of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an aside, the only other way of achieving this whilst maintaining the isolation of the ADC from the battery would be to replace the P channel MOSFET with a small relay (say a reed relay), but then you still have to build a relay driving circuit which is just about as complex as this one.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-11T10:03:27.250" LastActivityDate="2015-10-11T10:03:27.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16730" PostTypeId="1" AcceptedAnswerId="17222" CreationDate="2015-10-11T12:55:23.063" Score="1" ViewCount="694" Body="&lt;p&gt;So just bought an arduino Uno and I've been playing around with it. I want to connect one of the input pins to one of the PWM outputs and measure the output from there by sending it to my computer through &lt;code&gt;Serial&lt;/code&gt; and then plot it in python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if this is a basic question.&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="13951" LastActivityDate="2015-10-27T12:35:46.580" Title="Can I connect an output pin to an input pin to measure it's voltage on a single board?" Tags="|pins|pwm|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16731" PostTypeId="1" CreationDate="2015-10-11T11:26:23.083" Score="2" ViewCount="3623" Body="&lt;p&gt;I want to change my Arduino Leonardo's name that Windows shows me when it's plugged in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that i have to change its firmware to change the name but I cant find firmware for it on the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino Mega, I have changed it with a downloaded firmware via flip, but I can't change the file because it's a .hex.&lt;/p&gt;&#xA;" OwnerDisplayName="cracken" LastActivityDate="2015-10-11T16:03:39.737" Title="How to change the usb name of Atmel 32u4?" Tags="|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16732" PostTypeId="1" CreationDate="2015-10-11T14:13:09.690" Score="16" ViewCount="72091" Body="&lt;p&gt;I'd like to use an ATMega328P for my project, I hope to do it without the Arduino board.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know with the Arduino IDE and an Arduino board I can program the microcontroller. However, would it be possible once I've programmed and debugged the program with Arduino IDE + Arduino board, to take away the microcontroller from the Arduino board and to use the ATMega328P separately, without the board? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If yes, what additional configurations I should do the ATMega328P to work correctly on the breadboard?  &lt;/p&gt;&#xA;" OwnerUserId="13954" LastEditorUserId="19409" LastEditDate="2019-08-22T05:30:31.367" LastActivityDate="2019-11-07T02:53:29.557" Title="Program an ATMega328P and use it without Arduino board" Tags="|arduino-ide|atmega328|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16733" PostTypeId="2" ParentId="16732" CreationDate="2015-10-11T14:39:28.257" Score="2" Body="&lt;p&gt;Search for &lt;a href=&quot;https://duckduckgo.com/?q=build%20an%20arduino&quot; rel=&quot;nofollow&quot;&gt;&quot;Build an Arduino&quot;&lt;/a&gt; - you'll find tons of how-to articles about doing just that. You'd need to be able to solder connections on a printed-circuit board (and not even that if you wanted to use a solderless breadboard), but it's really straightforward. You can even build it first and program the MCU on the PCB using an FTDI cable. I use an Arduino board and a solderless breadboard to experiment with unfamiliar parts, but I usually go immediately to a hand-built board once I'm familiar with all of the components I'll be using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prototyping with the Arduino board lets you throw together a bunch of parts and get something working quickly, and if the Arduino is more capable than your final target - f/ex, a Mega 2650 - you can temporarily ignore the memory and I/O constraints of the smaller device.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-11T14:39:28.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16734" PostTypeId="1" CreationDate="2015-10-11T14:54:13.303" Score="0" ViewCount="156" Body="&lt;p&gt;im new to arduino and thinking to create a LED project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;im creating a LED project and i want to control 12 LED's. so i use two 7HC595 but problem i face is how can i only control 12 outputs ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and i want to create multiple blink patterns with 12 LED, please be kind enough to provide blink patterns that i can modify and create different partners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have found many shift-out programs but i do not understand how to limit it to 12 outputs and create multiple blink patterns. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks &lt;/p&gt;&#xA;" OwnerUserId="13922" LastActivityDate="2016-01-17T06:30:05.070" Title="two 7HC595 and only 12 outputs" Tags="|led|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16735" PostTypeId="2" ParentId="16732" CreationDate="2015-10-11T15:10:46.793" Score="7" Body="&lt;p&gt;You can remove an ATMEGA from an Arduino and use it in your own board, however when used on a typical Arduino board the chip will be fused for an external crystal as a clock source, rather than the (simpler but less accurate) internal clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot change the clock source over ISP unless the clock source the chip is currently expecting is operational, so if you want to change the clock selection you will want to do that before removing the chip from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can also provide a clock crystal and its two capacitors (or a substitute resonator which often has this built in) on your external board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically chips (even those pre-flashed with a bootloader as a convenience) are cheaper than boards, so it's unclear why you would want to move the same chip off the Arduino as opposed to using another.  You will want a USB-logical level serial adapter anyway, and once you have that you can do development on the bare chip on your board, even if you do initial testing on the Arduino.  In a pinch if you don't have the USB converter you can either pull the chip out of an Arduino board and run wires from its D1 and D0, or hold the on-board chip in reset to allow you to borrow those serial lines without interference.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-10-11T15:10:46.793" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16736" PostTypeId="2" ParentId="16731" CreationDate="2015-10-11T16:03:39.737" Score="2" Body="&lt;p&gt;The Arduino '32U4 bootloader, Caterina, can be found under &lt;code&gt;hardware/arduino/bootloaders/caterina&lt;/code&gt;. It requires &lt;a href=&quot;http://www.fourwalledcubicle.com/files/LUFA/Doc/140928/html/&quot; rel=&quot;nofollow&quot;&gt;LUFA&lt;/a&gt; in order to build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the technical part aside, note that you are not allowed to use the USB IDs assigned to Arduino LLC with products you intend to distribute under another name. You will need to acquire your own vendor ID from the &lt;a href=&quot;http://www.usb.org/&quot; rel=&quot;nofollow&quot;&gt;USB-IF&lt;/a&gt; if you want to do so.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-11T16:03:39.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16737" PostTypeId="1" CreationDate="2015-10-11T16:28:09.470" Score="1" ViewCount="267" Body="&lt;p&gt;I realize that this is a forum for Arduino but since the Teensy 3.2 is compatible with the Arduino IDE I thought it would be appropriate to ask the question here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, can I create an interface between the Teensy 3.2 and a DSP, more specifically the TMS320C5534-Fixed-Point Digital Signal Processor and how could I go about it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do do is capture an EEG and EoG (electrooculogram) signal, amplify it, filter the signal, use the DSP for ADC and signal processing and finally get this information from the DSP to the Teensy 3.2, which will then make a decision based on the signal obtained from the DSP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe this is a simple question but I couldn't find any answers online. I am pretty new to the world of microcontrollers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you guys!&lt;/p&gt;&#xA;" OwnerUserId="13957" LastEditorUserId="4628" LastEditDate="2015-12-02T18:24:38.297" LastActivityDate="2016-05-30T22:44:05.593" Title="Is it possible to create an interface between Teensy 3.2 and a DSP?" Tags="|arduino-uno|programming|signal-processing|teensy|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16738" PostTypeId="1" CreationDate="2015-10-11T19:30:32.813" Score="1" ViewCount="155" Body="&lt;p&gt;I'm trying to make a snake game using the u8g lib. But for now, only the second body part of the snake follows the head, where I want the whole body to follow the snake's head and I don't understand why it doesn't work.&#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;U8glib.h&quot;&#xA;&#xA;U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);    // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8&#xA;&#xA;const int SNAKEMAXSIZE = 10;&#xA;&#xA;bool title = true;&#xA;bool gameRunning = false;&#xA;&#xA;enum direction {HAUT, BAS, GAUCHE, DROITE};&#xA;&#xA;int snakeDirection = GAUCHE;&#xA;&#xA;class snakeCell&#xA;{&#xA;  private:&#xA;  int x;&#xA;  int y;&#xA;&#xA;  public:&#xA;&#xA;  snakeCell(int x, int y)&#xA;  {&#xA;    this-&amp;gt;x = x;&#xA;    this-&amp;gt;y = y;&#xA;  }&#xA;&#xA;  snakeCell()&#xA;  {&#xA;    x = 42;&#xA;    y = 24;&#xA;  }&#xA;&#xA;  void setX(int x)&#xA;  {&#xA;    this-&amp;gt;x = x;&#xA;  }&#xA;&#xA;  void setY(int y)&#xA;  {&#xA;    this-&amp;gt;y = y;&#xA;  } &#xA;&#xA;  int getX()&#xA;  {&#xA;    return x;&#xA;  }&#xA;&#xA;  int getY()&#xA;  {&#xA;    return y;&#xA;  }&#xA;&#xA;&#xA;&#xA;  void draw()&#xA;  {&#xA;    u8g.drawBox(x, y, 5,5);&#xA;  }&#xA;};&#xA;&#xA;class Pomme&#xA;{&#xA;  public:&#xA;  int x;&#xA;  int y;&#xA;&#xA;  Pomme(int x, int y)&#xA;  {&#xA;    this-&amp;gt;x = x;&#xA;    this-&amp;gt;y = y;&#xA;  }&#xA;&#xA;  Pomme()&#xA;  {&#xA;    x = 42;&#xA;    y = 24;&#xA;  }&#xA;&#xA;  void randomSpawn()&#xA;  {&#xA;    x = random(48);&#xA;    y = random(84);&#xA;  }&#xA;&#xA;  void draw()&#xA;  {&#xA;    u8g.drawCircle(x, y, 5);&#xA;  }&#xA;};&#xA;&#xA;snakeCell snake[10] = {snakeCell(), snakeCell(47,24), snakeCell(52,24), snakeCell(57,24), snakeCell(62,24), snakeCell(62,29), snakeCell(62,34), snakeCell(57,34), snakeCell(52,34), snakeCell(52,39)};&#xA;&#xA;Pomme pomme = Pomme();&#xA;&#xA;void draw(void) {&#xA;  // graphic commands to redraw the complete screen should be placed here  &#xA;  u8g.setFont(u8g_font_6x13);&#xA;  //u8g.setFont(u8g_font_osb21);&#xA;  u8g.drawRFrame(0, 0, 84, 48, 0);   //Screen frame&#xA;  printTitle();&#xA;  game();&#xA;}&#xA;&#xA;void setup(void) {&#xA;  // flip screen, if required&#xA;   //u8g.setRot180();&#xA;&#xA;  // set SPI backup if required&#xA;  //u8g.setHardwareBackup(u8g_backup_avr_spi);&#xA;&#xA;  // assign default color value&#xA;&#xA;  randomSeed(analogRead(0));&#xA;&#xA;  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {&#xA;    u8g.setColorIndex(255);     // white&#xA;  }&#xA;  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {&#xA;    u8g.setColorIndex(3);         // max intensity&#xA;  }&#xA;  else if ( u8g.getMode() == U8G_MODE_BW ) {&#xA;    u8g.setColorIndex(1);         // pixel on&#xA;  }&#xA;  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {&#xA;    u8g.setHiColorByRGB(255,255,255);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop(void) {&#xA;  // picture loop&#xA;  u8g.firstPage(); &#xA;  do {&#xA;    draw();&#xA;  } while( u8g.nextPage() );&#xA;&#xA;  // rebuild the picture after some delay&#xA;  delay(50);&#xA;}&#xA;&#xA;void printTitle()&#xA;{&#xA;  if(title == true)&#xA;  {&#xA;    u8g.setFont(u8g_font_6x13);&#xA;    //u8g.drawStr( 26, 30, &quot;SNAKE&quot;);&#xA;    delay(2000);&#xA;    title = false;&#xA;    gameRunning = true;&#xA;  }&#xA;}&#xA;&#xA;void moveSnake()&#xA;{ &#xA;  //move head accordingly to movement&#xA;  if(snakeDirection == GAUCHE)&#xA;  {&#xA;    snake[0].setX(snake[0].getX() - 1);&#xA;  }&#xA;  else if(snakeDirection == DROITE)&#xA;  {&#xA;    snake[0].setX(snake[0].getX() + 1);&#xA;  }&#xA;  else if(snakeDirection == BAS)&#xA;  {&#xA;    snake[0].setY(snake[0].getY() + 1);&#xA;  }&#xA;  else if(snakeDirection == HAUT)&#xA;  {&#xA;    snake[0].setY(snake[0].getY() - 1);&#xA;  }&#xA;&#xA;  //tail follow head&#xA;  for(int i = 9; i &amp;gt; 0; i--)&#xA;  {&#xA;    snake[i] = snakeCell(snake[i-1].getX(),snake[i-1].getY());&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&#xA;void restart()&#xA;{&#xA;  //snakeCell snake[10] = {snakeCell(), snakeCell(47,24), snakeCell(52,24), snakeCell(57,24), snakeCell(62,24), snakeCell(62,29), snakeCell(62,34), snakeCell(57,34), snakeCell(52,34), snakeCell(47,34)};&#xA;}&#xA;&#xA;void drawSnake()&#xA;{&#xA;  for(int i = 0; i &amp;lt; SNAKEMAXSIZE; i++)&#xA;  {&#xA;    snake[i].draw();&#xA;  }&#xA;}&#xA;&#xA;void spawnApple()&#xA;{&#xA;  pomme = Pomme();&#xA;  pomme.randomSpawn();&#xA;}&#xA;&#xA;void checkCollision()&#xA;{&#xA;  // detect if apple eaten&#xA;  for(int i = 0; i &amp;lt; SNAKEMAXSIZE; i++)&#xA;  {&#xA;    if((snake[i].getX() == pomme.x) &amp;amp;&amp;amp; (snake[i].getY() == pomme.y))&#xA;    {&#xA;      pomme.randomSpawn();&#xA;    }&#xA;  }&#xA;  // detect if snake hit wall&#xA;  for(int i = 0; i &amp;lt; SNAKEMAXSIZE; i++)&#xA;  {&#xA;    if((snake[i].getX() &amp;gt;= 84) || (snake[i].getX() &amp;lt;= 0) || (snake[i].getY() &amp;gt;= 48) || (snake[i].getY() &amp;lt;= 0))&#xA;    {&#xA;      //gameOver();&#xA;      restart();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void gameOver()&#xA;{&#xA;  gameRunning = false;&#xA;  //u8g.setFont(u8g_font_6x13);&#xA;  //u8g.drawStr( 14, 30, &quot;GAME OVER&quot;);&#xA;  //delay(1000);&#xA;  restart();&#xA;  gameRunning = true;&#xA;}&#xA;&#xA;void game()&#xA;{&#xA;  if(gameRunning == true)&#xA;  {&#xA;    checkCollision();&#xA;    moveSnake();&#xA;    drawSnake();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="13963" LastActivityDate="2015-10-11T21:10:09.217" Title="Arduino snake on 5110 screen - some help needed" Tags="|arduino-uno|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16739" PostTypeId="2" ParentId="16738" CreationDate="2015-10-11T20:49:52.347" Score="1" Body="&lt;p&gt;There might be a problem with going through your snake array from the back.&#xA;I'm not sure if you're filling it from front or back, but you should read it from there aswell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, every time you re-draw your snake, you're creating a new snakeCell?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//tail follow head&#xA;  for(int i = 9; i &amp;gt; 0; i--)&#xA;  {&#xA;    snake[i] = snakeCell(snake[i-1].getX(),snake[i-1].getY());&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should differentiate between a snakeCell that is active or not. And just re-position and draw it when it's active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to check if you're not placing them ontop of eachother. You should put each piece of the tail in the previous position of the preceding part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also: You shouldn't really be mixing up French and English naming in your code.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-10-11T21:10:09.217" LastActivityDate="2015-10-11T21:10:09.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16740" PostTypeId="1" CreationDate="2015-10-11T21:16:27.290" Score="1" ViewCount="3440" Body="&lt;p&gt;I am building a quad-copter, the problem is of stability and for better stability lesser sampling time is required. For lesser sampling time I need to have faster loop() function. But the Pulsein() command takes very large time which in turn expands the sampling time. Is there any method to read the rc channels in background and read them from an integer.&lt;/p&gt;&#xA;" OwnerUserId="13968" LastActivityDate="2015-11-30T20:14:19.227" Title="How to read RC receiver channels without using pulsein() command with arduino" Tags="|arduino-uno|robotics|pid|pulsein|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16741" PostTypeId="2" ParentId="16740" CreationDate="2015-10-11T22:51:42.160" Score="1" Body="&lt;p&gt;The keyword you are looking for here is &lt;em&gt;interrupt&lt;/em&gt;.  What is a pulse but a signal that goes from low to high followed by going from high to low, with some period of time between them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of sitting there waiting for the pulse to arrive then measuring how long it is, which is essentially what &lt;code&gt;pulseIn()&lt;/code&gt; does, you need to attach the signal to an interrupt pin.  Then you write an interrupt routine that triggers when the signal changes from one level to another which looks to see what the level actually is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the signal has risen from low to high then you record the time it happened.  If the signal has fallen from high to low then you look what the time is, and subtract the time you remembered from when the signal rose.  That difference is then the width of the pulse, which you can store in an integer to read in your main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a number of signals you want to monitor you might want to look into using the &lt;em&gt;pin change interrupt&lt;/em&gt; which allows you to use any pin as an interrupt source.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-11T22:51:42.160" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16742" PostTypeId="1" CreationDate="2015-10-12T00:13:41.770" Score="0" ViewCount="884" Body="&lt;p&gt;I'm trying to get a simple TX/RX pair to work. I've got identical Nanos and I'm using the example from:&#xA;&lt;a href=&quot;http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&quot; rel=&quot;nofollow&quot;&gt;http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the advice about adding a cap across the Vcc GND on the nrf board, and added a 10uF electrolytic to both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still haven't received a packet yet, and I wondering how to eliminate the power supply as a cause. I scoped the power pins, and even without a cap I got about 250mV of ripple. With the cap it goes down to about 100mV. Is this within tolerance? What kind of caps does anyone else use, and has anyone scoped the result to see where the threshold lies?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside form that, are there any other clever ways to debug this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 20160122. I finally tested using those cheap piggyback 3.3v regulator boards that plug straight into the nrf board. Works perfectly, not one lost packet over 5000 packets sent. Interestingly, the RX side appears to be the fussy one. Thanks to everyones' suggestions. For a total combined cost of about 4$ per node, I have a great wireless TX/RX solution.  &lt;/p&gt;&#xA;" OwnerUserId="11984" LastEditorUserId="11984" LastEditDate="2016-01-21T22:22:06.693" LastActivityDate="2017-09-10T19:45:46.443" Title="NRF24L01+ how much supply ripple is acceptable?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16743" PostTypeId="2" ParentId="4751" CreationDate="2015-10-12T00:34:29.393" Score="6" Body="&lt;h1&gt;Generated from IDE&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Because this is a generic error, I'll answer it. I was getting this on STDERR when using the IDE:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is because in the IDE I was using &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sketch &amp;rarr; &lt;strong&gt;Upload Using Programmer [&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + U]&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I should have been using&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sketch &amp;rarr; &lt;strong&gt;Upload [&lt;kbd&gt;Ctrl&lt;/kbd&gt; + U]&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="13972" LastEditDate="2015-10-12T00:44:16.480" LastActivityDate="2015-10-12T00:44:16.480" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16744" PostTypeId="1" CreationDate="2015-10-12T00:47:06.717" Score="2" ViewCount="206" Body="&lt;p&gt;Does Fritzing support the standard 0.1&quot; break-away header?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I search for &quot;header&quot; in its parts database, I see several examples, and some even seem to reference 0.1 headers, but I can't actually seem to select the physical part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if I select the &quot;Header 3&quot; part, the description specifically refers to 0.1 break away headers, but the &quot;package&quot; field references a completely different part, causing it to render incorrectly. If I click that dropdown to try and select a different package, there are dozens listed, but none look like a 0.1 header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AOvhT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AOvhT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-10-12T00:47:06.717" Title="How to select a 0.1&quot; header in Fritzing" Tags="|system-design|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16748" PostTypeId="1" CreationDate="2015-10-12T03:11:01.697" Score="1" ViewCount="649" Body="&lt;p&gt;I am trying to make blinkers and hazards lights for a car.  I can get&#xA;the left and right blinkers to work. I cannot figure out how to get&#xA;the lights to blink simultaneously like hazard lights would. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I think I want is that when both inputs are HIGH then Both LEDs will&#xA;blink together at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I left the garbage and comments in the code so you can see what I have&#xA;tried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Blinkers and Hazard Lights&#xA;&#xA; Simulates a vehicles blinkers and Hazard Lights&#xA; left button connected to pin 2 using a pushdown resister&#xA; right button connected to pin 3 using a pushdown resister&#xA; left LED connected to pin 9&#xA; right LED connected to pin 10&#xA; Hazard LED is Pin 13 At one point I was trying to make pin 13 represent the hazard lights but that is not what I want to do.&#xA;&#xA; When left button is pushed Left LED will Blink&#xA; When Right Button Is pushed Right LED will Blink&#xA;&#xA; If this worked the way I wanted it to. when both buttons where HIGH both LED 9 &amp;amp; 10 would blink simultaneously.&#xA;&#xA;&#xA; created 2015&#xA; by thomsl41@gmail.com&#xA;&#xA;*/&#xA;&#xA;// constants won't change. They're used here to &#xA;// set pin numbers:&#xA;const int buttonPinLeft = 2;     // the number of the pushbutton pin&#xA;const int buttonPinRight = 3;&#xA;const int buttonPinHazard = 2 &amp;amp;&amp;amp; 3;&#xA;const int ledPinLeft = 9;      // the number of the LED pin&#xA;const int ledPinRight = 10;&#xA;const int ledPinHazard = 13;&#xA;&#xA;// variables will change:&#xA;int buttonStateLeft = 0;         // variable for reading the pushbutton status&#xA;int buttonStateRight = 0;&#xA;int buttonStateHazard = 0;&#xA;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPinLeft, OUTPUT);&#xA;   pinMode(ledPinRight, OUTPUT);&#xA;   pinMode(ledPinHazard, OUTPUT);&#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPinLeft, INPUT);&#xA;  pinMode(buttonPinRight, INPUT);&#xA;  pinMode(buttonPinHazard, INPUT);  &#xA;}&#xA;&#xA;void loop(){&#xA;  // read the state of the pushbutton value:&#xA;  buttonStateLeft = digitalRead(buttonPinLeft);&#xA;  buttonStateRight = digitalRead(buttonPinRight);&#xA;  buttonStateHazard = digitalRead(buttonPinHazard);&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (buttonStateLeft == HIGH) {     &#xA;    // turn LED on:    &#xA;  digitalWrite(ledPinLeft, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(500);              // wait for a second&#xA;  digitalWrite(ledPinLeft, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(500);              // wait for a second&#xA;  } &#xA; else {&#xA;    // turn LED off:&#xA;    digitalWrite(ledPinLeft, LOW); &#xA;  }&#xA;&#xA;if (buttonStateRight == HIGH) {     &#xA;    // turn LED on:    &#xA;  digitalWrite(ledPinRight, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(500);              // wait for a second&#xA;  digitalWrite(ledPinRight, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(500);              // wait for a second&#xA;&#xA;} &#xA;  else {&#xA;    // turn LED off:&#xA;    digitalWrite(ledPinRight, LOW); &#xA;  }&#xA;}&#xA;&#xA;/*if (buttonStateHazard == HIGH) {     &#xA;    // turn LED on:    &#xA;  digitalWrite(ledPinLeft, LOW);&#xA;  digitalWrite(ledPinRight, LOW);&#xA;  digitalWrite(ledPinHazard, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(2000);              // wait for a second&#xA;  digitalWrite(ledPinHazard, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(2000);              // wait for a second&#xA;  //} &#xA; //else {&#xA;    // turn LED off:&#xA;   // digitalWrite(ledPinHazard, LOW); &#xA; }&#xA;&#xA;}&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13976" LastEditorUserId="13979" LastEditDate="2015-10-12T07:27:14.650" LastActivityDate="2016-02-09T09:01:22.447" Title="Help making LEDs blink like blinkers in a car" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16749" PostTypeId="1" CreationDate="2015-10-12T03:30:48.767" Score="2" ViewCount="42" Body="&lt;p&gt;I have an Arduino BT and I can't connect it to any device I have. I've tried in 3 different situations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Win7 - If I choose 'Connect without a PIN code', the device seems properly detected but it doesn't appears in Device Manager. In the case of the connection with the PIN code, it throws a timeout error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Win8 - Don't even ask me for the PIN code. A message 'This isn't working. Try again and verify if the device is still visible' appears. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Android 5.0 - When I try to pair and write the PIN code, I get a message 'Invalid PIN or password'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PIN is 12345, by Arduino.cc page. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another different thing is that in the documentation, the board has the Blink code by default. But the orange light on the board doesn't blink, and don't turn green either. I didn't find anything about the color of the LED in this board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me? &lt;/p&gt;&#xA;" OwnerUserId="13977" LastEditorUserId="13977" LastEditDate="2015-10-12T03:36:44.663" LastActivityDate="2015-10-12T03:36:44.663" Title="Problems with Arduino BT" Tags="|bluetooth|android|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16750" PostTypeId="1" CreationDate="2015-10-12T03:38:22.117" Score="2" ViewCount="14092" Body="&lt;p&gt;I'm having issues reading the actual double values from my Arduino &lt;code&gt;Serial.println()&lt;/code&gt; in my Java app. I've tried following usage examples found &lt;a href=&quot;https://github.com/Fazecast/jSerialComm/wiki/Event-Based-Reading-Usage-Example&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; but get what I guess is a hex value. The serial monitor within the Arduino program is displaying the correct values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code: I'm fairly new to this and would appreciate any comments regarding style/problems/inefficiencies within my code!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import com.fazecast.jSerialComm.*;&#xA;import java.util.*;&#xA;import java.io.*;&#xA;&#xA;public class PortRead {&#xA;  public static SerialPort userPort;&#xA;  static InputStream in;&#xA;&#xA;  public static void main(String args[]) {&#xA;    Scanner input = new Scanner(System.in);&#xA;    /*&#xA;     This returns an array of commport addresses, not useful for the client&#xA;     but useful for iterating through to get an actual list of com parts available&#xA;    */&#xA;    SerialPort ports[] = SerialPort.getCommPorts();&#xA;    int i = 1;&#xA;    //User port selection&#xA;    System.out.println(&quot;COM Ports available on machine&quot;);&#xA;    for (SerialPort port : ports) {&#xA;      //iterator to pass through port array&#xA;      System.out.println(i++ + &quot;: &quot; + port.getSystemPortName()); //print windows com ports&#xA;    }&#xA;    System.out.println(&quot;Please select COM PORT: 'COM#'&quot;);&#xA;    SerialPort userPort = SerialPort.getCommPort(input.nextLine());&#xA;&#xA;    //Initializing port&#xA;    userPort.openPort();&#xA;    if (userPort.isOpen()) {&#xA;    System.out.println(&quot;Port initialized!&quot;);&#xA;    //timeout not needed for event based reading&#xA;    //userPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 100, 0);&#xA;    } else {&#xA;    System.out.println(&quot;Port not available&quot;);&#xA;    return;&#xA;    }&#xA;&#xA;    userPort.addDataListener(new SerialPortDataListener() {&#xA;      @Override&#xA;      public int getListeningEvents() {&#xA;        return SerialPort.LISTENING_EVENT_DATA_AVAILABLE;&#xA;      }&#xA;      public void serialEvent(SerialPortEvent event) {&#xA;        if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE)&#xA;        return;&#xA;        byte[] newData = new byte[userPort.bytesAvailable()];&#xA;        int numRead = userPort.readBytes(newData, newData.length);&#xA;        System.out.println(&quot;Read &quot; + numRead + &quot; bytes.&quot;);&#xA;      }&#xA;    });&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13978" LastEditorUserId="4628" LastEditDate="2017-11-25T12:06:52.997" LastActivityDate="2017-11-25T12:06:52.997" Title="Reading Arduino serial stream in Java using jSerialComm" Tags="|serial|communication|" AnswerCount="1" CommentCount="3" ClosedDate="2017-11-27T20:24:26.283" ContentLicense="CC BY-SA 3.0" />
  <row Id="16751" PostTypeId="2" ParentId="16748" CreationDate="2015-10-12T05:10:29.930" Score="2" Body="&lt;p&gt;It looks like you need to do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((buttonStateRight == HIGH) &amp;amp;&amp;amp; (buttonStateLeft == HIGH)) {&#xA;    digitalWrite(ledPinRight, HIGH); &#xA;    digitalWrite(ledPinLeft, HIGH); &#xA;}&#xA;else if (buttonStateRight == HIGH) {&#xA;    digitalWrite(ledPinRight, HIGH); &#xA;}&#xA;else if (buttonStateLeft == HIGH) {&#xA;    digitalWrite(ledPinleft, HIGH); &#xA;}&#xA;//One delay for all&#xA;delay(500);&#xA;//Shut anything off that might be on after the delay&#xA;digitalWrite(ledPinRight, LOW); &#xA;digitalWrite(ledPinLeft, LOW); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code is really hard to read but it may mostly be because you need to insert four spaces at the beginning of each line of code to make it look right on this forum.&lt;/p&gt;&#xA;" OwnerUserId="13577" LastActivityDate="2015-10-12T05:10:29.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16752" PostTypeId="1" CreationDate="2015-10-12T06:11:35.287" Score="0" ViewCount="459" Body="&lt;p&gt;I'm trying to follow this tutorial here: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/ttl-serial-camera/using-the-camera&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/ttl-serial-camera/using-the-camera&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what my serial log is printing-- I've added a few commands for logging:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino version is: 10605&#xA;Chip Select is: 4&#xA;VC0706 Camera snapshot test&#xA;Card failed, or not present&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know my SD card works because when I use this program: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ReadWrite&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ReadWrite&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;it works just fine. What am I messing up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an arduino uno with wifi shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks! &lt;/p&gt;&#xA;" OwnerUserId="13592" LastActivityDate="2016-07-08T14:31:12.397" Title="VC0706 card failed, or not present" Tags="|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16753" PostTypeId="2" ParentId="16752" CreationDate="2015-10-12T06:23:28.783" Score="1" Body="&lt;p&gt;Comparing and contrasting with the SD card file -- I've found that if you comment out the following -- it works. Maybe this will help someone.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#if !defined(SOFTWARE_SPI)&#xA;//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;//  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega&#xA;//#else&#xA;//  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.&#xA;//#endif&#xA;//#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13592" LastActivityDate="2015-10-12T06:23:28.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16754" PostTypeId="2" ParentId="16732" CreationDate="2015-10-12T06:26:25.377" Score="9" Body="&lt;p&gt;Yes you can use &lt;strong&gt;&lt;code&gt;ATMega328P&lt;/code&gt;&lt;/strong&gt; without arduino board. I always use the IC without arduino. There are two ways of doing it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can use arduino board with the IC. Program the IC and then take it out and use it in your circuit. You will have to use &lt;strong&gt;&lt;code&gt;16MHZ Oscillator&lt;/code&gt;&lt;/strong&gt; with capacitors.&lt;/li&gt;&#xA;&lt;li&gt;If you don't have arduino board, you can use other programmers like &lt;strong&gt;&lt;code&gt;USBasp&lt;/code&gt;&lt;/strong&gt; to program your &lt;strong&gt;&lt;code&gt;Atmega328p&lt;/code&gt;&lt;/strong&gt;. In this case, do not use the direct upload button instead use the upload using programmer options from file menu. Do not forget to select board as &lt;strong&gt;&lt;code&gt;Arduino Pro or Pro Mini (5v, 16mhz) With ATmega328&lt;/code&gt;&lt;/strong&gt; and programmer as &lt;strong&gt;&lt;code&gt;USBasp&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Refer to &lt;a href=&quot;http://learn.qtechknow.com/Resources/Images/Tutorial1-8.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;Atmega328p Pin Mapping&lt;/strong&gt;&lt;/a&gt; and program your device accordingly. Enjoy!&lt;/p&gt;&#xA;" OwnerUserId="13197" LastActivityDate="2015-10-12T06:26:25.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16755" PostTypeId="1" CreationDate="2015-10-12T08:07:27.070" Score="0" ViewCount="707" Body="&lt;p&gt;The project I'm building requires multiple LED arrays. I'm going to wire these LEDs in parallel and then connect the arrays to individual pins on a shift register. In addition to the LEDs running in parallel I've connected resistors in series to each LED. I've been prototyping this on a couple of breadboards and I've noticed my parallel LEDs are much more dim then my LEDs I have in series. The resistors I'm using are around 550 OHMs and I'm powering the registers through my arduino uno. I think this may be part of the reason why they're so dim, as the arduino is only providing 5V. My question is, can I/should I have my registers connected to my arduino via the data connections and power them using an external source? Will this provide me with brighter LEDs? I don't want to dump the resistors, and I have around 21 arrays, if it matters, each with a varying number of LEDs&lt;/p&gt;&#xA;" OwnerUserId="13982" LastActivityDate="2015-10-12T10:41:59.527" Title="Driving multiple LED arrays with shift registers" Tags="|arduino-uno|power|led|resistor|shift-register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16756" PostTypeId="1" AcceptedAnswerId="16757" CreationDate="2015-10-12T08:14:11.080" Score="0" ViewCount="559" Body="&lt;p&gt;How come when I try to push a sketch to my Arduino I see this error on the console? The subsequent sketch does not work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've already added myself to the &lt;code&gt;dialout&lt;/code&gt; group,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sudo usermod -aG dialout $USER&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And, I did that after I confirmed the &lt;code&gt;dialout&lt;/code&gt; group owns the device (in my case &lt;code&gt;/dev/ttyACM0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls /dev/ttyACM0 -l&#xA;crw-rw---- 1 root dialout 166, 0 Oct 12 03:15 /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13972" LastActivityDate="2015-12-11T11:20:12.530" Title="How come the console prints error `avrdude: usbdev_open(): did not find any USB device &quot;usb&quot;`?" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16757" PostTypeId="2" ParentId="16756" CreationDate="2015-10-12T08:14:11.080" Score="0" Body="&lt;p&gt;This is because in the IDE I was using &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sketch &amp;rarr; &lt;strong&gt;Upload Using Programmer [&lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;Shift&lt;/kbd&gt; + U]&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, I should have been using&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sketch &amp;rarr; &lt;strong&gt;Upload [&lt;kbd&gt;Ctrl&lt;/kbd&gt; + U]&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13972" LastActivityDate="2015-10-12T08:14:11.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16759" PostTypeId="1" CreationDate="2015-10-12T08:33:01.863" Score="0" ViewCount="124" Body="&lt;p&gt;How can i use the attach interupt command and read rc channels in background. I am in doubt that attach interupt is only applied to 2 pins just and cant be used to get data from other pins. &lt;/p&gt;&#xA;" OwnerUserId="13968" LastActivityDate="2015-10-19T00:03:11.793" Title="How to read 6 RC remote channels using Attachinterupt for every channel" Tags="|arduino-uno|pwm|remote-control|" AnswerCount="1" CommentCount="5" ClosedDate="2015-10-30T17:19:35.517" ContentLicense="CC BY-SA 3.0" />
  <row Id="16760" PostTypeId="2" ParentId="16755" CreationDate="2015-10-12T09:01:44.287" Score="1" Body="&lt;p&gt;You haven't provided enough information to allow definitive answers to your questions, but you can apply &lt;a href=&quot;https://www.google.com/?gws_rd=ssl#q=led+resistor+calculator&quot; rel=&quot;nofollow&quot;&gt;LED resistor calculators&lt;/a&gt; and formulas to determine how much current is available to drive LEDs of various voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:  Suppose you hook up a red LED that drops about 1.6 V when it's on and operating at a current of 5 to 25 mA.  Suppose the LED is in series with a 550 Ω resistor, between a 5 V source and ground.  Current will be about (5-1.6)/550 A ≈ 0.0062 A = 6.2 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wished to limit current through Arduino Uno pins to safe-area amounts like 25 mA, you could drive at most 4 such LEDs per output pin.  If you decrease the resistor to get more current, the number of LEDs allowed per pin decreases too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because pin voltage drops slightly as the pin drives more current, LED brightnesses will also decrease slightly as more LEDs are attached to a pin, so putting different numbers of LEDs on different pins is likely to make light levels uneven.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Limits on output currents from 74HC595 shift register pins are similar to those on Arduino Uno pins; eg 35 mA absolute max ratings for the Qn pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than driving LEDs directly from Uno pins or '595 pins, you can use transistor driver stages.  Most transistor drivers will allow higher voltages (ie more LEDs in series, rather than in parallel) and higher currents.  Also consider using LED driver chips; many of them contain PWM circuitry for brightness control and registers for storing drive levels. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-12T09:01:44.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16765" PostTypeId="1" AcceptedAnswerId="16768" CreationDate="2015-10-12T15:16:24.813" Score="0" ViewCount="23016" Body="&lt;p&gt;I'm trying to save GPS coordinates to an EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example I feed it the latitude of 56060066 as the argument float x&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeFloat(unsigned int addr, float x)&#xA;{&#xA;  byte seriesOfBytes[3];&#xA;  *((float *)seriesOfBytes) = x;&#xA;  // Write all four bytes.&#xA;  for(int i = 0; i &amp;lt; 4; i++)&#xA;  {&#xA;    i2c_eeprom_write_byte(0x57, addr, myFloat.bytes[i]); // Write byte to EEPROM&#xA;    Serial.println(seriesOfBytes[i],BIN);  // Debug line&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm expecting to receive the following four bytes from the serial print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000011&#xA;01010111&#xA;01101000&#xA;10100010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead I'm getting these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00101000&#xA;11011010&#xA;01010101&#xA;01001100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried changing all sorts of parameters, but can't seem to find the problem. Can anyone spot the issue?&lt;/p&gt;&#xA;" OwnerUserId="276" LastActivityDate="2019-07-21T11:42:25.713" Title="How to cast float into four bytes?" Tags="|float|byte-order|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16766" PostTypeId="2" ParentId="14018" CreationDate="2015-10-12T15:17:41.517" Score="0" Body="&lt;p&gt;Check this &lt;a href=&quot;https://www.youtube.com/watch?v=0zuRukW7o0A&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=0zuRukW7o0A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reboot and press CMD+R immediately after reboot to enter in Recovery&#xA;Mode&lt;/li&gt;&#xA;&lt;li&gt;Open Terminal from Recovery mode&lt;/li&gt;&#xA;&lt;li&gt;Run the command csrutil enable --without kext&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;li&gt;Install driver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13984" LastActivityDate="2015-10-12T15:17:41.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16767" PostTypeId="2" ParentId="13998" CreationDate="2015-10-12T15:21:06.387" Score="1" Body="&lt;p&gt;Check this video &lt;a href=&quot;https://www.youtube.com/watch?v=0zuRukW7o0A&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=0zuRukW7o0A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reboot and press CMD+R immediately after reboot to enter in Recovery Mode&lt;/li&gt;&#xA;&lt;li&gt;Open Terminal from Recovery mode&lt;/li&gt;&#xA;&lt;li&gt;Run the command csrutil enable --without kext&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;li&gt;Install driver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13984" LastActivityDate="2015-10-12T15:21:06.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16768" PostTypeId="2" ParentId="16765" CreationDate="2015-10-12T15:53:16.440" Score="1" Body="&lt;p&gt;If you were to enable the display of warnings you would most likely see it complain about &lt;em&gt;&quot;dereferencing type-punned pointer will break strict-aliasing rules&quot;&lt;/em&gt; which is what you are doing here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you are trying to cast an array of four 8-bit values which can have any alignment they like (byte alignment) to a 32-bit float value which needs 4-byte alignment.  And the two just don't mesh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to work the other way around - cast a type that has smaller alignment requirements over the type that has larger requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of getting 4 bytes and trying to fill them as a float you get a float and read it as 4 bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte *b = (byte *)&amp;amp;floatVal;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can access b[0] to b[3] quite happily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to do it is with a union:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union {&#xA;    float fval;&#xA;    byte bval[4];&#xA;} floatAsBytes;&#xA;&#xA;floatAsBytes.fval = floatVal;&#xA;EEPROM.write(0, floatAsBytes.bval[0]);&#xA;EEPROM.write(1, floatAsBytes.bval[1]);&#xA;EEPROM.write(2, floatAsBytes.bval[2]);&#xA;EEPROM.write(3, floatAsBytes.bval[3]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, in your code, you only allocated enough room for 3 bytes, not 4...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T15:53:16.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16769" PostTypeId="1" AcceptedAnswerId="16771" CreationDate="2015-10-12T16:14:47.590" Score="1" ViewCount="159" Body="&lt;p&gt;I wrote my custom sketch, where I am printing some greeting text inside &lt;code&gt;setup()&lt;/code&gt; method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found, that each time I am restarting IDE, and opening serial monitor, a greeting text is printed there again, i.e. &lt;code&gt;setup()&lt;/code&gt; method running again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can this happen? I was thinking &lt;code&gt;setup()&lt;/code&gt; method run once, when Arduino is powered up by connecting to the USB socket?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible to restart it already connected, then how this can be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_BMP085.h&amp;gt;&#xA;&#xA;Adafruit_BMP085 bmp;&#xA;&#xA;String command;&#xA;&#xA;String awaitingMessage = &quot;Temperature and pressure sensor awaiting commands\r\nCommand \'help\' is for help&quot;;&#xA;&#xA;void awaiting() {&#xA;  Serial.println(awaitingMessage);  &#xA;}&#xA;&#xA;void help() {&#xA;  Serial.println(&quot;Temperature and pressure sensor commands:&quot;);&#xA;  Serial.println(&quot;temp\t- output temperature in degrees Celsius&quot;);&#xA;  Serial.println(&quot;press\t- output pressure in Pascals&quot;);&#xA;  Serial.println(&quot;wait\t- print awaiting message&quot;);&#xA;  Serial.println(&quot;help\t- output this text&quot;);  &#xA;}&#xA;&#xA;void temperature() {&#xA;  Serial.println(bmp.readTemperature());    &#xA;}&#xA;&#xA;void pressure() {&#xA;  Serial.println(bmp.readPressure());    &#xA;}&#xA;&#xA;void unknown() {&#xA;  if( command.length() &amp;gt; 0 ) {&#xA;      Serial.println(&quot;Unknown command was \'&quot; + command + &quot;'&quot;);  &#xA;    }&#xA;}&#xA;&#xA;void setup() {&#xA;   Serial.setTimeout(50000);&#xA;  Serial.begin(9600);&#xA;  if (!bmp.begin()) {&#xA;    Serial.println(&quot;Could not find a valid BMP085 sensor, check wiring!&quot;);&#xA;    while (1) {}&#xA;  }&#xA;  else {&#xA;    awaiting();&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  command = Serial.readStringUntil('\n');&#xA;&#xA;  if( command.startsWith(&quot;temp&quot;) ) {&#xA;    temperature();&#xA;  }&#xA;&#xA;  else if( command.startsWith(&quot;press&quot;) ) {&#xA;    pressure();&#xA;  }&#xA;&#xA;  else if( command.startsWith(&quot;wait&quot;) ) {&#xA;    awaiting();&#xA;  }&#xA;&#xA;  else if( command.startsWith(&quot;help&quot;) ) {&#xA;    help();&#xA;  }&#xA;&#xA;  else {&#xA;    unknown();&#xA;    //awaiting();   &#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Video is here: &lt;a href=&quot;https://youtu.be/-QBleGVxaus&quot; rel=&quot;nofollow&quot;&gt;https://youtu.be/-QBleGVxaus&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="6841" LastEditDate="2015-10-12T16:33:07.630" LastActivityDate="2015-10-12T16:37:15.460" Title="How can program/arduino restarted by IDE?" Tags="|arduino-uno|ubuntu|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16770" PostTypeId="2" ParentId="16769" CreationDate="2015-10-12T16:19:30.717" Score="-1" Body="&lt;p&gt;This means your Arduino or ATmega328 is restarting due to another issue. Usually the Arduino will reboot when there is too much amperage draw which is called a brown-out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can also mean there is a bug in your code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please also note as you mentioned &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I found, that each time I am restarting IDE, and opening serial monitor, a greeting text is printed there again, i.e. setup() method running again&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino will reboot when opening the serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2015-10-12T16:37:15.460" LastActivityDate="2015-10-12T16:37:15.460" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16771" PostTypeId="2" ParentId="16769" CreationDate="2015-10-12T16:30:13.247" Score="4" Body="&lt;p&gt;When you open the serial monitor (or even just go to the serial port menu) the serial port is opened. When the serial port is opened the DTR line is asserted.  This is the method that the Arduino uses to reset so that you can access the bootloader and upload a new sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time you open the serial port - through whatever means you choose - you reset the board, whether you like it or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of &quot;fixes&quot; for this - the simplest is to add a large (say 10µF) capacitor between the RESET and GND pins of the Arduino to filter out the reset pulse that would otherwise reboot the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also ways of disabling the reset within Windows, but that requires you to write your own software to interface with the board instead of using the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some boards also come with a method of completely detaching the reset signal from the USB interface, but modifying the board itself isn't for beginners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just remember that once you have disabled reset through whatever means you will have to re-enable it (resolder the track you cut, remove the capacitor, whatever) before you can upload a new sketch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T16:30:13.247" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16772" PostTypeId="1" AcceptedAnswerId="16773" CreationDate="2015-10-12T16:44:27.427" Score="2" ViewCount="3266" Body="&lt;p&gt;So recently I started making a sonar out of ultrasonic HC-SR04 sensor and servo motor. The idea was to slowly rotate servo 180 degrees while measuring distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Soon after I noticed that regular pulseIn() command could wait 20ms while doing nothing. So I started learning interrupts. I came up with a code which sends TRIG signal and records sending time with micros() function. When an interrupt occurs on ECHO pin, we subtract current time with TRIG time and get time of round trip of the sound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code works as intended without servos connected, but it behaves interestingly ! I always get distance which is 8 cm bigger than actual distance. So I had to subtract 8 cm every time ! Also I noticed that max reliable range decreased , using pulseIn() I could measure distance of 400cm, and with mine code it starts to show weird numbers after 150cm...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So i thought that 150cm is enough for me, and tried to run the code with servos attached. everything ran as intended, until the servos started to move. Now I was getting distance along with pretty much random numbers, periodically positive and negative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could just use one the fancy libraries out there, but I am curious what am I doing wrong, why i need to subtract 8cm each time , why my reliable range decreased so much, and most importantly why am I getting weird values while servos are on ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;CODE :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define ECHO 2&#xA;#define TRIG 7&#xA;&#xA; Servo servo;&#xA; int distance;&#xA; volatile long echoTime = 0;&#xA; long trigTime = 0,sendTime = 0,timeServo = 0;&#xA; bool scanning = false;&#xA; byte servoDir = -1,servoAngle = 0;&#xA;&#xA;&#xA;void setup() &#xA;{ &#xA;  servo.attach(12);&#xA;  Serial.begin(115200);&#xA;  pinMode(ECHO,INPUT);&#xA;  pinMode(TRIG,OUTPUT);&#xA;  attachInterrupt(digitalPinToInterrupt(ECHO), echo_interupt, FALLING);&#xA;&#xA;} &#xA;void loop() &#xA;{&#xA;  // SERVO&#xA;&#xA;   if((millis() - timeServo &amp;gt; 10)){&#xA;     if(servoAngle &amp;lt;= 0 || servoAngle &amp;gt;= 180)servoDir = -servoDir;&#xA;     servoAngle += servoDir;&#xA;     servo.write(servoAngle);&#xA;     timeServo = millis();&#xA;   }&#xA;&#xA;&#xA;  // GETTING RESULTS&#xA;  if(echoTime &amp;gt; 0){&#xA;    distance = echoTime - trigTime;&#xA;    distance /= 58;&#xA;    echoTime = 0;&#xA;    trigTime = 0;&#xA;    Serial.println(distance - 8);&#xA;  }&#xA;  // SENDING PULSE&#xA;  if(millis() - sendTime &amp;gt; 20){&#xA;  digitalWrite(TRIG,LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(TRIG,HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(TRIG,LOW);&#xA;  trigTime = micros();&#xA;  sendTime = millis();&#xA;  }&#xA;}&#xA;&#xA; // INTERUPT&#xA;void echo_interupt(){&#xA;  echoTime = micros();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13985" LastEditorUserId="10794" LastEditDate="2015-10-12T19:54:43.927" LastActivityDate="2017-04-24T17:30:04.833" Title="Servos and ultrasonic at the same time" Tags="|serial|sensors|c++|interrupt|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16773" PostTypeId="2" ParentId="16772" CreationDate="2015-10-12T17:02:20.847" Score="1" Body="&lt;p&gt;8cm is 233µs of sound travel time.  There and back again would be 466µs.  466µs, at 16MHz, is around 7400 instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When an interrupt is triggered you don't get an instant response.  First the built in interrupt function is called. That then looks to see if you have registered an interrupt function.  It then calls that interrupt function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that takes time, and when you're working with microseconds it makes a big difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then you have to go and get the current micros() value, which again takes time to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it all adds up to a delay.  Not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For greater accuracy you should investigate using &lt;em&gt;input capture&lt;/em&gt; which will start a timer running when you send the trigger and the timer will automatically stop the nanosecond the echo is received.  From that you can calculate a much more precise distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why you are getting strange results with the servos on?  Most likely because you are moving the receiving head while the pulse is being received.  I made a similar system while playing once and found that the best results were achieved by moving the head to the desired position, waiting a moment for any vibration to settle, do the ping and get the result, then move the head to the next position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and by the way, the HC-SR04 is (from memory) only really rated for up to 2m - I have never achieved anything more than around 1.8m with any accuracy.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T17:02:20.847" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="16774" PostTypeId="1" AcceptedAnswerId="16778" CreationDate="2015-10-12T17:41:39.700" Score="1" ViewCount="477" Body="&lt;p&gt;{assume arming is done}&#xA;Can i connect the brushless ESC to any digital pin and give writemicroseconds() to it? Will this work. because i have connected my 4 ESC's to &quot;~&quot; pins. so i thinks that other will not work.&lt;/p&gt;&#xA;" OwnerUserId="13968" LastActivityDate="2015-10-12T19:33:07.223" Title="Can i run brushless ESC from any digital pin of arduino" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16776" PostTypeId="1" CreationDate="2015-10-12T19:07:53.063" Score="1" ViewCount="6809" Body="&lt;p&gt;I wrote Arduino sketch and it works. It waits for a command and answers text on response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nz3sh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nz3sh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simultaneously, I can't get any response with command line tools.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I have the following code to get temperature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;tty=/dev/ttyUSB0&#xA;exec 4&amp;lt;$tty 5&amp;gt;$tty&#xA;stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&#xA;#stty -F $tty 9600 -echo&#xA;#printf &quot;temp\n&quot; &amp;gt;&amp;amp;5&#xA;echo temp &amp;gt;&amp;amp;5&#xA;read reply &amp;lt;&amp;amp;4&#xA;echo &quot;$reply&quot;&#xA;#tail -n 1 - &amp;lt;&amp;amp;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It returns empty or hang under different circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if I run built-in &lt;code&gt;Serial Monitor&lt;/code&gt;, I can see responses on command lines like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo temp &amp;gt; /dev/ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I see nothing with commands like &lt;code&gt;tail -f /dev/ttyUSB0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2015-10-12T19:51:55.093" Title="How to connect Arduino device to Linux?" Tags="|arduino-uno|serial|linux|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16777" PostTypeId="2" ParentId="16765" CreationDate="2015-10-12T19:09:16.517" Score="2" Body="&lt;p&gt;You are getting exactly what you said you want. 4 bytes representing the number in float format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are expecting to get, is 4 bytes representing the number in big-endian integer format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Majenkos solution for casting, you need to change the types and reverse the &lt;code&gt;for&lt;/code&gt; loop for big-endinaness.&lt;br&gt;&#xA;I also used &lt;code&gt;int32_t&lt;/code&gt; because the size of the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Int&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;int&lt;/code&gt;&lt;/a&gt; is 16-bit (2-byte) on the Arduino Uno (and other ATMega based boards) and on the Arduino Due it's 32-bit (4-byte). Its better to define the exact &lt;code&gt;int&lt;/code&gt; in this case.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;union {&#xA;    int32_t ival;&#xA;    byte bval[4];&#xA;} int32AsBytes;&#xA;&#xA;void writeInt32(unsigned int addr, int32_t x)&#xA;{&#xA;    int32AsBytes.ival = x;&#xA;    for(int i = 3; i &amp;gt;= 0; i--) // reverse for big-endian&#xA;    {&#xA;        i2c_eeprom_write_byte(0x57, addr, myFloat.bytes[i]); // Write byte to EEPROM&#xA;        Serial.println(int32AsBytes.bval[i], BIN);  // Debug line&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-10-12T19:09:16.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16778" PostTypeId="2" ParentId="16774" CreationDate="2015-10-12T19:33:07.223" Score="1" Body="&lt;p&gt;It should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow&quot;&gt;Servo&lt;/a&gt; library doesn't use hardware PWM, so you can connect them to a non &quot;~&quot; (PWM) pin.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-10-12T19:33:07.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16779" PostTypeId="2" ParentId="16776" CreationDate="2015-10-12T19:39:43.153" Score="1" Body="&lt;p&gt;Add the flag &lt;code&gt;-hupcl&lt;/code&gt; to your &lt;code&gt;stty&lt;/code&gt; command.  That will disable the assertion of DTR which is resetting the board.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; hupcl (-hupcl)&#xA;             Stop asserting modem control (do not stop asserting modem&#xA;             control) on last close.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first time it is run there will be a reset, since setting that flag entails opening the port, which causes a reset.  So you need to add a delay long enough to get past the bootloader - minimum 2 seconds, best make it 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do that with the &lt;code&gt;sleep&lt;/code&gt; command: &lt;code&gt;sleep 3&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you now won't be able to upload a new sketch since you have disabled the auto-reset feature that allows you to enter the bootloader, so before uploading a new sketch you need to turn the reset back on with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -F $tty hupcl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't disable the reset then every operation in your script that opens and then closes the serial port will trigger a reset of the board.  So in summary try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/bin/bash&#xA;tty=/dev/ttyUSB0&#xA;stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -hupcl&#xA;sleep 3&#xA;echo temp &amp;gt;$tty&#xA;read reply &amp;lt;$tty&#xA;echo &quot;$reply&quot;&#xA;stty -F $tty hupcl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-12T19:51:55.093" LastActivityDate="2015-10-12T19:51:55.093" CommentCount="22" ContentLicense="CC BY-SA 3.0" />
  <row Id="16780" PostTypeId="1" CreationDate="2015-10-12T20:07:26.233" Score="1" ViewCount="3004" Body="&lt;p&gt;Please take a look at following example (I have Java background):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* BT_ADDRESS = &quot;abcd,ef,ghijkl&quot;;&#xA;&#xA;void bar(const char* string) {&#xA;  ...&#xA;}&#xA;&#xA;void foo() {&#xA;   bar(&quot;AT+BIND=&quot; + BT_ADDRESS);&#xA;   bar(&quot;AT+LINK=&quot; + BT_ADDRESS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to achieve this with &quot;Arduino-C++&quot; so BT_ADDRESS only has to be entered at one location?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2015-10-13T05:01:46.740" LastActivityDate="2015-10-13T05:01:46.740" Title="Concatenate string constants" Tags="|c++|string|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16781" PostTypeId="1" CreationDate="2015-10-12T20:20:55.253" Score="2" ViewCount="931" Body="&lt;p&gt;I was told, that when computer opens port, it sends DTR (Data Terminal Ready) signal to Arduino, which initiates Arduino reboot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This looks like part of DTR / DSR flow control. According to this, in response to DTR, Arduino should no only reboot, but also raise DSR (Data Set Ready) signal when it is ready to receive data&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And computer should wait for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it happen so?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2015-10-13T01:04:23.767" Title="Doesn't Arduino reports DSR (Data Set Ready) correctly?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16782" PostTypeId="2" ParentId="16780" CreationDate="2015-10-12T20:25:50.143" Score="4" Body="&lt;p&gt;There is, as you may expect with C, many different ways of doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest is probably to use, instead of a const variable, a preprocessor macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C you can concatenate string literals like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print(&quot;AT+BIND=&quot; &quot;abcd,ef,ghijkl&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the lack of anything but spaces between the strings - they are concatenated together. You can even do it on separate lines - it's a technique that is great for incredibly long strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can, of course, replace one of those with a preprocessor macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BT_ADDRESS &quot;abcd,ef,ghijkl&quot;&#xA;print(&quot;AT+BIND=&quot; BT_ADDRESS);&#xA;print(&quot;AT+LINK=&quot; BT_ADDRESS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The preprocessing replaces BT_ADDRESS with the string literal &quot;abcd,ef,ghijkl&quot; and all is well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other options, depending on what &lt;code&gt;print&lt;/code&gt; does, is to expand it to take two &lt;code&gt;const char *&lt;/code&gt; parameters and deal with them both separately.  For instance, you might have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void print(const char *command, const char *data) {&#xA;    Serial.print(command);&#xA;    Serial.println(data);&#xA;}&#xA;&#xA;print(&quot;AT+BIND=&quot;, BT_ADDRESS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't know how many parameters you may want to pass you could use &lt;em&gt;variadic&lt;/em&gt; arguments:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdarg.h&amp;gt;&#xA;&#xA;void print(int count, ...) {&#xA;    va_list args;&#xA;    va_start args, count);&#xA;&#xA;    for (int i = 0; i &amp;lt; count; i++) {&#xA;        const char *arg = va_arg(args, const char *);&#xA;        Serial.print(arg);&#xA;    }&#xA;    va_end(args);&#xA;}&#xA;&#xA;print(2, &quot;AT+BIND=&quot;, BT_ADDRESS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yet another option is to pre-format the data into a single string using the various string operators.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int len = strlen(&quot;AT+BIND=&quot;) + strlen(BT_ADDRESS);&#xA;char temp[len + 1]; // Be sure to keep space for the terminating NULL.&#xA;strcpy(temp, &quot;AT+BIND=&quot;);&#xA;strcat(BT_ADDRESS);&#xA;print(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could go on all night with different options...  The first one using the preprocessor is probably easiest though.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T20:25:50.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16783" PostTypeId="2" ParentId="16781" CreationDate="2015-10-12T20:30:09.897" Score="3" Body="&lt;p&gt;No, this doesn't happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DTR is used purely for resetting the board.  Personally I would have chosen the RTS signal instead, but the wise guys at Arduino decided on DTR.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino has no knowledge of the DTR signal, it only knows that it has been rebooted.  Whether that reboot came from DTR, or from the reset button, or wherever, it has no knowledge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the DTR is being (in my opinion ab-) used to perform the resetting in order to make uploading a sketch easier and that is all.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T20:30:09.897" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16784" PostTypeId="2" ParentId="16781" CreationDate="2015-10-12T20:39:37.877" Score="3" Body="&lt;p&gt;No, it does not, and can not for the simple reason that there is no DSR line connected to the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally host software / serial driver configuration ignores DSR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the boards with an 8u2/16u2 the custom firmware therein can report whatever virtual state of the signal it is programmed to. On those with hardware USB-serial they will report however the pin is hard wired, or whatever value it is pulled to or floating at.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of these (possibly excepting a Leonardo type board or an ARM one with native USB) reflect anything about the state of the target processor, so software hoping to talk to an Arduino should ignore the DSR signal.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-10-13T01:04:23.767" LastActivityDate="2015-10-13T01:04:23.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16785" PostTypeId="2" ParentId="16765" CreationDate="2015-10-12T20:41:47.437" Score="1" Body="&#xA;&#xA;&lt;p&gt;This mucking around with casts and arrays is far too complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://playground.arduino.cc/Code/EEPROMWriteAnything&quot; rel=&quot;nofollow&quot;&gt;Reading and Writing Data Structures to EEPROM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library EEPROMAnything.h will accomplish this. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;EEPROMAnything.h&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The library just consists of this file. Save into your &quot;libraries&quot; folder under the folder name &lt;code&gt;EEPROMAnything&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;  // for type definitions&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;template &amp;lt;typename T&amp;gt; unsigned int EEPROM_writeAnything (int ee, const T&amp;amp; value)&#xA;{&#xA;    const byte* p = (const byte*)&amp;amp;value;&#xA;    unsigned int i;&#xA;    for (i = 0; i &amp;lt; sizeof(value); i++)&#xA;        EEPROM.write(ee++, *p++);&#xA;    return i;&#xA;}&#xA;&#xA;template &amp;lt;typename T&amp;gt; unsigned int EEPROM_readAnything (int ee, T&amp;amp; value)&#xA;{&#xA;    byte* p = (byte*)&amp;amp;value;&#xA;    unsigned int i;&#xA;    for (i = 0; i &amp;lt; sizeof(value); i++)&#xA;        *p++ = EEPROM.read(ee++);&#xA;    return i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Example code&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;EEPROMAnything.h&amp;gt;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  float foo = 56060066;&#xA;  EEPROM_writeAnything (0, foo);&#xA;&#xA;  float bar;&#xA;  EEPROM_readAnything (0, bar);&#xA;&#xA;  Serial.println (bar);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Output from above&lt;/h3&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;56060064.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you don't get exactly the same number back. This is because of the precision of 4-bytes floats.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After re-reading the question I see you are using I2C EEPROM. That changes the answer a bit, but you can see an adaptation of that library for I2C &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10896&amp;amp;reply=8#reply8&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. The general idea is the same though.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;i2c_eeprom_write_byte(0x57, addr, myFloat.bytes[i]); // Write byte to EEPROM&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your code seems to be writing all of the bytes to the same address, I don't know how that could work.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-12T20:47:59.183" LastActivityDate="2015-10-12T20:47:59.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16786" PostTypeId="1" CreationDate="2015-10-12T20:45:56.043" Score="1" ViewCount="51" Body="&lt;p&gt;I'm attempting to turn on a set of LED's one at a time and then switch them all off at the same time, I am stuck however on turning them off at the same time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledpins[] = {2,3,4,5,6,7,8,9}; //creates a list of the pins in use&#xA;&#xA;void setup() {&#xA;  for (int i = 0; i &amp;lt; 8; i++){&#xA;    pinMode(ledpins[i], OUTPUT);  // iterates over the list led pins from the 0 pin to the pins before the eigth&#xA;  }  &#xA;}&#xA;&#xA;void loop() {&#xA;  for (int i = 0; i &amp;lt; 8; i++){&#xA;    digitalWrite(ledpins[i], HIGH); // turns all the pins of one at a time&#xA;  }&#xA;&#xA;  delay(100); //when all on will wait 100 ms&#xA;  digitalWrite(ledpins[0,7], LOW); //turns off all the leds at once&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The annotations are for my own understanding.&#xA;I just need help turning all the LED's off at once which I dont know the command for.&lt;/p&gt;&#xA;" OwnerUserId="13993" LastEditorUserId="3" LastEditDate="2015-10-13T11:55:19.887" LastActivityDate="2015-10-13T11:55:19.887" Title="How to apply a programme to all values in a list simultaneously" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16787" PostTypeId="2" ParentId="16786" CreationDate="2015-10-12T20:53:11.460" Score="3" Body="&lt;p&gt;You have already done it twice, why are you struggling the third time?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 8; i++){&#xA;  digitalWrite(ledpins[i], HIGH); // turns all the pins of one at a time&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;// turns all the pins of one at a time&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Except that it is happening so fast you can't see then doing it individually. So just do the same but set them to LOW:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 8; i++){&#xA;  digitalWrite(ledpins[i], LOW); // turns all the pins off one at a time&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you might want to add a delay into the loop that turns them on so you can see them turn on individually instead of all at once:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 8; i++){&#xA;  digitalWrite(ledpins[i], HIGH); // turns all the pins of one at a time&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-12T20:53:11.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16788" PostTypeId="2" ParentId="16780" CreationDate="2015-10-12T21:05:33.607" Score="-1" Body="&lt;p&gt;Get rid of strange &lt;code&gt;print()&lt;/code&gt; and use standard &lt;code&gt;stdout&lt;/code&gt;, &lt;code&gt;fprintf()&lt;/code&gt; and &lt;code&gt;%&lt;/code&gt; format tokens.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;Stream.h&amp;gt;&#xA;&#xA;// printf to file support http://arduino.cc/playground/Main/Printf  &#xA;// we need fundamental FILE definitions and printf declarations&#xA;// apparently it eats 1k FLASH by saves to much copy&amp;amp;paste and hopefully even FLASH &#xA;&#xA;// create a output function&#xA;// This works because Serial.write, although of&#xA;// type virtual, already exists.&#xA;static int stream_putchar (char c, FILE *stream) {&#xA;    ((Stream*)(stream-&amp;gt;udata))-&amp;gt;write(c);&#xA;    return 0;&#xA;}&#xA;&#xA;void SetupFileStream(FILE* file, Print* stream) {&#xA;    fdev_setup_stream(file, stream_putchar, NULL, _FDEV_SETUP_WRITE);&#xA;    file-&amp;gt;udata = stream;&#xA;}&#xA;&#xA;#ifdef UDRE0&#xA;// non interrupt transmit function&#xA;static int uart_putchar (char c, FILE *stream) {&#xA;    volatile byte *ucsrna = (byte*)(stream-&amp;gt;udata);&#xA;    while ( !bitRead( ucsrna[0], UDRE0) ) {;}  // wait for transmit buffer is empty&#xA;    ucsrna[&amp;amp;UDR0-&amp;amp;UCSR0A] = c;&#xA;    return 0;&#xA;}&#xA;&#xA;void SetupUartStream(FILE* file, volatile byte *ucsrna) {&#xA;    fdev_setup_stream(file, uart_putchar, NULL, _FDEV_SETUP_WRITE);&#xA;    file-&amp;gt;udata = (void*) ucsrna;&#xA;}&#xA;#endif&#xA;&#xA;#define INFO(fmt, args...) \&#xA;    fprintf_P(stderr, PROGSTR(&quot;INFO: &quot; fmt), ## args);&#xA;&#xA;// create a FILE structure to reference our UART output function in main project file&#xA;static FILE myStdOut = {0};&#xA;void setup() {&#xA;....&#xA;    Serial.begin(19200);&#xA;    SetupUartStream(&amp;amp;myStdOut, &amp;amp;UCSR0A);   // when debugging in AvrStudio then debugger is saturated by debug messages in user data empty interrupt handler if used buffered stream output&#xA;    // The uart is the standard output device STDOUT&#xA;    stdout = &amp;amp;myStdOut;&#xA;    stderr = stdout;&#xA;...&#xA;} &#xA;&#xA;....&#xA;const char* BT_ADDRESS_RAM = &quot;abcd,ef,ghijkl&quot;;&#xA;const char* PROGMEM BT_ADDRESS_FLASH = &quot;abcd,ef,ghijkl&quot;;&#xA;&#xA;&#xA;INFO(&quot;AT+BIND=%s&quot;, BT_ADDRESS_RAM);&#xA;INFO(&quot;AT+BIND=%S&quot;, BT_ADDRESS_FLASH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-10-12T21:05:33.607" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16789" PostTypeId="2" ParentId="16786" CreationDate="2015-10-12T22:02:20.063" Score="1" Body="&lt;p&gt;There is another approach that is to use direct port manipulation. It is a lot faster than using &lt;code&gt;digitalWrite&lt;/code&gt; in the sense that it requires less clock cycles to execute and allows you to change one port at a time (the UNO has 3 ports called D, B and C). You can find an introduction to port manipulation on this page: &lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/PortManipulation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example that toggles the LED you chose:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    DDRD |= B11111100; // Pin 2 to 7 as outputs&#xA;    DDRB |= B00000011; // Pin 8 to 9 as outputs&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    // Pin 2 to 7 HIGH&#xA;    PORTD |= ( 1&amp;lt;&amp;lt;2 ) | ( 1&amp;lt;&amp;lt;3 ) | ( 1&amp;lt;&amp;lt;4 ) | ( 1&amp;lt;&amp;lt;5 ) | ( 1&amp;lt;&amp;lt;6 ) | ( 1&amp;lt;&amp;lt;7 );&#xA;    // Pin 8 to 9 HIGH&#xA;    PORTB |= ( 1&amp;lt;&amp;lt;0 ) | ( 1&amp;lt;&amp;lt;1 );&#xA;&#xA;    _delay_ms( 500 );&#xA;&#xA;    // Pin 2 to 7 LOW&#xA;    PORTD &amp;amp;= ~( 1&amp;lt;&amp;lt;2 ) &amp;amp; ~( 1&amp;lt;&amp;lt;3 ) &amp;amp; ~( 1&amp;lt;&amp;lt;4 ) &amp;amp; ~( 1&amp;lt;&amp;lt;5 ) &amp;amp; ~( 1&amp;lt;&amp;lt;6 ) &amp;amp; ~( 1&amp;lt;&amp;lt;7 );&#xA;    // Pin 8 to 9 LOW&#xA;    PORTB &amp;amp;= ~( 1&amp;lt;&amp;lt;0 ) &amp;amp; ~( 1&amp;lt;&amp;lt;1 );&#xA;&#xA;    _delay_ms( 500 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13995" LastActivityDate="2015-10-12T22:02:20.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16790" PostTypeId="1" AcceptedAnswerId="16791" CreationDate="2015-10-12T22:37:50.553" Score="0" ViewCount="2546" Body="&lt;p&gt;I am working on a project with my school's 3D Printing Club where we are making a humanoid robot and I am attempting to wire the arm at the moment, and program the hands to translate text to sign language. The portion of the arm I am currently working with uses six TowerPro 5010 servos, one for each finger, and another for the wrist, and I am controlling it with an Arduino Uno. I have a 9v wall plug that I am powering the Arduino with, and a 4xAA battery pack (wired in series for 6v, last measured at 5.7) that I would like to use for the servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially, I wired the servo ground pins to the Arduino GND output, and the servo power pins to the battery pack's 6v output, I connected the ground on the battery to the ground on the Arduino, and I attached the servo motors to their IO pins. This approach worked perfectly for two servos, barely for three, and not at all for four. Even with most of the motors staying still (I was only moving one at a time with three and four servos, but I can move two simultaneously no problem with nothing else connected). Not sure how to describe the load on them quantitatively, but they are pulling on fishing line that has a good deal of resistance, but nothing excessive, or near their limits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been googling around for hours, and I found some tutorials where a similar battery was powering eight servos at a time, and so I am unsure why mine was cutting out so soon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to reduce the load of the servos, but nothing I tried worked. At one point I tried wiring the servos on a shift register to only power the ones I needed, but then I realized this was a dumb idea because my shift register would never be able to output enough current to power even one servo. I have some 5v voltage regulators, but I don't think they will help since the servo takes from 4v to 6v, and I looked through all my transistors, but they are all designed for very small currents. I have a relay which should be able to switch that voltage that voltage easily, but only one of them. If possible I would like to try and do this without purchasing any additional components such as motor controllers or specialized batteries, but I understand that if I need to I need to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has any advice on how to proceed I would greatly appreciate it. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="13996" LastActivityDate="2015-10-12T23:06:55.067" Title="Powering multiple servos on external battery" Tags="|power|servo|battery|current|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16791" PostTypeId="2" ParentId="16790" CreationDate="2015-10-12T23:06:55.067" Score="1" Body="&lt;p&gt;If you dont mind to use a bit of space for a dedicated board that controls your servo and power them, I would suggest to use &lt;a href=&quot;http://www.adafruit.com/product/815&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/product/815&lt;/a&gt; which is very good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your issue might become a power draining where the batteries cant keep up to give enough amper to use 3 or 4 servos at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure what kind of batteries you are using, probably not rechargeable ones but I would suggest to get an ampermeter to get the real draining on your circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you will understand a bit better what is going on and why this issue is happening on your configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cant find the power consummation of this servo so I Cant give much more information.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-10-12T23:06:55.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16793" PostTypeId="1" AcceptedAnswerId="16799" CreationDate="2015-10-12T23:56:44.543" Score="1" ViewCount="358" Body="&lt;p&gt;I'm building a robot that needs to pick up a piece of material and then determine its mass. My robot will retrieve the material using a scoop at the ended of a mechanized arm. Once the material is in the scoop, the arm will tilt upwards until the material slides down the arm and into the chassis.&#xA;I hope to weigh the material while its in the chassis, but I'm not sure how to do this. I've found that load sensors are useful for taking masses, but I'm not clear on how they're implemented. For example, I've found load beam cells, but how would I implement one in my design? Does it require a metal plate of some sort (like a weighing pan) on top of it like a laboratory scale? The sensor must be able to communicate with an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My robot needs to be under 6 lbs and have a footprint of 35 x 35 cm. Thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="user14000" LastEditorDisplayName="user14000" LastEditDate="2015-10-13T00:03:23.080" LastActivityDate="2015-11-18T22:24:48.267" Title="What type of sensor could I use to determine the mass of a small object (under 1 kg)?" Tags="|arduino-uno|sensors|robotics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16794" PostTypeId="1" CreationDate="2015-10-13T02:14:59.647" Score="-1" ViewCount="2828" Body="&lt;p&gt;I am looking at purchasing a &lt;a href=&quot;http://www.adafruit.com/products/1643&quot; rel=&quot;nofollow&quot;&gt;NeoPixel Ring&lt;/a&gt; for a project, but need it to work without an Arduino. Once the NeoPixel has been programmed by the Arduino, will it function when powered without the Arduino? I am not looking at changing colors or anything, I want to set the LEDs to solid red and not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found in the Adafruit website that it says &quot;NeoPixels don’t just light up on their own; they require a microcontroller (such as Arduino) and some programming.&quot; But is this only to get them working initially, or do they require an microcontroller permanently?&lt;/p&gt;&#xA;" OwnerUserId="223" LastEditorUserId="223" LastEditDate="2015-10-13T02:21:15.670" LastActivityDate="2022-04-01T20:01:46.400" Title="NeoPixel Ring Usage Without Arduino" Tags="|led|adafruit|neopixel|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16795" PostTypeId="2" ParentId="16794" CreationDate="2015-10-13T02:19:23.313" Score="1" Body="&lt;p&gt;No, the settings for the colors are stored in RAM on the individual devices so they need to be reprogrammed every time they are powered on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, it is possible to use a much smaller device such as a surface-mount ATtiny85 to program them, and &lt;a href=&quot;https://github.com/cpldcpu/light_ws2812&quot; rel=&quot;nofollow&quot;&gt;light_ws2812&lt;/a&gt; runs on said device just fine. And once they have been programmed it is possible to put the MCU in deep sleep so that it consumes almost no power.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-13T02:19:23.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16796" PostTypeId="1" CreationDate="2015-10-13T07:17:05.833" Score="-2" ViewCount="4034" Body="&lt;p&gt;urgently need some inputs,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VCC-5v&#xA;GND-GND&#xA;SCL-SCL(analog pin 5)&#xA;SDA-SDA(analog pin 4)&#xA;ADD-NC or GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code pasted below&#xA;used library from GIT : &lt;a href=&quot;https://github.com/claws/BH1750&quot; rel=&quot;nofollow&quot;&gt;https://github.com/claws/BH1750&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;BH1750.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;BH1750 lightMeter;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;    lightMeter.begin();&#xA;    Serial.println(&quot;Running...&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    uint16_t lux = lightMeter.readLightLevel();&#xA;    Serial.print(&quot;Light: &quot;);&#xA;    Serial.print(lux);&#xA;    Serial.println(&quot; lx&quot;);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10894" LastEditorUserId="4143" LastEditDate="2015-10-13T11:34:28.050" LastActivityDate="2019-11-03T16:05:39.620" Title="BH1750 Light sensor always giving output as 54612lx" Tags="|arduino-uno|sensors|library|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16797" PostTypeId="1" CreationDate="2015-10-13T07:40:10.373" Score="2" ViewCount="543" Body="&lt;p&gt;Is there a difference between Pro Micro 8MHz 3.3V and LilyPad USB bootloaders? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both are based on 32U4 running at 8 MHz.&lt;/p&gt;&#xA;" OwnerUserId="13504" LastEditorUserId="9962" LastEditDate="2016-02-15T05:44:26.900" LastActivityDate="2016-02-15T05:44:26.900" Title="Pro Micro and LilyPad USB" Tags="|arduino-leonardo|arduino-pro-micro|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16798" PostTypeId="2" ParentId="16796" CreationDate="2015-10-13T08:13:34.800" Score="1" Body="&lt;p&gt;There may be a regulator and logic shifter on the board you are using but according to the data sheet the device is a 3V device with 1.8V logic and I2C levels.  So this is the first thing you need to check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you got 4.7K resistors pulling the SDA and SCL lines to Vcc? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you change your code to turn the device off and then take a reading?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing wrong with your code, your wiring looks OK, so that implies that there is something wrong with the device or the Arduino.  Change the device (and code) for another I2C device and see if that works fine.  If it does then it looks like there might be a problem with the BH1750.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-13T08:13:34.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16799" PostTypeId="2" ParentId="16793" CreationDate="2015-10-13T08:18:59.580" Score="1" Body="&lt;p&gt;Just a little brainstorming:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a spring, then you can easily calculate the physical force (mass) needed to stretch the spring to a certain extent. The law is called:&#xA; &lt;a href=&quot;https://en.wikipedia.org/wiki/Hooke%27s_law&quot; rel=&quot;nofollow&quot;&gt;Hookes's Law&lt;/a&gt;&#xA; - you could then just measure the increase in distance between the initial position and the position with load. Use a servo or any distance measure.&lt;/p&gt;&#xA;" OwnerUserId="14004" LastActivityDate="2015-10-13T08:18:59.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16802" PostTypeId="1" CreationDate="2015-10-13T11:15:15.767" Score="-1" ViewCount="2868" Body="&lt;p&gt;Can anyone help me regarding the output of this program? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the function of &lt;code&gt;Num_Write&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int num_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0 &#xA;{ 0,1,1,0,0,0,0 }, // 1 &#xA;{ 1,1,0,1,1,0,1 }, // 2 &#xA;{ 1,1,1,1,0,0,1 }, // 3 &#xA;{ 0,1,1,0,0,1,1 }, // 4 &#xA;{ 1,0,1,1,0,1,1 }, // 5 &#xA;{ 1,0,1,1,1,1,1 }, // 6&#xA;{ 1,1,1,0,0,0,0 }, // 7 &#xA;{ 1,1,1,1,1,1,1 }, // 8 &#xA;{ 1,1,1,0,0,1,1 }}; // 9 &#xA;&#xA;void Num_Write(int); &#xA;&#xA;void setup() {  &#xA;  pinMode(2, OUTPUT); &#xA;  pinMode(3, OUTPUT); &#xA;  pinMode(4, OUTPUT); &#xA;  pinMode(5, OUTPUT); &#xA;  pinMode(6, OUTPUT); &#xA;  pinMode(7, OUTPUT); &#xA;  pinMode(8, OUTPUT); &#xA;} &#xA;&#xA;void loop() {  &#xA;  for (int counter = 10; counter &amp;gt; 0; --counter) { &#xA;    delay(1000); &#xA;    Num_Write(counter-1); &#xA;  } &#xA;  delay(3000); &#xA;} &#xA;&#xA;void Num_Write(int number) { &#xA;  int pin= 2; &#xA;  for (int j=0; j &amp;lt; 7; j++) { &#xA;    digitalWrite(pin, num_array[number][j]); &#xA;    pin++; &#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13535" LastEditorUserId="6936" LastEditDate="2016-02-21T08:14:07.417" LastActivityDate="2016-02-21T08:14:07.417" Title="Arduino with seven segment" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16803" PostTypeId="1" CreationDate="2015-10-13T12:27:15.773" Score="-1" ViewCount="1745" Body="&lt;p&gt;I have an Arduino Nano &amp;amp; am success fully controlling 4 servos from it but it then occurred to me that I am controlling these in a serial manner, ie I set 1 position then the next then the next....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like the servos to act in a parallel manner i.e. that their motions can happen at the same time but at different speeds or different position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible using just 1 controller (maybe some sort of polling/interrupt setup?) or will I need to run separate controllers for each set of servos &amp;amp; synchronize them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Added the PC side code &amp;amp; the Arduino side code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PC Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from Tkinter import *&#xA;import serial&#xA;&#xA;usbport = 'COM5'&#xA;ser = serial.Serial(usbport, 9600, timeout=1)&#xA;&#xA;def init():&#xA;    for servo in range(1, 5):&#xA;        print servo&#xA;        ser.write(chr(255))&#xA;        ser.write(chr(servo))&#xA;        ser.write(chr(90))&#xA;&#xA;class App:&#xA;&#xA;    def __init__(self, master):&#xA;&#xA;        frame = Frame(master)&#xA;        frame.pack()&#xA;        self.scale1 = Scale(master, from_=0, to=180, command=lambda ev: self.getAngle(1), bd=5, bigincrement=2, length=360, width=30, label='Servo 1')&#xA;        self.scale1.set(90)&#xA;        self.scale1.pack(side=LEFT)&#xA;        self.scale2 = Scale(master, from_=0, to=180, command=lambda ev: self.getAngle(2), bd=5, bigincrement=2, length=360, width=30, label='Servo 2')&#xA;        self.scale2.set(90)&#xA;        self.scale2.pack(side=LEFT)&#xA;        self.scale3 = Scale(master, from_=0, to=180, command=lambda ev: self.getAngle(3), bd=5, bigincrement=2, length=360, width=30, label='Servo 3')&#xA;        self.scale3.set(90)&#xA;        self.scale3.pack(side=LEFT)&#xA;        self.scale4 = Scale(master, from_=0, to=180, command=lambda ev: self.getAngle(4), bd=5, bigincrement=2, length=360, width=30, label='Servo 4')&#xA;        self.scale4.set(90)&#xA;        self.scale4.pack(side=LEFT)&#xA;        self.centre = Button(frame, text=&quot;Centre All&quot;, command=self.centre)&#xA;        self.centre.pack(side=TOP)&#xA;&#xA;&#xA;    def getAngle(self, slider):&#xA;        if slider==1:&#xA;            ang = self.scale1.get()&#xA;        if slider==2:&#xA;            ang = self.scale2.get()            &#xA;        if slider==3:&#xA;            ang = self.scale3.get()&#xA;        if slider==4:&#xA;            ang = self.scale4.get()&#xA;        ser.write(chr(255))&#xA;        ser.write(chr(slider))&#xA;        ser.write(chr(ang))&#xA;&#xA;    def centre(self):&#xA;        for servo in range(1, 5):&#xA;            ser.write(chr(255))&#xA;            ser.write(chr(servo))&#xA;            ser.write(chr(90))&#xA;        self.scale1.set(90)&#xA;        self.scale2.set(90)&#xA;        self.scale3.set(90)&#xA;        self.scale4.set(90)&#xA;&#xA;init()&#xA;root = Tk()&#xA;app = App(root)&#xA;root.mainloop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*&#xA; * ------------------------------&#xA; *   MultipleSerialServoControl&#xA; * ------------------------------&#xA; *&#xA; * Uses the Arduino Serial library&#xA; *  (http://arduino.cc/en/Reference/Serial)&#xA; * and the Arduino Servo library&#xA; *  (http://arduino.cc/en/Reference/Servo)&#xA; * to control multiple servos from a PC using a USB cable.&#xA; *&#xA; * Dependencies:&#xA; *   Arduino 0017 or higher&#xA; *     (http://www.arduino.cc/en/Main/Software)&#xA; *   Python servo.py module&#xA; *     (http://principialabs.com/arduino-python-4-axis-servo-control/)&#xA; *&#xA; * Created:  23 December 2009&#xA; * Author:   Brian D. Wendt&#xA; *   (http://principialabs.com/)&#xA; * Version:  1.1&#xA; * License:  GPLv3&#xA; *   (http://www.fsf.org/licensing/)&#xA; *&#xA; */&#xA;&#xA;// Import the Arduino Servo library&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;// Create a Servo object for each servo&#xA;Servo servo1;&#xA;Servo servo2;&#xA;Servo servo3;&#xA;Servo servo4;&#xA;&#xA;// Common servo setup values&#xA;int minPulse = 600;   // minimum servo position, us (microseconds)&#xA;int maxPulse = 2400;  // maximum servo position, us&#xA;&#xA;// User input for servo and position&#xA;int userInput[3];    // raw input from serial buffer, 3 bytes&#xA;int startbyte;       // start byte, begin reading input&#xA;int servo;           // which servo to pulse?&#xA;int pos = 90;        // servo angle 0-180&#xA;int i;               // iterator&#xA;&#xA;// LED on Pin 13 for digital on/off demo&#xA;int ledPin = 13;&#xA;int pinState = LOW;&#xA;&#xA;void setup() &#xA;{ &#xA;  // Attach each Servo object to a digital pin&#xA;  servo1.attach(3, minPulse, maxPulse);&#xA;  servo2.attach(4, minPulse, maxPulse);&#xA;  servo3.attach(5, minPulse, maxPulse);&#xA;  servo4.attach(9, minPulse, maxPulse);&#xA;&#xA;  // LED on Pin 13 for digital on/off demo&#xA;  pinMode(ledPin, OUTPUT);&#xA;&#xA;  // Open the serial connection, 9600 baud&#xA;  Serial.begin(9600);&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  // Wait for serial input (min 3 bytes in buffer)&#xA;  if (Serial.available() &amp;gt; 2) {&#xA;    // Read the first byte&#xA;    startbyte = Serial.read();&#xA;    // If it's really the startbyte (255) ...&#xA;    if (startbyte == 255) {&#xA;      // ... then get the next two bytes&#xA;      for (i=0;i&amp;lt;2;i++) {&#xA;        userInput[i] = Serial.read();&#xA;      }&#xA;      // First byte = servo to move?&#xA;      servo = userInput[0];&#xA;      // Second byte = which position?&#xA;      pos = userInput[1];&#xA;      // Packet error checking and recovery&#xA;      if (pos == 255) { servo = 255; }&#xA;&#xA;      // Assign new position to appropriate servo&#xA;      switch (servo) {&#xA;        case 1:&#xA;          servo1.write(pos);    // move servo1 to 'pos'&#xA;          break;&#xA;        case 2:&#xA;          servo2.write(pos);&#xA;          break;&#xA;        case 3:&#xA;          servo3.write(pos);&#xA;          break;&#xA;        case 4:&#xA;          servo4.write(pos);&#xA;          break;&#xA;&#xA;        // LED on Pin 13 for digital on/off demo&#xA;        case 99:&#xA;          if (pos == 180) {&#xA;            if (pinState == LOW) { pinState = HIGH; }&#xA;            else { pinState = LOW; }&#xA;          }&#xA;          if (pos == 0) {&#xA;            pinState = LOW;&#xA;          }&#xA;          digitalWrite(ledPin, pinState);&#xA;          break;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1564" LastEditorUserId="1564" LastEditDate="2015-10-14T10:51:50.873" LastActivityDate="2020-07-11T22:27:51.490" Title="Parallel servo control?" Tags="|arduino-nano|servo|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16804" PostTypeId="2" ParentId="16802" CreationDate="2015-10-13T13:34:16.263" Score="2" Body="&lt;p&gt;Num_Write will map the output pins to display a number on the 7-segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please note that the schematic below is not the best, nor the proper way to connect a 7 segment display. It's intended to show the connection for illustrating purposes, not for actual wiring. Each segment lead should have it's own resistor. Also, depending on if you have a Common Anode or Common Cathode 7 segment, wiring will differ.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ku5o8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ku5o8.jpg&quot; alt=&quot;Image of a 7segment connected to a microcontroller&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the number 0 is being displayed (check in the num_array) all segments are lit, except for the last segment (segment G).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Num_Write(int number) {                 //Write a number to the 7-segment display. &#xA;  int pin= 2;                                //Take the starting (output) pin.&#xA;  for (int j=0; j &amp;lt; 7; j++) {                //Loop through all the segments of the given number.&#xA;    digitalWrite(pin, num_array[number][j]); //Write the output pin according to the pattern in the &quot;num_array&quot; for the given number.&#xA;    pin++;                                   //Go to the next pin.&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So by looping through the pins, and looping through the array (while setting the pins) we can display a number on the 7 segment display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra:&#xA;The output will be somewhat like this, but then reversed (9 to 0) and withouth the A, B, C, D, E and F.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ivz0x.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ivz0x.gif&quot; alt=&quot;seven segment counting up&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-10-13T13:49:21.243" LastActivityDate="2015-10-13T13:49:21.243" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16805" PostTypeId="1" AcceptedAnswerId="16806" CreationDate="2015-10-13T14:58:15.383" Score="1" ViewCount="1843" Body="&lt;p&gt;I would like to store temperature readings in eeprom, the value from -55.00 to 125.99. What is the most space efficient way to store these numbers with two significant digits along with epoch timestamp?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="4126" LastActivityDate="2015-10-13T21:29:09.850" Title="Most efficient way to store number in EEPROM?" Tags="|eeprom|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16806" PostTypeId="2" ParentId="16805" CreationDate="2015-10-13T15:06:56.387" Score="5" Body="&lt;p&gt;My best off-the-top-of-my-head figure is 6 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4 bytes for the timestamp (assuming a 32-bit value).  Two byte for -32768 to +32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiply the temperature by 100 to make it into the integer range -5500 to +12599. That then fits comfortably inside a 16-bit signed integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;However&lt;/em&gt;, there are other tricks you can use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you know the time of one reading you don't need to store the time of the next - only how much later it is.  One byte can then store up to 255 &quot;whatevers&quot; later than the previous entry - be that seconds, minutes, hours, whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar with the temperature.  You can just store the difference from the previous reading as a single byte if you know that successive readings will never deviate by more than +/-1.27 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you can check to see what the last saved temperature was, and only save a new temperature if it has changed from before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing is the resolution of your data.  You say 2 decimal points, but if the values are all multiples of 0.05 then what is the point of storing at 0.01 resolution?  Just store how many 0.05s there are (divide by 0.05) then multiply it out again afterwards to get the original temperature.  Most useful when coupled with a temperature difference to increase the storage range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's many tricks, you see, and which work best depend exactly on what you want to do with the data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-13T21:29:09.850" LastActivityDate="2015-10-13T21:29:09.850" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16807" PostTypeId="1" AcceptedAnswerId="16808" CreationDate="2015-10-13T16:02:19.257" Score="0" ViewCount="4407" Body="&lt;p&gt;I purchased this 4 digit, 7 segment display from Adafruit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Product: &lt;a href=&quot;http://www.adafruit.com/products/865&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/products/865&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data Sheet: &lt;a href=&quot;http://www.adafruit.com/datasheets/865datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/datasheets/865datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything I have searched for on the net either has 12 pins or 16 pins and most of those are only using 4 resistors.  This one has 14 pins.  I'm trying to wire it up to an Arduino but I'm not sure which pins should have resistors and which shouldn't.  If I wire it up like in the product picture with 1k resistors, I get 8.8.:8.8. and as I remove resistors from 5V, I can see the different sections that are lit/not lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that the correct way of doing it?  Can I now just wire those to the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="13898" LastActivityDate="2015-10-13T17:58:01.957" Title="4 Digit, 7 Segment Display Wiring (14 pin)" Tags="|led|display|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16808" PostTypeId="2" ParentId="16807" CreationDate="2015-10-13T17:58:01.957" Score="0" Body="&lt;p&gt;It's just a 12 pin display, but with two extra pins for the colon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing connections can help you better understand what it going on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resistor should be added to the anodes (pins 1,2,3,4,5,8,9,12,13) just like on the website. Pin 8 should be a different value, to match the brightness of the other (multiplexed) leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other end of the resistor can be put into the Arduino. Depending on the resistor value you may need to add some transistor to drive the other pins (cathodes) on the display. Lower value resistors means a brighter display, but too much current for the Arduino to drive all 8 leds of a digit at the same time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1k resistors, would mean about 3mA of current per segment. So if all segments are on in one digit, that would be 8*3, so 24mA. Which is approaching the maximum current an Arduino pin can source.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-13T17:58:01.957" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16809" PostTypeId="1" CreationDate="2015-10-13T18:20:07.410" Score="1" ViewCount="7236" Body="&lt;p&gt;Anyone know how to use the &lt;a href=&quot;https://www.arduino.cc/en/Reference/FileSeek&quot; rel=&quot;nofollow&quot;&gt;seek() function&lt;/a&gt; of Arduino &lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;SD Library&lt;/a&gt; to position pointer at the end of a file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If programming in Windows do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void fileInsert(char *file, void *data, size_t len) {&#xA;&#xA;    FILE *filePtr;&#xA;&#xA;    if ((filePtr = fopen(file, &quot;rb+&quot;)) == NULL) {&#xA;        printf(&quot;Arquivo %s não pode ser aberto.&quot;, file);&#xA;        exit(EPERM);&#xA;&#xA;    } else {&#xA;&#xA;        fseek(filePtr, 0L, SEEK_END);&#xA;        fwrite(data, len, 1, filePtr);&#xA;        fclose(filePtr);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the Arduino does not have the SEEK_END&lt;/p&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-10-13T19:05:57.400" Title="using seek() in Arduino to go to the end of a variable-sized file" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16810" PostTypeId="2" ParentId="16696" CreationDate="2015-10-13T18:39:28.540" Score="1" Body="&lt;p&gt;I use something very similar to what you are proposing to measure RSSI in an antenna pattern generator.  Say you have an array of 16 samples.  You start filling the array with samples but don't actually output a result until the array is full.  This will give you a startup period of 16 samples where no decisions are made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the array is loaded, set a semaphore that indicates that results may now be used to make decisions.  New samples overwrite the oldest sample in a recirculating buffer.  You will now get decision outputs at the same rate as the sample rate with a lag, i.e. when the inputs go to zero abruptly, it will take 16 sample periods for the output to catch up.  I call this a 16 sample rolling average.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For relatively stable inputs, simply take the mean of the array and output that result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For inputs that are glitchy such as RSSI take the mean of the array and then find the sample(s) that is (are) the farthest away from that mean.  You then recalculate the mean without that sample included.  Note:  Do not discard that sample, simply ignore it for that cycle.  I call this a 15/1 outlyer average.  For my RSSI measurements, this gives me the equivalent of a 48 sample rolling average.  You can do an 8/1, 16/2 system etc requiring 9 and 18 samples per sample respectively, tuning the counts to your particular application.  I am able to get nearly anaechoic chamber results in the middle of a radio noisy office.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, note that the outlyers are NEVER discarded as they may represent a real trend.&lt;/p&gt;&#xA;" OwnerUserId="14014" LastActivityDate="2015-10-13T18:39:28.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16812" PostTypeId="2" ParentId="16809" CreationDate="2015-10-13T19:05:57.400" Score="3" Body="&lt;p&gt;You can only seek to an absolute position from the start of the file.  Fortunately there is the &lt;code&gt;size()&lt;/code&gt; method that can tell you where the end is, though.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file.seek(file.size());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-13T19:05:57.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16814" PostTypeId="1" CreationDate="2015-10-13T20:32:30.730" Score="2" ViewCount="1085" Body="&lt;p&gt;This is a question about modifying sketches other than through the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Uno r3 + Arduino WiFi Shield (not the 101).  Up to now I've been using the IDE to manually change the ssids and passwords to connect to wireless networks.  As a next step, I'd like to create something that will let update the ssid and password from a source other than an IDE, preferably a batch or bash file.  Over the air updates are out of the question (way too advanced) so it is safe to assume that all updates will be done via the USB cable.  Based on my limited knowledge of what I &lt;em&gt;think&lt;/em&gt; needs to happen, I need to solve the following high-level problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get the computer to recognize that a gateway is plugged into a USB port&lt;/li&gt;&#xA;&lt;li&gt;Prompt the user to enter the new ssid and network password&lt;/li&gt;&#xA;&lt;li&gt;Write to the ssid and password fields&lt;/li&gt;&#xA;&lt;li&gt;Compile the code and save it (equivalent compile/upload in the IDE)&lt;/li&gt;&#xA;&lt;li&gt;Run the sketch to find and connect to the network&lt;br&gt;&lt;br&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd like this to look like two blank fields and a &quot;submit&quot; button to the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My imaginary use case is that I'm installing a clone of my gateway/sensor network at a technically-illiterate grandparent's house.  I have no idea where to begin or even if such a thing is possible!&lt;br&gt;&lt;br&gt;Assuming that it is possible, how can I make it easy for them to configure the gateway for use on their home network without resorting to the IDE?&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2015-12-13T22:37:31.020" Title="Modify SSID and Passwords in WiFi sktechs" Tags="|arduino-uno|wifi|shields|sketch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16815" PostTypeId="1" CreationDate="2015-10-13T21:11:33.880" Score="0" ViewCount="1028" Body="&lt;p&gt;I've made 3 programs. One is written in python, c++ processing and bash. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to be okay but then sometimes I get a signal from the arduino that activates the function to lower down the volume on the python code listening for serial data. This is sometimes random but it seems that I can reproduce the same behavior when I turn the light on. I can cause the same disruption if I wave my hands over it quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I filter this? I know that IR is part of the electromagnetic spectrum in which the visible light takes part. The sensor is facing upward for a type of omnidirectional receptor. I've placed a TV IR blackish cover over it but with the same results. Do I need to use the function to hash decode the incoming signal? I suppose that it needs a simple circuit as any other sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to discard the possibility of a random activation in my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken into consideration the answers until now I can confirm that this is part of a physical phenomena due to the distance between my light and the device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the solution to my volume problem It seems that I used &quot;0&quot; in the same statement as the ir code I remapped in the python code. It turned out to be part of the IRlib library of the arduino code that returns a &quot;0&quot; when it encounters an unknown signal. (due to protocol specification? - out of useful range? )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that I can change the if statement value for other than &quot;0&quot; but that won't stop it from returning &quot;0&quot; and that's a disadvantage. The solution that came to me is simply intercepting the signal and use continue to skip this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any alternative to this?&lt;/p&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2015-10-15T02:01:17.137" LastActivityDate="2015-10-15T02:01:17.137" Title="Why does a light bulb activate an infrared sensor? Is there a way I can filter this out?" Tags="|ir|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16816" PostTypeId="2" ParentId="16814" CreationDate="2015-10-13T22:31:32.030" Score="1" Body="&lt;p&gt;Yes, this is possible. However, you need to have some programming skills (Java, C, C++, anything really that can cope with serial comms) to write the computer-side program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forget 'automatic' running of a program without installing a service on the target computer to constantly monitor incoming serial comms. That said, there's nothing to stop you doing that but to me it's an unnecessary extra step. If the End User can handle connecting the Arduino to the computer without having a breakdown, then they can probably cope with launching the input program themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, write a program for the target computer that analyses COM ports for active connections. For each connection, listen for some kind of identification sequence. Perform a basic 'handshake' to verify that it's found the Arduino. Once it has, allow the User to enter the WiFi details, which are then passed on to the Arduino via serial. If you're feeling &lt;em&gt;slightly&lt;/em&gt; adventurous (the necessary code is provided with the Arduino IDE as an Example, so it's no real challenge) you could have the Arduino scan for networks and offer the User a list to choose from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino, include within the sketch a method of opening serial comms with the target computer. This can be either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Within &lt;code&gt;loop()&lt;/code&gt;&lt;/strong&gt;, at regular intervals, which becomes redundant after you've performed the setup correctly; or&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;A one-time affair within &lt;code&gt;setup()&lt;/code&gt;&lt;/strong&gt;. Each time the Arduino is powered on it attempts to establish comms with the computer, but times out after 30 seconds of 'silence', thus the User has to launch the program on the computer within a reasonable time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Whichever approach you choose, the code in the sketch follows a similar essence - send a unique message to whatever is listening (if anything at all!) and wait for a specific response. If the computer is connected and the program is running, it should answer. Provided the answer received by the Arduino is expected (thus 'handshake' mentioned earlier), it should then wait for the SSID/pass to be entered by the User and sent by the computer. From there, connecting the Arduino to the network is a trivial process.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-10-13T22:31:32.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16817" PostTypeId="2" ParentId="16815" CreationDate="2015-10-14T02:03:00.600" Score="1" Body="&lt;p&gt;Yes, a light bulb will put out some infrared light. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decoding remote control signals isn't that hard - there is a tutorial at instructables - &lt;a href=&quot;http://www.instructables.com/id/The-Easiest-Way-to-Use-Any-IR-Remote-with-Ardiuno/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/The-Easiest-Way-to-Use-Any-IR-Remote-with-Ardiuno/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also means you can tell the difference between different buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. - when posting in this forum, it helps to include your code and your wiring.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-14T02:03:00.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16818" PostTypeId="2" ParentId="16815" CreationDate="2015-10-14T03:19:52.913" Score="1" Body="&lt;p&gt;What kind of light bulb is it?  Try using e.g. an LED instead of incandescent; you might get less IR signal.&lt;br&gt;&#xA;Having a more complicated signal that is decoded by the receiver reduces your false positives.&lt;/p&gt;&#xA;" OwnerUserId="11554" LastActivityDate="2015-10-14T03:19:52.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16819" PostTypeId="1" CreationDate="2015-10-14T04:14:37.643" Score="0" ViewCount="503" Body="&lt;p&gt;I know there's sketch to make ESP8266 becoming a simple web server. ESP8266 is cheap, small and consume less power compared to a Arduino Wifi shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to a more complex functionality requirement, I wish to place the web server code inside the Arduino itself (UNO, Nano or Pro Mini maybe). Is it possible to do this by configuring ESP8266 as a wifi bridge/shield to the Arduino? Or some mechanism methods which can route network traffics from ESP8266 to/from Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated&lt;/strong&gt;&lt;br&gt;&#xA;It connected to 4 relays &amp;amp; one I2C RTC DS1307.&lt;br&gt;&#xA;It needs to sync RTC time with NTP server, and implement a web server which allows on-demand turn on/off each individual relay or by scheduling (e.g: turn on/off different relay at particular time of day). If RAM spaces allows, would like to implement a password access scheme for the web server as well&lt;/p&gt;&#xA;" OwnerUserId="4990" OwnerDisplayName="Dennis" LastEditorUserId="4990" LastEditDate="2015-10-14T04:57:14.867" LastActivityDate="2015-10-14T09:25:19.280" Title="Possible configure ESP8266 as wifi shield for Arduino?" Tags="|wifi|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16820" PostTypeId="2" ParentId="16819" CreationDate="2015-10-14T04:29:25.900" Score="2" Body="&lt;p&gt;The ESP has 40 kb of ram and the average SPI flash rom used by ESP modules have 1 ~ 8 MB of code space. The average Arduino has much less of both. Uno R3 has the ATMega328, with 2kb of SRAM and 32kb of code space. Your trying to drive a truck with a mini cooper engine. &lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastActivityDate="2015-10-14T04:29:25.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16821" PostTypeId="1" CreationDate="2015-10-14T05:10:13.400" Score="2" ViewCount="1257" Body="&lt;p&gt;I was driving a relay from Arduino Uno R3 Pin 13. I observed that every time I upload some code the led on the board designating pin 13 would blink. I'm curious why this is so. I understand that the serial LED blinks cause there's a serial transmission but why an IO pin?&lt;/p&gt;&#xA;" OwnerUserId="14022" LastEditorUserId="13552" LastEditDate="2015-10-14T13:33:52.570" LastActivityDate="2015-10-18T09:07:43.563" Title="Why does the PIN 13 LED of Uno R3 blink every time I upload some code?" Tags="|arduino-uno|digital|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16822" PostTypeId="2" ParentId="16821" CreationDate="2015-10-14T05:19:35.547" Score="1" Body="&lt;p&gt;It's driven by the bootloader, which is performing the flashing (I suppose you are flashing through the USB port).&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-14T05:19:35.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16823" PostTypeId="2" ParentId="16821" CreationDate="2015-10-14T06:10:38.683" Score="4" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt; - the flashing is by design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vrReL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vrReL.png&quot; alt=&quot;Optiboot flashing pin 13&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably the reason is to confirm that the bootloader has started.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-14T06:10:38.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16824" PostTypeId="1" CreationDate="2015-10-14T07:20:39.233" Score="2" ViewCount="188" Body="&lt;p&gt;When I use together servo motor and gps module with softwareserial , I found problem .Servo turing without signal.When I remove gps receive pin ,servo normally work. I use arduino mega 2560, ublox NEO6M and micro servo SG90 .Help me please! &lt;/p&gt;&#xA;" OwnerUserId="13783" LastActivityDate="2015-10-14T07:20:39.233" Title="Servo problem when use gps with softwareserial" Tags="|arduino-mega|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16825" PostTypeId="1" AcceptedAnswerId="16832" CreationDate="2015-10-14T08:05:33.950" Score="0" ViewCount="196" Body="&lt;p&gt;I recently purchased a 1.2 8x8 yellow matrix from Adafruit, along with a HT16K33 backpack for it. I joined the matrix and the backpack, connected everything to the arduino, followed the instructions on the site and got it to work. During animation certain rows would not light up and upon later examination I realized that I had to solder up the pins to the backpack because some pins would not completely make contact with the backpack. After soldering the matrix to the backpack, I fired up arduino and uploaded the matrix8x8 sketch that comes with the library to test the matrix and nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a multimeter yet, but tried to check whether electricity is reaching the backpack which turns out to be true. (used a led and connected it to both + and -, and data and clock pins on the backpack.) in both cases the led lights up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I check the health of the backpack and/or matrix?&lt;/p&gt;&#xA;" OwnerUserId="14024" LastActivityDate="2015-12-13T17:34:45.900" Title="LED matrix appears dead" Tags="|arduino-mega|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16826" PostTypeId="1" CreationDate="2015-10-14T08:53:39.537" Score="0" ViewCount="632" Body="&lt;p&gt;I want to exchange some date between arduino and beaglebone, as far as I know, most arduinos works with 5v levels, so I need to convert 5v into 3.3v beaglebone in order to communicate with it.&lt;br&gt;&#xA;Unfortunatly I have no pro mini 3.3v now, only 5v arduinos.&lt;br&gt;&#xA;So I need to convert levels.&lt;br&gt;&#xA;I have several questions.    &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I have UART TTL CP2102 converter, I am using it to programm my Arduino pro mini, can I use it directly with beagle bone without converter ? &lt;a href=&quot;http://ecx.images-amazon.com/images/I/410n8%2BHhdNL._SY300_.jpg&quot; rel=&quot;nofollow&quot;&gt;http://ecx.images-amazon.com/images/I/410n8%2BHhdNL.&lt;em&gt;SY300&lt;/em&gt;.jpg&lt;/a&gt; like this. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I can buy this cable with pl2303 inside &lt;a href=&quot;http://i01.i.aliimg.com/wsphoto/v0/32250361345/Free-postage-1pcs-PL2303-PL2303HX-USB-to-UART-TTL-Cable-module-4p-4-pin-RS232-Converter.jpg&quot; rel=&quot;nofollow&quot;&gt;http://i01.i.aliimg.com/wsphoto/v0/32250361345/Free-postage-1pcs-PL2303-PL2303HX-USB-to-UART-TTL-Cable-module-4p-4-pin-RS232-Converter.jpg&lt;/a&gt;  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it possible to power my arduino pro mini 5v with 3.3v supply and use it directly with beaglebone &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;Can you provide simple level converter schematic to solder it quickly &lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All in all I need just to communicate with beaglebone via uart from pc with USB-UART converter or from arduino it doesn't matter, just to communicate and send some data.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest what is the best way to follow. &lt;/p&gt;&#xA;" OwnerUserId="14025" LastActivityDate="2015-10-14T09:23:34.263" Title="Connect arduino to beaglebone black" Tags="|serial|usb|uart|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16827" PostTypeId="2" ParentId="16826" CreationDate="2015-10-14T09:23:34.263" Score="1" Body="&lt;p&gt;The simplest way is just to plug the Arduino in to the BBB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The BBB has USB.  The Arduino has USB.  Connect the two together and you have both power and data immediately available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the Arduino and its version it will either be there as &lt;code&gt;/dev/ttyAMA0&lt;/code&gt; or &lt;code&gt;/dev/ttyUSB0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even use &lt;code&gt;avrdude&lt;/code&gt; to upload new software to the Arduino direct from the BBB.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-14T09:23:34.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16828" PostTypeId="2" ParentId="16819" CreationDate="2015-10-14T09:25:19.280" Score="0" Body="&lt;p&gt;I can't comment on Passerby's answer so here is an answer to that question in the comments: What ESP8266 are you using? The simple ESP-01, the one with just 8 pins, does not have four I/O ports. However if you have a more advanced ESP8266(for example the ESP12 on a breakout board) you do have 4 I/O pins and you could just threw out the Arduino entirely. The ESP8266 is better suited to serve as a webserver than your arduino. So as Passerby suggested try just using your ESP8266 alone instead of combined with your Arduino. Have a look at &lt;a href=&quot;http://randomnerdtutorials.com/esp8266-web-server/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. It is a tutorial on how to build a webserver controlling two LED's. All you would need to do is replace the LED's with the relays and add another two outputs. Note that you do need another powersupply for your ESP8266 than the Arduino. The arduino can only supply about 40mA, while the peek current of an ESP8266 can be around 250mA. Good Luck!&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-10-14T09:25:19.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16829" PostTypeId="2" ParentId="16696" CreationDate="2015-10-14T10:42:54.923" Score="1" Body="&lt;p&gt;Thank you John! Your solution is what I was looking for: it resolves my conflict between preserving all the data and excluding the skewing effects of outliers; is simple enough to implement on a microcontroller; and seems to work perfectly. I'm guessing that the rolling mean will also smooth out any potential swings due to mechanical resonance.&lt;br&gt;&#xA;I know this is an Arduino forum, but I find it quicker and easier to write interactive code in Python, so I've written a crude `test bed' implementation of your algorithm in Python so that I could get a feel for how it works in practice, with user keyboard input simulating real-life sensor readings. I've avoided any libraries or esoteric Python syntax, so this should be easy to adapt to C++/Arduino. I'm posting it here in case it is of interest to the community.&lt;br&gt;&#xA;I've used the formula for Sample Std Deviation (n-1) rather than Population SD (n) which I think is correct in this context, but please let me know if not:&lt;br&gt;&#xA;in LaTeX: $SD=\sqrt{\frac{\sum_{(i=1)}^{n}(x_{i}-\bar{x})^{2}}{n-1}}$&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are any other algorithms or solutions to my post, I'd be very interested to know. Thanks again.    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#===================================================&#xA;def SampleSD(data,bufLen):&#xA;    datasum = 0.0 # NB declare as float to prevent integer rounding error&#xA;    diffsum = 0.0 # NB declare as float to prevent integer rounding error&#xA;    for m in range (0,bufLen):&#xA;        datasum += data[m]&#xA;    mean = datasum / bufLen&#xA;    for m in range (0,bufLen):&#xA;        diffsum += (data[m] - mean) ** 2&#xA;    sd = (diffsum /(bufLen-1)) ** 0.5 &#xA;    print &quot;n: %d\tSum: %f\tMean: %f\tSD: %f&quot; %(bufLen,datasum,mean,sd)&#xA;    return mean,sd&#xA;&#xA;#=====================================&#xA;def addData(data,bufLen):&#xA;    print &quot;\n------------------------------&quot;&#xA;    new = input (&quot;Sensor reading: &quot;)&#xA;    for m in range(bufLen-1,0,-1):       &#xA;        data[m]=data[m-1]&#xA;    data[0]=new&#xA;    return data&#xA;&#xA;#======================================&#xA;bufLen = input (&quot;Buffer Length: &quot;)&#xA;print&#xA;data = [0] * bufLen # Declare an array of suitable length in Python&#xA;n = 0&#xA;&#xA;# Fill buffer with initial data&#xA;while n &amp;lt; (bufLen):&#xA;    new = input (&quot;Initial sensor reading: &quot;)         &#xA;    data[n] = new&#xA;    n +=1&#xA;print &quot;\nBuffer initialised.&quot;&#xA;print &quot;Data: &quot;,data&#xA;&#xA;while True:&#xA;    addData(data,bufLen)&#xA;    print &quot;Data: &quot;, data&#xA;    mean,sd = SampleSD(data,bufLen)&#xA;#===========================================&#xA;# Recalculate Mean only using data within range +/- 1 SD of mean&#xA;    if sd != 0: # Error trap to avoid divide by zero error if sd = 0&#xA;        print &quot;\nChecking for outliers:&quot;&#xA;        newSum = 0.0 # NB declare as float to prevent integer rounding error&#xA;        newLen = 0&#xA;        n=0&#xA;        while n &amp;lt; (bufLen):&#xA;            if ((data[n] &amp;lt; (mean + sd)) and (data[n] &amp;gt; (mean - sd))):&#xA;                print &quot;Data [%d] = %d Included&quot; % (n, data[n])&#xA;                newSum += data[n] # sum of data which is within +- 1SD of original mean&#xA;                newLen += 1 # number of data whic are within +/- 1SD of original mean&#xA;            else:&#xA;                print &quot;Data [%d] = %d Excluded: Out of range&quot; % (n, data[n])&#xA;            n+=1&#xA;    CorrMean = newSum / newLen &#xA;    print &quot;New n: %d\tNew Sum: %f\tCorrected Mean: %f&quot; %(newLen,newSum,CorrMean)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13929" LastEditorUserId="13929" LastEditDate="2015-10-14T10:50:55.803" LastActivityDate="2015-10-14T10:50:55.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16831" PostTypeId="1" AcceptedAnswerId="16843" CreationDate="2015-10-14T16:10:18.663" Score="0" ViewCount="165" Body="&lt;p&gt;I am testing a WinCE device that loses all USB communication infrequently. I need to detect when the USB fails on this device. When it fails, the power is intact at the port, just no data at all on D+ and D- (I verified this with an oscilloscope). This host device is basically a black box to me so I can't do anything to it but check it's state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My proposed solution:  Use an arduino of some type (preferably an UNO since I have one already) programmed to detect USB activity to let me know when USB is failing on the host device I am testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? The arduino seems like a good solution for me because I assume it is a USB client, which I need in this scenario.  Any example or pointing me in the right direction would be of great help.  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13983" LastActivityDate="2016-07-28T19:08:30.267" Title="Detect USB activity from a host" Tags="|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16832" PostTypeId="2" ParentId="16825" CreationDate="2015-10-14T16:21:29.120" Score="0" Body="&lt;p&gt;I hate to say it, but a multimeter would really come in handy for you.  Harbor Freight has some for under $10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, without knowing anything specific about what you are using, you could try using the same LED you used to test power and put it in parallel with one of the LEDs on the matrix.  I'm guessing you don't have power at the LEDs though because it seems unlikely that all the LEDs would fail.  Check your solder work and make sure you have not shorted anything.  Also, you could have overheated a component when soldering causing it to fail.  Good luck.&lt;/p&gt;&#xA;" OwnerUserId="13983" LastActivityDate="2015-10-14T16:21:29.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16834" PostTypeId="1" AcceptedAnswerId="16839" CreationDate="2015-10-14T18:11:25.503" Score="0" ViewCount="671" Body="&lt;p&gt;I am making my own &quot;7 segment LED driver&quot;. I know there is a lot of examples on the internet, I just want to try my own. But I have a piece of code that does not work and I don't know why. Can somebody explain to me why it is not working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I put in this, it works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(pins[0], one[0]);&#xA;digitalWrite(pins[1], one[1]);&#xA;digitalWrite(pins[2], one[2]);&#xA;digitalWrite(pins[3], one[3]);&#xA;digitalWrite(pins[4], one[4]);&#xA;digitalWrite(pins[5], one[5]);&#xA;digitalWrite(pins[6], one[6]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So of course I tried using for():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (byte i = 0; i &amp;gt;= 6; i++)&#xA;  {&#xA;    digitalWrite(pins[i], one[i]);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this does not work. But why? I think it should. Btw. &lt;em&gt;pins&lt;/em&gt; is const byte array and &lt;em&gt;one&lt;/em&gt; is const bool array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any suggestions!&lt;/p&gt;&#xA;" OwnerUserId="12154" LastActivityDate="2015-10-14T19:44:27.173" Title="Why cannot I input arrays as digitalWrite arguments?" Tags="|digital|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16835" PostTypeId="1" CreationDate="2015-10-14T18:34:30.650" Score="0" ViewCount="1083" Body="&lt;p&gt;I have a few sensors plugged in and getting some data from them. I want to use XMPP protocol to push the sensor data to my main server. Is there a good XMPP library available which I can use?&lt;/p&gt;&#xA;" OwnerUserId="14032" LastActivityDate="2016-02-12T02:09:51.760" Title="Is there a good XMPP (Jabber) library for Arduino?" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16836" PostTypeId="1" CreationDate="2015-10-14T18:47:48.930" Score="1" ViewCount="126" Body="&lt;p&gt;I am now constructing something with 30 servos (each one will control an individual joint separately, so I guess I can't get away from this), how can I determine how much current do I need, I have a 5V 6A power supply, will that be working just fine? Many thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14033" LastActivityDate="2015-10-14T21:16:54.687" Title="Power Supply for 30 Servos" Tags="|arduino-mega|power|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16837" PostTypeId="1" AcceptedAnswerId="16842" CreationDate="2015-10-14T19:01:03.433" Score="1" ViewCount="2600" Body="&lt;p&gt;I'm using the following library to drive a 4 digit, 7 segment LED display:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/SevenSegmentLibrary&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/SevenSegmentLibrary&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The display is showing the temperature which it gets from a DS18B20 temperature sensor.  Since the LED display constantly needs to be refreshed, when the code runs to get the current temperature, the display temporarily turns off because the LEDs are not being refreshed.  The code I am using is below. Is there anyway to prevent the LED display from turning off while the temperature request code runs?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;SevSeg sevseg;&#xA;&#xA;unsigned long timer; // the timer&#xA;unsigned long INTERVAL = 30000; // the repeat interval (30 seconds)&#xA;&#xA;#define ONE_WIRE_BUS 2&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;void setup() {&#xA;  byte numDigits = 4;&#xA;  byte digitPins[] = {A2, A3, A4, A5};&#xA;  byte segmentPins[] = {8, 10, 6, 4, 3, 9, 7, 5};&#xA;&#xA;  sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);&#xA;  sevseg.setBrightness(90);&#xA;&#xA;  // Get the initial temperature and show it on the LED display&#xA;  sensors.begin();&#xA;  sensors.requestTemperatures();&#xA;  sevseg.setNumber(sensors.getTempCByIndex(0), 1);&#xA;  timer = millis(); // start timer&#xA;}&#xA;&#xA;void loop() {&#xA;  if ((millis()-timer) &amp;gt; INTERVAL) {&#xA;    // Reset the timer and get/display the current temperature&#xA;    timer += INTERVAL;    &#xA;    sensors.requestTemperatures();&#xA;    sevseg.setNumber(sensors.getTempCByIndex(0), 1);&#xA;  }&#xA;&#xA;  sevseg.refreshDisplay(); // Must run repeatedly to refresh the LED display&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13898" LastEditorUserId="4131" LastEditDate="2015-10-15T19:27:17.430" LastActivityDate="2015-10-15T19:27:17.430" Title="Execute Code While Refreshing a 7 Segment LED Display" Tags="|led|display|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16838" PostTypeId="2" ParentId="16836" CreationDate="2015-10-14T19:20:34.477" Score="1" Body="&lt;p&gt;Get one of the servo's working at full load &amp;amp; measure the current flowing through it, multiply that by 30.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's a lot of servos :D&lt;/p&gt;&#xA;" OwnerUserId="1564" LastActivityDate="2015-10-14T19:20:34.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16839" PostTypeId="2" ParentId="16834" CreationDate="2015-10-14T19:44:27.173" Score="0" Body="&lt;p&gt;You've written the &lt;code&gt;for&lt;/code&gt; loop incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (byte i = 0; i &amp;gt;= 6; i++)   &amp;lt;-- ERROR HERE&#xA;  {&#xA;    digitalWrite(pins[i], one[i]);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That first line should be &lt;code&gt;for (byte i = 0; i &amp;lt;= 6; i++)&lt;/code&gt;. &lt;code&gt;i&lt;/code&gt; begins at zero, which is less than six, and the loop only runs while &lt;code&gt;i&lt;/code&gt; is greater than 6.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-10-14T19:44:27.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16840" PostTypeId="2" ParentId="16836" CreationDate="2015-10-14T21:16:54.687" Score="1" Body="&lt;p&gt;You'll need to look up for your particular model of servo what it is rated for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this &lt;a href=&quot;http://www.rctoys.com/pdf/hitec-servos/HIT-HS55.pdf&quot; rel=&quot;nofollow&quot;&gt;random datasheet&lt;/a&gt; I got values of about 5mA while idle and 150mA while running. Your 6A supply will be fine (if your servos don't draw significantly more than these) even if you run them all at once (which in practice, you might not).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if you stall the servos they will draw more current, but it seems unlikely that you'd stall all of them at once.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-10-14T21:16:54.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16841" PostTypeId="2" ParentId="16835" CreationDate="2015-10-14T22:20:56.863" Score="1" Body="&lt;p&gt;A quick search pulls up &lt;a href=&quot;https://github.com/adamvr/XMPPArduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adamvr/XMPPArduino&lt;/a&gt; which hasn't been touched since it was first created five years ago, and may or may not work. XMPP is a very heavy protocol that is very burdensome for a microcontroller to try and run. You could try and get the above library to work, or I would recommend one of the following alternatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Load an XMPP client onto the OpenWRT side of the Yun and send commands from the Yun to control it. (&lt;strike&gt;Although glancing through the list of packages, there does not appear to be a pre-existing one. So this might not be an option unless you are up for cross compiling one.&lt;/strike&gt; Looks like there is at least one: BitlBee via &lt;a href=&quot;https://github.com/arduino/openwrt-packages-yun&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/openwrt-packages-yun&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Have the Arduino communicate using a lighter weight protocol (e.g. HTTP or MQTT) to another server or application that you write, which in turn sends your XMPP message using a readily available library.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-10-14T22:33:20.953" LastActivityDate="2015-10-14T22:33:20.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16842" PostTypeId="2" ParentId="16837" CreationDate="2015-10-14T22:45:38.950" Score="1" Body="&lt;p&gt;The problem here is that the display is driven using a timer interrupt.  The temperature sensor, being a one-wire device, has to have very careful timing to communicate with it.  As a result it disables interrupt so it has exclusive use of the CPU and can properly predict its timing while it's communicating.  And so the display can't refresh at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what can you do?  Well, nothing really.  You can't have perfect timing for the temperature sensor while at the same time interrupting it for displaying the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there's really two main options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Change the temperature sensor.  Use an SPI or I2C temperature sensor that has a real hardware interface to communicate with it so you don't have to use big-banging.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Change the display.  A non-multiplexed display or a display with its own built in driver (most often with some serial protocol like I2C or UART) would mean you don't have to use interrupts to update the display.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Basically you have two technologies that won't sit together well on the same chip.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I missed the &lt;code&gt;sevseg.refreshDisplay()&lt;/code&gt; function call since the website had scrolled it off the bottom of the code block.  Bah!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so it's not using an interrupt.  That could be a good thing, or it may be meaningless.  It takes time to do the temperature reading, and it's that getting in the way of the refreshing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a chance you may be able to push the update &quot;into the background&quot; by attaching it to a timer interrupt, but if the OneWire communication does disable interrupts then the problem will still persist (I don't have OneWire to hand to look at the code right now).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-15T13:09:27.103" LastActivityDate="2015-10-15T13:09:27.103" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16843" PostTypeId="2" ParentId="16831" CreationDate="2015-10-14T22:51:04.150" Score="0" Body="&lt;p&gt;If all you are interested in is the voltages on the D+ and D- lines you could wire those direct into two ADC inputs on the Arduino and wire +5V and GND into the +5V and GND pin.  The Arduino can then sample the voltages and compare them to valid or invalid ranges.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-14T22:51:04.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16847" PostTypeId="1" CreationDate="2015-10-15T08:29:28.317" Score="0" ViewCount="487" Body="&lt;p&gt;I am able to use AT command from the Serial monitor however when I run the following code nothing is sent or received from the ESP8266. Can someone advise what could be the problem.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;;&#xA;&#xA;SoftwareSerial esp8266(0,1); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;                            // This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;                             // and the RX line from the esp to the Arduino's pin 3&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); // your esp's baud rate might be different&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; if(esp8266.available()) // check if the esp is sending a message &#xA;  {&#xA;    while(esp8266.available())&#xA;    {&#xA;      // The esp has data so display its output to the serial window &#xA;      char c = esp8266.read(); // read the next character.&#xA;      Serial.write(c);&#xA;    }  &#xA;  }&#xA;&#xA;&#xA;  if(Serial.available())&#xA;  {&#xA;    // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest&#xA;    // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it&#xA;    // but we want to send everything at the same time.&#xA;    delay(1000); &#xA;&#xA;    String command=&quot;&quot;;&#xA;&#xA;    while(Serial.available()) // read the command character by character&#xA;    {&#xA;        // read one character&#xA;     command+=(char)Serial.read();&#xA;    }&#xA;    esp8266.println(command); // send the read character to the esp8266&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14043" LastEditorUserId="42" LastEditDate="2015-10-15T09:04:02.597" LastActivityDate="2015-10-15T10:02:46.590" Title="cannot read from softwareserial" Tags="|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16848" PostTypeId="2" ParentId="16704" CreationDate="2015-10-15T08:32:57.503" Score="1" Body="&lt;p&gt;I had a similar problem. though it was easily solved but not obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't connect my nano to the computer, but other devices worked fine. After a while other devices started to be faulty such as portable hard-drives and my CC3D flight controllers. After a cable replacement all the items started working again even the Arduino that i otherwise had discarded as broken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might not be the solution you are looking for but im leaving it here in case others comes for a solution.&lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-10-15T08:32:57.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16849" PostTypeId="2" ParentId="16847" CreationDate="2015-10-15T10:02:46.590" Score="2" Body="&lt;pre&gt;&lt;code&gt;SoftwareSerial esp8266(0,1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't use pins 0 and 1 for software serial since they are the hardware serial &lt;code&gt;Serial&lt;/code&gt; than you use for communication with the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pick two other pins to use.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-15T10:02:46.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16850" PostTypeId="1" AcceptedAnswerId="16851" CreationDate="2015-10-15T11:16:31.913" Score="0" ViewCount="994" Body="&lt;p&gt;I need to make my program run immediately on a reset or power up. However, the bootloader delays program startup by around 2.5 seconds. How can I get over this? Is there a way to turn off the bootloader wait period?&lt;/p&gt;&#xA;" OwnerUserId="13907" LastActivityDate="2015-10-15T11:23:03.740" Title="Arduino Mega 2560 bootloader delay" Tags="|arduino-mega|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16851" PostTypeId="2" ParentId="16850" CreationDate="2015-10-15T11:23:03.740" Score="0" Body="&lt;p&gt;Yes.  You remove the bootloader completely and program the Arduino using a hardware programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you could &quot;turn off&quot; the wait period you would never be able to get into the bootloader to program the board, so the bootloader would be completely useless.  So either way you would then need a hardware programmer to do anything constructive with the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A hardware programmer could be another Arduino, or a real hardware programming adapter.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-15T11:23:03.740" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16852" PostTypeId="1" CreationDate="2015-10-15T12:36:32.873" Score="0" ViewCount="1149" Body="&lt;p&gt;I know that there are plenty of questions related to relays, but I have to ask. I am trying to sort out the issue and spend hours reading but cannot make progress. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;http://www.sainsmart.com/arduino/arduino-components/omron-12v-2-channel-relay-opto-couple-for-arduino-uno-r3-raspberry-pi-arm.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SainSmart 2-Channel 12V Relay Module&lt;/a&gt; for Arduino and wired it according to picture. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xzwDc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xzwDc.jpg&quot; alt=&quot;SainSmart 2-channel relay&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO R3 board is powered from 12V plug external power supply. I take that 12V to power JD-VCC on relay (from VIN). Arduino 5V is used to power optocoupler circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use to power 12/24/220V devices (on picture I wired 6V battery for troubleshooting). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when I set PIN7 to LOW i would expect that fan spins up. LED on relay goes RED, so I expect it is sign that relay is activated. However, fan does not power on. &#xA;When I bring PIN7 to HIGH, I hear click; LED goes OFF. I assume it deactivated relay. All the time I have 6V on voltmeter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong?&#xA;I really tried to find answer around, but either I do not see or it is not so obvious. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XUBE7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XUBE7.png&quot; alt=&quot;WIRING&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14045" LastEditorDisplayName="user31481" LastEditDate="2017-10-23T21:54:38.423" LastActivityDate="2017-10-23T21:54:38.423" Title="Sainsmart Omron 12V optocoupled 2 channel relay problem" Tags="|relay|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16853" PostTypeId="2" ParentId="9953" CreationDate="2015-10-15T12:40:50.497" Score="0" Body="&lt;p&gt;Did you by any chance, download the Windows version of the Arduino IDE and install it under Wine? Then I would expect it to seek a COM# serial port. In which case you will have to create a symbolic link from the relevant /dev/ttyUSBx to COMx for your Arduino IDE to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The right way is to download the Arduino for Linux tar.gz file and extract it to a path of your choice in your Home folder.&lt;/p&gt;&#xA;" OwnerUserId="13907" LastActivityDate="2015-10-15T12:40:50.497" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16854" PostTypeId="2" ParentId="16852" CreationDate="2015-10-15T13:01:12.053" Score="0" Body="&lt;p&gt;&lt;s&gt;Looking at what I assume is &lt;a href=&quot;http://www.sainsmart.com/arduino-compatibles-1/relay/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html&quot; rel=&quot;nofollow&quot;&gt;the same module on the Sainsmart website&lt;/a&gt; it looks like the relays are 5V. That means the 12V you have pumped into them has made the &lt;a href=&quot;https://en.wikipedia.org/wiki/Magic_smoke&quot; rel=&quot;nofollow&quot;&gt;Magic Smoke™&lt;/a&gt; escape.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Throw them away, buy some new ones, and next time don't put in more than twice the voltage it needs.&lt;/s&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-15T13:59:48.147" LastActivityDate="2015-10-15T13:59:48.147" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="16855" PostTypeId="1" AcceptedAnswerId="16874" CreationDate="2015-10-15T16:31:52.857" Score="-1" ViewCount="2694" Body="&lt;p&gt;I want to create a website where the users can have their own database. An example:&#xA;- An user will receive some data from HTTP POST and I want to storage all the information into a local database to access to it. For example, the URL that the user has visited in the last month.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the best option will be to create a database in my server and put each user in it, but it will be very long database and the information between users is not shared, therefore it will be more secure using a local database, but I don´t know if that can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project is about ESP8266 and uploading data to a server, so this can be done using a microcontroller instead the computer. I have seen the raspberry to use it as a server and storage there the database, but it is so expensive. Can be done using another board as Arduino, Texas Instruments, etc...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main aim is to create a main hub to storage all the values received from the ESP8266 and then share over internet, but I don´t know how to build a hub where I can store a database inside and a HTML website to show the values. Any ideas? I would like to avoid a computer to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think in something for less than 10 GBP, because I bought and Arduino and Ethernet shield for 5 GBP both, fake version, but useful for my project&lt;/p&gt;&#xA;" OwnerUserId="14050" LastEditorUserId="14050" LastEditDate="2015-10-15T16:37:30.153" LastActivityDate="2017-12-17T03:26:05.923" Title="Where can I storage a local database?" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="2" ClosedDate="2017-12-20T15:45:18.563" ContentLicense="CC BY-SA 3.0" />
  <row Id="16858" PostTypeId="1" CreationDate="2015-10-15T17:38:30.237" Score="6" ViewCount="41360" Body="&lt;p&gt;What is the difference in using a common anode and common cathode of the 7 Segment in interfacing with the Arduino? How can you change the code if we need to add another 7 Segment display?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can you change the code to have a counter in backwards (from 0 to 9)?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ANODE = 2;   &#xA;&#xA;const int LED1 = 3;   &#xA;const int LED2 = 4;   // pin for led 2&#xA;const int LED3 = 5;   // pin for led 3&#xA;const int LED4 = 6;   // pin for led 4&#xA;&#xA;// now bottom row&#xA;&#xA;const int LED5 = 7;   &#xA;const int LED6 = 8;   &#xA;const int LED7 = 9;   &#xA;const int LED8 = 10;  &#xA;&#xA;int DELAY = 0;        &#xA;&#xA;void setup() {&#xA;  pinMode(ANODE, OUTPUT);  // common anode is obviously an output&#xA;&#xA;  pinMode(LED1, OUTPUT);   // led are output for low will be on&#xA;  pinMode(LED2, OUTPUT);   // led 2 is output&#xA;  pinMode(LED3, OUTPUT);   // led 3 is output&#xA;  pinMode(LED4, OUTPUT);   // led 4 is output&#xA;  pinMode(LED5, OUTPUT);   // led 5 is output&#xA;  pinMode(LED6, OUTPUT);   // led 6 is output&#xA;  pinMode(LED7, OUTPUT);   // led 7 is output&#xA;  pinMode(LED8, OUTPUT);   // led 8 is output&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  if (DELAY == 300){&#xA;    delay(100000);&#xA;  }&#xA;&#xA;&#xA;&#xA;  digitalWrite(ANODE, HIGH); &#xA;&#xA;  digitalWrite(LED1, HIGH);   &#xA;  digitalWrite(LED2, HIGH);   &#xA;  digitalWrite(LED3, HIGH);   &#xA;  digitalWrite(LED4, HIGH); &#xA;  digitalWrite(LED5, HIGH);   &#xA;  digitalWrite(LED6, HIGH);   &#xA;  digitalWrite(LED7, HIGH);   &#xA;  digitalWrite(LED8, HIGH);  &#xA;&#xA;delay(1000);   &#xA;&#xA;  digitalWrite(LED1, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED1, HIGH);  &#xA;  digitalWrite(LED2, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED2, HIGH);  &#xA;  digitalWrite(LED3, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED3, HIGH);  &#xA;  digitalWrite(LED4, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED4, HIGH);  &#xA;  digitalWrite(LED5, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED5, HIGH);  &#xA;  digitalWrite(LED6, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED6, HIGH);  &#xA;  digitalWrite(LED7, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED7, HIGH);  &#xA;  digitalWrite(LED8, LOW);   &#xA;  delay(500);                &#xA;  digitalWrite(LED8, HIGH);  &#xA;&#xA;  delay(100);                &#xA;&#xA;  DELAY = DELAY + 150;       &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13535" LastEditorUserId="10794" LastEditDate="2015-10-16T04:46:05.040" LastActivityDate="2021-02-26T05:34:57.310" Title="LEDs: difference between common anode and common cathode?" Tags="|arduino-uno|c++|led|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16859" PostTypeId="2" ParentId="16821" CreationDate="2015-10-15T17:44:49.327" Score="-1" Body="&lt;p&gt;To show that the bootloader is functioning satisfactorily to the hobbyist. Boot loader helps to upload new sketch on the chip.&lt;/p&gt;&#xA;" OwnerUserId="14053" LastEditorUserId="3" LastEditDate="2015-10-18T09:07:43.563" LastActivityDate="2015-10-18T09:07:43.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16860" PostTypeId="1" AcceptedAnswerId="16863" CreationDate="2015-10-15T18:28:40.027" Score="0" ViewCount="65" Body="&lt;p&gt;I bought a &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Ping&quot; rel=&quot;nofollow&quot;&gt;Ping Ultrasonic Range Finder&lt;/a&gt;. It has four pins that you connect to the Arduino. I see in Internet that they have three pins. What does represent each pin and where to connect it to? I have an Arduino Uno Starter Kit.&lt;/p&gt;&#xA;" OwnerUserId="10878" LastEditorUserId="6959" LastEditDate="2015-10-16T14:58:54.060" LastActivityDate="2015-10-16T14:58:54.060" Title="Ping sensor with three or four pins?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16862" PostTypeId="1" AcceptedAnswerId="16868" CreationDate="2015-10-15T18:42:42.000" Score="0" ViewCount="8707" Body="&lt;p&gt;I am new to Arduino and want to create a graduation project for my university.&#xA;I am thinking to create a GPS tracker that can be attached to a cloth to track kids, for example.&#xA;So the requirements for this project is as follows:&#xA;- The device should be small&#xA;- It should upload its location to a web server constantly.&#xA;- the device should work with battery for at least 8 hours&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what components are needed for this project?&#xA;What concern me a lot is that how can I find battery last this much time, if I need bigger battery, it may hinder the device from being attached easily.&lt;/p&gt;&#xA;" OwnerUserId="14056" LastActivityDate="2019-11-28T06:39:51.327" Title="What components I need for a small GPS tracker" Tags="|gsm|gps|adafruit|components|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16863" PostTypeId="2" ParentId="16860" CreationDate="2015-10-15T19:21:18.220" Score="0" Body="&lt;p&gt;You have 4 &lt;em&gt;pins&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vcc: +5V supply voltage (it stands for Collector Voltage)&lt;/li&gt;&#xA;&lt;li&gt;GND: Ground.&lt;/li&gt;&#xA;&lt;li&gt;Trig: Causes an ultrasound pulse to be generated (it stands for &lt;em&gt;Trigger&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Echo: Tells you when an echo has been received.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can see how to wire and use it here: &lt;a href=&quot;http://www.instructables.com/id/Easy-ultrasonic-4-pin-sensor-monitoring-hc-sr04/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Easy-ultrasonic-4-pin-sensor-monitoring-hc-sr04/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-15T19:21:18.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16864" PostTypeId="2" ParentId="16862" CreationDate="2015-10-15T19:29:26.780" Score="1" Body="&lt;p&gt;You need four things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A GPS receiver&lt;/li&gt;&#xA;&lt;li&gt;A GSM modem&lt;/li&gt;&#xA;&lt;li&gt;An Arduino&lt;/li&gt;&#xA;&lt;li&gt;A Battery&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using off the shelf products you would probably end up with something about the size of a cigarette packet at best - probably bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it small enough to be unobtrusive would take a lot of work.  You would need to design your own circuitry combining everything that is contained in the three circuits above into the smallest design you can, and since most existing solutions use pre-built modules (&lt;em&gt;cans&lt;/em&gt;) that are relatively large you would first have to discover how they work and replicate them as one single tiny module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then there is the battery.  GPS receivers are very sensitive devices. They have quite powerful preamplifiers to detect the incredibly faint signals of the satellites.  Consequently they use quite a bit of power.  Similarly GSM modems are quite power hungry, especially when they are far from a cell tower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put those together and you have quite large power requirements - so the battery will consequently be relatively large.  Many times the size of the circuit you designed above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you're trying to make something that James Bond might stick on the back of someone's jumper without them noticing you're very much out of luck I'm afraid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is why most tracking of people is done using a larger device that most people have sat in their pocket already: a mobile phone.  You can already get software for most phones that will allow you to track your children.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-15T19:29:26.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16865" PostTypeId="1" AcceptedAnswerId="16867" CreationDate="2015-10-15T19:35:12.733" Score="1" ViewCount="278" Body="&lt;p&gt;How can i send numbers like 300 or 1024 ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the recommendation of the atmel's manual.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SpiTransmitir(unsigned char data)&#xA;{&#xA;   SPDR = data;&#xA;   while(!(SPSR &amp;amp; (1&amp;lt;&amp;lt;SPIF)));//{Serial.println(&quot;While&quot;);}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I imagined that one bit shift could be the solution, but it still fails.&lt;/p&gt;&#xA;" OwnerUserId="10229" LastActivityDate="2015-10-16T11:31:53.390" Title="Send numbers bigger than 256 by SPI" Tags="|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16866" PostTypeId="1" CreationDate="2015-10-15T19:35:29.890" Score="0" ViewCount="4019" Body="&lt;p&gt;I'm having some trouble getting my arduino uno to communicate with a simple python script through pyserial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets start with my arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;byte i = 0;&#xA;void loop() {&#xA;  Serial.println(i);&#xA;  i = i + 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Really dead simple. It just spews the numbers from 0 to 255 over and over again. It works fine in the arduino serial monitor and gets me the expected result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The python script comes from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Python&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Interfacing/Python&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;ser = serial.Serial('/dev/ttyUSB0', 9600)&#xA;while True:&#xA;    print ser.readline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However running this script gets me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ python test.py &#xA;Traceback (most recent call last):&#xA;  File &quot;test.py&quot;, line 4, in &amp;lt;module&amp;gt;&#xA;    print ser.readline()&#xA;  File &quot;/usr/lib/python2.7/dist-packages/serial/serialposix.py&quot;, line 460, in read&#xA;    raise SerialException('device reports readiness to read but returned no data (device disconnected?)')&#xA;serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using ubuntu 14.04 and python-serial_2.6-1build1_all.deb&lt;/p&gt;&#xA;" OwnerUserId="14057" LastActivityDate="2016-04-21T02:19:12.223" Title="pySerial and serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)" Tags="|arduino-uno|serial|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16867" PostTypeId="2" ParentId="16865" CreationDate="2015-10-15T19:42:40.190" Score="1" Body="&lt;p&gt;You need to send two bytes - a high byte and a low byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two things you need to know with SPI:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You must wait for one byte to finish transmitting before you send the next&lt;/li&gt;&#xA;&lt;li&gt;The whole transaction needs to be wrapped with a digital &lt;em&gt;chip select&lt;/em&gt; signal.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So you have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Chip Select idles HIGH&lt;/li&gt;&#xA;&lt;li&gt;You lower Chip Select&lt;/li&gt;&#xA;&lt;li&gt;You send one byte&lt;/li&gt;&#xA;&lt;li&gt;You send the other byte&lt;/li&gt;&#xA;&lt;li&gt;You raise chip select&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At the receiver you:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Wait for chip select to go low&lt;/li&gt;&#xA;&lt;li&gt;Receive one byte&lt;/li&gt;&#xA;&lt;li&gt;Receive a second byte&lt;/li&gt;&#xA;&lt;li&gt;Chip Select rises&lt;/li&gt;&#xA;&lt;li&gt;You combine the two bytes together into one integer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-15T19:42:40.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16868" PostTypeId="2" ParentId="16862" CreationDate="2015-10-15T20:30:51.627" Score="0" Body="&lt;p&gt;In addition to @Majenko's post, you will save considerable power by turning the GPS &amp;amp; GSM off when not needed - for example, you might decide that once per minute, or once per 5 minutes is enough (maybe send it a text to trigger &quot;continuous mode&quot;?). Once the Arduino has switched off the other devices, it can go into &quot;sleep&quot; mode for a while. Check out Nick Gammon's excellent treatise on power saving modes at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can save both power and size by replacing an entire Arduino with an ATTiny - prototype on an Arduino first, then once it's working, move to an AtTiny - they have fewer pins, less memory, and are cheaper &amp;amp; smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt you could get the size smaller than a small cellphone, which can be had for very little - $35ish plus shipping, from &lt;a href=&quot;http://www.aliexpress.com/item/Cheap-original-Mobile-phone-LG-Optimus-One-P500-WIFI-GPS-JAVA-Android-OS-Unlocked-Mobile-Phone/32274282341.html?spm=2114.01020208.3.1.zgFwLV&amp;amp;ws_ab_test=searchweb201556_1,searchweb201527_3_71_72_73_74_75,searchweb201560_9&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/Cheap-original-Mobile-phone-LG-Optimus-One-P500-WIFI-GPS-JAVA-Android-OS-Unlocked-Mobile-Phone/32274282341.html?spm=2114.01020208.3.1.zgFwLV&amp;amp;ws_ab_test=searchweb201556_1,searchweb201527_3_71_72_73_74_75,searchweb201560_9&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-15T20:30:51.627" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16869" PostTypeId="2" ParentId="16696" CreationDate="2015-10-15T20:31:39.657" Score="1" Body="&lt;p&gt;... and here's my minimal working example for the Arduino. Feel free to adapt it for your own requirements, and please post any improvements or corrections to my script; or any alternative algorithms for the above.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just noticed that my approach of using the SD to define and exclude outliers is a little more (? unnecessarily) complex than John's algorithm, which defines outliers in terms of the highest and lowest values from the mean; but both methods seem to work nicely.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUFFER 5 // Buffer size (number of readings to use in rolling Mean)&#xA;#define SENSORPIN 3 // Analogue input pin from sensor&#xA;int data[BUFFER]; // Make an array of appropriate size for Buffer&#xA;&#xA;void setup() {&#xA;  pinMode(SENSORPIN, INPUT);&#xA;&#xA;  // Fill buffer with initial data&#xA;  int n = 0;&#xA;  while (n &amp;lt; BUFFER) {&#xA;    data[n] = analogRead(SENSORPIN);&#xA;    n++;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // Calculate Raw Mean &amp;amp; SD&#xA;  float datasum = 0;&#xA;  float diffsum = 0;&#xA;  for (int n = 0; n &amp;lt; BUFFER; n++) {&#xA;    datasum += data[n];&#xA;  }&#xA;  float mean = float(datasum / BUFFER);&#xA;  for (int n = 0; n &amp;lt; BUFFER; n++) {&#xA;    diffsum += ((data[n] - mean) * (data[n] - mean));&#xA;  }&#xA;  float sd = sqrt(diffsum / (BUFFER - 1));&#xA;&#xA;  // Recalculate Corrected Mean only using data within range +/- 1SD of Raw Mean&#xA;  if (sd != 0) {      // Avoid divide by zero error if sd = 0&#xA;    float newSum = 0; // Sum of readings within acceptable range&#xA;    float newLen = 0; // Number of readings within acceptable range&#xA;    int n = 0;&#xA;    while (n &amp;lt; BUFFER) {&#xA;      if ((data[n] &amp;lt; (mean + sd)) and (data[n] &amp;gt; (mean - sd))) {&#xA;        newSum += data[n];&#xA;        newLen ++;&#xA;      }&#xA;      n++;&#xA;    }&#xA;    mean = newSum / newLen; // Corrected Mean&#xA;  }&#xA;&#xA;  // Add your code here to do stuff with variable float 'mean' = the (Corrected) Mean&#xA;&#xA;  // Read new sensor reading, append to buffer and delete oldest reading&#xA;  for (int n = (BUFFER - 1); n &amp;gt; 0; n--) {&#xA;    data[n] = data[n - 1];    &#xA;  }&#xA;  data[0] = analogRead(SENSORPIN);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13929" LastActivityDate="2015-10-15T20:31:39.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16870" PostTypeId="1" AcceptedAnswerId="16916" CreationDate="2015-10-15T21:38:02.447" Score="1" ViewCount="201" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/JChristensen/Button&quot; rel=&quot;nofollow&quot; title=&quot;JChristensen&amp;#39;s Button Library&quot;&gt;JChristensen's Button Library&lt;/a&gt; to debounce my buttons and provide extra functionality.  I'm trying to use his press &amp;amp; hold function to do something if the button is pressed and held for greater than 2 seconds.  If it is just pressed momentarily it should do something else.  His example use switch cases, and I couldn't get it to work.  Here is my example that currently doesn't work.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;Button.h&amp;gt;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;printf.h&amp;gt;&#xA;&#xA;    // Keypress state setup&#xA;    byte clearPin = 16; // Clear pin&#xA;&#xA;    #define PULLUP true&#xA;    #define INVERT true // Since the pullup resistor will keep the pin high  unless the&#xA;    #define DEBOUNCE_MS 20 // A debounce time of 20 milliseconds usually works well for tactile button switches.&#xA;    #define LONG_PRESS 2000 // We define a &quot;long press&quot; to be 2000 milliseconds.&#xA;    unsigned long ms; // The current time from millis()&#xA;    Button clearBtn(clearPin, PULLUP, INVERT, DEBOUNCE_MS); // Declare the button&#xA;    int score=1;&#xA;&#xA;void setup () &#xA;{&#xA;  pinMode(16, INPUT_PULLUP); // Pin for clear button&#xA;  Serial.begin(9600); // Radio Setup&#xA;}    &#xA;&#xA;void loop()&#xA;{&#xA; clearScore(); // sets both home and away scores to 0 or enters settings menu&#xA;}&#xA;&#xA;void clearScore()&#xA;{&#xA;  ms = millis(); //record the current time&#xA;  clearBtn.read(); // Read the button&#xA;&#xA;  if (clearBtn.pressedFor(2000)) {&#xA;    // Enter settings menu&#xA;     Serial.println(&quot;Settings Menu&quot;);&#xA;     while (clearBtn.read()!=1) {&#xA;&#xA;     } // End While&#xA;   return; // Hopefully not proceed down to the next if&#xA;  }&#xA;  if (clearBtn.wasReleased() &amp;amp;&amp;amp; !clearBtn.pressedFor(2000)) {&#xA;    score=0;&#xA;    Serial.println(&quot;Clearing Scores&quot;);&#xA;    delay(50); &#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help please?  My serial output repeats &quot;Settings Menu&quot; over and over.  Once I let go of the button &lt;s&gt;variable1&lt;/s&gt; always gets set to 0.&lt;/p&gt;&#xA;" OwnerUserId="14060" LastEditorUserId="3917" LastEditDate="2015-10-17T03:10:09.673" LastActivityDate="2015-10-19T14:53:23.440" Title="Help with button library, hold&gt;2s doA else doB" Tags="|c++|button|debounce|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16871" PostTypeId="1" CreationDate="2015-10-16T00:26:45.773" Score="0" ViewCount="363" Body="&lt;p&gt;I'm new to Arduino. When Arduino verifies this sketch &lt;a href=&quot;https://github.com/MediaTek-Labs/Real-Time-Bicycle-Tracking-Map-using-PubNub&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MediaTek-Labs/Real-Time-Bicycle-Tracking-Map-using-PubNub&lt;/a&gt; throws the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;BikeTracker.ino: In function 'void setup()':&#xA;BikeTracker.ino:45:5: error: 'PubNub' was not declared in this scope&#xA;BikeTracker.ino: In function 'void loop()':&#xA;BikeTracker.ino:91:14: error: 'PubNub' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've read most answers are pointing out to www.arduino.cc/en/Guide/Libraries some people say it's common Arduino linking issue (easy to fix) after tried out multiple approaches with no dice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also followed PubNub customer support advice (with list of steps below) but no avail:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;OCT 12, 2015  |  10:23AM PDT  PubNub replied: Eduardo,&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I got this from our hardware/IoT/embedded engineer:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You are probably not including all the libraries, or has the wrong&#xA;  path for them.&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;When you download the source at&#xA;  MediaTek-Labs/Real-Time-Bicycle-Tracking-Map-using-PubNub on GitHub:&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Click .ino file and a pop up will ask if you need a new folder for the&#xA;  sketch – click Yes. &lt;/li&gt;&#xA;  &lt;li&gt;Then copy the rest of the files from the source to&#xA;  this new folder. &lt;/li&gt;&#xA;  &lt;li&gt;Compile it and see if you get any library path errors&#xA;  that you need to provide. Let me know if you require further&#xA;  assistance.&lt;/li&gt;&#xA;  &lt;/ul&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;BTW this is my PubNub.h &lt;a href=&quot;https://gist.github.com/egomez99/fb1d738ec39913629e9a&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/egomez99/fb1d738ec39913629e9a&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can shed some lights. &lt;/p&gt;&#xA;" OwnerUserId="14061" LastEditorUserId="14061" LastEditDate="2015-10-16T23:43:25.923" LastActivityDate="2016-02-17T03:48:26.107" Title="Arduino: Error: 'PubNub' was not declared in this scope" Tags="|arduino-ide|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16872" PostTypeId="2" ParentId="61" CreationDate="2015-10-16T01:58:34.497" Score="44" Body="&lt;p&gt;Plenty of options exist in the world of electronics simulators, but &lt;a href=&quot;https://www.tinkercad.com/learn/circuits&quot; rel=&quot;noreferrer&quot;&gt;circuits.io aka TinkerCAD&lt;/a&gt; is probably the most versatile one out there.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can compose your circuit on a virtual breadboard which looks just like real.&lt;/li&gt;&#xA;&lt;li&gt;You can actually watch a LED blinking or press a button during real-time simulation rather than struggling with abstract waveforms.&lt;/li&gt;&#xA;&lt;li&gt;You can combine digital devices like a 555 timer or shift registers with (interactive) analog components like resistors and LEDs.&lt;/li&gt;&#xA;&lt;li&gt;You can program an Arduino and simulate the microcontroller together with your analog circuit around it.&lt;/li&gt;&#xA;&lt;li&gt;You can debug an Arduino: when the simulator reaches your breakpoint, the simulation is paused and you can easily check every variable in your code and every voltage or current in your circuit.&lt;/li&gt;&#xA;&lt;li&gt;You can use and observe different communication protocols like UART, I2C and SPI.&lt;/li&gt;&#xA;&lt;li&gt;You can pause the simulation in the middle of an I2C sequence by putting a breakpoint in the driver code (e.g. interrupt service routine for I2C events)&lt;/li&gt;&#xA;&lt;li&gt;It's FREE!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XIkP1.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XIkP1.png&quot; alt=&quot;Example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is an example circuit that has with an IR Remote and an LCD Screen.&lt;/p&gt;&#xA;&lt;p&gt;Disclaimer: We are the makers of 123D Circuits&lt;/p&gt;&#xA;" OwnerUserId="14062" LastEditorUserId="35430" LastEditDate="2020-06-28T19:04:52.040" LastActivityDate="2020-06-28T19:04:52.040" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="16873" PostTypeId="2" ParentId="16858" CreationDate="2015-10-16T02:13:22.313" Score="2" Body="&lt;p&gt;Basically you just need to change the HIGH's by LOW's and the LOW's by HIGH's.&lt;/p&gt;&#xA;" OwnerUserId="13671" LastActivityDate="2015-10-16T02:13:22.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16874" PostTypeId="2" ParentId="16855" CreationDate="2015-10-16T02:14:43.153" Score="1" Body="&lt;p&gt;You can use the Sparkfun data project:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://data.sparkfun.com/&quot; rel=&quot;nofollow&quot;&gt;https://data.sparkfun.com/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;they build an open source tool called &lt;code&gt;phant&lt;/code&gt; (&lt;a href=&quot;https://github.com/sparkfun/phant&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sparkfun/phant&lt;/a&gt;) that you use to host on your own or use their free version online&lt;/p&gt;&#xA;" OwnerUserId="14063" LastActivityDate="2015-10-16T02:14:43.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16875" PostTypeId="2" ParentId="16858" CreationDate="2015-10-16T02:15:54.563" Score="-1" Body="&lt;p&gt;You can easily test this in 123D Circuits, check this out:&#xA;&lt;a href=&quot;https://123d.circuits.io/circuits/1019227-7-segment-circuit&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://123d.circuits.io/circuits/1019227-7-segment-circuit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Click start simulation and then click on the buttons to light up the corresponding segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u4dZO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u4dZO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14062" LastActivityDate="2015-10-16T02:15:54.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16876" PostTypeId="2" ParentId="16269" CreationDate="2015-10-16T03:28:52.150" Score="1" Body="&lt;p&gt;I've had similar issues with large (&gt; 1Gb) SD cards, I've had various different problems with different cards, some things that helped me debugging the problem:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make sure your wires are the same length and try to use &lt;strong&gt;short wires&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;make sure your power supply is sufficient, sd card readers can draw up to &lt;code&gt;150mA&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;format the card in either &lt;code&gt;FAT16&lt;/code&gt; or &lt;code&gt;FAT32&lt;/code&gt; and never use &quot;quick erase&quot;, try to use official tools (like &lt;a href=&quot;https://www.sdcard.org/downloads/formatter_4/index.html&quot; rel=&quot;nofollow&quot;&gt;https://www.sdcard.org/downloads/formatter_4/index.html&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;make sure if you're the correct &lt;code&gt;BAUD rate&lt;/code&gt; (9600) to talk to your card&lt;/li&gt;&#xA;&lt;li&gt;filename support is pretty old so keep them short and don't use spaces or special characters&lt;/li&gt;&#xA;&lt;li&gt;make sure the SD card is not in &quot;&lt;strong&gt;write lock&lt;/strong&gt;&quot; mode, there's a small switch on the side of some SD cards that can prohibit writing (but will allow reading)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14063" LastActivityDate="2015-10-16T03:28:52.150" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16878" PostTypeId="1" AcceptedAnswerId="19582" CreationDate="2015-10-16T03:56:33.127" Score="0" ViewCount="5192" Body="&lt;p&gt;I'm completely new to Arduino and do not have an electronics background.&#xA;I'm really keen to do a POC on home automation. As a start, I decided to switch on a tube light using ESP8266, Arduino Uno R3 and isolated relay. I have read that this can be done without arduino also.&lt;/p&gt;&#xA;&lt;p&gt;I'm able to switch on and switch off the relay without any problem. But when the relay is connected to the tube light, the ESP8266 stops responding. I couldn't find what was causing the issue.&lt;/p&gt;&#xA;&lt;p&gt;I also read that the ESP2866 should be powered properly to function correctly. I'm following the wiring schema 5 mentioned in the link &lt;a href=&quot;http://yaab-arduino.blogspot.in/2015/03/esp8266-wiring-schemas.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://yaab-arduino.blogspot.in/2015/03/esp8266-wiring-schemas.html&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2ic8q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2ic8q.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is my code.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define DEBUG true&#xA;int relay = 8;&#xA;SoftwareSerial esp8266(2, 3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;// This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;// and the RX line from the esp to the Arduino's pin 3&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(115200); // your esp's baud rate might be different&#xA;  pinMode(relay, OUTPUT);&#xA;  digitalWrite(relay, LOW);&#xA;&#xA;  sendData(&amp;quot;AT+RST\r\n&amp;quot;, 2000, DEBUG); // reset module&#xA;  sendData(&amp;quot;AT+CWMODE=3\r\n&amp;quot;, 1000, DEBUG); // configure as access point&#xA;  sendData(&amp;quot;AT+CWJAP=\&amp;quot;xxxx\&amp;quot;,\&amp;quot;xxx\&amp;quot;\r\n&amp;quot;, 5000, DEBUG); // configure as access point&#xA;&#xA;  sendData(&amp;quot;AT+CIPMUX=1\r\n&amp;quot;, 1000, DEBUG); // configure for multiple connections&#xA;  sendData(&amp;quot;AT+CIPSERVER=1,80\r\n&amp;quot;, 1000, DEBUG); // turn on server on port 80&#xA;  sendData(&amp;quot;AT+CIFSR\r\n&amp;quot;, 5000, DEBUG); // get ip address&#xA;  sendData(&amp;quot;AT+CIFSR\r\n&amp;quot;, 5000, DEBUG); // get ip address&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (esp8266.available()) // check if the esp is sending a message&#xA;  {&#xA;&#xA;    if (esp8266.find(&amp;quot;+IPD,&amp;quot;))&#xA;    {&#xA;      delay(1000);&#xA;&#xA;      int connectionId = esp8266.read() - 48; // subtract 48 because the read() function returns&#xA;      // the ASCII decimal value and 0 (the first decimal number) starts at 48&#xA;&#xA;      if (esp8266.find(&amp;quot;==&amp;quot;))&#xA;      {&#xA;        Serial.print(&amp;quot;State : &amp;quot;);&#xA;        char c = esp8266.read();&#xA;        Serial.print(c);&#xA;        if (c == '1') {&#xA;          digitalWrite(relay, HIGH);&#xA;        }&#xA;        else {&#xA;          digitalWrite(relay, LOW);&#xA;        }&#xA;      }&#xA;      String webpage = &amp;quot;A&amp;quot;;&#xA;&#xA;      String cipSend = &amp;quot;AT+CIPSEND=&amp;quot;;&#xA;      cipSend += connectionId;&#xA;      cipSend += &amp;quot;,&amp;quot;;&#xA;      cipSend += webpage.length();&#xA;      cipSend += &amp;quot;\r\n&amp;quot;;&#xA;&#xA;      sendData(cipSend, 1000, DEBUG);&#xA;      sendData(webpage, 1000, DEBUG);&#xA;&#xA;&#xA;      String closeCommand = &amp;quot;AT+CIPCLOSE=&amp;quot;;&#xA;      closeCommand += connectionId; // append connection id&#xA;      closeCommand += &amp;quot;\r\n&amp;quot;;&#xA;&#xA;      sendData(closeCommand, 3000, DEBUG);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;String sendData(String command, const int timeout, boolean debug)&#xA;{&#xA;  String response = &amp;quot;&amp;quot;;&#xA;&#xA;  esp8266.print(command); // send the read character to the esp8266&#xA;&#xA;  long int time = millis();&#xA;&#xA;  while ( (time + timeout) &amp;gt; millis())&#xA;  {&#xA;    while (esp8266.available())&#xA;    {&#xA;&#xA;      // The esp has data so display its output to the serial window&#xA;      char c = esp8266.read(); // read the next character.&#xA;      response += c;&#xA;    }&#xA;  }&#xA;&#xA;  if (debug)&#xA;  {&#xA;    Serial.print(response);&#xA;  }&#xA;&#xA;  return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above code works perfectly until I connect the tube light to the relay.&#xA;The power supply used in 9v 1A wall adapter.&lt;/p&gt;&#xA;&lt;p&gt;The relay used is &lt;a href=&quot;http://www.amazon.in/gp/product/B00LL0M6RS?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o03_s00&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.in/gp/product/B00LL0M6RS?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o03_s00&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The v+ of the relay is connected directly to the wall adapters voltage and ground to ground of wall adapter. The input of the relay is connected to Arduino digital pin 8.&lt;/p&gt;&#xA;&lt;p&gt;I'm really struggling hard to proceed here. Any help or hint would be much appreciated.&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="12116" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-15T05:27:47.097" Title="ESP8266 stops responding when isolated relay is connected to AC tubelight" Tags="|arduino-uno|esp8266|relay|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16880" PostTypeId="1" AcceptedAnswerId="16882" CreationDate="2015-10-16T05:51:54.917" Score="0" ViewCount="150" Body="&lt;p&gt;Recently I knew, that Arduino restarts any time somebody accesses it's serial port. I was trying to use this feature so that for each request Arduino restarts and give answer on request. Unfortunately, I found this is impossible with shell script, because shell script can't keep port open all time I send requests and wait responses: Arduino restarts on each port touch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I wrote simple C++ program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;fstream&amp;gt;&#xA;&#xA;using namespace std;&#xA;&#xA;void help() {&#xA;    cout &amp;lt;&amp;lt; &quot;bmp180dims usage:&quot; &amp;lt;&amp;lt; endl &amp;lt;&amp;lt;&#xA;            &quot;bmp180dims port command&quot; &amp;lt;&amp;lt; endl;&#xA;}&#xA;&#xA;int main(int argc, char* argv[]) {&#xA;&#xA;    if( argc != 3 ) {&#xA;        help();&#xA;        return 0;&#xA;    }&#xA;&#xA;    fstream port;&#xA;    string answer;&#xA;&#xA;    port.open(argv[1], std::fstream::in | std::fstream::out);&#xA;&#xA;    port &amp;lt;&amp;lt; argv[2] &amp;lt;&amp;lt; endl;&#xA;&#xA;    port &amp;gt;&amp;gt; answer;&#xA;&#xA;    cout &amp;lt;&amp;lt; answer &amp;lt;&amp;lt; endl;&#xA;&#xA;    port.close();&#xA;&#xA;    return 0;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since this program has explicit &lt;code&gt;open&lt;/code&gt; and &lt;code&gt;close&lt;/code&gt; statements, I was thinking, this program will wait for Arduino answer, because of stream reading functions. But I failed again: this program returns nothing as if it is not waiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently, the only way to communicate with Arduino, is to have daemon program, which always listen it's port. Is this really so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino-side code is here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/16769/how-can-program-arduino-restarted-by-ide&quot;&gt;How can program/arduino restarted by IDE?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-16T20:51:12.373" Title="How to wait Arduino ready with ANY method?" Tags="|usb|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16882" PostTypeId="2" ParentId="16880" CreationDate="2015-10-16T09:50:58.123" Score="2" Body="&lt;p&gt;Again, you're &lt;em&gt;not waiting for the bootloader to complete&lt;/em&gt; before sending your text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;port.open(argv[1], std::fstream::in | std::fstream::out);&#xA;// Board resets and enters bootloader&#xA;&#xA;port &amp;lt;&amp;lt; argv[2] &amp;lt;&amp;lt; endl;&#xA;// You send argv[2] to the bootloader&#xA;&#xA;port &amp;gt;&amp;gt; answer;&#xA;// The bootloader doesn't understand what you sent so doesn't reply with anything&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;must&lt;/em&gt; wait for the bootloader to complete &lt;em&gt;before&lt;/em&gt; sending ANYTHING to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two ways you can do that are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Insert a &lt;code&gt;sleep(3);&lt;/code&gt; immediately after opening the port to give the bootloader a chance to time out and start running your sketch, or&lt;/li&gt;&#xA;&lt;li&gt;Provide an initial &quot;I Am Ready&quot; message from your sketch that your C++ program waits for &lt;em&gt;before&lt;/em&gt; sending the text you want to send to elicit an answer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-16T09:50:58.123" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16883" PostTypeId="2" ParentId="16865" CreationDate="2015-10-16T11:31:53.390" Score="0" Body="&lt;p&gt;Try to join the numbers as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NUMERO 342&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(NUMERO, BIN); // Mostra valor do número em binário&#xA;&#xA;  uint8_t MSB = 0, LSB = 0; // Dois números de 8 bits&#xA;&#xA;  uint16_t junta = 0; // Valor junto em 16 bits&#xA;&#xA;  MSB = NUMERO &amp;gt;&amp;gt; 4;&#xA;  LSB = NUMERO &amp;lt;&amp;lt; 4;&#xA;&#xA;&#xA;  junta = (MSB &amp;lt;&amp;lt; 4) | (LSB &amp;gt;&amp;gt; 4) ;&#xA;&#xA;  Serial.println(junta, BIN);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-10-16T11:31:53.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16884" PostTypeId="1" CreationDate="2015-10-16T12:12:24.473" Score="0" ViewCount="91" Body="&lt;p&gt;This might be a bit of off topic but I have nowhere else to go. :-) I have programmed motion detection with ardruino and would like to integrate it with my home automation system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would like to install the PIR in the ceiling of the entrance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that all low voltage PIRs for ardruino are sold without any case (just a board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it mean I have to buy a regular PIR (with relay integrated) and modify it?&lt;/p&gt;&#xA;" OwnerUserId="14074" LastActivityDate="2016-02-16T16:41:04.873" Title="Where do I get motion detector for ardruino that can actually be installed in ceiling?" Tags="|arduino-yun|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16885" PostTypeId="2" ParentId="16878" CreationDate="2015-10-16T13:40:25.753" Score="0" Body="&lt;p&gt;I suspect that you've connected the relay wrong. I think that the LNP of the relay is supposed to be connected to D8 and the v+ to 5/3.3V and GND to GND....&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-10-16T13:40:25.753" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16887" PostTypeId="2" ParentId="9106" CreationDate="2015-10-16T14:19:10.777" Score="4" Body="&lt;p&gt;Might be a little late, but you can string more than two of these on one I2C bus, with a little ingenuity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You connect the AD0 pin of each MPU to a different I/O pin of the processor, then take low the address of the one MPU you want to talk to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then that MPU has one address, all the others have the other address, and being slaves will not respond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Provided you don't have more than one MPU selected at once, works a dream.&lt;/p&gt;&#xA;" OwnerUserId="14081" LastEditorUserId="10794" LastEditDate="2015-10-17T05:25:14.610" LastActivityDate="2015-10-17T05:25:14.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16892" PostTypeId="2" ParentId="16884" CreationDate="2015-10-16T15:50:41.780" Score="1" Body="&lt;p&gt;This might not be quite the answer you were looking for, but...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3D print your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect you haven't got a 3D printer but you can find someone on &lt;a href=&quot;http://www.3dhubs.com/&quot; rel=&quot;nofollow&quot;&gt;3D hubs&lt;/a&gt; to print it for you, and you might not even have to design the case because &lt;a href=&quot;http://www.thingiverse.com/search?q=pir%20sensor&amp;amp;sa=&quot; rel=&quot;nofollow&quot;&gt;thingiverse has a few already&lt;/a&gt;...&lt;/p&gt;&#xA;" OwnerUserId="14085" LastActivityDate="2015-10-16T15:50:41.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16893" PostTypeId="1" CreationDate="2015-10-16T16:01:58.260" Score="3" ViewCount="6360" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;GPRS shield&lt;/strong&gt;&lt;/a&gt; connected to an &lt;strong&gt;arduino uno&lt;/strong&gt; board, i want to use the shield to send sms and do &lt;strong&gt;phone calls&lt;/strong&gt;, from a &lt;strong&gt;C#&lt;/strong&gt; Wpf application, the &lt;strong&gt;arduino&lt;/strong&gt; is connected to the application using the serial port, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do that I've upload the following &lt;strong&gt;sketch&lt;/strong&gt; to the &lt;strong&gt;arduino&lt;/strong&gt; board:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; &#xA;&#xA;SoftwareSerial GPRS(7, 8);&#xA;unsigned char buffer[64]; // buffer array for data recieve over serial port&#xA;int count=0;     // counter for buffer array &#xA;void setup()&#xA;{&#xA;  GPRS.begin(9600);               // the GPRS baud rate   &#xA;  Serial.begin(9600);             // the Serial port of Arduino baud rate.     &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (GPRS.available())              // if date is comming from softwareserial port ==&amp;gt; data is comming from gprs shield&#xA;  {&#xA;    while(GPRS.available())          // reading data into char array &#xA;    {&#xA;      buffer[count++]=GPRS.read();    &#xA;      if(count == 64)break;&#xA;    }&#xA;    Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port&#xA;    clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array&#xA;    count = 0;                       // set counter of while loop to zero &#xA;  }&#xA;  if (Serial.available())            // if data is available on hardwareserial port ==&amp;gt; data is comming from PC or notebook&#xA;    GPRS.write(Serial.read());       // write it to the GPRS shield&#xA;}&#xA;void clearBufferArray()              // function to clear buffer array&#xA;{&#xA;  for (int i=0; i&amp;lt;count;i++)&#xA;    { buffer[i]=NULL;}                  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;every thing works perfectly when sending &lt;strong&gt;AT commands&lt;/strong&gt; to the shield using the &lt;strong&gt;Serial Monitor&lt;/strong&gt;, for example to dial a call this is all what i need to do &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JzBnh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JzBnh.png&quot; alt=&quot;ATD Command&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this works perfectly, but when trying to do the same thing from c# application, nothing happened !&#xA;here how i send the AT command from the code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private readonly SerialPort _serialPort;&#xA;public void Callphone(string number)&#xA;{&#xA;    _serialPort.Open();&#xA;    _serialPort.Write(&quot;ATD + +&quot; + number +&quot;;&quot;);&#xA;    Thread.Sleep(100);&#xA;    _serialPort.Close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: sending sms works fine from the serial port, using the same way :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; public void SendSms(string number, string message)&#xA;    {&#xA;        _serialPort.Open();&#xA;        _serialPort.Write(&quot;AT+CMGF=1\r&quot;);&#xA;        Thread.Sleep(SleepTimeStamp);&#xA;        _serialPort.Write(&quot;AT+CSCA=\&quot;&quot; + MessageCenterNumber + &quot;\&quot;\r&quot;);&#xA;        Thread.Sleep(SleepTimeStamp);&#xA;        _serialPort.Write(&quot;AT+CMGS=\&quot;&quot; + number + &quot;\&quot;\r&quot;);&#xA;        Thread.Sleep(SleepTimeStamp);&#xA;        _serialPort.Write(message + &quot;\x1A&quot;);&#xA;&#xA;        Thread.Sleep(SleepTimeStamp);&#xA;        _serialPort.Close();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am i missing something ?&lt;/p&gt;&#xA;" OwnerUserId="14084" LastEditorUserId="14084" LastEditDate="2015-10-16T20:04:54.537" LastActivityDate="2015-10-16T20:04:54.537" Title="Sending AT commands to a gprs shield using serial port" Tags="|arduino-uno|shields|gsm|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16895" PostTypeId="1" CreationDate="2015-10-16T19:09:42.617" Score="3" ViewCount="147" Body="&lt;p&gt;I am building a fan controller using an Arduino and a Raspberry Pi (the Pi is the master and the Arduino is the slave). The Raspberry Pi generates random numbers and I want the slave (Arduino) to be able to read the string of numbers and increase the current speed of a pwm fan by the amount read.&lt;br&gt;&#xA;How I can read the bits sent over I2c as numbers to allow me to do what I want to do?&lt;/p&gt;&#xA;" OwnerUserId="14090" LastEditorUserId="56216" LastEditDate="2019-05-07T03:57:32.403" LastActivityDate="2019-05-07T03:57:32.403" Title="How can I send a number from a master and make the slave read it?" Tags="|i2c|raspberrypi|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="16900" PostTypeId="2" ParentId="11990" CreationDate="2015-10-17T03:18:10.003" Score="0" Body="&lt;p&gt;Yes!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the simpler image replace R2 with a 10 Ohm resistor and Q1 with a N channel Logic Level FET.  This will allow  you to switch (PWM) amps with R1 removed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My LED strips pull about 3 amps at 12V. Depending on the FET you use you may have to add a heat sink.  You will need to connect the low side (Ground) on the Arduino power supply to the low side on the power supply for the LED strip.  The Arduino can then operate at 5 volts and the LED at 24V or whatever depends on the rating of the MOSFET.  I would suggest using one of the PWM outputs, they will work fine with this circuit.  This works for motors but additional parts will need to be added.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enjoy.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-17T03:18:10.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16901" PostTypeId="1" CreationDate="2015-10-17T06:22:51.173" Score="0" ViewCount="1558" Body="&lt;p&gt;I am using pressure sensor with Arduino Uno within Processing.&#xA;Given these variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial myPort;              //the serial port&#xA;float sensorValue = 0;      //the value form the sensor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino is printing float numbers on Processing console, according to the snippet below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(...)&#xA;&#xA;void serialEvent (Serial myPort){&#xA;//get the ASCII string&#xA;String inString = myPort.readStringUntil('\n');&#xA;&#xA;if (inString != null){&#xA;//trim off any whitespace:&#xA;inString = trim(inString);&#xA;//convert to an int and map to the screen height&#xA;sensorValue = float(inString);&#xA;println(sensorValue);&#xA;sensorValue = map(sensorValue, 0, 1023, 0, height);&#xA;//println(sensorValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I am getting a &lt;code&gt;NaN&lt;/code&gt; exception: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sensorValue = map(NaN, 0, 1023, 0, height);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how is this possible? printing numbers that aren't numbers?&lt;/p&gt;&#xA;" OwnerUserId="14041" LastEditorUserId="14041" LastEditDate="2015-10-17T06:30:14.777" LastActivityDate="2015-11-16T10:37:02.757" Title="Processing printing sensor readings and raising NaN exception at the same time" Tags="|arduino-uno|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16902" PostTypeId="2" ParentId="16901" CreationDate="2015-10-17T09:38:16.377" Score="1" Body="&lt;p&gt;//convert to an int and map to the screen height&#xA;sensorValue = float(inString);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't convert a String to a Float just like that by casting.  You have to interpret the characters within the String.  Oh, and a float isn't an integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you're doing there is trying to cast the address of the String object to a float, which it really doesn't like, hence you get NaN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue;&#xA;sensorValue = inString.toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-17T09:38:16.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16903" PostTypeId="1" CreationDate="2015-10-17T09:46:35.020" Score="2" ViewCount="311" Body="&lt;h1&gt;backgrounds&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I bought arduino leonardo and connect it to Ubuntu 15.04.&lt;br&gt;&#xA;With arduino IDE 1.0.5(from Ubuntu official repo) running in &lt;code&gt;sudo&lt;/code&gt;, the arduino was recognized as &lt;code&gt;/dev/ttyACM0&lt;/code&gt;.&lt;br&gt;&#xA;So I tried to upload sample sketch &lt;code&gt;Blink&lt;/code&gt; to the port ttyACM0 with settings of Leonardo, but every time I tried to upload IDE said that serial port is wrong. and then actually leonardo was recognized as ttyACM1. If I set ttyACM1 and retry, leonardo moved to ttyACM2; and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I searched some websites and installed &lt;code&gt;oracle-java7-installer&lt;/code&gt; package and &lt;code&gt;Arduino IDE 1.6.5&lt;/code&gt; from official site.&lt;br&gt;&#xA;After doing so and several tries, my leonardo finally stopped to be recognized. no &lt;code&gt;ttyACMx&lt;/code&gt; appears from that time.&lt;br&gt;&#xA;I guessed it's the problem on software environment, so I connected the arduino to Windows7 pc, but device manager also didn't recognize the arduino.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;How my leonardo is now&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Connecting to PC, &quot;ON&quot; LED have turned on and &quot;L&quot; LED blinks each 1 seconds. I guess it's thanks to default bootloader.&#xA;So looks not completely broken or bricked, but still can't access from any PC in normal way.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What I want to be taught&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Is my leonardo broken?&#xA;Is there a way to make it work?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;reply(20151018)&#xA;@Chris Stratton&lt;br&gt;&#xA;Thank you for suggesting! It's good news for me that it doesn't seem to broken.&lt;br&gt;&#xA;I ran &lt;code&gt;lsof | grep ttyACM&lt;/code&gt; and found nothing.&lt;br&gt;&#xA;And about &lt;code&gt;brltty&lt;/code&gt;, Ubuntu has installation of it by default, and &lt;code&gt;sudo service brltty status&lt;/code&gt; says its enabled.&lt;br&gt;&#xA;So I try &lt;code&gt;sudo service brltty stop&lt;/code&gt; and connect my Leonardo, but it still not be recognized. X(&lt;/p&gt;&#xA;" OwnerUserId="14100" LastEditorUserId="-1" LastEditDate="2015-10-23T15:57:57.410" LastActivityDate="2015-10-23T15:57:57.410" Title="Is my leonardo broken? Is there a way to make it work?" Tags="|serial|arduino-ide|arduino-leonardo|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16904" PostTypeId="1" CreationDate="2015-10-17T11:21:20.827" Score="0" ViewCount="2363" Body="&lt;p&gt;I want to control Lego Technic Servo Motor 88004.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way it works is - Lego has a 4 cable connector. Two of them supply power (+9V &amp;amp; GND) and the other are optionally +9V and they are called C1 and C2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo turns right or left max 90 deg when you supply PWM to either C1 (&quot;left&quot;) or C2 (&quot;right&quot;). (or the other way round, but it doesn't really matter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That basically means that what I need is a 9V PWM and be able to supply it to either C1 or C2. What is more the frequency has to be 1150 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the question is how do I achieve this goal? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm already using the L298N motor controller and happen to have one engine slot free. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) If I can supply PWM from Arduino to &quot;LNA&quot; input in L298N - will it also cause the output to be PWM? &#xA;Because L298N has a transistor I have a feeling that the output is also going to be PWM unless there's something else there i.e. capacitor &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if it's not does that matter at all - meaning is it going to still work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) How do I produce PWM with 1150 Hz from Arduino? My Arduino is 16MHz so I suppose that it should be possible to switch output with order of magnitude smaller frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If what I'm trying to do makes no sense please try to point me to the right direction.&lt;/p&gt;&#xA;" OwnerUserId="6466" LastActivityDate="2015-10-17T14:42:57.083" Title="Lego Technic Servo Motor - 9V PWM" Tags="|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16907" PostTypeId="2" ParentId="9680" CreationDate="2015-10-17T13:24:53.643" Score="1" Body="&lt;p&gt;I am not sure if you have found the answer. Here are my observation. Those who are searching for same problem can refer to these...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Change your Android device. Devices will have different bluetooth stack provided by bluetooth chip makers. Cheap ones will have problems. I had this. When I tested with another couple of devices, they seem to have handled it very well. It is all in the bluetooth stack on Android device!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Though I have not had problems with Arduino bluetooth device, try changing that.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Disable all logging on Android app. This will reduce burden on device.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Disable Serial communication on Arduino used for debugging purpose. This way you can make sure that only one serial communication channel is active communicating with Android.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you follow this, surely you will have solved your problem as I have solved the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Sachin&lt;/p&gt;&#xA;" OwnerUserId="14105" LastActivityDate="2015-10-17T13:24:53.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16908" PostTypeId="1" CreationDate="2015-10-17T13:55:15.320" Score="1" ViewCount="7519" Body="&lt;p&gt;I found an LCD for my Arduino Mega 2560 that's parallel (I like that, I don't like SPI), but it works at 3.3V and isn't 5V tolerant. That's why I'd need to use level shifters, but that would use too much space and I'd like to power the microcontroller with 3.3V. But that would cause problems because the USART communication is set to be on 5V and that can't be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to power my Arduino at 3.3V? Is there an alternative Arduino for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if there is, I'd need to have a 16MHz crystal on it. I know it's overclocking, but Gamebuino works at 16MHz on 3.3V and I would like to do the same.&lt;/p&gt;&#xA;" OwnerUserId="13891" LastActivityDate="2015-12-19T14:25:12.670" Title="Need to power Arduino Mega 2560 with 3.3V" Tags="|arduino-mega|voltage-level|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16909" PostTypeId="1" CreationDate="2015-10-17T14:02:45.693" Score="3" ViewCount="240" Body="&lt;p&gt;I am trying to control a dc motor speed with PWM. When I test it with simple program like spin in one direction with set PWM value it works. If PWM&gt;70 the motor will start spinning and max is 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I try to do the same in code below it only spins if PWM value is 255. Can someone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;test.ino&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*--------------------*/&#xA;// encoders&#xA;/*--------------------*/&#xA;//motor_encoder&#xA;int encoder0PinA = 3;&#xA;int encoder0PinB=2;&#xA;volatile int encoder0Count = 0;&#xA;volatile float angle0 = 0;&#xA;volatile float velocity0 = 0;&#xA;volatile float angle0_previous = 0;&#xA;volatile float angle0_post = 0;&#xA;//pendulum_encoder&#xA;int encoder1PinA = 20;&#xA;int encoder1PinB = 21;&#xA;volatile int encoder1Count = 0;&#xA;volatile float angle1 = 0;&#xA;volatile float velocity1 = 0;&#xA;volatile float angle1_previous = 0;&#xA;volatile float angle1_post = 0;&#xA;float error=0;&#xA;/*--------------------*/&#xA;// motor&#xA;/*--------------------*/&#xA;int enA = 10;&#xA;int in1 = 9;&#xA;int in2 = 8;&#xA;/*--------------------*/&#xA;// for Timer2&#xA;/*--------------------*/&#xA;volatile int tcnt2 = 131;&#xA;volatile int t = 0;&#xA;&#xA;volatile float error_proportional = 0;&#xA;volatile float error_derivative = 0;&#xA;volatile float error_integral = 0;&#xA;float kp =50;&#xA;float kd = 0;&#xA;float ki = 0;&#xA;float u = 0;&#xA;float motor_input = 0;&#xA;int INPUT_MAX = 255;&#xA;int P=0;&#xA;int I=0;&#xA;int D=0;&#xA;int integral=0;&#xA;void setup()&#xA;{&#xA;&#xA;  pinMode(enA, OUTPUT);&#xA;  pinMode(in1, OUTPUT);&#xA;  pinMode(in2, OUTPUT);&#xA;&#xA;  /*--------------------*/&#xA;  // for encoder&#xA;  /*--------------------*/  &#xA;  // for encoder 0&#xA;  pinMode(encoder0PinA, INPUT); &#xA;  pinMode(encoder0PinB, INPUT); &#xA;  attachInterrupt(0, doEncoder0A, CHANGE);  &#xA;  attachInterrupt(1, doEncoder0B, CHANGE);  &#xA;  // for encoder 1&#xA;  pinMode(encoder1PinA, INPUT); &#xA;  pinMode(encoder1PinB, INPUT); &#xA;  attachInterrupt(2, doEncoder1A, CHANGE);  &#xA;  attachInterrupt(3, doEncoder1B, CHANGE);    &#xA;&#xA;  /*--------------------*/&#xA;  // for Timer2&#xA;  /*--------------------*/&#xA;  // interrupts every 1 ms&#xA;  TIMSK2 &amp;amp;= ~(1&amp;lt;&amp;lt;TOIE2);&#xA;  TCCR2A &amp;amp;= ~((1&amp;lt;&amp;lt;WGM21) | (1&amp;lt;&amp;lt;WGM20));&#xA;  TCCR2B &amp;amp;= ~(1&amp;lt;&amp;lt;WGM22);&#xA;  ASSR &amp;amp;= ~(1&amp;lt;&amp;lt;AS2);&#xA;  TIMSK2 &amp;amp;= ~(1&amp;lt;&amp;lt;OCIE2A);&#xA;  TCCR2B |= (1&amp;lt;&amp;lt;CS22)  | (1&amp;lt;&amp;lt;CS20);&#xA;  TCCR2B &amp;amp;= ~(1&amp;lt;&amp;lt;CS21);&#xA;  TCNT2 = tcnt2;&#xA;  TIMSK2 |= (1&amp;lt;&amp;lt;TOIE2);&#xA;&#xA;  Serial.begin (9600); // for debugging&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA; error = angle1;&#xA;&#xA; if (abs(error) &amp;lt; 2){ &#xA; integral = integral + error; &#xA; }&#xA; else {&#xA; integral=0; &#xA; }&#xA; P = error*kp;&#xA; I = integral*ki; &#xA; D = (angle1_previous-angle1)*kd; &#xA;  u = P + I + D;&#xA;  motor_input = 255/24 * u; &#xA;&#xA;  Serial.print(&quot;u: &quot;);&#xA;  Serial.print( u);&#xA;  Serial.print(&quot; &quot;);&#xA;  motor_input = (int)motor_input;&#xA;&#xA;  if (motor_input &amp;gt;= INPUT_MAX){&#xA;    motor_input = INPUT_MAX;&#xA;  }&#xA;  else if (motor_input &amp;lt;= -INPUT_MAX){&#xA;    motor_input = -INPUT_MAX;&#xA;  }&#xA;&#xA;  Serial.print(&quot;error_proportional: &quot;);&#xA;  Serial.print(error_proportional);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(&quot;error_derivative: &quot;);&#xA;  Serial.print(error_derivative);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(&quot;error_integral: &quot;);&#xA;  Serial.print(error_integral);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(&quot;motor_input: &quot;);&#xA;  Serial.println(motor_input);&#xA;  setMotorSpeed(motor_input); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;measure_states.ino&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*--------------------*/&#xA;// enkoder od motora&#xA;/*--------------------*/&#xA;void doEncoder0A(){  &#xA;  if (digitalRead(encoder0PinA) == HIGH) { &#xA;    if (digitalRead(encoder0PinB) == LOW) {&#xA;      encoder0Count = encoder0Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder0Count = encoder0Count - 1;&#xA;    }&#xA;  }&#xA;  else {                                     &#xA;    if (digitalRead(encoder0PinB) == HIGH) { &#xA;      encoder0Count = encoder0Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder0Count = encoder0Count - 1;&#xA;    }&#xA;  }&#xA;  angle0 = 0.000785*encoder0Count;  // radian  (2*pi/8000)&#xA;}&#xA;&#xA;void doEncoder0B(){  // interrupt 1 function&#xA;  if (digitalRead(encoder0PinB) == HIGH) {   &#xA;    if (digitalRead(encoder0PinA) == HIGH) { &#xA;      encoder0Count = encoder0Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder0Count = encoder0Count - 1;&#xA;    }&#xA;  }&#xA;  else {                                   &#xA;    if (digitalRead(encoder0PinA) == LOW) { &#xA;      encoder0Count = encoder0Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder0Count = encoder0Count - 1;&#xA;    }&#xA;  }&#xA;  angle0 = 0.000785*encoder0Count;  &#xA;}&#xA;&#xA;/*--------------------*/&#xA;// for encoder 1&#xA;/*--------------------*/&#xA;void doEncoder1A(){  &#xA;  if (digitalRead(encoder1PinA) == HIGH) {  &#xA;    if (digitalRead(encoder1PinB) == LOW) { &#xA;      encoder1Count = encoder1Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder1Count = encoder1Count - 1;&#xA;    }&#xA;  }&#xA;  else {                                     &#xA;    if (digitalRead(encoder1PinB) == HIGH) { &#xA;      encoder1Count = encoder1Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder1Count = encoder1Count - 1;&#xA;    }&#xA;  }&#xA;  angle1 = 0.000785*encoder1Count;  &#xA;}&#xA;&#xA;void doEncoder1B(){  &#xA;  if (digitalRead(encoder1PinB) == HIGH) {  &#xA;    if (digitalRead(encoder1PinA) == HIGH) { &#xA;      encoder1Count = encoder1Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder1Count = encoder1Count - 1;&#xA;    }&#xA;  }&#xA;  else {                                   &#xA;    if (digitalRead(encoder1PinA) == LOW) { &#xA;      encoder1Count = encoder1Count + 1;&#xA;    } &#xA;    else {&#xA;      encoder1Count = encoder1Count - 1;&#xA;    }&#xA;  }&#xA;  angle1 = 0.000785*encoder1Count;  &#xA;}&#xA;&#xA;ISR(TIMER2_OVF_vect) {  &#xA;  TCNT2 = tcnt2;  &#xA;  t++;&#xA;&#xA;  // estimate velocity&#xA;  if (t == 1){&#xA;    angle0_previous = angle0;&#xA;    angle1_previous = angle1;&#xA;  }&#xA;  else if (t == 20){&#xA;    angle0_post = angle0;  &#xA;    angle1_post = angle1;&#xA;  }&#xA;  else if (t == 21){&#xA;    velocity0 = (angle0_post - angle0_previous)*50;  // rad/s&#xA;    velocity1 = (angle1_post - angle1_previous)*50;&#xA;&#xA;    error_proportional = 3.1416 - angle1;&#xA;    error_derivative = 3.1416 - velocity1;&#xA;    error_integral = error_integral + error_proportional;&#xA;&#xA;    t = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;motor.ino&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setMotorSpeed(int speed)&#xA;{&#xA;  if (speed &amp;lt; 0)&#xA;  {&#xA;    digitalWrite(in1, LOW);&#xA;    digitalWrite(in2, HIGH);&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(in1, HIGH);&#xA;    digitalWrite(in2, LOW);&#xA;&#xA;  }&#xA;&#xA;  analogWrite(enA,abs(speed));&#xA;&#xA;  angle1_previous=angle1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 1:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that the code below for setting timer messes PWM but Im not sure why. Anyone have any idea?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;TIMSK2 &amp;amp;= ~(1&amp;lt;&amp;lt;TOIE2);&#xA;  TCCR2A &amp;amp;= ~((1&amp;lt;&amp;lt;WGM21) | (1&amp;lt;&amp;lt;WGM20));&#xA;  TCCR2B &amp;amp;= ~(1&amp;lt;&amp;lt;WGM22);&#xA;  ASSR &amp;amp;= ~(1&amp;lt;&amp;lt;AS2);&#xA;  TIMSK2 &amp;amp;= ~(1&amp;lt;&amp;lt;OCIE2A);&#xA;  TCCR2B |= (1&amp;lt;&amp;lt;CS22)  | (1&amp;lt;&amp;lt;CS20);&#xA;  TCCR2B &amp;amp;= ~(1&amp;lt;&amp;lt;CS21);&#xA;  TCNT2 = tcnt2;&#xA;  TIMSK2 |= (1&amp;lt;&amp;lt;TOIE2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14106" LastEditorUserId="37523" LastEditDate="2019-08-02T17:30:16.350" LastActivityDate="2019-08-02T17:30:16.350" Title="Why doesn't PWM work on arduino in this code?" Tags="|arduino-mega|motor|pwm|pid|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="16910" PostTypeId="1" AcceptedAnswerId="16911" CreationDate="2015-10-17T14:05:28.680" Score="0" ViewCount="182" Body="&lt;p&gt;I'm working on a project in which when I press reset button the arduino should send longitudes and latitudes to my phone. I'm a beginner and tried to join two codes, first code can send the message and the second code can get the lon and lat printed on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First code--&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int timesTosend=1;&#xA;int count=0;&#xA;char phone_no[]=&quot;+917771914436&quot;;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  delay(2000);&#xA;  Serial.println(&quot;AT+CMGF=1&quot;);&#xA;  delay(200);&#xA;}&#xA;void loop()&#xA;{&#xA;  while (count&amp;lt;timesTosend)&#xA;  {&#xA;    delay(1500);&#xA;    Serial.print(&quot;AT+CMGS=\&quot;&quot;);&#xA;    Serial.print(phone_no);&#xA;    Serial.println(&quot;\&quot;&quot;);&#xA;    while(Serial.read()!='&amp;gt;');&#xA;    {&#xA;      Serial.print(&quot;Hii If this message is sent then its a huge sucess for me&quot;);&#xA;      delay(500);&#xA;      Serial.write(0x1A);&#xA;      Serial.write(0x0D);&#xA;      Serial.write(0x0A);&#xA;      delay(5000);&#xA;    }&#xA;    count++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second code--&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;long lat,lon; // create variable for latitude and longitude object&#xA;&#xA;SoftwareSerial gpsSerial(4, 3); // create gps sensor connection&#xA;TinyGPS gps; // create gps object&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); // connect serial&#xA;  gpsSerial.begin(9600); // connect gps sensor&#xA;}&#xA;&#xA;void loop(){&#xA;  while(gpsSerial.available()){ // check for gps data&#xA;   if(gps.encode(gpsSerial.read())){ // encode gps data&#xA;    gps.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude&#xA;    // display position&#xA;    Serial.print(&quot;Position: &quot;);&#xA;    Serial.print(&quot;lat: &quot;);Serial.print(lat);Serial.print(&quot; &quot;);// print latitude&#xA;    Serial.print(&quot;lon: &quot;);Serial.println(lon); // print longitude&#xA;   }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My code which is not working--&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;long lat,lon; // create variable for latitude and longitude object&#xA;&#xA;SoftwareSerial gpsSerial(4, 3); // create gps sensor connection&#xA;TinyGPS gps; // create gps object&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); // connect serial&#xA;  gpsSerial.begin(9600); // connect gps sensor&#xA;    Serial.begin(9600);&#xA;  delay(2000);&#xA;  Serial.println(&quot;AT+CMGF=1&quot;);&#xA;  delay(200);&#xA;}&#xA;&#xA;int timesTosend=1;&#xA;int count=0;&#xA;char phone_no[]=&quot;+917771914436&quot;;&#xA;void loop()&#xA;{&#xA;  while (count&amp;lt;timesTosend)&#xA;  {&#xA;    delay(1500);&#xA;    Serial.print(&quot;AT+CMGS=\&quot;&quot;);&#xA;    Serial.print(phone_no);&#xA;    Serial.println(&quot;\&quot;&quot;);&#xA;     while(Serial.read()!='&amp;gt;');&#xA;    {&#xA;      while(gpsSerial.available())&#xA;      {&#xA;        if(gps.encode(gpsSerial.read()))&#xA;        { // encode gps data&#xA;    gps.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude&#xA;    Serial.print(lat,lon);&#xA;      delay(500);&#xA;      Serial.write(0x1A);&#xA;      Serial.write(0x0D);&#xA;      Serial.write(0x0A);&#xA;      delay(5000);&#xA;        }&#xA;      }&#xA;    }&#xA;    count++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me out by correcting my mistake in the code.&lt;/p&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="4143" LastEditDate="2015-10-17T14:07:40.250" LastActivityDate="2015-10-17T14:11:46.643" Title="Problem in receieving message" Tags="|arduino-uno|gsm|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16911" PostTypeId="2" ParentId="16910" CreationDate="2015-10-17T14:09:54.737" Score="0" Body="&lt;pre&gt;&lt;code&gt;Serial.print(lat,lon);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That doesn't do what you think it does.  That is trying to print the latitude encoded in base &quot;lon&quot;, which just isn't going to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to send it as separate operations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(lat);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.print(lon);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you should separate out the GPS and GSM routines.  Create a function that gets the latitude and longitude, and another function that sends the two values as a text message.  Then you can keep things as discrete obvious steps and not get confused with what is happening when.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-17T14:11:46.643" LastActivityDate="2015-10-17T14:11:46.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16912" PostTypeId="2" ParentId="16908" CreationDate="2015-10-17T14:21:39.097" Score="0" Body="&lt;p&gt;What about a 3.3v Arduino Pro Mini, you'll need to solder headers but that's not too onerous. See here &lt;a href=&quot;https://www.sparkfun.com/products/11114&quot; rel=&quot;nofollow&quot;&gt;Arduino pro Mini&lt;/a&gt; or even cheaper from eBay&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-10-17T14:21:39.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16913" PostTypeId="2" ParentId="16904" CreationDate="2015-10-17T14:42:57.083" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Yes, the output will be a pwm. You can see it from the &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00000240.pdf&quot; rel=&quot;nofollow&quot;&gt;schematics&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;you have few options, with different precision and complexity:&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Configure one of the PWM HW blocks&lt;/li&gt;&#xA;&lt;li&gt;Do it by sw in a loop&lt;/li&gt;&#xA;&lt;li&gt;Use a timer to trigger a sw function - but it might be simpler to just configure the PWM HW block.&lt;/li&gt;&#xA;&lt;li&gt;Use some existing library that will implement one of the methods I listed&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would recommend Option 1: it's not so difficult, you will learn something of the AVR internals and it will be the solution with the least overhead. You can have a look at &lt;a href=&quot;https://sites.google.com/site/qeewiki/books/avr-guide/pwm-on-the-atmega328&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial. There are also many others floating around.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-17T14:42:57.083" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16915" PostTypeId="1" CreationDate="2015-10-17T15:32:45.743" Score="2" ViewCount="71" Body="&lt;p&gt;How can I change The timers to work correctly when The processor clock is set to 128K instead of 16 M?&#xA;At present, using the delay function does not work correctly, The delay is far too long.&lt;/p&gt;&#xA;" OwnerUserId="13590" LastActivityDate="2015-11-16T22:38:15.437" Title="The Time are functions do not work correctly when the processor clock speed is set at 128K" Tags="|arduino-uno|oscillator-clock|fuses|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16916" PostTypeId="2" ParentId="16870" CreationDate="2015-10-17T15:42:47.610" Score="0" Body="&lt;p&gt;The &lt;code&gt;loop()&lt;/code&gt; and &lt;code&gt;clearScore()&lt;/code&gt; code that you have is like the following.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  clearScore(); // sets both home and away scores to 0 or enters settings menu&#xA;}&#xA;void clearScore() {&#xA;  ms = millis(); //record the current time&#xA;  clearBtn.read(); // Read the button&#xA;  if (clearBtn.pressedFor(2000)) {&#xA;    // Enter settings menu&#xA;    Serial.println(&quot;Settings Menu&quot;);&#xA;    while (clearBtn.read()!=1) {&#xA;      // do stuff&#xA;    } // End While&#xA;    return; // Don't proceed to next if&#xA;  }&#xA;  if (clearBtn.wasReleased() &amp;amp;&amp;amp; !clearBtn.pressedFor(2000)) {&#xA;    score=0;&#xA;    Serial.println(&quot;Clearing Scores&quot;);&#xA;    delay(50); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you reset the Arduino and then hold down the clearBtn, &lt;code&gt;clearScore()&lt;/code&gt; will be called repeatedly. &lt;code&gt;clearBtn.pressedFor(2000)&lt;/code&gt; will not be satisfied during the first two seconds of holding the button down, and &lt;code&gt;clearBtn.wasReleased()&lt;/code&gt; will not be satisfied either, so &lt;code&gt;clearScore()&lt;/code&gt; will do nothing during the first two seconds.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the first two seconds, &quot;Settings Menu&quot; will be sent repeatedly:  &lt;code&gt;clearBtn.pressedFor(2000)&lt;/code&gt; is true, so the first &lt;code&gt;if&lt;/code&gt; succeeds each time &lt;code&gt;clearScore()&lt;/code&gt; runs, and it will run repeatedly because it is called from &lt;code&gt;loop()&lt;/code&gt;.  The &lt;code&gt;while&lt;/code&gt; test, &lt;code&gt;clearBtn.read()!=1&lt;/code&gt; [which in more-idiomatic C would be written as &lt;code&gt;!clearBtn.read()&lt;/code&gt;] fails until the clearBtn is released, so the &lt;code&gt;while&lt;/code&gt; loop does nothing.  Also, &lt;code&gt;clearBtn.wasReleased()&lt;/code&gt; will be false, so the other &lt;code&gt;if&lt;/code&gt; does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the button finally is released, &lt;code&gt;clearBtn.pressedFor(2000)&lt;/code&gt; goes false, so the first &lt;code&gt;if&lt;/code&gt; fails and the second executes one time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some code that should act more like what you want, as expressed in your comment, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's supposed to work like this: 1) hold button down for 2 seconds to enter settings menu. While in settings menu I'll code other stuff. Stay in settings menu until the clear button is pressed momentarily again. Once you press clear button again from being in the settings menu, the score should NOT be reset, and it should just return to the main loop. 2) if the clear button was not pressed for more than 2 seconds, just clear the score.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clearScore() {&#xA;  ms = millis(); //record the current time&#xA;&#xA;  while (clearBtn.read()) {&#xA;    if (clearBtn.pressedFor(2000)) {&#xA;      Serial.println(&quot;Settings Menu&quot;); // Announce Settings menu&#xA;      while (clearBtn.read()) {}       // Await button release&#xA;      while (!clearBtn.read()) {       // Await button press&#xA;        // do  Settings menu stuff here&#xA;        // (possibly wait for clearBtn release, to &#xA;        // avoid immediately clearing score again)&#xA;      }&#xA;    }&#xA;    return;&#xA;  }&#xA;&#xA;  if (clearBtn.wasReleased()) { // See if released, after short press&#xA;    score=0;&#xA;    Serial.println(&quot;Clearing Scores&quot;);&#xA;    delay(50); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit edit:&lt;/em&gt; To avoid  resetting the score at every settings exit, in the above code replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        // (possibly wait for clearBtn release, to &#xA;        // avoid immediately clearing score again)&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      }&#xA;    }&#xA;    while (clearBtn.read()) {} // wait for the settings-exit clearBtn release&#xA;    clearBtn.read(); // Do another read to avoid clearing score on next clearScore()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, right before the &lt;code&gt;return&lt;/code&gt;, wait for clearBtn release, and read it again to be sure later reads won't register a release.  The latter &lt;code&gt;read&lt;/code&gt; might not be needed, because &lt;code&gt;clearScore()&lt;/code&gt; does a &lt;code&gt;read&lt;/code&gt; when it tests the first &lt;code&gt;while&lt;/code&gt; condition; you could experiment.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-10-19T14:53:23.440" LastActivityDate="2015-10-19T14:53:23.440" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16917" PostTypeId="1" AcceptedAnswerId="16918" CreationDate="2015-10-17T15:53:42.390" Score="0" ViewCount="1825" Body="&lt;p&gt;I have tried a Google search and cannot find any place that tells me exactly how to wire the version 12 esp8266 ,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should it be wired for normal operation and for flashing ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am designing a diy pcb and need to know the specifics,to wire a switch for flashing purposes etc.I am using just a esp8266 version 12 standalone without a typical arduino micro-controller attached and will be flashing it to take the arduino ide ,any help with this would be great as I'm sure someone has already come across this problem.&lt;/p&gt;&#xA;" OwnerUserId="13542" LastActivityDate="2015-10-17T17:07:05.500" Title="Esp8266 V12 Wiring" Tags="|arduino-ide|pins|hardware|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16918" PostTypeId="2" ParentId="16917" CreationDate="2015-10-17T17:07:05.500" Score="1" Body="&lt;p&gt;You could find the &lt;a href=&quot;http://www.instructables.com/id/Getting-Started-with-the-ESP8266-ESP-12/?ALLSTEPS#step3&quot; rel=&quot;nofollow noreferrer&quot;&gt;solution&lt;/a&gt;, on the first hit for googling &quot;ESP8266 ESP-12&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r9Zj3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r9Zj3.jpg&quot; alt=&quot;wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You need to connect a few GPIO pins on the ESP-12 to 3.3V or Ground,&#xA;  to set it in the right mode for communicating with it. Here are the&#xA;  connections you need to make :&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;VCC ----&gt; 3.3V Power supply (Vout of LM1117)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GND ----&gt; Ground of power supply&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;CH_PD ----&gt; HIGH (3.3V)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GPIO2 ----&gt; HIGH (3.3V)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GPIO15 ----&gt; LOW (GND)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GPIO0 ----&gt; HIGH or Floating for AT Mode (3.3V) [ * if you want to&#xA;  flash completely different firmware then you must connect it to ground&#xA;  ]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to connect &lt;code&gt;GPIO0&lt;/code&gt; to &lt;code&gt;GND&lt;/code&gt; for flashing and to &lt;code&gt;VCC&lt;/code&gt; for normal operation.&lt;/p&gt;&#xA;" OwnerUserId="972" LastActivityDate="2015-10-17T17:07:05.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16919" PostTypeId="1" CreationDate="2015-10-17T17:16:06.433" Score="1" ViewCount="656" Body="&lt;p&gt;I have &lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;product_id=880&quot; rel=&quot;nofollow&quot;&gt;this MPU6050&lt;/a&gt;, and like most of the other MPU6050s, it is set up for SCL to be attached to A4 and SDA to be attached to A5. I have &lt;a href=&quot;http://www.amazon.co.uk/SainSmart-InstaBots-SS-SBR-1-0-Sensor-Shield/dp/B00N1YANH2&quot; rel=&quot;nofollow&quot;&gt;this shield&lt;/a&gt; on my Arduino Uno, which is configured for Sainsmart's (the company who made the shield) MPU6050, so the special MPU6050 pins are set up V, G, A5, A4, and my current setup needs V, G, A4, A5. I am using the built-in Wire library, &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/I2Cdev&quot; rel=&quot;nofollow&quot;&gt;I2CDev library&lt;/a&gt;, and &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050&quot; rel=&quot;nofollow&quot;&gt;the MPU6050 library&lt;/a&gt;. So I am wondering whether there is something in these libraries that define which pins it looks for my MPU6050 on, and if so how do I change it.&lt;/p&gt;&#xA;" OwnerUserId="10529" LastEditorUserId="4628" LastEditDate="2015-11-19T08:35:15.330" LastActivityDate="2016-02-17T12:50:08.160" Title="Switch MPU6050 to send SCL data through A4 and SDA through A5" Tags="|arduino-uno|pins|i2c|mpu6050|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16920" PostTypeId="1" CreationDate="2015-10-17T19:02:31.213" Score="0" ViewCount="1602" Body="&lt;p&gt;If I make connections like you see in picture below, will it work? Will I damage ESP or HC-SR04?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I know;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HC-SR04 (VCC) -&gt; 5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP8266 (VCC) -&gt; 3.6V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP8266 (RX/TX) -&gt; has 5V tolerance ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not taken into account the currents that will each pin draw. So, is everything OK?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not good at this stuff, so I'll appreciate it if you guys give me advice&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://postimg.org/image/mik7ms3fv/#codes&quot; rel=&quot;nofollow noreferrer&quot;&gt;Image&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ua0lc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ua0lc.jpg&quot; alt=&quot;Circuit Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of you suggest to use voltage regulator instead of external AA batteries. However, I have already ordered one but it takes too much time (nearly week) to get, due to delivery-shipping issues. So, I want to work on the coding part of my project.&lt;/p&gt;&#xA;" OwnerUserId="14111" LastEditorUserId="6936" LastEditDate="2015-10-22T21:00:02.900" LastActivityDate="2022-05-03T00:06:00.503" Title="Choosing Right Power Supply for Arduino - ESP8266 - HC-SR04" Tags="|arduino-uno|voltage-level|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16922" PostTypeId="2" ParentId="10208" CreationDate="2015-10-17T20:56:08.377" Score="3" Body="&lt;p&gt;From the picture I guess it is a roboduino. The only voltage regulator is the 662k, it is &lt;strong&gt;too small&lt;/strong&gt; compared to other voltage regulators!!! (have a look at the size and sink of the official arduino), so it is normal that the temperature is high. (arduino uno can get up to 1A and the regulator is bigger)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reduce temperature just &lt;strong&gt;use the lowest input source&lt;/strong&gt; (for instance, for arduino 5 volts, use 7 volts source, not 12 volts source). The bigger input voltage, the higher temperature in the regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solutions.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replace the 662K with another 662K one.&lt;/li&gt;&#xA;&lt;li&gt;use a bigger voltage regulator. Since 66K space is tight (SOT-23) and no sink space I suggest to solder a TO-92 like voltage regulator. Not nice solution, but handy.  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14114" LastActivityDate="2015-10-17T20:56:08.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16923" PostTypeId="2" ParentId="16915" CreationDate="2015-10-17T21:37:25.853" Score="1" Body="&lt;p&gt;A commonly-used approach is writing an intermediate or surrogate delay function that your application calls.  That delay routine needs a way to know if the clock is slow (128 KHz) or fast (16 MHz).  If the clock is slow, divide the delay counts by 125 (the ratio of 16 MHz and 128 KHz) before calling the built-in &lt;code&gt;delay()&lt;/code&gt;.  [Or, adjust all your application calls to use numbers scaled down by a factor of 125, and in the surrogate scale them back up if the clock is fast.  This may give you better control than just rounding, truncating, or truncating up will do.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you call the intermediate routine &lt;code&gt;vDelay()&lt;/code&gt; and change your app calls from a &lt;code&gt;delay(x)&lt;/code&gt; form to a &lt;code&gt;vDelay(x)&lt;/code&gt; form, in the function &lt;code&gt;vDelay(unsigned long ms)&lt;/code&gt; you will say something like &lt;code&gt;if (ClockIsSlow) delay((ms+124)/125); else delay(ms);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-17T21:37:25.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16924" PostTypeId="2" ParentId="16915" CreationDate="2015-10-17T22:06:29.287" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/CustomizeArduinoIDE&quot; rel=&quot;nofollow&quot;&gt;Add a new entry in boards.txt&lt;/a&gt; with the new value for &lt;code&gt;f_cpu&lt;/code&gt;. Note that the timing functions will become far less precise at so low a speed.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-17T22:06:29.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16925" PostTypeId="2" ParentId="13079" CreationDate="2015-10-17T22:12:15.607" Score="1" Body="&lt;p&gt;If you're using the components that came in the starter kit, the servo is wired differently in the book than it is in the actual kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the red wire on the servo is connected to the power, the black to the ground and the white to the data. The specs are also written on the side of the servo motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the project book, the wires went into these rows on the breadboard:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;26&quot;&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;li&gt;5V&lt;/li&gt;&#xA;&lt;li&gt;Signal&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Whereas for me that meant it was:&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;26&quot;&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;li&gt;Signal&lt;/li&gt;&#xA;&lt;li&gt;5V&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="14117" LastActivityDate="2015-10-17T22:12:15.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16927" PostTypeId="2" ParentId="16920" CreationDate="2015-10-17T22:31:47.657" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;GND seems dangling.&lt;/li&gt;&#xA;&lt;li&gt;If you are going to use multiple power sources, make sure that all the minus/GND are connected together.&lt;/li&gt;&#xA;&lt;li&gt;Whether the ESP8266 can use 5V or not should be checked against the actual unit you have. There are many variants and some might be more tolerant than others.&lt;/li&gt;&#xA;&lt;li&gt;You do not show the power source for 5V - what is it?&lt;/li&gt;&#xA;&lt;li&gt;By just typing on google HC-SR04 5V, you get a link to the manual, which has a section &quot;4.0 PRODUCT SPECIFICATION AND LIMITATIONS&quot;: Min:4.5V Typ:5V Max:5.5V. You should at least give it a try and report your findings, asking for clarifications, if you need any, rather than just ask here for something that google can provide.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-17T22:31:47.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16928" PostTypeId="1" AcceptedAnswerId="16930" CreationDate="2015-10-17T22:48:12.367" Score="1" ViewCount="277" Body="&lt;p&gt;The title pretty much says it all. I know that most Arduinos can do this, but I couldn't find very much information for the Zero. Any help would be very much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="14118" LastActivityDate="2015-10-17T22:57:33.790" Title="Can one supply an Arduino Zero's VIN pin with 5v?" Tags="|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16929" PostTypeId="2" ParentId="16919" CreationDate="2015-10-17T22:50:31.540" Score="1" Body="&lt;p&gt;The pin definition is in hardware. There is nothing you can do to change it. However you could try to reprogram it to use a software i2c library instead of the hardware wire library.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-17T22:50:31.540" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16930" PostTypeId="2" ParentId="16928" CreationDate="2015-10-17T22:57:33.790" Score="0" Body="&lt;p&gt;Yes you can. If you look at the schematics on the Arduino website you can see that the 3.3 volt regulator is connected to the 5 volt regulator. That means that if you feed 5 volts straight into the 5 volt pin it will go through the 3.3 volt regulator to supply the main chip.&#xA;Note that this is going into the 5 volt pin not the VIN pin which goes into the 5 volt regulator and would thus require a higher voltage than 5 volts.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-17T22:57:33.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16932" PostTypeId="1" CreationDate="2015-10-17T23:32:06.520" Score="0" ViewCount="158" Body="&lt;p&gt;Hi i have made this code&#xA;its so simple its should receive data from the computer and send it back via the serial but the problem is he do not what it is suppose to do&#xA;when its run its keep sending -1 to the computer&#xA;and if i send something to the arduini  like  55   i receive and answer 53&#xA;i have no idea were is the problem in this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long number = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;   void loop() {&#xA;   number = Serial.read();&#xA;   delay(1000);&#xA;   Serial.println(number);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14119" LastEditorUserId="14119" LastEditDate="2015-10-18T20:25:37.337" LastActivityDate="2015-10-20T11:47:07.277" Title="What wrong with that code?" Tags="|c|" AnswerCount="2" CommentCount="4" ClosedDate="2015-11-05T23:41:04.870" ContentLicense="CC BY-SA 3.0" />
  <row Id="16933" PostTypeId="1" AcceptedAnswerId="16969" CreationDate="2015-10-17T23:59:17.293" Score="0" ViewCount="7376" Body="&lt;p&gt;I'm working on a home automation project using Arduino and MQTT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a problem and my limited programming knowledge find a way to solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can send text trough MQTT normally, using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.Publish(&quot;some/topic&quot;,&quot;Some text here&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I try to send a variable (int, char, etc), the compiler says &quot;invalid conversion from 'char' to 'const char*' [-fpermissive]&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I store DHT11 sensor reading in const char* to send it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I've found &lt;a href=&quot;http://e.verything.co/post/61576413925/publishing-arduino-sensor-data-through-mqtt-over&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; code where &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *tempC;&#xA;tempC = dtostrf(((((analogRead(tempPinIn) * 5.0) / 1024) - 0.5) * 100), 5, 2, message_buffer);&#xA;client.publish(&quot;arduino/temperature&quot;,tempC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is used. But the extra sensor calibration makes it even harder for me to understand whats going on. &lt;/p&gt;&#xA;" OwnerUserId="11905" LastEditorUserId="10003" LastEditDate="2015-10-19T01:46:19.403" LastActivityDate="2015-10-19T01:46:19.403" Title="Read sensor and convert reading to const char*" Tags="|arduino-uno|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16939" PostTypeId="2" ParentId="12236" CreationDate="2015-10-18T05:35:15.600" Score="3" Body="&lt;p&gt;I suggest you to modify the following lines of code to check which reading has issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (isnan(h) || isnan(t) || isnan(f)) {&#xA;   Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;   return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13931" LastActivityDate="2015-10-18T05:35:15.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16940" PostTypeId="1" AcceptedAnswerId="16942" CreationDate="2015-10-18T06:02:32.407" Score="0" ViewCount="1587" Body="&lt;p&gt;I know about line follower mainly the grid solving robots i know the basics actually. Actually they have to trace the path of the grid in an arena and then reach back to starting point in a shortest distance. Here my doubt is regarding the line follower in this link I have attached.&lt;a href=&quot;https://www.youtube.com/watch?v=5At_u5rnh2U&quot; rel=&quot;nofollow&quot;&gt;Advanced Line Follower Robot for maze solving&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My doubt is what are the procedures to do it? They have mapped the path and used Dijkstra algorithm to solve the path. But how do they transfer the code(i.e) where it has to turn which direction it has to turn. how are they generating the what function should be passed? Please explain i need the procedure alone. am going to try it with python.&lt;/p&gt;&#xA;" OwnerUserId="14103" LastActivityDate="2015-12-17T18:40:55.340" Title="Advanced Line Follower robot" Tags="|arduino-uno|arduino-ide|robotics|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16942" PostTypeId="2" ParentId="16940" CreationDate="2015-10-18T07:18:33.623" Score="2" Body="&lt;p&gt;Any language will do, as long as it is supported by your HW platform.&#xA;If you want to use python, you need a board that can run python.&#xA;That could be an Arduino Yun, for example. Or an Intel Quark. Or an Intel Edison with an Arduino shield.&#xA;But these will be expensive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could, alternatively, use C/C++ and an Ardino UNO (or micro, nano, mini pro), which is far cheaper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling for something as simple as &quot;Arduino line following kit&quot; gives as first answer &lt;a href=&quot;http://www.instructables.com/id/Line-following-Robot-with-Arduino/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, which seems to be exactly what you are looking for.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-18T07:18:33.623" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16943" PostTypeId="2" ParentId="16520" CreationDate="2015-10-18T07:57:31.100" Score="1" Body="&lt;p&gt;I have one of these TFT LCD shields, but mine is a ILI9335. It has taken me nearly 2 weeks to find a working Library and code for my 9335 driver and I am now setting about creating sketches based around my working Library. &#xA;  Library - TFTLCD using st7783 controller&#xA;Unfortunately most sellers of these shields (excluding good reputable companies) do not adivise of which Driver is onboard the shield and it becomes difficult to locate a working Library for the driver of the purchased shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ALSO, check that the Libraries you have are working for your version of Arduino IDE. Some of my libraries would not compile in v1.0.5 but will in v1.6.3 (and vice versa)&#xA;If there is no Library specific to your 6767 Driver (and I must say I have not seen one in my searches for the 9335 Driver) then you may have to download as many different Libraries to locate a sketch that works for yours. &#xA;Once you have a working Library then it is just a matter of modifying it for your purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck in finding a working solution for your shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lance..&lt;/p&gt;&#xA;" OwnerUserId="14126" LastActivityDate="2015-10-18T07:57:31.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16947" PostTypeId="1" CreationDate="2015-10-18T10:03:36.380" Score="0" ViewCount="65" Body="&lt;p&gt;A master will send fan speed values to the slave. The slave will then read the fan speed values and change the speed value for the relevant pwm pin. However I am not sure how I can tell the slave which pin the data is for.  Should I send two packets of data in quick sucsession and then have a loop system wherby the first peice of data out of two is always for specifying the pin? Any help in tackling this would be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="14090" LastEditorUserId="10794" LastEditDate="2016-01-16T22:26:53.123" LastActivityDate="2016-01-17T02:21:40.280" Title="Is it possible to specify a pin upon which the data sent over i2c can act?" Tags="|c++|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16948" PostTypeId="2" ParentId="16947" CreationDate="2015-10-18T10:18:13.557" Score="0" Body="&lt;p&gt;In a way, yes.  You are making the assumption that many beginners do, that I2C is only able to send one byte.  That's not the case. You can send many bytes as one single packet with I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Send a single packet consisting of two bytes - the first is the pin number and the second the speed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-18T10:18:13.557" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="16952" PostTypeId="1" CreationDate="2015-10-18T11:53:45.597" Score="0" ViewCount="1644" Body="&lt;p&gt;I have used your bootloader for ATmega2560-16AU with 16MHz external crystal and it works like a wonder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my new project I have a 3V power supply. Therefore, I am planning to use a low frequency external crystal in order to operate the ATmega at a low frequency so that the voltage will be able to go as low as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have a number of issues/questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I uploaded the bootloader using an 8MHz external crystal and it went successfully but I am not able to upload a sketch.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I run an ATmega2560-16AU with an 8MHz crystal and will it work at 3V, without any risk?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As I do not have an ATmega2560-8AU right now, I am not able to test this. Will your bootloader work with Atmega2560-8AU and an external 8MHz crystal or, before burning bootloader, do I need to make any changes?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sorry to ask you such a long query, but I have really spent lots of time looking at this and finally today I made a post everywhere.&lt;/p&gt;&#xA;" OwnerUserId="14131" LastEditorUserId="6936" LastEditDate="2016-02-08T12:25:35.580" LastActivityDate="2017-12-27T22:15:13.263" Title="Difference in bootloader of ATmega with 16MHz external crystal and 8MHz external crystal" Tags="|arduino-mega|uploading|sketch|bootloader|frequency|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16953" PostTypeId="1" AcceptedAnswerId="16957" CreationDate="2015-10-18T12:09:59.103" Score="3" ViewCount="18636" Body="&lt;p&gt;Please be gentle with me. I am attempting to modify the configurations of my HC-05 bluetooth module by using the AT command set. The method by which I'm trying to do this is by implementing the following connection:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HC-05 GND --&gt; Arduino GND;&#xA;HC-05 3.3v --&gt; Arduino 3.3V;&#xA;HC-05 TX --&gt; Arduino Pin 10;&#xA;HC-05 RX --&gt; Arduino Pin 11;&#xA;HC-05 KEY --&gt; Arduino Pin 9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0ddBN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ddBN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code which I uploaded to my Arduino (btw my arduino uno is an SMD clone): (code's from &lt;a href=&quot;http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/step2/The-Arduino-Code-for-HC-05-Command-Mode/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/step2/The-Arduino-Code-for-HC-05-Command-Mode/&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BTSerial(10, 11); // RX | TX&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode&#xA;  digitalWrite(9, HIGH);&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Enter AT commands:&quot;);&#xA;  BTSerial.begin(38400);  // HC-05 default speed in AT command more&#xA;&#xA; }&#xA;&#xA;void loop() {&#xA;  // Keep reading from HC-05 and send to Arduino Serial Monitor&#xA;  if (BTSerial.available())&#xA;    Serial.write(BTSerial.read());&#xA;&#xA;  // Keep reading from Arduino Serial Monitor and send to HC-05&#xA;  if (Serial.available())&#xA;    BTSerial.write(Serial.read());&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is I can't seem to activate the AT mode. I don't get any response from the Serial Monitor whatever AT command I try. I double-checked the wiring and it's all good. I can't figure out what the problem is.&lt;/p&gt;&#xA;" OwnerUserId="14129" LastEditorUserId="3237" LastEditDate="2015-10-19T03:06:26.323" LastActivityDate="2017-04-13T21:41:17.493" Title="Problem activating HC-05 AT command mode with Arduino Uno Bluetooth shield" Tags="|bluetooth|hc-05|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16954" PostTypeId="1" AcceptedAnswerId="22403" CreationDate="2015-10-18T13:52:37.693" Score="5" ViewCount="18895" Body="&lt;p&gt;I currently try to connect an Arduino Micro/Leonardo/32u4 to an ELM327 Bluetooth dongle using a HC-05 Bluetooth shield from iTeadStudio. I also have similar problems trying to connect to a bluetooth dongle (with added serial connection) on my PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic AT-command communication works, but I haven't found out yet why AT+PAIR or AT+LINK are failing and what should be done to avoid this (I've done dozens of Serial Monitor command iterations). Until now I haven't found a command sequence that reliably connects. What I've tried so far (from different documentation and example codes):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check general AT command set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reset to default values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ORGL&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set master mode and check it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ROLE=1&#xA;&amp;gt; OK&#xA;AT+ROLE?&#xA;&amp;gt; +ROLE:1&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Connect only to the specified bluetooth address:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CMODE=0&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reset and initialize:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RESET&#xA;&amp;gt; OK&#xA;AT+INIT&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Configure inquiring mode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+INQM=1,9,48&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inquire:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+INQ&#xA;&amp;gt; +INQ:12:34:567890:1F1F,7FFF&#xA;&amp;gt; OK&#xA;AT+STATE?&#xA;&amp;gt; +STATE:INQUIRING&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to stop inquiring:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+INQC&#xA;&amp;gt; OK&#xA;AT+STATE?&#xA;&amp;gt; +STATE:INQUIRING&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reset and initialize again (otherwise we can't leave the inquiring state):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RESET&#xA;&amp;gt; OK&#xA;AT+INIT&#xA;&amp;gt; OK&#xA;AT+STATE?&#xA;&amp;gt; +STATE:INITIALIZED&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to pair with the found device (my PC asks for the 1234-password and creates a serial port):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+PAIR=12,34,567890,20&#xA;&amp;gt; OK&#xA;AT+STATE?&#xA;&amp;gt; +STATE:PAIRED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to connect&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+BIND=12,34,567890&#xA;&amp;gt; OK&#xA;AT+LINK=12,34,567890&#xA;&amp;gt; FAIL&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does someone have some hints for finding the right sequence?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2016-03-27T12:43:34.663" LastActivityDate="2018-11-26T15:40:48.820" Title="Problems connecting reliably using HC-05 (as bluetooth master)" Tags="|bluetooth|hc-05|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16955" PostTypeId="1" AcceptedAnswerId="16956" CreationDate="2015-10-18T14:44:15.583" Score="-2" ViewCount="666" Body="&lt;p&gt;This is my code but it doesn't work. I don't no why . I hope someone can explain the problem. Tks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char InTransfer;&#xA;char buffer;&#xA;void setup()&#xA;    {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  /* when get the sentences and print it*/&#xA;   while ( Serial.available())&#xA;  { &#xA;    buffer=Serial.read();&#xA;    Serial.write(buffer);&#xA;    InTransfer=1;    // detect &#xA;  }&#xA;  /* After done enter one time */&#xA;  if (Serial.available()==0)&#xA;    if(InTransfer==1){&#xA;      Serial.println(&quot;&quot;);&#xA;      InTransfer=0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14132" LastActivityDate="2015-10-18T14:53:06.270" Title="How to use serial.read a sentences and serial.print after that enter to new line" Tags="|serial|" AnswerCount="1" CommentCount="1" ClosedDate="2015-11-05T23:36:51.127" ContentLicense="CC BY-SA 3.0" />
  <row Id="16956" PostTypeId="2" ParentId="16955" CreationDate="2015-10-18T14:53:06.270" Score="1" Body="&lt;p&gt;Your code works perfectly, I don't see a problem with it. It's doing &lt;em&gt;exactly&lt;/em&gt; what you're telling it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem lies in a fundamental lack of understanding about how serial communications work on your part, so you are telling it to do the wrong thing.  Until you fix that aspect no program you try and write in this way will be a success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should start by learning how serial communication actually works.  A good starting point is an article I wrote ages ago: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-18T14:53:06.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16957" PostTypeId="2" ParentId="16953" CreationDate="2015-10-18T17:16:46.617" Score="1" Body="&lt;p&gt;After 3 hours I magically solved my pretty simple problem myself. If you wired the HC-05 and arduino correctly, the module should indicate that it's in AT Mode by blinking the LED in an interval of 2 seconds. You should get response in the Serial Monitor by typing the AT commands by switching from &quot;No line ending&quot; to &quot;Both NL and CR&quot;. That's about it. &lt;/p&gt;&#xA;" OwnerUserId="14129" LastActivityDate="2015-10-18T17:16:46.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16958" PostTypeId="1" CreationDate="2015-10-18T17:39:10.700" Score="2" ViewCount="145" Body="&lt;p&gt;I already asked my question in the Arduino Forum here: &lt;a href=&quot;https://forum.arduino.cc/index.php?topic=353846.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=353846.0&lt;/a&gt; but got no answer so far. Thus I hope here might be people who have a hint for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I introduced some Ubuntu patches I suspect these patches are to blame. But frankly I have no clue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect the programming port then Arduino IDE 1.6.5 properly recognizes it as the programming port. Thus I assume that the cable is properly plugged in and the Arduino powered. In addition I get&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; lsusb&#xA;...&#xA;Bus 003 Device 019: ID 2341:003d Arduino SA&#xA;...&#xA;&#xA;&amp;gt; dmesg&#xA;...&#xA; 2074.703747] usb 3-3: USB disconnect, device number 18&#xA;[ 2076.678150] usb 3-3: new full-speed USB device number 19 using xhci_hcd&#xA;[ 2076.696405] usb 3-3: New USB device found, idVendor=2341, idProduct=003d&#xA;[ 2076.696407] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[ 2076.696409] usb 3-3: Product: Arduino Due Prog. Port&#xA;[ 2076.696409] usb 3-3: Manufacturer: Arduino (www.arduino.cc)&#xA;[ 2076.696410] usb 3-3: SerialNumber: 55437333537351F0F1D0&#xA;[ 2076.696501] usb 3-3: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes&#xA;[ 2076.697270] cdc_acm 3-3:1.0: ttyACM3: USB ACM device&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I assume the device is definitely connected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; ls -l /dev/ttyACM3&#xA;crw-rw---- 1 root dialout 166, 3 Okt 17 09:56 /dev/ttyACM3&#xA;&#xA;&#xA;&amp;gt; grep dialout /etc/group&#xA;dialout:x:20:udo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I assume that my user &quot;udo&quot; is authorized to access the device. Everything as it should be and as it used to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The patches that were applied are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; grep &quot;2015-10-16.* upgrade &quot; /var/log/dpkg.log&#xA;2015-10-16 09:25:29 upgrade udev:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:30 upgrade libudev1:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:31 upgrade libpam-systemd:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:32 upgrade systemd-services:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:32 upgrade libsystemd-daemon0:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:33 upgrade libsystemd-login0:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:34 upgrade chromium-codecs-ffmpeg-extra:amd64 45.0.2454.85-0ubuntu0.14.04.1.1097 45.0.2454.101-0ubuntu0.14.04.1.1099&#xA;2015-10-16 09:25:35 upgrade libgdk-pixbuf2.0-0:amd64 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2&#xA;2015-10-16 09:25:35 upgrade libgdk-pixbuf2.0-common:all 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2&#xA;2015-10-16 09:25:36 upgrade google-chrome-stable:amd64 45.0.2454.101-1 46.0.2490.71-1&#xA;2015-10-16 09:25:41 upgrade libgl1-mesa-dri:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:42 upgrade libgbm1:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:43 upgrade libgl1-mesa-dev:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:43 upgrade mesa-common-dev:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:44 upgrade libgl1-mesa-glx:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:45 upgrade libgles2-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:45 upgrade libwayland-egl1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:46 upgrade libegl1-mesa-drivers:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:47 upgrade libglapi-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:48 upgrade libopenvg1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:48 upgrade libegl1-mesa:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:49 upgrade libgudev-1.0-0:amd64 1:204-5ubuntu20.14 1:204-5ubuntu20.15&#xA;2015-10-16 09:25:50 upgrade libhunspell-1.3-0:amd64 1.3.2-6ubuntu2 1.3.2-6ubuntu2.1&#xA;2015-10-16 09:25:51 upgrade libspice-server1:amd64 0.12.4-0nocelt2ubuntu1.1 0.12.4-0nocelt2ubuntu1.2&#xA;2015-10-16 09:25:51 upgrade libxatracker2:amd64 10.1.3-0ubuntu0.4 10.1.3-0ubuntu0.5&#xA;2015-10-16 09:25:52 upgrade linux-image-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106&#xA;2015-10-16 09:25:55 upgrade libsystemd-journal0:amd64 204-5ubuntu20.14 204-5ubuntu20.15&#xA;2015-10-16 09:25:55 upgrade ubuntu-release-upgrader-gtk:all 1:0.220.7 1:0.220.8&#xA;2015-10-16 09:25:56 upgrade ubuntu-release-upgrader-core:all 1:0.220.7 1:0.220.8&#xA;2015-10-16 09:25:57 upgrade python3-distupgrade:all 1:0.220.7 1:0.220.8&#xA;2015-10-16 09:25:58 upgrade update-manager:all 1:0.196.13 1:0.196.14&#xA;2015-10-16 09:25:59 upgrade update-manager-core:all 1:0.196.13 1:0.196.14&#xA;2015-10-16 09:26:00 upgrade python3-update-manager:all 1:0.196.13 1:0.196.14&#xA;2015-10-16 09:26:01 upgrade firefox:amd64 41.0+build3-0ubuntu0.14.04.1 41.0.1+build2-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:04 upgrade firefox-locale-en:amd64 41.0+build3-0ubuntu0.14.04.1 41.0.1+build2-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:05 upgrade flashplugin-installer:amd64 11.2.202.521ubuntu0.14.04.1 11.2.202.535ubuntu0.14.04.1&#xA;2015-10-16 09:26:06 upgrade gir1.2-gdkpixbuf-2.0:amd64 2.30.7-0ubuntu1.1 2.30.7-0ubuntu1.2&#xA;2015-10-16 09:26:06 upgrade gir1.2-gudev-1.0:amd64 1:204-5ubuntu20.14 1:204-5ubuntu20.15&#xA;2015-10-16 09:26:07 upgrade linux-headers-3.13.0-65:all 3.13.0-65.105 3.13.0-65.106&#xA;2015-10-16 09:26:12 upgrade linux-headers-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106&#xA;2015-10-16 09:26:15 upgrade linux-image-extra-3.13.0-65-generic:amd64 3.13.0-65.105 3.13.0-65.106&#xA;2015-10-16 09:26:21 upgrade linux-libc-dev:amd64 3.13.0-65.105 3.13.0-65.106&#xA;2015-10-16 09:26:22 upgrade thunderbird-locale-en:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:23 upgrade thunderbird:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:26 upgrade thunderbird-gnome-support:amd64 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:27 upgrade thunderbird-locale-en-us:all 1:38.2.0+build1-0ubuntu0.14.04.1 1:38.3.0+build1-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:27 upgrade liboxideqt-qmlplugin:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:29 upgrade liboxideqtquick0:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:30 upgrade liboxideqtcore0:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:33 upgrade oxideqt-codecs-extra:amd64 1.9.1-0ubuntu0.14.04.2 1.9.5-0ubuntu0.14.04.1&#xA;2015-10-16 09:26:33 upgrade python-tz:all 2012c-1build1 2012c-1ubuntu0.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I checked with Arduino 1.6.0 (which worked till yesterday) and then installed Arduino 1.6.5. Arduino 1.6.5 also fails to upload but definitely recognizes the port. What I get though is the message &quot;Forcing reset using 1200bps open/close on port /dev/ttyACM3...&quot; and then the upload is stuck. To be more precise bossac gets stuck and puts 100% load on one of my cores.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also installed bossash. If I issue a &quot;scan&quot; command bossash will properly detect the correct port. However I will also lockup with 100% load on one of the cores. So the issue is probably not related to the IDE at all but to bossa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone a hint how I might fix this? That is why bossac lock up and how to get it to upload again as it did before?&lt;/p&gt;&#xA;" OwnerUserId="1219" LastActivityDate="2015-10-18T17:39:10.700" Title="Arduino DUE Bossac Lockup after Ubuntu Upgrade" Tags="|arduino-due|ubuntu|bossa|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16959" PostTypeId="1" CreationDate="2015-10-18T17:51:17.890" Score="0" ViewCount="1366" Body="&lt;p&gt;I want to prevent someone from connecting an arduino device to a computer and downloading the code (yes, the hex-dump code) because I want to embed a wifi password inside a device that should be kept secret&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, I stumbled upon &lt;a href=&quot;https://arduino.stackexchange.com/a/180/10606&quot;&gt;this answer&lt;/a&gt; that mentions a security bit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to ask for more details regarding it - i.e. how can I use it, enable it, what are it's limitations, etc. (Preferably for a Teensy v3.2 board, but if it's standard/generic, I would accept such an answer as well). &lt;/p&gt;&#xA;" OwnerUserId="10606" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-16T07:01:51.567" Title="How can I enable the security bit of a teensy board?" Tags="|teensy|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16960" PostTypeId="1" AcceptedAnswerId="16963" CreationDate="2015-10-18T18:50:25.107" Score="0" ViewCount="399" Body="&lt;p&gt;I'm doing a project where I have few sensors on Arduino Uno. Now I am trying to send some data to the internet where i figured using my GSM shield with the Galileo board I have is the best solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing is that software serial is not working on Galileo so I have to use the Serial1 of Galileo board (Pin 0 and Pin 1) and I am out of serial ports. I was thinking of using serial communication between Arduino and Galileo but Galileo seems to have only pin0 and pin1 as serial and they are occupied by the GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any part I am getting wrong or any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(other than using the sensors on Galileo and getting rid of the Arduino Uno :) )&lt;/p&gt;&#xA;" OwnerUserId="14136" LastActivityDate="2015-10-18T19:57:26.680" Title="Communicating Arduino with Intel Galileo" Tags="|serial|gsm|arduino-galileo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16961" PostTypeId="1" AcceptedAnswerId="16966" CreationDate="2015-10-18T19:43:02.007" Score="0" ViewCount="2233" Body="&lt;p&gt;I'm currently assembling a prototype of the lightning infrastructure (&lt;em&gt;based on several MEGAs interconnected via RS485, as described &lt;a href=&quot;https://arduino.stackexchange.com/questions/15834/how-to-interconnect-multiple-arduinos-with-a-rpi-to-control-home-lights-switches&quot;&gt;in this other post&lt;/a&gt;&lt;/em&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The prototype consists of three MEGAs, a couple of &lt;a href=&quot;http://www.vimar.com/en/int/catalog/product/index/code/14008&quot; rel=&quot;nofollow noreferrer&quot;&gt;wall-push-button&lt;/a&gt; and the two relay modules here below:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.aliexpress.com/item/NEW-250V-2A-8-Channel-OMRON-SSR-G3MB-202P-Solid-State-Relay-Module-For-Arduino/32393847675.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;250V 2A 8 Channel OMRON SSR G3MB-202P Solid State Relay Module For Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.aliexpress.com/item/5V-4-CH-OMRON-SSR-G3MB-202P-Solid-Relay-Module-with-Resistive-Fuse-For-Arduino/32419548955.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;5V 4 CH OMRON SSR G3MB-202P Solid Relay Module with Resistive Fuse For Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Obviously I've:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connected one endpoint of each push-buttons to Arduino INPUT-PIN; the other endpoint to ground;&lt;/li&gt;&#xA;&lt;li&gt;connected the relay-module control-pins to Arduino OUTPUT-PIN (and ensuring a properly connected ground).&lt;/li&gt;&#xA;&lt;li&gt;connected lamps to relay-modules power connectors.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My question relates to &quot;&lt;strong&gt;pull-up resistor&lt;/strong&gt;&quot;: I've read in &lt;strong&gt;lots&lt;/strong&gt; of places that when involving push-buttons, &quot;pull-up resistors&quot; are needed in order to prevent shorts between ground and input-pin. As such, there are &lt;strong&gt;lots&lt;/strong&gt; of tutorial/videos on the web, showing a nice resistor added in the push-button circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further investigating, I've also learnt from the official documentation that &quot;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;...There are 20K pullup resistors built into the Atmega chip that can be accessed from software....&lt;/em&gt;&lt;/a&gt;&quot;, by setting the &lt;code&gt;pinMode()&lt;/code&gt; as &lt;code&gt;INPUT_PULLUP&lt;/code&gt; or setting it to &lt;code&gt;INPUT&lt;/code&gt; and the forcing a &lt;code&gt;digitalWrite(&amp;lt;PIN&amp;gt;,HIGH)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I ended:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;directly connecting the two relay-modules to MEGAs INPUT-PINs and...&lt;/li&gt;&#xA;&lt;li&gt;...activating the internal pull-up, with &lt;code&gt;digitalWrite(&amp;lt;INPUT_PIN&amp;gt;,HIGH)&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Nothing more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the second evening I'm &quot;testing&quot; my Arduino-luggage-prototype and... lamps are turning on/off like a charm, without any noticeable problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is: am I doing something nasty toward my MEGAs? Is the approach depicted above, a commonly-safe (as for the Arduino's health) approach?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;P.S.: should you wonder about how the prototype looks like, here is a photo (actually, taken right after the first power-up ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IWbOC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IWbOC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-24T22:54:02.123" Title="Relay module and internal pull-up resistors" Tags="|arduino-mega|relay|pull-up|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16962" PostTypeId="2" ParentId="16952" CreationDate="2015-10-18T19:43:55.993" Score="1" Body="&lt;p&gt;Yes, the ATmega328 will run fine at 8MHz, at 3 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formulas for clock speed vs. volts are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Below 1.8V - cannot operate&lt;/li&gt;&#xA;&lt;li&gt;Below 4 MHz - use at least 1.8V&lt;/li&gt;&#xA;&lt;li&gt;Between 4 MHz and 10 MHz you require: Volts = 1.8 + ((M - 4) * 0.15)&#xA;(Where M is Megahertz)&lt;/li&gt;&#xA;&lt;li&gt;Between 10 MHz and 20 MHz you require: Volts = 2.7 + ((M - 10) * 0.18)&#xA;(Where M is Megahertz)&lt;/li&gt;&#xA;&lt;li&gt;You can supply an absolute maximum of 5.5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Plugging 8MHz into this formula: volts = 1.8+((8-4)*0.15) = 2.4 volts minimum (5.5 volts maximum). Note that, as batteries are used, their voltage goes down gradually, so the 0.6 volts difference will mean that your project will run a little longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since your supply is &gt; 2.7V, we can reverse the second formula: 3V=2.7+(M-10)*0.18); 0.3=(M-10)*0.18; 0.66=M-10, so you can run it at 10.66MHz at 3V (but it is likely to stop as soon as the battery starts to drain).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second question, I think, is the most relevant one - the bootloader is written for 16MHz, and some things will not work at other speeds - serial communications used for programming for example. The same, for that matter, applies to the program - if you put in a &lt;code&gt;delay()&lt;/code&gt; instruction in your code, it will &lt;code&gt;delay()&lt;/code&gt; for twice as long as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get around the programming side by ditching the bootloader altogether - once your code is ready, select file-&gt;upload using programmer. This will still affect the speed your sketch runs at (anything time-related - serial communications, &lt;code&gt;delay()&lt;/code&gt;, etc). To change this, you will need to add a custom entry to the &lt;code&gt;boards.txt&lt;/code&gt; file. See &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=158701.0&quot; rel=&quot;nofollow&quot;&gt;[HOWTO:] Anatomy of the boards.txt file for custom boards&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6936" LastEditDate="2016-01-24T21:48:37.980" LastActivityDate="2016-01-24T21:48:37.980" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16963" PostTypeId="2" ParentId="16960" CreationDate="2015-10-18T19:57:26.680" Score="0" Body="&lt;p&gt;You could use SPI/I2C as interface between Arduino and Galileo.&#xA;They are better than plain serial.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-18T19:57:26.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16964" PostTypeId="2" ParentId="16932" CreationDate="2015-10-18T21:27:16.423" Score="2" Body="&lt;p&gt;You need to include &lt;code&gt;DEC&lt;/code&gt; as the second argument to the &lt;code&gt;Serial.println()&lt;/code&gt; call to get the correct numbers out.  Read up on this here: &lt;a href=&quot;https://www.arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Print&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, make change below: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(number, DEC); // DEC is needed to get the correct values&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14060" LastEditorUserId="46" LastEditDate="2015-10-20T11:47:07.277" LastActivityDate="2015-10-20T11:47:07.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16966" PostTypeId="2" ParentId="16961" CreationDate="2015-10-18T22:30:01.543" Score="0" Body="&lt;p&gt;Connecting one side of a switch to ground and the other side to an input pin (with its pinmode set to INPUT_PULLUP) is a standard way of connecting control switches to an Arduino installation, and is not a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, claims that built-in pull-ups are 20KΩ oversimplifies the situation.  See, for example, Table 28.2, DC Characteristics, in the ATmega48PA/88PA/168PA/328P specs, which shows a min value of 20KΩ for   I/O Pin Pull-up Resistors and a max value of 50KΩ.  I've measured resistances of about 40KΩ, IIRC, whenever I've measured the pull-up values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, built-in pull-ups typically are of too much resistance to work as pull-ups for TWI/SPI/I2C communications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, when you say in the question that you connected the relay-modules to input pins and they worked ok, I suppose that could be the case, but in general it is better to put i/o pins into output mode when you want to drive an output.  When you send LOW to an input pin, its built-in pull-up is turned off, the input impedance becomes high, and then the pin can float to any value between ground and Vcc. It might fail to turn off an attached device if that device also has high impedance.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-18T22:30:01.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16967" PostTypeId="1" CreationDate="2015-10-18T22:34:54.293" Score="0" ViewCount="341" Body="&lt;p&gt;So in computer engineering I've got to make a arduino based car, I've added a whole bunch of features such as IR tracking, obstacle avoidance(proximity sensor), optical tracking(follow a black line), and remote control through an android based phone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I'm a total newbie to technology I'm having trouble. I would appreciate it if You guys can point me towards resources and arduino libraries(for coding) that will work for me. Right now for coding I've only got basic pseudo-code setup since I do not know what libraries to use. I have searched up many sketches online and looked at them but didn't really understand any of the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the basic pseudo-code I got setup on the things that I've got to work on:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;DC Motor&lt;/strong&gt; (4 of em for the wheels) (I also plan to add a stepper motor for turning right and left so if you could direct me on that as well)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Import necessary library&#xA;//Setup the motors and pins&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//If signal for forward received&#xA;//Code for moving forward&#xA;//Set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Else If signal for backward received&#xA;//Code for moving backward&#xA;//Set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Else If signal for right received (keep turning right till stop signal received)&#xA;//Code for moving right&#xA;//Set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Else If signal for left received (keep turning left till stop signal received)&#xA;//Code for moving left&#xA;//Set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Else If signal for stop is received (Should we slow down to a stop or just stop?)&#xA;//Code for stop&#xA;//Set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;IR&lt;/strong&gt; (I've got transmitting and recording diodes)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Import Library&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Declare Pin for the IR Sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//While loop: Move Right&#xA;//If IR signal is received&#xA;//move forward&#xA;//Else&#xA;//Jump back to top of loop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Proximity Sensor&lt;/strong&gt; (obstacle avoidance mode) (I might either use the one from Lego kit or buy a separate one )&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Import Library&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//Declare Pin for proximity sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//While Loop: Send out sonar(echolocation or whatever) every second&#xA;//Is there any obstacle?&#xA;  //Yes, turn right so many degrees, and go back to while loop&#xA;  //No, move on forward at set speed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;//If you’re surrounded and cannot exit send out a message through flashing LED's&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm not asking for the code or for any of you to do all my stuff for me, I'm just asking for direction and resources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You&lt;/p&gt;&#xA;" OwnerUserId="14139" LastActivityDate="2016-02-16T07:40:19.683" Title="Help with arduino car project" Tags="|arduino-uno|programming|sensors|motor|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16968" PostTypeId="2" ParentId="16961" CreationDate="2015-10-18T22:41:44.810" Score="0" Body="&lt;p&gt;I am making the assumption the push buttons are wired directly to the mega.  This may work but for me it is not acceptable.  Why?  All of those wires act as an antenna array tuned to a lot of different frequencies.  My favorite trick is to use a 74C14 Schmidt trigger chip.  The reason is several fold. First it isolates the antennas from the processor.  The family I use will tolerate about 25volts input, giving a lot of head room.  Second it makes the software a bit easier, all switches come in positive true. Third I use a low pass network in front so if one of the mains hits it it will probably survive.  What I do is Pull up with a resistor that will cause about 1.5 ma to flow through the switch.  This value is dependent on your voltage, I typically use 12 or  24 VDC.  This input then goes through a 100K resistor to the input of the gate where I also put a .01 uF cap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also working on a similar project, I made the same decision on a hardwired network about 15 years ago.  All the switching is on several output boards (5V) located in a PC AT. I also chose the mega for several reasons, first I needed full duplex with my network, the MAX485 will do that you just have to leave the receive enabled and cycle the transmit when you want to send something.  I also added a low pass on the (A line I Think) to another pin so I could determine if the network was busy,  I currently have about 150 outputs with very few inputs.  Code is all in ASM86.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps, I will see if I can add to your reference question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-18T22:41:44.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16969" PostTypeId="2" ParentId="16933" CreationDate="2015-10-18T22:50:58.883" Score="1" Body="&lt;p&gt;The function &lt;code&gt;dtostrf()&lt;/code&gt; is prototyped as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *dtostrf (double          val,&#xA;               signed char     width,&#xA;               unsigned char   prec,&#xA;               char           *sout);&#xA;&#xA;Where:    &#xA;   val      Your float variable;&#xA;   width    Length of the string that will be created INCLUDING decimal point;&#xA;   prec     Number of digits after the deimal point to print;&#xA;   sout     Destination of output buffer;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An example of usage is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* OPTION ONE */&#xA;&#xA;    char msgBuffer[20];           // make sure this is big enough to hold your string&#xA;    char *pointer_to_created_string;&#xA;&#xA;    float testFloat = 123.45;&#xA;&#xA;    pointer_to_created_string = dtostrf(testFloat, 6, 2, msgBuffer);&#xA;    client.Publish(&quot;...topic...&quot;, pointer_to_created_string);&#xA;&#xA;/* OPTION TWO */&#xA;&#xA;    char msgBuffer[20];           // make sure this is big enough to hold your string&#xA;&#xA;    float testFloat = 123.45;&#xA;&#xA;    client.Publish(&quot;...topic...&quot;, dtostrf(testFloat, 6, 2, msgBuffer));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't be put off by the code in the link you included in your question. The first argument sent to &lt;code&gt;dtostrf&lt;/code&gt; (everything before the first comma) is nothing more than a some calculations bundled into one single line.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-10-18T22:50:58.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16970" PostTypeId="2" ParentId="16967" CreationDate="2015-10-18T22:52:41.943" Score="1" Body="&lt;p&gt;1) start simple - adding extra features will not help you, especially if you have a deadline&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) implement and test code for each low level function separately - however, in case you use libraries and or snippets, make sure that if a library/snippet requires exclusive use of a certain feature (ex: a timer), others do not need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) test the overall logic elsewhere, where it easier to debug (ex: on a PC), by replacing the actual function calls to low level actuators/sensors with mockup functions that do I/O through either a file or a console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Said this, what do you mean that you didn't understand the examples you found? To understand most of them, you need at least to read the API/interface of the libraries they use. And also reading the reference manual of the ATMega328P for the HW blocks referred by each library will help getting an overall feeling of what the library does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the basic physical model: once you have 4 DC motors (but 2 plus a caster would be enough), why do you want to add a stepper? Youc could do all of it with just 2 stepper motors , which will give you a simpler way to control precisely the orientation of the robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest you to get the basic movement sorted out, before worrying about the rest. Just make sure that it doesn't make exclusive use of the microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-18T22:52:41.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16971" PostTypeId="2" ParentId="15834" CreationDate="2015-10-18T23:40:39.597" Score="2" Body="&lt;p&gt;Remember RS485 is not a protocol, it is a definition of a physical transport layer.  With the Mega as you chose you can use serial 1,2,3 and run them in full duplex mode over the RS485 network e.e. you can receive what you send.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it operating in a multi master configuration.  Each mega when it transmits it also receives what it just sent and can determine on a byte by byte basis if it needs to back off.  The delay before coming back on line is determined by the node address and when the bus becomes available.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code will use the write function instead of the print function allowing each byte to be checked. (In time I probably will do it via software and emulate CAN or just use a can controller). Yes 8 bits works just fine, the ninth bit is a parity bit or other uses depending on who is defining it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My test system is operating with packets and sends in this format: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;|Length|Target|Source|Sequence|Command|Flags|Data|Check &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and expects an ACK in response.  This is relative simple first pass and has no illegal codes. All bytes are Hex but you can use what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives me Carrier Sense, multiple access but with destructive arbitration.  If you want CSMANDA just use a CAN physical layer or bit bang the data you send then you can arbitrate on a bit by bit basis.  It won't be that much different in software other then the transmit portion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am planning on using the RPi with Linux as the main node. With 8 bit data it will work just fine.  I just started about two weeks ago on this configuration and so far it is going well. I am operating at 9600 baud and have a lot of free time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-18T23:40:39.597" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16972" PostTypeId="2" ParentId="16884" CreationDate="2015-10-18T23:55:26.153" Score="0" Body="&lt;p&gt;Try looking at Alarm PID units, they typically will operate on 12VDC and have a relay output contact and a tamper contact.  They are not that expensive and come with a case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-18T23:55:26.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16973" PostTypeId="2" ParentId="16852" CreationDate="2015-10-19T00:00:23.600" Score="0" Body="&lt;p&gt;Remove the wire from the collector of your transistor and 12VDC, it should work fine.  It is possible you blown the opto coupler and transistor.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:00:23.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16974" PostTypeId="2" ParentId="16759" CreationDate="2015-10-19T00:03:11.793" Score="0" Body="&lt;p&gt;I am not sure what you are asking but you can have as many interrupt sources on a single interrupt pin as you want.  When the interrupt happens in your ISR (Interrupt Service Routine) you simply check each one and process the ones that are valid.  Be sure to do one final check before exiting as another could happen while servicing the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:03:11.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16975" PostTypeId="2" ParentId="16742" CreationDate="2015-10-19T00:09:03.163" Score="1" Body="&lt;p&gt;I would suggest using a different power supply, that appears to be your problem.  250mV is 1/4 of a volt, that is a lot of noise/ripple.  I am assuming it is ripple from the AC mains.  The series resister is way to large, try something about 0.1 ohm.  Also put a filter cap on the load side of the resister.  If you have high frequency noise add a 0.01 cap that will help.  Be sure the grounds between the units are solid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a feeling it is narrow fast rising spikes.  If so the odds are very high it is the power supply.  Can you try an analog one and see if the problem goes away?  Try adding more bulk capacitance, at the rate of at least 1000uF per amp.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="14095" LastEditDate="2015-10-21T20:36:51.420" LastActivityDate="2015-10-21T20:36:51.420" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16976" PostTypeId="2" ParentId="16737" CreationDate="2015-10-19T00:12:22.363" Score="1" Body="&lt;p&gt;I would use one of the serial interfaces and connect them together that way.  If Asyinc run as fast as reliable.  &lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:12:22.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16977" PostTypeId="2" ParentId="16734" CreationDate="2015-10-19T00:15:23.580" Score="1" Body="&lt;p&gt;Do not worry about limiting it to 12 bits, send all 16 and use just the twelve you need.  You never know you may expand the project.  Whatever is on the unused bits is irrelevant. they do nothing.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:15:23.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16978" PostTypeId="2" ParentId="16932" CreationDate="2015-10-19T00:17:37.390" Score="1" Body="&lt;p&gt;&lt;code&gt;Serial.read()&lt;/code&gt; returns one character from the input. &lt;code&gt;Serial.println&lt;/code&gt; will try to convert a variable into ASCII characters, and print that. Your variable, &lt;code&gt;number&lt;/code&gt; gets the ASCII code of the first typed character in its first byte. The &lt;code&gt;Serial.println&lt;/code&gt; call will interpret that and the next 3 bytes (whatever they happen to be...?) as a value to be printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your problem is in not understanding the conversion of digit strings into values and vice-versa, and of how the Serial.xxx functions work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to collect the terminal input character-by-character into an array, then convert it to a numeric value (assuming you're eventually going to do more with it than print it back out). Then you could &lt;code&gt;Serial.println()&lt;/code&gt; that (or another) value out to the terminal.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-19T00:17:37.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16979" PostTypeId="2" ParentId="16697" CreationDate="2015-10-19T00:18:10.937" Score="-1" Body="&lt;p&gt;Yes but you need to know what you are doing.  You will need a clock driver and possibly a clock receiver depending on the devices you select.  Then you need to modify both boards voiding any possible warranty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best answer is NO!&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:18:10.937" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16980" PostTypeId="2" ParentId="16559" CreationDate="2015-10-19T00:21:54.543" Score="0" Body="&lt;p&gt;That is one of the hardware features/functions of the microprocessor.  It is like a bag of candy when you eat the last piece there is no more left.  You can do software PWM but that can use a lot of compute power.  You can also get PWM peripheral devices you can connect to it.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:21:54.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16981" PostTypeId="1" CreationDate="2015-10-19T00:22:23.733" Score="3" ViewCount="868" Body="&lt;p&gt;I just got into an interesting mess.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 3 Arduino's (Pro Mini's) and 2x Teensy's (3.1's) connected via I2C to a Raspberry Pi Master. The 2x Teensy's I2C data lines are connected via OctoBoards but that doesn't really matter since the OctoBoard maps the I2C Pin's of the Teensy to itself. I have 4k7 pullup resistors for SDA/SLC close to the master (also tried on the end - with no effect). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's alone are super solid - no issues other than the occasionally I2C lockup when writing data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cwqPe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cwqPe.png&quot; alt=&quot;Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The I2C interface has been running for over 3h with no problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now as soon I add a Teensy to it, the bus locks-up and I need to completely shut down everything. Only thing I got to work was direct connection from RPI -&gt; Teensy and even then there were sporadic detection issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the Wire lib as well the IC2_T3 lib with no difference. Also tried with 4 different Teensy's with no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the Teensy's not compatible with RPI?&lt;/p&gt;&#xA;" OwnerUserId="14140" LastActivityDate="2023-01-12T09:08:11.040" Title="Raspberry Pi, Teensy and Arduino's on i2c" Tags="|i2c|arduino-pro-mini|teensy|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16982" PostTypeId="2" ParentId="16533" CreationDate="2015-10-19T00:26:27.070" Score="1" Body="&lt;p&gt;If you check the specifications they stat 12VDC is the max.  Your on board regulator is probably very hot and either shutting down or allowing the voltage to sag.  You can get a 9V wall Wart for under $5.  the 9V will keep the on-board regulator much cooler and add reliability.  &lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:26:27.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16983" PostTypeId="2" ParentId="16525" CreationDate="2015-10-19T00:29:14.487" Score="0" Body="&lt;p&gt;After you check the LDR specification you can use an online Ohm's Law calculator and calculate the resistance you need.  Be sure the power rating of the resistor is greater then what is shown.  Less it will smoke more is good but size is also important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-19T00:29:14.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16984" PostTypeId="2" ParentId="16959" CreationDate="2015-10-19T02:12:16.073" Score="0" Body="&lt;p&gt;It is possible for the AtMega processors - like the Teensy 2.0 (see &lt;a href=&quot;https://www.pjrc.com/teensy/&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/&lt;/a&gt; ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Work out your exact code. It will be a pain to update it once this is done, so thing carefully.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Upload the code using ICSP (file-&gt;upload using programmer). TEST IT HERE!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Work out the fuse you need to set. The important one is &quot;RSTDISBL&quot; - this disables the reset pin (makes it behave just like a regular pin).  Use the page at &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;http://www.engbedded.com/fusecalc/&lt;/a&gt; to calculate your fuse settings.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;DOUBLE CHECK IT!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an ICSP to set the fuse. You will need to work out the 6 pins to connect the ICSP to, since there is no standard ICSP header.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you did everything right, and the reset pin no longer works - this will protect the code from download!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anything went wrong (e.g. you set the wrong fuse values - I've been there), or if you want to change the code, you will run into problems. In theory, you can use a high-voltage programmer - like &lt;a href=&quot;http://www.societyofrobots.com/member_tutorials/node/239&quot; rel=&quot;nofollow&quot;&gt;http://www.societyofrobots.com/member_tutorials/node/239&lt;/a&gt; - to reset everything to factory, but that takes 20 volts, and there's a high chance one of the other components on the Teensy board will be damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, if you do use the High-voltage programmer, the chip's memory will be wiped, so this can't be used to recover your code.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-19T02:12:16.073" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="16985" PostTypeId="1" AcceptedAnswerId="17018" CreationDate="2015-10-19T02:54:52.490" Score="1" ViewCount="779" Body="&lt;p&gt;Firstly, I know that I have already posted this. I do not think anyone here is stupid so:&#xA;The game is: a power source connected to 6 buttons connected to 6 LEDs. you press them all in the randomly generated order, and they blink in the order pressed after completion, then randomize and reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an array shuffler code  1)Does the array shuffler work 2)How do I configure ports and attach them to values in the array, 3) How do I use an if-then statement to say if all buttons pressed in order, then LEDs blink 3 times?  I have a picture but not the actual Arduino, so, upon request, I can post the picture. Thank you. code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    // put your setup code here, to run once:&#xA;}&#xA;&#xA;void loop() {&#xA;    // put your main code here, to run repeatedly:&#xA;    int questionNumberArray[] = {0,1,2,3,4,5,6};//the array itself&#xA;    const size_t n = sizeof(questionNumberArray) / //the array used&#xA;    sizeof(questionNumberArray[0]);//the base of the array&#xA;&#xA;    for (size_t i = 0; i &amp;lt; n - 1; i++) //the loop itself&#xA;    {&#xA;        size_t j = random(1, n - i);&#xA;        int t = questionNumberArray[i]; //integer output for increase&#xA;        questionNumberArray[i] = questionNumberArray[j];//the value definition&#xA;        questionNumberArray[j] = t;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The six buttons are connected to digital pins (1, 2, 9, 11, 12, 13)&lt;/p&gt;&#xA;" OwnerUserId="14124" LastEditorUserId="13840" LastEditDate="2015-10-22T21:02:24.950" LastActivityDate="2015-10-22T21:02:24.950" Title="A whole basic game project Arduino" Tags="|arduino-uno|programming|c++|arduino-ide|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="16986" PostTypeId="2" ParentId="16959" CreationDate="2015-10-19T02:58:35.547" Score="0" Body="&lt;p&gt;While this does not answer your question, I believe it may help you with an alternative approach, which won't hide it completely, but will make it a lot harder to figure out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than keeping the password in plain text (which will be easy to spot in a hex dump), you can hide it somewhat. For example, exclusive-or each byte of the password with a randomly chosen number, put the result in your code; then, when you want to log in to the wifi, exlusive-or it with the same numbers (which must also be on your code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that all the information required MUST be on the Teensy, so it is not impossible to reverse engineer; however, it will be hidden from casual inspection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, although more complex obfustication is possible (using any off-the-shelf encryption), since both the code and any keys will be available to an attacker, it is a token gesture only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Teensy v3 has JTAG, which means a running Teensy can be inspected, single-stepped, all memory and pin states can be viewed &amp;amp; modified. Once someone has your device, it's pretty much a lost cause against a determined attacker.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-10-19T02:58:35.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="16987" PostTypeId="1" CreationDate="2015-10-19T03:37:42.853" Score="2" ViewCount="2134" Body="&lt;p&gt;So I recently bought this off brand arduino uno from betemcu.cn.&#xA;it says its r3 compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I program this thing with the arduino coder or do I need to use something else? whenever I try uploading the code it says &quot;problem uploading to board&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what settings or program should I use to code this?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/DMzKg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DMzKg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WUIJx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WUIJx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Corey Selby" LastActivityDate="2018-02-26T04:44:27.510" Title="How to program an offbrand arduino uno?" Tags="|sketch|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="16988" PostTypeId="1" AcceptedAnswerId="16993" CreationDate="2015-10-19T04:26:07.320" Score="0" ViewCount="1019" Body="&lt;p&gt;I am using a Sr04 Ultrasonic distance sensor with Uno clone for making a Alarm. The basic idea behind this project is that In Setup, Read the distance And store it in a varibale as Threshold. And in Loop, Check the distance readings regularly and if the Reading anytime is not equal to The threshold (that means someone interrupted in front of ultrasonic sensor), then a led flashes. I Know that is system is not enough good because the real world is a bit noisy. My problem is I am storing the theshold distance in &quot;int&quot; variable. The compiling error is &quot;Cant convert Long Unsigned char to Int&quot; something like this. Please tell me how can I store the reading of my sr04 sensor in a variable. I am using NewPing Library. &lt;/p&gt;&#xA;" OwnerUserId="11772" LastActivityDate="2015-10-19T07:59:51.920" Title="How to Store the Value of A Sr04 Ultrasonic distance sensor (ping)?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16990" PostTypeId="2" ParentId="16988" CreationDate="2015-10-19T05:09:40.277" Score="-1" Body="&lt;p&gt;If you want to store it as int, you have to firstly store it in a long type then convert it into int.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long i;&#xA;int j;&#xA;i = getReading();&#xA;j = (int) i;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are many ways to do it, for example you can also use rounding to convert it into integer variable.&lt;/p&gt;&#xA;" OwnerUserId="13931" LastActivityDate="2015-10-19T05:09:40.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="16991" PostTypeId="2" ParentId="16734" CreationDate="2015-10-19T05:12:51.413" Score="1" Body="&lt;p&gt;If you use 74HC595, you have to send data to all the bits no matter what. Even if you only want to change 1 bit, you have to resend the whole bit sequence.&lt;/p&gt;&#xA;" OwnerUserId="13931" LastActivityDate="2015-10-19T05:12:51.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16992" PostTypeId="1" CreationDate="2015-10-19T06:09:33.990" Score="1" ViewCount="34" Body="&lt;p&gt;Alright, so this code is for a game that is a power source connected to 6 buttons at ports 1, 2, 9, 11, 12, and 13. These are consequently supposed to light up 6 LEDs, each connected to 1. If you press the buttons in the right order, all the LEDs blink at once. Does it work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin1 = 1;&#xA;int ledPin2 = 2;&#xA;int ledPin3 = 9;&#xA;int ledPin4 = 11;&#xA;int ledPin5 = 12;&#xA;int ledPin6 = 13;&#xA;&#xA;void setup() {&#xA;//put your setup code here, to run once:&#xA;}&#xA;void loop() {&#xA;//put your main code here, to run repeatedly:&#xA;int QuestionNumberArray[] = {1, 2, 9, 11, 12, 13};//the array itself&#xA;const size_t n = sizeof(questionNumberArray) //the array used&#xA;sizeof(questionNumberArray[0]);//the base of the array&#xA;&#xA;for (size_t i = 0; i &amp;lt; n - 1; i++) //the loop itself&#xA;{&#xA;size_t j = random(1, n-i);&#xA;int t = questionNumberArray[i]; //integer output for increase&#xA;questionNumberArray[i] = questionNumberArray[j];//the value definition&#xA;questionNumberArray[j] = t;&#xA;pinMode(questionNumberArray, INPUT);&#xA;if(digitalRead(questionNumberArray) == HIGH) {&#xA;then(digitalRead(1, 2, 9, 11, 12, 13) == HIGH)&#xA;break; &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, how do I make it so that people have multiple tries to do it, or is it already like that?&#xA;Thank you&lt;/p&gt;&#xA;" OwnerUserId="14124" LastEditorUserId="46" LastEditDate="2015-10-20T12:28:22.510" LastActivityDate="2015-10-20T12:28:22.510" Title="Loop completion and resetting" Tags="|arduino-uno|arduino-ide|" AnswerCount="0" CommentCount="1" ClosedDate="2015-10-19T09:25:58.743" ContentLicense="CC BY-SA 3.0" />
  <row Id="16993" PostTypeId="2" ParentId="16988" CreationDate="2015-10-19T07:59:51.920" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;First you must verify that storing the value as int is even possible: long int can represent much larger values than int. Are you 100% sure that the maximum reading you will ever get can be represented as int?&lt;/li&gt;&#xA;&lt;li&gt;In case the answer to the previous question is &quot;yes&quot;, then you can just cast it on the fly:&#xA;&lt;code&gt;int int_val = (int)function_returning_longint();&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In case the answer is &quot;no&quot;, you can either give up the idea of using int and stick with long, which is not necessarily bad, or you can scale down the value, at the price of loosing some resolution:&#xA;&lt;code&gt;int int_val = function_returning_longint() &amp;gt;&amp;gt; 8;&lt;/code&gt; This assumes that long is 16 bit and int is 8 bit, but it would be preferable to use explicit types, like &lt;code&gt;int8_t&lt;/code&gt; and &lt;code&gt;int16_t&lt;/code&gt;. And in your case you might have to shift by a different value than 8.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Either way, do not make casts of from big type to small type without being 100% sure that the max value you will ever deal with can fit in the small type.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-19T07:59:51.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16995" PostTypeId="1" CreationDate="2015-10-19T09:38:44.907" Score="0" ViewCount="1783" Body="&lt;p&gt;I am developing GPRS HTTP send request code using a GSM/GPRS module. I found the following code via google:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*************************************************************************&#xA;* SIM800 GPRS/HTTP Library&#xA;* Distributed under GPL v2.0&#xA;* Written by Stanley Huang &amp;lt;stanleyhuangyc@gmail.com&amp;gt;&#xA;* For more information, please visit http://arduinodev.com&#xA;*************************************************************************/&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;// change this to the pin connect with SIM800 reset pin&#xA;#define SIM800_RESET_PIN 7&#xA;&#xA;// change this to the serial UART which SIM800 is attached to&#xA;#define SIM_SERIAL Serial&#xA;&#xA;&#xA;// define DEBUG to one serial UART to enable debug information output&#xA;//#define DEBUG Serial&#xA;&#xA;typedef enum {&#xA;    HTTP_DISABLED = 0,&#xA;    HTTP_READY,&#xA;    HTTP_CONNECTING,&#xA;    HTTP_READING,&#xA;    HTTP_ERROR,&#xA;} HTTP_STATES;&#xA;&#xA;typedef struct {&#xA;  float lat;&#xA;  float lon;&#xA;  uint8_t year; /* year past 2000, e.g. 15 for 2015 */&#xA;  uint8_t month;&#xA;  uint8_t day;&#xA;  uint8_t hour;&#xA;  uint8_t minute;&#xA;  uint8_t second;&#xA;} GSM_LOCATION;&#xA;&#xA;class CGPRS_SIM800 {&#xA;public:&#xA;    CGPRS_SIM800():httpState(HTTP_DISABLED) {}&#xA;    // initialize the module&#xA;    bool init();&#xA;    // setup network&#xA;    byte setup(const char* apn);&#xA;    // get network operator name&#xA;    bool getOperatorName();&#xA;    // check for incoming SMS&#xA;    bool checkSMS();&#xA;    // get signal quality level (in dB)&#xA;    int getSignalQuality();&#xA;    // get GSM location and network time&#xA;    bool getLocation(GSM_LOCATION* loc);&#xA;    // initialize HTTP connection&#xA;    bool httpInit();&#xA;    // terminate HTTP connection&#xA;    void httpUninit();&#xA;    // connect to HTTP server&#xA;    bool httpConnect(const char* url, const char* args = 0);&#xA;    // check if HTTP connection is established&#xA;    // return 0 for in progress, 1 for success, 2 for error&#xA;    byte httpIsConnected();&#xA;    // read data from HTTP connection&#xA;    void httpRead();&#xA;    // check if HTTP connection is established&#xA;    // return 0 for in progress, -1 for error, bytes of http payload on success&#xA;    int httpIsRead();&#xA;    // send AT command and check for expected response&#xA;    byte sendCommand(const char* cmd, unsigned int timeout = 2000, const char* expected = 0);&#xA;    // send AT command and check for two possible responses&#xA;    byte sendCommand(const char* cmd, const char* expected1, const char* expected2, unsigned int timeout = 2000);&#xA;    // toggle low-power mode&#xA;    bool sleep(bool enabled)&#xA;    {&#xA;      return sendCommand(enabled ? &quot;AT+CFUN=0&quot; : &quot;AT+CFUN=1&quot;);&#xA;    }&#xA;    // check if there is available serial data&#xA;    bool available()&#xA;    {&#xA;      return SIM_SERIAL.available(); &#xA;    }&#xA;    char buffer[256];&#xA;    byte httpState;&#xA;private:&#xA;    byte checkbuffer(const char* expected1, const char* expected2 = 0, unsigned int timeout = 2000);&#xA;    void purgeSerial();&#xA;    byte m_bytesRecv;&#xA;    uint32_t m_checkTimer;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is I have no idea how to change or define Rx and Tx Pin. If I define SIM_SERIAL serial1 it's showing me error. I want to change it to pins 10 and 11.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is other code whenever I try to compile it shows me error on &quot;serial1&quot; online. above code is sim800.h file &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is program code of send data through http&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;SIM800.h&quot;&#xA;&#xA;#define APN &quot;connect&quot;&#xA;#define con Serial&#xA;static const char* url = &quot;http://arduinodev.com/datetime.php&quot;;&#xA;&#xA;CGPRS_SIM800 gprs;&#xA;uint32_t count = 0;&#xA;uint32_t errors = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  con.begin(9600);&#xA;  while (!con);&#xA;&#xA;  con.println(&quot;SIM800 TEST&quot;);&#xA;&#xA;  for (;;) {&#xA;    con.print(&quot;Resetting...&quot;);&#xA;    while (!gprs.init()) {&#xA;      con.write('.');&#xA;    }&#xA;    con.println(&quot;OK&quot;);&#xA;&#xA;    con.print(&quot;Setting up network...&quot;);&#xA;    byte ret = gprs.setup(APN);&#xA;    if (ret == 0)&#xA;      break;&#xA;    con.print(&quot;Error code:&quot;);&#xA;    con.println(ret);&#xA;    con.println(gprs.buffer);&#xA;  }&#xA;  con.println(&quot;OK&quot;);&#xA;  delay(3000);  &#xA;&#xA;  if (gprs.getOperatorName()) {&#xA;    con.print(&quot;Operator:&quot;);&#xA;    con.println(gprs.buffer);&#xA;  }&#xA;  int ret = gprs.getSignalQuality();&#xA;  if (ret) {&#xA;     con.print(&quot;Signal:&quot;);&#xA;     con.print(ret);&#xA;     con.println(&quot;dB&quot;);&#xA;  }&#xA;  for (;;) {&#xA;    if (gprs.httpInit()) break;&#xA;    con.println(gprs.buffer);&#xA;    gprs.httpUninit();&#xA;    delay(1000);&#xA;  }&#xA;  delay(3000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  char mydata[16];&#xA;  sprintf(mydata, &quot;t=%lu&quot;, millis());&#xA;  con.print(&quot;Requesting &quot;);&#xA;  con.print(url);&#xA;  con.print('?');&#xA;  con.println(mydata);&#xA;  gprs.httpConnect(url, mydata);&#xA;  count++;&#xA;  while (gprs.httpIsConnected() == 0) {&#xA;    // can do something here while waiting&#xA;    con.write('.');&#xA;    for (byte n = 0; n &amp;lt; 25 &amp;amp;&amp;amp; !gprs.available(); n++) {&#xA;      delay(10);&#xA;    }&#xA;  }&#xA;  if (gprs.httpState == HTTP_ERROR) {&#xA;    con.println(&quot;Connect error&quot;);&#xA;    errors++;&#xA;    delay(3000);&#xA;    return; &#xA;  }&#xA;  con.println();&#xA;  gprs.httpRead();&#xA;  int ret;&#xA;  while ((ret = gprs.httpIsRead()) == 0) {&#xA;    // can do something here while waiting&#xA;  }&#xA;  if (gprs.httpState == HTTP_ERROR) {&#xA;    con.println(&quot;Read error&quot;);&#xA;    errors++;&#xA;    delay(3000);&#xA;    return; &#xA;  }&#xA;&#xA;  // now we have received payload&#xA;  con.print(&quot;[Payload]&quot;);&#xA;  con.println(gprs.buffer);&#xA;&#xA;  // show position&#xA;  GSM_LOCATION loc;&#xA;  if (gprs.getLocation(&amp;amp;loc)) {&#xA;    con.print(&quot;LAT:&quot;);&#xA;    con.print(loc.lat, 6);&#xA;    con.print(&quot; LON:&quot;);&#xA;    con.print(loc.lon, 6);&#xA;    con.print(&quot; TIME:&quot;);&#xA;    con.print(loc.hour);&#xA;    con.print(':');&#xA;    con.print(loc.minute);&#xA;    con.print(':');&#xA;    con.println(loc.second);&#xA;  }&#xA;&#xA;  // show stats  &#xA;  con.print(&quot;Total Requests:&quot;);&#xA;  con.print(count);&#xA;  if (errors) {&#xA;    con.print(&quot; Errors:&quot;);&#xA;    con.print(errors);&#xA;  }&#xA;  con.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i already know how to send data through http using AT command and software serial library here is  my code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.write(&quot;AT\n&quot;);&#xA;  delay(1000);&#xA;  mySerial.write(&quot;AT+CSQ\n&quot;);&#xA;  delay(1000);&#xA;  mySerial.write(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;internet\&quot;\n&quot;);&#xA;  delay(2000);&#xA;  mySerial.write(&quot;\nAT+SAPBR=1,1\n&quot;);&#xA;  delay(1000);&#xA;  mySerial.write(&quot;AT+HTTPINIT\n&quot;);&#xA;  delay(1000);&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;    delay(1000)&#xA;    serial.print(enter key)&#xA;  }&#xA;  if (Serial.available()) {&#xA;    delay(2000);&#xA;     mySerial.write(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;http://www.mydomain.in/index.php?dt=testdata\&quot;\n&quot;);&#xA;     delay(2000);&#xA;     mySerial.write(&quot;AT+HTTPACTION=0\n&quot;);&#xA;      delay(2000);&#xA;      mySerial.write(&quot;\n&quot;);&#xA;    mySerial.write(Serial.read());&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this code I define Rx Tx (UART)pin. Can you please suggest me any idea how can i define RX Tx pin in sim800.h file. because serial1 give me error on compiling time  &lt;/p&gt;&#xA;" OwnerUserId="13661" LastEditorUserId="26916" LastEditDate="2017-09-09T15:17:35.747" LastActivityDate="2017-09-09T15:17:35.747" Title="Change UART pin" Tags="|softwareserial|uart|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="16996" PostTypeId="2" ParentId="13053" CreationDate="2015-10-19T10:09:09.507" Score="1" Body="&lt;p&gt;Your stick goes into the chassis at some point. &#xA;Why not detect the position down there? &#xA;But to be sure to save fuel, you'd need to know the rpm/speed and especially the load of the engine. If you are going at a high gear and low speed you won't save fuel either, so the knob is not the right place to detect the gear in question. &#xA;Go for OBD, get the ratio of speed and rpm and get the load or injection quantities. If you go up the hill and select too high a gear, you won't be happy either.&lt;/p&gt;&#xA;" OwnerUserId="14004" LastActivityDate="2015-10-19T10:09:09.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16997" PostTypeId="2" ParentId="16987" CreationDate="2015-10-19T10:14:15.663" Score="3" Body="&lt;p&gt;&lt;strong&gt;The issue is probably that you need a driver for the onboard CH340G USB-to-serial bridge.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Baite Electronics Arduino clones are generally of good quality and work well.&lt;br&gt;&#xA;There are some differences between them and Arduino-brand Arduinos. Two notable ones are a different voltage regulator and (probably the issue here) a different USB-to-serial bridge IC.  The Arduino brand products use an FTDI IC and Baite uses, in this case, the CH340 USB bridge IC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The product is described &lt;a href=&quot;http://www.aliexpress.com/store/product/10pcs-lot-high-quality-UNO-R3-MEGA328P-CH340G-for-Arduino-Compatible-Improved-version-expert-version-NO/812021_1933705621.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;on this webpage&lt;/strong&gt;&lt;/a&gt; and you will see that they say&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UNO MEGA328P &lt;strong&gt;CH340G&lt;/strong&gt; for Arduino Compatible&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The CH340G relates to the USB interface IC.&lt;br&gt;&#xA;Until about a year ago the USB driver in windows worked with most common USB ICs as well as with FTDI ICs.  However, FTDI changed their system so that the Windows driver will now only work with FTDI brand ICs. So it is now necessary to load a driver into the PC (whether Windows, Linux or other O/S) to suit the CH340.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you email them Baite will provide a link to the CH340 driver, but they do not usually provide it on their website (reason unknown to me.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you can obtain a driver from numerous websites.&lt;br&gt;&#xA;&lt;a href=&quot;https://www.google.co.nz/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=ch340%20baite%20arduino%20driver&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;A web search on eg:  driver ch340 baite arduino&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&#xA;turns up many pages.   How good or how safe any of these is is TBD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduined.eu/ch340g-converter-windows-7-driver-download/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;This page&lt;/strong&gt;&lt;/a&gt; claims to provide a Windows 7 CH340G driver and install instructions&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Ix4t-_RZ7NI&quot; rel=&quot;nofollow noreferrer&quot;&gt;This YouTube video&lt;/a&gt; describes how to install a driver and provides a link to &lt;a href=&quot;http://www.wch.cn/download/CH341SER_EXE.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page&lt;/a&gt; which lists a number of drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://doityourselfchristmas.com/forums/showthread.php?14690-CH340-USB-RS232-Driver&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;This page discusses the issue&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="26916" LastEditDate="2018-02-26T04:44:27.510" LastActivityDate="2018-02-26T04:44:27.510" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="16998" PostTypeId="2" ParentId="16987" CreationDate="2015-10-19T10:19:37.087" Score="0" Body="&lt;p&gt;Just install your driver. Some might install automatically. Then try to upload the sketch using arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="14103" LastActivityDate="2015-10-19T10:19:37.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="16999" PostTypeId="1" AcceptedAnswerId="20121" CreationDate="2015-10-19T10:40:29.123" Score="1" ViewCount="760" Body="&lt;p&gt;I'm not the best at Arduino so I'm sorry for my &quot;noobiness&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm extending some code that I found online to work on the gyroscope that I'm building.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what the difference is between &lt;code&gt;pow&lt;/code&gt; and &lt;code&gt;sqrt&lt;/code&gt; in this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also wondering what the &lt;code&gt;180/pi&lt;/code&gt; is used for. I haven't gotten my mind around this part yet.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arx = (180/3.141592) * atan(ax / pow((ay, 2) + pow(az, 2)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's the difference here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ary = (180/3.141592) * atan(ay / sqrt(square(ax, 2) + square(az, 2)));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="6936" LastEditDate="2015-10-22T21:04:08.647" LastActivityDate="2016-01-30T04:20:50.543" Title="What's the difference between pow and sqrt in this code?" Tags="|mpu6050|gyroscope|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17000" PostTypeId="2" ParentId="16995" CreationDate="2015-10-19T10:59:37.527" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well there you are.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SIM_SERIAL mySerial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-10-19T10:59:37.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17001" PostTypeId="2" ParentId="16995" CreationDate="2015-10-19T11:05:57.290" Score="0" Body="&lt;p&gt;I think Serial1 has to do with the Hardware serial Port(tx1,rx1) on Arduino mega . But since you are not using Serial.print i suggest you try &quot;Serial/Serial0&quot; if you are using UNO. &#xA;If you want (10,11) like you said then i think you should use Softwareserial&#xA;&lt;br&gt; #include SoftwareSerial.h //check spelling online not sure&#xA;SoftwareSerial allex(10,11);&#xA;&lt;br&gt; #define SIM_SERIAL  allex &#xA;&lt;br&gt; try it and see if it works.&lt;/p&gt;&#xA;" OwnerUserId="13422" LastActivityDate="2015-10-19T11:05:57.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17002" PostTypeId="1" CreationDate="2015-10-19T11:08:39.983" Score="1" ViewCount="216" Body="&lt;p&gt;I want to know when something is connected to USB port by blinking an LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose have to check PB10 UOTGVBOF, but how to do this ?&lt;/p&gt;&#xA;" OwnerUserId="14151" LastActivityDate="2017-11-09T07:26:00.950" Title="USB detect on Arduino DUE" Tags="|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17003" PostTypeId="1" CreationDate="2015-10-19T12:47:24.247" Score="0" ViewCount="450" Body="&lt;p&gt;I'm building an automated Arduino crane where the base material is PVC pipes. The arm consists of the picking mechanism and other sensors, so the total arm might come to about 2-3 Kg (I haven't built it yet). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please suggest to me an appropriate make/model of servo motor which I can purchase (preferably from India only)? &lt;/p&gt;&#xA;" OwnerUserId="14154" LastEditorUserId="6936" LastEditDate="2015-10-22T20:57:39.567" LastActivityDate="2016-02-19T22:44:28.760" Title="Help choosing servo motor for Arduino crane" Tags="|arduino-uno|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17004" PostTypeId="2" ParentId="17003" CreationDate="2015-10-19T13:13:14.443" Score="1" Body="&lt;p&gt;It really depends on where you are placing the servo, how much peak load &amp;amp; at what kind if distance from the servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/__10347__Corona_538MG_Digital_Metal_Gear_Servo_7_0kg_53g_0_13sec.html&quot; rel=&quot;nofollow&quot;&gt;These Corona servos&lt;/a&gt; are capable of lifting 2-3Kg at a distance of 2cm from the servo centre. (look at the torque entry on the specification sheet)&lt;/p&gt;&#xA;" OwnerUserId="1564" LastEditorUserId="1564" LastEditDate="2015-10-19T13:24:50.640" LastActivityDate="2015-10-19T13:24:50.640" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17005" PostTypeId="2" ParentId="16858" CreationDate="2015-10-19T15:50:27.270" Score="7" Body="&lt;p&gt;A 7-segment is a packaged set of 8 LEDs (7 number-segments &amp;amp; 1 decimal point). Common anode means that the anode (positive) side of all of the LEDs are electrically connected at one pin, and each LED cathode has its own pin. So turning on any particular segment will involve running a current from this common anode (positive) pin to the particular cathode (negative) pin for the desired segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3Mu4Y.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Mu4Y.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Common cathode means that the cathodes of all of the LEDs are common and connected to a single pin. The anode for each LED has its own pin. So driving one of these means running a current from the particular anode (positive) pin for the desired segment to the common cathode pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0HLZa.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0HLZa.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way that you are diving the 7-segment involves using a separate pin to drive each segment, so you use 8 pins of the Arduino to drive the display. You will run out of digital pins if you try to add a second 7-segment. There are a couple of ways to address this. One is to add a 7-segment driver, like the CD4511. This limits you to being able to display only numerical digits, but uses only 4 pins of the Arduino per 7-segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another, more versatile way is to add a serial-in to parallel out chip (74HC595, for example) to drive the 7-segment. This requires only two pins from the Arduino (data &amp;amp; clock), and they can be chained to have multiple 7-segments driven from those same 2 pins.&lt;/p&gt;&#xA;" OwnerUserId="14082" LastActivityDate="2015-10-19T15:50:27.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17006" PostTypeId="1" CreationDate="2015-10-19T16:27:19.433" Score="0" ViewCount="515" Body="&lt;p&gt;Alright, so this code is for a game that is a power source connected to 6 buttons at ports 1, 2, 9, 11, 12, and 13. These are consequently supposed to light up 6 LEDs, each connected to 1. If you press the buttons in the right order, all the LEDs blink at once. Does it work?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DEBOUNCE 10  // button debouncer, how many ms to debounce, 5+ ms is usually plenty&#xA;&#xA;// here is where we define the buttons that we'll use. button &quot;1&quot; is the first, button &quot;6&quot; is the 6th, etc&#xA;byte buttons[] = {1, 2, 9, 11, 12, 13}; // the analog 0-5 pins are also known as 14-19&#xA;// This handy macro lets us determine how big the array up above is, by checking the size&#xA;#define NUMBUTTONS sizeof(buttons)&#xA;// we will track if a button is just pressed, just released, or 'currently pressed' &#xA;volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];&#xA;&#xA;void setup() {&#xA;byte i;&#xA;&#xA;// set up serial port&#xA;Serial.begin(9600);&#xA;Serial.print(&quot;Button checker with &quot;);&#xA;Serial.print(NUMBUTTONS, DEC);&#xA;Serial.println(&quot; buttons&quot;);&#xA;&#xA;// pin1 LED&#xA;pinMode(1, OUTPUT);&#xA;&#xA; // Make input &amp;amp; enable pull-up resistors on switch pins&#xA; for (i=0; ipinMode(buttons[i], INPUT);&#xA; digitalWrite(buttons[i], HIGH);&#xA;  }&#xA;&#xA; // Run timer2 interrupt every 15 ms &#xA; TCCR2A = 0;&#xA; TCCR2B = 1&amp;lt;&amp;lt;CS22 | 1&amp;lt;&amp;lt;CS21 | 1&amp;lt;&amp;lt;CS20;&#xA;&#xA; //Timer2 Overflow Interrupt Enable&#xA;  TIMSK2 |= 1&amp;lt;&amp;lt;TOIE2;&#xA;&#xA; }&#xA;&#xA;SIGNAL(TIMER2_OVF_vect) {&#xA;check_switches();&#xA;}&#xA;&#xA;void check_switches()  &#xA;{&#xA;  static byte previousstate[NUMBUTTONS];&#xA;static byte currentstate[NUMBUTTONS];&#xA; static long lasttime;&#xA; byte index;&#xA;&#xA;  if (millis() // we wrapped around, lets just try again&#xA;     lasttime = millis();&#xA;  }&#xA;&#xA;  if ((lasttime + DEBOUNCE) &amp;gt; millis()) {&#xA;    // not enough time has passed to debounce&#xA;return; &#xA;  }&#xA;  // ok we have waited DEBOUNCE milliseconds, lets reset the timer&#xA;  lasttime = millis();&#xA;&#xA;  for (index = 0; index digitalRead(buttons[index]);   // read the button&#xA;&#xA;    /*     &#xA;    Serial.print(index, DEC);&#xA;    Serial.print(&quot;: cstate=&quot;);&#xA;    Serial.print(currentstate[index], DEC);&#xA;    Serial.print(&quot;, pstate=&quot;);&#xA;    Serial.print(previousstate[index], DEC);&#xA;    Serial.print(&quot;, press=&quot;);&#xA;    */&#xA;&#xA;    if (currentstate[index] == previousstate[index]) {&#xA;      if ((pressed[index] == LOW) &amp;amp;&amp;amp; (currentstate[index] == LOW)) {&#xA;          // just pressed&#xA;          justpressed[index] = 1;&#xA;      }&#xA;      else if ((pressed[index] == HIGH) &amp;amp;&amp;amp; (currentstate[index] == HIGH))        {&#xA;          // just released&#xA;          justreleased[index] = 1;&#xA;      }&#xA;      pressed[index] = !currentstate[index];  // remember, digital HIGH     means NOT pressed&#xA;    }&#xA;    //Serial.println(pressed[index], DEC);&#xA;    previousstate[index] = currentstate[index];   // keep a running tally  of the buttons&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  for (byte i = 0; i if (justpressed[i]) {&#xA;      justpressed[i] = 0;&#xA;      Serial.print(i, DEC);&#xA;      Serial.println(&quot; Just pressed&quot;); &#xA;      // remember, check_switches() will CLEAR the 'just pressed' flag&#xA;    }&#xA;    if (justreleased[i]) {&#xA;      justreleased[i] = 0;&#xA;      Serial.print(i, DEC);&#xA;      Serial.println(&quot; Just released&quot;);&#xA;      // remember, check_switches() will CLEAR the 'just pressed' flag&#xA;    }&#xA;    if (pressed[i]) {&#xA;      Serial.print(i, DEC);&#xA;      Serial.println(&quot; pressed&quot;);&#xA;      // is the button pressed down at this moment&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;int questionNumberArray[] = {1, 2, 9, 11, 12, 13};//the array itself&#xA;const size_t n = sizeof(questionNumberArray) / //the array used&#xA;sizeof(questionNumberArray[0]);//the base of the array&#xA;&#xA;for (size_t i = 0; i &amp;lt; n - 1; i++) //the loop itself&#xA;{&#xA;size_t j = random(1, n - i);&#xA;int t = questionNumberArray[i]; //integer output for increase&#xA;questionNumberArray[i] = questionNumberArray[j];//the value definition&#xA;questionNumberArray[j] = t;&#xA;pinMode(questionNumberArray, INPUT);&#xA;if (digitalRead(questionNumberArray) == HIGH) {&#xA;  then(digitalRead(1, 2, 9, 11, 12, 13 == High(3))&#xA;  break;  &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, how do I make it so that people have infinite times to try&lt;/p&gt;&#xA;" OwnerUserId="14124" LastEditorUserId="14124" LastEditDate="2015-10-19T18:41:25.903" LastActivityDate="2015-10-19T18:41:25.903" Title="Arduino IDE says fcould not convert 'pinMode(buttons[((inti)], 0u)' from 'void' to 'bool'. How do I fix" Tags="|arduino-uno|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17007" PostTypeId="2" ParentId="17006" CreationDate="2015-10-19T16:39:23.560" Score="1" Body="&lt;p&gt;There is very little about the code you are producing at the moment that could be classified as &quot;right&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are like a child who has been playing with LEGO® being let loose on the workings of a nuclear reactor.  You're sticking things together without a) knowing what they do and b) knowing how they are supposed to work, and it's all going to end in tears.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest that, for the time being, you forget this game project of yours and go back to the basics.  Start by learning how to make an LED light up when you press a button.  That will teach you both how to read the state of a button and how to control an LED.  Then move on to doing it with multiple LEDs and multiple buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it stands you are just going to end up getting frustrated and annoyed.  You're asking questions without either knowing just what it is you are asking or how to understand the answers when you are given them.  And that is going to end up reflecting badly on the rating of your various users (hint: if you ask reasonable questions you get reasonable answers, and that means upvotes and reputation, which then means you can ask more questions so you don't have to keep creating new users to ask more questions where you don't actually understand what you're asking).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-19T16:39:23.560" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="17008" PostTypeId="1" AcceptedAnswerId="17009" CreationDate="2015-10-19T17:33:02.940" Score="0" ViewCount="117" Body="&lt;p&gt;I'm trying to use the last version of &lt;strong&gt;leOS2 scheduler from Leonardo Miliani&lt;/strong&gt; ( &lt;a href=&quot;https://github.com/leomil72/leOS2&quot; rel=&quot;nofollow&quot;&gt;https://github.com/leomil72/leOS2&lt;/a&gt; ) but I have a strange behavior with a very simplistic ONETIME task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Platform : Arduino Uno clone, so Atmel Atmega 328P CPU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is very straightforward : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;leOS2.h&quot;&#xA;leOS2 myOS; //create a new istance of the class leOS&#xA;&#xA;bool test = true;&#xA;&#xA;void setup()&#xA;{&#xA;    myOS.begin(); //initialize the scheduler&#xA;}&#xA;void loop()&#xA;{&#xA;    // Do some stuff ...&#xA;&#xA;    if(test)&#xA;    {&#xA;       DoAndUndo(3000);&#xA;       test = false;&#xA;    }&#xA;}&#xA;&#xA;void DoAndUndo(unsigned long duration)&#xA;{&#xA;    doSomething();&#xA;&#xA;    myOS.addTask(cancelTheThing, myOS.convertMs(duration), ONETIME);&#xA;}&#xA;&#xA;&#xA;void doSomething()&#xA;{&#xA;    Serial.println(&quot;thing on&quot;);&#xA;}&#xA;&#xA;void cancelTheThing()&#xA;{&#xA;    Serial.println(&quot;thing is off&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case it can be some kind of conflict, my code also relies on the following : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is :&#xA;        myOS.addTask(cancelTheThing, myOS.convertMs(duration), ONETIME);&#xA;is supposed to call asynchronously the &quot;cancelTheThing&quot; method 3 seconds later, and for only one time, and then forget it.&#xA;But for an unknown reason, it's called after the expected delay, &lt;strong&gt;but it loops infinitely on this method&lt;/strong&gt; ! In the example case above, my serial stream is filled with a lot of &quot;thing is off&quot; messages, and the µc is unresponsive to anything apart a reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The call to DoAndUndo() will produce a such like output : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; thing on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And 3s later, in a very fast infinite loop :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; thing is off&#xA; thing is off&#xA; thing is off&#xA; thing is off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I remove the &quot;ONETIME&quot; flag, the task is called every three seconds (exactly as it's suppose to do, so the scheduler works, but it's not what I want in my use case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note : As a try of workaround, I've tried some tricks like calling haltScheduler() inside my cancelTheThing() and reenable it with restartScheduler() in DoAndUndo(), and also tried to call removeTask once it has ran, but it didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help&lt;/p&gt;&#xA;" OwnerUserId="8309" LastEditorUserId="8309" LastEditDate="2015-10-19T19:08:37.227" LastActivityDate="2015-10-19T19:38:28.610" Title="Issue with leOS2 for one-time tasks" Tags="|arduino-uno|programming|c|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17009" PostTypeId="2" ParentId="17008" CreationDate="2015-10-19T17:43:36.330" Score="1" Body="&lt;p&gt;There appears to be a fault with the library whereby if the only registered task is a one-shot task it doesn't get cancelled when it has executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding another periodic task in &lt;code&gt;setup()&lt;/code&gt; (say to blink an LED every 500ms) so there are now 2 tasks instead of one works around the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way the system is written it will always try an execute task number 0 even when there are 0 tasks registered because they erroneously used a &quot;do {...} while&quot; construct instead of a &quot;while { ...}&quot; construct.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I  have filed a bug report, corrected the error, and raised a pull request with the fix in it.  Until it gets accepted you can obtain the fixed version here: &lt;a href=&quot;https://github.com/majenkotech/leOS2&quot; rel=&quot;nofollow&quot;&gt;https://github.com/majenkotech/leOS2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-19T19:38:28.610" LastActivityDate="2015-10-19T19:38:28.610" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="17011" PostTypeId="1" AcceptedAnswerId="17013" CreationDate="2015-10-19T18:30:07.353" Score="0" ViewCount="90" Body="&lt;p&gt;I made a code which can send the message to the entered phone number while it receieves a specific message or when the push button is pressed.&#xA;but it is showing the error that 'smsReceivingFunction' was not declared in this scope.&#xA;I'm a beginner and don't know what i'm doing wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to know the working of functions of library--&#xA;&lt;a href=&quot;http://1sheeld.com/docs/sms/#example&quot; rel=&quot;nofollow&quot;&gt;http://1sheeld.com/docs/sms/#example&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the code--&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneSheeld.h&amp;gt;&#xA;float lat ;&#xA;float lon ;&#xA;char charlat [30];&#xA;char charlon [30];&#xA;char readings [150];&#xA;int buttonPin=11;&#xA;int ledPin=12;&#xA;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  OneSheeld.begin();&#xA;    /* Set the button pin as input. */&#xA;  pinMode(buttonPin,INPUT);&#xA;  /* Set the LED pin as output. */&#xA;  pinMode(ledPin,OUTPUT);&#xA;  SMS.setOnSmsReceive(&amp;amp;smsReceivingFunction);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;    charlat[0] = 0;&#xA;  charlon[0] = 0;&#xA;  readings [0] = 0;&#xA;if(digitalRead(buttonPin) == HIGH)&#xA;  {&#xA;    /* Turn on the LED. */&#xA;    digitalWrite(ledPin,HIGH);&#xA;    delay( 1000);&#xA;    digitalWrite(ledPin,HIGH);&#xA;    delay( 500);&#xA;&#xA;&#xA;&#xA;&#xA;      lat = GPS.getLatitude();&#xA;      lon = GPS.getLongitude();&#xA;      dtostrf(lat, 3, 7, charlat);&#xA;      dtostrf(lon, 3, 7, charlon);&#xA;      strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;      strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;      strcat (readings, charlat);&#xA;      strcat(readings, &quot;,&quot;);&#xA;      strcat (readings, charlon);&#xA;      SMS.send(&quot;+917771914436&quot;, readings);&#xA;&#xA;      void smsReceivingFunction(const char * number,const char * text);&#xA;&#xA;&#xA;       if(!strcmp(number,&quot;+7771914436&quot;))               /* phone number from which you will send the sms &quot;PUT YOURS IN PLACE OF +1234567890&quot; */&#xA;      {&#xA;        if(!strcmp(text,&quot;?&quot;))&#xA;        lat = GPS.getLatitude();&#xA;      lon = GPS.getLongitude();&#xA;      dtostrf(lat, 3, 7, charlat);&#xA;      dtostrf(lon, 3, 7, charlon);&#xA;      strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;      strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;      strcat (readings, charlat);&#xA;      strcat(readings, &quot;,&quot;);&#xA;      strcat (readings, charlon);&#xA;      SMS.send(&quot;+917771914436&quot;, readings);&#xA;      }&#xA;  }&#xA;&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="4143" LastEditDate="2015-10-19T18:48:07.790" LastActivityDate="2015-10-19T21:56:03.060" Title="Error while compiling" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17012" PostTypeId="2" ParentId="16871" CreationDate="2015-10-19T19:21:51.947" Score="1" Body="&lt;p&gt;It turns out my Arduino IDE could not find PubNub.* files until I manually added them as a Library. &lt;/p&gt;&#xA;" OwnerUserId="14061" LastActivityDate="2015-10-19T19:21:51.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17013" PostTypeId="2" ParentId="17011" CreationDate="2015-10-19T21:56:03.060" Score="3" Body="&lt;p&gt;Basically the formatting and layout of your program is completely wrong.  You haven't actually defined this &lt;code&gt;smsReceivingFunction&lt;/code&gt; anywhere.  You have created a &lt;em&gt;prototype&lt;/em&gt; to it part way through your &lt;code&gt;loop()&lt;/code&gt; function, but not created the actual function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should learn to strictly indent your program properly.  It is important, since by doing so you can follow the flow and structure of your program much easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if I pass your program through &lt;a href=&quot;http://astyle.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Artistic Style&lt;/a&gt; to attempt to automatically correct your indenting it results in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneSheeld.h&amp;gt;&#xA;float lat ;&#xA;float lon ;&#xA;char charlat [30];&#xA;char charlon [30];&#xA;char readings [150];&#xA;int buttonPin = 11;&#xA;int ledPin = 12;&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    OneSheeld.begin();&#xA;    /* Set the button pin as input. */&#xA;    pinMode(buttonPin, INPUT);&#xA;    /* Set the LED pin as output. */&#xA;    pinMode(ledPin, OUTPUT);&#xA;    SMS.setOnSmsReceive(&amp;amp;smsReceivingFunction);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    charlat[0] = 0;&#xA;    charlon[0] = 0;&#xA;    readings [0] = 0;&#xA;    if (digitalRead(buttonPin) == HIGH) {&#xA;        /* Turn on the LED. */&#xA;        digitalWrite(ledPin, HIGH);&#xA;        delay( 1000);&#xA;        digitalWrite(ledPin, HIGH);&#xA;        delay( 500);&#xA;        lat = GPS.getLatitude();&#xA;        lon = GPS.getLongitude();&#xA;        dtostrf(lat, 3, 7, charlat);&#xA;        dtostrf(lon, 3, 7, charlon);&#xA;        strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;        strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;        strcat (readings, charlat);&#xA;        strcat(readings, &quot;,&quot;);&#xA;        strcat (readings, charlon);&#xA;        SMS.send(&quot;+917771914436&quot;, readings);&#xA;        void smsReceivingFunction(const char * number, const char * text);&#xA;&#xA;        if (!strcmp(number, &quot;+7771914436&quot;)) {           /* phone number from which you will send the sms &quot;PUT YOURS IN PLACE OF +1234567890&quot; */&#xA;            if (!strcmp(text, &quot;?&quot;)) {&#xA;                lat = GPS.getLatitude();&#xA;            }&#xA;&#xA;            lon = GPS.getLongitude();&#xA;            dtostrf(lat, 3, 7, charlat);&#xA;            dtostrf(lon, 3, 7, charlon);&#xA;            strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;            strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;            strcat (readings, charlat);&#xA;            strcat(readings, &quot;,&quot;);&#xA;            strcat (readings, charlon);&#xA;            SMS.send(&quot;+917771914436&quot;, readings);&#xA;        }&#xA;    }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can now see you have an extra &lt;code&gt;}&lt;/code&gt; at the end of your sketch, so your brackets are not balanced. That in itself is a syntax error.  Also you can see your function prototype slap bang in the middle of your loop() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;        SMS.send(&quot;+917771914436&quot;, readings);&#xA;        void smsReceivingFunction(const char * number, const char * text);&#xA;&#xA;        if (!strcmp(number, &quot;+7771914436&quot;)) {           /* phone number &#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think, though of course I can't actually test this since I don't have your hardware, that you really meant to start a new function at that point in your program, and of course that would mean finishing the previous function first: you &lt;em&gt;cannot&lt;/em&gt; nest functions inside each other.  So I would guess your program &lt;em&gt;should&lt;/em&gt; have looked something more like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneSheeld.h&amp;gt;&#xA;float lat ;&#xA;float lon ;&#xA;char charlat [30];&#xA;char charlon [30];&#xA;char readings [150];&#xA;int buttonPin = 11;&#xA;int ledPin = 12;&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    OneSheeld.begin();&#xA;    /* Set the button pin as input. */&#xA;    pinMode(buttonPin, INPUT);&#xA;    /* Set the LED pin as output. */&#xA;    pinMode(ledPin, OUTPUT);&#xA;    SMS.setOnSmsReceive(&amp;amp;smsReceivingFunction);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    charlat[0] = 0;&#xA;    charlon[0] = 0;&#xA;    readings [0] = 0;&#xA;    if (digitalRead(buttonPin) == HIGH) {&#xA;        /* Turn on the LED. */&#xA;        digitalWrite(ledPin, HIGH);&#xA;        delay( 1000);&#xA;        digitalWrite(ledPin, HIGH);&#xA;        delay( 500);&#xA;        lat = GPS.getLatitude();&#xA;        lon = GPS.getLongitude();&#xA;        dtostrf(lat, 3, 7, charlat);&#xA;        dtostrf(lon, 3, 7, charlon);&#xA;        strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;        strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;        strcat (readings, charlat);&#xA;        strcat(readings, &quot;,&quot;);&#xA;        strcat (readings, charlon);&#xA;        SMS.send(&quot;+917771914436&quot;, readings);&#xA;    }&#xA;}&#xA;&#xA;void smsReceivingFunction(const char * number, const char * text) {&#xA;    if (!strcmp(number, &quot;+7771914436&quot;)) {           /* phone number from which you will send the sms &quot;PUT YOURS IN PLACE OF +1234567890&quot; */&#xA;        if (!strcmp(text, &quot;?&quot;)) {&#xA;            lat = GPS.getLatitude();&#xA;        }&#xA;        lon = GPS.getLongitude();&#xA;        dtostrf(lat, 3, 7, charlat);&#xA;        dtostrf(lon, 3, 7, charlon);&#xA;        strcat(readings, &quot;please call me I i do not pick up the call please reach to my location:\n&quot;);&#xA;        strcat(readings, &quot;http://maps.google.com/maps?q=&quot;);&#xA;        strcat (readings, charlat);&#xA;        strcat(readings, &quot;,&quot;);&#xA;        strcat (readings, charlon);&#xA;        SMS.send(&quot;+917771914436&quot;, readings);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-19T21:56:03.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17014" PostTypeId="1" AcceptedAnswerId="17017" CreationDate="2015-10-19T22:46:33.207" Score="1" ViewCount="644" Body="&lt;pre&gt;&lt;code&gt;#ifndef FOO_H&#xA;#define FOO_H&#xA;&#xA;struct Foo{&#xA;  int randInt = random(0, 101);&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a header file with a &lt;code&gt;struct&lt;/code&gt; like above but when I compile I get this error: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;'random' was not declared in this scope&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use random() in a header file?&lt;/p&gt;&#xA;" OwnerUserId="13840" LastActivityDate="2015-10-19T23:32:03.430" Title="Using random() in a header file" Tags="|programming|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17016" PostTypeId="2" ParentId="17014" CreationDate="2015-10-19T23:01:35.297" Score="2" Body="&lt;p&gt;The struct is a declaration of a type. You cannot mix it with the initialization. This is how it could be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In foo.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef FOO_H&#xA;#define FOO_H&#xA;&#xA;struct Foo{&#xA;  int randInt;&#xA;};&#xA;&#xA;extern struct Foo foo;&#xA;struct Foo *initFoo(struct Foo *foo_ptr);&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In foo.c:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.h&quot;&#xA;&#xA;struct Foo foo;&#xA;struct Foo *initFoo(struct Foo *foo_ptr) {&#xA;  if (!foo_ptr)&#xA;    return NULL;&#xA;  foo_ptr-&amp;gt;randInt = random(0, 101);&#xA;  return foo_ptr;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;random() is a function and therefore its return value cannot be used as static initializer.&#xA;Unless -std=c++11 or -std=gnu++11 are enabled.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-19T23:32:03.430" LastActivityDate="2015-10-19T23:32:03.430" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17017" PostTypeId="2" ParentId="17014" CreationDate="2015-10-19T23:18:04.823" Score="2" Body="&lt;p&gt;Add &lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&lt;/code&gt; like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef FOO_H&#xA;#define FOO_H&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;struct Foo{&#xA;  int randInt = random(0, 101);&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13840" LastActivityDate="2015-10-19T23:18:04.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17018" PostTypeId="2" ParentId="16985" CreationDate="2015-10-20T00:09:50.650" Score="3" Body="&lt;p&gt;So you leds are connected to &quot;pins&quot; not &quot;ports.&quot; Since each of the buttons will turn on only 1 led we need to keep track of which button pairs with which led. To do this we can use a &lt;code&gt;struct&lt;/code&gt; like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ButtonLed{   &#xA;        int buttonPin;&#xA;        int ledPin;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You declare a &lt;code&gt;ButtonLed&lt;/code&gt; like this: &lt;code&gt;ButtonLed button1 = {1, 0}&lt;/code&gt; where the first parameter is the button's pin and the second is the led's pin. &lt;strong&gt;(All of the led pins are set to 0 since I don't know which pins you have them connected to.)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the array will hold the button/led pin pair like this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ButtonLed questionNumberArray[] = {button1, button2, button3, button4, button5, button6};&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there are 6 leds you know that your array is size 6 so use this declaration instead &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;const int n = 6;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I fixed you range for the random number generation. Look at the documentation for &lt;code&gt;random()&lt;/code&gt; here &lt;a href=&quot;https://www.arduino.cc/en/Reference/Random&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/Random&lt;/a&gt;. We can use this function for shuffling the array. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shuffleArray (ButtonLed arr [], const int size){&#xA;    for (int i = 0; i &amp;lt; size - 1; i++){ // iterates through array except last element&#xA;        int j = random(0, size); // generates a random index from (0 to n-1) inclusive&#xA;&#xA;        // swap current index with random index&#xA;        ButtonLed t = arr[i]; &#xA;        arr[i] = arr[j];&#xA;        arr[j] = t;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We will use this function to wait until the user enters a sequence of button presses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ButtonLed getButtonPress (ButtonLed arr [], const int size){&#xA;    bool pressed = false;&#xA;    ButtonLed  pressedButton;&#xA;    while (!pressed){ // loops until a button was pressed&#xA;        for (int i = 0; i &amp;lt; size &amp;amp;&amp;amp; !pressed; i++){ // !pressed allows early out&#xA;            if (digitalRead(arr[i].buttonPin)){ // one of the six buttons was pressed&#xA;                pressed = true; // exit both loops&#xA;                pressedButton = arr[i]; // stores which button was pressed&#xA;            }&#xA;        }&#xA;    }&#xA;    return pressedButton; // return the pressed button&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially it gets stuck in a loop and reads each of the 6 buttons until one of them is pressed and then records which one was pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using the code below and read the comments the only thing you need to do is change all the zeros in the &lt;code&gt;ButtonLed&lt;/code&gt; declarations to whatever pin the leds are connected to. Also the &lt;code&gt;struct&lt;/code&gt; above needs to go into it's only file called &quot;ButtonLed.h&quot; It &lt;strong&gt;must&lt;/strong&gt; be called that. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ButtonLed.h&quot;&#xA;&#xA;// These are ButtonLeds our newly created data type&#xA;// they hold both an led's pin and the pin for the button&#xA;// that turns it on&#xA;ButtonLed button1 = {1, 10};&#xA;ButtonLed button2 = {2,  8};&#xA;ButtonLed button3 = {9,  7};&#xA;ButtonLed button4 = {11, 6};&#xA;ButtonLed button5 = {12, 5};&#xA;ButtonLed button6 = {13, 4};&#xA;&#xA;// This function will randomly shuffle an array of ButtonLeds&#xA;void shuffleArray (ButtonLed arr [], const int size){&#xA;    for (int i = 0; i &amp;lt; size - 1; i++){ // iterates through array except last element&#xA;        int j = random(0, size); // generates a random index from (0 to size-1) inclusive&#xA;&#xA;        // swap current index with random index&#xA;        ButtonLed t = arr[i]; &#xA;        arr[i] = arr[j];&#xA;        arr[j] = t;&#xA;    }&#xA;}&#xA;&#xA;ButtonLed getButtonPress (ButtonLed arr [], const int size){&#xA;    bool pressed = false;&#xA;    ButtonLed  pressedButton;&#xA;    while (!pressed){ // loops until a button was pressed&#xA;        for (int i = 0; i &amp;lt; size &amp;amp;&amp;amp; !pressed; i++){ // !pressed allows early out&#xA;            if (digitalRead(arr[i].buttonPin)){ // one of the six buttons was pressed&#xA;                digitalWrite(digitalRead(arr[i].ledPin, HIGH); // turns on the led the user chose&#xA;                delay(200);&#xA;                digitalWrite(digitalRead(arr[i].ledPin, LOW); // turns it back off&#xA;                pressed = true; // exit both loops&#xA;                pressedButton = arr[i]; // stores which button was pressed&#xA;            }&#xA;        }&#xA;    }&#xA;    return pressedButton; // return the pressed button&#xA;}&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;    randomSeed(analogRead(A0));&#xA;    // This is how you set up the leds for output&#xA;    pinMode(button1.ledPin, OUTPUT);&#xA;    pinMode(button2.ledPin, OUTPUT);&#xA;    pinMode(button3.ledPin, OUTPUT);&#xA;    pinMode(button4.ledPin, OUTPUT);&#xA;    pinMode(button5.ledPin, OUTPUT);&#xA;    pinMode(button6.ledPin, OUTPUT);&#xA;&#xA;    // This is how you set up the buttons for input&#xA;    pinMode(button1.buttonPin, INPUT);&#xA;    pinMode(button2.buttonPin, INPUT);&#xA;    pinMode(button3.buttonPin, INPUT);&#xA;    pinMode(button4.buttonPin, INPUT);&#xA;    pinMode(button5.buttonPin, INPUT);&#xA;    pinMode(button6.buttonPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // This array is of type ButtonLed our newly created data type&#xA;    ButtonLed questionNumberArray[] = {button1, button2, button3, &#xA;                                       button4, button5, button6}; &#xA;    const size_t n = 6; // array's size&#xA;&#xA;    shuffleArray(questionNumberArray, n);&#xA;&#xA;&#xA;    numLeds = 1;&#xA;    bool guessCorrectly = false;&#xA;&#xA;    // this while loop allows the user to keep trying until they get it right&#xA;    while (!guessCorrectly){&#xA;&#xA;&#xA;        // This loop displays the correct sequence to the user&#xA;        for (int i = 0; i &amp;lt; numLeds; i++){&#xA;            digitalWrite(questionNumberArray[i].ledPin, HIGH); // turn on the led&#xA;&#xA;            delay(500); // decrease this number to flash faster; increase to flash slower&#xA;&#xA;            digitalWrite(questionNumberArray[i].ledPin, LOW); // turn off the led&#xA;        }&#xA;&#xA;&#xA;        bool correctButton = true; // the user has pressed the correct button&#xA;        ButtonLed userSequence [6];      // stores the sequence the user entered&#xA;        // lets the user push 6 buttons&#xA;        for (int i = 0; i &amp;lt; numLeds; i++){&#xA;            userSequence[i] = getButtonPress(questionNumberArray, numLeds);&#xA;            delay(500); // delay between button presses&#xA;        }&#xA;&#xA;        // check if the user entered the correct sequence&#xA;        for (int i = 0; i &amp;lt; numLeds &amp;amp;&amp;amp; correctButton; i++){ &#xA;            if (userSequence[i].buttonPin != questionNumberArray[i].buttonPin)&#xA;                correctButton = false;&#xA;        }&#xA;&#xA;        if (correctButton){ // user entered the correct sequence&#xA;            guessCorrectly = true;&#xA;            // This will turn on the leds in the correct sequence&#xA;            for (int i = 0; i &amp;lt; numLeds; i++){&#xA;                digitalWrite(questionNumberArray[i].ledPin, HIGH); // turn on the led&#xA;                delay(500); // delay half a second&#xA;                digitalWrite(questionNumberArray[i].ledPin, LOW); // turn off the led&#xA;            }&#xA;            numLeds++;&#xA;            if (numLeds &amp;gt; 6)&#xA;                --numLeds;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you are finished typing the code above it &lt;code&gt;ctrl+shift+n&lt;/code&gt; and open a new tab called &quot;ButtonLed.h&quot; and add this to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef BUTTONLED_H&#xA;#define BUTTONLED_H&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;// We create new data type called ButtonLed which stores the button's pin&#xA;    // and the led's pin; this allows us to keep both an led and it's&#xA;    // corresponding button together without have to manage 2 arrays&#xA;    struct ButtonLed{   &#xA;        int buttonPin;&#xA;        int ledPin;&#xA;    };&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure you open a new tab and not a new project. Also as others have said you should really learn how to program. Be aware this code compiles however, I haven't tested it. I will update the code when you tell me what pins the leds are connected to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I added a while loop that allows the user to keep trying until they guess correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also updated the code for which pins the leds are connected to. Remember they're connected to &quot;pins&quot; &lt;strong&gt;Not&lt;/strong&gt; &quot;ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OMnho.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OMnho.png&quot; alt=&quot;Schematic for your project.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2015-10-20T06:45:21.293" LastActivityDate="2015-10-20T06:45:21.293" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17019" PostTypeId="2" ParentId="17002" CreationDate="2015-10-20T00:11:46.883" Score="1" Body="&lt;p&gt;What I'm going to say is probably not the most efficient way to do it, but it should work: if your DUE is used as gadget and you wnat to detect the presence of a master, connect a GPIO to the +Vcc line of the usb port and either poll or program an edge triggered interrupt to detect when the line goes high.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-20T00:11:46.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17020" PostTypeId="2" ParentId="6826" CreationDate="2015-10-20T04:57:32.270" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;| Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the &#xA;| ENC28J60 chip.&#xA;| Based on the Ethercard example from www.jeelabs.org&#xA;| Phil Grant Jan 2014&#xA;*/&#xA;#include &amp;lt;EtherCard.h&amp;gt;&#xA;// change these settings to match your own setup&#xA;#define APIKEY  &quot;xxxxxxxxxxxxxxxx&quot;&#xA;&#xA;//DHT Setup&#xA;#include &quot;DHT.h&quot;&#xA;#define DHTPIN 2     // what pin we're connected to&#xA;// Uncomment whatever type you're using!&#xA;//#define DHTTYPE DHT11   // DHT 11&#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;//#define DHTTYPE DHT21   // DHT 21 (AM2301)  &#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;// ethernet interface mac address, must be unique on the LAN&#xA;byte mymac[] = { 0xXX,0xXX,0xXX,0xXX,0xXX,0xXX };&#xA;&#xA;char website[] PROGMEM = &quot;api.thingspeak.com&quot;;&#xA;&#xA;byte Ethernet::buffer[700];&#xA;uint32_t timer;&#xA;Stash stash;&#xA;&#xA;void setup () {&#xA;  Serial.begin(57600);&#xA;    dht.begin(); //Initializate DHT&#xA;  Serial.println(&quot;\n[webClient]&quot;);&#xA;&#xA;  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) &#xA;    Serial.println( &quot;Failed to access Ethernet controller&quot;);&#xA;  if (!ether.dhcpSetup())&#xA;    Serial.println(&quot;DHCP failed&quot;);&#xA;&#xA;  ether.printIp(&quot;IP:  &quot;, ether.myip);&#xA;  ether.printIp(&quot;GW:  &quot;, ether.gwip);  &#xA;  ether.printIp(&quot;DNS: &quot;, ether.dnsip);  &#xA;&#xA;  if (!ether.dnsLookup(website))&#xA;    Serial.println(&quot;DNS failed&quot;);&#xA;&#xA;  ether.printIp(&quot;SRV: &quot;, ether.hisip);&#xA;}&#xA;&#xA;void loop () {&#xA;  ether.packetLoop(ether.packetReceive());&#xA;&#xA;  if (millis() &amp;gt; timer) {&#xA;    timer = millis() + 60000; //Transmit every minute&#xA;    delay(2000);  // Wait a few seconds between measurements.&#xA;  // Reading temperature or humidity takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  float h = dht.readHumidity(); // Read temperature as Celsius (the default)&#xA;  char h_buffer[10];&#xA;  String Hstring = dtostrf(h,0,5,h_buffer); //Convert Humidity value to String&#xA;&#xA;  float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true)&#xA;  //float f = dht.readTemperature(true);&#xA;  char t_buffer[10];&#xA;  String Tstring = dtostrf(t,0,5,t_buffer); //Convert Temperature value to String&#xA;&#xA;    byte sd = stash.create();&#xA;    stash.print(&quot;field1=&quot;);&#xA;    stash.println(Hstring);&#xA;    stash.print(&quot;&amp;amp;field2=&quot;);&#xA;    stash.println(Tstring);&#xA;    stash.save();&#xA;&#xA;    // generate the header with payload - note that the stash size is used,&#xA;    // and that a &quot;stash descriptor&quot; is passed in as argument using &quot;$H&quot;&#xA;    Stash::prepare(PSTR(&quot;POST /update HTTP/1.1&quot; &quot;\r\n&quot; &#xA;                        &quot;Host: $F&quot; &quot;\r\n&quot; &#xA;                        &quot;Connection: close&quot; &quot;\r\n&quot; &#xA;                        &quot;X-THINGSPEAKAPIKEY: $F&quot; &quot;\r\n&quot; &#xA;                        &quot;Content-Type: application/x-www-form-urlencoded&quot; &quot;\r\n&quot; &#xA;                        &quot;Content-Length: $D&quot; &quot;\r\n&quot; &#xA;                        &quot;\r\n&quot; &#xA;                        &quot;$H&quot;),&#xA;            website, PSTR(APIKEY), stash.size(), sd);&#xA;&#xA;    // send the packet - this also releases all stash buffers once done&#xA;    ether.tcpSend();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14168" LastActivityDate="2015-10-20T04:57:32.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17021" PostTypeId="1" AcceptedAnswerId="17025" CreationDate="2015-10-20T06:37:19.180" Score="0" ViewCount="302" Body="&lt;p&gt;so I am having trouble sending data using software serial's write function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial TX(2,3); &#xA;&#xA;void setup() { &#xA;  // put your setup code here, to run once: &#xA;  TX.begin(1200); &#xA;} &#xA;&#xA;void loop() { &#xA;    TX.write(60);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is the delay necessary?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RX Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial RX(2,3); //(rx pin, tx pin)&#xA;const unsigned int bufferSize = 100;&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600); &#xA;  RX.begin(1200); &#xA;&#xA;}&#xA;&#xA;void printBuffer(const uint8_t *serialBuffer)&#xA;{&#xA;  //print contents of buffer&#xA;  for (int i = 0; i&amp;lt;100; i++) &#xA;    Serial.println(serialBuffer[i], BIN);&#xA;}&#xA;&#xA;void processBytes(const uint8_t value)&#xA;{ &#xA;  static uint8_t serialBuffer[bufferSize]; //buffer to hold values&#xA;  static unsigned int startPosition=0;&#xA;&#xA;  if(startPosition &amp;lt; bufferSize)&#xA;    serialBuffer[startPosition++] = value; &#xA;&#xA;  else&#xA;  {&#xA;    printBuffer(serialBuffer);&#xA;    startPosition = 0;&#xA;  }&#xA;&#xA;}//end of processBytes&#xA;void loop() { &#xA;&#xA;  //check if data is available in serial buffer&#xA;  while(RX.available())&#xA;  {&#xA;    //process data&#xA;    processBytes(RX.read());&#xA;  }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i transmit the number 60, it prints 226 constantly for 2-3 seconds, then prints 60 for a short while, then goes back to printing 226. Am I doing something wrong with my code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;FIRST QUESTION:&lt;/strong&gt; In the case when startPosition (in the process function) equals 100, it will call print. Print will then print 100 integers. Now, when doing that, there could still be data being transmitted from the transmitter. But the read function won't be executed until printBuffer returns, process returns, and the while loop iterates again. So during that time, couldn't some transmitted values potentially not be read? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SECOND QUESTION&lt;/strong&gt; How come Software serial doesn't synchronize incorrectly more often? How is it being so accurate if the start bit is just a single bit and it's a 0. So for instance, if payload has some 0s, how come one of those 0s aren't being assumed to be the startbit? How does this get resolved? I looked at the software serial library, but I am not able to find out why. Any guidance here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;THIRD QUESTION&lt;/strong&gt; Other than getting the startbit syncing right, are there other ways to sync the data? I was reading of NRZ encoding, manchester encoding, etc. Can any of these be implemented here? Also, would it be wise to alter the softwareSerial library to have more than one startbit? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance would be very appreciated! Thank you so much!&#xA;This is all being done with wireless RF modules. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-10-26T18:29:00.627" LastActivityDate="2015-10-26T18:29:00.627" Title="Unable to tell if error is from receiving or transmitting end" Tags="|arduino-uno|c++|communication|softwareserial|rf|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="17022" PostTypeId="1" AcceptedAnswerId="17026" CreationDate="2015-10-20T07:46:43.553" Score="9" ViewCount="17488" Body="&lt;p&gt;After looking into various schematics on controlling a relay via an Arduino, I have noticed that, most of the time, transistors are used to switch the separate supply into the relay coil rather than directly supplying the relay with the 5-Volt output from the I/O pin of the Arduino. For example, I have a 5-volt DPDT relay and also a small dc motor. I want to drive both directly from my Arduino UNO (SMD clone) with an Atmel328 processor? Would it be advisable to proceed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not (most likely):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Can someone give a detailed explanation and might as well important cautions on current limits and stuff?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How can one control such components without risking the Arduino? What are some common means to accomplish this?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What other devices can generally harm an Arduino board (or any microcontroller unit) in a similar manner?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm just a beginner who wants to be extremely cautious. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="14129" LastActivityDate="2021-05-31T13:26:19.767" Title="Reasons why it is not OK to connect a relay directly from an Arduino digital pin" Tags="|arduino-uno|relay|safety|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17024" PostTypeId="2" ParentId="17022" CreationDate="2015-10-20T08:45:43.340" Score="8" Body="&lt;p&gt;The recommended output (source or sink) from an I/O pin is 20 mA. The absolute maximum is 40 mA. Your relay coil is likely to consume more than that, particularly when it initially energizes. This will damage your output pin. Then it will eventually fail.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Nothing seems to be amiss by far. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, not yet. :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can one control such components without risking the Arduino? What are some common means to accomplish this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use transistors or MOSFETs.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What other devices can generally harm an Arduino board (or any microcontroller unit) in a similar manner?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Anything that exceeds the maximum voltage or current limits as documented in the datasheet. Coils (eg. in relays and motors) in particular are likely to have a high reverse voltage when they are turned off, which is why you need a &lt;a href=&quot;https://en.wikipedia.org/wiki/Snubber&quot;&gt;snubber diode&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Would it be advisable to proceed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It would be advisable to take heed of what I wrote above, and to read the many, many articles on the Web about how to drive motors and relays from an Arduino. You are not the first person to attempt this.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-20T08:45:43.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17025" PostTypeId="2" ParentId="17021" CreationDate="2015-10-20T08:52:04.623" Score="2" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() { &#xA;  Serial.println(&quot;NEW-------------&quot;);&#xA;  int x;&#xA;  int y[100];&#xA;  for(int i = 0; i&amp;lt;100; i++){ &#xA;    x=RX.read(); &#xA;    y[i] = x;&#xA;  } &#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are reading data without checking if there is any data there. That's like watching the TV without checking if it is turned on. Of course you get weird data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SoftwareSerial RX(0,1); //(rx pin, tx pin)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pins 0 and 1 are used by HardwareSerial. Why are you using them for SoftwareSerial?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;SoftwareSerial RX(0,1); //(rx pin, tx pin)&#xA;...&#xA;&#xA;  Serial.begin(9600); &#xA;  RX.begin(1200); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you initialized HardwareSerial, which now controls pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you try to initialize SoftwareSerial on those &lt;strong&gt;same&lt;/strong&gt; pins! Would you mind explaining why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever your explanation is, it won't work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've added in the changes you mentioned, but the data still seems to be skewed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You've changed things, for sure:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; for(int i = 0; i&amp;lt;100; i++){ &#xA;    if(RX.available())&#xA;      x=RX.read(); &#xA;&#xA;    y[i] = x;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let's see. In a loop of 100 iterations you see if anything is available (and if so, put it into &lt;code&gt;x&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, regardless of &lt;strong&gt;whether or not you got anything&lt;/strong&gt; you now assign &lt;code&gt;x&lt;/code&gt; to &lt;code&gt;y[i]&lt;/code&gt;. So, most of the time, &lt;code&gt;y[i]&lt;/code&gt; will have garbage in it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the data still seems to be skewed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not surprised. Do it differently. Only write to the array if you have data. In fact you may want a complete rework. Read this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;How to read serial without blocking&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have posted the amended code. Change: Only add to the array is data is being read from buffer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  int y[100];&#xA;  for(int i = 0; i&amp;lt;100; i++){ &#xA;    if(RX.available())&#xA;    {&#xA;      x=RX.read(); &#xA;      y[i] = x;&#xA;    }&#xA;  } &#xA;&#xA; for (int j = 1; j&amp;lt;=64; j++){ &#xA;    Serial.println(y[j]);&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You still have not fixed it. Let me talk you through what it is doing now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are making 100 attempts to read some data. One or two may succeed, and they will be put into the buffer &lt;code&gt;y&lt;/code&gt; (funny name for a buffer, right?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So imagine &lt;code&gt;.&lt;/code&gt; is garbage and &lt;code&gt;X&lt;/code&gt; is good data, after doing that loop of 100 the buffer will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;........X...........X...........X...X......................X.............................................&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your buffer is still 80% unchanged garbage. Then you print the first 64 elements (why 64 and not 100?) and you get a lot of garbage out. Exactly as expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You need to think about what you are doing. Draw it out on a bit of paper, perhaps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some example code from the page I linked for you, more than once. Please compare:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 50;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  } // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data)&#xA;  {&#xA;  // for now just display it&#xA;  // (but you could compare it to some value, convert to an integer, etc.)&#xA;  Serial.println (data);&#xA;  }  // end of process_data&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;  {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte)&#xA;    {&#xA;&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;      // terminator reached! process input_line here ...&#xA;      process_data (input_line);&#xA;&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;    }  // end of switch&#xA;&#xA;  } // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;  {&#xA;  // if serial data available, process it&#xA;  while (Serial.available () &amp;gt; 0)&#xA;    processIncomingByte (Serial.read ());&#xA;&#xA;  // do other stuff here like testing digital input (button presses) ...&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-23T20:38:45.633" LastActivityDate="2015-10-23T20:38:45.633" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="17026" PostTypeId="2" ParentId="17022" CreationDate="2015-10-20T08:55:18.257" Score="10" Body="&lt;p&gt;Processor pins have strictly limited current drive capability. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The rated values may vary depending on whether you want a high or low drive. &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Some processors will supply only a few mA and the most you will usually officially get is in the 20 to 30 mA range. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There is usually a total current limit for the processor and only a few pins can provide peak current simultaneously.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Processor pins have significant effective resistance and a high voltage will &quot;drop&quot; as increasing current is drawn and a low voltage will rise as load increases. Pins MAY be specific with a maximum short circuit current but at that point a high pin will be pulled low and a low pin will be pulled high so short circuit current has limited applicability.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Even if you have a say 25 mA per pin rated processor the power available is small. 25 mA · 4V say (1V drop on 5V Vcc) = 100 mW. Most motors will take more than that and only very small motors will run well when powered only by a pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Electric motors and inductors will generate significantly high voltages when current is interrupted - voltages of tens of volts can easily result and 100+ volts can happen. Connecting a motor of inductor to a processor pin directly is an invitation to destruction. Murphy will often oblige.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A transistor (bipolar or MOSFET) that will drive typical hobby motors costs 10's of cents (or free from scrapped equipment) and allows the port pin current drive to be buffered and &quot;amplified&quot;. Use of a transistor or other buffer is an extremely good idea if you have one or a few processors and do not wish them to die semi-randomly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MOSFET motor driver&lt;/strong&gt; - &lt;a href=&quot;https://www.picotech.com/library/application-note/some-power-pwm-drivers-for-electric-dc-motors&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;from here&lt;/strong&gt;&lt;/a&gt; - section 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltages and part numbers are for their example - select to suit.&lt;br&gt;&#xA;A NPN biploar could be used with the addition of an input resistor to the transistor base.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s4cSN.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s4cSN.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bidirectional driver - if you want the driver to be able to drive a load high and low this circuit will work. &lt;a href=&quot;http://www.electronics-tutorials.ws/transistor/tran_7.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;from here&lt;/a&gt;&lt;br&gt;&#xA;The input gate is in this case the internal processor driver. The two MOSFET gates connect directly to the processor pin. Vdd should usually be no higher than processor Vmax_drive_out. Slightly higher can be made to work with suitable design. Much higher voltage loads can be driven with this circuit (or similar) plus one extra transistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bRw7X.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bRw7X.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A buffer such as a ULN2803 (and other family members) will drive 8 channels x 500 mA/channel and several can be paralleled.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A ULN2803 is essentially 8 x &quot;Darlington&quot; transistors with emitters connected to a common ground, 8 x &quot;open collector&quot; (unconnected) collectors, and 8 flyback diodes to deal with over voltage spikes (use optional). (There is a ULN280x family with slightly different input characteristics). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This device provides a reasonably priced means of providing 8 x 500 mA pull down drivers. A load connected from an output to V+ is turned on when the input pin is driven high. Once you've used one a few times you'll find them trivially easy to use and very useful. (There is also a ULN200x family with 7 channels per package).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=HE4CqVR7H3s&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube &quot;how to&quot; video&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://graigroup.wordpress.com/2008/04/27/stepper-motor-driver-using-uln2803/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Driving a stepper motor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JncuL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JncuL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://graigroup.wordpress.com/2008/04/27/stepper-motor-driver-using-uln2803/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Also here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://profmason.com/?s=gearhead&quot; rel=&quot;nofollow noreferrer&quot;&gt;Driving small DC motors&lt;/a&gt; - and quite a lot else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mmgi9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mmgi9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.google.co.nz/search?q=uln2803+motor+driver&amp;amp;biw=1164&amp;amp;bih=817&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0CCAQsARqFQoTCJ_f69jo0MgCFUQrpgodKL4CZA&quot; rel=&quot;nofollow noreferrer&quot;&gt;A zillion examples&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.digikey.com/product-detail/en/ULN2803APG,CN/ULN2803APGCN-ND/856431&quot; rel=&quot;nofollow noreferrer&quot;&gt;Digikey - available in 1's if desired&lt;/a&gt; $0.72/1, $0.29 in 1000's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.toshiba.com/taec/components2/Datasheet_Sync/201212/DST_ULN2803APG-TDE_EN_22738.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;ULN2803 datasheet&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/312&quot; rel=&quot;nofollow noreferrer&quot;&gt;For sale at Sparkfun&lt;/a&gt;  - can be had rather cheaper but these are available&lt;/p&gt;&#xA;" OwnerUserId="6959" LastEditorUserId="14197" LastEditDate="2015-10-21T07:01:11.920" LastActivityDate="2015-10-21T07:01:11.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17027" PostTypeId="2" ParentId="17022" CreationDate="2015-10-20T10:39:09.240" Score="5" Body="&lt;p&gt;Have a look at the simple circuit on this &lt;a href=&quot;http://playground.arduino.cc/uploads/Main/relays.pdf&quot; rel=&quot;noreferrer&quot;&gt;PDF&lt;/a&gt; from the Arduino Playground.  It shows a single transistor to drive a small relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Russell says in his answer, a ULN2803 or similar is a chip which will allow you to drive several small relays, which is neater than using several transistors, if that's what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also note the diode &quot;D1&quot; in the circuit I linked - you need this, it's to protect the transistor from eventually being damaged by inductive spikes generated when the relay turns off.  Some of the ULN-style chips have this diode built in, which is why you don't always see it in schematics.)&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2015-10-20T10:39:09.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17028" PostTypeId="1" CreationDate="2015-10-20T11:47:13.243" Score="2" ViewCount="1612" Body="&lt;p&gt;I have this pretty simple task to light up an LED for 3 seconds when I send the right password from my Android phone to the Arduino via Bluetooth. I am using an HC-05 Bluetooth Module. My LED is connected to Pin 9 of the Arduino I/O. TX and RX of HC-05 is connected to Pins 1 and 0 of Arduino respectively. Here's the code I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int output = 9;         //I will be using to control a DC motor(LED is just for testing).&#xA;int output2 = 10;&#xA;char final[4];&#xA;char correct[4] = {'Q','W','E','R'};&#xA;int pass_true;&#xA;&#xA;void setup() {&#xA;  pinMode(output, OUTPUT);&#xA;  pinMode(output2, OUTPUT);&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  while(Serial.available()){&#xA;    for(int i=0; i&amp;lt;4; i++){&#xA;      final[i] = Serial.read();&#xA;    }&#xA;    for(int i=0; i&amp;lt;4; i++){&#xA;      if(final[i]==correct[i]){&#xA;        pass_true = 1;&#xA;      }&#xA;      else{&#xA;    pass_true = 0;&#xA;    break;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  if(pass_true==1){&#xA;    digitalWrite(output, HIGH);&#xA;    Serial.println(&quot;ON&quot;);&#xA;    delay(3000);&#xA;    pass_true = 0;&#xA;  }&#xA;  else{&#xA;    digitalWrite(output, LOW);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using Bluetooth SPP Pro Android App to send the 4-byte pass code (&quot;QWER&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the LED wont light up. I tried replacing the LED thinking that it may be a dead one but it's not. The &quot;TX&quot; LED on the board blinks everytime I press &quot;SEND&quot; in the Bluetooth App, but still Pin 9 doesn't seem to produce the HIGH output at all. Is there a problem with the code? &lt;/p&gt;&#xA;" OwnerUserId="14129" LastEditorUserId="14129" LastEditDate="2015-10-20T12:43:10.683" LastActivityDate="2016-12-02T16:40:03.823" Title="Code for password-activated LED via Bluetooth serial" Tags="|bluetooth|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17029" PostTypeId="1" AcceptedAnswerId="17031" CreationDate="2015-10-20T13:06:47.020" Score="1" ViewCount="3111" Body="&lt;p&gt;I have a functon that creates a instance of &lt;code&gt;KeyReport&lt;/code&gt; and I want to fill statically the &lt;code&gt;KeyReport.keys&lt;/code&gt; array. I'm new in the Arduino world so I'll put a example to explain it better:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendKey(byte keys[6], byte modifiers)&#xA;{&#xA;  KeyReport report = {0};&#xA;&#xA;  report.keys = keys; // This is my main trouble&#xA;  report.modifiers = modifiers;&#xA;  report.reserved = 1;&#xA;  Keyboard.sendReport(&amp;amp;report);&#xA;}&#xA;&#xA;void setup(){&#xA;delay(3000);&#xA;sendKey( {0x17,0,0,0,0,0}, 0x5); // I want to send hardcoded reports like this&#xA;}&#xA;&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14182" LastActivityDate="2015-10-20T13:26:41.593" Title="Passing a static array to a function" Tags="|programming|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17030" PostTypeId="2" ParentId="17022" CreationDate="2015-10-20T13:22:30.313" Score="5" Body="&lt;p&gt;To really protect your arduino it's worth putting a photo-coupler on the pin and driving your circuit that way.  Then no stray inductive charge or short can affect the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are also called OptoIsolators or Optocouplers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=143954.0&quot; rel=&quot;noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=143954.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14178" LastActivityDate="2015-10-20T13:22:30.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17031" PostTypeId="2" ParentId="17029" CreationDate="2015-10-20T13:26:41.593" Score="1" Body="&lt;pre&gt;&lt;code&gt;report.keys = keys; // This is my main trouble&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't assign the contents of one array to the contents of another array.  You can only copy the contents manually from one to the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way is with a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 6; i++) {&#xA;    report.keys[i] = keys[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a helper function - &lt;code&gt;memcpy()&lt;/code&gt; - which can do it for you if you prefer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(report.keys, keys, 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It effectively does exactly the same thing - copy 6 bytes starting from the address of &lt;code&gt;keys&lt;/code&gt; into the addresses starting at &lt;code&gt;report.keys&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the &quot;hard coded&quot; reports I suggest you create some &lt;code&gt;const&lt;/code&gt; arrays in the global context - and even use &lt;code&gt;PROGMEM&lt;/code&gt; to ensure they consume no RAM. That, of course, requires an entirely different way of passing and accessing the data.  It may be simpler to split the report into 6 individual variables and pass each byte separately:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendKey(byte k0, byte k1, byte k2, byte k3,&#xA;             byte k4, byte k5, byte modifiers)&#xA;{&#xA;  KeyReport report = {0};&#xA;&#xA;  report.keys[0] = k0;&#xA;  report.keys[1] = k1;&#xA;  report.keys[2] = k2;&#xA;  report.keys[3] = k3;&#xA;  report.keys[4] = k4;&#xA;  report.keys[5] = k5;&#xA;  report.modifiers = modifiers;&#xA;  report.reserved = 1;&#xA;  Keyboard.sendReport(&amp;amp;report);&#xA;}&#xA;&#xA;sendKey(0x17, 0, 0, 0, 0, 0, 0x05);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Yes, it's a little more long winded in the function, but calling the function is somewhat more simplified over the other options.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-20T13:26:41.593" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17033" PostTypeId="1" AcceptedAnswerId="17035" CreationDate="2015-10-20T14:27:04.767" Score="0" ViewCount="212" Body="&lt;p&gt;I'm new to electronics and have been getting rather into my Arduino. But I don't just like following an instructable to do something. I like to know the math behind it and how it works inside. Now from my understanding the Arduino (Uno R3 for me), has a 200 mA max current. The LEDs I used have a 20 mA current. Now with 64 LEDs, wouldn't this fry my Arduino? This also applies to my LCD screen with a 160 mA current. Am I missing a key secret to going over amperage?&lt;/p&gt;&#xA;" OwnerUserId="14183" LastEditorUserId="46" LastEditDate="2015-10-20T15:56:10.677" LastActivityDate="2015-10-20T15:56:10.677" Title="LED cube and 200 mA limitation" Tags="|arduino-uno|led|lcd|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17035" PostTypeId="2" ParentId="17033" CreationDate="2015-10-20T15:07:47.660" Score="1" Body="&lt;p&gt;The current limit you quote is the maximum current that the main chip on the Arduino can tolerate through its 5V or GND pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the chip itself consumes (round numbers demonstrate the theory) say 50mA that leaves 150mA in total that can be sourced or sunk through IO pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to supply 20mA per LED (that is actually overkill - you can use considerably less and have very little difference in brightness) that means you can have, illuminated at any one time, (150 / 20 = ) 7.5 LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To increase the number of LEDs you can drive at once you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reduce the current by increasing the resistor values.&lt;/li&gt;&#xA;&lt;li&gt;Use multiplexing so that, although it looks like all LEDs are on at once, only a few are actually on at once.&lt;/li&gt;&#xA;&lt;li&gt;Use external LED driving circuitry (transistors, LED driver shift registers, etc).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All this pertains purely to the current that passes through the main chip itself.  It does not pertain to any current you draw from the 5V or 3.3V pins.  The maximum current through those pins is limited by the voltage regulator they are attached to, and also by the voltage that you are supplying the board with (the higher the voltage, the more voltage has to be dropped, and so the more heat is generated per mA drawn).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 5V regulator has around 800mA limit when supplied with 6.5V.  If supplied with 12V the limit is considerably less (since it will get too hot and go into &lt;em&gt;thermal shutdown&lt;/em&gt;).  You subtract what you are drawing through the chip (maximum 200mA) and that is how much current you have available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 3.3V regulator is driven from the 5V regulator, so any current drawn from the 3.3V pin must also be subtracted from what is available on the 5V pin.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-20T15:07:47.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17036" PostTypeId="2" ParentId="17033" CreationDate="2015-10-20T15:14:02.237" Score="1" Body="&lt;p&gt;I'm assuming you're talking about an 8x8x8 cube.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 200mA is for all IO. The regular 5v line can supply 500mA. Since you don't have 64 pins available, you are not supplying the leds via the Arduino directly. Probably using some shift register, or led driver chips for the 64 (cathode) columns. For the 8 levels you'd use some PNP transistors or P-channel mosfets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the Arduino won't drive any led directly, so it will only use a few tens of milli-amps. Since you'll draw around 1.3A when all leds are lid, you should power the external components directly from the power supply, instead of via the Arduino. Or you'll hit the 500mA limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the Arduino is just pushing the levers, and not doing any of the hard work (crane analogy).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-20T15:14:02.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17039" PostTypeId="1" AcceptedAnswerId="17040" CreationDate="2015-10-20T18:54:04.507" Score="0" ViewCount="693" Body="&lt;p&gt;I've found a lot of tutorials about how to use an Arduino to control power supplies to lamps and things like that using a relay. However, I also need to power the Arduino with the same power that is going through the relay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I'd like to be able to plug my device into the wall. The device would use the 110VAC to power the Arduino. My device would also have some outlets that I could plug something into. The Arduino would be connected to a relay and would decide when to enable electricity to the outlet. The important part being that I would like everything to be on one power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to have a step down converter to transform the power, in addition to the relay? Is there some sort of break out board that has both of these functionalities in one board? What is the best way to do this?&lt;/p&gt;&#xA;" OwnerUserId="1111" LastActivityDate="2015-10-20T19:29:57.033" Title="Powering Arduino with 110v and controlling relay" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17040" PostTypeId="2" ParentId="17039" CreationDate="2015-10-20T19:29:57.033" Score="4" Body="&lt;p&gt;In these cases where power must come from mains, my preferred solution is to buy a cheap phone charger+usb cable from ebay. They are sealed and safer than do-it-yourself solutions. The power adapter is barely larger than a normal plug for mains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you absolutely need to reach the arduino with only one cable, you can still use the solution i gave, only use a power cord to reach the contraption, then use a socket expander for mains and very short usb cable.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-20T19:29:57.033" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17041" PostTypeId="2" ParentId="10478" CreationDate="2015-10-20T20:36:39.607" Score="1" Body="&lt;p&gt;Forget Tserial.h lib. To solve your problem (for serial communication) I sugest you to use &quot;read/write from/to a file&quot; programming method. The serial ports may be written to just like you are writing in a file. In the facedetect.cpp (OpenCV's example), in the detectAndDraw() function (I'm using OpenCV 3.0) add: &lt;code&gt;unsigned char MSB[1] = {0}; //&#xA;    unsigned char LSB[1] = {0}; //&#xA;    char serialPortFilename[]=&quot;/dev/ttyACM0&quot;;&#xA;    FILE *serPort = fopen(serialPortFilename, &quot;w&quot;); //&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;than add: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LSB[0]=r-&amp;gt;x &amp;amp; 0xff;//&#xA;    MSB[0]=(r-&amp;gt;x &amp;gt;&amp;gt;8) &amp;amp; 0xff;//&#xA;&#xA;    fwrite((const void*)MSB,sizeof(unsigned char),sizeof(MSB),serPort);//&#xA;fwrite((const void*)LSB,sizeof(unsigned char),sizeof(LSB),serPort);//&#xA;&#xA;LSB[0]=r-&amp;gt;y &amp;amp; 0xff;//&#xA;    MSB[0]=(r-&amp;gt;y &amp;gt;&amp;gt;8) &amp;amp; 0xff;//&#xA;&#xA;    fwrite((const void*)MSB,sizeof(unsigned char),sizeof(MSB),serPort);//&#xA;    fwrite((const void*)LSB,sizeof(unsigned char),sizeof(LSB),serPort);//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into the if (0.75 &amp;lt; aspect_ratio &amp;amp;&amp;amp; aspect_ratio &amp;lt; 1.3) statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally don't forget to close the file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fclose(serPort);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this will work for you!&lt;/p&gt;&#xA;" OwnerUserId="14191" LastActivityDate="2015-10-20T20:36:39.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17042" PostTypeId="1" AcceptedAnswerId="17048" CreationDate="2015-10-20T21:01:58.627" Score="0" ViewCount="3362" Body="&lt;p&gt;Just bought an ESP8266 module to try it using my arduino uno R3. I have connected my WIFI module correctly, anyways evenb if i disconnect it, the error occur.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While trying to upload the WIFI (connect with wpa) sketch i get several errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First i tried uploading the hole sketch, i got those errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/libraries/WiFi/WiFi.cpp: In member function ‘uint8_t* WiFiClass::macAddress(uint8_t*)’:&#xA;/usr/share/arduino/libraries/WiFi/WiFi.cpp:112:1: error: unable to find a register to spill in class ‘POINTER_REGS’&#xA;/usr/share/arduino/libraries/WiFi/WiFi.cpp:112:1: error: this is the insn:&#xA;(insn 35 25 26 2 (set (reg:QI 23 r23)&#xA;    (mem/c:QI (plus:HI (reg/f:HI 28 r28)&#xA;            (const_int 2 [0x2])) [3 S1 A8])) /usr/share/arduino/libraries/WiFi/WiFi.cpp:110 28 {movqi_insn}&#xA;     (nil))&#xA;/usr/share/arduino/libraries/WiFi/WiFi.cpp:112: confused by earlier errors, bailing out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that i tried to only import just the libraries and try to compile it. Even with this method i get errors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;WiFiServer.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from /usr/share/arduino/libraries/WiFi/WiFiServer.h:8:0,&#xA;                 from sketch_oct20b.ino:1:&#xA;/usr/share/arduino/hardware/arduino/cores/arduino/Server.h:4:29: error: expected class-name before ‘{’ token&#xA;In file included from sketch_oct20b.ino:1:0:&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:14:3: error: ‘uint16_t’ does not name a type&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:17:22: error: field ‘uint16_t’ has incomplete type&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:18:24: error: ‘uint8_t’ has not been declared&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:20:11: error: ‘size_t’ does not name a type&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:21:11: error: ‘size_t’ does not name a type&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:22:3: error: ‘uint8_t’ does not name a type&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:24:9: error: ‘Print’ has not been declared&#xA;/usr/share/arduino/libraries/WiFi/WiFiServer.h:18:42: error: ‘NULL’ was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can just figure out some syntax errors, but my c is not good enough to understand much of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what am i doing wrong and show me how it will be done?&lt;/p&gt;&#xA;" OwnerUserId="14192" LastActivityDate="2015-10-20T23:00:05.110" Title="Arduino WIFI compiler error" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17043" PostTypeId="2" ParentId="601" CreationDate="2015-10-20T22:12:23.083" Score="1" Body="&lt;p&gt;I'm pretty sure you could just take the signal cable from the dust sensor and plug it directly into your mcu digital pin of choice and then wire the Vcc and Gnd as well.  I'm working with a CO2 sensor and don't really want the shield overhead.&lt;/p&gt;&#xA;" OwnerUserId="14195" LastActivityDate="2015-10-20T22:12:23.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17044" PostTypeId="1" CreationDate="2015-10-20T21:38:18.423" Score="1" ViewCount="1663" Body="&lt;p&gt;I am working on a prototype device which I am now on my 2nd board iteration and moving away from it being a shield and wired to an arduino mega2560 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used the freely available Arduino mega 2560 schematic and incorporated this into my project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice that there are 2 µcontrollers on this schematic, (Atmega2560 &amp;amp; Atmega16U2)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that the arduino bootloader resides on the 16u2 and it connect to the usb connector. the 16u2 then programs the 2560 with the code you send it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the searching I have done I'm getting myself terribly confused. &#xA;Someone suggested to me that I could in fact do away with the Atmega16u2 all together (this would drastically reduce my component count and free up valuable board space) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I was intending to flash a boot loader that would make the device appear to a computer (over usb) as a midi controller device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am unclear if I can indeed interface a usb port directly to the ATmega2560,  and upload my sketch code AND a midi-over-usb boot loader..&#xA;I doubt the advice because the ATmega16U2 (i think) has a built in UART to communicate via usb and that the 2560 does not...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry If this all sounds vague, I'm searched out and confused...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks. &lt;/p&gt;&#xA;" OwnerUserId="14201" OwnerDisplayName="Brad Holland" LastActivityDate="2015-10-21T00:04:06.447" Title="Can I place bootloader directly onto Atmega2560 and have USB?" Tags="|bootloader|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17045" PostTypeId="2" ParentId="17044" CreationDate="2015-10-20T21:49:16.360" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;if I can indeed interface a usb port directly to the ATmega2560&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You cannot interface USB directly to the ATMega2560, because that µC has no USB support build into (and VUSB is probably no solution either).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your program is simple enough, then it could fit onto the ATMega16U2 on its own, eliminating the 2560. &lt;/p&gt;&#xA;" OwnerUserId="19797" OwnerDisplayName="Turbo J" LastActivityDate="2015-10-20T21:49:16.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17046" PostTypeId="2" ParentId="17044" CreationDate="2015-10-20T22:23:16.287" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I understand that the arduino bootloader resides on the 16u2 and it connect to the usb connector. the 16u2 then programs the 2560 with the code you send it. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is a misunderstanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bootloader is on the 2560.  The 16U2 contains its own custom firmware which acts as a USB CDC/ACM interface to connect the USB to the 2560 as a TTL UART connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same can be done using any number of other similar devices, such as the FT232R etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot directly connect the USB to the 2560 since the 2560 has no concept of what USB is.  The 16U2 has that knowledge, but doesn't have as many IO pins as the 2560, so combining the two gives you a total system that both understands USB and has lots of IO.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-20T22:23:16.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17048" PostTypeId="2" ParentId="17042" CreationDate="2015-10-20T23:00:05.110" Score="0" Body="&lt;p&gt;The WiFi libraries (such as &lt;code&gt;Wifi.h&lt;/code&gt;, &lt;code&gt;WifiClient.h&lt;/code&gt;, and &lt;code&gt;WiFiServer.h&lt;/code&gt;) are used for interfacing with the official Arduino WiFi shield. Interfacing with an ESP8266 module is typically done by issuing AT commands via UART (i.e. &lt;code&gt;Serial.write()&lt;/code&gt;, etc.)&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2015-10-20T23:00:05.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17050" PostTypeId="1" CreationDate="2015-10-20T23:38:40.453" Score="2" ViewCount="662" Body="&lt;p&gt;I am planing to build a project where an arduino pro mini 3.3V runs on 2 aa batteries. The standard brown out detection shuts it down at about 2.7/2.8V where it could run on lower voltages too.&#xA;So I changed the efuse to get the BOD down to 1.8V. I connected a serial to usb converter and used avrdude:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp -p m328p -P COM5 -b 19200 -U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0x06:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I tried to upload a program using the arduino 1.0.3 IDE but I got this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync(): not in sync: resp=0x1c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With 1.6.4 I got another error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x75&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After some googling I tried some lower baud rate (the standard seems to be 57600). With 19200 everything worked with avrdude, so I created a new entry in the boards.txt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ##############################################################&#xA;&#xA;pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 BOD 1.8V&#xA;&#xA;pro328.upload.protocol=arduino&#xA;pro328.upload.maximum_size=30720&#xA;pro328.upload.speed=19200&#xA;&#xA;pro328.bootloader.low_fuses=0xFF&#xA;pro328.bootloader.high_fuses=0xDA&#xA;pro328.bootloader.extended_fuses=0x06&#xA;pro328.bootloader.path=atmega&#xA;pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex&#xA;pro328.bootloader.unlock_bits=0x3F&#xA;pro328.bootloader.lock_bits=0x0F&#xA;&#xA;pro328.build.mcu=atmega328p&#xA;pro328.build.f_cpu=8000000L&#xA;pro328.build.core=arduino&#xA;pro328.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And burned a bootloader using the 1.0.3 IDE again. After that I could upload a blink program. My goal is to upload a mysensors sketch though and that doesn't work. I am getting an error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verification error, first mismatch at byte 0x0002&#xA;         0x69 != 0x61&#xA;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mysensors seems to have general problems with old arduino IDEs so I tried to use the newer 1.6.4 but I can't define my own board there and if I try it without I get hte out of sync error (because it's still using the wrong baudrate I guess).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried using another arduino uno as ISP =&gt; same results&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this? Is there a way to define my own board for 1.6.x?&#xA;Whats the standard way of doing this and why does the change of the efuse results in me not beeing able to program the mini any longer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for every answer/help!&lt;/p&gt;&#xA;" OwnerUserId="13704" LastActivityDate="2015-12-27T21:54:59.240" Title="Arduino Pro Mini lower BOD problem" Tags="|arduino-pro-mini|avrdude|isp|arduinoisp|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17051" PostTypeId="1" CreationDate="2015-10-20T23:45:29.380" Score="0" ViewCount="1083" Body="&lt;p&gt;I'm not sure if i should post this here or on StackOverflow but I am coding for an LED cube controlled with 4 shift registers. I have a function in a .h file that is supposed to take an array of 1s and 0s (to represent each LED) and then use the shiftOut function to shift the data into the shift registers. This is complicated that the shiftOut function has to take a int which it shifts out in binary and only goes 8 bits at a time. This means I have to separate my array into 4 groups of 8 and then convert each group into an int. I have tried to make my function do that but it is compiling fine and then not lighting up any LEDs. I believe the problem has to do with the way I'm separating the array into 4 smaller arrays althoughI can not figure out exactly what is going wrong, here is my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LEDcube.h&amp;gt;&#xA;&#xA;int data = 2; &#xA;int clock = 3;&#xA;int latch = 4;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(data, OUTPUT);&#xA;  pinMode(clock, OUTPUT);  &#xA;  pinMode(latch, OUTPUT);  &#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  int layer[32] = {0,&#xA;&#xA;                  1,1,1,1,1,&#xA;                  0,0,0,0,0,&#xA;                  1,1,1,1,1,&#xA;                  0,0,0,0,0,&#xA;                  1,1,1,1,1,&#xA;&#xA;                  0,0,0,0,0,0};&#xA;  write(data, clock, latch, layer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;LEDcube.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;int binToNum(int bin[])&#xA;{&#xA;  int j = 1;&#xA;  int num = 0;&#xA;  for(int i = 0; i &amp;lt; 8; i++, j = j * 2)&#xA;  {&#xA;    if(bin[i] == 1)&#xA;    {&#xA;      num = num + j;&#xA;    }&#xA;  }&#xA;  return num;&#xA;}&#xA;void write(int data, int clock, int latch, int layer[])&#xA;{&#xA;  int reg1[8];&#xA;  int reg2[8];&#xA;  int reg3[8];&#xA;  int reg4[8];&#xA;  for(int i = 0; 1 &amp;lt; 8; i++)&#xA;  {&#xA;    reg1[i] = layer[i];&#xA;  }&#xA;    for(int i = 0; 1 &amp;lt; 8; i++)&#xA;  {&#xA;    int q = i + 8;&#xA;    reg2[i] = layer[q];&#xA;  }&#xA;  for(int i = 0; 1 &amp;lt; 8; i++)&#xA;  {&#xA;    int q = i + 16;&#xA;    reg3[i] = layer[q];&#xA;  }&#xA;  for(int i = 0; 1 &amp;lt; 8; i++)&#xA;  {&#xA;    int q = i + 24;&#xA;    reg4[i] = layer[q];&#xA;  }  &#xA;  int regnum1 = binToNum(reg1);&#xA;  int regnum2 = binToNum(reg2);&#xA;  int regnum3 = binToNum(reg3);&#xA;  int regnum4 = binToNum(reg4);&#xA;  digitalWrite(latch, LOW);&#xA;  shiftOut(data, clock, MSBFIRST, regnum4);&#xA;  shiftOut(data, clock, MSBFIRST, regnum3);&#xA;  shiftOut(data, clock, MSBFIRST, regnum2);  &#xA;  shiftOut(data, clock, MSBFIRST, regnum1);&#xA;  digitalWrite(latch, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14113" LastEditorUserId="14113" LastEditDate="2015-10-21T03:21:03.680" LastActivityDate="2015-12-20T05:27:34.017" Title="Shift register 1's and 0's array to 4 int's function not working" Tags="|c++|shift-register|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17052" PostTypeId="1" CreationDate="2015-10-20T23:48:55.353" Score="2" ViewCount="1543" Body="&lt;p&gt;Just followed &lt;a href=&quot;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;a tutorial&lt;/a&gt; on how to set up ESP8266 with my Arduino Uno R3. I have a serial connection and get a response of the Arduino but I'm stuck now at chapter &quot;first commands&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have successfully issued the &lt;code&gt;AT&lt;/code&gt; command and also the &lt;code&gt;AT+RST&lt;/code&gt; command and got a response. BUT, the response return was &quot;invalid&quot; at its end instead of &quot;ready&quot;. Also theres an output &quot;MEM CHECK FAIL!!!&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&#xA;&#xA;OK&#xA;AT+RST&#xA;&#xA;&#xA;OK&#xA;&#xA; ets Jan  8 2013,rst cause:2, boot mode:(3,4)&#xA;&#xA;load 0x40100000, len 1396, room 16 &#xA;tail 4&#xA;chksum 0x89&#xA;load 0x3ffe8000, len 776, room 4 &#xA;tail 4&#xA;chksum 0xe8&#xA;load 0x3ffe8308, len 540, room 4 &#xA;tail 8&#xA;chksum 0xc0&#xA;csum 0xc0&#xA;&#xA;2nd boot version : 1.4(b1)&#xA;  SPI Speed      : 40MHz&#xA;  SPI Mode       : QIO&#xA;  SPI Flash Size &amp;amp; Map: 8Mbit(512KB+512KB)&#xA;jump to run user1 @ 1000&#xA;&#xA;ÃÕMEM CHECK FAIL!!! &amp;lt;&amp;lt;----------------------------- ???&#xA;äslrô&#xA;Ai-Thinker Technology Co. Ltd.&#xA;&#xA;invalid &amp;lt;&amp;lt;----------------------------------------- should be &quot;ready&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain me what that means? Do I have to (re)flash the firmware? And also - are the instructions all the same? I have bought mine from China but it was sold at the same ESP8266 module on Amazon.&lt;/p&gt;&#xA;" OwnerUserId="14192" LastEditorUserId="4628" LastEditDate="2017-01-28T14:33:34.590" LastActivityDate="2017-07-29T12:47:43.020" Title="Arduino Uno &quot;MEM CHECK FAIL&quot; error" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17053" PostTypeId="2" ParentId="17044" CreationDate="2015-10-21T00:04:06.447" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Someone suggested to me that I could in fact do away with the Atmega16u2 all together (this would drastically reduce my component count and free up valuable board space)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I recommend that you keep the '16U2 and ditch the '2560. Since the '16U2 is both native USB capable &lt;em&gt;and&lt;/em&gt; has sufficient I/O for a MIDI controller then you should use &lt;em&gt;that&lt;/em&gt; one for your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, since &lt;a href=&quot;https://arduino.stackexchange.com/questions/3122/arduino-core-for-atmega16u2&quot;&gt;there's no Arduino core for the '16U2&lt;/a&gt; you may want to consider either learning AVR programming without Arduino (when will there be a better time to do so?), or switching to the (overpowered) 'U4, which uses the Leonardo core.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-21T00:04:06.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17054" PostTypeId="2" ParentId="17051" CreationDate="2015-10-21T00:27:42.860" Score="1" Body="&lt;p&gt;The problem is you need to write your data with all of your bits consolidated into a single integer instead of as an array of integers. For example, if you were to &lt;code&gt;shiftOut(data, clock, MSBFIRST, 1)&lt;/code&gt; that would send &lt;code&gt;00000001&lt;/code&gt;, not &lt;code&gt;1&lt;/code&gt;. So for example, if you want to send out 1,0,1,0,1,0,1,0 you need to send &lt;code&gt;shiftOut(data, clock, MSBFIRST, 170)&lt;/code&gt;, because 170 in binary is 10101010. So you will need to figure out how to represent your data as an integer rather than array of integers of which you are only using the first bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that you are attempting to do a binary conversion, but your for loop is a little off. Try this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 8; i++)&#xA;{&#xA;  if(bin[i] == 1)&#xA;  {&#xA;    num = num + j;&#xA;  }&#xA;  j = j * 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if that fixes it, you will probably still need to some major refactoring to get decent speed, currently you are using 128 bytes of memory to represent 4 bytes worth of data. and there are plenty of other little inefficiencies here and there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest version of the above functionality is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int data = 2; &#xA;int clock = 3;&#xA;int latch = 4;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(data, OUTPUT);&#xA;  pinMode(clock, OUTPUT);&#xA;  pinMode(latch, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  int data1 = 0b1111100000111110; //Set a variable using a binary constant&#xA;  int data2 = 0b0000111110000000;&#xA;  digitalWrite(latch, LOW);&#xA;  shiftOut(data, clock, MSBFIRST, data1);&#xA;  shiftOut(data, clock, MSBFIRST, data2);&#xA;  digitalWrite(latch, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are going to be doing more bit level manipulation, you should probably learn various bit wise operators such as &amp;lt;&amp;lt;, &gt;&gt; &amp;amp;, ^, |, ~, &amp;amp;=, and |=. The &lt;a href=&quot;https://www.arduino.cc/en/Reference/HomePage&quot; rel=&quot;nofollow&quot;&gt;Arduino documentation&lt;/a&gt; goes over them and what they do (scroll down, on the left under Bitwise Operators).&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2015-10-21T04:35:34.067" LastActivityDate="2015-10-21T04:35:34.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17055" PostTypeId="2" ParentId="17051" CreationDate="2015-10-21T03:53:23.040" Score="1" Body="&lt;p&gt;As noted in Stu's answer, the question's code does not pack bits properly into the bytes that &lt;code&gt;shiftOut()&lt;/code&gt; will unpack them from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you merely want to make things work, as opposed to packing stuff up one place so it can be unpacked another, just write the bits to your SR yourself.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i=0; i&amp;lt;32; ++i) {&#xA;  digitalWrite(data, layer[i]); // Put a bit on the data pin&#xA;  digitalWrite(clock, HIGH); // Pulse the clock&#xA;  digitalWrite(clock, LOW);&#xA;}&#xA;digitalWrite(latch, HIGH); // Pulse the latch&#xA;digitalWrite(latch, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the clock or latch need low-going instead of high-going pulses, reverse the order of writing &lt;code&gt;HIGH&lt;/code&gt; and &lt;code&gt;LOW&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-21T03:53:23.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17057" PostTypeId="1" AcceptedAnswerId="75525" CreationDate="2015-10-21T07:19:40.447" Score="2" ViewCount="2323" Body="&lt;p&gt;I'm playing with the Arduino Leonardo &lt;code&gt;Keyboard.print()&lt;/code&gt; command, but I'm facing a annoying problem: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I print a double quote, it will not appear and also will make to disappear the next character (i.e.):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.print(&quot;echo \&quot;This is a demo\&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo his is a demo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when I use this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.print(&quot;echo -This is \&quot;a demo-&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output (note the umlaut over the &lt;code&gt;a&lt;/code&gt; instead of getting &lt;code&gt;&quot;a&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'This is ä demo'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect that the problem is that my computer is configured to use Spanish layout. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What source code file can I change to fix this? I can't find the defines used by &lt;code&gt;Keyboard.print()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14182" LastEditorUserId="14182" LastEditDate="2015-10-21T07:27:20.490" LastActivityDate="2020-05-08T15:16:06.263" Title="Keyboard.print() skips keys" Tags="|usb|arduino-leonardo|keyboard|atmega32u4|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17058" PostTypeId="2" ParentId="17057" CreationDate="2015-10-21T08:04:48.150" Score="4" Body="&lt;p&gt;The Arduino assumes a US keyboard layout.  The thing with keyboards is they don't actually send the letters or symbols that are printed on the keys.  Instead the send a &lt;em&gt;scan code&lt;/em&gt; that defines &lt;em&gt;where&lt;/em&gt; on the keyboard the key is.  It is then up to the computer to convert those scan codes into actual letters and symbols, and that is performed by the keyboard mapping selected in the operating system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some special keys are known as &lt;em&gt;dead keys&lt;/em&gt;.  These don't actually print a character on their own - instead they are used to modify the next key pressed - for instance the key which occupies the space a &quot; would be on a US keyboard, on a Spanish keyboard, is a dead key which modifies the next key by adding an umlaut to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the Arduino doesn't know that you have a Spanish mapping, when you send a &quot; it just sends what it believes is the location of that character on a keyboard, and of course it gets that wrong since it assumes the wrong keyboard layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are two things you can do to &quot;fix&quot; it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change your keyboard layout to US, but that will mean your normal keyboard will stop working properly.&lt;/li&gt;&#xA;&lt;li&gt;Change how the Arduino thinks the keyboard is laid out, but that means lots of work to find the right scan codes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The Arduino's keyboard layout is stored in the file &lt;code&gt;HID.cpp&lt;/code&gt; in the Arduino core (&lt;code&gt;hardware\avr\cores\arduino&lt;/code&gt; or somewhere like that - I forget off hand) and is the &lt;code&gt;_asciimap&lt;/code&gt; array.  It is a list of the first 128 ASCII characters and the keyboard scancode mappings for them, including &lt;em&gt;modifier keys&lt;/em&gt; like Shift.  You will have to find the scan codes for the keys you want to map on your keyboard layout and change the codes in that list.  For instance, the character &quot; is listed as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0x34|SHIFT,    // &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is scan code 0x34 (52 decimal) coupled with the SHIFT modifier.  You will have to discover (maybe Google can help) what the 0x34 should be changed to so that it moves the &quot; to wherever it is on a Spanish keyboard.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-21T08:04:48.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17060" PostTypeId="1" AcceptedAnswerId="17111" CreationDate="2015-10-21T13:17:36.497" Score="0" ViewCount="1493" Body="&lt;p&gt;I've been working with the lovely I2C_Anything.h (thanks to the great work and support from Nick over at &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10896&amp;amp;reply=9#reply9&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=10896&amp;amp;reply=9#reply9&lt;/a&gt;).. All working great, I was using Serial communication between Teensy 3.1 &amp;amp; mini pro but looking to replace with I2C - I was sending a file name across that was fine, but not managing to figure it out with the I2C_Anything technique.. here's some snippets:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MASTER&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t MaxMP3Name = 13;&#xA;//====================================&#xA;// DATA STRUCTURE FOR MP3 SLAVE&#xA;//==================================== &#xA;struct SEND_MP3_STRUCTURE{&#xA;  char Filename[MaxMP3Name];&#xA;  uint8_t VolLeft;&#xA;  uint8_t VolRight;&#xA;  uint8_t Command;&#xA;};&#xA;SEND_MP3_STRUCTURE txMP3;&#xA;&#xA;#define MP3_SLAVE_ADDRESS 77 &#xA;&#xA;const uint8_t PlayFile = 1;&#xA;const uint8_t PauseFile = 2;&#xA;const uint8_t StopFile = 3;&#xA;&#xA;... etc&#xA;&#xA;//#################################//&#xA;//##  SEND MP3 COMMAND           ##//&#xA;//#################################//&#xA;void sendMP3Command(String MP3File, uint8_t Command) {      &#xA;  char *TextArray[MaxMP3Name];&#xA;  MP3File.toCharArray(TextArray, MaxMP3Name);&#xA;  txMP3.Filename = TextArray;&#xA;  txMP3.VolLeft = VolLeft; &#xA;  txMP3.VolRight = VolRight;  &#xA;  txMP3.Command = Command;&#xA;  Wire.beginTransmission(MP3_SLAVE_ADDRESS);&#xA;  I2C_writeAnything(txMP3);&#xA;  Wire.endTransmission(true);&#xA;}&#xA;&#xA;...etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... not entirely sure what i'm doing, I've tried most variations (using String in the struct vs char *Filename[] and various other attempts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SLAVE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t MaxMP3Name = 13;&#xA;//====================================&#xA;// RECEIVE DATA FORMAT&#xA;//==================================== &#xA;struct RECEIVE_DATA_STRUCTURE{&#xA;  char Filename[MaxMP3Name];&#xA;  uint8_t VolLeft;&#xA;  uint8_t VolRight;&#xA;  uint8_t Command;   &#xA;};&#xA;volatile RECEIVE_DATA_STRUCTURE RXdata;&#xA;#define SLAVE_ADDRESS 77&#xA;volatile uint8_t newData; // flag to detect I2C activity&#xA;&#xA;// MAKE GLOBAL VERSIONS&#xA;String RX_Filename;&#xA;uint8_t RX_VolLeft = 30;&#xA;uint8_t RX_VolRight = 30;&#xA;uint8_t RX_Command = 0;&#xA;&#xA;... etc&#xA;&#xA;//#################################//&#xA;//##  MASTER SENDING US DATA     ##//&#xA;//#################################//&#xA;void onReceiveEvent(int numbytes){&#xA;  if(numbytes == 16){ &#xA;    I2C_readAnything(RXdata);      &#xA;    newData = 2;    &#xA;  }   &#xA;}&#xA;&#xA;... etc&#xA;&#xA;&#xA;&#xA;void loop(){ &#xA;  if (newData==2){// I2C received Data &#xA;    RX_Filename = RXdata.Filename;&#xA;    RX_VolLeft = RXdata.VolLeft;    &#xA;    RX_VolRight = RXdata.VolRight;            &#xA;    RX_Command = RXdata.Command;             &#xA;    newData = 0; // Clear data sent marker&#xA;  }&#xA;}&#xA;&#xA;... etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hopefully you'll be able to see pretty quickly what i'm trying to do and the method I should be using to do it..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any insights&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Andy&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Sorry, still getting used to this comment vs editing questions business, didn't realise it would add my comment when I hit enter so it cut me off... here's full comment: &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Hiya Nick, thanks for your suggestion, How you've recommended it is actually how I tried it originally (I don't like using Strings either) - which just ends up giving me the error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;&quot;invalid conversion from 'volatile char*' to 'const char*' [-fpermissive]&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(on the Slave) - obviously the RXdata is updated during the interrupt so can't leave it out (despite the fact it compiles - but doesnt work).. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got it working soon after I posted by breaking down the filename in the struct to separate chars, then assembling back into char array in a function I made. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That seemed to work fine, but only if I added null char at as the last char (0x00) - I can get the char &lt;code&gt;Filename[MaxMP3Name];&lt;/code&gt; working, but only if I lose the volatile declaration, and it skips the last char. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any further help Nick, I really appreciate all you do for the community and I know you're the best guy to help me (not to take anything away from anyone else that wants to jump in ;)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Current solution i'm using that avoids the volatile erros&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Obviously could be a for loop etc but I wrote it out this way just to debug and see where the issue was. Not perfect, but breaking it down this way seems to be overcoming the issue of trying to do anything with the volatile variable. (and i've got so much to figure out for so many other parts of the project that I was thinking i'd come back to it later once i'm done with other bits).. Cheers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#################################//&#xA;//##  SEND MP3 COMMAND        ##//&#xA;//#################################//&#xA;void sendMP3Command(String MP3File, uint8_t Command) {      &#xA;  char FileName[8];&#xA;  MP3File.toCharArray(FileName, MaxMP3Name+1);&#xA;  txMP3.File1 = FileName[0];&#xA;  txMP3.File2 = FileName[1];&#xA;  txMP3.File3 = FileName[2];&#xA;  txMP3.File4 = FileName[3];&#xA;  txMP3.File5 = FileName[4];&#xA;  txMP3.File6 = FileName[5];&#xA;  txMP3.File7 = FileName[6];&#xA;  txMP3.File8 = FileName[7];&#xA;  txMP3.VolLeft = VolLeft; &#xA;  txMP3.VolRight = VolRight;  &#xA;  txMP3.Command = Command;&#xA;  StartMicros = micros();&#xA;  Wire.beginTransmission(MP3_SLAVE_ADDRESS);&#xA;  I2C_writeAnything(txMP3);&#xA;  Wire.endTransmission(true);&#xA;  EndMicros = micros();&#xA;  //Serial.print(&quot;MP3 Packet Size: &quot;); Serial.println(sizeof(txMP3));&#xA;  //Serial.print(&quot;Sending Command To MP3: &quot;); Serial.print(MP3File);Serial.print(&quot;   Command; &quot;); Serial.print(txMP3.Command);Serial.print(&quot;   Time; &quot;); Serial.print(EndMicros-StartMicros);Serial.println(&quot;uS &quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... Oh, and on the slave end, I changed the numbytes to be sizeof, but as you say Nick, not even any need for that, i'm not using it on any of my other I2C slaves all running in the project (5 X MCU core system). the filename is then pulled from the I2C array in a siimilar (debugging) way as the master packs them in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//##############################//&#xA;// RECONSTRUCT FILENAME&#xA;//##############################//&#xA;String getFilename(){  &#xA;  char FileName[] = {&#xA;    RXdata.File1,&#xA;    RXdata.File2,&#xA;    RXdata.File3,&#xA;    RXdata.File4,&#xA;    RXdata.File5,&#xA;    RXdata.File6,&#xA;    RXdata.File7,&#xA;    RXdata.File8,&#xA;    0x00&#xA;  };&#xA;  return FileName;&#xA;&#xA;}&#xA;&#xA;&#xA;//#################################//&#xA;//##  MASTER REQUESTING DATA     ##//&#xA;//#################################//&#xA;void onRequestEvent(void){  &#xA;    I2C_singleWriteAnything(TXdata);&#xA;    newData = 1;    &#xA;}&#xA;&#xA;//#################################//&#xA;//##  MASTER SENDING US DATA ##//&#xA;//#################################//&#xA;void onReceiveEvent(int numbytes){&#xA;  if(numbytes == sizeof RXdata){ &#xA;    I2C_readAnything(RXdata);      &#xA;    newData = 2;    &#xA;  }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5065" LastEditorUserId="5065" LastEditDate="2016-01-26T21:56:43.193" LastActivityDate="2016-01-26T21:56:43.193" Title="I2C_Anything String / Char Array issues" Tags="|arduino-uno|c++|i2c|string|struct|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17062" PostTypeId="1" AcceptedAnswerId="17063" CreationDate="2015-10-21T14:56:51.837" Score="2" ViewCount="25872" Body="&lt;p&gt;I know this question has be asked before on this site. However it was never really answered. I have an Arduino Uno. I am trying to get it to read a 2 GB SDHC Micro SD card. The problem is, the SD card never intializes. I am not sure if there is something wrong with the wiring (which I think is NOT the issue) or the SD card/shield. I have formatted the SD card, but perhaps I did use the wrong settings to do so. Additionally, this SD card is quite old, probably several years. It can still be managed on my PC however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought the following &lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/B015VH43WM&quot; rel=&quot;nofollow noreferrer&quot;&gt;Micro SD shield off Amazon.&lt;/a&gt; It has the pins VCC, GND, MISO, CS, MOSI, and SCK, for which I figured the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MISO = D0&#xA;CS = D1&#xA;MOSI = CLK&#xA;SCK = D3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the circuit wired in the following way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SCK to Pin 10 on Arduino&#xA;CS to Pin 11 on Arduino&#xA;MISO to Pin 12 on Arduino&#xA;MOSI to Pin 13 on Arduino&#xA;VCC to 3.3V source on Arduino&#xA;GND to Arduino Ground&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The image below is a compilation of the closeup of the shield and my wiring. Not that I am also using Pin 9 in the picture. However this is used for a different portion of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IfhE9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IfhE9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that I am trying to run comes from the SdFat library. Though the Amazon page says the device can be used without this library, I prefer to have it. I am running the &lt;code&gt;SdInfo.ino&lt;/code&gt; example located in SdFat/SdFat/examples/SdInfo/. I have changed the coding so that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t SD_CHIP_SELECT = 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also tried running the &lt;code&gt;Basic.ino&lt;/code&gt; example in the TMRpcm library, located at: TMRpcm/examples/basic, but this doesn't work either. Below is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;                      // need to include the SD library&#xA;//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560&#xA;#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328, can use other pins&#xA;#include &amp;lt;TMRpcm.h&amp;gt;           //  also need to include this library...&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;TMRpcm tmrpcm;   // create an object for use in this sketch&#xA;&#xA;void setup(){&#xA;  tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc&#xA;  Serial.begin(9600);&#xA;  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:&#xA;    Serial.println(&quot;SD fail&quot;);  &#xA;    return;   // don't do anything more if not&#xA;  }&#xA;  tmrpcm.play(&quot;music&quot;); //the sound file &quot;music&quot; will play each time the arduino powers up, or is reset&#xA;}&#xA;&#xA;void loop(){  &#xA;  if(Serial.available()){    &#xA;    if(Serial.read() == 'p'){ //send the letter p over the serial monitor to start playback&#xA;      tmrpcm.play(&quot;music&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In short. My SD card does not initialize, and I cannot seem to figure out why.&lt;/p&gt;&#xA;" OwnerUserId="14220" LastEditorUserId="4628" LastEditDate="2017-12-21T18:21:35.570" LastActivityDate="2020-02-29T06:00:45.767" Title="SD card fails to initialize" Tags="|arduino-uno|shields|sd-card|tmrpcm|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17063" PostTypeId="2" ParentId="17062" CreationDate="2015-10-21T15:27:44.267" Score="5" Body="&lt;p&gt;The first thing to try is to use the 'proper' pins for the SPI:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SCK to Pin 10 on Arduino ---&amp;gt; Pin 13&#xA;CS to Pin 11 on Arduino ---&amp;gt; Pin 10&#xA;MISO to Pin 12 on Arduino ---&amp;gt; Pin 12&#xA;MOSI to Pin 13 on Arduino ---&amp;gt; Pin 11&#xA;VCC to 3.3V source on Arduino&#xA;GND to Arduino Ground&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try that first and see how you get on.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, just thought I'd mention, probably worth just following the Adafruit example word for word as I'm guessing your board is pretty much a good fit for this tutorial: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-micro-sd-breakout-board-card-tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/adafruit-micro-sd-breakout-board-card-tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;good luck getting it rockin' ;)&lt;/p&gt;&#xA;" OwnerUserId="5065" LastEditorUserId="19409" LastEditDate="2017-12-22T12:49:02.673" LastActivityDate="2017-12-22T12:49:02.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17066" PostTypeId="2" ParentId="17062" CreationDate="2015-10-21T17:21:53.507" Score="1" Body="&lt;p&gt;That breakout board includes a 3.3V regulator and level shifter.  It should be powered from 5V for proper operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as @Andology mentions: &lt;em&gt;use the correct &lt;a href=&quot;http://arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;SPI&lt;/a&gt; pins&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-21T17:21:53.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17068" PostTypeId="1" CreationDate="2015-10-21T18:08:37.750" Score="2" ViewCount="40" Body="&lt;p&gt;Ok, so i have a unit that i want to add information to the EEPROM, using the USB port, such as SSID for wifi shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then i want to disconnect the USB cable, plugin a battery and then it should run its normal loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IF usb-cable &#xA;   run_setup_loop();&#xA;ELSE&#xA;   run_main_loop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-10-21T18:08:37.750" Title="Split arduino run mode depending on active USB connection" Tags="|usb|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17072" PostTypeId="1" AcceptedAnswerId="17080" CreationDate="2015-10-21T20:08:15.867" Score="1" ViewCount="295" Body="&lt;p&gt;Complete electronics beginner here. I'm attempting to build a weighing scale with an Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm attempting to follow &lt;a href=&quot;http://www.open-electronics.org/wi-fi-body-scale-with-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;, with the shield that they use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TMFhq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TMFhq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've arranged my load cells on the scale into a Wheatstone Bridge, and I can get some readings just by taking a voltage reading from the two cells marked V+ and V-. The board has terminals that are linked to a INA125p, and the pins should give an amplified reading.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pin A1:0.96 &#xA;Pin A2:1.42 &#xA;Pin A3:5.00 &#xA;Pin A4:5.00 &#xA;Pin A5:5.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regardless of whether I have the scale wired in or not, I get these readings from the individual pins. The scales seem to be able to take power from the Arduino shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scales that I have are different from the ones in the example. From what I can figure out, the yellow cables that they reference turn their particular scale on when weight is put on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've put the wires where I take the reading into the 2 and 4 terminals on the circuit board that they have (where the tutorial references a differential signal), but again, it makes no change.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;unsolder or cut the white wire that is referred to as G3 (Wheatstone bridge mass) on the original printed circuit, extend take it to terminal 1 on the new printed circuit;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;unsolder or cut the white wire that is referred to as G2 (Wheatstone&#xA;  bridge positive) on the original printed circuit, extend take it to&#xA;  terminal 3 on the new printed circuit;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;unsolder or cut the white wire that is referred to as G1 and G4 on the&#xA;  original printed circuit, extend take it to terminal 4 and 2 on the&#xA;  new printed circuit (differential signal on the Wheatstone bridge)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've attempted lots of different combinations of cables and terminals on the new circuit, but it appears to make no difference to the readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: &#xA;Based on the tutorial and the drawing above, am I taking the readings from the correct place? Are there any things I'm obviously doing wrong with the circuit itself?&#xA;If the circuit is correct, how would I go about trying to get correct readings from the scale when I add weight to it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I apologise for the vague nature of this question, but I am a complete beginner trying to figure this out, and I am struggling to follow the tutorial. I'll try and provide any additional information that you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT - I have a Salter SAL-3003 SSSVDR08 scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each load cell has 3 cables, Red, Black and White. The red ones are the ones marked with the V+, V- etc. On the original board, they were wired in threes.&lt;/p&gt;&#xA;" OwnerUserId="14229" LastEditorUserId="14229" LastEditDate="2015-10-21T21:01:36.273" LastActivityDate="2015-10-21T22:57:47.683" Title="Using digital weighing scales with INA125p" Tags="|arduino-uno|shields|analogread|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17074" PostTypeId="2" ParentId="16542" CreationDate="2015-10-21T21:35:07.557" Score="1" Body="&lt;p&gt;I am assuming since you did not state anything differently you simply want to turn it on or off and possibly PWM to control speed of the motor.  By far the easiest way is to simply use a N-Channel logic level MOSFET.  Connect the Arduino pin of your choice through a 51 (1) ohm resistor to the gate of the MOSFET, also Connect a 10K (2) resistor from the same microprocessor (Arduino) pin to ground.  The &quot;Ground&quot; low side of the 40V power supply needs to be connected to the low side of the Arduino.  The low side of the 40V power supply must be connected to the source of the MOSFET.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the motor from the plus side of the 40V power supply (this will be removed for testing) to the Drain of the N-Channel MOSFET. Last and very important place a diode rated at least 2 amps at 60 volts from the positive side of the poser supply (cathode of the diode, with the band) to the Drain of the MOSFET (anode, no band).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Carefully check your wiring; if it is ok you are ready to test it.  The safest way is to use a led with a 510 ohm in series with the cathode on the Arduino +5 with the positive side of the 40v power supply disconnected.  The anode side connects to the drain of the MOSFET.  When the motor is turned on the LED will light, if it does not reverse polarity of the LED.  As tempting as it might be do not leave the LED connected to the Arduino when the motor is connected.  Up the value of the resistor to about 5.6K and connect it across the motor, it will light when the motor is on.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This helps dampen oscillations&lt;/li&gt;&#xA;&lt;li&gt;Since the Arduino initializes with all pins as inputs this can drift high, this solves that potential problem which would cause the MOSFET to turn on.&lt;/li&gt;&#xA;&lt;li&gt;For the MOSFET you need at least 60V with a 10A rating.  This should work with a small heat sink.  If you go to a higher amp rating on the MOSFET it will operate cooler.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Output of Arduino goes to 10K to ground and to a 51 ohm resistor (1/8 W or larger)&#xA;The other side of the resistor goes to the gate of the MOSFET.&#xA;Ground of the motor power supply, the Arduino and the Source of the MOSFET are connected together.  The 2A diode is connected with the cathode (no band) to the drain of the MOSFET, the cathode (band) is connected to the +40V.  The motor connects from the +40 to the Drain of the MOSFET, reversing the leads will probably reverse motor direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-21T21:35:07.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17077" PostTypeId="2" ParentId="16176" CreationDate="2015-10-21T22:01:00.850" Score="2" Body="&lt;p&gt;This is not a simple chip to use.  These parts of the data sheet may help you understand what is happening.  It is internally an analog device and needs clean power.  I would highly recommend you download the Allegro data sheet, it has a lot of information that will help you.  Below is a short section of the data sheet, The first paragraph should give you a hint that the output voltage will be about 2.5V with a 5V unipolar power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Quiescent output voltage (VIOUT(Q)). The output of the device&#xA;when the primary current is zero. For a unipolar supply voltage,&#xA;it nominally remains at VCC⁄ 2. Thus, VCC = 5 V translates into&#xA;VIOUT(Q) = 2.5 V. Variation in VIOUT(Q) can be attributed to the&#xA;resolution of the Allegro linear IC quiescent voltage trim and&#xA;thermal drift.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Electrical offset voltage (VOE). The deviation of the device output&#xA;from its ideal quiescent value of VCC / 2 due to nonmagnetic&#xA;causes. To convert this voltage to amperes, divide by the device&#xA;sensitivity, Sens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accuracy (ETOT). The accuracy represents the maximum deviation&#xA;of the actual output from its ideal value. This is also known&#xA;as the total output error. The accuracy is illustrated graphically in&#xA;the output voltage versus current chart at right.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize this does not answer your question but it does give you a good starting point to resolve your problem.  Hopefully you or a buddy has some analog experience, that will help a lot.  Oh Yes clean power supplies are imperative for this to work.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-21T22:01:00.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17079" PostTypeId="1" CreationDate="2015-10-21T22:46:32.487" Score="0" ViewCount="159" Body="&lt;p&gt;How would you connect multiple HC-SRO4 ultrasonic sensors to one arduino uno? As of now, I have a bunch of jumper cables, 3 u.s sensors, and one arduino uno board. How would one hook up 3 sensors? A schematic would be excellent!&lt;/p&gt;&#xA;" OwnerUserId="13691" LastActivityDate="2016-01-20T10:07:26.160" Title="Multiple sensor connection help" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17080" PostTypeId="2" ParentId="17072" CreationDate="2015-10-21T22:57:47.683" Score="2" Body="&lt;p&gt;Fixed (to some extent)! Faulty connection between the INA125p and the plint it was sitting in. I refitted it and i'm now getting varied readings with the scales, but that's to be expected with the noise the INA125p generates.&lt;/p&gt;&#xA;" OwnerUserId="14229" LastActivityDate="2015-10-21T22:57:47.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17081" PostTypeId="2" ParentId="16237" CreationDate="2015-10-21T23:00:06.527" Score="1" Body="&lt;p&gt;Actually, this is dependent on the datasheet. Assuming it's 7 segment + dot, it will require 8 independent pins to control each of the segment. All of segments are connected to a common anode/cathode which can be connected to a pullup/pulldown. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we have 4 digit, that means we need 4*8=32 pins, which is a lot for any microcontroller. However, if you map out the internal circuit, you'll find that the segments are multiplexed. (You can do this by touching the pins with a wire connected to a pullup resistor, and another wire connected to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, you'll find that all the segment pins are multiplexed together in such a way that if all anodes/cathodes are enabled, all of the digits show the same display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how then can we make use of this information? Here's an idea:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about turning on each of the digits one at a time (by controlling the common anode/cathode), but doing it quickly? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example sequence would be as follows: &#xA;Set the segments for digit 1, enable the corresponding common anode/cathode for 5ms. Turn off.&#xA;Set the segments for digit 2, enable the corresponding common anode/cathode for 5ms. Turn off.&#xA;Do the same for digit 3 and then 4.&#xA;Repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Controlling in this manner means you only need 8+4 pins=12 which is available on an arduino uno. Refreshing at 4*5=20ms will hardly be visible to our human perception, thanks to persistence of vision. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My answer is really just a starting point. If you spend some time, you can try to put in other smarts which are suited for your application, using even less pins. You should try this as an exercise. ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &#xA;As a precaution, it's important to limit the current running through each of the LED segments so that they can live a long and happy life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming a forward voltage of 2V, adding a 1k resistor at the common anode limits the current to 3mA. This means adding resistors for all 4 anodes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same could work for common cathode displays, as long as the reverse breakdown voltage is not exceeded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As with all things you find on the net, don't take my word for it. You should do the maths to check. &lt;/p&gt;&#xA;" OwnerUserId="7282" LastEditorUserId="7282" LastEditDate="2015-10-22T08:55:51.487" LastActivityDate="2015-10-22T08:55:51.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17083" PostTypeId="1" CreationDate="2015-10-22T04:12:51.030" Score="1" ViewCount="1065" Body="&lt;p&gt;So, when I searched for ways to drive AC circuits from Arduino, everyone suggested relays with a transistor switching circuit to channel an external 5V. I was wondering what would happen if I used an optocoupler like 4n35 to drive an AC circuit. Will the phototransistor inside the chip burn out?&lt;/p&gt;&#xA;" OwnerUserId="14022" LastActivityDate="2017-03-03T15:49:04.010" Title="Why can't I use an optocoupler to drive an AC circuit using the arduino digital pins?" Tags="|arduino-uno|relay|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17084" PostTypeId="2" ParentId="17083" CreationDate="2015-10-22T05:05:37.620" Score="1" Body="&lt;p&gt;No. A 4N35 will switch 150mA at 30V DC. See &lt;a href=&quot;http://elinux.org/RPi_GPIO_Interface_Circuits&quot; rel=&quot;nofollow&quot;&gt;http://elinux.org/RPi_GPIO_Interface_Circuits&lt;/a&gt; for more detail. If you are proposing to switch 110/240V AC there are safety issues. You should look at available commercial modules.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-10-22T05:05:37.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17086" PostTypeId="2" ParentId="17079" CreationDate="2015-10-22T09:16:09.173" Score="1" Body="&lt;p&gt;It depends on what you want to do overall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the &lt;a href=&quot;https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE/edit&quot; rel=&quot;nofollow&quot;&gt;HC-SR04&lt;/a&gt; works roughly like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you generate a strobe on a pin for a minimum amount of time, and this strobe is understood by the sensor as &quot;emit the ultrasound signal&quot;&lt;/li&gt;&#xA;&lt;li&gt;then you somehow (more on this later) measure how much time passed between your strobe and a change of level on another pin from the sensor - this is how the sensor notifies you that there was an echo and it has returned.&lt;/li&gt;&#xA;&lt;li&gt;finally, you convert the time measured into distance, using a conversion algo (typically multiplying by a certain factor) that is specific to the sensor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Mostly the problem revolves around point #2: how to measure the time elapsed between command (strobe) and answer (change of level).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have various options, each with pros and cons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;busy looping: it's easy to implement, very straightforward and works right away. The problem is that your arduino will do just that.&lt;/li&gt;&#xA;&lt;li&gt;polling: it's a less aggressive version of polling, where you check the values every now and then. It lets you do more, but the drawback is that in the worst case the line changes level right after you have checked it, so it will be noticed only at the following iteration. The period used for checking is the maximum error you will get.&lt;/li&gt;&#xA;&lt;li&gt;GPIO interrupt driven: this is harder but lets your arduino do many other things, while not loosing precision (I'll detail it separately)&lt;/li&gt;&#xA;&lt;li&gt;HW backed: the AVR on UNO has the ability to capture events: basically there is a timer running that will stop when it gets triggered by a certain event (ex: the change of pin level cause by the echo). It is very precise, but you are limited by the number of HW blocks available on the AVR (3 iirc).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now about the sub-cases of the GPIO interrupt-driven solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;EXT based: the ATMega328p present on the UNO has what are called external interrupt sources, which is a fancy way to say that if you configure correctly a pin, the processor will notice when the pin voltage level changes and do something about it (in your case, take a time measurement) - this is quite generic solution, but unfortunately it works only on 2 pins, so you are out of lack with your 3 sensors, unless you implement some scheme where you multiplex 2 or more sensors on only one pin.&lt;/li&gt;&#xA;&lt;li&gt;Pin-change-interrupt based: on AVR most of the PINS are grouped in ports. Each port contains maximum 8 pins and is labelled with a letter (A, B, C, ..). The way this interrupt works is roughly like the EXT type, but with a catch: you will get an interrupt whenever &lt;em&gt;any&lt;/em&gt; of the pins that you have enabled on a certain port will change. In your case you could allocate only one sensor on a certain port, so that it would be obvious that if you get an interrupt for that port, it will be because of that sensor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So now you can see why I said &quot;it depends&quot;. If all you want to do is to get the information about proximity, you can go with busy-looping/polling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you decide later on to do more on the same arduino, be aware that you might have to come back to the implementation of the ultrasonic sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there is a &lt;a href=&quot;http://playground.arduino.cc/Code/NewPing&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; for this, but its implementation will fall into one of the cases i mentioned before, so be aware that the same catch applies: at some point you might want to do something that conflicts with the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other points worth mentioning, that you should consider in your design (at least experiment with them):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;orientation of the sensors: will they interfere with each other?&lt;/li&gt;&#xA;&lt;li&gt;timing: do you need/want to activate them all simultaneously or do you prefer to have them activated in sequence?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-22T09:22:18.630" LastActivityDate="2015-10-22T09:22:18.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17088" PostTypeId="2" ParentId="16656" CreationDate="2015-10-22T11:41:01.910" Score="0" Body="&lt;p&gt;From my personal experience, you should give some init time to the rfid reader to init. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to use a digital output to control the chip reset, and give it some milliseconds to init. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a similar behavior with a rfid reader and the reason was this I just told. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck! &lt;/p&gt;&#xA;" OwnerUserId="14238" LastActivityDate="2015-10-22T11:41:01.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17089" PostTypeId="1" CreationDate="2015-10-22T11:55:19.010" Score="3" ViewCount="1068" Body="&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building a small battery powered counting device. As with many other projects like this, saving power is critical. I am therefore trying to utilise the sleep mode wherever possible. This is using a 328P as a standalone MCU running on the 1MHz internal clock&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Hall Effect sensor I am using outputs Vcc when nothing is detected, and Ground when something is detected. It therefore seems well suited to being used as a trigger for an interrupt to wake up the 328P from sleep (so that I don't even need to use a watchdog timer.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is an excerpt from my code. This code does put the processor into sleep as desired. However, from testing I have discovered that the device will not sleep when the magnet is left near the sensor, as its output stays LOW. As I only want to detect pulses of a moving piece of metal, this is wasting power. I only want to wake up when it is initially detected on each cycle.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sleepLoop()&#xA;{&#xA;  Serial.print(&quot;S&quot;);&#xA;&#xA;  delay(5);   //scales to 40ms&#xA;&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;  sleep_enable();&#xA;  noInterrupts();&#xA;&#xA;  attachInterrupt(digitalPinToInterrupt(countInterruptPin), sleepInterrupt, LOW);&#xA;&#xA;  interrupts();&#xA;  sleep_cpu();&#xA;&#xA;  //The program will continue from here.&#xA;&#xA;  //First thing to do is disable sleep.&#xA;  sleep_disable();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I therefore changed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;attachInterrupt(digitalPinToInterrupt(countInterruptPin), sleepInterrupt, LOW);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(digitalPinToInterrupt(countInterruptPin), sleepInterrupt, FALLING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PROBLEM&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my processor never goes to sleep. For debugging I have put in a serial print at the start of the loop so that I know it has entered this loop of code. Whether &lt;code&gt;LOW&lt;/code&gt; or &lt;code&gt;FALLING&lt;/code&gt; is used the 'S' is printed. I only know it is not sleeping because I am measuring the current flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought the sensor may be going LOW long enough to keep the device awake, but not long enough to register as a count (as I have a debounce in there) so I have checked the output from the sensor with an oscilloscope in case it was momentarily going &lt;code&gt;LOW&lt;/code&gt;, but I couldn't see any sign of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The findings from the oscilloscope make me feel like there is something about the interrupt function that I am overlooking. Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="12133" LastEditorUserId="9962" LastEditDate="2016-02-21T09:06:25.140" LastActivityDate="2017-02-15T21:47:35.640" Title="Trouble with sleep mode and interrupts" Tags="|c++|interrupt|sleep|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17090" PostTypeId="2" ParentId="13736" CreationDate="2015-10-22T11:58:55.730" Score="1" Body="&lt;p&gt;You could also implement a readLine routine, similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void _readLine(File f, char *line)&#xA;{&#xA;    boolean cr_found = false;&#xA;    int p = 0;&#xA;    while (f.available()) {&#xA;        char b = f.read();&#xA;        if(b!='\r' &amp;amp;&amp;amp; b!='\n')&#xA;            line[p++] = b;&#xA;&#xA;        if(b == '\r') cr_found = true;&#xA;        if((b == '\n') &amp;amp;&amp;amp; cr_found) break;&#xA;    }&#xA;    line[p] = '\0';&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And read the SD file line by line, processing each one of them by its own.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[32];&#xA;&#xA;while(dataFile.available()) {&#xA;    _readLine(dataFile, buffer);&#xA;    // do something with buffer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14238" LastActivityDate="2015-10-22T11:58:55.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17092" PostTypeId="1" AcceptedAnswerId="17101" CreationDate="2015-10-22T12:26:43.883" Score="2" ViewCount="8668" Body="&lt;p&gt;Currently working on understanding shift registers and traing to display binary number from 65535 to 0 on a 16 LED's.  Below you can see schematics I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5X4Y1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5X4Y1.png&quot; alt=&quot;Used topology&quot;&gt;&lt;/a&gt;&#xA;The code I am using is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int latchPin = 8;&#xA;int clockPin = 12;&#xA;int dataPin = 11;&#xA;int numberToDisplay=65535;&#xA;&#xA;void setup() {&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    digitalWrite(latchPin, LOW);&#xA;&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);  &#xA;&#xA;    digitalWrite(latchPin, HIGH);&#xA;    delay(500);&#xA;  }&#xA;&#xA;void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)&#xA;{&#xA;    uint8_t i;&#xA;&#xA;    for (i = 0; i &amp;lt; 16; i++)  {&#xA;        if (bitOrder == LSBFIRST)&#xA;            digitalWrite(dataPin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; i)));&#xA;        else    &#xA;            digitalWrite(dataPin, !!(val &amp;amp; (1 &amp;lt;&amp;lt; (15 - i))));&#xA;&#xA;        digitalWrite(clockPin, HIGH);&#xA;        digitalWrite(clockPin, LOW);        &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is when I change numberToDisplay from 0 to 225, everything works and LEDs are lighted correspondingly (if numberToDisplay=225 all red lights are on). But if numbers are bigger than 225 everything just stops working and nothing lights up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="8715" LastActivityDate="2017-09-17T20:44:31.327" Title="Multiple shift registers, 16 bit numbers" Tags="|arduino-uno|shift-register|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17093" PostTypeId="2" ParentId="17092" CreationDate="2015-10-22T12:45:39.923" Score="1" Body="&lt;p&gt;notice the &lt;code&gt;uint8_t val&lt;/code&gt;. You are truncating the 16-bit number back to 8 bit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way of fixing this is to split the 16-bit number before calling shiftOut.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shiftOut(dataPin, clockPin, MSBFIRST, highByte(numberToDisplay));  &#xA;shiftOut(dataPin, clockPin, MSBFIRST, lowByte(numberToDisplay));  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-22T12:45:39.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17094" PostTypeId="2" ParentId="9359" CreationDate="2015-10-22T13:21:49.457" Score="2" Body="&lt;p&gt;I would say that this may be related to the analog reference. Try &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;AnalogReference&lt;/a&gt; and see if it helps.&lt;/p&gt;&#xA;" OwnerUserId="14238" LastActivityDate="2015-10-22T13:21:49.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17096" PostTypeId="2" ParentId="17092" CreationDate="2015-10-22T14:12:56.073" Score="1" Body="&lt;p&gt;I agree with Gerben. But Byte datatype will not help you, since &lt;a href=&quot;https://www.arduino.cc/en/Reference/Byte&quot; rel=&quot;nofollow&quot;&gt;Byte&lt;/a&gt; type is an unsigned 8-bit type (the same as uint8_t). Why don't you try this header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint16_t val)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or follow Gerbens idea, just using out of the box &lt;a href=&quot;https://www.arduino.cc/en/Reference/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;shiftOut&lt;/a&gt; routine. It shifts 8-bit variables, so you shouldn't need to re-implement the routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards.&lt;/p&gt;&#xA;" OwnerUserId="14238" LastActivityDate="2015-10-22T14:12:56.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17097" PostTypeId="2" ParentId="3908" CreationDate="2015-10-22T14:22:16.317" Score="3" Body="&lt;p&gt;Using the latest Teensyduino distribution as of this writing, 1.25, you have to uncomment the higher overclocking options in the &lt;code&gt;boards.txt&lt;/code&gt; file, located here in my install-&#xA;&lt;code&gt;/hardware/teensy/avr/boards.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The options look like this, just remove the # symbol-  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#uncomment these if you want to try faster overclocking&#xA;#teensy31.menu.speed.168opt=168 MHz optimized (overclock)&#xA;#teensy31.menu.speed.144opt=144 MHz optimized (overclock)&#xA;#teensy31.menu.speed.120opt=120 MHz optimized (overclock)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14245" LastActivityDate="2015-10-22T14:22:16.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17099" PostTypeId="1" CreationDate="2015-10-22T14:52:11.827" Score="0" ViewCount="2532" Body="&lt;p&gt;I am a newbie and working on a kind of WiFi-controlled vehicle (car or maybe hovercraft later). My ESP8266 repeats the commands I send. For example, AT gives AT, AT+GWR gives AT+GWR, dabdabik gives dabdabik, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino Uno to send commands, as I don't have FTDI related stuff (USB to Serial Converter). I use AA cells for power supply (1.5v*2=3v). I don't even have 3.3 volt direct supply. I am using the Arduino IDE Serial Monitor. I connected the Arduino's TX to the ESP8266's RX via a voltage divider (1.66K Ohm(TX) and 1.66K Ohm (GND)-&gt;3.29 Ohm(RX)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My connections are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESP8266----------------Arduino Uno&#xA;TX---Voltage divider---RX(d0)&#xA;RX---------------------TX(d1)&#xA;GND--------------------GND&#xA;VCC-------**3V**&#xA;CH_PD-----**3V**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes it gives garbage otherwise it just repeats (weird). Garbage ONLY changes if baud rate is changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I flashed it (it seems) with the AT 9.5.2 firmware. Flashing works rarely ONLY with TX to TX connected directly without a voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried as much as I could after searching the web and ESP8266 forum but still couldn't solve problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help. I am a student in a small town (Manipal) in Southern India so no good stores nearby and I don't want to buy FTDI or anything online. I am a bit new to electronics, but I am a C++ programmer and student.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I noticed after some resets that it gives full garbage to longer commands most of the time, whereas two-letter commands give partial garbage. For example AT gives IT,TT,OT,etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no coding.&#xA;I am sending the commands directly via Arduino hardware serial pins (rx,tx) and a bare minimum program.&lt;/p&gt;&#xA;" OwnerUserId="14248" LastEditorUserId="4628" LastEditDate="2016-01-08T12:11:58.097" LastActivityDate="2017-08-11T06:08:58.067" Title="ESP8266 returns whatever is sent through Arduino serial" Tags="|arduino-uno|serial|wifi|esp8266|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17101" PostTypeId="2" ParentId="17092" CreationDate="2015-10-22T17:29:07.310" Score="2" Body="&lt;p&gt;Your problem is entirely that you declare val to be uint8_t, instead of uint16_t. You are truncating your data to 8 bits before displaying it. One other note, the 74HC595 has a maximum total drive current of 50mA. Your circuit will draw around 90mA for each of the 74HC595's if all of the LEDs are on. You may want to change the resistors to something bigger (510 Ohm, for example) to avoid this problem. Of course that will make the LEDs dimmer, so it's a tradeoff. Here's &lt;a href=&quot;https://123d.circuits.io/circuits/1142474&quot; rel=&quot;nofollow noreferrer&quot;&gt;your project in 123D Circuits&lt;/a&gt;. You can simulate it in the browser and look at the code running in the Arduino there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QxbeP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QxbeP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14082" LastEditorUserId="14082" LastEditDate="2015-10-22T22:47:47.603" LastActivityDate="2015-10-22T22:47:47.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17104" PostTypeId="1" AcceptedAnswerId="17108" CreationDate="2015-10-22T19:23:31.037" Score="0" ViewCount="462" Body="&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to Arduino world, and I like to buy a board. I am a bit confused how Arduino products are being sold. Coming from Raspberry world, it seems that I don't know what actually Arduino is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to understand what is it that this product offers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KfpYB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KfpYB.png&quot; alt=&quot;Arduino UNO R3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why it says &quot;&lt;strong&gt;For&lt;/strong&gt; Arduino UNO R3&quot;? 2. Isn't it actually an &quot;Arduino UNO R3&quot;? So why it says &quot;For&quot;?&lt;/li&gt;&#xA;&lt;li&gt;What are MEGA328P and CH340? Does &quot;Arduino UNO R3&quot; comes with other chipsets?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14252" LastActivityDate="2015-11-11T09:37:57.390" Title="Trying to understand Arduino products" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17107" PostTypeId="2" ParentId="17104" CreationDate="2015-10-22T20:18:27.370" Score="1" Body="&lt;p&gt;The board in the picture is not an official Arduino board. It is a clone.  You will note that in the picture the board does not say &quot;Arduino&quot;  It may be 100% compatible or it may not, you have to decide if the low price is worth it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want an official board you should check either &lt;a href=&quot;http://arduino.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.cc&lt;/a&gt; or &lt;a href=&quot;http://arduino.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino.org&lt;/a&gt; to find official distributors. (see &lt;a href=&quot;https://arduino.stackexchange.com/questions/11824/difference-between-arduino-cc-and-arduino-org&quot;&gt;this question&lt;/a&gt; for information about why there is both arduino.cc and arduino.org).&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-10-22T20:18:27.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17108" PostTypeId="2" ParentId="17104" CreationDate="2015-10-22T20:20:41.047" Score="4" Body="&lt;p&gt;It sounds to me like an Arduino Uno &lt;strong&gt;clone&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why it says &quot;For Arduino UNO R3&quot;? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would read that as &quot;For Arduino UNO R3 &lt;strong&gt;projects&lt;/strong&gt;&quot; (ie. Uno-compatible).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Isn't it actually an &quot;Arduino UNO R3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it's a clone. Or not really a clone (see below) because they used different hardware. It is compatible with the Uno in most respects.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What are MEGA328P?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is the &lt;strong&gt;main&lt;/strong&gt; chip on the board (actually an Atmega328P).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and CH340?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They have saved money by using a CH340 USB-to-serial chip instead of the Atmega16U2 used on genuine Uno boards. You may need to install a different driver to make that work. I disagree with the other answer(s) that this is a separate board or chip. It is clear from the photo of the chip near the USB socket that it is a CH340 chip there. See, for example &lt;a href=&quot;https://hackaday.com/tag/ch340/&quot; rel=&quot;nofollow&quot;&gt;https://hackaday.com/tag/ch340/&lt;/a&gt; from which I quote:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The cheapest USB to serial chip on the market appears to be the CH340G, available for 20-40 cents apiece from the usual retailers. There is, however, almost no English documentation, and the datasheet for the CH340 family doesn’t include this chip&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They used it because it is cheap.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does &quot;Arduino UNO R3&quot; comes with other chipsets?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes the &lt;strong&gt;genuine&lt;/strong&gt; one comes with an Atmega328P (main processor) and Atmega16U2 (USB interface).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Having said all that, the Uno is a good all-rounder starting board to get going with Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that they are using the SMD (surface mounted) main processor chip. If you fry it you need to replace the whole board, not just the chip. However the entire board is quite cheap. :)&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-22T20:20:41.047" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17110" PostTypeId="1" CreationDate="2015-10-22T21:06:52.917" Score="1" ViewCount="223" Body="&lt;p&gt;I want to make a water screen. I will create character with solenoid valve. Sometimes sequential valve will pass to water, sometimes not pass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I will create some shape or character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how can I create this character with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any good idea ? Can you help me ?&lt;/p&gt;&#xA;" OwnerUserId="14255" LastEditorUserId="3638" LastEditDate="2015-10-24T20:27:17.887" LastActivityDate="2015-10-24T20:27:17.887" Title="How to Create a water screen with solenoid valve in arduino" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17111" PostTypeId="2" ParentId="17060" CreationDate="2015-10-22T21:16:00.000" Score="1" Body="&lt;p&gt;This part looks weird:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendMP3Command(String MP3File, uint8_t Command) {      &#xA;  char *TextArray[MaxMP3Name];&#xA;  MP3File.toCharArray(TextArray, MaxMP3Name);&#xA;  txMP3.Filename = TextArray;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have made an array of 13 pointers to strings. This is not what you want. You want the file name to end up into &lt;code&gt;txMP3.Filename&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be closer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendMP3Command(String MP3File, uint8_t Command) {      &#xA; MP3File.toCharArray(txMP3.Filename, MaxMP3Name);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally I wouldn't be using the &lt;code&gt;String&lt;/code&gt; class at all, but that should be better.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void onReceiveEvent(int numbytes){&#xA;  if(numbytes == 16){ &#xA;    I2C_readAnything(RXdata);      &#xA;    newData = 2;    &#xA;  }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are you &lt;strong&gt;sure&lt;/strong&gt; it's 16 bytes? What if you change the struct? Let the compiler do the thinking for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void onReceiveEvent(int numbytes){&#xA;  if(numbytes == sizeof (RXdata)){ &#xA;    I2C_readAnything(RXdata);      &#xA;    newData = 2;    &#xA;  }   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How you've recommended it is actually how I tried it originally (I don't like using Strings either) - which just ends up giving me the error &quot;invalid conversion from 'volatile char*' to 'const char*' [-fpermissive]&quot; (on the Slave) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This minimal example compiles OK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;I2C_Anything.h&amp;gt;&#xA;const uint8_t MaxMP3Name = 13;&#xA;struct RECEIVE_DATA_STRUCTURE{&#xA;  char Filename[MaxMP3Name];&#xA;  uint8_t VolLeft;&#xA;  uint8_t VolRight;&#xA;  uint8_t Command;   &#xA;};&#xA;&#xA;volatile RECEIVE_DATA_STRUCTURE RXdata;&#xA;volatile uint8_t newData; // flag to detect I2C activity&#xA;&#xA;void onReceiveEvent(int numbytes){&#xA;  if(numbytes == sizeof RXdata){ &#xA;    I2C_readAnything(RXdata);      &#xA;    newData = 2;    &#xA;  }   &#xA;}&#xA;&#xA;void setup() &#xA;{&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-10-24T20:48:36.147" LastActivityDate="2015-10-24T20:48:36.147" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17112" PostTypeId="2" ParentId="17083" CreationDate="2015-10-22T23:26:12.343" Score="1" Body="&lt;p&gt;Normally Opto couplers like a 4N35 were not designed to drive an application load.  Typically they are used to trigger another device such as a SCR or Triac.  There is a vidio I would recommend you watch, it gives some information and the comments are good.  Give this a try:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=FVef6f2_Si8&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=FVef6f2_Si8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-22T23:26:12.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17115" PostTypeId="2" ParentId="16429" CreationDate="2015-10-22T23:56:07.220" Score="1" Body="&lt;p&gt;Yes but you want something much faster then the Arduino, normally it is in the 96k~48k bps range.  Try this link, they make a lot of great parts and the bulk of what you have to do is control software.  You can let the chip do the grunt work (analog) and transfer thee data to where ever you want.  Some of the chips will record for 300 seconds plus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.aplusinc.com.tw/exec/product.php?lg=E&amp;amp;mod=show&amp;amp;cid=43&amp;amp;pid=aPR33A3&quot; rel=&quot;nofollow&quot;&gt;http://www.aplusinc.com.tw/exec/product.php?lg=E&amp;amp;mod=show&amp;amp;cid=43&amp;amp;pid=aPR33A3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used there parts they work great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have fun,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-22T23:56:07.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17116" PostTypeId="2" ParentId="16301" CreationDate="2015-10-23T00:22:54.277" Score="1" Body="&lt;p&gt;I would suggest powering it from the 12V input and monitor the 12V with a power supply monitoring chip or circuit which will send an interrupt to your system when the voltage drops to whatever voltage you design it for. This can be accomplished with a few resistors and a comparator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your hold up time will be controlled by the amount of capacitance on the 12V side.  When the interrupt is tripped write the value to EEPROM and then shut down.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analog input is a good sounding idea but there is a lot of latency between the time the voltage starts to fail and is detected.  The hardware interrupt will be much faster giving you more time to save your counter and the additional capacitance on the 12V side will give you a lot more time then back feeding through the GPIO pins..&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-23T00:22:54.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17118" PostTypeId="2" ParentId="14178" CreationDate="2015-10-23T01:10:47.533" Score="1" Body="&lt;p&gt;It sounds like you are trying to make a digital to analog converter driving some type of load.  Look at this link: &lt;a href=&quot;http://emesystems.com/BS2PWM.htm&quot; rel=&quot;nofollow&quot;&gt;http://emesystems.com/BS2PWM.htm&lt;/a&gt;&#xA;It will give you a start. Please note they use an opamp as a buffer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This 'buffer' has a very high input impedance and a low output impedance.  It can drive from a few mills to over an amp depending on the opamp chosen.  Additional circuitry can get you into thousands of amps if desired.  The schematic is a 2 pole filter originally designed for the Stamp microcontroller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filter soothes it out but adds a delay on the final output value (settling time).  The greater the filter capactance the lower the ripple and the slower the response.  You can add another pole to filter if you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a bit of information from an old semiconductor guy absolute ratings are just that.  If you exceed them even for a few nanoseconds you can be sure you damaged the device, you just do not know when it will fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen a lot of microcontrollers damaged because of capacitors connected to the pins, power excluded, doesn't matter if the pin is input or output.  When the power supply collapses it will inject current into the microprocessor substrate possibly damaging it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="8" LastEditDate="2015-10-23T16:01:08.180" LastActivityDate="2015-10-23T16:01:08.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17119" PostTypeId="2" ParentId="13993" CreationDate="2015-10-23T01:20:17.197" Score="0" Body="&lt;p&gt;Everything looks good, however Try a different relay, and double check your AC side and be sure the bulb voltage is correct for the AC and the bulb is OK.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have a power shortage from your USB or however you are powering it.  If you can monitor the 5VDC and be sure it is stable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="8" LastEditDate="2015-10-23T16:00:40.037" LastActivityDate="2015-10-23T16:00:40.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17120" PostTypeId="2" ParentId="13485" CreationDate="2015-10-23T01:31:23.833" Score="0" Body="&lt;p&gt;Consider one of the many I2C I/O boards (search for i2c expander on eBay) that can be purchased for a few bucks.  They are also available from many of the people that support Arduino.   It then only requires 2 pins from the Arduino for up to 8 external devices which can have from 8, 16 and sometimes more I/O per board.  They can be used as input or output.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also operate several displays on the same two pins as the I/O.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have fun&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="8" LastEditDate="2015-10-23T16:01:19.627" LastActivityDate="2015-10-23T16:01:19.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17121" PostTypeId="2" ParentId="15837" CreationDate="2015-10-23T02:00:12.037" Score="1" Body="&lt;p&gt;It turns out the problem is a fairly common one - Actiontec wireless access points break this way when set to Both, not AES - see &lt;a href=&quot;https://superuser.com/questions/522781/unable-to-ssh-from-any-wireless-ip-to-another-wireless-ip-on-home-network&quot;&gt;https://superuser.com/questions/522781/unable-to-ssh-from-any-wireless-ip-to-another-wireless-ip-on-home-network&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently on other routers this bug is marked as a feature, &quot;Wireless Isolation&quot; or something.&lt;/p&gt;&#xA;" OwnerUserId="10780" LastEditorUserId="-1" LastEditDate="2017-03-20T10:18:34.487" LastActivityDate="2015-10-23T02:00:12.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17122" PostTypeId="2" ParentId="17022" CreationDate="2015-10-23T02:20:45.273" Score="4" Body="&lt;p&gt;Let us look as some basic's, these seem to be the basis of a lot of questions:&lt;/p&gt;&#xA;&lt;p&gt;A capacitor when power is switched on draws a huge amount of current that tapers off as it gets charged. This curve is also called the RC time constant (this is close but not exact &amp;quot;&lt;a href=&quot;http://www.electronics-tutorials.ws/rc/rc_1.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.electronics-tutorials.ws/rc/rc_1.html&lt;/a&gt;&amp;quot; will give a better explanation).&lt;/p&gt;&#xA;&lt;p&gt;When switching off a capacitor discharges at an exponential rate (RC time constant) depending on the value, charge voltage and the load.  This makes them good for holding power for a short time when the power fails.&lt;/p&gt;&#xA;&lt;p&gt;An Inductor draws nothing when first switched on but the current increases exponentially until its voltage reaches the supply voltage.&lt;/p&gt;&#xA;&lt;p&gt;When switched off the inductive field in the inductor collapse causing the polarity to reverse.  The voltage will rise unlimited until typically something externally limits it. The faster it is turned off the quicker the rise time and voltage.  Energy will cease to flow when the inductive charge is dissipated.  Guess where this current goes when the inductive load such as a relay is connected to a port pin?&lt;/p&gt;&#xA;&lt;p&gt;For this reason you need to put a diode (commonly called a fly wheel diode) across the inductive load.  Google for: &amp;quot;inductor/capacitor charge curve&amp;quot; you will find a lot of nice graphs explaining this. This diode is not necessary if you use an appropriately rated MOSFET (UIS). The UIS (Unclamped Inductive Spike) information is in the MOSFET data sheet.  If you look at the circuit it has the cathode + connected to the most positive side of the power supply.  In this configuration it will not conduct unless the voltage is reversed (when the inductive load is switched off).&lt;/p&gt;&#xA;&lt;p&gt;Another common misconception is you can load a microprocessor I/O to the maximum. This is bad design. They give you a maximum per pin, per port and for the chip.  At room temperature you will probably get away with it for a while.&lt;/p&gt;&#xA;&lt;p&gt;Let us assume we have a port with a 40mA load.  The output is 0.005 from the power rail.  Using Ohm’s law we are dissipating 20 milliwatts of power on one pin. At this rate of loading it does not take long to over heat the device because of internal power dissipation.&lt;/p&gt;&#xA;&lt;p&gt;When the output pin is changing state it draws more current because it has to charge or discharge its internal and the external capacitance, ‘more heat’, more speed ‘more heat’.&lt;/p&gt;&#xA;&lt;p&gt;If you look some of the specs will give you a maximum temperature, it is for the junction on the die, not the case temperature.  Plastic is a poor conductor so heat sinking the package does not do a lot.  Now consider this along with the ambient temperature.  The ratings are given typically with the device at 25C, guess what happens when it gets warmer.&lt;/p&gt;&#xA;&lt;p&gt;Have fun,&lt;/p&gt;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="19409" LastEditDate="2021-05-31T13:26:19.767" LastActivityDate="2021-05-31T13:26:19.767" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17123" PostTypeId="1" CreationDate="2015-10-23T04:02:30.983" Score="0" ViewCount="119" Body="&lt;p&gt;I have a question concerning the LM35 sensor: if I'm not too concerned about accuracy (I don't mind having 2 or more degrees off), is it possible to use the LM35 sensor at higher temperatures than the normal range? The project that I'm thinking of using this sensor, temperatures should reach 200 degrees, maximum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="14259" LastActivityDate="2015-10-23T09:56:45.297" Title="LM35 at higher temperatures" Tags="|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17124" PostTypeId="2" ParentId="17110" CreationDate="2015-10-23T06:03:34.283" Score="2" Body="&lt;p&gt;You can refer to &lt;a href=&quot;https://cmosgr.wordpress.com/2013/10/04/electric-solenoid-valve/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; for the generic actuation (iow Arduino board + relays shield + power supply for the valves), but that leaves one problem open: timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To draw something on a wall of water, you need to make sure that the water flows with a known, constant speed (unless your wall is very tall, I would ignore the effect of gravity, if the initial speed is high enough).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe it can be achieved without this extra step, but to play it safe, I'd also add a pump that feeds all the valves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will ensure that you will have a known pressure/speed of the water, thus being able to calculate the timing of the valves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use one of the relays to control also the pump.&#xA;Notice also that most likely an arduino UNO/Nano or equivalent will not be sufficient, as you will get relatively few lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ArduinoMega2560 or DUE have far more GPIOs.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-23T06:13:09.150" LastActivityDate="2015-10-23T06:13:09.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17125" PostTypeId="1" CreationDate="2015-10-23T09:30:29.037" Score="0" ViewCount="87" Body="&lt;p&gt;I'm using a basic relay and I want to use 12 like this. Each one needs 50 milliamps, but the Arduino can supply only 300 milliamps. What can I do?&lt;/p&gt;&#xA;" OwnerUserId="14265" LastEditorUserId="4628" LastEditDate="2015-11-23T13:28:29.307" LastActivityDate="2015-11-23T13:28:29.307" Title="Arduino Uno + 12 relays" Tags="|arduino-uno|relay|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17126" PostTypeId="2" ParentId="17125" CreationDate="2015-10-23T09:54:51.933" Score="2" Body="&lt;p&gt;You should never drive relays direct from an Arduino.  You always need a driver circuit since each OP pin can only reliably provide up to 25mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every relay needs (at least) an NPN transistor and a flyback diode.  Follow the myriad of examples for controlling one relay on an Arduino and multiply it by 12.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might like to make things smaller and more manageable by using a paur of ULN2303 chips with 6 darlington drivers in each instead of using 12 discrete transistors.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-23T09:54:51.933" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="17127" PostTypeId="2" ParentId="17123" CreationDate="2015-10-23T09:56:45.297" Score="4" Body="&lt;p&gt;No, you cannot.  The LM35 is rated for an &lt;strong&gt;absolute maximum&lt;/strong&gt; junction temperature of 150°C.  Any higher than that and you will damage it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For temperatures above that you are better using a thermocouple.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-23T09:56:45.297" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17128" PostTypeId="2" ParentId="17083" CreationDate="2015-10-23T10:48:46.367" Score="2" Body="&lt;p&gt;Use it with Triac.  I use MOC3020 + BT138 + 330 and 510 Ohm resistors.&#xA;It works good as relay and in dimmer scheme.&#xA;Scheme is here &#xA;&lt;a href=&quot;http://cyber-place.ru/attachment.php?attachmentid=1030&amp;amp;d=1370462030&quot; rel=&quot;nofollow&quot;&gt;http://cyber-place.ru/attachment.php?attachmentid=1030&amp;amp;d=1370462030&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14266" LastActivityDate="2015-10-23T10:48:46.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17129" PostTypeId="1" CreationDate="2015-10-23T13:07:31.137" Score="1" ViewCount="951" Body="&lt;p&gt;I'm trying to switch multiple 12V LED's with my arduino, based on the input of a (serial-in parallel-out) shift-register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 12V comes from a separate battery, so I can use 8 mosfets to get my 12V, and I might even put a parallel-in serial-out shift register in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I'm hoping that there is a cleaner way of doing this.&#xA;Is there some kind of component that combines a shift register and a mosfet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on the best way to solve this?&lt;/p&gt;&#xA;" OwnerUserId="14269" LastActivityDate="2015-10-26T16:21:46.577" Title="Best way to make an Arduino switch 8 12V LED's" Tags="|power|shift-register|mosfet|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17131" PostTypeId="1" CreationDate="2015-10-23T14:21:50.770" Score="1" ViewCount="154" Body="&lt;p&gt;Is there any similar (less expensive alternative) arduino board to CMUcam4?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CMUcam4:The CMUcam4 is a fully programmable embedded computer vision sensor. The main processor is the Parallax P8X32A (Propeller Chip) connected to an OmniVision 9665 CMOS camera sensor module.&lt;/p&gt;&#xA;" OwnerUserId="14272" LastEditorUserId="14272" LastEditDate="2015-10-23T14:29:23.863" LastActivityDate="2016-04-20T20:10:34.803" Title="less expensive alternative arduino board to CMUcam4" Tags="|hardware|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17133" PostTypeId="2" ParentId="17131" CreationDate="2015-10-23T14:38:24.730" Score="1" Body="&lt;p&gt;I have used OpenCV on Intel Galileo for doing recognition of sub images from a larger image (given the cover of a magazine, identify it in a pile of magazines partially covering it). The frame rate is far from stellar.&#xA;I haven't tried with Edison but it should be much faster, as it's an Atom core vs the pentium-like Quark. OpenCV is optimized for x86.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a normal webcam to capture the image, so this solution gives more flexibility in the choice of the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could have a look at &lt;a href=&quot;http://wiki.ros.org/Edison&quot; rel=&quot;nofollow&quot;&gt;ROS on Edison&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-23T14:56:05.570" LastActivityDate="2015-10-23T14:56:05.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17135" PostTypeId="1" CreationDate="2015-10-23T15:58:05.420" Score="2" ViewCount="329" Body="&lt;p&gt;I'm writing a sketch to run on a Mega that builds up an array of timestamps (using the &lt;a href=&quot;http://playground.arduino.cc/Code/QueueArray&quot; rel=&quot;nofollow&quot;&gt;QueueArray library&lt;/a&gt; and &lt;a href=&quot;https://github.com/rodan/ds3231&quot; rel=&quot;nofollow&quot;&gt;DS3231 library&lt;/a&gt;). I'm having a problem where a struct I'm defining and then queueing is always referring to the first in the list. The relevant bits of the code looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;QueueArray.h&amp;gt;&#xA;#include &amp;lt;DS3231.h&amp;gt;&#xA;struct payload_t&#xA;{&#xA;   unsigned long timestamp;&#xA;}&#xA;&#xA;QueueArray &amp;lt;payload_t&amp;gt; dataQueue;&#xA;DS3231 clock;&#xA;RTCDateTime dt;&#xA;&#xA;void setup() {&#xA;   clock.begin();&#xA;   clock.setDateTime(__DATE__, __TIME__);&#xA;}&#xA;&#xA;void loop() {&#xA;    payload_t dataPayload;&#xA;    dataPayload.timestamp = getTimestamp();&#xA;    dataQueue.enqueue(dataPayload);&#xA;&#xA;    payload_t tempItem = dataQueue.dequeue();&#xA;&#xA;    /**&#xA;     * At this stage, the dataPayload.timestamp is correct, &#xA;     * but tempItem.timestamp will always show the value from &#xA;     * the first item in the queue&#xA;     */&#xA;&#xA;    sleep(1000);&#xA;}&#xA;&#xA;unsigned long getTimestamp() &#xA;{&#xA;    RTCDateTime dt = clock.getDateTime();&#xA;    return dt.unixtime;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As per the comment in the main() loop, the first time a packet is added to the queue, the timestamp matches. For subsequent items, the value retrieved from the queue always gives the timestamp from the first item in the queue.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel this is my C knowledge letting me down with something basic, but can anyone point me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="2832" LastEditorUserId="2832" LastEditDate="2015-10-24T16:18:42.400" LastActivityDate="2015-10-24T16:18:42.400" Title="Problem with structs and pointers(?) - Mega with QueueArray" Tags="|arduino-mega|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17136" PostTypeId="1" CreationDate="2015-10-23T16:05:27.907" Score="2" ViewCount="106" Body="&lt;p&gt;How does the arduino uno talk with i2c? i saw the circuit and it use analog input pins but as far as i know you cant use them as output. How does he send data over those pins?&lt;/p&gt;&#xA;" OwnerUserId="14265" LastActivityDate="2015-10-23T16:06:36.170" Title="Arduino Uno and I2C" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17137" PostTypeId="2" ParentId="17136" CreationDate="2015-10-23T16:06:36.170" Score="2" Body="&lt;p&gt;Most pins on the Arduino are multi-function and can be switched into different modes. Analog is just one of those modes. I2C is one of the available modes for the pins that A4 and A5 are connected to.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-23T16:06:36.170" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17139" PostTypeId="2" ParentId="17135" CreationDate="2015-10-23T20:42:49.653" Score="2" Body="&lt;p&gt;It's not your C knowlede letting you down, it's just that you haven't gotten used yet to the weirdness of the arduino ide/compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not need to create a main() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to create a loop() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main() is already defined and calls loop() in a loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check any other sketch and you'll notice that it usually defines setup() and loop(), almost never main().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must put in the setup function all the code that needs to be executed once (settings and initializations) and in the loop() function whatever needs to be executed iteratively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, leave declarations out of loop() unless you want such variables to have scope (and life) limited to only one round of loop()&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-23T20:42:49.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17141" PostTypeId="2" ParentId="17129" CreationDate="2015-10-23T22:36:02.957" Score="1" Body="&lt;p&gt;I would recommend using something like the &lt;a href=&quot;http://datasheet.octopart.com/STP08DP05TTR-STMicroelectronics-datasheet-8439803.pdf&quot; rel=&quot;nofollow&quot;&gt;STP08DP05&lt;/a&gt;.  ST Microelectronics makes 16 and 24 bit versions as well.  You can also find TI and NXP parts that will do basically the same thing.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With these parts you can hardwire your max current value with a resistor to make sure you don't overdrive the LED.  Just because you can drive the LED at 90mA, doesn't mean you should... it will probably be way to bright.  The IC's can also be daisy-chained to your shift register and you can drive very large strings of LEDs... or use them for RGB LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT - Based on Comments&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a couple of options.  Note the Vdd represents the voltage supply to the IC itself and the nominal operating voltage is 3.0V up to 5.5V (I'm honestly not sure why they even added 7V as a max value when they specify 5.5V on the next page). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, Vdd is not necessarily the voltage that your LED's are driven at.  You can drive the LEDs at 12V  (if you need to) and add a series resistor to the OUT pins of the IC's to dissipate the extra heat.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would probably be fine with 200 ohms per pin.  If you set your current at 20mA, and assuming a 2.2V drop through the LED, that would give you approximately 5.8V at the OUT pins and the IC wouldn't have to dissipate much heat in terms of power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you don't need to drive them at 12V then I wouldn't bother.  Usually the forward voltage of an LED is 1.8 to 3.3V and you don't need 12V.  However, if you are driving a lot of them then it may be easier to use the 12V.  There are always trade-offs.&lt;/p&gt;&#xA;" OwnerUserId="5067" LastEditorUserId="5067" LastEditDate="2015-10-26T16:21:46.577" LastActivityDate="2015-10-26T16:21:46.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17142" PostTypeId="2" ParentId="16866" CreationDate="2015-10-23T23:19:50.233" Score="1" Body="&lt;p&gt;This may be a kernel bug. See here: &lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1501240&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The workaround it seems is to use kernel &lt;code&gt;3.13.0-63-generic&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can change the kernel for a one-time boot by holding shift while starting up. To make the change persistent, you need to edit &lt;code&gt;/etc/default/grub&lt;/code&gt;: &lt;a href=&quot;https://askubuntu.com/questions/262965/grub-timeout-set-to-0-cant-access-grub-menu-anymore?rq=1&quot;&gt;https://askubuntu.com/questions/262965/grub-timeout-set-to-0-cant-access-grub-menu-anymore?rq=1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14282" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.187" LastActivityDate="2015-10-23T23:19:50.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17147" PostTypeId="1" CreationDate="2015-10-24T08:28:56.483" Score="1" ViewCount="11791" Body="&lt;p&gt;I am communicating with ESP8266 using SoftwareSerial of Arduino UNO. I can successfully send AT commands and get response when communicating through the terminal. But if i &lt;strong&gt;programmatically&lt;/strong&gt; send particular AT commands there is no response. &#xA;For eg: &#xA;I type AT in serial monitor I get OK&#xA;But if i send the following through SoftwareSerial pins&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;mySerial.println(&quot;AT&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;there is no response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell what will be the solution as to how to send AT commands explicitly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch is&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;SoftWareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(2, 3); // RX, TX&#xA;&#xA;void setup() {&#xA;// Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;AT&quot;);&#xA;  delay(100);&#xA;  while (mySerial.available()&amp;gt;0 ) {&#xA;    char ch=mySerial.read();&#xA;    data.concat(ch);&#xA;    if(ch=='\n')&#xA;      Serial.println(data);&#xA;    data=&quot;&quot;;&#xA;  }&#xA;}//setup&#xA;&#xA;void loop()  {&#xA;  while (mySerial.available()&amp;gt;0 ) {&#xA;    char ch=mySerial.read();&#xA;    data.concat(ch);&#xA;    if(ch=='\n')&#xA;      Serial.println(data);&#xA;    data=&quot;&quot;;&#xA;  }&#xA;  while (Serial.available()&amp;gt;0 ) {&#xA;    mySerial.write(Serial.read());&#xA;    delay(100);&#xA;  }&#xA;}//loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using Sparkfun Level Shifter to get 3.3V from 5V. The wiring is straightforward. ESP8266 Vcc and CH_PD to 3.3V; GND to GND; Tx to Arduino 2(Rx) directly; Rx to Sparkfun 3.3V RXO LV side and Arduino 3(Tx) to RXI HV side) so that when Arduino transmits it gets stepped down to 3.3V and ESP8266 receives it. The wiring should be correct as it is working perfectly when AT commands are sent manually. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried everything of sending mySerial.write(&quot;AT/r/n&quot;), mySerial.print(&quot;AT&quot;) mySerial.print(&quot;\r\n&quot;), etc but nothing seems to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it that there is some problem with SoftwareSerial. But then how is it working if i send AT commands manually through terminal ?&lt;/p&gt;&#xA;" OwnerUserId="8254" LastEditorUserId="7856" LastEditDate="2015-10-27T09:59:30.667" LastActivityDate="2018-09-30T13:07:11.827" Title="SoftwareSerial with ESP8266" Tags="|arduino-uno|softwareserial|esp8266|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17149" PostTypeId="2" ParentId="16692" CreationDate="2015-10-24T10:07:35.133" Score="0" Body="&lt;p&gt;Moved to another board more suitable to our needs, but @sm4rteverything (Twitter) gave us the following solution (not tested):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This is a known bug of the bootloader.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;to fix this U need to download the one i attach in this email with the&#xA;  ATMEL-ICE tool. &lt;a href=&quot;http://www.atmel.com/tools/atatmel-ice.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.atmel.com/tools/atatmel-ice.aspx&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Copy the attched file under: \Arduino15\packages\AMEL\hardware\samd\1.0.0\bootloaders\sme&#xA;  (Linux) C:\Users\\AppData\Roaming\Arduino15\packages\AMEL\hardware\samd\1.0.0\bootloaders\sme&#xA;  (Windows)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;last follow these three simple step Connect the ATMEL-ICE on the SWD&#xA;  J1 connector (pin 1 on top-rigth , the pin on eon cabel is the red&#xA;  one)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KN53N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KN53N.png&quot; alt=&quot;Board picture&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;select on Arduino IDE to connect to ASME via atmel-ice (board menu)&#xA;  tool-&gt;burn bootloader&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="13925" LastEditorUserId="13925" LastEditDate="2016-01-26T17:34:03.260" LastActivityDate="2016-01-26T17:34:03.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17150" PostTypeId="1" CreationDate="2015-10-24T14:28:35.903" Score="1" ViewCount="945" Body="&lt;p&gt;It says in the description of the function:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Registers a function to be called when a slave device receives a transmission from a master.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So when does it exactly called? I guess it's not been called for each byte, but its the meaning of receiving transmission from the master. Does it called for each byte? When the master use transmissionBegin? transmissionEnd?&lt;/p&gt;&#xA;" OwnerUserId="14265" LastEditorUserId="10794" LastEditDate="2016-05-22T20:49:02.070" LastActivityDate="2016-05-22T21:30:22.997" Title="Arduino Wire.onReceive(handler)" Tags="|i2c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17151" PostTypeId="2" ParentId="17150" CreationDate="2015-10-24T14:58:00.493" Score="1" Body="&lt;p&gt;It is called at the end of the reception of the entire packet - i.e., when the slave receives the final &lt;code&gt;STOP&lt;/code&gt; bit.  It is passed the number of bytes received (which is the number of bytes you requested since I2C has no way of being able to work out if it is actually receiving real data - see &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10896&amp;amp;reply=10#reply10&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) as the only parameter so you know how many bytes you can then read from the internal buffer without overflowing it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-22T21:30:22.997" LastActivityDate="2016-05-22T21:30:22.997" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17154" PostTypeId="1" AcceptedAnswerId="17156" CreationDate="2015-10-24T18:05:41.010" Score="1" ViewCount="6617" Body="&lt;p&gt;I'm building an instrument that has 72 buttons that can be pressed. Now I'm planning on using Arduino to send data to computer via USB cable about which buttons are pressed. So I figured I'd need 72 different input pins, one for each button(the button is connected to the Arduino via a wire). But, the Arduino doesn't have 72 input pins, so this seems kind of impossible. So what I'm looking for is a way to somehow extend the number of pins on the Arduino or another way to solve my problem. Maybe it would be better to use another micro-controller? Maybe using analog inputs for this is better?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it makes any difference, the max number of buttons that can be pressed at once is 10.&lt;/p&gt;&#xA;" OwnerUserId="14308" OwnerDisplayName="user3071028" LastActivityDate="2015-10-24T18:51:27.130" Title="How to add more inputs on Arduino?" Tags="|usb|input|pins|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17155" PostTypeId="2" ParentId="17154" CreationDate="2015-10-24T18:18:02.263" Score="-1" Body="&lt;p&gt;You may try making something like a button grid, Like the ways Leds are connected in a Led cube, For example - In a 4*4*4 led cube, u don't need 64 pins, but a smart connection of all on x and y axis, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;what i mean to say is, &#xA;you need to make rows and columns of button, But i don't think this idea would work cause buttons are totally different from leds, But then also try searching for led cube circuit, let it spark a new idea in your mind.&lt;/p&gt;&#xA;" OwnerUserId="13514" LastActivityDate="2015-10-24T18:18:02.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17156" PostTypeId="2" ParentId="17154" CreationDate="2015-10-24T18:20:49.647" Score="2" Body="&lt;p&gt;There is a whole concept you need to learn:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Matrix&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;By using a matrix arrangement you can, using (8 + 9 = ) 17 IO pins you can create a grid of 8 × 9 buttons, which is 72 buttons.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method is used all the time for keypads, and you can read more here: &lt;a href=&quot;http://playground.arduino.cc/Main/KeypadTutorial&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/KeypadTutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To further reduce the number of IO pins used you can replace the 8 IO pins for one dimension of the matrix with a 3-to-8 decoder, since only one pin is ever active at a time.  That reduces it down to just 12 IO pins for the whole shebang. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-24T18:20:49.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17157" PostTypeId="2" ParentId="17154" CreationDate="2015-10-24T18:51:27.130" Score="2" Body="&lt;p&gt;There are quite a few GPIO expanders available that you could use to increase IO lines in your circuit, mostly running off I2C. Just search &quot;I2C GPIO&quot; on your favorite electronics site/google/ebay&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Examples:&#xA;&lt;a href=&quot;https://www.sparkfun.com/products/8130&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8130&lt;/a&gt;&#xA;[No affiliation]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If every sensed key has to be on a GPIO, then this is the way to go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, with IO expanders, you will find that sensing large number of keys still takes lots of code on your uC. With some extra software effort, you could eliminate expanders, and rather scan a key matrix as suggested by Majenko&lt;/p&gt;&#xA;" OwnerUserId="14297" LastActivityDate="2015-10-24T18:51:27.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17158" PostTypeId="1" AcceptedAnswerId="17159" CreationDate="2015-10-24T19:04:53.647" Score="1" ViewCount="1822" Body="&lt;p&gt;I have the following circuit: &lt;a href=&quot;https://i.stack.imgur.com/lZJDW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lZJDW.jpg&quot; alt=&quot;Arduino circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I know it works and that the diode protects the negative voltage from flowing back into the transistor. This is essentially the circuit: &lt;a href=&quot;https://i.stack.imgur.com/qGZ9h.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qGZ9h.jpg&quot; alt=&quot;Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone illustrate what happens when the motor stops? The current normally flows from 5V to GND (and the electrons from GND to 5V, but this doesn't matter (I think?)), and then it reverses when you switch it off, so current comes out of the top of M1, and then what? I don't get it here.&lt;/p&gt;&#xA;" OwnerUserId="14298" LastEditorUserId="8" LastEditDate="2015-10-24T20:24:47.753" LastActivityDate="2015-10-24T20:24:47.753" Title="DC motor kickback diode?" Tags="|arduino-uno|motor|transistor|h-bridge|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17159" PostTypeId="2" ParentId="17158" CreationDate="2015-10-24T19:18:47.577" Score="2" Body="&lt;p&gt;While the motor is being powered the current flows from Vcc to GND as in this circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QULAI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QULAI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the power is disconnected (such as the transistor in the ground connection in your circuit is switched off) amongst other things (including the collapsing of magnetic fields) the spinning of the motor turns it into a generator.  The power generated is the opposite of what was being provided to make it move.  As the magnetic field of the coils collapses additional high voltages are also generated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When disconnected the motor can be represented as a battery connected backwards.  In that configuration the current flows from the + of this hypothetical battery through the diode into the - thus stopping any current from going elsewhere, as in this circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Rjim.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Rjim.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-24T19:54:45.260" LastActivityDate="2015-10-24T19:54:45.260" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17160" PostTypeId="1" AcceptedAnswerId="17161" CreationDate="2015-10-24T21:57:59.150" Score="0" ViewCount="1100" Body="&lt;p&gt;I am a big noob I know that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but can this code be used to reset arduino board (instead of pressing the usual reset button on the board) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to reset the board as If am pressing the reset button using IR &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int receiverpin = 2; // pin 1 of IR receiver to Arduino digital pin 2&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;IRrecv irrecv(receiverpin); // create instance of irrecv&#xA;decode_results results;&#xA;void setup()&#xA;{&#xA;irrecv.enableIRIn(); // start the receiver&#xA;}&#xA;void(* resetFunc) (void) = 0; //declare reset function @ address 0&#xA;&#xA;void loop()&#xA;{&#xA; if (irrecv.decode(&amp;amp;results)) // have we received an IR signal?&#xA;{&#xA;if(results.value == 0x2FD847B) //if the button press equals the hex &#xA;{&#xA;  resetFunc();&#xA;}&#xA;{&#xA;irrecv.resume(); // receive the next value&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14300" LastActivityDate="2015-10-24T22:06:26.963" Title="How to use Infra Red (IR) to reset arduino board" Tags="|ir|" AnswerCount="1" CommentCount="0" ClosedDate="2015-10-25T16:06:02.410" ContentLicense="CC BY-SA 3.0" />
  <row Id="17161" PostTypeId="2" ParentId="17160" CreationDate="2015-10-24T22:06:26.963" Score="1" Body="&lt;p&gt;Kind of, yes.  That doesn't actually reset the Arduino, it just sends the program to address 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two other ways of performing the reset that do a proper full reset:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Enable the watchdog timer and let it time out to reset the CPU.&lt;/li&gt;&#xA;&lt;li&gt;Connect an IO pin to the RESET pin - keep it in INPUT most of the time but set it to OUTPUT and LOW when you want to reset.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;By just jumping to address 0 you aren't resetting the internal peripherals and registers to their reset state, so things like timers and such will still be running when they shouldn't be, etc.  It's better by far to do a real reset instead of just jumping to 0 like that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-24T22:06:26.963" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17162" PostTypeId="2" ParentId="16576" CreationDate="2015-10-24T22:14:31.653" Score="1" Body="&lt;p&gt;Having exchanged the board for another one (that works!) I can now confirm that the calls above (e.g. AT+CMGL) &lt;em&gt;should&lt;/em&gt; work if there is a working SIM connection.&lt;/p&gt;&#xA;" OwnerUserId="13815" LastActivityDate="2015-10-24T22:14:31.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17163" PostTypeId="2" ParentId="16538" CreationDate="2015-10-25T00:08:46.437" Score="0" Body="&lt;p&gt;You need to add a 100nF (0.1µF) capacitor between DTR and RESET so it generates a pulse instead of a constant LOW all the time the port is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The older IDE uses an older version of avrdude. The newer version of avrdude with the newer IDE has extra code for manually manipulating DTR to get around some issues with new versions of the FTDI drivers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-25T00:08:46.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17164" PostTypeId="1" AcceptedAnswerId="17171" CreationDate="2015-10-25T00:27:35.020" Score="0" ViewCount="35" Body="&lt;p&gt;I would like to verify timings of a relay controlled by an arduino (uno R3). There is a lot going on in the sketch and it does not use the delay function but one which is based on &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;counting milliseconds&lt;/a&gt;. The arduino then transmits to another arduino using a radio module (nRF24L01). I'd like to confirm the intervals between the relay, so for instance if the relay is acivated 10 times and there are 5 seconds between each actvation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I was wondering was whether anyone had any reccomendations on methods to verify timings using an external source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two ideas I came up with were: have another arduino with a very simple script that measures the timings or try and find/write a verilog script to upload to a mojo fpga and measures the timings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ideal situation would be where I have a seperate device that hooks up to the relay and then measures and displays the timings between the relay switches and is extremely precise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that makes sense, if not please let me know and I'll explain further. Thank you for reading and any help is greatly appriciated.&lt;/p&gt;&#xA;" OwnerUserId="8726" LastActivityDate="2015-10-25T11:40:25.483" Title="Verifying the timing between relay activations" Tags="|safety|timing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17169" PostTypeId="1" CreationDate="2015-10-25T05:59:20.060" Score="3" ViewCount="2694" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/TMRh20/TMRpcm/wiki&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/TMRpcm/wiki&lt;/a&gt; library to play wav files from an SD card to a speaker I have attached to my Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have run separate tests/programs that ensures:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;my speaker is connected properly and can play sound &lt;/li&gt;&#xA;&lt;li&gt;my SD file is connected properly as it can read and files, text files.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However, I'm trying to use the &lt;code&gt;tmrpcm.play(&quot;example.wav&quot;)&lt;/code&gt; command and nothing is happening. I used wav files that for sure works (from a demo I found online) so it's not the wav file problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have any clue on what is going on and how I can fix this?&lt;/p&gt;&#xA;" OwnerUserId="14307" LastEditorUserId="6936" LastEditDate="2016-03-15T04:40:00.433" LastActivityDate="2017-03-12T16:40:16.297" Title="Using TMRpcm library, the audio does not play" Tags="|arduino-uno|sd-card|audio|tmrpcm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17171" PostTypeId="2" ParentId="17164" CreationDate="2015-10-25T06:50:37.003" Score="1" Body="&lt;p&gt;You could use &lt;a href=&quot;http://sigrok.org&quot; rel=&quot;nofollow&quot;&gt;sigrok&lt;/a&gt; with one of the many &lt;a href=&quot;http://sigrok.org/wiki/Supported_hardware&quot; rel=&quot;nofollow&quot;&gt;supported devices&lt;/a&gt;.&#xA;For example, you can find on ebay an &lt;a href=&quot;http://sigrok.org/wiki/MCU123_USBee_AX_Pro_clone&quot; rel=&quot;nofollow&quot;&gt;8 channell 24MHz probe&lt;/a&gt; for less than $10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a nice tool to have laying around. For example you can use it as less-invasive-than-serial-print way to detect when internal states of a program change value: just toggle some unused GPIO.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-25T11:40:25.483" LastActivityDate="2015-10-25T11:40:25.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17172" PostTypeId="1" CreationDate="2015-10-25T12:20:41.417" Score="0" ViewCount="175" Body="&lt;p&gt;A newbe here. How come when I compile with an error I do not get the line or line number highlighted? I Get the errors just can't find where they are.&lt;/p&gt;&#xA;" OwnerUserId="14309" LastEditorUserId="14309" LastEditDate="2015-10-25T13:45:20.283" LastActivityDate="2016-01-22T20:29:16.157" Title="Compilling error not highlighting line in code" Tags="|arduino-uno|compile|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17173" PostTypeId="1" CreationDate="2015-10-25T15:13:34.853" Score="0" ViewCount="49" Body="&lt;p&gt;I am on my final year project in I.T. my project is that i want to create a helicopter or quadcopter with a camera attached to it. And i want to control the copter via wifi from an android phone in another location. e.g, the copter is at home and i am somewhere else (work, university etc..). so i wanted to know if i can connect both via 2 different routers and control it and get the live video the camera is actually recording (the idea is to monitor your house when you are away). if that is possible, which arduino hardware will enable me to do that.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="14315" LastActivityDate="2015-10-25T15:50:23.073" Title="Arduino communicate between 2 different router in different location" Tags="|arduino-uno|wifi|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17174" PostTypeId="2" ParentId="17173" CreationDate="2015-10-25T15:50:23.073" Score="1" Body="&lt;p&gt;It's not the Arduino that has anything to do with this but the routing, port forwarding and/or VPN that you set up between your routers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd have thought, since you're in your final year of IT, you'd at least have some rudimentary knowledge of routing, port forwarding and VPNs...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-25T15:50:23.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17176" PostTypeId="1" AcceptedAnswerId="17318" CreationDate="2015-10-25T18:00:20.437" Score="0" ViewCount="491" Body="&lt;p&gt;I'm trying to upload a huge sketch to my &lt;strong&gt;Uno R2&lt;/strong&gt;. It's compiling just fine but it fails to upload at 94% of writing to flash...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is so large because of a big array of data in a separate .h file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;const unsigned char PROGMEM data[] = {&#xA;  0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f, 0x80, 0x7f, 0x80, 0x7f, 0x80, (etc...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A test sketch with just 12 bytes of data uploads fine, so the problem is either with the size or some weird bug triggered by some of the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless i'm missing something, this should technically work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /home/hatagashira/.arduino-1.6.5/hardware/tools/avr/bin/avrdude -C/home/hatagashira/.arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build8921209068074674980.tmp/program.cpp.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 19:04:16&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/home/hatagashira/.arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/hatagashira/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;         Setting bit clk period        : 5.0&#xA;         AVR Part                      : ATmega328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;         Hardware Version: 3&#xA;         Firmware Version: 3.3&#xA;         Vtarget         : 0.3 V&#xA;         Varef           : 0.3 V&#xA;         Oscillator      : 28.800 kHz&#xA;         SCK period      : 3.3 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: safemode: lfuse reads as 0&#xA;avrdude: safemode: hfuse reads as 0&#xA;avrdude: safemode: efuse reads as 0&#xA;avrdude: reading input file &quot;/tmp/build8921209068074674980.tmp/program.cpp.hex&quot;&#xA;avrdude: writing flash (30110 bytes):&#xA;&#xA;Writing | ###############################################    | 94% 5.10savrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14317" LastActivityDate="2015-10-29T22:05:20.450" Title="Sketch upload freezes during write" Tags="|arduino-uno|uploading|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17177" PostTypeId="1" CreationDate="2015-10-25T18:31:04.473" Score="2" ViewCount="497" Body="&lt;p&gt;I have a &lt;a href=&quot;https://www.sparkfun.com/products/10736&quot; rel=&quot;nofollow&quot;&gt;Razor IMU&lt;/a&gt;, which communicates through a &lt;a href=&quot;https://www.arduino.cc/en/Main/USBSerial&quot; rel=&quot;nofollow&quot;&gt;USB to Serial Converter&lt;/a&gt; with a USB Host Shield mounted on an Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even though serial communication can be achieved directly through the Arduino pins, I'm using a Host shield to keep the pins free for other devices. I found the Host Shield Library, which had specific examples for XBOX and PS3 controllers, Bluetooth devices, keyboards and mice etc., but I can't figure out a way to send/receive data to the IMU connected to the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm kind of a noob, so be kind. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="14319" LastActivityDate="2015-10-25T18:31:04.473" Title="Data exchange through USB Host Shield" Tags="|serial|shields|usb|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17178" PostTypeId="2" ParentId="4419" CreationDate="2015-10-25T18:53:33.707" Score="0" Body="&lt;p&gt;Are you sure there are no rollovers / overflows? Keep in mind the limitations of FAT16, max volume size is 2GB, and only with the max sector size of 512B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At minimum &lt;code&gt;dcounter&lt;/code&gt; will overflow in 9 hours if you log every second.&lt;/p&gt;&#xA;" OwnerUserId="14317" LastActivityDate="2015-10-25T18:53:33.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17179" PostTypeId="1" AcceptedAnswerId="17182" CreationDate="2015-10-25T19:31:38.667" Score="0" ViewCount="321" Body="&lt;p&gt;I'm not that experienced with electronics but I am learning. And I've set a challenge for myself. I have a Digispark USB Development board (and many more but I want to use this one!), I have a Bluetooth module and I have two RGB LEDs which I want to control over the Bluetooth connection. Each LED has to be controlled separately and I want to be able to set each color separately and be able to mix about 256x256x256 colors. Which means, PWM connections. The Bluetooth connection would listen to instructions, receiving four bytes containing RGB values and a value between 0 and three to pick which light needs to be set. (0=None, 1=left, 2=right, 3=both)&lt;br&gt;&#xA;Also important is that it needs to be small. It will end up in a container of of roughly 3x3x10 CM in size. (Slightly bigger than 1x1x3 inch.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The challenge is that Digispark only has 6 pins available so that's not enough to handle this all. I could use three pins and use a 74HC165N Shift Register but that would just turn each color on or off, thus limiting me to 8 colors. That's not good enough! Besides, I also need to connect the four pins of the Bluetooth module.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is simple: What would I need more to build this project? To send the proper six analog signals while having enough pins to handle the Bluetooth datastream? &lt;/p&gt;&#xA;" OwnerUserId="14316" LastEditorUserId="14316" LastEditDate="2015-10-25T21:46:43.987" LastActivityDate="2015-10-25T21:46:43.987" Title="Using 2 RGB lights over Bluetooth with a DigiSpark" Tags="|pwm|multiplexer|rgb-led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17180" PostTypeId="1" CreationDate="2015-10-25T19:41:14.847" Score="1" ViewCount="1281" Body="&lt;p&gt;I have a piezoelectric sensor. Both pins are the same length. I have one like this: &lt;a href=&quot;https://cdn.solarbotics.com/products/photos/93c51bd69dcc15a0f60bb6bb4c96d4df/lrg/17855-dscn3894.JPG&quot; rel=&quot;nofollow&quot;&gt;Piezo picture&lt;/a&gt;. On the Piezo it's written &lt;em&gt;muRata&lt;/em&gt; and &lt;em&gt;01P&lt;/em&gt;. How do I know which do I send to the digital pins and which to the ground? I have an Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="10878" LastActivityDate="2015-10-29T22:10:17.137" Title="How do I know which is ground and power in Piezo?" Tags="|arduino-uno|sensors|pins|piezo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17181" PostTypeId="2" ParentId="17180" CreationDate="2015-10-25T20:05:41.957" Score="2" Body="&lt;p&gt;On the one I have, the shorter pin is ground. I discovered that empirically - a scientific word for &quot;I tried it the wrong way round the first time but the magic smoke stayed inside.&quot; Afterwards I inspected it more carefully, I found a '+' embossed in the top surface nearer one side. :-o&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-25T20:05:41.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17182" PostTypeId="2" ParentId="17179" CreationDate="2015-10-25T20:25:58.873" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Which means, analog connections.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nope. It means PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you control the brightness of a single LED?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By generating a PWM signal with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;sufficiently high frequency to not be able to notice the flickering;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;duty cycle proportional to the brightness you want/need, where 100% is full brightness, and 0% is OFF&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You only have to do that for each colour of the RGB LED you want to drive.&#xA;Ideally you would use a HW block capable of generating the PWM signal, but it can be also bit-banged, should you run out of PWM blocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just keep in mind that different colours have different currents (for the same level of brightness), so you have to pay attention at calculating the correct value of the resistor applied to each colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer to ensure that each channel is driven by a HW PWM generator, you can also use an external driver. Ex: &lt;a href=&quot;http://www.intersil.com/en/products/audiovideo/display-ics/led-backlight-drivers/ISL97671A.html&quot; rel=&quot;nofollow&quot;&gt;I2C 6-channels PWM generator&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-25T20:45:28.763" LastActivityDate="2015-10-25T20:45:28.763" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17183" PostTypeId="1" AcceptedAnswerId="17186" CreationDate="2015-10-25T20:39:42.223" Score="0" ViewCount="1369" Body="&lt;p&gt;I'll preface this buy saying I am very new to working with Arduino boards or hardware in general.&#xA;I am attempting to follow a tutorial on instructables&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/PCBot/step4/Printer-test/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/PCBot/step4/Printer-test/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have my board and printer wired up properly and I have git cloned the python thermal printer. My issue begins at this paragraph:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open the UART0 serial port&#xA;  by default the GPIO's of the edison are disables.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can enable them by programming the edison via the Arduino IDE or by using the MRAA library available for several programming languages.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To open enable the UART0 port, TX RX on the edison breakout board, open a Python shell in the thermal and write:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;import mraa&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;x=mraa.Uart(0) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I opened a python shell and entered the &lt;code&gt;import mraa&lt;/code&gt; lines and tried to run the &lt;code&gt;printertest.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I receive an error that says no module named serial. I am not sure where the issue is. I thought the Edison already had python serial installed. I did try to install it with &lt;code&gt;opkg install python-serial&lt;/code&gt; but it didn't work. If my issue is with enabling the Uart0 port I am not sure how to go about doing it. I have the Arduino IDE installed but I have no idea how to go about enabling it via the Arduino IDE. The instructions are a bit vague in that paragraph. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Update I have successfully installed pip and got pyserial installed. Now when I try to run the printertest.py I get an error &lt;code&gt;OSError: [Errno 2] No such file or directory: '/dev/ttyAMA0'&lt;/code&gt; which I think is potentially caused by me not succesfully opening Uart0 port but I am not sure how to. I tried adding the import in a shell as well as adding it directly to the code via nano&lt;/p&gt;&#xA;" OwnerUserId="12034" LastEditorUserId="12034" LastEditDate="2015-10-26T02:02:28.567" LastActivityDate="2015-10-26T03:34:08.767" Title="Open the Uart0 Serial Port on Intel Edison" Tags="|serial|arduino-ide|edison|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17184" PostTypeId="1" CreationDate="2015-10-25T22:16:08.873" Score="5" ViewCount="5094" Body="&lt;p&gt;I'm trying to operate the esp8266. When I connect RX+TX pins to pins 1+2 on the Arduino, everything works fine. but when I'm trying to use software serial all hell breaks loose and the recieved data is garbadeged (It seems like everything is ok but I can't read the output data...&#xA;more interesting, the output is not consistent!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial esp8266(11, 10); // RX, TX&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    esp8266.begin(19200);&#xA;    Serial.begin(115200 );&#xA;}&#xA;&#xA;void loop() {&#xA;    esp8266.write(&quot;AT\r\n&quot;);&#xA;    String buffer;&#xA;    Serial.print(&quot;SENDING AT...&quot;);&#xA;    for(uint64_t time = millis();(time+1000) &amp;gt; millis();)&#xA;       for(;esp8266.available();buffer+=(char)esp8266.read());&#xA;    buffer.replace(&quot;\r\n&quot;,&quot; &quot;);&#xA;    Serial.println(&quot;RESPONSE:&quot; + buffer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the output: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/CL9jv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CL9jv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried changing the SerialMonitor baud rate, the input pins, but results are all the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recently changed the MCU(uno) to a different and even a different esp module from a different supplier,&#xA;I am still getting the same results! I can't be the first one to encounter such phenomena...&lt;/p&gt;&#xA;" OwnerUserId="8468" LastEditorUserId="8468" LastEditDate="2015-10-31T19:23:18.633" LastActivityDate="2016-02-28T00:56:10.553" Title="esp8266 garbage out only when using SoftwareSerial" Tags="|c++|wifi|softwareserial|esp8266|terminal|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17185" PostTypeId="2" ParentId="17180" CreationDate="2015-10-26T00:00:32.750" Score="1" Body="&lt;p&gt;If you're using just one or sound quality doesn't matter: it doesn't matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you need to figure it out with a scope like &lt;a href=&quot;http://service.toptica.com/index.php?pg=kb.page&amp;amp;id=7&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connect both poles of the connector of the PZT to an oscilloscope (time base approx. 50ms/div, y-axis 200mV/div).&lt;/li&gt;&#xA;&lt;li&gt;Slightly tap the head of the PZT with your finger. As a result you should get a voltage pulse on the oscilloscope.  &lt;/li&gt;&#xA;&lt;li&gt;Positive Amplitude  -&gt; + pole of the piezo is connected to the inner conductor of the oscilloscope BNC connector. &lt;/li&gt;&#xA;&lt;li&gt;Negative Amplitude -&gt; + pole of the piezo is connected to the outer conductor of the oscilloscope BNC connector.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14317" LastEditorUserId="14317" LastEditDate="2015-10-29T22:10:17.137" LastActivityDate="2015-10-29T22:10:17.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17186" PostTypeId="2" ParentId="17183" CreationDate="2015-10-26T03:34:08.767" Score="0" Body="&lt;p&gt;I have solved the issues and successfully connected this printer with the Compute Module. I solved the issue by changing the target of &lt;code&gt;/dev/ttyAMA0&lt;/code&gt; to &lt;code&gt;/dev/ttyMFD1&lt;/code&gt; as shown by &lt;a href=&quot;http://iotdk.intel.com/docs/master/mraa/edison.html&quot; rel=&quot;nofollow&quot;&gt;http://iotdk.intel.com/docs/master/mraa/edison.html&lt;/a&gt; . This was the final step after I had installed pyserial.&lt;/p&gt;&#xA;" OwnerUserId="12034" LastActivityDate="2015-10-26T03:34:08.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17188" PostTypeId="1" AcceptedAnswerId="17223" CreationDate="2015-10-26T07:30:52.110" Score="1" ViewCount="14427" Body="&lt;p&gt;I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://rads.stackoverflow.com/amzn/click/B00PI6TO8U&quot; rel=&quot;nofollow noreferrer&quot;&gt;ESP8266&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Problem:&#xA;I see SoftAP and can connect to it. But I can't send AT-commands to ESP8266 from Arduino.&#xA;I use Arduino app v.1.6.5 for send command to ESP8266 via Arduino. But I don't get answer. And ESP8266 doesn't blinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use this scheme:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Co7kW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Co7kW.png&quot; alt=&quot;Scheme for connecting Arduino and ESP8266&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, help me. I'm trying to fix this is very time consuming.&lt;/p&gt;&#xA;" OwnerUserId="14326" LastEditorUserId="14326" LastEditDate="2018-05-21T11:18:48.473" LastActivityDate="2018-05-21T11:18:48.473" Title="Problem with connecting ESP8266 to arduino" Tags="|arduino-uno|esp8266|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17189" PostTypeId="1" AcceptedAnswerId="17190" CreationDate="2015-10-26T10:24:06.840" Score="0" ViewCount="1947" Body="&lt;p&gt;I am learning Arduino from &quot;Arduino cookbook by Michael Margolis&quot;, i was reading about bitwise operations and extracting low and high bytes from int. He said that there is no function in Arduino to extract high and low bytes from long at the time of his writing. He stated an alternative to the problem by adding two line of code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define highWord(w) ((w) &amp;gt;&amp;gt; 16)&#xA;#define lowWord(w) ((w) &amp;amp; 0xffff)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line i clearly understood like this, please make corrections if i am wrong.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;32bit binary of 16909060 is 0000 0001 0000 0010 0000 0011 0000 0100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by right shifting last 16 bits we will arrive at &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;32bit binary of 16909060 after right shifting 16bits is 0000 0000 0000 0000 0000 0001 0000 0010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not able to interpret the second line. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define lowWord(w) ((w) &amp;amp; 0xffff)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would be very grateful if some body explain how the above line of code works? &#xA;Thanks.         &lt;/p&gt;&#xA;" OwnerUserId="13910" LastActivityDate="2015-10-26T21:52:48.403" Title="Extracting high and low bytes from long" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17190" PostTypeId="2" ParentId="17189" CreationDate="2015-10-26T10:49:50.377" Score="4" Body="&lt;p&gt;The second line masks off the top two bytes using a bitwise AND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use a bitwise AND it follows the normal rules for any boolean truth table.  1 &amp;amp; 1 = 1, 1 &amp;amp; 0 = 0...  Since the value is being ANDed, effectively, against 0x0000FFFF, the top two bytes will be cleared to zero while the bottom two bytes are preserved.  In this way you can extract the lower two bytes out of the four byte long.&lt;/p&gt;&#xA;" OwnerUserId="14231" LastActivityDate="2015-10-26T10:49:50.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17191" PostTypeId="2" ParentId="17188" CreationDate="2015-10-26T12:39:52.853" Score="0" Body="&lt;p&gt;I had the same problem. I solved it doing the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect Arduino TX to a voltage divider (to get 3,3V) and then to TX on ESP8266&#xA;Connect Arduino RX to RX on ESP8266&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should work!.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please read the information on this link &#xA;&lt;a href=&quot;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&quot; rel=&quot;nofollow&quot;&gt;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14330" LastActivityDate="2015-10-26T12:39:52.853" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17192" PostTypeId="2" ParentId="12196" CreationDate="2015-10-26T12:51:25.027" Score="1" Body="&lt;p&gt;As a project building a cat detector sounds interesting, but as a cat owner I can promise you that if you actually go through with it the cats will see it, play with it and trash it within 5 minutes.  If it is successful and you do manage to scare them out of the basement they are just going to find somewhere else to 'do their business' and that could be in your bed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, your sensor will need to scan a large field of potentially rapidly moving objects.  A beam wouldn't be suitable because they could step over or under it.  I think PIR would be best for this task, but PIR sensors might not be sensitive enough to detect the little darlings.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea maybe a gas sensor based project to provide an audible warning when a human enters the area that there are 'landmines' in the proximity and extreme caution needs to be used, if you know what I mean :)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-10-26T12:51:25.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17194" PostTypeId="1" CreationDate="2015-10-26T13:08:17.877" Score="2" ViewCount="113" Body="&lt;p&gt;I am developing a project with RFduino, where I need to connect HC-05 Bluetooth module to my RFduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to find a way to do that, with out luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: Is it possible to connect HC-05 board to RFduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this is my first question at Arduino.stackexchange.com&lt;/p&gt;&#xA;" OwnerUserId="14332" LastActivityDate="2015-10-26T13:08:17.877" Title="RFduino and HC-05" Tags="|hc-05|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17195" PostTypeId="1" AcceptedAnswerId="17196" CreationDate="2015-10-26T15:19:47.413" Score="0" ViewCount="290" Body="&lt;p&gt;I need to attach several capacitive sensors MPR121 with each of them using all of its 12 electrodes to an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please tell me, how many will work with the voltage and current Arduino Uno supplies?&lt;/p&gt;&#xA;" OwnerUserId="14338" LastActivityDate="2015-10-26T15:25:49.337" Title="Capacitive sensor MPR121 on Arduino Uno—how many will work?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17196" PostTypeId="2" ParentId="17195" CreationDate="2015-10-26T15:25:49.337" Score="2" Body="&lt;p&gt;The answer is 4 regardless of the current consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have 4 MPR121 devices on an I2C bus (by connecting the ADDR pin to the right place to select 1 of 4 addresses), and the Uno has one I2C bus - so that means 4 devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; use software I2C to add more devices on other pins, but that's slow and clunky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that aside, if you used something to increase the number of I2C buses available, according to the datasheet the peak current consumption is 1mA during sampling, and assuming 300mA maximum for the Arduino's 3.3V regulator, that would mean a maximum of 300 MPR121 connected to the Arduino.  Note that, if you could actually &lt;em&gt;get&lt;/em&gt; to the Arduino amongst that tangle of wires, you'd find it getting rather hot...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-26T15:25:49.337" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17198" PostTypeId="2" ParentId="5341" CreationDate="2015-10-26T16:17:40.600" Score="2" Body="&lt;p&gt;I suppose you mean the &amp;quot;Galileo integrated Ethernet port&amp;quot; (the on-board RJ45). Then the answer is &amp;quot;no, not directly&amp;quot;. The whole code provided by Intel in Arduino 1.6 IDE applies to the W5100 based shield, not the integrated Ethernet interface (which is a bit stupid, imho...)&lt;/p&gt;&#xA;&lt;p&gt;Technically, however, this is possible, but you will need to create a library in C/C++, which interfaces with the system lib (the Linux one). You can then access the wonderful world of BSD sockets (much more powerful than the sockets within the W5100).&lt;/p&gt;&#xA;&lt;p&gt;Note however that the configuration of the integrated Ethernet board is not very easy with the Galileo, because the default Yocto image does not allow you to change default IP parameters (the Yocto image uses DHCP by default). So technically, you need then to deal with a startup script that changes the IP parameters at startup, but it's pretty heavy to do.&lt;/p&gt;&#xA;" OwnerUserId="14341" LastEditorUserId="90731" LastEditDate="2023-07-06T08:27:12.163" LastActivityDate="2023-07-06T08:27:12.163" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17199" PostTypeId="2" ParentId="15960" CreationDate="2015-10-26T16:30:44.017" Score="0" Body="&lt;p&gt;The assumption I am making is &quot;VISA connection&quot; is a PC operating VISA.&#xA;I have seen ports shut down on windows several times yet the same port works fine while in DOS.  My suggestion is try a different computer, that should narrow down your problem to which side of the connector is failing.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-26T16:30:44.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17200" PostTypeId="2" ParentId="15836" CreationDate="2015-10-26T16:44:10.447" Score="1" Body="&lt;p&gt;Rule 1 do not connect Arduino pins to long wires. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve your your goal in many ways, a serial interface looks good from here.  I am doing it with a RS485 interface, note it is an interface not a protocol. You can use CAN, Wi-fi and many others.  It sounds like all the units except 1 will be receiving data, the other is transmitting it to the other devices.  RS485 will work good and it needs only 5V.  It will work over several thousand feet and some reasonable speeds. You can use a UART either hardware or software to accomplish the task with a RS-485 driver at each node.  You need to remember you need to wire from point to point with the terminating resistors only on the end nodes. &lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-26T16:44:10.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17201" PostTypeId="1" AcceptedAnswerId="17204" CreationDate="2015-10-26T17:20:10.277" Score="0" ViewCount="219" Body="&lt;p&gt;When the 433 transmitter is wired close to the Arduino Due (within 12&quot; away), it works as expected. But when I put it on the end of a 15' cable, it has the following 2 symptoms:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-All the other nearby 433Mhz transmitters and receivers stop working. (I've never seen this happen from any other cause).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-My Extech 480836 EMF meter shows a big jump in electromagnetic radiation along the entire length of the 15' cable (it jumps from &lt;em&gt;0.1 uW/m2&lt;/em&gt; to &lt;em&gt;3 mW/m2&lt;/em&gt; a few inches away). The reading only goes down to normal if I unplug the transmitter's data wire from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transmitter in question is still able to send signals correctly when wired with a 15' cable to the Due (properly activating remote switches), even though it disables every other 433 transmitter in the area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested this with 2 different kinds of 433 transmitters, getting the same result. Both of the transmitters work fine whenever wired closely to the Arduino Due, and both work as expected when connected to an Arduino Uno. The problems still occur even if I'm not sending any wireless transmissions from the code. Disconnecting the transmitter's data wire from the Arduino Due causes the problem to stop immediately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the &lt;a href=&quot;https://github.com/sui77/rc-switch&quot; rel=&quot;nofollow&quot;&gt;RCSwitch library&lt;/a&gt;. The simple code below works fine on an Arduino Uno, whether the transmitter is wired far or close to the Uno. The same code works fine with the Due when the transmitter is close to the Due. But when the transmitter is wired 15' away from the Due, then the problems occur. On the Due I've tested using 5v and 3v for powering the transmitter. Changing the voltages doesn't seem to affect the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RCSwitch.h&amp;gt;&#xA;RCSwitch mySwitch = RCSwitch();&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  // Transmitter is connected to Arduino Pin #8 &#xA;  mySwitch.enableTransmit(8);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why am I having this strange behavior? Do you have any suggestions on how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-26T19:59:41.333" Title="433Mhz transmitter interference when using long cable, only on Arduino Due" Tags="|arduino-due|wireless|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17203" PostTypeId="1" AcceptedAnswerId="17219" CreationDate="2015-10-26T18:16:34.100" Score="0" ViewCount="3143" Body="&lt;p&gt;I want to check if a device is working or not. It is a custom made PCB with a Atmega8. It was given to me along with the AVR code. How do I read the data that it sends on my laptop using a arduino, preferably a Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried connecting the output UART pin to the Rx of the arduino, and then provided the common ground. Then I opened serial monitor on my laptop but I a m not getting anything. Is it because the PCB is damaged or am I doing it wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the AVR code which was burned on the IC, so I can provide you with more information if you need.&lt;/p&gt;&#xA;" OwnerUserId="11145" OwnerDisplayName="daltonfury42" LastActivityDate="2015-10-27T13:34:53.737" Title="How to read the serial data from a ATMEGA8 on a PC using Arduino?" Tags="|uart|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17204" PostTypeId="2" ParentId="17201" CreationDate="2015-10-26T19:59:41.333" Score="0" Body="&lt;p&gt;I think I found the problem. It seems that there's an anomaly with the Due where when a pinmode is set as OUTPUT, it sets the pin as HIGH by default, whereas with the other Arduinos it's set as LOW. This forum page is discussing the problem: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=154869.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=154869.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise this page suggests the problem is a bug with the wiring_digital.c file: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=185230.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=185230.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In RCSwitch.cpp, this is the enableTransmit code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void RCSwitch::enableTransmit(int nTransmitterPin) {&#xA;  this-&amp;gt;nTransmitterPin = nTransmitterPin;&#xA;  pinMode(this-&amp;gt;nTransmitterPin, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems the code sets the pin as OUTPUT, which would cause an anomaly on the Due alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I solved the problem by calling the enableTransmit function just before sending a signal, and then calling disableTransmit() immediately afterwards. Can anyone think of a cleaner/better solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Out of curiosity, can anyone suggest what a standard transmitter might be sending when the data line is constantly held at HIGH?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-26T19:59:41.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17205" PostTypeId="2" ParentId="15960" CreationDate="2015-10-26T21:02:35.153" Score="0" Body="&lt;p&gt;In the end I found a solution, more or less through trial and error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Labview default its VISA VIs to &quot;asynchronous&quot; mode: I found that by switching them to &quot;synchronous&quot; (right click on them and select &quot;synchronous&quot;) this problem disappeared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is caused by the computer occasionally getting ahead of the Arduino and asking for the next measurement before it's finished receiving the first one. Switching to synchronous mode forces execution to wait until the VISA exchange is complete before it continues. &lt;/p&gt;&#xA;" OwnerUserId="13301" LastActivityDate="2015-10-26T21:02:35.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17206" PostTypeId="1" AcceptedAnswerId="17245" CreationDate="2015-10-26T21:52:20.857" Score="1" ViewCount="663" Body="&lt;p&gt;I'm quite a newbie to this and I've been struggling for sometime now with my school project, trying to find a way to send accelerometer data from my MMA7361 in data packets, I understand that I have to send the data in packets, but I'm having problems going about it. One of the requirements of the project is that I have to send the data in array-packets of all the individual axes (e.g. a buffer array to hold the x-axis value, another for the y-axis value and also for the z-axis value). I have read quite a lot of documentation on the internet about this  but putting it together is a challenge. Below is the infamous MMA7361 code sketch, do please help out if you can thankyou. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;AcceleroMMA7361.h&amp;gt;&#xA;&#xA;    AcceleroMMA7361 accelero;&#xA;    int x;&#xA;    int y;&#xA;    int z;&#xA;&#xA;    void setup(){&#xA;        Serial.begin(9600);&#xA;        accelero.begin(13, 12, 11, 10, A0, A1, A2);&#xA;        accelero.setARefVoltage(3.3);     //sets the AREF voltage   to 3.3V&#xA;        accelero.setSensitivity(LOW);           //sets the sensitivity to +/-6G&#xA;        accelero.calibrate();&#xA;    }&#xA;&#xA;    void loop(){&#xA;        x = accelero.getXRaw();&#xA;        y = accelero.getYRaw();&#xA;        z = accelero.getZRaw();&#xA;        Serial.print(&quot;\nx: &quot;);&#xA;        Serial.print(x);&#xA;        Serial.print(&quot;\ty: &quot;);&#xA;        Serial.print(y);&#xA;        Serial.print(&quot;\tz: &quot;);&#xA;        Serial.print(z);&#xA;        delay(500);                                     //(make it readable)&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="14350" LastEditDate="2015-10-29T23:21:45.893" LastActivityDate="2015-10-29T23:21:45.893" Title="pushing accelerometer data in packets from an arduino due to the pc and unto processing" Tags="|c++|arduino-due|datalogging|processing-lang|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17207" PostTypeId="2" ParentId="17189" CreationDate="2015-10-26T21:52:48.403" Score="0" Body="&lt;p&gt;An alternative way of seeing the two operations is through the operators &quot;integer division&quot; and &quot;reminder of the integer division&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a more generic fashion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#include &amp;lt;limits.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#define highBits(value, number_of_high_bits) \&#xA; (value / (1 &amp;lt;&amp;lt; (sizeof(value) * CHAR_BIT - number_of_high_bits)))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;#define lowBits(value, number_of_high_bits) \&#xA; (value % (1 &amp;lt;&amp;lt; (sizeof(value) * CHAR_BIT - number_of_high_bits)))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will work regardless the number of bits used for &lt;code&gt;value&lt;/code&gt; and with an arbitrary number of &lt;code&gt;high_bits&lt;/code&gt; to either keep or shave.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-26T21:52:48.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17208" PostTypeId="2" ParentId="17203" CreationDate="2015-10-26T21:54:56.253" Score="0" Body="&lt;p&gt;You can download this example code to your Arduino UNO...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure the baud rate on the line &lt;code&gt;mySerial.begin(4800)&lt;/code&gt; to match the baud rate your device is sending. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then run &quot;Serial Terminal&quot; from the Arduino IDE and connect the output of your device to pin 10 on the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the baud rate is correct, you should see the Serial output from your device in the serial terminal window. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Why you might not want to direct connect&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here is the schematic of the serial port section of the Arduino UNO...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qRkWM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qRkWM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX pin on the header is connected directly connected to the TXD/PD1 pin on the ATMEGA chip as highlighted in red. This pin will be actively driven if any of the following happen...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is a sketch running on the Arduino than enables the serial port (i.e. includes &lt;code&gt;Serial.begin()&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;There is a sketch running on the Arduino that enables pin 1 as output (i.e. includes &lt;code&gt;pinMode(1,OUTPUT);&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;The Arduino reboots and runs the bootloader, which always briefly enables the serial port on startup. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are some devices that can be permanently damaged by having their serial output tied to an actively driven signal, especially a +5 volt one like we have here. The BBB is one of them (I know from experience!). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One response suggested downloading the &lt;code&gt;BlinkMe&lt;/code&gt; sketch into the Arduino, presumably to make sure there is not another sketch running that could enable the serial port. This is the right idea, but you have to keep in mind that the UNO will &lt;a href=&quot;https://arduino.stackexchange.com/questions/439/why-does-starting-the-serial-monitor-restart-the-sketch&quot;&gt;reboot anytime the RTS line is toggled&lt;/a&gt;. Here is a not-so-far-fetched scenario...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You load &lt;code&gt;BlinkMe&lt;/code&gt; into the UNO.&lt;/li&gt;&#xA;&lt;li&gt;You connect the device to the TX pin on the UNO.&lt;/li&gt;&#xA;&lt;li&gt;You launch &lt;code&gt;Tools-Serial Monitor&lt;/code&gt; from the Arduino IDE to see the serial data. &lt;/li&gt;&#xA;&lt;li&gt;The Serial Monitor window opens and toggles the RTS line (does this every time you launch it). &lt;/li&gt;&#xA;&lt;li&gt;The UNO reboots.&lt;/li&gt;&#xA;&lt;li&gt;The bootloader runs and enables the serial port on the ATMEGA.&lt;/li&gt;&#xA;&lt;li&gt;The connected device is cooked.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also keep in mind that even if the attached device can tolerate being connected to an actively driven signal, once you connect another signal to the Arduino TX pin then you loose the ability to communicate with the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Loading the &lt;code&gt;Softserial&lt;/code&gt; sketch takes the same number of steps as loading the &lt;code&gt;BlinkMe&lt;/code&gt; sketch, reduces the chance of of damaging the connected device, and also allows you to keep access to the Arduino while you are doing all this. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-10-27T13:34:53.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17209" PostTypeId="2" ParentId="3350" CreationDate="2015-10-26T22:05:57.783" Score="1" Body="&lt;p&gt;There is something quite close to what you are asking.&#xA;You need either the (more expensive) ICEMKII (iirc) or the (cheaper) AVRDragon.&#xA;Then it's possible to &lt;a href=&quot;http://awtfy.com/category/microcontrollers/&quot; rel=&quot;nofollow&quot;&gt;use&lt;/a&gt; it with gdb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice the AVR supports only one breakpoint, so what happens is that the binary in flash will be dynamically patched.&#xA;This will slightly reduce the life of the AVR, but I think it's fairly acceptable. One can always use Arduino UNO with the original DIP package for AVR, mounted on a socket. Then it's sufficient to replace the burnt microcontroller and keep the rest (but it's hundreds of thousands of programming cycles before the AVR fails).&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-26T22:05:57.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17210" PostTypeId="1" CreationDate="2015-10-26T23:32:39.007" Score="1" ViewCount="993" Body="&lt;p&gt;I have a limit switch attached to an arduino Mega 2650 for motion control. The limit switch's two Normally Open contacts are connected to an Arduino Pin and ground, such that when the Limit Switch is engaged, the Arduino Pin gets short circuited to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As expected, I have bouncing issues with this setup. I confirmed it using counters in my ISRs. Finally, I wrote the following code that seems to reliably identify whether my limit switch is engaged or disengaged at any given point in time. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int lsOuterLeftIn = 18; // lsOuterLeftIn is my Limit Switch&#xA;const int LED = 9;&#xA;volatile bool lsEngaged = false; // flag for limit switch engaged&#xA;void setup() {&#xA;    pinMode(lsOuterLeftIn, INPUT_PULLUP);&#xA;    pinMode(LED, OUTPUT);&#xA;    attachInterrupt(digitalPinToInterrupt(lsOuterLeftIn), ISR1, FALLING);&#xA;    attachInterrupt(digitalPinToInterrupt(lsOuterLeftIn), ISR2, RISING);&#xA;}&#xA;void  loop() {&#xA;    if (lsEngaged) digitalWrite(LED, HIGH);&#xA;    else digitalWrite(LED, LOW);&#xA;}&#xA;void ISR1(){&#xA;    delay(100);&#xA;    lsEngaged = (digitalRead(lsOuterLeftIn));&#xA;}&#xA;void ISR2(){&#xA;    delay(100);&#xA;    lsEngaged = (digitalRead(lsOuterLeftIn));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, here is my problem. I came upon this &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;Arduino documentation page&lt;/a&gt;, and it says &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Since delay() requires interrupts to work, it will not work if called inside an ISR. &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, I do make use of &lt;code&gt;delay()&lt;/code&gt; inside ISRs and it seems to work, what is going on? Do I have a situation where things are working at the moment, but could break easily because the &lt;code&gt;delay()&lt;/code&gt; function could malfunction on me as the documentation says? &lt;/p&gt;&#xA;" OwnerUserId="12134" LastEditorUserId="12134" LastEditDate="2015-10-26T23:38:49.687" LastActivityDate="2015-11-26T12:48:34.103" Title="Debouncing a limit switch in Arduino ISR with delays" Tags="|arduino-uno|arduino-mega|interrupt|button|debounce|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17211" PostTypeId="1" AcceptedAnswerId="17215" CreationDate="2015-10-27T01:25:42.373" Score="1" ViewCount="231" Body="&lt;p&gt;I would like to know of references that discuss the process of uploading code onto an Arduino board. I have read this &lt;a href=&quot;https://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;reference&lt;/a&gt; on hacking the Arduino and an outline of the build process. I also found this &lt;a href=&quot;https://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;segment&lt;/a&gt; on creating Arduino libraries informative. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall I am interested in tracing through an upload process to learn more detail about how the programming works. I would like to understand which C-libraries are used. I would like to understand how the code is uploaded onto the Arduino. One example that I would like to see is an direct upload of C or C++ code without using the IDE gui. I want to see kind of the &quot;bare-minimum&quot; necessary for programming the Arduino (in C/C++). I would ideally like to read about something like this which makes use of the Arduino libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking forward to hearing back responses, and being a part of this community. Any references and comments appreciated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #1&lt;/strong&gt; (request for more information from the accepted answer):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;How does the main sketch trace through the C/C++ code?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the make file shown in the accepted answer: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;$(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;$(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Does part of the main sketch transfer through in the compilation of malloc.c and realloc.c (as well as the c/c++ files)?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would think so, being that it is compiled every time we change the main sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Lastly, how is the outputted .hex file uploaded to the board?&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #2&lt;/strong&gt; Trouble compiling with make method&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am having issues with the manual compiling process, I am using &lt;em&gt;Arduino 1.6.5 r5&lt;/em&gt;. It seems that &lt;em&gt;malloc.c&lt;/em&gt; and &lt;em&gt;realloc.c&lt;/em&gt; are not in the same place as they were in IDE 1.0.6.. Here is the makefile. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;#&#xA;# Edited by: Kyle Lawlor&#xA;# Date: 30th October 2015&#xA;&#xA;$H# where you installed the Arduino app&#xA;ARDUINO_DIR = /home/wiz/programs/arduino-1.6.5-r5/&#xA;&#xA;# various programs&#xA;CC = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&quot;&#xA;CPP = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&quot;&#xA;AR = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&quot;&#xA;OBJ_COPY = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&quot;&#xA;&#xA;# create a file called Blink.cpp in same base dir&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &quot;-I$(ARDUINO_DIR)hardware/arduino/avr/cores/arduino&quot; &quot;-I$(ARDUINO_DIR)hardware/arduino/avr/variants/standard&quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &quot;$(ARDUINO_DIR)hardware/arduino/avr/cores/arduino/&quot;&#xA;&#xA;build:&#xA;&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;#   $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;#   $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o&#xA;    rm core.a&#xA;#   $(AR) rcs core.a malloc.c.o&#xA;#   $(AR) rcs core.a realloc.c.o&#xA;    $(AR) rcs core.a WInterrupts.c.o&#xA;    $(AR) rcs core.a wiring.c.o&#xA;    $(AR) rcs core.a wiring_analog.c.o&#xA;    $(AR) rcs core.a wiring_digital.c.o&#xA;    $(AR) rcs core.a wiring_pulse.c.o&#xA;    $(AR) rcs core.a wiring_shift.c.o&#xA;    $(AR) rcs core.a CDC.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial.cpp.o&#xA;    $(AR) rcs core.a HID.cpp.o&#xA;    $(AR) rcs core.a IPAddress.cpp.o&#xA;    $(AR) rcs core.a main.cpp.o&#xA;    $(AR) rcs core.a new.cpp.o&#xA;    $(AR) rcs core.a Print.cpp.o&#xA;    $(AR) rcs core.a Stream.cpp.o&#xA;    $(AR) rcs core.a Tone.cpp.o&#xA;    $(AR) rcs core.a USBCore.cpp.o&#xA;    $(AR) rcs core.a WMath.cpp.o&#xA;    $(AR) rcs core.a WString.cpp.o&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The build fails unless the lines involving those two functions are commented out. I searched in the directories but had no luck in finding the libraries, so I decided to move forward in testing things out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the file I am using as &lt;em&gt;Blink.cpp&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void setup(){&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    delay(1000);              // wait for a second&#xA;    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;    delay(1000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again, the &lt;em&gt;build does compile&lt;/em&gt; ignoring &lt;em&gt;malloc&lt;/em&gt; and &lt;em&gt;realloc&lt;/em&gt;. I am unsure of whether these are critical libraries as I am not very familiar with C/C++. While the libraries do compile, &lt;em&gt;there is an error&lt;/em&gt; derived from the &lt;code&gt;delay()&lt;/code&gt; function in &lt;em&gt;Blink.cpp&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;/home/wiz/programs/arduino-1.6.5-r5/hardware/tools/avr/bin/avr-gcc&quot; -Os -Wl,--gc-sections -mmcu=atmega328p -o Blink.cpp.elf Blink.cpp.o core.a -lm&#xA;core.a(wiring.c.o): In function `delay':&#xA;/home/wiz/programs/arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino/wiring.c:113: undefined reference to `yield'&#xA;collect2: error: ld returned 1 exit status&#xA;make: *** [build] Error 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am unsure at this point whether or not this error is related to the fact that &lt;em&gt;malloc&lt;/em&gt; and &lt;em&gt;realloc&lt;/em&gt; have not been compiled. I have traced back into the &lt;em&gt;wiring.c&lt;/em&gt; file to find out where &lt;code&gt;yield()&lt;/code&gt; was. That file starts with an &lt;code&gt;#include &quot;wiring_private.h&quot;&lt;/code&gt; and here is the delay function and yield:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void delay(unsigned long ms)&#xA;{&#xA;        uint16_t start = (uint16_t)micros();&#xA;&#xA;        while (ms &amp;gt; 0) {&#xA;                yield();&#xA;                if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA;                        ms--;&#xA;                        start += 1000;&#xA;                }&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the include statements from the &lt;em&gt;wiring_private.h&lt;/em&gt; header. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;stdarg.h&amp;gt;&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps on of these contain the &lt;code&gt;yield()&lt;/code&gt; function, which is not being seen correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any advice for what I am doing wrong regarding building manually with 1.6.5? Any comments or further comments will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #3&lt;/strong&gt; Identified where &lt;code&gt;yield()&lt;/code&gt; function is located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Project directory:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;├── abi.cpp&#xA;├── Arduino.h&#xA;├── binary.h&#xA;├── Blink.cpp&#xA;├── Blink.cpp.d&#xA;├── Blink.cpp.o&#xA;├── CDC.cpp&#xA;├── CDC.cpp.d&#xA;├── CDC.cpp.o&#xA;├── Client.h&#xA;├── core.a&#xA;├── HardwareSerial0.cpp&#xA;├── HardwareSerial1.cpp&#xA;├── HardwareSerial2.cpp&#xA;├── HardwareSerial3.cpp&#xA;├── HardwareSerial.cpp&#xA;├── HardwareSerial.cpp.d&#xA;├── HardwareSerial.cpp.o&#xA;├── HardwareSerial.h&#xA;├── HardwareSerial_private.h&#xA;├── HID.cpp&#xA;├── HID.cpp.d&#xA;├── HID.cpp.o&#xA;├── hooks.c&#xA;├── IPAddress.cpp&#xA;├── IPAddress.cpp.d&#xA;├── IPAddress.cpp.o&#xA;├── IPAddress.h&#xA;├── main.cpp&#xA;├── main.cpp.d&#xA;├── main.cpp.o&#xA;├── new.cpp&#xA;├── new.cpp.d&#xA;├── new.cpp.o&#xA;├── new.h&#xA;├── Printable.h&#xA;├── Print.cpp&#xA;├── Print.cpp.d&#xA;├── Print.cpp.o&#xA;├── Print.h&#xA;├── run.mk&#xA;├── run.mk~&#xA;├── Server.h&#xA;├── Stream.cpp&#xA;├── Stream.cpp.d&#xA;├── Stream.cpp.o&#xA;├── Stream.h&#xA;├── Tone.cpp&#xA;├── Tone.cpp.d&#xA;├── Tone.cpp.o&#xA;├── Udp.h&#xA;├── USBAPI.h&#xA;├── USBCore.cpp&#xA;├── USBCore.cpp.d&#xA;├── USBCore.cpp.o&#xA;├── USBCore.h&#xA;├── USBDesc.h&#xA;├── WCharacter.h&#xA;├── WInterrupts.c&#xA;├── WInterrupts.c.d&#xA;├── WInterrupts.c.o&#xA;├── wiring_analog.c&#xA;├── wiring_analog.c.d&#xA;├── wiring_analog.c.o&#xA;├── wiring.c&#xA;├── wiring.c.d&#xA;├── wiring.c.o&#xA;├── wiring_digital.c&#xA;├── wiring_digital.c.d&#xA;├── wiring_digital.c.o&#xA;├── wiring_private.h&#xA;├── wiring_pulse.c&#xA;├── wiring_pulse.c.d&#xA;├── wiring_pulse.c.o&#xA;├── wiring_pulse.S&#xA;├── wiring_shift.c&#xA;├── wiring_shift.c.d&#xA;├── wiring_shift.c.o&#xA;├── WMath.cpp&#xA;├── WMath.cpp.d&#xA;├── WMath.cpp.o&#xA;├── WString.cpp&#xA;├── WString.cpp.d&#xA;├── WString.cpp.o&#xA;└── WString.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;yield()&lt;/code&gt; is located in &lt;em&gt;hooks.c&lt;/em&gt;. I do not understand why the function is not available to &lt;em&gt;wiring.c&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #4&lt;/strong&gt; Compilation working&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Structure of &lt;em&gt;arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.&#xA;├── abi.cpp&#xA;├── Arduino.h&#xA;├── binary.h&#xA;├── CDC.cpp&#xA;├── Client.h&#xA;├── HardwareSerial0.cpp&#xA;├── HardwareSerial1.cpp&#xA;├── HardwareSerial2.cpp&#xA;├── HardwareSerial3.cpp&#xA;├── HardwareSerial.cpp&#xA;├── HardwareSerial.h&#xA;├── HardwareSerial_private.h&#xA;├── HID.cpp&#xA;├── hooks.c&#xA;├── IPAddress.cpp&#xA;├── IPAddress.h&#xA;├── main.cpp&#xA;├── new.cpp&#xA;├── new.h&#xA;├── Printable.h&#xA;├── Print.cpp&#xA;├── Print.h&#xA;├── Server.h&#xA;├── Stream.cpp&#xA;├── Stream.h&#xA;├── Tone.cpp&#xA;├── Udp.h&#xA;├── USBAPI.h&#xA;├── USBCore.cpp&#xA;├── USBCore.h&#xA;├── USBDesc.h&#xA;├── WCharacter.h&#xA;├── WInterrupts.c&#xA;├── wiring_analog.c&#xA;├── wiring.c&#xA;├── wiring_digital.c&#xA;├── wiring_private.h&#xA;├── wiring_pulse.c&#xA;├── wiring_pulse.S&#xA;├── wiring_shift.c&#xA;├── WMath.cpp&#xA;├── WString.cpp&#xA;└── WString.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason the &lt;code&gt;yield()&lt;/code&gt; function was not recognized was because I was not compiling with &lt;em&gt;1.6.5&lt;/em&gt; correctly. Below is an updated &lt;em&gt;makefile&lt;/em&gt; that compiles the &lt;em&gt;Blink.cpp&lt;/em&gt; seemingly correct. I have yet to verify the sketch works on upload to the Arduino (via &lt;code&gt;avrdude&lt;/code&gt;). The mistake was that I did not compile &lt;code&gt;abi.cpp&lt;/code&gt;, &lt;code&gt;HardwareSerialx.cpp&lt;/code&gt;(0-3), and &lt;code&gt;hooks.c&lt;/code&gt;. &lt;code&gt;hooks.c&lt;/code&gt; is where the &lt;code&gt;yield()&lt;/code&gt; is located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Updated &lt;em&gt;makefile&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;#&#xA;# Edited by: Kyle Lawlor&#xA;# Date: 30th October 2015&#xA;&#xA;$H# where you installed the Arduino app&#xA;ARDUINO_DIR = /home/wiz/programs/arduino-1.6.5-r5/&#xA;&#xA;# various programs&#xA;CC = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&quot;&#xA;CPP = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&quot;&#xA;AR = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&quot;&#xA;OBJ_COPY = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&quot;&#xA;&#xA;# create a file called Blink.cpp in same base dir&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &quot;-I$(ARDUINO_DIR)hardware/arduino/avr/cores/arduino&quot; &quot;-I$(ARDUINO_DIR)hardware/arduino/avr/variants/standard&quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &quot;$(ARDUINO_DIR)hardware/arduino/avr/cores/arduino/&quot;&#xA;&#xA;build:&#xA;&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;#   $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;#   $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)hooks.c -o hooks.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)abi.cpp -o abi.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial0.cpp -o HardwareSerial0.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial1.cpp -o HardwareSerial1.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial2.cpp -o HardwareSerial2.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial3.cpp -o HardwareSerial3.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o&#xA;    rm core.a&#xA;#   $(AR) rcs core.a malloc.c.o&#xA;#   $(AR) rcs core.a realloc.c.o&#xA;    $(AR) rcs core.a hooks.c.o&#xA;    $(AR) rcs core.a WInterrupts.c.o&#xA;    $(AR) rcs core.a wiring.c.o&#xA;    $(AR) rcs core.a wiring_analog.c.o&#xA;    $(AR) rcs core.a wiring_digital.c.o&#xA;    $(AR) rcs core.a wiring_pulse.c.o&#xA;    $(AR) rcs core.a wiring_shift.c.o&#xA;    $(AR) rcs core.a abi.cpp.o&#xA;    $(AR) rcs core.a CDC.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial0.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial1.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial2.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial3.cpp.o&#xA;    $(AR) rcs core.a HID.cpp.o&#xA;    $(AR) rcs core.a IPAddress.cpp.o&#xA;    $(AR) rcs core.a main.cpp.o&#xA;    $(AR) rcs core.a new.cpp.o&#xA;    $(AR) rcs core.a Print.cpp.o&#xA;    $(AR) rcs core.a Stream.cpp.o&#xA;    $(AR) rcs core.a Tone.cpp.o&#xA;    $(AR) rcs core.a USBCore.cpp.o&#xA;    $(AR) rcs core.a WMath.cpp.o&#xA;    $(AR) rcs core.a WString.cpp.o&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are &lt;em&gt;malloc.c&lt;/em&gt; and &lt;em&gt;realloc.c&lt;/em&gt; being used anymore? I searched across &lt;em&gt;1.6.5&lt;/em&gt; for a directory similar to &lt;em&gt;avr-libc&lt;/em&gt;, I couldn't find anything. I'm guessing they are no longer in use. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #5&lt;/strong&gt; Upload via &lt;em&gt;avrdude&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically this command worked for my board (Arduino Uno SMD):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -v -p atmega328p -c arduino -P /dev/ttyACM0 -b 115200 -D -U flash:w:/path/to/Blink.cpp.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is all to say that the latter makefile in this post correctly builds the &lt;em&gt;.hex&lt;/em&gt; file. Which can then successfully be uploaded onto the board. (Using Arduino 1.6.5).&lt;/p&gt;&#xA;" OwnerUserId="13854" LastEditorUserId="13854" LastEditDate="2015-11-01T21:50:53.520" LastActivityDate="2015-11-01T21:50:53.520" Title="Requesting references for learning about the upload process" Tags="|uploading|core-libraries|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17212" PostTypeId="1" CreationDate="2015-10-27T02:29:24.847" Score="0" ViewCount="564" Body="&lt;p&gt;Im getting stuck in a while loop because Im having trouble running a calculation on some sensor values. When I read my four sensors values and compare the ratio of the first two to the second two, I keep getting 0.00, no matter what the values are. Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while ( ( (frontleft + frontright) / (backleft + backright) &amp;lt;= 0.8 ) || ( (frontleft + frontright) / (backleft + backright) &amp;gt; 1.2) ) {&#xA;    if (backleft + backright &amp;gt; frontleft + frontright) {&#xA;      myStepper2.step(10);&#xA;    }&#xA;    if (backleft + backright &amp;lt; frontleft + frontright) {&#xA;      myStepper2.step(-10);&#xA;    }&#xA;    int backleft = analogRead(A0);&#xA;    int backright = analogRead(A1);&#xA;    int frontleft = analogRead(A2);&#xA;    int frontright = analogRead(A3);   &#xA;&#xA;    Serial.print(&quot;Backleft Reading: &quot;);&#xA;    Serial.println(backleft);&#xA;    Serial.print(&quot;\n&quot;);&#xA;    Serial.print(&quot;BackRight Reading: &quot;);&#xA;    Serial.println(backright);&#xA;    Serial.print(&quot;\n&quot;);&#xA;    Serial.print(&quot;Frontleft Reading: &quot;);&#xA;    Serial.println(frontleft);&#xA;    Serial.print(&quot;\n&quot;);&#xA;    Serial.print(&quot;Frontright Reading: &quot;);&#xA;    Serial.println(frontright);&#xA;    Serial.print(&quot;\n&quot;);&#xA;    float ratio = (frontleft + frontright) / (backleft + backright);&#xA;    float math = (5 + 6) / (4 + 5);&#xA;    Serial.print(&quot;Math: &quot;);&#xA;    Serial.println(math);&#xA;    Serial.print(&quot;Ratio: &quot;);&#xA;    Serial.println(ratio);&#xA;    Serial.print(&quot;\n&quot;);&#xA;    delay(500);&#xA;&#xA;  }    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Im getting values for my sensors (backleft, backright, frontleft, frontright), but 'ratio' always comes out 0.00. Because of that, Im getting trapped in the loop I believe. What's going on here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, just to check, I added 'math' float as that quick calculation, but I'm getting a value of 1.00 in Serial Monitor. Why? It should be 1.222.&lt;/p&gt;&#xA;" OwnerUserId="14356" LastActivityDate="2015-10-27T04:59:04.013" Title="Math with analog input values coming out wrong" Tags="|arduino-uno|c++|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17213" PostTypeId="2" ParentId="17147" CreationDate="2015-10-27T04:05:31.717" Score="3" Body="&lt;p&gt;I have been playing with an ESP8266 over the last couple of days with similar results. My conclusion was that it is very timing dependent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you build in (fairly large) delays into your code then you will find it works better. The delays are effectively what you are doing as you type in each new command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found, for example, that the &lt;code&gt;AT+CWJAP&lt;/code&gt; (join access point) command takes quite a while, like 10 seconds or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preferably don't use &quot;actual&quot; delays because they are blocking (unless you don't care about that). You could have a list of commands you want to send, and a system that pulls the next one out of the list when a certain time has elapsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use something like 5 to 10 second delays between commands you should get better results. At the very least, after sending one command, look for a confirmation string from the device (eg. &lt;code&gt;OK&lt;/code&gt;, &lt;code&gt;ERROR&lt;/code&gt; etc.).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-27T04:05:31.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17214" PostTypeId="2" ParentId="17212" CreationDate="2015-10-27T04:59:04.013" Score="1" Body="&lt;p&gt;Read this: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12146&quot; rel=&quot;nofollow&quot;&gt;Integer arithmetic and overflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float math = (5 + 6) / (4 + 5);&#xA;Serial.print(&quot;Math: &quot;);&#xA;Serial.println(math);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The compiler is treating your expression (the RH side of the &quot;=&quot; sign) as &lt;strong&gt;integers&lt;/strong&gt;. Thus it is working out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11 / 9 = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you assign that &lt;code&gt;1&lt;/code&gt; to a float. Too late to make it a float! It is already truncated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float math = float (5 + 6) / float (4 + 5);&#xA;Serial.print(&quot;Math: &quot;);&#xA;Serial.println(math, 4);  // 4 decimal places&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Math: 1.2222&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This also looks wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while ( ( (frontleft + frontright) / (backleft + backright) &amp;lt;= 0.8 ) || ( (frontleft + frontright) / (backleft + backright) &amp;gt; 1.2) ) {&#xA;    if (backleft + backright &amp;gt; frontleft + frontright) {&#xA;      myStepper2.step(10);&#xA;    }&#xA;    if (backleft + backright &amp;lt; frontleft + frontright) {&#xA;      myStepper2.step(-10);&#xA;    }&#xA;    int backleft = analogRead(A0);&#xA;    int backright = analogRead(A1);&#xA;    int frontleft = analogRead(A2);&#xA;    int frontright = analogRead(A3);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How many &lt;code&gt;backleft&lt;/code&gt; variables do you have? The one in the &lt;code&gt;while&lt;/code&gt; instruction will &lt;strong&gt;not&lt;/strong&gt; be the one you are doing the analogRead on. It doesn't &quot;forward read&quot; variables. I bet you have a different &lt;code&gt;frontleft&lt;/code&gt; / &lt;code&gt;backleft&lt;/code&gt; etc. set of variables declared earlier. These will &lt;strong&gt;not&lt;/strong&gt; be updated inside the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(To make them get updated drop the word &lt;code&gt;int&lt;/code&gt; from inside the loop).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-27T04:59:04.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17215" PostTypeId="2" ParentId="17211" CreationDate="2015-10-27T06:10:45.263" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I am interested in tracing through an upload process to learn more detail ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I covered the uploading process in some detail here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I would like to understand which C-libraries are used&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;See my post about &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-i-actually-need-to-use-them&quot;&gt;How the IDE organizes things&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;One example that I would like to see is an direct upload of C or C++ code without using the IDE gui.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I wrote a simple Makefile on the &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=308853.msg2145054#msg2145054&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Forum&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;&#xA;# where you installed the Arduino app&#xA;ARDUINO_DIR = C:/Documents and Settings/Nick/Desktop/arduino-1.0.6/&#xA;&#xA;# various programs&#xA;CC = &amp;quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&amp;quot;&#xA;CPP = &amp;quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&amp;quot;&#xA;AR = &amp;quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&amp;quot;&#xA;OBJ_COPY = &amp;quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&amp;quot;&#xA;&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &amp;quot;-I$(ARDUINO_DIR)hardware/arduino/cores/arduino&amp;quot; &amp;quot;-I$(ARDUINO_DIR)hardware/arduino/variants/standard&amp;quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &amp;quot;$(ARDUINO_DIR)hardware/arduino/cores/arduino/&amp;quot;&#xA;&#xA;build:&#xA;    &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o&#xA;    rm core.a&#xA;    $(AR) rcs core.a malloc.c.o&#xA;    $(AR) rcs core.a realloc.c.o&#xA;    $(AR) rcs core.a WInterrupts.c.o&#xA;    $(AR) rcs core.a wiring.c.o&#xA;    $(AR) rcs core.a wiring_analog.c.o&#xA;    $(AR) rcs core.a wiring_digital.c.o&#xA;    $(AR) rcs core.a wiring_pulse.c.o&#xA;    $(AR) rcs core.a wiring_shift.c.o&#xA;    $(AR) rcs core.a CDC.cpp.o&#xA;    $(AR) rcs core.a HardwareSerial.cpp.o&#xA;    $(AR) rcs core.a HID.cpp.o&#xA;    $(AR) rcs core.a IPAddress.cpp.o&#xA;    $(AR) rcs core.a main.cpp.o&#xA;    $(AR) rcs core.a new.cpp.o&#xA;    $(AR) rcs core.a Print.cpp.o&#xA;    $(AR) rcs core.a Stream.cpp.o&#xA;    $(AR) rcs core.a Tone.cpp.o&#xA;    $(AR) rcs core.a USBCore.cpp.o&#xA;    $(AR) rcs core.a WMath.cpp.o&#xA;    $(AR) rcs core.a WString.cpp.o&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are quite a few more complex ones around.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I want to see kind of the &amp;quot;bare-minimum&amp;quot; necessary for programming the Arduino (in C/C++).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA; {&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Does part of the main sketch transfer through in the compilation of malloc.c and realloc.c (as well as the c/c++ files)?&lt;/p&gt;&#xA;&lt;p&gt;I would think so, being that it is compiled every time we change the main sketch.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm not sure I understand the part about &amp;quot;transfer through&amp;quot; but basically functions which are needed in the main sketch are linked into the combined file by the linker.&lt;/p&gt;&#xA;&lt;p&gt;Effectively these are the main parts:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Compile main sketch&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;&#xA;# Compile libraries&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o&#xA;...&#xA;&#xA;# Remove temporary &amp;quot;combined libraries&amp;quot; file&#xA;    rm core.a&#xA;&#xA;# Add compiled libraries into combined file &amp;quot;core.a&amp;quot;&#xA;    $(AR) rcs core.a malloc.c.o&#xA;    $(AR) rcs core.a realloc.c.o&#xA;...&#xA;&#xA;# Link main sketch to combined libraries (linker will discard things not needed)&#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm&#xA;&#xA;# Make an .eep (EEPROM) file&#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep&#xA;&#xA;# Make the main .hex file&#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Lastly, how is the outputted .hex file uploaded to the board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There are various ways of achieving this. The IDE calls the program &lt;code&gt;avrdude&lt;/code&gt; which is designed to upload a .hex file to a processor. You can also just copy the .hex file to an SD card and upload it using a board programmer.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Are malloc.c and realloc.c being used anymore?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;They &lt;strong&gt;are&lt;/strong&gt; being used, the trick is to find them.&lt;/p&gt;&#xA;&lt;p&gt;I can't see them being directly linked in a 1.6.5 compiler output, so I am assuming (I can't prove it right now) that they are linked in by default from libc.a (the default C library). Being a default library it is not mentioned on the linker line.&lt;/p&gt;&#xA;&lt;p&gt;In my (Linux) installation I found that library here:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;~/Development/arduino-1.6.5-r5/hardware/tools/avr/avr/lib/libc.a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you do a &lt;code&gt;nm&lt;/code&gt; on it you find this (amongst other things):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;malloc.o:&#xA;00000002 C __brkval&#xA;         U __do_clear_bss&#xA;         U __do_copy_data&#xA;00000002 C __flp&#xA;00000146 T free&#xA;         U __heap_end&#xA;         U __heap_start&#xA;00000000 T malloc&#xA;00000000 D __malloc_heap_end&#xA;00000002 D __malloc_heap_start&#xA;00000004 D __malloc_margin&#xA;0000003e a __SP_H__&#xA;0000003d a __SP_L__&#xA;0000003f a __SREG__&#xA;00000000 a __tmp_reg__&#xA;00000001 a __zero_reg__&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From &lt;code&gt;man nm&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;quot;D&amp;quot;&#xA;  &amp;quot;d&amp;quot; The symbol is in the initialized data section.&#xA; ...&#xA;  &amp;quot;T&amp;quot;&#xA;  &amp;quot;t&amp;quot; The symbol is in the text (code) section.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_17.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_17.html&lt;/a&gt; :&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The C standard library itself is stored in '/usr/lib/libc.a' and contains functions specified in the ANSI/ISO C standard, such as 'printf'---this library is linked by default for every C program.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;I am guessing here that &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; moved into the standard (default) library since version 1.0.6 (or they wanted to override it with a bugfix) and it is now being found, by default, in the standard C library as described above.&lt;/p&gt;&#xA;&lt;p&gt;You should be able to find more about AVR libc at its page: &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.nongnu.org/avr-libc/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-11-01T21:06:40.827" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17216" PostTypeId="1" CreationDate="2015-10-27T09:12:56.917" Score="0" ViewCount="232" Body="&lt;p&gt;I have an atmega328p (running on it's internal 8mhz clock) receiving data over rf. I need the data received to be communicated to the raspberry pi 2 using its gpio pins, I cannot use USB. I don't have the budget for a gertduino. Is there any way to do this directly? I only need to be able to receive serial output on the pi, no uploading sketches.&lt;/p&gt;&#xA;" OwnerUserId="14362" LastActivityDate="2015-11-26T09:47:32.683" Title="atmega328 raspberry pi 2 communication" Tags="|serial|atmega328|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17217" PostTypeId="2" ParentId="17216" CreationDate="2015-10-27T09:21:37.350" Score="1" Body="&lt;p&gt;Both the Arduino and the Raspberry PI have interfaces like SPI, I2C and UART. These interfaces will make it easy for you to communicate between the two. I suggest you search for UART unless you need a very high data throughput, then you need to go for SPI. But unless you want to send over a thousand messages per second UART will work just fine.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-10-27T09:21:37.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17218" PostTypeId="1" CreationDate="2015-10-27T09:24:09.497" Score="1" ViewCount="1451" Body="&lt;p&gt;I want to dim 24 LEDs which are powered by a transformer outputting 24V 6W at 0.25A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am worried about temperatures, especially considering the circuit has to stay on for several hours keeping the LEDs off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would a TIP122 transistor be ok?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips for keeping the transistor off until the dimming process starts?&lt;/p&gt;&#xA;" OwnerUserId="14363" LastActivityDate="2015-10-27T12:10:19.373" Title="Dimming 6W (24V DC 0.25A) LEDs using Arduino" Tags="|led|pwm|transistor|arduino-duemilanove|heat|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17219" PostTypeId="2" ParentId="17203" CreationDate="2015-10-27T09:26:37.403" Score="1" Body="&lt;p&gt;If you connect the TX pin on your device to the 'TX' pin on the Arduino, then load a sketch such as 'blink' that won't initialize the Arduino's own UART, you can use the Arduino's onboard USB-UART adapter to talk to your device.&lt;/p&gt;&#xA;" OwnerUserId="6302" LastActivityDate="2015-10-27T09:26:37.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17220" PostTypeId="2" ParentId="17218" CreationDate="2015-10-27T12:10:19.373" Score="1" Body="&lt;p&gt;I would suggest using the &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/CAT4101-D.PDF&quot; rel=&quot;nofollow&quot;&gt;CAT4101&lt;/a&gt; constant current sink PWM LED driver.  It can handle up to 1A at up to 25V and deals with the constant current regulation for you - just provide at least the 24V you need and enough current capacity and connect the correctly calculated current setting resistor and the CAT4101 will do the rest for you.  You can then control it through the PWM input pin direct from the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-27T12:10:19.373" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17221" PostTypeId="2" ParentId="17210" CreationDate="2015-10-27T12:29:50.057" Score="1" Body="&lt;p&gt;What you can do (and is anyway far better than waiting in interrupt context), is to have a volatile variable, which you set in the interrupt (say to 1) and in the main loop you check it: once it is set, you execute the delay and then read the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you can change the sensor, just trade the mechanical switch for an optical end run sensor. If your moving object has steady movement, you will not get any bounces from the optical coupler. Then you can just poll it.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-27T12:29:50.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17222" PostTypeId="2" ParentId="16730" CreationDate="2015-10-27T12:35:46.580" Score="2" Body="&lt;p&gt;PWM are digital output pins, and it seems that you wish to measure analog equivalent voltage generated by PWM output. If so, you'd need a filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Construct a unity gain op-amp based RC filter with cut-off frequency significantly smaller than PWM clock frequency. This will generate a analog waveform that can drive analog circuits. You could connect this to ADC input pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could Google &quot;Active low pass filter&quot; for a lot of schematics and formula.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to faithfully reproduce analog signal captured through ADC on a computer screen graph, your ADC sample rate must be more than ~2.5 times analog signal's bandwidth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your sample rate is close to Nyquist rates,  you'd need to filter (interpolate) your digitized signal in software to generate a smooth graph. This is a bit involved in maths and software. Otherwise you'd only get a &quot;spikey&quot; waveform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or preferably have a sample rate &gt; 10 times analog bandwidth. This will give large enough sample counts to reliably show analog data without much processing.&lt;/p&gt;&#xA;" OwnerUserId="14297" LastActivityDate="2015-10-27T12:35:46.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17223" PostTypeId="2" ParentId="17188" CreationDate="2015-10-27T12:53:44.843" Score="1" Body="&lt;p&gt;I had the same problem. I used &lt;code&gt;SoftwareSerial&lt;/code&gt; library, so you should set baud rate as 115200 for communication with esp8266. It might look like this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(2,3); &#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(115200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It helped in my case.&lt;/p&gt;&#xA;" OwnerUserId="14260" LastActivityDate="2015-10-27T12:53:44.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17224" PostTypeId="1" AcceptedAnswerId="18042" CreationDate="2015-10-27T13:10:13.533" Score="0" ViewCount="157" Body="&lt;p&gt;I have created rest service using .js file on Parse.com.&#xA;I want to access cloud function from arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i tried this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;client.get(&lt;a href=&quot;https://myAppID:javascript-key=myJavaScriptKey@api.parse.com/1/functions/hello&quot; rel=&quot;nofollow&quot;&gt;https://myAppID:javascript-key=myJavaScriptKey@api.parse.com/1/functions/hello&lt;/a&gt;&quot;);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i am getting error &quot;Method not allowed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution :&#xA;Somehow i got the answer which is as follows.I hope it will help others.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ParseCloudFunction cloudFunction;&#xA; cloudFunction.setFunctionName(function_name);  //string (&quot;hello&quot;)&#xA; cloudFunction.add(&quot;light_sensor&quot;, light); //pass parameter to cloud&#xA;&#xA; ParseResponse response = cloudFunction.send();&#xA; Serial.println(response.getJSONBody());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14369" LastEditorUserId="14369" LastEditDate="2015-11-23T13:03:11.457" LastActivityDate="2016-02-21T13:59:59.427" Title="How to access parse cloud functions using arduino?" Tags="|arduino-yun|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17225" PostTypeId="1" CreationDate="2015-10-27T13:44:50.437" Score="0" ViewCount="573" Body="&lt;p&gt;I've had an Arduino Uno for a couple of months-making basic sketches-and recently purchased an Adafruit ultimate GPS shield and attached with soldered headers. This shield has 2 options for reading data, direct and soft serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can sit near a window in my house and receive data using the direct method. This is just due to uploading a blank sketch and reading the serial window. Next, I tried to use one of the examples included in the Adafruit_GPS library and the serial window shows a bunch of nonsense updating. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone else seen this problem? I'm wondering if its the digital pins on the Arduino that I may have damaged since the example code has a simple phrase to display at the start, and I don't even get this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code eg: Serial.println(&quot;Get version!&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to verify, both boards have power and the direct method was giving me good GPS readings, the serial method gave me junk (not even a simple printed phrase to start), and I verified the Soft Serial switch was flipped and the baud rates matched in code and serial window. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached pictures of the direct method results from that in the serial window, and then the junk results using an unaltered sample serial code. Any help with this would be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vbf7N.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vbf7N.jpg&quot; alt=&quot;Direct Method Results&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/jDQpn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jDQpn.jpg&quot; alt=&quot;Direct Method Example Results&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14357" LastEditorUserId="9962" LastEditDate="2016-02-25T07:53:06.937" LastActivityDate="2016-09-23T06:31:42.840" Title="Arduino Uno + Adafruit Ultimate GPS Shield Serial issue" Tags="|arduino-uno|softwareserial|gps|adafruit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17226" PostTypeId="1" AcceptedAnswerId="17227" CreationDate="2015-10-27T14:08:22.237" Score="0" ViewCount="2120" Body="&lt;p&gt;Whenever I run into information about DAC, it seems to be related to audio processing. Are there any other use cases where DAC might be useful, or have any advantages over regular ADC PWM output on an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-27T15:11:04.320" Title="Are DAC pins useful for anything besides working with audio?" Tags="|arduino-due|digital-analog-conversion|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17227" PostTypeId="2" ParentId="17226" CreationDate="2015-10-27T14:17:48.837" Score="3" Body="&lt;p&gt;DACs have many uses outside the realm of audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically a DAC is used any time you want to generate a specific voltage for whatever you need it for - that could be to generate a waveform for audio, or it could be for any other situation, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setting an offset point for an op-amp&lt;/li&gt;&#xA;&lt;li&gt;Creating a comparison voltage for comparing another signal to&lt;/li&gt;&#xA;&lt;li&gt;Controlling the bias voltage of a transistor&lt;/li&gt;&#xA;&lt;li&gt;Generating a specific reference voltage for an external (or even the internal) ADC&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The list goes on.  There are many places you would want to use a DAC.  And why a DAC above PWM? Well basically it boils down to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Precision - the DAC can generate a more precise voltage than a filtered PWM signal&lt;/li&gt;&#xA;&lt;li&gt;Noise - the DAC generates a much smoother voltage with better response than filtered PWM which either has switching noise and fast response or less switching noise and delays in voltage level changes.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-27T14:17:48.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17228" PostTypeId="2" ParentId="17225" CreationDate="2015-10-27T14:18:10.420" Score="1" Body="&lt;p&gt;It looks like you are using the wrong baud rate somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You mentioned that you had checked your baud rates but check again because the second terminal window looked as if the baud rate was wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your terminal window. Go to bottom right hand corner where it says 9600 and change it to match the serial speed set in your arduino code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or it could be that you are receiving too much data as per the bottom of this article:  &lt;a href=&quot;https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield/soft-serial-connect&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-ultimate-gps-logger-shield/soft-serial-connect&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="1192" LastEditorUserId="1192" LastEditDate="2015-10-27T14:26:52.307" LastActivityDate="2015-10-27T14:26:52.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17230" PostTypeId="1" CreationDate="2015-10-27T15:08:16.683" Score="0" ViewCount="1759" Body="&lt;p&gt;I need to put arduino in sleep mode. I did not find the library avr/sleep.h . From where to download it. &lt;/p&gt;&#xA;" OwnerUserId="14372" LastActivityDate="2015-10-27T15:13:41.513" Title="How to put arduino in sleep mode?" Tags="|sleep|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17231" PostTypeId="2" ParentId="17226" CreationDate="2015-10-27T15:11:04.320" Score="4" Body="&lt;p&gt;They are incredibly useful.  They are essentially how you deal with the analog world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I'm using two of them in a project here that uses a frequency generator and a couple of op-amps to create a VSWR bridge, allowing me to figure out the resonant frequencies of an antenna...  The parts with the arduino cost less than $20... Buying something that does the same thing is about $300!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, yes, they are very useful. :)&lt;/p&gt;&#xA;" OwnerUserId="14231" LastActivityDate="2015-10-27T15:11:04.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17232" PostTypeId="2" ParentId="17230" CreationDate="2015-10-27T15:13:41.513" Score="3" Body="&lt;p&gt;&lt;code&gt;avr/sleep.h&lt;/code&gt; is part of the compiler. You don't need to download it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other libraries that act as a wrapper to it to make life easier:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/lowpowerlab/lowpower&quot; rel=&quot;nofollow&quot;&gt;https://github.com/lowpowerlab/lowpower&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/rocketscream/Low-Power&quot; rel=&quot;nofollow&quot;&gt;https://github.com/rocketscream/Low-Power&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-27T15:13:41.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17234" PostTypeId="1" AcceptedAnswerId="17235" CreationDate="2015-10-27T16:14:02.517" Score="1" ViewCount="2650" Body="&lt;p&gt;How does arduino uno cast from &lt;strong&gt;long&lt;/strong&gt; to &lt;strong&gt;int&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it truncate the bits? (Does it just delete the 16 most left bits?)&lt;/p&gt;&#xA;" OwnerUserId="14374" LastActivityDate="2015-10-27T16:24:14.643" Title="Cast from long to int" Tags="|data-type|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17235" PostTypeId="2" ParentId="17234" CreationDate="2015-10-27T16:24:14.643" Score="5" Body="&lt;p&gt;Yes, it just blindly chops off the upper 16 bits.  That means that the sign can change between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, 123456789 gets truncated to -13035 and -123456789 truncates to 13035.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To see that in more detail, look at the binary.  123456789 in binary is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000 0111 0101 1011 1100 1101 0001 0101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Truncate that at 16 bits and you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1100 1101 0001 0101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course the high (sign) bit is set, so the value is negative.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-27T16:24:14.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17236" PostTypeId="1" CreationDate="2015-10-27T16:39:01.963" Score="1" ViewCount="225" Body="&lt;p&gt;New Arduino Uno, Arduino 1.6.3, MBP running 10.10.5. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE is running, I connect to the laptop via usb. The green LED is on the amber light is on but it's not blinking. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I attempted to upload the blink file from File&gt;Example&gt;Basic&gt;Blink. It compiles without issue but won't upload. I get the can't open device &quot;/dev/cu.usbmodem1421&quot; : No such file or directory...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attempted using the reset button, changing ports, cycling the IDE and the computer. The killer is that I've had an Arduino on this laptop before. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggests for getting the Arduino linked and operational.&lt;/p&gt;&#xA;" OwnerUserId="14375" LastActivityDate="2016-07-08T21:48:47.777" Title="Arduino port recognition" Tags="|arduino-uno|uploading|port-mapping|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17237" PostTypeId="1" CreationDate="2015-10-27T17:02:16.357" Score="5" ViewCount="7034" Body="&lt;p&gt;I've built a weather station using Arduino that measures temperature/humidity and pressure using an Adafruit 8266 HUZZAH. Temperature and Humidity are measured using a DHT22 sensor a ordered from AdaFruit. The project was completed about 4 months ago and for the first three months has returned what appears to be good data. Eventually, the humidity values started returning garbage, values around 1%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I replaced the DHT22 sensor with another, this time from a random eBay seller. This also worked fine for about a week (humidity values appear to look good in the 20-60% range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then all of a sudden, they dropped to 1% again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I run the DHTtester program (instead of my program) against the sensor and my Uno development board, the result is also 1% humidity for this sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; DHTxx test!&#xA; Humidity: 1.00 %   Temperature: 19.20 *C 66.56 *F  Heat index: 17.96 *C 64.33 *F&#xA; Humidity: 1.00 %   Temperature: 19.20 *C 66.56 *F  Heat index: 17.96 *C 64.33 *F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So at this point, I know the problem is not with my program (happens with both my program and the DHTtest program), not with my Arduino (happens with both the 8266 in &quot;the field&quot; and my Uno on my couch). So something must be happening to the sensors in the field, where they work for a week to a few months, and then fail?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm beginning to think some bug/critter is eating or doing something to the sensor (maybe they are attracted to it because it's warmer), but anyway is there a good way to shield if this is the case without affecting the values? Any other way to see what is going on?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // Example testing sketch for various DHT humidity/temperature sensors&#xA; // Written by ladyada, public domain&#xA;&#xA; #include &quot;DHT.h&quot;&#xA; #define DHTPIN 2     // what pin we're connected to&#xA;&#xA; // Uncomment whatever type you're using!&#xA; //#define DHTTYPE DHT11   // DHT 11&#xA; #define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA; //#define DHTTYPE DHT21   // DHT 21 (AM2301)&#xA;&#xA; // Connect pin 1 (on the left) of the sensor to +5V&#xA; // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1&#xA; // to 3.3V instead of 5V!&#xA; // Connect pin 2 of the sensor to whatever your DHTPIN is&#xA; // Connect pin 4 (on the right) of the sensor to GROUND&#xA; // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor&#xA;&#xA; // Initialize DHT sensor.&#xA; DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA; void setup() {&#xA;   Serial.begin(9600);&#xA;   Serial.println(&quot;DHTxx test!&quot;);&#xA;   dht.begin();&#xA; }&#xA;&#xA; void loop() {&#xA;     // Wait a few seconds between measurements.&#xA;     delay(2000);&#xA;     // Reading temperature or humidity takes about 250 milliseconds!&#xA;     // Sensor readings may also be up to 2 seconds 'old' &#xA;     float h = dht.readHumidity();&#xA;     // Read temperature as Celsius (the default)&#xA;     float t = dht.readTemperature();&#xA;     // Read temperature as Fahrenheit (isFahrenheit = true)&#xA;     float f = dht.readTemperature(true);&#xA;&#xA;     // Check if any reads failed and exit early (to try again).&#xA;     if (isnan(h) || isnan(t) || isnan(f)) {&#xA;         Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;         return;&#xA;     }&#xA;&#xA;     // Compute heat index in Fahrenheit (the default)&#xA;     float hif = dht.computeHeatIndex(f, h);&#xA;     // Compute heat index in Celsius (isFahreheit = false)&#xA;     float hic = dht.computeHeatIndex(t, h, false);&#xA;&#xA;     Serial.print(&quot;Humidity: &quot;);&#xA;     Serial.print(h);&#xA;     Serial.print(&quot; %\t&quot;);&#xA;     Serial.print(&quot;Temperature: &quot;);&#xA;     Serial.print(t);&#xA;     Serial.print(&quot; *C &quot;);&#xA;     Serial.print(f);&#xA;     Serial.print(&quot; *F\t&quot;);&#xA;     Serial.print(&quot;Heat index: &quot;);&#xA;     Serial.print(hic);&#xA;     Serial.print(&quot; *C &quot;);&#xA;     Serial.print(hif);&#xA;     Serial.println(&quot; *F&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10429" LastEditorUserId="4628" LastEditDate="2015-11-20T01:57:47.723" LastActivityDate="2016-03-10T16:11:55.703" Title="Humidity values returned by DHT22 sensors failing after some time" Tags="|sensors|c++|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17239" PostTypeId="1" AcceptedAnswerId="17244" CreationDate="2015-10-27T19:12:39.507" Score="3" ViewCount="1619" Body="&lt;p&gt;Is it a good way to measure liquid level in a water tank using a general purpose sonar sensor? How can echoes from the tank walls affect measurement accuracy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a cylinder shaped &lt;strong&gt;horizontal&lt;/strong&gt; 700L water tank, used for emergency water supply. I need to measure the water level with approx. 5% accuracy and display it in my kitchen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0XD5H.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0XD5H.jpg&quot; alt=&quot;sonar sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE! Today I found this helpful page: &lt;a href=&quot;http://alaskanshade.blogspot.ch/2013/12/home-heating-hacking-part-1-or-how-to.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Home Heating Hacking Part 1 or How to Measure an Oil Tank&lt;/a&gt;.&#xA;I had no time to realize my idea, but it's exactly what I wanted to do. So take a look.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="14379" LastEditorUserId="14379" LastEditDate="2016-01-12T10:32:19.823" LastActivityDate="2016-01-12T10:32:19.823" Title="Accuracy of liquid level measurement using sonar sensor" Tags="|home-automation|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17240" PostTypeId="2" ParentId="8880" CreationDate="2015-10-27T20:16:43.057" Score="1" Body="&lt;p&gt;The confusion you have arises from the context of the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The server.* commands manipulate the server instance - that is, the actively listening socket that is waiting for connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The client.* commands change their meaning depending on if you are a server waiting for connections or a client that is making a connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the latter case client.print() sends data to the server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the former case, on a server, the client.* commands refer to a specific client that has made a connection to the server.  Using client.print() in this instance sends data &lt;em&gt;to&lt;/em&gt; the currently connected client.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So &quot;client&quot; can be thought of as &quot;the connection between me and the remote end&quot; however that connection was created - either by &quot;me&quot; specifically connecting to the remote end, or the remote end connecting to my &quot;server&quot; instance and a new &quot;client&quot; being spawned from it for this one connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember - a client can only connect to one server, but a server can have many connections from many different clients, and it is those &lt;em&gt;client&lt;/em&gt; connections that you talk to.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-27T20:16:43.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17242" PostTypeId="1" CreationDate="2015-10-27T23:33:22.263" Score="2" ViewCount="23" Body="&lt;p&gt;I have almost no eexperience building electronic kits. I just buoght and began tinkering with sparkfun 3.2 and want to adapt its simon sketch to real audio files&#xA;What isis theeasiest to assemble add on shield or breakout not surew hat you call this looked at this one&#xA;VS1053 Codec + MicroSD Breakout - MP3/WAV/MIDI/OGG Play + Record - v4&lt;/p&gt;&#xA;" OwnerUserId="14386" LastActivityDate="2015-10-27T23:33:22.263" Title="what is the fastest shield to add to the sparkfun v3.2 Arduino Uno that will enable me to playback and record hour of short audio dictation" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17243" PostTypeId="1" AcceptedAnswerId="31769" CreationDate="2015-10-27T23:53:37.957" Score="1" ViewCount="2654" Body="&lt;p&gt;I'm hoping to get some help with this as I am unable to get the CAN to Initialize.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the sparkfun Can-Bus shield: &lt;a href=&quot;https://www.sparkfun.com/products/13262&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/13262&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and an Arduino Leonardo board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following code to try to connect my 2008 Audi S6 to the Arduino board:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Canbus.h&amp;gt;&#xA;#include &amp;lt;defaults.h&amp;gt;&#xA;#include &amp;lt;global.h&amp;gt;&#xA;#include &amp;lt;mcp2515.h&amp;gt;&#xA;#include &amp;lt;mcp2515_defs.h&amp;gt;&#xA;#include &amp;lt;Canbus.h&amp;gt;&#xA;char UserInput;&#xA;int data;&#xA;char buffer[456];  //Data will be temporarily stored to this buffer before being written to the file&#xA;&#xA;//********************************Setup Loop*********************************//&#xA;&#xA;void setup(){&#xA;Serial.begin(9600);&#xA;while(!Serial);&#xA;Serial.println(&quot;CAN-Bus Demo&quot;);&#xA;&#xA;if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the  specified speed */&#xA;  {&#xA;Serial.println(&quot;CAN Init ok&quot;);&#xA;  } else&#xA;  {&#xA;    Serial.println(&quot;Can't init CAN&quot;);&#xA;  } &#xA;&#xA;  delay(1000); &#xA;&#xA;Serial.println(&quot;Please choose a menu option.&quot;);&#xA;Serial.println(&quot;1.Speed&quot;);&#xA;Serial.println(&quot;2.RPM&quot;);&#xA;Serial.println(&quot;3.Throttle&quot;);&#xA;Serial.println(&quot;4.Coolant Temperature&quot;);&#xA;Serial.println(&quot;5.O2 Voltage&quot;);&#xA;Serial.println(&quot;6.MAF Sensor&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;//********************************Main Loop*********************************//&#xA;&#xA;void loop(){&#xA;&#xA;while(Serial.available()){&#xA;   UserInput = Serial.read();&#xA;&#xA;if (UserInput=='1'){&#xA; data=Canbus.ecu_req(VEHICLE_SPEED, buffer);&#xA; Serial.print(&quot;Vehicle Speed: &quot;);&#xA; Serial.print(data);&#xA; Serial.println(&quot; km/hr &quot;);&#xA; delay(1000);&#xA;}&#xA;else if (UserInput=='2'){&#xA; data= Canbus.ecu_req(ENGINE_RPM, buffer);&#xA; Serial.print(&quot;Engine RPM: &quot;);&#xA; Serial.print(data);&#xA; Serial.println(&quot; rpm &quot;);&#xA; delay(1000);&#xA;&#xA;}&#xA;else if (UserInput=='3'){&#xA; data= Canbus.ecu_req(THROTTLE, buffer);&#xA; Serial.print(&quot;Throttle: &quot;);&#xA;  Serial.print(data);&#xA; Serial.println(&quot; %% &quot;);&#xA; delay(1000);&#xA;&#xA;}&#xA;else if (UserInput=='4'){&#xA; data =Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);&#xA; Serial.print(&quot;Engine Coolant Temp: &quot;);&#xA; Serial.print(data);&#xA; Serial.println(&quot; degC&quot;);&#xA; delay(1000);&#xA;&#xA;}&#xA;else if (UserInput=='5'){&#xA; data=Canbus.ecu_req(O2_VOLTAGE, buffer);&#xA; Serial.print(&quot;O2 Voltage: &quot;);&#xA; Serial.print(data);&#xA; Serial.println(&quot; V&quot;);&#xA; delay(1000);&#xA;&#xA;}&#xA;else if (UserInput=='6'){&#xA; data=Canbus.ecu_req(MAF_SENSOR, buffer);&#xA; Serial.print(&quot;MAF Sensor: &quot;);&#xA; Serial.print(data);&#xA; Serial.println(&quot; g/s&quot;);&#xA; delay(1000);&#xA;&#xA;}&#xA;else&#xA;{&#xA;  Serial.println(UserInput);&#xA;  Serial.println(&quot;Not a valid input.&quot;);&#xA;  Serial.println(&quot;Please enter a valid option.&quot;);&#xA;}&#xA;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Overall, I just can't get the CAN to initialize. I've looked online and just can't seem to find a solid solution. I've tried other libraries as well to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please assist!&lt;/p&gt;&#xA;" OwnerUserId="14387" LastActivityDate="2020-10-06T18:06:02.793" Title="Can BUS Shield on Arduino Leonardo - Can't init CAN" Tags="|arduino-leonardo|can-bus|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17244" PostTypeId="2" ParentId="17239" CreationDate="2015-10-28T01:41:34.113" Score="5" Body="&lt;p&gt;I've implemented this on my 2 x 23,000 litre water tanks using 2x hc-sr04 sensors mounted on the tank lids and a nano in the pump house. Yes water is a good hard reflective surface to bounce the ultrasonic sound waves off. My tanks have an overflow outlet but not sure how well the eletronic will last? However they are cheap to replace. It is only early days but the overall the results are looking good.&#xA;Couple of points:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.polling occurs hourly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.I only power the ultrasonic sensor just before taking a reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3.Has a sound detection sensor to alert on water pump overrun, ie a leak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;good luck &lt;/p&gt;&#xA;" OwnerUserId="14389" LastActivityDate="2015-10-28T01:41:34.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17245" PostTypeId="2" ParentId="17206" CreationDate="2015-10-28T03:56:03.657" Score="0" Body="&lt;p&gt;It's pretty simple to store the x, y and z co-ordinates in three separate arrays. Instead of storing them in single &lt;code&gt;int&lt;/code&gt; variables you can just store them in &lt;code&gt;int&lt;/code&gt; arrays. You can make three arrays that are of size 1000 a store the raw values there. In order to iterate through the arrays within &lt;code&gt;loop()&lt;/code&gt; you can set up &lt;code&gt;i&lt;/code&gt; at global scope and include an if statement that will know when the arrays are filled, for example &lt;code&gt;if (i == 1000)&lt;/code&gt; and within this if statement you can set up a &lt;code&gt;for&lt;/code&gt; loop that will iterate through the arrays and print their values and after reset &lt;code&gt;i&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; and then reset the buffer arrays i.e. fill them with zeroes. This last step is not needed since they will be overwritten anyway but it is good to have so you don't accidentally use old values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the &lt;code&gt;for&lt;/code&gt; loop that will print the values will take 8 minutes with that &lt;code&gt;delay(500);&lt;/code&gt; You can make this delay smaller or print the value before each &lt;code&gt;if&lt;/code&gt; statement as the data comes in.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AcceleroMMA7361.h&amp;gt;&#xA;&#xA;AcceleroMMA7361 accelero;&#xA;int xAxisBuffer [1000] = {0};&#xA;int yAxisBuffer [1000] = {0};&#xA;int zAxisBuffer [1000] = {0};&#xA;&#xA;int i = 0;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;    accelero.begin(13, 12, 11, 10, A0, A1, A2);&#xA;    accelero.setARefVoltage(3.3);     //sets the AREF voltage   to 3.3V&#xA;    accelero.setSensitivity(LOW);           //sets the sensitivity to +/-6G&#xA;    accelero.calibrate();&#xA;}&#xA;&#xA;void loop(){&#xA;    // This stores the x, y and z values in their&#xA;    // respective arrays&#xA;    xAxisBuffer[i] = accelero.getXRaw();&#xA;    yAxisBuffer[i] = accelero.getYRaw();&#xA;    zAxisBuffer[i] = accelero.getZRaw();&#xA;    ++i; // moves to the next position&#xA;&#xA;    if (i == 1000){ // the arrays are full&#xA;        // prints the (x, y, z) values&#xA;        // because the delay is .5 seconds it will&#xA;        // take about 8 minutes to print all 1000  &#xA;        for (int j = 0; j &amp;lt; 1000; j++){&#xA;            Serial.print(&quot;\nx: &quot;);&#xA;            Serial.print(xAxisBuffer[j]);&#xA;            Serial.print(&quot;\ty: &quot;);&#xA;            Serial.print(yAxisBuffer[j]);&#xA;            Serial.print(&quot;\tz: &quot;);&#xA;            Serial.print(zAxisBuffer[j]);&#xA;            delay(500); //(make it readable)&#xA;        }&#xA;        // restart at beginning of the arrays&#xA;        i = 0;&#xA;        // reset the arrays&#xA;        memset(xAxisBuffer,0,sizeof(xAxisBuffer));&#xA;        memset(yAxisBuffer,0,sizeof(yAxisBuffer));&#xA;        memset(zAxisBuffer,0,sizeof(zAxisBuffer));&#xA;    }                                   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13840" LastEditorUserId="13840" LastEditDate="2015-10-28T04:05:49.887" LastActivityDate="2015-10-28T04:05:49.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17246" PostTypeId="1" CreationDate="2015-10-28T04:39:47.990" Score="2" ViewCount="79" Body="&lt;p&gt;An XBee Pro S1 module sits on a DIP socket on-board a Personal Weather Station (PWS) to transmit data. &#xA;Instead of letting the station transmit data wirelessly via the XBee, I would like to read that data off the socket pins on which it sits, via an Arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible? If so, what should I look into?&lt;br&gt;&#xA;I am new to wireless communication with a µC, so any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="6548" LastEditorUserId="6548" LastEditDate="2015-10-28T06:34:15.383" LastActivityDate="2015-10-28T06:34:15.383" Title="Intercept Data being sent to XBee Module via UNO" Tags="|arduino-uno|serial|xbee|wireless|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17249" PostTypeId="1" AcceptedAnswerId="17255" CreationDate="2015-10-28T07:34:49.490" Score="0" ViewCount="74" Body="&lt;p&gt;I have 2 programs made for my arduino.The first one is for solving a maze automatically and the second one is for controlling the robot with a android app.I wanted to control the robot with the app I made as soon as it has finished solving the maze.&#xA;                   Is it possible to upload both the program in the arduino and run it one at a time?If so can you tell me how? &lt;/p&gt;&#xA;" OwnerUserId="14393" LastActivityDate="2015-10-28T15:35:27.393" Title="How to switch program in arduino using android app?" Tags="|robotics|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17250" PostTypeId="2" ParentId="15935" CreationDate="2015-10-28T07:46:57.190" Score="1" Body="&lt;p&gt;What you need to do instead is to declare an array buffer of the data type you need to send, and send it through Serial. The array buffer could be of any length of your choosing, then you reiterate through on a for loop till all the contents of the buffer are read out which is essentially the burst mode you require.&lt;/p&gt;&#xA;" OwnerUserId="14350" LastActivityDate="2015-10-28T07:46:57.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17253" PostTypeId="2" ParentId="17184" CreationDate="2015-10-28T09:48:15.700" Score="2" Body="&lt;p&gt;Try dropping the SoftwareSerial connection speed to 19200. Ie, esp8266.begin(19200). 115200 it is the absolute max the SoftwareSerial can theoretically handle.&#xA;Also if you are not using all the change interrupt pins on your MCU (Uno/Nano?) then use any 2 pins from 10, 11, 12 or 13 rather than 3, 2 // RX, TX.&#xA;Not sure about sendCommand function. If you just want to test the connection then it should be as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial esp8266(10, 11); // RX, TX&#xA;&#xA;void setup() {&#xA;    esp8266.begin(19200);&#xA;    Serial.begin(115200 );&#xA;&#xA;    char buffer[50];&#xA;    esp8266.write(&quot;AT\r\n&quot;);&#xA;    esp8266.readBytes(buffer, sizeof(buffer));&#xA;    Serial.println(buffer);&#xA;&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously once you need to open web pages and recieve responses then you will need a libary to handle IDP+ data. With a bit of coercion I got Adafruit_ESP8266.h working with SoftwareSerial.&lt;/p&gt;&#xA;" OwnerUserId="14389" LastEditorUserId="14389" LastEditDate="2015-10-29T06:30:10.530" LastActivityDate="2015-10-29T06:30:10.530" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17255" PostTypeId="2" ParentId="17249" CreationDate="2015-10-28T10:49:06.727" Score="1" Body="&lt;p&gt;Once I made a sketch to run multiple programs. I wrote a &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;loop&lt;/code&gt; function for every different &quot;program&quot;, (e.g. &lt;code&gt;setup_p1&lt;/code&gt;, &lt;code&gt;setup_p2&lt;/code&gt;, ... &lt;code&gt;loop_p1&lt;/code&gt;, ...) and then wrote a simple &lt;code&gt;main&lt;/code&gt; sketch to handle them all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my application I choose the program at startup with a 3-dipswitch, but you can easily switch this to allow &quot;on the fly&quot; switching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I choose to use a callback because it's faster than just checking the mode every time, at least in my case&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// callback for loop function&#xA;typedef void (*loopfunction)();&#xA;loopfunction currentloop;&#xA;&#xA;void setup()&#xA;{&#xA;  // Set dip-switch pins as input&#xA;  pinMode(MODE_PIN2,INPUT_PULLUP);&#xA;  pinMode(MODE_PIN1,INPUT_PULLUP);&#xA;  pinMode(MODE_PIN0,INPUT_PULLUP);&#xA;&#xA;  // Concatenate the dip-switch values&#xA;  byte mode = 7 - ((digitalRead(MODE_PIN2) &amp;lt;&amp;lt; 2) | (digitalRead(MODE_PIN1) &amp;lt;&amp;lt; 1) | digitalRead(MODE_PIN0));&#xA;&#xA;  // choose the correct mode&#xA;  switch(mode)&#xA;  {&#xA;    case 0: // Shutdown - do nothing&#xA;            break;&#xA;    case 1: // Program 1&#xA;            setup_p1();&#xA;            currentloop = loop_p1;&#xA;            break;&#xA;    case 2: // Program 2&#xA;            setup_p2();&#xA;            currentloop = loop_p2;&#xA;            break;&#xA;    ...&#xA;  }&#xA;&#xA;  // Not a valid program: halt&#xA;  if (!currentloop)&#xA;  {&#xA;    while(1);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Execute the current loop&#xA;  currentloop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2015-10-28T15:35:27.393" LastActivityDate="2015-10-28T15:35:27.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17258" PostTypeId="2" ParentId="13826" CreationDate="2015-10-28T13:53:50.430" Score="0" Body="&lt;p&gt;If you use RX, and TX in default pin then it is not necessary that you should &lt;em&gt;include SoftwareSerial&lt;/em&gt; library.&lt;/p&gt;&#xA;" OwnerUserId="14394" LastActivityDate="2015-10-28T13:53:50.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17259" PostTypeId="1" AcceptedAnswerId="17268" CreationDate="2015-10-28T15:54:34.470" Score="0" ViewCount="251" Body="&lt;p&gt;I was hoping someone could help, im totally new to this. I wish to use this code for a Raspberry Pi on an Arduino Uno with the Adafruit SD data logging shield. It is for recording reed switch closures on a tipping bucket rain gauge. The interrupt and bounce time are to allow program interrupts and false tip suppression. I am looking to tie it in with the RTC and SD storage options on the Arduino. Any help appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python3&#xA;import RPi.GPIO as GPIO&#xA;import time&#xA;&#xA;# this many mm per bucket tip&#xA;CALIBRATION = 0.200&#xA;# which GPIO pin the gauge is connected to&#xA;PIN = 17&#xA;# file to log rainfall data in&#xA;LOGFILE = &quot;log.csv&quot;&#xA;&#xA;GPIO.setmode(GPIO.BCM)  &#xA;GPIO.setup(PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)&#xA;&#xA;# variable to keep track of how much rain&#xA;rain = 0&#xA;&#xA;# the call back function for each bucket tip&#xA;def cb(channel):&#xA;    global rain&#xA;    rain = rain + CALIBRATION&#xA;&#xA;# register the call back for pin interrupts&#xA;GPIO.add_event_detect(PIN, GPIO.FALLING, callback=cb, bouncetime=300)&#xA;&#xA;# open the log file&#xA;file = open(LOGFILE, &quot;a&quot;)&#xA;&#xA;# display and log results&#xA;while True:&#xA;    line = &quot;%i, %f&quot; % (time.time(), rain)&#xA;    print(line)&#xA;    file.write(line + &quot;\n&quot;)&#xA;    file.flush()&#xA;    rain = 0&#xA;    time.sleep(5)&#xA;&#xA;# close the log file and exit nicely&#xA;file.close()&#xA;GPIO.cleanup()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14401" LastEditorUserId="2881" LastEditDate="2015-10-28T19:02:35.197" LastActivityDate="2015-10-28T20:57:17.810" Title="Can anyone explain how this code can be converted to work on a Arduino Uno" Tags="|arduino-uno|programming|compile|" AnswerCount="1" CommentCount="1" ClosedDate="2015-11-05T23:38:28.670" ContentLicense="CC BY-SA 3.0" />
  <row Id="17261" PostTypeId="1" CreationDate="2015-10-28T17:35:32.510" Score="1" ViewCount="826" Body="&lt;p&gt;I'm a beginner using Arduino with a Teensy 3.2 board and programming it as a usb keyboard. I have two 4 button membrane switches. Their button contacts are on pins 1-8, and the 9th pin holds a soldered together wire of both membrane switches' &quot;ground&quot; line or whatever it's true name is; the line that completes the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically when you press the buttons they are supposed to simply type &quot;a, b, c...&quot; respectively. I've been told I need to use a matrix for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking for an example of how to code a keyboard matrix that effectively supports a one row/9 column line (or vice versa?) I've been unable to find that solution online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I have so far is this code which, when the button on the second pin is pressed, sends tons of &quot;AAAAAAAAAAAAAAAA&quot; keystrokes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // make pin 2 an input and turn on the &#xA;  // pullup resistor so it goes high unless&#xA;  // connected to ground:&#xA;  pinMode(2, INPUT_PULLUP);&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  //if the button is pressed&#xA;  if(digitalRead(2)==LOW){&#xA;    //Send an ASCII 'A', &#xA;    Keyboard.write(65);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would anyone be able to help?&lt;/p&gt;&#xA;" OwnerUserId="14403" LastActivityDate="2015-10-28T18:33:51.743" Title="Arduino keypad matrix example? ( teensyduino )" Tags="|pins|teensy|keyboard|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17262" PostTypeId="2" ParentId="17261" CreationDate="2015-10-28T18:33:51.743" Score="1" Body="&lt;p&gt;By your description, you don't have a matrix.  You have them wired as just 8 straight switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A matrix would be if you had the 4 switch pins of one keypad wired to the same switch pins of the other keypad, and the two common connections from the keypads wired to two separate IO pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment your code is responding whenever a button is in the low state. Instead it needs to respond only when the button &lt;em&gt;transitions&lt;/em&gt; from the high state to the low state.  To do that you need to know what state all the buttons were in the previous pass through loop to compare them to what they are in this pass through loop - and if any have changed then they have either been pressed or released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also implement debouncing to that you don't get false presses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to learn how to do all that yourself I have a handy library that will do it all for you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/DebouncedInput&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/DebouncedInput&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to convert your setup to an actual matrix to save on IO pins you want to read the Arduino Keypad tutorial:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/KeypadTutorial&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/KeypadTutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-28T18:33:51.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17263" PostTypeId="1" CreationDate="2015-10-28T19:15:08.883" Score="0" ViewCount="551" Body="&lt;p&gt;I want to make simple client-server program where arduino behave as a client. For example I have a LED connected in arduino board that is controlled by a switch. With the switch I can turn off and on the LED. Now I want to send the status of that LED to another computer wirelessly (let's say within the Local network). That computer will act as a server and update the change as soon as the LED changes its status. I am not expecting any complete code, I just want to know how could it be done in general? May be some links can help me? Because this is my first time working with client-server in arduino sketch, I need some kind of guidelines. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="14404" LastActivityDate="2016-02-28T16:00:08.260" Title="Sending data from Arduino to the server where arduino (sketch) acts as a client" Tags="|arduino-uno|serial|sketch|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17264" PostTypeId="1" AcceptedAnswerId="17274" CreationDate="2015-10-28T19:15:12.947" Score="0" ViewCount="326" Body="&lt;p&gt;I'm trying to design a menu interface on a 1.8'' TFT display module. I've got it working with the Adafruit_ST7735 + Adafruit_GFX libraries. At least when I was just trying out the features... But now I'm trying to organize the code in Classes as this thing will get too complex soon. I have done some Java and C, so I started learning C++. I've been reading and coding nonstop for a week now, but there are some things that I can't wrap my head around that keep me from making any progress for a couple of days already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... For example there's a function public void drawRect(); in Adafruit_ST7735 library and I have a function draw() that draws a bunch of related stuff to the display in my own class (Rectangle.cpp). Say I initialize the display in my main program file how can I use that drawRect() function in my Rectangle::draw()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also Rectangle will be used for composing other parts of the menu interface and will probably be initialized in a collection or as a member of another class. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried a bunch of different things but I've come to a dead end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;main program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;_v0_0_0.h&quot;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &amp;lt;Adafruit_ST7735.h&amp;gt; // Hardware-specific library&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#include &quot;Point.h&quot;&#xA;#include &quot;Rectangle.h&quot;&#xA;#include &quot;SomeView.h&quot;&#xA;&#xA;#define     TFT_CS  4&#xA;#define     TFT_RST 0&#xA;#define     TFT_DC  10&#xA;&#xA;Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);&#xA;SomeView a_view;&#xA;&#xA;void setup()&#xA;{&#xA;    tft.initR(INITR_BLACKTAB); // initializes the display&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    a_view.draw(); //draw something to view (a button, scrollbar, menu item, etc)&#xA;    while (true) {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SomeView.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Rectangle.h&quot;&#xA;&#xA;class SomeView {&#xA;private:&#xA;    Rectangle a_rectangle;&#xA;public:&#xA;    SomeView();&#xA;    void draw();&#xA;&#xA;    const Rectangle&amp;amp; getRectangle() const {&#xA;        return a_rectangle;&#xA;    }&#xA;&#xA;    void setRectangle(const Rectangle&amp;amp; rectangle) {&#xA;        a_rectangle = rectangle;&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SomeView.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SomeView.h&quot;&#xA;&#xA;SomeView::SomeView() :&#xA;        a_rectangle(Point::Point(0, 0), Point::Point(0, 0)) {&#xA;}&#xA;&#xA;void SomeView::draw() {&#xA;    a_rectangle.setCorners(Point::Point(0, 0), Point::Point(2, 6));&#xA;    a_rectangle.draw();&#xA;&#xA;    a_rectangle.setCorners(Point::Point(20, 66), Point::Point(100, 100));&#xA;    a_rectangle.draw();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rectangle.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Point.h&quot;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &amp;lt;Adafruit_ST7735.h&amp;gt; // Hardware-specific library&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;class Rectangle{&#xA;private:&#xA;    Point p1;&#xA;    Point p2;&#xA;public:&#xA;    Rectangle();&#xA;    Rectangle(Point&amp;amp; p1, Point&amp;amp; p2);&#xA;    void setCorners(const Point&amp;amp; p1, const Point&amp;amp; p2);&#xA;    void draw();&#xA;&#xA;    // ... getters and setters for the points&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rectangle.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Rectangle.h&quot;&#xA;&#xA;Rectangle::Rectangle() : p1(), p2()&#xA;    {&#xA;    }&#xA;&#xA;Rectangle::Rectangle(Point&amp;amp; p1, Point&amp;amp; p2) : p1(p1), p2(p2)&#xA;    {&#xA;    }&#xA;&#xA;void Rectangle::setCorners(const Point&amp;amp; p1, const Point&amp;amp; p2) {&#xA;    this-&amp;gt;p1 = p1;&#xA;    this-&amp;gt;p2 = p2;&#xA;}&#xA;&#xA;// this is where I want to use a function from the adafruit library&#xA;void Rectangle::draw() {&#xA;    Adafruit_ST7735::drawRect(p1.getX(), p1.getY(), p2.getX(), p2.getY(), ST7735_GREEN); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14311" LastEditorUserId="14311" LastEditDate="2015-10-28T22:31:31.240" LastActivityDate="2015-10-28T23:33:11.053" Title="Is there a way to use functions defined in a library in any class?" Tags="|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17265" PostTypeId="2" ParentId="17264" CreationDate="2015-10-28T19:42:56.200" Score="0" Body="&lt;p&gt;Yes, there is a way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However that's not how object oriented programming (OOP) is supposed to be used, at least in theory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely you won't like my advice, but here it is: take it easy, find a good book or online course and learn to program on a system that is simpler to debug, than a microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your PC, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C is closer to the HW than java. C++ can be seen as both of them, but there is not so much you can do without learning C, properly.&#xA;From that perspective, C++ can be seen also as a superset of C, only much more complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at &lt;a href=&quot;http://karwin.blogspot.fi/2012/11/c-pointers-explained-really.html&quot; rel=&quot;nofollow&quot;&gt;this explanation&lt;/a&gt;, for example.&#xA;It's quite simple, but exhaustive. Read it carefully and you will find out that pointers are not so difficult to grasp, after all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you spend enough time to get the basics right, it will save you lots of frustration (and, yes, time!) later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a more systematic approach, try &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-28T19:51:43.950" LastActivityDate="2015-10-28T19:51:43.950" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17266" PostTypeId="2" ParentId="17050" CreationDate="2015-10-28T20:20:55.270" Score="1" Body="&lt;p&gt;When you go below (or above) the manufacturer's voltage/clock specifications, expect some problems. One chip may work another will not.  Remember the lower the voltage normally the slower the clock needs to be.  The CPUs are cut from a wafer (size and geometry specific) which may contain many thousand CPU die, they are at different locations on the wafer they will be a little different and they make more then one wafer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check the data sheet, it will show what clock speed will work at what voltage.  As the CPU clock changes so will your baud rate so plan on recalculating that if you change the clock. Example:  If you are operating with a 16MHz clock and change it to 8MHz the baud will be exactly 1/2.  If at 9600 it will be 4800 unless you modify the clock dividers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your error indicates a potential baud rate problem. One of the funny things that happens when the voltage is above/below the manufacturer's speck not all instructions operate properly over temperature. Clock problems should be expected. &lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-28T20:20:55.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17268" PostTypeId="2" ParentId="17259" CreationDate="2015-10-28T20:57:17.810" Score="0" Body="&lt;p&gt;This should help get you started but don't expect it to actually work as it is. Note that i did not test this at all, it's for example purposes.  if there is a specific programming problem it should be addressed separately instead of handing out working code.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int CALIBRATION = 0.200;   //Calibration Constant&#xA;int pin = 2;                     //Pin it's on, this is int0 for uno.&#xA;volatile int rain = 0;           //Used in interrupt routine&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(pin, INPUT);&#xA;    attachInterrupt(digitalPinToInterrupt(pin), cn, FALLING);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;     /* Output OR LOG DATA HERE&#xA;        Also You need a Time Library and RTC (Real Time CLock) the above&#xA;        code is for a raspberry pi that has all that. */&#xA;&#xA;}&#xA;&#xA;void cb() {&#xA;    rain = rain + CALIBRATION;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14405" LastActivityDate="2015-10-28T20:57:17.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17269" PostTypeId="2" ParentId="12930" CreationDate="2015-10-28T20:57:35.847" Score="2" Body="&lt;p&gt;You will have to play some games to make it work.  CAN is a bus with dominate and recessive states.  This is how it arbitrates.  When a unit starts sending a message and another starts concurrently they will both keep transmitting until one is sending a dominate signal and the other is recessive.  At that point the unit placing the recessive signal on the bus backs off and waits until the bus is idle before re-trying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can simulate this with a few transistors (not real CAN but will work).  Monitor the bus with the receive side and drive it with the transistor with a pull up resistor.  When the transistor is on that is the dominate state when the transistor is off that is the recessive state.  This automatically places a priority order to each unit. Also you cannot operate with 1 CAN device, each message has to be acknowledged by another. It is imperative that you receive what you send.  Transceivers are very cheep on eBay and they have the Maxim chip which is very good.&#xA;Good Luck,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-28T20:57:35.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17270" PostTypeId="1" AcceptedAnswerId="17273" CreationDate="2015-10-28T21:41:42.313" Score="0" ViewCount="7113" Body="&lt;p&gt;In the master write/ slave read example for the wire library, there is an integer declared howMany that is never used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup() {&#xA;   Wire.begin(8);                // join i2c bus with address #8&#xA;   Wire.onReceive(receiveEvent); // register event&#xA;   Serial.begin(9600);           // start serial for output&#xA;}&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  while (1 &amp;lt; Wire.available()) { // loop through all but the last&#xA;   char c = Wire.read(); // receive byte as a character&#xA;   Serial.print(c);         // print the character&#xA;}&#xA; int x = Wire.read();    // receive byte as an integer&#xA; Serial.println(x); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the function does not work without it, i would like to know what is its exact purpose.I would imagine that is something regarding the buffer size.&lt;/p&gt;&#xA;" OwnerUserId="14408" LastActivityDate="2022-05-23T15:50:42.383" Title="What is the purpose of the howMany integer in the wire.onReceive() function from the example code?" Tags="|i2c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17271" PostTypeId="1" CreationDate="2015-10-28T22:10:08.533" Score="-1" ViewCount="628" Body="&lt;p&gt;I have 2 motors connected to a dual H-Bridge motor driver and the H-bridge connected to an arduino uno, It was working fine at first but now my motors are spinning very slow and the car bearly moves, I have changed the batteries  but still moves slow and with no power, please help&lt;/p&gt;&#xA;" OwnerUserId="14410" LastActivityDate="2019-09-20T06:08:34.303" Title="H-Bridge L298N motor driver" Tags="|arduino-uno|motor|shields|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17272" PostTypeId="2" ParentId="17271" CreationDate="2015-10-28T22:18:37.243" Score="3" Body="&lt;p&gt;You can try to bisect the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove the Arduino and drive the motors with wires: replace the input for the pwm signal with a +Vcc and you will get the same as if the Arduino was outputting a PWM with 100% duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should allow you to diagnose if there is a problem with the driver/motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that shows no problem and the wheels spin as expected, then you have some issue (either sw or electrical with the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But at least you can halve the complexity of the problem.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-28T22:18:37.243" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17273" PostTypeId="2" ParentId="17270" CreationDate="2015-10-28T23:18:26.027" Score="2" Body="&lt;p&gt;It tells you how many bytes have been received, and consequently how many you can read with &lt;code&gt;Wire.read()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before you have read anything with &lt;code&gt;Wire.read()&lt;/code&gt; &lt;code&gt;Wire.available()&lt;/code&gt; will return the same value.  As you read from the buffer &lt;code&gt;Wire.available()&lt;/code&gt; will decrease, but &lt;code&gt;howMany&lt;/code&gt; will stay the same.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-28T23:18:26.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17274" PostTypeId="2" ParentId="17264" CreationDate="2015-10-28T23:27:12.677" Score="0" Body="&lt;p&gt;There are two basic methods to do what you want:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Inheritance&lt;/li&gt;&#xA;&lt;li&gt;Pointer passing&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Inheritance involves making your new class a &lt;em&gt;child&lt;/em&gt; class of the Adafruit TFT class.  You new class then gets all the public functions of the Adafruit class - it essentially becomes the Adafruit class &lt;em&gt;plus&lt;/em&gt; your extra functions overlaid over the top:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Rectangle : public Adafruit_ST7735 {&#xA;    ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have to ensure that you provide a suitable constructor that passes the right parameters to the Adafruit parent class, and then you create a Rectangle class &lt;em&gt;instead&lt;/em&gt; of the Adafruit class in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Inheritance tutorial: &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/inheritance/&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/doc/tutorial/inheritance/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That is fine if you just want one class that uses the functions from the Adafruit class.  The second option is to pass a pointer (or reference) to the Adafruit class to your other classes, either when you construct them or at function call time.  For instance, you might have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Rectangle {&#xA;    private:&#xA;        Adafruit_ST7735 *_tft;&#xA;&#xA;    public:&#xA;        Rectangle(Adafruit_ST7735 &amp;amp;tft) : _tft(&amp;amp;tft) {}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in your function you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Rectangle::draw() {&#xA;    _tft-&amp;gt;drawRect(p1.getX(), p1.getY(), p2.getX(), p2.getY(), ST7735_GREEN);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You would, of course, construct your class with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_ST7735 myTFTScreen(blah blah blah);&#xA;Rectangle myRect(myTFTScreen);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then call &lt;code&gt;myRect.draw();&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-28T23:33:11.053" LastActivityDate="2015-10-28T23:33:11.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17275" PostTypeId="1" AcceptedAnswerId="17384" CreationDate="2015-10-28T23:42:57.620" Score="0" ViewCount="1399" Body="&lt;p&gt;I have a Arduino UNO with a Ethernet shield which hosts a basic HTML page with a button on it which controls a Relay module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to connect to a computer's power button so I can turn it on remotely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found out that the relay basically does the opposite to the digital pin's output&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally open Relay &lt;br&gt;&#xA;HIGH = Open &lt;br&gt;&#xA;LOW = Closed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected it through a NOT Gate made using a NPN transistor and it works perfectly how I wanted it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to the question... Is there a way to write the code to make the digital pin = HIGH straight away and fast enough to not allow the relay to close the circuit and accidentally turn the computer on/off when the Arduino restarts, so I don't have to use a NOT Gate.&lt;/p&gt;&#xA;" OwnerUserId="14411" LastActivityDate="2020-05-13T22:07:34.250" Title="Relay doing opposite to digital pin" Tags="|arduino-uno|ethernet|relay|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17276" PostTypeId="2" ParentId="17275" CreationDate="2015-10-29T00:26:58.763" Score="0" Body="&lt;p&gt;You could use a less invasive way to turn on your computer: &lt;a href=&quot;https://en.wikipedia.org/wiki/Wake-on-LAN&quot; rel=&quot;nofollow&quot;&gt;wake on LAN&lt;/a&gt;. In this case you only need to generate the magic packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It won't work in forcibly turning off the PC, but it's more generic and doesn't require HW hacking.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-29T00:26:58.763" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17277" PostTypeId="1" CreationDate="2015-10-29T04:58:09.957" Score="1" ViewCount="559" Body="&lt;p&gt;I am rather new to the Arduino world and am looking for a way to create my own tipping rain gauge with only one Arduino(micro).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had some help from a friend to get a loop that checks for when a switch is closed, which signals that the bucket has tipped and thus &quot;x units&quot; of rain have fallen. The code I have for sensing this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  /*&#xA;    digitalWrite(4, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(4, LOW);&#xA;    delay(6500);&#xA;  */&#xA;  int analogValue = digitalRead(8);&#xA;&#xA;  if (analogValue==HIGH)&#xA;  {&#xA;    Serial.println(count);&#xA;    count++;&#xA;    delay(250);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I developed a code to count up in 0.5 second intervals so that I could essentially time stamp when the switch from the first loop was closed/activated. The code for the timer is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  while (ssec &amp;lt; 10)&#xA;  {&#xA;    Serial.print(hour);&#xA;    Serial.print(&quot;:&quot;);&#xA;    Serial.print(minute);&#xA;    Serial.print(&quot;:&quot;);&#xA;    Serial.print(sec);&#xA;    Serial.print(&quot;.&quot;);&#xA;    Serial.print(ssec);&#xA;    //Serial.print(&quot; s&quot;);&#xA;    //Serial.println();&#xA;    ssec += 5;&#xA;    delay(500);&#xA;    Serial.println();&#xA;  }&#xA;  if (ssec == 10);&#xA;  {&#xA;    sec++;&#xA;    ssec = 0;&#xA;    //Serial.print(sec);&#xA;    //Serial.print(&quot;.&quot;);&#xA;    //Serial.print(ssec);&#xA;  }&#xA;  if (sec == 60)&#xA;  {&#xA;    minute++;&#xA;    sec = 0;&#xA;  }&#xA;  if (minute == 60)&#xA;  {&#xA;    hour++;&#xA;    minute = 0;&#xA;  }&#xA;  if (hour == 24)&#xA;  {&#xA;    Serial.println();&#xA;    Serial.print(&quot;DAY &quot;);&#xA;    Serial.print(day);&#xA;    Serial.print(&quot; COMPLETED!&quot;);&#xA;    Serial.print(&quot;Data Points: &quot;);&#xA;    //Serial.print(count);&#xA;    Serial.println();&#xA;    Serial.println();&#xA;    hour = 0;&#xA;    day++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that it is very hard to run these together at the same time due to the fact that I am using a delay function to run the timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any ways to essentially run these side by side? Or a library I can use that will run the timer while i have the arduino looking for the switch to close, and I can simply call the timer when I need it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for any and all help! :)&lt;/p&gt;&#xA;" OwnerUserId="14417" LastEditorUserId="7508" LastEditDate="2016-05-27T09:58:49.420" LastActivityDate="2016-05-27T13:58:19.707" Title="Altering code to run a timer while checking for a data input" Tags="|c++|arduino-micro|timing|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17279" PostTypeId="2" ParentId="4039" CreationDate="2015-10-29T06:40:56.807" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino sketches usually feature a setup and loop function. Are these functions only provided for convenience or do they actually have special purposes? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They throw in an extra function call to &lt;code&gt;init&lt;/code&gt; which initializes the timers which let &lt;code&gt;millis&lt;/code&gt;, &lt;code&gt;micros&lt;/code&gt; and &lt;code&gt;delay&lt;/code&gt; work without further effort. Other than that, no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code compiles (and runs) under the IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Effectively the IDE generates code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main ()&#xA;  {&#xA;  init ();  // set up timers&#xA;  setup (); // your own initialization&#xA;  while (true)&#xA;    loop ();  // stuff you want to keep doing&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;They have fiddled with it since then, as Ignacio Vazquez-Abrams said, but basically you can ignore that. There is nothing particularly special about &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;main&lt;/code&gt; like I showed above. You can do everything in &lt;code&gt;setup&lt;/code&gt; if you want. You can do everything in &lt;code&gt;loop&lt;/code&gt; if you want (if you never return from it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember, you are dealing with a C++ compiler here. Functions don't have some magic significance based on their names.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-29T06:40:56.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17280" PostTypeId="2" ParentId="17270" CreationDate="2015-10-29T06:48:36.010" Score="1" Body="&lt;p&gt;The reference page &lt;a href=&quot;https://www.arduino.cc/en/Reference/WireOnReceive&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/WireOnReceive&lt;/a&gt; states:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Parameters&lt;/p&gt;&#xA;&lt;p&gt;handler: the function to be called when the slave receives data; this should take a single int parameter (the number of bytes read from the master) and return nothing, e.g.: &lt;code&gt;void myHandler(int numBytes)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I suggest you look at the reference pages for the functions in future before asking what they do.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-10-29T06:48:36.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17281" PostTypeId="2" ParentId="17277" CreationDate="2015-10-29T06:59:00.223" Score="1" Body="&lt;p&gt;What's with the double-spacing? It makes it hard to read.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(ssec==10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/tips#trap13&quot; rel=&quot;nofollow&quot;&gt;Arduino programming traps, tips and style guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I understand that it is very hard to run these together at the same time due to the fact that I am using a delay function to run the timer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know StackExchange doesn't like link-only answers, but it is this or copy-and-paste:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;How to do multiple things at once ... like cook bacon and eggs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-29T06:59:00.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17282" PostTypeId="1" AcceptedAnswerId="17283" CreationDate="2015-10-29T09:03:55.460" Score="0" ViewCount="68" Body="&lt;p&gt;I have successfully implemented some code which uses a linked-list.  Everything is working, except assigning a value to a float within the embeded class.  When I run the code below, I get the expected behavior, a flashing LED for 10 secs then LED turns continuously ON, and I also get the debug messages I expect.  However, when I comment the marked line to assign a value to the float, it still compiles, but the LED does not flash as expected and I get complete rubbish from debug.  I am using codebender on Chrome, and I have tried Firefox (both given same results).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main Sketch &lt;a href=&quot;https://codebender.cc/sketch:175995&quot; rel=&quot;nofollow&quot;&gt;https://codebender.cc/sketch:175995&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of library working &lt;a href=&quot;https://codebender.cc/sketch:176008&quot; rel=&quot;nofollow&quot;&gt;https://codebender.cc/sketch:176008&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void(*GF)(void);&#xA;&#xA;#include &quot;LinkedList.h&quot;&#xA;&#xA;class CsC {&#xA;    public:&#xA;        float PerS;&#xA;        GF FunctionToCall;&#xA;};&#xA;&#xA;LinkedList&amp;lt;CsC*&amp;gt; TaskList = LinkedList&amp;lt;CsC*&amp;gt;();&#xA;&#xA;void LEDON()&#xA;{&#xA;    digitalWrite(13,HIGH);&#xA;}&#xA;void after(float interval, String intervalDescription, GF func);&#xA;&#xA;void after(float interval, String intervalDescription, GF func)&#xA;{&#xA;    float multi = 1;&#xA;    if(intervalDescription == &quot;mins&quot;) multi *= 60;&#xA;    float delayMS = multi * interval;&#xA;    CsC *c;&#xA;    //Error if either of these lines uncommented&#xA;    //c-&amp;gt;PerS=10000;&#xA;    //c-&amp;gt;PerS=delayMS;&#xA;    c-&amp;gt;FunctionToCall=func;&#xA;    TaskList.add(c);&#xA;    Serial.print(&quot;.&quot;);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(13, OUTPUT);&#xA;    Serial.println(&quot;Start write task list&quot;);&#xA;&#xA;    after(35,&quot;secs&quot;,LEDON);&#xA;&#xA;    Serial.println(&quot;Done&quot;);&#xA;    Serial.println(&quot;Start prog&quot;);&#xA;}&#xA;void loop()&#xA;{&#xA;    Serial.print(&quot;List=&quot;);&#xA;    Serial.print(TaskList.size());&#xA;    while(TaskList.size()&amp;gt;0){&#xA;        CsC *c=TaskList.shift();&#xA;        long timeout=millis()+10000;&#xA;        //long timeout=millis()+((long)(c-&amp;gt;PerS*1000.0));&#xA;        while(millis()&amp;lt;timeout){&#xA;            //To indicate it is running, and to save time, I have used a delay here&#xA;            digitalWrite(13,HIGH);&#xA;            delay(250);&#xA;            digitalWrite(13,LOW);&#xA;            delay(250);&#xA;        }&#xA;        c-&amp;gt;FunctionToCall();&#xA;    }&#xA;    Serial.print(&quot;.&quot;);&#xA;    Serial.println(&quot;complete&quot;);&#xA;    while(1){}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11988" LastActivityDate="2015-10-29T09:38:03.787" Title="Problem assign float to an embed class within the Linked-list libary" Tags="|c++|library|class|float|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17283" PostTypeId="2" ParentId="17282" CreationDate="2015-10-29T09:38:03.787" Score="1" Body="&lt;p&gt;One possible error is a memory leak as you did not allocate the memory to the class&#xA;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CsC *c=new CsC();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11988" LastActivityDate="2015-10-29T09:38:03.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17284" PostTypeId="2" ParentId="17184" CreationDate="2015-10-29T09:59:56.100" Score="0" Body="&lt;p&gt;A quick thing to try out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try changing &lt;code&gt;Serial.begin(115200);&lt;/code&gt; to &lt;code&gt;Serial.begin(9600);&lt;/code&gt; and leave  &lt;code&gt;esp8266.begin(115200);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also completely new to Arduino, but I remember seeing the junk values when the serial monitor baud rate is set to a different value than the Arduino's Baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using Arduino Uno and if I set the baud rate to a value other 9600 in the serial window, I was seeing junk values in println function calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e Set &lt;code&gt;Serial.Begin(9600);&lt;/code&gt; and the Serial Montior baud rate also &lt;code&gt;9600&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12116" LastActivityDate="2015-10-29T09:59:56.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17285" PostTypeId="1" CreationDate="2015-10-29T10:45:48.313" Score="0" ViewCount="1316" Body="&lt;p&gt;Hello I have managed to get both the Adafruit Datalogging shield walk-through and this individual code working &lt;a href=&quot;http://www.learn.parallax.com/reed-switch-arduino-demo&quot; rel=&quot;nofollow&quot;&gt;http://www.learn.parallax.com/reed-switch-arduino-demo&lt;/a&gt; separately, but trying to combine the two together I get these errors. I think I have it all arranged correctly but any help would be greatly appreciated. Board Arduino Uno and Adafruit Datalogger shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Temp_and_Reed_Switch_data_logging_shield.ino:55:1: error: 'Serial' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:58:8: error: expected constructor, destructor, or type conversion before '(' token&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:61:1: error: expected unqualified-id before 'if'&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:66:1: error: 'Serial' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:70:1: error: expected unqualified-id before 'for'&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:70:21: error: 'i' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:70:30: error: 'i' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:80:1: error: expected unqualified-id before 'if'&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:84:1: error: 'Serial' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:85:1: error: 'Serial' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:87:1: error: 'Wire' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:88:1: error: expected unqualified-id before 'if'&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:95:1: error: 'logfile' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:97:1: error: 'serial' does not name a type&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:98:1: error: expected unqualified-id before 'if'&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:104:8: error: expected constructor, destructor, or type conversion before '(' token&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:105:8: error: expected constructor, destructor, or type conversion before '(' token&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:107:8: error: expected constructor, destructor, or type conversion before '(' token&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:108:13: error: expected constructor, destructor, or type conversion before '(' token&#xA;Temp_and_Reed_Switch_data_logging_shield.ino:114:1: error: expected declaration before '}' token&#xA;Multiple libraries were found for &quot;SD.h&quot;&#xA;&#xA; Used: C:\Users\Andrew\Documents\Arduino\libraries\SD&#xA;&#xA; Not used: C:\Program Files (x86)\Arduino\libraries\SD&#xA;&#xA;'Serial' does not name a type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//  SD card datalogger&#xA;// SD card attached to SPI bus as follows:&#xA;// MOSI - pin 11&#xA;// MISO - pin 12&#xA;// CLK - pin 13&#xA;// CS - pin 10&#xA;&#xA;#include &quot;SD.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define LOG_INTERVAL  1000 // mills between entries&#xA;#define ECHO_TO_SERIAL   1 // echo data to serial port&#xA;#define WAIT_TO_START    0 // Wait for serial input in setup()&#xA;&#xA;&#xA;// the digital pins that connect to the LEDs&#xA;#define redLEDpin 4&#xA;#define greenLEDpin 5&#xA;&#xA;// The analog pins that connect to the sensors&#xA;&#xA;#define tempPin 1                // analog 1&#xA;&#xA;RTC_DS1307 RTC; // define the Real Time Clock object&#xA;const int chipSelect = 10;&#xA;const int switchPin = 2;     //     // Reed switch to digital pin 2&#xA;&#xA;// the logging file&#xA;File logfile;&#xA;&#xA;void error(char *str)&#xA;{&#xA;  Serial.print(&quot;error: &quot;);&#xA;  Serial.println(str);&#xA;&#xA;  // red LED indicates error&#xA;  digitalWrite(redLEDpin, HIGH);&#xA;&#xA;  while (1);&#xA;}&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  Serial.println();&#xA;  //If we set WAIT_TO_START to anything but 0, the Arduino will wait until the user types something in.&#xA;#if WAIT_TO_START&#xA;  Serial.println(&quot;Type any character to start&quot;);&#xA;  while (!Serial.available());&#xA;#endif //WAIT_TO_START&#xA;}&#xA;&#xA;&#xA;// initialize the SD card&#xA;Serial.print(&quot;Initializing SD card...&quot;);&#xA;// make sure that the default chip select pin is set to&#xA;// output, even if you don't use it:&#xA;pinMode(10, OUTPUT);&#xA;&#xA;// see if the card is present and can be initialized:&#xA;if (!SD.begin(chipSelect)) {&#xA;  Serial.println(&quot;Card failed, or not present&quot;);&#xA;  // don't do anything more:&#xA;  return;&#xA;}&#xA;Serial.println(&quot;card initialized.&quot;);&#xA;&#xA;// create a new file on SD Card called Logger number&#xA;char filename[] = &quot;LOGGER00.CSV&quot;;&#xA;for (uint8_t i = 0; i &amp;lt; 100; i++) {&#xA;  filename[6] = i / 10 + '0';&#xA;  filename[7] = i % 10 + '0';&#xA;  if (! SD.exists(filename)) {&#xA;    // only open a new file if it doesn't exist&#xA;    logfile = SD.open(filename, FILE_WRITE);&#xA;    break;  // leave the loop!&#xA;  }&#xA;}&#xA;&#xA;if (! logfile) {&#xA;  error(&quot;couldnt create file&quot;);&#xA;}&#xA;&#xA;Serial.print(&quot;Logging to: &quot;);&#xA;Serial.println(filename);&#xA;&#xA;Wire.begin();&#xA;if (!RTC.begin()) {&#xA;  logfile.println(&quot;RTC failed&quot;);&#xA;#if ECHO_TO_SERIAL&#xA;  Serial.println(&quot;RTC failed&quot;);&#xA;#endif  //ECHO_TO_SERIAL&#xA;}&#xA;&#xA;logfile.println(&quot;millis,time,temp,reedswitch&quot;);&#xA;#if ECHO_TO_SERIAL // attempt to write out the header to the file&#xA;serial.println(&quot;millis,time,temp,reedswitch&quot;);&#xA;if (logfile.writeError || !logfile.sync()) {&#xA;  error(&quot;write header&quot;);&#xA;#endif   //ECHO_TO_SERIAL&#xA;}&#xA;&#xA;&#xA;pinMode(redLEDpin, OUTPUT);&#xA;pinMode(greenLEDpin, OUTPUT);&#xA;&#xA;pinMode(switchPin, INPUT);        // switchPin is an input&#xA;digitalWrite(switchPin, HIGH);    // Activate internal pullup resistor&#xA;long lastDebounce1 = 0;&#xA;long debounceDelay = 500;    // Ignore bounces under 1/2 second&#xA;&#xA;// If you want to set the aref to something other than 5v&#xA;//analogReference(EXTERNAL);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  DateTime now;&#xA;&#xA;  // delay for the amount of time we want between readings&#xA;  delay((LOG_INTERVAL - 1) - (millis() % LOG_INTERVAL));&#xA;&#xA;  digitalWrite(greenLEDpin, HIGH);&#xA;&#xA;  // log milliseconds since starting&#xA;  uint32_t m = millis();&#xA;  logfile.print(m);           // milliseconds since start&#xA;  logfile.print(&quot;, &quot;);&#xA;#if ECHO_TO_SERIAL&#xA;  Serial.print(m);         // milliseconds since start&#xA;  Serial.print(&quot;, &quot;);&#xA;#endif&#xA;&#xA;  // fetch the time&#xA;  now = RTC.now();&#xA;  // log time&#xA;  logfile.print(now.get()); // seconds since 2000&#xA;  logfile.print(&quot;, &quot;);&#xA;  logfile.print(now.year(), DEC);&#xA;  logfile.print(&quot;/&quot;);&#xA;  logfile.print(now.month(), DEC);&#xA;  logfile.print(&quot;/&quot;);&#xA;  logfile.print(now.day(), DEC);&#xA;  logfile.print(&quot; &quot;);&#xA;  logfile.print(now.hour(), DEC);&#xA;  logfile.print(&quot;:&quot;);&#xA;  logfile.print(now.minute(), DEC);&#xA;  logfile.print(&quot;:&quot;);&#xA;  logfile.print(now.second(), DEC);&#xA;#if ECHO_TO_SERIAL&#xA;  Serial.print(now.get()); // seconds since 2000&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(now.year(), DEC);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(now.month(), DEC);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(now.day(), DEC);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(now.hour(), DEC);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(now.minute(), DEC);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(now.second(), DEC);&#xA;#endif //ECHO_TO_SERIAL &#xA;&#xA;  delay(10);&#xA;  int tempReading = analogRead(tempPin);&#xA;&#xA;  // converting that reading to voltage, for 3.3v arduino use 3.3&#xA;  float voltage = tempReading * 5.0 / 1024;&#xA;  float temperatureC = (voltage - 0.5) * 100 ;&#xA;&#xA;  logfile.print(&quot;, &quot;);&#xA;  logfile.println(temperatureC);&#xA;  logfile.print(&quot;, &quot;);&#xA;  logfile.print(reedswitch);&#xA;#if ECHO_TO_SERIAL&#xA;&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.println(temperatureC);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(reedswitch);&#xA;#endif //ECHO_TO_SERIAL&#xA;&#xA;  digitalWrite(greenLEDpin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14401" LastEditorUserId="3" LastEditDate="2015-10-29T11:32:47.247" LastActivityDate="2015-10-29T14:25:50.773" Title="Formatting and code errors?" Tags="|arduino-uno|programming|compile|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17289" PostTypeId="2" ParentId="17285" CreationDate="2015-10-29T12:04:42.993" Score="2" Body="&lt;p&gt;Everything you have written between the end of &lt;code&gt;setup()&lt;/code&gt; (line 55) to the start of &lt;code&gt;loop()&lt;/code&gt; (line 117) is not in a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are struggling to combine two or more programs, start small and work your way to the full code.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-10-29T12:04:42.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17290" PostTypeId="1" CreationDate="2015-10-29T12:34:42.007" Score="0" ViewCount="279" Body="&lt;p&gt;So, I have a lcd that takes up the whole board of an arduino mega. I want to connect a temperature sensor and make a really lame weather station, but the lcd screen is totally in the road. It's a shield so this is to be expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come up with wacky ideas, like soldering to the rear of the board but I think that's a bad idea. Surely there must be a better way? The lcd shield exposes no pins.&lt;/p&gt;&#xA;" OwnerUserId="14424" LastActivityDate="2016-02-26T20:53:28.027" Title="How can I connect more sensors when my lcd is blocking pin access?" Tags="|shields|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17291" PostTypeId="2" ParentId="17290" CreationDate="2015-10-29T12:39:00.403" Score="1" Body="&lt;p&gt;What you need is a shield that can go between the Arduino and the LCD shield and break out whatever connections you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are generally available as &quot;screw terminal&quot; shields, such as this one from iTead:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.itead.cc/mega-proto-screw-shield.html&quot; rel=&quot;nofollow&quot;&gt;http://www.itead.cc/mega-proto-screw-shield.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-29T12:39:00.403" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17293" PostTypeId="1" CreationDate="2015-10-29T13:47:22.227" Score="0" ViewCount="160" Body="&lt;p&gt;I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include “TimerOne.h”&#xA;bool val=0;&#xA;void setup()&#xA;{&#xA;    pinMode(13, OUTPUT);&#xA;    Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period&#xA;    Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;    val=1;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(13,val);&#xA;    while(!val);&#xA;    val=0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The LED doesnt blink at all! Any help would be appreceitated!&#xA;thanks!&lt;/p&gt;&#xA;" OwnerUserId="14428" LastEditorUserId="4143" LastEditDate="2015-10-29T15:04:37.553" LastActivityDate="2015-10-29T18:17:53.567" Title="How to resolve my Timer Interrupt issue" Tags="|arduino-uno|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17294" PostTypeId="2" ParentId="17285" CreationDate="2015-10-29T14:25:50.773" Score="0" Body="&lt;p&gt;Building furhter onto &lt;a href=&quot;https://arduino.stackexchange.com/a/17289/14429&quot;&gt;@CharlieHanson's answer&lt;/a&gt;, what you should do in order to fix this is probably following changes (&lt;em&gt;please note that I wrote this in order to try to get rid of the errors, the flow of the program may still not be correct, that depends entirely on how you put together the code from the files&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Remove the bracket at line 52, just a few lines down in the &lt;code&gt;setup()&lt;/code&gt;-method, below this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#endif //WAIT_TO_START&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. (Maybe not nessecary, but for manageability)&lt;/strong&gt; Move this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long lastDebounce1 = 0;&#xA;long debounceDelay = 500;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-from where it currently is (just a few lines above the beginning of the &lt;code&gt;loop()&lt;/code&gt;-method) to the other variable declarations (above the &lt;code&gt;error()&lt;/code&gt;-method).&lt;/p&gt;&#xA;" OwnerUserId="14429" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-10-29T14:25:50.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17295" PostTypeId="2" ParentId="17293" CreationDate="2015-10-29T15:07:03.110" Score="0" Body="&lt;p&gt;I'm not surprised the LED doesn't blink - the entirety of your logic in the loop() function is so bizarre as to elicit the question:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;WTF?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Let's take a look at it line by line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(13,val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set the LED to whatever &lt;code&gt;val&lt;/code&gt; is - &lt;code&gt;val&lt;/code&gt; starts as 0, so the LED is off.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(!val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While &lt;code&gt;val&lt;/code&gt; is not anything except 0, so while val is zero, do nothing. (The interrupt would escape you from this if your &lt;code&gt;val&lt;/code&gt; was &lt;code&gt;volatile&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;val=0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set &lt;code&gt;val&lt;/code&gt; to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can &lt;code&gt;val&lt;/code&gt; be anything except 0 when you do the digitalWrite?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-10-29T16:03:14.793" LastActivityDate="2015-10-29T16:03:14.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17296" PostTypeId="1" AcceptedAnswerId="17612" CreationDate="2015-10-29T15:35:48.577" Score="1" ViewCount="2119" Body="&lt;p&gt;I am using Arduino UNO and trying to interface 2 16-bit &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/ads8319.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ADS8319&lt;/a&gt; ADCs with it via the SPI interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have interfaced the 2 ADCs with the micro-controller using the &quot;4 Wire CS Mode Without Busy Indicator&quot; (data sheet page number 15). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following code to get the values from the ADCs.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#define CONVPIN 7&#xA;#define SELPIN 8&#xA;#define SELPIN2 4&#xA;#define MISOPIN 12&#xA;#define SCLKPIN 13&#xA;&#xA;int adcvalue;&#xA;byte byte1; byte byte2;&#xA;const float aRefVoltage = 5;&#xA;float volts = 0;&#xA;&#xA;void setup() {&#xA;&#xA;  // put your setup code here, to run once:&#xA;  pinMode(SELPIN, OUTPUT); // ADC's selection pin&#xA;  pinMode(SELPIN2, OUTPUT); // 2nd ADC's selection pin&#xA;  pinMode(CONVPIN, OUTPUT); // ADC's conversion pin&#xA;  pinMode(SCLKPIN, OUTPUT); // ADC's clock pin&#xA;  pinMode(MISOPIN, INPUT);  // ADC's data out&#xA;  SPI.begin();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  digitalWrite(CONVPIN, LOW);&#xA;  digitalWrite(SELPIN, HIGH);&#xA;  digitalWrite(SELPIN2, HIGH);&#xA;  digitalWrite(CONVPIN, HIGH);&#xA;  digitalWrite(SELPIN, LOW);&#xA;&#xA;  delay(1000);&#xA;&#xA;  byte1 = SPI.transfer(0x00); //transfer (read) 8 bits from the adc chip D15-8&#xA;  byte2 = SPI.transfer(0x00);  //transfer (read) the second 8 bits. D7-0&#xA;&#xA;  adcvalue = (byte1 &amp;lt;&amp;lt;8) | (byte2 &amp;amp; 0xff);  // combine the 2 bytes to make our 16 bit word&#xA;  Serial.print(&quot;Voltage Value: &quot;);&#xA;  Serial.println(adcvalue,BIN);&#xA;  volts = (adcvalue*aRefVoltage/65535);&#xA;  Serial.print(&quot; Sensor Volts: &quot;);&#xA;  Serial.println(volts,5);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However i am not getting the right values. The ADC that ive selected by &quot;digitalWrite(SELPIN, LOW);&quot; should output 1V, whereas the values keep on changing in between 0 and 2.2 V .I am not sure if my code is correct or not. Can you please verify the code so that i should know whether the problem is in my hardware, or the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the screenshot for my schematic :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jb2d8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jb2d8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your helpful suggestions and comments would be appreciated !&#xA;Thankyou.&lt;/p&gt;&#xA;" OwnerUserId="13187" LastEditorUserId="7856" LastEditDate="2015-10-30T16:08:43.170" LastActivityDate="2021-02-05T06:24:22.760" Title="Interfacing ADS8319 with Arduino UNO" Tags="|arduino-uno|spi|adc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17297" PostTypeId="1" CreationDate="2015-10-29T15:44:23.467" Score="1" ViewCount="546" Body="&lt;p&gt;I'm trying to learn AVR development in C and Assembly for the Arduino Uno (Atmel 328p microprocessor) in Linux. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found many good guides on how to install and setup the AVR plugin for Eclipse, and I've no problem building and uploading C code. &#xA;However there doesn't seem to be any menu options for creating an assembler project, nor can I seem to find the correct syntax for using the cli avr-as for assembling my programs into a .hex file.&lt;/p&gt;&#xA;" OwnerUserId="14430" LastActivityDate="2016-02-27T20:06:00.570" Title="How is AVR Assembly in Eclipse or at Linux command line done?" Tags="|linux|assembly|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17299" PostTypeId="1" AcceptedAnswerId="17313" CreationDate="2015-10-29T17:26:34.257" Score="0" ViewCount="817" Body="&lt;p&gt;I've designed this system which is supposed to turn on the LEDs when the temperature of a particular probe exceeds 32 degrees. From what I can tell, this should be functional but the analog sensor is always reading 0 when calling analogRead() on the pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an image of my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TiksO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TiksO.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int length = 5;&#xA;float airTemp = 32;&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{      &#xA;  // loads current temperature into array&#xA;  int reading;&#xA;  float voltage;&#xA;  float temp[length];&#xA;  for (int i = 0; i &amp;lt; length; i++) &#xA;  {&#xA;    reading = analogRead(i);&#xA;    Serial.print(reading);&#xA;    voltage = reading * 5.0;&#xA;    voltage /= 1024;&#xA;    temp[i] = (voltage - 0.5) * 100;&#xA;  }&#xA;&#xA;  // turns on/off fans based on current temperature&#xA;  for (int i = 0; i &amp;lt; length; i++) &#xA;  {  &#xA;    pinMode(i, OUTPUT);&#xA;    if (temp[i] &amp;gt; airTemp) &#xA;    {&#xA;      digitalWrite(i + 8, HIGH);&#xA;    } &#xA;    else if(temp[i] &amp;lt;= airTemp) &#xA;    {&#xA;      digitalWrite(i + 8, LOW);    &#xA;    }&#xA;  }  &#xA;  delay(1000);&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I learned how to read the temperature from &lt;a href=&quot;https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. It's probably a dumb mistake, but I just started working with Arduino yesterday and I couldn't find information anywhere so thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14431" LastActivityDate="2015-10-29T20:36:54.050" Title="TMP36 probe reading 0 on analog" Tags="|arduino-uno|sensors|sketch|temperature-sensor|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17300" PostTypeId="2" ParentId="17299" CreationDate="2015-10-29T17:42:13.503" Score="0" Body="&lt;p&gt;Make sure your breadboard isn't one of the ones with split power rails.  If the coloured lines on the + and GND rails have a break in them you will need to bridge that break with wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solid rail:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9qMjR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9qMjR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Split rail:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PPDh9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PPDh9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-29T17:42:13.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17301" PostTypeId="1" AcceptedAnswerId="17388" CreationDate="2015-10-29T17:50:13.783" Score="1" ViewCount="936" Body="&lt;p&gt;I recently bought this linear actuator and motor controller from Pololu:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.pololu.com/product/2305&quot; rel=&quot;nofollow&quot;&gt;Linear actuator&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.pololu.com/product/1394&quot; rel=&quot;nofollow&quot;&gt;Motor Controller JRK21v3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are several steps that I have to follow in order to set this thing up before I can test it. These instructions can be found here: &lt;a href=&quot;http://www.pololu.com/docs/0J38/5&quot; rel=&quot;nofollow&quot;&gt;Pololu JRK USB Motor Controller User’s Guide » Setting Up Your System&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to program this using PWM method because I would like to keep the Serial RX for other sensors.  From my little experiment, by using a potentiometer, I noticed this pattern:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Position: Voltage &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fully extended : 0 V&lt;/li&gt;&#xA;&lt;li&gt;At Rest : 2.35V&lt;/li&gt;&#xA;&lt;li&gt;Fully Retracted  : 4.77V.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For this system, I will be controlling it using a PS2 controller. So, by using only the Y_axis of the analog joystick of a PS2 Controller (Up: 0, Rest: 128 and Down: 255), I program it as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//Move Linear Actuator with PS2 on JRK21v3 Controller&#xA;&#xA;#define pwm 6           //red wire &#xA;#define dir 7           //yellow wire&#xA;&#xA;//PS2 controller&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Cytron_PS2Shield.h&amp;gt;&#xA;&#xA;Cytron_PS2Shield ps2(10, 11); // SoftwareSerial: Rx and Tx pin&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(pwm,OUTPUT);&#xA;&#xA;  ps2.begin(9600); &#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int Y_axis = ps2.readButton(PS2_JOYSTICK_RIGHT_Y_AXIS);  // 0 - 255&#xA;  Serial.print(&quot;Y_axis:&quot;);&#xA;  Serial.println(Y_axis);&#xA;&#xA;  analogWrite(pwm, Y_axis);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I tested it, the linear actuator jitters/vibrates when it is at rest position. What could possibly cause this? Is it the duty cycle due to the PWM? How can I fix this or are there any other better methods?&lt;/p&gt;&#xA;" OwnerUserId="13456" LastEditorUserId="6936" LastEditDate="2016-03-16T07:40:32.243" LastActivityDate="2016-03-16T07:40:32.243" Title="Linear actuator jitters/vibrates when getting PWM from Arduino Mega 2560 through JKR 21v3 motor controller" Tags="|arduino-mega|motor|pwm|robotics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17302" PostTypeId="1" CreationDate="2015-10-29T17:59:37.687" Score="0" ViewCount="880" Body="&lt;p&gt;I want to detect if a seat is occupied by a person. This is &lt;a href=&quot;https://arduino.stackexchange.com/questions/1288/detect-and-stream-if-a-chair-is-occupied/1308#1308&quot;&gt;the answer&lt;/a&gt; that I found on Stackoverflow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how accurate is the output of 4 suggested sensors? Will the computing of all these 4 sensor values into one boolean recognize a case when, for instance, a box of 40kg is placed on a seat and some person is just slightly &quot;shaking&quot; that seat with a hand? In those cases Arduino should recognize that a seat is not occupied by a person. Will it work with only 4 sensors or is there any better and more accurate solution (maybe some existing library)? I guess that CapSense-Library is not applicable in my case.&lt;/p&gt;&#xA;" OwnerUserId="14433" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-07-06T06:48:13.660" Title="Detect if a chair is occupied using Arduino with some sensors" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17303" PostTypeId="1" AcceptedAnswerId="17308" CreationDate="2015-10-29T18:02:04.400" Score="0" ViewCount="35" Body="&lt;p&gt;I'm doing a project on the arduino with simple 433MHz antenna modules. And I was wondering if someone could offer clarifications on how receivers work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that high gain receivers can pick up a very narrow beam of radio power and thus, can transfer data at high rates. Given that this signal is tightly focused to the transmitting end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a low gain receiver can pick up a much wider beam of radio power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is the following. When they say &quot;narrower beam&quot; does that represent the amplitude of the signal or the number of different waves that are being transmitted? OR does it refer to the number of DIFFERENT frequencies it can pick up? Sorry, if my question is confusing. Happy to clarify any part of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Source: &lt;a href=&quot;http://www.qrg.northwestern.edu/projects/vss/docs/communications/2-what-are-high-and-low-gain.html&quot; rel=&quot;nofollow&quot;&gt;http://www.qrg.northwestern.edu/projects/vss/docs/communications/2-what-are-high-and-low-gain.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13674" LastActivityDate="2015-10-29T19:03:43.987" Title="Gain on a receiver" Tags="|hardware|communication|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17304" PostTypeId="1" CreationDate="2015-10-29T18:07:15.320" Score="0" ViewCount="376" Body="&lt;p&gt;how do I compare coordinates I receive from the GPS module with the coordinates that I had hardcoded into the arduino, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if (GPS reading &amp;lt;= hardcoded)&#xA;   movecarforward();&#xA;else&#xA;   movecarback();&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the coordinates I get keep going up and down which makes it difficult for me to compare and excute the function below.Please help.....&lt;/p&gt;&#xA;" OwnerUserId="14410" LastActivityDate="2015-11-28T23:36:00.173" Title="GPS coordinates" Tags="|arduino-uno|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17305" PostTypeId="2" ParentId="17293" CreationDate="2015-10-29T18:17:53.567" Score="1" Body="&lt;p&gt;Try this instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include “TimerOne.h”&#xA;bool val=0;&#xA;void setup()&#xA;{&#xA;    pinMode(13, OUTPUT);&#xA;    Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period&#xA;    Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;    val=!val;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(13,val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-29T18:17:53.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17306" PostTypeId="2" ParentId="17290" CreationDate="2015-10-29T18:20:58.503" Score="1" Body="&lt;p&gt;Sandwich an arduino protoshield in between and add the sensors to this board, or add some wires, so the sensor can be places &quot;outside&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-10-29T18:20:58.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17307" PostTypeId="2" ParentId="17304" CreationDate="2015-10-29T18:29:37.043" Score="1" Body="&lt;p&gt;You could check out the codes for this reverse geocaching project at &lt;a href=&quot;https://learn.adafruit.com/reverse-geocache-engagement-box/software&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/reverse-geocache-engagement-box/software&lt;/a&gt; or the dog collar project at &lt;a href=&quot;https://learn.adafruit.com/gps-dog-collar&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/gps-dog-collar&lt;/a&gt; to get some help. For my GPS project I just wanted to display the distance and speed, so all I had to do was save the current location, subtract it from the previous location and add it to distanceTraveled. It'd be helpful if you could share your code here. &lt;/p&gt;&#xA;" OwnerUserId="14234" LastActivityDate="2015-10-29T18:29:37.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17308" PostTypeId="2" ParentId="17303" CreationDate="2015-10-29T19:03:43.987" Score="1" Body="&lt;p&gt;Think of the receiver as a camera with a telephoto lens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the lens zoomed out you can see a large area.  You get visual information from all over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the lens zoomed in you can only see a very small area. The visual information you receive is only from a very small &lt;em&gt;field of vision&lt;/em&gt; and things outside that field never get to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's exactly the same with radio waves except that the shape of the antenna affects the zoom instead of lenses.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-29T19:03:43.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17309" PostTypeId="1" AcceptedAnswerId="17310" CreationDate="2015-10-29T19:18:48.343" Score="0" ViewCount="145" Body="&lt;p&gt;I have a question regarding how the read function works in Software Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;recv reads the bits a receiver picks up into a serial buffer. than read returns a uint8_t. However, when i set read() equal to a variable and print it, it doesn't necessarily always print out a byte. &#xA;For instance:&#xA;int x = rx.read(); //if the read is supposed to read 60, x prints 111100&#xA;int x = rx.read(); //if the read is supposed to read 226, x prints 11100010&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How come the first statement doesn't print 00111100? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, i realize this might be a very dumb question. I looked into the software serial library, and couldn't identify what I'm missing. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastActivityDate="2015-10-29T19:40:10.037" Title="Read function in Software Serial" Tags="|arduino-uno|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17310" PostTypeId="2" ParentId="17309" CreationDate="2015-10-29T19:40:10.037" Score="1" Body="&lt;p&gt;For the very same reason that you don't normally write 00000069 instead of just 69. The leading 0's are completely meaningless and can be omitted or included without any change to the value.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-29T19:40:10.037" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17311" PostTypeId="2" ParentId="17297" CreationDate="2015-10-29T20:07:02.377" Score="1" Body="&lt;p&gt;If you don't mind using make, I'd recommend copying the Makefiles from &lt;a href=&quot;http://ChibiOS&quot; rel=&quot;nofollow&quot;&gt;ChibiOS&lt;/a&gt;. For me it works quite well and it's much more aligned to my daily experience with Linux.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-29T20:07:02.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17312" PostTypeId="2" ParentId="17299" CreationDate="2015-10-29T20:35:53.240" Score="0" Body="&lt;p&gt;I figured it out. I had the temperature sensors wired wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Old (Bad):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ys4yN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ys4yN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sOWWZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sOWWZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14431" LastActivityDate="2015-10-29T20:35:53.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17313" PostTypeId="2" ParentId="17299" CreationDate="2015-10-29T20:36:54.050" Score="1" Body="&lt;p&gt;The image on the linked tutorial has the middle pin of the TMP036 going to the analog input, whereas you have it going to 5V, so that is not going to help one bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, it is wired wrongly.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-10-29T20:36:54.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17314" PostTypeId="2" ParentId="10458" CreationDate="2015-10-29T21:10:10.197" Score="0" Body="&lt;p&gt;I assume when you state &quot;CDMA&quot; it is Carrier Detect Multiple Access.  There are several that are not very expensive and can go thousands of feet such as a RS485 network.  The premium would be CAN, it will give your CSMA-NDA (Carrier Detect, Multiple Access, Non Destructive Arbitration). A non-destructive bit-wise arbitration is used to control access to the bus. There are many more but these seem to be very popular.  Of course you can always go to an Ethernet Network, that is not that expensive and is typically a star network where the others are point to point. This is not a  complete answer but it should get you going down the correct path.  CAN will not run with one node, it needs a remote node to acknowledge the transmission. Try this link for a better description: &quot;&lt;a href=&quot;http://bitstream24.com/controller-area-network-can-bus-arbitration-principle/&quot; rel=&quot;nofollow&quot;&gt;http://bitstream24.com/controller-area-network-can-bus-arbitration-principle/&lt;/a&gt;' Check the people that support this forearm, they sell the modules with instructions and of course eBay.&#xA;Good Luck,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="14095" LastEditDate="2015-10-29T21:15:47.960" LastActivityDate="2015-10-29T21:15:47.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17315" PostTypeId="2" ParentId="15834" CreationDate="2015-10-29T21:21:25.303" Score="0" Body="&lt;p&gt;If you want to use Nick Gammon's protocol you might find this useful: &lt;a href=&quot;https://github.com/Sthing/Nick-Gammon-RS485&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Sthing/Nick-Gammon-RS485&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is my implementation of the protocol in Python (for use on a RaspberryPi).&#xA;I have only tested python-to-python yet, testing against Nick Gammon's code is next on my to do list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/Thing&lt;/p&gt;&#xA;" OwnerUserId="14435" LastActivityDate="2015-10-29T21:21:25.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17317" PostTypeId="2" ParentId="4140" CreationDate="2015-10-29T22:02:29.057" Score="1" Body="&lt;p&gt;Note: if you are changing something have the power off.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to try is unplug the IC. If it powers up after the IC is removed it is Possibly the IC is bad; However measure the Voltages on the proto board where the IC is inserted, be sure Pin 16 is +5V when referenced to pin 8.  Check the data sheet for the correct pinout, I do not know what IC you are using. If the voltage is correct it is pointing more to a bad IC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final check for the IC is to insert the IC and remove the ground lead to the LEDs.  If the system comes up then the problem is not enough power to drive the LEDs as is. If it does not come up replace the IC.  Even a momentary reverse voltage or a ESD (Electro Static Discharge) incident will damage the IC, we know is is going to fail, we do not know when.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure your resistors are at least 300 Ohm or higher, with that resistance the LEDs when all on will draw a total of 80mA. If you want to do the calculations try this link: &quot;&lt;a href=&quot;http://www.onlineconversion.com/ohms_law.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.onlineconversion.com/ohms_law.htm&lt;/a&gt;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to check the LEDs, remove the IC and connect +5V one at a time to the wire that goes to the resistor from the IC.&#xA;Good Luck,&#xA;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2015-10-29T22:02:29.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17318" PostTypeId="2" ParentId="17176" CreationDate="2015-10-29T22:05:20.450" Score="0" Body="&lt;p&gt;My two arduino nanos did flash and run the program correctly. I suspect a problem with the uno's serial communication but unwilling to troubleshoot further (i only have one uno). I decided to switch to the nano for further prototyping.&lt;/p&gt;&#xA;" OwnerUserId="14317" LastActivityDate="2015-10-29T22:05:20.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17319" PostTypeId="1" CreationDate="2015-10-29T23:01:09.880" Score="1" ViewCount="13812" Body="&lt;p&gt;I have an accelerometer connected to my Arduino Due to spit out data on my serial monitor as described in &lt;a href=&quot;https://arduino.stackexchange.com/questions/17206/pushing-accelerometer-data-in-packets-from-an-arduino-due-to-the-pc-and-unto-pro&quot;&gt;my earlier post&lt;/a&gt;. I'm trying to find a sketch I could use to plot a continuous real-time graph on either Processing, MatLab or using Python MatPlot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accelerometer data is stored in arrays of &lt;code&gt;xArray[k]&lt;/code&gt; for the x-coordinate values, &lt;code&gt;yArray[k]&lt;/code&gt; for the y-coordinate values and &lt;code&gt;zArray[k]&lt;/code&gt; for the z-coordinate values. How can I plot a real-time graph of these values? Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2018-08-08T22:00:59.340" Title="Plotting a real time graph of sensor data from Arduino on Processing, MatLab or Python" Tags="|arduino-due|accelerometer|python|matlab|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17320" PostTypeId="1" CreationDate="2015-10-29T23:23:54.150" Score="2" ViewCount="1325" Body="&lt;p&gt;I am trying to connect an Arduino Due to Simulink to run it in external mode. I am unable to successfully deploy to hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm testing it with a blinking light model: A pulse generator connected to a digital output pin. This is the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ### Starting build procedure for model: due_blink&#xA;   Code Generation  1&#xA;  Elapsed: 8 sec&#xA;  ### Generating code into build folder: C:\Users\Dana\Documents\MATLAB\due_blink_ert_rtw&#xA;  ### Invoking Target Language Compiler on due_blink.rtw&#xA;  ### Using System Target File: C:\Program Files\MATLAB\R2015b\rtw\c\ert\ert.tlc&#xA;  ### Loading TLC function libraries&#xA;  ### Initial pass through model to cache user defined code&#xA;  ### Caching model source code&#xA;  ### Writing header file due_blink.h&#xA;  ### Writing header file due_blink_types.h&#xA;  .&#xA;  ### Writing header file rtwtypes.h&#xA;  ### Writing source file due_blink.c&#xA;  ### Writing header file due_blink_private.h&#xA;  ### Writing source file due_blink_data.c&#xA;  ### Writing header file rtmodel.h&#xA;  .&#xA;  ### Writing source file ert_main.c&#xA;  ### TLC code generation complete.&#xA;  ### Evaluating PostCodeGenCommand specified in the model&#xA;  ### Using toolchain: Arduino ARM v1.6.1 | gmake (64-bit Windows)&#xA;  ### 'C:\Users\Dana\Documents\MATLAB\due_blink_ert_rtw\due_blink.mk' is up to date&#xA;  ### Building 'due_blink': C:\PROGRA~1\MATLAB\R2015b\bin\win64\gmake -f due_blink.mk all&#xA;  C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-gcc -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=161  -MD -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER='&quot;Unknown&quot;' -DUSB_PRODUCT='&quot;Arduino Due&quot;' -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_DUE_ -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMW_TIMERID=9 -DMW_TIMERCOUNT=131250 -DMW_SAM_CLOCKID=TC_CMR_TCCLKS_TIMER_CLOCK3 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_BAUDRATE_SERIAL2_=9600 -D_RTT_BAUDRATE_SERIAL3_=9600 -D_RTT_ANALOG_REF_=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/include -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/blocks/sfcn/include -IC:/Users/Dana/Documents/MATLAB/due_blink_ert_rtw -IC:/Users/Dana/Documents/MATLAB -IC:/PROGRA~1/MATLAB/R2015b/extern/include -IC:/PROGRA~1/MATLAB/R2015b/simulink/include -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/ert -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/libsam -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/CMSIS/Include -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/Device/ATMEL -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/variants/arduino_due_x -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../include -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../scheduler/include -o &quot;due_blink.o&quot; &quot;due_blink.c&quot; &#xA;  C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-gcc -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=161  -MD -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER='&quot;Unknown&quot;' -DUSB_PRODUCT='&quot;Arduino Due&quot;' -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_DUE_ -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMW_TIMERID=9 -DMW_TIMERCOUNT=131250 -DMW_SAM_CLOCKID=TC_CMR_TCCLKS_TIMER_CLOCK3 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_BAUDRATE_SERIAL2_=9600 -D_RTT_BAUDRATE_SERIAL3_=9600 -D_RTT_ANALOG_REF_=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/include -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/blocks/sfcn/include -IC:/Users/Dana/Documents/MATLAB/due_blink_ert_rtw -IC:/Users/Dana/Documents/MATLAB -IC:/PROGRA~1/MATLAB/R2015b/extern/include -IC:/PROGRA~1/MATLAB/R2015b/simulink/include -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/ert -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/libsam -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/CMSIS/Include -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/Device/ATMEL -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/variants/arduino_due_x -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../include -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../scheduler/include -o &quot;due_blink_data.o&quot; &quot;due_blink_data.c&quot;&#xA;  C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=161  -MD -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER='&quot;Unknown&quot;' -DUSB_PRODUCT='&quot;Arduino Due&quot;' -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_DUE_ -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMW_TIMERID=9 -DMW_TIMERCOUNT=131250 -DMW_SAM_CLOCKID=TC_CMR_TCCLKS_TIMER_CLOCK3 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_BAUDRATE_SERIAL2_=9600 -D_RTT_BAUDRATE_SERIAL3_=9600 -D_RTT_ANALOG_REF_=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DRT -DSTACK_SIZE=64 -DMODEL=due_blink -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/include -IC:/MATLAB/SupportPackages/R2015b/arduinobase/toolbox/target/supportpackages/arduinobase/blocks/sfcn/include -IC:/Users/Dana/Documents/MATLAB/due_blink_ert_rtw -IC:/Users/Dana/Documents/MATLAB -IC:/PROGRA~1/MATLAB/R2015b/extern/include -IC:/PROGRA~1/MATLAB/R2015b/simulink/include -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015b/rtw/c/ert -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/libsam -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/CMSIS/Include -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/system/CMSIS/Device/ATMEL -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino -IC:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/variants/arduino_due_x -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../include -IC:/MATLAB/SupportPackages/R2015b/arduino/toolbox/target/supportpackages/arduinotarget/registry/../scheduler/include -o &quot;USBCore.o&quot; &quot;C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp&quot;&#xA;  &amp;lt;command-line&amp;gt;:0:13: error: initializer fails to determine size of 'STRING_PRODUCT' &#xA;  C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp:69:34: note: in expansion of macro 'USB_PRODUCT' &#xA;   const uint8_t STRING_PRODUCT[] = USB_PRODUCT; &#xA;                                    ^ &#xA;  &amp;lt;command-line&amp;gt;:0:13: error: array must be initialized with a brace-enclosed initializer &#xA;  C:/MATLAB/SupportPackages/R2015b/arduino-1.6.1/hardware/arduino/sam/cores/arduino/USB/USBCore.cpp:69:34: note: in expansion of macro 'USB_PRODUCT' &#xA;   const uint8_t STRING_PRODUCT[] = USB_PRODUCT; &#xA;                                    ^ &#xA;  gmake: *** [USBCore.o] Error 1&#xA;  ### Build procedure for model: 'due_blink' aborted due to an error.&#xA;  Error(s) encountered while building &quot;due_blink&quot;:&#xA;  ### Failed to generate all binary outputs.&#xA;  Component: Simulink | Category: Model error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have the Arduino Due board selected in the settings, with the correct COM port. When running the same model with an Arduino Uno, ld.exe crashes with exit status 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can connect to the board in the Matlab command window and manually change the pins to HIGH or LOW, so it must be a problem with Simulink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="14443" LastEditorUserId="14443" LastEditDate="2015-10-30T01:07:15.687" LastActivityDate="2018-12-17T11:22:13.030" Title="Errors when deploying Simulink model to Arduino Due" Tags="|arduino-due|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17321" PostTypeId="2" ParentId="6617" CreationDate="2015-10-30T00:03:32.477" Score="1" Body="&lt;p&gt;Put a Maxim DS18S20 on your board, each has a unique serial number and are very inexpensive.  There are a lot of software examples on the internet using this device.  You could dead-bug it to the nano.  to operate it needs a 4.7K resister connected to +5 and a ground connection. You can connect both the 5V and Ground connections of the device to ground.  It would be easy to dead bug this to the nano then by simple communication via one pin you can get the serial number. There are several packages available.  With care you could use an input pin, read the serial and save it for future use.  When it Inits it will do this again. Just be sure the input is not driven low during the init process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good Luck,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gil&lt;/p&gt;&#xA;" OwnerUserId="14095" LastEditorUserId="14095" LastEditDate="2015-10-30T00:09:53.393" LastActivityDate="2015-10-30T00:09:53.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17322" PostTypeId="1" CreationDate="2015-10-30T00:19:23.680" Score="1" ViewCount="3609" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PIyaW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PIyaW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;Using LabVIEW I am sending string of data through Xbee like,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;u123&lt;/li&gt;&#xA;&lt;li&gt;r64&lt;/li&gt;&#xA;&lt;li&gt;r89&lt;/li&gt;&#xA;&lt;li&gt;u34&lt;/li&gt;&#xA;&lt;li&gt;r179&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And my arduino is receiving this data.&#xA;I want my arduino to read this data as a string&#xA;and I want to extract numbers from these strings and feed it into two different servos. &#xA;For example from u123 I want to extract 123 and feed it to servo1 and from r64 I want to extract 64 and feed it to servo2 and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino IDE Serial Monitor is showing nothing but Arduino's Xbee is receiving and sending data. Don't know why :(&lt;/p&gt;&#xA;" OwnerUserId="14222" LastEditorUserId="14222" LastEditDate="2015-10-30T00:32:15.087" LastActivityDate="2015-10-30T00:52:39.060" Title="How to extract number from a string?" Tags="|serial|xbee|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17323" PostTypeId="2" ParentId="17322" CreationDate="2015-10-30T00:52:39.060" Score="1" Body="&lt;p&gt;First collect all of the characters up to the new-line (`\n' or line-feed) into an array of characters, and put a zero byte after the last one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since It looks like all of the strings you need to parse consist of one a single letter followed by the value you want, &lt;code&gt;value = atoi(inputArray[1];&lt;/code&gt; will return the value as a 16-bit int. If it could be larger than 32767 but less than 65536 (probably not if you're driving a servo with it), then cast the value to unsigned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there might be an unknown number of characters (non-digits) preceeding the value, the C function &lt;code&gt;size_t strcspn(const char *string, const char *cset)&lt;/code&gt; will return the length of the leading sub-string of &lt;code&gt;string&lt;/code&gt; that does not contain characters in &lt;code&gt;cset&lt;/code&gt;. So &lt;code&gt;value = atoi(inputArray[strcspn(inputArray, &quot;0123456789&quot;)]);&lt;/code&gt; will do the same thing, but calculating the array index of the first digit in the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(For completeness, note there is a companion function, &lt;code&gt;size_t strspn(const char *str, const char *cset);&lt;/code&gt;, that returns the leading sub-string of 'string' consisting &lt;em&gt;only&lt;/em&gt; of characters in &lt;code&gt;cset&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-10-30T00:52:39.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17324" PostTypeId="1" CreationDate="2015-10-30T02:37:19.930" Score="1" ViewCount="859" Body="&lt;p&gt;I've been working on this for 4+ hours, and have gotten nowhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an array of weather conditions, and a number is sent over serial port to indicate which member of the array to print to the LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing the problem is in how I'm defining the array. These are my current 2 guesses for how to define it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String weatherConditions[49] = { &quot;tornado&quot;,&quot;hurricane&quot;,&quot;tropical storm&quot;,&quot;sev tstorms&quot;,&quot;tstorms&quot;,&quot;mix rain-snow&quot;,&quot;mix rain-sleet&quot;,&quot;mix snow-sleet&quot;,&quot;freez drizzle&quot;,&quot;drizzle&quot;,&quot;freez rain&quot;,&quot;showers&quot;,&quot;showers&quot;,&quot;snow flur&quot;,&quot;lt snow show&quot;,&quot;blowing snow&quot;,&quot;snow&quot;,&quot;hail&quot;,&quot;sleet&quot;,&quot;dust&quot;,&quot;foggy&quot;,&quot;haze&quot;,&quot;smoky&quot;,&quot;blustery&quot;,&quot;windy&quot;,&quot;cold&quot;,&quot;cloudy&quot;,&quot;mostly cloud&quot;,&quot;mostly cloud&quot;,&quot;part cloud&quot;,&quot;part cloud&quot;,&quot;clear&quot;,&quot;sunny&quot;,&quot;fair&quot;,&quot;fair&quot;,&quot;mix rain-hail&quot;,&quot;hot&quot;,&quot;isol tstorms&quot;,&quot;scat tstorms&quot;,&quot;scat tstorms&quot;,&quot;scat showers&quot;,&quot;heavy snow&quot;,&quot;scat snowshow&quot;,&quot;heavy snow&quot;,&quot;part cloudy&quot;,&quot;tshowers&quot;,&quot;snow showers&quot;,&quot;isol tshowers&quot;,&quot;not available&quot; };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char weatherConditions[49][16] = { &quot;tornado&quot;,&quot;hurricane&quot;,&quot;tropical storm&quot;,&quot;sev tstorms&quot;,&quot;tstorms&quot;,&quot;mix rain-snow&quot;,&quot;mix rain-sleet&quot;,&quot;mix snow-sleet&quot;,&quot;freez drizzle&quot;,&quot;drizzle&quot;,&quot;freez rain&quot;,&quot;showers&quot;,&quot;showers&quot;,&quot;snow flur&quot;,&quot;lt snow show&quot;,&quot;blowing snow&quot;,&quot;snow&quot;,&quot;hail&quot;,&quot;sleet&quot;,&quot;dust&quot;,&quot;foggy&quot;,&quot;haze&quot;,&quot;smoky&quot;,&quot;blustery&quot;,&quot;windy&quot;,&quot;cold&quot;,&quot;cloudy&quot;,&quot;mostly cloud&quot;,&quot;mostly cloud&quot;,&quot;part cloud&quot;,&quot;part cloud&quot;,&quot;clear&quot;,&quot;sunny&quot;,&quot;fair&quot;,&quot;fair&quot;,&quot;mix rain-hail&quot;,&quot;hot&quot;,&quot;isol tstorms&quot;,&quot;scat tstorms&quot;,&quot;scat tstorms&quot;,&quot;scat showers&quot;,&quot;heavy snow&quot;,&quot;scat snowshow&quot;,&quot;heavy snow&quot;,&quot;part cloudy&quot;,&quot;tshowers&quot;,&quot;snow showers&quot;,&quot;isol tshowers&quot;,&quot;not available&quot; };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried many other ways of defining the array (including &quot;char* weatherConditions&quot;), but I'm sure most of them were just ignorant guesses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later in the code I have this to display a member of the array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.clear();&#xA;lcd.setCursor(0, 0);&#xA;lcd.print(weatherTodayHigh);lcd.print(&quot;/&quot;);lcd.print(weatherTodayLow);lcd.print(&quot; &quot;);lcd.print(weatherConditions[weatherCurrentConditionsCode]);&#xA;lcd.setCursor(0, 1);&#xA;lcd.print(weatherTomorrowHigh);lcd.print(&quot;/&quot;);lcd.print(weatherTomorrowLow);lcd.print(&quot; &quot;);lcd.print(weatherConditions[weatherTomorrowConditionsCode);&#xA;break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything I try ends up causing nothing to be printed on the 1602 LCD display (I have 15 other scrollable &quot;screens&quot; that are displaying just fine on the LCD). The earlier text on this screen (the highs and lows for today and tomorrow) is displaying fine, but after that, where the weather condition text is supposed to be shown, there is nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to easily display the same weather condition text on the serial monitor (for that I was using &quot;String weatherConditions[49] = {...&quot; and then &quot;Serial.println(weatherConditions[currentValue]);&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get members of a text array to be printed on the LCD?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="13840" LastEditDate="2015-10-30T10:56:35.727" LastActivityDate="2015-10-30T12:56:45.163" Title="Why can't I print this text to LCD?" Tags="|c++|lcd|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17325" PostTypeId="1" CreationDate="2015-10-30T03:15:30.320" Score="0" ViewCount="44" Body="&lt;p&gt;I have a Huzzah ESP826 Wifi breakout chip which requires 3.3V power voltage and peaks at 500mA of current, and an LED strip which requires 12V and 1A.  How can I power both with one dc jack (I have a 12V 5A power supply) on one breadboard?&lt;/p&gt;&#xA;" OwnerUserId="14447" LastActivityDate="2015-10-30T08:17:24.920" Title="How much voltage/current do I need for multiple chips?" Tags="|voltage-level|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17326" PostTypeId="1" AcceptedAnswerId="20147" CreationDate="2015-10-30T03:23:34.807" Score="1" ViewCount="2725" Body="&lt;p&gt;I want to learn and use Hamming Code. Would it be wise to &#xA;alter the Software serial library to do this or just change the data being&#xA;transmitted in the actual Arduino sketch? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, for means of better synchronization, what would be the best method with regards to &lt;a href=&quot;http://rayshobby.net/cart/image/cache/data/acc/rf_pair-500x500.JPG&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; tx/rx modules working with the Arduino using Software Serial. Am I constrained to using the built in synchronization from the library or may I also implement other forms of synchronization, like manchester and NRZ coding? If so, any guidance here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For implementing Hamming code, what if the interference occurs on the parity bit? Is there a way around this problem? &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-10-30T20:43:18.497" LastActivityDate="2018-04-27T14:43:19.660" Title="Synchronization and Implementing hamming code on Software Serial" Tags="|arduino-uno|communication|softwareserial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17327" PostTypeId="2" ParentId="17325" CreationDate="2015-10-30T07:04:23.477" Score="2" Body="&lt;p&gt;You need a voltage regulator for the esp. Preferably a dc-dc step down, which will neither waste power nor heat up. Other, passive solutions are possible but not desirable. The regulator can be found on ebay amazon etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more thing about the LEDs: depending on the model you have, they might or might not work with 3.3V input (I'm assuming you want to drive the LEDs from the esp).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case they take only 12V input, you will need some interface solution, like &lt;a href=&quot;http://tobiscorner.floery.net/powerrgb/&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;, for example. &lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-30T08:17:24.920" LastActivityDate="2015-10-30T08:17:24.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17328" PostTypeId="2" ParentId="17319" CreationDate="2015-10-30T07:30:43.193" Score="1" Body="&lt;p&gt;I hope this is helpful to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you need to read about serial communication between matlab and arduino. You need to establish communication between those two first. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then take note of the format of the data coming out of your Accelerometer. In my case, I'm working with IMU and my data format is as an example: #YPR = 2.34, 13.23, -2.20&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, from Matlab, you need to write a script to be able to read this string and identify any floating-point value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I did in Matlab. YPR = Yaw, Pitch, Roll&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data = fscanf(s);              %Read Data from Serial&#xA;[Y(count),P(count),R(count)] = strread(data, '#YPR = %f,%f,%f');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you have to set up the plot and force matlab to update the plot in real time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;%set() is used to set graphic object properties&#xA;       set(plotGraph1,'XData',time,'YData',Y,'color','r');  &#xA;       set(plotGraph2,'XData',time,'YData',P,'color','g');&#xA;       set(plotGraph3,'XData',time,'YData',R,'color','b');&#xA;       drawnow;           %force matlab to updata plot instantaneously&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The link below is a good place for you to get going. But you need to make some modifications to it though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://billwaa.wordpress.com/2013/07/10/matlab-real-time-serial-data-logger/&quot; rel=&quot;nofollow&quot;&gt;https://billwaa.wordpress.com/2013/07/10/matlab-real-time-serial-data-logger/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13456" LastEditorUserId="13456" LastEditDate="2015-10-30T07:45:21.720" LastActivityDate="2015-10-30T07:45:21.720" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17329" PostTypeId="1" AcceptedAnswerId="17336" CreationDate="2015-10-30T08:39:36.443" Score="0" ViewCount="1482" Body="&lt;p&gt;The goal is to read the MAC address from a &lt;a href=&quot;http://pdfserv.maximintegrated.com/en/ds/DS2502-E48.pdf&quot; rel=&quot;nofollow&quot;&gt;DS2502-E48 &lt;/a&gt;chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I accomplished this goal too with the following code, but I can't get behind at how this works.&#xA;I had a similar program with a PIC chip as reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked several references about OneWire and the DS2502 but not the info I needed to hop to the right memory addresses. &#xA;Where'd I normally attain the information so that I know I have to write: &lt;strong&gt;cc ,f0 , 0, 10&lt;/strong&gt; , read a &lt;em&gt;random&lt;/em&gt; byte, and then I'm at the right position for MAC.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;OneWire ds(2);&#xA;void setup()   &#xA;{         &#xA;  Serial.begin(9600);&#xA;&#xA;&#xA;  byte i;&#xA;  byte dataLength;&#xA;  byte present = 0;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    Serial.print(&quot;No more addresses.\n&quot;);&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;&#xA;  delay(1000);     // maybe 750ms is enough, maybe not&#xA;&#xA;  present = ds.reset();  &#xA;  if (present != 1 )&#xA;  {&#xA;    Serial.println(&quot;No device present, exiting...&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;    ds.write(0xCC);//SKIP_ROM&#xA;    ds.write(0xF0);//READ_MEMORY&#xA;    ds.write(0);  // ?&#xA;    ds.write(10); // ?&#xA;    ds.read();    // ?&#xA;    dataLength = ds.read();&#xA;&#xA;    for ( i = 0; i &amp;lt; dataLength; i++) {           &#xA;    data[i] = ds.read();&#xA;    if ( i&amp;gt;3){&#xA;      Serial.print(data[i], HEX);&#xA;      Serial.print(&quot; &quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop()                     &#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14448" LastActivityDate="2015-10-30T10:43:15.263" Title="Please explain this OneWire communication with Arduino Uno and DS2502-E48" Tags="|arduino-uno|1-wire|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17330" PostTypeId="2" ParentId="17329" CreationDate="2015-10-30T09:09:45.987" Score="0" Body="&lt;p&gt;I found a nice writeup on this on a &lt;a href=&quot;https://hclxing.wordpress.com/2014/02/09/hacking-a-dell-power-adapter-part-iii/&quot; rel=&quot;nofollow&quot;&gt;blog&lt;/a&gt;.  To quote his experimental findings:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Comparing to the OneWire spec, we can tell it’s writing 0xCC, which&#xA;  should be SKIP_ROM. Following that is 0xF0 (ReadMem), and two bytes&#xA;  starting address: 0x08, 0x00.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Based on this, the zero and 10 that you are writing are apparently an address value.&lt;/p&gt;&#xA;" OwnerUserId="14231" LastActivityDate="2015-10-30T09:09:45.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17331" PostTypeId="1" CreationDate="2015-10-30T09:11:52.597" Score="1" ViewCount="345" Body="&lt;p&gt;I am developing a system where I want to control the direction of the DC motor (12V) from Arduino Mega/Uno. For that, I am using L298N H-bridge chip without the board as shown below. &lt;a href=&quot;https://i.stack.imgur.com/peh1L.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/peh1L.jpg&quot; alt=&quot;L298N&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, do I need to add extra hardware or is it enough on its own?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14450" LastActivityDate="2015-10-30T10:10:12.897" Title="Using L298N to control DC Motor" Tags="|arduino-uno|arduino-mega|h-bridge|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17332" PostTypeId="1" CreationDate="2015-10-30T09:13:38.753" Score="0" ViewCount="472" Body="&lt;p&gt;I have defined a c++ class (RpmDriver) and want to use attachInterrupt in the constructor to link an Arduino pin to its ISR (RpmInt) in the class. When I try this, I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;error: cannot convert 'RpmDriver::RPMInt' from type 'void (RpmDriver::)()' to type 'void (*)()' &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;RpmDriver.h&quot;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;int currentRpm;&#xA;long lastMillis;&#xA;int pin;&#xA;&#xA;RpmDriver::RpmDriver(int Pins[])&#xA;{&#xA;    pin=Pins[0];&#xA;    currentRpm=0;&#xA;    pinMode(pin,INPUT);&#xA;    lastMillis = millis();&#xA;    attachInterrupt(digitalPinToInterrupt(pin),RPMInt, RISING);&#xA;}&#xA;RpmDriver::~RpmDriver(void)&#xA;{}&#xA;&#xA;bool RpmDriver::GetData(char* dest,char* format)&#xA;{&#xA;    sprintf(dest,format,currentRpm);&#xA;}&#xA;&#xA;void RpmDriver::RPMInt()&#xA;{&#xA;    double RPMConstant=40000;&#xA;    unsigned long newMillis=millis();&#xA;    unsigned long t = newMillis-lastMillis;&#xA;    t=100;//temp&#xA;    currentRpm=(t==0)?0:(int)RPMConstant/t;&#xA;    lastMillis=newMillis;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the header file is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#pragma once&#xA;class RpmDriver&#xA;{&#xA;public:&#xA;    RpmDriver(int pins[]);&#xA;    ~RpmDriver(void);&#xA;    bool GetData(char*,char*);&#xA;private:&#xA;    void RPMInt(void);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="14449" LastActivityDate="2015-10-30T20:56:32.073" Title="C++ Namespace/scope problem when trying to attach arduino interrupt" Tags="|c++|interrupt|class|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17333" PostTypeId="2" ParentId="17331" CreationDate="2015-10-30T10:10:12.897" Score="1" Body="&lt;p&gt;In theory, this particular device should work on its own.  However you should search for and read the datasheet for it. (I'll leave you to do that yourself, just to make sure you really do read it.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should consider a heatsink too by the way, and provision for things like a fuse on the power, and whether you will be using a separate 5V for the logic (again you need the datasheet for that).&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2015-10-30T10:10:12.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17334" PostTypeId="2" ParentId="10428" CreationDate="2015-10-30T10:21:27.583" Score="1" Body="&lt;p&gt;Unfortunately you can't just simply upload the Arduino bootloader and expect it to work. The ATmega16 is not the same as the ATmega328. One quick look at the datasheet will already explain why this is not working. The UDR(USART data register) is at 0xC6 on the 328, while it's at 0x2B at the Atmega328. So the ATmega16 will look at the location where the 328 stores the received data and will not find it. This could explain the hang, but I expect that other things like UART setup will have gone wrong before you get to the receiving of data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want serial communication with the ATmega16, try programming it directly in C with the AVR libraries and without the Arduino extensions. That will make it harder to figure out.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-10-30T10:21:27.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17335" PostTypeId="2" ParentId="17332" CreationDate="2015-10-30T10:24:34.040" Score="2" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply because a class member is not the right format of function for attachInterrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can only use normal functions with attachInterrupt, so the normal method is to have a normal function outside your class which then calls the member function within your class.  How you arrange it so that it knows where your objects are is up to you.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you have only one object then assign it to a global pointer in your library using the constructor&lt;/li&gt;&#xA;&lt;li&gt;If you have lots of instances then create a linked list within your class in a static context and add each object to it in the constructor, then iterate through that list when the interrupt fires.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-30T10:24:34.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17336" PostTypeId="2" ParentId="17329" CreationDate="2015-10-30T10:43:15.263" Score="0" Body="&lt;p&gt;From the DS2502 datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Skip ROM [CCh]&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This command can save time in a single-drop bus system by allowing the bus master to access the&#xA;  memory functions without providing the 64-bit ROM code. If more than one slave is present on the bus&#xA;  and a read command is issued following the Skip ROM command, data collision will occur on the bus as&#xA;  multiple slaves transmit simultaneously (open drain pulldowns will produce a wired-AND result).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;READ MEMORY [F0h]&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Read Memory command is used to read data from the 1024-bit EPROM data field. The bus master&#xA;  follows the command byte with a 2-byte address (TA1=(T7:T0), TA2=(T15:T8)) that indicates a starting&#xA;  byte location within the data field. An 8-bit CRC of the command byte and address bytes is computed by&#xA;  the DS2502 and read back by the bus master to confirm that the correct command word and starting&#xA;  address were received. If the CRC read by the bus master is incorrect, a reset pulse must be issued and the&#xA;  entire sequence must be repeated. If the CRC received by the bus master is correct, the bus master issues&#xA;  read time slots and receives data from the DS2502 starting at the initial address and continuing until the&#xA;  end of the 1024-bit data field is reached or until a reset pulse is issued. If reading occurs through the end&#xA;  of memory space, the bus master may issue eight additional read time slots and the DS2502 will respond&#xA;  with a 8-bit CRC of all data bytes read from the initial starting byte through the last byte of memory.&#xA;  After the CRC is received by the bus master, any subsequent read time slots will appear as logical 1s until&#xA;  a reset pulse is issued. Any reads ended by a reset pulse prior to reaching the end of memory will not have&#xA;  the 8-bit CRC available.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you are telling it that you want to read the memory from whatever device is on the bus, not any one specific one (since you are not needing to provide the ROM ID to identify the exat item on the bus), starting from address ((0 &amp;lt;&amp;lt; 8) |10) = 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the DS2502-E48 datasheet you can see the layout of the memory:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The data record starts with a length byte (0Ah) and the 4-byte UniqueWare Project ID 00001129h. The&#xA;  next 6 bytes contain the 48-bit node address which consists of an incrementing 24-bit extension identifier&#xA;  and the IEEE-assigned 24-bit company ID value 006035h. An inverted 16-bit CRC ends the data record.&#xA;  The remaining bytes of the 32-byte memory page remain unprogrammed. Neither the 24-bit extension&#xA;  identifier nor the 24-bit company ID are related to the 64-bit ROM registration number. The ROM&#xA;  registration number is used to provide a unique address to access the DS2502-E48 when multidropped on&#xA;  a 1-Wire bus.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So translating that into something more pictorial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Length byte&#xA;0x00: 0x0A&#xA;&#xA;// UniqueWare PID&#xA;0x01: 0x00&#xA;0x02: 0x00&#xA;0x03: 0x11&#xA;0x04: 0x29&#xA;&#xA;// Serialization (&quot;extension&quot;) number&#xA;0x05: 0x?? &#xA;0x06: 0x?? &#xA;0x07: 0x??&#xA;&#xA;// Company ID Value&#xA;0x08: 0x??&#xA;0x09: 0x??&#xA;0x0A: 0x??&#xA;&#xA;// 16-bit CRC&#xA;0x0B: 0x??&#xA;0x0C: 0x??&#xA;&#xA;// All the rest is EEPROM data&#xA;0x0D - 0x7F: 0x??&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So by starting at address 10 (0x0A) you are reading the last byte of the company ID, the CRC, and then whatever else is in the memory after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read the entire MAC address (least significant byte first) you should be starting to read at address 5.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-30T10:43:15.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17337" PostTypeId="2" ParentId="17324" CreationDate="2015-10-30T12:56:45.163" Score="1" Body="&lt;p&gt;Ignacio hit the nail on the head. Once I moved the weatherConditions array to EEPROM, the sketch worked perfectly. Also the IDE stopped giving me errors about low RAM.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-10-30T12:56:45.163" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17338" PostTypeId="2" ParentId="17275" CreationDate="2015-10-30T13:13:41.517" Score="0" Body="&lt;p&gt;To ensure that relay doesn't switch between NO-NC when controller is &lt;em&gt;away&lt;/em&gt; relay will need some memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine having a 1 bit memory driving relay. If arduino dies/restart, its own GPIO may change, but relay's memory will remember last state and stay there, till controller instructs otherwise, granted relay circuit and its memory element don't lose power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This also means there will be at least 2 lines required from uC to control this relay now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd prefer to use some kind of serial shift register, e.g. &lt;a href=&quot;http://pdf.datasheetcatalog.com/datasheet2/e/0zfy3x112ch42r82d060wl0jtocy.pdf&quot; rel=&quot;nofollow&quot;&gt;CD4094&lt;/a&gt;, &lt;a href=&quot;http://pdf.datasheetcatalog.com/datasheet2/9/0oqf0076icwadgde9su7g9oihq3y.pdf&quot; rel=&quot;nofollow&quot;&gt;CD4042&lt;/a&gt;, &lt;a href=&quot;http://pdf.datasheetcatalog.com/datasheet2/c/0ho1jgpu09kii6i650li4579diky.pdf&quot; rel=&quot;nofollow&quot;&gt;CD4099&lt;/a&gt; etc because that allows me to control more than one relays from same 2 lines on uC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find some other part more suitable for your application.&lt;/p&gt;&#xA;" OwnerUserId="14297" LastEditorUserId="14297" LastEditDate="2015-10-30T13:28:33.853" LastActivityDate="2015-10-30T13:28:33.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17339" PostTypeId="2" ParentId="17326" CreationDate="2015-10-30T13:44:10.803" Score="1" Body="&lt;p&gt;The SoftwareSerial can only transmit and receive EIA-232 formatted packets.  That is what it is written to do, and that is what it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It cannot transfer any other format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use other encoding techniques you will have to use a different method than SoftwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might involve writing your own bit-banging routines in your sketch or in your own library, or using SoftwareSerial as a basis to adapt into your own library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the SoftwareSerial library is written in such a way that EIA-232 packets are a requirement - the falling edge of the start bit triggers reception of one packet - any other encoding that doesn't have that kind of start bit arrangement would require some completely different method of arranging the reception.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-30T13:44:10.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17340" PostTypeId="2" ParentId="17302" CreationDate="2015-10-30T13:52:49.533" Score="1" Body="&lt;p&gt;As has been mentioned in the comments there's many ways of sensing, each with its own pros and cons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensing the presence of something is actually twofold.  First you need to know if there is something there, and secondly you need to try and identify &lt;em&gt;what&lt;/em&gt; it is that's there and if it fits your criteria.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With passive sensors of the type used by Arduinos it all comes down to a matter of &lt;em&gt;probability&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have force sensors, you know when &lt;em&gt;something&lt;/em&gt; is there, but you can't work out &lt;em&gt;what&lt;/em&gt; is there, only that it weighs a certain amount.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using capacitative sensors you can get an idea about what the &lt;em&gt;something&lt;/em&gt; is made of - how much does it affect the capacitance, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using ultrasound and/or infra-red beams etc you can get an idea of the kind of size of the object that is in the chair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So combining them all together you can work out the likelihood that it is a human if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It weighs enough to be a human&lt;/li&gt;&#xA;&lt;li&gt;It has a suitable dielectric response to be a human&lt;/li&gt;&#xA;&lt;li&gt;It is big enough to be a human&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Of course, there's always the chance that it's just a big dog, or a sack of potatoes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's all a case of improving that probability by adding more sensors of different types, until you are &lt;em&gt;almost&lt;/em&gt; certain that it is a human.  You will never be 100% certain, of course.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-30T13:52:49.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17341" PostTypeId="1" CreationDate="2015-10-30T14:35:01.637" Score="2" ViewCount="168" Body="&lt;p&gt;I am trying send data from an Arduino to an android device with bluetooth.&#xA;I want to send a date y and when it arrives, turn on a led, but when I send the data nothing happened.&#xA;This is my code for Arduino (I use the bluetooth module hc-05)&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;char entrada;&#xA;void setup()&#xA;{ &#xA;pinMode(8,OUTPUT);&#xA;Serial.begin(9600);&#xA;digitalWrite(8,LOW);&#xA;}&#xA;void loop()&#xA;{&#xA;   if(Serial.available()&amp;gt;0)&#xA;{&#xA; entrada=Serial.read();&#xA; if(entrada=='1')&#xA; {&#xA;    digitalWrite(8,LOW);&#xA;    Serial.println(&quot;1&quot;);&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the side of android i have this codec with my handler and thread for inputstream and outputstream&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;public void run()&#xA;    {&#xA;        byte[] espera=new byte [256];&#xA;        int esperaalmacen;&#xA;        while (true) {&#xA;            try {&#xA;                esperaalmacen=entradadatos.read(espera);&#xA;                mhandler.obtainMessage(MENSAJELEYENDO,esperaalmacen,-1,espera).sendToTarget();&#xA;            }catch (IOException e){}&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in my activity main I have:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;       @Override&#xA;    public void handleMessage(Message msg)&#xA;    {&#xA;        super.handleMessage(msg);&#xA;        switch (msg.what)&#xA;        {&#xA;            case CONECTADO:&#xA;                //ManejarDatos msjre = new ManejarDatos((BluetoothSocket)msg.obj);&#xA;                msjre = new ManejarDatos((BluetoothSocket)msg.obj);&#xA;                break;&#xA;            case MENSAJELEYENDO:&#xA;                byte[] readBuf = (byte[])msg.obj;&#xA;                String string = new String(readBuf);&#xA;                Toast.makeText(getApplicationContext(), string, Toast.LENGTH_LONG).show();&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My modulo I have configured as slave.&lt;/p&gt;&#xA;" OwnerUserId="13817" LastEditorDisplayName="user27792" LastEditDate="2019-08-02T17:25:24.310" LastActivityDate="2019-08-02T17:25:24.310" Title="Comunication between Android and Arduino" Tags="|hc-05|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17342" PostTypeId="1" CreationDate="2015-10-22T03:49:44.063" Score="2" ViewCount="420" Body="&lt;p&gt;&lt;strong&gt;Project:&lt;/strong&gt;&#xA;I'm a software guy trying to learn more about hardware so I've decided to do a project that uses a small micro controller which plays short sound clips over a .5w speaker. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The microcontroller I've selected is Adafruits 3v Pro Trinket along with their 2.5w mono amplifier. The microcontroller however does not have much storage that I could put sound clips on. I'm considering buying a micro sd card breakout board but I'm not sure if this would work (or how to even wire it to the microcontroller). I don't necessarily need to be able to remove the storage and I only need ~16mb so does anyone have suggestions on other chips I could get in place of using an SD Card? I've been searching on Adafruit but haven't been able to find anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Rational:&lt;/strong&gt;&#xA;I would love to use a larger micro controller with a build in sd card slot but I need to be able to stick this inside a 1.5&quot; diameter tube, so space is tight and hence the small micro controller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Links to parts:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Microcontroller: &lt;a href=&quot;https://www.adafruit.com/products/2010&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2010&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;Amp: &lt;a href=&quot;https://www.adafruit.com/products/2130&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2130&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Speaker: &lt;a href=&quot;https://www.adafruit.com/products/1890&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1890&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SD Breakout: &lt;a href=&quot;https://www.adafruit.com/products/254&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/254&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="27506" OwnerDisplayName="Joe Jankowiak" LastActivityDate="2015-10-30T16:24:47.853" Title="Adding more storage to microprocessor 3.3v trinket" Tags="|sd-card|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17344" PostTypeId="1" AcceptedAnswerId="21694" CreationDate="2015-10-30T20:20:31.430" Score="1" ViewCount="144" Body="&lt;p&gt;Can anybody tell me how the &lt;a href=&quot;https://docs.particle.io/guide/getting-started/start/core/&quot; rel=&quot;nofollow&quot;&gt;Particle (Photon/Core)&lt;/a&gt; WiFi &lt;em&gt;setup&lt;/em&gt; works?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to mimic this WiFi configuration format for my own device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic steps are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Power device on; put in &quot;listening mode&quot; if not already active;&lt;/li&gt;&#xA;&lt;li&gt;Connect smartphone to the wireless network that you want to connect your device to;&lt;/li&gt;&#xA;&lt;li&gt;Open the Tinker/Spark/whatever-it's-called App on your smartphone; choose &quot;Add New Device&quot;;&lt;/li&gt;&#xA;&lt;li&gt;Enter wireless password;&lt;/li&gt;&#xA;&lt;li&gt;Wait for device to be discovered by the App; device is now connected to WiFi.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How is the information (SSID, password) transferred from the smartphone to the device?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14464" LastEditorUserId="10003" LastEditDate="2015-11-12T20:29:55.923" LastActivityDate="2016-03-11T15:02:28.517" Title="Particle-like wifi configuration" Tags="|wifi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17345" PostTypeId="2" ParentId="17332" CreationDate="2015-10-30T20:28:54.087" Score="1" Body="&lt;p&gt;You should qualify &lt;code&gt;RpmDriver::RPMInt()&lt;/code&gt; as &lt;code&gt;static&lt;/code&gt;.&#xA;Static member functions are very much like plain functions, only using&#xA;their class as a sort of namespace. Obviously, you will not be able to&#xA;access any member data, but this should not be a problem as it seems&#xA;your class is not storing any data anyway.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2015-10-30T20:56:32.073" LastActivityDate="2015-10-30T20:56:32.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17346" PostTypeId="1" CreationDate="2015-10-31T02:54:42.213" Score="1" ViewCount="3711" Body="&lt;p&gt;I have a generic 16x2 LCD display connected to my Arduino.  I can use the standard LCD library to display characters, but are there way to turn on and of individual pixels?&lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2015-10-31T04:04:57.163" Title="Can I access individual pixels on my 16x2 LCD display" Tags="|lcd|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17347" PostTypeId="2" ParentId="17346" CreationDate="2015-10-31T04:04:57.163" Score="2" Body="&lt;p&gt;It's possible to define custom characters for “generic 16x2 LCD displays” [ie, displays based on HD44780 or equivalent controllers], but only up to eight such characters at the same time.  See &lt;a href=&quot;https://www.arduino.cc/en/Reference/LiquidCrystalCreateChar&quot; rel=&quot;nofollow&quot;&gt;LiquidCrystal.CreateChar&lt;/a&gt; for details.  See page 2 and part of page 1 of the &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=19002.0&quot; rel=&quot;nofollow&quot;&gt;Print degree symbol ° on LCD&lt;/a&gt; arduino.cc thread for create-character examples that don't use the library.  Page 1 of that thread also shows a table of all the characters built into typical HD44780 controllers, some of which may perhaps meet your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For pixel-by-pixel LCD control, look at graphics LCDs, eg the &lt;a href=&quot;http://playground.arduino.cc/Code/GLCDks0108&quot; rel=&quot;nofollow&quot;&gt;KS0108&lt;/a&gt; or &lt;a href=&quot;http://playground.arduino.cc/Code/LCD12864&quot; rel=&quot;nofollow&quot;&gt;LCD12864&lt;/a&gt; and similar.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-10-31T04:04:57.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17348" PostTypeId="1" CreationDate="2015-10-31T05:26:55.757" Score="2" ViewCount="115" Body="&lt;p&gt;I'm trying to use the &lt;a href=&quot;http://www.meas-spec.com/product/t_product.aspx?id=8684&quot; rel=&quot;nofollow&quot;&gt;MS5803 pressure sensor&lt;/a&gt; with a Teensy 3.2. Compiling the &lt;a href=&quot;https://www.sparkfun.com/products/12909&quot; rel=&quot;nofollow&quot;&gt;Sparkfun&lt;/a&gt;, or other, libraries, however, results in no output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you provide guidance on how to modify the libraries to work with the Teensy (t3_i2c)?&lt;/p&gt;&#xA;" OwnerUserId="14468" LastEditorUserId="6936" LastEditDate="2015-11-14T05:24:53.937" LastActivityDate="2015-11-14T05:24:53.937" Title="Teensy and MS5803 sensor" Tags="|arduino-uno|sensors|i2c|library|teensy|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17349" PostTypeId="1" AcceptedAnswerId="17410" CreationDate="2015-10-31T05:51:03.183" Score="1" ViewCount="18892" Body="&lt;p&gt;I have two arduinos (An UNO R3 and a Mega 2560), and I need to communicate them via two ESP8266 modules to exchange some values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In one arduino I'll use a SW-420 vibrarion module, and I need to send a value wirelessly to the other board, which it'll have an LCD screen that will display a message when a value is recieved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that with that specific WiFi modules? Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="14467" LastActivityDate="2016-08-18T10:17:19.133" Title="Connecting two arduinos using WiFi" Tags="|arduino-uno|arduino-mega|wifi|communication|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17350" PostTypeId="1" CreationDate="2015-10-31T09:56:11.593" Score="0" ViewCount="5293" Body="&lt;p&gt;I'm using an Arduino Mega with Ubuntu 15.10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sadly I've got an error during compilation, that the Time.h library cannot be found. The verbose compile output shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall&#xA;-fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 &#xA;-DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 &#xA;-D__PROG_TYPES_COMPAT__ &#xA;-I/usr/share/arduino/hardware/arduino/cores/arduino &#xA;-I/usr/share/arduino/hardware/arduino/variants/mega &#xA;-I/usr/share/arduino/libraries/LiquidCrystal &#xA;-I/usr/share/arduino/libraries/SPI &#xA;/tmp/build6998056390288565759.tmp/Home_Guard.cpp -o /tmp/build6998056390288565759.tmp/Home_Guard.cpp.o &#xA;**Home_Guard.ino:2:20: fatal error: Time.h: No such file or directory**&#xA;compilation terminated.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've already tried to use &quot;time.h&quot; instead of &quot;Time.h&quot; but it doesn't help.&lt;/p&gt;&#xA;" OwnerUserId="11839" LastActivityDate="2015-10-31T10:29:36.950" Title="Arduino Mega, Ubuntu, Time.h: No such file or directory" Tags="|time|ubuntu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17351" PostTypeId="1" AcceptedAnswerId="17353" CreationDate="2015-10-31T09:57:36.367" Score="0" ViewCount="811" Body="&lt;p&gt;In my university we need to buy arduino boards and kits to build a moving robotic arm, that moves up and down and clockwise in a specific degree (almost like humans's).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what's the most &lt;strong&gt;suitable&lt;/strong&gt; arduino board to build this arm? &#xA;I suggested to use the basic UNO board, but we may need to use relays (for example) if the power source is 12volts. So there is should be a better one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My regards.&lt;/p&gt;&#xA;" OwnerUserId="14470" LastActivityDate="2015-11-03T04:29:13.033" Title="What is the best arduino board for a robotic arm?" Tags="|arduino-uno|robotics|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17352" PostTypeId="2" ParentId="17350" CreationDate="2015-10-31T10:29:36.950" Score="1" Body="&lt;p&gt;ok. It seems that the Ubuntu arduino package does not contain this library. The file Time.zip has to be downloaded from the authors website: &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_Time.html&quot; rel=&quot;nofollow&quot;&gt;http://www.pjrc.com/teensy/td_libs_Time.html&lt;/a&gt; and added in the Arduino GUI menue bar: Sketch -&gt; Import Library -&gt; Add Library  &lt;/p&gt;&#xA;" OwnerUserId="11839" LastActivityDate="2015-10-31T10:29:36.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17353" PostTypeId="2" ParentId="17351" CreationDate="2015-10-31T10:31:00.650" Score="2" Body="&lt;p&gt;If you are hoping to drive the arm straight from the Arduino, that's not going to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should do is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define the maximum weight and size of the load your arm will carry.&lt;/li&gt;&#xA;&lt;li&gt;Define expected precision and speed of the movements.&lt;/li&gt;&#xA;&lt;li&gt;Count the Degrees of Freedom (DoF) your arm will need (1 DoF = 1 simple joint)&lt;/li&gt;&#xA;&lt;li&gt;Figure out size and materials of each part of the arm&lt;/li&gt;&#xA;&lt;li&gt;Calculate the torque required at each joint (yes, you need some basic physics calculation)&lt;/li&gt;&#xA;&lt;li&gt;Identify the motors you want to drive (DC are inexpensive but not very well suited for this, without lots of additional control logic &amp;amp; HW - stepper motors are better, but they still do require some additional effort - servos are the easier way but they are a bit more expensive)&lt;/li&gt;&#xA;&lt;li&gt;Define the requirements for both the micro controller and the power supply, based on the previous choice.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you can refine your question, based on the few points I sketched, you will get ahead much faster and with less risk later on to have to backtrack and re-design something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might have already answered some of those steps, then I suggest you list here your choices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, if you are referring to some link you found (instructables, etc.) please post it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As reference, hobbyking has an extensive catalog of motors and power supplies. You can find the same items also on ebay, but hobbyking can be used at least as reference for various specs (power, torque, weight, etc.).&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-10-31T11:17:29.130" LastActivityDate="2015-10-31T11:17:29.130" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17355" PostTypeId="1" CreationDate="2015-10-31T11:46:20.760" Score="2" ViewCount="10611" Body="&lt;p&gt;Is there a method to play a Melody with Tone() without using the delay() function?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tone(8, melody[thisNote], noteDuration);&#xA;int pauseBetweenNotes = noteDuration;&#xA;**delay(pauseBetweenNotes);**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12172" LastActivityDate="2022-05-22T17:10:01.480" Title="Playing Melody with Tone() without using delay()" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17356" PostTypeId="1" CreationDate="2015-10-31T12:16:25.863" Score="2" ViewCount="51" Body="&lt;p&gt;my vb.net app produce this result as 2d array :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110000000111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110000000111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110000000000000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110111000111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01111111100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110011100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110011100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110011100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110011100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;01110011100111000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;00000000000000000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i want to send every single column to my arduino over serial port and use the column to turn on this leds : &#xA;* leds connected from pin 2 to pin 13&#xA; &lt;a href=&quot;https://i.stack.imgur.com/9okO8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9okO8.jpg&quot; alt=&quot;arduino uno r3 &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;anyone can help me ? :(&lt;/p&gt;&#xA;" OwnerUserId="14471" LastActivityDate="2015-10-31T12:16:25.863" Title="arduino serial comminucation" Tags="|arduino-uno|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17357" PostTypeId="1" CreationDate="2015-10-31T13:34:58.203" Score="0" ViewCount="1247" Body="&lt;p&gt;I have an Arduino webserver that displays many buttons over a webpage (73 at the moment) that toggle different switches. I shortened up the button-drawing code with this function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void displayButton(String toggleName, byte toggle, byte link1, EthernetClient &amp;amp; client, boolean last) {&#xA;  if (toggle == 0) client.print(&quot;&amp;lt;a href=\&quot;/?&quot;);&#xA;  else client.print(&quot;&amp;lt;a class=\&quot;linkSelected\&quot; href=\&quot;/?&quot;);&#xA;  client.print(link1);&#xA;  client.print(&quot;\&quot;&amp;gt;&quot;);&#xA;  client.print(toggleName);&#xA;  client.print(&quot;&amp;lt;/a&amp;gt;&quot;);&#xA;  if (last) client.print(&quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is a shortened version of my loop function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    boolean done = false;&#xA;    while (client.connected() &amp;amp;&amp;amp; !done)&#xA;    {&#xA;      while (client.available () &amp;gt; 0 &amp;amp;&amp;amp; !done)&#xA;        done = processIncomingByte (client.read ());&#xA;    }  // end of while client connected&#xA;      client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;      client.println(&quot;Content-Type: text/html&quot;);&#xA;      client.println();&#xA;      client.print(&quot;&amp;lt;HTML&amp;gt;&amp;lt;HEAD&amp;gt;&quot;);&#xA;      displayButton(&quot;F8&quot;, f8Toggle, 57, client, 0);&#xA;      displayButton(&quot;F9&quot;, f9Toggle, 58, client, 0);&#xA;      displayButton(&quot;F10&quot;, f10Toggle, 59, client, 1);&#xA;      client.println(&quot;&amp;lt;/center&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;);&#xA;      delay(5); client.stop();&#xA;  } // end of &quot;if client&quot;&#xA;} // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's any way to have the displayButton function use the EthernetClient instance without it having to be passed every time. I'm interested in this in order to clean up my code a little (since I would be able to remove 73 instances of the word &quot;client&quot;), and also as a learning experience.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2022-11-29T07:07:56.003" Title="Any way to pass EthernetClient to function outside of loop automatically?" Tags="|web-server|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17358" PostTypeId="2" ParentId="12133" CreationDate="2015-10-31T13:40:49.410" Score="44" Body="&lt;p&gt;Probably, you have Chinese Uno analog which works on &lt;strong&gt;CH340&lt;/strong&gt; USB-to-serial chip, so you need to install driver for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steps to fix:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install the &lt;a href=&quot;http://www.wch.cn/download/CH341SER_MAC_ZIP.html&quot;&gt;CH340 driver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Run the command in Terminal: &lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&lt;/code&gt; (disable kext signing introduced in Mac OS X 10.9 Yosemite)&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also you're right &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot;&gt;according to Uno and FDTI&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Differences with other boards&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Uno differs from all preceding boards in that it &lt;strong&gt;does not&lt;/strong&gt; use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="14475" LastActivityDate="2015-10-31T13:40:49.410" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="17359" PostTypeId="1" CreationDate="2015-10-31T14:39:19.623" Score="1" ViewCount="774" Body="&lt;p&gt;Here is what I want to do or get it done (since I am not a embedded guy)...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a prototype with Arduino to detect open window/door of my room using camera(image processing/object state detection)? &lt;/li&gt;&#xA;&lt;li&gt;that prototype will take pictures of room door/window at certain interval and than using some algorithm to decide whether they are open or not and will sound an alarm if it is open.&lt;/li&gt;&#xA;&lt;li&gt;prototype should work in dark as well&lt;/li&gt;&#xA;&lt;li&gt;No false alarms&lt;/li&gt;&#xA;&lt;li&gt;Form factor should be small (the final product should not be bigger than smoke detectors that we have it in our room)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My questions are..&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is it possible? :)&lt;/li&gt;&#xA;&lt;li&gt;What all things I need to create a prototype?&lt;/li&gt;&#xA;&lt;li&gt;Which camera should I use? Camera should be really small.&lt;/li&gt;&#xA;&lt;li&gt;Are algorithms available to detect it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14476" LastEditorUserId="10794" LastEditDate="2015-11-02T20:54:25.000" LastActivityDate="2015-11-02T21:18:09.323" Title="Create a device to detect object state" Tags="|arduino-uno|programming|sensors|hardware|system-design|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17360" PostTypeId="2" ParentId="17359" CreationDate="2015-10-31T14:51:04.957" Score="1" Body="&lt;p&gt;Your answers :-)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;yes, it's possible and should not be too complex&lt;/li&gt;&#xA;&lt;li&gt;for a simple prototype, you do not need an embedded device, just a PC with a webcam&lt;/li&gt;&#xA;&lt;li&gt;a webcam with few megapixels should be enough&lt;/li&gt;&#xA;&lt;li&gt;try &lt;a href=&quot;http://docs.opencv.org/2.4/doc/tutorials/tutorials.html&quot; rel=&quot;nofollow&quot;&gt;OpenCV&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After your prototype is ready, you can use a small PC-like platform.&#xA;Examples: &lt;a href=&quot;https://www.google.com/aclk?sa=l&amp;amp;ai=CsNmY_dM0VuiRFuKBzAOcxJDgDdGgyKIH8efl4LMC_cvtnrYCCAAQAWD3AaAB3equ_gPIAQGqBCdP0M5kw2YT3Obbzfo8B3d9qayKUzbCXrPpIufHz_uQFQPIWMXZfWaAB4uV0QGIBwGQBwKoB6a-G9gHAQ&amp;amp;sig=AOD64_3sTdZzbZkDAbC22hPrSwlSylgCpQ&amp;amp;clui=0&amp;amp;q=&amp;amp;ved=0CBsQ0QxqFQoTCL3Vz7357MgCFYGocgodxggEyw&amp;amp;adurl=http://netgate.com/turbot/&quot; rel=&quot;nofollow&quot;&gt;Minnowboard&lt;/a&gt;, &lt;a href=&quot;http://www.intel.com/content/www/us/en/do-it-yourself/edison.html&quot; rel=&quot;nofollow&quot;&gt;Edison&lt;/a&gt;, &lt;a href=&quot;http://beagleboard.org/bone&quot; rel=&quot;nofollow&quot;&gt;BeagleBone&lt;/a&gt;, &lt;a href=&quot;https://www.raspberrypi.org/products/raspberry-pi-2-model-b/&quot; rel=&quot;nofollow&quot;&gt;RaspBerry PI 2&lt;/a&gt;, &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;Arduino Yun&lt;/a&gt;, &lt;a href=&quot;http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-overview.html&quot; rel=&quot;nofollow&quot;&gt;Galileo 2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A word of warning: depending on the expectations you have, you will have to pick more powerful models. Computer Vision is computationally intensive.&#xA;The examples I gave are roughly sorted by performance and, unsurprisingly, cost. OpenCV is available for many architectures, but afaik, it is particularly optimized for x86, since it's mostly sponsored by Intel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclosure: I work for Intel, so I am more informed on Intel products, but by no means I'm trying to do advertisement, this answer is simply given to the best of my knowledge.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-10-31T14:51:04.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17361" PostTypeId="2" ParentId="17351" CreationDate="2015-10-31T15:01:52.593" Score="0" Body="&lt;p&gt;Best answer is Arduino Uno because it is enough for your application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But all Arduino are works on 5 volt or 3.3 volt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For operating 12 volt devices use transistors or MOSFETs.&lt;/p&gt;&#xA;" OwnerUserId="14477" LastEditorUserId="10794" LastEditDate="2015-11-03T04:29:13.033" LastActivityDate="2015-11-03T04:29:13.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17364" PostTypeId="2" ParentId="1850" CreationDate="2015-10-31T16:34:15.580" Score="1" Body="&lt;p&gt;I also got same problem and actually the problem was is of arduino. Arduino ATmega328 IC and ATmega16u chip was damaged . After that I replace ATmega328 Damaged Ic With new one reprogram it and program in ATmega16u chip and upload firmwares to ATmega16u chip.&lt;/p&gt;&#xA;" OwnerUserId="14394" LastActivityDate="2015-10-31T16:34:15.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17365" PostTypeId="2" ParentId="85" CreationDate="2015-10-31T16:39:53.173" Score="1" Body="&lt;p&gt;&quot; Peter R. Bloomfield &quot; I used to upload sketch in my arduino uno by connecting Rx and Tx pin but my sketch get uploaded.&#xA;Actually problem is arduino uno driver may be deleted in your case&lt;/p&gt;&#xA;" OwnerUserId="14394" LastEditorUserId="14394" LastEditDate="2015-11-03T13:28:11.027" LastActivityDate="2015-11-03T13:28:11.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17366" PostTypeId="2" ParentId="8379" CreationDate="2015-10-31T16:42:13.110" Score="0" Body="&lt;p&gt;May be your ATmega328 IC would have been damaged or ATmega16u or ATmega8u chip was damaged. I also got same few days ago.&lt;/p&gt;&#xA;" OwnerUserId="14394" LastActivityDate="2015-10-31T16:42:13.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17367" PostTypeId="2" ParentId="4769" CreationDate="2015-10-31T16:44:41.760" Score="2" Body="&lt;p&gt;Yes, you can unplug it directly whether if serial communication is active or not if you dont need power supply anu more using usb cable&lt;/p&gt;&#xA;" OwnerUserId="14394" LastActivityDate="2015-10-31T16:44:41.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17369" PostTypeId="2" ParentId="9018" CreationDate="2015-10-31T17:07:05.513" Score="0" Body="&lt;p&gt;just go to this link. &#xA;Visit to &#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/PWM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first use PWM to both right side and left side motor.&#xA;When right side motor spin/rotate at 255 value make leftside motor rotation speed at about 100 then you will see that it goes left-forward like wise you do rest of other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  //LEFT MOTOR&#xA;  pinMode(7, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT); // connect pwm pin of left motor at pin9&#xA;&#xA;  //right motor&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;  pinMode(12, OUTPUT); motor // connect pwm pin of right motor at pin12&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(7, HIGH);&#xA;  digitalWrite(8, LOW);&#xA;  analogWrite(9, 100);&#xA;  delay(1000);&#xA;  digitalWrite(10, HIGH);&#xA;  digitalWrite(11, LOW);&#xA;  analogWrite(12, 255);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14394" LastEditorUserId="14394" LastEditDate="2015-10-31T17:44:54.357" LastActivityDate="2015-10-31T17:44:54.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17372" PostTypeId="2" ParentId="17359" CreationDate="2015-10-31T18:04:53.630" Score="1" Body="&lt;p&gt;I wonder if you haven't overspecified the device? Is there a reason that it must be photo-interpretive? Because if you only need to know whether a door or window is open, a couple of switches and some simple wired logic, or the very most basic of micro-controllers, if you choose to go that way, will be more than adequate, less expensive, more reliable in the long term (Ok, I know you won't be in a dorm room for long), less prone to false or missed alarms, totally unaffected by the ambient lighting or the lack of it, unobtrusive (no cameras - plural - in the middle of the room). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I get that it might not be as much fun to make, if that is one of your top criteria!&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-10-31T18:11:21.567" LastActivityDate="2015-10-31T18:11:21.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17375" PostTypeId="1" AcceptedAnswerId="17379" CreationDate="2015-10-31T18:41:25.200" Score="0" ViewCount="578" Body="&lt;p&gt;I have this application where I want to send commands from the PC to an Arduino, remotely, and receive an answer back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware configuration I'm using to achieve that is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PC &amp;lt;--&amp;gt; Arduino with an Xbee &amp;lt;--&amp;gt; Another Arduino with another Xbee&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's just half-duplex communication. Everything seems easy, but there is a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each Arduino has an Xbee Shield with an Xbee module connected to it.&#xA;Reading the documentation of the ArduinoXbeeShield, an excerpt caught my eye:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&quot;With the jumpers in the Xbee position (i.e. on the two pins towards theinterior of the board), the DOUT pin of the Xbee module is connected to the RX pin of the microcontroller; and DIN is connected to TX. Note that the RX and TX pins of the microcontroller are still connected to the TX and RX pins (respectively) of the FTDI chip - data sent from the microcontroller will be transmitted to the computer via USB as well as being sent wirelessly by the Xbee module. &lt;strong&gt;The microcontroller, however, will only be able to receive data from the Xbee module, not over USB from the computer&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;With the jumpers in the USB position (i.e. on the two pins nearest the edge of the board), the DOUT pin the Xbee module is connected to the RX pin of the FTDI chip, and DIN on the Xbee module is connected to the TX pin of the FTDI chip. This means that the Xbee module can communicate directly with the computer - &lt;strong&gt;however, this only works if the microcontroller has been removed from the Arduino board. If the microcontroller is left in the Arduino board, it will be able to talk to the computer normally via USB, but neither the computer nor the microcontroller will be able to talk to the Xbee module&lt;/strong&gt;.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means I will not be able to build what I want with this configuration?&#xA;I already tried, but didn't work.&lt;/p&gt;&#xA;" OwnerDisplayName="user14480" LastActivityDate="2015-10-31T19:13:12.613" Title="PC &lt;-&gt; Xbee &lt;-&gt; Another Xbee Communication" Tags="|arduino-uno|serial|shields|xbee|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17376" PostTypeId="1" CreationDate="2015-10-31T18:59:11.353" Score="0" ViewCount="202" Body="&lt;p&gt;I'm working with esp8266.i am able to send text from webserver to arduino which is displayed on my 16*2 lcd display.but the problem is that when i send text including space i.e:john smith, the text show on my serial monitor and also in lcd  like that (john+smith)..the spaces i gave is converted into &quot;+&quot; sign..Can anyone suggest me how to overcome from that problem??&#xA;my code is given below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;  #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA; SoftwareSerial espSerial(2,3);&#xA;&#xA;  LiquidCrystal lcd(12,11, 7, 6, 5, 4);&#xA;&#xA;const bool printReply = true;&#xA;const char line[] = &quot;-----\n\r&quot;;&#xA;int loopCount=0;&#xA;&#xA;char html[50];&#xA;char command[20];&#xA;char reply[500]; &#xA;&#xA;char ipAddress [20];&#xA;char name[30];&#xA;int lenHtml = 0;&#xA;char temp[5];&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;      Serial.begin(9600);&#xA;        lcd.begin(16,2);&#xA;&#xA;      Serial.println(&quot;Start\r\n\r\n&quot;);&#xA;&#xA;      lcd.print(&quot;WELCOME &quot;);&#xA;&#xA;      espSerial.begin(9600); &#xA;&#xA;&#xA;&#xA;      Serial.println(&quot;reset the module&quot;); &#xA;      espSerial.print(&quot;AT+RST\r\n&quot;);&#xA;&#xA;      getReply( 2000 );&#xA;&#xA;&#xA;&#xA;      Serial.println(&quot;Change to station mode&quot;); &#xA;      lcd.clear();&#xA;      lcd.print(&quot;station mode&quot;);&#xA;      espSerial.print(&quot;AT+CWMODE=1\r\n&quot;);&#xA;      getReply( 1500 );&#xA;&#xA;&#xA;&#xA;      Serial.println(&quot;Connect to a network &quot;);&#xA;      lcd.clear();&#xA;     lcd.print(&quot;connecting...&quot;);&#xA;&#xA;&#xA;      espSerial.print(&quot;AT+CWJAP=\&quot;ESP_E61A83\&quot;\r\n&quot;);&#xA;      getReply( 6000 );&#xA;&#xA;&#xA;      Serial.println(&quot;Get the ip address assigned by the router&quot;); &#xA;      espSerial.print(&quot;AT+CIFSR\r\n&quot;);&#xA;      getReply( 1000 );&#xA;&#xA;&#xA;      int len = strlen( reply ); &#xA;      bool done=false;&#xA;      bool error = false;&#xA;      int pos = 0;&#xA;      while (!done)&#xA;      {&#xA;           if ( reply[pos] == 10) { done = true;} &#xA;           pos++;&#xA;           if (pos &amp;gt; len) { done = true;  error = true;}&#xA;      }&#xA;&#xA;      if (!error)&#xA;      {&#xA;            int buffpos = 0;&#xA;            done = false;&#xA;            while (!done)&#xA;            {&#xA;               if ( reply[pos] == 13 ) { done = true; }&#xA;               else { ipAddress[buffpos] = reply[pos];    buffpos++; pos++;   }&#xA;            }&#xA;            ipAddress[buffpos] = 0;&#xA;      }&#xA;      else { strcpy(ipAddress,&quot;ERROR&quot;); }&#xA;&#xA;&#xA;&#xA;&#xA;      Serial.println(&quot;Set for multiple connections&quot;); &#xA;      espSerial.print(&quot;AT+CIPMUX=1\r\n&quot;);&#xA;      getReply( 1500 );&#xA;&#xA;&#xA;&#xA;      Serial.println(&quot;Start the server&quot;); &#xA;        lcd.clear();&#xA;      lcd.print(&quot;Server starts&quot;);&#xA;      espSerial.print(&quot;AT+CIPSERVER=1,80\r\n&quot;);&#xA;      getReply( 1500 );&#xA;&#xA;      Serial.println(&quot;&quot;);&#xA;&#xA;&#xA;&#xA;   lcd.clear();&#xA;      Serial.println(&quot;Waiting for page request&quot;);&#xA;      Serial.print(&quot;Connect to &quot;); Serial.println(ipAddress);&#xA;      Serial.println(&quot;&quot;);&#xA;lcd.print(&quot;feed me more&quot;);&#xA;delay(1500);&#xA;        lcd.clear();&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;      if(espSerial.available()) &#xA;&#xA;&#xA;&#xA;          bool foundIPD = false;&#xA;          for (int i=0; i&amp;lt;strlen(reply); i++)&#xA;          {&#xA;               if (  (reply[i]=='I') &amp;amp;&amp;amp; (reply[i+1]=='P') &amp;amp;&amp;amp; (reply[i+2]=='D')   ) { foundIPD = true;    }&#xA;          }&#xA;&#xA;&#xA;          if ( foundIPD  )  &#xA;          {&#xA;&#xA;              loopCount++;&#xA;&#xA;              int nameStartPos = 0;&#xA;              for (int i=0; i&amp;lt;strlen(reply); i++)&#xA;              {&#xA;                   if (!haveName)&#xA;                   {&#xA;                         if (  (reply[i]=='n') &amp;amp;&amp;amp; (reply[i+1]=='a') &amp;amp;&amp;amp; (reply[i+2]=='m') &amp;amp;&amp;amp; (reply[i+3]=='e')  &amp;amp;&amp;amp; (reply[i+4]=='=') ) &#xA;                         { &#xA;                             haveName = true;&#xA;                             nameStartPos = i+5;&#xA;                         }&#xA;                   }     &#xA;              }&#xA;&#xA;&#xA;              if (haveName)&#xA;              {&#xA;                    int tempPos = 0;&#xA;                    bool finishedCopying = false;&#xA;                    for (int i=nameStartPos; i&amp;lt;strlen(reply); i++)&#xA;                    {&#xA;                         if ( (reply[i]==' ') &amp;amp;&amp;amp; !finishedCopying )  { finishedCopying = true;   } &#xA;                         if ( !finishedCopying )                     { name[tempPos] = reply[i];   tempPos++; }&#xA;                    }              &#xA;                    name[tempPos] = 0;&#xA;              }&#xA;&#xA;              if (haveName) { lcd.clear(); lcd.print(&quot;TEACHERS INFO..&quot;);Serial.print( &quot;name = &quot;);lcd.setCursor(0,1);Serial.println(name);lcd.print(name);Serial.println(&quot;&quot;);lcd.print(&quot;&quot;); }&#xA;&#xA;&#xA;&#xA;              else          { Serial.println( &quot;no name entered&quot;);   Serial.println(&quot;&quot;);lcd.print(&quot;&quot;); }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;              strcpy(html,&quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,25\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );          &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );                      &#xA;&#xA;              strcpy(html,&quot;&amp;lt;h1 &amp;gt;TEACHERS INFORMATION WEBSERVER&amp;lt;/h1&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,40\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );         &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );          &#xA;&#xA;              strcpy(html,&quot;&amp;lt;p&amp;gt;CREATED by jack&amp;lt;/p&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,31\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );          &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );           &#xA;&#xA;              strcpy(html,&quot;&amp;lt;p&amp;gt; Teachers Request number &quot;);&#xA;              itoa( loopCount, temp, 10);&#xA;              strcat(html,temp);&#xA;              strcat(html,&quot;&amp;lt;/p&amp;gt;&quot;);&#xA;&#xA;              // need the length of html&#xA;              int lenHtml = strlen( html );&#xA;&#xA;              strcpy(command,&quot;AT+CIPSEND=0,&quot;);&#xA;              itoa( lenHtml, temp, 10);&#xA;              strcat(command, temp);&#xA;              strcat(command, &quot;\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );          &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );                       &#xA;&#xA;&#xA;&#xA;             if (haveName)&#xA;             {&#xA;&#xA;                  strcpy(html,&quot;&amp;lt;p &amp;gt;TEACHER name is &quot;); strcat(html, name ); strcat(html,&quot;&amp;lt;/p&amp;gt;&quot;);&#xA;&#xA;&#xA;                  lenHtml = strlen( html );&#xA;                  strcpy(command,&quot;AT+CIPSEND=0,&quot;); itoa( lenHtml, temp, 10); strcat(command, temp); strcat(command, &quot;\r\n&quot;);&#xA;                  espSerial.print(command);&#xA;                  getReply( 2000 );          &#xA;                  espSerial.print(html);&#xA;                  getReply( 2000 );                           &#xA;             }&#xA;&#xA;&#xA;              strcpy(html,&quot;&amp;lt;form action=\&quot;&quot;); strcat(html, ipAddress); strcat(html, &quot;\&quot; method=\&quot;GET\&quot;&amp;gt;&quot;); strcat(command, &quot;\r\n&quot;);&#xA;&#xA;              lenHtml = strlen( html );&#xA;              itoa( lenHtml, temp, 10);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,&quot;); &#xA;              itoa( lenHtml, temp, 10); &#xA;              strcat(command, temp);  &#xA;              strcat(command, &quot;\r\n&quot;);&#xA;&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );          &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );          &#xA;&#xA;              strcpy(html,&quot;Name:&amp;lt;br&amp;gt;&amp;lt;input type=\&quot;text\&quot; name=\&quot;name\&quot;&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,40\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );         &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );         &#xA;&#xA;&#xA;              strcpy(html,&quot;&amp;lt;input type=\&quot;submit\&quot; value=\&quot;Submit\&quot;&amp;gt;&amp;lt;/form&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,43\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 );       &#xA;              espSerial.print(html);&#xA;              getReply( 2000 );&#xA;&#xA;              strcpy(html,&quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;);&#xA;              strcpy(command,&quot;AT+CIPSEND=0,14\r\n&quot;);&#xA;              espSerial.print(command);&#xA;              getReply( 2000 ); &#xA;              espSerial.print(html);&#xA;              getReply( 2000 ); &#xA;&#xA;&#xA;              espSerial.print( &quot;AT+CIPCLOSE=0\r\n&quot; );&#xA;              getReply( 1500 );            &#xA;&#xA;&#xA;              Serial.println(&quot;last getReply 1 &quot;);&#xA;              getReply( 2500 );  &#xA;&#xA;              Serial.println(&quot;last getReply 2 &quot;);&#xA;              getReply( 2500 ); &#xA;&#xA;&#xA;&#xA;          } &#xA;      } &#xA;&#xA;&#xA;      delay (100);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void getReply(int wait)&#xA;{&#xA;    int tempPos = 0;&#xA;    long int time = millis();&#xA;    while( (time + wait) &amp;gt; millis())&#xA;    {&#xA;        while(espSerial.available())&#xA;        {&#xA;            char c = espSerial.read(); &#xA;            if (tempPos &amp;lt; 500) { reply[tempPos] = c; tempPos++;   }&#xA;        }&#xA;        reply[tempPos] = 0;&#xA;    } &#xA;&#xA;    if (printReply) { Serial.println( reply );  Serial.println(line);     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13522" LastEditorUserId="4143" LastEditDate="2015-10-31T19:02:35.973" LastActivityDate="2015-10-31T19:36:21.777" Title="How can i change &quot;+&quot; sign into spaces?" Tags="|esp8266|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17378" PostTypeId="2" ParentId="17376" CreationDate="2015-10-31T19:06:51.493" Score="0" Body="&lt;p&gt;If you have your text in a character array, which it seems you have, then it is simple enough to iterate through that array changing whatever characters you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if the text is in &lt;code&gt;reply&lt;/code&gt; then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (char *p = reply; *p; p++) {&#xA;    if (*p == '+') *p = ' ';&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, starting at the beginning of reply, by creating a pointer &lt;code&gt;p&lt;/code&gt; and pointing it at the start of reply, check to see if there is anything except the &lt;code&gt;NULL&lt;/code&gt; character, run the code inside the brackets, and move to the next character (p++).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code inside the brackets looks to see if the current character is a + and if so then set the current character to be a space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to use an integer counter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; reply[i] != 0; i++) {&#xA;    if (reply[i] == '+') reply[i] = ' ';&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-31T19:06:51.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17379" PostTypeId="2" ParentId="17375" CreationDate="2015-10-31T19:13:12.613" Score="0" Body="&lt;p&gt;Basically with your shield you have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Communicate between the MCU and the XBee at the cost of not being able to communicate between the PC and the MCU.&lt;/li&gt;&#xA;&lt;li&gt;Communicate between the PC and the XBee at the cost of having to remove the MCU from the board completely.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Neither of which are particularly ideal.  The first option is completely out since that rules out all PC communication.  The second option turns the Arduino into just a USB-&gt;TTL Serial adapter - and a rather expensive one at that (you can get them on eBay for like $2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is to re-wire the system using jumper wires (messy, I know) so that the TX and RX pins of the XBee connect to other pins on your Uno then use SoftwareSerial to communicate with the XBee.  That will leave the Arduino's TX and RX pins free for communicating with the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively invest in a different Arduino that has more hardware UART interfaces, like a Mega2560.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-31T19:13:12.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17380" PostTypeId="2" ParentId="17376" CreationDate="2015-10-31T19:30:45.353" Score="0" Body="&lt;p&gt;Two things:&#xA;+If you are using strings, try using the String built in object, it is very handy and useful&#xA;+when using String, you can use replace function&lt;/p&gt;&#xA;" OwnerUserId="8468" LastActivityDate="2015-10-31T19:30:45.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17381" PostTypeId="2" ParentId="17376" CreationDate="2015-10-31T19:36:21.777" Score="1" Body="&lt;p&gt;It is hard to understand what your code does. You said that arduino recives text from the server, but I see in the code is that the arduino &lt;strong&gt;is&lt;/strong&gt; the http server, serving an html page with a form in it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is also the reason you recieve spaces replaced with &quot;+&quot;, the http request is &lt;a href=&quot;https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;url encoded&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with a search and replace solution of a &quot;+&quot; sign is that url encoding is more than a &quot;+&quot; sign. A space can also be encoded into %20 and there are several other characters that are being encoded as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you will have to do is to implement a &lt;strong&gt;decoding&lt;/strong&gt; function. It is not that hard but if you are lazy, there are plenty of C implementations available on the net. Here is a quick google search hit: &lt;a href=&quot;https://gist.github.com/jmsaavedra/7964251&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/jmsaavedra/7964251&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8127" LastActivityDate="2015-10-31T19:36:21.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17383" PostTypeId="2" ParentId="17275" CreationDate="2015-10-31T23:00:24.967" Score="1" Body="&lt;p&gt;The relay module you have is this one from SainSmart:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.sainsmart.com/arduino/arduino-components/relays/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.sainsmart.com/arduino/arduino-components/relays/sainsmart-2-channel-5v-relay-module-for-arduino-raspberry-pi.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The schematic is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mGFca.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mGFca.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see you connect VCC to +5V and IN2 to your IO pin.  Setting the IO to LOW will then turn on the LED and the optocoupler together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's not the only way you can connect it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect VCC to the IO pin and IN2 to GND instead.  Then you set your output HIGH to turn it on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arrangement shown in the schematic is commonly done because some MCUs are able to sink more current than they can source thorugh an IO pin.  That is not the case with an Arduino which has symmetric IO pins that can sink and source the same amount of current.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-10-31T23:00:24.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17384" PostTypeId="2" ParentId="17275" CreationDate="2015-11-01T01:02:03.853" Score="0" Body="&lt;p&gt;I've solved the problem,&#xA;Thanks to everyone who helped. &lt;br&gt;&#xA;I don't need a NOT gate anymore, here's what I added to make it work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void setup() { &lt;br&gt;&#xA;  startup(); &lt;br&gt;&#xA;   &lt;br&gt;&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void  startup() {&lt;br&gt;&#xA;  digitalWrite(relay1, HIGH); &lt;br&gt;&#xA;  digitalWrite(relay2, HIGH); &lt;br&gt;&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop() { &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I removed the rest of the code to keep it simple and easy to understand)&lt;/p&gt;&#xA;" OwnerUserId="14411" LastActivityDate="2015-11-01T01:02:03.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17385" PostTypeId="1" AcceptedAnswerId="17386" CreationDate="2015-11-01T01:45:24.173" Score="0" ViewCount="1389" Body="&lt;p&gt;Previously I had my Due connected via Programming Port for weeks, and it never changed serial ports after pressing the reset button. Recently I switched to having it connected via the Native Port instead, and was surprised to see that it changes port numbers every time I press the reset button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example if it was on ttyATM1 beforehand, after pressing reset it'll be on ttyATM2 instead. It changes numbers like this after every reset. Is this normal behavior?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a python script sending serial data to the Due, and I have to change the port number in the python code every time the Due changes ports. &lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-11-01T02:08:08.727" Title="Why does Arduino Due Native Port change serial ports after every reset? (Linux)" Tags="|serial|arduino-due|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17386" PostTypeId="2" ParentId="17385" CreationDate="2015-11-01T02:08:08.727" Score="1" Body="&lt;p&gt;It happens because of Linux, not because of the Arduino.&#xA;Since you unplug/reset the DUE while the port is still open, when it's back online, the old file name is still in use, so a new one is created.&#xA;Just close the port before resetting the DUE and you will see that after the reset it will have the same one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily reproduce the same issue with a serial to usb adapter (/dev/ttyUSBS0,1,2,etc) and screen or minicom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make your program more robust, you should listen for kernel events and open the port accordingly.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-01T02:08:08.727" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17388" PostTypeId="2" ParentId="17301" CreationDate="2015-11-01T05:01:03.960" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://www.pololu.com/product/1394&quot; rel=&quot;nofollow&quot;&gt;Pololu jrk 21v3&lt;/a&gt; motor controller supports four input modalities: via USB, via TTL-level serial, via RC / pulse width control, and via the mode you are trying to use, an analog 0-5V input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears you are trying to use a PWM output to produce an analog signal control mode.  A PWM signal is a pulsed digital output rather than an analog signal.  The 21v3 may be jittering its control setpoint back and forth between 0V and 5V at a high frequency, which will make the linear actuator jitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try adding an &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=971&amp;amp;bih=588&amp;amp;q=RC+low-pass+filter&amp;amp;oq=RC+low-pass+filter&amp;amp;gs_l=img.12..0j0i30l6j0i5i30l3.963.963.0.2484.1.1.0.0.0.0.80.80.1.1.0....0...1ac..64.img..0.1.80.SfBLFQdVhSA&quot; rel=&quot;nofollow&quot;&gt;RC low-pass filter&lt;/a&gt; to the PWM output, ie between your PWM pin 6 and the input to the 21v3.  (Note, it might make more sense to use a software-serial output to control the 21v3, instead of using a PWM output with a low-pass filter, which may still allow use of hardware serial for your other sensors...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To verify if an RC filter will work, try at first with large R (eg 5KΩ to 10KΩ) and large C (eg 5μF to 10μF) to see if the jitter goes away.  If so, you then can tune the filter to find how small you can make R or C and still avoid jitter.  A filter with smaller RC will allow higher-frequency control than will one with larger RC, but may be more prone to jitter.  R should be somewhat less than the input impedance of the 21v3's analog input.  To determine that value, look at the data sheet of whatever chip that input goes into.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-01T05:01:03.960" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17389" PostTypeId="1" CreationDate="2015-11-01T09:21:28.547" Score="1" ViewCount="105" Body="&lt;p&gt;I am working on a project with Arduino Uno Clone. After having a look on my arrangement, please tell me whether I will have to face any difficulty or consider any thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a relay on pin 2 (drive An Induction cooktop from AC Mains), &lt;/p&gt;&#xA;&#xA;&lt;p&gt;6 mini 9g servo from pin 3-8 (want to drive non-pwm pins with any Software library), &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a 8 ohm speaker on pin 9, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a microSd card module from pin 10-13 (play .wav files through speaker), &lt;/p&gt;&#xA;&#xA;&lt;p&gt;5 pushbuttons from pin A0-A4, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;a toy dc motor on A5 (Drive through a transistor). So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Will I have to face any pin arrangement problem in my project? If yes, please give me a solution &lt;/li&gt;&#xA;&lt;li&gt;I have six servos and a dc motor in which only one will be moving at a time, is there really a need of external power source for motors &lt;/li&gt;&#xA;&lt;li&gt;I have to drive this arrangement through AC Mains, but i dont want to buy An adapter. I have a mobile charger which have written &quot;INPUT 100-250V AC, OUTPUT 4-12V, 800mA&quot; , can I drive my arduino with this? &lt;/li&gt;&#xA;&lt;li&gt;Can I boost the volume of my speaker by using a transistor or capacitor (I have no idea about amplifier IC) ? &lt;/li&gt;&#xA;&lt;li&gt;I have to include these librairies, SD library, tmrpcm, SPI, servo, and any one extra to drive servos on non-pwm pins. What would be the total size because my arduino has only 30kb approx?  Thanks To Give Me Time. Please help me.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11772" LastEditorUserId="14490" LastEditDate="2015-11-01T10:49:39.870" LastActivityDate="2016-01-30T14:40:17.860" Title="Will there be any pin interference in this Project?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17390" PostTypeId="2" ParentId="13150" CreationDate="2015-11-01T10:20:12.797" Score="3" Body="&lt;p&gt;Some good results you can get with &lt;a href=&quot;https://en.wikipedia.org/wiki/Opto-isolator&quot; rel=&quot;nofollow noreferrer&quot;&gt;optocouplers&lt;/a&gt;.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4OV9U.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4OV9U.png&quot; alt=&quot;PC817 photo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's electrically disconnects one part of your circuit from another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, here is my IoT-ish device, which is detects water leaks in my bathroom:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CPr45.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CPr45.png&quot; alt=&quot;Scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the transformer (T1), which have two separate output windings, so, that windings does not connected electrically, only magnetically. The block in border &quot;Sensing unit&quot; doesn't have any wires with other scheme - only magnetic field, which is gives it power, and infrared light in the optocoupler (u2, &lt;a href=&quot;https://pdf1.alldatasheet.com/datasheet-pdf/view/43368/SHARP/PC817.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PC817&lt;/a&gt;), which informs ESP01 about leak presence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does it work? Very simple! When the water shorts JP1 (long naked wires on the floor), Q1 opens and lights-up the IR diode in PC817. Light from this diode opens another transistor - and pulls the RxD PIN of ESP01 down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/BG4444/waterLeakDetector&quot; rel=&quot;nofollow noreferrer&quot;&gt;Small sketch&lt;/a&gt;, written on Arduino for ESP8266 periodically sends pin state by &lt;code&gt;HTTPS&lt;/code&gt; on my web server, where monitor software, &lt;a href=&quot;https://en.wikipedia.org/wiki/Nagios&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nagios&lt;/a&gt;, checks the information age and the pin state, and send to me notifications, when something goes wrong.&lt;/p&gt;&#xA;" OwnerUserId="14490" LastEditorUserId="14490" LastEditDate="2020-02-07T07:37:25.480" LastActivityDate="2020-02-07T07:37:25.480" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17391" PostTypeId="2" ParentId="17319" CreationDate="2015-11-01T11:14:41.503" Score="1" Body="&lt;pre&gt;&lt;code&gt; import serial #import Serial Library&#xA; import numpy  # Import numpy&#xA; import matplotlib.pyplot as plt #import matplotlib library&#xA; from drawnow import *&#xA;&#xA; accelX = []&#xA; accelY = []&#xA; accelZ = []&#xA;&#xA;arduinoData = serial.Serial('COM4', 115200)&#xA;plt.ion()    #Tell matplotlib you want interactive mode to plot live data&#xA;cnt = 0&#xA;def makeFig():         #Create a function that makes our desired plot&#xA;#plt.ylim(0,1000)                #Set the limit on the y axis&#xA;plt.title('Sensor data')         #Set the title&#xA;plt.grid(True)                   #Set The grid&#xA;plt.ylabel('Axis Acceleration')  #Label the y axis&#xA;plt.plot(accelX,'ro-', label='Raw X Acceleration') #Set the line plot &#xA;plt.ylim(0, 1000)&#xA;plt.legend(loc = 'upper left')&#xA;plt2 = plt.twinx()  #Create a new object of plt2 &#xA;plt2.plot(accelY, 'b^-', label='Raw Y Acceleration')&#xA;#plt2.ylim(0,1000)&#xA;plt2.legend(loc='center right')&#xA;plt2.ticklabel_format(useOffset=False) #Compel matplotlib not to autoscale&#xA;#plt3 = plt.twinx()&#xA;plt.plot(accelZ, 'go-', label='Raw Z Acceleration')&#xA;plt.legend(loc='upper right')&#xA;plt.ylim(0,1000)&#xA;&#xA; while True: #While loop that loops forever&#xA;   while(arduinoData.inWaiting() == 0):   #Wait here until there is data&#xA;    pass #do nothing&#xA;arduinoString = arduinoData.readline() #read the line of text from serial &#xA;dataArray = arduinoString.strip().strip('\n')  #Split into an array&#xA;# Ensure that you are not working on empty line&#xA;if arduinoString:&#xA;    dataArray = arduinoString.split(&quot;,&quot;) &#xA;# Ensure that index is not out of range&#xA;if len(dataArray) &amp;gt; 1:&#xA;    xAxis = int(dataArray[0]) #Convert first element to int insert in xAxis&#xA;    yAxis = int(dataArray[1]) #Convert second element to int insert in yAxis&#xA;    zAxis = int(dataArray[2]) #Convert third element to int insert in zAxis&#xA;    print xAxis, &quot;,&quot;, yAxis, &quot;,&quot;, zAxis&#xA;    accelX.append(xAxis)   #Build our x axis array by appending to accelX&#xA;    accelY.append(yAxis)   #Build our y axis array by appending to accelY&#xA;    accelZ.append(zAxis)   #Build our z axis array by appending to accelZ&#xA;    drawnow(makeFig)       #Call drawnow to update our live graph&#xA;    plt.pause(.0000001)&#xA;    cnt=cnt+1&#xA;    if(cnt&amp;gt;50):&#xA;        accelX.pop(0)&#xA;        accelY.pop(0)&#xA;        accelZ.pop(0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="14350" LastEditDate="2015-11-01T11:26:25.337" LastActivityDate="2015-11-01T11:26:25.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17392" PostTypeId="1" CreationDate="2015-11-01T12:17:35.227" Score="2" ViewCount="191" Body="&lt;p&gt;Let's say someone has four CAT5 cables that are running along the ceiling for the length of a room (30 feet), of which most of the twisted pairs are connected to Arduino input/output pins on one end. Would it be okay to keep these wires bundled together when running along the ceiling? Or is it safer to keep them separated by a few inches? Is interference usually a problem only in very specific situations, or should it be considered for all long wire runs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about if there is a telephone cable (hooked up to a landline telephone) running along the same length? Is there any chance of interference if this is too close to the Arduino cables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about if there are 120v mains lines running the same length? Should these be kept at a distance from the Arduino cables?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other end of the cables that are hooked up to the Arduino, some of the following are connected: temperature sensors, light sensors, servo motors, LCDs, relays, and push-buttons.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2016-01-30T23:46:18.700" Title="Should long wires be kept separated from each other, to reduce interference?" Tags="|wires|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17393" PostTypeId="2" ParentId="17357" CreationDate="2015-11-01T12:27:43.173" Score="1" Body="&lt;p&gt;As Majenko has noted in the comments, the solution was to declare &quot;EthernetClient client;&quot; as a global variable, outside of the loop. Normally I would've tried something like this on my own, but was hesitant to do so because I had never seen anything like that in other code.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-11-01T12:27:43.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17394" PostTypeId="2" ParentId="17392" CreationDate="2015-11-01T12:53:43.953" Score="1" Body="&lt;p&gt;It depends on the frequency/frequencies you care about transmitting on your cables. One simple approach is to put on both ends a filter that lets pass only those frequencies you care about.&#xA;You can also consider using some error detection/correction encoding or check if there is some existing library that suits your needs. This last approach will work if you do not get too many interferences and your application can tolerate that data is re-transmitted every now and then, making the communication timing not 100% deterministic.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-01T12:53:43.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17395" PostTypeId="2" ParentId="17389" CreationDate="2015-11-01T13:02:52.657" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;possibly you will face problems with current drain and timing. There is no ready made solution. You have to get a bit farther by yourself and come back with detailed descriptions of your problems.&lt;/li&gt;&#xA;&lt;li&gt;check on other threads (google) the issues with driving directly a coil. There are plenty of explanations why you need to be careful about it.&lt;/li&gt;&#xA;&lt;li&gt;you should at least try to do the math yourself, then ask for verification. Try to calculate the power requirements of each component (average, maximum, peak) and add them up for every scenario. The you can report your finding and ask for confirmation/advice.&lt;/li&gt;&#xA;&lt;li&gt;Sure you can, there are plenty of solutions available, but you have to define your requirements and constraints. Then it's easy to pick one solution (or at least google for it).&lt;/li&gt;&#xA;&lt;li&gt;Just try to include them in the project and compile them. It's fast and you will get the answer immediately. There are ways to optimize things, but first you should assess if it's needed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All in all, to get more help, you should show more in detail what you have already done, what are your concerns and why.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-01T13:02:52.657" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17396" PostTypeId="2" ParentId="17392" CreationDate="2015-11-01T14:09:44.470" Score="2" Body="&lt;p&gt;A benefit of using CAT-5 is that the pairs are twisted.  You would want to look at how you are using the pairs so that you're not introducing cross talk inadvertently, but the twisted pairs tend to resist RFI which is why its used.  Telephone wire, however, can be a completely different story.  You may find some that is twisted pair, but most if it is simply flat cable.  Worse, much of it is very cheap flat cable with what amounts to a piece of thread with a very thin foil wrapped around it.  This is very high loss and very vulnerable to RFI.&lt;/p&gt;&#xA;" OwnerUserId="14231" LastActivityDate="2015-11-01T14:09:44.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17397" PostTypeId="2" ParentId="61" CreationDate="2015-11-01T14:23:53.040" Score="5" Body="&lt;p&gt;You could e.g. use my simulator.&#xA;It is especially suitable for PLC-like applications, where multitasking is achieved by cyclic evaluation of interconnected circuit-like objects: Timers, Markers, Latches, Oneshots and Registers.&#xA;You can use it to simulate your controlled system as well, as becomes clear from the examples in the download. It has modest visualisation capacities, can draw timing charts, and allows you to access and alter c.q. force all variables in real time during a running simulation. Also you can freeze time. When you're satisfied with the behavior of your control it generates the C code to be uploaded to an actual Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://pypi.python.org/pypi/SimPyLC&quot; rel=&quot;noreferrer&quot;&gt;https://pypi.python.org/pypi/SimPyLC&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14493" LastEditorUserId="14493" LastEditDate="2015-11-01T14:31:18.277" LastActivityDate="2015-11-01T14:31:18.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17398" PostTypeId="2" ParentId="16479" CreationDate="2015-11-01T14:54:50.140" Score="2" Body="&lt;p&gt;A popular option is the Shinyei PPD42 sensor. There are a few well-documented blogs that describe how to connect it to an Arduino. Some of the users determined that the sensors are more accurate when a fan is placed on the unit to blow air through it, but this might not be necessary in an outdoors and windy environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two of these sensors hooked up to an Arduino, one monitoring indoors and one outdoors. I found that the indoors unit needed a fan on it to help it detect particles better (otherwise I was getting too many zeros). But the outdoors unit seems fine without the fan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mainly followed this blog's instructions for the code:&#xA;&lt;a href=&quot;http://www.howmuchsnow.com/arduino/airquality/grovedust/&quot; rel=&quot;nofollow&quot;&gt;http://www.howmuchsnow.com/arduino/airquality/grovedust/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I read a few months ago that the next best sensors are in the $200 range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Dylos DC1100 dust monitor (considered very accurate) and it usually correlates with my Shinyei readings. But I'm pretty sure I introduced some &quot;magic numbers&quot; into my code to make the Shinyei readings match more closely with the Dylos. The entire process wasn't easy for me, and it took me weeks to get everything to behave the way I wanted.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-11-01T14:54:50.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17399" PostTypeId="1" CreationDate="2015-11-01T15:29:36.693" Score="0" ViewCount="92" Body="&lt;p&gt;I have modified the code for Flappy Duino to give me a score at the end of the game. Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;Adafruit_PCD8544.h&amp;gt;&#xA;&#xA;Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);&#xA;&#xA;#include &quot;Sprite.h&quot;&#xA;#include &quot;Chym.h&quot;&#xA;#include &quot;Bar.h&quot;&#xA;&#xA;Chym player;&#xA;Bar bar; Bar bar2;&#xA;int gameScore = 0;&#xA;int highScore = 0;&#xA;int KNOCK_PIN = 2;&#xA;int LED_PIN = 8;&#xA;&#xA;boolean clicked = false;&#xA;&#xA;void loop(){}&#xA;&#xA;void resetGame() {&#xA;  player.respawn();&#xA;  bar.setPos(0, 20);&#xA;  bar2.setPos(50, 30);&#xA;  gameScore = 0;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  display.begin();&#xA;  display.setContrast(50);&#xA;  display.clearDisplay();&#xA;  display.display();&#xA;&#xA;  digitalWrite(LED_PIN, HIGH);&#xA;&#xA;  pinMode(KNOCK_PIN, INPUT_PULLUP);&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;&#xA;  resetGame();&#xA;&#xA;  while(1) {&#xA;    getInput();&#xA;    player.update();&#xA;    bar.update(); bar2.update();&#xA;    drawLCD();&#xA;  }&#xA;}&#xA;&#xA;void getInput() {&#xA;  int knock = digitalRead(KNOCK_PIN);&#xA;  if (knock == 0) { // push down&#xA;    clicked = true;&#xA;    gameScore = gameScore + 1;&#xA;    Serial.println(gameScore);&#xA;  } &#xA;  else {&#xA;    clicked = false;&#xA;  }&#xA;}&#xA;&#xA;void drawLCD() {&#xA;  display.clearDisplay();&#xA;&#xA;  if (!player.isDead()) {&#xA;    int ht1 = bar.hitTest(player.getX(), player.getY());&#xA;    int ht2 = bar2.hitTest(player.getX(), player.getY());&#xA;    int die = ht1 + ht2;&#xA;    if (die == 1) {&#xA;        // game over&#xA;        player.die();&#xA;    }&#xA;&#xA;    if (clicked) {&#xA;      player.flyUp();&#xA;    } &#xA;    else {&#xA;      player.cancelJump();&#xA;    }&#xA;    player.render();    &#xA;&#xA;    bar.render(); bar2.render(); &#xA;  } &#xA;  else {&#xA;    if (gameScore &amp;gt;&amp;gt; highScore) {&#xA;      highScore = gameScore;&#xA;    }&#xA;    display.setCursor(0, 0);&#xA;    display.setTextSize(1);&#xA;    display.print(&quot;ur Score- &quot;);&#xA;    display.println(gameScore);&#xA;    display.print(&quot;HI Score- &quot;);&#xA;    display.println(highScore);&#xA;    if (clicked) {&#xA;      resetGame();&#xA;    }&#xA;  }&#xA;&#xA;  display.display();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first time the game runs thru the gameScore is greater than highScore so gameScore and highScore print as the same. However every other time the function is called up the highScore doesn't change even when the following statement is true:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (gameScore &amp;gt;&amp;gt; highScore) {&#xA;          highScore = gameScore;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-11-01T15:32:54.393" Title="Broken Score on Game Sketch" Tags="|programming|c++|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17400" PostTypeId="2" ParentId="17399" CreationDate="2015-11-01T15:32:54.393" Score="1" Body="&lt;pre&gt;&lt;code&gt;if (gameScore &amp;gt;&amp;gt; highScore)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have the wrong operator there.  &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is &lt;em&gt;right shift&lt;/em&gt;, so you are right shifting the &lt;code&gt;gameScore&lt;/code&gt; by &lt;code&gt;highScore&lt;/code&gt; bits, which if it's more than 16 will end up as 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you just want &lt;code&gt;&amp;gt;&lt;/code&gt; for &lt;em&gt;greater than&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (gameScore &amp;gt; highScore)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-01T15:32:54.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17402" PostTypeId="1" CreationDate="2015-11-01T16:11:37.880" Score="2" ViewCount="3587" Body="&lt;p&gt;I was using a 20x4 LCD connected to Arduino Uno via &lt;a href=&quot;http://www.ebay.com/itm/IiC-I2C-TWI-SP-I-Serial-Interface-Board-Adapter-Module-Port-For-Arduino-1602LCD-/181576314435&quot; rel=&quot;nofollow noreferrer&quot;&gt;a common I2C adapter board.&lt;/a&gt; Everything was working perfectly, including the LCD. I had it running like this for a couple of days without any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My next step was to connect the LCD to a Nano instead in order to make the package smaller. The exact same code from the Uno was uploaded to the Nano, and I connected the wires in the exact same way. The major difference here was that I soldered the wires onto the Nano, because I didn't want to use headers. I did a continuity test for shorts and the connections seemed to be fine. There are only 4 wires between the Arduino and LCD adapter board: 5v, ground, SDA and SCL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nano powers up fine, and the LCD powers up fine, but immediately the LCD shows the following:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/E6Qzl.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E6Qzl.jpg&quot; alt=&quot;Corrupt LCD&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That had never happened when I had the LCD connected to the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, the LCD stops working completely, even when I move it back to the UNO. It just constantly displays those 2 lines. (Adjusting the contrast makes the boxes appear or disappear).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the first LCD seemed permanently broken like that, I tested it on a 2nd brand-new LCD. First I connected it to the same Uno with the same code, and everything was working perfectly. I re-uploaded that same code again to the Nano, just to make sure everything was in sync. Then upon connecting the 2nd LCD to the Nano, immediately it displayed those 2 lines. I disconnected it right away (within 5 seconds), and tried to put it back on the Uno, but still the display is corrupted. I've tried other sketches, but both of these displays seem to be broken and never display anything except for those 2 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if I just connect 5v and ground to the LCD, no matter from what source, it just constantly displays those 2 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas as to what could &quot;break&quot; an LCD so quickly like that, and if it's possible fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;As per Gerben's suggestion, I removed the I2C backpack and hooked the LCD up directly. This was the 2nd one I had broken, the one where I'm more certain of its entire (short) history. I ended up with the exact same result. Adjusting the pot only makes the boxes appear or disappear. I tried skipping the Arduino completely and giving it 5v power from an adapter, and it still has the same result.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/O5DY3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O5DY3.jpg&quot; alt=&quot;Corrupt LCD without backpack&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="11174" LastEditDate="2015-11-01T18:46:05.453" LastActivityDate="2019-09-10T07:54:42.280" Title="What could make an LCD stop working permanently after being connected for 5 seconds to Arduino?" Tags="|lcd|arduino-nano|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17403" PostTypeId="1" CreationDate="2015-11-01T18:30:40.623" Score="1" ViewCount="356" Body="&lt;p&gt;I am planning for a project but i am stuck with a task and hope you could help me. My work is to note down a number which is actually a set of readings displayed on a meter and store it on a arduino. My problem is that i need a detection technique so that i could record the number or extract the number from a image or video if u suggest to use a camera or recorder or purely can be a sensor. Thank you guys, waiting for you.&lt;/p&gt;&#xA;" OwnerUserId="14499" LastEditorUserId="4143" LastEditDate="2015-11-01T19:03:57.760" LastActivityDate="2015-11-02T21:53:16.623" Title="Arduino number detection" Tags="|sensors|" AnswerCount="1" CommentCount="3" ClosedDate="2015-11-05T23:37:31.937" ContentLicense="CC BY-SA 3.0" />
  <row Id="17406" PostTypeId="1" AcceptedAnswerId="17408" CreationDate="2015-11-01T20:31:33.477" Score="2" ViewCount="2207" Body="&lt;p&gt;my Problem is, that I get random values from my ultra sonic sensor if my arduino is connected to any external power supply (vin port 30) on my arduino nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I power up from the laptop usb port, I get consistent values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested 3 different power supplies between 7-17V and up to 2000mA.&#xA;I have tested this on 2 different nano boards.&#xA;Also tested with an extra 2000uF capacitor between vin and gnd&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pls help if you got an idea :)&lt;/p&gt;&#xA;" OwnerUserId="14501" LastActivityDate="2023-02-17T23:29:18.783" Title="Ultrasonic sensor returns random values on external power supply" Tags="|power|arduino-nano|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17407" PostTypeId="1" CreationDate="2015-11-01T23:23:23.727" Score="2" ViewCount="764" Body="&lt;p&gt;I'm very new with this devices so I'm a bit confused. I've got two Xbee modules series 1 and an Arduino UNO. I want to make like a chat between the two Xbee modules, one of them connected to the PC through a Xbee Explorer USB and the other one assembled in the Arduino Board through a shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've configured the two Xbee modules with the same PAN ID and Channel, and the Xbee module 1 has MY = 0 and DL = 1 and the Xbee module 2 has MY = 1 and DL =0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected the Xbee module 1 to the PC through the Explorer and the Xbee module 2 connected to the PC through Ardunino+Shield.&#xA;I've uploaded the following code to Arduino:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(4, 5); // RX, TX&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;  }&#xA;  if (Serial.available()) {&#xA;    mySerial.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my shield the jumper of the RX digital is the 4th pin and the TX jumper in the 5th pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I open the serial monitor window I get the message &quot;Goodnight moon!&quot; but when I send a message from the XCTU console or from the serial window I don't get that message in the other interface (XCTU console or serial monitor window).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the shield (this one &lt;a href=&quot;http://www.seeedstudio.com/wiki/XBee_Shield_V2.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.seeedstudio.com/wiki/XBee_Shield_V2.0&lt;/a&gt;) I've 4 leds: first one (power) is on, the second one (signal strength) is off, the third one (association) blinks all the time, and the fourth one (on/sleep) is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why I don't get the messages like a chat? What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!! &lt;/p&gt;&#xA;" OwnerUserId="14503" LastEditorUserId="37523" LastEditDate="2019-07-28T16:00:04.817" LastActivityDate="2019-07-28T16:00:04.817" Title="Chat between Xbee and Arduino" Tags="|softwareserial|communication|shields|xbee|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="17408" PostTypeId="2" ParentId="17406" CreationDate="2015-11-01T23:57:38.710" Score="3" Body="&lt;p&gt;So i tried to used a stable 5V input on the 5V input pin and got the same more or less random values (jumping all around... especially on targets more than 1m away) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I changed form newPing lib (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=37712.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=37712.0&lt;/a&gt;) to Ultrasonic lib (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=37712.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=37712.0&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the values are correct on each power supply and even more accurate on high distance than with newPing on USB power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't know whats broken with the newPing v1.7 lib -.- but this works!&lt;/p&gt;&#xA;" OwnerUserId="14501" LastEditorUserId="14501" LastEditDate="2015-11-07T20:18:45.367" LastActivityDate="2015-11-07T20:18:45.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17410" PostTypeId="2" ParentId="17349" CreationDate="2015-11-02T00:53:07.370" Score="1" Body="&lt;p&gt;Step 1: I would load NodeMCU on you ESP8266: &lt;a href=&quot;https://github.com/nodemcu/nodemcu-firmware&quot; rel=&quot;nofollow&quot;&gt;https://github.com/nodemcu/nodemcu-firmware&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 2: Connect to your home router or make an ap on one of your ESP and connect them... use the api: &lt;a href=&quot;https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en&quot; rel=&quot;nofollow&quot;&gt;https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en&lt;/a&gt; over serial connection&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 3: write a TCP server:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;srv=net.createServer(net.TCP)&#xA;srv:listen(80,function(conn)&#xA;  conn:on(&quot;receive&quot;,function(conn,payload)&#xA;    print(payload) //This payload will be send to your arduino over soft serial&#xA;    conn:send(&quot;&amp;lt;h1&amp;gt; Hello, NodeMCU!!! &amp;lt;/h1&amp;gt;&quot;)&#xA;  end)&#xA;  conn:on(&quot;sent&quot;,function(conn) conn:close() end)&#xA;end)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 4: write a TCP client:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;suc = false;&#xA;function sendData( host, pathData )&#xA;    suc = false;&#xA;    print(&quot;GoSending!&quot;);&#xA;    -- A simple http client&#xA;    conn=net.createConnection(net.TCP, 0)&#xA;    conn:on(&quot;receive&quot;, function(conn, payload)&#xA;        if(string.find(payload, &quot;200 OK&quot;)~=nil) then&#xA;            suc = true;&#xA;            print(&quot;AllDone&quot;)&#xA;        else&#xA;            suc = false;&#xA;        end&#xA;    end)&#xA;    conn:on(&quot;connection&quot;, function(c)&#xA;        print(&quot;connected&quot;);&#xA;        conn:send(&quot;GET /&quot;.. pathData ..&quot; HTTP/1.1\r\nHost: &quot;.. host ..&quot;\r\n&quot;&#xA;            ..&quot;Connection: keep-alive\r\nAccept: */*\r\n\r\n&quot;) &#xA;        end)&#xA;    conn:on(&quot;disconnection&quot;, function() &#xA;        if(suc==false) then&#xA;            print(&quot;ErrorSending&quot;)&#xA;        end&#xA;    end)&#xA;    conn:on(&quot;reconnection&quot;, function() print(&quot;reconnection&quot;) end )&#xA;    conn:connect(80,host)&#xA;end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Step 5: Connect your esp boards with software serial to the arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 6: write (from board 1) to softserial to esp1: sendData( hostIP, yourData) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step: 7 Parse the Data on sofserial read on the second arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 8: DONE!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok more infos on step 6.&#xA;If you got your script running on your esp, you can call functions by sending the function name with parameters over your serial connection. &#xA;So, this is some example code for your ardoino if you got the script from above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial wifi(3, 2); // RX, TX&#xA;&#xA;//at some time in your programm&#xA;//Build up your string that will be send over serial&#xA;String i1 = &quot;sendData(\&quot;ipFromTheServer\&quot;, \&quot;send.php?d=&quot;;&#xA;String i2 = i1+dataToSend;&#xA;String i3 = i2 +&quot;\&quot;);&quot;;&#xA;wifi.println(i3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will call the sendData function on you esp. this will call the send.php on a Server... you can put a server up on an other esp and call it (dont have to be a php page)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More infos on step 7.&#xA;the script on top will always print all incoming data. So you just have to read serial data on wifi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (wifi.available())&#xA;    Serial.write(wifi.read()); //this will print all inc data to your arduino console (serial) parse this data!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Info: I've build this on my own... dont know if this is best practice :)&lt;/p&gt;&#xA;" OwnerUserId="14501" LastEditorUserId="14501" LastEditDate="2015-11-15T16:22:36.687" LastActivityDate="2015-11-15T16:22:36.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17411" PostTypeId="1" CreationDate="2015-11-02T01:57:55.847" Score="1" ViewCount="5672" Body="&lt;p&gt;I am interested in learning how the Arduino IDE handles parameters in order to correctly upload hex files with &lt;em&gt;avrdude&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this in &lt;em&gt;boards.txt&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.name=Arduino/Genuino Uno&#xA;&#xA;uno.vid.0=0x2341&#xA;uno.pid.0=0x0043&#xA;uno.vid.1=0x2341&#xA;uno.pid.1=0x0001&#xA;uno.vid.2=0x2A03&#xA;uno.pid.2=0x0043&#xA;uno.vid.3=0x2341&#xA;uno.pid.3=0x0243&#xA;&#xA;uno.upload.tool=avrdude&#xA;uno.upload.protocol=arduino&#xA;uno.upload.maximum_size=32256&#xA;uno.upload.maximum_data_size=2048&#xA;uno.upload.speed=115200&#xA;&#xA;uno.bootloader.tool=avrdude&#xA;uno.bootloader.low_fuses=0xFF&#xA;uno.bootloader.high_fuses=0xDE&#xA;uno.bootloader.extended_fuses=0x05&#xA;uno.bootloader.unlock_bits=0x3F&#xA;uno.bootloader.lock_bits=0x0F&#xA;uno.bootloader.file=optiboot/optiboot_atmega328.hex&#xA;&#xA;uno.build.mcu=atmega328p&#xA;uno.build.f_cpu=16000000L&#xA;uno.build.board=AVR_UNO&#xA;uno.build.core=arduino&#xA;uno.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is this in &lt;em&gt;platform.txt&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# AVR Uploader/Programmers tools&#xA;# ------------------------------&#xA;&#xA;tools.avrdude.path={runtime.tools.avrdude.path}&#xA;tools.avrdude.cmd.path={path}/bin/avrdude&#xA;tools.avrdude.config.path={path}/etc/avrdude.conf&#xA;&#xA;tools.avrdude.upload.params.verbose=-v&#xA;tools.avrdude.upload.params.quiet=-q -q&#xA;tools.avrdude.upload.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude.program.params.verbose=-v&#xA;tools.avrdude.program.params.quiet=-q -q&#xA;tools.avrdude.program.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude.erase.params.verbose=-v&#xA;tools.avrdude.erase.params.quiet=-q -q&#xA;tools.avrdude.erase.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m&#xA;&#xA;tools.avrdude.bootloader.params.verbose=-v&#xA;tools.avrdude.bootloader.params.quiet=-q -q&#xA;tools.avrdude.bootloader.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i&quot; -Ulock:w:{bootloader.lock_bits}:m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line is particularly interesting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tools.avrdude.upload.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like these variables are corresponding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{cmd.path} --&amp;gt; tools.avrdude.cmd.path&#xA;{config.path} --&amp;gt; tools.avrdude.config.path&#xA;{upload.verbose} --&amp;gt; tools.avrdude.upload.params.verbose&#xA;{build.mcu} --&amp;gt; uno.build.mcu&#xA;{upload.protocol} --&amp;gt; uno.upload.protocol&#xA;{serial.port} --&amp;gt; ?&#xA;{upload.speed} --&amp;gt; uno.upload.speed&#xA;{build.path} --&amp;gt; ?&#xA;{build.project_name} --&amp;gt; ?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems these are likely used in the Java code for the IDE. There are obviously a few I am unsure of. I would guess these are considered user inputs in the IDE. Though I am by no means a Java or JavaScript programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where are these variables explicitly defined in the Arduino library? (e.g. &lt;code&gt;{runtime.tools.avrdude.path}&lt;/code&gt;, &lt;code&gt;{path}&lt;/code&gt;, &lt;code&gt;{cmd.path}&lt;/code&gt; ....) Or how do they get defined by IDE?&lt;/p&gt;&#xA;" OwnerUserId="13854" LastEditorUserId="6936" LastEditDate="2016-03-31T13:30:08.193" LastActivityDate="2021-01-31T07:30:04.430" Title="Where do avrdude parameters get defined in the Arduino IDE?" Tags="|arduino-ide|uploading|avrdude|core-libraries|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17412" PostTypeId="2" ParentId="9111" CreationDate="2015-11-02T02:09:16.870" Score="0" Body="&lt;p&gt;Try the Dot &lt;a href=&quot;http://www.eran.io/the-dot-factory-an-lcd-font-and-image-generator/&quot; rel=&quot;nofollow&quot;&gt;Factory&lt;/a&gt; and The LCD &lt;a href=&quot;http://en.radzio.dxp.pl/bitmap_converter/&quot; rel=&quot;nofollow&quot;&gt;Assistant&lt;/a&gt;. I'm happy with both. Let's you create any Windows font. &lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2015-11-02T02:09:16.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17413" PostTypeId="2" ParentId="17411" CreationDate="2015-11-02T05:56:52.993" Score="-1" Body="&lt;p&gt;The Arduino library is about what runs on the target, while the &quot;IDE&quot; (not sure if it can still be called IDE, as now they try to do also command line) is about everything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But my impression is that if you are ready to ask these sort of question, you could consider dropping the IDE and moving to a more standard Makefile approach. Or Maybe Eclipse, where you still have the IDE, but you can define everything in a more standard way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino approach is good to get people with little experienced started, but after a while one started to feel its limitations.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-02T05:56:52.993" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17414" PostTypeId="1" CreationDate="2015-11-02T07:45:22.940" Score="1" ViewCount="2519" Body="&lt;p&gt;I'm trying to understand the values that I'm getting from my MPU6050. I believe that there is a problem with my code. I'm not entirely sure how the code is supposed to look like. There doesn't seem to be very many examples on the MPU6050.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;After taking a look at the system print I found that the numbers that are written out is the time and not the values of the MPU6050. Why am I getting the zeros and nan for?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I also had a library problem thats fixed now.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the code from a site and I've modified it because it didn't run for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// collect readings&#xA;accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;// apply gyro scale from datasheet&#xA;gsx = gx/gyroScale;   gsy = gy/gyroScale;   gsz = gz/gyroScale;&#xA;&#xA;// calculate accelerometer angles&#xA;ary = -(180/3.141592) * atan(ax / sqrt(square(ay) + square(az))); &#xA;arx =  (180/3.141592) * atan(ay / sqrt(square(ax) + square(az)));&#xA;arz = (180/3.141592) * atan(sqrt(square(ay) + square(ax)) / az);&#xA;&#xA;// set initial values equal to accel values&#xA;if (i == 1) {&#xA;grx = arx;&#xA;gry = ary;&#xA;grz = arz;&#xA;}&#xA;// integrate to find the gyro angle&#xA;else{&#xA;grx = grx + (timeStep * gsx);&#xA;gry = gry + (timeStep * gsy);&#xA;grz = grz + (timeStep * gsz);&#xA;}  &#xA;&#xA;// apply filter&#xA;rx = (0.1 * arx) + (0.9 * grx);&#xA;ry = (0.1 * ary) + (0.9 * gry);&#xA;rz = (0.1 * arz) + (0.9 * grz);&#xA;&#xA; Serial.print(ax);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(ay);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(az);   Serial.print(&quot;\t\t&quot;);&#xA; Serial.print(gx);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(gy);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(gz);   Serial.print(&quot;\t\t&quot;);&#xA; Serial.print(arx);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(ary);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(arz);   Serial.print(&quot;\t\t&quot;);&#xA; Serial.print(grx);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(gry);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(grz);   Serial.print(&quot;\t\t&quot;);&#xA; Serial.print(rx);   Serial.print(&quot;\t&quot;);&#xA; Serial.print(ry);   Serial.print(&quot;\t&quot;);&#xA; Serial.println(rz);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output im getting &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2   1.00    61.00   0.06000     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;3   61.00   139.00  0.07800     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;4   139.00  219.00  0.08000     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;5   219.00  300.00  0.08100     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;6   300.00  380.00  0.08000     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;7   380.00  462.00  0.08200     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;8   462.00  543.00  0.08100     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;9   543.00  624.00  0.08100     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;10  624.00  705.00  0.08100     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;11  705.00  788.00  0.08300     0   0   0       0   0   0       nan nan nan     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;41  3223.00 3307.00 0.08400     0   0   0       0   0   0       nan nan nan nan nan nan     nan nan nan&#xA;42  3307.00 3392.00 0.08500     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;43  3392.00 3476.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;44  3476.00 3560.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;45  3560.00 3645.00 0.08500     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;46  3645.00 3729.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;47  3729.00 3813.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;48  3813.00 3897.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;49  3897.00 3982.00 0.08500     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;50  3982.00 4066.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;51  4066.00 4150.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;52  4150.00 4234.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;53  4234.00 4319.00 0.08500     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;54  4319.00 4403.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;55  4403.00 4487.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;56  4487.00 4571.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;57  4571.00 4656.00 0.08500     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;58  4656.00 4740.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;59  4740.00 4824.00 0.08400     0   0   0       0   0   0       nan nan nan     nan nan nan     nan nan nan&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="6936" LastEditDate="2016-01-01T13:34:00.333" LastActivityDate="2020-02-29T19:35:17.660" Title="Understanding values from an MPU6050" Tags="|arduino-uno|mpu6050|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17415" PostTypeId="2" ParentId="4019" CreationDate="2015-11-02T09:55:06.277" Score="0" Body="&#xA;&#xA;&lt;p&gt;To use external interrupt 4 (INT6), pin D7 on Leonardo board. we need change interrupt register as follows&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   EICRB |= (1&amp;lt;&amp;lt;ISC60)|(1&amp;lt;&amp;lt;ISC61); // sets the interrupt type&#xA;   EIMSK |= (1&amp;lt;&amp;lt;INT6); // activates the interrupt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that write in WInterrupts.c&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Follow this link&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=124057.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=124057.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14507" LastEditorUserId="10794" LastEditDate="2015-11-02T20:44:22.490" LastActivityDate="2015-11-02T20:44:22.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17416" PostTypeId="1" AcceptedAnswerId="17418" CreationDate="2015-11-02T10:47:45.553" Score="0" ViewCount="488" Body="&lt;p&gt;I have &lt;strong&gt;two 6 volts DC motors&lt;/strong&gt; connected to &lt;strong&gt;L298N motor Driver&lt;/strong&gt;. Do I need to use 12 Volts battery?&lt;/p&gt;&#xA;" OwnerUserId="14508" LastActivityDate="2015-11-02T11:13:11.733" Title="I have two 6 volts DC motors connected to L298N motor Driver. Do I need to use 12 Volts battery?" Tags="|arduino-uno|motor|battery|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17417" PostTypeId="2" ParentId="17414" CreationDate="2015-11-02T10:49:01.747" Score="1" Body="&lt;p&gt;The output MPU 6050 does need filtering/processing before you can get any sense from it.  I have used the library &quot;MPU6050_6Axis_MotionApps20.h&quot; with success, it is located here: &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h&quot; rel=&quot;nofollow&quot;&gt;MPU6050_6Axis_MotionApps20.h&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written an example here: &lt;a href=&quot;https://codebender.cc/sketch:118202&quot; rel=&quot;nofollow&quot;&gt;MPU 6050 for MicroView&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11988" LastEditorUserId="6936" LastEditDate="2015-12-31T09:48:35.950" LastActivityDate="2015-12-31T09:48:35.950" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17418" PostTypeId="2" ParentId="17416" CreationDate="2015-11-02T11:13:11.733" Score="1" Body="&lt;p&gt;No, you need to use a (roughly) 6V battery. They are 6V motors, so they need a 6V battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you &lt;em&gt;do&lt;/em&gt; need to sum the &lt;em&gt;currents&lt;/em&gt; not the voltages. The battery must be able to provide &lt;em&gt;at least&lt;/em&gt; the current required by &lt;em&gt;both&lt;/em&gt; motors together.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-02T11:13:11.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17422" PostTypeId="1" CreationDate="2015-11-02T14:31:36.257" Score="0" ViewCount="4141" Body="&lt;p&gt;I want to program a temperature sensor with a LED using Arduino. &#xA;the goal is to make a sensor, when the temperature is over than Temperature max, the LED turns off and when the temperature is small than temperature max we turn on the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my problem is when I programed the void setup() as followed, the LED doesn't work, and when I comment Serial.begin (9600) the LED work but I cannot diplay the value of the temperature. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   Serial.begin(9600);&#xA;   pinMode(tempPin, INPUT);&#xA;   pinMode(led, OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here you find my complet code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int tempPin = A0;   // the output pin of LM35&#xA;float Max_temp = 24.0;&#xA;int led = 1;&#xA;&#xA;float  temp, cel;&#xA;void setup() {&#xA;   Serial.begin(9600);&#xA;   pinMode(tempPin, INPUT);&#xA;   pinMode(led, OUTPUT);&#xA;}&#xA;void loop() { &#xA;      cel = readTemp(); &#xA;  if(cel&amp;lt; Max_temp) {        // if temp is higher than tempMax&#xA;      digitalWrite(led, HIGH);  // turn on led&#xA;      delay(300);&#xA;     } &#xA;     else {                    // else turn of led&#xA;       digitalWrite(led, LOW);  // turn on led&#xA;      delay(100);&#xA;  }&#xA;   Serial.print(&quot;TEMP: &quot;);&#xA;   Serial.print(cel);      // display the temperature&#xA;   Serial.print(&quot;C &quot;);&#xA;   Serial.println();&#xA;   delay(300);  &#xA;}&#xA;&#xA;float readTemp() {  // get the temperature and convert it to celsius&#xA;  temp = analogRead(tempPin);&#xA;  return temp * 0.48828125;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;thank you very much in advance&lt;/p&gt;&#xA;" OwnerUserId="14515" LastActivityDate="2017-05-06T02:43:24.490" Title="Arduino Temperature sensor with a LED" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17423" PostTypeId="2" ParentId="17422" CreationDate="2015-11-02T14:33:12.870" Score="4" Body="&lt;pre&gt;&lt;code&gt;int led = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You do know that pins 0 and 1 are the serial port don't you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take your pick.... Either use pin 1 for the LED &lt;em&gt;OR&lt;/em&gt; use pin 1 for the serial connection.  You can't do both!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it says &lt;em&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;in the manual&lt;/a&gt;&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In addition, some pins have specialized functions:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-02T15:14:39.780" LastActivityDate="2015-11-02T15:14:39.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17428" PostTypeId="1" AcceptedAnswerId="17439" CreationDate="2015-11-02T19:12:46.803" Score="1" ViewCount="7091" Body="&lt;p&gt;I made this circuit: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D1Oye.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D1Oye.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part with the DC motor is from this tutorial: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v32/experiment-12-driving-a-motor&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v32/experiment-12-driving-a-motor&lt;/a&gt; ( I only use another resistor, with 220 OHM)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, I also have a TMP36 sensor attached. What I would like to do is this:&#xA;When the temperature is 25 degrees or more, the motor should turn on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//TMP36 Pin Variables&#xA;int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to&#xA;                        //the resolution is 10 mV / degree centigrade with a&#xA;                        //500 mV offset to allow for negative temperatures&#xA;&#xA;/*&#xA; * setup() - this function runs once when you turn your Arduino on&#xA; * We initialize the serial connection with the computer&#xA; */&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);  //Start the serial connection with the computer&#xA;                       //to view the result open the serial monitor &#xA;}&#xA;&#xA;void loop()                     // run over and over again&#xA;{&#xA; //getting the voltage reading from the temperature sensor&#xA; int reading = analogRead(sensorPin);  &#xA;&#xA; // converting that reading to voltage, for 3.3v arduino use 3.3&#xA; float voltage = reading * 5.0;&#xA; voltage /= 1024.0; &#xA;&#xA; // print out the voltage&#xA; Serial.print(voltage); Serial.println(&quot; volts&quot;);&#xA;&#xA; // now print out the temperature&#xA; float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset&#xA;                                               //to degrees ((voltage - 500mV) times 100)&#xA; Serial.print(temperatureC); Serial.println(&quot; degrees C&quot;);&#xA;&#xA; if(temperatureC &amp;gt;= 25){&#xA;  analogWrite(9, 250);&#xA; }&#xA;&#xA;&#xA; delay(1000);                                     //waiting a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get this result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.74 volts&#xA;24.22 degrees C&#xA;0.74 volts&#xA;24.22 degrees C&#xA;0.74 volts&#xA;24.22 degrees C&#xA;0.74 volts&#xA;24.22 degrees C&#xA;0.74 volts&#xA;24.22 degrees C&#xA;0.74 volts&#xA;24.22 degrees C&#xA;0.75 volts&#xA;25.20 degrees C &amp;lt;------&#xA;0.87 volts&#xA;36.91 degrees C&#xA;0.66 volts&#xA;16.41 degrees C&#xA;0.78 volts&#xA;27.64 degrees C&#xA;0.77 volts&#xA;26.66 degrees C&#xA;0.84 volts&#xA;34.47 degrees C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point where the sensor measures &gt; 25 degrees, the motor turns on but the circuit gets &quot;poluted&quot; and the temp sensor starts to send all kinds of strange values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I solve this?&#xA;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;hr /&gt;&#xA;&#xA;&lt;p&gt;I got it to work in with the following: http:// i.stack.imgur.com/4GFPH.png&lt;/p&gt;&#xA;" OwnerUserId="14522" LastEditorUserId="14522" LastEditDate="2015-11-06T12:51:19.377" LastActivityDate="2017-06-24T11:55:23.030" Title="Arduino + TMP36 + DC Motor" Tags="|motor|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17429" PostTypeId="1" CreationDate="2015-11-02T19:22:55.243" Score="1" ViewCount="55" Body="&lt;p&gt;So at my school we are preapering for a competition. They asked me to do the technical side of it. And I accepted... I was thinking of using an arduino as a usb device for the buttons. I am going to use the serial port for this. But I can't think of a way to do it in the way I want. I want to recieve the button presses fair and well. But I also want to control the lights for the buttons, from my computer. I am using &lt;code&gt;Serial.printLn()&lt;/code&gt; to send the serial data to the computer. But how can I send serial data to the arduino without delaying other things (What happens when someone presses a button while I am sending a command?)? Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="14516" LastActivityDate="2015-11-02T19:52:52.443" Title="Efficiently using a serial inteface" Tags="|serial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17430" PostTypeId="2" ParentId="17429" CreationDate="2015-11-02T19:52:52.443" Score="-1" Body="&lt;p&gt;The nastiest part in what you describe is likely to be the debouncing on the button, rather than the serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One easy way out is to use some form of bounceless implementation, like an optical coupler. Another is to use HW debouncing, like the MAX 6816 family.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can use a loop where you alternate between serial communications and checks for the status of the buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can rely on interrupts for the buttons, but it's more complex and might be overkill.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-02T19:52:52.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17431" PostTypeId="1" CreationDate="2015-11-02T17:35:17.480" Score="2" ViewCount="1044" Body="&lt;p&gt;I configured two XBees using &lt;a href=&quot;http://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu&quot; rel=&quot;nofollow noreferrer&quot;&gt;XCTU&lt;/a&gt;, connected them to the computer and sent Bytes back and forth. &lt;strong&gt;&lt;em&gt;Works.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rSq9r.png&quot; alt=&quot;Works.&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the current, non-working setup: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;1 XBee, connected to the Computer using a &lt;a href=&quot;https://www.sparkfun.com/products/11812&quot; rel=&quot;nofollow noreferrer&quot;&gt;SparkFun XBee Explorer USB&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;1 XBee, connected to an Arduino Mega using &lt;a href=&quot;https://www.sparkfun.com/products/11373&quot; rel=&quot;nofollow noreferrer&quot;&gt;SparkFun XBee Explorer Regulated&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;GND to GND&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;5V to 5V on the Arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;DOUT to TX1 on the Arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;DIN to RX1 on the Arduino&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial1.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;  //After 3 seconds the XBee should send out a couple of &quot;A&quot;s coming from the serial port&#xA;  delay(3000);&#xA;  int i = 0;&#xA;  while (i &amp;lt; 10) {&#xA;    Serial1.print(&quot;A&quot;);&#xA;    delay(100);&#xA;    i++;&#xA;  }&#xA;}&#xA;void loop() {&#xA;  //If anything is sent to the XBee it should appear in the Arduino's serial buffer&#xA;  //making the LED on pin 13 turn on&#xA;  if (Serial1.available() &amp;gt; 0) {&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The DOUT LED on the Explorer Regulated flashes as supposed to but nothing is received on the computer where my Terminal application is listening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same when I send something from the Terminal, the LED on pin 13 of the Arduino does not indicate any bytes in the buffer, meaning that the XBee probably never received anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried swapping TX &amp;amp; RX, resulting in the DIN LED blinking instead of DOUT. Transmission still not working.&lt;/p&gt;&#xA;" OwnerUserId="14535" OwnerDisplayName="Dario" LastEditorUserId="37523" LastEditDate="2019-07-28T15:57:46.183" LastActivityDate="2019-07-28T15:57:46.183" Title="Serial communication between Computer &amp; Arduino via XBee" Tags="|serial|wireless|uart|xbee|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="17434" PostTypeId="2" ParentId="17359" CreationDate="2015-11-02T21:05:13.907" Score="0" Body="&lt;p&gt;I doubt you could make such a thing, especially with no embedded experience.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You want to use a camera, but it should &quot;work in the dark&quot; - problem there. You would need to somehow &quot;light&quot; the room with (say) infra-red, but then technically it wouldn't be dark any more.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It should be really small, but has to have the power of image capture and image processing. Maybe a dedicated board designed by people with a lot of experience, and using surface-mounted devices, could do that. I strongly doubt you could do it on an Arduino of any type.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No false alarms? Without knowing your windows that might be hard to say, but considering windows are usually made of glass, detecting the difference between a closed window, and a wide-open one, might be marginal as you would still see the scene outside through the glass. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As the sun rises and falls the image captured would change considerably, quite probably leading to false alarms. Imagine a sudden thunderstorm, where the next image is much darker than the previous one. The image comparison would register a &quot;difference&quot;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Imagine a picture taken during a storm with lightning flashes corrupting the image.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is someone enters the room and walks in front of the window? That would register as a difference, but doesn't mean the window is open.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What seems much more practical to me would be variants of existing technologies, eg.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Magnets and reed switches&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Shine a laser on the window and detect if it moves (the angle would probably change).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use distance-detection, such as pinging devices. An open window would change the distance (a bit).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use passive infra-red to detect the movement when the window opens.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Vibration detection mounted on the window glass, or possibly the window frame.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Temperature measurement to detect a difference in temperature as the window opens.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The camera sounds to me the least practical.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-02T21:05:13.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17435" PostTypeId="2" ParentId="17359" CreationDate="2015-11-02T21:18:09.323" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Here is what I want to do or get it done (since I am not a embedded&#xA;  guy)...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Welcome to the world of embedded... things. I highly appreciate your interest in the embedded world, after all it's more interesting as just PC things :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;create a prototype with Arduino to detect open window/door of my room &lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You've come to the right place, Arduino (embedded stuff) is very good at input/output. And that seems like a fun project!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;using camera(image processing/object state detection)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Wait, where did this come from? Humans are good at observing, their main sense would be vision (I guess?) to do so. Microcontrollers are somewhat better at logic signals. They are good at taking sensor signals and turning them into whatever you like.&#xA;&lt;em&gt;There is a possibility you'd just like to do something with image processing/detection. If so, please mention that :)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;that prototype will take pictures of room door/window at certain interval and than using some algorithm to decide whether they are open&#xA;  or not and will sound an alarm if it is open.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Arduino can read out a simple &lt;a href=&quot;https://www.adafruit.com/products/375&quot; rel=&quot;nofollow&quot;&gt;&quot;Door sensor&quot;&lt;/a&gt; and check if the door is, or is not closed. This will both shrink your project and make it easier.&#xA;Arduino can sound an alarm. You can even add a keypad (for a disable code).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;prototype should work in dark as well&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The drawback of human vision. Is that it does not work so well in the dark. Sensor's based on the touch of the door or a magnetic contact on the door are not affected by darkness.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;No false alarms&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If your sensor won't fail, the alarm won't go off by accident :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Form factor should be small (the final product should not be bigger than smoke detectors that we have it in our room)&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use an arduino nano or micro.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My questions are..&#xA;  - Is it possible? :)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yup! You can check for &lt;a href=&quot;http://www.instructables.com/id/Getting-the-required-components/&quot; rel=&quot;nofollow&quot;&gt;existing projects&lt;/a&gt; on the web. You can put in your own implementation though.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;What all things I need to create a prototype?&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Whatever you need is what you will need.&#xA;An sensor as input, an arduino to process it and an &quot;alarm&quot;.&#xA;There are a trillion configurations for this, you can choose to just go by one or check what fits your needs best.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Which camera should I use? Camera should be really small.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unless you really want to get going with camera detection/object tracking, you shouldn't use one. (Especially with arduino it can be quite frustrating.) You should use a PC or raspberry Pi or Android phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or use arduino with said sensor.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Are algorithms available to detect it?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Yes. For this, it's again application specific. You should check out some resources, check what others use and determine what would work best for you. Try it out and if it won't work you can ask it :) (probably on normal stack-overflow since it's not really arduino related, maybe robotics stackexchange).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-11-02T21:18:09.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17436" PostTypeId="1" AcceptedAnswerId="17676" CreationDate="2015-11-02T21:43:29.853" Score="5" ViewCount="10512" Body="&lt;p&gt;I've bought this sensor module board to link to an Arduino nano: &lt;a href=&quot;http://www.ebay.com/itm/For-Arduino-Liquid-PH-Value-Detection-detect-Sensor-Module-Monitoring-Controller/321764233326&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/For-Arduino-Liquid-PH-Value-Detection-detect-Sensor-Module-Monitoring-Controller/321764233326&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assumed the two screws were for calibration (low point + slope), but it seems the operation is different and I can't figure out how. I've got two reference liquids for pH of 4.0 and 7.0. When I put the probe in either one, I get readings. Turning one of the two screws seems to offset the reading so for instance I had pH 4 = 900 and pH 7 = 1000 (0 - 1023 range). Turning one of two screws would lower the value a bit, but it never gets below 500 or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I can do is measure two points (4.0 and 7.0) and their respective measurement values. That way I could calculate points in between, but as far as I know pH is not a linear scale, but logarithmic. If I get this wrong, the reading might seem right but only show 4.0 and 7.0 correct and not the rest of the values (I don't have 10.0 reference fluid at the moment). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now onto the second screw, that one at first seemed to do nothing. But then I noticed that it sets some kind of threshold value, turning a LED on the board on and off. That LED seems to be linked to the value being read, but it's further purpose? Calibration? No idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok so best case someone has an equal module and wants to detail how it works. Otherwise maybe some of you have some bright ideas on what I could try in order to get this to work the way I want it to :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 09-11-2015&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got feedback from the seller. She sent me the following ZIP: &lt;a href=&quot;http://1drv.ms/1MSk1DX&quot; rel=&quot;nofollow&quot;&gt;http://1drv.ms/1MSk1DX&lt;/a&gt;. It contains some files in Chinese but one had sourcecode in it. Tried it on my Arduino but unfortunately the values still don't make much sense. Depending on how I turn the knob on the print, I get values between 9 and 17 for a liquid that's in real life 7.0. I didn't try but doubt that doing a -7 offset is sensible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code itself is pretty straightforward, taking a 6-center average of ten consecutive measures. The interesting lines are these:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; avgValue = 0;&#xA; for (int i=2;i&amp;lt;8;i++)       // take the average value of 6 center sample&#xA;   avgValue+=buf[i]; &#xA;&#xA; float phValue = (float)avgValue*5.0/1024/6; // convert the analog into millivolt&#xA; phValue=3.5*phValue+Offset;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe someone can make sense of this, because I can't. I don't understand the 5.0 multiplication and the 3.5 after that one. Where do these come from? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, when I dip the probe into the storage liquid, my normal meter plummets to pH 0.5 whilst the software is giving me 17 (which is a higher value than the one I got from reading my 7.0 liquid). So either my board is broken or this sample code is useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematics can be found in the ZIP file by the way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 11-11-2015&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did some more experimenting. First I found out that the readings from the module increased for more acidic liquid. So I reversed the value by using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buf[i]=1024 - analogRead(SensorPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok, now the values made more sense. Then I adjusted the pot to be in the middle of the available range. I dipped the probe in the 7.0 liquid, read the value and adjusted the offset. Then dipped in 4.0, adjusted the pot to match with 4.00, here are the results: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pH 7.0 reference --&amp;gt; 6.27&#xA;set offset to: 0.73&#xA;pH 4.0 reference --&amp;gt; 5.17&#xA;adjusted the pot so value read 4.0&#xA;pH 7.0 reference --&amp;gt; 5.86&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So as I expected, adjusting the pot also messes up the 7.0 reference measurement. I then though it might be because of the slope of the pot (if there would be any), so I went to the lowest value first to have the least difference. Again the readings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pH 7.0 reference --&amp;gt; 8.70&#xA;set offset to: -1.70&#xA;pH 4.0 reference --&amp;gt; 5.17&#xA;adjusted the pot so value read 4.0&#xA;pH 7.0 reference --&amp;gt; 5.70&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The interesting thing here is that the 4.0 value reads 5.17 in both cases, even though the pot was in a different position. I cannot explain why though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make sure the probe is fine I re-calibrated my normal pH meter, operates as usual. This one also has two pots, one for 7.0 calibration and one for 4.0 slope. Calibration is done by setting 7.0, then measuring 4.0 and ajusting the slope pot. Measure 7.0 again, change 7.0 pot, measure 4.0 again, etc. until the values match their liquids. Usually takes me about 3 - 4 loops to get it right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Took the two containers of reference fluids and started mixing. This gave me measurements in the range of pH 4 - 7.5. Also measured the storage liquid which has a pH of 1.00. Results are in an Excel sheet: &lt;a href=&quot;http://1drv.ms/1lkAO6e&quot; rel=&quot;nofollow&quot;&gt;http://1drv.ms/1lkAO6e&lt;/a&gt;. Next question is how to convert this into a suitable formula?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 18-11-2015&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working on @slash-dev's solution, here's what I did: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first turned the pot all the way down to the lowest value. The readings (for pH 7.0) are as follows: low = 540 and high = 1017. Code as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rawValue = analogRead(SensorPin);&#xA;int buf[10];                //buffer for read analog&#xA;&#xA;for(int i=0;i&amp;lt;10;i++)       //Get 10 sample value from the sensor for smooth the value&#xA;{ &#xA;   buf[i] = rawValue;&#xA;   delay(10);&#xA;}&#xA;&#xA;// sorting left out to reduce the sample length&#xA;&#xA;int avgValue=0;&#xA;for(int i=2;i&amp;lt;8;i++)  // take the average value of 6 center samples&#xA;   avgValue += (buf[i] - CENTER);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this stage I'm printing the raw value of course.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shorting of the BNC connector I don't exactly understand, should I short the inside (where the pin goes) or the outside of the connector? And short it to the GND? I used the reference solution instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I added the formula to determine the voltage. For the low value that reads 0.10. I now put in the center value of 540 which brings the voltage reading to 0.0, seems good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for step 2 I placed the probe into the 4.0 reference solution. The voltage now reads 0.48, raw value 637. I start adjusting the pot to where the voltage reads 2.25, takes quit some adjusting. Raw now reads 1000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now comes the part I don't exactly get. You say we can now calculate the pH/V, but with what variables? I mean, -3 / 2.25 will always result in -1.33 but shouldn't there be a variable here depending on how far I actually adjusted the pot? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I now put in the formula to calculate the pH as expected it reads 4.0 for the 4.0 reference solution. But it now screws up the 7.0 solution as we adjusted the pot but didn't compensate for it as far as I see? I also tried the adjusted pH formulas but I guess those are meant for the first code we had and not this adjusted one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what am I missing between step 2 and 3 that messes up things here? Also, you state that the inverting by subtracting from 1024 is correct, but when I do that the voltage readings become minus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing I wonder about; if the pot has to be a slope, shouldn't it be a different one than the one next to it (where a linear one makes more sense)? Cause it isn't, they both read &quot;W103 / 143C&quot;. In the meantime, the vendor is kindly sending over a replacement one to ensure it's not a hardware defect somewhere. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Next update: :)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I now reverted to my original code to try the adjusted pH calculations. I used the 7.0 reference solution to calibrate again and then measured the 4.0 solution. It reads 4.1! Ok, not completely spot on but not bad either. It's a small difference which might as well come from the probe, not the most expensive one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I wonder whether we should still try to get the other approach working cause it sounds better (more scientific?) for some reason. Anyway, this is at least a whole lot better than nothing :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;USB power vs linked?&lt;/strong&gt;&#xA;Another strange thing seems to happen when I disconnect the Nano from the USB port of my laptop and instead power it via a Raspberry. I want to use I2C to send the value from the Nano to the RPi. This works, but as soon as I power the nano from the RPi (5V connected to vIn), the calculated pH value drops?&lt;/p&gt;&#xA;" OwnerUserId="14525" LastEditorUserId="14525" LastEditDate="2015-11-18T21:35:43.237" LastActivityDate="2017-09-09T08:31:19.687" Title="Using / calibrating pH sensor module" Tags="|sensors|c++|arduino-nano|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17437" PostTypeId="2" ParentId="14686" CreationDate="2015-11-02T21:47:43.290" Score="0" Body="&lt;p&gt;I think you're better off with a set-up like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;A shiny object might bounce the laser as if it were a mirror.&#xA;But we wan't to know if the laser was interrupted.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So. If we place the sensor on the other side, we can accurately say if the light reaches the sensor. Thus if there is an object between (shiny or not).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;But what if another light-source shines into my sensor? It'll think that there is no object.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We can encapsulate the sensor, so that only light from the direction of the laser can shine into it. And we can filter out other light &quot;colors&quot;.&#xA;Also the strength of the laser should be bigger as any other ambien light (not too strong also). You could even choose to make the laser pulse a specific pattern and let the sensor check if it's right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QNIRf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QNIRf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-11-02T21:47:43.290" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17438" PostTypeId="2" ParentId="17403" CreationDate="2015-11-02T21:53:16.623" Score="3" Body="&lt;p&gt;&quot;Number detection&quot; sounds like you're trying to interpret a 7-segment digital display - is that correct? One way would be to place 7 photo-detectors (times the number of digits), one per segment, on or at the face of the display. Sample the photo-detectors and create a 7-bit code representing the lit segments, into a byte. You could start with a simple lookup table that translates from code to the digit it represents. You might need to get clever about interpreting codes that shouldn't appear, but do, due, perhaps to light leakage, ambient lighting, or noise. The &quot;lit&quot; segments may only be lit for a fraction of second at a time, and only one at a time, if the display is multiplexed, so your sampling algorithm will have to take that into account. Must the display remain visible? You might need optics or optical fibers to view the segments without obstructing them.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-11-02T21:53:16.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17439" PostTypeId="2" ParentId="17428" CreationDate="2015-11-03T01:11:36.017" Score="1" Body="&lt;p&gt;Motors tend to use more current than the arduino can supply, try hooking up the motor to a different power supply than the arduino 5V. What most likely is happening, is that when the motor turns on, it alters the value of the voltage, which the temperature sensor is using to tell the arduino what the temperature is. You need to have the temperature sensor hooked up to the arduino to have the reference at the right voltage, so the motor should be on a different power supply. That should fix things.&lt;/p&gt;&#xA;" OwnerUserId="14529" LastActivityDate="2015-11-03T01:11:36.017" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17441" PostTypeId="2" ParentId="17089" CreationDate="2015-11-03T09:13:01.443" Score="0" Body="&lt;p&gt;There is a more radical alternative, that could yield even higher power savings: use the HAL sensor to trigger a monostable circuit that normally would keep the uC (and the clock source) powered off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it starts, get it to update the counter and time the monostable so that it shortly puts the rest of the system back to off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the eeprom for the counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For improved efficiency, get rid of the bootloader and start executing your application right away. If you program from the ISP interface, you do not need the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2015-11-03T09:28:39.017" LastActivityDate="2015-11-03T09:28:39.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17443" PostTypeId="1" AcceptedAnswerId="17445" CreationDate="2015-11-03T10:07:02.120" Score="1" ViewCount="3463" Body="&lt;p&gt;Im trying to use the millis() function as a replacement for the delay() function in order to debounce a mechanical button. This is for an electric drum kit I am building. Im using a teensy Arduino to send MIDI signals from the drum pads to an external music program. The mechanical button needs to be responsible for cycling through five different states which change the MIDI signal sent from each pad, thus changing the sound, as well as lighting up one of five LEDs on my drum pad so I know which state i'm in.  However I cant use delay() to debounce the button because that effects the efficiency of the drum pads, with some hits not being registered, latency etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Im trying to debug the code by just getting the LEDs to light up correctly when I press the button. This was the original code I wrote with the delay() function. This worked perfectly to debounce the button, but messed with my drum pads:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int but = 12;&#xA;int led0 = 7;&#xA;int led1 = 8;&#xA;int led2 = 9;&#xA;int led3 = 10;&#xA;int led4 = 11;&#xA;&#xA;int ledCase = 0; &#xA;int butState = 0; &#xA;int oldButState = 0; &#xA;&#xA;void setup()   {                &#xA;pinMode(led0, OUTPUT);&#xA;pinMode(led1, OUTPUT);&#xA;pinMode(led2, OUTPUT);&#xA;pinMode(led3, OUTPUT);&#xA;pinMode(led4, OUTPUT);&#xA;pinMode(but, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop()    { &#xA;&#xA;   oldButState = digitalRead(but);&#xA;   delay(10);&#xA;   butState = digitalRead(but); &#xA;&#xA;   if (butState != oldButState &amp;amp;&amp;amp; butState == LOW) {   &#xA;     ledCase += 1;  &#xA;     oldButState = butState;&#xA;   }&#xA;&#xA;   if (ledCase &amp;gt; 4) {&#xA;    ledCase = 0;&#xA;   }&#xA;&#xA;   Serial.println(ledCase);&#xA;&#xA;&#xA;switch (ledCase) {&#xA;case 0:&#xA;digitalWrite(led0, HIGH);&#xA;digitalWrite(led1, LOW);&#xA;digitalWrite(led2, LOW);&#xA;digitalWrite(led3, LOW);&#xA;digitalWrite(led4, LOW);&#xA;break;&#xA;case 1:&#xA;digitalWrite(led0, LOW);&#xA;digitalWrite(led1, HIGH);&#xA;digitalWrite(led2, LOW);&#xA;digitalWrite(led3, LOW);&#xA;digitalWrite(led4, LOW);&#xA;break;&#xA;case 2:&#xA;digitalWrite(led0, LOW);&#xA;digitalWrite(led1, LOW);&#xA;digitalWrite(led2, HIGH);&#xA;digitalWrite(led3, LOW);&#xA;digitalWrite(led4, LOW);&#xA;break;&#xA;case 3:&#xA;digitalWrite(led0, LOW);&#xA;digitalWrite(led1, LOW);&#xA;digitalWrite(led2, LOW);&#xA;digitalWrite(led3, HIGH);&#xA;digitalWrite(led4, LOW);&#xA;break;&#xA;case 4:&#xA;digitalWrite(led0, LOW);&#xA;digitalWrite(led1, LOW);&#xA;digitalWrite(led2, LOW);&#xA;digitalWrite(led3, LOW);&#xA;digitalWrite(led4, HIGH);&#xA;break;&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I tried to use to replace the delay() function, but that hasn't worked. Note I added these lines in and removed the delay section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long onTime;&#xA;unsigned long delayTime;&#xA;&#xA;void setup() {&#xA;delayTime = millis() + 10; &#xA;}&#xA;&#xA;void loop()    { &#xA;oldButState = digitalRead(but);&#xA;onTime = millis();&#xA;if (onTime &amp;gt;= delayTime) {&#xA;butState = digitalRead(but); &#xA;delayTime = millis() + 10; &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any pointers as to how I can make the millis() function work to debounce this would be would be very much appreciated, thank you :)&lt;/p&gt;&#xA;" OwnerUserId="14538" LastActivityDate="2015-12-08T23:32:06.043" Title="How to simulate delay() to debounce mechanical button using millis()?" Tags="|button|teensy|millis|midi|debounce|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17444" PostTypeId="1" CreationDate="2015-11-03T10:43:34.853" Score="3" ViewCount="1376" Body="&lt;p&gt;Is it possible to use the &lt;a href=&quot;http://www.adafruit.com/products/789&quot; rel=&quot;nofollow&quot;&gt;Adafruit PN532 NFC/RFID Controller Shield&lt;/a&gt; with the &lt;a href=&quot;http://johnny-five.io&quot; rel=&quot;nofollow&quot;&gt;Johnny Five API&lt;/a&gt;? I've searched the depths of google and I'm unable to find anything so far. If it is possible, how can I go about this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Uno with this.&lt;/p&gt;&#xA;" OwnerUserId="14540" LastActivityDate="2015-11-03T10:43:34.853" Title="Using Johnny-five API with RFID Controller Shield" Tags="|arduino-uno|shields|rfid|adafruit|johnny-five|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17445" PostTypeId="2" ParentId="17443" CreationDate="2015-11-03T11:00:41.663" Score="3" Body="&lt;p&gt;To better understand how you can do this it is good to understand first just what goes on when a button bounces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is, literally, bouncing - just like a ball when you drop it.  Due to the fact that it's either connected to ground or pulled up to +5V by the pullup resistor it's either going to be LOW or HIGH with very little time between when it's not in either state, so we can pretty much ignore the rise and fall times of the signal.  It's either connected to ground, or it's not connected to ground.  And we're only really interested in when it's connected to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More importantly we're interested in &lt;em&gt;how long&lt;/em&gt; it's been connected to ground for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By remembering the time it transitioned from HIGH to LOW and then comparing that time to the current time you can know how long it has been connected to ground.  By noticing when it's no longer connected to ground and &quot;forgetting&quot; the time you remembered you can start counting afresh with the next transition from HIGH to LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take the following diagram for instance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S2wVC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S2wVC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blue line is the state of the button.  As you can see it starts HIGH, then it gets pressed to be LOW and bounces between HIGH and LOW a number of times before it settles on being LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red line is the difference between a timestamp that is set to be equal to &lt;code&gt;millis()&lt;/code&gt; at the moment the button transitions from HIGH to LOW and the current &lt;code&gt;millis()&lt;/code&gt; value, and is ignored when the button is HIGH.  As you can see the difference between that timestamp and the current &lt;code&gt;millis()&lt;/code&gt; value steadily increases. Whenever the button bounces to the HIGH state it resets that difference, and it starts again with the next LOW transition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the button has finished bouncing there is nothing to change the state of the timestamp, so the difference keeps increasing.  Eventually that difference will pass a trigger point (the yellow line in this diagram) and at that point you can be fairly sure that the button has finished bouncing and you should react to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To translate that into some code, you may end up with something like this (untested):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Two variables to store remembered state information - the time&#xA;// of the last HIGH-LOW transition and the previous state of the&#xA;//  button.&#xA;static uint32_t debounceTime = 0;&#xA;static uint8_t buttonState = HIGH;&#xA;&#xA;// Check to see if the button has changed state&#xA;if (digitalRead(buttonPin) != buttonState) {&#xA;    // Remember the new state&#xA;    buttonState = digitalRead(buttonPin);&#xA;    // If the new state is LOW ...&#xA;    if (buttonState == LOW) {&#xA;        // ... then record the time stamp&#xA;        debounceTime = millis();&#xA;    } else {&#xA;        // ... otherwise set the time stamp to 0 for &quot;don't care&quot;.&#xA;        debounceTime = 0;&#xA;    }&#xA;}&#xA;&#xA;// If the time stamp is more than 0 and the difference between now and&#xA;// then is greater than 10ms ...&#xA;if (debounceTime &amp;gt; 0 &amp;amp;&amp;amp; (millis() - debounceTime &amp;gt; 10)) {&#xA;    // ... set the time stamp to 0 to say we have finished debouncing&#xA;    debounceTime = 0;&#xA;    // and do whatever it is you need to do.&#xA;    digitalWrite(ledPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are various tweaks and additions that could be made to that method, but that gives you the basic idea of how you split the debouncing away from the reacting, and it's the &lt;em&gt;results&lt;/em&gt; of the debouncing that you react to, not the button state itself.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-03T11:00:41.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17446" PostTypeId="1" AcceptedAnswerId="17448" CreationDate="2015-11-03T12:16:46.057" Score="0" ViewCount="674" Body="&lt;p&gt;I'm using Arduino Pro Micro (5v version) in one of my project for my car. The car's 12V +ve connected to RAW input of ProMicro and everything seems to work perfectly until I crank the ignition of my car. &#xA;Here's what actually happened, my circuit works perfectly fine when car's ignition is in ON state. However, as soon as I started my car the voltage dropped from 12v to between 9-10volt and the LG33 (SMD voltage regulator) burned out. Now, I want a good solution as what should I do now?&#xA;I have already LM2596 DC 3A Step-Down regulator. So should I use that to step-down 12v to 5v OR is there anything else I can do which might be a better solution?&lt;/p&gt;&#xA;" OwnerUserId="14542" LastActivityDate="2015-11-03T12:49:18.820" Title="Pro Micro Voltage regulator burned" Tags="|voltage-level|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17447" PostTypeId="1" CreationDate="2015-11-03T12:34:36.543" Score="1" ViewCount="1867" Body="&lt;p&gt;I'm new to Arduino and microcontroller . I want to connect my Arduino Mega to three slaves which Arduino Unos. I know that these slaves will share MISO, MOSI, and SCK lines. However, SS is unique to each slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For single slave, the SS is pin 53. So, for three slaves, which other two pins can I use as SS?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="14543" LastActivityDate="2015-11-03T13:39:50.277" Title="Arduino Mega 2560 multiple slave via SPI" Tags="|arduino-mega|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17448" PostTypeId="2" ParentId="17446" CreationDate="2015-11-03T12:49:18.820" Score="3" Body="&lt;p&gt;What happened was the ignition caused massive spikes on the 12V power. You require an automotive grade regulator that can cope with spikes in excess of around 70V or more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet is probably a car USB charger adapter since they are cheap and easy to get hold of.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-03T12:49:18.820" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17449" PostTypeId="1" CreationDate="2015-11-03T13:10:44.890" Score="2" ViewCount="456" Body="&lt;p&gt;I want to modify (extend) g_APinDescription array defined in the variant.cpp.&#xA;It is necessary for new pin addition. I want to use PB0-PB7 ports as an external interrupts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;g_APinDescription = (const PinDescription *) realloc(g_APinDescription, (103 * sizeof(const PinDescription)));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a compilation errors:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;invalid use of array with unspecified bounds&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not C expert and don't know what is wrong here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use several pins which are unconnected on the DUE.&#xA;Usual read and write is simple to implement but if I want to use the interrupts then difficulties arrive.&lt;/p&gt;&#xA;" OwnerUserId="11351" LastEditorUserId="10907" LastEditDate="2016-01-13T01:24:03.810" LastActivityDate="2016-01-13T01:24:03.810" Title="How to add new pins in the Arduino Due" Tags="|arduino-due|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17450" PostTypeId="2" ParentId="17447" CreationDate="2015-11-03T13:36:55.160" Score="2" Body="&lt;p&gt;Any you like. There's nothing magic about them, as long as you have the main SS pin as an output to ensure the SPI port is in master mode.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-03T13:36:55.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17451" PostTypeId="2" ParentId="17447" CreationDate="2015-11-03T13:39:50.277" Score="2" Body="&lt;p&gt;You can use any pin for the Slave Select. The SS pin on the Arduino is only used as SS when the arduino is an SPI slave, not (like in your case) when it's the master. The only thing you have to take care of is to not use the SS pin as an Input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just make sure the library you are using allows you to specify your own SS output pin.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-03T13:39:50.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17452" PostTypeId="2" ParentId="12402" CreationDate="2015-11-03T16:57:14.540" Score="1" Body="&lt;p&gt;The easiest way to read and write DDR SRAM would be to install it in a PC and write a serial server that allowed the Arduino to access the data by requesting it over the serial port.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now although that is possible to do, the performance probably won't be great.  So it might be worth looking into memory that interfaces over SPI or IIC, there are several ICs that you could use.  Most of them would have libraries already available and you would be looking at about £1 per 256kbits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But like it has been said above if you are looking at storing multi-GBs of data then you probably want SD cards.  If the write speed is going to be a problem then look at multiplexing the data over many SD cards.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-11-03T16:57:14.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17453" PostTypeId="1" AcceptedAnswerId="17462" CreationDate="2015-11-03T19:17:06.770" Score="2" ViewCount="1042" Body="&lt;p&gt;I have a simple set of 8 push buttons wired to a Teensy 3.2 board (which uses Arduino via Teensyduino plugin). The 8 buttons are on pins 1-8 and their common ground line (one line soldered to each of them) is on the GND pin. I have code to get any one button working that works. It's currently set to make pressing the second button type &quot;A.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to make push buttons 1 through 8 type out A,B,C...etc respectively as you press them. I've been told of two problems with my setup, the first being that copying the code for every button is a bad way to go about it and second that it's subject to bouncing issues (creates a keystroke once every 5 presses or so.) I'd also like to set this up so in the future I can write a 3rd party app that configures the keys based on the user's preference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding those needs up I'm not sure where to go next. I'm beginner enough that I'm not sure how to properly incorporate the bounce class or if that's the right way to go given the needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is a matrix the way to go or is there an elegant way to manual set each button and compensate for bounce? I'd really appreciate a small example if anyone has done this. Thanks~ Current code follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CHECK_EVERY_MS 20&#xA;#define MIN_STABLE_VALS 5&#xA;&#xA;unsigned long previousMillis;&#xA;char stableVals;&#xA;char buttonPressed;&#xA;&#xA;void setup() {&#xA;  // make pin 2 an input and turn on the &#xA;  // pullup resistor so it goes high unless&#xA;  // connected to ground:&#xA;  pinMode(2, INPUT_PULLUP);&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void  loop() {&#xA;    if ((millis() - previousMillis) &amp;gt; CHECK_EVERY_MS)&#xA;    {&#xA;        previousMillis += CHECK_EVERY_MS;&#xA;        if (digitalRead(2) != buttonPressed)&#xA;        {&#xA;            stableVals++;&#xA;            if (stableVals &amp;gt;= MIN_STABLE_VALS)&#xA;            {&#xA;                buttonPressed = !buttonPressed;&#xA;                stableVals = 0;&#xA;&#xA;                if (buttonPressed)&#xA;                {&#xA;                    //Send an ASCII 'A', &#xA;                    Keyboard.write(65);&#xA;                }&#xA;            }&#xA;        }&#xA;        else&#xA;            stableVals = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;-------&lt;/strong&gt;&#xA;&lt;strong&gt;Edit: WORKING CODE FOLLOWS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  jw - 3 Nov 2015 - Program for button debounce demo&#xA;Ref: http://arduino.stackexchange.com/questions/17453/arduino-sending-keystrokes-via-push-buttons-proper-bouncing-and-manually-settin&#xA;*/&#xA;&#xA;//--------------------------------------------------------&#xA;enum { sw0=3, sw1=4, sw2=5, sw3=6, sw4=7, sw5=8, sw6=9, sw7=10}; // Switchbutton lines&#xA;enum { nSwitches=8, bounceMillis=42}; // # of switches; debounce delay&#xA;struct ButtonStruct {&#xA;  unsigned long int bounceEnd;  // Debouncing-flag and end-time&#xA;  // Switch number, press-action, release-action, and prev reading&#xA;  byte swiNum, swiActP, swiActR, swiPrev;&#xA;};&#xA;&#xA;struct ButtonStruct buttons[nSwitches] = {&#xA;  {0, sw0, 'A'}, &#xA;  {0, sw1, 'B'}, &#xA;  {0, sw2, 'C'}, &#xA;  {0, sw3, 'D'},&#xA;  {0, sw4, 'E'},&#xA;  {0, sw5, 'F'},&#xA;  {0, sw6, 'G'},&#xA;  {0, sw7, 'H'}};&#xA;//--------------------------------------------------------&#xA;void setup() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    pinMode(buttons[i].swiNum, INPUT_PULLUP);&#xA;Keyboard.begin();&#xA;}&#xA;//--------------------------------------------------------&#xA;byte readSwitch (byte swiNum) {&#xA;  // Following inverts the pin reading (assumes pulldown = pressed)&#xA;  return 1 - digitalRead(swiNum);&#xA;}&#xA;//--------------------------------------------------------&#xA;void doAction(byte swin, char code, char action) {&#xA;  Keyboard.write(action);&#xA;}&#xA;//--------------------------------------------------------&#xA;void doButton(byte bn) {&#xA;  struct ButtonStruct *b = buttons + bn;&#xA;  if (b-&amp;gt;bounceEnd) { // Was button changing?&#xA;    // It was changing, see if debounce time is done.&#xA;      if (b-&amp;gt;bounceEnd &amp;lt; millis()) {&#xA;    b-&amp;gt;bounceEnd = 0;    // Debounce time is done, so clear flag&#xA;    // See if the change was real, or a glitch&#xA;    if (readSwitch(b-&amp;gt;swiNum) == b-&amp;gt;swiPrev) {&#xA;      // Current reading is same as trigger reading, so do it&#xA;      if (b-&amp;gt;swiPrev) {&#xA;        doAction(b-&amp;gt;swiNum, 'P', b-&amp;gt;swiActP);&#xA;      } else {&#xA;        doAction(b-&amp;gt;swiNum, 'R', b-&amp;gt;swiActR);&#xA;      }&#xA;    }&#xA;      }&#xA;  } else {  // It wasn't changing; but see if it's changing now&#xA;    if (b-&amp;gt;swiPrev != readSwitch(b-&amp;gt;swiNum)) {&#xA;      b-&amp;gt;swiPrev = readSwitch(b-&amp;gt;swiNum);&#xA;      b-&amp;gt;bounceEnd = millis()+bounceMillis; // Set the Debounce flag&#xA;    }&#xA;  }&#xA;}&#xA;//--------------------------------------------------------&#xA;long int seconds, prevSec=0;&#xA;void loop() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    doButton(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14403" LastEditorUserId="14403" LastEditDate="2015-11-04T20:16:45.670" LastActivityDate="2016-10-18T03:29:57.383" Title="Arduino sending keystrokes via push-buttons. Proper bouncing and manually setting buttons?" Tags="|usb|button|teensy|keyboard|debounce|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17454" PostTypeId="1" CreationDate="2015-11-03T22:46:47.933" Score="1" ViewCount="1393" Body="&lt;p&gt;I am using an Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a code in a c file, that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;avr/io.h&amp;gt;             /* for DDRB, PORTB, etc. */&#xA;#include &amp;lt;util/delay.h&amp;gt;         /* for _delay_ms () */&#xA;#include &amp;lt;arduino.h&amp;gt;&#xA;&#xA;&#xA;&#xA;int main(void){&#xA;  DDRB    |= ((1 &amp;lt;&amp;lt; DDB7)); // Define pin 13 as output&#xA;&#xA;  noInterrupts();&#xA;&#xA;//set timer1 interrupt at 1Hz&#xA;  TCCR1A = 0;// set entire TCCR1A register to 0&#xA;  TCCR1B = 0;// same for TCCR1B&#xA;  TCNT1  = 0;//initialize counter value to 0&#xA;  // set compare match register for 1hz increments&#xA;  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be &amp;lt;65536)&#xA;  // turn on CTC mode&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS12 and CS10 bits for 1024 prescaler&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS10);  &#xA;  // enable timer compare interrupt&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;  interrupts();&#xA;&#xA;  while(1){&#xA;        asm(&quot;nop&quot;);&#xA;  }&#xA;return 0;&#xA;}&#xA;&#xA;&#xA;&#xA;  ISR(TIMER1_COMPA_vect)          // timer compare interrupt service routine&#xA;{&#xA;  PORTB ^= ((1 &amp;lt;&amp;lt;  PB7));   // toggle LED pin&#xA;  PINB |= _BV(7);&#xA;  PINB = PINB | _BV(7);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is called from an ino file, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    extern &quot;C&quot;&#xA; {&#xA; void foo ();&#xA; }&#xA;&#xA;void setup ()&#xA;  {  &#xA;  foo ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if I set up another timer interrupt (ex Timer Interrupt 0 or 2, the blink will stop happening, for some reason...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//set timer0 interrupt at 2kHz&#xA;  TCCR0A = 0;// set entire TCCR2A register to 0&#xA;  TCCR0B = 0;// same for TCCR2B&#xA;  TCNT0  = 0;//initialize counter value to 0&#xA;  // set compare match register for 2khz increments&#xA;  OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be &amp;lt;256)&#xA;  // turn on CTC mode&#xA;  TCCR0A |= (1 &amp;lt;&amp;lt; WGM01);&#xA;  // Set CS01 and CS00 bits for 64 prescaler&#xA;  TCCR0B |= (1 &amp;lt;&amp;lt; CS01) | (1 &amp;lt;&amp;lt; CS00);   &#xA;  // enable timer compare interrupt&#xA;  TIMSK0 |= (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, the strangest part happens that if all the three (or just the same two) timer interrupts are set, and with everything defined in the INO file, it works fine...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//this code will enable all three arduino timer interrupts.&#xA;//timer0 will interrupt at 2kHz&#xA;//timer1 will interrupt at 1Hz&#xA;//timer2 will interrupt at 8kHz&#xA;&#xA;//storage variables&#xA;boolean toggle0 = 0;&#xA;boolean toggle1 = 0;&#xA;boolean toggle2 = 0;&#xA;&#xA;void setup(){&#xA;&#xA;  //set pins as outputs&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;cli();//stop interrupts&#xA;&#xA;//set timer0 interrupt at 2kHz&#xA;  TCCR0A = 0;// set entire TCCR2A register to 0&#xA;  TCCR0B = 0;// same for TCCR2B&#xA;  TCNT0  = 0;//initialize counter value to 0&#xA;  // set compare match register for 2khz increments&#xA;  OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be &amp;lt;256)&#xA;  // turn on CTC mode&#xA;  TCCR0A |= (1 &amp;lt;&amp;lt; WGM01);&#xA;  // Set CS01 and CS00 bits for 64 prescaler&#xA;  TCCR0B |= (1 &amp;lt;&amp;lt; CS01) | (1 &amp;lt;&amp;lt; CS00);   &#xA;  // enable timer compare interrupt&#xA;  TIMSK0 |= (1 &amp;lt;&amp;lt; OCIE0A);&#xA;&#xA;//set timer1 interrupt at 1Hz&#xA;  TCCR1A = 0;// set entire TCCR1A register to 0&#xA;  TCCR1B = 0;// same for TCCR1B&#xA;  TCNT1  = 0;//initialize counter value to 0&#xA;  // set compare match register for 1hz increments&#xA;  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be &amp;lt;65536)&#xA;  // turn on CTC mode&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set CS12 and CS10 bits for 1024 prescaler&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS10);  &#xA;  // enable timer compare interrupt&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;//set timer2 interrupt at 8kHz&#xA;  TCCR2A = 0;// set entire TCCR2A register to 0&#xA;  TCCR2B = 0;// same for TCCR2B&#xA;  TCNT2  = 0;//initialize counter value to 0&#xA;  // set compare match register for 8khz increments&#xA;  OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be &amp;lt;256)&#xA;  // turn on CTC mode&#xA;  TCCR2A |= (1 &amp;lt;&amp;lt; WGM21);&#xA;  // Set CS21 bit for 8 prescaler&#xA;  TCCR2B |= (1 &amp;lt;&amp;lt; CS21);   &#xA;  // enable timer compare interrupt&#xA;  TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A);&#xA;&#xA;&#xA;sei();//allow interrupts&#xA;&#xA;}//end setup&#xA;&#xA;ISR(TIMER0_COMPA_vect){//timer0 interrupt 2kHz toggles pin 8&#xA;//generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles for full wave- toggle high then toggle low)&#xA;  if (toggle0){&#xA;    digitalWrite(8,HIGH);&#xA;    toggle0 = 0;&#xA;  }&#xA;  else{&#xA;    digitalWrite(8,LOW);&#xA;    toggle0 = 1;&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)&#xA;//generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles for full wave- toggle high then toggle low)&#xA;  if (toggle1){&#xA;    digitalWrite(13,HIGH);&#xA;    toggle1 = 0;&#xA;  }&#xA;  else{&#xA;    digitalWrite(13,LOW);&#xA;    toggle1 = 1;&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER2_COMPA_vect){//timer1 interrupt 8kHz toggles pin 9&#xA;//generates pulse wave of frequency 8kHz/2 = 4kHz (takes two cycles for full wave- toggle high then toggle low)&#xA;  if (toggle2){&#xA;    digitalWrite(9,HIGH);&#xA;    toggle2 = 0;&#xA;  }&#xA;  else{&#xA;    digitalWrite(9,LOW);&#xA;    toggle2 = 1;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  //do other things here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is anybody able to explain why it works in the first case, doesn't work in the second, and in the third, it works as well?&lt;/p&gt;&#xA;" OwnerUserId="14557" LastEditorUserId="14557" LastEditDate="2015-11-03T23:00:20.793" LastActivityDate="2016-02-02T02:47:50.207" Title="Timer interrupt won't work if the ISR is not set" Tags="|programming|arduino-mega|c|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17455" PostTypeId="2" ParentId="17454" CreationDate="2015-11-03T22:56:16.620" Score="1" Body="&lt;p&gt;I found out that it's not enough to just define the interrupts, there must also be an ISR method with the compare vector...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ISR(TIMER0_COMPA_vect)          // timer compare interrupt service routine&#xA;{&#xA;  PORTB ^= ((1 &amp;lt;&amp;lt;  PB6));   // toggle LED pin&#xA;  PINB |= _BV(6);&#xA;  PINB = PINB | _BV(6);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There was no error at compile, though.&lt;/p&gt;&#xA;" OwnerUserId="14557" LastActivityDate="2015-11-03T22:56:16.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17457" PostTypeId="1" CreationDate="2015-11-04T00:25:40.247" Score="0" ViewCount="284" Body="&lt;p&gt;Basically i would like to create a horse racing game, (5 horses starting all to a point A and finishing in a random position to a point B).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did an animated GIF for you to understand it more clearly :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oOZvB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/oOZvB.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This exactly what i want to do, but in real.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of using 5 motors (one for each horse) with a string they pull where the horse is attached on it (like this : &lt;a href=&quot;https://www.youtube.com/watch?v=NjuoCS9-pCY&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=NjuoCS9-pCY&lt;/a&gt;), and to create randomness at each race, do a random speed for each motors every 1 or two seconds and then stop when each horse hit the finishing line (by pushing a sensor ?). Finally when all horses hit the finishing line, the motors goes backward and get the horses back to the start line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The horses will be tiny like 1 inch (2.5cm) and the distance from start to finish line will be like 20inch (50cm) and i need the race to last at least 5-10 sec so motors don't need to turn too fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it is the best way or if it is even possible (and how ? with what components?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been searching for solutions to my project but didn't found anything suitable yet so here i am..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you a lot for you help&lt;/p&gt;&#xA;" OwnerUserId="14559" LastActivityDate="2016-05-03T22:10:46.393" Title="Horse racing game" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17458" PostTypeId="1" AcceptedAnswerId="17460" CreationDate="2015-11-04T01:07:01.997" Score="3" ViewCount="2238" Body="&lt;p&gt;I'm working on a battery-powered data logger, using a bare Atmega 328. I'm using sleep between sensor readings, via the Narcoleptic library. Everything seems to work fine, until I connect my multimeter to check on the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The multimeter uses manual range-setting (i.e., not autoranging). If I set the multimeter to the 0-20 mA range, I can see that my idle current is about 0.250 mA, but the upper value is off-scale. If I try to get a reading on the 0-200 mA range, the circuit misbehaves, never goes into sleep, and doesn't record any data. The current stays constant somewhere around 14-20mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to do something special to accurately measure current in the range of 0.25-40+mA? Or do I need a different kind/quality of multimeter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My multimeter is a $15 digital unit from Circuit Test, model DMR-1100A. &lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="3956" LastEditDate="2015-11-04T01:50:45.197" LastActivityDate="2015-11-04T02:07:26.173" Title="Circuit doesn't work when multimeter/current meter is attached" Tags="|power|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17459" PostTypeId="2" ParentId="17458" CreationDate="2015-11-04T01:32:17.297" Score="1" Body="&lt;p&gt;If your tester has autorange function, you have to disable it, as it can interfere with normal operations by changing the internal shunt resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you configure the meter as current meter, DC, connected in series between the power supply/battery and the rest of the circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tester might give a poor reading at low current values but it shouldn't interfere(much) with the circuit itself.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-04T01:32:17.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17460" PostTypeId="2" ParentId="17458" CreationDate="2015-11-04T02:07:26.173" Score="6" Body="&lt;p&gt;Multimeters have something called a &quot;burden voltage&quot;. See this PDF: &lt;a href=&quot;http://www.eevblog.com/files/uCurrentArticle.pdf&quot; rel=&quot;noreferrer&quot;&gt;uCurrent - A professional precision current ... - EEVblog&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see Dave Jones' video: &lt;a href=&quot;https://www.youtube.com/watch?v=i069j6S80OU&quot; rel=&quot;noreferrer&quot;&gt;µCurrent&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meters measure current by dropping voltage over an internal resistor, and measuring the drop. By definition therefore, there is a voltage drop, which is the &quot;burden voltage&quot;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the circuit misbehaves, never goes into sleep, and doesn't record any data&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you put a voltmeter on the processor side of the ammeter you will probably find that the voltage going into your processor is somewhat less than you think. That would account for the misbehaving.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible approach is to crank up the voltage from your power source, checking the voltmeter to see that it reaches the expected voltage on the &lt;strong&gt;processor&lt;/strong&gt; side of the ammeter, however in a circuit which might turn on and off (ie. sleep) this voltage might jump around (depending on the current) so this should be done with caution (to not exceed the maximum processor voltage).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Or do I need a different kind/quality of multimeter?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A higher quality meter may well help - watch that video and look at the PDF to see what I am talking about. My meters (which cost more than $15) don't have this problem to the same extent.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-04T02:07:26.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17462" PostTypeId="2" ParentId="17453" CreationDate="2015-11-04T05:55:11.167" Score="1" Body="&lt;p&gt;I'm not sure what you mean by “Is a matrix the way to go”, so will ignore that question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shown below is a way of using an array of structs (one of C's ways of organizing a collection of items) to keep data for several buttons, such that it's straightforward to use one subroutine to process each button the same way, using a for-loop to call the routine for each button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each element of the array &lt;code&gt;buttons&lt;/code&gt; is a &lt;code&gt;ButtonStruct&lt;/code&gt;, and each &lt;code&gt;ButtonStruct&lt;/code&gt; contains five items: bounceEnd, swiNum, swiActP, swiActR, swiPrev, which respectively represent a debouncing-flag and end-time; a switch number [ie a pin number]; a code for action to take on a press; a code for action to take on a release; and previous state of button.  (In many special cases, some of these items will be irrelevant and you can leave them out of the &lt;code&gt;ButtonStruct&lt;/code&gt;.)  The form &lt;code&gt;b-&amp;gt;x&lt;/code&gt; that is used in the &lt;code&gt;doButton()&lt;/code&gt; routine says to access element &lt;code&gt;x&lt;/code&gt; of the struct that &lt;code&gt;b&lt;/code&gt; points to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the start of each &lt;code&gt;loop()&lt;/code&gt; pass, &lt;code&gt;doButton()&lt;/code&gt; is called once for each button.  It first tests if debouncing was underway for the button.  If so, it sees if enough time has gone by to suppose button bounce is over.  If so, it reads the button's state, and if different from previous state, does an action for whichever way the button changed.  (If the button state is unchanged after a debounce delay, the program supposes there was a glitch.)  If debouncing was not underway, the program checks if the button state is different from most recent pass.  In that case, it sets up a debounce test for the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The buttons are tested and debounced individually, as you can see in the sample output that is shown following the program.  (This program was tested on an Uno, with four independent buttons used in the test. &lt;em&gt;Edit: Made corrections to handle 32-bit overflow, 2016.10.17&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  jw - 3 Nov 2015 - Program for button debounce demo&#xA;Ref: http://arduino.stackexchange.com/questions/17453/arduino-sending-keystrokes-via-push-buttons-proper-bouncing-and-manually-settin&#xA;*/&#xA;&#xA;//--------------------------------------------------------&#xA;enum { sw0=8, sw1=9, sw2=10, sw3=11}; // Switchbutton lines&#xA;enum { nSwitches=4, bounceMillis=42}; // # of switches; debounce delay&#xA;struct ButtonStruct {&#xA;  unsigned long int bounceGo;   // Debouncing-flag and end-time&#xA;  // Switch number, press-action, release-action, and prev reading&#xA;  byte swiNum, swiActP, swiActR, swiPrev;&#xA;};&#xA;&#xA;struct ButtonStruct buttons[nSwitches] = {&#xA;  {0, sw0, 'A','a', 0}, {0, sw1, 'B','b', 0}, {0, sw2, 'C','c', 0}, {0, sw3, 'D','d', 0}};&#xA;//--------------------------------------------------------&#xA;void setup() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    pinMode(buttons[i].swiNum, INPUT_PULLUP);&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting&quot;);&#xA;}&#xA;//--------------------------------------------------------&#xA;byte readSwitch (byte swiNum) {&#xA;  // Following inverts the pin reading (assumes pulldown = pressed)&#xA;  return 1 - digitalRead(swiNum);&#xA;}&#xA;//--------------------------------------------------------&#xA;void doAction(byte swin, char code, char action) {&#xA;  Serial.print(&quot;Switch &quot;);&#xA;  Serial.print(swin);&#xA;  Serial.print(code);&#xA;  Serial.print(' ');&#xA;  Serial.print(action);&#xA;  Serial.print(&quot; at t=&quot;);&#xA;  Serial.print(millis());&#xA;  Serial.println();&#xA;}&#xA;//--------------------------------------------------------&#xA;void doButton(byte bn) {&#xA;  struct ButtonStruct *b = buttons + bn;&#xA;  if (b-&amp;gt;bounceGo) { // Was button changing?&#xA;    // It was changing, see if debounce time is done.&#xA;      if (millis() - b-&amp;gt;bounceGo &amp;gt; bounceMillis) {&#xA;    b-&amp;gt;bounceGo = 0;    // Debounce time is done, so clear flag&#xA;    // See if the change was real, or a glitch&#xA;    if (readSwitch(b-&amp;gt;swiNum) == b-&amp;gt;swiPrev) {&#xA;      // Current reading is same as trigger reading, so do it&#xA;      if (b-&amp;gt;swiPrev) {&#xA;        doAction(b-&amp;gt;swiNum, 'P', b-&amp;gt;swiActP);&#xA;      } else {&#xA;        doAction(b-&amp;gt;swiNum, 'R', b-&amp;gt;swiActR);&#xA;      }&#xA;    }&#xA;      }&#xA;  } else {  // It wasn't changing; but see if it's changing now&#xA;    if (b-&amp;gt;swiPrev != readSwitch(b-&amp;gt;swiNum)) {&#xA;      b-&amp;gt;swiPrev = readSwitch(b-&amp;gt;swiNum);&#xA;      b-&amp;gt;bounceGo = millis();   // Set the Debounce flag&#xA;    }&#xA;  }&#xA;}&#xA;//--------------------------------------------------------&#xA;long int seconds, prevSec=0;&#xA;void loop() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    doButton(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the sample output below, a P line indicates a button press, detected at given &lt;code&gt;millis()&lt;/code&gt; time, and an R line indicates a button release.   Observe, near the end, overlaps among separate button presses and releases.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting&#xA;Switch 8P A at t=2170&#xA;Switch 8R a at t=2322&#xA;Switch 9P B at t=2789&#xA;Switch 9R b at t=2969&#xA;Switch 10P C at t=3395&#xA;Switch 10R c at t=3562&#xA;Switch 11P D at t=4087&#xA;Switch 11R d at t=4260&#xA;Switch 11P D at t=6518&#xA;Switch 10P C at t=6961&#xA;Switch 8P A at t=7070&#xA;Switch 10R c at t=7112&#xA;Switch 11R d at t=7427&#xA;Switch 8R a at t=7598&#xA;Switch 10P C at t=8502&#xA;Switch 9P B at t=8642&#xA;Switch 10R c at t=8961&#xA;Switch 9R b at t=9054&#xA;Switch 9P B at t=9954&#xA;Switch 11P D at t=10073&#xA;Switch 8P A at t=10164&#xA;Switch 8R a at t=10215&#xA;Switch 9R b at t=10315&#xA;Switch 11R d at t=10354&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-10-18T03:29:57.383" LastActivityDate="2016-10-18T03:29:57.383" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17463" PostTypeId="1" CreationDate="2015-11-04T12:14:55.050" Score="-1" ViewCount="1420" Body="&lt;p&gt;I have a basic mp3 trigger with arduino uno setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trigger - &lt;a href=&quot;https://www.sparkfun.com/products/11029&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/11029&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MP3Trigger.h&amp;gt;&#xA;&#xA;//  Script Function:  RobertSonics mp3trigger (v2) paired with an Arduino UNO&#xA;//  &#xA;//  Jumper Connections:   UNO  ------  mp3trigger (v2)&#xA;//             (UNO RX)     0  ------  TX&#xA;//             (UNO TX)     1  ------  RX&#xA;//             (Ground)   GND  ------  GND&#xA;//           (+5 volts)    5v  ------  USBVCC&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;void setup(){&#xA;    Serial.begin(38400);    // Standard for mp3trigger  &#xA;    Serial.print(&quot;t&quot;);&#xA;    Serial.write(1);&#xA;    delay(50000);    &#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't get it to play any tracks. The response in the Serial monitor just says tt&lt;/p&gt;&#xA;" OwnerUserId="14572" LastActivityDate="2016-07-30T09:10:13.140" Title="Arduino UNO with Sparkfun MP3 Trigger" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17464" PostTypeId="2" ParentId="17463" CreationDate="2015-11-04T12:37:28.047" Score="1" Body="&lt;p&gt;So, from the beginning:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Have you got data on you SD card and is it is FT16 or FAT32 format?&lt;/li&gt;&#xA;&lt;li&gt;Is the MP3 status light giving any indication of life?&lt;/li&gt;&#xA;&lt;li&gt;Does the MP3 card detect when you start it up without the SD card in (One long flash).&lt;/li&gt;&#xA;&lt;li&gt;Do you have a data file named &quot;001SomethingOrOther.MP3&quot;?&lt;/li&gt;&#xA;&lt;li&gt;Have you tried the command &quot;v&quot; 0x00?&lt;/li&gt;&#xA;&lt;li&gt;Have you tried the commands &quot;S0&quot; and &quot;S1&quot;?&lt;/li&gt;&#xA;&lt;li&gt;Have you looked at the sample data on &lt;a href=&quot;http://robertsonics.com/mp3-trigger-support/&quot; rel=&quot;nofollow&quot;&gt;http://robertsonics.com/mp3-trigger-support/&lt;/a&gt;?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope that helps, an please post your finding, because mine arrives next week :)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-11-04T12:37:28.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17465" PostTypeId="1" AcceptedAnswerId="17469" CreationDate="2015-11-04T12:55:50.273" Score="1" ViewCount="6040" Body="&lt;p&gt;I'm making a control system for the heating of a plate using a PID control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the goal is to regulate the temperature of the plate by changing the power dissipated by the resistance. By using a sensor I read the temperature  of the plate and is then used as the input in the PID control. &#xA;I programmed also a signal wave square for the PWM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the thing I don't understand is what I'm exactly supposed to do with the output signal I receive. &#xA;and I cannot connect between the PWM and the PID. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code of the square signal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  pinMode(9, OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;   // phase haute&#xA;   digitalWrite(9,HIGH);&#xA;   delay(30);&#xA;   // phase basse&#xA;   digitalWrite(9,LOW);&#xA;   delay(70);&#xA;   //ton+toff = 0.1;&#xA;//   ton = 0.1*Output;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code of PID and the sensor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/********************************************************&#xA; * PID Basic Example&#xA; * Reading analog input 0 to control analog PWM output 3&#xA; ********************************************************/&#xA;&#xA;#include &amp;lt;PID_v1.h&amp;gt;&#xA;&#xA;int val; &#xA;//Define Variables we'll be connecting to&#xA;double Setpoint, Input, Output;&#xA;&#xA;//Specify the links and initial tuning parameters&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,2,5,1, DIRECT);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  //initialize the variables we're linked to&#xA;  Input = analogRead(1);&#xA;  Setpoint = 37; //temperature a reguler &#xA;&#xA;  //turn the PID on&#xA;  myPID.SetMode(AUTOMATIC);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  val = analogRead(1);&#xA;  float mv = ( val/1024.0)*5000; &#xA;  float Input = mv/10;&#xA;  myPID.Compute();&#xA;  analogWrite(3,Output);&#xA;  Serial.print(&quot;input temperature is :&quot;);&#xA;  Serial.println(Input);&#xA;  delay (1000);&#xA;//  delay(1000);&#xA;  Serial.print(&quot;output is :&quot;);&#xA;  Serial.println(Output);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="14515" LastActivityDate="2015-11-04T16:42:23.050" Title="Regulation of the temperature using PID" Tags="|arduino-uno|pid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17466" PostTypeId="1" AcceptedAnswerId="17534" CreationDate="2015-11-04T15:22:52.743" Score="0" ViewCount="372" Body="&lt;p&gt;I'm trying to use a W5100 Arduino Ethernet Shield on a ATMega2560 using avr code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There exists a library written in C, which should work &lt;a href=&quot;http://www.seanet.com/~karllunt/w5100_webserv.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.seanet.com/~karllunt/w5100_webserv.zip&lt;/a&gt; from &lt;a href=&quot;http://www.seanet.com/~karllunt/w5100_library.html&quot; rel=&quot;nofollow&quot;&gt;http://www.seanet.com/~karllunt/w5100_library.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The w5100_webserv.c should be a working example for an ATmega644p. He mentions that the four callback functions should be modified, namely my_select(), my_deselect(), my_xchg() and my_reset()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The w5100_webserv.c also contains the following definitions for SPI_PORT/DDR CS_PORT/DDR/BIT and RESET_PORT/DDR/SPI:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;*  Define the SPI port, used to exchange data with a W5100 chip.&#xA;*/&#xA;#define SPI_PORT     PORTB                /* target-specific port containing the SPI lines */&#xA;#define SPI_DDR      DDRB                /* target-specific DDR for the SPI port lines */&#xA;&#xA;#define CS_DDR        DDRD                /* target-specific DDR for chip-select */&#xA;#define CS_PORT     PORTD                /* target-specific port used as chip-select */&#xA;#define CS_BIT        2                    /* target-specific port line used as chip-select */&#xA;&#xA;#define RESET_DDR   DDRD                /* target-specific DDR for reset */&#xA;#define RESET_PORT    PORTD                /* target-specific port used for reset */&#xA;#define RESET_BIT    3                    /* target-specific port line used as reset */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've changed it to the following according to what i think the ATmega2560's datasheet specifies&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Define the SPI port, used to exchange data with a W5100 chip.&#xA; */&#xA;#define SPI_PORT     PORTB                /* target-specific port containing the SPI lines */&#xA;#define SPI_DDR      DDRB                /* target-specific DDR for the SPI port lines */&#xA;&#xA;#define CS_DDR        DDRB                /* target-specific DDR for chip-select */&#xA;#define CS_PORT     PORTB                /* target-specific port used as chip-select */&#xA;#define CS_BIT        10                  /* target-specific port line used as chip-select */&#xA;&#xA;#define RESET_DDR   DDRB                /* target-specific DDR for reset */&#xA;#define RESET_PORT    PORTB                /* target-specific port used for reset */&#xA;#define RESET_BIT    20                   /* target-specific port line used as reset */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Furthermore, in the main(), there are also specific code for the AT644p:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  * Initialize the ATmega644p SPI subsystem */&#xA;CS_PORT |= (1&amp;lt;&amp;lt;CS_BIT);                                    // pull CS pin high&#xA;CS_DDR |= (1&amp;lt;&amp;lt;CS_BIT);                                    // now make it an output&#xA;&#xA;SPI_PORT = SPI_PORT | (1&amp;lt;&amp;lt;PORTB4);                        // make sure SS is high&#xA;SPI_DDR = (1&amp;lt;&amp;lt;PORTB4)|(1&amp;lt;&amp;lt;PORTB5)|(1&amp;lt;&amp;lt;PORTB7);            // set MOSI, SCK and SS as output, others as input&#xA;SPCR = (1&amp;lt;&amp;lt;SPE)|(1&amp;lt;&amp;lt;MSTR);                                // enable SPI, master mode 0&#xA;SPSR |= (1&amp;lt;&amp;lt;SPI2X);                                        // set the clock rate fck/2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've changed it to the following according to what i think the ATmega2560's datasheet specifies&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Initialize the ATmega2560 SPI subsystem&#xA; */&#xA;CS_PORT |= CS_BIT;                                    // pull CS pin high&#xA;CS_DDR |= CS_BIT;                                    // now make it an output&#xA;&#xA;SPI_PORT = SPI_PORT | (1&amp;lt;&amp;lt;PORTB0);                        // make sure SS is high&#xA;SPI_DDR = (1&amp;lt;&amp;lt;PORTB0)|(1&amp;lt;&amp;lt;PORTB2)|(1&amp;lt;&amp;lt;PORTB1);            // set MOSI, SCK and SS as output, others as input&#xA;SPCR = (1&amp;lt;&amp;lt;SPE)|(1&amp;lt;&amp;lt;MSTR);                                // enable SPI, master mode 0&#xA;SPSR |= (1&amp;lt;&amp;lt;SPI2X);                                        // set the clock rate fck/2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lastly i've changed the my_reset() function:&#xA;    void  my_reset(void)&#xA;    {&#xA;        RESET_PORT |= RESET_BIT;                            // pull reset line high&#xA;        RESET_DDR |= RESET_BIT;                            // now make it an output&#xA;        RESET_PORT &amp;amp;=~RESET_BIT;                            // pull the line low&#xA;        _delay_ms(5);                                            // let the device reset&#xA;        RESET_PORT |= RESET_BIT;                            // done with reset, pull the line high&#xA;        _delay_ms(10);                                            // let the chip wake up&#xA;    }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure whether my changes are 100 % correct and i don't know what changes needs to be done to my_select() my_deselect and my_xchg. I hope someone can suggest som corrections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="5126" LastActivityDate="2015-11-06T14:00:13.210" Title="Arduino W5100 AVR" Tags="|ethernet|avr|spi|port-mapping|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17467" PostTypeId="1" AcceptedAnswerId="17470" CreationDate="2015-11-04T15:43:36.977" Score="1" ViewCount="551" Body="&lt;p&gt;I am making a temperature circuit with arduino.&#xA;is there any way to plot the value of the temperature in a graph using arduino?&#xA;thank you very much in advance &lt;/p&gt;&#xA;" OwnerUserId="14515" LastActivityDate="2015-11-04T17:34:52.270" Title="graph of a function Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17469" PostTypeId="2" ParentId="17465" CreationDate="2015-11-04T16:42:23.050" Score="2" Body="&lt;p&gt;A PID only has one input and one output. In your case, the input will be the temperature. The use of the arduino would be to process the raw data of the temperature sensor and relay the temperature to the PID. Depending on the make and model of the PID, there could be certain transfer protocols you must adhere to. There are most likely open source libraries that will take care of transferring the data properly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your PID is the piece of hardware that will &quot;decide&quot; when it is appropriate to turn the heater on and off, therefore it shall be responsible for driving the heater. That is what the output of the PID is responsible for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, your PID has a set point. In your case, the set point would be the desired max temperature of the plate. This set point is set and altered manually through user input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a side note, if this is a personal project or a non deliverable, I'd recommend not using a PID. Try processing and analyzing all of the data exclusively on the Arduino, as it would be a challenging and rewarding task.  &lt;/p&gt;&#xA;" OwnerUserId="14576" LastActivityDate="2015-11-04T16:42:23.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17470" PostTypeId="2" ParentId="17467" CreationDate="2015-11-04T17:34:52.270" Score="0" Body="&lt;p&gt;Yes you can use the &lt;a href=&quot;https://blog.arduino.cc/2015/11/03/arduino-ide-1-6-6-released-and-available-for-download/&quot; rel=&quot;nofollow&quot;&gt;Plot&lt;/a&gt; menu command in the new Arduino 1.6.6 or you can use the &lt;a href=&quot;http://www.visualmicro.com/post/2015/08/16/Arduino-Breakpoint-Command-Syntax-Plotting-Values-Example.aspx&quot; rel=&quot;nofollow&quot;&gt;Visual Micro debugger&lt;/a&gt; to create graphs in Visual Studio&lt;/p&gt;&#xA;" OwnerUserId="4169" LastActivityDate="2015-11-04T17:34:52.270" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17471" PostTypeId="1" AcceptedAnswerId="17473" CreationDate="2015-11-04T17:57:15.757" Score="1" ViewCount="134" Body="&lt;p&gt;I am following a DIY guide that requires me to patch two arduino core library files: &lt;code&gt;HID.cpp&lt;/code&gt; and &lt;code&gt;USBAPI.h&lt;/code&gt;. This is not really practical for many reasons. I am not a native C programmer, but I am sure there are better ways to achieve the same without messing directly with system files. How can I override system library files without modifying the originals?&lt;/p&gt;&#xA;" OwnerUserId="14578" LastActivityDate="2015-11-04T20:09:35.710" Title="Alternative to patching core library source and header files" Tags="|core-libraries|build|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17472" PostTypeId="2" ParentId="17402" CreationDate="2015-11-04T18:36:35.677" Score="4" Body="&lt;p&gt;It's unlikely that you have killed the unit as this is pretty hard to do from the data interface and your picture is typical for an LCD that has not gone through the initialization sequence.  A dead LCD driver will usually display nothing and what your picture shows is that the LCD controller itself is operating.  If anything is dead, I would suspect the I2C interface board as this would yield the same result you are seeing.  It may also be that the timing of the I2C interface is right on the edge which may explain why a long cable'd setup is working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if the initialization is not done, no other commands will work.  Note also that the initialization timing and sequence of events is ABSOLUTELY CRITICAL and missing any single step or time requirement will give the result you are showing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting at page 10 of this &lt;a href=&quot;http://www.tayloredge.com/reference/Electronics/Displays/lcdtech.pdf&quot; rel=&quot;nofollow&quot;&gt;instructional PDF&lt;/a&gt; is my favorite and the basis of my driver that I have been using since the 80's.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The driver I use works on every display I have ever hooked to it, regardless of changes in the particular project's processor clock speed because I paid strict attention to the worst case timing requirements.  If the timing of the I2C interface violates one LCD it may not violate another, i.e. one display can tolerate bad timing while another can't.  There are also issues if the LCD driver uses the busy flag or not:  Blind data transmission without reading the LCD's busy state will work if the LCD is fast enough and the driver is slow enough, otherwise 'No bueno!' plus the interface is not going to operate at its maximum speed.  When using the busy flag (Bit 7 of the interface) there is solid handshaking which confirms (Instead of &quot;Trusts&quot;) that the LCD is ready for the next cycle and allows operation right up to the limit of performance.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would suggest is that you put the interface on a logic analyzer and verify that the timing is not being violated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timing tolerances and variation between parts is like lug nuts on a car... If you car has 5 lug nuts per wheel, it will probably work with 3 or even 2 but NOT UNDER ALL CONDITIONS.  SOME LCDs will be happy with bad timing but ALL LCDs NEVER will be.&lt;/p&gt;&#xA;" OwnerUserId="14014" LastEditorUserId="14014" LastEditDate="2015-11-06T19:08:49.323" LastActivityDate="2015-11-06T19:08:49.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17473" PostTypeId="2" ParentId="17471" CreationDate="2015-11-04T20:09:35.710" Score="2" Body="&lt;p&gt;Unfortunately there &lt;em&gt;really&lt;/em&gt; isn't any way of doing that other than modifying those files. The good news is that it is perfectly viable to make the modifications under a different &quot;core&quot; and then &lt;a href=&quot;https://code.google.com/p/arduino/wiki/Platforms1&quot; rel=&quot;nofollow&quot;&gt;amend boards.txt&lt;/a&gt; with the core containing the modifications.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-04T20:09:35.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17474" PostTypeId="1" CreationDate="2015-11-04T20:20:20.077" Score="2" ViewCount="1985" Body="&lt;p&gt;I am quite new to all the arduino stuff and right now I am struggling with a Problem that seems to be easy, but I have honestly no idea how to deal with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to read the data from a gyroscop and transmit the raw values via bluetooth to another device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the arduino uno r3 (it should be quite new since I bought it yesterday), the famous MPU-6050 Gyro-GY521 and for bluetooth De-HC-06BT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could already manage to assemble everything and send the data via bluetooth. To read the data from the gyro I am using the famous library MPU6050, which comes with some examples and seems to be the de facto standard for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole script is based on the &lt;code&gt;MPU6050_DMP6&lt;/code&gt; example and utilizes a &lt;code&gt;SoftwareSerial&lt;/code&gt; to transmit the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunatly has two major issues:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It just stops to send data after some time (~2 Minutes) and a restart makes it send again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It prints &lt;code&gt;FIFO Overflow&lt;/code&gt; ~ each 20th frame, so I guess there is an ongoing failure which might stop the system.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If anybody could give some hint how to solve the »FIFO-« and »Breakdownissue« I would be very glad and I appreciate any kind of help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Ahead!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;&#xA;// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files&#xA;// for both classes must be in the include path of your project&#xA;#include &quot;I2Cdev.h&quot;&#xA;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;//#include &quot;MPU6050.h&quot; // not necessary if using MotionApps include file&#xA;&#xA;// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation&#xA;// is used in I2Cdev.h&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &quot;Wire.h&quot;&#xA;#endif&#xA;&#xA;// class default I2C address is 0x68&#xA;// specific I2C addresses may be passed as a parameter here&#xA;// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)&#xA;// AD0 high = 0x69&#xA;MPU6050 mpu;&#xA;//MPU6050 mpu(0x69); // &amp;lt;-- use for AD0 high&#xA;&#xA;//RX und TX gekreuzt vom Bluetooth board&#xA;SoftwareSerial serial2(10, 11); //RX, TX&#xA;&#xA;#define OUTPUT_READABLE_YAWPITCHROLL&#xA;&#xA;&#xA;&#xA;&#xA;//#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)&#xA;//bool blinkState = false;&#xA;&#xA;// MPU control/status vars&#xA;bool dmpReady = false;  // set true if DMP init was successful&#xA;uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU&#xA;uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)&#xA;uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)&#xA;uint16_t fifoCount;     // count of all bytes currently in FIFO&#xA;uint8_t fifoBuffer[64]; // FIFO storage buffer&#xA;&#xA;// orientation/motion vars&#xA;Quaternion q;           // [w, x, y, z]         quaternion container&#xA;VectorInt16 aa;         // [x, y, z]            accel sensor measurements&#xA;VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements&#xA;VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements&#xA;VectorFloat gravity;    // [x, y, z]            gravity vector&#xA;float euler[3];         // [psi, theta, phi]    Euler angle container&#xA;float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector&#xA;&#xA;// packet structure for InvenSense teapot demo&#xA;uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===               INTERRUPT DETECTION ROUTINE                ===&#xA;// ================================================================&#xA;&#xA;volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high&#xA;void dmpDataReady() {&#xA;    mpuInterrupt = true;&#xA;}&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===                      INITIAL SETUP                       ===&#xA;// ================================================================&#xA;&#xA;void setup() {&#xA;    // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;        Wire.begin();&#xA;        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)&#xA;    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;        Fastwire::setup(400, true);&#xA;    #endif&#xA;&#xA;    Serial.begin(115200);&#xA;    while (!Serial); // wait for Leonardo enumeration, others continue immediately&#xA;&#xA;    serial2.begin(9600);&#xA;    //serial2.println(&quot;Hello&quot;);&#xA;&#xA;&#xA;    // initialize device&#xA;    Serial.println(F(&quot;Initializing I2C devices...&quot;));&#xA;    mpu.initialize();&#xA;&#xA;    // verify connection&#xA;    Serial.println(F(&quot;Testing device connections...&quot;));&#xA;    Serial.println(mpu.testConnection() ? F(&quot;MPU6050 connection successful&quot;) : F(&quot;MPU6050 connection failed&quot;));&#xA;&#xA;&#xA;    // load and configure the DMP&#xA;    Serial.println(F(&quot;Initializing DMP...&quot;));&#xA;    devStatus = mpu.dmpInitialize();&#xA;&#xA;&#xA;    // make sure it worked (returns 0 if so)&#xA;    if (devStatus == 0) {&#xA;        // turn on the DMP, now that it's ready&#xA;        Serial.println(F(&quot;Enabling DMP...&quot;));&#xA;        mpu.setDMPEnabled(true);&#xA;&#xA;        // enable Arduino interrupt detection&#xA;        Serial.println(F(&quot;Enabling interrupt detection (Arduino external interrupt 0)...&quot;));&#xA;        attachInterrupt(0, dmpDataReady, RISING);&#xA;        mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;        // set our DMP Ready flag so the main loop() function knows it's okay to use it&#xA;        Serial.println(F(&quot;DMP ready! Waiting for first interrupt...&quot;));&#xA;        dmpReady = true;&#xA;&#xA;        // get expected DMP packet size for later comparison&#xA;        packetSize = mpu.dmpGetFIFOPacketSize();&#xA;    } else {&#xA;&#xA;        Serial.print(F(&quot;DMP Initialization failed (code &quot;));&#xA;        Serial.print(devStatus);&#xA;        Serial.println(F(&quot;)&quot;));&#xA;    }&#xA;&#xA;    // configure LED for output&#xA;    //pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;    // if programming failed, don't try to do anything&#xA;    if (!dmpReady) return;&#xA;&#xA;    // wait for MPU interrupt or extra packet(s) available&#xA;    while (!mpuInterrupt &amp;amp;&amp;amp; fifoCount &amp;lt; packetSize) {&#xA;&#xA;    }&#xA;&#xA;    // reset interrupt flag and get INT_STATUS byte&#xA;    mpuInterrupt = false;&#xA;    mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;    // get current FIFO count&#xA;    fifoCount = mpu.getFIFOCount();&#xA;&#xA;    // check for overflow (this should never happen unless our code is too inefficient)&#xA;    if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;        // reset so we can continue cleanly&#xA;        mpu.resetFIFO();&#xA;        //Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;    } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;        // wait for correct available data length, should be a VERY short wait&#xA;        while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;&#xA;        // read a packet from FIFO&#xA;        mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;&#xA;        // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;        // (this lets us immediately read more without waiting for an interrupt)&#xA;        fifoCount -= packetSize;&#xA;&#xA;        #ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;            // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;&#xA;&#xA;            serial2.print(ypr[0] * 180/M_PI);&#xA;            serial2.print(&quot;,&quot;);&#xA;            serial2.print(ypr[1] * 180/M_PI);&#xA;            serial2.print(&quot;,&quot;);&#xA;            serial2.print(ypr[2] * 180/M_PI);&#xA;            serial2.print(&quot;\n&quot;);&#xA;&#xA;        #endif&#xA;&#xA;        delay(5);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14583" LastActivityDate="2017-01-16T18:10:18.157" Title="MPU6050, Bluetooth — FIFO Overflow and Breakdown" Tags="|arduino-uno|bluetooth|mpu6050|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17476" PostTypeId="1" CreationDate="2015-11-04T22:27:15.697" Score="6" ViewCount="755" Body="&lt;p&gt;A TMP35/36/37 is giving very high voltage readings, which results in high temperature readings. The serial monitor looks like this: &lt;a href=&quot;https://i.stack.imgur.com/4RMhI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4RMhI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, the sensor value is in the 900s, voltage is almost 5, and temp is in the 400s. The circuit is very simple, just a TMP connected to 5V and ground and pin A0. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;const int sensorPin = A0;&#xA;const float baselineTemp = 20.0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorVal = analogRead(sensorPin);&#xA;  Serial.print(&quot;Sensor value: &quot;);&#xA;  Serial.print(sensorVal);&#xA;&#xA;  float voltage = (sensorVal / 1024.0) * 5.0;&#xA;  Serial.print(&quot;, volts: &quot;);&#xA;  Serial.print(voltage);&#xA;&#xA;  Serial.print(&quot;, degrees C: &quot;);&#xA;  float temperature = (voltage - .5) * 100;&#xA;  Serial.println(temperature);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a very simple program and a very simple circuit, so I'm not sure what is going on. Maybe the problem is the sensor itself. I have also tried this sensor with multiple other circuits and programs and the same thing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone knows anything about this, help would be great.&lt;/p&gt;&#xA;" OwnerUserId="13748" LastEditorUserId="13748" LastEditDate="2015-11-04T23:46:23.857" LastActivityDate="2018-06-03T02:37:02.127" Title="Why is my TMP35 giving me weird values?" Tags="|arduino-uno|sensors|temperature-sensor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17477" PostTypeId="1" AcceptedAnswerId="17504" CreationDate="2015-11-04T22:43:08.140" Score="3" ViewCount="21709" Body="&lt;p&gt;I have an Arduino Uno with a motor shield, as well as a DS1307 RTC that I am using to control 2 pumps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like to set a start time (startHour + startMinute) and end time (endHour + endMinute) for each pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had luck using &lt;code&gt;if&lt;/code&gt; statements to control my timer like below (adapted from Iain Foulds):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte startHour=8&#xA;byte startMinute=15&#xA;byte endHour= 14&#xA;byte endMinute= 20&#xA;&#xA;byte startHour2=22&#xA;byte startMinute2=30&#xA;byte endHour2= 2&#xA;byte endMinute2= 45&#xA;&#xA;void loop() {&#xA;  byte checkStartTime1() {&#xA;    DateTime now = RTC.now();&#xA;    // Read in what our current datestamp is from RTC&#xA;    if (now.hour() == startHour &amp;amp;&amp;amp; now.minute() == startMinute) {&#xA;      validStart1 = 1;&#xA;    } else {&#xA;      validStart1 = 0;&#xA;    }&#xA;    return validStart1;&#xA;    // Return the status for powering up&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But my concern is that this only checks for equivalency at the moment, and if I lost power when my start time came up my pump would not come on. So I was hoping to set up an &lt;code&gt;if&lt;/code&gt; statement that can deal with &quot;&gt;=&quot; as opposed to just &quot;==&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which I can use if I only deal with the hour section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (now.hour() &amp;gt;= startHour &amp;amp;&amp;amp; &amp;lt;= endHour)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But things get complicated when I try to add in minutes to the control structure. I end up with a series of nested for loops that do not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hoping someone can help me write an &lt;code&gt;if&lt;/code&gt; statement (or &lt;code&gt;switch case&lt;/code&gt;) that can accommodate hours and minutes. So that any time between 8:15-14:20&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;validStart1=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and anytime other time &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;validStart1=0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And please note the addition of the second set for this timer (StartHour2)- which I threw as my second pump will need to deal with the switch over past midnight.&lt;/p&gt;&#xA;" OwnerUserId="14586" LastEditorUserId="4628" LastEditDate="2018-08-21T08:05:14.000" LastActivityDate="2021-07-28T18:36:08.763" Title="Creating a timer using a Real Time Clock with start and stop times" Tags="|arduino-uno|timers|rtc|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17478" PostTypeId="2" ParentId="17477" CreationDate="2015-11-04T23:32:56.100" Score="3" Body="&lt;p&gt;What you need to do is convert the time into some standard single number and then compare those numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A popular method is to calculate the number of seconds since an &lt;em&gt;epoch&lt;/em&gt;.  An &lt;em&gt;epoch&lt;/em&gt; is an arbitrary point in time that you measure time since.  Microsoft chose 01/01/0000 for their epoch - Unix chose 01/01/1970.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Time.h library contains functions for manipulating time values - one of the functions in it can convert a full date and time specification into the number of seconds since 01/01/1970 (Unix epoch).  If you want ideas then look at the source code for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A similar approach can be used to just work on the hours and minutes within a day.  One hour is 60 minutes, so you can create a number that is the number of hours multiplied by 60 plus the number of minutes in the current hour.  That will give you the number of minutes since midnight.  You can even add in the seconds if you want even more accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have that single value it's very easy to compare it with a &lt;code&gt;&amp;gt;=&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-04T23:32:56.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17479" PostTypeId="1" AcceptedAnswerId="17484" CreationDate="2015-11-05T00:53:02.780" Score="1" ViewCount="302" Body="&lt;p&gt;I would like to know the specs of the accelerometer used on a LightBlue Bean before buying one, but I couldn't find any info online. Anybody has an idea?&lt;/p&gt;&#xA;" OwnerUserId="14588" LastActivityDate="2016-02-03T18:59:54.960" Title="Can anyone tell me about the onboard accelerometer of LightBlue Bean?" Tags="|accelerometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17480" PostTypeId="1" AcceptedAnswerId="17483" CreationDate="2015-11-05T01:51:44.513" Score="1" ViewCount="1387" Body="&lt;p&gt;I am (currently) parsing a PPM analog signal using an Arduino Uno R3 using the analog comparator ASCR and analog hardware interrupts using AIN0 and AIN1. I am applying a specific negative comparison voltage using a linear voltage regulator on AIN0 and the signal on AIN1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code snippets:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;setup&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ACSR  = B00011011;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;outside other closures&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(ANALOG_COMP_vect) {&#xA;   CRCArduinoPPMChannels::INT0ISR();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to move this project to an Arduino (compatible) &lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pro Micro from SparkFun&lt;/a&gt;. The &lt;a href=&quot;http://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/ATMega32U4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; specifies AIN0 on ATmega32u4 pin 1 but do not see a reference to AIN1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet outlines use of the analog comparator on page 289:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AIN+ can be connected either to the AIN0 (PE6) pin, or to the internal&#xA;  Bandgap reference. AIN- can only be connected to the ADC multiplexer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have connected the signal to Arduino pin 7, the comparison voltage to Arduino pin 20 (analog 2) and set the following options of the ADMUX register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ADMUX = B11000101;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The interrupts trigger but the comparator voltage (AIN-) is not being observed. Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="14589" LastEditorUserId="26916" LastEditDate="2017-09-10T00:04:17.557" LastActivityDate="2019-08-29T23:17:14.053" Title="Using Analog Comparator on ATmega32u4" Tags="|atmega32u4|digital-analog-conversion|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17481" PostTypeId="1" CreationDate="2015-11-05T02:04:14.453" Score="1" ViewCount="531" Body="&lt;p&gt;This is more of a C/C++ question. However the files I am asking about are a part of the Arduino library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;em&gt;/arduino-1.6.5-r5/hardware/arduino/avr/cores/arduino/Arduino.h&lt;/em&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef Arduino_h&#xA;#define Arduino_h&#xA;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;stdbool.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;#include &quot;binary.h&quot;&#xA;&#xA;#ifdef __cplusplus&#xA;extern &quot;C&quot;{&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How are these blocks found at compile time in the main sketch?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does &lt;code&gt;#include &amp;lt;avr/somelibrary.h&amp;gt;&lt;/code&gt; mean that this is a standard library from either &lt;em&gt;avr-g++&lt;/em&gt; or &lt;em&gt;avr-gcc&lt;/em&gt;? As opposed to a standard g++ or gcc compiler?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last question, how can there be an &lt;em&gt;Arduino.h&lt;/em&gt; without an &lt;em&gt;Arduino.c&lt;/em&gt;? I searched through the project but could not find an &lt;em&gt;Arduino.c&lt;/em&gt;. All of these are probably stupid questions, as I am in the process of learning C/C++. I am completely new to it.  &lt;/p&gt;&#xA;" OwnerUserId="13854" LastEditorUserId="37523" LastEditDate="2019-11-10T15:09:20.440" LastActivityDate="2019-11-10T15:09:20.440" Title="Question about include statements and details in Arduino.h file from core library" Tags="|uploading|core-libraries|avr-gcc|gcc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17482" PostTypeId="2" ParentId="17481" CreationDate="2015-11-05T02:11:07.913" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does &lt;code&gt;#include &amp;lt;avr/somelibrary.h&amp;gt;&lt;/code&gt; mean that this is a standard library from either &lt;em&gt;avr-g++&lt;/em&gt; or &lt;em&gt;avr-gcc&lt;/em&gt;? As opposed to a standard g++ or gcc compiler?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. It simply means that the compiler should check both its built-in include paths as well as any passed via the &lt;code&gt;-I&lt;/code&gt; command line option (or its local equivalent) for a file called &quot;avr/somelibrary.h&quot;. That AVR GCC knows where AVR Libc is located is incidental.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One last question, how can there be an &lt;em&gt;Arduino.h&lt;/em&gt; without an &lt;em&gt;Arduino.c&lt;/em&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no obligation to match each header file with a .c/.cc/.cpp file, or vice versa.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-05T02:11:07.913" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17483" PostTypeId="2" ParentId="17480" CreationDate="2015-11-05T02:27:12.203" Score="1" Body="&lt;p&gt;AIN- won't be connected to the ADC mux unless ACME is set and ADEN is cleared. Don't forget to do so.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-05T02:27:12.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17484" PostTypeId="2" ParentId="17479" CreationDate="2015-11-05T03:19:38.597" Score="1" Body="&lt;p&gt;There is a reference to the &lt;a href=&quot;http://ae-bst.resource.bosch.com/media/products/dokumente/bma250/bst-bma250-ds002-05.pdf&quot; rel=&quot;nofollow&quot;&gt;accelerometer datasheet&lt;/a&gt; from the &lt;a href=&quot;http://legacy.punchthrough.com/bean/the-arduino-reference/accelerationreading/&quot; rel=&quot;nofollow&quot;&gt;Arduino Reference page&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14589" LastActivityDate="2015-11-05T03:19:38.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17485" PostTypeId="1" CreationDate="2015-11-05T03:51:50.743" Score="1" ViewCount="4174" Body="&lt;p&gt;I am trying to plot a graph on processing but I'm having challenges going about it. The processing sketch below does work for plotting only one axis, and I'm trying to plot all three axis on the same sketch. Does anyone have an idea on how I could go about it. Below are the Arduino and Processing sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AcceleroMMA7361 ski;&#xA;int x;&#xA;int y;&#xA;int z;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(115200);&#xA;   ski.begin(13, 12,11,10, A0, A1, A2);&#xA;   ski.setARefVoltage(3.3);             &#xA;   ski.setSensitivity(HIGH);&#xA;   ski.calibrate();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    x = ski.getXRaw();&#xA;    y = ski.getYRaw();&#xA;    z = ski.getZRaw();&#xA;   //Serial.print(&quot;\nx: &quot;);&#xA;     Serial.println(x);&#xA;   //Serial.print(&quot;\ty: &quot;);&#xA;   //Serial.print(y);&#xA;   //Serial.print(&quot;\tz: &quot;);&#xA;   //Serial.print(z);&#xA;   delay(10);                                     //(make it readable)&#xA;}//End of Arduino Sketch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Processing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;&#xA;Serial myPort;        // The serial port&#xA;int xPos = 1;         // horizontal position of the graph&#xA;&#xA;float fValue;&#xA;boolean newVal = false;&#xA;&#xA;void setup () {&#xA;   size(800, 630);&#xA;   println(Serial.list());&#xA;   myPort = new Serial(this, Serial.list()[0], 115200);&#xA;   myPort.bufferUntil('\n');&#xA;   background(2);&#xA;   stroke(127, 34, 255);&#xA;}&#xA;&#xA;void draw () {&#xA;    if (newVal) {&#xA;       line(xPos, height, xPos, height - fValue);&#xA;       if (++xPos &amp;gt;= width) {&#xA;         xPos = 0;&#xA;         background(2);&#xA;       }&#xA;       newVal = false;&#xA;    }&#xA;}&#xA;&#xA;void serialEvent (Serial myPort) {&#xA;   String inString = myPort.readStringUntil('\n');&#xA;   if (inString != null) {&#xA;       inString = trim(inString);&#xA;       fValue = float(inString);&#xA;       fValue = map(fValue, 0, 1023, 0, height);&#xA;       newVal = true;&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="6936" LastEditDate="2016-03-19T01:27:25.103" LastActivityDate="2016-03-19T01:27:25.103" Title="Graph plotting on Processing from Arduino sensor data" Tags="|serial|arduino-due|sketch|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17486" PostTypeId="1" AcceptedAnswerId="17529" CreationDate="2015-11-05T04:35:35.227" Score="3" ViewCount="15804" Body="&lt;p&gt;I'm trying to plot a graph with python using the canvas widget, I'm currently sending data in from an arduino sensor sketch ..does anyone have an idea on how I can plot this graph in real time on Python using canvas. I've read up on it but I'm having problems with unpacking the x , y and z axis data and looping it to updating in real time. Below is the arduino sketch.And also the skeleton of the Tkinter canvas sketch. Thanks!!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AcceleroMMA7361 ski;&#xA;int x;&#xA;int y;&#xA;int z;&#xA;&#xA;void setup(){&#xA;    Serial.begin(115200);&#xA;    ski.begin(13, 12,11,10, A0, A1, A2);&#xA;    ski.setARefVoltage(3.3);             &#xA;    ski.setSensitivity(HIGH);&#xA;    ski.calibrate();&#xA;}&#xA;&#xA;void loop(){&#xA;    x = ski.getXRaw();&#xA;    y = ski.getYRaw();&#xA;    z = ski.getZRaw();&#xA;    Serial.print(&quot;\nx: &quot;);&#xA;    Serial.println(x);&#xA;    Serial.print(&quot;\ty: &quot;);&#xA;    Serial.print(y);&#xA;    Serial.print(&quot;\tz: &quot;);&#xA;    Serial.print(z);&#xA;    delay(10);                                     //(make it readable)&#xA;}//End of Arduino Sketch&#xA;&#xA;&#xA;&#xA;  from Tkinter import *&#xA;  import serial #import Serial Library&#xA;  import numpy as np # Import numpy&#xA;&#xA;  ardoData = serial.Serial('COM4', 115200) &#xA;  accelX1 = []     #to hold the incoming axis data from the arduino&#xA;  accelY1 = []&#xA;  accelZ1 = []&#xA;&#xA;&#xA;  class GraphException(Exception):&#xA;      def __init__(self, string):&#xA;         Exception.__init__(self, string)&#xA;&#xA;  class Smoking(Canvas):&#xA;     def __init__(self, master, FrameTitle, Col, Row, Height):&#xA;        Canvas.__init__(self, master)&#xA;          self.FrameTitle = FrameTitle&#xA;          self.x1Axis = range(1001)&#xA;          self.y1Axis = range(1001)&#xA;          self.z1Axis = range(1001)&#xA;          self.Line1 = range(1001)&#xA;          self.Line2 = range(1001)&#xA;          self.Line3 = range(1001)&#xA;          self.configure(height=Height, width=750, bg='grey', bd=3, relief=GROOVE)&#xA;         self.grid()&#xA;         self.grid_propagate(0)&#xA;         self.Col = Col&#xA;         self.Row = Row&#xA;         self.place(y=Col, x=Row)&#xA;         self.create_text(380, 20, text=self.FrameTitle, fill = 'black')&#xA;         for i in range(0, 1001):&#xA;            self.Line1[i] = self.create_line(-10+(i*10), 90, 0+(i*10), 90, fill='blue', width=0)&#xA;            self.Line2[i] = self.create_line(-10+(i*10), 90, 0+(i*10), 90, fill='red', width=0)&#xA;            self.Line3[i] = self.create_line(-10+(i*10), 90, 0+(i*10), 90, fill='yellow', width=0)&#xA;&#xA;     def LiveValues(self,accelX1, accelY1, accelZ1, Centerline = False, Dritter = False):&#xA;          for x in range(1, 59):&#xA;             for i in np.arange(1, 1001, 1): &#xA;                  while(ardoData.inWaiting() == 0):  &#xA;                      pass #do nothing&#xA;                  ardoString = ardoData.readline()              &#xA;                  dataArray = ardoString.strip().strip('\n')   #Split into an array called dataArray and strip off any spaces&#xA;                # Ensure that you are not working on empty line&#xA;               if ardoString:&#xA;                   dataArray = ardoString.split(&quot;,&quot;)&#xA;               if len(dataArray) &amp;gt; 1:&#xA;                   self.x1Axis = int(dataArray[0])&#xA;                   self.y1Axis = int(dataArray[1])&#xA;                   self.z1Axis = int(dataArray[2])&#xA;                   accelX1.append(self.x1Axis)&#xA;                   accelY1.append(self.y1Axis)&#xA;                   accelZ1.append(self.z1Axis)&#xA;              for x in range(0, 1001):&#xA;                 self.coords(self.Line1[x], -10+(x*10), self.accelX1[x], (x*10), self.accelX1[x+1])&#xA;                 self.coords(self.Line2[x], -10+(x*10), self.accelY1[x], (x*10), self.accelY1[x+1])&#xA;                 self.coords(self.Line3[x], -10+(x*10), self.accelZ1[x], (x*10), self.accelZ1[x+1])&#xA;&#xA;&#xA;   # Create and run the GUI&#xA;   root = Tk()&#xA;   app = Smoking(root, &quot;Smooth Sailing&quot;, 1000, 1000, 1000)&#xA;   app.mainloop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after working with the answer given on the post I ended up with a Line graph that is not reactive, I understand that I have to tweak the code to suit the range of values I am getting which is shown below. I increased the limit as indicated by @patthoyts but I still couldn't get either lines to show up on the canvas and to even be reactive ( what i mean by that is to respond to the movement of the sensor). Also, do bear with me Editors!, if I'm going about editing this question the wrong way, is just that I'm quite desperate to have this issue resolved. Does anyone have any clue as to how I could resolve this issue. Thanks PS: I added both images , that of my data stream and the image on the canvas. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/V5pdE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V5pdE.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xKX47.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xKX47.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="14350" LastEditDate="2015-11-12T00:18:22.047" LastActivityDate="2020-05-21T10:19:11.560" Title="Graph plotting on Python using Tkinter Canvas" Tags="|serial|programming|arduino-due|python|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17490" PostTypeId="1" CreationDate="2015-11-05T09:26:40.810" Score="0" ViewCount="441" Body="&lt;p&gt;I posted this also at &lt;a href=&quot;https://stackoverflow.com/questions/33540095/johnny-five-lcd-black-boxes-only&quot;&gt;Stack Overflow&lt;/a&gt;. I have tested the Johnny Five LED example on my Arduino Uno, and it worked fine. Now I need to test Johnny Five &lt;strong&gt;LCD&lt;/strong&gt;. I connected all wires correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8a9mJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8a9mJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var five = require(&quot;johnny-five&quot;), board, lcd;&#xA;&#xA;board = new five.Board();&#xA;board.on(&quot;ready&quot;, function() {&#xA;  lcd = new five.LCD({&#xA;    // LCD pin name  RS  EN  DB4 DB5 DB6 DB7&#xA;    // Arduino pin # 7    8   9   10  11  12&#xA;    pins: [7, 8, 9, 10, 11, 12],&#xA;    backlight: 6,&#xA;    rows: 2,&#xA;    cols: 20&#xA;    // Options:&#xA;    // bitMode: 4 or 8, defaults to 4&#xA;    // lines: number of lines, defaults to 2&#xA;    // dots: matrix dimensions, defaults to &quot;5x8&quot;&#xA;  });&#xA;&#xA;  // Tell the LCD you will use these characters:&#xA;  lcd.useChar(&quot;check&quot;);&#xA;  lcd.useChar(&quot;heart&quot;);&#xA;  lcd.useChar(&quot;duck&quot;);&#xA;&#xA;  // Line 1: Hi rmurphey &amp;amp; hgstrp!&#xA;  lcd.clear().print(&quot;rmurphey, hgstrp&quot;);&#xA;  lcd.cursor(1, 0);&#xA;&#xA;  // Line 2: I &amp;lt;3 johnny-five&#xA;  // lcd.print(&quot;I&quot;).write(7).print(&quot; johnny-five&quot;);&#xA;  // can now be written as:&#xA;  lcd.print(&quot;I :heart: johnny-five&quot;);&#xA;&#xA;  this.wait(3000, function() {&#xA;    lcd.clear().cursor(0, 0).print(&quot;I :check::heart: 2 :duck: :)&quot;);&#xA;  });&#xA;&#xA;  this.repl.inject({&#xA;    lcd: lcd&#xA;  });&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it doesn't output as expected. It is showing one row of black boxes only. what have I missed?&lt;/p&gt;&#xA;" OwnerUserId="14593" LastEditorUserId="4628" LastEditDate="2017-12-31T04:55:13.650" LastActivityDate="2017-12-31T04:55:13.650" Title="Johnny Five LCD: black boxes only" Tags="|arduino-uno|johnny-five|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17492" PostTypeId="2" ParentId="17477" CreationDate="2015-11-05T09:59:13.207" Score="1" Body="&lt;pre&gt;&lt;code&gt;byte startHour=8&#xA;byte startMinute=15&#xA;byte endHour= 14&#xA;byte endMinute= 20&#xA;&#xA;byte startHour2=22&#xA;byte startMinute2=30&#xA;byte endHour2= 2&#xA;byte endMinute2= 45&#xA;&#xA;void loop()&#xA;{&#xA;  DateTime now = RTC.now();  // Read in what our current datestamp is from RTC&#xA;&#xA;  if (&#xA;    ( (now.hour()==startHour &amp;amp;&amp;amp; now.minute()&amp;gt;= startMinute) || (now.hour()&amp;gt;startHour)&#xA;    &amp;amp;&amp;amp; ( (now.hour()==endHour &amp;amp;&amp;amp; now.minute()&amp;lt; endMinute) || (now.hour()&amp;lt;endHour) ) {&#xA;    validStart1 = 1;  &#xA;&#xA;  } else {&#xA;    validStart1 = 0;  // &#xA;  }&#xA;&#xA;return validStart1; // Return the status for powering up&#xA; } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-05T09:59:13.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17493" PostTypeId="1" CreationDate="2015-11-05T11:11:20.370" Score="1" ViewCount="17605" Body="&lt;p&gt;I installed the new IDE Environment 1.6.6 and I got this error when compiling a program. I am using an Arduino Uno&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\COM4&quot;: access denied&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need your help.&lt;/p&gt;&#xA;" OwnerUserId="14515" LastEditorUserId="6936" LastEditDate="2016-02-21T08:03:22.473" LastActivityDate="2018-01-09T22:58:55.657" Title="avrdude: ser_open(): can't open device &quot;\\.\COM4&quot;: Access denied" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ClosedDate="2018-01-10T11:45:16.767" ContentLicense="CC BY-SA 3.0" />
  <row Id="17494" PostTypeId="1" CreationDate="2015-11-05T13:13:50.813" Score="2" ViewCount="812" Body="&lt;p&gt;I am using a &lt;a href=&quot;http://redbearlab.com/blendmicro/&quot; rel=&quot;nofollow&quot;&gt;blend micro board&lt;/a&gt;, where the digital pins 4, 6 and 7 are reserved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected a MPU6050 which uses the I2C protocol, so there is the need for the i2cdev lib to handle that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example I am using tells me to use pin 7 as int pin for the mpu6050, but that is not possible, since it is reserved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know how I could set this Pin to some other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Ahead!&lt;/p&gt;&#xA;" OwnerUserId="14583" LastEditorUserId="2881" LastEditDate="2015-11-05T13:45:22.670" LastActivityDate="2015-11-05T13:45:22.670" Title="I2C — set int pin" Tags="|i2c|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17495" PostTypeId="1" CreationDate="2015-11-05T13:57:58.840" Score="2" ViewCount="140" Body="&lt;p&gt;In my board I need to use PB0-PB7 ports as an external interrupt sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I spent a lot of time to understand that. Seems the easiest way is to update variant.cpp file by adding these pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately this is not the solution I'm looking for (actually this can be a solution if I'm able to add pins from the sketch, but it is not possible to update cons dynamic array after declaration ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is to create my own interrupt handler. But I didn't find how should I do that.&lt;/p&gt;&#xA;" OwnerUserId="11351" LastEditorUserId="14766" LastEditDate="2015-11-13T18:44:26.643" LastActivityDate="2015-11-13T18:44:26.643" Title="How to use Due PB0-PB7 pins as an external interrupt" Tags="|arduino-due|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17496" PostTypeId="2" ParentId="10400" CreationDate="2015-11-05T14:04:02.317" Score="1" Body="&lt;p&gt;Hi a bit late but I thought it could be useful to someone, I successed to train SD  commands without pc easyvr commander with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ARDUINO 1.6.6&#xA;// EasyVR Shield 2.0&#xA;// EasyVR library v1.7&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#if !defined(SERIAL_PORT_MONITOR)&#xA;#error &quot;Arduino version not supported. Please update your IDE to the latest version.&quot;&#xA;#endif&#xA;&#xA;#define pcSerial SERIAL_PORT_MONITOR&#xA;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;SoftwareSerial port(12, 13);&#xA;&#xA;#include &quot;EasyVR.h&quot;&#xA;EasyVR easyvr(port);&#xA;&#xA;//&#xA;&#xA;char label[33];&#xA;uint8_t data;&#xA;&#xA;bool train = false;&#xA;bool recog = false;&#xA;&#xA;int8_t group = EasyVR::PASSWORD;&#xA;int8_t index = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pcSerial.begin(9600);&#xA;  port.begin(9600);&#xA;&#xA;  while (!easyvr.detect())&#xA;  {&#xA;    pcSerial.println(F(&quot;EasyVR not detected!&quot;));&#xA;    delay(1000);&#xA;  }&#xA;&#xA;  //&#xA;&#xA;  easyvr.setPinOutput(EasyVR::IO1, LOW);&#xA;  pcSerial.print(F(&quot;EasyVR detected, version &quot;));&#xA;  pcSerial.println(easyvr.getID());&#xA;  easyvr.setTimeout(5);&#xA;  //  easyvr.setLevel(EasyVR::HARD);&#xA;&#xA;  //&#xA;&#xA;  printCommands();&#xA;}&#xA;&#xA;void printCommands()&#xA;{&#xA;  pcSerial.print(F(&quot;Password: &quot;));&#xA;  int16_t count = easyvr.getCommandCount(group);&#xA;  pcSerial.print(count);&#xA;  pcSerial.println(F(&quot; command(s)&quot;));&#xA;  for (int8_t idx = 0; idx &amp;lt; count; ++idx) {&#xA;    if (easyvr.dumpCommand(group, idx, label, data)) {&#xA;      pcSerial.print(idx);&#xA;      pcSerial.print(F(&quot; = &quot;));&#xA;      pcSerial.print(label);&#xA;      pcSerial.print(F(&quot;, Trained &quot;));&#xA;      pcSerial.print(data, DEC);&#xA;      if (!easyvr.isConflict()) pcSerial.println(F(&quot; times, OK&quot;));&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;bool checkMonitorInput()&#xA;{&#xA;  if (pcSerial.available() &amp;lt;= 0) return false;&#xA;&#xA;  int16_t rx = pcSerial.read();&#xA;  //  pcSerial.print(rx);&#xA;&#xA;  if (rx == 's')&#xA;  {&#xA;    easyvr.removeCommand(group, index);&#xA;    easyvr.addCommand(group, index);&#xA;    easyvr.setCommandLabel(group, index, &quot;cuss&quot;);&#xA;&#xA;    printCommands();&#xA;  }&#xA;&#xA;  if (rx == 't')&#xA;  {&#xA;    recog = false;&#xA;    pcSerial.print(&quot;say something&quot;);&#xA;    train = true;&#xA;  }&#xA;&#xA;  if (rx == 'r')&#xA;  {&#xA;    train = false;&#xA;    pcSerial.print(&quot;start recognition&quot;);&#xA;    recog = true;&#xA;  }&#xA;&#xA;  //&#xA;&#xA;  if (rx &amp;gt;= 0)&#xA;  {&#xA;    easyvr.stop();&#xA;    pcSerial.flush();&#xA;    return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  checkMonitorInput();&#xA;&#xA;  if (train) {&#xA;    pcSerial.println(&quot;Train a word&quot;);&#xA;    easyvr.trainCommand(group, index);&#xA;  }&#xA;&#xA;  if (recog) {&#xA;    pcSerial.println(&quot;Say the word&quot;);&#xA;    easyvr.recognizeCommand(group);&#xA;  }&#xA;&#xA;  //&#xA;&#xA;  do {&#xA;    if (checkMonitorInput()) return;&#xA;  }&#xA;  while (!easyvr.hasFinished());&#xA;&#xA;  //&#xA;&#xA;  int16_t idx = easyvr.getCommand();&#xA;  if (idx &amp;gt;= 0) {&#xA;    if (easyvr.dumpCommand(EasyVR::PASSWORD, idx, label, data)) {&#xA;      pcSerial.print(&quot;recognized = &quot;);&#xA;      pcSerial.println(label);&#xA;    }&#xA;    easyvr.playSound(0, EasyVR::VOL_FULL);&#xA;&#xA;  } else {&#xA;    if (easyvr.isTimeout()) pcSerial.println(&quot;Timed out, try again...&quot;);&#xA;    int16_t err = easyvr.getError();&#xA;    if (err &amp;gt;= 0) {&#xA;      pcSerial.print(&quot;Error 0x&quot;);&#xA;      pcSerial.println(err, HEX);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14574" LastActivityDate="2015-11-05T14:04:02.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17497" PostTypeId="1" AcceptedAnswerId="23581" CreationDate="2015-11-05T15:55:18.153" Score="0" ViewCount="1521" Body="&lt;p&gt;I'd like to build a LED lighting for my house. I've made preliminary tests and I've realized that my 12V transformer emits a considerable electric hum at the Arduino's PWM frequency range (PWM signal from Arduino gets amplified by external amplifier powered by the transformer). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know, that I can reduce the audible noise if I will drive the PWM at higher frequency, beyond the human ear's audible range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK Arduino itself is not able to give me 8-bit PWM at the &gt;20kHz range. Do you know any feasible hardware high frequency PWMs that will work with the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="7329" LastActivityDate="2016-04-26T15:53:32.000" Title="How to build a high-frequency (&gt;20kHz) driver for LEDs?" Tags="|led|pwm|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17498" PostTypeId="1" AcceptedAnswerId="17503" CreationDate="2015-11-05T16:09:06.967" Score="0" ViewCount="727" Body="&lt;p&gt;I'm trying to control three relays with the Arduino Uno rev3 and a HC-05 bluetooth module from Elecfreaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've wrote this code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the comments are the part of the code that I use to replace the Serial by default to be able to use the HC-05 module &#xA;//#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;int relay1 = 2;&#xA;int relay2 = 3;&#xA;int relay3 = 4;&#xA;int relay1estatus = 0;&#xA;int relay2estatus = 0;&#xA;int relay3estatus = 0;&#xA;char command;&#xA;//SoftwareSerial bluetooth(5,6);&#xA;&#xA;void setup() {&#xA; Serial.begin(9600); //bluetooth.begin(9600);&#xA; pinMode(relay1, OUTPUT);&#xA; pinMode(relay2, OUTPUT);&#xA; pinMode(relay3, OUTPUT);&#xA; digitalWrite(relay1, LOW);&#xA; digitalWrite(relay2, LOW);&#xA; digitalWrite(relay3, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA; while(Serial.available() &amp;gt; 0){ //bluetooth.available()&#xA;  command = (byte)Serial.read(); //(byte)bluetooth.read();&#xA;  Serial.println(command); //bluetooth.println(command)&#xA;&#xA;  if (command == 'a'){&#xA;   if (relay1estatus == 0){&#xA;    digitalWrite(relay1, HIGH);&#xA;    relay1estatus = 1;&#xA;   }else{&#xA;    digitalWrite(relay1, LOW);&#xA;    relay1estatus = 0;&#xA;   }&#xA;  }&#xA;&#xA; if (command == 'b'){ &#xA;  if (relay2estatus == 0){&#xA;   digitalWrite(relay2, HIGH);&#xA;   relay2estatus = 1;&#xA;  }else{&#xA;   digitalWrite(relay2, LOW);&#xA;   relay2estatus = 0;&#xA;  }&#xA; }&#xA;&#xA; if (command == 'c'){&#xA;  if (relay3estatus == 0){&#xA;   digitalWrite(relay3, HIGH);&#xA;   relay3estatus = 1;&#xA;  }else{&#xA;   digitalWrite(relay3, LOW);&#xA;   relay3estatus = 0;&#xA;   }&#xA;  }&#xA; }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that this code works perfectly using the Arduino IDE serial monitor, but when I try it using instead of the default serial methods, the SoftwareSerial ones it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doesn't work in a very strange way because I can switch one by one the relays between on or off but, when I have two of them activated seems like freezes, I can't switch the third one on or off and neither I can switch the other two again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To send the 'commands' through bluetooth I use the Bluetooth Terminal app available in the PlayStore.&#xA;(I've just posted the same question in stackoverflow but now I think here's the best place to ask it)&lt;/p&gt;&#xA;" OwnerUserId="14600" LastActivityDate="2015-11-05T18:42:09.600" Title="Having problems with HC-05 and three relays" Tags="|bluetooth|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17499" PostTypeId="1" CreationDate="2015-11-05T16:43:20.113" Score="0" ViewCount="1845" Body="&lt;p&gt;I am working on esp8266 with Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected pins like arduino-esp 3.3-vcc&#xA;gnd-gnd 3.3-CH_PD RX-TX TX-RX  and reset to gnd using 3k resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't send AT commands in serial monitor in Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later I connected a capacitor between Vcc and Gnd. Now I could send AT commands and I am getting same commands back. Whatever I entered, I am getting the same back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't get reply as OK. And I got some random characters too. Can anyone help me with this?&lt;/p&gt;&#xA;" OwnerUserId="14603" LastEditorUserId="14766" LastEditDate="2015-11-13T18:44:22.420" LastActivityDate="2017-09-13T09:07:53.860" Title="Error in sending AT commands in esp8266 connecting to arduino IDE" Tags="|esp8266|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17500" PostTypeId="2" ParentId="13189" CreationDate="2015-11-05T16:46:57.913" Score="2" Body="&lt;p&gt;I was having similar problem (but not the same ) &#xA;And it was due to software serial pins which keep on filling the buffers of MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some times it happen that pwm pins keep on receiving data e.g. GPS also keep filling the buffer and due to that arduino freeze .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this problem I open new dummy software serial port.( select any pins which is free ) and do listen to your software serial pins when you want to read it otherwise make dummy listen.&lt;/p&gt;&#xA;" OwnerUserId="14130" LastEditorUserId="220" LastEditDate="2015-11-05T23:31:14.907" LastActivityDate="2015-11-05T23:31:14.907" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17501" PostTypeId="2" ParentId="17499" CreationDate="2015-11-05T17:02:00.993" Score="1" Body="&lt;p&gt;Looks like your connection is somewhere missing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect CH_PD and reset pin to high--i.e. 3.3v.&lt;/p&gt;&#xA;" OwnerUserId="14130" LastEditorUserId="220" LastEditDate="2015-11-05T23:30:10.260" LastActivityDate="2015-11-05T23:30:10.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17503" PostTypeId="2" ParentId="17498" CreationDate="2015-11-05T18:42:09.600" Score="0" Body="&lt;p&gt;I don't see a problem with the code indicated for bluetooth; if that code is indeed ok, then probably you should look for hardware issues;  first, look for low +5V when multiple relays are turned on.  (Attach a voltmeter or a scope to +5, see if it changes when a second relay comes on, etc.)  Second, look (with a storage scope) for glitches when the relays switch.  If you don't have a storage scope, try testing with a separate power supply for the relays.  (Tie the grounds of things together, but give the Arduino and the HC-05 +V that's isolated from relay +V.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More seriously, your code is overweight.  For example, replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (relay1estatus == 0){&#xA;    digitalWrite(relay1, HIGH);&#xA;    relay1estatus = 1;&#xA;   } else {&#xA;    digitalWrite(relay1, LOW);&#xA;    relay1estatus = 0;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    relay1estatus = 1 - relay1estatus;&#xA;    digitalWrite(relay1, relay1estatus);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-05T18:42:09.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17504" PostTypeId="2" ParentId="17477" CreationDate="2015-11-05T19:33:04.383" Score="5" Body="&lt;p&gt;I had a similar problem when i tried to control some heating source here at home.This was how I made my steps to get it working.&#xA;First I will assume you are using the library time.h and DS1307RTC.h (check here for info: &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_Time.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_libs_Time.html&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that you will need 3 variables of the type tmElements_t.&#xA;tm will store your current time( the one you get from DS1307). The other two are auxiliary for defining time you start and time you stop the pump.&#xA;In similar way, you will need 3 variables of type time_t for the same reasons.&#xA;time_t variables store a the timestamps since 01/01/1970 (Unix epoch) which are easier to work with but tmElements structures are more human friendly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tmElements_t tm, tm_hour_start, tm_hour_end;&#xA;time_t now, t_hour_start, t_hour_end;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in your loop you need to get the current time from rtc:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time_t now = RTC.get();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after, use the breaktime funtion to convert the timestamp value to tmElements struture:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;breakTime(now, tm);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next step is to copy contents of tm to the other auxiliary structures, use the memcpy function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(&amp;amp;tm_hour_start, &amp;amp;tm, sizeof(tm));&#xA;memcpy(&amp;amp;tm_hour_end, &amp;amp;tm, sizeof(tm));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after, change the the auxiliaries vars to meet your correct schedule of start and stop (are seconds important? if so, do similar way):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tm_hour_start.Hour = startHour;&#xA;tm_hour_start.Minute = startMinute;&#xA;tm_hour_start.Second = 0;&#xA;tm_hour_end.Hour = endHour;&#xA;tm_hour_end.Minute = endMinute;&#xA;tm_hour_end.Second = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ok, we have the more human friendly start and end structures, lets get the timestamps from them. To do soo we use the makeTime function that converts tmElements_t structures to time_t:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t_hour_start = makeTime(tm_hour_start);&#xA;t_hour_end = makeTime(tm_hour_end);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you need to do now, is check if your current timestamp (now) is between this newly created timestamps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((t_hour_start &amp;lt;= now) &amp;amp;&amp;amp; (now &amp;lt;= t_hour_end)){&#xA;   //do something is soo...&#xA;}else{&#xA;   // do something if not...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra tip:&lt;/strong&gt; In case your stop hour goes past midnight, add one more day to the timestamp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (startHour &amp;gt; endHour) //past midnight correction&#xA;   t_hour_end = t_hour_end + SECS_PER_DAY;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;clean code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;time.h&amp;gt;&#xA;#include &amp;lt;DS1307RTC.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;// other includes etc...&#xA;&#xA;byte startHour=8&#xA;byte startMinute=15&#xA;byte endHour= 14&#xA;byte endMinute= 20&#xA;&#xA;tmElements_t tm, tm_hour_start, tm_hour_end;&#xA;time_t now, t_hour_start, t_hour_end;&#xA;&#xA;// setup function and other needed things...    &#xA;&#xA;void loop(){&#xA;  //get current timestamp&#xA;  time_t now = RTC.get();&#xA;  // make current date and time structure&#xA;  breakTime(now, tm);&#xA;  // make auxiliary structures to be more human editable and friendly&#xA;  memcpy(&amp;amp;tm_hour_start, &amp;amp;tm, sizeof(tm));&#xA;  memcpy(&amp;amp;tm_hour_end, &amp;amp;tm, sizeof(tm));&#xA;  // change auxiliary structures to meet your start and end schedule &#xA;  tm_hour_start.Hour = startHour;&#xA;  tm_hour_start.Minute = startMinute;&#xA;  tm_hour_start.Second = 0;&#xA;  tm_hour_end.Hour = endHour;&#xA;  tm_hour_end.Minute = endMinute;&#xA;  tm_hour_end.Second = 0;&#xA;  // reverse process to get timestamps&#xA;  t_hour_start = makeTime(tm_hour_start);&#xA;  t_hour_end = makeTime(tm_hour_end);&#xA;  // check if end time is past midnight and correct if needed&#xA;  if (startHour &amp;gt; endHour) //past midnight correction&#xA;       t_hour_end = t_hour_end + SECS_PER_DAY;&#xA;&#xA;  //final part   &#xA;  if ((t_hour_start &amp;lt;= now) &amp;amp;&amp;amp; (now &amp;lt;= t_hour_end)){&#xA;          //do something is soo...&#xA;  }else{&#xA;          // do something if not...&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; to correct the thing about midnight checks spotted in comments. New code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;DS1307RTC.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;// other includes etc...&#xA;&#xA;byte startHour = 8;&#xA;byte startMinute = 15;&#xA;byte endHour = 14;&#xA;byte endMinute = 20;&#xA;&#xA;tmElements_t tm, tm_hour_start, tm_hour_end;&#xA;time_t now_, t_hour_start, t_hour_end;&#xA;boolean update_tm = 1;&#xA;&#xA;&#xA;&#xA;// setup function and other needed things...    &#xA;void setup(){};&#xA;&#xA;void loop(){&#xA;  //get current timestamp&#xA;  time_t now_ = RTC.get();&#xA;  // make current date and time structure&#xA;  breakTime(now_, tm);&#xA;  // make auxiliary structures to be more human editable and friendly&#xA;  if(update_tm){&#xA;    memcpy(&amp;amp;tm_hour_start, &amp;amp;tm, sizeof(tm));&#xA;    memcpy(&amp;amp;tm_hour_end, &amp;amp;tm, sizeof(tm));&#xA;    // change auxiliary structures to meet your start and end schedule &#xA;    tm_hour_start.Hour = startHour;&#xA;    tm_hour_start.Minute = startMinute;&#xA;    tm_hour_start.Second = 0;&#xA;    tm_hour_end.Hour = endHour;&#xA;    tm_hour_end.Minute = endMinute;&#xA;    tm_hour_end.Second = 0;&#xA;    // reverse process to get timestamps&#xA;    t_hour_start = makeTime(tm_hour_start);&#xA;    t_hour_end = makeTime(tm_hour_end);&#xA;&#xA;    // check if end time is past midnight and correct if needed&#xA;    if (startHour &amp;gt; endHour) //past midnight correction&#xA;      t_hour_end = t_hour_end + SECS_PER_DAY;&#xA;  }&#xA;  //final part   &#xA;  if ((t_hour_start &amp;lt;= now_) &amp;amp;&amp;amp; (now_ &amp;lt;= t_hour_end)){&#xA;    /* if we got a valid schedule, don't change the tm_hour structures and the &#xA;    respective t_hour_start and t_hour_end timestamps. They should be updated &#xA;    after exiting the valid schedule */&#xA;    if(update_tm)  &#xA;      update_tm = 0;&#xA;&#xA;    //do something is soo...&#xA;  }else{&#xA;    if(update_tm == 0)  &#xA;      update_tm = 1;&#xA;    // do something if not...&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2015-11-08T15:06:14.860" LastActivityDate="2015-11-08T15:06:14.860" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17505" PostTypeId="2" ParentId="17497" CreationDate="2015-11-05T20:00:03.653" Score="2" Body="&lt;p&gt;Just change the timer prescaler to a lower value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. timer2 (PWM pins 3 and 11) has the prescaler set to clock/64 and runs at around 500Hz. So changing it to clock/8 will result in 4kHz. (Sorry, no clock/16 available).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR2 &amp;amp;= ~_BV(CS22);//clear CS22 bit&#xA;TCCR2 |= _BV(CS21);//set CS21 bit&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-05T20:00:03.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17506" PostTypeId="1" CreationDate="2015-11-05T20:16:14.857" Score="1" ViewCount="7553" Body="&lt;p&gt;I cant seem to find this error is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elevator_bug_2.ino:38:1: error: expected unqualified-id before ‘if’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// these constants won't change. They are the&#xA;// lowest and highest readings you get from your sensor:&#xA;const int sensorMin = 0;      // sensor minimum, discovered through experiment&#xA;const int sensorMax = 600;    // sensor maximum, discovered through experiment&#xA;&#xA;void setup() {&#xA;  // initialize serial communication:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the sensor:&#xA;  int sensorReading = analogRead(A0);&#xA;  // map the sensor range to a range of four options:&#xA;  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);&#xA;&#xA;  // do something different depending on the&#xA;  // range value:&#xA;  switch (range) {&#xA;    case 0:    // your hand is on the sensor&#xA;      Serial.println(&quot;dark&quot;);&#xA;      break;&#xA;    case 1:    // your hand is close to the sensor&#xA;      Serial.println(&quot;dim&quot;);&#xA;      break;&#xA;    case 2:    // your hand is a few inches from the sensor&#xA;      Serial.println(&quot;medium&quot;);&#xA;      break;&#xA;    case 3:    // your hand is nowhere near the sensor&#xA;      Serial.println(&quot;bright&quot;);&#xA;      break;&#xA;  }&#xA;  delay(1);        // delay in between reads for stability&#xA;}&#xA;&#xA;if (Serial.println(&quot;dark&quot;) == true)   // LINE 38&#xA;{&#xA;&#xA;&#xA;int led = 9;           // the PWM pin the LED is attached to&#xA;int brightness = 0;    // how bright the LED is&#xA;int fadeAmount = 5;    // how many points to fade the LED by&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  // declare pin 9 to be an output:&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  // set the brightness of pin 9:&#xA;  analogWrite(led, brightness);&#xA;&#xA;  // change the brightness for next time through the loop:&#xA;  brightness = brightness + fadeAmount;&#xA;&#xA;  // reverse the direction of the fading at the ends of the fade:&#xA;  if (brightness == 0 || brightness == 255) {&#xA;    fadeAmount = -fadeAmount ;&#xA;  }&#xA;  // wait for 30 milliseconds to see the dimming effect&#xA;  delay(30);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user14609" LastEditorUserId="10794" LastEditDate="2015-11-06T06:14:05.897" LastActivityDate="2018-02-02T02:53:15.333" Title="Error in my Arduino code &quot; error: expected unqualified-id before ‘if’ &quot;" Tags="|programming|c++|c|" AnswerCount="2" CommentCount="1" ClosedDate="2023-02-27T16:28:18.117" ContentLicense="CC BY-SA 3.0" />
  <row Id="17507" PostTypeId="2" ParentId="17506" CreationDate="2015-11-05T20:38:10.003" Score="2" Body="&lt;p&gt;C is procedural language and code is compiled. You cannot put code beyond procedure as you try to do in mentioned &lt;code&gt;if&lt;/code&gt;. Remaining code following this point is nonsense. Do you mean you can put second &lt;code&gt;loop()&lt;/code&gt; based on &lt;code&gt;if&lt;/code&gt; condition ? I recommend to start learning programming C before using Arduino. In C you can do such a idea using preprocessor directives &lt;code&gt;IF, ELSE, ENDIF&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3825" LastActivityDate="2015-11-05T20:38:10.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17508" PostTypeId="1" CreationDate="2015-11-05T21:02:25.707" Score="0" ViewCount="6097" Body="&lt;p&gt;I've already sent you the code but you told me to format it, so I tried this way ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the problem I got is it doesn't read good the 2 slave (sender) to the master&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(reader) ...you told me LAST TIME (DON'T DO SERIAL PRINTLN IN THE CALLBACK &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ROUTINE) so I tried this code (I've got some data from both but not in order)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here's the slave 1 and 2 code (I only change the  &lt;code&gt;slavedeviceId&lt;/code&gt; address)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;&#xA;//&#xA;// i2c_test_01&#xA;&#xA;//&#xA;// This demonstrates a master transmitting to a slave.&#xA;// &#xA;&#xA;// The master transmits a value read from an analogue port.&#xA;&#xA;// The slave sends the value to the serial device.&#xA;//&#xA;&#xA;&#xA;byte x = 0;&#xA;//&#xA;const byte AnalogueInputPin = 0;&#xA;&#xA;const byte SlaveDeviceId = 2;&#xA;&#xA;&#xA;&#xA;void setup() {  &#xA;  // Start I2C bus as master&#xA;  Wire.begin();     &#xA;}&#xA;&#xA;void loop() {&#xA;  int input0 = analogRead(x);&#xA;  // Send two bytes to slave.&#xA;  Wire.beginTransmission(SlaveDeviceId);&#xA;  Wire.write(input0 &amp;gt;&amp;gt; 8);&#xA;  Wire.write(input0 &amp;amp; 255);&#xA;  Wire.endTransmission();&#xA;&#xA;  delay(10);&#xA;&#xA;  x++;&#xA;  if (x == 4) {&#xA;    x = 0;&#xA;  }&#xA;&#xA;  delay(40);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here's the master (reader)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for your time it is realy intructive for me !!!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;const byte SlaveDeviceId = 1;&#xA;const byte SlaveDeviceId2 = 2;&#xA;int S1;&#xA;int S2;&#xA;int c;&#xA;int cc;&#xA;&#xA;void setup() { &#xA;  // Start I2C bus as a slave&#xA;  Wire.begin(); &#xA;  Wire.onReceive(receiveCallback);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void SLAVEone() {&#xA;  Wire.begin(SlaveDeviceId);&#xA;  delay(5);&#xA;  Wire.onReceive(receiveCallback);&#xA;  delay(5);&#xA;}&#xA;&#xA;void SLAVEtwo() {&#xA;  Wire.begin(SlaveDeviceId2);&#xA;  delay(5);&#xA;  Wire.onReceive(receiveCallback2);&#xA;  delay(5);&#xA;}&#xA;&#xA;void receiveCallback(int aCount) {&#xA;  if(aCount == 2) {&#xA;    int receivedValue  = Wire.read() &amp;lt;&amp;lt; 8; &#xA;    receivedValue |= Wire.read(); &#xA;    //Serial.print(c);  &#xA;    //Serial.print(&quot; S1 = &quot;);&#xA;    //Serial.println(receivedValue);  &#xA;    S1 = receivedValue;&#xA;  } else {&#xA;    Serial.print(&quot;Unexpected number of bytes received: &quot;);&#xA;    Serial.println(aCount);&#xA;  }&#xA;  c++;&#xA;  if (c == 4) {&#xA;    c = 0;&#xA;  }&#xA;}&#xA;&#xA;void receiveCallback2(int aCount2) {&#xA;  if (aCount2 == 2) {&#xA;    int receivedValue2  = Wire.read() &amp;lt;&amp;lt; 8; &#xA;    receivedValue2 |= Wire.read();&#xA;    // Serial.print(cc);&#xA;    //Serial.print(&quot; S2 = &quot;);&#xA;    //Serial.println(receivedValue2);&#xA;    S2 = receivedValue2;&#xA;  } else {&#xA;    Serial.print(&quot;Unexpected number of bytes received: &quot;);&#xA;    Serial.println(aCount2);&#xA;  }&#xA;  cc++;&#xA;  if (cc == 4) {&#xA;    cc = 0;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  for(int y = 0; y &amp;lt;= 3; y++) {&#xA;    SLAVEone();&#xA;    Serial.print(c);&#xA;    Serial.print(&quot; = S1 = &quot;);&#xA;    Serial.println(S1);&#xA;    delay(10);&#xA;  }&#xA;  for(int y = 0; y &amp;lt;= 3; y++) {&#xA;    SLAVEtwo();&#xA;    Serial.print(cc);&#xA;    Serial.print(&quot; = S2 = &quot;);&#xA;    Serial.println(S2);&#xA;    delay(10);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14016" LastEditorUserId="6424" LastEditDate="2015-11-08T08:21:09.090" LastActivityDate="2016-02-06T23:15:33.437" Title="I2C send and read 2 bytes many slave" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17509" PostTypeId="2" ParentId="17508" CreationDate="2015-11-05T22:32:07.990" Score="1" Body="&lt;p&gt;I don't quite see how your code is supposed to work.  It seems like your &quot;slave&quot; devices are trying to write to your &quot;master&quot; as if they were master devices not slaves, and your &quot;master&quot; is rapidly switching between thinking it is one of two slaves. The whole methodology is backwards.  The &quot;master&quot; should connect to a &quot;slave&quot; and request the data not wait for a &quot;slave&quot; to randomly throw data at it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-05T22:32:07.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17510" PostTypeId="1" CreationDate="2015-11-05T22:09:13.117" Score="1" ViewCount="198" Body="&lt;p&gt;I build photo gate, to detect throwing ball. &#xA;It works fine when delay time in main loop for max 40 milliseconds. &#xA;Problems start when I delay every loop only for 20 milliseconds, now my LED which indicates if something broke path between IR led and IR receiver, &lt;strong&gt;blinks occasionally&lt;/strong&gt;, if I set delay for 10 milliseconds and turn on, then LED is off for 2 seconds, then start blinking very fast and is ON for rest time, until I break IR path. I think some physics is going on here which I don't understand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also would like to ask if it is possible to &lt;strong&gt;narrow IR wave path to be more like laser&lt;/strong&gt; (going strait into one direction) and how I can &lt;strong&gt;control sensitivity&lt;/strong&gt; of IR detection&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is schematic &lt;a href=&quot;https://i.stack.imgur.com/KBYYf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KBYYf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.vishay.com/docs/81010/tsal6200.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;IR transmiter&lt;/a&gt;&#xA;&lt;a href=&quot;http://arduino-info.wikispaces.com/file/view/IR-Receiver-AX-1838HS.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;IR reciever&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//define pins. I used pins 4 and 5&#xA;#define irLedPin 4          // IR Led on this pin&#xA;#define irSensorPin 5       // IR sensor on this pin&#xA;#define buzzerPin 2       // buzzer on this pin&#xA;&#xA;int irRead(int readPin, int triggerPin); //function prototype&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(irSensorPin, INPUT);&#xA;  pinMode(irLedPin, OUTPUT);&#xA;  pinMode(buzzerPin, OUTPUT);&#xA;  Serial.begin(9600); &#xA;  // prints title with ending line break &#xA;  Serial.println(&quot;Program Starting&quot;); &#xA;  // wait for the long string to be sent &#xA;  delay(100); &#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;&#xA;  bool isOn = irRead(irSensorPin, irLedPin);&#xA;  //Serial.println(isOn); //display the results&#xA;  if(isOn == true)&#xA;  {&#xA;    digitalWrite(buzzerPin, HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;     digitalWrite(buzzerPin, LOW);&#xA;  }&#xA;  delay(10); &#xA;}&#xA;&#xA;&#xA;int irRead(int readPin, int triggerPin)&#xA;{&#xA;  int halfPeriod = 13; //one period at 38.5khZ is aproximately 26 microseconds&#xA;  int cycles = 23; //26 microseconds * 23 is more or less 600 us&#xA;  int i;&#xA;  for (i=0; i &amp;lt;=cycles; i++)&#xA;  {&#xA;    digitalWrite(triggerPin, HIGH); &#xA;    delayMicroseconds(halfPeriod);&#xA;    digitalWrite(triggerPin, LOW); &#xA;    delayMicroseconds(halfPeriod - 1);     // - 1 to make up for digitaWrite overhead    &#xA;  }&#xA;  return digitalRead(readPin);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14640" OwnerDisplayName="kosnkov" LastEditorUserId="37523" LastEditDate="2018-07-27T01:22:39.333" LastActivityDate="2018-07-27T01:22:39.333" Title="IR receiver transmitter High frequency" Tags="|ir|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17511" PostTypeId="2" ParentId="17510" CreationDate="2015-11-05T22:48:24.933" Score="3" Body="&lt;p&gt;While you are doing a &lt;code&gt;delay()&lt;/code&gt; you can't be doing anything else - that includes looking to see if the beam has been broken by the ball.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;must not&lt;/em&gt; use &lt;code&gt;delay()&lt;/code&gt; in your sketch, instead use &lt;code&gt;millis()&lt;/code&gt; as in the &lt;strong&gt;BlinkWithoutDelay&lt;/strong&gt; example sketch in the IDE's &lt;em&gt;File -&gt; Examples&lt;/em&gt; menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also how you are dealing with your IR system is incorrect.  You are first generating a brief square wave and then afterwards you are looking to see what was received.  Instead you need to be generating the square wave and &lt;em&gt;at the same time&lt;/em&gt; see if that square wave is being received.  Normally that is achieved by using one of the PWM outputs of the Arduino set to the right frequency to generate a constant waveform which the receiver then senses all the time.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-05T22:48:24.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17512" PostTypeId="1" AcceptedAnswerId="17513" CreationDate="2015-11-05T23:23:07.463" Score="0" ViewCount="1229" Body="&lt;p&gt;I am trying to upload some code to the ATmega328 on Sparkfun's 9DOF Razor IMU. Because I don't have an FTDI board at hand I was trying to use my UNO by &quot;grounding&quot; the &lt;code&gt;RESET&lt;/code&gt; pin. Communicating with the 9DOF works well (it has some sample firmware loaded):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y6zBt.png&quot; width=&quot;400&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So here's the problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to program the ATmega328, the Arduino IDE gives e the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0d&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HMOUK.png&quot; width=&quot;300&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/kyOYw.jpg&quot; width=&quot;240&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="14535" LastActivityDate="2016-12-08T06:52:57.327" Title="Using Arduino UNO as FTDI programmer for 9DOF Razor IMU" Tags="|arduino-uno|uart|ftdi|programmer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17513" PostTypeId="2" ParentId="17512" CreationDate="2015-11-06T00:26:47.860" Score="1" Body="&lt;p&gt;What you're missing is the signal that resets the ATMega so it can enter the bootloader.  That signal is the one that goes to the DTR pin of the 9DOF and would normally be sent to the reset pin on your Arduino (that you are grounding).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is reset the 9DOF just as it's about to start trying to upload the code.  Timing is critical - you get about a second or so of leeway where the bootloader is actually available for avrdude to talk to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can try and find a point on your Arduino board where the DTR signal from the USB interface chip is available &lt;em&gt;before&lt;/em&gt; it passes through the capacitor to the RESET pin of the Arduino and take a wire from there (wherever that may be) to the DTR pin of the 9DOF.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-06T00:26:47.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17514" PostTypeId="1" AcceptedAnswerId="17517" CreationDate="2015-11-06T01:08:33.153" Score="1" ViewCount="636" Body="&lt;p&gt;This seems like a simple question but I'm not finding an answer so far: at a high level, say I have a timer interrupt and some input interrupt. The input arrives, the ISR is entered, interrupts are (automatically by default?) disabled, I service the input (quickly!), but while that's going on a timer used for some other purpose fires. I don't want to miss that timer but because interrupts are disabled my input processing won't get interrupted for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I exit the input ISR and interrupts are (automatically?) re-enabled. Assuming the timer is uncomplicated (it wouldn't overflow twice during my input ISR) how do I accurately handle the fact that it overflowed during my input ISR and I &quot;missed&quot; it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would this differ if instead of the timer I simply had a second input2 that similarly might fire during my input1 processing (but would present a useful input long enough to process after input1, presuming I knew it triggered)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not looking to nest interrupts here, just to understand what happens when an interrupt happens during another ISR which has temporarily disabled them - do they pend and fire after the blocking ISR returns, or are they just lost?&lt;/p&gt;&#xA;" OwnerUserId="4439" LastActivityDate="2015-11-06T03:30:36.173" Title="Timer (or other) interrupt happens while servicing an interrupt - how to accurately handle the second one?" Tags="|arduino-mega|avr|isr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17515" PostTypeId="1" CreationDate="2015-11-06T01:51:02.827" Score="1" ViewCount="577" Body="&lt;p&gt;I'm an art student, using arduino in an Electronic Arts Class.  I have already created a skateboard speedometer, using a Hall Effect Sensor and a magnet embedded in one of my skateboards wheels.  I've attached a speaker to the arduino that plays a tone, with the pitch depending on the RPM's of the wheel.  (the faster the board is going, the higher pitch the tone being played is).  Currently the speaker is attached to the skateboard and wired directly to the arduino.  My goal is to have a speaker with an arduino wirelessly connected to the arduino on the skateboard.  The arduino on the skateboard record's the RPM's and then wirelessly send that information to the second arduino to play the tone through the speaker.  Is this possible? what hardware would yo recommend? I've been looking at the Bluetooth HC-05 but I'm not sure this will work.  Thanks for any help!&lt;/p&gt;&#xA;" OwnerUserId="14613" LastActivityDate="2015-12-07T17:39:13.783" Title="How can I have two Arduino Uno's communicate wirelessly?" Tags="|wireless|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17516" PostTypeId="1" CreationDate="2015-11-06T02:39:31.447" Score="3" ViewCount="1080" Body="&lt;p&gt;I'm currently building a robotic arm. I'm using an Adafruit servo shield, 7 servos, Arduino uno, and a 5V 10A power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X9efl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X9efl.png&quot; alt=&quot;Diagram of Robotic arm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a program that controls the arm with mouse movement using a processing sketch, &lt;a href=&quot;https://github.com/mikevanis/Fixbot&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fixbot&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I'm using the Adafruit servo shield, and I've got no clue how to convert the program. I've found the center points for the servos, so I've managed to make the robot stand upright using my own code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could give me some pointers as to how to convert from the on-board PWM outputs to the servo shield outputs for the linked program, and how to set servo max/min, I would highly appreciate it.&lt;/p&gt;&#xA;" OwnerUserId="14615" LastEditorUserId="6936" LastEditDate="2015-11-14T05:24:30.223" LastActivityDate="2015-11-14T05:24:30.223" Title="Need help converting a processing sketch for a robot arm with servo shield" Tags="|arduino-uno|servo|arduino-motor-shield|adafruit|processing-lang|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17517" PostTypeId="2" ParentId="17514" CreationDate="2015-11-06T03:08:39.303" Score="1" Body="&lt;p&gt;Q1:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... exit the input ISR and interrupts are (automatically?) re-enabled&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, the RETI (return from interrupt) instruction enables interrupts.  See third paragraph of section 7.7 in &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmel's document #8271&lt;/a&gt; (a 650-page spec sheet for the Atmega 48, 88, 168, 328 series), which says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a Return from Interrupt instruction – RETI – is executed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Q2:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Assuming the timer is uncomplicated (it wouldn't overflow twice during my input ISR) how do I accurately handle the fact that it overflowed during my input ISR and I &quot;missed&quot; it?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the timer is running a clock, set the timer control bits to automatically reload the count register upon each overflow (or underflow).  That will leave a full count period for processing each timer interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, you can pre-load a next-timer-count (I think it can be different from the current count if necessary), so the timer can start its next interval automatically.  If the timer is used for some purpose more complicated than that, you may need a nested interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q3:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Would this differ if instead of the timer I simply had a second input2 that similarly might fire during my input1 processing (but would present a useful input long enough to process after input1, presuming I knew it triggered)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If indeed input2 sticks around long enough to process after input1 processing is done, no problem.  Its interrupt will occur after the first interrupted code sequence executes one more instruction after the RETI occurs.  (See paragraph 6 of section 7.7 in doc8271.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If input2 is brief, several different things can happen.   (a) If it is shorter than a clock cycle, in general it won't trigger an interrupt.  (b) If it is a level-interrupt-triggering event on INT0 or INT1 that ends while another interrupt is being processed, it won't trigger an interrupt.  (See discussion on page 72, section 13.2.3, of doc8271 of INTF0 and INTF1 being clear for level interrupts.) (c) If it is an interrupt-flag-setting event that sets a flag and ends while another interrupt is being processed, it will trigger an interrupt after the global interrupt flag is set, unless current processing clears its flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the above accurately states what happens on Atmega devices, but I suggest you also see doc8271 – and run tests – to see for yourself.  Here is part of what paragraphs 4 and 5 of section 7.7 in doc8271 say regarding (b) and (c):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are basically two types of interrupts. The first type is triggered by an event that sets the Interrupt Flag.  ... Interrupt Flags can also be cleared by&#xA;  writing a logic one to the flag bit position(s) to be cleared. If an interrupt condition occurs while the&#xA;  corresponding interrupt enable bit is cleared, the Interrupt Flag will be set and remembered until the interrupt is enabled, or the flag is cleared by software. Similarly, if one or more interrupt conditions occur while the Global Interrupt Enable bit is cleared, the corresponding Interrupt Flag(s) will be set and remembered until the Global Interrupt Enable bit is set, and will then be executed by order of priority.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The second type of interrupts will trigger as long as the interrupt condition is present. These interrupts do not necessarily have Interrupt Flags. If the interrupt condition disappears before the interrupt is enabled, the&#xA;  interrupt will not be triggered.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-06T03:30:36.173" LastActivityDate="2015-11-06T03:30:36.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17518" PostTypeId="1" CreationDate="2015-11-06T03:19:30.593" Score="0" ViewCount="329" Body="&lt;p&gt;I'm trying to compile and upload the example code for the arduino robotics starter kit (&lt;a href=&quot;https://github.com/Makeblock-official/Makeblock-Library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Makeblock-official/Makeblock-Library&lt;/a&gt; and &lt;a href=&quot;https://raw.githubusercontent.com/Makeblock-official/Assembly-Instructions/master/Starter_Robot_Kit_IR_Instruction.pdf&quot; rel=&quot;nofollow&quot;&gt;https://raw.githubusercontent.com/Makeblock-official/Assembly-Instructions/master/Starter_Robot_Kit_IR_Instruction.pdf&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the IDE to compile the code, you need to select the appropiate 'board' for the sketch, and the Arduino Orion isn't listed.  Should I just compile under the Arduino Uno, which I believe the Orion is based on?&lt;/p&gt;&#xA;" OwnerUserId="14618" LastActivityDate="2016-03-05T15:51:18.507" Title="Arduino Orion Upload - Which Board When Compiling" Tags="|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17519" PostTypeId="2" ParentId="13282" CreationDate="2015-11-06T03:43:16.913" Score="0" Body="&lt;p&gt;Here is answer for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS keeps on sending data and fill the mcu input buffer . Use listen function and read one software serial at once ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use listen then only one serial port will work at a time and you can swap accordingly .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was having same problem and It solved my problem &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just open a dummy serial port and when ever you need gps then listen to GPS serial port and do listen to dummy after GPS reading .&lt;/p&gt;&#xA;" OwnerUserId="14130" LastEditorUserId="220" LastEditDate="2015-11-07T15:26:26.013" LastActivityDate="2015-11-07T15:26:26.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17520" PostTypeId="1" CreationDate="2015-11-06T04:32:02.067" Score="1" ViewCount="109" Body="&lt;p&gt;I'd like to make an Arduino play a (2sec).wav file once when it is powered on (via push button) and another when it is switched off i.e. when the push button is pushed there is a 2sec delay and the .wav file plays, then the arduino turns off.  What would the best way be to implement this?  So far I've come up with: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;//play .wav file&#xA;&#xA;while(1){}&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;//play .wav file&#xA;}&#xA;&#xA;void loop(){&#xA;//empty&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14619" LastActivityDate="2016-11-01T04:23:12.397" Title="Prevent reiteration of loop instruction in Arduino/Execute instruction via off switch" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17521" PostTypeId="1" CreationDate="2015-11-06T04:45:57.490" Score="0" ViewCount="3646" Body="&lt;p&gt;On my Uno-equivalent Arduino, a SoftwareSerial connection (on RX, TX = 8, 9) is working*, while a hardware serial connection to the same device, set up in the same way (but on pins RX, TX = 0, 1) is not working. Why is the hardware serial setup not working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*By working I mean receiving a byte from the external device&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; as a simple example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(38000);&#xA;  pinMode(7, OUTPUT);&#xA;}&#xA;&#xA;void draw() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    Serial.read();&#xA;    tone(7, 440, 1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above, using &lt;code&gt;Serial&lt;/code&gt;, doesn't work, whereas&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial serial(8, 9);&#xA;&#xA;void setup() {&#xA;  serial.begin(38000);&#xA;  pinMode(7, OUTPUT);&#xA;}&#xA;&#xA;void draw() {&#xA;  if (serial.available() &amp;gt; 0) {&#xA;    serial.read();&#xA;    tone(7, 440, 1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I don't know if this helps, but connecting RX/TX through an LED to ground gave me the following, using Serial on (0, 1) and SoftwareSerial on (8, 9):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Serial&lt;/strong&gt;&lt;br&gt;&#xA;RX: bright&lt;br&gt;&#xA;TX: bright&lt;br&gt;&#xA;&lt;strong&gt;SoftwareSerial&lt;/strong&gt;&lt;br&gt;&#xA;RX: dim (but still lit)&lt;br&gt;&#xA;TX: bright  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the fact that RX is dim using SoftwareSerial significant?&lt;/p&gt;&#xA;" OwnerUserId="11929" LastEditorUserId="11929" LastEditDate="2015-11-06T22:58:48.790" LastActivityDate="2020-01-10T06:58:17.433" Title="Hardware serial not working, SoftwareSerial is" Tags="|serial|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="17522" PostTypeId="2" ParentId="17521" CreationDate="2015-11-06T05:40:43.870" Score="1" Body="&lt;p&gt;There may be several reasons&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Be sure uC pin connect pin header&lt;/li&gt;&#xA;&lt;li&gt;In setup part, you write Serial.begin(xxxx);&lt;/li&gt;&#xA;&lt;li&gt;After serial begin, don't change this pins IO features(Input, output)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please check that after if not solve, please share code&lt;/p&gt;&#xA;" OwnerUserId="14620" LastActivityDate="2015-11-06T05:40:43.870" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17523" PostTypeId="2" ParentId="17520" CreationDate="2015-11-06T06:03:58.807" Score="0" Body="&lt;p&gt;Neither way addresses your second requirement. I would do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;    {&#xA;    pinMode (OFF_BUTTON, INPUT_PULLUP);&#xA;&#xA;    //play .wav file&#xA;    }&#xA;&#xA;void loop()&#xA;  {&#xA;&#xA;  if (digitalRead (OFF_BUTTON) == LOW)  // depending on how it is wired&#xA;    {&#xA;    delay (2000);   // 2 second delay&#xA;    // play .wav file&#xA;    // power self off somehow&#xA;    }   &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-06T06:03:58.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17524" PostTypeId="2" ParentId="13226" CreationDate="2015-11-06T08:24:22.213" Score="2" Body="&lt;p&gt;I had same problem. It helped to connect GNDs of both power supplies namely the one powering the arduino and the 3.3V one powering the ESP8266.&lt;/p&gt;&#xA;" OwnerUserId="14623" LastActivityDate="2015-11-06T08:24:22.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17525" PostTypeId="2" ParentId="17506" CreationDate="2015-11-06T08:42:55.080" Score="1" Body="&lt;p&gt;As Tma mentioned earlier, C is a procedural language. That means that all the code must be part of a defined function. So in your code you have the functions void loop() and void setup(). Wich are two functions you must always have in an arduino sketch, but you can also define others. What you cannot do is having two functions with the same name and type in C like you have there, because there is no way to tell them apart from each other. You have two functions called loop and setup...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One basic thing about Arduino code that you must know is the way it runs your code. Every arduinos sketch must have a setup and a loop function. Then when you start the program, it wil first execute the code in your setup function ONCE and then start at your loop function. The name of the loop function already indicates that it will LOOP all the code inside it, so when your program reaches the end of loop() is starts again at the top of loop(). Your program will never reach any point below loop, because you need to specifically call a function to redirect your program to another point. I think the best way to learn Arduino is to study some C first.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-11-06T08:42:55.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17526" PostTypeId="1" CreationDate="2015-11-06T10:12:14.867" Score="0" ViewCount="1714" Body="&lt;p&gt;I am learning Arduino and trying to understand how integers and strings are sent across the serial port. &#xA;I tried a small program in arduino which reads a number as a string and tries to blink led 13 according to that number. Below is the arduino side of code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledpin = 13;&#xA;int value = 0;&#xA;int blinkrate;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   pinMode(ledpin,OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (Serial.available())&#xA;      {&#xA;         char ch = Serial.read();&#xA;         if (isDigit(ch))&#xA;            {&#xA;               value = (value*10) + (ch - '0');&#xA;            }&#xA;         else if (ch == 10)&#xA;            {&#xA;               blinkrate = value;&#xA;               Serial.println(blinkrate);&#xA;               value = 0;&#xA;            }&#xA;      }&#xA;    blinkled(blinkrate);&#xA;}&#xA;&#xA;void blinkled(int blinkrate)&#xA; {&#xA;   digitalWrite(ledpin,HIGH);&#xA;   delay(blinkrate);&#xA;   digitalWrite(ledpin,LOW);&#xA;   delay(blinkrate);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When i try to send a string from MATLAB, the RX led blinks once indicating something is coming, but the LED on pin 13 is not behaving accordingly(it should blink according to the number i send). Here is the matlab side of code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pre_open = instrfindall;&#xA;delete(pre_open);&#xA;serial_port = serial('COM3');&#xA;set(serial_port,'Terminator','CR');&#xA;set(serial_port,'BaudRate',9600);&#xA;set(serial_port,'DataBits',8);&#xA;set(serial_port,'StopBits',1);&#xA;set(serial_port,'Parity','none');&#xA;fopen(serial_port);&#xA;num = 200;&#xA;fwrite(serial_port,int2str(num));&#xA;data = fscanf(serial_port,'%d');&#xA;pause(2);&#xA;fclose(serial_port);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When i try to read the return string from arduino, MATLAB shows me a timeout error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be grateful if anybody points me to the right solution.&#xA;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="13910" LastActivityDate="2016-02-05T22:55:00.240" Title="Sending serial data to Arduino from Matlab(not using support package)" Tags="|arduino-uno|serial|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17527" PostTypeId="2" ParentId="3850" CreationDate="2015-11-06T10:53:13.203" Score="3" Body="&lt;p&gt;I know this question is relatively old but still, if you wnat to run  &lt;code&gt;SD.begin(chipselect);&lt;/code&gt; again first call &lt;code&gt;if(root.isOpen()) root.close();&lt;/code&gt; I added this to the library. This way &lt;code&gt;SD.begin(chipselect)&lt;/code&gt; will return &lt;code&gt;true&lt;/code&gt; if a card is present and &lt;code&gt;false&lt;/code&gt; when it's not.&lt;/p&gt;&#xA;" OwnerUserId="14624" LastActivityDate="2015-11-06T10:53:13.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17528" PostTypeId="2" ParentId="17520" CreationDate="2015-11-06T11:04:40.457" Score="1" Body="&lt;p&gt;An Arduino doesn't understand the concept of &quot;powering off&quot;.  It is either on (running) or off (not able to do anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your first task must be to design a system whereby the Arduino can control its own power so the Arduino can then go &quot;I have been asked by this external stimulus to switch off. Therefore I will play this sound and then perform whatever actions are required to remove power from myself.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only when you have worked out how you can get the Arduino to control its own power and still have the ability to manually turn the power on can you begin to think about adding things that happen &quot;when it powers off&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-06T11:04:40.457" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17529" PostTypeId="2" ParentId="17486" CreationDate="2015-11-06T11:09:04.610" Score="1" Body="&lt;p&gt;To generate a useful example I've setup an Arduino Nano with a magnetic orientation sensor and have it output 3 values per line for the X, Y and Z field strengths. It prints 1 line every 50ms and the following python tkinter script plots this. It started as your python code above but it has been reworked to be more pythonic. The result looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3wnW3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3wnW3.png&quot; alt=&quot;screenshot of tkinter plot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Call the script with the comport and speed. eg: &lt;code&gt;python magplot.py COM21 19200&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#!/usr/bin/python&#xA;#&#xA;# Read stream of lines from an Arduino with a magnetic sensor. This&#xA;# produces 3 values per line every 50ms that relate to the orientation&#xA;# of the sensor. Each line looks like:&#xA;# MAG   1.00    -2.00   0.00&#xA;# with each data line starting with &quot;MAG&quot; and each field separated by&#xA;# tab characters. Values are floating point numbers in ASCII encoding.&#xA;#&#xA;# This script supports both Python 2.7 and Python 3&#xA;&#xA;from __future__ import print_function, division, absolute_import&#xA;import sys&#xA;if sys.hexversion &amp;gt; 0x02ffffff:&#xA;    import tkinter as tk&#xA;else:&#xA;    import Tkinter as tk&#xA;from serial import Serial&#xA;&#xA;class App(tk.Frame):&#xA;    def __init__(self, parent, title, serialPort):&#xA;        tk.Frame.__init__(self, parent)&#xA;        self.serialPort = serialPort&#xA;        self.npoints = 100&#xA;        self.Line1 = [0 for x in range(self.npoints)]&#xA;        self.Line2 = [0 for x in range(self.npoints)]&#xA;        self.Line3 = [0 for x in range(self.npoints)]&#xA;        parent.wm_title(title)&#xA;        parent.wm_geometry(&quot;800x400&quot;)&#xA;        self.canvas = tk.Canvas(self, background=&quot;white&quot;)&#xA;        self.canvas.bind(&quot;&amp;lt;Configure&amp;gt;&quot;, self.on_resize)&#xA;        self.canvas.create_line((0, 0, 0, 0), tag='X', fill='darkblue', width=1)&#xA;        self.canvas.create_line((0, 0, 0, 0), tag='Y', fill='darkred', width=1)&#xA;        self.canvas.create_line((0, 0, 0, 0), tag='Z', fill='darkgreen', width=1)&#xA;        self.canvas.grid(sticky=&quot;news&quot;)&#xA;        self.grid_rowconfigure(0, weight=1)&#xA;        self.grid_columnconfigure(0, weight=1)&#xA;        self.grid(sticky=&quot;news&quot;)&#xA;        parent.grid_rowconfigure(0, weight=1)&#xA;        parent.grid_columnconfigure(0, weight=1)&#xA;&#xA;    def on_resize(self, event):&#xA;        self.replot()&#xA;&#xA;    def read_serial(self):&#xA;        &quot;&quot;&quot;&#xA;        Check for input from the serial port. On fetching a line, parse&#xA;        the sensor values and append to the stored data and post a replot&#xA;        request.&#xA;        &quot;&quot;&quot;&#xA;        if self.serialPort.inWaiting() != 0:&#xA;            line = self.serialPort.readline()&#xA;            line = line.decode('ascii').strip(&quot;\r\n&quot;)&#xA;            if line[0:3] != &quot;MAG&quot;:&#xA;                print(line) # line not a valid sensor result.&#xA;            else:&#xA;                try:&#xA;                    data = line.split(&quot;\t&quot;)&#xA;                    x, y, z = data[1], data[2], data[3]&#xA;                    self.append_values(x, y, z)&#xA;                    self.after_idle(self.replot)&#xA;                except Exception as e:&#xA;                    print(e)&#xA;        self.after(10, self.read_serial)&#xA;&#xA;    def append_values(self, x, y, z):&#xA;        &quot;&quot;&quot;&#xA;        Update the cached data lists with new sensor values.&#xA;        &quot;&quot;&quot;&#xA;        self.Line1.append(float(x))&#xA;        self.Line1 = self.Line1[-1 * self.npoints:]&#xA;        self.Line2.append(float(y))&#xA;        self.Line2 = self.Line2[-1 * self.npoints:]&#xA;        self.Line3.append(float(z))&#xA;        self.Line3 = self.Line3[-1 * self.npoints:]&#xA;        return&#xA;&#xA;    def replot(self):&#xA;        &quot;&quot;&quot;&#xA;        Update the canvas graph lines from the cached data lists.&#xA;        The lines are scaled to match the canvas size as the window may&#xA;        be resized by the user.&#xA;        &quot;&quot;&quot;&#xA;        w = self.winfo_width()&#xA;        h = self.winfo_height()&#xA;        max_X = max(self.Line1) + 1e-5&#xA;        max_Y = max(self.Line2) + 1e-5&#xA;        max_Z = max(self.Line3) + 1e-5&#xA;        max_all = 200.0&#xA;        coordsX, coordsY, coordsZ = [], [], []&#xA;        for n in range(0, self.npoints):&#xA;            x = (w * n) / self.npoints&#xA;            coordsX.append(x)&#xA;            coordsX.append(h - ((h * (self.Line1[n]+100)) / max_all))&#xA;            coordsY.append(x)&#xA;            coordsY.append(h - ((h * (self.Line2[n]+100)) / max_all))&#xA;            coordsZ.append(x)&#xA;            coordsZ.append(h - ((h * (self.Line3[n] + 100)) / max_all))&#xA;        self.canvas.coords('X', *coordsX)&#xA;        self.canvas.coords('Y', *coordsY)&#xA;        self.canvas.coords('Z', *coordsZ)&#xA;&#xA;def main(args = None):&#xA;    if args is None:&#xA;        args = sys.argv&#xA;    port,baudrate = 'COM4', 115200&#xA;    if len(args) &amp;gt; 1:&#xA;        port = args[1]&#xA;    if len(args) &amp;gt; 2:&#xA;        baudrate = int(args[2])&#xA;    root = tk.Tk()&#xA;    app = App(root, &quot;Smooth Sailing&quot;, Serial(port, baudrate))&#xA;    app.read_serial()&#xA;    app.mainloop()&#xA;    return 0&#xA;&#xA;if __name__ == '__main__':&#xA;    sys.exit(main())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Update&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Looking at the updated question it is clear that the new Tkinter code is not updating the display. In all windowing systems it is essential that the application thread is allowed to process events regularly. This is why the example code above uses the Tk &lt;code&gt;after()&lt;/code&gt; method to add calls to the event queue. The &lt;code&gt;read_serial()&lt;/code&gt; function checks to see if any data is available and if not &lt;em&gt;schedules a retry later&lt;/em&gt;. This is done by using &lt;code&gt;after()&lt;/code&gt; to request the same method is called again in 10ms time. During that 10ms delay the Tk application processes all the other windowing system events like mouse movement, keyboard input and crucially expose and painting events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same method is used to call the &lt;code&gt;replot()&lt;/code&gt; method once we have updated the list of data items. In this case &lt;code&gt;after_idle()&lt;/code&gt; has been used which means schedule this function call as soon as nothing else is happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The act of changing the canvas line coordinates will cause further events to be raised by Tk which affect the display only once they are processed by the event loop. If we never process the events, nothing will appear on screen.&lt;/p&gt;&#xA;" OwnerUserId="6703" LastEditorUserId="6703" LastEditDate="2015-11-12T02:20:56.330" LastActivityDate="2015-11-12T02:20:56.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17530" PostTypeId="2" ParentId="17526" CreationDate="2015-11-06T12:26:59.960" Score="0" Body="&lt;p&gt;You're setting the terminator to be 'CR'.  CR, or Carriage Return, is character 13.  In your Arduino program you are looking for character 10.  That is 'LF' or Line Feed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either are commonly used to denote a line ending, but both ends must agree on which it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, Unix files use a single LF for a line ending.  Windows files use the combination of both a CR and an LF.  Many networking protocols use a single CR for the line ending.  It really doesn't matter what is used &lt;em&gt;as long as it is consistent.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-06T12:26:59.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17531" PostTypeId="2" ParentId="17518" CreationDate="2015-11-06T12:32:38.730" Score="2" Body="&lt;p&gt;Yes, the &quot;Orion&quot; is just an Uno in a different shape with different connectors.  Just treat it like an ordinary Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly the &quot;Baseboard&quot; is just a Leonardo in a different shape with different connectors.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-06T12:32:38.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17534" PostTypeId="2" ParentId="17466" CreationDate="2015-11-06T14:00:13.210" Score="0" Body="&lt;p&gt;I've managed to specify the correct ports and bits in order to make the library function on the Arduino ATmega2560 using their Ethernet Shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SPI port definitions has to be changed to the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SPI_PORT    PORTB               /* target-specific port containing the SPI lines */&#xA;#define SPI_DDR     DDRB                /* target-specific DDR for the SPI port lines */&#xA;&#xA;#define CS_DDR      DDRB                /* target-specific DDR for chip-select */&#xA;#define CS_PORT     PORTB               /* target-specific port used as chip-select */&#xA;#define CS_BIT      4                   /* target-specific port line used as chip-select */&#xA;&#xA;#define RESET_DDR   DDRB                /* target-specific DDR for reset */&#xA;#define RESET_PORT  PORTB               /* target-specific port used for reset */&#xA;#define RESET_BIT   8                   /* target-specific port line used as reset */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The section about the AT644p in the main() function has to be changed to the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Initialize the ATmega2560 SPI subsystem&#xA; */&#xA;// Initial SPI Peripheral&#xA;SPI_DDR = (1&amp;lt;&amp;lt;PORTB2)|(1&amp;lt;&amp;lt;PORTB1)|(1&amp;lt;&amp;lt;PORTB0);&#xA;&#xA;// CS pin is not active&#xA;SPI_PORT |= (1&amp;lt;&amp;lt;CS_BIT);&#xA;&#xA;    // Enable SPI, Master Mode 0, set the clock rate fck/2&#xA;SPCR = (1&amp;lt;&amp;lt;SPE)|(1&amp;lt;&amp;lt;MSTR);&#xA;SPSR |= (1&amp;lt;&amp;lt;SPI2X);&#xA;&#xA;//Disable the SD card&#xA;DDRB |= (1&amp;lt;&amp;lt;CS_BIT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5126" LastActivityDate="2015-11-06T14:00:13.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17535" PostTypeId="1" AcceptedAnswerId="17537" CreationDate="2015-11-06T15:44:37.100" Score="0" ViewCount="1519" Body="&lt;p&gt;I expect from the following program &lt;code&gt;serial.c&lt;/code&gt; to light the led on if I send key &lt;code&gt;1&lt;/code&gt; from terminal, and light the led off when I send key &lt;code&gt;0&lt;/code&gt; from terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#define BAUD 9600&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;char data;&#xA;void main(void) {&#xA;  #include &amp;lt;util/setbaud.h&amp;gt; &#xA;  UBRR0H = UBRRH_VALUE;&#xA;  UBRR0L = UBRRL_VALUE;&#xA;  UCSR0B |= (1&amp;lt;&amp;lt;RXEN0);&#xA;  UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;  DDRB |= (1&amp;lt;&amp;lt;PB1);&#xA;  while(1) {&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0)));&#xA;    data = UDR0;&#xA;    if (data=='0') PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB1);&#xA;    if (data=='1') PORTB |= (1&amp;lt;&amp;lt;PB1);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use the following commands to compile and burn all the programs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -Os -mmcu=atmega328p -c -o serial.o serial.c&#xA;avr-ld -o serial.elf serial.o&#xA;avr-objcopy -O ihex serial.elf serial.hex&#xA;avrdude -c usbasp -p atmega328p -U flash:w:serial.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of avrdude is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ avrdude -c usbasp -p atmega328p -U flash:w:serial.hex&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: NOTE: &quot;flash&quot; memory has been specified, an erase cycle will be performed&#xA;         To disable this feature, specify the -D option.&#xA;avrdude: erasing chip&#xA;avrdude: reading input file &quot;serial.hex&quot;&#xA;avrdude: input file serial.hex auto detected as Intel Hex&#xA;avrdude: writing flash (12 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: 12 bytes of flash written&#xA;avrdude: verifying flash memory against serial.hex:&#xA;avrdude: load data flash data from input file serial.hex:&#xA;avrdude: input file serial.hex auto detected as Intel Hex&#xA;avrdude: input file serial.hex contains 12 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 0.02s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 12 bytes of flash verified&#xA;&#xA;avrdude: safemode: Fuses OK (E:07, H:DE, L:FF)&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For serial connection I tried PL2302 and FT232RL usb-com adapters - the effect is always the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Terminal settings on the computer are correct (9600,8N1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr-gcc version 4.8.1&#xA;avrdude version 6.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why the very first program in this question does not work as needed and what should be changed in it to achieve the desired behavior?&lt;/p&gt;&#xA;" OwnerUserId="14631" LastEditorUserId="37523" LastEditDate="2019-11-18T22:01:58.377" LastActivityDate="2019-11-18T22:01:58.377" Title="Why serial communication does not work on atmega168/328p?" Tags="|serial|atmega328|avr-gcc|pl2303hx|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="17536" PostTypeId="1" CreationDate="2015-11-06T16:00:52.907" Score="3" ViewCount="13068" Body="&lt;p&gt;I have this setup where I have and Arduino Uno, a mini servo motor, and a pushbutton. I use a single pushbutton to control the servo motor to go to one position, then push it again to go back. It first goes to 0 degrees, then if you push it it goes to 180 degrees then vice versa. The problem is that in its initial state (which is 0 degrees), the servo motor makes noise. Like it's running or something then it gets hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen other servo motors that never do this. Here is my code by the way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;const int buttonPin = 8;&#xA;const int servoPin = 9;&#xA;int buttonState = 0;&#xA;int directionState = 0;&#xA;Servo servoOne;&#xA;int pos = 0;&#xA;&#xA;void setup() {&#xA;  servoOne.attach(9);&#xA;  servoOne.write(directionState);&#xA;  pinMode(buttonPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  buttonState = digitalRead(buttonPin);&#xA;  if (directionState == 0) {&#xA;    if (buttonState == HIGH) {&#xA;      directionState = 1;&#xA;      for (pos = 0; pos &amp;lt; 180; pos = pos + 1) {&#xA;        servoOne.write(pos);&#xA;        delay(5);&#xA;      }&#xA;    }&#xA;  } else if (directionState == 1) {&#xA;    if (buttonState == HIGH) {&#xA;      directionState = 0;&#xA;      for (pos = 180; pos &amp;gt; 1; pos = pos - 1) {&#xA;        servoOne.write(pos);&#xA;        delay(5);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I really need all the help I can get.&lt;/p&gt;&#xA;" OwnerUserId="14632" LastEditorUserId="4628" LastEditDate="2018-01-15T11:33:43.640" LastActivityDate="2018-01-15T11:35:57.170" Title="Controlling Servo Motors with push button. Problem though" Tags="|arduino-uno|motor|servo|code-review|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17537" PostTypeId="2" ParentId="17535" CreationDate="2015-11-06T16:39:42.040" Score="1" Body="&lt;p&gt;The problem you have is that your baud rate is not being set right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only have part of the settings you need.  There is a third macro in the setbaud.h file that you need to take account of:  &lt;code&gt;USE_U2X&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That defines whether or not you need to set or clear the U2X0 bit of UCSRA0.  If that is set wrong then your baud rate will be either twice or half what you want it to be - in this case it's coming out as twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modify your code to assign the baud rate like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;util/setbaud.h&amp;gt; &#xA;UBRR0H = UBRRH_VALUE;&#xA;UBRR0L = UBRRL_VALUE;&#xA;#if USE_U2X&#xA;UCSR0A |= (1&amp;lt;&amp;lt;U2X0);&#xA;#else&#xA;UCSR0A &amp;amp;= ~(1&amp;lt;&amp;lt;U2X0);&#xA;#endif&#xA;UCSR0B |= (1&amp;lt;&amp;lt;RXEN0);&#xA;UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you should be able to receive characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the actual header file in question there is a large number of comments and instructions, including this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Assuming that the requested BAUD is valid for the given F_CPU then&#xA;     the macro UBRR_VALUE is set to the required prescaler value.  Two&#xA;     additional macros are provided for the low and high bytes of the&#xA;     prescaler, respectively: UBRRL_VALUE is set to the lower byte of&#xA;     the UBRR_VALUE and UBRRH_VALUE is set to the upper byte.  &lt;strong&gt;An&#xA;     additional macro USE_2X will be defined.  Its value is set to 1 if&#xA;     the desired BAUD rate within the given tolerance could only be&#xA;     achieved by setting the U2X bit in the UART configuration.  It will&#xA;     be defined to 0 if U2X is not needed.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My resulting UART configuration, which may be being affected by the bootloader, is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UBRR0H: 0x00&#xA;UBRR0L: 0x67&#xA;UCSR0A: 0x20&#xA;UCSR0B: 0x10&#xA;UCSR0C: 0x06&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That equates to &lt;code&gt;data register empty&lt;/code&gt;, &lt;code&gt;RX enabled&lt;/code&gt;, &lt;code&gt;8-bit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my mind that is equal to the values being manually set in the code, so shouldn't be a problem.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-06T17:19:55.827" LastActivityDate="2015-11-06T17:19:55.827" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="17538" PostTypeId="1" AcceptedAnswerId="17543" CreationDate="2015-11-06T16:51:36.780" Score="1" ViewCount="206" Body="&lt;p&gt;Im going to take part in a competition called IEEE Very Small Soccer and I need to set up a communication between my computer, that will run visual and strategy algorithms, and send some commands to 3 Arduinos, which will be the players. Most people use the Xbee module to send data to the Arduinos, so I was wondering why not use the Bluetooth module instead, once it is so much cheaper and the difference in power consumption isn't so big, the only drawback would be the working range, which is 10m, if Im correct... However, if the distance is really 10m, not 5m It will be ok, because the computer is always close to the robots.&lt;/p&gt;&#xA;&lt;p&gt;Summing up, my questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can I use a computer to send data to 3 Arduinos at the same time?&lt;/li&gt;&#xA;&lt;li&gt;What is the real working range of the Bluetooth module?&lt;/li&gt;&#xA;&lt;li&gt;Any suggestions or tips? =D&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0fjsE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0fjsE.png&quot; alt=&quot;IEEE Very Small Size Soccer schematic&quot; /&gt;&lt;/a&gt;?&lt;/p&gt;&#xA;" OwnerUserId="14634" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-11-06T21:25:09.483" Title="Computer to multiple arduino bluetooth modules" Tags="|bluetooth|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17539" PostTypeId="2" ParentId="17099" CreationDate="2015-11-06T18:46:54.217" Score="1" Body="&lt;p&gt;I noticed when testing my ESP8266 using the Arduino IDE serial console that ending with a &lt;code&gt;CR&lt;/code&gt; repeated what was sent, a &lt;code&gt;NL&lt;/code&gt; executed the command and combination of the two yielded a combination of the two behaviours. This could have just been the firmware on mine (it seemed to be non-standard), but it is possible that the behaviour is similar on yours. If you are using &lt;code&gt;CR&lt;/code&gt; &amp;amp; &lt;code&gt;NL&lt;/code&gt;, it would explain repetition. However, I can't explain commands not executing, or executing abnormally.&lt;/p&gt;&#xA;" OwnerUserId="11929" LastActivityDate="2015-11-06T18:46:54.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17540" PostTypeId="2" ParentId="4919" CreationDate="2015-11-06T19:18:18.103" Score="2" Body="&lt;p&gt;You are lucky. Looks like there is an Arduino library available for the ADS1256. You should give it a shot: &lt;a href=&quot;https://github.com/Flydroid/ADS12xx-Library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Flydroid/ADS12xx-Library&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it but checked the registers and functions from the datasheet and it does look good.&lt;/p&gt;&#xA;" OwnerUserId="1387" LastActivityDate="2015-11-06T19:18:18.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17542" PostTypeId="1" CreationDate="2015-11-06T21:24:20.220" Score="2" ViewCount="15360" Body="&lt;p&gt;I have the following load cells:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JfBSd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JfBSd.jpg&quot; alt=&quot;Load Cell three wires&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following HX711 amplifier &lt;a href=&quot;https://i.stack.imgur.com/fVy0H.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fVy0H.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every guide i can find on the internet describes how to connect a load cell with four wires to the amplifier. How can i connect a load cell with three wires to the amplifier?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="5126" LastActivityDate="2021-10-03T19:22:42.767" Title="Connect HX711 to a three wire load cell" Tags="|arduino-mega|c++|electricity|analog-sampling|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17543" PostTypeId="2" ParentId="17538" CreationDate="2015-11-06T21:25:09.483" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;yes, you can, this is what happens normally in a crowded area where multiple people use their phones with bluetooth headsets, for example.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if you believe &lt;a href=&quot;https://en.wikipedia.org/wiki/Bluetooth&quot; rel=&quot;nofollow&quot;&gt;the claims&lt;/a&gt; typical 10m max 100m but in practice there are a number of factors:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Quality of the HW design of the antennas&lt;/li&gt;&#xA;&lt;li&gt;Signal to noise ratio due to other radios operating in the same area&lt;/li&gt;&#xA;&lt;li&gt;Obstacles in the path&lt;/li&gt;&#xA;&lt;li&gt;Responsiveness and throughput required by your application&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you could consider other options, like &lt;a href=&quot;http://hallard.me/nrf24l01-real-life-range-test/&quot; rel=&quot;nofollow&quot;&gt;this module&lt;/a&gt;, which is basically the same, from the perspective of transferring data. Also &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;wifi&lt;/a&gt; could work, if you are allowed to setup your own access point.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2015-11-06T21:25:09.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17544" PostTypeId="2" ParentId="12676" CreationDate="2015-11-06T21:49:17.690" Score="1" Body="&lt;p&gt;Nick O'leary published an MQTT client for Arduino.&#xA;I use it extensively.  You can find it here: &lt;a href=&quot;http://knolleary.net/arduino-client-for-mqtt/&quot; rel=&quot;nofollow&quot;&gt;http://knolleary.net/arduino-client-for-mqtt/&lt;/a&gt;.&lt;br&gt;&#xA;Once you have established a tcpip connection you can use this library to send/receive via the MQTT protocol across a GPRS/GSM modem.  I have used it successfully on:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the Arduino GSM shield &lt;/li&gt;&#xA;&lt;li&gt;the Seeeduino GPRS IoT panel &lt;/li&gt;&#xA;&lt;li&gt;a Freetronics Arduino Mega connecting via ethernet to a TPLink MR3020 router&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14642" LastEditorUserId="14642" LastEditDate="2015-11-06T22:02:56.177" LastActivityDate="2015-11-06T22:02:56.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17546" PostTypeId="2" ParentId="12687" CreationDate="2015-11-07T02:54:24.273" Score="1" Body="&lt;p&gt;Check the serial number of your board. Some boards were shipped with a defective boot loader, which has the loader stuck in an infinite loop when powered off and on again. Just Google the serial range of possible defective boards, and check if your board is in that range. &lt;/p&gt;&#xA;" OwnerUserId="14576" LastActivityDate="2015-11-07T02:54:24.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17548" PostTypeId="1" CreationDate="2015-11-07T06:13:48.753" Score="2" ViewCount="1209" Body="&lt;p&gt;Is it possible to burn the hex file to a blank chip, generated by Arduino to burn using USBASP to that particular chip without using Arduino board ? Will the program work ?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My main goal is to use Atmega328P for low power. Should I select Arduino pro mini in the arduino IDE ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ater successful testing I will just burn the hex file to another 50 chips. thats why I dont want to use arduino board.&lt;/p&gt;&#xA;" OwnerUserId="14648" OwnerDisplayName="Maxmavin" LastEditorUserId="220" LastEditDate="2015-11-15T23:54:51.103" LastActivityDate="2015-11-15T23:54:51.103" Title="Burning arduino generate hex file to blank atmel chip" Tags="|avr|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17549" PostTypeId="2" ParentId="17548" CreationDate="2015-11-07T06:27:22.900" Score="2" Body="&lt;p&gt;Yes. The binary generated by the Arduino IDE in no way requires the presence of the Arduino bootloader in order to operate. Note that certain characteristics such as the MCU and clock rate are set at build time and cannot be changed in the final binary.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2015-11-07T06:27:22.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17550" PostTypeId="2" ParentId="11694" CreationDate="2015-11-07T06:36:30.360" Score="3" Body="&lt;p&gt;If you're working with remote sensor nodes, perhaps consider the &lt;a href=&quot;http://www.mysensors.org/download/&quot; rel=&quot;nofollow&quot;&gt;MySensors&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's got support for two methods of delivering OTA updates - one using a node.js controller running on a rPi; and another third-party solution with a .NET front-end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that, you could borrow the bootloader code from the library and customise to your own needs.&lt;/p&gt;&#xA;" OwnerUserId="14647" LastActivityDate="2015-11-07T06:36:30.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17551" PostTypeId="2" ParentId="17548" CreationDate="2015-11-07T06:46:37.827" Score="2" Body="&lt;p&gt;Yes that's no problem as long as you check your fuse bytes. And the connections to the 6pin ISP header.&#xA;Make sure you study the avrdude command line and the manual for the particular Atmel chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming the programmer you are using must use avrdude to be able to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I often use a nice GUI called &quot;avrdudess&quot; which is freeware. Great for avr beginners, and takes some of the effort out of writing directly into the command prompt.&lt;/p&gt;&#xA;" OwnerUserId="14649" LastActivityDate="2015-11-07T06:46:37.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17555" PostTypeId="2" ParentId="12687" CreationDate="2015-11-07T10:28:35.790" Score="1" Body="&lt;p&gt;Try to use a battery that provides at least 7-12 volts. The voltage regulator will regulate the needed 5 volts for the arduino.&lt;/p&gt;&#xA;" OwnerUserId="14653" LastActivityDate="2015-11-07T10:28:35.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17556" PostTypeId="2" ParentId="17536" CreationDate="2015-11-07T10:41:47.633" Score="1" Body="&lt;p&gt;You might need to add more time to the delay. Also, check how your powering the servo. If you're powering from the Arduino, it might be drawing to much current and causing issues. If it's a bigger servo, try to hook it up to an external power source and just connect the PWM line and it's ground.&lt;/p&gt;&#xA;" OwnerUserId="14653" LastActivityDate="2015-11-07T10:41:47.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17557" PostTypeId="1" AcceptedAnswerId="17558" CreationDate="2015-11-07T12:14:27.317" Score="0" ViewCount="4688" Body="&lt;p&gt;How does one measure the amount of current a relay is drawing from an Arduino? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I connect a multimeter in series with the digital pin to which the relay 'IN1' is connected (in this case pin 7), the 5V pin or GND pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Provisional testing gives me the following results (when the relay is ON):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pin 7: &lt;strong&gt;3.93 mA&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;5V pin: &lt;strong&gt;70.2 mA&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;GND pin: &lt;strong&gt;66.8 mA&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, assuming I pull more than 40 mA through digital pin 7 for a number of seconds, is the pin likely to fail immediately? Or slowly degrade over time?&lt;/p&gt;&#xA;" OwnerUserId="11366" LastEditorUserId="26916" LastEditDate="2017-11-04T06:26:11.280" LastActivityDate="2017-11-04T06:26:11.280" Title="How to measure relay current draw from Arduino" Tags="|relay|current|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17558" PostTypeId="2" ParentId="17557" CreationDate="2015-11-07T12:30:05.200" Score="1" Body="&lt;p&gt;Have you noticed how the 5V current is, give or take a little inaccuracy on the part of your ammeter, the sum of the other two currents?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without knowing what relay you are talking about, my guess is it is one of the SainSmart 5V relay modules with opto-coupler. Those, by default, use a common 5V input and split it between the opto-coupler (and then into your digital pin to be sunk through ground) and the relay to ground.  Therefore the 70mA is split between 66mA through the relay and 4mA through the digital IO pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the correct place to measure the total current in this instance is the 5V pin since that is the common point for the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In answer to your second question, &lt;em&gt;read the datasheet&lt;/em&gt;.  It quite clearly states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at V CC = 3V) under steady state conditions (non-transient), the following must be observed:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;ATmega48PA/88PA/168PA/328P:&lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;The sum of all I OL , for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA.&lt;/li&gt;&#xA;  &lt;li&gt;The sum of all I OL , for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA.&lt;/li&gt;&#xA;  &lt;li&gt;The sum of all I OL , for ports D0 - D4, RESET should not exceed 100 mA.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;  &#xA;  &lt;p&gt;If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And also a similar note for sourcing current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So although they &lt;em&gt;can&lt;/em&gt; sink or source more than 20mA, and theoretically up to 40mA, anything more than 20mA is not guaranteed and should be avoided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically overcurrents cause increased heat dissipation in the MOSFETs which causes the internals to break down.  Hence the note about &lt;em&gt;under steady state conditions&lt;/em&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So sourcing or sinking more than 20mA for longer than a few ms is asking for trouble. More than 40mA is just being irresponsible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the MOSFETs in the IO pins act like resistors when turned on.  As you should know, according to Ohm's Law, the voltage across a resistor is proportional to the current through the resistor.  Increase the current and you increase the voltage across the resistor.  Since that resistance is in series with your circuit that voltage gets subtracted from your available voltage on the IO pin - so drawing too much current will cause the voltage to drop (or rise for sinking) below (above) the specifications for the logic voltage for that IO pin.  So not only do you risk damage to the IO pin and other parts of the chip through overheating, but you also then operate outside the specifications for the logic levels which can cause things that you are communicating with to not work right.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-07T12:39:19.573" LastActivityDate="2015-11-07T12:39:19.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17559" PostTypeId="1" AcceptedAnswerId="17561" CreationDate="2015-11-07T12:41:06.527" Score="5" ViewCount="427" Body="&lt;p&gt;Atmel microcontrollers are not cheap compared to STM and Microchip. Why did Arduino select Atmel MCUs such as atmega328 and atmega2560 on their board out of so many alternatives?&lt;/p&gt;&#xA;" OwnerUserId="14633" LastActivityDate="2015-11-07T13:16:00.363" Title="Why were Atmel MCUs used for Arduino?" Tags="|atmega328|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17561" PostTypeId="2" ParentId="17559" CreationDate="2015-11-07T13:16:00.363" Score="6" Body="&lt;p&gt;Simply because the Wiring system that Arduino stole was written for the Atmel chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino didn't &quot;invent&quot; the Arduino system - they just took an existing system called Wiring and adapted it slightly and branded it Arduino.  &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T13:16:00.363" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17563" PostTypeId="1" CreationDate="2015-11-07T14:42:40.020" Score="0" ViewCount="936" Body="&lt;p&gt;I am newbie in Arduino (using UNO) and as I have 2 components that I wish to connected that one needs 5V and the other need the 3.3V, is it safe to connected them together next to each other?&lt;/p&gt;&#xA;" OwnerUserId="7040" LastActivityDate="2015-12-07T18:39:13.490" Title="Arduino UNO, using 5V and 3.3V" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17564" PostTypeId="2" ParentId="17526" CreationDate="2015-11-07T14:43:44.730" Score="1" Body="&lt;p&gt;Got it, instead of depending on the Serial object, i sent the line feed to arduino. All this time it has been waiting for the Line feed that never arrived.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete(instrfindall)&#xA;s = serial('COM3', 'BaudRate', 9600); %38400&#xA;fopen(s);&#xA;pause(0.1);&#xA;text = input('enter','s');&#xA;fprintf(s,'%s\n',text,'sync');&#xA;pause(0.1);&#xA;d = fscanf(s,'%s');&#xA;pause(0.1);&#xA;delete(instrfindall)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13910" LastActivityDate="2015-11-07T14:43:44.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17565" PostTypeId="2" ParentId="17563" CreationDate="2015-11-07T15:15:46.600" Score="1" Body="&lt;p&gt;If a component needs 5V it must be connected to 5V. If it needs 3.3V it must be connected to 3.3V.  Connecting a 3.3V component to a 5V supply is a sure fire way of destroying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, since the Arduino's main chip is a 5V device, if you want to connect it to a 3.3V device you must use some form of &lt;em&gt;level translation&lt;/em&gt; so that the 5V signals from the Arduino don't damage the 3.3V device. Also it may (though not always) be necessary to convert the signals from the 3.3V device to a level that the Arduino can understand (5V).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T15:15:46.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17566" PostTypeId="1" CreationDate="2015-11-07T15:44:11.000" Score="0" ViewCount="2168" Body="&lt;p&gt;I am in the process of breadboarding an Arduino for a project and am using my FTDI Serial cable &lt;a href=&quot;http://www.adafruit.com/products/70&quot; rel=&quot;nofollow&quot;&gt;Adafruit FTDI Cable&lt;/a&gt; (tested working on Windows 7). I have also tested the breadboarded Arduino successfully on Win7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug the FTDI Serial cable into my Linux (Ubuntu 14.04 with Mint Desktop) laptop and the other end to my project (exactly as I did for Windows and it works for Win7), the Tools, Port is grayed out when in Linux.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried running Arduino as root, with no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of : dmesg | tail is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo dmesg | tail&#xA;[  729.069015] usb 4-1.2: New USB device strings: Mfr=1, Product=2,     SerialNumber=3&#xA;[  729.069019] usb 4-1.2: Product: TTL232R-3V3&#xA;[  729.069022] usb 4-1.2: Manufacturer: FTDI&#xA;[  729.069024] usb 4-1.2: SerialNumber: FTF50VXW&#xA;[  729.487689] usb 4-1.2: USB disconnect, device number 4&#xA;[  729.615330] usbcore: registered new interface driver usbserial&#xA;[  729.615384] usbcore: registered new interface driver usbserial_generic&#xA;[  729.615432] usbserial: USB Serial support registered for generic&#xA;[  729.621997] usbcore: registered new interface driver ftdi_sio&#xA;[  729.622057] usbserial: USB Serial support registered for FTDI USB Serial Device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I type &quot;lsusb&quot; into the terminal, there is no difference between when the FTDI is plugged in and not plugged in.&#xA;I have tried switching ports with no success.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="14661" LastActivityDate="2016-01-07T04:30:01.850" Title="Can't get Ubuntu to see FTDI cable for breadboarding Arduino project" Tags="|arduino-uno|ftdi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17567" PostTypeId="1" AcceptedAnswerId="17570" CreationDate="2015-11-07T15:47:26.200" Score="0" ViewCount="460" Body="&lt;p&gt;I appreciate if someone can help me. &#xA;I have a function that counts the time and I would like to store values according to the day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;For example: day_7.11.2015 = [gain = 100.23, cost = 78.0 ...]&#xA;              day_8.11.2015 = ...&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know how can I create an array with these values taking as input the day, month and year. Does anyone have any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;String test = &quot;day_&quot; + String(day) + &quot;.&quot; + String(month) + &quot;.&quot; + String(year);&#xA;float String(test)[] = {11.2, 10, 20, 31.2};&#xA; Serial.println(test);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="14660" LastActivityDate="2015-11-07T16:06:30.857" Title="creating array using string name" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17569" PostTypeId="2" ParentId="17515" CreationDate="2015-11-07T15:59:28.563" Score="1" Body="&lt;p&gt;ESP8266 is also a good choice. these little guys are really useful and give you a Wi-Fi connection between your Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the cost of one ESP8266 is about $3.. super cheap!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R0gB7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R0gB7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-07T15:59:28.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17570" PostTypeId="2" ParentId="17567" CreationDate="2015-11-07T16:06:30.857" Score="0" Body="&lt;p&gt;What you're talking about is often called a &lt;em&gt;Hash&lt;/em&gt; or a &lt;em&gt;Map&lt;/em&gt; or sometimes both together as a &lt;em&gt;HashMap&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately it's a facility that isn't supported in the Arduino C++ language&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are &lt;code&gt;map&lt;/code&gt; objects available in normal C++, but they are incredibly expensive to use with regards to memory and they just aren't practical for use on a small microcontroller with memory measured in the kilobytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest you can probably get is to &quot;invert&quot; the storage, so you have a list of values that happen to be in date order (because that's when you added them) but the &quot;key&quot;, a simple sequential number, doesn't define the date.  Instead you store the date inside the array along with the data - assuming you really need to know the date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good concept to get to grips with for this is the &lt;em&gt;struct&lt;/em&gt;.  This is a custom data type which you define and can store a number of other different data types within itself.  You can then make an array or linked list out of those new data types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you may have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct {&#xA;    int year;&#xA;    byte month;&#xA;    byte day;&#xA;    float gain;&#xA;    float cost;&#xA;} Data;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then create variables of type &quot;Data&quot; and assign values to the items within it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Data myEntry;&#xA;myEntry.year = 2015;&#xA;myEntry.month = 11;&#xA;myEntry.day = 7;&#xA;myEntry.gain = 100.23;&#xA;myEntry.cost = 78.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or assign them directly at creation time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Data myEntry = {2015, 11, 7, 100.23, 78.0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wanted to store 100 days' worth of data you could use an array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Data myArray[100];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you access each slice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myArray[0].year = 2015;&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I mentioned above &quot;assuming you really need to know the date&quot;.  Most of the time with this kind of method you really don't need to store the date.  If you have one entry per day and you know &lt;em&gt;when you started gathering data&lt;/em&gt; then you know that each entry is one day more than the one before it - so you know that the tenth entry is ten days later than when you started gathering data.  Alternatively, if you have a 100 entry circular array (that is, when you reach the end of the array you start filling from the bottom again, so you keep the last 100 days' worth of data) and you know what the date is &lt;em&gt;today&lt;/em&gt; you can count backwards from today to work out what date each entry is.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T16:06:30.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17571" PostTypeId="1" CreationDate="2015-11-07T16:12:32.960" Score="3" ViewCount="1328" Body="&lt;p&gt;I'm managing to upload a sketch to the ESP8266 01. I have been researching on internet but I'm not able to get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have installed the libraries for Arduino IDE and my circuit is the ESP powered by 9V converted to 3.3V using a LD 3.3 converter. I tested the voltages and works fine. Also the led in ESP is on (red). &#xA;To connect to the computer I'm using a TTL USB cable without vcc connected only for tx and rx.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands for the ESP works fine (AT commands), but when I try to upload a sketch it shown the following error: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;espcomm_open failed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I also have connected to GP0 (ESP) a button to ground. The circuit is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9V battery --&gt; 3.3V converter --&gt; ESP---&gt; TTL&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows about that error and why could be? Because the AT commands works fine. Maybe I need to provide more information but not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to do this tutorial:&#xA;&lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/esp8266-temperature-slash-humidity-webserver.pdf&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/downloads/pdf/esp8266-temperature-slash-humidity-webserver.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem that I have following that tutorial is that in Arduino IDE, I cannot setup esptool as programmer, because isn't there. I loaded the same library for esp&lt;/p&gt;&#xA;" OwnerUserId="14050" LastActivityDate="2016-07-15T02:57:19.433" Title="Uploading sketch to ESP8266" Tags="|usb|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17573" PostTypeId="1" CreationDate="2015-11-07T18:00:22.527" Score="0" ViewCount="5395" Body="&lt;p&gt;I have a 4 dipswitch to get a 1 or a 0, try to get that into a string and from that get a decimal, therefor if I get for example a 0011 a 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so, I know that from the variations of 0000 to 1111 is a decimal from 0 to 15, I already have my string but how do I convert the &quot;binary string&quot; to decimal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to get the string I'm using this (the I is at 5because there is where is the dipswitch):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      for(int i = 5; i &amp;lt;= 9; i++){    &#xA;           Serial.println(digitalRead(i));&#xA;           Dstate = Dstate + digitalRead(i);&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14483" LastActivityDate="2016-02-05T20:54:38.073" Title="Getting a binary string and convert it to decimal" Tags="|arduino-nano|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17574" PostTypeId="1" AcceptedAnswerId="17577" CreationDate="2015-11-07T18:37:47.310" Score="0" ViewCount="96" Body="&lt;p&gt;Following one of the &lt;a href=&quot;http://www.tested.com/tech/robots/456466-know-your-arduino-guide-most-common-boards/&quot; rel=&quot;nofollow&quot;&gt;article&lt;/a&gt; from 2013 : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Before you start hammering that “add to shopping cart” button, note&#xA;  that the general impression around the web seems to be that the&#xA;  Leonardo still has a few bugs that need ironing out, and isn’t quite&#xA;  as beginner friendly as the Uno. For builders already familiar with&#xA;  Arduino, this is the better deal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The question is if Leonardo is still buggy and may cause any confusion to newbie Arduino programmers. Furthermore, Leonardo doesn't have removable chip, so how can one transfer the project into a separate processor and use Arduino to the other project?&lt;/p&gt;&#xA;" OwnerUserId="14666" LastActivityDate="2015-11-07T19:35:34.793" Title="Arduino Leonardo bugs and lack of removable microcontroller" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17575" PostTypeId="2" ParentId="17573" CreationDate="2015-11-07T18:41:07.820" Score="1" Body="&lt;p&gt;What you want are the bit-shifting operators &amp;lt;&amp;lt; and &gt;&gt;, and the OR operator |:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 4; i++) {&#xA;    Serial.println(digitalRead(5 + i));&#xA;    Dstate = Dstate | (digitalRead(5 + i) &amp;lt;&amp;lt; i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll notice I changed the loop so it runs from 0 to 3 instead of 5 to 9 - it makes other parts easier if you start counting from 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Dstate = Dstate | (digitalRead(5 + i) &amp;lt;&amp;lt; i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is where all the magic happens.  Let's break it down:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalRead(5 + i)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That of course gives you a 0 or 1 for pins 5, 6, 7 and 8 in turn.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt; i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That shifts the value returned by &lt;code&gt;digitalRead()&lt;/code&gt; left &lt;code&gt;i&lt;/code&gt; bits.  For instance, if &lt;code&gt;digitalRead()&lt;/code&gt; returns 1 and &lt;code&gt;i&lt;/code&gt; is 0 then &lt;code&gt;1&lt;/code&gt; is left shifted 0 times so remains as 0b0001.  If &lt;code&gt;i&lt;/code&gt; is 1 then it left shifts one bit, so the value becomes &lt;code&gt;0b0010&lt;/code&gt;.  If &lt;code&gt;i&lt;/code&gt; is 2 then it shifts two bits, so you get &lt;code&gt;0b0100&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally the result is combined with the current value of &lt;code&gt;Dstate&lt;/code&gt; with OR, so the four values basically get laid over the top of each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So say you have the four switches in the positions ON-OFF-ON-OFF and &lt;code&gt;Dstate&lt;/code&gt; starts off as 0, then the sequence would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i = 0, digitalRead = 1, shifted = 0b0001, OR = 0b0001&#xA;i = 1, digitalRead = 0, shifted = 0b0000, OR = 0b0001&#xA;i = 2, digitalRead = 1, shifted = 0b0100, OR = 0b0101&#xA;i = 3, digitalRead = 0, shifted = 0b0000, OR = 0b0101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T18:41:07.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17576" PostTypeId="2" ParentId="17566" CreationDate="2015-11-07T19:12:39.290" Score="1" Body="&lt;p&gt;Check if the driver is loaded, in Terminal type: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lsmod | grep  ftdi_sio&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you get no answer then it's not loaded, load it using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo modprobe ftdi_sio&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-07T19:12:39.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17577" PostTypeId="2" ParentId="17574" CreationDate="2015-11-07T19:35:34.793" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The question is if Leonardo is still buggy &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and may cause any confusion to newbie Arduino programmers. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Definitely.  The whole way the Leonardo works is very different to the likes of the Uno. Transitioning from one to the other, if you don't know what the differences really mean, can be confusing.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Furthermore, Leonardo doesn't have removable chip, so how can one transfer the project into a separate processor and use Arduino to the other project?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You build your circuit on a PCB and you provide an ICSP header.  ICSP stands for &lt;em&gt;I&lt;/em&gt;n &lt;em&gt;C&lt;/em&gt;ircuit &lt;em&gt;S&lt;/em&gt;erial &lt;em&gt;P&lt;/em&gt;rogramming.  You then use a hardware programmer to install either the Leonardo bootloader, which can then be used to install sketches through USB, or install a sketch direct without the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if you're making thousands of them you send your code to Atmel and they burn it to the chip in the factory for you - at a price of course.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T19:35:34.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17578" PostTypeId="1" CreationDate="2015-11-07T20:13:43.790" Score="0" ViewCount="2180" Body="&lt;p&gt;How can I make my program so that every half hour LED lights on and work for 5 minutes and than go off and the process should repeat  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made code but it does not works. Can someone help me?  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(8,OUTPUT);&#xA;&#xA;}&#xA;void loop() {&#xA;  digitalWrite(8,HIGH);&#xA;  delay(300000);&#xA;  digitalWrite(8,LOW);&#xA;  delay(1800000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14668" LastEditorUserId="26717" LastEditDate="2017-05-07T08:37:42.477" LastActivityDate="2017-05-07T08:37:42.477" Title="Turning on led every half hour" Tags="|arduino-uno|led|timing|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17579" PostTypeId="2" ParentId="17578" CreationDate="2015-11-07T20:51:20.837" Score="1" Body="&lt;p&gt;I see that the code is OK,&lt;br&gt;&#xA;are you sure that the led pis is 8 ?&lt;br&gt;&#xA;what is your input voltage ? (is it between 7 to 12 ?)&lt;br&gt;&#xA;did you tried lower time values ? (like 1:2 minuts ?)&lt;br&gt;&#xA;if you answer to all of these questions is &quot;yes&quot; then probably the arduino board is broken.&lt;/p&gt;&#xA;" OwnerUserId="14669" LastActivityDate="2015-11-07T20:51:20.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17580" PostTypeId="1" AcceptedAnswerId="17581" CreationDate="2015-11-07T21:02:55.253" Score="0" ViewCount="43" Body="&lt;p&gt;according to &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; the recommended input voltage is between 7 and 12 volts.&lt;br&gt;&#xA;The question is what is the difference between providing 7 volts(minimum recommended volts) and 12 volts(maximum recommended volts) ?.&lt;/p&gt;&#xA;" OwnerUserId="14669" LastActivityDate="2015-11-07T21:14:58.677" Title="what is the difference between providing 7 volts or 12 volts to arduino uno?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17581" PostTypeId="2" ParentId="17580" CreationDate="2015-11-07T21:14:58.677" Score="2" Body="&lt;p&gt;The amount of heat dissipated by the voltage regulator.  The higher the voltage you supply the hotter the regulator will get.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-07T21:14:58.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17582" PostTypeId="2" ParentId="17578" CreationDate="2015-11-07T22:34:52.550" Score="1" Body="&lt;p&gt;You need to make sure that the LED is connected with the right polarity, you need to connect the negative to Ground and the positive to the digital pin 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the led by connecting 3.3v and GND so you are sure that the led is not broken.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-11-07T22:34:52.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17583" PostTypeId="2" ParentId="17542" CreationDate="2015-11-07T22:46:49.043" Score="0" Body="&lt;p&gt;It seems like that module is used to connect the 4 wire load cell, but on the internet I found other schematics that might help you out how to wire it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one way (&lt;a href=&quot;http://i46.tinypic.com/30j0d2t.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://i46.tinypic.com/30j0d2t.jpg&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xYqBx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xYqBx.jpg&quot; alt=&quot;Schematic A&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise try this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9vDyI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9vDyI.jpg&quot; alt=&quot;Schematic B&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not an expert on load cells but it seems like you just need to give it a try and see if it works.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastEditorUserId="6936" LastEditDate="2016-03-01T20:09:10.883" LastActivityDate="2016-03-01T20:09:10.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17584" PostTypeId="2" ParentId="17578" CreationDate="2015-11-07T22:51:57.133" Score="2" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Test the LED: Connect it between +5v and ground &lt;em&gt;with&lt;/em&gt; its current-limiting resistor. Make sure the cathode is connected to ground and not the other way round. Inside the plastic bubble are two tiny bits of metal. The larger one is the cathode. Does it light? If not, the LED is faulty or the resistor is too high.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Reconnect the LED to pin 8, which is physical pin #14. (In case you got confused and used physical pin 8, no harm was done - physical pin 8 is another ground!) Reduce the delay times to 1 second on, 1 second off. Again be sure to connect its cathode side to ground. Does it blink? If not, perhaps Arduino's pin 8 driver is faulty.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try the same thing on a different pin (adjusting your code, of course). If it still doesn't blink, there is probably an issue with either the MCU chip or the power you're supplying to it. Assuming you used the board's +5v and ground in test (1.), then the power is OK and the chip is likely the cause.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-11-07T22:51:57.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17585" PostTypeId="1" AcceptedAnswerId="17615" CreationDate="2015-11-08T00:05:04.780" Score="0" ViewCount="250" Body="&lt;p&gt;First we set fuse bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c usbasp -p atmega328p -U lfuse:w:0xFF:m -U hfuse:w:0xDF:m -U efuse:w:0x07:m # same for atmega168&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the following examples we use the following commands to compile and burn all the programs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -Os -mmcu=atmega328p -c -o serial.o serial.c&#xA;avr-ld -o serial.elf serial.o&#xA;avr-objcopy -O ihex serial.elf serial.hex&#xA;avrdude -c usbasp -p atmega328p -U flash:w:serial.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Let us burn the following program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;void main (void) {&#xA;  DDRB |= (1&amp;lt;&amp;lt;PB5);&#xA;  PORTB |= (1&amp;lt;&amp;lt;PB5);&#xA;  while (1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It makes the led to be on constantly. And it stays so for infinite period of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we burn the following program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#define BAUD 9600&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;char data = 0;&#xA;void main(void) {&#xA;  // Initialize USART:&#xA;  #include &amp;lt;util/setbaud.h&amp;gt; &#xA;  UBRR0H = UBRRH_VALUE; // set the speed (Higher bit)&#xA;  UBRR0L = UBRRL_VALUE; // set the speed (Lower bit)&#xA;  UCSR0B |= (1&amp;lt;&amp;lt;RXEN0); // enable receiver&#xA;  UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00); // set mode (8N1)&#xA;  DDRB |= (1&amp;lt;&amp;lt;PB5); // enable output on pin PB5 (default led on arduino)&#xA;  while(1) {&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0))); // wait until a byte is received&#xA;    data = UDR0; // read it&#xA;    if (data) PORTB |= (1&amp;lt;&amp;lt;PB5); // set the led on&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then we open a terminal (9600,8N1) and press several keys, until the led turns off.&#xA;Now we burn the first program again and the led is constantly blinking. The reason for this is that watchdog times gets started when we press the keys in terminal. But why and when WDT gets started? How to make so that it will not start?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted also that we can disable the blinking only with complete poweroff/poweron - only after that the led lights constantly without blinking, as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This happens on atmega168 and atmega328p, 100% reproducible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avr-gcc version 4.8.1 avrdude version 6.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; bootloader is not used at all.&lt;/p&gt;&#xA;" OwnerUserId="14631" LastEditorUserId="37523" LastEditDate="2019-11-26T18:20:56.733" LastActivityDate="2019-11-26T18:20:56.733" Title="Why atmega168/328p starts to reset?" Tags="|serial|atmega328|avrdude|avr-gcc|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17586" PostTypeId="1" AcceptedAnswerId="17587" CreationDate="2015-11-08T00:40:39.840" Score="0" ViewCount="1300" Body="&lt;p&gt;I have a PIR sensor which sometimes give false readings and I have added a ultrasonic sensor to compensate for that. I think my algorithm can work, however currently it is very prone to give false positives.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Algorithm theory&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;My idea is to have an arduino which will obtain six samples and wait 25 milliseconds between each sample and then calculate the &lt;a href=&quot;http://www.mathsisfun.com/data/standard-deviation.html&quot; rel=&quot;nofollow&quot;&gt;variance&lt;/a&gt;. If the variance exceeds a specific threshold, which I have set to a thousnad, it will send an motion event over the serial bus.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem with the algorithm&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Ultrasonic sensors can give faulty responds which usually isn't hard to detect. My HC-SR04 sensor can only accurately read the distance between 2 cm and 400 cm. All the faulty readings are usually way over 400 cm or lower than 2 cm, therefore if is not within these boundaries a new try will be made to get a value within the boundaries, if it fails for three times it will assume the distance is exactly 400 cm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is redundant to wait for more than 23280 µs because 400*29.1*2 is the corresponding microseconds it would take for the distance to be 400 cm. &lt;code&gt;pulseIn&lt;/code&gt; has a timeout value which can be used for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory this sounds great to me but very often this algorithm will erroneously send motion events. My belief for this is that when the ultrasonic sensor transmitts a wave and wait for it come back, &lt;code&gt;pulseIn&lt;/code&gt; will timeout and retry and yet again ask the sensor to send a wave. This happens before the first wave has come back thus the distance will be incorrect and vary from time to time making the variance higher than my threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the distance is much lower than 4 metres my algorithm works very well.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I tried&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I figured I might be able to block for some time until the &lt;em&gt;echo&lt;/em&gt; pin on the ultrasonic sensor turns low or a time of 100ms has passed. The code hanged and I couldn't communicate with my arduino any more. I can't see the problem with my code to obtain the distance pursuant to the ultrasonic sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(tries=3;tries;--tries) {&#xA;  digitalWrite(TRIG_PIN), LOW); // Set trigger pin low.&#xA;  delayMicroseconds(2); // Let signal settle.&#xA;  digitalWrite(TRIG_PIN, HIGH); // Set trigger pin high.&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(TRIG_PIN, LOW); // Ping has now been sent.&#xA;  unsigned long duration = pulseIn(ECHO_PIN, HIGH, 23280); // Duration is in microseconds&#xA;  unsigned long time = micros();&#xA;  while(!(PINB &amp;amp; 0b00000010)) { // ECHO_PIN is PB1 or digital pin 9&#xA;    if((micros() - time) &amp;gt;= 100000) {&#xA;      continue;&#xA;    }&#xA;  }&#xA;  if(duration &amp;gt;= 116L &amp;amp;&amp;amp; duration &amp;lt;= 23280L) { // Is duration within boundaries?&#xA;    return ((float)(duration)/2.0) / 29.1;&#xA;  }&#xA;}&#xA;return 400.0f;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just blocks my program indefinently and I had to upload a new program removing that code for my arduino to respond again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question boils down to: how can I resolve this issue where my algorithm very frequently sends motion events erroneously? Is there a better way to detect motion with an ultrasonic sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;EDIT:&lt;/strong&gt; I was really tired when I wrote the code above and Majenko corrected me, I changed the code for this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(tries=3;tries;--tries) {&#xA;  digitalWrite(TRIG_PIN), LOW); // Set trigger pin low.&#xA;  delayMicroseconds(2); // Let signal settle.&#xA;  digitalWrite(TRIG_PIN, HIGH); // Set trigger pin high.&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(TRIG_PIN, LOW); // Ping has now been sent.&#xA;  unsigned long duration = pulseIn(ECHO_PIN, HIGH, 23280); // Duration is in microseconds&#xA;  unsigned long time = micros();&#xA;  while(PINB &amp;amp; 0b00000010) { // ECHO_PIN is PB1 or digital pin 9&#xA;    if((micros() - time) &amp;gt;= 100000) {&#xA;      goto retry;&#xA;    }&#xA;  }&#xA;  if(duration &amp;gt;= 116L &amp;amp;&amp;amp; duration &amp;lt;= 23280L) { // Is duration within boundaries?&#xA;    return ((float)(duration)/2.0) / 29.1;&#xA;  }&#xA;  retry:&#xA;  continue;&#xA;}&#xA;return 400.0f;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14671" LastEditorUserId="14671" LastEditDate="2015-11-08T09:44:46.200" LastActivityDate="2015-11-08T11:05:27.620" Title="Algorithm to detect motion using ultrasonic sensor" Tags="|sensors|atmega328|algorithm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17587" PostTypeId="2" ParentId="17586" CreationDate="2015-11-08T01:08:03.873" Score="1" Body="&lt;p&gt;The main blocking part of your code is this bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(!(PINB &amp;amp; 0b00000010)) { // ECHO_PIN is PB1 or digital pin 9&#xA;  if((micros() - time) &amp;gt;= 100000) {&#xA;    continue;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is saying &quot;While the echo pin is low, check the time.  If too much time has passed then carry on with the loop&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically that will loop until the echo pin goes high, regardless of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;continue&lt;/code&gt; command means to jump back to the beginning of the loop that it's in, be that a while, for, or do loop.  In this case it jumps back to the beginning of the while loop it's in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should consider using &lt;code&gt;break&lt;/code&gt;, which means &quot;Terminate this loop and carry on with what comes next&quot;.  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Ultrasound sensing with &lt;code&gt;pulseIn()&lt;/code&gt;, while simple to perform is rarely particularly accurate.  Any interrupts that occur during the sensing will affect the outcome, and it's only as accurate as the micros() function allows it to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a more precise and reliable measurement you should consider using one of the &lt;em&gt;Input Capture&lt;/em&gt; modules in the ATMega.  I don't know if there is a library to do it off hand, but programming it through the registers shouldn't be that difficult - just read the datasheet to find out how it all works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Briefly the operation of IC is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Send trigger pulse&lt;/li&gt;&#xA;&lt;li&gt;Start IC timer counting&lt;/li&gt;&#xA;&lt;li&gt;Pulse arrives&lt;/li&gt;&#xA;&lt;li&gt;IC stops counting automatically and interrupt is triggered&lt;/li&gt;&#xA;&lt;li&gt;Read counter value and convert to microseconds.&lt;/li&gt;&#xA;&lt;li&gt;Set flag to indicate a result is available&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The timing source is the main system clock and counting happens in the background completely parallel to the operation of the CPU, so nothing can interrupt it or delay it. Even if the execution of the IC interrupt routine is delayed by another interrupt running the counter value will have already stopped incrementing, so it will have been &quot;captured&quot; and give the correct result every time.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-08T11:05:27.620" LastActivityDate="2015-11-08T11:05:27.620" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17588" PostTypeId="1" AcceptedAnswerId="17601" CreationDate="2015-11-08T02:16:49.340" Score="0" ViewCount="79" Body="&lt;p&gt;Can I use GPS Module ET314AC with Arduino Mega? Here is the datasheet of ET314AC            &lt;a href=&quot;https://www.google.com.pk/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=4&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CC0QFjADahUKEwil6qrq4vnIAhVBhRoKHQePBOM&amp;amp;url=http%3A%2F%2Fwww.szstoton.com%2Fres%2Fstotongps%2Fpdres%2F201203%2F20120320163340251.pdf&amp;amp;usg=AFQjCNFOZ31eexhFJWxNYqHvN-QWt4GoEA&quot; rel=&quot;nofollow&quot;&gt;ET314AC Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14604" LastActivityDate="2015-11-08T18:05:46.510" Title="Using GPS Module ET314AC With arduino Mega" Tags="|arduino-mega|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17589" PostTypeId="2" ParentId="17476" CreationDate="2015-11-08T02:55:58.817" Score="1" Body="&lt;p&gt;Part seems to be broken; voltage is unusually high. &lt;/p&gt;&#xA;" OwnerUserId="13748" LastActivityDate="2015-11-08T02:55:58.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17590" PostTypeId="1" CreationDate="2015-11-08T03:10:33.053" Score="4" ViewCount="63574" Body="&lt;p&gt;I am attempting to connect and use an ESP8266 board with my Arduino nano v3.0 and I am not have much luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read a bunch of tutorials and articles, the most recent is &lt;a href=&quot;http://elektro-blogger.blogspot.co.nz/2015/07/arduino-and-esp82666.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://elektro-blogger.blogspot.co.nz/2015/07/arduino-and-esp82666.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected it like below and am using some simple code to try and get it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6j8ZG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6j8ZG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(10, 11);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600);&#xA;&#xA;  Serial.flush();&#xA;&#xA;  esp8266.print(&quot;AT+RST\r\n&quot;); // reset for esp8266&#xA;  delay(500);&#xA;  esp8266.flush();//clear serial1&#xA;  // Check AT&#xA;  esp8266.print(&quot;AT&quot;); // reset for esp8266&#xA;  esp8266.print(&quot;AT+CIFSR\r\n&quot;);// learn the ip which token for esp8266&#xA;  delay(500);&#xA;  if (esp8266.find(&quot;ready&quot;))&#xA;  {&#xA;    esp8266.flush();&#xA;    esp8266.print(&quot;AT+CIFSR\r\n&quot;);&#xA;    delay(500);&#xA;    Serial.println(&quot;CIHAZ IP ADRESI:&quot; + esp8266.readString()); // print esp8266 ip&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;there is no internet connection&quot;);&#xA;  }&#xA;  esp8266.print(&quot;AT+CIPMUX=1\r\n&quot;);//ser mux 1 so we want to connect as multiple users&#xA;  delay(500);&#xA;  if (esp8266.find(&quot;OK&quot;))&#xA;  {&#xA;    Serial.println(&quot;Mux ok&quot;);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;MUX failed&quot;);&#xA;  }&#xA;  esp8266.print(&quot;AT+CIPSERVER=1,23\r\n&quot;);// set esp8266 as server&#xA;  delay(500);&#xA;  if (esp8266.find(&quot;OK&quot;))&#xA;  {&#xA;    Serial.println(&quot;SERVER started&quot;);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;SERVER failed&quot;);&#xA;  }&#xA;&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;  if (esp8266.available())&#xA;  {&#xA;    Serial.print(esp8266.readString()); // get message which comes from clients.&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14673" LastActivityDate="2017-11-25T20:55:43.380" Title="Arduino Nano v3.0 with ESP8266" Tags="|arduino-ide|arduino-nano|esp8266|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17591" PostTypeId="1" CreationDate="2015-11-08T05:19:09.647" Score="0" ViewCount="1638" Body="&lt;p&gt;I'm working on a project that includes an ESP8266 (requires 3.3v input (250 mA peak)) and a HC-SR04 (requires 5v 20 mA peak). I'm making it battery/solar powered. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to keep costs down as well as make a system that works reliably and has good longevity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll be waking the device every 15 minutes and keeping it in deep sleep at the other times. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Originally I was going to use a battery source over 6v, like a 6 cell AA rechargeable battery pack, a 10v or so solar panel, and a breadboard type voltage regulator that conveniently provides 3.3v and 5v on the same board. This seems to waste a decent amount of power though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I'm looking into using a 2 AA rechargeable NiMH batteries, a 5v solar panel, a 3.3v step up voltage booster, and a 5v step up voltage booster. 5v step up voltage boosters are everywhere and cheap because of their uses for portable cell phone chargers. 3.3v step up voltage boosters on the other hand are more expensive and harder to find. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking for any advice or affirmation that I'm on the right path. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11556" LastActivityDate="2021-06-30T04:03:15.297" Title="Battery Solution for ESP8266 and HC-SR04" Tags="|esp8266|battery|solar|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17592" PostTypeId="2" ParentId="1391" CreationDate="2015-11-08T05:31:28.807" Score="2" Body="&lt;p&gt;I don't think your batteries were too low in current capacity, your delay time is not too short, at 10 +10 ms per clock pulse, you are only talking about 50 steps per second, that's not all that fast. I've written programs where I have had to go to microseconds to get enough rpm out of my stepper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, take everything out of your loop except the digitalwrite high, delay digitalwrite low and delay lines. Then the program &quot;should&quot; just spin the motor continuously in one direction. That way you are sure you don't have a logic issue.&#xA;Second, did you check to see if you didn't hook up pin 12 and 13 backwards, such that you are telling the driver to change direction every 10 ms instead of stepping? The sound it makes would be more like a buzz or vibration, usually a soft, staticy hiss is when the motor is enabled, but not getting a step pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, this post is about 18 months old, it is considerate and helpful to others to explain how you solved the problem (assuming you figured it out).&lt;/p&gt;&#xA;" OwnerUserId="14675" LastActivityDate="2015-11-08T05:31:28.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17593" PostTypeId="1" CreationDate="2015-11-08T12:39:41.633" Score="0" ViewCount="237" Body="&lt;p&gt;I would like to use one of the nice libraries like :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;JEELIB &lt;/li&gt;&#xA;&lt;li&gt;ENERLIB &lt;/li&gt;&#xA;&lt;li&gt;SLEEP_N0M1&lt;/li&gt;&#xA;&lt;li&gt;NARCOLEPTIC &lt;/li&gt;&#xA;&lt;li&gt;ADAFRUITSLEEPY_DOG &lt;/li&gt;&#xA;&lt;li&gt;LOW_POWER_MASTER&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;But to use a X second interval of sleeping and in the same time to enable the option of an Interrupt on pin2 that will get me out of all this sleepy mode vector if there will be interrupt ! which library is better and easier for this situation? &lt;/li&gt;&#xA;&lt;li&gt;when I want more then 8 second , what is the mining of doing 2x8s when they wrote it in some of those libraries -what should it mean to do ?&lt;/li&gt;&#xA;&lt;li&gt;Is there an option to enable the interrupt for a wake up from the sleep not only by a LOW_mode but also by a CHANGE_mode of the pin2 ??&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you very much in advanced @!&lt;/p&gt;&#xA;" OwnerUserId="11412" LastEditorUserId="2881" LastEditDate="2015-11-08T17:18:59.973" LastActivityDate="2015-11-09T23:43:41.257" Title="Using a library of sleeping with a combination of the WD and a physical INTERRUPT" Tags="|library|interrupt|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17594" PostTypeId="1" AcceptedAnswerId="17596" CreationDate="2015-11-08T13:27:40.350" Score="0" ViewCount="70" Body="&lt;p&gt;I am making a game of X and O’s and ran out of pins on the Arduino. After searching on the internet I found out about connecting it in a grid connecting all the anodes in columns and the different colours in rows but I don't know how to connect the anodes so it only turns on only one of the LEDs rather than the other 2 in the grid if they are all connected to ground. The wires I am unsure to connect are the orange ones in the diagram below (bottom left corner). Note the Red on the RGBs are not used so don't need to be connected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8G5Oq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8G5Oq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3733" LastActivityDate="2015-11-08T13:42:34.157" Title="Unsure how to connect the anode in this circuit" Tags="|arduino-uno|wires|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17595" PostTypeId="2" ParentId="17591" CreationDate="2015-11-08T13:32:08.017" Score="1" Body="&lt;p&gt;A time a go when searching for some circuit to provide power to ESP and also being capable of charging batteries I came across this reply &lt;a href=&quot;https://electronics.stackexchange.com/questions/36930/some-advice-on-charging-circuit-used-in-simple-ups/36938#36938&quot;&gt;here&lt;/a&gt;. Is intended for usb charger/Li-Ion batteries but maybe it could suit your needs too and be adapted. In the output the circuit presented there, you could use some LDO like  &lt;a href=&quot;http://ww1.microchip.com/downloads/en/devicedoc/22056b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP1825S&lt;/a&gt; (or even the MCP1825 with extra information possibilities). Never test the circuit yet, so can not provide any good answer about how long it provides juice to ESP.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-11-08T13:32:08.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17596" PostTypeId="2" ParentId="17594" CreationDate="2015-11-08T13:42:34.157" Score="1" Body="&lt;p&gt;Firstly, you have made the classic rookie mistake with your circuit regarding your LED current limiting resistors.  You have one per LED group instead of one per LED within a group.  The arrangement you have at the moment means that &lt;em&gt;at best&lt;/em&gt; some LEDs will be dim or not light at all, and &lt;em&gt;at worst&lt;/em&gt; will result in LEDs burning out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There should be a resistor in every red, green and blue wire in your diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for what to do with the three orange wires (once you have re-arranged the resistors) they connect to three spare IO pins on the Arduino - you then turn each column on or off as you need - only one column is on at a time.  If you need more than 20mA for a column (which is highly likely with up to 9 LEDs on at a time) then those lines should be connected to either +5V or GND (depending on if you are common anode or common cathode) via transistors and the transistors should be switched by the IO pins.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-08T13:42:34.157" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17597" PostTypeId="2" ParentId="17593" CreationDate="2015-11-08T14:15:08.373" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Best&quot; is completely subjective. I've used Narcoleptic myself. it's easy to use and somewhat limited. For the needs of my project, it served well. You'll need to review the libraries' source code and descriptions to decide which library will best serve your application.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Watchdog timer has a maximum interval of 8 seconds. To sleep longer, you'll need a routine that counts enough 8 second sleeps, plus lesser sleep periods, to make up the total sleep time you want. There are other timers you can use, but not in Power Down sleep mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;See section 10, &quot;Power Management and Sleep Modes&quot; of the ATmega328p datasheet (or the datasheet for the chip your Arduino uses). There is a table of wake-up sources for each sleep mode. It says that, except from Idle mode, only a level-triggered interrupt can wake the chip. But note that section 10.5 says a pin-change interrupt can wake the CPU. It appears that either kind can wake it but &quot;the required level must be held long enough for the MCU to complete the wake-up to trigger the level interrupt.&quot; It does not mention the (obviously transient) pin-change interrupt. You may need to experiment.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...I cant get a sleep for more than 8 second but I can only get to a sleeping mode twice and by that to get almost a 16 second of sleeping ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, the longest Watchdog timer period is 8 seconds.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I still didn't understand if there is an easy possible to get into a sleep with a routine periods of WD wakings and in the same time enabling a physical interrupt on pin2 that works parallel ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From my reading of the datasheet, yes, you can use both timers in parallel. But it wasn't clear to me whether a pin-change can both wake the CPU and cause an interrupt (that is, vector into your interrupt routine). A level-interrupt can, if the level is held long enough (I believe they said 4 CPU cycles would be required).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-11-09T23:43:41.257" LastActivityDate="2015-11-09T23:43:41.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17599" PostTypeId="2" ParentId="17585" CreationDate="2015-11-08T17:07:04.493" Score="1" Body="&lt;p&gt;WDT settings will remain unchanged, even after a reset. So the timer will keep running and therefore keep resetting the device. Which causes the blinking. Power cycling will clear the WDT settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS I didn't read the code, as uncommented register writes are pretty much unreadable.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-08T17:07:04.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17600" PostTypeId="2" ParentId="17590" CreationDate="2015-11-08T18:00:47.633" Score="3" Body="&lt;p&gt;The Esp8266 module has different firmware, the old one was running at 9600 and the new one is running at 115200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to upload this code on  your arduino Nano and send AT commands over the Serial monitor of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you send AT it should returns &quot;OK&quot;, if not, try to swap RX to TX and try to play around with the baudrate 9600, 57600, 115200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be that your Wifi module doesnt have any firmware loaded which might need to be done.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial wifi(10,11); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;Serial.begin(9600); // FTDI&#xA;wifi.begin(9600); // GPS; 9600 first time, 38400 second time&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;if (Serial.available())&#xA;wifi.write(Serial.read());&#xA;if (wifi.available())&#xA;Serial.write(wifi.read());&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-11-08T18:00:47.633" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17601" PostTypeId="2" ParentId="17588" CreationDate="2015-11-08T18:05:46.510" Score="1" Body="&lt;p&gt;yes you can, the datasheet is saying that you can read from a serial port which is what you want to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting the serial port to TX and RX pins of the Arduino, ground and power, you should be able to talk to the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cant find a breakboard for this module so I suppose you are going to solder it or you can give us the link where you bought it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you to try with TinyGPS library to decode the data, after you are sure that the module is talking to the Arduino correctly.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-11-08T18:05:46.510" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17602" PostTypeId="1" AcceptedAnswerId="17603" CreationDate="2015-11-08T08:04:54.117" Score="3" ViewCount="4618" Body="&lt;p&gt;I wish to use an arduino like &lt;a href=&quot;http://www.snapdeal.com/product/arduino-uno-r3-board-with/566147335&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; with a 12v solenoid lock like &lt;a href=&quot;http://www.ebay.in/itm/331401195916?ssPageName=STRK:MEWNX:IT&amp;amp;_trksid=p3984.m1439.l2649&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. How can I do this. I am told that using &lt;a href=&quot;https://www.sparkpcb.com/development/l293-d-dc-motor-driver-board.html&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; might work, but I am also thinking I can use a transistor's amlification to do that. Can you tell which one is better and if transistor, how to do that?&lt;/p&gt;&#xA;" OwnerUserId="12100" OwnerDisplayName="ADG" LastEditorUserId="13669" LastEditDate="2015-11-11T10:39:02.950" LastActivityDate="2015-11-11T10:39:02.950" Title="Using 5V arduino with 12v solenoid lock" Tags="|transistor|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17603" PostTypeId="2" ParentId="17602" CreationDate="2015-11-08T10:33:21.300" Score="4" Body="&lt;p&gt;By sheer luck your lock solenoid looks very similar to &lt;a href=&quot;https://www.adafruit.com/products/1512&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; (similar spec too &quot;Draws 650mA at 12V&quot;) and they have a working circuit for it &lt;a href=&quot;https://learn.adafruit.com/secret-knock-activated-drawer-lock&quot; rel=&quot;nofollow noreferrer&quot;&gt;over here&lt;/a&gt; so look at that and see what they used to drive it. &lt;a href=&quot;https://learn.adafruit.com/secret-knock-activated-drawer-lock/parts-and-tools&quot; rel=&quot;nofollow noreferrer&quot;&gt;Apparently&lt;/a&gt; it's a TIP120, so the peak/draw current is probably higher than that ballpark figure, which I suspect is for the hold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5ptTr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5ptTr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PNupP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PNupP.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overengineering the transistor by an order of magnitude or so (for a poorly spec'd solenoid part) ensures it doesn't go pop so easily. Also, a Darlington like TIP120 is very easy to drive from the arduino or some other microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/remote-controlled-door-lock-using-a-fingerprint-sensor-and-adafruit-io/setting-up-the-electronic-door-lock&quot; rel=&quot;nofollow noreferrer&quot;&gt;A similar project&lt;/a&gt; using the same solenoid lock used an IRLB8721 (power MOSFET) instead, which is even more beefy in terms of load current it can handle.&lt;/p&gt;&#xA;" OwnerUserId="13669" OwnerDisplayName="Respawned Fluff" LastEditorUserId="13669" LastEditDate="2015-11-08T19:23:00.733" LastActivityDate="2015-11-08T19:23:00.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17604" PostTypeId="2" ParentId="17590" CreationDate="2015-11-08T19:27:38.803" Score="2" Body="&lt;p&gt;Remember that ESP8266 Uses 3.3v logic and arduino 5v. So use a voltage divider to get 3.3v at esp8266 rx pin. Also esp8266 must be connected rx-&gt;rx tx-&gt;tx to communicate with pc and rx-&gt;tx tx-&gt;rx to communicate with arduino.&lt;/p&gt;&#xA;" OwnerUserId="14684" LastEditorUserId="20413" LastEditDate="2016-04-25T07:24:41.027" LastActivityDate="2016-04-25T07:24:41.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17605" PostTypeId="1" CreationDate="2015-11-08T20:47:02.233" Score="0" ViewCount="197" Body="&lt;p&gt;I am in a First Year Design class, and we are supposed to be making an autonomous robot. After hooking up some wind speed and temperature sensors to calibrate, I plugged in to my laptop (we have 2 arduino nanos) and ran a temperature code. I got the reading, but smelled something burning. Nothing was smoking, but I've found that when I plug my arduinos into my laptop, the light and the code indicate that they are not connected. This is odd because when I plug in the batteries, they show that the proper voltage is coming through, but they will still not connect to the laptop. Is it a problem with the micro-usb port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included the code I'm using just in case that is cause for suspicion. It is notable that our instructors have written an API that allows us to code in Java for the arduinos.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public static void main (String[] args)&#xA;{&#xA;    robot = new ArduinoNano();&#xA;    robot2 = new ArduinoNano();&#xA;    robot.setPort(&quot;COM5&quot;);&#xA;    robot2.setPort(&quot;COM6&quot;);&#xA;    robot.connect();&#xA;&#xA;    int reading = getThermistorReading();&#xA;&#xA;    System.out.println(&quot;The probe read the value &quot; + reading);&#xA;    System.out.println(&quot;In volts: &quot; + (reading * (5.0/1023.0)));&#xA;    System.out.println();&#xA;&#xA;    double temperature = (reading - 855.02) / -7.563;   &#xA;&#xA;    System.out.println(&quot;Temperature: &quot; + temperature);&#xA;&#xA;}&#xA;&#xA;public static int getThermistorReading()&#xA;{&#xA;    int sum = 0;&#xA;    int readingCount = 10;&#xA;&#xA;    for (int i = 0; i &amp;lt; readingCount; i++)&#xA;    {&#xA;        robot.refreshAnalogPins();&#xA;        int reading = robot.getAnalogPin(3).getValue();&#xA;        sum += reading;&#xA;    }&#xA;&#xA;    return sum / readingCount;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="14686" OwnerDisplayName="Will P" LastEditorUserId="7631" LastEditDate="2015-11-12T08:55:53.130" LastActivityDate="2021-04-20T19:02:24.530" Title="What's Happened with my Arduino?" Tags="|serial|usb|hardware|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17606" PostTypeId="2" ParentId="17605" CreationDate="2015-11-08T22:35:36.517" Score="1" Body="&lt;p&gt;First, did the Arduino continue to respond and operate after you smelled the burning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just because there isn't smoke doesn't mean you didn't kill something on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Arduino is not responding, there are two possibilites I can think of:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Your port is not working so simply switch to a different USB port&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Somehow your laptop must have sent a large amount of amps/volts to the circuit and burned it out. If you have a multimeter you can use the sound setting to test whether or not wires are burned out, and if your nifty with an iron/heat gun, you can replace the part. Or you could buy a new one. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I9she.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I9she.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;If the connection is good, you will hear a small beep. Oh, and these things don't work if there's a resistor in the way.&lt;/p&gt;&#xA;" OwnerUserId="14687" LastActivityDate="2015-11-08T22:35:36.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17607" PostTypeId="1" CreationDate="2015-11-09T00:58:12.023" Score="0" ViewCount="841" Body="&lt;p&gt;I have a simple HTTP server that monitors a serial port and responds to HTTP requests by sending the value. The serial port constantly outputs data, so that apart from a brief moment when the device is initializing the Arduino always has data available. Once a value is retrieved from the RS232 connection it is stored in a buffer. The buffer is overridden when new values are received. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Occasionally the server does not respond to a request. Monitoring through Chrome developer tools reports net::ERR_CONNECTION_RESET&#xA;Could it be that the Arduino is busy with processing the serial port when the connection request is made? What I find very difficult to understand is that once in a while the code below will display &quot;Not available&quot;. This shouldn't happen because, as stated above, the buffer is always available.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;    client.println(&quot;Content-Type: text/html&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println(&quot;Cache-Control: no-cache, no-store, must-revalidate&quot;);&#xA;    client.println(&quot;Pragma: no-cache&quot;);&#xA;    client.println(&quot;Expires: 0&quot;);&#xA;    client.println(&quot;Refresh: 5&quot;);&#xA;    client.println();&#xA;    client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&#xA;    client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;    client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;    client.print(&quot;Value: &quot;);&#xA;    if (valueReady()) {&#xA;      client.println( getValue() );&#xA;    } else {&#xA;      client.println( &quot;Not available&quot; );&#xA;    }&#xA;    client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;    client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;Not available&quot; message is really confusing because that should only occur when the Arduino starts. valueReady() will only return false when power is first applied. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs on the Ethernet shield do not indicate that the Arduino is being reset, but it seems as if the sketch is periodically restarting. Is it possible for a buffer overrun to cause the Arduino to reboot?&lt;/p&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2016-04-07T05:08:26.483" Title="Arduino ethernet shield not responding to every request because it is busy" Tags="|arduino-uno|ethernet|rs232|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17608" PostTypeId="2" ParentId="17607" CreationDate="2015-11-09T01:54:50.660" Score="1" Body="&lt;p&gt;The delay was occurring because, in some cases, I was storing the RS232 data into a character array past the initialized length. It looks like it was causing the Arduino to reboot.&lt;/p&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2015-11-09T01:54:50.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17609" PostTypeId="1" CreationDate="2015-11-09T03:02:14.707" Score="1" ViewCount="3911" Body="&lt;p&gt;I have a dipswitch of 4 steps to get a binary number that will turn out to decimal from 0 to 15, So I need to get that number and make it the ammount of minutes to make something and also be aware of some input while the time runs out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was thinking of having a variable being equal to millis() and then dividing it by 60,000 which is a minute in millis and If I get an integer that must mean a minute has passed, the problem is that I don't know how to check if the result is an integer or a float. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;any advice?&lt;/p&gt;&#xA;" OwnerUserId="14483" LastEditorUserId="14766" LastEditDate="2015-11-13T18:35:42.200" LastActivityDate="2016-04-11T21:32:59.157" Title="Counting minutes in arduino" Tags="|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17611" PostTypeId="2" ParentId="5178" CreationDate="2015-11-09T09:00:14.333" Score="3" Body="&lt;p&gt;Nick Gammon's solution worked for me. I am adding the arduino code I used below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While Arduino Leonardo is connected to your computer, press its reset button. A COM for Arduino Leonardo appears under the Arduino IDE: Tools &gt; Port: &#xA;&lt;strong&gt;You should upload the code within a few seconds just after you press the reset button while the Leonardo COM is appearing.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is the code I used: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Start of Code &#xA;&#xA;void setup() {&#xA;  // make pin 2 an input and turn on the&#xA;  // pullup resistor so it goes high unless&#xA;  // connected to ground:&#xA;  Serial.begin(9600);&#xA;  pinMode(13,OUTPUT);&#xA;  digitalWrite(13,HIGH);&#xA;  pinMode(2, INPUT_PULLUP);&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  //if the button is pressed&#xA;  if(digitalRead(2)==LOW){&#xA;    //Send the message&#xA;    Keyboard.print(&quot;Hello!&quot;);&#xA;  }&#xA;  delay(1000);&#xA;  digitalWrite(13,HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(13,LOW);&#xA;}&#xA;&#xA;// End of Code &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14693" LastActivityDate="2015-11-09T09:00:14.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17612" PostTypeId="2" ParentId="17296" CreationDate="2015-11-09T09:50:53.243" Score="0" Body="&lt;p&gt;After lots and lots and changing values for resistors and capacitors and checking connections, i came to find out that my micro-controller ground was not at the same level as the ADCs ( i had already connected its ground with my circuit board ground but there was some kind of problem ). When i soldered the controllers ground just near the ADCs ground, both the ADCs started working properly.&lt;/p&gt;&#xA;" OwnerUserId="13187" LastActivityDate="2015-11-09T09:50:53.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17613" PostTypeId="2" ParentId="17609" CreationDate="2015-11-09T10:56:51.820" Score="1" Body="&lt;p&gt;Your method is completely wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a variable that contains the value of millis() at the start of your period, whenever that may be (when the switches change? when a button is pressed? since the Arduino was powered up?) and compare that value to the current value of millis().  When the difference between them is greater than or equal to &lt;code&gt;60000 * 15&lt;/code&gt; then 15 minutes have passed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &lt;em&gt;BlinkWithoutDelay&lt;/em&gt; in the Examples menu in the IDE - it showcases the technique for you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-09T10:56:51.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17614" PostTypeId="2" ParentId="17585" CreationDate="2015-11-09T12:22:50.317" Score="1" Body="&lt;p&gt;The problem code was reduced to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;char data;&#xA;void main(void) {&#xA;  UBRR0H = 0x00;&#xA;  UBRR0L = 0x67; // baud=9600&#xA;  UCSR0B = 0x10; // 00010000&#xA;  UCSR0C = 0x06; // 00000110&#xA;  DDRB |= (1&amp;lt;&amp;lt;PB5);&#xA;  PORTB |= (1&amp;lt;&amp;lt;PB5);&#xA;  while(1) {&#xA;    data = UDR0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the code which works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;void main(void) {&#xA;  char data;&#xA;  UBRR0H = 0x00;&#xA;  UBRR0L = 0x67; // baud=9600&#xA;  UCSR0B = 0x10; // 00010000&#xA;  UCSR0C = 0x06; // 00000110&#xA;  DDRB |= (1&amp;lt;&amp;lt;PB5);&#xA;  PORTB |= (1&amp;lt;&amp;lt;PB5);&#xA;  while(1) {&#xA;    data = UDR0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to explain that char inside main makes the problem disappear...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;Just for the record, here are two more examples. The first example works with both compilation methods. The second example works only with the second compilation method. The examples differ only with that in the first direct code is used, and in the second it is used via functions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#define BAUD 9600&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;void main(void) {&#xA;  char data;&#xA;  #include &amp;lt;util/setbaud.h&amp;gt; &#xA;  UBRR0H = UBRRH_VALUE;&#xA;  UBRR0L = UBRRL_VALUE;&#xA;  UCSR0B = (1&amp;lt;&amp;lt;RXEN0)|(1&amp;lt;&amp;lt;TXEN0);&#xA;  UCSR0C = (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;  DDRB = (1&amp;lt;&amp;lt;PB5);&#xA;  while (1) {&#xA;    PORTB ^= (1&amp;lt;&amp;lt;PB5);&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0)));&#xA;    data = UDR0;&#xA;    UDR0 = data;&#xA;    while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;TXC0)));&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;#define BAUD 9600&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;void serialSetup(void) {&#xA;  #include &amp;lt;util/setbaud.h&amp;gt; &#xA;  UBRR0H = UBRRH_VALUE;&#xA;  UBRR0L = UBRRL_VALUE;&#xA;  UCSR0B = (1&amp;lt;&amp;lt;RXEN0)|(1&amp;lt;&amp;lt;TXEN0);&#xA;  UCSR0C = (1&amp;lt;&amp;lt;UCSZ01)|(1&amp;lt;&amp;lt;UCSZ00);&#xA;}&#xA;void serialSend(char data) {&#xA;  UDR0 = data;&#xA;  while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;TXC0)));&#xA;}&#xA;char serialGet(void) {&#xA;  while(!(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;RXC0)));&#xA;  return UDR0;&#xA;}&#xA;void main(void) {&#xA;  char data;&#xA;  serialSetup();&#xA;  DDRB = (1&amp;lt;&amp;lt;PB5);&#xA;  while (1) {&#xA;    PORTB ^= (1&amp;lt;&amp;lt;PB5);&#xA;    data = serialGet();&#xA;    serialSend(data);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14631" LastEditorUserId="14631" LastEditDate="2015-11-16T05:19:53.673" LastActivityDate="2015-11-16T05:19:53.673" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17615" PostTypeId="2" ParentId="17585" CreationDate="2015-11-09T12:48:32.337" Score="1" Body="&lt;p&gt;One thing that I found whilst experimenting with command line compilation is that for some strange reason no startup code was being linked with my code, so it all went completely screwy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I finally tracked the problem down to a missing command line flag while linking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you need to link with &lt;code&gt;avr-gcc&lt;/code&gt; not &lt;code&gt;avr-ld&lt;/code&gt;.  Second, you need to pass the &lt;code&gt;-mmcu=atmega328p&lt;/code&gt; flag to the link command so that it knows which startup code to link in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my complete command line sequence for compiling a simple blink program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -g -mmcu=atmega328p -ffunction-sections -fdata-sections   -c -o blink.o blink.c&#xA;avr-gcc -mmcu=atmega328p -Wl,--gc-sections -o blink.elf blink.o &#xA;avr-objdump -S blink.elf &amp;gt; blink.dis&#xA;avr-objcopy -O ihex -R .eeprom blink.elf blink.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You notice I'm making function and data sections too, and then garbage collecting the unused ones - good practice since it can very much reduce the size of your finished program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am doing this through a Makefile, which looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PREFIX=avr-&#xA;CC=${PREFIX}gcc&#xA;CXX=${PREFIX}g++&#xA;LD=${PREFIX}ld&#xA;AS=${PREFIX}as&#xA;OBJCOPY=${PREFIX}objcopy&#xA;OBJDUMP=${PREFIX}objdump&#xA;&#xA;BIN=blink&#xA;MCU=atmega328p&#xA;OBJS=blink.o&#xA;&#xA;CFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections&#xA;CXXFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections -fno-exceptions&#xA;LDFLAGS=-mmcu=${MCU} -Wl,--gc-sections&#xA;&#xA;${BIN}.hex: ${BIN}.elf&#xA;    ${OBJCOPY} -O ihex -R .eeprom $&amp;lt; $@&#xA;&#xA;${BIN}.elf: ${OBJS}&#xA;    ${CC} ${LDFLAGS} -o $@ $? &#xA;    ${OBJDUMP} -S $@ &amp;gt; ${BIN}.dis&#xA;&#xA;install: ${BIN}.hex&#xA;    avrdude -c usbasp -p ${MCU} -U flash:w:${BIN}.hex -qq&#xA;&#xA;clean:&#xA;    rm -f *.o *.elf *.hex&#xA;&#xA;fuses:&#xA;    avrdude  -c usbasp -p ${MCU} -U lfuse:w:0xff:m -U hfuse:w:0xd6:m -U efuse:w:0x05:m -qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-09T12:48:32.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17617" PostTypeId="1" AcceptedAnswerId="17641" CreationDate="2015-11-09T15:19:33.303" Score="0" ViewCount="180" Body="&lt;p&gt;I am making a system which regulates the temperature of a plate. &#xA;using the PID library&#xA;I programed the system as followed: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/********************************************************&#xA; * PID Basic Example&#xA; * Reading analog input 0 to control analog PWM output 5&#xA; ********************************************************/&#xA;&#xA;#include &amp;lt;PID_v1.h&amp;gt;&#xA;#include &quot;math.h&quot; &#xA;&#xA;int val, output2; &#xA;//Define Variables we'll be connecting to&#xA;double Setpoint, Input, Output;&#xA;//Specify the links and initial tuning parameters&#xA;PID myPID( &amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,0,20,20, DIRECT);&#xA;&#xA;void setup()&#xA;{&#xA;  //initialize the variables we're linked to&#xA;  Setpoint = 37; //temperature a reguler &#xA;&#xA;  //turn the PID on&#xA;  pinMode(9, OUTPUT);&#xA;  myPID.SetOutputLimits(-100, 100);&#xA;  myPID.SetMode(AUTOMATIC);&#xA;  Serial.begin(57600);&#xA;  while (!Serial); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // phase haute&#xA;  //delay(100-output2);&#xA;  val = analogRead(1);&#xA;  float mv = ( val/1024.0)*5000; &#xA;  Input = mv/10;&#xA;  myPID.Compute();&#xA;  {   output2 = map(Output, -100, 100, 0, 200); &#xA;      Serial.print(&quot;output is :&quot;);&#xA;      Serial.println(output2); &#xA;      digitalWrite(9,HIGH);&#xA;      delay(output2);&#xA;      // phase basse&#xA;      digitalWrite(9,LOW);&#xA;  }&#xA;  //analogWrite(5,Output);&#xA;  //Serial.print(&quot;input temperature is :&quot;);&#xA;  //Serial.println(Input);&#xA;  // Serial.println(Output);&#xA;  // Serial.println(Input);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see in the code the output result is between 0 and 100. &#xA;the temperature desired in the plate is 37 degre. and the actual temperature is 24 degre. consequently, the program supposes to set the value of the output to the max value to reach to 37 degre. &#xA;But the problem is my output is setting to different values as you can see here: &lt;a href=&quot;https://i.stack.imgur.com/yVt8T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yVt8T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what can be the problem here ? thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="14515" LastActivityDate="2015-11-10T13:42:28.980" Title="arduino PWM temperature inexpected results" Tags="|arduino-uno|programming|temperature-sensor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17622" PostTypeId="2" ParentId="9581" CreationDate="2015-11-09T16:17:33.497" Score="1" Body="&lt;p&gt;First, upload the sketch below to your Arduino. Then, try to tie RX (pin 3) and TX (pin 2) of SoftwareSerial together. Open the Serial Monitor and send some text and see if you get it back as a response.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial Serial1(3, 2);&#xA;&#xA;void setup()&#xA;  {  Serial.begin(9600);&#xA;     Serial1.begin(9600);&#xA;  }&#xA;&#xA;void loop()&#xA;  {&#xA;     if (Serial1.available())&#xA;         { char c = Serial1.read() ;&#xA;           Serial.print(c);&#xA;         }&#xA;     if (Serial.available())&#xA;         {  char c = Serial.read();&#xA;            Serial1.print(c);&#xA;         }&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you get a response, then your SoftwareSerial part is working and you can then try to connect to your ESP8266.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-09T16:24:13.127" LastActivityDate="2015-11-09T16:24:13.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17623" PostTypeId="1" CreationDate="2015-11-08T11:52:19.360" Score="0" ViewCount="785" Body="&lt;p&gt;I have an XDRduino Mega &lt;a href=&quot;http://yourduino.com/sunshop2/index.php?l=product_detail&amp;amp;p=387&quot; rel=&quot;nofollow noreferrer&quot;&gt;clone&lt;/a&gt; with ATmega2560 and ATmega16U2 USB support chip.  I also have a Sensor Shield (same vendor), which provides screw terminals to Vin and Ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the board with USB, loaded &quot;Blink&quot;, and then changed the time interval.  Next I connected a 20x4 LCD using the Sensor Shield and a breadboard and loaded LCD &quot;Hello world&quot;.  All seemed fine with the new board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time I powered on or reset the Mega, the TX and RX LEDs flashed a couple of times and then my sketch started running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I disconnected it from the PC (no USB for power anymore) and connected a (working from another project) &lt;a href=&quot;http://www.alliedelec.com/mean-well-usa-s-60-12/70069551/&quot; rel=&quot;nofollow noreferrer&quot;&gt;S-60-12&lt;/a&gt; power supply, DC Output 12V 5A to the shield screw terminals.  I verified polarity -V to GND, +V to VCC.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, I swear I hooked it up correctly.  But if you tell me that hooking it up backwards would explain all the symptoms below, then yes I'll believe you that I screwed up {sob}.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(And yes, you're right, there is no diode protection on Vin, just on the dc power jack.  Dummy me.  Double dummy me, as there was a screw type power plug laying unused on the bench {groan}.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About 4 seconds later, I heard a snap and immediately pulled the plug on the power supply.  Yes, something probably smoked, but let's refine at bit, please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I moved the Mega to my PC, (disconnecting the external power supply so to use only USB for power).  It is no longer recognized as a USB device, and the Arduino IDE (1.6.5) no longer finds the USB serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voltages at 3.3V pin and 5V pin are correct.  I've also probed the regulator and comparator and all looks well for the power circuitry. F1 is not blown (or there would be no power as USB is the only source).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Item: The TX and RX leads are on solid.  I expected them to flash then turn off.  (Power LED is on solid, which is normal.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Item: The reset pin for the Mega reads 1.41 V.  It's connected through a 10K pullup to +5 V (reads 4.63 at USB pin, 4.53 at the 5V pin).  &lt;strong&gt;&lt;em&gt;This seems way too low.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Item: The reset pin for the 16U2 reads V+ (4.35) and is has a 10K pull-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Item: AREF is 50 mV.  I believe it should be 1.1 V or 2.56 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question: Is it reasonable to think the 2560 may be dead, and the LEDs are on because the 16U2 can't talk to it?  &lt;strong&gt;Any way to test this theory?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If the 16U2 were bad, it would still be possible to program the 2560 via the ICSP header, thus salvaging something...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question: The 16U2 won't do the USB connection dance with the PC because the 2560 is dead?  &lt;strong&gt;Should the 16U2 to try to connect no matter what the state of the 2560?.&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:  &lt;strong&gt;If the 16U2 is dead, should TX and RX LEDs be lit?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:  &lt;strong&gt;If I had reversed the hookup, should not the regulator (P1117 chip) have saved me?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question:  &lt;strong&gt;Has anyone else had a failing component&lt;/strong&gt; (other than the 2560 &amp;amp; 16U2) &lt;strong&gt;with these symptoms?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="14697" OwnerDisplayName="HiTechHiTouch" LastEditorUserId="26916" LastEditDate="2017-09-08T09:52:04.550" LastActivityDate="2017-09-08T09:52:04.550" Title="Arduino Mega failure after first use of Mega Shield power connector" Tags="|sensors|power|shields|usb|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17624" PostTypeId="1" AcceptedAnswerId="17629" CreationDate="2015-11-09T17:25:15.133" Score="0" ViewCount="613" Body="&lt;p&gt;I have a WS2812B LED strip that is controlled by an Arduino. Normally, both the Arduino and LED strip are powered by the same 5V power supply. The 5V and GND pins of the Arduino and LED strip are connected together. If I want to reprogram the Arduino, I have to disconnect the LED strip or else it might want to try and draw power from my computer's USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a bunch of (assorted) transistors, (schottky, zener) diodes and resistors. Is there something I can build that will allow the power supply to power both the Arduino and LED strip, while the Arduino's USB can only power the Arduino itself?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've thought about using a diode between the 5V of the Arduino and 5V of the power supply and using a resistor to pull the 5V terminal of the power supply pin low (when the power supply is not connected) but I'm not sure how stable that will be: once the diode starts conducting the resistor will have no chance to pull the pin low again and I'm not sure if the Arduino will like the voltage drop across the diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously the external power would be disconnected before plugging the Arduino into USB. Since the LED strip runs on 5V I can't use the VIN pin.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-11-09T19:07:01.607" Title="Stop Arduino from powering LED strip when connected to USB" Tags="|power|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17625" PostTypeId="1" AcceptedAnswerId="18310" CreationDate="2015-11-09T18:04:16.577" Score="0" ViewCount="1338" Body="&lt;p&gt;Lets suppose I have a circuit with a car battery, a switch and a led. The led will turn on when the switch is closed, and turn off if it's not. I want to remove the led from the circuit and put an Arduino in that place to &quot;read&quot; when the circuit is closed or open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a good programmer, so the code is not the real problem. I only want to know how to do this without damaging the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="11030" LastEditorUserId="14766" LastEditDate="2015-11-13T18:35:37.853" LastActivityDate="2015-12-01T18:08:26.007" Title="How to read a higher voltage digital input?" Tags="|arduino-mega|voltage-level|digital|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17627" PostTypeId="1" AcceptedAnswerId="17638" CreationDate="2015-11-09T18:41:05.973" Score="1" ViewCount="514" Body="&lt;p&gt;I am uploading data using Thingspeak and I would like to get only values stored in a field. Is there any way to get this in a cvs http request?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you call a cvs http url, you get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fuxzu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fuxzu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to get is just the value in field2: 10,10,12,12,16 without the headers.&lt;/p&gt;&#xA;" OwnerUserId="14707" LastEditorUserId="14707" LastEditDate="2015-12-10T09:14:38.630" LastActivityDate="2015-12-10T09:14:38.630" Title="Get csv field values" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17628" PostTypeId="1" CreationDate="2015-11-09T18:42:56.903" Score="1" ViewCount="890" Body="&lt;p&gt;I have an Uno with CC3000 wifi shield and am trying to use the sntp.h library to get NTP time. I have been experimenting with a modified version of the ntpTest code from the library which fetches the time every minute. In the serial monitor I get the correct time MOST of the time. However at random intervals, the time will display 3 hours and 14 minutes ahead of the current MST time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the SNTP client constructor looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sntp mysntp = sntp(NULL,&quot;time.nist.gov&quot;, (short)(-7 * 60),(short)(-7 * 60), true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The time will display correctly for two to ten minutes and then display one of the erroneous times once then revert to correct time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;Here is the pared down code from the &lt;a href=&quot;https://learn.adafruit.com/adafruit-cc3000-wifi/ntptest&quot; rel=&quot;nofollow&quot;&gt;Adafruit CC3000 WIFI shield ntpTest&lt;/a&gt; example. Note that the only reason I was getting the time so often was just teaching myself how it worked and I noticed this odd behavior. My intent was not to make an application that would, in the end, access NTP servers more than once per day.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*************************************************** &#xA;  This is an example for the Adafruit CC3000 Wifi Breakout &amp;amp; Shield&#xA;&#xA;  Designed specifically to work with the Adafruit WiFi products:&#xA;  ----&amp;gt; https://www.adafruit.com/products/1469&#xA;&#xA;  Adafruit invests time and resources providing this open source code, &#xA;  please support Adafruit and open-source hardware by purchasing &#xA;  products from Adafruit!&#xA;&#xA;  Written by Kevin Townsend &amp;amp; Limor Fried &amp;amp; Rick Lesniak for Adafruit Industries.  &#xA;  BSD license, all text above must be included in any redistribution&#xA; ****************************************************/&#xA;&#xA;/*&#xA;&#xA;This example does a test of the SNTP (Simple Network Time Protocol) client:&#xA;* Initialization&#xA;* SSID Scan&#xA;* AP connection&#xA;* DHCP printout&#xA;* SNTP time synchronization&#xA;* Extract and print current time and date information&#xA;&#xA;*/&#xA;&#xA;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;//#include &quot;utility/NetTime.h&quot;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;#include &quot;sntp.h&quot;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                                         SPI_CLOCK_DIVIDER); // you can change this clock speed but DI&#xA;&#xA;&#xA;&#xA;#define WLAN_SSID       &quot;CompsciWifi&quot;   // cannot be longer than 32 characters!&#xA;#define WLAN_PASS       &quot;005276DA&quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;//Arguments to SNTP client constructor:&#xA;//  1 - Primary Network Time Server URL (can be NULL)&#xA;//  2 - Secondary Network Time Server URL (also can be NULL)&#xA;//  3 - Local UTC offset in minutes (US Eastern Time is UTC - 5:00&#xA;//  4 - Local UTC offset in minutes for Daylight Savings Time (US Eastern DST is UTC - 4:00&#xA;//  5 - Enable Daylight Savings Time adjustment (not implemented yet)&#xA;//&#xA;//sntp mysntp = sntp(NULL, &quot;time.nist.gov&quot;, (short)(-7 * 60), (short)(-7 * 60), true);&#xA;sntp mysntp = sntp(NULL, &quot;time-a.timefreq.bldrdoc.gov&quot;, (short)(-7 * 60), (short)(-7 * 60), true);&#xA;&#xA;// Type SNTP_Timestamp is 64-bit NTP time. High-order 32-bits is seconds since 1/1/1900&#xA;//   Low order 32-bits is fractional seconds&#xA;SNTP_Timestamp_t now;&#xA;&#xA;// Type NetTime_t contains NTP time broken out to human-oriented values:&#xA;//  uint16_t millis; ///&amp;lt; Milliseconds after the second (0..999)&#xA;//  uint8_t  sec;    ///&amp;lt; Seconds after the minute (0..59)&#xA;//  uint8_t  min;    ///&amp;lt; Minutes after the hour (0..59)&#xA;//  uint8_t  hour;   ///&amp;lt; Hours since midnight (0..23)&#xA;//  uint8_t  mday;   ///&amp;lt; Day of the month (1..31)&#xA;//  uint8_t  mon;    ///&amp;lt; Months since January (0..11)&#xA;//  uint16_t year;   ///&amp;lt; Year.&#xA;//  uint8_t  wday;   ///&amp;lt; Days since Sunday (0..6)&#xA;//  uint8_t  yday;   ///&amp;lt; Days since January 1 (0..365)&#xA;//  bool     isdst;  ///&amp;lt; Daylight savings time flag, currently not supported   &#xA;NetTime_t timeExtract;&#xA;&#xA;#define pF(string_pointer) (reinterpret_cast&amp;lt;const __FlashStringHelper *&amp;gt;(pgm_read_word(string_pointer)))&#xA;&#xA;const prog_char   janStr[] PROGMEM = &quot;January&quot;;&#xA;const prog_char   febStr[] PROGMEM = &quot;February&quot;;&#xA;const prog_char   marStr[] PROGMEM = &quot;March&quot;;&#xA;const prog_char   aprStr[] PROGMEM = &quot;April&quot;;&#xA;const prog_char   mayStr[] PROGMEM = &quot;May&quot;;&#xA;const prog_char   junStr[] PROGMEM = &quot;June&quot;;&#xA;const prog_char   julStr[] PROGMEM = &quot;July&quot;;&#xA;const prog_char   augStr[] PROGMEM = &quot;August&quot;;&#xA;const prog_char   sepStr[] PROGMEM = &quot;September&quot;;&#xA;const prog_char   octStr[] PROGMEM = &quot;October&quot;;&#xA;const prog_char   novStr[] PROGMEM = &quot;November&quot;;&#xA;const prog_char   decStr[] PROGMEM = &quot;December&quot;; &#xA;&#xA;PROGMEM const char* const monthStrs[] = { janStr, febStr, marStr, aprStr, mayStr, junStr,&#xA;                                          julStr, augStr, sepStr, octStr, novStr, decStr}; &#xA;&#xA;const prog_char   sunStr[] PROGMEM = &quot;Sunday&quot;;&#xA;const prog_char   monStr[] PROGMEM = &quot;Monday&quot;;&#xA;const prog_char   tueStr[] PROGMEM = &quot;Tuesday&quot;;&#xA;const prog_char   wedStr[] PROGMEM = &quot;Wednesday&quot;;&#xA;const prog_char   thuStr[] PROGMEM = &quot;Thursday&quot;;&#xA;const prog_char   friStr[] PROGMEM = &quot;Friday&quot;;&#xA;const prog_char   satStr[] PROGMEM = &quot;Saturday&quot;; &#xA;&#xA;PROGMEM const char* const dayStrs[] = { sunStr, monStr, tueStr,  wedStr,&#xA;                                        thuStr, friStr, satStr};&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Sets up the HW and the CC3000 module (called automatically&#xA;            on startup)&#xA;*/&#xA;/**************************************************************************/&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); &#xA;&#xA;  //Serial.print(&quot;Free RAM: &quot;); Serial.println(getFreeRam(), DEC);&#xA;&#xA;&#xA;  /* Initialise the module */&#xA;  Serial.println(F(&quot;\nInitialising the CC3000 ...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Unable to initialise the CC3000! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Optional: Update the Mac Address to a known value */&#xA;/*&#xA;  uint8_t macAddress[6] = { 0x08, 0x00, 0x28, 0x01, 0x79, 0xB7 };&#xA;   if (!cc3000.setMacAddress(macAddress))&#xA;   {&#xA;     Serial.println(F(&quot;Failed trying to update the MAC address&quot;));&#xA;     while(1);&#xA;   }&#xA;*/&#xA;&#xA;&#xA;  /* Delete any old connection data on the module */&#xA;  Serial.println(F(&quot;\nDeleting old connection profiles&quot;));&#xA;  if (!cc3000.deleteProfiles()) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Attempt to connect to an access point */&#xA;  char *ssid = WLAN_SSID;             /* Max 32 chars */&#xA;  Serial.print(F(&quot;\nAttempting to connect to &quot;)); Serial.println(ssid);&#xA;&#xA;  /* NOTE: Secure connections are not available in 'Tiny' mode! */&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;&#xA;  /*Serial.println(F(&quot;UpdateNTPTime&quot;));&#xA;  if (mysntp.UpdateNTPTime())&#xA;  {&#xA;    Serial.println(F(&quot;Current local time is:&quot;));&#xA;    mysntp.ExtractNTPTime(mysntp.NTPGetTime(&amp;amp;now, true), &amp;amp;timeExtract);*/&#xA;&#xA;    /*Serial.print(timeExtract.hour); Serial.print(F(&quot;:&quot;)); Serial.print(timeExtract.min); Serial.print(F(&quot;:&quot;));Serial.print(timeExtract.sec); Serial.print(F(&quot;.&quot;));Serial.println(timeExtract.millis);&#xA;    Serial.print(pF(&amp;amp;dayStrs[timeExtract.wday])); Serial.print(F(&quot;, &quot;)); Serial.print(pF(&amp;amp;monthStrs[timeExtract.mon])); Serial.print(F(&quot; &quot;)); Serial.print(timeExtract.mday); Serial.print(F(&quot;, &quot;));Serial.println(timeExtract.year);&#xA;    Serial.println(timeExtract.yday + 1); &#xA;  }&#xA;&#xA;  /* You need to make sure to clean up after yourself or the CC3000 can freak out */&#xA;  /* the next time you try to connect ... */&#xA;  /*Serial.println(F(&quot;\n\nClosing the connection&quot;));&#xA;  cc3000.disconnect(); */&#xA;&#xA;    mysntp.UpdateNTPTime();&#xA;    mysntp.ExtractNTPTime(mysntp.NTPGetTime(&amp;amp;now, true), &amp;amp;timeExtract);&#xA;    Serial.print(pF(&amp;amp;dayStrs[timeExtract.wday])); Serial.print(F(&quot;, &quot;)); Serial.print(pF(&amp;amp;monthStrs[timeExtract.mon])); Serial.print(F(&quot; &quot;)); Serial.print(timeExtract.mday); Serial.print(F(&quot;, &quot;));Serial.println(timeExtract.year);&#xA;}&#xA;&#xA;&#xA;void loop(void)&#xA;{&#xA;    mysntp.UpdateNTPTime();&#xA;    mysntp.ExtractNTPTime(mysntp.NTPGetTime(&amp;amp;now, true), &amp;amp;timeExtract);&#xA;    Serial.print(timeExtract.hour); Serial.print(F(&quot;:&quot;)); Serial.print(timeExtract.min);&#xA;&#xA;    delay(60000);&#xA;    Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14705" LastEditorUserId="14705" LastEditDate="2015-12-02T17:02:59.707" LastActivityDate="2018-11-07T22:00:36.210" Title="Occasional incorrect time returned by NTP" Tags="|wifi|time|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17629" PostTypeId="2" ParentId="17624" CreationDate="2015-11-09T19:01:01.810" Score="3" Body="&lt;p&gt;I'd try powering the led strip for the power-supply directly, and the arduino board via a (schottky) diode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way the led strip will have no power when only usb is plugged in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino won't mind that it receive a bit less that 5v because of the voltage drop of the diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing to look out for it sending a 5v signal to a WS2812B chip that has no power. According to the datasheet this is not allowed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you either need to buffer the output of the arduino going to the input of the WS2812B (e.g. using some transistors, or a &lt;a href=&quot;http://elinux.org/images/6/61/EOMA68-UART-RX-DIODE-PROTECT.png&quot; rel=&quot;nofollow&quot;&gt;simple pull-up with diode&lt;/a&gt;). Or, since you are not hot-plugging the usb, have the 5v from the power supply go (via a resistor) to an input on the arduino, so you can detect this in your setup routine, and have it block the rest of the code, or something.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-11-09T19:07:01.607" LastActivityDate="2015-11-09T19:07:01.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17631" PostTypeId="1" AcceptedAnswerId="17634" CreationDate="2015-11-09T19:30:52.610" Score="0" ViewCount="280" Body="&lt;p&gt;I'm new at using Xbee and I would like to get some help on how to interpret API packets. Me setup consists of two arduino unos, two xbee S2, two &lt;a href=&quot;http://q.lnwfile.com/_/q/_raw/gn/ta/2w.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;xbee shields&lt;/a&gt; and a one magnetometer sensor HMC5883L.  The sensor is connected to the arduino via I2C and transmitting the data to the xbee (router) using serial communication. On the other side (coordinator) I'm reading and displaying the data on the serial monitor. I have read the data sheet of the xbee but I still can't figure how to interpret the packet. Here is a screen shot of the values that I'm getting on the serial monitor on the router and the corresponding packets on the coordinator's serial monitor. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/ugIDP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ugIDP.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are four bytes that are changing each time so how can I translate them to an integer value. Any help would be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="14345" LastActivityDate="2015-11-09T20:15:57.277" Title="Help to decode xbee S2 API packet" Tags="|arduino-uno|serial|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17632" PostTypeId="1" AcceptedAnswerId="17633" CreationDate="2015-11-09T19:46:57.033" Score="0" ViewCount="64" Body="&lt;p&gt;I have an Emulator and Roms I would like to create a portable device to allow me to connect via RCA to a TV and play. Only I have no prior knowledge of how Integrated Circuits function or what they are capable of. If a IC would work, how does one go about programming one to load up the emulator? What other components aside from RCA and USB would I need? Any direction with this would be great and sorry in case I am not asking the proper questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured arduino is similar to what I am building in regards to circuitry/ electronics. Thanks in advance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the only bit of information I have found online in 4 days thats not store bought.   &lt;a href=&quot;http://www.voja.rs/PROJECTS/GAME_HTM/2.%20Hardware.htm#Schema&quot; rel=&quot;nofollow&quot;&gt;CLICK HERE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14703" LastEditorUserId="14703" LastEditDate="2015-11-09T20:11:38.607" LastActivityDate="2015-11-09T20:11:38.607" Title="Is it possible to run emulator from IC? and how?" Tags="|electronics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17633" PostTypeId="2" ParentId="17632" CreationDate="2015-11-09T19:54:58.627" Score="1" Body="&lt;p&gt;Not a chance, I am afraid.  The Arduino cannot do what you think it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you could &lt;em&gt;program&lt;/em&gt; the Arduino to act like some of the simple old video games, but there is no way it can run a pre-existing emulator program like your computer can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need something more like a Raspberry Pi - in fact there is an interesting project that might be just what you want: &lt;a href=&quot;http://blog.petrockblock.com/retropie/&quot; rel=&quot;nofollow&quot;&gt;RetroPie&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-09T19:54:58.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17634" PostTypeId="2" ParentId="17631" CreationDate="2015-11-09T20:15:57.277" Score="0" Body="&lt;p&gt;You have a bunch of &quot;stuff&quot;, followed by the data you sent, followed finally by another bunch of &quot;stuff&quot;.  I don't know what the &quot;stuff&quot; is, but I can see and decode your data easily enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect you transmitted the data using &lt;code&gt;.println(...)&lt;/code&gt;.  That will send an ASCII representation of the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to take the line: &lt;code&gt;-196.88&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code&gt;, if we find the ASCII values and represent them as hexadecimal we have:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2D,31,39,36,2E,38,38,D,A&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which I am sure you can find in one of those lines - maybe this one:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0,15,90,0,13,A2,0,40,C1,A8,2E,98,8D,1,&lt;strong&gt;2D,31,39,36,2E,38,38,D,A&lt;/strong&gt;,3B&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you have 14 bytes defining something interesting about the packet (I'm sure Google can tell you what - source and destination maybe, probably a packet length too), then your data, and finally what looks like it's probably a checksum.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-09T20:15:57.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17635" PostTypeId="2" ParentId="9672" CreationDate="2015-11-09T21:00:08.220" Score="1" Body="&lt;p&gt;You can open two Arduino IDE windows, and use Tools / Board to set each of them to one of the two kinds of boards you are programming.   Ie, you can have multiple IDE windows open, with different options selected in each.  I've programmed an Uno and a Nano device with the same program from two different windows simultaneously (ie, RX lights blinking on both boards at the same time) without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use one USB cable and one port, or can use a separate USB cable for each window.  You might need to use Tools / Port occasionally if the port number changes when you recable things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the external editor option selected.  Text in each Arduino IDE window updates when I click Verify or Load, rather than each time I save the file in emacs.  I don't know how it works if you aren't using an external editor and have the same file open in two IDE windows.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-09T21:00:08.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17636" PostTypeId="1" AcceptedAnswerId="17637" CreationDate="2015-11-09T22:21:56.950" Score="0" ViewCount="296" Body="&lt;pre&gt;&lt;code&gt;int guard = 7;&#xA;int switchPin = 6;&#xA;int motorPin = 9;&#xA;&#xA;void setup(){&#xA;  pinMode(guard,INPUT);&#xA;  pinMode(switchPin,INPUT);&#xA;  pinMode(motorPin,OUTPUT);&#xA;}&#xA;&#xA;  void loop(){&#xA;   if (digitalRead(guard==HIGH)&amp;amp;&amp;amp;digitalRead(switchPin==HIGH))              //&amp;amp;&amp;amp;&#xA;&#xA;   {&#xA;&#xA;     digitalWrite(motorPin,HIGH);&#xA;    delay(500);&#xA;    digitalWrite(motorPin,LOW);&#xA;    delay(1000);&#xA;   }&#xA;        else {&#xA;&#xA;     digitalWrite(motorPin,LOW);&#xA;   }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GiMXO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GiMXO.jpg&quot; alt=&quot;123dsimulation image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14711" LastEditorUserId="6424" LastEditDate="2015-11-10T02:50:17.653" LastActivityDate="2015-11-10T02:50:17.653" Title="Why won't the slide switches control the motor in this 123d simulation?" Tags="|arduino-uno|motor|transistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17637" PostTypeId="2" ParentId="17636" CreationDate="2015-11-09T23:15:35.407" Score="0" Body="&lt;p&gt;This should be written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( digitalRead(guard)==HIGH &amp;amp;&amp;amp; digitalRead(switchPin)==HIGH ) {&#xA;&#xA;// Rest of the code..&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-09T23:15:35.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17638" PostTypeId="2" ParentId="17627" CreationDate="2015-11-10T00:14:31.753" Score="0" Body="&lt;p&gt;You can use this format to achieve what you described:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://api.thingspeak.com/channels/(channel_id)/field/(field_id).(format)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;http://community.thingspeak.com/documentation/api/&quot; rel=&quot;nofollow&quot;&gt;http://community.thingspeak.com/documentation/api/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; It seems that there are no available options that can do what you want. But, you can tweak the response like in this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int i;&#xA;  String response = &quot;created_at,entry_id,field2 2015-10-22 19:30:00,14878,5&quot;;&#xA;&#xA;  for (i = response.length()-1; i &amp;gt;= 0 ; i--)&#xA;  {&#xA;    if (s.charAt(i) == ',') break;&#xA;  }&#xA;  String value = response.substring(i+1);&#xA;  Serial.println(value); // This will show only 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-10T17:38:55.327" LastActivityDate="2015-11-10T17:38:55.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17639" PostTypeId="1" AcceptedAnswerId="17650" CreationDate="2015-11-10T01:26:11.673" Score="8" ViewCount="30686" Body="&lt;p&gt;I've run into an issue trying to combine 2 different Arduino timer projects I've found online. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For both projects I'm using a DS3231 RTC, but have been able use the DS1307 library just fine in my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first set of code I picked up started with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DS1307RTC.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second set of code I tried to combine did not have this 'include', but instead used &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RTC_DS1307 RTC;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as found here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/understanding-the-code&quot;&gt;https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/understanding-the-code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a novice coder, I'm not really sure what the difference between the above two ways to call this library. But I do know the first way using &quot;include&quot;, if I want to access the current time on the RTC I use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RTC.get();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as opposed to the second method which requires:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RTC.now();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And while it was easy to find documentation to sync the RTC to computer time over the USB cable using this handy bit of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Notify if the RTC isn't running&#xA;    if (! RTC.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running&quot;);&#xA;  }&#xA;&#xA;&#xA;&#xA;   // Get time from RTC&#xA;  DateTime current = RTC.get();&#xA;  DateTime compiled = DateTime(__DATE__, __TIME__);&#xA;  if (current.unixtime() &amp;lt; compiled.unixtime()) { //CHECKS AGAINST COMPUTERTIME&#xA;    Serial.println(&quot;RTC is older than compile time! Updating&quot;);&#xA;    RTC.adjust(DateTime(__DATE__, __TIME__));  //UPDATES FROM COMPUTER IF OLD TIME IS OFF&#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can find no easy alternative using &quot;#include DS1307RTC&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first thought that the difference between RTC.now() and RTC.get() was just a matter of word substitution. But later on when I want to use a &quot;time_t&quot; call after initializing with &quot;RTC_DS1307 RTC;&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; time_t timeNOW = RTC.now();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the error &quot;cannot convert 'DateTime' to 'time_t {aka long unsigned int}' in initialization&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm assuming one method uses &quot;DateTime&quot; and one method uses &quot;time_t&quot;. But I'm not sure if this is the case, and if so, how to convert a &quot;DateTime&quot; value to a &quot;time_t&quot; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two goals in writing this post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- Can someone please explain to me the difference between &quot;#include DS1307RTC.h&quot; and &quot;RTC_DS1307 RTC;&quot; and how it impacts my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- I'd like to stick with using &quot;&quot;RTC_DS1307 RTC;&quot;, only because it seems easy to sync my RTC to my computer. But if I do, I get the above error. So can someone please tell me how to convert a &quot;RTC now()&quot; call to a &quot;time_t&quot; value? Or is the issue more complicated than just a mere conversion between data types?&lt;/p&gt;&#xA;" OwnerUserId="14586" LastActivityDate="2023-01-27T03:25:52.930" Title="The difference between &quot;time_t&quot; and &quot;DateTime&quot;" Tags="|arduino-uno|timers|time|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17640" PostTypeId="1" CreationDate="2015-11-10T01:50:35.937" Score="0" ViewCount="755" Body="&lt;p&gt;I'm trying to interface my Arduino UNO with both a 1) TFT LCD screen and 2) WiFi Breakout board/shield.&#xA;The WiFi breakout board uses many of the same Digital pins as the LCD screen so is it possible for the arduino to interface with both devices simultaneously?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also noticed that the shield goes over the arduino, but covers the header pins. Does this mean that I can't use these pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've never worked with shields or breakout boards and would like some advice before I purchase either component. &#xA;If neither of these solutions will work, please provide me with alternate methods. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your time/feedback is greatly appreciated :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Vip&lt;/p&gt;&#xA;" OwnerUserId="14714" LastActivityDate="2021-06-29T03:03:15.660" Title="Interfacing Arduino UNO with TFT LCD and WiFi Shield" Tags="|arduino-uno|wifi|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17641" PostTypeId="2" ParentId="17617" CreationDate="2015-11-10T01:53:19.670" Score="0" Body="&lt;p&gt;As Gerben said in a comment, you should add the value of Input to the serial print, to facilitate problem diagnosis.  As your question stands, one can only speculate about what the problem might be.  My speculation is that the system is unable to cope with parameters (Kp, Ki, Kd) = (0, 20, 20), ie, that it's unstable and unresponsive without proportional control.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-10T13:42:28.980" LastActivityDate="2015-11-10T13:42:28.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17642" PostTypeId="1" AcceptedAnswerId="17648" CreationDate="2015-11-10T03:15:59.947" Score="1" ViewCount="1443" Body="&lt;p&gt;So for my project, I am making a button that turns on and off an LED, but also display the state of the led on an LCD and by Serial.  But my issue is, I don't want it to just show a 0 or a 1, I want it to say On or Off.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;int inPin = 22;         // the number of the input pin&#xA;int outPin = 13;       // the number of the output pin&#xA;&#xA;int state = HIGH;      // the current state of the output pin&#xA;int reading;           // the current reading from the input pin&#xA;int previous = LOW;    // the previous reading from the input pin&#xA;&#xA;// the follow variables are long's because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long time = 0;         // the last time the output pin was toggled&#xA;long debounce = 200;   // the debounce time, increase if the output flickers&#xA;&#xA;&#xA;void setup(){&#xA;    // set up the LCD's number of columns and rows:&#xA;    lcd.begin(16, 2);&#xA;    // Print a message to the LCD.&#xA;    lcd.print(&quot;System Activated&quot;);&#xA;    //&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;Ready...&quot;);&#xA;&#xA;    pinMode(inPin, INPUT);&#xA;    pinMode(outPin, OUTPUT);&#xA;&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;System Activated&quot;);&#xA;    Serial.println(&quot;Made by Mateo Holguin&quot;);&#xA;    Serial.println(&quot;0 = Light is Off | 1 = Light is On&quot;);&#xA;    Serial.println(&quot;=======================================&quot;);&#xA;}&#xA;&#xA;void loop(){&#xA;    reading = digitalRead(inPin);&#xA;&#xA;    if (reading == HIGH &amp;amp;&amp;amp; previous == LOW &amp;amp;&amp;amp; millis() - time &amp;gt; debounce) {&#xA;        Serial.println(&quot;Button Switch State Change:&quot;);&#xA;        if (state == HIGH)&#xA;            state = LOW;&#xA;        else&#xA;            state = HIGH;&#xA;&#xA;        Serial.println(state);&#xA;        Serial.println(&quot;&quot;);&#xA;        lcd.clear();&#xA;        lcd.print(&quot;State: &quot;);&#xA;        lcd.print(state);&#xA;&#xA;        time = millis();    &#xA;    }&#xA;&#xA;    digitalWrite(outPin, state);&#xA;&#xA;    previous = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14716" LastEditorUserId="13840" LastEditDate="2015-11-12T08:56:13.193" LastActivityDate="2015-11-14T20:40:44.097" Title="Instead of 1 and 0, make display say On or Off" Tags="|serial|c++|lcd|button|debounce|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17643" PostTypeId="2" ParentId="17642" CreationDate="2015-11-10T04:37:16.500" Score="5" Body="&lt;p&gt;Put the strings to display in an array, and output them instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char const * const stateDisplay[] = {&quot;Off&quot;, &quot;On&quot;};&#xA;&#xA; ...&#xA;&#xA;lcd.print(stateDisplay[state]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-10T04:37:16.500" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17647" PostTypeId="1" CreationDate="2015-11-10T08:25:03.153" Score="1" ViewCount="1983" Body="&lt;p&gt;I have an application where an HX711 ADC is used with 4 load cells. (in wheatstone bridge configuration, rated at 50kg each).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that I am trying to sense 30~ish gram changes with it accurately, while the cells will be loaded with 10 to 40 kilograms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have built up the circuitry and placements properly, calibrated and tested etc. but I have 2 questions that I couldn't come up with a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1st question:&lt;/strong&gt; &#xA;When powering arduino from USB cable the readings are much more stable (they are fluctuating like +-5 grams only) but when I connect a 12V power source (with 5A output) to the arduino, the readings start to fluctuate much more. (+-30 grams or so). The HX711 is powered from arduino 5v out pin but even though i tried to power it from a 5v adapter the fluctuations seemed to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should also note that the HX711 is connected to the analog pins A0 and A1, and there are 8 other sensors connected to the pwm pins of the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now any ideas why does that happen? Any way to prevent this fluctuation? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2nd question:&lt;/strong&gt;&#xA;If I calibrate with a load close to the max. weight (as suggested in many papers) the small changes seems to be very unreliable. If I calibrate it with a small weight (like around 200g) I can sense small weights properly but this time when a 2 kg weight is put it is read like 2.3kg or something. Is this normal? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that my load cells are not the proper ones for the application but I would like to push them as much as i can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time&lt;/p&gt;&#xA;" OwnerUserId="14136" LastActivityDate="2017-04-06T07:04:00.017" Title="HX711 Load Cell application strange behaviour" Tags="|arduino-uno|adc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17648" PostTypeId="2" ParentId="17642" CreationDate="2015-11-10T09:47:55.930" Score="2" Body="&lt;p&gt;Another option: use the &quot;inline&quot; &lt;em&gt;if&lt;/em&gt; construct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(state ? F(&quot;On&quot;) : F(&quot;Off&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The format is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;if comparison&amp;gt; ? &amp;lt;true result&amp;gt; : &amp;lt;false result&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of &lt;code&gt;F(...)&lt;/code&gt; to force the strings to stay in flash memory.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-14T20:40:44.097" LastActivityDate="2015-11-14T20:40:44.097" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17649" PostTypeId="2" ParentId="17436" CreationDate="2015-11-10T09:51:15.920" Score="1" Body="&lt;p&gt;I don't know if this is a complete answer, but I can't comment yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analogRead function in Arduino which is used by your sensor reads values from 0 - 5V. It divides the values between 0 and 5V in 1024 steps. So it returns a value between 0 and 1023. That is why it is multiplied by 5. It is easier to understand if the calculation is done in reverse order. Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;analogRead returns 512, so that is on 1024 / 512 = 0,5th part of its range. Multiply that by 5.0 to get the actual voltage. 0.5 * 5.0 = 2.5. It is then divided by 6 to get the average.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also change the order of the calculation. The comments say that it calculates the average, but it doesn't it just adds the values. It does divide it by 6 eventually so that does not cause the error, but for readability it is generally good practice to let your code do what the comments say.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastEditorUserId="26916" LastEditDate="2017-09-09T08:31:19.687" LastActivityDate="2017-09-09T08:31:19.687" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17650" PostTypeId="2" ParentId="17639" CreationDate="2015-11-10T09:53:26.737" Score="12" Body="&lt;p&gt;A &lt;code&gt;DateTime&lt;/code&gt; is a full class with lots of methods to it - a &lt;code&gt;time_t&lt;/code&gt; is just an unsigned long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;time_t&lt;/code&gt; is used to store the number of seconds since the &lt;em&gt;epoch&lt;/em&gt; (normally 01/01/1970)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino &lt;em&gt;Time&lt;/em&gt; library returns a &lt;code&gt;time_t&lt;/code&gt; to the &lt;code&gt;now()&lt;/code&gt; function - but RTCLib return s a DateTime object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DateTime object, though, has a &lt;code&gt;unixtime()&lt;/code&gt; method which will return a &lt;code&gt;time_t&lt;/code&gt; representation of the time stored in the DateTime object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DateTime dt = RTC.now();&#xA;time_t time = dt.unixtime();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-10T09:53:26.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17651" PostTypeId="1" AcceptedAnswerId="17652" CreationDate="2015-11-10T10:17:40.027" Score="0" ViewCount="103" Body="&lt;p&gt;RS-485 and RS-232 are a type of communication protocol or a type and cable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I studying these serial communication protocols and each place refers to the RS-232 / RS-485 in different ways. Some articles mention that it is a cable, the other a protocol, so I was in doubt.&lt;/p&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2015-11-10T10:59:01.950" Title="RS-232 is a protocol or a cable?" Tags="|serial|rs485|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17652" PostTypeId="2" ParentId="17651" CreationDate="2015-11-10T10:24:51.020" Score="1" Body="&lt;p&gt;RS-232 etc mean different things in different contexts.  More specifically it is called TIA/EIA-232.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It refers to both the electrical characteristics of an NRZ signalling system, and at the same time it refers to the packet format for the transmission of data through such a system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also refers to the connectors that are used with such a system and, by extension, the cables that have those connectors on them.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The standard defines the electrical characteristics and timing of signals, the meaning of signals, and the physical size and pinout of connectors. The current version of the standard is TIA-232-F Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange, issued in 1997.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;RS-485, or TIA/EIA-485, in contrast &lt;em&gt;only&lt;/em&gt; specifies the electrical characteristics and not the data that is sent down the line. It doesn't specify any connectors to use, nor what format the data should take. For instance you can use RS-232 formatted packets, or you could use a MODBUS-RTU format that uses completely different packets. It only refers to the drivers and voltages used.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;TIA-485-A, also known as ANSI/TIA/EIA-485, TIA/EIA-485, EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-10T10:59:01.950" LastActivityDate="2015-11-10T10:59:01.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17653" PostTypeId="1" AcceptedAnswerId="17657" CreationDate="2015-11-10T11:07:15.310" Score="-1" ViewCount="530" Body="&lt;p&gt;I have a Arduino Due that I'm trying to upload a sketch to. I follow the tutorial &lt;a href=&quot;http://playground.arduino.cc/Code/Eclipse&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Eclipse&lt;/a&gt; to get the board running with the Eclipse plugin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However uploading the sketch gives me the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use the Arduino IDE everthing works fine. I'm using Eclipse mars with Arduino 1.6.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could have gone wrong?&lt;/p&gt;&#xA;" OwnerUserId="14724" LastActivityDate="2016-02-23T16:31:33.673" Title="Arduino Due uploading error using Eclipse plugin &quot;avrdude: stk500_recv(): programmer is not responding&quot;" Tags="|arduino-due|eclipse|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17654" PostTypeId="2" ParentId="17640" CreationDate="2015-11-10T12:46:47.073" Score="1" Body="&lt;p&gt;I agree with Chris on this. The uno is limited where it comes to pins and and ram, you should probably look at a mega, or similar. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as running both at once, i don't think it would be possible with the uno, with the ram limitations, as well as pin limitations, you'll be hard pressed to get them going at the same time, within the same sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While technically it is possible to use alternative pins, i doubt there will be enough unused pins to shift an entire shield over to on the Uno&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're looking for a cheaper rout, you may look at adding a secondary Uno to run the wifi, and send any data you need displayed to the uno running the tft via serial coms.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-11-10T12:46:47.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17655" PostTypeId="2" ParentId="17623" CreationDate="2015-11-10T12:59:49.323" Score="0" Body="&lt;p&gt;If what i read is correct, then you've probably cooked your duino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for what exactly failed, i'm going to guess from your description, that one or both of the capacitors failed. Usually when they blow, you'll hear a loud snap like you describe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest testing those, and replacing them if they are faulty.. This is no guarantee that other components weren't damaged, but it's a good place to start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for why the LED's may still light up, that could be any number of reasons really, and not a particularly good indicator of what exactly failed. &lt;/p&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="12076" LastEditDate="2015-11-10T13:18:21.217" LastActivityDate="2015-11-10T13:18:21.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17656" PostTypeId="2" ParentId="17436" CreationDate="2015-11-10T13:02:38.757" Score="0" Body="&lt;p&gt;As a first approach, I'd collect a number of measurements from each of as many knowns as you can find or make, and plot them for a visual clue to the linearity or not (probably not) of the sensor's output vs. pH. You could try to eyeball-fit a curve to the data; interpolate linearly between sample points if you have enough of them; or run a least-squares approximation fit. The key is you'll need enough data - knowns - to make whatever approach you use give results accurate enough for your intended use. (Obviously this will be different if you just need to know if something is acidic or basic, or you're monitoring tropical fish tanks, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: &#xA;If your pH meter is good enough for the fish, and if your sensor is reliably repeatable and sensitive enough, why not check your meter against the two standards, then calibrate the sensor to your meter? Once you're happy with the result, lock down the screws with a dab of nail polish (it's not very tamper-proof but it will be tamper-evident). A pH 10.0 standard won't be very useful to you; at that extreme you'll already know the pH is out and you probably won't care about the exact value. You need your precision between the fish-tolerable limits, close to the pH goal.&#xA;In fact, if you trust your meter, you don't even need the standards. In that case you need only make up a few samples as you described, covering the pH range of interest, and use them to calibrate your sensor to the meter.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-11-10T17:07:51.817" LastActivityDate="2015-11-10T17:07:51.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17657" PostTypeId="2" ParentId="17653" CreationDate="2015-11-10T13:08:21.383" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's your clue. &#xA;1) programmer is not responding - This usually means the device isn't connected, or powered, or reachable by the IDE, make sure you have eclipse configured correctly for your device, and it's location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) not in sync - This is a redundant, or overlapping error, of course it's not going to sync if it can't connect.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="4143" LastEditDate="2015-11-10T13:49:03.380" LastActivityDate="2015-11-10T13:49:03.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17658" PostTypeId="2" ParentId="17647" CreationDate="2015-11-10T13:17:05.550" Score="2" Body="&lt;p&gt;1) Put your power source on an oscilloscope and check it. I assume what's happening is you don't have a clean sine, and the power fluctuates, whereas power from a PC USB port is usually very well regulated. This may be causing issues in your sensor due to under/over voltage at a minuscule level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Because you're pushing your sensors to the edge of their capabilities, you're going to have to work around them, so the normal scenario's don't really offer much help, as they are usually based on working within the middle ground of capabilities. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You said that factoring based on low load vs high load created unreliable  variances in your measurements, i would personally suggest calibrating not for max load, nor min load, but 2/3 of max, or 1/3 max, and see if that stabilizes you, or at least gets you somewhere to the middle of the road where your differences are nominal, or something you can live with. &lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2015-11-10T13:17:05.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17659" PostTypeId="1" CreationDate="2015-11-10T14:23:50.597" Score="0" ViewCount="1649" Body="&lt;p&gt;I'm new to Arduino and am learning how Serial communication works. I am trying to send a value from Matlab to Arduino, but it seems to be partly fruitful. If anyone can explain the difference between the acquiring input and predefined strings in Matlab &#xA;Here is the program I tried, and it is successful.&#xA;Arduino : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; %This program receives an array of chars and stores them in array and transmits them back &#xA;&#xA; const int no_of_fields = 3; &#xA; int field_index = 0;&#xA; int vec_to_hold[no_of_fields]; //Array to hold the numbers&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;}&#xA;void loop()&#xA;{&#xA;   if(Serial.available())&#xA;    {&#xA;     char ch = Serial.read();&#xA;     if(ch &amp;gt;= '0'&amp;amp;&amp;amp; ch&amp;lt;= '9') //check if the received chars are digits&#xA;      {&#xA;         if(field_index&amp;lt;no_of_fields)&#xA;           {&#xA;              vec_to_hold[field_index] = (vec_to_hold[field_index] * 10) + (ch -'0'); //accumulate values to form and integer&#xA;           }&#xA;      }&#xA;     else if(ch == ',')&#xA;     {&#xA;       field_index++;&#xA;     }&#xA;     else if(ch == '\n')&#xA;     {&#xA;        for (int i = 0;i&amp;lt;min(no_of_fields,field_index+1);i++)&#xA;         {&#xA;         Serial.print(vec_to_hold[i]);&#xA;         vec_to_hold[i] = 0;&#xA;         }&#xA;        Serial.println();&#xA;        field_index = 0;&#xA;      }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the Matlab side of Code : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete(instrfindall)&#xA;S = serial('COM3', 'BaudRate', 9600,'Terminator','LF'); %38400&#xA;fopen(S);&#xA;pause(0.1);&#xA;vec_sent = input('Enter : ','s');&#xA;fprintf(S,'%s\n',vec_sent);&#xA;pause(0.1);&#xA;t_value = fscanf(S,'%d');&#xA;disp(t_value);&#xA;delete(instrfindall)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code is working, but what if i don't want to enter the string. I want to be predefined. &#xA;For example in the above matlab code      &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vec_sent = '200,300,400';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If i convert this line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vec_sent = input('Enter : ','s');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; vec_sent = '200,300,400';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it does not work. The RX pin on the Arduino blinks indicating something is coming on the serial, but TX pin is not at all blinking, and nothing appears in MATLAB except an error stating &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Warning: Unsuccessful read: A timeout occurred before the Terminator was reached..&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would be grateful if anybody points out what I am doing wrong.&#xA;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="13910" LastEditorUserId="7856" LastEditDate="2015-11-11T03:12:19.873" LastActivityDate="2016-02-10T17:39:39.477" Title="Matlab and Arduino Serial communication" Tags="|arduino-uno|serial|matlab|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17660" PostTypeId="1" CreationDate="2015-11-10T14:33:09.323" Score="2" ViewCount="845" Body="&lt;p&gt;For a battery charging project, i am using an ARDUINO UNO which is driving a buck converter to provide the battery with the charging current. I am using external ADCs to measure the battery's charging voltage and current. The test setup is working fine, but right now i am just measuring the voltage and current at random time instants. However to measure it correctly, battery voltage reading should be done at an instant when the controller's PWM output is LOW (OFF duty cycle), and battery current reading should be done when PWM output is HIGH (ON duty cycle). So i was thinking how i can do that, since i am using analogueWrite() function to give PWM output, i thought if i could access analogueWrite() fucntion, may be i could there insert the function of read_ADC_Voltage() during the LOW time, and read_ADC_Current() during the HIGH time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my approach right ? If yes then can please anyone tell me how can i access and use this analogueWrite() function ? And if someone has any other idea to do the readings correctly, please suggest. I shall be grateful.&lt;/p&gt;&#xA;" OwnerUserId="13187" LastActivityDate="2015-11-11T14:01:35.467" Title="Read Voltage at PWM off time, and Current at PWM on time" Tags="|arduino-uno|pwm|analogwrite|adc|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17661" PostTypeId="1" CreationDate="2015-11-10T15:24:36.837" Score="2" ViewCount="119" Body="&lt;p&gt;In what situation would the Vin pin be attached to any of the I/O pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in what situation would the Vin pin be attached to an external circuit?&lt;/p&gt;&#xA;" OwnerUserId="14727" LastEditorUserId="2881" LastEditDate="2016-02-16T16:53:59.363" LastActivityDate="2016-02-16T16:53:59.363" Title="In what situation would the Vin pin be attached to any of the I/O pins?" Tags="|serial|" AnswerCount="2" CommentCount="0" ClosedDate="2016-02-19T21:39:44.000" ContentLicense="CC BY-SA 3.0" />
  <row Id="17662" PostTypeId="2" ParentId="17660" CreationDate="2015-11-10T15:24:43.450" Score="0" Body="&lt;p&gt;No, in my opinion changing functions in the Arduino Core is not a good approach. You would have to change it back for any other project you are going to do and secondly, if you insert a function in the part where analogWrite is low it will result in a change in the duty cycle. Which may not be a big problem, but just don't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice would be to use a timer to run a callback function every x seconds. Then in that function temporarily set the PWM to 0 and read your values. This is indeed not the most efficient approach, but we're talking about microseconds here... This approach is completely intterupt driven so you could run other things while it is running it's PWM and checking the voltage periodically. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds as if you have gotten pretty far by yourself, so I'm not going to write you example code. You can a tutorial on how to use a timer to periodically call a function &lt;a href=&quot;http://playground.arduino.cc/Code/ArduinoTimerObject&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2015-11-10T15:24:43.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17664" PostTypeId="2" ParentId="1180" CreationDate="2015-11-10T15:33:39.550" Score="2" Body="&lt;p&gt;CSV format is most versatile for any data (signed/unsigned, various size and precision). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cross-platform (written in Java/Scala) tool &lt;a href=&quot;https://github.com/tardigrade888/scsvlog&quot; rel=&quot;nofollow&quot;&gt;Scsvlog&lt;/a&gt; can receive/parse CSV strings from serial port / socket, show values and draw charts (up to 8).&lt;/p&gt;&#xA;" OwnerUserId="14728" LastEditorUserId="6936" LastEditDate="2015-11-13T17:57:32.953" LastActivityDate="2015-11-13T17:57:32.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17665" PostTypeId="2" ParentId="17661" CreationDate="2015-11-10T15:36:48.690" Score="3" Body="&lt;p&gt;Vin is exactly the same as using the barrel jack (DC in) on the Arduino.  You can use it when you want to power your Arduino from an external source and you don't want to have the bulk of a big power plug.  It can also be used as a power output when you are using the barrel jack, for instance for powering relays or motors.  It just saves on having to splice wires into the cable of a wall wart, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage you feed in to the Vin pin should be of the same specification as the barrel jack - that is, between 7 and 12V.  From there, just like the barrel jack, it goes to the 5V regulator to provide the 5V for the board, and then on to the 3.3V regulator for low powered peripherals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, at any time, you power the board from the USB and have something connected to the Vin pin that consumes power you risk damaging the 5V regulator on the Arduino since power will flow backwards through it form 5V to Vin, which it really isn't meant to do.  In these situations it is good to connect a diode between 5V and Vin such that the anode is on 5V and the cathode on Vin - so that if the 5V is higher than the Vin voltage then the current will bypass the regulator safely.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-10T15:36:48.690" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17666" PostTypeId="1" AcceptedAnswerId="17668" CreationDate="2015-11-10T18:24:37.377" Score="5" ViewCount="20640" Body="&lt;p&gt;I have a ESP8266_01, and I wired up. It does not work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected the ESP to an Arduino Uno. I am using a 5V pin from uP with a 3.3V regulator, and I have a voltage divider between RX(ESP) and TX(uP). And I am sure that the wiring is correct. The thing is, I am not getting anything back from ESP, not even errors. And I tried to use different baudrates as well. There is a blue LED flashing from ESP only when I am using 115200, and red LED lights up constantly at any other baudrate.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What have I done wrong here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did 4 hours of research already and don't know what else I can do now. &#xA;If you have any idea, please leave me a word.&lt;/p&gt;&#xA;" OwnerUserId="14732" LastEditorUserId="27346" LastEditDate="2017-11-23T23:30:21.933" LastActivityDate="2017-11-23T23:30:21.933" Title="ESP 8266 does not respond at all" Tags="|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17668" PostTypeId="2" ParentId="17666" CreationDate="2015-11-10T18:50:59.077" Score="4" Body="&lt;p&gt;Start by uploading blink sketch to your Arduino then connect it to your ESP8266 like this: TX-TX and RX-RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now open Serial Monitor and send AT command and see if it responds. If so then you can control it using your Arduino by wiring it back to TX-RX and RX-TX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Don't forget to set the line ending in the Serial Monitor to Newline or Carriage Return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Use this code to connect to ESP8266:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 2; // Wire this to Tx Pin of ESP8266&#xA;const byte txPin = 3; // Wire this to Rx Pin of ESP8266&#xA;&#xA;// We'll use a software serial interface to connect to ESP8266&#xA;SoftwareSerial ESP8266 (rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  ESP8266.begin(115200); // Change this to the baudrate used by ESP8266&#xA;  delay(1000); // Let the module self-initialize&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Sending an AT command...&quot;);&#xA;  ESP8266.println(&quot;AT&quot;);&#xA;  delay(30);&#xA;  while (ESP8266.available()){&#xA;     String inData = ESP8266.readStringUntil('\n');&#xA;     Serial.println(&quot;Got reponse from ESP8266: &quot; + inData);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the Hardware Serial interface will be busy when connected to Computer, then you have to use another Serial interface to communicate with your ESP8266. In this case, Software Serial comes handy. &lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-10T19:56:32.907" LastActivityDate="2015-11-10T19:56:32.907" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17670" PostTypeId="2" ParentId="17660" CreationDate="2015-11-10T20:16:08.707" Score="1" Body="&lt;p&gt;Add a pin-change-interrupt (PCI) handler (See eg &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;PinChangeInt&lt;/a&gt; at arduino.cc); clear the flag and enable the interrupt whenever you want to take readings, and disable that PCI after you have the reading.  As noted in the link, PCIs are available on all signal pins (possibly not on A6 and A7 on the 328), so are available on any of the PWM pins.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-10T20:16:08.707" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17672" PostTypeId="2" ParentId="17661" CreationDate="2015-11-10T20:47:40.330" Score="2" Body="&lt;p&gt;Vin connected to an IO pin: If you want to damage your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hypothetically, I could imagine a misguided attempt to detect if it's being powered from a barrel jack or from USB, but the higher voltage (and it will ALWAYS be a higher voltage if powered from that rail) is likely to damage the chip&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do that safely/correctly, you would need a voltage divider, to reduce both the voltage to a level below the +5v level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin to an external circuit is very reasonable. If you have, for example, a motor that needs +12v, and your Vin is 12v, then you can provide the power for the motor from Vin, and still control it from the Arduino - you would use a transistor to turn the +5v from one of the digital pins (set to output) to 12v from Vin. This is typically what happens on a &quot;motor driver&quot; - for example, see &lt;a href=&quot;http://www.hobbytronics.co.uk/image/data/tutorial/bipolar-stepper-drive.jpg&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/image/data/tutorial/bipolar-stepper-drive.jpg&lt;/a&gt; - on the left-hand side, you will see &quot;motor supply&quot; - this runs at a higher voltage (and is isolated from +5v and Arduino pins), and if your motor needs what the barrel jack supplies (and is no more than 12v), then Vin is perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other situation is that you can put +7v to +12v INTO the Vin, instead of using the barrel jack - this will power your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-11-10T20:47:40.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17673" PostTypeId="2" ParentId="17659" CreationDate="2015-11-10T22:23:19.203" Score="0" Body="&lt;p&gt;The Arduino parsing code seems to function correctly. If I just use the IDE Serial Monitor window and enter &quot;200,300,400&quot;, the Arduino replies &quot;200300400&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error message says that you either did not get the LF, or the LF did not arrive within 0.1 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to try, as I do not have MATLAB, is to change how the Arduino replies.  On the Arduino, &lt;code&gt;Serial.println&lt;/code&gt; will send a CR and a LF at the end.  Perhaps you should just do the LF explicitly instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0;i&amp;lt;min(no_of_fields,field_index+1);i++)&#xA;{&#xA;  Serial.print(vec_to_hold[i]);&#xA;  vec_to_hold[i] = 0;&#xA;}&#xA;Serial.print( (char)10 ); // just LF, not CR/LF with println&#xA;field_index = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will test whether the CR is causing a line termination problem in MATLAB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is that the &lt;code&gt;pause(0.1)&lt;/code&gt; is too short.  The documentation states that this is highly dependent on the OS timer resolution.  Try &lt;code&gt;pause(1)&lt;/code&gt;.  This will test whether the time is too short.  At 9600, 0.1s is only 100 character times.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2015-11-12T16:35:26.890" LastActivityDate="2015-11-12T16:35:26.890" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17674" PostTypeId="2" ParentId="17659" CreationDate="2015-11-10T23:27:55.433" Score="1" Body="&lt;p&gt;To confirm that the cause of the connection problem is not the software, you can try to connect using reliable software. Do do this, download and install the MATLAB support package for Arduino hardware: &lt;a href=&quot;http://www.mathworks.com/hardware-support/arduino-matlab.html&quot; rel=&quot;nofollow&quot;&gt;http://www.mathworks.com/hardware-support/arduino-matlab.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7631" LastActivityDate="2015-11-10T23:27:55.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17675" PostTypeId="1" AcceptedAnswerId="17678" CreationDate="2015-11-11T01:44:09.753" Score="3" ViewCount="3046" Body="&lt;ul&gt;&#xA;&lt;li&gt;I upload a blank sketch: pin 13 LED is on. Why?&lt;/li&gt;&#xA;&lt;li&gt;I connect pin 13 to GND: it turns off until I remove the connection&lt;/li&gt;&#xA;&lt;li&gt;I connect multimeter between pin 13 and GND: measures 0.14V and LED turns off until multimeter is removed&lt;/li&gt;&#xA;&lt;li&gt;I press hard reset: LED blinks a few times, turns off for a second then turns on&lt;/li&gt;&#xA;&lt;li&gt;I upload a sketch that on setup sets pinMode(13, INPUT): pin 13 LED is on&lt;/li&gt;&#xA;&lt;li&gt;I upload a sketch that on setup sets pinMode(13, OUTPUT): pin 13 LED is off 0.01V&lt;/li&gt;&#xA;&lt;li&gt;I upload a Blink example: Everything works fine, LED cycles from 4.84V to 0.01V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Why is the LED on unless I set pinMode to output? Have I broken my UNO or is this normal?&#xA;I swear it wasn't like this a few days ago.&lt;/p&gt;&#xA;" OwnerUserId="14742" LastActivityDate="2017-08-07T08:37:31.783" Title="Uno pin 13 LED mysteriously always ON at 0.14V unless pinMode OUTPUT" Tags="|arduino-uno|led|pins|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17676" PostTypeId="2" ParentId="17436" CreationDate="2015-11-11T01:53:38.680" Score="3" Body="&lt;p&gt;The schematic only shows one trim pot (R23), and it does, as you suspect, set a level for the LED to illuminate.  More of a GOOD/BAD indicator, and is available on pin &lt;code&gt;DO&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other trim pot is not on the schematic.  Is it marked on the board?  R6, R7, R8 or R9 maybe?  It probably controls the gain on &lt;code&gt;p_AOUT&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;t_AOUT&lt;/code&gt; is an analog temperature voltage, and appears to measure the temperature of the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit - official but totally bogus:&lt;/strong&gt; &lt;strike&gt;According to my secret source, you are supposed to put the probe in the pH 7.0 reference solution and, with &lt;code&gt;Offset&lt;/code&gt; defined to be 0.0, run the program and display the calculated pH value.  You may need to decrease the trim pot gain to get smaller (the smallest?) numbers.  Now take that displayed value and modify the &lt;code&gt;Offset&lt;/code&gt; constant in the sketch to be 7.0 minus the displayed value.  If the displayed value is 8.1,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Offset (-1.1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Build and upload the modified sketch.  This time, put the probe in your pH 4.0 reference solution and adjust the gain pot until the displayed value is as close to 4.0 as you can get.  This will calibrate it for mostly acidic solutions.&lt;/strike&gt;&#xA;&lt;hr&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit 1: Iterate?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It's not clear, but I also wondered if this procedure is supposed to be iterated.  Go back to 7 and make sure that adjusting the gain didn't change &lt;code&gt;Offset&lt;/code&gt;. Then test the pH 4 solution again; the gain pot may require a small(er) change. If it seems to be diverging, um, don't do that. ;)  I think it would diverge only if the probe had an inverted response, which would probably mean it's bad. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are measuring basic solutions, do the same procedure with reference solutions of pH 7.0 (of course) and a basic reference solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voilà!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: For the 7.0 test, you could short the probe pins together. It really should look like a short circuit when pH == 7.0.  If switching to using the real probe in the pH 7.0 solution gives wildly different readings, the probe &lt;em&gt;may&lt;/em&gt; be bad.  If you're able to calibrate it, it &lt;em&gt;may&lt;/em&gt; be &quot;good enough&quot;. &#xA;&lt;hr&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit 2: Fix the formulas in the provided sketch.&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The schematic shows a non-inverting op amp with &lt;code&gt;PH+&lt;/code&gt; on the input, and &lt;code&gt;p_AOUT&lt;/code&gt; on the output.  The (adjustable?) gain is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R9/R8 + 1 = 10k/10k + 1 = 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The slope of an ideal probe response is -59mV/pH.  You were experimentally getting a negative slope, which agrees with the schematic.  I believe it was correct to &quot;invert&quot; the &lt;code&gt;analogRead&lt;/code&gt; value by subtracting it from 1024.  There is no way that the provided code could have worked with a positive slope of 3.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reference voltage provided to the the &lt;code&gt;PH-&lt;/code&gt; pin is half the zener diode voltage... which is unidentified.  It could be the very-common 5.1V part, which is essentially forcing &lt;code&gt;PH-&lt;/code&gt; to be at &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5.1V/((R6+R7)/R6) = 5.1V/2 = 2.55V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I say probably, because you usually want the plus or minus probe voltage swing to have as much room as possible.  This would imply (an ideal) &lt;code&gt;analogRead&lt;/code&gt; of pH 7.0 to be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2.55V/5.0V * 1024 = 522&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the &quot;center&quot; of the probe swing about pH 7.0.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 1: Determine the reference voltage&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;At pH 7.0, print out the raw &lt;code&gt;analogRead&lt;/code&gt; return value, before inverting it.  (The pot wiper should be at it's limit.  Which way, I don't know.  Changing the gain pot shouldn't change the &lt;code&gt;analogRead&lt;/code&gt; very much at the low-gain end.  If it does change it, turn it to the other extreme.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As stated before, you can run the pH 7.0 test by shorting the BNC connector pin to the shield or by using your reference solution.  I recommend shorting for now, to eliminate any possible interference from the probe.  It will absolutely determine the offset, but only if the gain is as small as possible.  You have to start here.  Once you know the center reading, you can change the code to display the voltage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CENTER 522&#xA;int avgValue=0;&#xA;for(int i=2;i&amp;lt;8;i++)  // take the average value of 6 center samples&#xA;  avgValue += (buf[i] - CENTER);&#xA;float voltage = (((float)avgValue) / 6.0) * (5.0 / 1024.0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Print this out.  You'd better get something close to 0.0... don't make me come over there.  :)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 2: Set the gain pot.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is determining the slope, but you need to maximize the swing for the most extreme pH you want to read, say 4.0.  Using the 4.0 reference solution, adjust the gain pot so that the displayed voltage is close to +2.5V, say +2.25V to make sure it's not pegged at 1024.  (Let's see, slope is negative, 4.0 is &amp;lt; 7.0, so voltage should increase...)  With that reading, you can calculate the pH/V:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-3pH/2.25V  =  -1.33 pH/V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Step 3: Calculate and print pH&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Modify the original computation to use the pH/V slope:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float phValue = voltage * (-1.33) + 7.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not even close to &lt;code&gt;phValue = 3.5*voltage + Offset&lt;/code&gt;.  -_-  &amp;nbsp; I have found several source now that echo my original answer.  Totally wrong, and wrong to the point of misleading.  I do think these steps will do it.  It sounds good in my head, anyway.  :D&#xA;&lt;hr&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit 3: &quot;Next question is how to convert this into a suitable formula?&quot;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Ok, if you don't want to fix the formula in the code, you can fit a linear or quadratic curve to your data.  Linear is actually recommended as &quot;good enough&quot;, and that is effectively the change suggested in &lt;strong&gt;Edit 2&lt;/strong&gt;.  If we just use your data points, though, this would be the linear approximation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float adjustedPh = phValue * 1.627 - 2.499;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and the quadratic approximation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float adjustedPh = (-0.01796 * phValue + 1.8056) * phValue - 2.94;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2015-11-15T03:54:47.390" LastActivityDate="2015-11-15T03:54:47.390" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17677" PostTypeId="2" ParentId="17675" CreationDate="2015-11-11T02:42:29.790" Score="1" Body="&lt;p&gt;Apparently it's normal. Although random. Sometimes the default voltage of the pin is high enough to make the LED light up because of the op-amp. Sometimes it isn't.&#xA;Source: &lt;a href=&quot;https://electronics.stackexchange.com/a/39707&quot;&gt;https://electronics.stackexchange.com/a/39707&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14742" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-11-11T02:42:29.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17678" PostTypeId="2" ParentId="17675" CreationDate="2015-11-11T02:52:17.413" Score="8" Body="&lt;p&gt;The LED is driven by an op-amp (see the schematic). When the pin is configured as input the op-amp has an undefined input (floating input). Thus it may or may not turn on the LED. If you configure it to an output the op-amp is driven in a known way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J8xMt.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J8xMt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why is the LED on unless I set pinMode to output? Have I broken my UNO or is this normal?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's perfectly normal.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think they did this to stop the LED &quot;loading&quot; the SCK pin (pin 13), particularly if you have it configured as an input and are trying to measure something, the 1k resistor and LED would throw out the measurement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could conceivably have a pull-down resistor from SCK to GND, but that would load the pin as well.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-11T02:52:17.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17679" PostTypeId="2" ParentId="17436" CreationDate="2015-11-11T03:45:30.773" Score="0" Body="&lt;p&gt;I can't ask a question but make sure you're giving it enough power for the heating element, its not much but you never know try a separate power source if you are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you mentioned the nano, are you using a 3.3v nano or 5V nano?  (the regulator would have a 33 or 50 on it after a letter or two)  if 3.3V and assuming by example code they give the analog output is 5V you'll need a level shifter of sorts to map to 3.3V, then change the calculations to use 3.3 instead of 5 value.    if that's not the case and it's not power or connections then it may be broke or the probe etc.... there's a few variables. &lt;/p&gt;&#xA;" OwnerUserId="14405" LastActivityDate="2015-11-11T03:45:30.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17680" PostTypeId="2" ParentId="17623" CreationDate="2015-11-11T03:59:58.173" Score="1" Body="&lt;p&gt;I want to make this obvious to the casual reader:  Mega Sensor Shields -- all versions I've data on -- run the power connector to +5V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power connector &lt;strong&gt;&lt;em&gt;is not power in&lt;/em&gt;&lt;/strong&gt;, as defined by the base board.  In fact, there is no direct way to get to the base board regulator from the shield.  (A pin exists for Vin, but it isn't connected to anything on the shield.  It's mechanical support.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's intended to supply more current to devices connected via the shield than the base board does.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a jumper that disconnects the sensor shield +5 rail from base board power to allow independent &lt;strong&gt;&lt;em&gt;+5 volts distribution&lt;/em&gt;&lt;/strong&gt; to the shield attached devices.&lt;/p&gt;&#xA;" OwnerUserId="14697" LastActivityDate="2015-11-11T03:59:58.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17681" PostTypeId="2" ParentId="17236" CreationDate="2015-11-11T07:40:26.357" Score="0" Body="&lt;p&gt;I think you may not install arduino hardware and ftd drivers,&#xA;Follow the steps given here and then check,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Download the latest version of Arduino software and install it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open windows device manager - You can open windows device manager by right   clicking on 'My Computer' and choosing Properties. In the new Window, Click on    Device Manager &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now Scroll Down the List of Devices in the Device Manager till you come to a Device or expand Ports (COMM).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now you should see Arduino hardware with warning icon or without.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now do right click on arduino hardware name. Now, Windows will provide you two options, Choose the one that says “Locate and install drivers manually from a specific Location.”&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;By browsing locate arduino installed folder, then update.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you previously done these procedure or now, then open arduino software&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to tools and choose board as what you have like (arduino uno, mega, due etc....)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;then in tools menu you should choose serial port (example comm 10, comm 21, comm 8 etc...) in which the arduino board connected, some time the board name displays with serial port otherwise you can observe from device manager ports list.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;now upload blink example and check.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="14746" LastActivityDate="2015-11-11T07:40:26.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17685" PostTypeId="1" AcceptedAnswerId="17686" CreationDate="2015-11-11T10:57:03.863" Score="0" ViewCount="232" Body="&lt;p&gt;I'm trying my best to understand and utilise questions that already exist as well as other websites, however I just wanted to check the circuit I've come up with (which is a very simple switch circuit) will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan on using a &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/bd/bd135.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;BD139&lt;/a&gt; transistor, although I haven't purchased anything yet, so can change to anything really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fans are each 0.09A at 12V. I've calculated that R1 should be 360ohms. The 5V control will be coming from an Arduino. I believe it's within the specs of the transistor. Ic max is 1.5A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the circuit look correct? Are there any changes I should make?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/1CWRD.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="6331" LastActivityDate="2015-11-11T11:13:37.433" Title="Understanding transistor datasheets" Tags="|transistor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17686" PostTypeId="2" ParentId="17685" CreationDate="2015-11-11T11:13:37.433" Score="2" Body="&lt;p&gt;For saturation you should assume h&lt;sub&gt;fe&lt;/sub&gt; to be 10. This gives:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(5V − 0.85V) / ((0.09A ⋅ 3) / 10) = 154 Ω&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider using a 150-220Ω base resistor instead. And since a fan is an inductive load, don't forget the flyback diode from the collector to the +12V rail. A 1N4000 series diode should be fine for this small a load.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-11T11:13:37.433" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17687" PostTypeId="1" CreationDate="2015-11-11T11:16:27.550" Score="1" ViewCount="4584" Body="&lt;p&gt;I'm working with arduino nano and it has interfaced with SIM900 GSM. I'm sending &quot;AT\r&quot; to GSM modem, but not getting response. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Setup is Ready&quot;);  &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   Serial.write(&quot;AT\r&quot;);&#xA;   delay(1000);&#xA;   if(Serial.available() &amp;gt; 0)&#xA;   {&#xA;     Serial.println(&quot;Data received&quot;);&#xA;     Serial.println(Serial.read());&#xA;   }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setup is Ready&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATATATATATATATATATATATATATATATATATAT&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set the 9600 baudrate to modem and my rx and tx is connected correctly...&#xA;What is the problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="11672" LastActivityDate="2017-07-06T04:34:11.960" Title="SIM900 Modem is not responding" Tags="|serial|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17688" PostTypeId="2" ParentId="17687" CreationDate="2015-11-11T11:43:37.227" Score="1" Body="&lt;p&gt;You aren't talking to the SIM900. You are just communicating with the serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="781" LastActivityDate="2015-11-11T11:43:37.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17690" PostTypeId="2" ParentId="17660" CreationDate="2015-11-11T14:01:35.467" Score="1" Body="&lt;p&gt;P.S I am writing it as an answer since my code wont fit in comment&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked into interrupts and learned about them that there are 2 types of interrupts in Arduino namely &quot;external&quot;, and &quot;pin change&quot;. So i downloaded the &quot;PinChangeInt Library&quot; to test it. I wrote a small program where a PWM of 62.5kHz is being generated on pin3, and i am calling rising and falling edge triggered interrupts on this pin, i.e to display one value when rising edge occurs, and other value when falling edge occurs. My code looks like following: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;PinChangeInt.h&amp;gt;&#xA;    #define pw 3&#xA;    int pwm;&#xA;&#xA;&#xA;    void setup() {&#xA;      // put your setup code here, to run once:&#xA;      pinMode(pw, OUTPUT) ;&#xA;      pwm_setup();             // Set PWM to a frequency of 62.5kHz&#xA;&#xA;      PCintPort::attachInterrupt(pw,rise,RISING);    // call void rise() when PWM is HIGH&#xA;      PCintPort::attachInterrupt(pw,fall,FALLING);   // call void fall() when PWM is LOW&#xA;&#xA;&#xA;      Serial.begin(9600);&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // put your main code here, to run repeatedly:&#xA;      pwm = 127;                                                // 50% duty cycle&#xA;      pwm_on(pwm);&#xA;&#xA;    }&#xA;    void pwm_setup()&#xA;    {&#xA;&#xA;      TCCR2A = 0x23 ;&#xA;      TCCR2B = 0x09 ; // mode 7, clock prescale by 1&#xA;      OCR2A = 256-1 ;  // 256 clock periods = 16us per cycle&#xA;      OCR2B =0 ;&#xA;      TCNT2 =0 ;&#xA;&#xA;    }&#xA;    void pwm_on(double)&#xA;     {&#xA;        OCR2B = pwm ;&#xA;     }&#xA;&#xA;    void rise()&#xA;    {&#xA;      Serial.println(&quot;RISE&quot;);&#xA;    }&#xA;&#xA;void fall()&#xA;{&#xA;  Serial.println(&quot;fall&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is not working the way i think it should. It keeps on displaying &quot;fall&quot; every time, whereas according to me it should display &quot;RISE&quot; and &quot;fall&quot; alternatively, right ? However if i remove the &quot;PCintPort::attachInterrupt(pw,fall,FALLING); &quot; line, it starts to display &quot;RISE&quot; as it is supposed to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since its my first time programming with Arduino, and i am just a beginning level programmer, i might be making some stupid mistake here. So can you point it out please ?&lt;/p&gt;&#xA;" OwnerUserId="13187" LastActivityDate="2015-11-11T14:01:35.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17691" PostTypeId="2" ParentId="17319" CreationDate="2015-11-11T14:05:20.360" Score="1" Body="&lt;p&gt;MATLAB has a &lt;a href=&quot;http://www.mathworks.com/hardware-support/arduino-matlab.html&quot; rel=&quot;nofollow&quot;&gt;free add-on for connecting to Arduino hardware&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7631" LastActivityDate="2015-11-11T14:05:20.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17692" PostTypeId="2" ParentId="17687" CreationDate="2015-11-11T14:19:35.420" Score="2" Body="&lt;p&gt;You should not use the same Serial interface to debug and talk to your SIM900. You should use a SoftwareSerial interface to talk to the SIM900 and use the hardware Serial to send response back to your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 2; // Wire this to Tx Pin of SIM900&#xA;const byte txPin = 3; // Wire this to Rx Pin of SIM900&#xA;&#xA;// We'll use a software serial interface to connect to SIM900&#xA;SoftwareSerial SIM900(rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  SIM900.begin(9600); // Change this to the baudrate used by SIM900&#xA;  delay(1000); // Let the module self-initialize&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Sending an AT command...&quot;);&#xA;  SIM900.println(&quot;AT&quot;);&#xA;  delay(30);&#xA;  while (SIM900.available()){&#xA;     String inData = SIM900.readStringUntil('\n');&#xA;     Serial.println(&quot;Got reponse from SIM900: &quot; + inData);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-11T14:19:35.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17693" PostTypeId="1" AcceptedAnswerId="17698" CreationDate="2015-11-11T14:38:33.657" Score="2" ViewCount="4176" Body="&lt;p&gt;The serial port on my Arduino Mega is receiving 3 floats as bytes (total of 12 bytes, 4 per float) over serial. Unfortunately I cannot assemble the 4 Bytes in a float, as the serial monitor only displays&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0.00&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0.00&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0.00&lt;/code&gt; etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent2() {&#xA;  if (Serial2.available() &amp;gt; 11) {&#xA;    byte yawData[3];&#xA;    yawData[0] = Serial2.read();&#xA;    yawData[1] = Serial2.read();&#xA;    yawData[2] = Serial2.read();&#xA;    yawData[3] = Serial2.read();&#xA;    float yawAngle = *((float*)(yawData));&#xA;    Serial.println(yawAngle);&#xA;&#xA;    byte pitchData[3];&#xA;    pitchData[0] = Serial2.read();&#xA;    pitchData[1] = Serial2.read();&#xA;    pitchData[2] = Serial2.read();&#xA;    pitchData[3] = Serial2.read();&#xA;    float pitchAngle = *((float*)(pitchData));&#xA;&#xA;    byte rollData[3];&#xA;    rollData[0] = Serial2.read();&#xA;    rollData[1] = Serial2.read();&#xA;    rollData[2] = Serial2.read();&#xA;    rollData[3] = Serial2.read();&#xA;    float rollAngle = *((float*)(rollData));&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made sure the data coming to Serial2 is not &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; The initial mistake was my byte array not being sized correctly. I fixed it. The values I print are fine until after about a second, they get totally weird. Dropped bits/Bytes maybe? Seems odd because a sample sketch written in Processing works perfectly while taking the exact same input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Si6fa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Si6fa.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14535" LastEditorUserId="14535" LastEditDate="2015-11-11T23:29:49.973" LastActivityDate="2015-11-12T09:07:37.087" Title="Assemble or typecast byte array to float" Tags="|serial|data-type|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17694" PostTypeId="2" ParentId="17693" CreationDate="2015-11-11T14:55:06.730" Score="2" Body="&lt;p&gt;If you must do it that way I'd recommend using a &lt;code&gt;union&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef union {&#xA;    float val;&#xA;    uint8_t bytes[4];&#xA;} floatval;&#xA;&#xA;floatval v;&#xA;v.bytes[0] = Serial2.read();&#xA;v.bytes[1] = Serial2.read();&#xA;v.bytes[2] = Serial2.read();&#xA;v.bytes[3] = Serial2.read();&#xA;Serial.println(v.val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A better solution is to just write and read the raw float data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sender:&#xA;Serial.write((const char *)&amp;amp;myfloat, sizeof(float));&#xA;&#xA;// Receiver&#xA;Serial2.readBytes((char *)&amp;amp;myfloat, sizeof(float));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even better still is to define a &lt;code&gt;struct&lt;/code&gt; which is the packet of data you wish to send:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct {&#xA;    float yaw;&#xA;    float pitch;&#xA;    float roll;&#xA;} attitude;&#xA;&#xA;attitude myatt;&#xA;myatt.yaw = 14.9;&#xA;myatt.pitch = 23.4;&#xA;myatt.roll = 11.49;&#xA;&#xA;Serial.write((const char *)&amp;amp;myatt, sizeof(attitude));&#xA;&#xA;// receive:&#xA;&#xA;attitude myatt;&#xA;Serial2.readBytes((char *)&amp;amp;myatt, sizeof(attitude));&#xA;Serial.println(myatt.yaw);&#xA;Serial.println(myatt.pitch);&#xA;Serial.println(myatt.roll);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-11T15:14:47.227" LastActivityDate="2015-11-11T15:14:47.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17695" PostTypeId="1" CreationDate="2015-11-11T14:59:49.527" Score="-1" ViewCount="536" Body="&lt;p&gt;What are the most common ways of destroying a Arduino using the I/O pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in what situation would it be acceptable to attach the positive or negative end of a power supply to an I/O pin?&lt;/p&gt;&#xA;" OwnerUserId="14727" LastEditorUserId="6424" LastEditDate="2015-11-12T08:56:09.283" LastActivityDate="2019-06-02T20:43:16.127" Title="How to destroy my Arduino with I/O pins?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17696" PostTypeId="2" ParentId="17693" CreationDate="2015-11-11T15:00:44.760" Score="0" Body="&lt;p&gt;try use memcpy, i think it might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent2() {&#xA;  if (Serial2.available() &amp;gt; 11) {&#xA;    byte yawData[4];&#xA;    float yawAngle = 0;&#xA;    yawData[0] = Serial2.read();&#xA;    yawData[1] = Serial2.read();&#xA;    yawData[2] = Serial2.read();&#xA;    yawData[3] = Serial2.read();&#xA;    memcpy(&amp;amp;yawAngle, &amp;amp;yawData,sizeof(float));&#xA;    Serial.println(yawAngle);&#xA;&#xA;    // same for others ...&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-11-11T15:00:44.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17697" PostTypeId="2" ParentId="17695" CreationDate="2015-11-11T15:05:32.517" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What are the most common ways of destroying a Arduno using the I/O pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Over-voltage and over-current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over-voltage involves putting too high (or too low) a voltage onto an IO pin.  Over-current involves trying to source (or sink) too much current through an IO pin.  Both can be fatal.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, in what situation would it be acceptable to attach the positive or negative end of a power supply to an I/O pin?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Positive&quot;:&lt;/strong&gt; When that power supply is no more than 5V and shares ground with the Arduino and you want to know if it's on or not, or measure the voltage (Analog Input).  Anything more than 5V will require a voltage divider to bring the voltage down to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&quot;Negative&quot;:&lt;/strong&gt; If by that you mean the ground terminal, and that ground terminal is shared with the Arduino ground, then you can do it any time - but why would you, since you'd just be connecting to the Arduino ground since they are one and the same. If it's not the ground terminal but a potential &lt;em&gt;below&lt;/em&gt; ground, then never unless you use some circuitry to raise that potential above ground for measuring it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-11T15:05:32.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17698" PostTypeId="2" ParentId="17693" CreationDate="2015-11-11T15:11:25.830" Score="3" Body="&lt;p&gt;I tried the code below and it worked for me, don't miss the &lt;code&gt;delay()&lt;/code&gt; part: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sender Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    float yaw = 10.5;&#xA;    float pitch = 20.15;&#xA;    float roll = 100.10;&#xA;    float ypr[3];  &#xA;    ypr[0] = yaw;&#xA;    ypr[1] = pitch;&#xA;    ypr[2] = roll;&#xA;    Serial.write((byte*) ypr, 12);  // No new-line&#xA;    delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiver Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&#xA;void serialEvent() {&#xA;    if (Serial.available() == 12){&#xA;      byte yawData[4];&#xA;      yawData[0] = Serial.read();&#xA;      yawData[1] = Serial.read();&#xA;      yawData[2] = Serial.read();&#xA;      yawData[3] = Serial.read();&#xA;      float yawAngle = *((float*)(yawData));&#xA;      Serial.println(yawAngle);&#xA;&#xA;      yawData[0] = Serial.read();&#xA;      yawData[1] = Serial.read();&#xA;      yawData[2] = Serial.read();&#xA;      yawData[3] = Serial.read();&#xA;      float yawPitch = *((float*)(yawData));&#xA;      Serial.println(yawPitch);&#xA;&#xA;      yawData[0] = Serial.read();&#xA;      yawData[1] = Serial.read();&#xA;      yawData[2] = Serial.read();&#xA;      yawData[3] = Serial.read();&#xA;      float yawRoll = *((float*)(yawData));&#xA;      Serial.println(yawRoll);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Results:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/84qZ5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/84qZ5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-12T09:07:37.087" LastActivityDate="2015-11-12T09:07:37.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17699" PostTypeId="2" ParentId="17693" CreationDate="2015-11-11T17:05:59.593" Score="0" Body="&lt;p&gt;What if you write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yawData[3] = Serial2.read();&#xA;yawData[2] = Serial2.read();&#xA;yawData[1] = Serial2.read();&#xA;yawData[0] = Serial2.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i.e. you change the endianness of the representation&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-11-11T17:05:59.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17700" PostTypeId="2" ParentId="17695" CreationDate="2015-11-11T18:13:48.837" Score="1" Body="&lt;p&gt;There are many ways to destroy an Arduino, check out this article, &lt;a href=&quot;http://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;10 Ways to Destroy An Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Shorting I/O Pins to Ground&lt;/li&gt;&#xA;  &lt;li&gt;Shorting I/O Pins to Each Other&lt;/li&gt;&#xA;  &lt;li&gt;Apply Overvoltage to I/O Pins&lt;/li&gt;&#xA;  &lt;li&gt;Apply External Vin Power Backwards&lt;/li&gt;&#xA;  &lt;li&gt;Apply &gt;5V to the 5V Connector Pin&lt;/li&gt;&#xA;  &lt;li&gt;Apply &gt;3.3V to the 3.3V Connector Pin&lt;/li&gt;&#xA;  &lt;li&gt;Short Vin to GND&lt;/li&gt;&#xA;  &lt;li&gt;Apply 5V External Power with Vin Load&lt;/li&gt;&#xA;  &lt;li&gt;Apply &gt;13V to the Reset Pin&lt;/li&gt;&#xA;  &lt;li&gt;Exceed Total Microcontroller Current&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="27346" LastEditDate="2019-06-02T20:43:16.127" LastActivityDate="2019-06-02T20:43:16.127" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17701" PostTypeId="1" AcceptedAnswerId="17702" CreationDate="2015-11-11T18:34:37.313" Score="2" ViewCount="88" Body="&lt;p&gt;I'm trying to make a gag gift for a friend. The effect I'm trying to imitate is of a device that starts up for a moment and then putters out like something is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I need it to:&#xA;1. Vibrate a motor for a second or two.&#xA;2. Make the vibration sputter out.&#xA;3. Light up an LED behind an error message on a paper screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have very little hands on experience with anything electronic, but I have some programming and I took enough physics to know what a capacitor, etc is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are whether an Arduino is a good and cost effective way to accomplish this and is there any beginner friendly advice anyone can give me to get this accomplish&lt;/p&gt;&#xA;" OwnerUserId="14760" LastActivityDate="2015-11-11T19:00:08.743" Title="Giving the impression of a dying device - making a vibrating motor slow down and stop" Tags="|led|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17702" PostTypeId="2" ParentId="17701" CreationDate="2015-11-11T19:00:08.743" Score="1" Body="&lt;p&gt;You can control the motor using PWM (Pulse Width Modulation) and make it run for full, then slowly decrease the speed till stop and after light up the led.&#xA;This tutorial from Adafruit could be a good start if you are not familiar with PWM and have also some good advices: &lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please be really careful about the supply source. Motors can easy draw more current then the limited available from the pins of arduino. Maybe a H-bridge could be helpfull here.(take a look at this for example of h-bridge: &lt;a href=&quot;https://learn.adafruit.com/adafruit-raspberry-pi-lesson-9-controlling-a-dc-motor/lm293d&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-raspberry-pi-lesson-9-controlling-a-dc-motor/lm293d&lt;/a&gt; )&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-11-11T19:00:08.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17703" PostTypeId="1" CreationDate="2015-11-11T19:31:41.900" Score="1" ViewCount="942" Body="&lt;p&gt;I saw &lt;a href=&quot;https://arduino.stackexchange.com/questions/8934/send-keyboard-media-keys-with-keyboard-library&quot;&gt;this answer&lt;/a&gt; but I can't find the analog for Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried cycling thru keycodes from 0x01 thru maybe 0x500, and I went thru ascii a few times, also found brightness up/down, and &lt;code&gt;F11&lt;/code&gt;, &lt;code&gt;F12&lt;/code&gt;, but they get pressed &lt;strong&gt;with fn key by default&lt;/strong&gt; which makes them do operations other than vol +/-.&lt;/p&gt;&#xA;" OwnerUserId="11714" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-11-11T22:16:59.463" Title="How to send volume +/- on Mac/OSX from Leonardo" Tags="|arduino-leonardo|keyboard|mac-os|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17704" PostTypeId="1" CreationDate="2015-11-11T19:43:45.870" Score="0" ViewCount="1552" Body="&lt;p&gt;I need an Arduino to send a message, to be displayed on the web, after pressing a push button, which is connected to an Arduino [or shield], without using a GSM shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to send a message just by using HTML/PHP code included in the Arduino IDE. This displayed message should contain two buttons. One button is used to turn a LED ON/OFF and the other to open a streaming video.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with the Arduino code and explain how I should do that? Is there any third party device, apart from a GSM shield, that can help me to send that message?&lt;/p&gt;&#xA;" OwnerUserId="14762" LastEditorUserId="6936" LastEditDate="2016-03-13T07:49:13.447" LastActivityDate="2016-03-13T07:49:13.447" Title="Is it possible for Arduino to send a message to the internet without using a GSM shield?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="17705" PostTypeId="1" CreationDate="2015-11-11T19:53:41.913" Score="1" ViewCount="1829" Body="&lt;p&gt;For a battery charging project, i am using an ARDUINO UNO which is driving a buck converter to provide the battery with the charging current. I am using external ADCs to measure the battery's charging voltage and current. The test setup is working fine, but right now i am just measuring the voltage and current at random time instants. However to measure it correctly, battery voltage reading should be done at an instant when the controller's PWM output is LOW (OFF duty cycle), and battery current reading should be done when PWM output is HIGH (ON duty cycle). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked into interrupts and learned about them that there are 2 types of interrupts in Arduino namely &quot;external&quot;, and &quot;pin change&quot;. So i downloaded the &quot;PinChangeInt Library&quot; to test it. I wrote a small test program where a PWM of 62.5kHz is being generated on pin3, and i am calling rising and falling edge triggered interrupts on this pin, i.e to display one value when rising edge occurs, and other value when falling edge occurs.  My code looks like following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;PinChangeInt.h&amp;gt;&#xA;    #define pw 3&#xA;    int pwm;&#xA;&#xA;&#xA;    void setup() {&#xA;      // put your setup code here, to run once:&#xA;      pinMode(pw, OUTPUT) ;&#xA;      pwm_setup();             // Set PWM to a frequency of 62.5kHz&#xA;&#xA;      PCintPort::attachInterrupt(pw,rise,RISING);    // call void rise() when PWM is HIGH&#xA;      PCintPort::attachInterrupt(pw,fall,FALLING);   // call void fall() when PWM is LOW&#xA;&#xA;&#xA;      Serial.begin(9600);&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // put your main code here, to run repeatedly:&#xA;      pwm = 127;                                                // 50% duty cycle&#xA;      pwm_on(pwm);&#xA;&#xA;    }&#xA;    void pwm_setup()&#xA;    {&#xA;&#xA;      TCCR2A = 0x23 ;&#xA;      TCCR2B = 0x09 ; // mode 7, clock prescale by 1&#xA;      OCR2A = 256-1 ;  // 256 clock periods = 16us per cycle&#xA;      OCR2B =0 ;&#xA;      TCNT2 =0 ;&#xA;&#xA;    }&#xA;    void pwm_on(double)&#xA;     {&#xA;        OCR2B = pwm ;&#xA;     }&#xA;&#xA;    void rise()&#xA;    {&#xA;      Serial.println(&quot;RISE&quot;);&#xA;    }&#xA;&#xA;void fall()&#xA;{&#xA;  Serial.println(&quot;fall&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is not working the way i think it should. It keeps on displaying &quot;fall&quot; every time, whereas according to me it should display &quot;RISE&quot; and &quot;fall&quot; alternatively, right ? However if i remove the &quot;PCintPort::attachInterrupt(pw,fall,FALLING); &quot; line, it starts to display &quot;RISE&quot; as it is supposed to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since its my first time programming with Arduino, and i am just a beginning level programmer, i might be making some stupid mistake here. So can anyone point it out please ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your helpful comments and suggestions would be appreciated.&#xA;Thankyou!&lt;/p&gt;&#xA;" OwnerUserId="13187" LastEditorUserId="10907" LastEditDate="2016-01-11T13:08:08.137" LastActivityDate="2016-02-10T13:31:00.967" Title="ISR not working as it is supposed to" Tags="|arduino-uno|pwm|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17706" PostTypeId="1" CreationDate="2015-11-11T20:21:29.737" Score="5" ViewCount="2238" Body="&lt;p&gt;I have an Arduino Uno board, with these components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.cooking-hacks.com/rs-485-modbus-module-shield-board-for-arduino-raspberry-pi-intel-galileo&quot; rel=&quot;nofollow&quot; title=&quot;rs-485 Modbus module shield&quot;&gt;rs-485 Modbus module shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.cooking-hacks.com/multiprotocol-radio-shield-board-for-arduino-rpi-intel-galileo&quot; rel=&quot;nofollow&quot; title=&quot;Multiprotocol radio shield board for Arduino&quot;&gt;Multiprotocol radio shield board for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In addition I have a level sensor which reads either 1 when it is above water, and 0 when it is below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to be able to give the value of this sensor to a modbus master over rs485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.cooking-hacks.com/documentation/tutorials/modbus-module-shield-tutorial-for-arduino-raspberry-pi-intel-galileo/&quot; rel=&quot;nofollow&quot; title=&quot;Cooking Hacks Tutorial&quot;&gt;Cooking Hacks Tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This page has a description of how to use the ModbusMaster485 library, but I can not find any information about the slave library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can not find any documentation for this library, and would really appreciate any pointers.&lt;/p&gt;&#xA;" OwnerUserId="8470" LastEditorUserId="28033" LastEditDate="2016-12-09T08:34:40.313" LastActivityDate="2016-12-11T19:20:30.903" Title="Modbus Communication protocol for Arduino as Slave" Tags="|arduino-uno|modbus|rs485|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17707" PostTypeId="2" ParentId="17703" CreationDate="2015-11-11T20:27:51.983" Score="1" Body="&lt;p&gt;Unfortunately, &lt;code&gt;Fn&lt;/code&gt; is hardware and it is handled internally by the keyboard to do something hardware-based without sending any code. So the short answer is: you can't simulate Fn key with arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I think of as a solution is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create a program on your Mac that can listen for keyboard scan codes to do vol +/- or any other function.&lt;/li&gt;&#xA;&lt;li&gt;Send a custom scan code from Arduino to your Mac ( a scan code that isn't part of the standard scan codes ).&lt;/li&gt;&#xA;&lt;li&gt;When your listening program receives that code, it should do Vol +/- (or anything else )...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-11T20:37:42.320" LastActivityDate="2015-11-11T20:37:42.320" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17709" PostTypeId="1" AcceptedAnswerId="17717" CreationDate="2015-11-11T21:29:43.273" Score="1" ViewCount="1375" Body="&lt;p&gt;I have 8 LED's connected to a shift register on my arduino uno r3. I am trying to write a Python3 script that will prompt a user to select one of the LED's and then prompt to toggle on or off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should be pretty basic but I cant seem to get this working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already botched my code trying to get this running:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the jist of my python script is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import os&#xA;import time&#xA;&#xA;os.system('clear')&#xA;&#xA;ser = serial.Serial('/dev/cu.usbmodem1431', 9600)&#xA;&#xA;while True:&#xA;    led = input(&quot;Which LED do you wish to operate? (press x to quit): &quot;)&#xA;&#xA;    if led &amp;gt;= '0' and led &amp;lt;= '7':&#xA;        print(&quot;Operating LED # %s&quot; % led)&#xA;        ser.write(str.encode(led)) # sends the choice of led to arduino'&#xA;        on_or_off = input(&quot;Do you want to turn it on or off (press 0 for off and 1 for on): &quot;)&#xA;&#xA;        if on_or_off == '0':&#xA;            #send command to arduino to turn off the selected LED&#xA;            print(&quot;Command sent to arduino to turn OFF LED %s&quot; % led)&#xA;            ser.write(str.encode(on_or_off))&#xA;        elif on_or_off == '1':&#xA;            #send command to arduino to turn on the selected LED&#xA;            print(&quot;Command sent to arduino to turn ON LED %s&quot; % led)&#xA;            ser.write(str.encode(on_or_off))&#xA;        else:&#xA;            print(&quot;Please enter 0 or 1 to operate the LED. &quot;)&#xA;&#xA;    elif led == 'x':&#xA;        ser.close()&#xA;        break&#xA;    else:&#xA;        continue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason Arduino is only dealing with the first input...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HEre is my loop code on the arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if(Serial.available() &amp;gt; 0){&#xA;    led = Serial.read(); // from python script the led to operate&#xA;    led = led - '0';&#xA;    if(led &amp;gt;= '0' &amp;amp;&amp;amp; led &amp;lt;= '7'){&#xA;      if(Serial.available() &amp;gt; 0){&#xA;        ledState = Serial.read(); // expects the led state next&#xA;        ledState = ledState - '0';&#xA;        if(ledState == '0'){&#xA;          shiftWrite(led,LOW);&#xA;        }else if(ledState == '1'){&#xA;          shiftWrite(led,HIGH); &#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;shiftWrite is a function I wrote because there are 8 LEDS hooked to a shiftRegister&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;update:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the state machine suggestion and it didnt work...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void loop() {&#xA;  while(Serial.available()){&#xA;    led = Serial.read();&#xA;    led = led - '0';&#xA;    if(led&amp;gt;= 0 &amp;amp;&amp;amp; led &amp;lt;= 7){&#xA;      state = 1; //We've received the LED # go to state 1&#xA;      Serial.println(led);&#xA;      Serial.println(state);&#xA;      Serial.println(ledState);&#xA;      continue;&#xA;    }&#xA;    if(state == 1){&#xA;      ledState = Serial.read();&#xA;      ledState = ledState - '0';&#xA;      if(ledState == '0'){&#xA;        shiftWrite(led,LOW);&#xA;      }else if(ledState == '1'){&#xA;        shiftWrite(led,HIGH);&#xA;      }&#xA;      state = 0; //Ended the operation return to state 0&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the serial monitor in the arduino IDE open (not running the python script) I tried this input: 4,1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my output on the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4&#xA;1&#xA;0&#xA;1&#xA;1&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Basically the same problem as before...I actually thought the state machine idea would work...&lt;/p&gt;&#xA;" OwnerUserId="14764" LastEditorUserId="14764" LastEditDate="2015-11-12T00:37:29.180" LastActivityDate="2015-11-12T02:35:58.067" Title="Python script to toggle LED's" Tags="|arduino-uno|serial|sketch|python|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17710" PostTypeId="1" CreationDate="2015-11-11T21:46:21.083" Score="0" ViewCount="1871" Body="&lt;p&gt;I am using the SIM908 module to get GPS position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SIM908 sends the latitude and longitude in the &lt;code&gt;ddmm.mmmm&lt;/code&gt; format, but major online services for GPS location (for example, Google Earth) use the &lt;code&gt;dd.dddd&lt;/code&gt; format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how can I modify my code to convert coordinates from the SIM908 to &lt;code&gt;dd.dddd&lt;/code&gt; format? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the SIM908 GSM Library Code that I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;gps.h&quot;&#xA;char GPSGSM::getBattInf(char *str_perc, char *str_vol)&#xA;{&#xA;     char ret_val=0;&#xA;     char *p_char;&#xA;     char *p_char1;&#xA;&#xA;     gsm.SimpleWriteln(&quot;AT+CBC&quot;);&#xA;     gsm.WaitResp(5000, 100, &quot;OK&quot;);&#xA;     if(gsm.IsStringReceived(&quot;+CBC&quot;))&#xA;          ret_val=1;&#xA;&#xA;     //BCL&#xA;     p_char = strchr((char *)(gsm.comm_buf),',');&#xA;     p_char1 = p_char+1;  //we are on the first char of BCS&#xA;     p_char = strchr((char *)(p_char1), ',');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;     strcpy(str_perc, (char *)(p_char1));&#xA;&#xA;     //Voltage&#xA;     p_char++;&#xA;     p_char1 = strchr((char *)(p_char), '\r');&#xA;     if (p_char1 != NULL) {&#xA;          *p_char1 = 0;&#xA;     }&#xA;     strcpy(str_vol, (char *)(p_char));&#xA;     return ret_val;&#xA;}&#xA;&#xA;char GPSGSM::getBattTVol(char *str_vol)&#xA;{&#xA;     char *p_char;&#xA;     char *p_char1;&#xA;     char ret_val=0;&#xA;&#xA;     gsm.SimpleWriteln(&quot;AT+CBTE?&quot;);&#xA;     gsm.WaitResp(5000, 100, &quot;OK&quot;);&#xA;     if(gsm.IsStringReceived(&quot;+CBTE&quot;))&#xA;          ret_val=1;&#xA;&#xA;     //BCL&#xA;     p_char = strchr((char *)(gsm.comm_buf),':');&#xA;     p_char1 = p_char+2;  //we are on the first char of BCS&#xA;     p_char = strchr((char *)(p_char1), '\r');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;     strcpy(str_vol, (char *)(p_char1));&#xA;     return ret_val;&#xA;}&#xA;&#xA;char GPSGSM::attachGPS()&#xA;{&#xA;     if(AT_RESP_ERR_DIF_RESP == gsm.SendATCmdWaitResp(&quot;AT+CGPSPWR=1&quot;, 500, 100, &quot;OK&quot;, 5))&#xA;          return 0;&#xA;     if(AT_RESP_ERR_DIF_RESP == gsm.SendATCmdWaitResp(&quot;AT+CGPSRST=1&quot;, 500, 100, &quot;OK&quot;, 5))&#xA;          return 0;&#xA;     return 1;&#xA;}&#xA;&#xA;char GPSGSM::deattachGPS()&#xA;{&#xA;     if(AT_RESP_ERR_DIF_RESP == gsm.SendATCmdWaitResp(&quot;AT+CGPSPWR=0&quot;, 500, 100, &quot;OK&quot;, 5))&#xA;          return 0;&#xA;     return 1;&#xA;}&#xA;&#xA;char GPSGSM::getStat()&#xA;{&#xA;     char ret_val=-1;&#xA;     gsm.SimpleWriteln(&quot;AT+CGPSSTATUS?&quot;);&#xA;     gsm.WaitResp(5000, 100, &quot;OK&quot;);&#xA;     if(gsm.IsStringReceived(&quot;Unknown&quot;)||gsm.IsStringReceived(&quot;unknown&quot;))&#xA;          ret_val=0;&#xA;     else if(gsm.IsStringReceived(&quot;Not&quot;))&#xA;          ret_val=1;&#xA;     else if(gsm.IsStringReceived(&quot;2D&quot;)||gsm.IsStringReceived(&quot;2d&quot;))&#xA;          ret_val=2;&#xA;     else if(gsm.IsStringReceived(&quot;3D&quot;)||gsm.IsStringReceived(&quot;3d&quot;))&#xA;          ret_val=3;&#xA;     return ret_val;&#xA;}&#xA;&#xA;char GPSGSM::getPar(char *str_long, char *str_lat, char *str_alt, char *str_time, char *str_speed )&#xA;{&#xA;     char ret_val=0;&#xA;     char *p_char;&#xA;     char *p_char1;&#xA;     gsm.SimpleWriteln(&quot;AT+CGPSINF=0&quot;);&#xA;     gsm.WaitResp(5000, 100, &quot;OK&quot;);&#xA;     if(gsm.IsStringReceived(&quot;OK&quot;))&#xA;          ret_val=1;&#xA;&#xA;     //longitude&#xA;     p_char = strchr((char *)(gsm.comm_buf),',');&#xA;     p_char1 = p_char+1;  //we are on the first char of longitude&#xA;     p_char = strchr((char *)(p_char1), ',');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;     strcpy(str_long, (char *)(p_char1));&#xA;&#xA;     // latitude&#xA;     p_char++;&#xA;     p_char1 = strchr((char *)(p_char), ',');&#xA;     if (p_char1 != NULL) {&#xA;          *p_char1 = 0;&#xA;     }&#xA;     strcpy(str_lat, (char *)(p_char));&#xA;&#xA;     // altitude&#xA;     p_char1++;&#xA;     p_char = strchr((char *)(p_char1), ',');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;     strcpy(str_alt, (char *)(p_char1));&#xA;&#xA;     // UTC time&#xA;     p_char++;&#xA;     p_char1 = strchr((char *)(p_char), ',');&#xA;     if (p_char1 != NULL) {&#xA;          *p_char1 = 0;&#xA;     }&#xA;     strcpy(str_time, (char *)(p_char));&#xA;&#xA;     // TTFF&#xA;     p_char1++;&#xA;     p_char = strchr((char *)(p_char1), ',');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;&#xA;     // num&#xA;     p_char++;&#xA;     p_char1 = strchr((char *)(p_char), ',');&#xA;     if (p_char1 != NULL) {&#xA;          *p_char1 = 0;&#xA;     }&#xA;&#xA;     // speed&#xA;     p_char1++;&#xA;     p_char = strchr((char *)(p_char1), ',');&#xA;     if (p_char != NULL) {&#xA;          *p_char = 0;&#xA;     }&#xA;     strcpy(str_speed, (char *)(p_char1));&#xA;&#xA;     return ret_val;&#xA;}&#xA;&#xA;void parseTime(char *field, int *time)&#xA;{&#xA;     ////////////////Time////////////&#xA;     char tmp[4];&#xA;     tmp[2]=0; // Init tmp and null terminate&#xA;     tmp[0] = field[8];&#xA;     tmp[1] = field[9];&#xA;     time[0] = atoi(tmp); // Hours&#xA;     tmp[0] = field[10];&#xA;     tmp[1] = field[11];&#xA;     time[1] = atoi(tmp); // Minutes&#xA;     tmp[0] = field[12];&#xA;     tmp[1] = field[13];&#xA;     time[2] = atoi(tmp); // Seconds&#xA;     /////////////Date///////////////&#xA;     tmp[0] = field[0];&#xA;     tmp[1] = field[1];&#xA;     tmp[2] = field[2];&#xA;     tmp[3] = field[3];&#xA;     tmp[4]=0; // Init tmp and null terminate&#xA;     time[3] = atoi(tmp); // year&#xA;     tmp[0] = field[4];&#xA;     tmp[1] = field[5];&#xA;     tmp[2]=0; // Init tmp and null terminate&#xA;     time[4] = atoi(tmp); // month&#xA;     tmp[0] = field[6];&#xA;     tmp[1] = field[7];&#xA;     tmp[2]=0; // Init tmp and null terminate&#xA;     time[5] = atoi(tmp); // day&#xA;}&#xA;&#xA;// Read the latitude in decimal format from a GGA string&#xA;double convertLat(char* latString)&#xA;{&#xA;     double latitude = atof(latString);                                    // convert to a double (precise)&#xA;     int deg = (int) latitude / 100;                               // extract the number of degrees&#xA;     double min = latitude - (100 * deg);                  // work out the number of minutes&#xA;     latitude = deg + (double) min/60.0;                   // convert to decimal format&#xA;     return latitude;&#xA;}&#xA;&#xA;// Read the longitude in decimal format from a GGA string&#xA;double convertLong(char* longString)&#xA;{&#xA;     double longitude = atof(longString);                                  // convert to a double&#xA;     int deg = (int) longitude / 100;                              // extract the number of degrees&#xA;     double min = longitude - (100 * deg);                 // work out the number of minutes&#xA;     longitude = deg + (double) min/60.00;                 // convert to decimal format&#xA;     return longitude;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14767" LastEditorUserId="6936" LastEditDate="2016-01-24T21:34:10.327" LastActivityDate="2016-05-27T16:01:36.293" Title="How to change SIM908 GPS location coordinates format?" Tags="|arduino-uno|gps|tinygps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17711" PostTypeId="2" ParentId="17703" CreationDate="2015-11-11T21:50:42.797" Score="2" Body="&lt;p&gt;Could you just untick the &quot;Use all F1, F2, …&quot; in System Preferences -&gt; Keyboard?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MHk0S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MHk0S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just wondering if that would be an option and if doing so would create the desired outcome.&lt;/p&gt;&#xA;" OwnerUserId="14589" LastEditorUserId="14589" LastEditDate="2015-11-11T22:16:59.463" LastActivityDate="2015-11-11T22:16:59.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17712" PostTypeId="2" ParentId="17709" CreationDate="2015-11-11T22:05:44.700" Score="1" Body="&lt;p&gt;You're assuming that the microcontroller is going to wait until you choose LED state, which is wrong. Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int state = 0; &#xA;int led;&#xA;int ledState;&#xA;&#xA;void loop() {  &#xA;  while (Serial.available())&#xA;  {&#xA;    if (state == 0)&#xA;    {&#xA;      led = Serial.read() - '0';&#xA;      if(led &amp;gt;= 0 &amp;amp;&amp;amp; led &amp;lt;= 7)&#xA;      {&#xA;        state = 1; // Here we have got the LED number, go to state 1&#xA;        continue; &#xA;      }&#xA;    }&#xA;    if (state == 1)&#xA;    {&#xA;        ledState = Serial.read() - '0';&#xA;        if(ledState == 0)&#xA;        {&#xA;          shiftWrite(led,LOW);&#xA;        }&#xA;        else if(ledState == 1)&#xA;        {&#xA;          shiftWrite(led,HIGH); &#xA;        }&#xA;        state = 0; // Here we ended the operation, return back to state 0&#xA;    }&#xA;  }    &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need what we call a state machine, here I use &lt;code&gt;state=0&lt;/code&gt; for the state corresponding to choosing LED number, &lt;code&gt;state=1&lt;/code&gt; is for the state that waits for the operation ON/OFF.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-11T22:27:20.043" LastActivityDate="2015-11-11T22:27:20.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17713" PostTypeId="1" CreationDate="2015-11-11T23:15:23.390" Score="0" ViewCount="364" Body="&lt;p&gt;I've been playing with an Arduino Uno, trying to get a 16x2 LCD screen to work with an I2C controller. I've got &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00HICXURS&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; LCD screen and &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00FIVUVBY&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; controller. And I've been trying to get the sketch below to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LCD.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);//, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;void setup()&#xA;{&#xA;    lcd.begin(16,2);&#xA;    lcd.backlight();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;Hello world!&quot;);&#xA;    lcd.setCursor(0, 1);&#xA;    lcd.print(&quot;Row number: &quot;);&#xA;    lcd.setCursor(12, 1);&#xA;    lcd.print(&quot;2&quot;);&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've used an address scanner to verify that the address is correct (39 [0x27]), but it still won't display anything. It lights up, and I've tried adjusting the contrast, but it just won't display any characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if the definition of which pins are which is correct, but I can't seem to find anything detailing how the numbers used in the sketch correlate to the pins on the controller, which then correlate to the pins on the LCD screen. If any body can give me some insight I'd appreciate it.&lt;/p&gt;&#xA;" OwnerUserId="14770" LastActivityDate="2018-07-14T21:18:23.187" Title="LCD Pin Numbering vs I2C Controller Pin Numbering vs Sketch" Tags="|arduino-uno|i2c|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17714" PostTypeId="2" ParentId="17713" CreationDate="2015-11-11T23:35:43.233" Score="1" Body="&lt;p&gt;Yes, the pins can be different depending on the LCD and the controller. My favorite solution to this is to run a simple &quot;i2c guesser&quot; sketch that can be downloaded from the following forum thread (download link is at the bottom of the first post):&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=260510.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=260510.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that sketch it usually only takes me a couple minutes to find the correct pin numbers. &lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-11-11T23:35:43.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17716" PostTypeId="2" ParentId="17705" CreationDate="2015-11-12T01:02:49.337" Score="1" Body="&lt;p&gt;Here are a few items to consider.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;From &lt;code&gt;#define pw 3&lt;/code&gt; you are working with PD3, INT1.  As one of the Atmega328 Uno's two external interrupts, INT1 supports RISING and FALLING events separately.  Pin change interrupts (PCIs) on pins other than 2 or 3 of the Uno won't separate them and in the interrupt routine (one interrupt routine in that case, not two) you will need to test which occurs by reading the pin.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Serial communication depends on interrupts and won't work in an interrupt handler.  Instead, set a flag (via a volatile byte variable) to test in your &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For testing, put &lt;code&gt;pwm_on(pwm)&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt; instead of &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In &lt;code&gt;loop()&lt;/code&gt;, compute &lt;code&gt;seconds = milli()/1000&lt;/code&gt; and if &lt;code&gt;seconds != prevsec&lt;/code&gt;, set prevsec=seconds, enable your PCI or external interrupt, then enter a loop that waits for a flag and takes a reading.  Or, in the interrupt handler, both set a flag and take a reading into a volatile variable.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you only need to measure the quantities a few times per second, or a few times per minute, you could just busy-wait for the condition, then trigger a sample-and-hold, then convert analog to digital via &lt;code&gt;analogRead()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Regarding sample-and-hold: Unless you change the ADC sampling rate, &lt;code&gt;analogRead()&lt;/code&gt; will take up to 100 microseconds per reading.  If your input waveform is 62.5 KHz, it will toggle about about six times while being measured, which if measured directly is likely to give a random result.  However, if you use a sample-and-hold circuit, you can hold the ADC input constant until your measurement completes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative to using a sample-and-hold is changing the ADC sampling speed. See post #5 in thread &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=6549.0&quot; rel=&quot;nofollow&quot;&gt;Faster Analog Read?&lt;/a&gt; on forum.arduino.cc.  If you get the sample time down to 8 to 12 microseconds you can do ok with a busy-wait method.  Ie, when your code wants a reading, it has a loop that measures the PWM line over and over, and starts an ADC conversion shortly after the PWM gets to the state desired for the measurement.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-12T05:50:25.150" LastActivityDate="2015-11-12T05:50:25.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17717" PostTypeId="2" ParentId="17709" CreationDate="2015-11-12T02:35:58.067" Score="1" Body="&lt;p&gt;Try this code, it is working as intended:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;int state = 0; &#xA;int led;&#xA;int ledState;&#xA;&#xA;void loop() {  &#xA;&#xA;  while (Serial.available())&#xA;  {&#xA;    if (state == 0)&#xA;    {&#xA;&#xA;      led = Serial.read() - '0';&#xA;      if(led &amp;gt;= 0 &amp;amp;&amp;amp; led &amp;lt;= 7)&#xA;      {&#xA;        state = 1;&#xA;        Serial.println(&quot;Got LED number: &quot; + String(led)); &#xA;        break;      &#xA;      }&#xA;    }&#xA;    if (state == 1)&#xA;    {&#xA;        ledState = Serial.read() - '0';&#xA;        if(ledState == 0)&#xA;        {&#xA;          Serial.println(&quot;LED n &quot; + String(led) + &quot; is now OFF&quot;);&#xA;        }&#xA;        else if(ledState == 1)&#xA;        {&#xA;          Serial.println(&quot;LED n &quot; + String(led) + &quot; is now ON&quot;);&#xA;        }&#xA;        state = 0;&#xA;    }&#xA;  }    &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-12T02:35:58.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17718" PostTypeId="1" AcceptedAnswerId="17719" CreationDate="2015-11-12T03:08:17.397" Score="-1" ViewCount="63" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xCHd9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xCHd9.jpg&quot; alt=&quot;I do not know what part this is. I ordered an Arduino beginners kit and this part was not labeled. Please help! &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not know what part this is. I ordered an Arduino beginners kit and this part was not labeled. Please help! &lt;/p&gt;&#xA;" OwnerUserId="14769" LastActivityDate="2015-11-12T03:24:13.077" Title="Arduino Part Needs Identified" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17719" PostTypeId="2" ParentId="17718" CreationDate="2015-11-12T03:12:47.303" Score="1" Body="&lt;p&gt;It seems that it is an MPU6050 Module 3 Axis Accelerometer Gyroscope Module for Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Learn more: &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Main/MPU-6050&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/epV69.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/epV69.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-12T03:24:13.077" LastActivityDate="2015-11-12T03:24:13.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17721" PostTypeId="1" AcceptedAnswerId="17722" CreationDate="2015-11-12T12:05:25.933" Score="1" ViewCount="210" Body="&lt;p&gt;The main problem here is that they both need to communicate via the Arduino's SPI bus, and I know that each of the two devices will need its own CS pin (The data logger is hard wired to 10, so the digital potentiometer will need a different one)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be fine, except that the digital potentiometer has one pin for both SPI and SDO.&#xA;I read that to connect this to the Arduino, the shared pin on the digipot needs to be connected to the MISI pin on the Arduino (pin 12) and then to bridge the MISO pin to the MOSI pin with a resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would anyone be able to tell if this will work. I do not want to try connecting the two devices like this just in case it breaks something in the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14777" LastActivityDate="2015-11-12T12:13:42.940" Title="How to connect MCP4141 digipot and a data logger shield to the same Arduino board" Tags="|arduino-uno|shields|arduino-nano|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17722" PostTypeId="2" ParentId="17721" CreationDate="2015-11-12T12:13:42.940" Score="1" Body="&lt;p&gt;I have done the same thing in the past for a DS1302 RTC that uses the same communication system.  Yes, it works.  Will it interfere with the other communication though? Quite possibly.  It works fine for &lt;em&gt;half duplex&lt;/em&gt; communication, but could cause interference with something else on the bus that is &lt;em&gt;full duplex&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If in doubt, and you're not worried about high speed or high efficiency (you're not changing the potentiometer's value often) then use three other pins and bit-bang your own half duplex serial interface - it's not hard.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-12T12:13:42.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17723" PostTypeId="1" AcceptedAnswerId="17732" CreationDate="2015-11-12T13:08:46.780" Score="0" ViewCount="162" Body="&lt;p&gt;I have spent quite a considerable time debugging my code that was triggering false interruptions. I have found out that the source of the error were the diode lights (on the picture). I would like to ask if anyone can point me to the possible source of such behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will try to explain really briefly what the issue was providing only needed (from my point of view) details. If you would require more - tell me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have a board that looks like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SSv38.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SSv38.png&quot; alt=&quot;circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see two reed switches (close circuit in the presence of a magnet) which leads the &lt;code&gt;INT0&lt;/code&gt; (pin 2) and &lt;code&gt;INT1&lt;/code&gt; (pin 3) on arduino to trigger an interruption on their &lt;code&gt;RISING&lt;/code&gt; behaviour. The pull down resistors are 1kOhm. This cirquit works perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original version of this circuit had lights in positions &lt;code&gt;D5-D10&lt;/code&gt; and &lt;code&gt;D19-D24&lt;/code&gt; (between the reed switches and the connections to the interruptor pins). The lights are these:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mhMrqm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mhMrqm.jpg&quot; alt=&quot;diod lights&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part of the circuit with the red light (connected to &lt;code&gt;INT1&lt;/code&gt;) worked flawlessly, while the circuit with the green light (connected to &lt;code&gt;INT0&lt;/code&gt;) every once in a while triggered a false interruption in &lt;code&gt;INT1&lt;/code&gt;. The lights, however were always blinking correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have nearly no experience with circuits and hardware, so a pointer on where to start reading to understand the issue is also welcome. Hope to hear from someone who knows what the cause could have been. I would still like to use the lights somehow, because they give a nice feedback on what is happening to the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. I do not think the code is necessary here, but I will post it too if you like. I am however quite confident that the bug is not on the software side.&lt;/p&gt;&#xA;" OwnerUserId="14779" LastEditorUserId="14779" LastEditDate="2015-11-12T14:49:41.430" LastActivityDate="2015-11-12T17:42:19.160" Title="Diode lights generate false interruptions" Tags="|arduino-uno|interrupt|debugging|resistor|components|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17725" PostTypeId="1" AcceptedAnswerId="17727" CreationDate="2015-11-12T13:51:48.473" Score="1" ViewCount="69" Body="&lt;p&gt;I'm having trouble with the syntax of code. I want to have the motor turn when the next average the program measures is 100 or more greater than the previous average it measured. I don't know how to write the if statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(average == (average&amp;gt;=100)) {&#xA;for(pos = 0; pos &amp;lt;= 120; pos += 1) {&#xA;  sServo.write(pos);&#xA;  delay(50);&#xA;}&#xA;for(pos = 120; pos &amp;gt;= 0; pos -= 1) {&#xA;  sServo.write(pos);&#xA;  delay(50);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14783" LastEditorUserId="14783" LastEditDate="2015-11-12T14:26:23.017" LastActivityDate="2015-11-12T14:50:02.950" Title="Problem with for loop" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17727" PostTypeId="2" ParentId="17725" CreationDate="2015-11-12T14:50:02.950" Score="0" Body="&lt;p&gt;The motor should&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;turn when the next average the program measures is 100 or more greater than the previous average it measured&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So simply write it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Old average is called &quot;average&quot;&#xA;// Compute the new average and put it in next_average&#xA;if ((next_average - average) &amp;gt;= 100)&#xA;{&#xA;  // Turn the motor&#xA;}&#xA;average = next_average;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-11-12T14:50:02.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17728" PostTypeId="1" CreationDate="2015-11-12T15:10:33.567" Score="3" ViewCount="318" Body="&lt;p&gt;We have this project that uses a Continuous Rotation Servo and we have a slight problem controlling it. We're planning to attach a Rack Gear to the Servo to slide a stainless steel to the right, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Question:&lt;/strong&gt; Is it possible to stop the continuous rotation servo when the stainless steel hits a bump or it already made its proper position accurately?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea is like the Power Windows of cars.&lt;/p&gt;&#xA;" OwnerUserId="14632" LastEditorUserId="71575" LastEditDate="2022-07-07T17:34:18.347" LastActivityDate="2022-07-07T17:34:18.347" Title="A question about Continuous Rotation Servo and Arduino" Tags="|arduino-uno|continuous-servo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17729" PostTypeId="2" ParentId="17728" CreationDate="2015-11-12T15:53:33.517" Score="2" Body="&lt;p&gt;You can track the servo rotation with an encoder and after reaching a specific position, you can send different instructions to execute other actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other alternative is maybe you can place a limit switch at the position where you want it to stop.&lt;/p&gt;&#xA;" OwnerUserId="13456" LastActivityDate="2015-11-12T15:53:33.517" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17730" PostTypeId="1" CreationDate="2015-11-12T16:53:53.997" Score="1" ViewCount="1423" Body="&lt;p&gt;So I try to compile and upload a simple code such as the Basic Blink.&#xA;I have not connected it to pin 0 or pin 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an LED with the &quot;L&quot; label on the card that works. So I guess not the chip is damaged?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have selected the correct model which is Arduino Uno / Genuino. I've checked the drivers several times now, even reinstalled Arduino Software twice and tried on 2 different computers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5V works with ground, I can get the LED to light up. But I cannot compile / upload code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error MSG: avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;(this message repeats 10 times with attempts)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I read something about bootloader, but I have no idea how to do this / what it is. I do not have the right components for bootloading I guess. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the COM is correct. I've tried using all the listed COMs without any result. Is this a hardware issue? Is my chip grilled or something? &lt;/p&gt;&#xA;" OwnerUserId="14787" LastActivityDate="2020-02-20T15:51:57.287" Title="avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00" Tags="|arduino-uno|" AnswerCount="1" CommentCount="34" ClosedDate="2020-02-20T16:11:16.513" ContentLicense="CC BY-SA 3.0" />
  <row Id="17732" PostTypeId="2" ParentId="17723" CreationDate="2015-11-12T17:36:45.763" Score="2" Body="&lt;p&gt;Aaaaah, ok, now I see...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You put&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+5V - Reed - LED - input pin - 1k resistor - ground&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so the problem is that a red led has (usually) a voltage drop of about 1.5V, while the green one has a voltage drop of 1.8V-2.0V. The Atmega 328P has a Vih (i.e. the minimum voltage needed for a reliable high) of 0.6*Vcc, so for a 5V supply this value is 3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently with a green LED you will have a value TOO CLOSE to the minimum acceptable value for the input pin. Note that the 2.0V value is an usual one, but different leds have different voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover the so-called high-brightness leds (the ones with a transparent case) have a more-than-3V voltage drop, so if you put for instance a blue led you will never receive a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve the problem, you have three solutions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) use a (low brightness) red led also for the green path&#xA;2) remove the led from that path and drive it directly with the arduino (you will have also the notification that arduino has understood the command)&#xA;3) change the path to &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+5V - Reed - input pin - LED - 1k resistor - ground&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(i.e. take the voltage BEFORE the led, not after)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it'll work then :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: according to the data I found on the internet the red led is usually 1.8V, while the green one is usually 2.1V. This does not change my answer, anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And... You won't &quot;fry&quot; your pins with the 5V you are prividing to the circuit....&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2015-11-12T17:42:19.160" LastActivityDate="2015-11-12T17:42:19.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17733" PostTypeId="1" AcceptedAnswerId="17747" CreationDate="2015-11-12T19:35:46.267" Score="1" ViewCount="4075" Body="&lt;p&gt;I'm trying to send data using &lt;a href=&quot;http://www.ebay.com/itm/221524421949&quot; rel=&quot;nofollow noreferrer&quot;&gt;these&lt;/a&gt; cheap parts.&#xA;When I check the voltage on the data port of the transmitter, I see what I expect, 1.2 and 0.6 fluctuating while sending. &#xA;But when I check the receiver I get 0. I've got 3 of the sets and tried them all. Also tried it with running the transmitter on 11V for some extra power. I've added a LED to the transmitter to see when it transmits and I've added a not-so-good antenna to both while they are only 5cm apart during my tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiver&lt;/strong&gt;&lt;br&gt;&#xA;FS1000A with a LR433A&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;const int led_pin = 6;&#xA;//const int transmit_pin = 12;&#xA;const int receive_pin = 11;&#xA;//const int transmit_en_pin = 3;&#xA;&#xA;void setup()&#xA;{&#xA;    delay(1000);&#xA;    Serial.begin(9600);  // Debugging only&#xA;    Serial.println(&quot;setup&quot;);&#xA;&#xA;    // Initialise the IO and ISR&#xA;    //vw_set_tx_pin(transmit_pin);&#xA;    vw_set_rx_pin(receive_pin);&#xA;    //vw_set_ptt_pin(transmit_en_pin);&#xA;    //vw_set_ptt_inverted(true); // Required for DR3100&#xA;    vw_setup(1000);  // Bits per sec&#xA;&#xA;    vw_rx_start();       // Start the receiver PLL running&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;    uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;&#xA;    if (vw_get_message(buf, &amp;amp;buflen)) // Non-blocking&#xA;    {&#xA;  int i;&#xA;&#xA;        digitalWrite(led_pin, HIGH); // Flash a light to show received good message&#xA;  // Message with a good checksum received, print it.&#xA;  Serial.print(&quot;Got: &quot;);&#xA;&#xA;  for (i = 0; i &amp;lt; buflen; i++)&#xA;  {&#xA;      Serial.print(buf[i], HEX);&#xA;      Serial.print(' ');&#xA;  }&#xA;  Serial.println();&#xA;        digitalWrite(led_pin, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Transmitter&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;const int led_pin = 11;&#xA;const int transmit_pin = 12;&#xA;const int receive_pin = 2;&#xA;const int transmit_en_pin = 3;&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialise the IO and ISR&#xA;  vw_set_tx_pin(transmit_pin);&#xA;  vw_set_rx_pin(receive_pin);&#xA;  vw_set_ptt_pin(transmit_en_pin);&#xA;  vw_set_ptt_inverted(true); // Required for DR3100&#xA;  vw_setup(1000);   // Bits per sec&#xA;}&#xA;&#xA;byte count = 1;&#xA;&#xA;void loop()&#xA;{&#xA;  char msg[7] = {'h','e','l','l','o',' ','#'};&#xA;  Serial.println(&quot;sending&quot;);&#xA;  msg[6] = count;&#xA;  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting&#xA;  vw_send((uint8_t *)msg, 7);&#xA;  vw_wait_tx(); // Wait until the whole message is gone&#xA;  digitalWrite(led_pin, LOW);&#xA;  delay(1000);&#xA;  count = count + 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZLAIw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZLAIw.jpg&quot; alt=&quot;transmitter&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xQiju.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xQiju.jpg&quot; alt=&quot;receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14790" LastEditorUserId="14790" LastEditDate="2015-11-13T07:31:09.860" LastActivityDate="2022-05-09T14:35:37.397" Title="433MHz sending not receiving" Tags="|arduino-nano|arduino-micro|virtualwire|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17734" PostTypeId="1" AcceptedAnswerId="17741" CreationDate="2015-11-12T21:14:09.683" Score="2" ViewCount="640" Body="&lt;p&gt;I plan to use &lt;a href=&quot;https://www.adafruit.com/products/1356&quot; rel=&quot;nofollow&quot;&gt;Adafruit's RGB sensor&lt;/a&gt; with Arduino working as a RGB controller running on 5V. In my location, &lt;a href=&quot;https://www.adafruit.com/products/1334&quot; rel=&quot;nofollow&quot;&gt;the 5V-compatible version of the sensor&lt;/a&gt; is not available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 3,3V pin on my Arduino board. Can I use it to power the sensor, or will the data pins (which are rated 5V) still burn it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TCS34725 chip uses I2C communication, which arguably would still be compatible with the 5V (&lt;a href=&quot;http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am still very new to the electronics, and I don't feel confident enough to build my own level converter, and sadly, no converters advertised on &lt;a href=&quot;http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; are available in my country (Poland). &lt;/p&gt;&#xA;" OwnerUserId="7329" LastActivityDate="2019-07-13T13:45:22.357" Title="Can I safely integrate 3,3v sensor with 5v Arduino UNO? How?" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17736" PostTypeId="1" AcceptedAnswerId="17737" CreationDate="2015-11-12T21:32:40.340" Score="3" ViewCount="848" Body="&lt;p&gt;I have a set of buttons wired to an arduino leonardo that are meant to send either single keystrokes to a computer &quot;a, b, c...&quot; etc, or a key sequence like ctrl+z (to perform an undo command.) Effectively this is a little usb keyboard with pre defined buttons. The way the struct is now, I can only manage to send one keystroke, never a modifier key+letter like I need. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full code is listed here under &quot;working code&quot;: &lt;a href=&quot;https://arduino.stackexchange.com/questions/17453/arduino-sending-keystrokes-via-push-buttons-proper-bouncing-and-manually-settin&quot;&gt;Arduino sending keystrokes via push-buttons. Proper bouncing and manually setting buttons?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It just debounces the buttons and sends back actions (just single letters right now) using the ones defined in the struct. (thanks very much jwpat7)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part in question is this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ButtonStruct buttons[nSwitches] = {&#xA;  {0, sw0, 'A'},&#xA;  {0, sw1, 'B'}, &#xA;  {0, sw2, 'C'}, &#xA;  {0, sw3, 'D'},&#xA;  {0, sw4, 'E'},&#xA;  {0, sw5, 'F'},&#xA;  {0, sw6, 'G'},&#xA;  {0, sw7, 'H'}};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I effectively want to replace the 'A' in {0, sw0, 'A'} to something that sends ctrl+z keystroke/keysequence instead of the letter 'A'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried KEY_LEFT_CTRL, setting a variable like char ctrlKey = KEY_LEFT_CTRL; and trying {0, sw0, ctrlKey, 'z'}, the &quot;substitution&quot; hex here: &lt;a href=&quot;http://www.nthelp.com/ascii.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.nthelp.com/ascii.htm&lt;/a&gt; and a number of other things.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read through a lot and I can't seem to find anything relevant. I've been told it's possible to use pointers to create a key-sequence but a -&gt; operand in there just throws errors. I'm new and I realize I might have a core principal wrong, but isn't there some simple syntax to send a ctrl+z command (and then releasing it obviously) using that space? When I put {0, sw0, KEY_LEFT_CTRL, 'z'} it just reports &quot;Lz&quot;, using the last letter in KEY_LEFT_CTRL instead of treating it as a modifier.  I'm so confused&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Also right now one press = one character and doesn't continually report like holding down a key on a regular keyboard.  I'd like to fix that too but I'd settle for just a bloody ctrl+z at this point.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Current Code (compiled!)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    enum { sw0=2, sw1=3, sw2=4, sw3=5, sw4=6, sw5=7, sw6=8, sw7=9}; // Switchbutton lines&#xA;enum { nSwitches=8, bounceMillis=42}; // # of switches; debounce delay&#xA;struct ButtonStruct {&#xA;  unsigned long int bounceEnd;  // Debouncing-flag and end-time&#xA;  // Switch number, press-action, release-action, and prev reading&#xA;  byte swiNum, swiActP, charMod, swiActR, swiPrev;&#xA;};&#xA;&#xA;struct ButtonStruct buttons[nSwitches] = {&#xA;  {0, sw0, 'z',  KEY_LEFT_CTRL}, &#xA;  {0, sw1, 'B'}, &#xA;  {0, sw2, 'C'}, &#xA;  {0, sw3, 'D'},&#xA;  {0, sw4, 'E'},&#xA;  {0, sw5, 'F'},&#xA;  {0, sw6, 'G'},&#xA;  {0, sw7, 'H'}};&#xA;//--------------------------------------------------------&#xA;void setup() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    pinMode(buttons[i].swiNum, INPUT_PULLUP);&#xA;Keyboard.begin();&#xA;}&#xA;//--------------------------------------------------------&#xA;byte readSwitch (byte swiNum) {&#xA;  // Following inverts the pin reading (assumes pulldown = pressed)&#xA;  return 1 - digitalRead(swiNum);&#xA;}&#xA;//--------------------------------------------------------&#xA;void doAction(byte swin, char code, char tosend, char chmodi) {&#xA;&#xA;if (chmodi) {    // See if modifier needed&#xA;   Keyboard.press(chmodi);&#xA;   Keyboard.press(tosend);&#xA;   delay(100);&#xA;   Keyboard.releaseAll();&#xA;} else {&#xA;   Keyboard.write(tosend);&#xA;}&#xA;}&#xA;//--------------------------------------------------------&#xA;void doButton(byte bn) {&#xA;  struct ButtonStruct *b = buttons + bn;&#xA;  if (b-&amp;gt;bounceEnd) { // Was button changing?&#xA;    // It was changing, see if debounce time is done.&#xA;      if (b-&amp;gt;bounceEnd &amp;lt; millis()) {&#xA;    b-&amp;gt;bounceEnd = 0;    // Debounce time is done, so clear flag&#xA;    // See if the change was real, or a glitch&#xA;    if (readSwitch(b-&amp;gt;swiNum) == b-&amp;gt;swiPrev) {&#xA;      // Current reading is same as trigger reading, so do it&#xA;      if (b-&amp;gt;swiPrev) {&#xA;        doAction(b-&amp;gt;swiNum, 'P', b-&amp;gt;swiActP, b-&amp;gt;charMod);&#xA;      } &#xA;    }&#xA;      }&#xA;  } else {  // It wasn't changing; but see if it's changing now&#xA;    if (b-&amp;gt;swiPrev != readSwitch(b-&amp;gt;swiNum)) {&#xA;      b-&amp;gt;swiPrev = readSwitch(b-&amp;gt;swiNum);&#xA;      b-&amp;gt;bounceEnd = millis()+bounceMillis; // Set the Debounce flag&#xA;    }&#xA;  }&#xA;}&#xA;//--------------------------------------------------------&#xA;long int seconds, prevSec=0;&#xA;void loop() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;    doButton(i);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14403" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-11-16T21:14:32.980" Title="sending ctrl-z in a struct?" Tags="|button|keyboard|pointer|struct|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17737" PostTypeId="2" ParentId="17736" CreationDate="2015-11-12T21:53:09.837" Score="2" Body="&lt;p&gt;&lt;strike&gt;First off, consider trying '\032' or '\x1A' for the ctrl-z.  (See, eg, &lt;em&gt;&lt;a href=&quot;https://stackoverflow.com/q/16132971&quot;&gt;How to send ctrl+z in C&lt;/a&gt;&lt;/em&gt; on stackoverflow.)&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To send a ctrl-z, use something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.press(ctrlKey);&#xA;Keyboard.press('z');&#xA;delay(100);&#xA;Keyboard.releaseAll();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For more examples of using modifier keys, see the &lt;a href=&quot;https://www.arduino.cc/en/Reference/KeyboardPress&quot; rel=&quot;nofollow noreferrer&quot;&gt;KeyboardPress&lt;/a&gt; page at arduino.cc, and the example program &lt;code&gt;KeyboardLogout.ino&lt;/code&gt;.  [To coordinate this with the &lt;code&gt;struct&lt;/code&gt; data structure approach, you could use code somewhat like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tosend = b-&amp;gt;actionChar1;&#xA;if (tosend &amp;lt; ' ') {    // See if modifier needed&#xA;   Keyboard.press(ctrlKey);&#xA;   Keyboard.press(tosend+96); // or is it 64?&#xA;   delay(100);&#xA;   Keyboard.releaseAll();&#xA;} else {&#xA;   Keyboard.write(tosend);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[You'll need to test which offset, 96 or 64, works in the above code; I don't have a Leonardo or similar to run this on, and haven't looked at the Keyboard library source to see how it treats this.]  Another way is to add a modifier-byte field in the &lt;code&gt;struct&lt;/code&gt;, and issue it if its non-zero.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, suppose the current form of &lt;code&gt;ButtonStruct&lt;/code&gt; is analogous to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ButtonStruct {&#xA;  unsigned long int bounceEnd;  // Debouncing-flag and end-time&#xA;  // Switch number, press-action and prev reading&#xA;  byte swiNum, actionChar1, swiPrev;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;actionChar1&lt;/code&gt; is the action character in use now.  You could add another byte to the &lt;code&gt;struct&lt;/code&gt;, say &lt;code&gt;actionChar2&lt;/code&gt;, and after a statement like &lt;code&gt;Keyboard.write(b-&amp;gt;actionChar1);&lt;/code&gt; add the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (b-&amp;gt;actionChar2)&#xA;  Keyboard.write(b-&amp;gt;actionChar2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which says to write out &lt;code&gt;actionChar2&lt;/code&gt; if it is non-zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some of the questions linked to the previous question, you may see advice that &lt;code&gt;Keyboard.write&lt;/code&gt; won't send non-printing characters.  I don't know if that's so, but in any case, there are mods available for &lt;code&gt;Keyboard&lt;/code&gt; (ie, changes to the library) that allow non-printing characters and special characters to be sent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note, if your program gets close to using all the RAM memory, you may want to keep &lt;code&gt;buttons[]&lt;/code&gt; in ProgMem and access it from there so it doesn't need to be copied into RAM.  (See the three ProgMem questions that are linked in the top right sidebar &lt;a href=&quot;https://arduino.stackexchange.com/q/13545&quot;&gt;.&lt;/a&gt;  &lt;a href=&quot;https://arduino.stackexchange.com/q/14250&quot;&gt;.&lt;/a&gt; &lt;a href=&quot;https://arduino.stackexchange.com/q/16012&quot;&gt;.&lt;/a&gt;)   If you change the struct to use strings instead of single chars for its actions, using less RAM will increase in importance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt; re:  “what I don't know how to change ---&gt; {0, sw0, 'A'}”: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;{0, sw0, 'A'}&lt;/code&gt; initializes an element of &lt;code&gt;buttons[]&lt;/code&gt;.&#xA;In &lt;code&gt;buttons[]&lt;/code&gt;, each element is a &lt;code&gt;ButtonStruct&lt;/code&gt;, because &lt;code&gt;buttons[]&lt;/code&gt; is an array of &lt;code&gt;ButtonStruct&lt;/code&gt;s.  (For more about structs, see syntax and examples in eg &lt;a href=&quot;https://en.wikipedia.org/wiki/Struct_%28C_programming_language%29#Declaration&quot; rel=&quot;nofollow noreferrer&quot;&gt;Struct (C programming language)&lt;/a&gt; in wikipedia.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You control what information can be in each element of &lt;code&gt;buttons[]&lt;/code&gt; by modifying the definition of &lt;code&gt;ButtonStruct&lt;/code&gt;.  If you need more data items in each &lt;code&gt;buttons[]&lt;/code&gt; entry, then add more data items in the definition of &lt;code&gt;ButtonStruct&lt;/code&gt;.  Likewise for fewer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you decide what information you need to have available to process a button press, modify &lt;code&gt;ButtonStruct&lt;/code&gt; to contain exactly that information.  It may be that some information will apply in some cases but not in all.  If so, when you initialize &lt;code&gt;buttons[]&lt;/code&gt;, have some value (say 0) that stands for not-used, and fill in not-used spots with that value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you need key modifiers (shift, ctrl, alt) add a modifier item to &lt;code&gt;ButtonStruct&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whenever you change &lt;code&gt;ButtonStruct&lt;/code&gt;, you need to change &lt;code&gt;buttons[]&lt;/code&gt; initialization to match.  For example, if &lt;code&gt;ButtonStruct&lt;/code&gt; were to include &lt;a href=&quot;https://www.arduino.cc/en/Reference/KeyboardModifiers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Keyboard Modifiers&lt;/a&gt; and looked like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct ButtonStruct {&#xA;  // Switch number, press-actions and prev reading&#xA;  byte swiNum, actionChar, charMod, swiPrev;&#xA;  unsigned long int bounceEnd;  // Debouncing-flag and end-time&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[with some items in a different order than before!] your initializer elements in the &lt;code&gt;buttons[]&lt;/code&gt; declaration could look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  { sw29, 'Q' },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;charMod&lt;/code&gt;, &lt;code&gt;swiPrev&lt;/code&gt;, and &lt;code&gt;bounceEnd&lt;/code&gt; are left to default to zero, or like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  { sw37, 'R',  KEY_LEFT_CTRL},&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;swiPrev&lt;/code&gt; and &lt;code&gt;bounceEnd&lt;/code&gt; default to zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, in your button-action code you could say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tosend = b-&amp;gt;actionChar;&#xA;chmodi = b-&amp;gt;charMod;&#xA;if (chmodi) {    // See if modifier needed&#xA;   Keyboard.press(chmodi);&#xA;   Keyboard.press(tosend);&#xA;   delay(100);&#xA;   Keyboard.releaseAll();&#xA;} else {&#xA;   Keyboard.write(tosend);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For those elements of &lt;code&gt;buttons[]&lt;/code&gt; where you specified a modifier, the &lt;code&gt;if&lt;/code&gt;'s first branch executes, and for those where you didn't, ie, for plain unmodified characters, the second one does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are all sorts of variants on these methods.  For example, instead of specifying action characters and modifiers in the &lt;code&gt;buttons[]&lt;/code&gt; array, you could change it so that you specify function names, or could have several classes of actions.  If 80% of the actions were to issue one simple character, make that class 0, so the action class can usually default to 0.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-11-14T06:17:35.870" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17738" PostTypeId="1" CreationDate="2015-11-12T22:49:43.997" Score="-1" ViewCount="724" Body="&lt;p&gt;I try more solution but there are not working. i use adafruit mpr121 lib, sparkfuns solution but there are not working. Some solutions say, cut the addr socket but i am not understand. maybe you show this solutions breakout, i try my code.&lt;/p&gt;&#xA;" OwnerUserId="14795" LastActivityDate="2015-11-13T00:48:09.140" Title="Mpr121 multiple using breakout" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17739" PostTypeId="2" ParentId="17734" CreationDate="2015-11-12T23:37:57.637" Score="1" Body="&lt;p&gt;You can use &quot;logic level converter bidirectional,&quot; to connect modules with different voltage requirements. They are pretty cheap.&lt;/p&gt;&#xA;" OwnerUserId="8300" LastEditorUserId="10907" LastEditDate="2015-12-09T21:31:14.323" LastActivityDate="2015-12-09T21:31:14.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17741" PostTypeId="2" ParentId="17734" CreationDate="2015-11-13T00:03:42.107" Score="3" Body="&lt;p&gt;If you need I2C the best solution is go for a logic level converter based on BSS138 mosfet or similar. I've used a few and they never let me down. Examples: Sparkfun have this &lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/12009&lt;/a&gt; and Adafruit &lt;a href=&quot;http://www.adafruit.com/products/757&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.adafruit.com/products/757&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://cdn.sparkfun.com//assets/parts/8/5/2/2/12009-07.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you have also a few transistors available, you can make your own homemade solution till you get something more robust, according to arduino page: &lt;a href=&quot;https://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://playground.arduino.cc/Main/I2CBi-directionalLevelShifter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ub5WD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ub5WD.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;https://playground.arduino.cc/uploads/Main/i2c-level-shifter-transistors.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduino.cc&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="27346" LastEditDate="2019-07-13T13:45:22.357" LastActivityDate="2019-07-13T13:45:22.357" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="17742" PostTypeId="2" ParentId="17733" CreationDate="2015-11-13T00:08:33.620" Score="3" Body="&lt;p&gt;If you are not getting anything on the receiver, then the receiver is definitely the problem. These units will boost the gain until it get some signal, any signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to power the receiver + and GND (I have one, which ran on 5v, I can't see if these are the same), and put a multimeter from GND to Data, and you should get about half of Vcc, probably fluctuating a bit. If you look at the same with an oscilloscope, it should fluctuating wildly between 0 and Vcc volts. All of this should work without a transmitter, and without an Arduino (you will need a power supply for the receiver).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this is from memory, I don't have mine here to test.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you are getting &quot;random data&quot; (background noise), you can progress to sending a signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you should keep your &quot;1&quot;s and &quot;0&quot;s balanced to get a clear signal - check out Manchester encoding (this encodes a &quot;1&quot; as &quot;1,0&quot;, and a 0 as &quot;0,1&quot;, so there will be a perfect balance). You might also want to send a 1010101010 at the start - this gives the receiver a chance to adjust the gain to the correct level. Or, you can use some width-based encoding (e.g. &quot;slow 1, slow 0&quot; for a &quot;1&quot;, and &quot;fast 0, fast 1&quot; for a &quot;0&quot;).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-11-13T00:25:48.533" LastActivityDate="2015-11-13T00:25:48.533" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17743" PostTypeId="2" ParentId="17738" CreationDate="2015-11-13T00:48:09.140" Score="2" Body="&lt;p&gt;Unfortunately the wording of your question is very poor, however I think you are asking how to use multiple MPR121 devices on an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the Sparkfun website you can change the I2C address from the default of 0x5A to one of four other addresses by cutting the jumpers on the back and connecting it to one of the other pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ADDR &gt; GND  = 0x5A (default)&lt;/li&gt;&#xA;&lt;li&gt;ADDR &gt; 3.3V = 0x5B&lt;/li&gt;&#xA;&lt;li&gt;ADDR &gt; SDA  = 0x5C&lt;/li&gt;&#xA;&lt;li&gt;ADDR &gt; SCL  = 0x5D&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would also recommend using the &lt;a href=&quot;https://github.com/BareConductive/mpr121&quot; rel=&quot;nofollow&quot;&gt;Bare Conductive&lt;/a&gt; libraries rather than Sparkfun/Adafruit as they are more user friendly.&lt;/p&gt;&#xA;" OwnerUserId="1233" LastActivityDate="2015-11-13T00:48:09.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17744" PostTypeId="1" AcceptedAnswerId="17749" CreationDate="2015-11-13T04:55:57.303" Score="0" ViewCount="1595" Body="&lt;p&gt;When I run my code, the ESC makes some noises, different on the high pulse and low pulse, then it begins to jiggle for a bit when it gets to the loop. Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define MAX_SIGNAL 2000&#xA;#define MIN_SIGNAL 1000&#xA;#define MOTOR_PIN 10&#xA;&#xA;Servo motor;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Program begin...&quot;);&#xA;  Serial.println(&quot;This program will calibrate the ESC.&quot;);&#xA;&#xA;  motor.attach(MOTOR_PIN);&#xA;&#xA;  // Wait for input&#xA;  while (!Serial.available());&#xA;  Serial.read();&#xA;&#xA;  Serial.println(&quot;Now writing maximum output.&quot;);&#xA;  motor.writeMicroseconds(MAX_SIGNAL);&#xA;  delay(2000);&#xA;&#xA;  // Send min output&#xA;  Serial.println(&quot;Sending minimum output&quot;);&#xA;  motor.writeMicroseconds(MIN_SIGNAL);&#xA;  delay(2000);&#xA;&#xA;}&#xA;&#xA;void loop() {  &#xA;  motor.writeMicroseconds(MAX_SIGNAL);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14798" LastActivityDate="2017-03-17T20:48:14.703" Title="Brushless motor &quot;jiggles&quot;" Tags="|motor|pwm|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17745" PostTypeId="1" AcceptedAnswerId="17760" CreationDate="2015-11-13T05:57:32.323" Score="1" ViewCount="784" Body="&lt;p&gt;I've been following &lt;a href=&quot;http://www.electroschematics.com/11291/arduino-dht22-am2302-tutorial-library/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; and I've run into some weird problems. When my motor starts running, I get &quot;Failed to read from DHT sensor&quot; on my serial window, meaning that readHumidity() and readTemperature() functions are returning NaNs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;strong&gt;only&lt;/strong&gt; happens while the motor is running. Once I stop the motor even momentarily, the DHT sensor starts working again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why this is happening? I'm using a genuine UNO and a RHT03 sensor and some 5.9V motor (TD599839).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached a diagram I made of my circuit in fritzing -&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CI1q2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CI1q2.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14799" LastActivityDate="2015-11-14T17:09:40.590" Title="Can't read from DHT sensor when motor is running" Tags="|arduino-uno|motor|temperature-sensor|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17747" PostTypeId="2" ParentId="17733" CreationDate="2015-11-13T07:43:58.400" Score="2" Body="&lt;p&gt;What I thought was the receiver turned out to be the transmitter. I've earned my noob medal now :)&#xA;The chip with the LR433A on it is the sending unit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code above and the wiring is all good!&lt;/p&gt;&#xA;" OwnerUserId="14790" LastActivityDate="2015-11-13T07:43:58.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17749" PostTypeId="2" ParentId="17744" CreationDate="2015-11-13T11:05:19.073" Score="1" Body="&lt;p&gt;Your code is familiar to the process of calibrating ESC controllers and is common. As your code is correct, we have to look at the connections. How is arduino connected to the ESC controller? can you provide a diagram? Only GND and Pin 10 should be connected. Do not connect the 5V of arduino. Power up the ESC with an external source. I think ESC signal port is Hi impedance so it should be no need for any resistor. Take a look at this site: &lt;a href=&quot;http://robots.dacloughb.com/project-2/esc-calibration-programming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://robots.dacloughb.com/project-2/esc-calibration-programming/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see in that picture ( and the picture on the link provided), only pwm pin and ground are connected to arduino. Show us your connections if things keep going wrong. Also, does your power source provides enough juice to the motor?&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="11529" LastEditDate="2017-03-17T20:48:14.703" LastActivityDate="2017-03-17T20:48:14.703" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17750" PostTypeId="1" AcceptedAnswerId="17754" CreationDate="2015-11-13T11:53:55.507" Score="3" ViewCount="4972" Body="&lt;p&gt;I am using AT Tiny 85 to read voltage from lead acid battery charger while charging.  Basically the setup has two 7-segment displays driven by two SIPO shift registers(74ls164n). And used tiny 85's pin 4 (physical pin3) to read voltage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the code using arduino and finally burned it to AT Tiny 85,   it didn't worked, i debugged it for hours, and pulled hair out of my head, tested it on bread board, eventually i changed the port to &quot;A2&quot; from &quot;4&quot; and surprisingly, everything runs as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is why this happens? why &lt;code&gt;analogRead(A2)&lt;/code&gt; works while &lt;code&gt;analogRead(4)&lt;/code&gt; don't. ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino IDE 1.6.5 with &lt;a href=&quot;https://github.com/damellis/attiny&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/damellis/attiny&lt;/a&gt;  (1.0.1 installed from the board manager) .&#xA; &lt;a href=&quot;https://i.stack.imgur.com/JipV5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JipV5.png&quot; alt=&quot;datashett from sparkfun:&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Full Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//// Arduino Uno Pins&#xA;//const int data = 8 ; //Tiny pin 3 (Physical 2)&#xA;//const int clock = 9 ;//Tiny pin 2 (physical 7)&#xA;//const int battery_Sensor = A0; //Tiny pin 4 (physical 3)&#xA;//const int charger_ctrl = 5;   //Tinypin 1 (physical 6)&#xA;&#xA;// ATTiny 85 Pins&#xA;const int data = 3 ;&#xA;const int clock = 2 ;&#xA;const int battery_Sensor = 4;&#xA;const int charger_ctrl = 1;&#xA;&#xA;int outputValue = 0;&#xA;int sensorValue = 0;&#xA;int voltage_reading = 0;&#xA;int msb = 0;&#xA;int lsb = 0 ;&#xA;&#xA;// Qo -&amp;gt; 1&#xA;// Q1 -&amp;gt; 2&#xA;// Q2 -&amp;gt; 4&#xA;// Q3 -&amp;gt; 5&#xA;// Q4 -&amp;gt; 6&#xA;// Q5 -&amp;gt; 7&#xA;// Q6 -&amp;gt; 9&#xA;// Q7 -&amp;gt; 10&#xA;&#xA;&#xA;char c_array[10] = { '0', '1', '2',  '3',  '4',  '5', '6',  '7', '8', '9'} ;&#xA;&#xA;int measure_voltage(){&#xA; sensorValue = analogRead(battery_Sensor);&#xA; return map(sensorValue, 0, 1023, 0, 50);&#xA;}&#xA;&#xA;byte seven_segment(char input, bool period){&#xA;  byte output_byte;&#xA;  switch (input) {&#xA;      case '0':&#xA;        output_byte = B11101110;&#xA;        break;&#xA;      case '1':&#xA;        output_byte = B10000010;&#xA;        break;&#xA;      case '2':&#xA;        output_byte = B11001101;&#xA;        break;&#xA;      case '3':&#xA;        output_byte = B01101101;&#xA;        break;&#xA;      case '4':&#xA;        output_byte = B00101011;&#xA;        break;&#xA;      case '5':&#xA;        output_byte = B01100111;&#xA;        break;&#xA;      case '6':&#xA;        output_byte = B11100111;&#xA;        break;&#xA;      case '7':&#xA;        output_byte = B00101100;&#xA;        break;&#xA;      case '8':&#xA;        output_byte = B11101111;&#xA;        break;&#xA;      case '9':&#xA;        output_byte = B00101111;&#xA;        break;&#xA;      default: &#xA;        output_byte = B00000001;&#xA;      break;&#xA;    }&#xA;  if(period == 1){&#xA;    output_byte = output_byte ^ B00010000;&#xA;  }&#xA;  return output_byte;&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(clock, OUTPUT); // make the clock pin an output&#xA;  pinMode(data , OUTPUT); // make the data pin an output&#xA;  pinMode(charger_ctrl, OUTPUT);&#xA;  pinMode(battery_Sensor, INPUT);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    voltage_reading = measure_voltage() ; // voltage x 10&#xA;    msb = voltage_reading/10;&#xA;    lsb = voltage_reading%10;&#xA;&#xA;    shiftOut(data, clock, LSBFIRST, seven_segment(c_array[lsb], 0));// send this binary value to the shift register&#xA;    shiftOut(data, clock, LSBFIRST, seven_segment(c_array[msb], 1)); &#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10370" LastActivityDate="2015-11-13T14:05:46.637" Title="ATTiny 85 analog input pin number problem" Tags="|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17752" PostTypeId="1" AcceptedAnswerId="17761" CreationDate="2015-11-13T12:45:08.857" Score="1" ViewCount="199" Body="&lt;p&gt;How can I connect antenna to GPS Module ET314AC?(it is not on a breakout board). I have an antenna like this one &lt;a href=&quot;http://www.aliexpress.com/item/1575-42MHZ-Magnetic-base-GPS-active-Antenna-with-SMA-Plug-connector-for-GPS-receivers-and-Mobile/1531700595.html&quot; rel=&quot;nofollow&quot;&gt;GPS Active Antenna&lt;/a&gt; and Here is the datasheet of ET314AC&lt;a href=&quot;https://www.google.com.pk/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=4&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CC0QFjADahUKEwil6qrq4vnIAhVBhRoKHQePBOM&amp;amp;url=http%3A%2F%2Fwww.szstoton.com%2Fres%2Fstotongps%2Fpdres%2F201203%2F20120320163340251.pdf&amp;amp;usg=AFQjCNFOZ31eexhFJWxNYqHvN-QWt4GoEA&quot; rel=&quot;nofollow&quot;&gt;ET314AC Datasheet&lt;/a&gt;.I want to connect it manually without any connectors or other things in fact I want to cutoff the connector from antenna.&lt;/p&gt;&#xA;" OwnerUserId="14604" LastActivityDate="2015-11-13T19:07:49.397" Title="Connect Antenna to GPS Module ET314AC" Tags="|arduino-mega|gps|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17753" PostTypeId="2" ParentId="17704" CreationDate="2015-11-13T12:48:12.433" Score="1" Body="&lt;p&gt;Use this example to open a webpage using a push button, you need &lt;code&gt;Python&lt;/code&gt; installed on your Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 01:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upload this sketch to your arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 2; // the number of the pushbutton pin&#xA;int buttonState = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);  &#xA;  pinMode(buttonPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  buttonState = digitalRead(buttonPin);&#xA;  if (buttonState == HIGH) {&#xA;  Serial.println(&quot;OpenWebPage&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Circuit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pushbutton attached to pin 2 from +5V&lt;/li&gt;&#xA;&lt;li&gt;10K resistor attached to pin 2 from ground&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/F5lqY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/F5lqY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 02:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open a text editor and paste this code to a new file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;from subprocess import call&#xA;&#xA;ser = serial.Serial(&#xA;    port='COM5', # Change this to your COM port number&#xA;    baudrate=9600,&#xA;    parity=serial.PARITY_ODD,&#xA;    stopbits=serial.STOPBITS_TWO,&#xA;    bytesize=serial.SEVENBITS&#xA;)&#xA;&#xA;if (ser.isOpen()):&#xA;    print &quot;Serial Port is Open...&quot;&#xA;    print &quot;Waiting for a command ...&quot;&#xA;    while 1:&#xA;        cmd = ser.readline()&#xA;        if cmd.strip() == &quot;OpenWebPage&quot;:&#xA;            print &quot;Received command from Arduino...&quot; &#xA;            print &quot;Opening webpage...&quot; &#xA;            call([&quot;explorer&quot;, &quot;http://www.google.com&quot;]) #change it the address you want&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save the file to your desktop, name it : &lt;code&gt;SerialListener.py&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Step 03&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Now open a Command Prompt window.&lt;/li&gt;&#xA;&lt;li&gt;Navigate to your desktop folder and execute this command: &lt;code&gt;python SerialListener.py&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You should see &lt;strong&gt;Serial Port is Open... Waiting for a command ...&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;Press the push button, and a webpage should open in your default browser.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-13T13:47:54.467" LastActivityDate="2015-11-13T13:47:54.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17754" PostTypeId="2" ParentId="17750" CreationDate="2015-11-13T14:05:46.637" Score="6" Body="&lt;p&gt;See the &lt;a href=&quot;https://github.com/damellis/attiny/blob/master/attiny/variants/tiny8/pins_arduino.h#L52&quot; rel=&quot;noreferrer&quot;&gt;analogPinToChannel&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t A0 = 6;&#xA;static const uint8_t A1 = 7;&#xA;static const uint8_t A2 = 8;&#xA;static const uint8_t A3 = 9;&#xA;&#xA;...&#xA;&#xA;#define analogPinToChannel(p)   ( (p) &amp;lt; 6 ? (p) : (p) - 6 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;A2&lt;/code&gt;, which is &lt;code&gt;8&lt;/code&gt;, will return &lt;code&gt;2&lt;/code&gt; (&lt;code&gt;8-6&lt;/code&gt;) from the &lt;code&gt;analogPinToChannel&lt;/code&gt; function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using &lt;code&gt;4&lt;/code&gt; will give &lt;code&gt;4&lt;/code&gt;. There is no (useful) analog channel &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-13T14:05:46.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17755" PostTypeId="2" ParentId="17516" CreationDate="2015-11-13T14:52:50.317" Score="1" Body="&lt;p&gt;I use a generic servo shield, and the &lt;em&gt;servo PWM outputs&lt;/em&gt; (3 pin inline connector) on the shield are labeled accordingly (&lt;code&gt;0&lt;/code&gt; - &lt;code&gt;15&lt;/code&gt;). Your Adafruit servo shield should be the same, see below.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fP171.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fP171.jpg&quot; alt=&quot;Adafruit Servo shield&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The link that you provide also has the &lt;em&gt;Arduino&lt;/em&gt; version, see below. You should use that, instead of the &lt;em&gt;Processing&lt;/em&gt; version.&lt;/p&gt;&#xA;&lt;p&gt;The Arduino library &lt;code&gt;Servo.h&lt;/code&gt;, handles all of the &amp;quot;Servo PWM to Arduino pin conversions&amp;quot; that you ask for. So, looking at the &lt;a href=&quot;https://github.com/mikevanis/Fixbot&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fixbot&lt;/a&gt; code, it would seem that all you would need to do is change the five pins (servo PWM outputs) to which the servos are &lt;code&gt;attach&lt;/code&gt;ed in &lt;code&gt;setup()&lt;/code&gt;, according to which servo PWM outputs you attach each servo to.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;String command;&#xA;&#xA;Servo seg0;&#xA;Servo seg1;&#xA;Servo seg2;&#xA;Servo seg3;&#xA;Servo seg4;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  seg0.attach(8);            /* &amp;lt;--- Change Me !!! */&#xA;  seg1.attach(9);            /* &amp;lt;--- Change Me !!! */&#xA;  seg2.attach(10);           /* &amp;lt;--- Change Me !!! */&#xA;  seg3.attach(11);           /* &amp;lt;--- Change Me !!! */&#xA;  seg4.attach(12);           /* &amp;lt;--- Change Me !!! */&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available() &amp;gt; 0) {&#xA;    char inChar = Serial.read();&#xA;    command += inChar;&#xA;    if(inChar == '\n') {&#xA;      // clear command&#xA;      performCmd(command);&#xA;      command = &amp;quot;&amp;quot;;&#xA;    }&#xA;    Serial.flush();&#xA;  }&#xA;}&#xA;&#xA;void performCmd(String cmd) {&#xA;  int comma1 = cmd.indexOf(',');&#xA;  int comma2 = cmd.indexOf(',', comma1+1);&#xA;  int comma3 = cmd.indexOf(',', comma2+1);&#xA;  int comma4 = cmd.indexOf(',', comma3+1);&#xA;  &#xA;  int cmd0 = stringToInt(cmd.substring(0, comma1));&#xA;  int cmd1 = stringToInt(cmd.substring(comma1+1, comma2));&#xA;  int cmd2 = stringToInt(cmd.substring(comma2+1, comma3));&#xA;  int cmd3 = stringToInt(cmd.substring(comma3+1, comma4));&#xA;  int cmd4 = stringToInt(cmd.substring(comma4+1, cmd.length()));&#xA;  &#xA;  seg0.write(cmd0);&#xA;  seg1.write(cmd1);&#xA;  seg2.write(cmd2);&#xA;  seg3.write(cmd3);&#xA;  seg4.write(cmd4);&#xA;  &#xA;}&#xA;&#xA;int stringToInt(String str) {&#xA;  String tmp = String(str);&#xA;  return str.toInt();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Regarding your question about the maximum and minimums, again, these will be handled by the &lt;code&gt;Servo.h&lt;/code&gt; library.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;TL;DR&lt;/h3&gt;&#xA;&lt;p&gt;Change the five servo &lt;code&gt;attach&lt;/code&gt; lines in the &lt;code&gt;setup()&lt;/code&gt; routine, to reflect which servo ports your servos are connected to.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;strong&gt;Power Requirements&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;As an aside, remember that you will need to supply external power (+5V) to the Adafruit Servo board, via the blue screw terminal block, in order to have sufficient power (current) to actuate the servos. In the photo above the screw terminal block is not shown, but would be mounted half way up on the left hand side of the PCB (where it says &lt;code&gt;5-6V Servo&lt;/code&gt;). It can be seen in this photo, at the top:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mk9bK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mk9bK.jpg&quot; alt=&quot;Adafruit Servo Shield, showing blue screw terminal&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you do not supply external power, then the Arduino board, by itself will not be able to supply enough power. Even though the code may be running, the lack of power may make it appear that there is no output, as the servos remain immobile, due to the lack of current.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-11-14T03:25:22.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17756" PostTypeId="1" CreationDate="2015-11-13T16:01:40.957" Score="1" ViewCount="6033" Body="&lt;p&gt;I have two arduinos one is Arduino Mega while other is Arduino UNO and I want to send data from UNO to Mega and vice versa over wifi using two ESP8266 wifi modules without use of any router in between, so what is the simplest procedure I can use to do this? Moreover how can I do this with a router in between?&lt;/p&gt;&#xA;" OwnerUserId="14604" LastActivityDate="2016-06-08T06:17:45.327" Title="Communication between two arduinos over wifi esp8266" Tags="|arduino-uno|arduino-mega|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17757" PostTypeId="2" ParentId="17756" CreationDate="2015-11-13T16:28:56.433" Score="2" Body="&lt;p&gt;The simplest solution is to turn on Access Point Mode on one of Wifi modules. and the other one has to be set to Station Mode in order to connect to the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you want to add a router, just set both ESP8266 modules to Station Mode and connect them to the router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I would recommend replacing the Original Firware (AT firmware) of ESP8266 with NodeMCU Firmware. It uses lua language to write programs directly to ESP8266 which means that you can even make 2 ESP8266 modules talk with each other without even using Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-13T17:34:45.050" LastActivityDate="2015-11-13T17:34:45.050" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17758" PostTypeId="1" AcceptedAnswerId="17759" CreationDate="2015-11-13T16:30:04.637" Score="1" ViewCount="63" Body="&lt;p&gt;When I look at arduino and arduino-like boards featuring ATMEGA328 chip, I see that they either use a micro controller or a FTDI chip to program the ATMEGA through Arduino board pin 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This only works because there is a bootloader available on the chip. Is the bootloader present by default or do I need to install it.&#xA;What I mean is can I just buy 10,000 ATMEGA328 from ATMEL, put them on boards and program them through UART or do I need to first flash them with a bootloader?&lt;/p&gt;&#xA;" OwnerDisplayName="PeterG" LastActivityDate="2015-11-13T17:14:17.883" Title="Arduino Bootloader availability" Tags="|bootloader|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17759" PostTypeId="2" ParentId="17758" CreationDate="2015-11-13T16:32:56.080" Score="2" Body="&lt;p&gt;The bootloader is the feature supplied with the Arduino board, but not a chip itself. If you want to clone Arduino (fully or partially), you will have to burn the bootloader yourself.&lt;/p&gt;&#xA;" OwnerUserId="6848" OwnerDisplayName="Eugene Sh." LastActivityDate="2015-11-13T16:32:56.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17760" PostTypeId="2" ParentId="17745" CreationDate="2015-11-13T18:51:21.043" Score="0" Body="&lt;p&gt;The problem may be electrical noise from the motor, or &#xA;you may have a wiring problem (an incorrect or intermittent connection).&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Kira San’s comment “try to add a 100nF ceramic capacitor between the motor terminals” is directed toward suppressing electrical motor noise.  As brushes make or break connections on a motor's commutator, arcs and sparks can occur.  The capacitor will limit voltage rate of change thus suppressing some of that electrical noise.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;CharlieHanson's comment (add a flyback diode across the motor terminals) is partly related to noise suppression but mostly to suppressing high voltage excursion that occurs when you shut off motor power.  While the motor is running, the magnetic field in it stores ½ L i² joules of power.  When current stops suddenly, those joules of power convert to a high voltage spike.  A &lt;a href=&quot;https://en.wikipedia.org/wiki/Flyback_diode&quot; rel=&quot;nofollow noreferrer&quot;&gt;flyback diode&lt;/a&gt; acts as a near-short to absorb that spike.  The cathode (cross-bar) of the flyback diode attaches to the high side of the motor voltage, as shown in &lt;a href=&quot;http://www.electroschematics.com/wp-content/uploads/2015/02/arduino-dht22-circuit.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;the circuit diagram&lt;/a&gt; of the &lt;a href=&quot;http://www.electroschematics.com/11291/arduino-dht22-am2302-tutorial-library/&quot; rel=&quot;nofollow noreferrer&quot;&gt;project you linked to&lt;/a&gt; on electroschematics.com.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Re “you are using a resistor with that LED, yes? I'll overlook the fact that it's the wrong way round in the schematic!”, if the LED is wired backwards as shown in your drawing, it won't turn on – which is a good thing, because without a resistor (say 300-3000 Ω) in series with the LED, enough current may flow to damage the Uno or the LED.  Turn the LED around on the schematic (and on your wiring setup if you didn't already), and add a series resistor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; A comment says, “Don't have a diode either :S Will an LED work instead?”.  LEDs typically have rather low reverse-voltage ratings – 4 to 5 volts.  You could put two or three in series and if they don't burn up you're ok for this experiment.  But in production, don't depend on LEDs as flyback diodes except where it doesn't matter what happens.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;Gerben's comment, “What is that capacitor doing there? Slow start?” refers to the 100 μF capacitor shown between transistor base and emitter.  In conjunction with the 1KΩ resistor from D4, that gives RC=0.1 second, so the transistor will take an appreciable amount of time to turn on.  This has a couple of consequences:  PWM control may be less effective (at low duty cycles, PWM depends on short, high-current pulses, to overcome stiction etc) and the transistor will run hotter.  If it's a big power transistor, ok.  If it's a small switching transistor intended for full-on or full-off, no.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; A comment refers to a &lt;em&gt;&lt;a href=&quot;http://www.electroschematics.com/9540/arduino-fan-speed-controlled-temperature/&quot; rel=&quot;nofollow noreferrer&quot;&gt;fan speed controlled temperature&lt;/a&gt;&lt;/em&gt; page at electroschematics.com.  That page shows a &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/CD00001225.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;BD139 power transistor&lt;/a&gt;, and says the 100 μF capacitor between transistor base and emitter eliminates some motor noise.  Thus it falls into the “big power transistor, ok” category.  Well, more or less ok.  A heat sink may be needed on the transistor and the capacitor probably doesn't need to be that big; eg try 10 μF instead of 100.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;An ordinary 9V battery easily supplies a dozen milliamps, but current draw larger than that quickly depletes it.  See eg &lt;a href=&quot;http://www.powerstream.com/9V-Alkaline-tests.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;9V Alkaline tests&lt;/a&gt; at powerstream.com and my answer to a previous question, &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/a/9853/3917&quot;&gt;Using Arduino Micro With 12V Buzzer&lt;/a&gt;&lt;/em&gt; that's somewhat related.  The motor shown (&lt;a href=&quot;http://www.precisionmicrodrives.com/admin/a/search?q=124-001&quot; rel=&quot;nofollow noreferrer&quot;&gt;TD599839&lt;/a&gt;) is rated at 35 mA at 5.9 V no-load, so will draw say 50 mA no-load from a 9V battery and will try to draw several times that if loaded; ie it will overstress an ordinary 9V battery.  In brief: Use a wall-wart or equivalent, or a big battery, rather than a small 9V battery when running motors.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-11-14T17:09:40.590" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17761" PostTypeId="2" ParentId="17752" CreationDate="2015-11-13T19:07:49.397" Score="1" Body="&lt;p&gt;Read the datasheet!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;V_ANT_IN&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This pin is reserved an external DC power supply for active antenna.&#xA;  If using 2.85V active antenna, pin 19 has to be connected to pin 20.&#xA;  If the bias voltage of active isn’t 2.85V,you can input bias voltage of you need to this pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So just wire the antenna to the RF_IN pin and GND, and connect pin 19 to +3.3V (since your antenna is 3.3V not 2.85V).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-13T19:07:49.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17762" PostTypeId="1" AcceptedAnswerId="17763" CreationDate="2015-11-13T19:41:54.370" Score="0" ViewCount="26081" Body="&lt;p&gt;I'm having this strange error, which pops up around 90% of the time. I am trying to program my attiny25 using USBasp and the Arduino IDE / library. Sometimes it works, most times it doesn't.. This error occurs on large sketches as well as new sketches, with just the empty setup() and loop() functions. The error looks quite random to me, because my program just uploaded after trying around 10 times. Compiling goes fine. The error always occurs at byte 0x0000, and always in the format 0x00 != 0x _ _. I have six wires (correctly) connected from the USBasp to the attiny25. I do not use any resistors, capacitors etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone tell me what could possibly cause this error, and what to do to fix it? &lt;/p&gt;&#xA;" OwnerUserId="14509" LastActivityDate="2023-03-02T19:15:35.103" Title="avrdude: verification error, first mismatch at byte 0x0000 : 0x00 != 0x16 using USBasp" Tags="|arduino-ide|uploading|attiny|avrdude|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17763" PostTypeId="2" ParentId="17762" CreationDate="2015-11-13T19:46:59.937" Score="4" Body="&lt;p&gt;The cause is most likely the fact that you &lt;em&gt;&quot;... do not use any resistors, capacitors etc.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect a 100nF capacitor between Vcc and GND.  Connect a 10KΩ resistor between RESET and Vcc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-13T19:54:34.780" LastActivityDate="2015-11-13T19:54:34.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17764" PostTypeId="2" ParentId="17762" CreationDate="2015-11-13T19:57:13.373" Score="1" Body="&lt;p&gt;The problem has to do with the auto-reset feature, so you have to make sure the Reset pin is connected to VCC via a pull-up resistor. Generally, a 10k resistor will be just fine.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2015-11-13T19:57:13.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17765" PostTypeId="1" CreationDate="2015-11-13T20:36:36.470" Score="2" ViewCount="1272" Body="&lt;p&gt;I own a Macbook running OS X 10.10.3 (Yosemite)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I own a &lt;a href=&quot;http://minseg.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Min Seg&lt;/a&gt;.&lt;br&gt;&#xA;My Min Seg model is built on an Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Problem&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When I connect the board to the Macbook,&lt;br&gt;&#xA;using either of the Macbook's two USB 2.0 ports,&lt;br&gt;&#xA;using either of two USB A to B cables,&lt;br&gt;&#xA;the board lights up, but I am unable to connect&lt;br&gt;&#xA;to the tty device using the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Tools --&amp;gt; Port&lt;/code&gt; offered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/cu.Bluetooth-Incoming-Port&#xA;/dev/cu.Bluetooth-Modem&#xA;/dev/cu.usbmodem621 (Arduino Genuino Mega or Mega 2560)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was expecting to also see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/dev/tty.usbmodem621 (Arduino Genuino Mega or Mega 2560)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I unplug the board, the third listed option &#xA;from &lt;code&gt;Tools --&amp;gt; Port&lt;/code&gt; disappears, as expected.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Verification 1&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I opened the System Information utility application.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;USB --&amp;gt; USB Bus --&amp;gt;Arduino Mega:&#xA;&#xA;  Product ID:    0x0042&#xA;  Vendor  ID:    0x2a03&#xA;  Version:       0.01&#xA;  Serial Number: 75435353038351316281&#xA;  Speed:         Up to 12 Mb/sec&#xA;  Manufacturer:  Arduino Srl&#xA;  Location ID:   0x06200000 / 3&#xA;  Current Available (mA): 500&#xA;  Current Required  (mA): 100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Verification 2&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I used the Sparkfun &lt;a href=&quot;https://learn.sparkfun.com/tutorials/terminal-basics/all#coolterm-windows-mac-linux&quot; rel=&quot;nofollow noreferrer&quot;&gt;Terminal Basics&lt;/a&gt; wiki to check for the device.&#xA;I used the Terminal utility application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ls /dev/tty.*&lt;/code&gt; offered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/tty.Bluetooth-Incoming-Port&#xA;/dev/tty.Bluetooth-Modem&#xA;/dev/tty.usbmodem621&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;screen /dev/tty.usbmodem621 9600&lt;/code&gt; offered a successful connection.&lt;br&gt;&#xA;[A white screen, which allowed for exit using &lt;code&gt;Control+A&lt;/code&gt; followed by &lt;code&gt;Control+/&lt;/code&gt;]&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Attempted Solutions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I tried several means from &lt;a href=&quot;https://arduino.stackexchange.com/questions/12133/mac-osx-yosemite-no-serial-ports-showing-for-uno-r3&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I installed the &lt;a href=&quot;http://www.ftdichip.com/Drivers/VCP.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTDI drivers&lt;/a&gt;.&lt;br&gt;&#xA;I ran &lt;code&gt;sudo nvram boot-args=&quot;kext-dev-mode=1&quot;&lt;/code&gt; in the Terminal application.&lt;br&gt;&#xA;Is an alternative driver worth attempting, such as that listed &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also attempted to connect through Mathworks Simulink.&lt;br&gt;&#xA;When setting connection options, the program states&lt;br&gt;&#xA;that a cu device is expected, rather than a tty.&lt;/p&gt;&#xA;" OwnerUserId="14811" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-11-13T23:37:04.237" Title="Mac Arduino IDE Connection to Min Seg (Mega 2560). No tty" Tags="|arduino-ide|mac-os|port-mapping|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17766" PostTypeId="1" AcceptedAnswerId="17771" CreationDate="2015-11-13T23:22:27.957" Score="3" ViewCount="44843" Body="&lt;p&gt;I have Arduino Uno and 0.96&quot; I2C Oled 4 Pinned display. These are my Arduino codes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;U8glib.h&quot;&#xA;&#xA;U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);    // VDD=5V SCL=A5 SDA=A4&#xA;&#xA;int a = 10;&#xA;&#xA;void setup(void) {&#xA;}&#xA;&#xA;void loop(void) {&#xA;&#xA;  u8g.setFont(u8g_font_gdr25r);&#xA;  u8g.drawStr(8, 30, &quot;E&quot;);&#xA;  u8g.setFont(u8g_font_gdr25r);&#xA;  u8g.drawStr(30, 30,&quot;l&quot;);&#xA;  delay(2000);  &#xA;&#xA;  //  u8g.println(a);  //This code raw is not working&#xA;  //  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to indicate integer type variable is called &quot;a&quot; to the OLED screen, but u8glib library hasn't got &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;println( (int) a );&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;function to do this. I only see &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;u8g.drawStr(); &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;function that this can't handle integer variables to the display. How can I do that? &lt;/p&gt;&#xA;" OwnerUserId="1006" LastEditorUserId="1006" LastEditDate="2015-11-13T23:37:36.903" LastActivityDate="2019-08-14T20:34:05.170" Title="How to display variables on 0.96&quot; OLED with u8glib library?" Tags="|arduino-uno|i2c|display|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17767" PostTypeId="2" ParentId="17765" CreationDate="2015-11-13T23:37:04.237" Score="1" Body="&lt;p&gt;What you are seeing is normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In BSD (which is the OS that Mac OS is based on) a serial port has two distinct devices for two distinct roles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tty, or TeleTYpe interface is used for incoming connections, be that from a modem, serial terminal, whatever. You would normally run a process called getty on it to present a login prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cu, or Call Unix interface is used for making outgoing connections to other devices. Traditionally that was mainly other Unix servers through modems. Nowadays it includes many other devices such as an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The theory is that when you try and initiate an outgoing connection through the cu interface it first checks that no-one is connected in through the tty interface and if the serial port is available it disables the tty interface so the listening getty process doesn't interfere with your call. Also the tty and cu interfaces deal with the modem control lines differently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE is merely honouring that system by only offering you the outgoing device in the port list. As far as the Arduino communication is concerned there should be no difference.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-13T23:37:04.237" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17770" PostTypeId="2" ParentId="104" CreationDate="2015-11-14T07:08:44.313" Score="0" Body="&lt;p&gt;I have tried android app to programming Arduino Uno via bluetooth, simply by adding &lt;a href=&quot;http://www.bluino.com/2015/10/bluino-shield-pre-order.html#.Vkaz9NIrK70&quot; rel=&quot;nofollow&quot;&gt;Bluino_Shield&lt;/a&gt; to your Arduino Uno. This link app &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.bluino.bluinoloader&quot; rel=&quot;nofollow&quot;&gt;https://play.google.com/store/apps/details?id=com.bluino.bluinoloader&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14818" LastActivityDate="2015-11-14T07:08:44.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17771" PostTypeId="2" ParentId="17766" CreationDate="2015-11-14T07:23:59.043" Score="5" Body="&lt;p&gt;The &lt;a href=&quot;https://code.google.com/p/u8glib/wiki/userreference&quot; rel=&quot;nofollow&quot;&gt;U8glib user reference&lt;/a&gt; page mentions a couple of ways to print the value of a number using ASCII characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg, following the idea at the second mention of &lt;code&gt;sprintf&lt;/code&gt; at above link:&lt;s&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buf[9];&#xA;sprintf (buf, &quot;%d&quot;, a);&#xA;u8g.drawStr(33, 33, buf);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/s&gt;&lt;em&gt;Edit:&lt;/em&gt; The above follows the example at the link, but I've struck it out because in general &lt;code&gt;snprintf&lt;/code&gt; is safer than &lt;code&gt;sprintf&lt;/code&gt;.  See below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum {BufSize=9}; // If a is short use a smaller number, eg 5 or 6 &#xA;char buf[BufSize];&#xA;snprintf (buf, BufSize, &quot;%d&quot;, a);&#xA;u8g.drawStr(33, 33, buf);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The other way is via &lt;code&gt;print&lt;/code&gt;.  (Search for U8GLIB::print in above link, and also see arduino.cc's &lt;a href=&quot;https://www.arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow&quot;&gt;Print&lt;/a&gt; docs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;u8g.print(a);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get a &lt;code&gt;newline&lt;/code&gt; effect, you may need to have a variable keeping track of the current line number; add 1 to it to get next line's number, and use that as a position parameter in a &lt;code&gt;drawStr&lt;/code&gt; call.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-14T16:35:10.703" LastActivityDate="2015-11-14T16:35:10.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17773" PostTypeId="2" ParentId="17766" CreationDate="2015-11-14T12:28:19.613" Score="0" Body="&lt;p&gt;Ok, I have found the solution (Thank you @jwpat7) Here is my working code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;U8glib.h&quot;&#xA;&#xA;U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);  // VDD=5V GND=GND SCL=A5 SDA=A4&#xA;&#xA;int a = 0;&#xA;&#xA;void setup() {      }&#xA;&#xA;void loop() {&#xA;&#xA;u8g.firstPage(); &#xA; do {&#xA;u8g.setFont(u8g_font_gdr25r);&#xA;//u8g.drawStr(8, 30, &quot;Eeee&quot;);&#xA;&#xA;char buf[9];&#xA;sprintf (buf, &quot;%d&quot;, a);&#xA;u8g.drawStr(18, 3, buf);&#xA;&#xA;  } while( u8g.nextPage() );&#xA;  delay(200); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2015-11-14T12:28:19.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17774" PostTypeId="1" AcceptedAnswerId="17776" CreationDate="2015-11-14T12:49:12.333" Score="1" ViewCount="1869" Body="&lt;p&gt;I want to know if it's possible to use the F() macro on text that is being passed to a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an example function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void displayMenu(const char * txt, byte &amp;amp;var) {&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(txt);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(var);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is how I'm calling the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;displayMenu(&quot;Backlight:&quot;, backlight);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I didn't separate the repeating code into a separate function, I would've been able to write it out like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.clear();&#xA;lcd.setCursor(0, 0);&#xA;lcd.print(F(&quot;Backlight: &quot;));&#xA;lcd.setCursor(0, 1);&#xA;lcd.print(var);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I try to do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;displayMenu(F(&quot;Backlight&quot;), backlight);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it doesn't work. Also if I try to do this in the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(F(txt));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that also doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just wondering if such a thing is possible.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-11-14T15:21:10.627" Title="Any way to use F macro with a passed variable?" Tags="|flash|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17775" PostTypeId="1" AcceptedAnswerId="17777" CreationDate="2015-11-14T13:21:25.190" Score="2" ViewCount="1882" Body="&lt;p&gt;according to the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;tone()&lt;/a&gt; documentation using tone() interferes with PWM output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On my &lt;strong&gt;Arduino Micro&lt;/strong&gt; it seems to interfere with PWM on pin 5. After using tone() the PWM does not seem to work anymore. If I use pin 3,9 instead everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can someone explain why that is happening and if there is a way to circumvent that?&lt;/p&gt;&#xA;" OwnerUserId="14823" LastActivityDate="2015-11-14T16:32:02.757" Title="Arduino Micro tone() PWM Pins" Tags="|pwm|arduino-micro|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17776" PostTypeId="2" ParentId="17774" CreationDate="2015-11-14T15:21:10.627" Score="2" Body="&lt;p&gt;There is a special type for just this occasion - the &lt;code&gt;__FlashStringHelper&lt;/code&gt; type.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void displayMenu(const __FlashStringHelper *txt, byte var) {&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(txt);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(var);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note I removed the &lt;code&gt;&amp;amp;&lt;/code&gt; from &lt;code&gt;var&lt;/code&gt; - you don't want that unless you are passing a complex class or are wanting to modify the contents of &lt;code&gt;var&lt;/code&gt; in the function and have it reflected back outside the function.  Passing a reference to a byte (&lt;code&gt;&amp;amp;var&lt;/code&gt;) requires two bytes of data - just passing the content of a byte only requires one byte of data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-14T15:21:10.627" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17777" PostTypeId="2" ParentId="17775" CreationDate="2015-11-14T15:25:34.487" Score="2" Body="&lt;p&gt;It's called a &lt;em&gt;resource conflict&lt;/em&gt;.  The Arduino only has limited resources, and some resources are shared between different tasks. You can use that resource for one task or the other but not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the resource is a &lt;em&gt;timer&lt;/em&gt;.  You can use that timer to generate PWM or you can use it to drive the &lt;code&gt;tone()&lt;/code&gt; system - but not both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default the timer is configured for PWM, but once you use &lt;code&gt;tone()&lt;/code&gt; it re-assigns the timer to be used to trigger an interrupt at a specific frequency to toggle an IO pin.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-14T15:25:34.487" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17778" PostTypeId="2" ParentId="17775" CreationDate="2015-11-14T16:32:02.757" Score="3" Body="&lt;p&gt;The pin 3 and 11 only refers to boards based on the ATMega328. On these boards timer2 is used by tone, disabling PWM on pins 3 and 11. See Majenko answer about timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Micro (ATMega32u4) tone uses timer 3, which is connected to pin 5 only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So on the Micro, just don't use pin 5 for PWM when using tone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly don't trust everything on the arduino.cc website. There quite a bit of misinformation on there.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-14T16:32:02.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17779" PostTypeId="2" ParentId="1048" CreationDate="2015-11-14T17:04:04.270" Score="1" Body="&lt;p&gt;Arduino is really a common set of code that makes using the dev boards they sell accessible to wide range of user base.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is basically an IDE that uses the C/C++ language and a set of classes that are adaptable to common set of hardware, predominantly Atmel and mostly AVR although as people have mentioned already the Arduino boards are becoming increasingly more powerful. But is amazing how much you can do with the ATmega328p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to use the Arduino IDE to program your board and in fact, I tend to use Atmel Studio myself or Notepad++. You can get a plug-in for Atmel Studio 6.2 and above that allows you to create sketches and upload them to most Arduino boards.&lt;/p&gt;&#xA;" OwnerUserId="14649" LastActivityDate="2015-11-14T17:04:04.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17780" PostTypeId="1" CreationDate="2015-11-13T12:08:45.740" Score="0" ViewCount="4004" Body="&lt;p&gt;I am trying to send hex or binary numbers through BLE UART, but it is taking only char value which is converted into ASCII value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Adafruit's Bluefruit micro device and Bluefruit LE apps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/Bluefruit_LE_Connect_Android&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/Bluefruit_LE_Connect_Android&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/adafruit/Adafruit_BluefruitLE_nRF51&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/Adafruit_BluefruitLE_nRF51&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(F(&quot;[Recv] &quot;));&#xA;Serial.println(ble.buffer);&#xA;BluetoothData=ble.buffer[0];&#xA;Serial.println(BluetoothData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/maqfC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/maqfC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the UART box I want to type only a hex number and receive it in the Ble.buffer of the Arduino only.&lt;/p&gt;&#xA;" OwnerUserId="14152" OwnerDisplayName="Deepak Aagri" LastEditorUserId="220" LastEditDate="2015-11-22T14:54:48.270" LastActivityDate="2016-01-21T18:16:49.070" Title="How to send and receive hex or binary numbers via BLE UART?" Tags="|nrf51|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17781" PostTypeId="2" ParentId="17780" CreationDate="2015-11-13T13:34:18.440" Score="1" Body="&lt;p&gt;ASCII is just a pattern of 0s and 1s, and can therefore be represented in binary, hex, octal, or decimal. The interpretation is entirely up to you in your code.&lt;/p&gt;&#xA;" OwnerDisplayName="Matt Young" LastActivityDate="2015-11-13T13:34:18.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17782" PostTypeId="1" AcceptedAnswerId="17801" CreationDate="2015-11-14T20:56:25.390" Score="1" ViewCount="1134" Body="&lt;p&gt;So basically I'm making 2 buttons turn on and off 2 different LEDs using debounce.&#xA;I got that settled with one button to turn on and off 1 LED.&#xA;But how do I make it so I can use the same lines but obviously different names of pins in Void loop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this is the one command line, but how do I make 2 commands with the if statement, may I have an example? Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;int inPin = 22;         // the number of the input pin&#xA;int inPin2 = 26;&#xA;int outPin1 = 13;       // the number of the output pin&#xA;int outPin2 = 6;&#xA;&#xA;int state = LOW;      // the current state of the output pin&#xA;int reading;           // the current reading from the input pin&#xA;int reading2;&#xA;int previous = HIGH;    // the previous reading from the input pin&#xA;int previous2 = HIGH;&#xA;&#xA;&#xA;// the follow variables are long's because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long time = 0;         // the last time the output pin was toggled&#xA;long debounce = 200;   // the debounce time, increase if the output flickers&#xA;&#xA;//===============================================================================================&#xA;void doIt(int outPin)&#xA;{&#xA;  Serial.print(&quot;Button Switch State Change:&quot;);&#xA;  if (state == HIGH) state = LOW;&#xA;  else state = HIGH;&#xA;  Serial.println(state);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Zone1|State: &quot;);&#xA;  lcd.print(state ? F(&quot;On&quot;) : F(&quot;Off&quot;));&#xA;  Serial.print(state ? F(&quot;On&quot;) : F(&quot;Off&quot;));&#xA;  digitalWrite(outPin, state);&#xA;}&#xA;//===============================================================================================&#xA;void setup()&#xA;{&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;System Activated&quot;);&#xA;  //&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Ready...&quot;);&#xA;&#xA;  pinMode(inPin, INPUT);&#xA;  pinMode(outPin1, OUTPUT);&#xA;  pinMode(inPin2, INPUT);&#xA;  pinMode(outPin2, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;System Activated&quot;);&#xA;  Serial.println(&quot;Made by Mateo Holguin&quot;);&#xA;  Serial.println(&quot;0 = Light is Off | 1 = Light is On&quot;);&#xA;  Serial.println(&quot;=======================================&quot;);&#xA;}&#xA;&#xA;//===============================================================================================&#xA;&#xA;void loop()&#xA;{&#xA;  reading = digitalRead(inPin);&#xA;  reading2 = digitalRead(inPin2);&#xA;&#xA;  if (reading == HIGH &amp;amp;&amp;amp; previous == LOW &amp;amp;&amp;amp; millis() - time &amp;gt; debounce) {&#xA;    doIt(outPin1);  &#xA;  }&#xA;  else if (reading2 == HIGH &amp;amp;&amp;amp; previous2 == LOW &amp;amp;&amp;amp; millis() - time &amp;gt; debounce){&#xA;    doIt(outPin2);&#xA;  }&#xA;&#xA;&#xA;&#xA;  previous = reading;&#xA;  previous2 = reading2;&#xA;  time = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14716" LastEditorUserId="14716" LastEditDate="2015-11-15T21:05:40.777" LastActivityDate="2015-11-16T17:11:02.680" Title="Two commands in Void loop?" Tags="|c++|debounce|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17783" PostTypeId="2" ParentId="17782" CreationDate="2015-11-14T21:05:54.873" Score="1" Body="&lt;p&gt;I think you are asking &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (value &amp;gt; 5)&#xA;{&#xA;  StatementOne;&#xA;  statementTwo;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I think you might want to write a function, which would look like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void doThing(int button, int led)&#xA;{&#xA;  if (digitalRead(button))&#xA;     digitalWrite(led);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[Edit after reading your comment]&#xA;So you need to store the state of the system as a variable in the code.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool state = false;&#xA;if (button1 &amp;amp;&amp;amp; !state)&#xA;{&#xA;  state = true;&#xA;  // Your on code.&#xA;} &#xA;if (button2 &amp;amp;&amp;amp; state)&#xA;{&#xA;  state = false; &#xA;  // Your off code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to add your existing code for turning your LCD and LED on and off where the comments are.&lt;br&gt;&#xA;The state variable holds the on or off state of your LCD and LED.&#xA;You can of course split it even further so your LCD and LED come on separately of each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that help?  If so don't forget to mark it as answered.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2015-11-16T17:11:02.680" LastActivityDate="2015-11-16T17:11:02.680" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17784" PostTypeId="1" AcceptedAnswerId="17785" CreationDate="2015-11-15T03:02:04.567" Score="0" ViewCount="839" Body="&lt;p&gt;I've been teaching a blind student how to program and build electronics with Arduino. So far I've substituted LED's with piezo buzzers with excellent results. We are getting to the point where more complicated output is required and braille displays are excessively expensive. &#xA;I've found these micro solenoids on eBay.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/wxNg7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wxNg7.jpg&quot; alt=&quot;micro solenoids &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are 5 volts and small enough to place on a grid to create display. Could I substitute these on a regular LED grid and run it via conventional shift register or MAX7219 methods?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the link to the &lt;a href=&quot;http://m.ebay.com/itm/2pcs-x-DC-5v-6V-inhaled-Type-Push-Pull-Solenoid-Electromagnet-DC-Micro-Solenoid-/331680100757?nav=SEARCH&quot; rel=&quot;nofollow noreferrer&quot;&gt;micro solenoids&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7061" LastActivityDate="2015-11-15T22:16:11.737" Title="8x8 solenoid matrix" Tags="|led|hardware|shift-register|max7219|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17785" PostTypeId="2" ParentId="17784" CreationDate="2015-11-15T03:19:12.720" Score="0" Body="&lt;p&gt;If I understand Chinglish, you won't be able to drive it with the typical LED drivers... it give 350mA for &quot;Current&quot;.  That's 30-40 times the normal LED current, and would require special driver circuitry capable of 0.350A * 5 V = 1.75W per device, over 100W to activate all of them!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; it also says they cannot be continuously activated, which makes sense, given the small package and high power.  Leave 'em on long enough and they would probably burn your fingers.  :(&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-11-15T03:19:12.720" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17786" PostTypeId="1" AcceptedAnswerId="17790" CreationDate="2015-11-15T03:43:29.013" Score="3" ViewCount="36720" Body="&lt;p&gt;&lt;strong&gt;Convert text array/buffer to integer and string.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hi! i'm sending text to an arduino and the output of that library is a &#xA;uint8_t array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Atm the text send is a number between &quot;0&quot; and &quot;1023&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void something(uint8_t * text){&#xA; analogWrite(13,text);// does not work&#xA;}&#xA;/*&#xA;toInt() also not&#xA;int() not&#xA;atoi() not&#xA;invalid conversion from 'uint8_t* {aka unasigned char*}' to 'const char*'&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i need to convert it to an  integer or better to a uint16_t. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i plan to send custom commands in near future it would also be good to know how to convert that array to a string, that i then split/manipulate/parse.. whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i looked in various posts but i couldn't get it to work on that simple example above. i'm new to c++&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if it's needed the length is also aviable inside the function.&lt;/p&gt;&#xA;" OwnerUserId="11876" LastEditorUserId="11876" LastEditDate="2015-11-15T04:39:10.073" LastActivityDate="2016-07-18T21:49:51.363" Title="uint8_t * to integer and string" Tags="|programming|c++|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17787" PostTypeId="1" AcceptedAnswerId="17789" CreationDate="2015-11-15T05:28:32.613" Score="1" ViewCount="16116" Body="&lt;p&gt;I have two Arduino boards and two ESP8266 modules with the NodeMCU firmware, and I want to make this:&#xA;One Aruino will be connected to one module and a vibration sensor, and when this sensor detects some vibration, it will send some data using the ESP8266 module as a server, then, the other Arduino will recieve the data with the other ESP module and display a message to a LCD screen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already programmed the WiFi modules as a server and as a client using NodeMCU firmware and LuaUploader. The issue I have is that I don't know how to make a program in the Arduino IDE that communicate both Arduino boards using the ip adress assigned to both ESP modules, can you help me? Thanks&lt;/p&gt;&#xA;" OwnerUserId="14467" LastEditorUserId="6424" LastEditDate="2015-11-15T18:57:49.553" LastActivityDate="2015-11-17T21:53:33.287" Title="Communication via IP adress with Arduino IDE and ESP8266" Tags="|arduino-uno|esp8266|nodemcu|lua|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17788" PostTypeId="2" ParentId="17787" CreationDate="2015-11-15T07:31:49.980" Score="0" Body="&lt;p&gt;You have the esp8266 talking.  Now you need to come up with a method of passing data from the arduinos to the esp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use serial, you can use i2c, spi? Or something of your own design.  The problem wit using serial is the you are already using serial to communicate with the board from your PC.  You can use SoftSerial on the Arduino, but not sure how you'd do it on the ESP. &#xA;There are ways of making both boards work as master and slave i2c and spi, but it's probably overkill.&#xA;You could use two pins, one pin sends a binary bit and the other to clock the data, set high when new data has been written and set low when it has been read.&lt;br&gt;&#xA;Then just use the same sort of algorithm as you did between you eps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have assumed that one Arduino is connected to one esp.  Let the ESPs worry about ip addresses.  If you want the Arduino to specify the destination then use a simpler addressing system than IP and let the ESPs translate that.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2015-11-15T07:39:22.433" LastActivityDate="2015-11-15T07:39:22.433" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17789" PostTypeId="2" ParentId="17787" CreationDate="2015-11-15T09:00:08.547" Score="0" Body="&lt;p&gt;First, you need a SoftwareSerial interface, since the hardware serial is already used for debugging. To setup a SoftwareSerial this is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 6; // Wire this to Tx Pin of ESP8266&#xA;const byte txPin = 7; // Wire this to Rx Pin of ESP8266&#xA;&#xA;// We'll use a software serial interface to connect to ESP8266&#xA;SoftwareSerial ESP8266 (rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  ESP8266.begin(115200); // Change this to the baudrate used by ESP8266&#xA;  delay(1000); // Let the module self-initialize&#xA;}&#xA;&#xA;void loop() {&#xA;  while (ESP8266.available()){&#xA;     String inData = ESP8266.readStringUntil('\n');&#xA;     Serial.println(&quot;Got Data from ESP8266: &quot; + inData);&#xA;     // The rest of your code...&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To send data from ESP8266 back to Arduino try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart.setup(0, 115200, 8, 0, 1, 1 ) -- Change the baudrate to 115200&#xA;-- A simple http server&#xA;srv=net.createServer(net.TCP)&#xA;srv:listen(80,function(conn)&#xA;    conn:on(&quot;receive&quot;,function(conn,payload)&#xA;        payload = payload + &quot;\n&quot;&#xA;        uart.write(0, payload) -- send it back to Arduino via Serial interface&#xA;    end)&#xA;      conn:on(&quot;sent&quot;,function(conn) conn:close() end)&#xA;    end)&#xA;&#xA;uart.on(&quot;data&quot;, function(data) &#xA;    -- When ESP8266 receives data from Arduino, it will trigger this event&#xA;end, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-15T09:14:52.467" LastActivityDate="2015-11-15T09:14:52.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17790" PostTypeId="2" ParentId="17786" CreationDate="2015-11-15T11:36:29.230" Score="4" Body="&lt;p&gt;Your problem is that you are storing your text in an &lt;em&gt;unsigned&lt;/em&gt; pointer (&lt;code&gt;uint8_t *&lt;/code&gt;)instead of a &lt;em&gt;signed&lt;/em&gt; pointer (&lt;code&gt;char *&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change all your text types to &lt;code&gt;char *&lt;/code&gt; then you can directly use &lt;code&gt;atoi()&lt;/code&gt;.  If you have a lot to change, though, you can just &lt;em&gt;cast&lt;/em&gt; the unsigned pointer into a signed one (and make it &lt;code&gt;const&lt;/code&gt; at the same time):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWrite(13, atoi((const char *)text));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-15T11:36:29.230" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17791" PostTypeId="1" CreationDate="2015-11-15T13:25:20.497" Score="0" ViewCount="230" Body="&lt;p&gt;I'm an electronics noob. I have this string of LEDs but don't know how to connect them to my Arduino Uno. As they are wired in parallel, there are two wires / four ends. What do I plug where?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sx9SN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sx9SN.jpg&quot; alt=&quot;string of LEDS&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14840" LastActivityDate="2015-12-15T13:56:47.617" Title="How do I connect this string of LEDs to my Arduino Uno?" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17792" PostTypeId="2" ParentId="17786" CreationDate="2015-11-15T13:25:26.647" Score="0" Body="&lt;p&gt;analogWrite is a function to set a PWM duty cycle value to a pin on the micro&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually to control a motor speed or LED brightness or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you plan to use the char value to set the PWM value??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit more context would help with your problem.&lt;/p&gt;&#xA;" OwnerUserId="14649" LastActivityDate="2015-11-15T13:25:26.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17793" PostTypeId="2" ParentId="17791" CreationDate="2015-11-15T13:37:34.867" Score="1" Body="&lt;p&gt;Connect the negative ( or cathode ) to ground ( 0V )&#xA;and the postive ( anode ) to the output pin of the controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly connecting that many LEDS directly to a single micro pin is not a good idea. Usually you would need to go through a buffer/driver first which can deliver the correct power to the LEDS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not that familiar with the UNO but unless that board has a driver circuit on it you might need a few extra components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/13wme.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/13wme.png&quot; alt=&quot;Basic LED driver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the specs of the LEDS?&lt;/p&gt;&#xA;" OwnerUserId="14649" LastEditorUserId="14649" LastEditDate="2015-11-15T13:55:03.140" LastActivityDate="2015-11-15T13:55:03.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17795" PostTypeId="2" ParentId="17784" CreationDate="2015-11-15T14:10:33.010" Score="1" Body="&lt;p&gt;Yes the power requirements are a lot more than LEDs but theres a trick with solenoids which is each solenoid output would be PWM rather than DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could experiment with different frequencies/duties but I reckon start with a 100-200Hz pulse at around 25-50% duty. Can drop your power down by at least a 1/4 or less. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is obviously a bit more complex than a simple off or on. But solenoids have no problem with holding their magnetic field with a pulse and its recommended to avoid overheating the coil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: so there are 2 ways to approach it that I see. Either dedicate 1 pin on your micro for each solenoid which would go through a driver (with diode protection) and setup a PWM routine to pulse each output. or..&#xA;use a matrix approach with an oscillator on each solenoid. Meaning you would just switch the oscillator on and off&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first approach is more code intensive and would be limited by the micro.&#xA;The second is more hardware intensive limited by the components you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also to make sure they retract a short reverse polarity pulse would do that.&lt;/p&gt;&#xA;" OwnerUserId="14649" LastEditorUserId="14649" LastEditDate="2015-11-15T22:16:11.737" LastActivityDate="2015-11-15T22:16:11.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17796" PostTypeId="2" ParentId="17784" CreationDate="2015-11-15T14:57:39.027" Score="0" Body="&lt;p&gt;Looking at the description. They have a permanent magnet inside, so they are kind of &quot;latching&quot;. So using an H-bridge you can have them move outward or inward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem will be that a finger will be &lt;strong&gt;pushing&lt;/strong&gt; on the shaft. So unpowered, they will move when a finger goes over them. You would have to add some mechanism that moves another pin, and locks it in place. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-15T14:57:39.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17797" PostTypeId="1" AcceptedAnswerId="17799" CreationDate="2015-11-15T15:38:28.953" Score="1" ViewCount="155" Body="&lt;p&gt;I'm trying to better understand what is going on behind the Arduino IDE. First off I am no expert in C or writing firmware to boards but do have experience in real development.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see currently the Arduino IDE is one big vast library we first select our board.&#xA;What I don't understand is where are our header files? The source files for the board you select?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only that we use a number of functions already detected within the IDE where are these located also is any of this code editable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a look through the Arduino directory and most of this stuff looks like its Java I was hoping for C files. Thanks for any links, help or info anyone can give.&lt;/p&gt;&#xA;" OwnerUserId="14843" LastActivityDate="2015-11-15T16:39:41.257" Title="Arduino IDE, Underlying Code and Libraries" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17798" PostTypeId="1" CreationDate="2015-11-15T16:20:19.333" Score="4" ViewCount="586" Body="&lt;p&gt;Does anybody have some information or experiences with the flexibility of Spectra Symbol's &lt;a href=&quot;https://www.sparkfun.com/products/8681&quot; rel=&quot;nofollow&quot;&gt;SoftPot Membrane Potentiometer&lt;/a&gt; during the use? Is it possible to partly wind it up on a reel (or something similar) and use the remaining part dynamically without loosing precision and control? Are there &quot;ghost touches&quot; caused by the force/pressure of bending/winding the sensor strip? Or should the sensor always be used in a flattened position?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any helpful comments.&lt;/p&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2018-04-05T10:07:01.150" Title="Flexibility of SoftPot Membrane Potentiometer during the use?" Tags="|potentiometer|" AnswerCount="1" CommentCount="0" ClosedDate="2018-04-05T10:57:25.313" ContentLicense="CC BY-SA 3.0" />
  <row Id="17799" PostTypeId="2" ParentId="17797" CreationDate="2015-11-15T16:39:41.257" Score="0" Body="&lt;p&gt;Just check the &lt;a href=&quot;https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/cores/arduino&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt;. Specifically look at &lt;code&gt;Arduino.h&lt;/code&gt;, &lt;code&gt;main.cpp&lt;/code&gt; and &lt;code&gt;wiring*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These files should also be present in the Arduino application folder somewhere, but you'll have to go through quite a few subfolders to find them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The different boards have different .h file that will specify the pin-numbers and other chip specific data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;auto detect&quot; functionality is done by &lt;code&gt;keywords.txt&lt;/code&gt; files. At least for libraries. That way if you install a new library with keywords.txt file, the library functions-names are recognized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The processes of taking all these files, and the users code, and compile it all whole story on it's own.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-15T16:39:41.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17801" PostTypeId="2" ParentId="17782" CreationDate="2015-11-15T19:29:01.157" Score="1" Body="&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Use the code below as it is, it's working for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;int inPin = 22; &#xA;int inPin2 = 26;&#xA;int outPin1 = 13;    &#xA;int outPin2 = 6;&#xA;&#xA;int state1 = HIGH;&#xA;int state2 = HIGH;&#xA;int reading;     &#xA;int reading2;&#xA;int previous = HIGH; &#xA;int previous2 = HIGH;&#xA;&#xA;int debounce = 150;   // the debounce time, increase if the output flickers&#xA;&#xA;//===============================================================================================&#xA;void doIt(int outPin, int state)&#xA;{&#xA;  Serial.print(&quot;Button Switch State Change:&quot;);&#xA;  if (state == HIGH) state = LOW;&#xA;  else state = HIGH;&#xA;  Serial.println(state);&#xA;  lcd.clear();&#xA;&#xA;  if (outPin == outPin1) &#xA;    lcd.print(&quot;Zone1|State: &quot;);&#xA;  else if (outPin == outPin2)&#xA;    lcd.print(&quot;Zone2|State: &quot;);&#xA;&#xA;  lcd.print(state ? F(&quot;On&quot;) : F(&quot;Off&quot;));&#xA;  Serial.print(state ? F(&quot;On&quot;) : F(&quot;Off&quot;));&#xA;  digitalWrite(outPin, state);&#xA;}&#xA;//===============================================================================================&#xA;void setup()&#xA;{&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;System Activated&quot;);&#xA;  //&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;Ready...&quot;);&#xA;&#xA;  pinMode(inPin, INPUT);&#xA;  pinMode(outPin1, OUTPUT);&#xA;  pinMode(inPin2, INPUT);&#xA;  pinMode(outPin2, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;System Activated&quot;);&#xA;  Serial.println(&quot;Made by Mateo Holguin&quot;);&#xA;  Serial.println(&quot;0 = Light is Off | 1 = Light is On&quot;);&#xA;  Serial.println(&quot;=======================================&quot;);&#xA;}&#xA;&#xA;//===============================================================================================&#xA;&#xA;void loop()&#xA;{&#xA;  reading = digitalRead(inPin);&#xA;  reading2 = digitalRead(inPin2);&#xA;  delay(debounce);&#xA;&#xA;  if (reading == HIGH)&#xA;  {&#xA;    state1 = !state1;&#xA;    doIt(outPin1, state1);  &#xA;  }&#xA;  else if (reading2 == HIGH){&#xA;    state2 = !state2;&#xA;    doIt(outPin2, state2);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-15T22:26:27.880" LastActivityDate="2015-11-15T22:26:27.880" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="17802" PostTypeId="1" CreationDate="2015-11-15T19:58:28.227" Score="1" ViewCount="516" Body="&lt;p&gt;I have a complex sketch that I spent many weeks working on, which I am backing up frequently because I'm afraid of losing any of my progress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if it's common practice to make a self-contained package of the sketch and all its dependencies, so that it can be moved easily to another OS if necessary. My concern is that if my OS crashes and I have to reinstall everything or move to another OS, I might run into library and dependency errors, especially with the libraries that I altered/customized. I need my sketch to be able to compile as quickly as possible on whatever OS I end up using, since it's a home-automation sketch that controls dozens of things around me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a valid concern? And if so, what are some preferred ways to make a sketch become &quot;self-contained&quot;, so that everything necessary is included? Is there some kind of a better version-control system for Arduino sketches that an amateur programmer might not be aware of?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="4628" LastEditDate="2015-11-16T14:08:26.860" LastActivityDate="2015-11-16T14:08:26.860" Title="Is it possible to package a sketch with dependent libraries for cross-platform compatibility?" Tags="|arduino-ide|library|ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17803" PostTypeId="2" ParentId="17802" CreationDate="2015-11-15T20:23:55.790" Score="1" Body="&lt;p&gt;A way to do so is to include all the library files (*.cpp, *.h) in your sketch folder and then include them in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many solutions that you might find handy in this link: &lt;a href=&quot;https://arduino.stackexchange.com/questions/348/how-to-organize-my-arduino-projects-structure-for-easy-source-control&quot;&gt;How to organize my Arduino projects&amp;#39; structure for easy source control?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-11-15T20:23:55.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17804" PostTypeId="2" ParentId="17802" CreationDate="2015-11-15T21:16:20.750" Score="2" Body="&lt;p&gt;I would suggest switching to &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; instead of the Arduino IDE. (Yes, shameless plug, it's my IDE).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UECIDE has a facility that I dubbed &quot;localizing&quot; a library whereby it copies it into a libraries folder within the sketch folder itself, and that copy of the library is used in preference to any other library named the same in the system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that a sketch and its libraries then become completely self contained in one folder, and it's perfectly possible to have different versions of the same library in different sketches.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-15T21:16:20.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17805" PostTypeId="1" CreationDate="2015-11-15T23:05:56.957" Score="5" ViewCount="383" Body="&lt;p&gt;I have 9 pins that are inputs from 9 IR LEDs. I want to combine all their results into one 9 bit number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;example:&#xA;pin1 = high,&#xA;pin2 = high,&#xA;pin3 = high,&#xA;pin4 = low,&#xA;pin5 = high,&#xA;pin6 = low,&#xA;pin7 = low,&#xA;pin8 = high,&#xA;pin9 = low&lt;/p&gt;&#xA;&#xA;&lt;p&gt;9 bit number = 111010010&lt;/p&gt;&#xA;" OwnerUserId="14848" LastActivityDate="2015-11-16T14:08:32.173" Title="How do I create a 9 bit number based on values from 9 digital inputs?" Tags="|led|pins|input|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17806" PostTypeId="2" ParentId="17798" CreationDate="2015-11-15T23:34:20.783" Score="0" Body="&lt;p&gt;As you can see from this data sheet it will show you examples on how it is used. &lt;a href=&quot;https://www.sparkfun.com/datasheets/Sensors/Flex/SoftPot-Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Sensors/Flex/SoftPot-Datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd buy a curved one just to make sure, because as it bends, the 2 conductive materials will touch.&lt;/p&gt;&#xA;" OwnerUserId="14716" LastEditorUserId="14716" LastEditDate="2015-11-15T23:39:58.483" LastActivityDate="2015-11-15T23:39:58.483" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17807" PostTypeId="2" ParentId="17805" CreationDate="2015-11-16T00:26:25.837" Score="2" Body="&lt;p&gt;As @KiraSan said, You need something larger than a byte for 9 bits. However:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int tally;&#xA;tally=0;&#xA;for (char pin=1; pin&amp;lt;=9; pin++) {&#xA;    if (digitalRead(pin)==HIGH) {&#xA;        tally|=1&amp;lt;&amp;lt;(9-pin);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is done from memory and is untested, if anyone spots any errors, let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Explanation: tally is the sum (you should do something with this at the end, obviously, or it has no effect). It is defined and set to 0. Then, for each pin (1-9), read the pin; if the pin is high: take the number '1', and double it (9-pin) times; so if pin=9, it is doubled 0 times; for pin=2, it is doubled once (for a total of 2), and so forth. Set this bit on the tally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this reads digital pin 1 (which happens to be the second pin, the first being pin 0) - this should be marked as &quot;tx&quot; to set in the first bit, not the one referred to as &quot;pin1&quot; (which might be a constant or a variable, and therefore could point to any given pin). This method also assumes the pins are in order - you could easily change it to start from 0, or 7, but they have to be in order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want arbitrary pins, or variable pins, you might try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const PIN_COUNT=9;&#xA;char pins[PIN_COUNT]={13,2,5,4,3,6,7,8,9};&#xA;int tally;&#xA;&#xA;tally=0;&#xA;&#xA;for (char pin=0; pin&amp;lt;PIN_COUNT; pin++) {&#xA;    if (digitalRead(pins[pin])==HIGH) {&#xA;        tally|=1&amp;lt;&amp;lt;pin;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changes: add PIN_COUNT as a constant at the start, set the order of the pins (which can include any digital pins, including repeating a given pin if you feel so inclined, even after the start of the code.). You can also change them by doing: &lt;code&gt;pins[0]=1;&lt;/code&gt; - note that they are numbered from 0-8 for 9 pins. Since they now start at 0, the line with &amp;lt;&amp;lt; is now adjusted accordingly, as is the line that starts with &lt;code&gt;for...&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-11-16T01:00:57.367" LastActivityDate="2015-11-16T01:00:57.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17808" PostTypeId="2" ParentId="17805" CreationDate="2015-11-16T00:42:17.037" Score="6" Body="&lt;p&gt;In your code you would use a 16 bit unsigned integer as your variable. As there is no such thing as a 9 bit type. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pins correspond to different ports on your micro, you basically do this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the pin value from the port register, and bit shift to the right bit position then OR with the variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you had 8 of the LEDS on PORTB (pin 0 - 7 )and the 9th on PORTC (pin 2)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int ir_inputs = 0&#xA;&#xA;ir_inputs = PORTB; //just reads the register directly&#xA;ir_inputs = ir_inputs|((PORTC &amp;amp; 0x04)&amp;lt;&amp;lt;6); //reads the bit on pin 2 then shifts it 6 places to bit 8 (or the 9th bit remember bits always start at 0) and does not affect the other bits&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;something like that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;actually you could put it into a function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int getIRinputs(void){&#xA;    return (unsigned int)PORTB|((PORTC &amp;amp; 0x04)&amp;lt;&amp;lt;6);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Easy done&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you had the inputs on 9 separate ports the principle is the same.&#xA;Read, Shift, OR&lt;/p&gt;&#xA;" OwnerUserId="14649" LastEditorUserId="14649" LastEditDate="2015-11-16T12:04:42.503" LastActivityDate="2015-11-16T12:04:42.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17809" PostTypeId="2" ParentId="17805" CreationDate="2015-11-16T04:58:32.193" Score="3" Body="&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef union NUM_9_BITS_t {&#xA;    unsigned int U;&#xA;    struct NUM_9_BITS_FIELD {&#xA;        unsigned int BIT0 : 1;&#xA;        unsigned int BIT1 : 1;&#xA;        unsigned int BIT2 : 1;&#xA;        unsigned int BIT3 : 1;&#xA;        unsigned int BIT4 : 1;&#xA;        unsigned int BIT5 : 1;&#xA;        unsigned int BIT6 : 1;&#xA;        unsigned int BIT7 : 1;&#xA;        unsigned int BIT8 : 1;&#xA;        unsigned int BITO : 23;&#xA;    } BITS;&#xA;} NUM_9_BITS;&#xA;&#xA;NUM_9_BITS num;&#xA;&#xA;num.BITS.BIT0 = digitalRead(PIN0);&#xA;num.BITS.BIT1 = digitalRead(PIN1);&#xA;num.BITS.BIT2 = digitalRead(PIN2);&#xA;num.BITS.BIT3 = digitalRead(PIN3);&#xA;num.BITS.BIT4 = digitalRead(PIN4);&#xA;num.BITS.BIT5 = digitalRead(PIN5);&#xA;num.BITS.BIT6 = digitalRead(PIN6);&#xA;num.BITS.BIT7 = digitalRead(PIN7);&#xA;num.BITS.BIT8 = digitalRead(PIN8);&#xA;&#xA;Serial.print(num.U);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14850" LastEditorUserId="4628" LastEditDate="2015-11-16T14:08:32.173" LastActivityDate="2015-11-16T14:08:32.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17811" PostTypeId="1" CreationDate="2015-11-16T09:10:22.880" Score="7" ViewCount="15563" Body="&lt;p&gt;At the moment, I'm using various operating systems and devices like the Raspberry pi to control lights and other stuff over websockets. I use websockets since they added the support on Chrome. I write a lot of Javascript stuff for fun. Websockets allow you to communicate with another server without the need of reloading a page. It's a lot better than Ajax. Once the connection is open with a web server data can travel both ways. No unnecessary headers to send. No unnecessary requests. You just send only the data you want, this in both directions. AND FAST, DAMN FAST.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I use Javascript's &lt;code&gt;requestAnimationframe&lt;/code&gt; to send RGB values (based on music frequency) to lamps connected to the network. &lt;code&gt;requestAnimationframe&lt;/code&gt; executes approximately at 60 Hz. But that's not the highest speed, I also created some &quot;web controllers&quot; to &lt;a href=&quot;https://www.youtube.com/watch?v=ThLoN494XBc&quot; rel=&quot;noreferrer&quot;&gt;control servos&lt;/a&gt; and other stuff with touch and mouse events. In that case it probably touches transmission frequencies of 200-300 data packets (normally I use JSON- encoded strings) or more per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Websocket servers have also broadcast which allows you for example to control multiple RGB lamps based on the music you play from basically every modern device that has a browser. I don't use &quot;normal&quot; sockets because of the simple fact that there is no support for sockets in a standard web browser. So I would need to create a custom iOS app, custom Windows app, custom Android app. I said that we know that websockets are made for a fast multi-user / multi-device / bidirectional communication. And it should be really fast or it's useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lately I have a lot of fun with electronics and MCUs, so I made even more lamps and stuff controlled from Arduinos, ATtinys and other microcontrollers. I'm new to C++ but since I write Javascript code since the previous century I just have to slightly modify old Javascript functions to run in the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for sure I'm not ready to write a perfect library for an MCU, so I need to use what I find online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently there are not many people into websockets. I tested 2-3 Arduino websockets libraries and couldn't get them to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last one I tested(&lt;a href=&quot;https://github.com/Links2004/arduinoWebSockets&quot; rel=&quot;noreferrer&quot;&gt;Links2004&lt;/a&gt;) works but I can't send a 4 decimal string faster than 2 times per second or it crashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I did was to add this code for testing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void onWebsocketMessage(uint8_t * payload) {&#xA; analogWrite(13,atoi((const char *)payload));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;payload&lt;/code&gt; is the data received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems that could slow down/crash everything:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;My code. Does &lt;code&gt;atoi&lt;/code&gt; take too much to execute?&lt;/li&gt;&#xA;&lt;li&gt;My code. Is the &lt;code&gt;(const char *)&lt;/code&gt; cast filling memory?&lt;/li&gt;&#xA;&lt;li&gt;The lib itself?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I know that the CPU memory or whatever else is not the problem because of this video:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=8ISbmQTbjDI&quot; rel=&quot;noreferrer&quot;&gt;https://www.youtube.com/watch?v=8ISbmQTbjDI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He gets realtime stats from the controller at 200-600 Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it's supercool and I could just install that &quot;custom firmware&quot; I prefer to stay in the Arduino IDE for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix websockets on the ESP8266 device using Arduino IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe can I extract only the websocket part from that firmware (CNLohr's Video)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggest another lib?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I posted here because I use the Arduino IDE. And the ESP8266 has also been part of the Arduino world for a while. And maybe some not so popular Arduino-based websockets work also on the ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wouldn't it be nice to control your ws2812b strip with a web interface showing the preview like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://jsfiddle.net/dgws3usa/5/&quot; rel=&quot;noreferrer&quot;&gt;http://jsfiddle.net/dgws3usa/5/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;links2004 @ github&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The network should be fine. It's a relatively expensive Cisco/Linksys N router at 20cm/8inch away from the ESP8266 module.&lt;/li&gt;&#xA;&lt;li&gt;Luckily the module I'm using is one of the modules listed in the Arduino IDE, the &lt;a href=&quot;https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/#&quot; rel=&quot;noreferrer&quot;&gt;MOD-WIFI-ESP8266-DEV&lt;/a&gt;, but I have another one with fewer GPIOs.&lt;/li&gt;&#xA;&lt;li&gt;I just noticed now that I programmed it at 80 Mhz instead of 160 Mhz.&lt;/li&gt;&#xA;&lt;li&gt;The program I uploaded consists only of the basic websockets server example with in addition just the code posted above.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;atoi&lt;/code&gt; is the problem/is slow, what are other ways to convert the received array to a string?&lt;/li&gt;&#xA;&lt;li&gt;I use both the latest versions of the Arduino ESP8266 port and the arduinoWebSockets. At least I guess so. I followed the install instructions one day before I asked this question.&lt;/li&gt;&#xA;&lt;li&gt;By crash I mean, while moving the range slider, if updating in realtime with &lt;code&gt;addEventListener('input',function,false)&lt;/code&gt; at some point (after 1 sec/ 3-4 messages send/received) it stops sending or receiving data. By the way, the video you posted seems to work properly with a lot more code. Also that guy updates in realtime with &lt;code&gt;oninput&lt;/code&gt; vs 'onchange', which would only update when the user releases the slider.&lt;/li&gt;&#xA;&lt;li&gt;I think for now I can't use &lt;code&gt;Serial.setDebugOutput(true);&lt;/code&gt; as I didn't get the serial communication working. I'm using a cheap CH340G to program the chip.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Japanese post.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;9&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;I'm doing exatly the same thing but in a much simpler way. No web server, no ping pongs, no serial stuff, I don't use complex functions to elaborate the web server's data. Altough his example works.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;He is doing, code-wise, a lot more than I do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;for(i=0; i&amp;lt;4; i++) {&#xA;  mask[i] = client.read();&#xA;}&#xA;byte m_data[data_len];&#xA;char data_c[data_len];&#xA;Serial.print(&quot;Receive Data = &quot;);&#xA;for(i = 0; i1-0x30);&#xA;    break;&#xA;  case 3:&#xA;    data_b = ((data_c[0]-0x30)*100) + ((data_c&lt;a href=&quot;https://www.youtube.com/watch?v=ThLoN494XBc&quot; rel=&quot;noreferrer&quot;&gt;1&lt;/a&gt;-0x30)*10) + (data_c&lt;a href=&quot;https://github.com/Links2004/arduinoWebSockets&quot; rel=&quot;noreferrer&quot;&gt;2&lt;/a&gt;-0x30);&#xA;    break;&#xA;  }&#xA;  LED_PWM(data_b);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My full &quot;test&quot; code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;ESP8266WiFiMulti.h&amp;gt;&#xA;#include &amp;lt;WebSocketsServer.h&amp;gt;&#xA;#include &amp;lt;Hash.h&amp;gt;&#xA;ESP8266WiFiMulti WiFiMulti;&#xA;WebSocketsServer webSocket=WebSocketsServer(81);&#xA;void webSocketEvent(uint8_t num,WStype_t type,uint8_t * payload,size_t lenght) {&#xA;  switch(type) {&#xA;    case WStype_DISCONNECTED:&#xA;      break;&#xA;    case WStype_CONNECTED:&#xA;      {&#xA;      IPAddress ip=webSocket.remoteIP(num);&#xA;      }&#xA;      break;&#xA;    case WStype_TEXT:&#xA;      analogWrite(13,atoi((const char *)payload)); // MY CODE&#xA;      webSocket.broadcastTXT(payload,lenght);&#xA;      break;&#xA;    case WStype_BIN:&#xA;      hexdump(payload,lenght);&#xA;      webSocket.sendBIN(num,payload,lenght);&#xA;      break;&#xA;  }&#xA;}&#xA;void setup() {&#xA;  pinMode(13,OUTPUT); // MY CODE&#xA;  for(uint8_t t=4;t&amp;gt;0;t--) {&#xA;    delay(1000);&#xA;  }&#xA;  WiFiMulti.addAP(&quot;ssid&quot;,&quot;pass&quot;);&#xA;  while(WiFiMulti.run()!=WL_CONNECTED) {&#xA;    delay(100);&#xA;  }&#xA;  webSocket.begin();&#xA;  webSocket.onEvent(webSocketEvent);&#xA;}&#xA;void loop() {&#xA;  webSocket.loop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;11&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;I normally write Javascript code. Converting a string to a number or vice-versa is much simpler. &lt;code&gt;num=1; str=1+''; num=str*1;&lt;/code&gt; So all this binary array is relatively new for me.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Note that while I convert the binary array to an int now. In the future I need to convert that to a string which then will be parsed. Something like JSON. And so update more channels per message.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the client side, like I said, I'm sending the data really fast. So if there is no buffer on the server side that could be a problem. Solving that is simple: &lt;code&gt;requestanimationframe&lt;/code&gt;. Continuously check if the input changed. That allows you to send the data every 16-17ms. So 60 Hz. Not slower, Not faster. But again that should be the maximum pause between messages.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I said that I will reprogram it at 160 Mhz now and hope there are other ways to convert the received data faster and hope for updates relative to my code.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right. The serial works. Reprogrammed the ESP8266 At 160 Mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error I get when when I set &lt;code&gt;Serial.setDebugOutput(true);&lt;/code&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LmacRxBlk:1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need some other information just ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the late response.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;webSocket.broadcastTXT(payload,lenght);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Broadcasting seems to be the problem. I just have a few minutes so for now I can't do the describe debug stuff... But I will do as soon as I have a little more time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT4&lt;/strong&gt; for Aditya Tannu&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;NeoPixelBus.h&amp;gt;&#xA;#define pixelCount 16&#xA;NeoPixelBus strip = NeoPixelBus(pixelCount,13);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inside the webSocketEvent function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case WStype_TEXT:&#xA;for(uint8_t i=0;i&amp;lt;pixelCount;i++){&#xA; strip.SetPixelColor(&#xA;  i,&#xA;  RgbColor(i==(atoi((const char *)payload)%pixelCount)?255:0,0,0)&#xA;  // i need to put the above outside of the loop.&#xA;  // it does not work if i do so&#xA; );&#xA;}&#xA;strip.Show();&#xA;break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HTML JS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var ws,form;&#xA;function msg(a){&#xA;  console.log(a);&#xA;}&#xA;window.onload=function() {&#xA;  form=document.getElementById('form');// change&#xA;  ws=new WebSocket('ws://IPNUMBER:PORT');// change&#xA;  ws.onopen=function() {&#xA;    ws.send('0');&#xA;  };&#xA;  ws.onmessage=msg;&#xA;  form.addEventListener('input',function() {&#xA;    ws.send(this.firstChild.value) // firstchild is the range&#xA;  }, false);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://youtu.be/IbKtPX20kbY&quot; rel=&quot;noreferrer&quot;&gt;vid&lt;/a&gt;, I use a logic level converter from 3.3v to 5v: pca9306.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 5&lt;/strong&gt; for Links2004&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think I should rework the examples. It looks like most users don't&#xA;  understand it well.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nono. At some point you need to broadcast back the actual position anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry. I forgot to test the debug stuff again. But we know it's the broadcast. We just need to send back data only when there is not too much traffic.&lt;/p&gt;&#xA;" OwnerUserId="11876" LastEditorUserId="4628" LastEditDate="2015-12-09T20:37:59.747" LastActivityDate="2017-06-03T11:40:34.700" Title="ESP8266 &amp; websockets" Tags="|arduino-ide|library|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17814" PostTypeId="2" ParentId="17787" CreationDate="2015-11-16T10:39:56.407" Score="0" Body="&lt;p&gt;After reviewing your codes, I've rewritten them this way, I didn't get a chance to test them though, so try them and let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Server code: a. Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int ledPin = 13;&#xA;int txPin = 2;&#xA;int rxPin = 3;&#xA;&#xA;SoftwareSerial wifi(rxPin, txPin);&#xA;&#xA;void setup() {&#xA;    pinMode(ledPin, OUTPUT);&#xA;    Serial.begin(115200); // This baudrate is better than 9600&#xA;    wifi.begin(9600);&#xA;    wifi.println(&quot;dofile('wifiserv.lua')&quot;); // This where it goes&#xA;    digitalWrite(ledPin, LOW);&#xA;    delay(2000); // delay is necessary&#xA;}&#xA;&#xA;void loop() {&#xA;  while(wifi.available())&#xA;  {&#xA;     digitalWrite(ledPin, HIGH);&#xA;     String inData = wifi.readStringUntil('\n');&#xA;     if (inData.startsWith(&quot;Server IP: &quot;))&#xA;        Serial.println(inData); // This is just the Server IP address&#xA;     else&#xA;        Serial.println(&quot;Got new sensor value: &quot; + inData)&#xA;  }&#xA;  digitalWrite(ledPin, LOW); // This means no data is available&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Server code: b. ESP8266&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uart.setup(0, 9600, 8, 0, 1, 1 )&#xA;wifi.setmode(wifi.STATION)&#xA;wifi.sta.config(&quot;mynet&quot;,&quot;pass&quot;)&#xA;print(&quot;Server IP: &quot; .. wifi.sta.getip() .. &quot;\n&quot;)&#xA;&#xA;srv = net.createServer(net.TCP)&#xA;srv:listen(80,function(conn)&#xA;    conn:on(&quot;receive&quot;,function(conn, s)&#xA;        data = s:match(&quot;sensor=(%w+)&quot;)&#xA;        data = data + &quot;\n&quot;&#xA;        uart.write(0, data)&#xA;    end)&#xA;end)&#xA;&#xA;uart.on(&quot;data&quot;, function(cmd) &#xA;    -- When ESP8266 receives data from Arduino, it will trigger this event&#xA;end, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Client code: a. Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int ledPin = 13;    &#xA;int EP = 9;&#xA;int txPin = 2;&#xA;int rxPin = 3;&#xA;&#xA;int dato = 10;&#xA;&#xA;String ip; // Assign this to your server IP&#xA;&#xA;SoftwareSerial wifi(rxPin, txPin);&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledPin, OUTPUT);    &#xA;  pinMode(EP, INPUT);         &#xA;  Serial.begin(115200);&#xA;  wifi.begin(9600);   &#xA;  wifi.println(&quot;dofile('wificlie.lua')&quot;); // This where it goes&#xA;  delay(2000); // delay is necessary&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  long medida = TP_init();&#xA;  delay(50);                  &#xA;&#xA;  if(medida &amp;gt; 1000)&#xA;  {&#xA;    Serial.println(medida); &#xA;    digitalWrite(ledPin, HIGH);     &#xA;&#xA;    String cmd = &quot;ip=&quot; + ip + &quot; &quot; + &quot;data=&quot; + String(dato);&#xA;    Serial.println(&quot;Sending: &quot; + cmd);&#xA;    wifi.println(cmd);&#xA;  }&#xA;  else                       &#xA;  {&#xA;    digitalWrite(ledPin, LOW);      &#xA;  }&#xA;}&#xA;&#xA;long TP_init()                &#xA;{&#xA;  delay(10);                         &#xA;  long medida = pulseIn(EP, HIGH);   &#xA;  return medida;                     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Client code: b. ESP8266&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wifi.setmode(wifi.STATION)&#xA;wifi.sta.config(&quot;mynet&quot;,&quot;pass&quot;)&#xA;&#xA;uart.setup(0, 9600, 8, 0, 1, 1 )&#xA;uart.on(&quot;data&quot;, function(s) &#xA;    uart.write(0, &quot;GoSending!&quot;)&#xA;    ip = s:match(&quot;ip=(%d+.%d+.%d+.%d+)&quot;)&#xA;    data = s:match(&quot;data=(%w+)&quot;)&#xA;    conn = net.createConnection(net.TCP, 0)&#xA;    conn:on(&quot;connection&quot;, function(c)&#xA;        print(&quot;connected&quot;);&#xA;        conn:connect(80,ip)&#xA;        conn:send(&quot;sensor=&quot; .. data)&#xA;        uart.write(0, &quot;Data has been sent successfully&quot;)&#xA;    end)&#xA;end, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-11-17T21:53:33.287" LastActivityDate="2015-11-17T21:53:33.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17818" PostTypeId="1" CreationDate="2015-11-16T13:51:36.010" Score="0" ViewCount="233" Body="&lt;p&gt;A have Arduino Mega 2560. I found in the spec that the maximum output current for each I/O pin is 40 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can i use 40 IO in parallel? That's mean 40*40ma*5 volt = 8000 mw = 8 watt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What about the heat?!&lt;/p&gt;&#xA;" OwnerUserId="14864" LastEditorUserId="2881" LastEditDate="2015-11-16T16:06:24.917" LastActivityDate="2015-11-16T16:06:24.917" Title="Power maximum output power for each pin" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17819" PostTypeId="2" ParentId="17818" CreationDate="2015-11-16T14:06:01.060" Score="2" Body="&lt;p&gt;No, you can't.  Read the rest of the specifications and you'll see why.  Also the 40mA is wrong. That is the &lt;em&gt;absolute&lt;/em&gt; maximum. 20mA is the guaranteed limit for steady-state IO.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-16T14:06:01.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17820" PostTypeId="1" AcceptedAnswerId="17824" CreationDate="2015-11-16T15:10:12.860" Score="1" ViewCount="813" Body="&lt;p&gt;I am working on a library for some Arduinos that should talk between each other.&#xA;The aim is that I can load the same binaries onto each Arduino. The I2C ID will be set by DipSwitches.&#xA;So far everything works pretty nice but once a while everything gets stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not asking you to resolve and debug my code, but I am not sure if i have done something completely wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make all Arduinos interchangeable I have no Master (&lt;code&gt;Wire.begin()&lt;/code&gt;) in my I2C Bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read, that the Master would be responsible for the pulse on the Clock line. As I have no Master in my setup maybe that is the reason for the instability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone confirm that connecting some I2C Arduinos without master is something that cannot be done? (or do I have to look for some other reason)&lt;/p&gt;&#xA;" OwnerUserId="14865" LastEditorUserId="2881" LastEditDate="2015-11-16T16:07:48.107" LastActivityDate="2016-04-23T18:18:44.500" Title="I2C between Arduinos without Master" Tags="|i2c|communication|wire-library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17821" PostTypeId="2" ParentId="17818" CreationDate="2015-11-16T16:04:00.600" Score="4" Body="&lt;p&gt;There are also limits on the total power of groups of pins,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed&#xA;  200mA. &lt;/li&gt;&#xA;  &lt;li&gt;The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA. &lt;/li&gt;&#xA;  &lt;li&gt;The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA. &lt;/li&gt;&#xA;  &lt;li&gt;The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.&lt;/li&gt;&#xA;  &lt;li&gt;The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So you are already limited to 800mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, you have to be careful to change all the pins at exactly the same time. Otherwise some pins will be low, and others high creating effectively a dead short. Or if you make sure the pins are inputs before changing, some pins will be on sooner, and those pins will then for a short period, handle all the current, and thus exceeding their limit for a brief moment. Which isn't that bad, but still not ideal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So definitely don't use &lt;code&gt;digitalWrite&lt;/code&gt; to change all the pins, one after the other. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-16T16:04:00.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17822" PostTypeId="1" AcceptedAnswerId="17823" CreationDate="2015-11-16T16:26:34.367" Score="0" ViewCount="535" Body="&lt;p&gt;I'm analyzing the VirtualWire library and in it, the send messages are being sent with digitalWrite in the &quot;send&quot; method. However, there is a setup speed function. I'm reading that function and I see a lot of prescalers and TCCR variables. However, I'm not quite sure what these things do. Because, if it uses digitalWrite anyway to send the bits, then really is no intrabit delay, etc. Can someone please clarify this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if question is convoluted. Happy to do any clarification. Thank you for all guidance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Also, how do I transmit a block of message. Something greater than a byte? I'm trying to calculate BLER of messages and software serial only transmits 1 byte at a time. While virtualWire uses low-level error detection (and i want to avoid the use of any error detection/correction).&lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-11-16T17:42:01.400" LastActivityDate="2015-11-16T17:42:01.400" Title="How does the speed work in VirtualWire Library" Tags="|arduino-uno|serial|virtualwire|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17823" PostTypeId="2" ParentId="17822" CreationDate="2015-11-16T16:54:33.400" Score="1" Body="&lt;p&gt;I think that is used for receiving. By setting the speed, it knows how often it needs to read the input pin. It does this using timer interrupts, so it will run &quot;in the background&quot; without interfering with the main (loop) code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TCCR stuff is the set the interval for the timer interrupt.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-16T16:54:33.400" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17824" PostTypeId="2" ParentId="17820" CreationDate="2015-11-16T17:14:04.290" Score="3" Body="&lt;p&gt;You have to have a master for an I2C bus to work.  Can't you allocate one of the dip switches to define the master?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit to be able to remove the downvote &#xA;Nick his answer seems to imply that you do not need masters but that is wrong. &#xA;What Nick is saying is that you can swap masters over time.&lt;br&gt;&#xA;But each time there is communication there is a master.&lt;br&gt;&#xA;So the statement &quot;You have to have a master for an I2C bus to work&quot; is 100% right.&#xA;As I misunderstood this myself I downvoted this answer. I hope this edit will enable me to remove my downvote and add a upvote.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="18478" LastEditDate="2016-04-23T18:18:44.500" LastActivityDate="2016-04-23T18:18:44.500" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17825" PostTypeId="1" CreationDate="2015-11-16T16:24:23.940" Score="2" ViewCount="318" Body="&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EtherCard.h&amp;gt;&#xA;&#xA;static byte mymac[] = { 0x7A,0x69,0x69,0x2D,0x30,0x31 };&#xA;&#xA;byte Ethernet::buffer[500];&#xA;static uint32_t timer;&#xA;&#xA;const char website[] PROGMEM = &quot;x0201g2.cloudapp.net&quot;;&#xA;&#xA;static void my_callback (byte status, word off, word len) {&#xA;  delay(1000);&#xA;}&#xA;&#xA;void setup () {&#xA;&#xA;  Serial.begin(57600);&#xA;  ether.begin(sizeof Ethernet::buffer, mymac, 10);&#xA;&#xA;  ether.dhcpSetup();&#xA;&#xA;  ether.dnsLookup(website);&#xA;}&#xA;&#xA;void loop () {&#xA;&#xA;  ether.packetLoop(ether.packetReceive());&#xA;&#xA;  if (millis() &amp;gt; timer) {&#xA;    timer = millis() + 5000;&#xA;    ether.browseUrl(PSTR(&quot;/foo/&quot;), &quot;bar&quot;, website, my_callback);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way I tested this is I open up SSH terminal for &lt;code&gt;x0201g2.cloudapp.net&lt;/code&gt; to monitor any incoming traffic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The result is that it works fine, when I have the &quot;serial monitor&quot; (in Arduino IDE) open. I would see that there's a consistent stream of &lt;code&gt;GET&lt;/code&gt; requests. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I do not have the serial monitor open nothing ever happen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially I had some &lt;code&gt;Serial&lt;/code&gt; println to show response status and IP address, so I thought it might be related to the fact that the MCU's serial  controller is waiting for a handshake or some sort of ACK/NACK to happen...if that make sense. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that was not the case now because even after I have removed all serial print statements it is behaving in exactly the same way (except that my monitor will show up blank, but I still need to bring it up for it to work). &lt;/p&gt;&#xA;" OwnerUserId="14878" OwnerDisplayName="40Plot" LastEditorUserId="37523" LastEditDate="2019-07-27T18:07:05.630" LastActivityDate="2019-07-27T18:07:05.630" Title="Arduino nano (clone) with ethernet shield only works when I open up serial monitor" Tags="|serial|arduino-nano|ethernet|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 4.0" />
  <row Id="17826" PostTypeId="1" CreationDate="2015-11-16T19:39:49.043" Score="2" ViewCount="3163" Body="&lt;p&gt;I am developing a device with Ethernet shield (with Wiznet W5100) and NRF24L01+. I need to use Soft SPI due to a bug in the Wiznet chip. Next I am developing a different device with NRF24L01+ only. I want to use hardware SPI (besides other things it already contains a socket for NRF24L01+ connected to the default Arduino SPI pins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is very inconvenient to enable/disable &lt;code&gt;#define SOFTSPI&lt;/code&gt; in &lt;code&gt;RF24_config.h&lt;/code&gt; every time I want to work on the other device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way how to choose the SPI type used by RF24 library in the application? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution is to make a copy of RF24 to RF24_SoftSpi and RF24Network to RF24Network_SoftSpi. I enabled SOFTSPI in “_SoftSpi” versions (+ renamed all files, fixed includes and #ifndef statements in headers to avoid ambiguous errors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in an application I just include RF24_SoftSpi instead of RF24 and RF24Network_SoftSpi instead of RF24Network to use software SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this workaround it is difficult to make updates to “_SoftSpi” libraries when a new feature is released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of any better solution?&lt;/p&gt;&#xA;" OwnerUserId="9866" LastEditorUserId="4628" LastEditDate="2017-02-04T07:08:50.413" LastActivityDate="2017-09-02T20:30:04.857" Title="How to choose SPI type used by RF24 library from application?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17827" PostTypeId="1" CreationDate="2015-11-16T20:02:30.977" Score="16" ViewCount="179045" Body="&lt;p&gt;Whenever I try to program my Arduino UNO Rev.3, I'm seeing the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I plug this in, I do see a power light. There are no cables whatsoever connected other than the USB. I have another Arduino UNO which works fine when I upload the sketch (I'm using the basic blink sketch). How do I resolve this? What kind of problem can it be?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="13972" LastEditDate="2015-11-16T20:48:18.903" LastActivityDate="2020-09-18T16:49:33.887" Title="How do I resolve &quot;avrdude: stk500_recv(): programmer is not responding&quot;?" Tags="|arduino-uno|debugging|" AnswerCount="6" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17828" PostTypeId="1" CreationDate="2015-11-16T21:29:17.217" Score="4" ViewCount="11056" Body="&lt;p&gt;I've bought this microSD reader/writer: &lt;a href=&quot;http://www.ebay.com/itm/131132034753&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/131132034753&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found only one tutorial, where the pins are similar to my pins, but in the example there is a CLK instead of SCK: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/microsd-shield-and-sd-breakout-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/microsd-shield-and-sd-breakout-hookup-guide&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins on my MicroSD reader are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CS&lt;/li&gt;&#xA;&lt;li&gt;SCK&lt;/li&gt;&#xA;&lt;li&gt;MOSI&lt;/li&gt;&#xA;&lt;li&gt;MISO&lt;/li&gt;&#xA;&lt;li&gt;VCC&lt;/li&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13439" LastActivityDate="2017-12-19T23:50:39.123" Title="How to use a microSD card reader with SCK instead of CLK?" Tags="|sd-card|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17829" PostTypeId="2" ParentId="17828" CreationDate="2015-11-16T22:47:54.597" Score="11" Body="&lt;p&gt;SCK stands for &lt;strong&gt;S&lt;/strong&gt;PI &lt;strong&gt;C&lt;/strong&gt;loc&lt;strong&gt;K&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CLK stands for SPI &lt;strong&gt;CL&lt;/strong&gt;oc&lt;strong&gt;K&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two different acronyms for the same thing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-16T22:47:54.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17830" PostTypeId="1" CreationDate="2015-11-16T23:51:11.510" Score="0" ViewCount="215" Body="&lt;p&gt;So I am trying to make a Mac OSX program with Cocoa that will be able to control my Arduino via serial. I currently have the C command &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;popen(&quot;echo 7 &amp;gt; /dev/cu.usbmodem1411&quot;, &quot;r&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to try to send the number 7 over serial to the Arduino. I know that the path     /dev/cu.usbmodem1411 is correct because the Arduino is responding, however it seems to &quot;crash&quot; or simply restart whenever this command is received from the Mac. Sorry this may be a question for StackOverflow, but I thought I would start here.&lt;/p&gt;&#xA;" OwnerUserId="10585" LastActivityDate="2015-12-19T12:25:09.587" Title="Popen command restarts arduino" Tags="|serial|c|mac-os|" AnswerCount="1" CommentCount="6" ClosedDate="2016-01-11T09:33:12.380" ContentLicense="CC BY-SA 3.0" />
  <row Id="17831" PostTypeId="1" CreationDate="2015-11-17T00:46:15.020" Score="1" ViewCount="574" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6g0Og.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6g0Og.png&quot; alt=&quot;datasheet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hi. i don't know how can i connect Mics-5132 CO Sensor to my arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;plz help &lt;/p&gt;&#xA;" OwnerUserId="14875" LastEditorUserId="6945" LastEditDate="2015-11-19T17:07:31.620" LastActivityDate="2016-06-17T04:29:09.247" Title="How can i connect the Mics-5132 to Arduino Uno (Carbon Monoxide Sensor)" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17832" PostTypeId="1" CreationDate="2015-11-17T00:52:57.097" Score="1" ViewCount="134" Body="&lt;p&gt;I'd like to preface this by saying I'm a complete beginner, but I have learned a ton already on this project, and I feel like I'm almost there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Uno and an Adafruit motor shield. I am working on a project for mechanical engineering and I need lots of amps for lots of torque for my mechanism. I'm including my code although I know it doesn't work, I haven't had the chance to debug it yet, and I'm really not sure if I'm on the right track. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I know that it's possible to draw more amperage than is strictly allowed from the Arduino. What I don't know for sure is how to code it. Attached is my preliminary attempt.. I kind of assumed that the maximum speed would be the maximum allowable speed of the motor, regardless of the Arduino's capabilities, and scaled the output &lt;code&gt;MAXampDrawSpeed&lt;/code&gt; as a function of that. To be specific, my motor can draw up to 20 amps, which would be too much for the Arduino to handle, so I scaled it down accordingly, with 255 being that maximum 20 amp output. I'm not sure if I'm on the right track there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the other problem is - the TA for my class made a simplified code reference file, sort of predefining a lot of the things that I manually defined in my code (or tried to at least). I didn't realize this, and when I asked him a question, he sort of shot me down and said &quot;you should use my reference code&quot; -- but his code doesn't compile for me. I had some problems with libraries (I fixed them!), but this isn't a library. It's a reference file, like the tabs up at the top. But it won't even compile for me. My feeling is that I may have annoyed him with my many many stupid questions up until this point and he's just kind of like &quot;girl, get it together&quot;... So the question there is -- am I almost there with my track or should I figure out what's wrong with his code and try to fix it his way so that I can ask him questions without being such a bother to him? And also is that likely to be a hindrance on drawing the extra amperage that I really really want? I am prepared to use heat dissipation methods as are necessary, and any advice you could give me there would also be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need any more information, about my mechanism or anything I'd be glad to share that as well. I'm parallel mounting one motor to the four dc motor mounts on my Arduino in order to draw maximum current in that way as well. I have two switches controlling the output, one of the switches will engage the program for the maximum distance competition and the other for the accuracy competition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So again, this code isn't right. I haven't even started on debugging it, because I didn't want to waste my time. Maybe you'll be able to follow my logic. I know there aren't many notes. If you need me to add notes for clarity I would also be glad to take the time to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Stepper.h&amp;gt;&#xA;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;#define STEP_TYPE_1   SINGLE&#xA;#define STEP_TYPE_2    SINGLE&#xA;#define STEPS_1    200&#xA;#define STEPS_2    200&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;Adafruit_DCMotor *DC1 = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *DC2 = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *DC3 = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *DC4 = AFMS.getMotor(4);&#xA;Servo Servo1;&#xA;&#xA;void setup() {&#xA;  digitalWrite(A0, HIGH); //Turns on the pullup resistor for A0&#xA;  int i = analogRead(A0); //Reads the value on the analog pin and saves     this as variable &quot;i&quot;&#xA;  AFMS.begin(); //Initializes the motorshield board&#xA;  int motorPin1 = 1;&#xA;  int motorPin2 = 2;&#xA;  int motorPin3 = 3;&#xA;&#xA;  pinMode(A0, INPUT); //Sets the Analog Pin 0 as an input&#xA;  digitalWrite(A0,HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  digitalWrite(A1,HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  pinMode(1, OUTPUT);&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  Servo1.attach(9);&#xA;}&#xA;&#xA;void loop()  { &#xA;  int distancepin = 0; //Just integer quantities, i like to have too     many of them &#xA;  int accuracypin = 0;&#xA;  int inPin1 = 0; //switch pin values&#xA;  int inPin2 = 0; &#xA;  int MAXampDrawTime = 75;&#xA;  int MAXampDrawSpeed = 178;&#xA;  int NORMampDrawTime = 225;&#xA;  int NORMampDrawSpeed = 61.2;&#xA;  int DrawTime = MAXampDrawTime+NORMampDrawTime;&#xA;  int ServoTime = 450;&#xA;  long previousMillis =0;&#xA;  long intervalMAXamps = 100;&#xA;  long intervalNORMamps = 400;&#xA;  DC1-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC2-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC3-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC4-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  inPin1 = digitalRead(A0);&#xA;  inPin2 = digitalRead(A1);&#xA;  if (inPin1 == HIGH){&#xA;    unsigned long time_zero = millis();&#xA;    unsigned long current_time = millis();&#xA;    digitalWrite(1,HIGH); //turn motor on to maximum draw amperage&#xA;    digitalWrite(2,HIGH);&#xA;    digitalWrite(3,HIGH);&#xA;    digitalWrite(4,HIGH);&#xA;    while((millis()-time_zero)&amp;lt;(400000)){&#xA;      if( millis() &amp;gt;= (time_zero+NORMampDrawTime)){&#xA;      DC1-&amp;gt;setSpeed(NORMampDrawSpeed); //set motor on to normal draw     amperage&#xA;      DC2-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;      DC3-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;      DC4-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;      digitalWrite(1,HIGH); //turn motor on to normal draw amperage  &#xA;      digitalWrite(2,HIGH);&#xA;      digitalWrite(3,HIGH);&#xA;      digitalWrite(4,HIGH);&#xA;    }&#xA;    if ( millis() &amp;gt;= (time_zero+DrawTime)); {&#xA;      digitalWrite(1,0); //turn off motors&#xA;      digitalWrite(2,0);&#xA;      digitalWrite(3,0);&#xA;      digitalWrite(4,0);&#xA;    }&#xA;    if (millis() &amp;gt;= (time_zero+ServoTime));{&#xA;      Servo1.write(0);&#xA;      delay(400);&#xA;      Servo1.write(90);&#xA;    }&#xA;  }&#xA;}&#xA;if (inPin2 = HIGH);{&#xA;  int MAXampDrawTime = 75;&#xA;  int MAXampDrawSpeed = 59;&#xA;  int NORMampDrawTime = 225;&#xA;  int NORMampDrawSpeed = 20;&#xA;  int DrawTime = MAXampDrawTime+NORMampDrawTime;&#xA;  int ServoTime = 250;&#xA;  unsigned long previousMillis =0;&#xA;  unsigned long intervalHIamps = 100;&#xA;  unsigned long intervalNORMALamps = 400;&#xA;  DC1-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC2-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC3-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;  DC4-&amp;gt;setSpeed(MAXampDrawSpeed);&#xA;&#xA;  unsigned long time_zero = millis();&#xA;  unsigned long current_time = millis();&#xA;  digitalWrite(1,HIGH);&#xA;  digitalWrite(2,HIGH);&#xA;  digitalWrite(3,HIGH);&#xA;  digitalWrite(4,HIGH);&#xA;  while((millis()-time_zero)&amp;lt;(500)){&#xA;  if( millis() &amp;gt;= (time_zero+MAXampDrawTime)){&#xA;    DC1-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;    DC2-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;    DC3-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;    DC4-&amp;gt;setSpeed(NORMampDrawSpeed);&#xA;    digitalWrite(1,HIGH);&#xA;    digitalWrite(2,HIGH);&#xA;    digitalWrite(3,HIGH);&#xA;    digitalWrite(4,HIGH);&#xA;  } else( millis() &amp;gt;= (time_zero+DrawTime)); {&#xA;    digitalWrite(1,0);&#xA;    digitalWrite(2,0);&#xA;    digitalWrite(3,0);&#xA;    digitalWrite(4,0);&#xA;  }&#xA;  if (millis() &amp;gt;= (time_zero+ServoTime));{&#xA;    int  time_check = millis();&#xA;    while (millis() - time_check &amp;lt; 400000) {&#xA;      inPin1 = digitalRead(A0);&#xA;      if (inPin1 == HIGH ) {&#xA;        Servo1.write(0);&#xA;        delay(400);&#xA;        Servo1.write(90);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14872" LastEditorUserId="3917" LastEditDate="2015-11-19T08:37:06.033" LastActivityDate="2015-11-19T14:50:35.903" Title="Drawing amperage with Arduino code" Tags="|arduino-uno|adafruit|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17833" PostTypeId="1" AcceptedAnswerId="17838" CreationDate="2015-11-17T01:39:09.797" Score="1" ViewCount="129" Body="&lt;p&gt;I have several projects that use simple 328 based arduinos that I built myself, similar to the familiar &quot;arduino on a breadboard&quot; projects that I'm sure everybody has seen. They have just the bare minimum, no ftdi, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to drop in the 32U4 without modifying the circuits, or would I have to do a bunch of work to the circuits to get them to work with the 32U4 chips, and if so what are the general steps?&lt;/p&gt;&#xA;" OwnerUserId="14877" LastActivityDate="2015-11-17T06:37:52.103" Title="is it possible to convert a 328 design to use a 32U4?" Tags="|atmega328|atmega32u4|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17834" PostTypeId="2" ParentId="17832" CreationDate="2015-11-17T03:46:10.597" Score="1" Body="&lt;p&gt;Firstly your formatting is horrible, but that's probably just the this editor, if it isn't please fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In loop() you are wasting time if you are re declaring constants, move them outside the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why have you got 4 on switches?  Could you not gang them altogether? Join the wires and use just one pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you are repeating blocks of code, break these out into functions, this means less code to debug. I.e. SetMotorSpeed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If (inPin2 = HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will always be true, because an assignment is C\C++ always returns true, you meant ==&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You TA is being paid to help you, don't be afraid to p##s them off, it's there job to get p'd off at students, and their choice.  At least you are doing it by asking questions not d##king around.  That said the most likely cause of you problems with his example is missing libraries or IDE version differences.  Or even library versions, if you add the first 5 errors as a comment I might be able to point you in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-11-17T03:46:10.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17835" PostTypeId="1" AcceptedAnswerId="17839" CreationDate="2015-11-17T04:50:34.730" Score="6" ViewCount="4157" Body="&lt;p&gt;You can buy Arduino Nano v3 clones from Alibaba at the cost of roughly $2-$3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have calculated the cost for fabricating and all the parts in the BOM for Arduino Nano V3, and it ended up costing around $10 to $12 (depending on where you fabricate the board, buy the components and purchasing volume - assuming less than 100 units). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, how are Chinese clone manufacturers able to slash the price so much it's only ~1/10 of the BOM cost. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could it purely be due to economy of scale, lower fixed costs (cheap labor), low quality parts &lt;em&gt;(How do you define &lt;strong&gt;low quality parts&lt;/strong&gt;)&lt;/em&gt;? Or are there other factors at play as well?&lt;/p&gt;&#xA;" OwnerUserId="14878" LastEditorUserId="4628" LastEditDate="2015-11-17T18:54:26.083" LastActivityDate="2015-11-17T18:54:26.083" Title="Why are Arduino clones cheap?" Tags="|arduino-nano|clones|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17838" PostTypeId="2" ParentId="17833" CreationDate="2015-11-17T06:37:52.103" Score="4" Body="&lt;p&gt;Just had a quick look at the datasheets, and the main difference I see physically is the 32u4 is 44 pin package and the 328 is either 32 or 28 pin.&#xA;Also the 32U4 seems to have a lot more peripherals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So based on that yes you will have to modify your circuit. Atmel are fairly consistant with ports and what their alternate functions are though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg SPI on portB, uart on portD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you are just going to have to compare the pinouts on the datasheets see how they differ. And adjust pin connections accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Datasheets are easy to find. Good Luck!&lt;/p&gt;&#xA;" OwnerUserId="14649" LastActivityDate="2015-11-17T06:37:52.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17839" PostTypeId="2" ParentId="17835" CreationDate="2015-11-17T08:12:14.490" Score="4" Body="&lt;p&gt;All the factors mentioned in the question apply to make the cost so low.  However, with an exception or two as noted in the next paragraph, “low quality parts” is not much of a factor, as explained in two paragraphs after that.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible low quality parts include the USB mini-B socket, crystals or resonators, and the reset switch.  The socket and switch contain metal shapes that can be well made or badly (and more cheaply) made.  Those badly made will function but may have shorter lives and higher failure rates.  For example, the USB cable fit may be loose, or the switch may fall apart.  Crystal or resonator accuracy and stability can be poor while still allowing a Nano clone to appear to function ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;a href=&quot;https://en.wikipedia.org/wiki/Surface-mount_technology&quot; rel=&quot;nofollow&quot;&gt;SMT (surface mount technology)&lt;/a&gt; or SMD (surface mount device) parts on the board cannot be made significantly more cheaply than can good parts.  SMD LEDs, resistors, diodes, voltage regulators, and capacitors come off of automated assembly lines with little or no manual intervention.  See, eg, &lt;a href=&quot;https://en.wikipedia.org/wiki/Ceramic_capacitor#Multi-layer_ceramic_capacitors_.28MLCC.29&quot; rel=&quot;nofollow&quot;&gt;ceramic capacitor manufacturing&lt;/a&gt; at wikipedia.  Parts are automatically packaged into sealed reels of parts suitable for use on an automatic pick-and-place machine that populates PCBs.  In short, the dozen 0603-size SMD LEDs, resistors, and caps, and the nine other passive or small-scale-integration SMD parts on the board will cost about the same coming off a bad manufacturing line as from a good line, so there is little profit to be made producing bad parts.  The 20-odd passive parts probably cost a couple of cents, at manufacturing scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Active SMD parts like voltage regulators, the ATmega328P, and the 32U4 or CH340, likewise come off automated manufacturing lines.  As these parts are more expensive, there is more economic incentive for cheating, and from time to time fake parts get sold and used.  In the past (and perhaps still) there have been manufactories that specialize in removing labeling on the tops of cheap or non-functional chips, and putting accurately detailed fake labels for expensive chips on instead. (&lt;a href=&quot;https://www.sparkfun.com/news/395&quot; rel=&quot;nofollow&quot;&gt;For example,&lt;/a&gt; NCP5318 buck regulators relabeled as ATmega328s.)  In short, most of the active SMD parts on a Nano either are genuine and work or obvious fakes that don't work and earn their sellers bad reputations or jail.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CH340g USB-to-serial chip  vs. ATmega32U4 USB issue is more complicated.  Ie, some may think of the CH340 as a lower quality part than a 32U4.  The CH340 may need a different USB driver than the 32U4 and may not support 57600 BPS serial in some cases. &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;http://www.arduinodroid.info/2015/07/ch340g-support.html&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt;.  The ATmega32U4 seems to be available on Alibaba for $0.10 to $.20 in moderate quantities.  I think the CH340g is made only in China and is somewhat cheaper than the ATmega32U4, so its contribution to the BOM total cost may be a few cents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PCB probably costs 5 to 10 cents, and assembly is free except for amortized costs of pick and place machines and an IR reflow system with a conveyor.  Boards probably are processed (components placed and soldered automatically) in panels of several dozen units, tested automatically, and then separated for packaging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary: Inexpensive parts and automated processing hold down the per-board costs, moreso than cutting corners on component quality.  Corners may get cut on assembly quality and on quality assurance inspections.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-17T08:12:14.490" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17842" PostTypeId="2" ParentId="17832" CreationDate="2015-11-17T11:20:05.887" Score="0" Body="&lt;p&gt;I'm going to echo what Matt said but you have way too many constants declared like variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A constant in C should be done like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MYCONSTANT 666&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;right at the top of your code and outside of any setup loop or main function&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also think about the integer types you are using remember that Arduinos are 8 bit processors only use longs (32bit) where you really really have too and especially do not declare a constant as a long or int the way you have inside your loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int NORMampDrawSpeed = 61.2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is just wrong you are saying that an int is a float, which it cannot be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally avoid using floats altogether in Arduinos but if you must then declare it as a float or a constant (if it is a constant)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float NORMampDrawSpeed = 61.2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NORMampDrawSpeed 61.2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;be very careful when doing arithmetic with floats and ints because it will always return a float unless specifically typecast&lt;/p&gt;&#xA;&#xA;&lt;p&gt;better still since your new to programming just don't use them&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes as Matt said write your own functions for stuff you need to do a lot such as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setMotors( byte on_off ){&#xA;    for( uint8_t i=1; i &amp;lt;= 4; i++){&#xA;        digitalWrite(i,on_off);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;declare this function above the setup function an use it to turn all your motors on or off (1 or 0) like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setMotors(1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14649" LastActivityDate="2015-11-17T11:20:05.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17847" PostTypeId="2" ParentId="233" CreationDate="2015-11-17T18:06:46.237" Score="2" Body="&lt;p&gt;I believe the library linked by Cybergibbons has a bug in &lt;/p&gt;&#xA;&#xA;&lt;p&gt;uint8_t OneWire::wireSearch(uint8_t *address)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A discrepancy at i = 0 (bit zero in this library, id_bit_number = 1 in a Maxim example) only follows the direction = 1 path and fails to find ROM addresses where bit zero = 0 (i.e. even family codes are missed when mixed devices, some with even and others with odd family codes, are present on the 1-wire bus).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fix I have just implemented and appears to work is to modify the library to declare searchLastDiscrepancy and last_zero as int8_t (not uint8_t), initialise/reset them to -1 (not zero) and, near the end of the method&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (!last_zero) &#xA;            searchLastDeviceFlag = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (last_zero == -1)&#xA;            searchLastDeviceFlag = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="14887" LastActivityDate="2015-11-17T18:06:46.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17848" PostTypeId="1" CreationDate="2015-11-17T15:17:38.013" Score="1" ViewCount="1469" Body="&lt;p&gt;I want to build a function generator but not the ones which outputs square wave or sawtooth ect. I will input a discrete function lets say f(n) = e^n for n=0 to n=100 and the output array will be outputs as voltage samples creating a e^x like signal on a scope?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="4557" OwnerDisplayName="user16307" LastEditorUserId="13669" LastEditDate="2015-11-19T17:07:46.527" LastActivityDate="2015-11-19T17:07:46.527" Title="Is it possible to make a mathematical function generator using Arduino?" Tags="|analogwrite|digital-analog-conversion|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17849" PostTypeId="2" ParentId="17848" CreationDate="2015-11-17T15:26:47.577" Score="3" Body="&lt;p&gt;You can generate arbitrary waveforms using either the built-in PWM and a low-pass filter or an external DAC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't get more than 16-bits in PWM ( or AFAIK non-audio DAC with arduino libraries ), so your e^N function will be below your resolution for most of the cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, generate a saw-tooth and use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Operational_amplifier_applications#Exponential_output&quot; rel=&quot;nofollow&quot;&gt;op-amp exponential function&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="798" OwnerDisplayName="Pete Kirkham" LastActivityDate="2015-11-17T15:33:16.777" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="17850" PostTypeId="2" ParentId="17848" CreationDate="2015-11-17T18:32:30.353" Score="3" Body="&lt;p&gt;Arduino DUE has a built-in DAC (has two in fact) and so you can do arbitrary function generation fairly easily by just going over some arbitrary table (that sampled the function) and output that with &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;analogWrite&lt;/code&gt;&lt;/a&gt; to the DAC channel[s]; details in &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DueSimpleWaveformGenerator&quot; rel=&quot;nofollow&quot;&gt;this arduino.cc tutorial&lt;/a&gt;. They only show sine/triangle/square waves there, but if you look at Waveforms.h at the end of that tutorial you can put arbitrary shapes in there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way this technique of waveform generation of using a lookup table and a DAC is abbreviated DDS for &lt;a href=&quot;https://en.wikipedia.org/wiki/Direct_digital_synthesizer&quot; rel=&quot;nofollow&quot;&gt;Direct Digital Synthesizer&lt;/a&gt;.&#xA;Here's a more conceptual tutorial on DDS (not involving arduino):&#xA;&lt;a href=&quot;http://www.ni.com/white-paper/5516/en/&quot; rel=&quot;nofollow&quot;&gt;http://www.ni.com/white-paper/5516/en/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DACs built-in Arduino DUE have 12-bit resolution by the way, i.e. 4096 discrete output levels. IF you need better than that, an external DAC is required, which you could connect by TWI/SPI etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get a poor man's DAC on the Arduino UNO or Leonardo by PWMing with &lt;code&gt;analogWrite&lt;/code&gt; on the GPIO pins (as suggested in the other answer), but you need &lt;a href=&quot;http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/&quot; rel=&quot;nofollow&quot;&gt;understand low pass filter fundamentals&lt;/a&gt; to get that done.&lt;/p&gt;&#xA;" OwnerUserId="13669" LastEditorUserId="13669" LastEditDate="2015-11-17T18:54:05.777" LastActivityDate="2015-11-17T18:54:05.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17851" PostTypeId="1" CreationDate="2015-11-17T20:39:36.240" Score="2" ViewCount="157" Body="&lt;p&gt;I'm trying to send a signal from Raspberry Pi GPIO to Arduino. I made a sketch that basically reads the state of the digital read, but the reading are very unstable. I understand that there is a floated voltage and the obvious solution is to configure the pullup resistor and connect the input to ground, but my goal is to read the incoming signal.&#xA;I'm using Arduino Mega 2560 and Raspberry Pi 2B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this info is enough!&lt;/p&gt;&#xA;" OwnerUserId="14894" LastActivityDate="2016-04-29T07:23:20.637" Title="Unstable reading from Raspberry Pi" Tags="|arduino-mega|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="17853" PostTypeId="1" AcceptedAnswerId="17978" CreationDate="2015-11-17T21:48:24.217" Score="0" ViewCount="641" Body="&lt;p&gt;&lt;strong&gt;Please help&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created an Arduino program that will switch the pins when I send a char. It works fine with serial monitor, but the problems come when I send chars with Eclipse using RXTX serial communication. When I click the button to send the char, at first click it does not switch the Arduino pins; it just senses the Rx and Tx LED but the second time it switches on. But when I tried to switch the second LED it first turns off the first LED although that was not my aim, and then it switches the intended LED. Here is my Arduino code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int lamp=2;&#xA;const int fan=3;&#xA;const int pump=4;&#xA;const int fridge=5;&#xA;char val;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(lamp,OUTPUT);&#xA;  pinMode(fan,OUTPUT);&#xA;  pinMode(pump,OUTPUT);&#xA;  pinMode(fridge,OUTPUT);&#xA;}&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if(Serial.available()) {&#xA;    val=Serial.read();&#xA;    if(val=='a') {&#xA;      digitalWrite(lamp,HIGH);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='b') {&#xA;      digitalWrite(lamp,LOW);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='c') {&#xA;      digitalWrite(fan,HIGH);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='d') {&#xA;      digitalWrite(fan,LOW);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='e') {&#xA;      digitalWrite(pump,HIGH);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='f') {&#xA;      digitalWrite(pump,LOW);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='g') {&#xA;      digitalWrite(fridge,HIGH);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    } else if(val=='h') {&#xA;      digitalWrite(fridge,LOW);&#xA;      Serial.print(val);&#xA;      delay(100);&#xA;    }&#xA;  } else {&#xA;    int sensorValue = analogRead(A0);&#xA;    Serial.println(sensorValue/10);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Here is a part of my Java code&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public boolean identifyport() throws PortInUseException, IOException, TooManyListenersException {&#xA;  this.setVisible(true);&#xA;  try {&#xA;    Enum=CommPortIdentifier.getPortIdentifiers();&#xA;    while(Enum.hasMoreElements())&#xA;      portname=(CommPortIdentifier)Enum.nextElement();&#xA;      if(portname.getPortType()==CommPortIdentifier.PORT_SERIAL)&#xA;        port=portname.open(this.getClass().getName(), 2000);&#xA;      serialport=(SerialPort)port;&#xA;      serialport.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_2,SerialPort.PARITY_NONE);&#xA;      input=((CommPort) serialport).getInputStream();&#xA;      output=((CommPort)serialport).getOutputStream();&#xA;      serialreader=new BufferedReader(new InputStreamReader(input));&#xA;      serialport.addEventListener(this);&#xA;      serialport.notifyOnDataAvailable(true);&#xA;      progressBar.setBackground(Color.GREEN);&#xA;      portlist.addItem(portname.getName());&#xA;      progressBar.setValue(i);&#xA;      slider_3.setValue(value);&#xA;      Thread.sleep(1000);&#xA;      prg();&#xA;    } catch (UnsupportedCommOperationException e1) {&#xA;      // TODO Auto-generated catch block&#xA;      JOptionPane.showMessageDialog(contentPane, &quot;Check USB cable connection&quot;, &quot;No port available &quot;, 0);&#xA;    } catch (InterruptedException e) {&#xA;      // TODO Auto-generated catch block&#xA;      JOptionPane.showMessageDialog(null, &quot;Port status&quot;, &quot;Please connect the device....!!!!&quot;, day, null);&#xA;    }&#xA;    return rootPaneCheckingEnabled;&#xA;  }&#xA;  @Override public void serialEvent(SerialPortEvent e) {&#xA;    // TODO Auto-generated method stub&#xA;    if(e.getEventType()==SerialPortEvent.DATA_AVAILABLE){&#xA;      try {&#xA;        serial=  serialreader.read();&#xA;      } catch(Exception e1) {&#xA;        e1.printStackTrace();&#xA;      }&#xA;    }&#xA;  }&#xA;  public void writedata(int v1) {&#xA;    try {&#xA;      output.write(v1);&#xA;      output.hashCode();&#xA;    } catch (IOException e) {&#xA;      // TODO Auto-generated catch block&#xA;      e.printStackTrace();&#xA;    }&#xA;  }&#xA;&#xA;*And this is part of the switch button;*&#xA;Button button_1 = new Button(&quot;switch&quot;);&#xA;button_1.setFont(new Font(&quot;Tahoma&quot;, Font.BOLD, 13));&#xA;button_1.setBounds(10, 10, 117, 42);&#xA;panel_3.add(button_1);&#xA;button_1.addActionListener(new ActionListener() {&#xA;  int count=0;&#xA;  public void actionPerformed(ActionEvent e) {&#xA;    writedata(v1);&#xA;    if(count==0) {&#xA;      canvas.setBackground(Color.RED);&#xA;      canvas.setForeground(Color.GREEN);&#xA;      v1='b';&#xA;      count++;&#xA;    } else {&#xA;      canvas.setBackground(Color.YELLOW);&#xA;      canvas.setForeground(Color.GREEN);&#xA;      v1='a';&#xA;      count--;&#xA;    }&#xA;  }&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry I can not write everything because there is so much code.&lt;/p&gt;&#xA;" OwnerUserId="14895" LastEditorUserId="10907" LastEditDate="2015-11-22T17:14:19.630" LastActivityDate="2017-08-26T18:19:55.663" Title="Serial Communication Problem Using Eclipse" Tags="|arduino-uno|serial|library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17856" PostTypeId="2" ParentId="17728" CreationDate="2015-11-18T01:09:48.107" Score="1" Body="&lt;p&gt;The way that power windows detect fully open or closed is typically by measuring the motor current:  When a motor is stalled it's current increases because there is no longer any back-emf as there is when the magnetic fields are rotating.  You can measure this current and then stop when you see it increase over the running current.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is especially useful in the context of the window example as limit switches would have to be set EXACTLY at the closed position which is hard to do and if they fail or get out of alignment can lead to burned out motors if the limit switch is set beyond the physical travel limit.  Furthermore, an obstruction will result in a burned out motor even if the limit switch is correctly set as the window could never reach its limit position.  In these two cases, a timeout would need to be included as a backup (A timeout is not a bad idea in any case!).&lt;/p&gt;&#xA;" OwnerUserId="14014" LastActivityDate="2015-11-18T01:09:48.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17857" PostTypeId="1" CreationDate="2015-11-18T01:46:57.273" Score="1" ViewCount="184" Body="&lt;p&gt;Is there a downside to providing a lot of amps to Arduino UNO's VIN? Is there any advantage to only supplying a limited amount of amps? I have a regulated power supply and I'm curious what I should set it to when going through the 5v port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, should I stick with 5 volts? I've seen some tutorials say if powering the board through VIN it should ideally be much more than that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a spec sheet of sort that tells you this?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastActivityDate="2015-11-18T02:53:24.333" Title="Ideal settings for regulated power using Arduino Uno VIN?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17858" PostTypeId="2" ParentId="17857" CreationDate="2015-11-18T02:03:36.340" Score="2" Body="&lt;p&gt;Honestly, it doesn't matter how much power (amps) you make available, it will only draw what it needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is definitely something to be said for limiting how much power you provide.  If something in your circuit is miswired or otherwise shorts out, limiting the circuit to something reasonable (wisely including a fuse in your design as well) means that you won't have some enormous current suddenly passing through burning stuff out and possibly injuring someone. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as what to provide in terms of volts and amps, the data sheet for your particular arduino is the place to go.  As long as you are providing &lt;em&gt;that&lt;/em&gt; you are in good shape.&lt;/p&gt;&#xA;" OwnerUserId="14231" LastActivityDate="2015-11-18T02:03:36.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17859" PostTypeId="2" ParentId="17831" CreationDate="2015-11-18T02:21:52.470" Score="1" Body="&lt;p&gt;That is a very skimpy data sheet for the MiCS-5132 .  (Shame on manufacturer for not including isolation information between heater and resistor output).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect 3.2 volts (3.3 volts is ok) to pins 1 and 3 (heater). Keep in mind the heater will draw about 32 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 2 and 4 are the output.  The output is a resistor, whose value changes with the degree of detected gases. And the resistance is about 160 k ohms.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire a resistor (call it R1) from VCC (positive power) to your input. Start out with R1 = 150k  (anything from 120K to 180K). .   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire the sensor (pin2) to your input (use an input that can do A/D conversion).  Wire the other side of the sensor (pin 4) to your board ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes a resistor voltage divider to your input pin. Your input pin should be an A/D converter.  The A/D converter input should return a value dependent upon the sensor resistance.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Experiment with different values for R1, to get the input range that you desire.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2015-11-18T02:21:52.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17860" PostTypeId="2" ParentId="17857" CreationDate="2015-11-18T02:53:24.333" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Reference/Board&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Board&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. Note that different boards accept different input voltages ranges, please see the documentation for your board.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For specific values, visit &lt;a href=&quot;https://www.arduino.cc/en/Main/Products?from=Main.Hardware&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Products?from=Main.Hardware&lt;/a&gt; and select your board, and look down to where it says &quot;Input voltage&quot; - there's a &quot;recommended&quot; and &quot;limit&quot;, each being a range. Note that some power sources will fluctuate (e.g. 4 AA batteries are 6 volts, possible slightly higher when brand new, but will drop down if there is a high drain, or as they get used up. 4 AA batteries will not provide 6v for long). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for current (measured in amps or milliamps), if the power supply cannot supply what is used by the board, it will overheat; if it provides more than is required, then it will work 100% perfectly well (so long as you don't have a short circuit). The current an Arduino on it's own will draw will vary depending on the board, Nick Gammon measured an Arduino Uno Rev 3 board at 50 milliamps, but LEDs will typically draw around 20mA each; motors will draw a lot more. 1000mA = 1 amp, so Nick's Uno would draw 0.050 amps. Power supplies typically say on them how many amps (or in some cases, milliamps) they can (safely) provide.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-11-18T02:53:24.333" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17861" PostTypeId="1" AcceptedAnswerId="18850" CreationDate="2015-11-18T04:40:13.387" Score="0" ViewCount="303" Body="&lt;p&gt;I have an Android app that sends data to the arduino HC-06. It is however giving me colors i did not send to it. Eg. Red in place of green, white in place of red etc.&#xA;Here is a snippet of my android code that sends the data via bluetooth&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; public void onColorChanged(int color) {&#xA;    BluetoothV2 bluetooth = new BluetoothV2();&#xA;    int r,g,b;&#xA;    r = Color.red(color);&#xA;    g = Color.green(color);&#xA;    b = Color.blue(color);&#xA;    bluetooth.Message(r+&quot;,&quot;+g+&quot;,&quot;+b);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is a snippet of my arduino code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {  &#xA;&#xA;if(Serial.available()&amp;gt;0){&#xA;&#xA;while(Serial.available()&amp;gt;0){&#xA;   char inChar = (char)Serial.read();&#xA;   inputString += inChar;       &#xA;}    &#xA;   int red = Serial.parseInt();&#xA;   int green = Serial.parseInt();&#xA;   int blue = Serial.parseInt();&#xA;   color(red,green,blue);&#xA;   inputString = &quot;&quot;;&#xA;   Serial.println(&quot;R:&quot;&amp;amp;&amp;amp; red &amp;amp;&amp;amp;&quot;G:&quot;&amp;amp;&amp;amp; green &amp;amp;&amp;amp;&quot;B:&quot;&amp;amp;&amp;amp; blue);&#xA;  }&#xA;}  &#xA;&#xA;void color (unsigned char red, unsigned char green, unsigned char blue){   &#xA;   analogWrite(redPin, 255-red);  &#xA;   analogWrite(greenPin, 255-green);&#xA;   analogWrite(bluePin, 255-blue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Terminal data&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;               2,,,,,,,,,,,,,2,,5,,,,,,,,,,,,,,,,,,,,,,,,,02725,1,502725,,,,,,,,,02514,5,602515     ,5,3,,,,,025&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is the problem how i get the data though Serial.read()? Or what am i missing&lt;/p&gt;&#xA;" OwnerUserId="14904" LastEditorUserId="14904" LastEditDate="2015-11-18T05:31:27.653" LastActivityDate="2015-12-19T23:51:08.510" Title="LED Control through bluetooth" Tags="|arduino-uno|serial|arduino-mega|android|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17862" PostTypeId="2" ParentId="16908" CreationDate="2015-11-18T04:58:09.730" Score="2" Body="&lt;p&gt;Have you considered maybe using the &lt;a href=&quot;https://www.sparkfun.com/products/10744&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Sparkfun Mega Pro 3.3V&quot;&lt;/a&gt; plus a &lt;a href=&quot;https://www.sparkfun.com/products/9873&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;SparkFun FTDI Basic Breakout - 3.3V&quot;&lt;/a&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses the same ATmega2560 processor and has the same I/O arrangement as the Arduino Mega 2560, but it runs off 3.3 V.&#xA;It doesn't have the 16 MHz crystal you wanted, but if you really insist on overclocking, perhaps you could replace its 8MHz resonator with a 16 MHz crystal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2J8Ov.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2J8Ov.jpg&quot; alt=&quot;Sparkfun Mega Pro with resonator circled&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="186" LastEditDate="2015-11-19T04:21:50.997" LastActivityDate="2015-11-19T04:21:50.997" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17863" PostTypeId="2" ParentId="16908" CreationDate="2015-11-18T05:46:19.993" Score="1" Body="&lt;p&gt;Have you considered maybe using the Inhaos Buono Mega 2560 (see &lt;a href=&quot;http://www.inhaos.com/newsview.php?news_id=44&quot; rel=&quot;nofollow&quot;&gt;a&lt;/a&gt;), also called the &lt;a href=&quot;http://www.inhaos.com/product_info.php?products_id=117&quot; rel=&quot;nofollow&quot;&gt;Inhaos Mega2560&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I can tell, it is pretty much identical hardware as the Arduino Mega 2560 -- including the ATmega2560 processor -- except it has a selector to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like many websites, every page on the Inhaos website &lt;a href=&quot;http://www.inhaos.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.inhaos.com/&lt;/a&gt; has a &quot;Contact Us&quot; link at the top of each page. Click that link to get a list of several ways to contact the company.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="186" LastEditDate="2015-11-19T14:20:41.927" LastActivityDate="2015-11-19T14:20:41.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17864" PostTypeId="1" AcceptedAnswerId="17871" CreationDate="2015-11-18T05:54:23.570" Score="0" ViewCount="998" Body="&lt;p&gt;In software serial, the write function only sends 1 byte at a time. Is there someway, some library, that i can send multiple bits/bytes, without stopping (and not using digitalWrite)? i want to be able to transmit at least 16 bits as opposed to just 8. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know i can send 2 bytes, or even 100 bytes. But the thing i'm trying to do is, implement my own LDPC(error correction) codes on the Arduino. Therefore, i'm taking a lot of channel measurements. One of them is figuring out how the error happens during the delay between the stop bit and the next startbit. Often times, this is were synchronization problems occur. So I'm trying to track this down. Hence why, I need to send more than 8 continuous bits. In software serial, it transmits 8 bits, then transmits the stop bit. then write() restarts on the next call. Instead of this, i just want to send more bits, like 64 bits for instance, and look at the BLER on the received data. (the reason why I'm staying away from hardware serial is because i'm doing this with wireless RF modules) Do you guys have any further info regarding this? I'm very grateful! Thank you so much!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it was suggested that I write my own softwareserial, but that's a pretty daunting task. I would like to avoid it, if i can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: Let me show you my data.&lt;/strong&gt; &#xA;So, I'm constantly transmitting the values; 123,124,125,126. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1111011&#xA;1111100&#xA;1111101&#xA;1111110&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above 4 lines repeat about 2 times. Then, suddenly, it synchronizes incorrectly, and the following 4 lines are being constantly repeated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11110101&#xA;11111001&#xA;11101101&#xA;11110001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It never syncs back to the original 4 transmissions. Now, inside the unsynced block of 4 transmitted bytes, there are fragments of the correct transmission inside. For instance, start from the 2nd bit of the 3rd byte of the correct transmitted byte. Now, if you account for the '0' start bit, and try to matchup the bits, the correct bits are being picked up in the correct order. It's just a problem of what the receiver takes as the startbit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i'm typing this edit, i realized something else. What i said in the above paragraph is true, then for the unsynced block, there should be a '0' start bit in front. Now, if the messages match up exactly, and if the 0 start bit that is being transmitted is being treated as a payload, then which 0 is being treated as the startbit, because all the bits between the synced and unsynced data are matched up. However, there should be one missing 0 each time because it's being read as a startbit, not databit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if this is convoluted. Happy to clarify any part of it. Thank you so much!!&lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2015-11-19T16:52:21.447" LastActivityDate="2015-11-24T20:27:15.013" Title="How to transmit more than 1 byte continually?" Tags="|arduino-uno|softwareserial|rf|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17865" PostTypeId="2" ParentId="16908" CreationDate="2015-11-18T05:56:30.957" Score="3" Body="&lt;p&gt;Have you considered maybe using the &lt;a href=&quot;https://www.itead.cc/iteaduino-mega-2560.html&quot; rel=&quot;nofollow&quot;&gt;Iteaduino MEGA2560&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://wiki.iteadstudio.com/Iteaduino_MEGA_2560&quot; rel=&quot;nofollow&quot;&gt;Iteaduino MEGA2560&lt;/a&gt;&#xA;uses the same ATmega2560 processor as the Arduino Mega 2560,&#xA;but is physically much smaller, the size of a Arduino UNO.&#xA;It has a switch to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.&#xA;It breaks out &lt;em&gt;all&lt;/em&gt; the GPIO pins of the ATmega2560,&#xA;so it actually has more I/O on its connectors than the Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm reading this right, the &lt;a href=&quot;ftp://imall.iteadstudio.com/IM120410003_Iteaduino_MEGA_2560/Documents/SCH_IM120410003_Iteaduino_MEGA_2560.pdf&quot; rel=&quot;nofollow&quot;&gt;Iteaduino schematics&lt;/a&gt; and a &lt;a href=&quot;http://www.epictinker.com/Iteaduino-MEGA-2560-p/dep024.htm&quot; rel=&quot;nofollow&quot;&gt;typical Iteaduino features list&lt;/a&gt;&#xA;seems to say it already has a 16 MHz crystal.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="186" LastEditDate="2015-11-19T04:02:53.453" LastActivityDate="2015-11-19T04:02:53.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17867" PostTypeId="2" ParentId="16908" CreationDate="2015-11-18T06:50:25.860" Score="1" Body="&lt;p&gt;Have you considered maybe using the &lt;a href=&quot;http://www.elecfreaks.com/estore/freaduino-mega2560-white-color-mb-frdn011.html&quot; rel=&quot;nofollow&quot;&gt;ElecFreaks Freaduino MEGA2560&lt;/a&gt; ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has an identical I/O arrangement and dimensions as the Arduino Mega 2560 -- including the ATmega2560 processor. It has a selector to run the ATmega2560 at 3.3 V, so its I/O pins can be directly connected to 3.3 V modules.&#xA;The voltage regulators and reset switch position are better than the Arduino Mega 2560.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-11-18T06:50:25.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17868" PostTypeId="1" AcceptedAnswerId="18203" CreationDate="2015-11-18T07:22:44.697" Score="0" ViewCount="442" Body="&lt;p&gt;I recently dusted off an &lt;em&gt;old&lt;/em&gt; Arduino Duemilanove to play with. I can connect it to my Mac laptop with the same USB cable I used previously and I'm able to monitor the serial port and see the output from the last sketch I uploaded (five years ago). Everything is unplugged from the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to upload a new sketch, the Arduino IDE gets stuck on &lt;code&gt;Uploading...&lt;/code&gt; indefinitely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Using Port                    : /dev/cu.usbserial-A800eGZI&#xA;Using Programmer              : arduino&#xA;Overriding Baud Rate          : 19200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The board itself has the green &lt;code&gt;PWR&lt;/code&gt; LED and amber &lt;code&gt;TX&lt;/code&gt; LED on solid once the currently loaded sketch starts running. Initiating an upload causes the amber &lt;code&gt;L&lt;/code&gt; LED to blink three times, then the &lt;code&gt;RX&lt;/code&gt; LED blinks twice, and finally the &lt;code&gt;TX&lt;/code&gt; LED on solid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the exact board: &lt;a href=&quot;https://www.sparkfun.com/products/retired/666&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/retired/666&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My research into this issue produced many suggestions that have not resolved the problem...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disabled the built-in FTDI driver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo kextunload -b com.apple.driver.AppleUSBFTDI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And made sure the FTDI driver from ftdichip.com was loaded:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo kextload /Library/Extensions/FTDIUSBSerialDriver.kext&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried &lt;code&gt;csrutil enable --without kext&lt;/code&gt; against my better judgement and saw no change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried a completely separate machine -- my PC running Windows 10 -- and the upload hung there too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried timing the upload to coincide with a board reset, hoping to sneak my upload in before the current sketch starts running. I did this &lt;em&gt;a lot&lt;/em&gt; and got no satisfaction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't given up yet; there are too many signs of life to think that it's unrecoverable. I'm looking for more suggestions on how to troubleshoot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already ordered another Arduino -- hopefully I can use it to burn the bootloader on the Duemilanove.&lt;/p&gt;&#xA;" OwnerUserId="14883" LastEditorUserId="14883" LastEditDate="2015-11-18T08:28:02.387" LastActivityDate="2015-11-28T10:15:58.090" Title="Unable to upload sketch on Mac OSX El Capitan" Tags="|arduino-due|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17869" PostTypeId="2" ParentId="17861" CreationDate="2015-11-18T08:11:33.137" Score="0" Body="&lt;p&gt;Maybe you can try again with something like this to check if the android part is not correct. From your terminal output it seems that you receive values higher than 255. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void onColorChanged(int red, int green, int blue) //values from 0 - 255&#xA;int r,g,b;&#xA;r= red;&#xA;g= green;&#xA;b= blue;&#xA;bluetooth.Message(r+&quot;,&quot;+g+&quot;,&quot;+b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The receive part in your arduino code is like my code for a similar project.&#xA;Try setting your color in the arduino code like this to check if the example code from above works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void color (int red, int green, int blue)&#xA;{   &#xA;analogWrite(redPin, red);  //the higher your send value the brighter the color&#xA;analogWrite(greenPin, green);&#xA;analogWrite(bluePin, blue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14908" LastActivityDate="2015-11-18T08:11:33.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17871" PostTypeId="2" ParentId="17864" CreationDate="2015-11-18T10:23:58.290" Score="2" Body="&lt;p&gt;I want to point out here that async serial communications relies on both ends providing a clock (there is no transmitted clock signal). Thus the sender clocks out bits at the &quot;baud rate&quot; (eg. 9600 bits per second) and the receiver clocks them in at the same rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a start bit and 8 data bits therefore you can tolerate some difference in the clocks between sender and receiver (and there will be &lt;em&gt;some&lt;/em&gt; difference). Effectively you could probably tolerate around a 10% difference in clock frequencies, as even if they are out by 10% the sample at the receiver will still land inside the data bit of the sender.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you want to transmit 64 bits you have reduced this error margin by a factor of 8. So let's say (ball park) that you can now only tolerate a difference of 1% between sender and receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now need to be pretty sure that the clocks on the respective boards are pretty accurate. The Uno, for example, has a resonator CSTCE16M0V53-R0 which appears to have a tolerance of 0.5% and a frequency stability of 0.2%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if the sender is running 0.5% slow, and the receiver 0.5% fast, you will almost certainly get errors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, when it becomes unsyncde, some new 0 bit should be treated as the startbit, in which case it should not be printed. But i don't see any misisng zero. It's as if the actual data just got shifted.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How will it get unsynced?  I don't think you are following how serial comms works. If you don't have any delay between bytes (or batches of bytes in your case) then it is impossible to resync, because if you miss a start bit, all the following bits will appear valid, they'll just be shifted. This is exactly what you are describing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, to &lt;strong&gt;ensure&lt;/strong&gt; syncing you need to have a gap between bytes (or batches-of-bytes in your case) longer than a byte might be, otherwise you can get this mis-sync happening. So if you make your batches longer, the gap has to be longer, effectively removing the slight advantage of larger batches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you have an incoming stream of bits on the receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;011110101101100011110101101101101100110101100101100110101111001010101110111001010101111&#xA;1101001010100101101001010100111011111001000010111100100011011001001001001011001001010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And imagine that you missed that first start bit. Without a gap between bytes (which would appear as: &lt;code&gt;111111111&lt;/code&gt;) you have no way of knowing which is a start bit and which is a data bit. Valid data would have a start bit, so you don't mistake valid data for the inter-byte gap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, with 8-bit bytes, &lt;strong&gt;data&lt;/strong&gt; will always be &lt;code&gt;0xxxxxxxx1&lt;/code&gt; and thus a gap of &lt;code&gt;1111111111&lt;/code&gt; must be the gap and not data because there is no zero there. But with any shorter gap, and if the receiver samples in the middle of byte, it certainly might think that the next 0 in the stream is a start bit (wrongly).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-11-24T20:27:15.013" LastActivityDate="2015-11-24T20:27:15.013" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17873" PostTypeId="1" CreationDate="2015-11-18T11:23:53.467" Score="2" ViewCount="2528" Body="&lt;p&gt;I am trying to read from a ps2 barcode scanner (Datalogic gryphon D). &#xA;The Arduino is powered by the USB. The circuit is shown below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0E703.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0E703.png&quot; alt=&quot;ps2 connection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pinout of the ps2 is&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rCEcu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rCEcu.jpg&quot; alt=&quot;ps2 pinout&quot;&gt;&lt;/a&gt;&#xA;I have used the fritzing pin assignments when making the diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the code from &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PS2Keyboard.h&amp;gt;&#xA;&#xA;const int DataPin = 8;&#xA;const int IRQpin =  5;&#xA;&#xA;PS2Keyboard keyboard;&#xA;&#xA;void setup() {&#xA;  delay(1000);&#xA;  keyboard.begin(DataPin, IRQpin);&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Keyboard Test:&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (keyboard.available()) {&#xA;&#xA;    // read the next key&#xA;    char c = keyboard.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The scanner scans and indicates that the scan was successful. The Arduino code shows &quot;Keyboard Test:&quot;, but none of the scans show anything. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="13330" LastEditorUserId="13330" LastEditDate="2015-11-18T19:46:24.597" LastActivityDate="2015-11-18T19:46:24.597" Title="Reading from ps2 barcode scanner" Tags="|arduino-uno|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17874" PostTypeId="1" AcceptedAnswerId="17912" CreationDate="2015-11-18T13:26:11.723" Score="0" ViewCount="231" Body="&lt;p&gt;I am trying to use Processing with Arduino Uno board to read the change of voltage done by a potentiometer. The code is simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;import cc.arduino.*;&#xA;&#xA;Serial myport;&#xA;Arduino arduino;&#xA;&#xA;color off = color(4, 79, 111);&#xA;color on = color(84, 145, 158);&#xA;int val=0;&#xA;float value=0;&#xA;void setup() {&#xA;  size(600, 600);&#xA;  println(Arduino.list());&#xA;  arduino = new Arduino(this, Arduino.list()[0], 57600);&#xA;  arduino.pinMode(0, Arduino.INPUT);&#xA;}&#xA;&#xA;void draw() {&#xA;  stroke(on);&#xA;  value = arduino.analogRead(0);&#xA;  println(value);&#xA;  ellipse(300,300,value,value);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is: For analog pins in Arduino IDE one should type A0, A1, ... but here in Processing IDE it is an error to type so. Is it possible that Processing reads the wrong pin? Because in Serial output I always get zero, however, for the same circuit in Arduino IDE the values change as I turn the potentiometer knob.&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14917" LastEditorUserId="14917" LastEditDate="2015-11-18T19:36:36.760" LastActivityDate="2015-11-19T12:31:05.483" Title="Problem with analog pins' name when trying to connect Arduino board and Processing" Tags="|processing-lang|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17875" PostTypeId="1" CreationDate="2015-11-18T13:28:40.420" Score="0" ViewCount="424" Body="&lt;p&gt;today i was trying to use arduino power headers as a power source for my basic laser.&lt;br&gt;&#xA;I used pin &quot;5V&quot; to connect it to the laser anode and the &quot;GND&quot; pin to the laser groung pin.&lt;br&gt;&#xA;after doing this arduino turned restarted, so I removed all the connections to the laser, now the arduino is normal.&lt;br&gt;&#xA;booth &quot;5V&quot; and &quot;GND&quot; pins is working normal.&lt;br&gt;&#xA;does this mean that I made a short circut and arduino protected it self ?&#xA;should I do anything now ?&lt;/p&gt;&#xA;" OwnerUserId="14669" LastActivityDate="2015-11-20T17:11:04.800" Title="How to know if arduino activated its short breaker?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17876" PostTypeId="1" CreationDate="2015-11-18T14:31:04.497" Score="3" ViewCount="126" Body="&lt;p&gt;Sending with this function here works fine:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;uint16_t usart0spiTransfer16(uint16_t spiMessage16) {&#xA;    uint16_t sdo = 0;&#xA;    byte firstByte = spiMessage16;&#xA;    byte secondByte = (spiMessage16 &amp;gt;&amp;gt; 8);&#xA;    while (((USART0-&amp;gt;US_CSR  &amp;gt;&amp;gt; 1) &amp;amp; 1) == 0);&#xA;    digitalWrite(SS, LOW);                  &#xA;    USART0-&amp;gt;US_THR = secondByte;                //write to USARTO Transmit Hold Register&#xA;&#xA;    //this byte is returned twice&#xA;    secondByte = USART0-&amp;gt;US_RHR;                //read from USART0 Receive Hold Register&#xA;    while (((USART0-&amp;gt;US_CSR  &amp;gt;&amp;gt; 1) &amp;amp; 1) == 0);  //TXRDY: Transmitter Ready&#xA;    USART0-&amp;gt;US_THR = firstByte;&#xA;&#xA;    //trying to read a second time gives me the same value as before&#xA;    firstByte = USART0-&amp;gt;US_RHR;&#xA;&#xA;    while (((USART0-&amp;gt;US_CSR  &amp;gt;&amp;gt; 9) &amp;amp; 1) == 0);&#xA;    digitalWrite(SS, HIGH);&#xA;&#xA;    sdo = (firstByte &amp;lt;&amp;lt; 8 ) | (secondByte &amp;amp; 0xFF);&#xA;    return sdo;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and when i wait for RXRDY after &lt;code&gt;secondByte = USART0-&amp;gt;US_RHR;&lt;/code&gt; with &lt;code&gt;while (((USART0-&amp;gt;US_CSR  &amp;gt;&amp;gt; 0) &amp;amp; 1) == 0);&lt;/code&gt; i will stay there forever since it does not change&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how do i read the registers value for the second time?&lt;/p&gt;&#xA;" OwnerUserId="14805" LastEditorUserId="37523" LastEditDate="2019-05-15T02:59:03.963" LastActivityDate="2019-05-15T02:59:03.963" Title="Reading Reveive Hold Register from USART in SPI Mode on Arduino Due" Tags="|arduino-due|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17877" PostTypeId="2" ParentId="17875" CreationDate="2015-11-18T14:59:45.273" Score="1" Body="&lt;p&gt;It sounds like connecting your Laser to the 5 volts power supply did draw too much current, thereby the 5 volts dropped to very low voltage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino didn't &quot;protect&quot; itself.  The Arduino simply shut down because of voltage being too low. Then, upon reapplication of 5 volts the Arduino re-started as normal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't mention any details about the Laser.  But if your Laser is simply a Diode, the Laser diode would draw a lot of current, resulting in the 5 volts power source giving reduced voltage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Laser is a &quot;laser module&quot; with a built in driver, perhaps you connected the Laser backwards to the 5 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 11/20/2015 :  IF you are using the Arduino UNO ,  : The  PolyFuse only protects from 500 mA overload on the USB connector.  Schematic for the UNO shows that 5 volts for USB is called &quot;XUSB&quot;. The  PolyFuse connects from &quot;USB VCC&quot; to the XUSB.  When you connected your Laser to the +5 and ground, the  PolyFuse was not involved. (Unless of course you did connect to the USB 5 volts (XUSB), and didn't tell us that.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;HOWEVER,  if you powered your UNO from the USB port, then the  PolyFuse WAS involved and did shut you down as others have commented.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2015-11-20T17:11:04.800" LastActivityDate="2015-11-20T17:11:04.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17879" PostTypeId="1" CreationDate="2015-11-18T15:47:29.763" Score="0" ViewCount="533" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;QTRSensors.h&amp;gt;&#xA;#define NUM_SENSORS 8&#xA;#define TIMEOUT 2500&#xA;#define EMITTER_PIN QTR_NO_EMITTER_PIN &#xA;QTRSensorsRC qtrrc((unsigned char[]) {10,7,6, 5, 4, 2,16,14},&#xA;NUM_SENSORS, TIMEOUT, EMITTER_PIN);&#xA;&#xA;unsigned int sensorValues[NUM_SENSORS];&#xA;int dirB = 12;&#xA;int speedB = 3;&#xA;int brakeB = 8;&#xA;int dirA = 13;&#xA;int speedA = 11;&#xA;int brakeA = 9;&#xA;int e=4;&#xA;int MzSensor=17;&#xA;int xp=4;&#xA;&#xA;void setup() {&#xA;delay(500);&#xA;int i;&#xA;pinMode(13,OUTPUT);&#xA;digitalWrite(13,HIGH);&#xA;for (i = 0; i &amp;lt; 200; i++)&#xA;{&#xA;  qtrrc.calibrate();&#xA;}&#xA;digitalWrite(13,LOW);&#xA;Serial.begin(9600);&#xA;delay(100);&#xA;Serial.println(&quot;Robot&quot;);&#xA;for (i = 0; i &amp;lt; NUM_SENSORS; i++)&#xA;{&#xA;  Serial.print(qtrrc.calibratedMinimumOn[i]);&#xA;  Serial.print(' ');&#xA;}&#xA;Serial.println();&#xA;{&#xA;  Serial.print(qtrrc.calibratedMaximumOn[i]);&#xA;  Serial.print(' ');&#xA;}&#xA;Serial.println();&#xA;Serial.println();&#xA;delay(100);&#xA;}&#xA;void loop() {&#xA;Serial.print('ogeday');&#xA;unsigned int position = qtrrc.readLine(sensorValues);&#xA;unsigned char i;&#xA;for (i = 0; i &amp;lt;NUM_SENSORS; i++)&#xA;{&#xA;  Serial.print(sensorValues[i] * 10 / 1001);&#xA;  Serial.print(' ');&#xA;}&#xA;Serial.print(&quot;   &quot;);&#xA;Serial.println(position);&#xA;delay(200);&#xA;if (digitalRead(MzSensor)==0) {&#xA;  while(digitalRead(MzSensor)==0) {&#xA;    digitalWrite (dirA, HIGH);&#xA;    analogWrite(speedA, 76);&#xA;    digitalWrite(dirB, HIGH);&#xA;    analogWrite(speedB, 76);&#xA;    xp == 5;&#xA;    Serial.println(&quot;durdu&quot;);&#xA;    delay(100);&#xA;  }&#xA;  delay(800);&#xA;  Serial.println(&quot;CIKTI&quot;);&#xA;}&#xA;else&#xA;if (position &amp;gt;= 3250 &amp;amp;&amp;amp;position &amp;lt;= 3750)&#xA;{&#xA;  if(sensorValues [1] &amp;lt; 500 )&#xA;  {&#xA;    e=7;&#xA;    xp=3;&#xA;  }&#xA;  if(sensorValues [8] &amp;lt; 500 )&#xA;  {&#xA;    e=1;&#xA;    xp=3;&#xA;  }&#xA;  if (sensorValues[3] &amp;lt; 500 || sensorValues[4] &amp;lt; 500 || sensorValues [5] &amp;lt;&#xA;  Serial.println(&quot;ILERI&quot;),&#xA;  digitalWrite(dirA, HIGH),&#xA;  digitalWrite(brakeA, LOW),&#xA;  analogWrite(speedA, 72),&#xA;  digitalWrite(dirB, HIGH),&#xA;  digitalWrite(brakeB, LOW),&#xA;  analogWrite(speedB, 72),&#xA;  e=4,&#xA;  xp=3,&#xA;&#xA;  delay (1),&#xA;&#xA;}&#xA;&#xA; else if (position &amp;gt; 4050 || sensorValues [8] &amp;lt;500)&#xA;  {&#xA;    Serial.println(&quot;EN SAG&quot;);&#xA;    digitalWrite(dirA, LOW);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 19);&#xA;    digitalWrite(dirB, HIGH);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 45);&#xA;    e=1;&#xA;    xp=3;&#xA;  }&#xA;  else if (position &amp;lt;- 4050 &amp;amp;&amp;amp;position &amp;gt;- 3900)&#xA;  {&#xA;    Serial.println(&quot;SAG&quot;);&#xA;    digitalWrite(dirA, HIGH);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 51);&#xA;    digitalWrite(dirB, HIGH);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 60);&#xA;    e=1;&#xA;    xp=3;&#xA;  }&#xA;  else if (position &amp;gt;= 2950 &amp;amp;&amp;amp;position &amp;lt;= 3100)&#xA;  {&#xA;    Serial.println(&quot;SOL&quot;);&#xA;    digitalWrite(dirA, HIGH);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 60);&#xA;    digitalWrite(dirB, HIGH);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 51);&#xA;    e=7;&#xA;    xp=3;&#xA;  }&#xA;  else if (position &amp;lt; 2950 || sensorValues [1] &amp;lt; 300 )&#xA;  {&#xA;    Serial.println(&quot;EN SOL&quot;);&#xA;    digitalWrite(dirA, HIGH);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 45);&#xA;    digitalWrite(dirB, 45);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 19);&#xA;    e=7;&#xA;    xp=3;&#xA;  }&#xA;  else if (e==7) {&#xA;    Serial.println(&quot;Cizgi SOLLL&quot;);&#xA;    if (xp!=1){&#xA;      digitalWrite(dirA, LOW);&#xA;      digitalWrite(brakeA, LOW);&#xA;      analogWrite(speedA, 30);&#xA;      digitalWrite(dirB, LOW);&#xA;      digitalWrite(brakeB, LOW);&#xA;      analogWrite(sppedB, 30);&#xA;      xp=1;&#xA;      delay(1); &#xA;    }&#xA;    digitalWrite(dirA, HIGH);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 66);&#xA;    digitalWrite(dirB, LOW);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 48);&#xA;    e=7;&#xA;  }&#xA;  else if (e==1) {&#xA;    Serial.pirntln(&quot;{Cizgi SAGGG&quot;);&#xA;    if(xp!=1) {&#xA;      digitalWrite(dirA, LOW);&#xA;      digitalWrite(brakeA, LOW);&#xA;      analogWrite(speedA, 30);&#xA;      digitalWrite(dirB, LOW);&#xA;      digitalWrite(brakeB, LOW);&#xA;      xp=1;&#xA;      delay(1);&#xA;    }&#xA;    digitalWrite(dirA, LOW);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 48);&#xA;    digitalWrite(dirB, HIGH);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 66);&#xA;    e=1;&#xA;  }&#xA;  else if (e==4) {&#xA;    Serial.println(&quot;ILERI GIDIYOR&quot;);&#xA;    digitalWrite(dirA, HIGH);&#xA;    digitalWrite(brakeA, LOW);&#xA;    analogWrite(speedA, 30);&#xA;    digitalWrite(dirB, HIGH);&#xA;    digitalWrite(brakeB, LOW);&#xA;    analogWrite(speedB, 30);&#xA;    e=4;&#xA;  }&#xA;  //delay(300)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14921" LastEditorUserId="14766" LastEditDate="2015-11-18T16:05:59.553" LastActivityDate="2015-12-02T01:15:00.633" Title="Here is my code and i keep getting this error expected primary-expression before'}' token" Tags="|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17880" PostTypeId="2" ParentId="17879" CreationDate="2015-11-18T15:49:39.900" Score="3" Body="&lt;p&gt;Change &lt;code&gt;delay (1),&lt;/code&gt; to &lt;code&gt;delay (1);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14766" LastEditorUserId="220" LastEditDate="2015-11-22T14:56:43.040" LastActivityDate="2015-11-22T14:56:43.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17881" PostTypeId="2" ParentId="17875" CreationDate="2015-11-18T16:10:47.580" Score="1" Body="&lt;p&gt;You uses more the 500mA limit, and the PolyFuse tripped. After unplugging the polyfuse cooled down and &quot;reset&quot; itself. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-18T16:10:47.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17882" PostTypeId="2" ParentId="16559" CreationDate="2015-11-18T16:13:34.430" Score="0" Body="&lt;p&gt;After all, it's a cost issue.&lt;br&gt;&#xA;Not only of the Arduino/Atmel, but any microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The outputs of the PWM unit (which has a limited number of PWM channels) have to be routed to the output pins.&lt;br&gt;&#xA;This routing is basically fix, because the silicon mask is fix.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, to add some flexibility, most controllers allow a limited configuration of this routing by adding some internal switches which can be accessed by writing to the specific registers. &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But any additional routing capabilities means more of those internal switches, which results in &lt;br&gt;more size -&gt; more silicon -&gt; more expensive.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore the micro designers say - for example - &quot;OK, it's enough to be able to output x of the y available PWM channels at every edge of the micro&quot;, and the poor PCB designer has to cope with what he gets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using an FPGA instead of a microcontroller you are really free to setup your function to pin routing - but look at the price of an FPGA ;-)&lt;/p&gt;&#xA;" OwnerUserId="3878" LastActivityDate="2015-11-18T16:13:34.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17884" PostTypeId="2" ParentId="12017" CreationDate="2015-11-18T17:35:44.440" Score="1" Body="&lt;p&gt;Assuming the board is not fried...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sounds like 'USB &amp;lt;--&gt; serial' chip issue. Not sure which chip it is, could be CP2102 or FT232 or CH340G. If it is FT232R and not a genuine one and you are using a specific version of the driver - you could have bricked the USB &amp;lt;--&gt; serial converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without assumptions, I would start with a bootable USB pen-drive with some flavour of Linux - I prefer Linux Mint/Ubuntu. Here is how I would go:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Boot the system with the pen-drive with Arduino disconnected&lt;/li&gt;&#xA;&lt;li&gt;Open terminal and tail the system log (e.g. tailf /var/log/syslog)&lt;/li&gt;&#xA;&lt;li&gt;Attach the Arduino board and see what shows up.&lt;/li&gt;&#xA;&lt;li&gt;If Arduino is detected, there will be a message with the serial port device name (e.g. /dev/ttyUSB0)&lt;/li&gt;&#xA;&lt;li&gt;Arduino IDE could run on Linux. If the port is detected, run Arduino IDE and see if it detects the board.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If not detected, the board is still useable, but you might need to find a way to connect external USB &amp;lt;--&gt; Serial converter and disconnect the on board one. That means cutting traces and probably soldering some pins.&lt;/p&gt;&#xA;" OwnerUserId="14922" LastActivityDate="2015-11-18T17:35:44.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17885" PostTypeId="1" CreationDate="2015-10-14T16:41:36.160" Score="3" ViewCount="371" Body="&lt;p&gt;I am newbie, I am afraid of doing harm and getting a burned-out Beagle Bone Black. I have soldered this &lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow&quot;&gt;SparkFun Logic Level Converter - Bi-Directional&lt;/a&gt;.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I check if my converter works correctly without connecting it to any board or at least only to an Arduino?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How should I connect all my schematic from bbb to converter and then to an Arduino. I have a bi-directional converter, BTW. Can someone draw a simple picture of how to connect?    &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would be grateful for any help. &lt;/p&gt;&#xA;" OwnerUserId="14025" OwnerDisplayName="solderingiron" LastActivityDate="2015-12-09T19:19:02.993" Title="How to connect Arduino and Beaglebone" Tags="|serial|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17886" PostTypeId="2" ParentId="17885" CreationDate="2015-11-16T19:02:04.680" Score="0" Body="&lt;p&gt;Your main concern for frying something would be when sending data from the Arduino(which uses 5V) to the Beagle (Which uses 3.3). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino &lt;em&gt;receiving&lt;/em&gt; data on the Arduino RX line wouldn't be anything to worry about since you would be sending data at 3.3V from the Beagle to 5V on the Arduino( Remember that unlike RS-232, TTL serial has no carrier voltage, so current only travels over the lines when data is actually sent )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could always hook up the Arduino side (HV/5V), program the Arduino to do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;HELLO WORLD&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inside &lt;code&gt;void loop()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and look for voltage being send over the RX pin on the LV side. You would still have to connect 3.3V to LV and GND to GND.  &lt;/p&gt;&#xA;" OwnerDisplayName="jetdillo" LastEditorUserId="173" LastEditDate="2015-11-22T14:51:54.567" LastActivityDate="2015-11-22T14:51:54.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17887" PostTypeId="2" ParentId="17879" CreationDate="2015-11-18T17:55:00.300" Score="1" Body="&lt;p&gt;In this part:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (sensorValues[3] &amp;lt; 500 || sensorValues[4] &amp;lt; 500 || sensorValues [5] &amp;lt;&#xA;Serial.println(&quot;ILERI&quot;),&#xA;digitalWrite(dirA, HIGH),&#xA;digitalWrite(brakeA, LOW),&#xA;analogWrite(speedA, 72),&#xA;digitalWrite(dirB, HIGH),&#xA;digitalWrite(brakeB, LOW),&#xA;analogWrite(speedB, 72),&#xA;e=4,&#xA;xp=3,&#xA;&#xA;delay (1),&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's a lot of ',' instead of ';'. Change then to ';'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the 'if' is incomplete. Check the 'if' statement.&lt;/p&gt;&#xA;" OwnerUserId="11030" LastActivityDate="2015-11-18T17:55:00.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17888" PostTypeId="2" ParentId="17885" CreationDate="2015-11-18T18:10:53.467" Score="1" Body="&lt;p&gt;The simplest method of connection is just to plug the Arduino into the BBB's USB socket.  That way there's no level conversion or anything needed - you can just open the serial port and communicate through that - what could be simpler?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even install avrdude on the BBB itself and upload code (HEX files) direct from the BBB, and the BBB supplies all the power.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-18T18:10:53.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17889" PostTypeId="2" ParentId="17879" CreationDate="2015-11-18T19:39:06.640" Score="0" Body="&lt;pre&gt;&lt;code&gt;if (sensorValues[3] &amp;lt; 500 || sensorValues[4] &amp;lt; 500 || sensorValues [5] &amp;lt;&#xA;  Serial.println(&quot;ILERI&quot;),&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;if()&lt;/code&gt; condition is not complete&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;;&lt;/code&gt; not &lt;code&gt;,&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A little advice. Use functions so that your code is easy to read and easy to debug (looking for errors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void func(String text, boolean mDirA, boolean mBrakeA, int mSpeedA,&#xA;    boolean mDirB, boolean mBrakeB, int mSpeedB){&#xA;&#xA;    Serial.println(text);&#xA;    digitalWrite(dirA, mDirA);&#xA;    digitalWrite(brakeA, mBrakeA);&#xA;    analogWrite(speedA, mSpeedA);&#xA;    digitalWrite(dirB, mDirB);&#xA;    digitalWrite(brakeB, mBrakeB);&#xA;    analogWrite(speedB, mSpeedB);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14924" LastEditorUserId="2944" LastEditDate="2015-12-02T01:15:00.633" LastActivityDate="2015-12-02T01:15:00.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17891" PostTypeId="1" AcceptedAnswerId="19345" CreationDate="2015-11-18T21:28:15.813" Score="4" ViewCount="61" Body="&lt;p&gt;I have an Arduino controlling a relay. I was taking a look at the timings using a logic analyzer and at the onset of the relay switching, it quickly switches again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be occurring randomly and I thought it could be highlighting a problem with my code but I wondered if it might just be a 'relay bounce' due to the speed of the switch. I've attached an image below. Any feedback is greatly appreciated. Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fKaJ7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fKaJ7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8726" LastEditorUserId="10907" LastEditDate="2015-12-21T11:33:59.727" LastActivityDate="2016-01-08T12:56:00.250" Title="Not sure if logic analyzer shows an error or perhaps just a 'relay bounce'" Tags="|relay|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17892" PostTypeId="2" ParentId="17542" CreationDate="2015-11-18T21:41:01.330" Score="2" Body="&lt;p&gt;A datasheet for the HX711 is &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf&lt;/a&gt;  (On your board, it looks like E+ is AVDD and E- is AGND.)&lt;/p&gt;&#xA;&lt;p&gt;Each of your two load cells could be a half-bridge of a wheatstone bridge, with excitation on the white and black, and sensing on the red like: &lt;a href=&quot;https://i.stack.imgur.com/PrHOR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PrHOR.jpg&quot; alt=&quot;https://i.stack.imgur.com/PrHOR.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have a similar loadcell with the colors as Blue-Red-Black, (instead of White-Red-Black as above, or the Red-White-Black in your image) with my red sensing wire in the middle.  The positive strain resistance (increasing resistance with increasing load) is between the Blue and Red, while the negative strain (decreasing resistance with decreasing load) is between the Red and the Black. The ~1000 ohm resistance in each leg changes by tenths of an ohm with hand pressure on the button, when the outer portion is supported, but the inner portion is not supported.  Your cells do not have the bridge-button part that create a balanced twist along the center portion, so it might be hard to reliably apply a load your cell.&lt;/p&gt;&#xA;&lt;p&gt;To make positive deflections of the cells combine to unbalance the Wheatstone bridge, wire one cell's white and black opposite to the other cell, and attach them to E+ and E-, with the reds connected to A+ and A- like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   HX711.E+ : Cell1.White + Cell2.Black&#xA;   HX711.E- : Cell1.Black + Cell2.White&#xA;   HX711.A+ : Cell1.Red&#xA;   Hx711.A- : Cell2.Red&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sUqcE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sUqcE.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The labelling on the schematic isn't quite right-- the &amp;quot;Reference 1K&amp;quot; are actually the negative-strain portions of the cells, and might be better labelled as &amp;quot;-Active 1k Ohm&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;If it moves in the wrong direction/wrong sign with increasing force, switch the reds or multiply by -1.&lt;/p&gt;&#xA;&lt;p&gt;If you have only one three-wire cell, use a couple 1K resistors, or a 2K potentiometer to balance the existing cell as the other half of the Wheatstone bridge.  One issue with using discrete (10%, 5%, 1%?) resistors is that the precision and tolerances when configured as a voltage divider may produce a significantly different result as compared with the balance in a lead cell and its full-scale signal (+/-0.1%) in a loadcell.  A the center tap of a potentiometer can provide for tuning to match the load cell voltage.  For the HX711's 32x, 64x, or 128x gain, you need to keep the voltage differences between the sense terminals  between +/-80mV, +/-40mV, or +/-20mV to stay within the limits of the HX711.&lt;/p&gt;&#xA;&lt;p&gt;Per @wirewrap's comment, the colors on the wire could be different than the picture I posted.  You can make certain by measuring the resistances between the wires and exciting on the pair with the greatest resistance, and sensing on the middle terminal.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2021-10-03T19:22:42.767" LastActivityDate="2021-10-03T19:22:42.767" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="17893" PostTypeId="2" ParentId="10008" CreationDate="2015-11-18T22:06:00.107" Score="-1" Body="&lt;p&gt;You might be driving the amplifier to its limits, and getting a value at its limits.&lt;/p&gt;&#xA;&lt;p&gt;The INA125 isn't a rail-to-rail amplifier, so if you are wiring it up to ground and +5V as described, its output is limited to be between 0+1V=+1V and 5V-1.7V=+3.3V, so it would be easy to saturate it and bump up against those limits and give you a constant value.&lt;/p&gt;&#xA;&lt;p&gt;If you are using the 10ohm resistor as the INA125 gain, the gain G=4+60000/10=6004x so the input voltage difference needs to be between 0.00016V and 0.00055V volts to be unsaturated within its output linear range.  If it is outside of those limits, the amplifier will act as a comparator.&lt;/p&gt;&#xA;&lt;p&gt;You could check this by putting a voltmeter on the output of the amp and measuring what is is and if it changes.  If it isn't near 2.5V when the scale is unloaded and is saturated at the limit of the amp, then you might need to balance the loadcell closer to zero so it doesn't peg the scale, or reduce the amplification.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2021-12-06T15:11:05.637" LastActivityDate="2021-12-06T15:11:05.637" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="17894" PostTypeId="2" ParentId="16793" CreationDate="2015-11-18T22:24:48.267" Score="0" Body="&lt;p&gt;A load beam cell would be good.  Put it as one leg of your robot, and calibrate it with the arm in a particular location dangling over the cell.   You'd need the beam load cell, and an instrumentation op amp, or HX711 (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide&lt;/a&gt;) to do the interfacing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also good would be the cells from a bathroom scale as the four feet -- you could hook them up like &lt;a href=&quot;https://electronics.stackexchange.com/a/199907/30711&quot;&gt;https://electronics.stackexchange.com/a/199907/30711&lt;/a&gt; or &lt;a href=&quot;https://electronics.stackexchange.com/a/199470/30711&quot;&gt;https://electronics.stackexchange.com/a/199470/30711&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing cool about using the robot feet for measurement is that you could calibrate for more sensitive measurements while reaching far from the base, and rougher measurements closer.  You could also calculate how far you could reach without toppling over.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-11-18T22:24:48.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17895" PostTypeId="1" AcceptedAnswerId="17984" CreationDate="2015-11-18T22:39:24.817" Score="0" ViewCount="72" Body="&lt;p&gt;I need a small display with ~ 5 digits.&#xA;The display needs to show number of visits to my site in real-time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Every time someone visits it needs to increase by one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought to create an app, that fetches server stats every 10 seconds, and checks new number of visitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you think it is better to do with Arduino or Raspberry Pi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know of a digits monitor that can be connected to it?&lt;/p&gt;&#xA;" OwnerUserId="14926" LastEditorUserId="3917" LastEditDate="2015-11-26T01:21:08.173" LastActivityDate="2015-11-26T01:21:08.173" Title="Connect Digital monitor to Arduino?" Tags="|programming|web-server|display|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17896" PostTypeId="2" ParentId="17868" CreationDate="2015-11-18T23:05:05.820" Score="0" Body="&lt;p&gt;Possibly the boot-loader baud rate in the IDE's &lt;code&gt;boards.txt&lt;/code&gt; file is wrong. I have older (less than 6 years) '328p chips whose boot-loaders expect 57600 baud, but the boards.txt file in more recent Arduino IDE's try to talk to them at 115200 baud. I've had to duplicate the Arduino Uno entry in boards.txt and make one that specifies 57600 baud, to use these chips.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-11-19T01:12:54.433" LastActivityDate="2015-11-19T01:12:54.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17897" PostTypeId="2" ParentId="1794" CreationDate="2015-11-18T23:38:47.587" Score="1" Body="&lt;p&gt;@ryeager's link to &lt;a href=&quot;http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/#comment-71836&quot; rel=&quot;nofollow&quot;&gt;http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/#comment-71836&lt;/a&gt; has this code for reading the Arduino's battery voltage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long readVcc() {&#xA;  // Read 1.1V reference against AVcc&#xA;  // set the reference to Vcc and the measurement to the internal 1.1V reference&#xA;  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);&#xA;  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)&#xA;    ADMUX = _BV(MUX5) | _BV(MUX0);&#xA;  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)&#xA;    ADMUX = _BV(MUX3) | _BV(MUX2);&#xA;  #else&#xA;    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);&#xA;  #endif  &#xA;&#xA;  delay(2); // Wait for Vref to settle&#xA;  ADCSRA |= _BV(ADSC); // Start conversion&#xA;  while (bit_is_set(ADCSRA,ADSC)); // measuring&#xA;&#xA;  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  &#xA;  uint8_t high = ADCH; // unlocks both&#xA;&#xA;  long result = (high&amp;lt;&amp;lt;8) | low;&#xA;&#xA;  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000&#xA;  return result; // Vcc in millivolts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick here is that it measures its internal reference of 1.1V using the battery voltage, and then inverts it to calculate the unknown reference voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ADMUX magic in this code can enable other interesting ADC readings, such as differential measurements, and differential ADC measurements with gain, depending on the component and datasheet.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-11-18T23:38:47.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17898" PostTypeId="1" AcceptedAnswerId="17900" CreationDate="2015-11-19T00:38:29.403" Score="2" ViewCount="1128" Body="&lt;p&gt;I'm just wondering why the VIN would require 7-12 volts when the USB port itself only requires 5 volts? What happens if you power an Uno on VIN with 5 volts?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="13972" LastEditDate="2015-11-19T01:16:27.677" LastActivityDate="2015-11-19T01:16:27.677" Title="On the Uno, why does VIN require 7-12 volts and the USB only 5 volts?" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17899" PostTypeId="2" ParentId="17898" CreationDate="2015-11-19T00:56:55.723" Score="0" Body="&lt;p&gt;The UNO takes your input power supply (7-12 volts) and then regulates the voltage down to 5 volts. This way, the UNO operates at a constant voltage regardless if your input power supply wanders about from 7 to 12 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB port,  BY DEFINITION and International Standards, needs to operate at 5 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you apply 5 volts power supply, the UNO won't be able to regulate to 5 volts. The voltage regulator itself will have a voltage drop, and the UNO will operate at less than 5 volts.  The UNO may or may not operate properly. The USB will likely suffer from more problems than the UNO if you apply 5 volts. &#xA;Good news is that the UNO will not likely suffer permanent damage. &lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2015-11-19T00:56:55.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17900" PostTypeId="2" ParentId="17898" CreationDate="2015-11-19T01:09:23.397" Score="3" Body="&lt;p&gt;USB's Vcc pin is assumed to be a stable, 5v supply, and is directly connected to the 5v bus on the Arduino board with no further regulation. Vin is assumed to be an unknown and unregulated voltage in the range of 7-12 volts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 7v minimum is a requirement of the design of the on-board voltage regulator which needs the 2v &quot;head room&quot; to maintain its output at 5v. A 5v power supply could be designed with a larger input range, even including voltages less than 5v, but the simple design used on the board covers a range of sources at a lower cost than a higher-performance power supply.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-11-19T01:09:23.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17901" PostTypeId="1" AcceptedAnswerId="17902" CreationDate="2015-11-19T01:16:13.493" Score="2" ViewCount="466" Body="&lt;p&gt;I have a bench supply which I can use to power a breadboard at 5 V. Is it a bad idea to power the the Arduino by going directly to the 5 V pin? It sounds like both this method, and the USB are unregulated, so there would be no difference. Is it safe? Are there any caveats to this?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They say they &quot;don't advise it&quot;, but why?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastActivityDate="2015-11-19T01:53:49.163" Title="Powering an Arduino UNO through 5V" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17902" PostTypeId="2" ParentId="17901" CreationDate="2015-11-19T01:53:49.163" Score="1" Body="&lt;p&gt;They wouldn't advise it because they provide on board regulation. By feeding it directly you're circumventing their own protection. If however, you're providing your own regulated supply there is no reason why you can't supply it directly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a perfect environment, USB should already be regulated. However given the cheap imported USB hubs and plug packs that are available on the market, I would certainly argue that a good bench power supply is no problems in this regards.&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2015-11-19T01:53:49.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17903" PostTypeId="1" CreationDate="2015-11-19T02:09:51.937" Score="3" ViewCount="7902" Body="&lt;p&gt;I'm trying to implement interrupts in my program. It essentially is constantly reading a photo-resistor and if it exceeds a certain threshold, we should send an update to our database. I'm struggling to understand how to do interrupts on a analog pin. I've tried &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=17450.0&quot; rel=&quot;nofollow&quot;&gt;reading this&lt;/a&gt; but honestly, it doesn't make much sense. Could anyone give me some advice? Here's out code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;  WiFi.begin(ssid, password);&#xA;&#xA;  Serial.print(&quot;Connecting&quot;);&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;WiFi connected&quot;);  &#xA;  Serial.println(&quot;IP address: &quot;);&#xA;  Serial.println(WiFi.localIP());&#xA;&#xA;  // Initally send out false state&#xA;  sendState(&quot;18:FE:34:F4:D0:AF&quot;, false, false);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if(analogRead(A0) &amp;lt; 20) {&#xA;    sendState(&quot;18:FE:34:F4:D0:AF&quot;, false, true);&#xA;    lastState = true;&#xA;    Serial.println(&quot;Waiting....&quot;);&#xA;    delay(15000);&#xA;  } else if(lastState == true){&#xA;    sendState(&quot;18:FE:34:F4:D0:AF&quot;, false, false);&#xA;    lastState = false;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void sendState(String address, boolean lights, boolean occupied) {&#xA;&#xA;  WiFiClient client;&#xA;  const int httpPort = 80;&#xA;  if (!client.connect(host, httpPort)) {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  String lightsStr = (lights) ? &quot;true&quot; : &quot;false&quot;;&#xA;  String occupiedStr = (occupied) ? &quot;true&quot; : &quot;false&quot;;&#xA;  String json = &quot;{\&quot;MACAddress\&quot;:\&quot;&quot; + address + &quot;\&quot;, \&quot;occupied\&quot;:&quot; + occupiedStr + &quot;}&quot;;&#xA;&#xA;  String postData;&#xA;  postData += &quot;POST /sensor HTTP/1.0 \r\n&quot;;&#xA;  postData += &quot;X-Parse-REST-API-Key: &quot; + API_KEY + &quot;\r\n&quot;;&#xA;  postData += &quot;Content-Type: application/json \r\n&quot;;&#xA;  postData += &quot;Host: &quot; + String(host) + &quot; \r\n&quot;;&#xA;  postData += &quot;Content-Length: &quot; + String(json.length()) + &quot;\r\n\r\n&quot;;&#xA;  postData += json;&#xA;&#xA;  // Send the postdata to the server.&#xA;  client.print(postData);&#xA;&#xA;  delay(1000);&#xA;&#xA;  // Read all the lines of the reply from server and print them to Serial&#xA;  while(client.available()){&#xA;    String line = client.readStringUntil('\r');&#xA;    Serial.print(line);&#xA;  }&#xA;&#xA;  Serial.println();&#xA;  Serial.println(&quot;Closing connection!&quot;);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14929" LastActivityDate="2015-11-20T22:00:32.480" Title="Interrupt on Analog Port - ESP8266 w/ Arduino" Tags="|arduino-ide|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17904" PostTypeId="2" ParentId="17903" CreationDate="2015-11-19T02:50:25.983" Score="3" Body="&lt;p&gt;Interrupts are a tricky concept to get, you have to be mindful of so many things (in bigger projects). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a quick look on youtube for some tutorials, there are a heap out there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said all that, your code above isn't using interrupts at all. And you have these big delays, does the code work as published? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest you rework the code into more of a state machine and have a single loop. ditch all the delays (except for your setup, that's fine) and go along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;setup&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;set a variable for current timer value and have a constant defined for your update interval&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;loop&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;read sensor (consider constantly reading, or reading it more often than the information is sent, and average it out)&lt;/li&gt;&#xA;&lt;li&gt;anything on the serial port? &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;go read it&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;check timer against old timer and interval&lt;/li&gt;&#xA;&lt;li&gt;interval exceeded&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;send averaged value&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;using interrupts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You could use interrupts but the thing to consider is that they can be run AT ANY TIME. your code must be interrupt-able which whilst isn't too hard, needs special consideration in relation to delays, reading 16bit values, not having delays in the interrupt, status register changes, a whole host of others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two types of interrupt, those that are driven by a change in input and those that are time based. You don't really want the change in state on this one because you would normally want to monitor it constantly anyway, but it is certainly doable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both time based and external input, you would have the interrupt set a flag that gets acted upon in your main loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;sorry for not providing more info at this time, screaming kids :(&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2015-11-19T03:04:46.800" LastActivityDate="2015-11-19T03:04:46.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17905" PostTypeId="1" CreationDate="2015-11-19T06:55:38.033" Score="-3" ViewCount="153" Body="&lt;p&gt;I want to start a new project with arduino uno and want to make some amazing mini projects, but i am confused that from where should i buy. So please suggest me some affordable robotic stores.&lt;/p&gt;&#xA;" OwnerUserId="14510" LastEditorUserId="14510" LastEditDate="2015-11-19T09:08:54.583" LastActivityDate="2015-11-19T09:22:33.573" Title="Suggest me some good seller for Arduino UNO" Tags="|arduino-uno|robotics|project|" AnswerCount="2" CommentCount="1" ClosedDate="2015-11-20T22:57:41.557" ContentLicense="CC BY-SA 3.0" />
  <row Id="17906" PostTypeId="2" ParentId="17905" CreationDate="2015-11-19T08:09:48.113" Score="2" Body="&lt;p&gt;I recently bought some arduino nano V3 on Aliexpress. It cost me €1.75,- so I immediately bought 4 :P arrived within 10 days. Also the arduino uno R3 (non-official) is only €3,-. Worth the try? I would say definitely, because if you need it for a project you want to leave it in not take it out because you have another idea. Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="14933" LastActivityDate="2015-11-19T08:09:48.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17907" PostTypeId="2" ParentId="17905" CreationDate="2015-11-19T08:42:32.247" Score="2" Body="&lt;p&gt;&lt;strong&gt;&lt;em&gt;I would comment, but my rep is not high enough so consider this a comment:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Welcome to StackExchange. You should maybe take a look at some guidelines on how to ask good questions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;First of all:&lt;/strong&gt; mind your tune! ASAP in capitals is very impolite and implies a request we MUST fulfil - no we don't. Try to use please and thank you and everyone will be happy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Second:&lt;/strong&gt; this is a Q&amp;amp;A Site to help people now and in the future, so most of the time questions like: where can I buy this or what book is good are not what this is made for because they won't be valid for very long and have been asked many times before (but answers lost their validity as mentioned above). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;and last but not least:&lt;/strong&gt; Google it. Ebay, Aliexpress, Amazon... whatever you fancy. There are many Arduino clones for low prices around. I bought a few UNOs for like 6€ each. They work fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind: welcome again. I hope you find many useful answers around. &lt;/p&gt;&#xA;" OwnerUserId="14004" LastActivityDate="2015-11-19T08:42:32.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17910" PostTypeId="2" ParentId="17830" CreationDate="2015-11-19T11:40:19.853" Score="0" Body="&lt;p&gt;I think the problem is more going to be that you don't have a serial connection to the arduino. ie, if you look in the Arduino IDE, you assign a serial port to the application. When you upload your sketch, a connection is made, the arduino resets (by design) and your sketch is uploaded. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it appears you are doing here is opening a new connection and sending the character (which is &lt;code&gt;ASCII&lt;/code&gt;) which in turn sends the arduino into reboot to look out for a sketch being uploaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not familiar with &lt;code&gt;popen&lt;/code&gt; and maybe you can use it and keep the connection open and even monitor the data stream, but I would say instead of writing directly to the device as you've done, use an application that will initialise the port properly (ie open it and leave it open) so that you can continue to use/monitor it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick google search has brought up &lt;a href=&quot;http://pbxbook.com/other/mac-tty.html&quot; rel=&quot;nofollow&quot;&gt;Mike's PBX Cookbook&lt;/a&gt; which has some good info about it. I've personally used &lt;code&gt;minicom&lt;/code&gt; (&lt;a href=&quot;http://hints.macworld.com/article.php?story=20041026113304907&quot; rel=&quot;nofollow&quot;&gt;a guide for installing minicom&lt;/a&gt;) and &lt;a href=&quot;http://freeware.the-meiers.org/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;CoolTerm&lt;/code&gt;&lt;/a&gt;, I have used &lt;code&gt;Screen&lt;/code&gt; but it was so long ago I don't remember why I moved on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;edit: I just followed the link submitted by the first commenter (sorry name not available in the edit screen), and although you've responded with &quot;that's not it&quot;, it actually is, you just haven't realised it since your &lt;code&gt;popen&lt;/code&gt; command is actually opening the port and triggering the RTS mentioned in that post&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2015-11-19T12:04:36.117" LastActivityDate="2015-11-19T12:04:36.117" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17911" PostTypeId="1" CreationDate="2015-11-19T12:10:53.100" Score="0" ViewCount="2034" Body="&lt;p&gt;I made an object named &quot;mySerial&quot; like this.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;SoftwareSerial mySerial(2,3) //pin 2 = RX, pin 3 = TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;also I made pin 13 periodically(0.5 seconds) blink(HIGH/LOW),&#xA;then the signal from pin 13 goes directly to pin 2 and pin 0(basic RX pin of UNO). I connected pin 0,2,13 directly with jumper wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and in the setup(), I wrote&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Serial.begin(9600);&#xA;&#xA;mySerial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in the loop(), I wrote&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite(13, HIGH);&#xA;delay(500);&#xA;digitalWrite(13, LOW);&#xA;delay(500);&#xA;&#xA;if(mySerial.available()){&#xA;    mySerial.println(&quot;mySerial!&quot;);&#xA;}&#xA;if(Serial.available()){&#xA;    Serial.println(&quot;Serial!&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I compile this code and operate arduino, &#xA;I can only see the &quot;Serial!&quot; on the serialmonitor. &#xA;I think this means that the pin 0 can recognize the signal but the pin 2 cant'&#xA;How can I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find what I've missed. Please help me guys!&lt;/p&gt;&#xA;" OwnerUserId="14937" LastEditorUserId="4131" LastEditDate="2016-01-18T17:58:35.000" LastActivityDate="2016-01-18T17:58:35.000" Title="How can I see the mySerial.print( ) through the serialmonitor on IDE?" Tags="|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17912" PostTypeId="2" ParentId="17874" CreationDate="2015-11-19T12:31:05.483" Score="0" Body="&lt;p&gt;(as suggested in comments to bump it down)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;your code works ok with me. I've shorted the 3.3v to analog A0 and your code fluctuates between 679~680 in processing &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cqhhi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cqhhi.jpg&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, this is the software versions I'm using: Processing - 3.0.1 Arduino IDE - 1.6.6 Firmata - 2.5.0&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-11-19T12:31:05.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17913" PostTypeId="2" ParentId="17911" CreationDate="2015-11-19T12:31:16.907" Score="1" Body="&lt;p&gt;Not the most scientific of approaches, and fundamentally flawed at any rate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've toggled the input twice over the period of one second, hardly an emulation of any serial port transmission and so one is letting you know there's been a change of state, the other is letting you know that it hasn't received any valid data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, when you attempt to read the port both will/should correctly give you nothing as a result because there was never anything there to begin with, nor is there anything coming in at the time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to test serial port comms like this, you are going to have to make a sketch for each scenario and use a real device to test it (like your actual serial port thru the Arduino IDE). Run some test, print the results and upload your second sketch and do it again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could even get a bit fancy and have a bit of fun with this and send a command to the arduino to turn off one serial port and turn the other one on, but that's got nothing to do with what you asked, so I won't be writing the code for that here ;)&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2015-11-19T12:31:16.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17914" PostTypeId="1" CreationDate="2015-11-19T13:54:07.897" Score="0" ViewCount="1125" Body="&lt;p&gt;Is there a way to adjust the duty cycle (PWM) based upon input gained by a sensor. For example, if the sensor picks up a really high value, it would increase the duty cycle for an LED making it brighter. Can we also do this task without a potentiometer? Can all of this be done &quot;hands-free&quot; by the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="13691" LastActivityDate="2017-12-16T14:56:28.247" Title="PWM help (input changing duty cycle)" Tags="|arduino-uno|pwm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17915" PostTypeId="1" CreationDate="2015-11-19T13:56:23.143" Score="0" ViewCount="1075" Body="&lt;p&gt;I am creating a moving robot which needs to know its exact position on the map(known before, start point also known). My ideas were : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GPS : this is not accurate enough for me, does not work indoors&lt;/li&gt;&#xA;&lt;li&gt;Acc + GYRO + Compass(Magnetometer): MPU-9150 : from that values I could compute the position but as small errors are continuously added after a while it becomes very inaccurate&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally my idea is to put some fixed points into the area and robot can periodically check where they are and compute its position accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I did some googlin' I could not find any appropriate sensor pair to do this. My idea is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one(more if no other option) sensor on robot covering 360 degrees&lt;/li&gt;&#xA;&lt;li&gt;few fixed points which sends a signal; each different one - let's say : I am the point one. I am the point two etc.&lt;/li&gt;&#xA;&lt;li&gt;sensor on a robot is receiving those signals and give me some meaningful value e.g. time from which I can compute the distance from each of the fixed point.&lt;/li&gt;&#xA;&lt;li&gt;10+ meters maximum range is fine for me&lt;/li&gt;&#xA;&lt;li&gt;must be cheap (less than 30$ for all)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Do you have any idea of such sensor pair ?&lt;/li&gt;&#xA;&lt;li&gt;Or other solution which would fit to my needs?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Bonus:&#xA;* The best would be if the fixed points were passive and just reflected the signal sends from robot - but I have no clue if such a thing exist :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any answers/comments.&lt;/p&gt;&#xA;" OwnerUserId="14239" LastEditorUserId="6936" LastEditDate="2016-01-24T21:56:58.040" LastActivityDate="2016-01-24T21:56:58.040" Title="Arduino : distance measurement between fixed points" Tags="|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17918" PostTypeId="1" CreationDate="2015-11-19T14:27:32.063" Score="7" ViewCount="917" Body="&lt;p&gt;I am building a computer for my son (me).  I'm trying to spark his interest in computer technology, so my idea is to drive multiple case lighting effects with a microprocessor or controller.  I went with the arduino over the pi because of simplicity of the system.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several lighting effects I want to drive, simultaneously, and that's where I'm wondering if the arduino is well suited, because the effects need to make use of delay(), and with it being single threaded I'm struggling to figure out how to make each output operate independently.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To give you an idea of what the microcontroller needs to drive simultaneously:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Flicker pattern using random delay values for outer case lighting&lt;/li&gt;&#xA;&lt;li&gt;Heartbeat pattern for CPU cooling block&lt;/li&gt;&#xA;&lt;li&gt;Blacklight / UV LED lighting for coolant lines.&lt;/li&gt;&#xA;&lt;li&gt;Strobing LEDs aimed at the fans to make them look stationary.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Trying to run all these effects in a linear loop with delay() operators just doesn't seem to be feasible.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to get an UNO for each effect?  Or is there a way of making these outputs operate independently?&lt;/p&gt;&#xA;" OwnerUserId="14940" LastActivityDate="2015-11-19T16:27:02.997" Title="Using Arduino for simultaneous lighting effects" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17919" PostTypeId="1" AcceptedAnswerId="17928" CreationDate="2015-11-19T14:46:57.547" Score="2" ViewCount="2719" Body="&lt;p&gt;I am new with coding, and I was wondering how I could run something once and define it as a constant. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue1 = analogRead(A0);  &#xA;int sensorValue2 = analogRead(A1);  &#xA;int g0 = 9.81*9.8;  &#xA;int h1 = 48;  &#xA;int R = 287.06;  &#xA;int a = -0.0065;  &#xA;&#xA;void setup() {   &#xA;    Serial.begin(9600);  &#xA;    int p1 = (1.09512*sensorValue2-22.105)*133.3225;  &#xA;    int t1 = (-0.08126*sensorValue1+65.6597)*274.15;  &#xA;}&#xA;&#xA;void loop() {&#xA;    String t = &quot;Temperature:    &quot;;  &#xA;    String tt = &quot; Celsius&quot;;  &#xA;    String p = &quot;Preassure:    &quot;;  &#xA;    String pp = &quot; Pascal&quot;;&#xA;    float celsius = -0.08126*sensorValue1+65.6597;     &#xA;    float kelvin = celsius*274.15;&#xA;    float pascal = (1.09512*sensorValue2-22.105)*133.3225;  &#xA;    float height = (t1/a)*((pascal/p1)^((a*R)/g0))-1)+h1;  &#xA;    Serial.println(t+celsius+tt);  &#xA;    Serial.println(p+pascal+pp);  &#xA;    Serial.println(kelvin);  &#xA;    Serial.println( );  &#xA;    Serial.println(height);  &#xA;    delay(1000);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14941" LastEditorUserId="4628" LastEditDate="2015-11-21T05:07:25.967" LastActivityDate="2015-11-21T05:07:25.967" Title="How do I set a constant in setup() that I can use in loop()?" Tags="|arduino-uno|code-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17920" PostTypeId="2" ParentId="17832" CreationDate="2015-11-19T14:50:35.903" Score="0" Body="&lt;p&gt;You reeeally don't want to draw current through your controller board.  It's best to use a transistor power circuit, or 741 op-amp, or relay.  Keep your power delivery separate from your control system.&lt;/p&gt;&#xA;" OwnerUserId="14940" LastActivityDate="2015-11-19T14:50:35.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17921" PostTypeId="1" AcceptedAnswerId="17925" CreationDate="2015-11-19T14:54:58.347" Score="0" ViewCount="531" Body="&lt;p&gt;My sensor outputs an int. I would like this to be an array of strings so I can send it with my 433MHz transmitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Converting an int to a string to an array of strings seems to be extremely complicated. I've tried multiple approaches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error is always:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;array must be initialized with a brace-enclosed initializer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;const int led_pin = 11;&#xA;const int transmit_pin = 12;&#xA;const int receive_pin = 2;&#xA;const int transmit_en_pin = 3;&#xA;int mostureSensor = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialise the IO and ISR&#xA;  vw_set_tx_pin(transmit_pin);&#xA;  vw_set_rx_pin(receive_pin);&#xA;  vw_set_ptt_pin(transmit_en_pin);&#xA;  vw_set_ptt_inverted(true); // Required for DR3100&#xA;  vw_setup(1000);   // Bits per sec&#xA;}&#xA;&#xA;byte count = 1;&#xA;&#xA;void loop()&#xA;{&#xA;  // read the input on analog pin 0:&#xA;  String sensorValue = String(analogRead(mostureSensor));&#xA;&#xA;  char charBuf[7];&#xA;  char msg[7] = sensorValue.toCharArray(charBuf, 7);&#xA;&#xA;  //char msg[7] = {'h','a','l','l','o',' ','#'};&#xA;  Serial.println(&quot;sending&quot;);&#xA;  msg[6] = count;&#xA;  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting&#xA;  vw_send((uint8_t *)msg, 7);&#xA;  vw_wait_tx(); // Wait until the whole message is gone&#xA;  digitalWrite(led_pin, LOW);&#xA;  delay(1000);&#xA;  count = count + 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14790" LastActivityDate="2015-11-19T15:18:47.713" Title="Convert INT to Array of Strings" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17922" PostTypeId="2" ParentId="17919" CreationDate="2015-11-19T15:08:40.850" Score="1" Body="&lt;p&gt;You can define Constants using the &quot;const&quot; keyword. Ex:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    const float pi = 3.14;&#xA;    const int foo = 12;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Const&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Const&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14942" LastActivityDate="2015-11-19T15:08:40.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17923" PostTypeId="2" ParentId="17914" CreationDate="2015-11-19T15:14:55.847" Score="1" Body="&lt;p&gt;The example at the bottom of this Arduino reference page does exactly that. If you want to change the way the value varies, you can just modify the variables in a loop or in whatever approach you prefer instead of analogread'ing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/AnalogWrite&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14942" LastActivityDate="2015-11-19T15:14:55.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17924" PostTypeId="1" AcceptedAnswerId="17927" CreationDate="2015-11-19T15:18:37.500" Score="1" ViewCount="274" Body="&lt;p&gt;I have a Problem with my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Goal is to receive a Ethernet message via UDP and send the message back via CAN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works fine but only with the first packet I send. When I send the same packet again there is no Response as you can see in the screenshot.&#xA;I´m using the Arduino Due with a Transceiver. The Programm which sends and reads the Messages is Vector Canoe&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;variant.h&quot;&#xA;#include &quot;due_can.h&quot;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;        &#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp.h&amp;gt; &#xA;&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;IPAddress ip(192, 168, 1, 177);&#xA;&#xA;unsigned int localPort = 8888;      // local port to listen on&#xA;&#xA;// buffers for receiving and sending data&#xA;char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,&#xA;&#xA;&#xA;EthernetUDP Udp;&#xA;&#xA;void setup() {&#xA;&#xA;Can0.init(250000);&#xA;Serial.begin(9600);&#xA;&#xA;Ethernet.begin(mac, ip);&#xA;Udp.begin(localPort);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    int packetSize = Udp.parsePacket();&#xA;    Udp.read(packetBuffer,packetSize);&#xA;&#xA;   if (packetSize)&#xA;  {&#xA;&#xA;    int Canframestosend= packetSize/8;    //Divides the Ethernet packet by 8 to match with CAN packet&#xA;    int count =0;&#xA;    int Rest=packetSize%8;                //Needed if the Ethernet packetsize isn´t a multiple of 8 &#xA;&#xA;&#xA;    for(int j=0;j&amp;lt;=Canframestosend;j++){&#xA;&#xA;    CAN_FRAME NewFrame;                   //CAN frames which are sent&#xA;    NewFrame.id=0xFA;                     //ID of the frames&#xA;    NewFrame.length=8;                    //Maximum of bytes a Can frame can have&#xA;&#xA;    for (int i=0;i&amp;lt;8;i++){&#xA;&#xA;       NewFrame.data.byte[i] = packetBuffer[count]; //Write the Ethernet info byte by byte on the CAN frames&#xA;       count++;&#xA;       }&#xA;    if(packetSize&amp;lt;count){&#xA;      NewFrame.length=Rest;                         //Shortens the last frame to avoid unnessecary zeros&#xA;      }&#xA;       Can0.sendFrame(NewFrame);&#xA;&#xA;      }     &#xA;&#xA;   }&#xA;   delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe there is an endless Loop but I don´t know which and why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope anybody can help me with that!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sOZGC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sOZGC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14943" LastEditorUserId="6628" LastEditDate="2015-11-19T17:07:49.467" LastActivityDate="2015-11-20T17:04:41.277" Title="Arduino sketch does not repeat" Tags="|arduino-due|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17925" PostTypeId="2" ParentId="17921" CreationDate="2015-11-19T15:18:47.713" Score="1" Body="&lt;p&gt;toCharArray is a method. It will copy the value from SensorValur to charBuff, it won't return the char array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; char msg[7] = sensorValue.toCharArray(charBuf, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; sensorValue.toCharArray(charBuf, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;charBuf will already have the sensorValue copied.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check more about &quot;toCharArray&quot; method :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/StringToCharArray&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/StringToCharArray&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14766" LastActivityDate="2015-11-19T15:18:47.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17926" PostTypeId="2" ParentId="8615" CreationDate="2015-11-19T15:21:07.917" Score="0" Body="&lt;p&gt;If you want to send your data directly from Matlab to the Arduino, you can try using the &quot;Matlab Arduino Support package&quot;. It lets you read/write pins on the arduino directly from Matlab command line or script just like you would with a VERY LOW END Data Acquisition card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has the advantage of removing the burden of managing the serial communication. I don't know how it handles large numbers though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mathworks.com/hardware-support/arduino-matlab.html?refresh=true&quot; rel=&quot;nofollow&quot;&gt;http://www.mathworks.com/hardware-support/arduino-matlab.html?refresh=true&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14942" LastActivityDate="2015-11-19T15:21:07.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17927" PostTypeId="2" ParentId="17924" CreationDate="2015-11-19T15:41:53.417" Score="0" Body="&lt;p&gt;I'd guess it's in the if(packetsize) logic -- if you get a packetsize of zero, you still try to read into a zero-size buffer and who knows what would happen.  Move the read inside the if(){...}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Reference/EthernetUDPRead&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/EthernetUDPRead&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you want to limit the reading to the UDP_TX_PACKET_MAX_SIZE size of the buffer, not to the size of the packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: The UDP_TX_PACKET_MAX_SIZE is only used in the user code, and nowhere else within the Ethernet Library.  You could use a larger buffer if you need to by defining and allocating a larger buffer and specifying its size in  EthernetUDP.read()  (see &lt;a href=&quot;https://www.arduino.cc/en/Reference/EthernetUDPRead&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/EthernetUDPRead&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2015-11-20T17:04:41.277" LastActivityDate="2015-11-20T17:04:41.277" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17928" PostTypeId="2" ParentId="17919" CreationDate="2015-11-19T15:53:37.117" Score="6" Body="&lt;p&gt;You can't, and there's other things wrong with your code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue1 = analogRead(A0);  &#xA;int sensorValue2 = analogRead(A1);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Calling functions from the global scope is an incredibly bad idea.  Those are run &lt;em&gt;before&lt;/em&gt; the board has been properly initialized, and the results you may get from it are not guaranteed in any way, shape, or form.  Instead you must call functions like &lt;code&gt;analogRead()&lt;/code&gt; from within another function, like &lt;code&gt;setup()&lt;/code&gt;, or &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for &lt;code&gt;const&lt;/code&gt; - a &lt;code&gt;const&lt;/code&gt; is just that - a constant value that can &lt;strong&gt;never&lt;/strong&gt; change.  You can only assign a value to it at the moment of creation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that means that you can only use it within the &lt;em&gt;scope&lt;/em&gt; it was defined within.  As you can't do that in the global scope (see above) then you &lt;em&gt;cannot&lt;/em&gt; use a constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So just use a normal global variable.  It will only change when you tell it to change.  Using a &lt;code&gt;const&lt;/code&gt; only makes sense when you have a &lt;em&gt;numeric literal&lt;/em&gt; that you want to refer to by name. Using &lt;code&gt;const&lt;/code&gt; doesn't protect the variable from being changed at run-time by memory leaks, etc, it just protects it from attempts to modify it at compile time - and if possible replace it with the numeric literal that it refers to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in summary just use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue1;&#xA;int sensorValue2;&#xA;int p1;&#xA;int t1;&#xA;&#xA;void setup() {&#xA;    sensorValue1 = analogRead(A0);&#xA;    sensorValue2 = analogRead(A1);&#xA;    p1 = (1.09512*sensorValue2-22.105)*133.3225;&#xA;    t1 = (-0.08126*sensorValue1+65.6597)*274.15;&#xA;}&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HOWEVER&lt;/strong&gt;: Your program methodology is also completely flawed.  You read the analog values once, and do calculations with them once, then repeatedly display the same values over and over again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;strong&gt;must&lt;/strong&gt; perform a &lt;em&gt;new&lt;/em&gt; &lt;code&gt;analogRead()&lt;/code&gt; of your sensors every iteration of &lt;code&gt;loop()&lt;/code&gt; in order to update the values in your variables.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-19T15:53:37.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17929" PostTypeId="2" ParentId="17918" CreationDate="2015-11-19T16:01:18.543" Score="6" Body="&lt;p&gt;Avoid delay() and use specific times of next actions and compare them to millis().  For a random time, set something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;now=millis();&#xA;...&#xA;if(nextFlicker &amp;lt; now) {&#xA;   toggleFlicker();&#xA;   nextFlicker=now+random(10000);&#xA;}&#xA;if(nextPulse &amp;lt; now) {&#xA;   nextPulse=now+ isPulseOn? 100 : 1000 ;&#xA;   togglePulse();&#xA;}&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are running more than the 50 day roll-over time of millis(), you may need some care to handle the overflows.  See &lt;a href=&quot;http://playground.arduino.cc/Code/TimingRollover&quot;&gt;http://playground.arduino.cc/Code/TimingRollover&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the strobing leds, investigate the timer-controlled outputs outputs.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-11-19T16:01:18.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17930" PostTypeId="2" ParentId="17915" CreationDate="2015-11-19T16:10:48.490" Score="2" Body="&lt;p&gt;Seems to me you are looking for some kinda of SLAM thing. Depending on your knowledge in control theory and your precision goals you can go from simple rotary encoders on wheels to multiple sensor fusion like Extended Kalman filters (&lt;a href=&quot;https://www.youtube.com/watch?v=WRwLwovntvk&amp;amp;list=PL2FC300FEFF72587A&amp;amp;index=1&quot; rel=&quot;nofollow&quot;&gt;example videos&lt;/a&gt;). Probably the most precise thing you can have is sensor fusion with LIDAR (can be achieved precisions like 1cm), however the price range is way to far from described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would start with a small approach and go from there depending on the results I'd get:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;rotary encoders (easy to calibrate and can be precise enough as a starting point)&lt;/li&gt;&#xA;&lt;li&gt;9DOF IMU (use a Extended Kalman filter or similar to make an AHRS correction). And in this part I have many advices. You have suggested MPU-9150. I'm not familiar with it but looking at datasheet it seems very good, specially because gyro comes factory calibrated. In past I've used razor IMU / GY-85 (adlx345 + ITG3200 + HMC5883L) and gyro was very precise and low noise. Hope Invesense used the same sensor in MPU . First in hardware: Acc are easy to calibrate just use gravity. Gyros are easy to calibrate but hard to do. Why, because it may be hard to get something that spins at constant RPM and know that value. But as I've said, according to datasheet, MPU comes factory calibrated. Magnetometers calibration can be a bit tricky. Bottom line is you get readings from various points of your robot  in 3D space. you plot all and you will get an ellipsoid. Then you find a transformation equation that maps the ellipsoid into a perfect sphere take a look &lt;a href=&quot;http://www.freescale.com/files/sensors/doc/app_note/AN4246.pdf&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt;. Your concerns about Angle random walk can be minimized with kalman filter and similar. &lt;a href=&quot;http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/&quot; rel=&quot;nofollow&quot;&gt;This page&lt;/a&gt; provides much great information and examples in how to make a good AHRS. Mr. Madgwick wrote a really nice algorithm that implements the IMU  filter and have it also written in C (nice for Arduino).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After integrate all things with Kalman and see the results, if things are not good enough, you can add more sensor and provide a better estimation for example: sonars, rangefinders, landmarks with image processing and as suggested also, RSSI and triangulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These links might help you in finding your way:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://web.eecs.utk.edu/~leparker/Courses/CS594-fall08/Lectures/Nov-20-Localization-Mapping-III.pdf&quot; rel=&quot;nofollow&quot;&gt;Introduction to Kalman Filters and SLAM&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://cdn.intechopen.com/pdfs-wm/13525.pdf&quot; rel=&quot;nofollow&quot;&gt;Indoor Location Tracking using Received Signal Strength Indicator&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6936" LastEditDate="2016-01-24T21:55:53.410" LastActivityDate="2016-01-24T21:55:53.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17931" PostTypeId="2" ParentId="17918" CreationDate="2015-11-19T16:27:02.997" Score="2" Body="&lt;p&gt;Base the pattern on time, instead of using delays. E.g. if the current time in seconds if odd, the led should be on. If it's even it should be off. This creates a blinking led effect without using any delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long seconds = millis()/1000;&#xA;if( (seconds % 2)==0 )// even&#xA;  digitalWrite(led, HIGH);&#xA;else // odd&#xA;  digitalWrite(led, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;E.g. to have it blink faster, change &lt;code&gt;1000&lt;/code&gt; to a lower value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. to make the led be on shorter than of change &lt;code&gt;%2&lt;/code&gt; to e.g. &lt;code&gt;%4&lt;/code&gt; (i.e. 1 second on, 3 seconds off)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-19T16:27:02.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17933" PostTypeId="1" AcceptedAnswerId="17936" CreationDate="2015-11-19T18:23:21.720" Score="1" ViewCount="3923" Body="&lt;p&gt;I am trying to use a class in .ino file. The code is:&#xA; &lt;br/&gt;&lt;br/&gt; .ino file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LED.h&amp;gt;&#xA;&#xA;int Pin1 = 13;&#xA;int Pin2 = 12;&#xA;int Pin3 = 11;&#xA;LED led;&#xA;void setup() {&#xA;  pinMode(Pin1,OUTPUT);&#xA;  pinMode(Pin2,OUTPUT);&#xA;  pinMode(Pin3,OUTPUT);&#xA;  digitalWrite(Pin1,LOW);&#xA;  digitalWrite(Pin2,LOW);&#xA;  digitalWrite(Pin3,LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  led.on(Pin1);&#xA;  delay(2);&#xA;  led.on(Pin2);&#xA;  delay(2);&#xA;  led.on(Pin3);&#xA;  delay(2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.h file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef LED_h&#xA;#define LED_h&#xA;&#xA;class LED{&#xA;public:&#xA;    void on(int);&#xA;    void off(int);&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.cpp file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;LED.h&quot;    &#xA;&#xA;void LED::on(int PIN){&#xA;    digitalWrite(PIN,HIGH);&#xA;}&#xA;&#xA;void LED::off(int PIN){&#xA;    digitalWrite(PIN,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino compiler picks the object declaration error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDC:6: error: 'LED' does not name a type&lt;br/&gt;&#xA;LEDC.ino: In function 'void loop()':&lt;br/&gt;&#xA;LEDC:17: error: 'led' was not declared in this scope&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I declare objects in Arduino then?&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way that I am putting the files in folders is like the attached image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aPIEJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aPIEJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14917" LastEditorUserId="14917" LastEditDate="2015-11-19T20:23:24.443" LastActivityDate="2020-04-04T03:20:01.227" Title="Including Class with .h and .cpp files" Tags="|c++|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17934" PostTypeId="1" CreationDate="2015-11-19T19:09:03.897" Score="2" ViewCount="2231" Body="&lt;p&gt;I am trying to make my Arduino micro-controller and my Mac talk together, and I have created a functional serial connection. My computer is sending data to my Arduino, and my Arduino is sending a &lt;code&gt;1&lt;/code&gt; when it is ready to receive a new piece of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have created an &lt;code&gt;if-else&lt;/code&gt; statement (Python script below), which is either sending a new line of data to the Arduino or waiting for the Arduino to be ready for receiving a new line of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that &lt;code&gt;ser.read()&lt;/code&gt; in the first part of the Python script always returns &lt;code&gt;1&lt;/code&gt;, which means that the script is sending the individual data lines faster than the Arduino connected stepper motors can possible react.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino script you can see that I am sending the state-status in the first line of the &lt;code&gt;serialEvent()&lt;/code&gt; function, which in my world should let the Arduino finish its job, before a new &quot;task&quot; is coming. However, it is for some reason not working. Can anybody help me out here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Python script&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import os&#xA;import time&#xA;import serial&#xA;&#xA;# Name of csv file with drawing coordinates&#xA;csvFile = &quot;scaled_coordinates.csv&quot;&#xA;&#xA;# Create serial connection&#xA;ser = serial.Serial(port='/dev/tty.usbserial-A9005bDh', baudrate=9600)&#xA;&#xA;wd = os.getcwd()&#xA;myFile = open(wd + &quot;/coordinates/&quot; + csvFile)&#xA;&#xA;state = '1'&#xA;&#xA;while True: # Exits when there is no more lines to read&#xA;    print &quot;test&quot;&#xA;&#xA;    if state == '0': # Wait for Arduino to be ready&#xA;        state = ser.read()&#xA;&#xA;    elif state == '1': # Send one more line to Arduino&#xA;        line = myFile.readline()&#xA;        if not line:&#xA;            break&#xA;        print line&#xA;        ser.write(line)&#xA;        state = '0' # Wait for Arduino before reading next line&#xA;&#xA;ser.close&#xA;myFile.close&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino &lt;code&gt;loop&lt;/code&gt; function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  serialEvent(); // Call the serial function&#xA;  if (coord_complete) {&#xA;    // Steps to move from currrent to new point&#xA;    target1 = steps(x_current, y_current, x_new, y_new, 1);&#xA;    target2 = steps(x_current, y_current, x_new, y_new, 2);&#xA;&#xA;    // Start moving&#xA;    stepper1.move(target1);&#xA;    stepper2.move(target2);&#xA;&#xA;    // Update current position&#xA;    x_current = x_new;&#xA;    y_current = y_new;&#xA;&#xA;    // Reset variables&#xA;    x_complete = false;&#xA;    y_complete = false;&#xA;    coord_complete = false;&#xA;  }&#xA;&#xA;  // Stay in while loop until steppermotors is done&#xA;  while ((stepper1.distanceToGo() != 0) &amp;amp;&amp;amp; (stepper2.distanceToGo() != 0)) {&#xA;    stepper1.run();&#xA;    stepper2.run();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino &lt;code&gt;serialEvent&lt;/code&gt; function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent() {&#xA;  // EDIT : PUT SERIAL.WRITE INSIDE IF STATEMENT //&#xA;  if((stepper1.distanceToGo() == 0) &amp;amp;&amp;amp; (stepper2.distanceToGo() == 0)){&#xA;    Serial.write('1'); // Tell Python that Arduino is ready for one more line&#xA;  }      &#xA;&#xA;  while (Serial.available() &amp;amp;&amp;amp; coord_complete == false) {&#xA;    char ch = Serial.read(); // Get new character&#xA;    // EDIT : REMOVE THIS LINE //&#xA;    Serial.print(ch);&#xA;&#xA;    // If digit; add it to coord_string&#xA;    if (isDigit(ch)) {&#xA;      coord_string[index++] = ch;&#xA;&#xA;    // Else if ch is &quot;,&quot;; then rename to x_new&#xA;    } else if (ch == ',') {&#xA;      coord_string[index++] = NULL;  // Finish coord_string&#xA;      x_new = atoi(coord_string);    // Convert to integer&#xA;      x_complete = true;             // Change x_complete to true&#xA;      index = 0;                     // Reset index&#xA;      memset(coord_string, 0, sizeof(coord_string));  // Reset coord_string&#xA;    // Else if ch is a new line; then rename as y_new&#xA;    } else if (ch == ';') {&#xA;      //Serial.write('0');&#xA;      coord_string[index++] = NULL;&#xA;      y_new = atoi(coord_string);&#xA;      y_complete = true;&#xA;      index = 0;&#xA;      memset(coord_string, 0, sizeof(coord_string));&#xA;    }&#xA;&#xA;    // Ends while-loop when true&#xA;    coord_complete = x_complete * y_complete;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Edit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have changed a bit in the first few lines of the &lt;code&gt;serialEvent&lt;/code&gt; function (See comments).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a sample of the text file I am reading from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;239,275;&#xA;1100,275;&#xA;300,400;&#xA;200,400;&#xA;200,300;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14949" LastEditorUserId="4628" LastEditDate="2015-11-21T10:15:16.333" LastActivityDate="2016-10-16T16:31:06.283" Title="How to make data sent by Python (via serial connection) wait for Arduino to finish current task?" Tags="|serial|python|arduino-duemilanove|" AnswerCount="1" CommentCount="1" ClosedDate="2016-10-20T14:28:15.747" ContentLicense="CC BY-SA 3.0" />
  <row Id="17935" PostTypeId="2" ParentId="17915" CreationDate="2015-11-19T19:59:23.933" Score="1" Body="&lt;p&gt;I've been working on this also, and have not found a 100% satisfactory solution. Some ideas I've been throwing around include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using an optical mouse to measure ground distance more accurately. This also subject to cumulative errors.&lt;/li&gt;&#xA;&lt;li&gt;Some sort of radio transmitters&lt;/li&gt;&#xA;&lt;li&gt;A pulse from a magnet, with a compass - these can be highly directional, and could possibly be strength-based, too.&lt;/li&gt;&#xA;&lt;li&gt;I read about one robot competition which had a fixed, overhead camera, picking up infrared LEDs; this is processed by a computer, which would then send the data back (e.g. for bluetooth) to the robot.&lt;/li&gt;&#xA;&lt;li&gt;The same infrared camera trick, but reversed: a camera pointing up, looking for fixed constelation of infrared LEDs on the ceiling - I would expect this to require more processing than an Arduino has, possibly a raspberry pi could do the trick?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-11-19T19:59:23.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17936" PostTypeId="2" ParentId="17933" CreationDate="2015-11-19T20:13:29.463" Score="1" Body="&lt;p&gt;That version of the IDE (it seems to change from version to version) differentiates between includes with &lt;code&gt;&amp;lt;...&amp;gt;&lt;/code&gt; and includes with &lt;code&gt;&quot;...&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;&amp;lt;...&amp;gt;&lt;/code&gt; it only looks in the system and library areas.  If you use &lt;code&gt;&quot;...&quot;&lt;/code&gt; it also looks inside your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in your main INO file change the LED include from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LED.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;LED.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it should compile.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-19T20:13:29.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17937" PostTypeId="2" ParentId="17934" CreationDate="2015-11-19T20:19:24.997" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If I'm getting things right, your program fails in the above:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;when you send the first message in python, you set state = 0. In&#xA;  arduino you enter the serialEvent function and while is triggered. You&#xA;  get the first char and send it through Serial.print (but this char&#xA;  will be send to python!!!). &lt;strong&gt;For the sake of example let's say the&#xA;  first char you get from cvs is '2'&lt;/strong&gt;. At this point let's hold on a&#xA;  sec and look what happens in python. State was '0' but as you have&#xA;  used in arduino &lt;code&gt;Serial.print(ch);&lt;/code&gt; now state will be updated with&#xA;  '2'. This will cause no more triggers of the if-else statements in&#xA;  python.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;edit:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;By now, and also as a debug, add this lines at your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if state == '0': # Wait for Arduino to be ready&#xA;    state = ser.read()&#xA;    if state != '1':&#xA;        print &quot;state: &quot; + state&#xA;        state = '0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;However if csv file contains '1's values this will also cause a&#xA;  problem. Do you really need that &lt;code&gt;Serial.print(ch)&lt;/code&gt; in arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; The new version since comments&#xA;Basically if you are trying to do things before new coordinates, you have to do things in a sequential way. You only ask for info after making all the moves. This is the code I've used to test.&#xA;&lt;strong&gt;Note:&lt;/strong&gt; I had to adapt your code because was missing the complete arduino code to test it. So I kinda simulated the motor moving etc with delays. Please adapt to your original code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;string.h&amp;gt;&#xA;&#xA;bool coord_complete = false;&#xA;byte stepper1_disToGo = 0, stepper2_disToGo = 0;&#xA;// debug things&#xA;int led = 13;&#xA;bool led_state = true, x_complete, y_complete;&#xA;char coord_string[256];&#xA;int index = 0, x_new = 0, y_new = 0;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(led, OUTPUT);&#xA;  memset(&amp;amp;coord_string, 0, sizeof(coord_string));&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  serialData(); //ask and process more data&#xA;&#xA;  /*&#xA;    // Steps to move from currrent to new point&#xA;    target1 = steps(x_current, y_current, x_new, y_new, 1);&#xA;    target2 = steps(x_current, y_current, x_new, y_new, 2);&#xA;&#xA;    // Start moving&#xA;    stepper1.move(target1);&#xA;    stepper2.move(target2);&#xA;&#xA;    // Update current position&#xA;    x_current = x_new;&#xA;    y_current = y_new;&#xA;&#xA;    // Reset variables&#xA;    x_complete = false;&#xA;    y_complete = false;&#xA;  */&#xA;  delay(2000); //replace to simulate actions&#xA;  stepper1_disToGo = 10;&#xA;  stepper2_disToGo = 10;&#xA;  coord_complete = false;&#xA;&#xA;  // replaced to simulate&#xA;  /*&#xA;    // Stay in while loop until steppermotors is done&#xA;    while ((stepper1.distanceToGo() != 0) &amp;amp;&amp;amp; (stepper2.distanceToGo() != 0)) {&#xA;    stepper1.run();&#xA;    stepper2.run();&#xA;    }&#xA;  */&#xA;  while ((stepper1_disToGo != 0) || (stepper2_disToGo != 0)) {&#xA;    stepper1_disToGo --;&#xA;    stepper2_disToGo --;&#xA;    digitalWrite(led, led_state); // is moving!!!!&#xA;    delay(100);&#xA;    led_state = !led_state;&#xA;  }&#xA;}&#xA;&#xA;/*&#xA;   you try to use the serialEvent  but the structure of&#xA;   your code and the verifications make it act like sequential.&#xA;   If you only want to make things after all steps are done there&#xA;   is no need for the serialEvent function&#xA;*/&#xA;void serialData() {&#xA;  /*&#xA;     This will never be false because you are stuck in the while&#xA;&#xA;    // EDIT : PUT SERIAL.WRITE INSIDE IF STATEMENT //&#xA;    if((stepper1.distanceToGo() == 0) &amp;amp;&amp;amp; (stepper2.distanceToGo() == 0)){&#xA;    Serial.write('1'); // Tell Python that Arduino is ready for one more line&#xA;    }&#xA;  */&#xA;  //EDIT: wait for info&#xA;  while (Serial.available() &amp;lt; 1) {&#xA;    Serial.write('1'); /// Tell Python that Arduino is ready for one more line&#xA;    delay(500);// ask for info sometimes&#xA;  }&#xA;  while (Serial.available()) {&#xA;    char ch = Serial.read(); // Get new character&#xA;&#xA;    // If digit; add it to coord_string&#xA;    if (isDigit(ch)) {&#xA;      coord_string[index++] = ch;&#xA;&#xA;      // Else if ch is &quot;,&quot;; then rename to x_new&#xA;    } else if (ch == ',') {&#xA;      coord_string[index++] = NULL;                   // Finish coord_string&#xA;      x_new = atoi(coord_string);                     // Convert to integer&#xA;      x_complete = true;                              // Change x_complete to true&#xA;      index = 0;                                      // Reset index&#xA;      memset(coord_string, 0, sizeof(coord_string));  // Reset coord_string&#xA;&#xA;      // Else if ch is a new line; then rename as y_new&#xA;    } else if (ch == ';') {&#xA;      coord_string[index++] = NULL;&#xA;      y_new = atoi(coord_string);&#xA;      y_complete = true;&#xA;      index = 0;&#xA;      memset(coord_string, 0, sizeof(coord_string));&#xA;    }&#xA;    //EDIT: change to AND verification&#xA;    // Ends while-loop when true&#xA;    coord_complete = x_complete &amp;amp;&amp;amp; y_complete;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The structure of your loop should be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;ask for data and wait for it&lt;/li&gt;&#xA;&lt;li&gt;Read data and parse it&lt;/li&gt;&#xA;&lt;li&gt;Calculate steps needed&lt;/li&gt;&#xA;&lt;li&gt;move servos till new positions&lt;/li&gt;&#xA;&lt;li&gt;repeat&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;this should be your new code more or less if no mistakes were made because can't really test this version (is missing the variables declarations setup, includes etc...)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;&#xA;  serialData(); //ask and process more data&#xA;  // Steps to move from currrent to new point&#xA;  target1 = steps(x_current, y_current, x_new, y_new, 1);&#xA;  target2 = steps(x_current, y_current, x_new, y_new, 2);&#xA;&#xA;  // Start moving&#xA;  stepper1.move(target1);&#xA;  stepper2.move(target2);&#xA;&#xA;  // Update current position&#xA;  x_current = x_new;&#xA;  y_current = y_new;&#xA;&#xA;  // Reset variables&#xA;  x_complete = false;&#xA;  y_complete = false;&#xA;  coord_complete = false;&#xA;&#xA;  // Stay in while loop until steppermotors is done&#xA;  while ((stepper1.distanceToGo() != 0) &amp;amp;&amp;amp; (stepper2.distanceToGo() != 0)) {&#xA;    stepper1.run();&#xA;    stepper2.run();&#xA;  }&#xA;}&#xA;&#xA;void serialData() {&#xA;&#xA;  //EDIT: wait for info&#xA;  while (Serial.available() &amp;lt; 1) {&#xA;    Serial.write('1'); /// Tell Python that Arduino is ready for one more line&#xA;    delay(500);// ask for info sometimes&#xA;  }&#xA;  // we got info!!!&#xA;  while (Serial.available()) {&#xA;    char ch = Serial.read(); // Get new character&#xA;&#xA;    // If digit; add it to coord_string&#xA;    if (isDigit(ch)) {&#xA;      coord_string[index++] = ch;&#xA;&#xA;      // Else if ch is &quot;,&quot;; then rename to x_new&#xA;    } else if (ch == ',') {&#xA;      coord_string[index++] = NULL;                   // Finish coord_string&#xA;      x_new = atoi(coord_string);                     // Convert to integer&#xA;      x_complete = true;                              // Change x_complete to true&#xA;      index = 0;                                      // Reset index&#xA;      memset(coord_string, 0, sizeof(coord_string));  // Reset coord_string&#xA;&#xA;      // Else if ch is a new line; then rename as y_new&#xA;    } else if (ch == ';') {&#xA;      coord_string[index++] = NULL;&#xA;      y_new = atoi(coord_string);&#xA;      y_complete = true;&#xA;      index = 0;&#xA;      memset(coord_string, 0, sizeof(coord_string));&#xA;    }&#xA;    //EDIT: change to AND verification&#xA;    // Ends while-loop when true&#xA;    coord_complete = x_complete &amp;amp;&amp;amp; y_complete;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2015-11-21T00:37:00.430" LastActivityDate="2015-11-21T00:37:00.430" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17938" PostTypeId="1" AcceptedAnswerId="17945" CreationDate="2015-11-19T20:35:46.063" Score="0" ViewCount="16974" Body="&lt;p&gt;I have an external device using an &lt;strong&gt;ATmega328&lt;/strong&gt;, not a &lt;strong&gt;ATmega328-P&lt;/strong&gt; as used by the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to use &lt;strong&gt;AVRDUDE&lt;/strong&gt; and an Arduino Uno to flash a hex file on this chip. Therefore I removed the ATmega that came with the Arduino and popped in the one without the &quot;-P&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the Arduino IDE, it doesn't work, so I tried AVRDUDE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c arduino -P com3 -p ATMEGA328 -b 19200 -U flash:r:sdint.hex:r&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I'm doing something wrong here, because it does not work:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding&lt;br /&gt;&#xA;  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&lt;br /&gt;&#xA;  avrdude: stk500_recv(): programmer is not responding&lt;br /&gt;&#xA;  avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&lt;br /&gt;&#xA;  ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What commandline should I use to flash an Arduino Uno with an ATmega328?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="8762" LastEditorUserId="8762" LastEditDate="2015-11-19T21:03:20.670" LastActivityDate="2015-11-22T19:37:21.343" Title="How to flash the &quot;atmega328&quot; with AVRDUDE?" Tags="|arduino-uno|atmega328|avrdude|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17939" PostTypeId="1" AcceptedAnswerId="17943" CreationDate="2015-11-19T21:36:10.557" Score="2" ViewCount="7054" Body="&lt;p&gt;I am looking for a way to create an adjustable PWM controller capable of modulation frequency from 0-100 (more preferably 0-1000) Hz, duty cycle from 0-100%, and able to accept a voltage range of 5-30V DC. I have looked through Sparkfun and Adafruit for product or PWM shields capable of this and I have yet to find one. Some servo shields can be programmed down to 50Hz and arduino itself can be slowed to like 30Hz using timer0 and timer1 changes. However none of these options make it easy to vary frequency and none of them can accept much more than 6V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched far and wide and found a few interesting things:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;a href=&quot;http://www.instructables.com/id/The-ultimate-PWM-driver-for-many-applications/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/The-ultimate-PWM-driver-for-many-applications/&lt;/a&gt;&lt;p&gt;&#xA; This instructable shows an analog un-sensored PWM driver. It would get the job done here however, I need a way to read my Frequency and Duty Cycle&#xA;&#xA;&lt;p&gt;&#xA;2) &lt;a href=&quot;https://www.electronicsblog.net/arduino-frequency-counterduty-cycle-meter/&quot; rel=&quot;nofollow&quot;&gt;https://www.electronicsblog.net/arduino-frequency-counterduty-cycle-meter/&lt;/a&gt;&#xA;&lt;p&gt;&#xA;Here there is a way using pulsein() and other arduino functions to read both frequency and duty cycle as seen above. But then this is also assuming you're PWM voltage is 5V. So maybe you use a 5V regulator on the signal into the arduino? Would something that simple work or would it skew the signal and prevent accurate measurements? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, if anyone has a better idea I'm open to it. I've been searching for a solution for some time. The trouble really seems to be the low frequency PWM request.&lt;/p&gt;&#xA;" OwnerUserId="14953" LastActivityDate="2018-04-28T02:49:45.313" Title="Building an adjustable low frequency PWM controller with Arduino" Tags="|arduino-uno|programming|pwm|timers|frequency|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17940" PostTypeId="1" AcceptedAnswerId="17988" CreationDate="2015-11-19T21:39:01.757" Score="2" ViewCount="3502" Body="&lt;p&gt;I have been working on a project as a gift for my girlfriend for Christmas which involves some a bunch of standard &quot;white&quot; LEDs controlled by shift registers and darlington arrays, and also some RGB LED strips (WS2812B strip, 29 LEDs on strip). Everything is going fine with the white LEDs, but not so much with the RGB ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I leave the RGB leds running for a while all of the LEDs on the strip turn red, except for the first one, which continues to change color. I am not sure how long &quot;a while&quot; is because in &quot;short term&quot; testing, approximately running continuously for an hour, it works fine and all of the LEDs change appropriately, but if I leave it running overnight I wake up with the issue of all red and one single RGB &quot;working&quot;. I then have to reset to get it working again. These RGB LEDSs need to be run for long periods (24 hours) of time without &quot;freezing&quot;. The rest of the program (with the normal LEDs) continues to work fine despite the RGB ones not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me explain how I am controlling them. &lt;code&gt;V_rgb&lt;/code&gt; is 5V (5V - 8A power supply), which it is also grounded to. Then the data line, &lt;code&gt;C&lt;/code&gt;, is connected to an Arduino Uno, on pin 12, which is a PWM pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In software, I am using a Adafruit Neopixel Library to control the RGB LEDs and write their respective colors, based off the examples given in their git repo and the tutorial &lt;a href=&quot;http://www.tweaking4all.com/hardware/arduino/arduino-ws2812-led/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have pasted my code below in case that may help, but honestly I am not sure if it is software or hardware related. (unrelated code has been removed)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#define rgbPin 11&#xA;#define numRGBleds 29&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(numRGBleds, rgbPin, NEO_GRB + NEO_KHZ800);&#xA;int colorStep = 0;&#xA;int rgbIndex = 0;&#xA;&#xA;void shiftColor() {&#xA;  int i = 0;&#xA;  for (i = 0; i &amp;lt; numRGBleds; i++) {&#xA;    int idx = (rgbIndex + i) % numRGBleds;&#xA;    int colorVal = round(i * colorStep);&#xA;    strip.setPixelColor(idx, Wheel(colorVal &amp;amp; 255));&#xA;  } &#xA;  strip.show();&#xA;  rgbIndex++;&#xA;}&#xA;&#xA;uint32_t Wheel(byte WheelPos) {&#xA;  WheelPos = 255 - WheelPos;&#xA;  if (WheelPos &amp;lt; 85) {&#xA;    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);&#xA;  } if (WheelPos &amp;lt; 170) {&#xA;    WheelPos -= 85;&#xA;    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);&#xA;  } &#xA;  WheelPos -= 170; &#xA;  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  strip.begin();&#xA;  strip.show();&#xA;  rgbIndex = 0;&#xA;  colorStep = 255 / (numRGBleds - 1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  shiftColor();&#xA;  delay(1000); // Redo every second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My thoughts of what it could be are the following, let me know if any make any sense or are known issues:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Having issues with &lt;code&gt;micros()&lt;/code&gt; value rollover&lt;/li&gt;&#xA;&lt;li&gt;Overheating&lt;/li&gt;&#xA;&lt;li&gt;Noisy power supply&lt;/li&gt;&#xA;&lt;li&gt;Defective LED strip&lt;/li&gt;&#xA;&lt;li&gt;black magic?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current solution to the problem is to just reset the board using the watchdog functionality. It reboots in a few milliseconds and sometimes flashes in the process, but I would like to figure out the real problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE #2&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with the reset solution, I left it running overnight and it did not freeze which leads me to think it is definitely a software, not hardware, issue. I have changed some of the wiring and coding to make sure the watchdog reset is not noticeable. It resets every half hour or so. This will make sure all of the memory is cleaned, except stuff I store in the EEPROM (which I do use to make the reset less noticeable). This reset delays processing by a few milliseconds, but time is not critical, so it is not a big deal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still however, would like to know a more elegant way of doing this. The software reset is a bit &quot;hacky&quot;&lt;/p&gt;&#xA;" OwnerUserId="14954" LastEditorUserId="14954" LastEditDate="2015-11-20T14:12:28.320" LastActivityDate="2015-11-21T13:30:02.170" Title="Arduino and WS2812 RGB LED Strip &quot;freezing&quot;" Tags="|arduino-uno|led|rgb-led|neopixel|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="17941" PostTypeId="1" AcceptedAnswerId="17942" CreationDate="2015-11-19T22:49:13.367" Score="0" ViewCount="75" Body="&lt;p&gt;I am starting a project that may need a lot of Arduino Yuns in the future, but today I found that they are not available on the official Arduino store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the story on the Yun? Is it being replaced by something newer? Also, how can I evaluate the longer-term availability of this board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case it's helpful, I need the dual-processor setup, wifi capability, and extra storage of the Yun.&lt;/p&gt;&#xA;" OwnerUserId="10236" LastActivityDate="2016-11-17T23:11:04.127" Title="Yun availability" Tags="|arduino-yun|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17942" PostTypeId="2" ParentId="17941" CreationDate="2015-11-20T00:20:22.673" Score="0" Body="&lt;p&gt;In short: Who knows?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all the in-fighting between the two Arduino factions (Arduino.cc and Arduino.org) it's anyone's guess what boards are going to be available this time next year, and of those that are available which of the two factions will be producing and distributing them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-20T00:20:22.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17943" PostTypeId="2" ParentId="17939" CreationDate="2015-11-20T00:43:45.110" Score="4" Body="&lt;p&gt;The ATmega328 in the Arduino Uno has a 16-bit timer (Timer/Counter 1) which can do PWM. It has a prescaler that can divide by 1024.  The lowest frequency that it can generate is about 0.12 Hz:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;16MHz / 1024 / 65535 / 2 = 0.1192 Hz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We change the PWM frequency by changing the &quot;top&quot; value. For higher frequencies, lower the top value, and/or pick a smaller prescaler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(And, really, what does 0 Hz PWM even mean?!? :-)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The duty cycle can vary from 0-100%, with the resolution changing with the specific frequency you generate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the high-voltage... use a motor driver, or darlington, or hexfet, or whatever...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm confused as to why you're reading the frequency. With the 16MHz crystal, you set it and you get what you asked for (within the crystal tolerances, temperature, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At least, that's how I think it works.&#xA;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="14956" LastActivityDate="2015-11-20T00:43:45.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17944" PostTypeId="1" CreationDate="2015-11-20T02:23:46.123" Score="0" ViewCount="100" Body="&lt;p&gt;I am developing libraries for compatibility across a number of Arduino/compatible boards. I know that Arduino boards can be identified by the test &quot;#if defined (&lt;strong&gt;AVR_ATmega328P&lt;/strong&gt;)&quot; and compatibles as well: #if defined(&lt;strong&gt;TM4C123GH6PM&lt;/strong&gt;).   There are a few lists of these IDs on the web but are all outdated. I have searched various cores and library code and do not see where these defines are actually defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon's &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow&quot;&gt;Sketch to detect Atmega chip types&lt;/a&gt; identifies the chip type. What I'm looking for the board type to define pin configurations, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where and in what format are board signatures stored? Is there c++ code that can find the board signature? Does anyone know of a site where these signatures are stored and updated by the Arduino community?&lt;/p&gt;&#xA;" OwnerUserId="3655" LastActivityDate="2015-11-20T10:05:32.233" Title="Identifying Arduino-compatible board signatures in code" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17945" PostTypeId="2" ParentId="17938" CreationDate="2015-11-20T02:36:22.263" Score="0" Body="&lt;p&gt;This seems to be quite a common problem, and there are a number of problems, each with their own solution.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure you have selected the right chip&lt;/li&gt;&#xA;&lt;li&gt;Make sure you have selected the right serial port (when you unplug your board, it should disappear).&lt;/li&gt;&#xA;&lt;li&gt;Make sure you do not have anything plugged in to the tx &amp;amp; rx pins (usually 0 and 1).&lt;/li&gt;&#xA;&lt;li&gt;Make sure your Atmega chip has a bootloader on it&lt;/li&gt;&#xA;&lt;li&gt;Try another cable&lt;/li&gt;&#xA;&lt;li&gt;There may be a problem with your computer - try another computer&lt;/li&gt;&#xA;&lt;li&gt;If using another helps, try reinstalling the USB serial driver&lt;/li&gt;&#xA;&lt;li&gt;Try unplugging the Arduino board, holding down the reset switch, then plugging it in (still holding down reset); continue to hold down reset for about 5 seconds.&lt;/li&gt;&#xA;&lt;li&gt;make sure nothing else is trying to use your serial port&lt;/li&gt;&#xA;&lt;li&gt;Does your chip have a bootloader? Chips bought as part of an Arduino will, otherwise, it almost certainly doesn't, unless it specifically says (in the description of what you bought).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If it does not have a bootloader (or may not have a bootloader) you will need to set this up. You can either use the instructions here: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt; (which I never got working) or you can use an ICSP like the &lt;a href=&quot;http://www.freetronics.com.au/products/usbasp-icsp-programmer-for-avr-arduino#.VlIY_2xifXs&quot; rel=&quot;nofollow&quot;&gt;http://www.freetronics.com.au/products/usbasp-icsp-programmer-for-avr-arduino#.VlIY_2xifXs&lt;/a&gt; (which is what I use) - works great. They can be had for a few dollars from China.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-11-22T19:37:21.343" LastActivityDate="2015-11-22T19:37:21.343" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17946" PostTypeId="1" AcceptedAnswerId="17965" CreationDate="2015-11-20T03:09:37.380" Score="6" ViewCount="1409" Body="&lt;p&gt;This is admittedly a cross-post from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=360468.0&quot; rel=&quot;nofollow&quot;&gt;LED fade malfunction (random flash) &lt;/a&gt; but I can't get an answer on the Arduino forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was mucking around with some very basic code and I noticed that when repeatedly holding an LED at 0 brightness for 1 second and then fading in to full brightness, a small flash would occasionally happen at the beginning of each fade (seemingly random). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 11;&#xA;int brightness = 0;&#xA;&#xA;void setup()  &#xA;{ &#xA;  pinMode(led, OUTPUT);&#xA;} &#xA;&#xA;&#xA;void loop()  &#xA;{ &#xA;  if(brightness &amp;gt;= 256) //checks if brightness has passed 255, resets to 0&#xA;  {&#xA;    analogWrite(led, 255);&#xA;    brightness = 0; &#xA;  }&#xA;  analogWrite(led, brightness);&#xA;  if(brightness == 0)&#xA;    {&#xA;      delay(1000); //LED off for 1 second&#xA;    }&#xA;&#xA;  brightness+=1; //increment brightness&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the thing that has me completely perplexed is that I can use a different piece of code (below) and the flash goes away!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int i = 0;&#xA;int led = 11;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(led,OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;analogWrite(led, i);&#xA;delay(6);&#xA;if(i%256 == 0)&#xA;{&#xA;  i = 0 ;&#xA;  delay(1000);&#xA;}&#xA;i++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Has anyone got any clue as to why this would happen? Both programs have basically the same code, except for that i is reset to 0 in the first program whereas in the second, i keeps incrementing past 255 so that analogWrite 'overflows.' I think it must be a firmware, (or maybe a software?) problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a video on youtube of it happening here, &lt;a href=&quot;https://www.youtube.com/watch?v=mbBJWjYScng&quot; rel=&quot;nofollow&quot;&gt;Arduino - fading LED problem&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11606" LastEditorUserId="11606" LastEditDate="2016-01-05T21:52:13.377" LastActivityDate="2016-01-08T16:38:17.733" Title="Why does an LED sometimes flash when increasing brightness?" Tags="|arduino-uno|led|pwm|analogwrite|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17947" PostTypeId="1" AcceptedAnswerId="17948" CreationDate="2015-11-20T05:43:26.663" Score="3" ViewCount="787" Body="&lt;p&gt;I am new to electronics and Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the difference between power supply ground and Arduino's ground. If I connect my LED cathode to power ground, it doesn't work. But if I connect it to Arduino ground, it works. Aren't all ground the same? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see picture below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AhDtD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AhDtD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14960" LastEditorUserId="14960" LastEditDate="2015-11-20T08:26:29.407" LastActivityDate="2015-11-20T16:16:30.420" Title="Newbie - What is the Difference Between Power Supply's GND and Arduino's GND?" Tags="|arduino-pro-mini|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17948" PostTypeId="2" ParentId="17947" CreationDate="2015-11-20T06:47:59.960" Score="3" Body="&lt;p&gt;I would expect there to be no difference between the grounds in your circuit, and after looking over the &lt;a href=&quot;https://www.adafruit.com/images/product-files/2377/Arduino-Pro-Mini-v14.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic for the board&lt;/a&gt;, it appears that all of the grounds are common.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the most likely explanation for what you're seeing is a quirk in the breadboard. It may be that the side busses are split at the middle of the board, or perhaps there was just a bad connection somewhere on the ground bus on that side of the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way you could troubleshoot it further would be by jumping the ground side of the LED to the power supply ground. Start with the ground on the regulator and then work out until you find the spot where you loose continuity.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-20T06:47:59.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17949" PostTypeId="1" AcceptedAnswerId="17950" CreationDate="2015-11-20T07:19:00.197" Score="1" ViewCount="4551" Body="&lt;p&gt;I am using a Uno as a data logger with a DS1307 RTC and the following libraries Time.h DS1307RTC.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DS1307 does not have any support for DST and neither library includes Time Zone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any libraries which adjust for DST?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I used the &lt;code&gt;Timezone&lt;/code&gt; module to correct my times for DST.&#xA;It took a little time to sort it out, so I though I would post the steps I followed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Customise &lt;code&gt;WriteRules&lt;/code&gt; for my Timezone.&#xA;I copied rule from &lt;code&gt;WorldClock&lt;/code&gt;.&#xA;NOTE also need to modify Timezone in setup(void)&#xA;Run &lt;code&gt;WriteRules.pde&lt;/code&gt; to write rules to EEPROM address 100&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;TimeRTCSet.pde&lt;/code&gt; to set RTC time to UTC. &#xA;Start Serial Monitor. &#xA;In Terminal send time to Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;date -u +T%s &amp;gt; /dev/tty.usbmodemFA131 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Run &lt;code&gt;HardwareRTC.pde&lt;/code&gt; to demonstrate time display in UTC &amp;amp; local&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified my sketch by including the following code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timezone.h&amp;gt;    //https://github.com/JChristensen/Timezone&#xA;⋯&#xA;Timezone myTZ(100);       //assumes rules stored at EEPROM address 100&#xA;TimeChangeRule *tcr;        //pointer to the time change rule, use to get TZ abbrev&#xA;time_t utc, local;&#xA;⋯&#xA;utc = now();&#xA;local = myTZ.toLocal(utc, &amp;amp;tcr);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="3879" LastEditDate="2015-11-21T04:26:55.157" LastActivityDate="2015-11-21T04:26:55.157" Title="Library to correct time for DST" Tags="|arduino-uno|time|rtc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17950" PostTypeId="2" ParentId="17949" CreationDate="2015-11-20T07:58:30.067" Score="3" Body="&lt;p&gt;You could use the &lt;a href=&quot;https://github.com/JChristensen/Timezone&quot; rel=&quot;nofollow&quot;&gt;Timezone library&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-11-20T07:58:30.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17951" PostTypeId="1" CreationDate="2015-11-20T08:55:51.743" Score="1" ViewCount="579" Body="&lt;p&gt;I am trying to create a new library that uses another existing library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original library declares a way to create an object called Multiserial that can be created in the main file and the program is correctly compiled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I include this library in a second one and I try to build the program, then the IDE returns an error that says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:27:0,&#xA;                   from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26,&#xA;                   from MultiSerial.h:17,&#xA;                   from maqMODBUSmst.h:5,&#xA;                   from maqMODBUSmst.c:1:&#xA;  C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Printable.h:25:1: error: unknown type name 'class'&#xA;   class Print;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Even if the library only contains the include of the first one.&lt;/p&gt;&#xA;" OwnerUserId="10657" LastEditorUserId="4628" LastEditDate="2015-11-22T14:53:39.403" LastActivityDate="2015-11-22T14:53:39.403" Title="Why can't I include a library in another one?" Tags="|library|wire-library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17953" PostTypeId="1" CreationDate="2015-11-20T09:59:51.877" Score="1" ViewCount="450" Body="&lt;p&gt;I succeeded in programming a system of thermoregulation using Arduino.  This system holds the temperature of a plate at 37°C. I used a PID corrector to realize this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do now is make a graphic interface that can communicate with the Arduino, allowing me to see a graph of the temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like an explanation of how to send temperature data to a graphic interface using Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="14515" LastEditorUserId="4628" LastEditDate="2015-11-26T15:34:04.203" LastActivityDate="2015-11-26T15:34:04.203" Title="Arduino graphic interface" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17954" PostTypeId="2" ParentId="17944" CreationDate="2015-11-20T10:05:32.233" Score="1" Body="&lt;p&gt;In the &lt;code&gt;boards.txt&lt;/code&gt; file each board has a board type definition, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.build.board=AVR_UNO&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you compile your sketch that is adapted into a &quot;board&quot; define by prepending &lt;code&gt;-DARDUINO_&lt;/code&gt; to it and adding it to the compilation command line - so that one becomes the same as &lt;code&gt;#define ARDUINO_AVR_UNO&lt;/code&gt;.  You can, of course, test for it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef ARDUINO_AVR_UNO&#xA;....&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The location of the &lt;code&gt;boards.txt&lt;/code&gt; file varies with different versions of the IDE, but every installed core will have one.  Look around in your Arduino program folder in the &lt;code&gt;hardware&lt;/code&gt; subdirectory.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-20T10:05:32.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17955" PostTypeId="2" ParentId="17953" CreationDate="2015-11-20T10:16:23.400" Score="1" Body="&lt;p&gt;It all depends on what graphical interface.  There's many ways of doing it.  You have TFT screens that the Arduino controls directly (take a look at UTFT for example), or serially connected displays (such as the ones offered by 4D Systems).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you need to decide what kind of display device you want to use - and that is deciding:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What your budget is&lt;/li&gt;&#xA;&lt;li&gt;How many Arduino resources you can dedicate to the interface&lt;/li&gt;&#xA;&lt;li&gt;What IO you have available on your Arduino&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And more.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-20T10:16:23.400" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17957" PostTypeId="1" CreationDate="2015-11-20T12:08:58.870" Score="2" ViewCount="892" Body="&lt;p&gt;I have an Arduino Due (made in Italy) which suddenly (after working nicely for some time) started a new behavior: If I connect it to my computer via USB it is recognized and connects. The &quot;On&quot;-led is turned on but gets darker within seconds until it's off and the connection breaks. This happens with both USB ports. The area around the usb ports gets hot and especially the &quot;504L&quot; next to the reset buttons. (I just have my finger to measure the temperature, so it could also be something else in this corner). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could have happened to the board? And is there anything I can try to revive it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;@GuitarPicker: It's the object labelled &quot;0105&quot; in your image, so it's probably the F1 fuse. If I connect the top USB, F1 gets hot, if I use the lower usb, F2 is activated. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There is nothing connected to the board. Before that, I used it to send SPI commands where I might have connected some of the SPI pins in the 6 pin group.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The board is placed on wood, so there should be no external connection &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;No smoke or visible damage. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="50158" LastEditorUserId="50158" LastEditDate="2015-11-20T17:46:56.520" LastActivityDate="2015-11-20T17:46:56.520" Title="Arduino due dying after connection, gets hot" Tags="|arduino-due|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17959" PostTypeId="2" ParentId="17780" CreationDate="2015-11-20T13:49:55.153" Score="0" Body="&lt;p&gt;The hex button toggle switch will show what the value of your characters are in hex. find the character that matches the value you want to send and use that. if you type the string 0x01 the app will send 0x30 0x78 0x30 0x31 0x0A. Since it trys to convert your characters to hex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this table is pretty handy showing what characters are represented by which hex numbers &lt;a href=&quot;http://web.cs.mun.ca/~michael/c/ascii-table.html&quot; rel=&quot;nofollow&quot;&gt;http://web.cs.mun.ca/~michael/c/ascii-table.html&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;unfortunately the character representing 0x01 is pretty difficult to type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can work around this issue by using the toInt() function in Arduino if you send the number 1 as a character the toInt() function will convert it to an int with value of 1. The hex equivalent is 0x01.&lt;/p&gt;&#xA;" OwnerUserId="6855" LastEditorUserId="6855" LastEditDate="2015-11-20T13:59:15.130" LastActivityDate="2015-11-20T13:59:15.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17960" PostTypeId="2" ParentId="17951" CreationDate="2015-11-20T14:15:04.657" Score="2" Body="&lt;p&gt;Nested includes lead to these convoluted error messages and are in general, a PITA for the next reader to follow &amp;amp; understand. It is better practice for the dependent library to test, at compile time, for the existence of its required libraries and for each one found missing, issue: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#error DepLibe.h: Missing required include file ReqLibe.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Most .h files guard against multiple-inclusion by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _REQLIBE_H_&#xA;#define _REQLIBE_H_&#xA;// library definitions here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or some variant of it. DepLibe.h can test for these guard symbols. DepLibe.h should document the dependencies in prominent comments. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-11-20T14:15:04.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17961" PostTypeId="2" ParentId="17957" CreationDate="2015-11-20T15:51:44.710" Score="3" Body="&lt;p&gt;The &quot;504L&quot; is a 500mA polyfuse.  If more than 500mA is attempted to be drawn through the USB port it will get hot which causes the fuse to &quot;trip&quot;.  When it cools down again it will &quot;reset&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is too much current being drawn through the USB port?  Well, that's what needs answering to know just why your board is misbehaving:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do you have lots of things plugged into the board - like LED strips, motors, etc?&lt;/li&gt;&#xA;&lt;li&gt;Is the board sat on something metal causing a short circuit? (I did that by having some loose change on my desk once).&lt;/li&gt;&#xA;&lt;li&gt;Have you physically damaged the board and caused some pins of one of the chips to short together?&lt;/li&gt;&#xA;&lt;li&gt;Has the Magic Smoke™ escaped from one of the chips rendering your board broken?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-20T15:51:44.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17962" PostTypeId="2" ParentId="17853" CreationDate="2015-11-20T15:55:15.937" Score="0" Body="&lt;p&gt;The java code you wrote should send just 'a' and 'b' so you should see just lamp turning on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Move writedata invocation just before count++ and count-- statements to solve your &quot;first time&quot;. The problem could be the initialization of v1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Into writedata method why do you call hashcode on the output stream? Maybe flush?&lt;/p&gt;&#xA;" OwnerUserId="9934" LastActivityDate="2015-11-20T15:55:15.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17963" PostTypeId="2" ParentId="17947" CreationDate="2015-11-20T16:16:30.420" Score="2" Body="&lt;p&gt;I agree with the other answers.  On rare occasions, TO-xxx packages have bizarre pinouts, but the 78xx series does, in fact, have ground on the middle terminal.  This is surely a split power supply in your breadboard power busses, or else a bad breadboard.  Many breadboards have splits in the power rails halfway down.  I've also seen some with splits more often than that, perhaps as much as disconnects every 5 (or 5 pairs of) contacts.  I have a breadboard, for example, which allows for 6 different voltages, all in a single line, from various connections to a battery pack.  I'd recommend buzzing the breadboard before starting to use it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also had breadboards whose contacts fail after using larger AWG wires in particular holes (or forcing odd connections, such as machined contacts on IC's or sockets, or larger stamped rectangular pins on a TO package such as this) into breadboard holes. The last thing you want to worry about when building a prototype of a new design is whether or not the wiring under the breadboard works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many multimeters have a continuity test capability for diagnosing problems such as these, BUT make sure no power is connected (or you could damage the meter on this setting).&lt;/p&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2015-11-20T16:16:30.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17964" PostTypeId="1" AcceptedAnswerId="18285" CreationDate="2015-11-20T19:32:38.347" Score="8" ViewCount="4317" Body="&lt;p&gt;I have been programming for quite a while now but I am new to Arduino and AVR Programming. The main question I have about programming these Micro-controllers is are there major differences in designing code in Object Orientated Classes vs the more traditional inline programming I have seen in many examples? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words in the world of Arduino/AVR Controllers are there any savings with Memory and Performance utilizing classes or visa versa?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say for example we have a Class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class SomeClass(){&#xA;&#xA;private:&#xA;   int x;&#xA;   int y;&#xA;&#xA;public:&#xA;   void foo();&#xA;   void bar();&#xA;}&#xA;&#xA;SomeClass thisClass;&#xA;thisClass.foo();&#xA;thisClass.bar();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would there be any performance or memory gains designing the program in a more inline fashion like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x;&#xA;int y;&#xA;&#xA;void foo(){ /*** Do something ***/};&#xA;void bar(){ /*** Do more stuff ***/};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried doing some searches on Stack Exchange and Google but couldn't find quite the answer I am looking for the closest thing I was able to find was &lt;a href=&quot;https://arduino.stackexchange.com/questions/6690/what-are-the-benfits-of-global-variables-over-static-class-members&quot;&gt;this Stack Exchange Question.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am asking about this is I have a project that needs to be as light as possible and I am not clear how I should be designing my program in this environment.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for the answers, this has shed light on things. There is one thing that I am not quite clear about. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you have a class that you are designing that utilizes the u8glib as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class UserInterface{&#xA;private:&#xA;   U8GLIB_ST7920_128X64 Display;&#xA;&#xA;public:&#xA;   UserInterface();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How would you get around using &quot;Dynamic Memory&quot; like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UserInterface::UserInterface(){&#xA;   UserInterface::Display = U8GLIB_ST7920_128X64(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-12-02T17:03:27.033" Title="OOP vs Inline with Arduino" Tags="|programming|arduino-mega|memory-usage|performance|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17965" PostTypeId="2" ParentId="17946" CreationDate="2015-11-20T19:38:22.040" Score="4" Body="&#xA;&#xA;&lt;p&gt;According to the links you provide from the arduino.cc forum the question is more or less answered. If not that important, just avoid &lt;code&gt;analogWrite(led,0)&lt;/code&gt; and make it &lt;code&gt;analogWrite(led,1)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you still want that &lt;code&gt;analogWrite(led,0)&lt;/code&gt;, I've tested your code with the advice and it seems to work OK when changing the register manually:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;wiring_private.h&quot;&#xA;&#xA;int led = 11;&#xA;int brightness = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if (brightness &amp;gt;= 256) //checks if brightness has passed 255, resets to 0&#xA;  {&#xA;    brightness = 0;&#xA;    sbi(TCCR2A, COM2A1);&#xA;    OCR2A = 0; // set pwm duty&#xA;  }&#xA;&#xA;  analogWrite(led, brightness);&#xA;  if (brightness == 0)&#xA;  {&#xA;    delay(1000); //LED off for 1 second&#xA;  }&#xA;&#xA;  brightness += 1; //increment brightness&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Edit: to explain what those &quot;strange codes&quot; are&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm not very expert in this field to explain how exactly this works but basically &lt;code&gt;sbi&lt;/code&gt; is function defined in a macro by Atmel (?), it stands for &quot;&lt;strong&gt;s&lt;/strong&gt;et &lt;strong&gt;b&lt;/strong&gt;it &lt;strong&gt;i&lt;/strong&gt;n&quot; and is used to change registers of ATmega chips. So basically what I did was change register defined by the macro &lt;code&gt;TCCR2A&lt;/code&gt; (why? because it is the register that controls PWM in pin 11) and pass the bitmask &lt;code&gt;COM2A1&lt;/code&gt; (this is a mode of compare defined in datasheet) and &lt;code&gt;OCR2A&lt;/code&gt; is a register used to store the compare value that defines duty cycle. Imagine a counter that every time it receives a tick from a signal clock it compares the value of the counter with the value stored in &lt;code&gt;OCR2A&lt;/code&gt; and it sets the pin high or low if that value as been passed or not (more or less like this, depending on the mode stored on &lt;code&gt;TCCR2A&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in fact I've not done some black magic. I just looked into the code of &lt;code&gt;analogWrite()&lt;/code&gt; and that is the way they use to set a value of PWM in pin 11:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void analogWrite(uint8_t pin, int val)&#xA;{&#xA;    // We need to make sure the PWM output is enabled for those pins&#xA;    // that support it, as we turn it off when digitally reading or&#xA;    // writing with them.  Also, make sure the pin is in output mode&#xA;    // for consistenty with Wiring, which doesn't require a pinMode&#xA;    // call for the analog output pins.&#xA;    pinMode(pin, OUTPUT);&#xA;    if (val == 0)&#xA;    {&#xA;        digitalWrite(pin, LOW);&#xA;    }&#xA;    else if (val == 255)&#xA;    {&#xA;        digitalWrite(pin, HIGH);&#xA;    }&#xA;    else&#xA;    {&#xA;        switch(digitalPinToTimer(pin))&#xA;        {&#xA;&#xA;...&#xA;&#xA;          #if defined(TCCR2A) &amp;amp;&amp;amp; defined(COM2A1)&#xA;            case TIMER2A:&#xA;                // connect pwm to pin on timer 2, channel A&#xA;                sbi(TCCR2A, COM2A1);&#xA;                OCR2A = val; // set pwm duty&#xA;                break;&#xA;          #endif&#xA;...&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically I just used that info to set the register to zero, as suggested from the arduino.cc forum link that you have. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to know more about PWM in Arduino, &lt;a href=&quot;http://www.righto.com/2009/07/secrets-of-arduino-pwm.html&quot; rel=&quot;nofollow&quot;&gt;this site&lt;/a&gt; has a lot of info and explains a lot of the modes of registers also.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6936" LastEditDate="2016-01-08T16:38:17.733" LastActivityDate="2016-01-08T16:38:17.733" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17966" PostTypeId="2" ParentId="17964" CreationDate="2015-11-20T19:56:22.603" Score="4" Body="&lt;p&gt;The reason you can't find the answer is because the answer is both Yes and No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For basic class stuff - defining your class with methods etc and instantiating objects from it - there's little difference in the end result compared with &quot;vanilla&quot; C.  The compiler's optimizations are so good now that performance is just the same. Yes, there may be slight increases in memory use since you're passing an extra pointer with each method call (instead of &lt;code&gt;foo(int x)&lt;/code&gt; you have &lt;code&gt;foo(MyClass *this, int x)&lt;/code&gt;) but that's so small as to not be noticeable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The big differences come when you start playing with &lt;em&gt;polymorphism&lt;/em&gt; and other advanced topics.  When start doing these complex programs the compiler is not always unable to work out which functions are required and which aren't, and it's not able to cut out the unused functions (&lt;em&gt;&quot;garbage collection&quot;&lt;/em&gt;). So you may well end up with bigger code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That doesn't mean slower code, just chunks of code that are hanging around that never do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of bigger importance is managing your dynamic memory better than you are used to.  Since there is such a small amount of memory the heap is very small, and as a result it gets fragmented very easily.  Dynamic creation and destruction of objects (&lt;code&gt;new myClass&lt;/code&gt;, &lt;code&gt;delete myClassObject&lt;/code&gt;, etc) is very bad.  Class objects really need to either be statically defined (in global scope is the most common) or temporarily allocated on the stack (local instances).  Otherwise you're asking for trouble - and the first you will know of it is strange things happening (no error reports or exceptions, you see...).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-20T19:56:22.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17967" PostTypeId="2" ParentId="17903" CreationDate="2015-11-20T22:00:32.480" Score="2" Body="&#xA;&#xA;&lt;p&gt;You can use the inbuilt analog comparator to generate an interrupt when a certain threshold is reached. Example circuit (reference voltage on D7, voltage under test on D6):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w0DUe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w0DUe.png&quot; alt=&quot;Analog comparator schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code for the Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile boolean triggered;&#xA;&#xA;ISR (ANALOG_COMP_vect)&#xA;  {&#xA;  triggered = true;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  ADCSRB = 0;           // (Disable) ACME: Analog Comparator Multiplexer Enable&#xA;  ACSR =  bit (ACI)     // (Clear) Analog Comparator Interrupt Flag&#xA;        | bit (ACIE)    // Analog Comparator Interrupt Enable&#xA;        | bit (ACIS1);  // ACIS1, ACIS0: Analog Comparator Interrupt Mode Select (trigger on falling edge)&#xA;   }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (triggered)&#xA;    {&#xA;    Serial.println (&quot;Triggered!&quot;); &#xA;    triggered = false;&#xA;    }&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The incoming voltage is on the AIN0 (positive) pin which is pin 12 on the actual chip, and D6 on the Arduino board. The reference voltage (negative) pin is pin 13 on the chip, and D7 on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My example does not address the issue of transmitting the results, but that is the easy bit. You might need to build in a test so that you don't transmit the information thousands of times a second.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-20T22:00:32.480" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17968" PostTypeId="2" ParentId="6697" CreationDate="2015-11-20T22:38:37.570" Score="0" Body="&lt;p&gt;I had the same issues Thanks for help .However I made the  following connections then above mentioned &lt;/p&gt;&#xA;&#xA;&lt;p&gt;RC522 RFID borad     Arduino YUN  (as per the github example code dumpinfo)&#xA;chip select (nss ) - Pin 10 &#xA;Rst                - Pin 9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link for Gihub RFID RC522&#xA;Hope it helps someone who is stuck&lt;/p&gt;&#xA;" OwnerUserId="14981" LastActivityDate="2015-11-20T22:38:37.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17970" PostTypeId="1" AcceptedAnswerId="17974" CreationDate="2015-11-20T23:00:43.730" Score="2" ViewCount="9666" Body="&lt;p&gt;I want to build a simple voltage regulator  3.8-4.2V with atleast 2A Peak Current Capability for my GSM Shield (It doesn't have regulated power supply), I don't want variation or it may burn the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using voltage divider won't help here as there can be variations.&#xA;Somewhere i read LDO are for for this task but i am able to get only 3.3v regulator with 800mA supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can i use 3.3v to power the same ?&lt;/p&gt;&#xA;" OwnerUserId="14983" LastEditorUserId="14983" LastEditDate="2015-11-21T05:44:02.330" LastActivityDate="2015-11-21T05:44:02.330" Title="5v to 4.3v Regulator - For SIM800 module" Tags="|arduino-uno|power|voltage-level|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17971" PostTypeId="2" ParentId="158" CreationDate="2015-11-20T23:14:26.403" Score="3" Body="&lt;p&gt;For future readers: use the Adafruit_MCP23017 library.&lt;/p&gt;&#xA;" OwnerUserId="14984" LastActivityDate="2015-11-20T23:14:26.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17974" PostTypeId="2" ParentId="17970" CreationDate="2015-11-21T00:28:23.983" Score="1" Body="&lt;p&gt;Consider using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Buck_converter&quot; rel=&quot;nofollow&quot;&gt;buck converter&lt;/a&gt; for this.  Search ebay for &quot;buck converter&quot; and you will see items like &quot;&lt;a href=&quot;http://www.ebay.com/itm/261956897110&quot; rel=&quot;nofollow&quot;&gt;Buck Converter Step-Down Adjustable Converter Power Module Regulator LM2596&lt;/a&gt;.  That title indicates several things:  the converter is adjustable, it steps voltage down, it's a regulator, and it's based on TI's &lt;a href=&quot;http://www.ti.com/product/lm2596&quot; rel=&quot;nofollow&quot;&gt;LM2596&lt;/a&gt; chip.  It's rated at 2 A continuous, 3 A peak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A buck converter has some advantages over a linear regulator:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Lower dropout (in general), ie, the input voltage has to be at least as much as the output voltage, possibly plus a small margin for one FET loss, but doesn't have to have the 1.1 to 1.3 volt margin typical of an LDO regulator.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Higher efficiency (in general).  For example, 95% is not uncommon.  (The ebay item mentioned above shows 92%.)   A linear regulator, whether LDO or not, turns the input-to-output voltage difference into heat.  A buck converter, on the other hand, uses an inductor and a capacitor to store energy; it refills the capacitor at a controlled rate via the inductor as often as necessary to deliver the required load.  The inductor's DC resistance wastes energy, but that resistance can be kept small.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Smaller parts due to high frequency switching operation.  As operating frequency is increased the inductor can be made smaller.  On the other hand, higher frequencies lead to higher switching losses, so there's a tradeoff.  Note, some SOT3-sized (~1.4 mm x 2.9 mm) transistors eg NTR4503 are rated over 2 A at 25°C and might be usable as an output FET for a buck converter chip, and inductors and capacitors also are available in sizes probably as small as you are looking for, but buying them and building your own converter is unlikely to be cost effective.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-21T02:39:07.827" LastActivityDate="2015-11-21T02:39:07.827" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="17975" PostTypeId="5" CreationDate="2015-11-21T00:56:47.120" Score="0" Body="&lt;p&gt;NeoPixels are the common name for &lt;a href=&quot;https://www.adafruit.com/&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt;'s implementation of WS2812 Integrated Light Source.  They refer to simple, scalable and affordable full-color Light Emitting Diodes (LEDs). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Red, green and blue LEDs are integrated alongside a driver chip into a tiny surface-mount package controlled through a single wire. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can be used individually, chained into longer strings or assembled into still more interesting form-factors.&lt;/p&gt;&#xA;" OwnerUserId="14986" LastEditorUserId="14986" LastEditDate="2015-11-22T14:52:36.857" LastActivityDate="2015-11-22T14:52:36.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17976" PostTypeId="4" CreationDate="2015-11-21T00:56:47.120" Score="0" Body="The WS2812 Integrated Light Source from Adafruit." OwnerUserId="14986" LastEditorUserId="14986" LastEditDate="2015-11-22T14:48:37.363" LastActivityDate="2015-11-22T14:48:37.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17978" PostTypeId="2" ParentId="17853" CreationDate="2015-11-21T04:35:23.313" Score="0" Body="&lt;p&gt;Thanks my friends, I had already solved the problem, the problem was this....&#xA;I made the method that ran after pressing each button, which sent the data at particular button, it seems the data interfered each other but I do not know why, but I had deleted that method and I used to send data using the object I created at each button.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Button button_1 = new Button(&quot;switch&quot;);&#xA;    button_1.setFont(new Font(&quot;Tahoma&quot;, Font.BOLD, 13));&#xA;    button_1.setBounds(10, 10, 117, 42);&#xA;    panel_3.add(button_1);&#xA;    button_1.addActionListener(new ActionListener() {&#xA;            int count=0;&#xA;        public void actionPerformed(ActionEvent e) {&#xA;            if(count==0){&#xA;                canvas.setBackground(Color.RED);&#xA;                canvas.setForeground(Color.GREEN);&#xA;&#xA;                char v2 = 'a';&#xA;                try {&#xA;                    output.write(v2);&#xA;                } catch (IOException e1) {&#xA;                    // TODO Auto-generated catch block&#xA;                    e1.printStackTrace();&#xA;                }&#xA;            count++;&#xA;            }&#xA;            else{&#xA;                canvas.setBackground(Color.YELLOW);&#xA;                canvas.setForeground(Color.GREEN);&#xA;                char v1 = 'b';&#xA;                try {&#xA;                    output.write(v1);&#xA;                } catch (IOException e1) {&#xA;                    // TODO Auto-generated catch block&#xA;                    e1.printStackTrace();&#xA;                }&#xA;                count--;&#xA;        }&#xA;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it worked fine....!!!!.&lt;/p&gt;&#xA;" OwnerUserId="14895" LastActivityDate="2015-11-21T04:35:23.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17979" PostTypeId="2" ParentId="17953" CreationDate="2015-11-21T05:11:13.483" Score="2" Body="&lt;p&gt;There are two main possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one is to make a GUI on the Arduino itself. Add a TFT screen, touchscreen if you want the user to interact, or a non-touchscreen (cheaper) if you just want to display. Then, within your Arduino code, you can display the temperature data, and if you go the touchscreen route, interact with the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I own a couple of &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardEsplora&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Esplora&lt;/a&gt; devices, and they would be near perfect for this, as they have a non-touch TFT screen, a joystick, buttons and a pot. All the equipment you need to display the temperature. Oh, and it has temperature and light sensors onboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8k8mC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8k8mC.jpg&quot; alt=&quot;My Esplora Sketch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second way would be to make a GUI on your desktop/laptop machine. In your Arduino code, you could send your temperature data through USB (Serial), Bluetooth (SoftwareSerial), WiFi, Ethernet, nRF, etc etc etc. If you don't mind having the Arduino tethered to your computer by a cable, USB&amp;lt;--&gt;Serial is the easiest solution. The software on the computer listens on a serial socket and when it receives temperature data, it displays it within its GUI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="4628" LastEditorUserId="4628" LastEditDate="2015-11-23T12:07:08.180" LastActivityDate="2015-11-23T12:07:08.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17980" PostTypeId="2" ParentId="17970" CreationDate="2015-11-21T05:28:51.823" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I planned to use 3.7v LIPO battery&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's what your SIM800 module is &lt;em&gt;intended&lt;/em&gt; to be &lt;em&gt;directly&lt;/em&gt; powered by, &lt;em&gt;without&lt;/em&gt; any intervening boost or buck converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Behind all the misdirection of a title that doesn't describe what you are actually trying to do, your question is an exercise in going around in a circle right back to where you started.  Don't try to convert energy from the lithium cell to some other voltage and then from there to the allowed input range of the SIM800 (which is very intentionally that of a single lithium cell), rather use the parts as they were intended to be used.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;i guess it has current 800mA..&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it has a capacity of 800 milliamp hours, not 800 milliamps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A phone or RC model type lithium cell you would find today would have a &quot;C&quot; rating of 10 or better, but even if we assumed one of only 5, that would predict that your cell should be expected to be able to support pulse loads of 5 times the one-hour draw rate, which would be .8 * 5 = 4 amps.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-11-21T05:34:04.027" LastActivityDate="2015-11-21T05:34:04.027" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="17982" PostTypeId="1" CreationDate="2015-11-21T10:25:59.887" Score="1" ViewCount="44" Body="&lt;p&gt;Why would this simple code which prints out array values give the right value 240 when the array is addressed with index directly addressed by number&#xA;but give 184 when addressed usin a varibale n that is incrementing?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PROGMEM const unsigned char COLSA[8] = {  &#xA;      240, 240, 240, 240, &#xA;      240, 240, 240, 240};  //Stored pattern&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int n;&#xA;   for(n=0;n&amp;lt;8;n=n+1) &#xA;    {&#xA;      Serial.println(n);&#xA;      Serial.println(COLSA[1]);&#xA;      //n=2;  //If I use n in this way things are fine. It prints 240. Else it prints 184&#xA;      Serial.println(COLSA[n]);&#xA;    }&#xA;     delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14995" LastEditorUserId="4143" LastEditDate="2015-11-21T10:32:11.333" LastActivityDate="2015-11-21T10:37:53.860" Title="Addressing contents of array using incrementing variable" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17983" PostTypeId="2" ParentId="17982" CreationDate="2015-11-21T10:37:53.860" Score="4" Body="&lt;p&gt;Because the array is a constant the compiler can, when it knows the entry number (i.e., using a numeric literal) replace the access to the array with the contents of that array index - so it's not looking up the value of 240 at runtime, instead the value 240 has been used where the access to the array was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when accessing it using a variable the compiler can't do that, so it has to actually access the array in RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BUT&lt;/strong&gt; the array &lt;em&gt;isn't&lt;/em&gt; in RAM, it's in PROGMEM, so the address that it's being given for where the array is located is completely wrong.  You're program is telling it &quot;It's in the bedroom&quot; - but you're omitting the important information of: &quot;... of the house next-door.&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PROGMEM and RAM are two completely different things accessed through two completely separate data and address buses - just like two separate houses, they both have a number of rooms in them, and those rooms are called the same thing, but &lt;em&gt;they're not the same room&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of accessing an array by index like that you have to use special instructions to say &quot;Get this value from PROGMEM&quot;, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     Serial.println(pgm_read_byte_near(COLSA + v));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That says &quot;Give me the byte that is located at &lt;em&gt;v&lt;/em&gt; addresses on from the start of the &lt;code&gt;COLSA&lt;/code&gt; array in PROGMEM.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-21T10:37:53.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17984" PostTypeId="2" ParentId="17895" CreationDate="2015-11-21T11:19:21.447" Score="1" Body="&lt;p&gt;It all depends on how used to you are with using pi or arduino. What you want can be done in both ways.&#xA;The displaying of count is common for both. It can be done using a 16X1 LCD display, 5 different 7 segment LED connected via decoders or a graphic display module. Interfacing all these with Arduino will be relatively simpler than Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the fetching of data and sending it to your device for displaying it. You can use ESP8266 Wi-Fi module with arduino and pull the data. Which is not as simple as it sounds but it is not impossible too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For pi, (like @max246 said) you can run a python script and use another api to get the data.&lt;/p&gt;&#xA;" OwnerUserId="8426" LastActivityDate="2015-11-21T11:19:21.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17985" PostTypeId="1" CreationDate="2015-11-21T11:52:26.053" Score="0" ViewCount="295" Body="&lt;p&gt;I'm newbie in Arduino Dev&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got Arduino Uno R3, at first it just worked fine.&#xA;I tried to upload my whole project sketch which almost up to the max size of arduino memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then suddenly the upload failed, and i can upload any other sketch even an empty or simple sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already remove all cables connected, still failed to upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really dont know how to fix this.&lt;/p&gt;&#xA;" OwnerUserId="14999" LastActivityDate="2015-11-21T14:48:20.200" Title="Arduino Uno cannot upload any sketch: avrdude: stk500_recv(): programmer is not responding" Tags="|arduino-uno|avrdude|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17986" PostTypeId="2" ParentId="17826" CreationDate="2015-11-21T12:36:05.380" Score="1" Body="&lt;p&gt;Using this &lt;a href=&quot;https://github.com/TMRh20/&quot; rel=&quot;nofollow&quot;&gt;RF24 library&lt;/a&gt; set, I am able to use or not softspi by doing #define SOFTSPI on my sketch, there's no need to define it on the RF24_config.h, you should be able to define it on your own sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino 1.6.5&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;#include &quot;printf.h&quot;&#xA;#define SOFTSPI //Define pins RF24_config.h&#xA;&#xA;/****************** User Config ***************************/&#xA;/***      Set this radio as radio number 0 or 1         ***/&#xA;bool radioNumber = 0;&#xA;&#xA;/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 &amp;amp; 8     */&#xA;RF24 radio(8,9);&#xA;&#xA;....&#xA;....&#xA;void setup() { ... }&#xA;void loop() { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14945" LastEditorUserId="14945" LastEditDate="2015-11-23T20:56:31.043" LastActivityDate="2015-11-23T20:56:31.043" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="17988" PostTypeId="2" ParentId="17940" CreationDate="2015-11-21T13:30:02.170" Score="3" Body="&lt;p&gt;Try changing &lt;code&gt;rgbIndex++;&lt;/code&gt; to &lt;code&gt;rgbIndex=(rgbIndex+1)%numRGBleds;&lt;/code&gt;. I thing the problem is the int rgbIndex rollover, which occurs after about 9 hours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also try changing delay(1000) to delay(1). That way the problem might pop up a lot faster. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-21T13:30:02.170" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="17989" PostTypeId="2" ParentId="3479" CreationDate="2015-11-21T13:48:33.920" Score="2" Body="&lt;p&gt;I just grabbed the version from the ones above here and made is somewhat smaller in terms of code. Feel free to use it in your Arduino app.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This will store the last known state of the button&#xA;int lastButtonState = LOW;&#xA;&#xA;void loop()&#xA;{&#xA;  // Get the current state of the button&#xA;  int currentButtonState = digitalRead(buttonPin);&#xA;&#xA;  // Has the button gone high since we last read it?&#xA;  if (currentButtonState == HIGH &amp;amp;&amp;amp; lastButtonState == LOW) {&#xA;     // Switch the state of the output&#xA;     digitalWrite(ledPin, !digitalRead(ledPin));&#xA;  }&#xA;&#xA;  // Store the button's state so we can tell if it's changed next time round&#xA;  lastButtonState = currentButtonState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15002" LastEditorUserId="15002" LastEditDate="2015-11-21T14:00:16.490" LastActivityDate="2015-11-21T14:00:16.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17990" PostTypeId="1" AcceptedAnswerId="17992" CreationDate="2015-11-21T13:58:35.827" Score="3" ViewCount="559" Body="&lt;p&gt;I'm working on quite a big project and I need few advices. Basically, Arduino will be receiving data (Strings) and will work with it. No problems with that, but I don't know what to do with receiving and sending data. Customers (all over the country, so the program will not run on LAN) will send the data, but the question is, via what? Application, that will make a TCP connection to Arduino, send UDP packet or maybe a website? Customers need to have access to data (it needs to be refreshed when arduino deletes it too). What would be the most efficient, easy to use and reliable system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next thing I want to know is how to make a connection. Open a port on router and connect arduino to that router? I currently have a python script that actually sends an UDP packet to local IP and it works great, but it is limited to LAN. Will it work if I just change the IP (to external) and send it to the port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the last thing (for now). I know how to programm in python and java. Which one is better for connections and GUIs? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help, and if you need any more info about the project, I will be happy to edit this post. &lt;/p&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="10907" LastEditDate="2015-11-22T14:51:39.430" LastActivityDate="2015-11-22T14:51:39.430" Title="Help putting an Arduino project on the Internet" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="17991" PostTypeId="2" ParentId="17985" CreationDate="2015-11-21T14:48:20.200" Score="1" Body="&lt;p&gt;First stop for me is always the connections (which you've done), the sketch itself (which doesn't sound likely) and then the COM port / baud rate.  If your sketch involves anything with the serial connection, ISR's or power supplies, that could be an issue with the Arduino not listening.  It sounds like you've covered this as well by trying simple sketches.  Next, check the COM port on the host computer (sometimes it changes in Windows) and inside the IDE, the baud rate, and open the IDE serial port and wander through baud rate settings until you get something legible as a response in the serial window.  Also, double check inside the IDE that you still have the correct board selected.  Occasionally / rarely, I've had to reboot Windows to cure the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good news is, this pain is significant enough that you don't usually make the mistake again, and will probably never forget how you solved it....&lt;/p&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2015-11-21T14:48:20.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17992" PostTypeId="2" ParentId="17990" CreationDate="2015-11-21T15:25:44.747" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What would be the most efficient, easy to use and reliable system?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What seems to me is that you need what is called Unified Application Routing. There are various technologies to do that but what I suggest is &lt;a href=&quot;http://wamp-proto.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;WAMP &lt;/a&gt; (Web Applicaton messaging protocol, do not get confused with wamp server stack) but you can check this &lt;a href=&quot;http://wamp-proto.org/compared/&quot; rel=&quot;nofollow noreferrer&quot;&gt;comparison table&lt;/a&gt; and select the one that most helps you. Based on that what I suggest is &lt;a href=&quot;http://crossbar.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;crossbar.io&lt;/a&gt;. Is open source with a lot of examples, runs on small devices (raspberry pi for example) and is intended for the use you propose, connect devices and let users/apps to get/give information from them. You can publish/subcribe to topics and all devices or apps connected with that topic can read it. Imagine something like an arduino is reading temperatures from a room and publish that data to topic &quot;Temp1&quot;. All devices(other arduino, servers, esp8266)  or apps(websites, programs, what ever you clients you imagine) that also are connected at that moment to topic &quot;Temp1&quot; will get that update and act like you want. Wamp also provides a nice feature that is called RPC (remote procedure call). Imagine that you want some real nasty thing in your arduino but it lacks memory or is too slow for that. You can create a program that is, lets say in a raspberry, just waiting for that calculation and returns the result to arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at this &lt;a href=&quot;https://www.youtube.com/watch?v=XTIM5W2hLRc&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt; as an example of what you can do with this ttype of techonologies. A lot of demos also in crossbar.io page. The beauty is that you can program in almost any language you are familiar with. They rely on websockets for the majority of things but crossbar is not restricted to it only, you can even use raw sockets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the second part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you create your on server (crossbar lets say) inside the lan you have to forward the port he is listening in your router so other outside your network can access it( and possibly will need to get some kind of Dynamic DNS service if your internet provider do not have statics IPs). Or you can host your server outside your network (crossbar has a tutorial for Amazon EC2 and for Microsoft Azure I think). You only need to port forward server ports.&#xA;Hwo do you connect arduino? Use ethernet shields, esp8266, choose a yun or make a combo like arduino with usb + raspberry. That way you can also use your raspberry as a crossbar server.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of my home made crossbar.io server using 2 python programs , 1 rboard and a raspberry pi has a host to manage my home heating system and the webpage is being accessed from internet, not local lan. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R66CF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R66CF.jpg&quot; alt=&quot;Home Heating manager&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2015-11-21T19:59:10.890" LastActivityDate="2015-11-21T19:59:10.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="17993" PostTypeId="1" AcceptedAnswerId="18021" CreationDate="2015-11-21T17:12:40.010" Score="3" ViewCount="12597" Body="&lt;p&gt;Can someone tell me how fast the built in DAC (and ADC) in an Arduino Due can be written or read? I currently don't have the equipment to measure but need the information to plan my next steps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to move galvanometer mirrors and want to make the voltage/position updates as small as possible. How fast are the internal DACs compared to an SPI connection (where I have to write 2 Byte). &lt;/p&gt;&#xA;" OwnerUserId="50158" LastActivityDate="2015-11-22T20:59:26.387" Title="Speed of built in DAC/ADC in Arduino Due" Tags="|arduino-due|adc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17994" PostTypeId="1" AcceptedAnswerId="21022" CreationDate="2015-11-21T17:22:39.320" Score="5" ViewCount="911" Body="&lt;p&gt;How can I create a workspace &amp;amp; projects so that either the Arduino IDE or the &lt;a href=&quot;http://www.baeyens.it/eclipse/&quot; rel=&quot;nofollow&quot;&gt;EclipseArduino IDE&lt;/a&gt; may be used to develop the project, interchangeably?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have both IDEs installed and working but in separate workspaces. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One workspace that either IDE can understand and work in;&lt;/li&gt;&#xA;&lt;li&gt;Either to IDE build with the physically same set of library sources;&lt;/li&gt;&#xA;&lt;li&gt;Whichever IDE I open to see my sources as I last left them, regardless of which IDE I last used.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The source files to have conventional names - .C or .C++, not .pde or .ino;&lt;/li&gt;&#xA;&lt;li&gt;Either IDE to build with the physically same set of library object modules;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My use-case is that I work in/with Eclipse, and I teach Arduino skills to people starting out with the Arduino IDE. I'd like to be able to prepare class work at home with Eclipse but open and project it in class with the Arduino IDE. It would be nice if I could demonstrate the two IDEs using the same code. Clearly, I could hack up a demonstration, but I'd rather do it honestly and without sync issues like having to apply twice any changes we made in class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;Update 20 Apr '16:&#xA;At @Jantje's suggestion (in the comments below his answer), I created a github issue, &quot;&lt;em&gt;Importing an ArduinoIDE project with the New Sketch Wizard and using same sketch-name, failed.&lt;/em&gt;&quot; The new sketch would over-write the .ino file with a new, empty sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That issue got fixed in the April 14, 2016 nightly and now works as his answer to this question says it does. &lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-20T20:19:41.867" LastActivityDate="2017-09-14T08:57:09.473" Title="One workspace, two IDEs - Possible?" Tags="|arduino-ide|eclipse|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="17995" PostTypeId="2" ParentId="17990" CreationDate="2015-11-21T17:37:01.983" Score="2" Body="&lt;p&gt;If I'm understanding you correctly, you have your application running on a LAN and now want to figure out how to make it accessible over the Internet (WAN). If you're there the next step is relatively straight forward. All you need is an IP address that is visible on the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't say what your connection to the Internet is, so let's look at both of the likely (IPv4) possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You have a block of publicly visible addresses (something other than an IP address starting with 10, 172.16, or 192.168 that are allocated by RFC 1918), or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You are behind a single IP address using NAT (network address translation) to provide the internal machines with access to the Internet. The internal machines (and devices) will all have an RFC 1918 address and will not be accessible from the Internet – except by traffic responding to requests made by those machines which are routed to them using NAT. For many users this is the more likely case.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the first case it is simply a matter of connecting the Arduino to a network segment that is connected to the Internet and assigning an IP address (or configuring DHCP). Also, make sure that the UDP port you are using is not assigned to another service.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second case you will also need to connect the Arduino to a network segment with access to the Internet, but because of NAT users outside will not be able to get to the Arduino (yet). To solve that problem you will need to map a port and your external address (the address of your router) to a port and the internal address of your Arduino. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Assume your service runs on port 3142 and your IP address on the Internet is 8.9.10.11 and the Arduino is at 192.168.0.42 on your internal network.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then you would configure the port forwarding settings on your router to direct UDP traffic bound for port 3142 to the internal IP address of 192.168.0.42. Some routers will only allow you to forward to the same port, others will also allow you to use a different internal port as well.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You may also need to open up a &quot;hole&quot; in your firewall to allow traffic to the port where your service runs. The truly cautious will connect the Arduino to a network segment in the DMZ and there will be another firewall protecting your internal computers and devices.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once you have this set up anybody on the outside will be able to use the service on the Arduino – if they know the IP address and the port number. Typically you would run the service at a well known host name and use DNS to translate the host name to an IP address. From your question I can't tell how you want to advertise the service, that would be another good question…&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-21T17:37:01.983" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="17996" PostTypeId="2" ParentId="17895" CreationDate="2015-11-21T17:45:23.590" Score="1" Body="&lt;p&gt;For the complexity of the pulling of the data from a specific API, I would suggest to use i2c screen from adafruit and a python script running on raspberry pi. this will save you time on coding eth interface and just mostly copy and paste some simple code to communicate to the display&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one module that I used and it is simple to use: &lt;a href=&quot;https://www.adafruit.com/products/1270&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1270&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-11-21T17:45:23.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17997" PostTypeId="2" ParentId="3479" CreationDate="2015-11-21T18:53:54.723" Score="1" Body="&lt;p&gt;Pinouts, pullups and logic errors have been addressed elsewhere, so I will focus on switch debouncing.  Debouncing, in my opinion, is best handled in software (rather than hardware) for large volume production costs and lazy programmers (like me).  For small projects a simple pullup / cap circuit offers better reliability and improved speed, but I'm just lazy in my old age.  Also keep in mind that switch bounce worsens significantly over the life of a switch.  I've seen new PB's with bounce &amp;lt; 20 ms worsen to over 300 ms with reasonable usage, so keep that in mind with projects that become semi-permanent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I use for a software solution on a fairly bouncy SPST NO pushbutton. In this case, I'm using NO PB to GND with 1K external pullups, since I personally don't want to depend on whether or not the internal pullup still works on older devices I may have abused in a former life.... Of course, arguments could be made for various areas still needing cleanup, improved encapsulation, quicker response, higher quality, etc., but this works for me for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;inSw.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class inSw&#xA;{&#xA;private:&#xA;    volatile boolean swState;           // current state ( 0 / 1 ) of switch&#xA;&#xA;public:&#xA;    uint8_t  pinNum;&#xA;    volatile unsigned long lastPush;    // Time (millis() ) when last switch push detected&#xA;    unsigned long debTime = 30;         // Time (micros() ) required to debounce switch&#xA;&#xA;    void init(uint8_t sw);&#xA;    boolean readState(void);&#xA;} ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inSw.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void inSw::init(uint8_t sw) {&#xA;    pinNum = sw;&#xA;    pinMode(sw, INPUT);&#xA;    swState = 0;&#xA;    lastPush = millis();&#xA;};&#xA;&#xA;boolean inSw::readState() {&#xA;//  swState = digitalRead(pinNum);&#xA;return swState;&#xA;}&#xA;void setupSwitches(void) {&#xA;    swS1.init(I2C_SOA);     // pin D20&#xA;    attachInterrupt(digitalPinToInterrupt(swS1.pinNum), swS1Press, FALLING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interrupt Service Routines are placed outside Setup() and Loop(), with the attachInterrupt (above) called from inside Setup().  This allows the switch to break long-running routines, such as Stepper.step(10000) which bangs against the limit switch on step 14....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void swS1Press() {&#xA;    unsigned long now = millis();&#xA;    if (swS1.lastPush &amp;lt; (now - swS1.debTime)) { // if newly pushed&#xA;        RunStop.toggle();&#xA;        swS1.lastPush = millis();       // sw last pushed now&#xA;&#xA;        if (RunStop.val == RS_RUN)&#xA;            digitalWrite(LED_PIN, HIGH);   // set the LED on&#xA;        else&#xA;            digitalWrite(LED_PIN, LOW);   // set the LED off&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lastly, just remember to check the switch state at various points inside loop().  I use this switch as an emergency stop switch, and the onboard LED to ensure it triggers.&lt;/p&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2015-11-21T18:53:54.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17998" PostTypeId="1" AcceptedAnswerId="17999" CreationDate="2015-11-21T20:12:41.720" Score="1" ViewCount="123" Body="&lt;p&gt;I am building a project that is using A12864ZW 128X64 LCD, the question I have is should there be anything in the circuit to prevent damage to the Arduino Mega or the LCD? I am using this &lt;a href=&quot;http://overskill.alexshu.com/128x64-12864-lcd-w-arduino-serial/&quot; rel=&quot;nofollow&quot;&gt;example here&lt;/a&gt; for a start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I damaged one LCD with the current circuit because everything was working perfect then all of a sudden it was like the LCD Contrast was set all the way up, displaying only a dark screen but I couldn't adjust it with the U8Glib or with the V0. During programming I would disconnect the ground from the Arduino to the Breadboard, when I would do this the LCD would still flicker as it was being programmed. This is why I am wondering if I am missing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read somewhere that putting a MOSFET on the Ground of the LCD that is connected to the Reset pin helps. Another problem that I am having is I am using Eclipse with the Arduino C++ add in and sometimes I can program easily, everything goes as expected but then it will fail to upload until I unplug and reset the board sometimes several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the program is using pins 11-13 it can create problems because these are the same pins used for programming if I remember correctly. I tried changing the pins used but didn't seem to help anything.&lt;/p&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2015-11-21T20:43:46.223" Title="Arduino using LCD" Tags="|programming|arduino-mega|lcd|eclipse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="17999" PostTypeId="2" ParentId="17998" CreationDate="2015-11-21T20:43:46.223" Score="1" Body="&lt;p&gt;Disconnecting ground while all the other pins are connected and the Arduino is powered up is a &lt;em&gt;very&lt;/em&gt; bad idea.  Either manually, or using a MOSFET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply because the power you are feeding in to the screen wants to try and find a way to ground through some means or other - and if the ground is disconnected then that means muscling its way through the IO pins into the Arduino and through to ground that way.  The result is that you damage the LCD screen's fragile circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to disconnect the ground pin at any time, you must ensure that either the power is turned off, or the power connections to the LCD are disconnected first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to have the Arduino's RESET toggle the power to the LCD to force a hard reset then you need to use a P-channel MOSFET in the power connection instead, so the ground connection is always connected.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-21T20:43:46.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18001" PostTypeId="1" CreationDate="2015-11-21T21:09:06.550" Score="0" ViewCount="1912" Body="&lt;p&gt;I am sending custom code to Arduino with this ardulink command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{        ArduinoControl.link.sendCustomMessage(&quot;oled&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code from standard Ardulink sketch CustomMessagesChipKit.ino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  if (stringComplete) {&#xA;    if(inputString.startsWith(&quot;alp://&quot;)) {&#xA;    // OK is a message I know (this is general code you can reuse)&#xA;      boolean msgRecognized = true;&#xA;      if(inputString.substring(6,10) == &quot;cust&quot;) { // Custom Message&#xA;        // here you can write your own code.&#xA;        int separatorPosition = inputString.indexOf('/', 11 );&#xA;        int messageIdPosition = inputString.indexOf('?', 11 );&#xA;        String customId = inputString.substring(11,separatorPosition);&#xA;        String value = inputString.substring(separatorPosition + 1, messageIdPosition);&#xA;        if(customId == &quot;oled&quot;) {&#xA;            //Clear the virtual buffer&#xA;            lcd.noBacklight();&#xA;            analogWrite(9,100);&#xA;            digitalWrite(13, HIGH);&#xA;            lcd.clear();&#xA;            lcd.setCursor(0,0);&#xA;            lcd.print(&quot;jkhgvjgv&quot;);&#xA;        } else {&#xA;          msgRecognized = false;&#xA;          // this sketch doesn't know other messages in this case command is ko (not ok)&#xA;        }&#xA;      } else {&#xA;        msgRecognized = false;&#xA;        // this sketch doesn't know other messages in this case command is ko (not ok)&#xA;      }&#xA;      // Prepare reply message if caller supply a message id (this is general code you can reuse)&#xA;      int idPosition = inputString.indexOf(&quot;?id=&quot;);&#xA;      if(idPosition != -1) {&#xA;        String id = inputString.substring(idPosition + 4);&#xA;        // print the reply&#xA;        Serial.print(&quot;alp://rply/&quot;);&#xA;        if(msgRecognized) { // this sketch doesn't know other messages in this case command is ko (not ok)&#xA;          Serial.print(&quot;ok?id=&quot;);&#xA;        } else {&#xA;          Serial.print(&quot;ko?id=&quot;);&#xA;        }&#xA;        Serial.print(id);&#xA;        Serial.write(255); // End of Message&#xA;        Serial.flush();&#xA;      }&#xA;    }&#xA;    // clear the string:&#xA;    inputString = &quot;&quot;;&#xA;    stringComplete = false;&#xA;  }}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a result the LED on pin 13 is turning on after message from java program. But that is all. LCD or or LED on PWM 9 pin are not reacting at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I could not understand how to send an answer back from Arduino to Ardulink. Can you please show me an example? I would love to send and print data in Java program from  DHT11 sensor in response. I know about RawDataListener and I read the whole Ardulink site, but I did not understand that. I a newbie in programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When i replace &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{String customId = inputString.substring(11,separatorPosition);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{String customId = inputString.substring(11,15);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;than everything works. What can it be?&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="15007" LastEditDate="2015-11-29T13:14:28.247" LastActivityDate="2016-01-28T16:05:04.093" Title="Sending and receiving custom messages with Ardulink" Tags="|arduino-uno|serial|library|communication|java|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18003" PostTypeId="1" CreationDate="2015-11-22T01:20:04.713" Score="2" ViewCount="126" Body="&lt;p&gt;I'm trying to get set up to develop for the &lt;a href=&quot;https://www.adafruit.com/products/1501&quot; rel=&quot;nofollow&quot;&gt;Adafruit Trinket&lt;/a&gt; on a Mac running the OS X El Capitan beta (10.11.2 beta) with Xcode and &lt;a href=&quot;http://embedxcode.weebly.com&quot; rel=&quot;nofollow&quot;&gt;embedXcode&lt;/a&gt;. I've got the Arduino IDE downloaded from arduino.cc installed as /Applications/ArduinoCC.app. I'm able to build and run the Blink example using the Arduino IDE and Xcode appears to also work (it knows about the Trinket, and claims to successfully load the code) but it does not blink. The red LED on pin 1 just continues to pulse at about 10 Hz as if it was waiting to for code to be loaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what could be going on or how I can troubleshoot further?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updates:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I've made the changes to avrdude.conf suggested by the folks at Adafruit to accommodate the erase timing requirements of the Trinket.&lt;/li&gt;&#xA;&lt;li&gt;I got a response on the Adafruit forum that suggested going back to 1.6.5 as many people have been reporting problems with 1.6.6 breaking things. However, I can program the board using 1.6.6.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-11-25T17:08:03.853" LastActivityDate="2015-11-25T17:08:03.853" Title="Using embedXcode with Adafruit Trinket" Tags="|ide|osx|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18004" PostTypeId="2" ParentId="17780" CreationDate="2015-11-22T06:29:36.627" Score="0" Body="&lt;p&gt;Following code changes have been made to send the values in hex as input from user&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;replace the utf-8 conversion &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;value = message.getBytes(&quot;UTF-8&quot;);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;by hex&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int len = message.length();&#xA;byte[] data = new byte[len / 2];&#xA;for (int i = 0; i &amp;lt; len; i += 2) {&#xA;    data[i / 2] = (byte) ((Character.digit(message.charAt(i), 16) &amp;lt;&amp;lt; 4)&#xA;            + Character.digit(message.charAt(i+1), 16));&#xA;}&#xA;value=data;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;suppress the exception headlining for UnsupportedEncodingException&#xA;otherwise it throws a compile time error  UnsupportedEncodingException&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Result examples :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3F ( hex ) results in ? ( ascii )&#xA;63 results in c&lt;/p&gt;&#xA;" OwnerUserId="14152" LastActivityDate="2015-11-22T06:29:36.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18005" PostTypeId="1" AcceptedAnswerId="18009" CreationDate="2015-11-22T14:45:08.220" Score="1" ViewCount="456" Body="&lt;p&gt;Ref: &lt;a href=&quot;https://robotics.stackexchange.com/q/8526/11146&quot;&gt;https://robotics.stackexchange.com/q/8526/11146&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to build a simple android controlled robot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will connect &lt;code&gt;android phone&amp;lt;usb&amp;gt;arduino&amp;lt;wire&amp;gt;motor controller&amp;lt;wire&amp;gt;dc motor&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder why I have to write two programs (android java &amp;amp; arduino c++)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I directly control the DC motor from android java program without writing arduino code?&lt;/p&gt;&#xA;" OwnerUserId="15017" LastEditorUserId="-1" LastEditDate="2017-04-13T12:49:17.743" LastActivityDate="2015-11-22T17:08:10.283" Title="Controlling DC motor from Android device" Tags="|arduino-uno|usb|android|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18006" PostTypeId="1" CreationDate="2015-11-22T15:16:25.207" Score="12" ViewCount="3126" Body="&lt;p&gt;I'm having trouble trying to get Arduino digital ports values and set these values into a Python Tkinter Widget Scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Python and Arduino with Firmata.  I'm able to access my arduino board with python code.  For example in a label widget I'm getting and setting Arduino analog port value in real-time to a label as in following code without any problems:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import Tkinter&#xA;import pyfirmata&#xA;&#xA;def onStartButtonPress():&#xA;    while True:&#xA;        if flag.get():&#xA;            analogReadLabel.config(text=str(a0.read()))&#xA;            analogReadLabel.update_idletasks()&#xA;            top.update()&#xA;        else:&#xA;            break&#xA;    board.exit()&#xA;    top.destroy()&#xA;&#xA;def onExitButtonPress():&#xA;    flag.set(False)&#xA;&#xA;port = 'COM7'&#xA;board = pyfirmata.Arduino(port)&#xA;&#xA;it = pyfirmata.util.Iterator(board)&#xA;it.start()&#xA;&#xA;a0 = board.get_pin('a:0:i')&#xA;&#xA;top = Tkinter.Tk()&#xA;top.title(&quot;Reading Analog pins&quot;)&#xA;&#xA;descriptionLabel = Tkinter.Label(top, text=&quot;Potentiometer input:- &quot;)&#xA;descriptionLabel.grid(column=1, row=1)&#xA;&#xA;analogReadLabel = Tkinter.Label(top, text=&quot;Press Start..&quot;)&#xA;analogReadLabel.grid(column=2, row=1)&#xA;&#xA;flag = Tkinter.BooleanVar(top)&#xA;flag.set(True)&#xA;&#xA;startButton = Tkinter.Button(top, text=&quot;Start&quot;, command=onStartButtonPress)&#xA;startButton.grid(column=1, row=2)&#xA;&#xA;exitButton = Tkinter.Button(top, text=&quot;Exit&quot;, command=onExitButtonPress)&#xA;exitButton.grid(column=2, row=2)&#xA;&#xA;top.mainloop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Up to this point it's okay and the GUI shows me something like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/wNfXQ.png&quot; alt=&quot;Python Gui interface reading real-time value from analog 0&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what I'm trying to do and not getting is: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/udb6v.png&quot; alt=&quot;What I&amp;#39;m trying to update Scale with digital pins&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import Tkinter&#xA;import pyfirmata&#xA;import serial; &#xA;&#xA;def onStartButtonPress():&#xA;    while True:&#xA;        if flag.get():&#xA;            analogReadLabel.config(text=str(d8.read()))&#xA;            analogReadLabel1.config(text=str(d9.read()))&#xA;            analogReadLabel2.config(text=str(d10.read()))&#xA;            analogReadLabel.update_idletasks()&#xA;&#xA;        pos1 = d8.read()&#xA;        if pos1 == True:&#xA;            pos1 = int(pos1)&#xA;            pos1 = 0&#xA;            brightnessScale.set(pos1)&#xA;&#xA;        pos2 = d9.read()&#xA;        if pos2 == True:&#xA;            pos2 = int(pos2)&#xA;            pos2 = 100&#xA;            brightnessScale.set(pos2)&#xA;&#xA;       ''' and so on '''&#xA;&#xA;        brightnessScale.update_idletasks()&#xA;        top.update()&#xA;    else:&#xA;        break&#xA;board.exit()&#xA;top.destroy()&#xA;&#xA;&#xA;def onExitButtonPress():&#xA;    flag.set(False)&#xA;&#xA;port = 'COM7'&#xA;board = pyfirmata.Arduino(port)&#xA;&#xA;it = pyfirmata.util.Iterator(board)&#xA;it.start()&#xA;&#xA;a0 = board.get_pin('a:0:i')&#xA;&#xA;d4 = board.get_pin('d:4:i')&#xA;d5 = board.get_pin('d:5:i')&#xA;d6 = board.get_pin('d:6:i')&#xA;d7 = board.get_pin('d:7:i')&#xA;d8 = board.get_pin('d:8:i')&#xA;d9 = board.get_pin('d:9:i')&#xA;d10 = board.get_pin('d:10:i')&#xA;&#xA;top = Tkinter.Tk()&#xA;top.geometry(&quot;800x600&quot;)&#xA;top.title(&quot;Reading Analog pins&quot;)&#xA;&#xA;descriptionLabel = Tkinter.Label(top, text=&quot;Potentiometer input:- &quot;)&#xA;descriptionLabel.grid(column=1, row=1)&#xA;&#xA;analogReadLabel = Tkinter.Label(top, text=&quot;Level 1&quot;)&#xA;analogReadLabel.grid(column=2, row=1)&#xA;&#xA;analogReadLabel1 = Tkinter.Label(top, text=&quot;Level 2&quot;)&#xA;analogReadLabel1.grid(column=3, row=1)&#xA;&#xA;analogReadLabel2 = Tkinter.Label(top, text=&quot;Level 3&quot;)&#xA;analogReadLabel2.grid(column=4, row=1)&#xA;&#xA;brightnessScale = Tkinter.Scale(top, from_ = 500, &#xA;                            to = 0, &#xA;                            length = 500, &#xA;                            width = &quot;30&quot;,&#xA;                            tickinterval = 50, &#xA;&#xA;                            bg = &quot;lightskyblue&quot;,&#xA;                            highlightcolor = &quot;darkblue&quot;,&#xA;                            highlightbackground = &quot;royalblue&quot;,&#xA;                            troughcolor = &quot;darkblue&quot;,&#xA;&#xA;                            state = Tkinter.DISABLED,&#xA;                            sliderlength = 50,&#xA;                            relief = &quot;sunken&quot;,&#xA;                            label = &quot;Volume do Reservatorio em %&quot;,&#xA;                            orient = Tkinter.VERTICAL)&#xA;brightnessScale.grid(column=1, row=5)&#xA;Tkinter.Label(top,text=&quot;Volume da Caixa em (%)&quot;).grid(column=1, row=6)&#xA;&#xA;flag = Tkinter.BooleanVar(top)&#xA;flag.set(True)&#xA;&#xA;startButton = Tkinter.Button(top, text=&quot;Start&quot;, command=onStartButtonPress)&#xA;startButton.grid(column=1, row=2)&#xA;&#xA;exitButton = Tkinter.Button(top, text=&quot;Exit&quot;, command=onExitButtonPress)&#xA;exitButton.grid(column=2, row=2)&#xA;&#xA;top.mainloop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To summarize: I have reed switches in each digital port declared in the code.  These reed switches are normally open state, when I put a magnetic field near them it turn to close and I get a change in that value like from False to True.  What I'm trying to do is update the Tkinter Scale Widget in real time as the labels but I'm not getting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any trick in python code that can solve my problem ? Because I did a lot of research on the internet and I could not get done, as you can see in image 2 when the state of the second digital pin changes, a label changes to True, and in the scale code this corresponds to the value 100, but it's still on the 0 mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not comfortable also with the usage of command, and variable parameters of scale widget.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, I want to update in real time python Tkinter scale widget according to values from digital ports from arduino using firmata. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Python 2.7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: for completeness:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my arduino code (Sketch) without firmata, which is working as expected.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int level; &#xA;int position; &#xA;&#xA;void setup() {&#xA;&#xA;pinMode(8, INPUT); &#xA;pinMode(9, INPUT);&#xA;pinMode(10, INPUT);&#xA;pinMode(11, INPUT);&#xA;pinMode(12, INPUT);&#xA;&#xA;Serial.begin(9600); // ativa a porta serial&#xA;&#xA;void loop() {&#xA;digitalWrite(8, LOW); &#xA;digitalWrite(9, LOW);&#xA;digitalWrite(10, LOW);&#xA;digitalWrite(11, LOW);&#xA;digitalWrite(12, LOW);&#xA;&#xA;&#xA;position = digitalRead(8); &#xA;if ( position == HIGH) {level=0;}&#xA;&#xA;position = digitalRead(9); &#xA;if ( position == HIGH) {Level=100;}&#xA;&#xA;position = digitalRead(10); &#xA;if ( position == HIGH) {level=200;}&#xA;&#xA;position = digitalRead(11); &#xA;if ( position == HIGH) {level=300;}&#xA;&#xA;position = digitalRead(12); &#xA;if ( position == HIGH) {level=400;}&#xA;&#xA;Serial.println(level); &#xA;delay(500);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I could do also here&#xA;is get these values via serial in python and use them to update the scale in this way but I don't know if in this method it's gonna work also!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what I thought in Python: &#xA;But I still have much to learn in algorithms and Data Structures. &#xA;Just the Pseudo Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;def setScaleValue():&#xA;while True:&#xA;    if flag.get():&#xA;         pos1 = d4.read()&#xA;        if pos1 == True: #or 1 &#xA;        #Here is the problem i don't know for sure what comes in my digital port&#xA;        #If is a True bool or a 1 as HIGH value from arduino&#xA;        #And probably i don't know if it's possible to change the values of a scale in this way !!!&#xA;        #or if i'm mistaken the Cast stuff in Python&#xA;            pos1 = int(pos1)&#xA;            pos1 = 0&#xA;            brightnessScale.set(pos1)&#xA;&#xA;        pos2 = d8.read()&#xA;        if pos2 == True:&#xA;            pos2 = int(pos2)&#xA;            pos2 = 100&#xA;            brightnessScale.set(pos2)&#xA;&#xA;        brightnessScale.update_idletasks()&#xA;        top.update()&#xA;    else:&#xA;        break&#xA;board.exit()&#xA;top.destroy()&#xA;&#xA;return&#xA;&#xA;&#xA;d4 = board.get_pin('d:4:i')&#xA;d5 = board.get_pin('d:5:i')&#xA;d6 = board.get_pin('d:6:i')&#xA;d7 = board.get_pin('d:7:i')&#xA;d8 = board.get_pin('d:8:i')&#xA;&#xA;brightnessScale = Tkinter.Scale(top, from_ = 500, &#xA;                            to = 0, &#xA;                            length = 500, &#xA;                            width = &quot;30&quot;,&#xA;                            tickinterval = 50, &#xA;&#xA;                            bg = &quot;lightskyblue&quot;,&#xA;                            highlightcolor = &quot;darkblue&quot;,&#xA;                            highlightbackground = &quot;royalblue&quot;,&#xA;                            troughcolor = &quot;darkblue&quot;,&#xA;&#xA;                            state = Tkinter.DISABLED,&#xA;                            sliderlength = 50,&#xA;                            relief = &quot;sunken&quot;,&#xA;                            label = &quot;Volume do Reservatorio em %&quot;,&#xA;                            orient = Tkinter.VERTICAL)&#xA;brightnessScale.grid(column=1, row=5)&#xA;Tkinter.Label(top,text=&quot;Volume da Caixa em (%)&quot;).grid(column=1, row=6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15019" LastEditorUserId="3917" LastEditDate="2015-12-01T18:18:09.173" LastActivityDate="2020-12-16T02:04:20.333" Title="Update Dynamically Tkinter Widget Scale from Arduino Ports using python and firmata" Tags="|arduino-uno|usb|analogread|python|firmata|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18007" PostTypeId="1" AcceptedAnswerId="18008" CreationDate="2015-11-22T16:16:19.517" Score="3" ViewCount="6532" Body="&lt;p&gt;How can I do a readable, small, smart and good URL decoder in Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String GetRidOfurlCharacters(String urlChars)&#xA;{&#xA;&#xA;  urlChars.replace(&quot;%0D%0A&quot;, String('\n'));&#xA;&#xA;  urlChars.replace(&quot;+&quot;,   &quot; &quot;);&#xA;  urlChars.replace(&quot;%20&quot;, &quot; &quot;);&#xA;  urlChars.replace(&quot;%21&quot;, &quot;!&quot;);&#xA;  urlChars.replace(&quot;%22&quot;, String(char('\&quot;')));&#xA;  urlChars.replace(&quot;%23&quot;, &quot;#&quot;);&#xA;  urlChars.replace(&quot;%24&quot;, &quot;$&quot;);&#xA;  urlChars.replace(&quot;%25&quot;, &quot;%&quot;);&#xA;  urlChars.replace(&quot;%26&quot;, &quot;&amp;amp;&quot;);&#xA;  urlChars.replace(&quot;%27&quot;, String(char(39)));&#xA;  urlChars.replace(&quot;%28&quot;, &quot;(&quot;);&#xA;  urlChars.replace(&quot;%29&quot;, &quot;)&quot;);&#xA;  urlChars.replace(&quot;%2A&quot;, &quot;*&quot;);&#xA;  urlChars.replace(&quot;%2B&quot;, &quot;+&quot;);&#xA;  urlChars.replace(&quot;%2C&quot;, &quot;,&quot;);&#xA;  urlChars.replace(&quot;%2D&quot;, &quot;-&quot;);&#xA;  urlChars.replace(&quot;%2E&quot;, &quot;.&quot;);&#xA;  urlChars.replace(&quot;%2F&quot;, &quot;/&quot;);&#xA;  urlChars.replace(&quot;%30&quot;, &quot;0&quot;);&#xA;  urlChars.replace(&quot;%31&quot;, &quot;1&quot;);&#xA;  urlChars.replace(&quot;%32&quot;, &quot;2&quot;);&#xA;  urlChars.replace(&quot;%33&quot;, &quot;3&quot;);&#xA;  urlChars.replace(&quot;%34&quot;, &quot;4&quot;);&#xA;  urlChars.replace(&quot;%35&quot;, &quot;5&quot;);&#xA;  urlChars.replace(&quot;%36&quot;, &quot;6&quot;);&#xA;  urlChars.replace(&quot;%37&quot;, &quot;7&quot;);&#xA;  urlChars.replace(&quot;%38&quot;, &quot;8&quot;);&#xA;  urlChars.replace(&quot;%39&quot;, &quot;9&quot;);&#xA;  urlChars.replace(&quot;%3A&quot;, &quot;:&quot;);&#xA;  urlChars.replace(&quot;%3B&quot;, &quot;;&quot;);&#xA;  urlChars.replace(&quot;%3C&quot;, &quot;&amp;lt;&quot;);&#xA;  urlChars.replace(&quot;%3D&quot;, &quot;=&quot;);&#xA;  urlChars.replace(&quot;%3E&quot;, &quot;&amp;gt;&quot;);&#xA;  urlChars.replace(&quot;%3F&quot;, &quot;?&quot;);&#xA;  urlChars.replace(&quot;%40&quot;, &quot;@&quot;);&#xA;  urlChars.replace(&quot;%41&quot;, &quot;A&quot;);&#xA;  urlChars.replace(&quot;%42&quot;, &quot;B&quot;);&#xA;  urlChars.replace(&quot;%43&quot;, &quot;C&quot;);&#xA;  urlChars.replace(&quot;%44&quot;, &quot;D&quot;);&#xA;  urlChars.replace(&quot;%45&quot;, &quot;E&quot;);&#xA;  urlChars.replace(&quot;%46&quot;, &quot;F&quot;);&#xA;  urlChars.replace(&quot;%47&quot;, &quot;G&quot;);&#xA;  urlChars.replace(&quot;%48&quot;, &quot;H&quot;);&#xA;  urlChars.replace(&quot;%49&quot;, &quot;I&quot;);&#xA;  urlChars.replace(&quot;%4A&quot;, &quot;J&quot;);&#xA;  urlChars.replace(&quot;%4B&quot;, &quot;K&quot;);&#xA;  urlChars.replace(&quot;%4C&quot;, &quot;L&quot;);&#xA;  urlChars.replace(&quot;%4D&quot;, &quot;M&quot;);&#xA;  urlChars.replace(&quot;%4E&quot;, &quot;N&quot;);&#xA;  urlChars.replace(&quot;%4F&quot;, &quot;O&quot;);&#xA;  urlChars.replace(&quot;%50&quot;, &quot;P&quot;);&#xA;  urlChars.replace(&quot;%51&quot;, &quot;Q&quot;);&#xA;  urlChars.replace(&quot;%52&quot;, &quot;R&quot;);&#xA;  urlChars.replace(&quot;%53&quot;, &quot;S&quot;);&#xA;  urlChars.replace(&quot;%54&quot;, &quot;T&quot;);&#xA;  urlChars.replace(&quot;%55&quot;, &quot;U&quot;);&#xA;  urlChars.replace(&quot;%56&quot;, &quot;V&quot;);&#xA;  urlChars.replace(&quot;%57&quot;, &quot;W&quot;);&#xA;  urlChars.replace(&quot;%58&quot;, &quot;X&quot;);&#xA;  urlChars.replace(&quot;%59&quot;, &quot;Y&quot;);&#xA;  urlChars.replace(&quot;%5A&quot;, &quot;Z&quot;);&#xA;  urlChars.replace(&quot;%5B&quot;, &quot;[&quot;);&#xA;  urlChars.replace(&quot;%5C&quot;, String(char(65)));&#xA;  urlChars.replace(&quot;%5D&quot;, &quot;]&quot;);&#xA;  urlChars.replace(&quot;%5E&quot;, &quot;^&quot;);&#xA;  urlChars.replace(&quot;%5F&quot;, &quot;_&quot;);&#xA;  urlChars.replace(&quot;%60&quot;, &quot;`&quot;);&#xA;  urlChars.replace(&quot;%61&quot;, &quot;a&quot;);&#xA;  urlChars.replace(&quot;%62&quot;, &quot;b&quot;);&#xA;  urlChars.replace(&quot;%63&quot;, &quot;c&quot;);&#xA;  urlChars.replace(&quot;%64&quot;, &quot;d&quot;);&#xA;  urlChars.replace(&quot;%65&quot;, &quot;e&quot;);&#xA;  urlChars.replace(&quot;%66&quot;, &quot;f&quot;);&#xA;  urlChars.replace(&quot;%67&quot;, &quot;g&quot;);&#xA;  urlChars.replace(&quot;%68&quot;, &quot;h&quot;);&#xA;  urlChars.replace(&quot;%69&quot;, &quot;i&quot;);&#xA;  urlChars.replace(&quot;%6A&quot;, &quot;j&quot;);&#xA;  urlChars.replace(&quot;%6B&quot;, &quot;k&quot;);&#xA;  urlChars.replace(&quot;%6C&quot;, &quot;l&quot;);&#xA;  urlChars.replace(&quot;%6D&quot;, &quot;m&quot;);&#xA;  urlChars.replace(&quot;%6E&quot;, &quot;n&quot;);&#xA;  urlChars.replace(&quot;%6F&quot;, &quot;o&quot;);&#xA;  urlChars.replace(&quot;%70&quot;, &quot;p&quot;);&#xA;  urlChars.replace(&quot;%71&quot;, &quot;q&quot;);&#xA;  urlChars.replace(&quot;%72&quot;, &quot;r&quot;);&#xA;  urlChars.replace(&quot;%73&quot;, &quot;s&quot;);&#xA;  urlChars.replace(&quot;%74&quot;, &quot;t&quot;);&#xA;  urlChars.replace(&quot;%75&quot;, &quot;u&quot;);&#xA;  urlChars.replace(&quot;%76&quot;, &quot;v&quot;);&#xA;  urlChars.replace(&quot;%77&quot;, &quot;w&quot;);&#xA;  urlChars.replace(&quot;%78&quot;, &quot;x&quot;);&#xA;  urlChars.replace(&quot;%79&quot;, &quot;y&quot;);&#xA;  urlChars.replace(&quot;%7A&quot;, &quot;z&quot;);&#xA;  urlChars.replace(&quot;%7B&quot;, String(char(123)));&#xA;  urlChars.replace(&quot;%7C&quot;, &quot;|&quot;);&#xA;  urlChars.replace(&quot;%7D&quot;, String(char(125)));&#xA;  urlChars.replace(&quot;%7E&quot;, &quot;~&quot;);&#xA;  urlChars.replace(&quot;%7F&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%80&quot;, &quot;`&quot;);&#xA;  urlChars.replace(&quot;%81&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%82&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%83&quot;, &quot;Æ&quot;);&#xA;  urlChars.replace(&quot;%84&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%85&quot;, &quot;â¦&quot;);&#xA;  urlChars.replace(&quot;%86&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%87&quot;, &quot;â¡&quot;);&#xA;  urlChars.replace(&quot;%88&quot;, &quot;Ë&quot;);&#xA;  urlChars.replace(&quot;%89&quot;, &quot;â°&quot;);&#xA;  urlChars.replace(&quot;%8A&quot;, &quot;Å&quot;);&#xA;  urlChars.replace(&quot;%8B&quot;, &quot;â¹&quot;);&#xA;  urlChars.replace(&quot;%8C&quot;, &quot;Å&quot;);&#xA;  urlChars.replace(&quot;%8D&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%8E&quot;, &quot;Å½&quot;);&#xA;  urlChars.replace(&quot;%8F&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%90&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%91&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%92&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%93&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%94&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%95&quot;, &quot;â¢&quot;);&#xA;  urlChars.replace(&quot;%96&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%97&quot;, &quot;â&quot;);&#xA;  urlChars.replace(&quot;%98&quot;, &quot;Ë&quot;);&#xA;  urlChars.replace(&quot;%99&quot;, &quot;â¢&quot;);&#xA;  urlChars.replace(&quot;%9A&quot;, &quot;Å¡&quot;);&#xA;  urlChars.replace(&quot;%9B&quot;, &quot;âº&quot;);&#xA;  urlChars.replace(&quot;%9C&quot;, &quot;Å&quot;);&#xA;  urlChars.replace(&quot;%9D&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%9E&quot;, &quot;Å¾&quot;);&#xA;  urlChars.replace(&quot;%9F&quot;, &quot;Å¸&quot;);&#xA;  urlChars.replace(&quot;%A0&quot;, &quot;Â&quot;);&#xA;  urlChars.replace(&quot;%A1&quot;, &quot;Â¡&quot;);&#xA;  urlChars.replace(&quot;%A2&quot;, &quot;Â¢&quot;);&#xA;  urlChars.replace(&quot;%A3&quot;, &quot;Â£&quot;);&#xA;  urlChars.replace(&quot;%A4&quot;, &quot;Â¤&quot;);&#xA;  urlChars.replace(&quot;%A5&quot;, &quot;Â¥&quot;);&#xA;  urlChars.replace(&quot;%A6&quot;, &quot;Â¦&quot;);&#xA;  urlChars.replace(&quot;%A7&quot;, &quot;Â§&quot;);&#xA;  urlChars.replace(&quot;%A8&quot;, &quot;Â¨&quot;);&#xA;  urlChars.replace(&quot;%A9&quot;, &quot;Â©&quot;);&#xA;  urlChars.replace(&quot;%AA&quot;, &quot;Âª&quot;);&#xA;  urlChars.replace(&quot;%AB&quot;, &quot;Â«&quot;);&#xA;  urlChars.replace(&quot;%AC&quot;, &quot;Â¬&quot;);&#xA;  urlChars.replace(&quot;%AE&quot;, &quot;Â®&quot;);&#xA;  urlChars.replace(&quot;%AF&quot;, &quot;Â¯&quot;);&#xA;  urlChars.replace(&quot;%B0&quot;, &quot;Â°&quot;);&#xA;  urlChars.replace(&quot;%B1&quot;, &quot;Â±&quot;);&#xA;  urlChars.replace(&quot;%B2&quot;, &quot;Â²&quot;);&#xA;  urlChars.replace(&quot;%B3&quot;, &quot;Â³&quot;);&#xA;  urlChars.replace(&quot;%B4&quot;, &quot;Â´&quot;);&#xA;  urlChars.replace(&quot;%B5&quot;, &quot;Âµ&quot;);&#xA;  urlChars.replace(&quot;%B6&quot;, &quot;Â¶&quot;);&#xA;  urlChars.replace(&quot;%B7&quot;, &quot;Â·&quot;);&#xA;  urlChars.replace(&quot;%B8&quot;, &quot;Â¸&quot;);&#xA;  urlChars.replace(&quot;%B9&quot;, &quot;Â¹&quot;);&#xA;  urlChars.replace(&quot;%BA&quot;, &quot;Âº&quot;);&#xA;  urlChars.replace(&quot;%BB&quot;, &quot;Â»&quot;);&#xA;  urlChars.replace(&quot;%BC&quot;, &quot;Â¼&quot;);&#xA;  urlChars.replace(&quot;%BD&quot;, &quot;Â½&quot;);&#xA;  urlChars.replace(&quot;%BE&quot;, &quot;Â¾&quot;);&#xA;  urlChars.replace(&quot;%BF&quot;, &quot;Â¿&quot;);&#xA;  urlChars.replace(&quot;%C0&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C1&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C2&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C3&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C4&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C5&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C6&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C7&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C8&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%C9&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CA&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CB&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CC&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CD&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CE&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%CF&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D0&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D1&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D2&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D3&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D4&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D5&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D6&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D7&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D8&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%D9&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DA&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DB&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DC&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DD&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DE&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%DF&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%E0&quot;, &quot;Ã&quot;);&#xA;  urlChars.replace(&quot;%E1&quot;, &quot;Ã¡&quot;);&#xA;  urlChars.replace(&quot;%E2&quot;, &quot;Ã¢&quot;);&#xA;  urlChars.replace(&quot;%E3&quot;, &quot;Ã£&quot;);&#xA;  urlChars.replace(&quot;%E4&quot;, &quot;Ã¤&quot;);&#xA;  urlChars.replace(&quot;%E5&quot;, &quot;Ã¥&quot;);&#xA;  urlChars.replace(&quot;%E6&quot;, &quot;Ã¦&quot;);&#xA;  urlChars.replace(&quot;%E7&quot;, &quot;Ã§&quot;);&#xA;  urlChars.replace(&quot;%E8&quot;, &quot;Ã¨&quot;);&#xA;  urlChars.replace(&quot;%E9&quot;, &quot;Ã©&quot;);&#xA;  urlChars.replace(&quot;%EA&quot;, &quot;Ãª&quot;);&#xA;  urlChars.replace(&quot;%EB&quot;, &quot;Ã«&quot;);&#xA;  urlChars.replace(&quot;%EC&quot;, &quot;Ã¬&quot;);&#xA;  urlChars.replace(&quot;%ED&quot;, &quot;Ã­&quot;);&#xA;  urlChars.replace(&quot;%EE&quot;, &quot;Ã®&quot;);&#xA;  urlChars.replace(&quot;%EF&quot;, &quot;Ã¯&quot;);&#xA;  urlChars.replace(&quot;%F0&quot;, &quot;Ã°&quot;);&#xA;  urlChars.replace(&quot;%F1&quot;, &quot;Ã±&quot;);&#xA;  urlChars.replace(&quot;%F2&quot;, &quot;Ã²&quot;);&#xA;  urlChars.replace(&quot;%F3&quot;, &quot;Ã³&quot;);&#xA;  urlChars.replace(&quot;%F4&quot;, &quot;Ã´&quot;);&#xA;  urlChars.replace(&quot;%F5&quot;, &quot;Ãµ&quot;);&#xA;  urlChars.replace(&quot;%F6&quot;, &quot;Ã¶&quot;);&#xA;  urlChars.replace(&quot;%F7&quot;, &quot;Ã·&quot;);&#xA;  urlChars.replace(&quot;%F8&quot;, &quot;Ã¸&quot;);&#xA;  urlChars.replace(&quot;%F9&quot;, &quot;Ã¹&quot;);&#xA;  urlChars.replace(&quot;%FA&quot;, &quot;Ãº&quot;);&#xA;  urlChars.replace(&quot;%FB&quot;, &quot;Ã»&quot;);&#xA;  urlChars.replace(&quot;%FC&quot;, &quot;Ã¼&quot;);&#xA;  urlChars.replace(&quot;%FD&quot;, &quot;Ã½&quot;);&#xA;  urlChars.replace(&quot;%FE&quot;, &quot;Ã¾&quot;);&#xA;  urlChars.replace(&quot;%FF&quot;, &quot;Ã¿&quot;);&#xA;&#xA;  return urlChars;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I want to make a loop and only replace a url escaping if it exists, not trying to replace all the (possible) occurrences.&lt;/p&gt;&#xA;" OwnerUserId="14182" LastActivityDate="2016-08-10T10:26:13.977" Title="Simple URL decoding" Tags="|programming|c++|string|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18008" PostTypeId="2" ParentId="18007" CreationDate="2015-11-22T16:42:23.893" Score="4" Body="&lt;p&gt;The fact that you're using a String (urgh, shudder shudder... you should read this: &lt;a href=&quot;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&quot; rel=&quot;noreferrer&quot;&gt;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&lt;/a&gt;) actually makes it a little harder to work with.  Instead you should have your String data in a character array (&quot;C string&quot;). Then a parser is much easier to write using a pair of character pointers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the theory is you scan from the start of the string to the end of the string using both pointers copying characters as you go, and as soon as you hit a &lt;code&gt;%&lt;/code&gt; you read ahead 2 characters using the first pointer (the second pointer stays where it is) and you convert the two read characters as hex into the ASCII equivalent and use the second pointer to replace the &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then both pointers keep moving forward, but they stay out of step. As each &lt;code&gt;%&lt;/code&gt; crops up the pointers get further and further out of step until you reach the end of the string and all the &lt;code&gt;%xx&lt;/code&gt; have been replaced with a single character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, this code I have just knocked up does the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char data[50] = &quot;http://foo/bar?x=hello%20there%3A%20majenko&quot;;&#xA;&#xA;// Create two pointers that point to the start of the data&#xA;char *leader = data;&#xA;char *follower = leader;&#xA;&#xA;// While we're not at the end of the string (current character not NULL)&#xA;while (*leader) {&#xA;    // Check to see if the current character is a %&#xA;    if (*leader == '%') {&#xA;&#xA;        // Grab the next two characters and move leader forwards&#xA;        leader++;&#xA;        char high = *leader;&#xA;        leader++;&#xA;        char low = *leader;&#xA;&#xA;        // Convert ASCII 0-9A-F to a value 0-15&#xA;        if (high &amp;gt; 0x39) high -= 7;&#xA;        high &amp;amp;= 0x0f;&#xA;&#xA;        // Same again for the low byte:&#xA;        if (low &amp;gt; 0x39) low -= 7;&#xA;        low &amp;amp;= 0x0f;&#xA;&#xA;        // Combine the two into a single byte and store in follower:&#xA;        *follower = (high &amp;lt;&amp;lt; 4) | low;&#xA;    } else {&#xA;        // All other characters copy verbatim&#xA;        *follower = *leader;&#xA;    }&#xA;&#xA;    // Move both pointers to the next character:&#xA;    leader++;&#xA;    follower++;&#xA;}&#xA;// Terminate the new string with a NULL character to trim it off&#xA;*follower = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;data&lt;/code&gt; array now contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://foo/bar?x=hello there: majenko&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-22T16:42:23.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18009" PostTypeId="2" ParentId="18005" CreationDate="2015-11-22T17:02:19.647" Score="2" Body="&lt;p&gt;The short answer is &quot;you can't.&quot; For the Arduino to do anything useful it needs to have instructions telling it what to do. In your example the Arduino's job is to do something that the Android can't – turn on and off the DC motor. You could even use a wifi or Bluetooth connection from the Android to the Arduino to make it possible to avoid the hassle of the USB cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your project requires a number of small hunks of code on the Arduino to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Listen for commands from the Android.&lt;/li&gt;&#xA;&lt;li&gt;Validate the commands received.&lt;/li&gt;&#xA;&lt;li&gt;Turn on or off the motor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Roughly speaking your loop() function might look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // look for a command&#xA;  // validate the command&#xA;  if (valid &amp;amp;&amp;amp; turn_motor_on) {&#xA;    motor_on();&#xA;  } else {&#xA;    motor_off();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fortunately the Arduino code can be very simple and there is a lot of example code to help you get started.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-11-22T17:08:10.283" LastActivityDate="2015-11-22T17:08:10.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18011" PostTypeId="1" CreationDate="2015-11-22T17:21:18.537" Score="1" ViewCount="459" Body="&lt;p&gt;I have build simple Arduino ISP programmer, which works fine on ATmega 328 chips (when I select Arduino UNO board) and a ton of others (tiny45, tiny2313). But, when I want to program an ATmega8 chip, it writes it succesfuly, but then the chip runs at 1/16 of the desired speed! (for example a delay(1000) in code takes 16 seconds real-life). I have a 16 MHz crystal oscillator with capacitors connected to the chip, so I thought that the problem is not there but... when I remove the crystal, the chip still runs the same, it still takes 16 seconds.&#xA;So I assume two possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the crystal is somehow broken, so the chip runs from some internal&#xA;thing? But I tried multiple crystals, all the same,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;OR&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;I am doing something wrong, but I really don't know what...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does somebody have an idea what may be wrong or how to test it? Or feel free for more details...Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: In IDE, I am selecting &quot;Arduino NG or older&quot; and then I select ATmega8  as processor. I am uploading the sketches directly, without bootloader.&lt;/p&gt;&#xA;" OwnerUserId="12154" LastEditorUserId="12154" LastEditDate="2015-11-22T17:26:25.793" LastActivityDate="2015-11-23T19:04:29.953" Title="ATmega 8 wrong timing with Arduino NG bootloader" Tags="|isp|frequency|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18012" PostTypeId="2" ParentId="17994" CreationDate="2015-11-22T17:41:39.830" Score="2" Body="&lt;p&gt;Are you willing / able to work with Xcode? There is a package called &lt;a href=&quot;http://embedxcode.weebly.com&quot; rel=&quot;nofollow&quot;&gt;embedXcode&lt;/a&gt; that enables Arduino development on Macs – I'm just getting up to speed with it, but it does appear to allow you to work either in Xcode or with the Arduino IDE (the .ino file is present and is what you edit in Xcode). In my testing so far it appears that the easiest thing to do is to create a project using Xcode and then you can point the Arduino IDE at the project pretty easily, getting Xcode to pick up a sketch started in the Arduino IDE is currently beyond me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the point of view of your students I would think that you'd want to keep the .ino file rather than make them learn about the conventions of C or C++. It would also save you the hassle of somehow managing file names – although you could probably get make to do this for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't looked into it at all, but I think you could do something similar with &lt;a href=&quot;https://atom.io&quot; rel=&quot;nofollow&quot;&gt;Atom&lt;/a&gt; (a quick Google found a blog post called &lt;em&gt;&lt;a href=&quot;https://viget.com/extend/arduino-development-in-atom-editor&quot; rel=&quot;nofollow&quot;&gt;Arduino Development in Atom Editor&lt;/a&gt;&lt;/em&gt; and an Atom package called &lt;a href=&quot;https://atom.io/packages/nino&quot; rel=&quot;nofollow&quot;&gt;nino&lt;/a&gt; that is described as a &quot;Toolbelt for Arduino&quot;) or Emacs, or for that matter Vim is also like to have some Arduino support.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-11-23T07:48:16.233" LastActivityDate="2015-11-23T07:48:16.233" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18013" PostTypeId="2" ParentId="13993" CreationDate="2015-11-22T18:24:05.713" Score="1" Body="&lt;p&gt;what i would do is test the parts one by one.&#xA;so first look if you're signal is good by attaching a led to it.&#xA;then test you're relay with 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now you should know what the problem is the arduino or the relay&lt;/p&gt;&#xA;" OwnerUserId="15022" LastActivityDate="2015-11-22T18:24:05.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18014" PostTypeId="1" CreationDate="2015-11-22T18:42:53.343" Score="2" ViewCount="57" Body="&lt;p&gt;I have a Flexiforce 25 pound pressure sensors connected to my Arduino Uno which connects to my laptop. My requirement is to be able to play video games using taps on pressure sensors. I am successfully sending signals to my Laptop and I am using Java on my Mac to send keystrokes (Key Down and Key Up) signals to move in the game. However I am facing issues with long key down and key up. How do I detect that and make sure that my program runs smooth? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uno code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {}&#xA;&#xA;void loop() {&#xA;int sensorValue = analogRead(A0);&#xA;int sensorValue2 = analogRead(A1);&#xA;int sensorValue3 = analogRead(A2);&#xA;int sensorValue4 = analogRead(A3);&#xA;int sensorValue5 = analogRead(A4);&#xA;int sensorValue6 = digitalRead(2);&#xA;&#xA;// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):&#xA;float voltage = sensorValue * (5.0 / 1023.0);&#xA;float voltage2 = sensorValue2 * (5.0 / 1023.0);&#xA;float voltage3 = sensorValue3 * (5.0 / 1023.0);&#xA;float voltage4 = sensorValue4 * (5.0 / 1023.0);&#xA;float voltage5 = sensorValue5 * (5.0 / 1023.0);&#xA;float voltage6 = sensorValue6 * (5.0 / 1023.0);&#xA;&#xA;if(voltage &amp;gt; 1){ &#xA;   Serial.begin(9600); Serial.println(&quot;A0&quot;); Serial.end();&#xA;}&#xA;if(voltage2 &amp;gt; 1){ &#xA;   Serial.begin(9600); Serial.println(&quot;A1&quot;); Serial.end();&#xA;}&#xA;if(voltage3 &amp;gt; 1){ &#xA;   Serial.begin(9600); Serial.println(&quot;A2&quot;); Serial.end();&#xA;}&#xA;if(voltage4 &amp;gt; 1){ &#xA;   Serial.begin(9600); Serial.println(&quot;A3&quot;); Serial.end();&#xA;}&#xA;if(voltage5 &amp;gt; 1){ &#xA;   Serial.begin(9600); Serial.println(&quot;A4&quot;); Serial.end();&#xA;}&#xA;if(voltage6 &amp;gt; 0){ &#xA;   Serial.begin(9600); Serial.println(&quot;D2&quot;); Serial.end();&#xA;}&#xA;// Wait 100 milliseconds&#xA;delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In java I'm using &lt;code&gt;java.wt.Robot&lt;/code&gt; and &lt;code&gt;gnu.io.SerialPort&lt;/code&gt; to press key and read from serial port. On a serialEvent I will override the listener function to perform my operation which is press Keys on my machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Java Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void serialEvent(SerialPortEvent oEvent) {&#xA;    if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {&#xA;        try {&#xA;            String inputLine = null;&#xA;            if (input.ready()) {&#xA;                inputLine = input.readLine();&#xA;                if (inputLine.contains(&quot;A0&quot;)) {&#xA;&#xA;                    long start = System.currentTimeMillis();&#xA;                    while (System.currentTimeMillis() - start &amp;lt; duration) {&#xA;                        robot.keyPress(KeyEvent.VK_UP);&#xA;                    }&#xA;                    robot.keyRelease(KeyEvent.VK_UP);&#xA;                    System.out.println(&quot;UP&quot;);&#xA;&#xA;                } else if (inputLine.contains(&quot;A1&quot;)) {&#xA;&#xA;                    long start = System.currentTimeMillis();&#xA;                    while (System.currentTimeMillis() - start &amp;lt; duration) {&#xA;                        robot.keyPress(KeyEvent.VK_DOWN);&#xA;                    }&#xA;                    robot.keyRelease(KeyEvent.VK_DOWN);&#xA;                    System.out.println(&quot;DOWN&quot;);&#xA;&#xA;                } else if (inputLine.contains(&quot;A2&quot;)) {&#xA;&#xA;                    long start = System.currentTimeMillis();&#xA;                    while (System.currentTimeMillis() - start &amp;lt; duration) {&#xA;                        robot.keyPress(KeyEvent.VK_LEFT);&#xA;                    }&#xA;                    robot.keyRelease(KeyEvent.VK_LEFT);&#xA;                    System.out.println(&quot;LEFT&quot;);&#xA;&#xA;                } else if (inputLine.contains(&quot;A3&quot;)) {&#xA;&#xA;                    long start = System.currentTimeMillis();&#xA;                    while (System.currentTimeMillis() - start &amp;lt; duration) {&#xA;                        robot.keyPress(KeyEvent.VK_RIGHT);&#xA;                    }&#xA;                    robot.keyRelease(KeyEvent.VK_RIGHT);&#xA;                    System.out.println(&quot;RIGHT&quot;);&#xA;&#xA;                } else if (inputLine.contains(&quot;A4&quot;)) {&#xA;&#xA;                    long start = System.currentTimeMillis();&#xA;                    while (System.currentTimeMillis() - start &amp;lt; duration) {&#xA;                        robot.keyPress(KeyEvent.VK_S);&#xA;                    }&#xA;                    robot.keyRelease(KeyEvent.VK_S);&#xA;                    System.out.println(&quot;S&quot;);&#xA;&#xA;                } else if (inputLine.contains(&quot;D2&quot;)) {&#xA;                    robot.keyPress(KeyEvent.VK_D);&#xA;                    robot.keyRelease(KeyEvent.VK_D);&#xA;                    System.out.println(&quot;D&quot;);&#xA;&#xA;                }&#xA;            }&#xA;&#xA;        } catch (Exception e) {&#xA;            System.err.println(e.toString());&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This performs Up, Down, Left, Right, &quot;S&quot; and &quot;D&quot; operation for SuperMario 3 GBA game. This works but not as smooth as intended. Is there anything that I can use to directly bind to my keyboard to get a smoother key operations. &lt;/p&gt;&#xA;" OwnerUserId="15023" LastActivityDate="2015-11-22T18:42:53.343" Title="Flexiforce to Uno to Keyboard. Working but not as inteded" Tags="|arduino-uno|mac-os|java|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18015" PostTypeId="1" AcceptedAnswerId="18317" CreationDate="2015-11-22T19:32:18.460" Score="5" ViewCount="14333" Body="&lt;p&gt;I have an I2C LCD screen provided with a Sunfounder kit and certainly built by DFRobot or such a constructor (there is nothing written on the LCD), and an Arduino Uno R3 copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is when I use &lt;code&gt;lcd.print()&lt;/code&gt; to write a string on the LCD, only the &lt;strong&gt;first character&lt;/strong&gt; of the string is printed. I can only print on other positions by using setCursor but only one character at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to change libraries (&lt;a href=&quot;https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library&quot; rel=&quot;nofollow&quot; title=&quot;github&quot;&gt;https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library&lt;/a&gt;, the one supplied with the LCD...), It always behaves the same!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, here's a very simplistic program which exhibits this behavior:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27, 16, 2);&#xA;// set the LCD address to 0x27 for a 16 chars and 2 line display&#xA;void setup() {&#xA;  lcd.init();&#xA;  lcd.backlight();&#xA;}&#xA;&#xA;void loop() {&#xA;  lcd.print(&quot;write&quot;);&#xA;  delay(1000);&#xA;  lcd.setCursor(10, 0);&#xA;  lcd.print(&quot;p10&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;0, 1 write&quot;);&#xA;  if((millis() / 1000) % 5 == 0) {&#xA;    lcd.clear();&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I end up with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w      p   &#xA;0w         &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the screen (before the &lt;code&gt;clear()&lt;/code&gt; occurs of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;write  p10      &#xA;0, 1 writewrite&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lcd itself was ok some time ago. The only thing I could think is I recently updated to Arduino 1.6.6. Can it be a bug in the compiler?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dfrobot.com/index.php?route=product/product&amp;amp;path=156_53&amp;amp;product_id=135&quot; rel=&quot;nofollow&quot; title=&quot;The hello world from dfrobot&quot;&gt;The hello world from DFRobot&lt;/a&gt; also doesn't work properly (first char only, again) (please note to make it display something with my LCD I have to change the address from 0x20 to 27).&lt;/p&gt;&#xA;" OwnerUserId="8309" LastEditorUserId="7148" LastEditDate="2020-04-12T16:40:04.600" LastActivityDate="2020-06-19T19:09:01.477" Title="LCD 16*02 I2C shield only shows first character printed" Tags="|arduino-uno|i2c|lcd|compile|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18016" PostTypeId="1" AcceptedAnswerId="18017" CreationDate="2015-11-22T19:44:05.080" Score="2" ViewCount="710" Body="&lt;p&gt;I want to hook up ESP8266, which has a 3.3v logic level to my bare-bones Arduino (basically a minimal interface for the ATmega382P IC).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can power my circuit at 3.3 V without a 5 V regulator so will the voltage of the logic level also be 3.3 V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there is a tiny boost converter in the IC... but I'm uncertain. &lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="26916" LastEditDate="2017-09-08T23:08:12.540" LastActivityDate="2017-09-08T23:08:12.540" Title="When it says the Uno has logic level at 5 V is that also true of a bareduino/breadboard Arduino?" Tags="|voltage-level|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18017" PostTypeId="2" ParentId="18016" CreationDate="2015-11-22T19:47:20.240" Score="7" Body="&lt;p&gt;The logic level is the same as the voltage you supply the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can think of the IO pins as tiny switches that either connect the output pin to the supply voltage or to ground (when in output mode) or compare the incoming voltage to an input pin to a percentage of the supply voltage (typically &amp;lt;0.3×Vcc for low and &gt;0.6Vcc for high)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, if you run the chip at 3.3V the logic level will be 3.3V logic (or more specifically &amp;lt; 1.1v for low and &gt; 2.2v for high).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-22T19:47:20.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18018" PostTypeId="1" AcceptedAnswerId="18242" CreationDate="2015-11-22T19:48:35.237" Score="6" ViewCount="566" Body="&lt;p&gt;I made a simple circuit controlled by the ATMEGA IC then tried to encase it in resin. It died. What is the thing that caused it to die? I've had other circuits working fine in resin. I want to try again, what steps can I take to prevent this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked for obvious shorts but can find none. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resin heats up when it cures, could that be the issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WaMDY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WaMDY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2015-11-29T18:15:43.870" Title="What killed it? Arduino in resin" Tags="|enclosure|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18019" PostTypeId="2" ParentId="18015" CreationDate="2015-11-22T19:57:48.677" Score="3" Body="&lt;p&gt;Your code contains, in part,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;....&#xA;LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display&#xA;void setup() {&#xA;  lcd.init();&#xA;  lcd.backlight();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For all of the constructors in &lt;code&gt;LiquidCrystal_I2C.h&lt;/code&gt; on my system, the second and third parameters are &lt;code&gt;EN&lt;/code&gt; and &lt;code&gt;RW&lt;/code&gt;, ie, the enable and read/write backpack-pin numbers.  They don't specify the size of the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest trying constructor usage like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in place of &lt;code&gt;lcd.init();&lt;/code&gt; say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.begin (16,2); // for 16 x 2 LCD module&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, &lt;code&gt;lcd.begin()&lt;/code&gt; will call &lt;code&gt;init()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-22T19:57:48.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18020" PostTypeId="2" ParentId="18007" CreationDate="2015-11-22T20:40:09.560" Score="3" Body="&#xA;&#xA;&lt;p&gt;I wrote a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12942&quot; rel=&quot;nofollow&quot;&gt;Tiny web server&lt;/a&gt; for the Arduino which has a similar thing in it. You might find it useful for your project. Inside there is a function that decodes the URL codes on-the-fly (ie. in a state machine). The code is a bit different to Majenko's because he assumes that you have the string in memory. In my case I am decoding a byte at a time (so you don't have to hold a long string in memory before you decode it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The snippet that does the decoding is this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // percent-encoding: possible states&#xA;  enum EncodePhaseType {&#xA;    ENCODE_NONE,&#xA;    ENCODE_GOT_PERCENT,&#xA;    ENCODE_GOT_FIRST_CHAR,&#xA;  };&#xA;  // percent-encoding: current state&#xA;  EncodePhaseType encodePhase;&#xA;  byte encodeByte;  // encoded byte being assembled (first nybble)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// ---------------------------------------------------------------------------&#xA;// add a character to the value buffer - percent-encoded (if wanted)&#xA;// ---------------------------------------------------------------------------&#xA; void HTTPserver::addToValueBuffer (byte inByte, const bool percentEncoded)&#xA;  {&#xA;  if (valueBufferPos &amp;gt;= MAX_VALUE_LENGTH)&#xA;    {&#xA;    flags |= FLAG_VALUE_BUFFER_OVERFLOW;&#xA;    return;&#xA;    }  // end of overflow&#xA;&#xA;  // look for stuff like &quot;foo+bar&quot; (turn the &quot;+&quot; into a space)&#xA;  // and also &quot;foo%21bar&quot; (turn %21 into one character)&#xA;  if (percentEncoded)&#xA;    {&#xA;    switch (encodePhase)&#xA;      {&#xA;&#xA;      // if in &quot;normal&quot; mode, turn a &quot;+&quot; into a space, and look for &quot;%&quot;&#xA;      case ENCODE_NONE:&#xA;        if (inByte == '+')&#xA;          inByte = ' ';&#xA;        else if (inByte == '%')&#xA;          {&#xA;          encodePhase = ENCODE_GOT_PERCENT;&#xA;          return;  // no addition to buffer yet&#xA;          }&#xA;        break;&#xA;&#xA;      // we had the &quot;%&quot; last time, this should be the first hex digit&#xA;      case ENCODE_GOT_PERCENT:&#xA;        if (isxdigit (inByte))&#xA;          {&#xA;          byte c = toupper (inByte) - '0';&#xA;          if (c &amp;gt; 9)&#xA;            c -= 7;  // Fix A-F&#xA;          encodeByte = c &amp;lt;&amp;lt; 4;&#xA;          encodePhase = ENCODE_GOT_FIRST_CHAR;&#xA;          return;  // no addition to buffer yet&#xA;          }&#xA;        // not a hex digit, give up&#xA;        encodePhase = ENCODE_NONE;&#xA;        flags |= FLAG_ENCODING_ERROR;&#xA;        break;&#xA;&#xA;      // this should be the second hex digit&#xA;      case ENCODE_GOT_FIRST_CHAR:&#xA;        if (isxdigit (inByte))&#xA;          {&#xA;          byte c = toupper (inByte) - '0';&#xA;          if (c &amp;gt; 9)&#xA;            c -= 7;  // Fix A-F&#xA;          inByte = encodeByte | c;&#xA;          }&#xA;        else&#xA;          flags |= FLAG_ENCODING_ERROR;&#xA;&#xA;        // done with encoding it, or not a hex digit&#xA;        encodePhase = ENCODE_NONE;&#xA;&#xA;      } // end of switch on encodePhase&#xA;    } // end of percent-encoded&#xA;&#xA;  // add to value buffer, encoding has been dealt with&#xA;  valueBuffer [valueBufferPos++] = inByte;&#xA;  valueBuffer [valueBufferPos] = 0;  // trailing null-terminator&#xA;  } // end of HTTPserver::addToValueBuffer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-11-22T20:40:09.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18021" PostTypeId="2" ParentId="17993" CreationDate="2015-11-22T20:59:26.387" Score="3" Body="&lt;p&gt;See sections 43, Analog-to-Digital Converter (ADC), and 44, Digital-to-Analog Converter Controller (DACC), in the Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf specsheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, subsection 43.2, Embedded Characteristics, says: “1 MHz Conversion Rate”.  Some time diagrams appear quite a few pages later that suggest 10-bit conversions can be done more rapidly than 12-bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the DAC (or DACC, per the specsheet), section 44.6, Functional Description, says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The DACC uses the master clock (MCK) divided by two to perform conversions. This clock is named DACC Clock.&#xA;  Once a conversion starts the DACC takes 25 clock periods to provide the analog result on the selected analog&#xA;  output.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;AIUI, the Due's master clock frequency is 84 MHz, so DACC Clock frequency is 42 MHz, whence 25 cycles take 575 ns, which is an update frequency of about 1.74 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details about the ADC, see eg &lt;a href=&quot;http://www.djerickson.com/arduino/&quot; rel=&quot;nofollow&quot;&gt;&#xA;Analog performance, particularly of Due's 12 bit ADC&lt;/a&gt; at djerickson.com.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-22T20:59:26.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18022" PostTypeId="1" AcceptedAnswerId="18024" CreationDate="2015-11-22T21:33:49.090" Score="4" ViewCount="659" Body="&lt;p&gt;What I have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 x 8 channel relay&lt;/li&gt;&#xA;&lt;li&gt;1 x IR receiver&lt;/li&gt;&#xA;&lt;li&gt;1x Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;1x momentary switch&lt;/li&gt;&#xA;&lt;li&gt;1x breadboard&lt;/li&gt;&#xA;&lt;li&gt;1x 10K resister&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think the wiring is all ok as for the most part things are working as they should..ish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just a few bugs I need to fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The goal was to toggle just 2 relays (at the moment) on/off with the hardwired switch and individually toggle the a relay using an IR remote control. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like I said this sort of works....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press the momentary button it does indeed toggle both relays...yeah!&#xA;then as long as the 2 relays are toggled to the on position by the momentary switch I can toggle each relay using buttons on a remote. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I turn the relays off with the momentary button I can't turn them on with the remote. Also if I turn off one of the relays with the remote and then press momentary switch it alternates the toggle between the 2 relays rather than just turning the other one off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using various example sketches to achieve all this and just trying to stitch them together as best I can but something is telling me that the approach is all wrong and that I should maybe be looking into Boolean's perhaps? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope you can shed some light on this for me. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;#define irPin 8&#xA;IRrecv irrecv(irPin);&#xA;decode_results results;&#xA;const int buttonPin = 2;&#xA;const int relay1 = 13;&#xA;const int relay2 = 12;&#xA;int relay1State;&#xA;int relay2State;&#xA;int buttonState;&#xA;int lastButtonState;&#xA;long lastDebounceTime = 0;&#xA;long debounceDelay = 50;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn();&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(relay1, OUTPUT);&#xA;  pinMode(relay2, OUTPUT);&#xA;  digitalWrite(relay1, relay1State);&#xA;  digitalWrite(relay2, relay2State);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    switch (results.value) {&#xA;      case 0xFF30CF:&#xA;        Serial.println(&quot;Button 1 Pressed&quot;);&#xA;        relay1State = ~relay1State;&#xA;        digitalWrite(relay1, relay1State);&#xA;        delay(250);&#xA;        break;&#xA;      case 0xFF18E7:&#xA;        Serial.println(&quot;button 2 pressed&quot;);&#xA;        relay2State = ~relay2State;&#xA;        digitalWrite(relay2, relay2State);&#xA;        delay(250);&#xA;        break;&#xA;    }&#xA;    irrecv.resume();&#xA;  }&#xA;&#xA;  int reading = digitalRead(buttonPin);&#xA;  if (reading != lastButtonState) {&#xA;    lastDebounceTime = millis();&#xA;  }&#xA;  if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;&#xA;    if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;&#xA;      if (buttonState == HIGH) {&#xA;        relay1State = !relay1State;&#xA;        relay2State = !relay2State;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  digitalWrite(relay1, relay1State);&#xA;  digitalWrite(relay2, relay2State);&#xA;  lastButtonState = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15027" LastEditorUserId="1576" LastEditDate="2019-09-19T05:08:37.987" LastActivityDate="2022-01-30T04:32:16.430" Title="Controlling relays with IR and button" Tags="|button|relay|ir|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18023" PostTypeId="1" AcceptedAnswerId="18025" CreationDate="2015-11-22T22:04:47.223" Score="1" ViewCount="457" Body="&lt;p&gt;For an Arduino project I am working on, I am trying to modify the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 to support DSSCircuit's I2C Master Library (&lt;a href=&quot;https://github.com/DSSCircuits/I2C-Master-Library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/DSSCircuits/I2C-Master-Library&lt;/a&gt;). This is to combat the known issue of the Arduino Wire library to often get hung up while trying to run the EndTransmission function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to this and do not understand how the terms 'slave address' and 'register address' and 'bytes you want to send' are different, if they are. I also do not understand how buffering works in the base IMU library. Any information on those would be appreciated, but is not the focus of my question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the example code of the IMU unit...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FreeSixIMU.h&amp;gt;&#xA;#include &amp;lt;FIMU_ADXL345.h&amp;gt;&#xA;#include &amp;lt;FIMU_ITG3200.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;I2C.h&amp;gt;&#xA;&#xA;int raw[6]; // x y z yaw pitch roll&#xA;&#xA;// Set the FreeSixIMU object&#xA;FreeSixIMU sixDOF = FreeSixIMU();&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA;  I2c.begin();&#xA;&#xA;  delay(100);&#xA;  sixDOF.init(); //begin the IMU&#xA;  delay(100);&#xA;}&#xA;&#xA;void loop() { &#xA;  sixDOF.getRawValues(raw);&#xA;  Serial.print(raw[0]);&#xA;  Serial.print(&quot; x | &quot;);  &#xA;  Serial.print(raw[1]);&#xA;  Serial.print(&quot; y | &quot;);&#xA;  Serial.print(raw[2]);&#xA;  Serial.println(&quot; z&quot;);&#xA;  delay(100); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I changed the selected IMU library functions as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Writes val to address register on device&#xA;void ADXL345::writeTo(byte address, byte val) {&#xA;  I2c.write(address, val);&#xA;  // send register address&#xA;}&#xA;&#xA;// Reads num bytes starting from address register on device in to _buff array&#xA;void ADXL345::readFrom(byte address, int num, byte _buff[]) {&#xA;  I2c.read(address, (byte) num);&#xA;  // sends address to read from&#xA;}&#xA;&#xA;void ITG3200::writemem(uint8_t _addr, uint8_t _val) {&#xA;  I2c.write(_addr, _val);   // start transmission to device&#xA;}&#xA;&#xA;void ITG3200::readmem(uint8_t _addr, uint8_t _nbytes, uint8_t __buff[]) {&#xA;  I2c.read(_addr, _addr, _nbytes);   // start transmission to device&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And added the &lt;code&gt;#include &amp;lt;I2C.h&amp;gt;&lt;/code&gt; statements to the headers files where applicable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running the example code, the serial output will not change values based on how I move the accelerometer, which makes me think I used the wrong slave address to read data from, or some other issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me modify the IMU library to include DSSCircuit's Master I2C Library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you Stack Exchange Community!&#xA;John&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see PersonAGem's edit below. Using the wire library is known to have arbitrary hangups, and in this example PersonAGem lists the edits I should make to the other libraries I am using as well as gives me the code I should use in my &lt;code&gt;.ino&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I ask a new question about this topic &lt;a href=&quot;https://arduino.stackexchange.com/questions/18256/using-arduino-shield-seems-to-break-serial-print-and-uploading-new-code&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15028" LastEditorUserId="7856" LastEditDate="2015-11-30T15:02:54.123" LastActivityDate="2015-11-30T15:02:54.123" Title="Modifying Arduino IMU library to rely on DSSCircuit's I2C Master Library" Tags="|arduino-uno|i2c|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18024" PostTypeId="2" ParentId="18022" CreationDate="2015-11-22T23:10:09.673" Score="3" Body="&lt;p&gt;So according to your comments this should be the code if no mistake was made&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;#define irPin 8&#xA;IRrecv irrecv(irPin);&#xA;decode_results results;&#xA;const int buttonPin = 2;&#xA;const int relay1 = 13;&#xA;const int relay2 = 12;&#xA;int relay1State = 0;&#xA;int relay2State = 0;&#xA;int masterState = 0;&#xA;int buttonState;&#xA;int lastButtonState;&#xA;long lastDebounceTime = 0;&#xA;long debounceDelay = 50;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn();&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(relay1, OUTPUT);&#xA;  pinMode(relay2, OUTPUT);&#xA;  digitalWrite(relay1, relay1State);&#xA;  digitalWrite(relay2, relay2State);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    switch (results.value) {&#xA;      case 0xFF30CF:&#xA;        Serial.println(&quot;Button 1 Pressed&quot;);&#xA;        relay1State = !relay1State;&#xA;        digitalWrite(relay1, relay1State);&#xA;        delay(250);&#xA;        break;&#xA;      case 0xFF18E7:&#xA;        Serial.println(&quot;button 2 pressed&quot;);&#xA;        relay2State = !relay2State;&#xA;        digitalWrite(relay2, relay2State);&#xA;        delay(250);&#xA;        break;&#xA;    }&#xA;    irrecv.resume();&#xA;  }&#xA;&#xA;  int reading = digitalRead(buttonPin);&#xA;  if (reading != lastButtonState) {&#xA;    lastDebounceTime = millis();&#xA;  }&#xA;  if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;&#xA;    if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;&#xA;      if (buttonState == HIGH) {&#xA;        masterState = !masterState;&#xA;        relay1State = masterState;&#xA;        relay2State = masterState;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  digitalWrite(relay1, relay1State);&#xA;  digitalWrite(relay2, relay2State);&#xA;  lastButtonState = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;what I've done is create a masterState that only changes whenever you press the buttonPin and by pressing it will also change both relays to the value of new masterState independently of their actual state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another advice: is a bad practice to not initialize variables before use, because when you declare it is not granted that they are automatically equal to zero.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-11-22T23:10:09.673" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18025" PostTypeId="2" ParentId="18023" CreationDate="2015-11-22T23:47:58.440" Score="1" Body="&lt;p&gt;You are missing the rest of the code in reading operations. You are just requesting the data, no actually reading it from the device:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the original code of adlx345::read&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void ADXL345::readFrom(byte address, int num, byte _buff[]) {&#xA;  Wire.beginTransmission(_dev_address); // start transmission to device&#xA;  Wire.write(address);             // sends address to read from&#xA;  Wire.endTransmission();         // end transmission&#xA;&#xA;  Wire.beginTransmission(_dev_address); // start transmission to device&#xA;  Wire.requestFrom(_dev_address, num);    // request 6 bytes from device&#xA;&#xA;  int i = 0;&#xA;  while(Wire.available())         // device may send less than requested (abnormal)&#xA;  {&#xA;    _buff[i] = Wire.read();    // receive a byte&#xA;    i++;&#xA;  }&#xA;  if(i != num){&#xA;    status = ADXL345_ERROR;&#xA;    error_code = ADXL345_READ_ERROR;&#xA;  }&#xA;  Wire.endTransmission();         // end transmission&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would change to (if no mistakes made):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void ADXL345::readFrom(byte address, int num, byte _buff[]) {&#xA;  I2c.read(_dev_address, address, num) // request 6 bytes from device&#xA;  if(I2c.available() != num){  // device may send less than requested (abnormal)&#xA;    status = ADXL345_ERROR;&#xA;    error_code = ADXL345_READ_ERROR;&#xA;  }&#xA;&#xA;  int i = 0;&#xA;  while(I2c.available())         &#xA;  {&#xA;    _buff[i] = I2c.receive();    // receive a byte&#xA;    i++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you may need to force cast parameters between functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If for some reason you don't want the actual code and want to use another library, I'll suggest &lt;a href=&quot;http://www.i2cdevlib.com/devices&quot; rel=&quot;nofollow&quot;&gt;I2Cdev site&lt;/a&gt; with a well documented classes for adlx345 and ITG3200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This caused me no problem. That is the only 2 functions I changed:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Writes val to address register on device&#xA;void ADXL345::writeTo(byte address, byte val) {&#xA;  I2c.write((uint8_t) _dev_address, (uint8_t) address, (uint8_t) val);&#xA;}&#xA;&#xA;// Reads num bytes starting from address register on device in to _buff array&#xA;void ADXL345::readFrom(byte address, int num, byte _buff[]) {&#xA;  I2c.read((uint8_t) _dev_address, (uint8_t) address, (uint8_t) num);  // request 6 bytes from device&#xA;  if(I2c.available() != num){  // device may send less than requested (abnormal)&#xA;    status = ADXL345_ERROR;&#xA;    error_code = ADXL345_READ_ERROR;&#xA;  }&#xA;&#xA;  int i = 0;&#xA;  while(I2c.available())         &#xA;  {&#xA;    _buff[i] = I2c.receive();    // receive a byte&#xA;    i++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino code used:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;I2C.h&amp;gt;&#xA;#include &quot;FIMU_ADXL345.h&quot;&#xA;&#xA;ADXL345 acc = ADXL345();&#xA;int x=0,  y=0, z=0;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  I2c.begin();&#xA;  delay(100);&#xA;  acc.init(ADXL345_ADDR_ALT_LOW);&#xA;  delay(100);&#xA;  Serial.print(&quot;Is ACC OK?: &quot;);&#xA;  Serial.println(acc.status);&#xA;  Serial.print(&quot;Any Error code?: &quot;);&#xA;  Serial.println(acc.error_code);&#xA;  Serial.println(&quot;********Print all register current values********&quot;);&#xA;  acc.printAllRegister();&#xA;  Serial.println(&quot;********END register print******&quot;);&#xA;  Serial.println(acc.getRate());&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  acc.readAccel(&amp;amp;x,&amp;amp;y,&amp;amp;z);&#xA;  Serial.print(x);&#xA;  Serial.print('\t');&#xA;  Serial.print(y);&#xA;  Serial.print('\t');&#xA;  Serial.println(z);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output given:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Is ACC OK?: 1&#xA;Any Error code?: 0&#xA;********Print all register current values********&#xA;0x00: B11100101&#xA;0x1D: B00000000&#xA;0x1E: B00000000&#xA;0x1F: B00000000&#xA;0x20: B00000000&#xA;0x21: B00000000&#xA;0x22: B00000000&#xA;0x23: B00000000&#xA;0x24: B00000000&#xA;0x25: B00000000&#xA;0x26: B00000000&#xA;0x27: B00000000&#xA;0x28: B00000000&#xA;0x29: B00000000&#xA;0x2A: B00000000&#xA;0x2B: B00000000&#xA;0x2C: B00001010&#xA;0x2D: B00001000&#xA;0x2E: B00000000&#xA;0x2F: B00000000&#xA;0x30: B10000011&#xA;0x31: B00000000&#xA;0x32: B11110101&#xA;0x33: B11111111&#xA;0x34: B00000011&#xA;0x35: B00000000&#xA;0x36: B11100101&#xA;0x37: B00000000&#xA;0x38: B00000000&#xA;0x39: B00000000&#xA;********END register print******&#xA;100.00&#xA;-12 4   230&#xA;-10 2   231&#xA;-11 3   231&#xA;-12 3   228&#xA;-10 3   230&#xA;-11 2   231&#xA;-12 2   229&#xA;-11 3   229&#xA;-10 3   231&#xA;-11 3   229&#xA;-10 2   230&#xA;-12 4   230&#xA;-12 3   229&#xA;-10 2   229&#xA;-13 4   230&#xA;-11 3   230&#xA;-10 3   230&#xA;-11 2   230&#xA;-11 4   229&#xA;-11 3   230&#xA;-11 3   230&#xA;-11 3   229&#xA;-12 3   229&#xA;-10 2   229&#xA;-11 3   230&#xA;-11 3   231&#xA;-11 3   230&#xA;-15 14  227&#xA;34  104 210&#xA;138 95  191&#xA;243 18  88&#xA;323 -15 74&#xA;280 -8  -2&#xA;263 -2  37&#xA;212 10  163&#xA;16  39  233&#xA;28  114 195&#xA;29  161 170&#xA;33  124 211&#xA;5   49  244&#xA;7   22  224&#xA;-10 3   229&#xA;-11 2   230&#xA;-12 2   230&#xA;-11 3   231&#xA;-12 4   228&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2015-11-23T22:03:30.163" LastActivityDate="2015-11-23T22:03:30.163" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18026" PostTypeId="1" CreationDate="2015-11-14T07:42:09.553" Score="0" ViewCount="494" Body="&lt;p&gt;I have an arduino attached with a RGB-Shield. I want to query my server for the RGB values periodically. I basically got it working using the Ethernet Shield but it takes too long to get the value (~500ms}. I really want to read the values from my server really really fast in an endless loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you give me any hints on how I can improve my code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;IPAddress server(192,168,1,151); &#xA;IPAddress ip(192, 168, 1, 177);&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  // start the Ethernet connection:&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Ethernet.begin(mac, ip);&#xA;  }&#xA;&#xA;  delay(1000);&#xA;&#xA;  if (client.connect(server, 80)) {&#xA;    client.println(&quot;GET /rgb.php HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: 192.168.1.151&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;&#xA;    ... read from Server    &#xA;&#xA;  }&#xA;&#xA;&#xA;  if (!client.connected()) {&#xA;    client.stop();&#xA;    if (client.connect(server, 80)) {&#xA;      client.println(&quot;GET /rgb.php HTTP/1.1&quot;);&#xA;      client.println(&quot;Host: 192.168.1.151&quot;);&#xA;      client.println(&quot;Connection: close&quot;);&#xA;      client.println();&#xA;    }   &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="matthias" LastEditorUserId="27346" LastEditDate="2018-12-04T12:51:31.220" LastActivityDate="2018-12-04T12:51:31.220" Title="Arduino read from Server periodically" Tags="|ethernet|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18027" PostTypeId="2" ParentId="18026" CreationDate="2015-11-14T14:28:57.157" Score="1" Body="&lt;p&gt;You could try with a direct TCP connection (in this way you skip the HTTP layer) but you need to prepare also a small TCP server (in any language comfortable to you) that accepts the client connection, sends the data, waits the ACK and close the connection.&lt;/p&gt;&#xA;" OwnerDisplayName="Mat" LastActivityDate="2015-11-14T14:28:57.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18028" PostTypeId="1" CreationDate="2015-11-23T03:09:29.360" Score="0" ViewCount="300" Body="&lt;p&gt;I am testing the basic Software Serial example on the arduino website, but I cant get the myserial to print&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA; Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(4800);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;  }&#xA;  if (Serial.available()) {&#xA;    mySerial.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2019-01-04T20:23:05.240" Title="Need Basic Help with Software Serial" Tags="|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18031" PostTypeId="2" ParentId="18028" CreationDate="2015-11-23T04:47:12.113" Score="1" Body="&lt;p&gt;In the example, digital pins 10 and 11 (mySerial) on your Arduino board are used as virtual RX and TX serial lines. The virtual RX pin (pin10)is set up to listen for anything coming in on the hardware RX serial line, and to then echo that data out the virtual TX line (pin11). Conversely, anything received on the virtual RX (pin10) is sent out over the hardware TX.&lt;/p&gt;&#xA;" OwnerUserId="15033" LastActivityDate="2015-11-23T04:47:12.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18033" PostTypeId="1" CreationDate="2015-11-23T05:44:37.780" Score="2" ViewCount="105" Body="&lt;p&gt;So I just starting playing around with UART and SoftwareSerial while playing with these SRF-02 Sensors - &lt;a href=&quot;http://www.robot-electronics.co.uk/htm/srf02techSer.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.robot-electronics.co.uk/htm/srf02techSer.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help getting one to read to the other, I have been using this, makes sense logically, but doesn't work. I was thinking I'm missing something important for the synchronization of both sensors to one another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;SoftwareSerial mySerial(10,11); // RX, TX &#xA;&#xA;void SendCmd(unsigned char address,unsigned char cmd)&#xA;{&#xA;  mySerial.write(address);//set the address of SRF02(factory default is 0)&#xA;  delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit&#xA;  mySerial.write(cmd);//send the command to SRF02&#xA;  delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit&#xA;}&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  Serial.println(&quot;SRF02 TEST!&quot;);&#xA;}&#xA;void loop(void)&#xA;{&#xA;  unsigned int reading;&#xA;  SendCmd(0x00,0x5C);//Transmit 8 cycle 40khz pulse from adress 0x00&#xA;  delay(70);//time for SRF02 to measure the range&#xA;  SendCmd(0x02,0x5E);//Get Range, returns two bytes (high byte first) from the most recent ranging to adress 0x02&#xA;   delay(10);//wait for some time,let the Arduino receive 2 bytes data from the TX pin of SRF02&#xA;  if(mySerial.available()&amp;gt;=2)//if two bytes were received&#xA;  {&#xA;    reading = mySerial.read()&amp;lt;&amp;lt;8;//receive high byte (overwrites previous reading) and shift high byte to be high 8 bits&#xA;    reading |= mySerial.read(); // receive low byte as lower 8 bits&#xA;    Serial.print(reading); // print the reading&#xA;    Serial.println(&quot;cm&quot;);&#xA;  }&#xA;  delay(250); // wait a bit since people have to read the output :)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="37523" LastEditDate="2019-07-26T22:15:13.550" LastActivityDate="2019-07-26T22:15:13.550" Title="SRF-02 UART, transmitting from one address to another" Tags="|sensors|softwareserial|uart|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18034" PostTypeId="1" CreationDate="2015-11-23T07:55:41.410" Score="0" ViewCount="632" Body="&lt;p&gt;I'm working in a ultrasonic radar project and the supervising teacher wants us to produce a chirp sound wave (a frequency-varying sinusoid).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm familiarised with the usual ultrasonic module, but as far as I know, it cannot do the task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched on-line for transducers that I could use, but couldn't find anything useful.&#xA;Are there any commercially available component that could do this task? If not, what could I possibly do?&lt;/p&gt;&#xA;" OwnerUserId="15037" LastActivityDate="2016-05-04T07:16:04.073" Title="Are there ultrasonic transducers which are able to produce a &quot;chirp&quot; sound wave?" Tags="|arduino-uno|frequency|sound|components|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18035" PostTypeId="1" AcceptedAnswerId="18036" CreationDate="2015-11-23T09:37:14.127" Score="2" ViewCount="272" Body="&lt;p&gt;I have a question regarding the ARDuino uno and some shields. I currently have a shield on my Uno, which takes the pins 0 to 7. However, on top of that board there is an extension of those 8 pins. If they were always in use, I suppose that the extra ports wouldn't be on top of the board, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how it looks: &lt;a href=&quot;https://i.stack.imgur.com/QAxHa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QAxHa.png&quot; alt=&quot;arduino shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it seems like you're able to &quot;share&quot; them. Is it possible to do so in real-time or is that there so you can use the ports when you disable the shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If its possible in real-time, how would I go about doing that? I've searched a little but couldn't find anything. I suppose i'd need some kind of clock to make the switch between the shield and the other components on pins 0-7, but not sure how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm kind of an electrics newbie, so hence the question might be a little silly :)&lt;/p&gt;&#xA;" OwnerUserId="15039" LastActivityDate="2015-11-23T09:44:25.660" Title="&quot;Sharing&quot; used GPIO pins" Tags="|shields|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18036" PostTypeId="2" ParentId="18035" CreationDate="2015-11-23T09:44:25.660" Score="2" Body="&lt;p&gt;No, you can't &quot;share&quot; pins between shields, except in specific circumstances (open-drain interrupts, I2C or SPI buses, etc).  General GPIO pins connect to just one device at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't tell from that picture, but it is highly unlikely that all 8 of the IO pins are actually in use by the shield, and the ones that aren't actually connected to anything within the shield are available for another shield placed on top to use.  You'll have to look at the schematic or manual for the shield to know exactly which pins are used for what and which are available for other shields to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, one thing to note with that shield - it doesn't appear to pass through the power header, so how a shield on top would get powered at all is a mystery to me.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-23T09:44:25.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18037" PostTypeId="1" AcceptedAnswerId="18038" CreationDate="2015-11-23T09:44:57.547" Score="2" ViewCount="1571" Body="&lt;p&gt;I've been searching a little for self-updating the ARDuino, and most i've come about is updating it using a wifi / lan shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have a GPRS shield that can connect it to the internet. Say that I want to remotely update the shield - how would I go about doing that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing I need some kind of bootloader - but is that extra hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually the question boils down to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How can I flash the ARDuino Uno with new software, that I'll receive over a GPRS connection using a GPRS shield?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15039" LastActivityDate="2017-08-08T07:00:22.050" Title="Updating the ARDuino code over GPRS" Tags="|software|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18038" PostTypeId="2" ParentId="18037" CreationDate="2015-11-23T09:52:59.433" Score="4" Body="&lt;p&gt;You would either have to replace the bootloader on your chip (software) with one that knows about your GPRS shield (I don't know if there is one, so you would most likely have to write your own and that is not a trivial task), or use a second microcontroller to act as a programming interface between the GPRS shield and the main Arduino.  That could be another Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option is probably the simplest to create:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The GPRS is connected to Arduino A.&lt;/li&gt;&#xA;&lt;li&gt;Your main software runs on Ardiuno B.&lt;/li&gt;&#xA;&lt;li&gt;Both Arduinos are connected by serial&lt;/li&gt;&#xA;&lt;li&gt;Normal operation Arduino A passes all serial verbatim through to Arduno B&lt;/li&gt;&#xA;&lt;li&gt;Arduino A receives programming instructions and downloads the new code - maybe storing it on an SD card temporarily (not enough RAM in an Arduino) then resets Arduino B into the bootloader.&lt;/li&gt;&#xA;&lt;li&gt;Arduino A then sends the serial instructions in the same way that avrdude does to program the downloaded HEX file.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Arduino A is then a proxy between the GPRS and Arduino B.  Arduino A does all the control of the GPRS and sends data between Arduino A and the internet and vice versa - it's up to you to decide how best to achieve that, depending on what information you have going backwards and forwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both solutions require a certain level of programming knowledge and skill and aren't trivial, but are perfectly possible if you set your mind to it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-23T09:52:59.433" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18039" PostTypeId="1" CreationDate="2015-11-23T10:46:38.093" Score="2" ViewCount="1360" Body="&lt;p&gt;I just got my RFID-RC522 Reader and was wondering one thing. Can i Use an RFID Reader to emulate an RFID Tag, so that if i have another reader it will detect the other one as a card and transfer data. It should be detected as a Tag like a midfare Classic but the data sould be supplied by the Arduino. Is this possible? At all? Or does it require another type of reader? If you know a solution please share it.&lt;/p&gt;&#xA;" OwnerUserId="15041" LastActivityDate="2022-11-29T04:05:15.627" Title="Emulate RFID Tag" Tags="|rfid|emulation|" AnswerCount="1" CommentCount="0" ClosedDate="2022-11-29T06:22:48.327" ContentLicense="CC BY-SA 3.0" />
  <row Id="18040" PostTypeId="1" CreationDate="2015-11-23T12:31:33.780" Score="4" ViewCount="2454" Body="&lt;p&gt;I'm wondering if there is any way to include the text of a file into a sketch by using a single placeholder command, similar to the &quot;#Include&quot; command when using Server Side Includes on .shtml files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sorry if I'm not wording this correctly. It was hard for me to phrase it and also hard for me to search about it, since the nouns seem so generic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that some parts of code can be separated out into their own functions, and that those functions could be saved in a different .ino file. But I'm wondering about for the cases that can't be separated out into functions (like for declarations at the beginning of a sketch, or an area in loop() that would require too many variables to be passed to the function).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT: I think I should've been more specific:&#xA;In one example, I have lots of html code being served from the loop() function. The Arduino webserver is serving a complex page that shows about 100 buttons on the webpage. I would like to separate the page-serving code to a separate .ino file and have it opened as a separate tab in the Arduino IDE. That way it's easy for me to open that tab whenever I want to modify the webpage, but also the code for serving the page won't take up so much space in my main file. The code isn't completely html (it has lots of functions and conditionals), so that's why I can't just save it as an external .html file and have it served from that file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As another example: At the top of my sketch I have lots of defines for wireless signals that need to be sent. They look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned long a1o = 4216115, a1c = 4216124, a2o = 4216259, a2c = 4216268, a3o = 4216579, a3c = 4216588, a4o = 4218115, a4c = 4218124, a5o = 4224259, a5c = 4224268; //remote control 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are 10 lines of code that look like that, and I never have to modify them because they're all constants. When I'm searching for bugs in my code, I never have to refer to those lines, and they're usually just in my way.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="11174" LastEditDate="2015-11-23T14:34:03.863" LastActivityDate="2016-02-22T14:16:35.333" Title="Any way to include the text of a file inside a sketch, to make it shorter and neater?" Tags="|compile|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18041" PostTypeId="1" CreationDate="2015-11-23T12:46:12.670" Score="1" ViewCount="6751" Body="&lt;p&gt;I am trying to upload a basic Blink code from my computer to Arduino Lilypad contains Atmega 328. While my Blink codes are uploading, &lt;strong&gt;FTDI 1402-C CN480661 FT232RL&lt;/strong&gt; module is not responding to the Arduino IDE at the end of the process. So I couldn't upload any codes with this uploading method, I mean using FTDI modules directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I do the connections:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/axOsO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/axOsO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my Blink code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { pinMode(13, OUTPUT);}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);     delay(1000);            &#xA;  digitalWrite(13, LOW);      delay(1000);         &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I chose &lt;strong&gt;AVRISP mkII&lt;/strong&gt; as a programmer. &lt;strong&gt;ATmega328&lt;/strong&gt; as a processor. &lt;strong&gt;Arduino Lilypad&lt;/strong&gt; as a board on &lt;em&gt;Arduino IDE&lt;/em&gt; &lt;strong&gt;v1.6.6&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point, I got this error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;\.\COM4&quot;: Access is denied&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Windows's device manager says: USB Serial Port is attached to COM4, also Arduino IDE saw that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gRNE8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gRNE8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I downloaded FTDI driver for Windows, but still, I can't upload any code into my Lilypad Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use FTDI to program my Lilypad Arduino?&lt;/p&gt;&#xA;" OwnerUserId="1006" LastActivityDate="2015-11-30T15:19:47.170" Title="How to use FTDI to program Lilypad Arduino?" Tags="|ftdi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18042" PostTypeId="2" ParentId="17224" CreationDate="2015-11-23T13:06:34.703" Score="0" Body="&lt;p&gt;I read api of Parse and there i got the class to call cloud function from &#xA;Arduino.I hope it will help others.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ParseCloudFunction cloudFunction;&#xA; cloudFunction.setFunctionName(fnname); //String (&quot;hello&quot;)&#xA; cloudFunction.add(&quot;light_sensor&quot;, 139); //parameter&#xA;&#xA; ParseResponse response = cloudFunction.send();&#xA; Serial.println(response.getJSONBody());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14369" LastActivityDate="2015-11-23T13:06:34.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18043" PostTypeId="1" AcceptedAnswerId="18097" CreationDate="2015-11-23T14:29:00.160" Score="2" ViewCount="1492" Body="&lt;p&gt;The linux processor runs a Python script from which I would like to send an array of integers to the Yun microprocessor. How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then, how can I retrieve and then use this array in my Arduino Sketch?&lt;/p&gt;&#xA;" OwnerUserId="15045" LastActivityDate="2015-12-20T20:51:20.980" Title="Share data between the two processors of the Arduino Yun" Tags="|arduino-yun|python|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18045" PostTypeId="1" AcceptedAnswerId="18049" CreationDate="2015-11-23T15:43:17.687" Score="2" ViewCount="299" Body="&lt;p&gt;I'm trying to make a home automation setup but I'm having a bit of trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to send commands of varying sizes to my arduino, separated by &quot;|&quot; and after receiving it completely it runs code corresponding to the command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;input &quot;RCP=10001|CMD=D|VAL=120&quot; &#xA;would result in an array like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String cmd[][] = {{&quot;RCP&quot;, &quot;10001&quot;}, {&quot;CMD&quot;, &quot;D&quot;}, {&quot;VAL&quot;, &quot;120&quot;}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with the amount of 'variables' being... well, variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code would continue checking if the RCP (recipient) ID corresponds with the ID of the current client and then run code based on the following variables.&#xA;But I don't think that's important info for the code which separated the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This string would be sent through an NRF24L01+ (That code already works)&lt;/p&gt;&#xA;" OwnerUserId="15050" LastEditorUserId="3917" LastEditDate="2015-11-23T21:42:44.400" LastActivityDate="2015-11-23T21:42:44.400" Title="Run code via NRF24L01+ command &quot;dynamically&quot;?" Tags="|communication|nrf24l01+|string|variables|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18046" PostTypeId="2" ParentId="9632" CreationDate="2015-11-23T16:04:59.080" Score="1" Body="&lt;p&gt;The Arduino IDE compiles and outputs standard Intel HEX format files that are compatible with (nearly?) all programmers. If you enable detailed logging in the preferences panel you can find out which directory the IDE is building your code in and if the IDE does not include specific support for your programmer you can then locate the .hex file and upload it using the tool you are familiar with. The projects are typically built in a &lt;code&gt;build.*&lt;/code&gt; subdirectory under %TEMP% (or /tmp on unix).&lt;/p&gt;&#xA;" OwnerUserId="6703" LastActivityDate="2015-11-23T16:04:59.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18048" PostTypeId="2" ParentId="18041" CreationDate="2015-11-23T16:32:09.057" Score="2" Body="&lt;p&gt;&quot;Access is denied&quot; this looks like you should at least restart your computer after you installed the FTDI driver if you have not already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run Arduino IDE as Administrator and also make sure you are logged into an Administrator account in your windows login.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all this fails this means another application is using that com port you will need to figure out what could be using that com port another instance of Arduino IDE opened? Etc&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all else fails restart your computer with the usb unplugged, login, open arduino IDE and plug in your usb and select the com port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: You can also try changing the USB port you are currently using for another one, this will also change your com port to a new number&lt;/p&gt;&#xA;" OwnerUserId="14843" LastEditorUserId="14843" LastEditDate="2015-11-23T16:37:35.897" LastActivityDate="2015-11-23T16:37:35.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18049" PostTypeId="2" ParentId="18045" CreationDate="2015-11-23T16:47:16.397" Score="3" Body="&lt;p&gt;What you are asking is very tricky at best. Your average Arduino doesn't have enough memory to start storing arrays of Strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you will need to &quot;distil&quot; the information as it comes in and store the distilled information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the possible keys are all known beforehand then you can assign a number to each possible key - say RCP is 1, CMD is 2, VAL is 3, etc.  If the values are all numeric or can be represented by a number, then convert those to the corresponding number and store those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the Arduino is not good at working with dynamic memory allocations - again because of lack of memory.  If you can decide on a reasonable maximum number of messages to store then you can pre-allocate the memory for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance it may be good to define a structure which is the content of a message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct message {&#xA;    uint8_t key;&#xA;    uint16_t val;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then make an array of that structure - one slice per possible command, say 10 of them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct message messageQueue[10];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would take a total of 30 bytes in memory - each entry being 3 bytes (1 for the key, two for the value).  Now you can set the keys and values to the correct data as it arrives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on how you want to deal with the messages as they come in - add them to the end of an existing queue, or always starting the queue from empty every time a new message arrives - you might want to implement a &lt;em&gt;circular buffer&lt;/em&gt;.  This is basically how the Serial port on the Arduino works - in involves having two &lt;em&gt;pointers&lt;/em&gt; to locations in the array - one where you are writing to, and one where you are reading from. As you write to the array the writing pointer moves along - if it reaches the end it starts from the beginning again.  As you read from the array the reading pointer moves along too.  If the two pointers are together then the array is empty. If the writing pointer would end up where the reading pointer is, the array is full.  Take a look in the Arduino source code (HardwareSerial.cpp) to see how it's implemented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for parsing the string as it comes in - if you have it as a single String already then it's a case of looking through it for the | characters and splitting out each portion in turn, then doing the same with each portion looking for the =. Then you can interpret what is in the key/value pairs and decide what to store in the array.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-23T16:47:16.397" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18050" PostTypeId="2" ParentId="18039" CreationDate="2015-11-23T16:50:23.600" Score="0" Body="&lt;p&gt;I'm almost positive you cant use a RFID Reader to talk to another RFID Reader with the basic libraries and resources we have. You are best just getting an actual tag may it be Mifare classic or another type of RFID Tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure this is possible but the amount of development you will need to dedicate towards this would out weigh just getting a cheap RFID tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is look around see what type of things you have laying around maybe something has an RFID tag in it, or maybe you have a phone with NFC. You can use your phones NFC to send data to a RFID reader, but you will need to find the resources to do this. Sorry I'm not much help but maybe someone has done this before and has a simple solution.&lt;/p&gt;&#xA;" OwnerUserId="14843" LastActivityDate="2015-11-23T16:50:23.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18051" PostTypeId="1" CreationDate="2015-11-23T17:23:08.453" Score="3" ViewCount="420" Body="&lt;p&gt;I'm building  an application that uses 20 servo motors, and i control then with an Arduino Mega. The servos are having some instability, to the point where they make small random swings. Im powering then from a 7.4V LiPo battery and I drop the voltage to around 6V with 2 series diodes. I've made some research and found 4 things that may help stabilize the servos.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Put a 1000uF eletrolitic capacitor between the battery VCC and GND pins.&lt;/li&gt;&#xA;&lt;li&gt;Put a 470uF eletrolitic capacitor between each servo VCC and GND pins.&lt;/li&gt;&#xA;&lt;li&gt;Put a 100nF ceramic capacitor between each servo SIGNAL and GND pins.&lt;/li&gt;&#xA;&lt;li&gt;Put a 10k pull-up resistor on each servo SIGNAL pin.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My question is, how to make the right decision here. It is better for the project if I take all this designs into account, or I shouldn't be making some combination of this, or one in particular?&lt;/p&gt;&#xA;" OwnerUserId="15054" LastActivityDate="2015-11-29T14:03:45.960" Title="Multiple servos noise" Tags="|arduino-mega|servo|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18053" PostTypeId="1" CreationDate="2015-11-23T16:00:07.673" Score="1" ViewCount="90" Body="&lt;p&gt;Is there any way to connect RFduino's via radio frequency? Or any capability to transmit information between RFduino's for distances up to 200 feet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to purchase a dev kit (for RF duino) but i'm not sure what parts I will need to transmit info longish (200 feet) distances.&lt;/p&gt;&#xA;" OwnerUserId="15197" OwnerDisplayName="Peter Solimine" LastEditorUserId="27346" LastEditDate="2018-11-30T22:40:22.793" LastActivityDate="2018-11-30T22:40:22.793" Title="RFduino communication capabilities" Tags="|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18054" PostTypeId="2" ParentId="18053" CreationDate="2015-11-23T18:34:48.557" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://blog.adafruit.com/2010/06/11/aprs-radio-shield-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;https://blog.adafruit.com/2010/06/11/aprs-radio-shield-for-arduino/&lt;/a&gt;&#xA;Be warned you need a license to transmit on amateur frequencies at least in the US, you will also need to hook up a transmitter for this shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GSMShield would also be great and is something I'm thinking about using for my project, the way the Arduino IDE is setup and the libraries already in place I'm sure it would be easy to turn text messages into commands or readable and usable data between the sender and receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are two ways one using a long range radio frequency or the GSM network. We would need to know more exact data of your project on how to implement these two solutions to accomplish what you would like to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first option is most likely going to be the lesser option if you don't have a license to transmit long range frequencies and do not have experience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option is easy and all you would have to do is make sure both sender and receiver are within a GSM network. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck and I'm excited to see what other solutions others may post since I'm in the same boat.&lt;/p&gt;&#xA;" OwnerUserId="14843" LastActivityDate="2015-11-23T18:34:48.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18056" PostTypeId="2" ParentId="18011" CreationDate="2015-11-23T19:04:29.953" Score="1" Body="&lt;p&gt;Ok, I finally solved it, so I will write it here so somebody may learn from it in the future :) The problem was really in the fuses, thanks Chris Stratton. Most of my chips were bought already modified for working with Arduino. But this ATmega 8 had the factory fuses, which were setting it for working with internal 1MHz oscillator. You can read and your write your fuse settings with avrdude, so I set them to arduino default (lfuse 0xDF, hfuse 0xCA, from boards.txt). Now it works perfectly even without uploading bootloader.&lt;/p&gt;&#xA;" OwnerUserId="12154" LastActivityDate="2015-11-23T19:04:29.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18059" PostTypeId="2" ParentId="4677" CreationDate="2015-11-24T05:07:04.330" Score="1" Body="&lt;p&gt;It would be most helpful to see the code you're using and to know more about the configuration of your network and the symptoms of the conflict – for example where is the web site running?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things to try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Simplify your network. Eliminate everything but the Arduinos and the web server. See if that changes anything.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the command &lt;code&gt;arp -a&lt;/code&gt; (assuming you've got a machine running something UNIXish). It will show you the MAC and IP addresses of hosts on your network. Look to see if the Arudinos are still there and if there are any devices that conflict with them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try to &lt;code&gt;ping&lt;/code&gt; the Arudinos. Do they respond?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;WireShark&lt;/code&gt; or &lt;code&gt;tcpdump&lt;/code&gt; to monitor traffic on the network. Look for traffic to or from the Arudinos (by IP addresses and by MAC addresses).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add some debug code to the Arduino sketch so that you can watch what they are doing (send it out the serial monitor). See if what goes on the wire matches what you expect (monitoring with &lt;code&gt;tcpdump&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-24T05:07:04.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18061" PostTypeId="2" ParentId="18040" CreationDate="2015-11-24T05:57:30.087" Score="1" Body="&lt;p&gt;As suggested in comments, you can use &lt;code&gt;#include&lt;/code&gt; statements to include texts of files into a sketch.  For example, suppose files c1.h,  c2.h,  c3.h,  c4.h, and  c5.h are in directory &lt;code&gt;~/sketchbook/tincludes&lt;/code&gt;, along with the file &lt;code&gt;tincludes.ino&lt;/code&gt;, which is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;void setup() {&#xA;  const long int&#xA;#include &quot;c1.h&quot;&#xA;#include &quot;c2.h&quot;&#xA;#include &quot;c3.h&quot;&#xA;#include &quot;c4.h&quot;&#xA;#include &quot;c5.h&quot;&#xA; etc=5   ;&#xA;  Serial.begin(115200);&#xA;  Serial &amp;lt;&amp;lt; z1o &amp;lt;&amp;lt;  z1c &amp;lt;&amp;lt;  z2o &amp;lt;&amp;lt;  z2c &amp;lt;&amp;lt;  z3o &amp;lt;&amp;lt;  z3c &amp;lt;&amp;lt;  z4o &amp;lt;&amp;lt;  z4c &amp;lt;&amp;lt;  z5o &amp;lt;&amp;lt;  z5c;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further, suppose c1.h ... c5.h each contain one line of code, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;==&amp;gt; c1.h &amp;lt;==&#xA;  z1o=25829, z1c=9774,&#xA;&#xA;==&amp;gt; c2.h &amp;lt;==&#xA;  z2o=7850, z2c=25585,&#xA;&#xA;==&amp;gt; c3.h &amp;lt;==&#xA;  z3o=7103, z3c=17981,&#xA;&#xA;==&amp;gt; c4.h &amp;lt;==&#xA;  z4o=30827, z4c=24511,&#xA;&#xA;==&amp;gt; c5.h &amp;lt;==&#xA;  z5o=4167, z5c=10036,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the sketch will compile ok, and the sketch-lines with &lt;code&gt;const long int&lt;/code&gt; through &lt;code&gt;etc=5   ;&lt;/code&gt; will compile the same as if they were replaced by &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const long int z1o=25829, z1c=9774, z2o=7850, z2c=25585, z3o=7103,&#xA;     z3c=17981, z4o=30827, z4c=24511, z5o=4167, z5c=10036, etc=5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-24T05:57:30.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18063" PostTypeId="1" CreationDate="2015-11-24T06:56:01.967" Score="11" ViewCount="249" Body="&lt;p&gt;I have created a cloud function using the Parse.com Javascript SDK and I am calling those functions from Arduino. Following is code for the &lt;code&gt;hello&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code&gt;Parse.Cloud.define(&quot;hello&quot;, function(request, response) {&#xA;                response.success(&quot;This is hello function&quot;);         &#xA;}); //hello function Block&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am calling this function from the Arduino side using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Bridge.begin();&#xA;  Serial.begin(9600);&#xA;&#xA;  while (!Serial);&#xA;&#xA;  Parse.begin(&quot;***zE0uUjQkMa7nj5D5BALvzegzfyVNSG22BD***&quot;, &quot;***Ssggp5JgMFmSHfloewW5oixlM5ibt9LBSE***&quot;);&#xA;  //commented my keys with * here only&#xA;&#xA;  // In this example, we associate this device with a pre-generated installation&#xA;  Parse.getInstallationId();&#xA;  Parse.startPushService();&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Start loop&quot;);&#xA;  demoBasic(&quot;meeting&quot;, 0);&#xA;}&#xA;&#xA;void demoBasic(String functionname, int light) {&#xA;  char fnname[11];&#xA;  functionname.toCharArray(fnname, 11);&#xA;&#xA;  Serial.print(&quot;In &quot;);&#xA;  Serial.print(functionname);&#xA;  Serial.println(&quot; Function&quot;);&#xA;&#xA;&#xA;  ParseCloudFunction cloudFunction;&#xA;  cloudFunction.setFunctionName(fnname);&#xA;  cloudFunction.add(&quot;light_sensor&quot;, light);&#xA;  cloudFunction.add(&quot;value&quot;, &quot;Arduino Hello&quot;);//parameters&#xA;&#xA;  ParseResponse response = cloudFunction.send();&#xA;  Serial.println(response.getJSONBody());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is that I am getting response 8 times only. After that whole program flow gets blocked. What is the problem?&lt;/p&gt;&#xA;" OwnerUserId="14369" LastEditorDisplayName="user31481" LastEditDate="2017-11-15T20:51:02.603" LastActivityDate="2019-04-19T19:03:05.527" Title="Cloud function getting stopped Parse.com in loop when calling from Arduino-yun" Tags="|arduino-yun|code-review|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18064" PostTypeId="2" ParentId="18040" CreationDate="2015-11-24T09:27:25.100" Score="1" Body="&lt;p&gt;Usually you should not define a variable inside a header file. If, for example, you write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// file myvars.h&#xA;int var_a = 10;&#xA;&#xA;// file main.ino&#xA;#include &quot;myvars.h&quot;&#xA;&#xA;// file another.cpp&#xA;#include &quot;myvars.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the linker will fail, because there are two definitions of the same variable &lt;code&gt;var_a&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to do it is to declare a variable as extern inside the header file, then define them into a cpp (or ino) file just once. I mean&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// file myvars.h&#xA;extern int var_a;&#xA;&#xA;// file myvars.cpp&#xA;int var_a = 10;&#xA;&#xA;// file main.ino&#xA;#include &quot;myvars.h&quot;&#xA;&#xA;// file another.cpp&#xA;#include &quot;myvars.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you will be able to access &lt;code&gt;var_a&lt;/code&gt; from both main.ino and another.cpp. If you don't want to add another cpp file for the definitions, you just have to provide the definition inside ONE of the ino or cpp files you already have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in your case, just make two more files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;file remote_control_1.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern const unsigned long a1o, a1c, a2o, a2c, a3o, a3c, a4o, a4c, a5o, a5c;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file remote_control_1.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;remote_control_1.h&quot;&#xA;const unsigned long a1o = 4216115;&#xA;const unsigned long a1c = 4216124;&#xA;const unsigned long a2o = 4216259;&#xA;const unsigned long a2c = 4216268;&#xA;const unsigned long a3o = 4216579;&#xA;const unsigned long a3c = 4216588;&#xA;const unsigned long a4o = 4218115;&#xA;const unsigned long a4c = 4218124;&#xA;const unsigned long a5o = 4224259;&#xA;const unsigned long a5c = 4224268;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in your files just write &lt;code&gt;#include &quot;remote_control_1.h&quot;&lt;/code&gt; to access those variables&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-11-24T09:27:25.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18068" PostTypeId="1" CreationDate="2015-11-24T12:53:58.787" Score="5" ViewCount="2226" Body="&lt;p&gt;I am working on a project where i emulate the EDID of a screen to force a source into sending data on a certain resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read the original EDID code of a screen and change the timings into the resolution I want to force the source in, i send this changed EDID code to the source with an Arduino uno when the source gives a read on address 0x50 (where the EDID located, see handshake). We have an HDMI in/out with the data lines connected thru and the DDC lines (source) connected to the Arduino that we can send the changed EDID to the source (i²c protocol).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can change the resolution successfully on some sources, and on some it doesn’t change. The attached screen doesn’t find a source. I use the same code for both scenarios.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DTWI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;         //BUFFER_LENGTH = 256&#xA;&#xA;uint8_t edid[256] = {&#xA; 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0xF4, 0x0C, 0x45, 0x52, 0x46, 0x31, 0x15, 0x19, 0x01, 0x03, 0x80, 0x3C, 0x22, 0x78, 0x2A, 0x52, 0x95, 0xA5, 0x56, 0x54, 0x9D, 0x25, 0x0E, 0x50, 0x54, 0xBF, 0xEF, 0x80, 0x71, 0x4F, 0x81, 0xC0, 0x81, 0x00, 0x81, 0x80, 0x95, 0x00, 0xA9, 0xC0, 0xB3, 0x00, 0x01, 0x01, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E, 0x28, 0x55, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x32, 0x4B, 0x1E, 0x51, 0x11, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x53, 0x32, 0x37, 0x45, 0x33, 0x37, 0x30, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x62, 0x02, 0x03, 0x1B, 0xF1, 0x46, 0x90, 0x04, 0x1F, 0x13, 0x03, 0x12, 0x67, 0x03, 0x0C, 0x00, 0x10, 0x00, 0x80, 0x22, 0x23, 0x09, 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x01, 0x1D, 0x00, 0xBC, 0x52, 0xD0, 0x1E, 0x20, 0xB8, 0x28, 0x55, 0x40, 0x56, 0x50, 0x21, 0x00, 0x00, 0x1E, 0x8C, 0x0A, 0xD0, 0x90, 0x20, 0x40, 0x31, 0x20, 0x0C, 0x40, 0x55, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x18, 0x8C, 0x0A, 0xD0, 0x8A, 0x20, 0xE0, 0x2D, 0x10, 0x10, 0x3E, 0x96, 0x00, 0x56, 0x50, 0x21, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D&#xA;};  &#xA;&#xA;void receiveEvent(int receivedByte)&#xA;{&#xA;    if (receivedByte == 1)          //If there is 1 byte received&#xA;    {&#xA;      int receivedValue = Wire.read() &amp;lt;&amp;lt; 1;&#xA;      receivedValue |= Wire.read();&#xA;      Serial.print(&quot;Read byte: &quot;);&#xA;      Serial.print(receivedValue); &#xA;      Serial.println();&#xA;    }&#xA;    else&#xA;    {&#xA;        Serial.println(&quot;Not the amount of bytes that was expected: &quot;);&#xA;        Serial.print(receivedByte); &#xA;    }  &#xA;&#xA;    while(Wire.available())&#xA;    {&#xA;        Wire.read();&#xA;    }&#xA;    return;&#xA;}&#xA;&#xA;void requestEvent()&#xA;{  &#xA;      Serial.println();&#xA;&#xA;     for (int i = 0; i &amp;lt; 256; i++){&#xA;            Wire.write(edid[i]);               //Write EDID&#xA;            Serial.print(edid[i], HEX);      //Print EDID&#xA;            Serial.print(&quot;,&quot;);  &#xA;     }&#xA;&#xA;    Serial.println(); &#xA;    Serial.println(&quot;Finished&quot;);      //Write is complete&#xA;&#xA;}  &#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); &#xA;  Serial.println(&quot;**** HDMI ****&quot;);&#xA;  pinMode(2, OUTPUT);          //Hot plug detection&#xA;  Wire.begin(0x50);  &#xA;  digitalWrite(2, LOW); &#xA;  delay(20);&#xA;  digitalWrite(2, HIGH);         //Source knows that a screen is attached and want to read the edid of the screen&#xA;&#xA;  Wire.onReceive(receiveEvent);  &#xA;  Wire.onRequest(requestEvent); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following attached pictures are the EDID handshakes without the Arduino involved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Handshake 1: This is an HDMI 1.4 device &lt;a href=&quot;https://i.stack.imgur.com/8YSMW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8YSMW.png&quot; alt=&quot;HDMI 1.4 device&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Handshake 2: This is another HDMI 1.4 device&lt;a href=&quot;https://i.stack.imgur.com/HXRxR.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HXRxR.png&quot; alt=&quot;Another HDMI 1.4 device&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that the handshakes are the same. &#xA;My code only works on handshake 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea why it doesn't work on the other devices ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it has to do with the Start/Restart ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards !&lt;/p&gt;&#xA;" OwnerUserId="15072" LastActivityDate="2017-04-04T03:41:45.080" Title="HDMI EDID emulator" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18070" PostTypeId="2" ParentId="3411" CreationDate="2015-11-24T15:05:54.397" Score="1" Body="&lt;p&gt;Sorry I do not have the reputation to comment. I think your problem can be because you selected the wrong settings for your board. Check in Tools option, and make sure Board, Processor and Port is correct.&lt;/p&gt;&#xA;" OwnerUserId="15075" LastActivityDate="2015-11-24T15:05:54.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18072" PostTypeId="1" CreationDate="2015-11-24T16:15:41.443" Score="8" ViewCount="4038" Body="&lt;p&gt;I have ran across a couple of different event libraries that are available on the AVR and Andruino but I am not sure which one is the best option. What I would like to do is design my program in a event driven style but not sure how to go about this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a project that I need to keep lightweight but also in this program I have several actions that can be happening at any given time i.e. Digital Inputs being triggered and I need to run code whenever these events happen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://playground.arduino.cc/Code/QP&quot;&gt;the QP Framework&lt;/a&gt; that looked promising but I wanted to get some feedback from some others that might of used this type of library before and might be able to provide some examples and maybe some experiences.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another site I found &lt;a href=&quot;http://blog.ardublock.com/2013/10/29/evaluating-of-event-driven-libraries-on-arduino/&quot;&gt;here&lt;/a&gt; and lists all sorts of different libs&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="14761" LastEditDate="2015-11-24T16:23:59.993" LastActivityDate="2016-01-01T18:10:56.330" Title="Event driven programming" Tags="|programming|arduino-mega|threads|events|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18074" PostTypeId="1" AcceptedAnswerId="18077" CreationDate="2015-11-24T18:28:58.900" Score="0" ViewCount="207" Body="&lt;p&gt;I'm connecting a client (java program) to an arduino (server). What I want to know is, how high the CPU usage is, and what to do if there are no clients that are trying to connect to arduino? Should I make a delay?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EthernetClient client = server.available();&#xA;&#xA;if(client){&#xA;    Serial.println(&quot;Connected&quot;);&#xA;    server.write(&quot;Hello\n&quot;);&#xA;&#xA;    //check if client is still connected&#xA;    while (client.connected()){&#xA;        Serial.println(&quot;Still there&quot;);&#xA;        delay(2000);&#xA;       //check if client received any data&#xA;       if(client.available()){&#xA;           //read message from client&#xA;     }&#xA;  }&#xA;} else {&#xA;     Serial.println(&quot;Nope&quot;);&#xA;     server.write(&quot;Hello\n&quot;);&#xA;     ???????????? delay(2000); ??????????????&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="4358" LastEditDate="2015-11-29T21:37:02.790" LastActivityDate="2015-11-29T21:37:02.790" Title="TCP connection CPU usage, multiple signals?" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18075" PostTypeId="1" AcceptedAnswerId="18076" CreationDate="2015-11-24T20:51:45.897" Score="1" ViewCount="496" Body="&lt;p&gt;Is it possible to do something like this: send a HIGH signal to an output pin, after a 0.33s delay arduino sends HIGH signal to another pin, and after another 0.33s delay, arduino sends signal to third pin. There has to be 90 seconds long high signal for each pin, but with 0.33s delay between each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sooo something like this; start of the high signal on left, stop on right side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pin1: 0 ...... 90.00&#xA;pin2: 0.33 ... 90.33&#xA;pin3: 0.66 ... 90.66&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to solve this?&lt;/p&gt;&#xA;" OwnerUserId="13760" LastActivityDate="2015-11-24T20:55:00.493" Title="sending multiple signals at the same time, with short delay" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18076" PostTypeId="2" ParentId="18075" CreationDate="2015-11-24T20:55:00.493" Score="3" Body="&lt;p&gt;Yes. Read the BlinkWithoutDelay example and triplicate it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-24T20:55:00.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18077" PostTypeId="2" ParentId="18074" CreationDate="2015-11-24T21:29:26.597" Score="2" Body="&lt;p&gt;You don't need to do anything. If the else clause has a delay (e.g. of 2 seconds), then it will take up to that long before the arduino accepts the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;server.write&quot; in the &quot;else&quot; clause doesn't make any sense - who are you sendin it to? server.write will normally write to all available connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's nothing else you want to do, you might as well retry straight away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that, if you are doing a serial.println statement, and you have no delay, then, while waiting for a connection, it will print the &quot;Nope&quot; message, as fast as it can.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-11-24T21:29:26.597" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18078" PostTypeId="2" ParentId="18043" CreationDate="2015-11-24T22:05:35.880" Score="0" Body="&lt;p&gt;Serial1 on the Arduino side is connected to a serial console on the Linux side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you could use calls on the Arduino to run your Python script on the Linux side and then listen to the output of the script to come back though the serial port and part it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of a project where I used a Yun like this. The Arduino side interfaces to some temperature sensors, and then types commands into the Linux side over the serial connection to run CURL and report data to internet URLs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://wp.josh.com/2014/06/05/tempurature-logging-to-a-google-spreadsheet-with-an-arduino-yun/#more-1797&quot; rel=&quot;nofollow&quot;&gt;http://wp.josh.com/2014/06/05/tempurature-logging-to-a-google-spreadsheet-with-an-arduino-yun/#more-1797&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am going to warn you that this is very ugly. Then Yun itself is quite ugly too. There were so many problems that I ended up giving up on this platform completely. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-11-24T22:05:35.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18080" PostTypeId="2" ParentId="8847" CreationDate="2015-11-24T22:25:41.193" Score="1" Body="&lt;p&gt;In the Arduino IDE for my Pro Mini I have to select the board: &#xA;&quot;Arduino Deumilanove or Diecimila&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure why this is or if this could cause any potential damage to your Pro Mini but I do know for sure this is the solution I used to program my pro mini and it works every time.&lt;/p&gt;&#xA;" OwnerUserId="14843" LastActivityDate="2015-11-24T22:25:41.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18083" PostTypeId="1" CreationDate="2015-11-24T23:20:45.923" Score="0" ViewCount="520" Body="&lt;p&gt;I want to move the mouse pointer with an Arduino and ultrasonic sensor but when I compiled it says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Mouse.h not found&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and I don't know what I can do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Mouse.h&amp;gt;&#xA;&#xA;int echoPinCursor=2;&#xA;int trigPinCursor=3;&#xA;&#xA;int echoPinBtn=4;&#xA;int trigPinBtn=5;&#xA;int echoPinScroll=6;&#xA;int trigPinScroll=7;&#xA;int x;&#xA;int y;&#xA;long duracionCursor, distanciaCursor;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA; pinMode(trigPinCursor, OUTPUT);&#xA; pinMode(echoPinCursor, INPUT);&#xA; pinMode(trigPinBtn, OUTPUT);&#xA; pinMode(echoPinBtn, INPUT);&#xA; pinMode(trigPinScroll, OUTPUT);&#xA; pinMode(echoPinScroll, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    //mover el cursor&#xA;  int direccionx=moverx();&#xA;  int direcciony=movery();&#xA;&#xA;  Mouse.move(direccionx, direcciony,0);&#xA;  delay(2);&#xA;&#xA;}&#xA;&#xA;int moverx(){&#xA;      distanciaCursor=obtener_distanciaCursor();&#xA;  if (distanciaCursor &amp;gt;= 1  || distanciaCursor &amp;lt;= 11){&#xA;       x--;&#xA;     }&#xA;   if (distanciaCursor &amp;gt;= 12 || distanciaCursor &amp;lt;= 24){&#xA;       x++;&#xA;      }&#xA;     return x;&#xA;}&#xA;&#xA;int movery(){&#xA;      distanciaCursor=obtener_distanciaCursor();&#xA;     if (distanciaCursor &amp;gt;= 25 || distanciaCursor &amp;lt;= 37){&#xA;       y--;&#xA;       }&#xA;   if (distanciaCursor &amp;gt;= 38 || distanciaCursor &amp;lt;= 50){&#xA;       y++;&#xA;      }&#xA;  return y;&#xA;}&#xA;&#xA;long obtener_distanciaCursor(void)&#xA;{&#xA;  digitalWrite(trigPinCursor, LOW);&#xA; delayMicroseconds(2);&#xA;&#xA; digitalWrite(trigPinCursor, HIGH);&#xA; delayMicroseconds(10);&#xA;&#xA; digitalWrite(trigPinCursor, LOW);&#xA; duracionCursor = pulseIn(echoPinCursor, HIGH);&#xA;&#xA; distanciaCursor = duracionCursor/58.2;&#xA;return(distanciaCursor);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15091" LastEditorUserId="6936" LastEditDate="2016-03-26T03:13:54.980" LastActivityDate="2016-03-26T03:13:54.980" Title="I want to move the mouse pointer with an Arduino and ultrasonic sensor" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18084" PostTypeId="2" ParentId="18083" CreationDate="2015-11-24T23:27:06.977" Score="2" Body="&lt;p&gt;That's because the Uno can't be a mouse.  For that you need the Leonardo or something else with a similar &quot;U&quot; style microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are adventurous, and you have a genuine Arduino, you can reprogram the USB controller chip with new firmware so it thinks it's a mouse, but programming the main MCU is then a real chore.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-24T23:27:06.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18089" PostTypeId="1" AcceptedAnswerId="18094" CreationDate="2015-11-25T02:37:02.103" Score="2" ViewCount="498" Body="&lt;p&gt;I'm using 2 SRF02 sensors on the same Arduino board to attempt to have the transmitter only pulse the 40 KHz wave, while the receiver will be only taking a fake range, i.e. picking up a reading based on another transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using SoftwareSerial and need to know how to synchronize the time for the receiver to know when the transmitter sent the data. What I found is that I'm going to have to do this using start and stop bytes to set them in the same cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my current code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;SoftwareSerial mySerial(10,11); // RX, TX &#xA;&#xA;void SendCmd(unsigned char address,unsigned char cmd) {&#xA;  mySerial.write(address);&#xA;  //set the address of SRF02(factory default is 0)&#xA;  delayMicroseconds(100);&#xA;  //serial data is fixed at 9600,N,8,2,so we need some time to create the second stop bit&#xA;  mySerial.write(cmd);&#xA;  //send the command to SRF02&#xA;  delayMicroseconds(100);&#xA;  //serial data is fixed at 9600,N,8,2,so we need some time to create the second stop bit&#xA;}&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  Serial.println(&quot;SRF02 TEST!&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  unsigned int reading;&#xA;  SendCmd(0x00,0x5C);&#xA;  //Transmit 8 cycle 40khz pulse from address 0x00 - transmitter&#xA;  delay(70);&#xA;  //time for SRF02 to measure the range&#xA;  SendCmd(0x02,0x57);&#xA;  //Get Fake Range at Address 0x02 - receiver&#xA;  delay(10);&#xA;  //wait for some time,let the Arduino receive 2 bytes data from the TX pin of SRF02&#xA;  if(mySerial.available()&amp;gt;=2) {&#xA;    //if two bytes were received&#xA;    reading = mySerial.read()&amp;lt;&amp;lt;8;&#xA;    //receive high byte (overwrites previous reading) and shift high byte to be high 8 bits&#xA;    reading |= mySerial.read();&#xA;    // receive low byte as lower 8 bits&#xA;    Serial.print(reading);&#xA;    // print the reading&#xA;    Serial.println(&quot;cm&quot;);&#xA;    //Serial.println(&quot;Time Sent: &quot;); &#xA;    //Serial.print(T_sent);&#xA;  }&#xA;  delay(250);&#xA;  // wait a bit since people have to read the output :)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="4628" LastEditDate="2015-11-25T19:00:03.340" LastActivityDate="2015-11-25T20:19:40.200" Title="UART Software Serial - Syncing two different sensors with start and stop bytes" Tags="|uart|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18090" PostTypeId="2" ParentId="18074" CreationDate="2015-11-25T02:37:59.577" Score="2" Body="&lt;p&gt;As the Arduino typically has no demand-based clock scaling, or alternate threads of comparable priority you can schedule, there's really little point in using a delay (which is implemented as a busy-wait) rather than a tight loop - really, the primary appropriate reason would be to reduce the frequency of status output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you want to design a power-efficient system, you could consider sleeping the CPU between checking if there is anything worthwhile to do, or until an interrupt indicates that there is.  This is not something which delay() will take care of for you, so it is a fair amount of extra work and testing to get right, but it can be very worthwhile if running from batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your application is not particularly intensive you can also configure the clock divider fuse and slow the chip down generally.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-11-25T02:37:59.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18091" PostTypeId="1" CreationDate="2015-11-25T03:19:49.047" Score="2" ViewCount="59" Body="&lt;p&gt;I need to make a transmitter and receiver with each specifically transmitting and receiving a signal. I am using two SRF-02 sensors, one is the designated transmitter, the other the receiver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is that the receiver is not currently able to pick up the reading, reason being that the receiver has no idea of when the startbyte is incoming or when the stop byte comes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can i send the receiver a start byte when i activate the transmitter and send an end byte for when the signal is received?&lt;/p&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-11-25T03:19:49.047" Title="Synchronizing two sensors on uart, make one receiver and one transmitter" Tags="|uart|" AnswerCount="0" CommentCount="1" ClosedDate="2016-01-30T02:52:13.773" ContentLicense="CC BY-SA 3.0" />
  <row Id="18092" PostTypeId="2" ParentId="6715" CreationDate="2015-11-25T04:17:28.117" Score="5" Body="&lt;p&gt;Mike's answer uses a Fibonacci Linear Feedback Shift Register configuration, but the compactness Galois Linear Feedback Shift Register Configuration could be faster:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define speakerPin 8&#xA;&#xA;unsigned long lastClick;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;   pinMode(speakerPin,OUTPUT);&#xA;   lastClick = micros();   &#xA;}&#xA;&#xA;&#xA;/* initialize with any 32 bit non-zero  unsigned long value. */&#xA;#define LFSR_INIT  0xfeedfaceUL&#xA;/* Choose bits 32, 30, 26, 24 from  http://arduino.stackexchange.com/a/6725/6628&#xA; *  or 32, 22, 2, 1 from &#xA; *  http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf&#xA; *  or bits 32, 16, 3,2  or 0x80010006UL per http://users.ece.cmu.edu/~koopman/lfsr/index.html &#xA; *  and http://users.ece.cmu.edu/~koopman/lfsr/32.dat.gz&#xA; *  or generate a one with https://github.com/hayguen/mlpolygen&#xA; */  &#xA;#define LFSR_MASK  ((unsigned long)( 1UL&amp;lt;&amp;lt;31 | 1UL &amp;lt;&amp;lt;15 | 1UL &amp;lt;&amp;lt;2 | 1UL &amp;lt;&amp;lt;1  ))&#xA;&#xA;unsigned int generateNoise(){ &#xA;  // See https://en.wikipedia.org/wiki/Linear_feedback_shift_register#Galois_LFSRs&#xA;   static unsigned long int lfsr = LFSR_INIT;  /* 32 bit init, nonzero */&#xA;   /* If the output bit is 1, apply toggle mask.&#xA;                                    * The value has 1 at bits corresponding&#xA;                                    * to taps, 0 elsewhere. */&#xA;                                &#xA;   if(lfsr &amp;amp; 1) { lfsr =  (lfsr &amp;gt;&amp;gt;1) ^ LFSR_MASK ; return(1);}&#xA;   else         { lfsr &amp;gt;&amp;gt;= 1;                      return(0);}&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;      /* ... */&#xA;      if ((micros() - lastClick) &amp;gt; 50 ) { // Changing this value changes the frequency.&#xA;        lastClick = micros();&#xA;        digitalWrite (speakerPin, generateNoise());&#xA;      }&#xA;     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For a 16 bit implementation (faster, but only a cycle of 2^16) try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define LFSR_MASK 0x8016 &#xA;static uint16_t lfsr = LFSR_INIT;  /* 16 bit init, nonzero */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Written in a more compact form:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define speakerPin 8&#xA;&#xA;#define LFSR_INIT 0xfeed /* non-zero seed value for generateNoise() */&#xA;#define LFSR_MASK 0x8016 /* magic number from http://users.ece.cmu.edu/~koopman/lfsr/ */&#xA;&#xA;unsigned long lastClick;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;   pinMode(speakerPin,OUTPUT);&#xA;   lastClick = micros();   &#xA;}&#xA;&#xA;&#xA;unsigned int generateNoise(){ &#xA;   // Return 1 bit of noise using a Galois Linear Feedback Shift Register&#xA;   // See https://en.wikipedia.org/wiki/Linear_feedback_shift_register#Galois_LFSRs&#xA;&#xA;   static uint16_t lfsr = LFSR_INIT; &#xA;                                &#xA;   if(lfsr &amp;amp; 1) { lfsr =  (lfsr &amp;gt;&amp;gt;1) ^ LFSR_MASK ; return(1);}&#xA;   else         { lfsr &amp;gt;&amp;gt;= 1;                      return(0);}&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;      /* ... */&#xA;      if ((micros() - lastClick) &amp;gt; 50 ) { // Changing this value changes the frequency.&#xA;        lastClick = micros();&#xA;        digitalWrite (speakerPin, generateNoise());&#xA;      }&#xA;     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For an 8 bit implementation (faster than 32 bit, slightly slower than 16, but only a cycle of 2^8) try:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define LFSR_MASK 0x8e &#xA;&#xA;static byte lfsr = LFSR_INIT;  /* 8 bit init, nonzero */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where the mask constants are from the 8.txt and 16.txt files at &lt;a href=&quot;http://users.ece.cmu.edu/%7Ekoopman/lfsr/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://users.ece.cmu.edu/~koopman/lfsr/index.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/hayguen/mlpolygen&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/hayguen/mlpolygen&lt;/a&gt; program can search for maximum length feedback polynomials of various bit sizes.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2022-01-04T18:25:48.673" LastActivityDate="2022-01-04T18:25:48.673" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18094" PostTypeId="2" ParentId="18089" CreationDate="2015-11-25T06:19:55.077" Score="0" Body="&lt;p&gt;Your code bit &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SendCmd(0x00,0x5C);//Transmit 8 cycle 40khz pulse from address 0x00 - transmitter&#xA;delay(70);//time for SRF02 to measure the range&#xA;SendCmd(0x02,0x57); //Get Fake Range at Address 0x02 - receiver&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will send a sound burst, delay 70 ms, then start listening for the burst, which by then will have traveled around 24 meters and probably be no longer audible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should instead start the fake range listener immediately after sending the burst.  The general idea for one approach is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Record time (eg, &lt;code&gt;t1=micros();&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Send burst (eg, &lt;code&gt;SendCmd(0,0x5C);&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Record time (eg, &lt;code&gt;t2=micros();&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Listen for burst (eg, &lt;code&gt;SendCmd(2,0x58); // Get microseconds&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Wait 70 ms, then read microseconds result &lt;code&gt;t3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Compute corrected total microseconds, &lt;code&gt;tm=t3+t2-t1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Convert microseconds to cm&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note use of command 0x58 instead of 0x57 to get microseconds instead of cm.  If you used 0x57, instead of adding &lt;code&gt;t2-t1&lt;/code&gt; to &lt;code&gt;t3&lt;/code&gt;, you would add &lt;code&gt;t2-t1&lt;/code&gt; microseconds-converted-to-cm to a cm reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason for the computation &lt;code&gt;tm=t3+t2-t1&lt;/code&gt; is that the second command is issued about &lt;code&gt;t2-t1&lt;/code&gt; microseconds later than the first command, as explained in the next paragraph.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an unknown delay &lt;code&gt;d1&lt;/code&gt; between when &lt;code&gt;t1&lt;/code&gt; is recorded and when the first SRF02 acts; and there is an unknown delay &lt;code&gt;d2&lt;/code&gt; between when &lt;code&gt;t2&lt;/code&gt; is recorded and when the second SRF02 begins listening.  The correct amount to add to &lt;code&gt;t3&lt;/code&gt; is &lt;code&gt;t2+d2-(t1+d1)&lt;/code&gt;, which is &lt;code&gt;t2-t1&lt;/code&gt; if &lt;code&gt;d1&lt;/code&gt; equals &lt;code&gt;d2&lt;/code&gt;, a more-or-less plausible assumption.  If your experiments reveal a constant error, add a small constant offset to compensate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt you should have the &lt;code&gt;delayMicroseconds(100);&lt;/code&gt; statements in &lt;code&gt;SendCmd()&lt;/code&gt;, and would recommend getting the code to work ok, then see if it still works ok when you take them out.  The &lt;code&gt;delay(10);&lt;/code&gt; is unnecessary if you rewrite your 2-character-wait correctly (ie as a &lt;code&gt;while&lt;/code&gt; rather than an &lt;code&gt;if&lt;/code&gt;), and the &lt;code&gt;delay(70);&lt;/code&gt; is unnecessary if you start conversion with command &lt;code&gt;0x5A&lt;/code&gt;,  “Fake Ranging Mode - Result in centimeters, automatically Tx range back to controller as soon as ranging is complete” and then properly wait for two characters to arrive, instead of a blind wait followed by a test if they've arrrived.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-11-25T06:19:55.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18096" PostTypeId="2" ParentId="18089" CreationDate="2015-11-25T07:48:05.560" Score="0" Body="&lt;pre&gt;&lt;code&gt; unsigned int reading;&#xA;  unsigned long t1=micros();&#xA;  SendCmd(0, 0x5C);//send pulse with transmitter&#xA;  unsigned long t2=micros();&#xA;  SendCmd(2, 0x58);//return value in microseconds&#xA;&#xA;  delay(70);//time for SRF02 to measure the range&#xA;  //SendCmd(0x02,0x5E);&#xA;  unsigned long t3 = SendCmd(2,0x5E);&#xA;  unsigned long tm = t3+t2-t1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hey thanks for the input. When I created t3, I get an error saying void value not ignored as ought to be.&lt;/p&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-11-25T07:48:05.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18097" PostTypeId="2" ParentId="18043" CreationDate="2015-11-25T09:21:00.927" Score="1" Body="&lt;p&gt;Given that my Python script printed the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[10, 20, 30, 40]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the sketch I used to retrieve the array&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;Process.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;   Bridge.begin();&#xA;   Serial.begin(19200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   Process proc;&#xA;   int i=0;&#xA;   size_t dim = 1;&#xA;   int* array = (int*)malloc(dim);&#xA;&#xA;&#xA;   Serial.print(&quot;Running process...&quot;);&#xA;   Serial.println(&quot;done!&quot;);&#xA;   proc.runShellCommand(&quot;python /script.py&quot;);&#xA;&#xA;   while (proc.available()){&#xA;     if((char)proc.read() != ']'){&#xA;        array[i] = proc.parseInt();&#xA;        dim++;&#xA;        array = (int*)realloc(array,dim);&#xA;        Serial.println(array[i]);&#xA;        i++;&#xA;      }&#xA;      else&#xA;        break;&#xA;   }&#xA;&#xA;   Serial.println();&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15045" LastActivityDate="2015-11-25T09:21:00.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18103" PostTypeId="1" AcceptedAnswerId="18180" CreationDate="2015-11-25T12:39:28.197" Score="0" ViewCount="1689" Body="&lt;p&gt;I am getting an error while Uploading the Bootloader to Atmega8A&#xA;I am selecting..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Board -&amp;gt; Arduino NG and Older&#xA;  Processor -&amp;gt; Atmega8A&#xA;  Programmer -&amp;gt; USBasp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and sketch code is ArduinoISP, After selecting port then I do &quot;Burn Bootloader&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But getting an error of...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   &quot;efuse&quot; memory type not defined for part &quot;ATmega8&quot;&#xA;    Error while burning bootloader. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please tell me what to do. Any help will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="14658" LastActivityDate="2015-11-27T12:10:32.307" Title="Problem in Uploading a Bootloader to Atmega8A" Tags="|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18104" PostTypeId="2" ParentId="18103" CreationDate="2015-11-25T13:10:44.533" Score="1" Body="&lt;p&gt;Google is your friend!!!&#xA;Apparently this is a known regression &lt;a href=&quot;https://github.com/arduino/Arduino/issues/2075&quot; rel=&quot;nofollow&quot;&gt;bug&lt;/a&gt; not yet corrected. The possible solution is also suggested there by user &lt;a href=&quot;https://github.com/rigelinorion&quot; rel=&quot;nofollow&quot;&gt;rigelinorion&lt;/a&gt; and here is the quote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Hello, I solved it this way...&#xA;&#xA;Open for edit the file C:\Program Files\Arduino\hardware\arduino\avr\platforms.txt&#xA;this is standard section uploader/programmers tools&#xA;&#xA;#==============================================================================&#xA;tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude&#xA;tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf&#xA;tools.avrdude.cmd.path.linux={runtime.ide.path}/hardware/tools/avrdude&#xA;tools.avrdude.config.path.linux={runtime.ide.path}/hardware/tools/avrdude.conf&#xA;&#xA;tools.avrdude.upload.params.verbose=-v -v -v -v&#xA;tools.avrdude.upload.params.quiet=-q -q&#xA;tools.avrdude.upload.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude.program.params.verbose=-v -v -v -v&#xA;tools.avrdude.program.params.quiet=-q -q&#xA;tools.avrdude.program.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude.erase.params.verbose=-v -v -v -v&#xA;tools.avrdude.erase.params.quiet=-q -q&#xA;tools.avrdude.erase.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Uefuse:w:{bootloader.extended_fuses}:m -Ulock:w:{bootloader.unlock_bits}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m&#xA;&#xA;tools.avrdude.bootloader.params.verbose=-v -v -v -v&#xA;tools.avrdude.bootloader.params.quiet=-q -q&#xA;tools.avrdude.bootloader.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}:i&quot; -Ulock:w:{bootloader.lock_bits}:m&#xA;#==============================================================================&#xA;&#xA;create a new tool called, for example, avrdude1&#xA;simply copy section tools.avrdude and name it tools.avrdude1&#xA;the trick is that we remove switch &quot;-Uefuse:w:{bootloader.extended_fuses}:m&quot; from &quot;tools.avrdude1.erase.pattern=&quot;&#xA;&#xA;#=============================================================================&#xA;tools.avrdude1.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude&#xA;tools.avrdude1.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf&#xA;tools.avrdude1.cmd.path.linux={runtime.ide.path}/hardware/tools/avrdude&#xA;tools.avrdude1.config.path.linux={runtime.ide.path}/hardware/tools/avrdude.conf&#xA;&#xA;tools.avrdude1.upload.params.verbose=-v -v -v -v&#xA;tools.avrdude1.upload.params.quiet=-q -q&#xA;tools.avrdude1.upload.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude1.program.params.verbose=-v -v -v -v&#xA;tools.avrdude1.program.params.quiet=-q -q&#xA;tools.avrdude1.program.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&#xA;tools.avrdude1.erase.params.verbose=-v -v -v -v&#xA;tools.avrdude1.erase.params.quiet=-q -q&#xA;&#xA;#this line was edited&#xA;tools.avrdude1.erase.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m&#xA;&#xA;tools.avrdude1.bootloader.params.verbose=-v -v -v -v&#xA;tools.avrdude1.bootloader.params.quiet=-q -q&#xA;tools.avrdude1.bootloader.pattern=&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}:i&quot; -Ulock:w:{bootloader.lock_bits}:m&#xA;#==============================================================================&#xA;&#xA;Here is an example of the use of the tool avrdude1 in boards.txt file&#xA;&#xA;atmega8.name=ATmega8 OPTIBOOT&#xA;atmega8.upload.protocol=arduino&#xA;atmega8.upload.maximum_size=7168&#xA;atmega8.upload.speed=115200&#xA;atmega8.upload.tool=avrdude1&#xA;atmega8.bootloader.low_fuses=0xbf&#xA;atmega8.bootloader.high_fuses=0xCC&#xA;atmega8.bootloader.path=atmega8&#xA;atmega8.bootloader.file=optiboot/optiboot_atmega8.hex&#xA;atmega8.bootloader.unlock_bits=0x3F&#xA;atmega8.bootloader.lock_bits=0x0F&#xA;atmega8.bootloader.tool=avrdude1&#xA;atmega8.build.mcu=atmega8&#xA;atmega8.build.f_cpu=16000000L&#xA;atmega8.build.core=arduino&#xA;atmega8.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-11-25T13:10:44.533" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18105" PostTypeId="1" CreationDate="2015-11-25T13:38:03.497" Score="0" ViewCount="125" Body="&lt;p&gt;I'm a newbee to Arduino programming and hoping someone can help me with this. These are the errors when uploading the proceeding sketch. Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: stk500_rcv() : programmer is not &#xA;responding&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: stk500_getsync() attempt 10 of 10:not in sync:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem uploading to board.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//www.RobotLinking.com&#xA;//2015.5.7&#xA;/************************************************/&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;/************************************************/&#xA;Servo myservo;//create servo object to control a servo&#xA;/************************************************/&#xA;void setup()&#xA;{&#xA;  myservo.attach(9);//attachs the servo on pin 9 to servo object&#xA;  myservo.write(0);//back to 0 degrees &#xA;  delay(1000);//wait for a second&#xA;}&#xA;/*************************************************/&#xA;void loop()&#xA;{  &#xA;  myservo.write(15);//goes to 15 degrees &#xA;  delay(1000);//wait for a second&#xA;  myservo.write(30);//goes to 30 degrees &#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(45);//goes to 45 degrees &#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(60);//goes to 60 degrees &#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(75);//goes to 75 degrees &#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(90);//goes to 90 degrees&#xA;  delay(1000);//wait for a second&#xA;  myservo.write(75);//back to 75 degrees &#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(60);//back to 60 degrees&#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(45);//back to 45 degrees&#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(30);//back to 30 degrees&#xA;  delay(1000);//wait for a second.33&#xA;  myservo.write(15);//back to 15 degrees &#xA;  delay(1000);//wait for a second&#xA;  myservo.write(0);//back to 0 degrees &#xA;  delay(1000);//wait for a second&#xA;}&#xA;/**************************************************/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="6826" LastEditDate="2015-11-26T01:17:06.317" LastActivityDate="2015-11-26T01:17:06.317" Title="Problem up loading to board" Tags="|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18106" PostTypeId="1" CreationDate="2015-11-25T13:49:28.330" Score="8" ViewCount="42955" Body="&lt;p&gt;I have connected my Arduino with an ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check the ESP8266, by manually entering commands at serial monitor, I get correct results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run this program &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(2,3);&#xA;&#xA;void setup() {&#xA;  Serial.setTimeout(5000);&#xA;  Serial.begin(115200);&#xA;  esp8266.begin(115200);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(2000);&#xA;  String command=&quot;AT&quot;;&#xA;&#xA;  esp8266.println(command);&#xA;  if(esp8266.available())&#xA;  {&#xA;    while(esp8266.available())&#xA;    {&#xA;      char c=esp8266.read();&#xA;      Serial.write(c);          &#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get garbage values where sometimes it has an &lt;code&gt;OK&lt;/code&gt; in between the output:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot; Received: &quot;ÁT OK &quot; Received: &quot;AÔ ÏË &quot; Received: &quot;AÔ OK &quot; Received: &quot;ÁT ÏË &quot; Received: &quot;ÁT OË &quot; Received: &quot;ÁÔ OK &quot; Received: &quot;Á¬ OK &quot; Received: &quot;ÁT OË &quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Could someone help me?&lt;/p&gt;&#xA;" OwnerUserId="15105" LastEditorUserId="6936" LastEditDate="2016-02-10T13:47:58.340" LastActivityDate="2021-11-15T09:28:35.667" Title="Arduino outputs garbage values on serial monitor with ESP8266" Tags="|arduino-uno|esp8266|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18107" PostTypeId="2" ParentId="12196" CreationDate="2015-11-25T14:55:19.910" Score="2" Body="&lt;p&gt;Ultrasonic sensors can only measure the distance to the nearest object in their cone. Are you sure you can detect a &quot;small&quot; thing like a cat?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the only feasable way is to use optical recognition (motion sensor with a camera - even a webcam - and a board like a raspberry pi). &lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-11-25T14:55:19.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18108" PostTypeId="1" CreationDate="2015-11-25T15:18:18.153" Score="0" ViewCount="3761" Body="&lt;p&gt;I was thinking about if it is possible to &lt;strong&gt;simulate&lt;/strong&gt; PWM (AKA pulse width modulation).&lt;br&gt;&#xA;Is it possible to reach the speed of the PWM using the delay() function ?.&lt;br&gt;&#xA;Note : I am talking about the pins which does not support PWM, Arduino uno Pin 13 for example.&lt;/p&gt;&#xA;" OwnerUserId="14669" LastActivityDate="2016-01-12T21:12:40.350" Title="Is it possible to simulate PWM using delay() function?" Tags="|pwm|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18110" PostTypeId="2" ParentId="18108" CreationDate="2015-11-25T15:33:55.157" Score="3" Body="&lt;p&gt;It is possible to create a PWM signal from a non-PWM digital pin although you would not want to use delay, but timer interrupts for accuracy and finite timing. PWM intervals are typically measured in (μs[microseconds] vs ms[milliseconds]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The standard Arduino servo library  does this: &lt;a href=&quot;https://github.com/arduino/Arduino&quot; rel=&quot;nofollow&quot;&gt;Servo&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14589" LastActivityDate="2015-11-25T15:33:55.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18111" PostTypeId="2" ParentId="18108" CreationDate="2015-11-25T16:11:15.340" Score="1" Body="&lt;p&gt;It would be possible to do it. Would it be a smart thing to do ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not think so. Micro-controllers (not just Atmel's) have dedicated hardware modules to manage the signals for PWM. What happens when you use AnalogWrite is the compiler/interpreter/whatever uses these informations to modify the appropriate registers so the toggling is not managed by the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the delay() functions, you are simply letting clock cycles pass by until the time you set is passed which is a lot less efficient. Plus, you would probably not get the same PWM frequency.&lt;/p&gt;&#xA;" OwnerUserId="14942" LastActivityDate="2015-11-25T16:11:15.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18112" PostTypeId="2" ParentId="18108" CreationDate="2015-11-25T16:13:34.717" Score="1" Body="&lt;p&gt;What you are talking about is more appropriately called Bit-Banging. Check out this &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. It even has an example of what you are trying to do. @Jason is correct that it causes a number of issues. The link above will also run you through the draw backs of this method which I will summarize.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Jittery due to interrupts (Interrupts can be disabled)&lt;/li&gt;&#xA;&lt;li&gt;The Processor cannot do anything else and keep the output working&lt;/li&gt;&#xA;&lt;li&gt;Frequency and Duty Cycle are difficult to determine&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14953" LastActivityDate="2015-11-25T16:13:34.717" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18113" PostTypeId="2" ParentId="18105" CreationDate="2015-11-25T16:48:26.293" Score="1" Body="&lt;p&gt;One of the first things to know about Arduinos is that that there are a lot of them – and a lot of tools for programming them. For your problem this means that the most likely reason for the problem you are having is a mismatch between the board your are using and the board your tools are set to upload to. Since you've said you're new to the Arduino I'm assuming that you're using the &quot;official&quot; IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, here are some things to try:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;From the IDE main menu, choose &lt;strong&gt;Tools &gt; Board&lt;/strong&gt; and select your board, then&lt;/li&gt;&#xA;&lt;li&gt;Choose &lt;strong&gt;Tools &gt; Programmer&lt;/strong&gt; and select an appropriate programmer for your board. Without knowing what board you're using and how you're connecting to it I can't offer more specific advice. However, if you Google for something like &quot;beginner tutorial &quot; you're likely to find an answer. Or more likely three answers. You'll need to look at the one that matches the OS you're using on your development machine.&lt;/li&gt;&#xA;&lt;li&gt;You may also need to select the port that the Arduino is connected to.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you've gotten this far and haven't solved the problem, here's what I'd do next:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do a search on the exact error message you're getting – copy it out of the IDE and the paste it into your favorite search engine. Put quotes around the message so that you don't get a bunch of unrelated hits for your search.&lt;/li&gt;&#xA;&lt;li&gt;Search for tutorials on the board and/or IDE vendor site.&lt;/li&gt;&#xA;&lt;li&gt;Work through a tutorial from a good beginner's site. I like the &lt;a href=&quot;https://learn.adafruit.com/lesson-0-getting-started/overview&quot; rel=&quot;nofollow&quot;&gt;materials the Adafruit folks have developed&lt;/a&gt;, but there are lots of good resources out there.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Post a question. When you do be sure to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Describe your environment: the board you're using, the IDE you're using, the OS you're working on, how the board is connected to the development machine, and the basic settings of the IDE.&lt;/li&gt;&#xA;&lt;li&gt;Explain what you've tried.&lt;/li&gt;&#xA;&lt;li&gt;Describe, or better, include a screen shot or the actual text of the problem that you're seeing (like you did here).&lt;/li&gt;&#xA;&lt;li&gt;For some problems it will also be useful to include the code. If you include the complete code then it is possible that somebody could try to actually reproduce your problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-25T16:48:26.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18116" PostTypeId="2" ParentId="18089" CreationDate="2015-11-25T19:59:37.723" Score="0" Body="&lt;p&gt;This is my updated code based on your suggestions, jwpat, although I did not understand your comment with &lt;code&gt;delay(70);&lt;/code&gt; not being needed if I start conversion with &lt;code&gt;(2,0x5A)&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;SoftwareSerial mySerial(10,11); // RX, TX &#xA;&#xA;void SendCmd(unsigned char address,unsigned char cmd)&#xA;{&#xA;  mySerial.write(address);//set the address of SRF02(factory default is 0)&#xA;  //delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit&#xA;  mySerial.write(cmd);//send the command to SRF02&#xA;  //delayMicroseconds(100);//serial data is fixed at 9600,N,8,2,so we need some time to creat the sencond stop bit&#xA;}&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  Serial.println(&quot;SRF02 TEST!&quot;);&#xA;}&#xA;void loop(void)&#xA;{&#xA;  unsigned long t3;&#xA;  unsigned long t1=micros();//time tx command issued&#xA;  SendCmd(0, 0x5C);//send pulse with transmitter&#xA;  unsigned long t2=micros();//time rx command issued&#xA;  SendCmd(2, 0x58);//listen for pulse&#xA;  //SendCmd(2, 0x5A);&#xA;  delay(70);//time for SRF02 to measure the range&#xA;  //SendCmd(0x02,0x5E);&#xA;  SendCmd(2,0x5E);//Get range&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA; while(mySerial.available()&amp;gt;=2)//if two bytes were received&#xA;  {&#xA;    t3 = mySerial.read()&amp;lt;&amp;lt;8;//receive high byte (overwrites previous reading) and shift high byte to be high 8 bits&#xA;    t3 |= mySerial.read();// receive low byte as lower 8 bits&#xA;    unsigned long Tm = t3 + t2 - t1;//total amt of microseconds between pulse and reading&#xA;    unsigned long Dist = (Tm/29); //converting microseconds to cm&#xA;    Serial.print(Dist); // print the reading&#xA;    Serial.println(&quot;cm&quot;);&#xA;    //Serial.print(tm);&#xA;    //Serial.println(&quot;ms&quot;);&#xA;&#xA;  }&#xA;  delay(250); // wait a bit since people have to read the output :)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running this code my results keep being the following values regardless of me shifting the distance between the sensors: &#xA;72cm &lt;a href=&quot;https://i.stack.imgur.com/hXdBw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hXdBw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="15032" LastEditDate="2015-11-25T20:19:40.200" LastActivityDate="2015-11-25T20:19:40.200" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18117" PostTypeId="2" ParentId="13064" CreationDate="2015-11-25T20:18:29.423" Score="4" Body="&lt;p&gt;I ran across this post and thought that a more in depth explanation should be given on why when using digital inputs that more times than not you will need to use the pull-up resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you define one of the pins to be a input the chip measures the voltage on the pins, if the voltage measures more than half of the VCC voltage the input is off. What happens if you don't use a Pull-up Resistor the chip will measure a seemingly random voltage. This is because of interference from other electronics, radio waves etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what happens when you use a high resistance Resistor (10 - 100 ohms) it forces the voltage to remain high if the pin is not grounded since there is voltage being applied. But when you ground the pin using a Button or whatever the pin is kept under the halfway mark around 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you mentioned using the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(PIN, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;enables the internal Pull-Up Resistors in the chip by setting the Pin to a High state like you would defining it as a output. The code above is a newer way of writing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(PIN, INPUT);&#xA;digitalWrite(PIN, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now there is another reason for seemingly random input signals, which is called &quot;Button Bounce&quot;. What happens here is when a User presses the Button there might be a very small time that the Button actually connects then disconnects then finally reconnects. This is because of when the contacts of the Switch come together sometimes they don't connect perfectly, one side of the Switch might connect then be disconnected as the connecting plate levels out before finally connecting as it should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a Snapshot I found from &lt;a href=&quot;http://www.gammon.com.au&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au&lt;/a&gt;, it shows a bounce from a Osillicope showing the actual Button Bounce:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mR2Vz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mR2Vz.png&quot; alt=&quot;Button Bounce&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make sure that the user is actually pressing the button use a delay and recheck the Button again to see if it is still pressed. I find that a 500 - 700 microsecond delay works great. I provided a quick example on how to catch a Button Bounce (&lt;a href=&quot;https://www.arduino.cc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// constants won't change. They're used here to&#xA;// set pin numbers:&#xA;const int buttonPin = 2;    // the number of the pushbutton pin&#xA;const int ledPin = 13;      // the number of the LED pin&#xA;&#xA;// Variables will change:&#xA;int ledState = HIGH;         // the current state of the output pin&#xA;int buttonState;             // the current reading from the input pin&#xA;int lastButtonState = LOW;   // the previous reading from the input pin&#xA;&#xA;// the following variables are long's because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long lastDebounceTime = 0;  // the last time the output pin was toggled&#xA;long debounceDelay = 50;    // the debounce time; increase if the output flickers&#xA;&#xA;void setup() {&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;&#xA;  // set initial LED state&#xA;  digitalWrite(ledPin, ledState);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the switch into a local variable:&#xA;  int reading = digitalRead(buttonPin);&#xA;&#xA;  // check to see if you just pressed the button&#xA;  // (i.e. the input went from LOW to HIGH),  and you've waited&#xA;  // long enough since the last press to ignore any noise:&#xA;&#xA;  // If the switch changed, due to noise or pressing:&#xA;  if (reading != lastButtonState) {&#xA;    // reset the debouncing timer&#xA;    lastDebounceTime = millis();&#xA;  }&#xA;&#xA;  if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;    // whatever the reading is at, it's been there for longer&#xA;    // than the debounce delay, so take it as the actual current state:&#xA;&#xA;    // if the button state has changed:&#xA;    if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;&#xA;      // only toggle the LED if the new button state is HIGH&#xA;      if (buttonState == HIGH) {&#xA;        ledState = !ledState;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  // set the LED:&#xA;  digitalWrite(ledPin, ledState);&#xA;&#xA;  // save the reading.  Next time through the loop,&#xA;  // it'll be the lastButtonState:&#xA;  lastButtonState = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope that this explanation will help others out saving them from banging their heads against the wall trying to figure out where these phantom signals are coming from.&lt;/p&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2015-11-25T20:18:29.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18119" PostTypeId="1" CreationDate="2015-11-25T21:18:16.927" Score="5" ViewCount="1514" Body="&lt;p&gt;How do you confirm a pin has been damaged and is unable to work as a digital input?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried detecting a pushbutton (connecting ground to pin 11 with a pullup resistor enabled) on a fresh Arduino Uno and digitalRead() always registers 0, regardless of the pushbutton state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To confirm it wasn't my pushbutton's wiring, I tested it on some other pins, and they register the button press perfectly. I then tested pin 11 as an output, and it was able to blink and LED just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's pretty new, and I don't remember doing anything with it that would have damaged anything, much less pin 11, but is it fair to say that pin has somehow been damaged? As far as I can tell, everything else on the Arduino works perfectly.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-12-21T20:19:54.683" Title="How to confirm a pin is fried" Tags="|arduino-uno|wires|digital-in|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18120" PostTypeId="1" AcceptedAnswerId="18130" CreationDate="2015-11-25T22:02:15.030" Score="0" ViewCount="1089" Body="&lt;p&gt;How would you go about checking if an input pin has been set using the entire bank? I am thinking that I need to use bit twiddling with a bit mask but I have not used this enough to figure out how to do what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;   DDRA = 0x00;&#xA;   PORTA = 0xff;&#xA;}&#xA;&#xA;void loop(){&#xA;   //Check if any pin from Port A has been pressed&#xA;   if (PINA &amp;amp; 0xff){&#xA;      //do stuff&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the code above is not working how I expected it to. Has anyone tried to use this approach before? Am I going about this the wrong way? I figured since I was using all 8 pins from one bank, it would be better to check if any of the pins on that bank have been set instead of checking each individual pin. My thinking on this was to prevent any user input from being skipped in case a button press was initiated while the program was running other code. This way I only check if anything in the bank has been set saving time (I think).&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="4628" LastEditDate="2015-11-26T20:43:45.940" LastActivityDate="2019-02-26T00:30:52.563" Title="How to check if a pin is set from bank?" Tags="|programming|arduino-mega|avr|input|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18121" PostTypeId="2" ParentId="18120" CreationDate="2015-11-25T22:13:42.230" Score="0" Body="&lt;p&gt;The simplest way is to use DigitalRead in a loop. It makes your code more portable, and easier to read.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-11-25T22:13:42.230" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18124" PostTypeId="1" CreationDate="2015-11-26T00:03:49.640" Score="1" ViewCount="356" Body="&lt;p&gt;I am using HIDUINO as my firmware (flashing via dfu-programmer), and to upload sketch I need to re-flash original firmware, upload sketch and then flash HIDUINO again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to flash sketches without reflashing original firmware?&lt;/p&gt;&#xA;" OwnerUserId="15117" LastActivityDate="2015-11-26T11:06:35.700" Title="Is there any way to flash sketches using custom firmware?" Tags="|flash|firmware|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18126" PostTypeId="1" AcceptedAnswerId="18240" CreationDate="2015-11-26T00:12:11.157" Score="1" ViewCount="408" Body="&lt;p&gt;I'm wondering if there's anything out there that maybe works pretty similarly to Firmata, runs on Unos or Megas, and can be controlled over Ethernet. I am writing a home automation system with .NET, and I see some options for supporting Firmata with .NET, but I want to be able to connect my devices over Ethernet.&lt;/p&gt;&#xA;" OwnerUserId="15107" LastActivityDate="2015-11-29T16:38:01.233" Title="Is there something I can use to control Arduinos easily over Ethernet with .NET?" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18127" PostTypeId="2" ParentId="18120" CreationDate="2015-11-26T00:46:02.893" Score="0" Body="&lt;p&gt;I'm not really an expert in &amp;quot;plain avr code&amp;quot; but I've modified arduino blink and got (almost) a perfect example. Placed a jumper between 5v and pin 8 of arduino and uploaded the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;  DDRB = 0b00100000;&#xA;  &#xA;  &#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  if (PINB &amp;amp; 0x1) {&#xA;    PORTB =  0b00100000;  // turn the LED on (HIGH is the voltage level)&#xA;    delay(500);              // wait for a second&#xA;    PORTB = 0;    // turn the LED off by making the voltage LOW&#xA;    delay(500);              // wait for a second&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;according to following picture pin8 on arduino is PB0 and pin13 is PB5. So using DDRB I set PB5 as output and all others as input. Then in loop I check as you do PINB register and use bitmask to check first pin (the PB0). And it works... well not quite well. For some reason the loop goes a few times more before goes really low. I believe is because I just remove the jumper and do not actually ground pin 8 ( is left float) and maybe the extra loops are discharging some capacitance on that pin 8.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZXMxn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZXMxn.png&quot; alt=&quot;pinouts&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://jobs.arduinoexperts.com/wp-content/uploads/2013/03/ARDUINO_V2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduinoexperts.com&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;So, to your specific question, your bitmask is right. This instruction &lt;code&gt;PORTA = 0xff;&lt;/code&gt; is useless because, as far as I know, this settings are ignored because you set Pin direction in pins of PORTA to input. However, according to that image, atmega328 doesn't have a PORTA. Is that your error or are you using another microcontroller?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Capacitance thing is confirmed, maked it swing between gnd and vcc   with a switch and all works fine.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-02-26T00:30:52.563" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18130" PostTypeId="2" ParentId="18120" CreationDate="2015-11-26T02:27:15.247" Score="2" Body="&lt;p&gt;The problem is here:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;//Check if any pin from Port A has been pressed&#xA;if (PINA &amp;amp; 0xff){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since the pullups are enabled, the default state of the pins is high. To detect a &quot;press&quot;, they have to be pulled to ground. This changes the test to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Check if any pin from Port A has been pressed&#xA;if (~PINA) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And for individual pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Check if PA3 has been pressed&#xA;if (!(PINA &amp;amp; _BV(PA3))) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="368" LastEditDate="2015-11-26T02:34:11.277" LastActivityDate="2015-11-26T02:34:11.277" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18131" PostTypeId="2" ParentId="3700" CreationDate="2015-11-26T07:36:17.467" Score="1" Body="&lt;p&gt;once you have installed the driver, you should be able to use it with any IDE or program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but I doubt anyone would prefer the Arduino IDE to codebender&lt;/p&gt;&#xA;" OwnerUserId="8222" LastActivityDate="2015-11-26T07:36:17.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18133" PostTypeId="1" CreationDate="2015-11-26T09:34:51.183" Score="0" ViewCount="941" Body="&lt;p&gt;Hello folks,&#xA;              I am using G1/4 Pressure Transmitter Sensor 0-1.2 MPa sensor can you guide for programming part.The conversion from bar to pascal  or bar to Mpa or pascal to psi.Though I am new to it. Plz guide me .&lt;/p&gt;&#xA;" OwnerUserId="13400" LastActivityDate="2015-11-27T00:21:42.813" Title="Interface pressure Sensor" Tags="|arduino-uno|c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18134" PostTypeId="2" ParentId="18124" CreationDate="2015-11-26T10:04:08.763" Score="1" Body="&lt;p&gt;I assume you mean you are reprogramming the USB interface chip, which means you no longer have a UART pathway through to the ATMega328P. If so then yes, you can provide your own USB interface in parallel by connecting an FT232 (or similar) breakout board direct to the ATMega328P chip just like you would on a breadboard Arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zaoYI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zaoYI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;FTDI TX -&gt; Arduino RX (Yellow)&lt;/li&gt;&#xA;&lt;li&gt;FTDI RX -&gt; Arduino TX (Blue)&lt;/li&gt;&#xA;&lt;li&gt;FTDI DTR -&gt; 100nF Capacitor -&gt; Arduino RESET (Green)&lt;/li&gt;&#xA;&lt;li&gt;FTDI GND -&gt; Arduino GND (Black)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The capacitor is required with later versions of &lt;code&gt;avrdude&lt;/code&gt; and newer versions of the Arduino IDE since the DTR signal is now held LOW rather than being pulsed as it used to be.  This is to combat a change in the FTDI drivers that meant that the DTR stopped being driven at all and broke the auto-reset facility.  So now we need a capacitor to convert a constant LOW into a short low-going pulse to initiate a reset without locking it all up.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-26T11:06:35.700" LastActivityDate="2015-11-26T11:06:35.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18135" PostTypeId="1" CreationDate="2015-11-26T10:11:51.120" Score="-1" ViewCount="5965" Body="&lt;p&gt;I would like to use an array of strings which I define as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* CommandQueue[]={&quot;FirstCommend&quot;, &quot;SecondCommend&quot;, &quot;ThirdCommand&quot;, &quot;Cmd4&quot;, &quot;Cmd5&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The purpose of this array is to hold commands (&quot;strings of various lengths&quot;) that the Arduino will receive through a serial port. Those commands will be interpreted by calling appropriate callback functions to act on them. The CommandQueue is supposed to line up the commands in a sort of &quot;buffer&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially the &quot;CommandQueue&quot; array does not contain any elements and gets populated during the runtime of the project. The  array will continuously be interrogated and once a command is interpreted (and the corresponding function executed) the command will be eliminated from the queue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I determine how many elements (i.e. strings) or commands are present in the array? The sizeof() function will not be helpful because the individual elements can be of different lengths.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for your help or comments.&lt;/p&gt;&#xA;" OwnerUserId="1612" LastActivityDate="2018-08-09T03:04:24.123" Title="Array of strings - how to determine the number of elements present" Tags="|string|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18136" PostTypeId="2" ParentId="18135" CreationDate="2015-11-26T10:33:21.047" Score="1" Body="&lt;p&gt;Do you need to know how long the command queue is, or just if there are still elements in it? This seems like a case where you might be better off using a different data structure – a linked list seems like an obvious possibility. If you're not familiar with linked lists, &lt;a href=&quot;http://www.thegeekstuff.com/2012/08/c-linked-list-example/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; may be helpful. Otherwise, I think you'll need to keep track of the number of elements in the queue for yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do use an array, it will need to be declared with a fixed length, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; char * CommandQueue[MAX_QUEUE_LENGTH];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sizeof&lt;/code&gt; operator would tell you the length of the array, but not the number of items in it (the length of the array is the number of character pointers defined by MAX_QUEUE_LENGTH). The code to manage the command queue as an array could get pretty messy, especially if you need to execute the commands in order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If instead you use a linked list then each command is added to the list at the end as it comes in, and when you execute commands they are pulled from the head of the list. If you need to know the length of the queue you could either update it as you add and remove commands, or you could iterate over the list and count the number of items in the list.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-11-26T10:44:19.980" LastActivityDate="2015-11-26T10:44:19.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18137" PostTypeId="1" CreationDate="2015-11-26T10:57:05.290" Score="0" ViewCount="4084" Body="&lt;p&gt;I'm trying to send short strings via Java client to Arduino server and vice versa. Sending data to client goes fine, but when I try to send data to arduino it cuts the string into bytes and then sends the first letter.  Will the following work?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;for(int i = 0; i &amp;lt; data.length(); i++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if it can be sent as characters I want to send it in one piece, because strings are very short so there should be no problems with length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Alright, I read &lt;code&gt;client.read()&lt;/code&gt; documentation, so the problem is at arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my java code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;public class TCP {&#xA;static Socket clientSocket;&#xA;&#xA;public static void main(String args[]) throws Exception {&#xA;    clientSocket = new Socket(&quot;10.10.10.57&quot;, 5000); &#xA;    sendToServer(&quot;HAI THERE\n&quot;);&#xA;    String msg = getFromServer();&#xA;    System.out.println(msg);&#xA;    close();    &#xA;}&#xA;&#xA;static void sendToServer(String msg) throws Exception {&#xA;    //create output stream attached to socket&#xA;    PrintWriter outToServer = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream()));&#xA;    //send msg to server&#xA;    outToServer.print(msg + '\n');&#xA;    outToServer.flush();&#xA;}&#xA;&#xA;static String getFromServer() throws Exception{&#xA;    //create input stream attached to socket&#xA;    InputStreamReader isr = new InputStreamReader(clientSocket.getInputStream());&#xA;    BufferedReader inFromServer = new BufferedReader(isr);&#xA;    //read line from server&#xA;    String res = inFromServer.readLine(); // if connection closes on server end, this throws java.net.SocketException &#xA;    return res;&#xA;}&#xA;&#xA;static void close() throws IOException{&#xA;    clientSocket.close();&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code sends only one byte at the same time.It might be problem in my arduino code, since I read it with &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char c = client.read()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One more thing. If there is any java master, I would like to know what to do with exceptions. How should I handle disconnected socket, failed connection to server, and so forth?&lt;/p&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="3917" LastEditDate="2015-11-27T23:05:36.337" LastActivityDate="2015-11-27T23:05:36.337" Title="Sending data over TCP connection in one piece" Tags="|arduino-uno|tcpip|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18138" PostTypeId="1" AcceptedAnswerId="18139" CreationDate="2015-11-25T23:02:21.080" Score="0" ViewCount="172" Body="&lt;p&gt;I've had the 1.0.5 IDE on my PC, which worked great. Now I've just decided to update to 1.6.6. After some stupid Java errors and trial and error, I got it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recompiled my project. Massive errors. Fixed the errors and compiled again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It stated &quot;Uploading...&quot; That took much longer than before, but I saw the &quot;This takes xxx memory and xxx bytes on the device&quot; yadi yadi ya.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to unplug the Arduino, swap some jumpers and reconnect it (as I've always done). Only this time - I hear 3 beeps from my PC (the sound you hear with broken USB devices). The COM port is no longer recognized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do  I fix this? Did that IDE upgrade just brick my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="15039" OwnerDisplayName="Rob Quist" LastEditorUserId="4628" LastEditDate="2017-06-19T04:34:52.567" LastActivityDate="2017-07-19T05:52:32.820" Title="Updated Arduino IDE and Arduino not working" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18139" PostTypeId="2" ParentId="18138" CreationDate="2015-11-25T23:06:46.553" Score="0" Body="&lt;p&gt;Allright, seems to be fixed. After a 3rd reinstall it seems like its fixed. I reinstalled the whole package, including the drivers, and now it seems to recognize the device again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the compiling now stops properly when done and shows &quot;upload complete&quot;.&lt;/p&gt;&#xA;" OwnerUserId="15039" OwnerDisplayName="Rob Quist" LastActivityDate="2015-11-25T23:06:46.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18140" PostTypeId="2" ParentId="18135" CreationDate="2015-11-26T11:14:38.723" Score="2" Body="&lt;p&gt;You can't know how many items are in an array simply because an array has a fixed size, and there is no such thing as &quot;not an entry&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest you can have is a fixed size array and only some entries in it are valid - those that aren't valid have a special value to say &quot;this is not a valid entry&quot;. For &lt;code&gt;char&lt;/code&gt; pointers it's normal to use &lt;code&gt;NULL&lt;/code&gt; as the &quot;not a valid entry&quot; value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The drawback of this approach though is that you can never store more items than there are slots for, and finding out how many valid or invalid entries there are and shuffling them around when you remove the first entry is both a tedious and time consuming task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better in this situation to use a &lt;em&gt;circular buffer&lt;/em&gt; which is a fixed size array but you remove the concept of a &quot;first&quot; entry. Instead you have a &quot;head&quot; and a &quot;tail&quot; value which is the locations in the array where you read from (remove the oldest) and write to (add after the newest).  It's how the serial port on the Arduino deals with incoming and outgoing data - as data arrives it is added to a circular buffer and you then read from that buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To help work with circular buffers I wrote a small template class:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/CircularBuffer&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/CircularBuffer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-26T11:14:38.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18141" PostTypeId="1" AcceptedAnswerId="18158" CreationDate="2015-11-26T11:19:06.770" Score="0" ViewCount="437" Body="&lt;p&gt;I'd like to write a Board Manager profile for some Arduino boards that I have. So far I've struck out on finding the documentation on the format and contents of the files. Does anybody know where I can find it?&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2017-08-06T05:35:09.933" Title="Documentation for creating a Board Manager profile for the Arduino IDE" Tags="|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18142" PostTypeId="1" CreationDate="2015-11-26T12:08:49.337" Score="0" ViewCount="145" Body="&lt;p&gt;I am currently working on a project that uses an Arduino Mega 2560 board along with the Arduino GSM shield to connect to the internet and send/receive SMS messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As part of my project, I want to be able to update the software that I am running dynamically. At a high level, I want to connect to my server, check if there is an update, if there is, download it and then overwrite the current sketch to run the new downloaded binary if the checksum of the downloaded binary is as expected (to avoid corruption).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I am new to Arduino programming, so I figured I would ask a community of people with experience to determine the best method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current ideas are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Writing a custom bootloader&lt;/strong&gt; - The sketch will have an update routine that downloads the new binary to a known location, and then performs a system reset. The bootloader will then overwrite the current sketch with the downloaded binary and then run the sketch.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Overwriting the sketch whilst running&lt;/strong&gt; - I'm not sure of the viability of this method, but the overall method would be to write an update routine to the end of flash memory, and in this code simply overwrite all of the non-bootloader code with the new sketch.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Are these methods both viable, if so, is there one that would be preferable to another? If not, are there any known solutions to this problem?&lt;/p&gt;&#xA;" OwnerUserId="632" LastActivityDate="2015-11-26T13:36:32.600" Title="Best practise when dynamically updating sketch" Tags="|uploading|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18143" PostTypeId="1" CreationDate="2015-11-26T12:31:05.120" Score="0" ViewCount="263" Body="&lt;p&gt;So the arduino shows up as &quot;Unknown device&quot; when connected to my computer. Followed somr guides on google but still failed, this error came up, what should I do? I've tried &quot;Disable Driver Signature Enforcement&quot; and the regedit thing..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TUxUJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TUxUJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15126" LastActivityDate="2016-06-15T12:53:48.043" Title="Windows 10 problem installing driver" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18144" PostTypeId="2" ParentId="18142" CreationDate="2015-11-26T13:36:32.600" Score="1" Body="&lt;p&gt;You won't be able to download the whole binary and test its checksum before flashing because RAM is so much smaller than flash. To do that, you'd need an external storage device to hold the new binary, and a custom bootloader to install it from the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you'll have to load-and-flash, testing the checksum on the fly, and retry if you need to until you get a good reload. Can your device and its environment tolerate stopping for however long a couple of retry cycles might take? You can't recover if the process is interrupted once you start flashing; you can only move forward. Can it tolerate a conceivably long outage if communication goes down once the reload process has started?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-11-26T13:36:32.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18145" PostTypeId="1" CreationDate="2015-11-26T15:31:00.493" Score="0" ViewCount="252" Body="&lt;p&gt;I'd like to run an application on my system after pushing a button on an Arduino shield. I've read that I need to use the &lt;code&gt;runShellCommand()&lt;/code&gt; function, which can be accessed from a Process header. However when I add the &lt;code&gt;#include &amp;lt;Process.h&amp;gt;&lt;/code&gt; line to my program I'm getting this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.build/uno/src/sketch.cpp:2:21: fatal error: Process.h: No such file or directory&#xA; #include &amp;lt;Process.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using Ubuntu 14.04 and I've installed Arduino software from repositories.&lt;/p&gt;&#xA;" OwnerUserId="15130" LastEditorUserId="4628" LastEditDate="2015-11-26T20:42:24.640" LastActivityDate="2016-01-26T05:07:58.913" Title="I don't have &quot;Process&quot; header" Tags="|arduino-uno|linux|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18146" PostTypeId="2" ParentId="18145" CreationDate="2015-11-26T17:15:02.963" Score="1" Body="&lt;p&gt;That only works on an Arduino Yún (&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShellCommands&quot; rel=&quot;nofollow&quot;&gt;as described in this tutorial&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-11-26T17:15:02.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18147" PostTypeId="1" AcceptedAnswerId="18148" CreationDate="2015-11-26T17:55:51.770" Score="1" ViewCount="8036" Body="&lt;p&gt;I am using an Arduino Mega and a 12864ZW LCD with the u8glib library and the following code to draw to the LCD:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;U8GLIB_ST7920_128X64 Display(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);&#xA;&#xA;void loop(){&#xA;   Draw();&#xA;}&#xA;&#xA;void Draw(){&#xA;   Display.firstPage();&#xA;&#xA;   do{&#xA;      Display.setPrintPos(10, 10);&#xA;      Display.print(&quot;This is a test&quot;);&#xA;   }while(Display.nextPage());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the display is constantly redrawing itself. When I used LCD displays in the past, they usually only required to write to the LCD once unless you wipe the display. When I adjusted the code to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;U8GLIB_ST7920_128X64 Display(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);&#xA;bool needsUpdate = true;&#xA;&#xA;void loop(){&#xA;   Draw();&#xA;}&#xA;&#xA;void Draw(){&#xA;   if (needsUpdate){&#xA;       Display.firstPage();&#xA;       do{&#xA;          Display.setPrintPos(10, 10);&#xA;          Display.print(&quot;This is a test&quot;);&#xA;       }while(Display.nextPage());&#xA;       needsUpdate = false;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not get anything drawn on the LCD. Is there a parameter that needs to be set so I only have to redraw the LCD if something changes? Am I using an outdated library? Is there a better library I should be using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the main problem I have with using this library is does the Draw loop need to be executed continuously to display on the LCD or is there a way to only draw the screen once until it is needed to be drawn again?&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="4628" LastEditDate="2015-11-27T17:09:04.640" LastActivityDate="2015-11-27T17:09:04.640" Title="Problems with Draw Loop using u8glib" Tags="|programming|arduino-mega|library|lcd|u8glib|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18148" PostTypeId="2" ParentId="18147" CreationDate="2015-11-26T18:42:06.867" Score="1" Body="&lt;p&gt;&lt;strike&gt;You haven't shown us all the code – in particular, the call to &lt;code&gt;Draw()&lt;/code&gt; from &lt;code&gt;loop()&lt;/code&gt; is missing – so this answer is speculative, based on the assumption&lt;/strike&gt; your &lt;code&gt;loop()&lt;/code&gt; is as follows. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;    Draw();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;If so,&lt;/strike&gt; your first bit of code will constantly redraw because &lt;code&gt;loop()&lt;/code&gt; runs repeatedly without delay.  Try adding a &lt;code&gt;delay(1000);&lt;/code&gt; after &lt;code&gt;Draw()&lt;/code&gt; in that case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your second bit of code will begin by drawing your image once, and in that &lt;code&gt;Draw()&lt;/code&gt; call it will set &lt;code&gt;needsUpdate&lt;/code&gt; to false.  Then &lt;code&gt;loop()&lt;/code&gt; runs again, and the &lt;code&gt;firstPage()&lt;/code&gt; call erases the screen.  Since &lt;code&gt;needsUpdate&lt;/code&gt; now is false and remains false, subsequent calls don't draw an image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than putting your picture loop into &lt;code&gt;Draw()&lt;/code&gt;, perhaps use &lt;code&gt;Draw()&lt;/code&gt; just to draw primitives, and keep your controls in &lt;code&gt;loop()&lt;/code&gt;: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;  Display.firstPage();  &#xA;  do {     // picture loop&#xA;    Draw();&#xA;  } while( Display.nextPage() );    &#xA;  delay(1000); // delay before next picture&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you still get repeated fast redraws, for troubleshooting comment out the &lt;code&gt;do&lt;/code&gt; and &lt;code&gt;} while&lt;/code&gt; lines.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-26T19:19:25.000" LastActivityDate="2015-11-26T19:19:25.000" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18149" PostTypeId="1" CreationDate="2015-11-26T18:51:05.650" Score="2" ViewCount="560" Body="&lt;p&gt;I'm quite new to these things and I need some help. I'm building a computer shelf with plexiglass and RGB LEDs (one per length) and I need some help to sketch up a data sheet of some sort for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking of using an Arduino Uno, but will it be able to run 12+ LEDs?&lt;/p&gt;&#xA;" OwnerUserId="15132" OwnerDisplayName="Henrik" LastEditorUserId="6936" LastEditDate="2016-09-19T10:09:19.003" LastActivityDate="2016-09-19T10:09:19.003" Title="Multiple RGB LEDs" Tags="|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18151" PostTypeId="2" ParentId="18149" CreationDate="2015-11-26T19:43:42.573" Score="1" Body="&lt;p&gt;If your RGB LEDs are &lt;a href=&quot;http://www.ebay.com/sch/i.html?_odkw=WS2812+7++5050++Round&amp;amp;_osacat=0&amp;amp;_from=R40&amp;amp;_trksid=p2045573.m570.l1313.TR2.TRC0.A0.H0.XWS2812+++5050++.TRS0&amp;amp;_nkw=WS2812+++5050++&amp;amp;_sacat=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;WS2812-style, 5050-size&lt;/a&gt; units, it is no problem to control dozens of them using an Arduino Uno or several other models of Arduinos.  [For ATtiny systems, other libraries than &lt;a href=&quot;http://www.adafruit.com/category/168&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit's NeoPixel&lt;/a&gt; may be needed; the NeoPixel library keeps several bytes of state data per pixel, which some other libs don't.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WS2812-style LEDs typically are arranged in serial strings, driven by a single IO pin from an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have more than half a dozen WS2812s in the string, power for them should come from an external power supply, rather than via an Arduino's built-in 5V regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see related questions like &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/q/10357&quot;&gt;Arduino with WS2812 using Adafruit NeoPixel library fade in/out different patterns&lt;/a&gt;&lt;/em&gt;, and &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/q/17940&quot;&gt;Arduino and WS2812 RGB LED Strip &quot;freezing&quot;&lt;/a&gt;&lt;/em&gt;, and  &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/q/13136&quot;&gt;fading colors on a ws2812 strip&lt;/a&gt;&lt;/em&gt;; also see &lt;a href=&quot;https://www.google.com/search?num=50&amp;amp;hl=en&amp;amp;q=site:arduino.stackexchange.com/questions+WS2812+-newest+-recently&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google search Arduino Stackexchange for WS2812&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-11-26T19:43:42.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18152" PostTypeId="2" ParentId="17147" CreationDate="2015-11-26T19:44:12.260" Score="0" Body="&lt;p&gt;Did you make sure that your lines end with \n\r?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember you need both newline characters to send over the line from the terminal.&lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-12-16T03:16:07.187" LastActivityDate="2015-12-16T03:16:07.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18153" PostTypeId="1" CreationDate="2015-11-26T19:53:28.950" Score="2" ViewCount="64223" Body="&lt;p&gt;Im using the arduino Micro pro to read the data out of a temperature sensor (lm35). The program is compiling and NOT uploading, but when I try and open the serial monitor is says: Error opening serial port 'COM1'. (Port busy)&lt;/p&gt;&#xA;" OwnerUserId="15134" LastEditorUserId="15134" LastEditDate="2015-11-26T20:16:19.277" LastActivityDate="2016-03-01T06:16:45.340" Title="Error opening serial port 'COM1'. (Port busy)" Tags="|arduino-pro-micro|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18154" PostTypeId="1" AcceptedAnswerId="18157" CreationDate="2015-11-26T19:57:41.183" Score="1" ViewCount="745" Body="&lt;p&gt;I bought a &lt;a href=&quot;http://www.ebay.com/itm/5V-10A-one-1-Channel-Relay-Module-With-optocoupler-For-PIC-AVR-DSP-ARM-Arduino-/310636242802&quot; rel=&quot;nofollow noreferrer&quot;&gt;single channel relay&lt;/a&gt; on eBay and besides the NC/COM/NO, it has six pins and a jumper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PicO1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PicO1.jpg&quot; alt=&quot;relay&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not possible to see the labels on the image, but the labels are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X  X--X  X  X  X&#xA;VCC   -IN+   GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default jumper position is shown above with a &lt;code&gt;-&lt;/code&gt; mark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which pins should I use for VCC, GND and ARDUINO? Is the jumper on the correct position?&lt;/p&gt;&#xA;" OwnerUserId="15048" LastEditorUserId="10907" LastEditDate="2015-11-30T15:05:02.447" LastActivityDate="2015-11-30T15:05:02.447" Title="How does this eBay relay board connect to the Arduino" Tags="|arduino-mega|relay|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18155" PostTypeId="2" ParentId="18133" CreationDate="2015-11-26T20:05:51.017" Score="1" Body="&lt;p&gt;I'm assuming you mean that you want to pull a voltage number off of an input pin and convert it to a meaningful number. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this find the range of the incoming voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the range of the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you need to split the voltage up to show what parts of the range convert to how much psi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of a temperature gauge that has the same principle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor&quot; rel=&quot;nofollow&quot;&gt;Temp sensor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15133" LastActivityDate="2015-11-26T20:05:51.017" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18156" PostTypeId="2" ParentId="18119" CreationDate="2015-11-26T20:09:36.977" Score="1" Body="&lt;p&gt;Yes, it sounds like that pin is fried.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You seem to have done all the things I would recommend:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try your circuit on a different pin (works fine)&lt;/li&gt;&#xA;&lt;li&gt;Try your circuit on the same (faulty) pin on a different microcontroller (works fine)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you get different results between two chips that should be the same with the same code running on them then one of them is most likely faulty in some way, or has some other setting in it (fuse setting) that could be affecting it.  I am not aware of any settings like that on the '328P, certainly none that you would change without knowing you had changed them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-26T20:09:36.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18157" PostTypeId="2" ParentId="18154" CreationDate="2015-11-26T20:14:02.523" Score="2" Body="&lt;p&gt;Your module consists of both an optocoupler (large black rectangular device) and a P-channel MOSFET driver circuit for the relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VCC and GND are used to power the MOSFET and relay, and so should be connected to a power source suitable for driving the relay (if it's a 5V relay then the +5V and GND pins of the Arduino - if it's a 12V relay then a 12V power supply).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The interface to the Arduino is through the optocoupler. The Arduino sees that as just an LED, so you can wire it up just like any other LED.  The circuit contains a current limiting resistor already, so you don't need to worry about that at all.  So you connect the - of the input to GND and the + to an IO pin, or connect the + to +5V and the - to the IO pin, depending on which polarity of drive you want to have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The jumper is optional to allow you to create one of those two links on the board - say connecting - to GND or connecting + to VCC so you don't need the extra wire.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-26T20:14:02.523" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18158" PostTypeId="2" ParentId="18141" CreationDate="2015-11-26T20:17:49.723" Score="2" Body="&lt;p&gt;Documentation is kind of scarce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically there are two aspects to what you want - the &lt;em&gt;board definition&lt;/em&gt; and the &lt;em&gt;board manager JSON file&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first describes the board to both the IDE (entry in &lt;code&gt;boards.txt&lt;/code&gt;) and to the API software (definition of what pins are what and what peripherals are where, etc).  The latter is in the file &lt;code&gt;pins_arduino.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there is the &lt;code&gt;JSON&lt;/code&gt; file that describes the whole package to the board manager and is what allows people to download the &lt;code&gt;boards.txt&lt;/code&gt; and &lt;code&gt;pins_arduino.h&lt;/code&gt; files (and anything else you may require) from your website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As there is not much documentation you are best off taking an existing set of files that are close to what you want and modifying them.  Most of the time it will be a slight tweak such as re-ordering a few pins in some arrays, or changing the name of the board and maybe an upload command or baud rate setting.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-26T20:17:49.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18159" PostTypeId="2" ParentId="9201" CreationDate="2015-11-26T20:18:59.753" Score="1" Body="&lt;p&gt;I was just having this issue. You need to be able to read and write on both ends. You send up sending an ack package back to the sending arduino like in the test sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You ripped that part out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to read back through the example code and line by line understand what the data is doing and why it's doing it that way before you can start using rf24.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short of it is that the sender will send data and then finish and wait for a response packet before sending the next one. The reciever works much the same way except it always will be listening for incoming data until the sender message ends. Then it in turn will send a reply packet saying that it recieved the first packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure that the reciever isn't looping waiting for packets. It should only respond once it recieves something. The sender should have a timeout on it so that it knows that it's messages are failing. This is also incredibly important for debugging so you can see who failed and why. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is basically tcp at work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use noack and that's called udp&lt;/p&gt;&#xA;" OwnerUserId="15133" LastActivityDate="2015-11-26T20:18:59.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18160" PostTypeId="2" ParentId="18154" CreationDate="2015-11-26T20:19:58.400" Score="0" Body="&lt;p&gt;You should do a bit of testing. The Vcc and GND pins will go to power and ground respectively. They are powering the circuitry on the board that protects the Arduino from the relay coil. Then it looks like the IN pins allow you to operate the relay either from an active high or an active low signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a DMM check the connections of the pins (see if any of them are common). The thing that is puzzling to me is the jumper, but it may be set up so that you can use only two wires to control the relay by using the IN terminal to also supply either Vcc or ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So start out by hooking up to power and ground, and then test by jumping the IN pins to ground and power in turn. I would expect the relay to operate when the IN+ goes to Vcc or when the IN- goes to GND.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-26T20:19:58.400" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18161" PostTypeId="2" ParentId="18001" CreationDate="2015-11-26T20:34:57.750" Score="1" Body="&lt;p&gt;you can read a complete (real project) example about how to receive messages from Arduino with Ardulink from here: &lt;a href=&quot;https://github.com/openQCM&quot; rel=&quot;nofollow&quot;&gt;https://github.com/openQCM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general you can use a listener (digital, analog, and raw) to receive messages from Arduino. A raw listener receive all messages received from Arduino, so you need to implement code to filter the messages you are interested in. Digital and Analog listeners receive events from digital and analog PINs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch in your question isn't the original sketch you can find in Ardulink distribution. That sketch was written to manage the OLED on the ChipKit shield I have. You have modified the sketch to manage your LCD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually you can send successfully messages from an Ardulink based application (as Ardulink Console) to Arduino since LED on PIN 13 is turned on. So the problem maybe just on your sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To FIX analogWrite on PIN 9 try to set the PIN as OUTPUT with this statement:&#xA;pinMode(9, OUTPUT);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot help you with lcd library that I don't know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need for some help don't hesitate to write to me. &lt;/p&gt;&#xA;" OwnerUserId="9934" LastActivityDate="2015-11-26T20:34:57.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18162" PostTypeId="2" ParentId="18147" CreationDate="2015-11-26T21:05:54.433" Score="1" Body="&lt;p&gt;Much thanks to jwpat7 for getting me on the right track with this. So I found out how this LCD should really be setup. I am not sure why the examples I was able to find online and even on the u8glib wiki showed the usage like my question but I was able to get this library functioning right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First thing is the .firstPage() and .nextPage() functions. The .firstPage() function actually clears the screen and the .nextPage() function displays what is waiting in the queue (thanks jwpat7). When the .nextPage() finishes there is no need to write to the LCD again until you need a refresh. I put together a very simple code example that uses a input to change the text without having to continuously update the LCD.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;U8GLIB_ST7920_128X64 Display(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);&#xA;bool redraw = true;&#xA;String strOut = &quot;This is a test...&quot;;&#xA;&#xA;void loop() {&#xA;&#xA;    if (redraw){&#xA;        Display.firstPage();  //Clear the LCD&#xA;&#xA;        //Main Difference while the LCD needs drawing will return 1&#xA;        while(Display.nextPage()){&#xA;            Display.setFont(u8g_font_04b_03b);&#xA;            Display.setPrintPos(20, 20);&#xA;            Display.print(strOut);&#xA;        }&#xA;&#xA;        redraw = false;  //Clear flag to redraw&#xA;    }&#xA;&#xA;    //check if any of the pins in PINA have been pressed &#xA;    if (~PINA &amp;amp; 0xff){&#xA;        strOut = &quot;Of the emergency broadcast ...&quot;;&#xA;&#xA;        redraw = true; //Set flag to redraw the screen&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2015-11-26T21:05:54.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18163" PostTypeId="1" AcceptedAnswerId="18500" CreationDate="2015-11-26T21:37:09.903" Score="3" ViewCount="12214" Body="&lt;p&gt;I am trying to make a sensor that gets temperature and humidity values from a DHT22 and send it through NRF24L01+ to a Raspberry Pi 2 Model B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To connect NRF24L01+ to ATtiny85 and to free two pins for the DHT22, I used &lt;a href=&quot;http://hackster.io/arjun/nrf24l01-with-attiny85-3-pins-74a1f2&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a scheme of my sensor:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ip0Y4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ip0Y4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a photo of the test board with the sensor (sorry, it is very untidy, because I remade it many times before to fix the problem):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/52X6K.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/52X6K.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I program the ATtiny85 with Arduino IDE (with 8 MHz clock).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;a href=&quot;http://github.com/TMRh20/RF24&quot; rel=&quot;nofollow noreferrer&quot;&gt;this library&lt;/a&gt; and radio communication is working perfectly (it can't be an error during the radio transmission).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code of my ATtiny85:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;byte currentNodeAddr[6] = &quot;1Node&quot;;  // Address of this node&#xA;&#xA;// Struct for sending measured data&#xA;struct Data {&#xA;  uint16_t temp;  // Temperature value&#xA;  uint16_t hum;   // Humidity value&#xA;  int status;     // DHT22 module status&#xA;} data;&#xA;&#xA;RF24 radio(2,2);  // Create instance of RF24 radio object&#xA;DHT dht;          // Create instance of DHT22 module object&#xA;&#xA;void setup() {&#xA;  // Set up the radio&#xA;  radio.begin();&#xA;  radio.openWritingPipe(currentNodeAddr);&#xA;  radio.stopListening();&#xA;  dht.setup(3); // Set up the sensor on PB3 pin&#xA;}&#xA;&#xA;void loop() {&#xA;  // This DHT library can calculate the delay but it may be 2+ sec&#xA;  delay(dht.getMinimumSamplingPeriod());&#xA;  // Get values from DHT22&#xA;  data.temp = dht.getTemperature();&#xA;  data.hum = dht.getHumidity();&#xA;  radio.write(&amp;amp;data, sizeof(Data));  // Send data to the Raspberry&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't the get temperature and humidity values from the DHT22. I used a lot of different libraries for DHT22 (for example, &lt;em&gt;github.com/ringerc/Arduino-DHT22, github.com/nethoncho/Arduino-DHT22, github.com/jscrane/DHT22&lt;/em&gt;, etc.) and none of them works (they return zeros, NAN, or, generally, timeout error). And it seems that the connection with the DHT22 is correct (there were connection errors and I fixed them). I tried to use a lot of DHT22 modules, so the problem can't be a defective module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I put a 2 second (and more) delay in between read requests. Yes, I added a 10k resistor between pin 1 and 2 of the DHT22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am thinking that the libraries work fine, but may be free pins (PB3 or PB4) of ATtiny85 can't receive data for some reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tell me please where may be an error or a bug? Thank you in advance! And also many thanks to authors of all links and repositories that I have mentioned here!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT (in accordance with frarugi87's answer):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I have grounded 3 and 4 pins of the DHT22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I program ATtiny at the &lt;strong&gt;1 MHz&lt;/strong&gt;, values are sent every 2 seconds (as it should be), but when I program ATtiny at &lt;strong&gt;8 MHz&lt;/strong&gt;, values are sent every 16 seconds (is it correct?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the suggested code to check the radio library and it seems it works pretty well (values are being incremented and sent):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/m8oH8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m8oH8.png&quot; alt=&quot;Test radio library&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I used the suggested library (&lt;a href=&quot;https://github.com/RobTillaart/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;RobTillaart/Arduino&lt;/a&gt; v. 0.1.21) and at first time it returned some strange values (humidity and the status were 0 and temperature was MAX_INT value), but when I have tried to get only status value as string, the library also has returned -2 (DHTLIB_ERROR_TIMEOUT). This time I program ATTiny at 8 MHz:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XnmDS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XnmDS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I tried to get values without NRF24L01+ through I2C connection between the ATtiny85 and the Raspberry Pi. Result was the same (DHTLIB_ERROR_TIMEOUT):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RcpKr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RcpKr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the problem is in timings of ATtiny85 or in the program process?&#xA;I used these links (&lt;a href=&quot;http://spellfoundry.com/sleepy-pi/setting-arduino-ide-raspbian/&quot; rel=&quot;nofollow noreferrer&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;https://www.raspberrypi.org/forums/viewtopic.php?f=42&amp;amp;t=76639&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;https://projects.drogon.net/raspberry-pi/gertboard/arduino-ide-installation-isp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;) to set up Arduino IDE on Raspbian.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is list of useful links for this project which I found to implement it (I hope the authors will not mind that I posted their links here)&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino/AVR DHT projects and libraries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Wireless-Weather-Station/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Wireless Weather Station&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Mini-weather-station-with-Attiny85/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mini weather station with Attiny85&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Esay-IoT-Weather-Station-With-Multiple-Sensors/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Easy IoT weather station with multiple sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nathanchantrell/TinyTX&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATtiny84 &amp;amp; RFM12B wireless sensor node&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.uugear.com/portfolio/dht11-humidity-temperature-sensor-module/&quot; rel=&quot;nofollow noreferrer&quot;&gt;DHT11 HUMIDITY &amp;amp; TEMPERATURE SENSOR MODULE&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=269216.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;DHT22 running @ 8MHZ&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=97915.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;DHT22 not working with 8mhz clockspeed?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=124457&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit DHT Library and ATtiny85&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/DHTLib&quot; rel=&quot;nofollow noreferrer&quot;&gt;Class for DHTxx sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/markruys/arduino-DHT&quot; rel=&quot;nofollow noreferrer&quot;&gt;An Arduino library for reading the DHT family of temperature and humidity sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://blog.ringerc.id.au/2012/01/using-rht03-aliases-rht-22.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using a RHT03 (aliases: RHT-22, DHT22, AM2302) temperature/humidity sensor from Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/amperka/dht&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino-library for DHT11/DHT22 sensors reading&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/markruys/arduino-DHT&quot; rel=&quot;nofollow noreferrer&quot;&gt;Efficient DHT library for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.pgollor.de/cms/?page_id=1013&quot; rel=&quot;nofollow noreferrer&quot;&gt;Feuchtesensor AM2302/DHT22&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/7-Segment-Digital-Thermometer-using-ATtiny-85/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;7 Segment Digital Thermometer using ATtiny 85&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/wiring&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wiring up DHT humidity sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Attiny85-RF-Transmitter-to-Arduino-Uno-Receiver-Ma/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Attiny85 RF Transmitter to Arduino Uno Receiver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nethoncho/Arduino-DHT22&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino library for the DHT22 humidity and temperature sensor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino library for DHT11DHT22, etc Temp &amp;amp; Humidity Sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/TinyDHT&quot; rel=&quot;nofollow noreferrer&quot;&gt;A simplified DHT11/DHT22/AM2302 library for use with the Trinket/Gemma&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/nathanchantrell/Arduino-DHT22&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino library for the DHT22 humidity and temperature sensor &lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ringerc/scrapcode/blob/master/arduino_avr/RHT03_DHT22_humidity_temp_sensor.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino sketch code for reading RHT03 (also known as DHT22, RHT22, and AM2302) temperature/humidity sensor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Arduino/AVR nRF24L01 projects and libraries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimized fork of nRF24L01 for Arduino and Raspberry&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/TMRh20/RF24Network&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimized Network Layer for nRF24L01(+) Radios on Arduino and Raspberry Pi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://nerdralph.blogspot.ru/2014/01/nrf24l01-control-with-3-attiny85-pins.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;nrf24l01+ control with 3 ATtiny85 pins&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://hallard.me/nrf24l01-real-life-range-test/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NRF24L01 real life range test&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/edoardoo/RF24&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimized fork of nRF24L01 for Arduino and Raspberry Pi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.itead.cc/blog/nrf24l01-six-channels-to-one-receiver&quot; rel=&quot;nofollow noreferrer&quot;&gt;NRF24L01 SIX CHANNELS TO ONE RECEIVER&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/stanleyseow/attiny-nRF24L01&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino attiny support files for nRF24L01 RF modules&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ARDUINO + RASPBERRY PI Switching light with NRF24l01+&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Programming the ATtiny85 from Raspberry-Pi:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Programming-the-ATtiny85-from-Raspberry-Pi/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programming the ATtiny85 from Raspberry Pi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://projects.drogon.net/raspberry-pi/gertboard/arduino-ide-installation-isp/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino IDE Installation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoOnOtherAtmelChips&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino for other Chips&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tiny AVR Programmer Hookup Guide&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.raspberrypi.org/forums/viewtopic.php?f=42&amp;amp;t=76639&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATtiny85 with Arduino IDE and Gertboard&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://spellfoundry.com/sleepy-pi/setting-arduino-ide-raspbian/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Setting up the Arduino IDE on Raspbian&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Arduino/AVR FR433 libraries:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ninjablocks/433Utils&quot; rel=&quot;nofollow noreferrer&quot;&gt;433Kit is a collection of code and documentation designed to assist you in the connection and usage of RF 433MHz transmit and receive modules to/with your Arduino and Rapberry Pi&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tiny AVR Programmer Hookup Guide&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Troubleshooting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://community.particle.io/t/wrong-reading-value-for-dh22-get-stuck-after-running-for-a-while/11271&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wrong reading value for DH22 &amp;amp; get stuck after running for a while&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=91569.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;DHT22 Sensor - sync timeout&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14918" LastEditorUserId="14918" LastEditDate="2016-07-31T08:41:07.420" LastActivityDate="2016-08-01T09:37:39.717" Title="Using ATtiny85, NRF24L01+, DHT2: can't get data from DHT22" Tags="|attiny|nrf24l01+|temperature-sensor|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="18164" PostTypeId="2" ParentId="18051" CreationDate="2015-11-26T21:38:37.097" Score="-1" Body="&lt;p&gt;You can use the old software serial library from mikal heart. that one does not die interupts. You can do a google search on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is a forum topic about it:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=82596.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=82596.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15022" LastEditorUserId="15022" LastEditDate="2015-11-29T14:03:45.960" LastActivityDate="2015-11-29T14:03:45.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18165" PostTypeId="1" CreationDate="2015-11-26T21:31:12.287" Score="1" ViewCount="146" Body="&lt;p&gt;I'm new to the Arduino world so please bear with me. I'm not sure whether the ATmega328 bootloader needs to be burned. What I'm reading is all that needs to be done is plug the board into the computer by USB cable. Then burning the 328 is also mentioned. I appreciate any help.&lt;/p&gt;&#xA;" OwnerUserId="15103" OwnerDisplayName="Tom Evans" LastEditorUserId="3917" LastEditDate="2015-11-27T23:11:03.530" LastActivityDate="2015-11-27T23:11:03.530" Title="Does ATmega328 on Uno need to be burned?" Tags="|bootloader|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18166" PostTypeId="2" ParentId="18165" CreationDate="2015-11-26T21:33:21.903" Score="1" Body="&lt;p&gt;If you bought an Arduino Uno the bootloader comes pre-programmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;The ATmega328 on the Uno comes preprogrammed with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files).&quot; - from the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;oficial page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Might want to take a look at &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=153154.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; discussion if you're confused.&lt;/p&gt;&#xA;" OwnerUserId="7734" OwnerDisplayName="Wesley Lee" LastActivityDate="2015-11-26T21:33:21.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18167" PostTypeId="2" ParentId="18165" CreationDate="2015-11-26T22:08:29.450" Score="1" Body="&lt;p&gt;You only ever need to burn a bootloader if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You are building your own &quot;breadboard&quot; Arduino&lt;/li&gt;&#xA;&lt;li&gt;You have somehow erased the bootloader that is on your Arduino&lt;/li&gt;&#xA;&lt;li&gt;You have replaced the original chip on the Arduino&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The chip that came already inserted into the Arduino board already has the bootloader installed into it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-26T22:08:29.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18168" PostTypeId="2" ParentId="18165" CreationDate="2015-11-26T22:44:21.603" Score="1" Body="&lt;p&gt;It depends. If you bought the arduino from most places, it will be already be burned. However, some less reputable sources might not burn it. If the LED on pin 13 blinks when you power on the arduino, that means the bootloader is installed.&lt;/p&gt;&#xA;" OwnerUserId="15137" LastActivityDate="2015-11-26T22:44:21.603" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18169" PostTypeId="1" AcceptedAnswerId="18460" CreationDate="2015-11-26T22:59:31.483" Score="0" ViewCount="244" Body="&lt;p&gt;&lt;a href=&quot;http://download.intel.com/support/edison/sb/edisonarduino_hg_331191008.pdf&quot; rel=&quot;nofollow&quot;&gt;Intel Edison Kit for Arduino Hardware Guide&lt;/a&gt; instructs: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 28 &amp;gt; /sys/class/gpio/export&#xA;echo 27 &amp;gt; /sys/class/gpio/export&#xA;echo 204 &amp;gt; /sys/class/gpio/export&#xA;echo 205 &amp;gt; /sys/class/gpio/export&#xA;echo 236 &amp;gt; /sys/class/gpio/export&#xA;echo 237 &amp;gt; /sys/class/gpio/export&#xA;echo 14 &amp;gt; /sys/class/gpio/export&#xA;echo 165 &amp;gt; /sys/class/gpio/export&#xA;echo 212 &amp;gt; /sys/class/gpio/export&#xA;echo 213 &amp;gt; /sys/class/gpio/export&#xA;echo 214 &amp;gt; /sys/class/gpio/export&#xA;echo low &amp;gt; /sys/class/gpio/gpio214/direction&#xA;echo high &amp;gt; /sys/class/gpio/gpio204/direction&#xA;echo high &amp;gt; /sys/class/gpio/gpio205/direction&#xA;echo in &amp;gt; /sys/class/gpio/gpio14/direction&#xA;echo in &amp;gt; /sys/class/gpio/gpio165/direction&#xA;echo low &amp;gt; /sys/class/gpio/gpio236/direction&#xA;echo low &amp;gt; /sys/class/gpio/gpio237/direction&#xA;echo in &amp;gt; /sys/class/gpio/gpio212/direction&#xA;echo in &amp;gt; /sys/class/gpio/gpio213/direction&#xA;echo mode1 &amp;gt; /sys/kernel/debug/gpio_debug/gpio28/current_pinmux&#xA;echo mode1 &amp;gt; /sys/kernel/debug/gpio_debug/gpio27/current_pinmux&#xA;echo high &amp;gt; /sys/class/gpio/gpio214/direction&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However line 3 already gives an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo: write error: No such device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on how to enable I2C?&lt;/p&gt;&#xA;" OwnerUserId="15138" LastActivityDate="2016-02-03T11:57:29.510" Title="Configuring IO18, IO19 for I2C connectivity on Intel Edison Kit for Arduino" Tags="|i2c|edison|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18170" PostTypeId="2" ParentId="18133" CreationDate="2015-11-27T00:21:42.813" Score="0" Body="&lt;p&gt;One thing that I would add to this is that if you need good accuracy you may want to apply a voltage equal to your full scale output to the AREF pin. The value on AREF does not have to be equal to the full range of the sensor – just to the maximum value you will get – if you will never see readings at the extremes of the sensor's range you can set your AREF below the maximum value and get higher resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tronixstuff has a good &lt;a href=&quot;http://tronixstuff.com/2013/07/02/tutorial-arduino-and-the-ti-ads1110-16-bit-adc/&quot; rel=&quot;nofollow&quot;&gt;tutorial on the AREF pin&lt;/a&gt; that goes into considerable detail about how to configure the pin and use the &lt;code&gt;analogReference()&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-27T00:21:42.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18171" PostTypeId="1" CreationDate="2015-11-27T01:08:39.923" Score="2" ViewCount="713" Body="&lt;p&gt;I need to pass &lt;code&gt;std::vector &amp;lt;double&amp;gt;&lt;/code&gt; values from a C++ console program (written in Visual Studio 2015) running on a PC to Arduino in real-time using USB serial communication. Can anyone of you give any advice on how to implement Firmata or something similar into a C++ console application?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I googled everywhere and could not find a decent example for C++. Almost everything can be computed in console app, Arduino needs to work only with LCD display and beside that it can have StandardFirmata uploaded.&lt;/p&gt;&#xA;" OwnerUserId="15140" LastEditorUserId="4628" LastEditDate="2015-11-28T20:33:20.843" LastActivityDate="2015-11-28T20:33:20.843" Title="Arduino Uno - Firmata/Serial Communication in Visual Studio C++" Tags="|arduino-uno|serial|c++|communication|visualstudio|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18172" PostTypeId="1" CreationDate="2015-11-27T01:42:48.817" Score="1" ViewCount="5956" Body="&lt;p&gt;I'm a newbee to Arduino programming and hoping someone can help me with this. These are the error messages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: stk500_rcv() : programmer is not responding&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude: stk500_getsync() attempt 10 of 10:not in sync:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem uploading to board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a Arduino UNO clone on com port 3,the blink sketch is functioning. I get the mentioned error message on all sketches I have ran. Not sure what to do.&lt;/p&gt;&#xA;" OwnerUserId="15103" LastActivityDate="2020-10-16T04:01:23.850" Title="avrdude: stk500_rcv :programmer is not responding" Tags="|avrdude|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18173" PostTypeId="2" ParentId="18137" CreationDate="2015-11-27T02:52:00.303" Score="2" Body="&lt;p&gt;The problem is, that &quot;char&quot; is just one character. So you have to build your return out of the chars... if you want to use the &quot;client.read()&quot; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String res = &quot;&quot;; //this will be the resived msg after the loop&#xA;do {&#xA;   char c = client.read(); //c will be -1 if no byte is left&#xA;   if(c!=-1) &#xA;       strcat(res, String(c)); //Append the char to the result string&#xA;} while(c!=-1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;//Code is not tested!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To your java problem... just put your code parts into try catchs not whole functions (remove it for the function and add it on the points eclipse tell you to). So you can react to each error individually. Then put client stuff in a own thread so it not blocks any other stuff. Every disconnect or faild connection will throw an exception if you dont catch it with an if. So you have to handel it their (try to reconnect or something)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static void close() {&#xA;    try {&#xA;        client.close();&#xA;    } catch (IOException e) {&#xA;        system.out.println(e.toString()); //Print the error or do something else&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14501" LastEditorUserId="14501" LastEditDate="2015-11-27T18:09:12.657" LastActivityDate="2015-11-27T18:09:12.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18174" PostTypeId="1" CreationDate="2015-11-27T03:30:33.130" Score="1" ViewCount="3623" Body="&lt;p&gt;I am working on an Arduino project for school to power a 12V DC cooling fan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to adjust the speed of the fan. The instructions say to set the motor pin at an equation of &lt;code&gt;(0 to 9) * 10 + 150&lt;/code&gt; to get a range of 150 to 240.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to write a mathematical equation but can not figure out what 150 to 240 means.  Is this voltage, resistance...?  Thanks for the help.&lt;/p&gt;&#xA;" OwnerUserId="15144" LastEditorUserId="8033" LastEditDate="2015-12-25T19:16:55.393" LastActivityDate="2015-12-25T19:16:55.393" Title="Simple Speed question - Mapping PWM values" Tags="|power|pwm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18175" PostTypeId="2" ParentId="18174" CreationDate="2015-11-27T03:58:51.920" Score="3" Body="&lt;p&gt;They're the value to pass to &lt;code&gt;analogWrite()&lt;/code&gt; in order to generate a PWM waveform with an appropriate duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But don't bother writing your own algorithm, just use &lt;a href=&quot;https://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-11-27T03:58:51.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18176" PostTypeId="1" CreationDate="2015-11-27T07:52:10.283" Score="2" ViewCount="8553" Body="&lt;p&gt;Hello guys ,&#xA;             I want to perform a mesh network between 3-4 modules using ESP8266 . Any one have idea how to do it?&lt;/p&gt;&#xA;" OwnerUserId="13400" LastActivityDate="2021-03-07T10:30:36.557" Title="Peer to peer communication" Tags="|arduino-uno|c|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18177" PostTypeId="2" ParentId="18176" CreationDate="2015-11-27T09:12:50.843" Score="4" Body="&lt;p&gt;You can't, that's not how the esp8266 works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The esp8266 is WiFi, so you will either need an access point or nominate one esp8266 module to act as an access point running in softap mode.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-27T09:12:50.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18178" PostTypeId="1" AcceptedAnswerId="18179" CreationDate="2015-11-27T10:35:29.973" Score="1" ViewCount="3601" Body="&lt;p&gt;I am currently trying to generate a 38 KHz signal for my TSOP4838 (&lt;a href=&quot;http://www.vishay.com/docs/82459/tsop48.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.vishay.com/docs/82459/tsop48.pdf&lt;/a&gt;) with an ATtiny84A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the real thing would be to utilize a timer but the ATtiny only has 2 Timers (T0 and T1). Timer1 can not be used because it is already used by other features.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to transmit actual data to the TSOP4838. I only want to use it as a light barrier (Iknow there are better ICs for that but I am stuck with the ones I already have).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I have tried so far is setting up timer0 for my PWM stuff and everything worked IR LED-wise. The delay functions (&lt;code&gt;micros()&lt;/code&gt;, &lt;code&gt;millis()&lt;/code&gt; etc.) stopped working and prevented me from using my serial communication. I tried to change the code in &lt;code&gt;wiring.c&lt;/code&gt; to use a prescaler of 1 instead of 64 by changing the defines but that didn't work out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now stuck with two options I guess:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A: somehow modify timer0 to generate my 38 KHz signal and still provide correct functionality for the timing functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;B: let timer0 be initialized the way the Arduino wants it and utilize the delay functions to blink the IR LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would prefer A but Google didn't give me a solution. Maybe some of the gurus around here could help?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If A is not possible can somebody give me a hint how to &quot;bit bang&quot; the IR LED with delay? (I guess that is a silly question but I can't figure it out at the moment :()&lt;/p&gt;&#xA;" OwnerUserId="15147" LastEditorUserId="3917" LastEditDate="2015-11-27T23:12:31.583" LastActivityDate="2019-01-13T10:04:32.053" Title="Generating a 38 KHz signal without timers" Tags="|pwm|timers|attiny|ir|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18179" PostTypeId="2" ParentId="18178" CreationDate="2015-11-27T11:06:39.393" Score="1" Body="&lt;p&gt;A 38kHz square wave at 50% duty cycle would be a transition running at 38x2=76kHz.  That is 1/76,000 = 0.000013158s, or 13.158µs.  That's quite a high accuracy to try and achieve with delays on a small chip like the 84A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume you are running it at 8Mhz (internal calibrated RC oscillator) - that means each clock tick is 1/8000000=125ns long. so 13156ns would equate to 105.248 clock cycles. That can't happen, so the closest you would get is 105 clock cycles, which would be 13125ns, or 76.190kHz, or an end frequency of 38.095kHz.  So fairly close.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you need to create a tight loop that is &lt;em&gt;exactly&lt;/em&gt; 105 clock cycles long &lt;em&gt;including&lt;/em&gt; the toggling of the IO pin &lt;em&gt;and&lt;/em&gt; the comparisons and branches for the loop.  For that you need to do some careful instruction cycle counting and work in assembly language.  Page 268 of &lt;a href=&quot;http://www.atmel.com/images/doc8183.pdf&quot; rel=&quot;nofollow&quot;&gt;the data sheet&lt;/a&gt; details the clock cycles used for each instruction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest (though most long winded) loop would be an OUT or SBR (depending on port) instruction (1 clock) to set the IO pin HIGH, then 104 NOPs (1 clock each), then an OUT or CBR to set it LOW (1 clock), then 102 NOPs (1 clock each), then an RJMP to go back to the start (2 clocks).  That is then a grand total of 210 clock cycles, or 1/(210*0.000000125) = 38.095kHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could compress all the NOP instructions down into a tight loop themselves by setting a register to a pre-defined loop count value, decrement it each pass - repeat if it's not 0. That means even more careful instruction counting to get that loop to equal the 104 or 102 clock cycles needed for the precise timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt; all that is pretty much academic, because the loop will keep being interrupted by your timer 0 interrupt and cause &lt;em&gt;jitter&lt;/em&gt; in your output as the interrupt routine is being run instead of your IO pin driving loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't need absolutely reliable timing anyway it might be easier (though far less accurate) to use the &lt;code&gt;micros()&lt;/code&gt; function to find when 13µs have elapsed and do it all in C instead of assembly.  You will still need high speed direct port access rather than using &lt;code&gt;digitalWrite()&lt;/code&gt; since &lt;code&gt;digitalWrite()&lt;/code&gt; adds way too much overhead to be able to do that kind of timing reliably.  Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t start = micros();&#xA;while(1) {&#xA;    if (micros() - start &amp;gt;= 13) {&#xA;        start = micros();&#xA;        PORTB ^= 1&amp;lt;&amp;lt;4; // toggle B4&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the use of &lt;code&gt;while (1)&lt;/code&gt; there rather than relying on the &lt;code&gt;loop()&lt;/code&gt; function repeating itself.  There is quite a large overhead in using the auto-repeating of &lt;code&gt;loop()&lt;/code&gt; that can be avoided by looping within it with a &lt;code&gt;while (1)&lt;/code&gt; like that.  Of course, anything else you want to happen repeatedly would have to be inside that &lt;code&gt;while&lt;/code&gt; loop, and most likely would impact your output timing somewhat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a much better solution would be to use a timer, since that is what they are there for.  But fidding with timers breaks things like &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;.  So the answer to that is &lt;em&gt;don't use &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;&lt;/em&gt;.  Instead create your own timing functions that are controlled by your own interrupt that does the pin IO - instead of relying on a system provided tick you create your own.  If your interrupt is firing every 13µs then add 13 to a global counter - that counter is then the number of microseconds that have passed.  When that count exceeds 1000 you subtract 1000 (&lt;em&gt;don't&lt;/em&gt; zero it) and add 1 to a millisecond counter.  Now you have the equivalent to &lt;code&gt;millis()&lt;/code&gt; in a global (&lt;em&gt;remember to make it volatile&lt;/em&gt;) variable that you can use instead of &lt;code&gt;millis()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-27T11:06:39.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18180" PostTypeId="2" ParentId="18103" CreationDate="2015-11-27T12:10:32.307" Score="0" Body="&lt;p&gt;I used Programmer &quot;AVRUPro+&quot; for Uploading Program. I downloaded its Software &quot;Progisp&quot; Then I did some few steps....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) After downloading it, Run the Progisp.exe file.&lt;br&gt;&#xA;2) Then went to Command tab, and clicked “Program Fuse”, It just did my fuse  set.&lt;br&gt;&#xA;3)Then I just did the simple process of burning the bootloader to my Atmega Controller.&lt;br&gt;&#xA;4)After this I was able to upload my program to my new Atmega Controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="14658" LastActivityDate="2015-11-27T12:10:32.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18181" PostTypeId="2" ParentId="18178" CreationDate="2015-11-27T13:34:20.943" Score="1" Body="&lt;p&gt;It would be much easier to use a dedicated IC such as a 555 or a 556. I built such a system based on these circuits &lt;a href=&quot;http://www.pcbheaven.com/circuitpages/Long_Range_IR_Beam_Break_Detector/&quot; rel=&quot;nofollow&quot;&gt;IR Bream Break Detector&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-11-27T13:34:20.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18182" PostTypeId="2" ParentId="18174" CreationDate="2015-11-27T14:28:40.500" Score="5" Body="&lt;p&gt;The &lt;code&gt;analogWrite()&lt;/code&gt; function takes a value that is between 0 (fully off) and 255 (fully on).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your value of 150 to 240 is a value within that range of 0 to 255 and represents a percentage of the &quot;on time&quot; of the PWM signal.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;(150 / 255) * 100 = 58.8% on time&lt;/li&gt;&#xA;&lt;li&gt;(240 / 255) * 100 = 94.1% on time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You seem to have an &quot;input value&quot; of between 0 and 9 inclusive.  Let's call this value &quot;&lt;em&gt;i&lt;/em&gt;&quot;.  You want an output value, let's call it &quot;&lt;em&gt;o&lt;/em&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The instructions say &quot;0 to 9 times 10 plus 150 to get a range of 150 to 240&quot;. That is simple enough to convert to a formula.  0-9 is &lt;em&gt;i&lt;/em&gt;, remember:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;o = i × 10 + 150&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If &lt;em&gt;i&lt;/em&gt; is 0 then &lt;em&gt;o&lt;/em&gt; = &lt;em&gt;0 × 10 + 150&lt;/em&gt; = &lt;em&gt;0 + 150&lt;/em&gt; = &lt;em&gt;150&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;em&gt;i&lt;/em&gt; is 9 then &lt;em&gt;o&lt;/em&gt; = &lt;em&gt;9 × 10 + 150&lt;/em&gt; = &lt;em&gt;90 + 150&lt;/em&gt; = &lt;em&gt;240&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Ignacio mentions, the Arduino API has a &lt;code&gt;map&lt;/code&gt; function which is meant to be used for this kind of thing;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;o = map(i, 0, 9, 150, 240);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;However:&lt;/em&gt; the &lt;code&gt;map()&lt;/code&gt; function is quite heavyweight since it is designed to be a generic mapping function for scaling values. Doi g the calculation manually will always be far more efficient since map will use steps and calculations that are not really part of your needed result. It's a bit like the differende between 1 + 2 and 1+ 5 - 3 + 2 - 4 + 2. The result is the same, but one is far simpler to calculate than the other.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-24T09:27:01.100" LastActivityDate="2015-12-24T09:27:01.100" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18183" PostTypeId="1" AcceptedAnswerId="18221" CreationDate="2015-11-27T15:15:32.897" Score="5" ViewCount="7637" Body="&lt;p&gt;I am designing my own quadcopter control algorithm, whereby I currently read 4 RC receiver channels using PulseIn on each loop in the following manner:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ch1_raw = pulseIn(rcPin1, HIGH, 25000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, ch1_raw contains the length of a HIGH pulse in microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now want to avoid PulseIn in the interest of speed and instead achieve the same using interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeIntExample&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Main/PinChangeIntExample&lt;/a&gt; and I am aware that other similar questions have been asked (e.g. &lt;a href=&quot;https://arduino.stackexchange.com/questions/16740/how-to-read-rc-receiver-channels-without-using-pulsein-command-with-arduino&quot;&gt;How to read RC receiver channels without using pulsein() command with arduino&lt;/a&gt; and &lt;a href=&quot;https://arduino.stackexchange.com/questions/9465/is-pulsein-fast-enough-for-quadcopter?newreg=1d1811fae8244f409488e6c4dba0d915&quot;&gt;Is PulseIn fast enough for Quadcopter?&lt;/a&gt;), but I don't understand how to implement interrupt to give me the correct ch1_raw value on each loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can somebody help me? (I'm new to Arduino, so go easy on me please!) Thanks!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;So far I have tried to implement the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PinChangeInt.h&amp;gt;&#xA;&#xA;unsigned long pulsestart, pulsewidth;&#xA;&#xA;int rcPin1 = A0;&#xA;&#xA;void setup(){&#xA;&#xA;  pinMode(rcPin1, INPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  PCintPort::attachInterrupt(rcPin1, counttime,RISING); &#xA;  PCintPort::attachInterrupt(rcPin1, subtracttime,FALLING);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;&#xA;  Serial.print(&quot;  pulsewidth: &quot;);&#xA;  Serial.println(pulsewidth);&#xA;&#xA;}&#xA;&#xA;&#xA;void counttime()&#xA;{&#xA;  pulsestart = micros();&#xA;}&#xA;&#xA;void subtracttime()&#xA;{&#xA;  pulsewidth = micros()- pulsestart;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit 2: &#xA;(Somewhat) successful implementation so far, using EnableInterrupt.h instead. It seems that FALLING is being detected, but not RISING.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EnableInterrupt.h&amp;gt;&#xA;&#xA;#define rcPin1 10&#xA;&#xA;volatile uint16_t pulsestart=0; &#xA;volatile uint16_t pulsewidth=0;&#xA;//volatile unsigned long pulsestart=0; &#xA;//volatile unsigned long pulsewidth=0;&#xA;volatile uint16_t risingcount=0;&#xA;volatile uint16_t fallingcount=0;&#xA;&#xA;void counttime()&#xA;{&#xA;  pulsestart = micros();&#xA;  risingcount++;&#xA;}&#xA;void subtracttime()&#xA;{&#xA;  pulsewidth = micros()- pulsestart;&#xA;  fallingcount++;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(rcPin1, INPUT_PULLUP);  &#xA;  enableInterrupt(rcPin1, counttime, RISING);&#xA;  enableInterrupt(rcPin1, subtracttime, FALLING);&#xA;}&#xA;&#xA;void loop() {&#xA;  //delay(1000);&#xA;  Serial.print(&quot;risingcount: &quot;);&#xA;  Serial.print(risingcount);  &#xA;  Serial.print(&quot; fallingcount: &quot;);&#xA;  Serial.println(fallingcount); &#xA;  //Serial.print(&quot;pulsewidth: &quot;);&#xA;  //Serial.println(pulsewidth);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15153" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-07-06T16:03:21.623" Title="Read RC receiver channels using Interrupt instead of PulseIn" Tags="|arduino-uno|interrupt|pulsein|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18184" PostTypeId="2" ParentId="18183" CreationDate="2015-11-27T15:21:48.570" Score="3" Body="&lt;p&gt;Interrupts don't obey, or even understand the concept of, the &quot;loop&quot; paradigm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An interrupt fires when it needs to fire, and if you're reading a PWM signal then that means it's firing hundreds of times a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as your interrupt is updating a variable that can be read from within the loop, and you ensure that the variable doesn't get updated during your reading of it (Google: &lt;em&gt;Critical Sections&lt;/em&gt;) then you will always have the most up to date value at your fingertips whenever you need it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the interrupt itself, that's very straight forward - you just need to recognise if it's a rising or falling edge:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If rising edge: record the timestamp (micros()).&lt;/li&gt;&#xA;&lt;li&gt;If falling edge: Subtract the recorded timestamp from the current micros() and store in the global variable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-27T15:21:48.570" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18185" PostTypeId="2" ParentId="18174" CreationDate="2015-11-27T15:40:57.980" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://labs.arduino.org/map&quot; rel=&quot;nofollow&quot;&gt;map()&lt;/a&gt; function is the answer. It &quot;rescales&quot; the range of the data, using this formula:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You input these five values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;map(value, fromLow, fromHigh, toLow, toHigh)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;value&lt;/code&gt; is the X value you want to resize&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;fromLow&lt;/code&gt; and &lt;code&gt;fromHigh&lt;/code&gt; is the range that X is currently in&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;toLow&lt;/code&gt; and &lt;code&gt;toHigh&lt;/code&gt; is the range that you want to scale X to&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15155" LastEditorUserId="220" LastEditDate="2015-12-23T17:14:59.690" LastActivityDate="2015-12-23T17:14:59.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18186" PostTypeId="2" ParentId="18178" CreationDate="2015-11-27T16:38:39.577" Score="0" Body="&lt;p&gt;Several approaches are possible, some of which, but far from all, have been listed in previous answers.  In following, I assume that by “use it as a light barrier” you mean that the TSOP4838 will be part of an object-intrusion detection system, rather than for transmitting data.  As a consequence, some jitter and/or inaccuracy is acceptable.  Note, all of the following methods assume that Arduino core code has set up timer 0 to support ordinary micros() and millis() calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 1:  Compute or calibrate a simple loop:  In &lt;code&gt;setup()&lt;/code&gt;, run a series of tests that find a value &lt;code&gt;k&lt;/code&gt; to minimize error, via C code equivalent to the following Python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for k in plausibleRange():&#xA;  err = genBurst19(k)&#xA;  if err &amp;lt; bestErr:&#xA;    bestErr = err&#xA;    bestK = k&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;genBurst19()&lt;/code&gt; is like the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;def genBurst19(k):&#xA;  t1=micros()&#xA;  for i in range(38):&#xA;    setPortBit(i&amp;amp;1)&#xA;    for j in range(k):&#xA;      nop&#xA;  t2=micros()&#xA;  return abs(t2-t1-500)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, &lt;code&gt;genBurst19()&lt;/code&gt; sends a burst of 19 cycles, which at 38 KHz should take 500 microseconds.  It returns a measure of error to the caller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After finding &lt;code&gt;bestK&lt;/code&gt;, you can subsequently use it as a limit for other delay loops, or could just use repeated calls to &lt;code&gt;genBurst19(bestK)&lt;/code&gt; whenever you want to generate some &quot;38KHz&quot;.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, you might wish to try some minor variations, such as adding a second or third &lt;code&gt;nop&lt;/code&gt; in the inner delay loop, or generating some higher multiple of 19 cycles.  While a delay loop containing a single &lt;code&gt;nop&lt;/code&gt; (or no &lt;code&gt;nop&lt;/code&gt; at all, just an empty loop) has finer resolution than a loop with multiple &lt;code&gt;nop&lt;/code&gt;s, it may happen (depending on loop code) that a smaller error occurs with more.  [But also see Approach 3 regarding fine tuning.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary:  This method is easy to use, has low jitter, but is limited in the accuracy it can attain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 2:  Use a method analogous to &lt;a href=&quot;https://en.wikipedia.org/wiki/Bresenham&amp;#39;s_line_algorithm&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bresenham's&lt;/a&gt; to produce a signal with high-accuracy period, on the average, but with more jitter than Approach 1.  Bresenham's algorithm tries to draw a straight line, on an x-y grid of pixels; you are trying to draw a straight line, on a time-vs-cycles grid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this method, you keep track of how many microseconds total should have elapsed, and when you fall too far behind, issue a delay with &lt;code&gt;k-1&lt;/code&gt; instead of &lt;code&gt;k&lt;/code&gt;, to catch up; or if too far ahead, with &lt;code&gt;k+1&lt;/code&gt;, to drop back.  See my answer to &lt;a href=&quot;https://stackoverflow.com/a/8113883&quot;&gt;stackoverflow 8113883&lt;/a&gt; for a little more re Bresenham's method, in the line drawing context.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary:  By applying Bresenham's method, you can get the average frequency as close as you like (when averaged over a few milliseconds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Approach 3:  This is more of a fillip than a whole approach.  It modifies Approach 1 by adding the following C code before the &lt;code&gt;for j in range(k): nop&lt;/code&gt; loop.  It also needs a second parameter, &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (l) {&#xA;  case 9: nop;&#xA;  case 8: nop;&#xA;  case 7: nop;&#xA;  case 6: nop;&#xA;  case 5: nop;&#xA;  case 4: nop;&#xA;  case 3: nop;&#xA;  case 2: nop;&#xA;  case 1: nop;&#xA;  case 0: ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use this approach, first find the best &lt;code&gt;k&lt;/code&gt; using a series of calls like &lt;code&gt;err = genBurst19(k,5)&lt;/code&gt;.  Then find the best &lt;code&gt;l&lt;/code&gt; via &lt;code&gt;err = genBurst19(bestK,l)&lt;/code&gt; for &lt;code&gt;l&lt;/code&gt; from 0 to 9.  [Note, a number smaller than 9 can be used in the above, if the &lt;code&gt;for j in range(k): nop&lt;/code&gt; loop uses fewer cycles.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary: This fillip can tune &lt;code&gt;genBurst19()&lt;/code&gt; closer to single-nop accuracy.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-11-27T16:38:39.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18187" PostTypeId="2" ParentId="18015" CreationDate="2015-11-27T16:48:04.793" Score="2" Body="&lt;p&gt;I'm incredibly new to Arduino (I literally got one a few hours ago and I'm still finding my feet with it!) so take that into account when considering anything I say however I'd be inclined to agree that this may be an issue with the 1.6.6 IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was getting pretty much the same symptoms on a Freematics MEGA2560/3.2&quot; SSD1289 LCD using the MultiLCD library using 1.6.6. Based on your comment above I uninstalled and installed 1.6.5 instead, recompiled and uploaded and it's now displaying properly...&lt;/p&gt;&#xA;" OwnerUserId="15157" LastActivityDate="2015-11-27T16:48:04.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18188" PostTypeId="1" AcceptedAnswerId="18207" CreationDate="2015-11-27T17:28:46.267" Score="1" ViewCount="701" Body="&lt;p&gt;I have an arduino pro mini and I have attached a 16x2 character LCD and an LM35 analog temperature sensor. When I upload a sketch using only the sensor and send the readings to serial monitor, the readings are OK. When I upload a sketch that displays the readings to the LCD the readings are about 130°C in room temperature. Where is the problem and how can I solve it. Thanks in advance &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code with lcd:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;byte smiley[8] = {&#xA;  B00000,&#xA;  B01110,&#xA;  B01010,&#xA;  B01110,&#xA;  B00000,&#xA;  B00000,&#xA;  B00000,&#xA;};&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  // set up the LCD's number of columns and rows: &#xA;  lcd.createChar(0, smiley);&#xA;  lcd.begin(16, 2);&#xA;  analogReference(INTERNAL);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(analogRead(0)/1024.0 * 500);&#xA;  lcd.write(byte(0));&#xA;  lcd.print(&quot;C&quot;);&#xA;  lcd.setCursor(0, 2);&#xA;  lcd.print(&quot;21&quot;);&#xA;  lcd.write(byte(0));&#xA;  lcd.print(&quot;C&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // Turn off the cursor:&#xA;  lcd.print((analogRead(0)/1024.0)*500);&#xA;  lcd.write(byte(0));&#xA;  lcd.print(&quot;C&quot;);&#xA;  lcd.setCursor(0, 2);&#xA;  delay(5000);&#xA;  lcd.clear();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only sensor code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  Serial.println(analogRead(0)/1024.0*500);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8275" LastEditorUserId="8275" LastEditDate="2015-11-28T14:44:45.523" LastActivityDate="2015-11-28T15:21:18.500" Title="LM35 and Character LCD" Tags="|lcd|arduino-pro-mini|temperature-sensor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18189" PostTypeId="1" AcceptedAnswerId="18190" CreationDate="2015-11-27T17:43:49.303" Score="0" ViewCount="368" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h1&gt;UPDATE: IT seems that there is a problem using pin 11 and 13 together but if I use a different pwm pin like pin 5. It's okay. I'm guessing that the timers used at pin 11 is connected to tone() but not sure...&lt;/h1&gt;&#xA;&lt;p&gt;I’ve encountered a weird problem with an Arduino with this simple task. It involves just a buzzer and LED and a very simple custom library that I made.&lt;/p&gt;&#xA;&lt;p&gt;I wanted the buzzer to sweep back and forth with a specified frequency range (f1, f2), the led will also display a specific brightness (0, 50) based on the frequency being played.&lt;/p&gt;&#xA;&lt;p&gt;The buzzer works perfectly on its own, and also the LED, but when you put them together, it malfunctions.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;A more detailed explanation can be found here: &lt;a href=&quot;https://tilarduino.wordpress.com/2015/11/27/weird-arduino-problem-buzzer-led-brightness/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://tilarduino.wordpress.com/2015/11/27/weird-arduino-problem-buzzer-led-brightness/&lt;/a&gt;&#xA;And i've included all the files i've used here: &lt;a href=&quot;https://gist.github.com/mithi/09ae419a3c7eba285221&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://gist.github.com/mithi/09ae419a3c7eba285221&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Using this code below, commenting out line 19 with line 18 uncommented-out will make the buzzer work, and commenting out line 19 with line 18 back in will make the led work as expected. But together, the code malfunctions. buzzer is attached to pin 13 and led is attached to pin 11.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;SimplestLibrary.h&amp;quot;&#xA;&#xA;Sweeper sweeper; &#xA;Buzzer buzzer; &#xA;AnalogLED led;&#xA;&#xA;int f1 = 3000;&#xA;int f2 = 4500;&#xA;int f = 0;&#xA;&#xA;void setup() {&#xA;    sweeper.New(f1, f2, BACKANDFORTH); &#xA;    buzzer.New(13);&#xA;    led.New(11);&#xA;}&#xA;&#xA;void loop() {&#xA;    f = sweeper.Update(1); &#xA;    buzzer.Play(f, 4, 2);&#xA;    led.NewBrightness(map(f, f1, f2, 0, 50));&#xA;    delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15158" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-14T15:20:44.347" Title="Arduino Simple Task - sweeping a buzzer and led, not working as expected" Tags="|arduino-uno|c++|led|arduino-ide|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18190" PostTypeId="2" ParentId="18189" CreationDate="2015-11-27T18:48:44.090" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;Arduino.cc&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simple solution is to use a PWM that isn't an output from &lt;code&gt;Timer2&lt;/code&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Timer      OCxA pin    OCxB pin&#xA;  0           6        5&#xA;  1           9        10&#xA;  2           11       3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-11-27T18:48:44.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18191" PostTypeId="1" CreationDate="2015-11-27T19:03:07.917" Score="2" ViewCount="286" Body="&lt;p&gt;I'm using two SIM908 shields to communicate with each other. One of the shields will be connected to a sensor and it should send values contentiously to the second SIM908 (receiver). I'm facing a problem on the receiver side, I'm only able to receive the first SMS and when sending a new SMS it displays the older one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that I'm using is from (cooking-hacks.com) where I bought the shield. In the original code the instructions were in void setup function so I  moved them to void loop function to keep checking for new SMS and print any received values. I also made other minor changes. Here is the code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int8_t answer;&#xA;int x;&#xA;int onModulePin= 2;&#xA;char aux_string[30];&#xA;char SMS[200];&#xA;float fSMS;&#xA;char data[20];&#xA;&#xA;void setup() {&#xA;  pinMode(onModulePin, OUTPUT);&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting...&quot;);&#xA;  power_on();&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Setting SMS mode...&quot;);&#xA;  sendATcommand(&quot;AT+CMGF=1&quot;, &quot;OK&quot;, 1000);&#xA;  // sets the SMS mode to text&#xA;  sendATcommand(&quot;AT+CPMS=\&quot;SM\&quot;,\&quot;SM\&quot;,\&quot;SM\&quot;&quot;, &quot;OK&quot;, 1000);&#xA;  // selects the memory&#xA;  answer = sendATcommand(&quot;AT+CMGR=1&quot;, &quot;+CMGR:&quot;, 2000);&#xA;  // reads the first SMS (since all other messages are deleted from previous delete statement)&#xA;  if (answer == 1) {&#xA;    answer = 0;&#xA;    while(Serial.available() == 0);&#xA;    // this loop reads the data of the SMS&#xA;    do {&#xA;      // if there are data in the UART input buffer, reads it and checks for the answer&#xA;      if(Serial.available() &amp;gt; 0) {&#xA;        SMS[x] = Serial.read();&#xA;        x++;&#xA;        // check if the desired answer (OK) is in the response of the module&#xA;        if (strstr(SMS, &quot;OK&quot;) != NULL) {&#xA;          answer = 1;&#xA;        }&#xA;      }&#xA;    }while(answer == 0);&#xA;    // Waits for the answer with timeout&#xA;    SMS[x] = '\0';&#xA;    /*  strtok(SMS, &quot;,&quot;);&#xA;    strtok(NULL, &quot;,&quot;);&#xA;    strtok(NULL, &quot;,&quot;);&#xA;    strtok(NULL, &quot;\n&quot;);&#xA;    strcpy(data,strtok(NULL, &quot;&quot;));*/&#xA;    Serial.println(SMS);&#xA;    //Serial.println(data);&#xA;    /*    fSMS= atof (data);&#xA;    Serial.println(fSMS, 5);*/&#xA;  } else {&#xA;    Serial.print(&quot;error &quot;);&#xA;    Serial.println(answer, DEC);&#xA;  }&#xA;  Serial.println(&quot;AT+CMGDA= \&quot;DEL ALL\&quot;&quot;);&#xA;  //delete all messages from SIM card&#xA;  delay(5000);&#xA;}&#xA;&#xA;void power_on() {&#xA;  uint8_t answer=0;&#xA;  // checks if the module is started&#xA;  answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);&#xA;  if (answer == 0) {&#xA;    // power on pulse&#xA;    digitalWrite(onModulePin,HIGH);&#xA;    delay(3000);&#xA;    digitalWrite(onModulePin,LOW);&#xA;    // waits for an answer from the module&#xA;    while(answer == 0){&#xA;      // Send AT every two seconds and wait for the answer&#xA;      answer = sendATcommand(&quot;AT&quot;, &quot;OK&quot;, 2000);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {&#xA;  uint8_t x=0,  answer=0;&#xA;  char response[100];&#xA;  unsigned long previous;&#xA;  memset(response, '\0', 100);&#xA;  // Initialice the string&#xA;  delay(100);&#xA;  while( Serial.available() &amp;gt; 0) Serial.read();&#xA;  // Clean the input buffer&#xA;  Serial.println(ATcommand);&#xA;  // Send the AT command&#xA;  x = 0;&#xA;  previous = millis();&#xA;  // this loop waits for the answer&#xA;  do {&#xA;    // if there are data in the UART input buffer, reads it and checks for the answer&#xA;    if(Serial.available() != 0) {&#xA;      response[x] = Serial.read();&#xA;      x++;&#xA;      // check if the desired answer is in the response of the module&#xA;      if (strstr(response, expected_answer) != NULL) {&#xA;        answer = 1;&#xA;      }&#xA;    }&#xA;    // Waits for the asnwer with time out&#xA;  } while((answer == 0) &amp;amp;&amp;amp; ((millis() - previous) &amp;lt; timeout));&#xA;  return answer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14345" LastEditorUserId="4131" LastEditDate="2015-11-27T20:26:42.727" LastActivityDate="2017-02-14T00:43:01.047" Title="Unable to read any SMS's other than the first SMS using SIM908 shield" Tags="|arduino-uno|shields|gsm|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18192" PostTypeId="1" CreationDate="2015-11-27T19:40:52.607" Score="2" ViewCount="623" Body="&lt;p&gt;The following code does what I need it to do (when a start switch is on and door switch is off - a warning light flashes. When the start switch and door switch are both on - a valve opens to allow water in for 2 seconds). I need the light to flash until the door is HIGH too at which point the valve program runs once.  The only way I have to get out of this is to use exit(0). Is there a better way to do this? Ideally, I would like to stay away from anything too Boolean! Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int start = 2;&#xA;int door = 3;&#xA;int light = 8;&#xA;int valve = 9;&#xA;int counter = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(start,INPUT);&#xA;  pinMode(door,INPUT);&#xA;  pinMode(light,OUTPUT);&#xA;  pinMode(valve,OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(digitalRead(start)==HIGH &amp;amp;&amp;amp; digitalRead(door)==HIGH) {&#xA;    digitalWrite(valve, HIGH);&#xA;    delay(2000);&#xA;    digitalWrite(valve,LOW);&#xA;    exit(0);&#xA;    //breaks out of loop. Arduino then needs reset.&#xA;  }&#xA;&#xA;  if (digitalRead(start)==HIGH &amp;amp;&amp;amp; digitalRead(door)==LOW) {&#xA;    digitalWrite(light,HIGH);&#xA;    delay(500);&#xA;    digitalWrite(light,LOW);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14711" LastEditorUserId="4628" LastEditDate="2015-11-30T15:03:36.230" LastActivityDate="2016-04-15T09:22:47.243" Title="Better way than exit(0)?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18193" PostTypeId="2" ParentId="18192" CreationDate="2015-11-27T19:45:35.983" Score="1" Body="&lt;p&gt;What you need to do is learn what a &lt;em&gt;finite state machine (FSM)&lt;/em&gt; is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An FSM is a way of having the Arduino in one of a &lt;em&gt;finite&lt;/em&gt; number of &lt;em&gt;states&lt;/em&gt;, such as &quot;light flashing&quot;, or &quot;letting water in&quot;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written a reasonable (IMHO) tutorial here: &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/&quot; rel=&quot;nofollow&quot;&gt;https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="7508" LastEditDate="2016-04-15T09:22:47.243" LastActivityDate="2016-04-15T09:22:47.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18194" PostTypeId="1" CreationDate="2015-11-27T20:08:45.203" Score="4" ViewCount="7573" Body="&lt;p&gt;I cannot seem to upload the simple blink program to my Arduino Nano. I keep getting the message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I have tried already with a lot of suggestions on Google. &lt;strong&gt;I have tried it on both a Windows 7 &amp;amp; 8 machine and with 2 different Nano's:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set my Board to Arduino Nano&lt;/li&gt;&#xA;&lt;li&gt;Set my Processor to ATmega168&lt;/li&gt;&#xA;&lt;li&gt;Set my port to COM1&lt;/li&gt;&#xA;&lt;li&gt;On windows 8 turned off driver signature&lt;/li&gt;&#xA;&lt;li&gt;Installed the FTDI Driver&lt;/li&gt;&#xA;&lt;li&gt;Checked my drivers in control panel&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB controllers says USB Serial Converter&lt;/li&gt;&#xA;&lt;li&gt;USB Serial port says USB Serial Port (COM1)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Rebooted a Lot!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When I plugin the nano to the USB it starts blinking the L led 180 times a minute. When I start uploading, L blinks at about 80-100 times a minute, blinks the rx and then start blinking the L led fast again.&lt;/p&gt;&#xA;" OwnerUserId="15159" LastEditorUserId="15159" LastEditDate="2015-11-27T20:31:58.477" LastActivityDate="2022-06-27T10:14:39.567" Title="Arduino Nano - programmer is not responding" Tags="|arduino-nano|programmer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18195" PostTypeId="2" ParentId="12187" CreationDate="2015-11-27T23:03:37.923" Score="0" Body="&lt;p&gt;@user3060854 -- were you able to resolve this? A higher baud rate for communicating with the HC bluetooth module can help with your speed/slowdown problem. But have noticed baud rates above 115200 dont work well. I believe the problem is the receiver baud rate %error, which should not happen at 250k baud. But I havent figured out how to set a baud rate of 250k in the BT module. The question with details is here ---  &lt;a href=&quot;https://arduino.stackexchange.com/questions/18132/setting-baud-rate-of-250k-for-the-hc-05-bluetooth-module&quot;&gt;Setting non-standard baud rate (250k) for the HC-05 bluetooth module&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6930" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-11-27T23:03:37.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18196" PostTypeId="1" CreationDate="2015-11-27T23:17:39.503" Score="0" ViewCount="1581" Body="&lt;p&gt;Can anyone help me to make this work? I have been trying for a couple of days to make this work, but no luck. I use a DS18b20 Temperature sensor and an ENC28J60 Ethernet module. The last code that I find like close to work is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;| Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the &#xA;| ENC28J60 chip.&#xA;| Based on the Ethercard example from www.jeelabs.org&#xA;| Phil Grant Jan 2014&#xA;*/&#xA;#include &amp;lt;EtherCard.h&amp;gt;&#xA;// change these settings to match your own setup&#xA;#define APIKEY  &quot;xxxx&quot;&#xA;&#xA;//DHT Setup&#xA;//#include &quot;DHT.h&quot;&#xA;//#define DHTPIN 2     // what pin we're connected to&#xA;// Uncomment whatever type you're using!&#xA;//#define DHTTYPE DHT11   // DHT 11&#xA;//#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;//#define DHTTYPE DHT21   // DHT 21 (AM2301)  &#xA;//DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;// ethernet interface mac address, must be unique on the LAN&#xA;byte mymac[] = { 0x12,0x11,0x22,0x12,0x21,0x11 };&#xA;char website[] = &quot;api.thingspeak.com&quot;;&#xA;byte Ethernet::buffer[700];&#xA;uint32_t timer;&#xA;Stash stash;&#xA;&#xA;void setup () {&#xA;Serial.begin(57600);&#xA;//dht.begin(); //Initializate DHT&#xA;  Serial.println(&quot;\n[webClient]&quot;);&#xA;if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) &#xA;    Serial.println( &quot;Failed to access Ethernet controller&quot;);&#xA;  if (!ether.dhcpSetup())&#xA;    Serial.println(&quot;DHCP failed&quot;);&#xA;  ether.printIp(&quot;IP:  &quot;, ether.myip);&#xA;  ether.printIp(&quot;GW:  &quot;, ether.gwip);  &#xA;  ether.printIp(&quot;DNS: &quot;, ether.dnsip);  &#xA;  if (!ether.dnsLookup(website))&#xA;    Serial.println(&quot;DNS failed&quot;);&#xA;  ether.printIp(&quot;SRV: &quot;, ether.hisip);&#xA;}&#xA;&#xA;void loop () {&#xA;  ether.packetLoop(ether.packetReceive());&#xA;  if (millis() &amp;gt; timer) {&#xA;    timer = millis() + 60000; //Transmit every minute&#xA;    delay(2000);  // Wait a few seconds between measurements.&#xA;  // Reading temperature or humidity takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  float h = dht.readHumidity();&#xA;  // Read temperature as Celsius (the default)&#xA;  char h_buffer[10];&#xA;  String Hstring = dtostrf(h,0,5,h_buffer);&#xA;  //Convert Humidity value to String&#xA;  float t = dht.readTemperature();&#xA;  // Read temperature as Fahrenheit (isFahrenheit = true)&#xA;  //float f = dht.readTemperature(true);&#xA;  char t_buffer[10];&#xA;  String Tstring = dtostrf(t,0,5,t_buffer);&#xA;  //Convert Temperature value to String&#xA;  byte sd = stash.create();&#xA;  stash.print(&quot;field1=&quot;);&#xA;  stash.println(Hstring);&#xA;  stash.print(&quot;&amp;amp;field2=&quot;);&#xA;  stash.println(Tstring);&#xA;  stash.save();&#xA;  // generate the header with payload - note that the stash size is used,&#xA;  // and that a &quot;stash descriptor&quot; is passed in as argument using &quot;$H&quot;&#xA;  Stash::prepare(PSTR(&#xA;    &quot;POST /update HTTP/1.1&quot; &quot;\r\n&quot;&#xA;    &quot;Host: $F&quot; &quot;\r\n&quot;&#xA;    &quot;Connection: close&quot; &quot;\r\n&quot;&#xA;    &quot;X-THINGSPEAKAPIKEY: $F&quot; &quot;\r\n&quot;&#xA;    &quot;Content-Type: application/x-www-form-urlencoded&quot; &quot;\r\n&quot;&#xA;    &quot;Content-Length: $D&quot; &quot;\r\n&quot;&#xA;    &quot;\r\n&quot;&#xA;    &quot;$H&quot;),&#xA;    website, PSTR(APIKEY), stash.size(), sd);&#xA;    // send the packet - this also releases all stash buffers once done&#xA;    ether.tcpSend();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But on the serial monitor I get this message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;[webClient]&#xA;IP:  192.168.88.252&#xA;GW:  192.168.88.1&#xA;DNS: 8.8.8.8&#xA;DNS failed&#xA;SRV: 0.0.0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have try all of this network configurations and I am sure that arduino have access to internet from my home router. I can ping arduino IP address from other computers in my network and all computers have access to Internet from same router and same subnet with same DNS.&#xA;Any more ideas? &lt;/p&gt;&#xA;" OwnerUserId="15162" LastEditorUserId="220" LastEditDate="2015-12-01T00:13:01.017" LastActivityDate="2017-11-22T10:31:53.330" Title="Arduino with DS18b20 and ENC28J60 to thingspeak" Tags="|arduino-uno|shields|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18197" PostTypeId="2" ParentId="18196" CreationDate="2015-11-28T03:52:21.050" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;But on serial monitor I get msg: [webClient] IP: 192.168.88.252 GW: 192.168.88.1 DNS: 8.8.8.8 DNS failed SRV: 0.0.0.0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The line above shows that you have the Ethernet interface configured to use a private IP address (192.168.X.Y) and that you're trying to reach Google's DNS server at 8.8.8.8. That means that you've got to have a connection to the Internet accessible through your gateway (192.168.88.1). The gateway will have to be doing NAT since your router will not (should) not route traffic from private addresses to the Internet – and even if it did other routers would not be able to route traffic back to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to do is to confirm that you've got an Internet connection and that the address you're trying to reach exists. If you've got another computer on the same network that can reach the Internet try the address you're trying to reach (api.thingspeak.com) and confirm that the name resolves to an IP address. Then confirm that the gateway you're using on that machine matches what you've got configured on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another good thing to check would be that the Arduino seems to be working on the wire. There are a number of ways that you could confirm this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check to see that you can ping it.&lt;/li&gt;&#xA;&lt;li&gt;Check to see that it shows up in your ARP cache (use the command &lt;code&gt;arp -a&lt;/code&gt; in the terminal if you're on Linux or OS X. You're looking to see that the IP address assigned to the Arduino is unique and that you get back the MAC address that you expect.&lt;/li&gt;&#xA;&lt;li&gt;Try pointing your DNS at your router (assuming it is configured to act as a DNS server). That will let you see if you get a response from inside your network. Before doing this configure that &lt;code&gt;api.thingspeak.com&lt;/code&gt; resolves using ping or by going there on another machine. If this works, you should try it pointing another machine at 8.8.8.8 as your DNS server – just to confirm that this works. If it works and the Arduino fails then it is getting more puzzling.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;At this point you most likely will have identified the problem. If you haven't it would make sense to spend some time learning a bit about &lt;code&gt;tcpdump&lt;/code&gt; or Wire Shark so that you can watch TCP traffic on the network. At the very least you'll want to be able to watch to see the basic DNS transaction. One possibility may be that the Arduino expects the DNS server to be on the local wire and that it is timing out too fast.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-28T03:52:21.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18198" PostTypeId="1" AcceptedAnswerId="18200" CreationDate="2015-11-28T04:06:13.657" Score="0" ViewCount="727" Body="&lt;p&gt;I am debating over getting arduino yun or 2pcs nRF24L01+ 2.4GHz Wireless Transceiver. Here is the link to the transceiver on amazon &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E594ZX0&quot; rel=&quot;nofollow&quot;&gt; amazon description&lt;/a&gt;. I do not know much about wifi but why would someone get the 70 dollar yun instead of the basic transceiver and a uno. In particular for my project I want my arduino to use Web API's like twilio to send messages to my phone. Can both products do that?I know the yun has linux but I don't know if I need that for my project.Is their a better option (price is part of my decision)&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2015-11-28T12:30:20.147" Title="Difference between simple wifi transceiver and arduino yun" Tags="|arduino-uno|arduino-yun|wireless|web|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18199" PostTypeId="1" AcceptedAnswerId="18230" CreationDate="2015-11-28T05:50:15.427" Score="1" ViewCount="91" Body="&lt;p&gt;I want my code to run my motor for a specific amount of time at a specific speed and then stop and not do anything else. I'm having trouble here, I think with my switch and the if loops running on repeat. What is a good way for me to stop the code from looping? And any helpful hints on my switches will be appreciated as well? Thanks and I hope you had a wonderful thanksgiving if you're American. If you're not, I hope you just had a great day in general.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;Adafruit_DCMotor *DC1 = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *DC2 = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *DC3 = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *DC4 = AFMS.getMotor(4);&#xA;&#xA;Servo Servo1;&#xA;&#xA;void setup() {&#xA;  digitalWrite(A0, HIGH); //Turns on the pullup resistor for A0&#xA;  AFMS.begin(); //Initializes the motorshield board&#xA;  int motorPin1 = 1;&#xA;  int motorPin2 = 2;&#xA;  int motorPin3 = 3;&#xA;  int motorPin4 = 4;&#xA;  pinMode(A0, INPUT); //Sets the Analog Pin 0 as an input&#xA;  digitalWrite(A0, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  digitalWrite(A1, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  pinMode(1, OUTPUT);&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  Servo1.attach(9);&#xA;}&#xA;&#xA;void loop()  {&#xA;  int MAXampDrawTime = 1000;&#xA;  int MAXampDrawSpeed = 20;&#xA;  int NORMampDrawTime = 1500;&#xA;  int NORMampDrawSpeed = 10;&#xA;  int DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;  int ServoTime = 450;&#xA;  int previousMillis = 0;&#xA;  int inPin0 = LOW;&#xA;  int inPin1 = LOW;&#xA;  inPin0 = digitalRead(A0);&#xA;  inPin1 = digitalRead(A1);&#xA;  unsigned long time_zero = millis();&#xA;  unsigned long current_time = millis();&#xA;&#xA;  if (inPin0 == HIGH) {&#xA;    time_zero = millis();&#xA;    current_time = millis();&#xA;    while (millis() - time_zero &amp;lt; MAXampDrawTime); {&#xA;      dcMoveConst(MAXampDrawSpeed, 1);&#xA;      dcMoveConst(MAXampDrawSpeed, 2);&#xA;      dcMoveConst(MAXampDrawSpeed, 3);&#xA;      dcMoveConst(MAXampDrawSpeed, 4);&#xA;    }&#xA;    while (millis() - time_zero &amp;lt; NORMampDrawTime); {&#xA;      dcMoveConst(NORMampDrawSpeed, 1);&#xA;      dcMoveConst(NORMampDrawSpeed, 2);&#xA;      dcMoveConst(NORMampDrawSpeed, 3);&#xA;      dcMoveConst(NORMampDrawSpeed, 4);&#xA;    }&#xA;    if (millis() - time_zero &amp;gt; DrawTime) {&#xA;      dcMoveConst(0, 1);&#xA;      dcMoveConst(0, 2);&#xA;      dcMoveConst(0, 3);&#xA;      dcMoveConst(0, 4);&#xA;    }&#xA;&#xA;    if (millis() - time_zero &amp;gt;= ServoTime); {&#xA;      Servo1.write(0);&#xA;      delay(400);&#xA;      Servo1.write(90);&#xA;    }&#xA;  }&#xA;&#xA;  if (inPin1 == HIGH) {&#xA;    time_zero = millis();&#xA;    current_time = millis();&#xA;    MAXampDrawTime = 1000;&#xA;    MAXampDrawSpeed = 20;&#xA;    NORMampDrawTime = 1500;&#xA;    NORMampDrawSpeed = 10;&#xA;    DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;    while (millis() - time_zero &amp;lt; MAXampDrawTime); {&#xA;      dcMoveConst(MAXampDrawSpeed, 1);&#xA;      dcMoveConst(MAXampDrawSpeed, 2);&#xA;      dcMoveConst(MAXampDrawSpeed, 3);&#xA;      dcMoveConst(MAXampDrawSpeed, 4);&#xA;    }&#xA;    while (millis() - time_zero &amp;lt; NORMampDrawTime); {&#xA;      dcMoveConst(NORMampDrawSpeed, 1);&#xA;      dcMoveConst(NORMampDrawSpeed, 2);&#xA;      dcMoveConst(NORMampDrawSpeed, 3);&#xA;      dcMoveConst(NORMampDrawSpeed, 4);&#xA;    }&#xA;    if (millis() - time_zero &amp;gt; DrawTime) {&#xA;      dcMoveConst(0, 1);&#xA;      dcMoveConst(0, 2);&#xA;      dcMoveConst(0, 3);&#xA;      dcMoveConst(0, 4);&#xA;    }&#xA;&#xA;    if (millis() - time_zero &amp;gt;= ServoTime); {&#xA;      Servo1.write(0);&#xA;      delay(400);&#xA;      Servo1.write(90);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14872" LastEditorUserId="4628" LastEditDate="2015-11-29T21:37:58.587" LastActivityDate="2015-11-29T21:37:58.587" Title="Problems stopping an if loop, and starting it as well" Tags="|debugging|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18200" PostTypeId="2" ParentId="18198" CreationDate="2015-11-28T06:47:40.507" Score="1" Body="&lt;p&gt;The nRF24L01+ modules aren't WiFi. They cannot talk to a WiFi router or the internet. They can only talk to other nRF24L01+ modules. They are good for connecting two or more UNOs together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Yún has a full WiFi connection and is also able to operate as a router itself. It is best suited when you need to run complex networking on an Arduino.  To access the WiFi on the Yún you need to communicate with it over the in-built serial connection. There are libraries to help you, but the overall package is really very much overkill unless you have a requirement to do complex network routing (VPN for instance) or run software (say a Python program) directly on the Linux portion of the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like what you are really after for your project is an Arduino UNO and &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;WiFi shield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular option is the ESP8266 modules.  These can be controlled through serial using &lt;em&gt;AT&lt;/em&gt; commands, or directly programmed using the Arduino-compatible &lt;em&gt;core&lt;/em&gt; available from &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-28T12:30:20.147" LastActivityDate="2015-11-28T12:30:20.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18203" PostTypeId="2" ParentId="17868" CreationDate="2015-11-28T10:15:58.090" Score="0" Body="&lt;p&gt;The problem was that I selected &lt;code&gt;ATMega168&lt;/code&gt; when I should have selected &lt;code&gt;ATMega328&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BJkTe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BJkTe.jpg&quot; alt=&quot;facepalm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14883" LastActivityDate="2015-11-28T10:15:58.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18204" PostTypeId="2" ParentId="18199" CreationDate="2015-11-28T12:41:25.257" Score="2" Body="&lt;p&gt;There are two major flaws with your program - and both of them can be &quot;fixed&quot; by you understanding some concepts better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, in your program, there is no concept of &quot;When the button is pressed&quot;, only &quot;While the button is pressed&quot;.  This is caused by an error in your understanding of how reading of buttons needs to be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The digitalRead() function will return the &lt;em&gt;current&lt;/em&gt; state of the button &lt;em&gt;at that precise moment in time&lt;/em&gt;. It has no concept of &quot;This has just been pressed&quot;, only &quot;This is currently pressed&quot;.  So you need to remember in what state the button was &lt;em&gt;last time&lt;/em&gt; you looked at it, and only &lt;em&gt;if it has changed&lt;/em&gt; do you do something to react to it.  The same with the releasing of the button - at the moment it only knows that it &lt;em&gt;isn't&lt;/em&gt; pressed, not that it &lt;em&gt;was&lt;/em&gt; pressed but is &lt;em&gt;no longer&lt;/em&gt; pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second problem is that of &lt;em&gt;state&lt;/em&gt;, and is closely coupled with the fixing of the reading of the buttons.  At the moment the &lt;em&gt;state&lt;/em&gt; of your arduino (i.e., what it thinks it should be doing at the moment) is entirely defined by what buttons are currently being held in or not held in at any one time.  Instead the buttons need to be used to set flags that tell the Arduino what it should be doing and when - such as a flag that says &quot;You should be moving the servos&quot;.  Such an arrangement is called a &lt;em&gt;finite state machine&lt;/em&gt; and is one of the simplest ways of getting something small like an Arduino to do multiple things at once - in this case reading what is happening to the switches whilst at the same time making motors do different things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information on &lt;em&gt;finite state machines&lt;/em&gt; you might like to cast your eye over this: &lt;a href=&quot;http://hacking.majenko.co.uk/finite-state-machine&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/finite-state-machine&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T12:41:25.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18205" PostTypeId="2" ParentId="18199" CreationDate="2015-11-28T14:22:37.217" Score="0" Body="&lt;p&gt;@Majenko --- I love this new way of thinking about code! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is - maybe it would do some good to know what my robot is doing, it's launching a fishing rod. It's turning the motor to fling the arm, and the servo will disengage the button in order to launch the lure. These processes are independent from each other... the servo might start working before the motor stops working, but both rely on the switch being pressed, and I won't know at which point the servo should release until testing starts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I've realized that I've got the if qualifiers in the wrong place and I'm currently trying to fix that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;&#xA;&#xA;&#xA;Adafruit_DCMotor *DC1 = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *DC2 = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *DC3 = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *DC4 = AFMS.getMotor(4);&#xA;&#xA;Servo Servo1;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  digitalWrite(A0, HIGH); //Turns on the pullup resistor for A0&#xA;  AFMS.begin(); //Initializes the motorshield board&#xA;&#xA;  int motorPin1 = 1;&#xA;  int motorPin2 = 2;&#xA;  int motorPin3 = 3;&#xA;  int motorPin4 = 4;&#xA;&#xA;&#xA;&#xA;&#xA;  pinMode(A0, INPUT); //Sets the Analog Pin 0 as an input&#xA;  digitalWrite(A0, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  digitalWrite(A1, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  pinMode(1, OUTPUT);&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  Servo1.attach(9);&#xA;#define s_idle 1&#xA;#define s_maxthrow 2&#xA;#define s_accthrow 3&#xA;#define s_waitservo 4&#xA;#define s_servogo 5&#xA;#define s_turnoff 6&#xA;&#xA;  int inPin0 = LOW;&#xA;  int inPin1 = LOW;&#xA;  inPin0 = digitalRead(A0);&#xA;  inPin1 = digitalRead(A1);&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()  {&#xA;  static int state = 1; // initial state is 1, the idle state&#xA;  static unsigned long ts; // to store the current time in for delays&#xA;  int MAXampDrawTime;&#xA;  int MAXampDrawSpeed;&#xA;  int NORMampDrawTime;&#xA;  int NORMampDrawSpeed;&#xA;  int servoTime = 450;&#xA;  int inPin0 = LOW;&#xA;  int inPin1 = LOW;&#xA;  int DrawTime;&#xA;  inPin0 = digitalRead(A0);&#xA;  inPin1 = digitalRead(A1);&#xA;&#xA;  switch (state) {&#xA;    case s_idle:&#xA;      //we don't deen to do anything here, waiting for a state&#xA;      break;&#xA;&#xA;    case s_maxthrow:&#xA;&#xA;      if (inPin0 == HIGH); {&#xA;        MAXampDrawTime = 500;&#xA;        MAXampDrawSpeed = 20;&#xA;        NORMampDrawTime = 250;&#xA;        NORMampDrawSpeed = 10;&#xA;        DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;&#xA;        ts = millis();&#xA;&#xA;        dcMoveConst(MAXampDrawSpeed, 1);&#xA;        dcMoveConst(MAXampDrawSpeed, 2);&#xA;        dcMoveConst(MAXampDrawSpeed, 3);&#xA;        dcMoveConst(MAXampDrawSpeed, 4);&#xA;        delay(MAXampDrawTime);&#xA;        dcMoveConst(NORMampDrawSpeed, 1);&#xA;        dcMoveConst(NORMampDrawSpeed, 2);&#xA;        dcMoveConst(NORMampDrawSpeed, 3);&#xA;        dcMoveConst(NORMampDrawSpeed, 4);&#xA;        delay(NORMampDrawTime);&#xA;        state = s_turnoff;&#xA;&#xA;      }&#xA;    case s_turnoff:&#xA;      dcRelease(1);&#xA;      dcRelease(2);&#xA;      dcRelease(3);&#xA;      dcRelease(4);&#xA;      state = s_idle;&#xA;      break;&#xA;&#xA;    case s_accthrow:&#xA;      if (inPin1 == HIGH); {&#xA;        MAXampDrawTime = 1000;&#xA;        MAXampDrawSpeed = 20;&#xA;        NORMampDrawTime = 750;&#xA;        NORMampDrawSpeed = 10;&#xA;        DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;&#xA;        ts = millis();&#xA;&#xA;        dcMoveConst(MAXampDrawSpeed, 1);&#xA;        dcMoveConst(MAXampDrawSpeed, 2);&#xA;        dcMoveConst(MAXampDrawSpeed, 3);&#xA;        dcMoveConst(MAXampDrawSpeed, 4);&#xA;        delay(MAXampDrawTime);&#xA;        dcMoveConst(NORMampDrawSpeed, 1);&#xA;        dcMoveConst(NORMampDrawSpeed, 2);&#xA;        dcMoveConst(NORMampDrawSpeed, 3);&#xA;        dcMoveConst(NORMampDrawSpeed, 4);&#xA;        delay(NORMampDrawTime);&#xA;        state = s_turnoff;&#xA;      }&#xA;&#xA;    case s_servogo:&#xA;      if (millis() - ts &amp;gt; servoTime); {&#xA;        Servo1.write(0);&#xA;        delay(400);&#xA;        Servo1.write(90);&#xA;      }&#xA;&#xA;  }&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14872" LastEditorUserId="14872" LastEditDate="2015-11-28T14:47:36.290" LastActivityDate="2015-11-28T14:47:36.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18206" PostTypeId="1" AcceptedAnswerId="18208" CreationDate="2015-11-28T15:17:22.823" Score="1" ViewCount="69" Body="&lt;p&gt;I'm a guy who loves the tech world, but more in particular the Robotic one.&#xA;I wanna start developing/making my first creations of robots or sort of.&#xA;I won a little board from &lt;strong&gt;Texas Instrument&lt;/strong&gt; from the &lt;strong&gt;Maker Faire&lt;/strong&gt; here in Rome, but I don't really know how to get the best out of it, and specially what to buy as extra stuff to start making. I guess the best way to start would be a &lt;strong&gt;kit&lt;/strong&gt; (?) So I saw the Arduino one (Genuino one as I'm out of the USA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question then is: &lt;strong&gt;What's the best way to start diving into this world?&lt;/strong&gt; Feel free to consider or ignore the fact I got that little board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Board:&#xA;&lt;a href=&quot;http://www.ti.com/tool/msp-exp430f5529lp&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/tool/msp-exp430f5529lp&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15170" LastActivityDate="2015-11-28T16:08:30.070" Title="How to get started?" Tags="|arduino-uno|arduino-leonardo|" AnswerCount="1" CommentCount="3" ClosedDate="2015-12-16T16:53:02.947" ContentLicense="CC BY-SA 3.0" />
  <row Id="18207" PostTypeId="2" ParentId="18188" CreationDate="2015-11-28T15:21:18.500" Score="1" Body="&lt;p&gt;Firstly you do not keep your code consistent between you temperature test and your LCD test code. The problem lies in your use of the &lt;strong&gt;internal&lt;/strong&gt; analog reference, that reference is 1.1V and that is giving you 130°C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Temp = 260*0.5= 130&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 260 is the ADC reading worked back from the 130°C you gave&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use Internal reference-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internal ref = 1.1÷1024=0.001074219&#xA;That multiplied by one hundred to account for the mV reading of the lm35 gives &lt;code&gt;0.107&lt;/code&gt; that will give you the correct temp when using the internal reference&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;Analog reference&lt;/a&gt; from the arduino site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use the analog reading *0.5 comment out the &lt;code&gt;analogReference()&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2015-11-28T15:21:18.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18208" PostTypeId="2" ParentId="18206" CreationDate="2015-11-28T16:08:30.070" Score="1" Body="&lt;p&gt;Robotics is a very large field covering a lot of disciplines, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Motor and sensor control and interfacing&lt;/li&gt;&#xA;&lt;li&gt;Mechanics and kinematics&lt;/li&gt;&#xA;&lt;li&gt;Visual and optical processing&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And many more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino side of things is mostly concerned with the first point - the interfacing and control of motors and sensors, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For robotics probably the most important thing to get to grips with is servo motors.  If you can leave the mechanics side of things to someone else for now (to build a robot from the ground up would require metal working skills, welding, and more, which we're not really able to help you with) and start with a &quot;kit&quot; robot of some form to get you going that would be the best entry point IMHO.  One such kit that I have been looking at recently and is easily available on eBay is the &lt;a href=&quot;http://www.ebay.co.uk/itm/171804866408&quot; rel=&quot;nofollow&quot;&gt;&quot;6DOF&quot; robot arm&lt;/a&gt; (note: the servos are sold separately normally).  Just add cheaply available standard model servos and interface them to an Arduino and you have a robot arm you can program to do things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's when the fun starts.  Learning to program for robotics does often involve some more advanced mathematics, so be prepared to have to do some study...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for what board to use?  Your MSP430 board is more than capable of controlling robotics.  Not sure about the programming aspect of it - in general it's TI's own IDE and programming environment, but I do know that some of their boards (not sure about that one) are supported by a port of the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T16:08:30.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18209" PostTypeId="1" AcceptedAnswerId="18210" CreationDate="2015-11-28T16:52:34.503" Score="2" ViewCount="197" Body="&lt;p&gt;I have been using a &lt;strong&gt;Make-It Robotics kit&lt;/strong&gt;, that I picked up from a RadioShack that was closing, to learn more about Arduino, C, etc.  After building the &lt;strong&gt;line-following robot&lt;/strong&gt; and downloading the correct libraries, I can get the robot to function as intended.  It uses 2 optical sensors in front of 2 driving wheels that are controlled by independent DC motors.  The optical sensors determine if the left or right side of the front of the robot is over a white or black area on the test track. The necessary motor then turns on to keep the black line roughly between the 2 sensors as the robot moves along. The default test track that came with the kit was a large black circle on a white background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make some modifications to the code (and maybe the underlying library files) to try to make the robot able to handle other types of paths with more acute angles and sharper turns, etc.  But, I don't understand some aspects of the highest level .ino source code file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a little unsure of pasting such a long code block below and also don't think an image of it will help.  The version data for the file I'm using is below.  The files can be found online @ &lt;a href=&quot;https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit/blob/master/2770168%20Starter%20Kit/linefollow/linefollow.ino&quot; rel=&quot;nofollow&quot;&gt;LINK&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ******************************************************************************    **&#xA;// * File Name          : linefollow&#xA;// * Author             : RadioShack Corporation&#xA;// * Version            : V1.0&#xA;// * Date               : 2014/01/16&#xA;// * Description        : Optical sensors send feedback to PCB &#xA;// *                      to make the robot follow a black line on a white background.&#xA;// ********************************************************************************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this .ino file, &lt;strong&gt;I don't understand the code from line 68 onwards&lt;/strong&gt;: from the Read Left/Right Optical Status onward...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand some of the bitwise operations there and don't really see how the sensor readings (whether it is over a white or black area on the surface) correlates to which motor activates to keep the robot on the course...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From my limited understanding of Arduino, this robot kit, and the code, it seems like the software and hardware have to interact in this way:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Robot moves forward using both motors turning the wheels in the same direction.  It approaches the black test circle at a shallow angle (i.e. almost tangent to it) to allow one sensor to go over the black line before the other one does.&lt;/li&gt;&#xA;&lt;li&gt;Optical readings of each sensor are taken periodically.&lt;/li&gt;&#xA;&lt;li&gt;If both sensors detect white space, robot continues to move forward.&lt;/li&gt;&#xA;&lt;li&gt;If the right sensor detects that it has gone from white to black and then to white, it means that the robot needs to turn to the left to stay on the path.&lt;/li&gt;&#xA;&lt;li&gt;To turn left, the left motor is un-powered and the right motor is powered until the right sensor detects black again.&lt;/li&gt;&#xA;&lt;li&gt;Now that the robot is on course, it will keep turning in the direction of the sensor that detects a white to black to white transition.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am not seeing how my intuitive understanding of the robot's operation matches with that of the code...&lt;/p&gt;&#xA;" OwnerUserId="10203" LastEditorUserId="10203" LastEditDate="2015-11-28T17:26:57.120" LastActivityDate="2015-11-29T20:23:24.703" Title="Unsure about how the code works for this Make-It Robotics kit" Tags="|robotics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18210" PostTypeId="2" ParentId="18209" CreationDate="2015-11-28T17:52:42.173" Score="2" Body="&lt;p&gt;Indeed, the way the bitwise operations are written is confusing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if((sensor_in &amp;amp; 0xf00)==0)&#xA;    sensorValue1=sensor_in &amp;amp; 0xff;&#xA;  else if((sensor_in &amp;amp; 0xf00)&amp;gt;&amp;gt;8==1)  &#xA;    sensorValue2=sensor_in &amp;amp; 0xff;&#xA;  if (sensorValue1 == 0x00)&#xA;    action1 =action1 &amp;amp; 0xfe;&#xA;  if (sensorValue1 == 0xFF)&#xA;    action1 = action1 | 0x01;&#xA;  if (sensorValue2 == 0x00)&#xA;    action1 = action1 | 0x02;&#xA;  if (sensorValue2 == 0xFF)&#xA;    action1 = action1 &amp;amp; 0xfd;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically you have two input values that can be in the same variable - differentiated by the 9th bit of the value.  Values between 0 and 255 relate to one sensor, between 256 and 511 to the other.  The bitwise operators split that into sensorValue1 and sensorValue2 accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then those sensor values are compared to 0 or 255 and used to define the action to perform - that action being comprised of the lowest two bits of a byte variable, so you have three possible actions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 = both sensors off&#xA;1 = sensor 1 on, sensor 2 off&#xA;2 = sensor 1 off, sensor 2 on&#xA;3 = both sensors on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments in the program also tell you this information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;action1&#xA;         left        right&#xA;0x00    black        black&#xA;0x01    black        white&#xA;0x02    white        black&#xA;0x03    white        white&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have how to deal with the action value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(action1 != action2)&#xA;{&#xA;  if (action1 == 3 )&#xA;    line_following.go_forward(50);&#xA;  if (action1 == 1)&#xA;    line_following.line_following_turn_left(50);    &#xA;  if (action1 == 2)&#xA;    line_following.line_following_turn_right(50);  &#xA;  if (action1 == 0)&#xA;    line_following.go_forward(50);  &#xA;}&#xA;action2=action1;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if the action has changed, we can change what we are doing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If action is 3, so if both sensors read as white, or if action is 0, so both sensors read black (in other words if both sensors read the same) then move forwards.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If action is 1 (so the left sensor reads black) then turn to the left.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If action is 2 (so the right sensor reads black) then turn to the right.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So basically if it doesn't know anything better, it drives forwards, otherwise it turns in the direction that it finds the black line, thus keeping it always on that line.  As it drifts off the line one sensor will sense white, so the robot will turn away from that whiteness and back on to the line.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T17:52:42.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18211" PostTypeId="1" AcceptedAnswerId="18214" CreationDate="2015-11-28T18:59:00.740" Score="3" ViewCount="1794" Body="&lt;p&gt;When I bought my Arduino Uno and connected it to my computer, I tried to make the simple blink circuit (before programming the Arduino) and suddenly the LED started blinking. Is the blink example the default Arduino sketch?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure that I didn't uploaded anything to the board.&lt;/p&gt;&#xA;" OwnerUserId="14669" LastEditorUserId="510" LastEditDate="2019-05-28T21:17:56.447" LastActivityDate="2019-05-28T21:17:56.447" Title="What is the Arduino Uno default sketch?" Tags="|arduino-uno|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="18212" PostTypeId="1" CreationDate="2015-11-28T18:59:41.757" Score="1" ViewCount="3406" Body="&lt;p&gt;I'm referring to the 5th circuit (see below screenshot) of the sparkfun manual came with the arduino uno. Instead of connecting all three of the (+) (-) and the digital pin to each push button, can I just connect the (-) through the resistor and the digital pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a side question, in terms of physics, you need two ends to be connected in order to create pressure for the flow of electrons, but the digital wire for each push button that goes out to the arduino board doesn't have its own ground wiring that suppose to create the pressure as a couple. How to cope with that in terms of electron flow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0UI4S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0UI4S.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15175" LastEditorUserId="15175" LastEditDate="2015-11-30T16:54:47.270" LastActivityDate="2015-11-30T16:54:47.270" Title="are 3 connections necessary for a push button?" Tags="|button|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18213" PostTypeId="1" CreationDate="2015-11-28T19:01:28.523" Score="1" ViewCount="1284" Body="&lt;p&gt;In an effort to learn about transistors that seemed easy enough. But I can't get it to work in practice&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I control 4 LEDs with just 2 digital outputs (High, Low). So I figured I would use the difference between PNP and NPN transistors to create logic gates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[00,01,10,11]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can not seem to get this to work in practice for the life of me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about Charliplexing, but that is n*(n-1), which isn't good enough. I've also read about shift registers, but I'm not sure I fully understand (I'm a noob), and it sounds like you need a minimum of 3 pins. Is what I am trying to do even possible? If not, then why?&lt;/p&gt;&#xA;" OwnerUserId="15176" LastActivityDate="2015-11-28T19:19:16.877" Title="How do I control 4 LEDs with 2 Digital Outputs?" Tags="|arduino-uno|digital|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18214" PostTypeId="2" ParentId="18211" CreationDate="2015-11-28T19:07:22.927" Score="2" Body="&lt;p&gt;Some may have the &quot;Blink&quot; sketch pre-installed, but many don't. However, when there is no sketch installed the board sits in bootloader mode waiting for you to upload a sketch.  While it's in bootloader mode the LED pin pin D13 blinks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your LED is blinking about once a second then it's the Blink sketch.  If it's rapidly blinking three or four times per second or so then it's in the bootloader and you have no sketch loaded.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T19:07:22.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18215" PostTypeId="2" ParentId="18213" CreationDate="2015-11-28T19:19:16.877" Score="3" Body="&lt;p&gt;Using two pins it is possible to drive 4 LEDs as long as you only want one of them on at a time.  One LED will always be on - it's not possible to have a setting where there is no output selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you are &quot;decoding&quot; a binary value output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00 = LED 1 on, other three off&#xA;01 = LED 2 on, other three off&#xA;10 = LED 3 on, other three off&#xA;11 = LED 4 on, other three off&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To do that you need to use (or construct) a &lt;em&gt;2-to-4 decoder&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using logic gates it can be constructed like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bD5A9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bD5A9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can translate that into transistors then you'll end up with quite a lot of transistors.  Most people would use a specific 2-to-4 decoder chip such as the 74HC139.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shift registers usually require three pins, yes, though there are possible ways of working with two pins.  You require two pins to provide the data and clock signals, and a third pin to latch the shifted data out to the outputs. However it is possible to use the first leading edge of the clock signal or a specially formatted data signal with a capacitor to create a pulse just before sending new data which can latch the old data.  This requires careful consideration though regarding how fast you would be transmitting, etc, and is not really recommended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better solution if you are limited in pins and need to drive multiple LEDs is to use WS2812 &quot;NeoPixel&quot; LEDs which chain together and use a single wire protocol to send data to all the LEDs in the chain.  You can support many LEDs (even hundreds) on a single IO pin, and they are full 24-bit RGB to boot.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T19:19:16.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18216" PostTypeId="2" ParentId="18212" CreationDate="2015-11-28T19:35:55.073" Score="1" Body="&lt;p&gt;In order for an input pin to be able to read a real value it must be connected to something - either a power source (Vcc) or to ground.  If it's not connected to either of those and left &quot;flapping in the breeze&quot; then it's said to be &lt;em&gt;floating&lt;/em&gt; and the input value cannot be determined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need a way of switching that input pin between being connected to Vcc or being connected to GND.  That is why there are three wires - the input pin and the two voltage levels that must be chosen between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now an input pin has a very high resistance (&lt;em&gt;impedance&lt;/em&gt;) to ground. So when you connect it to Vcc a very tiny current will flow through it to ground, thus completing a circuit.  If you add another resistance between the pin and Vcc the incredibly small amount of current that flows will only cause the smallest of voltage drops across that new resistor (see Ohms Law).  So connecting the input pin to Vcc through a 10kΩ resistor (for example) will mean the voltage read at the input pin will be only fractionally below the +5V of Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when you introduce the pushbutton, which connects the input pin to ground when pressed, will also connect the resistor to ground. So you have the full 5V of Vcc across that resistor, and the input pin will be reading 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without the resistor in there - if you just connected the input pin to Vcc and then had the button connecting to ground - as soon as you press the button it would connect Vcc directly to ground, which is a really &lt;em&gt;really&lt;/em&gt; bad thing to do. That's called a short circuit, and it's when batteries start to explode and wires melt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the input pin itself is basically a voltage detector that detects what the voltage at the input pin is.  It has two thresholds known as VIH and VIL - the input logic voltage for HIGH and LOW respectively.  On the Arduino those are &lt;em&gt;0.6Vcc and 0.3Vcc&lt;/em&gt; - or 60% of the supply voltage for high, and 30% for low. At 5V that's 3V and 1.5V respectively.  If the voltage seen at the input pin is above 3V then it's seen as being HIGH. If it's below 1.3V then it's seen as being LOW.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-28T19:35:55.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18217" PostTypeId="2" ParentId="1391" CreationDate="2015-11-28T20:41:48.297" Score="1" Body="&lt;p&gt;The one thing that helped me was NOT to connect GND to stepper board from microcontroller (bottom black line from schematic posted in first post). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it was connected, driver would draw 12V@3A immediately and gets freaky hot. Also motor didn´t turn at all.&lt;/p&gt;&#xA;" OwnerUserId="15179" LastActivityDate="2015-11-28T20:41:48.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18218" PostTypeId="2" ParentId="18212" CreationDate="2015-11-28T22:14:10.597" Score="4" Body="&lt;p&gt;You can use the internal pullup e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(inPin, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then wire your switch between pin and Gnd.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-11-28T22:14:10.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18219" PostTypeId="1" CreationDate="2015-11-28T22:44:47.877" Score="2" ViewCount="637" Body="&lt;h1&gt;Problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I've been trying to a create a receiver and transmitter beacon for a following robot, but have not been able to sync my two SRF02s to one another. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;SoftwareSerial mySerial(10,11); // RX, TX &#xA;&#xA;void SendCmd(unsigned char address,unsigned char cmd)&#xA;{&#xA;  mySerial.write(address);//set the address of SRF02(factory default is 0) &#xA;  mySerial.write(cmd);//send the command to SRF02&#xA;}&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  Serial.println(&quot;SRF02 TEST!&quot;);&#xA;}&#xA;void loop(void)&#xA;{&#xA;  unsigned long t3;&#xA;  unsigned long t1=micros();//time tx command issued&#xA;  SendCmd(1, 0x5C);//send pulse with transmitter&#xA;  unsigned long t2=micros();//time rx command issued&#xA;  SendCmd(2, 0x5B);//listen for pulse returns results in microsconds&#xA;&#xA;&#xA;&#xA;&#xA;&#xA; while(mySerial.available() &amp;lt; 2)//if two bytes were received&#xA;  {}&#xA;    t3 = mySerial.read()&amp;lt;&amp;lt;8;//receive high byte (overwrites previous reading) and shift high byte to be high 8 bits&#xA;    t3 |= mySerial.read();// receive low byte as lower 8 bits&#xA;    unsigned long Tm = t3 + t2 - t1;//total amt of microseconds between pulse and reading&#xA;    unsigned long Dist = (Tm/29); //converting microseconds to cm&#xA;    Serial.print(t3); // print the reading&#xA;    Serial.println(&quot;cm&quot;);&#xA;    //Serial.print(tm);&#xA;    //Serial.println(&quot;ms&quot;);&#xA;&#xA;&#xA;  delay(250); // wait to read the output &#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Output#&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LNZ0Q.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LNZ0Q.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-11-29T12:00:53.700" Title="UART Software Serial - Syncing two sensors to make a tx and rx beacon" Tags="|uart|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18220" PostTypeId="2" ParentId="18219" CreationDate="2015-11-28T23:00:23.393" Score="1" Body="&lt;p&gt;I don't think what you are trying to do is possible with those modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; what you are trying to do is transmit a 40KHz pulse on one module and find out when it arrives at the other module. Unfortunately that is not going to be possible with serially attached modules - simply because it takes longer to transfer the serial data than it does for the ultrasound pulse to travel between the two modules.  That's why you're seeing such big values - you're actually measuring the amount of time it takes to transfer the serial data, not the sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For those modules to work they have to transmit a pulse themselves and then listen for that pulse and they return the difference between those two events. The timing for that is all done internally to the module and the results are returned through serial. Trying to perform the individual operations through serial is just not going to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better solution would be to modify an HC-SR04 module.  De-solder the transmitter from the board and re-connect it with some wires - that is then your remote module. You can do the same with the receiver module if you want it remote from the board if you like.  Then you interface the HC-SR04 direct to the Arduino and use it as you normally would.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so it seems there is a method of using them (AKA &quot;Fake&quot; sensing - idiotic name if ever there was one) that could be made to work if it's done precisely right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, doing it precisely right, as you have seen, is not easy.  Timing is critical. Timing of when you send instructions, and how you determine exactly when an instruction has been sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be much better off using a real hardware UART than software serial. That would mean upgrading your board to one with more than one hardware UART since you are using the only one the Uno has for your serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also recommend not using the Arduino's Serial object(s) for this since they impose their own buffering and asynchronous transfer of data which will really really mess with your timing.  Instead you should manually manipulate the registers directly - that way you can know exactly when the final bit of the serial commands have reached the ultrasound module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also send the command to the receiver first before the transmitter.  Did you know that at 9600 baud it takes about 2ms to transfer two bytes?  In that time sound will have travelled about 68cm.  If you start the receiver first then start the transmitter the receiver will be running when the sound wave reaches it, as opposed to when the sound wave is somewhere in the next room.  Then of course you have to take into account the time between starting the two properly, and that all comes back down to knowing your timing exactly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-29T12:00:53.700" LastActivityDate="2015-11-29T12:00:53.700" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18221" PostTypeId="2" ParentId="18183" CreationDate="2015-11-29T00:44:58.840" Score="5" Body="&lt;p&gt;Regarding the question, “Does PinChangeInt only work on digital pins?”, note that PCI's work on all the digital pins of an ATmega328, and on the first six analog pins.  (32-pin '328s have eight analog pins, A0-A7; 28-pin '328s only six, A0-A5.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the problem symptom that “&lt;code&gt;pulsewidth&lt;/code&gt; just seems to increase continuously”, that could happen if for some reason rising edges aren't processed.  To debug, add a couple more volative byte variables, say &lt;code&gt;nrises&lt;/code&gt; and &lt;code&gt;nfalls&lt;/code&gt;; increment each of them in the appropriate interrupt handler; and report their values from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding your &lt;code&gt;#include &amp;lt;PinChangeInt.h&amp;gt;&lt;/code&gt; statement, note that &lt;code&gt;PinChangeInt.h&lt;/code&gt; is &lt;a href=&quot;https://github.com/GreyGnome/PinChangeInt/commit/ec745f854b2b807640341cf479f540bb8bb3fc2f&quot; rel=&quot;noreferrer&quot;&gt;deprecated&lt;/a&gt; (as of 3 April 2015).  Consider using &lt;a href=&quot;https://github.com/GreyGnome/EnableInterrupt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;EnableInterrupt.h&lt;/code&gt;&lt;/a&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible you'll resolve your problem while changing libraries.  If so, fine.  If not, or if that library's performance isn't adequate, consider changing over to handling the  pin change interrupts more directly.  The ISR in the following sketch shown below runs several times faster than code that uses &lt;code&gt;PinChangeInt&lt;/code&gt; or &lt;code&gt;EnableInterrupt&lt;/code&gt; library calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;em&gt;Edit:&lt;/em&gt; This edit encloses the ISR in a sketch that compiles.  The code previously shown was missing two array length specifications.  This code was tested with a rotary encoder attached to A2, A3, with A0 and A1 grounded; an output sample (using an Arduino Nano) follows the code.]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  rcTiming.ino -- JW, 30 November 2015 -- &#xA; * Uses pin-change interrupts on A0-A4 to time RC pulses&#xA; *&#xA; * Ref: http://arduino.stackexchange.com/questions/18183/read-rc-receiver-channels-using-interrupt-instead-of-pulsein&#xA; *&#xA; */&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;static   byte rcOld;        // Prev. states of inputs&#xA;volatile unsigned long rcRises[4]; // times of prev. rising edges&#xA;volatile unsigned long rcTimes[4]; // recent pulse lengths&#xA;volatile unsigned int  rcChange=0; // Change-counter&#xA;&#xA;// Be sure to call setup_rcTiming() from setup()&#xA;void setup_rcTiming() {&#xA;  rcOld = 0;&#xA;  pinMode(A0, INPUT);  // pin 14, A0, PC0, for pin-change interrupt&#xA;  pinMode(A1, INPUT);  // pin 15, A1, PC1, for pin-change interrupt&#xA;  pinMode(A2, INPUT);&#xA;  pinMode(A3, INPUT);&#xA;  PCMSK1 |= 0x0F;       // Four-bit mask for four channels&#xA;  PCIFR  |= 0x02;       // clear pin-change interrupts if any&#xA;  PCICR  |= 0x02;       // enable pin-change interrupts&#xA;}&#xA;// Define the service routine for PCI vector 1&#xA;ISR(PCINT1_vect) {&#xA;  byte rcNew = PINC &amp;amp; 15;   // Get low 4 bits, A0-A3&#xA;  byte changes = rcNew^rcOld;   // Notice changed bits&#xA;  byte channel = 0;&#xA;  unsigned long now = micros(); // micros() is ok in int routine&#xA;  while (changes) {&#xA;    if ((changes &amp;amp; 1)) {  // Did current channel change?&#xA;      if ((rcNew &amp;amp; (1&amp;lt;&amp;lt;channel))) { // Check rising edge&#xA;        rcRises[channel] = now;     // Is rising edge&#xA;      } else {              // Is falling edge&#xA;        rcTimes[channel] = now-rcRises[channel];&#xA;      }&#xA;    }&#xA;    changes &amp;gt;&amp;gt;= 1;      // shift out the done bit&#xA;    ++channel;&#xA;    ++rcChange;&#xA;  }&#xA;  rcOld = rcNew;        // Save new state&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting RC Timing Test&quot;);&#xA;  setup_rcTiming();&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long rcT[4]; // copy of recent pulse lengths&#xA;  unsigned int rcN;&#xA;  if (rcChange) {&#xA;&#xA;    // Data is subject to races if interrupted, so off interrupts&#xA;    cli();          // Disable interrupts&#xA;    rcN = rcChange;&#xA;    rcChange = 0;       // Zero the change counter&#xA;    rcT[0] = rcTimes[0];&#xA;    rcT[1] = rcTimes[1];&#xA;    rcT[2] = rcTimes[2];&#xA;    rcT[3] = rcTimes[3];&#xA;    sei();          // reenable interrupts&#xA;&#xA;    Serial &amp;lt;&amp;lt; &quot;t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[0] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[1]&#xA;       &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[2] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[3] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcN &amp;lt;&amp;lt; endl;&#xA;  }&#xA;  sei();            // reenable interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code shown above uses &lt;code&gt;Streaming.h&lt;/code&gt;, a &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;noreferrer&quot;&gt;contributed library&lt;/a&gt; that adds some “syntactic sugar” to Arduino C.  That is, at compile time it converts C++-like &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; Serial stream operators to &lt;code&gt;Serial.print&lt;/code&gt; statements, without increasing code size.  If you don't have &lt;code&gt;Streaming.h&lt;/code&gt; installed, either install it via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;noreferrer&quot;&gt;arduiniana.org&lt;/a&gt; or manually translate the &lt;code&gt;Serial &amp;lt;&amp;lt; ...&lt;/code&gt; statement to &lt;code&gt;Serial.print&lt;/code&gt; statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sample of the sketch's output on serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;t=35773 0 0 14196 13456 4&#xA;t=35775 0 0 14196 13456 3&#xA;t=35778 0 0 14196 5748 4&#xA;t=35781 0 0 5244 5748 3&#xA;t=35783 0 0 5244 5748 4&#xA;t=35785 0 0 5244 5748 3&#xA;t=35786 0 0 5244 28 12&#xA;t=35788 0 0 3024 28 3&#xA;t=35789 0 0 3024 28 4&#xA;t=35792 0 0 3024 28 3&#xA;t=35796 0 0 3024 6396 4&#xA;t=35802 0 0 9316 6396 3&#xA;t=35809 0 0 9316 6396 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the output above, the two 0's are from A0, A1 being grounded and not changing.  The next two numbers are from the DT and CLK lines of a KY-040 rotary encoder, which toggle alternately to encode step-direction.  They should represent on-times in microseconds, and are always multiples of 4 because &lt;code&gt;micros()&lt;/code&gt; reports multiples of 4.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last number is the number of times the ISR's change-checking loop ran since &lt;code&gt;loop()&lt;/code&gt;'s previous print.  An A2 change will show a count of 3 or more, and an A3 change 4 or more.  Cases where times are the same may represent contact bounces shorter than the ISR's service time; ie, several falling edges in a row might be detected, or several rising edges.  A storage scope or logic analyzer probably is necessary for finding out exactly what happens.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-11-30T20:18:21.067" LastActivityDate="2015-11-30T20:18:21.067" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18222" PostTypeId="1" CreationDate="2015-11-29T03:02:55.173" Score="5" ViewCount="993" Body="&lt;p&gt;Is it safe to connect a USB input to an Arduino (Nano) at the same time as an external regulated 5V supply to its 5V pin is connected, assuming the supplies have common grounds ? Will (I hope) the external 5V be used so as to not draw too much current out of the USB supply ?&lt;/p&gt;&#xA;" OwnerUserId="15181" LastActivityDate="2015-12-01T02:31:42.630" Title="Arduino power sources" Tags="|power|usb|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18223" PostTypeId="2" ParentId="18219" CreationDate="2015-11-29T04:04:31.517" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;theyre roughly 15 cm apart&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;15cm substantially less than the time it takes to send the second device its command at 9600 baud (2 bytes, probably 20 bits counting framing, around 72 cm)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result you are likely missing the pulse, and perhaps catching some timeout, or even a cached response string from a next-to previous command which measured the previous pulse, including the time between pulses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To operate that close, you will need to either use dedicated trigger/detect wires, or start the receiver before you transmit and try to subtract the delay from the time you started the receiver until the time when you transmit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware that usage of software serial, as well as buffering of serial in general may introduce variable latency in your timestamping of the serial communications.  Ideally for something like this you would use a non-buffered implementation - the timing of serial data itself is &lt;em&gt;potentially&lt;/em&gt; precise to a fraction of the baud rate, though we don't know how it is implemented on the sensor end.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-11-29T04:04:31.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18225" PostTypeId="1" CreationDate="2015-11-29T06:10:52.667" Score="0" ViewCount="223" Body="&lt;p&gt;I am having problems with the ESP8266-01 I bought. It works at only 115200 baud rate and it gives many problems when programming with Arduino Uno. I got it flashed to 9600 baud rate, but still many times it becomes unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen many videos online that has the ESP8266 that works at 9600 by default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please tell me where I can buy the latest ESP8266 that runs at 9600 baud rate by default?&lt;/p&gt;&#xA;" OwnerUserId="15105" LastEditorUserId="4628" LastEditDate="2015-11-30T07:31:57.390" LastActivityDate="2015-11-30T07:31:57.390" Title="Suggestions for latest ESP8266 WiFi module" Tags="|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18226" PostTypeId="2" ParentId="12616" CreationDate="2015-11-29T08:21:42.067" Score="0" Body="&lt;p&gt;When an Arduino stops appearing, it is usually because it's fried. Especially if other machines appear when connected, and the faulty machine appears on no other machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;burning the bootloader&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-11-29T08:21:42.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18227" PostTypeId="1" CreationDate="2015-11-29T08:27:21.000" Score="2" ViewCount="458" Body="&lt;p&gt;I would like to implement a camera to my Arduino project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I have worked with some sensors (e.g. distance), Wifi and Bluetooth modules, buzzer etc. You can find some very good examples on the web on how to use these things on your project, from the wiring to the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when we talk about cameras, I feel like things start to be more difficult - I don't know if it's because camera users should know better what they are doing and therefore don't need a step by step guide, if simply there is a lack of information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see myself like &lt;a href=&quot;https://arduino.stackexchange.com/questions/13563/how-to-connect-new-ov7670-fifo-to-arduino&quot;&gt;this guy&lt;/a&gt; and &lt;a href=&quot;https://arduino.stackexchange.com/questions/9959/interfacing-arduino-uno-with-ov7670-with-fifo&quot;&gt;this guy&lt;/a&gt;. We just can't find a tutorial!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking forward to buy a &lt;a href=&quot;http://www.filipeflop.com/pd-721b3-camera-vga-ov7670-al422-fifo.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;VGA OV7670 AL422 FIFO&lt;/em&gt;&lt;/a&gt; camera or a &lt;a href=&quot;http://www.filipeflop.com/pd-13ab1e-camera-serial-ttl-jpeg-com-video-ntsc.html?ct=&amp;amp;p=1&amp;amp;s=1&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;em&gt;Serial TTL JPEG with NTSC video&lt;/em&gt;&lt;/a&gt;, but I don't want to spend my money on something I won't be able to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is any better camera I could buy (by better I mean an easier camera to start working and with some information for the implementation)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2017-01-02T08:28:12.807" Title="Cameras modules for my project" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ClosedDate="2017-01-02T08:29:08.907" ContentLicense="CC BY-SA 3.0" />
  <row Id="18228" PostTypeId="1" AcceptedAnswerId="18257" CreationDate="2015-11-29T08:29:56.860" Score="2" ViewCount="2690" Body="&lt;p&gt;I need your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino ProMini in my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In project board there is Atmega328P which doesn't have Arduino bootloader, and Atmega328P RXD, TXD pins are connected to FTDI Basic(sparkfun)'s TXD and RXD pins. &#xA;I searched on internet how to burn bootloader for arduino. Most of them use other Arduino's built in SPI or other method. Problem is Atmega328P is already assembled to PCB board and I cannot make any soldering or change. Atmega328 and FTDI basic are connected and assembled to upload sketch (if there is bootloader of Arduino inside of Atmega328P, no problem to upload sketch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any solution or suggestions to burn bootloader using FTDI?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You.&lt;/p&gt;&#xA;" OwnerUserId="13487" LastActivityDate="2015-11-30T02:51:02.880" Title="Atmega328P burn bootloader with FTDI" Tags="|bootloader|arduino-pro-mini|ftdi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18229" PostTypeId="2" ParentId="18222" CreationDate="2015-11-29T08:45:35.820" Score="3" Body="&lt;p&gt;From the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Nano&lt;/a&gt; at Arduino.CC:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically selected to the highest voltage source.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or, take if from the schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8MoM5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8MoM5.png&quot; alt=&quot;Nano 3 Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-11-29T08:45:35.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18230" PostTypeId="2" ParentId="18199" CreationDate="2015-11-29T08:50:37.823" Score="0" Body="&lt;p&gt;Consider something like this edit of your code.  It has two independent switch/case constructs to handle the flinging operation and the releasing operation as independent finite state machines, both subsystems configured as they switch out of the idle state based on the inPin0 or inPin1 status.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick of using fast iterations through the loops without delay() helps simulate parallel processing of finite state machines.  With this scheme, one has excess processing time and more options.  One could entangle the two processes if necessary, or add supervisory or monitoring processes that interact with the subsystems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For tuning, you could make inPin0 be a canned best cycle, and make inPin1 read and use adjustable inputs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Not tested or run...&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;Adafruit_DCMotor *DC1 = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *DC2 = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *DC3 = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *DC4 = AFMS.getMotor(4);&#xA;&#xA;Servo Servo1;&#xA;&#xA;void setup() {&#xA;  digitalWrite(A0, HIGH); //Turns on the pullup resistor for A0&#xA;  AFMS.begin(); //Initializes the motorshield board&#xA;&#xA;  int motorPin1 = 1;&#xA;  int motorPin2 = 2;&#xA;  int motorPin3 = 3;&#xA;  int motorPin4 = 4;&#xA;&#xA;  pinMode(A0, INPUT); //Sets the Analog Pin 0 as an input&#xA;  digitalWrite(A0, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  digitalWrite(A1, HIGH);&#xA;  pinMode(A1, INPUT);&#xA;  pinMode(1, OUTPUT);&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  Servo1.attach(9);&#xA;&#xA;  int inPin0 = LOW;&#xA;  int inPin1 = LOW;&#xA;  inPin0 = digitalRead(A0);&#xA;  inPin1 = digitalRead(A1);&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()  {&#xA;  static int flingState = 1; // initial state is 1, the idle state&#xA;  static int releaseState = 1; // initial state is 1, the idle state&#xA;  static unsigned long flingTime; // to store the current time in for delays&#xA;  static unsigned long releaseTime; // to store the current time in for delays&#xA;&#xA;  int MAXampDrawTime;&#xA;  int MAXampDrawSpeed;&#xA;  int NORMampDrawTime;&#xA;  int NORMampDrawSpeed;&#xA;  int servoTime = 450;&#xA;  int inPin0 = LOW;&#xA;  int inPin1 = LOW;&#xA;  int DrawTime;&#xA;  inPin0 = digitalRead(A0);&#xA;  inPin1 = digitalRead(A1);&#xA;&#xA;  switch (flingState) {  // manage flinging&#xA;    case 1:  // idle state&#xA;      if (inPin0 == HIGH) {  // config for maxthrow&#xA;         MAXampDrawTime = 500;&#xA;         MAXampDrawSpeed = 20;&#xA;         NORMampDrawTime = 250;&#xA;         NORMampDrawSpeed = 10;&#xA;         DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;         flingState = 2;&#xA;      }&#xA;      if (inPin1 == HIGH) {  // config for accThrow&#xA;        MAXampDrawTime = 1000;&#xA;        MAXampDrawSpeed = 20;&#xA;        NORMampDrawTime = 750;&#xA;        NORMampDrawSpeed = 10;&#xA;        DrawTime = MAXampDrawTime + NORMampDrawTime;&#xA;        flingState = 2;&#xA;      }&#xA;      break;&#xA;&#xA;    case 2: // start fling oneshot&#xA;        flingTime = millis();&#xA;        dcMoveConst(MAXampDrawSpeed, 1);&#xA;        dcMoveConst(MAXampDrawSpeed, 2);&#xA;        dcMoveConst(MAXampDrawSpeed, 3);&#xA;        dcMoveConst(MAXampDrawSpeed, 4);&#xA;        flingState = 3;&#xA;        break;&#xA;    case 3: // maxFlinging timer&#xA;        if (millis() - flingTime &amp;gt; MAXampDrawTime) flingState =4;&#xA;        break;&#xA;    case 5: // initiate slower Flinging oneshot &#xA;        dcMoveConst(NORMampDrawSpeed, 1);&#xA;        dcMoveConst(NORMampDrawSpeed, 2);&#xA;        dcMoveConst(NORMampDrawSpeed, 3);&#xA;        dcMoveConst(NORMampDrawSpeed, 4);&#xA;        flingState = 5;&#xA;        break;&#xA;    case 6: // drawing timer&#xA;        if (millis() - flingTime &amp;gt; MAXampDrawTime + NORMampDrawTime) &#xA;            flingState = 7;&#xA;        break;&#xA;    case 7 : // s_turnoff:&#xA;      dcRelease(1);&#xA;      dcRelease(2);&#xA;      dcRelease(3);&#xA;      dcRelease(4);&#xA;      flingState = 1;&#xA;      break;&#xA;&#xA;  } // end flingState Machine&#xA;&#xA;&#xA;  switch (releaseState) {  // independently manage the release servo&#xA;    case 1:  // idle&#xA;      if (inPin0 == HIGH) {servoTime=450; releaseState = 2;}&#xA;      if (inPin1 == HIGH) {servoTime=450; releaseState = 2;}&#xA;      break;&#xA;    case 2:  // start holding oneshot&#xA;      releaseTime = millis();&#xA;      releaseState =3;&#xA;      break;&#xA;    case 3: // holding timer&#xA;      if (millis() -releaseTime &amp;gt; servoTime) releaseState = 4;&#xA;      break;&#xA;    case 4: // releasing oneshot&#xA;        Servo1.write(0);&#xA;        releaseState = 5;&#xA;        break;&#xA;    case 5: //released timer&#xA;        if (millis() - releaseTime &amp;gt; servoTime+400) {&#xA;             Servo1.write(90);&#xA;             releaseState = 1; // back to idle&#xA;        }&#xA;        break;&#xA;    } // end releaseState machine&#xA;      // if (millis()%100 ==0) reportState(flingState,releaseState);  &#xA;  } // end loop     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-11-29T08:50:37.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18231" PostTypeId="1" AcceptedAnswerId="18233" CreationDate="2015-11-29T10:19:28.513" Score="3" ViewCount="492" Body="&lt;p&gt;My code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin = 8;&#xA;int pout = 12;&#xA;int result=0;&#xA;void setup() {&#xA;  pinMode(pin, INPUT);&#xA;  pinMode(pout, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  result = digitalRead(pin);&#xA;&#xA;  if(result == 1)&#xA;  {&#xA;    digitalWrite(pout, HIGH); &#xA;    delay(1000);&#xA;  }&#xA;  if(result == 0)&#xA;  { &#xA;    digitalWrite(pout, LOW); &#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have set delay 1 sec but whenever i put high voltage on pin 8 The LED glow for 5 second. why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to set delay to none ? means whenever the pin 8 is HIGH the LED will glow else off.&lt;/p&gt;&#xA;" OwnerUserId="15187" LastEditorUserId="15187" LastEditDate="2015-11-29T10:56:01.130" LastActivityDate="2015-11-29T11:32:50.143" Title="Why LED light delay is 5 second in arduino?" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18232" PostTypeId="1" CreationDate="2015-11-29T10:56:48.423" Score="1" ViewCount="560" Body="&lt;p&gt;I am working on a project which uses an Arduino board. Currently I am testing my device using 2-phase power and it works fine.  I want to use that device in agriculture fields where 3-phase power is available instead. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="15188" LastEditorUserId="3917" LastEditDate="2015-11-29T20:49:11.403" LastActivityDate="2015-11-29T20:49:11.403" Title="How can I power an Arduino in a 3-phase environment?" Tags="|arduino-uno|power|voltage-level|current|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18233" PostTypeId="2" ParentId="18231" CreationDate="2015-11-29T11:32:50.143" Score="6" Body="&lt;p&gt;The problem (likely) isn't in your code. You need to include a pull-down resistor in your electronics, so that when you remove the &quot;high voltage&quot; the residual charge stored in the pin due to its capacitance can be drained. Alternatively you can use the internal pull-up resistors, but then you'd need to invert the logic of the pin (high becomes low and vice versa) and instead of connecting &quot;high voltage&quot; you'd need to connect ground to activate the LED.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-11-29T11:32:50.143" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18235" PostTypeId="2" ParentId="18225" CreationDate="2015-11-29T11:52:57.617" Score="1" Body="&lt;p&gt;No, I'm afraid we can't, since we're not ESP8266 salesmen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I would seriously recommend not using an Arduino to communicate with the ESP8266 but instead to program the ESP8266 directly so you don't have any communication worries.  If you want to add an Arduino into the mix at a later date for its enhanced IO capabilities, then feel free to do so - where you can then implement your own serial protocol at whatever baud rate you like (or other protocol even - SPI? I2C?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need is: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Arduino core for the ESP8266: &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Some form of USB serial adapter (eg FT232 breakout board).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The controller chip on the ESP8266 is considerably more powerful than the Arduino's chip, and the fact that many people insist on using the ESP8266 as a slave device to the lower powered Arduino always seems completely backward to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want an easier board to program that messing with breakout boards you can do a lot worse than investing in a NodeMCU board. Make sure you go for the version 1 not the version 0.9 since the version 1 has a slightly more enhanced chip on it with more IO facilities than the version 0.9.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-29T11:52:57.617" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18237" PostTypeId="2" ParentId="18001" CreationDate="2015-11-29T15:30:02.850" Score="1" Body="&lt;p&gt;It looks like you're trying to send a custom message to arduino and have it respond. As a small add on to your code try serialCommand. It pulls in whatever you send over the command line and executes it as a command and returns whatever you need to whatever interface you gave such as softwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/scogswell/ArduinoSerialCommand/tree/master/examples&quot; rel=&quot;nofollow&quot;&gt;https://github.com/scogswell/ArduinoSerialCommand/tree/master/examples&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I offer that you could use the two together to get the results you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let serialCommand listen for commands and execute them and then set up a listener in Java for any serial communication back from the unit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's more or less what I end up doing when it comes to bluetooth, rf24, and wifi anyway, so why not serial as well. &lt;/p&gt;&#xA;" OwnerUserId="15133" LastActivityDate="2015-11-29T15:30:02.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18238" PostTypeId="2" ParentId="18225" CreationDate="2015-11-29T15:39:59.743" Score="1" Body="&lt;p&gt;Here's the other bit of it that most people don't understand on their first try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything that plugs into an arduino is not a slave device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case both this module and the hc-05 and hc-06 are standalone and actually &lt;strong&gt;HAVE THEIR OWN SOFTWARE&lt;/strong&gt; on them. These chips are fully functional without arduino and you can send commands to them directly or by using the arduino as a dummy chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So at the end of the day to get your project working you should interface with the device directly instead of passing it through arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your device most likely isn't busted so don't worry about constantly flashing between versions. You probably just need to configure it using AT+ commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a pdf of AT+ commands&#xA;&lt;a href=&quot;https://www.google.com/urlhttps://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&amp;amp;ved=0ahUKEwjXmJWb_bXJAhVHKCYKHR6gDcIQFggcMAE&amp;amp;usg=AFQjCNGkMIRnc2C3uzlIlXCZ1seaiRgXmQ&amp;amp;sig2=AAPvKqWZl44dDPV86lzxUA&quot; rel=&quot;nofollow&quot;&gt;Download pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a quickstart guide that includes pictures and order of commands. Don't fry your boards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.google.com/urlhttps://www.google.com/url?sa=t&amp;amp;source=web&amp;amp;rct=j&amp;amp;url=http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&amp;amp;ved=0ahUKEwjXmJWb_bXJAhVHKCYKHR6gDcIQFggcMAE&amp;amp;usg=AFQjCNGkMIRnc2C3uzlIlXCZ1seaiRgXmQ&amp;amp;sig2=AAPvKqWZl44dDPV86lzxUA&quot; rel=&quot;nofollow&quot;&gt;Download pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that's done serialCommand amd software serial are pretty easy to use. Look at the serialCommand examples to see how it's done. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/scogswell/ArduinoSerialCommand/tree/master/examples/SerialCommandExampleSoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial example using serialCommand&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-11-29T15:50:30.900" LastActivityDate="2015-11-29T15:50:30.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18239" PostTypeId="2" ParentId="18153" CreationDate="2015-11-29T15:58:03.960" Score="3" Body="&lt;p&gt;I've got an idea. Your board isn't being recognized. Try unplugging the arduino and see if Com 1 is still there. Sometimes it can recognize mice and other devices as Com 1 or 2 instead of your arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On some of my development machines after everything settled out my devices will show up on Com 4 and 5 when I am working on two at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not the case go into the device manager and see if you can see the board listed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also wonder if you have your sensor hooked to digital pins 0 and 1. These pins are used for your serial line on usb. So if you have anything such as a sensor hooked to them it may be generating data keeping the line busy instead of it being able to negotiate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had this happen when setting up hc-05 for the first time. I realized I had to keep the chip off while flashing or I would end up with errors or Com busy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please provide your pinout and basic information about the Com ports available on the ide. Also consider that you will need to specify the correct board as it will default to an uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programmer not in sync issues generally occur because the board is recognized but cannot be written to for one reason or another.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the board has something plugged into digital 1 and 0 which are serial i/o pins&lt;/li&gt;&#xA;&lt;li&gt;the board programmer is busy running your last batch of code&lt;/li&gt;&#xA;&lt;li&gt;usb error&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;try a different cord&lt;/li&gt;&#xA;&lt;li&gt;try unplugging potential wiring issues and see if it can be written to without anything on it&lt;/li&gt;&#xA;&lt;li&gt;try holding down reset on the board until the board when you try to write to it until just after it finishes compiling to clear any potential programing issues&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my experience mega have a tendency to suffer from the last one. &lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-12-06T15:49:58.293" LastActivityDate="2015-12-06T15:49:58.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18240" PostTypeId="2" ParentId="18126" CreationDate="2015-11-29T16:07:20.690" Score="1" Body="&lt;p&gt;I don't use .net but I have done this using php website to control a door lock over ethernet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution was to use the ethernet to recieve commands and be able to use them on the arduino through http calls. And when it was done send a http call back to the server with some data. I was doing a door lock program for example. Please ignore anything talking about doors, locking, unlocking, or other requirements to certain calls, I am just providing examples about how it COULD be used, not that you need to include my door lock code in your project to get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as how that works out with .net that's up to you, however I can give you a hand getting your messages back and forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first you want to create the ethernet connection to your router. put this in your header section.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;UIPEthernet.h&amp;gt;&#xA;// assign a MAC address for the ethernet controller.&#xA;// fill in your address here:&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;&#xA;// fill in an available IP address on your network here,&#xA;// for manual configuration:&#xA;IPAddress ip(127, 0, 0, 1);&#xA;&#xA;// initialize the library instance:&#xA;EthernetClient client;&#xA;&#xA;char server[] = &quot;www.example.com&quot;;&#xA;//IPAddress server(127,0,0,1);  // numeric IP for www.example.com (no DNS)&#xA;&#xA;int waitTime = 3L;&#xA;&#xA;unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds&#xA;const unsigned long postingInterval = waitTime * 1000L; // delay between updates, in milliseconds&#xA;// the &quot;L&quot; is needed to use long type numbers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;throw this in your main loop so it doesn't constantly make http requests spamming a server.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// if ten seconds have passed since your last connection,&#xA;// then connect again and send data:&#xA;if (millis() - lastConnectionTime &amp;gt; postingInterval || buttonState == 0) {&#xA;  httpRequest();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Create a method to handle httpRequest because shoving everything under the main is kinda sloppy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alright so there will be quite a bit here because http headers are kinda lengthy.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// this method makes a HTTP connection to the server:&#xA;void httpRequest() {&#xA;  // close any connection before send a new request.&#xA;  // This will free the socket on the WiFi shield&#xA;  client.stop();&#xA;  // if there's a successful connection:&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;    // send the HTTP PUT request:&#xA;  Serial.println(&quot;String is &quot; + readString);&#xA;  if(readString == &quot;Ready&quot; || readString == &quot;&quot;){  &#xA;    client.println(&quot;GET /command.txt HTTP/1.1&quot;);&#xA;    where = &quot;web&quot;;&#xA;    waitTime = 5L;&#xA;  }&#xA;  else{&#xA;    // here is the basic format of sending a get command&#xA;    //this specific request is so that I can tell where the command came from. I had a web client / mobile app that could control the door AND you could also control it from a physical buttom. The door would have to reply either way to the web server (READ: .net application) in order to have the correct status always show up on the web end.&#xA;&#xA;    client.print(&quot;GET /update.php?where=Arduino&amp;amp;command=Ready&amp;amp;status=&quot;);&#xA;    if(readString == &quot;Reset&quot;){&#xA;      client.print(&quot;Reset&quot;);&#xA;    }&#xA;    else if(isLocked){&#xA;      client.print(&quot;Locked&quot;);&#xA;    }&#xA;    else{&#xA;      client.print(&quot;Unlocked&quot;);&#xA;    }&#xA;    client.println(&quot; HTTP/1.1&quot;);&#xA;    waitTime = 1L;&#xA;  }&#xA;  client.println(&quot;Host: www.example.com&quot;);&#xA;  client.println(&quot;User-Agent: arduino-ethernet&quot;);&#xA;  client.println(&quot;Connection: close&quot;);&#xA;  client.println();&#xA;&#xA;    // note the time that the connection was made:&#xA;    lastConnectionTime = millis();&#xA;  }&#xA;  else {&#xA;    // if you couldn't make a connection:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;TL;DR if you wanna use ethernet you need to use all of ethernet.&#xA;Start by creating your connection to the router statically (watch for conflicts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then create a method of watching for incoming data or waiting for a command if there isn't one. (server call).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then create A FULL HTTP REQUEST in order to pass your request through. Shorting any parts of this last part and you will either end up with bad request errors or will simply fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if you need anything else or if this was useful to you!&lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-11-29T16:38:01.233" LastActivityDate="2015-11-29T16:38:01.233" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18242" PostTypeId="2" ParentId="18018" CreationDate="2015-11-29T18:15:43.870" Score="3" Body="&lt;p&gt;Potting of circuits can lead to various issues. It can't be told exactly what caused your device to fail until you uncover it like an archeologist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Common problems are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Resin entering a spring loaded contact and canceling out contact forces&lt;/li&gt;&#xA;&lt;li&gt;Resin exsuding corrosive substances ruining contacts&lt;/li&gt;&#xA;&lt;li&gt;Resin expanding during curing and opening spring contacts or even breaking up solder contacts&lt;/li&gt;&#xA;&lt;li&gt;Same effect after cool down of resin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Later and often unexpected problems are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;thin gaps around potted objects (i.e. no surface contact) literally sucking in water. &lt;/li&gt;&#xA;&lt;li&gt;potting material producing water itself during curing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Many of these problems can be circumvented by applying conformal coating, as suggested by comments and apparently proven right by your experiments. &#xA;If it is not necessary refrain from using sockets and solder connections directly to the components. You won't be able to salvage them, anyway.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2015-11-29T18:15:43.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18243" PostTypeId="2" ParentId="18153" CreationDate="2015-11-29T18:35:44.043" Score="0" Body="&lt;p&gt;Simple solution:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close the arduino application and start again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if still the issue persist restart your system. :)&lt;/p&gt;&#xA;" OwnerUserId="15187" LastActivityDate="2015-11-29T18:35:44.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18244" PostTypeId="2" ParentId="18232" CreationDate="2015-11-29T19:00:02.407" Score="3" Body="&lt;p&gt;The very short answer is that the Arduino board itself is designed to be powered by low-voltage DC (but you almost certainly already know this). So what you're really asking, I think, is &quot;can you use the mains power supply that converts mains AC to DC on a three-phase supply?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to that is a guarded yes. You will need to confirm that you are connecting to a single phase (basically what you were doing in testing) and that the voltage is appropriate for your power adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The abridged version of the gory details follows…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Three-phase supplies are almost always used for motor or other power applications – for a low power device like an Arduino (or even lighting or small appliances) you don't typically need three-phase. What is usually done is to take the power supply for those devices either from phase-to-neutral or phase-to-phase – depending on the configuration of the three-phase supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wikipedia has an article on &lt;a href=&quot;https://en.wikipedia.org/wiki/Three-phase_electric_power&quot; rel=&quot;nofollow&quot;&gt;three-phase power&lt;/a&gt; that explains the common connection schemes (Y or star where the three phases are wired to a common point, and delta where they are wired in a triangle). What is significant is that you will typically get a high and a low voltage depending on how you connect to a three-phase system. For example in the US a common Y three-phase service will give you 120 V phase-to-neutral and 208 V phase-to-phase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A true 3-phase (as in needs to connect to all three phases) low-voltage power supply will probably be quite expensive. But you also don't need one. Unless you are building an &quot;industrial&quot; device all you need is a &quot;normal&quot; low-voltage power supply that is designed for the voltage that you'll be connecting it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need to do is to confirm the voltage that you'll be using and check that your power supply is rated for it. Many low voltage supplies are designed to be &quot;universal&quot; and you'll see a rating like 100-240 V, 50-60 Hz. That's likely to work on most three-phase supplies as long as the connection isn't phase-to-phase in a part of the world where the high voltage is in the 400 V range.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-11-29T19:51:45.320" LastActivityDate="2015-11-29T19:51:45.320" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18245" PostTypeId="1" CreationDate="2015-11-29T19:43:17.823" Score="0" ViewCount="341" Body="&lt;p&gt;My RFduino dev kit just arrived, and for my project I have to connect a few RFduinos via Bluetooth and light up certain LEDs attached to the RFduinos. If anyone could point me in the right direction as to where I can program them/how I can connect them, it would be GREATLY appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15197" LastEditorUserId="4628" LastEditDate="2015-12-04T14:38:47.323" LastActivityDate="2016-02-02T16:53:18.790" Title="How can I program RFduinos and how can I connect them with Bluetooth?" Tags="|bluetooth|communication|ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18246" PostTypeId="2" ParentId="18209" CreationDate="2015-11-29T20:23:24.703" Score="0" Body="&lt;p&gt;In addition to the answer given on this site, I had to do some reading up on what bit-wise operations are and how they are useful.  I did most of that reading on the Arduino website reference section.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also stumbled across an online tech blog that actually dissected the inner workings of this program!  The blog's author seemed glad to help Arduino beginners who got this kit, but had trouble understanding how exactly the robot moved in response to the sensor data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.joestechblog.com/2014/07/10/makeit-robotics-starter-kit/&quot; rel=&quot;nofollow&quot;&gt;JoesTechBlog&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone even asked the blog's author about why anyone would code the logic in this manner.  I too was wondering the same as to why it wasn't done at a higher (thus easier to understand level).  Below is the author's response to that question.  Can anyone here comment on it in terms of its veracity?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hello Richard, Yes I agree this logic is non-intuitive. I would have done the &gt;logic on the mirco-controller, that lives on the driver board, and just had &gt;the read_Optical() method return a 0, 1, 2, or 3. But there is one possible &gt;reason for this logic. Performing bitwise operations in most cases takes up &gt;less CPU cycles than complex number comparisons. Since Radio Shack is not &gt;providing us the source code that runs on the driver board. Then we can only &gt;guess. Also sometimes bare metal programmers think in these terms, which may &gt;seem non-intuitive at times, but the more we start working at the bit level &gt;the more it makes sense.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Thanks for the post.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Joe&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10203" LastActivityDate="2015-11-29T20:23:24.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18247" PostTypeId="1" AcceptedAnswerId="18249" CreationDate="2015-11-29T21:58:13.170" Score="3" ViewCount="778" Body="&lt;p&gt;This is my first post. Please excuse me if this is a repost, but I couldn't find a similar question via search. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some experience with Arduino and I'm looking to utilize AVR's sleep mode in a project. I followed along with this tutorial &lt;a href=&quot;http://donalmorrissey.blogspot.com/2011/11/sleeping-arduino-part-4-wake-up-via.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. However, when I modify the code as follows, the uC seems to wait 4.09 seconds before waking up the first time. After that, it wakes up repeatedly (about every 6 milliseconds). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my mind, the Arduino should enter sleep mode and not wake until the timer interrupt wakes it every 4.09 seconds (and then repeats and sleeps again). When I add a delayMicroseconds() after each wake up, it seems to function correctly. I want to accomplish &lt;em&gt;sleep until interrupt wakes, perform interrupted action, then go back to sleep.&lt;/em&gt; What's going on? Am I missing something obvious? Is the Serial.println() causing an interrupt that wakes the uC right as it enters sleep?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;&#xA;ISR(TIMER1_OVF_vect)&#xA;{&#xA; //do nothing  &#xA;}&#xA;&#xA;&#xA;void enterSleep(void)&#xA;{&#xA;  set_sleep_mode(SLEEP_MODE_IDLE);&#xA;&#xA;  sleep_enable();&#xA;&#xA;&#xA;  /* Disable all of the unused peripherals. This will reduce power&#xA;   * consumption further and, more importantly, some of these&#xA;   * peripherals may generate interrupts that will wake our Arduino from&#xA;   * sleep!&#xA;   */&#xA;  power_adc_disable();&#xA;  power_spi_disable();&#xA;  power_timer0_disable();&#xA;  power_timer2_disable();&#xA;  power_twi_disable();  &#xA;&#xA;  /* Now enter sleep mode. */&#xA;  sleep_mode();&#xA;&#xA;  /* The program will continue from here after the timer timeout*/&#xA;  sleep_disable(); /* First thing to do is disable sleep. */&#xA;&#xA;  /* Re-enable the peripherals. */&#xA;  power_all_enable();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  /*** Configure the timer.***/&#xA;&#xA;  /* Normal timer operation.*/&#xA;  TCCR1A = 0x00; &#xA;&#xA;  /* Clear the timer counter register.&#xA;   * You can pre-load this register with a value in order to &#xA;   * reduce the timeout period, say if you wanted to wake up&#xA;   * ever 4.0 seconds exactly.&#xA;   */&#xA;  TCNT1=0x0000; &#xA;&#xA;  /* Configure the prescaler for 1:1024, giving us a &#xA;   * timeout of 4.09 seconds.&#xA;   */&#xA;  TCCR1B = 0x05;&#xA;&#xA;  /* Enable the timer overlow interrupt. */&#xA;  TIMSK1=0x01;&#xA;  while(!Serial);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    enterSleep();&#xA;    Serial.println(&quot;Waking&quot;);&#xA;    //delayMicroseconds(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2015-11-29T23:36:46.873" Title="Why does my Arduino keep waking up?" Tags="|arduino-uno|interrupt|avr|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18248" PostTypeId="1" CreationDate="2015-11-29T22:15:54.640" Score="2" ViewCount="169" Body="&lt;p&gt;I'm new to Arduino and have little programming experience apart from my computer science degree.  I used C++ for some projects in my degree but am barely proficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first project is relatively complex process control for an Arduino beginner and I've quickly become frustrated with the Arduino IDE which seems to be a common problem.  I've installed Visual Studio with the Visual Micro plugin (Win7) but I'm getting compile problems.  I have successfully built a data logging sensor array both in Arduino IDE and Visual Studio in Win7, but as I'm trying to add complexity I'm experiencing difficulties.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this recommendation on &lt;a href=&quot;http://www.gammon.com.au/forum/bbshowpost.php&quot; rel=&quot;nofollow&quot;&gt;Gammon Forum&lt;/a&gt; for use with the Arduino IDE to achieve a standard C++ build environment but it's not working in the visual studio environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Files contained in &quot;EmptySketch&quot; project folder:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;EmptySketch.ino&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//beginning EmptySketch.ino&#xA;//end EmptySketch.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;TestSketch.cpp&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//beginning TestSketch.cpp&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Hello&quot;);&#xA;  Serial.flush();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;}&#xA;//end TestSketch.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I create a project in Arduino IDE this compiles, uploads and runs with the expected output, but when I open &lt;code&gt;EmptySketch.ino&lt;/code&gt; in VS it builds, uploads but gives no output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me with this approach or should I simply upload my real project using a conventional &lt;code&gt;.ino&lt;/code&gt; which won't compile and ask for help with that? &lt;/p&gt;&#xA;" OwnerUserId="15202" LastEditorUserId="19409" LastEditDate="2016-04-27T17:55:48.740" LastActivityDate="2016-04-27T17:55:48.740" Title="Arduino IDE Visual Studio and compile problems blank project .ino hack" Tags="|compile|build|visualstudio|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18249" PostTypeId="2" ParentId="18247" CreationDate="2015-11-29T23:31:37.283" Score="3" Body="&lt;p&gt;Yes.  Arduino's buffered serial output is interrupt-based, in that it uses interrupts to refill the UART transmit register when it runs empty, until the software-managed transmit buffer has been drained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot put the ATmega back to &quot;lasting&quot; sleep until the last byte of the serial transmission has been written to the UART hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the goal of your serial output is only debug, it might be simplest to shorten it to a single character and either send that directly or wait long enough that it should have sent.  If you want to keep the full message, it may take exploration of the Arduino source code to figure out how to determine when the transmission is done.  A simpler, if cruder option might be to just keep going back to sleep until a readback of the counter indicates that your intended sleep is over.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-11-29T23:36:46.873" LastActivityDate="2015-11-29T23:36:46.873" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18250" PostTypeId="2" ParentId="18194" CreationDate="2015-11-29T23:56:49.963" Score="1" Body="&lt;p&gt;If it's a new nano is probably the new version which has the 328 processor. Try switching to that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also does your computer make the windows &quot;I just plugged something in&quot; sound when you connect? Is the driver recognized?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this instead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set Board to Arduino Nano&#xA;Set Processor to ATmega328&#xA;Set port to COM2 or any other device if recognized. Test to see if the Com1 stays if you unplug it. Try other usb ports as well. &lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-11-30T00:05:03.623" LastActivityDate="2015-11-30T00:05:03.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18251" PostTypeId="2" ParentId="6769" CreationDate="2015-11-30T00:22:33.140" Score="1" Body="&lt;p&gt;I recently purchased the arduinotech module learning Kit and contains both components shown above. It does  mention an Infrared Photo Diode which it think is your &quot;Black LED&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the heads up on the HDX switches. Now I know what they are.:)&lt;/p&gt;&#xA;" OwnerUserId="15207" LastActivityDate="2015-11-30T00:22:33.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18252" PostTypeId="2" ParentId="17237" CreationDate="2015-11-30T00:41:48.987" Score="0" Body="&lt;p&gt;Can't really help as I have the same problem ! , DHT22 on an ESP8266 has failed twice , while a DHT11 on a similar system has worked faultlessly for months (Thingspeak 27272) , DHT11 is inside the house while the DHT22 is below the house in the carport, Only thing I have come up with is that the DHT22 MAY be failing due to exhaust/hydrocarbon fumes from the car startups &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Art &lt;/p&gt;&#xA;" OwnerUserId="15208" LastActivityDate="2015-11-30T00:41:48.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18255" PostTypeId="1" AcceptedAnswerId="18573" CreationDate="2015-11-30T01:38:56.600" Score="3" ViewCount="123" Body="&lt;p&gt;Since &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow&quot;&gt;inotool&lt;/a&gt; is dead, I'm trying to transition over to Arduino's built-in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;nofollow&quot;&gt;command line tool&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems largely equivalent, but the one feature it seems to be missing is a serial interface. e.g. Running &lt;code&gt;ino serial&lt;/code&gt; would open a simple serial interface to the Arduino, providing invaluable debugging info from any Serial.print() statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is this accomplished with the current Arduino command line tool?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-12-09T22:12:04.840" Title="Connecting via serial with Arduino comand line" Tags="|serial|command-line|ino|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18256" PostTypeId="1" CreationDate="2015-11-30T01:48:24.207" Score="2" ViewCount="167" Body="&lt;p&gt;Hello Stack Exchange Community!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an arduino project I am working on, I modify the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 to support DSSCircuit's I2C Master Library (&lt;a href=&quot;https://github.com/DSSCircuits/I2C-Master-Library&quot; rel=&quot;nofollow&quot;&gt;https://github.com/DSSCircuits/I2C-Master-Library&lt;/a&gt;). This is to combat the known issue of arduino's Wire library to often get hung up while trying to run the EndTransmission function, and it works some of the time. Code was from Stack Exchange community (&lt;a href=&quot;https://arduino.stackexchange.com/questions/18023/modifying-arduino-imu-library-to-rely-on-dsscircuits-i2c-master-library&quot;&gt;Modifying Arduino IMU library to rely on DSSCircuit&amp;#39;s I2C Master Library&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;I2C.h&amp;gt;&#xA;#include &quot;FIMU_ADXL345.h&quot;&#xA;&#xA;ADXL345 acc = ADXL345();&#xA;int x=0,  y=0, z=0;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  I2c.begin();&#xA;  delay(100);&#xA;  acc.init(ADXL345_ADDR_ALT_LOW);&#xA;  delay(100);&#xA;  Serial.print(&quot;Is ACC OK?: &quot;);&#xA;  Serial.println(acc.status);&#xA;  Serial.print(&quot;Any Error code?: &quot;);&#xA;  Serial.println(acc.error_code);&#xA;  Serial.println(&quot;********Print all register current values********&quot;);&#xA;  acc.printAllRegister();&#xA;  Serial.println(&quot;********END register print******&quot;);&#xA;  Serial.println(acc.getRate());&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  acc.readAccel(&amp;amp;x,&amp;amp;y,&amp;amp;z);&#xA;  Serial.print(x);&#xA;  Serial.print('\t');&#xA;  Serial.print(y);&#xA;  Serial.print('\t');&#xA;  Serial.println(z);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 libraries must be modified from using Wire.h to I2C.h . &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Writes val to address register on device&#xA;void ADXL345::writeTo(byte address, byte val) {&#xA;  I2c.write((uint8_t) _dev_address, (uint8_t) address, (uint8_t) val);&#xA;}&#xA;&#xA;// Reads num bytes starting from address register on device in to _buff array&#xA;void ADXL345::readFrom(byte address, int num, byte _buff[]) {&#xA;  I2c.read((uint8_t) _dev_address, (uint8_t) address, (uint8_t) num);  // request 6 bytes from device&#xA;  if(I2c.available() != num){  // device may send less than requested (abnormal)&#xA;    status = ADXL345_ERROR;&#xA;    error_code = ADXL345_READ_ERROR;&#xA;  }&#xA;&#xA;  int i = 0;&#xA;  while(I2c.available())         &#xA;  {&#xA;    _buff[i] = I2c.receive();    // receive a byte&#xA;    i++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using an arduino shield, and it prevents me from uploading the code at the same time as the shield is on. My best guess is that the shield is continually triggering the device to restart in a way that does not harm performance but harms upload of code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 8,244 bytes (25%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 600 bytes (29%) of dynamic memory, leaving 1,448 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open the serial port and let it run for a few seconds, it shows no current register values, and returns 0 for x y -- as expected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Is ACC OK?: 1&#xA;Any Error code?: 0&#xA;********Print all register current values********&#xA;0x00: B00000000&#xA;0x1D: B00000000&#xA;0x1E: B00000000&#xA;0x1F: B00000000&#xA;0x20: B00000000&#xA;0x21: B00000000&#xA;0x22: B00000000&#xA;0x23: B00000000&#xA;0x24: B00000000&#xA;0x25: B00000000&#xA;0x26: B00000000&#xA;0x27: B00000000&#xA;0x28: B00000000&#xA;0x29: B00000000&#xA;0x2A: B00000000&#xA;0x2B: B00000000&#xA;0x2C: B00000000&#xA;0x2D: B00000000&#xA;0x2E: B00000000&#xA;0x2F: B00000000&#xA;0x30: B00000000&#xA;0x31: B00000000&#xA;0x32: B00000000&#xA;0x33: B00000000&#xA;0x34: B00000000&#xA;0x35: B00000000&#xA;0x36: B00000000&#xA;0x37: B00000000&#xA;0x38: B00000000&#xA;0x39: B00000000&#xA;********END register print******&#xA;0.10&#xA;0   0   0&#xA;0   0   0&#xA;0   0   0&#xA;0   0   0&#xA;0   0   0&#xA;0   0   0&#xA;0   0   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is, when the arduino shield is put on during serial transmission the loop will stop, and the device will stop outputting any information to serial even if the shield is taken off. This also usually disallows the uploading of new code even if the shield is off, and the only solution I've found to sometimes work is waiting a few minutes, disconnecting the arduino from computer to kill its power source, and restart the arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me understand why this happens?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks Community!&#xA;John Doe&lt;/p&gt;&#xA;" OwnerUserId="15028" LastActivityDate="2015-11-30T01:48:24.207" Title="Using arduino shield seems to break serial.print and uploading new code?" Tags="|arduino-uno|serial|uploading|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18257" PostTypeId="2" ParentId="18228" CreationDate="2015-11-30T02:51:02.880" Score="1" Body="&lt;p&gt;You cannot upload the bootloader through the ATmega's UART pins.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps the the necessary pins (SPI &amp;amp; reset) are broken out on your board, and if not you may be able to tap them with some fine hookup wire long enough for the task as long as there are no conflicting peripherals connected to them which you cannot temporarily disable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you may just have to desolder the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical FTDI serial adapter is not the right tool for loading a bootloader either - it might at a stretch be adapted to very slowly toggling the ISP pins but the usual choices, such as an ISP programmer or another arduino with an ISP sketch on it will require far less effort on your part. &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-11-30T02:51:02.880" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18258" PostTypeId="1" CreationDate="2015-11-30T03:53:51.670" Score="0" ViewCount="159" Body="&lt;p&gt;How do you install an Arduino library so it's only available for a specific project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say I have a codebase located at /myproject, and I want to install libraries at /myproject/lib/somelib. I can't find how to make &lt;code&gt;arduino myproject.ino&lt;/code&gt; find the libraries under ./lib.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling &quot;installing Arduino libraries&quot; only finds me examples of &lt;a href=&quot;https://www.arduino.cc/en/Guide/Libraries&quot; rel=&quot;nofollow&quot;&gt;installing libraries globally&lt;/a&gt; (and through the GUI no less), which is horrible practice and guarantees version conflicts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I used &lt;code&gt;ino&lt;/code&gt;, it supported a local ./lib directory, but I can't find any equivalent feature in &lt;code&gt;arduino&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-11-30T16:25:28.420" Title="How to install a library for a single project" Tags="|library|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18259" PostTypeId="1" CreationDate="2015-11-30T04:29:26.773" Score="2" ViewCount="685" Body="&lt;p&gt;I am using an ATtiny85 for making a smart watch. Bluetooth module HC-05 with ATtiny85 pins PB3-&gt;TX, PB4-&gt;RX and it works. Secondly I have connected a 0.96&quot; OLED on PB0 (SDA) and PB2 (SCL) and this is also working perfectly. But once I combine both things, it doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="15214" LastEditorUserId="4628" LastEditDate="2015-11-30T06:30:54.523" LastActivityDate="2015-11-30T06:30:54.523" Title="ATtiny85 + HC-05 + Oled = smart watch" Tags="|i2c|softwareserial|attiny|hc-05|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18260" PostTypeId="2" ParentId="18245" CreationDate="2015-11-30T04:53:40.643" Score="1" Body="&lt;p&gt;I am starting on a similar project (without the Dev Kit).  Hooking the Bluetooth module to the RFduino is pretty straight forward, PWR to PWR, GND to GND, remember to cross the transmission wires: TX to RX &amp;amp; RX to TX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;void setup()&lt;/code&gt;, you need to start the connection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600); // check your documentation to see the baud rate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your &lt;code&gt;void loop()&lt;/code&gt;, read or write to/from the bluetooth connection with serial write/read. &lt;code&gt;Serial.read()&lt;/code&gt; or &lt;code&gt;Serial.write()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that Bluetooth is a communication protocol, not a controller.  You don't mention WHAT you are connecting your RFduinos to using Bluetooth. You still need a controller capable of sending a signal to light up the LEDs using Bluetooth.  &lt;/p&gt;&#xA;" OwnerUserId="15213" LastEditorUserId="6936" LastEditDate="2016-01-03T16:42:41.127" LastActivityDate="2016-01-03T16:42:41.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18261" PostTypeId="2" ParentId="4976" CreationDate="2015-11-30T07:48:36.537" Score="1" Body="&lt;p&gt;Try using &lt;code&gt;serin.listen()&lt;/code&gt; for each SoftwareSerial before using &lt;code&gt;serin.read()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only one pin can be read at a time and by default it's reading from the last pin initialized. &lt;/p&gt;&#xA;" OwnerUserId="15217" LastEditorUserId="3917" LastEditDate="2015-12-09T20:16:45.517" LastActivityDate="2015-12-09T20:16:45.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18262" PostTypeId="1" CreationDate="2015-11-30T07:50:19.323" Score="-1" ViewCount="3549" Body="&lt;p&gt;I know that I can connect an ESP8266 with an Arduino Uno at pins 0 and 1, which is Rx and Tx, and enter commands manually in the serial monitor the commands to test it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had tried to use software serial and altserial to connect an ESP8266 to other pins, but it was error prone at sometimes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is that how to use an automated program to control an ESP8266 when I connect the ESP8266 with an Arduino Uno at pins 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample code would be helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have added a simple program to blink led when it get response but it is not working. could you look at it too?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  delay(3000);&#xA;  pinMode(12,OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  digitalWrite(12,LOW);&#xA;  delay(2000);&#xA;  Serial.println(&quot;AT&quot;);&#xA;  if(Serial.available())&#xA;  {&#xA;    digitalWrite(12,HIGH);&#xA;&#xA;    while(Serial.available())&#xA;    {&#xA;      char c=Serial.read();&#xA;    }&#xA;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15105" LastEditorUserId="15105" LastEditDate="2015-11-30T16:18:20.670" LastActivityDate="2017-11-28T19:25:45.860" Title="How to program ESP8266 with Arduino Uno pins 0 and 1?" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18263" PostTypeId="1" CreationDate="2015-11-29T21:57:48.320" Score="1" ViewCount="7190" Body="&lt;p&gt;I have an Arduino Uno whose LED, which is connected to  pin 13, is not turning off and it always stays on, and it annoys me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ggDts.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ggDts.jpg&quot; alt=&quot;Arduino UNO&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Touching any exposed pins turns off the LED after removing my hands from the pins it turns back on &lt;em&gt;slowly&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it works perfectly with the programs. This program does turn the LED off and it stays that way while the program is running.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  digitalWrite(13, LOW);         &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I upload other programs that don't use pin 13 then it stays on again. How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="14939" OwnerDisplayName="Akash Kumar" LastEditorUserId="4628" LastEditDate="2015-11-30T12:58:59.207" LastActivityDate="2015-11-30T12:58:59.207" Title="Arduino in-built LED is not turning off" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18264" PostTypeId="2" ParentId="18263" CreationDate="2015-11-30T09:17:07.823" Score="3" Body="&lt;p&gt;If you don't tell it to turn off, it behaves &quot;as it wants&quot;. If you don't write a 0 on its pin, how can you force it to stay shut down?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it to be in an off state, force it: in your setup function write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(13, OUTPUT);&#xA;digitalWrite(13, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No need to refresh it every loop, just in the setup.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-11-30T09:17:07.823" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18265" PostTypeId="2" ParentId="18258" CreationDate="2015-11-30T10:20:41.580" Score="0" Body="&lt;p&gt;You want to switch to my &lt;a href=&quot;http://uecide.org/beta&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; for that functionality. You can then place libraries inside a folder called &lt;em&gt;libraries&lt;/em&gt; in your sketch folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also get the benefits of a much improved IDE :)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-30T11:25:17.500" LastActivityDate="2015-11-30T11:25:17.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18266" PostTypeId="2" ParentId="18262" CreationDate="2015-11-30T11:16:29.387" Score="2" Body="&lt;p&gt;The problem with using pins 0 and 1 is that they are also used to communicate with the PC for both serial monitoring &lt;em&gt;and&lt;/em&gt; programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you attach an ESP8266 to pins 0 and 1 chances are you will fail when uploading a new sketch - you will have to disconnect the ESP8266 every time you need to upload a new sketch - that is why most people use SoftwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if you are using pins 0 and 1 for the ESP8266 you cannot then also use the serial monitor to see what is going on with your program and thus be able to debug it when it's not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're OK with both those caveats then by all means go ahead and use pins 0 and 1.  You use it in exactly the same way as using SoftwareSerial but you don't need to define an object first - you just use the pre-defined Serial object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important thing to remember with the ESP8266 is that the default firmware's AT command interface is ropey as hell.  It's most likely that which is tripping you up not your SoftwareSerial.  You have to get the timing right with it from what I remember - always impose a 1 second delay after sending each command - it's the delay that terminates the command, not a carriage return (although I think a CR is also needed). Maybe later versions have been improved since, but that's one really good reason to directly program the ESP8266 and implement your own protocol for communicating.  My &lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;nofollow&quot;&gt;ICSC&lt;/a&gt; library is a good candidate for communicating between the two - it runs on both the ESP8266 and the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-30T11:16:29.387" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18267" PostTypeId="2" ParentId="18263" CreationDate="2015-11-30T12:00:42.733" Score="0" Body="&lt;p&gt;You could try to actually remove the LED with a soldering pen... I haven't tried it however, so you could end up disabling pin 13 (or worst). &lt;/p&gt;&#xA;" OwnerUserId="356" LastActivityDate="2015-11-30T12:00:42.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18269" PostTypeId="2" ParentId="18041" CreationDate="2015-11-30T15:19:47.170" Score="1" Body="&lt;p&gt;The error message&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;avrdude: ser_open(): can't open device &quot;\\.\COM4&quot;: Access is denied&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;tells me that the error occurs when the Arduino IDE tries to open a connection to the FTDI adapter &quot;serial port&quot;, long before the Arduino IDE actually sends anything through the FTDI adapter to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you read the &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting&quot; rel=&quot;nofollow&quot;&gt;Arduino Troubleshooting guide&lt;/a&gt;?&#xA;The Arduino Troubleshooting guide recommends&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Access to the Serial Port&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;On Windows, if the software is slow to start or crashes on launch, or&#xA;  the Tools menu is slow to open, you may need to disable Bluetooth&#xA;  serial ports or other networked COM ports in the Device Manager. The&#xA;  Arduino software scans all the serial (COM) ports on your computer&#xA;  when it starts and when you open the Tools menu, and these networked&#xA;  ports can sometimes cause large delays or crashes.&lt;/li&gt;&#xA;  &lt;li&gt;Check that you're&#xA;  not running any programs that scan all serial ports, like USB Cellular&#xA;  Wifi Dongle software (e.g. from Sprint or Verizon), PDA sync&#xA;  applications, Bluetooth-USB drivers (e.g. BlueSoleil), virtual daemon&#xA;  tools, etc.&lt;/li&gt;&#xA;  &lt;li&gt;Make sure you don't have firewall software that blocks&#xA;  access to the serial port (e.g. ZoneAlarm).&lt;/li&gt;&#xA;  &lt;li&gt;You may need to quit&#xA;  Processing, PD, vvvv, etc. if you're using them to read data over the&#xA;  USB or serial connection to the Arduino board.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I were you my next steps would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Unplug the USB cable from my computer, and check the &quot;Tools &gt;&gt; Serial Port&quot; option. Usually when the USB cable is unplugged, that option is greyed out (empty list), but sometimes there is a few things listed. Remember that list.&lt;/li&gt;&#xA;&lt;li&gt;Plug the USB cable from the FTDI back in (preferably in a &lt;em&gt;different&lt;/em&gt; socket of the computer this time), and check the &quot;Tools &gt;&gt; Serial Port&quot; option. Do you remember the list from the previous step? There should be a new item on the list, representing the FTDI adapter -- pick that one.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would unplug the FTDI from the Arduino Lilypad, and then tell the Arduino IDE to upload the sketch. Obviously with the Arduino airgapped from your computer it won't be able to upload the sketch, but does it give a useful error message?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Reboot the computer with nothing plugged into its USB ports. Plug the FTDI adapter directly into the Arduino Lilypad (&quot;BLK&quot; to &quot;B&quot;, &quot;GRN&quot; to &quot;G&quot;). Start the Arduino IDE in Administrator mode. Make sure the board type is set correctly. Try to plug in the USB cable, set the Serial Port, and upload a sketch before any other program has a chance to grab that COM port.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-11-30T15:19:47.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18270" PostTypeId="1" AcceptedAnswerId="18274" CreationDate="2015-11-30T16:19:24.727" Score="0" ViewCount="621" Body="&lt;p&gt;I have an arduino uno which is powered by batteries. I have 6 AA-Batteries (1,5V each) connected to Vin and GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thats cool because I don't have any cables and works pretty good. &#xA;The reason I need 6 AA batteries is, that I have a SIM900-module connected to my arduino uno. My USB Port (5V and 500mA) and my standard external power supply (9V and 1A) doesn't deliver enough current for the SIM900. But with the batteries the SIM900 gets enough power (current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there is the problem, that the batteries get sucked empty pretty fast and i don't want to exchange them every day. :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched for an power supply which can deliver 3A with 9V and found &lt;a href=&quot;http://www.amazon.de/gp/product/B00V336QHY?keywords=arduino%209v%204A&amp;amp;qid=1448900022&amp;amp;ref_=sr_1_fkmr2_1&amp;amp;sr=8-1-fkmr2&quot; rel=&quot;nofollow&quot;&gt;one&lt;/a&gt;. But i'm not sure if the arduino uno can handle that input via the on-board power-jack? The reason I want a 3A power supply is, that some users on the internet say that the sim900 sometimes uses more than the maximum current written in the documentation (which is 2A).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm an electronic noob.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a risk if I try to use the 9V-3A power supply? &#xA;Does the arduino only pull the power it needs? So when it needs only 900mA, it only takes 900mA even if the power supply can deliver 3A?&#xA;As far as I know, it should work, because the batteries deliver as much current as the arduino (ad sim900) needs. So the batteries don't have an ampere limit, right?&lt;/p&gt;&#xA;" OwnerUserId="11679" LastEditorUserId="11679" LastEditDate="2015-11-30T16:32:48.510" LastActivityDate="2015-11-30T17:22:57.023" Title="arduino uno external power supply" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18271" PostTypeId="2" ParentId="18258" CreationDate="2015-11-30T16:25:28.420" Score="1" Body="&lt;p&gt;I ended up switching to &lt;a href=&quot;https://github.com/scottdarch/Arturo&quot; rel=&quot;nofollow&quot;&gt;ano&lt;/a&gt;, which supports a local &lt;code&gt;lib&lt;/code&gt; directory.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-11-30T16:25:28.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18272" PostTypeId="1" AcceptedAnswerId="18273" CreationDate="2015-11-30T16:55:03.600" Score="1" ViewCount="1853" Body="&lt;p&gt;I need to reduce the SPI clock speed of the Arduino Due down to about 100 kHz. Unfortunately my hardware doesn't support higher speeds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the current maximum divider of 255, I can only reach a speed of still 320 kHz (SPI.setClockDivider(10, 255);).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I could use a software SPI, but I'm still interested in using the build-in hardware. A possible solution could be to lower the overall clock speed of 84 MHz. Any idea how to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="15226" LastActivityDate="2015-11-30T17:18:01.810" Title="Arduino Due SPI speed reduction" Tags="|arduino-due|spi|code-optimization|oscillator-clock|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18273" PostTypeId="2" ParentId="18272" CreationDate="2015-11-30T17:01:41.043" Score="2" Body="&lt;p&gt;You can try using the SPISettings interface:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPISettings settings(100000, MSBFIRST, SPI_MODE0);&#xA;&#xA;SPI.beginTransaction(settings);&#xA;... do your stuff ...&#xA;SPI.endTransaction();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-11-30T17:18:01.810" LastActivityDate="2015-11-30T17:18:01.810" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18274" PostTypeId="2" ParentId="18270" CreationDate="2015-11-30T17:22:57.023" Score="1" Body="&lt;p&gt;The Arduino itself has a limit of about 800mA. That is imposed by the voltage regulator that converts the incoming voltage to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need more than 800mA then you need to provide your own regulated 5V power source and feed it in to the 5V pin (not VIN).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suitable power sources are mobile phone chargers (&lt;em&gt;modern USB ones&lt;/em&gt;).  They generally come in multiples of amps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to answer your theory question - the current is the &lt;em&gt;maximum&lt;/em&gt; that the supply can provide. It's the voltage that is &lt;em&gt;fixed&lt;/em&gt; and the current varies depending on the &lt;em&gt;load&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-30T17:22:57.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18275" PostTypeId="1" CreationDate="2015-11-30T18:15:42.023" Score="2" ViewCount="3992" Body="&lt;p&gt;How can I write the bootloader and sketch code to an Arduino through the ISP and then write the sketch code again using the Arduino IDE later?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I can write the bootloader through the ISP and then write the sketch through the Arduino IDE.  This works just like normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can also write the bootloader and sketch through the ISP.  The code runs like normal, but I can't load a new version of the sketch through the Arduino IDE.  It just timesout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what the IDE says when it attempts to upload the program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM5&#xA;         Using Programmer              : wiring&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_getsync(): timeout communicating with programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE creates two hex files after compiling the sketch: one is just the compiled sketch (Sketch.ino.hex) and the other is the compiled sketch with the bootloader code appended to the end (Sketch.ino.with_bootloader.hex).  So, I feel like this should be possible because Arduino produces the file for me.&lt;/p&gt;&#xA;" OwnerUserId="15230" OwnerDisplayName="Joey M" LastActivityDate="2021-06-30T08:16:03.970" Title="burn arduino bootloader and compiled sketch at same time" Tags="|bootloader|isp|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18276" PostTypeId="2" ParentId="18275" CreationDate="2015-11-30T18:36:16.127" Score="1" Body="&lt;p&gt;If you program via ISP, it erases the boot loader, because you do not need it. The whole point of the boot loader is to allow programming over USB. So if you want to use the normal Arduino USB input to program, burn the bootloader and then do not use the ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note my knowledge of this dates back to older arduino ~1.0 software, it is possible modifications have been made, but the above should still be true. If you have an ISP you do not need the bootloader at all.&lt;/p&gt;&#xA;" OwnerUserId="15228" LastActivityDate="2015-11-30T18:36:16.127" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18277" PostTypeId="1" AcceptedAnswerId="18278" CreationDate="2015-11-30T19:06:55.633" Score="0" ViewCount="78" Body="&lt;p&gt;I'm looking to buy my first arduino kit. However I have a concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my Arduino Mega is bought from one manufacturer, then can I buy shields or other parts from other manufacturers? Are there any incompatibility issues&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15232" LastActivityDate="2015-11-30T19:15:18.877" Title="Buying Arduino Parts Different Manufacturers" Tags="|arduino-mega|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18278" PostTypeId="2" ParentId="18277" CreationDate="2015-11-30T19:15:18.877" Score="1" Body="&lt;p&gt;Of course you can. In just the same way that you can buy a car from one manufacturer and bumper stickers from another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the whole point of the Arduino platform - mix and match to make things -just like LEGO®.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-30T19:15:18.877" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18279" PostTypeId="1" AcceptedAnswerId="18280" CreationDate="2015-11-30T19:29:11.673" Score="1" ViewCount="1018" Body="&lt;p&gt;I have servo (TowerPro sg90) connected to 32 servo controller (&lt;a href=&quot;http://www.aliexpress.com/item/New-Version-32-Channel-Robot-Servo-Control-Board-Servo-Motor-Controller-PS2-Wireless-Control-USB-UART/32272674301.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;) through UART interface (RX-TX, GND-GND). &#xA;Seller provide documentation how to connect and control my servos, but it isn't work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo work if I connect it indirectly to Arduino. Controller indicate that it is working too (photo below - red led).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already try different servos. Also try use provided software to control servos from pc through Mac/PC. But it's interface is unreadable for me. I tried different options but servos not responding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch code below (from sellers examples):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.print(&quot;#3P500T2000\r\n&quot;);&#xA;  delay(2000);&#xA;  Serial.print(&quot;#3P1500T2000\r\n&quot;);&#xA;  delay(3000);&#xA;  Serial.print(&quot;#3P2500T2000\r\n&quot;); &#xA;  delay(2000);&#xA;  Serial.print(&quot;#3P1500T2000\r\n&quot;);&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Photo of my connections: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Verqy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Verqy.jpg&quot; alt=&quot;arduino-duamilanovo+32-servo-controller+servo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if it post duplicate some, but I cannot google this problem.&lt;/p&gt;&#xA;" OwnerUserId="15235" LastActivityDate="2015-11-30T19:34:20.530" Title="Cannot control servos through 32-servo-controller on Aurduino Duamilanove" Tags="|servo|uart|arduino-duemilanove|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18280" PostTypeId="2" ParentId="18279" CreationDate="2015-11-30T19:34:20.530" Score="3" Body="&lt;p&gt;There is one connection missing - the one that powers the servo and board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment your servo board is getting a small amount of power through the RX pin - &lt;strong&gt;disconnect it immediately, you are damaging it&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to provide +5V to the +5V terminal block, and also a suitable voltage (+5V should do) to the VCC on the terminal block.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-30T19:34:20.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18281" PostTypeId="2" ParentId="16740" CreationDate="2015-11-30T20:14:19.227" Score="0" Body="&lt;p&gt;You may find &lt;a href=&quot;https://arduino.stackexchange.com/a/18221/3917&quot;&gt;my answer to another&lt;/a&gt; question –  &lt;em&gt;&lt;a href=&quot;https://arduino.stackexchange.com/q/18183&quot;&gt;Read RC receiver channels using Interrupt instead of PulseIn&lt;/a&gt;&lt;/em&gt; – useful.  It includes the sketch shown below, which is intended for background timing of four RC channels attached to pins A0-A3.  See the other answer for further comments about the code, example output, etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*  rcTiming.ino -- JW, 30 November 2015 -- &#xA; * Uses pin-change interrupts on A0-A4 to time RC pulses&#xA; *&#xA; * Ref: https://arduino.stackexchange.com/questions/18183/read-rc-receiver-channels-using-interrupt-instead-of-pulsein&#xA; *&#xA; */&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;static   byte rcOld;        // Prev. states of inputs&#xA;volatile unsigned long rcRises[4]; // times of prev. rising edges&#xA;volatile unsigned long rcTimes[4]; // recent pulse lengths&#xA;volatile unsigned int  rcChange=0; // Change-counter&#xA;&#xA;// Be sure to call setup_rcTiming() from setup()&#xA;void setup_rcTiming() {&#xA;  rcOld = 0;&#xA;  pinMode(A0, INPUT);  // pin 14, A0, PC0, for pin-change interrupt&#xA;  pinMode(A1, INPUT);  // pin 15, A1, PC1, for pin-change interrupt&#xA;  pinMode(A2, INPUT);&#xA;  pinMode(A3, INPUT);&#xA;  PCMSK1 |= 0x0F;       // Four-bit mask for four channels&#xA;  PCIFR  |= 0x02;       // clear pin-change interrupts if any&#xA;  PCICR  |= 0x02;       // enable pin-change interrupts&#xA;}&#xA;// Define the service routine for PCI vector 1&#xA;ISR(PCINT1_vect) {&#xA;  byte rcNew = PINC &amp;amp; 15;   // Get low 4 bits, A0-A3&#xA;  byte changes = rcNew^rcOld;   // Notice changed bits&#xA;  byte channel = 0;&#xA;  unsigned long now = micros(); // micros() is ok in int routine&#xA;  while (changes) {&#xA;    if ((changes &amp;amp; 1)) {  // Did current channel change?&#xA;      if ((rcNew &amp;amp; (1&amp;lt;&amp;lt;channel))) { // Check rising edge&#xA;        rcRises[channel] = now;     // Is rising edge&#xA;      } else {              // Is falling edge&#xA;        rcTimes[channel] = now-rcRises[channel];&#xA;      }&#xA;    }&#xA;    changes &amp;gt;&amp;gt;= 1;      // shift out the done bit&#xA;    ++channel;&#xA;    ++rcChange;&#xA;  }&#xA;  rcOld = rcNew;        // Save new state&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting RC Timing Test&quot;);&#xA;  setup_rcTiming();&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long rcT[4]; // copy of recent pulse lengths&#xA;  unsigned int rcN;&#xA;  if (rcChange) {&#xA;&#xA;    // Data is subject to races if interrupted, so off interrupts&#xA;    cli();          // Disable interrupts&#xA;    rcN = rcChange;&#xA;    rcChange = 0;       // Zero the change counter&#xA;    rcT[0] = rcTimes[0];&#xA;    rcT[1] = rcTimes[1];&#xA;    rcT[2] = rcTimes[2];&#xA;    rcT[3] = rcTimes[3];&#xA;    sei();          // reenable interrupts&#xA;&#xA;    Serial &amp;lt;&amp;lt; &quot;t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[0] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[1]&#xA;       &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[2] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[3] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcN &amp;lt;&amp;lt; endl;&#xA;  }&#xA;  sei();            // reenable interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-11-30T20:14:19.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18282" PostTypeId="1" CreationDate="2015-11-30T20:36:31.793" Score="0" ViewCount="37" Body="&lt;p&gt;I am trying to get values for two ping sensors, but am not getting any returns, can someone help me edit my code?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600); &#xA;  pingRange(2);&#xA;  pingRange(3);&#xA;}&#xA;&#xA;void loop(){&#xA;}&#xA;&#xA;  long pingRange (int pingPin)&#xA;&#xA;{&#xA;  pinMode(pingPin, OUTPUT);&#xA;  digitalWrite(pingPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(pingPin, HIGH);&#xA;  delayMicroseconds(5);&#xA;  digitalWrite(pingPin, LOW);&#xA;  pinMode(pingPin, INPUT);&#xA;  return microsecondsToCentimeters(pulseIn(pingPin, HIGH));&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;  // The speed of sound is 340 m/s or 29 microseconds per centimeter.&#xA;  // The ping travels out and back, so to find the distance of the&#xA;  // object we take half of the distance travelled.&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-11-30T20:43:01.697" Title="Using 2 PING Senors at Once" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18283" PostTypeId="2" ParentId="18282" CreationDate="2015-11-30T20:43:01.697" Score="1" Body="&lt;p&gt;There's one part of your code conspicuous by its absence:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pingRange(2);&#xA;pingRange(3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're calling the functions, but you're not doing anything with the returned value.  I think you meant to print that value to the serial interface...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(pingRange(2));&#xA;Serial.println(pingRange(3));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-11-30T20:43:01.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18284" PostTypeId="1" AcceptedAnswerId="18323" CreationDate="2015-11-30T21:30:14.120" Score="0" ViewCount="2180" Body="&lt;p&gt;The RS485 master-slave communication library on Nick Gammon's page &lt;a href=&quot;http://www.gammon.com.au/Arduino/RS485_protocol.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/Arduino/RS485_protocol.zip&lt;/a&gt; is working for me OK, but on the same hardware wiring is not working for the non-blocking library &lt;a href=&quot;http://www.gammon.com.au/Arduino/RS485_non_blocking.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/Arduino/RS485_non_blocking.zip&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can not find information about the connection of MAX485 on Arduino for non-block version. Is MAX485/RS485 from HW serial (ie Rx=0 and Tx=1)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how can a slave on the same line at the same time receive from master the message &quot;hello world&quot; and print it to the serial monitor?&#xA;Thank you for the explanation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I added the SoftwareSerial library into Nick's example for non-blocking, so it works, but is it still a non-blocking?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Master:&#xA;#include &amp;lt;RS485_non_blocking.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;const byte ENABLE_PIN = 4; &#xA;SoftwareSerial mySerial(2,3); //RX = 2 TX = 3&#xA;&#xA;size_t fWrite (const byte what) {&#xA;  return mySerial.write (what);  &#xA;}&#xA;&#xA;RS485 myChannel (NULL, NULL, fWrite, 0);  &#xA;&#xA;void setup () {&#xA;  Serial.begin (9600);&#xA;  mySerial.begin (28800);&#xA;  myChannel.begin ();  &#xA;&#xA;  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable &#xA;}  // end of setup&#xA;&#xA;const byte msg [] = &quot;Hello world&quot;;&#xA;&#xA;void loop () {&#xA;  digitalWrite (ENABLE_PIN, HIGH);  // enable sending &#xA;  myChannel.sendMsg (msg, sizeof (msg));&#xA;  digitalWrite (ENABLE_PIN, LOW);  // disable sending&#xA;  delay (1000);   &#xA;}  // end of loop&#xA;&#xA;//Slave:&#xA;#include &amp;lt;RS485_non_blocking.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;const byte ENABLE_PIN = 4; &#xA;SoftwareSerial mySerial(2,3); //RX = 2 TX = 3&#xA;&#xA;int fAvailable () {&#xA;  return mySerial.available ();  &#xA;}&#xA;&#xA;int fRead() {&#xA;  return mySerial.read ();&#xA;}&#xA;&#xA;RS485 myChannel (fRead, fAvailable, NULL, 20); &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(28800);&#xA;  myChannel.begin();&#xA;  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable&#xA;}  // end of setup&#xA;&#xA;void loop() {&#xA;  if (myChannel.update()) {&#xA;    Serial.write (myChannel.getData(), myChannel.getLength());&#xA;    Serial.println();&#xA;  }&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Regards, Vava&#xA;(Sorry for my English... :-)&lt;/p&gt;&#xA;" OwnerUserId="15238" LastEditorUserId="4628" LastEditDate="2015-12-03T00:38:36.403" LastActivityDate="2015-12-03T00:38:36.403" Title="Serial: What is different between Gammon's RS485 (blocking) and RS485 &quot;non blocking&quot; libraries?" Tags="|serial|rs485|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18285" PostTypeId="2" ParentId="17964" CreationDate="2015-11-30T21:37:19.020" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The main question I have about programming these Micro-controllers is&#xA;are there major differences in designing code in Object Orientated&#xA;Classes vs the more traditional inline programming I have seen in many&#xA;examples?&lt;/p&gt;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&lt;p&gt;In other words in the world of Arduino/AVR Controllers are there any&#xA;savings with Memory and Performance utilizing classes or visa versa?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes, there is a great difference between using C or C++ for small scale embedded systems such as Arduino/AVR. C++ allows more information to be provide for compiler optimizations.&lt;/p&gt;&#xA;&lt;p&gt;If you are implementing an OOP framework, platform or runtime C++ and classes can also help with software architecture and reuse. In &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cosa&lt;/a&gt; a number of OOP design patterns are used to achieve interfaces for both application programmers and device driver programmers. The most common is &lt;a href=&quot;https://en.wikipedia.org/wiki/Delegation_pattern&quot; rel=&quot;nofollow noreferrer&quot;&gt;delegation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using abstract classes, virtual member functions, inlining, and templates can help achieve lower foot-print and higher performance than traditional implementations. As an example the Cosa Pin classes are X5-X10 faster than the Arduino core and at the same time smaller in foot-print. Please see the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/tree/master/examples/Benchmarks&quot; rel=&quot;nofollow noreferrer&quot;&gt;benchmarks&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;One thing to &amp;quot;unlearn&amp;quot; from traditional C++ programming is the usage of new/delete (malloc/free). With SRAM size of only a few Kbyte using a heap is very much a risk. The answer is static classes and stack based data.&lt;/p&gt;&#xA;&lt;p&gt;There is much more to be said about OOP framework architecture but I hope this helps answer your initial questions.&lt;/p&gt;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-01T10:41:35.197" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18286" PostTypeId="1" CreationDate="2015-12-01T00:27:04.193" Score="3" ViewCount="9899" Body="&lt;p&gt;I am looking at Adafruit to purchase some LED strips for a mod for my computer case, and want to power it with an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking at the Uno, but the Mega looks good too.  I hear the Uno is good because if the chip fries, you can just replace it easier than the Mega's chip.  I did hear that the Uno chip had issues, but that was a 2013 post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, I am essentially looking to connect about a foot of 144 leds/m to the front of my case, and connect that to the Arduino.  I will then be lining the inside of my case with about 12-15&quot; per side (x4 sides) of 60 leds/m so I wanted to connect that to another part of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that each led takes something like 6mA or 60mA each, so that is what we should watch for.  I was trying to search for this question that others asked, but people were looking to connect a lot of strips, and needed relays and whatnot, so I wanted to make sure the Arduino itself could power about 1.5 to 2 meters of Led strips in at least 2 different strip configs (or whatever you want to call them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also am curious if there will be an issue programming each strip setup or, if it just is a little more work to get it setup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is a computer cause led setup, I'm not sure if I should go USB power, or a wall charger?  What is the recommended approach for something like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will definitely be reading up more tutorials and all that important stuff, but I want to buy the stuff now since I realized there's a cyber Monday deal going on, so I don't want to miss out...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated, thank you!&lt;/p&gt;&#xA;" OwnerUserId="15242" LastActivityDate="2015-12-07T09:40:00.497" Title="How many LED Strips can we connect to an Arduino Uno? Is there a way to connect 1-3 meters worth without needing extra parts (relays)?" Tags="|arduino-uno|arduino-mega|led|adafruit|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18287" PostTypeId="2" ParentId="18286" CreationDate="2015-12-01T00:52:54.427" Score="5" Body="&lt;p&gt;Yes, the current draw is the main factor here.  That's not really an Arduino issue though, as I will enlighten you about later on when I talk power supplies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I assume, since you don't mention what the LEDs are, that you are talking about strips of WS2812 &quot;NeoPixel&quot; LEDs (the ones where you can control the colour of each and every individual LED).&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend keeping all the LEDs as one single strip.  That doesn't mean you can cut the strip into segments, just join the ends to each other using wire in one chain.  That way you just have one chain to deal with in the Arduino.  Running multiple chains can be somewhat more resource hungry and I'm not even sure it's possible on an Arduino.  So keep it all as one long chain split into chunks and re-joined with wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for power.  Your computer has a big powerful power supply in it.  That gives a very good regulated 5V supply with many many amps available.  More than enough to run hundreds of LEDs.  By all means run the Arduino from USB (makes for easy programming - inspect your motherboard, it may well have an internal USB connector that would be ideal (I know mine has).  And then run the LEDs themselves off the +5V direct from the computer's power supply.  A spare hard drive power connector could be good for that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-01T00:52:54.427" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18288" PostTypeId="1" CreationDate="2015-12-01T01:36:48.877" Score="0" ViewCount="561" Body="&lt;p&gt;I have a project where I would like to control a countdown clock using a remote with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno R3 Development Board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Funduino Uno Protoshield Board &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://cdn.shopify.com/s/files/1/0045/8932/files/DMDCON_DMDConnector.pdf?100730&quot; rel=&quot;nofollow noreferrer&quot;&gt;Freetronics Dot Matrix Display Connector&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino-info.wikispaces.com/IR-RemoteControl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino IR Reciever&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both the DMDCon and the IR use digital pin 11. Can these two share the pin 11 or is there a workaround of sorts?&lt;/p&gt;&#xA;" OwnerUserId="15244" LastEditorUserId="26916" LastEditDate="2017-09-09T08:01:28.617" LastActivityDate="2019-08-30T16:03:20.407" Title="Using digital pin 11 for DMDCon and IR remote" Tags="|arduino-uno|led|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18289" PostTypeId="1" CreationDate="2015-12-01T01:48:46.367" Score="2" ViewCount="295" Body="&lt;p&gt;I'm currently trying to log data from a GPS shield onto a microSD card using a Sparkfun microSD shield. All my code will compile, but when I open the serial monitor the microSD will initialize, but then the log file itself won't be able to be opened. I have formatted the card and reset all the shields and the Arduino itself multiple times, but nothing seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I upload the example sketch used to show the functionality of the data logging, provided in the SD.h library by Sparkfun, everything will function properly and it will be able to open the file correctly. I used this file to give me information on how to format my code, so it is very similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that I think may be causing the issue is the size of my code. When uploaded, the code uses 80% of total memory and 84% of dynamic. I tried commenting out a lot of the code to see if more free memory would give a different result, but still got the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be awesome, and thank you in advance! I've included my code below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Include FONA, Watchdog, SD card and declare pins&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;#include &quot;Adafruit_FONA.h&quot;&#xA;#include &quot;Adafruit_SleepyDog.h&quot;&#xA;#include &quot;SPI.h&quot;&#xA;#include &quot;SD.h&quot;&#xA;&#xA;#define FONA_RX 2 //Reset pin&#xA;#define FONA_TX 3 //FONA serial TX pin&#xA;#define FONA_RST 4 //FONA serial RX pin&#xA;&#xA;//Include software serial&#xA;SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);&#xA;SoftwareSerial *fonaSerial = &amp;amp;fonaSS;&#xA;&#xA;Adafruit_FONA fona = Adafruit_FONA(FONA_RST);&#xA;&#xA;const int chipSelect = 8;&#xA;&#xA;File dataFile = SD.open(&quot;data.log&quot;, FILE_WRITE);&#xA;&#xA;//Set strings to hold all the data&#xA;  String Lat = &quot;&quot;;&#xA;  String Long = &quot;&quot;;&#xA;  String KPH = &quot;&quot;;&#xA;  String Head = &quot;&quot;;&#xA;  String Alt = &quot;&quot;;&#xA;&#xA;  float latitude, longitude, speed_kph, heading, altitude;&#xA;&#xA;//Set integers for the data&#xA;  int GPSlat = latitude;&#xA;  int GPSlong = longitude;&#xA;  int GPSkph = speed_kph;&#xA;  int GPShead = heading;&#xA;  int GPSalt = altitude;&#xA;&#xA;//Set counter and phone number for location messaging&#xA;  int Log_Counter = 0;&#xA;&#xA;// Halt function called when an error occurs.  Will print an error and stop execution while&#xA;// doing a fast blink of the LED.  If the watchdog is enabled it will reset after 10 seconds.&#xA;//void halt(const __FlashStringHelper *error) {&#xA;//  Serial.println(error);&#xA;//}&#xA;&#xA;//uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0); //&#xA;&#xA;//uint8_t type; //&#xA;&#xA;&#xA;void setup() {&#xA;  while (!Serial);&#xA;&#xA;  //Initialize serial output&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Team Space Bread GPS - Zero-G-luten&quot;));&#xA;&#xA;  //Initialize SD card, then check if card is present&#xA;  Serial.print(F(&quot;Initializing SD card...&quot;));&#xA;  pinMode(SS, OUTPUT);&#xA;  digitalWrite(SS, HIGH);&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(F(&quot;Card failed or is not present&quot;));&#xA;    while (1);&#xA;  }&#xA;  Serial.println(&quot;Card initialized&quot;);&#xA;&#xA;  //Open file to log data to&#xA;  if (! dataFile) {&#xA;    Serial.println(F(&quot;Error opening log file&quot;));&#xA;    while (1);&#xA;  }&#xA;&#xA;  //Initialize FONA module&#xA;  Serial.println(F(&quot;Initializing FONA.... (may take a couple seconds)&quot;));&#xA;  fonaSerial-&amp;gt;begin(4800);&#xA;  if (!fona.begin(*fonaSerial)) {&#xA;  // halt(F(&quot;Couldn't find FONA&quot;));&#xA;  }&#xA;  fonaSS.println(&quot;AT+CMEE=2&quot;);&#xA;  Serial.println(F(&quot;FONA is functioning swimmingly&quot;));&#xA;&#xA;  //Enable watchdog timer; if code hangs and will not connect to GPS, WDT will run out after 10 seconds&#xA;  //and reset the code&#xA;  Watchdog.enable(10000);&#xA;  Watchdog.reset();&#xA;&#xA;  //Wait for FONA to connect to cell network&#xA;  Serial.println(F(&quot;Checking for network...&quot;));&#xA;  while (fona.getNetworkStatus() != 1) {&#xA;   delay(500);&#xA;  }&#xA;&#xA;  //Enable GPS&#xA;  Watchdog.reset();&#xA;  Serial.println(F(&quot;Enabling GPS&quot;));&#xA;  fona.enableGPS(true);&#xA;  delay(2000);&#xA;  Watchdog.reset();&#xA;  if (!fona.enableGPS(true)) {&#xA;  // halt(F(&quot;Failed to turn GPS on, resetting...&quot;));&#xA;  }&#xA;  Serial.println(F(&quot;GPS connection successful&quot;));&#xA;&#xA;  // Start the GPRS data connection.&#xA;  Watchdog.reset();&#xA;  Serial.println(F(&quot;Enabling GPRS&quot;));&#xA;  fona.enableGPRS(true);&#xA;  delay(2000);   &#xA;  Watchdog.reset();&#xA;  if (!fona.enableGPRS(true)) {&#xA;  //  halt(F(&quot;Failed to turn GPRS on, resetting...&quot;));&#xA;  }&#xA;  Serial.println(F(&quot;Connected to cellular&quot;));&#xA;&#xA;  //Wait a bit for connection to stabilize&#xA;  Watchdog.reset();&#xA;  delay(5000);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;//Reset Watchdog at start of loop - everything must work in less than 10 seconds!&#xA; Watchdog.reset();&#xA;&#xA;// Grab a GPS reading.&#xA;&#xA;  bool gpsFix = fona.getGPS(&amp;amp;latitude, &amp;amp;longitude, &amp;amp;speed_kph, &amp;amp;heading, &amp;amp;altitude);&#xA;&#xA;//Define strings as data intergers&#xA;  Lat += String(GPSlat);&#xA;  Long += String(GPSlong);&#xA;  KPH += String(GPSkph);&#xA;  Head += String(GPShead);&#xA;  Alt += String(GPSalt);&#xA;//Print all data onto SD card&#xA;  dataFile.print(&quot;GPS lat: &quot;);&#xA;  dataFile.println(Lat);&#xA;  dataFile.print(&quot;GPS long: &quot;);&#xA;  dataFile.println(Long);&#xA;  dataFile.print(&quot;GPS speed KPH: &quot;);&#xA;  dataFile.println(KPH);&#xA;  dataFile.print(&quot;GPS heading: &quot;);&#xA;  dataFile.println(Head);&#xA;  dataFile.print(&quot;GPS altitude: &quot;);&#xA;  dataFile.println(Alt);&#xA;  dataFile.print(&quot; &quot;);&#xA;&#xA;//Flush file to save data onto card&#xA;  dataFile.flush();&#xA;&#xA;//Every loop, add 1 to Log_Counter. When Log_Counter==180 (every 15 minutes), send SMS to number with location&#xA;  Log_Counter++;&#xA;  if (Log_Counter==180) {&#xA;//There has to be a more elegant way to do this, but ¯\_(ツ)_/¯&#xA;&#xA;//Buffer for location and phone number&#xA;  char LocationBuffer[48];&#xA;//  char SendTo[16];&#xA;&#xA;//Make latitude and longitude into one string&#xA;  String(Location) = Lat+=Long+=Alt ;&#xA;&#xA;//Set phone number to text to&#xA;//  String(PhoneNumber) = &quot;18143803250&quot;;&#xA;                       //^^^^This^^^^ is where you put the number to send the location to every 15 minutes&#xA;&#xA;//Location string to char that will be able to send &#xA;  Location.toCharArray(LocationBuffer, sizeof(LocationBuffer));&#xA;&#xA;////Set phone number to char&#xA;//  PhoneNumber.toCharArray(SendTo, sizeof(SendTo));&#xA;&#xA;//Send SMS w/ location&#xA;fona.sendSMS(&quot;18143803250&quot;, LocationBuffer);&#xA;}&#xA;&#xA;//Take mesaurement every 5 seconds&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15063" LastActivityDate="2015-12-01T01:48:46.367" Title="Sparkfun MicroSD shield cannot open log file" Tags="|arduino-uno|shields|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18290" PostTypeId="2" ParentId="18222" CreationDate="2015-12-01T02:31:42.630" Score="0" Body="&lt;p&gt;OK, I see a section labelled +5V auto selector, with a Schotky diode between +5V and the VUSB rail, I don't understand enough about electronics to see what this does though. I get that if I supply 7V, say, to Vin then the Nano will use that as the 'highest voltage source'. I could perhaps use a variable voltage source fed from the batteries and set it to, say, 5.2V and force the Nano to use that? The reason for all this is that the Nano will be connected to a Raspberry Pi via USB for communicating with the ros system, and the Pi is unable to supply much from its USB ports, it cant run, for example, a WiFi dongle, mouse and keyboard at the same time. &lt;/p&gt;&#xA;" OwnerUserId="15181" LastActivityDate="2015-12-01T02:31:42.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18291" PostTypeId="2" ParentId="18286" CreationDate="2015-12-01T02:57:35.197" Score="1" Body="&lt;p&gt;The important thing to understand here is that there are two things going on:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Powering the LEDs – that's the big power draw and it makes a ton of sense to do that off of the computer power supply.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Controlling the LEDs – that'a a very small load, using one (NeoPixel et al.) or two (DotStar et al.) pins on the Arduino. So there is no need to do anything fancy, you should have more than enough drive in the Arduino pin(s) to handle the LED control.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You might want to take a look at the &lt;a href=&quot;http://fastled.io&quot; rel=&quot;nofollow&quot;&gt;FastLED&lt;/a&gt; library (or head directly to the &lt;a href=&quot;https://github.com/fastled/fastled&quot; rel=&quot;nofollow&quot;&gt;GitHub repo&lt;/a&gt;) it explicitly support multiple strands of LEDs (and interchangeably supports a whole slew of LED type including NeoPixels and DotStars. I think, but haven't tried, you could support multiple strands of NeoPixels by creating several instances and giving each instance its own pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DotStars come (if you get a &quot;finished&quot; end) with a connector that has all four wires (Vcc, Gnd, data, and clock) as well as two additional wires for &quot;bulk&quot; power. But if you don't get a finished end you would just solder to the pads that are at each cut point. You probably want to power the strip(s) in parallel – feeding them from each end so that the LEDs at the end don't see too much of a voltage drop.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-01T03:02:42.613" LastActivityDate="2015-12-01T03:02:42.613" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18292" PostTypeId="1" CreationDate="2015-12-01T03:18:20.003" Score="2" ViewCount="35" Body="&lt;p&gt;I have 2 Xbee S1 models, 2 Arduino Wireless Proto Shields, 2 Arduino Megas, and an Xbee Explorer and am trying to make one Arduino Trigger another Arduino to send a pulse, I have tried to set up many tutorials on youtube and digi, but still cannot get it to work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone walk me through the steps for setup? &lt;/p&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-12-01T03:18:20.003" Title="XBEE S1 Wireless Connection" Tags="|xbee|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18293" PostTypeId="1" AcceptedAnswerId="18294" CreationDate="2015-12-01T04:16:12.413" Score="0" ViewCount="72" Body="&lt;p&gt;As the title says there are many different wall chargers to choose from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;12v, 9v, 5v, with different mA amounts...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The starter kit on Adafruit's website mentions to get the 9V 1000mA switching power adapter, so I'm curious if that's what we should get?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the link to all of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are regular wall adapters, and these big power supplies...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.adafruit.com/search?q=switching+power+adapter&amp;amp;b=1&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/search?q=switching+power+adapter&amp;amp;b=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just looking to run some LED Strip lights from the arduino and power some joystick buttons, some rotary encoder/knobs, and a keypad to work the LED lights&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thoughts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15242" LastActivityDate="2015-12-01T06:17:59.573" Title="Looking at Adafruit's website I'm confused which wallcharger I should get" Tags="|arduino-uno|power|adafruit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18294" PostTypeId="2" ParentId="18293" CreationDate="2015-12-01T04:33:40.523" Score="0" Body="&lt;p&gt;This website looks like a pretty official answer for you. &#xA;&lt;a href=&quot;http://playground.arduino.cc/Learning/WhatAdapter&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/WhatAdapter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Since you'll probably be connecting other things to the Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have enough juice to make each component of the circuit function reliably.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino's on-board regulator can actually handle up to 20V or more, so you can actually use an adapter that puts out 20V DC. The reasons you don't want to do that are twofold: you'll lose most of that voltage in heat, which is terribly inefficient. Secondly, the nice 9V pin on the Arduino board will actually be putting out 20V or so, which could lead to potential disaster when you connect something expensive to what you thought was the 9V pin. Our advice is to stick with the 9V or 12V DC adapter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15247" LastActivityDate="2015-12-01T04:33:40.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18295" PostTypeId="1" CreationDate="2015-12-01T05:07:50.420" Score="2" ViewCount="328" Body="&lt;p&gt;I think I broke my Arduino Uno as I was playing with it. I connected an ultrasonic range finder to it and uploaded a sketch to it. It was working fine until I accidentally touched the ICSP headers for the USB interface (the pins near the USB port). Now,everything is still working but my computer cannot detect it and it does not show up in the device manager or the IDE. Please tell me if it is broken and how to fix it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I just bought it and just started using it after another Arduino had the same problem.&lt;/p&gt;&#xA;" OwnerUserId="15251" OwnerDisplayName="yongtheskill" LastEditorUserId="27346" LastEditDate="2018-11-19T09:32:39.053" LastActivityDate="2018-11-19T09:32:39.053" Title="Is my Arduino Uno broken?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="6" ClosedDate="2016-01-22T21:57:15.520" ContentLicense="CC BY-SA 3.0" />
  <row Id="18297" PostTypeId="1" CreationDate="2015-12-01T05:27:43.390" Score="0" ViewCount="2377" Body="&lt;p&gt;I don't know how I can connect an MP503 sensor to my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LhNig.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LhNig.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;http://eleparts.co.kr/data/design/product_file/SENSOR/gas/MP503%20(Ver1.4)%20-%20Manual.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://eleparts.co.kr/data/design/product_file/SENSOR/gas/MP503%20(Ver1.4)%20-%20Manual.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15249" LastEditorUserId="4628" LastEditDate="2015-12-04T14:38:42.973" LastActivityDate="2019-11-07T18:03:33.127" Title="How can I connect the MP503 to an Arduino Uno (Smoke, Alcohol Sensor)?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18298" PostTypeId="2" ParentId="16803" CreationDate="2015-12-01T05:35:55.800" Score="1" Body="&lt;p&gt;The python code is polling through the servos sequentially/serialy, but the arduino code looks parallel. The arduino will parse the string and pass the command to the servo code, passing control back to the loop() command before the servo reaches its assigned position. Maybe that is your question: &quot;is servo.write(position) a blocking call?&quot; If so, the answer is no, it is non-blocking, the motors will drive at the motors speed to the final positions independently. If you want coordinated movement through this scheme, you have to break the movements up and coordinate it on the python side without feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you want to go from position (90,90,90,90) to position (81,0,90,90) you will need to know it takes 900ms (for example) to complete the -90 move, and break it up into 10 segments of 100ms to coordinate the (-1,0,-10,0) steps.  Doing the coordination without feedback will be awkward, and might be better handled from your python/UI side.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-01T05:35:55.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18299" PostTypeId="2" ParentId="18293" CreationDate="2015-12-01T06:00:34.370" Score="0" Body="&lt;p&gt;Your Arduino Uno will use 35 to 50 mA at 5V.  The  “joystick buttons, some rotary encoder/knobs, and a keypad” will draw a small amount of current, probably between 1 and 10 mA.  Thus, power for the Uno and your controls will be well under 100 mA and can be supplied via USB without any problem.  (Also see: &lt;em&gt;&lt;a href=&quot;https://electronics.stackexchange.com/q/5498&quot;&gt;How to get more than 100mA from a USB port&lt;/a&gt;&lt;/em&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your Uno enumerates and negotiates to get 500 mA via USB, you might have 450 mA available out of the +5V pin.  However, in some cases if you need more than a few dozen mA to power other devices, it will make sense to get a separate 5V supply for them.  (Eg, if the devices drag down the +5V and cause the Uno to reset, or if the devices are electrically noisy, like motors, RC servos, relays, solenoids.)  Also, note that &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=70450.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;thread #70450&lt;/a&gt; at forum.arduino.cc says you can draw 650 mA (or 3.25 W of power) when the Uno is powered via its DC power jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your LED string has up to 6 or 7 WS2812B equivalents, you can power it from the Uno's 5V.  Here is the all-lights-on, full-brightness calculation for six of them:  6 WS2812Bs x 3 LEDs per WS8211 x 21 mA per LED = 378 mA.  For seven:  7 x 3 x 21 mA = 441 mA, which is out there on the edge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For longer LED strings, figure on a little over 3 W of power for every 10 WS2812B equivalents.  (Calculation: 5 volts x 10  WS2812Bs x 3 LEDs per WS2812B x 21 max mA per LED = 3150 mW = 3.15 W.)  For example, get a 10 W (2 A x 5 V) or greater 5V power supply for a meter of 30- WS2812B-per-meter LED strip, etc.  This power supply will connect directly to the LED strip's power connectors.  The ground from the LED strip will connect to the Uno's ground, to establish a signal reference point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the absolute max voltage rating for a WS2812B, according to its datasheet, is 5.3 V, so use a supply whose voltage does not exceed 5.3 V.  The absolute min voltage rating is 3.5 V; they will work ok on 3.7 V LIPO batteries, but 3V3 power is out of spec for a WS2812B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in a previous question, if your LED strip is being installed inside a desktop PC, the PC's power supply will have lots of 5 V power available, and you can hook on to one of the red +5V wires and black Gnd wires from its supply to power the LEDs, either while powering the Uno itself from USB power or while using the same +5V to power the Uno as the LEDs.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-01T06:17:59.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18300" PostTypeId="1" AcceptedAnswerId="18345" CreationDate="2015-12-01T06:52:10.163" Score="1" ViewCount="69" Body="&lt;p&gt;I have a Arduino Uno which is looping over Serial.println(&quot;$testmessage&quot;). Connected to this is a USB cable that i have cut and soldered male jumper leads to . I need to receive this message (&quot;$testmessage&quot;) from the Uno using this USB cable without using the leosticks usb connector. After receiving the correct messgae from the Uno i plan to use Serial to send data from the leostick to my pc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm stuck trying to figure out how to receive this message from the Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently the the USB 5v and ground is connected to the leosticks 5V, GND pins. The Uno powers on and the the tx led is flashing every 100 milliseconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can i just plug the green and white wires from the USB cable into D0&amp;amp;D1 and except it to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Uno plugs into usb cable in the image)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/M0kbb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/M0kbb.jpg&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15253" LastActivityDate="2015-12-02T15:34:08.933" Title="Leostick Receiving message from Uno using USB jumpers cables" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18301" PostTypeId="2" ParentId="18300" CreationDate="2015-12-01T08:27:44.830" Score="0" Body="&lt;p&gt;I don't think this has any chance of working. You can't use USB to interface between the two devices, as the Leostick can't work as USB host. Your best bet is to use (software) serial.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-12-01T08:27:44.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18302" PostTypeId="1" CreationDate="2015-12-01T09:31:42.667" Score="0" ViewCount="140" Body="&lt;p&gt;I’m trying to make a string of 300 Christmas tree lights where the colour of each of the lights is entirely controllable by my own code. I am a programmer so that side of things is the easy part as far as I’m concerned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My researches so far have led me (no pun intended) to WS2811s driven by an Arduino. I prefer the look of these to the flat Adafruit-type ones. I don’t own an Arduino yet but have been dipping my toe into this site for quite a while now so am beginning to understand the basics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’ve established that I will need to have a fairly hefty 5volt power supply for the LEDs but that the Arduino itself can then run happily on its own USB supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the things I’ve read seem to imply that the Arduino will struggle to process my program and supply the data to 300 LEDs at the same time, but it’s not clear what the problem will be. I assume each LED will continue to glow with the same colour until it receives the data for its next colour and the code for “Fire!” which then prompts all of them to switch to their next colour. Is this wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realise that 3 bytes per LED for 300 LEDs is a fair amount of data to keep having to send up the wire. I will also be having an array in the program to keep track of all 300 colour values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this work? Can you offer any advice that might mean I don’t hit a brick wall somewhere when putting all this together?&lt;/p&gt;&#xA;" OwnerUserId="3377" LastActivityDate="2015-12-01T09:48:55.893" Title="Newbie and string of 300 WS2811s" Tags="|led|rgb-led|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18303" PostTypeId="2" ParentId="18302" CreationDate="2015-12-01T09:48:55.893" Score="1" Body="&lt;p&gt;I don't think you'll have any problems. The LED's have a data rate of 800kbps, so you can theoretically push out 110 frames per second if your Arduino does nothing but transmit data. If you keep the routine that updates the colors fairly efficient then you'll have nothing to worry about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the array storing the colors would take up 900 bytes of memory, leaving you with only 1100 bytes for everything else your program would need to store (which should be fine).&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-12-01T09:48:55.893" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18304" PostTypeId="2" ParentId="16467" CreationDate="2015-12-01T10:06:26.527" Score="2" Body="&lt;p&gt;Ok, if I understood what you meant, you want that a single led in the ring is on and the refresh rate is dependent on the pressure, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, you did not write any &quot;select this led&quot; code, so it can't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I fixed a couple of things in your code. Mainly:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;added the circularity to the ring (with variable &lt;code&gt;currentlyOnLed&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;fixed some types (use the &lt;code&gt;byte&lt;/code&gt; unless you need a bigger type)&lt;/li&gt;&#xA;&lt;li&gt;removed some &lt;code&gt;constrain&lt;/code&gt;s, which were reduntant&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;frequency*interval&lt;/code&gt; instead of &lt;code&gt;frequency/interval&lt;/code&gt; (I guess it was a typo)&lt;/li&gt;&#xA;&lt;li&gt;I prefer summing the step instead of setting &lt;code&gt;previousMillis&lt;/code&gt; to &lt;code&gt;currentMillis&lt;/code&gt;, so you will not add error with time passing&lt;/li&gt;&#xA;&lt;li&gt;moved &lt;code&gt;FastLED.show()&lt;/code&gt; outside the loop: I'm not sure about this, but I think that you don't need to call it every loop. I can't test it, anyway.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, here is the fixed code. Let us know if it works for you&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS    34&#xA;#define DATA_PIN    6&#xA;#define SENSOR_PIN  A0&#xA;&#xA;int airPressure;&#xA;int high  = 0;&#xA;int low   = 600;&#xA;byte barometricToRGB;&#xA;int frequency = 0;&#xA;byte interval = 50;&#xA;byte currentlyOnLed;&#xA;&#xA;long previousMillis = 0;&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    pinMode(SENSOR_PIN,INPUT);  &#xA;    FastLED.addLeds&amp;lt;NEOPIXEL, DATA_PIN&amp;gt;(leds, NUM_LEDS);&#xA;    currentlyOnLed = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;    airPressure = analogRead(SENSOR_PIN);&#xA;    autoTune();&#xA;&#xA;    unsigned long currentMillis = millis();&#xA;    Serial.print(&quot;frequency &quot;);&#xA;    Serial.println(frequency);&#xA;    Serial.print(&quot;Time to beat &quot;);&#xA;    Serial.println(frequency*interval);&#xA;    Serial.print(&quot;Last Called &quot;);&#xA;    Serial.println(currentMillis - previousMillis);&#xA;&#xA;    if(currentMillis - previousMillis &amp;gt; (frequency*interval)) {&#xA;        previousMillis += (frequency*interval);&#xA;&#xA;        //Set next on led&#xA;        if (currentlyOnLed &amp;gt;= NUM_LEDS - 1)&#xA;            currentlyOnLed = 0;&#xA;        else&#xA;            currentlyOnLed++;&#xA;&#xA;        for (byte i=0; i&amp;lt;NUM_LEDS; i++) {&#xA;            if (i == currentlyOnLed)&#xA;                leds[i].setRGB( barometricToRGB, 68, 255/barometricToRGB);&#xA;            else&#xA;                leds[i] = CRGB::Black;&#xA;        }&#xA;        FastLED.show();&#xA;    }&#xA;}&#xA;&#xA;void autoTune() {&#xA;    airPressure = constrain(airPressure, low, high);&#xA;    barometricToRGB = map(airPressure, low, high, 1, 255);&#xA;    frequency = map(airPressure, low, high, 1, 100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-12-01T10:06:26.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18305" PostTypeId="1" CreationDate="2015-12-01T10:20:22.037" Score="2" ViewCount="223" Body="&lt;p&gt;I need to send one transmission and record multiple distances with 4 receivers, but everytime I use more than 2 receivers, the serial data does not print. What can I do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I'm using 5 SRF-02 Sensors, 1 transmitter and 4 receivers all via I2C.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define cmdByte 0x00                                 // Command byte&#xA;#define rangeByte 0x02                             // Byte for start of ranging data&#xA;&#xA;byte highByte = 0x00;                                // Stores high byte from ranging&#xA;byte lowByte = 0x00;                                // Stored low byte from ranging&#xA;int range = 0; &#xA;int rangeData;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Wire.begin();  &#xA;}&#xA;&#xA;void loop() {&#xA;   D0_1= getRange(0x70, 0x71);  &#xA;   Serial.println(D0_1);&#xA;   D0_2= getRange(0x70, 0x72);  &#xA;   Serial.println(D0_2);&#xA;   D0_3= getRange(0x70, 0x73);  &#xA;   Serial.println(D0_3);&#xA;   D0_4= getRange(0x70, 0x74);  &#xA;   Serial.println(D0_4);&#xA;}&#xA;&#xA; int getRange (uint8_t send_address, uint8_t rec_address)&#xA; {&#xA;  Wire.beginTransmission(rec_address);&#xA;  Wire.write((uint8_t)cmdByte);&#xA;  Wire.write((uint8_t)0x56);&#xA;  Wire.endTransmission(); &#xA;&#xA;  Wire.beginTransmission(send_address);             // Start communticating with SRF02&#xA;  Wire.write((uint8_t)cmdByte);                         // Send Command Byte&#xA;  Wire.write((uint8_t)0x5C);        // Transmit an 8 cycle 40khz burst - no ranging takes place&#xA;  Wire.endTransmission();  &#xA;&#xA;  delay(80);                                                           // Wait for ranging to be complete&#xA;&#xA;  Wire.beginTransmission(rec_address);       // start communicating with SRFmodule&#xA;  Wire.write((uint8_t)rangeByte);                 // Call the register for start of ranging data&#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.requestFrom(rec_address, 2);            // Request 2 bytes from SRF module&#xA;&#xA;  while(Wire.available() &amp;lt; 2);                    // Wait for data to arrive&#xA;  highByte = Wire.read();                           // Get high byte&#xA;  lowByte = Wire.read();                           // Get low byte&#xA;&#xA;  range = (highByte &amp;lt;&amp;lt; 8 ) + lowByte;              // Put them together&#xA;&#xA;&#xA; delay(120); &#xA;&#xA;&#xA; return(range);                                                    // Returns Range&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="4131" LastEditDate="2015-12-04T14:39:26.650" LastActivityDate="2015-12-04T14:39:26.650" Title="Too many Bytes Using Ultrasonic Sensors" Tags="|sensors|i2c|wire-library|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18306" PostTypeId="2" ParentId="18297" CreationDate="2015-12-01T10:56:22.483" Score="3" Body="&lt;p&gt;Ok, first of all I doubt you will be able to get a lot of measurements with that. Because... I know that kind of sensors and you will quickly get tired of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you have to connect&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;pin 1 to +5V&lt;/li&gt;&#xA;&lt;li&gt;pin 2 to ground&lt;/li&gt;&#xA;&lt;li&gt;pin 3 to +5V&lt;/li&gt;&#xA;&lt;li&gt;pin 4 to a resistor towards ground. Value has to be determined.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To chose the value, you have to try. Change resistor values until, in fresh air, the voltage you can sense across the resistor is approx 1V. I think it is arount 10k, but you'll have to try&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chosen the resistor, you have to simply attach the node between pin 4 and the resistor to an analog input and then read the voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you have to calibrate the sensor. Put it in a fixed-concentration gas and measure the voltage: &lt;code&gt;nCalib = analogRead(sensorPin);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, when you need to measure the concentration, you just have to read the voltage again with &lt;code&gt;nMeas = analogRead(sensorPin);&lt;/code&gt;. The factor Rs/Ro can be calculated with the formula&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rs_over_Ro = nCalib / (1024 - nCalib) * (1024 - nMeas) / nMeas;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you have the factor, look at the graph in figure 3 to get the concentration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZQnDt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZQnDt.png&quot; alt=&quot;figure 3: sensitivity for Mp503&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I told you, I think you will quickly get tired of it, but this is how to use it.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-12-01T10:56:22.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18307" PostTypeId="1" CreationDate="2015-12-01T11:00:48.187" Score="0" ViewCount="2511" Body="&lt;p&gt;I am having a problem with my Arduino freezing after a small amount of time. I'm using an RTC DS1307 breakout to keep track of the time and display the time on an LCD. It displays hours, minutes and seconds (updated every second).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I have 25V which is supplied by a transformer and connected to a set of LEDs through a &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/CAT4101-D.PDF&quot; rel=&quot;nofollow noreferrer&quot;&gt;CAT4101&lt;/a&gt; constant-current sink LED driver. The Arduino board is powered by a 2amp USB transformer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At a set time, the timer should set off the process to dim the lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is working well if I set the lights to dim within a few minutes. However, if I leave the board on for more than 10-15 minutes then everything seems to freeze (i.e. the time on the LCD stops being updated and stays stuck at the moment it froze).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I originally thought it could have been something to do with my code. But I then skimmed everything down to the bare essential and just uploaded the code necessary to update the time on the LCD. And even in this case it freezes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I managed to avoid things freezing was to disconnect the CAT4101 pin 1 from Arduino's PWM and disconnect pin 2 from Arduino's 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CAT4101&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pin 1 = connected to Arduino PWM&#xA;pin 2 = connected to +5v&#xA;pin 3 = connected to ground &#xA;pin 4 = connected to ground with 2kOhm resistor&#xA;pin 5 = connected to LED cathode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code below (I have stripped down the code by removing any additional functions and leaving only the bare code which is leading the application to crash).&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;RTC_DS1307 rtc;&#xA;DateTime now;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);&#xA;&#xA;void setup() { &#xA;  Wire.begin();&#xA;  rtc.begin();&#xA;  lcd.begin(16,2);&#xA;&#xA; if (!rtc.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    rtc.adjust(DateTime(__DATE__, __TIME__)); // time = hh:mm:ss format, e.g. 06:01:01&#xA;  }&#xA;&#xA;  lcd.clear();&#xA;}&#xA;&#xA;void loop() { &#xA;  now = rtc.now();&#xA;  updateDisplay();&#xA;}&#xA;&#xA;&#xA;void updateDisplay(){&#xA; int h = now.hour(); // Get the hours right now and store them in an integer called h&#xA; int m = now.minute(); // Get the minutes right now and store them in an integer called m&#xA; int s = now.second(); // Get the seconds right now and store them in an integer called s&#xA;&#xA; lcd.setCursor(0, 0); // Set the cursor at the column zero, upper row...&#xA; lcd.print(&quot; The time is: &quot;); // ...with spaces to clear characters from setting alarm.&#xA; lcd.setCursor(4, 1); // Move the cursor to column four, lower row&#xA; if (h&amp;lt;10){   // Add a zero, if necessary, as above&#xA;  lcd.print(0);&#xA; }&#xA; lcd.print(h);   // Display the current hour&#xA; lcd.setCursor(6, 1); // Move to the next column&#xA; lcd.print(&quot;:&quot;);  // And print the colon&#xA; lcd.setCursor(7, 1); // Move to the next column&#xA; if (m&amp;lt;10){   // Add a zero, if necessary, as above&#xA;  lcd.print(0);&#xA; }&#xA; lcd.print(m);   // Display the current minute&#xA; lcd.setCursor(9, 1); // Move to the next column&#xA; lcd.print(&quot;:&quot;);  // And print the colon&#xA; lcd.setCursor(10, 1); // Move to the next column&#xA; if (s&amp;lt;10){   // Add a zero, if necessary, as above&#xA;  lcd.print(0);&#xA; }&#xA; lcd.print(s);   // Display the current second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WPClR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WPClR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14363" LastEditorUserId="37523" LastEditDate="2019-07-24T17:32:54.057" LastActivityDate="2020-01-18T19:15:17.710" Title="Arduino is freezing after 10-15 minutes" Tags="|lcd|rtc|arduino-duemilanove|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="18310" PostTypeId="2" ParentId="17625" CreationDate="2015-12-01T13:57:34.907" Score="1" Body="&lt;p&gt;As @Gerben says, voltage dividers are a good place to start. To elaborate on the topic, you can use a combination of voltage dividers, zener diodes and clamping diodes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;a href=&quot;https://electronics.stackexchange.com/questions/35807/how-would-i-design-a-protection-clipper-circuit-for-adc-input&quot;&gt;EE.SE post&lt;/a&gt; has some good info about this, related to ADC, but still the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First off, a voltage divider circuit is easily found on the internet,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.google.com/search?q=voltage+divider&amp;amp;ie=utf-8&amp;amp;oe=utf-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Google&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This circuit from &lt;a href=&quot;http://hyperphysics.phy-astr.gsu.edu/hbase/electric/voldiv.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hyperphysics&lt;/a&gt; shows the basics:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cLmul.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cLmul.gif&quot; alt=&quot;Hyperphysics&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To add more protection to this so as not to go over the max I/O voltage of the MCU, you can add a zener diode on the &lt;strong&gt;V&lt;sub&gt;out&lt;/sub&gt;&lt;/strong&gt;. &#xA;That would give you something like this(&lt;a href=&quot;https://electronics.stackexchange.com/a/48317/46355&quot;&gt;Olins&lt;/a&gt;): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CSQ5O.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CSQ5O.gif&quot; alt=&quot;credit to Olin&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will give you the desired range to give legitimate High and Low on an I/O.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you wanted to forgo the voltage divider and zener you can use &lt;a href=&quot;https://en.wikipedia.org/wiki/Clamper_%28electronics%29&quot; rel=&quot;nofollow noreferrer&quot;&gt;clamping diodes&lt;/a&gt; to the microcontroller supply voltage Vcc. This will give a range that will not damage the I/O.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HrneK.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fHrneK.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 10k resistor is there to limit the current through the diodes, which are Schottky diodes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another method, which I have used before and is reliable, is to use a diode and two resistors like below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uDj4f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logic is that, when the input &lt;code&gt;IN&lt;/code&gt; is &gt; Vcc(5V) the signal on the I/O &lt;code&gt;_IN&lt;/code&gt; will be the voltage of the pull_up resistor &lt;code&gt;R2&lt;/code&gt;, if it is low or floating the signal will be low. R1 also gives a known logic state if the input floats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;: Changed the image to proper logic flow.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-01T18:08:26.007" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18311" PostTypeId="1" AcceptedAnswerId="18316" CreationDate="2015-12-01T14:26:44.363" Score="1" ViewCount="1183" Body="&lt;p&gt;I am currently working on a camera platform based on the MT9D111 module from Micron. The first thing to do is to write the configuration to the numerous registers of the chip which is done via an i2C connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I adapted the code from &lt;a href=&quot;https://hackaday.io/project/6386-usensecam/log/20618-checking-mt9d111-communication&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; for testing this with an Arduino Uno. 3.3V supply and 8MHz clock are also provided by the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to work fine, but there are some odds which I don't know the reason for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here is the code (I just added the soft reset sequence according to the Developers Guide):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int freqOutputPin = 9;   // OC1A output pin for ATmega328 boards&#xA;&#xA;#define TMR1 0&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;//#include &amp;lt;TimerOne.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  pinMode(freqOutputPin, OUTPUT);&#xA;  Serial.begin(9600);&#xA;&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS10);  //selecting prescaler 0b001 (Tclk/1)&#xA;  TCCR1B &amp;amp;= ~((1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS11)); // turn off CS12 and CS11 bits&#xA;  TCCR1A |= ((1 &amp;lt;&amp;lt; WGM11) | (1 &amp;lt;&amp;lt; WGM10)); //Configure timer 1 for TOP mode (with TOP = OCR1A)&#xA;  TCCR1B |= ((1 &amp;lt;&amp;lt; WGM13) | (1 &amp;lt;&amp;lt; WGM12));&#xA;  TCCR1A |= (1 &amp;lt;&amp;lt; COM1A0); // Enable timer 1 Compare Output channel A in toggle mode&#xA;  TCCR1A &amp;amp;= ~(1 &amp;lt;&amp;lt; COM1A1);&#xA;  TCNT1 = 0;&#xA;  OCR1A = TMR1;&#xA;&#xA;  delay(500);  //Initial delay&#xA;  Wire.begin(); // join i2c bus as master&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;MT9D111 Camera Module + Arduino&quot;);&#xA;  Serial.println(&quot;Read and Write 16-bit register value example&quot;);&#xA;  Serial.println(&quot;*  Read expected value = 0x1519 from Register 0x00&quot;);&#xA;  Serial.println(&quot;*  Write value = 0xA5F0 to Register 0x20:1&quot;);&#xA;  Serial.println();&#xA;  init1(); //execute code just 1 time&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;void init1() {&#xA;  int16_t a;&#xA;&#xA;  delay(500);  //wait until start&#xA;  Serial.print(&quot;Soft reset first&quot;);&#xA;  Serial.println();&#xA;  soft_reset();//do a soft reset at startup&#xA;&#xA; //***************Configuration here!****************//&#xA;  Serial.print(&quot;Read result from register 0x00&quot;);&#xA;  a = read_reg(0);&#xA;  Serial.println();&#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.println(a, HEX);  //print result&#xA;  Serial.println();&#xA;  Serial.print(&quot;Read original data from register 0x0a, should be 11&quot;);&#xA;  Serial.println();&#xA;  a = read_reg(10);  &#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.println(a, HEX);  //print result&#xA;  Serial.println();&#xA;&#xA;  //Enable this part for writing register&#xA;  //Some example reads and writes follow&#xA;  Serial.print(&quot;Writing 0xA5F0 in register 0x20:1&quot;);&#xA;  Serial.println();&#xA;  write_reg(32, 1, 165, 240);&#xA;  Serial.print(&quot;Read new value from register 0x20:1&quot;);&#xA;  Serial.println();&#xA;  a = read_reg(32);&#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.println(a, HEX);  //print result&#xA;  Serial.println();&#xA;  Serial.print(&quot;Writing 0xA1F3 in register 0x20:1&quot;);&#xA;  Serial.println();&#xA;  write_reg(32, 1, 161, 243);&#xA;  Serial.print(&quot;Read new value from register 0x20:1&quot;);&#xA;  Serial.println();&#xA;  a = read_reg(32);  &#xA;  Serial.print(&quot;0x&quot;);&#xA;  Serial.println(a, HEX);  //print result&#xA;  Serial.println();&#xA;}&#xA;&#xA;//Write 2Byte register&#xA;void write_reg(int reg_address, int page, int data_msb, int data_lsb) {&#xA;  delay(5);  //5ms&#xA;  Wire.beginTransmission(93); // transmit to device 93, Camera Module&#xA;  Wire.write(240);   //page register address&#xA;  Wire.write(0);&#xA;  Wire.write(page);   //select page 0/1/2&#xA;  Wire.endTransmission(1);    // stop transmitting&#xA;  Wire.beginTransmission(93); // transmit to device 93, Camera Module&#xA;  Wire.write(reg_address);   //register address 8bit, decimal&#xA;  Wire.write(data_msb);  //msbyte&#xA;  Wire.write(data_lsb);  //lsbyte&#xA;  Wire.endTransmission(1);    // stop transmitting&#xA;}&#xA;&#xA;//read 2Byte register&#xA;//be careful about selected register page&#xA;int16_t read_reg(int reg_address) {&#xA;  int16_t err;&#xA;  delay(5);  //5ms&#xA;  Wire.beginTransmission(93); // transmit to device 93, Camera Module&#xA;  Wire.write(reg_address);   //register address 8bit, decimal&#xA;  err = Wire.endTransmission(1);    // stop transmitting&#xA;  Serial.println(err);&#xA;  Wire.requestFrom(93, 2, 1); //request value form device 93, 2 bytes with stop bit&#xA;  int16_t result = ((Wire.read() &amp;lt;&amp;lt; 8) | Wire.read());  //read 16 bits&#xA;  return result;&#xA;}&#xA;&#xA;//Perform Soft reset, required at startup&#xA;void soft_reset(){&#xA;  write_reg(101, 0, 160, 0);//write registers according to dev guide&#xA;  write_reg(195, 1, 5, 1);&#xA;  write_reg(13, 0, 0, 33);&#xA;  delay(5);&#xA;  write_reg(13, 0, 0, 0);&#xA;  delay(5);//wait for i2c to be ready again&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running this code gives me the following result on the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8j3Tr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8j3Tr.png&quot; alt=&quot;Serial Monitor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here are the questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do you have any ideas why I get an extra FFFF when reading a register after writing it? (underlined in blue)&lt;/li&gt;&#xA;&lt;li&gt;Why are there some extra zeros in the output? (marked in yellow)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15261" LastEditorUserId="4628" LastEditDate="2015-12-02T08:15:55.420" LastActivityDate="2019-10-01T02:54:49.267" Title="I2C connection with MT9D111 camera module, strange results after writing registers via i2C" Tags="|arduino-uno|serial|programming|i2c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18312" PostTypeId="1" AcceptedAnswerId="18314" CreationDate="2015-12-01T14:33:35.060" Score="2" ViewCount="4887" Body="&lt;p&gt;I have a new DS1307 (original, not a Chinese rip off), with a new battery. It is working great, but when I turn the Arduino off (it is currently connected to laptop) and then turn it back on, it resets the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line that sets the time is (in setup part of code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setDS1307time(30, 42, 21, 4, 26, 11, 14);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, when the Arduino gets the power back it runs the program again and it overrides the correct current time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I avoid this?&lt;/p&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="4628" LastEditDate="2015-12-04T14:38:31.963" LastActivityDate="2015-12-04T20:08:35.220" Title="Arduino RTC - getting the time from RTC after the power is cut off" Tags="|arduino-uno|rtc|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18313" PostTypeId="1" CreationDate="2015-12-01T14:52:26.783" Score="6" ViewCount="15297" Body="&lt;p&gt;so for about the last 8.5 hours (almost non-stop) I have been trying to figure out one issue and I have exhausted every search I could possibly think of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm building a puzzle that requires 5 RFID readers on the 1 Arduino, but for the sake of testing i've only been using 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both readers work independantly, I can read out the UIDs of the little cards, which is all I need to do, but as soon as I make them share the MISO line, it simply stops printing anything out. I have no idea why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both readers have a common external 3.3v power supply and ground, they share all other lines but have an individual Slave Select. For testing I put both of their MISO cables into a breadboard which then leads into the Arduino on PIN 12, but it will only print out the UID when only ONE cable is plugged into the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there something special I need to do to make this work? Is there a reason why the readers sharing a MISO line would break it? Even if i don't initialise one of them, just for the fact that it's plugged in still breaks it. I have tried setting one to HIGH and one to LOW, both to LOW, both to HIGH, nothing changes it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, something else kind of confusing to me, it's meant to be active LOW to activate the SS, but when only 1 is plugged into the MISO line, it doesn't seem to matter which state it's in, it always prints...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a little bit of testing on my sketch just a moment ago and realised that when both are plugged into the MISO, the sketch will not progress past this line (which is also the first line in the loop)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( ! mfrc522_2.PICC_IsNewCardPresent())&#xA;        return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know everything else is working because it works when there is nothing else plugged into the MISO line, but I need it to work when all the others are plugged in too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please please please, if you have any idea, let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the MFRC522 Library&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is basically the setup i'm using:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/huuiu.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/huuiu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not using any voltage translators or shifters, everything is 5v from the arduino except for the power to the readers which is coming from an external 3.3v supply like mentions previously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty certain that this is the datasheet for the RC522 i'm using, though i'm not sure if it's V1 or V2, but given the differences between them I don't think it matters:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if they are able to share MISO lines like someone below said, I just assumed I could?&lt;/p&gt;&#xA;" OwnerUserId="15263" LastEditorUserId="15263" LastEditDate="2015-12-01T22:35:23.127" LastActivityDate="2020-11-04T14:50:57.093" Title="Issue sharing MISO with multiple RC522 RFID Readers" Tags="|arduino-uno|spi|rfid|" AnswerCount="3" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18314" PostTypeId="2" ParentId="18312" CreationDate="2015-12-01T15:29:11.047" Score="4" Body="&lt;p&gt;Without knowing the DS1307 well, I think there are two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make the setting of the clock a UI function (you should probably do this in any case since you will want users to have the ability to set the clock). The user would have to initiate the action (and put in the time to set) so there would be no problems the clock getting reset inappropriately, or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do a check for sanity of the clock before you run that line. You might be able to do that through the clock API (e.g., make a call to check the time, or to get the clock status and see if it makes sense) or you could do it by storing the clock status in nonvolatile memory. The very worst case would be that you store the time of last boot and check that it seems reasonable (e.g., the time you get from the RTC is after the last boot and is within reason – say no more than a month or a year ago). If the time is too far off to feel confident you could issue a &quot;check time&quot; warning.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you have a network connection using NTP as well as the RTC would be a very smart option. NTP can hold the time within a few milliseconds. The RTC would then provide you with protection against a network outage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using the Arduino to manage scheduled events one thing you'll want to think about is events that are scheduled in a moment of time that is either &quot;skipped&quot; as you advance the clock or that &quot;repeats&quot; if you set the clock back. One way to handle that is to never &quot;jump&quot; time, but to always just speed it up or slow it down.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-01T19:04:20.960" LastActivityDate="2015-12-01T19:04:20.960" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="18315" PostTypeId="2" ParentId="18284" CreationDate="2015-12-01T17:01:57.890" Score="0" Body="&lt;p&gt;The hardware connection should be the same, as blocking vs non-blocking is referring to how you handle the incoming data packets.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't quote me on this, but generally, blocking vs non-blocking refers to the use of &lt;code&gt;delay()&lt;/code&gt; or similar, which will block anything else from running while that function is being executed.&lt;/p&gt;&#xA;" OwnerUserId="7628" LastActivityDate="2015-12-01T17:01:57.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18316" PostTypeId="2" ParentId="18311" CreationDate="2015-12-01T17:33:53.310" Score="1" Body="&lt;p&gt;The &lt;code&gt;0&lt;/code&gt; comes from your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(err);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's printing the error code. 0, hence no error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the extra &lt;code&gt;FFFF&lt;/code&gt; I'd say it's because you are using signed integers. Change your &lt;code&gt;a&lt;/code&gt; declaration to &lt;code&gt;uint16_t&lt;/code&gt; and see if that fixes it.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastEditorUserId="4628" LastEditDate="2019-10-01T02:54:49.267" LastActivityDate="2019-10-01T02:54:49.267" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18317" PostTypeId="2" ParentId="18015" CreationDate="2015-12-01T17:58:15.987" Score="4" Body="&lt;p&gt;That's definitely a bug appeared in 1.6.6.&#xA;For reference, see&#xA;&lt;a href=&quot;https://blog.arduino.cc/2015/11/03/arduino-ide-1-6-6-released-and-available-for-download/#comment-278766&quot; rel=&quot;nofollow&quot;&gt;https://blog.arduino.cc/2015/11/03/arduino-ide-1-6-6-released-and-available-for-download/#comment-278766&lt;/a&gt;&#xA;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=359652.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=359652.0&lt;/a&gt;&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=357312.msg2476987#msg2476987&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=357312.msg2476987#msg2476987&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last link seems to provide a solution, by a &lt;strong&gt;updated version of LCD I2C lib&lt;/strong&gt; : &lt;a href=&quot;https://github.com/marcoschwartz/LiquidCrystal_I2C&quot; rel=&quot;nofollow&quot;&gt;https://github.com/marcoschwartz/LiquidCrystal_I2C&lt;/a&gt; (not yet tried).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 1.6.6 is a bit messy according some people, but the I2C lib too ;). So the question is : where should it be fixed ?&lt;/p&gt;&#xA;" OwnerUserId="8309" LastEditorUserId="8309" LastEditDate="2015-12-02T09:20:19.797" LastActivityDate="2015-12-02T09:20:19.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18318" PostTypeId="2" ParentId="18288" CreationDate="2015-12-01T18:00:06.803" Score="1" Body="&lt;p&gt;The workaround would be to configure the &lt;a href=&quot;https://github.com/shirriff/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/shirriff/Arduino-IRremote&lt;/a&gt; library referenced in your question to any available digital input.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-01T18:00:06.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18319" PostTypeId="1" CreationDate="2015-12-01T21:09:45.100" Score="7" ViewCount="590" Body="&lt;p&gt;My Due webserver was working perfectly fine for months when connected to Linux via the native port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when connected to Windows 10 via the native port, if the Arduino webserver is idle for about 5 minutes (when no client calls a webpage), then there is a strange 5-10 second delay before the webpage is able to load. This delay doesn't happen when connected to the webserver via the programming port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It almost seems like maybe Windows is putting the port to sleep when it notices an idle delay, and then it has to wait for the port to wake up before it can call the webpage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Windows &quot;Power Settings&quot; I set the computer to never go to sleep, and also in the Power &quot;Advanced Settings&quot; I disabled the USB &quot;selective suspend&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any ideas why there would be this strange delay only on Windows and only when connected via the native port?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ADDITIONS:&lt;/strong&gt; I made a simplified example that reproduces the problem on my machine. I wonder if anyone can see any problems with this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the python code. Note that if the python script is never run, there are no delays on the Arduino webserver, and everything works as expected.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial, sys&#xA;&#xA;SERIALPORT = &quot;COM5&quot; # Change this to your serial port!&#xA;&#xA;# Set up serial port&#xA;try:&#xA;  ser = serial.Serial(SERIALPORT, 115200, timeout=0)&#xA;except serial.SerialException:&#xA;  sys.exit()&#xA;&#xA;ser.write(&quot;Hello World&quot;)&#xA;print(&quot;Hello World&quot;)&#xA;&#xA;ser.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And below is the simplified Arduino code. It's just a simple webserver that serves a page that has a &quot;reload&quot; button that reloads the page. You can hit &quot;reload&quot; as many times as you want, and the program never freezes. But if you run the python code above and then try to reload the page, there is a long delay (anywhere between 10-60 seconds by my current estimate).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you comment out all of the &quot;SerialUSB.print&quot; lines that are anywhere in the loop (in this simplified case, there's only 1 line at: &quot;SerialUSB.println (data);&quot; in the processData function), then the webpage never freezes, even if you run the python code frequently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my real-world example, my python code was running once a minute, causing random freezes. If I stopped the python code from running, then there were no more freezes on the webpage. I ended up commenting out all of my SerialUSB.print statements that were in the loop, and that way I could have the python code running on schedule, and my program had full functionality (except for the loss of SerialUSB.print).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = {&#xA;  0x04, 0xBA, 0xB0, 0xCC, 0xDF, 0x04&#xA;};&#xA;EthernetServer server(80);&#xA;EthernetClient client;&#xA;&#xA;const byte MAX_INPUT = 25; //for processIncomingByte&#xA;&#xA;void setup ()&#xA;{&#xA;  SerialUSB.begin (115200);&#xA;  Ethernet.begin(mac);&#xA;  SerialUSB.print(&quot;server is at &quot;);&#xA;  SerialUSB.println(Ethernet.localIP());&#xA;}  // end of setup&#xA;&#xA;bool processIncomingByte (const byte inByte)&#xA;{&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;  switch (inByte)&#xA;  {&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;      if (input_pos == 0)&#xA;        return true;   // got blank line&#xA;      // terminator reached! process input_line here ...&#xA;      processData (input_line);&#xA;      // reset buffer for next time&#xA;      input_pos = 0;&#xA;      break;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1)) input_line [input_pos++] = inByte;&#xA;      break;&#xA;  }  // end of switch&#xA;  return false;    // don't have a blank line yet&#xA;} // end of processIncomingByteWeb&#xA;&#xA;void processData (const char * data)&#xA;{ //Note: since there are no GET requests in this simple example, I removed the parts for processing GET.&#xA;  SerialUSB.println (data);&#xA;  if (strlen (data) &amp;lt; 4)&#xA;    return;&#xA;}  // end of processDataWeb&#xA;&#xA;void loop ()&#xA;{&#xA;  client = server.available();&#xA;  if (client) {&#xA;    boolean done = false;&#xA;    while (client.connected() &amp;amp;&amp;amp; !done)&#xA;    {&#xA;      while (client.available () &amp;gt; 0 &amp;amp;&amp;amp; !done)&#xA;        done = processIncomingByte (client.read ());&#xA;    }  // end of while client connected&#xA;&#xA;      client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;      client.println(&quot;Content-Type: text/html&quot;);&#xA;      client.println();&#xA;      client.print(&quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&quot;);&#xA;      client.print(&quot;&amp;lt;a href=\&quot;/\&quot;&amp;gt;Reload&amp;lt;/a&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;);&#xA;      delay(10); client.stop();&#xA;  }&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not technically a problem for me anymore, except for having had to comment out all my &quot;SerialUSB.print&quot; statements. But I am interested in learning what is causing this strange behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: the &quot;processIncomingByte&quot; and &quot;processData&quot; functions are mainly from Mr. Gammon's writings and tutorials, and they are working flawlessly for me in 2 other Arduino webservers I have running. I wanted to note this because if I had written the functions myself, then obviously they would require much more scrutiny.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="11174" LastEditDate="2015-12-09T14:00:25.740" LastActivityDate="2017-08-24T20:00:44.040" Title="On Arduino Due webserver, there is a 5 second delay on Windows, only when connected via native port" Tags="|serial|arduino-due|web-server|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="18320" PostTypeId="1" AcceptedAnswerId="18332" CreationDate="2015-12-01T21:50:01.197" Score="4" ViewCount="854" Body="&lt;p&gt;I'd like to use my Teensy 3.1 to send MIDI Show Control messages using USB MIDI in order to control an ETC Nomad system. These are different from standard NoteOn, NoteOff, ProgramChange, etc. commands, but as far as I can tell they are not supported by the standard library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can send these messages directly (using lower level commands), as seen &lt;a href=&quot;http://www.mymidiremotes.com/home/?page_id=46&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, or does anyone know of a library that supports this? Google has, unusually, not been much help.&lt;/p&gt;&#xA;" OwnerUserId="3522" LastEditorUserId="3522" LastEditDate="2015-12-02T22:07:51.647" LastActivityDate="2015-12-02T22:07:51.647" Title="Teensy MIDI Show Control" Tags="|teensy|midi|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18321" PostTypeId="1" AcceptedAnswerId="18324" CreationDate="2015-12-01T23:30:45.827" Score="0" ViewCount="440" Body="&lt;p&gt;Is it possible to register a class instance member function with Arduino's &lt;a href=&quot;https://www.arduino.cc/en/Reference/WireOnReceive&quot; rel=&quot;nofollow&quot;&gt;Wire.OnReceive&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to make my code object-oriented, and want a specific non-static class function to handle I2C data, but if I'm reading &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=116685.0&quot; rel=&quot;nofollow&quot;&gt;this thread&lt;/a&gt; correctly, &lt;code&gt;onReceive&lt;/code&gt; is incompatible with classes since it only accepts a function pointer, which won't store context.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-12-02T00:16:33.250" Title="Using a class instance with Wire.onReceive" Tags="|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18322" PostTypeId="2" ParentId="1612" CreationDate="2015-12-01T23:40:03.393" Score="3" Body="&lt;p&gt;Note, there is also the NRF24LE1 SoC which has its own ULP MCU - good for transmitting simple data such as sensor readings. If used to Arduino, ARduino Pro Mini 3.3v and the NRF24L01+ is easier and better way to go. (Mod the Arduino to be ULP)&lt;/p&gt;&#xA;" OwnerUserId="15274" LastActivityDate="2015-12-01T23:40:03.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18323" PostTypeId="2" ParentId="18284" CreationDate="2015-12-02T00:02:50.170" Score="2" Body="&#xA;&#xA;&lt;p&gt;Reference page: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11428&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The blocking library is intended where you want to wait for incoming data, and are prepared to do nothing else while it arrives. There is also a timeout parameter which lets the code proceed if nothing happens for a specified number of milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The non-blocking library is intended for where you need to do other things (like control motors, or read switches) at the same time you are receiving data. For that situation you call an &lt;code&gt;update&lt;/code&gt; function periodically which assembles the incoming packet, byte-by-byte if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the data is fully received the &lt;code&gt;update&lt;/code&gt; returns true, and you can process the packet.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If so, how can a slave on the same line at the same time receive from master the message &quot;hello world&quot; and print it to the serial monitor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As I stated above in neither case do you receive and print &quot;at the same time&quot;, however the non-blocking one does not simply wait until all the data has arrived.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code from the linked page:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop ()&#xA;  {&#xA;  if (myChannel.update ())  // returns true when packet fully received&#xA;    {&#xA;    Serial.write (myChannel.getData (), myChannel.getLength ()); &#xA;    Serial.println ();&#xA;    }&#xA;&#xA;  // do other things while waiting&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If in example for non-blocking libraries is the same wiring as in the example of blocking library, where is (in non-blocking example) definition of RX(=2) and TX(=3) pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The hardware is the same.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;there is limitation for use - only pins which supports change interrupts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Of course. If the underlying protocol is SoftwareSerial then the usual limitations apply (that is for the Rx pin).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2015-12-02T22:01:46.460" LastActivityDate="2015-12-02T22:01:46.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18324" PostTypeId="2" ParentId="18321" CreationDate="2015-12-02T00:16:33.250" Score="0" Body="&lt;p&gt;A non-static class member function has an implicit &lt;code&gt;ClassName *this&lt;/code&gt; parameter inserted as the first parameter in the parameter list.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the function prototype required for &lt;code&gt;Wire.onReceive()&lt;/code&gt; does not have that parameter specified in its parameter list a non-static member function is not compatible with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same goes for &lt;code&gt;attachInterrupt()&lt;/code&gt; and anything else that takes a function pointer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-02T00:16:33.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18325" PostTypeId="2" ParentId="18015" CreationDate="2015-12-02T01:17:45.870" Score="2" Body="&lt;p&gt;I tried the solution described by AFract and it solved the problem. (sorry, I couldn't reply to his comment because I don't have enough reputation.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the new LiquidCrystal_I2C library here: &lt;a href=&quot;https://github.com/marcoschwartz/LiquidCrystal_I2C&quot; rel=&quot;nofollow&quot;&gt;https://github.com/marcoschwartz/LiquidCrystal_I2C&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Info on the code commit is here: &lt;a href=&quot;https://github.com/marcoschwartz/LiquidCrystal_I2C/pull/5&quot; rel=&quot;nofollow&quot;&gt;https://github.com/marcoschwartz/LiquidCrystal_I2C/pull/5&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15276" LastActivityDate="2015-12-02T01:17:45.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18326" PostTypeId="2" ParentId="18313" CreationDate="2015-12-02T02:12:16.630" Score="3" Body="&lt;p&gt;Looking at the &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet for the MFR522&lt;/a&gt;, it is not clear that it even supports multidrop SPI. It does not mention anything about the state of the SPI output pins when the chip is not selected. It also mentions that the chip uses the slave select line to detect what communication mode to use upon startup, but does not mention anything about how the chip will react to changes on that pin after startup.&lt;/p&gt;&#xA;&lt;p&gt;Considering this, along with the fact to your library also does not seem to support connections to multiple MFR522, my guess is that this chip only supports a 1-to-1 SPI link.&lt;/p&gt;&#xA;&lt;p&gt;Further, the SPI Timing characteristics in the datasheet specify how lon gthe SS (called NSS) must be high before communication can begin, but does not specify how long after SS goes low that the MISO goes tri-state, which would be an important thing to know if the chip did support multidrop SPI.&lt;/p&gt;&#xA;&lt;p&gt;This is all backed up by the behavior you are seeing. If both chips are driving the MISO line simultaneously, then communication will not be possible when both are connected.&lt;/p&gt;&#xA;&lt;p&gt;To support multiple MFR522 connections, you could possibly...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a multiplexing buffer to only enable SPI lines to one chip at a time. Downside is you would need Extra hardware, but upside is that you could probably use existing library intact by selecting the desired MFR522 before making the linrary calls.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect each MFR522 to different GPIO pins on the Arduino and bit bang the SPI to each chip independently. Upside is that you don't need any extra hardware and you potentially have a lot of flexibility on how you access the MFR522's. Downside is you will have to retrofit this bit-banged SPI into the library or use (or write) a different library.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I've seen this question come up many times over the years, so if you do choose option #2, please publish your code so others can use it!&lt;/p&gt;&#xA;&lt;h1&gt;An Experiment&lt;/h1&gt;&#xA;&lt;p&gt;I'd propose you do this to find out if your chips are compatible with multi-drop SPI...&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Power up your system with a RC522 reader.&lt;/li&gt;&#xA;&lt;li&gt;Check and make sure it works.&lt;/li&gt;&#xA;&lt;li&gt;Disconnect the SS and MISO lines from the RC522 so they are no longer connected to the Arduino (or anything else). Leave the RC522 powered up - if it resets it might loose the auto-detected SPI configuration.&lt;/li&gt;&#xA;&lt;li&gt;Use a jumper to connect the SS line to ground.&lt;/li&gt;&#xA;&lt;li&gt;Connect the MISO line to ground with a 1K ohm resistor.&lt;/li&gt;&#xA;&lt;li&gt;Use a multimeter to check the voltage on the MISO line.&lt;/li&gt;&#xA;&lt;li&gt;Connect the MISO line to Vcc with the 1K ohm resistor.&lt;/li&gt;&#xA;&lt;li&gt;Use a multimeter to check the voltage on the MISO line.&lt;/li&gt;&#xA;&lt;li&gt;Connect the SS line to Vcc.&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 3-6.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Report back the table of the 4 voltage readings you got and we should have our answer!&lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-02T04:32:21.420" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18327" PostTypeId="2" ParentId="17811" CreationDate="2015-12-02T04:35:52.190" Score="1" Body="&lt;p&gt;I tried to port Charles Lohr's implementation to esp8266/Arduino. An initial working version is up here: &lt;a href=&quot;https://github.com/AdySan/ESPSocket&quot; rel=&quot;nofollow&quot;&gt;https://github.com/AdySan/ESPSocket&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to get ~150Hz without any disconnections or crashes. I'll keep working on it to add more functionality and hopefully improve speed.&lt;/p&gt;&#xA;" OwnerUserId="15062" LastActivityDate="2015-12-02T04:35:52.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18328" PostTypeId="1" CreationDate="2015-12-02T04:54:40.563" Score="0" ViewCount="1165" Body="&lt;p&gt;sorry if I sound incompetent, but I know nothing about coding. I have a group project where I must sort various balls into different tracks. The final issue I have is that I must use an arduino for this portion. However, none of us know how to program, and the only experience we have is from doing the lessons from adafruit (copy and paste written code). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am attempting to do is attach a paddle to the tip of a high torque servo motor. I will then automatically feed the servo signals, ranging from 0 to 5. Each signal tells which position for the servo to turn to. Could anyone please help guide me in how to write this code? I was thinking of using &#xA;&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/overview&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; guide for my motor. However it uses a POT. My project must be completely automated. The positons also are all within 180*. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="15278" LastActivityDate="2015-12-02T11:25:54.007" Title="Making Servo Motor Automatically Move Based on Input" Tags="|motor|servo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18329" PostTypeId="1" CreationDate="2015-12-02T05:27:26.257" Score="3" ViewCount="1199" Body="&lt;p&gt;I am designing a home automation project. I want to control different home appliances through GSM. I am designing it in such a way that each apparatus is connected to an Arduino and bluetooth module. There is a master unit with Arduino, Bluetooth and GSM modules. When the user sends a message, the GSM receives it and communicates via Bluetooth to the corresponding Bluetooth module and Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to communicate between two Bluetooth modules of two Arduinos? Is there a better solution?&lt;/p&gt;&#xA;" OwnerUserId="15216" LastEditorUserId="4628" LastEditDate="2015-12-02T08:24:52.043" LastActivityDate="2016-02-02T18:09:09.710" Title="Communication between two Bluetooth modules of two Arduinos" Tags="|arduino-uno|bluetooth|gsm|wireless|home-automation|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18330" PostTypeId="2" ParentId="18329" CreationDate="2015-12-02T05:42:58.913" Score="2" Body="&lt;p&gt;I'm not sure how many bluetooth devices can be connected to your smartphone. But if you use smartphone, the you can eliminate the master Arduino. But as I said, it still depends on the number of devices you'd like to control. This is supposed to go in the comment section.&lt;/p&gt;&#xA;" OwnerUserId="13456" LastActivityDate="2015-12-02T05:42:58.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18332" PostTypeId="2" ParentId="18320" CreationDate="2015-12-02T08:14:21.840" Score="5" Body="&lt;p&gt;According to the &lt;a href=&quot;https://www.pjrc.com/teensy/td_midi.html&quot; rel=&quot;noreferrer&quot;&gt;documentation&lt;/a&gt;, SysEx messages are sent like any other messages:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;array[0] = 0xf0;&#xA;array[1] = 0x7f;&#xA;array[2] = 0x7f;&#xA;array[3] = 0x02;&#xA;array[4] = 0x7f;&#xA;array[5] = 0x01;&#xA;array[6] = 0xf7;&#xA;usbMIDI.sendSysEx(7, array);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6802" LastActivityDate="2015-12-02T08:14:21.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18333" PostTypeId="1" AcceptedAnswerId="18342" CreationDate="2015-12-02T08:14:50.923" Score="1" ViewCount="163" Body="&lt;p&gt;Actually I'm not good at English ;-) trying to ask to you. please understand me :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I needed connect SD card Shield and TFT LCD Screen to Arduino Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;successfully finished compile at source code but when i connect MISO together &lt;/p&gt;&#xA;&#xA;&lt;p&gt;it doesn't work. only SS pin is connected separate Pin's to Micro&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i make it work together to Micro.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;i've checked each device perfectly work at Micro&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plese Help me!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards and Thanks&lt;/p&gt;&#xA;" OwnerUserId="15282" LastActivityDate="2015-12-02T13:24:23.937" Title="multiple connection with ISP Pin at Arduino Micro" Tags="|arduino-micro|isp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18334" PostTypeId="2" ParentId="9111" CreationDate="2015-12-02T08:27:17.323" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://www.rinkydinkelectronics.com/library.php?id=51&quot; rel=&quot;nofollow&quot;&gt;UTFT library&lt;/a&gt; has a SmallFont which is 8x12. Not sure whether this is too big for you, but it could be worth looking into. It is ASCII only, so you might want to add some characters yourself. But as someone mentioned, memory is limited, so add sparingly.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastEditorUserId="4628" LastEditDate="2015-12-02T08:41:38.320" LastActivityDate="2015-12-02T08:41:38.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18337" PostTypeId="2" ParentId="18328" CreationDate="2015-12-02T11:25:54.007" Score="1" Body="&lt;p&gt;So you have a &quot;number&quot; and you want to set the servo to some angle. The logic is very simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If number is 0 then set angle to 90&lt;/li&gt;&#xA;&lt;li&gt;If number is 1 then set angle to 45&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How you &quot;get&quot; the number hasn't been specified, so I will assume you just have an integer with a value between 0 and 5 inclusive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting a servo's angle is as simple as &lt;em&gt;writing&lt;/em&gt; that angle to the servo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servo.write(45); // Set the angle to 45 degrees&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how do you join the two together?  Well, there's three different ways that spring to mind.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A string of &lt;code&gt;if&lt;/code&gt; statements&lt;/li&gt;&#xA;&lt;li&gt;A &lt;a href=&quot;http://hacking.majenko.co.uk/time-to-make-a-switch&quot; rel=&quot;nofollow&quot;&gt;switch&lt;/a&gt; construct&lt;/li&gt;&#xA;&lt;li&gt;An array&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first one is just like the bullet points above, just written as C:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (number == 0) servo.write(90);&#xA;if (number == 1) servo.write(45);&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second method is very similar but can be more efficient when you know you only ever select one item from a list of options.  Read this to see how: &lt;a href=&quot;http://hacking.majenko.co.uk/time-to-make-a-switch&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/time-to-make-a-switch&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third option, the array, is especially good when you have a lot of options to manage and they are all the same result with a different value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int angles[6] = {90, 45, 315, 0, 0, 0};&#xA;&#xA;// ... later ...&#xA;servo.write(angles[number]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-02T11:25:54.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18339" PostTypeId="1" AcceptedAnswerId="18340" CreationDate="2015-12-02T12:41:45.073" Score="3" ViewCount="634" Body="&lt;p&gt;I would like to use 652 unsigned long values on an Arduino Uno, but it doesn't look like there's enough memory. I thought about the splitting unsigned long values to 3 unsigned chars to store in PROGMEM which I can letter recall and join as unsigned long as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not super experienced with byte manipulations and I got myself stuck when trying to merge the data. When I try with one variable at a time, I get the expected output. The part I'm confused about is why do I get different values when using a variable as an array index for each value ? How can I fix this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my test code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &quot;flashData.h&quot;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  unsigned long fromPROGMEM = (onsets1[0] &amp;lt;&amp;lt; 16) | (onsets2[0] &amp;lt;&amp;lt; 8) | onsets3[0]; &#xA;  Serial.println(fromPROGMEM);&#xA;&#xA;  unsigned long fromValues = (0x00 &amp;lt;&amp;lt; 16) | (0x01 &amp;lt;&amp;lt; 8) | 0xF3;&#xA;  Serial.println(fromValues);&#xA;&#xA;  byte b1 = 0x00;&#xA;  byte b2 = 0x01;&#xA;  byte b3 = 0xF3;&#xA;&#xA;  unsigned long fromBytes = (b1 &amp;lt;&amp;lt; 16) | (b2 &amp;lt;&amp;lt; 8) | b3;&#xA;&#xA;  Serial.println(fromBytes);&#xA;  delay(2000);&#xA;&#xA;  unsigned char c1,c2,c3;&#xA;  unsigned long value;&#xA;&#xA;  Serial.println(&quot;data using same index:&quot;);&#xA;  for(int i = 0 ; i &amp;lt; 10; i++){&#xA;    c1 = onsets1[3];&#xA;    c2 = onsets2[3];&#xA;    c3 = onsets3[3];&#xA;    value = (c1 &amp;lt;&amp;lt; 16) | (c2 &amp;lt;&amp;lt; 8) | c3; &#xA;    Serial.print(&quot;index: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;\tvalue:&quot;);&#xA;    Serial.println (value);&#xA;    delay(10);&#xA;  }&#xA;&#xA;  Serial.println(&quot;data using counter:&quot;);&#xA;  for(int i = 0 ; i &amp;lt; 10; i++){&#xA;    c1 = onsets1[i];&#xA;    c2 = onsets2[i];&#xA;    c3 = onsets3[i];&#xA;    value = (c1 &amp;lt;&amp;lt; 16) | (c2 &amp;lt;&amp;lt; 8) | c3; &#xA;    Serial.print(&quot;index: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;\tvalue:&quot;);&#xA;    Serial.println (value);&#xA;    delay(10);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and flashData.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _flashData_h_&#xA;#define _flashData_h_&#xA;&#xA;static PROGMEM const unsigned char onsets1[652] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03};&#xA;static PROGMEM const unsigned char onsets2[652] = {0x01,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x25,0x26,0x28,0x29,0x2A,0x2B,0x2C,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x38,0x39,0x3A,0x3B,0x3C,0x3F,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x48,0x49,0x4A,0x4C,0x4D,0x4E,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x59,0x5A,0x5B,0x5C,0x5E,0x5F,0x61,0x63,0x64,0x65,0x67,0x6A,0x6B,0x6C,0x6D,0x6E,0x70,0x71,0x73,0x75,0x76,0x77,0x79,0x7C,0x7E,0x7F,0x80,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9E,0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xC0,0xC2,0xC4,0xC6,0xC9,0xCB,0xCD,0xCF,0xD2,0xD4,0xD6,0xD8,0xDA,0xDB,0xDD,0xDF,0xE0,0xE2,0xE4,0xE6,0xE7,0xE8,0xE9,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF4,0xF6,0xF7,0xF8,0xF9,0xFA,0xFD,0xFE,0xFF,0x00,0x01,0x02,0x03,0x06,0x07,0x08,0x0A,0x0D,0x0F,0x10,0x11,0x12,0x13,0x14,0x16,0x18,0x19,0x1A,0x1C,0x1D,0x1F,0x21,0x22,0x23,0x25,0x28,0x2A,0x2B,0x2C,0x2E,0x30,0x31,0x33,0x34,0x35,0x38,0x3C,0x3D,0x3E,0x41,0x42,0x44,0x45,0x46,0x47,0x48,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x53,0x54,0x56,0x57,0x58,0x59,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x63,0x65,0x66,0x67,0x69,0x6A,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x75,0x77,0x78,0x79,0x7A,0x7B,0x7D,0x7E,0x7F,0x80,0x82,0x84,0x87,0x89,0x8B,0x8E,0x90,0x92,0x94,0x97,0x99,0x9B,0x9D,0xA0,0xA2,0xA4,0xA5,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB9,0xBA,0xBB,0xBD,0xBF,0xC0,0xC2,0xC4,0xC6,0xC7,0xC8,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1,0xE2,0xE4,0xE6,0xE8,0xEA,0xEB,0xED,0xEF,0xF1,0xF2,0xF3,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFF,0x01,0x03,0x04,0x05,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0F,0x10,0x11,0x12,0x13,0x15,0x16,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x20,0x21,0x23,0x24,0x25,0x27,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x30,0x32,0x33,0x35,0x36,0x37,0x3A,0x3B,0x3C,0x3E,0x40,0x43,0x44,0x45,0x47,0x48,0x49,0x4A,0x4C,0x4D,0x4E,0x50,0x55,0x56,0x57,0x59,0x5A,0x5B,0x5E,0x5F,0x60,0x61,0x62,0x63,0x65,0x66,0x67,0x68,0x69,0x6B,0x6C,0x6F,0x70,0x71,0x72,0x73,0x74,0x76,0x77,0x79,0x7A,0x7B,0x7D,0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x99,0x9B,0x9D,0x9F,0xA2,0xA4,0xA6,0xA8,0xAB,0xAD,0xAF,0xB1,0xB4,0xB6,0xB7,0xB8,0xBB,0xBD,0xBE,0xBF,0xC0,0xC1,0xC2,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCC,0xCD,0xCE,0xCF,0xD1,0xD3,0xD6,0xD8,0xDA,0xDC,0xDE,0xDF,0xE0,0xE1,0xE3,0xE4,0xE5,0xE7,0xE8,0xE9,0xEA,0xEC,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFE,0x01,0x03,0x04,0x05,0x07,0x09,0x0A,0x0B,0x0C,0x0E,0x10,0x12,0x13,0x14,0x15,0x17,0x18,0x1A,0x1C,0x1E,0x1F,0x20,0x21,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x34,0x35,0x37,0x39,0x3C,0x3E,0x40,0x42,0x43,0x45,0x47,0x49,0x4A,0x4B,0x4C,0x4E,0x50,0x52,0x53,0x54,0x56,0x57,0x58,0x59,0x5B,0x5C,0x5D,0x5F,0x60,0x61,0x62,0x64,0x66,0x68,0x69,0x6B,0x6C,0x6D,0x6E,0x70,0x71,0x72,0x74,0x75,0x76,0x78,0x79,0x7B,0x7C,0x7D,0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x8A,0x8B,0x8C,0x8D,0x8F,0x90,0x91,0x93,0x94,0x95,0x96,0x97,0x98,0x9B,0x9D,0x9F,0xA1};&#xA;static PROGMEM const unsigned char onsets3[652] = {0xF3,0x31,0x59,0x76,0x98,0xBA,0xDD,0xFF,0x43,0x66,0x88,0xAA,0xC7,0xEF,0x0B,0x2D,0x50,0x72,0x8E,0xB1,0xD3,0xF5,0x17,0x3A,0x5C,0x7E,0xA0,0xC8,0xE5,0x0D,0x29,0x6E,0x90,0xAC,0xD5,0xF7,0x13,0x35,0x58,0x7A,0x9C,0xB9,0xE1,0xFD,0x42,0x6A,0x86,0xA8,0xC5,0x0F,0x31,0x54,0x7C,0x92,0xB5,0xCB,0xF9,0x1B,0x43,0x60,0xA4,0xC1,0xE3,0x28,0x4A,0x72,0x8E,0xB1,0xD3,0xF5,0x17,0x34,0x5C,0x78,0xBD,0xDF,0x01,0x46,0x62,0x84,0xCF,0x0D,0x30,0x52,0x7A,0x91,0xD5,0xF7,0x1A,0x5E,0x86,0xA3,0xE7,0x26,0x5F,0x92,0xAF,0xF3,0x1B,0x32,0x5A,0x7C,0x9F,0xBB,0xE3,0x00,0x28,0x4A,0x66,0x89,0xAB,0xC7,0x0C,0x34,0x4A,0x72,0x95,0xB7,0xD9,0xFB,0x1E,0x3A,0x62,0x7F,0x9B,0xC3,0xE0,0x2A,0x52,0x69,0x91,0xB3,0xD5,0xF7,0x1F,0x36,0x58,0x80,0x9D,0xB9,0xE1,0xF8,0x42,0x65,0x81,0xA9,0xCB,0xE8,0x10,0x54,0x93,0xD2,0x16,0x60,0x9F,0xE4,0x28,0x6D,0xAB,0xF0,0x12,0x34,0x79,0xB2,0xDA,0x02,0x46,0x85,0xAD,0xCF,0xF2,0x0E,0x30,0x4D,0x75,0x97,0xB9,0xD0,0xFE,0x1A,0x65,0x87,0xA3,0xC5,0xE2,0x2C,0x4E,0x6B,0x8D,0xAF,0xD7,0xEE,0x38,0x5B,0x77,0xC1,0x00,0x45,0x67,0x89,0xAB,0xCE,0xF0,0x01,0x57,0x7F,0x95,0xDA,0xFC,0x1E,0x5D,0x7F,0x9C,0xE0,0x25,0x6F,0x91,0xAE,0xF2,0x14,0x3C,0x7B,0x98,0xBA,0x04,0x82,0xAF,0xCC,0x16,0x33,0x77,0x94,0xBC,0xD2,0xFA,0x1D,0x3F,0x61,0x7D,0xA6,0xC8,0xE4,0x29,0x51,0x8F,0xAC,0xCE,0xF0,0x13,0x35,0x57,0x79,0x9C,0xBE,0xE0,0x02,0x47,0x69,0x8B,0xCA,0xF2,0x31,0x53,0x75,0x98,0xBA,0xD6,0xF9,0x15,0x5F,0x82,0xA4,0xC6,0xE8,0x05,0x33,0x60,0x7D,0xBC,0xFA,0x3F,0x83,0xC2,0x0C,0x51,0x95,0xD4,0x18,0x5D,0xA1,0xE0,0x25,0x69,0xA8,0xD0,0xE7,0x0F,0x31,0x53,0x75,0x98,0xB4,0xDC,0xF9,0x1B,0x3D,0x5F,0x7C,0xA4,0xC0,0x05,0x21,0x49,0x88,0xD2,0xF4,0x11,0x55,0x94,0xBC,0xDE,0x1D,0x4B,0x62,0x8F,0xAC,0xF0,0x2F,0x57,0x74,0x96,0xB2,0xD5,0xF7,0x1F,0x3B,0x63,0x86,0xAE,0xC4,0xEC,0x09,0x47,0x8C,0xD0,0xF3,0x15,0x54,0x98,0xC0,0xE2,0x05,0x21,0x66,0x88,0xA4,0xD2,0xEF,0x39,0x72,0xBC,0xD9,0xFB,0x23,0x3F,0x62,0x84,0xA0,0xC3,0xF0,0x07,0x2F,0x4C,0x74,0x90,0xCF,0xF7,0x13,0x3B,0x58,0x74,0x9C,0xB9,0xDB,0x03,0x1F,0x6A,0x86,0xA3,0xED,0x0F,0x31,0x4E,0x76,0x92,0xB5,0xF9,0x27,0x38,0x7C,0xA4,0xC1,0x05,0x28,0x4A,0x8E,0xCD,0x11,0x3A,0x50,0x9B,0xBD,0xDF,0x93,0x24,0x40,0x68,0xA7,0x2A,0x58,0x74,0xB9,0xDB,0xF7,0x3C,0x5E,0x80,0xA3,0xC5,0xE7,0x09,0x2C,0x48,0x70,0x8D,0xD1,0xF9,0x38,0x54,0x77,0x9F,0xBB,0xDD,0x00,0x22,0x60,0x83,0x9F,0xE9,0x11,0x2E,0x50,0x72,0x95,0xB7,0xDF,0xFB,0x18,0x40,0x5C,0x7F,0xA1,0xB8,0x08,0x2A,0x46,0x6E,0x8B,0xAD,0xD5,0xFD,0x14,0x58,0x97,0xDC,0x20,0x59,0xA9,0xEE,0x32,0x71,0xB5,0xF4,0x38,0x77,0x99,0xC1,0x06,0x4A,0x6D,0x8F,0xAB,0xCE,0xF0,0x0C,0x34,0x57,0x79,0x95,0xBD,0xDA,0x02,0x1E,0x46,0x5D,0xA7,0xE6,0x25,0x6F,0xAE,0xF2,0x14,0x37,0x5F,0x7B,0xC0,0xE8,0xFE,0x21,0x43,0x6B,0x8D,0xC6,0x10,0x33,0x55,0x77,0x99,0xBC,0xD8,0x00,0x1D,0x45,0x5B,0x83,0xA0,0xE4,0x29,0x67,0x8F,0xAC,0xF0,0x18,0x35,0x63,0x79,0xB8,0xFD,0xC1,0x4D,0x6F,0x86,0xCA,0xF2,0x09,0x4D,0x92,0xBA,0xD6,0xF9,0x15,0x37,0x59,0x82,0xA4,0xBA,0xE8,0x05,0x27,0x49,0x6B,0x8E,0xAA,0xCC,0xEF,0x17,0x33,0x78,0xB6,0x01,0x3F,0x7E,0xC3,0xEB,0x07,0x4C,0x90,0xB2,0xD5,0xFD,0x19,0x5E,0xA2,0xBE,0xE1,0x03,0x25,0x47,0x64,0xAE,0xD6,0xED,0x15,0x31,0x59,0x76,0xB5,0xF9,0x1B,0x3E,0x7C,0xA4,0xC7,0xE9,0x0B,0x33,0x50,0x8E,0xB6,0xD9,0x01,0x11,0x56,0x7E,0x95,0xDF,0x9F,0x13,0x29,0x46,0x68,0x8A,0xAC,0xC9,0xEB,0x0D,0x2A,0x52,0x6E,0xAD,0xCF,0xF7,0x25,0x30,0x64,0x7B,0xA3,0xBF,0x09,0x42,0x8D,0xCB};&#xA;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's what I see from Serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;499&#xA;499&#xA;499&#xA;data using same index:&#xA;index: 0    value:1654&#xA;index: 1    value:1654&#xA;index: 2    value:1654&#xA;index: 3    value:1654&#xA;index: 4    value:1654&#xA;index: 5    value:1654&#xA;index: 6    value:1654&#xA;index: 7    value:1654&#xA;index: 8    value:1654&#xA;index: 9    value:1654&#xA;data using counter:&#xA;index: 0    value:4294945024&#xA;index: 1    value:4294962688&#xA;index: 2    value:12806&#xA;index: 3    value:28928&#xA;index: 4    value:4294948096&#xA;index: 5    value:4294964224&#xA;index: 6    value:14337&#xA;index: 7    value:30464&#xA;index: 8    value:4294940928&#xA;index: 9    value:4294951174&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I see what I expect for first 3 values and also for data using same index, but no when using a variable as an index for the PROGMEM arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is going on and how can I fix this ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Mikael's answer is the solution, but I will post a working snippet here for reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &quot;flashData.h&quot;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  delay(2000);&#xA;&#xA;  unsigned char c1,c2,c3;&#xA;  unsigned long value;&#xA;&#xA;  Serial.println(&quot;data using counter:&quot;);&#xA;  for(int i = 0 ; i &amp;lt; 652; i++){&#xA;    c1 = (unsigned char) pgm_read_byte(&amp;amp;onsets1[i]);&#xA;    c2 = (unsigned char) pgm_read_byte(&amp;amp;onsets2[i]);&#xA;    c3 = (unsigned char) pgm_read_byte(&amp;amp;onsets3[i]);&#xA;    value = (((unsigned long) c1) &amp;lt;&amp;lt; 16) | ((unsigned long)c2 &amp;lt;&amp;lt; 8) | (unsigned long)c3; &#xA;    Serial.print(&quot;index: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;\tvalue:&quot;);&#xA;    Serial.println (value);&#xA;    delay(10);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The key is not only explicitly casting the data read, but also correctly reading the the PROGMEM data.&lt;/p&gt;&#xA;" OwnerUserId="3505" LastEditorUserId="3505" LastEditDate="2015-12-02T16:12:23.600" LastActivityDate="2015-12-02T16:12:23.600" Title="How to correctly pack an unsigned long from 3 unsigned chars?" Tags="|arduino-uno|memory-usage|progmem|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18340" PostTypeId="2" ParentId="18339" CreationDate="2015-12-02T13:15:11.837" Score="5" Body="&lt;p&gt;You can try (explict unsigned long values): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long fromValues = (0x00UL &amp;lt;&amp;lt; 16) | (0x01 &amp;lt;&amp;lt; 8) | 0xF3;&#xA;Serial.println(fromValues);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value = (((unsigned long) c1) &amp;lt;&amp;lt; 16) | (c2 &amp;lt;&amp;lt; 8) | c3; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is that the expression is implicit int and not long (as you are assuming). You need to tell the compiler about this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An extra bonus comment: There is actually a 24 bit integer definition in AVR GCC according to the &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc&quot;&gt;wiki, see Extensions, Types&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-02T13:15:11.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18341" PostTypeId="1" AcceptedAnswerId="18347" CreationDate="2015-12-02T13:17:24.337" Score="0" ViewCount="1992" Body="&lt;p&gt;I'm still very new to arduino and coding and having some difficulties trying to figure out what I am doing wrong here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This program is to have control over 2 relays, using a combination of an      IR receiver and a ir_remotecontrol with pre-programmed buttons (ir_remote buttons 1 = relay 1 toggle, button 2 = relay 2 toggle). &#xA;A master momentary hard wired switch to override changes to the relays and toggle their states i.e if both relays are on via ir remote - toggle them off, or if only 1 relay is on toggle it off with &#xA;first click of button then toggle both back on after second click of button. &#xA;The Bluetooth module and android app is to also control relays the same as the ir_remote via integers sent through the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It all sort of works at the moment...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I just work the relays using the ir remote and the momentary switch it all works perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;if I make sure the relays are in the off position using the remote switch and then use the Bluetooth it also works perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem only is when I use a combination of the ir remote or switch and the Bluetooth - things get weird - the Bluetooth commands seem to reverse and the relays start making a buzzing noise and the momentary switch muddles things up so basically it's all bad news! I've stared at this code for hours and tried a few different things but I just can't see what's wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if I need to give a more detailed example of the errors I am having. Just thinking it is probably obvious for you pro's out there when you see my noob code!.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*This program is to have control over 2 relays, using a cobination of   an IR reciever and remote control with pre programmed buttons    (ir_remote buttons 1 = relay 1 toggle, 2 = relay 2 toggle). &#xA;A master momentery hard wired switch to overide changes to the relays and toggle their states i.e if both relays are on via ir remote - toggle them off, or if 1 only relay is on toggle it off with first click of button then toggle both back on after sencond click of button. &#xA;Bluetooth module and andoid app to also control relays the same as the ir_remote.&#xA; */    &#xA;//include libaries, and initialise variables&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;#define irPin 8&#xA;#define RxD 7&#xA;#define TxD 6&#xA;#define relay1 13&#xA;#define relay2 12&#xA;#define buttonPin 2 &#xA;SoftwareSerial blueTooth(RxD, TxD);&#xA;IRrecv irrecv(irPin);&#xA;decode_results results;&#xA;int comdata; &#xA;const int wait = 30;&#xA;int sensorValue = 0;&#xA;int sensorOut = 0;&#xA;int relay1State = 0; &#xA;int relay2State = 0;&#xA;int masterState = 0;&#xA;int buttonState = 0;        &#xA;int lastButtonState = 0;   &#xA;long lastDebounceTime = 0;  &#xA;long debounceDelay = 50;    &#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  blueTooth.begin(38400);                     //set bluetooth baud rate&#xA;  delay(500);&#xA;  irrecv.enableIRIn();                        //enable infrared recieve&#xA;  pinMode(relay1, OUTPUT);                    //setting relays 1 &amp;amp; 2 to output&#xA;  pinMode(relay2, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);                  //setting momentery swith (overide) to inpt          &#xA;  digitalWrite(relay1, relay1State);          //putting current status of relays into a variable&#xA;  digitalWrite(relay2, relay2State);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if (blueTooth.available())                  //setting a variable for bluetooth recieved serial commands&#xA;  comdata = blueTooth.read();&#xA;&#xA;  if(comdata == '1'){&#xA;&#xA;  digitalWrite(relay1, relay1State);          //if bluetooth receivs &quot;1&quot; toggle relay1state -- essentially relay 1 ON&#xA;  }&#xA;  if(comdata == '0'){&#xA;  digitalWrite(relay1, !relay1State);         //if bluetooth receivs &quot;0&quot; toggle relay1state -- essentially relay 1 OFF&#xA;&#xA;  }&#xA;  if(comdata == '2'){&#xA;  digitalWrite(relay2, relay2State);          //if bluetooth receivs &quot;2&quot; toggle relay2state -- essentially relay 2 ON&#xA;&#xA;  }&#xA;  if(comdata == '3'){&#xA;  digitalWrite(relay2, !relay2State);         //if bluetooth receivs &quot;3&quot; toggle relay2state -- essentially relay 2 OFF&#xA;  }&#xA;&#xA;&#xA;  if (irrecv.decode(&amp;amp;results)){                     //Start listing for ir commands, if set remote button code is recvived toggle the variable relay1State or relay2state&#xA;  switch (results.value){&#xA;      case 0xFF30CF:&#xA;        relay1State = !relay1State;&#xA;        digitalWrite(relay1, relay1State);&#xA;        delay(250);&#xA;        break;&#xA;      case 0xFF18E7:&#xA;        relay2State = !relay2State;&#xA;        digitalWrite(relay2, relay2State);&#xA;        delay(250);&#xA;        break;&#xA;    }&#xA;    irrecv.resume();&#xA;    }&#xA;&#xA;  int reading = digitalRead(buttonPin);          //debounce used to help with faulse readings from momentery switch&#xA;  if (reading != lastButtonState) {&#xA;   lastDebounceTime = millis();&#xA;  }&#xA;  if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;&#xA;  if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;&#xA;  if (buttonState == HIGH) {                      //if the momentery switch is pressed toggle masterstate which is both relay 1 and relay 2 state&#xA;     masterState = !masterState;&#xA;     relay1State = masterState;&#xA;     relay2State = masterState;&#xA;      }&#xA;      }&#xA;    }&#xA;&#xA;  digitalWrite(relay1, relay1State);&#xA;  digitalWrite(relay2, relay2State);&#xA;  lastButtonState = reading;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15027" LastEditorUserId="9962" LastEditDate="2016-02-21T09:06:17.937" LastActivityDate="2016-02-21T09:06:17.937" Title="Controlling 2 relays with IR remote, push button and bluetooth - sort of works, need help!" Tags="|arduino-uno|bluetooth|relay|remote-control|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18342" PostTypeId="2" ParentId="18333" CreationDate="2015-12-02T13:24:23.937" Score="2" Body="&lt;p&gt;Each SPI device must have a separate device/slave select pin. The device must disconnect (high impedance state) when not selected. The SD shield will have a level shifter. It may not correctly disconnect from MISO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on what libraries you are using you might also need to check that they set the SPI hardware attributes correctly (clock, mode, etc). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help please post code and references to the shields and libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-02T13:24:23.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18343" PostTypeId="2" ParentId="18339" CreationDate="2015-12-02T13:37:58.600" Score="2" Body="&lt;p&gt;I got it to work by typecasting firmly and using multiplications:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println(&quot;data using counter:&quot;);&#xA;  for (int i = 0 ; i &amp;lt; 10; i++) {&#xA;    c1 = onsets1[i];&#xA;    c2 = onsets2[i];&#xA;    c3 = onsets3[i];&#xA;    value = (uint8_t)c3 + (uint16_t)((uint8_t)c2*256)+(uint32_t)(c1*65536);&#xA;    Serial.print(&quot;index: &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(c1, HEX);&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(c2, HEX);&#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(c3, HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(&quot;\tvalue:&quot;);&#xA;    Serial.println (value, HEX);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;data using counter:&#xA;index: 0    A1, F6, 0   value:A1F600&#xA;index: 1    FC, A7, 0   value:FCA700&#xA;index: 2    B5, 7A, B8  value:B57AB8&#xA;index: 3    EF, DB, 0   value:EFDB00&#xA;index: 4    14, F9, 0   value:14F900&#xA;index: 5    D7, 7F, 0   value:D77F00&#xA;index: 6    F2, 72, 1   value:F27201&#xA;index: 7    6F, DB, 0   value:6FDB00&#xA;index: 8    5E, 5E, 0   value:5E5E00&#xA;index: 9    F0, E7, B8  value:F0E7B8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-12-02T13:37:58.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18344" PostTypeId="1" CreationDate="2015-12-02T14:23:10.970" Score="2" ViewCount="1028" Body="&lt;p&gt;I made modifications on the original code of DMP6 MPU6050 to make it as I want. I took the standard libraries with it and they are &lt;code&gt;helper_3dmath.h&lt;/code&gt;, &lt;code&gt;MPU6050.cpp&lt;/code&gt;, &lt;code&gt;MPU6050.h&lt;/code&gt;, &lt;code&gt;MPU6050_6Axis_MotionApps20.h&lt;/code&gt;, &lt;code&gt;I2C.cpp&lt;/code&gt; and finally &lt;code&gt;I2c.cpp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a main.ino and &lt;code&gt;get_angles.cpp&lt;/code&gt;, which contains the code that has the function that calculates the angles out of the MPU6050. And a header file &lt;code&gt;get_angles.h&lt;/code&gt;. I am getting an error that I can't figure out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main.ino is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;get_angles.h&quot;&#xA;angles imu ;&#xA;MPU6050 mpu;&#xA;void setup() {&#xA;    Wire.begin();&#xA;     TWBR = 24;&#xA;     Serial.begin(115200);&#xA;     mpu.initialize();&#xA;     mpu.setDMPEnabled(true);&#xA;     packetSize = mpu.dmpGetFIFOPacketSize();&#xA;}&#xA;&#xA;void loop() {&#xA;  int yaw,pitch,roll;&#xA;  yaw =imu.get_yaw();&#xA;  pitch=imu.get_pitch();&#xA;  roll=imu.get_roll();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;get_angles.cpp&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;get_angles.h&quot;&#xA;int angles::get_yaw() {&#xA;  MPU6050 mpu;&#xA;  mpuIntStatus = mpu.getIntStatus();&#xA;  fifoCount = mpu.getFIFOCount();&#xA;  // check for overflow (this should never happen unless our code is too inefficient)&#xA;  if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;    // reset so we can continue cleanly&#xA;    mpu.resetFIFO();&#xA;    Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;  } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;    // wait for correct available data length, should be a VERY short wait&#xA;    while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;    // read a packet from FIFO&#xA;    mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;    // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;    // (this lets us immediately read more without waiting for an interrupt)&#xA;    fifoCount -= packetSize;&#xA;    mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;    mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;    mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;    int yaw;&#xA;    yaw=ypr[0] * 180/M_PI;&#xA;    return(yaw);&#xA;  }&#xA;}&#xA;&#xA;int angles::get_pitch() {&#xA;  MPU6050 mpu;&#xA;  mpuIntStatus = mpu.getIntStatus();&#xA;  fifoCount = mpu.getFIFOCount();&#xA;  // check for overflow (this should never happen unless our code is too inefficient)&#xA;  if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;    // reset so we can continue cleanly&#xA;    mpu.resetFIFO();&#xA;    Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;  } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;    // wait for correct available data length, should be a VERY short wait&#xA;    while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;    // read a packet from FIFO&#xA;    mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;    // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;    // (this lets us immediately read more without waiting for an interrupt)&#xA;    fifoCount -= packetSize;&#xA;    mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;    mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;    mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;    int pitch;&#xA;    pitch=ypr[1] * 180/M_PI;&#xA;    return(pitch);&#xA;  }&#xA;}&#xA;&#xA;int angles::get_roll() {&#xA;  MPU6050 mpu;&#xA;  mpuIntStatus = mpu.getIntStatus();&#xA;  fifoCount = mpu.getFIFOCount();&#xA;  // check for overflow (this should never happen unless our code is too inefficient)&#xA;  if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;    // reset so we can continue cleanly&#xA;    mpu.resetFIFO();&#xA;    Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;  } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;    // wait for correct available data length, should be a VERY short wait&#xA;    while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;    // read a packet from FIFO&#xA;    mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;    // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;    // (this lets us immediately read more without waiting for an interrupt)&#xA;    fifoCount -= packetSize;&#xA;    mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;    mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;    mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;    int roll;&#xA;    roll=ypr[2] * 180/M_PI;&#xA;    return(roll);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;get_angles.h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;#ifndef get_angles_H&#xA;#define get_angles_H&#xA;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;static   uint16_t packetSize;&#xA;class angles {&#xA;  public:&#xA;    int get_yaw();&#xA;    int get_pitch();&#xA;    int get_roll();&#xA;  private:&#xA;    uint8_t mpuIntStatus;&#xA;    uint16_t fifoCount;     // count of all bytes currently in FIFO&#xA;    uint8_t fifoBuffer[64]; // FIFO storage buffer&#xA;    Quaternion q;           // [w, x, y, z] quaternion container&#xA;    VectorFloat gravity;    // [x, y, z] gravity vector&#xA;    float ypr[3];           // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error I am facing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.5 (Windows 8.1), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpInitialize()'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpPacketAvailable()'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(long*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(int*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(VectorInt16*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(long*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(int*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(Quaternion*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(long*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(int*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(VectorInt16*, unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetEuler(float*, Quaternion*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpProcessFIFOPacket(unsigned char const*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpReadAndProcessFIFOPacket(unsigned char, unsigned char*)'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':&#xA;C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetFIFOPacketSize()'&#xA;get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here&#xA;collect2.exe: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15290" LastEditorUserId="3917" LastEditDate="2015-12-03T22:02:17.797" LastActivityDate="2015-12-03T22:02:17.797" Title="Error in modification on MPU6050_DMP6" Tags="|arduino-uno|c++|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18345" PostTypeId="2" ParentId="18300" CreationDate="2015-12-02T15:34:08.933" Score="0" Body="&lt;p&gt;While USB &lt;em&gt;is&lt;/em&gt; a serial protocol, it's a completely different serial protocol than the RS-232-style logic-level serial protocol that the Serial library supports.  So the approach mentioned in the question has no logical chance of working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the USB electrical signal is differential (double-ended, or line-to-line, rather than single-ended, or line-to-ground).  So the mentioned approach has no electrical chance of working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What may work is to wire from Tx on the Uno to Rxd1 on the Leostick, and from Rx to Txd1, unless that conflicts with the Leostick's USB-Serial link.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-02T15:34:08.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18346" PostTypeId="2" ParentId="18341" CreationDate="2015-12-02T16:18:39.973" Score="2" Body="&lt;p&gt;Only the button changes &lt;code&gt;relay1State&lt;/code&gt; and &lt;code&gt;relay2State&lt;/code&gt;. The IR and BT only change the pin using digitalWrite. But then in the last 3 lines, the pin is changed back to the value of &lt;code&gt;relay1State&lt;/code&gt; and &lt;code&gt;relay2State&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think for the IR and BT you need to change e.g. &lt;code&gt;digitalWrite(relay2, !relay2State);&lt;/code&gt; to &lt;code&gt;relay2State=false;&lt;/code&gt; etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS It there a pull-up/pull-down resistor on the button pin?&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-02T16:18:39.973" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18347" PostTypeId="2" ParentId="18341" CreationDate="2015-12-02T16:25:12.203" Score="1" Body="&lt;p&gt;Looks like it could be reusing the old comdata values in the first part of loop().  Maybe make the first chunk:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (blueTooth.available()) {&#xA;      comdata = blueTooth.read();&#xA;      switch (comdata) {  // set state variables based on bluetooth&#xA;      case  '0':  // if bluetooth receivs &quot;0&quot; clear 1&#xA;          relay1State = 0;&#xA;          break; &#xA;      case  '1':  // if bluetooth receivs &quot;1&quot; set 1&#xA;          relay1State = 1; &#xA;          break; &#xA;      case  '2':  // if bluetooth receivs &quot;2&quot; set 2&#xA;          relay2State = 1;&#xA;          break; &#xA;      case  '3':  // if bluetooth receivs &quot;1&quot; clear2&#xA;          relay2State = 0; &#xA;          break; &#xA;&#xA;      case  '4':  // if bluetooth receivs &quot;4&quot; toggle 1&#xA;          relay1State = !relay1State; &#xA;          break; &#xA;      case  '5':  // if bluetooth receivs &quot;5&quot; toggle 2&#xA;          relay2State = !relay2State; &#xA;          break; &#xA;      case  '6':  // if bluetooth receivs &quot;6&quot; toggle master/both&#xA;          masterState = relay1State = relay2State = !masterState;&#xA;          break; &#xA;      }  // end of switch&#xA;      // apply state variables to outputs&#xA;      // (could be left to the end of the loop() code)&#xA;      digitalWrite(relay1, relay1State);  &#xA;      digitalWrite(relay2, relay2State);&#xA;   } // end of bluetooth processing&#xA;&#xA;   ... /// IR processing code&#xA;&#xA;   // debounce button and toggle masterstate &amp;amp; set state vars accordingly&#xA;   // see http://arduino.stackexchange.com/questions/17443/how-to-simulate-delay-to-debounce-mechanical-button-using-millis&#xA;   // &#xA;&#xA;// re-ensure output state matches the state variables.&#xA;digitalWrite(relay1, relay1State);&#xA;digitalWrite(relay2, relay2State);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As it is, the if() statements trigger on the state of the last read comdata, not on the whether a new command was read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, maybe check whether the toggling comments match the code or the code matches the intention properly.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2015-12-03T23:39:11.467" LastActivityDate="2015-12-03T23:39:11.467" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18348" PostTypeId="1" AcceptedAnswerId="18355" CreationDate="2015-12-02T16:28:15.437" Score="2" ViewCount="4686" Body="&lt;p&gt;Is there a variable data type available for Arduino? I have a class that should have a member that will differ in data type, in the past I have used the &quot;variable&quot; keyword in c++ but when I tried to use it the compiler yelled at me. I searched online and found a couple of articles that mentioned that if you are using an alternate GUI (I am using eclipse mars) that you can enable the feature but I can not find the correct settings as the examples I had found were for Juno and below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of what I am trying to accomplish&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class DisplayItem{&#xA;&#xA;   public:&#xA;   variant *displayVar;&#xA;&#xA;   void Display(){&#xA;      Serial.println(displayVar);&#xA;   }&#xA;}&#xA;&#xA;int intDisplay;&#xA;String strDisplay;&#xA;&#xA;DisplayItem item();&#xA;item.displayVar = &amp;amp;intDisplay;&#xA;item.Display();&#xA;item.displayVar = &amp;amp;strDisplay;&#xA;item.Display();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I realize I could create a overloaded function to display different data types but it would be allot easier if I could simply assign a reference to a variant datatype and reuse the variable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after looking through the answers I think I have this figured out. I needed to keep track of which variable was being set, I put together a quick example in hopes it will help someone else out with the same question.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class DisplayItem{&#xA;&#xA;   private:&#xA;   int iVarType;&#xA;&#xA;   union{&#xA;      int *i;&#xA;      float *f;&#xA;   } displayVar;&#xA;&#xA;   public:&#xA;   void SetVar(int *var){&#xA;      displayVar.i = var;&#xA;      iVarType = 0;&#xA;   }&#xA;&#xA;   void SetVar(float *var){&#xA;      displayVar.f = var;&#xA;      iVarType = 1;&#xA;   }&#xA;&#xA;   void Display(){&#xA;      if (iVarType == 0){&#xA;         Serial.println(displayVar.i);&#xA;      }else if (iVarType == 1){&#xA;         Serial.println(displayVar.f);&#xA;      }&#xA;   }&#xA;}&#xA;&#xA;int intDisplay = 1;&#xA;float floatDisplay = 0.123;&#xA;&#xA;DisplayItem item();&#xA;item.SetVar(&amp;amp;intDisplay);&#xA;item.Display();&#xA;item.SetVar(&amp;amp;floatDisplay);&#xA;item.Display();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will Display:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;0.123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="14761" LastEditDate="2015-12-03T21:40:21.483" LastActivityDate="2015-12-03T21:40:21.483" Title="Arduino Variable Data Type?" Tags="|programming|arduino-mega|data-type|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18349" PostTypeId="1" AcceptedAnswerId="18356" CreationDate="2015-12-02T16:30:07.767" Score="5" ViewCount="161" Body="&lt;p&gt;I'm taking my first wobbly steps outside the Arduino IDE and I'm not having much success with timers / interrupts. I can set a pin to output and light an LED with registers fine but I cannot for the life of me get it to blink using a timer. I have tried numerous tutorials and followed the Atmel ATmega328 datasheet very closely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using an Arduino Uno R3 &amp;amp; Atmel ICE (ISP.) My dev system is Raspbian (Debian) with the GNU AVR toolchain (avr-gcc, avr-objcopy, avrdude.) Apart from not having a bootloader it's a bog standard board (including fuses.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;ISR(TIMER0_COMPA_vect)&#xA;{&#xA;    PORTB ^= (1 &amp;lt;&amp;lt; PB5); // Toggle Arduino Pin #13&#xA;}&#xA;&#xA;int main (void)&#xA;{&#xA;    DDRB = (1 &amp;lt;&amp;lt; DDB5); // Arduino Pin #13 is Output&#xA;&#xA;    cli(); // Clear Interrupts&#xA;&#xA;    OCR0A = (unsigned char)0xFF; // Compare Register A = 255&#xA;    TIMSK0 = (1 &amp;lt;&amp;lt; OCIE0A); // Enable Interrupt for Comp. Reg. A&#xA;    TCCR0A = (1 &amp;lt;&amp;lt; WGM01); // CTC Mode&#xA;&#xA;    sei(); // Set Interrupts&#xA;    TCCR0B = (1 &amp;lt;&amp;lt; CS02) | (1 &amp;lt;&amp;lt; CS00); // Divide by 1024 Prescaler (GO!)&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know if I'm just not seeing something or if I've set registers in the wrong order but it's driving me crazy.&lt;/p&gt;&#xA;" OwnerUserId="15295" LastEditorUserId="37523" LastEditDate="2019-11-30T20:41:25.000" LastActivityDate="2019-11-30T20:41:25.000" Title="Trouble with Timer 0" Tags="|interrupt|atmega328|timers|avrdude|avr-gcc|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18350" PostTypeId="2" ParentId="18348" CreationDate="2015-12-02T16:40:46.047" Score="1" Body="&lt;p&gt;No, there is no such thing.  The whole concept of &quot;type&quot; only exists during compilation, not at run-time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can &quot;emulate&quot; it using &quot;setters&quot; and keeping your own internal state information:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Thing {&#xA;    private:&#xA;        String *strvar;&#xA;        int intvar;&#xA;        int type;&#xA;&#xA;    public:&#xA;        void set(int val) {&#xA;            intvar = val;&#xA;            type = 1;&#xA;        }&#xA;        void set(String &amp;amp;str) {&#xA;            strval = &amp;amp;str;&#xA;            type = 2;&#xA;        }&#xA;        void Display() {&#xA;            if (type == 1) {&#xA;                Serial.print(&quot;Value: &quot;);&#xA;                Serial.println(intval);&#xA;            } else if (type == 2) {&#xA;                Serial.print(&quot;String: &quot;);&#xA;                Serial.println(strval);&#xA;            } else {&#xA;                Serial.println(&quot;Something went wrong&quot;);&#xA;            }&#xA;        }&#xA;};&#xA;&#xA;Thing t;&#xA;String s = &quot;This is a string&quot;;&#xA;int i = 23;&#xA;t.set(s);&#xA;t.Display();&#xA;t.set(i);&#xA;t.Display();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The multiple functions named the same but with different parameters are &lt;em&gt;overloaded&lt;/em&gt;. The best match is picked at compile time.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-02T16:40:46.047" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18351" PostTypeId="1" CreationDate="2015-12-02T18:51:53.367" Score="1" ViewCount="1041" Body="&lt;p&gt;I am trying to update the Arduino library via the library manager and I tried to download it from the link given in the firmata_test program:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WARNING: Category '' in library ArduinoUnit is not valid. Setting to&#xA;  'Uncategorized'&#xA;  C:\Users\SAURAB~1\AppData\Local\Temp\arduino_c8217a5b56c170d64dfe4c80a1a205dc\firmata_test.ino:&#xA;  In member function 'virtual void test_beginPrintsVersion::once()':&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\SAURAB~1\AppData\Local\Temp\arduino_c8217a5b56c170d64dfe4c80a1a205dc\firmata_test.ino:32:3:&#xA;  warning: narrowing conversion of '249' from 'int' to 'char' inside { }&#xA;  [-Wnarrowing]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;};&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;^&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Multiple libraries were found for &quot;Firmata.h&quot;  Used:&#xA;  C:\Users\saurabh2836\Documents\Arduino\libraries\Firmata  Not used:&#xA;  C:\Program Files (x86)\Arduino\libraries\Firmata&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm getting this error. I searched but found no conclusive answer. I'm using Windows 8 64bit and Firmata downloaded from &lt;a href=&quot;http://www.firmata.org/&quot; rel=&quot;nofollow&quot;&gt;http://www.firmata.org/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong?&lt;/p&gt;&#xA;" OwnerUserId="15067" LastEditorUserId="4628" LastEditDate="2015-12-03T14:36:39.400" LastActivityDate="2015-12-08T09:22:43.390" Title="Issue in installing Arduino unit library and running with Firmata test application" Tags="|arduino-uno|firmata|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18352" PostTypeId="1" CreationDate="2015-12-02T18:58:22.093" Score="0" ViewCount="896" Body="&lt;p&gt;I am trying to learn and understand the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow&quot;&gt;COSA Library&lt;/a&gt; using a 12864ZW (ST7920) 128X64 LCD Display. Right now I am able to use the LCD using the u8glib but also found that COSA has a library for the &lt;a href=&quot;https://dl.dropboxusercontent.com/u/993383/Cosa/doc/html/dir_6c9b05e5d5923c236f9de149d085166d.html&quot; rel=&quot;nofollow&quot;&gt;ST7920 Display&lt;/a&gt;, I originally used &lt;a href=&quot;http://overskill.alexshu.com/128x64-12864-lcd-w-arduino-serial/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; to get things working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem that I have now is in the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/ST7920/ST7920.hh&quot; rel=&quot;nofollow&quot;&gt;ST7920 Documentation&lt;/a&gt; there is a schematic that shows how to hook up a ST7920 Compatible LCD. The first &lt;a href=&quot;http://overskill.alexshu.com/128x64-12864-lcd-w-arduino-serial/&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; only uses 3 lines from the Mega and the Cosa is using what looks like 6 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the header file, it looks like it is derived from the HD44780 Class and what I can gather is pins 16 and 4 are hard coded for something? I am not quite clear on how to use the Cosa version of the library. Can someone please give me a explanation and perhaps a explanation on how to get this working using Cosa? &lt;/p&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2015-12-02T20:49:53.207" Title="Arduino Mega, ST7920 using COSA" Tags="|arduino-mega|lcd|st7920|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18354" PostTypeId="1" AcceptedAnswerId="18357" CreationDate="2015-12-02T19:07:08.763" Score="2" ViewCount="1211" Body="&lt;p&gt;I am using an Arduino to control some mechanical components in a project I have. It controls a motor, two servos, a valve, and a compressor. When plugged into the computer, everything works fine and perfectly. However, when I power it through the barrel jack using our power supply, some weird things happen. First of all, our servos, which are powered through the Arduino, stop working. All the other components work except for them. Secondly, at the end of the code we have a 5 second delay. Using the computer it works fine. When powered with our supply the delay doesn't seem to happen at all. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="15296" LastEditorUserId="3917" LastEditDate="2015-12-16T08:20:24.477" LastActivityDate="2015-12-16T13:08:26.453" Title="Arduino Not Working as Intended when using barrel jack" Tags="|arduino-uno|power|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18355" PostTypeId="2" ParentId="18348" CreationDate="2015-12-02T19:07:10.140" Score="2" Body="&lt;p&gt;For the situation illustrated in the question – displaying data – polymorphic functions already exist, and might as well be used in this case.  Specifically, use the &lt;code&gt;Streaming.h&lt;/code&gt; &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;contributed library&lt;/a&gt;.  It adds some “syntactic sugar” to Arduino C.  At compile time it converts C++-like &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; Serial stream operators to &lt;code&gt;Serial.print&lt;/code&gt; statements, without increasing code size.  You can install it via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow&quot;&gt;arduiniana.org&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other cases, a &lt;code&gt;union&lt;/code&gt; data structure allows treating an area of memory different ways.  Wikipedia's &lt;em&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Union_type&quot; rel=&quot;nofollow&quot;&gt;Union type&lt;/a&gt;&lt;/em&gt; article explains the general idea.  See eg &lt;a href=&quot;http://www.tutorialspoint.com/cprogramming/c_unions.htm&quot; rel=&quot;nofollow&quot;&gt;tutorialspoint.com/cprogramming&lt;/a&gt; for &lt;code&gt;union&lt;/code&gt; syntax and usage.  For some reason, arduino.cc's &lt;a href=&quot;https://www.arduino.cc/en/Reference/HomePage&quot; rel=&quot;nofollow&quot;&gt;Language Reference&lt;/a&gt; page hasn't got &lt;code&gt;union&lt;/code&gt; on its list of language features.  However, mcgurrin.com has a page called &lt;em&gt;&lt;a href=&quot;http://www.mcgurrin.com/robots/?p=127&quot; rel=&quot;nofollow&quot;&gt;There is Power in a Union&lt;/a&gt;&lt;/em&gt; that codes a simple Arduino C example two ways (where &lt;code&gt;bearing&lt;/code&gt; is an &lt;code&gt;int&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;higherByte = compass.read();&#xA;lowerByte = compass.read();&#xA;bearing = ((higherByte&amp;lt;&amp;lt;8)+lowerByte)/10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;-vs-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union Data {&#xA;  byte b[2];&#xA;  int value;&#xA;};&#xA;...&#xA;union Data data;&#xA;data.b[0] = compass.read();&#xA;data.b[1] = compass.read();&#xA;bearing = data.value/10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-02T19:07:10.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18356" PostTypeId="2" ParentId="18349" CreationDate="2015-12-02T19:18:56.207" Score="4" Body="&lt;p&gt;&lt;code&gt;return 0&lt;/code&gt; resets the device. Use &lt;code&gt;while(1);&lt;/code&gt; instead, to make it wait indefinitely.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-02T19:18:56.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18357" PostTypeId="2" ParentId="18354" CreationDate="2015-12-02T20:00:28.127" Score="0" Body="&lt;p&gt;I believe that the problem that you are facing is lack of power. It is likely that your power source cannot supply enough current or voltage to power the equipment AND the arduino. Try to get a power supply that has more amps.&lt;/p&gt;&#xA;" OwnerDisplayName="user15297" LastActivityDate="2015-12-02T20:00:28.127" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18358" PostTypeId="1" CreationDate="2015-12-02T20:34:16.960" Score="0" ViewCount="801" Body="&lt;p&gt;I am completely lost here, I have no idea what I am doing wrong. I am using Eclipse Mars using the Eclipse C++ Arduino extension. I am also using the COSA library, this is where the problem comes in. I can use all of the core COSA libraries but I can not figure out how to include the other libraries that are supplied with COSA specifically the ST7920.h file that is located in the libraries folder. Does anyone have any experience with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried setting the path using the Project-&gt;C/C++ General-&gt;Preprocessor include paths and setting it there to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that I am concerned about is in these separate libraries they are including files that are in other libs using only the header file, for example in the ST7920.hh file it has:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Cosa/LCD.hh&quot;&#xA;#include &amp;lt;HD44780.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I need to configure things so that the HD44780.h file needs to be found also. That file is located at &quot;../HD44780/HD44780.h&quot;. How do I tell the compiler to search the &quot;libraries&quot; folder for files?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I tried to simply add the libraries folder as a linked folder in my project, that also did not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the only code I have is the #include  and the compiler come back with that it can't find the file.&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="14761" LastEditDate="2015-12-02T21:01:58.740" LastActivityDate="2018-08-14T22:01:20.110" Title="Eclipse add library" Tags="|arduino-mega|eclipse|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18359" PostTypeId="2" ParentId="18352" CreationDate="2015-12-02T20:49:53.207" Score="1" Body="&lt;p&gt;The Cosa ST7920 library uses text mode only (16X4). The ST7920 class is controlled though an adapter. There are several adapters available depending on how you wish to connect to the Arduino. They range from parallel 4-bit to SPI with shift register. The adapters implement the interface &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/HD44780/HD44780.hh#L44&quot; rel=&quot;nofollow&quot;&gt;HD44780::IO&lt;/a&gt;. There are several LCD examples. The &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/LCD/CosaLCDbench/CosaLCDbench.ino&quot; rel=&quot;nofollow&quot;&gt;CosaLCDbench&lt;/a&gt; shows the possible configurations with LCD and Adapters. Please see the file for further details.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-02T20:49:53.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18360" PostTypeId="2" ParentId="18358" CreationDate="2015-12-02T21:09:00.460" Score="0" Body="&lt;p&gt;If you are using Linux I would recommend looking at the makefile based build script for Cosa (See &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/tree/master/build&quot; rel=&quot;nofollow&quot;&gt;Cosa/build&lt;/a&gt;). After configuration building from any IDE is more or less a simple command. No Makefile is required. The script cosa will do all the work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cosa BOARD ACTION&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cosa uno avanti&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will build a sketch for Arduino Uno, upload and start a serial monitor. This can be used from any IDE. I use GNU Emacs, M-X compile (F2), with the command. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way the Arduino pre-processor works each referenced library needs to be included in the sketch. For a sketch that uses ST7920:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;HD44780.h&amp;gt;&#xA;#include &amp;lt;ST7920.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-02T21:09:00.460" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18361" PostTypeId="1" CreationDate="2015-12-02T21:13:39.947" Score="0" ViewCount="907" Body="&lt;p&gt;I have &lt;code&gt;TM1812&lt;/code&gt; addressable &lt;code&gt;LED&lt;/code&gt; strip (1meter long 96 LED). I am looking a way to &lt;code&gt;program&lt;/code&gt; it and i found this &lt;a href=&quot;http://www.deskontrol.net/blog/arduino-based-artnet-node-for-led-pixels/&quot; rel=&quot;nofollow&quot;&gt;http://www.deskontrol.net/blog/arduino-based-artnet-node-for-led-pixels/&lt;/a&gt;&#xA;and its mentioned in article that it doens't work with &lt;code&gt;current version&lt;/code&gt; of Arduino &lt;code&gt;IDE&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some other lib/api available to program it or another method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;As mentioned by @dlu FastLED support wide variety of &lt;code&gt;LEDs&lt;/code&gt;. I contacted developers of &lt;code&gt;FastLED&lt;/code&gt; on google + and they have updated there documentation for support of &lt;code&gt;TM1812&lt;/code&gt; its similar to &lt;code&gt;TM1809&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="14939" LastEditorUserId="14939" LastEditDate="2015-12-03T11:09:08.223" LastActivityDate="2016-07-13T03:23:18.820" Title="Programming addressable LED" Tags="|arduino-uno|led|rgb-led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18363" PostTypeId="2" ParentId="18361" CreationDate="2015-12-02T21:43:09.023" Score="1" Body="&lt;p&gt;There is a very nice library called &lt;a href=&quot;http://fastled.io&quot; rel=&quot;nofollow&quot;&gt;FastLED&lt;/a&gt;, it is also on &lt;a href=&quot;https://github.com/fastled/fastled&quot; rel=&quot;nofollow&quot;&gt;GitHub as FastLED/FastLED&lt;/a&gt;. It is quite flexible and supports a huge range of addressable LEDs. I'm currently using it with 1.6.6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that you linked to was developed with an older version of the Arduino IDE, so you might want to see if you can find an older version and try building with that.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-02T22:25:25.840" LastActivityDate="2015-12-02T22:25:25.840" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18364" PostTypeId="2" ParentId="3881" CreationDate="2015-12-02T22:24:56.170" Score="1" Body="&lt;p&gt;This will work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;longDelayInSeconds = 120; //two minutes;   &#xA;while (p &amp;lt; longDelayInSeconds) {&#xA;&#xA;        delay(1000);&#xA;        p++;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15300" LastActivityDate="2015-12-02T22:24:56.170" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18367" PostTypeId="1" CreationDate="2015-12-03T01:07:13.000" Score="0" ViewCount="78" Body="&lt;p&gt;I got this program. It controls a refrigeration room using a ds1280 temperature probe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is, sometimes the probe reach 7.00°C then the refrigerattion cycle start (refrigeration cycle is on a switch case statment) and then the probe read 6.75. So the refrigeration don't complete its start and leaves part of the system in wrong mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I add some guard to ... once the switch case statment don't being interrupted by anything unless complete the on in this case or the off in other case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the most resembling parts of the code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void turnOnCompressor(){ &#xA;&#xA;/*&#xA;This subrutine is intended to stop the refrigeration cycle &#xA;in the most ordered way, and keeping the refrigerant on &#xA;the high side of the system. &#xA;*/&#xA;&#xA;// boolean refrigerattion = false; // var to handle ref status only once &#xA;// byte compOn = 0; &#xA;// byte pascomOn = 0; //to chek if the variable has updated.&#xA;// unsigned long  comOnTime  = 0; &#xA;// unsigend long  comOnDelay = 1500; &#xA;// unsigend long  comOnCT    = 0;     //the current time of the compressor. &#xA;&#xA;//------for debug only&#xA;//Serial.print(&quot;comOnCT  =             &quot;); Serial.println(comOnCT); &#xA;//Serial.print(&quot;comOnCT - millis()  =  &quot;); Serial.println(millis() - comOnTime ); &#xA;&#xA;// Serial.println(&quot;INICIANDO REFRIGERACION&quot;);&#xA;&#xA;&#xA;if(refrigerationBegin == true ) &#xA;{&#xA;&#xA;&#xA;if(refrigerattion == true &amp;amp;&amp;amp; millis()- comOnTime  &amp;gt;= comOnDelay ){&#xA;   compOn ++; &#xA;   comOnTime = millis(); &#xA; /*&#xA; //--------for debug only&#xA; Serial.println(&quot;---------------------&quot;); &#xA; Serial.print(&quot;Var compOn &quot;); Serial.println(compOn);&#xA; Serial.print(&quot;comoON  &quot;); Serial.println(compOn);&#xA; Serial.print(&quot;pascomON&quot;); Serial.println(pascomOn);&#xA; Serial.println(&quot;---------------------&quot;); &#xA;*/&#xA;}&#xA;&#xA;if(compOn &amp;gt; pascomOn ){&#xA;&#xA;  switch(compOn){ &#xA;&#xA;  case(1): &#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;      CICLO DE      &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;    REFRIGERACION   &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;                    &quot;));&#xA;  break; &#xA;&#xA;  case(2): &#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;       VENT 1       &quot;));&#xA;  digitalWrite(dif1, LOW); &#xA;  break; &#xA;&#xA;  case(3):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;       VENT 2       &quot;));&#xA;  digitalWrite(dif2, LOW); &#xA;  break; &#xA;&#xA;  case(4):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;      SOLENOIDE     &quot;));&#xA;  digitalWrite(solenoid, LOW); &#xA;  break; &#xA;&#xA;  case(5):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;      COMPRESOR     &quot;));&#xA;  digitalWrite(compressor, LOW);&#xA;  break; &#xA;&#xA;  case(6):&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;                    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;                    &quot;));&#xA;  refrigerattion = false;&#xA;  refOff = true     ;       // to cycle only once the set of the instructions per cycle.&#xA;  compOn = 0;&#xA;  cycleFansvar = false;        //bool to chek the refrigerattion has stop &#xA;  //--------------------------------&#xA;  //refrigerattion = true; add this variable at the end of the off routine to cycle the &#xA;  //operation otherwise will just start once&#xA;}&#xA;}&#xA;}&#xA;&#xA;refrigerationBegin = false; &#xA;}&#xA;&#xA;&#xA;void turnOnCompressor(){ &#xA;&#xA;/*&#xA;This subrutine is intended to stop the refrigeration cycle &#xA;in the most ordered way, and keeping the refrigerant on &#xA;the high side of the system. &#xA;*/&#xA;&#xA;// boolean refrigerattion = false; // var to handle ref status only once &#xA;// byte compOn = 0; &#xA;// byte pascomOn = 0; //to chek if the variable has updated.&#xA;// unsigned long  comOnTime  = 0; &#xA;// unsigend long  comOnDelay = 1500; &#xA;// unsigend long  comOnCT    = 0;     //the current time of the compressor. &#xA;&#xA;//------for debug only&#xA;//Serial.print(&quot;comOnCT  =             &quot;); Serial.println(comOnCT); &#xA;//Serial.print(&quot;comOnCT - millis()  =  &quot;); Serial.println(millis() - comOnTime ); &#xA;&#xA;// Serial.println(&quot;INICIANDO REFRIGERACION&quot;);&#xA;&#xA;&#xA;if(refrigerationBegin == true ) &#xA;{&#xA;&#xA;&#xA;if(refrigerattion == true &amp;amp;&amp;amp; millis()- comOnTime  &amp;gt;= comOnDelay ){&#xA;   compOn ++; &#xA;   comOnTime = millis(); &#xA; /*&#xA; //--------for debug only&#xA; Serial.println(&quot;---------------------&quot;); &#xA; Serial.print(&quot;Var compOn &quot;); Serial.println(compOn);&#xA; Serial.print(&quot;comoON  &quot;); Serial.println(compOn);&#xA; Serial.print(&quot;pascomON&quot;); Serial.println(pascomOn);&#xA; Serial.println(&quot;---------------------&quot;); &#xA;*/&#xA;}&#xA;&#xA;if(compOn &amp;gt; pascomOn ){&#xA;&#xA;  switch(compOn){ &#xA;&#xA;  case(1): &#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;      CICLO DE      &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;    REFRIGERACION   &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;                    &quot;));&#xA;  break; &#xA;&#xA;  case(2): &#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;       VENT 1       &quot;));&#xA;  digitalWrite(dif1, LOW); &#xA;  break; &#xA;&#xA;  case(3):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;       VENT 2       &quot;));&#xA;  digitalWrite(dif2, LOW); &#xA;  break; &#xA;&#xA;  case(4):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;      SOLENOIDE     &quot;));&#xA;  digitalWrite(solenoid, LOW); &#xA;  break; &#xA;&#xA;  case(5):&#xA;  lcd.setCursor(0,0);  lcd.print(F(&quot;    REFRIGERACION   &quot;));&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;     ENCENDIENDO    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;      COMPRESOR     &quot;));&#xA;  digitalWrite(compressor, LOW);&#xA;  break; &#xA;&#xA;  case(6):&#xA;  lcd.setCursor(0,1);  lcd.print(F(&quot;                    &quot;)); &#xA;  lcd.setCursor(0,2);  lcd.print(F(&quot;                    &quot;));&#xA;  refrigerattion = false;&#xA;  refOff = true     ;       // to cycle only once the set of the instructions per cycle.&#xA;  compOn = 0;&#xA;  cycleFansvar = false;        //bool to chek the refrigerattion has stop &#xA;  //--------------------------------&#xA;  //refrigerattion = true; add this variable at the end of the off routine to cycle the &#xA;  //operation otherwise will just start once&#xA;}&#xA;}&#xA;}&#xA;&#xA;refrigerationBegin = false; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15305" LastEditorUserId="2881" LastEditDate="2015-12-03T11:21:09.417" LastActivityDate="2015-12-03T11:21:09.417" Title="Prevent Switch case from not being complete" Tags="|programming|arduino-mega|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="18368" PostTypeId="2" ParentId="16440" CreationDate="2015-12-03T01:30:48.923" Score="2" Body="&lt;p&gt;I use the ESP8266 to get the data from my arduino to my webserver using wlan. You could easy install a webserver on your pi and connect it to your wifi, or just use a server online. &#xA;So you can install on all places where you get WLAN. Also you could use a repeater if your wlan is not strong enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thats how my projekt works (Water level messure)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get range from ultrasonic sensor (every minute)&lt;/li&gt;&#xA;&lt;li&gt;Send data to the ESP8266 using SoftwareSerial&lt;/li&gt;&#xA;&lt;li&gt;Send getRequest with WLAN to my php page on the Server&lt;/li&gt;&#xA;&lt;li&gt;Save Data to MySql Database&lt;/li&gt;&#xA;&lt;li&gt;Show the Data Online with php and a javascript graph lib&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My example is one way Arduino to Server, but you could easy communicate back to each of your arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;good luck :)&lt;/p&gt;&#xA;" OwnerUserId="14501" LastActivityDate="2015-12-03T01:30:48.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18369" PostTypeId="1" AcceptedAnswerId="18371" CreationDate="2015-12-03T02:09:06.780" Score="1" ViewCount="5917" Body="&lt;p&gt;I have an Uno that loops processing serial commands and reading from a DHT11 sensor. For whatever reason, the device often stops responding. I put an LED on a pin and gave it a blink to see whether the loop is running, and sure enough the loop() stops running (the LED stays ON or OFF, depending on when it froze). I enabled the watchdog at 2 seconds, but it does not reset the device [it still stays frozen, even though wdt_reset() is called at basically the same time as the blinking LED is toggled].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then tried various combinations of BaudRate=1200 (or 9600), Open(), Close(), DtrEnable=true [on both the Uno and the Mega], yet none of the combinations would make the device reset. The device &lt;em&gt;will&lt;/em&gt; reset, however, if I re-upload the sketch using the Arduino IDE. I would like to emulate this resetting functionality from my own program's code. Reading on the official site, it sounds like the Baud=1200 reset feature is available only on certain models (not the Uno or Mega).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is by no means simple as I am no beginner when it comes to programming. This is the first time, however, that I have had a finicky unit that freezes all the time (say between 10 minutes and 2 hours into running). I merely want to reset the unit from the PC using code, like the Arduino IDE does. On the other hand, if the watchdog worked correctly, that would be fine as well. At the same time, I am not that experienced with electronic circuits, so making a circuit that would &quot;press&quot; the &quot;reset&quot; pin when the LED stops blinking is not something I am quite ready to do. Plus, I do not want to add a bunch more components if the job can be done through code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a side note, the Serial connection appears to be fully functional the whole time. The LED on the unit that indicates receiving from the PC continues to function whenever I send data to the device. I can connect and reconnect without any apparent issues. Plus, the Arduino IDE has no problem uploading new sketches and resetting the device. Naturally, no data is received from the device after it freezes (until it gets reset, of course).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 1&lt;/strong&gt;: I made a simple sketch (see below) that would run for about 20 seconds and then let the WDT watchdog timeout do its thing. Result:&#xA;(a) Running the code on an Arduino-brand Mega 2560, the device simply resets every 20 seconds and keeps blinking;&#xA;(b) Running the code on a generic (made in China) Uno R3, at timeout the L light turns on and the device becomes completely unresponsive (not even the reset button or the Arduino IDE can save it); It must be unplugged to reset it.&#xA;(c) Running the code on an Arduino-brand Uno R3 works as expected, just like on the Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;void setup() {&#xA;  wdt_reset();&#xA;  wdt_enable(WDTO_2S);&#xA;  wdt_reset();&#xA;  pinMode(A5, OUTPUT);&#xA;  delay(1);&#xA;  Serial.begin(125000);&#xA;}&#xA;unsigned int LoopCount = 0;&#xA;bool TestLED = false;&#xA;void loop() {&#xA;  if(LoopCount % 300 == 0){&#xA;    TestLED = !TestLED;&#xA;    digitalWrite(A5, TestLED ? HIGH:LOW);&#xA;    if(LoopCount &amp;lt; 20000)&#xA;      wdt_reset();&#xA;  }&#xA;  delayMicroseconds(1000);&#xA;  LoopCount++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nevertheless, I still would like if someone could provide a solution in terms of resetting a frozen generic Uno from Serial in .NET code -- not the WDT frozen, but the normal frozen (of unknown origin). I may be the one coding, but I'm unfortunately not the one deciding which units are put into production.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;: I switched the EasyDriver to its own power source, where the only things in common with the stepper and the Arduino were the ground and the two signal wires. The generic Uno board ended up being even more problematic, going into a new freeze mode (after just a minute or two, pretty reliably) where the L light would blink very quickly. I'm not sure whether it had anything to do with toggling of the DtrEnable property, but I decided to stop messing with the generic board for the time being. The name-brand Uno appeared to freeze occasionally or malfunction as well with the original wiring, but the Watchdog did its thing and reset it straight away every time. Also, I tried toggling the RtsEnable property with the generic board, but it didn't seem to make a difference. The board would become unresponsive and unrevivable, even from the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some more background: The reliability problem only really started to surface when I hooked up the DHT11 temperature sensor, &lt;em&gt;even though&lt;/em&gt; the freezing would tend to happen only when the stepper motor was running. I have the DHT11 hooked up exactly as advocated by Adafruit, and it tends to read correctly most of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 3&lt;/strong&gt;: I was thinking maybe the SainSmart Mega2560 would be different from the no-name generic I was using. After getting one and hooking it up, I have found it to have the exact same problem. The SainSmart CPU crashes between 5 and 15 minutes into running. The serial chip (or module) keeps going as you can still see the serial lights change when you send to it. However, the on-board reset button does nothing, and the Arduino IDE cannot upload to the device or reset it. Only a power cycle can save it.&lt;/p&gt;&#xA;" OwnerUserId="15303" LastEditorUserId="15303" LastEditDate="2015-12-28T13:03:32.070" LastActivityDate="2015-12-28T13:03:32.070" Title="Reset Arduino Uno R3 from Serial when it freezes (stops looping)?" Tags="|arduino-uno|serial|arduino-mega|reset|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="18370" PostTypeId="2" ParentId="18367" CreationDate="2015-12-03T02:55:19.053" Score="1" Body="&lt;p&gt;Are you trying to control by temperature or by time? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I'm finding the code hard to follow. There seem to be 2 copies of it, and the comments in turnOnCompressor() seem to contradict the function name. I also don't see any code that mentions temperature.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is temperature controlled, you need a dead-band - a temperature range bounded by a high- and a low setpoint. If you have a single setpoint, the system will jitter as air-circulation and electrical noise make the temperature appear to alternate above and below setpoint. The turn-on setpoint needs to be higher than the turn-off setpoint. You'll need to experiment to find out how far apart they need to be for the system to be stable.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-03T02:55:19.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18371" PostTypeId="2" ParentId="18369" CreationDate="2015-12-03T03:36:10.430" Score="3" Body="&lt;p&gt;You can reset the Uno over the serial link by toggling the DTR line. How you do that depends on what platform and language you are using. There is a capacitor between the line and the reset pin, so the toggle must last a minimum ammount of time. 0.5 seconds works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is ok for just a quick fix hack, but probably better in the long run to (1) figure out why the code is crashing, and/or (2) figure out why WDT is not working. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-12-03T03:36:10.430" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18373" PostTypeId="1" AcceptedAnswerId="18374" CreationDate="2015-12-03T07:25:39.160" Score="0" ViewCount="5599" Body="&lt;p&gt;I have two Adapters, one is rated as Output 12V 500mA (used to power an old modem) and another one is rated as 5V 1A (old mobile phone charger).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is can use any of these to power my Arduino UNO with a barrel connector?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does it mean when any adapter is rated as Output DC 5V 1A, Does it mean maximum we can draw 1A of current through it? What will happen if I draw more current than that.&lt;/p&gt;&#xA;" OwnerUserId="15310" OwnerDisplayName="palash" LastEditorUserId="15310" LastEditDate="2015-12-03T08:52:48.397" LastActivityDate="2018-09-17T09:36:28.227" Title="Can I use 5V 1A Adapter to power Arduino UNO?" Tags="|current|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18374" PostTypeId="2" ParentId="18373" CreationDate="2015-12-03T07:39:14.173" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ep3D4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ep3D4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we look at &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;technical specifications&lt;/a&gt;, it is recommended to supply voltage from 7-12V so use your adapter 12V/500mA (&lt;strong&gt;never go above 20V&lt;/strong&gt;). 5V/1A adapter is not enough when connecting via DC barrel jack according to technical specifications.&lt;/p&gt;&#xA;" OwnerDisplayName="Junior" LastActivityDate="2015-12-03T08:00:40.280" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18375" PostTypeId="2" ParentId="18163" CreationDate="2015-12-03T09:48:32.193" Score="0" Body="&lt;p&gt;Ok, let's troubleshoot it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try with the following sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;byte currentNodeAddr[6] = &quot;1Node&quot;;  // Address of this node&#xA;&#xA;// Struct for sending measured data&#xA;struct Data {&#xA;  uint16_t temp;  // Temperature value&#xA;  uint16_t hum;   // Humidity value&#xA;  int status;     // DHT22 module status&#xA;} data;&#xA;&#xA;RF24 radio(2,2);  // Create instance of RF24 radio object&#xA;&#xA;void setup() {&#xA;    // Set up the radio&#xA;    radio.begin();&#xA;    radio.openWritingPipe(currentNodeAddr);&#xA;    radio.stopListening();&#xA;    data.temp = 0;&#xA;    data.hum = 1;&#xA;    data.status = 2;&#xA;}&#xA;&#xA;void loop() {&#xA;    data.temp++;&#xA;    data.hum++;&#xA;    data.status++;&#xA;    radio.write(&amp;amp;data, sizeof(Data));&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should see a bunch of data being sent to the raspberry every second (you should see &lt;code&gt;temp = 1, hum = 2, status = 3&lt;/code&gt; then, after two seconds, &lt;code&gt;temp = 2, hum = 3, status = 4&lt;/code&gt; and so on. Of course you need something to display the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is some problems then it's the radio library fault, otherwise let's integrate the DHT22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, AFTER having tried the previous sketch and confirming that everything is working, download the library from &lt;a href=&quot;https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, install it and then use this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;dht.h&amp;gt;&#xA;&#xA;dht DHT;&#xA;&#xA;const byte DHT22_Pin = 3;&#xA;&#xA;byte currentNodeAddr[6] = &quot;1Node&quot;;  // Address of this node&#xA;&#xA;// Struct for sending measured data&#xA;struct Data {&#xA;  uint16_t temp;  // Temperature value&#xA;  uint16_t hum;   // Humidity value&#xA;  int status;     // DHT22 module status&#xA;} data;&#xA;&#xA;RF24 radio(2,2);  // Create instance of RF24 radio object&#xA;&#xA;void setup() {&#xA;    // Set up the radio&#xA;    radio.begin();&#xA;    radio.openWritingPipe(currentNodeAddr);&#xA;    radio.stopListening();&#xA;}&#xA;&#xA;void loop() {&#xA;    data.status = DHT.read22(DHT22_Pin);&#xA;    data.temp = (int)DHT.humidity;&#xA;    data.hum = (int)DHT.temperature;&#xA;&#xA;    radio.write(&amp;amp;data, sizeof(Data));&#xA;&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, instead of displaying increasing numbers, it should say the temperature, the humidity and, most important, the status:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 0 -&amp;gt; OK&#xA;-1 -&amp;gt; ERROR_CHECKSUM&#xA;-2 -&amp;gt; ERROR_TIMEOUT&#xA;-3 -&amp;gt; ERROR_CONNECT&#xA;-4 -&amp;gt; ERROR_ACK_L&#xA;-5 -&amp;gt; ERROR_ACK_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check if this works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IMPORTANT NOTE&lt;/strong&gt;: I read somewhere that sometimes the ground pin on the DHT is 3 instead of 4. Try grounding both pins if something does not work.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-12-03T09:48:32.193" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18381" PostTypeId="1" AcceptedAnswerId="18384" CreationDate="2015-12-03T12:56:54.700" Score="2" ViewCount="981" Body="&lt;p&gt;Trying to shift out from ATtiny85 to a shift register using the USI in SPI mode. I have Timer 0 running as slowly as possible (checked it was running by temporarily changing it to toggle a pin with an LED attached.) I have LEDs hooked up to USCK and DO so by rights I should be able to see them blinking as it sends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What else do I need to do in order to get it shifting out in sync with Timer 0? All the examples I've looked at so far strobe the USI clock manually.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;&#xA;int main(void){&#xA;    DDRB = (1 &amp;lt;&amp;lt; DDB2) | (1 &amp;lt;&amp;lt; DDB1); // USCK &amp;amp; DO Output&#xA;    DDRB &amp;amp;= ~(1 &amp;lt;&amp;lt; DDB0); // DI Input&#xA;    PORTB |= (1 &amp;lt;&amp;lt; DDB0); // Pullup Resistor for DI&#xA;&#xA;    TCCR0A = (1 &amp;lt;&amp;lt; WGM01); // Timer 0 in CTC Mode&#xA;    OCR0A = 0xFF; // Timer 0 Compare A&#xA;    TCCR0B = (1 &amp;lt;&amp;lt; CS02) | (1 &amp;lt;&amp;lt; CS00); // Prescaler / 1024&#xA;&#xA;    USICR = (1 &amp;lt;&amp;lt; USIWM0); // USI 3 Wire Mode&#xA;    USICR |= (1 &amp;lt;&amp;lt; USICS0); // Timer 0 for USI 4-bit Clock Source&#xA;&#xA;    USIDR = 0x7F; // Why you no go? :c&#xA;&#xA;    USISR |= 0x08; // Set Counter to 8&#xA;    USISR = (1 &amp;lt;&amp;lt; USIOIF); // Clear Counter Overflow&#xA;&#xA;    while(1);&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15295" LastEditorUserId="15295" LastEditDate="2015-12-03T19:45:27.803" LastActivityDate="2015-12-03T19:45:27.803" Title="ATtiny85 SPI with Timer 0" Tags="|timers|attiny|spi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18382" PostTypeId="1" AcceptedAnswerId="18386" CreationDate="2015-12-03T12:59:01.083" Score="0" ViewCount="1239" Body="&lt;p&gt;I am using adxl335 accelerometer with Arduino uno r3 to measure acceleration due to gravity along x axis. I am using 50 ms delay and printing to serial. &#xA;I have two questions, which are;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can I measure fractional values, like .8 in acceleration due to gravity?&lt;/li&gt;&#xA;&lt;li&gt;when I shake the accelerometer up down along x axis, I don't see any variations in 'g'?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am using analog pins and 3.3V power supply from Arduino to power the sensor.&lt;/p&gt;&#xA;" OwnerDisplayName="user15319" LastActivityDate="2015-12-03T13:45:25.357" Title="Measuring acceleration in g's" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18383" PostTypeId="1" CreationDate="2015-12-03T13:08:10.043" Score="0" ViewCount="169" Body="&lt;p&gt;I want to use LDR to control a light bulb (12W) which runs on AC supply using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If yes, how?&lt;/p&gt;&#xA;" OwnerUserId="7754" LastEditorUserId="6936" LastEditDate="2016-01-03T16:42:46.970" LastActivityDate="2016-01-06T18:20:38.473" Title="How can I use arduino board for AC mains?" Tags="|photoresistor|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18384" PostTypeId="2" ParentId="18381" CreationDate="2015-12-03T13:10:17.283" Score="0" Body="&lt;p&gt;Did you forget to load the counter and clear flags in USISR? &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-03T13:10:17.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18385" PostTypeId="1" CreationDate="2015-12-03T13:34:59.583" Score="2" ViewCount="274" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Suggest Hardwares to use and also suggest some place to learn about&#xA;IoT, video tutorials, websites, blogs, books etc. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Currently I am using Xbees to communicate between LabVIEW and Arduino Mega.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Most of the websites that I checked are using ESP8266 but I am not&#xA;sure how to use them to receive and transmit simultaneously.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/az5Or.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/az5Or.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/EheAs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EheAs.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14222" LastActivityDate="2015-12-03T13:34:59.583" Title="Suggest some ways to communicate (Rx and Tx) between Arduino and LabVIEW through Internet" Tags="|ethernet|xbee|esp8266|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18386" PostTypeId="2" ParentId="18382" CreationDate="2015-12-03T13:45:25.357" Score="0" Body="&lt;p&gt;If you read the &lt;a href=&quot;http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; you can quickly find that the output of the device is 300mV per &lt;em&gt;g&lt;/em&gt;.  That means:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read the analog value&lt;/li&gt;&#xA;&lt;li&gt;Convert it to millivolts&lt;/li&gt;&#xA;&lt;li&gt;Divide it by 300&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The result is the &lt;em&gt;g&lt;/em&gt; value.  If you do it using floating point then yes, you get fractions of a &lt;em&gt;g&lt;/em&gt; resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float mv = analogRead(0) / 1023.0 * 5000.0; &#xA;float g = mv / 300.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the analog channel has 1024 steps, that's 5/1024 = 0.0048828V per step, or 4.8828mV per step.  Divide that by 300 and you get a resolution of 0.01628g&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for not seeing variations in X when you shake up and down, maybe that is because you really want to look at the Z axis, not the X. X is left/right, Y is forward/backward and Z is up/down.  It's all in the &lt;a href=&quot;http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; - it makes for good reading, I suggest you take a look.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-03T13:45:25.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18390" PostTypeId="2" ParentId="18383" CreationDate="2015-12-03T16:53:39.250" Score="1" Body="&lt;p&gt;The quick and dirty answer is that you need something that will safely handle the mains voltage that you can control with the Arduino (which is running at 5 (or 3.3) volts). There are two issues you need to consider:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Safety – keeping the mains voltage separate from the Arduino and the other low voltage components so that nobody gets hurt.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Capability of components – avoiding damage to the Arduino and related components due to the mains voltage.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A common way of achieving the second goal is with either a relay or a solid-state component like a triac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first goal is often accomplished by using an optocoupler – a device that isolates the low-voltage circuitry from the higher mains voltage by means of an LED and a photo transistor in a common housing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuitry around the relay and optocoupler aren't all that complicated but it isn't trivial either. You might look on e-bay – a search for &quot;arduino relay&quot; will find you lots of modules that will do the job for you.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-03T16:53:39.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18391" PostTypeId="1" CreationDate="2015-12-03T00:35:27.087" Score="-1" ViewCount="629" Body="&lt;p&gt;I have an &lt;a href=&quot;https://github.com/ArduCAM/Arduino/tree/master/ArduCAM&quot; rel=&quot;nofollow&quot;&gt;Arducam&lt;/a&gt; hooked up to an Arduino UNO.  The code I am running looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;ArduCAM.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;memorysaver.h&quot;&#xA;&#xA;const int CS = 10;&#xA;&#xA;ArduCAM myCAM(OV5642, CS);&#xA;&#xA;void setup() {&#xA;  uint8_t vid, pid;&#xA;&#xA;  Wire.begin();&#xA;  Serial.begin(115200);&#xA;  pinMode(CS, OUTPUT);&#xA;&#xA;  SPI.begin();&#xA;&#xA;  //Check if the camera module type is OV5642&#xA;  myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &amp;amp;vid);&#xA;  myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &amp;amp;pid);&#xA;&#xA;  if ((vid != 0x56) || (pid != 0x42))&#xA;    Serial.println(&quot;Can't find OV5642 module!&quot;);&#xA;  else&#xA;    Serial.println(&quot;OV5642 detected.&quot;);&#xA;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the rdSensorReg16_8 function from the library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//I2C Write 8bit address, 16bit data&#xA;byte ArduCAM::wrSensorReg8_16(int regID, int regDat)&#xA;{&#xA;    Wire.beginTransmission(sensor_addr &amp;gt;&amp;gt; 1);&#xA;    Wire.write(regID &amp;amp; 0x00FF);     &#xA;&#xA;    Wire.write(regDat &amp;gt;&amp;gt; 8);            // sends data byte, MSB first&#xA;    Wire.write(regDat &amp;amp; 0x00FF);    &#xA;&#xA;    if(Wire.endTransmission())&#xA;    {&#xA;        return 0; &#xA;    }&#xA;&#xA;    delay(1);&#xA;    return(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I am experiencing is that sometimes I will receive the &quot;Can't find OV5642 module!&quot; message, and other times everything is fine and I receive &quot;OV5642 detected&quot; (I have the OV5642 module hooked up, so it should always be returning detected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried using different cables to connect the camera to my UNO.  I have tried swapping out my USB cable.  I have tried using a 12v wall adapter to power the UNO. None of these options permanently solved my problem - I still receive both messages interchangeably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing that &lt;em&gt;seems&lt;/em&gt; like it is adding consistency is when I change which USB port on my computer the cable is plugged into.  Every time I switch the USB port I am using, it seems like for the first run I'll receive the successful &quot;OV5642 detected&quot; message, but after reseting the Arduino or re-uploading my sketch, I go back to the &quot;Can't find OV5642 module!&quot; message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me troubleshoot why I am getting inconsistent readings?  Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15328" OwnerDisplayName="Bert Wagner" LastEditorUserId="15328" LastEditDate="2015-12-03T19:33:46.847" LastActivityDate="2019-12-16T17:02:05.287" Title="Arduino UNO inconsistent I2C register reading from ArduCam" Tags="|arduino-uno|i2c|spi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18392" PostTypeId="1" CreationDate="2015-12-03T18:32:03.097" Score="2" ViewCount="469" Body="&lt;p&gt;What is the simplest (from a user/install standpoint) 2a stepper motor driver for an Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like something simple and easy to stack like the &lt;a href=&quot;https://www.adafruit.com/products/1438&quot; rel=&quot;nofollow&quot;&gt;Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit&lt;/a&gt;  but unfortunately it only handles 1.2a. I can do basic soldering but I would like to keep things simple and physically stacked or connected if possible. I don't want to use jumpers or a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to run this stepper to simply open and close a door every few hours:&#xA;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00QA8XUGC&quot; rel=&quot;nofollow&quot;&gt;14:1 Planetary Gearbox High Torque Nema 17 Stepper&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this battery from Amazon:&#xA;ExpertPower EXP1250 12V 5Ah&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm missing anything please let me know. Your feedback is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15326" LastActivityDate="2015-12-03T18:32:03.097" Title="Best 2a stepper motor driver for Arduino Uno" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18393" PostTypeId="2" ParentId="18369" CreationDate="2015-12-03T18:51:28.047" Score="0" Body="&lt;p&gt;Since we don't know the nature of the freeze-up, and the clone-board behaves differently than an Arduino-brand board but we don't know how or why, there's not much more we can offer beyond suggesting you recommend a higher quality board to your management. You surely have reason enough to do so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last remaining thing I can think of, and it's kludgey work-around (shame on me) is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You know the board will come back after a power-cycle. Kludge up a 555 timer circuit that powers-down the board for a second or two, and trigger it from the DTR line. This is really a broken fix for a broken board!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If my management or a client was intent on shipping a product built with these, I'd have to speak up about potential damage to the company's reputation - and possible liability, if a failure could have real consequences someone - and if necessary, write my objections to the next three levels above me. This board should not be shipped in a product.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-12-03T19:50:03.860" LastActivityDate="2015-12-03T19:50:03.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18394" PostTypeId="1" CreationDate="2015-12-03T19:08:32.660" Score="0" ViewCount="65" Body="&lt;p&gt;Hi me and a friend is making a computer shelf with leds in the woodwork, were using a special glue for the plexiglass in the shelf which means we're using individual rgb leds, four leds for each window (3 windows) and what I need help with is, amount of voltage, ampere, code and how to connect all this up. I've used 123d.io to sketch something up but I'm struggling with getting proper strength in the leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://puu.sh/lI6IU/0aca425cce.png&quot; alt=&quot;Sketch&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(code &lt;a href=&quot;https://puu.sh/lI6PC/e214028b07.txt&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://puu.sh/lI6PC/e214028b07.txt&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aswell as some of them change colors as the picture here shows:&#xA;&lt;img src=&quot;https://puu.sh/lI7h4/980d8e7a00.png&quot; alt=&quot;On&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very new at these things so I really appreciate all help and advice (and from an earlier post, reason for not using strips is purely based on the method of build, the shelf will not sit correct if the strips were in use)&lt;/p&gt;&#xA;" OwnerUserId="15132" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.500" LastActivityDate="2015-12-03T20:16:03.460" Title="Multiple rgb control plus calculation help" Tags="|arduino-uno|rgb-led|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18396" PostTypeId="2" ParentId="18394" CreationDate="2015-12-03T19:57:43.593" Score="2" Body="&lt;p&gt;It's not advised to connect leds in parallel, with only one common resistor. Slight difference in forward voltage of the leds will create big current differences. This will make some leds appear brighter that neighboring leds. It can also damage the brighter led since too much current can flow through them. So you need to add a resistor to each led, and common the other side of these resistors to the transistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second bigger error is that there isn't any resistor between the arduino pin and the base of the transistor. Without it there is nothing limiting the current going into the base, which could fry the arduino pin.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-03T19:57:43.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18397" PostTypeId="2" ParentId="18394" CreationDate="2015-12-03T19:58:46.457" Score="1" Body="&lt;p&gt;There's a lot to unpack here, this is actually several questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, the way your circuit is designed currently, your data pins are connected via the transistors to ground. This means if you set a pin high, or use analogWrite(), the Arduino will pump as much current as it can get, directly into the ground. This can damage the Arduino. Put a resistor between the pin, and the transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first point is that you are using several LEDs. If you want to control them separately, you will need 3 pins per colour. AnalogWrite() only works on PWM pins - if you look at your Uno, you can see that some of the pins are marked with a ~ (pin 3,45,6,9,10,11) - these are the only ones you can (easily) use. Since there are 6 of them, you could only run 2 LEDs this way. You could either run the project on multiple arduinos (1 Arduino per 2 &quot;windows&quot;), or you can get a chip to do the heavy lifting for you. I am working on a similar project, and am using a TLC5940 - there is a thorough tutorial at &lt;a href=&quot;http://playground.arduino.cc/Learning/TLC5940&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/TLC5940&lt;/a&gt; - they also save you from having all the resistors and transistors, and each TLC5940 will run up to 16 LED-pins (3 per LED, so you can run up to 5 &quot;windows&quot;). They are also designed to daisy chain, so if you need more, you can just add another chip; no extra Arduino pins to worry about. 3 of them can run all 12 of your LEDs independently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next item to be aware of is that there is a limit to how much power (in Amps, or milliAmps) you can draw from a given power source. Each part will use a certain number of millAmps. The spec sheet for your parts should tell you how many. LEDs are generally around 20mA (per colour), but this varies - check the datasheet. An Arduino uses about 50mA. This means that if all 12 of your LEDs are bright white, you will be drawing 50mA+(20mA * 12 * 3) = 770mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does this affect you? Well, if your project draws less than the power source can provide, you're golden! You can't provide &quot;too much current&quot; to a component - it will draw what it needs. When you draw more than the supply can supply, you get one of two results. If it runs on the mains, it will overheat, and eventually either burn out, or catch fire (there are exceptions to this, but you'd better be sure of your facts before risking it!). How long this takes, depends on how much current you are drawing, and how much margin there is on the power supply. In the case of a battery, the battery will drop in voltage, and will also heat up (but is much less likely to catch fire). I suspect this is happening here. If you have a multimeter, you can hook up your circuit to batteries, and then measure the voltage between + and - on the batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S - +1 to @Gerben - you need one resistor per LED leg (except common). If you use the TLC5940, you would need 3 TLC5940s; as I said before, you can daisy-chain them. This does, however, mean that you can control each LED individually.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2015-12-03T20:16:03.460" LastActivityDate="2015-12-03T20:16:03.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18398" PostTypeId="1" CreationDate="2015-12-03T20:19:39.697" Score="0" ViewCount="560" Body="&lt;p&gt;I've also asked this question over on stack exchange so I'll link the actual question &lt;a href=&quot;https://stackoverflow.com/questions/34074697/interfacing-matplotlib-with-arduino&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short story is I have a plot that updates in real time from data collected on an Arduino. The plot updates on a 50ms + overhead interval and I can either choose on the Arduino side to either delay the loop 50ms + compensation or use &lt;code&gt;flush()&lt;/code&gt;. I'm running into some problems with the delay option where my program begins to lag (Python side). I'm wondering if flush will work as I expect and hold the output until my python program reads from the serial port. So then the Python program is completely controlling the flow of data every time it polls for an update.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here's a snippet of the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  val1 = analogRead(0);&#xA;  val2 = analogRead(1);&#xA;  Serial.print(val1);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(val2);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  //Serial.flush();&#xA;  delay(50); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15329" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-01-02T20:42:38.150" Title="Interfacing Arduino with matplotlib animation" Tags="|arduino-uno|serial|programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18399" PostTypeId="2" ParentId="18391" CreationDate="2015-12-03T20:34:36.880" Score="0" Body="&lt;p&gt;I would start by adding a short delay before SPI.begin() and verifying that the power drawn does not exceed 500 mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The product description describes the power on sequence. &lt;a href=&quot;http://www.uctronics.com/download/cam_module/OV5642DS.pdf&quot; rel=&quot;nofollow&quot;&gt;OV5642&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-03T20:34:36.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18400" PostTypeId="1" CreationDate="2015-12-03T20:57:15.263" Score="0" ViewCount="112" Body="&lt;p&gt;I have a large quantity of gyro values and I read them through the Arduino serial monitor. I'd like to know how I can use these values in other programming languages (such as C/C++/Java) after the values are read. Are there particular  libraries for the Arduino that could help me in this way?&lt;/p&gt;&#xA;" OwnerUserId="15330" LastEditorUserId="10907" LastEditDate="2015-12-17T17:45:59.270" LastActivityDate="2015-12-17T17:45:59.270" Title="Read gyro output values with other programming languages" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18401" PostTypeId="2" ParentId="18354" CreationDate="2015-12-03T21:07:11.087" Score="1" Body="&lt;p&gt;i agree with majenko, maybe you know how to fix it but if you do not know here is a site with good information to make you're own  5 volt Regulated source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.rakeshmondal.info/IC-7805-Voltage-Regulator&quot; rel=&quot;nofollow&quot;&gt;http://www.rakeshmondal.info/IC-7805-Voltage-Regulator&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sorry for my bad english and good luck. :D&lt;/p&gt;&#xA;" OwnerUserId="15022" LastActivityDate="2015-12-03T21:07:11.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18403" PostTypeId="2" ParentId="18400" CreationDate="2015-12-03T21:07:51.483" Score="1" Body="&lt;p&gt;If your Arduino sketch is printing the data as ASCII numeric strings (human-readable), then any language with support for reading and writing to a serial device can interact with your Arduino on the port it is connected to, and collect the gyro data as it is being sent.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-03T21:07:51.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18404" PostTypeId="2" ParentId="3926" CreationDate="2015-12-03T22:08:55.173" Score="1" Body="&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;   int numberpulses;&#xA;&#xA;   numberpulses = listenForIR();&#xA;&#xA;   Serial.print(&quot;Heard &quot;);&#xA;   Serial.print(numberpulses);&#xA;   Serial.println(&quot;-pulse long IR signal&quot;);&#xA;   if (IRcompare(numberpulses, ApplePlaySignal)) {&#xA;      Serial.println(&quot;PLAY&quot;);&#xA;      if (ledState == LOW)&#xA;         ledState = HIGH;&#xA;      else&#xA;         ledState = LOW;&#xA;&#xA;      // set the LED with the ledState of the variable:&#xA;      digitalWrite(ledPin, ledState); &#xA;&#xA;   }&#xA;   if (IRcompare(numberpulses, AppleRewindSignal)) {&#xA;      Serial.println(&quot;REWIND&quot;);&#xA;   }&#xA;   if (IRcompare(numberpulses, AppleForwardSignal)) {&#xA;      Serial.println(&quot;FORWARD&quot;);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15333" LastEditorUserId="8" LastEditDate="2015-12-26T20:39:58.760" LastActivityDate="2015-12-26T20:39:58.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18405" PostTypeId="2" ParentId="18400" CreationDate="2015-12-03T22:48:25.030" Score="1" Body="&lt;p&gt;Yes, of course you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C/C++ there are different libraries depending on your operating system - that is if you even really need a library to help you at all (in Linux you certainly don't - you just use standard system calls - open, read, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Java there are a few different ones.  RXTX is a common (though not very good) one.  Personally I ise JSSC(Java Simple Serial Connector) since it contains the JNI files for all the main platforms - you don't have to get the right separate library packages for your specific OS like you do with RXTX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then of course there's things like PySerial for Python, Device::SerialPort for Perl, and whatever nonsense Microsoft have created for C# and their .NET stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in general: pick a language you are comfortable with, then ask Google how to use the serial port in it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-03T22:48:25.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18406" PostTypeId="1" AcceptedAnswerId="18408" CreationDate="2015-12-03T23:15:24.813" Score="-1" ViewCount="1304" Body="&lt;p&gt;I have just started my first project. I got through with 2 periodically blinking LEDs. Now I want one LED (blue) to be lit constantly and the other (red) to be blinking as before. Can anyone help me with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code for blinking LEDs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int red_led = 4;&#xA;int blue_led = 3;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(red_led, OUTPUT);&#xA;&#xA;  pinMode(blue_led, OUTPUT);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(blue_led, LOW);&#xA;&#xA;  digitalWrite(red_led, HIGH);&#xA;&#xA;  delay(1000);&#xA;&#xA;  digitalWrite(blue_led, HIGH);&#xA;&#xA;  digitalWrite(red_led, LOW);  &#xA;&#xA;  delay(1000);&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15335" LastEditorUserId="-1" LastEditDate="2015-12-05T22:07:58.867" LastActivityDate="2015-12-05T22:07:58.867" Title="One LED being constant and another blinking" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18407" PostTypeId="1" AcceptedAnswerId="18410" CreationDate="2015-12-03T23:24:29.420" Score="4" ViewCount="25958" Body="&lt;p&gt;I was creating Arduino function which sends two &lt;code&gt;int&lt;/code&gt; and additional &lt;code&gt;char&lt;/code&gt;s between them and at the beginning and end of &lt;code&gt;char&lt;/code&gt; array - then print that array to the serial port in almost real time. (For example &quot;X50Y100T&quot;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to use &lt;code&gt;String&lt;/code&gt; object in Arduino and I found two possible solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Using &lt;code&gt;sprintf()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char sendBuffer[16];&#xA;void dataSend(int first, int second) {&#xA;  sprintf(sendBuffer, &quot;X%dY%dT&quot;, first, second);&#xA;  Serial.println(sendBuffer);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char sendBuffer[16];&#xA;void dataSend(int first, int second){&#xA;  char convert[6];&#xA;  sendBuffer[0] = 'X';&#xA;&#xA;  itoa(first, convert, 10);&#xA;  strcat(sendBuffer, convert);&#xA;&#xA;  sendBuffer[strlen(sendBuffer)] = 'Y';&#xA;&#xA;  itoa(second, convert, 10);&#xA;  strcat(sendBuffer, convert);&#xA;&#xA;  sendBuffer[strlen(sendBuffer)] = 'T';&#xA;&#xA;  Serial.println(sendBuffer); &#xA;  memset(sendBuffer,0,sizeof(sendBuffer));&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My question is - which one is better from technical point of view?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;sprintf()&lt;/code&gt; looks better but it increases the sketch size by ~1,5KB. Are there any other drawbacks of &lt;code&gt;sprintf()&lt;/code&gt;? The second solution do many things to achieve same thing and I don't know if it's efficient... Maybe there are other solutions for sending this kind of &lt;code&gt;char&lt;/code&gt; array?&lt;/p&gt;&#xA;" OwnerUserId="15334" LastEditorUserId="6936" LastEditDate="2016-01-03T16:41:06.427" LastActivityDate="2016-01-03T16:41:06.427" Title="What is better: one sprintf() or multiple strcat() and itoa()?" Tags="|arduino-uno|serial|sketch|string|code-optimization|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18408" PostTypeId="2" ParentId="18406" CreationDate="2015-12-03T23:25:18.913" Score="2" Body="&lt;p&gt;The wonderful thing about the Arduino is that it hides a lot of the programming &quot;noise&quot; and lets you concentrate on the code that is actually doing the work. Part of the joy of programming is starting to &quot;own&quot; the code and being able to make it do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer here isn't too hard, and I'm sure that many could answer your question – but I think you might enjoy the experience more (and you would earn more respect) if you make a stab at it yourself first. Or if you already have, tell us what you've tried and what happened when you tried it. That will help us help you to see not only the steps necessary, but the concepts that will enable you to branch off on your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know what is causing the LEDs to blink in your current code?&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-03T23:25:18.913" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18409" PostTypeId="2" ParentId="18407" CreationDate="2015-12-03T23:35:54.710" Score="0" Body="&lt;p&gt;As a general principle code that is easy to read and modify is &quot;better&quot; – the problem here is that there are many &quot;betters&quot; to consider:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Readability&lt;/li&gt;&#xA;&lt;li&gt;Maintainability&lt;/li&gt;&#xA;&lt;li&gt;Space efficiency&lt;/li&gt;&#xA;&lt;li&gt;Time efficiency&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is no universal answer to which of those is the most important. My personal bias is to start with code that is easy to read and obvious in its function. Then if time or space are an issue to start looking for ways to improve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code, you could also do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  itoa(first, sendBuffer[1], 10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would save you a function call and perhaps some space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also keep in mind that the cost of &lt;code&gt;sprintf()&lt;/code&gt; in terms of space may get amortized over many uses, so it might not be as bad as it initially seems.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-03T23:35:54.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18410" PostTypeId="2" ParentId="18407" CreationDate="2015-12-03T23:45:54.383" Score="4" Body="&lt;p&gt;Why do you feel you need to use either method? Neither are needed. Just print the individual parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print('X');&#xA;Serial.print(first);&#xA;Serial.print('Y');&#xA;Serial.print(second);&#xA;Serial.println('T');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No intermediate buffers, just sending the data direct out to the UART.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-03T23:45:54.383" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18411" PostTypeId="1" CreationDate="2015-12-03T23:58:23.407" Score="4" ViewCount="731" Body="&lt;p&gt;I would like to write code in Arduino language, compile it in the Arduino IDE, grab the resulting binary code, and flash it to the Due via the TX/RX UART pins, bypassing both the USB Programming Port and Atmel16U2 chip. Before the UART flash, I am manually toggling the Erase and Reset pins on the Due to initiate a hard reset of the SAM3X chip, and SAM-BA now waits for the code. I would like to know: can I directly grab the binary code compiled by the Arduino IDE and give it to SAM3X via UART or is there extra code baked into that binary by the Arduino compiler that would cause this method to fail?&lt;/p&gt;&#xA;" OwnerUserId="15337" LastActivityDate="2020-12-13T14:03:40.333" Title="Flash Arduino Due via UART" Tags="|arduino-due|flash|bossa|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18412" PostTypeId="2" ParentId="18407" CreationDate="2015-12-04T00:22:03.367" Score="2" Body="&lt;p&gt;Here's a method that for some reason uses slightly fewer bytes of flash memory than Majenko's does, while producing the same output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&lt;/code&gt; at the beginning of the program, and replace the five statements shown in Majenko's answer with the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial &amp;lt;&amp;lt; 'X' &amp;lt;&amp;lt; first &amp;lt;&amp;lt; 'Y' &amp;lt;&amp;lt; second &amp;lt;&amp;lt; 'T' &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, use the &lt;code&gt;Streaming.h&lt;/code&gt; &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;contributed library&lt;/a&gt;, which adds some “syntactic sugar” to Arduino C.  At compile time it converts C++-like &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; Serial stream operators to &lt;code&gt;Serial.print&lt;/code&gt; statements, without increasing code size.  You can install it via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow&quot;&gt;arduiniana.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the &lt;code&gt;#if&lt;/code&gt;-delimited sections in the program shown below are selected individually (by changing two of the three 01's at a time to 0's), I got the following compiled-code and RAM figures, running the program on a Nano, where all three ways appear to give the same output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      Bytes  Bytes&#xA;Alt.  Flash   Ram    Note&#xA; 1    2,204   182    Five Serial.print stmts&#xA; 2    3,384   190    Using snprintf()&#xA; 3    2,176   182    One Streaming stmt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know whether this slight decrease (from 2204 to 2176 bytes of flash) is replicable, but the method probably is worth trying in your situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;void loop() {&#xA;  int first=50, second=100;&#xA;  //enum { first=50, second=100};&#xA;#if 01&#xA;  Serial.print('X');&#xA;  Serial.print(first);&#xA;  Serial.print('Y');&#xA;  Serial.print(second);&#xA;  Serial.println('T');&#xA;#endif&#xA;#if 01&#xA;  char sendBuffer[16];&#xA;  snprintf(sendBuffer, sizeof sendBuffer, &quot;X%dY%dT&quot;, first, second);&#xA;  Serial.println(sendBuffer);&#xA;#endif&#xA;#if 01&#xA;  Serial &amp;lt;&amp;lt; 'X' &amp;lt;&amp;lt; first &amp;lt;&amp;lt; 'Y' &amp;lt;&amp;lt; second &amp;lt;&amp;lt; 'T' &amp;lt;&amp;lt; endl;&#xA;#endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, I used &lt;code&gt;snprintf()&lt;/code&gt; rather than &lt;code&gt;sprintf()&lt;/code&gt; because it's easier to avoid buffer overruns with &lt;code&gt;snprintf()&lt;/code&gt; than with &lt;code&gt;sprintf()&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-04T00:22:03.367" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18413" PostTypeId="2" ParentId="18407" CreationDate="2015-12-04T00:49:50.520" Score="0" Body="&lt;p&gt;The sprintf() function has a memory cost because of the library import at compile time.  But it only costs that once, no matter how many more times you use it.  Unless you're running out of space, memory used is not a big deal.  There's no point keeping some memory unused on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's better to use sprintf() because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sprintf() produces code that is more readable, since the final output string can be easily visualised - obviously with only place holders for the variable parts.&lt;/li&gt;&#xA;&lt;li&gt;Making minor changes to the output is quicker, since there's not lines of output generator functions to re-organise.&lt;/li&gt;&#xA;&lt;li&gt;You end up with less code.  Less code is is easier to debug and maintain.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would however, encourage you to use snprintf().  This function differs from sprintf() by taking the maximum buffer size as an argument.  This will help prevent problems with buffer-overruns (i.e.: accidentally putting more data into a string than in can hold)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sprintf on Arduino does not include support for floating point numbers though.  This is quite a drawback.  One needs to use additionally use dtostrf(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real takeaway point is this:  Only optimise your program when you need to.  &lt;a href=&quot;https://en.wikipedia.org/wiki/Donald_Knuth&quot; rel=&quot;nofollow&quot;&gt;Donald Knuth&lt;/a&gt; said: &quot;Premature Optimisation is the root of all evil&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2015-12-04T00:49:50.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18414" PostTypeId="2" ParentId="16620" CreationDate="2015-12-04T01:15:57.367" Score="1" Body="&lt;p&gt;The core of the problem is that the code is being compiled as C and not C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error says 'new[]' is undefined at the link stage.  This is because the linker is not pulling in the C++ standard libraries.  The built-in function new[] it doesn't exist in C. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The filename FPS_GT511C3.c.cpp is the elephant in the room.  You could consider renaming it (and others) to FPS_GT511C3.cpp.  Although the plain Arduino IDE does not really have a problem with building them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option might be to modify the new[] (and delete[]) for C's malloc() and free().  However this is only appropriate for the allocation of simple types (byte, int, etc).  If the code also allocates objects, it's not possible to simply swap these functions out since C++ (default) initialisation is be going on.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2015-12-04T01:15:57.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18415" PostTypeId="2" ParentId="18406" CreationDate="2015-12-04T01:26:59.333" Score="1" Body="&lt;p&gt;Remember that the setup() function runs once, and then the loop() function runs forever.  So to keep the blue LED light, simply turn it on, but never off.  The code for the red LED remains unchanged.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int red_led  = 4;&#xA;const int blue_led = 3;&#xA;&#xA;void setup()  &#xA;{&#xA;    pinMode(red_led, OUTPUT);&#xA;    pinMode(blue_led, OUTPUT);&#xA;&#xA;    digitalWrite(blue_led, HIGH);  // LED On&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    digitalWrite(red_led, HIGH);  // LED On&#xA;    delay(1000);&#xA;    digitalWrite(red_led, LOW);   // LED Off&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2015-12-04T01:26:59.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18416" PostTypeId="2" ParentId="18398" CreationDate="2015-12-04T01:40:40.763" Score="1" Body="&lt;p&gt;On the Arduino side, &lt;code&gt;flush&lt;/code&gt; simply waits until the last byte has been fully transmitted.  It says nothing about how quickly it is being read by the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general problem you are having is called &quot;flow control&quot;.  It has been solved with many different techniques, like &quot;handshaking&quot;.  For example, the PC could send a character when it has received the last byte of a data set (a line, as returned by &lt;code&gt;readline&lt;/code&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;line = self.ser.readline()&#xA;self.ser.write(&quot;!&quot;); // Tell Arduino line was received&#xA;line = line.split()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While the PC proceeds to parse the line, the Arduino will eventually receive the handshake character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  // Send a line&#xA;  Serial.println( ... );&#xA;&#xA;  // Wait for handshake character&#xA;  bool gotHandshake;&#xA;  do {&#xA;    while (!Serial.available())&#xA;      ; // wait for chars&#xA;    char c = Serial.read();&#xA;    gotHandshake = (c == '!');&#xA;  } while (!gotHandshake);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the Arduino can proceed to send the next data set (i.e., a line).  The OS on the PC will buffer characters from the Arduino until the python program receives them with &lt;code&gt;readline&lt;/code&gt; and sends another handshake character.  No &lt;code&gt;delay&lt;/code&gt; required.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-04T01:40:40.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18417" PostTypeId="1" CreationDate="2015-12-03T20:01:52.770" Score="1" ViewCount="105" Body="&lt;p&gt;I'm using an Arduino Uno with the Adafruit Data Logger Shield powered by a Voltaic 5V 2A battery pack. When writing to an SD card, the time stamp never changes (always reports the same now.unixtime). However, when powered from a laptop, the time stamp is correct and everything seems to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input voltage from the battery is confirmed to be just over 5V and not substantially lower the the laptop usb port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone seen this before? Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="15385" OwnerDisplayName="GIVW" LastEditorUserId="37523" LastEditDate="2018-07-27T01:46:25.987" LastActivityDate="2018-07-27T01:46:25.987" Title="Arduino Uno data logger shield recording nonsense time" Tags="|arduino-uno|shields|datalogging|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18418" PostTypeId="2" ParentId="18417" CreationDate="2015-12-04T05:31:20.777" Score="2" Body="&lt;p&gt;Where are you brining the power onto the Arduino board? If you bring it in through the external power connector you need to account for the voltage needed to run the regulator. You might be running into problems with low voltage and some part of your system that is sensitive to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try bring the power in on the 5 V pin, but then you are taking responsibility for the quality of the power supply.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-04T05:31:20.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18419" PostTypeId="2" ParentId="18417" CreationDate="2015-12-04T05:53:52.570" Score="1" Body="&lt;p&gt;If you are putting just over 5V into the Vin, it goes through the on-board regulator and needs a 7v minimum per &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardUno&lt;/a&gt;  The Adafruit Data Logger Shield doc at &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-data-logger-shield.pdf&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/downloads/pdf/adafruit-data-logger-shield.pdf&lt;/a&gt; shows a 9V battery pack.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-04T05:53:52.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18420" PostTypeId="2" ParentId="323" CreationDate="2015-12-04T07:26:32.023" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The DS2482-100 is an I2C-to-1-Wire®bridge device that interfaces directly to standard (100kHz max) or fast (400kHz max) I2C masters to perform bidirectional protocol conversion between the I2C master and any&#xA;  downstream 1-Wire slave devices.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It uses a higher level protocol over I2C which does not directly match the bit-banged OneWire interface above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible solution is to &quot;only&quot; reuse the OneWire interface and reimplement it. Sub-classing will not work as the member functions are not virtual. Unfortunately this will not work directly due to error handing, timing, etc. The DallasTemperature class will also need modifying. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see the &lt;a href=&quot;http://datasheets.maximintegrated.com/en/ds/DS2482-100.pdf&quot; rel=&quot;nofollow&quot;&gt;DS2482-100 product description and protocol&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve your goal of allowing either bit-banged or DS2482-100 based 1-Wire master would require 1) an abstract interface (class) used by 1-Wire master device drivers, 2) sub-classes for each implementation master variant. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the 1-Wire protocol has a number of common commands a delegation pattern is more useful. Please see the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/OWI/OWI.hh&quot; rel=&quot;nofollow&quot;&gt;Cosa OWI::Driver&lt;/a&gt; and &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/DS18B20/DS18B20.hh&quot; rel=&quot;nofollow&quot;&gt;DS18B20&lt;/a&gt; device driver for an example of the delegation pattern. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-04T07:26:32.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18421" PostTypeId="1" CreationDate="2015-12-04T08:35:08.447" Score="2" ViewCount="2951" Body="&lt;p&gt;I have a problem calibrating my GY-61 accelerometer on an Arduino Uno to get values in m/s2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Analog-reading code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;const int xPin = A5;         &#xA;const int yPin = A4;                &#xA;const int zPin = A3;&#xA;// ...&#xA;void loop() {&#xA;   int xRead = analogRead(xPin);&#xA;   int yRead = analogRead(yPin);&#xA;   int zRead = analogRead(zPin);&#xA;&#xA;   float xData = (((float)xRead - 337.92) / 61.44 * 9.81);&#xA;&#xA;   accData= sqrt((xData*xData)+(yData*yData)+(zData*zData));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;xData should show values in m/s2.&#xA;What do those values  &lt;code&gt;337.92&lt;/code&gt;  and  &lt;code&gt;61.44&lt;/code&gt; mean and how can I calibrate them to get right values? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Values I get (in one position without moving):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xData   yData   zData    accData&#xA;-11.16   1.61   -0.79    11.31&#xA;-0.79  -11.48    0.01    11.51&#xA;-0.47   -0.63  -10.68    10.71&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;accData should be near 9.81 m/s2, also x or y or z, depending on rotation.&lt;/p&gt;&#xA;" OwnerUserId="14759" LastEditorUserId="3917" LastEditDate="2015-12-05T00:01:52.323" LastActivityDate="2016-01-26T12:59:41.020" Title="Accelerometer sensor gy-61 convert to m/s2" Tags="|arduino-uno|accelerometer|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18422" PostTypeId="1" AcceptedAnswerId="18427" CreationDate="2015-12-04T09:26:01.853" Score="1" ViewCount="3478" Body="&lt;p&gt;I would like to use larger numbers than an unsigned long long in Arduino. Is that possible?&lt;/p&gt;&#xA;" OwnerUserId="15349" LastActivityDate="2015-12-04T15:17:02.733" Title="Can I work with larger numbers than an unsigned long long in Arduino?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18425" PostTypeId="1" CreationDate="2015-12-04T12:55:12.510" Score="-1" ViewCount="77" Body="&lt;p&gt;I am trying to communicate with ethernet shield. When I enter the IP in Chrome the job is done (simply an LED turns off and on with IP/$1 and IP/$2) but with Safari it is not. Any idea what the difference is?&lt;/p&gt;&#xA;" OwnerUserId="14917" LastActivityDate="2016-02-07T20:26:45.963" Title="Control the ethernet shield with Chrome and Safari" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18427" PostTypeId="2" ParentId="18422" CreationDate="2015-12-04T15:17:02.733" Score="3" Body="&lt;p&gt;There are many ways to use numbers bigger than an &lt;code&gt;unsigned long&lt;/code&gt; on Arduino. The right one depends on the application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Floats and Doubles&lt;/strong&gt;&#xA;&lt;code&gt;float&lt;/code&gt;s and &lt;code&gt;double&lt;/code&gt;s types on Arduino can hold exact integers up  &lt;code&gt;2^53&lt;/code&gt;. That is a very large number. They are built into the Arduino compiler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;uint64_t&lt;/strong&gt;&#xA;The &lt;code&gt;uint64_t&lt;/code&gt; type can hold exact integers up to &lt;code&gt;2^64&lt;/code&gt;. That is a very large number. This type is built into the Arduino compiler, but note that some Arduino library functions do not have versions for this type so may need to down-convert for printing and serializing and stuff like that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;BigNumber (or bc)&lt;/strong&gt;&#xA;The &lt;code&gt;BigNumber&lt;/code&gt; type can represent exact numbers (integer or otherwise) limited only by available memory- but certainly hundreds of digits long on Arduino. These are extremely big numbers. This type is not built into the Arduino, but there is a nice Arduino library version available... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/nickgammon/BigNumber&quot; rel=&quot;nofollow&quot;&gt;https://github.com/nickgammon/BigNumber&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, this type is not supprted by the Arduino built-in library functions so  you will need to either down-convert or find &lt;code&gt;BigNumber&lt;/code&gt; compatible functions for things like printing and serializing. &lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-12-04T15:17:02.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18428" PostTypeId="1" CreationDate="2015-12-04T16:13:26.060" Score="2" ViewCount="143" Body="&lt;p&gt;Basically I want one LED to flash 5 times in the same amount of time it takes another LED to flash 4 times. This is what I have, but they are flashing independently and I need them to flash simultaneously. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//Making a 5/4 Polyrhythm with 2 LEDs&#xA;const int LED13 = 13;&#xA;const int LED7 = 7;&#xA;int i = 5; &#xA;&#xA;void setup() {&#xA;   pinMode(LED13, OUTPUT);&#xA;   pinMode(LED7, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  for(i=0; i&amp;lt;5; i++)&#xA;  {&#xA;     digitalWrite (LED13, HIGH);&#xA;     delay(500);&#xA;     digitalWrite (LED13, LOW);&#xA;     delay(800);&#xA;  }&#xA;&#xA;  for(i=0; i&amp;lt;4; i++)&#xA;  {&#xA;     digitalWrite (LED7, HIGH);&#xA;     delay(500);&#xA;     digitalWrite (LED7, LOW);&#xA;     delay(1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="15359" LastEditorUserId="3917" LastEditDate="2015-12-09T20:36:18.887" LastActivityDate="2015-12-09T20:36:18.887" Title="How to make 2 LEDs flash in a 5/4 Polyrhythm?" Tags="|led|timing|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18429" PostTypeId="1" AcceptedAnswerId="18439" CreationDate="2015-12-04T16:19:27.647" Score="2" ViewCount="858" Body="&lt;p&gt;Trying to get avr-objdump to generate a listing that interleaves the assembly with the source code. I've tried a bunch of debugging arguments in different configurations but I can't seem to get it. The best I could do was getting it to interleave the object with line numbers from the assembly (avr-objdump -lS spi.o)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/AshlynBlack/tinySPI/blob/c0748ee5fe1d5b85813ac7b4628bb84014d4a0d4/examples/Makefile&quot; rel=&quot;nofollow&quot;&gt;Original Makefile&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my current Makefile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PREFIX=avr-&#xA;CC=${PREFIX}gcc&#xA;OBJCOPY=${PREFIX}objcopy&#xA;&#xA;BIN=knightrider&#xA;MCU=attiny85&#xA;OBJS=../src/tinySPI.o src/knightrider.o&#xA;&#xA;PROG?=atmelice_isp&#xA;PORT?=usb&#xA;&#xA;CFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections&#xA;LDFLAGS=-mmcu=${MCU} -Wl,--gc-sections&#xA;&#xA;${BIN}.hex: ${BIN}.elf&#xA;    @mkdir -p bin&#xA;    ${OBJCOPY} -O ihex -R .eeprom build/$&amp;lt; bin/$@&#xA;&#xA;${BIN}.elf: ${OBJS}&#xA;    @mkdir -p build&#xA;    ${CC} ${LDFLAGS} -o build/$@ $?&#xA;&#xA;install: ${BIN}.hex&#xA;    avrdude -c ${PROG} -P ${PORT} -p ${MCU} -U flash:w:${BIN}.hex:i -qq&#xA;&#xA;clean:&#xA;    rm -f build/*&#xA;    rm -f bin/*&#xA;&#xA;fuses:&#xA;    avrdude -c ${PROG} -P ${PORT} -p ${MCU} -U lfuse:w:0x62:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:i -qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What would I need to change in order to run avr-objdump and get an interleaved listing of an .o and its corresponding .c (e.g. spi.o and spi.c)?&lt;/p&gt;&#xA;" OwnerUserId="15295" LastEditorUserId="15295" LastEditDate="2015-12-05T18:50:38.153" LastActivityDate="2015-12-05T18:50:38.153" Title="Interleave Assembly and Source for avr-objdump" Tags="|assembly|avr-toolchain|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18430" PostTypeId="2" ParentId="18428" CreationDate="2015-12-04T16:27:46.577" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/a/17929/6628&quot;&gt;https://arduino.stackexchange.com/a/17929/6628&lt;/a&gt; with code like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int onTime = 500;&#xA;const int measureTime = (int) (60*1000/10);  // 10 BPM, or 1500*4ms/measure&#xA;const int off4 = measureTime/4 - onTime;  // take care these don't go negative&#xA;const int off5 = measureTime/5 - onTime;  //&#xA;unsigned long next5;&#xA;unsigned long next4;&#xA;&#xA;&#xA;...&#xA;loop(){&#xA;  unsigned long now;&#xA;  now=millis();&#xA;  ...&#xA;  if(next5 &amp;lt; now) {&#xA;     if digitalRead(LED13) { next5 = now+off5;   digitalWrite(LED13,LOW );}&#xA;     else                  { next5 = now+onTime; digitalWrite(LED13,HIGH);}&#xA;  }&#xA;  if(next4 &amp;lt; now) {&#xA;     if digitalRead(LED7)  { next4 = now+off4;    digitalWrite(LED7,LOW );}&#xA;     else                  { next4 = now+onTime ; digitalWrite(LED7,HIGH);}&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-12-04T16:45:42.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18431" PostTypeId="2" ParentId="18428" CreationDate="2015-12-04T16:38:36.607" Score="4" Body="&lt;p&gt;I generally calculate whether the led must be on or off, based on the current time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Making a 5/4 Polyrythm with 2 LEDs&#xA;const int LED13 = 13;&#xA;const int LED7 = 7;&#xA;int i = 5; &#xA;&#xA;void setup() {&#xA;   pinMode(LED13, OUTPUT);&#xA;   pinMode(LED7, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    // led 13 flashes 5 times per interval of 6 seconds. So the led is on/off for 600ms ( 6000/(2*5) )&#xA;    // led  7 flashes 4 times per interval of 6 seconds. So the led is on/off for 750ms ( 6000/(2*4) )&#xA;    bool led13on = (millis()/600)%2!=0; // count the number of 600ms intevals have passed, and see if this number if odd or even. odd means led must be on, even means the led must be on&#xA;    bool led7on  = (millis()/750)%2!=0;&#xA;    digitalWrite (LED13, led13on);&#xA;    digitalWrite (LED7, led7on);&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-04T16:38:36.607" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18432" PostTypeId="1" CreationDate="2015-12-04T16:39:40.887" Score="0" ViewCount="938" Body="&lt;p&gt;I am trying to create an array of structs that contain pairs of Strings and Callbacks the problem I am having is assigning the callback function. I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define UI_ROUTINE_ITEMS 10&#xA;&#xA;struct MenuItem{&#xA;    String label;&#xA;    typedef void (*callback)();&#xA;};&#xA;&#xA;class MenuSystem{&#xA;   MenuItem routineMenu[UI_ROUTINE_ITEMS];&#xA;&#xA;   MenuSystem(){&#xA;      routineMenu[0] = {&quot;Test&quot;, &amp;amp;Test::TestCallback};&#xA;   }&#xA;}&#xA;&#xA;class Test{&#xA;   void TestCallback(){&#xA;      Serial.println(&quot;Callback called&quot;);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to compile this I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: no match for 'operator=' (operand types are 'MenuItem' and '&amp;lt;brace-enclosed initializer list&amp;gt;')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know this is a Syntax issue I just can not figure out how this should be done. I have looked at several examples but I can't figure out how to do this with Classes without using free/malloc, what am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I finally got this working, the problem was that the function that I was trying to call was not static and the declaration in the structure was not quite right. Below is the corrected example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define UI_ROUTINE_ITEMS 10&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;struct MenuItem{&#xA;    String label;&#xA;    void (*callback)(void);&#xA;};&#xA;&#xA;class MenuSystem{&#xA;   MenuItem routineMenu[UI_ROUTINE_ITEMS];&#xA;&#xA;   MenuSystem(){&#xA;      routineMenu[0] = {&quot;Test&quot;, &amp;amp;Test::TestCallback};&#xA;   }&#xA;}&#xA;&#xA;class Test{&#xA;   public static void TestCallback(){&#xA;      Serial.println(&quot;Callback called&quot;);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="14761" LastEditDate="2015-12-05T01:26:02.660" LastActivityDate="2017-05-30T15:01:33.380" Title="Array of Strings and Callbacks" Tags="|arduino-mega|c++|callbacks|array|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18433" PostTypeId="1" AcceptedAnswerId="18436" CreationDate="2015-12-04T16:57:41.830" Score="0" ViewCount="516" Body="&lt;p&gt;Is it allowed to have battery and USB connected to the Trinket(3.3V) at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the battery to also power other components, so always disconnecting power, hooking USB to re-program and vice-versa is quite time consuming (and I fear to ruin the connectors).&lt;/p&gt;&#xA;" OwnerUserId="15190" LastActivityDate="2015-12-04T17:49:27.887" Title="Trinket: Battery + USB at the same time?" Tags="|power|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18434" PostTypeId="1" CreationDate="2015-12-04T16:59:30.753" Score="5" ViewCount="13650" Body="&lt;p&gt;I'm trying to find a way I can toggle the 5V pin to turn on/off. I want the voltage to pass to another wire at a certain point. It should be off and then when something happens, the 5V should turn on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="13545" LastEditorUserId="6936" LastEditDate="2016-01-06T03:15:35.003" LastActivityDate="2020-01-21T02:32:39.773" Title="Is there any way I can turn off the 5V pin?" Tags="|pins|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18435" PostTypeId="2" ParentId="18434" CreationDate="2015-12-04T17:31:52.210" Score="2" Body="&lt;p&gt;There isn't programmatic control of the 5V pin, it is hard wired to the USB or the output of the Vin Voltage regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try something from &lt;a href=&quot;https://arduino.stackexchange.com/questions/403/how-can-higher-current-devices-motors-solenoids-lights-etc-be-controlled-b&quot;&gt;How can higher current devices (motors, solenoids, lights, etc.) be controlled by an Arduino?&lt;/a&gt; to control the low side of the external device.  If you need high-side control, maybe an opto-isolator would be a good solution.   &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-12-04T17:31:52.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18436" PostTypeId="2" ParentId="18433" CreationDate="2015-12-04T17:49:27.887" Score="2" Body="&lt;p&gt;From &lt;a href=&quot;https://learn.adafruit.com/system/assets/assets/000/010/773/original/adafruit_products_trinket3.png?1378223258&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/system/assets/assets/000/010/773/original/adafruit_products_trinket3.png?1378223258&lt;/a&gt; it looks OK -- there are blocking diodes D3 and D2 that prevent backfeeding either the battery or the USB +5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are worried, or want to monitor battery-only performance, you could make a special USB cable with the +5 red wire disconnected, and rely on the in-circuit battery to power the device, while still using the USB data lines.  See &lt;a href=&quot;https://www.pjrc.com/teensy/external_power.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/external_power.html&lt;/a&gt; Option 2 for an example of the cable surgery.   &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-04T17:49:27.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18437" PostTypeId="2" ParentId="18432" CreationDate="2015-12-04T18:09:48.410" Score="1" Body="&lt;p&gt;Several issue with this code. First, use public/protected/private for classes. Second, use a const char* instead of String or even better str_P. It is the usage of String that is giving the compile error. Third, the Test::TestCallback function reference is not possible. It is a member function. To correct that either have an instance or define the callback function as static. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could define an abstract MenuItem class with the string and a virtual member function. A Menu class would hold a collection of MenuItems. All the static data should be put in program memory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/Menu/Menu.hh&quot; rel=&quot;nofollow&quot;&gt;Menu&lt;/a&gt; system in Cosa. Please see the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/LCD/CosaLCDmenu/CosaLCDmenu.ino&quot; rel=&quot;nofollow&quot;&gt;example sketch&lt;/a&gt;. This implementation follows the &lt;a href=&quot;https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller&quot; rel=&quot;nofollow&quot;&gt;MVC&lt;/a&gt; design pattern.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-04T18:09:48.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18439" PostTypeId="2" ParentId="18429" CreationDate="2015-12-04T19:07:45.760" Score="3" Body="&lt;p&gt;First make sure you add &lt;code&gt;-g&lt;/code&gt; to all your compilation commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you can run &lt;code&gt;avr-objdump -S build/spi.elf&lt;/code&gt; (for instance).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I see you're missing the MCU definition in your link command. Without that it won't link in the proper C startup routines and your program will most probably not run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a makefile I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PREFIX=avr-&#xA;CC=${PREFIX}gcc&#xA;CXX=${PREFIX}g++&#xA;LD=${PREFIX}ld&#xA;AS=${PREFIX}as&#xA;OBJCOPY=${PREFIX}objcopy&#xA;OBJDUMP=${PREFIX}objdump&#xA;&#xA;BIN=blink&#xA;MCU=atmega328p&#xA;OBJS=blink.o&#xA;&#xA;CFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections&#xA;CXXFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections -fno-exceptions&#xA;LDFLAGS=-mmcu=${MCU} -Wl,--gc-sections&#xA;&#xA;${BIN}.hex: ${BIN}.elf&#xA;    ${OBJCOPY} -O ihex -R .eeprom $&amp;lt; $@&#xA;&#xA;${BIN}.elf: ${OBJS}&#xA;    ${CC} ${LDFLAGS} -o $@ $? &#xA;    ${OBJDUMP} -S $@ &amp;gt; ${BIN}.dis&#xA;&#xA;install: ${BIN}.hex&#xA;    avrdude -C ./avrdude.conf -c usbasp -p ${MCU} -U flash:w:${BIN}.hex&#xA; -qq&#xA;&#xA;clean:&#xA;    rm -f *.o *.elf *.hex&#xA;&#xA;fuses:&#xA;    avrdude  -c usbasp -p ${MCU} -C avrdude.conf -U lfuse:w:0xff:m -U h&#xA;fuse:w:0xd6:m -U efuse:w:0x05:m -qq&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-04T19:07:45.760" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18440" PostTypeId="1" AcceptedAnswerId="18441" CreationDate="2015-12-04T19:29:33.673" Score="0" ViewCount="769" Body="&lt;p&gt;In arduino's official page about ShiftOut &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ShiftOut&lt;/a&gt;, a drawing with two 74HC595 powered by the arduino board, is displayed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the resistors are 220Ω, the total current should be 5/220x16 = 0.36A which exceeds the maximum total current of 0.20A for the arduino device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, could someone turn on simultaneously 16 LEDs using two shift registers without damaging the device?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2015-12-04T19:36:57.943" Title="max current while using a shift register" Tags="|shift-register|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18441" PostTypeId="2" ParentId="18440" CreationDate="2015-12-04T19:36:57.943" Score="2" Body="&lt;p&gt;0.20A is &lt;em&gt;not&lt;/em&gt; the maximum current for an Arduino device.  0.20A is the maximum current for &lt;em&gt;the chip that is on the Arduino&lt;/em&gt;.  Thus it is only relevant to devices that are &lt;em&gt;directly&lt;/em&gt; connected to the Arduino's IO pins (that connect direct to the chip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shift registers take their own power from the +5V pin, which is limited to between 500mA and 800mA depending on how you power your board.  Each shift register has its own power limits that are completely separate to the Arduino's main chip's power limits.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-04T19:36:57.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18442" PostTypeId="2" ParentId="18434" CreationDate="2015-12-04T19:54:32.357" Score="1" Body="&lt;p&gt;You don't really want to do that. The 5V pin is on the power bus of your Arduino board. If it &lt;em&gt;were&lt;/em&gt; possible to turn it off, the entire Arduino would shut down.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-04T19:54:32.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18443" PostTypeId="2" ParentId="18312" CreationDate="2015-12-04T20:08:35.220" Score="1" Body="&lt;p&gt;If setup() runs, it is because the system has been restarted. It could becuase the reset button was pushed, or it could be due to a power-cycle. But either way, the code will start over completely. So you could&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Deal with restart issues in setup() as it will only be called once per session (unless you call it in your own code); or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make a variable &lt;code&gt;static boolean PowerCycled = true;&lt;/code&gt; and clear it once your code has dealt with its re-start issues. After a restart, the initialzed data will get reloaded, including &lt;code&gt;PowerCycled&lt;/code&gt; with it's initial value of &lt;code&gt;true&lt;/code&gt; restored.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-04T20:08:35.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18444" PostTypeId="2" ParentId="18434" CreationDate="2015-12-04T20:19:21.707" Score="2" Body="&lt;p&gt;If I'm understanding you correctly, you want a 5 V output that is under programatic control. Do you know how much power you want to pull from the pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the demand is fairly low, you could use one of the digital pins directly – they will supply about 40 mA on an &quot;official&quot; Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need more power, then you could use the pin to switch an external device such as a transistor or a relay.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-04T20:19:21.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18445" PostTypeId="1" AcceptedAnswerId="18454" CreationDate="2015-12-04T15:48:13.037" Score="0" ViewCount="1924" Body="&lt;p&gt;I am using &lt;a href=&quot;http://www.adafruit.com/product/2000&quot; rel=&quot;nofollow noreferrer&quot;&gt;Trinket Pro 5V&lt;/a&gt; to run a simple i/o code. The input from the piezo vibration sensor is read by the Trinket and Translated into a servo position.&#xA;It works fine powered through a USB connection, however as soon as I try to power it using a 9V battery (plugged into the Bat+ and G terminals), the code stops running and the red light on the Trinket starts to blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the power source not sufficient - 9V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone faced a similar problem?&lt;/p&gt;&#xA;" OwnerUserId="15366" OwnerDisplayName="K.Nadkina" LastEditorUserId="27346" LastEditDate="2018-11-19T10:09:20.370" LastActivityDate="2018-11-19T10:09:20.370" Title="Trinket Pro 5V red light flashing when battery attached" Tags="|power|battery|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18447" PostTypeId="2" ParentId="18434" CreationDate="2015-12-04T22:31:14.170" Score="5" Body="&lt;p&gt;For energy-efficient switching (along with relatively high-current capability), I recommend using a &lt;em&gt;Darlington&lt;/em&gt; transistor connected to one of the output pins (digital for on/off, analogue for variable). Then you would just call  pinMode(A0, OUTPUT); followed by digitalWrite(A0, HIGH); Here is a sketch I made demonstrating what I mean:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XcJlh.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XcJlh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that a normal transistor would draw more current from the Arduino's pin, which could be bad for the Arduino, and which would waste energy.&lt;/p&gt;&#xA;" OwnerUserId="15303" LastActivityDate="2015-12-04T22:31:14.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18448" PostTypeId="1" CreationDate="2015-12-04T22:53:05.760" Score="3" ViewCount="342" Body="&lt;p&gt;Following this tutorial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Complete-newbie-step-by-step-3D-printer-with-all-p/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Complete-newbie-step-by-step-3D-printer-with-all-p/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected DVD stepper motor to RAMPS 1.4 on arduino with Marlin software with this settings: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt; //#define DEFAULT_AXIS_STEPS_PER_UNIT   {80,80,4000,500}  // default steps per unit for Ultimaker&#xA;&#xA; #define DEFAULT_AXIS_STEPS_PER_UNIT {215.12,215.12,8034.69,196.52}&#xA;&#xA; // #define DEFAULT_MAX_FEEDRATE          {300, 300, 5, 25}    // (mm/sec)&#xA;&#xA; #define DEFAULT_MAX_FEEDRATE {100, 100, 2, 25}&#xA;&#xA; // #define DEFAULT_MAX_ACCELERATION      {3000,3000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.&#xA;&#xA; #define DEFAULT_MAX_ACCELERATION {200,200,50,5000}&#xA;&#xA;&#xA; #define DEFAULT_ACCELERATION          100    // X, Y, Z and E acceleration in mm/s^2 for printing moves&#xA;&#xA; #define DEFAULT_RETRACT_ACCELERATION  100    // E acceleration in mm/s^2 for retracts&#xA;&#xA; #define DEFAULT_TRAVEL_ACCELERATION   100    // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put a &lt;a href=&quot;https://vid.me/vd6Q&quot; rel=&quot;nofollow&quot;&gt;video at vid.me&lt;/a&gt; (hopefully with sound) showing stepper behaviour when I press +1mm,-1mm,-1mm,-1mm,-1mm,-1mm,-1mm,+1mm,+1mm,+1mm,+1mm  on Pronterface software.&lt;/p&gt;&#xA;" OwnerUserId="15365" LastEditorUserId="3917" LastEditDate="2015-12-09T20:30:38.473" LastActivityDate="2016-02-28T17:38:57.267" Title="Weird stepper motor behaviour on RAMPS in arduino" Tags="|arduino-mega|motor|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18449" PostTypeId="1" CreationDate="2015-12-04T23:02:32.277" Score="3" ViewCount="634" Body="&lt;p&gt;I was looking for some easy tutorial on bidirectional communication via ESP8266 connected to Arduino UNO. I want to send and receive strings from and to JQuery based website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I couldn't find any answers on this because most of them are about working directly with ESP. It's probably easy thing to setup but I'm totally new in working with network communication ;(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this moment I know how to set AT for ESP as client and receive messages with pin number to toggle:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RST&#xA;AT+CWMODE=1&#xA;AT+CIPMUX=1&#xA;AT+CWJAP=&quot;user&quot;,&quot;pswd&quot;&#xA;AT+CIPSERVER=1,80&#xA;AT+CIPSTO=10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And JQuery for buttons (data is their ID) form one of tutorials:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$(&quot;.led&quot;).click(function(){&#xA;    var p = $(this).attr('id'); &#xA;    $.get(&quot;http://192.168.1.14:80/&quot;, {pin:p}); &#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem with this is whenever I send something the ESP gets the value and prints info but then it disconnects after 10 seconds (defined time) and when I hit the button again it reconnects and I can't do more (for example: send another value) during the time when it's connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it normal behavior? How to make it possible to send many messages when it's still connected to the port without waiting to reconnect? Can I make it in more &quot;streaming&quot; way? And how to make this bidirectional? Any advice on configuring the device will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="15334" LastActivityDate="2015-12-04T23:02:32.277" Title="ESP8266 and Arduino bidirectional streaming from and to a website" Tags="|arduino-uno|communication|esp8266|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18450" PostTypeId="1" CreationDate="2015-12-05T00:05:00.217" Score="2" ViewCount="8199" Body="&lt;p&gt;I am building a CNC machine based on GRBL code on a uno. I also have found a script to read data on a N64 controller. I know there is not enough pins available to do both codes running on the same arduino, so I was wondering if I could have my GRBL arduino connected to a computer thru USB, and at the same time, have a second arduino reading data from the n64 joystick, create Gcode accordingly, and feed that Gcode to the GRBL arduino through the tx/rx pins of each of them.&#xA;I guess I'll have to put a on-off switch on the tx/rx wife to avoid &quot;noise&quot; when I actually send Gcode to the GRBL arduino from the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this all make sense?&lt;/p&gt;&#xA;" OwnerUserId="13493" LastActivityDate="2015-12-06T12:21:11.370" Title="May I use both USB-serial and tx/rx pins at the same time?" Tags="|arduino-uno|serial|usb|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18452" PostTypeId="2" ParentId="18450" CreationDate="2015-12-05T01:05:59.510" Score="3" Body="&lt;p&gt;The usb port and the tx/rx pins are one and the same thing. You can't use one thing for two jobs at the same time. So you will either have to implement some kind of multiplexing system (switches) or come up with a different way of doing things, maybe using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; library or the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire Library&lt;/a&gt; or investing in a better board with more than one serial port.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="186" LastEditDate="2015-12-06T12:14:09.833" LastActivityDate="2015-12-06T12:14:09.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18453" PostTypeId="1" CreationDate="2015-12-05T04:16:42.053" Score="2" ViewCount="605" Body="&lt;p&gt;I want to hook up an arduino to one of those generic RGB LED controllers, you see them everywhere, they are these little white boxes with power input and RGB strip plug and an IR LED lead. Is there a way to take to the IR + and - and connect them the arduino? Then spoof an IR signal to control the control module? I want to do it this way because I already own both the arduino and control module and that module handles the power for the LEDs. All I am hoping I have to do is send the controller the hex value for the IR command through the the arduino in order to control it. Here's a link to what the module looks like and the remote it comes &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00ASHQQKI&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/dp/B00ASHQQKI/ref=cm_sw_r_cp_awd_htMywb1W85962&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15369" LastActivityDate="2015-12-05T14:25:10.620" Title="How to interface with generic IR RGB LED controller?" Tags="|arduino-uno|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18454" PostTypeId="2" ParentId="18445" CreationDate="2015-12-05T04:35:49.980" Score="1" Body="&lt;p&gt;Please consider reading the &lt;a href=&quot;http://learn.adafruit.com/trinket-gemma-servo-control/wiring&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;https://learn.adafruit.com/trinket-gemma-servo-control/wiring&quot;&lt;/a&gt; tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It is suggested you use an external wall or battery supply and not&#xA;  power the servo via the regulator. servos can draw up to 500mA and the&#xA;  Trinket regulator can only source 150 milliamps (USB power generally&#xA;  500 milliamps).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No matter what power supply you hook to the &quot;Bat+&quot; battery pin, if you hook the servo power to the &quot;5V&quot; pin on the trinket, the trinket's on-board 5V regulator will temporarily collapse under the load of the servo, which typically causes the system to reset over and over again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, please hook the servo power directly to the battery.&#xA;Alas, a typical partially-drained 9V battery has enough internal resistance that the battery's voltage will temporarily collapse under the load of the servo, which typically causes the system to reset over and over again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, use a better power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people, even when they intend to eventually run their system on batteries, start out using a wall-wart power supply, so they don't have to keep wondering &quot;Is this glitch because of a bug in my software, or is the battery just going dead?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://learn.adafruit.com/16-channel-pwm-servo-driver/hooking-it-up&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Adafruit 16-Channel Servo Driver with Arduino&quot;&lt;/a&gt; tutorial says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Good power choices are:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/276&quot; rel=&quot;nofollow noreferrer&quot;&gt;5v 2A switching power supply&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/658&quot; rel=&quot;nofollow noreferrer&quot;&gt;5v 10A switching power supply&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&quot;http://www.adafruit.com/products/830&quot; rel=&quot;nofollow noreferrer&quot;&gt;4xAA Battery Holder&lt;/a&gt; - 6v with Alkaline cells.  4.8v with NiMH rechargeable cells.&lt;/li&gt;&#xA;  &lt;li&gt;4.8 or 6v Rechargeable RC battery packs from a hobby store.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You might also want to look at other &lt;a href=&quot;http://www.adafruit.com/category/135&quot; rel=&quot;nofollow noreferrer&quot;&gt;Battery holders&lt;/a&gt; that hold lots of AA batteries in a convenient package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related:&#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/73169/how-to-get-high-current-from-9-volt-batteries&quot;&gt;&quot;How to get high current from 9 volt batteries&quot;&lt;/a&gt;&#xA;and&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=132106.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;What is the max current I could draw from a 9V battery?&quot;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-05T04:35:49.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18456" PostTypeId="2" ParentId="18351" CreationDate="2015-12-05T08:40:01.193" Score="1" Body="&lt;p&gt;The compiler is giving a lot of information. The warnings can be ignored but the &quot;multiple libraries&quot; indicates that there is at least two copies of Firmata installed. Check (search) that you have not got several downloads of Firmata. Worst case reinstall to clean up that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-08T09:22:43.390" LastActivityDate="2015-12-08T09:22:43.390" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18458" PostTypeId="1" CreationDate="2015-12-05T10:17:07.723" Score="2" ViewCount="286" Body="&lt;p&gt;I am currently working on a project on serial communication between RPi and Arduino. This is the code that I am using from RPi side, it's in C: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int main()&#xA;{&#xA;   //-------------------------&#xA;   //----- SETUP USART 0 -----&#xA;   //-------------------------&#xA;   //At bootup, pins 8 and 10 are already set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively&#xA;   int Arduino= -1;&#xA;&#xA;   //OPEN THE UART&#xA;   //The flags (defined in fcntl.h):&#xA;   //   Access modes (use 1 of these):&#xA;   //       O_RDONLY - Open for reading only.&#xA;   //       O_RDWR - Open for reading and writing.&#xA;   //       O_WRONLY - Open for writing only.&#xA;   //&#xA;   //   O_NDELAY / O_NONBLOCK (same function) - Enables nonblocking mode. When set read requests on the file can return immediately with a failure status&#xA;   //                                           if there is no input immediately available (instead of blocking). Likewise, write requests can also return&#xA;   //                                           immediately with a failure status if the output can't be written immediately.&#xA;   //&#xA;   //   O_NOCTTY - When set and path identifies a terminal device, open() shall not cause the terminal device to become the controlling terminal for the process.&#xA;   Arduino = open(&quot;/dev/ttyAMA0&quot;, O_RDWR | O_NOCTTY | O_NDELAY);           //Open in non blocking read/write mode&#xA;   if (Arduino == -1)&#xA;   {&#xA;       //ERROR - CAN'T OPEN SERIAL PORT&#xA;       printf(&quot;Error - Unable to open UART.  Ensure it is not in use by another application\n&quot;);&#xA;   }&#xA;&#xA;   //CONFIGURE THE UART&#xA;   //The flags (defined in /usr/include/termios.h - see http://pubs.opengroup.org/onlinepubs/007908799/xsh/termios.h.html):&#xA;   //   Baud rate:- B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000, B2500000, B3000000, B3500000, B4000000&#xA;   //   CSIZE:- CS5, CS6, CS7, CS8&#xA;   //   CLOCAL - Ignore modem status lines&#xA;   //   CREAD - Enable receiver&#xA;   //   IGNPAR = Ignore characters with parity errors&#xA;   //   ICRNL - Map CR to NL on input (Use for ASCII comms where you want to auto correct end of line characters - don't use for bianry comms!)&#xA;   //   PARENB - Parity enable&#xA;   //   PARODD - Odd parity (else even)&#xA;   struct termios options;&#xA;   tcgetattr(Arduino, &amp;amp;options);&#xA;   options.c_cflag = B9600 | CS8 | CLOCAL | CREAD;      //&amp;lt;Set baud rate&#xA;   options.c_iflag = IGNPAR;&#xA;   options.c_oflag = 0;&#xA;   options.c_lflag = 0;&#xA;   tcflush(Arduino, TCIFLUSH);&#xA;   tcsetattr(Arduino, TCSANOW, &amp;amp;options);&#xA;&#xA;   //----- TX BYTES -----&#xA;   unsigned char tx_buffer[20];&#xA;   unsigned char *p_tx_buffer;&#xA;   int Angle=-20;&#xA;   int Speed=100;&#xA;&#xA;   int Botschaft=Fusion(Crypt(Angle),Crypt(Speed));&#xA;&#xA;   p_tx_buffer = &amp;amp;tx_buffer[0];&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,1)+'0';&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,2)+'0';&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,3)+'0';&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,4)+'0';&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,5)+'0';&#xA;   *p_tx_buffer++ = Decompositer(Botschaft,6)+'0';&#xA;&#xA;&#xA;   if (Arduino != -1)&#xA;   {&#xA;      int count = write(Arduino, &amp;amp;tx_buffer[0], (p_tx_buffer - &amp;amp;tx_buffer[0]));     //Filestream, bytes to write, number of bytes to write&#xA;      if (count &amp;lt; 0)&#xA;      {&#xA;        printf(&quot;UART TX error\n&quot;);&#xA;      }&#xA;   }&#xA;&#xA;//----- CHECK FOR ANY RX BYTES -----&#xA;   if (Arduino != -1)&#xA;   {&#xA;      // Read up to 255 characters from the port if they are there&#xA;      unsigned char rx_buffer[256];&#xA;      int rx_length = read(Arduino, (void*)rx_buffer, 255);     //Filestream, buffer to store in, number of bytes to read (max)&#xA;      if (rx_length &amp;lt; 0)&#xA;      {&#xA;        //An error occured (will occur if there are no bytes)&#xA;      }&#xA;      else if (rx_length == 0)&#xA;      {&#xA;        //No data waiting&#xA;      }&#xA;      else&#xA;      {&#xA;        //Bytes received&#xA;        rx_buffer[rx_length] = '\0';&#xA;        printf(&quot;%i bytes read : %s\n&quot;, rx_length, rx_buffer);&#xA;      }&#xA;   }&#xA;&#xA;   //----- CLOSE THE UART -----&#xA;   close(Arduino);&#xA;}&#xA;&#xA;int Fusion(int Angle, int Speed)&#xA;{&#xA;   int msg;&#xA;   msg=Angle*1000+Speed;&#xA;   return msg;&#xA;}&#xA;&#xA;int Decompositer(int Num,int Place)&#xA;{&#xA;   int Result[5];&#xA;&#xA;   Result[0]=Num/100000;&#xA;   Result[1]=(Num-Result[0]*100000)/10000;&#xA;   Result[2]=(Num-Result[0]*100000-Result[1]*10000)/1000;&#xA;   Result[3]=(Num-Result[0]*100000-Result[1]*10000-Result[2]*1000)/100;&#xA;   Result[4]=(Num-Result[0]*100000-Result[1]*10000-Result[2]*1000-Result[3]*100)/10;&#xA;   Result[5]=(Num-Result[0]*100000-Result[1]*10000-Result[2]*1000-Result[3]*100-Result[4]*10);&#xA;   return Result[Place-1];&#xA;}&#xA;&#xA;int Crypt(int Value)&#xA;{&#xA;   int result;&#xA;   result = Value + 100;&#xA;   return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is my code from the Arduino side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial2.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;    if (Serial2.available())&#xA;    {&#xA;        int inByte = Serial2.read();&#xA;        Serial.write(inByte);&#xA;    }&#xA;    if (Serial.available())&#xA;    {&#xA;        int inByte = Serial.read();&#xA;        Serial2.write(inByte);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My purpose is to send a 6 digit number to my Arduino side, and be able to read them and then separate them into 2 different numbers...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is I see only the first 2 digits and the rest are weird characters like &lt;code&gt;1‚þ&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really appreciate your help.&lt;/p&gt;&#xA;" OwnerUserId="11897" LastEditorUserId="6936" LastEditDate="2016-03-07T11:26:10.620" LastActivityDate="2016-03-07T11:26:10.620" Title="Serial Communication, Arduino and Rpi , C library" Tags="|serial|arduino-mega|c|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="18460" PostTypeId="2" ParentId="18169" CreationDate="2015-12-05T10:47:00.973" Score="0" Body="&lt;p&gt;It was a strange problem which we were not able to resolve in an acceptable manner after all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem disappeared after we re-flashed the device.&lt;/p&gt;&#xA;" OwnerUserId="15138" LastActivityDate="2015-12-05T10:47:00.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18462" PostTypeId="2" ParentId="18450" CreationDate="2015-12-05T12:50:26.867" Score="1" Body="&lt;p&gt;Low impedance circuits connected to the TX/RX pins would cause distortion in the serial signal and would interfere with communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A switch would help here. Alternately, you could use a Mega 2560 with more IOs, or if you are breadboarding it, use a 1284p chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use SoftwareSerial to communicate with the other Arduino on another set of pins.&lt;/p&gt;&#xA;" OwnerUserId="10219" LastActivityDate="2015-12-05T12:50:26.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18463" PostTypeId="2" ParentId="18383" CreationDate="2015-12-05T13:03:12.170" Score="0" Body="&lt;p&gt;You can use a relay shield like these:&#xA;&lt;a href=&quot;http://www.ebay.com/bhp/arduino-relay-shield&quot; rel=&quot;nofollow&quot;&gt;Relay Boards - eBay&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to check the amp draw of the relays. Sometimes you need a transistor, but I don't think you should for these shields. Just be careful working with mains voltage.&lt;/p&gt;&#xA;" OwnerUserId="10219" LastActivityDate="2015-12-05T13:03:12.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18464" PostTypeId="2" ParentId="18453" CreationDate="2015-12-05T14:25:10.620" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html&quot; rel=&quot;nofollow&quot;&gt;IRRemote Library&lt;/a&gt; is a good starting point, but you'll probably need a RAW mode.   I've got a couple IR controllers from different companies, and they use different codes for the same things. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-05T14:25:10.620" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18465" PostTypeId="1" CreationDate="2015-12-05T19:10:58.930" Score="1" ViewCount="1705" Body="&lt;p&gt;I currently have a project that is working on an AtMega2560 platform (heavily derived off the Arduino Mega). It mainly involves a GPS module and SD card. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going forward I am looking to add a few more sensors (IMU etc.). I would like to a more powerful microcontroller -- for the high rate logging I need and also it seems best from a future scalability perspective. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to start with using one of the ARM based uC platforms available out there, transition my software to it using a breadboard setup, and then eventually make a custom board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my QUESTION is: &#xA;Which would be an easier option from a migration/transition and community support point of view --- Teensy or Due? I currently use the SDFat and Adafruit GPS libraries, the SDFat being a major concern for migration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any other considerations/suggestions/advice will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6930" LastActivityDate="2015-12-06T11:29:03.280" Title="Migrating from ATMega2560 to ARM based -- Teensy vs Due?" Tags="|arduino-mega|arduino-due|library|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18466" PostTypeId="1" CreationDate="2015-12-05T19:53:41.800" Score="2" ViewCount="851" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/DeanIsMe/SevSeg&quot; rel=&quot;nofollow&quot;&gt;sevseg&lt;/a&gt; and i can't get more than 8 digits to work.  I really need 15.  Does somebody know what I can do to get this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shown is the original example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is using Gabriel Staples example in the sevseg library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;&#xA;SevSeg sevseg; //Instantiate a seven segment controller object&#xA;&#xA;void setup()&#xA;{&#xA;  byte numDigits = 4; //&amp;lt;&amp;lt;---I am wanting 15, but doesn't work after 8------   &#xA;  byte digitPins[] = {2, 3, 4, 5}; //Digits: 1,2,3,4 &amp;lt;--put one resistor (ex: 220 Ohms, or 330 Ohms, etc, on each digit pin)&#xA;  byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; //Segments: A,B,C,D,E,F,G,Period&#xA;&#xA;  sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);&#xA;// Note: 100 brightness simply corresponds to a delay of 2000us after lighting each segment. A brightness of 0 &#xA;// is a delay of 1us; it doesn't really affect brightness as much as it affects update rate (frequency).&#xA;// Therefore, for a 4-digit 7-segment + pd, COMMON_ANODE display, the max update rate for a &quot;brightness&quot; of 100 is 1/(2000us*8) = 62.5Hz.&#xA;// I am choosing a &quot;brightness&quot; of 10 because it increases the max update rate to approx. 1/(200us*8) = 625Hz.&#xA;// This is preferable, as it decreases aliasing when recording the display with a video camera....I think.&#xA;  sevseg.setBrightness(10); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //local vars&#xA;  static byte decPlace = 0;&#xA;&#xA;  sevseg.setNumber(8888,decPlace);&#xA;  decPlace++;&#xA;  decPlace %= 4; //rollover back to 0 once variable gets to 4; To anyone wondering: the % is called the &quot;modulo&quot; operator; see here for explanation &amp;amp; example: https://www.arduino.cc/en/Reference/Modulo&#xA;&#xA;  sevseg.refreshDisplay(); // Must run repeatedly; don't use blocking code (ex: delay()) in the loop() function or this won't work right&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the following code, I can't get the 3rd set of 5 numbers to display.  I have changed the sevseg.h file to 15, but that shouldn't matter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;&#xA;SevSeg sevseg1;//Instantiate a seven segment controller object 1&#xA;SevSeg sevseg2;//Instantiate a seven segment controller object 2&#xA;SevSeg sevseg3;//Instantiate a seven segment controller object 3&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;byte segmentPins[] = {22, 23, 24, 25, 26, 27, 28, 34}; //Segments:     A,B,C,D,E,F,G,Period&#xA;&#xA;  byte digitPins1[] = {29, 30, 31, 32, 33};&#xA;  sevseg1.begin(COMMON_CATHODE, sizeof(digitPins1), digitPins1,  segmentPins);&#xA;  sevseg1.setBrightness(10);&#xA;&#xA;  byte digitPins2[] = {35, 36, 37, 38, 39};&#xA;  sevseg2.begin(COMMON_CATHODE, sizeof(digitPins2), digitPins2, segmentPins);&#xA;  sevseg2.setBrightness(10);&#xA;&#xA;  byte digitPins3[] = {40, 41, 42, 43, 44};&#xA;  sevseg3.begin(COMMON_CATHODE, sizeof(digitPins2), digitPins3, segmentPins);&#xA;  sevseg3.setBrightness(10);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;&#xA;static byte decPlace = 2;&#xA;&#xA;  sevseg1.setNumber( 12345, decPlace );&#xA;  sevseg2.setNumber( 12345, decPlace );&#xA;  sevseg3.setNumber( 12345, decPlace );&#xA;&#xA;&#xA;  sevseg1.refreshDisplay();&#xA;  sevseg2.refreshDisplay();&#xA;  sevseg2.refreshDisplay();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15383" LastEditorUserId="15383" LastEditDate="2015-12-11T12:59:25.187" LastActivityDate="2015-12-11T13:54:58.563" Title="Using more than 8 digits using the sevseg library" Tags="|arduino-mega|display|ui|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18467" PostTypeId="2" ParentId="18466" CreationDate="2015-12-05T21:05:04.727" Score="5" Body="&lt;p&gt;You can change the pre-defined maximum number of digits at the top of the &lt;code&gt;SevSeg.h&lt;/code&gt; header file to as many as 10, if you use &lt;code&gt;long&lt;/code&gt; or &lt;code&gt;unsigned long&lt;/code&gt; when you call &lt;code&gt;setNumber&lt;/code&gt;.  It is defined &lt;a href=&quot;https://github.com/DeanIsMe/SevSeg/blob/master/SevSeg.h#L27&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, on line 27:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAXNUMDIGITS 8 //Increase this number to support larger displays&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This the version referenced from the &lt;a href=&quot;http://playground.arduino.cc/Main/SevenSegmentLibrary&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Playground SevSeg&lt;/a&gt;.  Be sure to use the same number in your modulo, too:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  //local vars&#xA;  static byte decPlace = 0;&#xA;&#xA;  sevseg.setNumber(8888,decPlace);&#xA;  decPlace++;&#xA;  decPlace %= 10; //rollover back to 0 once variable gets to 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;decPlaces&lt;/code&gt; is mostly useful for floating-point numbers: it specifies how many digits after the decimal point should be displayed.  For integer values, it specifies how many leading zeroes will be displayed.&lt;/p&gt;&#xA;&lt;p&gt;However (as you discovered), you cannot call &lt;code&gt;setNumber&lt;/code&gt; with anything larger than a &lt;code&gt;long&lt;/code&gt;, so you are limited to 10 or fewer digits for &lt;code&gt;MAXNUMDIGITS&lt;/code&gt;.  (There is no byte overflow -- it's just limited to the number of decimal digits in 2&lt;sup&gt;32&lt;/sup&gt;-1.)  This is a limit of one SevSeg instance.  You could have &lt;em&gt;two&lt;/em&gt; instances of &lt;code&gt;SevSeg&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;SevSeg sevseg1;&#xA;SevSeg sevseg2;&#xA;&#xA;void setup() &#xA;{&#xA;  byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; //Segments: A,B,C,D,E,F,G,Period&#xA;&#xA;  byte digitPins1[] = {2, 3, 4, 5, 22, 23, 24};&#xA;  sevseg1.begin(COMMON_ANODE, sizeof(digitPins1), digitPins1, segmentPins);&#xA;  sevseg1.setBrightness(10);&#xA;  &#xA;  byte digitPins2[] = {14,15,16,17,18,19,20,21};&#xA;  sevseg2.begin(COMMON_ANODE, sizeof(digitPins2), digitPins2, segmentPins);&#xA;  sevseg2.setBrightness(10);&#xA;  &#xA;  sevseg1.setNumber(  7654321UL, 7 );&#xA;  sevseg2.setNumber( 87654321UL, 8 );&#xA;}&#xA;&#xA;void loop() &#xA;{ &#xA;  sevseg1.refreshDisplay();&#xA;  sevseg2.refreshDisplay();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first instance handles 7 digits, and the second instances handles 8 digits.  Note the use of &amp;quot;UL&amp;quot; to force and &lt;code&gt;unsigned long&lt;/code&gt; call.&lt;/p&gt;&#xA;&lt;h2&gt;Update 11-DEC-2015&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Using the following code, I can't get the 3rd set of 5 numbers to display. I have changed the sevseg.h file to 15, but that shouldn't matter:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;First, the &lt;code&gt;MAXNUMDIGITS&lt;/code&gt; is the maximum &lt;em&gt;per instance&lt;/em&gt;, so you could set it to &lt;strong&gt;5&lt;/strong&gt; to save some precious RAM.&lt;/p&gt;&#xA;&lt;p&gt;Second, you have a copy and paste error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sevseg1.refreshDisplay();&#xA;sevseg2.refreshDisplay();&#xA;sevseg2.refreshDisplay();   &amp;lt;--  Oopsies!  :)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Third, I assume the &lt;code&gt;setNumber&lt;/code&gt; calls are placeholders for what you're really going to use.  Since they always set the same value, they could be in &lt;code&gt;setup&lt;/code&gt;.  In your final program, there must be some input that will be used to calculate a number to display with &lt;code&gt;setNumber&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-11T13:54:58.563" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18468" PostTypeId="2" ParentId="18466" CreationDate="2015-12-05T21:10:07.173" Score="1" Body="&lt;p&gt;Looking at the &lt;a href=&quot;https://github.com/DeanIsMe/SevSeg&quot; rel=&quot;nofollow&quot;&gt;sevseg README file on GitHub&lt;/a&gt; I find this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you wish to use more than 8 digits, increase MAXNUMDIGITS in SevSeg.h.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Have you done that? Seems like that might be the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @slash-dev said, be sure to also modify the &lt;code&gt;loop()&lt;/code&gt; code as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  //local vars&#xA;  static byte decPlace = 0;&#xA;&#xA;  sevseg.setNumber(8888,decPlace);&#xA;  decPlace++;&#xA;  decPlace %= numDigits;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think it makes more sense to use &lt;code&gt;numDigits&lt;/code&gt; rather than a hard coded constant that you have to remember to change whenever you change the number of digits in your display. It would be worth checking the code for any other hard coded constants. If space is an issue, it might be worth checking to see if using a &lt;code&gt;#define&lt;/code&gt; results in smaller code than using a variable – in any case do something to avoid needing to understand what &quot;magic numbers&quot; are doing. This is especially important when the same numeric value (e.g., 4) is being used for multiple reasons. Then it gets hard if you need to change the value as you have to understand the purpose behind each use.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-05T21:21:46.523" LastActivityDate="2015-12-05T21:21:46.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18469" PostTypeId="2" ParentId="18417" CreationDate="2015-12-05T21:30:20.760" Score="2" Body="&lt;p&gt;The problem was indeed a question of voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using the battery to supply 5 volts to the DC power port, which as suggested by the comments needs 7 volts or more. The problem is fixed by using the battery, which supplies a stable 5V, to give power to the USB port (or, presumably the 5V pin, though that is not available in my application).&lt;/p&gt;&#xA;" OwnerUserId="15385" LastActivityDate="2015-12-05T21:30:20.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18470" PostTypeId="2" ParentId="9663" CreationDate="2015-12-06T02:39:25.733" Score="2" Body="&lt;p&gt;In the &lt;a href=&quot;https://www.sparkfun.com/products/12574#comment-532f2a48ce395fee4f8b4567&quot; rel=&quot;nofollow noreferrer&quot;&gt;comments on SparkFun's product page for RN-42&lt;/a&gt;, gskelly indicates there is a flag in the v6.15 firmware that allows you to switch back and forth easily:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Actually, since this includes the v6.15 firmware, you don’t need to&#xA;  re-flash the module to switch between HID and SPP. It can now be done&#xA;  using AT commands as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S~,6    // Enable HID on reboot&#xA;R,1     // Reboot&#xA;S~,0    // Enable SPP on reboot&#xA;R,1     // Reboot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15388" LastEditorUserId="33229" LastEditDate="2017-04-28T15:43:11.477" LastActivityDate="2017-04-28T15:43:11.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18471" PostTypeId="1" CreationDate="2015-12-06T06:07:12.927" Score="0" ViewCount="50" Body="&lt;p&gt;I'm making a &lt;strong&gt;speedometer using arduino&lt;/strong&gt;. I've made use of the interrupt pins to achieve the same. My problem is with the power source. I'm using a 12 V battery supply to power the arduino and I'm also &lt;strong&gt;using the same battery to use a horn&lt;/strong&gt;. But, whenever I push the button to sound the horn, the IR sensor connected to the arduino is getting activated and I'm getting an &lt;strong&gt;erroneous reading.&lt;/strong&gt; The only common thing between the arduino and the horn is the battery supply.&lt;/p&gt;&#xA;" OwnerUserId="10900" LastActivityDate="2015-12-06T07:09:21.653" Title="Erroneous sensor reading while connecting extra load" Tags="|arduino-uno|sensors|power|interrupt|battery|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18472" PostTypeId="2" ParentId="18471" CreationDate="2015-12-06T07:09:21.653" Score="1" Body="&lt;p&gt;If the horn has a speaker coil or other magnetic actuator in it, then it will present an inductive load that may cause a voltage spike when you turn it off.  Or, if it's a buzzer, it may generate voltage spikes all during its operation.  Voltage spikes or other electrical noise are the most likely cause of the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also is possible that the horn draws enough current to drop your battery voltage so low that the Arduino or the sensors don't function reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To find out which is the problem, take voltage readings with and without the horn in operation.  If you have an oscilloscope, look for spikes on system power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try isolating and/or buffering the Arduino's power.  If power glitches are the problem, that should fix the problem.  If the problem is electromagnetically radiated electrical noise, further isolation (eg shielding) may be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To isolate the Arduino's power, either operate it from another battery (which is something you can do anyway, while diagnosing the problem) or add one diode into the Arduino's power lead and another into the horn's.  Connect an electrolytic capacitor, eg 100 to 1000 μF, from the Arduino's +V input to ground.  If necessary add ferrite beads around the power leads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A capacitor across 12 V from the battery will buffer the power, but for more isolation and buffering you can add a buck converter which can manufacture eg +7V from a +12V input while remaining relatively impervious to spikes on the +12V.  Put the large electrolytic across the +7V if you use a buck converter.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-06T07:09:21.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18473" PostTypeId="1" CreationDate="2015-12-06T09:00:54.387" Score="0" ViewCount="390" Body="&lt;p&gt;I am planning to buy a low cost and low weight laptop with an Atom Processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I only have cloned Arduinos - will the Arduino drivers and IDE work on laptops which come with Atom Processors?&lt;/p&gt;&#xA;" OwnerUserId="10694" LastEditorUserId="6936" LastEditDate="2016-01-04T19:41:33.580" LastActivityDate="2016-01-04T19:41:33.580" Title="Will Intel Atom Processor laptops support cloned a Arduino with CH340 driver?" Tags="|arduino-ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18474" PostTypeId="2" ParentId="18473" CreationDate="2015-12-06T10:28:28.493" Score="1" Body="&lt;p&gt;The processor in your laptop is irrelevant. It is the operating system you should be thinking about, not the processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the operating system has drivers for the CH340 chip, and Windows does, as you already know since you are using it already, then you already know that the answer is a big fat yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only time you need to worry about if the processor will support something is when you are switching to a completely different archetecture such as ARM.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-06T10:37:08.127" LastActivityDate="2015-12-06T10:37:08.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18475" PostTypeId="2" ParentId="18465" CreationDate="2015-12-06T11:29:03.280" Score="1" Body="&lt;p&gt;If compatability is what you are after I would say go for the Due. If good products are what you are after, go for the Teeensy. The Due, being a real Arduino, will have the best software support and forum community and thus the best chance of getting existing libraries to work with it. The Teensy, because the project really centers around one guy's brilliance, is highly dependant on that one person's time, and while he has done a stirling job with the Teeensy core, he is still only one guy and can only do so much. So it may be harder to get third party libraries working on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, the Due is not a nice board. The SAM3X chips are awful. Any chip that needs an erase button attached to it to get around the &quot;possibility it won't be able to enter the bootloader&quot; (which incidentally is hard coded in ROM and can NEVER be replaced or upgraded) is destined for the scrap heap IMHO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are of course other options as well. There are about a million and one ARM based Arduino-like boards out there with varying amounts of support, either from the chip manufacturer (such as the ST boards), or third party builders. Then of course there are other architectures that are in my biased opinion much better than the ARM ones - chips such as the MIPS based PIC32, used in the chipKIT family of boards. Those latter though don't yet have a port of the SdFat library yet, although it is something that is being actively worked on. There are even Sparc based boards out there that are worth a look.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-06T11:29:03.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18477" PostTypeId="1" AcceptedAnswerId="40330" CreationDate="2015-12-06T14:48:35.513" Score="1" ViewCount="169" Body="&lt;p&gt;So I purchased a 4 channel Relay which handles AC250V 10A ; DC30V 10A.&#xA;But am I able to connect this to replace a light switch so I can automate it?  My bedroom runs on 15 amps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8rZDF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8rZDF.jpg&quot; alt=&quot;relay board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00VHVIBAM&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://amazon.com/gp/product/B00VHVIBAM?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o00_s00&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14716" LastEditorUserId="19409" LastEditDate="2017-07-06T12:58:21.923" LastActivityDate="2017-07-06T14:59:35.317" Title="Relay to Mains lightswitch" Tags="|relay|" AnswerCount="1" CommentCount="4" ClosedDate="2017-07-06T19:52:40.540" ContentLicense="CC BY-SA 3.0" />
  <row Id="18478" PostTypeId="1" AcceptedAnswerId="18479" CreationDate="2015-12-06T15:28:00.020" Score="0" ViewCount="86" Body="&lt;p&gt;I'm new to Arduino and today I have a problem with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led_1 = 10;&#xA;int led_2 = 11;&#xA;int led_3 = 12;&#xA;int button = 3;&#xA;int time = 0;&#xA;byte val = 0;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pinMode(led_1, OUTPUT);&#xA;  pinMode(led_2, OUTPUT);&#xA;  pinMode(led_3, OUTPUT);&#xA;  pinMode(button, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  val = digitalRead(button);&#xA;&#xA;  if (val == HIGH){&#xA;    time = millis();&#xA;    while (digitalRead(button) == HIGH) {&#xA;      if (millis() - time &amp;lt; 1000) {digitalWrite(led_1, HIGH);}&#xA;      else if (millis() -time &amp;gt; 1000 &amp;amp;&amp;amp; millis()-time &amp;lt;2000) {digitalWrite(led_2, HIGH);}&#xA;      else if (millis()-time &amp;gt;2000) {digitalWrite(led_3, HIGH);}&#xA;    }&#xA;  } else { &#xA;    time =0;&#xA;    digitalWrite(led_1, LOW);&#xA;    digitalWrite(led_2, LOW);&#xA;    digitalWrite(led_3, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code should work like this: If I press the button less than one second, &lt;code&gt;led_1&lt;/code&gt; will turn on. If I press it between one and two seconds, &lt;code&gt;led_2&lt;/code&gt; will turn on; and if I press the button more than 2 seconds, &lt;code&gt;led_3&lt;/code&gt; will turn on. If I don't press a button, the LEDs remain off. The &lt;code&gt;time&lt;/code&gt; variable is used to take the time when I start to press the button and then the control &lt;code&gt;millis()- time&lt;/code&gt; should give how long I press the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works for a while, then after a random time (I think) if I push the button, only the &lt;code&gt;led_3&lt;/code&gt; turns on. Why?&lt;/p&gt;&#xA;" OwnerUserId="11976" LastEditorUserId="10907" LastEditDate="2015-12-10T15:29:58.380" LastActivityDate="2015-12-10T15:29:58.380" Title="Issue with simple project" Tags="|arduino-uno|led|time|millis|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18479" PostTypeId="2" ParentId="18478" CreationDate="2015-12-06T16:29:06.897" Score="2" Body="&lt;p&gt;&lt;code&gt;time&lt;/code&gt; should be an &lt;code&gt;unsigned int&lt;/code&gt;.  As soon as &lt;code&gt;millis&lt;/code&gt; reaches 32768, it will be stored as -32768 in &lt;code&gt;time&lt;/code&gt;, and your comparisons will not work. This happens after 32.768 seconds.  Here's a short sketch to illustrate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int time = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin( 9600 );&#xA;}&#xA;&#xA;void loop() {&#xA;    time = millis();&#xA;    if (time % 1000 == 0) {&#xA;      Serial.println( time );&#xA;      delay( 2 ); // let millis() increment&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To see the difference, just change the first line to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int time = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note how &lt;code&gt;time&lt;/code&gt; rolls over to 0 after 65535 (well, only 65000 is printed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend using unsigned constants by adding a &quot;U&quot; after the digits: &lt;code&gt;1000U&lt;/code&gt;.  In your &lt;code&gt;if&lt;/code&gt; statements, you must cast the &lt;code&gt;millis&lt;/code&gt; to the same (smaller) type: &lt;code&gt;(unsigned int)millis()&lt;/code&gt;.  Also, parentheses make the expression more clear:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      else if (((unsigned int)millis() - time &amp;gt; 1000U) &amp;amp;&amp;amp; ((unsigned int)millis() - tempo &amp;lt; 2000U)) {digitalWrite(led_2, HIGH);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2015-12-06T16:56:19.570" LastActivityDate="2015-12-06T16:56:19.570" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18480" PostTypeId="2" ParentId="18478" CreationDate="2015-12-06T16:29:14.627" Score="2" Body="&lt;p&gt;Your code seems inefficient and there is a &lt;code&gt;tempo&lt;/code&gt; variable that doesn't appear elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (val == HIGH) {&#xA;    time = millis();&#xA;    while (digitalRead(button) == HIGH) {&#xA;      int time0=millis();&#xA;      if (time0 - time &amp;lt; 1000) {&#xA;        digitalWrite(led_1, HIGH);&#xA;      } else if (time0 - time &amp;lt; 2000) {&#xA;        digitalWrite(led_2, HIGH);&#xA;      } else if (time0 - time &amp;gt; 2000) {&#xA;        digitalWrite(led_3, HIGH);&#xA;      }&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this code will turn on all LEDs, one by one. If you want to turn off the other, you'll have to had code for that in the tests.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-12-06T16:29:14.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18481" PostTypeId="1" CreationDate="2015-12-06T17:18:50.613" Score="2" ViewCount="88" Body="&lt;p&gt;I'm completely new to using modules for the Arduino, so I'm sure some people have more knowledge about this topic than me.&#xA;Here's the thing, I want to stream audio over my home wifi, so I'm in need of some rather high-speed modules, I'm aiming for 1-1.5 mbps for some proper compressed audio, including the overhead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked online for some well known wifi modules, but the only one I've managed to find that is popular is the esp8266, and that thing is definitely not for streaming anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before anyone asks, yes, it is critical for it to work over wifi.&#xA;Has anyone done something like this? What gets the best results?&lt;/p&gt;&#xA;" OwnerUserId="15396" LastEditorUserId="10907" LastEditDate="2015-12-16T10:46:27.247" LastActivityDate="2015-12-16T10:46:27.247" Title="Looking for help with WiFi modules" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18482" PostTypeId="2" ParentId="18481" CreationDate="2015-12-06T17:23:01.723" Score="1" Body="&lt;p&gt;I cant comment so I'm going to post as an answer.  Arduino is most likely not capable of running any sort of audio unless you have an mp3 shield to support it.  As far as the wifi module, I suggest using Ethernet shield as that will run a lot better compared to wifi module.&lt;/p&gt;&#xA;" OwnerUserId="14716" LastActivityDate="2015-12-06T17:23:01.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18484" PostTypeId="2" ParentId="17099" CreationDate="2015-12-06T20:57:26.803" Score="0" Body="&lt;p&gt;When I recieved my first ESP I struggled for weeks trying to get it working. First, the voltage divider is a good thing for its longevity but I got it working without it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next about baudrate, mine sent some data at startup on 76800 baud then would work on 9600 baud. You might want to check that out for the garbage you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, it might be related to a power draw problem. The ESP has 400mA peaks, this is high for an Arduino and even for a 3.3v USB serial programmer. I had to use a 1A breadboard power supply to actually get it to work. Before buying anything you should try putting a big (220µF or more) capacitor in parallel on the 3.3V power.&lt;/p&gt;&#xA;" OwnerUserId="15395" LastActivityDate="2015-12-06T20:57:26.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18485" PostTypeId="1" AcceptedAnswerId="18495" CreationDate="2015-12-06T20:57:52.733" Score="0" ViewCount="448" Body="&lt;p&gt;I am from a mobile development background and very new to Arduino. I am trying to make an electronic cricket score board. The logic is simple. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Score - 888 (3 Digits)&lt;/strong&gt; - I have implemented this logic using shift registers.  Three pin used from Arduino Uno and this is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Overs - 88 (2 Digits)&lt;/strong&gt; - Need to find a best way to implement it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wickets - 8 (1 Digit)&lt;/strong&gt; - Need to find a best way to implement it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I need to add Wickets and Overs to the logic. I think there are two ways to do it. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;One is passing data from Score shift registers. I think this way is a bit complicated in logic level. But if this is a good way, then great.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The other is, connect to Arduino Uno pins directly rather than getting information from score shift registers.  There are only few pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Please Note: I need to print this design in PCB&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be a basic question. But I would like to the know which way is efficient, and its advantages. If both are not, I would like to the know the best one.&lt;/p&gt;&#xA;" OwnerUserId="12140" LastEditorUserId="12140" LastEditDate="2015-12-07T09:16:00.593" LastActivityDate="2015-12-07T09:41:22.517" Title="Best way to implement score board logic using Arduino and Shift Registers?" Tags="|arduino-uno|serial|shift-register|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18486" PostTypeId="2" ParentId="18485" CreationDate="2015-12-06T22:07:25.483" Score="0" Body="&lt;p&gt;You could use a 16x2 LCD to display the information; then you wouldn't need so many separate lines from the Arduino, the PCB would be simple and compact, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you need a big high-power display that is not multiplexed, you could use one 74HC595 per digit, assigning one bit per segment with 7-segment LED displays, with a driver transistor on each output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The six '595s would be in series, which would use only two output lines from the Arduino: clock and data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to build your display from 84 or 126 WS2811 or WS2812B LEDs (2 or 3 per segment, and 7 segments times 6 digits).  About $10 to $15 on Ebay.  This would use one data pin from the Arduino to drive the whole display and would supply bright RGB light. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-12-06T22:13:05.633" LastActivityDate="2015-12-06T22:13:05.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18487" PostTypeId="1" AcceptedAnswerId="18501" CreationDate="2015-12-07T01:39:36.663" Score="-1" ViewCount="183" Body="&lt;p&gt;I recently bought the LinkSprite color jpeg camera:&#xA;&lt;a href=&quot;https://www.sparkfun.com/products/12804&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12804&lt;/a&gt;&#xA;And the Arduino Wireless SD Shield:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWirelessShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoWirelessShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering how to connect the camera to the Arduino and how to have it take and save a picture to the sd card when a button is pressed.&lt;/p&gt;&#xA;" OwnerUserId="15407" LastEditorUserId="9962" LastEditDate="2016-02-23T14:02:22.607" LastActivityDate="2016-02-23T14:02:22.607" Title="Connecting and Programming LinkSprite Camera to Arduino" Tags="|arduino-uno|shields|sd-card|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18488" PostTypeId="2" ParentId="4434" CreationDate="2015-12-07T02:28:57.213" Score="1" Body="&lt;p&gt;This is an old post, but for future people:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield may have not been switched on — it has its own power button, which is right next to the SIM card. It's tiny, but it's there.&lt;/p&gt;&#xA;" OwnerUserId="15408" LastEditorUserId="6936" LastEditDate="2016-01-04T19:39:51.843" LastActivityDate="2016-01-04T19:39:51.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18489" PostTypeId="1" CreationDate="2015-12-06T23:31:18.450" Score="0" ViewCount="224" Body="&lt;p&gt;Can anyone assist me with read/write to a SD shield. I am using a arduino along with a SD shield (POD  uSD) I am using a ultrasonic sensor to measure a distance, it has a safety factor in it. It also measures the time a measurement was taken, I now need to save the data from the serial monitor to a file and send that file to a SD card. I cannot seem to solve the saving a file part along with the SD shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have wrote my code but can seem to implement the shield along with my code, I want to store my data onto a file on the SD card. I've reviewed the example provided in the library's but it won't work for me&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define redled 10&#xA;#define greenled 11&#xA;#define echoPin 12&#xA;#define trigPin 13&#xA;&#xA;unsigned long interval=60000; //interval = 60 seconds&#xA;unsigned long previoustime=0;&#xA;int minutes = 0; //global variables&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600); //Set Baud rate to 9600 to match serial monitor&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(greenled, OUTPUT);&#xA;  pinMode(redled, OUTPUT);&#xA;}&#xA;&#xA;void loop() { &#xA; //----------------------------------------------------------- &#xA;  unsigned long currenttime = millis(); //counts time in milliseconds and puts it into current time&#xA;  if ((currenttime-previoustime) &amp;gt;= interval) { //When time is greater 60 seconds&#xA;    previoustime = currenttime; //Make the previous time equalled to the minute to take away in the next if statement        **Time since start section**&#xA;    minutes = minutes + 1; //Add 1 minute&#xA;  }&#xA;  unsigned long time = (currenttime-previoustime) / 1000; //converts the milliseconds to seconds&#xA;  //-----------------------------------------------------------&#xA;  long distance = ultra_sensor(); //call function that now returns the distance&#xA;  //-----------------------------------------------------------&#xA;  if (distance &amp;lt; 4) {            // If distance is less than 4cm&#xA;    digitalWrite(redled,HIGH);   // Turn on Red LED&#xA;    digitalWrite(greenled,LOW);  // Turn off Green LED&#xA;  }&#xA;  else {                          //If distance is greater than 4cm&#xA;    digitalWrite(redled,LOW);     // Turn off Red LED&#xA;    digitalWrite(greenled,HIGH);  // Turn on Green LED&#xA;  }&#xA;  //----------------------------------------------------------- &#xA;  if (distance &amp;gt;= 200 || distance &amp;lt;= 0){&#xA;    Serial.println(&quot;Out of range&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.print(distance);&#xA;    Serial.print(&quot;cm&quot;);&#xA;    Serial.print(&quot; after &quot;);&#xA;    Serial.print(minutes);              //Printing distance and time to serial monitor&#xA;    Serial.print(&quot; minutes &quot;);&#xA;    Serial.print(&quot;and &quot;);  &#xA;    Serial.print(time);&#xA;    Serial.println(&quot; seconds&quot;);&#xA;  }&#xA;  //-----------------------------------------------------------&#xA;  delay(2000); //Get reading every 2 seconds&#xA;}&#xA;&#xA;&#xA;&#xA;long ultra_sensor() { //Ultrasonic sensor reading is now a function. More efficient&#xA;  digitalWrite(trigPin, LOW);  //Set Trigger to idle&#xA;  delayMicroseconds(2); //Wait 2 microseconds&#xA;  digitalWrite(trigPin, HIGH); //Set Trigger to high which sends out a wave&#xA;  delayMicroseconds(10); //Send the wave for 10 microseconds&#xA;  digitalWrite(trigPin, LOW); //Turn the trigger to idle&#xA;  long duration = pulseIn(echoPin, HIGH); //make duration the wave that echo recieves back&#xA;  long dis = (duration/2) / 29.1; //divide by 2 for going there and back.                         ***Speed of sound***&#xA;  return dis; //Send the distance to function call&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15090" OwnerDisplayName="ArduinoRookie" LastEditorUserId="4131" LastEditDate="2015-12-10T15:28:01.230" LastActivityDate="2015-12-10T15:28:01.230" Title="arduino SD card saving to file" Tags="|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18491" PostTypeId="1" CreationDate="2015-12-07T04:44:59.130" Score="1" ViewCount="717" Body="&lt;p&gt;here is what I got:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;teensy++ 2.0 with code below&lt;/li&gt;&#xA;&lt;li&gt;Glediator configured for Glediator_Protocol/Single_Pixels/HL_TL/RGB/B_1000000&lt;/li&gt;&#xA;&lt;li&gt;led matrix with the PL9823 leds (80 of them)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I first off have to set the code to 160 on the teensy just to get it to                     at least make the leds change. even when i have it set to that OR the 80 leds, it does not show what is on screen (see video below). I have no clue what to try next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;FastLED.h&quot;&#xA;#define NUM_LEDS 160&#xA;const int dataline = PIN_B4;&#xA;CRGB leds[NUM_LEDS];&#xA;&#xA;void setup() &#xA;{&#xA;    digitalWrite(6,LOW);&#xA;    Serial.begin(1000000); &#xA;    LEDS.addLeds&amp;lt;WS2812B, dataline&amp;gt;(leds, NUM_LEDS);&#xA;    for (int p=0;p&amp;lt; NUM_LEDS;p++)&#xA;    {&#xA;        leds[p] = CRGB::Black;  &#xA;        FastLED.show();&#xA;    }&#xA;}&#xA;&#xA;int serialReadBlocking() &#xA;{&#xA;    while (!Serial.available()) &#xA;    {&#xA;    }&#xA;    return Serial.read(); &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    while (serialReadBlocking() != 1) &#xA;    {&#xA;    } &#xA;    for (long i=0; i &amp;lt; NUM_LEDS; i++) &#xA;    {&#xA;        leds[i].r = serialReadBlocking();&#xA;        leds[i].g = serialReadBlocking();&#xA;        leds[i].b = serialReadBlocking();&#xA;    }&#xA;    FastLED.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=H6OuMWKtbmo&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=H6OuMWKtbmo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10993" LastActivityDate="2015-12-07T10:19:08.260" Title="glediator + PL9823 (WS2812B) + teensy = fail?" Tags="|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18492" PostTypeId="1" CreationDate="2015-12-07T08:06:52.613" Score="2" ViewCount="1469" Body="&lt;p&gt;Scenario: I would like to monitor my closet's door as I highly suspect a family member is opening and using my items without permission. To respect privacy and also because my closet is nowhere near a power mains, I don't need video nor audio recording. I also do not need indicator lights etc because I intend to turn it on when I go to work and check the logs on the SD card when I return home. A typical day would require the device to run for 12 hours minimally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aim: Is it possible for Arduino to achieve the following,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Run on batteries for at least 1 month&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Detect motion&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Logging the detection motion onto a text file in a SD card&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Or do I have to look elsewhere for this functionality?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current understanding: I am aware Arduino can run on batteries though I've never been able to get it to last more than 3 hours. Probably has to do with me not using the low power mode or something and that my batteries were being stepped up. I also know that Arduino has some PIR motion sensors though I don't quite remember how power hungry these sensors are. I have NEVER tried logging onto an SD card using Arduino. This sums up my experience with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any advice would be much appreciated. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15413" LastActivityDate="2015-12-09T04:11:55.437" Title="Low power + Logging motion detection" Tags="|sensors|power|sd-card|datalogging|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18493" PostTypeId="2" ParentId="18492" CreationDate="2015-12-07T09:30:48.280" Score="1" Body="&lt;p&gt;It is possible to modify an Arduino Pro Mini (clone or original) to less than 1 mA and give at least a month on standard batteries (1000 mAh). Basically you need to remove the Power indicator LED and use low power mode in the sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could start simple by just lighting a LED when motion is detected and add the SD log later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several techniques to detect motion. Advanced accelerometers such as &lt;a href=&quot;http://www.analog.com/en/products/mems/mems-accelerometers/adxl345.html&quot; rel=&quot;nofollow&quot;&gt;ADXL345&lt;/a&gt; but also simple &lt;a href=&quot;http://www.interlogix.com/intrusion/category/wired-sensing&quot; rel=&quot;nofollow&quot;&gt;wire sensing&lt;/a&gt;. The standby power requirements for these have a large variation. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-07T09:30:48.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18494" PostTypeId="2" ParentId="18286" CreationDate="2015-12-07T09:40:00.497" Score="0" Body="&lt;p&gt;The other answers you have here cover the points well, just to offer my $0.02.&lt;/p&gt;&#xA;&lt;h1&gt;Using a wall adapter&lt;/h1&gt;&#xA;&lt;p&gt;It's really not necessary to use a separate wall adapter and you'd be adding another layer of complexity unnecessarily. So don't bother. Also with a wall adapter you would have to consider grounding it to the computer's power supply, not necessarily an issue, but not required if you use internal power.&lt;/p&gt;&#xA;&lt;h1&gt;Powering your LEDs&lt;/h1&gt;&#xA;&lt;p&gt;your computers power supply is more than capable of handling EVERYTHING you've mentioned (unless you're already maxing it out, which I doubt).&lt;/p&gt;&#xA;&lt;p&gt;Just make sure that you're powering the LEDs directly from the computer's power supply, and not from the (arduino) board itself, since that 5v is limited to 500mA from the USB connector, and definitely don't drive the main power from a data pin (I'm sure you know that—but just in case :P)&lt;/p&gt;&#xA;&lt;p&gt;If you do split the strip (running two strips shouldn't be a problem) be sure to provide power where ever you can, ie each end, even in the middle. It will aid in providing even power throughout the strip.&lt;/p&gt;&#xA;&lt;h1&gt;Powering the Arduino&lt;/h1&gt;&#xA;&lt;p&gt;I'd be running the Arduino off it as well, either grab a header cable off the board that has an end you could plug into your arduino and mount it inside, or feed a USB cable through the back and use one of the extra external USB ports. A bonus of running it outside would be you could physically reset the board by unplugging it :) or simply turning it off by doing the same.&lt;/p&gt;&#xA;" OwnerUserId="304" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-07T09:40:00.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18495" PostTypeId="2" ParentId="18485" CreationDate="2015-12-07T09:41:22.517" Score="2" Body="&lt;p&gt;There isn't really a &lt;em&gt;best&lt;/em&gt; way (and such questions are usually discouraged as they can easily descend into argument).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I would go for chaining all of the '595s together so you only ever use the 3 pins; it gives you the opportunity to use a smaller MCU like the ATtiny when you put it all on a board later which makes it (slightly) cheaper and (potentially) smaller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a software point of view, it doesn't make a huge amount of difference - doing it the way I have suggested means you send the 3 values out in the correct order every time one of them updates. Separating the 3 scores with their own dedicated pins means juggling which one needs to be updated each time. Neither option is particularly complicated and with this sort of application efficiency of code is mostly redundant because the entire MCU is dedicated to the (simple) task.&lt;/p&gt;&#xA;" OwnerUserId="15415" LastActivityDate="2015-12-07T09:41:22.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18496" PostTypeId="2" ParentId="18489" CreationDate="2015-12-07T09:44:05.517" Score="1" Body="&lt;p&gt;Looks like your sketch (pin usage) is in conflict with the SD shield (SPI pins). Try using other pins. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-07T09:44:05.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18497" PostTypeId="2" ParentId="18491" CreationDate="2015-12-07T10:19:08.260" Score="1" Body="&lt;p&gt;G'day Guy, What you're building there looks nice. Do you have a circuit diagram you can share? Regarding the code, I've never played with &lt;code&gt;FastLED.h&lt;/code&gt; but is the &lt;code&gt;serialReadBlocking&lt;/code&gt; how it deals with the input data? Not that it's wrong, just not what I was expecting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things to look at:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Your serial baud rate is a bit odd, 1 million neat. Is that intended? I wouldn't think so. Most common is 9600, I have run projects at 19,200 for giggles, but I doubt that you have it correct there.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I see your project you are using multi coloured LEDs with 3+1 pins which in actual fact means you have 240 LEDs (are the last 80 segments/colours all lighting?). If your PC sending the serial stream is expecting 80x single colour LEDs (80 individual LEDS) but you've got 80x tri-colour LEDs (80x3=240 LEDs) you probably aren't lighting them all up. (I only mention this point because I noticed your PC appeared to be sending only one colour, but that could have just been the moment I saw in the video). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;edit: I meant to include this link for the teensy serial baud rate info: &lt;a href=&quot;https://www.pjrc.com/teensy/td_uart.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_uart.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2015-12-07T10:19:08.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18498" PostTypeId="2" ParentId="4076" CreationDate="2015-12-07T10:34:11.763" Score="2" Body="&lt;p&gt;This is a very brief explanation regarding servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The type of servo system that you are proposing is a none positional open loop system and is generaly used for accurate movement rate (controlled speed) . The loop in this case is usually a tachogenerator which sends a voltage (which is proportional to the motor speed) to a comparator which compares the tachogenerator voltage to the required adjustable voltage , the output of the comparator then regulates the motor speed, hence the required speed . this type of servo system will continue to run at the constant speed until  A the comparator signal is set to zero or B the motive power is reremoved from the moter ( switched off)   ----Point to point servo control , on the other hand ,, generally uses a position command which is verified with a signal from an encoder at which point the servo will stop until another command is issued from the stack ( EG. another position location or a dwell command (wait) or other )  the most common way to do this is to use gcode which has the ability to give full control of your servo system . If there is no encoding device then accurate servo position control is very difficult if not impossible.&lt;/p&gt;&#xA;" OwnerUserId="15418" LastEditorUserId="15418" LastEditDate="2015-12-07T11:49:06.140" LastActivityDate="2015-12-07T11:49:06.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18500" PostTypeId="2" ParentId="18163" CreationDate="2015-12-07T11:52:12.533" Score="1" Body="&lt;p&gt;Thanks to Rob Tillaart, the autor of the Arduino DHT &lt;a href=&quot;https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; suggested by @frarugi87 (also thank him), the problem has been solved (see &lt;strong&gt;&lt;a href=&quot;https://github.com/RobTillaart/Arduino/issues/30&quot; rel=&quot;nofollow&quot;&gt;this issue&lt;/a&gt;&lt;/strong&gt; for more information).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case &lt;strong&gt;to fix the problem&lt;/strong&gt; there is only needed to to set a specific value of &lt;code&gt;DHTLIB_TIMEOUT&lt;/code&gt; by leaving the definition &lt;code&gt;#define DHTLIB_TIMEOUT 1000&lt;/code&gt; in the &lt;code&gt;dht.h&lt;/code&gt; file of this library and commenting other definitions written next to it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// #ifndef F_CPU&#xA;#define DHTLIB_TIMEOUT 1000 // should be approx. clock/40000&#xA;// #else&#xA;// #define DHTLIB_TIMEOUT (F_CPU/40000)&#xA;// #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The ATtiny is programmed on 8 MHz. The DHT22 is working at a voltage of 3.3V with a &lt;strong&gt;3K3&lt;/strong&gt; resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cause of the problem may be the way I program the ATtiny85 with old version of Arduino IDE installed in the Raspberry Pi (see comments to the @frarugi87's answer). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Libraries used:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib&quot; rel=&quot;nofollow&quot;&gt;RobTillaart/Arduino DHT11, 21, 22, 33 library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;nofollow&quot;&gt;Arduino driver for nRF24L01 http://maniacbug.github.com/RF24&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the final code of the ATtiny85 transmitter and the Raspberry Pi reseiver respectively (&lt;strong&gt;I took the most part of the code from different examples of RF24 libraries and DHT libraries! Excuse me, if the code is not tidy.&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NRF24Transmitter.ino:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;dht.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;#define DHT22_PIN 3&#xA;#define LONG_DELAY_MS 900000&#xA;&#xA;byte currentNodeAddr[6] = &quot;1Node&quot;;  // Address of this node&#xA;&#xA;// Struct for sending measured data&#xA;struct Data {&#xA;  float temp;  // Temperature value&#xA;  float hum;   // Humidity value&#xA;  int status;     // DHT22 module status&#xA;} data;&#xA;&#xA;RF24 radio(2,2);  // Create instance of RF24 radio object&#xA;dht DHT;          // Create instance of DHT22 module object&#xA;&#xA;void setup() {&#xA;  // Set up the radio&#xA;  radio.begin();&#xA;  radio.openWritingPipe(currentNodeAddr);&#xA;  radio.stopListening();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  unsigned long startMillis = millis();&#xA;  while (millis() - startMillis &amp;lt; LONG_DELAY_MS);&#xA;&#xA;  do {&#xA;    data.status = DHT.read22(DHT22_PIN);&#xA;    data.temp = DHT.temperature;&#xA;    data.hum = DHT.humidity;&#xA;&#xA;    if (data.status != DHTLIB_OK) {&#xA;      delay(1000);&#xA;    }&#xA;&#xA;  } while(data.status != DHTLIB_OK);&#xA;&#xA;  radio.write(&amp;amp;data, sizeof(Data));  // Send data to the Raspberry&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiver.cpp:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;cstdlib&amp;gt;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;sstream&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#include &amp;lt;unistd.h&amp;gt;&#xA;#include &amp;lt;RF24/RF24.h&amp;gt;&#xA;&#xA;using namespace std;&#xA;&#xA;uint8_t addresses[][6] = {&quot;1Node&quot;, &quot;2Node&quot;, &quot;3Node&quot;, &quot;4Node&quot;, &quot;5Node&quot;};&#xA;&#xA;// Struct for sending measured data&#xA;struct Data &#xA;{&#xA;    float temp;  // Temperature value&#xA;    float hum;   // Humidity value&#xA;    int status;     // DHT22 module status&#xA;} data;&#xA;&#xA;RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);&#xA;&#xA;int main(int argc, char** argv)&#xA;{&#xA;    uint8_t currentPipe = 1;&#xA;    data.temp = -888;&#xA;    data.hum = -888;&#xA;&#xA;    printf(&quot;BEGIN: %d\n&quot;, (int)radio.begin());&#xA;&#xA;    radio.setAutoAck(1);&#xA;    radio.setRetries(15,15);&#xA;//  radio.setDataRate(RF24_1MBPS);&#xA;//  radio.setPALevel(RF24_PA_MAX);&#xA;//  radio.setCRCLength(RF24_CRC_16);&#xA;&#xA;    radio.openReadingPipe(1, addresses[0]);&#xA;    radio.openReadingPipe(2, addresses[1]);&#xA;    radio.openReadingPipe(3, addresses[2]);&#xA;    radio.openReadingPipe(4, addresses[3]);&#xA;    radio.openReadingPipe(5, addresses[4]);&#xA;&#xA;    radio.startListening();&#xA;&#xA;    radio.printDetails();&#xA;&#xA;    sleep(1);&#xA;&#xA;    cout &amp;lt;&amp;lt; &quot;Start!&quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;    while(true)&#xA;    {&#xA;        cout &amp;lt;&amp;lt; &quot;Waiting for data...&quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;        while (radio.available(&amp;amp;currentPipe)) &#xA;        {&#xA;            cout &amp;lt;&amp;lt; &quot;Reading: &quot; &amp;lt;&amp;lt; addresses[currentPipe - 1] &amp;lt;&amp;lt; &quot;...&quot; &amp;lt;&amp;lt; endl;&#xA;&#xA;            radio.read(&amp;amp;data, sizeof(Data));&#xA;&#xA;            cout &amp;lt;&amp;lt; &quot;Temp: &quot; &amp;lt;&amp;lt; data.temp &amp;lt;&amp;lt; endl;&#xA;            cout &amp;lt;&amp;lt; &quot;Hum: &quot; &amp;lt;&amp;lt; data.hum &amp;lt;&amp;lt; endl;&#xA;            cout &amp;lt;&amp;lt; &quot;Status: &quot; &amp;lt;&amp;lt; data.status &amp;lt;&amp;lt; endl;&#xA;        }&#xA;&#xA;        sleep(1);&#xA;    }   &#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is Makefile to compile the receiver.cpp:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#############################################################################&#xA;#&#xA;# Makefile for librf24 examples on Raspberry Pi&#xA;#&#xA;# License: GPL (General Public License)&#xA;# Author:  gnulnulf &amp;lt;arco@appeltaart.mine.nu&amp;gt;&#xA;# Date:    2013/02/07 (version 1.0)&#xA;#&#xA;# Description:&#xA;# ------------&#xA;# use make all and make install to install the examples&#xA;# You can change the install directory by editing the prefix line&#xA;#&#xA;prefix := /usr/local&#xA;&#xA;# Detect the Raspberry Pi by the existence of the bcm_host.h file&#xA;BCMLOC=/opt/vc/include/bcm_host.h&#xA;&#xA;ifneq (&quot;$(wildcard $(BCMLOC))&quot;,&quot;&quot;)&#xA;# The recommended compiler flags for the Raspberry Pi&#xA;CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s&#xA;endif&#xA;&#xA;# define all programs&#xA;#PROGRAMS = scanner pingtest gettingstarted&#xA;PROGRAMS = receiver #gettingstarted gettingstarted_call_response transfer pingpair_dyn test&#xA;SOURCES = ${PROGRAMS:=.cpp}&#xA;&#xA;all: ${PROGRAMS}&#xA;&#xA;${PROGRAMS}: ${SOURCES}&#xA;    g++ ${CCFLAGS} -Wall -I../ -lrf24-bcm $@.cpp -o $@&#xA;&#xA;clean:&#xA;    rm -rf $(PROGRAMS)&#xA;&#xA;install: all&#xA;    receiver -d $(prefix) || mkdir $(prefix)&#xA;    receiver -d $(prefix)/bin || mkdir $(prefix)/bin&#xA;    for prog in $(PROGRAMS); do \&#xA;      install -m 0755 $$prog $(prefix)/bin; \&#xA;    done&#xA;&#xA;.PHONY: install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14918" LastEditorUserId="14918" LastEditDate="2016-08-01T09:37:39.717" LastActivityDate="2016-08-01T09:37:39.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18501" PostTypeId="2" ParentId="18487" CreationDate="2015-12-07T13:01:07.830" Score="0" Body="&lt;p&gt;Connect the camera to a serial port (hardware or software serial depending on Arduino board). See further information on &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=JPEG_2M_Pixel_Color_Camera_Serial_Interface%28TTL_level%29&quot; rel=&quot;nofollow&quot;&gt;wiki&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Control the camera and fetch the image over the serial connections (see commands) and write to the SD disc. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-07T13:01:07.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18502" PostTypeId="2" ParentId="9362" CreationDate="2015-12-07T13:55:32.973" Score="0" Body="&lt;p&gt;The SD might need disconnecting. Add below to setup(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(10, OUTPUT);&#xA;digitalWrite(10, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also check the pin assignment for the W5100 (in the Ethernet library). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-07T13:55:32.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18503" PostTypeId="1" AcceptedAnswerId="18504" CreationDate="2015-12-07T14:49:50.410" Score="0" ViewCount="418" Body="&lt;p&gt;I have the following script which checks if the user has pressed the numbers &quot;770&quot; or &quot;769&quot; continuously in the remote. The script works fine and displays all numbers. When I press the buttons &quot;770&quot; or &quot;769&quot; continuously the function powerOff() is called and I get no serial input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv&#xA; * An IR detector/demodulator must be connected to the input RECV_PIN.&#xA; * Version 0.1 July, 2009&#xA; * Copyright 2009 Ken Shirriff&#xA; * http://arcfn.com&#xA; */&#xA;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;IRsend irsend;&#xA;&#xA;decode_results results;&#xA;&#xA;int intValue;&#xA;String strValue;&#xA;String str3;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    intValue = results.value;&#xA;&#xA;    Serial.print(&quot;Integer value : &quot;);&#xA;    Serial.println(intValue);&#xA;&#xA;&#xA;    strValue = String(intValue);&#xA;    Serial.print(&quot;String str : &quot;);&#xA;    Serial.println(strValue);&#xA;&#xA;    Serial.print(&quot;Length : &quot;);&#xA;    Serial.print(strValue.length());&#xA;    Serial.println();&#xA;&#xA;&#xA;    if(strValue.length() &amp;lt;= 1){&#xA;      str3 += strValue;&#xA;      Serial.println(str3);&#xA;       // Receive the next value&#xA;   }&#xA;&#xA;    delay(200);&#xA;    irrecv.resume();&#xA;  }&#xA;  //Serial.println(str3);&#xA;  if(str3.endsWith(&quot;770&quot;)){&#xA;    powerOff();&#xA;    str3 = &quot;&quot;;&#xA;  }&#xA;  else if(str3.endsWith(&quot;769&quot;)){&#xA;    powerOff();&#xA;    str3 = &quot;&quot;;&#xA;  }&#xA;&#xA;  else{}&#xA;  //powerOff();&#xA;}&#xA;&#xA;void powerOff(){&#xA;    irsend.sendRC6( 0xC0000C, 24);&#xA;    irrecv.resume(); // Receive the next value&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12015" LastEditorUserId="12015" LastEditDate="2015-12-07T15:39:18.843" LastActivityDate="2015-12-07T15:39:18.843" Title="Script stops functioning after calling irsend() function in irlibrary!" Tags="|arduino-uno|serial|ir|remote-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18504" PostTypeId="2" ParentId="18503" CreationDate="2015-12-07T14:57:22.367" Score="3" Body="&lt;p&gt;Apparently you should be calling &lt;code&gt;irrecv.enableIRIn()&lt;/code&gt; after sending, not &lt;code&gt;irrecv.resume()&lt;/code&gt;. Sorry for suggesting the wrong thing on IRC before :-)&lt;/p&gt;&#xA;" OwnerUserId="5018" LastActivityDate="2015-12-07T14:57:22.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18505" PostTypeId="1" AcceptedAnswerId="18516" CreationDate="2015-12-07T15:13:54.557" Score="1" ViewCount="265" Body="&lt;p&gt;I'm using minIMU-9 &lt;a href=&quot;https://www.pololu.com/product/1268&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.pololu.com/product/1268&lt;/a&gt; and I want to read pitch, roll and yaw angles. I applied this library &lt;a href=&quot;https://github.com/pololu/minimu-9-ahrs-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/pololu/minimu-9-ahrs-arduino&lt;/a&gt; but there is a slope when sensor is not moving or vibrating. How can i fix or compensate this. The y axis is angle in degree and x axis is time in seconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pitch&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Us5BU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Us5BU.png&quot; alt=&quot;Pitch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Roll&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9oRC2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9oRC2.png&quot; alt=&quot;Roll&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yaw&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dzEgx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dzEgx.png&quot; alt=&quot;Yaw&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2015-12-12T08:42:48.020" LastActivityDate="2015-12-12T08:42:48.020" Title="minIMU 9 and Arduino reading Gyro angle" Tags="|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18509" PostTypeId="1" CreationDate="2015-12-07T16:29:13.827" Score="0" ViewCount="290" Body="&lt;p&gt;is there any way I can run an MG2639 GPS Cellular Shield (the one SparkFun makes) on an Arduino Uno for GPS tracking purposes? It seems whether I use New or AltSoftSerial, the unit just can’t read what’s streaming in through from the GPS on the 115200 baud rate, which the shield is hard-wired to.&lt;/p&gt;&#xA;" OwnerUserId="13571" LastEditorUserId="13571" LastEditDate="2015-12-16T22:22:18.800" LastActivityDate="2016-06-03T18:28:00.033" Title="MG2639 &amp; Arduino Uno not GPS-ing?" Tags="|gps|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18510" PostTypeId="2" ParentId="18509" CreationDate="2015-12-07T17:15:58.567" Score="1" Body="&lt;p&gt;Try sending a command that sets the GPS baud rate to something a little lower:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;altss.write( F(&quot;$PMTK251,38400*27\r\n&quot;) );&#xA;altss.end();&#xA;altss.begin( 38400 ); // change to match above command&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are you sure you're having trouble &lt;em&gt;reading&lt;/em&gt;, because there are many other things you may be doing in your sketch that cause input buffer &lt;em&gt;overflow&lt;/em&gt;.  Please post your code and some sample output for us to examine.  It may be failing for a different reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you may just be losing data because you're trying to do too many things in &lt;code&gt;loop()&lt;/code&gt;.  Please take a look &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Troubleshooting.md#trying-to-do-too-many-things&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this kind of problem, I have posted a modified version of &lt;code&gt;AltSoftSerial&lt;/code&gt; on github, &lt;a href=&quot;https://github.com/SlashDevin/NeoICSerial&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, that let you process GPS data in the background (i.e., during interrupts).  When coupled with &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt;, it can save you quite a bit of program space, RAM and execution time.  There is an interrupt-driven example &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/examples/NMEA_isr/NMEA_isr.ino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  Just change which include is uncommented on lines 30-31:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#else  &#xA;  // Only one serial port is available, uncomment one of the following:&#xA;  #include &amp;lt;NeoICSerial.h&amp;gt;&#xA;  //#include &amp;lt;NeoSWSerial.h&amp;gt;&#xA;#endif&#xA;#include &quot;GPSport.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and the baud rate below, on line 140:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // Start the UART for the GPS device&#xA;  gps_port.attachInterrupt( GPSisr );&#xA;  gps_port.begin( 115200 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2016-06-03T18:28:00.033" LastActivityDate="2016-06-03T18:28:00.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18512" PostTypeId="1" CreationDate="2015-12-07T17:53:50.747" Score="-2" ViewCount="3016" Body="&lt;p&gt;I have a home automation project and am looking to use multiple current sensors (ACS712) for multiple appliances. I just need to know whether current is present or not instead of the current value. Is it possible, that I connect the ACS712 sensor to the digital input of Arduino, and get HIGH or LOW via &lt;code&gt;digitalRead()&lt;/code&gt; function. If not, please suggest an alternative to detect ac current is present or not with digital input i.e. HIGH or LOW that can be read via the &lt;code&gt;digitalRead()&lt;/code&gt; function.&lt;/p&gt;&#xA;" OwnerUserId="15421" LastActivityDate="2016-01-29T04:41:52.580" Title="Can you connect ACS712 sensor to digital input of Arduino?" Tags="|digital-in|" AnswerCount="4" CommentCount="4" ClosedDate="2016-01-29T05:54:44.763" ContentLicense="CC BY-SA 3.0" />
  <row Id="18513" PostTypeId="2" ParentId="18512" CreationDate="2015-12-07T17:56:31.890" Score="0" Body="&lt;p&gt;Use a comparator for an adjustable threshold and feed the output into the arduino digital pin.&lt;/p&gt;&#xA;" OwnerUserId="15422" LastActivityDate="2015-12-07T17:56:31.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18515" PostTypeId="2" ParentId="18512" CreationDate="2015-12-07T18:58:47.860" Score="2" Body="&lt;p&gt;Considering an ATMEGA with a 5V VCC we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LOW  = &amp;lt; 0.3*VCC = 0,3*5V = 1.5 V&#xA;HIGH = &amp;gt; 0.5*VCC = 0,5*5V = 2.5 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can connect directly to the Arduino if the output of your sensor is higher than 2.5 volts whether current is present or below 1.5 volts if not. This would translate to HIGH or LOW output from &lt;code&gt;digitalRead()&lt;/code&gt; function respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to recalculate this values for the 3 volt version of Arduino, probably in this case is better the comparator solution to ensure up to 3 volts max logic level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example circuit as follow, just need to set voltage divider to desired threshold (note this is for 5v case),&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/juOxX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/juOxX.png&quot; alt=&quot;Comparator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-12-07T18:58:47.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18516" PostTypeId="2" ParentId="18505" CreationDate="2015-12-07T20:19:31.083" Score="1" Body="&lt;p&gt;I suppose &quot;at desktop readings&quot; means you have your sensor resting on the desktop so you where looking for a constant output value over the time. Well, there are some mechanical limitations about gyroscope's accuracy, resolution and external factor like temperature that make noisy or non-sense readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are obtaining from this library is a calculated orientation that carries or accumulate an error over time. Basically there is not a perfect algorithm to calculate orientation as at MEM's scale electrons still moving due to temperature and other radiations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution depends on your application scenario: if your sensor will be most the time quite, maybe just mathematical compensate with inverted slope (about 4-5 degrees per minute) and look for more rapid changes to determine movement. If your application will be on constant move maybe it is not required any compensation. Trade off must be considered if both scenarios will take place on your application. Anyway, reading measures on your actual application will give you more clue on how to handle this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below the L3GD20's mechanical characteristics&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6Zs5P.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Zs5P.png&quot; alt=&quot;Gyro&amp;#39;s mechanical characteristics&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-12-07T20:19:31.083" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18517" PostTypeId="2" ParentId="18492" CreationDate="2015-12-07T20:40:47.040" Score="1" Body="&lt;p&gt;For low-power, just some tips (link references)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/petervojtek/diy/wiki/Arduino-with-Very-Low-Power-Consumption&quot; rel=&quot;nofollow&quot;&gt;https://github.com/petervojtek/diy/wiki/Arduino-with-Very-Low-Power-Consumption&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;claim the below results,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LED off, without the JeeLib library: 6.7 mA&#xA;LED on, without the JeeLib library: 8.8 mA&#xA;LED off, with the JeeLib library: 43 uA (!)&#xA;LED on, with the JeeLib library: 2.2mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/petervojtek/diy/wiki/Arduino-with-Very-Low-Power-Consumption&quot; rel=&quot;nofollow&quot;&gt;https://github.com/petervojtek/diy/wiki/Arduino-with-Very-Low-Power-Consumption&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detailed step by step tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For sensing PIR will depend on exact components; using SMD low-leakage components will do the trick but cost would increase. There are very-low-power RTC on the market and maybe SD logging will be more difficult as can consume up to 200 mA per reading/writing operations.&lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-12-07T20:40:47.040" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18518" PostTypeId="1" CreationDate="2015-12-08T02:46:49.933" Score="0" ViewCount="2981" Body="&lt;p&gt;Is there a high-quality (32 bit/96,000 kbps) digitizer for Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody know where I can find the best options for this?&lt;/p&gt;&#xA;" OwnerUserId="15433" LastEditorUserId="6936" LastEditDate="2016-01-01T06:51:06.523" LastActivityDate="2016-01-01T06:51:06.523" Title="Where can I get a high-quality ADC (audio digitizer) for Arduino?" Tags="|audio|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18519" PostTypeId="2" ParentId="18518" CreationDate="2015-12-08T03:04:27.840" Score="2" Body="&lt;p&gt;You are going to need a bigger board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(96000000 samples/second) * (32 bits / sample) ~= &lt;a href=&quot;http://www.wolframalpha.com/input/?i=%2896000000%20sample%2Fsecond%29%20*%20%2832%20bits%20%2F%20sample%29&quot; rel=&quot;nofollow&quot;&gt;3 Gigabits/second&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A poor little Arduino Uno only runs at 20MHz and can process 8 bits bytes at a time, so even if it could somehow read and store a byte every cycle, it would still be orders of magnitude too slow for your purposes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I guess is might be possible to build a shield with an ultra high speed ADC and on board memory to directly store the captures samples to, you probably would bother making it since the Arduino would struggle to do anything useful with the captured data even after the fact. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highest quality audio recording shield for Arduino I've seen is a modified &lt;a href=&quot;http://www.adafruit.com/products/94?&amp;amp;main_page=product_info&amp;amp;cPath=17_21&amp;amp;products_id=94&quot; rel=&quot;nofollow&quot;&gt;Wav Shield&lt;/a&gt; that can record 8-bit mono files at 44,100 samples per second using the &lt;a href=&quot;https://blog.adafruit.com/2009/07/07/waverp-an-arduino-library-for-recording-and-playing-wave-files-on-the-adafruit-wave-shield/&quot; rel=&quot;nofollow&quot;&gt;waverp library&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7859" LastActivityDate="2015-12-08T03:04:27.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18521" PostTypeId="2" ParentId="18518" CreationDate="2015-12-08T08:44:01.713" Score="1" Body="&lt;p&gt;think 96000kps was most likely a typo. 96ksps or 96000sps is more likely since the title specifies audio. Still a little too much for an Arduino though. You need a chip with I2S and a CODEC chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a project at the moment interfacing a PIC32 to a CODEC for CD quality audio reproduction. The codec I am using (PCM1774) is DAC only, but you can get CODECs in many combinations of ADC and DAC with different numbers of channels in each.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I2S is very similar to SPI but needs some extra facilities that not all chips can provide. Things like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;High speed flexible base clock at (for example) 256x the sample frequency&lt;/li&gt;&#xA;&lt;li&gt;Left/Right framing clock derived from base clock&lt;/li&gt;&#xA;&lt;li&gt;DMA for smooth transfer of data&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't know what offerings Atmel have, but for PIC32 you need one of the more modern chips, such as the PIC32MX1xx/2xx family, PIC32MX470, or for high end work the 200MHz PIC32MZ chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MX1xx/2xx and MZ chips are available in a Arduino-like system called chipKIT which might suit your needs better than small Atmel chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due might also be able to do I2C but I won't be able to help you with that since I have relegated my Due to the bittom of my junk pile.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-08T08:44:01.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18523" PostTypeId="1" CreationDate="2015-12-08T09:56:18.417" Score="-1" ViewCount="831" Body="&lt;p&gt;I am trying to figure out how to get 2 Arduinos to talk back and forth from one another using cheap simple RF modules. I have a total of 4 RF modules (2 receiver and 2 transmitter) and 2 Arduinos. I need Arduino A to send about 3 variables to Arduino B, and I need Arduino B to send 1 variable back to Arduino A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I attempted 2 way communication, I programmed Arduino A to broadcast constantly, while having Arduino B trade off between receiving once, then sending once on every other loop. This resulted in Arduino B also only broadcasting, and was not receiving any signal from Arduino A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My other attempt was to have Arduino B send for about 250 ms, then receive for 250 ms, and repeat. This worked as long as Arduino A was only broadcasting, but as soon as I had Arduino A doing the same thing, the clock on each seemed to be slightly off and there would be periods where both Arduinos were sending, or where both were trying to receive, so it was also very unreliable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a reliable way to do two way communication with this kind of hardware, or would I need transceivers to do this kind of project?&lt;/p&gt;&#xA;" OwnerUserId="15434" LastActivityDate="2019-08-29T16:42:13.093" Title="2 way RF with Virtual Wire / 315 / 433 MHz" Tags="|rf|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18525" PostTypeId="2" ParentId="18523" CreationDate="2015-12-08T12:14:53.783" Score="1" Body="&lt;p&gt;If the RF Modules you are mentioning are the ones I am thinking of they do seem to be very special bits of kit.  I have tried Bluetooth you can get cheap HM05 modules (Might be the wrong number you want the one that can be the master or slave).  These were a bit better but don't have the range.&lt;br&gt;&#xA;My personal fav at the moment would be a ESP8266, no I have never hooked one up to an Arduino, but it can be done fairly easily.  You should get 100m range (in ideal circumstances) and you can get aerials to boost that.  You can also set one up as a repeater between two wifi segments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever you decide you might want to change your code slightly so that one Arduino sends a time signal and the other doesn't send its data until its turn.  Or give them GPS receivers and pull the time from there.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2015-12-08T12:14:53.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18527" PostTypeId="2" ParentId="18227" CreationDate="2015-12-08T12:40:02.507" Score="0" Body="&lt;p&gt;I am currently experimenting with this module: &lt;a href=&quot;http://www.uctronics.com/mega-pixel-camera-module-mt9d111-jpeg-out-p-227l.html&quot; rel=&quot;nofollow&quot;&gt;http://www.uctronics.com/mega-pixel-camera-module-mt9d111-jpeg-out-p-227l.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I2C connection and supplies are working fine with an Arduino Uno, but getting the image data with an Arduino might be not possible.&#xA;You can slow down the Pixel Clock of this module to 375kHz, bit I think the  GPIO read-out speed (at least with the standard digitalRead functions) and memory of the Arduino are not sufficient...&lt;/p&gt;&#xA;" OwnerUserId="15261" LastActivityDate="2015-12-08T12:40:02.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18528" PostTypeId="1" AcceptedAnswerId="18529" CreationDate="2015-12-08T13:22:44.907" Score="0" ViewCount="321" Body="&lt;ol&gt;&#xA;&lt;li&gt;is it dangerous for arduino the below circuit because GND pin is common with -12V battery pole?&lt;/li&gt;&#xA;&lt;li&gt;is it dangerous for lots of 5v circuit to be grounded on -12v battery pole?&lt;/li&gt;&#xA;&lt;li&gt;in case i don't connect GND arduino pin with -12v , does arduino works?&lt;/li&gt;&#xA;&lt;li&gt;in case that 1,2 question is dangerous for arduino,does it safe if a connect a diode at P1 mark?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i1YTZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i1YTZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11803" LastEditorUserId="2881" LastEditDate="2015-12-08T14:09:07.917" LastActivityDate="2015-12-08T14:09:07.917" Title="Supply arduino through Vin pin with a battery" Tags="|arduino-mega|battery|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18529" PostTypeId="2" ParentId="18528" CreationDate="2015-12-08T13:56:49.027" Score="1" Body="&lt;p&gt;Voltages, being a &lt;em&gt;potential difference&lt;/em&gt; are always measured relative to another voltage.  Normally that reference voltage is referred to as &lt;em&gt;ground&lt;/em&gt;, though may not always be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The + and - on the battery refers to the &lt;em&gt;polarity of the battery&lt;/em&gt; not the &lt;em&gt;polarity of the voltage&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;em&gt;relative to the - terminal&lt;/em&gt; the positive terminal is 12 volts higher, or +12V.  &lt;em&gt;Relative to the + terminal&lt;/em&gt; the negative terminal is 12V lower, so -12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When one of your battery terminals is connected to a point in your circuit nominated as ground (the - terminal of your battery in this case) then your battery voltage at the + terminal is measured relative to ground, which we say is 0V.  So the + terminal is 12V higher than the - terminal, and the - terminal is 0V, so therefore the + terminal must be 12V &lt;em&gt;with respect to ground&lt;/em&gt;.  The - terminal, since it is connected to ground is at the same voltage as ground, so it is 0V &lt;em&gt;with respect to ground&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to connect the + terminal of a battery to ground instead, then the - terminal would be 12V &lt;em&gt;lower&lt;/em&gt; than ground, so would be -12V &lt;em&gt;with respect to ground&lt;/em&gt;.  The + terminal would be 0V &lt;em&gt;with respect to ground&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-08T13:56:49.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18530" PostTypeId="1" CreationDate="2015-12-08T16:01:29.560" Score="0" ViewCount="115" Body="&lt;p&gt;At first, I tried to make whole code for an RC car and remote controller, but I realized that it's difficult for me since I have few ideas about C++. So, I changed a few things like turning on the LEDs with switches and servomotors with potentiometer. Here are my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Remote controller&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BTSerial(2,3);&#xA;int sw1=13;&#xA;int sw2=12;&#xA;&#xA;void setup() {&#xA;  BTSerial.begin(9600);&#xA;  Serial.begin(9600);&#xA;  pinMode(sw1, INPUT_PULLUP);&#xA;  pinMode(sw2, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;  int a = analogRead(A0);&#xA;  int map_a=map(a,0,1023,0,255);&#xA;  int state1=digitalRead(sw1);&#xA;  int state2=digitalRead(sw2);&#xA;&#xA;  BTSerial.print('S');&#xA;  BTSerial.print(map_a);&#xA;  BTSerial.print(',');&#xA;  BTSerial.print(state1);&#xA;  BTSerial.print(',');&#xA;  BTSerial.print(state2);&#xA;  BTSerial.print('E');&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&amp;lt; RC CAR &gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial BTSerial(2,3);&#xA;&#xA;byte buffer[255];&#xA;int bufferPosition;&#xA;&#xA;&#xA;void setup() {&#xA; BTSerial.begin(9600);&#xA; Serial.begin(9600);&#xA; bufferPosition=0;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  {&#xA;    if(BTSerial.available()&amp;gt;0){&#xA;    unsigned char data = (unsigned char)BTSerial.read();&#xA;    buffer[bufferPosition++]=data;&#xA;    Serial.println(data);&#xA;    delay(100);&#xA;    }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I checked the result from &lt;code&gt;Serial.println(data)&lt;/code&gt; from RC car code, &#xA;it was trash...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you instruct me what's wrong with this code?&lt;/p&gt;&#xA;" OwnerUserId="15446" LastEditorUserId="6936" LastEditDate="2016-01-04T19:40:15.543" LastActivityDate="2016-01-04T19:40:15.543" Title="I'd like to make RC car and remote controller via bluetooth (HC06)" Tags="|bluetooth|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18531" PostTypeId="1" AcceptedAnswerId="18555" CreationDate="2015-12-08T17:13:51.023" Score="2" ViewCount="1701" Body="&lt;p&gt;The command line that my toolchain (&lt;a href=&quot;https://www.jetbrains.com/clion/&quot; rel=&quot;nofollow&quot;&gt;CLion&lt;/a&gt; + &lt;a href=&quot;http://platformio.org/#!/&quot; rel=&quot;nofollow&quot;&gt;PlatformIO&lt;/a&gt;) uses to program my Arduino (Uno) includes includes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude ... -c arduino ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html&quot; rel=&quot;nofollow&quot;&gt;the documentation&lt;/a&gt; for this programmer simply reads&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;-c programmer-id&lt;br&gt;&#xA;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;&#xA;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arduino&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Arduino&lt;br&gt;&#xA;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...   &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What does the &lt;code&gt;arduino&lt;/code&gt; programmer do. Does it just correspond to using the bootloader?&lt;/p&gt;&#xA;" OwnerUserId="867" LastActivityDate="2015-12-13T15:21:46.110" Title="What does the 'arduino' avrdude programmer do?" Tags="|avrdude|programmer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18533" PostTypeId="1" CreationDate="2015-12-08T18:52:42.630" Score="-1" ViewCount="1838" Body="&lt;p&gt;Please help me find a way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at the following for sending data &lt;a href=&quot;http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/&quot; rel=&quot;nofollow&quot;&gt;Arduino to MySql&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But can't seem to find visa-versa.&lt;/p&gt;&#xA;" OwnerUserId="15449" LastActivityDate="2015-12-31T19:50:13.233" Title="I would like to retrieve data from a MySQL database using PHP using HTTP requests, on my Arduino" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18534" PostTypeId="1" CreationDate="2015-12-08T19:34:35.023" Score="1" ViewCount="824" Body="&lt;p&gt;I am currently working on a photo-transistor like this:&#xA;&lt;a href=&quot;http://www.ebay.com/itm/10pcs-ITR8307-S18-TR8-Optical-Switches-Reflective-Phototransistor-Output-/381374566327?hash=item58cbb20fb7:g:lgoAAOSwr81UQ7KG&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/10pcs-ITR8307-S18-TR8-Optical-Switches-Reflective-Phototransistor-Output-/381374566327?hash=item58cbb20fb7:g:lgoAAOSwr81UQ7KG&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It very nicely allows me to identify colors white, green and black. The problem I am having is that the Arduino is powered with batteries so the readings for those colors change as voltage in the batteries reduces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to make the reading proportional to the voltage in the system, but this still gives different values, I guess the readings change non-linearly as voltage changes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder what will be the solution to this problem: Specifically, how to make the reading of an IR sensor the same for the same color at different voltages?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code I am using so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;// initialize serial communication at 9600 bits per second:&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;// read the input from the IR sensor on pin A0:&#xA;float sensorValue = analogRead(A0);&#xA;// read the voltage in the system by connecting pin A1 to Vcc, with the same resistor value used in the IR sensor:&#xA;float Vref = analogRead(A1);&#xA;&#xA;// adjust reading value to voltage in system:&#xA;float AdjustedReading = sensorValue/Vref;&#xA;&#xA;Serial.println(AdjustedReading);&#xA;delay(100);        &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2016-01-12T07:11:38.750" Title="IR sensor readings at different voltages" Tags="|voltage-level|battery|ir|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18535" PostTypeId="2" ParentId="18533" CreationDate="2015-12-08T19:42:01.680" Score="2" Body="&lt;p&gt;There are two things you have to set up for this:&#xA;1. Retrieving/parsing websites from your Arduino.&#xA;2. Making a dynamic website using PHP (and MySql).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Try to set up your Arduino as a &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WebClient&quot; rel=&quot;nofollow&quot;&gt;WebClient&lt;/a&gt;, check if you can retrieve a website like google.com or &lt;a href=&quot;http://www.minimalsites.com/&quot; rel=&quot;nofollow&quot;&gt;a minimalistic website&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Try to get your arduino to interpret a string or retrieve values from that website. (I.E: retrieve the day/time from the HTTP message)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;IF your arduino can retrieve webpages, you're halfway there (somewhat). And your project is running out of the scope of this arduino.stackexchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you're going to have to &lt;a href=&quot;https://www.google.nl/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;es_th=1&amp;amp;ie=UTF-8#q=dynamic%20website%20php%20mysql&amp;amp;es_th=1&quot; rel=&quot;nofollow&quot;&gt;create a dynamic website&lt;/a&gt;. You can let PHP reach for values from your MySql database (you should just use a text file first) and display them on your site (in HTML).&#xA;Your Arduino can now poll your website, to get the HTML content and parse it to the values.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-12-08T19:42:01.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18536" PostTypeId="1" CreationDate="2015-12-08T20:47:24.917" Score="2" ViewCount="800" Body="&lt;p&gt;I want to make a clone of those radar enforcement signs that look like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MC460.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MC460.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought a Hot Wheels Radar gun that can send an analog signal to determine speed.  See this thread:  &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=145063.msg1889312#msg1889312&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=145063.msg1889312#msg1889312&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From FreqPeriod's documentation, it has the following comment in the code:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;connect pin 5,6,7 to input circuit&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question is -- how do I wire up the radar gun analog signal wire to the arduino to successfully use FreqPeriod?&lt;/p&gt;&#xA;" OwnerUserId="15450" LastActivityDate="2015-12-08T20:47:24.917" Title="Using a Hot Wheels Radar Gun with FreqPeriod library" Tags="|frequency|adc|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18537" PostTypeId="1" AcceptedAnswerId="18543" CreationDate="2015-12-08T21:43:47.740" Score="0" ViewCount="979" Body="&lt;p&gt;What is the easiest way to mount DS1307 to ethernet shield? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to do this:&#xA;&lt;a href=&quot;https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but my program just freezes when I try to read data from RTC. Is there any other ways to do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int RTCpin2 = 2;&#xA;const int RTCpin3 = 3;&#xA;&#xA;void setup() {&#xA;    pinMode(RTCpin2, OUTPUT);&#xA;    pinMode(RTCpin3, OUTPUT);&#xA;&#xA;    analogWrite(RTCpin2, LOW);&#xA;    analogWrite(RTCpin3, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;     // process RTC time&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13760" LastEditorUserId="13760" LastEditDate="2015-12-08T21:50:33.150" LastActivityDate="2015-12-08T23:00:51.417" Title="connecting RTC DS1307 to ethernet shield" Tags="|arduino-uno|shields|ethernet|rtc|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18538" PostTypeId="1" AcceptedAnswerId="18547" CreationDate="2015-12-08T22:18:50.953" Score="7" ViewCount="5707" Body="&lt;p&gt;Well I've just started learning the concept of multithreading with C++ and immediately a bunch of questions came to mind about the possibility of using multithreading with microcontrollers in general and Arduino specifically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, is it possible to use multithreading on any type of Arduino boards?&lt;/p&gt;&#xA;" OwnerUserId="15428" LastEditorUserId="6936" LastEditDate="2015-12-30T22:06:44.353" LastActivityDate="2017-01-31T14:16:19.027" Title="Multithreading with Arduino" Tags="|programming|c++|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18539" PostTypeId="2" ParentId="18538" CreationDate="2015-12-08T22:36:05.423" Score="3" Body="&lt;p&gt;The really quick answer is &quot;maybe&quot; – it depends on what you mean by &quot;Arduino&quot; and what you mean by &quot;thread.&quot; The answer is likely to be different for the AVR based Arduinos (Uno et al.) vs. the ARM based Arduinos (Due et al.) – I would expect there to be much better hardware support for &quot;real&quot; threads on the ARM processors. Another question you'd want to answer is &quot;why threads?&quot; Do you want the abstraction to help you organize your code? Or do you actually need &quot;real&quot; threads?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before there was hardware thread support (e.g., the mid-80s) there are user thread implementations, it seems possible that they might be adaptable to run even on an AVR. I would expect it to be something of a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a threads package called &lt;a href=&quot;http://dunkels.com/adam/pt&quot; rel=&quot;nofollow noreferrer&quot;&gt;Protothreads&lt;/a&gt; which may be interesting. The description says &quot;Protothreads are extremely lightweight stalkless threads designed for severely memory constrained systems.&quot; I found &lt;a href=&quot;https://arduino.stackexchange.com/questions/12411/arduino-protothreads-by-example&quot;&gt;another question asking about simple usage&lt;/a&gt; of Protothreads, so it seems that you may find some other users of the package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also find some useful information in this Stack Exchange &lt;a href=&quot;https://stackoverflow.com/questions/9145321/implementing-a-user-level-threads-package&quot;&gt;question on threads&lt;/a&gt;, a quick search for &quot;C user threads&quot; found &lt;a href=&quot;http://homepage.cs.uiowa.edu/~jones/opsys/threads&quot; rel=&quot;nofollow noreferrer&quot;&gt;this implementation&lt;/a&gt; on the first page – and I'm sure there are many more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A search on &quot;Arduino threads&quot; found several more interesting looking links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/286/how-can-i-create-multiple-running-threads&quot;&gt;How can I create multiple running threads?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/ivanseidel/ArduinoThread&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Thread package on GitHub&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.kwartzlab.ca/2010/09/arduino-multi-threading-librar/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.kwartzlab.ca/2010/09/arduino-multi-threading-librar/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forums.trossenrobotics.com/showthread.php?5923-Multithreading-(Parallel-loops)-on-an-Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forums.trossenrobotics.com/showthread.php?5923-Multithreading-(Parallel-loops)-on-an-Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you just want threads, a small and inexpensive board, and I/O pins it might be worth considering a Raspberry Pi – Linux has thread support.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-12-11T17:55:10.107" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18540" PostTypeId="2" ParentId="9998" CreationDate="2015-12-08T22:41:16.833" Score="1" Body="&lt;p&gt;Could be the OS not allowing the application to access the COM ports, there is a terminal command to give the Arduino IDE access to the specific COM port.&lt;/p&gt;&#xA;" OwnerUserId="14716" LastActivityDate="2015-12-08T22:41:16.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18541" PostTypeId="1" AcceptedAnswerId="18544" CreationDate="2015-12-08T22:47:06.760" Score="3" ViewCount="4361" Body="&lt;p&gt;I'd like to buy new resistors for breadboarding with my Arduino Uno. There are 0.25W, 0.4W, 0.6W, 1W, 2W, 3W, 5W, 10W resistors in the shop. What is the most suitable for this operation?&lt;/p&gt;&#xA;" OwnerUserId="15454" LastEditorUserId="15454" LastEditDate="2015-12-15T09:25:19.430" LastActivityDate="2018-02-22T17:20:19.583" Title="What is the minimum wattage of resistors for breadboarding with Arduino Uno?" Tags="|arduino-uno|resistor|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18542" PostTypeId="2" ParentId="18541" CreationDate="2015-12-08T22:52:17.257" Score="0" Body="&lt;p&gt;The smaller the better for the most part. On 1/4 or 1/8 W resistors the leads size is small enough to work well in bread boards. Rarely do you need to dissipate large amounts of power so 1/8 is a good size for logic, maybe 1/4-1/2 for power supply areas.  See Majenko's answer for the heavy math, mostly applicable in power supply areas as he points out.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="14948" LastEditDate="2015-12-09T21:33:29.303" LastActivityDate="2015-12-09T21:33:29.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18543" PostTypeId="2" ParentId="18537" CreationDate="2015-12-08T23:00:51.417" Score="1" Body="&lt;p&gt;I assume that snippet of code is supposed to provide the +5Vand GND for powering the RTC module.  Well, there's two fundamental flaws with it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pins 2 and 3 are the DIGITAL pins, not the analog pins. Instead you want to be using pins A2 and A3.&lt;/li&gt;&#xA;&lt;li&gt;analogWrite controls the PWM output on pins that support PWM. HIGH is 1, so analogWrite will be providing a 1/255 duty cycle PWM signal on that pin.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So to fix it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use pins A2 and A3 instead of 2 and 3&lt;/li&gt;&#xA;&lt;li&gt;Use digitalWrite() instead of analogWrite().&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-08T23:00:51.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18544" PostTypeId="2" ParentId="18541" CreationDate="2015-12-08T23:09:27.597" Score="5" Body="&lt;p&gt;The answer is: It depends what you want to use them for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a wattage that is higher than the power it will dissipate. What that power is depends on what you are doing with them.  There are standard formulae that tell you the power in any given situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you know the current and the resistance you can use:  P=I²×R. If you know the voltage across the resistor it's P=V²÷R.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take as an example the common resistor for an LED.  Assume a 2V LED and a 220 ohm resistor. With a 5V total voltage the voltage across the resistor would be 5-2=3V. So the power would be (3²)/220 = 9/220 = 0.041W so you could quite happily use a 0.125w (⅛w) resistor for that job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest though most common Arduino jobs can be accommodated by ⅛W or ¼W resistors.  ¼W is better for breadboarding since the leads are fatter than ⅛W, but ⅛W can take two leads at once direct into an Arduino's headers. Also if you fold the leads in half and squash them with pliers they fit better.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-09T10:53:19.613" LastActivityDate="2015-12-09T10:53:19.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18545" PostTypeId="2" ParentId="17443" CreationDate="2015-12-08T23:32:06.043" Score="2" Body="&lt;p&gt;Actually, Majenko's diagram assumes the interplay of the pullup resistor forces the line back to a HIGH position (as quickly as the internal transistors can overpower the drop from the switch).  If the switch itself is mechanical with a pullup resistor (external or internal), then the only thing &quot;bouncing&quot; is the switch.  If you use a digital switch, the rise is much sharper without significant bounce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A cheap and effective debouncing tactic is to add a capacitor in parallel with the switch.  The cap will drop to GND quickly as the switch drains the charge stored in the cap.  But the cap will take a while to recharge since its only source is through the resistor (during which time the mechanicals settle down).  (This looks much better in a diagram, but I haven't figured out how to draw on here yet.) I wish I could recommend values, but it really depends on the mechanicals of the switch and the certainty of the debounce desired--make everything HUGE and you're guaranteed no bounce, use values in between and you go on probabilities.  I usually start out with 0.1uF and vary it up or down until I get a balance between reliability and speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main advantage is, of course, you use absolutely no computing time to debounce any number of switches.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Potential disadvantages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Added hardware cost for each switch, making this technique less desirable in production scenarios&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;0/1 thresholds of input pins will vary across the manufacturing process, so one cap / input pin may have a different debounce time than another on an identical circuit.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Software debouncing schemes can note that the switch is pushed on the first drop to GND, where this hardware-only tactic relies on the last actual contact with GND.  As the switch ages, I've seen this delay exceed 50 mSec.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since the bounce is mechanical at its core, bounce worsens over the life of the mechanical part (in this case the switch).  Typically, software can be fine-tuned easier than hardware. Often, however, swapping out a cap is easier than reflashing firmware.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2015-12-08T23:32:06.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18546" PostTypeId="2" ParentId="18349" CreationDate="2015-12-08T23:36:50.537" Score="4" Body="&lt;p&gt;Returning from &lt;code&gt;main&lt;/code&gt; does not reset the device (it would start up again and do it all over in that case). It calls &lt;code&gt;exit&lt;/code&gt; which turns interrupts off and loops indefinitely.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000068 &amp;lt;__ctors_end&amp;gt;:&#xA;  68:   11 24           eor r1, r1&#xA;  6a:   1f be           out 0x3f, r1    ; 63&#xA;  6c:   cf ef           ldi r28, 0xFF   ; 255&#xA;  6e:   d8 e0           ldi r29, 0x08   ; 8&#xA;  70:   de bf           out 0x3e, r29   ; 62&#xA;  72:   cd bf           out 0x3d, r28   ; 61&#xA;  74:   0e 94 52 00     call    0xa4    ; 0xa4 &amp;lt;main&amp;gt;&#xA;  78:   0c 94 61 00     jmp 0xc2    ; 0xc2 &amp;lt;_exit&amp;gt;&#xA;&#xA;...&#xA;&#xA;000000a4 &amp;lt;main&amp;gt;:&#xA;  a4:   80 e2           ldi r24, 0x20   ; 32&#xA;  a6:   84 b9           out 0x04, r24   ; 4&#xA;  a8:   f8 94           cli&#xA;  aa:   8f ef           ldi r24, 0xFF   ; 255&#xA;  ac:   87 bd           out 0x27, r24   ; 39&#xA;  ae:   82 e0           ldi r24, 0x02   ; 2&#xA;  b0:   80 93 6e 00     sts 0x006E, r24&#xA;  b4:   84 bd           out 0x24, r24   ; 36&#xA;  b6:   78 94           sei&#xA;  b8:   85 e0           ldi r24, 0x05   ; 5&#xA;  ba:   85 bd           out 0x25, r24   ; 37&#xA;  bc:   80 e0           ldi r24, 0x00   ; 0&#xA;  be:   90 e0           ldi r25, 0x00   ; 0&#xA;  c0:   08 95           ret&#xA;&#xA;000000c2 &amp;lt;_exit&amp;gt;:&#xA;  c2:   f8 94           cli&#xA;&#xA;000000c4 &amp;lt;__stop_program&amp;gt;:&#xA;  c4:   ff cf           rjmp    .-2         ; 0xc4 &amp;lt;__stop_program&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see at address 0x74 it calls main, and then jumps to exit. &lt;code&gt;exit&lt;/code&gt; turns off interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With interrupts off your ISR will not toggle pin 13.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2015-12-08T23:36:50.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18547" PostTypeId="2" ParentId="18538" CreationDate="2015-12-08T23:54:51.487" Score="7" Body="&lt;p&gt;In &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cosa&lt;/a&gt; you can find the following support for concurrent programming:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Event.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;Events&lt;/a&gt;, interface interrupt service routines &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Job.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jobs&lt;/a&gt;, delayed, &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Periodic.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;periodic&lt;/a&gt; or &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Alarm.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;alarm&lt;/a&gt; functions with us, ms and seconds level timers (Watchdog, RTT or RTC).&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/FSM.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;FSM&lt;/a&gt;, object-state function&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/ProtoThread/ProtoThread.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;ProtoThreads&lt;/a&gt;, object-state pointer&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/Nucleo/Thread.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;Threads&lt;/a&gt;, Semaphores, etc, multiple stacks&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa-UML&quot; rel=&quot;nofollow noreferrer&quot;&gt;UML&lt;/a&gt; Capsules and Connectors, dependency driven programming&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are plenty examples on how to use these. A good starting point is the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/tree/master/examples/Blink&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blink&lt;/a&gt; sketches. There is even a &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/examples/Blink/CosaBlinkThread/CosaBlinkThread.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;multi-threading Blink&lt;/a&gt; example with a thread that does the LED on/off and a controller thread that periodically changes the blink period. The thread stack size is only 64 bytes and it runs even on an ATtiny. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all the AVR internal hardware modules (such as SPI, TWI, UART, etc) there is plenty of opportunities for concurrency.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheduler&lt;/a&gt; library for the Arduino core is also available. This is a port of the Cosa Threads. Please see github for further details. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2017-01-31T14:16:19.027" LastActivityDate="2017-01-31T14:16:19.027" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18549" PostTypeId="2" ParentId="9243" CreationDate="2015-12-09T01:09:14.037" Score="2" Body="&lt;p&gt;Welcome to the wide world of Communications.  You are asking about &lt;a href=&quot;https://en.wikipedia.org/wiki/Error_detection_and_correction&quot; rel=&quot;nofollow&quot;&gt;&quot;Error Detection and Correction&quot;&lt;/a&gt;.  This is different from &quot;framing&quot;, which allows you to determine when a message starts and ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With &quot;error detection&quot;, you know there was an error, but you can't necessarily recover from it.  With &quot;correction&quot;, you know there was an error and you &lt;em&gt;can&lt;/em&gt; determine what was originally sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;always&lt;/em&gt; requires extra bytes.  There are many schemes, but the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fletcher%27s_checksum&quot; rel=&quot;nofollow&quot;&gt;Fletcher checksum&lt;/a&gt; for Error Detection is easy to implement, fast, and only requires 2 extra bytes in the message (4 if hex digits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The generic approach is to use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;finite-state machine&lt;/a&gt;.  In complicated message protocols, there would be nested state machines: the inner-most would probably determine framing, the next one out might looks at addressing, etc.  Any or all of those layers could use Error Detection and/or Correction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your simple &quot;protocol&quot;, a single state machine is probably sufficient.  The states might be IDLE, RX_PAYLOAD and RX_CS.  As characters are received, they are processed according to the current state and occasionally change the state variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial.available()) {&#xA;  uint8_t c = Serial.read();&#xA;  switch (state) {&#xA;    case IDLE:&#xA;      if (c == MSG_START)&#xA;        state = RX_PAYLOAD;&#xA;      break;&#xA;    case RX_PAYLOAD:&#xA;      if (c == MSG_END) {&#xA;        state = RX_CS;&#xA;        cs = 0;&#xA;        csCount = 0;&#xA;      } else if (length &amp;lt; MAX_LENGTH-1) {&#xA;        msg[ length++ ] = c;&#xA;      }&#xA;      break;&#xA;    case RX_CS:&#xA;      //  Add in the next hex CS digit&#xA;      cs = cs * 16 + fromHex(c);&#xA;      if (++csCount == 2) {&#xA;        // both digits received, see if the CS matches&#xA;        if (cs == csOfMsg( msg, length )) {&#xA;          // Handle the message&#xA;          msg[ length ] = '\0';&#xA;          Serial.println( msg );&#xA;        } else {&#xA;          Serial.println( F(&quot;Bad message!&quot;) );&#xA;        }&#xA;        state = IDLE;&#xA;      }&#xA;      break;&#xA;  } // end switch&#xA;} // end while&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are entire books written on protocols and their design.  This is just a made-up example to give you an idea of how it should be structured: a finite state machine, driven by received character &quot;events&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes you can compute the checksum as the characters are received, like Fletcher.  Here, it waits until the entire message plus 2 CS bytes are received.  &lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2015-12-09T01:15:45.973" LastActivityDate="2015-12-09T01:15:45.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18550" PostTypeId="2" ParentId="18530" CreationDate="2015-12-09T01:15:51.167" Score="1" Body="&lt;p&gt;There are some fundamental problems in the code - &lt;code&gt;bufferPosition&lt;/code&gt; never stops increasing (until it reaches 32768) and so &lt;code&gt;buffer&lt;/code&gt; will overflow. However, neither of these two problems are causing the 'trash', as you are outputting the result of reading the serial, not anything from the buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem lies in the casting of the result from &lt;code&gt;BTSerial.read()&lt;/code&gt; to &lt;code&gt;unsigned char&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.print()&lt;/code&gt; does not like this. Actually it doesn't care, but it won't give you what you expect. It just prints out the value stored - so 'a', which is 97, will come out as '97' on the serial monitor. &lt;code&gt;Serial.print()&lt;/code&gt; only outputs ASCII characters when you give it a &lt;code&gt;char&lt;/code&gt; or &lt;code&gt;char[]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-12-09T01:15:51.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18551" PostTypeId="1" CreationDate="2015-12-09T02:09:30.410" Score="2" ViewCount="339" Body="&lt;p&gt;I just uploaded a sketch of a song to my Arduino and it works well.  Could I just take the chip out and hook up speakers to it and a power source to play the song? and just get another chip and put it in the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="15456" LastActivityDate="2015-12-09T14:01:17.570" Title="Taking off the chip from Arduino" Tags="|atmega328|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18552" PostTypeId="2" ParentId="18551" CreationDate="2015-12-09T03:23:53.407" Score="2" Body="&lt;p&gt;Yes and no. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To elaborate, the sketch you downloaded to the chip has been flashed to internal non-volatile memory. So if you were to move it to &lt;em&gt;another&lt;/em&gt; Arduino board or other device with the appropriate support hardware, then it should work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you're intending to directly hook-up speakers to it and a power source, then I highly doubt it's going to work. You really need some support hardware for the chip (such as an external clock - though I think the Atmega328 has an internal clock, decoupling capacitors, amplifiers for the spearkers, etc.).&lt;/p&gt;&#xA;" OwnerUserId="10383" LastActivityDate="2015-12-09T03:23:53.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18553" PostTypeId="2" ParentId="18492" CreationDate="2015-12-09T03:46:14.610" Score="0" Body="&lt;p&gt;The PIR sensors are actually pretty cheap: &lt;a href=&quot;http://www.ebay.com/itm/like/171338717482?ul_noapp=true&amp;amp;chn=ps&amp;amp;lpid=82&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/like/171338717482?ul_noapp=true&amp;amp;chn=ps&amp;amp;lpid=82&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2015-12-09T03:46:14.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18554" PostTypeId="2" ParentId="18492" CreationDate="2015-12-09T04:11:55.437" Score="1" Body="&lt;p&gt;You would be better off with a bare ATmega chip than an Arduino - you want to eliminate extraneous circuitry like a USB converter, regulators with quiescent current draw, and any resistors pulling signals against their usual state.  Fortunately the ATmega chip has a fairly wide voltage range, especially at 8 MHz or below, so you can use something like 3 cells, alkaline or rechargeable, over most of their range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An SDcard is neither necessary, nor a good idea.  If your circuit won't be discovered you can probably hold the data in static ram while the ATmega sleeps; if not, the quantity of data would probably not exceed the on-chip EEprom and would certainly not exceed that of a 4 megabyte SPI flash. Either of these will be far more robust (and low power) in a battery powered situation than an SD card.  They will also be simpler to support in software.  Either an SPI flash or an SDcard will probably have a narrower supply range the the ATmega and require a regulator - you may be able to enable that only when you need to access the memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your main power consumption win however will be sensors.  If you can use a contact sensor - either a direct switch, or a magnetic reed one, that will result in the lowest power consumption.  Your next option might well be an accelerometer chip, specifically if you choose one which can run in a micropower mode and fire a wakeup interrupt to the MCU when it detects that a door it is mounted on is being opened.  Anything with light is likely to have much higher power consumption and could well be impractical, unless you figure out how to operate it in short bursts with a lengthy inactive time in between. &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-12-09T04:11:55.437" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18555" PostTypeId="2" ParentId="18531" CreationDate="2015-12-09T05:58:36.123" Score="2" Body="&lt;p&gt;Yes, the -c option specifies the methods of interacting with the device's loader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The source code of the arduino programmer is &lt;a href=&quot;http://svn.savannah.nongnu.org/viewvc/trunk/avrdude/arduino.c?root=avrdude&amp;amp;view=markup&quot; rel=&quot;nofollow&quot;&gt;http://svn.savannah.nongnu.org/viewvc/trunk/avrdude/arduino.c?root=avrdude&amp;amp;view=markup&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, '-c arduino' chooses the client side code tailored to the bootloader in the Arduino Uno.  Looking at the code in the above link, it tweaks the DTR and RTS lines to get the Ardunino into an stk500 compatible mode, and then invokes the stk500 protocol. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2015-12-13T15:21:46.110" LastActivityDate="2015-12-13T15:21:46.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18557" PostTypeId="2" ParentId="18255" CreationDate="2015-12-09T08:38:52.477" Score="2" Body="&lt;p&gt;If you are using linux, as I guess, you can look at &lt;a href=&quot;https://wiki.archlinux.org/index.php/Working_with_the_serial_console&quot; rel=&quot;nofollow&quot;&gt;this archwiki page&lt;/a&gt;. Even if is a wiki relative to archlinux OS some informations explained are LinuxOS independendent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your needs, you can use screen command. Here is an example: remember to substitute the serial port with the one wich arduino is connected (usually /dev/ttyACM* or /dev/ttyUSB*) and to specify the right baud rate.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screen /dev/ttyACM0 9600&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15465" LastActivityDate="2015-12-09T08:38:52.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18558" PostTypeId="1" CreationDate="2015-12-09T09:48:09.690" Score="-2" ViewCount="263" Body="&lt;p&gt;I downloaded the Processing language and ran the &quot;Hello World&quot; program to test it. The message appears in the Serial console but not on the Processing console. It prints &quot;null&quot; only. I am using the code supplied by Sparkfun. Other people have had this problem. I am looking for clear explanation and solution.&lt;/p&gt;&#xA;" OwnerUserId="15467" LastActivityDate="2015-12-09T14:44:37.113" Title="Why won't processing not communicate with Arduino uno?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18559" PostTypeId="2" ParentId="18533" CreationDate="2015-12-09T12:46:32.253" Score="2" Body="&lt;p&gt;You could develop a REST based service, to make Arduino consume web service using the &lt;a href=&quot;https://github.com/marcoschwartz/aREST&quot; rel=&quot;nofollow&quot;&gt;aRest&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is a tutorial of how to use the aRest API with Arduino: &lt;a href=&quot;https://learn.adafruit.com/a-rest-api-for-arduino-and-the-cc3000-wifi-chip?view=all&quot; rel=&quot;nofollow&quot;&gt;A REST API for Arduino &amp;amp; the CC3000 WiFi Chip&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="12089" LastEditorUserId="3917" LastEditDate="2015-12-31T19:50:13.233" LastActivityDate="2015-12-31T19:50:13.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18560" PostTypeId="1" CreationDate="2015-12-07T14:59:13.747" Score="2" ViewCount="2087" Body="&lt;p&gt;I am working on a project in which I have made a robot powered by 4 Johnson DC motors (300 rpm) and controlled by Arduino UNO R3. Now in my project I'd used ultrasonic sensor (HC-SR04) for detecting obstacles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is that as soon as my an obstacle is detected robot should turn by 180° but what actually happening is that sometimes robot takes turn very late (though I'd kept range of sensor approximately 50cm) and sometimes it just collides with obstacles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I'm new to Arduino I just want to know if an ultrasonic sensor is fast enough to sense obstacles and signal the Arduino about it, before it gets close enough?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sense()&#xA;{&#xA;     analogWrite(trigPin, 0);&#xA; // instead of digitalWrite(trigPin,LOW);&#xA;     delayMicroseconds(2); &#xA;&#xA;/* as I'd used my digital pins for  motors and all i have to use pwm pin for  trigger pin of sensors i guess it doesn't make any difference*/&#xA;&#xA;     analogWrite(trigPin, 255);&#xA;  // instead of digitalWrite(trigPin, HIGH);&#xA;     delayMicroseconds(10); &#xA;&#xA;     analogWrite(trigPin, 0);&#xA;     duration = pulseIn(echoPin, HIGH);&#xA;&#xA;     distance = duration/58.2;&#xA;&#xA;      if (distance &amp;gt; maximumRange)&#xA;          return 0;&#xA;      else&#xA;          return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15504" OwnerDisplayName="NISHANT DESAI" LastEditorUserId="6936" LastEditDate="2016-01-04T19:40:40.713" LastActivityDate="2016-02-03T21:03:48.683" Title="Is a HC-SR04 fast enough to make decisions on moving robot (4 Johnson motors 300 rpm)?" Tags="|sensors|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18561" PostTypeId="2" ParentId="18551" CreationDate="2015-12-09T14:01:17.570" Score="0" Body="&lt;p&gt;Easy part first: You CAN put another chip on arduino PROVIDED that chip already has a bootloader on it. If it's a raw chip, burn the bootloader on it first. &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;This guide will help&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You CAN connect the programmed chip to speaker PROVIDED you add the minimal circuit components required for an arduino to run. These include - a 16 MHz crystal, two 22 pf capacitors and a 10K resistor. Use the schematic in the bootloader guide. That will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides this, you will require a 5V power source. You can alternatively use 3xAA cells (4.5V will work perfectly). Alternatively use a wall adapter of 7V or higher and use a linear regulator (7805) to generate a perfect 5V supply for your arduino. You will need this pin mapping diagram to connect the speaker to arduino once you take it out from the board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NxqQs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NxqQs.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7553" LastActivityDate="2015-12-09T14:01:17.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18562" PostTypeId="2" ParentId="12545" CreationDate="2015-12-09T14:35:12.363" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino only performs Serial.read at 20 millisecond intervals.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It sounds like you're using &lt;code&gt;delay&lt;/code&gt; to pace the reads.  But why?  You'll start to lose data after reading just 3 or 4 characters (60ms to 80ms).  Serial at 9600 can send 1 character per millisecond, 20 times faster than you are reading them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you edit your post to include your code, we might be able to make a suggestion to eliminate that delay.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-09T14:35:12.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18563" PostTypeId="2" ParentId="18558" CreationDate="2015-12-09T14:44:37.113" Score="1" Body="&lt;p&gt;I apologize for presenting a vague question. I was unable to successfully run the simple code to learn &quot;serial communication&quot; presented by Sparkfun on: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step 1. Run Arduino to produce &quot;Hello, World&quot; on the Serial Port.&#xA;Step 2. Run Progressing 3.0.1 to produce &quot;Hello, World&quot; on its console.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code from the website are copied and pasted onto my iMac running El Capitan. I received an error message for Step 2 stating the &quot;port is busy.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I closed the Arduino (Step 1) and compiled and ran Step 2, it worked!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several other people found different solutions. My solution is simple. Run one program at a time.&lt;/p&gt;&#xA;" OwnerUserId="15467" LastActivityDate="2015-12-09T14:44:37.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18564" PostTypeId="1" AcceptedAnswerId="18565" CreationDate="2015-12-09T17:23:51.430" Score="0" ViewCount="225" Body="&lt;p&gt;I would like to use the external analog refence voltage in an Attiny88 project I am working on that will be powered with batteries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the datasheet for this processor does not show an Aref pin like other versions of the attiny, like attiny85 and attiny84, where it is usually the pin PA0 or PB0. Does anyone know where is the pin for the external voltage reference in attiny88 (e.i. Aref pin)? Does this chip has the functionality for an external analog reference voltage?&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2015-12-09T17:39:26.617" Title="Where is the Aref pin for Attitny88" Tags="|voltage-level|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18565" PostTypeId="2" ParentId="18564" CreationDate="2015-12-09T17:39:26.617" Score="5" Body="&lt;p&gt;As shown in the detailed information for the ADMUX register in the ADC section of the datasheet, the ATtiny88 has no external voltage reference. Consider using a ATmega8 or ATmega88PB instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-09T17:39:26.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18566" PostTypeId="2" ParentId="9030" CreationDate="2015-12-09T18:47:42.530" Score="5" Body="&lt;p&gt;It is not a JST connector. There are ramps on the side of the connector that won't allow the grove/seeed cables slide into the connectors. After I shaved/cut off the ramps, to allow them to fit into the connector, I found that the pins are slightly offset in there vertical alignment. &#xA;This appears to be a custom connector. However, if anyone knows better, I would be interested, but the answer is not JST.&lt;/p&gt;&#xA;" OwnerUserId="15478" LastActivityDate="2015-12-09T18:47:42.530" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18567" PostTypeId="2" ParentId="17885" CreationDate="2015-12-09T19:19:02.993" Score="1" Body="&lt;p&gt;In addition to the other methods listed, which will both work, you could also use an Arduino that uses 3.3V logic and connect the serial/UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Trinket: &lt;a href=&quot;https://www.adafruit.com/products/1500?gclid=COGOxqq-z8kCFcYRHwodpL8P2A&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1500?gclid=COGOxqq-z8kCFcYRHwodpL8P2A&lt;/a&gt;&#xA;Pro 328: &lt;a href=&quot;https://www.sparkfun.com/products/10914&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10914&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15478" LastActivityDate="2015-12-09T19:19:02.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18568" PostTypeId="1" CreationDate="2015-12-09T19:38:05.427" Score="1" ViewCount="3959" Body="&lt;p&gt;I'm working on a morse transmitter (kind-a), this how it looks like now:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RYiYq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RYiYq.png&quot; alt=&quot;Arduino-button-potentiometer-piezobuzzer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's working, but is it correct? My piezo buzzer is 3-24V. I use the potentiometer as a volume control. The button is for transmitting morse code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen a way of wiring like this, not using any resistors, it feels wrong, is it correct?&#xA;&lt;a href=&quot;https://cdn.sparkfun.com/assets/learn_tutorials/3/1/0/Arduino_circuit_11_01.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cdn.sparkfun.com/assets/learn_tutorials/3/1/0/Arduino_circuit_11_01.png&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15454" LastEditorUserId="15454" LastEditDate="2015-12-09T20:00:02.777" LastActivityDate="2015-12-09T20:15:49.090" Title="What is the correct way to wire a piezzo buzzer with a potentiometer and a button?" Tags="|arduino-uno|button|potentiometer|piezo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18569" PostTypeId="1" AcceptedAnswerId="18570" CreationDate="2015-12-09T16:02:12.277" Score="3" ViewCount="13571" Body="&lt;p&gt;I have an &lt;strong&gt;Arduino Micro&lt;/strong&gt; where I want to control a display with IR commands. So the Arduino should send the IR commands to the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found a library &quot;&lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;Arduino-IRremote&lt;/a&gt;&quot;, which I am using to transmit Commands to the display. The display works perfectly with its remote control, however I can't get it accept signals from my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the special part about my setup is, that I do not use a &quot;classic&quot; IR transmitter. Instead i uset an IR cable, which is connected to &quot;IR-In&quot; of the display. So no LED - only a wired connection. The IR-cable consists of 3 wires. 2 for power supply (VIN and GND) and one is for the data connection. The wire with the data connection is connected with the Arduino PWM pin 3 (like it is said on the example in the linked library), but I tried all other pins anyway.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;IRsend irsend;&#xA;&#xA;void loop() {&#xA;&#xA;  for (int i = 0; i &amp;lt; 2; i++) {&#xA;    digitalWrite(RXLED, HIGH);&#xA;    irsend.sendNEC(0x004eff71, 32);&#xA;    Serial.println( &quot;sendNEC 00 4E FF 71&quot; );&#xA;    digitalWrite(RXLED, LOW);&#xA;    delay(40);&#xA;&#xA;  }&#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;004eff71&lt;/code&gt; is a NEC-Command from the original remote control&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now can somebody tell me, what I'm doing wrong? The program compiles and the LED lights up, everytime it should send the NEC-command. But still the display receives nothing.&#xA;What is wrong?&lt;/p&gt;&#xA;" OwnerUserId="15493" OwnerDisplayName="Maikell" LastEditorUserId="15493" LastEditDate="2015-12-10T14:46:43.320" LastActivityDate="2023-02-10T22:59:54.627" Title="Sending IR (NEC)-Signals with Arduino" Tags="|hardware|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18570" PostTypeId="2" ParentId="18569" CreationDate="2015-12-09T16:17:35.570" Score="3" Body="&lt;p&gt;It isn't working probably because the output of the Arduino isn't simply an on/off signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That library uses a pulse width modulated output on the Arduino to drive an LED.  &lt;strong&gt;When the LED is &quot;on&quot; the signal driving it is actually pulsing at a very high rate.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what all you'd have to change to make that work with a direct wired connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing that might becausing problems is that without checking, you can't be sure that the signal level you are sending matches the levels that the IR receiver would normally produce. &lt;/p&gt;&#xA;" OwnerUserId="10567" OwnerDisplayName="JRE" LastActivityDate="2015-12-09T16:17:35.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18571" PostTypeId="2" ParentId="18568" CreationDate="2015-12-09T20:15:49.090" Score="1" Body="&lt;p&gt;You are using the Arduino basically as a power supply (in your wiring). The linked wiring is for PWM (analogWrite). This allows pulse output to generate tone (and volume). Here is a good &lt;a href=&quot;http://www.varesano.net/blog/fabio/pwm-and-arduino-fading-led-and-playing-melodies-piezo-speaker&quot; rel=&quot;nofollow&quot;&gt;reference&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-09T20:15:49.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18572" PostTypeId="1" CreationDate="2015-12-09T20:28:48.230" Score="2" ViewCount="763" Body="&lt;p&gt;I am trying to read data from the Serial port in my Arduino, store it in a buffer and when all the data has been read stop reading and then start using the data (the talkMIDI() function). The Arduino succesfully some bytes from Serial but not all of them and then hangs without stopping before the end.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if (!stop) &#xA;  {&#xA;    char in = Serial.read();&#xA;    if (in != -1)&#xA;    {&#xA;      buffer[pos] = in;&#xA;      pos++;&#xA;      Serial.write(&quot;read&quot;);&#xA;      Serial.print(pos);&#xA;      Serial.print(&quot;\r\n&quot;);&#xA;    }&#xA;    if (in == 126)&#xA;    {&#xA;      stop = 1;&#xA;      Serial.write(&quot;STOP&quot;);&#xA;    }&#xA;  }&#xA;  else&#xA;  {&#xA;    if (cursor &amp;lt; pos)&#xA;    {&#xA;      talkMIDI (buffer[cursor], buffer[cursor+1], buffer[cursor+2]);&#xA;      cursor = cursor+3;&#xA;      delay(500);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After manually sending a 126 value (~) character, I get a &quot;STOP&quot; response on the Serial line but Arduino doesn't start executing the code from the else branch (the talkMIDI() part -- the function doesn't even get called once).&lt;/p&gt;&#xA;" OwnerUserId="10942" LastEditorUserId="10942" LastEditDate="2015-12-09T21:05:57.213" LastActivityDate="2015-12-09T21:05:57.213" Title="How to read all avaiable data from a Serial stream and then stop" Tags="|arduino-uno|softwareserial|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18573" PostTypeId="2" ParentId="18255" CreationDate="2015-12-09T22:12:04.840" Score="0" Body="&lt;p&gt;I ended up simply switching to &lt;a href=&quot;https://github.com/scottdarch/Arturo&quot; rel=&quot;nofollow&quot;&gt;ano&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-12-09T22:12:04.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18574" PostTypeId="1" CreationDate="2015-12-09T22:56:07.153" Score="1" ViewCount="3514" Body="&lt;p&gt;Learning how to program with Arduino, but the learning curve is out of my league.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;FastLED.h&amp;gt;&#xA;    #define NUM_LEDS 4&#xA;    #define DATA_PIN 3&#xA;&#xA;        CRGB leds[NUM_LEDS];&#xA;&#xA;           void setup() { &#xA;       FastLED.addLeds&amp;lt;NEOPIXEL, DATA_PIN&amp;gt;(leds, NUM_LEDS);&#xA;   }&#xA;&#xA;       void loop() {&#xA;      // Turn the first led red for 1 second&#xA;      leds[0] = CRGB::Green; &#xA;      leds[1] = CRGB::Red;&#xA;      leds[2] = CRGB::Green; &#xA;      leds[3] = CRGB::Red;&#xA;      FastLED.show( 99 );&#xA;      delay(1000);&#xA;&#xA;      // Set the first led back to black for 1 second&#xA;      leds[0] = CRGB::Red; &#xA;      leds[1] = CRGB::Green;&#xA;      leds[2] = CRGB::Red; &#xA;      leds[3] = CRGB::Green; &#xA;      FastLED.show( 99 );&#xA;      delay(1000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I want them to fade from green to red.&#xA;led 1 is green, and led 2 is red&#xA;I should probably program this in a different way, but I don't know how.&#xA;Any ideas are welcome!&lt;/p&gt;&#xA;" OwnerUserId="8162" LastActivityDate="2015-12-10T16:49:09.887" Title="FastLED fade WS2812B" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18575" PostTypeId="1" AcceptedAnswerId="19055" CreationDate="2015-12-10T04:26:14.473" Score="12" ViewCount="110255" Body="&lt;p&gt;&lt;strong&gt;GOAL&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Arduino UNO, send AT commands to ESP8266 via a SoftwareSerial port and receive results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CURRENT STATUS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I either send AT commands and get nothing back (&lt;em&gt;wiring scheme 1&lt;/em&gt;) or I send AT commands and get garbage back (&lt;em&gt;wiring scheme 2&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the Arduino as a pass through (as explained in the tutorial listed in the resources section), I can send AT commands. I have found that I can communicate with the ESP8266 at 115200 baud. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the results of running &lt;code&gt;AT+GMR&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT version:0.40.0.0(Aug  8 2015 14:45:58)&#xA;SDK version:1.3.0&#xA;Ai-Thinker Technology Co.,Ltd.&#xA;Build:1.3.0.2 Sep 11 2015 11:48:04&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;WIRING SCHEME 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;!! I have the green wire attached to pin 3 on the Arduino Uno and the yellow wire attached to pin 2; not 1 and 0 as the picture suggests !!&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0yEju.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0yEju.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;WIRING SCHEME 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same wiring as above, but I have RX and TX reversed. The green wire is attached to pin 2 and the yellow wire is attached to pin 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;This is running on Arduino Uno&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(2, 3);&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(115200);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  Serial.println(&quot;Started&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  esp8266.begin(115200);&#xA;  esp8266.write(&quot;AT\r\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (esp8266.available()) {&#xA;    Serial.write(esp8266.read());&#xA;  }&#xA;  if (Serial.available()) {&#xA;    esp8266.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;RESULTS FROM RUNNING SKETCH&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Wiring Scheme 1&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Started&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Wiring Scheme 2&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Started&#xA;�����&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tested the ESP8266 via the instructions listed in the tutorial in the &lt;em&gt;Resources I've Used&lt;/em&gt; section below. The ESP8266 works just fine when sending it instructions via the Serial Prompt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;RESOURCES I'VE USED&lt;/strong&gt;&#xA;&lt;a href=&quot;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;QUESTION&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if what I am trying to do is possible? And if it is, what am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="15491" LastEditorUserId="26916" LastEditDate="2017-09-10T00:53:13.617" LastActivityDate="2018-02-14T09:55:44.910" Title="Send AT commands to ESP8266 from Arduino Uno via a SoftwareSerial port" Tags="|arduino-uno|esp8266|softwareserial|" AnswerCount="6" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18576" PostTypeId="1" CreationDate="2015-12-10T04:41:06.993" Score="0" ViewCount="131" Body="&lt;p&gt;Im using an SRf02 ultrasonic sensor, and I need to make the wires long to elevate the sensor. They turn on and blink and are able to transmit a signal, yet they are not able to receive a signal. What is the error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vB0YI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vB0YI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="15032" LastEditDate="2015-12-10T21:24:23.003" LastActivityDate="2015-12-10T21:24:23.003" Title="Wire over 1ft does not work with sensors SRF02" Tags="|sensors|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18579" PostTypeId="2" ParentId="18574" CreationDate="2015-12-10T10:54:22.227" Score="1" Body="&lt;p&gt;At the moment you have become used to working with pre-defined named colours, like CRGB::Red and CRGB::Green.  Those are just symbolic names for combinations of numeric values for red, green and blue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So by using numeric values and varying them slightly over time you can create fade effects.  I am not personally familiar with that library or class, so I cannot tell you how to do it, but reading the documentation should show you how you can use variables to specify each of the colour components as a single colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for how to fade from red to green - since they are two completely separate colours (they use separate colour channels in the LEDs) there are two main ways of doing it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start with red on full and green off. Slowly increase green to get yellow. Then slowly decrease red to get green.&lt;/li&gt;&#xA;&lt;li&gt;Start with red on full and green off. Slowly increase green while slowly decrease red. At 50% they will cross over.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-10T10:54:22.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18580" PostTypeId="1" AcceptedAnswerId="18581" CreationDate="2015-12-10T11:56:25.193" Score="0" ViewCount="825" Body="&lt;p&gt;This is more of a thought experiment, as I don't know if I'll have the time to work on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Items:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/ARDUINO-SOLAR-CHARGE-CONTROLLER-Version-30/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;Homebrew MPPT controller from Instructables&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://i.stack.imgur.com/9iE2z.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;LM2596 Adjustable Buck Regulator&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Idea:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the Instructable, that seems like a fairly interesting and robust circuit, originally developed by one Tim Nolan whose website no longer seems to exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm somewhat lazy/fearful of messing things up when building from scratch, so I like to get preassembled modules and tinker instead. So, my thought is simple (ish). Looking at the LM2596 module, the output voltage is determined by the setting of the multiturn pot. I'd like to replace that pot with, say, a PWM controlled voltage from an Arduino, which I can then adjust using Tim Nolan's code to achieve MPPT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to be very specific, the question is: can I safely remove that pot and use a PWM'd voltage in its place, in order to control the output for MPPT?&lt;/p&gt;&#xA;" OwnerUserId="11375" LastActivityDate="2015-12-10T16:43:08.967" Title="MPPT using preassembled 'adjustable' buck/boost IC" Tags="|arduino-uno|pwm|solar|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18581" PostTypeId="2" ParentId="18580" CreationDate="2015-12-10T13:24:57.310" Score="1" Body="&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The switching frequency of the LM2596 is 150kHz, but the sampling frequency of the Arduino is only 10kHz (on a good day).  You won't be able to adjust the PWM quickly enough to fine-tune the LM2596 output voltage.  The LM2596 uses the 1.23V feedback voltage to change what it's doing.  But the feedback voltage will only change as fast as the Arduino can change the PWM feeding it (and that the RC smoother will allow).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will be like pushing a shopping cart backwards, blindfolded.  By the time you feel the directional change in the cart, it will have steered off course by quite a bit.  Then you have to compensate wildly to bring it back on course.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same would probably happen here: the LM2596 would begin adjusting the output voltage to make the feedback voltage come back towards 1.23V.  But the Arduino doesn't respond in time.  The Arduino has to do an ADC conversion, do some calculations, change the PWM, which eventually changes the RC output voltage, which is the feedback voltage.  So the LM2596 changes some more... and even more.  Eventually the feedback voltage does change, but by this time the output voltage has changed significantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to look at is that the LM2596 is like another &quot;processor&quot;, trying to optimize its own function, output voltage instead of MPPT.  It's running much faster than the Arduino, so there's no way the Arduino can trick the LM2596 into doing what it &lt;em&gt;really&lt;/em&gt; wants, MPPT.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-10T13:24:57.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18582" PostTypeId="1" AcceptedAnswerId="18584" CreationDate="2015-12-10T14:52:36.410" Score="3" ViewCount="2513" Body="&lt;p&gt;I need to generate en (extended) NEC signal. I have connected an Arduino with a display-device via an IR cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Arduino --&amp;gt; IR-cable --&amp;gt; IR-input of display device&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;IR-cable:&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rAIhP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rAIhP.jpg&quot; alt=&quot;IR Cable datasheet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One plug is cutted and the 3 wires are connected with the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino should generate NEC Signals, and the display shall react to it. Basically the arduino acts like a wired remote control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is: There are many tutorials around, that show how to do this with a sensor (e.g by using this &lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow noreferrer&quot;&gt;library&lt;/a&gt;). But none of the tutorials says how to do it with a cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out, my previous attempts all failed, because I tried to generate a modulated NEC-signal to the display. The display however does not understand it, because there is no device that demodulates the signal. The IR sensor normally does this, which is missing in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&#xA;This is, what an modulated NEC signal looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00 4e ff 61&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library generates the moduled signal (pulse bursts) and this is how it works for IR sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how do I have to send my IR-command, that the display understands it? How do I send a not-modulated IR signal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The following graphic demonstrates the issue:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://files.cablewholesale.com/mailimages/ir-transmission.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://files.cablewholesale.com/mailimages/ir-transmission.gif&quot; alt=&quot;IR&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not have IR-LED Transmitter, Amplifier, Limiter, Band Pass Filter, Demodulator, Integrator, Comparator....&#xA;I just want to create the green Output-signal directly from my Arduino&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="15493" LastEditDate="2015-12-11T10:45:50.650" LastActivityDate="2024-02-27T12:39:39.523" Title="How to send unmodulated IR-Signal via cable?" Tags="|ir|arduino-micro|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18583" PostTypeId="2" ParentId="9030" CreationDate="2015-12-10T14:58:28.233" Score="12" Body="&lt;p&gt;It looks like the Grove connector is proprietary. I emailed Seeedstudio, and they directed me to &lt;a href=&quot;https://statics3.seeedstudio.com/images/opl/datasheet/3470130P1.pdf&quot; rel=&quot;noreferrer&quot;&gt;this datasheet&lt;/a&gt;. Unless I'm reading it incorrectly, it doesn't appear to correspond to any type of JST connector, although it's similar. It has 2mm pin spacing, which would make it closest to the &lt;a href=&quot;https://www.sparkfun.com/datasheets/Prototyping/ePH.pdf&quot; rel=&quot;noreferrer&quot;&gt;JST-PH type&lt;/a&gt;, but all the other dimensions are slightly different.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="3134" LastEditDate="2017-12-28T21:54:52.623" LastActivityDate="2017-12-28T21:54:52.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18584" PostTypeId="2" ParentId="18582" CreationDate="2015-12-10T15:07:42.070" Score="4" Body="&lt;p&gt;There are two major components to an infra-red signal.  One is the high frequency carrier wave signal that pulses the LED on and off.  This frequency has to match that of the receiver and is used with either a high-pass or band-pass filter to filter out ambient IR light and allow it to only react to a real signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second component, and it sounds like this is the one you are interested in, is the on-off pulsing of that carrier wave in different combinations and with different timings to denote binary 0 and 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Without knowing what your cable actually is, and we'd need to see a datasheet to get all the proper information, all this is just surmising.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would imagine that you provide power and ground to the emitter cable, and the third pin is a logical &quot;on/off&quot; signal that enables and disables the carrier frequency to the LED.  That would allow you to send any codes you like as long as you know the timing of the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the library you link to is all the timing you need in the ir_NEC.cpp file.  The times are defined as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define NEC_BITS          32&#xA;#define NEC_HDR_MARK    9000&#xA;#define NEC_HDR_SPACE   4500&#xA;#define NEC_BIT_MARK     560&#xA;#define NEC_ONE_SPACE   1690&#xA;#define NEC_ZERO_SPACE   560&#xA;#define NEC_RPT_SPACE   2250&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual data format is defined in the &lt;code&gt;sendNEC&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void  IRsend::sendNEC (unsigned long data,  int nbits)&#xA;{&#xA;    // Set IR carrier frequency&#xA;    enableIROut(38);&#xA;&#xA;    // Header&#xA;    mark(NEC_HDR_MARK);&#xA;    space(NEC_HDR_SPACE);&#xA;&#xA;    // Data&#xA;    for (unsigned long  mask = 1UL &amp;lt;&amp;lt; (nbits - 1);  mask;  mask &amp;gt;&amp;gt;= 1) {&#xA;        if (data &amp;amp; mask) {&#xA;            mark(NEC_BIT_MARK);&#xA;            space(NEC_ONE_SPACE);&#xA;        } else {&#xA;            mark(NEC_BIT_MARK);&#xA;            space(NEC_ZERO_SPACE);&#xA;        }&#xA;    }&#xA;&#xA;    // Footer&#xA;    mark(NEC_BIT_MARK);&#xA;    space(0);  // Always end with the LED off&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;mark&lt;/code&gt; and &lt;code&gt;space&lt;/code&gt; functions take a number of microseconds to perform either an ON or OFF of the PWM signal.  That is somewhat simpler for you, since it is just an ON or OFF of a digital IO pin to control the output of the emitter cable.  So where you have a MARK you turn on the output, then delay for the specified time. For a space you turn off the output and again delay for the specified time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can just replicate the operation of that sendNEC function but with your own output control and timing in it instead of using the functions in that library.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; It seems the cable doesn't need power - just provide the ground connection and the signal connection.  Of course, this is assuming that it isn't just an LED on a wire.  If it is just an LED on a wire then you would need to just use the library you link to as it is.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-10T15:07:42.070" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18585" PostTypeId="2" ParentId="18068" CreationDate="2015-12-10T16:05:59.950" Score="1" Body="&lt;p&gt;I'm not an expert in HDMI/DDC, but I have some theories to remove potential problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&quot;Wire.onRequest/Wire.onReceive&quot; could be before &quot;digitalWrite(2, HIGH)&quot;, to really represent &quot;OK, you can send me data now&quot; (Arduino isn't the fastest HW, and Arduino libs add extra overhead - lots of condition races can occur);&lt;/li&gt;&#xA;&lt;li&gt;You could use &quot;Write.write(did, 256)&quot;, instead of writing one byte to I2C then another via serial (again, racing conditions, specially since serial writing is slow);&lt;/li&gt;&#xA;&lt;li&gt;If I'm not misunderstanding, the byte received from HDMI means the byte you should start transmitting EDID (ex: for &quot;0&quot;, do a &quot;Wire.write(edid, 128)&quot;, for &quot;0x80&quot;, do a &quot;Wire.write(edid + 0x80)&quot;). This is a common approach for reading from PROM chips. HDMI have a 5V pin to allow PROM reading from turned-off devices, and byte 127 from EDID means &quot;I may have more 128 bytes for you&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Are you doing simple tests, with unmodified data? Ex: read EDID from device X, test that same EDID, then test with modified data?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15498" LastActivityDate="2015-12-10T16:05:59.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18586" PostTypeId="2" ParentId="18580" CreationDate="2015-12-10T16:43:08.967" Score="1" Body="&lt;p&gt;The pot is actually part of the feedback mechanism, so you can just feed it a fixed voltage (based on PWM duty cycle). See the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lm2596.pdf&quot; rel=&quot;nofollow&quot;&gt;second diagram on page 9 of the datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could however replace it with a &lt;a href=&quot;https://www.sparkfun.com/products/10613&quot; rel=&quot;nofollow&quot;&gt;digital pot&lt;/a&gt; (not necessarily 10k).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-10T16:43:08.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18587" PostTypeId="2" ParentId="18574" CreationDate="2015-12-10T16:49:09.887" Score="1" Body="&lt;pre&gt;&lt;code&gt;//start with full red&#xA;leds[0].red = 255;&#xA;&#xA;//slowly add green&#xA;for( int i=0; i&amp;lt;256; i++ )&#xA;{&#xA;  leds[0].green = i;&#xA;  delay(10);&#xA;}&#xA;&#xA;// slowly subtract red&#xA;for( int i=255; i&amp;gt;=0; i-- )&#xA;{&#xA;  leds[0].red = i;&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-10T16:49:09.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18588" PostTypeId="1" AcceptedAnswerId="18628" CreationDate="2015-12-10T19:35:38.347" Score="0" ViewCount="297" Body="&lt;p&gt;I'm trying to get a TAE5767 (FM radio) to work. According to &lt;a href=&quot;http://www.instructables.com/id/TEA5767-FM-Radio-Breakout-Board-for-Arduino/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this instructable&lt;/a&gt; I'm trying it on a 5V-Olimexino 32u4 (Leonardo-compatible) with following code (Arduino 1.6.3):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setFrequency(float frequency) {&#xA;  unsigned int frequencyB = 4 * (frequency * 1000000 + 225000) / 32768;&#xA;  byte frequencyH = frequencyB &amp;gt;&amp;gt; 8;&#xA;  byte frequencyL = frequencyB &amp;amp; 0xFF;&#xA;  Wire.beginTransmission(0x60); &#xA;&#xA;  Wire.write(frequencyH);&#xA;  Wire.write(frequencyL);&#xA;  Wire.write(0xB0);&#xA;  Wire.write(0x10);&#xA;  Wire.write(0x00);&#xA;  Serial.println(&quot;sending&quot;);&#xA;  Wire.endTransmission();&#xA;  Serial.println(&quot;sent&quot;);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;  }&#xA;&#xA;  Wire.begin();&#xA;  setFrequency(89);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, it only prints&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sending&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First, I thought I'd damaged my chip, but I'm now using the second with the same result. I've also tried the I2C-Scanner from &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;Nick Gammon&lt;/a&gt;, but it prints nothing. I've tried adding 2.2k resistors from SCL and SDA to 5V without success. Does someone has a clue what I can try?&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2017-09-16T18:41:46.117" LastActivityDate="2017-09-16T18:41:46.117" Title="Olimexino 32u4: Wire.endTransmission() hangs" Tags="|i2c|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18589" PostTypeId="2" ParentId="18569" CreationDate="2015-12-10T19:43:18.587" Score="0" Body="&lt;p&gt;It would help to know the specifications of the IR input on the device you're trying to control but after a bit of googling it looks like most of them are just expecting a connection to an IR receiver. I found a link to what appears to be a common one, TSOP22.., TSOP24.., TSOP48.., TSOP44.. and here's a link to the data sheet (&lt;a href=&quot;http://www.vishay.com/docs/82459/tsop48.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.vishay.com/docs/82459/tsop48.pdf&lt;/a&gt;). If you check the Vo on page 2 it shows 0-5V. You didn't mention if you're using a 5V or 3V Arduino so that could be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PWM outputs do in fact generate square wave signals so at first glance this does not look like a hardware issue (assuming it is wired correctly for the IR input on your equipment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd start taking a look at the data you're trying to send. I haven't looked into the library you mentioned and hopefully it contains a sample to show how to properly initialize the library and send data. Maybe instead of first byte first it needs to be sent first byte last or requires a fixed number of bytes to send...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Providing more details about your project you might get a better answer.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastEditorUserId="7297" LastEditDate="2015-12-10T20:11:19.087" LastActivityDate="2015-12-10T20:11:19.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18590" PostTypeId="2" ParentId="18576" CreationDate="2015-12-10T19:44:30.253" Score="1" Body="&lt;p&gt;Using the internal pullup resistors for I2C is not recommended.  Arduino are very wrong in providing those as the default option and basically &quot;hiding&quot; the fact that I2C needs decent pullup resistors from you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The internal pullup resistors, because they are so weak (i.e., a high resistance, typically &gt; 50KΩ), do not pull the clock and data lines up adequately, and as such are only suitable for very short connections (in the order of a few inches).  Anything longer and the induced noise and inductance and capacitance of the wires will corrupt the I2C waveform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I2C requires pullup resistors in the range of 2.2KΩ to 4.7KΩ.  As you can see that is more than 10x the pullup strength of the internal resistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For off-board connections (i.e., wires) you want the lower end of that range.  So add a 2.2KΩ resistor between SCL and +5V and another between SDA and +5V and you should find it works much better.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-10T19:44:30.253" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18592" PostTypeId="2" ParentId="17147" CreationDate="2015-12-10T21:16:30.297" Score="2" Body="&lt;p&gt;Same problem here with this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Three step for me to make it work :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use method write() and not println()&lt;/li&gt;&#xA;&lt;li&gt;Send newline \n when talking to esp8266&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;don't wait newline to print the response&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;esp8266Serial.write(&quot;AT\n&quot;);&#xA;delay(100);&#xA;while (esp8266Serial.available() &amp;gt; 0 ) {&#xA;  char ch = esp8266Serial.read();&#xA;  Serial.println(ch);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I hope it helps&lt;/p&gt;&#xA;" OwnerUserId="15505" LastActivityDate="2015-12-10T21:16:30.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18595" PostTypeId="2" ParentId="2913" CreationDate="2015-12-11T00:20:02.947" Score="4" Body="&lt;p&gt;There is no need to measure the windings of the motor... please see the great write up for full details using an Arduino to sense the back EMF on a PWM driven motor to control the speed. This can be applied to a 3 phase motor as well, see &lt;a href=&quot;https://robidouille.wordpress.com/2009/09/20/back-emf/&quot; rel=&quot;nofollow&quot;&gt;Back EMF&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This person uses the analog input and a voltage divider to sense when the EMF happened, basically he gets the motor running, then periodically grounds one side of the motor through the H-Bridge he is using to drive it, and the other side of the  motor goes to a voltage divider into the Arduino... and it is also an open circuit at this time so the voltage generated is from the collapsing of the coil field so if it is 12V it becomes a safe 4V at the Arduino Analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your question says &quot;measure the back EMF&quot;, what I provided senses the back EMF... to measure it you just need to sample the Analog pin a bunch of times, and that will give you a reference of the max amplitude.&lt;/p&gt;&#xA;" OwnerUserId="15507" LastEditorUserId="6936" LastEditDate="2016-01-04T19:39:10.403" LastActivityDate="2016-01-04T19:39:10.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18598" PostTypeId="1" AcceptedAnswerId="18665" CreationDate="2015-12-11T02:57:42.673" Score="0" ViewCount="1016" Body="&lt;p&gt;I am trying to read data from an XV-11 sensor using the description of the format found here &lt;a href=&quot;https://xv11hacking.wikispaces.com/LIDAR+Sensor&quot; rel=&quot;nofollow&quot;&gt;https://xv11hacking.wikispaces.com/LIDAR+Sensor&lt;/a&gt;.  This is the code I am currently using to communicate with the computer by USB and the sensor with software serial on an arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  mySerial.begin(115200);&#xA;}&#xA;&#xA;int count = 0;&#xA;&#xA;void loop() &#xA;{ &#xA;    if(mySerial.available())&#xA;    {&#xA;      byte in = mySerial.read();&#xA;      Serial.println(in, HEX);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the data I am receiving on the computer is inconsistent with what I expect.  For example, I am expecting a 0xFA byte every 22 bytes, however this only sometimes happens.  Many times extra or fewer bytes appear in the middle of the data.  I am using the 5 volt arduino serial communication, however I have heard that it is still compatible with 3.3 V sensor communication, so I doubt it is the problem.  I don't thinkthe sensor is broken, as it is new from a working unit.&lt;/p&gt;&#xA;" OwnerUserId="15510" LastEditorUserId="15510" LastEditDate="2015-12-12T20:09:01.707" LastActivityDate="2017-04-07T15:44:39.710" Title="Read serial data from XV11 sensor" Tags="|arduino-uno|serial|sensors|softwareserial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18599" PostTypeId="1" CreationDate="2015-12-11T04:03:50.977" Score="0" ViewCount="26" Body="&lt;p&gt;trying print values for two sensors, one works the other is 0, any tips on how i can use more than one?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pingPin = 10;&#xA;const int pingPinz = 11;&#xA;unsigned int duration1, duration2, inches1, inches2;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  pinMode(pingPin, OUTPUT);          // Set pin to OUTPUT&#xA;  pinMode(pingPinz, OUTPUT);          // Set pin to OUTPUT&#xA;  digitalWrite(pingPin, LOW);        // Ensure pin is low&#xA;  digitalWrite(pingPinz, LOW);        // Ensure pin is low&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(pingPin, HIGH);       // Start ranging&#xA;  digitalWrite(pingPinz, HIGH);       // Start ranging&#xA;  delayMicroseconds(5);              //   with 5 microsecond burst&#xA;  digitalWrite(pingPin, LOW);        // End ranging&#xA;  digitalWrite(pingPinz, LOW);        // End ranging&#xA;  pinMode(pingPin, INPUT);           // Set pin to INPUT&#xA;  pinMode(pingPinz, INPUT);           // Set pin to INPUT&#xA;  duration1 = pulseIn(pingPin, HIGH); // Read echo pulse&#xA;  duration2 = pulseIn(pingPinz, HIGH); // Read echo pulse&#xA;  inches1 = duration1 / 74 ;        // Convert to inches&#xA;  inches2 = duration2 / 74 ;        // Convert to inches&#xA;  Serial.println(inches1);            // Display result&#xA;  Serial.println(inches2);            // Display result&#xA;  delay(200);                 // Short delay&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-12-11T09:59:01.657" Title="Printing Serial Readings for 2+ Parallax Ping Sensors" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18600" PostTypeId="1" CreationDate="2015-12-11T04:30:07.423" Score="0" ViewCount="712" Body="&lt;p&gt;I am working on a project which requires signal strength of a bluetooth TX and RX. what i assume is that in bluetooth module like hc05, there is an antenna receiver which reads the analog signal and then passes it to its ADC to get data in terms of 0's and 1's. But is there any way i can read the analog signal strength of the reveiver antenna directly? Please help&lt;/p&gt;&#xA;" OwnerUserId="15512" LastActivityDate="2015-12-11T07:42:00.497" Title="Reading Analog values of bluetooth module HC 05" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18601" PostTypeId="1" AcceptedAnswerId="18797" CreationDate="2015-12-11T05:53:34.000" Score="1" ViewCount="569" Body="&lt;p&gt;I've tried searching for this issue but came up empty. Due to the desire to use a better IDE, I installed Sublime Text 3 and Stino. I have installed the Stino package and now have the Arduino menu inside the Sublime Text editor. I have selected the Arduino application folder appropriately. However, when I compile the simple Blink example, I'm presented with the following error. This error comes up when I attempt to compile any Arduino project. Have I forgotten to configure a setting? All videos and tutorials I've seen just follow the same steps as I have and don't seem to include any additional configuration (besides selecting the Arduino application folder).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Stino - Start building &quot;Blink&quot;...]&#xA;[  3%] Creating C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp.o...&#xA;&quot;C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++&quot; -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD  -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=161 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   &quot;-IC:\Program Files (x86)\Arduino\examples\01.Basics\Blink&quot; &quot;-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino&quot; &quot;-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard&quot; &quot;C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp&quot; -o &quot;C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp.o&quot;&#xA;The filename, directory name, or volume label syntax is incorrect.&#xA;&#xA;&#xA;[Stino - Exit with error code 1.] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2015-12-18T07:59:18.237" Title="Sublime Text Compilation Issue" Tags="|arduino-uno|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18603" PostTypeId="2" ParentId="18600" CreationDate="2015-12-11T07:42:00.497" Score="1" Body="&lt;p&gt;Try looking up the datasheet to see if there is a command for signal strength. It's impossible to &lt;strong&gt;directly&lt;/strong&gt; read the the analog value since the signal strength is way too low in amplitude.&lt;/p&gt;&#xA;" OwnerUserId="15435" LastActivityDate="2015-12-11T07:42:00.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18604" PostTypeId="1" CreationDate="2015-12-11T08:13:56.373" Score="3" ViewCount="5173" Body="&lt;p&gt;At the moment I am working on a code that should send a plateau to a certain position and back. The plateau is being moved by the stepper, in my case a Nema 17 with a &lt;a href=&quot;https://www.pololu.com/product/2133&quot; rel=&quot;nofollow noreferrer&quot;&gt;Polulu DRV8825&lt;/a&gt; driver. Everything is hooked up correctly. &#xA;My goal is to press '4' on the keyboard and that then the stepper moves to a certain position. However, I am not succeeding in this. I am using AccelStepper and at the moment I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;AccelStepper stepper(1, 5, 4);&#xA;&#xA;int spd = 1000;    // The current speed in steps/second&#xA;int sign = 1;      // Either 1, 0 or -1  &#xA;int buttonState = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  stepper.setMaxSpeed(1000);&#xA;  stepper.setSpeed(1000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  char c;&#xA;  if (Serial.available()) {&#xA;    c = Serial.read();&#xA;    if (c == 'f') {  // forward&#xA;      sign = 1;&#xA;    }&#xA;    if (c == 'r') {  // reverse&#xA;      sign = -1;&#xA;    }&#xA;    if (c == 's') {  // stop&#xA;      sign = 0;&#xA;    }&#xA;    if (c == '1') {  // super slow&#xA;      spd = 100;&#xA;    }&#xA;    if (c == '2') {  // medium&#xA;      spd = 900;&#xA;    }&#xA;    if (c == '3') {  // fast&#xA;      spd = 1000;&#xA;    }&#xA;    if (c == '4') {&#xA;      //not working, does anyone know how to do this?&#xA;      stepper.moveTo(500);&#xA;    }&#xA;    stepper.setSpeed(sign * spd);&#xA;  }&#xA;  stepper.runSpeed();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone have tips or know how to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks is advance!&lt;/p&gt;&#xA;" OwnerUserId="15514" LastEditorUserId="28084" LastEditDate="2016-11-24T22:41:17.690" LastActivityDate="2016-12-25T16:25:32.023" Title="Send stepper to position and back AccelStepper" Tags="|arduino-uno|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18605" PostTypeId="1" CreationDate="2015-12-11T08:35:45.993" Score="2" ViewCount="878" Body="&lt;p&gt;I'm using ESP with USB to serial converter (D-SUN) is it possible to use the 3.3 volts of the USB instead of the Arduino Uno?&lt;/p&gt;&#xA;" OwnerUserId="15515" LastEditorUserId="4628" LastEditDate="2015-12-11T19:26:42.310" LastActivityDate="2015-12-12T22:18:24.773" Title="The 3.3 volts of the USB To TTL" Tags="|arduino-uno|serial|esp8266|voltage-protection|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18606" PostTypeId="1" CreationDate="2015-12-11T09:51:27.283" Score="0" ViewCount="7595" Body="&lt;p&gt;I have made an Arduino circuit which outputs in terms of frequency(hz) and I need output in terms of db as well&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any formula which can I apply to convert frequency hertz to db or is there any reference link to understand the conversion process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be highly appreciated&lt;/p&gt;&#xA;" OwnerUserId="10894" LastActivityDate="2015-12-12T19:54:18.123" Title="How to convert frequency into db" Tags="|arduino-uno|frequency|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18607" PostTypeId="2" ParentId="18599" CreationDate="2015-12-11T09:59:01.657" Score="1" Body="&lt;p&gt;Your problem is in how you are working with the two sensors. At the moment you are triggering both sensors together then waiting for the first one to echo back. Only when that has responded do you then wait for the second one to echo back, and that echo has been and gone already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you have two tennis balls. You throw them both at different walls at the same time, then attempt to catch them both. While you are catching the first ball the second one bounces off the back of your head and rolls under the table. That's what's happening with your echos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead you need to treat both sensors completely separately. Trigger the first, then get the response. Then trigger the second and get the response. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-11T09:59:01.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18608" PostTypeId="2" ParentId="13964" CreationDate="2015-12-11T10:03:17.123" Score="0" Body="&lt;p&gt;At the end I came out with a button connected to one of the digital input pins and a sketch that, using the bridge to communicate with the &quot;Linux part&quot; of Yún, restores original values in the configuration files and reboots the whole controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the reboot completes the Arduino Yún is accessible again through the Wi-Fi network &quot;Arduino Yun xxxxxxxxxx&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11622" LastEditorUserId="510" LastEditDate="2017-11-05T14:11:15.547" LastActivityDate="2017-11-05T14:11:15.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18609" PostTypeId="2" ParentId="18605" CreationDate="2015-12-11T10:06:34.347" Score="3" Body="&lt;p&gt;I don't know what that adapter is (a link would be nice, or at least the chip number it uses) but in general the 3.3v on a USB TTL adapter can only provide a small current. For instance the FT232RL can only provide up to 50mA at 3.3v. That may not be enough current to drive the RF circuitry of the ESP. The early Arduinos used the FT232RL chip for the USB interface and it was the 3.3v from that which was used for the 3.3v header on the Arduino. This was somewhat of a failing with those Arduinos since the 50mA limit was a real problem when people started using more 3.3v devices. That was one of the driving forces (as well as cost) in the decision to switch to an MCU for the USB interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to be on the safe side I wouldn't use the 3.3v from the USB adapter to power the ESP. You are better using a 5v to 3.3v regulator circuit driven from the 5v of the USB. And yes, that could be a whole Arduino, or build your own on some stripboard.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-11T10:06:34.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18610" PostTypeId="2" ParentId="18606" CreationDate="2015-12-11T10:08:51.790" Score="2" Body="&lt;p&gt;dB is volume (sound pressure), frequency is pitch. The two are entirely different concepts and can't be converted. A bit like you can't convert the roundness of a doughnut into blue. Roundness and blueness (it has blueberries in it by the way) are two different properties of the doughnut.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-12T11:19:01.027" LastActivityDate="2015-12-12T11:19:01.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18611" PostTypeId="2" ParentId="16756" CreationDate="2015-12-11T11:20:12.530" Score="0" Body="&lt;p&gt;Try &quot;Tools&gt; Port:&gt; then select your board&quot; &#xA;Make sure your pc hasn't assigned new com port to the attached usb (Arduino) &lt;/p&gt;&#xA;" OwnerUserId="15518" LastActivityDate="2015-12-11T11:20:12.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18612" PostTypeId="1" CreationDate="2015-12-11T13:58:05.443" Score="2" ViewCount="106" Body="&lt;p&gt;I'm using Arduino Uno board as master and AVR32UC3A0512 as slave. I've written code for arduino using SPI.h library, and Atmel Studio 6.2 using spi.h. I'm sending data from arduino to atmel i.e from SPDR register in arduino to RDR register in Atmel, but the data is not getting recieved. Hence, I'm not able to read the data. I've successfully interfaced SPI between two arduino boards and I'm using the same Arduino Master code while interfacing it with slave EVK. I've also set the baud rate same, I'm not sure what the problem might be. Can anyone please help me out?&lt;/p&gt;&#xA;" OwnerUserId="15521" LastActivityDate="2015-12-11T13:58:05.443" Title="SPI Interface between Arduino UNO and EVK1100" Tags="|arduino-uno|spi|avr|atmel-studio|" AnswerCount="0" CommentCount="2" ClosedDate="2016-01-30T02:49:30.853" ContentLicense="CC BY-SA 3.0" />
  <row Id="18613" PostTypeId="2" ParentId="18575" CreationDate="2015-12-11T14:10:49.133" Score="1" Body="&lt;p&gt;&lt;strong&gt;Does anyone know if what I am trying to do is possible?&lt;/strong&gt;&#xA;It is possible, i've done it with 2 arduinos where one was simulating ESP8266 (waiting for ebay order).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And if it is, what am I doing wrong?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are doing is wrong on most levels, but i think you got most sorted out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An idea is to implement this little fella: &lt;a href=&quot;http://www.banggood.com/3_3V-5V-TTL-Bi-directional-Logic-Level-Converter-For-Arduino-p-949438.html&quot; rel=&quot;nofollow&quot;&gt;Logic level shifter&lt;/a&gt; it will save you many troubles later. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On your &quot;WIRING SCHEME 1&quot; you are using the arduino's Hardware serial port to talk directly to the device as if it was connected through a TTL cable or FTDI cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the arduino device would in theory read from the hardware when talking too the ESP8266, if you have another arduino or a TTL cable, try and connect it to gate 2 and 3 on the &quot;main&quot; arduino and you should get a similar result as for your example result 2. Since you would that way proxy through the arduino. If not that would be a place to start debugging. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beside that i could only recommend you in investing in either a TTL 3,3v or a logic level converter. When i got my cable everything worked out of the box. &lt;/p&gt;&#xA;" OwnerUserId="3638" LastActivityDate="2015-12-11T14:10:49.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18614" PostTypeId="2" ParentId="18575" CreationDate="2015-12-11T14:43:51.540" Score="8" Body="&lt;p&gt;Well you may try this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start by uploading blink sketch to your Arduino then connect it to your ESP8266 like this: TX-TX and RX-RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now open Serial Monitor and send AT command and see if it responds. If so then you can control it using your Arduino by wiring it back to TX-RX and RX-TX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Don't forget to set the line ending in the Serial Monitor to Newline or Carriage Return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use this code to connect to ESP8266:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 2; // Wire this to Tx Pin of ESP8266&#xA;const byte txPin = 3; // Wire this to Rx Pin of ESP8266&#xA;&#xA;// We'll use a software serial interface to connect to ESP8266&#xA;SoftwareSerial ESP8266 (rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  ESP8266.begin(115200); // Change this to the baudrate used by ESP8266&#xA;  delay(1000); // Let the module self-initialize&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Sending an AT command...&quot;);&#xA;  ESP8266.println(&quot;AT&quot;);&#xA;  delay(30);&#xA;  while (ESP8266.available()){&#xA;     String inData = ESP8266.readStringUntil('\n');&#xA;     Serial.println(&quot;Got reponse from ESP8266: &quot; + inData);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the Hardware Serial interface will be busy when connected to Computer, then you have to use another Serial interface to communicate with your ESP8266. In this case, Software Serial comes handy. &lt;/p&gt;&#xA;" OwnerUserId="6424" LastEditorUserId="6424" LastEditDate="2015-12-14T12:42:22.403" LastActivityDate="2015-12-14T12:42:22.403" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18615" PostTypeId="1" AcceptedAnswerId="18616" CreationDate="2015-12-11T15:23:27.280" Score="2" ViewCount="221" Body="&lt;p&gt;As far as I understand it checks for a valid serial connection (new program incoming) and then either writes it to flash or starts executing the existing program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't the 32u4 or EDBG fill the role of an ISP and program the MCU instead of the MCU self-programming? I know the EDBG is accessed via OpenOCD to write the bootloader to the SAMD21 on Arduino Zero boards so why is the bootloader even required?&lt;/p&gt;&#xA;" OwnerUserId="15295" LastActivityDate="2015-12-11T16:01:28.583" Title="What does the bootloader do?" Tags="|bootloader|atmega32u4|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18616" PostTypeId="2" ParentId="18615" CreationDate="2015-12-11T16:01:28.583" Score="2" Body="&lt;p&gt;The bootloader is there for convenience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you understand what the bootloader does and how it operates.  However, you have missed out one benefit, and that is evident when you're &lt;em&gt;not&lt;/em&gt; using the bootloader.  That is, when you're not using the bootloader the &lt;em&gt;same&lt;/em&gt; connection can be used for a serial connection to the PC.  If the 32U4 were directly programming the main MCU then it would be talking to the SPI pins not the UART pins, so you would need a second connection, or both a connection to the UART &lt;em&gt;and&lt;/em&gt; the SPI pins, and much more complex firmware on the 32U4, in order to get a serial connection to the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the simplest option is just to have a dumb pass-through interface from the USB to the UART pins and have the main MCU self program with a bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also means that you don't need any special programming hardware when making your own board - just something (another arduino maybe) to get the bootloader on there in the first place (or buy the MCU pre-programmed) and then use any TTL serial interface to program it with your main program.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-11T16:01:28.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18617" PostTypeId="2" ParentId="757" CreationDate="2015-12-11T18:43:38.250" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://jtxp.org/tech/tinysafeboot_en.htm&quot; rel=&quot;nofollow&quot;&gt;TinySafeBoot&lt;/a&gt; is an alternative for ATtiny and ATmega devices.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Compatible to plenty of ATtinys and ATmegas (see below)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Read/Write access to Flash and EEPROM.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;All IOs available for serial communication&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;One-wire, also with multiple AVRs on a single line&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Autobauding, rugged protocol.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Activated by Reset + Password (optional)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Password and Timeout user changeable anytime.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Emergency Erase&quot; to overcome lost Password - kills all data but leaves bootloader intact.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ATtinys: ~ 550 bytes, &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ATmegas: &amp;lt; 512 bytes (!)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;TSB for ATtiny can update itself.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Sourcecode is free Software (GPL)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15295" LastActivityDate="2015-12-11T18:43:38.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18618" PostTypeId="2" ParentId="18606" CreationDate="2015-12-11T21:05:24.447" Score="0" Body="&lt;p&gt;Decibels (Db) are calculated using amplitudes and by definition decibels are the measurement of sound intensity or power level of electrical signal by comparing it with a given level on a logarithmic scale, which is &lt;strong&gt;independent of frequency&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can measure the decibels though if you know the amplitude of your source which i'm guessing is ~5v .&lt;/p&gt;&#xA;" OwnerUserId="11982" LastEditorUserId="11982" LastEditDate="2015-12-11T21:10:36.233" LastActivityDate="2015-12-11T21:10:36.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18619" PostTypeId="1" AcceptedAnswerId="18624" CreationDate="2015-12-11T21:57:13.533" Score="0" ViewCount="312" Body="&lt;p&gt;I have the following situation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One Arduino Uno with a 433mhz transmitter wired to the laptop to have serial communication. Another Arduino Uno with a 9V battery wired with a 433mhz receiver and an LCD screen (16x2, I2C).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following code to transmit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  //Force low when enabled&#xA;  vw_set_ptt_inverted(true);&#xA;  //Set pin 12 for transmitter&#xA;  vw_set_tx_pin(12);&#xA;  //Setup with speed of the data transfer.&#xA;  vw_setup(4000);&#xA;  //Set serial communication at 9600 baud&#xA;  Serial.begin(9600);//set Serial&#xA;  //Set pin 13 to light up when transmitting&#xA;  pinMode(13,OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  //If message send via serial monitor&#xA;  if (Serial.available()) {&#xA;    //wait a bit for the entire message to arrive&#xA;    delay(100);&#xA;&#xA;    while (Serial.available() &amp;gt; 0) {&#xA;      //Read serial into string&#xA;      String message = Serial.readString();&#xA;      //Initialize char array&#xA;      char msg[message.length()];&#xA;      //Write string to char array&#xA;      message.toCharArray(msg, message.length());&#xA;      //send char array as unsigned int (bits)&#xA;      vw_send((uint8_t *)msg, strlen(msg));&#xA;      //Wait until the complete message has been send&#xA;      vw_wait_tx();&#xA;      //Turn on light when finished&#xA;      digitalWrite(13,HIGH);&#xA;      delay(200);&#xA;    }&#xA;  }else{&#xA;    //Turn off light&#xA;    digitalWrite(13, LOW);  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the following code to receive a message and print on a LCD screen:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address&#xA;&#xA;void setup() {&#xA;  //start up LCD with 16 chars with 2 lines&#xA;  lcd.begin(16,2);  &#xA;  //Turn on backlight&#xA;  lcd.backlight();&#xA;  //Write initialising message&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Initialisation..&quot;);&#xA;  //Force low when enabled&#xA;  vw_set_ptt_inverted(true); &#xA;  //Set pin 12 to receive&#xA;  vw_set_rx_pin(12);&#xA;  //Setup with speed of the data transfer.&#xA;  vw_setup(4000);&#xA;  //set pin 13 for light&#xA;  pinMode(13, OUTPUT);&#xA;  //Start receiver&#xA;  vw_rx_start();  &#xA;&#xA;  //Set message on LCD that setup has completed&#xA;  lcd.setCursor(0,1); &#xA;  lcd.print(&quot;Completed!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  //initialize array for message&#xA;  uint8_t msg[VW_MAX_MESSAGE_LEN];&#xA;  uint8_t msgLength = VW_MAX_MESSAGE_LEN;&#xA;&#xA;  //If message received&#xA;  if (vw_get_message(msg, &amp;amp;msgLength)){&#xA;    //Turn on light&#xA;    digitalWrite(13, HIGH);&#xA;&#xA;    //Print on lcd&#xA;    lcd.clear();&#xA;    lcd.setCursor(0,0);&#xA;    lcd.write(msg, msgLength);&#xA;  }else{&#xA;    //Else turn of light&#xA;    digitalWrite(13, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that the message that is being transmitted and received by the other arduino always is short 1 character. For example if I send &quot;test&quot;, it receives and displays &quot;tes&quot;. What am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(My short solution was to just add a space to the message, then the space got cut off. But I want to understand what is going wrong.)&lt;/p&gt;&#xA;" OwnerUserId="15159" LastActivityDate="2015-12-12T00:44:12.270" Title="Message received with 1 character less" Tags="|arduino-uno|lcd|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18620" PostTypeId="1" CreationDate="2015-12-11T21:59:12.300" Score="1" ViewCount="203" Body="&lt;p&gt;I have a project made with Arduino, and I want to replace it by a miniaturized circuit with just a microcontroller. Is there any tutorial that can guide me in doing this? Any reference is wellcome. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="15533" LastActivityDate="2016-03-25T10:37:06.550" Title="From Arduino to a miniaturized circuit" Tags="|arduino-uno|atmega328|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18621" PostTypeId="1" AcceptedAnswerId="18623" CreationDate="2015-12-12T00:03:42.803" Score="0" ViewCount="106" Body="&lt;p&gt;As opposed to PCINT (Atmel's Pin Change INTerrupt, INTx is arduino-compatible interupt)  In other words, does Software Serial use atmel's pin change or arduino falling interrupt?&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-12T00:21:08.160" Title="Are INTx pins the only ones eligible for Software Serial?" Tags="|interrupt|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18622" PostTypeId="2" ParentId="18620" CreationDate="2015-12-12T00:09:15.897" Score="4" Body="&lt;p&gt;You can use an &lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino on a breadboard&lt;/a&gt; to get you going. From the breadboard, you can then develop a circuit on a pre-made PCB like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gl4zM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gl4zM.jpg&quot; alt=&quot;PCB&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to a custom PCB, if you so desire.&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-12T00:09:15.897" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18623" PostTypeId="2" ParentId="18621" CreationDate="2015-12-12T00:21:08.160" Score="1" Body="&lt;p&gt;&lt;code&gt;SoftwareSerial&lt;/code&gt; uses PCINT.  &lt;code&gt;AltSoftSerial&lt;/code&gt; uses INT0 or INT1, which has FALLING, RISING, CHANGE or LOW LEVEL options.  See Section 12.2, p. 71 of the Atmel &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega328 spec&lt;/a&gt;, for example.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-12T00:21:08.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18624" PostTypeId="2" ParentId="18619" CreationDate="2015-12-12T00:44:12.270" Score="2" Body="&lt;p&gt;I haven't found the source of the problem by reading through the code, and will limit my comments to advice about debugging the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the code as it stands, there are half a dozen points where the missing character might have dropped out.  With just a final result, the problem location is difficult to narrow down.  Modify your code to display intermediate data.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the sending code, print the read-in string and its length to Serial.  Eg, if you &lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&lt;/code&gt; you can say: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial &amp;lt;&amp;lt; message &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; message.length() &amp;lt;&amp;lt; endl;&lt;/code&gt;&#xA;&lt;code&gt;Serial &amp;lt;&amp;lt; msg &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; strlen(msg) &amp;lt;&amp;lt; endl;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Note, &lt;code&gt;msg&lt;/code&gt; actually occupies strlen(msg)+1 bytes, the last byte being a null-byte terminator, which your code doesn't send or receive.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the receiving code, besides the &lt;code&gt;lcd.write&lt;/code&gt; of &lt;code&gt;msg&lt;/code&gt;, do an &lt;code&gt;lcd.print&lt;/code&gt; with &lt;code&gt;msgLength&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also do some code clean-up in the sender.  Remove the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;while (Serial.available() &amp;gt; 0) {&lt;/code&gt;,&#xA;and its corresponding &lt;code&gt;}&lt;/code&gt;, because  &lt;code&gt;Serial.readString()&lt;/code&gt; already contains a character-wait loop with timeout.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-12T00:44:12.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18625" PostTypeId="1" AcceptedAnswerId="57297" CreationDate="2015-12-12T03:42:48.777" Score="12" ViewCount="33733" Body="&lt;p&gt;I have a 9-DOF sensor (&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Sensors/IMU/MPU-9150-Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MPU-9150&lt;/a&gt;) and I want to use its magnetometer to retrieve the rotation angle, from 0 to 359. However, its library returns three values: x, y and z.&lt;/p&gt;&#xA;&lt;p&gt;I do not know how to transform this into a single value. Is there any way to do this?&lt;/p&gt;&#xA;" OwnerUserId="11030" LastEditorUserId="61722" LastEditDate="2024-01-21T11:38:53.613" LastActivityDate="2024-01-21T11:38:53.613" Title="Converting three-axis magnetometer values to degrees" Tags="|magnetometer|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18626" PostTypeId="1" CreationDate="2015-12-12T07:17:04.240" Score="1" ViewCount="403" Body="&lt;p&gt;I am trying to get Arduino Uno with Raspberry Pi to communicate with each other. I want the python script to write a message and for my Arduino to read it. This was working before, but I came back a week later and it stopped. Essentially, I want the Raspberry Pi to write '3' and for my Arduino to recognize this 3 and light up some LEDs. Where do you think I am going wrong? The Arduino works when testing it through the IDE and Serial Monitor. There are no errors when running the python script, the LEDS just don't light up, so I assume there is some miscommunication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;ser = serial.Serial('/dev/ttyACM0', 9600)&#xA;ser.write('3')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino Code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String serialRead;&#xA;int val;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  strip.begin();  &#xA;  strip.setBrightness(25);&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  serialRead = Serial.read();&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    val = Serial.read();&#xA;&#xA;    if (val &amp;gt; '0' &amp;amp;&amp;amp; val &amp;lt;= '9') {&#xA;      Serial.println(val);&#xA;      val = val - '0';&#xA;      Serial.println(val);&#xA;&#xA;      if (val == 3)&#xA;      {&#xA;        //strip.setBrightness(100);&#xA;        colorWipe(strip.Color(127, 127, 127), 50);&#xA;        colorWipe(strip.Color(0, 0, 0), 50);        &#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15539" LastActivityDate="2015-12-12T07:59:08.530" Title="Arduino Uno and Raspberry Pi USB Serial Communication" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18627" PostTypeId="2" ParentId="18626" CreationDate="2015-12-12T07:46:33.147" Score="4" Body="&lt;p&gt;Just at a glance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your loop consumes the byte and stores it in &lt;code&gt;serialRead&lt;/code&gt;, so there is probably no available data at the outer &lt;code&gt;if&lt;/code&gt;, so it is never entered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try deleting this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serialRead = Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8561" LastEditorUserId="8561" LastEditDate="2015-12-12T07:59:08.530" LastActivityDate="2015-12-12T07:59:08.530" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18628" PostTypeId="2" ParentId="18588" CreationDate="2015-12-12T10:32:12.980" Score="1" Body="&lt;p&gt;I've did not got it working with &lt;code&gt;Wire&lt;/code&gt;. Hence I've implemented a I2C protocol myself using bit-banging and then it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update from 2017-September-16&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was not &lt;code&gt;Wire.h&lt;/code&gt; but a specialty of the Olimexino 32u4 board. I've only found out by using a Real Time Clock connected to the UEXT port's I2C bus, that I have to switch on the power for the UEXT port by setting D8 to LOW. Otherwise SDA or SCL seem to be pulled down preventing any I2C communication.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2017-09-16T18:41:09.740" LastActivityDate="2017-09-16T18:41:09.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18629" PostTypeId="1" AcceptedAnswerId="18630" CreationDate="2015-12-12T13:36:08.697" Score="0" ViewCount="2107" Body="&lt;p&gt;I tried a basic Blink example and I found a strange case where :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Works&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tfcD5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tfcD5.jpg&quot; alt=&quot;Working example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does not work&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rpYOF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rpYOF.jpg&quot; alt=&quot;NOT working example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain me what is happening ?&lt;/p&gt;&#xA;" OwnerUserId="15541" LastActivityDate="2015-12-12T14:48:12.257" Title="Blink question with breadboard &amp; LED" Tags="|led|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18630" PostTypeId="2" ParentId="18629" CreationDate="2015-12-12T13:50:14.480" Score="3" Body="&lt;p&gt;It is because the rail in the middle breaks the vertical connections.&#xA;So the positive leg in the first example is not connected to the negative leg of the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your second example both the negative leg and the positive leg are connected on the same rail, because of the that the power is not flowing through the LED but directly back to the GND pin of your arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same for the resistor. Since both legs are connected to the same rail, the resistor has no effect.&lt;/p&gt;&#xA;" OwnerUserId="15542" LastEditorUserId="15543" LastEditDate="2015-12-12T14:48:12.257" LastActivityDate="2015-12-12T14:48:12.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18632" PostTypeId="1" AcceptedAnswerId="18634" CreationDate="2015-12-12T17:39:06.670" Score="0" ViewCount="3214" Body="&lt;p&gt;I bought an FC-22 (MQ135) gas sensor module which I plugged into my Arduino Uno. I connected it to the A0 analog port. Then created a code that reads the raw data from A0 (code below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the code on my Arduino Uno in my house I get values of about 30. If I blow over the sensor I get values until about 160. My question is now how I have to read / interpret these values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the MQ135 specifications the sensor has a sesitivity for air quality, measuring benzene, alcohol and smoke.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I interpret the values I get? What is a good value and what isn't? Do I have to calculate something out of these values?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorValue = analogRead(0);&#xA;  Serial.print(sensorValue, DEC);&#xA;  delay(100);&#xA;  if (sensorValue &amp;gt; 50) {&#xA;    digitalWrite(13, HIGH);&#xA;  }&#xA;  else {&#xA;    digitalWrite(13, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13612" LastActivityDate="2017-11-17T06:43:36.187" Title="MQ135 output on Arduino Uno" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18634" PostTypeId="2" ParentId="18632" CreationDate="2015-12-12T19:41:54.360" Score="2" Body="&lt;p&gt;According to the &lt;a href=&quot;https://www.olimex.com/Products/Components/Sensors/SNS-MQ135/resources/SNS-MQ135.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; you have to calibrate it.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-12T19:41:54.360" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18635" PostTypeId="2" ParentId="18606" CreationDate="2015-12-12T19:54:18.123" Score="2" Body="&lt;p&gt;dB it self just express in a logarithmic scale a ratio between two values and it self is unit independent (because is a ratio). Just because the most common uses of dB scales are linked to intensity or power doesn't necessarily mean that can't be used to represent other ratios of different types of quantities. Or at least I couldn't find any definition that restricts the use of dB in such cases. The formulas to express such ratio are present &lt;a href=&quot;https://en.wikipedia.org/wiki/Decibel&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; you just have to figured it out what is really your ratio. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, if you have some kind of sensor that somehow the output is a frequency, let's say something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(x) = ax + f0  [Hz]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no reason why you can't express this function in a logarithmic ratio scale using dB something like, related to f0 or f(x=0)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;L(x) = 10*Log10*(f(x)/f0) [dB]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which would give you the represented dB output of your equation with respect to x.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; since we are in arduino stackexchange and talking about sensor, the common use of dB in electronics is the representation of power ratio or (the more common) a frequency response of a circuit(or system) that is represented by a &lt;a href=&quot;https://en.wikipedia.org/wiki/Bode_plot&quot; rel=&quot;nofollow&quot;&gt;Bode Plot&lt;/a&gt;, so I advise you to really take a good look at both links and try to figure what you really are asked to represent.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2015-12-12T19:54:18.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18637" PostTypeId="2" ParentId="18605" CreationDate="2015-12-12T22:18:24.773" Score="1" Body="&lt;p&gt;From my experience using the USB to TTL adapter will not work very well. I got some code on my ESP somehow, but could not get it working reliable. So I ended up powering it from an additional source.&lt;/p&gt;&#xA;" OwnerUserId="14570" LastActivityDate="2015-12-12T22:18:24.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18638" PostTypeId="1" CreationDate="2015-12-12T22:19:39.810" Score="1" ViewCount="157" Body="&lt;p&gt;I have spent the whole day trying to deal with this problem connecting Arduinos together using UART (Serial). But the problem is that it always behaves weirdly. For now the problem is that if previous number (I am sending numbers over serial) stays in the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me describe the problem. I want to send the following sequence of numbers 16 4 100. Numbers are sent with a terminator char after each number, but on the receiver side I get the following result 16 46 100.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see if the previous number is longer (length, has more digits) than the current one, like 16 and 4, 132 and 34, the difference (number of digits) remains in the next result: for 16 and 4 it will be 16 and 46, for 132 and 34 it will be 132 and 342.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried different ways to solve this problem, but unfortunately I cannot find the solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my functions used for communication:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void sendCommandToSerial(int command) {&#xA;  Serial3.print(command);&#xA;  Serial3.print(TERMINATOR_CHAR);&#xA;  Serial3.flush();&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial3.begin(9600);&#xA;  Serial.begin(9600);&#xA;} &#xA;&#xA;int readRawBytes(char *inputBuffer,const int bufferSize) {&#xA;  return Serial3.readBytesUntil(TERMINATOR_CHAR, inputBuffer, bufferSize);&#xA;}&#xA;int readIntFromSerial() {&#xA;  if(readRawBytes(inputBuffer,DEFAULT_BUFFER_SIZE) &amp;gt; 0) {&#xA;    return atoi(inputBuffer);&#xA;  }&#xA;  return -1;&#xA;}&#xA;int readFloatFromSerial() {&#xA;  if(readRawBytes(inputBuffer,DEFAULT_BUFFER_SIZE) &amp;gt; 0) {&#xA;    return atof(inputBuffer);&#xA;  }&#xA;  return -1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried both software and hardware serials, still the same.&#xA;Please help to find and solve the problem.&lt;/p&gt;&#xA;" OwnerUserId="7757" LastEditorUserId="4131" LastEditDate="2015-12-14T13:59:44.143" LastActivityDate="2015-12-14T13:59:44.143" Title="Extra characters remain in Serial" Tags="|serial|arduino-ide|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18639" PostTypeId="1" AcceptedAnswerId="18640" CreationDate="2015-12-12T22:54:37.863" Score="2" ViewCount="605" Body="&lt;p&gt;I use Arduino IDE 1.6.6 on Ubuntu 15.10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting the Arduino IDE without using &lt;code&gt;sudo&lt;/code&gt; fails for both:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;uploading the code to the Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;starting the serial monitor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The group I need to add my user to is called &lt;code&gt;dialout&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myuser@mycomputer:~$ ls -l /dev/ttyACM*&#xA;crw-rw---- 1 root dialout 166, 0 Dez 12 17:57 /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I added &lt;code&gt;myuser&lt;/code&gt; to &lt;code&gt;dialout&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo usermod -a -G dialout myuser&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Somewhere I read that I have to add &lt;code&gt;myuser&lt;/code&gt; to &lt;code&gt;tty&lt;/code&gt; as well, so I did it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo usermod -a -G tty myuser&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though I still fail with the above mentioned when trying to use the IDE with &lt;code&gt;myuser&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I have to do to get the IDE working with &lt;code&gt;myuser&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13612" LastActivityDate="2015-12-12T23:53:07.563" Title="Arduino IDE fails without sudo" Tags="|arduino-uno|arduino-ide|ubuntu|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18640" PostTypeId="2" ParentId="18639" CreationDate="2015-12-12T23:47:50.297" Score="2" Body="&lt;p&gt;There should be a command like 'id' or something similar that will show the groups you are a member of. Run that to check that the new groups have taken effect – you may need to log out and then log back in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other thing to check is the group owner of the device itself (in /dev). that will also need to match the group you assigned to yourself. Also make sure that the device permissions allow group access.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-12T23:53:07.563" LastActivityDate="2015-12-12T23:53:07.563" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18641" PostTypeId="2" ParentId="18638" CreationDate="2015-12-13T00:00:39.493" Score="3" Body="&lt;p&gt;The Stream member function readBytesUntil() does not null terminate the string. It returns the number of characters read. You must terminate the string with null(0) before calling atoi() and atof() or fill the string will null(0) before calling readBytesUntil(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see Arduino &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L219&quot; rel=&quot;nofollow&quot;&gt;Stream.cpp&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-13T00:00:39.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18642" PostTypeId="1" AcceptedAnswerId="18645" CreationDate="2015-12-13T07:42:26.667" Score="2" ViewCount="6670" Body="&lt;p&gt;I've written a program for Arduino UNO and 3 LED lights. The program is supposed to turn an inputted number into binary and then display it on the LEDs, on being 1 and off being 0 I have looked it over quite a few times and don't understand why it is not working as it should. I'm a beginner at working with Arduino so I probably just need a more experienced eye to show me where I have messed up. I have a link to a picture of the Arduino setup below. Thanks!&#xA;&lt;a href=&quot;https://drive.google.com/file/d/0B8k_WNZ3eFOkZHkwNUllTEp4WGM/view?usp=sharing&quot; rel=&quot;nofollow&quot;&gt;https://drive.google.com/file/d/0B8k_WNZ3eFOkZHkwNUllTEp4WGM/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//setting up lights&#xA;const int lightOne = 13;&#xA;const int lightTwo = 12;&#xA;const int lightThree = 11;&#xA;&#xA;//array of the lights for when printing the binary&#xA;int lights[] = {lightOne, lightTwo, lightThree};&#xA;&#xA;&#xA;void setup() {&#xA;  //setting pin modes and starting up the serial monitor&#xA;  pinMode(lightOne, OUTPUT);&#xA;  pinMode(lightTwo, OUTPUT);&#xA;  pinMode(lightThree, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;//converts a given number into binary&#xA;String binary(int number) {&#xA;  String r;&#xA;  while(number!=0) {&#xA;    r = (number % 2 == 0 ? &quot;0&quot; : &quot;1&quot;)+r; &#xA;    number /= 2;&#xA;  }&#xA;  return r;&#xA;}&#xA;&#xA;//outputs the binary string to the lights (not expecting numbers larger than     9)&#xA;void printBinary(String binaryNumber) {&#xA;  for (int i = 0; i &amp;lt; sizeof(binaryNumber); i++) {&#xA;    digitalWrite(lights[i+11], (binaryNumber[i] == '0' ? LOW : HIGH));&#xA;    delay(2000);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  int input = Serial.read();                //get the number&#xA;  String binaryNumber = binary(input);      //convert number to binary&#xA;  Serial.println(binaryNumber);             //print binary to serial monitor&#xA;  printBinary(binaryNumber);                //display number in binary on     LEDs&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15555" LastActivityDate="2015-12-31T06:06:23.997" Title="Displaying binary to LEDs" Tags="|arduino-uno|c++|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18643" PostTypeId="2" ParentId="18642" CreationDate="2015-12-13T08:31:10.333" Score="1" Body="&lt;p&gt;You need to check that there are characters available before reading. Please see documentation of &lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;Serial.read&lt;/a&gt;() (and &lt;a href=&quot;https://www.arduino.cc/en/Serial/Available&quot; rel=&quot;nofollow&quot;&gt;Serial.available()&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-13T08:31:10.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18644" PostTypeId="1" AcceptedAnswerId="18650" CreationDate="2015-12-13T10:19:09.833" Score="1" ViewCount="1232" Body="&lt;p&gt;I'm following this &lt;a href=&quot;http://communityofrobots.com/tutorial/kawal/how-drive-dc-motor-using-l293d-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt; to control a DC motor with an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same problem as this stackexchange post arduino.stackexchange.com/questions/10049/problems-with-l293d where the motor is not rotating.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The chip is heading to the right. (5v pins are on the right)&lt;/li&gt;&#xA;&lt;li&gt;Connecting directly the motor to the battery works.&lt;/li&gt;&#xA;&lt;li&gt;Current (5V on the bottom &amp;amp; 2*1.5V) is flowing everywhere expected EXCEPT on the yellow &amp;amp; green wires of the motor (the red wire of the battery pack is connected to the second line of the breadboard).&lt;/li&gt;&#xA;&lt;li&gt;Connecting directly the motor to the battery works.&lt;/li&gt;&#xA;&lt;li&gt;I copied the code of the above tutorial which is basically : &quot;digitalWrite(4,HIGH);&quot;, there is current on the cable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Am I wrong into thinking that a L293D chip can output sufficient current ? Is the chip malfunctioning ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FE9o4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FE9o4.jpg&quot; alt=&quot;My montage&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15541" LastActivityDate="2015-12-13T17:35:50.250" Title="Rotating a motor with L293D" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18645" PostTypeId="2" ParentId="18642" CreationDate="2015-12-13T10:41:23.533" Score="2" Body="&lt;h1&gt;Welcome to SE Arduino!&lt;/h1&gt;&#xA;&#xA;&lt;h2&gt;Long Version&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You have a couple of things to look at:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Don't use &lt;code&gt;String&lt;/code&gt; class it has too much overhead for Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Your conversion function is not really necessary because you can convert it on your &lt;code&gt;Serial.println()&lt;/code&gt; by specifying &lt;code&gt;binary&lt;/code&gt; as output. eg: &lt;a href=&quot;https://www.arduino.cc/en/Serial/Println&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Serial.println(number, BIN)&lt;/code&gt;&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;Serial.read&lt;/code&gt; returns an integer, but that &lt;code&gt;int&lt;/code&gt; only contains a &lt;a href=&quot;https://www.arduino.cc/en/Reference/Byte&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;byte&lt;/code&gt;&lt;/a&gt; (unsigned) value anyway (unless there's nothing to be read, in which case it returns &lt;code&gt;-1&lt;/code&gt;). Because you're taking a number (not really relevant) and you want it to be a number on the return, just use &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;byte&lt;/code&gt; (unsigned: &lt;code&gt;0 &amp;lt;-&amp;gt; 255&lt;/code&gt;) or &lt;a href=&quot;https://www.arduino.cc/en/Reference/Char&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;char&lt;/code&gt;&lt;/a&gt; (signed: &lt;code&gt;-127 &amp;lt;-&amp;gt; +128&lt;/code&gt;). &lt;/li&gt;&#xA;&lt;li&gt;You could/should/doesn't matter if you use &lt;code&gt;Serial.available()&lt;/code&gt; or not, it is a matter for yourself, I usually do, but it's non blocking anyway and if there's nothing there to be read, it'll just continue on anyway. Although if you're not going to use it, you should test for that &lt;code&gt;-1&lt;/code&gt; as what you're doing at the moment is taking that and converting it to binary (which is &lt;code&gt;0xFF&lt;/code&gt; which is everything on). &lt;strong&gt;This is one of your major problems in the code&lt;/strong&gt; (the other is in the &lt;strong&gt;Short Version&lt;/strong&gt; section.&lt;/li&gt;&#xA;&lt;li&gt;You're using &lt;code&gt;&quot;0&quot;&lt;/code&gt; and &lt;code&gt;&quot;1&quot;&lt;/code&gt; which are &lt;code&gt;ASCII&lt;/code&gt; values, and you haven't indicated how you're getting the number. So it may be &lt;code&gt;ASCII&lt;/code&gt; (&lt;code&gt;byte&lt;/code&gt;) or actually a &lt;code&gt;byte&lt;/code&gt; value. ie, &lt;code&gt;&quot;0&quot;&lt;/code&gt; is &lt;code&gt;48 (dec)&lt;/code&gt; or &lt;code&gt;30 (hex)&lt;/code&gt;. Whereas a &lt;code&gt;0&lt;/code&gt; is just &lt;code&gt;zero&lt;/code&gt;. Funnily enough, because you're using modulo (&lt;code&gt;%&lt;/code&gt;) it doesn't really matter because you're only interested in the lowest nibble, which for the sake of your code, doesn't matter what's encoded at the higher end. ie: &lt;code&gt;1&lt;/code&gt; (&lt;code&gt;0b00000001&lt;/code&gt;) is the same as &lt;code&gt;&quot;1&quot; = 49 (dec) = 0x31 = 0b00110001&lt;/code&gt; when used with &lt;code&gt;%2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Ditch your &lt;code&gt;delay(2000)&lt;/code&gt;. Delays are evil* :) You could write the values to the pins all day, you're not going to cause any problems, if you want to output less to your serial port (which you should do), you could do timed outputs back to Serial. ie, do your &lt;code&gt;Serial.println()&lt;/code&gt; once a second, or record the values into backup/old variables and compare them, and only print the output if the value changes&lt;/li&gt;&#xA;&lt;li&gt;The big one is in the next section&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;h2&gt;Short Version&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is your &lt;em&gt;main&lt;/em&gt; problem, on this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(lights[i+11], (binaryNumber[i] == '0' ? LOW : HIGH));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(lights[i], (binaryNumber[i] == '0' ? LOW : HIGH));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You already have the pin value encoded in the array, you don't want to add 11 to the index, that's going to throw you above your three light values :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;* Delays are evil&lt;/strong&gt;: It's a matter of opinion, and that's just how I feel, I actually googled it and this is just a random response. But it contains the crux of what I'd say anyway: &lt;a href=&quot;http://www.makeuseof.com/tag/arduino-delay-function-shouldnt-use/&quot; rel=&quot;nofollow&quot;&gt;http://www.makeuseof.com/tag/arduino-delay-function-shouldnt-use/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2015-12-13T10:41:23.533" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18647" PostTypeId="1" CreationDate="2015-12-13T14:12:19.460" Score="0" ViewCount="19748" Body="&lt;p&gt;I recently started playing around with Arduinos to connect a few sensors up. I used an Arduino Nano to measure temperature, humidity, air pressure and light level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To store the data in a database, I used another Arduino that I connected to a Raspberry Pi, and let the two Arduinos talk wirelessly to each other via 433 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That all works pretty well, but the 433 MHz communication is not exactly the most reliable (I often miss a transmission). When I stumbled upon the ESP8266 module, it seemed like the optimal solution for communication. How cool would it be if I could just pull out the information via an HTTP call from the Raspberry Pi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After toying around for many hours, uploading many different firmwares, getting more and more frustrated because I could not get it to do anything, I finally have it working through an FTDI module connected up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9mjhX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9mjhX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use an MB102 power module to provide the 3.3v required by the ESP8266. I turns out you need to connect the ground from the MB102 to the ground of the FTDI module to get any proper response. After doing that I was able to send AT commands and get the proper responses. I could even connect it to my home Wifi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next thing I want to do is connect it to the Arduino. I found a very simple schema for that (&lt;a href=&quot;http://blog.huntgang.com/2015/01/20/arduino-esp8266-tutorial-web-server-monitor-example/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://blog.huntgang.com/2015/01/20/arduino-esp8266-tutorial-web-server-monitor-example/&lt;/a&gt;), where you connect RX to TX and TX to RX. Using the MB102 I connected it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aLzdG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aLzdG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently I should now be able to upload a blank sketch to the Arduino, and then use the serial monitor again to sens AT command, exactly the same way I did it when using the FTDI module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I get nothing at all this way. I don't even see my own AT commands in the console. I do see the ESP8266 flashing every time I send a command (I even see it it still connected to my router, probably it remembered the info I send through the FTDI...?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is, what am I going wrong? I read some posts about the TX from the Arduino also being 5v and that you need to do something to bring it back to 3.3v, but there are also many tutorials that say it's not required.&lt;/p&gt;&#xA;" OwnerUserId="15557" LastEditorUserId="4628" LastEditDate="2016-01-13T15:05:16.497" LastActivityDate="2020-06-02T12:14:06.583" Title="Linking Arduino Nano with ESP8266 Wifi module" Tags="|esp8266|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18648" PostTypeId="2" ParentId="18625" CreationDate="2015-12-13T14:30:59.687" Score="3" Body="&lt;p&gt;This is a basic math problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;az=90-atan(y/x)*180/pi&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;atan()&quot; is arctangent and converts from coordinate variables to angle in radians, *180/pi converts from radians to degrees, and 90- converts from degrees math angles (degrees CCW from the x axis) to azimuth (degrees CW from north).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calibrating the sensor is a trickier problem. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-13T14:30:59.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18649" PostTypeId="2" ParentId="11824" CreationDate="2015-12-13T15:23:07.230" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.arduino.org&quot; rel=&quot;nofollow&quot;&gt;arduino.org&lt;/a&gt; is not only boards assembler, but is also who designs and engineers the arduino boards. They own the arduino trademark all over the world, except the USA, therefore &lt;a href=&quot;http://www.arduino.cc&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; owns the trademark only in the USA.&lt;/p&gt;&#xA;" OwnerUserId="15155" LastActivityDate="2015-12-13T15:23:07.230" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18650" PostTypeId="2" ParentId="18644" CreationDate="2015-12-13T17:22:23.363" Score="1" Body="&lt;p&gt;Your picture shows a holder for two AA cells, yielding something in the neighbourhood of 3v.  That is far too little for an L293D.  (This isn't really your fault, as it appears you got this erroneous idea from following a bad tutorial, but it does demonstrate that not everything you read on the Internet is sensible.  Using a 9v &quot;transistor&quot; battery is also a bad idea).    3 cells would be about the minimum, but even there it would not work well, as that chip has two bipolar transistors in the path yielding a voltage drop of over a volt.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use a an L293D you really want at least a 5 or 6 volt system, and a motor wound for low to moderate current at that voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a lower voltage, look at a more modern MOS-based H bridge chip - the TB6612FNG is an often used example.  You will however still want to choose motors wound for moderate current at a 3- or 4- cell voltage - those intended for 2-cell usage typically draw more current than is ideal for an IC driver chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is entirely possible that there are additional issues with your attempt as well.  Normally, a question such as this would require a complete and accurate schematic diagram, which you have not provided.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-12-13T17:35:50.250" LastActivityDate="2015-12-13T17:35:50.250" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18652" PostTypeId="1" AcceptedAnswerId="18654" CreationDate="2015-12-13T17:38:16.857" Score="2" ViewCount="269" Body="&lt;p&gt;I want to learn core and mechanics of microcontrollers with Arduino, and I don't really know where to find good source of knowledge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every Arduino related tutorial is about very basic stuff like connecting the LCD display without explaining what every pin does. When it comes to programming tutorials only explain what functions are needed and do not explain what happens inside the hardware. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example i know what delay() function does, and I know that I can find definition in the source files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void delay(unsigned long ms)&#xA;{&#xA;    uint16_t start = (uint16_t)micros();&#xA;&#xA;    while (ms &amp;gt; 0) {&#xA;        yield();&#xA;        if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I really want to know what that code does, and how to write own functions. I would appreciate if you could provide me with any starting point. Should I just follow the source files until I get it or is there any better reference?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Arduino Leonardo, and experience in programming in C/C++.&lt;/p&gt;&#xA;" OwnerUserId="15562" LastActivityDate="2015-12-13T19:33:33.627" Title="How to learn electronics/programming with Arduino?" Tags="|programming|c++|arduino-leonardo|" AnswerCount="2" CommentCount="0" ClosedDate="2015-12-29T16:31:37.433" ContentLicense="CC BY-SA 3.0" />
  <row Id="18653" PostTypeId="2" ParentId="18652" CreationDate="2015-12-13T18:06:57.007" Score="2" Body="&lt;p&gt;There are two main topics there: Digital Electronics, and C++ programming, and the Arduino happens to bridge the gap between the two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's why it's hard to find tutorials in the style you want.  So instead of looking for Arduino tutorials that do what you want you need to split the topics apart and deal with them separately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search for C++ programming tutorials. That should help you understand the structure and syntax of a program better. Search for digital electronics tutorials. Good keywords are things like &lt;em&gt;logic gates&lt;/em&gt;, &lt;em&gt;combinational logic&lt;/em&gt; or &lt;em&gt;digital interfacing&lt;/em&gt; and just &lt;em&gt;digital electronics&lt;/em&gt;. That should help you understand things like logic levels, logical functions, inputs and outputs, and such like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have basic understanding in both fields you can begin to see how the two relate together. One of the most important skills any engineer has is understanding and interpreting datasheets. From datasheets you can find how the hardware operates and what you would need your program to do to make the hardware do what you want.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-13T18:06:57.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18654" PostTypeId="2" ParentId="18652" CreationDate="2015-12-13T19:33:33.627" Score="1" Body="&lt;p&gt;For information about the “core and mechanics of microcontrollers with Arduino”, there are numerous articles with lots of details on the &lt;a href=&quot;http://forum.arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt; forum.  However, most of the code posted there sucks, as does most of the code posted here on &lt;a href=&quot;http://arduino.stackexchange.com&quot;&gt;Arduino Stackexchange&lt;/a&gt;.  That's a natural consequence of people posting code that doesn't work and they wonder why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a reasonably organized and accurate body of information about Arduino hardware and software, see &lt;a href=&quot;http://www.gammon.com.au/forum/index.php?bbtopic_id=123&quot; rel=&quot;nofollow&quot;&gt;Nick Gammon's Arduino pages&lt;/a&gt;.  Also see &lt;a href=&quot;https://arduino.land/FAQ/showcat.html&quot; rel=&quot;nofollow&quot;&gt;arduino.land&lt;/a&gt; pages.  For better understanding of Arduino software internals, see &lt;a href=&quot;http://garretlab.web.fc2.com/en/arduino/inside/index.html&quot; rel=&quot;nofollow&quot;&gt;garretlab's “Internal Structure of Arduino Software”&lt;/a&gt; pages, which are well organized and quite informative about the subjects they cover.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the specific &lt;code&gt;delay()&lt;/code&gt; code shown in the question, first consider this slightly simpler version, from Arduino 1.6.3:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void delay(unsigned long ms) {&#xA;    uint16_t start = (uint16_t)micros();&#xA;    while (ms &amp;gt; 0) {&#xA;        if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ignoring data type constraints, it's evident that the &lt;code&gt;while&lt;/code&gt; loop counts down &lt;code&gt;ms&lt;/code&gt; from its original value to zero.  The burden of the &lt;code&gt;if&lt;/code&gt; executes about once per millisecond, because &lt;code&gt;start&lt;/code&gt; advances 1000 microseconds each time within the &lt;code&gt;if&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The casts of &lt;code&gt;micros()&lt;/code&gt; – ie, where &lt;code&gt;uint16_t&lt;/code&gt; appears in parentheses before &lt;code&gt;micros()&lt;/code&gt; – tell the compiler to throw away the upper two bytes of &lt;code&gt;micros()&lt;/code&gt; [which is actually an unsigned long, or &lt;a href=&quot;http://www.cplusplus.com/reference/cstdint/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;uint32_t&lt;/code&gt;&lt;/a&gt;] and treat it as an unsigned 16-bit integer.  The low two bytes of &lt;code&gt;micros()&lt;/code&gt; overflow every 65536 microseconds, on which occasions within a millisecond it will come to pass that although &lt;code&gt;(uint16_t)micros()&lt;/code&gt; is less than &lt;code&gt;start&lt;/code&gt;, due to use of unsigned arithmetic &lt;code&gt;((uint16_t)micros() - start) &amp;gt;= 1000&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code you included has one more statement in the &lt;code&gt;while&lt;/code&gt; loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    yield();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For most models of Arduino, &lt;code&gt;yield()&lt;/code&gt; is an empty function, a do-nothing if compiled at all.  On the Due, with &lt;a href=&quot;https://www.arduino.cc/en/Reference/Scheduler&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Scheduler.h&lt;/code&gt;&lt;/a&gt; in use to support cooperative (non-preemptive) multitasking using multiple stacks, &lt;code&gt;yield()&lt;/code&gt; gives the scheduler an opportunity to schedule another task, if one is ready to run.  Note that if a  “cooperative” but malignant task always takes just under 65536 microseconds to do its work, it can happen that &lt;code&gt;delay()&lt;/code&gt; as shown never returns.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-13T19:33:33.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18656" PostTypeId="2" ParentId="16699" CreationDate="2015-12-13T21:42:15.703" Score="1" Body="&lt;p&gt;Are you sure the baud rate is correct? You could try 115200 and 57600. Is the serial monitor set to &quot;Carriage Return&quot; or &quot;Both NL &amp;amp; CR&quot;? If this isnt set, the modem won't respond to your commands since it requires a '\r' to terminate every command. Is there any indication that the modem is powered (like the net LED blinking)? Your code looks alright but, to be sure everything's okay, use this test program to interact with the modem using the serial monitor; just change your loop() to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void loop(){&#xA;        while (Serial.available())&#xA;            GPRS.write(Serial.read());&#xA;        while (GPRS.available())&#xA;            Serial.write(GPRS.read());&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, everything you type in the monitor will be relayed to the modem and everything from the modem will be relayed to the PC, all via the arduino.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-13T21:42:15.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18657" PostTypeId="2" ParentId="18647" CreationDate="2015-12-13T22:00:10.527" Score="0" Body="&lt;p&gt;There might be an issue with the baudrate from the Nano FTDI chip to the RX/TX and the ESP8266. Did you disconnect when uploading the sketch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about trying &lt;a href=&quot;http://blog.huntgang.com/2015/01/20/arduino-esp8266-tutorial-web-server-monitor-example/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; instead? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-13T22:00:10.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18659" PostTypeId="2" ParentId="16814" CreationDate="2015-12-13T22:37:31.020" Score="1" Body="&lt;p&gt;You could also make use of the Arduino serialEvent() function. Behind the scenes, every time the loop() function returns, this function (if you define it) is automatically run by the Arduino if the Serial buffer contains data. So all you have to do is define the serialEvent() function and have it read from the serial port and compare what it gets against some pre-defined handshake value. If the read data is a valid handshake, the Arduino should respond with a unique value too and then await the SSID, password and other stuff you wish to set. &#xA;This means your can run your PC program anytime and simply have it send the handshake and wait for the Arduino's response before sending the wifi details. You can use serialEvent() like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void serialEvent(){&#xA;        if (Serial.read() == 'Z'){ //if 'Z' is your handshake value&#xA;            Serial.write('X');   // if 'X' is the response expected by the PC&#xA;            getWifiDetails();   // the handler that gets the needed data&#xA;        }&#xA;        while (Serial.read() != -1);  // flush to get rid of any garbage&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The handshake value could be more than 1 byte to increase chances of uniqueness. This method assumes you aren't doing anything else with the serial port, since that could bring garbage to the forefront of Serial.read() calls and cause false triggering of serialEvent() and its IF condition. You could implement a timeout in your handler to handle such events though.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-13T22:37:31.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18660" PostTypeId="2" ParentId="18598" CreationDate="2015-12-13T23:18:32.287" Score="0" Body="&lt;p&gt;The 'Serial' baud rate is too low compared to the baud rate of 'mySerial'. It could be causing you to lose bytes as the Serial buffer overflows, especially if the sensor transmits a lot of values in a relatively short interval. Increase the Serial baud rate to 115200 and see how it goes.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-13T23:18:32.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18661" PostTypeId="1" AcceptedAnswerId="18729" CreationDate="2015-12-14T00:21:04.457" Score="1" ViewCount="895" Body="&lt;p&gt;I'm trying to code a simple transmitter - Receiver program with nRF24L01&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very simple code. Compiles. But when I try to test it using serial monitor. But only the first character is printed on the screen just once.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;#define CE_PIN 9&#xA;#define CSN_PIN 10&#xA;&#xA;&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;&#xA;int smth[1];  // the transmitter data&#xA;int x=0;  // the copy of the receiver data&#xA;char rec[1]; //the receiver data&#xA;&#xA;int ledPin = 3; // choose the pin for the LED&#xA;int inPin = 7;   // choose the input pin (for a pushbutton)&#xA;int val = 0;     // variable for reading the pin status&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT);  // declare LED as output&#xA;  pinMode(inPin, INPUT);    // declare pushbutton as input&#xA;&#xA;  radio.begin();&#xA;  radio.openWritingPipe(pipe);  //originally transmitter&#xA;}&#xA;&#xA;void loop(){&#xA;  val = digitalRead(inPin);  // read input value&#xA;  if (val==HIGH) {         // check if the input is HIGH (button released)&#xA;    digitalWrite(ledPin, HIGH);  // turn LED OFF&#xA;    Serial.println('1');&#xA;    smth[0] = '1';&#xA;    radio.write(smth, sizeof(smth));&#xA;  } else {&#xA;    digitalWrite(ledPin, LOW);  // turn LED ON&#xA;    Serial.println('0');&#xA;    smth[0] = '0';&#xA;    radio.write(smth, sizeof(smth));&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Serial Monitor :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Instead of printing a zeros for infinite time till I change the mode of the switch, even though if I change the mode of the switch from low to high, nothing is printed on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Library for instance &lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help?&lt;/p&gt;&#xA;" OwnerUserId="15428" LastEditorUserId="11529" LastEditDate="2015-12-15T11:46:00.960" LastActivityDate="2021-09-05T00:06:52.267" Title="nRF24L01 Problem" Tags="|arduino-uno|nrf24l01+|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18662" PostTypeId="1" CreationDate="2015-12-14T00:40:40.190" Score="0" ViewCount="301" Body="&lt;p&gt;Can the ATTINYx5 use its universal serial interface for a better UART than the Sofware Serial library alone? If so, is there a library or tutorial for this?&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-14T01:06:38.590" Title="ATTINYx5 usi for uart?" Tags="|softwareserial|attiny|uart|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18664" PostTypeId="2" ParentId="18662" CreationDate="2015-12-14T01:06:38.590" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc4300.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR307&lt;/a&gt; describes implementation of a half duplex UART implementation using the USI. Note that full duplex is not possible due to the synchronous design of the USI.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-14T01:06:38.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18665" PostTypeId="2" ParentId="18598" CreationDate="2015-12-14T01:07:13.117" Score="1" Body="&lt;p&gt;Soft Serial is totally unreliable. You may have a better error rate at other baud rates, but you will never achieve the same as a hardware based serial connection.  I'd switch my debugging connection to the software serial, nd use the hardware serial for the XV-11.&lt;/p&gt;&#xA;" OwnerUserId="15570" LastActivityDate="2015-12-14T01:07:13.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18666" PostTypeId="1" CreationDate="2015-12-14T02:05:10.847" Score="2" ViewCount="48" Body="&lt;p&gt;I'm currently looking for an RF protocol that doesn't use much power (generally much less than wifi) Something similar to simple AM radio, but with an authentication library readily available. ZigBee has about 250kbps bandwidth. I don't need nearly as much, so something with ~5kbps (dial-up speeds) would be acceptable. Using the Arduino Yun; so i'm constrained to the 5V output.&#xA;I'm also trying to stay away from the 2.4 GHz band.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything out there with this in mind? I was thinking maybe &lt;a href=&quot;https://en.wikipedia.org/wiki/Z-Wave&quot; rel=&quot;nofollow&quot;&gt;Z-Wave&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the ZWave chips go this is where i'm at: &lt;a href=&quot;http://pastebin.com/B0Yif3LS&quot; rel=&quot;nofollow&quot;&gt;http://pastebin.com/B0Yif3LS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14884" LastEditorUserId="14884" LastEditDate="2015-12-14T02:13:02.190" LastActivityDate="2015-12-14T02:13:02.190" Title="Looking for an existing lightweight RF protocol" Tags="|arduino-yun|rf|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18667" PostTypeId="1" CreationDate="2015-12-14T02:43:43.153" Score="3" ViewCount="3413" Body="&lt;p&gt;I have tried to get the Ai-Thinker ESP8266 working at all. If you hook it up to an Uno you have garbage returned no matter what the baud rate is. Tried softwareSerial on D3 and D4 (switching pins doesn't help) and over D0 and D1 with no sketch (to send AT commands directly to the device because softwareSerial wasn't working).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a logic converter from 5v to 3.3v to handle the voltage correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know for a fact you can do that. I've done it a bunch with Bluetooth. HC-05.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: Pins in the wrong order won't return anything, in order to get garbage it needs to be wired correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a FTDI module that functions as another passthrough unit for this. It has a jumper for 3.3v to 5v and will stay on 3.3v as these units are unable to handle 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used PuTTY in order to view the boot information of this chip. On boot it returns this information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's my issue.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ets Jan  8 2013,rst cause:4, boot mode:(3,7)&#xA;&#xA;wdt reset&#xA;load 0x40100000, len 816, room 16&#xA;tail 0&#xA;chksum 0x8d&#xA;load 0x3ffe8000, len 788, room 8&#xA;tail 12&#xA;chksum 0xcf&#xA;ho 0 tail 12 room 4&#xA;load 0x3ffe8314, len 288, room 12&#xA;tail 4&#xA;chksum 0xcf&#xA;csum 0xcf&#xA;&#xA;2nd boot version : 1.2&#xA;  SPI Speed      : 40MHz&#xA;  SPI Mode       : QIO&#xA;  SPI Flash Size : 4Mbit&#xA;jump to run user1&#xA;&#xA;sd▒C▒&#xA;Ai-Thinker Technology Co. Ltd.&#xA;&#xA;invalid&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the end of the day this invalid line means that the wifi information (from what I understand) is corrupted. It also refreshes this information over and over and WILL NOT accept AT commands so I can't seem to chase it down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am afraid that by attempting to update it if this kind of issue happens it will be bricked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both of these modules are opened today and I have tested another 8266 with similar results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15133" LastEditorUserId="15133" LastEditDate="2015-12-14T22:28:48.830" LastActivityDate="2017-04-04T11:56:42.610" Title="ESP8266 Returns 'invalid' - Cause 4" Tags="|arduino-uno|esp8266|ftdi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18668" PostTypeId="1" CreationDate="2015-12-14T04:04:03.420" Score="0" ViewCount="484" Body="&lt;p&gt;How do you save space by preventing the inclusion of unnecessary binaries?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I compiled the &lt;a href=&quot;http://wiki.ros.org/rosserial_arduino/Tutorials/Blink&quot; rel=&quot;nofollow&quot;&gt;ROS Blink&lt;/a&gt; example, I received the warning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Global variables use 1,951 bytes (76%) of dynamic memory,&#xA;leaving 609 bytes for local variables. Maxiumum is 2,560 bytes.&#xA;Low memory available, stability problems may occur.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Considering the example uses almost no libraries, I was surprised by this, but sure enough, the compiler pulls in a ton of libraries that are never used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scanning dependencies of src&#xA;Scanning dependencies of arduino&#xA;Scanning dependencies of ros_lib&#xA;src/main.cpp&#xA;arduino/wiring.c&#xA;arduino/wiring_shift.c&#xA;arduino/wiring_digital.c&#xA;arduino/wiring_pulse.c&#xA;arduino/WInterrupts.c&#xA;arduino/hooks.c&#xA;arduino/wiring_analog.c&#xA;arduino/USBCore.cpp&#xA;arduino/new.cpp&#xA;arduino/Tone.cpp&#xA;arduino/WString.cpp&#xA;arduino/HardwareSerial1.cpp&#xA;arduino/Stream.cpp&#xA;arduino/HardwareSerial3.cpp&#xA;arduino/HardwareSerial0.cpp&#xA;arduino/CDC.cpp&#xA;arduino/HardwareSerial2.cpp&#xA;arduino/main.cpp&#xA;arduino/HID.cpp&#xA;arduino/HardwareSerial.cpp&#xA;arduino/IPAddress.cpp&#xA;arduino/Print.cpp&#xA;arduino/WMath.cpp&#xA;arduino/abi.cpp&#xA;Linking libarduino.a&#xA;ros_lib/duration.cpp&#xA;ros_lib/time.cpp&#xA;Linking libros_lib.a&#xA;Linking firmware.elf&#xA;Converting to firmware.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why are so many files being included in the compilation, and how do I filter them out?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2015-12-14T12:05:07.980" Title="How to prevent inclusion of unnecessary libraries?" Tags="|compile|memory-usage|code-optimization|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18669" PostTypeId="1" AcceptedAnswerId="18720" CreationDate="2015-12-14T04:54:52.357" Score="0" ViewCount="2067" Body="&lt;p&gt;I'm trying to sending and receiving data via RS485 communication. Interfacing Arduino and PC(laptop) &#xA;using SN75176 RS485. I wrote a program to send a string &quot;Hello&quot; from arduino via Tx pin. My intention is to receive&#xA;the &quot;Hello&quot; string in my PC's hyperterminal. After uploading the program im receiving junk data. The baud rate i've mentioned in&#xA;my program and i gave in hyperterminal are same. I've checked the wire connection, it is ok. Then, what is the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;int Txpin = 1;&#xA;int ditpin = 5;  //for 1st rs485&#xA;int ditpin1 = 2; //for 2nd rs485&#xA;void setup()&#xA;  {&#xA;          // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;    pinMode(Txpin,OUTPUT);&#xA;    digitalWrite(ditpin, HIGH); //For transmit data from arduino&#xA;    digitalWrite(ditpin1, LOW); //For receive data to hyperterminal&#xA;  }&#xA;&#xA;void loop() &#xA;  {&#xA;    Serial.println(&quot;Hello\r\n&quot;);&#xA;    delay(1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wire connection:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aQ7y2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aQ7y2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10608" LastEditorUserId="4131" LastEditDate="2015-12-15T11:46:10.740" LastActivityDate="2015-12-15T20:30:08.957" Title="Problem in RS485 Communication between Arduino and PC" Tags="|rs485|rs232|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18670" PostTypeId="2" ParentId="18668" CreationDate="2015-12-14T06:44:13.843" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE build&lt;/a&gt; script will actually copy all core source code file to the tmp directory, compile and generate an archive file. The sketch is compiled and linked with this library. Only the referenced (used) functions and data are &lt;a href=&quot;http://openhardwareplatform.blogspot.se/2011/03/inside-arduino-build-process.html&quot; rel=&quot;nofollow&quot;&gt;linked in the binary&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The size (both program and data) of this blink is somewhat larger than the &quot;standard&quot; blink example but this is due to the publisher-subscriber run-time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: If you google you can find commands to listing what is actually in the generated binary. &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=155142.0&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a starting point.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-14T06:50:13.047" LastActivityDate="2015-12-14T06:50:13.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18671" PostTypeId="2" ParentId="8508" CreationDate="2015-12-14T09:17:26.843" Score="0" Body="&lt;p&gt;as stated above, it all has to do with the size of your payload. To clarify things, you need to keep in mind how many bytes a certain data type uses/needs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;char: 1 byte&#xA;int: 2 bytes&#xA;float 4 bytes &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(above is based on the Arduino reference, see &lt;a href=&quot;https://www.arduino.cc/en/Reference/Float&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Float&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, if you set payload size to 8 bytes in the NRF24L01 and then try to send a struct with int, float, float you will have 2 + 4 + 4 = 10 bytes, which does not fit in the payload size.&lt;/p&gt;&#xA;" OwnerUserId="15574" LastActivityDate="2015-12-14T09:17:26.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18673" PostTypeId="2" ParentId="18668" CreationDate="2015-12-14T12:05:07.980" Score="2" Body="&lt;p&gt;Part of the compilation process is what is known as &lt;em&gt;garbage collection&lt;/em&gt;, which is controlled by the compilation flag &lt;code&gt;-Wl,--gc-sections&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This process goes through the compiled program and works out which sections (functions, blocks of read-only data, etc, each in its own &lt;em&gt;section&lt;/em&gt; controlled by &lt;code&gt;-ffunction-sections&lt;/code&gt; and &lt;code&gt;-fdata-sections&lt;/code&gt; IIRC) and works out which are not needed in your compiled program.  It then deletes them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you have though is not with code or read-only data size, but with static RAM allocation size.  This is global variables and local static variables - things used for stiring data, maybe as serial buffers, etc.  Most of that is probably part of the underlying RTOS that you have elected to use. Which is the problem of using an RTOS to just blink an LED. It could be seen as a task that is beneath the RTOS and is complete overkill. Of course, since you're just testing, that is pretty irrelevant, however, as you add more functionality you will most likely find that the memory footprint doesn't increase much since it's the &quot;background&quot; stuff that of the RTOS that will always be there regardless of what tasks you are performing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-14T12:05:07.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18674" PostTypeId="1" AcceptedAnswerId="18675" CreationDate="2015-12-14T12:37:07.107" Score="0" ViewCount="821" Body="&lt;p&gt;I have found an Arduino function which converts a 2-bytes-&lt;code&gt;long&lt;/code&gt;-value to a binary value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. I call &lt;code&gt;sendCommand(0x05)&lt;/code&gt; And it gives me an output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;00000101&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendCommand(unsigned long command){&#xA;  for (unsigned long  mask = 1UL &amp;lt;&amp;lt; (7);  mask;  mask &amp;gt;&amp;gt;= 1) {&#xA;&#xA;    if (command &amp;amp; mask) {&#xA;&#xA;    Serial.print( &quot;1&quot; );&#xA;    } else {&#xA;&#xA;    Serial.print( &quot;0&quot; );&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;my Problem is, that I want to have the Least significant bit first. How do I have to adjust this function to achieve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.&#xA;&lt;code&gt;sendCommand(0x05)&lt;/code&gt;&#xA;shall give an output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;10100000&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15493" LastActivityDate="2015-12-14T13:12:43.327" Title="Convert Long to binary - least signifant bit first" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18675" PostTypeId="2" ParentId="18674" CreationDate="2015-12-14T13:12:43.327" Score="1" Body="&lt;pre&gt;&lt;code&gt;void sendCommand(unsigned long command){&#xA;  for (unsigned long  mask = 1UL; mask&amp;lt;256UL;  mask &amp;lt;&amp;lt;= 1) {&#xA;&#xA;    if (command &amp;amp; mask) {&#xA;&#xA;    Serial.print( &quot;1&quot; );&#xA;    } else {&#xA;&#xA;    Serial.print( &quot;0&quot; );&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS a long is actually 4 bytes long. But your code only uses 1 byte of it.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-14T13:12:43.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18676" PostTypeId="2" ParentId="11936" CreationDate="2015-12-14T13:41:59.797" Score="1" Body="&lt;p&gt;Until you have the correct baud rate &lt;em&gt;and&lt;/em&gt; good satellite reception, many fields will be zero or empty.  I wrote a diagnostic program for &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt; that will try different baud rates and confirm that the GPS device is functioning.  The example program is in this directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;examples/NMEAdiagnostic&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Installation instructions are &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Installing.md&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're inside, you may not be able to receive anything.  Move next to a window or go outside.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-14T13:41:59.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18677" PostTypeId="1" CreationDate="2015-12-14T16:02:29.713" Score="2" ViewCount="118" Body="&lt;p&gt;I have been running a simple RF link between 2 arduini uno recently and everything went faily well. I am now trying a new project with an arduino mini pro (5V/16MHz) and the seeeduino RF link (@315MHz), and I see very odd results : when the transmitter is on USB cable, the link runs ok, but when on a 9V battery (as raw voltage input), I get very very limiter range (a few inches). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the setup works on USB, I'm assuming that the current limitation on the GPIO that powers the RF transmitter is not the issue here. It therefore has to be the battery itself or the regulator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow I need to use a GPIO to shut down the radio during power saving phases. My current design is very basic, I should probably add a transistor to enable power on the RF. I was also thinking maybe the RD oscilliator needs to settle down a bit, I may need to add some delays before starting to send data. I can see on the oscilloscope that the data and power PINs seem to behave correctly, although I have noticed a voltage drop on the power pin which is similar in pattern to the data transmitted (but again this is no issue unless using the 9V battery).&lt;/p&gt;&#xA;" OwnerUserId="15588" LastActivityDate="2016-02-01T01:07:16.947" Title="powering RF on GPIO" Tags="|battery|rf|arduino-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18679" PostTypeId="1" CreationDate="2015-12-14T16:55:00.550" Score="5" ViewCount="1318" Body="&lt;p&gt;So here's the scenario.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have sent my teensy 3.1 circuit to a client of mine&#xA;And now I need to update the code burned onto teensy without providing client access to the code&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to create an exe or an installer of a kind which on execution simply upload the new code onto the teensy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the code is finally a hex file uploaded onto the controller I hope this must be possible&#xA;But on doing a quick google search i was not able to find any valid resource which would guide me how to go about it.&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="612" LastEditDate="2015-12-16T05:06:42.073" LastActivityDate="2015-12-16T05:06:42.073" Title="Is it possible to create a standalone exe which can burn the code into a Teensy 3.1?" Tags="|uploading|bootloader|teensy|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18680" PostTypeId="1" CreationDate="2015-12-14T17:08:41.003" Score="4" ViewCount="223" Body="&lt;p&gt;I have created a data logger that writes to a MicroSD on a user defined interval.  The data logger also has the ability to use an xBee unit to transmit the data received to a base station.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a &lt;a href=&quot;https://drive.google.com/folderview?id=0B8g6J3lNxKRDa3U5aC02VVppQ3M&amp;amp;usp=sharing&quot; rel=&quot;nofollow&quot;&gt;link to the code and pictures of the data logger&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Arduino IDE for prototyping and coding.  After compiling the code, I use the temp HEX file and upload it to the boards using AVR Studio 4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am experiencing is the data loggers will stop running after a random number of recordings.  This can be days or weeks of running before the problem is experienced. This issue rarely occurs when the logger is running in local mode, but occurs often when running with an XBee unit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A temporary fix I have found for the problem is to add &lt;code&gt;delay(10);&lt;/code&gt; before and after the SD card writes.  I do not know why this fixes the problem and would like to find a more appropriate solution. &lt;/p&gt;&#xA;" OwnerUserId="15591" LastEditorUserId="6936" LastEditDate="2016-01-02T19:37:26.757" LastActivityDate="2016-01-02T19:37:26.757" Title="Arduino IDE Based Data Logger - Stops Running" Tags="|programming|atmega328|xbee|sd-card|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18681" PostTypeId="2" ParentId="18679" CreationDate="2015-12-14T17:11:01.183" Score="1" Body="&lt;p&gt;Yes, it is perfectly possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need three things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The HEX file you want to program&lt;/li&gt;&#xA;&lt;li&gt;The programming utility for your chosen board (would be in the IDE folder somewhere - not sure what Teensy uses off hand)&lt;/li&gt;&#xA;&lt;li&gt;A text editor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then, using the text editor, you create a &lt;code&gt;.BAT&lt;/code&gt; file which executes the programming utility with the right parameters to program the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can help to do an upload in the IDE in verbose mode so you can see exactly what command and parameters are being executed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-14T17:11:01.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18682" PostTypeId="2" ParentId="18679" CreationDate="2015-12-14T17:11:09.640" Score="1" Body="&lt;p&gt;Yes.  Teensy has a command line loader available at &lt;a href=&quot;https://www.pjrc.com/teensy/loader_cli.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/loader_cli.html&lt;/a&gt; or &lt;a href=&quot;https://github.com/PaulStoffregen/teensy_loader_cli&quot; rel=&quot;nofollow&quot;&gt;https://github.com/PaulStoffregen/teensy_loader_cli&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the hex file, the teensy_cli client could upload it without giving your client the source code.  For non-teensy devices, avrdude could be used similarly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, one could fork the cli code, modify it to use an embedded copy of your hex file data in a hard-coded or encrypted constant, and then deliver that modified single-purpose executable file to your client.   &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-14T17:11:09.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18683" PostTypeId="1" CreationDate="2015-12-14T19:44:29.263" Score="0" ViewCount="399" Body="&lt;p&gt;Me and my friend are having some trouble setting up an software clock to our arduino uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's for a school project and we´ve never done any programming before. thanks! &lt;/p&gt;&#xA;" OwnerUserId="15592" LastActivityDate="2015-12-14T20:25:40.803" Title="Set an arduino software clock" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18684" PostTypeId="2" ParentId="18683" CreationDate="2015-12-14T20:11:56.327" Score="1" Body="&lt;p&gt;There is a Time library which you can import.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are things that I found on the Arduino website.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hour();            // The hour now  (0-23)&#xA;minute();          // The minute now (0-59)&#xA;second();          // The second now (0-59)&#xA;day();             // The day now (1-31)&#xA;weekday();         // Day of the week, Sunday is day 1&#xA;month();           // The month now (1-12)&#xA;year();            // The full four digit year: (2009,&#xA;                //  2010 etc)&#xA;setTime(t);              // Set the system time to the&#xA;                      //  give time t&#xA;setTime(hr,min,sec,day,month,yr); // Another way to set&#xA;                               //  the time&#xA;adjustTime(adjustment); // Adjust system time by adding&#xA;                     //  the adjustment value&#xA;&#xA;timeStatus();   // Indicates if time has been set and&#xA;             //  recently synchronized&#xA;             //  returns one of the following&#xA;             //  enumerations:&#xA;* timeNotSet    // The time has never been set,&#xA;             //  the clock started at Jan 1 1970&#xA;* timeNeedsSync // The time had been set but a sync&#xA;             //  attempt did not succeed&#xA;* timeSet       // The time is set and is synced&#xA;             //  Time and Date values are not valid if&#xA;             //  the status is timeNotSet. Otherwise &#xA;             //  values can be used but the returned&#xA;             //  time may have drifted if the status is&#xA;             //  timeNeedsSync.     &#xA;&#xA;setSyncProvider(getTimeFunction);// Set the external time&#xA;                              //  provider&#xA;setSyncInterval(interval);    // Set the number of&#xA;                           //  seconds between re-sync&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And obviously,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;Time.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Tell me in the comments if you need more help.&lt;/p&gt;&#xA;" OwnerDisplayName="user15297" LastEditorDisplayName="user15297" LastEditDate="2015-12-14T20:25:40.803" LastActivityDate="2015-12-14T20:25:40.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18686" PostTypeId="1" AcceptedAnswerId="18688" CreationDate="2015-12-14T20:34:10.697" Score="1" ViewCount="22834" Body="&lt;p&gt;I have this code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String incoming;   // for incoming serial data&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);  // opens serial port, sets data rate to 9600 bps&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // send data only when you receive data:&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;            // read the incoming byte:&#xA;            incoming = Serial.read();&#xA;            String mysrr = String(incoming);&#xA;            // say what you got:&#xA;            Serial.print(&quot;I received: &quot;);&#xA;            Serial.println(mysrr);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few of you will recognise this as an Arduino example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I run it ( I sent it the message &quot;hi&quot;), I get this in the serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I received: 104&#xA;I received: 105&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is this happening?&lt;/p&gt;&#xA;" OwnerDisplayName="user15297" LastActivityDate="2015-12-14T20:49:24.713" Title="Converting ASCII value to String" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18687" PostTypeId="2" ParentId="18679" CreationDate="2015-12-14T20:40:03.673" Score="1" Body="&lt;p&gt;The simplest solution is to ask you client to install the TeensyLoader application. &lt;a href=&quot;https://www.pjrc.com/teensy/loader.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/loader.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Send the new HEX file to the client. The client should then connect the board to the computer. Run the TeensyLoader and upload the HEX file. The TeensyLoader will recognize the board when the reset button is pushed. The HEX file will need to be located on disk (after download or mail attachment).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-14T20:40:03.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18688" PostTypeId="2" ParentId="18686" CreationDate="2015-12-14T20:42:54.680" Score="0" Body="&lt;p&gt;Serial.read() returns an int not a String. &lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/Read&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use an int for incoming (as the example). Or even better use a char and skip all the strings. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-14T20:49:24.713" LastActivityDate="2015-12-14T20:49:24.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18689" PostTypeId="1" AcceptedAnswerId="18690" CreationDate="2015-12-14T21:11:38.730" Score="0" ViewCount="161" Body="&lt;p&gt;I am playing around with this Tinycircuits &lt;a href=&quot;https://www.tiny-circuits.com/tiny-shield-16-edge-led.html&quot; rel=&quot;nofollow&quot;&gt;16 LED board&lt;/a&gt; and I can figure out how to persistently light two LEDs at the same time. The page comes with an example that i can modify but I can only do 1 at a time &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How do I light more than one LED at a time?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;TinyDuino Edge LED Demo&#xA;&#xA;April 9 2014, by Ben Rose&#xA;&#xA;This example code is in the public domain.&#xA;&#xA;http://www.tiny-circuits.com&#xA;&#xA;*/&#xA;&#xA;void setup()&#xA;{&#xA;  LedOn(0);//Pass a zero to turn all LEDs off&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for(int i=1;i&amp;lt;16;i++){&#xA;    LedOn(i);&#xA;    delay(20);&#xA;  };&#xA;  for(int i=16;i&amp;gt;1;i--){&#xA;    LedOn(i);&#xA;    delay(20);&#xA;  };&#xA;}&#xA;&#xA;void LedOn(int ledNum)&#xA;{&#xA;  for(int i=5;i&amp;lt;10;i++){&#xA;    pinMode(i, INPUT);&#xA;    digitalWrite(i, LOW);&#xA;  };&#xA;  if(ledNum&amp;lt;1 || ledNum&amp;gt;16) return;&#xA;  char highpin[16]={5,6,5,7,6,7,6,8,5,8,8,7,9,7,9,8};&#xA;  char lowpin[16]= {6,5,7,5,7,6,8,6,8,5,7,8,7,9,8,9};&#xA;  ledNum--;&#xA;  digitalWrite(highpin[ledNum],HIGH);&#xA;  digitalWrite(lowpin[ledNum],LOW);&#xA;  pinMode(highpin[ledNum],OUTPUT);&#xA;  pinMode(lowpin[ledNum],OUTPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1521" LastEditorUserId="25788" LastEditDate="2016-09-18T14:14:47.380" LastActivityDate="2016-09-18T14:14:47.380" Title="Light leds on this board one at a time" Tags="|led|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18690" PostTypeId="2" ParentId="18689" CreationDate="2015-12-14T21:36:43.897" Score="2" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dHQgl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dHQgl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is your circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you can take it from here by looking at the diagram, but please note that e.g. 1 0 0 0 0 will light up 3 and 1, so be careful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To show more than one, turn on multiple LEDs in rapid succession. It will give the effect that more than one are on. This is known as multiplexing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After Googling around, I understood it better. I also wrote this code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int IO1 = 50;&#xA;int IO2 = 48;&#xA;int IO3 = 46;&#xA;int IO4 = 44;&#xA;int IO5 = 41;&#xA;int del = 1000;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(IO1, INPUT);&#xA;  pinMode(IO2, INPUT);&#xA;  pinMode(IO3, INPUT);&#xA;  pinMode(IO4, INPUT);&#xA;  pinMode(IO5, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;    displayLED(1);&#xA;    delay(del);&#xA;    displayLED(2);&#xA;    delay(del);&#xA;    displayLED(3);&#xA;    delay(del);&#xA;    displayLED(4);&#xA;    delay(del);&#xA;    displayLED(5);&#xA;    delay(del);&#xA;    displayLED(6);&#xA;    delay(del);&#xA;    displayLED(7);&#xA;    delay(del);&#xA;    displayLED(8);&#xA;    delay(del);&#xA;    displayLED(9);&#xA;    delay(del);&#xA;    displayLED(10);&#xA;    delay(del);&#xA;    displayLED(11);&#xA;    delay(del);&#xA;    displayLED(12);&#xA;    delay(del);&#xA;    displayLED(13);&#xA;    delay(del);&#xA;    displayLED(14);&#xA;    delay(del);&#xA;    displayLED(15);&#xA;    delay(del);&#xA;    displayLED(16);&#xA;    delay(del);// light up LEDS 1, 2 and 3.&#xA;}&#xA;&#xA;void displayLED(int a){&#xA;    clear();&#xA;    if (a == 1){o(1); o(2); h(1); l(2); Serial.println('1');}&#xA;    if (a == 2){o(1); o(2); l(1); h(2); Serial.println('2');}&#xA;    if (a == 3){o(1); o(3); h(1); l(3); Serial.println('3');}&#xA;    if (a == 4){o(1); o(3); l(1); h(3); Serial.println('4');}&#xA;    if (a == 5){o(2); o(3); h(2); l(3); Serial.println('5');}&#xA;    if (a == 6){o(2); o(3); l(2); h(3); Serial.println('6');}&#xA;    if (a == 7){o(2); o(4); h(2); l(4); Serial.println('7');}&#xA;    if (a == 8){o(2); o(4); l(2); h(4); Serial.println('8');}&#xA;    if (a == 9){o(1); o(4); h(1); l(4); Serial.println('9');}&#xA;    if (a == 10){o(1); o(4); l(1); h(4); Serial.println(10);}&#xA;    if (a == 11){o(3); o(4); l(3); h(4); Serial.println(11);}&#xA;    if (a == 12){o(3); o(4); h(3); l(4); Serial.println(a);}&#xA;    if (a == 13){o(3); o(5); l(3); h(5); Serial.println(a);}&#xA;    if (a == 14){o(3); o(5); h(3); l(5); Serial.println(a);}&#xA;    if (a == 15){o(4); o(5); l(4); h(5); Serial.println(a);}&#xA;    if (a == 16){o(4); o(5); h(4); l(5); Serial.println(a);}&#xA;&#xA;}&#xA;&#xA;void clear(){pinMode(IO1, INPUT);&#xA;  pinMode(IO2, INPUT);&#xA;  pinMode(IO3, INPUT);&#xA;  pinMode(IO4, INPUT);&#xA;  pinMode(IO5, INPUT);}&#xA;&#xA;void o(int o){&#xA;    if (o == 1){pinMode(IO1, OUTPUT);}&#xA;    if (o == 2){pinMode(IO2, OUTPUT);}&#xA;    if (o == 3){pinMode(IO3, OUTPUT);}&#xA;    if (o == 4){pinMode(IO4, OUTPUT);}&#xA;    if (o == 5){pinMode(IO5, OUTPUT);}&#xA;}&#xA;&#xA;void h(int l){&#xA;    if (l == 1){digitalWrite(IO1, HIGH);}&#xA;    if (l == 2){digitalWrite(IO2, HIGH);}&#xA;    if (l == 3){digitalWrite(IO3, HIGH);}&#xA;    if (l == 4){digitalWrite(IO4, HIGH);}&#xA;    if (l == 5){digitalWrite(IO5, HIGH);}&#xA;}&#xA;&#xA;void l(int h){&#xA;    if (h == 1){digitalWrite(IO1, LOW);}&#xA;    if (h == 2){digitalWrite(IO2, LOW);}&#xA;    if (h == 3){digitalWrite(IO3, LOW);}&#xA;    if (h == 4){digitalWrite(IO4, LOW);}&#xA;    if (h == 5){digitalWrite(IO5, LOW);}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user15297" LastEditorDisplayName="user15297" LastEditDate="2015-12-19T13:37:26.007" LastActivityDate="2015-12-19T13:37:26.007" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18691" PostTypeId="2" ParentId="18689" CreationDate="2015-12-14T21:40:59.507" Score="0" Body="&lt;p&gt;That is an interesting challenge. You should include the circuit diagram for this. It really helps understand the code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J3WQz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J3WQz.png&quot; alt=&quot;Charleplex Circuit&quot;&gt;&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is excellent information on this technique to reduce number of pins &lt;a href=&quot;http://playground.arduino.cc/Code/Charlieplex&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-14T21:40:59.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18692" PostTypeId="2" ParentId="18667" CreationDate="2015-12-14T22:28:18.487" Score="1" Body="&lt;p&gt;Alright so I figured it out. Thanks to user Butters for pointing me in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno DOES NOT have enough power to handle the ESP8266 itself. It needs a power source using a 5v to 3v stepdown chip. The 3v3 rail doesn't handle it by itself.&lt;/p&gt;&#xA;" OwnerUserId="15133" LastActivityDate="2015-12-14T22:28:18.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18693" PostTypeId="1" AcceptedAnswerId="18694" CreationDate="2015-12-14T23:23:07.323" Score="2" ViewCount="760" Body="&lt;p&gt;If arduino works as a client and tries to connect to web server (the server is mine), should I connect to it via TCP or HTTP connection? Data will be simple strings (20 chars at max) so TCP connection should probably be enough? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The connection has to work in both ways - web server sending data to arduino and arduino sending data back to server. &lt;/p&gt;&#xA;" OwnerUserId="13760" LastActivityDate="2015-12-14T23:52:44.900" Title="TCP or HTTP connection between web server and arduino" Tags="|arduino-uno|web-server|tcpip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18694" PostTypeId="2" ParentId="18693" CreationDate="2015-12-14T23:35:25.427" Score="2" Body="&lt;p&gt;It's time you learned the &lt;a href=&quot;https://en.wikipedia.org/wiki/OSI_model&quot; rel=&quot;nofollow&quot;&gt;OSI 7 layer model: PDNTSPA&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTTP is a &lt;em&gt;P&lt;/em&gt;resentation (protocol) that runs over a TCP &lt;em&gt;S&lt;/em&gt;ession.  If you are interacting with a web server then you will be opening a TCP socket and sending HTTP requests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no other way of talking to a web server. It only speaks HTTP, and you can only connect to it through TCP.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-14T23:52:44.900" LastActivityDate="2015-12-14T23:52:44.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18695" PostTypeId="1" AcceptedAnswerId="18696" CreationDate="2015-12-14T23:47:58.143" Score="2" ViewCount="536" Body="&lt;p&gt;I was designing a voice automated kitchen lighting system. I have led strips under the cabinets which are remote controlled by an IR remote, so I captured the IR codes and got an IR led to turn them on. Now I introduced BitVoicer so that I could use voice commands to control the LED. I have ran into the issue that the IR led keeps turning the lights on and off, but my IR codes worked prior to using BitVoicer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;BitVoicer11.h&amp;gt;&#xA;&#xA;int IRledPin = 13;&#xA;&#xA;BitVoicerSerial bvSerial = BitVoicerSerial();&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; pinMode(IRledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  bvSerial.getData();&#xA;&#xA;  if(bvSerial.strData == &quot;&quot;)&#xA;  {&#xA;    return;&#xA;  }&#xA;&#xA;  if(bvSerial.strData == &quot;wake&quot;)&#xA;  {&#xA;   LightOnCode();&#xA;  }&#xA;}&#xA;&#xA;  void pulseIR(long microsecs)&#xA;   {&#xA;     cli();&#xA;&#xA;     while (microsecs &amp;gt; 0)&#xA;      {&#xA;        digitalWrite(IRledPin, HIGH);&#xA;        delayMicroseconds(10);&#xA;        digitalWrite(IRledPin, LOW);&#xA;        delayMicroseconds(10);&#xA;&#xA;        microsecs -= 26;&#xA;      }&#xA;     sei();&#xA;    }&#xA;   void LightOnCode()&#xA;{&#xA;  pulseIR(8940);&#xA;  delayMicroseconds(4380);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(600);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(560);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(540);&#xA;        delayMicroseconds(1660);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1660);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(500);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1660);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(560);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(600);&#xA;  pulseIR(500);&#xA;  delayMicroseconds(580);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(540);&#xA;  delayMicroseconds(1660);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1640);&#xA;  pulseIR(580);&#xA;  delayMicroseconds(1660);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1660);&#xA;  pulseIR(560);&#xA;  delayMicroseconds(560);&#xA;  pulseIR(520);&#xA;  delayMicroseconds(1680);&#xA;  pulseIR(520);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If anyone could answer my question as to why the led keeps sending extra signals I would appreciate it! If you have any questions don't hesitate to ask!&lt;/p&gt;&#xA;" OwnerUserId="15432" LastActivityDate="2016-06-12T04:36:07.203" Title="Arduino / BitVoicer Sending IR code on loop" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18696" PostTypeId="2" ParentId="18695" CreationDate="2015-12-15T01:04:16.317" Score="1" Body="&lt;p&gt;Taking a quick look at the &lt;a href=&quot;http://www.bitsophia.com/BitVoicer/v12/BitVoicerManual_v12_en.pdf&quot; rel=&quot;nofollow&quot;&gt;Documentation&lt;/a&gt; on page 22, it looks like you need to use your &lt;code&gt;bvSerial.strData&lt;/code&gt; calls within a function called &lt;code&gt;void serialEvent()&lt;/code&gt; rather than inside of your loop.  I would recommend trying out their tutorial on that page just to make sure you get BitVoicer to work properly before scaling it for your application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="5067" LastActivityDate="2015-12-15T01:04:16.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18698" PostTypeId="2" ParentId="11946" CreationDate="2015-12-15T03:18:57.950" Score="8" Body="&lt;p&gt;Your four half bridge load cell sensors can connect into a full wheatstone bridge as in &lt;a href=&quot;https://electronics.stackexchange.com/a/199470/30711&quot;&gt;https://electronics.stackexchange.com/a/199470/30711&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your sensors are like this 50kg load cell from SparkFun's &lt;a href=&quot;https://www.sparkfun.com/products/10245&quot; rel=&quot;noreferrer&quot;&gt;https://www.sparkfun.com/products/10245&lt;/a&gt;  or Ebay's &lt;a href=&quot;http://www.ebay.com/itm/4pcs-Body-Load-Scale-Weighing-Sensor-Resistance-Strain-Half-bridge-Sensors-50kg-/251873576571&quot; rel=&quot;noreferrer&quot;&gt;http://www.ebay.com/itm/4pcs-Body-Load-Scale-Weighing-Sensor-Resistance-Strain-Half-bridge-Sensors-50kg-/251873576571&lt;/a&gt; they might have a compression and tension gage both on the top surface. The Ebay site has a diagram like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PrHOR.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PrHOR.jpg&quot; alt=&quot;three-wire 50kg load cell&quot;&gt;&lt;/a&gt; &#xA;... which indicates a positive strain gauge on the red-white, and a negative strain on the red-black. (note that the coloring order in this diagram does not match the coloring order in this picture.  I have a similar gauge with blue-red-black colors, and the positive strain gauge is the right pair, negative on the left.) The gauged surface on the center bar between the face-to-face coupled 'E's in the sensor should act like a parallel bar and has portions under compression and under tension, rather than purely under tension.  In cross-section, the gauged bar in the center is sort of the cross-piece in a Z-shaped spring. In this case, the strains oppose each other, and, if manufactured well, the reduction of resistance in the negative strain portion will offset the increase in resistance in the positive strain portion and the total white-black resistance should be constant.  One still needs to set up the bridge so that the voltage dividers move in opposite directions with added load, and 4 devices wired in a white-to-white and black-to-black loop should work as above.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wire four of these up carefully by flipping them around so the stress sensitive portions unbalance the bridge constructively, you can use all four sensors without any extra resistors.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, two diagonally-opposite sides of a wheatstone bridge are each formed by the compression elements of two gauges wired in series, while the remaining two sides of the bridge are each formed from two tension elements from two cells.  With load on all the sensors, the compression resistances are reduced, while the tension resistances are increased and it pulls the bridge out of balance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get this, wire all four sensors in a big ring with maximum resistance, matching colors and initially ignoring the red center tap wires.  (This is the function of the soldered-together blues and blacks are in your scale.)  Choose two opposite (red) center taps as E+ and E-, and the remaining two (red) center taps as S+,S-.  Put the excitation voltage on the E+/E- from the diagram above and read a force-sensitive voltage difference across S+/S-, and this is what you feed into your HX711 as A+ and A-  (Ignore B+/B- as a second, unused channel.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a schematic with gauges 1-4 as G1 G2, G3, G4 per the above specs, applying an excitation on the G1 and G3 reds, and reading the signals off the G2 and G4 reds.  The G4 gauge is loaded a bit with some positive strain increasing the G4+ resistance, and some negative strain reducing the G4- resistance.  Ideally, loading G4 with 25kg would produce 0.5mV/V times its 2.5V excitation voltage, producing 1.250mV across Sig+/Sig-, and stretching R8 to be 1001 ohms and compressing R7 to 999 ohms as shown.   (The schematic/simulator thing on electronics.stackexchange.com is pretty cool.)&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/GYEy2.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fGYEy2.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;noreferrer&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of the &quot;White&quot; wires in the diagram and like on my gauges, consider it the &quot;blue&quot; wires from your scale's sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With only two of these half-bridge sensors, one should not match the end colors and hook white-to-black (blue-to-black) and black-to white, (black-to-blue) imposing an excitation voltage from between these two junctions, and read the differences across the reds, as increased load pulls one side high and the other side low.  This will look like the plain 4-resistor wheatstone bridges in the common datasheets, rather than the 4-half-bridge/eight-resistor scheme above. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-15T03:18:57.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18699" PostTypeId="2" ParentId="13243" CreationDate="2015-12-15T06:30:41.063" Score="1" Body="&lt;p&gt;I am not sure why no one has suggested a Microwave Doppler sensor. I am not sure how it would work in an outdoor environment but it is designed to detect motion regardless of whether it is a human. This &lt;a href=&quot;http://jpnelson.com/post/37623468093/microwave-motion-sensors-for-fun-and-profit-hb100&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; has some information about using a cheap Microwave sensor with an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="15519" LastActivityDate="2015-12-15T06:30:41.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18700" PostTypeId="1" CreationDate="2015-12-15T08:45:42.440" Score="1" ViewCount="294" Body="&lt;p&gt;I am trying to find out if it is possible to light up multiple LEDs with a standard Arduino Uno. Say I have 500 LEDs and logically I give each one of them a number from 1 to 500. In my test scenario I'd like to say something like &quot;LED No 275 On&quot; and as a result only have this single LED turning on while all others remain off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to do that at all? Or will I have to use many different Arduino Unos for that?&lt;/p&gt;&#xA;" OwnerUserId="13612" LastActivityDate="2015-12-17T06:37:08.957" Title="Light up multiple LEDs with standard Arduino Uno" Tags="|arduino-uno|led|pins|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18701" PostTypeId="1" AcceptedAnswerId="18710" CreationDate="2015-12-15T08:49:57.087" Score="1" ViewCount="4473" Body="&lt;p&gt;Is it possible to uncrimp a RJ45 plug and connect the wires directly to the Arduino pins? I guess I'd have to decrypt the ethernet signal then on my Arduino which might not have enough processing power at command for such a task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to do it with an Ethernet shield, so please don't link any in the answers.&lt;/p&gt;&#xA;" OwnerUserId="15600" LastEditorUserId="6936" LastEditDate="2016-01-02T19:39:55.507" LastActivityDate="2017-05-18T18:35:55.627" Title="Connect ethernet cable wires directly to pins" Tags="|pins|ethernet|wires|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18702" PostTypeId="1" CreationDate="2015-12-15T08:51:01.533" Score="2" ViewCount="186" Body="&lt;p&gt;I'm running arduino 1.6.6 sketchbook, and been using the sketch book for my arduino uno for a couple of months. A week ago roughly it started acting weird, for a reason I haven't been able to figure out even after extensive googling.&#xA;I got Windows 10 educational version (free version thx to my uni).&#xA;&lt;a href=&quot;https://i.stack.imgur.com/URYTE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/URYTE.png&quot; alt=&quot;The serial port name is gibberish&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In device manager, the board shows up correctly (named itself COM3 Arduino Uno)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/x9Tx8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x9Tx8.png&quot; alt=&quot;Device manager, shows up correctly&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it might have to do with drivers somehow, but reinstalls, updates, and every option I have tried so far has failed. The error that the sketchbook gives is avrdude: ser_open(): can't open device &quot;\.\COM3?ðÕ&amp;amp;¬ôÕ&amp;amp;´æiúd??þÿÿÿÈð&quot;: The system cannot find the file specified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone seen something similar before?&lt;/p&gt;&#xA;" OwnerUserId="15602" LastActivityDate="2015-12-15T08:51:01.533" Title="port name showing up as gibberish" Tags="|arduino-uno|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18703" PostTypeId="2" ParentId="18700" CreationDate="2015-12-15T09:08:40.860" Score="1" Body="&lt;p&gt;Probably the simple answer is to use 63 8-bit shift registers, with a LED and resistor attached to each shift register output pin. There are many good examples of using shift registers to add output ports on the internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shift register solution will let you turn on just one LED at a time, or if your power supply can stand it, all 500 at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question shows how to go about the expansion &lt;a href=&quot;https://arduino.stackexchange.com/questions/117/is-there-a-way-to-have-more-than-14-output-pins-on-arduino&quot;&gt;Is there a way to have more than 14 Output pins on arduino?&lt;/a&gt;&#xA;It also gives some other valid options.&lt;/p&gt;&#xA;" OwnerUserId="881" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2015-12-17T06:37:08.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18704" PostTypeId="2" ParentId="18701" CreationDate="2015-12-15T09:40:31.043" Score="1" Body="&lt;p&gt;I am by no means an expert on this, this answer is ~20 minutes of me googling things, but I would say that &lt;em&gt;in theory&lt;/em&gt; it is probably possible to do this with an arduino, at least at the lower transfer rates anyway, and certainly from a &quot;will it kersplode my board&quot; point of view - probably not since ethernet &lt;a href=&quot;https://en.wikipedia.org/wiki/Ethernet_over_twisted_pair&quot; rel=&quot;nofollow noreferrer&quot;&gt;runs at +/- 2v&lt;/a&gt; (ish) and &lt;a href=&quot;https://electronics.stackexchange.com/questions/36725/current-over-ethernet&quot;&gt;~10mA&lt;/a&gt; (ish). &lt;em&gt;However&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ethernet protocol is &lt;a href=&quot;http://ww1.microchip.com/downloads/en/AppNotes/01120a.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;exceedingly complex&lt;/a&gt;, with many layers needed to actually communicate with anything useful, all of which you would have to implement from scratch (there won't be a library to just drop in) and I'm not completely convinced that an entirely software-based implementation of the stack would fit on the arduino (but I could definitely be wrong there - and actually, on further thought, this probably is wrong, but I reckon &lt;em&gt;I&lt;/em&gt; couldn't write it so it fit, but I'm a reasonably average human being).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is all about hacking and re-inventing wheels just for the fun of it but I am absolutely certain that there is no fun to be had re-engineering Ethernet and TCP/IP and all of the stuff in betweeen from scratch (obviously my opinion, I enjoy all sorts of things others don't, so YMMV).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion would be - if you don't like ethernet shields, look into getting a 'raw' ethernet controller chip (like the one soldered onto an ethernet shield) and build it directly into whatever device you're trying to make &lt;em&gt;first&lt;/em&gt;, that'll give you plenty of exposure to how ethernet works at that level, then you can decide if you're still up for re-inventing the brain that invented the wheel. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="15415" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-15T09:40:31.043" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18706" PostTypeId="1" CreationDate="2015-12-15T11:59:23.423" Score="0" ViewCount="983" Body="&lt;p&gt;I have tried to find simple library for triggering timer after some time. &#xA;The idea is to retry network connection (RF24 network library). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have following code now  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(!mesh.write(message, headerType, memSize)) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code will try to send packet until success&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I need to give up after for instance 10 seconds &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanna to have something like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool timerTriggered = false;&#xA;Timer myTimer = new Timer(10000);&#xA;myTimer.setCallback(countedDown);&#xA;&#xA;void countedDown() {&#xA;   timerTriggered = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And start timer before network request &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myTimer.start();&#xA;&#xA;while(!mesh.write(message, headerType, memSize) || !timerTriggered) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please suggest the best way to implement this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found problem as far as delay(); uses timer internally it conflicts with libraries or simple timer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to use &lt;code&gt;Alarm.delay(400);&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe someone knows better solution ? &lt;/p&gt;&#xA;" OwnerUserId="7757" LastEditorUserId="7757" LastEditDate="2015-12-15T12:07:06.990" LastActivityDate="2015-12-15T14:24:43.027" Title="Arduino countdown timer for repeating actions" Tags="|arduino-nano|interrupt|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18707" PostTypeId="2" ParentId="18706" CreationDate="2015-12-15T12:17:37.210" Score="1" Body="&lt;p&gt;Something like this would work as a non-blocking, general purpose timer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long startTimestamp;&#xA;unsigned long timestamp;&#xA;const unsigned long timer_length = 10000; //10 seconds&#xA;&#xA;startTimestamp = millis();&#xA;timestamp = startTimestamp;&#xA;&#xA;while ( (timestamp - startTimestamp) &amp;lt; timer_length)&#xA;{&#xA;    // keep doing thing&#xA;&#xA;    timestamp = millis();&#xA;}&#xA;&#xA;// stop doing thing now&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15415" LastActivityDate="2015-12-15T12:17:37.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18709" PostTypeId="2" ParentId="18706" CreationDate="2015-12-15T14:24:43.027" Score="1" Body="&lt;p&gt;To expand on the other answer and combine it better with your situation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just check the current time in your while loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long startTime = millis();&#xA;while((!mesh.write(message, headerType, memSize)) &amp;amp;&amp;amp; ()millis() - startTime) &amp;lt; 10000)) {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, while it's not transmitted properly, and the difference between now and when you started transmitting is less that 10 seconds, keep trying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no need for any special libraries or asynchronous timers - it can all be done by examining &lt;code&gt;millis()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-15T14:24:43.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18710" PostTypeId="2" ParentId="18701" CreationDate="2015-12-15T14:27:15.793" Score="1" Body="&lt;p&gt;Electrically, you don't have to worry about anything, as the previous answer stated, but Ethernet (Even 100Mbps FastEthernet, much less Gigabit) is way too fast for the Arduino to read.  &lt;code&gt;digitalRead()&lt;/code&gt; is roughly 100x too slow, &lt;a href=&quot;http://jeelabs.org/2010/01/06/pin-io-performance/&quot; rel=&quot;nofollow&quot;&gt;it takes roughly 4 microseconds&lt;/a&gt;, and even doing direct port reads is 5x too slow.  This doesn't take into account another operations, much less the fact that the clocks on the Arduino's don't run that fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;100Mbps FastEtherent runs at roughly 31MHz, or 31,000,000 Hz.  That is FAST compared to our Arduino's, which have a clock speed of only 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your question in a word, no, it is not possible to do what you ask.&lt;/p&gt;&#xA;" OwnerUserId="7628" LastEditorDisplayName="user15297" LastEditDate="2015-12-16T01:20:11.160" LastActivityDate="2015-12-16T01:20:11.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18712" PostTypeId="1" AcceptedAnswerId="18713" CreationDate="2015-12-15T15:15:48.470" Score="0" ViewCount="502" Body="&lt;p&gt;I've got an RGB led strip I'm trying to control. It's a 12v, 4 pin strip. &#xA;Pin layout seems rather odd to me as 1 pin takes 12v of power and 3 pins (that go to ground) control the colors. In other words, &lt;strong&gt;the LED colors are controlled by limiting outgoing voltage&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HqvbV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HqvbV.jpg&quot; alt=&quot;Led Strip&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;White&lt;/strong&gt;- +12v&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Green&lt;/strong&gt;- Green in negative voltage&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Red&lt;/strong&gt; - Red in negative voltage&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Blue&lt;/strong&gt; - Blue in negative voltage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've already made a similar setup that uses n-channel MOSFETS (or at least I think that's what they are) between the colored cables and the ground and Arduino power the MOSFET gates as necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So my question is:&lt;/strong&gt; is it possible to hook these LEDs up directly to arduino and control the negative voltage without aditional electronics?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a slightly off topic question: Is there a specific name for elements that are controlled with negative voltages.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;By the way, I'm using Arduino nano, although I don't think it is relevant at this point and I've got Mega and Uno aswell if needed.&lt;/p&gt;&#xA;" OwnerUserId="15608" LastActivityDate="2015-12-15T15:26:10.030" Title="Negative voltage output Or Controling negative voltage" Tags="|arduino-nano|rgb-led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18713" PostTypeId="2" ParentId="18712" CreationDate="2015-12-15T15:21:03.080" Score="2" Body="&lt;p&gt;No, it's not possible, since the voltages and currents involved (12V) are too high.  It will damage your board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your arrangement with N-channel MOSFETs is the correct arrangement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, you are not working with &quot;negative&quot; voltages at all - it's all positive - you just happen to be between the &quot;load&quot; and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is called a &lt;strong&gt;Low Side Switch&lt;/strong&gt; since it is on the &quot;low&quot; (i.e., between the load and ground) side of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs you have are in an arrangement called &lt;strong&gt;Common Anode&lt;/strong&gt; in that the anodes (+ pins) of the LEDs are all tied together (common) and you control the cathode (- pins) of the LEDs.  It means you can use cheap N-channel MOSFETs that are (as you have seen) easy to control with a microcontroller.  The other arrangement, &lt;em&gt;Common Cathode&lt;/em&gt;, where all the cathodes (- pins) are tied together and you switch the power to the anodes (+ pins) requires P-channel MOSFETs &lt;em&gt;and&lt;/em&gt; N-channel MOSFETs to switch the P-channel MOSFETs, which increases costs.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-15T15:26:10.030" LastActivityDate="2015-12-15T15:26:10.030" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18714" PostTypeId="1" CreationDate="2015-12-15T16:05:40.223" Score="1" ViewCount="246" Body="&lt;p&gt;I have connected an &lt;a href=&quot;https://www.sparkfun.com/products/242&quot; rel=&quot;nofollow&quot;&gt;Infrared sensor&lt;/a&gt; to my Arduino Uno and I've set this code up to blink whenever a distance of less than 50 cm is picked up. If there is an object less than 50 cm away, it does pick it up. However, with nothing in front of it it still blinks at random intervals. The sensor is new. Where do you think the problem is? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorPin = 0;&#xA;int ledPin = 13;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  float distance = 12343.85 * pow(analogRead(sensorPin),-1.15);&#xA;  if(distance &amp;lt; 50){ &#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(ledPin, LOW);&#xA;  } &#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15610" LastEditorUserId="6936" LastEditDate="2016-01-02T20:39:26.257" LastActivityDate="2018-01-19T21:57:31.070" Title="Infrared distance sensor picks up distances that are not there" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18715" PostTypeId="2" ParentId="18701" CreationDate="2015-12-15T17:53:27.797" Score="2" Body="&lt;p&gt;As others have stated, it's not physically possible for an Arduino to encode or decode standard Ethernet protocol messages over CAT5 cable with wires at one end connected directly to the Arduino pins, and the other plugged into a standard Ethernet device.&#xA;Standard Ethernet runs at least 10 Mbit/s for &lt;a href=&quot;http://www.fpga4fun.com/10BASE-T3.html&quot; rel=&quot;nofollow&quot;&gt;10BASE-T, each bit Manchester encoded&lt;/a&gt;, so effectively 20 Mbit/s. See &lt;a href=&quot;http://www.testequity.com/documents/pdf/ethernet-debugging.pdf&quot; rel=&quot;nofollow&quot;&gt;&quot;TCP/IPv4 and Ethernet 10BASE-T/&#xA;100BASE-TX Debugging&quot;&lt;/a&gt; for a lot of photos of what the standard Ethernet protocol looks like on an oscilloscope screen.&#xA;An Arduino running at 16 MHz can't sample a pin at 20 Mbit/s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, Arduinos can easily transmit and receive messages using a variety of other, slower &lt;a href=&quot;http://en.wikibooks.org/wiki/Embedded_Systems/Common_Protocols&quot; rel=&quot;nofollow&quot;&gt;communication protocols&lt;/a&gt;.&#xA;Devices that use such protocols can often be wired directly to the Arduino pins, with the Arduino programmed appropriately with that protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Occasionally people use CAT5 cable (commonly called &quot;ethernet cable&quot;) to carry those non-Ethernet messages from one device to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes people wire a RJ45 socket (also called a 8p8c socket) directly to an Arduino and corresponding RJ45 socket wired directly to the other device (often with a big &quot;THIS IS NOT ETHERNET&quot; warning on both sockets), and use standard off-the-shelf CAT5 patch cables with standard &lt;a href=&quot;http://cp.literature.agilent.com/litweb/pdf/5989-7528EN.pdf&quot; rel=&quot;nofollow&quot;&gt;RJ25 plugs (also called 8p8c plugs)&lt;/a&gt; to carry those non-Ethernet messages between the sockets.&#xA;(For example, the connection between the Arduino-compatible &quot;&lt;a href=&quot;http://reprap.org/wiki/Motherboard_1_2&quot; rel=&quot;nofollow&quot;&gt;Motherboard 1.2 Generation 3&lt;/a&gt;&quot; and the &quot;&lt;a href=&quot;http://reprap.org/wiki/Stepper_Motor_Driver_2.3&quot; rel=&quot;nofollow&quot;&gt;Stepper Motor Driver 2.3 Generation 3&lt;/a&gt;&quot; used in some early RepRaps; the &lt;a href=&quot;http://reprap.org/wiki/TechZone_Tip_Assembly#Thermocouple_A-D_converter_with_OneWire&quot; rel=&quot;nofollow&quot;&gt;TechZone Thermocouple A-D converter&lt;/a&gt; and other &lt;a href=&quot;http://www.opencircuits.com/1-wire&quot; rel=&quot;nofollow&quot;&gt;1-wire devices that use the 1WRJ45 standard&lt;/a&gt;; etc.&#xA;As far as I can tell, none of the many CAT5 cables Nate connected to various Arduinos in &lt;a href=&quot;https://www.sparkfun.com/tutorials/282&quot; rel=&quot;nofollow&quot;&gt;&quot;Lessons from Rebuilding Illumitune&quot;&lt;/a&gt; actually carry any Ethernet messages.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes people cut and strip the ends of CAT5 cable, using them as a convenient bundle of wires that can be used pretty much like any wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hooking wires directly between two Arduinos (or an Arduino and some other device using some non-Ethernet protocol) often seems to work when both are plugged into the same power supply and connected by a short cable. The &quot;extra hardware&quot; people use to interface between an Arduino and a Ethernet network or CANbus or RS485 bus or MIDI or etc. helps avoid a variety of problems that happen when two devices are plugged into different power supplies or have long cable runs between them or both.&lt;/p&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-12-15T17:53:27.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18716" PostTypeId="1" CreationDate="2015-12-15T18:56:00.037" Score="1" ViewCount="319" Body="&lt;p&gt;So I have been trying to write a code where I use the &lt;code&gt;millis()&lt;/code&gt; function to print the milliseconds of on-time of the board using &lt;code&gt;Serial&lt;/code&gt;. But the condition is I want to stop printing the value once it reaches 10 seconds (10000ms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been trying to use the &lt;code&gt;exit()&lt;/code&gt; function but I get no output then. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;stdlib.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Serial.begin(9600);          //  setup serial&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;&#xA;unsigned long timer1;&#xA;&#xA;while(timer1%10000!=0)&#xA;&#xA;{&#xA;&#xA;timer1=millis();&#xA;&#xA;Serial.println(timer1);&#xA;&#xA;}&#xA;&#xA;    exit(1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15613" LastEditorUserId="6936" LastEditDate="2016-01-02T19:36:48.293" LastActivityDate="2016-01-02T19:36:48.293" Title="exit(0) function shows up an error" Tags="|arduino-uno|programming|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18718" PostTypeId="2" ParentId="18716" CreationDate="2015-12-15T19:54:04.540" Score="2" Body="&lt;p&gt;The AVR library documentation for &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__stdlib_1ga137096a48cc0c731052cadfb69c39b34.html&quot; rel=&quot;nofollow&quot;&gt;exit()&lt;/a&gt; is great help. It explains that the interrupts are turned off and an infinite loop is entered. As the interrupts get turned off the last characters in the Serial buffer are not transmitted. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://www.arduino.cc/en/Serial/Flush&quot; rel=&quot;nofollow&quot;&gt;Serial.flush()&lt;/a&gt; to wait for the transmission to complete before calling exit(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-15T20:07:55.567" LastActivityDate="2015-12-15T20:07:55.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18720" PostTypeId="2" ParentId="18669" CreationDate="2015-12-15T20:13:29.767" Score="0" Body="&lt;p&gt;You cannot connect from Arduino serial input/output with RS485 circuit and then to the PC RS232 port. You need a TTL to RS232 adapter. For instance an adapter based on &lt;a href=&quot;http://pdfserv.maximintegrated.com/en/ds/MAX3222-MAX3241.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MAX3222&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TPUVf.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TPUVf.gif&quot; alt=&quot;MAX3232 circuit diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-15T20:30:08.957" LastActivityDate="2015-12-15T20:30:08.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18721" PostTypeId="1" CreationDate="2015-12-15T20:52:02.817" Score="0" ViewCount="576" Body="&lt;p&gt;What I would like to do is,&#xA; step 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led1 fades from black(off) to green (max-on 255)&#xA;led2 fades from black(off) to red (max-on 255)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this happens at the same time.&#xA;If the max value is reached, then both leds fade out (to black, off)&#xA;so step 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led1 fades from green to black &#xA;led2 fades from red to black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then step 3, almost same as step 1 but opposite colours:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led1 fades from black(off) to red(max-on 255)&#xA;led2 fades from black(off) to green(max-on 255)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And step 4, both fade to black&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;led1 fades from green to black &#xA;led2 fades from red to black&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the code that fades led 1/3/5 from red to black and back to red&#xA;and led 2/4/6 from green to black, and back.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;    #define NUM_LEDS 6&#xA;    #define DATA_PIN 3&#xA;&#xA;        CRGB leds[NUM_LEDS];&#xA;&#xA;           void setup() { &#xA;               Serial.begin(9600);&#xA;       FastLED.addLeds&amp;lt;NEOPIXEL, DATA_PIN&amp;gt;(leds, NUM_LEDS);&#xA;   }&#xA;&#xA;       void loop()&#xA;{&#xA;&#xA;&#xA;  int x = 1;&#xA;   for (int i = 1; i &amp;gt; -1; i = i + x){&#xA;&#xA;     leds[0] = CRGB(i,0,0);&#xA;     leds[1] = CRGB(0,i,0);&#xA;     leds[2] = CRGB(i,0,0);&#xA;     leds[3] = CRGB(0,i,0);&#xA;      Serial.println(i);&#xA;      FastLED.show();&#xA;      if (i == 55) x = -1;             // switch direction at peak&#xA;      delay(100);&#xA;&#xA;   } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;****Original question****&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to fade a led (WS2812B) from black to green or red, and&#xA;  back to black. (that is working)  But now I want the same led fading&#xA;  to blue.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;How could I do that? I was trying a if..else but can't figure it out&#xA;  Or should I count the for loops?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This is the starting code I am using&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;maybe something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (i==0)&#xA;{&#xA;             leds[0] = CRGB(i,0,0);&#xA;             leds[1] = CRGB(0,i,0);&#xA;             leds[2] = CRGB(i,0,0);&#xA;             leds[3] = CRGB(0,i,0);&#xA;}&#xA;    else&#xA;{&#xA;             leds[0] = CRGB(0,0,i);&#xA;             leds[1] = CRGB(0,0,i);&#xA;             leds[2] = CRGB(0,0,i);&#xA;             leds[3] = CRGB(0,0,i);&#xA;}&#xA;              FastLED.show();&#xA;              if (i == 100) x = -1;&#xA;              delay(100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;But that is not working. Any suggestions?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="8162" LastEditDate="2015-12-16T18:46:07.493" LastActivityDate="2015-12-17T02:27:40.807" Title="Counting loops or if..else" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18723" PostTypeId="1" CreationDate="2015-12-15T21:32:53.573" Score="3" ViewCount="4890" Body="&lt;p&gt;The CJMCU 8*8 LED board is a grid of 64 W2812 (addressable) LEDs. The board is configured as if it was one long LED strand (just a single  DIN, 5v and GND). For some flipping hair pulling reason, my code works fine on 2812 LED strands, but I get nothing on the board. Just random flickering when I jostle the 5V wire. Any ideas? Am I completely missing something here? Pretty sure the board is fine, just can't seem to take any input...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Here's a link to the board: &lt;a href=&quot;http://www.aliexpress.com/store/product/CJMCU-64Bit-WS2812-5050-RGB-LED-Development-Board-Built-in-RGB-Driver-White-SKU-11481/933826_32249197598.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/store/product/CJMCU-64Bit-WS2812-5050-RGB-LED-Development-Board-Built-in-RGB-Driver-White-SKU-11481/933826_32249197598.html&lt;/a&gt;) &lt;/p&gt;&#xA;" OwnerUserId="15617" LastActivityDate="2020-01-30T04:49:52.457" Title="Seeking help - Using CJMCU 8*8 LED matrix with arduino" Tags="|arduino-uno|led|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18724" PostTypeId="1" AcceptedAnswerId="18725" CreationDate="2015-12-15T20:52:03.807" Score="2" ViewCount="1003" Body="&lt;p&gt;I bought some 'lucky dip' IR sensors from China, no idea what they are, but they appeared to get lost in the post so instead I &lt;a href=&quot;http://uk.rs-online.com/web/p/ir-receivers/7085086/&quot; rel=&quot;nofollow noreferrer&quot;&gt;bought some of these&lt;/a&gt; from a reputable place in the UK that come with a &lt;a href=&quot;http://docs-europe.electrocomponents.com/webdocs/0e56/0900766b80e56a95.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next day, both items arrived together! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to build a very simple proximity sensor for a robot, I built the following circuit:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/HJIUW.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fHJIUW.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and stole this code to test it out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define IRledPin 8&#xA;#define D13ledPin 13&#xA;#define IRsensorPin 9&#xA;&#xA;void IR38Write() {&#xA;  for(int i = 0; i &amp;lt;= 384; i++) {&#xA;    digitalWrite(IRledPin, HIGH);&#xA;    delayMicroseconds(13);&#xA;    digitalWrite(IRledPin, LOW);&#xA;    delayMicroseconds(13);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void setup(){&#xA;  pinMode(IRledPin, OUTPUT);&#xA;  digitalWrite(IRledPin, LOW);&#xA;  pinMode(D13ledPin, OUTPUT);&#xA;  digitalWrite(D13ledPin, LOW);&#xA;}&#xA;&#xA;&#xA;&#xA;void loop(){&#xA;  IR38Write();&#xA;  if (digitalRead(IRsensorPin)==LOW){&#xA;    digitalWrite(D13ledPin, HIGH);&#xA;  } else {&#xA;    digitalWrite(D13ledPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I hold my hand in front of it, nothing happens (LED on-board arduino should light up), &lt;em&gt;however&lt;/em&gt; if I point a TV remote at it and press a button, the LED lights up. I tested 2 of the 'fancy' sensors that I got and both behaved the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried one of the 'lucky dip' sensors, swapped it straight in and the whole thing works perfectly - point a TV remote and the LED lights, hold my hand ~10cm in front of it and the LED lights!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, where have I gone wrong?&lt;/p&gt;&#xA;" OwnerUserId="15415" OwnerDisplayName="MalphasWats" LastEditorUserId="37523" LastEditDate="2018-07-27T00:19:13.247" LastActivityDate="2018-07-27T00:19:13.247" Title="What's wrong with my IR sensor" Tags="|ir|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18725" PostTypeId="2" ParentId="18724" CreationDate="2015-12-15T21:09:49.477" Score="4" Body="&lt;p&gt;See page 5 of your datasheet - that 'fancy' sensor suppresses &quot;• Continuous signals at any frequency&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you'll need to pulse your 38.4kHz signal for the sensor to produce an output.&lt;/p&gt;&#xA;" OwnerUserId="8166" OwnerDisplayName="brhans" LastActivityDate="2015-12-15T21:09:49.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18726" PostTypeId="2" ParentId="18724" CreationDate="2015-12-15T22:27:38.927" Score="3" Body="&lt;p&gt;The answer I've accepted is the correct answer, but I wanted to add this extra bit for completeness. I reworked my code to use non-blocking delays for the IR LED so the sensor actually gets a chance to see it before it stops transmitting and it works! Range is quite a bit shorter than the 'lucky dip' sensor (~ 2cm).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define IR_LED 8&#xA;#define LED 13&#xA;#define SENSOR 9&#xA;&#xA;unsigned long burst_timer;&#xA;unsigned long gap_timer;&#xA;&#xA;unsigned long timestamp;&#xA;&#xA;char led_state;&#xA;char burst_count;&#xA;&#xA;const char BURST_MAX = 20;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(IR_LED, OUTPUT);&#xA;  led_state = LOW;&#xA;  burst_count = 0;&#xA;  digitalWrite(IR_LED, led_state);&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;  digitalWrite(LED, LOW);&#xA;&#xA;  pinMode(SENSOR, INPUT);&#xA;&#xA;  timestamp = micros();&#xA;  burst_timer = timestamp;&#xA;  gap_timer = timestamp;&#xA;}&#xA;&#xA;&#xA;void toggle_led()&#xA;{&#xA;  if (led_state == LOW)&#xA;  {&#xA;    led_state = HIGH;&#xA;  }&#xA;  else&#xA;  {&#xA;    led_state = LOW;&#xA;    burst_count++;&#xA;  }&#xA;&#xA;  digitalWrite(IR_LED, led_state);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  timestamp = micros();&#xA;  if (timestamp - burst_timer &amp;gt; 13 &amp;amp;&amp;amp; burst_count &amp;lt; BURST_MAX)&#xA;  {&#xA;    toggle_led();&#xA;    burst_timer = timestamp;&#xA;    gap_timer = timestamp;&#xA;  }&#xA;&#xA;  if (burst_count &amp;gt;= BURST_MAX &amp;amp;&amp;amp; timestamp - gap_timer &amp;gt; (13*2*BURST_MAX) )&#xA;  {&#xA;    burst_count = 0;&#xA;    burst_timer = timestamp;&#xA;    gap_timer = timestamp;&#xA;  }&#xA;&#xA;&#xA;  if (digitalRead(SENSOR) == LOW)&#xA;  {&#xA;    digitalWrite(LED, HIGH);&#xA;  } &#xA;  else &#xA;  {&#xA;    digitalWrite(LED, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every time I use &lt;code&gt;delay()&lt;/code&gt; (or &lt;code&gt;delayMicroseconds()&lt;/code&gt;) I find a new reason not to!&lt;/p&gt;&#xA;" OwnerUserId="15415" OwnerDisplayName="MalphasWats" LastActivityDate="2015-12-15T22:27:38.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18728" PostTypeId="2" ParentId="16121" CreationDate="2015-12-16T01:20:20.217" Score="2" Body="&lt;p&gt;From what I can see in your results, it seems &lt;code&gt;AT+HTTPINIT&lt;/code&gt; returned an error. This means the HTTP service wasn't even successfully activated. So there's no way the commands you issued later would have been successful. From the AT command manual, AT+HTTPINIT is necessary before you can do any HTTP-related stuff.&#xA;You need to run the command &lt;code&gt;AT+CGATT=1&lt;/code&gt; to attach GPRS, even if your query shows its value is already 1. &#xA;It could also be that your APN requires authentication, using a username and password. So once you find out the username and password authorized by 'indosatgprs' (customer care?), you can use them in the following commands.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    AT+SAPBR=3,1,&quot;USER&quot;,&quot;Enter the username here&quot;&#xA;    AT+SAPBR=3,1,&quot;PWD&quot;,&quot;Enter password&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both commands should return OK if successful. To view all the parameters you have set, you can use &lt;code&gt;AT+SAPBR=4,1&lt;/code&gt;. If all the parameters are satisfactory, and you have sufficient airtime in the SIM, then you can attempt &lt;code&gt;AT+HTTPINIT&lt;/code&gt;. Only if this command returns OK, should you proceed to run &lt;code&gt;AT+HTTPPARA&lt;/code&gt;-related commands. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-16T01:20:20.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18729" PostTypeId="2" ParentId="18661" CreationDate="2015-12-16T01:39:43.430" Score="0" Body="&lt;p&gt;A quick look at the library header files shows you should call &lt;code&gt;radio.stopListening()&lt;/code&gt; before calling &lt;code&gt;radio.write()&lt;/code&gt; for the module to switch to transmit mode. This could be what is blocking the &lt;code&gt;radio.write&lt;/code&gt; in the else block. I also recommend you try a &lt;code&gt;byte&lt;/code&gt; array first, to get things working, just in case &lt;code&gt;int&lt;/code&gt;s are the issue.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-16T01:39:43.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18730" PostTypeId="2" ParentId="18700" CreationDate="2015-12-16T04:13:00.180" Score="1" Body="&lt;p&gt;Rectangular matrices and strips of dozens or hundreds of LEDs are available from places like Adafruit and Sparkfun, with added circuitry to allow you to address and manipulate single LEDs easily. Some are single color, some are RGB. Adafruit in particular has many products like this and many tutorials on how to use them.&lt;/p&gt;&#xA;" OwnerUserId="7559" LastActivityDate="2015-12-16T04:13:00.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18733" PostTypeId="2" ParentId="18714" CreationDate="2015-12-16T08:55:49.360" Score="1" Body="&lt;p&gt;I see one problem with your code and how it relates to this device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output from the sensor is not the monotomic function you describe; not over its entire range.  Your conversion function describes only a section of the response.  The device is only intended to be used when an object is in range 10-80 cm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should check that the voltage at the analog input is valid before performing the math:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int v;&#xA;&#xA;v = analogRead(sensorPin);&#xA;// sensor is valid in range 0.4 to 2.5 V&#xA;if((82 &amp;lt; v) &amp;amp;&amp;amp; (v &amp;lt; 512)) {&#xA;  // voltage is in usable range, can convert&#xA;  distance = 12343.85 * pow(v,-1.15);&#xA;  if(distance &amp;lt; 50) { &#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(ledPin, LOW);&#xA;  }&#xA;}&#xA;else {&#xA;  // no valid reading - probably just skip and try again on next loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With that the false triggers may be eliminated.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastEditorUserId="3742" LastEditDate="2016-01-05T08:53:48.247" LastActivityDate="2016-01-05T08:53:48.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18734" PostTypeId="1" CreationDate="2015-12-16T09:14:35.660" Score="5" ViewCount="722" Body="&lt;p&gt;I am trying to decode the IR signals from a remote. I'm using an Arduino Pro Micro, and a TSOP38238 IR receiver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out that the remote uses the Nokia32(RCMM) protocol, and I have been able to partially decode it using cyborg5/IRLib (specifically this one: &lt;a href=&quot;https://github.com/cyborg5/IRLib/blob/master/examples/rcmm/rcmm.ino&quot; rel=&quot;nofollow&quot;&gt;rcmm.ino&lt;/a&gt;). I tweaked the values of the example using the LIRC file corresponding to my remote, mainly the absolute error tolerance (&lt;a href=&quot;http://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/free/Freebox_V5.lircd.conf&quot; rel=&quot;nofollow&quot;&gt;Freebox_V5.lircd.conf&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compared to other remotes I tried (with different protocols) the RCMM algorithm doesn't manage to decode the signal every time. Around 40% of the time when I press a button I got an &quot;Unknown type received&quot; output from the decoder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is three outputs (for the same button) of the algorithm for a successful decoding and below two other outputs corresponding to two failures. Could anyone tell me what could be done to increase the success of the decoding algorithm? &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Successful&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Decoded RCMM: Value:2400A601 (32 bits)&#xA;Raw samples(36): Gap:63264&#xA;  Head: m410  s290&#xA;0:m160 s290 1:m160 s590      2:m210 s390    3:m210 s240      &#xA;4:m210 s240 5:m210 s240      6:m210 s240    7:m210 s240      &#xA;8:m210 s540 9:m210 s590      10:m210 s390   11:m210 s590         &#xA;12:m160 s290    13:m160 s290         14:m160 s240   15:m210 s440         &#xA;&#xA;16:m160&#xA;Extent=9810&#xA;Mark  min:160    max:210&#xA;Space min:240    max:590&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Failure 1&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Unknown type received. Ignoring.&#xA;Decoded Unknown(0): Value:0 (0 bits)&#xA;Raw samples(36): Gap:3148&#xA;  Head: m410  s290&#xA;0:m160 s240 1:m210 s590      2:m210 s390    3:m210 s240      &#xA;4:m210 s240 5:m210 s240      6:m160 s290    7:m160 s290      &#xA;8:m160 s590 9:m210 s590      10:m160 s440   11:m210 s590         &#xA;12:m160 s240    13:m210 s240         14:m210 s240   15:m210 s390         &#xA;&#xA;16:m210&#xA;Extent=9810&#xA;Mark  min:160    max:210&#xA;Space min:240    max:590&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Failure 2&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Unknown type received. Ignoring.&#xA;Decoded Unknown(0): Value:0 (0 bits)&#xA;Raw samples(32): Gap:27904&#xA;  Head: m410  s290&#xA;0:m160 s290 1:m160 s590      2:m160 s490    3:m160 s240      &#xA;4:m210 s240 5:m160 s290      6:m160 s290    7:m160 s290      &#xA;8:m160 s290 9:m160 s590      10:m160 s490   11:m160 s590         &#xA;12:m160 s1190   13:m160 s440         14:m160&#xA;Extent=9460&#xA;Mark  min:160    max:210&#xA;Space min:240    max:1190&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15626" LastEditorUserId="6936" LastEditDate="2016-01-04T10:55:14.410" LastActivityDate="2016-02-07T19:30:48.777" Title="Nokia32/RCMM IR decoding issues" Tags="|ir|arduino-pro-micro|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18735" PostTypeId="2" ParentId="18680" CreationDate="2015-12-16T09:54:11.293" Score="2" Body="&lt;p&gt;This use of String is dangerous.  You are growing and shrinking the String in a loop and hoping the memory manager prevents any holes from forming:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clockResetcheck() {&#xA;&#xA;  char clkset[] = &quot;CLKSET.TXT&quot;;&#xA;  if  (myFile.open(clkset, O_READ)) {&#xA;&#xA;    uint16_t newYr;&#xA;    uint8_t  newDay;&#xA;    uint8_t  newMo;&#xA;    uint8_t  newHr;&#xA;    uint8_t  newMin;&#xA;    uint8_t  newSec;&#xA;    char data;&#xA;    String temp;&#xA;    int place = 0;&#xA;&#xA;    while ((data = myFile.read()) &amp;gt; 0) {&#xA;&#xA;    if (data == '/' || data == ':' || data == ',') {&#xA;      if (place == 0) {&#xA;        newDay = temp.toInt();&#xA;        temp = &quot;&quot;;&#xA;      }&#xA;      if (place == 1) {&#xA;      newMo = temp.toInt();&#xA;      temp = &quot;&quot;;&#xA;      }&#xA;      if (place == 2) {&#xA;        newYr = temp.toInt();&#xA;        temp = &quot;&quot;;&#xA;      }&#xA;      if (place == 3) {&#xA;        newHr = temp.toInt();&#xA;        temp = &quot;&quot;;&#xA;      }&#xA;      if (place == 4) {&#xA;        newMin = temp.toInt();&#xA;        temp = &quot;&quot;;&#xA;      }&#xA;      if (place == 5) {&#xA;        newSec = temp.toInt();&#xA;        temp = &quot;&quot;;&#xA;      }&#xA;      place++;&#xA;      if (place == 6) {&#xA;        myFile.close();&#xA;        break;&#xA;      }&#xA;    }&#xA;    else {&#xA;      temp = temp + data;&#xA;    }&#xA;  }&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;temp = temp + data&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a danger flag.  This sort of concatenation is going to reallocate the buffer used by String to make it fit the result.  The reallocate will leave behind a hole with the previous smaller string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;String has logic to reuse the buffer if possible.  So if you start big, it should not have to reallocate.  Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String temp(&quot;12345678&quot;);  // allocates the buffer at largest needed size&#xA;temp = &quot;&quot;; // clear out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is a less likely to fragment memory.  You have a few other concatenates in code that are similar danger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best advice to long running programs I ever received:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Stay off the heap.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are using String inside functions.  That means that buffers are allocated and freed again and again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better pattern is to remove &lt;strong&gt;all&lt;/strong&gt; the local String's in functions.  Instead use one global String as a temp buffer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String g_temp(&quot;                        &quot;);&#xA;void function1() {&#xA;   g_temp = &quot;&quot;;&#xA;   g_temp += char&#xA;}&#xA;void functionB() {&#xA;   g_temp = &quot;&quot;;&#xA;   // do stuff with g_temp&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this pattern, the allocate happens once when the program starts.  If the size is setup large enough, if will &lt;strong&gt;never&lt;/strong&gt; need to reallocate.  This means your high water mark for memory use is established at the time the program starts.  You don't have to monitor for a week to see if some corner case will run out of memory.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-12-16T09:54:11.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18736" PostTypeId="2" ParentId="12500" CreationDate="2015-12-16T11:14:32.993" Score="2" Body="&lt;p&gt;There is a new command for the ESP8266 in AT version:0.50.0.0 - SDK version:1.4.0 that lets you explicitly set the full UART configuration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;AT+UART_CUR&lt;/code&gt; – set the current UART configuration&#xA;This command sets the current UART configuration; it does not write to the flash. Hence there is no change in the default baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;AT+UART_CUR=9600,8,1,0,0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="15629" LastEditorUserId="10907" LastEditDate="2015-12-17T10:56:43.247" LastActivityDate="2015-12-17T10:56:43.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18737" PostTypeId="2" ParentId="18354" CreationDate="2015-12-16T13:08:26.453" Score="0" Body="&lt;p&gt;I had a similar problem recently while powering a servo with a Arduino.&#xA;It did turn out to be power, our Arduino could only supply about 500ma and with sufficient speed or torque on the servo (a lot of times just the boot sequence) we would it the 500ma at peak, the effect however was baffling at first because when we hit the peak current the Arduino would reboot, this could account for you extra delay at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For us the solution was simple bypass the Arduino when supplying current to the servos, in our case it as a 5v battery, you would probably need to drop the 12v to 6v in your case.&lt;/p&gt;&#xA;" OwnerUserId="15632" LastActivityDate="2015-12-16T13:08:26.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18738" PostTypeId="1" AcceptedAnswerId="18739" CreationDate="2015-12-16T18:00:53.327" Score="6" ViewCount="11892" Body="&lt;p&gt;I was doing a small project with an Arduino Uno. It involved interrupts as I am using encoders to measure how much the differential wheel system moves forward. My robot moves only forward. So I use only a single channel from each encoder. Here are my two interrupt routines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR (INT0_vect){&#xA;&#xA;      encoderRPos = encoderRPos + 1;     &#xA;&#xA;}&#xA;&#xA;ISR (INT1_vect){&#xA;&#xA;  encoderLPos = encoderLPos + 1;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variables &lt;code&gt;encoderRPos&lt;/code&gt; and &lt;code&gt;encoderLPos&lt;/code&gt; are of type &lt;code&gt;volatile int&lt;/code&gt;. I understand that the variables which undergoes change in any interrupt routine need to be of type volatile. This is to warn other parts of the code that use these variables that it may change anytime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what happened in my code was a bit strange and I could not explain it. Here is how I compute the distance moved by the left wheel:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #define distancePerCount 0.056196868  &#xA;  float SR = distancePerCount * (encoderRPos - encoderRPosPrev);&#xA;  float SL = distancePerCount * (encoderLPos - encoderLPosPrev);&#xA;&#xA;  encoderRPosPrev = encoderRPos;&#xA;  encoderLPosPrev = encoderLPos;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I print the following on my serial monitor, I notice an anomaly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DMDlf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DMDlf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the third column, (SL) it's value is too high just for some time. This is upsetting all my calculations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only clue I can get it, if I take the value of SL that I got (3682), which is always a constant, and calculate back &lt;code&gt;(encodeLPos - encoderLPosPrev)&lt;/code&gt;, I will get 65519.66, which is close to the max value of &lt;code&gt;unsigned int&lt;/code&gt;. Which means &lt;code&gt;(encoderLPos - encoderLPosPrev)&lt;/code&gt; is causing an overflow while both the values whose difference is taken is somewhere around 5000 only!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I managed to solve it. It was by luck. This is how I modified the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  static int encoderRPosPrev = 0;&#xA;  static int encoderLPosPrev = 0;&#xA;&#xA;  int diffL = (encoderLPos - encoderLPosPrev);&#xA;  int diffR = (encoderRPos - encoderRPosPrev);&#xA;&#xA;  float SR = distancePerCount * diffR;&#xA;  float SL = distancePerCount * diffL;&#xA;&#xA;  encoderRPosPrev = encoderRPos;&#xA;  encoderLPosPrev = encoderLPos;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't comprehend what has happened. Is there something about volatile variables that I should have known about?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href=&quot;http://paste.ubuntu.com/14085127/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is the entire code if you ever want to take a look. And it's working very well after changing it to what was suggested in the accepted answer.&lt;/p&gt;&#xA;" OwnerUserId="11145" LastEditorUserId="11145" LastEditDate="2015-12-18T04:39:43.367" LastActivityDate="2022-11-29T18:16:48.070" Title="How to properly use volatile variables in Arduino?" Tags="|arduino-uno|interrupt|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18739" PostTypeId="2" ParentId="18738" CreationDate="2015-12-16T18:08:37.427" Score="9" Body="&lt;p&gt;You need to learn about &lt;em&gt;critical sections&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is probably happening is that the variables are being changed by the interrupt routines mid-way through the calculations. Your 'fix' reduces the time spent doing the calculation with the volatile variables thus making it less likely that there is a collision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should do is copy the volatile variables to local variables with interrupts disabled for that brief period.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cli();&#xA;int l = encoderLpos;&#xA;int r = encoderRpos;&#xA;sei();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because the Arduino is an 8 bit CPU it takes multiple assembly instructions to perform mathematical operations on 16 bit values. Floating point is even worse using many many instructions for a simple addition. Division and multiplication use considerably more. An interrupt has plenty of opportunity to fire during that list of instructions. By doing an assignment like that and then using the new local variables in your calculations the instructions needed to deal with the volatile variables is kept to an absolute minimum.  By turning off interrupts during the assignment you guarantee that the variables can't ever be changed while you are using them. This snippet of code is called a &lt;em&gt;critical section&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-16T18:14:22.517" LastActivityDate="2015-12-16T18:14:22.517" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="18740" PostTypeId="1" CreationDate="2015-12-16T19:59:04.947" Score="2" ViewCount="2446" Body="&lt;p&gt;I recently purchased an Arduino Mega 2560. As soon as I connected it for the first time with my macbook pro the led was blinking (default blink program). To stop the blinking, I uploaded an empty sketch to Arduino. Now the arduino is not showing up in serial port in any operating system. The LED is constantly on and not blinking. Please help&lt;/p&gt;&#xA;" OwnerUserId="15423" LastActivityDate="2016-02-15T22:21:39.830" Title="Arduino Mega 2560 not showing up in Serial Port in IDE" Tags="|arduino-mega|mac-os|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18741" PostTypeId="2" ParentId="18740" CreationDate="2015-12-16T21:16:40.220" Score="1" Body="&lt;p&gt;Did you try:-&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Unplugging and reconnecting the board?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Holding down the reset button (on the board) during compile and then letting go when the Ide says &quot;Uploading to ...&quot;? (Make sure the sketch has a setup(){} and loop(){} so is not entirely empty)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work then ...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The pin13 on all the time with an empty sketch might indicate a hardware problem. Is anything connected to the board apart from the usb cable? Green LED simply means the board has power unless you are talking about the tx/rx Led's?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;for windows users ...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Look in &quot;Control Panel&gt;Device Manager&quot; to see if there is an exclamation mark against any devices, or &quot;Unknown/Other&quot; devices? If you can see the board but it has an error against it look at the properties to see if you can see what the error is. Re-installing the arduino ide will attempt to install the usb drivers again but they can also be found in the \drivers sub folder below the Arduino Ide.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can see an entry in control panel but it is not showing in the Arduino Ide try changing the port to a different COM number (right click&gt;properties)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can't see anything in Control Panel try a different usb port on your computer. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is the board connected directly to the pc via usb or via a usb hub? Make sure direct connect. If power externally make sure enough power.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2015-12-17T21:50:44.583" LastActivityDate="2015-12-17T21:50:44.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18742" PostTypeId="1" AcceptedAnswerId="18743" CreationDate="2015-12-17T01:33:04.023" Score="2" ViewCount="610" Body="&lt;p&gt;I am trying to use &lt;a href=&quot;https://learn.adafruit.com/tlc5947-tlc59711-pwm-led-driver-breakout/overview&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; board (setup tutorial on left hand nav) with my Arduino Uno.  I have tried using their example code, as well as my own simplified code, to turn on a single blue LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplified code I &quot;wrote&quot; is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Adafruit_TLC5947.h&quot;&#xA;&#xA;#define NUM_TLC5974 1&#xA;&#xA;#define data   3&#xA;#define clock   5&#xA;#define latch   6&#xA;&#xA;Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5974, clock, data, latch);&#xA;&#xA;void setup() {&#xA;  tlc.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  tlc.setPWM(0, 4095);&#xA;  tlc.write();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/tlc5947-tlc59711-pwm-led-driver-breakout/programming&quot; rel=&quot;nofollow&quot;&gt;Scroll to the bottom for reference. (TLC5947)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This compiles and uploads successfully.  I have DIN connected to 3, CLK to 5, and LAT to 6.  V+ is connected to the Arduino 5V pin, and GND to Arduino ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this setup, the LED does not turn on when connected to channel 0 on the board.  Using a multimeter, I have verified that the voltage between common ground and the channel 0 pin is ~0V.  Checking voltage on the board between GND and V+, I see 4.8V, which looks good.  Connecting the LED directly to the V+ line lights it up, but obviously isn't switchable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no clue why I'm not seeing anything on channel 0's output when I directly write it to 100% duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this not working?&lt;/p&gt;&#xA;" OwnerUserId="15645" LastEditorUserId="6936" LastEditDate="2016-01-02T19:35:51.533" LastActivityDate="2016-01-02T19:35:51.533" Title="Adafruit TLC5947 breakout board is not working with my Arduino Uno" Tags="|arduino-uno|led|pwm|voltage-level|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18743" PostTypeId="2" ParentId="18742" CreationDate="2015-12-17T01:38:05.390" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... the LED does not turn on when connected to channel 0 on the board. [...] Connecting the LED directly to the v+ line lights it up, but obviously isn't switchable.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From this I suspect that you have connected the LED between pin 0 and ground. The problem with doing this is that the TLC594x LED driver outputs are current &lt;strong&gt;&lt;em&gt;sinks&lt;/em&gt;&lt;/strong&gt;, and connect the output to ground when on. The LEDs must connect between V+ and the output as shown in the datasheet.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-17T01:38:05.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18744" PostTypeId="2" ParentId="18721" CreationDate="2015-12-17T02:27:40.807" Score="1" Body="&lt;p&gt;I would do that based on the clock. This lets you run each one independently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the off-chance that your project runs that long, the clock rolls over (resets) every 50 days.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to assume the 55 in your code should read 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would do something like this (this is a code snippet, but should get you started):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int phase_milliseconds=2500; // each phase lasts 2.5 seconds.&#xA;const phase_progress_length=256;   // each phase goes from 0 to 255&#xA;const phases=4;                    // numbered from 0 to 3, will repeat forever.&#xA;&#xA;// This is the time since your Arduino turned on&#xA;unsigned long time=millis();&#xA;// how far we are through the current phase?&#xA;int progress= time%phase_milliseconds)*phase_progress_length/phase_milliseconds;&#xA;&#xA;// which phase are we in?&#xA;int phase=(time/phase_milliseconds)%phases;&#xA;&#xA;if (phase==0) { // first step&#xA;         leds[0] = CRGB(progress,0,0);&#xA;         leds[1] = CRGB(0,progress,0);&#xA;} else if (phase==1) { // second step&#xA;         leds[0] = CRGB(255-progress,0,0);&#xA;         leds[1] = CRGB(0,255-progress,0);&#xA;} else if (phase==2) { // third step step&#xA;         leds[0] = CRGB(0,progress,0);&#xA;         leds[1] = CRGB(progress,0,0);&#xA;} else if (phase==3) { // fourth step&#xA;         leds[0] = CRGB(0,255-progress,0);&#xA;         leds[1] = CRGB(255-progress,0,0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since this is time based, it doesn't matter much how often it runs, you don't need a delay (you can still put one in if you like). You can extend this to more steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that I rattled this off, off the top of my head, so there may be errors.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2015-12-17T02:27:40.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18745" PostTypeId="1" AcceptedAnswerId="18766" CreationDate="2015-12-17T05:22:35.713" Score="5" ViewCount="3258" Body="&lt;p&gt;The DHT11 and DHT22 is a 4 pin temperature and humidity sensor, where one of the pins is labelled as NC (not connected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm curious what the unused pin is used for.&#xA;Factory calibration?&lt;/p&gt;&#xA;" OwnerUserId="4558" LastActivityDate="2015-12-17T16:35:27.890" Title="DHT11 and DHT22 unused pin" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18746" PostTypeId="2" ParentId="17147" CreationDate="2015-12-17T05:24:58.333" Score="1" Body="&lt;p&gt;It appears to me that when the ESP8266 sends a few characters to the Arduino, the initial version of the code always erases those characters (&lt;code&gt;data=&quot;&quot;;&lt;/code&gt;) without ever printing anything to your serial monitor.&#xA;So there is no way to tell whether the ESP8266 is sending anything or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it easier to debug, try printing &lt;em&gt;every&lt;/em&gt; character from the ESP8266 to the serial monitor, whether or not it makes a complete message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you see on the serial monitor with the following code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(2, 3); // RX, TX&#xA;&#xA;String data = &quot;&quot;;&#xA;&#xA;void setup(){&#xA;// Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;AT&quot;);&#xA;}//setup&#xA;&#xA;void loop(){&#xA;  if( mySerial.available()&amp;gt;0 ){&#xA;    char ch=mySerial.read();&#xA;    data.concat(ch);&#xA;    Serial.print((int)ch, HEX); // debug: print *every* character, in hex.&#xA;    if( ch=='\n' ){&#xA;      Serial.println();&#xA;      // Use &quot;F()&quot; macro as recommended by&#xA;      // https://learn.adafruit.com/memories-of-an-arduino/optimizing-sram .&#xA;      Serial.print(F(&quot;complete message:&quot;));&#xA;      Serial.println(data);&#xA;      data=&quot;&quot;;&#xA;      Serial.print(F(&quot;waiting for next message ...&quot;));&#xA;      }&#xA;  }&#xA;  if( Serial.available()&amp;gt;0 ){&#xA;    mySerial.write(Serial.read());&#xA;  }&#xA;}//loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="186" LastActivityDate="2015-12-17T05:24:58.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18748" PostTypeId="1" CreationDate="2015-12-17T06:19:00.607" Score="0" ViewCount="516" Body="&lt;p&gt;I have an Uno R3 with CH340G which works perfectly at my home w7 x64 notebook.&lt;br&gt;&#xA;It worked properly right away with the CH341s64.sys driver. I tried revs from 2009, 2011 and 2014 and it is working with either one.&lt;br&gt;&#xA;On my w7 x64 desktop though the drivers somehow do not communicate properly.&lt;br&gt;&#xA;If I plug in the device, windows recognized it and a new port (port 8 in my case) shows up in device manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to transfer a sketch to the device it fails with error message &#xA;avrdude: stk500_recv(): programmer is not responding.&lt;br&gt;&#xA;I have tried CH341s64.sys rev 3.3.2011.11  and 3.4.2014.8 without success.&lt;br&gt;&#xA;I have no clue how I can troubleshoot this as windows shows the port properly and there are no signs of error on the driver. There are no entries in the event logs.&lt;br&gt;&#xA;Is there possibly a log file from the IDE which could shine a light?&lt;br&gt;&#xA;I already tried with firewall disabled but no change.&lt;br&gt;&#xA;My IDE is the latest 1.6.6 on both systems.&lt;/p&gt;&#xA;" OwnerUserId="15646" LastEditorUserId="15646" LastEditDate="2015-12-17T07:20:48.540" LastActivityDate="2016-01-16T08:08:54.380" Title="Arduino clone with ch340G and correct w7 x64 driver cannot connect to IDE" Tags="|arduino-uno|clones|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18749" PostTypeId="2" ParentId="16150" CreationDate="2015-12-17T06:41:41.167" Score="3" Body="&lt;p&gt;I just tried it (using my own method), and I got it working with very good sensitivity (should be fine for two people) using a TIP102 Darlington transistor and some resistors. Here is what I did:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZlmX4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZlmX4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1, the 1M pulldown resistor on the first pin of the Darlington is necessary to keep the light off when nobody is touching the wires. Without this, the light will turn on and off frantically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R2, the 1k resistor keeps the Arduino from draining too much current (since that would be bad for the pin) in the case that your A0 is in OUTPUT mode and set to LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R3 keeps the LED (or in my case, an AC relay connected to an actual light) from draining too much current from the Arduino. Note: The LED leads may be backward (reverse polarity) in the provided diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// I release this code under the standard MIT licence;&#xA;// (in addition to whatever StackExchange implies);&#xA;&#xA;const short triggerThreshold = 10;// Lower is more sensitive;&#xA;&#xA;void setup() {&#xA;  pinMode(A0, INPUT);&#xA;  pinMode(A5, OUTPUT);&#xA;  digitalWrite(A5, LOW);&#xA;  delay(1);&#xA;}&#xA;&#xA;void loop() {&#xA;  short value = analogRead(A0);&#xA;  digitalWrite(A5, (value &amp;gt; triggerThreshold) ? HIGH : LOW);&#xA;  delayMicroseconds(10000);// 10ms;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the &lt;code&gt;triggerThreshold&lt;/code&gt; setting in the code. If you want more sensitivity, try changing the 10 to a 5. I just tried it, and it becomes &lt;em&gt;extremely&lt;/em&gt; sensitive, yet it still appears to reliably stay off when I don't touch it. Naturally if you use large plates for touching, electrostatic in the air could set it off, so you may need to change this number to be higher to make it less sensitive, depending on your setup.&lt;/p&gt;&#xA;" OwnerUserId="15303" LastEditorUserId="15303" LastEditDate="2015-12-17T22:57:06.367" LastActivityDate="2015-12-17T22:57:06.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18750" PostTypeId="2" ParentId="12021" CreationDate="2015-12-17T07:13:12.437" Score="1" Body="&lt;p&gt;I have a couple of these running right now, and they will often work at a slope when the surface is complex (not flat). However, the detection angle, as it comes from the sensors, appears to be about 30deg from centre in each direction. Hence, the sensors do need to be relatively pointed at the object being detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When placing my hand directly above it, it doesn't really matter what angle I tilt my hand, presumably since I have fingers that are not flat. On the other hand, if I put a paper towel in front of it, it will stop seeing it if I angle the paper towel more than 20 or so degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overall, if you keep the object within 30 degrees from the sensor's fixation point, it will work, granted the object, if flat, is &quot;pointed&quot; at (facing) the sensor flat-wise within about 20 to 25 degrees. For irregularly surfaced objects, it does not seem to matter too much unless the angle is pretty steep, such as 60 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I mean:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sKF5E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sKF5E.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15303" LastEditorUserId="15303" LastEditDate="2015-12-22T00:00:44.127" LastActivityDate="2015-12-22T00:00:44.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18751" PostTypeId="2" ParentId="18748" CreationDate="2015-12-17T07:24:06.040" Score="1" Body="&lt;p&gt;Solved:&lt;br&gt;&#xA;The issue was due to an USB Hub which I have at my desktop.&lt;br&gt;&#xA;After I connecting the arduino directly to an USB port at my desktop everything was fine.&lt;br&gt;&#xA;Unfortunately there is no hint about this in the arduino troubleshooting guide. A hub is only mentioned in conjunction with a MAC.&lt;/p&gt;&#xA;" OwnerUserId="15646" LastActivityDate="2015-12-17T07:24:06.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18753" PostTypeId="2" ParentId="18172" CreationDate="2015-12-17T11:22:47.003" Score="2" Body="&lt;p&gt;try this site: &lt;a href=&quot;https://github.com/Makeblock-official/Makeblock-USB-Driver/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Makeblock-official/Makeblock-USB-Driver/&lt;/a&gt; , it works for me. This is a driver for arduino, and command for bash&lt;/p&gt;&#xA;" OwnerUserId="15654" LastActivityDate="2015-12-17T11:22:47.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18754" PostTypeId="1" CreationDate="2015-12-17T12:22:20.757" Score="6" ViewCount="1130" Body="&lt;p&gt;I'm searching for a good water flow meter to add to my home controller project with Arduino. I have been searching in several pages and I only found some devices that work for low flow.  I need to control the water usage in my home and I thought to add a flow meter at the point where the water enters my home, and view the data with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have experience with any flow meter with good quality? &lt;/p&gt;&#xA;" OwnerUserId="15655" LastEditorUserId="6936" LastEditDate="2016-01-02T17:01:04.947" LastActivityDate="2016-02-01T18:33:37.070" Title="A good water flow meter to monitor home usage with Arduino" Tags="|sensors|hardware|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18755" PostTypeId="1" CreationDate="2015-12-17T12:29:04.900" Score="6" ViewCount="21981" Body="&lt;p&gt;I would like to get the &lt;strong&gt;best range possible&lt;/strong&gt; from my &lt;strong&gt;433MHz modules&lt;/strong&gt;. After A LOT of searching and reading, I'm convinced I should be able to cover &lt;strong&gt;10m indoors with free line of sight&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update]&lt;/strong&gt;&lt;br&gt;&#xA;After some tips in the comments I changed a few things. It looks like with an Arduino receiving in stead of a Pi, I get an extra meter, 1,5m now so still terrible. And 'as a bang on the fire arrow' as we say in Dutch, I now use two whip antenna's parallel to each other.&lt;br&gt;&#xA;Before moving to fix the reception on my Pi, I now first try to maximize the reception on the receiving Arduino. This makes it much more simple to investigate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update 2]&lt;/strong&gt;&lt;br&gt;&#xA;After some more tests I got to about 6 meters range. When the transmitter is behind 1cm of wood, this goes back to 30cm.&lt;br&gt;&#xA;My current 433MHz modules are going into the garbage bin, I thank you all for your time. I will look for a more stable alternative and maybe try some other/better433MHz modules like these: &lt;a href=&quot;http://www.ebay.com/itm/433MHz-Superheterodyne-RF-Link-kits-3400-ARM-MCU-Transmitter-and-Reveiver-/281169560721?hash=item4177030491:g:SUcAAOxyaTxTRKJn&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/433MHz-Superheterodyne-RF-Link-kits-3400-ARM-MCU-Transmitter-and-Reveiver-/281169560721?hash=item4177030491:g:SUcAAOxyaTxTRKJn&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[update 3]&lt;/strong&gt;&lt;br&gt;&#xA;The new modules made an enormous change. I can now send my data from across my house with no problems at all. No ground plane (will try that TwoD!) yet. Still on 5V transmitter voltage!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've asked a question before about my 433MHz setup so for full disclosure:&lt;br&gt;&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17733/433mhz-sending-not-receiving&quot;&gt;433MHz sending not receiving&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current range is about 40/50cm, this is not much since I use a straight antenna ~17cm at the receiver and a coil antenna at the transmitter:&lt;br&gt;&#xA;&lt;a href=&quot;http://www.instructables.com/id/433-MHz-Coil-loaded-antenna/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/433-MHz-Coil-loaded-antenna/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the modules I use:&lt;br&gt;&#xA;&lt;a href=&quot;http://www.ebay.com/itm/-/221524421949?roken=cUgayN&amp;amp;soutkn=xKBBUo&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/-/221524421949?roken=cUgayN&amp;amp;soutkn=xKBBUo&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And just FYI, I use these awesome working pumps:&lt;br&gt;&#xA;&lt;a href=&quot;http://www.ebay.com/itm/-/321779742264?roken=cUgayN&amp;amp;soutkn=hk1lrB&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/-/321779742264?roken=cUgayN&amp;amp;soutkn=hk1lrB&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried many antenna combinations and also upping the transmitter voltage to 12V but it doesn't help much. My aim is to reach 10m line of sight at the least.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I notice that my Pi outputs 4.77V to the receiver. &lt;/li&gt;&#xA;&lt;li&gt;The 4 penlites now output around 5V so transmitter power is low.  &lt;/li&gt;&#xA;&lt;li&gt;What I also like to test is adding 10uF caps to the V and GND of the transmitter but I have to wait for them to get delivered.&lt;/li&gt;&#xA;&lt;li&gt;I have the 10mw version of the transmitter, they may be just useless.&lt;/li&gt;&#xA;&lt;li&gt;The receiver stands in front of a speaker and a subwoofer, I turn those off when I test.&lt;/li&gt;&#xA;&lt;li&gt;The 433MHz modules came in pairs. I did not respect this and use any receiver with any transmitter, wonder if this is a problem. My end-goal is 3 transmitters on one receiver.&lt;/li&gt;&#xA;&lt;li&gt;Since I have multiple Tx/Rx modules, I swapped them to exclude DOA modules.&lt;/li&gt;&#xA;&lt;li&gt;Also tried these Helical antenna's, only made range worse; &lt;a href=&quot;http://www.ebay.com/itm/-/171271811976?roken=cUgayN&amp;amp;soutkn=TmOnpH&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/-/171271811976?roken=cUgayN&amp;amp;soutkn=TmOnpH&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My Arduino usses VirtualWire to send with 1000 baud to my Raspberry Pi, on the Pi side I use PIGPIO and the following code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if __name__ == &quot;__main__&quot;:&#xA;&#xA;   import time&#xA;   import datetime&#xA;   import pigpio&#xA;   import vw&#xA;   import json&#xA;   import requests&#xA;   from requests.auth import HTTPDigestAuth&#xA;&#xA;   # Setup receiving 433MHz port&#xA;   RX=27&#xA;&#xA;   # Setup Baud rate 433MHz&#xA;   BPS=1000&#xA;&#xA;   # Connect to local Pi.&#xA;   pi = pigpio.pi() &#xA;&#xA;   # Specify Pi, rx gpio, and baud.&#xA;   rx = vw.rx(pi, RX, BPS) &#xA;&#xA;   # Empty message&#xA;   msg = 0&#xA;&#xA;   # Save the time&#xA;   start = time.time()&#xA;&#xA;   # Run for 3 seconds&#xA;   while (time.time()-start) &amp;lt; 36000:&#xA;&#xA;      # Count msg per cycle&#xA;      msg += 1&#xA;&#xA;      # Sleep for .4 second&#xA;      time.sleep(0.4)&#xA;&#xA;      # Run while receiver is ready&#xA;      while rx.ready():&#xA;&#xA;         # String join received characters into message&#xA;         message = (&quot;&quot;.join(chr (c) for c in rx.get()))&#xA;&#xA;         # Print the received message to screen&#xA;         print(message)&#xA;&#xA;         # Create data dictionary&#xA;         data = {}&#xA;         data['meting']    = message[8:11]&#xA;         data['bericht']   = message[4:7]&#xA;         data['plant']     = message[1:3]&#xA;         data['timestamp'] = str(datetime.datetime.utcnow().isoformat())&#xA;&#xA;         # Print the data to the screen&#xA;         print(data)&#xA;&#xA;         # Setup filename for local data backup&#xA;         filename = str('data/' + data['plant'] + data['bericht'] + data['meting'] + '.json')&#xA;&#xA;         # Write JSON data file to disk&#xA;         with open(filename, 'w') as outfile:&#xA;            json.dump(data, outfile)&#xA;&#xA;         # Sending data&#xA;         url = 'http://server:8000/v1/documents?database=plantjes&amp;amp;extension=json'&#xA;&#xA;         # Setup headers&#xA;         headers = {&#xA;            'Content-Type': 'application/json'&#xA;         }&#xA;&#xA;         # Execute request&#xA;         r = requests.post(url, json = data, auth=HTTPDigestAuth('plantje', 'password'))&#xA;&#xA;         # Print request response&#xA;         print r&#xA;&#xA;   # Cancel the receiving of data&#xA;   rx.cancel()&#xA;&#xA;   # Stop PIGPIO listening on pins&#xA;   pi.stop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This script sends the measurement of the Hygro sensor to a database in JSON. This works like a charm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino uses this code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;#include &amp;lt;Sleep_n0m1.h&amp;gt;&#xA;&#xA;String pid = &quot;p02&quot;;&#xA;const int led_pin = 11;&#xA;const int transmit_pin = 12;&#xA;const int hygroSensor = 0;&#xA;int hygroPower = 8;&#xA;const int pump_pin = 5;&#xA;int watering_level = 900;&#xA;&#xA;int count = 0;&#xA;Sleep sleep;&#xA;unsigned long sleepTime;&#xA;&#xA;void setup()&#xA;{&#xA;  // serial console setup&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;setting up&quot;);&#xA;&#xA;  // cycle sleep time in ms&#xA;  sleepTime = 10000;&#xA;&#xA;  // virtualwire setup&#xA;  vw_set_tx_pin(transmit_pin);&#xA;&#xA;  // setting of pin modes&#xA;  pinMode(hygroPower, OUTPUT);&#xA;  pinMode(led_pin, OUTPUT);&#xA;  pinMode(pump_pin, OUTPUT);&#xA;&#xA;  // Bits per sec&#xA;  vw_setup(1000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // delay to allow serial output to be ready after wake up&#xA;  delay(100); &#xA;&#xA;  // cycle counter&#xA;  count++;&#xA;&#xA;  // turn on hygro sensor module&#xA;  digitalWrite(hygroPower, HIGH);&#xA;&#xA;  // wait a bit for hygro sensor to start&#xA;  delay(1000);&#xA;&#xA;  // read the input on analog pin 0:&#xA;  int measure = analogRead(hygroSensor);&#xA;&#xA;  // Start light to show transmitting&#xA;  digitalWrite(led_pin, HIGH); &#xA;&#xA;  // log moment of sending&#xA;  Serial.println(&quot;Sending: &quot; + String(measure));&#xA;&#xA;  // create &amp;amp; send random message id&#xA;  String mid = &quot;m&quot; + String(random(100, 999));&#xA;&#xA;  // Sending data&#xA;  String hygrodata = &quot;d&quot; + String(measure);&#xA;  dataSend(pid + mid + hygrodata);&#xA;&#xA;  // Stop light to show transmitting&#xA;  digitalWrite(led_pin, LOW);&#xA;&#xA;  // Wait a second&#xA;  delay(1000);&#xA;&#xA;  // sleep code&#xA;  if(count &amp;gt;= 3)&#xA;  {&#xA;    // reset counter&#xA;    count = 0;&#xA;&#xA;    // run pump routine&#xA;    //waterpump(measure, mid, pid);&#xA;&#xA;    // log sleeping to serial console&#xA;    Serial.print(&quot;Going to sleep now..&quot;);&#xA;&#xA;    // set sleep mode&#xA;    sleep.pwrDownMode();&#xA;&#xA;    // turn off hygro module power&#xA;    digitalWrite(hygroPower, LOW);&#xA;&#xA;    // sleep for: sleepTime&#xA;    sleep.sleepDelay(sleepTime);&#xA;  }&#xA;}&#xA;&#xA;// Data sending funtion&#xA;int dataSend(String data) {&#xA;  // declare int for length of message&#xA;  int msglen;&#xA;&#xA;  // set length of message +1&#xA;  msglen = data.length() + 1;&#xA;&#xA;  // declare array of characters&#xA;  char envelope[msglen];&#xA;&#xA;  // put string in array&#xA;  data.toCharArray(envelope, msglen);&#xA;&#xA;  // log data to serial monitor&#xA;  Serial.println(data);&#xA;&#xA;  // send data&#xA;  vw_send((uint8_t *)envelope, sizeof(envelope));&#xA;&#xA;  // wait for sending to finish&#xA;  vw_wait_tx();&#xA;&#xA;  // return 1 for succes&#xA;  return 1;&#xA;}&#xA;&#xA;// Pump function&#xA;int waterpump(int measure, String mid, String pid) {&#xA;    // Log measure&#xA;    Serial.println(measure);&#xA;&#xA;    // Water when needed&#xA;    if (measure &amp;gt; watering_level) {&#xA;      // Turn on pump 2 seconds&#xA;      digitalWrite(pump_pin, HIGH);&#xA;      delay(3000);&#xA;      digitalWrite(pump_pin, LOW);&#xA;      // Send pump data&#xA;      dataSend(pid + mid + &quot;pump&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This controls the sensing of the messages and also the water pump I use to water my plant automagically when needed. This also works like a charm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CFJ3x.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CFJ3x.jpg&quot; alt=&quot;Arduino Hygo meter 433MHz setup&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QIJ9k.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QIJ9k.jpg&quot; alt=&quot;Raspberry Pi 433MHz receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14790" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-07-30T15:12:38.613" Title="433mhz range optimization" Tags="|rf|virtualwire|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18757" PostTypeId="1" CreationDate="2015-12-17T14:18:44.890" Score="5" ViewCount="4901" Body="&lt;p&gt;I want to build a scheme to get data from several DS18B20 sensors and write their temperature to serial. Before I connected them using parasite mode and using 2,7k resistor (because I didn't have 4,7k at home). Back then, it worked for 1 device, if I plug in another, it won't detect any of them (it writes &quot;No more addresses&quot;). Now I replaced 2,7k resistor with 4,7k and it doesn't detect any device connected. But if I do one little thing, which is replacing 4,7k resistor back with 2,7k, it will detect one device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is exactly how it is all connected now:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/y0xad.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/y0xad.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and here is the default sketch I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;// OneWire DS18S20, DS18B20, DS1822 Temperature Example&#xA;//&#xA;// http://www.pjrc.com/teensy/td_libs_OneWire.html&#xA;//&#xA;// The DallasTemperature library can do all this work for you!&#xA;// http://milesburton.com/Dallas_Temperature_Control_Library&#xA;&#xA;OneWire  ds(10);  // on pin 2 (a 4.7K resistor is necessary)&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius, fahrenheit;&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    Serial.println(&quot;No more addresses.&quot;);&#xA;    Serial.println();&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.print(&quot;ROM =&quot;);&#xA;  for ( i = 0; i &amp;lt; 8; i++) {&#xA;    Serial.write(' ');&#xA;    Serial.print(addr[i], HEX);&#xA;  }&#xA;&#xA;  if (OneWire::crc8(addr, 7) != addr[7]) {&#xA;    Serial.println(&quot;CRC is not valid!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println();&#xA;&#xA;  // the first ROM byte indicates which chip&#xA;  switch (addr[0]) {&#xA;    case 0x10:&#xA;      Serial.println(&quot;  Chip = DS18S20&quot;);  // or old DS1820&#xA;      type_s = 1;&#xA;      break;&#xA;    case 0x28:&#xA;      Serial.println(&quot;  Chip = DS18B20&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    case 0x22:&#xA;      Serial.println(&quot;  Chip = DS1822&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;Device is not a DS18x20 family device.&quot;);&#xA;      return;&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44);        // start conversion, use ds.write(0x44,1) with parasite power on at the end&#xA;&#xA;  delay(1000);     // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  Serial.print(&quot;  Data = &quot;);&#xA;  Serial.print(present, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;    Serial.print(data[i], HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.print(&quot; CRC=&quot;);&#xA;  Serial.print(OneWire::crc8(data, 8), HEX);&#xA;  Serial.println();&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;  celsius = (float)raw / 16.0;&#xA;  fahrenheit = celsius * 1.8 + 32.0;&#xA;  Serial.print(&quot;  Temperature = &quot;);&#xA;  Serial.print(celsius);&#xA;  Serial.print(&quot; Celsius, &quot;);&#xA;  Serial.print(fahrenheit);&#xA;  Serial.println(&quot; Fahrenheit&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there anything I am doing wrong? Because I somehow managed to get it working some time ago.&lt;/p&gt;&#xA;" OwnerUserId="15117" LastEditorUserId="4131" LastEditDate="2015-12-18T18:48:59.943" LastActivityDate="2015-12-20T03:05:48.360" Title="&quot;No more addresses&quot; when using multiple DS18B20 sensors" Tags="|arduino-uno|temperature-sensor|1-wire|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18759" PostTypeId="1" AcceptedAnswerId="18760" CreationDate="2015-12-17T14:52:55.193" Score="4" ViewCount="785" Body="&lt;p&gt;I need to power an arduino uno with a battery but for a very long period of time. And I read a lot of thing about this. Some say do not use a 9V battery with a regulator some other say that it is the best way. SO I am really confused and I need to know what's the best solution for this (taking into consideration the fact that I need my board to last a week at least, if it is possible?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15659" LastActivityDate="2015-12-18T19:05:04.520" Title="powering the arduino uno" Tags="|arduino-uno|battery|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18760" PostTypeId="2" ParentId="18759" CreationDate="2015-12-17T15:06:36.113" Score="7" Body="&lt;p&gt;The Arduino Uno is not really designed for that. Simply keeping the power indicator LED, regulators and extra circuits on for a week will require in the order of 1500-2000 mAh (10*24*7=1680mAh). That is without any application at all on the MCU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it is possible to modify the board and reduce this extra power requirements to less than 1 mA and as low as 0.1 mA. Or even better buy a Pro Mini clone and cut the wiring to the LED and regulator, and power with a 3.7 V/1500mAh battery directly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a great &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot;&gt;reference&lt;/a&gt; on the subject. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-17T15:06:36.113" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18761" PostTypeId="2" ParentId="18759" CreationDate="2015-12-17T15:11:27.423" Score="4" Body="&lt;p&gt;You will definitely not get a week out of a 9V cell - they have very small capacities (and are expensive relative to other types of cell).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Uno already has a regulator in it and this regulator wastes a certain amount of energy converting between different voltages. I'm certainly no expert, but from what I've gleaned over the last month or so of owning an Uno, powering it from batteries can be tricky if you want to do it for long periods of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably worth trying a 12v sealed lead acid battery - these have capacities measured in Amp Hours, rather than milli-amp hours like most other types of cell. The built-in voltage regulator in the Uno is good up to 20V, just be sure to connect to the barrel jack on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, without knowing more about what you're actually trying to power along with the Uno, it's difficult to make proper recommendations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also suggest looking at building your system with a naked MCU and a voltage regulator tailored to your application. That way you can throw away a lot of the stuff that uses power on the board that you don't need. (Start with a Breadboarduino and take stuff out from there!)&lt;/p&gt;&#xA;" OwnerUserId="15415" LastActivityDate="2015-12-17T15:11:27.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18762" PostTypeId="1" CreationDate="2015-12-17T15:19:18.767" Score="0" ViewCount="154" Body="&lt;p&gt;I've been doing some XBee experiments with Arduino Pro Mini 5V. I knew that XBee S2 is 3.3V only, so I've connected its Vcc to 3.3V from external supply, but I had also connected XBee RXTX to arduino TXRX, in this order, and since that i can't use my XBee Explorer to communicate with XCTU on my notebook. The connections with an 5V Arduino RXTX can cause damages to the XBee, even if the XBee was powered with 3.3V?&lt;/p&gt;&#xA;" OwnerUserId="15054" LastEditorUserId="15054" LastEditDate="2015-12-17T17:43:54.020" LastActivityDate="2016-01-07T13:22:53.353" Title="XBee + Arduino Problem" Tags="|power|xbee|arduino-mini|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18763" PostTypeId="1" AcceptedAnswerId="18764" CreationDate="2015-12-17T15:50:53.470" Score="1" ViewCount="1405" Body="&lt;p&gt;I am new  to Arduino. I have connected the Arduino to the computer and I have installed the necessary drivers. But when I am compiling the Blink.ino program and other programs, which is present in the example, I am getting an compilation error. I have the IDE folder in D:\ drive&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exec: &quot;D:\\Arduino\\arduino-nightly\\tools-builder\\ctags\\5.8-arduino5/ctags&quot;: file does not exist&#xA;    Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what to do. Please help me&lt;/p&gt;&#xA;" OwnerUserId="15660" LastEditorUserId="15660" LastEditDate="2015-12-17T16:35:03.043" LastActivityDate="2015-12-17T16:35:03.043" Title="None of the programs in Arduino example is compiling" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18764" PostTypeId="2" ParentId="18763" CreationDate="2015-12-17T15:56:34.847" Score="1" Body="&lt;p&gt;A couple of things here look odd – but then I don't use Windows very often – I'd suggest that you download a fresh copy of the stock (not development) Arduino IDE. You can get it &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's odd looking too me is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The double backslashes, they could be causing the file to appear not to exist, and&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;code&gt;arduino-nightly&lt;/code&gt; component in the path. That suggests to me that you're using a &quot;bleeding edge&quot; version of the IDE where problems are likely to creep in. These versions are for developers and people who like living on the edge (or who want to help with testing new features and the like).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;One thing to do to check out the first oddity is to actually try to follow that path (both with and without the double backslashes). If the file is there (without the double backslashes) then it seems like something is odd with the path construction in the IDE.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-17T16:08:17.327" LastActivityDate="2015-12-17T16:08:17.327" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18765" PostTypeId="2" ParentId="18745" CreationDate="2015-12-17T16:34:49.937" Score="0" Body="&lt;p&gt;in this datasheet both 3. and 4. pins are marked GND :&#xA;&lt;a href=&quot;https://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15180" LastActivityDate="2015-12-17T16:34:49.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18766" PostTypeId="2" ParentId="18745" CreationDate="2015-12-17T16:35:27.890" Score="2" Body="&lt;p&gt;On the DHT11 it's connected to pin 6 of the SOIC14 inside. So it's at least connected to something. But who knows what it's for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has a (internal) pull-up resistor to VCC of around 100kOhm on this pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected my logic analyzer to it, there is no signal, even while reading the sensor. Also connecting the arduino's signal wire to this (incorrect) pin does nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Factory calibration or testing would be my guess too, but who knows.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-17T16:35:27.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18767" PostTypeId="1" AcceptedAnswerId="18769" CreationDate="2015-12-17T17:59:40.620" Score="0" ViewCount="3128" Body="&lt;p&gt;I've bought and Arduino Nano compatible on eBay:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Qax36.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qax36.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But by the time I connect it to my Macbook Pro (OS X El Capitan 10.11.2) doesn't appear under &quot;Tools -&gt; Port&quot; in Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IkAtJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IkAtJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've followed some instructions by other posts here in StackOverflow:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/5119/arduino-nano-no-serial-port-for-macbook-air-2013&quot;&gt;Arduino Nano no serial port for MacBook Air 2013&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13813/arduino-nano-with-mac-os-yosemite-10-10&quot;&gt;Arduino Nano with Mac OS Yosemite 10.10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But none of them worked :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could help me out with this issue I'll be grateful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15663" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-12-17T18:52:38.223" Title="Arduino Nano Atmega328P doesn't work on Macbook" Tags="|usb|arduino-nano|mac-os|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18768" PostTypeId="2" ParentId="18762" CreationDate="2015-12-17T18:25:22.910" Score="1" Body="&lt;p&gt;Just found this on Digi website. &quot;The XBee is a 3.3V only device, connecting 5V to any pin may damage the radio. If you had connected the XBee to a 5V microcontroller or power source, it's possible that the radio is damaged beyond repair&quot;. On this link, the last topic, knowledge.digi.com/articles/Knowledge_Base_Article/…. I really think that the XBee is gone. One way to avoid this problem is to get one of this regulated breakout board. &lt;a href=&quot;http://www.hobbytronics.co.uk/xbee-explorer-reg&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbytronics.co.uk/xbee-explorer-reg&lt;/a&gt;. As it says in the description, it regulates ALL pins to 3.3V, making me believe that I needed to take care of that before making such a mistake. Hopefully this prevent someone from doing this mistake in the future. So, bye-bye XBee.&lt;/p&gt;&#xA;" OwnerUserId="15054" LastEditorUserId="15054" LastEditDate="2016-01-07T13:22:53.353" LastActivityDate="2016-01-07T13:22:53.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18769" PostTypeId="2" ParentId="18767" CreationDate="2015-12-17T18:52:38.223" Score="1" Body="&lt;p&gt;I was be able to solve the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By looking for the serial chip my board has: CH340G I found this blog post: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I downloaded the signed driver for my chip and now it works :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Driver: &lt;a href=&quot;http://kiguino.moos.io/downloads/CH34x_Install.zip&quot; rel=&quot;nofollow&quot;&gt;http://kiguino.moos.io/downloads/CH34x_Install.zip&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="15663" LastActivityDate="2015-12-17T18:52:38.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18770" PostTypeId="1" AcceptedAnswerId="18775" CreationDate="2015-12-17T19:02:05.467" Score="0" ViewCount="82" Body="&lt;p&gt;On Dr. Monk's library page &lt;a href=&quot;http://www.doctormonk.com/2012/01/arduino-timer-library.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, he states: &quot;You can attach up to 10 events to a timer.&quot; I am wondering if this is a hardware limit, or if it was an arbitrary number he chose for his library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Timer.h, he defines the maximum number of timed events like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_NUMBER_OF_EVENTS (10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you foresee any problems if I changed that to a higher number? My sketch is already approaching the limit of 10 timed events running at the same time, so it would help me if I was able to increase the maximum number of timed events to about 20.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2015-12-17T19:29:56.930" Title="Can I increase the 10 event limit in Simon Monk's Timer library?" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18771" PostTypeId="1" AcceptedAnswerId="18781" CreationDate="2015-12-17T19:12:28.927" Score="0" ViewCount="1221" Body="&lt;p&gt;I have a Mega 2560 with a ramps 1.4 shield. I noticed when I turn on the 14v power supply the mega would also power up and run. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I damaging it running it at 14v? If not is there a solder or jumper somewhere that I can set it to only run the mega/logic on the usb power? The 14v is just for the stepper motors.&lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2015-12-17T22:06:34.563" Title="Can I run a Mega 2560 on 14v?" Tags="|arduino-mega|power|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18772" PostTypeId="2" ParentId="18759" CreationDate="2015-12-17T19:16:04.040" Score="3" Body="&lt;p&gt;Three main things to do to decrease the Uno's power consumption:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove the power LED (you can Google for instructions if you're not sure how to do it)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bypass the voltage regulator by providing ~5V of power to the 5V pin. You can arrange three sets of AA batteries in series to get about 4.5V which should be fine except that the crystal may run at a different speed (and you may get incorrect results from the millis() function for example). Obviously if that is unacceptable then you will need to provide a constant 5V voltage either by using the Arduino's regulator (which is quite inefficient) or buying a more efficient third-party regulator. The voltage provided by the batteries will vary somewhat, and over time the batteries will start putting out less voltage and eventually your Arduino may start to behave erratically or not at all. If reliability is of high importance then this may not be acceptable to you.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use sleep modes to the greatest extent possible (see &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/ArduinoSleepCode&lt;/a&gt;). If your Arduino only needs to wake up for a few seconds every hour, you can make a few batteries go a very long way. Note that if you're using a regulator, it will still draw significant power even while the Arduino is sleeping.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Bonus tip: buy a micro instead, or build your own board. (Avamander suggests a Pro Mini 3.3V in the comments below, he's probably right, I don't know much about that board)&lt;/p&gt;&#xA;" OwnerUserId="1656" LastEditorUserId="1656" LastEditDate="2015-12-18T19:05:04.520" LastActivityDate="2015-12-18T19:05:04.520" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18773" PostTypeId="1" CreationDate="2015-12-17T19:17:18.693" Score="0" ViewCount="781" Body="&lt;p&gt;How can I only let half of the LEDs light up,&#xA;for example, LED 1 on, LED 2 off, LED 3 on...and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did it this way&#xA;(this example fades also all LEDs on and off)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;   int x = 1;&#xA;   for (int i = 0; i &amp;gt; -1; i = i + x){&#xA;      leds[0] = CRGB(i,0,0);&#xA;      leds[1] = CRGB(0,i,0);&#xA;      leds[2] = CRGB(i,0,0);&#xA;      leds[3] = CRGB(0,i,0);&#xA;      Serial.println(i);&#xA;      FastLED.show();&#xA;      if (i &amp;gt;= 55) x = -1;             // switch direction at peak&#xA;      delay(10);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but that is not so nice if you have 100 LEDs or so.&lt;/p&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="84" LastEditDate="2016-09-18T14:12:42.157" LastActivityDate="2016-09-18T14:12:42.157" Title="Light only half of the LEDs" Tags="|arduino-uno|neopixel|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18774" PostTypeId="2" ParentId="18773" CreationDate="2015-12-17T19:21:08.450" Score="2" Body="&lt;p&gt;I don't know much about neopixel but as a general coding practice if you want to do something for every other object, you use the modulus operator like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(i % 2 == 0)&#xA;{&#xA;  //i is even&#xA;  //off&#xA;}&#xA;else&#xA;{&#xA;  //i is odd&#xA;  //on&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So just wrap your current for loop in another one and to the above with the iterating variable.&lt;/p&gt;&#xA;" OwnerUserId="3386" LastActivityDate="2015-12-17T19:21:08.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18775" PostTypeId="2" ParentId="18770" CreationDate="2015-12-17T19:29:56.930" Score="1" Body="&lt;p&gt;I don't see anything that would cause any issue. Just don't exceed 255.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-17T19:29:56.930" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18776" PostTypeId="2" ParentId="18773" CreationDate="2015-12-17T20:24:05.123" Score="1" Body="&lt;pre&gt;&lt;code&gt;int x = 1;&#xA;   for (int i = 0; i &amp;gt; -1; i = i + x){&#xA;     // using modulo&#xA;     if(i % 2 == 0){&#xA;     leds[i] = CRGB(i,0,0)}else{&#xA;     leds[i] = CRGB(0,i,0);}&#xA;&#xA;      Serial.println(i);&#xA;      FastLED.show();&#xA;      if (i &amp;gt;= 55) x = -1;             // switch direction at peak&#xA;      delay(10);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int x = 2;&#xA;   for (int i = 0; i &amp;gt; -1; i = i + x){&#xA;     leds[i] = CRGB(i,0,0);&#xA;&#xA;      Serial.println(i);&#xA;      FastLED.show();&#xA;      if (i &amp;gt;= 55) x = -2;             // switch direction at peak&#xA;      delay(10);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user15297" LastEditorDisplayName="user15297" LastEditDate="2015-12-18T06:58:14.480" LastActivityDate="2015-12-18T06:58:14.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18777" PostTypeId="1" CreationDate="2015-12-17T20:55:29.107" Score="2" ViewCount="61" Body="&lt;p&gt;How does one assert, from the Linux user land (root-er land?) on the Atheros AR9331, the 32u4's arduino-pin 7 for communication handshake?&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-17T20:55:29.107" Title="How to shake hands (Atheros-ATmega comms)" Tags="|arduino-yun|linux|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18779" PostTypeId="1" AcceptedAnswerId="18782" CreationDate="2015-12-17T21:12:08.780" Score="-2" ViewCount="63" Body="&lt;p&gt;I'm searching pc controlled quadrotor code projects.  I tried to do &lt;a href=&quot;https://github.com/strangedev/Arduino-Quadcopter&quot; rel=&quot;nofollow&quot;&gt;strangedev's project&lt;/a&gt; but not works for me. Is any one test this project. PID commands works like relays. suddenley speeds up and down. I tried to tune PID constants with Ziegler nichols but no success. Is there any realy working code and setup. Can you share your experiences? &lt;/p&gt;&#xA;" OwnerUserId="8552" LastActivityDate="2015-12-18T09:42:47.553" Title="Is there any realy working setup for multicopter with codes" Tags="|arduino-uno|pwm|pid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18780" PostTypeId="1" AcceptedAnswerId="18796" CreationDate="2015-12-17T21:29:49.757" Score="0" ViewCount="413" Body="&lt;p&gt;I connected a logic analyzer on digital pins 0 and 1 (Rx and Tx). Using &lt;code&gt;Serial.&lt;/code&gt; functions on Galileo and the integrated terminal on Arduino IDE, I noticed this UART port was not used when chars were received and transmitted, what is sustained by the blocks diagram of Galileo &lt;a href=&quot;https://www.arduino.cc/en/uploads/ArduinoCertified/IntelGalileoLogicSchematics.jpg&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if UART1 is used on PC communications, I would like to use UART0 to other things, like a bluetooth adapter. Any tips?&lt;/p&gt;&#xA;" OwnerUserId="15675" LastActivityDate="2015-12-18T07:37:00.160" Title="How to connect HC-05 to an arduino Galileo?" Tags="|uart|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18781" PostTypeId="2" ParentId="18771" CreationDate="2015-12-17T22:06:34.563" Score="1" Body="&lt;p&gt;You &lt;em&gt;can&lt;/em&gt;, but you shouldn't, because the the board will heat excessively, as you're out of the recommended range for the input voltage on vin (7-12V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless you have a &lt;em&gt;switching&lt;/em&gt; regulator (the one on the board is linear), then you shouldn't' have too much of a difference between the operating voltage and vin as an operating principle because of efficiency (and thus heat) issues.&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-17T22:06:34.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18782" PostTypeId="2" ParentId="18779" CreationDate="2015-12-17T22:32:44.683" Score="2" Body="&lt;p&gt;I've not used the (unmaintained) code you reference, but if a PID is responding much too fast in a new system, cut the parameters down significantly, first focusing on P and later I.  Turn off the D, and the I terms, then slow the P down until it is behaving reasonably.  Once Proportional control is working then try bringing I up in proportion to the change you did with P.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/strangedev/Arduino-Quadcopter/blob/master/quadcopter/quadcopter.ino#L62&quot; rel=&quot;nofollow&quot;&gt;https://github.com/strangedev/Arduino-Quadcopter/blob/master/quadcopter/quadcopter.ino#L62&lt;/a&gt; code starts with (P,I,D) values of (0.5,0,1), so back off to (0.25,0,0) or (0.05,0,0) or lower to get the speed or response more as you expect, and then experiment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Higher P will make it faster and saturate to the PID limit values quicker and make it more-relay like.  If your system is in a relay-like bang-bang mode, then Zeigler-Nichols tuning will be hard to do well. Reduce P until you get a non-relay-like response.    Show your code and add in some print/debugging to see what sort of pitch values give you what sort of outputs.  PID isn't magical, if you want a pitch measurement of -30 to cause a control output of +10, P=10/(-30)=0.3 might be a good starting point.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way the unmaintained code looks, value of P=20 will saturate at your output limits of +/-20 with only a pitch measurement of +/-1 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Show your actual code and values in your question, slow down the PID, and add debugging output. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2015-12-18T09:42:47.553" LastActivityDate="2015-12-18T09:42:47.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18784" PostTypeId="1" CreationDate="2015-12-18T02:08:32.077" Score="0" ViewCount="82" Body="&lt;p&gt;I am working on an Arduino project where I need more digital and analofgpins than the Uno offers. I was wondering how to hook up multiple Arduinos (4) together so I can use their digital and analog pins. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="15407" LastActivityDate="2015-12-31T18:08:21.220" Title="Multiple Arduino Uno Slaves" Tags="|arduino-uno|digital|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18786" PostTypeId="2" ParentId="18784" CreationDate="2015-12-18T03:33:58.140" Score="3" Body="&lt;p&gt;I suggest using a single &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega&lt;/a&gt;.  It offers 54 digital I/O and 16 analogue inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose you could also use I2C or SPI to communicate between multiple Uno's.&lt;/p&gt;&#xA;" OwnerUserId="15684" LastActivityDate="2015-12-18T03:33:58.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18787" PostTypeId="2" ParentId="18755" CreationDate="2015-12-18T03:36:44.950" Score="2" Body="&lt;p&gt;Have you ever tried the Nordic nRF24L01 based modules? They are available on eBay for very low cost, and operate in the 2.4 GHz band.  They should offer a range of at least tens of meters indoors.  I have had good success with these, and they are very easy to interface to Arduino.&lt;/p&gt;&#xA;" OwnerUserId="15684" LastActivityDate="2015-12-18T03:36:44.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18788" PostTypeId="1" CreationDate="2015-12-18T05:53:14.903" Score="-1" ViewCount="602" Body="&lt;p&gt;Could anyone please help me as I currently using &lt;a href=&quot;https://github.com/RedBearLab/nRF51822-Arduino&quot; rel=&quot;nofollow&quot;&gt;nRF51822-Arduino&lt;/a&gt; library with a nRF51822 chip and I couldn't call the interrupt function, &lt;code&gt;wakeUp()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I connect the external interrupt pin to nRF51822 pin: P0_1 or arduino pin: A0 after pin transform in the nRF51822-Arduino library. Maybe I know what value should I put for the variable &lt;code&gt;pin&lt;/code&gt; for the function below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(pin, wakeUp, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that when there is an interrupt change, it will call the &lt;code&gt;wakeUp()&lt;/code&gt; function?&lt;/p&gt;&#xA;" OwnerUserId="15686" LastEditorUserId="6936" LastEditDate="2016-01-03T16:44:38.877" LastActivityDate="2019-12-18T21:03:05.537" Title="Having issue using Arduino IRQ handler in nRF51822" Tags="|interrupt|nrf51|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18789" PostTypeId="1" AcceptedAnswerId="18795" CreationDate="2015-12-18T05:53:22.593" Score="1" ViewCount="2222" Body="&lt;p&gt;My intention was to overload a function to handle optional parameters. My code looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void functionA(const char *errorMsg) {&#xA;  functionA('0', errorMsg);&#xA;}&#xA;&#xA;void functionA(char errorCode, const char *errorMsg) {&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The line functionA('0',... generates the error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;invalid conversion from 'char' to 'const char*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I fix that?&lt;/p&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2015-12-18T07:29:49.197" Title="invalid conversion from 'char' to 'const char*'" Tags="|data-type|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18790" PostTypeId="1" AcceptedAnswerId="18793" CreationDate="2015-12-18T06:23:42.797" Score="1" ViewCount="2139" Body="&lt;p&gt;I am trying to build a project that contains more than one MPU 9250, until now I'm still confused to MPU9250. If I were going to that, does anybody here know how to set addresses to each of the MPU's I am going to use? Thank you for spending time reading my question. I hope someone will help me get through this.&lt;/p&gt;&#xA;" OwnerUserId="15688" LastActivityDate="2017-01-29T15:05:13.823" Title="How to set address for using more than MPU9250" Tags="|programming|arduino-mega|" AnswerCount="2" CommentCount="0" ClosedDate="2018-02-07T07:56:27.673" ContentLicense="CC BY-SA 3.0" />
  <row Id="18791" PostTypeId="2" ParentId="18790" CreationDate="2015-12-18T06:54:56.783" Score="0" Body="&lt;p&gt;This is the type of information which a Data Sheet is intended to communicate.  In I2C mode the AD0 pin selects between two possible addresses,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1101000 for AD0=0 and &#xA;1101001 for AD0=1.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In SPI mode you can presumably have as many as you like by giving each its own chip select.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, using multiple sensors may not be very useful unless your apparatus is flexible - only the 3 accelerometer axis would be expect to yield different values based on position relative to the center of rotations. &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-12-18T06:54:56.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18792" PostTypeId="2" ParentId="18789" CreationDate="2015-12-18T06:57:04.633" Score="1" Body="&lt;p&gt;What do your prototypes look like? I suspect that the compiler thinks that it is calling the first instance of &lt;code&gt;functionA()&lt;/code&gt; and is trying to cast &lt;code&gt;'0'&lt;/code&gt; to a 'const char *` and that isn't going to work…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have prototypes for both signatures, then adding the second one may solve your problem. If you do, I'm puzzled.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-18T06:57:04.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18793" PostTypeId="2" ParentId="18790" CreationDate="2015-12-18T07:03:33.040" Score="1" Body="&lt;p&gt;It is possible to have up to two MPU 9250 devices on an I2C bus without any extra logic. Pin 9 (AD0/SD0) defines the lowest bit in the I2C address of the device. Please see &lt;a href=&quot;http://43zrtwysvxb2gf29r5o0athu.wpengine.netdna-cdn.com/wp-content/uploads/2015/02/MPU-9250-Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;Chap 7.2 I2C Interface&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to connect more than two devices this can be done by connecting the AD0/SD0 pin of each device to a chip select pin on the arduino. This pin is asserted when addressing the device (This solution was provided by @Gerben, see comments below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example with three MPU 9250: Arduino D4-D6 are used as chip select pins. MPU1 AD0/SD0 pin connected to D4, MPU2 pin to D5, and MPU3 to D6. D4..D6 are initiate to HIGH. When addressing a MPU the chip select pin is set to LOW and the lower I2C address is used for access. The other MPUs will be listening for the higher I2C address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-18T23:28:21.173" LastActivityDate="2015-12-18T23:28:21.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18794" PostTypeId="2" ParentId="18788" CreationDate="2015-12-18T07:18:16.733" Score="0" Body="&lt;p&gt;Reading the source code for the attachInterrupt() shows that you should use the Arduino Pin number:&#xA;&lt;a href=&quot;https://github.com/RedBearLab/nRF51822-Arduino/blob/S130/arduino-1.6.x/hardware/RBL/RBL_nRF51822/cores/RBL_nRF51822/wiring_interrupter.cpp#L70&quot; rel=&quot;nofollow&quot;&gt;https://github.com/RedBearLab/nRF51822-Arduino/blob/S130/arduino-1.6.x/hardware/RBL/RBL_nRF51822/cores/RBL_nRF51822/wiring_interrupter.cpp#L70&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Pin number for A0 is 19 according to the pin transformation:&#xA;&lt;a href=&quot;https://github.com/RedBearLab/nRF51822-Arduino/blob/S130/arduino-1.6.x/hardware/RBL/RBL_nRF51822/cores/RBL_nRF51822/pin_transform.cpp#L64&quot; rel=&quot;nofollow&quot;&gt;https://github.com/RedBearLab/nRF51822-Arduino/blob/S130/arduino-1.6.x/hardware/RBL/RBL_nRF51822/cores/RBL_nRF51822/pin_transform.cpp#L64&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-18T07:18:16.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18795" PostTypeId="2" ParentId="18789" CreationDate="2015-12-18T07:29:49.197" Score="1" Body="&lt;p&gt;The compiler needs the &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/functions/&quot; rel=&quot;nofollow&quot;&gt;prototypes&lt;/a&gt; of the functions before the body containing the call to the overloaded function otherwise if starts complaining that the parameters does not match the known function (at this point in the source code).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// The function prototypes&#xA;void functionA(const char *errorMsg);&#xA;void functionA(char errorCode, const char *errorMsg);&#xA;...&#xA;void functionA(const char *errorMsg) &#xA;{&#xA;  functionA('0', errorMsg);&#xA;}&#xA;&#xA;void functionA(char errorCode, const char *errorMsg) &#xA;{&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-18T07:29:49.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18796" PostTypeId="2" ParentId="18780" CreationDate="2015-12-18T07:37:00.160" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://alextgalileo.altervista.org/blog/galileo-uart-and-arduino-serial-objects-mapping/&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; might answer your questions about the Serial mapping on Galileo. Seems like you should use Serial1 for UART0 and Serial2 for UART1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-18T07:37:00.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18797" PostTypeId="2" ParentId="18601" CreationDate="2015-12-18T07:59:18.237" Score="0" Body="&lt;p&gt;As a quick update for anyone who runs into a similar issue (granted, a week later)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I upgraded to 1.6.5 of the Arduino IDE, making sure to set my Arduino application folder appropriately, and the compilation issue has disappeared. I am able to compile and upload projects successfully.&lt;/p&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2015-12-18T07:59:18.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18799" PostTypeId="1" AcceptedAnswerId="18800" CreationDate="2015-12-18T11:53:47.397" Score="1" ViewCount="211" Body="&lt;p&gt;I'm working on a Raspberry Pi connected to an Arduino.&#xA;When I execute&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo 'Hello' &amp;gt; /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;, the Arduino receives the data, as indicated by its LED. How can I read the data on the Arduino and process it?&lt;/p&gt;&#xA;" OwnerUserId="15690" LastActivityDate="2015-12-18T13:13:38.253" Title="Can I receive data on the Arduino by sending data to /dev/ttyACM0?" Tags="|serial|usb|" AnswerCount="1" CommentCount="1" ClosedDate="2016-01-08T20:46:29.110" ContentLicense="CC BY-SA 3.0" />
  <row Id="18800" PostTypeId="2" ParentId="18799" CreationDate="2015-12-18T13:13:38.253" Score="2" Body="&lt;p&gt;Use Serial.read() there are plenty of examples that come with the Arduino IDE, just make sure the baud rates on the Raspberry Pi and Arduino match.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2015-12-18T13:13:38.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18802" PostTypeId="1" AcceptedAnswerId="18804" CreationDate="2015-12-18T15:03:05.413" Score="0" ViewCount="3625" Body="&lt;p&gt;Hello Everyone (I might be making some mistake in asking this &quot;question&quot;, bear with me as I am new to these sites... I honestly think this is the best way to frame my inquiry because it's rather elaborate)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like some help in understanding the &quot;timings&quot; of Arduino MEGA 2560's ADC module, especially with respect to the command &lt;em&gt;analogRead&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega2560 microcontroller Datasheet&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume, for now, that our conversions are normal ones ( the other type being a &quot;first&quot; conversion, which takes 25 ADC clock cycles instead of 13, due to the time required for the initialization of analog components )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understood, on a normal single conversion, the sample and hold happens after 1.5 ADC clock cycles from the start of the conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say that I set the prescaler to 32 with the following commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned char PS_32 = (1 &amp;lt;&amp;lt; ADPS2) | (1 &amp;lt;&amp;lt; ADPS0);&#xA;const unsigned char PS_128 = (1 &amp;lt;&amp;lt; ADPS2) | (1 &amp;lt;&amp;lt; ADPS1) | (1 &amp;lt;&amp;lt; ADPS0);&#xA;&#xA;ADCSRA &amp;amp;= ~PS_128;  // remove bits set by Arduino library&#xA;ADCSRA |= PS_32;  // set our own prescaler to 32 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;hence 16MHz / 32 = 500 kHz should be the new ADC clock frequency&#xA;( or 2 microseconds ADC clock period )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;since a normal single conversion takes 13 ADC cycles, the entire conversion should take about 26 microseconds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm not mistaken, (2 microseconds * 1,5)  = 3 microseconds after the ADC conversion starts, my analog pin value is set on hold, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I measured the elapsed time using the micros() function and, like I'd expect,&#xA;I found out that there's a little overhead introduced with analogRead function&#xA;because it takes about 28 \ 32 \ 36 microseconds (these are empirical measures).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;analyzing the code in wiring_analog.c&#xA;( which is located in the folder [...]/arduino/hardware/arduino/cores/arduino/ )&#xA;the actual conversion seems to happen at line 77&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// start the conversion&#xA;sbi(ADCSRA, ADSC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;does that mean that this is the instant from which the actual ADC conversion start, and so 1.5 ADC clock cycles from here, my analog pin value is set on hold?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can I know how much time passed before that sbi function call is issued?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw that a single instruction on arduino won't take more than 4 microseconds (but micros() function has that resolution so I don't exactly know!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, considering the so called &quot;first&quot; conversion, which take 25 ADC clock cycles&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does this conversion happen just the first time I call analogRead since I powered on Arduino?&#xA;or does it happen even after some time , because the ADC module gets powered off? (of course, I consider the case when Arduino remains powered on all the time)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Judging by the timings I measured it seems like that the former is the one really happening, even if I don't use ADC for some time, but can anyone confirm?&lt;/p&gt;&#xA;" OwnerUserId="15691" LastActivityDate="2015-12-23T15:31:59.790" Title="Arduino Mega 2560 ADC sampling instant and other timings" Tags="|analogread|adc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18803" PostTypeId="2" ParentId="18773" CreationDate="2015-12-18T15:30:50.950" Score="0" Body="&lt;p&gt;This is, for the most part, exactly what others have said. However, nobody has managed to actually use a &lt;code&gt;for&lt;/code&gt; loop properly; they've carried forward your inefficiencies for some unknown reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole point of a &lt;code&gt;for&lt;/code&gt; loop is to execute a block of code a predetermined number of times. In your code, you create a loop that loops for a ridiculous length (65,536 times) but each time checks how many loops there have been.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once the &lt;code&gt;for&lt;/code&gt; loop has been constructed properly there are two approaches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int NUMBER_LEDS = 100;      // you only ever have to change this&#xA;                            // if the number of LEDs change - and it's really&#xA;                            // easy to find if you put it at the start of&#xA;                            // your code.&#xA;&#xA;for (int x = 0; x &amp;lt; NUMBER_LEDS; x++)&#xA;{&#xA;    if (x % 2 == 0)&#xA;        leds[x] = CRGB(x,0,0);&#xA;    else&#xA;        leds[x] = CRGB(0,x,0);&#xA;    Serial.println(x);&#xA;    FastLED.show();&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code is fine if you just want two LED subsets. If you want more than two, you can use a &lt;code&gt;switch/case&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int NUMBER_LEDS = 100;      // you only ever have to change this&#xA;                            // if the number of LEDs change - and it's really&#xA;                            // easy to find if you put it at the start of&#xA;                            // your code.&#xA;int NUMBER_SETS = 4;        // this will give four groups.&#xA;&#xA;&#xA;for (int x = 0; x &amp;lt; NUMBER_LEDS; x++)&#xA;{&#xA;    switch (x % NUMBER_SETS)&#xA;    {&#xA;        case (0):&#xA;        {&#xA;            leds[x] = CRGB(0,0,0);&#xA;            break;&#xA;        }&#xA;        case (1):&#xA;        {&#xA;            leds[x] = CRGB(x,0,0);&#xA;            break;&#xA;        }&#xA;        case (2):&#xA;        {&#xA;            leds[x] = CRGB(0,x,0);&#xA;            break;&#xA;        }&#xA;        case (3):&#xA;        {&#xA;            leds[x] = CRGB(0,0,x);&#xA;            break;&#xA;        }&#xA;    }&#xA;    Serial.println(x);&#xA;    FastLED.show();&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't have to write a &lt;code&gt;case&lt;/code&gt; block for every outcome of &lt;code&gt;x%2&lt;/code&gt;; you might want a certain group of LEDs to stay on for two iterations, for example. More information on &lt;code&gt;switch/case&lt;/code&gt; can be found &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/control/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, towards the bottom of the page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you read this article on &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/operators/&quot; rel=&quot;nofollow&quot;&gt;Operators in C++&lt;/a&gt;, starting from &quot;Compound Assignement&quot;. It helps make code more readable and can considerably decrease the amount of typing you have to do - &lt;code&gt;i = i + 1&lt;/code&gt; neatly becomes &lt;code&gt;i++&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2015-12-18T15:30:50.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18804" PostTypeId="2" ParentId="18802" CreationDate="2015-12-18T16:02:05.233" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;does that mean that this is the instant from which the actual ADC&#xA;  conversion start, and so 1.5 ADC clock cycles from here, my analog pin&#xA;  value is set on hold?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. After between 3μs and 5μs. This is because conversion start at the following rising edge of the ADC clock cycle. This rising edge might have just happened, which means you need to wait 31 (main) clock cycles.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;how can I know how much time passed before that sbi function call is&#xA;  issued?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could copy the original code and create your own &lt;code&gt;analogRead2&lt;/code&gt; function that measures the time before setting ADSC.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I saw that a single instruction on arduino won't take more than 4&#xA;  microseconds (but micros() function has that resolution so I don't&#xA;  exactly know!)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A single instruction will take 1 or 2 clock cycles (if I remember correctly). So at 16Mhz that will mean 62.5ns (nano seconds) per clock cycle. Not 4ms&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now, considering the so called &quot;first&quot; conversion, which take 25 ADC&#xA;  clock cycles&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;does this conversion happen just the first time I call analogRead&#xA;  since I powered on Arduino? or does it happen even after some time ,&#xA;  because the ADC module gets powered off? (of course, I consider the&#xA;  case when Arduino remains powered on all the time)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Judging by the timings I measured it seems like that the former is the&#xA;  one really happening, even if I don't use ADC for some time, but can&#xA;  anyone confirm?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This first conversion is after the &lt;code&gt;ADEN&lt;/code&gt; bit changes from 0 to 1. If you don't unset this bit, all further conversions will take the shorter time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS on the first conversion, the sample-and-hold takes place after the extra 12 ADC clock cycles, so between cycle 12 and 13.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS this info is actually based on the ATMega328, but should be pretty similar in the 2560.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2015-12-23T15:31:59.790" LastActivityDate="2015-12-23T15:31:59.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18805" PostTypeId="1" AcceptedAnswerId="18809" CreationDate="2015-12-18T16:26:04.860" Score="2" ViewCount="8387" Body="&lt;p&gt;&lt;strong&gt;Use&lt;/strong&gt;&lt;br&gt;&#xA;I am assuming that this is possible for any phone model's battery. I am making this vague on purpose (this isn't for a specific project). The &lt;strong&gt;goal&lt;/strong&gt; is to have the most compact and long-lasting battery possible for my arduino projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;&#xA;I don't care about the cost. This would be for personal use (not selling this or using it for school), so I don't care about patenting or copyright issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;br&gt;&#xA;I want to know if this even makes sense for a portable arduino power source option. I want to benefit from newer phones' long battery life, as well as their compact size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Also:&lt;/em&gt;&lt;br&gt;&#xA;Are there better alternatives to this using different batteries? (I have looked at Nick Gammon's posts over setting sleep cycles to extend battery life (&lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;); If utilizing his methods on different batteries are better than using a phone battery please let me know...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If Possible...&lt;/strong&gt;&lt;br&gt;&#xA;Does it make sense for something like a:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LED suit (lasting 12 hours)&lt;/li&gt;&#xA;&lt;li&gt;Portable gaming system (lasting 8 hours) - similar to: (&lt;a href=&quot;https://www.adafruit.com/products/2510&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2510&lt;/a&gt;)&lt;br&gt;&#xA;&lt;em&gt;I Know this is for Raspberry Pi&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;BlueTooth Speaker (lasting 6 hours)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;etc...&lt;/p&gt;&#xA;" OwnerUserId="14947" LastActivityDate="2016-05-15T14:54:27.153" Title="Using a phone battery as a power source possible?" Tags="|power|battery|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18806" PostTypeId="1" AcceptedAnswerId="18807" CreationDate="2015-12-18T16:30:23.107" Score="0" ViewCount="1236" Body="&lt;p&gt;I am receiving 8 bytes from serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to convert and save in double variable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how i tried.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;union u_data&#xA;    {&#xA;        byte b[4];&#xA;        double fval;&#xA;    } u;&#xA;&#xA;double BytesToDouble (byte b8,byte b7,byte b6,byte b5,byte b4,byte b3,byte b2,byte b1)&#xA;{   &#xA;    u.b[0] = b1;&#xA;    u.b[1] = b2;&#xA;    u.b[2] = b3;&#xA;    u.b[3] = b4;&#xA;    u.b[4] = b5;&#xA;    u.b[5] = b6;&#xA;    u.b[6] = b7;&#xA;    u.b[7] = b8;&#xA; return u.fval;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i am getting 0.00. Because here double size is 4 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there is any other way to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15695" LastEditorUserId="2881" LastEditDate="2015-12-18T16:40:47.367" LastActivityDate="2015-12-18T16:40:47.367" Title="Handling double (8 byte) in Arduino mega 2560?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18807" PostTypeId="2" ParentId="18806" CreationDate="2015-12-18T16:34:23.920" Score="2" Body="&lt;p&gt;In the Arduino there is no such thing as a double. A double is just another name for a float.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will have to either:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Manually interpret the double format data and calculate that into a float value, or&lt;/li&gt;&#xA;&lt;li&gt;Send the value as some other format, such as float (32-bit), ASCII text, or (a selection of) integer values.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since you can't actually use anything more than float, sending data with a higher resolution is pointless, so you are probably best off just sending it as a float.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-18T16:34:23.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18808" PostTypeId="2" ParentId="18806" CreationDate="2015-12-18T16:34:56.013" Score="1" Body="&lt;p&gt;avr-gcc doesn't support &lt;a href=&quot;https://en.wikipedia.org/wiki/Double-precision_floating-point_format&quot; rel=&quot;nofollow&quot;&gt;binary64&lt;/a&gt;. You can use 8 bytes to treat it as an opaque data type, but attempting to manipulate it beyond manually converting to/from binary32 will be naught but pain.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-18T16:34:56.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18809" PostTypeId="2" ParentId="18805" CreationDate="2015-12-18T16:40:17.573" Score="1" Body="&lt;p&gt;Sounds like a good solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just note that most cellphones use Lithium batteries. Those are typically around 3.7 volt. They require some special way of charging, or they may &lt;strong&gt;explode&lt;/strong&gt; or catch on &lt;strong&gt;fire&lt;/strong&gt;. They also get damaged if discharged too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These batteries may have some protection circuitry inside them. This would be ideal in your case, as it protects against over-discharge, and accidental shorts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would be the cells used in notebooks called &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_battery_sizes#/media/File:Liion-18650-AA-battery.jpg&quot; rel=&quot;nofollow&quot;&gt;18650&lt;/a&gt;s. These are available with protection and without. The advantage is that you have a standard size. You can buy battery holders for them. That way you can easily exchange batteries. You can also combine cells to create higher voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the runtime; you can make a rough &lt;a href=&quot;http://oregonembedded.com/batterycalc.htm&quot; rel=&quot;nofollow&quot;&gt;calculation&lt;/a&gt; of it.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-18T16:40:17.573" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18811" PostTypeId="1" CreationDate="2015-12-18T17:13:46.497" Score="4" ViewCount="7509" Body="&lt;p&gt;I have a 12V 2.5 ampere Dc adapter.Can i use it to power arduino uno board?&#xA;It says on the arduino website that i can use 9-12V and upto 1 ampere. I am concerned with current limit here..&lt;/p&gt;&#xA;" OwnerUserId="13332" LastActivityDate="2018-02-13T12:45:37.423" Title="Arduino Power - DC adapter" Tags="|arduino-uno|power|current|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18812" PostTypeId="2" ParentId="18811" CreationDate="2015-12-18T17:44:28.333" Score="6" Body="&lt;p&gt;Don't worry about the current limit. The board will only draw what it needs. The spec is telling you that the board can draw as much as 1 amp, so in general the power supply should be able to supply that – more is no problem, but less could be if you have a lot of devices attached to the board that are drawing power as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As is pointed out in the comment above the higher the input voltage the more power the on-board regulator will need to dissipate (as heat). If you are using the barrel jack (which you should if you aren't providing power through an external regulator or other stable source) there is a diode (D1 in the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;reference design&lt;/a&gt;) in the input path and the &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/MC33269-D.PDF&quot; rel=&quot;noreferrer&quot;&gt;MC33269D-5.0 regulator&lt;/a&gt; is spec'd with a max dropout voltage of 1.25 V so you will need an input voltage of at least 6.95 V (assuming a 0.7 V drop across the diode).&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-18T21:24:42.030" LastActivityDate="2015-12-18T21:24:42.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18813" PostTypeId="1" CreationDate="2015-12-18T18:09:48.860" Score="1" ViewCount="348" Body="&lt;p&gt;I am looking for a solution regarding the gsr, accelerometer, heart rate, skin temperature. From this &lt;a href=&quot;https://arduino.stackexchange.com/questions/601/grove-sensors-without-a-grove-shield&quot;&gt;other question&lt;/a&gt; seems that Grove isn't clear enough with their documentation. So I am looking for other ideas. I already know cooking hacks and I am afraid that with their hardware I can't make my Arduino wearable and comfortable enough, because at the end I'd like to attach a lithium battery with a case (that's why I don't want the extra bulk of a shield).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details of what I am looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accelerometer:&#xA;Range: +/- 1.0g&#xA;Minimum resolution: 0.01g&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Galvanic Skin Response&#xA;Range: 56k Ohms to 20M Ohms &#xA;Two-standard-deviation error of +/- 4.0% otherwise&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Skin Temperature &#xA;Range: 20.0°C to 40.0°C&#xA;Resolution: 0.05°C&#xA;Error: +/- 0.8°C&lt;/p&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-21T05:22:35.650" Title="How can I attach sensors without a shield for a wearable project?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18814" PostTypeId="2" ParentId="18811" CreationDate="2015-12-18T18:11:17.977" Score="4" Body="&lt;p&gt;Make sure that the adapter you have is the correct polarity for the arduino or it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The barrel jack is centre positive, so look for this symbol on your adapter:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/riM6S.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/riM6S.png&quot; alt=&quot;centre positive symbol&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The barrel jack should have reverse voltage protection so it won't work if it's the wrong way around. The Vin pin doesn't have this protection, so be extra careful connecting things there.&lt;/p&gt;&#xA;" OwnerUserId="15415" LastEditorUserId="15415" LastEditDate="2015-12-18T21:25:33.070" LastActivityDate="2015-12-18T21:25:33.070" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18817" PostTypeId="2" ParentId="18813" CreationDate="2015-12-18T21:09:25.927" Score="1" Body="&lt;p&gt;The accelerometer may be pretty easy (since it may not need to be in close contact with the person), but the GSR and skin temperature will need to be touching the person to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing you will want to do is to identify the sensors that you want to use, and then come up with some ideas for how to make them wearable so that you can measure the parameters that you're looking for. Will you be able to attach them with straps, or does the attachment need to be more subtle or more comfortable? Small breakout boards are handy, but they may make the sensor uncomfortable to wear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest taking at look at the &lt;a href=&quot;http://adafruit.com&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt; site for some ideas on wearables and sensor interfacing. There is a lot of useful information there and much of it focuses on Arduino based designs. For the most part the sensors they sell and use are well documented either with data sheets or code (or both).&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-18T21:09:25.927" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18818" PostTypeId="1" CreationDate="2015-12-18T21:27:08.553" Score="3" ViewCount="1082" Body="&lt;p&gt;Using win7 and arduino 1.6.7 IDE&#xA;I have a rather large CONST array of chars and upon compile using atmega2560, it fails and says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 11,216 bytes (4%) of program storage space. Maximum is 253,952 bytes.&#xA;Global variables use 8,414 bytes (102%) of dynamic memory, leaving -222 bytes for local variables. Maximum is 8,192 bytes.&#xA;processing.app.debug.RunnerException: Not enough memory; see &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#size&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#size&lt;/a&gt; for tips on reducing your footprint.&#xA;    at cc.arduino.Compiler.size(Compiler.java:319)&#xA;    at cc.arduino.Compiler.build(Compiler.java:156)&#xA;    at processing.app.Sketch.build(Sketch.java:1108)&#xA;    at processing.app.Sketch.build(Sketch.java:1083)&#xA;    at processing.app.Editor$BuildHandler.run(Editor.java:2011)&#xA;    at java.lang.Thread.run(Thread.java:745)&#xA;Not enough memory; see &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#size&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#size&lt;/a&gt; for tips on reducing your footprint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I delete the CONST array the program compiles successfully, but when I put it back in, the compiler tells me that I'm using too much dynamic RAM.  If I am to understand correctly, consts should store in ROM not RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the even weirder part I put the program in Arduino IDE for Linux and it compiles, but it makes my robot act all crazy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15702" LastActivityDate="2015-12-20T13:45:48.350" Title="Const Array still using dynamic RAM during compile, causing failure" Tags="|arduino-uno|constants|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18819" PostTypeId="2" ParentId="18818" CreationDate="2015-12-18T21:38:46.690" Score="5" Body="&lt;p&gt;In a Princeton architecture &lt;code&gt;const&lt;/code&gt; arrays are stored purely within the &lt;code&gt;text&lt;/code&gt; (i.e., flash / read only / ROM) area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a Harvard architecture (which is what the Arduino is) the RAM and Flash both use completely different memory spaces, and instructions that work on RAM don't work on Flash, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of that it has to copy the &lt;code&gt;const&lt;/code&gt; array from Flash into RAM so it can be accessed as normal variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To combat this you can use &lt;code&gt;PROGMEM&lt;/code&gt; to force it to remain only in Flash, but then you have to use special functions to access the data - you can't use it like normal variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read more here: &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/PROGMEM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-18T21:38:46.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18820" PostTypeId="1" CreationDate="2015-12-18T21:56:15.287" Score="0" ViewCount="549" Body="&lt;p&gt;Newbie question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to pass the last byte of a local IP as a parameter.&#xA;Eg.: when Ethernet.localIP() returns 192.168.0.100,&#xA;I need to extract the 100 and put it in a char array or string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone any ideas? Thx!&lt;/p&gt;&#xA;" OwnerUserId="15631" LastActivityDate="2015-12-18T22:02:59.060" Title="How to extract the last byte out of an IP adress" Tags="|programming|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18821" PostTypeId="2" ParentId="18820" CreationDate="2015-12-18T22:02:59.060" Score="2" Body="&lt;p&gt;&lt;code&gt;localIP()&lt;/code&gt; returns an &lt;code&gt;IPAddress&lt;/code&gt; object.  That object has an operator for &lt;code&gt;[]&lt;/code&gt; allowing you to access the individual parts of it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IPAddress ip = Ethernet.localIP();&#xA;Serial.println(ip[3]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-18T22:02:59.060" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18822" PostTypeId="2" ParentId="18818" CreationDate="2015-12-18T22:24:41.770" Score="2" Body="&lt;p&gt;&lt;code&gt;Const&lt;/code&gt; data &lt;em&gt;may&lt;/em&gt; be stored in ROM but the standards don't require it; you usually have to specify in some (non-standard) way that it be placed there. I.e., &lt;code&gt;const&lt;/code&gt;-ness is a necessary, but not a sufficient, condition for locating into ROM. &lt;a href=&quot;http://www.dansaks.com/articles/1998-11%20Placing%20Data%20into%20ROM%20with%20Standard%20C.pdf&quot; rel=&quot;nofollow&quot;&gt;Placing Data into ROM with Standard C&lt;/a&gt; by Dan Saks is a short, well-written paper (as is typical of Saks) describing what the standards do and, particularly, do not say about ROMming of constant data. It is well worth a few minutes to read it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-12-20T13:45:48.350" LastActivityDate="2015-12-20T13:45:48.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18823" PostTypeId="2" ParentId="9115" CreationDate="2015-12-18T22:45:42.183" Score="2" Body="&lt;p&gt;Here is what I do. I detect whether the voltage is rising or falling and adjust the threshold based on that.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int ledPin = 13;   //pin 13 will be connected to the MOSFET SS relay&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    int sensorValue = analogRead(A0); // This is the main battery voltage sensor&#xA;    int RLA1;   //this will be connected to the MOSFET SS relay&#xA;    float threshold; //  To enable some hysteresis and prevent the relay from chattering, we move the threshhold, depending on whether we are going up or down&#xA;&#xA;    float Vmainold;  //  Used to detect whether we are going up or down&#xA;    float  Vmain;   // Main battery voltage.&#xA;    float Vaux;     // Auxillary battery voltage&#xA;&#xA;    Vmain = sensorValue / 204.6 + 9.8;   // Add back the ~10V that the zener shifts for higher resolution&#xA;&#xA;   if (Vmain &amp;gt; Vmainold) threshold = 13.2;  // If the voltage is rising, set threshhold to 13.2&#xA;   else&#xA;    if (Vmain &amp;lt; Vmainold) &amp;amp;&amp;amp; (Vmainold &amp;gt; 12.8) threshold = 12.8 // If the voltage is falling and previous voltage is above TH, set theshhold to 12.8&#xA;    else&#xA;        if (Vmain = Vmainold) threshold = 13.2;  // If the voltage is stable, set threshhold to 13.2&#xA;&#xA;   if (Vmain &amp;gt;= threshold) RLA1 = 1; //  Charging&#xA;&#xA;   else&#xA;    if (Vmain &amp;lt; threshold) { RLA1 = 0;  Vmainold = Vmain; }  // Not connected&#xA;&#xA;   delay(1000);&#xA;   Serial.print(Vmain);&#xA;   Serial.print(&quot;  Main  &quot;);&#xA;   Serial.print(Vmainold);&#xA;   Serial.print(&quot;  old  &quot;);&#xA;   Serial.println();&#xA;   Vmainold = Vmain;&#xA;   digitalWrite(ledPin, RLA1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;`&lt;/p&gt;&#xA;" OwnerUserId="15704" LastEditorUserId="3917" LastEditDate="2015-12-30T16:49:12.997" LastActivityDate="2015-12-30T16:49:12.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18824" PostTypeId="2" ParentId="18757" CreationDate="2015-12-18T22:52:43.883" Score="0" Body="&lt;p&gt;A strong-pullup seems to be the key to having multiple sensors in parasitic mode, as described in the datasheet for the DS18b20 devices. Though they suggest using a MOSFET to pull up the 1-wire bus, I've had good results (3 meters of wire, 3 devices more than 2 meters out) by tying an output port directly to the 1-wire bus, bypassing the 4.7K resistor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// One wire bus strong-pullup:&#xA;//&#xA;//    +------------+     +5v            +---------+     +---------+&#xA;//    |    MCU     |      |             | DS18b20 |     | DS18b20 |&#xA;//    |            |  R_pu = 4.7K       | g  d +5 |     | g  d +5 |&#xA;//    | Strong-    |      |             +-o--o--o-+     +-o--o--o-+&#xA;//    | Pullup   &amp;gt; o------o               |  |  |         |  |  |&#xA;//    |            |      |               +--|--+         +--|--+&#xA;//    |            |      |               |  |            |  |&#xA;//    |    Data &amp;lt;&amp;gt; o------o---------------|--o------------|--o------ - - -&#xA;//    |            |                      |               |&#xA;//    +------------+                      V               V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Initialize the strong-pullup port by setting the port as an output and HIGH, the disable and enable it by changing the port mode, not the output value. (Setting the port mode to input floats it, rather than grounding it as setting it LOW would do. This technique was suggested to me by Dave Tweed in Electrical Engineering Stack Exchange.)&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-18T22:52:43.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18825" PostTypeId="1" AcceptedAnswerId="18826" CreationDate="2015-12-18T22:54:46.193" Score="0" ViewCount="1843" Body="&lt;p&gt;I am trying to develop a NTP client library for ESP8266/Arduino to make adding NTP sync an easier task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I've thought about a constructor as &lt;strong&gt;&lt;code&gt;NTPClient(String host, int interval);&lt;/code&gt;&lt;/strong&gt; and a &lt;strong&gt;&lt;code&gt;NTPClient.begin()&lt;/code&gt;&lt;/strong&gt; function to register sync function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is with that registering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a public function: &lt;strong&gt;&lt;code&gt;time_t ntpClient::getNtpTime()&lt;/code&gt;&lt;/strong&gt; that connects to NTP server, decodes the response and returns a &lt;code&gt;time_t&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, inside &lt;strong&gt;&lt;code&gt;boolean ntpClient::begin()&lt;/code&gt;&lt;/strong&gt; function I try to run &lt;strong&gt;&lt;code&gt;setSyncProvider(ntpClient::getNtpTime)&lt;/code&gt;&lt;/strong&gt;. I've also tried to use &lt;strong&gt;&lt;code&gt;setSyncProvider(this-&amp;gt;getNtpTime)&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get a compile error here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ntpClient.cpp:In member function 'boolean ntpClient::begin()&#xA;ntpClient.cpp:79:39: error: cannot convert 'ntpClient::getNtpTime' from type 'time_t (ntpClient::)() {aka long int (ntpClient::)()}' to type 'getExternalTime {aka long int (*)()}&#xA;  setSyncProvider(ntpClient*:getNtpTime)&#xA;Error compiling project sources&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could I do to allow registering this function as sync provider to hide NTP internals to my sketches?&lt;/p&gt;&#xA;" OwnerUserId="15705" LastEditorUserId="6936" LastEditDate="2016-01-01T17:35:57.250" LastActivityDate="2016-01-01T17:35:57.250" Title="NTP Client Library. Set sync provider pointing to public class function. Possible?" Tags="|c++|arduino-ide|library|esp8266|time|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18826" PostTypeId="2" ParentId="18825" CreationDate="2015-12-18T23:16:55.150" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What could I do to allow registering this function as sync provider to hide NTP internals to my sketches?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The function should be a static member function. A &quot;normal&quot; member function does not have the right prototype as there is a hidden parameter (&quot;this&quot;). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static time_t getNtpTime();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To solve this you need a &lt;a href=&quot;https://sourcemaking.com/design_patterns/singleton&quot; rel=&quot;nofollow&quot;&gt;single-ton&lt;/a&gt; (an instance of the client class) that the static function can use. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class NTPClient {&#xA;public:&#xA;   NTPClient() ...&#xA;   {&#xA;     ...&#xA;     s_client = this;&#xA;   }&#xA;   time_t getNtpTime();&#xA;   ...&#xA;   static time_t getNtpTime() ( return (s_client-&amp;gt;getNtpTime()); }&#xA;   ...&#xA;protected:&#xA;   static NTPClient* s_client;&#xA;   ...&#xA;}; &#xA;...&#xA;NTPClient::s_client = NULL;&#xA;...&#xA;NTPClient ntpClient;&#xA;...&#xA;setSyncProvider(NTPClient::getNtpTime)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively a global function and a known instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class NTPClient { ... };&#xA;extern NTPClient ntpClient;&#xA;...&#xA;time_t getNtpTime() { return (ntpClient.getNtpTime()); } &#xA;...&#xA;setSyncProvider(getNtpTime) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-20T18:04:26.497" LastActivityDate="2015-12-20T18:04:26.497" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18827" PostTypeId="2" ParentId="10415" CreationDate="2015-12-18T23:57:47.520" Score="2" Body="&lt;p&gt;Yes, but you have to erase the flash (and reset the ATMEL SAM3X8E processor) manually before the programming. You can use the J16 and J22 jumpers to do this.&lt;/p&gt;&#xA;" OwnerUserId="15706" LastActivityDate="2015-12-18T23:57:47.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18829" PostTypeId="1" CreationDate="2015-12-19T01:27:24.140" Score="3" ViewCount="649" Body="&lt;p&gt;I am a bit of a novice with the Arduino, and have had to learn a lot for my High Altitude balloon launch. I am getting ready to launch this, but for some reason, my datalogger, printing to an SD card, will work in the setup function but not the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone could explain what is wrong with my code, and any improvements that could be made to it, it would be very helpful. I am using SPI, SD, I2C, Wire, Sparkfun BMP, and MPU6050 library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;SD.h&amp;gt;&#xA;    #include &amp;lt;math.h&amp;gt;&#xA;    #define thermoPin 0&#xA;&#xA;    #include &amp;lt;SFE_BMP180.h&amp;gt;&#xA;    SFE_BMP180 pressure;&#xA;&#xA;    #define ALTITUDE 87.8&#xA;    #include &quot;I2Cdev.h&quot;&#xA;&#xA;    #include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;    MPU6050 mpu;&#xA;    #define OUTPUT_READABLE_YAWPITCHROLL&#xA;&#xA;    #define OUTPUT_READABLE_REALACCEL&#xA;&#xA;    #define analogInPin 3  // Analog input pin that the potentiometer is attached to&#xA;&#xA;    int sensorValue = 0;        // value read from the sensor&#xA;&#xA;&#xA;&#xA;&#xA;    // MPU control/status vars&#xA;    bool dmpReady = false;  // set true if DMP init was successful&#xA;    uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU&#xA;    uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)&#xA;    uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)&#xA;    uint16_t fifoCount;     // count of all bytes currently in FIFO&#xA;    uint8_t fifoBuffer[64]; // FIFO storage buffer&#xA;&#xA;    // orientation/motion vars&#xA;    Quaternion q;           // [w, x, y, z]         quaternion container&#xA;    VectorInt16 aa;         // [x, y, z]            accel sensor measurements&#xA;    VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements&#xA;    VectorFloat gravity;    // [x, y, z]            gravity vector&#xA;    float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector&#xA;&#xA;    volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high&#xA;    void dmpDataReady() {&#xA;        mpuInterrupt = true;&#xA;    }&#xA;&#xA;&#xA;&#xA;    #define photocellPin 2&#xA;    // the cell and 10K pulldown are connected to a9&#xA;    int photocellReading;     // the analog reading from the analog resistor divider&#xA;&#xA;    #define chipSelect 4&#xA;&#xA;    void setup() {&#xA;      pinMode(A5, OUTPUT);&#xA;      pinMode(A4, OUTPUT);&#xA;      // Open dataFile communications and wait for port to open:&#xA;      if (!SD.begin(chipSelect)) {&#xA;        // don't do anything more:&#xA;        return;&#xA;      }&#xA;        File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;      if(dataFile) {&#xA;&#xA;      // Initialize the sensor (it is important to get calibration values stored on the device).&#xA;&#xA;      if (pressure.begin())&#xA;        dataFile.println(&quot;BMP180 init success&quot;);&#xA;      else&#xA;      {&#xA;        dataFile.println(&quot;BMP180 init fail\n\n&quot;);&#xA;        while(1); // Pause forever.&#xA;      } &#xA;      // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;        #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;            Wire.begin();&#xA;            TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)&#xA;        #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;            Fastwire::setup(400, true);&#xA;        #endif&#xA;        dataFile.println(F(&quot;Initializing I2C devices...&quot;));&#xA;        mpu.initialize();&#xA;&#xA;        dataFile.println(F(&quot;Testing device connections...&quot;));&#xA;        dataFile.println(mpu.testConnection() ? F(&quot;MPU6050 connection successful&quot;) : F(&quot;MPU6050 connection failed&quot;));&#xA;        // load and configure the DMP&#xA;        dataFile.println(F(&quot;Initializing DMP...&quot;));&#xA;        devStatus = mpu.dmpInitialize();&#xA;&#xA;        mpu.setXGyroOffset(220);&#xA;        mpu.setYGyroOffset(76);&#xA;        mpu.setZGyroOffset(-85);&#xA;        mpu.setZAccelOffset(1788); // 1688 factory default for my test chip&#xA;    mpu.setDMPEnabled(true);&#xA;    mpuIntStatus = mpu.getIntStatus(); &#xA;    dmpReady = true;&#xA;    packetSize = mpu.dmpGetFIFOPacketSize();&#xA;    dataFile.close();&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // make a string for assembling the data to log:&#xA;      int valF, valC;&#xA;      valF = analogRead(thermoPin);&#xA;      valC = analogRead(thermoPin);&#xA;      File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;&#xA;      // if the file is available, write to it:&#xA;      if (dataFile) {&#xA;&#xA;        dataFile.print(F(&quot;Millis since Launch&quot;));&#xA;        dataFile.println(millis());&#xA;        dataFile.print(F(&quot;, Analog Val.&quot;));&#xA;        dataFile.print(valF);&#xA;&#xA;        photocellReading = analogRead(photocellPin);&#xA;&#xA;        dataFile.print(F(&quot;  Analog reading = &quot;));&#xA;        dataFile.println(photocellReading);     // the raw analog reading&#xA;                                          // We'll have a few threshholds, qualitatively determined&#xA;      dataFile.println();&#xA;      char status;&#xA;      double T,P,p0,a;&#xA;&#xA;        dataFile.print(F(&quot;provided altitude: &quot;));&#xA;      dataFile.print(ALTITUDE,0);&#xA;      dataFile.println(F(&quot; meters, &quot;));&#xA;&#xA;&#xA;      status = pressure.startTemperature();&#xA;      if (status != 0)&#xA;      {&#xA;        // Wait for the measurement to complete:&#xA;        delay(status);&#xA;&#xA;&#xA;        status = pressure.getTemperature(T);&#xA;        if (status != 0)&#xA;        {&#xA;          // Print out the measurement:&#xA;          dataFile.print(F(&quot;temperature: &quot;));&#xA;          dataFile.print(T,2);&#xA;          dataFile.println(&quot; deg F&quot;);&#xA;&#xA;&#xA;          status = pressure.startPressure(3);&#xA;          if (status != 0)&#xA;          {&#xA;            // Wait for the measurement to complete:&#xA;            delay(status);&#xA;&#xA;&#xA;            status = pressure.getPressure(P,T);&#xA;            if (status != 0)&#xA;            {&#xA;              // Print out the measurement:&#xA;              dataFile.print(F(&quot;absolute pressure: &quot;));&#xA;              dataFile.print(P,2);&#xA;              dataFile.print(F(&quot; mb, &quot;));&#xA;&#xA;&#xA;              p0 = pressure.sealevel(P,ALTITUDE); // we're at 87.08 meters (Home)&#xA;              dataFile.print(F(&quot;relative (sea-level) pressure: &quot;));&#xA;              dataFile.print(p0,2);&#xA;              dataFile.print(F(&quot; mb, &quot;));&#xA;              dataFile.print(p0*0.0295333727,2);&#xA;              dataFile.println(&quot; inHg&quot;);&#xA;&#xA;&#xA;              a = pressure.altitude(P,p0);&#xA;              dataFile.print(F(&quot;computed altitude: &quot;));&#xA;              dataFile.print(a,0);&#xA;              dataFile.print(F(&quot; meters, &quot;));&#xA;            }&#xA;            else dataFile.println(&quot;error retrieving pressure measurement\n&quot;);&#xA;          }&#xA;          else dataFile.println(&quot;error starting pressure measurement\n&quot;);&#xA;        }&#xA;        else dataFile.println(&quot;error retrieving temperature measurement\n&quot;);&#xA;      }&#xA;      else dataFile.println(&quot;error starting temperature measurement\n&quot;);&#xA;      // if programming failed, don't try to do anything&#xA;        if (!dmpReady) return;&#xA;&#xA;        // wait for MPU interrupt or extra packet(s) available&#xA;        while (!mpuInterrupt &amp;amp;&amp;amp; fifoCount &amp;lt; packetSize) {&#xA;        }&#xA;&#xA;        // reset interrupt flag and get INT_STATUS byte&#xA;        mpuInterrupt = false;&#xA;        mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;        // get current FIFO count&#xA;        fifoCount = mpu.getFIFOCount();&#xA;&#xA;        // check for overflow (this should never happen unless our code is too inefficient)&#xA;        if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;            // reset so we can continue cleanly&#xA;            mpu.resetFIFO();&#xA;            dataFile.println(F(&quot;FIFO overflow!&quot;));&#xA;&#xA;        // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;        } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;            // wait for correct available data length, should be a VERY short wait&#xA;            while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;&#xA;            // read a packet from FIFO&#xA;            mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;&#xA;            // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;            // (this lets us immediately read more without waiting for an interrupt)&#xA;            fifoCount -= packetSize;&#xA;&#xA;            #ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;                // display Euler angles in degrees&#xA;                mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;                mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;                mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;                dataFile.print(F(&quot;ypr\t&quot;));&#xA;                dataFile.print(ypr[0] * 180/M_PI);&#xA;                dataFile.print(F(&quot;\t&quot;));&#xA;                dataFile.print(ypr[1] * 180/M_PI);&#xA;                dataFile.print(F(&quot;\t&quot;));&#xA;                dataFile.println(ypr[2] * 180/M_PI);&#xA;            #endif&#xA;&#xA;            #ifdef OUTPUT_READABLE_REALACCEL&#xA;                // display real acceleration, adjusted to remove gravity&#xA;                mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;                mpu.dmpGetAccel(&amp;amp;aa, fifoBuffer);&#xA;                mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;                mpu.dmpGetLinearAccel(&amp;amp;aaReal, &amp;amp;aa, &amp;amp;gravity);&#xA;                dataFile.print(F(&quot;areal\t&quot;));&#xA;                dataFile.print(aaReal.x);&#xA;                dataFile.print(F(&quot;\t&quot;));&#xA;                dataFile.print(aaReal.y);&#xA;                dataFile.print(F(&quot;\t&quot;));&#xA;                dataFile.println(aaReal.z);&#xA;            #endif&#xA;        }&#xA;        // read the analog in value:&#xA;      sensorValue = analogRead(analogInPin);            &#xA;      // print the results to the dataFile monitor:&#xA;      dataFile.print(F(&quot;  analog Val of OZONE= &quot; ));                       &#xA;      dataFile.println(sensorValue);                     &#xA;      dataFile.close();&#xA;      }&#xA;      analogWrite(A4, 168);&#xA;      delay(3000);&#xA;      analogWrite(A4, 0);&#xA;      delay(750);&#xA;      analogWrite(A5, 0);&#xA;      delay(250);&#xA;      analogWrite(A5, 168);&#xA;      delay(3000);&#xA;        analogWrite(A4, 168);&#xA;      delay(2000);&#xA;      analogWrite(A4, 0);&#xA;      delay(1000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Possible problems (correct me if I'm wrong):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I noticed that the MPU6050 stops transmitting if delays are put into it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;EDIT: &#xA;I have now tried the script but commented out the accelerometer (MPU6050) portion,  and it successfully writes to the SD card. could someone explain why the accelerometer portion messes up the rest of the code?&lt;/p&gt;&#xA;" OwnerUserId="15707" LastEditorUserId="6936" LastEditDate="2015-12-29T20:17:03.923" LastActivityDate="2015-12-29T20:17:03.923" Title="SD print in script works in setup but not loop" Tags="|programming|arduino-mega|sd-card|mpu6050|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18830" PostTypeId="2" ParentId="18829" CreationDate="2015-12-19T05:57:29.847" Score="1" Body="&lt;p&gt;I haven't followed all the details of your code, nor looked into all of the libraries being used, so you may need to ignore some of the following comments.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You write “my datalogger, printing to an sd card, will work in the setup function but not the loop”.  However, you don't say what you mean by “work”, nor how you tell if it works.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;It looks like your code in &lt;code&gt;loop()&lt;/code&gt; uses the same filename as in &lt;code&gt;setup()&lt;/code&gt;.  If so, there's no reason to write a file in&lt;code&gt;setup()&lt;/code&gt; because it will just be overwritten later.  (If you have a reason, use a different file name.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Sequences like &lt;code&gt;status = pressure.startTemperature(); if (status != 0) {... delay(status); ... }&lt;/code&gt; look suspect.  The parameter to &lt;a href=&quot;https://www.arduino.cc/en/Reference/Delay&quot; rel=&quot;nofollow&quot;&gt;Arduino's &lt;code&gt;delay()&lt;/code&gt; function&lt;/a&gt; is a number of milliseconds, in an &lt;code&gt;unsigned long&lt;/code&gt;; is your &lt;code&gt;startTemperature()&lt;/code&gt; supposed to return a status that's usable as the number of milliseconds to delay?  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Your &lt;code&gt;status&lt;/code&gt; is declared via &lt;code&gt;char status;&lt;/code&gt; and  &lt;code&gt;char&lt;/code&gt; is a signed type.  If &lt;code&gt;status&lt;/code&gt; is negative, the call &lt;code&gt;delay(status);&lt;/code&gt; will first convert &lt;code&gt;status&lt;/code&gt; to a signed &lt;code&gt;long&lt;/code&gt; by sign-extension.  Then it will convert the signed &lt;code&gt;long&lt;/code&gt; to an &lt;code&gt;unsigned long&lt;/code&gt; with the same bit pattern.  This will ensure a delay of at least 7 weeks, which presumably is longer than you mean to wait.&#xA;[Ref: See the “Conversions from Signed Integral Types” table in microsoft.com/en-us/library's &lt;em&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/xbfs6fd4.aspx&quot; rel=&quot;nofollow&quot;&gt;Conversions from Signed Integral Types&lt;/a&gt;&lt;/em&gt; webpage.]&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To avoid those long and tedious sequences of &lt;code&gt;dataFile.print(...);&lt;/code&gt; statements, you can &lt;code&gt;#include Streaming.h&lt;/code&gt;, which is a &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;contributed library&lt;/a&gt; that adds some “syntactic sugar” to Arduino C.  At compile time it converts C++-like &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; stream operators to &lt;code&gt;.print()&lt;/code&gt; calls, without increasing code size.  If you don't have &lt;code&gt;Streaming.h&lt;/code&gt; installed, install it via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow&quot;&gt;arduiniana.org&lt;/a&gt;.  Then, for example, in place of &lt;/p&gt;&#xA;&#xA;&lt;p&gt;dataFile.print(F(&quot;areal\t&quot;));&#xA;  dataFile.print(aaReal.x);&#xA;  dataFile.print(F(&quot;\t&quot;));&#xA;  dataFile.print(aaReal.y);&#xA;  dataFile.print(F(&quot;\t&quot;));&#xA;  dataFile.println(aaReal.z);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  dataFile &amp;lt;&amp;lt; F(&quot;areal\t&quot;) &amp;lt;&amp;lt; aaReal.x &amp;lt;&amp;lt; '\t' &amp;lt;&amp;lt; aaReal.y &amp;lt;&amp;lt; '\t' &amp;lt;&amp;lt; aaReal.z &amp;lt;&amp;lt; endl;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;6&quot;&gt;&#xA;&lt;li&gt;Whether using &lt;code&gt;Streaming.h&lt;/code&gt; or not, writing &lt;code&gt;F(&quot;\t&quot;)&lt;/code&gt; instead of &lt;code&gt;'\t'&lt;/code&gt; uses half a dozen bytes of program memory where one will do, and uses the same amount or more of RAM.  That is, while F() saves on RAM usage for long strings, it's of negative value for single characters and short strings.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-19T05:57:29.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18831" PostTypeId="2" ParentId="12814" CreationDate="2015-12-19T07:42:57.673" Score="2" Body="&lt;p&gt;I use more or less the same code to do my networked widgets and it has been quite reliable in my experience. Do you know if you have a DHCP server on the network segment that the Arduino is on? The absence of a server or a configuration that won't respond to the Arduino seem like the most likely explanation for the problem you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to troubleshoot this would be to get another machine on the same network segment and watch the traffic with &lt;code&gt;tcpdump&lt;/code&gt; or Wireshark or a similar tool. If you're running on a &quot;third party&quot; machine (e.g. not the DHCP server) then you'll be able to see the Arduino's side of the DHCP exchange, but I'm not sure if you'll be able to see the server (the Arduino will be broadcasting since it can't know the address of the DHCP server, but I think the server's response is unicast). If you've got a Linux box or some other machine that you can log into where you could run the DHCP server you can watch both sides of the negotiation. But even if you can't get to the server it will help to see if the Arduino is starting the DHCP negotiation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need a fixed IP address on the Arduino, the way to do it is to configure the DHCP server to reserve an address for the Arduino. That way you can have a known address on the Arduino without having to hard code an IP address (which will eventually bite you).&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-19T07:42:57.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18832" PostTypeId="1" CreationDate="2015-12-19T09:10:31.430" Score="0" ViewCount="2845" Body="&lt;p&gt;I am IR library from Ken Shirrif at &lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote/releases/download/MAJOR/IRremote.zip&quot; rel=&quot;nofollow&quot;&gt;https://github.com/z3t0/Arduino-IRremote/releases/download/MAJOR/IRremote.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is good and I have used the examples to receive and send and to playback IR signals from the library. And they are working good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To send Unknown signals we should use sendRaw() method with a list of integers got from the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is when I use the receive program, I get the decoded hexadecimal value for even the Unknown signals. And can I use this small decoded signal to send signals apart from the long list of integers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to send these codes from android. It would be quite easy to send and store the small hexadecimal decoded value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to use the decoded value to send for raw signals with some encodings at arduino?&lt;/p&gt;&#xA;" OwnerUserId="15105" LastActivityDate="2015-12-19T18:37:28.793" Title="how to use the decoded raw value to send IR signal in arduino" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18833" PostTypeId="2" ParentId="18757" CreationDate="2015-12-19T10:02:41.543" Score="1" Body="&lt;p&gt;A problem with what you are doing on the breadboard is that you show no bypass capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What makes the pull up &quot;strong&quot; is the ability to provide current to move the data line from zero back to one.  The load on the data line is its capacitance.  To move the data line from 0 to 1, you have to charge that capacitor.  Working on a bread board, you are correct that you have a larger capacitive load.  So you require more current to move the data line from zero to one quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are correct that the lower 620 ohm resistor will provide more current.  The large current will move the capacitance load of the data line more quickly.  But you are not paying attention to the other side of the resistor, the 5V rail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The layout you have has inductance in the wires from the Arduino power supply out to the bread board.  An inductor has a voltage drop across it proportional to the rate of change of the current through it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V = L  di/dt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The analogy is that inductance is a flywheel: if it is not spinning, it will take force to get is moving.  Similar, once it is spinning, it will take force to stop it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when the resistor starts conducting to pull up the data line, the inductance in the wires and breadboard cause a voltage drop.  The +5 side of the resistor voltage drops.  This inductance in the wires leading to the resistor prevents it from rapidly charging the data line back to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is the role of &lt;em&gt;bypass&lt;/em&gt; capacitors.  You place 1 or 2 right at the resistor between the +5 and GND strips on the bread board.  Now when the resistor draws current, it initially pulls from the energy stored in the capacitors.  After a short time, the current will start pulling from the +5 wire.  Thereby, you have &lt;strong&gt;bypassed&lt;/strong&gt; the inductance of the +5 supply, hence the name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add a 0.1 microFarad ceramic capacitor on your breadboard where the wires connect to the contact strips.  You will see this on schematics for anything that has a DC supply off board.  Right next to the power connector will be 2 or 3 capacitors, usually one big 2-10 uF tantalum and one smaller 0.1 uF or so.  Similar across circuit boards you see bypass caps placed at the supply voltage pin of every chip, commonly two: a 0.1 uF and a smaller 10 nF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might seem pointless to place a small capacitor in parallel with a larger capacitor.  The values just add, yes?  But again, the time response is different.  Capacitors are not perfect and have internal series resistance.  A big 10 uF electrolytic capacitor may store a lot of energy, but it is not fast in terms of how quickly it can start providing current.  A little 100 nF ceramic monolithic capacitor is very fast, but doesn't have much energy.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So with two bypass caps in parallel, you have the small one for the initial burst of current, the larger cap for the heavy lifting, and last and slowest the 5V wires and traces to supply to steady current.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastEditorUserId="3742" LastEditDate="2015-12-20T03:05:48.360" LastActivityDate="2015-12-20T03:05:48.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18835" PostTypeId="2" ParentId="9115" CreationDate="2015-12-19T11:04:47.720" Score="2" Body="&lt;p&gt;The state machine is a solid approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this simple case, you can also solve this by implementing small dead bands around the change levels.  When the value is in a range near the transition threshold, do nothing.  Only when the value is certainly above or below the transition, make the change.  Your code would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Variables will change:&#xA;int currentVoltage = 0;         // current voltage value&#xA;int previousVoltage = 0;     // previous voltage value    &#xA;&#xA;void loop() {&#xA;  int deadband = 5;&#xA;  // on very first loop, start with no dead band&#xA;  // this is necessary in case starting voltage is in &#xA;  // middle of a transition range&#xA;  if (0 == previousVoltage) {&#xA;    deadband = 0;&#xA;  }&#xA;&#xA;  // read the voltage across the battery voltage pin:&#xA;  currentVoltage = analogRead(BatteryVoltagePin);&#xA;&#xA;  // test the voltage against the three ranges&#xA;  // value above maximum threshold&#xA;  if ((699+deadband) &amp;lt; currentVoltage) {   &#xA;    digitalWrite(GreenLedPin, HIGH);&#xA;    digitalWrite(OrangeLedPin, LOW );&#xA;    digitalWrite(RedLedPin, LOW );&#xA;  }&#xA;&#xA;  //value between two thresholds (middle region)&#xA;  if (((628+deadband) &amp;lt; currentVoltage) &amp;amp;&amp;amp; (currentVoltage &amp;lt;= (699-deadband))) {          &#xA;    digitalWrite(GreenLedPin, LOW);&#xA;    digitalWrite(OrangeLedPin, HIGH);&#xA;    digitalWrite(RedLedPin, LOW);&#xA;  }&#xA;&#xA;  // value below minimum threshold&#xA;  if (currentVoltage &amp;lt; (628-deadband)) {&#xA;    digitalWrite(GreenLedPin, LOW);&#xA;    digitalWrite(OrangeLedPin, LOW );&#xA;    digitalWrite(RedLedPin, HIGH);&#xA;  }&#xA;&#xA;  // Note that at this point, none of the if cases above&#xA;  // might have been true.  When the voltage is right near the&#xA;  // thresholds, do nothing.  Only when the voltage is definitively&#xA;  // in the range does the LED state change.&#xA;&#xA;  // save the current state as the last state, &#xA;  //for next time through the loop&#xA;  previousVoltage = currentVoltage;&#xA;  delay(10);&#xA;&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In function, this will achieve the same result as hysteresis.&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-12-19T11:04:47.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18836" PostTypeId="1" CreationDate="2015-12-19T12:14:31.567" Score="0" ViewCount="664" Body="&lt;p&gt;I used an Arduino Uno on my project to produce a frequency greater than 35000Hz and the output of digital pin was connected to the ultrasonic transmitter circuitry:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/emtuj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/emtuj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it's not working on the transmitting side. Here's the Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    pinMode(13,OUTPUT);&#xA;    pinMode(12,OUTPUT);&#xA;    int pirSenses = analogRead(A1);&#xA;    int pirOuts=11;&#xA;    pinMode(pirOuts,INPUT); /*PIR sensor 1*/&#xA;    int pirSense = analogRead(A0);&#xA;    int pirOut = 10;&#xA;    pinMode(pirOut,INPUT); /*PIR sensor 2*/&#xA;    Serial.println(pirSense);Serial.println(pirSenses);&#xA;&#xA;    if (pirOut || pirOuts == HIGH)&#xA;    { /*tone produces ultrasonic frequency*/&#xA;        delay(8000);&#xA;        tone(13, 50132); delay(100); noTone(13); delay(10);&#xA;        tone(13,54621);  delay(50);  noTone(13); delay(50);&#xA;        tone(13,35689);  delay(60);  noTone(13);&#xA;    } &#xA;    else if (pirOut||pirOuts==LOW)&#xA;    {&#xA;        tone(13, 50132); delay(100); noTone(13); delay(10);&#xA;        tone(13,54621);  delay(50);  noTone(13); delay(50);&#xA;        tone(13,35689);  delay(60);  noTone(13);&#xA;    } &#xA;    else&#xA;    {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the transmitter (model &quot;MCPCT-G5100-4139&quot;) specification:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SavQ6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SavQ6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me with this problem. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13535" LastEditorUserId="46" LastEditDate="2015-12-22T11:00:54.263" LastActivityDate="2021-06-28T23:08:05.753" Title="problem on implementation of the ultrasonic circuitry" Tags="|arduino-uno|frequency|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18837" PostTypeId="2" ParentId="18832" CreationDate="2015-12-19T13:27:47.783" Score="2" Body="&lt;p&gt;If the signal is reported as &quot;unknown&quot; the library couldn't identify the protocol (RC5, RC6, NEC, SONY, etc).  If the library doesn't know the protocol,  the decoded number is meaningless. Simply put, an IR remote transmission has a frequency; a header; some data (the actual remote command); and a footer.  Without knowing the protocol the library doesn't know the length and shape of each section, so the purpose of the decoded number is only to show quickly if the decoding is receiving the same code at each keypress. You can verify this yourself.  Every time something makes an already known remote code be reported as &quot;unknown&quot;, the code received is different from a real code, so simply guessing (or knowing beforehand) the protocol is not going to help anyway. &lt;/p&gt;&#xA;" OwnerUserId="15714" LastEditorUserId="3917" LastEditDate="2015-12-19T18:37:28.793" LastActivityDate="2015-12-19T18:37:28.793" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="18838" PostTypeId="1" AcceptedAnswerId="18844" CreationDate="2015-12-19T13:35:17.033" Score="4" ViewCount="721" Body="&lt;p&gt;I have an existing project using an Arduino Yun that controls Christmas lights with relays to turn them on/off. There are currently 13 separate rows of lights on the (60 foot) tree, each plugged into a wall wart that's controlled by its own relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm considering adding the ability to dim the lights, so I wanted to figure out the best way to do it. The lights can all be dimmed &quot;in unison&quot; - there's no need for 13 seperately controlled dimmers. But I have to be mindful not to cause any &quot;buzzing&quot; in the audio equipment on stage where the tree is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read about PWN, zero cross, and other terms and saw the zero cross tail from &lt;a href=&quot;http://powerswitchtail.com&quot; rel=&quot;nofollow&quot;&gt;powerswitchtail.com&lt;/a&gt; that seem useful in the typical project. I'd like to be able to pull this off with no more than 2 &quot;dimmers&quot; for the whole project, if possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where do I start, and how do I do it?&lt;/p&gt;&#xA;" OwnerUserId="3911" LastEditorUserId="10907" LastEditDate="2015-12-21T11:34:22.227" LastActivityDate="2015-12-21T11:34:22.227" Title="Arduino Christmas light project with dimmer" Tags="|arduino-yun|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="18839" PostTypeId="1" CreationDate="2015-12-19T15:05:38.597" Score="-1" ViewCount="400" Body="&lt;p&gt;I'm working on a project and it can send to one receiver only. What I need is to send a message to multiple receivers. I need a code sample that would satisfy my needs. Please help! I need to finish this ASAP.&lt;/p&gt;&#xA;" OwnerUserId="15715" LastEditorUserId="4628" LastEditDate="2015-12-21T11:33:21.727" LastActivityDate="2022-11-30T19:08:46.107" Title="How to send a group message to multiple receivers using GSM900 and Arduino Mega2560?" Tags="|programming|arduino-mega|gsm|coding-standards|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18840" PostTypeId="2" ParentId="18836" CreationDate="2015-12-19T15:44:42.503" Score="1" Body="&lt;p&gt;Your ultrasonic Transducer driver circuit isn't doing a very good job. At most you are getting only a few milliwatts output to the transducer. Your circuit is applying 12 volts through a 2.2K resistor to the transducer, and your Q1 transistor is merely shorting out the Transducer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From viewing the data sheet on your transducer, it looks like a tiny loud speaker and not a Piezo device. But that is OK.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the following push pull driver circuit.  I have tried to keep it simple, but you would need to come up with a PNP transistor (in addition to your existing NPN transistor).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The V2 square wave is your 5 volt output from Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, notice that I have shown the driver circuit using 5 volts, not 12 volts. Using this circuit, if you use 12 volts supply, the output doesn't get any more powerful, and just causes more heating in the transistors.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1  :  IMPORTANT :  Don't leave your output pin in the HIGH state.  This turns on transistor Q1 and causes sustained current in the Transducer.  To alleviate this, insert a 47uf capacitor in series with the transducer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2 :  Changed schematic to include output capacitor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EoRJ6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EoRJ6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2015-12-22T02:55:53.270" LastActivityDate="2015-12-22T02:55:53.270" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18842" PostTypeId="1" AcceptedAnswerId="19486" CreationDate="2015-12-19T19:38:47.167" Score="1" ViewCount="3737" Body="&lt;p&gt;I'm wondering how to connect the L293D (H-bridge) and an MPU 6050.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using 1 Arduino Uno, 2 DC motors, 1 MPU6050 and an L293D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried this, I got some sparks/smoke from the breadboard and none of the motors where running. I only used a 9v battery, not 12v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/uGD8u.png&quot; alt=&quot;mpu 6050 and l293d&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the L293D: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rl1MH.jpg&quot; alt=&quot;l293d&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MPU 6050 wiring: int-digital 2, SDA-A4, SCL-A5, GND-GND, VDD-Vss&lt;/p&gt;&#xA;&#xA;&lt;p&gt;L293D wiring: Vss-VDD, Input4-Digital 5, Output4-Motor, Output3-Motor, Input3-Digital 6, Enable2-5V, Enable1-5V, Input1-Digital 9, Output1-motor, Output2-motor, Input2-Digital 10, Vs-12V battery.&lt;/p&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="27346" LastEditDate="2019-01-04T08:43:17.727" LastActivityDate="2019-01-04T08:43:17.727" Title="How to connect an L293D and an MPU6050 to run together?" Tags="|arduino-uno|sensors|motor|mpu6050|h-bridge|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="18844" PostTypeId="2" ParentId="18838" CreationDate="2015-12-19T20:19:56.923" Score="0" Body="&lt;p&gt;I can think of a couple of ways to approach this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a DMX dimmer, something like &lt;a href=&quot;http://smile.amazon.com/American-Dp-415-Channel-Dimmer-Pack/dp/B000FVZUMM&quot; rel=&quot;nofollow&quot;&gt;this 4-channel dimmer&lt;/a&gt;, or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use an household &lt;a href=&quot;http://smile.amazon.com/X10-RWS17-WS12A-Decorator-Dimmer/dp/B00022OCE6&quot; rel=&quot;nofollow&quot;&gt;X10 dimmer&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;DMX is used for stage lighting and there is some information on &lt;a href=&quot;http://playground.arduino.cc/Learning/DMX&quot; rel=&quot;nofollow&quot;&gt;controlling DMX devices with an Arduino in the Playground&lt;/a&gt; where there is also some &lt;a href=&quot;http://playground.arduino.cc/DMX/DMXShield&quot; rel=&quot;nofollow&quot;&gt;information on the hardware interface and shields&lt;/a&gt;, it looks pretty simple. DMX is a differential RS485 interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;X10 is used for home automation, the signaling is done over the AC line. There is some information on &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/X10&quot; rel=&quot;nofollow&quot;&gt;using X10 and an Arduino library&lt;/a&gt; in the Tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both seem like viable approaches, if you're working in a theater it is likely that they might already have DMX equipment and it would be as simple as hooking up to the gear in the house. Then you'd only need to add a shield or build the interface hardware.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-19T20:19:56.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18846" PostTypeId="1" CreationDate="2015-12-19T22:17:31.540" Score="2" ViewCount="103" Body="&lt;p&gt;I'm developing a little project with Arduino, using a small web page to show data. Well, I have been develop the web page and the small code to communicate with Arduino board in my local computer and all work fine.&#xA;But, after, I uploaded the code to a Raspberry Pi and then the problems appear.&#xA;This is very strange, because when I execute the code inside a WSGI like  django (in my case is other, webapp2) the code works well. I call a specific URL and this WSGI call a method inside a class that communicated with the Arduino board through serial port, so far, so good. &#xA;The problem appears when I decided build a method to execute the lines that do the communication, in this moment Arduino does not response and only lights the led number 13 and the 'L' led twice (the led inside the board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand why this happens. The code is exactly the same. Any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the other hand, because I don't have GUI in the raspberry I don't can view the serial port communication easy. &#xA;Do you  know any way to view or debug the serial communications between a pc and Arduino without GUI, over the command line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;# -*- coding: utf-8 -*-&#xA;import serial&#xA;import time&#xA;&#xA;arduino=serial.Serial('/dev/ttyACM0', baudrate=9600, timeout=3.0)&#xA;arduino.close()&#xA;arduino.open()&#xA;&#xA;sensorTemp=''&#xA;arduino.write('a')&#xA;while arduino.inWaiting() &amp;gt; 0:&#xA;        sensorTemp+=arduino.read(1)&#xA;print sensorTemp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks you so much. Any idea is welcome.&lt;/p&gt;&#xA;" OwnerUserId="15655" LastEditorUserId="37523" LastEditDate="2019-07-24T09:08:16.690" LastActivityDate="2019-07-24T09:08:16.690" Title="Strange problem with serial communication" Tags="|serial|debugging|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18847" PostTypeId="2" ParentId="18839" CreationDate="2015-12-19T22:58:31.957" Score="0" Body="&lt;p&gt;Simply change the number in the AT command and send the message again. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-19T22:58:31.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18848" PostTypeId="2" ParentId="13626" CreationDate="2015-12-19T23:26:38.233" Score="1" Body="&lt;p&gt;There are a few files in the Arduino Due core that you should have a look at. They give great insight into the SAM register set up; &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/variants/arduino_due_x/variant.h&quot; rel=&quot;nofollow&quot;&gt;variant.h&lt;/a&gt;, &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/variants/arduino_due_x/variant.cpp&quot; rel=&quot;nofollow&quot;&gt;variant.cpp&lt;/a&gt; and &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/system/libsam/chip.h&quot; rel=&quot;nofollow&quot;&gt;chip.h&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you can dive into the &lt;a href=&quot;https://github.com/arduino/Arduino/tree/master/hardware/arduino/sam/system/libsam&quot; rel=&quot;nofollow&quot;&gt;libsam&lt;/a&gt; and the many components (include/source). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SAM code has a very different structure and style compared to AVR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-19T23:26:38.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18849" PostTypeId="1" CreationDate="2015-12-19T23:35:30.280" Score="-2" ViewCount="69" Body="&lt;p&gt;I have hacked this kettle so that I can turn it on and off remotely via wifi and that is working perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/F8mzH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/F8mzHm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added this to get a better signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eS1Dh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eS1Dhm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my micro controlling the 5v buttons on the kettle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o56Nw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o56Nwm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I keep running into a wall when it comes to reading the temperature of the water. The kettle does this automatically, but I want to transfer this information to my micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I hook my multimeter to the ground and and yellow wire that connects to the lower voltage board (5v) that had the buttons and display I can use the voltage reading to predict the temp. The reading ranges from 0-5v, but my micro is a 3.3v micro so a direct connection isn't a great idea. I've tried using breakout boards designed to read voltage, but if I connect anything it throws the reading off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The multi-meter is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get my micro to read the voltage as if it were a multi-meter? I even tried one of those little seven segment voltmeters but that threw off the reading just like the optocoupler and leds and other methods that I tried. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I have it set up:&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="37" LastEditDate="2015-12-21T16:10:19.947" LastActivityDate="2015-12-21T16:10:19.947" Title="Reading temp data" Tags="|voltage-level|" AnswerCount="1" CommentCount="4" ClosedDate="2016-01-11T21:08:31.247" ContentLicense="CC BY-SA 3.0" />
  <row Id="18850" PostTypeId="2" ParentId="17861" CreationDate="2015-12-19T23:51:08.510" Score="1" Body="&lt;pre&gt;&lt;code&gt;int firstcomma = inputString.indexOf(',');&#xA;int secondcomma = inputString.indexOf(',',firstcomma+1);&#xA;String r = inputString.substring(0,firstcomma);&#xA;String g = inputString.substring(firstcomma+1,secondcomma);&#xA;String b =  inputString.substring(secondcomma+1);&#xA;red = r.toInt();&#xA;green = g.toInt();&#xA;blue = b.toInt();&#xA;Serial.print(&quot;R&quot;);&#xA;Serial.print(red);&#xA;Serial.print(&quot;G&quot;);&#xA;Serial.print(green);&#xA;Serial.print(&quot;B&quot;);&#xA;Serial.println(blue);   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solved my problems.&lt;/p&gt;&#xA;" OwnerUserId="14904" LastActivityDate="2015-12-19T23:51:08.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18851" PostTypeId="1" CreationDate="2015-12-19T23:51:56.853" Score="2" ViewCount="158" Body="&lt;p&gt;Atmel studio 7 with Arduino Uno: &#xA;Just upgraded to Atmel studio 7 and my target platform is the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't get past the start procedure: Firstly on starting up I get &lt;em&gt;Sequence contains no elements&lt;/em&gt; (first image below). Then after pressing enter and entering the the &lt;em&gt;Sketch File&lt;/em&gt; and &lt;em&gt;Arduino IDE Path&lt;/em&gt; fields, the &lt;em&gt;Board&lt;/em&gt; and &lt;em&gt;Device&lt;/em&gt; fields remain empty (second image below). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm unable to select or update any of these two fields (&lt;em&gt;Board&lt;/em&gt; and &lt;em&gt;Device&lt;/em&gt;) - any assistance is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OjUIB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OjUIB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mpMXN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mpMXN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15724" LastActivityDate="2015-12-19T23:51:56.853" Title="Atmel studio 7 with Arduino Uno: Just upgraded to Atmel studio 7 and my target platform is the Arduino Uno" Tags="|keyboard|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18852" PostTypeId="2" ParentId="18849" CreationDate="2015-12-20T03:25:41.927" Score="0" Body="&lt;h2&gt;Voltage divider&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can possibly use a simple voltage divider. Try connecting two 100K ohm resistors in series between the voltage you want to measure and ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yellow-&gt;100K ohm resistor-&gt;100K ohm resistor-&gt;ground&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now connect your multi-meter to the middle connection between the two resistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the circuit that happens to be driving the yellow wire, you should hopefully see a voltage that varies between ~ 0-2.5 volts. If so, you can connect this voltage to your 3.3v micro analog input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the value of the resistors is not critical - you just want them to be about the same and pretty large. &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Op Amp&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If the yellow wire output is so weak that even a voltage divider with very large resistors is pulling the voltage down significantly, then you can use a high impedance op-amp with 1x gain to buffer the signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you'd connect the yellow wire to the &lt;code&gt;+&lt;/code&gt; input of the op amp, and connect ground to the &lt;code&gt;-&lt;/code&gt; input of the op amp. The output voltage of the op amp would not track the input voltage (the yellow wire) and you can use a voltage divider on the output as above.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use digital temp sensor&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This option does not directly answer you question, but might be the best solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get something like a &lt;a href=&quot;http://amzn.to/1Jmmwrd&quot; rel=&quot;nofollow&quot;&gt;DS18B20&lt;/a&gt; digital temperature sensor for a buck or two and connect it digitally to your MCU and avoid the problem altogether. This chip is happy at 3.3 volts, so you'd just need to put it physically someplace where it is sensing the same temperature as the yellow wire.  This will likely be more accurate too!&lt;/p&gt;&#xA;" OwnerUserId="7859" LastEditorUserId="7859" LastEditDate="2015-12-20T20:26:58.433" LastActivityDate="2015-12-20T20:26:58.433" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18854" PostTypeId="1" AcceptedAnswerId="18866" CreationDate="2015-12-20T07:50:54.377" Score="3" ViewCount="2561" Body="&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;hello&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello&#xA;hello&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why does &lt;code&gt;hello&lt;/code&gt; print twice?&lt;/p&gt;&#xA;" OwnerUserId="15730" LastActivityDate="2015-12-20T18:08:19.297" Title="Why is setup() executed twice at runtime?" Tags="|serial|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="18855" PostTypeId="1" CreationDate="2015-12-20T08:03:38.767" Score="1" ViewCount="166" Body="&lt;p&gt;I had an idea to hack a wireless doorbell so it could send notifications to my phone when someone rings the doorbell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pulled out the PCB from the doorbell and powered it using the +5v from the Arduino - so far so good&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the (once was a wire to the speaker) as an analog input&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I have is that the voltage for the chime continues for a long time. eg its at 0 before push then it fluctuates for a second, then returns to 519 for a while, before eventually returning to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a smarter way to do this - I have included my code below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  //detect a changing voltage&#xA;  val = analogRead(sensorPin); //pin A0&#xA;  delay(500);&#xA;  oldVal = analogRead(sensorPin);//pin A0&#xA;&#xA;//if the voltage changed then +1 to the ring counter&#xA;  if (val != oldVal) {&#xA;      ringCounter = ringCounter+1;&#xA;  }&#xA;&#xA;  if (ringCounter &amp;gt; 3 &amp;amp;&amp;amp; pinDevid1State == false) // someone pressed the doorbell&#xA;  {&#xA;    if(DEBUG){Serial.println(&quot;pinDevid1 is HIGH&quot;);}&#xA;    pinDevid1State = true;&#xA;    Serial.println(&quot;DingDong&quot;);&#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(5000);&#xA;    Serial.println(&quot;Notification Sent.&quot;);&#xA;&#xA;    //reset vars&#xA;    val = 0;&#xA;    oldVal = 0;&#xA;    ringCounter =0;&#xA;  }&#xA;&#xA;  if (ringCounter &amp;lt; 3 &amp;amp;&amp;amp; pinDevid1State == true) // the doorbell stopped ringing&#xA;  {&#xA;    if(DEBUG){Serial.println(&quot;pinDevid1 is LOW&quot;);}&#xA;    pinDevid1State = false;&#xA;    digitalWrite(ledPin, LOW);&#xA;    Serial.println(&quot;DingDongEnd&quot;);&#xA;    //Sending request to PushingBox when the pin is LOW&#xA;    //sendToPushingBox(DEVID1);    //Here you can run an other scenario by creating a DEVID2 variable&#xA;&#xA;    //reset vars&#xA;    val = 0;&#xA;    oldVal = 0;&#xA;    ringCounter =0;&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15731" LastActivityDate="2015-12-24T13:29:23.680" Title="Using fluctuating voltage as an input" Tags="|arduino-uno|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18856" PostTypeId="1" CreationDate="2015-12-20T08:06:21.333" Score="2" ViewCount="6321" Body="&lt;p&gt;Is it possible to flash a &lt;code&gt;.hex&lt;/code&gt; file on an AVR MCU, which already contains the Arduino bootloader, using an AVRISP mkII, without overwriting the bootloader?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my concrete situation, I have an Arduino Uno that I would like to program sometimes over an AVRISP mkII, and sometimes using the built-in programmer (i.e. by just connecting the Uno via USB to a computer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, given a compiled &lt;code&gt;.hex&lt;/code&gt; file, this is what I use to upload it using the built-in programmer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c arduino -p atmega328p -P/dev/ttyACM0 -b115200 -D -Uflash:w:_build/image.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By default, this works as expected. I  can also use &lt;code&gt;avrdude&lt;/code&gt; to upload it using the AVRISP:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp2 -p atmega328p -U flash:w:_build/image.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gets my image on the board as well; however, it also seems to overwrite the bootloader, i.e. after this, I can only use the AVRISP, and not the built-in one, to upload images. The only way back, at this point, is to re-flash the bootloader (via the AVRISP) on the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I try to instruct &lt;code&gt;avrdude&lt;/code&gt; to upload via the AVRISP without overwriting the bootloader:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp2 -p atmega328p -D -U flash:w:_build/image.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then it fails in the verification phase:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on @ChrisStratton's answer, I understand this means my problem actually starts before I even try to upload it, by the compiler emitting code which has addresses that should belong to the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the command I use to compile and link (I am not using the Arduino IDE at all)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-g++ -c -g -O3 -w -std=c++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -I.. -mmcu=atmega328p -DF_CPU=16000000L blinkPB5.cpp -o _build/blinkPB5.cpp.o -MMD -MF _build/blinkPB5.cpp.m&#xA;avr-g++ -Os -Wl,--gc-sections -mmcu=atmega328p -o _build/image.elf _build/blinkPB5.cpp.o&#xA;avr-objdump -S _build/image.elf&#xA;avr-objcopy -Oihex -R.eeprom _build/image.elf _build/image.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As explained above, I can use the same resulting &lt;code&gt;.hex&lt;/code&gt; file both via the bootloader (by just uploading it via serial) and the AVRISP (by overwriting the bootloader).&lt;/p&gt;&#xA;" OwnerUserId="1568" LastEditorUserId="1568" LastEditDate="2015-12-21T12:01:57.623" LastActivityDate="2016-10-19T05:33:40.683" Title="Upload a .hex file, using a standalone ISP, without overwriting bootloader" Tags="|bootloader|avrdude|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18857" PostTypeId="1" AcceptedAnswerId="18858" CreationDate="2015-12-20T08:49:58.327" Score="2" ViewCount="13090" Body="&lt;p&gt;Are loops not allowed in setup()? The following doesn't print anything inside the &lt;code&gt;for&lt;/code&gt; loop to the serial terminal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Ping&quot;);&#xA;  for (int i = 0; i &amp;gt;= 10; i++) {&#xA;    Serial.println(i);&#xA;    Serial.println(&quot;Pong&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ping&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15730" LastActivityDate="2015-12-20T14:17:59.410" Title="Can I run a loop in setup()" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18858" PostTypeId="2" ParentId="18857" CreationDate="2015-12-20T09:23:00.030" Score="8" Body="&lt;p&gt;In principle yes, you can use a loop in setup() however this specific code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;gt;= 10; i++) {&#xA;  Serial.println(i);&#xA;  Serial.println(&quot;Pong&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will result in the body of the loop &lt;em&gt;never&lt;/em&gt; executing, as the loop test &lt;code&gt;i &amp;gt;= 10&lt;/code&gt; is &lt;em&gt;initially&lt;/em&gt; false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably meant &lt;code&gt;i &amp;lt;= 10&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, it would be poor program structure to use a loop in setup() in place of one in loop(), however if you need a loop to apply similar operations to a range of things, or to briefly busy wait on a condition as part of setting up operation, that kind of thing could be appropriate.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2015-12-20T09:23:00.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18859" PostTypeId="2" ParentId="11689" CreationDate="2015-12-20T10:18:30.377" Score="3" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cosa&lt;/a&gt; &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/TWI.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;TWI&lt;/a&gt; class is a very different approach to I2C device driver support. It does not use any extra SRAM for buffers at all. If a device driver is non-blocking it must handle the necessary buffering. Also the Cosa TWI class supports typical interaction with I2C devices such as master/slave, &quot;write register-read data&quot;-patterns, and transactions when using multi-threading. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A software and hardware &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-TWI&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino-TWI&lt;/a&gt; library is available. It uses the Arduino-GPIO library and can be used on AVR and SAM based boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some examples: &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/examples/Tools/CosaTWIscanner/CosaTWIscanner.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;TWI Scanner&lt;/a&gt;, &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/DS3231/DS3231.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;DS3231 Real-Time Clock/Calender&lt;/a&gt;, &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/DFRobot_IIC_LCD_Module/DFRobot_IIC_LCD_Module.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C LCD Adapter with PCF8574&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2017-10-05T22:13:45.080" LastActivityDate="2017-10-05T22:13:45.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18860" PostTypeId="1" AcceptedAnswerId="18861" CreationDate="2015-12-20T11:57:08.003" Score="0" ViewCount="729" Body="&lt;p&gt;I use &lt;a href=&quot;http://123d.circuits.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;this simulator&lt;/a&gt; to check if what I want to do works. This is how it looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZUyqx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZUyqx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've recently realised that I've connected my RGB LED to 5V pin instead of GND like on schema. It worked perfectly that way (led worked and chanaged colors). When I connected it back to GND pin, it didn't worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I went back to simulator and changed things to those that worked physically (using 5V pin) it didn't worked, but GND did.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do you think there are some differences? Can I use 5V pin instead of GND if it works? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino: Arduino Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="15733" LastActivityDate="2015-12-20T12:14:32.760" Title="Different behavior than in simulator: 5V pin works instead of GND. Why is that?" Tags="|power|arduino-leonardo|rgb-led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18861" PostTypeId="2" ParentId="18860" CreationDate="2015-12-20T12:14:32.760" Score="2" Body="&lt;p&gt;The RGB LED's are available with common cathode and common anode.  That determines whether you connect the common pin to ground or to +5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your schematic you likely mismatched the selected part to what you actually have.  If you have the opposite type of LED as planned, just reverse the connection as you did.  You are not alone in this type of mistake.  &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=22413.0&quot; rel=&quot;nofollow&quot;&gt;see similar whot? here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A digital multimeter with a diode test mode would be very useful here.  The DMM would quickly measure the polarity of the diode tell you which lead connects to positive and which to ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But did it really work correctly?  Don't you also see that you have to write LOW to the digital output to make the LED light up?&lt;/p&gt;&#xA;" OwnerUserId="3742" LastActivityDate="2015-12-20T12:14:32.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18862" PostTypeId="1" AcceptedAnswerId="18863" CreationDate="2015-12-20T12:41:34.943" Score="2" ViewCount="51" Body="&lt;p&gt;If you use an external oscillator, and divide-by-8 internally, can you apply up to 160MHz on PB6? For example, can I use my 50MHz oscillator to clock my 328p @ 6250KHz? Note: when I say oscillator I don't mean resonator or crystal&lt;/p&gt;&#xA;" OwnerUserId="4664" LastActivityDate="2015-12-20T14:20:43.260" Title="Input clock limit" Tags="|oscillator-clock|input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18863" PostTypeId="2" ParentId="18862" CreationDate="2015-12-20T13:46:03.640" Score="1" Body="&lt;p&gt;No! 20 MHz max (Please see &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;8.8 External Clock, pp. 34&lt;/a&gt;). The 50MHz clock could be divided by 8 with a &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT393.pdf&quot; rel=&quot;nofollow&quot;&gt;counter&lt;/a&gt; or the 150MHz clock by 16 with a &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/74/74VHC393.pdf&quot; rel=&quot;nofollow&quot;&gt;faster counter&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-20T14:20:43.260" LastActivityDate="2015-12-20T14:20:43.260" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18864" PostTypeId="2" ParentId="18857" CreationDate="2015-12-20T14:17:59.410" Score="3" Body="&lt;p&gt;You could (and I occasionally do) write your entire program in the &lt;code&gt;setup()&lt;/code&gt; function. &lt;code&gt;Setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; are constructs provided for your convenience, but they aren't necessary. In C/C++ compiled programs, it conventional for the C run-time code to call &lt;code&gt;main()&lt;/code&gt;, and for &lt;code&gt;main()&lt;/code&gt; to be written by the programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is conventional within the Arduino IDE world to bury the complicated stuff to let new user get productive quickly with a gentle learning curve.&#xA;That includes a pre-written &lt;code&gt;main()&lt;/code&gt; that provides the calls to &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following &lt;code&gt;main()&lt;/code&gt; function is typical of a number of pre-written Arduino &lt;code&gt;main()&lt;/code&gt; functions, but you don't have to use the pre-written one; you can supply your own. It will need to call &lt;code&gt;init()&lt;/code&gt;, and Arduino library function that prepares the hardware and software environment into a known state; after that you're good to go.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * main.cpp&#xA; *&#xA; *  Created on: Dec 13, 2011&#xA; *      Author: jrobert&#xA; */&#xA;&#xA;#include &quot;WProgram.h&quot;&#xA;&#xA;int main(void){&#xA;    init();&#xA;    setup();&#xA;    for(;;)&#xA;        loop();&#xA;}&#xA;&#xA;&#xA;&#xA;extern &quot;C&quot; void __cxa_pure_virtual() {&#xA;    while (1)&#xA;        ;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-20T14:17:59.410" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18865" PostTypeId="2" ParentId="18856" CreationDate="2015-12-20T15:56:30.037" Score="4" Body="&lt;p&gt;To preserve the bootloader, you should use the &lt;code&gt;-D&lt;/code&gt; option in the ISP command line just as it was used in the bootloader upload command line. This will disable usage of full-chip erase.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I expect you would end up with something like &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -c avrisp2 -p atmega328p -D -U flash:w:_build/image.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, it is important to add something which I overlooked when first posting this answer, which is that &lt;strong&gt;the ATmega series cannot do a &lt;em&gt;partial&lt;/em&gt; flash erase via the ISP interface&lt;/strong&gt; in the way that it can when the bootloader causes the chip to program itself.  This effectively means that you only get one shot at loading a program to an &lt;em&gt;already blank&lt;/em&gt; area of the chip this way - after that, to load a different one to the same area you will have to do a mass erase &lt;em&gt;of the entire chip&lt;/em&gt; and reload &lt;em&gt;both&lt;/em&gt; the bootloader and the sketch, or else command the bootloader to erase the blocks where the sketch would reside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you will also need a hex file for your sketch with no contents that conflict with the bootloader, as while the bootloader would refuse to overwrite any of its own blocks when programming a sketch, the ISP is perfectly happy to try to write over the top of the bootloader, which would likely result in a logical AND of the bits of two different pieces of code, and cause the chip to boot to nonsense.  A typical Arduino board configuration reserves space for the expected bootloader, so if the one you are using matches the size reserved in the chosen configuration, you should not have a conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option could be to combine the bootloader and sketch hex files, literally concatenating their contents one after the other into the same file.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-10-19T05:33:40.683" LastActivityDate="2016-10-19T05:33:40.683" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18866" PostTypeId="2" ParentId="18854" CreationDate="2015-12-20T18:08:19.297" Score="4" Body="&lt;p&gt;It isn't, it's displaying the previous message from when you didn't have the Serial Monitor open yet, plus the new message caused by the Arduino resetting from the Serial Monitor being opened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put a longer message in there you'll probably see the first line get cut off and then the full line.&lt;/p&gt;&#xA;" OwnerUserId="15295" LastActivityDate="2015-12-20T18:08:19.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18867" PostTypeId="2" ParentId="13400" CreationDate="2015-12-20T18:17:03.760" Score="1" Body="&lt;p&gt;Try using &lt;code&gt;dataFile.write(arrayName);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/FileWrite&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/FileWrite&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15295" LastActivityDate="2015-12-20T18:17:03.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18868" PostTypeId="2" ParentId="699" CreationDate="2015-12-20T19:32:34.190" Score="4" Body="&lt;p&gt;Sending 11 bits over serial at a baud of 9600, but for the sampling, I store it in an array with as little delay as possible, then once it's done, I send it through the serial port to be read by a python script. I'm doing this for an FFT using matplotlib. I listen to a 0-5V signal, then without using the delay() function, I store the analogRead() values into that array. In a split second the reading is done, then the serial data dump starts. When I calibrated the input frequency using tone() from another connected Arduino, I realized that I had to divide the index by 8915 in order to get accuracy to within .1 Hz. Because one would have to divide by the frequency of the sampling to get the proper index intervals, my guess is the Arduino sampling frequency (at least mine with my code) is 8915Hz. &lt;/p&gt;&#xA;" OwnerUserId="15738" LastActivityDate="2015-12-20T19:32:34.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18869" PostTypeId="1" AcceptedAnswerId="18870" CreationDate="2015-12-20T19:36:26.930" Score="0" ViewCount="101" Body="&lt;p&gt;My code keeps saying that that Button_8 and the rest of the #define macros are out of scope.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRLib.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define MY_PROTOCOL SONY&#xA;#define RIGHT_ARROW   0xfd50af //Move several clockwise&#xA;#define LEFT_ARROW    0xfd10ef //Move servo counterclockwise&#xA;#define SELECT_BUTTON 0xfd906f //Center the servo&#xA;#define UP_ARROW      0xfda05f //Increased number of degrees servo &#xA;#define DOWN_ARROW    0xfdb04f //Decrease number of degrees servo moves&#xA;#define BUTTON_0 0xfd30cf  //Pushing buttons 0-9 moves to fixed  positions&#xA;#define BUTTON_1 0xfd08f7  // each 20 degrees greater&#xA;#define BUTTON_2 0xfd8877&#xA;#define BUTTON_3 0xfd48b7&#xA;#define BUTTON_4 0xfd28d7&#xA;#define BUTTON_5 0xfda857&#xA;#define BUTTON_6 0xfd6897&#xA;#define BUTTON_7 0xfd18e7&#xA;#define BUTTON_8 0xfd9867&#xA;#define BUTTON_9 0xfd58a7&#xA;&#xA;IRrecv My_Receiver(11);//Receive on pin 11&#xA;IRdecode My_Decoder; &#xA;long Previous;&#xA;Servo myservo2;&#xA;Servo myservo;  &#xA;&#xA;&#xA;void setup() &#xA;{&#xA;myservo.attach(8); &#xA;myservo2.attach(3);&#xA;My_Receiver.enableIRIn();&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  if (My_Receiver.GetResults(&amp;amp;My_Decoder))&#xA;{&#xA;   My_Decoder.decode();&#xA;   if(My_Decoder.decode_type==MY_PROTOCOL) &#xA;   {&#xA;       if(My_Decoder.value==0xFFFFFFFF)&#xA;       My_Decoder.value= Previous;&#xA;       if(My_Decoder.value == Button_9)&#xA;       {&#xA;       myservo.write(0);&#xA;       myservo2.write(180);&#xA;       }&#xA;     else if(My_Decoder.value == Button_8)&#xA;      {&#xA;         myservo.write(180);&#xA;          myservo2.write(180);&#xA;       }&#xA;&#xA;&#xA;    }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when i use a switch statement instead of the 4 and 5 if statement like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch(My_Decoder.value) {&#xA;        case Button_8:   //do something; break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it works, but i dont know why.&lt;/p&gt;&#xA;" OwnerUserId="7837" LastActivityDate="2015-12-20T19:38:41.187" Title="#define macro not in scope when i try to use IR library" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18870" PostTypeId="2" ParentId="18869" CreationDate="2015-12-20T19:38:41.187" Score="2" Body="&lt;p&gt;C++ is case-sensitive. &lt;code&gt;Button_8&lt;/code&gt; is different from &lt;code&gt;BUTTON_8&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-20T19:38:41.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18871" PostTypeId="2" ParentId="18043" CreationDate="2015-12-20T20:38:33.443" Score="1" Body="&lt;p&gt;The Yun makes communication between the microprocessor and the Linux side easy.  On the Arduino side, use the Bridge library in your &quot;processing script&quot; to read (or write) Bridge values set by the python program running on the Linux side.  From the linux side, the bridge looks like a web address and you set values by addressing a URL with a get or put url http request. You can also manipulate these values from another computer on the network as well if you like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some Arduino Yun dataloggers that use the Linux side to communicate via wifi with an ftp server that serves several Yun dataloggers. The arduino script reads the sensors, creates the records, etc. You can also have the microprocessor side write files that are used by the linux side of the Yun. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find the Yun's combination of Linux and the regular arduino in one package makes the overall system easier to program and to interface with the rest of the web.&lt;/p&gt;&#xA;" OwnerUserId="15740" LastEditorUserId="15740" LastEditDate="2015-12-20T20:51:20.980" LastActivityDate="2015-12-20T20:51:20.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18872" PostTypeId="1" AcceptedAnswerId="18878" CreationDate="2015-12-20T21:29:25.487" Score="0" ViewCount="142" Body="&lt;p&gt;I'm trying to alternatively have a random int generate a binary number with 4 lights. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my current code, However, it seems that all the lights(leds) go on, I don't think the minus option works. As in, it won't take a value from the currently randomized digit. (randombinary = randombinary - x)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried just &quot;randombinary - x&quot;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int button = 2;&#xA;const int redone = 13;&#xA;const int redtwo = 8;&#xA;const int greenone = 12;&#xA;const int greentwo = 7;&#xA;int randomnumber = 0;&#xA;int randombinary = 0;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;  pinMode(7, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(2, INPUT);&#xA;&#xA;}&#xA;  void loop() {&#xA;&#xA;delay(1000);&#xA;&#xA;  int randomnumber = (1, 15);&#xA;  randombinary = randomnumber;&#xA;&#xA;  if (randombinary &amp;gt;=8){&#xA;    digitalWrite(redone, HIGH);&#xA;   randombinary = randombinary - 8;&#xA;  }&#xA; else {&#xA;   digitalWrite(redone, LOW);&#xA; }&#xA;&#xA;&#xA;  if (randombinary &amp;gt;=4){&#xA;    digitalWrite(greenone, HIGH);&#xA;   randombinary = randombinary - 4;&#xA;  }&#xA;  else {&#xA;    digitalWrite(greenone, LOW);&#xA;  }&#xA;&#xA;  if (randombinary &amp;gt;=2){&#xA;    digitalWrite(redtwo, HIGH);&#xA;  randombinary =  randombinary - 2; &#xA;  }&#xA;  else  {&#xA;    digitalWrite(greentwo, LOW);&#xA;  }&#xA;&#xA;  if (randombinary &amp;gt;=1){&#xA;    digitalWrite(greentwo, HIGH);&#xA;  randombinary =  randombinary - 1;&#xA;  }&#xA;  else  {&#xA;    digitalWrite(greentwo, LOW);&#xA;  }&#xA;&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would appreciate any help!&lt;/p&gt;&#xA;" OwnerUserId="15745" OwnerDisplayName="Texz" LastActivityDate="2015-12-21T08:16:13.473" Title="Arduino C, Led &gt; binary alternative all lights" Tags="|led|c|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18873" PostTypeId="2" ParentId="18872" CreationDate="2015-12-20T21:36:22.127" Score="1" Body="&lt;pre&gt;&lt;code&gt;int randomnumber = (1, 15);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Guess you have missed to call &lt;a href=&quot;https://www.arduino.cc/en/Reference/Random&quot; rel=&quot;nofollow&quot;&gt;random&lt;/a&gt;. That statement actually always returns 15. C is a strange language.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int randomnumber = random(1, 15);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-20T21:36:22.127" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18875" PostTypeId="2" ParentId="18872" CreationDate="2015-12-20T22:27:07.120" Score="0" Body="&lt;p&gt;So here's the new version, very strange, when I set the number on random, it doesn't work. However, if I enter a number myself, it does.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int button = 2;&#xA;const int redone = 13;&#xA;const int redtwo = 8;&#xA;const int greenone = 12;&#xA;const int greentwo = 7;&#xA;int randomnumber = 0;&#xA;int randombinary = 0;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(13, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;  pinMode(7, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(2, INPUT);&#xA;&#xA;&#xA;&#xA;&#xA;      maarten();&#xA;&#xA;    }&#xA;      void loop() {&#xA;&#xA;      }&#xA;&#xA;      void maarten(){&#xA;&#xA;&#xA;&#xA;      int randomnumber = random(1, 15);&#xA;      randombinary = randomnumber;&#xA;&#xA;    if (randombinary &amp;gt;=8){&#xA;&#xA;      digitalWrite(redone, HIGH);&#xA;      randombinary = randombinary - 8;&#xA;    }&#xA;    else {&#xA;      digitalWrite(redone, LOW);&#xA; }&#xA;&#xA;&#xA;    if (randombinary &amp;gt;=4){&#xA;&#xA;      digitalWrite(greenone, HIGH);&#xA;      randombinary = randombinary - 4;&#xA;    }&#xA;    else {&#xA;      digitalWrite(greenone, LOW);&#xA;    }&#xA;&#xA;    if (randombinary &amp;gt;=2){&#xA;&#xA;      digitalWrite(redtwo, HIGH);&#xA;      randombinary =  randombinary - 2; &#xA;    }&#xA;    else  {&#xA;      digitalWrite(greentwo, LOW);&#xA;    }&#xA;&#xA;   if (randombinary &amp;gt;=1){&#xA;&#xA;     digitalWrite(greentwo, HIGH);&#xA;     randombinary =  randombinary - 1;&#xA;   }&#xA;   else  {&#xA;     digitalWrite(greentwo, LOW);&#xA;  }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15745" LastActivityDate="2015-12-20T22:27:07.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18876" PostTypeId="1" AcceptedAnswerId="18914" CreationDate="2015-12-20T23:32:23.047" Score="5" ViewCount="2909" Body="&lt;p&gt;I tried to fix this problem the whole weekend but, after no success I decided to post it here. I would really appreciate any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Wi-Fi module activates the DC motor and lets it run for 3 seconds, but when the DC motor stops after that 3 seconds, the Wi-Fi module and display don't respond anymore.  It only works once.  (After I push the reset button the same thing happens.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What causes this disturbance? Any advice on my circuit?&lt;/strong&gt; (I included a Fritzing Diagram because I am bad at drawing schematics)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BREkf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BREkf.jpg&quot; alt=&quot;Fritzing Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;SoftwareSerial ESP8266(9, 8); // RX = 8 en TX = 9&#xA;&#xA;#define DEBUG true&#xA;&#xA;boolean FAIL_8266 = false;&#xA;int LED = 13; // led op 13&#xA;&#xA;int secondeAan = 3000;&#xA;&#xA;String my_AP_SSID = &quot;myID&quot;;&#xA;String my_AP_Pass = &quot;myPass&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;  // -- stel led in --&#xA;  pinMode(LED, OUTPUT);&#xA;&#xA;  // -- lcd scherm --&#xA;  lcd.begin(16, 2);&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 1);&#xA;&#xA;  do {&#xA;    ESP8266.begin(115200); // start communicatie met esp8266&#xA;&#xA;    //Wait Serial Monitor to start&#xA;    while (!Serial);&#xA;&#xA;    lcd.clear();&#xA;    lcd.print(&quot;--- Start ---&quot;);&#xA;&#xA;    ESP8266.print(&quot;AT\r\n&quot;);&#xA;    delay(500);&#xA;&#xA;    if (ESP8266.find(&quot;OK&quot;))&#xA;    {&#xA;      FAIL_8266 = false;&#xA;      sendData(&quot;AT+RST\r\n&quot;, 4000, DEBUG);&#xA;      sendData(&quot;AT+CWMODE=3\r\n&quot;, 2000, DEBUG);&#xA;      sendData(&quot;AT+CWJAP=\&quot;&quot; + my_AP_SSID + &quot;\&quot;,\&quot;&quot; + my_AP_Pass + &quot;\&quot;,9,4\r\n&quot;, 2000, DEBUG);&#xA;      sendData(&quot;AT+CIFSR\r\n&quot;, 2000, DEBUG);&#xA;      sendData(&quot;AT+CIPMUX=1\r\n&quot;, 2000, DEBUG);&#xA;      sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;, 2000, DEBUG);&#xA;&#xA;    } else {&#xA;      lcd.clear();&#xA;      lcd.setCursor(0, 1);&#xA;      lcd.print(&quot;Module have no response.&quot;);&#xA;      delay(500);&#xA;      FAIL_8266 = true;&#xA;    }&#xA;  } while (FAIL_8266);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  // Get the number of bytes (characters) available for reading from the serial port&#xA;  if (ESP8266.find(&quot;+IPD,&quot;))&#xA;  {&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Nieuwe connectie&quot;);&#xA;    // -- sluit connectie --&#xA;    motorToggle();&#xA;    sendData(&quot;AT+CIPCLOSE=0\r\n&quot;, 100, DEBUG);&#xA;    sendData(&quot;AT+CIPCLOSE=1\r\n&quot;, 100, DEBUG);&#xA;    sendData(&quot;AT+CIPCLOSE=2\r\n&quot;, 100, DEBUG);&#xA;  }&#xA;}&#xA;&#xA;void motorToggle () {&#xA;  digitalWrite(LED, HIGH);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;eten gegeven&quot;);&#xA;  delay(secondeAan);&#xA;  digitalWrite(LED, LOW);&#xA;  delay(200);&#xA;}&#xA;&#xA;String sendData(String command, const int timeout, boolean debug)&#xA;{&#xA;  String response = &quot;&quot;;&#xA;&#xA;  ESP8266.print(command); // send the read character to the esp8266&#xA;&#xA;  long int time = millis();&#xA;&#xA;  while ( (time + timeout) &amp;gt; millis())&#xA;  {&#xA;    while (ESP8266.available())&#xA;    {&#xA;      char c = ESP8266.read();&#xA;      response += c;&#xA;    }&#xA;  }&#xA;&#xA;  if (debug)&#xA;  { lcd.clear();&#xA;    lcd.print(response);&#xA;  }&#xA;&#xA;  return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15748" LastEditorUserId="3917" LastEditDate="2015-12-30T16:52:51.680" LastActivityDate="2015-12-30T16:52:51.680" Title="Arduino DC motor causes disturbance. What can cause it?" Tags="|arduino-uno|motor|lcd|c|esp8266|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18877" PostTypeId="2" ParentId="18876" CreationDate="2015-12-21T06:19:19.493" Score="3" Body="&lt;p&gt;There are a couple of things that could be causing your problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The current draw of the motor, especially at start up. The motor may be drawing enough power to pull down the voltage at the processor causing it to crash, or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You may be seeing transients as the motor starts and/or stops that are causing the processor to crash.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One way you could detect problems like this is to use the on-board LED as a heart beat or run indicator. You could either blink it in &lt;code&gt;loop()&lt;/code&gt; or do something like turn it off just before starting or stopping the motor and then back on afterwards. If the blink stops or if the LED goes out then you know that the processor has stopped running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a general rule, except with the tiniest of motors, I'd suggest using the Arduino to control a transistor that controls the motor from its own power supply line (it could be the same supply as the one the feeds the Arduino, just don't run the motor power through the Arduino). That and the suggestions in the comments will go a long way towards isolating the Arduino from the motor and power disturbances it will cause.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-21T06:19:19.493" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18878" PostTypeId="2" ParentId="18872" CreationDate="2015-12-21T08:16:13.473" Score="2" Body="&lt;p&gt;Code review (one possible solution can be found below) &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Absolute numbers in the code, like 15 as the limit for the random numbers are generally considered harmful. It would be better to give all absolute numbers a constantsname and use these throughout. The OP code did not use the constants for the pins, for instance. &lt;/li&gt;&#xA;&lt;li&gt;Writing similar pieces of code in a row makes maintenance hard. Therefore, group similar items in any kind of list, like an array, and iterate over them. &lt;/li&gt;&#xA;&lt;li&gt;Functions should have expressive names clearly stating what is going on inside. &lt;/li&gt;&#xA;&lt;li&gt;Functions should be short and concise, ideally having only a few lines. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Try something along these lines: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// setting the number of bits to analyze, corresponding pins and corresponding powers of two.&#xA;// the latter is here for instructional purposes although it is redundant. &#xA;const int numberOfBits = 4;&#xA;const int randLimit = 15;   // 2^(1+numberOfBits)-1 actually;&#xA;int ledPins[numberOfBits] = {13, 8, 12, 7};&#xA;int bitValue[numberOfBits] = {8, 4, 2, 1}; // the powers of two&#xA;&#xA;void turnOffAllLeds ()&#xA;{&#xA;  Serial.println (&quot;turning all off&quot;);&#xA;  for (int i = 0; i &amp;lt; numberOfBits; i++)&#xA;  {&#xA;    digitalWrite (ledPins[i], LOW);&#xA;  }&#xA;}&#xA;&#xA;void selectivelyTurnOnLeds(int value)&#xA;{&#xA;  turnOffAllLeds ();&#xA;&#xA;  // now for each bit, check if it is set in the value, if yes: turn on corresponding led&#xA;  for (int i = 0; i &amp;lt; numberOfBits; i++)&#xA;  {&#xA;    if ((value &amp;amp; bitValue[i]) &amp;gt; 0)&#xA;    {&#xA;      digitalWrite (ledPins[i], HIGH);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void setup() &#xA;{&#xA;  for (int i = 0; i &amp;lt; numberOfBits; i++)&#xA;  {&#xA;    pinMode (ledPins[i], OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  selectivelyTurnOnLeds (random (randLimit));&#xA;  delay (1000);&#xA;}                                                                            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S. When posting a question, please also post what your code is supposed to do. If it were not for a lazy prechristmas workday, I would not have taken the time to reverse engineer your code. &lt;/p&gt;&#xA;" OwnerUserId="15752" LastActivityDate="2015-12-21T08:16:13.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18880" PostTypeId="1" CreationDate="2015-12-21T09:54:51.017" Score="2" ViewCount="595" Body="&lt;p&gt;Can you please tell me to find out Airtel IR Remote Mark and Space coding. I am making a project in which i have to Airtel IR Remote But I do not have decoding style of it. So please help me out. Any help will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="14658" LastActivityDate="2017-02-09T12:01:26.297" Title="What is the Mark and Space of Ir remote of Airtel?" Tags="|arduino-uno|ir|remote-control|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18882" PostTypeId="1" AcceptedAnswerId="18883" CreationDate="2015-12-21T12:51:54.937" Score="0" ViewCount="1183" Body="&lt;p&gt;I have an issue with an Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to communicate with it through the Serial-Port. Meaning I want to send and receive Serial commands. With USB and the &quot;Serial Monitor&quot; this works nice.&#xA;Now I have connected the COM-Port of the PC with Adruinos Digital Pins 0 and 1 (RX and TX) and a GND PIN. (3 Cables total).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a minimal example of my Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600,SERIAL_8N1);&#xA;  Serial.println(&quot;Start&quot;);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Hello World&quot;);&#xA;&#xA;  delay( 1000 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Serial Monitor says:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start&#xA;Hello World&#xA;Hello World&#xA;Hello World&#xA;Hello World&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Putty however says:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒::&#xA;                                                     ▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*▒▒    ▒R▒▒▒t▒*▒▒▒R▒▒▒t▒*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Putty is connected with &#xA;- BaudRate: 9600&#xA;- Data Bits: &#xA;- Stop Bits: 1&#xA;- Parity: None&#xA;- Flow Control: None&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;The PC has a 9-pin D socket (&lt;a href=&quot;http://www.airyear.com/images/products1/202711.jpg&quot; rel=&quot;nofollow&quot;&gt;Image&lt;/a&gt;)&#xA;This is connected to a RS232 to RJ45 connector (&lt;a href=&quot;http://ecx.images-amazon.com/images/I/41BucionchL._SY300_.jpg&quot; rel=&quot;nofollow&quot;&gt;image&lt;/a&gt;)&#xA;From the RJ45-Cable I used the Brown, Blue, and White/Green Cable to connect with the Arduino&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="15493" LastEditDate="2015-12-21T13:03:40.410" LastActivityDate="2015-12-21T13:03:40.410" Title="Issue with Serial PINs (RX/TX) on Arduino" Tags="|serial|arduino-nano|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18883" PostTypeId="2" ParentId="18882" CreationDate="2015-12-21T12:59:44.647" Score="3" Body="&lt;p&gt;RS232 is not TTL. You need a level converter. For more details see &lt;a href=&quot;https://www.sparkfun.com/tutorials/215&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/tutorials/215&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-21T12:59:44.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18884" PostTypeId="1" CreationDate="2015-12-21T13:19:22.837" Score="0" ViewCount="2169" Body="&lt;p&gt;I have a DotStar LED strip that I want to make it blink (e.g., 1 second on, 5 second off in an endless loop).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried doing so via the script below but it does not work. Can someone please explain me how to do so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Script:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_DotStar.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;          &#xA;&#xA;#define NUMPIXELS 10&#xA;&#xA;#define DATAPIN    4&#xA;#define CLOCKPIN   5&#xA;Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);  &#xA;&#xA;void setup() &#xA;{&#xA;  strip.begin();  &#xA;  strip.show();   &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  strip.show(); &#xA;  strip.setBrightness(155);  &#xA;  for (int i=0; i &amp;lt;= 10; i=i+1) {&#xA;    strip.setPixelColor(i, 255, 255, 255); &#xA;  }&#xA;  delay(1000); &#xA;&#xA;  strip.setBrightness(0);  &#xA;  delay(5000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7040" LastEditorUserId="6936" LastEditDate="2016-03-25T11:01:59.240" LastActivityDate="2016-03-25T11:01:59.240" Title="Flashing dotStar LED" Tags="|led|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18886" PostTypeId="1" AcceptedAnswerId="19721" CreationDate="2015-12-21T15:29:46.063" Score="0" ViewCount="265" Body="&lt;p&gt;Can an RFID tag be used to identify a room? For example, I walk into a room, and the RFID receiver tells me that I am in say, the living room. Would it be possible for a tag to ping back the signal from a distance of 10ft? Or is there a similar technology like RFID that can extend to a much greater range? &lt;/p&gt;&#xA;" OwnerUserId="13691" LastActivityDate="2016-01-18T22:13:00.840" Title="RFID tag &quot;location identification&quot;" Tags="|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18887" PostTypeId="2" ParentId="18884" CreationDate="2015-12-21T15:45:20.043" Score="2" Body="&lt;p&gt;The basic idea of the program you're trying to write is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;  strip.show(); // Turn LED strip on.&#xA;  delay(1000);  // One second, argument is milliseconds.&#xA;  strip.setBrightness(0); //Turn LED strip off.&#xA;  delay(5000);&#xA;  strip.setBrightness(155); //Turn LED strip on.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't used the Adafruit DotStar library, so there may be details that I'm missing (like do you need to do a &lt;code&gt;strip.show()&lt;/code&gt; after setting the brightness). But maybe this is enough to get you thinking about how to construct the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real joy in hacking with something like this is the experimenting and the learning. Take the time to try to understand how you project works and to predict what will change as you modify the code and how you can tell if it is working the way you expect – that will get you a long way towards being a strong programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you're troubleshooting something new and/or unfamiliar, one thing that really helps is to break down the problem into simple steps. For example with this project a good first step would be to get the DotStart strip to turn on. Then see if you can get it to turn off. Build it up piece by piece.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-21T16:22:30.203" LastActivityDate="2015-12-21T16:22:30.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18888" PostTypeId="1" CreationDate="2015-12-21T15:54:39.097" Score="1" ViewCount="248" Body="&lt;p&gt;I am developing code to run a word clock and have noticed a slight problem. I am using a DS3231 to keep time, and using the &lt;code&gt;Wire&lt;/code&gt; library to communicate with it. I ping the DS3231 every second to get the time and check a few other things. This is all working fine except when the clock loses power. It seems that occasionally upon loss of power to the Arduino, the time that that the DS3231 reports when it regains power, is incorrect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought is that the power is getting cut in the middle of various &lt;code&gt;Wire.read()&lt;/code&gt; commands and this is causing the chip to mess up and reset its own time, but I am not sure. The DS3231 has a battery backup attached to it, and that battery has only been plugged in for a month or two, so I don't imagine that is the problem.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering if anyone has an idea how I can deal with this potential problem, or if there is some way I can clear the &lt;code&gt;Wire&lt;/code&gt; library before it starts up again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have put some sample code below to give an idea of what I am doing. There is of course much more code, but this is the only relevant part. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define kClockAddress 0x68&#xA;&#xA;void readDS3231time(byte * second, byte * minute, byte * hour, byte * dayOfWeek, byte * dayOfMonth, byte * month, byte * year) {&#xA;  Wire.beginTransmission(kClockAddress);&#xA;  Wire.write(0); // set DS3231 register pointer to 00h&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom(kClockAddress, 7); // request seven bytes of data from DS3231 starting from register 00h&#xA;  *second = bcdToDec(Wire.read() &amp;amp; 0x7f);&#xA;  *minute = bcdToDec(Wire.read());&#xA;  *hour = bcdToDec(Wire.read() &amp;amp; 0x3f);&#xA;  *dayOfWeek = bcdToDec(Wire.read());&#xA;  *dayOfMonth = bcdToDec(Wire.read());&#xA;  *month = bcdToDec(Wire.read());&#xA;  *year = bcdToDec(Wire.read());&#xA;}&#xA;&#xA;void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231&#xA;  Wire.beginTransmission(kClockAddress);&#xA;  Wire.write(0); // set next input to start at the seconds register&#xA;  Wire.write(decToBcd(second)); // set seconds&#xA;  Wire.write(decToBcd(minute)); // set minutes&#xA;  Wire.write(decToBcd(hour)); // set hours&#xA;  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)&#xA;  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)&#xA;  Wire.write(decToBcd(month)); // set month&#xA;  Wire.write(decToBcd(year)); // set year (0 to 99)&#xA;  Wire.endTransmission();&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Wire.begin()&#xA;   // DS3231 seconds, minutes, hours, day, date, month, year&#xA;   //setDS3231time(0, 36, 10, 2, 21, 12, 15);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // retrieve data from DS3231&#xA;  readDS3231time(&amp;amp;second, &amp;amp;minute, &amp;amp;hour, &amp;amp;dayOfWeek, &amp;amp;dayOfMonth, &amp;amp;month, &amp;amp;year);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14954" LastEditorUserId="10794" LastEditDate="2016-01-30T03:51:51.000" LastActivityDate="2016-02-01T19:45:07.880" Title="Arduino Uno Wire Transmission Issues" Tags="|arduino-uno|c++|power|time|wire-library|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18890" PostTypeId="1" CreationDate="2015-12-21T16:49:52.323" Score="3" ViewCount="1112" Body="&lt;p&gt;I am an engineer at a machine shop. When a machine stops running, I want to be notified via a vibrating pager (like at restaurants). My plan is to attach the arduino board in the machine and when the machine stops (quits vibrating) I want it to trigger the vibrating pager that I have in my pocket. By what means can the arduino communicate with the vibrating pager to cause it to go off? SMS? Wifi? Bluetooth would likely be out of range. Other options?&lt;/p&gt;&#xA;" OwnerUserId="15762" LastActivityDate="2015-12-21T17:31:31.893" Title="Use Arduino to transmit signal to a vibrating pager" Tags="|arduino-uno|communication|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18891" PostTypeId="2" ParentId="18890" CreationDate="2015-12-21T17:31:31.893" Score="2" Body="&lt;p&gt;To do SMS through a GSM shield like &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoGSMShield&lt;/a&gt; with a dataplan, and the device should be accessible anywhere you can get reception.  With a wifi shield like &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield101&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoWiFiShield101&lt;/a&gt; you could make it work within your wifi network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sparkfun's sales guide at &lt;a href=&quot;https://www.sparkfun.com/pages/wireless_guide&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/pages/wireless_guide&lt;/a&gt; indicates there are a few bluetooth modules that reach 100m, so if your range is less than 100m, bluetooth is a possibility.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2015-12-21T17:31:31.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18893" PostTypeId="1" CreationDate="2015-12-21T20:51:08.250" Score="3" ViewCount="840" Body="&lt;p&gt;I am trying to upload the Marlin Firmware to my 3D printer's Arduino Mega 2560 and I am experiencing a problem. It keeps saying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;qr_solve.cpp:7:18: fatal error: time.h: No such file or directory&#xA; #include &amp;lt;time.h&amp;gt;&#xA;                  ^&#xA;compilation terminated.&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help as I'm lost as how to fix it, because I try to scroll up to see what is highlighted in red and I can't find anything.&lt;/p&gt;&#xA;" OwnerUserId="14769" LastEditorUserId="6936" LastEditDate="2017-06-02T22:39:52.887" LastActivityDate="2017-09-01T12:25:52.967" Title="Marlin Firmware troubles: &lt;time.h&gt; error" Tags="|arduino-mega|firmware|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18894" PostTypeId="2" ParentId="18813" CreationDate="2015-12-21T21:17:23.093" Score="1" Body="&lt;p&gt;I ran into a similar quandary when making a prototype for a device that needed real test-data from an external, glove-worn accelerometer. I wound up running the data/power/etc pins from my Arduino board to a female RJ-45 jack (I've used a telephone jack on another project where only 4 wires were needed). Then I cut an old cat-5 network cable in half and soldered the wire-ends to data/power/etc pins on my external sensor board. This allowed me to separate one component's wiring scheme from the other's. (FYI: longer lengths of cable between components does increase the risk of noise/interference corrupting digital signals. This can usually be resolved by reducing data rates or by adding a few resistors/capacitors to filter the signal, but I have limited knowledge on this)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you don't have any old RJ45 cables/jacks laying around, it can really help to find some way to &quot;modularize&quot; the various pieces that will be working together when your device is complete. If you're familiar with object oriented programming, think of it as &quot;designing an interface&quot; for each component. Then, even if you completely redesign the wiring for a particular component, you only need to ensure that your &quot;interface&quot; (aka connection) is the same, and you wont need to resolder anything on the other end of the line. &lt;/p&gt;&#xA;" OwnerUserId="10664" LastActivityDate="2015-12-21T21:17:23.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18895" PostTypeId="1" AcceptedAnswerId="18898" CreationDate="2015-12-21T23:53:58.490" Score="2" ViewCount="9932" Body="&lt;p&gt;From what I understand the master has primary control over the slaves and communicates with them. A master must always be present as well, and can be connected to (up to) 7 slaves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If I have 2 arduinos with Bluetooth communicating with each other&#xA;from within a radius of 80 meters or less, which arduino do I set as&#xA;the &lt;strong&gt;master&lt;/strong&gt; and which do I set as the &lt;strong&gt;slave&lt;/strong&gt;? (what dictates which one should be set as master, etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want both arduinos to be able to transmit data to one-another (where neither has privilege over the other), so in my mind this is more like two slaves communicating. Both devices have the same controls on them and will effect the other devices the exact same way.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How does the &lt;strong&gt;communication&lt;/strong&gt; process work exactly, and how should more&#xA;arduinos be addressed if they are to be added with similar&#xA;privileges?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14947" LastActivityDate="2015-12-22T00:42:28.743" Title="How Master and Slave concept works with Bluetooth?" Tags="|bluetooth|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18896" PostTypeId="1" AcceptedAnswerId="18905" CreationDate="2015-12-22T00:02:21.757" Score="3" ViewCount="4248" Body="&lt;p&gt;I wanted to buy an Arduino (ATmega) 2560 (8 Bit MCU) via Amazon. But there was no Arduino visible. There was only a &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.amazon.de/SainSmart-Mega2560-ATmega2560-ATMEGA8U2-cable/dp/B00FLL8OZG/ref=sr_1_1?ie=UTF8&amp;amp;qid=1450723952&amp;amp;sr=8-1&amp;amp;keywords=arduino%20mega&quot; rel=&quot;nofollow noreferrer&quot;&gt;SainSmart 2560&lt;/a&gt; and&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2FJHj.png&quot; alt=&quot;SainSmart 2560 image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.amazon.de/SunFounder-ATmega2560-16AU-Board-compatible-Arduino/dp/B00D9NA4CY/ref=sr_1_1?s=computers&amp;amp;ie=UTF8&amp;amp;qid=1450738573&amp;amp;sr=1-1&amp;amp;keywords=sunfounder%202560&quot; rel=&quot;nofollow noreferrer&quot;&gt;SunFounder 2560&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZsfiF.png&quot; alt=&quot;SunFounder 2560 image&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On both websides (SainSmart and SunFounder) there is the information that they are Arduino compatible. But all three boards (Atmel-orginal, SainSmart, SunFounder) do not look similar... There are differences. Is it possible to buy one of those boards without:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;checking the datasheet differences&lt;/li&gt;&#xA;&lt;li&gt;having problems with the Arduino Ethernet Shield !?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, what is &lt;strong&gt;compatible&lt;/strong&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="15770" LastActivityDate="2015-12-22T10:01:47.623" Title="What does &quot;Arduino compatible&quot; mean?" Tags="|arduino-mega|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18897" PostTypeId="2" ParentId="18813" CreationDate="2015-12-22T00:28:42.377" Score="0" Body="&lt;p&gt;For accelerometer sensing I used LIS3DH from STMicroelectronics, its low power(down to 2uA), small (LGA package 3x3x1 mm) and has cool build-in features (like orientation, tap and doble tap detection among other things). &lt;a href=&quot;http://www.st.com/web/catalog/sense_power/FM89/SC444/PF250725?icmp=pf250725_pron_pr_feb2014&quot; rel=&quot;nofollow&quot;&gt;http://www.st.com/web/catalog/sense_power/FM89/SC444/PF250725?icmp=pf250725_pron_pr_feb2014&lt;/a&gt; and there are a lot of libraries like &lt;a href=&quot;https://github.com/adafruit/Adafruit_LIS3DH&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_LIS3DH&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For intro to GSR check this project &lt;a href=&quot;http://cwwang.com/2008/04/13/gsr-reader/&quot; rel=&quot;nofollow&quot;&gt;http://cwwang.com/2008/04/13/gsr-reader/&lt;/a&gt; Pretty easy ;) More advanced design will require a signal generator and an instrumentation amplifier. An example of such design can be found here &lt;a href=&quot;https://www.maximintegrated.com/en/design/reference-design-center/system-board/6147.html/tb_tab1&quot; rel=&quot;nofollow&quot;&gt;https://www.maximintegrated.com/en/design/reference-design-center/system-board/6147.html/tb_tab1&lt;/a&gt; Another interesting project is the truth wristband &lt;a href=&quot;http://produceconsumerobot.com/truth/&quot; rel=&quot;nofollow&quot;&gt;http://produceconsumerobot.com/truth/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The temperature part can be done with a thermistor (IC temperature sensors do not compliant with your resolution spec) and a bridge circuit. For reference check this sensor &lt;a href=&quot;http://www.digikey.com/product-detail/en/PR103J2/615-1069-ND/2651611&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com/product-detail/en/PR103J2/615-1069-ND/2651611&lt;/a&gt; and also some literature about Wheatstone Bridge &lt;a href=&quot;http://www.ametherm.com/thermistor/ntc-thermistors-temperature-measurement-with-wheatstone-bridge&quot; rel=&quot;nofollow&quot;&gt;http://www.ametherm.com/thermistor/ntc-thermistors-temperature-measurement-with-wheatstone-bridge&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope be helpful. &lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-12-22T00:28:42.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18898" PostTypeId="2" ParentId="18895" CreationDate="2015-12-22T00:42:28.743" Score="3" Body="&lt;p&gt;Well, master/slave concept for Bluetooth resides on the protocol, not in the communications. On few words, this means Bluetooth Master is who has the ability to initiate connection with a peripheral (or slave), but onces connected both master and slave basically can interchange information without restriction (limited by application). If your bluetooth module or implementation has a SPP (serial port profile &lt;a href=&quot;https://developer.bluetooth.org/TechnologyOverview/Pages/SPP.aspx&quot; rel=&quot;nofollow&quot;&gt;https://developer.bluetooth.org/TechnologyOverview/Pages/SPP.aspx&lt;/a&gt;) once the master finds and connect to the slave, information can flow in both ways like a chat (actually, chat application is the most common usage example of bluetooth modules)&lt;/p&gt;&#xA;" OwnerUserId="11037" LastActivityDate="2015-12-22T00:42:28.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18900" PostTypeId="2" ParentId="6617" CreationDate="2015-12-22T01:02:08.283" Score="2" Body="&lt;p&gt;I hate to say it, but the answer is no, there is not way to uniquely identify multiple 340 based usb-serial converters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same problem, where I have multiple (4+) usb-serial converters, any one could be plugged into any port, and they were purchased at the same time and therefore are identical in every way (including iSerial of 0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, if I move things around, I have to connect by hand to see what's attached, peruse dmesg output, etc. It's a big pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tom&lt;/p&gt;&#xA;" OwnerUserId="15771" LastActivityDate="2015-12-22T01:02:08.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18901" PostTypeId="2" ParentId="18896" CreationDate="2015-12-22T03:30:26.137" Score="2" Body="&lt;p&gt;Arduino is an open-source electronics platform. Lots of other manufacturers make Arduino-compatible boards, not just Arduino/Genuino. I have used both Arduino-branded and 3rd party manufactured boards without encountering any issues. I have not used boards by SainSmart or SunFounder, but they look compatible from a specifications perspective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are worried about compatibility with the Ethernet Shield, you could always buy them as a pair (e.g. &lt;a href=&quot;http://www.amazon.de/SainSmart-Arduino-Ethernet-Shield-Duemilanove/dp/B00I1W25KM/ref=sr_1_2?ie=UTF8&amp;amp;qid=1450754865&amp;amp;sr=8-2&amp;amp;keywords=SainSmart+Ethernet+Shield+W5100&quot; rel=&quot;nofollow&quot;&gt;SainSmart Arduino Mega 2560 + Ethernet Shield for Arduino UNO Mega Duemilanove R3 AVR PIC ATMEL Robot&lt;/a&gt;) just to be on the safe side.&lt;/p&gt;&#xA;" OwnerUserId="15757" LastActivityDate="2015-12-22T03:30:26.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18903" PostTypeId="1" AcceptedAnswerId="19054" CreationDate="2015-12-22T07:09:42.733" Score="3" ViewCount="42696" Body="&lt;p&gt;I have an Arduino Uno and ESP8266. I want to connect and control an LED from a web server. I made a connection referring to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KYbW1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KYbW1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow noreferrer&quot;&gt;WifiWebServer&lt;/a&gt; code to the Arduino, and applied my router's credentials.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ssid[] = &quot;Router SSID&quot;;      // your network SSID (name) &#xA;char pass[] = &quot;Router's WPA Password&quot;; `&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm getting a &quot;Wifi Shield not present&quot; message from the Serial Monitor. I even tried giving external 3.3v power supply to my ESP8266 module, but no change. What am I missing here? Can someone help me fix this issue? &lt;/p&gt;&#xA;" OwnerUserId="15774" LastEditorUserId="4628" LastEditDate="2015-12-24T10:05:02.717" LastActivityDate="2017-11-27T20:30:08.977" Title="Connecting ESP8266 with Arduino Uno - WiFi shield not present" Tags="|arduino-uno|esp8266|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18904" PostTypeId="2" ParentId="18903" CreationDate="2015-12-22T08:26:04.267" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;WiFiWebServer tutorial&lt;/a&gt; describes how to use the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow&quot;&gt;ArduinoWiFiShield&lt;/a&gt;. This shield is based on different WiFi hardware than the ESP8266 modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a WiFi library driving the ESP8266 modules instead, e.g &lt;a href=&quot;http://docs.iteadstudio.com/ITEADLIB_Arduino_WeeESP8266/index.html&quot; rel=&quot;nofollow&quot;&gt;WeeESP8266&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your favourite internet finding machine sure will find lots of similar libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A different approach would be &lt;a href=&quot;http://www.arduinesp.com&quot; rel=&quot;nofollow&quot;&gt;ArduinESP&lt;/a&gt; (&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;), which means to develop code to run on the ESP8266 module directly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;...aaaand please rethink your wiring. The ESP8266 modules are a pure 3.3V pets and your wiring connects a 5V logic signal directly to the ESP8266 and this may send your ESP8266 into the digital heaven with or without waving goodbye using blue smoke...&lt;/p&gt;&#xA;" OwnerUserId="653" LastEditorUserId="653" LastEditDate="2015-12-23T00:09:33.140" LastActivityDate="2015-12-23T00:09:33.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18905" PostTypeId="2" ParentId="18896" CreationDate="2015-12-22T09:17:57.847" Score="3" Body="&lt;p&gt;Arduino Compatible can mean many things, but most of the time it means that some company has made something they sell to a customer that supports development with the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is that most Arduino Compatible units use the Atmel processors, but some use others too. Third party developers then make &quot;board&quot;-projects that you can add into the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be aware though that you in some cases can run into issues if you dont do your homework, here are some of the issues you can run into:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some &quot;compatible&quot; boards use different architectures, so even if you can do many things with the Arduino IDE, maybe some sensor libraries are not supported. (Might have to be hacked or updated)&lt;/li&gt;&#xA;&lt;li&gt;Some &quot;compatible&quot; boards have different USB-circuits (if they have them at all)&lt;/li&gt;&#xA;&lt;li&gt;Most of the boards you buy off aliexpress, banggood etc. do not come with instructions at all and some times they differ from the &quot;original&quot; design (might be better, might be &quot;the same&quot; or might be worse.).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not trying to scare you off, but just my experiences. You can find a lot of fun things on those sites like clones of lilitiny with the AtTiny 85. One example is in my blog heer: &lt;a href=&quot;http://mjelde.blogspot.no/2015/12/lilytiny-lilypad-attiny85-wearable-iot.html&quot; rel=&quot;nofollow&quot;&gt;http://mjelde.blogspot.no/2015/12/lilytiny-lilypad-attiny85-wearable-iot.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main issue with the clones I've had is that some times they differ in some ways that the first times will make you scratch your head. Like: ESP8266 is Arduino Compatible with the boards manager added ( &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt; ), BUT: The input pins are not &quot;correct&quot; marked. So you should then add constants to &quot;remap&quot; them in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the ESP8266 does only support 1V analog read, while many Arduinos support 5V. But you can &quot;fix&quot; this with an 16bit ADC (analog to digital converter). The ESP8266 only has 3.3V also, so you cant run sensors that &quot;must&quot; have 5V, without then giving them a different power circuit :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AtTiny 85 LilyTiny clone i bought in a pair of 2 from AliExpress works fine and works different than the rest of the Arduinos. Uploading to those for instance means you leave them disconnected and then you hit upload in the IDE. Then it says in the status window to connect it, which you then do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it uploads. It has very few inputs, but it's very cute id say. Primarily it's made for wearable and of course it has a lot of short comings compared to a large arduino board. But you can of course use it to control RGB leds, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember to always check specifications (3V vs 5V, how much analog read resolution can it handle, etc). There is the sensor vs board (some sensors work on both 3.3V and 5V, some work only on 5V, some only on 3.3V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For going to 5V to 3.3V you usually use a voltage divider. Either you can buy pre made ones or you can make it based off three resistors and some math :-)&lt;/p&gt;&#xA;" OwnerUserId="15777" LastActivityDate="2015-12-22T09:17:57.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18906" PostTypeId="2" ParentId="18896" CreationDate="2015-12-22T10:01:47.623" Score="0" Body="&lt;p&gt;The other answer seem to focus on &quot;compatible&quot; meaning &quot;works with the IDE&quot; but that's not what they mean here. &quot;Compatible&quot; in this context means &quot;clone of the original&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can count on these boards being functionally identical. The microprocessor and pinout are the same, which is what a shield cares about. The peripheral circuitry might vary slightly, but that's not a big deal. They might (as mentioned) have a different USB-Serial chip but that won't cause any issues once you install the appropriate drivers on your PC.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2015-12-22T10:01:47.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18907" PostTypeId="1" CreationDate="2015-12-22T11:57:01.063" Score="1" ViewCount="1058" Body="&lt;p&gt;I am working on a project, trying to construct an 80 button keypad. My problem is how to multiplex it so that i only feed the arduino with two sets of BCD or binary(whichever is easier) which are supposed to drive a 75 led display board simultaneously with a pair of 7 segments. The led display board is remote, which means i should drive the boards serially. The other 5 buttons remaining out of 80 are for other functions such as clear last number etc.&#xA;Please help!&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Thank you very much guys. To answer FuaZe, it is 16*8 but will not use the whole 128 buttons. These extra buttons are for future expansion. The input should consist 16colums and 8 rows. The remote output board is a led matrix numbered from 1 to 75, arranged in a 15colums and 5rows. The same display board is to have a two digit 7seg display. The remote board is to be accessed serially so as to use few cables.&#xA;When I press a button on the matrix, say column 5 row 2 the number 20 should appear on the 7seg plus a correspondind diode on column 5 row 2 to light. In short if is a bingo board with numbers 1 to 75..&lt;/p&gt;&#xA;" OwnerUserId="15778" LastEditorUserId="37622" LastEditDate="2021-12-01T13:24:54.857" LastActivityDate="2021-12-01T13:24:54.857" Title="16 by 8 Keyboard matrix" Tags="|keyboard|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="18908" PostTypeId="1" CreationDate="2015-12-22T11:58:45.780" Score="0" ViewCount="1806" Body="&lt;p&gt;I know there are multiple threads about ethernet shields not starting properly after power up and that there are versions that don't have those problems. But which versions are okay? Which versions do not require extra soldering/pin bending/physical resets? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How good are chinese rip-offs of those versions?&lt;/p&gt;&#xA;" OwnerUserId="13760" LastActivityDate="2022-09-01T12:06:40.600" Title="Ethernet shield reset problems" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18909" PostTypeId="1" AcceptedAnswerId="46003" CreationDate="2015-12-22T12:12:44.107" Score="0" ViewCount="225" Body="&lt;p&gt;i've got a huge (about 6 x 23 cm) graphics LCD. I used my multimeter and the datasheet the LCD driver chips (6 x KS0104 and 2 x KS0103) to get the pinout. It has the following pins: GND, M, FCS (not 100% shure), CL1, CL2, D0-3, VDD and a ground for the metal part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that i dont know how i can drive a 4bit GLCD with an Arduino because i didnt found a library which can do this (e.g. OpenGLCD supports only the KS0104 which is an 8 bit controller)&lt;/p&gt;&#xA;" OwnerUserId="15779" LastActivityDate="2017-10-28T23:07:43.503" Title="How to drive a 4bit GLCD?" Tags="|library|lcd|display|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="18910" PostTypeId="1" AcceptedAnswerId="18913" CreationDate="2015-12-22T12:41:30.500" Score="0" ViewCount="753" Body="&lt;p&gt;My .ino looks roughly like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;command.h&quot;&#xA;&#xA;Command command;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Command&#xA;{&#xA;    public:&#xA;        Command();&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;command.h&quot;&#xA;&#xA;Command::Command() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    char inChar = (char)Serial.read();&#xA;    Serial.print(inChar);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial events don't seem to be happening. It works normally if I move the code out of the class.&lt;/p&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2016-07-12T12:44:36.610" Title="serialEvents within a class" Tags="|serial|class|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18911" PostTypeId="1" CreationDate="2015-12-22T13:57:09.673" Score="1" ViewCount="231" Body="&lt;p&gt;I haven't been able to get the example code from the page &lt;a href=&quot;https://www.arduino.cc/en/Reference/WiFiClientConnect&quot; rel=&quot;nofollow&quot;&gt;WiFi:Client:connect()&lt;/a&gt; to work on my Arduino Yún. Is this not how I'm supposed to send data over WiFi to be read by something like a socket?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, how would I go about doing so? (This is the only solution I've found from the internet).&lt;/p&gt;&#xA;" OwnerUserId="15782" LastEditorUserId="6936" LastEditDate="2016-01-02T19:36:19.730" LastActivityDate="2016-01-02T19:36:19.730" Title="Does WiFiClient work on a Yún to send data over a certain IP and port to be received by a Python socket?" Tags="|wifi|arduino-yun|communication|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18912" PostTypeId="2" ParentId="18907" CreationDate="2015-12-22T14:03:26.227" Score="1" Body="&lt;p&gt;Easiest would be to use 2 arduino's, which are connected in some way.&#xA;One of them should tell the other one what to do. I suggest you make the one reading the buttons the &quot;master&quot; and the other one it's &quot;slave&quot; device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use 8 inputs, for each column and 10 outputs for each row.&#xA;Then you check all 8 inputs per column (pretty rapidly) and then you'll be able to read every button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could choose to either send changes or just every value to the slave device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The slave device would have to do something similiar, but with 2 outputs, to address the right LED's/segments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could use shift-registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There actually are a lot of tutorials on this to be found on the web.&#xA;You should check out &quot;Arduino multiplexing&quot; or &quot;Arduino led cube&quot; tutorials.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-12-22T14:03:26.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18913" PostTypeId="2" ParentId="18910" CreationDate="2015-12-22T14:59:10.283" Score="4" Body="&lt;p&gt;When you put the &lt;code&gt;Serial.begin&lt;/code&gt; in the constructor and declare the &lt;code&gt;Command&lt;/code&gt; object at file scope, the &lt;code&gt;Serial.begin&lt;/code&gt; will occur &lt;em&gt;before&lt;/em&gt; &lt;code&gt;setup()&lt;/code&gt;.  Not recommended, perhaps not allowed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do that, the compiler has to figure out that the &lt;code&gt;Serial&lt;/code&gt; instance must be constructed before the &lt;code&gt;Command&lt;/code&gt; instance is constructed.  It can't always figure out the correct order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, this is why you see many classes with a &lt;code&gt;begin&lt;/code&gt; or &lt;code&gt;init&lt;/code&gt; method.  This allows the construction of file-scope instances to take place in any order, before &lt;code&gt;setup&lt;/code&gt;.  Then &lt;code&gt;setup&lt;/code&gt; does the &lt;code&gt;Command.begin()&lt;/code&gt;, which finally calls &lt;code&gt;Serial.begin&lt;/code&gt;, long after &lt;code&gt;Serial&lt;/code&gt; has been constructed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, using &lt;code&gt;SerialEvent&lt;/code&gt; is no better than doing the polling in &lt;code&gt;loop()&lt;/code&gt;.  If you're busy doing something else, &lt;code&gt;SerialEvent&lt;/code&gt; does not get called.  If you need to handle characters in the background, in the RX interrupt, you might want to take a look at a modified version for the &lt;code&gt;Serial&lt;/code&gt; object(s) I posted, &lt;a href=&quot;https://github.com/SlashDevin/NeoHWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoHWSerial&lt;/a&gt;.  You can attach a routine to be called whenever a character is received.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2015-12-22T14:59:10.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18914" PostTypeId="2" ParentId="18876" CreationDate="2015-12-22T15:09:36.483" Score="5" Body="&lt;p&gt;Thanks for the help everyone. I fixed it by using Capacitors. They suppress the noise that the dc motor produces. I found my information  &lt;a href=&quot;https://www.pololu.com/docs/0J15/9&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dATTj.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dATTj.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15748" LastActivityDate="2015-12-22T15:09:36.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18915" PostTypeId="2" ParentId="18911" CreationDate="2015-12-22T15:17:59.127" Score="1" Body="&lt;p&gt;No, that code is only for the WiFi shield.  For the Yun you need to look at the &lt;a href=&quot;https://www.arduino.cc/en/Reference/YunBridgeLibrary&quot; rel=&quot;nofollow&quot;&gt;Bridge&lt;/a&gt; library that is bundled with the IDE. It allows you to run commands and perform actions on the Linux based Atheros portion of the Yun which is what has access to the WiFi.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-22T15:17:59.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18916" PostTypeId="2" ParentId="18842" CreationDate="2015-12-22T18:16:08.993" Score="1" Body="&lt;p&gt;There a some mistakes with the wiring of the supply voltage (Vss) according to the datasheet (&lt;a href=&quot;http://www.ti.com/lit/ds/symlink/l293.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.ti.com/lit/ds/symlink/l293.pdf&lt;/a&gt;) of the L293D a those on pin 8 (Vss2) and 16 (Vss1). I think those are not connected because each Vss is for one motor of the driver. So you have to connect 9V (or 12V) to both pins.&#xA;There is also something wrong with the capacitor (polarity). And your connection of the battery to the breadboard is a bit weird because + of the battery is usally the red not the black wire / marked row on the breadboard.&lt;/p&gt;&#xA;" OwnerUserId="15779" LastActivityDate="2015-12-22T18:16:08.993" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18917" PostTypeId="2" ParentId="9468" CreationDate="2015-12-22T18:34:36.757" Score="0" Body="&lt;p&gt;If you search for &quot;arduino lcd tft shield&quot; on ebay you should if a few shields for your kind of lcd. But all of them require an Arduino MEGA (or DUE). &#xA;You could also use some kind of a shift register to drive this lcd with an Arduino UNO (or other small boards).&lt;/p&gt;&#xA;" OwnerUserId="15779" LastActivityDate="2015-12-22T18:34:36.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18918" PostTypeId="1" CreationDate="2015-12-22T19:32:49.640" Score="2" ViewCount="328" Body="&lt;p&gt;When programming the Pro Mini using this USB-to-serial adapter the boot loader only works once. After the first programming the programmer is out of sync or not responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to program the Pro Mini again I have to burn the bootloader using my Uno as an ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming the Pro Mini through an Uno does not present the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the lock bits not being set properly or somehow overridden?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QLPso.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QLPso.jpg&quot; alt=&quot;Usb to serial module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15787" LastEditorUserId="10907" LastEditDate="2016-01-11T18:44:25.300" LastActivityDate="2022-05-04T14:04:10.377" Title="Bootloader only works once with usb to serial module" Tags="|serial|usb|bootloader|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18919" PostTypeId="1" CreationDate="2015-12-22T20:30:14.000" Score="2" ViewCount="17421" Body="&lt;p&gt;I am writing an Arduino sketch to read temp data from multiple DS18B20 sensors and then write it to serial. The problem is, as I am connecting more sensors, the delay between my temp data is written to a serial increases (like 100ms for 1 sensor and 1s for 4 sensors). Can I somehow improve my sketch to read it faster?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sketch I am using:&#xA;(I am using DallasTemperature to simplify it all)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;#define ONE_WIRE_BUS 10&#xA;#define TEMPERATURE_PRECISION 8&#xA;#define BAUD_RATE 9600&#xA;&#xA;// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;&#xA;// Pass our oneWire reference to Dallas Temperature. &#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;// arrays to hold device addresses&#xA;DeviceAddress devices[10];&#xA;int devicesFound = 0;&#xA;&#xA;void setup(void)&#xA;{&#xA;  // start serial port&#xA;  Serial.begin(BAUD_RATE);&#xA;  //Serial.println(&quot;Dallas Temperature IC Control Library Demo&quot;);&#xA;&#xA;  // Start up the library&#xA;  sensors.begin();&#xA;&#xA;  // locate devices on the bus&#xA;  Serial.print(&quot;Locating devices...&quot;);&#xA;  Serial.print(&quot;Found &quot;);&#xA;  Serial.print(sensors.getDeviceCount(), DEC);&#xA;  Serial.println(&quot; devices.&quot;);&#xA;&#xA;  devicesFound = sensors.getDeviceCount();  &#xA;&#xA;  // report parasite power requirements&#xA;  Serial.print(&quot;Parasite power is: &quot;); &#xA;  if (sensors.isParasitePowerMode()) Serial.println(&quot;ON&quot;);&#xA;  else Serial.println(&quot;OFF&quot;);&#xA;&#xA;  for (int i = 0; i &amp;lt; devicesFound; i++)&#xA;    if (!sensors.getAddress(devices[i], i)) &#xA;      Serial.println(&quot;Unable to find address for Device&quot; + i); &#xA;&#xA;  // show the addresses we found on the bus&#xA;  for (int i = 0; i &amp;lt; devicesFound; i++)&#xA;  {    &#xA;    Serial.print(&quot;Device &quot; + (String)i + &quot; Address: &quot;);&#xA;    printAddress(devices[i]);&#xA;    Serial.println();&#xA;  }&#xA;&#xA;  for (int i = 0; i &amp;lt; devicesFound; i++)&#xA;    sensors.setResolution(devices[i], TEMPERATURE_PRECISION);&#xA;}&#xA;&#xA;// function to print a device address&#xA;void printAddress(DeviceAddress deviceAddress)&#xA;{&#xA;  for (uint8_t i = 0; i &amp;lt; 8; i++)&#xA;  {&#xA;    // zero pad the address if necessary&#xA;    if (deviceAddress[i] &amp;lt; 16) Serial.print(&quot;0&quot;);&#xA;    Serial.print(deviceAddress[i], HEX);&#xA;  }&#xA;}&#xA;&#xA;// function to print the temperature for a device&#xA;String printTemperature(DeviceAddress deviceAddress)&#xA;{&#xA;  float tempC = sensors.getTempC(deviceAddress);&#xA;  if (tempC &amp;lt; 10)&#xA;    return &quot;0&quot; + (String)tempC;&#xA;  else&#xA;    return (String)tempC;&#xA;}&#xA;&#xA;// function to print a device's resolution&#xA;void printResolution(DeviceAddress deviceAddress)&#xA;{&#xA;  Serial.print(&quot;Resolution: &quot;);&#xA;  Serial.print(sensors.getResolution(deviceAddress));&#xA;  Serial.println();    &#xA;}&#xA;&#xA;// main function to print information about a device&#xA;void printData(DeviceAddress deviceAddress)&#xA;{&#xA;  Serial.print(&quot;Device Address: &quot;);&#xA;  printAddress(deviceAddress);&#xA;  Serial.print(&quot; &quot;);&#xA;  printTemperature(deviceAddress);&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop(void)&#xA;{ &#xA;  if (devicesFound == 0)&#xA;  {&#xA;     Serial.println(&quot;No devices found.&quot;);&#xA;     return;&#xA;  }&#xA;&#xA;  sensors.requestTemperatures();&#xA;&#xA;  String sent = &quot;&quot;;&#xA;&#xA;  // print the device information&#xA;  for (int i = 0; i &amp;lt; devicesFound; i++)&#xA;  {&#xA;    sent += printTemperature(devices[i]);&#xA;    if (i != devicesFound - 1)&#xA;      sent += &quot; &quot;;    &#xA;  }&#xA;&#xA;  Serial.println(sent);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15117" LastActivityDate="2017-06-05T15:02:27.407" Title="How to read temperature from multiple DS18B20 faster?" Tags="|sensors|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18920" PostTypeId="1" AcceptedAnswerId="18921" CreationDate="2015-12-22T20:41:11.353" Score="0" ViewCount="839" Body="&lt;p&gt;Currently I'm controlling an RGB LED with my Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm mixing the colors using analogWrite&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though, the LED's don't light up at all for low analogwrite values and the difference between the levels is not visible (to me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using 100 Ohms resistors between the LED's, using a 680Ohms didn't seem to make a difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Analogwrite is working by toggling the LED's fast (PWM)? So not by lowering voltage? This is why I think it's weird that they don't light up at all, on low write values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int r, g, b = 0;&#xA;String command = &quot;&quot;;&#xA;const byte rxPin = 11;&#xA;const byte txPin = 10;&#xA;&#xA;SoftwareSerial blueTooth (rxPin, txPin);&#xA;&#xA;void handleCommand() {&#xA;  r = rgbFromCommand(&quot;r=&quot;,&quot;;&quot;);&#xA;  g = rgbFromCommand(&quot;g=&quot;,&quot;;&quot;);&#xA;  b = rgbFromCommand(&quot;b=&quot;,&quot;;&quot;);&#xA;&#xA;  if(r != -1){&#xA;    analogWrite(A2,r);&#xA;  }&#xA;  if(g != -1){&#xA;    analogWrite(A1,g);&#xA;  }&#xA;  if(b != -1){&#xA;    analogWrite(A0,b);&#xA;  }&#xA;}&#xA;&#xA;int rgbFromCommand(String prefix, String postfix) {&#xA;  int idx = command.indexOf(prefix);&#xA;  int endIdx = command.indexOf(postfix,idx);&#xA;  if(idx&amp;gt;=0 &amp;amp;&amp;amp; endIdx&amp;gt;=0){&#xA;    idx+=2;&#xA;    return command.substring(idx,endIdx).toInt();&#xA;  }&#xA;  return -1;&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(rxPin,INPUT);&#xA;  pinMode(txPin,OUTPUT);&#xA;  Serial.begin(9600);&#xA;  blueTooth.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    // read the incoming byte:&#xA;    char incomingByte = Serial.read();&#xA;&#xA;    if(incomingByte == '\n'){&#xA;      handleCommand();&#xA;      command = &quot;&quot;;&#xA;    }else{&#xA;      command += incomingByte;&#xA;    }&#xA;  }&#xA;  if(blueTooth.available() &amp;gt; 0){&#xA;        // read the incoming byte:&#xA;    char incomingByte = blueTooth.read();&#xA;&#xA;    if(incomingByte == '\n'){&#xA;      handleCommand();&#xA;      command = &quot;&quot;;&#xA;    }else{&#xA;      command += incomingByte;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-12-22T20:49:59.737" Title="RGB Led - mixing colors using analogWrite" Tags="|analogwrite|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18921" PostTypeId="2" ParentId="18920" CreationDate="2015-12-22T20:49:59.737" Score="2" Body="&lt;p&gt;Analog pins aren't PWM pins. Instead you have to use the pins marked with a &lt;code&gt;~&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins that aren't PWM pins will be off with a value of 0-127 and on with a value between 128 and 255.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-22T20:49:59.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18922" PostTypeId="2" ParentId="18908" CreationDate="2015-12-22T20:54:00.980" Score="0" Body="&lt;p&gt;If you don't want to make any modifications to the shield, and you don't want to make any modifications in code, then there really is only one option:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't use cheap knockoffs, but buy a genuine Arduino one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you have a board that requires modifications to work properly and if you're unwilling to make those required modifications then you can not just magic it into working by waving your magic wand.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-22T20:54:00.980" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18923" PostTypeId="2" ParentId="18919" CreationDate="2015-12-22T21:04:42.343" Score="2" Body="&lt;p&gt;I would start by changing this section:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String sent = &quot;&quot;;&#xA;&#xA;// print the device information&#xA;for (int i = 0; i &amp;lt; devicesFound; i++)&#xA;{&#xA;  sent += printTemperature(devices[i]);&#xA;  if (i != devicesFound - 1)&#xA;  sent += &quot; &quot;;    &#xA;}&#xA;&#xA;Serial.println(sent);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This section should read and print the temperature directly instead of creating a string. The string handling is a large overhead and it does not allow Serial (UART) to work very much in parallel if the buffer is filled. The printTemperature() function is using a lot of strings (and heap operations).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you have done what is possible; 1) reduce the conversion resolution (9-bits is minimum), 2) use single conversion request command to all sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative is to use alarm triggers and only read sensors with alarms. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-22T21:04:42.343" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18924" PostTypeId="2" ParentId="13485" CreationDate="2015-12-22T22:59:41.700" Score="0" Body="&lt;p&gt;The 4053 can replace the 4051 (&lt;a href=&quot;http://media.digikey.com/pdf/Data%20Sheets/Fairchild%20PDFs/CD4051BC.pdf&quot; rel=&quot;nofollow&quot;&gt;data sheet&lt;/a&gt;). To do that the three output pins on 4053 should be tied together (pin 4, 14 and 15, see logic diagram). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device allows adding eight analog pins at the cost of three digital pins and one analog pin. The device will multiplex the eight new analog pins onto the arduino analog pin. Three digital pins are used to select which pin is multiplexed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino &lt;a href=&quot;http://playground.arduino.cc/Learning/4051&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; for 4051 will work just fine with the above modification of the wiring. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-22T22:59:41.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18925" PostTypeId="1" CreationDate="2015-12-22T23:04:57.473" Score="3" ViewCount="569" Body="&lt;p&gt;Long story short: I need to pair these devices: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino UNO with Seeed BLE Shield&lt;/li&gt;&#xA;&lt;li&gt;Adafruit Feather 32u4 Bluefruit LE.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The Seeed shield is configured and able to connect and communicate via the UART to an Android phone by HM BLE Terminal app from Google Play Store.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can also connect the phone and Feather. The two independent connections work really well but a problem occurs when connecting the Seeed shield with Feather. &lt;strike&gt;Connection isn't troubling&lt;/strike&gt; No errors are reported but I can't send/receive any data via the serial monitor (I'm using &lt;a href=&quot;https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/tree/master/examples/bleuart_cmdmode&quot; rel=&quot;nofollow&quot;&gt;bleuart_cmdmode&lt;/a&gt; or &lt;a href=&quot;https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/tree/master/examples/bleuart_datamode&quot; rel=&quot;nofollow&quot;&gt;bleuart_datamode&lt;/a&gt; from the Adafruit examples).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically my question is how to make them work: HM-11 module with BLE and the Adafruit board (nRF51822 chipset from Nordic).&lt;/p&gt;&#xA;" OwnerUserId="15790" LastEditorUserId="3917" LastEditDate="2015-12-31T19:54:20.843" LastActivityDate="2018-05-09T20:49:30.783" Title="Working with Seed BLE Shield and Adafruit Feather BLE" Tags="|arduino-uno|serial|bluetooth|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18926" PostTypeId="2" ParentId="18723" CreationDate="2015-12-22T23:24:00.450" Score="1" Body="&lt;p&gt;I just received 2 of these from 2 different suppliers on EBAY.&#xA;None work using the pins called [GND +5V DIN]. As it turns out the DIN is actually NOT DIN. The other connector area [GND +5V DOUT] is the DIN. Ugh!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These boards are marked CJMCU-8*8 on the back side and on the front they say &quot;WS2812B-64 RGB LEDS&quot;. Which is another issue. They are using the 6 pin WS2812, not the 4 pin WS2812B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if this is what your board looks like then perhaps try the pin marked DOUT for your DIN. Or try to psych out the traces to make sure first.&lt;/p&gt;&#xA;" OwnerUserId="15792" LastActivityDate="2015-12-22T23:24:00.450" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18927" PostTypeId="2" ParentId="18903" CreationDate="2015-12-22T23:45:07.660" Score="3" Body="&lt;p&gt;You can program and upload code to ESP8266 using Arduino programming environment, reusing code and libraries with small changes. Check &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt; for more information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For most tasks ESP8266 may substitute Arduino board completely. It has more flash, more RAM and integrated WiFi, and is faster (80MHz).&lt;/p&gt;&#xA;" OwnerUserId="15705" LastActivityDate="2015-12-22T23:45:07.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18928" PostTypeId="1" AcceptedAnswerId="19083" CreationDate="2015-12-23T00:31:09.983" Score="0" ViewCount="5736" Body="&lt;p&gt;Very broad question here.  I don't know exactly what the problem is but I'll edit this post as we narrow down the possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I'm running into memory constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running a sketch that records two temperature values every 60 seconds and transmits them to an AWS RDB via wifi.  It works well for about two hours then stops.  I don't know if it's a memory constraint but I suspect that it is.  What other common problems (often overlooked by newbies) can cause a sketch to end after a couple hours of run-time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to add an instruction to a loop to clear the SRAM?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO + WiFi 101&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit #1 12/24/2015:&lt;br&gt;It's the WiFi board.  It happily remains connected to my phone's hotspot but only lasts an hour or two on my home network.  Working on root cause...any ideas are welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit #2 12/25/2015:&lt;br&gt;Tried to Wifi.disconnect() and reconnect with no luck.  Why do some networks kick the board off while others work just fine?  Will look into the watchdog.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="13355" LastEditDate="2015-12-25T14:40:25.073" LastActivityDate="2016-02-27T22:13:48.237" Title="Clearing SRAM in loop()" Tags="|arduino-uno|wifi|sketch|memory-usage|sram|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18929" PostTypeId="2" ParentId="16656" CreationDate="2015-12-23T00:47:46.053" Score="1" Body="&lt;p&gt;Have you tried other baud rates? Could you paste a link to the manual or upload the manual itself? From what i could find quickly, the module supports 3 modes: RS232, RS485 and Wiegand 26/34. So the manual should provide some means of selecting a particular mode (perhaps the CS pin?). I suspect you arent actually using the RS232 mode, which is why you are getting strange results. If you can't find a way to select a mode, you could try brute-forcing it and try the WG26 mode next. This code from seeedstudio seems to do the job &lt;a href=&quot;http://www.seeedstudio.com/depot/datasheet/RFID_630_WG.pde&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/depot/datasheet/RFID_630_WG.pde&lt;/a&gt; or you could look at the Wiegand protocol on Wikipedia and write your own code, since its relatively straight forward. Also a google image search turned up this link to Aliexpress: &lt;a href=&quot;http://www.aliexpress.com/item/Waterproof-Security-Door-Access-Control-Wiegand-26-125KHz-RFID-ID-Card-Reader-EM4100-102A/1362129655.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/Waterproof-Security-Door-Access-Control-Wiegand-26-125KHz-RFID-ID-Card-Reader-EM4100-102A/1362129655.html&lt;/a&gt;; this is your reader, right?&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-23T00:47:46.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18930" PostTypeId="2" ParentId="18928" CreationDate="2015-12-23T01:21:36.427" Score="0" Body="&lt;p&gt;Could you provide your sketch? At the rate you mentioned, 2 hours is merely 240 values and this shouldn't even matter since you are probably reassigning values to the same variables and not storing them in some growing array. Perhaps your WIFI shield merely gets disconnected from the network. How do you mean the sketch stops? Like you no longer receive the values in the database? More info is needed.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-23T01:21:36.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18931" PostTypeId="1" AcceptedAnswerId="18933" CreationDate="2015-12-23T01:47:04.167" Score="0" ViewCount="1182" Body="&lt;p&gt;For a project that I'm working on I need an extremely small, power efficient wireless device (could be radio, or some other interface) to network between a series of ATTiny85s and a larger Arduino. The communication range only needs to be about 1 foot, max. I'm currently using wired I2C, so it would be excellent if someone could suggest a radio or another device that can use the two digital pins previously occupied by the SCK and SDA lines on the ATTiny. I have those two, along with one extra digital pin available for use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This device needs to be extremely small - &lt;a href=&quot;http://www.miniinthebox.com/upgraded-2-4ghz-nrf24l01-wireless-transceiver-module-for-arduino-black_p683437.html&quot; rel=&quot;nofollow&quot;&gt;this common NRF24L01&lt;/a&gt; package is too big and its SPI interface uses too many pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="15677" LastEditorUserId="11529" LastEditDate="2015-12-23T15:53:05.283" LastActivityDate="2015-12-24T01:44:24.720" Title="Small, Power-Efficient wireless communication with ATTiny85" Tags="|arduino-uno|attiny|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18932" PostTypeId="2" ParentId="18907" CreationDate="2015-12-23T02:47:29.493" Score="1" Body="&lt;p&gt;Another option would be using both shift registers and port expanders, like Adafruit's &lt;a href=&quot;https://www.adafruit.com/products/732&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP23017 I2C Port Expander&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can use that for the buttons, just get a few of them and hook them up on the I2C bus and you have over eighty pins for the price of 2! If you choose to use the previously stated expander, you will also benefit from Adafruit's library.&lt;/p&gt;&#xA;&lt;p&gt;Then, use a shift register for your LEDs, using one of the pins that is not I2C.&lt;/p&gt;&#xA;&lt;p&gt;Note: Pin expanders can handle input and output. Shift registers are only for output!&lt;/p&gt;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="10712" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-23T02:47:29.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18933" PostTypeId="2" ParentId="18931" CreationDate="2015-12-23T03:17:34.760" Score="2" Body="&lt;p&gt;An RF kit like &lt;a href=&quot;http://www.elecfreaks.com/estore/315mhz-rf-link-kit.html&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. It's a 2-part kit, Tx and Rx separately -- each needing Vcc, GND and one pin. You need both on each ATTiny to be able to transmit and receive.&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-12-23T03:17:34.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18934" PostTypeId="1" CreationDate="2015-12-23T08:20:19.720" Score="0" ViewCount="301" Body="&lt;p&gt;I created my project prototype with Arduino Micro and Adafruit Bluetooth low energy device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I need to develop the prototype to production (like a small USB device). I just need Rx, Tx, 3V pin from Arduino Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started design with ATmega32U4, USB and BLE by using Fritzing IDE. I am confused with Arduino Micro parts like reset, bootloader and other pins. Is there any problem if I leave the unwanted pins from Arduino unconnected, for my project? Will it work correctly like a Arduino micro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my first PCB design. Please help me to design a final PCB with the unwanted pins left unconnected.&lt;/p&gt;&#xA;" OwnerUserId="15799" LastEditorUserId="6936" LastEditDate="2015-12-30T06:53:00.020" LastActivityDate="2021-06-28T21:06:10.587" Title="Arduino Micro project with Bluetooth low energy" Tags="|bluetooth|adafruit|arduino-micro|atmega32u4|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18935" PostTypeId="1" AcceptedAnswerId="18936" CreationDate="2015-12-23T10:17:49.683" Score="2" ViewCount="679" Body="&lt;p&gt;I have arduino uno + ethernet shield + 9V/200mA adapter. I am trying to send some data with HTTP connection. When it's connected to USB it works perfectly, but when I plugged out USB, hangs (after less than a minute, it stops pinging).&lt;/p&gt;&#xA;&lt;p&gt;I have tried &lt;a href=&quot;http://forum.freetronics.com/viewtopic.php?t=176&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EthernetClient.cpp&#xA;&#xA;int EthernetClient::connect(IPAddress ip, uint16_t port) {&#xA;  if (_sock != MAX_SOCK_NUM)&#xA;    return 0; // i changed to -1  as suggested on previous link&#xA;&#xA;  for (int i = 0; i &amp;lt; MAX_SOCK_NUM; i++) {&#xA;    uint8_t s = socketStatus(i);&#xA;    if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT || s == SnSR::CLOSE_WAIT) {&#xA;      _sock = i;&#xA;      break;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and also example from library &lt;code&gt;Examples-library-WebClientRepeating&lt;/code&gt;, but I get the same problem as in my code.&#xA;Is my adapter too weak?&lt;/p&gt;&#xA;&lt;p&gt;This code is from Example WebClientRepeating:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED    };&#xA;&#xA;// fill in your Domain Name Server address here:&#xA;IPAddress ip(193, 77, 60, 66);&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;IPAddress gateway(193, 77, 60, 7);&#xA;IPAddress myDns(193, 77, 60, 213);&#xA;&#xA;EthernetClient client;&#xA;&#xA;char server[] = &amp;quot;www.arduino.cc&amp;quot;;&#xA;//IPAddress server(64,131,82,241);&#xA;&#xA;unsigned long lastConnectionTime = 0; // last time you connected to the server, in millisecond&#xA;const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds&#xA;// the &amp;quot;L&amp;quot; is needed to use long type numbers&#xA;&#xA;void setup() {&#xA;  // start serial port:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  // give the ethernet module time to boot up:&#xA;  delay(1000);&#xA;  // start the Ethernet connection using a fixed IP address and DNS server:&#xA;  Ethernet.begin(mac, ip, myDns, gateway, subnet);&#xA;&#xA;  // print the Ethernet board/shield's IP address:&#xA;  Serial.print(&amp;quot;My IP address: &amp;quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.write(c);&#xA;  }&#xA;&#xA;  // if ten seconds have passed since your last connection, then connect again and send data:      &#xA;  if (millis() - lastConnectionTime &amp;gt; postingInterval) {&#xA;    httpRequest();&#xA;  }    &#xA;}&#xA;&#xA;// this method makes a HTTP connection to the server:&#xA;void httpRequest() {&#xA;  // close any connection before send a new request.&#xA;  // This will free the socket on the WiFi shield&#xA;  client.stop();&#xA;&#xA;  // if there's a successful connection:&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&amp;quot;connecting...&amp;quot;);&#xA;    // send the HTTP PUT request:&#xA;    client.println(&amp;quot;GET /latest.txt HTTP/1.1&amp;quot;);&#xA;    client.println(&amp;quot;Host: www.arduino.cc&amp;quot;);&#xA;    client.println(&amp;quot;User-Agent: arduino-ethernet&amp;quot;);&#xA;    client.println(&amp;quot;Connection: close&amp;quot;);&#xA;    client.println();&#xA;&#xA;    // note the time that the connection was made:&#xA;    lastConnectionTime = millis();&#xA;  }&#xA;  else {&#xA;    // if you couldn't make a connection:&#xA;    Serial.println(&amp;quot;connection failed&amp;quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1:&lt;/strong&gt;&#xA;Also when I plug USB in its start working with 9V power adapter.&lt;/p&gt;&#xA;" OwnerUserId="14759" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-24T08:24:39.087" Title="Arduino hangs after less than a minute, but not on USB" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18936" PostTypeId="2" ParentId="18935" CreationDate="2015-12-23T11:03:50.377" Score="2" Body="&lt;p&gt;The problem is that when you are using the external 9V power supply, you are relying on the Arduino's on-board regulator to provide the 5V power supply to both the Arduino and the Ethernet shield. This regulator has very limited current capacity — much less than the 500 mA that's available from a PC's USB port — and you're overloading it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this problem, you should use a 5V plug pack with a USB connector to power your system.&lt;/p&gt;&#xA;" OwnerUserId="11306" LastActivityDate="2015-12-23T11:03:50.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18937" PostTypeId="1" AcceptedAnswerId="18939" CreationDate="2015-12-23T11:16:05.577" Score="3" ViewCount="4067" Body="&lt;p&gt;I'm attempting to read the values of 8 pins at a time into a byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The obvious answer to this seems to be the Port registers, however with the way the Arduino is wired, I'd have to split my read across two registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, I need a way to combine the lower 5 bits of PORTB with the upper 3 bits of PORTD into a single byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, this is the physical layout with the data lines I'm attempt to read/write to and their corresponding port assignments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             SCSI&#xA;DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0&#xA;|   |   |   |   |   |   |   |&#xA;PB4 PB3 PB2 PB1 PB0 PD7 PD6 PD5&#xA;            AVR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From what I can gather I need to use some shift operators to achieve this,&#xA;perhaps something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hi = PORTB &amp;amp; 3;&#xA;lo = PORTD &amp;gt;&amp;gt; 3; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I'm unsure if that's correct and then how I would combine them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to write a macro to make getting and setting this byte easier?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a good learning resource on bit manipulation like this?&lt;/p&gt;&#xA;" OwnerUserId="15797" LastActivityDate="2015-12-23T12:36:56.687" Title="Combine bits from two ports into a single byte" Tags="|programming|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18938" PostTypeId="2" ParentId="18935" CreationDate="2015-12-23T12:10:26.177" Score="1" Body="&lt;p&gt;It may be that, for some reason, the library thinks Serial communication is working, but when the buffer of unsent characters gets full, it hangs waiting to complete a Serial.print() or Serial.println().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, try commenting out all use of Serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  /*&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;Serial.println(...);&lt;/code&gt; to &lt;code&gt;// Serial.println(...);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might happen if the system is started with USB working, and then USB is unplugged.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastActivityDate="2015-12-23T12:10:26.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18939" PostTypeId="2" ParentId="18937" CreationDate="2015-12-23T12:19:36.150" Score="2" Body="&lt;p&gt;Assuming PORTB and PORTD are correctly giving unsigned char values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;result = (PORTB &amp;lt;&amp;lt; 3) | (PORTD&amp;gt;&amp;gt;5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a macro:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SCSIBITS ((PORTB &amp;lt;&amp;lt; 3) | (PORTD&amp;gt;&amp;gt;5))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use like this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;result = SCSIBITS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To make it clearer which specific bits are being used, write:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SCSIBITS (((PORTB &amp;amp; B00011111) &amp;lt;&amp;lt; 3) | ((PORTD &amp;amp; B11100000) &amp;gt;&amp;gt; 5)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It should be easier to see that the lower 5 bits of PORTB, and the upper 3 bits of PORTD are being used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the general case, where the values being manipulated are not unsigned char (should not be a problem in this specific case, but may be helpful to know), you might write:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SCSIBITS ((unsigned char)((PORTB &amp;amp; B00011111) &amp;lt;&amp;lt; 3) | ((PORTD &amp;amp; B11100000) &amp;gt;&amp;gt; 5)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SCSIBITS ((((unsigned char)PORTB &amp;amp; B00011111) &amp;lt;&amp;lt; 3) | (((unsigned char)PORTD &amp;amp; B11100000) &amp;gt;&amp;gt; 5)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are a few links to bit-manipulation tutorials:&lt;br&gt;&#xA;&lt;a href=&quot;https://www.hackerearth.com/notes/bit-manipulation/&quot; rel=&quot;nofollow&quot;&gt;https://www.hackerearth.com/notes/bit-manipulation/&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://www.cprogramming.com/tutorial/bitwise_operators.html&quot; rel=&quot;nofollow&quot;&gt;http://www.cprogramming.com/tutorial/bitwise_operators.html&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://www.tutorialspoint.com/ansi_c/c_bits_manipulation.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.tutorialspoint.com/ansi_c/c_bits_manipulation.htm&lt;/a&gt;  &lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2015-12-23T12:36:56.687" LastActivityDate="2015-12-23T12:36:56.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18940" PostTypeId="1" AcceptedAnswerId="18942" CreationDate="2015-12-23T13:23:31.513" Score="0" ViewCount="8258" Body="&lt;p&gt;Using ArduinoJson I have assigned a value such as;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* id = root[&quot;id&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the original JSON id was &quot;1&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (strcmp(id, &quot;1&quot;) == 0) {&#xA;    // this executes&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an array of structs that I wish to compare the id against. The struct looks like;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct  {&#xA;   char id[2];&#xA;   ....&#xA;} Device;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assign an id (1-9) into the struct id by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_cmd.id[0] = '0' + (++DevicesPtr);&#xA;_cmd.id[1] = '\0';&#xA;Devices[DevicesPtr-1] = _cmd;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where _cmd is of type Device. Devices is an array with up to 8 entries&#xA;Now I try to find a match in the devices using the JSON id&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (byte i = 0; i &amp;lt; DevicesPtr; i++) {&#xA;    if (strcmp(Devices[i].id, id) == 0) {&#xA;       // This code does not execute&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't seem to get a match I have also tried (Devices[i].id == id)&lt;/p&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2015-12-23T18:30:54.543" Title="Compare const char * to const char" Tags="|programming|c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18941" PostTypeId="2" ParentId="18026" CreationDate="2015-12-23T13:34:01.183" Score="0" Body="&lt;p&gt;I would start with this section: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (client.connect(server, 80)) {&#xA;  client.println(&quot;GET /rgb.php HTTP/1.1&quot;);&#xA;  client.println(&quot;Host: 192.168.1.151&quot;);&#xA;  client.println(&quot;Connection: close&quot;);&#xA;  client.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How many messages does the Arduino Ethernet library send for this block? Actually due to the implementation of the Arduino Print and EthernetClient class it sends 7 messages (no joke!). It does not collect this into a single message/frame. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first optimization is to print a single string and send that as one frame.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #define CR &quot;\r\n&quot;&#xA;&#xA;  client.print(&quot;GET /rgb.php HTTP/1.1&quot; CR&#xA;               &quot;Host: 192.168.1.151&quot; CR&#xA;               &quot;Connection: close&quot; CR&#xA;               CR);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-23T14:48:25.160" LastActivityDate="2015-12-23T14:48:25.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18942" PostTypeId="2" ParentId="18940" CreationDate="2015-12-23T13:41:58.413" Score="1" Body="&lt;p&gt;Try something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct  {&#xA;  char id[2];&#xA;  ....&#xA;} Device;&#xA;&#xA;const int DEVICES_MAX = 8;&#xA;Device Devices[DEVICES_MAX];&#xA;&#xA;for (int i = 0; i &amp;lt; DEVICES_MAX; i++) {&#xA;  Devices[i].id[0] = '1' + i;&#xA;  Devices[i].id[1] = 0;&#xA;  ...&#xA;}&#xA;&#xA;for (int i = 0; i &amp;lt; DEVICES_MAX; i++) {&#xA;  if (!strcmp(Devices[i].id, id)) {&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-23T14:46:23.597" LastActivityDate="2015-12-23T14:46:23.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18944" PostTypeId="1" AcceptedAnswerId="18948" CreationDate="2015-12-23T15:36:52.393" Score="3" ViewCount="1396" Body="&lt;p&gt;I have an Arduino Nano which is Powered by an external Power supply. This is connected with VIN and GND. The voltmeter says, there are &lt;code&gt;12,12 V&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some components connected on the 5V PIN, which altogether draw max. &lt;code&gt;100mA&lt;/code&gt;&#xA;Since some of the components are not working anymore, I started measuring...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have disconnected everything, but the Arduino Nano Power supply. (&lt;code&gt;12,12V&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I now measure GND and the 5V PIN, the Voltmeter says &lt;strong&gt;6,97V!&lt;/strong&gt; I guess this is why my components are giving up. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;But why are there &lt;code&gt;6,97 Volts&lt;/code&gt; all of the sudden? &lt;/li&gt;&#xA;&lt;li&gt;Is my Arduino broken now? &lt;/li&gt;&#xA;&lt;li&gt;Can I fix this?&lt;/li&gt;&#xA;&lt;li&gt;How can this happen?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="15493" LastEditDate="2015-12-23T15:50:06.480" LastActivityDate="2016-02-01T23:15:41.267" Title="Arduino Nano gives 7V on the 5V PIN!" Tags="|arduino-nano|voltage-level|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18946" PostTypeId="2" ParentId="18754" CreationDate="2015-12-23T17:47:16.623" Score="1" Body="&lt;p&gt;I've used an arduino with an &lt;a href=&quot;http://mostlyhighperformance.blogspot.com/p/irrigation.html?m=1&quot; rel=&quot;nofollow&quot;&gt;irrigation flow meter&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I'm getting accurate results, but I haven't checked against a bill. It can handle high flow, and the sensors will attach to any size pvc line. The sensor are a bit expensive, however. $150 for the sensor and $35 for the T junction that it plugs into. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as you are living in an apartment, you'll probably need a non-invasive sensor. Perhaps an acoustic one. &lt;/p&gt;&#xA;" OwnerUserId="10437" LastActivityDate="2015-12-23T17:47:16.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18947" PostTypeId="2" ParentId="18940" CreationDate="2015-12-23T18:30:54.543" Score="1" Body="&lt;p&gt;You can't compare a char and a string.. How can you compare apples and bananas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you have two ways to do your job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) do as @Mikael Patel suggests, so convert your &lt;code&gt;id&lt;/code&gt;s into strings. This is fine because it will allow you to deal with multiple chars ids.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) a more efficient way to do this (note that this works with just SINGLE CHARS IDS) is the following one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (strlen(id) == 1) {&#xA;    for (byte i = 0; i &amp;lt; DevicesPtr; i++) {&#xA;        if (Devices[i].id == id[0]) {&#xA;           // This code will execute if ids match&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that id should be exactly 1 char long, otherwise the whole comparison as you thought is meaningless&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this solution you don't need multibyte id char in the struct definition, so you can just define&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct  {&#xA;   char id;&#xA;   ....&#xA;} Device;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and, in the code, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_cmd.id = '0' + (++DevicesPtr);&#xA;Devices[DevicesPtr-1] = _cmd;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2015-12-23T18:30:54.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18948" PostTypeId="2" ParentId="18944" CreationDate="2015-12-23T19:51:41.943" Score="3" Body="&lt;p&gt;Of course the 5V regulator on the nano can be faulty. Another possibility is the 5V decoupling capacitor. If it goes open circuit the regulator will oscillate and the mean output voltage will be near half the input voltage. Most regs have a minimum decoupling cap value specified.&lt;/p&gt;&#xA;" OwnerUserId="7991" LastActivityDate="2015-12-23T19:51:41.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18949" PostTypeId="1" CreationDate="2015-12-23T22:08:17.480" Score="2" ViewCount="1230" Body="&lt;p&gt;I ran into some strange problems while trying to send data from my Node.js Server to my Arduino. My goal is to transfer an &lt;code&gt;Int&lt;/code&gt; to the Arduino Nano and display it on a LCD. So far I managed to connect the server with the Arduino with the help of the &lt;a href=&quot;https://github.com/voodootikigod/node-serialport&quot; rel=&quot;nofollow noreferrer&quot;&gt;serial library&lt;/a&gt;. The Arduino returns all data sent to it via Serial and prints it bytewise to the LCD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Node.js always opens the port, but is only able to send and receive data when the Serial Monitor from the Arduino IDE is opened.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Data Node.js is sending seems to have a special format or gets transformed during the Process. If I send a simple &lt;code&gt;int&lt;/code&gt; like 2, the display shows a y and an undecipherable character, and the data returned looks like this:  49 50 49 13 10 48 13 10. I noticed that the amount of 13 corresponds with the &lt;code&gt;int&lt;/code&gt; I send (3 send = three 13's come back). When I enter data into Arduinos own Serial Monitor, it is displayed correctly and returned as ASCII (because I am saving the return value of &lt;code&gt;Serial.read()&lt;/code&gt; as an &lt;code&gt;Int&lt;/code&gt;). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's my server (the relevant parts): &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;http = require('http');&#xA;fs = require('fs');&#xA;serialport = require('serialport');&#xA;&#xA;port = 3000;&#xA;host = '127.0.0.1';&#xA;SerialPort = serialport.SerialPort;&#xA;arduinoPort = '/dev/ttyUSB2';&#xA;&#xA;var printLog = true;&#xA;var playerRoundKills = 0;&#xA;var playerTotalKills;&#xA;var roundLive = false;&#xA;&#xA;//open port&#xA;var myPort = new SerialPort(arduinoPort);&#xA;parser: serialport.parsers.raw          //rohdatenparser definieren&#xA;serialport.on('open', function(){&#xA;  console.log('Serial Port Opend');&#xA;  serialport.on('data', function(data){&#xA;      console.log(data[0]);&#xA;  });&#xA;});&#xA;&#xA;//implementation of abstract port functions&#xA;myPort.on('open', showPortOpen);&#xA;myPort.on('data', sendSerialData);&#xA;myPort.on('close', showPortClose);&#xA;myPort.on('error', showError);&#xA;&#xA;function showPortOpen() {&#xA;   console.log('port open. Data rate: ' + myPort.options.baudRate);&#xA;}&#xA;&#xA;//output incoming data&#xA;function sendSerialData(data) {&#xA;   console.log(data[0]);&#xA;if(typeof data[1] !== 'undefined') console.log(data[1]);&#xA;}&#xA;&#xA;function showPortClose() {&#xA;   console.log('port closed.');&#xA;}&#xA;&#xA;function showError(error) {&#xA;   console.log('Serial port error: ' + error);&#xA;}&#xA;&#xA;myPort.on(&quot;open&quot;, function () {&#xA;  console.log('open');&#xA;//send data (3) to arduino&#xA;myPort.write(3, function(err, results) {&#xA;    if(err != null)console.log('Fehler beim ersten senden: ' + err);&#xA;    if(results != null)console.log(&quot;Killcount erstmals gesendet: &quot;+results);&#xA;  });&#xA;});&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;//LDCD Display&#xA;LiquidCrystal lcd(9, 8, 6, 5, 4, 3);  //Digitale Pins an dem das Display angeschlossen ist&#xA;#define LCD_WIDTH 16                    //Anzahl Spalten des Display (16)&#xA;#define LCD_HEIGHT 2                    //Anzahl Zeilen des Display (2)&#xA;&#xA;&#xA;&#xA;#define DEBUG_MODE true        &#xA;&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(9600);  &#xA;  byte i;&#xA;&#xA;  lcd.begin(LCD_WIDTH, LCD_HEIGHT,1);&#xA;&#xA;  lcd.setCursor(0,0);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // when characters arrive over the serial port...&#xA;  if (Serial.available()) {&#xA;&#xA;    //clear display for new killcount&#xA;    //lcd.clear();&#xA;    // wait a bit for the entire message to arrive&#xA;    delay(100);&#xA;    // read all the available characters&#xA;    while (Serial.available() &amp;gt; 0) {&#xA;      // write each character to display as ascii&#xA;    int temp = Serial.read();&#xA;    lcd.write(temp);&#xA;    Serial.println(temp);&#xA;&#xA;    } &#xA;    //Serial.flush();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate any suggestions! =)&lt;/p&gt;&#xA;" OwnerUserId="15814" LastEditorUserId="37523" LastEditDate="2019-07-24T09:03:47.647" LastActivityDate="2019-07-24T09:03:47.647" Title="Serial Communication to Arduino with Node.js" Tags="|serial|node.js|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="18950" PostTypeId="2" ParentId="18855" CreationDate="2015-12-23T22:19:17.183" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I wonder if there is another pin on the board I could read&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I guess that would depend on the particular doorbell. The transmitter must send some representation of a button press to the receiver - a pulse train for the duration of the press, or perhaps just CW: carrier on, carrier off - which the receiver somehow passes on to trigger the audio. Look at the receiver's output side to identify that trigger signal and pass it, or a processed version of it, to the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-12-24T13:29:23.680" LastActivityDate="2015-12-24T13:29:23.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18951" PostTypeId="1" AcceptedAnswerId="18961" CreationDate="2015-12-23T23:26:14.357" Score="0" ViewCount="1383" Body="&lt;p&gt;I'd like to build a &quot;low fidelity&quot; spectrum analyzer to run on an Adafruit Trinket Pro. My primary goal is to intrigue my seven year-old niece with something that can be hacked. The plan is to pick up sound from a violin with a mic and use a set of 5 or 6 NeoPixels to represent octaves and use color for amplitude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first pass at this used &lt;a href=&quot;http://www.instructables.com/id/Arduino-Frequency-Detection&quot; rel=&quot;nofollow&quot;&gt;Amanda Ghassaei's frequency detection code&lt;/a&gt;. It kind of worked, but seemed to be having problems with complex waveforms. After doing some more reading and looking at simple spectrum analyzers it seems that I'd do better using something like a FFT to collect the frequency information. It also seems that that might be stretching the capability of an Arduino…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any FFT libraries that run well on the Arduino (over a range of about 200 to 4000 Hz)? Or are there other approaches that might work better?&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-24T10:39:32.347" Title="FFT (or similar) library for the Arduino" Tags="|signal-processing|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18952" PostTypeId="1" CreationDate="2015-12-24T00:01:47.573" Score="2" ViewCount="1622" Body="&lt;p&gt;I am planning to make an SMS notification to my phone with Arduino Uno via a push of a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Uno C520A Embedded System. Is it possible to do so with this model ? If yes, which WIFI module should I get ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to make an API request to the web through the push of a button.&lt;/p&gt;&#xA;" OwnerUserId="15817" LastActivityDate="2016-01-23T12:13:58.633" Title="How to make an SMS notification to my phone with Arduino Uno?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18953" PostTypeId="2" ParentId="18952" CreationDate="2015-12-24T00:32:37.713" Score="1" Body="&lt;p&gt;It is possible if your provider has a sms gateway e-mail-address. Just google which it is for your provider (e.g. number@tmomail.net for T-Mobile (US)). And there should be a lot of tutorial about how to send an email with an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every wifi-module with arduino support will work if your WiFi is a standart 3.6Ghz. And yes it should work with any arduino compatible microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="15779" LastActivityDate="2015-12-24T00:32:37.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18954" PostTypeId="1" AcceptedAnswerId="20112" CreationDate="2015-12-24T01:03:09.773" Score="4" ViewCount="1031" Body="&lt;p&gt;Apologies if this is the wrong sub-forum, the involvement of ATTiny and arduino places this into a strange category. Please correct me if I should post elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is important for this to be a library as small kids will be using this program and hardware for their own projects. Its kind of a rip on the LOLshield but it involves a lot more steps to integrate more lessons all at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My whole program takes 8 bytes of information and converts it to data for a shift register driving two multiplexers all driving an 8x8 LED matrix. It can also use multiple of these packets to make a slide show. I have it in a working state right now and would like to turn it into a library for easy use. I am a bit lost in this step as I had to create an interrupt timer and this makes it more complicated than the tutorial on the arduino website covers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if someone could point me to a library for ATTiny85 that makes calling a timer interrupt easy then the rest of this project will likewise become easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great! I will be continuing to look on online resources and will update should I figure it out.&lt;/p&gt;&#xA;" OwnerUserId="15818" LastActivityDate="2016-01-30T01:36:27.673" Title="Creating a library for attiny85 out of working program" Tags="|library|attiny|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18955" PostTypeId="1" AcceptedAnswerId="20796" CreationDate="2015-12-24T01:15:03.937" Score="2" ViewCount="2829" Body="&lt;p&gt;I'm new to MIDI and started playing with an Arduino Leonardo and &lt;a href=&quot;https://github.com/rkistner/arcore&quot; rel=&quot;nofollow&quot;&gt;arcore&lt;/a&gt;.&#xA;Based on the example code, I can easily send &lt;code&gt;noteOn/noteOff/controlChange&lt;/code&gt; messages, but I can't seem to send a pitch bend message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having a look at &lt;a href=&quot;http://www.onicos.com/staff/iz/formats/midi-event.html&quot; rel=&quot;nofollow&quot;&gt;this table&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0xE0    Chan 1 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE1    Chan 2 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE2    Chan 3 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE3    Chan 4 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE4    Chan 5 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE5    Chan 6 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE6    Chan 7 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE7    Chan 8 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE8    Chan 9 Pitch wheel range    Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xE9    Chan 10 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xEA    Chan 11 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xEB    Chan 12 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xEC    Chan 13 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xED    Chan 14 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xEE    Chan 15 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;    0xEF    Chan 16 Pitch wheel range   Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried to send a message like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MIDIEvent pitchwheel = {0xe0, 127,127};&#xA;MIDIUSB.write(pitchwheel);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this didn't work and I'm not sure what I'm missing/doing wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any hints/tips will be helpful.&lt;/p&gt;&#xA;" OwnerUserId="3505" LastActivityDate="2016-02-17T17:43:55.297" Title="How to send a pitch bend MIDI message using arcore?" Tags="|arduino-leonardo|midi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18956" PostTypeId="2" ParentId="18931" CreationDate="2015-12-24T01:44:24.720" Score="4" Body="&lt;p&gt;I've also had good results with using the &lt;a href=&quot;https://mchr3k.github.io/arduino-libs-manchester/&quot; rel=&quot;nofollow&quot;&gt;Mchr3k - Arduino Manchester Encoding&lt;/a&gt; library with those 315mhz RF kits. It has support for ATTiny85 as well.&lt;/p&gt;&#xA;" OwnerUserId="15819" LastActivityDate="2015-12-24T01:44:24.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18957" PostTypeId="2" ParentId="18855" CreationDate="2015-12-24T02:08:47.623" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I wonder if there is another pin on the board I could read&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could try to hook up a multimeter to the pins/leads from the doorbell button. Positive to doorbell button pin, negative to power supply ground/doorbell battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you figure out which pin has voltage when the doorbell button is pressed, you can have that go into a digital or analog input in the Arduino. Make sure that the ground from the doorbell PCB and the Arduino are connected so that they'll have common ground and it should be detectable.&lt;/p&gt;&#xA;" OwnerUserId="15819" LastActivityDate="2015-12-24T02:08:47.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18958" PostTypeId="1" CreationDate="2015-12-24T06:36:28.260" Score="5" ViewCount="4892" Body="&lt;p&gt;I got the 3.95&quot; LCD from aliexpress which uses IL9488. I used the &lt;a href=&quot;https://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865&quot; rel=&quot;nofollow&quot;&gt;MCUFRIEND_kbv&lt;/a&gt; library. I am using an Arduino Mega as I need other GPIO to be used for other purposes. I can't use the Uno because of this limitation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have other modules like the DS3231, and ESP8266 connected to the Mega and this 3.95&quot; LCD connected as well. ESP8266 is powered separately using a 12-5V converted supply. The Mega is powered using another source. The normal graphics test is working in the LCD. I am able to make it work with the Nano, Uno and Mega. Even for the Mega I am able to write customized messages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I intend to do is to update the time in the LCD which is received from the DS3231. It updates the LCD but I see a flickering issue here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every update (LCD display function is from the loop which sets the text when there is a second/time/hour difference in the time) seems like it draining more current as the one of the LED connected to Mega dims, the Rx/Tx LEDs also dim. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to get the LCD refreshed but it shows a flickering. I powered the LCD 3.3V and 5V using another separate source but still the small flickering continues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover all these time I was connected to the Mega through the USB from the laptop. Once I unplug the USB, LCD starts and shows some update and again become white. This continues and an not able to see anything on LCD there after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure why only when the Mega is connected to USB this LCD works and that too flickering but once the USB is removed the LCD is not working at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please do help me in this ?&lt;/p&gt;&#xA;" OwnerUserId="15823" LastEditorUserId="6936" LastEditDate="2016-01-04T19:40:10.963" LastActivityDate="2016-05-18T01:40:54.960" Title="3.95 MCU Friend Arduino TFT LCD flickering" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18959" PostTypeId="1" AcceptedAnswerId="19242" CreationDate="2015-12-24T09:41:29.290" Score="9" ViewCount="10664" Body="&lt;p&gt;I just received an Arduino 101 so I did the following in a wave of excitement...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connected the USB cable between it and my Macbook Pro&lt;/li&gt;&#xA;&lt;li&gt;Started the Arduino IDE version &lt;code&gt;1.6.7&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Wrote a little bit of code&lt;/li&gt;&#xA;&lt;li&gt;Selected &lt;code&gt;Tools | Boards | Boards Manager...&lt;/code&gt; and installed the &lt;code&gt;Intel Curie Boards&lt;/code&gt; as per &lt;a href=&quot;https://www.arduino.cc/en/Guide/Arduino101&quot;&gt;Getting Started&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Selected &lt;code&gt;Tools | Board: &quot;Arduino 101&quot;&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Selected &lt;code&gt;Tools | port: &quot;/dev/cu.usbmodemFA141 (Arduino 101)&quot;&lt;/code&gt; &lt;/li&gt;&#xA;&lt;li&gt;Selected &lt;code&gt;Sketch | Upload&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I was expecting something amazing, but I got the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting upload script&#xA;Payload: /var/folders/jr/5rmqcrqj58103d4p1f6_3sjr0000gn/T/build7c6ce067b9e8a57f9917c651ec494989.tmp/orientation.ino.bin&#xA;Waiting for device... &#xA;ERROR: Timed out waiting for Arduino 101.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there anything I can do to debug this or did I miss a step perhaps?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I tried the good ol' turn it off and on again, including shutting the IDE down).&lt;/p&gt;&#xA;" OwnerUserId="15828" LastEditorUserId="15828" LastEditDate="2015-12-24T11:44:58.997" LastActivityDate="2022-04-28T13:29:19.420" Title="ERROR: Timed out waiting for Arduino 101 - anything I can do?" Tags="|arduino-ide|uploading|mac-os|" AnswerCount="7" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18960" PostTypeId="2" ParentId="18952" CreationDate="2015-12-24T10:33:37.253" Score="1" Body="&lt;p&gt;Arduino uno is only the processor, you will need a Ethernet shield or Wifi shield to connect to the internet.&#xA;I would suggest Ethernet as it is less pain to configure and no drop of connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you will need to buy a sms gateway, &lt;a href=&quot;http://www.smsglobal.com/http-api/&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; looks pretty cool as they have good http api.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using the Arduino Ethernet sample, you will need to send a http request to the server when the button has been pressed.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-12-24T10:33:37.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18961" PostTypeId="2" ParentId="18951" CreationDate="2015-12-24T10:39:32.347" Score="1" Body="&lt;p&gt;I havent used any of the libraries to make the FFT for my personal project, due to complexity. Instead I bought a spectrum chip, which returns 7 frequencies: MSGEQ7  ( 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and&#xA;16kHz ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise if you are very keen on using a library, &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; is very famous and fast for Arduino processors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But again, if you dont need to have a precise band and the MSGEQ7 is good enough to detect what you want, go for it. &lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2015-12-24T10:39:32.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18962" PostTypeId="2" ParentId="18934" CreationDate="2015-12-24T10:43:11.430" Score="1" Body="&lt;p&gt;I have started to look at the Arduino Uno schematics, which are free on the website. To make an Arduino is very simple, just need the chip, crystal, a few capacitors and that's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to copy the same schematics then add the Bluetooth to the RX and TX pins, but be careful about the 3.3V as you don't want to fry your Bluetooth module :)&lt;/p&gt;&#xA;" OwnerUserId="13940" LastEditorUserId="4628" LastEditDate="2015-12-24T17:04:32.220" LastActivityDate="2015-12-24T17:04:32.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18963" PostTypeId="1" AcceptedAnswerId="18970" CreationDate="2015-12-24T13:37:20.007" Score="3" ViewCount="7246" Body="&lt;p&gt;In our college we are using a module developed by IIT Bombay (called FIREBIRD V[ver 5]). It has ATmega2560 and ATmega8 microcontrollers (master and slave) with bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The staff uses AVR Studio for programming. But since AVR Studio is supported only on Windows (and I have a Mac), I was looking for AVR programming in Mac. I downloaded Crosspack AVR. But I don't know how to proceed after this point. Also I downloaded TextWrangler (because I was told auto-suggestion is not available in TextEdit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I have downloaded the Arduino IDE, and I don't know what is required or how to configure it to program AVR microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched on the web and nothing is clear (mostly they all depend on something to do with terminal and the command line).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have Xcode installed in my Mac (I saw a relatively easy tutorial on how to set up Xcode for this purpose) and the file is 4GB. I am trying to work around using Xcode, but if it's the only nice way do let me know!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pertinent suggestions would be helpful.&lt;/p&gt;&#xA;" OwnerUserId="11957" LastEditorUserId="11957" LastEditDate="2015-12-26T22:39:29.080" LastActivityDate="2015-12-26T22:39:29.080" Title="How to program AVR in Mac OS X?" Tags="|avr|mac-os|avr-toolchain|" AnswerCount="2" CommentCount="11" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18965" PostTypeId="2" ParentId="18963" CreationDate="2015-12-24T14:38:15.090" Score="3" Body="&lt;p&gt;If you don't want to use the Terminal and the command line, the Arduino IDE is your best option. Get yourself an AVR programmer (or an Arduino Uno to serve as programmer, with the ArduinoISP sketch uploaded), and code on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L1uCn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L1uCn.png&quot; alt=&quot;ArduinoISP sketch to upload to the Arduino serving as AVR programmer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then connect your Arduino to your module via SPI. Select the correct processor and port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JXf9N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JXf9N.png&quot; alt=&quot;Select Processor and Port&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can now upload the sketch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iuvbk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iuvbk.png&quot; alt=&quot;Upload sketch via Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4628" LastActivityDate="2015-12-24T14:38:15.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18966" PostTypeId="1" CreationDate="2015-12-24T15:22:16.810" Score="0" ViewCount="848" Body="&lt;p&gt;I've tried a pretty standard code but the Serial Monitor yields zero response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a standard Arduino Uno (tried a second one as well, just to be sure) and am now trying the second shield with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(2, 3); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  Serial. begin(9600);&#xA; mySerial.begin(9600);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;  if (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is nothing coming back whatsoever in the serial monitor (yep, I checked the baud rate and tried several others).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I be seeing if anything?&lt;/p&gt;&#xA;" OwnerUserId="15836" LastActivityDate="2016-06-30T20:07:15.703" Title="How do I get the Itead 3G shield to work?" Tags="|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18967" PostTypeId="2" ParentId="18966" CreationDate="2015-12-24T15:44:36.260" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What should I be seeing if anything?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Usually, a GSM module will not send (unsollicited) messages. Everything it sends will be an response to an received message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try sending &lt;code&gt;AT&lt;/code&gt; (with a new line/carriage return (depending on the GSM module)) to the GSM module, it will send something like &lt;code&gt;AT OK&lt;/code&gt; or just &lt;code&gt;OK&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you didn't set the pin directions (output/input), might be doen by the serial libraries, but beter be safe if you're not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check your wiring (jumpers on UART multiplexer in this case?) and share it with us, Rx/Tx wiring often gets messed up :)&#xA;If your GSM module has a USB connection, you might even test it with a terminal (taking out the Arduino in the middle, thus any wiring/code between.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also suggest you change the name of the serial connection to the GSM to something like &lt;code&gt;gsmSerial&lt;/code&gt; rather than mySerial (which could be anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure the 3G shield has enough power (amperes), otherwise they might reset when attempting to make an connection.&#xA;(Put the external supply in the Arduino, rather than USB powered)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2015-12-24T15:55:56.613" LastActivityDate="2015-12-24T15:55:56.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18970" PostTypeId="2" ParentId="18963" CreationDate="2015-12-24T17:56:48.707" Score="3" Body="&lt;p&gt;First, install and get familiar with version 1.6.x of the Arduino IDE. Then, under the sketchbook directory, within &lt;code&gt;hardware/nex/avr/&lt;/code&gt; (create the directories if they don't exist) create the following files:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;boards.txt:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# NEX Robotics Fire Bird V&#xA;# Only ATmega2560@14.7456MHz supported for now&#xA;&#xA;nexfirebirdv2560m14.name=Fire Bird V ATMEGA2560 @ 14.7456 MHz&#xA;nexfirebirdv2560m14.upload.tool=avrdude&#xA;nexfirebirdv2560m14.upload.protocol=avr109&#xA;nexfirebirdv2560m14.upload.maximum_size=129024&#xA;nexfirebirdv2560m14.upload.maximum_data_size=8192&#xA;nexfirebirdv2560m14.upload.speed=115200&#xA;nexfirebirdv2560m14.bootloader.low_fuses=0xFF&#xA;nexfirebirdv2560m14.bootloader.high_fuses=0xDA&#xA;nexfirebirdv2560m14.bootloader.extended_fuses=0xFD&#xA;nexfirebirdv2560m14.build.mcu=atmega2560&#xA;nexfirebirdv2560m14.build.f_cpu=14745600L&#xA;nexfirebirdv2560m14.build.core=arduino:arduino&#xA;# This is not the real variant, but it will get the board running&#xA;nexfirebirdv2560m14.build.variant=arduino:mega&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;platform.txt:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name=NEX Robotics Fire Bird V&#xA;version=0.0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have verified that an empty sketch will build, but do not have the hardware to test uploading. The &lt;code&gt;upload.protocol&lt;/code&gt; value may need to be changed to &lt;code&gt;avr910&lt;/code&gt; or &lt;code&gt;arduino&lt;/code&gt; if the current value doesn't work. Make sure to restart the IDE after any changes to the configuration files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further improvements that can be done include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A real variant for the specific board&lt;/li&gt;&#xA;&lt;li&gt;Support for the on-board ATmega8 (for now just use one of the slave firmwares uploaded with avrdude)&lt;/li&gt;&#xA;&lt;li&gt;Support for the other AVR boards&lt;/li&gt;&#xA;&lt;li&gt;Support for the 8051 and ARM boards&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-24T17:56:48.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18971" PostTypeId="1" AcceptedAnswerId="18972" CreationDate="2015-12-24T19:42:16.147" Score="2" ViewCount="473" Body="&lt;p&gt;I have a project where I use 22 servos. I attach all 22 of the servos in the setup and in the loop, I use &lt;code&gt;myservo.write()&lt;/code&gt; command to make a particular servo move to a particular position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that, all the other servos become stiff at this point of time, even though I am not writing any value to those servos. By stiff I mean that the servo is holding at a particular random value. Which for most of the 22 servos is at or near 90°. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I make a particular servo move, while allowing all the other servos to freely rotate. I think that when I attach a servo the program prevents the free rotation of the servo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if the signal to one of the servos is leaking to other servos because of an issue with wiring, but this is not the case. The other servos become stiff only when I attach them to the pins which have been &quot;attached&quot; as a servo in the program. &lt;/p&gt;&#xA;" OwnerUserId="15839" LastEditorUserId="6936" LastEditDate="2016-01-02T19:36:03.707" LastActivityDate="2016-01-02T19:36:03.707" Title="Arduino Servo Free Rotation" Tags="|arduino-mega|arduino-ide|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18972" PostTypeId="2" ParentId="18971" CreationDate="2015-12-24T20:01:39.710" Score="0" Body="&lt;p&gt;When you &lt;code&gt;attach&lt;/code&gt; a servo the Arduino starts generating the PWM waveform for its currently selected angle. When you &lt;code&gt;write&lt;/code&gt; to the servo you just change the current angle and the waveform changes to match. That waveform is constantly being generated from the moment the servo is attached, and will always be generated.  That is how servos work.  They are not really designed to be back-driven by the load turning the cogs - it is the role of the servo to do the driving, not to be driven.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the servo you might actually damage the mechanics by driving it backwards like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way you can stop the servo from being actively driven is to detach the pin from the servo system so that it doesn't think there is a servo there any more.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-24T20:01:39.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18974" PostTypeId="1" CreationDate="2015-12-24T20:34:06.457" Score="5" ViewCount="3968" Body="&lt;p&gt;I'm having some programming problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's what's happening:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my .ino file, I have a &lt;code&gt;tft&lt;/code&gt; variable which holds the connection to a LCD. I want to make a class which can either automatically access that &lt;code&gt;tft&lt;/code&gt; class contained in the .ino, or pass it into the constructor when it's created; so basically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// assuming this is the .ino:&#xA;&#xA;TFT_ILI9163C tft = TFT_ILI9163C(cs, dc, rst);&#xA;&#xA;&#xA;MenuClass *menu = MenuClass();&#xA;menu-&amp;gt;init(&quot;Example&quot;, tft); // this should work and &quot;menu&quot; should now have access to the &quot;tft&quot; variable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's my Menu.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Menu class&#xA;&#xA;#include &quot;Menu.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;TFT_ILI9163C.h&amp;gt;&#xA;&#xA;String menName = &quot;Unnamed&quot;;&#xA;&#xA;void MenuClass::init(const String name) &#xA;{&#xA;    menName = name;&#xA;}&#xA;&#xA;String MenuClass::getName() {&#xA;    return menName;&#xA;}&#xA;&#xA;void MenuClass::draw() {&#xA;    tft.setCursor(2, 2);&#xA;    tft.print(menName);&#xA;}&#xA;&#xA;MenuClass Menu;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15840" LastEditorUserId="6936" LastEditDate="2016-01-06T03:16:08.107" LastActivityDate="2016-01-06T03:16:08.107" Title="Basic C++ programming, how to pass constructor argument into class?" Tags="|c++|arduino-ide|atmega32u4|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18975" PostTypeId="1" AcceptedAnswerId="19853" CreationDate="2015-12-24T20:35:28.767" Score="1" ViewCount="159" Body="&lt;p&gt;I found out that the arduino M0 pro R3 needs either micro HDMI or micro USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I don't have any micro USB or HDMI adapters, can I use the Samsung galaxy USB/micro adapter to connect?&lt;/p&gt;&#xA;" OwnerUserId="15841" LastActivityDate="2016-01-22T20:23:23.897" Title="Can I use my phone's charger to connect arduino M0 pro R3 with computer?" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="18977" PostTypeId="2" ParentId="8511" CreationDate="2015-12-24T22:41:01.343" Score="7" Body="&lt;p&gt;The safe way (i tested it).&#xA;First connect to 3.3V USB-TTL output first (also 5V Mini can work with 3.3V).&#xA;Now prepare this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);&#xA;  delay(10000);&#xA;  digitalWrite(13, LOW);&#xA;  delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Choose &quot;Arduino Pro/Mini&quot; with 5v/16MHz board and upload sketch.&#xA;If you see that the blinking is correct (10 sec ON/10sec OFF) - you have 5V/16MHz Arduino. Otherwise it will blink at 5 sec intervals instead of 10 sec.&lt;/p&gt;&#xA;" OwnerUserId="15845" LastActivityDate="2015-12-24T22:41:01.343" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="18978" PostTypeId="1" CreationDate="2015-12-24T23:00:32.117" Score="0" ViewCount="113" Body="&lt;pre&gt;&lt;code&gt;void fn( int pin, int pos)&#xA;{&#xA;    Servo temp;&#xA;    temp.attach(pin);&#xA;    temp.write(pos);&#xA;    delay(15); &#xA;    temp.detach();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int pos = 0 ; &#xA;    for (pos = 0; pos &amp;lt;= 180; pos += 1) { // goes from 0 degrees to 180 degrees&#xA;        // in steps of 1 degree&#xA;        //tmp2.write(pos);&#xA;        //delay(15);&#xA;        fn(41,pos);&#xA;        fn(2,180 - pos);   &#xA;    }&#xA;    for (pos = 180; pos &amp;gt;= 0; pos -= 1) { // goes from 180 degrees to 0 degrees&#xA;        fn(41,pos);&#xA;        fn(2,180 - pos);&#xA;    }    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I run the code in mega , the servo does not move when attached to pin 2 or 41. &#xA;The reason I am creating a function fn , is so that the servo does not stay attached. I want the servo to rotate freely when I am not giving it a pwm signal. &lt;/p&gt;&#xA;" OwnerUserId="15839" LastEditorUserId="7389" LastEditDate="2016-01-08T16:38:14.077" LastActivityDate="2016-01-08T16:38:14.077" Title="Could you tell me what is wrong with this Arduino code?" Tags="|arduino-mega|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18979" PostTypeId="2" ParentId="18974" CreationDate="2015-12-24T23:17:30.917" Score="2" Body="&lt;p&gt;Assuming you want to require every instance of MenuClass should be associated with a TFT_ILI9163C display object, you could use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MenuClass.h&#xA;&#xA;class TFT_ILI9163C; // declare a class name which is defined in TFT_ILI9163C.h&#xA;&#xA;class MenuClass&#xA;{&#xA;  private:&#xA;    // read-only private member initialized by constructor&#xA;    // (the m_ prefix is commonly used to denote class member values)&#xA;    TFT_ILI9163C* m_tft;&#xA;&#xA;  public:&#xA;    // constructor&#xA;    MenuClass(TFT_ILI9163C* pTft) : m_tft(pTft) {};&#xA;&#xA;  private:&#xA;    // private storage for the Name property&#xA;    String m_Name;&#xA;  public:&#xA;    // read the Name property&#xA;    String getName() {&#xA;      return m_Name;&#xA;    };&#xA;  public:&#xA;    // write the Name property&#xA;    void setName(String value) {&#xA;      m_Name = value;&#xA;    };&#xA;&#xA;  public:&#xA;    void draw() {&#xA;      // the m_tft member is a reference to the display class&#xA;      m_tft-&amp;gt;setCursor(2, 2);&#xA;      m_tft-&amp;gt;print(m_Name);&#xA;    };&#xA;}&#xA;MenuClass Menu;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that there is only one constructor, and it requires a pointer to the TFT_ILI9163C display. The body of the constructor &lt;code&gt;: m_tft(pTft) {};&lt;/code&gt; initializes the private member &lt;code&gt;m_tft&lt;/code&gt; with the constructor argument &lt;code&gt;pTft&lt;/code&gt;, so  MenuClass member functions invoke TFT functions as &lt;code&gt;m_tft-&amp;gt;fn(args);&lt;/code&gt;  Since there is no &quot;void constructor&quot; &lt;code&gt;MenuClass(void)&lt;/code&gt;, &lt;code&gt;m_tft&lt;/code&gt; is effectively guaranteed to point to a valid TFT_ILI9163C instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it looks like you were using &lt;code&gt;menName&lt;/code&gt; kind of like a class property, I rewrote that in the more commonly used m_propertyname style. Your &lt;code&gt;MenuClass::init()&lt;/code&gt; was behaving like a name property setter; I'm not sure whether menu initialization requires anything else. This simple example has class MenuClass defined entirely inside the header file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usage is pretty similar to your example code, except now the MenuClass constructor requires a pointer to a previously constructed TFT_ILI9163C display instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Main application&#xA;#include &amp;lt;TFT_ILI9163C.h&amp;gt;&#xA;#include &quot;MenuClass.h&quot;&#xA;// ... etc ...&#xA;&#xA;// the TFT_ILI9163C display instance&#xA;TFT_ILI9163C tft = TFT_ILI9163C(cs, dc, rst);&#xA;&#xA;// an example menu that draws on the display&#xA;MenuClass *menuFoo = new MenuClass(&amp;amp;tft); // use new to get pointer to new class instance&#xA;// MenuClass *menuFoo = MenuClass(&amp;amp;tft); // cannot convert 'MenuClass' to 'MenuClass*' in initialization&#xA;&#xA;void setup() {&#xA;  // an example menu that draws on the display&#xA;  menuFoo-&amp;gt;setName(&quot;Example&quot;);&#xA;  menuFoo-&amp;gt;draw();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you wanted to pass the constructor an initial Name property value as well as the tft display pointer, you could define the constructor as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  public:&#xA;    // constructor&#xA;    MenuClass(TFT_ILI9163C* pTft, String name) : m_tft(pTft), m_Name(name) {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even go a step further, and give the name argument a default value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  public:&#xA;    // constructor&#xA;    MenuClass(TFT_ILI9163C* pTft, String name = &quot;Unnamed&quot;) : m_tft(pTft), m_Name(name) {};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So with this modification, the expression &lt;code&gt;MenuClass(&amp;amp;myTFT)&lt;/code&gt; is the same as the expression &lt;code&gt;MenuClass(&amp;amp;myTFT, &quot;Unnamed&quot;)&lt;/code&gt;, but you can still override the default value like &lt;code&gt;MenuClass(&amp;amp;myTFT, &quot;DoSomething&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also perfectly legal to put statements inside the &lt;code&gt;{ }&lt;/code&gt; block of the constructor, but in this example all of the work is accomplished by the &lt;code&gt;:memberName(value)&lt;/code&gt; constructor syntax.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: &lt;code&gt;MenuClass *menuFoo = new MenuClass(&amp;amp;tft);&lt;/code&gt; thanks @BrettAM&lt;/p&gt;&#xA;" OwnerUserId="7174" LastEditorUserId="7174" LastEditDate="2015-12-24T23:33:56.097" LastActivityDate="2015-12-24T23:33:56.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18980" PostTypeId="2" ParentId="18978" CreationDate="2015-12-25T00:03:52.963" Score="2" Body="&lt;p&gt;Arrange your code like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo servo1, servo2;&#xA;&#xA;void setup() {&#xA;    servo1.attach(41);&#xA;    servo2.attach(2);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int pos;&#xA;&#xA;    for (pos = 0; pos &amp;lt;= 180; pos++) {&#xA;        servo1.write(pos);&#xA;        delay(15);&#xA;        servo2.write(180 - pos);&#xA;        delay(15);&#xA;    }&#xA;&#xA;    // 2nd loop here&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's rather inefficient to detach a servo after each write and then attach it again for the next write. Simply keep it up all the time.&lt;/p&gt;&#xA;" OwnerUserId="15427" LastEditorUserId="15427" LastEditDate="2016-01-06T15:13:28.900" LastActivityDate="2016-01-06T15:13:28.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18981" PostTypeId="2" ParentId="10408" CreationDate="2015-12-25T00:14:18.800" Score="1" Body="&lt;p&gt;I found an answer to a similar question here:&#xA;&lt;a href=&quot;https://forum.sparkfun.com/viewtopic.php?f=32&amp;amp;t=39214&amp;amp;start=15#p175098&quot; rel=&quot;nofollow&quot;&gt;https://forum.sparkfun.com/viewtopic.php?f=32&amp;amp;t=39214&amp;amp;start=15#p175098&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: it requires you to close and open the serial monitor at proper timings.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// disable the USB prior going to sleep&#xA;USBCON |= _BV(FRZCLK);  //freeze USB clock&#xA;PLLCSR &amp;amp;= ~_BV(PLLE);   // turn off USB PLL&#xA;USBCON &amp;amp;= ~_BV(USBE);   // disable USB&#xA;&#xA;// and wake it up after&#xA;//routine to properly wake up&#xA;sleep_disable();&#xA;delay(100);&#xA;USBDevice.attach(); // keep this&#xA;delay(100);&#xA;Serial.begin(9600);&#xA;delay(100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15846" LastEditorUserId="3917" LastEditDate="2015-12-25T19:18:33.547" LastActivityDate="2015-12-25T19:18:33.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18982" PostTypeId="1" CreationDate="2015-12-25T02:43:20.530" Score="3" ViewCount="2433" Body="&lt;p&gt;How do you wire a phototransistor so that it outputs a clean digital signal in response to certain light levels?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've wired a &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/QR/QRD1114.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;QRD1114&lt;/a&gt; to an Arduino analog pin to detect a white or black surface. However, I want to use this sensor to detect fast movement of a black/white color strip, and since &lt;code&gt;analogRead()&lt;/code&gt; can &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow noreferrer&quot;&gt;take up to 100µs&lt;/a&gt; and I'd rather use the ADC pin for other sensors, I want to rewire this so I can read the same signal with &lt;code&gt;digitalRead()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do this, the sensor needs to output less than 2.3V for white and more than 2.5V for black. I'm pretty close, but I'm having trouble with black. For white, the voltage drops to 0.7V, so that reads perfectly, but black still reflects a lot of IR, so it typically reads 2.3V, which still translates as a LOW value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sensor's circuit is a pretty basic voltage divider:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0f3nN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0f3nN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1 is the Arduino's built-in 20k pullup. R2 is a variable resistor I've tried using to &quot;shift&quot; the voltage level up for the black case. Unfortunately, I've found this very difficult to calibrate. The larger I make R2, the higher the black-case voltage gets...but so does the white-case voltage. By the time I make R2 large enough so that black registers as HIGH, white also registers as high. Through trial and error, I found 25.7k ohms is the sweet spot, but the difference in voltage between the two is about 0.5V, which makes me nervous about getting false readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've measured the phototransistor's resistance in each case, and for black it reads as 12.5k ohms while for white it reads as 9.7k ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given my 25.7k calibration resistance, the voltage divider should output for black:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = Vin * R2/(R1 + R2)&#xA;&#xA;5 * (12500+25700)/(20000 + 12500+25700) = 3.2V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and for white:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 * (9700+25700)/(20000 + 9700+25700) = 3.1V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, for black, my meter reads 2.3V for black and 2.0V for white.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do my meter measurements not match the voltage divider formula? Am I wiring this voltage divider correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to get a cleaner digital output without complicating the circuit too much?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="4628" LastEditDate="2017-09-08T16:28:55.113" LastActivityDate="2018-03-08T02:22:18.790" Title="How to wire an analog IR sensor for digital input?" Tags="|sensors|analogread|ir|digital|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="18983" PostTypeId="1" CreationDate="2015-12-25T06:33:01.783" Score="0" ViewCount="810" Body="&lt;p&gt;For &lt;a href=&quot;http://reefwingrobotics.blogspot.com.au/2015/12/moving-to-embedxcode.html&quot; rel=&quot;nofollow&quot;&gt;various reasons&lt;/a&gt;, I am moving from the Arduino IDE to Xcode using the embedXcode plugin. The code in question compiles and uploads fine from the Arduino IDE, so I think the issue is related to library definitions in embedXcode. The board I am using is an Arduino Mega 2560 (actually it is a &lt;a href=&quot;http://www.freetronics.com.au/products/ethermega-arduino-mega-2560-compatible-with-onboard-ethernet#.VnzZ7pN95Zo&quot; rel=&quot;nofollow&quot;&gt;Freetronics EtherMega&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error thrown is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;More specifically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    5.3-LINK                    Builds/embeddedcomputing.elf&#xA;&#xA;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -o Builds/embeddedcomputing.elf Builds/main.cpp.o Builds/embeddedcomputing.a -Os -w -mmcu=atmega2560 -Wl,--gc-sections  -LBuilds -lm&#xA;Builds/main.cpp.o: In function `Robot::Robot()':&#xA;main.cpp:(.text._ZN5RobotC2Ev[Robot::Robot()]+0x5e): undefined reference to `Servo::Servo()'&#xA;Builds/main.cpp.o: In function `Robot::begin()':&#xA;main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x5a): undefined reference to `Servo::attach(int)'&#xA;main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x64): undefined reference to `Servo::write(int)'&#xA;main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0xea): undefined reference to `Servo::write(int)'&#xA;main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x112): undefined reference to `Servo::write(int)'&#xA;main.cpp:(.text._ZN5Robot5beginEv[Robot::begin()]+0x132): undefined reference to `Servo::write(int)'&#xA;Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::HB25MotorControl(unsigned char)':&#xA;HB25MotorControl.cpp:(.text._ZN16HB25MotorControlC2Eh+0x14): undefined reference to `Servo::Servo()'&#xA;Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::begin()':&#xA;HB25MotorControl.cpp:(.text._ZN16HB25MotorControl5beginEv+0x42): undefined reference to `Servo::attach(int, int, int)'&#xA;HB25MotorControl.cpp:(.text._ZN16HB25MotorControl5beginEv+0x58): undefined reference to `Servo::writeMicroseconds(int)'&#xA;Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::stop()':&#xA;HB25MotorControl.cpp:(.text._ZN16HB25MotorControl4stopEv+0x12): undefined reference to `Servo::writeMicroseconds(int)'&#xA;Builds/embeddedcomputing.a(HB25MotorControl.cpp.o): In function `HB25MotorControl::moveAtSpeed(int)':&#xA;HB25MotorControl.cpp:(.text._ZN16HB25MotorControl11moveAtSpeedEi+0x44): undefined reference to `Servo::writeMicroseconds(int)'&#xA;collect2: error: ld returned 1 exit status&#xA;make: *** [Builds/embeddedcomputing.elf] Error 1&#xA;Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Robot.h contains a robot class which defines a Servo (for a turret) and two HB-25 MotorControl objects (which control the drive motors). The &lt;a href=&quot;http://reefwingrobotics.blogspot.com.au/2015/12/parallax-hb-25-motor-control-library.html&quot; rel=&quot;nofollow&quot;&gt;HB25MotorControl is a custom library&lt;/a&gt; that I have written for the Parallax HB-25 Motor Controller. It also uses the Servo library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer the obvious questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Yes I have &lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&lt;/code&gt; in my HB25MotorControl library. You&#xA;can see the library code by following the link above. It is also&#xA;included in the main sketch.  &lt;/li&gt;&#xA;&lt;li&gt;I have compiled, linked and uploaded other sketches which use Arduino and custom libraries in Xcode using the embedXcode plugin.&lt;/li&gt;&#xA;&lt;li&gt;My embedXcode Makefile definitions include&#xA;    the Servo library and the HB25MotorControl library. See extract&#xA;    below.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;APP_LIBS_LIST = Wire Servo SoftwareSerial&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USER_LIBS_LIST = NewPing Time DS3232RTC HB25MotorControl&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on how to fix this error and get my code to build in Xcode would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15798" LastEditorUserId="15798" LastEditDate="2015-12-26T01:14:24.013" LastActivityDate="2015-12-27T00:39:24.967" Title="embedXcode: Link Error using an Arduino library (Servo.h) within a header file" Tags="|arduino-mega|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="18984" PostTypeId="2" ParentId="18560" CreationDate="2015-12-25T06:44:01.997" Score="0" Body="&lt;p&gt;Try using &lt;a href=&quot;http://playground.arduino.cc/Code/NewPing&quot; rel=&quot;nofollow&quot;&gt;NewPing&lt;/a&gt; library. Ping sensors consistently and reliably at up to 30 times per second.&lt;/p&gt;&#xA;" OwnerUserId="15826" LastEditorUserId="6936" LastEditDate="2016-01-03T20:26:46.733" LastActivityDate="2016-01-03T20:26:46.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18985" PostTypeId="1" AcceptedAnswerId="18986" CreationDate="2015-12-25T06:54:45.110" Score="3" ViewCount="50" Body="&lt;p&gt;I have a program where a device registers itself with a command object. The command object is losing track of the registrations. The following program repeats &quot;0 devices registered&quot; even though when it initializes it displays &quot;Devices registered 1&quot;. My guess is that I am accidentally creating 2 copies of the command object.&#xA;This is the main sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;command.h&quot;&#xA;#include &quot;widget.h&quot;&#xA;&#xA;Command command;&#xA;Widget widget;&#xA;void setup() {&#xA;  command.init();&#xA;  widget.init(command);&#xA;}&#xA;&#xA;void loop() {&#xA;  command.update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;#ifndef Command_h&#xA;#define Command_h&#xA;&#xA;typedef struct  {&#xA;  char id;&#xA;  char name[20];&#xA;} Device;&#xA;&#xA;class Command&#xA;{&#xA;  public:&#xA;    Command();&#xA;    void init();&#xA;    void registerDevice(Device _cmd);&#xA;    void update();&#xA;  private:&#xA;    Device Devices[20];&#xA;    byte DevicesPtr = 0;&#xA;};&#xA;&#xA;#endif &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;command.h&quot;&#xA;&#xA;#define DEVICES_MAX 9&#xA;&#xA;Command::Command() {&#xA;  DevicesPtr = 0;&#xA;  Device Devices[DEVICES_MAX];&#xA;}&#xA;&#xA;void Command::init() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void Command::update(){&#xA;  Serial.print( DevicesPtr );&#xA;  Serial.println( &quot; devices registered&quot; );&#xA;  delay(500);  &#xA;}&#xA;void Command::registerDevice(Device _cmd) {&#xA;  _cmd.id = '0' + (++DevicesPtr);&#xA;  Devices[DevicesPtr] = _cmd;&#xA;  Serial.print(&quot;Devices registered &quot;);&#xA;  Serial.println(DevicesPtr);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;widget.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;command.h&quot;&#xA;&#xA;class Widget&#xA;{&#xA;  public:&#xA;    static void init(Command _command);&#xA;&#xA;  private:&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;widget.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;widget.h&quot;&#xA;#include &quot;command.h&quot;&#xA;&#xA;void Widget::init(Command _command) {&#xA;  Device device;&#xA;  strcpy(device.name, &quot;Widget #1&quot;);&#xA;  _command.registerDevice(device);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2015-12-26T23:09:35.337" Title="Class is not tracking changes to a private field" Tags="|class|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18986" PostTypeId="2" ParentId="18985" CreationDate="2015-12-25T09:39:58.143" Score="4" Body="&lt;p&gt;It is all about calling conventions and argument binding. The code is using call-by-value when it should be call-by-reference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is call-by-value (the incoming command is not updated, a copy is passed as parameter):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Widget::init(Command _command)&#xA;...&#xA;widget.init(command);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is call-by-reference (a pointer to command is passed as parameter):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Widget::init(Command* _command)&#xA;{&#xA;   __command-&amp;gt;registerDevice(...);&#xA;}&#xA;...&#xA;widget.init(&amp;amp;command);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternative syntax is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Widget::init(Command&amp;amp; _command)&#xA;{&#xA;   _command.registerDevice(...);&#xA;}&#xA;...&#xA;widget.init(command)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-26T23:09:35.337" LastActivityDate="2015-12-26T23:09:35.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18987" PostTypeId="2" ParentId="18560" CreationDate="2015-12-25T10:31:42.107" Score="1" Body="&lt;p&gt;On it's max speed, how far is it's braking distance?&#xA;Then you should start braking atleast from before that distance of the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say your braking distance is 25cm, you should start braking &gt;25cm.&#xA;But this is only when you would &lt;em&gt;instantly&lt;/em&gt; brake at the moment you're within 25cm reach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we have to know how many distance we will travel during the calculation, before we start braking.&#xA;You could just try it out, set the distance a little higher everytime you crash into it (Assuming it doesn't fail and is always at the same time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have to know the top speed of your motor, RPM doesn't say a lot in this story, we'll need to know how big your wheels are to be able to determine how many cm's you'll travel per revolution, and doing that times the RPM, you know your top speed. (Or you can also measure this, but it can change depending on how full your battery is)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, your code should be &lt;strong&gt;real-time&lt;/strong&gt; you'll likely want to use &lt;strong&gt;timers&lt;/strong&gt; to trigger the &lt;code&gt;trigPin&lt;/code&gt; and use an interrupt on the &lt;code&gt;echoPin&lt;/code&gt; to be sure none of your code will delay your sensor. This will improve execution speed aswell as reliability/deterministic timing. Also, it will make it possible to run it aside from your regular code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you know, your top speed = 10cm/second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you know that 1 calculation+reaction-time is 200ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can safely assume that you need &gt;2cm extra.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, you should add a little for when it's slippery/another surface or just so you won't touch the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So. The ping sensor is almost always fast enough, only if the calculated range is outside your max range, it will not work.&#xA;You could however, use an &lt;a href=&quot;http://www.hobbyist.co.nz/?q=infrared_proximity_sensor&quot; rel=&quot;nofollow&quot;&gt;IR proximity sensor&lt;/a&gt; which will trigger at a set distance. This way you don't have to do any calculations and just brake whenever you receive the interrupt. But it won't tell you the distance to the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cool thing on the distance sensor is that you can also scale the brake distance on your driving speed, so that it will brake later when you're driving on half your speed. That way you can come very close to an object, but still be 100% sure that you won't crash into it.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2015-12-25T10:31:42.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18988" PostTypeId="1" CreationDate="2015-12-25T10:38:07.077" Score="0" ViewCount="17610" Body="&lt;p&gt;So I'm following a beginners arduino book and I made a blinking program and now I've coded another program but when I try to upload it, avrdude(whatever that is) gives me the errors in the title and repeats them 10 times.&#xA;I have tried this so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Restarting my windows 8&lt;/li&gt;&#xA;&lt;li&gt;Pressing the reset button on my arduino uno R3&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My guess is that since it worked the first time, my blinking program must be clogging up the space in my arduino.How can I fix this problem. Or if my guess is right, how can I get the blinking program out of arduino and go home to my bots folder? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My IDE is arduino 1.6.7 and my port is CPU1. and lots of people mention tools&gt;serial port but there isn't a &quot;serial port&quot; button on my IDE.&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastActivityDate="2023-10-26T14:44:22.017" Title="avrdude: stk500_recv(): programmer is not responding + avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x47" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ClosedDate="2023-10-26T15:26:20.387" ContentLicense="CC BY-SA 3.0" />
  <row Id="18989" PostTypeId="1" CreationDate="2015-12-25T12:24:43.203" Score="2" ViewCount="224" Body="&lt;p&gt;I am a nooby so this might be an obvious answer kind of a question, but how do I change how many parameters arduino-uno reads from a sensor using SDI communication? My code (which was in public domain, an example for SDI communication) has no problems taking 3 or less parameters but the probe I have has 7 sensors in it and I need all of their values (but all I get in return is 1, literally just the number 1). If I remove and leave only 3 sensors in the probe it works normally. So the problem is not in the communication but in the quantity of data. My code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;SDISerial.h&amp;gt;&#xA;    #define DATALINE_PIN 2&#xA;    #define INVERTED 1&#xA;&#xA;    SDISerial sdi_serial_connection(DATALINE_PIN, INVERTED);&#xA;&#xA;    char* get_measurement(){&#xA;     char* service_request = sdi_serial_connection.sdi_query(&quot;?M!&quot;,60000UL);&#xA;     char* service_request_complete = sdi_serial_connection.wait_for_response(900);&#xA;     return sdi_serial_connection.sdi_query(&quot;?D0!&quot;,60000UL);&#xA;    }&#xA;&#xA;    void setup(){&#xA;     sdi_serial_connection.begin(); // start our SDI connection &#xA;     Serial.begin(9600); // start the connection&#xA;     Serial.println(&quot;OK INITIALIZED&quot;); // startup string&#xA;     delay(90000); // startup delay to allow sensor to powerup, 1.5 min &#xA;    }&#xA;&#xA;    void loop(){&#xA;     char* response = get_measurement(); // get measurement data&#xA;&#xA;     if (response!=NULL &amp;amp;&amp;amp; response[0] != '\0')&#xA;      Serial.println(response);&#xA;     else&#xA;      Serial.println(&quot;No Response&quot;);&#xA;     delay(1500);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15854" LastEditorUserId="15854" LastEditDate="2015-12-28T11:40:58.140" LastActivityDate="2015-12-28T11:40:58.140" Title="How do I change the default number of parameters SDI 12?" Tags="|arduino-uno|serial|sensors|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="18990" PostTypeId="2" ParentId="18988" CreationDate="2015-12-25T13:57:47.030" Score="0" Body="&lt;p&gt;Just search a little bit around Google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple solution is pressing the restart button after the program is compiled, then, upload it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or restart the Arduino while the Arduino is uploading the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the problem remains, try to &lt;strong&gt;&lt;a href=&quot;https://www.arduino.cc/en/Hacking/Bootloaderhttps://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;burn again the bootloader of your arduino.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="15855" LastEditorUserId="6936" LastEditDate="2016-01-02T19:39:47.447" LastActivityDate="2016-01-02T19:39:47.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18991" PostTypeId="2" ParentId="18988" CreationDate="2015-12-25T15:19:39.877" Score="2" Body="&lt;p&gt;I had the same exact problem and fixed it, just by molding the two reset pins on the arduino together. Just check if they are properly connected as the error probably is caused by that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jF6TI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jF6TI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work, check the LEDs on the board. When you are uploading a sketch both RX and TX should be lightning up.&lt;/p&gt;&#xA;" OwnerUserId="11595" LastActivityDate="2015-12-25T15:19:39.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18993" PostTypeId="1" CreationDate="2015-12-25T17:24:25.103" Score="0" ViewCount="4705" Body="&lt;p&gt;Could anybody please help me with my problem? My Arduino doesn't work correctly. I was between a project, and suddenly it started acting weird. First, it started taking about 4 minutes to compile and a minute to upload, I do not know why!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, now it doesn't accept any code at all. I will paste the error message below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, could anything be damaged as I inserted the USB cable of the Arduino to my power bank, rated 5V 2A, for about 30 seconds as power source and then again inserted it to the computer itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me. I have already tried searching on various forums, reinstalling the software and driver on my PC, pressing the reset button... No help so far.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ERROR MESSAGE:&#xA;  Arduino: 1.6.7 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;           Copyright (c) 2000-2005 Brian Dean, &lt;a href=&quot;http://www.bdmicro.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.bdmicro.com/&lt;/a&gt;&#xA;           Copyright (c) 2007-2009 Joerg Wunsch&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Using Port                    : COM6&#xA;Using Programmer              : arduino&#xA;Overriding Baud Rate          : 115200&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x49&#xA;Error opening serial port 'COM6'. (Port busy)&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x49&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x49&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15858" LastEditorUserId="3917" LastEditDate="2015-12-25T19:12:31.530" LastActivityDate="2016-01-04T17:41:25.637" Title="Arduino not working / not uploading" Tags="|arduino-uno|arduino-ide|uploading|" AnswerCount="2" CommentCount="1" ClosedDate="2016-01-21T20:44:19.183" ContentLicense="CC BY-SA 3.0" />
  <row Id="18996" PostTypeId="2" ParentId="18993" CreationDate="2015-12-25T18:31:24.580" Score="1" Body="&lt;p&gt;Connecting to the 5v/2A power supply would cause no trouble at all. Taking 4 minutes to compile is strange but unlikely to be related to the Arduino board. &quot;programmer is not responding&quot; errors are communication errors.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Did the program compile without errors?&lt;/li&gt;&#xA;&lt;li&gt;Are any LEDs lit or blinking on your board?&lt;/li&gt;&#xA;&lt;li&gt;Is the correct board selected in the Tools | Boards menu?&lt;/li&gt;&#xA;&lt;li&gt;Is the correct port selected in the Tools | Ports menu?&lt;/li&gt;&#xA;&lt;li&gt;Is the correct programmer selected in the Tools | Programmer menu?&lt;/li&gt;&#xA;&lt;li&gt;Try another USB cable.&lt;/li&gt;&#xA;&lt;li&gt;Try pressing/releasing the board's reset button right after you click the upload button.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2015-12-27T02:44:13.750" LastActivityDate="2015-12-27T02:44:13.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="18997" PostTypeId="1" AcceptedAnswerId="19015" CreationDate="2015-12-25T18:51:49.497" Score="0" ViewCount="658" Body="&lt;p&gt;I am using a BLE nano - as soon as I try to include I2Cdev.h and compile, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino\libraries\I2Cdev\I2Cdev.cpp:276:62: error: 'BUFFER_LENGTH' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How should I fix this? I imagine I can hard-code it in and guess around as to the value (32 seems common), but I think I am missing something else as far as it using the right libraries for the hardware, so how can I check/fix that if it is indeed the case? &lt;/p&gt;&#xA;" OwnerUserId="10606" LastActivityDate="2015-12-26T16:49:09.483" Title="Where am I supposed to get an I2C BUFFER_LENGTH defined?" Tags="|programming|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="18998" PostTypeId="1" AcceptedAnswerId="19007" CreationDate="2015-12-25T20:17:09.540" Score="0" ViewCount="261" Body="&lt;p&gt;Seeing as this is my first post I would like to thank everyone ahead who take their time to delve into my whimsical code, whoever you may be, be merciful ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For one of my uni projects, I would like to make a physical interface that can be operated via touch &quot;keys&quot; that rely on the human capacitance effect. I have relentlessly researched it (as much as feasible in my time as a student for this project) and even created a working prototype with 4 unique keys. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you will see in my code below, I am using the capacitiveSensor.h library, which I could unfortunately not find much documentation about other than a few videos and tutorials that build upon it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried deciphering the workings of it by looking at its code to see if I can manipulate it for my own biddings but quickly realized it is beyond my skill to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing right now is that while the touch keys work, they trigger each other because of the capacitance build up when one of the keys is being pressed or when the hand is close to other keys while pressing a key. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, I am looking for an algorithm that will reduce processing time &amp;amp; effort for the Arduino as the one I have implemented below slows it down way too much to be of any use for my project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for the long post, here is my current code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt; CapacitiveSensor.h &amp;gt; &#xA;#include &amp;lt; pitches.h &amp;gt;&#xA;&#xA;&#xA;&#xA;CapacitiveSensor cs_4_2 = CapacitiveSensor(4, 2); // 10M resistor between pins 4 &amp;amp; 2, pin 2 is sensor pin, add a wire and or foil if desired&#xA;CapacitiveSensor cs_4_3 = CapacitiveSensor(4, 3); // 10M resistor between pins 4 &amp;amp; 6, pin 6 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor cs_4_5 = CapacitiveSensor(4, 5); // 10M resistor between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;CapacitiveSensor cs_4_6 = CapacitiveSensor(4, 6);&#xA;&#xA;&#xA;&#xA;&#xA;# define COMMON_PIN 4 // send pin&#xA;# define CAP_THRESHOLD 450 // overall threshold&#xA;# define NUM_OF_KEYS 4 // Number of keys that are on the keyboard&#xA;# define noteDur 50 // duration of note&#xA;# define BUZZER_PIN 12 // The output pin for the piezo buzzer&#xA;# define noMulti 0.9 // incremental factor per key&#xA;# define overkill 5 // register no touch after this cap factor is exceeded&#xA;&#xA;// This macro creates a capacitance &quot;key&quot; sensor object for each key on the piano keyboard:&#xA;# define CS(Y) CapacitiveSensor(COMMON_PIN, Y)&#xA;&#xA;CapacitiveSensor keys[] = {&#xA;CS(2), CS(3), CS(5), CS(6)&#xA;};&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;Serial.begin(57600);&#xA;&#xA;// Turn off autocalibrate on all channels:&#xA;for (int i = 0; i &amp;lt; NUM_OF_KEYS; ++i) {&#xA;keys[i].set_CS_AutocaL_Millis(0xFFFFFFFF);&#xA;}&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;// needs to be repeated here to work in THIS scope&#xA;long sensor01 = cs_4_2.capacitiveSensor(30); // pin 2 is cap sensor, pin 4 is &quot;common send&quot;&#xA;long sensor02 = cs_4_3.capacitiveSensor(30);&#xA;long sensor03 = cs_4_5.capacitiveSensor(30);&#xA;long sensor04 = cs_4_6.capacitiveSensor(30);&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;Serial.println(&quot;&quot;);&#xA;Serial.print(&quot;key1&quot;);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(&quot;key2&quot;);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(&quot;key3&quot;);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(&quot;key4&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;Serial.print(keys[0].capacitiveSensor(CAP_THRESHOLD));&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(keys[1].capacitiveSensor(CAP_THRESHOLD));&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(keys[2].capacitiveSensor(CAP_THRESHOLD));&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.print(keys[3].capacitiveSensor(CAP_THRESHOLD));&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;// algo for key 1&#xA;if (keys[0].capacitiveSensor(CAP_THRESHOLD) &amp;gt; CAP_THRESHOLD &amp;amp;&amp;amp;&#xA;keys[1].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[0].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[2].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[0].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[3].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[0].capacitiveSensor(CAP_THRESHOLD) * noMulti) {&#xA;Serial.print(&quot;key pressed on sense1&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;tone(BUZZER_PIN, NOTE_A7, noteDur);&#xA;&#xA;}&#xA;&#xA;// algo for key 2&#xA;else if (keys[1].capacitiveSensor(CAP_THRESHOLD) &amp;gt; CAP_THRESHOLD &amp;amp;&amp;amp;&#xA;keys[0].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[1].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[2].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[1].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[3].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[1].capacitiveSensor(CAP_THRESHOLD) * noMulti) {&#xA;Serial.print(&quot;key pressed on sense2&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;tone(BUZZER_PIN, NOTE_B7, noteDur);&#xA;&#xA;}&#xA;// algo for key 3&#xA;else if (keys[2].capacitiveSensor(CAP_THRESHOLD) &amp;gt; CAP_THRESHOLD &amp;amp;&amp;amp;&#xA;keys[1].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[2].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[0].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[2].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[3].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[2].capacitiveSensor(CAP_THRESHOLD) * noMulti) {&#xA;Serial.print(&quot;key pressed on sense3&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;tone(BUZZER_PIN, NOTE_C7, noteDur);&#xA;&#xA;}&#xA;// algo for key 4&#xA;else if (keys[3].capacitiveSensor(CAP_THRESHOLD) &amp;gt; CAP_THRESHOLD &amp;amp;&amp;amp;&#xA;keys[1].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[3].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[2].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[3].capacitiveSensor(CAP_THRESHOLD) * noMulti &amp;amp;&amp;amp;&#xA;keys[0].capacitiveSensor(CAP_THRESHOLD) &amp;lt; keys[3].capacitiveSensor(CAP_THRESHOLD) * noMulti) {&#xA;Serial.print(&quot;key pressed on sense4&quot;);&#xA;Serial.println(&quot;&quot;);&#xA;tone(BUZZER_PIN, NOTE_D7, noteDur);&#xA;&#xA;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15863" LastActivityDate="2015-12-27T22:54:45.213" Title="Capacitive &quot;keys&quot; press event registration issues" Tags="|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="18999" PostTypeId="1" CreationDate="2015-12-25T22:28:19.887" Score="1" ViewCount="234" Body="&lt;p&gt;Sensors like Skin conductance, Body temperature and Heart Rate. Please imagine to talk to a child and keep the answer very simple so I can understand you and you don't lose time to write explanations for your answer.&lt;/p&gt;&#xA;" OwnerUserId="15699" LastActivityDate="2016-02-01T17:33:31.737" Title="How can I attach I2C sensors on the small board of Intel Edison?" Tags="|arduino-galileo|edison|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19000" PostTypeId="2" ParentId="18918" CreationDate="2015-12-25T23:20:43.357" Score="1" Body="&lt;p&gt;The module I had does not have a DTR signal. I mistook the RTS for DTR. Ordering correct module.&lt;/p&gt;&#xA;" OwnerUserId="15787" LastEditorUserId="10907" LastEditDate="2016-01-11T18:38:43.033" LastActivityDate="2016-01-11T18:38:43.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19001" PostTypeId="1" CreationDate="2015-12-25T23:41:20.080" Score="0" ViewCount="4804" Body="&lt;p&gt;I have an arduino uno. Whenever I try to upload code to the arduino I get this error.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;/dev/cu.usbserial-AL01EI7I&quot;: Device not configured &#xA;&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device Problem uploading to board. &#xA;See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15867" LastEditorUserId="15841" LastEditDate="2016-01-01T17:45:54.343" LastActivityDate="2016-01-31T18:03:55.627" Title="Problem Uploading to arduino uno board" Tags="|arduino-uno|uploading|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19002" PostTypeId="1" CreationDate="2015-12-26T00:23:09.530" Score="11" ViewCount="11645" Body="&lt;p&gt;I want to make a shell or C script that interprets the Arduino serial input to run commands. For that, I will need to make that script be the Serial monitor for my arduino. Another reason I want to use scripts or the command line as a Serial I/O is because the Arduino monitor function freezes the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino's serial port is &lt;code&gt;/dev/tty.usbmodem1d112&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have tried so far:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cat /dev/tty.usbmodem1d112&lt;/code&gt; &amp;lt; This returns absolutely nothing&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;screen /dev/tty.usbmodem1d112&lt;/code&gt; &amp;lt; This Prints output, but has problems with input.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;cat &amp;lt; /dev/tty.usbmodem1d112&lt;/code&gt; &amp;lt; Same result as cat without the &lt;code&gt;&amp;lt;&lt;/code&gt; symbol.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sometimes, I also get annoying &lt;strong&gt;Resource Busy&lt;/strong&gt; messages. This makes me re-plug the Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;OS X (10.9.5) Arduino IDE latest version. Arduino M0 pro board.&lt;/p&gt;&#xA;" OwnerUserId="15841" LastActivityDate="2015-12-27T20:35:57.020" Title="Use Unix terminal instead of the Monitor on Arduino IDE" Tags="|serial|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19004" PostTypeId="1" CreationDate="2015-12-26T01:09:12.633" Score="2" ViewCount="897" Body="&lt;p&gt;&lt;a href=&quot;https://www.reddit.com/r/arduino/comments/3y5bg3/help_reading_a_lf_fsk_rfid/&quot; rel=&quot;nofollow&quot;&gt;Reddit&lt;/a&gt; doesn't seem to be much help, so I'm posting here as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm try to read (what I think is) an HID Duoprox II 125kHz FSK RFID and am having a bit of trouble. I'm using an Arduino nano and am copying the code from the &lt;a href=&quot;http://playground.arduino.cc/Main/DIYRFIDReader&quot; rel=&quot;nofollow&quot;&gt;Arduino Playground&lt;/a&gt;. The changes I've made to the code are adjusting the frequency to 125kHz, changing debug to true, and reducing maxBuf to 100. I believe I also have to change val = digitalRead(inPin); to val = !digitalRead(inPin);, and I made grnLED turn on before &quot;got buf num: &quot; is sent, and turn off after. Rather than build the circuit shown, I bought an Rdm6300, reverse engineered the front end, and disconnected the back end from it, letting me use the Arduino as the back end instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as hardware goes, the reader seems to be working properly. The coil has a nice sine wave on it, and the output of the circuit seems to be a proper FSK data stream . (I scoped LedPin, 13, which is outputted by the Arduino after it has recieved the signal on pin 7.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, the Arduino is not sending anything back to the computer. I'm fairly certain that this is somehow a software issue, despite me copying the code from the Arduino website. The TX LED does not light up at all. Even if the data being sent to the Arduino were corrupted, it should still send &quot;got buf num: &quot; every 100 changes of the input signal. (grnLED does turn on for 37.4ms, but no serial data is sent, and the pin never turns on again.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's going on? Why doesn't the Arduino send anything back to the computer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;&#xA;int ledPin = 13; // LED connected to digital pin 13&#xA;int inPin = 7;   // sensing digital pin 7&#xA;int val;&#xA;int bitlenctr = 0;&#xA;int curState = 0;&#xA;&#xA;#define maxBuf 100 //reduce to 100 or so for debugging&#xA;#define debug  true&#xA;&#xA;char raw[maxBuf];&#xA;&#xA;int index = 0;&#xA;int bufnum = 0;&#xA;#define   redLED 12&#xA;#define   grnLED 11 &#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Timer1.initialize(8);  // initialize timer1, and set the frequency; this drives both the LC tank as well as the pulse timing clock&#xA;  // note: modify this as needed to achieve resonance and good match with the desired tags&#xA;  // the argument value is in microseconds per RF cycle, so 8us will yield RF of 125kHz, 7us --&amp;gt; 143kHz, etc.&#xA;&#xA;  Timer1.pwm(9, 512);           // setup pwm on pin 9, 50% duty cycle&#xA;  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt, once per RF cycle&#xA;&#xA;  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output for scope monitoring&#xA;  pinMode(inPin, INPUT);      // sets the digital pin 7 as input to sense receiver input signal&#xA;  pinMode(grnLED, OUTPUT);&#xA;  pinMode(redLED, OUTPUT);&#xA;  digitalWrite(grnLED, 0);&#xA;  digitalWrite(redLED, 1);&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;  val = !digitalRead(inPin);&#xA;  digitalWrite(ledPin, val); // for monitoring&#xA;  bitlenctr++;&#xA;  if(val != curState) {&#xA;    // got a transition&#xA;    curState = val;&#xA;    if(val == 1) {&#xA;      // got a start of cycle (low to high transition)&#xA;      if(index &amp;lt; maxBuf) {&#xA;        raw[index++] = bitlenctr;&#xA;      }&#xA;      bitlenctr = 1;&#xA;    }&#xA;  }  &#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;  if(index &amp;gt;= maxBuf) {&#xA;    digitalWrite(grnLED, 1);&#xA;    Serial.print(&quot;got buf num: &quot;);&#xA;    Serial.println(bufnum);&#xA;    digitalWrite(grnLED, 0);&#xA;&#xA;    if(debug) {&#xA;      for(int i = 0; i &amp;lt; maxBuf;&#xA;      i++) {&#xA;          Serial.print((int)raw[i]);&#xA;        Serial.print(&quot;/&quot;);&#xA;      }&#xA;      Serial.println(&quot;///raw data&quot;);&#xA;      delay(2000);&#xA;    }&#xA;&#xA;    // analyze this buffer&#xA;    // first convert pulse durations into raw bits&#xA;    int tot1 = 0;&#xA;    int tot0 = 0;&#xA;    int tote = 0;&#xA;    int totp = 0;&#xA;    raw[0] = 0;&#xA;    for(int i = 1; i &amp;lt; maxBuf; i++) {&#xA;      int v = raw[i];&#xA;      if(v == 4) {&#xA;        raw[i] = 0;&#xA;        tot0++;&#xA;      } &#xA;      else if(v == 5) {&#xA;        raw[i] = raw[i - 1];&#xA;        totp++;&#xA;      } &#xA;      else if(v == 6 || v == 7) {&#xA;        raw[i] = 1;&#xA;        tot1++;&#xA;      } &#xA;      else {&#xA;        raw[i] = 101; // error code&#xA;        tote++;&#xA;      }  &#xA;    }   &#xA;&#xA;    // next, search for a &quot;start tag&quot; of 15 high bits in a row&#xA;    int samecnt = 0;&#xA;    int start = -1;&#xA;    int lastv = 0;&#xA;    for(int i = 0; i &amp;lt; maxBuf; i++) {&#xA;      if(raw[i] == lastv) {&#xA;        // inside one same bit pattern, keep scanning&#xA;        samecnt++;&#xA;      } &#xA;      else {&#xA;        // got new bit pattern&#xA;        if(samecnt &amp;gt;= 15 &amp;amp;&amp;amp; lastv == 1) {&#xA;          // got a start tag prefix, record index and exit&#xA;          start = i;&#xA;          break;&#xA;        }&#xA;        // either group of 0s, or fewer than 15 1s, so not a valid tag, keep scanning&#xA;        samecnt = 1;&#xA;        lastv = raw[i];&#xA;      }  &#xA;    }&#xA;&#xA;    // if a valid prefix tag was found, process the buffer&#xA;    if(start &amp;gt; 0 &amp;amp;&amp;amp; start &amp;lt; (maxBuf - 5*90)) { //adjust to allow room for full dataset past start point&#xA;      process_buf(start);&#xA;    } &#xA;    else {&#xA;      Serial.println(&quot;no valid data found in buffer&quot;);&#xA;    }&#xA;    if(debug) {&#xA;      for(int i = 0; i &amp;lt; maxBuf;&#xA;        i++) {&#xA;          Serial.print((int)raw[i]);&#xA;        Serial.print(&quot;/&quot;);&#xA;      }&#xA;      Serial.print(&quot;///\nbuffer stats: zeroes:&quot;);&#xA;      Serial.print(tot0); &#xA;      Serial.print(&quot;/ones:&quot;); &#xA;      Serial.print(tot1);&#xA;      Serial.print(&quot;/prevs:&quot;); &#xA;      Serial.print(totp);&#xA;      Serial.print(&quot;/errs:&quot;);&#xA;      Serial.println(tote);  &#xA;      delay(1000);&#xA;    }&#xA;&#xA;    // start new buffer, reset all parameters&#xA;    bufnum++;&#xA;    curState = 0;&#xA;    index = 0;&#xA;  } &#xA;  else {&#xA;    delay(5);&#xA;  }  &#xA;}&#xA;&#xA;// process an input buffer with a valid start tag&#xA;// start argument is index to first 0 bit past prefix tag of 15+ ones&#xA;void process_buf(int start) {&#xA;  // first convert multi bit codes (11111100000...) into manchester bit codes&#xA;  int lastv = 0;&#xA;  int samecnt = 0;&#xA;  char manch[91];&#xA;  char final[45];&#xA;  int manchindex = 0;&#xA;&#xA;  Serial.println(&quot;got a valid prefix, processing data buffer...&quot;);&#xA;  for(int i = start + 1; i &amp;lt; maxBuf &amp;amp;&amp;amp; manchindex &amp;lt; 90; i++) {&#xA;    if(raw[i] == lastv) {&#xA;      samecnt++;&#xA;    } &#xA;    else {&#xA;      // got a new bit value, process the last group&#xA;      if(samecnt &amp;gt;= 3 &amp;amp;&amp;amp; samecnt &amp;lt;= 8) {&#xA;        manch[manchindex++] = lastv;&#xA;      } &#xA;      else if(samecnt &amp;gt;= 9 &amp;amp;&amp;amp; samecnt &amp;lt;= 14) {&#xA;        // assume a double bit, so record as two separate bits&#xA;        manch[manchindex++] = lastv;&#xA;        manch[manchindex++] = lastv;&#xA;      } &#xA;      else if(samecnt &amp;gt;= 15 &amp;amp;&amp;amp; lastv == 0) {&#xA;        Serial.println(&quot;got end tag&quot;);&#xA;        // got an end tag, exit&#xA;        break;&#xA;      } &#xA;      else {&#xA;        // last bit group was either too long or too short&#xA;        Serial.print(&quot;****got bad bit pattern in buffer, count: &quot;);&#xA;        Serial.print(samecnt);&#xA;        Serial.print(&quot;, value: &quot;);&#xA;        Serial.println(lastv);&#xA;        err_flash(3);&#xA;        return;&#xA;      }  &#xA;      samecnt = 1;&#xA;      lastv = raw[i];&#xA;    } //new bit pattern&#xA;  }&#xA;&#xA;  Serial.println(&quot;converting manchester code to binary...&quot;);&#xA;  // got manchester version, convert to final bits&#xA;  for(int i = 0, findex = 0; i &amp;lt; 90; i += 2, findex++) {&#xA;    if(manch[i] == 1 &amp;amp;&amp;amp; manch[i+1] == 0) {&#xA;      final[findex] = 1;&#xA;    } &#xA;    else if(manch[i] == 0 &amp;amp;&amp;amp; manch[i+1] == 1) {&#xA;      final[findex] = 0;&#xA;    } &#xA;    else {&#xA;      // invalid manchester code, exit&#xA;      Serial.println(&quot;****got invalid manchester code&quot;);&#xA;      err_flash(3);&#xA;      return;&#xA;    }&#xA;  }&#xA;&#xA;  // convert bits 28 thru 28+16 into a 16 bit integer&#xA;  int code = 0;&#xA;  int par = 0;&#xA;  for(int i = 28, k = 15; i &amp;lt; 28+16; i++, k--) {&#xA;    code |= (int)final[i] &amp;lt;&amp;lt; k;&#xA;  }&#xA;  int paritybit = final[28+16];&#xA;  for(int i = 0; i &amp;lt; 45; i++) {&#xA;    par ^= final[i];&#xA;  }&#xA;&#xA;  if(par) {  &#xA;    Serial.print(&quot;got valid code: &quot;);&#xA;    Serial.println((unsigned int)code);&#xA;    // do something here with the detected code...&#xA;    // &#xA;    //&#xA;    digitalWrite(redLED, 0);&#xA;    digitalWrite(grnLED, 1);&#xA;    delay(2000);&#xA;    digitalWrite(grnLED, 0);&#xA;    digitalWrite(redLED, 1);&#xA;  } &#xA;  else {&#xA;    Serial.println(&quot;****parity error for retrieved code&quot;);&#xA;    err_flash(3);&#xA;  }  &#xA;}&#xA;&#xA;// flash red for duration seconds&#xA;void err_flash(int duration) {&#xA;  return;&#xA;  for(int i = 0; i &amp;lt; duration*10; i++) {&#xA;    digitalWrite(redLED, 0);&#xA;    delay(50);&#xA;    digitalWrite(redLED, 1);&#xA;    delay(50);&#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even the following code doesn't work! All I receive is &quot;St&quot;! Increasing the PWM period does fix this.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;int val = 0;&#xA;int inPin = 7;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial.print(&quot;Starting!!&quot;);&#xA;  Timer1.initialize(8);&#xA;  Timer1.pwm(9, 512);&#xA;  Timer1.attachInterrupt(callback);&#xA;  pinMode(inPin, INPUT);&#xA;  }&#xA;&#xA;void callback(){&#xA;  val = digitalRead(inPin);}&#xA;&#xA;void loop(){&#xA;  Serial.println(&quot;hi!&quot;);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4581" LastEditorUserId="4581" LastEditDate="2015-12-26T22:41:00.737" LastActivityDate="2015-12-26T22:41:00.737" Title="Help reading a 125khz FSK RFID" Tags="|serial|timers|rfid|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19005" PostTypeId="2" ParentId="19002" CreationDate="2015-12-26T03:21:40.650" Score="8" Body="&lt;p&gt;You'll need to condition the serial line with the &lt;code&gt;stty&lt;/code&gt; command to get this to work. One of the easier ways to do it is to start by using the Serial Monitor and running the command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;stty -g &amp;lt; /dev/tty.usbmodem1d112&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will show you all of the settings that the Serial Monitor used to conditions the line. The &lt;code&gt;-g&lt;/code&gt; flag to stty tells it to give you the results in a form that can be used as the arguments to another stty command. You could do this like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;echo -n 'stty ' &amp;gt; stty.arduino ; sudo stty -g -f /dev/tty.usbmodem1d112 &amp;gt;&amp;gt; stty.arduino&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;chmod +x stty.arduino&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first line creates a shell script to condition the serial line. The second line makes it executable so that you can run it as a shell command – &lt;code&gt;./stty.arduino&lt;/code&gt;. The &lt;code&gt;sudo&lt;/code&gt; runs the command as root (with elevated privilege) which allows you to open the port even though the Serial Monitor will already have it open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want you could move the command into a directory on your &lt;code&gt;$PATH&lt;/code&gt; (for example ~/bin) so that it can be found regardless of where your current directory is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After getting set up you can see the output from &lt;code&gt;Serial.println()&lt;/code&gt; on the Arduino by doing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;./stty.arduino&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;cat &amp;lt; /dev/tty.usbmodem1d112&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on what you are trying to do, you might find the &lt;a href=&quot;http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts&quot; rel=&quot;nofollow&quot;&gt;expect&lt;/a&gt; or &lt;a href=&quot;http://www-users.cs.umn.edu/~gini/1901-07s/files/script.html&quot; rel=&quot;nofollow&quot;&gt;script&lt;/a&gt; commands helpful. Expect (&lt;a href=&quot;http://www.tcl.tk/man/expect5.31/expect.1.html&quot; rel=&quot;nofollow&quot;&gt;man page&lt;/a&gt;) lets you automate interactions with a text based application or process. Script (&lt;a href=&quot;https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/script.1.html&quot; rel=&quot;nofollow&quot;&gt;man page&lt;/a&gt;) creates a transcript of your interactions on the command line with another program or process.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2015-12-27T20:35:57.020" LastActivityDate="2015-12-27T20:35:57.020" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19007" PostTypeId="2" ParentId="18998" CreationDate="2015-12-26T06:32:05.100" Score="1" Body="&lt;p&gt;You might experiment with the code shown at the end of this answer.  It is fairly responsive, in the sense that readings are taken reasonably quickly (several per millisecond), which should leave a good deal of time available for other processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this code, all of the pins that are on the same port are sampled at the same time.  For example, pins 2,3,5,6  on an Uno are all on port D so their four pads can be tested all at the same time.  But if the pins list includes pins from &lt;code&gt;k&lt;/code&gt; different ports, sampling will take up to &lt;code&gt;k&lt;/code&gt; times as long as when sampling from a single port.  For example, on a Mega2560, pins 2, 3, 5 are on port E and pin 6 is on port H, so this code's execution time when processing buttons on pins 2,3,5,6 is about twice as long on a Mega as on an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;em&gt;Edit:&lt;/em&gt;  For Uno port-to-pin assignments, see an &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1095&amp;amp;bih=625&amp;amp;q=uno+pinout&amp;amp;oq=uno+pin&amp;amp;gs_l=img.1.0.0l3j0i30j0i5i30l6.2233.4374.0.6513.7.7.0.0.0.0.70.453.7.7.0....0...1ac.1.64.img..0.7.451.lq4psgGuNr0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno Pinout Diagram&lt;/a&gt;.  On such diagrams, labels like &lt;code&gt;ADC0 PCINT8 14 A0 23 PC0&lt;/code&gt; show the Arduino digital pin reference number (eg, 14), analog pin label (eg, A0), its various functional designations (ADC0, PCINT8, and PC0, meaning analog input pin 0, pin-change-interrupt pin 8, and bit 0 of port C), and the physical pin number (23).   For hardware level information about Uno ports, see &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmel's document #8271&lt;/a&gt;.  Use Google images similarly to find other-model diagrams, eg &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1095&amp;amp;bih=625&amp;amp;q=uno+pinout&amp;amp;oq=uno+pin&amp;amp;gs_l=img.1.0.0l3j0i30j0i5i30l6.2233.4374.0.6513.7.7.0.0.0.0.70.453.7.7.0....0...1ac.1.64.img..0.7.451.lq4psgGuNr0#hl=en&amp;amp;tbm=isch&amp;amp;q=mega+2560+pinout&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mega 2560 pinouts&lt;/a&gt;.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may need to tune some of the constants to fit your own circuitry or switch-function requirements.  I'm not able to tell from the question what resistor sizes you are using or what your circuit is.  For preliminary tuning, enable the &lt;code&gt;secondly()&lt;/code&gt; function and disable &lt;code&gt;testChange()&lt;/code&gt; functions.  If your circuit is similar to that shown below but uses higher resistances, you may need to increase &lt;code&gt;nsamp&lt;/code&gt;, &lt;code&gt;IsHighCount&lt;/code&gt;, and &lt;code&gt;preSamp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the general idea of circuitry I used:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tpwfx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tpwfx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above, &quot;Drive&quot; refers to pin 4.  &quot;Sense 1&quot; ... &quot;Sense j&quot; (with j=4) refer to pins 2, 3, 5, 6, as in your example code.  The capacitors illustrated are tape-covered aluminum-foil pads, eg 22 x 44 mm and the resistors are 440 KΩ each (two 220 KΩ's in series).  Those resistor values produce an RC time constant of a few dozen microseconds when a button isn't touched, and a couple hundred microseconds when a button is touched.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2 on  199 7587&#xA;2 off 179 7702&#xA;1 on  196 10798&#xA;1 off 154 10802&#xA;1 on  253 10900&#xA;1 off 180 10924&#xA;2 on  219 18097&#xA;2 off 166 18134&#xA;3 on  214 21105&#xA;3 off 155 21385&#xA;3 on  227 24312&#xA;3 off 72 24535&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that output, the first column is switch number.  The last column is the current reading of &lt;code&gt;millis()&lt;/code&gt; at time of printing.  The third column is total counts accrued from 12 sets of contact readings.  The simple-minded on/off algorithm used in the &lt;code&gt;testChangeA()&lt;/code&gt; function is that a contact is on when its 12-sample count exceeds 180.  One could also add calibrations, adaptive threshholds, debouncing, etc to the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code (which was run on an Uno, but I tested most of it on a Mega also, and it should run ok on other Arduinos as well since the direct port accesses are computed via functions like &lt;code&gt;portInputRegister&lt;/code&gt;, &lt;code&gt;portModeRegister&lt;/code&gt;, etc in &lt;code&gt;countPins7()&lt;/code&gt; setup before it calls &lt;code&gt;portSampler7()&lt;/code&gt; to run the test.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/* Via serial port, tell the current time when capacitive readings on&#xA; various digital pins show a button has been &quot;pressed&quot; or &quot;released&quot;.&#xA; JW - 25 Dec 2015&#xA;&#xA; See eg refs at http://playground.arduino.cc/Code/CapacitiveSensor and&#xA; http://www.arduino.cc/en/Reference/PortManipulation and&#xA; http://garretlab.web.fc2.com/en/arduino/inside/arduino/Arduino.h/digitalPinToPort.html&#xA;&#xA; */&#xA;#include &amp;lt;Streaming.h&amp;gt;      // provides nicer syntax for printing&#xA;// Set upper size on pins count per sample; #samples saved per reading;&#xA;//  #samples tossed; threshold for Button-is-on; #samples per set; etc&#xA;enum { nbits=8, nsamp=40, preSamp=1, SettleDown=90 };&#xA;enum { IsHighCount=15, SampleSets=12, IsHighTotal=IsHighCount*SampleSets };&#xA;void setup() {&#xA;  Serial.begin(115200);     // initialize serial port&#xA;}&#xA;//-----------------------------------------------------------&#xA;// portSampler7(): Sample a port nsamp times and return the results.&#xA;// Inputs:  drivePin, portCode, pinsMask, preWait.  Constant nsamp.&#xA;// Output:  array of nsamp samples. &#xA;// This version takes 8 cycles per sample, and as inputs switch &#xA;// on after about one RC time constant, on a 16MHz Arduino an&#xA;// m-count result (that is, a bit clear in m of the nsamp readings)&#xA;// suggests RC is about m/2 + preWait/2 us.&#xA;void portSampler7(uint8_t drivePin, uint8_t portCode, uint8_t pinsMask,&#xA;          uint8_t preWait, uint8_t *samples) {&#xA;  volatile uint8_t *pin, *port, *ddr;&#xA;  // pin, port, and ddr are pointers to registers with volatile&#xA;  // contents: input port, output port, direction register.&#xA;  pinMode(drivePin, OUTPUT);&#xA;  digitalWrite(drivePin,LOW);&#xA;  pin =  portInputRegister (portCode); // eg points to PIND&#xA;  port = portOutputRegister(portCode); // eg points to PORTD&#xA;  ddr =  portModeRegister  (portCode); // eg points to DDRD&#xA;  *port &amp;amp;= ~pinsMask;        // Turn off our pins&#xA;  *ddr  |= pinsMask;         // Make our pins be outputs, briefly&#xA;  for (uint8_t i=0; i&amp;lt;SettleDown; ++i) *pin;  // Delay to let pins settle low&#xA;  *ddr &amp;amp;= ~pinsMask;         // Make our pins be high-impedance inputs&#xA;  digitalWrite(drivePin,HIGH); // Turn on driver pin&#xA;  for (uint8_t i=0; i&amp;lt;preWait; ++i) *pin;  // Baseline Delay&#xA;  for (uint8_t i=0; i&amp;lt;nsamp; ++i) // Take and store nsamp readings&#xA;    samples[i] = *pin;&#xA;}&#xA;//-----------------------------------------------------------&#xA;/* Sample a pins-list and report results in counts array.  Eg,&#xA;   pinsList can look like &quot;2,3,4,5,6&quot; or &quot;2,4,5,12,9,23,17,7&quot;&#xA;   etc.  A list may contain digits and commas only.  Pins may be&#xA;   listed in any desired order.  Elements of counts will be in&#xA;   list-order.  Eg, in the &quot;2,3,4,5,6&quot; example, counts[0] is the&#xA;   count for pin 2, counts[1] is the count for pin 3, etc.  A&#xA;   larger count implies longer rise time and larger capacitance.&#xA;   Use preWait to suppress baseline-level counts (and to reduce &#xA;   sample array size) by waiting a while before beginning to sample.  &#xA; */&#xA;uint8_t countPins7(uint8_t drivePin, char *pinsList,&#xA;           uint8_t *counts, uint8_t preWait) {&#xA;  uint8_t pnum, pomask, pocode, potem, i, j, mul;&#xA;  uint8_t sampl[nsamp], pim[nbits], pat[nbits], bout=0, nat=0, pcon;&#xA;  char *c, cc;&#xA;  int usedPorts=0;  // To track which ports are done&#xA;  for (c=pinsList, counts[0]=pcon=0; *c; ++c) // Zero the counts array&#xA;    if (*c &amp;lt; '0' || *c &amp;gt; '9') counts[++pcon] = 0;&#xA;  // In each pass, group bit numbers by port and sample the port&#xA;  while (nat&amp;lt;pcon) { // Each loop pass sets one bit in usedPorts&#xA;    pnum = pocode = pomask = bout = pcon = 0;&#xA;    c = pinsList;&#xA;    while ((cc=*c++)) {  // Loop until c is at end of string&#xA;      if ('0' &amp;lt;= cc &amp;amp;&amp;amp; '9' &amp;gt;= cc) {&#xA;    pnum = 10*pnum + cc - '0';&#xA;    if ( *c &amp;lt; '0' || *c &amp;gt; '9') { // See if pin # is complete&#xA;      potem = digitalPinToPort(pnum);  // Get port #, in range 1 to 12&#xA;      if (!(usedPorts &amp;amp; (1&amp;lt;&amp;lt;potem))) { // Is potem's port already done?&#xA;        if (!pocode)           // If pocode not set, set it&#xA;          pocode = digitalPinToPort(pnum);&#xA;        if (pocode == potem) {  // Process pin if it's in current port&#xA;          pomask |= (pim[bout] = digitalPinToBitMask(pnum));&#xA;          pat[bout++] = pcon; // Save location of pin's bit in results&#xA;        }&#xA;      }&#xA;      pnum = 0; // Clear # accumulator&#xA;      ++pcon;   // Count pin numbers&#xA;    }&#xA;      }&#xA;    }&#xA;    // Now pomask is a mask for all bits to be read from port pocode&#xA;    // and we are ready to sample current port&#xA;    portSampler7(drivePin, pocode, pomask, preWait, sampl);&#xA;    usedPorts |= 1&amp;lt;&amp;lt;pocode;       // Mark the port finished&#xA;    // Count up # of zeroes (ie rise times) in sampled bits&#xA;    for (j=0; j&amp;lt;bout; ++j) {&#xA;      int count;&#xA;      uint8_t m=pim[j];&#xA;      for (count=i=0; i&amp;lt;nsamp; ++i)&#xA;    count += sampl[i] &amp;amp; m;&#xA;      counts[pat[j]] += nsamp - count/m;&#xA;    }&#xA;    nat += bout;        // Count number of pins done so far&#xA;  }&#xA;  return pcon;          // Return # of pins processed&#xA;}&#xA;//-----------------------------------------------------------&#xA;// secondly() will report counts at start-of-second&#xA;void secondly() {&#xA;  uint8_t counts[nbits], j, nc;&#xA;  if (millis()%1000) return;    // Wait for start-of-second&#xA;  nc = countPins7(4, &quot;2,3,5,6&quot;, counts, preSamp);&#xA;  Serial &amp;lt;&amp;lt; &quot;Counts: &quot;;&#xA;  for (j=0; j&amp;lt;nc; ++j)      // Marshal output&#xA;      Serial &amp;lt;&amp;lt; counts[j] &amp;lt;&amp;lt; &quot; &quot;;&#xA;  Serial &amp;lt;&amp;lt; &quot; t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; endl;&#xA;  while ((millis()%1000)==0) {}; // Await end-of-millisecond  &#xA;}&#xA;//-----------------------------------------------------------&#xA;uint8_t ostate[nbits] = {0};&#xA;void testChange1() {&#xA;  uint8_t counts[nbits], j, nc, s;&#xA;  nc = countPins7(4, &quot;2,3,5,6&quot;, counts, preSamp);&#xA;  for (j=0; j&amp;lt;nc; ++j) {&#xA;    s = counts[j] &amp;gt; IsHighCount;&#xA;    if (s ^ ostate[j]) {&#xA;      Serial &amp;lt;&amp;lt; j &amp;lt;&amp;lt; (s? &quot; on  &quot; : &quot; off &quot;) &amp;lt;&amp;lt; counts[j] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; endl;&#xA;      ostate[j] = s;&#xA;    }&#xA;  }&#xA;}&#xA;//-----------------------------------------------------------&#xA;void testChangeA() {&#xA;  uint8_t counts[nbits], j, k, nc, s;&#xA;  int sumcount[nbits]={0};&#xA;  for (k=0; k&amp;lt;SampleSets; ++k) {&#xA;    nc = countPins7(4, &quot;2,3,5,6&quot;, counts, preSamp);&#xA;    for (j=0; j&amp;lt;nc; ++j) {&#xA;      sumcount[j] += counts[j];&#xA;    }&#xA;  }&#xA;  for (j=0; j&amp;lt;nc; ++j) {&#xA;    s = sumcount[j] &amp;gt; IsHighTotal;&#xA;    if (s ^ ostate[j]) {&#xA;      Serial &amp;lt;&amp;lt; j &amp;lt;&amp;lt; (s? &quot; on  &quot; : &quot; off &quot;) &amp;lt;&amp;lt; sumcount[j] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; endl;&#xA;      ostate[j] = s;&#xA;    }&#xA;  }&#xA;}&#xA;//-----------------------------------------------------------&#xA;// Take samples of rise times at  designated pins.  When a pin's&#xA;// time changes from small to large, report rising edge; or &#xA;// when it changes from large to small, report falling edge.&#xA;void loop() {&#xA;  //secondly();&#xA;  //testChange1();&#xA;  testChangeA();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2015-12-27T22:54:45.213" LastActivityDate="2015-12-27T22:54:45.213" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19009" PostTypeId="1" CreationDate="2015-12-26T12:03:08.660" Score="1" ViewCount="805" Body="&lt;p&gt;I have got this LCD screen&#xA;&lt;a href=&quot;https://i.stack.imgur.com/FC87O.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FC87O.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to be able to decide every pixel status of the screen. Do I need to work directly with the buffer or is there another method?&lt;/p&gt;&#xA;" OwnerUserId="11152" LastActivityDate="2015-12-26T21:15:28.977" Title="Nokia 5110 Screen Pixel by Pixel" Tags="|programming|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19010" PostTypeId="2" ParentId="18135" CreationDate="2015-12-26T14:02:16.057" Score="1" Body="&lt;p&gt;A very useful macro is &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Types.h#L165&quot; rel=&quot;nofollow&quot;&gt;membersof&lt;/a&gt;().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define membersof(x) (sizeof(x) / sizeof(x[0]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will find in defined in large libraries and frameworks for C/C++. For your example above the number of elements is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int COMMAND_QUEUE_MAX = membersof(CommandQueue);&#xA;...&#xA;for (int i = 0; i &amp;lt; COMMAND_QUEUE_MAX; i++) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A dynamic set would require a max length and null terminated or simply a counter. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int COMMAND_QUEUE_MAX = ...;&#xA;char* CommandQueue[COMMAND_QUEUE_MAX] = { ....., NULL };&#xA;&#xA;for (char** cpp = CommandQueue; *cpp != NULL; cpp++) {&#xA;  char* name = *cp;&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or even better use a &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Queue.hh&quot; rel=&quot;nofollow&quot;&gt;Queue&lt;/a&gt; data type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Queue&amp;lt;char*, COMMAND_QUEUE_MAX&amp;gt; CommandQueue;&#xA;...&#xA;char* cp;&#xA;while (CommandQueue.dequeue(&amp;amp;cp)) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-26T14:19:37.073" LastActivityDate="2015-12-26T14:19:37.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19011" PostTypeId="2" ParentId="19009" CreationDate="2015-12-26T14:11:22.123" Score="5" Body="&lt;p&gt;The 5110 Nokia LCD display is based on &lt;a href=&quot;https://www.sparkfun.com/datasheets/LCD/Monochrome/Nokia5110.pdf&quot; rel=&quot;nofollow&quot;&gt;PCD8544&lt;/a&gt;. It is not possible to read the device display memory. The controller has only serial data input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically a graphical device driver for that display will use an offscreen bitmap (buffer). To check the pixel status you would need to check the status in the offscreen bitmap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some device drivers use only text and copy font bitmap directly to the display memory. In that case you cannot check the status of the pixel (if the text is not buffered). &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-26T21:15:28.977" LastActivityDate="2015-12-26T21:15:28.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19012" PostTypeId="1" CreationDate="2015-12-26T15:21:39.987" Score="0" ViewCount="1560" Body="&lt;p&gt;I have a Dallas Semiconductors 18B20 temperature sensor on a RobotLinking board. It's part of the &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B009OVGKTQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;RobotLinking 37 Sensors Kit&lt;/a&gt;. The board has a LED to indicate activity. It resembles this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hg7mY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hg7mY.jpg&quot; alt=&quot;sensor that is similar to mine&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what's weird. All the guides I can find for the 18B20 say that the pin order is GND, DQ, V&lt;sub&gt;DD&lt;/sub&gt;. That should mean pin 1 goes to GND, pin 2 goes to a GPIO, and pin 3 goes to 3.3V or 5V (this one can take either). Yes, I am looking at the sensor's pins from its bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do this, the board's LED is lit solidly. I get 0 degree readings, the same as if no device was connected. (Infinite resistance?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this work, and get valid temperature readings, I have to hook it up this way: sensor GND to the GPIO, sensor DQ to GND, and sensor V&lt;sub&gt;DD&lt;/sub&gt; to 5V or 3.3V. The LED only flashes when the temperature is actually read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a twist: if you look at the circuit traces on the RobotLinking board, it looks like the paths between the male breadboard connectors and the sensor's pins 2 and 3 are reversed. This means if you think you are connecting to pin 3 via the male connectors, you are in fact connecting to pin 2, and vice versa. The path from pin 1 on the sensor to the male pin 1 where it plugs into the breadboard is straight, so pin 1 probably means pin 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I described the above connections I made, I accounted for this apparent circuit pathing weirdness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another twist is in the manual, the sensor is soldered to the middle leads. My sensor is instead on the furthest leads from the pins, like in the attached image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manual with this kit didn't explain any of this. I'm at a loss to understand my observations. For a generic sensor kit for n00bs, why would one want the pins on the bottom of the circuit board not correspond to the pinout of the sensor?&lt;/p&gt;&#xA;" OwnerUserId="15877" LastActivityDate="2016-02-24T21:18:41.450" Title="RobotLinking 18B20 pinout and circuit board weirdness" Tags="|arduino-uno|sensors|temperature-sensor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19013" PostTypeId="2" ParentId="19012" CreationDate="2015-12-26T15:45:45.450" Score="1" Body="&lt;p&gt;From the look of the board, it is designed to support multiple devices. I'd suspect that the three sets of holes give different mappings of the device pins to the board pins. Could it be that the sensor is soldered into the wrong set of holes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a meter or can see the traces you could look to see if the middle set of holes is wired the way you would expect. If that is a photo of your board, it looks like you have enough length in the leads on the sensor to move it to the middle holes.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-26T15:45:45.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19014" PostTypeId="2" ParentId="3350" CreationDate="2015-12-26T16:36:20.920" Score="1" Body="&lt;p&gt;There is an on-target &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/Debug/Debug.hh&quot; rel=&quot;nofollow noreferrer&quot;&gt;debugger&lt;/a&gt; in &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cosa&lt;/a&gt; and a port of the library for &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Debug&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino/AVR&lt;/a&gt;. It allows conditional and unconditional break- and observation points, simple call back-trace, variable read, memory status check, memory dump, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QsIMN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QsIMN.png&quot; alt=&quot;Debug Demo Sketch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The debugger is implemented as a small command handler that is executed on the target (Arduino). A set of macros are used to mark break-points, variables to observe, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see the debugger &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Debug/blob/master/examples/DebugDemo/DebugDemo.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;demo sketch&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-27T15:55:15.903" LastActivityDate="2016-01-27T15:55:15.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19015" PostTypeId="2" ParentId="18997" CreationDate="2015-12-26T16:49:09.483" Score="1" Body="&lt;p&gt;BUFFER_LENGTH is set in &lt;a href=&quot;https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/I2Cdev/I2Cdev.h&quot; rel=&quot;nofollow&quot;&gt;I2Cdev.h&lt;/a&gt; depending on the target. BLE nano is not directly supported (what I can see). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-26T16:49:09.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19016" PostTypeId="1" CreationDate="2015-12-26T17:51:20.977" Score="1" ViewCount="389" Body="&lt;p&gt;I am seeing a &quot;blip&quot; in LED brightness when trying to fade a red LED on an Arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code demonstrates the &quot;blip&quot; seen in brightness right after a 254, 255, 0 sequence.  When the brightness is then set to 1, the actual brightness is much higher for a short period of time.  The blip is not seen during the entire delay interval, just at the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see the blip every time except for the very first cycle, before the 255 to 0 transition has ever happened.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best guess is that there is a PWM &quot;accumulation&quot; that is not seen when the brightness is set to zero, but it is used when the brightness is set to a non-zero value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; FadeBlip&#xA; Derived from Fade.ino.&#xA; */&#xA;&#xA;int led = 9;&#xA;int brightness = 0;&#xA;int fadeAmount = 1;&#xA;int skipBegin = 5;&#xA;int skipEnd = 254;&#xA;&#xA;// If you try a shorter delay, you must make the skip range smaller&#xA;// to pick out the blip.  If you try a longer delay, the blip is not&#xA;// as bright.&#xA;int delayms = 1000;&#xA;&#xA;void setup()  {&#xA;  pinMode(led, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  delay(1000);  // give us time to bring up serial monitor&#xA;}&#xA;&#xA;void loop()  {&#xA;  Serial.println(brightness);&#xA;  analogWrite(led, brightness);&#xA;&#xA;  brightness = brightness + fadeAmount;&#xA;&#xA;  // skip the boring middle values&#xA;  if (skipBegin &amp;lt; brightness &amp;amp;&amp;amp; brightness &amp;lt; skipEnd)&#xA;    brightness = skipEnd;&#xA;&#xA;  if (brightness &amp;gt; 255)&#xA;    brightness = 0;&#xA;&#xA;  delay(delayms);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15883" LastActivityDate="2016-01-09T17:32:58.630" Title="What causes a &quot;blip&quot; in LED brightness with sequence of 254, 255, 0, 1 brightness values?" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="1" ClosedDate="2016-01-21T20:45:58.037" ContentLicense="CC BY-SA 3.0" />
  <row Id="19018" PostTypeId="1" AcceptedAnswerId="19020" CreationDate="2015-12-26T19:19:13.897" Score="0" ViewCount="79" Body="&lt;p&gt;I plan to buy these 2 products to begin to play with arduino to learn.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.banggood.com/UNO-R3-ATmega328P-Board-2_4-Inch-TFT-LCD-Screen-Module-For-Arduino-p-945755.html&quot; rel=&quot;nofollow&quot;&gt;Board with LCD touch&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.banggood.com/Iduino-Yun-Shield-Expansion-Module-Board-Compatible-Arduino-p-979882.html&quot; rel=&quot;nofollow&quot;&gt;Yun board expansion&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have a mega 2560 which i bought with a starter kit and i love to play with. I have not played with the shield yet. I understand some shields can be used together, some not. and some with modification on the board and in the code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find pins specification for the touch screen and the support on the website doesn't respond. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If some one can help me find specifications for the touch screen, or help me choose some shields that will allow me to use a USB host, wifi, and a touchscreen it will be nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks all.&lt;/p&gt;&#xA;" OwnerUserId="15976" OwnerDisplayName="Benoit" LastEditorUserId="3150" LastEditDate="2016-01-02T19:37:52.133" LastActivityDate="2016-01-02T19:37:52.133" Title="arduino beginner documentation help" Tags="|arduino-mega|shields|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19019" PostTypeId="1" AcceptedAnswerId="19026" CreationDate="2015-12-26T21:47:45.837" Score="9" ViewCount="45361" Body="&lt;p&gt;For learning and hacking purposes, I plan to study and use parts from smartphones and tablets like Galaxy or iPhone. They are really efficient and pretty cheap...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did anybody do this before? If yes, can anybody tell me what kind of connector is this one on the galaxy camera, &lt;a href=&quot;https://www.ifixit.com/Store/Parts/Galaxy-Tab-S-10-5-Front-Facing-Camera-Wi-Fi/IF252-001-1&quot; rel=&quot;nofollow&quot;&gt;Galaxy Tab S 10.5 Front Facing Camera (Wi-Fi)&lt;/a&gt;, and whether it can be found for attaching it to an Arduino project? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Someone else asked a similar question here, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=269272.0&quot; rel=&quot;nofollow&quot;&gt;How to reuse quality camera from old / broken phone&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15886" LastEditorUserId="6936" LastEditDate="2016-01-01T14:13:33.837" LastActivityDate="2018-07-01T02:37:51.707" Title="Re-use smartphone/tablets parts like a camera" Tags="|hardware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19020" PostTypeId="2" ParentId="19018" CreationDate="2015-12-26T22:10:12.567" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;http://m.banggood.com/UNO-R3-ATmega328P-Board-2_4-Inch-TFT-LCD-Screen-Module-For-Arduino-p-945755.html&quot; rel=&quot;nofollow&quot;&gt;link you posted&lt;/a&gt; describes a TFT LCD Touch screen unit with the SPFD5408 controller, referenced in &lt;a href=&quot;http://m.instructables.com/id/How-to-use-24-inch-TFT-LCD-SPFD5408-with-Arduino-U/&quot; rel=&quot;nofollow&quot;&gt;this Instructable&lt;/a&gt; for use with the Mega. You might start there and migrate to the Yun once you get the screen working. &lt;/p&gt;&#xA;" OwnerUserId="14948" LastActivityDate="2015-12-26T22:10:12.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19021" PostTypeId="2" ParentId="19016" CreationDate="2015-12-26T22:21:58.500" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://arduino.stackexchange.com/q/17946&quot;&gt;Why does an LED sometimes flash when increasing brightness?&lt;/a&gt; question does exactly describe my problem (except for the substitution of pin 11 for pin 9).  That question refers to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=360468.msg2486781#msg2486781&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post at forum.arduino.cc&lt;/a&gt; which gives the beginnings of an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is caused by the fact that &lt;code&gt;analogWrite(led, 0)&lt;/code&gt; does not use PWM, it just sets the pin to LOW.  So when you call &lt;code&gt;analogWrite(led, 0)&lt;/code&gt;, the value in the Output Compare Register (OCR) is left at 255.  When you call &lt;code&gt;analogWrite(led, 1)&lt;/code&gt;, the OCR value is changed to 1, but due to double-buffering this doesn't take effect until the next timer cycle begins.  So for a fraction of the current timer cycle the output pin is left at HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to either avoid calling &lt;code&gt;analogWrite(led, 0)&lt;/code&gt; or to explicitly set the OCR value to 0 when &lt;code&gt;analogWrite(led, 0)&lt;/code&gt; is called.  This will only work if another call to &lt;code&gt;analogWrite()&lt;/code&gt; is not made in the current timer cycle.  Given that the default timer cycle takes 32 microseconds, this is unlikely to happen.  32 microseconds = 256 (ticks per timer cycle) / 16MHz (clock ticks per second) * 2 (default timer prescale factor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For pin 9, the solution was to add these lines immediately after the &lt;code&gt;analogWrite()&lt;/code&gt; call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (brightness == 0) {&#xA;    OCR1A = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For other pins, use the correct Output Compare Register.  For the Arduino UNO they are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-------------+----------+-------+&#xA;| Arduino Pin | Chip Pin | OCR   |&#xA;+-------------+----------+-------+&#xA;|           3 |        5 | OCR2B |&#xA;|           5 |       11 | OCR0B |&#xA;|           6 |       12 | OCR0A |&#xA;|           9 |       15 | OCR1A |&#xA;|          10 |       16 | OCR1B |&#xA;|          11 |       17 | OCR2A |&#xA;+-------------+----------+-------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course this solution will need to be modified if you have changed anything related to timers such as the PWM mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution given by the forum.arduino.cc post indicated that the Timer/Counter Control Register (TCCR) needed to be modified in addition to setting the OCR value.  This modification was to configure the PWM mode, but the PWM mode would have already been correctly configured by any previous call to &lt;code&gt;analogWrite()&lt;/code&gt; for that pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Others have suggested that calling &lt;code&gt;analogWrite(led, 1)&lt;/code&gt; before &lt;code&gt;analogWrite(led, 0)&lt;/code&gt; would be a simpler solution, but that still results in a flash, albeit shorter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Resources:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LED fade malfunction (random flash) (forum.arduino.cc/index.php?topic=360468.msg2486781)&lt;/li&gt;&#xA;&lt;li&gt;hardware/arduino/cores/avr/arduino/wiring_analog.c&lt;/li&gt;&#xA;&lt;li&gt;Secrets of Arduino PWM (www.righto.com/2009/07/secrets-of-arduino-pwm.html).  There is a more recent copy of this article at arduino.cc (www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM), but that copy has the useful graphics stripped out.&lt;/li&gt;&#xA;&lt;li&gt;Arduino Timers and Interrupts (arduino-info.wikispaces.com/Timers-Arduino)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15883" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-09T17:32:58.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19022" PostTypeId="2" ParentId="18983" CreationDate="2015-12-26T22:28:35.640" Score="1" Body="&lt;p&gt;I ended up contacting the developer of the embedXcode plugin. He was very helpful and provided the fix within a day. The cause of the issue is apparently the Arduino IDE has changed its library structure in the latest release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next version of embedXcode (release 4.1.4.) will include a fix for this, however if you can't wait until then you need to open ArduinoAVR_165.mk (located in the Makefiles group in Xcode) in your project and add the following line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/src/$(BUILD_CORE),$(APP_LIBS_LIST)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After you add this line, the file should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Two locations for Arduino libraries&#xA;#&#xA;APP_LIB_PATH = $(APPLICATION_PATH)/libraries&#xA;APP_LIB_PATH += $(APPLICATION_PATH)/hardware/arduino/$(BUILD_CORE)/libraries&#xA;&#xA;avr165_20 = $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%,$(APP_LIBS_LIST)))&#xA;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/utility,$(APP_LIBS_LIST)))&#xA;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/src,$(APP_LIBS_LIST)))&#xA;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/src/utility,$(APP_LIBS_LIST)))&#xA;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/src/$(BUILD_CORE),$(APP_LIBS_LIST)))&#xA;avr165_20 += $(foreach dir,$(APP_LIB_PATH),$(patsubst %,$(dir)/%/src/arch/$(BUILD_CORE),$(APP_LIBS_LIST)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that each project has its own ArduinoAVR_165.mk file, so you will have to make this change in each project until you update to the new release.&lt;/p&gt;&#xA;" OwnerUserId="15798" LastEditorUserId="15798" LastEditDate="2015-12-27T00:39:24.967" LastActivityDate="2015-12-27T00:39:24.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19023" PostTypeId="1" CreationDate="2015-12-26T23:57:55.957" Score="2" ViewCount="37" Body="&lt;p&gt;How does one modify the Bluetooth settings, like services or pincode, on a light blue bean?&#xA;Ps I'm on Android&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://legacy.punchthrough.com/bean/&quot; rel=&quot;nofollow&quot;&gt;http://legacy.punchthrough.com/bean/&lt;/a&gt; if you don't know what I'm talking about&lt;/p&gt;&#xA;" OwnerUserId="4664" LastEditorUserId="4664" LastEditDate="2015-12-27T01:32:13.657" LastActivityDate="2015-12-27T01:32:13.657" Title="Lightblue Bean BTLE tinkering" Tags="|bluetooth|atmega328|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19024" PostTypeId="1" AcceptedAnswerId="19037" CreationDate="2015-12-27T00:04:18.363" Score="0" ViewCount="574" Body="&lt;p&gt;I was wondering what carriers are compatible with a sim900 breakout board. I know it needs a GSM network (AT&amp;amp;T,T-mobile,?) but what networks can I use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs a 850/ 900/ 1800/ 1900 MHz frequency to work but who offers that frequency? I personally could not find what frequency cell phone companies offered. From how I understand it is that T-Mobile definitely will work.I have heard several different answers about companies like AT&amp;amp;T and I have seen discussion about sprint (which I don't understand because they are a CDMA carrier). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also heard that there are other carriers (Vondafone, nextel,Ting) that might be more cost effective for people like me who are only going to be using the text messaging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please set me straight on who I can use. &lt;/p&gt;&#xA;" OwnerUserId="8167" LastEditorUserId="8167" LastEditDate="2015-12-27T00:24:50.517" LastActivityDate="2015-12-28T13:02:36.280" Title="What phone carriers are available in the USA that are compatible with a sim900 breakout board" Tags="|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19025" PostTypeId="1" AcceptedAnswerId="72171" CreationDate="2015-12-27T07:30:02.693" Score="0" ViewCount="2880" Body="&lt;p&gt;So there is this pretty generic part of my project that involves triggering an ISR that will flip a boolean value. I have set up the software side like so: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  attachInterrupt(digitalPinToInterrupt(2), displayConvergence, FALLING);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(flashConvergence) {&#xA;    //Do stuff that takes several seconds &#xA;    delay(3000);&#xA;    flashConvergence = false;&#xA;  }&#xA;}&#xA;&#xA;void displayConvergence() {&#xA;  if (!flashConvergence) {&#xA;    flashConvergence = true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The schematic is as follows:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZE3pg.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fZE3pg.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the behavior of my circuit surprised me as the pin interrupt would get triggered randomly at a frequency at (guessing here) 3 times a second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Weird, I thought. I fiddled around and found that when the boost converter's 180V is not connected to any load, the interrupt service triggers as expected, as in it starts working correctly. So I thought perhaps the issue was some noise introduced by the boost converter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified the circuit by adding a capacitor across the switch: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/adfpO.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fadfpO.png&quot;&gt;simulate this circuit&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried 1 uF at first, but that didn't help and neither did 10 uF. However, when I tried 100 uF (I thought decoupling capacitors are usually 0.1uF to 1 uF, is the value I am using too big?), things seem to be working as expected with the exception that when I hold the switch in the closed position for a long time, then let it go back in the open position, the interrupt service can be triggered randomly for a short period right after I let go of the switch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my initial assumption that the ISR is triggering randomly due to EMI from the boost converter correct? Perhaps there are other causes I am not looking at? Is there a way to make this work 100% (as in solve the issue right after the switch is put in the open position)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="2815" LastEditorUserId="4131" LastEditDate="2015-12-29T04:29:00.000" LastActivityDate="2020-01-30T03:31:49.580" Title="Hardware Interrupt Triggered Randomly" Tags="|interrupt|isr|timing|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19026" PostTypeId="2" ParentId="19019" CreationDate="2015-12-27T08:28:46.913" Score="9" Body="&lt;p&gt;The connector on the flex circuit from that camera was made by Hirose (it has an HRS logo on it), and might be in the BM10, BM14, or BM20 series.  You can measure the pin spacing, stacking height, etc. to check which series it's in.  For example, the &lt;a href=&quot;http://www.mouser.com/new/hiroseconnector/hirose-BM14-b2b-b2fpc-connectors/&quot;&gt;Hirose BM14 series&lt;/a&gt; of FPC to board connectors has pins at 0.4 mm Pitch and 0.8 stacking height.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mouser.com/ProductDetail/Hirose-Connector/BM14B08-24DS-04V53/?qs=sGAEpiMZZMvffgRu4KC1R8YV3BvcJQGKbUaU25rr%252bdwhFlq%2fl3Wjjw%3d%3d&quot;&gt;Mouser.com&lt;/a&gt; carries a 24-pin BM14 connector that might mate or match with the pictured connector.  For other photos of Hirose FPC connectors, see &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1095&amp;amp;bih=609&amp;amp;q=hirose+fpc&amp;amp;oq=hirose+fpc&amp;amp;gs_l=img.3..0i24l2.2328.4678.0.5124.10.9.0.1.1.0.102.604.8j1.9.0....0...1ac.1.64.img..0.10.604.S8xAzOt5A_8&quot;&gt;google images for &lt;strong&gt;hirose fpc&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While you probably can find a matching connector (via careful measurement and perhaps some trial and error) and build an interface, it may be difficult to use the camera once it's hooked up.  Most Arduino models have too little RAM to support image processing.  A Yun might do it, a Tre, or some other micro entirely, eg Beagle or Raspberry.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2015-12-27T08:28:46.913" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19027" PostTypeId="2" ParentId="19025" CreationDate="2015-12-27T11:03:24.583" Score="-1" Body="&lt;p&gt;An alternative approach is to detach the interrupt handler and use the internal pullup instead of external resistor (and capacitor).  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int BUTTON = 2;&#xA;volatile bool flashConverage = false;&#xA;&#xA;void setup() &#xA;{&#xA;  setmode(BUTTON, INPUT_PULLUP);&#xA;  attachInterrupt(digitalPinToInterrupt(BUTTON), displayConvergence, FALLING);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (!flashConvergence) return;&#xA;&#xA;  // Do stuff that takes several seconds &#xA;  delay(3000);&#xA;  flashConvergence = false;&#xA;  attachInterrupt(digitalPinToInterrupt(BUTTON), displayConvergence, FALLING);       &#xA;}&#xA;&#xA;void displayConvergence() &#xA;{&#xA;  detachInterrupt(digitalPinToInterrupt(BUTTON));&#xA;  flashConvergence = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The processing (&quot;stuff that takes several seconds&quot;) will debounce the button (or at least ignore it :). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-27T18:40:24.787" LastActivityDate="2015-12-27T18:40:24.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19028" PostTypeId="1" AcceptedAnswerId="19029" CreationDate="2015-12-27T16:22:59.653" Score="1" ViewCount="4851" Body="&lt;p&gt;I am looking for a Bluetooth Low Energy (BLE) device that could send live sensor data from Arduino to iOS custom apps, not the app that is already in the app store. I would like to create my own apps to receive the sensor data. Or are there any other ways to achieve it? &lt;/p&gt;&#xA;" OwnerUserId="15898" LastEditorUserId="3917" LastEditDate="2015-12-27T17:15:58.907" LastActivityDate="2015-12-27T18:43:56.593" Title="How to Send Live Sensor Data to iOS Custom Apps with BLE" Tags="|arduino-uno|bluetooth|communication|mac-os|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19029" PostTypeId="2" ParentId="19028" CreationDate="2015-12-27T17:59:09.033" Score="1" Body="&lt;p&gt;I would expect this to be pretty straight forward. Off hand, I can't think of anything that would be a major roadblock to creating your iOS apps. It seems like there are two problems you'll need to solve:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Finding a BLE chip that is relatively easy to integrate with an Arduino, and&lt;/li&gt;&#xA;&lt;li&gt;Selecting the tools that you'll use on the iOS side to develop your app.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since I haven't done this my self, I started off looking on the Arduino side – mostly because it seemed like the problems there would be larger. I searched on Google using the terms:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;aruduino ble&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found quite a few candidates that look promising, here are some of the better ones:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/product/1697&quot; rel=&quot;nofollow&quot;&gt;Bluefruit LE - Bluetooth Low Energy (BLE 4.0) - nRF8001 Breakout - v1.0&lt;/a&gt; – I put this one on the top of my list because the price is pretty reasonable (&amp;lt; $20 US) and Adafruit tends to do a good job of supporting their products with tutorials and at least a basic library that demonstrates the functionality of the device.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://redbearlab.com/bleshield/&quot; rel=&quot;nofollow&quot;&gt;Redbear Labs&lt;/a&gt; - I don't know anything about Redbear, but they do well in Google searches and appear to have several products, including a BLE shield, that might do what you want.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://bleduino.cc&quot; rel=&quot;nofollow&quot;&gt;BLEduino&lt;/a&gt; - this is a Kickstarter, and while it looks interesting, a &lt;em&gt;very&lt;/em&gt; quick investigation didn't reveal a source where you can buy one.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The choice of devices will partly depend on what your ultimate goal is. Something like the BLEduino will give you an all-in-one package to build your project around. The downside of this is that you may be spending money on functionality that you don't need/want to duplicate. A breakout board like the Bluefruit LE gives you a smaller device and possibly more flexibility at the expense a bit more work to get up and running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you'll need to select development tools. I started by searching with the terms:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ble swift ios&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got a number of promising results, including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.raywenderlich.com/85900/arduino-tutorial-integrating-bluetooth-le-ios-swift&quot; rel=&quot;nofollow&quot;&gt;Arduino Tutorial: Integrating Bluetooth LE and iOS with Swift&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/bluetooth/&quot; rel=&quot;nofollow&quot;&gt;Apple: Bluetooth for Developers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/introduction-to-bluetooth-low-energy&quot; rel=&quot;nofollow&quot;&gt;Adafruit - Introduction to Bluetooth Low Energy&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These first three look like good starting points for &quot;getting your bearings,&quot; the following two are specific to actual boards.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout&quot; rel=&quot;nofollow&quot;&gt;Getting Started with the nRF8001 Bluefruit LE Breakout&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/RedBearLab/iOS&quot; rel=&quot;nofollow&quot;&gt;RedBearLab/iOS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-27T17:59:09.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19031" PostTypeId="1" CreationDate="2015-12-28T00:19:15.203" Score="-1" ViewCount="906" Body="&lt;p&gt;I have a remote control that has an STM32 MCU and sends data via NRF24L01. What I would like to do is clone the data sent when buttons are pressed by reading what is being sent to the RF24 and then replicating these messages with my own &quot;remote&quot;.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried sniffing the data wirelessly with my Pro Mini and NRF24L01. I have everything plugged in correctly, the BasicExample seems to be running fine, but when I run a promiscuous channel activity sniffer, I don't get any wireless data, not even running wifi and bluetooth near the NRF. Pro Mini is 5V and NRF sniffer is powered by an external 3.5V battery with cap on VCC-GND, ground is common to Pro Mini. I have also tried the WireShark approach, but with 0 packets found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I want to try it directly wired to the remote. I don't have a logic analyzer handy. How would I read the data? By just connecting MISO and CS to an arduino and running an SPI reader? What would be the best way to do this? I have the Pro Mini and many Teensy boards ready.&lt;/p&gt;&#xA;" OwnerUserId="11249" LastActivityDate="2015-12-28T00:58:26.020" Title="Reading SPI between an MCU and NRF24L01" Tags="|arduino-pro-mini|spi|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19032" PostTypeId="2" ParentId="19031" CreationDate="2015-12-28T00:50:07.113" Score="1" Body="&lt;p&gt;That was an interesting challenge. There are some obstacles to consider when trying to use RF sniffing:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What channel is used? (128)&lt;/li&gt;&#xA;&lt;li&gt;What bit-rate is used? (250K-1M-2M)&lt;/li&gt;&#xA;&lt;li&gt;How many address bytes? (3-5 byte)&lt;/li&gt;&#xA;&lt;li&gt;How many bits in CRC? (1-2 byte)&lt;/li&gt;&#xA;&lt;li&gt;Auto-Acknowledgement? (1 bit)&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Without any info on the remote NRF &lt;a href=&quot;http://www.nordicsemi.com/eng/content/download/2730/34105/file/nRF24L01_Product_Specification_v2_0.pdf&quot; rel=&quot;nofollow&quot;&gt;configuration&lt;/a&gt; this is tedious to break. Probing the hardware signals (MISO, MOSI, SCK, SS) on the remote NRF chip with a logic analyzer seems (much) easier. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-28T00:58:26.020" LastActivityDate="2015-12-28T00:58:26.020" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19033" PostTypeId="1" CreationDate="2015-12-28T03:50:24.203" Score="2" ViewCount="239" Body="&lt;p&gt;I have an Arduino based board using ATmega168PB, but so far only Atmel's provided toolchain supports this microcontroller. I can download the toolchain from Atmel's website, but I am not sure how to make the Arduino environment use it.&lt;/p&gt;&#xA;" OwnerUserId="15903" LastEditorUserId="6936" LastEditDate="2016-01-02T19:38:59.830" LastActivityDate="2016-01-02T19:38:59.830" Title="How can I make Arduino IDE use Atmel's provided toolchain? (Linux/Ubuntu)" Tags="|arduino-ide|compile|ubuntu|avr-toolchain|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19034" PostTypeId="2" ParentId="19033" CreationDate="2015-12-28T04:52:32.770" Score="3" Body="&lt;p&gt;In the directory for the new core create a new &lt;code&gt;platform.txt&lt;/code&gt; and give the entry for &lt;code&gt;compiler.path&lt;/code&gt; the location of the &lt;code&gt;bin/&lt;/code&gt; directory containing the Atmel toolchain.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;compiler.path=/path/to/bin/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2015-12-28T04:52:32.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19035" PostTypeId="2" ParentId="18575" CreationDate="2015-12-28T06:01:33.010" Score="1" Body="&lt;p&gt;I had lot of problems as well. In my case problems are almost solved by switching from SoftwareSerial to &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt;. It seemed that on the Uno the standard software serial library was not working for me. After switching I started to get results back for the first time. (I also used level shifting and external power supply for 3.3V)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;And by almost solved I mean - I still get, from time to time, gibberish on the terminal. So even AltSoftSerial isn't a perfect solution. &#xA;I was using the ESP-07 with a 115200 bps data rate.   &lt;/p&gt;&#xA;" OwnerUserId="15906" LastEditorUserId="3917" LastEditDate="2016-01-01T17:58:38.067" LastActivityDate="2016-01-01T17:58:38.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19036" PostTypeId="2" ParentId="19001" CreationDate="2015-12-28T07:53:29.797" Score="1" Body="&lt;p&gt;The error message is telling you that avrdude failed to open the device and read the modem status (basically the information about whether a device is present and ready on a serial line). The most likely causes of this are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using the wrong serial port (Tools &gt; Port in the Arduino IDE).&lt;/li&gt;&#xA;&lt;li&gt;The IDE not recognizing the board.&lt;/li&gt;&#xA;&lt;li&gt;Using a power only USB cable.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE seems to remember the device that your board was last connected through, but on some Unix flavored OSes the device name depends, in part, on method of connection – which port, hub or no hub, etc. So if you change the board or the port you plug it into, the name changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the very first thing to do is to look under  Tools &gt; Port in the Arduino IDE to see if there is another device present. Also confirm that you're using a USB cable with data wires. There are &quot;power only&quot; USB cables…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that, check to see if the OS sees the board. On OS X you would go to the Apple menu and choose About this Mac and then look at at the System Report to see what devices have been detected on your USB busses. I'd be surprised if there wasn't something similar on Linux (and Windows too for that matter). If you're comfortable on the command line you could look in &lt;code&gt;/dev&lt;/code&gt; for devices with similar names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the board is present, but not seen by the Arduino IDE, try restarting the IDE and/or plugging and unplugging the USB cable. Sometimes it helps to plug the cable into a different port.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-28T07:53:29.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19037" PostTypeId="2" ParentId="19024" CreationDate="2015-12-28T13:02:36.280" Score="1" Body="&lt;p&gt;SIM900 should be compatible with both AT&amp;amp;T and T-Mobile. T-Mobile uses 1900Mhz for 2G and AT&amp;amp;T uses 850Mhz and 1900Mhz. Although both carriers are upgrading to 4G, they still support 2G devices. My personal experience is that most quadband 2G devices still work with AT&amp;amp;T and T-Mobile and there is no technical reason why SIM900 shouldn't work. However, there can be issues with incompatible data plans that are compatible only with their own devices. You need to be careful when selecting the contract and buying the sim card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nextel and Ting uses Sprint's network which is CDMA and thus wouldn't work. However Vodafone seems to be using T-Mobile's network and may work. &lt;/p&gt;&#xA;" OwnerUserId="15519" LastActivityDate="2015-12-28T13:02:36.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19038" PostTypeId="1" AcceptedAnswerId="19039" CreationDate="2015-12-28T15:42:50.857" Score="0" ViewCount="169" Body="&lt;p&gt;I'd like to measure the voltage at a test point on a stepper motor driver chip with an arduino. The voltage at this point controls the amperages to the phase coils and is adjusted to trim the driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a common ground with the driver already, I'd like to wire the drivers v-ref point to an analog input to drive an LCD showing the output amp number so I can adjust the driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I am worried about is that with the hardware I have to test with a properly trimmed driver is pushing 0.84A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this safe to do without killing the arduino board? &lt;/p&gt;&#xA;" OwnerUserId="253" LastActivityDate="2015-12-28T16:24:41.680" Title="Measuring voltage on an analog pin - What do I need to know about amperage?" Tags="|arduino-uno|analogread|voltage-level|safety|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19039" PostTypeId="2" ParentId="19038" CreationDate="2015-12-28T16:04:43.553" Score="3" Body="&lt;p&gt;Yes. The only thing you need to be concerned about is the voltage. It needs to be less than the Arduino Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage sense circuit (analog inputs) typically have a high impedance and should draw a negligible current from the circuit being sensed. I didn't have much luck finding the actual spec for any of the AVR chips, but I did find &lt;a href=&quot;https://electronics.stackexchange.com/questions/67171/input-impedance-of-arduino-uno-analog-pins&quot;&gt;this answer to the question&lt;/a&gt; on Electronics.StackExchange – where they say &quot;hard to tell, the specs are incomplete, but 10 KΩ seems like a reasonable guesstimate/assumption&quot; (I paraphrase). The reasoning is interesting and worth a read.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2015-12-28T16:24:41.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19040" PostTypeId="1" CreationDate="2015-12-28T16:52:42.047" Score="2" ViewCount="784" Body="&lt;p&gt;Hi I was looking to interface Teensy++ 2.0 with MPU6050 for a simple IMU project.&#xA;I have done this previously using Teensy 3.1 by trying the project of &lt;a href=&quot;https://github.com/kriswiner/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;kriswiner&lt;/a&gt; however I also wanted to try it out on my Teensy++ 2.0 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I went to check the pin assignments for Teensy++ 2.0 on the &lt;a href=&quot;https://www.pjrc.com/teensy/pinout.html&quot; rel=&quot;nofollow&quot;&gt;pjrc&lt;/a&gt; website it has been mentioned that the pins PD0 and PD1 can be used as SDA and SCL using &lt;a href=&quot;https://www.pjrc.com/teensy/card4a.pdf&quot; rel=&quot;nofollow&quot;&gt;C Language&lt;/a&gt; but there is no assignment of SDA SCL on Teensy ++ 2.0 using &lt;a href=&quot;https://www.pjrc.com/teensy/card4b.pdf&quot; rel=&quot;nofollow&quot;&gt;Arduino Software&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that mean we cannot use these pins using Arduino software at all? Or is there a workaround to this?&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2015-12-28T16:52:42.047" Title="Teensy 2.0++ SDA SCL pins not accesible using ARDUINO software" Tags="|serial|c|softwareserial|mpu6050|teensy|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19041" PostTypeId="1" CreationDate="2015-12-28T17:11:44.200" Score="0" ViewCount="1978" Body="&lt;p&gt;I want to extract an AT command's response (via serial port) to find out if the GPS shield is working as it should be. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  if(Serial.available()&amp;gt;1){&#xA;     String response = Serial.read();&#xA;     Serial.println(response);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Normally the response to AT is OK but it keeps telling me that it cannot convert &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;String&lt;/code&gt; .... can someone help?&lt;/p&gt;&#xA;" OwnerUserId="15914" LastEditorUserId="3917" LastEditDate="2016-01-01T17:49:31.370" LastActivityDate="2016-01-01T17:49:31.370" Title="Read a String from serial to debug the AT commands sent to my GPS shield" Tags="|arduino-uno|serial|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19042" PostTypeId="2" ParentId="19041" CreationDate="2015-12-28T17:28:43.103" Score="0" Body="&lt;p&gt;Serial.read() returns a byte (a single character), you've told the compiler that response is a string. It doesn't know how to deal with the difference…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want to do it to read the response in a loop until you've got it all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an &lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-28T17:28:43.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19043" PostTypeId="1" AcceptedAnswerId="19046" CreationDate="2015-12-27T13:07:20.277" Score="3" ViewCount="1688" Body="&lt;p&gt;I want to build a contraption using an arduino that allows me to turn off my light from across the room. I plan to use a solenoid to move the lights switch up and down. I'm sure I'll have some specific questions later on but to start with, has anybody made or seen a similar project? All I'm really looking for is a link to a project (unless you're willing to give advice/suggestions). Thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="James M. " LastActivityDate="2015-12-28T18:00:15.993" Title="Link to an project for remotely turning off light switch?" Tags="|home-automation|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19044" PostTypeId="2" ParentId="19043" CreationDate="2015-12-27T13:27:57.627" Score="0" Body="&lt;p&gt;Various types of light switch actuators. Which is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ktgaq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ktgaq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MXlcq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MXlcq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5LTJu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5LTJu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RpkjO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RpkjO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CBpja.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CBpja.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CcyUO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CcyUO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GLrAY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GLrAY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XhUn2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XhUn2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15149" OwnerDisplayName="Michael Karas" LastActivityDate="2015-12-27T13:40:35.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19045" PostTypeId="2" ParentId="19043" CreationDate="2015-12-27T13:35:42.720" Score="2" Body="&lt;p&gt;This isn't exactly what you asked for, but may be a better idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Light switches are electrically just switches.  Either two points are connected or they are not.  In this case they are meant to be mechanically actuated by humans.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of making a electrically controlled contraption that mechanically activates the existing switch, you could more easily use a electrically-activated switch directly.  Such things are called &lt;i&gt;relays&lt;/i&gt;, and are quite common and readily available.  You can easily get a relay that can be actuated from 5 V that can switch 120 or 240 Vac at a few amps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the relay in parallel across the switch if you want the switch to be able to override the light on, and in series if you want the switch to be able to override the light off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To allow both the relay and the switch to toggle the light on/off independently, each needs to be a SPDT (single pole double throw) switch or relay.  Actually, you'll have a hard time finding a relay that isn't at least SPDT.  Ordinary wall switches aren't, but ones meant for multiple switches to control the same light are, like you often find at the top and bottom of the same set of stairs.&lt;/p&gt;&#xA;" OwnerDisplayName="Olin Lathrop" LastActivityDate="2015-12-27T13:35:42.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19046" PostTypeId="2" ParentId="19043" CreationDate="2015-12-27T14:24:58.033" Score="1" Body="&lt;h3&gt;MicroBot Push: a robotic finger for your buttons...&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/64zRC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/64zRC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.indiegogo.com/projects/microbot-push-a-robotic-finger-for-your-buttons#/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.indiegogo.com/projects/microbot-push-a-robotic-finger-for-your-buttons#/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The Robotoic Light Switch&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k7xM7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k7xM7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://hackaday.com/2015/11/06/the-robot-light-switch/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://hackaday.com/2015/11/06/the-robot-light-switch/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Wifi controlled light switch&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/20BQY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/20BQY.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://hackaday.io/project/5141-wifi-controlled-light-switch&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://hackaday.io/project/5141-wifi-controlled-light-switch&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7859" OwnerDisplayName="bigjosh" LastActivityDate="2015-12-27T14:24:58.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19047" PostTypeId="1" CreationDate="2015-12-28T20:12:39.607" Score="1" ViewCount="1133" Body="&lt;p&gt;I'd like to be able to measure the position of my garage door. Determining if the garage door is fully open or fully closed should be fairly simple with some magnetic reed switches but I'd like to know the position of the door when it's partially open/closed. &lt;/p&gt;&#xA;" OwnerUserId="15915" LastActivityDate="2016-12-19T02:49:19.027" Title="Options for measuring position of garage door" Tags="|sensors|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19048" PostTypeId="2" ParentId="19047" CreationDate="2015-12-28T22:00:59.253" Score="2" Body="&lt;p&gt;A couple of possibilities occur to me. One would be to mount a rotary encoder on a rotating part of the door. Another would be to attach a reed switch to the track and a series of magnets to the door. I suppose you could do something with a proximity sensor as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much precision do you need in the position of the door? What do you know that is deterministic? For example is the door transit time predictable? Is it a positive drive? Do you get to know when the door starts moving? That might be enough right there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can say more about what you're trying to do it would make it easier to provide suggestions and insight. &lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-28T22:00:59.253" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19049" PostTypeId="1" AcceptedAnswerId="19063" CreationDate="2015-12-28T23:14:50.467" Score="2" ViewCount="3224" Body="&lt;p&gt;I'm using my ATmega328P to sample an analog signal in free running mode. The ADC clock frequency is set to ÷128. I've read that a single analog conversion lasts 13 clock cycles. I would like to know if the number of clock cycles changes if I make the ADC trigger an interrupt after every conversion (ADIE bit set to one). Or will the ADC still use 13 clock cycles and start again on the 14th?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If ADIE is set to zero (no interrupts) will the result of the conversion still be written to ADCL and ADCH? And at what time of the 13 clock cycles is this result written to those registers? This is important to me so I can calculate how much time I have to read those registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be possible to set ADIE to zero and instead use a timer interrupt to read ADCL and ADCH every ~1 millisecond. Or am I missing something important?&lt;/p&gt;&#xA;" OwnerUserId="15919" LastActivityDate="2015-12-29T09:29:37.673" Title="Arduino Uno ADC behavior in free running mode" Tags="|atmega328|analogread|adc|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19050" PostTypeId="2" ParentId="19041" CreationDate="2015-12-28T23:15:58.123" Score="2" Body="&lt;p&gt;&lt;code&gt;if (Serial.available() &amp;gt; 1)&lt;/code&gt; is wrong. Always use &lt;code&gt;if (Serial.available())&lt;/code&gt; in such cases. Also it seems you are communicating with the GPS shield using Hardware Serial. However, the Arduino also uses the same serial port for communicating with the PC via the USB connection. So what you have basically is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino TX, PC RX and GPS RX are all connected&lt;/li&gt;&#xA;&lt;li&gt;Arduino RX, PC TX and GPS TX are all connected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So anything the Arduino writes to the Serial port using &lt;code&gt;Serial.println()&lt;/code&gt; is received by both the PC and the GPS shield. And the other hand, responses from the GPS shield and commands sent from the serial monitor all arrive at the same Arduino pin. So when you use &lt;code&gt;Serial.read()&lt;/code&gt;, assuming you used the serial monitor to send the command, you will end up receiving your own command (like some sort of echo), and according to your program, you use &lt;code&gt;Serial.println()&lt;/code&gt; to send the command again which is received by both PC and GPS shield, with the GPS shield responding to the same command again. All undesirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TLDR; use SoftwareSerial instead for the GPS shield. Connect the GPS shield TX to pin 2 and its RX to pin 3 and use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;    SoftwareSerial gps(2,3);   // pin 2 = RX, pin 3 = TX&#xA;&#xA;    void setup(){&#xA;        Serial.begin(57600);&#xA;        gps.begin(57600);    // change to your baud rate, if not auto-baud &#xA;    }&#xA;&#xA;    void loop(){&#xA;        while (Serial.available())     //used to send commands from PC&#xA;            gps.write(Serial.read());   // to gps&#xA;        while (gps.available())        // used to read responses from gps&#xA;            Serial.write(gps.read());  // to PC&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the Arduino forwards everything it receives from the PC monitor (commands) to the shield and sends everything it receives from the shield (responses) to the PC to be displayed in the serial monitor. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-28T23:15:58.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19051" PostTypeId="2" ParentId="13317" CreationDate="2015-12-28T23:39:12.847" Score="1" Body="&lt;p&gt;I think this is the correct way to create an array of C strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char * hvacSystems[] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;};&#xA;    int activeSystem = 0;  &#xA;    char * displayActiveSystem = hvacSystems[activeSystem]; &#xA;&#xA;    if(systemNeedsToBeCycled){&#xA;        activeSystem++;    // make sure to set a bound for this variable&#xA;        displayActiveSystem = hvacSystems[activeSystem]; &#xA;        tft.print(displayActiveSystem);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since strings are basically stored as char pointers so an array of strings is an array of char * variables. Or you could create an array of Arduino strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    String hvacSystems[] = {&quot;Off&quot;, &quot;Fan&quot;, &quot;Cool&quot;, &quot;Heat&quot;};&#xA;    int activeSystem = 0;  &#xA;    String displayActiveSystem = hvacSystems[activeSystem]; &#xA;&#xA;    if(systemNeedsToBeCycled){&#xA;        activeSystem++;    // make sure to set a bound for this variable&#xA;        displayActiveSystem = hvacSystems[activeSystem]; &#xA;        tft.print(displayActiveSystem);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-28T23:39:12.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19052" PostTypeId="1" CreationDate="2015-12-29T01:21:44.110" Score="2" ViewCount="211" Body="&lt;p&gt;I am trying to use a for loop for getting readings on two parallax ping sensors and want to find the difference between both readings.&lt;/p&gt;&#xA;&lt;p&gt;But am having trouble doing so. Whenever I declare &lt;code&gt;print ping(1)&lt;/code&gt;, I don't actually get the value of ping(1). &lt;em&gt;How can I have two variables for ping(0) and ping(1)&lt;/em&gt; that I can call whenever I want and have them be accurate.&lt;/p&gt;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int ultraSoundSignalPins[] = {5,7}; &#xA;int tx = 4;&#xA;char *pingString[] = {&amp;quot;Ping1 &amp;quot;,&amp;quot;Ping2 &amp;quot;}; // just something to print to indicate direction&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA; unsigned long ultrasoundValue;&#xA; for(int i=0; i &amp;lt; 2; i++)&#xA; {&#xA;   ultrasoundValue = ping(i);&#xA;   Serial.print(pingString[i]);&#xA;   Serial.print(ultrasoundValue);&#xA;   Serial.print(&amp;quot;cm, &amp;quot;);    &#xA;   delay(500);&#xA;  &#xA; }&#xA;} &#xA;&#xA;//Ping function&#xA;unsigned long ping(int i)&#xA;{&#xA; unsigned long echo;&#xA;&#xA; pinMode(ultraSoundSignalPins[i], OUTPUT); // Switch signalpin to output&#xA; pinMode(tx, OUTPUT);          &#xA; digitalWrite(ultraSoundSignalPins[i], LOW); // Send low pulse&#xA; digitalWrite(tx, LOW); &#xA; delayMicroseconds(2); // Wait for 2 microseconds&#xA; digitalWrite(ultraSoundSignalPins[i], HIGH); // Send high pulse&#xA; digitalWrite(tx, HIGH);&#xA; delayMicroseconds(5); // Wait for 5 microseconds&#xA; digitalWrite(ultraSoundSignalPins[i], LOW); // Holdoff&#xA; pinMode(ultraSoundSignalPins[i], INPUT); // Switch signalpin to input&#xA; digitalWrite(ultraSoundSignalPins[i], HIGH); // Turn on 0pullup resistor&#xA; echo = pulseIn(ultraSoundSignalPins[i], HIGH); //Listen for echo&#xA; return (echo / 29.1); //convert to CM then to inches&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-07-24T09:00:17.210" Title="Declaring Variables in a For Loop" Tags="|sensors|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="19053" PostTypeId="2" ParentId="19047" CreationDate="2015-12-29T04:45:54.887" Score="2" Body="&lt;p&gt;I would suggest an Ultrasonic Range Finder. There is an example in the Arduino Tutorials and they are available cheaply on ebay. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2015-12-29T04:45:54.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19054" PostTypeId="2" ParentId="18903" CreationDate="2015-12-29T04:56:47.223" Score="1" Body="&lt;p&gt;From your diagram, you appear to be using an ESP8266-01?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another &lt;a href=&quot;https://github.com/ekstrand/ESP8266wifi&quot; rel=&quot;nofollow&quot;&gt;ESP8266 AT command library&lt;/a&gt; that may be of interest/use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the AT command libraries are very dependent on the version of the firmware that you have on the device.  Depending on when/where you bought the device, this firmware will vary significantly.  I've not had any of the libraries work correctly with current versions of the firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the &lt;code&gt;AT+GMR&lt;/code&gt; at command (using your serial terminal) to determine the firmware version.  If you're on Windows/PC updating the firmware to a previous version (the 0.9.x.x range seems to be the most stable according to my research) is relatively straightforward.  If you're on Mac, it's not as straightforward...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Official/current release of the firmware is available from &lt;a href=&quot;https://github.com/espressif/ESP8266_AT&quot; rel=&quot;nofollow&quot;&gt;Espressif's Github repo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plenty of directions on the net for getting firmware onto the ESP8266 for both Mac and Windows/PC.  YMMV as to their accuracy/ease of use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that different versions of the firmware default to different baud rates.  Some default to 115200, others to 9600.  If you decide to use SoftwareSerial (rather than Serial, which your diagram suggests is what you're currently using) you'll need it to run on 9600.  I've not personally tested what Serial supports up to (but my understanding is that you can run up to 115200). Note that there are different commands for setting the ESP8266 AT command firmware baud rate depending on the firmware version/supplier.  The official SDK uses the &lt;code&gt;AT+IPR=9600&lt;/code&gt; command.  This stores the baud rate to the device (i.e. you don't need to send it every time, just once and it's then persistent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you haven't already, I'd recommend you get the system working with a simple serial terminal program (CoolTerm, for example) before getting into Arduino-land.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the ESP8266 does not reliably run from the 3v3 power rail on the Arduino. The ESP8266 requires up to 300mA, the Arduino is capability of around 50mA to my understanding.  Symptoms of insufficient power include random resetting of the device.  Best to run a separate 3v3 source to the ESP, or if you have a strong enough 5v supply, use a step-down converter.  Your diagram indicates you're using a standard Arduino, which runs 5v out of the serial pins (or digital outs), but your comments indicate you're running 3v3 (which means you're probably running a 3v3 Pro Mini or similar)?  If you're not running a 3v3 device, you'll definitely need to run a 5v-3v3 logic level converter (I can't link to examples due to not having enough reputation points—but these are relatively easy to get from SparkFun or similar.  I picked up a combined step-down converter with logic level converter which does both tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, If you don't need the ADC from the Arduino device for your application (which it sounds like you don't given your project description) I'd &lt;strong&gt;strongly&lt;/strong&gt; recommend you reconsider the advice from gmag11 and yeti re: running Arduino on the ESP8266.  It is much more stable, and the extra SRAM will make a big difference with processing/building HTTP request strings etc.  I wasted a &lt;em&gt;lot&lt;/em&gt; of time (unsuccessfully) trying to get AT commands working before switching to Arduino on the ESP8266, which has been a breeze by comparison.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2015-12-29T04:56:47.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19055" PostTypeId="2" ParentId="18575" CreationDate="2015-12-29T06:36:47.157" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does anyone know if what I am trying to do is possible?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Absolutely possible :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And if it is, what am I doing wrong?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial isn't capable of 115200 baud rate (despite &quot;allowing&quot; this as a setting).  Some reports suggest as high as 57600 is workable, though in my experience 9600 is best for reliability.  How to change the baud rate on the ESP8266 will depend on the firmware version.  I've had success with &lt;code&gt;AT+IPR=9600&lt;/code&gt;.  You only need to run this command once (it's a persistent setting).  I'd suggest, based on your description, that this is the most likely culprit that's causing the &quot;garbage&quot; output you describe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of other notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The ESP8266 runs on 3v3, not 5v, so you shouldn't have it directly connected to the digital pins—you need to run through a logic level converter.  Running 5v can fry your ESP8266.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino's 3v3 output has insufficient current to support the ESP8266 reliably (50mA Arduino vs up to 300mA for the ESP8266 by some accounts)—try running the ESP8266 off a separate supply.  It probably won't affect simple commands like &lt;code&gt;AT&lt;/code&gt; but when you try to connect to a network etc. it may cause unexpected device resets.&lt;/li&gt;&#xA;&lt;li&gt;As noted by others, you need to send \r\n — so make sure your Serial window is set to send both (this is a drop-down in the serial window)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2015-12-29T06:36:47.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19056" PostTypeId="2" ParentId="18106" CreationDate="2015-12-29T06:41:16.343" Score="11" Body="&lt;p&gt;As noted by Matt, the baud rate for the ESP8266 can vary depending on the firmware version/manufacturer.  9600 and 115200 are the most common.  If you can connect using a serial terminal program (like CoolTerm) you can then test the baudrate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like the ESP8266 is set to 115200, but in my experience (and others') SoftwareSerial isn't capable of 115200 baud rate (despite &quot;allowing&quot; this as a setting). Some reports suggest as high as 57600 is workable, though in my experience 9600 is best for reliability.  But you can reset this and see what the max reliable value is for you in your configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to change the baud rate on the ESP8266 will depend on the firmware version. I've had success with &lt;code&gt;AT+IPR=9600&lt;/code&gt;. You only need to run this command once (it's a persistent setting). I'd suggest, based on your description, that this is the most likely culprit that's causing the intermittent &quot;garbage&quot; output you describe.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2015-12-29T06:41:16.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19057" PostTypeId="2" ParentId="16380" CreationDate="2015-12-29T06:49:54.153" Score="1" Body="&lt;p&gt;You mention:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;connecting GPIO0 and GPIO2 to to Vcc or ground&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've had success with this sequence:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GPIO0 to gnd (and hold momentarily)&lt;/li&gt;&#xA;&lt;li&gt;RST to gnd (then let go, while holding GPIO0 to gnd)&lt;/li&gt;&#xA;&lt;li&gt;let go of GPIO0 from gnd (e.g. let it float again)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To do a firmware flashing, you need to hold GPIO0 to ground for the duration of the flashing process, so the sequence would be slightly different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this just prior to &quot;build and upload&quot; in the Arduino IDE—provided the build process doesn't take too long.  It will sometimes still fail, in which case reset the ESP8266 (RST to gnd momentarily) and restart the sequence. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a little test/development harness (like this one &lt;a href=&quot;http://www.buildcircuit.com.au/esp8266-test-board&quot; rel=&quot;nofollow&quot;&gt;http://www.buildcircuit.com.au/esp8266-test-board&lt;/a&gt;) is very handy for doing this repeatedly.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2015-12-29T06:49:54.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19059" PostTypeId="1" AcceptedAnswerId="19066" CreationDate="2015-12-29T07:52:04.267" Score="4" ViewCount="2967" Body="&lt;p&gt;I bought a &lt;code&gt;USB Nano V3.0 ATmega328 16M 5V Micro-controller CH340G board For Arduino&lt;/code&gt; and tried it with Arduino 1.6.6 on my MacBook Pro running OS X 10.11.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB serial could not be seen. I searched on the web and found a few posts about this board, and downloaded &lt;a href=&quot;http://www.wch.cn/download/CH341SER_MAC_ZIP.html&quot; rel=&quot;nofollow&quot;&gt;http://www.wch.cn/download/CH341SER_MAC_ZIP.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the instructions were in Chinese, but the driver &lt;code&gt;CH341SER_MAC.ZIP 资料类型：应用资料 资料大小：250KB 资料版本：1.1 更新时间：2013-12-25&lt;/code&gt; seemed to install, but I cannot seem to find any &lt;code&gt;/dev/tty&lt;/code&gt; and Arduino can't see any serial ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone had any success with this. (The seller has sold 18000 of these so someone may have got it working.)&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-09-27T12:24:45.323" Title="Problem with serial driver for CH340G board" Tags="|serial|arduino-nano|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19060" PostTypeId="2" ParentId="8347" CreationDate="2015-12-29T08:07:09.640" Score="0" Body="&lt;p&gt;Decoupling capacitors do help, as mentioned in the other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, to get a good reading, after powering up your digital pin 4, a delay of maybe 100-500ms may be required to allow the DHT22 to stabilize. For better results, you can also perform multiple readings (call delay(dht.getMinimumSamplingPeriod()) between the readings) and average them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you are using an Arduino Uno. For further power savings, you might consider using a Pro Mini and performing &lt;a href=&quot;http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/&quot; rel=&quot;nofollow&quot;&gt;some hardware modifications&lt;/a&gt;. For software power saving techniques, there is no better resource than Nick Gammon's &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11497&quot; rel=&quot;nofollow&quot;&gt;Power saving techniques for microprocessors&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15819" LastActivityDate="2015-12-29T08:07:09.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19061" PostTypeId="1" CreationDate="2015-12-29T08:44:41.260" Score="0" ViewCount="546" Body="&lt;p&gt;&lt;sup&gt;(I am professionally a software guy working in the &lt;a href=&quot;http://gcc.gnu.org&quot; rel=&quot;nofollow&quot;&gt;GCC&lt;/a&gt; compiler with &lt;a href=&quot;http://gcc-melt.org/&quot; rel=&quot;nofollow&quot;&gt;MELT&lt;/a&gt;, so I am fluent in software, but much less in hardware - I did use a solder for a 74LS00 nand gate based stuff in the 1990s. This is my first Arduino project)&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first Arduino project would be to automate the lights and the fan in my inhouse WC toilet in Paris (France) suburb. I bought several Arduino Nano v3 boards. I'm thinking of driving with a relay a low voltage 12v LED lightbubble. I want to detect human presence in the toilets. I'm thinking of some PIR sensor, but I am afraid that PIR won't detect anything if the temperature is above 37°C (or about 100F), which is unusual in Paris (France) but may happen a few days per year (I've got no air conditioning). Is my worry correct, or can a PIR still work with very warm outside temperature? Should I use an ultrasound detector instead?&lt;/p&gt;&#xA;" OwnerUserId="12068" LastEditorUserId="37523" LastEditDate="2019-11-29T20:52:16.783" LastActivityDate="2019-11-29T20:52:16.783" Title="detecting presence inside - PIR or ultrasound?" Tags="|sensors|arduino-nano|gcc|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19062" PostTypeId="2" ParentId="19061" CreationDate="2015-12-29T08:52:30.933" Score="3" Body="&lt;p&gt;PIR sensors work fine and are probably easier to program for than ultrasonic sensors. For example, this tutorial on a PIR sensor sold by &lt;a href=&quot;https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit&lt;/a&gt; has a &lt;a href=&quot;https://learn.adafruit.com/system/assets/assets/000/010/134/original/RE200B.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; at the bottom that says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Operating Conditions Operating Temperature -20 ˚C to +70 ˚C&lt;/p&gt;&#xA;&lt;p&gt;Storage Temperature -30 ˚C to +80 ˚C&lt;/p&gt;&#xA;&lt;p&gt;Operating Voltage 3 to 10 V at Rs = 47 kΩ&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You can try to find and check the datasheet for the sensor you intend to purchase to determine if it will work.&lt;/p&gt;&#xA;" OwnerUserId="15819" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-29T08:52:30.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19063" PostTypeId="2" ParentId="19049" CreationDate="2015-12-29T09:29:37.673" Score="2" Body="&lt;p&gt;You may want to take a look at Amanda Ghassaei's &lt;a href=&quot;http://www.amandaghassaei.com/projects/arduinodsp/&quot; rel=&quot;nofollow&quot;&gt;tutorials on Arduino DSP techniques&lt;/a&gt; or the &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFHT&quot; rel=&quot;nofollow&quot;&gt;FFT/FHT&lt;/a&gt; code at the Open Music Labs. Both use the Arduino ADC in free running mode. Amanda's code uses interrupts, the Open Music Lab code sits in a tight loop waiting for the conversion to complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the Open Music Lab code I can say, yes, the conversion is still written to ADCL and ADCH regardless of the interrupt setting in ADIE. I can't tell from your question how concerned you are about cycle counts, but I don't think you'd see a significant change using interrupts (I'd expect it to be zero). But using interrupts you'll take a hit as you enter and return from the ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned in the comment, take a look at Amanda Ghassaei's code. She toggles pin 12 which creates a spike in the trace if you have a scope attached to pin 12 (or a logic analyzer). That will give you a very easy way to determine the actual time to handle the conversion.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-29T09:29:37.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19064" PostTypeId="1" AcceptedAnswerId="19068" CreationDate="2015-12-29T10:51:09.793" Score="0" ViewCount="420" Body="&lt;p&gt;I'm a newbie in Arduino and I bought an Arduino Mega instead of the Uno. I want to know what the so-called additional i/o pins do. Are they the same with PWM and SPI? What can they do?&lt;/p&gt;&#xA;" OwnerUserId="15926" LastEditorUserId="4628" LastEditDate="2016-01-01T17:39:07.623" LastActivityDate="2019-06-10T20:25:30.643" Title="Use of additional i/o ports in Arduino Mega" Tags="|arduino-mega|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19065" PostTypeId="2" ParentId="19061" CreationDate="2015-12-29T10:58:31.920" Score="1" Body="&lt;p&gt;One thing to be wary of with PIR sensors is that they only detect &lt;em&gt;moving&lt;/em&gt; heat.  That means that your light would turn on as you enter the toilet, but would turn off again when the sensor fails to detect movement.  That will be once you're sat on the toilet and reading the newspaper.  To keep the light on you would need to flail your arms around to keep the sensor on, and thus the light on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So from that perspective alone the ultrasound would possibly be a better option since it can detect the presence of anything within its cone of sound - as long as that something is big enough, like a human body.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third option that you haven't mentioned is infra-red beams.  Depending on how big the toilet is you may be able to just have one IR beam passing through the room, and when someone is in the room that beam will be broken.  Only works in small cubicles though.  For larger rooms you may need either a mesh of beams to cover the whole room, or a dual-beam in-out counting arrangement on the entrance (two beams, one before the other. If beam A breaks before beam B then someone has entered - if beam B breaks before beam A then someone has left. When there are 0 people in the room then turn the light off).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-29T10:58:31.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19066" PostTypeId="2" ParentId="19059" CreationDate="2015-12-29T11:07:59.650" Score="6" Body="&lt;p&gt;Using different search criteria I found &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This indicated a newer driver for OSX 10.9 and above at:-&#xA;&lt;a href=&quot;http://kiguino.moos.io/downloads/CH34x_Install.zip&quot; rel=&quot;nofollow&quot;&gt;http://kiguino.moos.io/downloads/CH34x_Install.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is now working OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS This was probably a Mac question, but I will answer as it is mainly of interest to Arduino users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PPS The board worked on my Raspberry Pi which had the driver installed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WARNING&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The driver worked on &lt;code&gt;OS X 10.11&lt;/code&gt; but after upgrading to &lt;code&gt;OS X 10.11.2&lt;/code&gt; when I plug the USB cable into the Mac it causes a crash. This may or may not be related to the upgrade but after this happened twice I gave up.&lt;/h2&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="3879" LastEditDate="2016-01-10T01:47:26.017" LastActivityDate="2016-01-10T01:47:26.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19067" PostTypeId="2" ParentId="19064" CreationDate="2015-12-29T11:15:07.027" Score="1" Body="&lt;p&gt;Additional I/O pins means more inputs and outputs. Therefore, you can have more signals. There are also some more specialized pins. For example, there are more PWM pins, more TX and RX pins for serial communication and more analog read pins.&lt;/p&gt;&#xA;" OwnerDisplayName="user15297" LastActivityDate="2015-12-29T11:15:07.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19068" PostTypeId="2" ParentId="19064" CreationDate="2015-12-29T12:02:20.000" Score="0" Body="&lt;p&gt;&lt;strong&gt;Firstly some background info on the Arduino Mega:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't used the Mega, but I've used the Uno, and have worked with a variety of ATmega microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First thing you need to know is that the Arduino Mega (or any other Arduino) is a board that uses the Atmel ATmega microcontrollers. The specific microcontroller used on the Mega is the &lt;strike&gt;ATmega1280&lt;/strike&gt; ATmega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you are keen to learn more about your Arduino, a good place would be to look at the datasheet of the microcontroller itself. Just google &lt;strike&gt;ATmega1280&lt;/strike&gt; ATmega2560 datasheet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this might be a fair bit complicated, since you are new to the Arduino and microcontroller world. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good place to start would be the Arduino website itself (but I suppose you've already looked at it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now, regarding your question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you are referring to as &quot;additional i/o pins&quot;, but here's a quick rundown on what I/O pins are and used for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you may know I/O pins are used by the microcontroller to talk to the outside world. On the ATmega chips, most of these are GPIOs (General Purpose I/Os) that can be programmed to receive or send digital signals. Of these GPIOs some are used for PWM, and some may be used for some communication protocol. And of course there are analog input &amp;amp; reference pins, voltage supply, ground etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find all this information in the datasheet I linked above. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are curious how Arduino has routed the pins, you can have a look at the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-mega-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic of the Arduino Mega&lt;/a&gt; here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you also have a look at the Arduino website, they have a very good description on what each pin does: &lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardMega&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mega&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at &quot;Inputs and Outputs&quot;.&lt;/p&gt;&#xA;" OwnerUserId="15928" LastEditorUserId="27346" LastEditDate="2019-06-10T20:25:30.643" LastActivityDate="2019-06-10T20:25:30.643" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19069" PostTypeId="1" AcceptedAnswerId="19070" CreationDate="2015-12-29T12:22:23.490" Score="0" ViewCount="1234" Body="&lt;p&gt;I'm struggling with my first steps with Python and PySerial. I have one Arduino which reads impulses from an electricity power meter, passes the counts over to another Arduino over an RF link and then sends the data over to an Raspberry Pi. The Arduino to Arduino communication works well. However the last step of passing this to the RPi fails. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MeterValue from the Arduino side is an unsigned Long (32 bits) and therefore split in 4 pieces of 8-bit transmissions plus a frame start and frame end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0x01] Frame start&#xA;[0xMeterValueByte0]&#xA;[0xMeterValueByte1]&#xA;[0xMeterValueByte2]&#xA;[0xMeterValueByte3]&#xA;[0x04] Frame end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my Arduino code continuously sent to the RPi in debug purpose : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;//static test loop&#xA;Serial.write(0x01); //start frame&#xA;Serial.write(0x00);&#xA;Serial.write(0x00);&#xA;Serial.write(0x02);&#xA;Serial.write(0x04); //end frame&#xA;delay(3000);&#xA;&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my Python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Import serial&#xA;ser = serial.Serial('/dev/ttyACM0',9600)&#xA;print(&quot;Connected to: &quot; + ser.portstr)&#xA;&#xA;inputbuffer=[]&#xA;inputbuffer = [0 for i in range(10)]&#xA;&#xA;while True: &#xA;    if ser.inWaiting() &amp;gt; 0:&#xA;        inputbuffer = ser.read(1)&#xA;        print &quot;Byte received&quot;&#xA;        print &quot;Inputbuffer[0]: &quot; + hex(ord(inputbuffer[0]))&#xA;&#xA;        j = inputbuffer[0]&#xA;        print &quot;j= &quot; + hex(ord(j))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This check of the &quot;j&quot; parameter somehow fails:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        if (j == 0x1): #look for start of frame&#xA;            print &quot;Start found\n&quot;&#xA;            print &quot;Filling buffer\n&quot;&#xA;            while ser.inWaiting() &amp;lt; 5: #hold here until 5 bytes arrived&#xA;                pass #proceed here&#xA;            inputbuffer +=ser.read(5) #read 5 bytes&#xA;&#xA;            if inputbuffer[5] == 4: #check that the message has frame end&#xA;                RXval = inputbuffer[1]&#xA;                RXval |= (inputbuffer[2] &amp;lt;&amp;lt; 8)&#xA;                RXval |= (inputbuffer[3] &amp;lt;&amp;lt; 16)&#xA;                RXval |= (inputbuffer[4] &amp;lt;&amp;lt; 24)&#xA;                print &quot;RXval: &quot;, RXval&#xA;            else:&#xA;                print &quot;RX error, no frame end\n&quot;&#xA;        inputbuffer = []&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the Python output: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connected to: /dev/ttyACM0&#xA;Byte received&#xA;Inputbuffer[0]: 0x1&#xA;j= 0x1&#xA;Byte received&#xA;Inputbuffer[0]: 0x0&#xA;j= 0x0&#xA;Byte received&#xA;Inputbuffer[0]: 0x0&#xA;j= 0x0&#xA;Byte received&#xA;Inputbuffer[0]: 0x2&#xA;j= 0x2&#xA;Byte received&#xA;Inputbuffer[0]: 0x4&#xA;j= 0x4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then it repeats. Obviously the Python code doesn't realize j == 1. How should I handle the checking of the received bytes?&lt;/p&gt;&#xA;" OwnerUserId="15931" LastActivityDate="2015-12-29T14:42:47.310" Title="Python PySerial with Arduino fails byte check" Tags="|serial|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19070" PostTypeId="2" ParentId="19069" CreationDate="2015-12-29T12:31:17.947" Score="2" Body="&lt;p&gt;I think the problem is that you can't count ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spot the difference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0: [0x01] Frame start&#xA;1: [0xMeterValueByte0]&#xA;2: [0xMeterValueByte1]&#xA;3: [0xMeterValueByte2]&#xA;4: [0xMeterValueByte3]&#xA;5: [0x04] Frame end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0: Serial.write(0x01); //start frame&#xA;1: Serial.write(0x00);&#xA;2: Serial.write(0x00);&#xA;3: Serial.write(0x02);&#xA;4: Serial.write(0x04); //end frame&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your receiver is looking for a pattern of 6 bytes, but your Arduino sketch is only sending a pattern of 5 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your check for the start character is simple enough - you solved it fine a few lines above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;print &quot;j= &quot; + hex(ord(j))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you forgot to do something similar for the check:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (j == 0x1):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should really be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (ord(j) == 0x1):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2015-12-29T14:42:47.310" LastActivityDate="2015-12-29T14:42:47.310" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19072" PostTypeId="1" CreationDate="2015-12-29T16:45:56.583" Score="1" ViewCount="707" Body="&lt;p&gt;Can a teensy 3.2 deliver enough power to properly activate multiple servos by chance?&lt;/p&gt;&#xA;" OwnerUserId="13691" LastActivityDate="2015-12-31T14:35:59.127" Title="How much power can the Teensy 3.2 deliver to external components?" Tags="|power|teensy|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19073" PostTypeId="2" ParentId="19072" CreationDate="2015-12-29T17:21:58.837" Score="2" Body="&lt;p&gt;No.  You should provide your own regulator or supply for the servos specified voltage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be an original design, or an off-the-shelf &quot;battery eliminator&quot; intended for an R/C vehicle of similar needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the teensy regulator's maximum input voltage is fairly low, and may be in the range of what more powerful servos expect, ie, you might be able to run the teensy regulator off of the servo supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to consider the possibility of brownouts - multiple active or stalled servos can consume a lot of power, and if your upstream supply is not &quot;stiff&quot; enough this can result in the voltage dropping low enough that control electronics misoperate or reset - granted that is less likely with the teensy than with a 5v MCU using a regulator with a higher voltage dropout.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2015-12-31T14:35:59.127" LastActivityDate="2015-12-31T14:35:59.127" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19074" PostTypeId="1" AcceptedAnswerId="19086" CreationDate="2015-12-29T19:19:21.450" Score="1" ViewCount="7590" Body="&lt;p&gt;I have a SIM 800L module which I am using to send /receive SMS calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just wanted to know whether there is any library suitable for the SIM800 for arduino. I don't need GPRS functionality . I see mostly the arduino shield library but not sure whether it works with the SIM800 module bought from aliexpress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me in get me a library which can be used for the SIM800 .I have tried a lot but not getting a simple library for the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actual Issue :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to make it work with the AT commands using the Serial3 in the arduino MEGA. But when i started integrating with the existing project of ESP8266 and DS3231 somehow the Serial3 read() is not working properly. I tested with Serial3.readString()/ Serial3.read() and all. The CNMI for the SIM800 is 2,3,0,0 which is to direct the incoming message to the Terminal.&#xA;If my project is having a simple loop with only Serial3.read, then all messages contents are read properly. If I include the other Serial2 readings which is for the ESP8266, then I am not able to read the full messages from Serial3.I have tried with timer to read serial from the Serial3 for 3-5 secs but now way it is working.&lt;/p&gt;&#xA;" OwnerUserId="15823" LastActivityDate="2015-12-30T01:02:49.840" Title="SIM800 or SIM900 library for Arduino" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19075" PostTypeId="1" CreationDate="2015-12-29T19:27:11.870" Score="1" ViewCount="309" Body="&lt;p&gt;I am an absolute beginner with electronics and Arduino.&#xA;I have this hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;arduino uno&lt;/li&gt;&#xA;&lt;li&gt;xbee shield 1.1&lt;/li&gt;&#xA;&lt;li&gt;wee wifi chip&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've tried to make them work (to connect my Uno to the Internet) but I can't find the right tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there good resources I should look at, or do you know how set this up?&lt;/p&gt;&#xA;" OwnerUserId="15943" LastEditorUserId="3917" LastEditDate="2016-01-01T17:57:06.887" LastActivityDate="2016-01-01T17:57:06.887" Title="How to setup Uno + xbee shield 1.1 + wee wifi chip?" Tags="|arduino-uno|xbee|web-service|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19076" PostTypeId="1" CreationDate="2015-12-29T19:47:21.117" Score="0" ViewCount="965" Body="&lt;p&gt;My goal is to store the variable in the for loop as an array rather than as a single 'ultrasoundValue'. Can some one help me structure the code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have this code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ultraSoundSignalPins[] = {5,7}; &#xA;int tx = 4;&#xA;char *pingString[] = {&quot;Ping1 &quot;,&quot;Ping2 &quot;}; // just something to print to             indicate direction&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA; unsigned long ultrasoundValue;&#xA; for(int i=0; i &amp;lt; 2; i++)&#xA; {&#xA;   ultrasoundValue = ping(i);&#xA;   Serial.print(pingString[i]);&#xA;   Serial.print(ultrasoundValue);&#xA;   Serial.print(&quot;cm, &quot;);    &#xA;   delay(500);&#xA;&#xA; }&#xA;} &#xA;&#xA;//Ping function&#xA;unsigned long ping(int i)&#xA;{&#xA; unsigned long echo;&#xA;&#xA; pinMode(ultraSoundSignalPins[i], OUTPUT); // Switch signalpin to output&#xA; pinMode(tx, OUTPUT);          &#xA; digitalWrite(ultraSoundSignalPins[i], LOW); // Send low pulse&#xA; digitalWrite(tx, LOW); &#xA; delayMicroseconds(2); // Wait for 2 microseconds&#xA; digitalWrite(ultraSoundSignalPins[i], HIGH); // Send high pulse&#xA; digitalWrite(tx, HIGH);&#xA; delayMicroseconds(5); // Wait for 5 microseconds&#xA; digitalWrite(ultraSoundSignalPins[i], LOW); // Holdoff&#xA; pinMode(ultraSoundSignalPins[i], INPUT); // Switch signalpin to input&#xA; digitalWrite(ultraSoundSignalPins[i], HIGH); // Turn on 0pullup resistor&#xA; echo = pulseIn(ultraSoundSignalPins[i], HIGH); //Listen for echo&#xA; return (echo / 29.1); //convert to CM then to inches&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15032" LastActivityDate="2015-12-29T20:05:28.737" Title="Declare for loop as an array of variables" Tags="|array|" AnswerCount="2" CommentCount="0" ClosedDate="2016-01-21T20:48:42.437" ContentLicense="CC BY-SA 3.0" />
  <row Id="19077" PostTypeId="2" ParentId="19076" CreationDate="2015-12-29T19:49:20.293" Score="0" Body="&lt;p&gt;Make &lt;code&gt;ultrasoundValue&lt;/code&gt; an array and use &lt;code&gt;i&lt;/code&gt; as the index to it? Just like you have with all your other arrays?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You obviously know how to use arrays, since you have already been using them throughout your code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-29T19:49:20.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19078" PostTypeId="1" AcceptedAnswerId="19085" CreationDate="2015-12-29T20:00:46.137" Score="5" ViewCount="2312" Body="&lt;p&gt;The SoftwareSerial library has a built-in &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerialOverflow&quot; rel=&quot;noreferrer&quot;&gt;Overflow&lt;/a&gt; function, but the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;noreferrer&quot;&gt;Serial&lt;/a&gt; library does not.  Is there a simple way to check for a data buffer overflow on a hardware serial port?&lt;/p&gt;&#xA;" OwnerUserId="15942" LastActivityDate="2015-12-30T00:37:09.050" Title="HardwareSerial - check for overflow" Tags="|serial|softwareserial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19079" PostTypeId="2" ParentId="19076" CreationDate="2015-12-29T20:05:28.737" Score="1" Body="&lt;p&gt;You don't even have to add any lines, just modify a couple!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long ultrasoundValue [2]; //creates an array of unsigned longs of size 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and inside your for loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ultrasoundValue[i] = ping(i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It appears you are acquiring 2 separate ultrasound values. If you'd like to store multiple sets of these 2 values, you could use a two-dimensional array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long ultrasoundValue [10][2]; //an array of 10 pairs of long unsigned values&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and you could modify your for loop to have a pair of nested for loops:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for (int i = 0; i &amp;lt; 10; i++)&#xA; {&#xA;   for (int j = 0; j &amp;lt; 2; j++)&#xA;   {&#xA;      ultrasoundValue[i][j] = ping(j);&#xA;      //do whatever else&#xA;   }&#xA; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2015-12-29T20:05:28.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19082" PostTypeId="2" ParentId="19059" CreationDate="2015-12-29T21:06:16.440" Score="3" Body="&lt;p&gt;The CH340 is a chip with notoriously iffy driver support, definitely for OS X, and reportedly also for Windows. Some driver authors are not very fond of it, as evidenced by this &lt;a href=&quot;http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/uchcom.c?rev=1.13&amp;amp;content-type=text/x-cvsweb-markup&amp;amp;only_with_tag=MAIN&quot; rel=&quot;nofollow&quot;&gt;affectionate comment&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * driver for WinChipHead CH341/340, the worst USB-serial chip in the world.&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the upside, the chip costs an order of magnitude less than the commonly used FTDI chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen drivers from 3 sources:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The manufacturer drivers work off and on. The ones on the official site are not signed, and at some point, they started causing kernel panics for me.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://codebender.cc&quot; rel=&quot;nofollow&quot;&gt;Codebender&lt;/a&gt; team is including free CH340 drivers in their installer, and I've had some success running those, although I'm having some difficulties with the latest version. YMMV.&lt;/li&gt;&#xA;&lt;li&gt;So far, the drivers developed by &lt;a href=&quot;https://www.mac-usb-serial.com&quot; rel=&quot;nofollow&quot;&gt;Repleo&lt;/a&gt; have been rock solid for me. These are commercial, but, at less than $10, a pretty good deal in my opinion.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="353" LastActivityDate="2015-12-29T21:06:16.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19083" PostTypeId="2" ParentId="18928" CreationDate="2015-12-29T21:14:17.820" Score="1" Body="&lt;p&gt;The problem was solved with a &quot;soft restart&quot; loop. Posts #10 and #11 are all I needed:&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=49581.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=49581.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2015-12-29T21:14:17.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19084" PostTypeId="1" CreationDate="2015-12-30T00:29:41.077" Score="0" ViewCount="437" Body="&lt;p&gt;The Arduino Uno (for some models) has the ability to dislodge its IC chip. You can mount this on a piece of perfboard and, in essence, have a permanent connection. I will need the beefier Arduino Due, but I do not know how to make permanent connections with this device. Is there any way to form some kind of permanent connection with this board?&lt;/p&gt;&#xA;" OwnerUserId="13691" LastEditorUserId="19721" LastEditDate="2016-03-30T13:26:27.043" LastActivityDate="2016-12-26T01:11:56.020" Title="Permanent connections with Arduino Due" Tags="|arduino-due|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19085" PostTypeId="2" ParentId="19078" CreationDate="2015-12-30T00:37:09.050" Score="6" Body="&lt;p&gt;A look at &lt;code&gt;HardwareSerial_private.h&lt;/code&gt; shows incoming bytes are always read (interrupt-based), regardless of what your code is doing. So we can't set up a hardware interrupt to notify us when the chip's RX register has overflowed, because such an interrupt would depend on overflow flags but these flags never become set because, like I said, bytes are always read. It also shows that while all incoming bytes are read, not all are added to the 64-byte Serial buffer i.e. a byte may be read but if the buffer is full, nothing else happens; it is simply read to clear hardware flags. So the only (direct) way I can think of is to constantly poll &lt;code&gt;Serial.available()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt; to check if the number of bytes available for reading is equal to 64. If this condition yields TRUE, then you may safely conclude that the Serial buffer is full and about to overflow. This should suffice:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void loop(){&#xA;        //your code&#xA;        if (Serial.available() == SERIAL_RX_BUFFER_SIZE){ // Just to be general, 64 bytes in most cases&#xA;            //buffer is overrun, do what u will&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could make some changes to &lt;code&gt;HardwareSerial_private.h&lt;/code&gt; to get something like the overflow() method of SoftwareSerial. The relevant lines are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (i != _rx_buffer_tail) {    &#xA;        _rx_buffer[_rx_buffer_head] = c;&#xA;        _rx_buffer_head = i;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The snippet above ensures that the current write position is not equal to the tail of the ring buffer (i.e. if we are about to overwrite a character in the buffer), before writing the incoming byte to the buffer. An &lt;code&gt;else&lt;/code&gt; block could be added to set some global variable to indicate overflow. This global variable would have to be cleared when &lt;code&gt;Serial.read()&lt;/code&gt; is called.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-30T00:37:09.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19086" PostTypeId="2" ParentId="19074" CreationDate="2015-12-30T01:02:49.840" Score="1" Body="&lt;p&gt;Most likely, the Serial3 buffer is being overrun because you are not reading fast enough. That is why when you use a simple loop, everything works and you get the whole message; very little time passes between reads. The simplest solution to this is to increase the size of the Serial buffer to, maybe, 256 bytes. Search for &lt;code&gt;HardwareSerial.h&lt;/code&gt; in your Arduino installation and look for the &lt;code&gt;#define&lt;/code&gt;d variable &lt;code&gt;SERIAL_RX_BUFFER_SIZE&lt;/code&gt; in the file near the top. Change its value to 256 and save. This should provide enough buffer space to store the entire SMS until you read it.&#xA;Alternatively you could change your CNMI settings to push only SMS notifications, which are a lot smaller in size, to the Arduino. Then you can parse the notifications, extract the SMS index and then request the SMS from the SIM800 using the index whenever you wish, making sure to read quickly (you will need to craft a &lt;code&gt;while&lt;/code&gt; loop to do this efficiently, with timeouts and all). &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2015-12-30T01:02:49.840" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19087" PostTypeId="1" AcceptedAnswerId="19095" CreationDate="2015-12-30T01:39:17.823" Score="0" ViewCount="2287" Body="&lt;p&gt;I am trying to set up a 4 cameras which can take videos/photos at the press of a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things which I will need:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;4 micro cameras(the ones which are very small in size) with good&#xA;shutter speed and sensor. The cameras will often travel at 20 to&#xA;30mph. So I guess good shutter speed is needed. &lt;/li&gt;&#xA;&lt;li&gt;2 Push buttons. One will start and stop taking pictures really fast, and the other will do the same for video &lt;/li&gt;&#xA;&lt;li&gt;Battery which can last atleast taking 5 images/1 min of video recording.&lt;/li&gt;&#xA;&lt;li&gt;4 Microsd cards and the connectors. Is there anyway I would be able to set up a common adapter to all these cards, so when connected to a computer it will show up as 4 different drives?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So I think I can make the set up using this: &lt;a href=&quot;http://www.arducam.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.arducam.com/&lt;/a&gt;&#xA;But can it take images really fast. I couldn't see any information regarding this. It should be able to take like 4 images per second. Also it would be awesome if this set up can somehow support taking videos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now another thing I need is a push button which will start taking the photos and stop taking it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This whole thing should operate from a battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mostly I want to know is the list of products which will work or the specs to look for when choosing the products. Also I would like to know if this is the best way to go for  a project like this. This thing will be more like a toy, so I don't want to use really expensive parts for this. Also I don't want a gopro. I want to make this whole set up myself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if you need to know more details about this. &lt;/p&gt;&#xA;" OwnerUserId="15949" LastActivityDate="2015-12-30T11:45:04.140" Title="How do I connect multiple pinhole cameras and take photos and video at the press of a button?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ClosedDate="2016-01-21T20:46:43.200" ContentLicense="CC BY-SA 3.0" />
  <row Id="19088" PostTypeId="2" ParentId="19075" CreationDate="2015-12-30T02:19:30.410" Score="2" Body="&lt;p&gt;As far as the Wi-Fi and Uno is concerned, it's not too difficult. You should download its library for Arduino, which is available on Github and then try its example named &lt;em&gt;Wifi Client&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example, change your SSID and password, and run serial terminal. It will show you that your Arduino is connected to Wi-Fi and it will also display your IP Address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now enter this IP address in your browser and it's like you are pinging your Wi-Fi shield.  Soon it will display your analog values. Just make sure your computer and your Wi-Fi chip are connected to the same Wi-Fi connections.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastEditorUserId="3917" LastEditDate="2015-12-30T16:50:19.477" LastActivityDate="2015-12-30T16:50:19.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19089" PostTypeId="1" AcceptedAnswerId="20943" CreationDate="2015-12-30T02:25:45.940" Score="1" ViewCount="3389" Body="&lt;p&gt;I am working on a project in which I have to connect my Arduino with a GPS module. In this project I need to get longitude, latitude, time and date from the GPS module and need to send these values via USB to a computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On this computer, I am going to design software in Microsoft Visual Studio 2010, which will receive this data and display it on a map. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, before designing it in hardware, I want to simulate it on Proteus. I have searched in Proteus but there's no GPS module in it, so does anyone know any GPS module library for Proteus?&lt;/p&gt;&#xA;" OwnerUserId="7523" LastEditorUserId="6936" LastEditDate="2016-02-21T06:45:49.957" LastActivityDate="2016-02-21T06:49:36.680" Title="GPS library for Proteus" Tags="|arduino-uno|gps|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19091" PostTypeId="1" CreationDate="2015-12-30T04:09:23.527" Score="2" ViewCount="513" Body="&lt;p&gt;I wrote this test program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    digitalWrite(13,1);&#xA;    delay(300);&#xA;    digitalWrite(13,0);&#xA;    delay(300);&#xA;    void *a = malloc(10000000000000000000000000000000000000000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Curiously, the LED keeps blinking and so it means the loops continues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can it continue when it runs out of heap memory like that?&lt;/p&gt;&#xA;" OwnerUserId="15952" LastEditorUserId="6936" LastEditDate="2016-01-04T10:53:20.973" LastActivityDate="2016-01-04T10:53:20.973" Title="Arduino Uno - why doesn't memory leak crash the program?" Tags="|memory-usage|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19093" PostTypeId="2" ParentId="19091" CreationDate="2015-12-30T11:19:18.013" Score="3" Body="&lt;p&gt;&lt;code&gt;malloc()&lt;/code&gt; by itself generally doesn't &lt;em&gt;crash&lt;/em&gt; a program.  It attempts to allocate the requested amount of memory, and if it can it will.  If it can't (there isn't enough memory available) then it won't allocate anything and will just return NULL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By trying to allocate more memory than you have it will just fail every time and no memory will be allocated - thus you don't actually have a memory leak, so your program doesn't fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason for crashing is a phenomenon called &lt;em&gt;stack smashing&lt;/em&gt; where the memory area used by &lt;code&gt;malloc()&lt;/code&gt; (known as the &lt;em&gt;heap&lt;/em&gt;) and the memory area for the stack (used by local variables and for storing the contents of registers during function calls) collide with one another and one corrupts the other.  For instance, if the &lt;em&gt;return address&lt;/em&gt; of the current function in the stack is corrupted, when the function finishes it will return to the wrong memory location and who knows what may happen then?  Wrong instructions will be executed for sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, try this program out instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    char *a = (char *)malloc(10);&#xA;    if (a != NULL) {&#xA;        Serial.println(&quot;Allocated 10 bytes&quot;);&#xA;    } else {&#xA;        Serial.println(&quot;Allocation failed&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If all goes well you should see lots of &quot;Allocated 10 bytes&quot; followed by some &quot;Allocation failed&quot;.  Since the memory is now full there is a chance that it may now crash as the stack and heap collide - in which case you would expect to see the &quot;Allocation failed&quot; messages stop.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-30T11:19:18.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19094" PostTypeId="2" ParentId="19084" CreationDate="2015-12-30T11:30:14.607" Score="1" Body="&lt;p&gt;What it sounds like you want is an Arduino Due footprint prototyping shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://store.arduino.cc/index.php?main_page=product_info&amp;amp;products_code=A000080&quot; rel=&quot;nofollow&quot;&gt;Arduino make one&lt;/a&gt;, although it is out of stock, but it gives you an idea of what you are looking for. There are plenty of other designs out there for purchase of varying degrees of complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You solder the pins in place and mount it on top of your Due just like any shield, and solder your wires and components in where you want them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative option, of course, is to step away from Arduino and investigate some of the many other chips from other manufacturers out there that are considerably more powerful than the 8-bit ATMegas used on the low-end Arduinos, and yet are still available in a DIP footprint - chips like the PIC32MX1xx/2xx series from Microchip - 28 pin DIP (just like the 328P) yet 50MHz, 32-bit power.  Yes, it will be a bit of a learning curve, but there are helpful options out there that can assist you, like the &lt;a href=&quot;http://chipkit.net&quot; rel=&quot;nofollow&quot;&gt;chipKIT&lt;/a&gt; system including the handy &lt;a href=&quot;http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-DP32&quot; rel=&quot;nofollow&quot;&gt;DP32 board from Digilent&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-30T11:30:14.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19095" PostTypeId="2" ParentId="19087" CreationDate="2015-12-30T11:45:04.140" Score="1" Body="&lt;p&gt;Arduinos and Cameras do not mix well at all.  It's all down to the sheer quantity of data involved in pictures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take for instance a typical VGA image - 640x480 pixels at 24-bit (3 byte) colour depth.  One single picture requires 640x480x3 = 921600 bytes just to store it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add to that the fact that most small cameras include hardware JPEG compression which the Arduino really has no hope of being able to handle, and you just can't do anything with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most camera modules use a system called &lt;a href=&quot;http://mipi.org/specifications/camera-interface&quot; rel=&quot;nofollow&quot;&gt;CSI-3&lt;/a&gt; (Camera Serial Interface version 3) for streaming the raw data from the CCD elements into the target.  That allows for high speed data transfer of the whole frame at a speed that is able to support video.  If you think about video as 25 frames per second, and raw data, that means that the data is being transferred from the CCD elements in total at arouns 22 MiB/s - there is absolutely no way that an Arduino can deal with that kind of data.  So cameras that attach to an Arduino have their own controller chip that compresses the image to JPEG and streams it out through a much slower interface - typically RS232.  All the Arduino can then do is tell the camera &quot;Take a picture for me&quot; at which point an image is captured and compressed, and then the Arduino receives the JPEG data through serial (slowly) and stores it on an SD card (also slowly). It can't do anything else with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To crunch those numbers - assume that the compressed VGA image from the camera's processor chip is 100,000 bytes (I took a typical photo, scaled it to 640x480 and saved it with 90% JPEG compression and it was roughly that size).  At 9600 baud you get 960 bytes per second. 100,000 / 960 = 104 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is how long it would take to transfer one single image through the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the camera has a higher speed UART, say 115200 baud (11520 Bps), that would then give you 100,000/11,520 = 8.7 seconds.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, using an Arduino to control cameras in that way just isn't possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need a system that can talk CSI-3 directly - something with a direct camera connection, such as the Raspberry Pi.  Another alternative is any embedded computer with enough processing power and USB ports to connect cheap USB webcams to.  Again the Raspberry Pi would do - especially the newer version 2 with the quad core processor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-30T11:45:04.140" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19096" PostTypeId="1" AcceptedAnswerId="31303" CreationDate="2015-12-30T12:38:06.490" Score="4" ViewCount="15411" Body="&lt;p&gt;I'm using Ubuntu 14.04 with arduino Galileo and the newest arduino IDE from arduino.cc and every time I compile I got this warnings with &lt;em&gt;any library&lt;/em&gt; in place of EEPROM, SD, Wire, Wifi and a lot of others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check the boards manager I got the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Invalid library found in /home/User/.arduino15/packages/Intel/hardware/i586/1.6.2+1.0/libraries/Wire: /home/User/.arduino15/packages/Intel/hardware/i586/1.6.2+1.0/libraries/Wire &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows how to solve this?&lt;/p&gt;&#xA;" OwnerUserId="15675" LastEditorUserId="15675" LastEditDate="2015-12-30T13:54:16.167" LastActivityDate="2016-11-16T22:29:38.577" Title="WARNING: Category '' in library *any library* is not valid. Setting to 'Uncategorized'" Tags="|library|arduino-galileo|ubuntu|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19097" PostTypeId="1" AcceptedAnswerId="19240" CreationDate="2015-12-30T14:02:58.727" Score="2" ViewCount="989" Body="&lt;p&gt;I'm trying to plug a &lt;a href=&quot;http://wiki.iteadstudio.com/Wee_Serial_WIFI_Module&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wee serial WiFi&lt;/a&gt; module on my Arduino Uno, through an &lt;a href=&quot;https://hackspark.fr/fr/xbee-shield.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;XBee shield&lt;/a&gt; .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GsC52.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GsC52.jpg&quot; alt=&quot;Wee in XBee shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm simply trying to make work &lt;a href=&quot;https://github.com/itead/ITEADLIB_Arduino_WeeESP8266/blob/master/examples/ConnectWiFi/ConnectWiFi.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;the example from the library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I get is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup begin&#xA;FW Version:&#xA;to station err&#xA;Join AP failure&#xA;setup end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code i'm using :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;doxygen.h&amp;gt;&#xA;#include &amp;lt;ESP8266.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */&#xA;ESP8266 wifi(mySerial);&#xA;&#xA;#define SSID &quot;yuflowoffice&quot;&#xA;#define PASSWORD &quot;cashless&quot;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(115200);&#xA;  Serial.print(&quot;setup begin\r\n&quot;);&#xA;&#xA;  Serial.print(&quot;FW Version: &quot;);&#xA;  Serial.println(wifi.getVersion().c_str());&#xA;&#xA;  if (wifi.setOprToStation()) {&#xA;    Serial.print(&quot;to station ok\r\n&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;to station err\r\n&quot;);&#xA;  }&#xA;  delay(1500);&#xA;&#xA;  if (wifi.joinAP(SSID, PASSWORD)) {&#xA;    Serial.print(&quot;Join AP success\r\n&quot;);&#xA;    Serial.print(&quot;IP: &quot;);       &#xA;    Serial.println(wifi.getLocalIP().c_str());&#xA;  } else {&#xA;    Serial.print(&quot;Join AP failure\r\n&quot;);&#xA;  }&#xA;&#xA;  Serial.print(&quot;setup end\r\n&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="15959" LastEditorUserId="7389" LastEditDate="2016-01-06T10:56:31.787" LastActivityDate="2016-01-06T10:56:31.787" Title="Can't make Wee serial WiFi work with Arduino Uno" Tags="|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19098" PostTypeId="1" CreationDate="2015-12-30T15:36:45.530" Score="2" ViewCount="257" Body="&lt;p&gt;I am building a rover using an Arduino Mega and an Arduino Uno. The Mega has a sensor shield that has an SD card slot. The intent is for the rover to be autonomous, and I currently send logging info to the serial port (to log actions like boot, diagnostics, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to redirect this output to BOTH the serial and the SD card? I would be happy with just a single file with lines added for each entry. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My complication here is to prevent using &lt;code&gt;Serial.println&lt;/code&gt; as well as &lt;code&gt;SD.println&lt;/code&gt; as two separate commands. Is there any other way around this?&lt;/p&gt;&#xA;" OwnerUserId="15963" LastEditorUserId="6936" LastEditDate="2016-01-04T10:55:50.680" LastActivityDate="2016-01-04T10:55:50.680" Title="Logging to multiple destinations (serial &amp; SD card)" Tags="|serial|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19099" PostTypeId="2" ParentId="19091" CreationDate="2015-12-30T16:15:46.030" Score="0" Body="&lt;p&gt;Allocating memory doesn't really do much to it except for (typically) writing some bookkeeping information into its header - a portion the caller doesn't (isn't supposed to...) see. In particular, that bit of memory doesn't become unavailable for anything (other than further allocation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Malloc maintains a buffer between the stack pointer location and the heap, from which it will not allocate. This tends to ( &amp;lt;--- note &quot;weasel words&quot;) prevent a heap vs. stack collision&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the stack grows down into memory that was already allocated, the stack will over-write the data in some allocated block. It is impossible to say what effect that will have on further program operation without knowing a whole lot more about the program, and quite possibly, about the contents and timing of any data that has yet to be received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the heap grows upward into the stack, and program writes into that allocated block, it will be over-writing parts of it's own stack with, again, unpredictable (without a lot more information) results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple test program that merely allocates lots of small blocks will have a good chance of running forever, or at least until the &lt;code&gt;malloc()&lt;/code&gt; call returns a NULL pointer when it is out of memory to allocate. At that point, if the test program is checking for the NULL return, there is a good chance the program can print its message and end normally. But if the program blindly writes into the memory &lt;code&gt;malloc()&lt;/code&gt; returns, and writes through the eventual NULL pointer, then low-memory will get corrupted. Low memory is typically the location of the interrupt vector table (and the Arduinos' AVR processors are no exception), some interrupt is likely to get vectored to somewhere other than its proper service routine, and abnormal program operation will result; most likely, a crash.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2015-12-30T16:15:46.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19100" PostTypeId="2" ParentId="19096" CreationDate="2015-12-30T16:20:39.750" Score="3" Body="&lt;p&gt;Edit or add library.properties to that folder so that you specify a valid category. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of library.properties:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;name=WebServer&#xA;version=1.0&#xA;author=Cristian Maglie &amp;lt;c.maglie@example.com&amp;gt;, Pippo Pluto &amp;lt;pippo@example.com&amp;gt;&#xA;maintainer=Cristian Maglie &amp;lt;c.maglie@example.com&amp;gt;&#xA;sentence=A library that makes coding a Webserver a breeze.&#xA;paragraph=Supports HTTP1.1 and you can do GET and POST.&#xA;category=Communication&#xA;url=http://example.com/&#xA;architectures=avr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2015-12-30T16:20:39.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19101" PostTypeId="1" CreationDate="2015-12-30T07:51:58.850" Score="0" ViewCount="439" Body="&lt;p&gt;So I'm trying to read a bit of data via SWD. I've tried two chips as target - LPC1110 and STM32F030F4 (the first of them I used for other schematic, but I've reset the flash to make sure the pins are not configured improperly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Arduino as a host. I wire D3 to SWCLK and D4 to SWDIO (with pull-up to 3.3V line). I fail miserably with both chips - i.e. when I expect some ACK be read - it only shows HIGH state on the line all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code. Could anyone have a look and tell where I went wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int swdck = 3;&#xA;int swdio = 4;&#xA;&#xA;void setup() {                &#xA;  pinMode(swdck, OUTPUT);&#xA;  digitalWrite(swdck, HIGH);&#xA;  pinMode(swdio, INPUT);&#xA;  digitalWrite(swdio, HIGH);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// write some bits from X (least significant first) to SWD&#xA;void clockOut(int x, int bits) {&#xA;  pinMode(swdio, OUTPUT);&#xA;  while (bits &amp;gt; 0) {&#xA;    digitalWrite(swdck, LOW);&#xA;    digitalWrite(swdio, (x &amp;amp; 1) ? HIGH : LOW);&#xA;    delay(1);&#xA;    digitalWrite(swdck, HIGH);&#xA;    delay(1);&#xA;    bits--;&#xA;    x &amp;gt;&amp;gt;= 1;&#xA;  }&#xA;  pinMode(swdio, INPUT);&#xA;  digitalWrite(swdio, HIGH);&#xA;}&#xA;&#xA;// read some bits from SWD, least significant first&#xA;int clockIn(int bits) {&#xA;  pinMode(swdio, INPUT);&#xA;  digitalWrite(swdio, HIGH);&#xA;  int i, res;&#xA;  res = 0;&#xA;  for (i = 0; i &amp;lt; bits; i++) {&#xA;    digitalWrite(swdck, LOW);&#xA;    delay(1);&#xA;    if (digitalRead(swdio) == HIGH) {&#xA;      res += (1 &amp;lt;&amp;lt; i);&#xA;    }&#xA;    digitalWrite(swdck, HIGH);&#xA;    delay(1);&#xA;  }&#xA;  return res;&#xA;}&#xA;&#xA;void loop() {&#xA;  int x;&#xA;  // unlock sequence though it probably is not needed&#xA;  clockIn(26); clockIn(26); // more than 50 clocks&#xA;  clockOut(0xE79E, 16); // command to switch to SWD&#xA;  clockIn(26); clockIn(26);&#xA;&#xA;  clockOut(0x25, 7); // 0b0100101 - request to read Debug-port-0, i.e. ID&#xA;  x = clockIn(5); // there should be ACK bits somewhere... but I get 0x1111&#xA;  clockIn(26); clockIn(26); // perform more readings for case anything is returned&#xA;  Serial.println(x);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15972" OwnerDisplayName="Alumashka" LastEditorUserId="27346" LastEditDate="2018-11-19T10:09:27.180" LastActivityDate="2018-11-19T10:09:27.180" Title="Could not read ID via SWD with Arduino" Tags="|programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19102" PostTypeId="2" ParentId="19101" CreationDate="2015-12-30T18:35:34.623" Score="1" Body="&lt;p&gt;I am not a SWD expert; it is several years since I read the spec. So I apologise if you are way ahead of me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe ARM's SWD documentation, e.g. &quot;ARM® Debug Interface v5 Architecture Specification&quot; (ARM IHI 0031A) says that transfers are fixed length, starting with an 8 bits request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clockOut(int x, int bits) {&#xA;  pinMode(swdio, OUTPUT);&#xA;  while (bits &amp;gt; 0) {&#xA;    ...&#xA;    bits--;&#xA;    ...&#xA;  }&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is invoked with &lt;code&gt;clockOut(0xE79E, 16)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A packet request is 8 bits, followed by a response from the target. So this doesn't appear to follow the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly &lt;code&gt;clockOut(0x25, 7)&lt;/code&gt; appears to send 7 bits, which also looks wrong, and may explain why the read fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, there should be a 'turnaround bit' after sending the packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clockOut(int x, int bits) {&#xA;  pinMode(swdio, OUTPUT);&#xA;  ...&#xA;  pinMode(swdio, INPUT);&#xA;  digitalWrite(swdio, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;looks like it is setting up to do that, however, it also needs to signal another clock pulse, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clockOut(int x, int bits) {&#xA;  pinMode(swdio, OUTPUT);&#xA;  ...&#xA;  pinMode(swdio, INPUT);&#xA;  digitalWrite(swdio, HIGH);&#xA;  /* signal a clock pulse */&#xA;  digitalWrite(swdck, LOW);&#xA;  delay(1);&#xA;  digitalWrite(swdck, HIGH);&#xA;  delay(1);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A SWD read should return 33 bits, so &lt;code&gt;x = clockIn(5);&lt;/code&gt; looks a bit fragile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even so, it should get the three ACK bits. It should leave another pile of bits unread, which is what I mean by fragile. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, &lt;code&gt;x = clockIn(5);&lt;/code&gt; might be incorrect because of the short &lt;code&gt;clockOut(0x25, 7)&lt;/code&gt; and lack of a turnaround bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Small points:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'd change that &lt;code&gt;clockOut&lt;/code&gt; &lt;code&gt;while&lt;/code&gt; loop to be a &lt;code&gt;for&lt;/code&gt; loop like &lt;code&gt;clockIn&lt;/code&gt; to make it clear that it is running for a specific 'count' (bits) of bits to be transferred.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;delay(1)&lt;/code&gt; seems to be a long time between bits. I don't remember any&#xA;timing restrictions. However, I would expect the transfers to run&#xA;10-100x faster.&lt;/li&gt;&#xA;&lt;li&gt;IMHO &lt;code&gt;clockIn(26); clockIn(26);&lt;/code&gt; seems to be an unnecessarily obscure way&#xA;to generate the 50 cycle connection/reset sequence. I'd probably have&#xA;a slightly simpler function than &lt;code&gt;clockIn&lt;/code&gt; which only generates the&#xA;connection/reset sequence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;br&gt;&#xA;The statement &lt;code&gt;res += (1 &amp;lt;&amp;lt; i);&lt;/code&gt; in &lt;code&gt;clockIn&lt;/code&gt; works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I had to read it a couple of times to recognise that it is assembling a binary value, and not doing some tricky arithmetic. It is more common to use bitwise operators to assemble a binary value. It is only a small point of style, however &lt;code&gt;res |= (1 &amp;lt;&amp;lt; i);&lt;/code&gt; might be more clearly constructing a binary value, than &lt;code&gt;res += (1 &amp;lt;&amp;lt; i);&lt;/code&gt; because it can only ever effect one bit, and never many bits.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastEditorUserId="3493" LastEditDate="2015-12-30T23:43:16.540" LastActivityDate="2015-12-30T23:43:16.540" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19103" PostTypeId="2" ParentId="6832" CreationDate="2015-12-30T21:21:15.027" Score="1" Body="&lt;p&gt;I assume that, if this is a cost sensitive item, you need a reliable supply of multiples (so looking for small SD cards on e-bay isn't a viable solution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it need to be non-volatile storage? If it does't you may be able to find small 8-bit wide RAM chips at a pretty good price. If it needs to be non-volatile, you might look at individual flash chips. I found &lt;a href=&quot;http://uk.rs-online.com/web/p/flash-memory-chips/8228473P/&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;, an 8-bit by 512 KB Serial-SPI flash chip for £0.19 (about $0.28 US) in single units and £0.176 if you can by 100 at a time. I would expect DRAM chips and chips with a simpler interface to be less expensive (but you might end up spending more on interfacing the chips so it might end up as a wash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're able to consider a variety of processor chips it might be worth looking for something that has adequate storage on chip. That might be the most cost effective way to get the space.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-30T21:21:15.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19104" PostTypeId="2" ParentId="13089" CreationDate="2015-12-30T23:55:19.460" Score="2" Body="&lt;p&gt;The simplest solution (ignoring possible improvements) is to add the following to touchButton.cpp.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;touchButton.h&quot;&#xA;&#xA;// Extern reference to the LCD instance&#xA;#include &amp;lt;UTFT.h&amp;gt;&#xA;extern UTFT myGLCD;&#xA;&#xA;touchButton::touchButton(int x, int y, int xs, int ys, char myuse) {&#xA;  x1 = x;&#xA;  y1 = y;&#xA;  xsize = xs;&#xA;  ysize = ys;&#xA;  use = myuse;&#xA;}&#xA;&#xA;void touchButton::Draw() {&#xA;  switch (use) {&#xA;    case 'p':&#xA;      myGLCD.drawRoundRect(x1, y1, x1+xsize, y1+ysize);&#xA;    break;&#xA;&#xA;   default:&#xA;    break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are several improvements such as passing the UTFT instance reference as parameter, moving myGLCD to a separate .h/.cpp file, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of &quot;extern&quot; object reference may be found in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.h#L143&quot; rel=&quot;nofollow&quot;&gt;HardwareSerial.h&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-30T23:55:19.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19105" PostTypeId="1" AcceptedAnswerId="19114" CreationDate="2015-12-31T00:48:37.100" Score="0" ViewCount="2754" Body="&lt;p&gt;I am using the following code modified from the examples. I get the count of matches but the actual value is not displayed&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Regexp.h&amp;gt;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    MatchState ms;&#xA;    char buf [100];&#xA;    char buf2 [100] = &quot;The quick brown fox jumps over the lazy wolf&quot;;&#xA;    ms.Target (buf2);&#xA;    unsigned int count = ms.MatchCount (&quot;[aeiou]&quot;);&#xA;&#xA;    Serial.print (&quot;Found &quot;);&#xA;    Serial.print (count);&#xA;    Serial.println (&quot; matches.&quot;);&#xA;    for (int j = 0; j &amp;lt; count; j++)&#xA;    {&#xA;          Serial.print (&quot;Capture number: &quot;);&#xA;          Serial.println (j, DEC);&#xA;          Serial.print (&quot;Text: '&quot;);&#xA;          Serial.print (ms.GetCapture (buf, j));&#xA;          Serial.println (&quot;'&quot;);&#xA;    }&#xA;}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13330" LastActivityDate="2020-04-09T08:40:46.863" Title="Basic usage of Nick Gammon's Regexp library" Tags="|library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19106" PostTypeId="1" CreationDate="2015-12-31T00:50:05.413" Score="1" ViewCount="1015" Body="&lt;p&gt;I'm thinking about how to handle a rotary encoder. I'm planning on using interrupts and would like to use both the 'A' and 'B' phase transitions to generate interrupts. I'm wondering if there is any reason why the signals couldn't be OR'd together to generate the interrupt so that I wouldn't need to consume both external interrupts for the encoder.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-31T07:46:56.543" Title="Can external interrupts be OR'd together on the '328 (Uno)?" Tags="|arduino-uno|interrupt|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19107" PostTypeId="2" ParentId="19019" CreationDate="2015-12-31T02:38:21.747" Score="3" Body="&lt;p&gt;&lt;em&gt;(summary of comment thread)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;I &lt;strong&gt;strongly recommend&lt;/strong&gt; against trying to use any of these smartphone camera replacement parts. While they are cheap, this is because the signal they output is nigh impossible for you to use, even if you knew its specifications, which is unlikely given proprietary parts often have proprietary, non-public protocols. Even if you did have it, you'd likely have to implement a linux kernel extension for Raspberry Pi yourself to support it. Far more work than it's worth.&lt;/p&gt;&#xA;&lt;p&gt;If you actually want to do image processing, there is a clear recommendation: &lt;strong&gt;the Raspberry Pi camera interface&lt;/strong&gt;. RasPis have a special flex socket on the board for a camera, and you can buy cameras which work with the &lt;code&gt;raspivid&lt;/code&gt; etc. commands included in raspbian with no extra setup. This allows you to use OpenCV or similar image processing libraries, or write your own, without having to worry about bitbanging obscure camera protocols.&lt;/p&gt;&#xA;&lt;p&gt;No-name camera boards can be bought from eBay or similar sites for less than US$20, and they support 30fps 5 MP image/video capture to the Raspberry Pi natively and easily. Just search for &amp;quot;Raspberry Pi camera&amp;quot;.&lt;/p&gt;&#xA;&lt;h3&gt;&lt;em&gt;However...&lt;/em&gt;&lt;/h3&gt;&#xA;&lt;p&gt;If you're &lt;em&gt;really&lt;/em&gt; sure you're up to the challenge of hacking a proprietary camera module, you'll want to do thorough research finding the exact protocol specifications for these camera chips first, and try to find ones that are the most common, for the highest chance of compatibility, and likelihood of others having made progress on using them. Good luck!&lt;/p&gt;&#xA;" OwnerUserId="7102" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2015-12-31T02:38:21.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19109" PostTypeId="2" ParentId="19106" CreationDate="2015-12-31T07:46:56.543" Score="3" Body="&lt;p&gt;Regarding the notion that “&quot;internal&quot; interrupt latency and/or software overhead is much higher than it is for the &quot;external&quot; interrupts”, it certainly is true that PCI (pin-change interrupts) libraries &lt;a href=&quot;https://github.com/GreyGnome/PinChangeInt/commit/ec745f854b2b807640341cf479f540bb8bb3fc2f&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;PinChangeInt.h&lt;/code&gt; (deprecated)&lt;/a&gt; and &lt;a href=&quot;https://github.com/GreyGnome/EnableInterrupt&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;EnableInterrupt.h&lt;/code&gt;&lt;/a&gt; have high software overhead.  By keeping track of former values, for each pin those libraries support separate callback routines for Rising, Falling, Change, High, and Low.  PCIs are grouped in sets of eight pins per interrupt vector, leading to 40 different cases of callback routines when a PCI fires.  That is, when a PCI occurs, the libraries quickly find out which set of pins changed – because that's what the hardware supports – but then they go through all eight pins on the vector one by one checking if it changed, and how it changed, then calling the callback associated with the particular pin and its particular state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reading pins of a rotary encoder, say a &lt;a href=&quot;https://www.google.com/search?q=ky-040+rotary+encoder&amp;amp;biw=1095&amp;amp;bih=625&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;ved=0ahUKEwiN8-KEv4XKAhVU2mMKHVxYBPIQsAQIGw&quot; rel=&quot;nofollow noreferrer&quot;&gt;KY-040&lt;/a&gt;, the overhead described above can cause loss of 10%–20% of rotary counts.  If you are concerned about not losing counts, write your own &lt;code&gt;ISR()&lt;/code&gt;-level interrupt service routine.  The example below illustrates a routine using &lt;code&gt;ISR()&lt;/code&gt;; this example is from my &lt;a href=&quot;https://arduino.stackexchange.com/a/18221/3917&quot;&gt;answer to previous question #18221&lt;/a&gt;, with some comments added here and there.  See that answer for discussion of the timing data that is this program's output.  (For rotary encoder quadrature-counting, see discussion below).  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*  rcTiming.ino -- JW, 30 November 2015 -- &#xA; * Uses pin-change interrupts on A0-A4 to time RC pulses&#xA; *&#xA; * Ref: https://arduino.stackexchange.com/questions/18183/read-rc-receiver-channels-using-interrupt-instead-of-pulsein&#xA; *&#xA; */&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;static   byte rcOld;        // Prev. states of inputs&#xA;volatile unsigned long rcRises[4]; // times of prev. rising edges&#xA;volatile unsigned long rcTimes[4]; // recent pulse lengths&#xA;volatile unsigned int  rcChange=0; // Change-counter&#xA;&#xA;// Be sure to call setup_rcTiming() from setup()&#xA;void setup_rcTiming() {&#xA;  rcOld = 0;&#xA;  // Note, if using an encoder without pullups on it,&#xA;  // change INPUT in next 2 lines to INPUT_PULLUP&#xA;  pinMode(A0, INPUT);  // pin 14, A0, PC0, for pin-change interrupt&#xA;  pinMode(A1, INPUT);  // pin 15, A1, PC1, for pin-change interrupt&#xA;  pinMode(A2, INPUT);&#xA;  pinMode(A3, INPUT);&#xA;  PCMSK1 |= 0x0F;       // Four-bit mask for four channels&#xA;  PCIFR  |= 0x02;       // clear pin-change interrupts if any&#xA;  PCICR  |= 0x02;       // enable pin-change interrupts&#xA;}&#xA;// Define the service routine for PCI vector 1&#xA;ISR(PCINT1_vect) {&#xA;  byte rcNew = PINC &amp;amp; 15;   // Get low 4 bits, A0-A3&#xA;  byte changes = rcNew^rcOld;   // Notice changed bits&#xA;  byte channel = 0;&#xA;  unsigned long now = micros(); // micros() is ok in int routine&#xA;  while (changes) {&#xA;    if ((changes &amp;amp; 1)) {  // Did current channel change?&#xA;      if ((rcNew &amp;amp; (1&amp;lt;&amp;lt;channel))) { // Check rising edge&#xA;        rcRises[channel] = now;     // Is rising edge&#xA;      } else {              // Is falling edge&#xA;        rcTimes[channel] = now-rcRises[channel];&#xA;      }&#xA;    }&#xA;    changes &amp;gt;&amp;gt;= 1;      // shift out the done bit&#xA;    ++channel;&#xA;    ++rcChange;&#xA;  }&#xA;  rcOld = rcNew;        // Save new state&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting RC Timing Test&quot;);&#xA;  setup_rcTiming();&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long rcT[4]; // copy of recent pulse lengths&#xA;  unsigned int rcN;&#xA;  if (rcChange) {&#xA;&#xA;    // Data is subject to races if interrupted, so off interrupts&#xA;    cli();          // Disable interrupts&#xA;    rcN = rcChange;&#xA;    rcChange = 0;       // Zero the change counter&#xA;    rcT[0] = rcTimes[0];&#xA;    rcT[1] = rcTimes[1];&#xA;    rcT[2] = rcTimes[2];&#xA;    rcT[3] = rcTimes[3];&#xA;    sei();          // reenable interrupts&#xA;&#xA;    Serial &amp;lt;&amp;lt; &quot;t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[0] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[1]&#xA;       &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[2] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcT[3] &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; rcN &amp;lt;&amp;lt; endl;&#xA;  }&#xA;  sei();            // reenable interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, for the above you may need to download and install &lt;code&gt;Streaming.h&lt;/code&gt; via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduiniana.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Rotary encoder quadrature-counting&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program above tracks and reports pulse-length times, instead of decoding the quadrature signals the rotary encoder provides.  The program below reports rotary encoder counts, but does so using INT0 and INT1 instead of PCIs.  You will want to combine relevant portions of the two routines together – ie, use the interrupt setup and handling framework from above, with the body of the service routine from below.  [Note, this program is from my &lt;a href=&quot;https://arduino.stackexchange.com/a/16420/3917&quot;&gt;answer to previous question #16420&lt;/a&gt;.  The encoder decoding code within it is faster and shorter than other decoding code I've looked at, and is fast enough to support two encoders rotating simultaneously while losing few counts.]&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*  roto_jw4.ino -- JW, 29 September 2015 -- &#xA; *  A 4-state state-machine implementation of rotary&#xA; *  encoding for KY-040 rotary knobs.  The state-machine picture at&#xA; *  https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/318762&#xA; *  in a Feb 4, 2014 7:40 PM post by Anthony Seely shows counts&#xA; *  increasing on transitions 10 -&amp;gt; 11 -&amp;gt; 01 -&amp;gt; 00 -&amp;gt; 10 and&#xA; *  decreasing on transitions the other way.  Transitions between 00&#xA; *  and 11 or 10 and 01 are invalid.  This code detects valid&#xA; *  transitions by (abOld xor abNew) equaling 1 or 2.  It detects&#xA; *  up-count events by the tri-bit value ABA' (where A' is the new&#xA; *  reading on pin A) being equal to 1, 2, 5, or 6 (a bit mask of&#xA; *  0x66), and down-count events by ABA' being equal to 0, 3, 4, or 7&#xA; *  (a bit mask of 0x99).&#xA; *&#xA; *  On a KY-040 unit I tested, there are 30 detent positions per turn.&#xA; *  With this unit the code generates 60 counts per turn, which can be&#xA; *  seen individually as one turns the rotor slowly.  Odd counts&#xA; *  appear between detents, even counts at detents.&#xA; *&#xA; *  Set quadrature-signal pin numbers, via PinA and PinB constants.&#xA; *  Set IPINMODE to INPUT_PULLUP if there are no external pull-ups&#xA; *  on encoder AB pins, else set IPINMODE to INPUT&#xA; */&#xA;enum { PinA=2, PinB=3, IPINMODE=INPUT };&#xA;&#xA;static  byte abOld;     // Initialize state&#xA;volatile int count;     // current rotary count&#xA;         int old_count;     // old rotary count&#xA;&#xA;void setup() {&#xA;  pinMode(PinA, IPINMODE);&#xA;  pinMode(PinB, IPINMODE);&#xA;  attachInterrupt(0, pinChangeISR, CHANGE); // Set up pin-change interrupts&#xA;  attachInterrupt(1, pinChangeISR, CHANGE);&#xA;  abOld = count = old_count = 0;&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Starting Rotary Encoder Test&quot;);&#xA;}&#xA;&#xA;// On interrupt, read input pins, compute new state, and adjust count&#xA;void pinChangeISR() {&#xA;  enum { upMask = 0x66, downMask = 0x99 };&#xA;  byte abNew = (digitalRead(PinA) &amp;lt;&amp;lt; 1) | digitalRead(PinB);&#xA;  byte criterion = abNew^abOld;&#xA;  if (criterion==1 || criterion==2) {&#xA;    if (upMask &amp;amp; (1 &amp;lt;&amp;lt; (2*abOld + abNew/2)))&#xA;      count++;&#xA;    else count--;       // upMask = ~downMask&#xA;  }&#xA;  abOld = abNew;        // Save new state&#xA;}&#xA;&#xA;void loop() {&#xA;  if (old_count != count) {&#xA;    Serial.print(millis());&#xA;    Serial.print(&quot;  &quot;);&#xA;    Serial.println(count);&#xA;    old_count = count;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Using other pins for PCIs&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to monitor two rotary encoder lines using pin change interrupts on pins other than A0 and A1, you &lt;em&gt;may&lt;/em&gt; need to replace vector &lt;code&gt;PCINT1_vect&lt;/code&gt; with some other vector, and &lt;em&gt;will&lt;/em&gt; need to replace the pins mask with a different one.  The following program can be used to display a table of PCI vectors, masks, etc.  (As noted in my question &lt;a href=&quot;https://arduino.stackexchange.com/q/16551&quot;&gt;Why PJ0 and PJ1 are not reporting as PCINT pins&lt;/a&gt;, pins PJ0 and PJ1 on an ATmega-2560 board will not report correctly.)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*  pinsList -- JW, 4 October 2015 --&#xA; *&#xA; *  Displays a list of Arduino pin numbers for current kind of Arduino&#xA; *  board, along with port codes, pin-change-interrupt numbers, and&#xA; *  pin-change-interrupt vector numbers.&#xA; *&#xA; *  Here are two examples of output lines for pin 11, the first for an&#xA; *  Uno, the second for a Mega:&#xA; *&#xA; *        11   PB3   0x04   PWM   PCINT3  PCINT0_vect&#xA; *        11   PB5   0x20   PWM   PCINT5  PCINT0_vect&#xA; */&#xA;//-----------------------------------------------------------&#xA;// Given a value with 1 bit set, return bit #.  Else return 9.&#xA;byte getBitfromBV (byte m) {&#xA;  byte b=0, v=1;&#xA;  while (v) {&#xA;    if (m==v)&#xA;      return b;&#xA;    ++b; v &amp;lt;&amp;lt;= 1;&#xA;  }&#xA;  return 9;&#xA;}&#xA;//-----------------------------------------------------------&#xA;void processPinNumber(byte pin) {&#xA;  char buffi[128];      // We create text-to-write in buffi&#xA;  byte nbuff=0;         // #chars used in buffi&#xA;  byte nPCICR;          // 0, 1, or 2 for mask-register #&#xA;  byte bitInByte;       // 0 to 7 for bit in I/O mask&#xA;  byte pinPort;         // pin's port #, in range 1 to 12&#xA;  byte PCInum;          // PCINT# if pin is a PCI pin&#xA;  char *portLet = &quot;?ABCDEFGHIJKL&quot;;&#xA;&#xA;  if (pin &amp;gt;= NUM_DIGITAL_PINS) return;&#xA;&#xA;  pinPort = digitalPinToPort(pin); // Get port #, in range 1 to 12&#xA;  bitInByte = getBitfromBV(digitalPinToBitMask(pin));&#xA;&#xA;  nbuff = snprintf(buffi, sizeof(buffi), &quot;  %2d   P%c%d  0x%02x&quot;, &#xA;           pin, portLet[pinPort], bitInByte, 1&amp;lt;&amp;lt;bitInByte);&#xA;&#xA;  // Indicate if it's a PWM pin&#xA;  if (digitalPinHasPWM(pin)) {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;  PWM&quot;);&#xA;  } else {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;     &quot;);&#xA;  }&#xA;&#xA;  // If it's a PCINT pin, show its PCINT number and 0, 1, 2 for its vector #&#xA;  if (digitalPinToPCICR(pin)) {      // Is it a PCint pin?&#xA;    nPCICR = digitalPinToPCICRbit(pin); // 0, 1, 2 for pin's PCICR bit#&#xA;    PCInum = nPCICR*8 + bitInByte;&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff,&#xA;             &quot;  PCINT%d  PCINT%d_vect&quot;,  PCInum,  nPCICR);&#xA;  }&#xA;  Serial.println(buffi);&#xA;}&#xA;void setup() {&#xA;  delay(50);&#xA;  Serial.begin(115200);&#xA;  delay(50);&#xA;  while (!Serial) ;             // wait for serial stream to connect&#xA;  Serial.println(&quot;\nPin#  Port  Mask  PWM   PCINT&quot;);&#xA;  for (byte p=0; p&amp;lt;NUM_DIGITAL_PINS; ++p)&#xA;    processPinNumber(p);&#xA;  Serial.end();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ISR-framework-generating Sketch&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program below generates frameworks for specified PCI pins and prints them to &lt;code&gt;Serial&lt;/code&gt;.  See usage comments within the program.  This provides an easy way to create the basic outline of an ISR to handle PCIs.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*  pinFunctions -- JW, 1 October 2015 --&#xA; *&#xA; *  Displays direct pin-access and pin-change-interrupt setup code,&#xA; *  for inclusion in a sketch, for specified pin numbers.  The&#xA; *  displayed code can be pasted into a sketch where execution speed&#xA; *  matters.&#xA; *&#xA; *  When called with a call like `genCode (&quot;affix&quot;, &quot;9,11&quot;);`, genCode&#xA; *  will produce a set of procedures: ISR routines for pins that&#xA; *  support pin-change interrupts; get and put routines to read from&#xA; *  or store to registers; and a setup routine.  The generated get,&#xA; *  put, and setup routines will have names formed by suffixing the&#xA; *  affix to get, put, and setup, respectively.  For example, if the&#xA; *  affix is ML47 the names of generated routines will include&#xA; *  getML47, putML47, and setupML47.&#xA; *&#xA; *  Generated get() and put() code is of the following forms (in which&#xA; *  u, v are port-letters; values mu, mv, ni are numerical constants;&#xA; *  and w is a parameter value) if all the pins, n1, ... nk in the&#xA; *  pins-list are in port u, under mask mu:&#xA; *&#xA; *             return PINu &amp;amp; 0xmu; // Get pins n1, ... nk &#xA; *             PORTu = PINu &amp;amp; ~mu | w &amp;amp; mu;&#xA; *&#xA; * For example, with Uno pins 3, 4, 6, get() and put() bodies are:&#xA; *&#xA; *             return PIND &amp;amp; 0x58;&#xA; *             PORTD = PIND &amp;amp; 0xa7 | w &amp;amp; 0x58;&#xA; *&#xA; *  The following forms arise if the pins are in ports u and v; and so&#xA; *  forth if more than two ports are involved.&#xA; *&#xA; *             return PINu &amp;amp; masku | PINv &amp;amp; mv; // Get pins n1, ... nk&#xA; *             PORTu = w &amp;amp; 0xmu;   // Put pins &amp;lt;u pins&amp;gt;&#xA; *             PORTv = w &amp;amp; 0xmv;   // Put pins &amp;lt;v pins&amp;gt;&#xA; *&#xA; *  genCode() does not require that all pins belong to the same port.&#xA; *  It will produce usually-desired results if bit positions don't&#xA; *  interfere, otherwise may not.  For example: An Arduino Uno&#xA; *  pins-list &quot;2,10&quot; corresponds to port pins PD2 and PB2.  Both are&#xA; *  in bit position 2, so get's result will be the OR of the PB2 and&#xA; *  PD2 values, while put will store the same bit value to both pins.&#xA; *&#xA; *  To use the pasted code: A statement like `w = getAFFIX();` will&#xA; *  read a set of pins and store the value in w.  A statement like&#xA; *  `putAFFIX(w);` will write w to a set of pins.  Also, add a line&#xA; *  like the following in setup():&#xA; *&#xA; *       setupAFFIX(ioMode, enablePCI);&#xA; *&#xA; *  In the `setupAFFIX(ioMode, enablePCI);` call, substitute an&#xA; *  appropriate affix in place of AFFIX; substitute one of INPUT,&#xA; *  OUTPUT, or INPUT_PULLUP in place of ioMode; and substitute 1 or 0&#xA; *  for enablePCI, to enable or not enable pin-change-interrupt setup.&#xA; *&#xA; *  If you want to save room and don't plan to use pin-change&#xA; *  interrupts, instead of merely not enabling PCI setup, you can&#xA; *  remove the ISR routines and the `if (enablePCI) {...}` section&#xA; *  from the pasted code.&#xA; *&#xA; *  Each generated ISR routines contains one line, of form&#xA; *&#xA; *        byte datum = PINu &amp;amp; mu; // Read pins &amp;lt;list&amp;gt;&#xA; *&#xA; *  The idea is that you will paste the generated ISR into your&#xA; *  sketch, then populate it with appropriate interrupt processing&#xA; *  code.  Note 1: datum contains data from one port, a port which&#xA; *  belongs to the interrupt vector.  If you need data from other&#xA; *  ports as well, then paste appropriate lines from the get() routine&#xA; *  into the ISR.  Note 2: This version of pinFunctions does not&#xA; *  announce pins that don't belong to PCI vectors, if any.&#xA; *  (Processor pins with functions like PCINT0 ... PCINT23 belong to&#xA; *  PCI vectors.)  You can compare the masks used in get() to those&#xA; *  used in the ISR's to detect this.  If the masks differ, some pins&#xA; *  aren't PCI pins.  Note 3: If multiple ports' pins belong to one&#xA; *  vector (eg Ard#0 or PE0 for PCINT8 and Ard#15 or PJ0 for PCINT9,&#xA; *  both on vector PCINT1_vect), a code-generation error of form &quot;Pin&#xA; *  x's port #y isn't #z&quot; will appear and you will need to paste in&#xA; *  appropriate lines from get() or otherwise manually prepare correct&#xA; *  code.&#xA; */&#xA;&#xA;char buffi[128];        // We create text-to-write in buffi&#xA;char buffn[32];         // also in buffn&#xA;byte nbuff=0;           // #chars used in buffn&#xA;char *c;            // c points into pinsList&#xA;byte pin;           // pin number&#xA;byte nPCICR;            // 0, 1, or 2 for mask-register #&#xA;byte vecmask;           // OR of 1&amp;lt;&amp;lt;nPCICR values&#xA;byte intmask[3];        // OR of int. enable masks&#xA;byte maskBitPC;         // 0 to 7 for bit in PCI mask&#xA;byte maskBitIO;         // 0 to 7 for bit in I/O mask&#xA;byte pinPort;           // pin's port #, in range 1 to 12&#xA;byte PCInum;            // PCINT# if pin is a PCI pin&#xA;&#xA;// Given a value with 1 bit set, return bit #.  Else return 9.&#xA;byte getBitfromBV (byte m) {&#xA;  byte b=0, v=1;&#xA;  while (v) {&#xA;    if (m==v)&#xA;      return b;&#xA;    ++b; v &amp;lt;&amp;lt;= 1;&#xA;  }&#xA;  return 9;&#xA;}&#xA;&#xA;// Get next pin number from pinsList, and its associated reg numbers&#xA;byte getPinNumber() {&#xA;  byte cc=*c;&#xA;  if (!cc)&#xA;    return 0;&#xA;  pin=0;&#xA;  for (; '0' &amp;lt;= cc &amp;amp;&amp;amp; '9' &amp;gt;= cc; cc=*++c) {&#xA;    pin = 10*pin + cc - '0';&#xA;  }&#xA;  pinPort = maskBitIO = PCInum = nPCICR = maskBitPC = 0;&#xA;  if (pin &amp;lt; NUM_DIGITAL_PINS) {&#xA;    pinPort = digitalPinToPort(pin); // Get port #, in range 1 to 12&#xA;    maskBitIO = digitalPinToBitMask(pin);&#xA;    if (digitalPinToPCICR(pin)) {        // Is it a PCint pin?&#xA;      nPCICR  = digitalPinToPCICRbit(pin); // 0, 1, 2 for p's PCICR bit#&#xA;      maskBitPC = digitalPinToPCMSKbit(pin);&#xA;      PCInum =  nPCICR*8+ getBitfromBV(maskBitIO);&#xA;    }&#xA;  }&#xA;  if (!cc)         // At end of string? If so,&#xA;    --c;           // allow for caller incrementing c&#xA;  return 1;&#xA;}&#xA;&#xA;void genCode (char *affix, char *pinsList) {&#xA;  char *portLet = &quot;?ABCDEFGHIJKL?&quot;;&#xA;  enum { portMax=12 };&#xA;  byte readmask;        // Input-bits mask&#xA;  byte port;            // Port #&#xA;&#xA;  snprintf(buffi, sizeof(buffi), &quot;\n// %s : pins %s&quot;, affix, pinsList);&#xA;  Serial.println(buffi);&#xA;&#xA;  //==================================================================&#xA;  // Generate  &quot;byte get&amp;lt;affix&amp;gt;() { // Get pins &amp;lt;list&amp;gt;&quot;&#xA;  //              return PINu &amp;amp; mu | PINv &amp;amp; mv | ...&#xA;  //            }&quot;&#xA;  nbuff = snprintf(buffi, sizeof(buffi), &quot;byte get%s () { // Get pins&quot;, affix);&#xA;  for (port=1; port&amp;lt;=portMax; ++port) {&#xA;    for (readmask=0, c = pinsList; getPinNumber(); ++c) {&#xA;      if (pinPort==port) {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;% d,&quot;, pin);&#xA;    readmask |= maskBitIO;&#xA;      }&#xA;    }&#xA;    if (readmask) buffi[nbuff-1] = ';'; // Replace extra , by ;&#xA;  }&#xA;  Serial.println(buffi);    // Print first line of get...() function&#xA;  nbuff = snprintf(buffi, sizeof(buffi), &quot;  return&quot;);&#xA;  for (port=1; port&amp;lt;=portMax; ++port) {&#xA;    for (readmask=0, c = pinsList; getPinNumber(); ++c) {&#xA;      if (pinPort==port) {&#xA;    readmask |= maskBitIO;&#xA;      }&#xA;    }&#xA;    if (readmask) &#xA;      nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot; PIN%c &amp;amp; 0x%02x |&quot;,&#xA;            portLet[port], readmask);&#xA;  }&#xA;  snprintf(buffi+nbuff-2, sizeof(buffi)-nbuff, &quot;;\n}&quot;); // -2 loses extra &quot; |&quot;&#xA;  Serial.println(buffi);  // Print last two lines of get...() function&#xA;&#xA;  //==================================================================&#xA;  // Generate  &quot;void put&amp;lt;affix&amp;gt;(byte w) { // Put pins &amp;lt;list&amp;gt;&quot;&#xA;  //              PORTu = PINu &amp;amp; ~mu | w &amp;amp; mu;&#xA;  //              ...&#xA;  //            }&quot;&#xA;  nbuff = snprintf(buffi, sizeof(buffi), &quot;void put%s () { // Put pins&quot;, affix);&#xA;  for (port=1; port&amp;lt;=portMax; ++port) {&#xA;    for (readmask=0, c = pinsList; getPinNumber(); ++c) {&#xA;      if (pinPort==port) {&#xA;    nbuff += snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;% d,&quot;, pin);&#xA;    readmask |= maskBitIO;&#xA;      }&#xA;    }&#xA;    if (readmask) buffi[nbuff-1] = ';'; // Replace extra , by ;&#xA;  }&#xA;  Serial.println(buffi);    // Print first line of put...() function&#xA;  for (port=1; port&amp;lt;=portMax; ++port) {&#xA;    for (readmask=0, c = pinsList; getPinNumber(); ++c) {&#xA;      if (pinPort==port) {&#xA;    readmask |= maskBitIO;&#xA;      }&#xA;    }&#xA;    if (readmask) {&#xA;      snprintf(buffi, sizeof(buffi), &quot;  PORT%c = PIN%c &amp;amp; 0x%02x | w &amp;amp; 0x%02x;&quot;,&#xA;           portLet[port], portLet[port], (byte)(~readmask), readmask);&#xA;      Serial.println(buffi);  // Print a port-setting line of put...() function&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;}&quot;);  // Print last line of put...() function&#xA;&#xA;  //=================================================================&#xA;  // Generate ISR's:  Process 3 possible pin-change interrupt vectors&#xA;  vecmask = 0;&#xA;  for (byte ivect=0; ivect &amp;lt; 3; ++ivect) {&#xA;    byte sinPort=15;        // currently-in-use same port #&#xA;    intmask[ivect] = 0;&#xA;    byte busyvect=0;              // Assume vector not used&#xA;    byte readmask=0;              // Input mask&#xA;    // Loop to see if vector is used&#xA;    for (c = pinsList; getPinNumber(); ++c) {&#xA;      if (nPCICR == ivect) {&#xA;    ++busyvect; sinPort = pinPort;  // Bits on same port get read once&#xA;    vecmask |= 1&amp;lt;&amp;lt;ivect;&#xA;    intmask[ivect] |= 1&amp;lt;&amp;lt;maskBitPC;&#xA;      }&#xA;    }&#xA;    if (busyvect) {     // If vector is busy, create its ISR&#xA;      snprintf(buffi, sizeof(buffi), &quot;ISR(PCINT%d_vect) {&quot;, ivect);&#xA;      Serial.println(buffi);&#xA;      nbuff = 0;&#xA;      for (c = pinsList; getPinNumber(); ++c) {&#xA;        // See if it's a PCint pin, and on the current vector&#xA;    if (digitalPinToPCICR(pin) &amp;amp;&amp;amp; nPCICR == ivect) {&#xA;      intmask[ivect] |= 1&amp;lt;&amp;lt;maskBitPC;&#xA;      readmask |= digitalPinToBitMask(pin);&#xA;      nbuff += snprintf(buffn+nbuff, sizeof(buffn)-nbuff, &quot; %d,&quot;, pin);&#xA;      if (pinPort != sinPort) {&#xA;        snprintf(buffi, sizeof(buffi), &quot;Pin %d's port #%d isn't #%d&quot;, &#xA;             pin, pinPort, sinPort);&#xA;        Serial.println(buffi);&#xA;      }&#xA;    }&#xA;      }&#xA;      snprintf(buffi, sizeof(buffi), &quot;  byte datum = PIN%c &amp;amp; 0x%02x; // Read pins %s\n}&quot;,&#xA;           portLet[sinPort], readmask, buffn);&#xA;      Serial.println(buffi);&#xA;    }&#xA;  }&#xA;  snprintf(buffi, sizeof(buffi), &quot;void setup%s(byte ioMode, byte enablePCI) {&quot;, affix);&#xA;  Serial.println(buffi);&#xA;  for (c = pinsList; getPinNumber(); ++c) {&#xA;    nbuff = snprintf(buffi, sizeof(buffi), &quot;  pinMode(%2d, ioMode); // %2d, P%c%d&quot;,&#xA;         pin, pin, portLet[pinPort], getBitfromBV(maskBitIO));&#xA;&#xA;    if (maskBitPC)&#xA;      snprintf(buffi+nbuff, sizeof(buffi)-nbuff, &quot;   PCINT %d&quot;, PCInum);&#xA;    Serial.println(buffi);&#xA;  }&#xA;  Serial.println(&quot;  if (enablePCI) {&quot;);&#xA;  for (byte ivect=0; ivect &amp;lt; 3; ++ivect) {&#xA;    if (intmask[ivect]) {&#xA;      snprintf(buffi, sizeof(buffi), &quot;    PCMSK%d |= 0x%02x;&quot;, ivect, intmask[ivect]);&#xA;      Serial.println(buffi);&#xA;    }&#xA;  }&#xA;&#xA;  snprintf(buffi, sizeof(buffi), &quot;    PCIFR  |= 0x%02x; // clear PC interrupts if any&quot;,&#xA;       vecmask);&#xA;  Serial.println(buffi);&#xA;  snprintf(buffi, sizeof(buffi), &quot;    PCICR  |= 0x%02x; // enable PC interrupts\n  }\n}&quot;,&#xA;       vecmask);&#xA;  Serial.println(buffi);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  while (!Serial) ;             // wait for serial stream to connect&#xA;  Serial.println(&quot;Starting Code Generation&quot;);&#xA;  genCode (&quot;A0A1&quot;,  &quot;14,15\0&quot;); // A0, A1 on a nano&#xA;  genCode (&quot;Pair78&quot;,  &quot;7,8&quot;);&#xA;  genCode (&quot;Trip346&quot;,  &quot;3,4,6&quot;);&#xA;  genCode (&quot;Quad789A&quot;, &quot;7,8,9,10&quot;);&#xA;  genCode (&quot;Hex8toD&quot;,  &quot;8,9,10,12,11,13&quot;);&#xA;  genCode (&quot;LotsSmall&quot;, &quot;2,6,7,8,9,10,11,12,13,14,15,19,20,21,22,28,29,30,31,37&quot;);&#xA;  genCode (&quot;LotsBig&quot;,   &quot;31,37,38,37,38,45,46,52,53,54,55,61,62,63,69,70,71,76&quot;);&#xA;  Serial.println(&quot;Ending Code Generation&quot;);&#xA;  Serial.end();&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2015-12-31T07:46:56.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19110" PostTypeId="2" ParentId="12299" CreationDate="2015-12-31T08:57:30.320" Score="0" Body="&lt;p&gt;I found the Arduino examples a good reference for refreshing/learning C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important Arduino C++ classes are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;String: &lt;a href=&quot;https://www.arduino.cc/en/Reference/String&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/String&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Arduino classes for components: &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Libraries&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To learn more about the syntax of the language, the inventor of C++ has also a couple of videos online.&lt;/p&gt;&#xA;" OwnerUserId="1484" LastActivityDate="2015-12-31T08:57:30.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19111" PostTypeId="1" CreationDate="2015-12-31T09:58:17.077" Score="4" ViewCount="410" Body="&lt;p&gt;I need to display measurements of a sensor which need to be presented on a precise time-scale.&#xA;Since the loop function is not quite precise, how can i make sure that i can measure at say for example exactly 1ms?&#xA;( I am using an ADXL345 sensor ) &#xA;Thanks a lot!&lt;/p&gt;&#xA;" OwnerUserId="15977" LastActivityDate="2015-12-31T13:32:10.260" Title="How to have precise measurements" Tags="|sensors|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19112" PostTypeId="1" CreationDate="2015-12-31T10:02:49.597" Score="3" ViewCount="3605" Body="&lt;p&gt;Recently I got new Arduino Mega 2560 and &lt;a href=&quot;http://ebay.com/itm/MINI-V3-8-2-Wireless-Data-Transmission-Extension-Module-GSM-GPRS-SIM900A-/311402424851&quot; rel=&quot;nofollow noreferrer&quot;&gt;GSM/GPRS module - SIM900A v3.8.2&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I live in Europe, so I flashed European firmware for SIM900 and it was working OK (sending SMS, receive calls, sending http requests with GPRS) on my PC using PuTTY serial port terminal. After few tests, I ran default sketches from &lt;a href=&quot;https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;MarcoMartines GSMSHIELD&lt;/a&gt; library (other libraries weren't working for me) with Arduino Mega 2560 and they were running ok. After that I decided to make my own sketch. Here you go:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;SIM900.h&quot;&#xA;#include &quot;inetGSM.h&quot;&#xA;#include &quot;sms.h&quot;&#xA;#include &quot;call.h&quot;&#xA;&#xA;char NumberCalling[20];&#xA;char CorrectNumber[20] = {&quot;5&quot;, &quot;0&quot;, rest of my number here..... };&#xA;&#xA;void InstantSendSms()&#xA;{&#xA;  Serial.print(F(&quot;SMS: Preparing a text message to be sent to: &quot;));&#xA;  Serial.println(CorrectNumber);&#xA;&#xA;  char Message[155];&#xA;  sprintf(Message, &quot;Hello from Arduino :)&quot;);&#xA;&#xA;  Serial.print(F(&quot;Message to be sent : &quot;));&#xA;  Serial.println(Message);&#xA;  sms.SendSMS(CorrectNumber, Message);&#xA;  delay(50);&#xA;  Serial.println(F(&quot;SMS: Message has been sent.&quot;));&#xA;}&#xA;&#xA;void InstantSendHttp()&#xA;{  &#xA;&#xA;  char Address[155];&#xA;  sprintf(Address, &quot;test.php?text=test-message&quot;);&#xA;    Serial.println(F(&quot;GPRS: Opening a new Internet connection...&quot;));&#xA;&#xA;    if (inet.attachGPRS(&quot;internet&quot;, &quot;&quot;, &quot;&quot;))&#xA;      Serial.println(F(&quot;GPRS: Attached!&quot;));&#xA;    else &#xA;      Serial.println(F(&quot;GPRS: NOT attached! Error.&quot;));&#xA;    delay(1000);&#xA;&#xA;    //Read IP address.&#xA;    gsm.SimpleWriteln(&quot;AT+CIFSR&quot;);&#xA;    delay(5000);&#xA;    //Read until serial buffer is empty.&#xA;    gsm.WhileSimpleRead();&#xA;&#xA;    Serial.print(F(&quot;GET request : &quot;));&#xA;    Serial.println(Address);&#xA;&#xA;    char ReturnedMsg[50];&#xA;    int NumberRetMsg;&#xA;    NumberRetMsg = inet.httpGET(&quot;myserver.com&quot;, 80, Address, ReturnedMsg, 50);&#xA;    //Print the results.&#xA;    Serial.println(F(&quot;GPRS: Number of data received:&quot;));&#xA;    Serial.println(NumberRetMsg);  &#xA;    Serial.println(F(&quot;GPRS: Data received:&quot;)); &#xA;    Serial.println(ReturnedMsg); &#xA;&#xA;    inet.dettachGPRS();&#xA;&#xA;    Serial.println(F(&quot;GPRS: Query has been sent.&quot;));&#xA;&#xA;&#xA;  delay(2000);  // time to finish&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); // Serial connection via USB for debugging purposes&#xA;  Serial.println(F(&quot;*** Device is starting... ***&quot;));&#xA;  delay(50);&#xA;  Serial.println(F(&quot;* Setting up the GSM Module... *&quot;));&#xA;  // connection state&#xA;  boolean Connected = false;&#xA;  // establish network connection...&#xA;  while (!Connected)&#xA;  {&#xA;    if (gsm.begin(9600))&#xA;    {&#xA;      Serial.println(F(&quot;** GSM : GSM connection established. Ready. **&quot;));&#xA;      Connected = true;&#xA;    }&#xA;    else &#xA;    {&#xA;      Serial.println(F(&quot;** GSM : Failed to connect to the GSM network. **&quot;));&#xA;    }&#xA;  }&#xA;  delay(50);&#xA;  Serial.println(F(&quot;*** Setup complete! All systems are ON ***&quot;));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(F(&quot;GSM: Checking voice call status...&quot;));&#xA;  switch(call.CallStatusWithAuth(NumberCalling, 0, 0))&#xA;  {&#xA;    case CALL_INCOM_VOICE_AUTH: // Yes! Someone is calling us&#xA;      Serial.print(F(&quot;GSM: Receiving call... Caller ID: &quot;));&#xA;      Serial.println(NumberCalling);&#xA;      if(strcmp(NumberCalling, CorrectNumber) == 0)&#xA;      {&#xA;        Serial.println(F(&quot;GSM: Number IS matching whitelist!&quot;));&#xA;        delay(1800);  // Wait 1,8 seconds before hang up&#xA;        call.HangUp(); // Hang up on me&#xA;        InstantSendSms();&#xA;        InstantSendHttp();&#xA;      }&#xA;      else&#xA;      {&#xA;        Serial.println(F(&quot;GSM: Caller is unknown.&quot;));&#xA;        call.HangUp();&#xA;      }&#xA;      break;&#xA;    case CALL_NONE:&#xA;      Serial.println(F(&quot;GSM: No one is callin us right now.&quot;));&#xA;      break;&#xA;    default:&#xA;      Serial.println(F(&quot;GSM: Talking or not responding...&quot;));&#xA;      break;&#xA;  }&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At first, I used 9600 baud for GSM in the sketch. It successfully sent an SMS, but no luck with GPRS - in the Serial Monitor I got always the error message: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;GPRS: NOT attached! Error.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I read on the Internet that the baud rate is very important here. Somewhere on this forum I got the information that I should change baud rates in &lt;code&gt;HWSerial.cpp&lt;/code&gt; and &lt;code&gt;GSM.cpp&lt;/code&gt; in the library files to 4800 baud. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, I tried different bauds in my sketch. Finally I got this working with this configuration: in my sketch - 19200 baud, in library - 4800 baud. I run Arduino, SMS was sent ok, GPRS said &quot;GPRS: Attached!&quot; but no data came to my website. Then suddenly SIM900 module stopped working it is weirdly blinking. Power LED is brightening and darkening, and never goes off, and Status LED is quickly blinking. You can see that on the video, &lt;a href=&quot;http://youtu.be/BOAAtCoxGoo&quot; rel=&quot;nofollow noreferrer&quot;&gt;SIM900A Mini v3.8.2 - Weird blinking | Module not responding&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected it directly to my PC, PuTTy was receiving crazy input from the SIM900, as you can see below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tHaJu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tHaJu.jpg&quot; alt=&quot;PuTTY Receives corrupted input&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought that maybe the firmware had broken and I flashed again new firmware. It went smoothly and ok, but then again, module is acting in a strange way, the same as before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do to get it working normally?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&#xA;Hello. Today I tried again to work with my module. I communicated with sim900 using &lt;a href=&quot;http://m2msupport.net/m2msupport/module-tester/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://m2msupport.net/m2msupport/module-tester/&lt;/a&gt; , things are getting better, SIM900 is responding to AT commands. Module still doesn't work as it is supposed to - PowerLed is ON, StatusLed is indicating connecting to the network. It seems to be connected for about a second and then SIM900 is self-resetting and doing that over and over. How to fix that? &#xA;I don't think here power supply is guilty - it's 5V 2A.&lt;/p&gt;&#xA;" OwnerUserId="15978" LastEditorUserId="37523" LastEditDate="2019-05-14T20:02:21.173" LastActivityDate="2019-05-14T20:02:21.173" Title="MEGA2560 + SIM900A - constantly blinking, not responding" Tags="|arduino-mega|simulator|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="19113" PostTypeId="2" ParentId="19111" CreationDate="2015-12-31T10:36:32.180" Score="2" Body="&lt;p&gt;Microcontrollers have built in peripherals called Timers. They are used for many purposes, including working out when something should be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are plenty of good Timer libraries around for the Arduino, including the popular &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;TimerOne/TimerThree libraries&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T10:36:32.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19114" PostTypeId="2" ParentId="19105" CreationDate="2015-12-31T11:09:14.007" Score="2" Body="&lt;p&gt;You haven't defined any capture groups in your regexp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regexp &lt;code&gt;[aeiou]&lt;/code&gt; will &lt;em&gt;match&lt;/em&gt; any of those characters, but it won't &lt;em&gt;capture&lt;/em&gt; them.  To capture you need to define a &lt;em&gt;capture group&lt;/em&gt; which is a sequence of tokens surrounded by parenthesis.  For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;([aeiou])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your test phrase &quot;The quick brown fox jumps over the lazy wolf&quot; that should match 11 times and capture each match, resulting in captures of &lt;em&gt;e u i o o u o e e a o&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why matching and capturing are two completely different things is so you can do things like &lt;code&gt;[aeiou]([aeiou])&lt;/code&gt; which would capture the second vowel in a two vowel sequence. In your example it would match the &lt;em&gt;ui&lt;/em&gt; of &lt;em&gt;quick&lt;/em&gt; and capture just the &lt;em&gt;i&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T11:09:14.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19115" PostTypeId="2" ParentId="19098" CreationDate="2015-12-31T11:29:08.150" Score="2" Body="&lt;p&gt;The simplest thing you can do is to create a simple function that performs both tasks for you.  However, there are certain caveats that you should look out for.  The most basic function would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void log(const char *msg) {&#xA;    Serial.println(msg);&#xA;    myFile.println(msg);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However that is not the best way of doing it since that requires all your messages to be in RAM.  So you should really use the &lt;code&gt;__FlashStringHelper&lt;/code&gt; type as well as an &lt;em&gt;overload&lt;/em&gt; function so you can use the &lt;code&gt;F()&lt;/code&gt; macro to save RAM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void log(const char *msg) {&#xA;    Serial.println(msg);&#xA;    myFile.println(msg);&#xA;}&#xA;&#xA;void log(const __FlashStringHelper *msg) {&#xA;    Serial.println(msg);&#xA;    myFile.println(msg);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that will pick the right version of &lt;code&gt;log&lt;/code&gt; depending on what you pass.  But what if you want to pass some variables, like numbers?  Overloading can help again here.  Another pair of functions now that take two parameters instead of one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void log(const char *msg) {&#xA;    Serial.println(msg);&#xA;    myFile.println(msg);&#xA;}&#xA;&#xA;void log(const __FlashStringHelper *msg) {&#xA;    Serial.println(msg);&#xA;    myFile.println(msg);&#xA;}&#xA;&#xA;void log(const char *msg, int v) {&#xA;    Serial.print(msg);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(v);&#xA;    myFile.print(msg);&#xA;    myFile.print(&quot; &quot;);&#xA;    myFile.println(v);&#xA;}&#xA;&#xA;void log(const __FlashStringHelper *msg, int v) {&#xA;    Serial.print(msg);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(v);&#xA;    myFile.print(msg);&#xA;    myFile.print(&quot; &quot;);&#xA;    myFile.println(v);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now you have 4 functions called &lt;code&gt;log&lt;/code&gt;, and they can be used in these different ways:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;log(&quot;This is a message&quot;); // Could be a char * variable&#xA;log(F(&quot;This is a message&quot;));&#xA;log(&quot;The temperature is:&quot;, temp);&#xA;log(F(&quot;The temperature is:&quot;, temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course you can keep expanding and expanding the parameters in different ways for different combinations of parameters.  Just be warned that for some combinations of parameters the compiler won't be able to work out which is the right function to call (for instance if you have one that takes a &lt;code&gt;long&lt;/code&gt; and one that takes a &lt;code&gt;byte&lt;/code&gt; in the same place and you just pass a numeric literal), so you have to think carefully about how you arrange your parameters.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T11:29:08.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19116" PostTypeId="2" ParentId="19111" CreationDate="2015-12-31T13:14:08.117" Score="4" Body="&lt;p&gt;The &lt;a href=&quot;http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf&quot; rel=&quot;nofollow&quot;&gt;ADXL345&lt;/a&gt; has both a FIFO and data rate setting. This allows sampling to be done with a precise frequency without having to use timers, etc, on the MCU. The MCU/Arduino has to fetch data before the FIFO overflows. The max sampling frequency depends on the communication protocol (I2C or SPI), i.e. how fast the MCU can empty the FIFO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use the ADXL345 in stream mode, collect samples at a fixed rate, and get an interrupt when the FIFO has been filled to a specified level (watermark). The samples can then be read in burst mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The samples will be on a &quot;precise time-scale&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are even more advanced usages of the device with tap, double-tap and free fall detect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see Data Rate setting and FIFO control in datasheet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Using I2C at 100 KHz will take 1 ms just to address the device. Addressing a register will take another ms and a ms per data byte. Reading the data register (six bytes) will take at least 8 ms. Realistic max sample rate with I2C at 100 KHz is 10-100 Hz. There is also limited amount of memory for buffers.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2015-12-31T13:32:10.260" LastActivityDate="2015-12-31T13:32:10.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19117" PostTypeId="2" ParentId="12299" CreationDate="2015-12-31T13:48:10.923" Score="1" Body="&lt;p&gt;I would start with &lt;a href=&quot;https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list&quot;&gt;a standard C++ introduction book&lt;/a&gt; to get an understanding for the language. After that I would read a book on &lt;a href=&quot;http://www.amazon.com/Best-Sellers-Books-Object-Oriented-Design/zgbs/books/4013&quot; rel=&quot;nofollow noreferrer&quot;&gt;object-oriented design and implementation&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a lack of books on how to systematically approach programming small scale embedded systems such as Arduino. Due to the restrictions on resources, both processing and memory, C++ has to be used &quot;carefully&quot;. There is a need to understand some of the more difficult concepts such as volatile, virtual, ISR, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reading others code is also a very good way to learn. I would recommend looking at the source code and example sketches to &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow noreferrer&quot;&gt;Cosa&lt;/a&gt;. This is an OOP framework for Arduino/AVR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last but not least - learning by doing!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2015-12-31T14:27:58.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19119" PostTypeId="2" ParentId="14734" CreationDate="2015-12-31T16:48:19.400" Score="0" Body="&lt;p&gt;The amplifier circuit you refer to puts out 2.5 volts even without input from microphone. The LM386 has internal circuitry to make the output 1/2 of the +5 volts. Then, audio signal goes above and below the 2.5 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The amplifier circuit will only be putting out the PEAK of your audio signal (because D1 and C2 is a peak detector)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when all is quiet, take that ADC value as meaning zero microphone input. &lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2015-12-31T16:48:19.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19120" PostTypeId="2" ParentId="19075" CreationDate="2015-12-31T17:31:41.843" Score="0" Body="&lt;p&gt;I'd suggest taking this in small hunks. If you haven't done it already, your first step should be to get your development environment together. Use it to create and upload a simple test. The Blink sketch is a common place to start. There are excellent tutorials at the Adafruit site, the have a whole series for &lt;a href=&quot;https://learn.adafruit.com/lesson-0-getting-started/overview&quot; rel=&quot;nofollow&quot;&gt;getting started with the Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you've gotten far enough with the basics to start feeling confident. Try searching for a tutorial for your project. You can often find them by searching on Google – try something like &quot;arduino xbee shield tutorial&quot; – look for descriptions that sound like what you want to do and try reading them. Another good place to look for tutorials is on sites that sell the hardware you're interested in using. For example Adafruit has &lt;a href=&quot;https://learn.adafruit.com/xbee-radios/overview&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; on getting started with the Xbee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you work through the tutorials, come back with more questions. As you get more experience it will be easier to ask specific questions and those are easier to answer :-)&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-31T17:31:41.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19121" PostTypeId="2" ParentId="18512" CreationDate="2015-12-31T17:57:09.307" Score="0" Body="&lt;p&gt;It seems like you could do this with a transistor (if &quot;faking&quot; a digital signal from the ACS712 doesn't work). A simple circuit where the VIOUT of the ACS712 drives the base of a switching transistor connected to a digital pin on the Arduino with an internal pull up might do the trick (assuming that the ACS712 give you a voltage on VIOUT that is proportional to the current).&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2015-12-31T17:57:09.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19122" PostTypeId="2" ParentId="18784" CreationDate="2015-12-31T18:03:19.270" Score="0" Body="&lt;p&gt;Ryan Griggs' suggestion of the Mega is likely to be easier and more economical than using multiple Unos. That said can you say more about what you want to do with your proposed design? There are good reasons for distributing the load and the problems are interesting – so it is not obvious that the &quot;right&quot; answer is just to use a bigger central machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides tightly coupling them with the SPI or I2C you could also consider using Ethernet or Bluetooth. Arduino Ethernet shields tend to be expensive, but there are some wireless devices like the &lt;a href=&quot;https://www.adafruit.com/product/2471&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit Huzzah&lt;/a&gt; that are more economical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find this &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;post on I2C&lt;/a&gt; by Nick Gammon helpful. There is a similar example in &lt;a href=&quot;https://arduino.stackexchange.com/questions/15872/arduino-mega-with-two-arduino-unos-as-slaves-via-i2c?rq=1&quot;&gt;this question&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2015-12-31T18:08:21.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19123" PostTypeId="2" ParentId="18512" CreationDate="2015-12-31T18:25:49.743" Score="0" Body="&lt;p&gt;The Arduino/AVR (for instance &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega328p, chap. 22&lt;/a&gt;) has an analog comparator (D6/AIN0, D7/AIN1 or any analog pin). This could be used with the correct reference voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2015-12-31T18:25:49.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19124" PostTypeId="1" AcceptedAnswerId="19125" CreationDate="2015-12-31T11:20:23.213" Score="0" ViewCount="1413" Body="&lt;p&gt;I'm looking into how to smoothly crossfade between colors on an RGB LED with the Arduino and I've found this piece of code for doing it:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ColorCrossfader&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ColorCrossfader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand all parts of the code except for one thing.&#xA;The values for red, green and blue are changed incrementally through 1020 steps, because 255*4 = 1020.&#xA;But WHY 4? There are 3 colors, and 255 * 3 = 765. So why not 765 steps?&lt;/p&gt;&#xA;" OwnerUserId="16049" OwnerDisplayName="Harald" LastActivityDate="2018-02-22T10:46:27.880" Title="Why is 1020 steps used for crossfading colors on an RGB LED?" Tags="|led|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19125" PostTypeId="2" ParentId="19124" CreationDate="2015-12-31T11:53:13.687" Score="2" Body="&lt;p&gt;Extract from code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int wait = 10;      // 10ms internal crossFade delay; increase for slower fades&#xA;&#xA;for (int i = 0; i &amp;lt;= 1020; i++) {&#xA;  redVal = calculateVal(stepR, redVal, i);&#xA;  grnVal = calculateVal(stepG, grnVal, i);&#xA;  bluVal = calculateVal(stepB, bluVal, i);&#xA;&#xA;  analogWrite(redPin, redVal);   // Write current values to LED pins&#xA;  analogWrite(grnPin, grnVal);      &#xA;  analogWrite(bluPin, bluVal); &#xA;&#xA;  delay(wait); // Pause for 'wait' milliseconds before resuming the loop&#xA;&#xA;  if (DEBUG) { // If we want serial output, print it at the &#xA;    if (i == 0 or i % loopCount == 0) { // beginning, and every loopCount times&#xA;    } &#xA;    DEBUG += 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 1020 in the loop determines the time taken to make the crossfade from the current colour to the next - not the total cycle as you seem to think. In the main loop we have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;crossFade(red);&#xA;crossFade(green);&#xA;crossFade(blue);&#xA;crossFade(yellow);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And each of these crossfades will take 1024 * wait ms to complete. 'wait' is set to 10 ms so I would expect it to take 10.24 s to complete a fade from one colour to the next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Edit]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the large number (1020) is just to give a fine resolution in the steps calculation which is all done with integers. (What struck me as odd is that it doesn't use 256 * 4 = 1024.) The larger we make this number the finer the step resolution becomes. With coarse steps the ramp will complete too early.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we had 255 steps and we wish to go from 134 to 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;step = 255 / (endValue - prevValue)&#xA;step = 255 / (134 - 0 ) = 1.9 which will be rounded down to 1.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the crossfade will be complete in 134 steps instead of 255. i.e., it will finish 47% early.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we use 1020 steps and we wish to go from 134 to 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;step = 1020 / (endValue - prevValue)&#xA;step = 1020 / (134 - 0 ) = 7.6 which will be rounded down to 7.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the crossfade will be complete in 938 steps instead of 1020. i.e., it will finish 8% early.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="transistor" LastActivityDate="2015-12-31T13:11:16.777" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19127" PostTypeId="1" AcceptedAnswerId="20155" CreationDate="2015-12-31T20:23:08.197" Score="3" ViewCount="3835" Body="&lt;p&gt;I am using the dynamic memory in AVR microcontroller, so How to know that there is collision between stack and heap or if the memory has been filled?&lt;/p&gt;&#xA;" OwnerUserId="15990" LastActivityDate="2016-03-02T11:38:17.250" Title="AVR - How to know that there is collision between stack and heap or the memory has filled?" Tags="|avr|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19128" PostTypeId="2" ParentId="19127" CreationDate="2015-12-31T20:27:29.473" Score="2" Body="&lt;p&gt;In simple terms: if the stack and heap have collided then the program will most likely crash, and any countermeasures you may have in place are now null and void.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you can find out the current amount of free memory quite easily by looking at where the top of the heap is and creating a local variable on the stack and getting its address - subtract one from the other and you get the free memory size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's exactly what the &lt;a href=&quot;http://playground.arduino.cc/Code/AvailableMemory&quot; rel=&quot;nofollow&quot;&gt;MemoryFree Library&lt;/a&gt; does for you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T20:27:29.473" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19129" PostTypeId="1" CreationDate="2015-12-31T22:19:43.610" Score="1" ViewCount="5653" Body="&lt;p&gt;I have a bricked Arduino Uno and I want to try to flash the bootloader. I'm trying to figure out how to do it. &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;On this tutorial from SparkFun&lt;/a&gt; you can see this diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qad6g.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qad6g.jpg&quot; alt=&quot;Spark Fun layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They also show this table of the pinout&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TL2O2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TL2O2.png&quot; alt=&quot;SparkFun Pinout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That seems simple enough but it's totally different than the official tutorial, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Circuit (targeting Arduino Uno, Duemilanove, or Diecimila)&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qv3la.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qv3la.png&quot; alt=&quot;Schematic between two Arduinos&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which also says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An Arduino board serving as an ISP to program the ATmega on another Arduino board. On the Arduino Uno, you'll need to connect a 10 uF capacitor between reset and ground (after uploading the ArduinoISP sketch). Note that you need access to the reset pin on the target board, which isn't available on NG or older boards.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So do I need a 10 uF capacitor between reset and ground? How do I put a 10 uF capacitor in between reset and ground when, in this configuration, reset is connected to PIN 10? Why are there two configurations? What's the upsides and downsides to either of them?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="13972" LastEditDate="2015-12-31T23:11:52.827" LastActivityDate="2016-01-31T02:32:52.320" Title="What is the proper way to turn an Arduino UNO into an ISP?" Tags="|arduino-uno|bootloader|isp|icsp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19130" PostTypeId="1" CreationDate="2015-12-31T22:34:26.607" Score="4" ViewCount="8146" Body="&lt;p&gt;I'm not sure if these terms are interchangeable or not. What's the difference between ICSP and ISP? Is it simply the reset? I've shown &lt;a href=&quot;https://arduino.stackexchange.com/questions/19129/what-is-the-proper-way-to-turn-an-into-an-isp&quot;&gt;two configurations in this question I just asked&lt;/a&gt;. Are they both ICSP?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-31T02:25:08.443" Title="What's the difference between ICSP vs ISP?" Tags="|isp|icsp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19131" PostTypeId="2" ParentId="19129" CreationDate="2015-12-31T22:37:08.393" Score="1" Body="&lt;p&gt;The wiring is actually identical. It just uses the ISP header (2x3 pins) on the target board, instead of the pins 5v, GND, RST, 11, 12, 13. Just like the table you added says.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The downside to using the ISP header, is you need a male to female wire for connecting. Upside is you can easily take of these 6 pins, and connect it to a different arduino to be programmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I always needed to add a capacitor between RESET and GND. The exact value isn't that critical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reset pin is the one to the left of 3v3.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2015-12-31T22:37:08.393" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19132" PostTypeId="2" ParentId="19130" CreationDate="2015-12-31T22:50:41.870" Score="4" Body="&lt;p&gt;The difference between ISP and ICSP is a hyphen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ISP stands for In-circuit Serial Programming, and ICSP stands for In Circuit Serial Programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any arrangement that allows you to program a microcontroller while it is in a circuit using a serial protocol can be called ISP or ICSP.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T22:50:41.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19133" PostTypeId="1" CreationDate="2015-12-31T22:52:10.163" Score="0" ViewCount="173" Body="&lt;p&gt;I have two Arduino's. One from .org, and one from .cc. The arduino.org one has really nice silk screening on the header pins. The arduino.cc one does not. In addition there are some visible component differences. One has a 504S (not sure what this chip is), one has a 504L. The button on the .org one is a bit more tactile. The headers on the top (not the ICSP) headers are missing on the .org one. And, the four points that look like they're for soldering or testing are absent. I can try to get a high-res picture of the two up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought the .org one in a beginner kit online from Amazon (from the official seller). And, the .cc I bought from their website directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The .org one seems like it's made from higher-end components, and actually having the headers at the top makes it seem more polished. Is there any through guide to what these differences are or a changelog from one hardware revision to another?&lt;/p&gt;&#xA;" OwnerUserId="13972" LastEditorUserId="13972" LastEditDate="2015-12-31T23:03:54.590" LastActivityDate="2015-12-31T23:19:17.407" Title="Does Arduino.cc silkscreen the pin headers? What explains the differences here?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ClosedDate="2016-01-21T20:44:55.293" ContentLicense="CC BY-SA 3.0" />
  <row Id="19134" PostTypeId="2" ParentId="19133" CreationDate="2015-12-31T23:19:17.407" Score="2" Body="&lt;p&gt;No, there is nothing that documents the differences as in a changelog, purely because this is not an iterative change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two boards are designed and manufactured by two different (competing) companies in two different countries (USA and Italy) using different component suppliers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just because they both say Arduino UNO doesn't make them both the same board - not these days anyway, since the founders of Arduino got really childish and started throwing their faeces at each other like monkeys in the zoo.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2015-12-31T23:19:17.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19138" PostTypeId="2" ParentId="8674" CreationDate="2016-01-01T01:44:07.080" Score="0" Body="&lt;p&gt;This would be a good place to get out tcpdump or WireShark (or any other tool that will let you observe network traffic). If you watch the traffic while you're making the a request that goes to the Arduino (perhaps use a phone to make the request so that it comes from outside) you will be able to observe the TCP/IP transactions and see where the delays are.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-01T01:44:07.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19140" PostTypeId="1" AcceptedAnswerId="19141" CreationDate="2016-01-01T03:31:10.607" Score="2" ViewCount="1901" Body="&lt;p&gt;I would like to have a backup battery connected to a device that requires an uninterrupted power supply, like an Arduino or Raspberry Pi, so that if my primary power source (USB plug) gets pulled, the device will switch to being powered by the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need a solution that I can either build on a breadboard or buy for only a couple dollars. Does anyone know a solution? I'm assuming this is a common need and think I perhaps am not searching with the correct key words.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add that I may also use 4AA batteries and a DC-DC step down module to produce 5V exactly to power a 5V device, so I'm looking for a solution that accepts 5V. Assume the device, let's say Raspberry Pi, takes 5V, the power supply is 5V, and the battery backup is 5V.&lt;/p&gt;&#xA;" OwnerUserId="15995" LastEditorUserId="15995" LastEditDate="2016-01-01T05:17:06.550" LastActivityDate="2016-01-01T18:39:35.060" Title="How to build circuit to switch to other power source if primary source dies?" Tags="|battery|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19141" PostTypeId="2" ParentId="19140" CreationDate="2016-01-01T05:07:22.330" Score="2" Body="&lt;p&gt;Your $2 budget rules out some of the more-effective possible solutions, such as using an actual UPS (uninterruptible power supply) system.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One affordable approach is to connect the plus side of a 3.7 V lithium-polymer battery through a Schottky diode [such as MBR0520, SS14, 1N5819] to the +5 V line of an Arduino board.  (I haven't looked at Raspberry Pi schematics and don't know if this will apply there.)  Hook the minus side of the battery to Arduino ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, the battery voltage less the voltage drop through the diode (say .4–.5 V) should be just less than the voltage that USB supplies.  Ie, just under 5 V if you have a 5 V board, or just under 3.3 V for a 3.3 V board.  Note, most 3.3 V Arduino systems are specified to run at 8 MHz rather than 16.  There's a good chance a 5 V Arduino running at 16 MHz would continue to run ok when powered by about 3.3 V, but it's out of spec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your battery voltage exceeds 5 V you won't be able to make the connection quite so directly.  Besides certain risks of damage (see eg Method #5 and Method #8 of &lt;a href=&quot;http://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;10 Ways to Destroy An Arduino&lt;/a&gt;) there will be the practical matter that the higher battery voltage will cause its power to be used preferentially to the USB power, thus discharging the battery so that it won't act as a backup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; The question-edit says the system uses 5 V, and seems to suggest the primary 5V power supply uses 4 AA batteries and a DCDC converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the DCDC converter is a step-down &lt;a href=&quot;https://en.wikipedia.org/wiki/Buck_converter&quot; rel=&quot;nofollow noreferrer&quot;&gt;buck converter&lt;/a&gt; it will go out of regulation when the input voltage from the four AA's goes below 5 V, which is 1.25 V per cell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from the following graph, if the discharge rate of a typical alkaline cell is 100 mA, it still has about half its power left when its voltage goes below 1.25 V.  To fully use up the alkaline batteries, you could use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Buck%E2%80%93boost_converter&quot; rel=&quot;nofollow noreferrer&quot;&gt;buck-boost converter&lt;/a&gt; or could test if your buck converter just passes the voltage on through, as opposed to shutting down when the input voltage is low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JN2dL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JN2dL.png&quot; alt=&quot;alkaline AA-battery discharge curve&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note, the AA-battery discharge curves shown above and below are from the &lt;a href=&quot;http://www.powerstream.com/AA-tests.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;powerstream.com's “AA tests”  web page&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the backup battery, where you also want 5 V output, an economical possibility is use of four AA NiMH cells, with nominal voltage 1.2 V per cell. However, initial voltage officially can exceed 1.4 V per cell, giving 5.6 V total:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nL7mz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nL7mz.png&quot; alt=&quot;NiMH AA-battery discharge curve&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Schottky diode in series will bring that down to say 5.2 V, an acceptable level for powering a 5 V system.  But if the primary supplies 5.0 V, the backup will end up discharging slightly until its output voltage goes below that of the primary.  If that's acceptable, fine.  Otherwise, you could use a diode like 1N4001, with 0.7 to 0.8 volts of drop at 0 to 150 mA output.  Instead of losing some backup power at first (due to higher backup than primary voltage) you will lose some at the end, due to backup voltage going too low slightly sooner. That won't be a problem, however, if you restore the primary supply and recharge the backups in time to prevent over-discharge damage to the backup batteries.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-01T18:39:35.060" LastActivityDate="2016-01-01T18:39:35.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19142" PostTypeId="1" AcceptedAnswerId="19143" CreationDate="2016-01-01T06:01:52.763" Score="2" ViewCount="1956" Body="&lt;p&gt;I am using RF24 modules with my two Arduinos Leonardo with the &lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;nofollow&quot;&gt;RF24&lt;/a&gt; library. My goal is to be able to press a button on the first Arduino which will light up an LED on the second Arduino, and be able to press a button on the second Arduino to light up an LED on the first Arduino. I was easily able to figure this out as a one-way transmission with the first Arduino only transmitting and the second only receiving, but I am unable to make it a two-way transmission, where each Arduino can transmit and receive at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;RF24_config.h&amp;gt;&#xA;&#xA;int msg[1];&#xA;RF24 radio(9,10);&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;const uint64_t pipe2 = 0xF0F0F0F0AA;&#xA;void setup(void){&#xA;  Serial.begin(57600);&#xA;  pinMode(A0, INPUT);&#xA;  radio.begin();&#xA;  radio.openWritingPipe(pipe);&#xA;  radio.openReadingPipe(1,pipe2);&#xA;}&#xA;&#xA;void loop(void){&#xA;  int charToSend[1];&#xA;  charToSend[0] = digitalRead(A0);&#xA;  if (!radio.write(charToSend,1)) {Serial.println('didn\'t send');}&#xA;  radio.startListening();&#xA;  if (radio.available()){&#xA;    bool done = false;  &#xA;    done = radio.read(msg, 1); &#xA;    Serial.println(msg[0]);&#xA;    digitalWrite(13, msg[0]);&#xA;  }&#xA;  radio.stopListening();&#xA;  radio.powerDown(); &#xA;  delay(10);&#xA;  radio.powerUp();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the &lt;code&gt;radio.write()&lt;/code&gt; is returning false and therefore not sending.&lt;/p&gt;&#xA;" OwnerUserId="15997" LastEditorUserId="4628" LastEditDate="2016-01-04T19:39:03.830" LastActivityDate="2016-01-04T19:39:03.830" Title="RF24 tranceivers: trouble with two way communication" Tags="|arduino-leonardo|nrf24l01+|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19143" PostTypeId="2" ParentId="19142" CreationDate="2016-01-01T12:07:28.653" Score="3" Body="&lt;p&gt;The main thing that I can see wrong with your sketch is that the logic of your methodology is backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are spending most of your time either with the radio asleep, or not in listening mode, so it can not receive anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to spend all your time in listening mode waiting for messages to arrive, and only when the button changes state do you want to switch off listening mode and send a packet to the other end. As soon as you have done that you then go back to listening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't listen while the radio is powered down, so using &lt;code&gt;powerDown()&lt;/code&gt; and &lt;code&gt;powerUp()&lt;/code&gt; is just nonsense.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-01T12:07:28.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19144" PostTypeId="1" CreationDate="2016-01-01T13:41:22.290" Score="2" ViewCount="1970" Body="&lt;p&gt;The Arduino distance meter that I made doesn't display the correct distance. It just displays &quot;0.0 inches&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;int pingPin = 7;&#xA;int inPin = 6;&#xA;long duration, inches, cm;&#xA;int indec, cmdec;&#xA;int inchconv = 147;&#xA;int cmconv = 59;&#xA;String s1, s2;&#xA;&#xA;void setup() {&#xA;  lcd.begin(16, 2);&#xA;  pinMode(pingPin, OUTPUT);&#xA;  pinMode(inPin, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(pingPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(pingPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(pingPin, LOW);&#xA;&#xA;  duration = pulseIn(inPin, HIGH);&#xA;&#xA;  inches = microsecondsToInches(duration);&#xA;  indec = (duration - inches * inchconv) * 10 / inchconv;&#xA;  cm = microsecondsToCentimeters(duration);&#xA;  cmdec = (duration - cm * cmconv) * 10 / cmconv;&#xA;  s1 = String(inches) + &quot;.&quot; + String(indec) + &quot;in&quot; + &quot;     &quot;;&#xA;  s2 = String(cm) + &quot;.&quot; + String(cmdec) + &quot;cm&quot; + &quot;     &quot;;&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(s1);&#xA;  lcd.setCursor(0,1);&#xA;  lcd.print(s2);&#xA;&#xA;  delay(100);&#xA;}&#xA;&#xA;long microsecondsToInches(long microseconds)&#xA;{&#xA;  return microseconds / inchconv;&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;  return microseconds / cmconv;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the wiring diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sCAqn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sCAqn.jpg&quot; alt=&quot;Fritzing diagram of Arduino distance meter&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Might there be a problem in my code, or in my wiring?&lt;/p&gt;&#xA;" OwnerUserId="15999" LastEditorUserId="3917" LastEditDate="2016-01-02T05:01:47.297" LastActivityDate="2017-09-19T10:53:56.150" Title="Arduino ultrasonic distance meter doesn't display correct distance" Tags="|arduino-uno|sensors|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19145" PostTypeId="2" ParentId="18072" CreationDate="2016-01-01T18:10:56.330" Score="1" Body="&lt;p&gt;You may want to take a look at LMX by David Anderson &lt;a href=&quot;http://www.geology.smu.edu/dpa-www/robo/LMX&quot; rel=&quot;nofollow&quot;&gt;A Light-Weight Multi-Tasking Executive&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He has a very good set of videos on the code that he did for &lt;a href=&quot;https://www.youtube.com/channel/UCsGzeeBTraAts7lMQdfhqtA&quot; rel=&quot;nofollow&quot;&gt;Dallas Personal Robotics Group (DPRG)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific videos for LMX are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=nRaosdrDrdA&quot; rel=&quot;nofollow&quot;&gt;David Anderson on Robotics Software - part 1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Jnrg4WAtxGQ&quot; rel=&quot;nofollow&quot;&gt;David Anderson on Robotics Software - part 2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16005" LastActivityDate="2016-01-01T18:10:56.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19146" PostTypeId="1" CreationDate="2016-01-01T18:19:28.907" Score="1" ViewCount="123" Body="&lt;p&gt;How can I programme a USB mouse connected to the standard USB port of the Intel Edison's Arduino expansion board?  I would like to measure the displacement of the mouse and also specify the frequency of image capture using the mouse's optical sensor.  I do not know much about programming so tutorials relating to my project would be very helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16004" LastActivityDate="2016-01-01T19:35:51.163" Title="Programming a USB mouse connected to the Intel Edison Arduino expansion board" Tags="|edison|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19147" PostTypeId="2" ParentId="19144" CreationDate="2016-01-01T18:23:54.920" Score="2" Body="&lt;p&gt;To solve a problem like this you need to break it down into smaller pieces so that you can build up some confidence about what is working and what is not. When you share a problem like this as a question it helps if you can give us some idea of your experience level and of what you've already done to debug the problem – that helps with avoiding telling you what you already know and makes it easier to focus in on where the problem might be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what you've said it appears that you have things working well enough that you get a display on the LCD but it does not represent a meaningful distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at your schematic the first thing that comes to my mind is that you have the ultrasonic sensor at the opposite end of the breadboard from the LCD. Many breadboards split their power rails at the middle. So start by confirming that you have power to the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, double-check the rest of your wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next step for me would be to confirm that I understood the sensor and to try and prove that it was working as I expected. Look for some sample code that is known to work (often the site you bought the sensor from will have links to beginning tutorials or code samples). Try that to see if the sensor works with the sample code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work then check to see what you can do to prove the sensor is good (or bad). You might also contact the vendor to see if they can give you advice on proving that the sensor works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, break the problem down into &quot;bite sized&quot; chunks and work through it one step at a time, doing the simple stuff first. Try not to assume anything…&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-01T18:29:46.917" LastActivityDate="2016-01-01T18:29:46.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19148" PostTypeId="2" ParentId="19146" CreationDate="2016-01-01T19:35:51.163" Score="2" Body="&lt;p&gt;Here's a simple introduction to using the USB mouse as an input device. That might be a good starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://tahmidmc.blogspot.com/2015/12/using-input-device-on-embedded-linux.html&quot; rel=&quot;nofollow&quot;&gt;http://tahmidmc.blogspot.com/2015/12/using-input-device-on-embedded-linux.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16008" LastActivityDate="2016-01-01T19:35:51.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19150" PostTypeId="1" AcceptedAnswerId="19154" CreationDate="2016-01-01T20:37:47.090" Score="4" ViewCount="15973" Body="&lt;p&gt;I have connected an LCD with an I2C backpack to my Arduino Uno but it prints the wrong characters. The weird thing is that it worked fine for a while and when I updated the code (but didn't change anything to do with the LCD) it started displaying the wrong characters. This happened earlier today too. That time, reinstalling the LiquidCrystal library worked, but it doesn't now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what might be the problem so I can fix it permanently?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD's SDA and SCL are connected to A4 and A5 respectively and I'm running this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16     chars and 2 line display&#xA;&#xA;void setup()&#xA;{&#xA;  lcd.init();&#xA;  lcd.backlight();&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;Hello, world!&quot;);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is what's displayed on the screen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y9l43.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y9l43.jpg&quot; alt=&quot;some random characters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16010" LastEditorDisplayName="user6430" LastEditDate="2016-01-06T03:16:25.027" LastActivityDate="2018-10-15T15:42:23.587" Title="I2C LCD displaying weird characters" Tags="|arduino-uno|i2c|lcd|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19152" PostTypeId="2" ParentId="17436" CreationDate="2016-01-01T21:56:22.360" Score="-1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;USB power vs linked&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.mysensors.org/topic/186/new-library-to-read-arduino-vcc-supply-level-without-resistors-for-battery-powered-sensor-nodes-that-do-not-use-a-voltage-regulator-but-connect-directly-to-the-batteries&quot; rel=&quot;nofollow&quot;&gt;Read it&lt;/a&gt; and use current Vcc instead of 5.0 in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the same sensor and have the same problem. I'll be glad if you share full working code in this thread.&lt;/p&gt;&#xA;" OwnerUserId="16013" LastActivityDate="2016-01-01T21:56:22.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19153" PostTypeId="2" ParentId="9087" CreationDate="2016-01-01T21:58:30.290" Score="1" Body="&lt;p&gt;You probably want to take a look at Robert Faludi's book &lt;a href=&quot;http://shop.oreilly.com/product/9780596807740.do&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;Building Wireless Sensor Networks&lt;/em&gt;&lt;/a&gt;, published by O'Reilly. He describes, step by step, a very similar project, but without the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or Alasdair Allan's &lt;a href=&quot;http://shop.oreilly.com/product/0636920028802.do&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;Distributed Network Data&lt;/em&gt;&lt;/a&gt;, also published by O'Reilly, which has a similar project using an Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, take a look at Robert Faludi's blog &lt;a href=&quot;https://www.faludi.com/bwsn/tmp36-instructions-simple-sensor-network/&quot; rel=&quot;nofollow&quot;&gt;TMP36 Instructions: Simple Sensor Network&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastActivityDate="2016-01-01T21:58:30.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19154" PostTypeId="2" ParentId="19150" CreationDate="2016-01-01T22:38:27.723" Score="7" Body="&lt;p&gt;If you look up the ASCII codes for what you sent vs what was displayed, and also look at &quot;Table 4 Correspondence between Character Codes and Character Patterns (ROM Code: A00)&quot; in an HD44780U spec sheet, you will find hexadecimal values like the following.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;e 65, V  56&lt;/li&gt;&#xA;&lt;li&gt;l 6C, ニ C6&lt;/li&gt;&#xA;&lt;li&gt;o 6F, θ  F2&lt;/li&gt;&#xA;&lt;li&gt;o 6F, π  F7&lt;/li&gt;&#xA;&lt;li&gt;r 72, &amp;amp;  26&lt;/li&gt;&#xA;&lt;li&gt;d 64, B  24&lt;/li&gt;&#xA;&lt;li&gt;and so forth.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It appears that the high nibble of what you sent is being used as the low nibble of what is displayed, and the low nibble is being used as the high, but with some bits sometimes going wrong.  Note, a space is 0x20, and the reverse of that is 0x02, which would access a character from the character-generator RAM, which will contain random bits and produce a random blob as in your picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your mis-specification of display size (20, 4 vs 16, 2) isn't responsible for the problem, then maybe there is a hardware problem with the backpack you've soldered on to the LCD.  Look at it under a bright light, using a binocular parts-examination microscope if you've got one, and see if there are loose solder particles, extra solder flux, or loose solder connections on that board.  If you have an oscilloscope, check if your I2C signals are clean and have full swing.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-01T22:38:27.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19155" PostTypeId="1" AcceptedAnswerId="19166" CreationDate="2015-12-30T16:06:12.593" Score="1" ViewCount="1535" Body="&lt;p&gt;I have a gamepad which I want to treat as a sensor for my Arduino board. I want Arduino to trigger a certain action based on button pushes from the gamepad. Different buttons, different actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gamepad comes with a USB connector. I cut the the USB cable open, solder it with pluggable pins which are then connected to a breadboard. I supply the gamepad with 5V power from Arduino and connect the USB's Data+ to Arduino's analog input pin (A0). Please check the images below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought by observing the voltage coming from the gamepad's Data+ pin, I can probably determine if a button is being pushed. However, the observable input voltage in Arduino's A0 do not produce any meaningful difference between button push and release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: Is it possible to detect Gamepad's button pushes with this arrangement? If it's possible, where do you think I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hEZRk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hEZRk.jpg&quot; alt=&quot;USB Gamepad and Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/V6e4s.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fV6e4s.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="13623" OwnerDisplayName="Andree" LastActivityDate="2021-11-29T12:25:19.063" Title="Observing USB Gamepad with Arduino?" Tags="|usb|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19156" PostTypeId="2" ParentId="19150" CreationDate="2016-01-01T23:40:34.050" Score="2" Body="&lt;p&gt;From what I can see, it seems, in this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    LiquidCrystal_I2C lcd(0x27,20,4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;wrong parameters have been passed to the constructor. The last two arguments are supposed to indicate the number of columns and rows on the screen. Your screen has 16 columns and 2 rows, whereas you passed 20 columns and 4 rows to the constructor. This could be the problem.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-01T23:40:34.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19157" PostTypeId="2" ParentId="18677" CreationDate="2016-01-02T00:09:24.783" Score="1" Body="&lt;p&gt;As established in the comments, the issues here are powering the module directly from a GPIO pin, which are limited to 20 mA, and potentially the limited current of a 9V battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I avoid using 9V batteries in projects, as they are comparatively expensive for the lifetime they provide. There are various boost/step-up converters that make a steady 5V supply from two AA batteries.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2016-01-02T00:09:24.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19158" PostTypeId="2" ParentId="16156" CreationDate="2016-01-02T01:01:08.520" Score="1" Body="&lt;p&gt;I am owner of this blog whose link you shared, so first of all, I am felling happy that you got something out of it. Now secondly, this code you got from my post is incomplete. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to buy that one in order to get the complete code. The code I designed is using AT commands but the above code which you have mixed with your own code is using the Arduino library that's why it's not giving the correct results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, either use the complete code from my website or use the Arduino library code only because it has the commands for checking the response, you don't need to use my code to get the response.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastEditorUserId="6936" LastEditDate="2016-01-03T18:34:19.533" LastActivityDate="2016-01-03T18:34:19.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19159" PostTypeId="2" ParentId="19144" CreationDate="2016-01-02T01:05:55.410" Score="-1" Body="&lt;p&gt;I think you should first check it in simulation and for that install Proteus software and get this &lt;a href=&quot;http://www.theengineeringprojects.com/2015/02/ultrasonic-sensor-library-proteus.html&quot; rel=&quot;nofollow&quot;&gt;Ultrasonic Sensor Library for Proteus&lt;/a&gt; and then test your code in simulation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you confirmed that your code is working fine then you can come to the hardware debugging but I think its more probably because of programming issues.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-01-02T01:05:55.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19161" PostTypeId="2" ParentId="19144" CreationDate="2016-01-02T01:43:47.983" Score="0" Body="&lt;p&gt;Maybe you should use the New Ping library and check if the sensor works without LCD:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15334" LastActivityDate="2016-01-02T01:43:47.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19162" PostTypeId="1" AcceptedAnswerId="19165" CreationDate="2016-01-02T01:46:25.080" Score="1" ViewCount="2269" Body="&lt;p&gt;I am very new to coding and I am attempting to teach myself the best I can.  I have no prior knowledge of coding and am filling in the blanks via YouTube and forums alike.  One place I keep getting hung up on is what seems to be an unsigned integer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to figure out how these work (assignment and such) to no avail. I was wondering if anyone could offer some insight for me or at the least a link that gets specific for the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see them used as uint8_t, uint16_t, and uint_32 in various places.  Am I correct that it is an unsigned integer?  Meaning it is a whole positive number only.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I have attached is from Adafruit's article on multi-tasking.  I am trying to adapt my sketch for millis() over delay().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      uint32_t Color1, Color2;  // What colors are in use&#xA;      uint16_t TotalSteps;  // total number of steps in the pattern&#xA;      uint16_t Index;  // current step within the pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For instance: on the variable declarations they use these for the color.  I will need to change the colors, but have only seen them expressed in RGB.  They are in every sketch I see, but I am struggling to answer this question on my own.  Thanks in advance for any help.&lt;/p&gt;&#xA;" OwnerUserId="16021" LastActivityDate="2016-01-02T02:55:17.100" Title="uint8_t etc as color variable" Tags="|programming|arduino-ide|sketch|adafruit|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19163" PostTypeId="2" ParentId="19162" CreationDate="2016-01-02T02:39:38.970" Score="0" Body="&lt;p&gt;Everything about standard integer types is in &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;lt;stdint.h&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-02T02:39:38.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19164" PostTypeId="1" CreationDate="2016-01-02T02:40:27.480" Score="0" ViewCount="1447" Body="&lt;p&gt;I was trying to drive a Nema 17 stepper motor using an arduino uno and an A4988 driver. I had it wired up according to this instructable (&lt;a href=&quot;http://www.instructables.com/id/Drive-a-Stepper-Motor-with-an-Arduino-and-a-A4988-/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Drive-a-Stepper-Motor-with-an-Arduino-and-a-A4988-/&lt;/a&gt;) at step 2 without the motor power supply wired to the bread board yet. ALSO, I hadn't wired the sleep to reset yet (I just didn't read directions carefully). The board was connected to my computer via USB and I had uploaded the sketch on the instructable to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, because I misunderstood the directions, I plugged my 12V 8A power supply into the power input on the arduino. All of the sudden, my computer turned off. My computer is fine after restarting, but now the arduino isn't recognized at all by the computer when I plug it in. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given this information, I am pretty sure that my arduino is fried. However, I can't understand why plugging in the power supply to the power input, which has a voltage regulator, would cause the board to fry.&lt;/p&gt;&#xA;" OwnerUserId="16022" OwnerDisplayName="Jere82" LastEditorUserId="16022" LastEditDate="2016-01-02T02:51:46.233" LastActivityDate="2016-07-31T12:42:49.277" Title="I'm pretty sure I fried my Arduino Uno. Given my setup, what caused it to be fried? (I can't identify the short)" Tags="|arduino-uno|motor|stepper|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="19165" PostTypeId="2" ParentId="19162" CreationDate="2016-01-02T02:55:17.100" Score="2" Body="&lt;p&gt;If you search for information about C types on the internet, there will be much help to find, but effectively you are correct. One format of integer types in C take the form:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;uint&lt;/code&gt; / &lt;code&gt;int&lt;/code&gt;: Signed or unsigned integer. Unsigned integers are stored in simple binary representation, and signed integers are stored in &lt;a href=&quot;https://en.wikipedia.org/wiki/Two%27s_complement&quot; rel=&quot;nofollow noreferrer&quot;&gt;two's complement&lt;/a&gt; form.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;8&lt;/code&gt; / &lt;code&gt;16&lt;/code&gt; / &lt;code&gt;32&lt;/code&gt; / &lt;code&gt;64&lt;/code&gt;: The number of bits to store the value. This means the number of possible values is 2&lt;sup&gt;&lt;em&gt;x&lt;/em&gt;&lt;/sup&gt; where &lt;em&gt;x&lt;/em&gt; is the number of bits.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;_t&lt;/code&gt;: Simply a suffix to indicate that it is a type name, not a variable.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Colour storage&lt;/h2&gt;&#xA;&lt;p&gt;Colours are generally stored as three components: &lt;em&gt;red&lt;/em&gt;, &lt;em&gt;green&lt;/em&gt; and &lt;em&gt;blue&lt;/em&gt; (or sometimes four, adding &lt;em&gt;alpha&lt;/em&gt;, the degree of transparency).&lt;/p&gt;&#xA;&lt;p&gt;If each component is given an unsigned byte to be stored (so it has a value from 0–255), then the total colour size is 24 bits. However, 24 bit integers are not a standard size, so the next bigger size is selected, 32-bit. This also allows room for an alpha component if necessary, but otherwise the spare 8 bits are unused.&lt;/p&gt;&#xA;&lt;h3&gt;For example:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;| 00000000 | 00000000 | 00000000 | 00000000  | = 32 bits&#xA;| red      | green    | blue     |alpha/empty|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7102" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-02T02:55:17.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19166" PostTypeId="2" ParentId="19155" CreationDate="2016-01-02T03:11:11.210" Score="2" Body="&lt;p&gt;As mentioned, the problem is the gamepad you have uses communicates over USB, which requires a USB Host chip to communicate with. However, USB Host shields can be found on eBay (under &quot;arduino USB Host shield&quot;) from US$10, and they come with a USB socket, so you could use it easily with another gamepad that hadn't had the connector snipped. This also would allow use with HID devices such as mice and keyboards if you wished, so a worthwhile shield to own.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2016-01-02T03:11:11.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19167" PostTypeId="1" CreationDate="2016-01-02T03:14:36.867" Score="0" ViewCount="1947" Body="&lt;p&gt;I am using a VEX 2-wire motor with the Motor Controller 29 to use it like a three-wire motor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was told that I am able to program it like a servo using the Arduino &lt;code&gt;Servo&lt;/code&gt; class. When I use the &lt;code&gt;write()&lt;/code&gt; function to set the power, it works from values around 50-85 in one direction, slowing down the power as I increase the value, but when the value exceeds around 90 then the motor stops working and makes strange clicking sounds. It is not a hardware problem, because the motor works fine in either direction when I plug it straight into a power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what my problem is?&lt;/p&gt;&#xA;" OwnerUserId="16025" LastEditorUserId="16025" LastEditDate="2016-01-02T17:48:31.880" LastActivityDate="2017-04-12T06:43:36.987" Title="Problems using an arduino with vex motors and motor controller 29" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19168" PostTypeId="1" AcceptedAnswerId="19182" CreationDate="2016-01-02T03:27:11.913" Score="2" ViewCount="533" Body="&lt;p&gt;I'm coding a data logger and I would like to know what happens if there are no bytes remaining to be written using SD library, ie, if the SD card is full of data. The logging would just stop or I would get some nasty error?&lt;/p&gt;&#xA;" OwnerUserId="15675" LastActivityDate="2016-01-02T12:39:17.370" Title="What happens when there's no space left on SD card?" Tags="|sd-card|datalogging|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19169" PostTypeId="2" ParentId="19168" CreationDate="2016-01-02T03:36:44.493" Score="1" Body="&lt;p&gt;There doesn't seem to be any definite answer in the library documentation, but I am fairly certain that writes will simply fail, and not cause any sort of corruption. The last log entry may be incomplete, but the file should still be readable.&lt;/p&gt;&#xA;" OwnerUserId="7102" LastActivityDate="2016-01-02T03:36:44.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19173" PostTypeId="1" CreationDate="2016-01-02T06:19:37.420" Score="0" ViewCount="572" Body="&lt;p&gt;I want to add 6 LEDs  under my Arduino case and have the Arduino Uno pulsate the colors. How do I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RWkwn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RWkwn.jpg&quot; alt=&quot;http://i.imgur.com/klYLoVv.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16029" LastEditorUserId="10907" LastEditDate="2016-01-02T19:35:38.770" LastActivityDate="2016-01-02T19:35:38.770" Title="How to hook up an LED strip to an Arduino" Tags="|arduino-uno|rgb-led|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19174" PostTypeId="2" ParentId="19173" CreationDate="2016-01-02T06:59:26.793" Score="1" Body="&lt;p&gt;Depends on what they are and how much you don't know :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest starting off by looking at the tutorials for &lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/overview&quot; rel=&quot;nofollow&quot;&gt;NeoPixels&lt;/a&gt; and &lt;a href=&quot;https://learn.adafruit.com/adafruit-dotstar-leds/overview&quot; rel=&quot;nofollow&quot;&gt;DotStars&lt;/a&gt; on Adafruit's site – that should give you a general idea of how things work. Then take a look at the &lt;a href=&quot;http://fastled.io&quot; rel=&quot;nofollow&quot;&gt;FastLED&lt;/a&gt; library, it supports a large number of LED strips and has some decent examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FastLED examples that will show up in the Arduino IDE after you have installed the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you've gotten as far as identifying the strip you have and reading some of the basic tutorials and trying out some of the examples you'll either know how to do it or have some much more specific questions to ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, after looking at the &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00MA397GI&quot; rel=&quot;nofollow&quot;&gt;info on Amazon&lt;/a&gt; and looking more closely at the strip (and the price). I don't think these are individually addressable LEDs. More likely the RGB lines are grounds. So what you would do is to provide a +12V supply on the 12V line and ground one or more the RGB lines to turn on that LED. You could probably control brightness with PWM (pulse width modulation, turning them on and off quickly). The catch here is that the current draw will be more than the Arduino can sink and it's at 12V – two quick ways to kill your board in one tidy package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to do more research on this to get the details right, but I think you could use a transistor to do the switching (to protect your Arduino for the 12 V and from the current necessary to drive the LEDs). You would connect an Arduino pin to the base of the transistor to control it. You'd need to select a transistor that can handle the current of all of the LEDs of that color. As a guess I'd figure 60 mA per LED at full brightness (for each color) – this is based on NeoPixels running at 5 V so I could be way off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I'm right that these are not individually addressable then the programming would be relatively easy – just turn on the output to turn on the color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd start off by cutting off a strip of the LEDs to experiment with. Use the 12V supply that came with them and see what happens when you connect 12 V to the 12V line and ground one of the color lines. It doesn't look like there is a resistor to limit current, so you should add one to hold the current down. I &lt;em&gt;think&lt;/em&gt; the LEDs would be wired in parallel, so you'd be looking at needing to supply 6 times the individual LED current. To be safe you could start at around 20 mA and use a 100Ω 1W resistor – you can find an LED resistor calculator &lt;a href=&quot;http://ledcalc.com&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, be sure to select the parallel calculation and use a low current to start with to be safe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you know that the strip works the way you think it does, try adding a transistor to control each color. Then when you've got that working, hook up to the Arduino. Just remember that you will also need to respect the Arduino's current and voltage limits on the digital pins.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-02T08:18:23.213" LastActivityDate="2016-01-02T08:18:23.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19175" PostTypeId="2" ParentId="13676" CreationDate="2016-01-02T07:12:00.053" Score="1" Body="&lt;p&gt;You may want to take a look at LMX by David Anderson &lt;a href=&quot;http://www.geology.smu.edu/dpa-www/robo/LMX&quot; rel=&quot;nofollow&quot;&gt;A Light-Weight Multi-Tasking Executive&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He has a very good set of videos on the code that he did for &lt;a href=&quot;https://www.youtube.com/channel/UCsGzeeBTraAts7lMQdfhqtA&quot; rel=&quot;nofollow&quot;&gt;Dallas Personal Robotics Group (DPRG)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific videos for LMX are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=nRaosdrDrdA&quot; rel=&quot;nofollow&quot;&gt;David Anderson on Robotics Software - part 1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Jnrg4WAtxGQ&quot; rel=&quot;nofollow&quot;&gt;David Anderson on Robotics Software - part 2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16005" LastActivityDate="2016-01-02T07:12:00.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19176" PostTypeId="1" AcceptedAnswerId="19200" CreationDate="2016-01-02T07:12:59.610" Score="1" ViewCount="620" Body="&lt;p&gt;Can an Arduino Uno calculate the time that an assembly instruction will take in nanoseconds, not microseconds? I don't want to use a PC, because the calculation will be more accurate using an Arduino, as the processor won't be running other tasks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Arduino can't, is there any way to improve it, or any other open source hardware that can do?&lt;/p&gt;&#xA;" OwnerUserId="16030" LastEditorUserId="6936" LastEditDate="2016-01-02T09:59:36.660" LastActivityDate="2016-01-02T20:49:32.233" Title="How fast is an Arduino?" Tags="|arduino-uno|assembly|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19177" PostTypeId="2" ParentId="19176" CreationDate="2016-01-02T07:21:59.493" Score="2" Body="&lt;p&gt;If you're asking &quot;can an AVR measure how long it works on a task&quot; then the answer is yes, but I don't think that's what you're looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're asking &quot;can I craft a program that takes a specific amount of time to run&quot; then the answer is also yes. The trick is to look in the datasheet or in the AVR Assembly Instruction manual to see how long each instruction takes in cycles and then multiply that by the MCU's clock period.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-02T07:21:59.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19178" PostTypeId="1" CreationDate="2016-01-02T07:34:11.530" Score="0" ViewCount="719" Body="&lt;p&gt;I want to generate two PWM signals V&lt;sub&gt;C&lt;/sub&gt; and V&lt;sub&gt;H&lt;/sub&gt; to give input to the gas sensor  with the duty cycle mentioned below. I also want to take the reading from the same sensor at the same time using Arduino Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;img src=&quot;https://i.stack.imgur.com/bY2dK.png&quot; alt=&quot;Waveform1]&quot;&gt;&lt;a href=&quot;https://i.stack.imgur.com/8UGU5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8UGU5.png&quot; alt=&quot;Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am confused how to proceed with the code in Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="16031" LastEditorUserId="6936" LastEditDate="2016-01-02T19:39:29.257" LastActivityDate="2016-01-05T15:24:57.610" Title="Generate 2 PWM signals Vc and Vh from Arduino Uno" Tags="|arduino-uno|programming|pwm|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19179" PostTypeId="1" CreationDate="2016-01-02T08:31:11.050" Score="4" ViewCount="17238" Body="&lt;p&gt;I'm wondering if there are free programs or web sites that let you draw simple schematics similar to this example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wxqhn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wxqhn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-12-12T07:49:30.267" Title="Suggestions for a program for drawing simple schematics" Tags="|documentation|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19180" PostTypeId="1" AcceptedAnswerId="22284" CreationDate="2016-01-02T11:23:25.487" Score="0" ViewCount="4169" Body="&lt;p&gt;I have Chinese copy of arduino which uses ATmega16u2 (at least that's what is written on the chip itself). When connected, it is visible in system information under USB section:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Communication Device:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Product ID:   0x0043&lt;br&gt;&#xA;  Vendor ID:    0x2341&lt;br&gt;&#xA;  Version:  0.01&lt;br&gt;&#xA;  Serial Number:    75237333636351600270&lt;br&gt;&#xA;  Speed:    Up to 12 Mb/sec&lt;br&gt;&#xA;  Manufacturer: Arduino (www.arduino.cc)&lt;br&gt;&#xA;  Location ID:  0x1a140000 / 6&lt;br&gt;&#xA;  Current Available (mA):   1000&lt;br&gt;&#xA;  Current Required (mA):    100&lt;br&gt;&#xA;  Extra Operating Current (mA): 0&lt;br&gt;&#xA;  Built-In: Yes&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But it doesn't show up in arduino program ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched a lot, and it seems that people mostly had problems with arduinos on CH340 chips. I also have one such arduino, but it works properly after installing signed drivers as &lt;a href=&quot;http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;described here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any solutions for atmega 16u2 chips?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OS X El Capitan 10.11.2 (15C50) (hackintosh if it changes anything).&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno R3 (chinese copy)&lt;/li&gt;&#xA;&lt;li&gt;Arduino soft version 1.6.7&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Additional info:&#xA;I've tried connecting Arduino Mega 2560 with Atmega16u2 chip and it also doesn't work &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Info I've got using Nick's awesome program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jan  8 2016 at 21:35:08 with Arduino IDE 10607.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x94 0x89 &#xA;Processor = ATmega16U2&#xA;Flash memory size = 16384 bytes.&#xA;LFuse = 0xFF &#xA;HFuse = 0xD9 &#xA;EFuse = 0xF4 &#xA;Lock byte = 0xFF &#xA;Clock calibration = 0x56 &#xA;Bootloader in use: No&#xA;EEPROM preserved through erase: No&#xA;Watchdog timer always on: No&#xA;Bootloader is 4096 bytes starting at 3000&#xA;&#xA;Bootloader:&#xA;&#xA;3000: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF &#xA;3010: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF &#xA;3020: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF &#xA;...&#xA;&#xA;MD5 sum of bootloader = 0x6A 0xE5 0x9E 0x64 0x85 0x03 0x77 0xEE 0x54 0x70 0xC8 0x54 0x76 0x15 0x51 0xEA &#xA;No bootloader (all 0xFF)&#xA;&#xA;First 256 bytes of program memory:&#xA;&#xA;0: 0x90 0xC0 0x00 0x00 0xA9 0xC0 0x00 0x00 0xA7 0xC0 0x00 0x00 0xA5 0xC0 0x00 0x00 &#xA;10: 0xA3 0xC0 0x00 0x00 0xA1 0xC0 0x00 0x00 0x9F 0xC0 0x00 0x00 0x9D 0xC0 0x00 0x00 &#xA;20: 0x9B 0xC0 0x00 0x00 0x99 0xC0 0x00 0x00 0x97 0xC0 0x00 0x00 0x48 0xC4 0x00 0x00 &#xA;30: 0x0C 0xC4 0x00 0x00 0x91 0xC0 0x00 0x00 0x8F 0xC0 0x00 0x00 0x8D 0xC0 0x00 0x00 &#xA;40: 0x8B 0xC0 0x00 0x00 0x89 0xC0 0x00 0x00 0x87 0xC0 0x00 0x00 0x85 0xC0 0x00 0x00 &#xA;50: 0x83 0xC0 0x00 0x00 0x81 0xC0 0x00 0x00 0x7F 0xC0 0x00 0x00 0x02 0xC1 0x00 0x00 &#xA;60: 0x7B 0xC0 0x00 0x00 0x79 0xC0 0x00 0x00 0x77 0xC0 0x00 0x00 0x75 0xC0 0x00 0x00 &#xA;70: 0x73 0xC0 0x00 0x00 0x71 0xC0 0x00 0x00 0x6F 0xC0 0x00 0x00 0x6D 0xC0 0x00 0x00 &#xA;80: 0x6B 0xC0 0x00 0x00 0x69 0xC0 0x00 0x00 0x67 0xC0 0x00 0x00 0x65 0xC0 0x00 0x00 &#xA;90: 0x63 0xC0 0x00 0x00 0x61 0xC0 0x00 0x00 0x12 0x01 0x10 0x01 0x02 0x00 0x00 0x08 &#xA;A0: 0x41 0x23 0x43 0x00 0x01 0x00 0x01 0x02 0xDC 0x01 0x09 0x02 0x3E 0x00 0x02 0x01 &#xA;B0: 0x00 0xC0 0x32 0x09 0x04 0x00 0x00 0x01 0x02 0x02 0x01 0x00 0x05 0x24 0x00 0x01 &#xA;C0: 0x10 0x04 0x24 0x02 0x06 0x05 0x24 0x06 0x00 0x01 0x07 0x05 0x82 0x03 0x08 0x00 &#xA;D0: 0xFF 0x09 0x04 0x01 0x00 0x02 0x0A 0x00 0x00 0x00 0x07 0x05 0x04 0x02 0x40 0x00 &#xA;E0: 0x01 0x07 0x05 0x83 0x02 0x40 0x00 0x01 0x04 0x03 0x09 0x04 0x32 0x03 0x41 0x00 &#xA;F0: 0x72 0x00 0x64 0x00 0x75 0x00 0x69 0x00 0x6E 0x00 0x6F 0x00 0x20 0x00 0x28 0x00 &#xA;&#xA;Programming mode off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fuses info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega fuse calculator.&#xA;Written by Nick Gammon.&#xA;Version 1.10&#xA;Compiled on Jan  8 2016 at 22:19:34 with Arduino IDE 10607.&#xA;Attempting to enter programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x94 0x89 &#xA;Processor = ATmega16U2&#xA;Flash memory size = 16384&#xA;LFuse = 0xFF &#xA;HFuse = 0xD9 &#xA;EFuse = 0xF4 &#xA;Lock byte = 0xFF &#xA;Clock calibration = 0x56 &#xA;Hardare Boot Enable..................... [X]&#xA;Debug Wire Enable....................... [ ]&#xA;External Reset Disable.................. [ ]&#xA;Enable Serial (ICSP) Programming........ [X]&#xA;Watchdog Timer Always On................ [ ]&#xA;Preserve EEPROM through chip erase...... [ ]&#xA;Boot into bootloader.................... [ ]&#xA;Divide clock by 8....................... [ ]&#xA;Clock output............................ [ ]&#xA;Bootloader size: 4096 bytes.&#xA;Start-up time: SUT0: [ ]  SUT1: [ ] (see datasheet)&#xA;Clock source: low-power crystal.&#xA;Brownout detection at: 3.0V.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16016" LastEditorUserId="16016" LastEditDate="2016-01-08T20:21:33.910" LastActivityDate="2022-09-19T23:33:58.503" Title="Arduino Uno R3 (with Atmega 16u2) and MAC OSX 10.11 (El capitan) not working" Tags="|arduino-uno|arduino-mega|usb|mac-os|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19182" PostTypeId="2" ParentId="19168" CreationDate="2016-01-02T12:39:17.370" Score="3" Body="&lt;p&gt;Open-source is just great. Lets have a look at the source code for SD. &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/libraries/SD/src/utility/SdFile.cpp#L1164&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is what happens on write of a block. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * Write data to an open file.&#xA; *&#xA; * \note Data is moved to the cache but may not be written to the&#xA; * storage device until sync() is called.&#xA; *&#xA; * \param[in] buf Pointer to the location of the data to be written.&#xA; *&#xA; * \param[in] nbyte Number of bytes to write.&#xA; *&#xA; * \return For success write() returns the number of bytes written, always&#xA; * \a nbyte.  If an error occurs, write() returns -1.  Possible errors&#xA; * include write() is called before a file has been opened, write is called&#xA; * for a read-only file, device is full, a corrupt file system or an I/O error.&#xA; *&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The source code shows that blocks are allocated from the free list and if there are no more blocks the function will return an error. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-02T12:39:17.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19183" PostTypeId="2" ParentId="19176" CreationDate="2016-01-02T13:03:22.980" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How fast is an Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno is based on AVR MCU and run at 16 MHz. Due to the processor architecture it can execute almost 1 instruction per clock cycles (62.5 ns). It uses a simple two step pipeline which may require restart if a branch is taken. There are some instructions such as memory access that take more than one clock cycle. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can an Arduino Uno calculate the time that an assembly instruction will take in nanoseconds, not microseconds? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is possible to measure the execution time with a resolution of 4 us with micros(). Please describe what you want to calculate/measure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details on ATmega328p please see the &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;data-sheet, chap. 6.6 Instruction Execution Timing&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-02T13:03:22.980" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19184" PostTypeId="2" ParentId="17089" CreationDate="2016-01-02T13:17:43.183" Score="2" Body="&lt;p&gt;Only low level detect is possible with external interrupt pins (INT0/D2 and INT1/D3) in &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow&quot;&gt;power down sleep mode&lt;/a&gt;. The signal must be low for a number of clock cycles to be detected and the interrupt will detected while the signal is low (and the interrupt is enabled). It is not a transition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A pin change interrupt could be used instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details please see chap. 9.5 Power-down Mode and chap. 12. External Interrupts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-02T13:17:43.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19186" PostTypeId="2" ParentId="19179" CreationDate="2016-01-02T15:22:14.190" Score="5" Body="&lt;p&gt;A compilation of possibilities mentioned the comments. I'll add to this as I try out the suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From @Gerben, &quot;kind of in order of complexity&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.circuitlab.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;circuitlab.com&lt;/a&gt; - online schematic capture and simulator (analog, digital, and mixed signal). Licensed for professional, student/educator, and hobbyist (free) usage. Officially runs in Chrome and Firefox, and they report users having success with Safari and Opera which are not officially supported.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://fritzing.org/home&quot; rel=&quot;nofollow noreferrer&quot;&gt;Fritzing&lt;/a&gt; - cross-platform (Mac, Windows, Linux). Has Breadboard View mode with built in Arduino support that allows you to create diagrams like this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UvWA9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UvWA9.jpg&quot; alt=&quot;LCD Rise and Shine Clock from http://barkengmad.com/2013/10/led-clock-circuit-design-on-fritzing/&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there you can click on the Schematic view to route wires and convert the breadboard into a traditional schematic.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.circuitmaker.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;CircuitMaker&lt;/a&gt; - Windows only, requires creating an account.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.cadsoftusa.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eagle&lt;/a&gt; - cross-platform (Mac, Windows, Linux), paid and free versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Component library collections (thanks to Marko Mackic for the idea):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit-Eagle-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.element14.com/community/docs/DOC-64069/l/the-element14-arduino-cadsoft-library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Element14 Arduino library&lt;/a&gt; - requires registration, lots of other libraries as well&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sparkfun/SparkFun-Eagle-Libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://kicad-pcb.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;KiCad&lt;/a&gt; - cross-platform (Mac, Linux (with packages for several distributions), Windows, and source code), &lt;a href=&quot;http://kicad-pcb.org/download/source&quot; rel=&quot;nofollow noreferrer&quot;&gt;open source&lt;/a&gt; and also on &lt;a href=&quot;https://github.com/KiCad/kicad-source-mirror&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Found &lt;a href=&quot;https://123d.circuits.io&quot; rel=&quot;nofollow noreferrer&quot;&gt;Autodesk's 123D Circuits&lt;/a&gt; in a question on &lt;a href=&quot;https://arduino.stackexchange.com/questions/61/can-i-program-for-arduino-without-having-a-real-board&quot;&gt;Arduino Simulators (and emulators)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-13T05:53:30.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19187" PostTypeId="1" AcceptedAnswerId="19195" CreationDate="2016-01-02T15:43:33.170" Score="0" ViewCount="306" Body="&lt;p&gt;I'm using the non-blocking RS485 Gammon's library for Arduino (as shown at &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11428&lt;/a&gt;) to handle the communication between some arduinos.&#xA;Now I'm having trouble to add a Raspberry Pi (or otherwise a non-arduino platform) to the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I integrate the Gammon's protocol in a python or processing software?&lt;/p&gt;&#xA;" OwnerUserId="16036" LastEditorUserId="16036" LastEditDate="2016-01-02T17:04:59.870" LastActivityDate="2016-01-02T19:33:34.293" Title="Interfacing Gammon's RS485 with computer" Tags="|rs485|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19188" PostTypeId="1" AcceptedAnswerId="19191" CreationDate="2016-01-02T16:03:24.260" Score="0" ViewCount="209" Body="&lt;p&gt;Today, I've started a decision maker, using a Arduino UNO R3, a button and a RGB led.&#xA;This project makes a decision for you (yes, no, or maybe) when you don't know your own decision about something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I used in the project is the following one (written by me): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define out OUTPUT&#xA;#define in INPUT&#xA;#define H HIGH&#xA;#define L LOW&#xA;&#xA;&#xA;int red = 2;&#xA;int green = 3;&#xA;int blue = 4;&#xA;&#xA;int randomValue = 0;&#xA;&#xA;int button = 5;&#xA;int buttonState = 0;&#xA;&#xA;void setup(){&#xA;    pinMode(red, out);&#xA;    pinMode(green, out);&#xA;    pinMode(blue, out);&#xA;&#xA;    pinMode(button, in);   &#xA;}&#xA;&#xA;void loop(){&#xA;    buttonState = digitalRead(button);&#xA;    if(buttonState == H){&#xA;        randomValue = random(0,4);&#xA;        if(randomValue == 1){&#xA;            digitalWrite(red, H);&#xA;            delay(200);&#xA;            digitalWrite(red, L);&#xA;            clear();&#xA;        }&#xA;        if(randomValue == 2){&#xA;            digitalWrite(green, H);&#xA;            delay(200);&#xA;            digitalWrite(green, L);&#xA;            clear();&#xA;        }&#xA;        if(randomValue == 3) {&#xA;            digitalWrite(blue, H);&#xA;            delay(200);&#xA;            digitalWrite(blue, L);&#xA;            clear();&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The connections are correct, and the code also. The problem is: when I push the button, the LED starts showing random colors, and what I want is for the LED to show one color per push.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do?&lt;/p&gt;&#xA;" OwnerUserId="15855" LastEditorUserId="10907" LastEditDate="2016-01-04T10:55:05.013" LastActivityDate="2016-01-04T10:55:05.013" Title="Decision maker loop problem" Tags="|arduino-uno|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19190" PostTypeId="2" ParentId="18999" CreationDate="2016-01-02T16:15:56.947" Score="1" Body="&lt;p&gt;If you're using the mini-breakout board (&lt;a href=&quot;https://www.sparkfun.com/products/13025&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/13025&lt;/a&gt;), then you can get the I2C connections from the board (connections available through holes under the Edison; you can see them from the backside; see: &lt;a href=&quot;https://cdn.sparkfun.com//assets/parts/1/0/0/1/1/13025-02.jpg&quot; rel=&quot;nofollow&quot;&gt;https://cdn.sparkfun.com//assets/parts/1/0/0/1/1/13025-02.jpg&lt;/a&gt;). You can solder headers on or can solder wires directly to the required pins. You can find the pin mapping here: &lt;a href=&quot;http://iotdk.intel.com/docs/master/mraa/edison.html&quot; rel=&quot;nofollow&quot;&gt;http://iotdk.intel.com/docs/master/mraa/edison.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16008" LastActivityDate="2016-01-02T16:15:56.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19191" PostTypeId="2" ParentId="19188" CreationDate="2016-01-02T17:02:20.027" Score="1" Body="&lt;p&gt;There is one basic concept that you are lacking.  At the moment you are looking to see &lt;em&gt;if&lt;/em&gt; the button is pressed, not &lt;em&gt;when&lt;/em&gt; the button has been pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of just looking to see if it is HIGH you need to look if it &lt;em&gt;was&lt;/em&gt; LOW but is &lt;em&gt;now&lt;/em&gt; HIGH. It's that transition from LOW to HIGH that you need to use as your trigger for when to set the LED colour, and that means remembering the state of the button the last time you went through the loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonState = digitalRead(button);&#xA;if (buttonState != oldButtonState) {&#xA;    oldButtonState = buttonState;&#xA;    if(buttonState == H) {&#xA;        // Do your stuff&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;oldButtonState&lt;/code&gt; is defined the same as &lt;code&gt;buttonState&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-02T17:02:20.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19193" PostTypeId="2" ParentId="18999" CreationDate="2016-01-02T17:12:24.083" Score="0" Body="&lt;p&gt;Use the &lt;a href=&quot;https://www.sparkfun.com/products/13034&quot; rel=&quot;nofollow&quot;&gt;I2C breakout board&lt;/a&gt;. This will also handle voltage shift from 1.8 V to the sensor voltage level.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-02T17:12:24.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19195" PostTypeId="2" ParentId="19187" CreationDate="2016-01-02T19:33:34.293" Score="0" Body="&lt;p&gt;Open-source and Web-search is just great. &lt;a href=&quot;https://github.com/Sthing/Nick-Gammon-RS485&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; might be what you are looking for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-02T19:33:34.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19196" PostTypeId="2" ParentId="17052" CreationDate="2016-01-02T20:14:39.160" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.agcross.com/2015/09/the-esp8266-wifi-chip-part-1-up-and-running/&quot; rel=&quot;nofollow&quot;&gt;http://www.agcross.com/2015/09/the-esp8266-wifi-chip-part-1-up-and-running/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the tutorial it's an undocumented bug with no fix. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change the name, baud, and set up the wifi and password you should be good to go&lt;/p&gt;&#xA;" OwnerUserId="15133" LastActivityDate="2016-01-02T20:14:39.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19197" PostTypeId="1" CreationDate="2016-01-02T20:20:14.653" Score="0" ViewCount="493" Body="&lt;p&gt;I'm looking for a low cost motorized water valve.  I've done a number of searches and have found nothing compelling.  Has anyone here used a motorized water valve with Arduino?  What would you recommend?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fail-open solenoid might also work but I'd like to try my hand at a motorized valve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The valves I found start at US$50.  I'm looking for something cheaper.  The purpose is tinkering and I'd like to make an &quot;if water detected - then close valve&quot; sketch.  Ir's simple, just more expensive than I expected.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="13355" LastEditDate="2016-01-04T18:37:14.040" LastActivityDate="2016-01-08T16:38:10.773" Title="Low Cost Motorized Valve" Tags="|arduino-uno|programming|motor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19198" PostTypeId="2" ParentId="19180" CreationDate="2016-01-02T20:37:20.413" Score="3" Body="&lt;p&gt;You can use my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow noreferrer&quot;&gt;Chip detector sketch&lt;/a&gt; to confirm (using another Arduino to run the sketch) if the target chip is a Atmega16u2 or not, and if so, what fuses etc. are set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring would be like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mvkwF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mvkwF.jpg&quot; alt=&quot;Connecting to Atmega16u2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close-up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gVjGX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gVjGX.jpg&quot; alt=&quot;Wiring close-up&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ICSP header (from above):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/02lMq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/02lMq.png&quot; alt=&quot;ICSP header&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should see something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.&#xA;Written by Nick Gammon.&#xA;Version 1.17&#xA;Compiled on Jan  3 2016 at 07:34:08 with Arduino IDE 10605.&#xA;Attempting to enter ICSP programming mode ...&#xA;Entered programming mode OK.&#xA;Signature = 0x1E 0x94 0x89 &#xA;Processor = ATmega16U2&#xA;Flash memory size = 16384 bytes.&#xA;LFuse = 0xEF &#xA;HFuse = 0xD9 &#xA;EFuse = 0xF4 &#xA;Lock byte = 0xCF &#xA;Clock calibration = 0x96 &#xA;Bootloader in use: No&#xA;EEPROM preserved through erase: No&#xA;Watchdog timer always on: No&#xA;Bootloader is 4096 bytes starting at 3000&#xA;&#xA;Bootloader:&#xA;&#xA;3000: 0x4B 0xC0 0x00 0x00 0x64 0xC0 0x00 0x00 0x62 0xC0 0x00 0x00 0x60 0xC0 0x00 0x00 &#xA;3010: 0x5E 0xC0 0x00 0x00 0x5C 0xC0 0x00 0x00 0x5A 0xC0 0x00 0x00 0x58 0xC0 0x00 0x00 &#xA;3020: 0x56 0xC0 0x00 0x00 0x54 0xC0 0x00 0x00 0x52 0xC0 0x00 0x00 0xEE 0xC4 0x00 0x00 &#xA;&#xA;...&#xA;&#xA;MD5 sum of bootloader = 0xD8 0x8C 0x70 0x6D 0xFE 0x1F 0xDC 0x38 0x82 0x1E 0xCE 0xAE 0x23 0xB2 0xE6 0xE7 &#xA;Bootloader name: Arduino-dfu-usbserial-atmega16u2-Uno-Rev3&#xA;&#xA;First 256 bytes of program memory:&#xA;&#xA;0: 0x90 0xC0 0x00 0x00 0xA9 0xC0 0x00 0x00 0xA7 0xC0 0x00 0x00 0xA5 0xC0 0x00 0x00 &#xA;10: 0xA3 0xC0 0x00 0x00 0xA1 0xC0 0x00 0x00 0x9F 0xC0 0x00 0x00 0x9D 0xC0 0x00 0x00 &#xA;20: 0x9B 0xC0 0x00 0x00 0x99 0xC0 0x00 0x00 0x97 0xC0 0x00 0x00 0x48 0xC4 0x00 0x00 &#xA;30: 0x0C 0xC4 0x00 0x00 0x91 0xC0 0x00 0x00 0x8F 0xC0 0x00 0x00 0x8D 0xC0 0x00 0x00 &#xA;40: 0x8B 0xC0 0x00 0x00 0x89 0xC0 0x00 0x00 0x87 0xC0 0x00 0x00 0x85 0xC0 0x00 0x00 &#xA;50: 0x83 0xC0 0x00 0x00 0x81 0xC0 0x00 0x00 0x7F 0xC0 0x00 0x00 0x02 0xC1 0x00 0x00 &#xA;60: 0x7B 0xC0 0x00 0x00 0x79 0xC0 0x00 0x00 0x77 0xC0 0x00 0x00 0x75 0xC0 0x00 0x00 &#xA;70: 0x73 0xC0 0x00 0x00 0x71 0xC0 0x00 0x00 0x6F 0xC0 0x00 0x00 0x6D 0xC0 0x00 0x00 &#xA;80: 0x6B 0xC0 0x00 0x00 0x69 0xC0 0x00 0x00 0x67 0xC0 0x00 0x00 0x65 0xC0 0x00 0x00 &#xA;90: 0x63 0xC0 0x00 0x00 0x61 0xC0 0x00 0x00 0x12 0x01 0x10 0x01 0x02 0x00 0x00 0x08 &#xA;A0: 0x41 0x23 0x43 0x00 0x01 0x00 0x01 0x02 0xDC 0x01 0x09 0x02 0x3E 0x00 0x02 0x01 &#xA;B0: 0x00 0xC0 0x32 0x09 0x04 0x00 0x00 0x01 0x02 0x02 0x01 0x00 0x05 0x24 0x00 0x01 &#xA;C0: 0x10 0x04 0x24 0x02 0x06 0x05 0x24 0x06 0x00 0x01 0x07 0x05 0x82 0x03 0x08 0x00 &#xA;D0: 0xFF 0x09 0x04 0x01 0x00 0x02 0x0A 0x00 0x00 0x00 0x07 0x05 0x04 0x02 0x40 0x00 &#xA;E0: 0x01 0x07 0x05 0x83 0x02 0x40 0x00 0x01 0x04 0x03 0x09 0x04 0x32 0x03 0x41 0x00 &#xA;F0: 0x72 0x00 0x64 0x00 0x75 0x00 0x69 0x00 0x6E 0x00 0x6F 0x00 0x20 0x00 0x28 0x00 &#xA;&#xA;Programming mode off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On my genuine Uno I get these settings from OS/X:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Product ID:   0x0043&#xA;  Vendor ID:    0x2341&#xA;  Version:   0.01&#xA;  Serial Number:    74134373733351300000&#xA;  Speed:    Up to 12 Mb/sec&#xA;  Manufacturer: Arduino (www.arduino.cc)&#xA;  Location ID:  0xfd130000 / 8&#xA;  Current Available (mA):   500&#xA;  Current Required (mA):    100&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't had any problems using the Uno with OS/X however I don't remember whether or not I had to install a device driver for it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Info I've got using Nick's awesome program:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;Signature = 0x1E 0x94 0x89 &#xA;Processor = ATmega16U2&#xA;Flash memory size = 16384 bytes.&#xA;LFuse = 0xFF &#xA;HFuse = 0xD9 &#xA;EFuse = 0xF4 &#xA;...&#xA;Bootloader:&#xA;&#xA;3000: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF &#xA;....&#xA;&#xA;MD5 sum of bootloader = 0x6A 0xE5 0x9E 0x64 0x85 0x03 0x77 0xEE 0x54 0x70 0xC8 0x54 0x76 0x15 0x51 0xEA &#xA;No bootloader (all 0xFF)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is interesting that they are shipping without a bootloader on the ATmega16U2. Whilst that chip doesn't need one (and it is disabled by the fuses in mine) clearly there are &lt;em&gt;some&lt;/em&gt; differences. I checked the &quot;first 256 bytes&quot; of the code between your board and mine and they are the same, so possibly the main code is identical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would try to plug your Arduino into another Mac, if possible. It may be that your &quot;hackintosh&quot; has enough differences in its loaded software that it doesn't recognize that USB interface.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-08T20:29:37.013" LastActivityDate="2016-01-08T20:29:37.013" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19199" PostTypeId="2" ParentId="19179" CreationDate="2016-01-02T20:42:50.470" Score="2" Body="&lt;p&gt;I've been using ExpressSCH (Express Schematic) from: &lt;a href=&quot;http://www.expresspcb.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.expresspcb.com/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;That is a free install for Windows and is pretty easy to use.&lt;/p&gt;&#xA;&lt;p&gt;Example of its output:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mVkkP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mVkkP.png&quot; alt=&quot;ExpressSCH example&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It comes with quite a few symbols defined, and you can easily make your own extra ones (like the Uno I did in the schematic above).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-02T20:42:50.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19200" PostTypeId="2" ParentId="19176" CreationDate="2016-01-02T20:49:32.233" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I just want to know how much time (in nanosecond example: 14 microsecond and 145 nanosecond ) it'll take for a CMP instruction comparing 2 strings, because in theory it will take less time if the two strings doesn't match.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can set up a hardware timer (eg. Timer 1) with a prescaler of one, so that each &quot;tick&quot; counts one clock cycle. Thus it can time to a resolution of 62.5 ns if running at 16 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you could read the timer, do your target instruction (eg. compare two strings) and then read the timer again. The difference in counts will be the time (in units of 62.5 ns).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;page about timers&lt;/a&gt; which might help you get started.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... calculate the time that an assembly instruction will take ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Generally speaking the C++ compiler does a good job of generating code. You won't necessarily make things faster by writing in assembler and you might make it slower, because compiler-writers know various tricks which you might not.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-02T20:49:32.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19201" PostTypeId="2" ParentId="19164" CreationDate="2016-01-02T20:57:10.053" Score="1" Body="&lt;p&gt;The Uno is not one &quot;thing&quot; that fails. It has various components, some of which may have failed. I wrote a lengthy page about how to test various parts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I plugged my 12V 8A power supply into the power input on the arduino. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Perhaps you reversed the leads, and shorted the USB power to ground, thus causing the PC to turn off? This would probably also blow most of the components on the Uno because they would have had -12V applied to them, assuming it got past the voltage regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there &lt;strong&gt;is&lt;/strong&gt; a reverse polarity protection diode on the power input jack. Did you use that or the &lt;code&gt;Vin&lt;/code&gt; pin? (or the &lt;code&gt;Vcc&lt;/code&gt; pin?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the reverse polarity protection does not protect you if you use the &lt;code&gt;Vin&lt;/code&gt; pin.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-02T20:57:10.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19202" PostTypeId="2" ParentId="18959" CreationDate="2016-01-02T23:55:34.960" Score="1" Body="&lt;p&gt;If the path to your source file contains a space, it might be causing this error. For more information, and a workaround, see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=368654.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this topic&lt;/a&gt; in the Arduino forum.&lt;/p&gt;&#xA;" OwnerUserId="7631" LastEditorUserId="41407" LastEditDate="2018-08-19T18:28:25.313" LastActivityDate="2018-08-19T18:28:25.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19203" PostTypeId="2" ParentId="9095" CreationDate="2016-01-03T00:43:28.833" Score="1" Body="&lt;p&gt;If all the other solutions don't work and you are on a Linux distro try &lt;code&gt;sudo arduino&lt;/code&gt; and that should work, or follow these instructions: &lt;a href=&quot;https://web.archive.org/web/20170807180104/http://blog.opensensors.io/blog/2014/09/13/getting-started-with-arduino-on-linux/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Getting Started With Arduino on Linux (Ubuntu)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16044" LastEditorUserId="27346" LastEditDate="2019-05-12T21:09:52.013" LastActivityDate="2019-05-12T21:09:52.013" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19206" PostTypeId="1" CreationDate="2016-01-03T04:17:55.393" Score="-1" ViewCount="353" Body="&lt;p&gt;I am trying to figure out how i could make an android app like this one, &lt;a href=&quot;https://www.youtube.com/watch?v=cVj0jqOlGXo&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=cVj0jqOlGXo&lt;/a&gt; but instead of transmitting through bluetooth it would transmit it through a usb cable that plugs from my phone directly into my arduino.&lt;/p&gt;&#xA;" OwnerUserId="15997" LastEditorUserId="15997" LastEditDate="2016-01-03T04:33:39.027" LastActivityDate="2016-02-02T21:53:19.833" Title="android app to control arduino using usb" Tags="|usb|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19207" PostTypeId="1" CreationDate="2016-01-03T06:43:52.387" Score="8" ViewCount="22379" Body="&lt;p&gt;I went to upload my sketch to my Uno (r3), but unusually, the Upload Console returned this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\COM4&quot;: Access is denied.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just started seeing this, cannot upload.&lt;/p&gt;&#xA;" OwnerUserId="15884" LastEditorUserId="11529" LastEditDate="2016-02-07T11:21:25.373" LastActivityDate="2019-12-29T23:51:25.893" Title="Access denied when Uploading" Tags="|arduino-uno|ide|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19208" PostTypeId="2" ParentId="13429" CreationDate="2016-01-03T11:00:29.520" Score="2" Body="&lt;p&gt;I have this compilation error:   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TimeSerial.ino:68:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]&#xA;   if(Serial.find(TIME_HEADER)) {&#xA;&#xA;                         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please replace this line:&lt;br&gt;&#xA;&lt;code&gt;#define TIME_HEADER  &quot;T&quot;   // Header tag for serial time sync message&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;with this line:&lt;br&gt;&#xA;&lt;code&gt;#define TIME_HEADER  'T'   // Header tag for serial time sync message&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and compilation goes well.&lt;/p&gt;&#xA;" OwnerUserId="16046" LastEditorUserId="53314" LastEditDate="2019-07-09T16:31:52.837" LastActivityDate="2019-07-09T16:31:52.837" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="19209" PostTypeId="1" AcceptedAnswerId="19212" CreationDate="2016-01-03T11:01:00.107" Score="2" ViewCount="511" Body="&lt;p&gt;I was reading &lt;a href=&quot;http://www.embedds.com/programming-avr-usart-with-avr-gcc-part-1/&quot; rel=&quot;nofollow&quot;&gt;documentation on UART on AVR&lt;/a&gt; and it looks simple: when a flag (bit &lt;code&gt;RXC0&lt;/code&gt; of register &lt;code&gt;UCSR0A&lt;/code&gt;) is set to 1, it means the micro controller has new data for you, and you read this from register &lt;code&gt;UDR0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But something boggles my mind: How does the micro controller know that we have read the data? Or, in other words, after it received the first byte on UART, the flag is set to 1, but when is it set back to 0?&lt;/p&gt;&#xA;" OwnerUserId="16045" LastEditorUserId="6936" LastEditDate="2016-01-04T19:40:32.943" LastActivityDate="2016-01-04T19:40:32.943" Title="In UART, what mechanism sets the &quot;new data received&quot; flag back to 0?" Tags="|avr|uart|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19210" PostTypeId="1" AcceptedAnswerId="19267" CreationDate="2016-01-03T11:21:26.343" Score="1" ViewCount="707" Body="&lt;p&gt;Preferably PID functions on an Arduino uno or any other examples. I have been researching but many of the the websites really do not explain it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;P.S is there an algorithm for a PID? Thanks&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="14391" LastActivityDate="2016-01-06T11:32:13.917" Title="How does the PID controller actually work?" Tags="|arduino-uno|programming|electronics|pid|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19212" PostTypeId="2" ParentId="19209" CreationDate="2016-01-03T12:07:28.783" Score="2" Body="&lt;p&gt;The ATmega328p data-sheet describes the setting of RXCn:&lt;/p&gt;&#xA;&lt;h3&gt;Bit 7 – RXCn: USART Receive Complete&lt;/h3&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This flag bit is set when there are unread data in the receive buffer and cleared when the receive buffer is empty (i.e., does not contain any unread data). If the Receiver is disabled, the receive buffer will be flushed and consequently the RXCn bit will become zero. The RXCn Flag can be used to generate a Receive Complete interrupt (see description of the RXCIEn bit).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The hardware seems to keep a register the size of the receive buffer. Incremented when received and decremented when read. It is only one level so the size is 0..1, i.e. one bit.&lt;/p&gt;&#xA;&lt;p&gt;Actually there is two registers; one for possible incoming data and one for the latest data until read.&lt;/p&gt;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&lt;p&gt;More details in &lt;a href=&quot;http://www.atmel.com/images/doc8161.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328p data-sheet, chap. 19 USART0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-03T12:07:28.783" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19213" PostTypeId="2" ParentId="19207" CreationDate="2016-01-03T12:17:30.483" Score="0" Body="&lt;p&gt;You have selected the wrong COM port. Go to Tools -&gt; Port -&gt; Select the right port. If you do not know the port number disconnect the Arduino, open the same menu again and look what is listed there, write down if you can't remember, now plug your Arduino back in and select the option that wasn't there before.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-01-03T12:17:30.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19215" PostTypeId="2" ParentId="1391" CreationDate="2016-01-03T16:29:00.930" Score="6" Body="&lt;p&gt;I had this same issue when setting up this circuit with this code and driver on an Arduino Uno. All else was fine, but the current for the motor was set WAY too high on the driver from the factory. The VREF was 1.7 volts, and it needed to be around .5 for the motor I was using. As I set the VREF to the appropriate voltage, the motor started to spin as it should and stopped hissing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this post is old, but I hope that this helps someone else. Pololu has a great video (and documentation in general) for setting the appropriate voltage on most of their drivers on the product page here: &lt;a href=&quot;https://www.pololu.com/product/2133&quot; rel=&quot;nofollow&quot;&gt;DRV8825 Stepper Motor Driver Carrier, High Current&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="16057" LastEditorUserId="6936" LastEditDate="2016-01-04T19:40:57.463" LastActivityDate="2016-01-04T19:40:57.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19216" PostTypeId="1" AcceptedAnswerId="19218" CreationDate="2016-01-03T17:06:14.583" Score="1" ViewCount="478" Body="&lt;p&gt;&lt;strong&gt;Parts&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno R3 (Atmega328 - assembled)&lt;/li&gt;&#xA;&lt;li&gt;Adafruit Bicolor LED Square Pixel Matrix with I2C&#xA;Backpack&lt;/li&gt;&#xA;&lt;li&gt;Electret Microphone Amplifier - MAX4466 with Adjustable Gain&lt;/li&gt;&#xA;&lt;li&gt;Half-size Breadboard&lt;/li&gt;&#xA;&lt;li&gt;Breadboarding wires&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;br&gt;&#xA;I have been following the build guide for the &quot;Piccolo Music Visualizer&quot; on the Adafruit website (&lt;a href=&quot;https://learn.adafruit.com/piccolo?view=all&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/piccolo?view=all&lt;/a&gt;), using all of the same components and code (following the guide exactly as shown). I first tested the 8x8 matrix to see if it was working properly, and it works beautifully. The problems started when I wired up the electret microphone... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In regard to how I wired this to the breadboard, I followed the example for the R3 on the Adafruit guide (since that's my current version): &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;&#xA;The files (code) used for this project are found here: (&lt;a href=&quot;https://github.com/adafruit/piccolo&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/piccolo&lt;/a&gt;). The ffft file is supposed to be saved to the library (this worked for me). The Piccolo file is supposed to be saved to the Sketchbook (this did not work for me - kept giving error messages when trying to reference it). I instead copied the code found in the Piccolo file, and saved it as a new sketchbook file. Let me know if this might be the cause of the problem. This is my first arduino project, so I am still trying to figure out how the IDE works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;&#xA;The electret microphone is supposed to pick up audio and the LED matrix should display a waveform based on the loudness and frequency of the audio. Instead, I only have 2 bars on the bottom left lighting up (the effect is static - wont respond to volume or frequency changes). Oddly, when pulling out the microphone from the breadboard, the waveform begins displaying as it should, but in a glitchy/unstable form. I figured the problem was with the adjustable gain on the microphone, but no matter how much I adjust the screw only the 2 bars are affected and still static (when adjusted to the left only green LED, in middle is green and orange, to the right is red/orange/green on the matrix).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little confused as to what the problem could be... is the microphone broken, code malfunctioning, wiring incorrect, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pictures to reference&lt;/strong&gt; (DropBox link)&lt;strong&gt;:&lt;/strong&gt;&lt;br&gt;&#xA;- &lt;strong&gt;&lt;em&gt;See comment below for link&lt;/em&gt;&lt;/strong&gt; (must have &lt;em&gt;10 rep&lt;/em&gt; to use more than &lt;em&gt;2 links&lt;/em&gt; in post)&lt;br&gt;&#xA;(zip file contains &lt;strong&gt;3&lt;/strong&gt; pictures: &quot;&lt;em&gt;wiring&lt;/em&gt;&quot;, &quot;&lt;em&gt;when_on&lt;/em&gt;&quot;, &quot;&lt;em&gt;pulling_out_mic&lt;/em&gt;&quot;)&lt;br&gt;&#xA;Photos are over 2MB so I couldnt upload here.&lt;/p&gt;&#xA;" OwnerUserId="14947" LastActivityDate="2016-01-03T20:38:34.887" Title="Audio Visualizer (not working properly)" Tags="|arduino-uno|led|arduino-ide|audio|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19217" PostTypeId="1" AcceptedAnswerId="19343" CreationDate="2016-01-03T14:13:45.170" Score="5" ViewCount="2458" Body="&lt;p&gt;I'm working on an Arduino project, and I'd like to add GPS functionality. I could buy a GPS module, but those are expensive. I had an old Garmin Forerunner 305 lying around, so I took it apart and took a peek inside. There are two PCBs - one connected to a screen and one to the GPS. In addition, there was a battery and a small part for charging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to know if it is possible to connect this GPS to my Arduino, and if so, how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edited:&#xA;To make my question more precise,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-I see the pins in the top right of the picture. How do I connect those to my Arduino? Is there any specific kind of wire? Because the pins are too small for standard wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Once I connect it, how do I figure out the voltage requirements and pin layout? I tried googling the  GPS model, but nothing helpful came up. What kind of scope should I put on it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two pictures below show only the GPS part of the inside of the watch.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/CMrCK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CMrCK.jpg&quot; alt=&quot;The GPS PCB&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VsdzK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VsdzK.jpg&quot; alt=&quot;The other side of the GPS&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16066" OwnerDisplayName="geckods" LastEditorUserId="16066" LastEditDate="2016-01-04T00:35:34.660" LastActivityDate="2017-10-08T20:21:17.123" Title="Can I use a GPS from old Garmin with an Arduino?" Tags="|gps|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19218" PostTypeId="2" ParentId="19216" CreationDate="2016-01-03T20:38:34.887" Score="0" Body="&lt;p&gt;It sounds like a dry joint; the fact that the LED matrix seems to work 'better' when you're fiddling with the microphone board makes me think that the problem lies entirely with that little board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try adding more solder; the more the merrier.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-01-03T20:38:34.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19219" PostTypeId="2" ParentId="18383" CreationDate="2016-01-03T20:50:54.603" Score="2" Body="&lt;p&gt;Try the &lt;a href=&quot;http://www.powerswitchtail.com/Pages/default.aspx&quot; rel=&quot;nofollow&quot;&gt;PowerSwitch Tail II&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is suitable if you are living in the USA (120VAC power).&#xA;You will find 240VAC versions as a kit on that web page as well.&lt;/p&gt;&#xA;" OwnerUserId="16061" LastEditorUserId="6936" LastEditDate="2016-01-06T03:17:17.680" LastActivityDate="2016-01-06T03:17:17.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19220" PostTypeId="2" ParentId="19206" CreationDate="2016-01-03T21:08:54.670" Score="1" Body="&lt;p&gt;I think you may want to look &lt;em&gt;USB Serial port communication in android&lt;/em&gt;. Some googling will help&#xA; here's a nice example of such work, described in detail: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://felhr85.net/2015/01/09/a-dirty-and-quick-example-of-serial-port-communication-in-android/&quot; rel=&quot;nofollow&quot;&gt;http://felhr85.net/2015/01/09/a-dirty-and-quick-example-of-serial-port-communication-in-android/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in case the codes/that source gets lost, here is the&#xA;GitHub link of the developer: &lt;a href=&quot;https://github.com/felHR85/SerialPortExample&quot; rel=&quot;nofollow&quot;&gt;https://github.com/felHR85/SerialPortExample&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16064" LastActivityDate="2016-01-03T21:08:54.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19223" PostTypeId="1" CreationDate="2016-01-04T09:14:21.430" Score="1" ViewCount="7425" Body="&lt;p&gt;I'm trying to use Arduino Uno as ISP to program Arduino Mega 2560 using this Pin connections (Uno-&gt;Mega):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;slave reset: 10:       -&gt;        RESET on target&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MOSI:        11:      -&gt;           51&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MISO:        12:      -&gt;         50&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCK:         13:      -&gt;        52&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It runs perfectly when I &quot;Burn Bootloader&quot; from Arduino IDE and LED starts blinking on target. So I assume my pin connections are correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I open the Blink example and perform &quot;Upload Using Programmer&quot; in Sketch tab after choosing &quot;Arduino as ISP&quot; in Tools&gt;Programmer it uploads the code but LED on Mega doesn't blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm afraid that I have problem in my Mega Bootloader hex file and think it's not configuring Pin 13 as a LED pin. But in this case I shouldn't have seen the led blinking after burning the bootloader. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here? I appreciate your help.&#xA;-Bex&lt;/p&gt;&#xA;" OwnerUserId="16073" LastActivityDate="2023-05-12T00:58:37.757" Title="Using Arduino Uno as ISP to program Mega 2560" Tags="|arduino-uno|arduino-mega|arduinoisp|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19224" PostTypeId="1" CreationDate="2016-01-04T11:23:41.883" Score="0" ViewCount="2330" Body="&lt;p&gt;I have made an Arduino kit that acts as a weather station. It sends sensors data (DHT11 &amp;amp; LDR) to the ThingSpeak web server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to perform some actions based on the data on the ThingSpeak server (like if temperature exceeds a limit turn on the fan, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched and I found that there's a React app on ThingSpeak, which will trigger events if data exceeds some values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem where I got stuck is that I want to send a signal from the ThingSpeak web server to my ESP8266 (Arduino) to turn on/off the device connected to a relay on Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've figured out that there's also a ThingHTTP feature which sends HTTP requests. But I don't know how to send requests/signals to my kit to perform some actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already spent 2 months building this project, and now I'm stuck in the last part. Please give your valuable suggestions and solutions.&lt;/p&gt;&#xA;" OwnerUserId="16079" LastEditorUserId="4628" LastEditDate="2017-12-28T12:25:53.263" LastActivityDate="2017-12-28T12:26:45.850" Title="How to send data from ThingSpeak to ESP-8266 (Arduino) using ThingHTTP?" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19226" PostTypeId="2" ParentId="2940" CreationDate="2016-01-04T14:15:31.303" Score="0" Body="&lt;p&gt;Check this video,&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=RoG_-9lAnSI&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO as a USB keyboard (HID device) [Anything Arduino] (ep 6)&lt;/a&gt;,&#xA;as I think this is what you are looking for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the youtube video you can get links to the library site and schematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do need to build a small interface to connect your Arduino to a PC.&#xA;I got it for Uno and Micro, but other Arduinos with latest firmware would be OK.&lt;/p&gt;&#xA;" OwnerUserId="16080" LastEditorUserId="6936" LastEditDate="2016-01-08T16:39:20.787" LastActivityDate="2016-01-08T16:39:20.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19227" PostTypeId="2" ParentId="18993" CreationDate="2016-01-04T17:41:25.637" Score="0" Body="&lt;p&gt;I am getting the same exact errors.  Tried different boards, cables, upgrade to 1.6.7, etc.  Maybe will go back to pre1.6 and try.  Will also try via tinyisp when I get a chance.  FYI - having no issues with studio 6/tinyusb/avrdude combination, just on arduino.  Wonder if it is a USB driver or arduino version of avrdude problem?&lt;/p&gt;&#xA;" OwnerUserId="16084" LastActivityDate="2016-01-04T17:41:25.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19228" PostTypeId="1" AcceptedAnswerId="19235" CreationDate="2016-01-04T18:27:20.060" Score="1" ViewCount="170" Body="&lt;p&gt;I wanted to install a 5 LED strip underneath my PC's front panel. I want to send color over PC so it can change when i open different apps, with temperature or etc!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all I think the best way to do this is to just use Arduino to set the LED Values!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have had some troubles creating a good communication protocol for this, I've been just simply sending 45 digits (15 3 digit numbers) to my Arduino with serial. here's code:&#xA;Arduino :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_NeoPixel.h&quot;&#xA;#include &quot;WS2812_Definitions.h&quot;&#xA;&#xA;#define PIN 4&#xA;#define LED_COUNT 5&#xA;&#xA;struct pixel {&#xA;  int R = 0;&#xA;  int B = 0;&#xA;  int G = 0;&#xA;};&#xA;&#xA;Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;char count = 1;&#xA;int pixelNumber = 0;&#xA;struct pixel tempPixel;&#xA;//struct pixel Pixels[LED_COUNT];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Init&quot;);&#xA;  leds.begin();  // Call this to start up the LED strip.&#xA;  clearLEDs();   // This function, defined below, turns all LEDs off...&#xA;  leds.show();   // ...but the LEDs don't actually update until you call this.&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available() &amp;gt; 0) {&#xA;    if(count == 1) {&#xA;      tempPixel.R = PC_Receive();&#xA;    } else if (count == 2) {&#xA;      tempPixel.G = PC_Receive();&#xA;    } else if (count == 3) {&#xA;      tempPixel.B = PC_Receive();&#xA;      count = 0;&#xA;&#xA;      setPixelColor(pixelNumber, tempPixel);&#xA;      Serial.println(pixelNumber);&#xA;      leds.show();&#xA;//      Pixels[pixelNumber] = tempPixel;&#xA;      if(++pixelNumber &amp;gt;= LED_COUNT) {&#xA;        pixelNumber = 0;&#xA;      }&#xA;    }&#xA;    count++;&#xA;  }&#xA;&#xA;//  if(pixelNumber == 0) {&#xA;//    for(int i = 0; i &amp;lt; LED_COUNT; i++ ) {&#xA;//       setPixelColor(i, Pixels[i]); &#xA;//    }&#xA;//    &#xA;//    leds.show();&#xA;//  }&#xA;}&#xA;&#xA;void setPixelColor(int a, struct pixel P)&#xA;{&#xA;  leds.setPixelColor(a, P.R, P.G, P.B);&#xA;}&#xA;&#xA;char PC_Receive() {&#xA;  int result = 0;&#xA;&#xA;  while(Serial.available() == 0);&#xA;  result += ((int)Serial.read() - '0') * 100;&#xA;&#xA;  while(Serial.available() == 0);&#xA;  result += ((int)Serial.read() - '0') * 10;&#xA;&#xA;  while(Serial.available() == 0);&#xA;  result += ((int)Serial.read() - '0');&#xA;&#xA;  Serial.println(result);&#xA;  return result;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {&#xA;  for(int i = 0; i &amp;lt; LED_COUNT; i++) {&#xA;    leds.setPixelColor(i, red, green, blue);&#xA;  }&#xA;  leds.show();&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's PC's dirty code in python:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import time&#xA;import random&#xA;&#xA;class Pixel:&#xA;&#xA;    def __init__(self, R, G, B):&#xA;        self.R = R&#xA;        self.G = G&#xA;        self.B = B&#xA;&#xA;def clearAll():&#xA;    for i in range(0,5):&#xA;        ser.write(&quot;000000000&quot;)&#xA;&#xA;def sendPixel(pixels):&#xA;    for i in range(0,5):&#xA;        ser.write(str(pixels[i].R).zfill(3))&#xA;        ser.write(str(pixels[i].B).zfill(3))&#xA;        ser.write(str(pixels[i].G).zfill(3))&#xA;&#xA;&#xA;ser = serial.Serial('/dev/ttyACM2', 9600)&#xA;&#xA;little = [0,0,0,0,0]&#xA;&#xA;for i in range(0,5): &#xA;    little[i] = Pixel(0,255,50)&#xA;sendPixel(little)&#xA;&#xA;time.sleep(0.5)&#xA;clearAll()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the problem is it isn't stable, i think i should just use an \n at end or send back OK or something to confirm it, but that would make it slow if i did it for each value! (and checking only once after all 5 leds are send would mean sending more values until i receive the ok and clearing and sending them again!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you recommend me a better way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Just wanted to say! it's almost done! It does change color when i open chrome, and i think at 115200 baud rate it's fast enough to not notice a delay (although at 9600 i felt like it's slower then my (xxx/xxx/xxx....) protocol but it's better and works at 115200&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i will add some basic functions to my python side and add a rainbow effect&#xA;I will also add GPU temperature and etc... it's not going to be really hard on linux but windows, im not sure :D&lt;/p&gt;&#xA;" OwnerUserId="13932" LastEditorUserId="13932" LastEditDate="2016-01-06T17:04:36.570" LastActivityDate="2016-01-06T17:04:36.570" Title="Sending 5 Led pixel values to arduino , is this a good way?" Tags="|communication|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19229" PostTypeId="2" ParentId="19197" CreationDate="2016-01-04T18:34:34.847" Score="1" Body="&lt;p&gt;You can get sprinkler valves, that use solenoids, for under $20 that fit on plastic PVC pipe and are designed for water, such as these at &lt;a href=&quot;http://www.sprinklerwarehouse.com/&quot; rel=&quot;nofollow&quot;&gt;SprinklerWarehouse&lt;/a&gt;.  They typically use pipe sizes of about 1 inch.  &lt;/p&gt;&#xA;" OwnerUserId="16087" LastEditorUserId="6936" LastEditDate="2016-01-08T16:38:10.773" LastActivityDate="2016-01-08T16:38:10.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19230" PostTypeId="1" CreationDate="2016-01-04T19:28:04.893" Score="1" ViewCount="406" Body="&lt;p&gt;I have tried this on both an Arduino Uno and an Arduino Mega2560. my issue is as follows. Without a 150 LED string of addressable pixels attached, I can pretty consistently capture and read the input from an IR sensor connected at digital pin 2. Once I connect a addressable string of 150 LEDs at digital pin 3, it seems that I am no longer able to reliably read the input from the IR sensor. This seems to be more the case when the pattern I have running on the LED string is heavy, i.e., the majority of the pixels are lit, or the brightness is high. This project also includes a mic connected at analog 5 and aref. Additionally, I am using a 16×2 LCD Display &amp;amp; Keypad Shield connected at digital pins 4-9. Is there any reason that the voltage difference could screw with reading the IR input.&lt;/p&gt;&#xA;" OwnerUserId="16089" LastActivityDate="2016-01-04T19:28:04.893" Title="Arduino Neopixel affecting IR receiver module" Tags="|arduino-uno|arduino-mega|ir|neopixel|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19231" PostTypeId="1" CreationDate="2016-01-04T19:32:08.157" Score="2" ViewCount="82" Body="&lt;p&gt;I am going to use Nick's rolling-master system library (&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=11428&lt;/a&gt;) in my home project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For first experiments and testing, I have:&lt;br&gt;&#xA;- BAUD_RATE = 9600&lt;br&gt;&#xA;- max adress = 2 (it means max 3 drops)&lt;br&gt;&#xA;- 2 active drops with adress=0 and adress=1, 1 intentionally missing drop (simulation    of malfunction one of drops :-))&lt;br&gt;&#xA;- TIME_BETWEEN_MESSAGES = 200000&lt;br&gt;&#xA;- Packet length = 200 bytes&lt;br&gt;&#xA;- Packet time = 208333 microseconds&lt;br&gt;&#xA;- Timeout for no messages = 1633332 microseconds&lt;br&gt;&#xA;- gap between messages = 200 ms (measured value by oscilloscope).&lt;br&gt;&#xA;It work perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to increase the gap between the messages, but after I increased the constant &quot;TIME_BETWEEN_MESSAGES&quot;  from 200000 to 300000, then start bad communication  between the drops:&lt;br&gt;&#xA;- TIME_BETWEEN_MESSAGES = 300000&lt;br&gt;&#xA;- Packet length = 200 bytes&lt;br&gt;&#xA;- Packet time = 208333 microseconds&lt;br&gt;&#xA;- Timeout for no messages = 2033332 microseconds&lt;br&gt;&#xA;- gap between messages = 2170 ms&lt;br&gt;&#xA;Adress first started after reset (for example 1)  broadcasts, but nothing receives from other adress (for example 0), which started later.&lt;br&gt;&#xA;Adress 0 receives all messages from adress 1 OK, but nothing transmits (subroutine &quot;sendMessage ()&quot; is never called).&lt;br&gt;&#xA;After reseting of broacasting drop with adress  1, it works in reverse (addr 1 only receives, no broadcast, and addr 0 broadcasts).   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is there limit for &quot;TIME_BETWEEN_MESSAGES&quot; value ? &lt;strong&gt;How to increase gap between messages ?&lt;/strong&gt; For my purpose be enough gap 1 - 2 sec and so drops should have enough time for their own job. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for advice,&lt;br&gt;&#xA;Vava&lt;br&gt;&#xA;(Sorry for my English... :-)&lt;/p&gt;&#xA;" OwnerUserId="15238" LastEditorUserId="15238" LastEditDate="2016-01-04T19:43:46.627" LastActivityDate="2016-01-04T19:43:46.627" Title="Multi-drop RS485 device control v1.0 - why is limit for &quot;TIME_BETWEEN_MESSAGES &quot;?" Tags="|networking|timing|rs485|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19232" PostTypeId="2" ParentId="19228" CreationDate="2016-01-04T19:35:20.093" Score="0" Body="&lt;p&gt;I'd recommend adding digits to a digit register, setting the an R,B,G register with R,B,G and setting values of led a-e to the RBG registers when you get an a-e, ignoring whitespace, and clearing the register otherwise.  So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ser.write(&quot;xRBGabcde\n&quot;)  # clear all the LEDs&#xA; ser.write(&quot;x127RBb&quot;)       # make led b half-purple, relying on prior state &#xA; ser.write(&quot;x255Gc&quot;)        # make led c greenish-white    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-01-04T19:35:20.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19233" PostTypeId="1" CreationDate="2016-01-04T19:36:29.097" Score="3" ViewCount="6583" Body="&lt;p&gt;I have a &lt;a href=&quot;https://alselectro.files.wordpress.com/2015/05/esp1.png&quot; rel=&quot;nofollow&quot;&gt;ESP8266&lt;/a&gt; and I wonder if it is possible to create a Wi-Fi signal repeater using this module.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I can create a network so that devices connect it. &lt;/li&gt;&#xA;&lt;li&gt;I can connect to an existing network. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I can not connect the network created with the network that I connected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how to do this? or you have any examples?&lt;/p&gt;&#xA;" OwnerUserId="3837" LastEditorUserId="11529" LastEditDate="2016-02-26T15:02:31.483" LastActivityDate="2016-02-28T02:22:20.583" Title="WiFi repeater using ESP8266" Tags="|esp8266|" AnswerCount="1" CommentCount="1" ClosedDate="2016-03-01T06:17:40.050" ContentLicense="CC BY-SA 3.0" />
  <row Id="19234" PostTypeId="1" AcceptedAnswerId="19237" CreationDate="2016-01-04T19:55:14.847" Score="3" ViewCount="74889" Body="&lt;p&gt;How do I print a string and integer on an LCD? Here is what I have tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int number = 2;&#xA;int result = (number + number);&#xA;lcd.print(number, DEC + &quot; plus &quot; + number, DEC + &quot; equals &quot; + result, DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the result is an error.  When I try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(number + &quot;look&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;1234 &quot; + number);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the result on the LCD is &quot;34 &quot;, as it deleted the first two numbers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want it to print:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1234 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help!  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16090" LastActivityDate="2019-11-01T04:10:16.903" Title="Print string and integer LCD" Tags="|arduino-uno|programming|lcd|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19235" PostTypeId="2" ParentId="19228" CreationDate="2016-01-04T19:56:51.517" Score="1" Body="&lt;p&gt;I would recommend a similar solution as DaveX with a small modofication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you bitmask your LEDS, and leave room for a possible additional 3, you can mask any combination of them in the space of 00-FF. then you could send to the arduino a single string of 0xFFFFFFFF  FF(LED bitmask),FF(Red value), FF(Green Value), FF(Blue Value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so &#xA;LED 1 {&lt;code&gt;00000001&lt;/code&gt; =&lt;code&gt;01&lt;/code&gt;} all red {&lt;code&gt;FF0000&lt;/code&gt;} would be &lt;code&gt;0x01FF0000&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED 2 and  4 {&lt;code&gt;00001010&lt;/code&gt; =&lt;code&gt;0A&lt;/code&gt;} all green {&lt;code&gt;00FF00&lt;/code&gt;} would be &lt;code&gt;0x0A00FF00&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED 5 and 1 {&lt;code&gt;00010001&lt;/code&gt; =&lt;code&gt;11&lt;/code&gt;} all blue {&lt;code&gt;0000FF&lt;/code&gt;} would be &lt;code&gt;0x110000FF&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ALL LEDS off would be &lt;code&gt;0xFF000000&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All LEDS onn full white would be &lt;code&gt;0xFFFFFFFF&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="16089" LastActivityDate="2016-01-04T19:56:51.517" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19236" PostTypeId="1" AcceptedAnswerId="19860" CreationDate="2016-01-04T16:24:55.860" Score="1" ViewCount="242" Body="&lt;p&gt;I Have 2&lt;a href=&quot;http://panstamp.com&quot; rel=&quot;nofollow&quot;&gt;panstamp&lt;/a&gt;. I can program the first but not the second with the arduino program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I upload the sketch (a simple blink) on the second, I got this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Reading | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: Device signature = 0x004e22&#xA;avrdude: Expected signature for ATmega328P is 1E 95 0F&#xA;Double check chip, or use -F to override this check.&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And if I retry, I got this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;Reading | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: Device signature = 0x81f014&#xA;avrdude: Expected signature for ATmega328P is 1E 95 0F&#xA;Double check chip, or use -F to override this check.&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The device signature is not the same anymore ... &#xA;I've changed the wire and re-open arduino program. But it don't change, the device signature change (often 0xE1E1E1). I've check the connection between the ATmega and the wire and everything is ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the Panstamp broken ? or should I do a kind of factory reset?&lt;/p&gt;&#xA;" OwnerUserId="4659" OwnerDisplayName="Thanatheos" LastActivityDate="2016-01-22T22:21:39.043" Title="panstamp device signature is random" Tags="|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19237" PostTypeId="2" ParentId="19234" CreationDate="2016-01-04T20:21:15.927" Score="6" Body="&lt;p&gt;The &lt;code&gt;lcd.print()&lt;/code&gt; method takes a string or a number as an argument, but not both at once. Using the + operator for concatenation is not native to C strings. C strings are basically stored as pointers to the first character of the string. So when you tried &lt;code&gt;lcd.print(&quot;1234 &quot; + number)&lt;/code&gt; and got &lt;code&gt;&quot;34 &quot;&lt;/code&gt;, what most likely happened is that you advanced the pointer, pointing to the first character of &lt;code&gt;&quot;1234 &quot;&lt;/code&gt;(i.e. '1') by &lt;code&gt;number&lt;/code&gt; (i.e. 2), thus making the pointer point to the &lt;strong&gt;3rd&lt;/strong&gt; character in the string and thus making &lt;code&gt;lcd.print()&lt;/code&gt; display &lt;code&gt;&quot;34 &quot;&lt;/code&gt;. &#xA;In order to print something that contains both strings and integers, the most straightforward way is to convert each piece to an Arduino string and then concatenate them, using the + operator like you did earlier.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    lcd.print(String(&quot;1234 &quot;) + String(number));&#xA;    lcd.print(String(number) + String(&quot; plus &quot;) + String(number) + String(&quot; equals &quot;) + String(result));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are some examples. You could also use create a sufficiently large &lt;code&gt;char&lt;/code&gt; buffer and use &lt;code&gt;sprintf()&lt;/code&gt; from &lt;code&gt;stdio.h&lt;/code&gt; to build a string made up of integers and strings. Look up a textbook on C/C++ for more details.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-04T20:21:15.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19238" PostTypeId="2" ParentId="19234" CreationDate="2016-01-04T20:25:01.427" Score="0" Body="&lt;p&gt;What is wrong with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(number, DEC + &quot; plus &quot; + number, DEC + &quot; equals &quot; + result, DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is the number of parameters and the assumption that plus will concatenate string literals.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;1234 &quot; + number);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives &quot;34 &quot; when number is 2. Why? This is because that is the result of adding 2 to the string literal pointer, i.e. the string starting at the character &quot;3&quot;. Please use separate print statements instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;1234 &quot;);&#xA;lcd.print(number);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not use String to concatenate strings. That is a waste of SRAM, processing and has a risk of heap fragmentation. Simply a bad idea in small scale embedded systems such as AVR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To understand these errors you should go back and read about strings and string literals in C/C++ (compared to Java :).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-04T20:25:01.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19239" PostTypeId="2" ParentId="432" CreationDate="2016-01-04T21:06:42.627" Score="1" Body="&lt;p&gt;If you want a cheaper alternative to add WiFi capabilities to Arduino look at &lt;a href=&quot;http://www.instructables.com/id/Cheap-Arduino-WiFi-Shield-With-ESP8266/&quot; rel=&quot;nofollow&quot;&gt;ESP WiFi shield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works great with &lt;a href=&quot;http://yaab-arduino.blogspot.it/p/wifiesp.html&quot; rel=&quot;nofollow&quot;&gt;WiFiEsp library&lt;/a&gt;.&#xA;Programming model is exactly the same as Arduino WiFi Shield﻿&lt;/p&gt;&#xA;" OwnerUserId="7938" LastActivityDate="2016-01-04T21:06:42.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19240" PostTypeId="2" ParentId="19097" CreationDate="2016-01-04T21:20:10.720" Score="0" Body="&lt;p&gt;A look at &lt;a href=&quot;https://github.com/itead/ITEADLIB_Arduino_WeeESP8266/blob/master/ESP8266.h&quot; rel=&quot;nofollow&quot;&gt;https://github.com/itead/ITEADLIB_Arduino_WeeESP8266/blob/master/ESP8266.h&lt;/a&gt; shows that when you pass a &lt;code&gt;SoftwareSerial&lt;/code&gt; object to the ESP8266 constructor, a default baud rate of 9600 is also passed to it. Also, the library source file shows that, in the constructor, the &lt;code&gt;begin()&lt;/code&gt; method of the &lt;code&gt;SoftwareSerial&lt;/code&gt; object you passed (myserial) is called with 9600 baud. Thus, this line in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    mySerial.begin(115200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a duplicate, albeit one with a different baud rate, thus rendering the constructor's call of &lt;code&gt;mySerial.begin()&lt;/code&gt; useless, since your call comes after the constructor's. If you are certain that 115200 is the right baud rate for the hardware, then you should get rid of the line above and instead pass the baud rate to the constructor like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ESP8266 wifi(mySerial, 115200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace 115200 with any baud rate you discover to be the right one for the AT commands. You also need to uncomment the line in ESP8266.h in your library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //#define ESP8266_USE_SOFTWARE_SERIAL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then save, since you are using SoftwareSerial to communicate with the module.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-04T21:20:10.720" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19242" PostTypeId="2" ParentId="18959" CreationDate="2016-01-04T22:19:34.973" Score="5" Body="&lt;p&gt;Press the reset button next to the USB port. (either one, the master reset is between the DC jack and USB ).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will cause the Arduino 101 to reboot and enter DFU mode for 5 seconds if it is connected on USB. The download will proceed when the Curie enters DFU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IDE uses a baud-rate signal over USB. It is a virtual serial port, so baud rate doesn't matter. But when the host side (Arduino IDE) switches the baud rate to 1200, the board will reboot and enter DFU mode for download. If it gets stuck for some reason and misses the message to reboot, you can just hit the reset button and accomplish the same thing.&lt;/p&gt;&#xA;" OwnerUserId="16095" LastActivityDate="2016-01-04T22:19:34.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19243" PostTypeId="1" AcceptedAnswerId="19244" CreationDate="2016-01-05T00:18:54.003" Score="3" ViewCount="7228" Body="&lt;p&gt;I was trying to follow &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SPIEEPROM&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tutorial and came across &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;. What exactly does this do? &lt;/p&gt;&#xA;" OwnerUserId="16096" LastEditorUserId="37" LastEditDate="2016-01-08T20:54:17.323" LastActivityDate="2016-01-08T21:17:57.143" Title="&gt;&gt; &lt;&lt; and -&gt; Syntax in arduino" Tags="|programming|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19244" PostTypeId="2" ParentId="19243" CreationDate="2016-01-05T00:36:41.037" Score="4" Body="&lt;p&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; is right shift a value by a certain number of bits.&#xA;&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; is left shift a value by a certain number of bits.&#xA;&lt;code&gt;-&amp;gt;&lt;/code&gt; is accessing a member of a class or struct that is referenced by a pointer.&lt;/p&gt;&#xA;&lt;h1&gt;Right Shift and Left Shift&lt;/h1&gt;&#xA;&lt;p&gt;If you have a binary number &lt;code&gt;0b00010000&lt;/code&gt; and right shift it two bits you get &lt;code&gt;0b00000100&lt;/code&gt;. The C notation for that is &lt;code&gt;val &amp;gt;&amp;gt; 2&lt;/code&gt;.  The same for left shift - &lt;code&gt;val &amp;lt;&amp;lt; 2&lt;/code&gt; would result in &lt;code&gt;0b01000000&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h1&gt;Pointers and members&lt;/h1&gt;&#xA;&lt;p&gt;Normally when you access a member of a class or struct you use &lt;code&gt;.&lt;/code&gt;, such as &lt;code&gt;Serial.println()&lt;/code&gt;.  However it is possible to make a &lt;em&gt;pointer&lt;/em&gt; to a class instance, and when you do you need to access the members with &lt;code&gt;-&amp;gt;&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt; - such as &lt;code&gt;mySerial-&amp;gt;println()&lt;/code&gt;.&#xA;This arrow notation serves as syntactic sugar: &lt;code&gt;mySerial-&amp;gt;println()&lt;/code&gt; is interpreted as &lt;code&gt;(*mySerial).println()&lt;/code&gt;. The parentheses are necessary because the dereferencing operator &lt;code&gt;*&lt;/code&gt; has a lower order of precedence compared to the dot &lt;code&gt;.&lt;/code&gt; operator.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-08T21:17:57.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19245" PostTypeId="1" CreationDate="2016-01-05T02:55:52.153" Score="1" ViewCount="273" Body="&lt;p&gt;I am building a temperature monitoring system that has 24 thermocouples. Managing all the wires is a hassle, and I'd like to connect all 48 wires to a few plug and socket connectors. Maybe 6 of these &lt;a href=&quot;http://www.ebay.ca/itm/1pc-Small-8pin-terminal-lead-wire-harness-Jack-and-Plug-8-Pin-Wire-Socket-/181880935288?hash=item2a58f2d378:g:tx8AAOSwQTVWA1NM&quot; rel=&quot;nofollow noreferrer&quot;&gt;lead wire harnesses&lt;/a&gt; from eBay (see below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point of this would be to allow me to quickly disconnect all the thermocouples from their amplifiers when I need reposition the arduino, and then reconnect them afterwards without tracking each individual cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if this will have a negative impact on the function of the thermocouples. Is it ok to have a 'joint' (i.e., the socket) in the thermocouple cables, or do they need to remain intact from the end all the way to the amplifier? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, would having a few inches of regular copper wire inserted between the thermocouple wires and the amplifier be ok? That is, having two copper wires attached to the amplifier, joining 8 of these wires together in a socket, and attaching the plug to the actual thermocouple (alumel/chromel) wires? The thermocouple wires are several feet long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rz8Er.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rz8Er.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3956" LastActivityDate="2016-01-05T13:34:10.267" Title="Plug/socket between thermocouple wires and the amplifier" Tags="|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19246" PostTypeId="2" ParentId="19245" CreationDate="2016-01-05T03:13:26.903" Score="4" Body="&lt;p&gt;I do not know the accuracy that you will require in your temperature measurements.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your idea of using copper wire and connector sockets is reasonably ok as long as you are aware of the following :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where you make a connection from thermocouple wire to copper, that creates another thermocouple in itself. This isn't a great problem since the temperature of the &quot;undesired&quot; thermocouple is likely to be at room temperature (constant?)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;No matter what you do, you always end up with undesired thermocouples (example when you connect your thermocouple directly to your circuit board copper, darn it.)   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.picotech.com/library/application-note/thermocouple-application-note&quot; rel=&quot;nofollow&quot;&gt;Thermocouple Selection and use&lt;/a&gt; is a page you can go to for more information.  Especially the &lt;em&gt;Cold junction compensation&lt;/em&gt; (CJC) section.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT added : You should twist your extention leads together to reduce electrical noise from the environment. Twist each pair, do not twist the bundle all together.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-01-05T13:34:10.267" LastActivityDate="2016-01-05T13:34:10.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19248" PostTypeId="1" CreationDate="2016-01-04T17:34:30.387" Score="0" ViewCount="3707" Body="&lt;p&gt;Hello I have a nokia 5110 lcd display connected to my Arduino. I have looked at so many tutorials and none of them work for me. I am trying to get a bitmap displayed in the screen but only the lights light up and nothing else happens.&#xA;I have the lcd connected to the following Arduino pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;vcc -- 3.3v&lt;/li&gt;&#xA;&lt;li&gt;gnd -- gnd&lt;/li&gt;&#xA;&lt;li&gt;sce -- pin 7&lt;/li&gt;&#xA;&lt;li&gt;rst -- pin 6&lt;/li&gt;&#xA;&lt;li&gt;d/c -- pin 5&lt;/li&gt;&#xA;&lt;li&gt;DN -- pin 4&lt;/li&gt;&#xA;&lt;li&gt;sclk -- pin 8&lt;/li&gt;&#xA;&lt;li&gt;led -- 100ohm resistor --pin 11&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;here is an image&#xA;&lt;a href=&quot;https://i.stack.imgur.com/b5Xh1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b5Xh1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing will display on the screen could someone please help me here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &quot;U8glib.h&quot;&#xA; #include &quot;dht.h&quot;&#xA;&#xA; #define dht_apin A1&#xA; #define backlight_pin 11&#xA;&#xA; dht DHT;&#xA;&#xA; U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6&#xA;&#xA; const uint8_t brainy_bitmap[] PROGMEM = {&#xA;  0x00, 0x00, 0x03, 0xB0, 0x00, 0x00, 0x00, 0x00, &#xA;  0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x46,&#xA;  0x00, 0x00, 0x00, 0x00, 0xFC, 0x47, 0xC0, 0x00, &#xA;  0x00, 0x01, 0xCE, 0x4C, 0x60, 0x00, 0x00, 0x03,&#xA;  0x02, 0x58, 0x30, 0x00, 0x00, 0x03, 0x02, 0x58, &#xA;  0x10, 0x00, 0x00, 0x02, 0x02, 0x58, 0x18, 0x00,&#xA;  0x00, 0x03, 0x06, 0x4C, 0x18, 0x00, 0x00, 0x07, &#xA;  0x04, 0x44, 0x18, 0x00, 0x00, 0x0D, 0x80, 0x40,&#xA;  0x3C, 0x00, 0x00, 0x09, 0xC0, 0x40, 0xE6, 0x00,&#xA;  0x00, 0x18, 0x78, 0x47, 0xC2, 0x00, 0x00, 0x18,&#xA;  0x0C, 0x4E, 0x02, 0x00, 0x00, 0x1F, 0x86, 0x4C, &#xA;  0x7E, 0x00, 0x00, 0x0E, 0xC6, 0xE8, 0xEE, 0x00,&#xA;  0x00, 0x18, 0x43, 0xF8, 0x82, 0x00, 0x00, 0x10, &#xA;  0x06, 0x4C, 0x03, 0x00, 0x00, 0x30, 0x0C, 0x46,&#xA;  0x01, 0x00, 0x00, 0x30, 0x18, 0x46, 0x01, 0x00, &#xA;  0x00, 0x10, 0x18, 0x43, 0x03, 0x00, 0x00, 0x18,&#xA;  0x10, 0x43, 0x03, 0x00, 0x00, 0x1C, 0x70, 0x41, &#xA;  0x86, 0x00, 0x00, 0x0F, 0xE0, 0x40, 0xFE, 0x00,&#xA;  0x00, 0x09, 0x1E, 0x4F, 0x06, 0x00, 0x00, 0x08, &#xA;  0x30, 0x43, 0x86, 0x00, 0x00, 0x0C, 0x20, 0x41,&#xA;  0x86, 0x00, 0x00, 0x06, 0x60, 0x40, 0x8C, 0x00, &#xA;  0x00, 0x07, 0x60, 0x40, 0xB8, 0x00, 0x00, 0x01,&#xA;  0xE0, 0x41, 0xF0, 0x00, 0x00, 0x00, 0x38, 0xE3, &#xA;  0x00, 0x00, 0x00, 0x00, 0x0F, 0xBE, 0x00, 0x00,&#xA;  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xCF, &#xA;  0x82, 0x0C, 0x86, 0x46, 0x1F, 0xEF, 0xC3, 0x0C,&#xA;  0xC6, 0xEE, 0x1C, 0xEC, 0xC7, 0x0C, 0xE6, 0x7C, &#xA;  0x1C, 0xED, 0x8D, 0x8C, 0xFE, 0x38, 0x1C, 0xED,&#xA;  0x8D, 0xCC, 0xDE, 0x38, 0x1D, 0xCD, 0xDF, 0xCC, &#xA;  0xCE, 0x38, 0x1F, 0x8C, 0xF8, 0xEC, 0xC6, 0x38,&#xA;  0x1F, 0xEC, 0x08, 0x0C, 0xC2, 0x18, 0x1C, 0xEC, &#xA;  0x00, 0xC0, 0x00, 0x00, 0x1C, 0xFD, 0xFB, 0xC0,&#xA;  0x00, 0x00, 0x1C, 0xFC, 0x63, 0x00, 0x00, 0x00, &#xA;  0x1C, 0xEC, 0x63, 0xC0, 0x00, 0x00, 0x1F, 0xEC,&#xA;  0x60, 0xC0, 0x00, 0x00, 0x1F, 0xCC, 0x63, 0xC0, &#xA;  0x00, 0x00, 0x1F, 0x0C, 0x63, 0x00, 0x00, 0x00,&#xA;  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, &#xA;  0x00, 0x00, 0x00, 0x00, 0x28, 0x2B, 0x4F, 0x67,&#xA;  0x42, 0x38, 0x7B, 0xEA, 0x86, 0xB2, 0x28, 0xC7, &#xA; };&#xA;&#xA; void draw(void) {&#xA;   u8g.drawBitmapP( 0, 0, 6, 50, brainy_bitmap);  // put bitmap&#xA;   u8g.drawStr(10, 10, &quot;% &quot;);&#xA;&#xA; void loop(void) {&#xA;&#xA;   u8g.firstPage();  &#xA;   do {&#xA;     draw();&#xA;   } while( u8g.nextPage() );&#xA;&#xA;     delay(5000);  // Delay of 5sec before accessing DHT11 (min - 2sec)&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16124" OwnerDisplayName="user2279603" LastActivityDate="2020-04-14T11:49:51.057" Title="Arduino nokia 5110 lcd screen problem" Tags="|lcd|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19249" PostTypeId="2" ParentId="19248" CreationDate="2016-01-05T04:19:09.220" Score="2" Body="&lt;p&gt;There are several possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino GPIO pins drive outputs to ground or 5V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins on the Nokia 5110 LCDs boards I have are not 5V tolerant. So you might have damaged them when the Arduino's GPIO connected to 5V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple fix is to put a 10k ohm resistor in each signal path, i.e.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sce -- pin 7&lt;/li&gt;&#xA;&lt;li&gt;rst -- pin 6&lt;/li&gt;&#xA;&lt;li&gt;d/c -- pin 5&lt;/li&gt;&#xA;&lt;li&gt;DN -- pin 4&lt;/li&gt;&#xA;&lt;li&gt;sclk -- pin 8&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could get a level-shift chip, or build a circuit, but resistors are quick, cheap and easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would strongly recommend using a very simple Arduino library to get the display working. Then, once everything is working, continue with your current approach. All you need is a simple test; something which turns pixels on and off to check that it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had good results with the Arduino Playground &lt;a href=&quot;http://playground.arduino.cc/Code/PCD8544&quot; rel=&quot;nofollow&quot;&gt;Philips PCD8544 (Nokia 3310) driver&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several Nokia 5110's. A few needed the values loaded at initialisation to be tweaked, to make the display visible.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically in void LcdInitialise(void):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  LcdWrite(LCD_C, 0x21 );  // LCD Extended Commands.&#xA;  LcdWrite(LCD_C, 0xB1 );  // Set LCD Vop (Contrast). &#xA;  LcdWrite(LCD_C, 0x04 );  // Set Temp coefficent. //0x04&#xA;  LcdWrite(LCD_C, 0x14 );  // LCD bias mode 1:48. //0x13&#xA;  LcdWrite(LCD_C, 0x20 );  // LCD Basic Commands&#xA;  LcdWrite(LCD_C, 0x0C );  // LCD in normal mode.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have had to tweak &lt;em&gt;Set Temp coefficent&lt;/em&gt;, &lt;em&gt;LCD bias mode 1:48&lt;/em&gt; and &lt;em&gt;Set LCD Vop (Contrast)&lt;/em&gt; to get make the display clear, without looking washed-out, or all-dark. Using a very simple library like the &lt;a href=&quot;http://playground.arduino.cc/Code/PCD8544&quot; rel=&quot;nofollow&quot;&gt;Philips PCD8544 (Nokia 3310) driver&lt;/a&gt; should make it easy to adjust this until things work well.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastActivityDate="2016-01-05T04:19:09.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19250" PostTypeId="1" AcceptedAnswerId="19266" CreationDate="2016-01-05T07:55:49.113" Score="3" ViewCount="388" Body="&lt;p&gt;I wanted to use a piezo sounder to sound an alarm in an application. Testing indicated that &lt;code&gt;tone()&lt;/code&gt; was not very loud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use some external circuitry to swing the pins ±5V but as I have plenty of spare pins, it seemed feasible to use 2 pins driven in anti-phase to increase the power by 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked at the source &lt;code&gt;Tone.cpp&lt;/code&gt; but the code is somewhat intimidating. Before I start to modify it I was wondering if anyone else has already done something like this.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-01-05T22:00:50.833" Title="Push-Pull tone code" Tags="|sound|piezo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19251" PostTypeId="1" AcceptedAnswerId="19252" CreationDate="2016-01-05T09:33:07.927" Score="2" ViewCount="1791" Body="&lt;p&gt;So, I got an arduino uno and a &lt;a href=&quot;https://www.reichelt.de/Erweiterungsboards/ARDUINO-SHD-RGB/3/index.html?ACTION=3&amp;amp;GROUPID=6669&amp;amp;ARTICLE=148933&amp;amp;OFFSET=16&amp;amp;&quot; rel=&quot;nofollow&quot;&gt;RGB shield from velleman&lt;/a&gt; for christmas because I mentioned I might want to do a project with high power LEDs - a neat surprise, but now I have to use it (: &#xA;The shield can do PWM on an external power supply and this can be wired through to the high power LEDs itself. I aim to power about 10W of LED light in total, with different colors in order to make good use of the board. Can I go for Option 1? If not, what would you advise? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As &lt;a href=&quot;http://www.ebay.com/itm/1W-3W-High-Power-cool-warm-white-3000k-4000k-10000k-30000k-LED-20mm-star-pcb-/321471559197?var=&amp;amp;hash=item4ad932b61d:m:m9FF_32EUKYGAQ_1yJ7jQFA&quot; rel=&quot;nofollow&quot; title=&quot;for example...&quot;&gt;high power LEDs&lt;/a&gt; need a constant current, I am inclined to connect a &lt;a href=&quot;http://www.ebay.com/itm/High-Power-350mA-10W-LED-Driver-Board-DC-Boost-5-32V-Wide-Input/161047962520?_trksid=p2047675.c100005.m1851&amp;amp;_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20131003132420%26meid%3D095402a042fa472d9944387cbdd4ee36%26pid%3D100005%26rk%3D3%26rkt%3D6%26sd%3D141700678280&quot; rel=&quot;nofollow&quot; title=&quot;for example&quot;&gt;constant current supply&lt;/a&gt; as the external supply of the board (assuming all channels' LEDs need the same current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;: I talked to an electrician and a constant current supply typically works on a PWM basis; putting this in series with the PWM of the shield is not smart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively I could connect a standard constant voltage supply and make sure that the current is within limits: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One option would be to use &lt;em&gt;resistors&lt;/em&gt;; but, with 12V DC and 350mA I would need like 33 Ohm resistance dissipating 4 Watts of power, which is inefficient. &lt;/li&gt;&#xA;&lt;li&gt;Alternatively there are &lt;a href=&quot;http://www.ebay.com/itm/350-MA-Constant-current-LED-driver-with-PWM-control-up-to-10-off-1W-led-/311494471358?hash=item4886846ebe:g:E6EAAOSwwE5WWP1A&quot; rel=&quot;nofollow&quot; title=&quot;for example&quot;&gt;DC voltage to constant current LED drivers&lt;/a&gt; which will take care of the constant current for me; I could put those at the exits of the shield for the LEDs. They supposedly have a better conversion efficiency than the resistors, but I do have any knowledge about their performance with PWM as input; but I have serious doubts they would like that type of input. Furthermore, these drivers also often have PWM capabilities. This kind of module would render the shield functionality largely useless. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16105" LastEditorUserId="16105" LastEditDate="2016-01-05T15:01:06.993" LastActivityDate="2016-01-05T15:01:06.993" Title="constant current or constant voltage power supply to use with RGB shield with high power LEDs" Tags="|arduino-uno|power|led|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19252" PostTypeId="2" ParentId="19251" CreationDate="2016-01-05T12:24:09.813" Score="1" Body="&lt;p&gt;Your thinking and reasoning is pretty much spot on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board you have is basically a trio of high current low side switches. So yes, you need &lt;em&gt;something&lt;/em&gt; to limit the current, and as you have noted resistors are not going to be very efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way to drive high power LEDs is, as you know, with constant current. However, you need a constant current source &lt;em&gt;per LED channel&lt;/em&gt;, not one single one for the whole board. That means three individual constant current sources, each providing the right current for the LEDs you are driving on that channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible to roll your own cheap constant current sources using LM317T linear voltage regulators (&lt;a href=&quot;http://diyaudioprojects.com/Technical/Current-Regulator/&quot; rel=&quot;nofollow&quot;&gt;http://diyaudioprojects.com/Technical/Current-Regulator/&lt;/a&gt;). It's a cheap option, though pretty much as in-efficient as using resistors, just easier to deal with the heat sinking.  Note that on the LM317T the tab is live, so you must use three separate heat sinks for each channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My personal preference though is to use PWM capable constant current sinks. My favourite is the &lt;a href=&quot;http://www.onsemi.com/PowerSolutions/product.do?id=CAT4101&quot; rel=&quot;nofollow&quot;&gt;CAT4101&lt;/a&gt; which can deal with up to 1A per channel (more if you parallel them) and uses a single resistor to set the current. It has a PWM input that you can drive direct from an Arduino's PWM pin. Of course, as you note, that then makes your nice shield redundant. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-05T12:24:09.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19253" PostTypeId="1" CreationDate="2016-01-05T13:45:58.390" Score="0" ViewCount="4320" Body="&lt;p&gt;I'm trying to make AC current (50Hz) with an Arduino Uno. It seems to be not working (or wrong code).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int up;&#xA;int down;&#xA;int out = 11;&#xA;void setup() {&#xA;  pinMode(out, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (up = 0; up &amp;lt;= 255; up++) {&#xA;    analogWrite(out, up);&#xA;    delay(1);&#xA;  }&#xA;  for (down = 255; down &amp;gt;= 0; down--) {&#xA;    analogWrite(out, down);&#xA;    delay(1);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Now the code above is giving output voltage of 0-5V (getting increased from 0 to 5 and then decreased) not giving a negative cycle (-5V).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After setting the minimum delay of 1, the output wave is still half wave rectifier with frequency 2Hz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Without delay LED is blinking so fast I don't know what's its frequency.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How do I make make 50Hz AC current a with negative cycle?&lt;/p&gt;&#xA;" OwnerUserId="15187" LastEditorUserId="4628" LastEditDate="2017-12-28T12:24:03.217" LastActivityDate="2020-09-23T03:20:09.097" Title="Making AC current with pin 11" Tags="|arduino-uno|analogwrite|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19256" PostTypeId="2" ParentId="19178" CreationDate="2016-01-05T15:24:57.610" Score="1" Body="&lt;p&gt;You can use the &lt;code&gt;millis()&lt;/code&gt; function to see how much time has passed and use this to create your waveform while still being able to perform other tasks. You will check in which part of the wave you are in each iteration of &lt;code&gt;loop()&lt;/code&gt; and adjust your outputs accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long vhtime;&#xA;uint8_t vhpin = 9;   // the VH output pin&#xA;uint8_t vcpin = 10;  // the VC output pin&#xA;&#xA;long period = 250;   // the period of your pwm signal in ms&#xA;long vhduty = 14;    // amount of ms vh should be high&#xA;long vcdelay = 2;    // amount of ms we wait for vc to go high after vh has gone high&#xA;long vcduty = 5;     // amount of ms vc should be high&#xA;&#xA;long curtime;        // this will hold our current position in one period of the waveform&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(vhpin, OUT);&#xA;  pinMode(vcpin, OUT);&#xA;  digitalWrite(vcpin, LOW);&#xA;  digitalWrite(vhpin, HIGH);&#xA;  vhtime = millis();&#xA;}&#xA;&#xA;void loop() {&#xA;  curtime = millis() - vhtime;&#xA;  if (curtime &amp;gt; vhduty)        // we are in the last 236ms of the wave, vh should be low&#xA;    digitalWrite(vhpin, LOW);&#xA;  else                         // we are in the first 14ms of the wave, vh should be high&#xA;    digitalWrite(vhpin, HIGH);&#xA;  if (curtime &amp;gt; vcdelay &amp;amp;&amp;amp; curtime &amp;lt; vcduty + vcdelay) // vc should be high during this time&#xA;    digitalWrite(vcpin, HIGH);&#xA;  else&#xA;    digitalWrite(vcpin, LOW);&#xA;  if (curtime &amp;gt; period) {&#xA;    // we should start a new period&#xA;    digitalWrite(vhpin, HIGH);&#xA;    vhtime = millis();&#xA;  }&#xA;  // do your other calculations here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16117" LastActivityDate="2016-01-05T15:24:57.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19258" PostTypeId="2" ParentId="19248" CreationDate="2016-01-05T16:13:57.107" Score="0" Body="&lt;p&gt;Assuming you got your code from this site: &lt;a href=&quot;https://brainy-bits.com/tutorials/how-to-use-the-nokia-5110/&quot; rel=&quot;nofollow&quot;&gt;https://brainy-bits.com/tutorials/how-to-use-the-nokia-5110/&lt;/a&gt;, it seems you edited the code from there to display only the bitmap, but you didn't get rid of everything. You have no DHT temperature sensors, so get rid of all DHT references in your code, including the 5 seconds delay at the bottom of &lt;code&gt;loop()&lt;/code&gt;. If you intend to use the code from that site, then use it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void draw(void) {&#xA;  u8g.drawBitmapP( 37, 0, 6, 50, brainy_bitmap);  // put bitmap&#xA;}&#xA;&#xA;void setup(void) {&#xA;  analogWrite(backlight_pin, 50);  /* Set the Backlight intensity */&#xA;}&#xA;&#xA;void loop(void) {&#xA;  u8g.firstPage();  &#xA;  do {&#xA;    draw();&#xA;  } while( u8g.nextPage() );&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure to get rid of the #define, #include and constructor referring to DHT.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-05T16:13:57.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19259" PostTypeId="1" CreationDate="2016-01-05T17:31:17.667" Score="0" ViewCount="149" Body="&lt;p&gt;I am following the tutorial &lt;a href=&quot;https://www.openhomeautomation.net/tiny-wifi-temperature-arduino/&quot; rel=&quot;nofollow&quot;&gt;Tiny WiFi Temperature Sensor with Arduino&lt;/a&gt;. everthing works fine, but I have a little problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the serial monitor is opened the sensor is reading fine like 23.20, 20.25 etc.,  but when I closed the serial monitor window I got wrong values, for example, 289.34, 289.90. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does the serial monitor do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am stuck with this problem for last two days. Please give me a hand. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The baud rate is as you can see 115200 and i have changed it various time but it doesn't do anything.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I haven't test commenting out the Serial.println() lines&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The values i can see at my server (see the function send_request).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The problem is when i am testing the program opening the serial monitor windows everything works fine for example: 29.20, 30.12, 28.12 but when i close the windows i start getting wrong values for exmaple: 289.45, 289.89 , etc... .&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Here is my code.&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;Adafruit_CC3000_Server.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;&#xA;/*&#xA;   Tiny WiFi temperature sensor with Arduino, the TMP36 sensor &amp;amp; the CC3000 chip&#xA;   Writtent by Marco Schwartz for Open Home Automation&#xA;*/&#xA;&#xA;// Include required libraries&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;#include&amp;lt;stdlib.h&amp;gt;&#xA;&#xA;// Define CC3000 chip pins&#xA;#define ADAFRUIT_CC3000_IRQ   2&#xA;#define ADAFRUIT_CC3000_VBAT  A3&#xA;#define ADAFRUIT_CC3000_CS    8&#xA;&#xA;// WiFi network (change with your settings !)&#xA;#define WLAN_SSID       &quot;ssid&quot;        // cannot be longer than 32 characters!&#xA;#define WLAN_PASS       &quot;password&quot;&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;&#xA;// Create CC3000 instance&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                         SPI_CLOCK_DIV2);&#xA;&#xA;// Local server IP, port, and repository (change with your settings !)&#xA;uint32_t ip = cc3000.IP2U32(10,0,129,108);&#xA;int port = 8080;&#xA;String repository = &quot;/tiny-wifi-temperature/&quot;;&#xA;&#xA;void setup(void)&#xA;{&#xA;&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Start setup&quot;);&#xA;&#xA;&#xA;&#xA;  // Initialise the CC3000 module&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(&quot;Impossible to start&quot;);&#xA;    while (1);&#xA;  }&#xA;&#xA;&#xA;  Serial.println(F(&quot;\nDeleting old connection profiles&quot;));&#xA;  if (!cc3000.deleteProfiles()) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  listSSIDResults();&#xA;  connectNetwork();&#xA;  displayConnectionDetails();&#xA;  /*&#xA;  while(!displayConnectionDetails())&#xA;  {&#xA;    connectNetwork(); &#xA;  }*/&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void connectNetwork(void)&#xA;{&#xA;  Serial.println(F(&quot;Trying to connect wifi &quot;)); Serial.println(WLAN_SSID) ; &#xA;&#xA;  /*&#xA;  uint32_t ipAddress = cc3000.IP2U32(10, 0, 130, 200);&#xA;  uint32_t netMask = cc3000.IP2U32(255, 255, 0, 0);&#xA;  uint32_t defaultGateway = cc3000.IP2U32(10, 0, 1, 1);&#xA;  uint32_t dns = cc3000.IP2U32(10, 0, 1, 1);&#xA;  if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {&#xA;    Serial.println(F(&quot;Failed to set static IP!&quot;));&#xA;    while(1);&#xA;  }&#xA;  */&#xA;&#xA;  /*&#xA;  if (!cc3000.setDHCP()) {&#xA;    Serial.println(F(&quot;Failed to set DHCP!&quot;));&#xA;    while(1);&#xA;  }*/&#xA;&#xA;  // Connect to  WiFi network&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;  Serial.println(&quot;Connected to WiFi network!&quot;);&#xA;&#xA;&#xA;&#xA;&#xA;  // Check DHCP&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100);&#xA;  } &#xA;&#xA;}&#xA;&#xA;&#xA;void loop(void)&#xA;{&#xA;&#xA;  // Measure the temperature&#xA;  int sensorValue = analogRead(A4);&#xA;  float milliVoltsValue = sensorValue * 5000. / 1024.;&#xA;  float temperature = (milliVoltsValue - 500.) / 10.;&#xA;&#xA;  // Print the result&#xA;  Serial.println(temperature);&#xA;&#xA;  // Transform to string&#xA;  char temp[5];&#xA;  dtostrf(temperature, 5, 2, temp);&#xA;&#xA;  // Send request&#xA;  String request = &quot;GET &quot; + repository + &quot;sensor.php?temp=&quot; + String(temp) + &quot; HTTP/1.0&quot;;&#xA;  send_request(request);&#xA;&#xA;  // Update every second&#xA;  delay(1000);&#xA;}&#xA;&#xA;// Function to send a TCP request and get the result as a string&#xA;void send_request (String request) {&#xA;&#xA;  // Connect&#xA;  Serial.println(&quot;Starting connection to server...&quot;);&#xA;  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);&#xA;&#xA;  // Send request&#xA;  if (client.connected()) {&#xA;    client.println(request);&#xA;    client.println(F(&quot;&quot;));&#xA;    Serial.println(&quot;Connected &amp;amp; Data sent&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.println(F(&quot;Connection failed&quot;));&#xA;  }&#xA;&#xA;  while (client.connected()) {&#xA;    while (client.available()) {&#xA;&#xA;      // Read answer&#xA;      char c = client.read();&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;Closing connection&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;  client.close();&#xA;}&#xA;&#xA;&#xA;&#xA;void listSSIDResults(void)&#xA;{&#xA;  uint32_t index ;&#xA;  uint8_t valid , rssi, sec ;&#xA;  char ssidname[33];&#xA;&#xA;&#xA;&#xA;  if (!cc3000.startSSIDscan(&amp;amp;index)) {&#xA;    Serial.println(F(&quot;SSID scan failed!&quot;));&#xA;    return;&#xA;  }&#xA;&#xA;&#xA;  Serial.print(F(&quot;Networks found: &quot;)); Serial.println(index);&#xA;  Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;  while (index) {&#xA;    index--;&#xA;&#xA;    valid = cc3000.getNextSSID(&amp;amp;rssi, &amp;amp;sec, ssidname);&#xA;&#xA;    Serial.print(F(&quot;SSID Name    : &quot;)); Serial.print(ssidname);&#xA;    Serial.println();&#xA;    Serial.print(F(&quot;RSSI         : &quot;));&#xA;    Serial.println(rssi);&#xA;    Serial.print(F(&quot;Security Mode: &quot;));&#xA;    Serial.println(sec);&#xA;    Serial.println();&#xA;  }&#xA;  Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;  cc3000.stopSSIDscan();&#xA;}&#xA;&#xA;&#xA;bool displayConnectionDetails(void)&#xA;{&#xA;  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;  if (!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv, &amp;amp;dnsserv))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;    return false;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;    Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;    Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;    Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;    Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;    Serial.println();&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16121" LastEditorUserId="220" LastEditDate="2016-01-14T22:22:16.923" LastActivityDate="2016-01-14T22:22:16.923" Title="Arduino TMP36 sensor" Tags="|temperature-sensor|arduino-mini|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19260" PostTypeId="2" ParentId="19259" CreationDate="2016-01-05T18:10:12.973" Score="2" Body="&lt;p&gt;The serial monitor gives you a way to &quot;talk&quot; relatively directly with the Arduino – in this case it give you a way to easily confirm that the basic circuit is working and that you are getting sensible temperatures. That's a foundation on which you can build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is unlikely – I think – that the serial monitor is causing the problem. But before you believe me, there is one thing you should consider. The serial monitor runs relatively slowly, so outputting the temperature via the serial monitor introduces a delay in your code. That could explain the difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your next step is to trace your bad value. So, first more questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What baud rate are you running the serial monitor at? Does changing the baud rate affect the result? That would point to a timing related issue.&lt;/li&gt;&#xA;&lt;li&gt;Is there any code that writes to the serial monitor (e.g., a call to Serial.println())? If there is what happens when you comment it out?&lt;/li&gt;&#xA;&lt;li&gt;Where are you seeing the two values (the correct and incorrect values)? I assume that both are at the web server, but I want to confirm this.&lt;/li&gt;&#xA;&lt;li&gt;Can you explain more clearly the process to demonstrate the problem? In the tutorial that you link to I don't think that the code pathway is the same to see the value on the serial monitor as it is on the server, so I'm wondering if an error was made as you changed the code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-05T18:10:12.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19261" PostTypeId="2" ParentId="19179" CreationDate="2016-01-05T18:34:13.917" Score="1" Body="&lt;p&gt;Myself, I prefer to use Eagle, and download Sparkfun and Adafruit libraries for components based around Arduino. There you can create schematics, and create PCB layouts too.&lt;/p&gt;&#xA;" OwnerUserId="16123" LastEditorUserId="6936" LastEditDate="2016-01-06T15:15:44.327" LastActivityDate="2016-01-06T15:15:44.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19262" PostTypeId="1" CreationDate="2016-01-05T18:52:52.067" Score="0" ViewCount="655" Body="&lt;p&gt;Is this an issue or a defined behavior? I am using Arduino IDE 1.6.6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes I made changes in code, and immediately upload them to the Arduino board. And many times issues already fixed are persisting, leaving me that feeling of &quot;the uploaded code has not the changes I have just made&quot;. Then I save my sketch, compile and upload again and the issue vanishes. As long as the issue get someway fixed, I tend to forgot about it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As software engineer, most of the times I assume the code I am compiling and uploading / publishing to any platform is always the latest, not the latest saved. I believe this is not the behavior of the Arduino IDE. It uploads the last saved version of code, not the last modified.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In summary: I believe the Arduino IDE uploads to the board the last saved version of the sketch, not the current one being modified.&lt;/strong&gt; Can anyone confirm this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="14766" LastEditorUserId="19409" LastEditDate="2016-10-15T20:41:03.097" LastActivityDate="2016-10-15T20:41:03.097" Title="Arduino compiler uploading last saved version of sketch, not current" Tags="|sketch|uploading|ide|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19263" PostTypeId="2" ParentId="19210" CreationDate="2016-01-05T21:26:07.377" Score="3" Body="&lt;p&gt;How a PID controller works depends on the particular implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a algorithm/library for PID on the Arduino: &lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/Code/PIDLibrary&lt;/a&gt; and an excellent explanation of the all of functions within it at &lt;a href=&quot;http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over on stackoverflow and electronics, there are some good questions and explanations that might help:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/190606/understanding-a-pid-controller&quot;&gt;https://electronics.stackexchange.com/questions/190606/understanding-a-pid-controller&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/14614124/how-do-i-use-a-pid-controller?rq=1&quot;&gt;https://stackoverflow.com/questions/14614124/how-do-i-use-a-pid-controller?rq=1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/21516143/pid-control-value-of-process-parameter-based-on-pid-result?rq=1&quot;&gt;https://stackoverflow.com/questions/21516143/pid-control-value-of-process-parameter-based-on-pid-result?rq=1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/13542447/i-dont-understand-integral-part-of-pid-controller?rq=1&quot;&gt;https://stackoverflow.com/questions/13542447/i-dont-understand-integral-part-of-pid-controller?rq=1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/21534996/pid-controller-intuition-for-when-error-0?rq=1&quot;&gt;https://stackoverflow.com/questions/21534996/pid-controller-intuition-for-when-error-0?rq=1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-01-05T21:26:07.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19264" PostTypeId="2" ParentId="19262" CreationDate="2016-01-05T21:28:17.013" Score="2" Body="&lt;p&gt;I haven't tried it but it would be an easy experiment to make on some throw-away code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, do note that saving before compiling or uploading is &lt;em&gt;optional&lt;/em&gt; in the Arduino IDE. That may very well be the key to what you observed. I keep mine enabled, i.e., to save before any compile or upload. The option is in the Preferences dialog accessed from the menus, not in the manually-edited &lt;code&gt;preferences.txt&lt;/code&gt; file. That might be the key to what you observed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;In that case, including the pre-defined macros &lt;code&gt;__DATE__&lt;/code&gt; and &lt;code&gt;__TIME__&lt;/code&gt; (of the pre-processor run) and &lt;code&gt;__TIMESTAMP__&lt;/code&gt; (of the file's last modification) in a &quot;Hello&quot; string can help debug this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These pages list the &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros&quot; rel=&quot;nofollow&quot;&gt;standard&lt;/a&gt;, and &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros&quot; rel=&quot;nofollow&quot;&gt;common&lt;/a&gt; predefined macros implemented in gcc's pre-processor.&#xA;Note also that most version control systems offer similar macros that get replaced at checkout to embed a revision number and other version-control information.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-01-05T21:59:04.277" LastActivityDate="2016-01-05T21:59:04.277" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19265" PostTypeId="1" CreationDate="2016-01-05T21:44:44.597" Score="0" ViewCount="497" Body="&lt;p&gt;I have bought a new 'SunFounder Arduino uno R3' and started learning, the first lesson was 'Blinking LED' of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done it all, connected Jumper-Wires and the Sensor and the LED light, I wrote the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin = 9;&#xA;void setup()&#xA;{&#xA;   pinMode(ledPin,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;   digitalWrite(ledPin,HIGH);&#xA;   delay(500);               &#xA;   digitalWrite(ledPin,LOW); &#xA;   delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BUT NOTHING HAPPENS !!!, I checked out every thing over and over, it just does not work ???&#xA;Every thing is well about the board and the UNO R3 it is new.&#xA;I have checked the code and the connections and checked the Device Manager to know that the serial port of the arduino is 'COM3'...&#xA;I dont know what is wrong with it ?!!&lt;/p&gt;&#xA;" OwnerUserId="16129" LastActivityDate="2016-01-08T16:47:42.513" Title="Nothing is working even though every thing is right &amp; it is new?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19266" PostTypeId="2" ParentId="19250" CreationDate="2016-01-05T22:00:50.833" Score="3" Body="&lt;p&gt;Yes, Tim Eckel has already published a library &quot;toneAC&quot; on the Arduino website at &lt;a href=&quot;http://playground.arduino.cc/Code/ToneAC&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/ToneAC&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the syntax is there too.&lt;/p&gt;&#xA;" OwnerUserId="11606" LastActivityDate="2016-01-05T22:00:50.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19267" PostTypeId="2" ParentId="19210" CreationDate="2016-01-05T22:16:48.777" Score="3" Body="&lt;p&gt;I, also, didn't get the idea behind PID from just reading Wikipedia. After some videos/tutorials, I believe the best way to explain it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is PID&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PID is an algorithm. It involves three factors which can be adjusted to tune a signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is often used in servo's (and things like thermostates, basic signal controllers)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Imagine this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo will be used in the practical examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A servo has:&#xA;- a current position (signal)&#xA;- the position you want the servo to be in (goal signal)&#xA;- a speed (PID output signal)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PID output signal/algorithm makes sure that the servo reaches it's goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In short:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PID is an algorithm that can adjust a signal towards an setpoint. Or correct it for that matter.&#xA;It regulates how much you have to adjust the signal, without getting serious overshoot, or oscillation around the setpoint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Detail:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P stands for proportional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means that the further the servo is from it's setpoint, the more speed we want to/can give it. So that we're faster towards the set point.&#xA;This also means that we slow down as we near the set point.&#xA;Of course you can multiply each of these rules with a factor, to achieve a better balance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I stands for integrating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It basically comes down to the fact that it constantly keeps adding to the signal, depending on how long there is a difference between the current point and set point. This is so that if P is still a little slow, it adds some speed over time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D stands for differentiating&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's less commonly used. (Wikipedia)&#xA;The D factor reacts on the speed of the change in value. Or speed of change in setpoint (Dutch wikipedia is not 100%, comment if neccesary :) )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These factors / the algorithm provides a smooth regulation of various systems, hence that's why it is so adjustable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be used for balancing quadcopters or making your house comfortably warm (without sudden changes, or too slow changes)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you balance a quadcopter?&#xA;If it shifts to one side, you don't want to fully reverse the throttle.&#xA;It'll make it wobble, since you get a lot of overshoot.&#xA;Controlling things can be hard, PID is an known working algorithm for those cases. But you have to adjust the factors right to adjust it to your specific system. (They all react differently, or have to react differently).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="10907" LastEditDate="2016-01-06T11:32:13.917" LastActivityDate="2016-01-06T11:32:13.917" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19269" PostTypeId="1" CreationDate="2016-01-05T23:10:21.153" Score="2" ViewCount="417" Body="&lt;p&gt;I've been given a digispark and am looking to write straight assembly code for it. Anyone know how to get started with this? I've been successful in getting the Arduino IDE set-up but would really like to avoid writing assembly in-line... &lt;/p&gt;&#xA;" OwnerUserId="16131" LastActivityDate="2021-07-21T15:47:33.357" Title="Programing in Assembly for the Digispark" Tags="|assembly|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19270" PostTypeId="1" CreationDate="2016-01-05T23:30:24.850" Score="0" ViewCount="401" Body="&lt;p&gt;I' m trying to change 1 to 0 in two-dimensional (5x5 matrix) for specific servo positions.First, i tried to program forward movement of my robot.  My code is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#define x 5&#xA;#define y 5&#xA;&#xA;Servo myServo;&#xA;Servo myServo2;&#xA;&#xA;int pos = 0;&#xA;&#xA;int counter1;&#xA;int counter2;&#xA;int integer;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  myServo.attach(9);&#xA;  myServo2.attach(10);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int my2dArray[x][y]= {&#xA;  {1,1,1,1,1},&#xA;  {1,1,1,1,1},&#xA;  {1,1,0,1,1},&#xA;  {1,1,1,1,1},&#xA;  {1,1,1,1,1},&#xA;  };&#xA;&#xA;  int robot = my2dArray[2][2];&#xA;&#xA;   if (counter1 &amp;gt; 0){&#xA;     for (integer = 0;  integer &amp;lt;2; integer +=1){&#xA;      int my2dArray[2 + integer][2] = robot * my2dArray[2 + integer][2];&#xA;&#xA;     }&#xA; }&#xA;}&#xA;&#xA;&#xA;  int moveForward(){&#xA;  for (pos = 0; pos &amp;lt;= 360; pos += 1) {&#xA;    myServo.write(pos);&#xA;    myServo2.write(pos);   &#xA;    delay(15);&#xA;    if (pos == 360){&#xA;    counter1 += 1;&#xA;    }&#xA;    return counter1; &#xA;}&#xA;}&#xA;&#xA;int moveBackward(){&#xA;  for (pos = 360; pos &amp;lt;=0; pos -= 1) {&#xA;    myServo.write(pos);&#xA;    myServo2.write(pos);   &#xA;    delay(15);&#xA;    if (pos == 360){&#xA;    counter2 += 1;&#xA;    }&#xA;    return counter2; &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i can' t change the [3][2] and [4][2] elements from 1 to 0. I get an error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; error: variable-sized object 'my2dArray' may not be initialized&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you help me?&#xA;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="16134" LastEditorUserId="4131" LastEditDate="2016-01-08T16:38:44.797" LastActivityDate="2016-02-07T17:23:52.540" Title="Arduino raise the error &quot;variable-sized object 'my2dArray' may not be initialized&quot; while trying to change the elements of 2d array" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19271" PostTypeId="2" ParentId="19270" CreationDate="2016-01-05T23:33:57.043" Score="1" Body="&lt;p&gt;The error is in this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int my2dArray[2 + integer][2] = robot * my2dArray[2 + integer][2];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The presence of the word &lt;code&gt;int&lt;/code&gt; there tells it to try and make a new variable. You don't want to do that, since it's an error.  Lose the &lt;code&gt;int&lt;/code&gt; and it might work.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-05T23:33:57.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19272" PostTypeId="1" CreationDate="2016-01-06T01:38:19.613" Score="5" ViewCount="311" Body="&lt;p&gt;I am new to Arduino and I am learning how to avoid using delay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written some code to move my servo by 20° using delays, but can only move the servo once with my current code. In &lt;code&gt;setup()&lt;/code&gt;, I assign the servo 150. The next value the servo receives is 15, which it performs. It does not iterate through the following values though. I have been using this guide, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;BlinkWithoutDelay&lt;/a&gt;, with no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo;&#xA;unsigned long previousMillis = 0; &#xA;const long interval = 1000; &#xA;&#xA;    void setup() { &#xA;       myservo.attach(9);&#xA;       myservo.write(150); &#xA;    }&#xA;&#xA;   void loop() {&#xA;       unsigned long currentMillis = millis();&#xA;&#xA;       if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;            previousMillis = currentMillis;&#xA;            myservo.write(15);&#xA;       }&#xA;       if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;            previousMillis = currentMillis;&#xA;            myservo.write(35);&#xA;       }&#xA;       if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;            previousMillis = currentMillis;&#xA;            myservo.write(65);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16136" LastEditorUserId="6936" LastEditDate="2016-01-08T16:38:41.163" LastActivityDate="2016-01-08T16:38:41.163" Title="Trouble when avoiding delays" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19273" PostTypeId="2" ParentId="19272" CreationDate="2016-01-06T01:56:13.233" Score="7" Body="&lt;p&gt;You are resetting the timer on the first phase [&lt;code&gt;write(15)&lt;/code&gt;] instead of &lt;em&gt;after&lt;/em&gt; the last phase [after &lt;code&gt;write(65)&lt;/code&gt;]! The &lt;code&gt;previousMillis = currentMillis&lt;/code&gt; should be only after the last phase, before the loop repeats. Not only that, but the time at which each phase executes needs to be different. Currently every &lt;code&gt;if()&lt;/code&gt; statement is set to run after &lt;em&gt;interval&lt;/em&gt; has elapsed. If, for example, you wanted &lt;em&gt;interval&lt;/em&gt; to be the delay between each phase, you could use &lt;em&gt;interval*1&lt;/em&gt; on the first phase, &lt;em&gt;interval*2&lt;/em&gt; on the second, and &lt;em&gt;interval*3&lt;/em&gt; on the third. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (currentMillis - previousMillis &amp;lt;= interval * 1) {&#xA;        // Runs from interval*0 to interval*1;&#xA;        myservo.write(15);&#xA;   }&#xA;   else if (currentMillis - previousMillis &amp;lt;= interval * 2) {&#xA;        // Runs from interval*1 to interval*2;&#xA;        myservo.write(35);&#xA;   }&#xA;   else if (currentMillis - previousMillis &amp;lt;= interval * 3) {&#xA;        // Runs from interval*2 to interval*3;&#xA;        myservo.write(65);&#xA;   }&#xA;   else {&#xA;        // Runs once after interval*3;&#xA;        // *or* runs on first iteration when previousMillis is zero;&#xA;        previousMillis = currentMillis;// Reset the loop;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To put the above logic in English: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;write(15)&lt;/code&gt; while time is between 0 and 1 intervals; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;write(35)&lt;/code&gt; while time is between 1 and 2 intervals; &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;write(65)&lt;/code&gt; while time is between 2 and 3 intervals; &lt;/li&gt;&#xA;&lt;li&gt;reset the loop once time reaches 3+ intervals. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note the use of &lt;code&gt;else if&lt;/code&gt; instead of simply &lt;code&gt;if&lt;/code&gt; on consecutive statements. This prevents more than one code block from running on the same iteration of the &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I highly recommend having a small delay (like 1ms) somewhere in the &lt;code&gt;loop()&lt;/code&gt;, such as at the end. It would be a bad idea to constantly run the &lt;code&gt;write()&lt;/code&gt; function when the value is the same as on the last call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, if your starting value is indeed 150 and the loop should start only after interval*1, you may want to iterate from interval*2 through interval*4:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (currentMillis - previousMillis &amp;lt;= interval * 1) {&#xA;        // Runs from interval*0 to interval*1;&#xA;        // Do nothing; servo is set to either 150 or 65 during this time;&#xA;   }&#xA;   else if (currentMillis - previousMillis &amp;lt;= interval * 2) {&#xA;        // Runs from interval*1 to interval*2;&#xA;        myservo.write(15);&#xA;   }&#xA;   else if (currentMillis - previousMillis &amp;lt;= interval * 3) {&#xA;        // Runs from interval*2 to interval*3;&#xA;        myservo.write(35);&#xA;   }&#xA;   else if (currentMillis - previousMillis &amp;lt;= interval * 4) {&#xA;        // Runs from interval*3 to interval*4;&#xA;        myservo.write(65);&#xA;   }&#xA;   else {&#xA;        // Runs once after interval*4;&#xA;        // *or* runs on first iteration when previousMillis is zero;&#xA;        previousMillis = currentMillis;// Reset the loop;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15303" LastEditorUserId="6936" LastEditDate="2016-01-06T08:52:31.437" LastActivityDate="2016-01-06T08:52:31.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19274" PostTypeId="2" ParentId="19269" CreationDate="2016-01-06T06:50:12.973" Score="1" Body="&lt;p&gt;There seems to be some specific attiny flag required but by the gcc in order to make the genereated hex file work with digispark. Take a look here &lt;a href=&quot;https://github.com/pda/digispark-asm&quot; rel=&quot;nofollow&quot;&gt;https://github.com/pda/digispark-asm&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15519" LastActivityDate="2016-01-06T06:50:12.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19275" PostTypeId="2" ParentId="19272" CreationDate="2016-01-06T07:25:53.237" Score="1" Body="&lt;p&gt;If you want to change the servo every second, try to use a conditional expression in the timing structure. If you want to use more parallel structure with multiple intervals use different counters (example see: &lt;a href=&quot;https://stackoverflow.com/questions/32037217/how-can-i-replace-delay-by-millis/32043899#32043899&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of the every second version:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo;&#xA;unsigned long previousMillis = 0; &#xA;const long interval = 1000; &#xA;int angle = 150; &#xA;&#xA;void setup() { &#xA;   myservo.attach(9);&#xA;   myservo.write(angle); &#xA;}&#xA;&#xA;void loop() {&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;        previousMillis = currentMillis;&#xA;&#xA;        switch (angle) {&#xA;            case 150:&#xA;            case 65:&#xA;              angle = 15;&#xA;              myservo.write(angle);&#xA;              break;&#xA;            case 15:&#xA;              angle = 35;   &#xA;              myservo.write(angle);&#xA;              break;&#xA;            case 35: &#xA;              angle = 65;     &#xA;              myservo.write(angle);&#xA;              break;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Add variable assignment &lt;code&gt;angle&lt;/code&gt; in conditional expression.&lt;/p&gt;&#xA;" OwnerUserId="4131" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-01-06T12:27:41.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19276" PostTypeId="1" AcceptedAnswerId="19278" CreationDate="2016-01-06T11:29:38.353" Score="0" ViewCount="957" Body="&lt;p&gt;I was wondering if there are a way to do a menu system for arduino UNO using buttons and without libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to do it by myself but the code was too long and heavy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want full code, just a pseudo-code idea and how does it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there are libraries that to this, but I want to practise C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15855" LastActivityDate="2016-01-06T12:03:48.173" Title="Menu system without libraries" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19277" PostTypeId="2" ParentId="18425" CreationDate="2016-01-06T11:34:11.393" Score="1" Body="&lt;p&gt;I had the same problem. I forgot to complete the &lt;code&gt;client.println&lt;/code&gt; with a newline (&lt;code&gt;\n&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="16142" LastEditorUserId="6936" LastEditDate="2016-01-08T16:38:24.567" LastActivityDate="2016-01-08T16:38:24.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19278" PostTypeId="2" ParentId="19276" CreationDate="2016-01-06T12:03:48.173" Score="1" Body="&lt;p&gt;Interactive menus are certainly not a &quot;simple&quot; task. That is why people use libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever you try you will end up with complex code - either long winded with lots of duplication, or somewhat cryptic with lots of pointers, arrays, and structures. Not an easy task for a beginner in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I would set about it would involve the following things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A structure that defines a menu entry, including pointers to one of: sub-menu array, numeric variable (including max/min limits), option array, function to execute.&lt;/li&gt;&#xA;&lt;li&gt;Arrays of the above structure to define each menu&lt;/li&gt;&#xA;&lt;li&gt;Array or linked list of &quot;breadcrumbs&quot; through the menu to track where you are and go back up properly&lt;/li&gt;&#xA;&lt;li&gt;Functions to display and navigate the menu arrays on an LCD.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All of that uses fairly advanced C coding techniques, especially when it comes to managing all the pointers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;simpler&quot;, though more long winded way, would be to write individual functions for each menu and sub-menu, but that would make your program incredibly long and prone to have errors when duplicating (copy/paste) code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-06T12:03:48.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19279" PostTypeId="1" CreationDate="2016-01-06T12:26:55.817" Score="1" ViewCount="4723" Body="&lt;p&gt;I need to use a Bluetooth module with an Arduino Micro/Mini. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest which one would be the best, HC 05/06, or any other?&lt;/p&gt;&#xA;" OwnerUserId="16143" LastEditorUserId="6936" LastEditDate="2016-01-08T16:39:17.607" LastActivityDate="2016-01-08T16:39:17.607" Title="Which Bluetooth Module can I use with Arduino Micro/Mini?" Tags="|bluetooth|arduino-micro|arduino-mini|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19281" PostTypeId="2" ParentId="18383" CreationDate="2016-01-06T14:00:42.177" Score="0" Body="&lt;p&gt;If you want to switch it on/off, there is a simple solution using a relay and an optocupler (safer option) or transistor. Here is a &lt;a href=&quot;http://yourduino.com/p/OptoRelayChannelData-575.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematic&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9NFDA.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9NFDA.jpg&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but if you want to control intensity of light, then you have to use triac control, which you have explained here: &lt;a href=&quot;http://playground.arduino.cc/Main/ACPhaseControl&quot; rel=&quot;nofollow noreferrer&quot;&gt;AC Phase Control&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16123" LastEditorUserId="6936" LastEditDate="2016-01-06T18:20:38.473" LastActivityDate="2016-01-06T18:20:38.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19282" PostTypeId="2" ParentId="19279" CreationDate="2016-01-06T15:07:59.827" Score="1" Body="&lt;p&gt;Do you require slaves or masters? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both modules are actually the same, it is just the firmware that is different, and in turn that changes how they use the pins. HC05 can be both Master and Slave, and has a full set of AT commands, whereas HC06 can only be a slave, and has a more limited set of AT commands at its disposal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, for low power projects, then BLE modules, such as HC-10 or HC-11 might be worth considering. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Really, it all depends on what you want to do with them, what is the overall project? You could get away with one HC-05 and one HC-06, but it is really task dependant. It is probably worth you having a read up of some articles on the web, and looking at some example projects to see other people's configurations. This will hopefully help you to see what you actually require for your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FWIW, I looked into this a few months back and wrote a short blog, &lt;a href=&quot;https://gr33nonline.wordpress.com/2015/08/13/blue-moon/&quot; rel=&quot;nofollow&quot;&gt;BlueMoon&lt;/a&gt;, on it, which contains some example projects and links to video tutorials - this may help give you an insight...&lt;/p&gt;&#xA;" OwnerUserId="6936" LastActivityDate="2016-01-06T15:07:59.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19283" PostTypeId="2" ParentId="19279" CreationDate="2016-01-06T15:51:39.610" Score="2" Body="&lt;p&gt;I have had good results using the &lt;a href=&quot;https://www.adafruit.com/products/2479&quot; rel=&quot;nofollow&quot;&gt;Bluefruit LE UART Friend&lt;/a&gt; module from Adafruit with a 32u4 micro Arduino type module, there are only a few pins to connect up to get things going (do remember to follow the instructions to pull the CTS pin to ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per the previous answer it really does depend on what you want to do with it - but this module does Low Energy, can be configured as a &quot;Beacon&quot; and there is a companion App for Android/iOS.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastEditorUserId="6936" LastEditDate="2016-01-06T23:20:29.647" LastActivityDate="2016-01-06T23:20:29.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19284" PostTypeId="2" ParentId="9676" CreationDate="2016-01-06T16:14:37.013" Score="1" Body="&lt;p&gt;You don't need to know the IP address; the &lt;code&gt;getHostByName()&lt;/code&gt; method takes care of resolving the website to an address. It seems 2 lines are missing from your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define WEBPAGE &quot;/index.html&quot;  // change the string to the webpage you want&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the top, and:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   www.fastrprint(WEBPAGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;right after &lt;code&gt;www.fastrprint(F(&quot;GET &quot;));&lt;/code&gt;. Without these lines, you've failed to indicate the specific webpage you wish to GET. Anyways, when i tried to open &lt;code&gt;myapp.herokuapp.com&lt;/code&gt;, I got a message saying that its offline for maintenance, so you'll most likely fail to retrieve anything.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-06T16:14:37.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19285" PostTypeId="1" AcceptedAnswerId="19287" CreationDate="2016-01-06T16:37:17.370" Score="0" ViewCount="929" Body="&lt;p&gt;I was trying to understand the working of micros() function internally and I had a look at the function in Arduino.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long micros() {&#xA;    unsigned long m;&#xA;    uint8_t oldSREG = SREG, t;&#xA;&#xA;    cli();&#xA;    m = timer0_overflow_count;&#xA; #if defined(TCNT0)&#xA;    t = TCNT0;&#xA; #elif defined(TCNT0L)&#xA;    t = TCNT0L;&#xA;#else&#xA;    #error TIMER 0 not defined&#xA;#endif&#xA;&#xA;&#xA;#ifdef TIFR0&#xA;        if ((TIFR0 &amp;amp; _BV(TOV0)) &amp;amp;&amp;amp; (t &amp;amp; 255))&#xA;        m++;&#xA;#else&#xA;        if ((TIFR &amp;amp; _BV(TOV0)) &amp;amp;&amp;amp; (t &amp;amp; 255))&#xA;        m++;&#xA;#endif&#xA;&#xA;    SREG = oldSREG;&#xA;&#xA;    return ((m &amp;lt;&amp;lt; 8) + t) * (64 / clockCyclesPerMicrosecond());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone please explain me what this line is doing :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if ((TIFR0 &amp;amp; _BV(TOV0)) &amp;amp;&amp;amp; (t &amp;amp; 255))&#xA;   m++;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8426" LastActivityDate="2016-01-06T17:21:41.903" Title="Explanation for micros function" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19287" PostTypeId="2" ParentId="19285" CreationDate="2016-01-06T17:17:29.527" Score="5" Body="&lt;p&gt;If the timer 0 has overflowed (&lt;code&gt;TIFR0 &amp;amp; _BV(TOV0)&lt;/code&gt;) and there is at least a count of 1 in the timer count register (&lt;code&gt;t &amp;amp; 255&lt;/code&gt;) then increment the local copy of the overflow count.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That overflow count is used later on to add an upper 8 bits to what is basically an 8 bit counter to turn it into a 16 bit one (&lt;code&gt;(m &amp;lt;&amp;lt; 8) + t&lt;/code&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-06T17:17:29.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19288" PostTypeId="2" ParentId="19285" CreationDate="2016-01-06T17:21:41.903" Score="4" Body="&lt;p&gt;Since at the start of this function interrupts have been disabled by the &lt;code&gt;cli()&lt;/code&gt; function it is possible that the timer &lt;code&gt;TCNT0&lt;/code&gt; has overflowed yet this &lt;em&gt;event&lt;/em&gt; has not been processed and included in the value of &lt;code&gt;timer0_overflow_count&lt;/code&gt; that has been read into &lt;code&gt;m&lt;/code&gt;. Therefore the line that you are asking about is checking for this condition and incrementing the local copy &lt;code&gt;m&lt;/code&gt; if necessary before using it to calculate the number of microseconds since startup.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2016-01-06T17:21:41.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19291" PostTypeId="2" ParentId="3070" CreationDate="2016-01-06T20:39:38.323" Score="1" Body="&lt;p&gt;On ALL mechanical watt-hour meters (those with a rotating disk), the disk will have either one or two holes, typically in the mid section or outer edge of the aluminum disk. Utilities used these holes to pass a light beam through (from the top of the meter to the bottom of the meter) to detect and count disk rotations. A simple light source and photo-transistor can be used to detect the presence of the disk hole to sense disk rotations. &lt;/p&gt;&#xA;" OwnerUserId="16155" LastActivityDate="2016-01-06T20:39:38.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19292" PostTypeId="1" AcceptedAnswerId="19306" CreationDate="2016-01-06T20:57:19.207" Score="-2" ViewCount="4560" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(2, 3, 4, 5, 11, 12);// initialize the library with the numbers of the interface pins&#xA;&#xA;int pirPin = 7; //Variable that will receive the digital signal from the sensor &#xA;int LEDgreen = 6; //LED addressed to the digital pin 6&#xA;int speaker = 8; //speaker addressed to the digital pin 7&#xA;int buttonPin = 9; // the pin that the pushbutton is attached to&#xA;&#xA;void setup(){&#xA;  pinMode(buttonPin, INPUT);// Initialize the button pin as an input:&#xA;  pinMode(pirPin, INPUT);  // declares variable pirPin as an input&#xA;  pinMode(LEDgreen, OUTPUT); // declares variable LEDgreen as an output&#xA;  pinMode(speaker, OUTPUT); // declares variable speaker as an output&#xA;  lcd.begin(16, 2);&#xA;  // turn on the cursor:&#xA;  lcd.cursor();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){ &#xA;  int buttonState = digitalRead(buttonPin);// Read the pushbutton input pin:&#xA;  int pirVal = digitalRead(pirPin); //read the digital value from the pirPin and store the value in the local variable pirVal&#xA;  if(buttonState == LOW){&#xA;    if(digitalRead(pirPin) == LOW){&#xA;      /*The LED Blinks once with the command digitalWrite&#xA;      the LED keeps turned on after blink during the motion cycle*/   &#xA;      digitalWrite(LEDgreen, HIGH); &#xA;      delay(1000);&#xA;      digitalWrite(LEDgreen, LOW);&#xA;      delay(500);&#xA;      digitalWrite(LEDgreen, HIGH); &#xA;      /*speaker plays frequency, the number 7 is the digital pin, &#xA;      the second number is the frequency played and the third number is the sound duration&#xA;      we repeated this command with different frequency and varying the time in order to create a &#xA;      pleasant sound */&#xA;      tone(4,261,300);&#xA;      delay(200);&#xA;      tone(4,329,300);&#xA;      delay(200);&#xA;      tone(4,392,600);&#xA;      delay(200);&#xA;      tone(4,329,300);&#xA;      delay(200);&#xA;      tone(4,392,300);&#xA;      delay(200);&#xA;      tone(4,493,600);&#xA;      delay(200);&#xA;      tone(4,392,300);&#xA;      delay(200);&#xA;      tone(4,493,300);&#xA;      delay(200);&#xA;      tone(4,294,600);&#xA;      delay(200);&#xA;      lcd.setCursor(0,0);&#xA;      lcd.print(&quot;  Motion  &quot;);  // Print a message to the LCD.&#xA;      lcd.setCursor(0,1);&#xA;      lcd.print(&quot; Detected &quot;);&#xA;    } else if(digitalRead(pirPin) ==  HIGH) {&#xA;       digitalWrite(LEDgreen, LOW); // Turn off the LED in the case where no motion is detected&#xA;       lcd.setCursor(0,0);&#xA;       lcd.print(&quot;No Motion  &quot;);&#xA;       lcd.setCursor(0,1);&#xA;       lcd.print(&quot; Detected &quot;);&#xA;     }&#xA;   } else if(buttonState == HIGH) {&#xA;     if(digitalRead(pirPin) == LOW) {&#xA;       digitalWrite(LEDgreen, HIGH); &#xA;       delay(1000);&#xA;       digitalWrite(LEDgreen, LOW);&#xA;       delay(500);&#xA;       digitalWrite(LEDgreen, HIGH);&#xA;       tone(4,261,300);&#xA;       delay(200);&#xA;       tone(4,329,300);&#xA;       delay(200);&#xA;       tone(4,392,600);&#xA;       delay(200);&#xA;       tone(4,329,300);&#xA;       delay(200);&#xA;       tone(4,392,300);&#xA;       delay(200);&#xA;       tone(4,493,600);&#xA;       delay(200);&#xA;       tone(4,392,300);&#xA;       lcd.setCursor(0,0);&#xA;       lcd.print(&quot;  Motion  &quot;);&#xA;       lcd.setCursor(0,1);&#xA;       lcd.print(&quot; Detected &amp;amp; door &quot;);&#xA;     } else if(digitalRead(pirPin) ==  HIGH) {&#xA;       digitalWrite(LEDgreen, LOW);&#xA;       // Turn off the LED in the case where no motion is detected&#xA;       tone(4,329,300);&#xA;       delay(200);&#xA;       tone(4,392,300);&#xA;       delay(200);&#xA;       tone(4,493,600);&#xA;       delay(200);&#xA;       tone(4,392,300);&#xA;       lcd.setCursor(0,0);&#xA;       lcd.print(&quot;No Motion  &quot;);&#xA;       lcd.setCursor(0,1);&#xA;       lcd.print(&quot; Detected but door &quot;);&#xA;     }&#xA;   }&#xA;   delay(2000); // wait for 1 seconds before compare again&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16157" LastEditorUserId="4628" LastEditDate="2016-01-08T12:12:21.327" LastActivityDate="2019-05-17T17:38:26.240" Title="LCD does not work with if condition" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19293" PostTypeId="2" ParentId="9883" CreationDate="2016-01-06T21:31:02.233" Score="2" Body="&lt;p&gt;I had a similar problem. I solved it by using an oscilloscope to measure the arming sequence of an out-of-the-box RC remote controller and receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arming sequence through the controller-receiver was like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect ESC to battery (arduino is connected to signal and ground prior to this)&lt;/li&gt;&#xA;&lt;li&gt;Wait for 3 beeps&lt;/li&gt;&#xA;&lt;li&gt;Set the throttle to the lowest possible&lt;/li&gt;&#xA;&lt;li&gt;Wait for another beep&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I then adjusted my arduino code to output the same(similar) sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#define POT A0&#xA;&#xA;Servo m1;&#xA;&#xA;void setup() {&#xA;  m1.attach(6);&#xA;  Serial.begin(9600);&#xA;  delay(50);&#xA;  Serial.println(&quot;Serial ready:&quot;);&#xA;  arm(m1);&#xA;}&#xA;&#xA;void loop() {&#xA;  int potValue = analogRead(POT);&#xA;  int s = map(potValue,60,930,1200,1700); //Map the pot values to motor values&#xA;&#xA;  m1.write(s);&#xA;  Serial.println(s);&#xA;}&#xA;&#xA;void arm(Servo m){&#xA;  Serial.print(&quot;Arming.&quot;);&#xA;  m.write(0);&#xA;  delay(100);&#xA;  m.write(1224); //A value at which the motor starts turning&#xA;  delay(2000);&#xA;  m.write(1024); //A value at which the motor stands still&#xA;  delay(3000);&#xA;  Serial.println(&quot; Armed!&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also see a video of the whole thing in action here: &lt;a href=&quot;https://www.youtube.com/watch?v=jJPW61Joacw&quot; rel=&quot;nofollow&quot;&gt;A2212/13T brushless motor on a pivoting arm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Further testing shows, that it suffices to output a low non zero value to arm this ESC. Simply doing Servo.write(1024); until you hear the confirmation beep seems to work.&lt;/p&gt;&#xA;" OwnerUserId="16158" LastEditorUserId="16158" LastEditDate="2016-01-09T18:31:27.020" LastActivityDate="2016-01-09T18:31:27.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19294" PostTypeId="1" AcceptedAnswerId="19295" CreationDate="2016-01-06T23:35:32.300" Score="3" ViewCount="2296" Body="&lt;p&gt;I'm writing a little API for processing email messages in Arduinos. Obviously, I need to keep memory use down, but I also want to allow the end user to use the String functions (like indexOf) to search for particular content in emails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My logic uses char arrays (so that memory is statically allocated). If my end user converts a char array to a String (so that they can easily see if an email subject startsWith() a particular word) will this result in doubling the character memory used? .. or will the String class simply include a pointer to the original char array (and just add some cruft)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best-practice in this kind of situation?&lt;/p&gt;&#xA;" OwnerUserId="16161" LastActivityDate="2017-01-15T15:44:37.747" Title="What is the memory expense of creating a String from a char array?" Tags="|c++|string|memory-usage|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19295" PostTypeId="2" ParentId="19294" CreationDate="2016-01-07T00:28:32.290" Score="7" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;What would be the best-practice in this kind of situation?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;To not use &lt;code&gt;String&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I also want to allow the end user to use the String functions (like indexOf) to search for particular content in emails.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There's nothing wrong with providing an &lt;code&gt;indexOf&lt;/code&gt; function in your API.  But you don't have to use &lt;code&gt;String&lt;/code&gt; to implement that function when called.  You can just use the &lt;code&gt;strstr&lt;/code&gt; function on char arrays (reference &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strstr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I should also point out that most Arduinos do not have enough RAM for storing an email.&lt;/p&gt;&#xA;&lt;h3&gt;UPDATE 07-01-2016:&lt;/h3&gt;&#xA;&lt;p&gt;To answer the titular question, the fixed cost of using &lt;code&gt;String&lt;/code&gt; is at least 1600 bytes of program space, more if you use more than a few methods.  The linker can throw out methods you don't use.&lt;/p&gt;&#xA;&lt;p&gt;Then for each &lt;code&gt;String&lt;/code&gt; variable you declare, the recurring cost is 8 bytes for the variable itself, plus the variable-size memory chunk for your character data.  This chunk is allocated from the heap, and is the size of your string plus 4 more bytes to manage the chunk within the heap.  That's a total of 12 extra bytes per &lt;code&gt;String&lt;/code&gt; instance.&lt;/p&gt;&#xA;&lt;p&gt;However, I did not originally answer that question because you explicitly asked about the &lt;em&gt;memory&lt;/em&gt; expense.  This ignores other expenses that should not be ignored:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;execution time - Allocating memory from the heap is really a search for a chunk of the requested size.  At the beginning it can be quick, but as the heap gets fragmented (small chunks build up) it takes longer to find a chunk.  And when the &lt;code&gt;String&lt;/code&gt; is emptied or destroyed, the memory chunk gets put back into the heap and (possibly) merged with adjacent chunks.  Reducing the size of a &lt;code&gt;String&lt;/code&gt; does not free up any memory.  The &lt;code&gt;String&lt;/code&gt; maintains its maximum size until it is emptied or destroyed.&lt;/li&gt;&#xA;&lt;li&gt;long-term stability - Embedded Systems are supposed run &lt;em&gt;forever&lt;/em&gt;.  A primary characteristic of a system that can run forever is &amp;quot;deterministic.&amp;quot;  For whatever inputs it receives, it has a predictable response and end state.  When you use the heap via &lt;code&gt;String&lt;/code&gt;, the heap gets fragmented according to the data it handles.  This is not predictable, and it may get into a state where no memory chunk of the requested size is available.  Choke.&lt;/li&gt;&#xA;&lt;li&gt;maintenance - because the heap state depends on the processed &lt;code&gt;String&lt;/code&gt; data, finding the cause of the failure can be difficult.  It can fail at different times because the input data is different, and it can fail at different places in the program.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Because of &lt;em&gt;these&lt;/em&gt; expenses, &lt;code&gt;String&lt;/code&gt; is rarely used by an experienced developer.  Unfortunately, &lt;code&gt;String&lt;/code&gt; is tempting to the beginner because it is easy to understand.  What is difficult to understand is the complicated, non-deterministic behaviour under the hood that &lt;strong&gt;inevitably&lt;/strong&gt; leads to system failure, rending of garments and gnashing of teeth.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-07T15:28:54.723" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19296" PostTypeId="1" CreationDate="2016-01-07T02:07:00.103" Score="0" ViewCount="1214" Body="&lt;p&gt;I'm using a Yún shield from Dragino with an Arduino Uno, but the default wifi password for the shield (which should be &quot;dragino&quot;) isn't working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the wifi reset (holding down the reset button for 5 seconds) and a factory reset (holding down the reset button for 30 seconds) but the password still seems to be incorrect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way I can reset the password? &lt;/p&gt;&#xA;" OwnerUserId="16162" LastEditorUserId="6936" LastEditDate="2016-01-08T16:39:09.517" LastActivityDate="2016-04-09T16:14:41.960" Title="Arduino Yún shield password reset" Tags="|arduino-uno|shields|arduino-yun|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19297" PostTypeId="1" CreationDate="2016-01-07T03:51:57.293" Score="1" ViewCount="1129" Body="&lt;p&gt;Assuming I have all the necessary hardware...&#xA;I want to develop a system where you type in an email address and the Arduino will send hourly updates on attached sensors to the provided email address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can only get this to work if I enter my email account's username and password and send the email from the authenticated account. There's tons of examples online of this. However, I want to share it with others and I do not want my email authentication to be accessible or be attached with sending the emails.&#xA;For example, I want the email to be from a generic service like email@web-mail.com that no one can sign into and not my personal email or a Gmail account I made for the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anonymous email senders have the right method, but they require human interaction to bypass Captcha or similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an idea of how to do this? Or should I make a separate webserver that handles the requests made by the Arduino and send emails through a Gmail account I made for the project?&lt;/p&gt;&#xA;" OwnerUserId="16163" LastActivityDate="2016-01-07T15:49:09.233" Title="How to send an email via Arduino without an email account?" Tags="|communication|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19298" PostTypeId="2" ParentId="19297" CreationDate="2016-01-07T04:18:36.977" Score="1" Body="&lt;p&gt;You may be able to do this by running the &lt;a href=&quot;https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol&quot; rel=&quot;nofollow noreferrer&quot;&gt;SMTP&lt;/a&gt; transaction yourself. You don't actually need a valid from address (though I probably shouldn't be saying that). There are a number of resouces for how to do this, here's a quick list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/Email&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Playground Email Client page&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/arduino-lesson-17-email-sending-movement-detector.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/1114/how-to-send-an-email-with-arduino-and-a-wifi-shield&quot;&gt;How to send an email with Arduino and a WiFi shield?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you read an article telling you how to do SMTP in a generic sense (not using a particular provider's infrastructure) and it looks like they want a &quot;real&quot; e-mail address, you can try with a fake one. Chances are decent that it may work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some fine points that may cause you grief if you go for the most simple of implementation (for example, just because my e-mail address is foo@bar.org doesn't mean that bar.org will accept an SMTP connection, the &quot;right&quot; way to do it is to check DNS for an MX record for bar.org).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be best to do (and log) any errors that you encounter. There are plenty of things that can go wrong, so tracking where it blows up will help you – or anybody who's trying to help you debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to roll your own &lt;a href=&quot;https://github.com/gregington/SMTPClient&quot; rel=&quot;nofollow noreferrer&quot;&gt;SMTPClient&lt;/a&gt; and &lt;a href=&quot;https://github.com/bibi21000/arduino-fullip&quot; rel=&quot;nofollow noreferrer&quot;&gt;FullIP&lt;/a&gt; look worth checking out.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-07T04:58:10.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19299" PostTypeId="1" CreationDate="2016-01-07T04:51:45.827" Score="1" ViewCount="403" Body="&lt;p&gt;I want to use attiny13 in my project but this program is going over 1KB&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  delay(2000);&#xA;  Serial.println(&quot;AT+CMGF=1&quot;);&#xA;  delay;&#xA;}&#xA;void loop()&#xA;{&#xA;  for (int i=0 ;i &amp;lt; 1 ;i++)&#xA;  {&#xA;    delay(1500);&#xA;&#xA;    Serial.print(&quot;AT+CMGS=\&quot;&quot;);&#xA;    Serial.print(&quot;+918269394684&quot;);&#xA;    Serial.println(&quot;\&quot;&quot;);&#xA;    while(Serial.read()!='&amp;gt;');&#xA;    {&#xA;      Serial.print(&quot;22.7010709,75.9372517&quot;);&#xA;      delay(500);&#xA;      Serial.write(0x1A);&#xA;      Serial.write(0x0D);&#xA;      Serial.write(0x0A);&#xA;      delay(5000);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4437" LastEditorUserId="3917" LastEditDate="2016-01-07T05:49:33.467" LastActivityDate="2016-02-05T05:57:21.813" Title="Is it possible to reduce the size of this program to 1KB" Tags="|arduino-uno|attiny|ide|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19301" PostTypeId="1" AcceptedAnswerId="19327" CreationDate="2016-01-07T06:56:00.530" Score="1" ViewCount="8683" Body="&lt;p&gt;I'm trying to track down a clearly/simply articulated piece of code to take a reading from the &lt;a href=&quot;http://www.allegromicro.com/~/media/Files/Datasheets/ACS712-Datasheet.ashx?la=en&quot; rel=&quot;nofollow&quot;&gt;ACS712 current sensor&lt;/a&gt; (link to download PDF data sheet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that these sensors are noisy, and that reading AC current is quite different to DC current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After looking at a range of examples in a variety of forums etc., I've based the following on &lt;a href=&quot;http://henrysbench.capnfatz.com/henrys-bench/acs712-arduino-ac-current-tutorial/&quot; rel=&quot;nofollow&quot;&gt;http://henrysbench.capnfatz.com/henrys-bench/acs712-arduino-ac-current-tutorial/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ac_read() {&#xA;  int rVal = 0;&#xA;  int maxVal = 0;&#xA;  int minVal = 1023;&#xA;  int sampleDuration = 100; // 100ms&#xA;&#xA;  uint32_t startTime = millis();&#xA;  // take samples for 100ms&#xA;  while((millis()-startTime) &amp;lt; sampleDuration)&#xA;  {&#xA;    rVal = analogRead(A0);&#xA;    if (rVal &amp;gt; maxVal) &#xA;      maxVal = rVal;&#xA;&#xA;    if (rVal &amp;lt; minVal) &#xA;      minVal = rVal;&#xA;  }&#xA;&#xA;  // Subtract min from max to determine the peak to peak range&#xA;  // 1023 = the max value we'll get on the input (1024, zero indexed)&#xA;  // 5.0 = 5v total on adc input&#xA;  double volt = ((maxVal - minVal) * (5.0/1023.0));&#xA;&#xA;  // div by 2 is to calculate RMS from peak to peak&#xA;  // 0.35355 is factor to calculate RMS from peak to peak&#xA;  // see http://www.learningaboutelectronics.com/Articles/Voltage-rms-calculator.php&#xA;  double voltRMS = volt * 0.35355;&#xA;&#xA;  // x 1000 to convert volts to millivolts&#xA;  // divide by the number of millivolts per amp to determine amps measured&#xA;  // the 20A module 100 mv/A (so in this case ampsRMS = voltRMS&#xA;  double ampsRMS = (voltRMS * 1000)/100;&#xA;  Serial.println(ampsRMS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I unfortunately don't have sufficient test equipment at present to validate this, but I'm getting a value of around 8.9 for a 2300W device, which afaict is roughly accurate (based on this calculator &lt;a href=&quot;http://www.rapidtables.com/calc/electric/Watt_to_Amp_Calculator.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.rapidtables.com/calc/electric/Watt_to_Amp_Calculator.htm&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is anyone able to confirm the above makes sense/is logical/sane?  Is there anything obviously incorrect?&lt;/p&gt;&#xA;" OwnerUserId="15852" LastEditorUserId="10907" LastEditDate="2016-01-08T16:38:00.147" LastActivityDate="2016-01-29T04:39:26.640" Title="ACS712 sensor reading for AC current" Tags="|sensors|current|electricity|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19302" PostTypeId="2" ParentId="19299" CreationDate="2016-01-07T07:57:18.647" Score="5" Body="&lt;p&gt;There are several problems with your program as shown that make a good answer impossible.  After I list those problems, I'll then proceed to give an answer, partly good, partly bad.  The good part is that the 432-bytes-of-code program shown below should send all the indicated text strings, in the proper order and separated by appropriate delays.  The bad part is that it sends at 115200 bps instead of 9600.  Depending on point of view, it may be good or may be bad that the code doesn't look for absence of &lt;code&gt;'&amp;gt;'&lt;/code&gt; on Serial input; as I note in discussion of problems, the original code's unclear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As promised, here are several problems with your program as shown, and how to fix them:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The statement &lt;code&gt;delay;&lt;/code&gt; is a constant expression [address of the &lt;code&gt;delay()&lt;/code&gt; function rather than a call to &lt;code&gt;delay()&lt;/code&gt;] so take it out.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The statement &lt;code&gt;for (int i=0 ;i &amp;lt; 1 ;i++)&lt;/code&gt; is a do-nothing so take it out.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The sequence &lt;code&gt;while(Serial.read()!='&amp;gt;'); {&lt;/code&gt; is confusing – it compiles but isn't something a rational programmer would write – so take it out.  (As written, with a semicolon directly between the right parenthesis and the left brace, it busy-waits until it reads &lt;code&gt;'&amp;gt;'&lt;/code&gt; on Serial input.  Then the unnecessarily-blocked block of statements within the matched braces executes one time and &lt;code&gt;loop()&lt;/code&gt; exits its current pass.  If the semicolon weren't there, the statements within the braces would execute repeatedly until a &lt;code&gt;'&amp;gt;'&lt;/code&gt; appears on Serial input.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyhow, with the minor fixes outlined above, and using the &lt;code&gt;BasicSerial&lt;/code&gt; library from nerdralph's &lt;a href=&quot;http://nerdralph.blogspot.ca/2013/12/writing-avr-assembler-code-with-arduino.html&quot; rel=&quot;nofollow&quot;&gt;writing AVR assembler code with Arduino&lt;/a&gt; page, we get the following message for the program shown below. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sketch uses 432 bytes (42%) of program storage space. Maximum is 1,024 bytes.  Global variables use 68 bytes of dynamic memory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;BasicSerial.h&amp;gt;&#xA;char *text = &quot;AT+CMGF=1\n\0&quot;    &quot;AT+CMGS=\&quot;+918269394684\&quot;\0&quot;&#xA;  &quot;22.7010709,75.9372517\0&quot; &quot;\033\r\n&quot;;&#xA;#define send(item) while (*item) TxByte (*item++)&#xA;void setup() {&#xA;  //Serial.begin(9600);&#xA;  delay(2000);&#xA;  //Serial.write(&quot;AT+CMGF=1\n&quot;);&#xA;  send(text);&#xA;  //delay;&#xA;}&#xA;void loop() {&#xA;  char *msg = text;&#xA;  delay(1500);          // took out `for`&#xA;  //Serial.write(&quot;AT+CMGS=\&quot;+918269394684\&quot;&quot;);&#xA;  send(msg);&#xA;  //while(Serial.read()!='&amp;gt;'); {&#xA;  //Serial.write(&quot;22.7010709,75.9372517&quot;);&#xA;  send(msg);&#xA;  delay(500);&#xA;  //Serial.write(&quot;\033\r\n&quot;);&#xA;  send(msg);&#xA;  delay(5000);&#xA;  //}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Program Notes:&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The string &lt;code&gt;text&lt;/code&gt; contains all the text from your original &lt;code&gt;Serial&lt;/code&gt; prints and writes.  With the text organized as a single string, the program only needs to set its character pointer &lt;code&gt;msg&lt;/code&gt; once per loop, saving perhaps half a dozen bytes of code.   &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The commented-out &lt;code&gt;Serial.write&lt;/code&gt; statements are equivalents of your various &lt;code&gt;Serial.println&lt;/code&gt;, &lt;code&gt;Serial.print&lt;/code&gt;, and &lt;code&gt;Serial.write&lt;/code&gt; statements, with adjacent strings lumped into single writes, thus for example using one write instead of three to write the Esc, CR, LF sequence just before &lt;code&gt;delay(5000)&lt;/code&gt;.  Just changing those printlns, prints and writes all to writes reduces code size  by about 150 bytes, which might be enough of a reduction to get you by, depending where you start from.  But in my tests, substituting &lt;code&gt;BasicSerial&lt;/code&gt; in place of &lt;code&gt;Serial&lt;/code&gt; saves over a thousand bytes so is likely to be a requirement.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You probably can modify the code in &lt;code&gt;BasicSerial.S&lt;/code&gt; for other data rates, or perhaps can substitute one or another of the small &lt;code&gt;Serial&lt;/code&gt; replacements listed in ernstc's &lt;a href=&quot;http://www.ernstc.dk/arduino/tinycom.html&quot; rel=&quot;nofollow&quot;&gt;Serial communication with the Tiny's&lt;/a&gt; webpage, to get different data rates and/or receive as well as transmit.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt;  As Edgar Bonet noted in a comment, an ATtiny13 has 64 bytes of RAM, so the above program (using 68 bytes of RAM) will fail.  RAM usage can be reduced by copying string characters individually from program memory, instead of copying the string into RAM (per Arduino default).  See the following revision of the program, which also corrects a problem (leaving &lt;code&gt;msg&lt;/code&gt; pointed at a null byte) that would keep the former program from working.  Note, with these changes, we have:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sketch uses 456 bytes (44%) of program storage space. Maximum is 1,024 bytes.     Global variables use 6 bytes of dynamic memory.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;BasicSerial.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;const char text[] PROGMEM = &quot;AT+CMGF=1\n\0&quot; &#xA;  &quot;AT+CMGS=\&quot;+918269394684\&quot;\0&quot;&#xA;  &quot;22.7010709,75.9372517\0&quot; &quot;\033\r\n&quot;;&#xA;char *front = (char*)text;&#xA;#define send(item) while (pgm_read_byte(item)) TxByte (pgm_read_byte(item++))&#xA;&#xA;void setup() {&#xA;  delay(2000);&#xA;  send(front);  ++front;&#xA;}&#xA;void loop() {&#xA;  char *msg = front; &#xA;  delay(1500);&#xA;  send(msg);   ++msg;&#xA;  send(msg);   ++msg;&#xA;  delay(500);&#xA;  send(msg);&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-05T05:57:21.813" LastActivityDate="2016-02-05T05:57:21.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19304" PostTypeId="1" AcceptedAnswerId="19349" CreationDate="2016-01-07T08:58:15.860" Score="2" ViewCount="4465" Body="&lt;p&gt;I would like to make an arduino board that is capable of handling 24V i/o.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Powering the Arduino would be done through either a linear or switching regulator of some sort. Low amperages, so efficiency isn't the main problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For input:&#xA;24v to 5v input scaling could be created with a voltage divider. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, there will never run a high current into the arduino? So the power loss is minimal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For output:&#xA;5v to 24v can be easily achieved using a MOSFET? Since this will ramp up the possible load (higher amperages) given that I'm using a 24v supply/separate line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I could choose to make half the I/O only input and half only output.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Could I combine the MOSFET and voltage divider, and in what way?&lt;/li&gt;&#xA;&lt;li&gt;Are my &quot;assumptions&quot; about the I/O correct, or are there beter ways of handling it?&lt;/li&gt;&#xA;&lt;li&gt;What other things should I think of? Over voltage protection? Polarity inversion? Protection against too high currents?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2020-06-27T12:50:40.737" Title="Industrializing Arduino - 24V io? (Electronics)" Tags="|electronics|input|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19305" PostTypeId="1" CreationDate="2016-01-07T09:20:00.323" Score="3" ViewCount="758" Body="&lt;p&gt;Is it possible to directly set the registers that control the ADC in an Arduino Yun (micro-controller side is essentially a Arduino Leonardo) from a sketch or is there a specific file somewhere you must edit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a project that collects a signal digitizes it and sends it through a digital filter. I looked up the Datasheet for the micro-controller on the Yun and wrote the code setting the registers associated with the ADC portion of the micro controller. The code setting the registers was something like &lt;code&gt;REGNAME = 0x01;&lt;/code&gt;. Yet when tested several of the associated registers were unaffected. Pointers on the process to set the ADC manually without using the &lt;code&gt;analogRead()&lt;/code&gt; function would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;My original code looked something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup(){&#xA;    // register to turn on ADC&#xA;    REG1 = REG1 | 0x01;&#xA;&#xA;    //register to set sample rate and set ADC to Free Running Mode&#xA;    REG2 = REG2 &amp;amp; 0x30;&#xA;&#xA;    // register to set other settings&#xA;    REG3 = REG3 | 0xF1;&#xA;}&#xA;&#xA;void loop(){&#xA;    // code to take samples from ADC&#xA;    // and send them through a digital filter here.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16165" LastEditorUserId="7508" LastEditDate="2016-03-31T13:29:28.927" LastActivityDate="2016-05-30T14:42:52.200" Title="Is it possible to directly set the registers that control the ADC clock on the Arduino?" Tags="|arduino-yun|adc|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="19306" PostTypeId="2" ParentId="19292" CreationDate="2016-01-07T09:38:03.727" Score="1" Body="&lt;p&gt;This is a summary of your basic loop logic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  int buttonState = digitalRead(buttonPin);// Read the pushbutton input pin:&#xA;  int pirVal = digitalRead(pirPin); //read the digital value from the pirPin and store the value in the local variable pirVal&#xA;  if (buttonState == LOW) {&#xA;    if (digitalRead(pirPin) == LOW) {&#xA;        // buttonState is LOW&#xA;        // pirPin is recently read as LOW&#xA;        // ... Motion Detected ...&#xA;    }&#xA;    else if (digitalRead(pirPin) ==  HIGH) {&#xA;        // buttonState is LOW&#xA;        // pirPin is recently read as HIGH&#xA;        // ... No Motion Detected ...&#xA;    }&#xA;  }&#xA;  else if (buttonState == HIGH) {&#xA;    if (digitalRead(pirPin) == LOW) {&#xA;        // buttonState is HIGH&#xA;        // pirPin is recently read as LOW&#xA;        // ... Motion Detected &amp;amp; Door ...&#xA;    }&#xA;    else if (digitalRead(pirPin) ==  HIGH) {&#xA;        // buttonState is HIGH&#xA;        // pirPin is recently read as HIGH&#xA;        // ... No Motion Detected but Door ...&#xA;    }&#xA;  }&#xA;  delay(2000); // wait for 1 seconds before compare again&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is bad code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(pirPin) == LOW) {&#xA;    // ... Motion Detected ...&#xA;}&#xA;else if (digitalRead(pirPin) ==  HIGH) {&#xA;    // ... No Motion Detected ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;because each time the digitalRead(..) function is called, it can give a different value. So even though your intention is clear, this code won't work the way you expect. Consider what happens if the first digitalRead(pirPin) is high, so digitalRead(pirPin)==LOW is false, but then the second digitalRead(pirPin) is low, so digitalRead(pirPin)==HIGH is also false. Then neither block of code runs. Instead, use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(pirPin) == LOW) {&#xA;    // ... Motion Detected ...&#xA;}&#xA;else {&#xA;    // ... No Motion Detected ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or since you already sampled it at the start of the loop with &lt;code&gt;int pirVal = digitalRead(pirPin);&lt;/code&gt;, simplify the logic as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  int buttonState = digitalRead(buttonPin);// Read the pushbutton input pin:&#xA;  int pirVal = digitalRead(pirPin); //read the digital value from the pirPin and store the value in the local variable pirVal&#xA;&#xA;  if (buttonState == LOW) {&#xA;    if (pirVal == LOW) {&#xA;        // buttonState is LOW&#xA;        // pirPin is LOW&#xA;        // ... Motion Detected ...&#xA;    }&#xA;    else {&#xA;        // buttonState is LOW&#xA;        // pirPin is HIGH&#xA;        // ... No Motion Detected ...&#xA;    }&#xA;  }&#xA;  else {&#xA;    // buttonState is HIGH&#xA;    if (pirVal == LOW) {&#xA;        // buttonState is HIGH&#xA;        // pirPin is LOW&#xA;        // ... Motion Detected &amp;amp; Door ...&#xA;    }&#xA;    else {&#xA;        // buttonState is HIGH&#xA;        // pirPin is HIGH&#xA;        // ... No Motion Detected but Door ...&#xA;    }&#xA;  }&#xA;  delay(2000); // wait for 1 seconds before compare again&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, if you're using the Arduino IDE, you can easily clean up the indentation to make these control structures easier to see, by using Tools | Auto Format.&lt;/p&gt;&#xA;" OwnerUserId="7174" LastActivityDate="2016-01-07T09:38:03.727" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19307" PostTypeId="1" CreationDate="2016-01-07T12:57:32.587" Score="0" ViewCount="595" Body="&lt;p&gt;I am making a system of regulation of the temperature using PID.&#xA;I want to keep my temperature in 37 celsius.&#xA;in order to understand the stability of my system easily, I want to see the fuction of temperature in terms of time. &#xA;I found a function pulseIn() who Read a pulse (either HIGH or LOW) on a pin. &#xA;But I don't know how to do it into my program. &#xA;this is the program of my PID system: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PID_v1.h&amp;gt;&#xA;#include &quot;math.h&quot; &#xA;int c=0;&#xA;int  i=0, output2 = 0, output3 = 0; &#xA;double val=0.0;&#xA;double val2 = 0.0;&#xA;//Define Variables we'll be connecting to&#xA;double Setpoint, Input, Input2, Output=0;&#xA;double tOnMax = 50.0;&#xA;&#xA;//Specify the links and initial tuning parameters&#xA;PID myPID( &amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,10,20,20, DIRECT);&#xA;&#xA;void setup()&#xA;{&#xA;  //initialize the variables we're linked to&#xA;  Setpoint = 37; //temperature a reguler &#xA;&#xA;  //turn the PID on&#xA;  pinMode(9, OUTPUT);&#xA;  myPID.SetOutputLimits(-100, 100);&#xA;  myPID.SetMode(AUTOMATIC);&#xA;  Serial.begin(19200);&#xA;  while (!Serial); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // phase haute&#xA;  digitalWrite(9,HIGH);&#xA;  delay(output2);&#xA;  // phase basse&#xA;  digitalWrite(9,LOW);&#xA;&#xA;  for (i = 0; i &amp;lt; 64;i++)&#xA;      val += analogRead(0);&#xA;  val /= 64.;&#xA;&#xA; for (i = 0; i &amp;lt; 64;i++)&#xA;      val2 += analogRead(1);&#xA;  val2 /=64.;&#xA;&#xA;  float mv = round (( val/1024.0)*5000);&#xA;  float mv2 = round (( val2/1024.0)*5000);&#xA;  Input = mv/10;&#xA;  Input2 = mv2/10;&#xA;//  Serial.println(Input);&#xA;  myPID.Compute();&#xA;  output2 = map(Output, -100, 100, 0, tOnMax);&#xA;  output3 = map(Output, -100, 100, 0, tOnMax);&#xA;//  Serial.print(&quot;output is :&quot;);&#xA;//  Serial.println(output2); &#xA;//  Serial.print(&quot;Input: &quot;);&#xA;for (c=0; c &amp;lt; 500; c++) {}&#xA;Serial.println(Input);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;thnak you in advance&lt;/p&gt;&#xA;" OwnerUserId="14515" LastEditorUserId="4131" LastEditDate="2016-01-07T13:33:10.900" LastActivityDate="2016-01-10T05:55:40.847" Title="PID and pulseIn()" Tags="|arduino-uno|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="19308" PostTypeId="1" CreationDate="2016-01-07T14:53:35.437" Score="1" ViewCount="202" Body="&lt;p&gt;This going to be a difficult to debug problem but I hope some ppl here have C knowledge and idea what's going on. Given an arduino nano which is controlled by a C program from WRT54G. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relevant part of the arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA; int integerValue=0; &#xA;&#xA;                              // Max value is 65535&#xA;char incomingByte;&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {   // something came across serial&#xA;    integerValue = 0;         // throw away previous integerValue&#xA;    while(1) {            // force into a loop until 'n' is received&#xA;      incomingByte = Serial.read();&#xA;      if (incomingByte == '\n') break;   // exit the while(1), we're done receiving&#xA;      if (incomingByte == -1) continue;  // if no characters are in the buffer read() returns -1&#xA;      integerValue *= 10;  // shift left 1 decimal place&#xA;      // convert ASCII to integer, add, and shift left 1 decimal place&#xA;      integerValue = ((incomingByte - 48) + integerValue);&#xA;&#xA;    }&#xA;   Serial.print(&quot;Command: &quot;);&#xA;   Serial.println(integerValue);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pretty straight forward (it converts serial received ascii chars to numeric format), arduino receives a simple integer and it runs a function. For example 1-&gt; turn on relay1. This work's reliably for sure because I can just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;echo &quot;1&quot; &amp;gt; /dev/tts/1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here is the relevant part of the C code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;    int serialport_read_until(int fd, char* buf, char until, int buf_max, int timeout)&#xA;    {&#xA;        char b[1];  // read expects an array, so we give it a 1-byte array&#xA;        int i=0;&#xA;        do { &#xA;            int n = read(fd, b, 1);  // read a char at a time&#xA;            if( n==-1) return -1;    // couldn't read&#xA;            if( n==0 ) {&#xA;                usleep( 1 * 1000 );  // wait 1 msec try again&#xA;                timeout--;&#xA;                continue;&#xA;            }&#xA;    #ifdef SERIALPORTDEBUG  &#xA;            printf(&quot;serialport_read_until: i=%d, n=%d b='%c'\n&quot;,i,n,b[0]); // debug&#xA;    #endif&#xA;            buf[i] = b[0]; &#xA;            i++;&#xA;        } while( b[0] != until &amp;amp;&amp;amp; i &amp;lt; buf_max &amp;amp;&amp;amp; timeout&amp;gt;0 );&#xA;&#xA;        buf[i] = 0;  // null terminate the string&#xA;        return 0;&#xA;    }&#xA;&#xA;    /* Only use integer commands */&#xA;    int serialport_write(int fd, int comm_no)&#xA;    {&#xA;        char command[6];&#xA;&#xA;        sprintf(command,&quot;%d\n&quot;,comm_no);&#xA;        printf(&quot;Sending Command:%s&quot;,command);&#xA;&#xA;        int len = strlen(command);&#xA;        int n = write(fd, command, len);&#xA;        if( n!=len ) &#xA;            return -1;&#xA;        return 0;&#xA;    }&#xA;&#xA;void *ardu_handler(void *fdfd)&#xA;{&#xA;  int fd = *(int*)fdfd;&#xA;  char buf[256];&#xA;  char getback[10];&#xA;&#xA;  while (1)&#xA;   {&#xA;     memset(buf, 0, sizeof(buf)); &#xA;     serialport_read_until(fd, buf, '\n', 256, 5);&#xA;     fprintf(stderr, &quot;Received: %s\n&quot;, buf);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then a C thread will be started with the ardu_handler which in this case doesn't do anything else just print's back the response from the ardu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's happening is when I send a command I start getting back infinite amount of commands (up until I close the C app and start it again) and to make it worse it is even inconsistent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command: 62143&#xA;Command: 7891&#xA;Command: 3216&#xA;Command: 11287&#xA;...&#xA;runs forever.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I asking myself is whether these &lt;em&gt;responses&lt;/em&gt; coming out from the arduino or they are just coming out from the bogous C program...&#xA;It's not possible to connect to see what's coming out on the serial port unfortunately until this program holds the port open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I run the C code on mips this was doing the same thing back on x86 PC with an arduino uno (sometimes it is stable but then it falls into this unstable state and floods the serial port). It was unreliable and I would like to make it reliable. &lt;/p&gt;&#xA;" OwnerUserId="16175" LastEditorUserId="4131" LastEditDate="2016-01-08T16:39:13.780" LastActivityDate="2016-01-08T16:39:13.780" Title="C Serial Communication Code is unreliable" Tags="|serial|arduino-nano|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19310" PostTypeId="1" CreationDate="2016-01-07T15:32:37.793" Score="3" ViewCount="2446" Body="&lt;p&gt;I have just installed the arduino IDE on my gentoo laptop. I then installed the toolchain with the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;crossdev -s4 avr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does a stage 4 install of the toolchain, with all its dependecies etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am following a tutorial, with my arduino uno, which I am assuming is using the Amtel ATmega328 chipset. This tutorial is simply going to turn an led on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I click the verify button and I get the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/libexec/gcc/avr/ld: cannot find crtatmega328p.o: No such file or directory&#xA;&#xA;/usr/libexec/gcc/avr/ld: cannot find -latmega328p&#xA;&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I downloaded the source files &quot;avr-libc&quot; compiled them and noticed inside the directory &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/avr-libc-1.8.1/avr/lib/avr5/atmega328p&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That the compiled module is named crtm328p.o which is available on my pc under the directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/avr/lib/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I dont understand what is wrong and why this is not working. The only posts relating to missing files are over 5 years old and those solutions are not working.&lt;/p&gt;&#xA;" OwnerUserId="16177" LastEditorUserId="11529" LastEditDate="2016-03-02T16:59:41.333" LastActivityDate="2017-11-01T14:23:23.840" Title="Cannot find crtatmega328p" Tags="|arduino-uno|arduino-ide|compile|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19311" PostTypeId="2" ParentId="19297" CreationDate="2016-01-07T15:49:09.233" Score="1" Body="&lt;p&gt;I am thinking that you will have a few issues in doing this,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you wish to, as mentioned by &lt;em&gt;dlu&lt;/em&gt;, run the SMTP Transaction from the device yourself, you are free to do that, however, most SMTP Relays will require some sort of authentication; this is to prevent me from using a random relay to send out millions of messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another issue may be that if you do setup a local relay, your ISP will block traffic on port 25, which is common; this means your mail can never be delivered to an external server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thoughts on the &lt;em&gt;simplest&lt;/em&gt; way to do this would be getting a Virtual Private Server that will run the mail service and a webserver; you could then make a simple PHP script that will accept a few parameters, and send an email.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the above, you would only need to make an HTTP request to your server for the mail to be sent,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;http://web-mail.com/sendmail.php/?to=someone@somewhereelse.com&amp;amp;subject=Wooo&amp;amp;Message=This%20is%20a%20message.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="407" LastActivityDate="2016-01-07T15:49:09.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19312" PostTypeId="2" ParentId="19307" CreationDate="2016-01-07T16:05:46.787" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to see the evolution of the function tempertaure (t), in other words, i want to see in my screen for exemple: 24.1C -&gt; 20ms ; 25C-&gt; 200ms; 26 -&gt; 500ms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Quite apart from managing the heater, it sounds as if you need to sample the temperature at a constant rate, compare its value to any of several temperature-intervals, and, when it moves out of one interval into another, report the time it spent within the previous one. This will require saving which interval the temperature was last observed in, and the time it entered that interval, re-saving both when it moves into a new one. You may need to apply some smoothing to the temperature data to if there is any noise in the temperature data to prevent it appearing to jitter back and forth between intervals during interval edge crossings.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-01-07T16:05:46.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19313" PostTypeId="2" ParentId="19307" CreationDate="2016-01-07T16:14:35.930" Score="1" Body="&lt;p&gt;OK, with such a slow heater as compared to the calculation time of the arduino, you likely want to use a much longer sampling time. One could disconnect the PWM time and the sampling time from the loop() time by replacing the delay() with millis() as in &lt;a href=&quot;https://arduino.stackexchange.com/questions/17918/using-arduino-for-simultaneous-lighting-effects/17929#17929&quot;&gt;Using Arduino for simultaneous lighting effects&lt;/a&gt; and below, and with a sampling time of 1s, 10s or 60s, the parameters of the PID and the integral and derivative terms could start making sense. i.e. the D term would conform to watts/(degreeError/minute), the I term to Watts/(degreeError*minutes) and P to watts/degreeError.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One nice way to think of a PID controller is that it converts process errors into a control variable.  If you want to convert &quot;degrees below setpoint&quot; into &quot;milliseconds of heat per tOnMax second cycle&quot;, set that directly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Tuned for full power (1000ms/sec) up to 35C: P=1000/2 &#xA;PID myPID( &amp;amp;Degrees, &amp;amp;millisecondsOn, &amp;amp;Setpoint,500,0,0, DIRECT);&#xA;myPID.SetOutputLimits(0, tOnMax);&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &quot;duty cycle of heater&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Tuned for full power (100%) up to 35C: P=1.0/2 &#xA;PID myPID( &amp;amp;Degrees, &amp;amp;millisecondsOn, &amp;amp;Setpoint,0.5,0,0, DIRECT);&#xA;myPID.SetOutputLimits(0, 1.0);&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I didn't want to edit your code too much, but went for a 1s PWM frequency, 10s sampling or PID cycle time.   The 1sec PWM/cycle time is the minimum most commercial PID controllers work with (typically 1s-999s to handle a range from solid-state-relay controlled resistive heating elements to relay controlled mechanical systems like pilot light heaters or fan/pump systems) and should be plenty fast enough for your system.  Slower PWM times are better for mechanical systems, and faster times are better for thermal cycling of resistive elements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 10s cycle time is ~200x slower than your initial code looks like it is sampling, but the 10s time might be more in keeping with the physical changes in your system as compared to your resolution.  I can't tell the temperature resolution of your sensor for your code, but assuming it is 0.1C, taken with a (37C-20C)/30m=0.0094C/s rate of change, it would take about 10s to make 1 bit of  detectable change.  If you sample faster than that, all you will be getting is noise or no change.  Sampling significantly faster than the physical process changes can serve to confuse a PID in the integral and derivative terms--Derivative because the derivative of error is mostly zeros or noise, and Integral because the integral accumulator can wind up before the system even begins to move.  Looking at the Arduino PID library code at &lt;a href=&quot;https://github.com/br3ttb/Arduino-PID-Library/blob/master/PID_v1.cpp#L57&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/br3ttb/Arduino-PID-Library/blob/master/PID_v1.cpp#L57&lt;/a&gt; with a I=20, output limits of (-100,100), a t0=20C, a setpoint of 37, sampling time of 50ms, and a temperature rate of change of 0.0094C/s, the Iterm accumulator would be wound up to 100 in just 0.300 seconds.  The wound-up integral would guarantee an overshoot until the integral accumulator erodes afterwards (For example: 37.5C for 10s? 37.1C for 100s? ???)    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 1000ms PWM and 10s sampling time base, you would need to reconsider your PID settings.   In particular, the I and D terms strongly sensitive to the sampling time and the output range.  As a start, PID myPID( &amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,500,0,0, DIRECT); would start to proportionally turn the heater off at 37-1000/500)=35C, which might be good enough for your needs.  If that isn't close enough, you could increase P more to tighten the proportional band.  (&quot;Proportional band&quot; is error band where the P*error term of the PID doesn't saturate the output limits, i.e., PropBand = +/-(tOnMax/P) )   Alternately, you could fiddle with the I term to completely eliminate the droop.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PID_v1.h&amp;gt;&#xA;#include &quot;math.h&quot; &#xA;int c=0;&#xA;int  i=0, output2 = 0, output3 = 0; &#xA;double val=0.0;&#xA;double val2 = 0.0;&#xA;//Define Variables we'll be connecting to&#xA;double Setpoint, Input, Input2, Output=0;&#xA;double tOnMax = 1000.0; // 1 second PWM controlling 10w heater&#xA;unsigned long sampleTime, heaterTime;&#xA;&#xA;//Specify the links and initial tuning parameters&#xA;// Process takes 30m to come to 37C from 17C at 10W&#xA;// Proportional: Full power to setpoint-2C, then proportional taper: P= tOnMax/2&#xA;// Integral: 30m = 300 samples, so area under curve = 20*300/2=3000&#xA;// so for integral to roll up to 50% power (1/2 tOnMax) in 30m:&#xA;// I = tOnMax/2/3000 = 1000/2/3000 = 0.15&#xA;// Derivative: Max slew rate of 20C/30m = 20C/300 10sSamples = 0.067C/sample&#xA;// Ignore the derivative for now to avoid potential noise problems, &#xA;// but D=tOnMax/0.067=15000 would anticipate and counteract the maximum slewing rate&#xA;PID myPID( &amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint,tOnMax/2,0.15,0, DIRECT);&#xA;&#xA;void setup()&#xA;{&#xA;  //initialize the variables we're linked to&#xA;  Setpoint = 37; //temperature a reguler &#xA;&#xA;  //turn the PID on&#xA;  pinMode(9, OUTPUT);&#xA;  myPID.SetOutputLimits(0, tOnMax);&#xA;  myPID.SetMode(AUTOMATIC);&#xA;  Serial.begin(19200);&#xA;  while (!Serial); &#xA;  heaterTime=sampletime=millis();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned long now = millis();&#xA;  if(heaterTime &amp;lt; now){&#xA;     if(digitalRead(9)) {// phase haute -&amp;gt; basse&#xA;        heaterTime += tOnMax-output2; // schedule on &#xA;        digitalWrite(9,LOW);}&#xA;     } else {  // phase basse -&amp;gt; haute&#xA;       heaterTime += output2);  // schedule off&#xA;       digitalWrite(9,HIGH);&#xA;     }&#xA;  if (sampleTime &amp;lt; now ) {&#xA;      sampleTime = sampleTime + 10000;  // every 10 seconds&#xA;      val=0=val2=0;&#xA;      for (i = 0; i &amp;lt; 64;i++)&#xA;          val += analogRead(0);&#xA;      val /= 64.;&#xA;&#xA;      float mv = round (( val/1024.0)*5000); // convert to degrees*10?&#xA;      Input = mv/10;        // degrees&#xA;      myPID.Compute();&#xA;      output2 = Output;&#xA;      Serial.print(Input);&#xA;      Serial.print(&quot;C -&amp;gt; &quot;);&#xA;      Serial.print(output2); &#xA;      Serial.print(&quot;ms / &quot;); &#xA;      Serial.println(tOnMax); &#xA;   } // end sample&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-10T05:55:40.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19314" PostTypeId="2" ParentId="19296" CreationDate="2016-01-07T16:34:26.777" Score="1" Body="&lt;p&gt;Try connecting via ethernet to 192.168.255.1 with root/root&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SSH access for Dragrove is:&#xA;IP: 192.168.255.1 on LAN port. If you want to connect to the Dragrove via WiFi, the IP should be 192.168.1.108.&#xA;Username: root&#xA;Password: root&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Dragrove_-_Generic_gateway_for_internet_of_things&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Dragrove_-_Generic_gateway_for_internet_of_things&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16180" LastEditorUserId="16180" LastEditDate="2016-01-07T16:42:06.590" LastActivityDate="2016-01-07T16:42:06.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19315" PostTypeId="1" AcceptedAnswerId="19320" CreationDate="2016-01-07T17:45:17.960" Score="1" ViewCount="253" Body="&lt;p&gt;I am getting constant values and I need to know the amplification of the circuit. I believe that amplification = R8/R6 though I am not sure.&lt;a href=&quot;https://i.stack.imgur.com/pL7jh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pL7jh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11300" LastEditorUserId="2881" LastEditDate="2016-01-07T18:50:40.323" LastActivityDate="2016-01-07T19:29:55.283" Title="Amplification of microphone circuit" Tags="|arduino-micro|op-amp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19316" PostTypeId="1" AcceptedAnswerId="19319" CreationDate="2016-01-07T11:26:18.777" Score="3" ViewCount="1761" Body="&lt;p&gt;I have a Servo Motor and an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the Arduino to run a servo motor. The code was very simple. It was to just Turn it 90 Deg Anti-Clockwise when a switch is pressed and Turn back to its original position (90 Deg Clockwise).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo had 3 pins. &#xA; 1. V+&#xA; 2. Ground&#xA; 3. Data&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the V+ to the Arduino's 5v Output. And the Ground to the Arduino's GND pin. I connected the Data to Digital Pin 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When ever this script runs, The servo turns a little and then stops. It stops because the arduino froze and It wont do anything. I pressed the Reset button and it does nothing. I plugged off the Servo and the Power Supply and replugged the Power and it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power source was a battery pack with 4x 1.5 Volts batteries in it. Maybe there was a problem with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do anyone know what might be the problem here? Any Answer will be Appriciated. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16198" OwnerDisplayName="Bryan" LastActivityDate="2016-01-07T18:38:05.850" Title="Why does my Arduino freezes when i turn a servo" Tags="|servo|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19317" PostTypeId="2" ParentId="19316" CreationDate="2016-01-07T14:05:25.190" Score="1" Body="&lt;p&gt;Connect your servo V+ to your battery stack and the servo data input to your Arduino. I suspect that the servo is causing the Arduino to reset when the servo draws too much current through the Arduino's voltage supply circuitry.&lt;/p&gt;&#xA;" OwnerDisplayName="Ross_ValuSoft" LastActivityDate="2016-01-07T14:05:25.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19318" PostTypeId="2" ParentId="19316" CreationDate="2016-01-07T14:14:35.657" Score="1" Body="&lt;p&gt;My first response would be a brown out reset. Because of the load the voltage will sag and drop below a certain voltage so the microcontroller will reset. Try to put a big buffer capacitor on the power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other possible cause could be inductive spiking, but I dont expect this to be the cause of your problem.&lt;/p&gt;&#xA;" OwnerDisplayName="user3689010" LastActivityDate="2016-01-07T14:14:35.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19319" PostTypeId="2" ParentId="19316" CreationDate="2016-01-07T14:38:40.940" Score="2" Body="&lt;p&gt;You said that you were using 4x 1.5v batteries. That would make a total of 6 volts. The current that those batteries can supply is also little. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Recommended Input Range is 7-12 volts. And the Limit is 6-20 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You were supplying it with 6 Volts which is at the very limit of the Input Voltage Range. When the motor runs, the Voltage might have dropped and made the arduino freeze.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix is to supply the arduino with another source such as a benchtop supply that can supply more than 8 volts.&lt;/p&gt;&#xA;" OwnerUserId="16196" OwnerDisplayName="user96384" LastActivityDate="2016-01-07T14:38:40.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19320" PostTypeId="2" ParentId="19315" CreationDate="2016-01-07T19:29:55.283" Score="2" Body="&lt;p&gt;You are mostly correct Diana.  The gain of an OP-Amp would normally be R8 divided by R6.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what needs to be recognized is that in your circuit, the resistance of R3 and the microphone get entangled with your R6.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistance (impedance of your microphone) is in series with R6. R3 also comes into play, but I will ignore it here (subject of another question on amplifiers).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, since R of microphone is in series with your R6, your gain (amplification) will be slightly less than you have calculated.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The old 741 Op-Amp won't work very well (probably not at all) with a single ended power supply of 5 volts.  Although you have done a good job of biasing the non-inverting input (+) at 2.5 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 741 output can't get near the +5 volts, nor can it get near ground.  Try a better Op-Amp such as MCP6002. Look at how the output of the MCP6002 can approach the rails (your power supply and ground).&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-01-07T19:29:55.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19322" PostTypeId="2" ParentId="17508" CreationDate="2016-01-07T21:52:57.170" Score="2" Body="&lt;p&gt;There are so many mistakes in your code. I'll do my best to correct them using comments. The code for the slaves should be as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;&#xA;//&#xA;// i2c_test_01&#xA;&#xA;//&#xA;// This demonstrates a master transmitting to a slave.&#xA;// &#xA;&#xA;// The master transmits a value read from an analogue port.&#xA;&#xA;// The slave sends the value to the serial device.&#xA;//&#xA;&#xA;&#xA;int inp = 0;  // input pin&#xA;&#xA;const byte SlaveDeviceId = 2;&#xA;&#xA;void setup() {  &#xA;  Wire.begin(SlaveDeviceId);  // here the slave joins the bus, with its address as argument to begin()&#xA;  Wire.onRequest(callback);  // here you indicate what the slave should do if a bus master queries it&#xA;}&#xA;&#xA;void callback() {&#xA;  int input0 = analogRead(inp);  &#xA;  // Send two bytes to master&#xA;  Wire.write(input0 &amp;gt;&amp;gt; 8);&#xA;  Wire.write(input0 &amp;amp; 255);&#xA;&#xA;  inp++;&#xA;  if (inp == 4) {&#xA;    inp = 0;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the master's code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;const byte SlaveDeviceId = 1;&#xA;const byte SlaveDeviceId2 = 2;&#xA;char inputDev = 4;  // number of devices connected to slave analog inputs&#xA;&#xA;void setup() {&#xA;  Wire.begin();   // no argument here since its a master&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;//the onReceive() method is for slaves receiving from a master, so we dont use it here&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;\r\nSlave 1: &quot;);&#xA;  for (char i = 0; i &amp;lt; inputDev; i++){&#xA;    Wire.requestFrom(SlaveDeviceId, 2);&#xA;    delay(1);  // more than enough time for all the data to come in&#xA;    int val = Wire.read() &amp;lt;&amp;lt; 8;&#xA;    val |= Wire.read() &amp;amp; 0xFF;&#xA;    Serial.print(val);&#xA;    Serial.print(&quot;,&quot;);&#xA;  }&#xA;  Serial.println(&quot;\r\nSlave 2: &quot;);&#xA;  for (char i = 0; i &amp;lt; inputDev; i++){&#xA;    Wire.requestFrom(SlaveDeviceId2, 2);&#xA;    delay(1);  // more than enough time for all the data to come in&#xA;    int val = Wire.read() &amp;lt;&amp;lt; 8;&#xA;    val |= Wire.read() &amp;amp; 0xFF;&#xA;    Serial.print(val);&#xA;    Serial.print(&quot;,&quot;);&#xA;  }        &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-07T21:52:57.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19323" PostTypeId="1" CreationDate="2016-01-07T21:58:41.560" Score="0" ViewCount="2165" Body="&lt;p&gt;I want to use an Arduino Uno, a seven segment LED display (four digits) and the &lt;a href=&quot;http://playground.arduino.cc/Main/SevenSegmentLibrary&quot; rel=&quot;nofollow&quot;&gt;SevSeg library&lt;/a&gt;, to see temperature and humidity (alternatively). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all I try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #define COMMON_ANODE 1&#xA;  #define COMMON_CATODE 0&#xA;  #include &quot;DHT.h&quot;&#xA;  #define DHTPIN A5     // pin analogico che legge i dati&#xA;  #define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;  #include &quot;SevSeg.h&quot;&#xA;&#xA;  // Crea un'istanza dell'oggetto&#xA;  SevSeg sevseg;&#xA;  DHT dht(DHTPIN, DHTTYPE);&#xA;  unsigned long timer; // the timer&#xA;  unsigned long INTERVAL = 5000; // the repeat interval (30 seconds)&#xA;&#xA;  int segA = 6;   // Undicesimo PIN del display 7Segment x 4&#xA;  int segB = 2;   // Settimo PIN del display 7Segment x 4&#xA;  int segC = 10;  // Quarto PIN del display 7Segment x 4&#xA;  int segD = 12;  // Secondo PIN del display 7Segment x 4&#xA;  int segE = 13;  // Primo PIN del display 7Segment x 4&#xA;  int segF = 5;   // Decimo PIN del display 7Segment x 4&#xA;  int segG = 9;   // Quinto PIN del display 7Segment x 4&#xA;  int segDP = 11; // Terzo PIN del display 7Segment x 4&#xA;&#xA;  int digit1 = 7; // Dodicesimo PIN - PWM che Accende il primo digit&#xA;  int digit2 = 4; // Nono PIN - PWM che Accende il secondo digit &#xA;  int digit3 = 3; // Ottavo PIN - PWM che Accende il terzo digit &#xA;  int digit4 = 8; // Sesto PIN - PWM che Accende il quarto digit&#xA;&#xA;  void setup() &#xA;  {&#xA;    dht.begin();&#xA;    int numberOfDigits = 4; //Numero di cifre del display&#xA;&#xA;    // Inizializzo i PIN&#xA;    sevseg.Begin(COMMON_CATODE,digit1,digit2,digit3,digit4,segA,segB,segC,segD,segE,segF,segG,segDP);&#xA;    // Imposto la luminosità (valore da 0 a 100)&#xA;    sevseg.Brightness(90);&#xA;    timer = millis(); // start timer&#xA;  }&#xA;&#xA;  void loop() &#xA;  {&#xA;    if ((millis()-timer) &amp;gt; INTERVAL) {&#xA;      // Reset the timer and get/display the current temperature&#xA;      timer += INTERVAL;&#xA;      // Leggo dal sensore la temperatura&#xA;      float t = dht.readTemperature();&#xA;      float h = dht.readHumidity();&#xA;      //La converto in un numero intero a 4 cifre&#xA;      int a=t*100;&#xA;      sevseg.NewNum(a,2);&#xA;    }&#xA;        sevseg.PrintOutput();   &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works very well!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I cant see temperature (first) AND humidity (after) and again temperature (first) AND humidity (after)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried many ways but... nothing!! Can you help me?&lt;/p&gt;&#xA;" OwnerUserId="16185" LastEditorUserId="6936" LastEditDate="2016-01-10T16:26:45.210" LastActivityDate="2020-03-19T20:47:42.447" Title="Arduino thermometer and humidity display with 7 segment LED display" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19324" PostTypeId="2" ParentId="19323" CreationDate="2016-01-07T22:19:52.507" Score="1" Body="&lt;p&gt;You need to maintain a &lt;em&gt;state&lt;/em&gt; which tells your program whether you are displaying the temperature or the humidity.  Every time the timer expires you need to change from one state to the other, and then display the relevant value depending on what the state is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool displaying = false; // false = temperature, true = humidity&#xA;&#xA;void loop() {&#xA;    if ((millis()-timer) &amp;gt;= INTERVAL) {&#xA;        timer = millis();&#xA;        display = !display; // Switch between display values&#xA;&#xA;        if (display) {&#xA;            float h = dht.readHumidity();&#xA;            sevseg.NewNum(h * 100, 2);&#xA;        } else {&#xA;            float t = dht.readTemperature();&#xA;            sevseg.NewNum(t * 100, 2);&#xA;        }&#xA;    }&#xA;    sevseg.PrintOutput();   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-07T22:19:52.507" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19325" PostTypeId="2" ParentId="19308" CreationDate="2016-01-07T22:45:07.530" Score="1" Body="&lt;p&gt;I recommend you change the type of &lt;code&gt;incomingByte&lt;/code&gt; to &lt;code&gt;int&lt;/code&gt;, like was advised in the comments. Also, your null-termination is occurring past the end of &lt;code&gt;buf&lt;/code&gt;; change the condition in the &lt;code&gt;while&lt;/code&gt; statement to &lt;code&gt;i &amp;lt; buf_max - 1&lt;/code&gt;, so that one byte is left for the &lt;code&gt;null&lt;/code&gt;. Also use parentheses to separate those conditions, in the unlikely event there's some issue of precedence. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-07T22:45:07.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19326" PostTypeId="1" CreationDate="2016-01-08T00:10:23.650" Score="1" ViewCount="4325" Body="&lt;p&gt;I am trying to get the string (&quot;Enter an Integer : &quot;) to print to the serial, then have the user enter a string of numbers which is then converted to an array of chars then ints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the string will not display on the serial monitor when opened, and when the numbers are entered by the user, and  the conversion is done I need the string to be displayed again. So when the user inputs a number and presses enter it should be the end of that conversion, and prompt a new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int convert(void) {     &#xA;  while (Serial.available() &amp;gt; 0) {     &#xA;    char ch = Serial.read();&#xA;    if (ch &amp;gt;= '0' &amp;amp;&amp;amp; ch &amp;lt;= '9' || ch == '-') {&#xA;      // Collect digits, only works if minus is first. &#xA;      strValue[index] = ch;&#xA;      index++;&#xA;    } else {&#xA;      strValue[index] = '\0'; &#xA;      blinkRate = atoi(strValue);&#xA;      Serial.println(blinkRate);&#xA;      Serial.print(&quot;Enter integer : &quot;);&#xA;      index = 0;&#xA;    }&#xA;  }        &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16188" LastEditorUserId="10907" LastEditDate="2016-01-08T16:38:03.853" LastActivityDate="2016-01-10T16:26:18.463" Title="Print to console" Tags="|arduino-uno|serial|programming|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19327" PostTypeId="2" ParentId="19301" CreationDate="2016-01-08T00:50:56.733" Score="4" Body="&lt;p&gt;Measuring the peak-to-peak current and scaling the result will get you an answer which will at least go up and down with the magnitude of your average AC current, so yes it is NOT incorrect.  As you suggested it will be sensitive to noise from the sensor - in fact as you are taking the highest and lowest single readings the noise will always cause the measurement to be higher than actual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I think you could do better.  Given that the code is already having to take many samples (basically as fast as it can) for 100mS (which will sample 5 cycles of the waveform if it is 50Hz and 6 if it is 60Hz, depending on where you are in the world), then you could actually do the maths to measure the RMS value and by basing this on all of the signal the effect of the noise will be reduced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to know the ADC reading when there is no current &lt;code&gt;rZero&lt;/code&gt; (which should be around 511 but could be off a bit due to offset errors) - you could measure this with nothing connected to calibrate the sensor, or take a long term average even with the AC signal present.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the henrysbench tutorial points out it is important that the Arduino samples the signal at a high enough frequency (say 1000Hz - hence 100 samples for your 100mS sample duration)- the count of the number of times that the while loop executes &lt;code&gt;sampleCount&lt;/code&gt; will confirm if this still the case even with the extra computation time of this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if you increase the sample time please be careful that the &lt;code&gt;unsigned long rSquaredSum&lt;/code&gt; can't overflow, but I would avoid use of doubles within the while loop as they will definitely slow it down a LOT.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ac_read() {&#xA;  int rVal = 0;&#xA;  int sampleDuration = 100;       // 100ms&#xA;  int sampleCount = 0;&#xA;  unsigned long rSquaredSum = 0;&#xA;  int rZero = 511;                // For illustrative purposes only - should be measured to calibrate sensor.&#xA;&#xA;  uint32_t startTime = millis();  // take samples for 100ms&#xA;  while((millis()-startTime) &amp;lt; sampleDuration)&#xA;  {&#xA;    rVal = analogRead(A0) - rZero;&#xA;    rSquaredSum += rVal * rVal;&#xA;    sampleCount++;&#xA;  }&#xA;&#xA;  double voltRMS = 5.0 * sqrt(rSquaredSum / sampleCount) / 1024.0;&#xA;&#xA;  // x 1000 to convert volts to millivolts&#xA;  // divide by the number of millivolts per amp to determine amps measured&#xA;  // the 20A module 100 mv/A (so in this case ampsRMS = 10 * voltRMS&#xA;  double ampsRMS = voltRMS * 10.0;&#xA;  Serial.println(ampsRMS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2016-01-08T00:50:56.733" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19328" PostTypeId="2" ParentId="19326" CreationDate="2016-01-08T01:16:56.430" Score="1" Body="&lt;p&gt;The problem is, the Arduino serial monitor is way too crude to understand what you're trying to do.  Using a real terminal emulator (Teraterm for example) will probably give you better results (but you will also need to echo back the characters typed so you can see what you're typing) - either that or don't try and do things &quot;in-line&quot; like a prompt, instead print a message including the line feed (i.e., use &lt;code&gt;println()&lt;/code&gt; instead of &lt;code&gt;print()&lt;/code&gt;) so that the serial monitor can output a new line with the message text in it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-08T01:16:56.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19329" PostTypeId="1" CreationDate="2016-01-08T05:46:42.640" Score="1" ViewCount="867" Body="&lt;p&gt;I am not sure if this question has been asked before but here's what I wanted to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Arduino Nano, which I need to update with a new sketch. The plan is to be able to use another Arduino (maybe a Nano again), with an SD card reader and a sketch loaded as HEX file on it. Then connect both using a 4 pin RX/TX/5V/GND and upload the sketch from the transmitter to the receiver. Is it possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to do this; I know I can use one Arduino as an ISP to update other, but I am thinking of streaming the hex file to the other. Has anyone done this, any hints would be extremely helpful.&lt;/p&gt;&#xA;" OwnerUserId="16197" LastEditorUserId="19409" LastEditDate="2016-10-15T20:06:47.837" LastActivityDate="2016-10-15T20:06:47.837" Title="Field Programming a Arduino with another Arduino with SD card over RX/TX lines" Tags="|arduino-nano|uploading|firmware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19330" PostTypeId="1" CreationDate="2016-01-08T06:05:12.627" Score="7" ViewCount="11849" Body="&lt;p&gt;I'm new to the Arduino and do not quite understand the &lt;code&gt;F()&lt;/code&gt; macro yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my code, I have a &lt;code&gt;String&lt;/code&gt;, and as I want to transfer it via WebServer, I need to write it to the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow I need to convert the &lt;code&gt;String&lt;/code&gt;, to fit it into the &lt;code&gt;fastrprintln()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String weather_json = getWeatherData();&#xA;char weather[2048];&#xA;weather_json.toCharArray(weather,2048);&#xA;client.fastrprintln(F(weather));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any idea for me?&lt;/p&gt;&#xA;" OwnerUserId="16199" LastEditorUserId="6936" LastEditDate="2016-01-08T12:12:30.287" LastActivityDate="2016-01-08T12:12:30.287" Title="Store String using F() Macro" Tags="|memory-usage|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19331" PostTypeId="1" AcceptedAnswerId="19332" CreationDate="2016-01-08T04:09:45.817" Score="3" ViewCount="1067" Body="&lt;p&gt;I was wondering how much my Arduino I/O pin can output when it is set at &lt;strong&gt;Output&lt;/strong&gt; and is at &lt;strong&gt;High&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an &lt;strong&gt;Arduino Uno R3&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advanced.&lt;/p&gt;&#xA;" OwnerUserId="16198" OwnerDisplayName="Bryan" LastActivityDate="2016-01-08T06:21:35.400" Title="What is the Maximum Current an Arduino can Supply?" Tags="|current|input|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19332" PostTypeId="2" ParentId="19331" CreationDate="2016-01-08T04:19:11.360" Score="6" Body="&lt;p&gt;40.0mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino UNO Digital IO pins are connected directly to the IO pins on the ATMEGA328P processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From page 299 of the &lt;a href=&quot;https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwi3p_GkrpnKAhWEQyYKHVBiCJUQFggjMAA&amp;amp;url=http%3A%2F%2Fwww.atmel.com%2Fimages%2Fatmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&amp;amp;usg=AFQjCNEfBUXFG85G6huz6IpUbv0LQqhvGQ&amp;amp;sig2=9zwktRebt6GXlhApMf7Zzg&quot; rel=&quot;noreferrer&quot;&gt;data sheet&lt;/a&gt; for that processor...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Brff1.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Brff1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that there is also a total current limit for all output pins combined, and that the voltage starts to drop as the current goes up. &lt;/p&gt;&#xA;" OwnerUserId="7859" OwnerDisplayName="bigjosh" LastActivityDate="2016-01-08T04:19:11.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19333" PostTypeId="1" CreationDate="2016-01-08T06:40:04.780" Score="0" ViewCount="3567" Body="&lt;p&gt;Consider:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UNzrv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UNzrv.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I having a problem in compiling in extern &quot;C&quot; code in the Arduino IDE 1.6.7 which I don't have on version 1.6.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: conflicts with new declaration with 'C' linkage&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is complaining about the lines containing &lt;code&gt;loop()&lt;/code&gt; and &lt;code&gt;start_timer(void);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __cplusplus&#xA;extern &quot;C&quot; {&#xA;#endif&#xA;&#xA;void start_timer(void);&#xA;&#xA;#ifdef __cplusplus&#xA;}&#xA;#endif&#xA;&#xA;&#xA;void start_timer(void)&#xA;{&#xA;    Serial.println(&quot;2&quot;);&#xA;    Serial.begin(9600);&#xA;    delay(2000);&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;    start_timer();&#xA;    Serial.println(&quot;4&quot;);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(&quot;1&quot;);&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15686" LastEditorUserId="510" LastEditDate="2017-11-06T23:27:48.327" LastActivityDate="2017-11-06T23:27:48.327" Title="Why can't the new Arduino IDE 1.6.7 compile extern &quot;C&quot;?" Tags="|programming|c++|arduino-ide|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19334" PostTypeId="1" CreationDate="2016-01-08T06:26:07.880" Score="2" ViewCount="912" Body="&lt;p&gt;I am using the following &lt;a href=&quot;https://code.google.com/p/simple-modbus/&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/simple-modbus/&lt;/a&gt; arduino master library code. In order to communicate with my industrial drive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All seems right but I am getting some weird errors. I am using the arduino master code as it is. With just the difference in modbus_construct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the error I am getting&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; This report would have more information with&#xA; &quot;Show verbose output during compilation&quot;&#xA;&#xA;&#xA;enabled in File &amp;gt; Preferences.&#xA;Arduino: 1.0.6 (Windows 7), Board: &quot;Arduino Uno&quot;&#xA;In file included from SimpleModbusMasterArduino.ino:29:&#xA;&#xA;C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:131: error: expected ',' or '...' before numeric constant&#xA;In file included from C:\Program Files\Arduino\hardware\arduino\cores\arduino/HardwareSerial.h:28,&#xA;                 from C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:215,&#xA;                 from SimpleModbusMasterArduino.ino:29:&#xA;C:\Program Files\Arduino\hardware\arduino\cores\arduino/Stream.h:57: error: expected ',' or '...' before numeric constant&#xA;In file included from SimpleModbusMasterArduino.ino:29:&#xA;C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:222: error: expected ',' or '...' before numeric constant&#xA;SimpleModbusMasterArduino:37: error: 'Packet' does not name a type&#xA;SimpleModbusMasterArduino.ino: In function 'void setup()':&#xA;SimpleModbusMasterArduino:45: error: 'packets' was not declared in this scope&#xA;SimpleModbusMasterArduino:45: error: 'READ_HOLDING_REGISTERS' was not declared in this scope&#xA;SimpleModbusMasterArduino:45: error: 'modbus_construct' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SimpleModbusMasterArduino:49: error: 'modbus_configure' was not declared in this scope SimpleModbusMasterArduino.ino: In function 'void loop()': SimpleModbusMasterArduino:56: error: 'modbus_update' was not declared in this scope&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleModbusMaster.h&amp;gt;&#xA;&#xA;/*&#xA;   The example will use packet1 to read a register from address 0 (the adc ch0 value)&#xA;   from the arduino slave (id=1). It will then use this value to adjust the brightness&#xA;   of an led on pin 9 using PWM.&#xA;   It will then use packet2 to write a register (its own adc ch0 value) to address 1 &#xA;   on the arduino slave (id=1) adjusting the brightness of an led on pin 9 using PWM.&#xA;*/&#xA;&#xA;//////////////////// Port information ///////////////////&#xA;#define baud 115200&#xA;#define timeout 1000&#xA;#define polling 200 // the scan rate&#xA;#define retry_count 10&#xA;&#xA;// used to toggle the receive/transmit pin on the driver&#xA;#define TxEnablePin 2 &#xA;#define LED 13&#xA;&#xA;&#xA;// The total amount of available memory on the master to store data&#xA;#define TOTAL_NO_OF_REGISTERS 8&#xA;#define TOTAL_NO_OF_CONSTANTS 1&#xA;&#xA;// This is the easiest way to create new packets&#xA;// Add as many as you want. TOTAL_NO_OF_PACKETS&#xA;// is automatically updated.&#xA;enum&#xA;{&#xA;  PACKET1,&#xA;  //PACKET2,&#xA;  TOTAL_NO_OF_PACKETS // leave this last entry&#xA;};&#xA;&#xA;// Create an array of Packets to be configured&#xA;Packet packets[TOTAL_NO_OF_PACKETS];&#xA;&#xA;// Masters register array&#xA;unsigned int regs[TOTAL_NO_OF_REGISTERS];&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialize each packet&#xA;  modbus_construct(&amp;amp;packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0x3000, 8, 0);&#xA;  //modbus_construct(&amp;amp;packets[PACKET2], 2, READ_HOLDING_REGISTERS, 0x3000, 8, 16);&#xA;&#xA;  // Initialize the Modbus Finite State Machine&#xA;  modbus_configure(&amp;amp;Serial, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  modbus_update();&#xA;  Serial.println(regs[0]);&#xA;  //regs[0] = analogRead(0); // update data to be written to arduino slave&#xA;&#xA;  //analogWrite(LED, regs[0]&amp;gt;&amp;gt;2); // constrain adc value from the arduino slave to 255&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="topsy coder" LastActivityDate="2016-01-08T11:23:28.720" Title="Modbus master arduino code is throwing weird errors on upload" Tags="|rs485|modbus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19335" PostTypeId="1" CreationDate="2016-01-08T07:21:22.937" Score="2" ViewCount="1609" Body="&lt;p&gt;we are using Arduino W5100 Ethernet shield. The code is to try DHCP first and if that fails, then try the static IP. we do the Ethernet Initialization and stop every time.  The library is Arduino Ethernet library.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;when we try with a wireless router, everything works and we are able to contact our web server.&lt;/li&gt;&#xA;&lt;li&gt;Now the wireless router is connected to a switch.&#xA;switch &amp;lt;======&gt; router &amp;lt;=====&gt; W5100&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;if we try to send data using the switch directly, DHCP fails, whereas a laptop using the same cable works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question is, even Arduino Library has DHCP functionality, why should a laptop work where the shield is failing? The network and topology and rules should be same for both the laptop and W5100 shield. Anything we can do to debug this issue more? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit1 : -  Switch which we are using is &lt;a href=&quot;http://searchnetworking.techtarget.com/tip/Layer-3-switches-explained&quot; rel=&quot;nofollow&quot;&gt;L3 in nature&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the code which we are using at present. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    while(1) {&#xA;&#xA;        KDEBUG(&quot;wait 10 seconds...\r\n&quot;);&#xA;        // wait 10 seconds&#xA;        for(loop = 10; loop &amp;gt; 0 ; loop--) {&#xA;            wait_millis(1000);&#xA;        }&#xA;&#xA;        KDEBUG(&quot;Try transmitting data on ethernet...\r\n&quot;);&#xA;        transmit_data();&#xA;&#xA;    }&#xA;&#xA;    return 0 ;&#xA;&#xA;}&#xA;&#xA;void wait_millis(uint16_t num) {&#xA;&#xA;    for(; num &amp;gt; 0 ; num-- ) {&#xA;        _delay_ms(1) ;&#xA;    }&#xA;&#xA;}&#xA;&#xA;// transmit data using Ethernet&#xA;static uint8_t transmit_data() {&#xA;&#xA;    char request[256];&#xA;    uint8_t status = 0  ;&#xA;&#xA;    // reset counter&#xA;    counter = (counter &amp;gt; 254) ? 0 : counter ;&#xA;&#xA;    memset(&amp;amp;request[0], 0 , sizeof(request));&#xA;    memset(&amp;amp;bencode[0], 0 , sizeof(bencode));&#xA;&#xA;&#xA;    wait_millis(5000);&#xA;    // try DHCP&#xA;    if (Ethernet.begin(mac_address) == 0) {&#xA;        KDEBUG(&quot;Failed to configure Ethernet using DHCP \r\n&quot;);&#xA;        // use static IP. no return code.&#xA;        Ethernet.begin(mac_address, ip_address);&#xA;&#xA;    } else {&#xA;        KDEBUG(&quot; Got lease from DHCP \r\n&quot;);&#xA;    }&#xA;&#xA;    // wait for ethernet to initialize:&#xA;    wait_millis(5000);&#xA;&#xA;    // we got a connection?&#xA;    status = client.connect(server, port) ;&#xA;    KDEBUGF(&quot;ethernet client  status= %d \r\n&quot;, status);&#xA;    if(!status) {&#xA;        goto quit ;&#xA;    }&#xA;&#xA;&#xA;        KDEBUG(&quot;connected \n&quot;);&#xA;    // create an HTTP request&#xA;    strcat(request, &quot;GET /api/gl868.php?data=&quot;);&#xA;    strcat(request,bencode);&#xA;    // 12 chars&#xA;    strcat(request,&quot; HTTP/1.1 \r\n&quot;);&#xA;    // 25 chars&#xA;    strcat(request,&quot;Host: &quot;);&#xA;    strcat(request,server);&#xA;    strcat(request,&quot; \r\n&quot;);&#xA;&#xA;    // send GET request&#xA;    client.println(request);&#xA;    _delay_ms(1);&#xA;    client.println() ;&#xA;&#xA;    wait_millis(1000);&#xA;    client.stop();&#xA;    wait_millis(1000);&#xA;&#xA;    if(client.connected()) {&#xA;        client.stop();&#xA;    }&#xA;&#xA;    return 1 ;&#xA;&#xA;quit:&#xA;&#xA;    wait_millis(100);&#xA;    if(client.connected()) {&#xA;        client.stop();&#xA;    }&#xA;&#xA;    return 0 ;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16206" OwnerDisplayName="srj0408" LastEditorUserId="16206" LastEditDate="2016-01-08T12:14:00.083" LastActivityDate="2016-01-08T16:38:32.267" Title="W5100 Ethernet shield DHCP fails with a Switch" Tags="|ethernet|networking|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19336" PostTypeId="2" ParentId="19335" CreationDate="2016-01-08T08:25:41.187" Score="1" Body="&lt;p&gt;A certain way to debug this is to use &lt;a href=&quot;http://www.tcpdump.org/tcpdump_man.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;tcpdump&lt;/code&gt;&lt;/a&gt; to capture network packets from both Arduino and your laptop and check the differences. I would start by looking for &lt;code&gt;DHCPDISCOVER&lt;/code&gt; packet that Arduino should be sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simpler way would be to check DHCP server logs to see how the communication looks like from server's perspective. Here, you should be looking for lines which have the MAC address of your Arduino shield. The success of this approach will depend of the verbosity of the DHCP server you're using.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-01-08T08:25:41.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19337" PostTypeId="2" ParentId="19330" CreationDate="2016-01-08T09:12:31.140" Score="11" Body="&lt;p&gt;The Arduino core macro &lt;a href=&quot;http://playground.arduino.cc/Learning/Memory&quot; rel=&quot;noreferrer&quot;&gt;F()&lt;/a&gt; takes a string literal and forces the compiler to put it in program memory. This reduces the amount of SRAM needed as the string is not copied to a data memory buffer. Special functions are required to access the data stored in program memory. The Arduino core hides a lot of the typical usages such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;Hello world&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Further details of the low level access program memory access may be found in the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/pgmspace.html&quot; rel=&quot;noreferrer&quot;&gt;AVR GCC libc&lt;/a&gt; documentation. The F() macro is &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/WString.h#L38&quot; rel=&quot;noreferrer&quot;&gt;defined&lt;/a&gt; as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class __FlashStringHelper;&#xA;#define F(string_literal) (reinterpret_cast&amp;lt;const __FlashStringHelper*&amp;gt;(PSTR(string_literal)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The FlashStringHelper class is used to help the compiler recognize this type of string literal when passed to Arduino functions. Below are some examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// String constructor with program memory string literal&#xA;String::String(const __FlashStringHelper *str);&#xA;&#xA;// Print (Serial, etc) of program memory string literal&#xA;size_t Print::print(const __FlashStringHelper *);&#xA;size_t Print::println(const __FlashStringHelper *);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should not use the Arduino core F() macro with anything other than a string literal. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-08T09:20:32.187" LastActivityDate="2016-01-08T09:20:32.187" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19338" PostTypeId="2" ParentId="19334" CreationDate="2016-01-08T09:15:23.517" Score="1" Body="&lt;p&gt;Your issue is that you define constants, such as &lt;code&gt;timeout&lt;/code&gt;, which are &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h&quot; rel=&quot;nofollow&quot;&gt;widely used&lt;/a&gt; in Arduino library as parameter names. After preprocessing your definitions, correct code in &quot;Arduino.h&quot; such as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long 1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No wonder the latter line fails to compile.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to find unique names for your defines, or use constant variables instead.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastEditorUserId="13327" LastEditDate="2016-01-08T11:23:28.720" LastActivityDate="2016-01-08T11:23:28.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19340" PostTypeId="2" ParentId="19335" CreationDate="2016-01-08T10:18:04.147" Score="1" Body="&lt;p&gt;If I understand your connection...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Device over wifi to router works.&lt;/li&gt;&#xA;&lt;li&gt;Wired, via a switch to router does not?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;DHCP is clearly switched on for WLAN, is it switched on for LAN?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I always use fixed IP for such projects, with a default value that can be reset so that I can always find my device. I change the IP (and/or MAC) via a serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="16207" LastEditorUserId="6936" LastEditDate="2016-01-08T16:38:32.267" LastActivityDate="2016-01-08T16:38:32.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19341" PostTypeId="1" AcceptedAnswerId="19342" CreationDate="2016-01-08T11:25:35.220" Score="4" ViewCount="507" Body="&lt;p&gt;I want to use an Arduino Yún as a kind of outdoor weather station. I want to supply the power for the Yún with a 5V USB-Charger. Using a normal USB cable everything works fine. But as the weather station shall be far from the next power socket, I made the USB cable about 10 meters longer. Now the Yún does not power up any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anybody an idea why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I use a 12 V power supply and a 7805 power converter instead?&lt;/p&gt;&#xA;" OwnerUserId="16209" LastEditorUserId="13327" LastEditDate="2023-03-30T11:32:32.473" LastActivityDate="2023-03-30T11:32:32.473" Title="Power Supply Problem with Arduino Yún: Using a long USB cable" Tags="|power|arduino-yun|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="19342" PostTypeId="2" ParentId="19341" CreationDate="2016-01-08T11:41:57.757" Score="4" Body="&lt;p&gt;The USB specification limits the length of a cable between two devices to 5 meters. When you make a longer cable, you're going out of spec, which means it is not guaranteed to work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're only supplying power, the issue is (as you have guessed) the voltage drop in the cable. However, the voltage drop will depend on how much current Arduino is consuming at any given moment. Supplying it with a higher voltage without a converter is dangerous, because it will lead to overvoltage you won't be able to control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest trying &lt;a href=&quot;https://raspberrypi.stackexchange.com/questions/39066/usb-cables-why-are-some-of-them-bad-for-raspberry-pi/39080&quot;&gt;better cables&lt;/a&gt; first: thicker and stiffer cables have thicker wires, and may have less voltage drop. You can also make your own cable (provided you can solder) using only two thick wires for power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ultimate solution, like you said yourself, is to deliver higher voltage over the wire (12V would do) and install a power converted (12V to 5V) near your Arduino. That way, the voltage drop in 5V line will be small, and the voltage drop in 10m 12V line will be compensated by the converter. Actually, the intermediate voltage may be higher: you can simply drop a mains line (220V or whatever you have) to your weather station and place the same USB charger near the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2016-01-08T11:57:20.287" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19343" PostTypeId="2" ParentId="19217" CreationDate="2016-01-08T12:14:02.830" Score="1" Body="&lt;p&gt;The short answer is &lt;strong&gt;NO&lt;/strong&gt;, unless you have solid experience with microelectronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding documentation for a module you take out of a commercial device is hard to impossible. Chances are, that module is specific to Garmin, and even if it isn't, it's certainly &lt;a href=&quot;https://en.wikipedia.org/wiki/End-of-life_%28product%29&quot; rel=&quot;nofollow&quot;&gt;EOL&lt;/a&gt; by now, with no support whatsoever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if you do find the spec, there is a high chance that you'll have to write a software library to support it on Arduino. Don't expect the supplier to share the code they gave to Garmin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to put together and debug this project, you will need quite some equipment:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;oscilloscope to debug the electrical interface&lt;/li&gt;&#xA;&lt;li&gt;soldering station to solder small pins properly&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Like people said in comments, this equipment alone will cost much more than a brand-new GPS receiver.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-01-08T12:14:02.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19344" PostTypeId="1" CreationDate="2016-01-08T12:32:10.880" Score="2" ViewCount="437" Body="&lt;p&gt;I have to build a wireless sensor network with arduinos on my project. It does not need to be a mesh network, but it needs to have self healing capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to use something cheaper than XBees. I tried the NRF24L01 with maniacbug's, TMRh20's and MySensors' libraries. However they aren't solving the problem and I'm wasting a ton of time trying to figure out how to make them work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing, I need a lot of repeater nodes between the base and the sensors because the office is 2 km far from the monitoring area and some of these libraries have a limitation of 5 level deep network, so I'd have max 4 repeaters between the base and sensor, which is bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the last, my project is going to be fine with 15 sensors for now, but it'll have 500-1000 nodes in a couple of months and most of these libraries assign 8 bit addresses (256 nodes), which does not cover that amount of nodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you suggest?&lt;/p&gt;&#xA;" OwnerUserId="16211" LastActivityDate="2016-01-08T17:00:11.837" Title="Module and library for self healing large sensor network" Tags="|sensors|arduino-nano|nrf24l01+|rf|networking|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19345" PostTypeId="2" ParentId="17891" CreationDate="2016-01-08T12:56:00.250" Score="2" Body="&lt;p&gt;According to your plot, the pulse length is 50 microseconds. Typical mechanical relay switching time is 10 milliseconds, which is 200 times longer. It's next to impossible that the pulse is due to your software powering the relay back on for a moment, since the relay simply could not react to such a short input pulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yeah, it's just a bounce. You can safely ignore it in most cases, unless you're counting events or doing something similar. In the latter case, there are both hardware and software &lt;a href=&quot;https://en.wikipedia.org/wiki/Switch#Contact_bounce&quot; rel=&quot;nofollow&quot;&gt;debouncing&lt;/a&gt; techniques, which share the basic idea of a low-pass filter.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-01-08T12:56:00.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19346" PostTypeId="1" AcceptedAnswerId="69765" CreationDate="2016-01-08T14:43:14.857" Score="5" ViewCount="3034" Body="&lt;p&gt;I know it's pretty standard to set up an Arduino system as a BLE client, and use something like an app running on a smartphone as the GATT server, which receives the data and does something with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my scenario I have a BLE sensor that is not connected directly to the Arduino system, and I want the Arduino to be able to respond to the sensor output (a wearable accelerometer) and, for example, initiate various lighting sequences depending on the data being received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would prefer not to introduce a third component (ie: mobile device as GATT server) into the equation. I'd like for the Arduino to listen to the remote device's services and characteristics, analyze the incoming data and then make some decisions about what LEDs to illuminate based on that analysis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can an Arduino run as a GATT server? &lt;/p&gt;&#xA;" OwnerUserId="16213" LastEditorUserId="4628" LastEditDate="2017-07-03T03:48:47.223" LastActivityDate="2019-11-01T10:57:01.653" Title="Can an Arduino act as a GATT Server (Bluetooth LE)" Tags="|bluetooth|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19347" PostTypeId="1" CreationDate="2016-01-08T16:08:38.747" Score="3" ViewCount="11177" Body="&lt;p&gt;I get a compile error when I try to set a different font in Adafruit GFX on a TFT display on my Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm testing a new TFT shield for Arduino equipped with an ILI9341 by using the Adafuit GFX libraries and examples. The test program supplied with the library works fine out of the box displaying text and all kind of drawings on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the standard font built into the Adafruit GFX library is &quot;blocky&quot; to save memory space. They do provide other fonts, but I get an error when I try to invoke them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The segment of code that throws the compile error is this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long testText1() {&#xA;  tft.setFont();    // When I remove this line the sketch compiles OK&#xA;  tft.fillScreen(BLACK);&#xA;  tft.setCursor(0, 50);&#xA;  tft.setTextColor(RED);&#xA;  tft.setTextSize(13);&#xA;  tft.println(&quot;1234&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When compiling I get this error: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;error: ‘class Adafruit_ILI9341_8bit_AS’ has no member named ‘setFont’&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to Adafruit's GFX manual, the &lt;code&gt;setFont()&lt;/code&gt; procedure allows to define a new font or revert to the standard one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I examined the libraries and nowhere could I find a procedure to select a font, yet the example has declarations like these below, so changing fonts should be possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX_AS.h&amp;gt;&#xA;#include &amp;lt;Adafruit_ILI9341_8bit_AS.h&amp;gt;&#xA;#include &amp;lt;Font16.h&amp;gt;&#xA;// #include &amp;lt;Font32.h&amp;gt;&#xA;// #include &amp;lt;Font64.h&amp;gt;&#xA;// #include &amp;lt;Font72.h&amp;gt;&#xA;#include &amp;lt;Font7s.h&amp;gt;&#xA;#include &amp;lt;Load_fonts.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to load the 7segment font with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tft.setFont(&amp;amp;Font7s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anybody have experience to share loading these fonts?&lt;/p&gt;&#xA;" OwnerUserId="16218" LastEditorUserId="6936" LastEditDate="2016-01-10T05:38:19.913" LastActivityDate="2017-08-28T16:24:29.603" Title="How can I load fonts into Adafruit GFX for TFT display (ILI9341)" Tags="|arduino-uno|adafruit|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19348" PostTypeId="2" ParentId="18667" CreationDate="2016-01-08T16:26:31.007" Score="-1" Body="&lt;p&gt;I don't know what this &quot;invalid&quot; means I am getting this on every boot but my device is working fine. I have tested downloading webpages and it's working. So maybe just ignore this. use cutecom it works there, didn't work in minicom maybe because of carriage return absent.&lt;/p&gt;&#xA;" OwnerUserId="16220" LastEditorUserId="16220" LastEditDate="2016-01-09T18:01:22.040" LastActivityDate="2016-01-09T18:01:22.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19349" PostTypeId="2" ParentId="19304" CreationDate="2016-01-08T16:37:52.220" Score="3" Body="&lt;p&gt;You mentioned 2 items: the supply voltage to the Arduino and scaling up to 24V output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the supply voltage you have available is 24V, then I would suggest you look for a DC-DC converter that scales down to 12V. Or, if you are looking to design your own PCB then perhaps use a 78xx voltage regulator. The 78xx are 3 pin devices and only require 2 caps to operate - I suppose a heat sink will not be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To scale up the outputs to 24V I would suggest one of the following options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Relay board / &#xA;These will take the 5V from your Arduino and close a mechanical switch. If the relays are good quality they will go on for ages. And you can switch loads from 0 to 240V and more, DC or AC.&#xA;Plus of the relays are sturdiness and that they are quite forgiving for short current overloads. Minus are that relays are &quot; slow&quot; when compared to semiconductors and they can arce when the contacts open - especially when driving inductive loads and that. Arcing will wear down your contacts and in extreme cases generate EMI that might interfere with your electronics. Arcing can be remediated in AC with a capacitor accross the contacts or in DC with a flyback diode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you will make your own PCB don't forget the flyback diode on pins connecting to the relay coils or you will possibly fry the Arduino due to a voltage spike!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many of these boards are available on the web, so it's a quick solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Optocouplers / &#xA;Also a good option. Functionally they act as a relay. They are a bit less forgiving to current overloads, so chose them wisely.&#xA;They are silent and fast acting. Available for AC or DC and up to 600V.&#xA;Minus side is that the tend to be a bit more expensive than relay boards. I'm talking about industrial grade devices and not some el-cheapo web site :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) MOSFETS or Bipolar transistors / &#xA;If you are designing your PCB then this could be an option.&#xA;Here you can use a MOSFET or a PNP transistor of the adequate ratings and you would be done. Though maybe considering yur time investment the options above could be less expensive in the end. &#xA;I this case you get complete control of PCB layout which might be a consideration.&#xA;If you go this way, don't forget to add a flyback diode to the output of these devices to protect from spikes when switching inductive loads (= motors, solenoids).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A big advantage of Relays and Optocouplers is the galvanic isolation they provide, both from the load to the board as between the loads themselves. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you could supply more detailed specs of the loads, environments etc I can help you narrow down your choices.&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-08T16:37:52.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19350" PostTypeId="2" ParentId="19265" CreationDate="2016-01-08T16:47:42.513" Score="2" Body="&lt;p&gt;In these cases it helps to break down the problem in pieces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the internal LED on pin 13 blinks with your code it means that the software side is OK so far (code, Arduino type, compiling, uploading etc), so I suggest looking at the physical side of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have a multimeter available? If so, connect it between pin 13 and ground and it should show you if the output works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, is the LED working? When you connect it between 5V and GND (with a resistor!) it should light up.&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-08T16:47:42.513" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19351" PostTypeId="2" ParentId="19344" CreationDate="2016-01-08T17:00:11.837" Score="2" Body="&lt;p&gt;A few thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;For ~$20 per unit, the 1mW Digimesh modules will take care of reliable mesh networking plus provide a high degree of configurability and scalability. Depending on the budget for your sensor nodes this might be better than &quot;wasting a ton of time&quot; messing with bare-bones hardware and third party code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Constrain the mesh network within the &quot;monitoring area&quot; and set up dedicated point-to-point links (with higher power and directional antennae) between it and your office. Set up two or three if you want redundancy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can't afford better hardware but have time to spare, consider reading up on mesh protocols and implementing one you think best fits your project. Many of them are reasonably simple if you are not pushing for maximum efficiency or performance.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16223" LastActivityDate="2016-01-08T17:00:11.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19352" PostTypeId="1" AcceptedAnswerId="19353" CreationDate="2016-01-08T17:52:16.210" Score="0" ViewCount="153" Body="&lt;p&gt;I was wondering if Arduino digital pin can receive binary data. For example, I might want one Arduino to send another Arduino a binary code. If the code is &lt;code&gt;01&lt;/code&gt; it would turn a red led on, if it was &lt;code&gt;11&lt;/code&gt; it would turn green on, etc. I would like to do this so that I don't have to use a lot of digital pins. Is this possible with Arduino or not?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="37" LastEditDate="2016-01-08T20:42:12.187" LastActivityDate="2016-01-09T02:31:42.923" Title="Arduino recieving binary" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19353" PostTypeId="2" ParentId="19352" CreationDate="2016-01-08T18:29:54.780" Score="2" Body="&lt;p&gt;Pretty much anything is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a method known as &lt;em&gt;bit banging&lt;/em&gt; which toggles a generic IO pin to create a protocol, and read changes on another generic IO pin to read in the data of a protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is in creating a protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately that has all been done for you - the SoftwareSerial library. It will create a bit banged version of the RS232 serial protocol using any combination of IO pins to transfer data between devices.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-08T18:29:54.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19354" PostTypeId="2" ParentId="19347" CreationDate="2016-01-08T20:17:10.023" Score="0" Body="&lt;p&gt;Looking further into documentation on the Adafruit website they indicate that indeed, their GFX library published on GitHub does not handle different fornts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Case closed :-)&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-08T20:17:10.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19355" PostTypeId="1" CreationDate="2016-01-08T20:40:47.133" Score="2" ViewCount="1272" Body="&lt;p&gt;This code is used for communication between the Glediator interface and a NeoPixel Matrix, but I receive an error saying 'UCSR0A' is not defined within the scope.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UCSR0A |= (1&amp;lt;&amp;lt;U2X0);                                &#xA;UCSR0B |= (1&amp;lt;&amp;lt;RXEN0)  | (1&amp;lt;&amp;lt;TXEN0) | (1&amp;lt;&amp;lt;RXCIE0);   &#xA;UCSR0C |= (1&amp;lt;&amp;lt;UCSZ01) | (1&amp;lt;&amp;lt;UCSZ00)             ; &#xA;UBRR0H = 0;&#xA;UBRR0L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any feedback is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16229" LastEditorUserId="6936" LastEditDate="2016-01-10T16:25:56.520" LastActivityDate="2016-01-10T16:25:56.520" Title="UART error can not compile on Arduino Yun (ATmega32u4)" Tags="|compile|uart|baud-rate|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19356" PostTypeId="2" ParentId="19355" CreationDate="2016-01-08T20:52:46.210" Score="1" Body="&lt;p&gt;Those register names are for a different chip (maybe the ATMega328P of the Uno).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to use the &lt;em&gt;right&lt;/em&gt; register names.  Start by reading the datasheet for the ATMega32U4.  You might find that the register names are UCSR1A etc, or UCSRA or something like that instead of UCSR0A.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-08T20:52:46.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19357" PostTypeId="1" AcceptedAnswerId="19358" CreationDate="2016-01-08T21:03:28.513" Score="2" ViewCount="1534" Body="&lt;p&gt;I'm building an automatic door lock, which is moved by a servo ( &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00MPW2N6K&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;this one&quot;&gt;this one&lt;/a&gt; ). However, I want to still make it possible to open the lock manually, but it's not possible if the servo is attached to the lock mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have ideas on how to go around this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a diagram of the lock mechanism&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HlkLP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HlkLP.png&quot; alt=&quot;Lock mechanism diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16230" LastEditorUserId="16230" LastEditDate="2016-01-08T21:58:31.697" LastActivityDate="2016-01-08T22:15:27.547" Title="Automatic/manual door lock with servo" Tags="|servo|" AnswerCount="1" CommentCount="7" ClosedDate="2016-01-17T15:14:23.780" ContentLicense="CC BY-SA 3.0" />
  <row Id="19358" PostTypeId="2" ParentId="19357" CreationDate="2016-01-08T22:15:27.547" Score="1" Body="&lt;p&gt;So it's actually the worm gear that is causing your problem, since that can't be reverse driven by the cogs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest option, I think, would be to have the middle cog normally separated from the worm gear and only re-engage it when you need to drive the mechanism with the servo.  You could maybe use a second servo to move it into the right place, or maybe a solenoid, or something along those lines. Have it slide along a short track or slot with a spring to ensure it disengages when the solenoid is released.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-08T22:15:27.547" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19359" PostTypeId="1" AcceptedAnswerId="19362" CreationDate="2016-01-08T23:27:29.243" Score="6" ViewCount="7837" Body="&lt;p&gt;I use an Arduino and a 9 DOF sensor (gyroscope, accelerometer and magnetometer) and I'm trying to use the pitch, roll and yaw that the sensor gives me to rotate an object in unity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to correctly compute pitch and roll (the z and x axis in unity) from the accelerometer but it seems that I can't get the Yaw right. By that I mean that when I rotate my sensor pitch or roll it rotates my yaw too, in a weird way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Code in the arduino to get the heading&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void getHeading(void)&#xA;{&#xA;  heading=180*atan2(Mxyz[0],Mxyz[1])/PI;&#xA;  if(heading &amp;lt;0) heading +=360;&#xA;}&#xA;&#xA;void getTiltHeading(void)&#xA;{&#xA;  //float pitch = asin(-Axyz[0]);&#xA;  //float roll = asin(Axyz[1]/cos(pitch));&#xA;  float pitch = atan( Axyz[0] / sqrt( Axyz[1] * Axyz[1] + Axyz[2] * Axyz[2] ) );&#xA;  float roll = atan( Axyz[1] / sqrt(Axyz[0] * Axyz[0] + Axyz[2] * Axyz[2]));&#xA;&#xA;  float xh = Mxyz[0] * cos(pitch) + Mxyz[2] * sin(pitch);&#xA;  float yh = Mxyz[0] * sin(roll) * sin(pitch) + Mxyz[1] * cos(roll) - Mxyz[2] * sin(roll) * cos(pitch);&#xA;  float zh = -Mxyz[0] * cos(roll) * sin(pitch) + Mxyz[1] * sin(roll) + Mxyz[2] * cos(roll) * cos(pitch);&#xA;  tiltheading = 180 * atan2(yh, xh)/PI;&#xA;  if(yh&amp;lt;0)    tiltheading +=360;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Pitch and roll&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    float _Pitch  = (float)(180 / Math.PI * Math.Atan( m_ResultX / Math.Sqrt( m_ResultY * m_ResultY + m_ResultZ * m_ResultZ ) ) );&#xA;    float _Roll = (float)(180 / Math.PI * Math.Atan(m_ResultY / Math.Sqrt(m_ResultX * m_ResultX + m_ResultZ * m_ResultZ)));&#xA;    float _Yaw = (float)(m_TiltHeadingResult);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't hesitate to ask for details.&lt;/p&gt;&#xA;" OwnerUserId="16233" LastEditorUserId="6936" LastEditDate="2016-01-08T23:54:22.923" LastActivityDate="2018-10-29T20:43:09.307" Title="Compute yaw from magnetometer and accelerometer" Tags="|sensors|algorithm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19360" PostTypeId="2" ParentId="735" CreationDate="2016-01-08T23:55:38.160" Score="1" Body="&lt;p&gt;We have been using Arduino's to teach basic microcontroller concepts in classes focused on environmental monitoring &amp;amp; instrumentation, rather than just electronics:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://edwardmallon.wordpress.com/2015/12/22/arduino-uno-based-data-logger-with-no-soldering/&quot; rel=&quot;nofollow&quot;&gt;An Arduino UNO based Datalogger for the Classroom&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IDE abstracts away enough of the low level details that you can get students into programming quickly, while still exposing them to enough of hardware side of things. I am not sure what other platform would let us take true beginners so far, so quickly.&lt;/p&gt;&#xA;" OwnerUserId="16238" LastActivityDate="2016-01-08T23:55:38.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19361" PostTypeId="2" ParentId="19333" CreationDate="2016-01-08T23:59:13.867" Score="1" Body="&lt;p&gt;The compiler is telling you that there is a conflict between the &lt;em&gt;two&lt;/em&gt; definitions of start_timer(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal usage of extern &quot;C&quot; is in a header file for functions that are accessed from both C and C++. This actually has to do with how C++ handles names and overloading. Using extern &quot;C&quot; will use normal C name handling and C++ name mangling is turned off (together with overloading, etc). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see &lt;a href=&quot;https://stackoverflow.com/questions/31349865/compiler-error-for-conflicting-variable-declarations-conflicts-with-new-declar&quot;&gt;https://stackoverflow.com/questions/31349865/compiler-error-for-conflicting-variable-declarations-conflicts-with-new-declar&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-01-08T23:59:13.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19362" PostTypeId="2" ParentId="19359" CreationDate="2016-01-09T00:08:12.777" Score="3" Body="&lt;p&gt;I don't know how all your sensor's axis are lined up, but it looks like you should level the magnetometer readings by rotating them by &lt;code&gt;-pitch&lt;/code&gt; and &lt;code&gt;-roll&lt;/code&gt; to get back to the global reference frame, instead of rotating the magnetometer readings by the positive angles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, The pitch and roll angles in the code are both relative the horizon, not a set of euler angles that define a rotation between two states; because of this, they do not compose to rotate the magnetometer back into the global xy frame like I assume the equations are trying to do. The code is also only using &lt;code&gt;atan&lt;/code&gt; for pitch and roll instead of &lt;code&gt;atan2&lt;/code&gt;, so their range is only 180 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to make sure the rotation matrix you multiply your magnetometer reading by is based on the same conventions as the equations you use to get pitch and roll from the accelerometer, and that it cancels the observed rotation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this correctly, I recommend you read into &lt;a href=&quot;https://en.wikipedia.org/wiki/Euler_angles&quot; rel=&quot;nofollow&quot;&gt;euler angles&lt;/a&gt;. You might also try searching around for a good library that handles 9-DOF sensor fusion for you.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2016-01-09T18:06:10.940" LastActivityDate="2016-01-09T18:06:10.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19363" PostTypeId="2" ParentId="19355" CreationDate="2016-01-09T00:14:55.940" Score="0" Body="&lt;p&gt;You should be able to use Serial1 to access the USART. But...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that on the Yún, the Serial class refers to USB (CDC)&#xA;  communication; for TTL serial on pins 0 and 1, use the Serial1 class.&#xA;  The hardware serials of the ATmega32U4 and the AR9331 on the Yún are&#xA;  connected together and are used to communicate between the two&#xA;  processors. As is common in Linux systems, on the serial port of the&#xA;  AR9331 is exposed the console for access to the system, this means&#xA;  that you can access to the programs and tools offered by Linux from&#xA;  your sketch[1].&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please see below references for further details:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardYun&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardYun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/yun/pins_arduino.h#L40&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/yun/pins_arduino.h#L40&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/leonardo/pins_arduino.h#L363&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/variants/leonardo/pins_arduino.h#L363&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-09T00:14:55.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19364" PostTypeId="1" CreationDate="2016-01-09T00:29:13.473" Score="1" ViewCount="3429" Body="&lt;p&gt;I am trying to make a remote controlled robot with Arduino and the IR remote control is kinda weird. When I press a button, sometimes I get the right hex value, other time I get the hold value FFFFFF. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I implement some code so that I can, for example, run the motors as long as I hold the button or detect which button it was since the hold code is the same for all codes? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I know that the hold value is 0xFFFFFFFF, is there a function that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(any hex not 0xffff) func(OR?) (0xffffffff) = (any hex ...)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;( 0xfffff)           func (0xffffff)   != (0xffffff)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or do I need to implement some kind of state machine? It is kinda difficult with the &lt;code&gt;delay()&lt;/code&gt; as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, I'm using Keyes KY 022. What are the signal length times? (I don't have an oscilloscope).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe would be useful to set the press value to other? Or to ignore it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LE: And some code to test: one single key:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe other libraries are interrupting the timer... &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;IRremote.h&amp;gt;&#xA;    #define IR_PIN 11&#xA;    IRrecv irrecv(IR_PIN);&#xA;    decode_results results;&#xA;    long int Key;&#xA;    const unsigned long int UP = 0x00FF629D;&#xA;    const unsigned long int DOWN = 0x00FFA857;&#xA;    const unsigned long int LEFT = 0x00FF22DD;&#xA;    const unsigned long int RIGHT = 0x00FFC23D;&#xA;    const unsigned long int OK = 0x00FF02FD;&#xA;    const unsigned long int k1 = 0x00FF6897;// C101E57B&#xA;    const unsigned long int k2 = 0x00FF9867;// 97483BFB&#xA;    const unsigned long int k3 = 0x00FFB04F;// F0C41643&#xA;    const unsigned long int k4 = 0x00FF30CF;&#xA;    const unsigned long int k5 = 0x00FF18E7;&#xA;    const unsigned long int k6 = 0x00FF7A85;&#xA;    const unsigned long int k7 = 0x00FF10EF;&#xA;    const unsigned long int k8 = 0x00FF38C7;&#xA;    const unsigned long int k9 = 0x00FF5AA5;&#xA;    const unsigned long int STAR = 0x00FF42BD;&#xA;    const unsigned long int k0 = 0x00FF4AB5;&#xA;    const unsigned long int HASH = 0x00FF52AD;&#xA;    const unsigned long int HOLD = 0xFFFFFFFF;&#xA;&#xA;   void setup(){&#xA;   // put your setup code here, to run once:&#xA;      Serial.begin(9600);&#xA;      delay(2000); while (!Serial);&#xA;      irrecv.enableIRIn();&#xA;  //irrecv.blink13(true);&#xA;  //setup1(); From IRremoteInfo TAB   &#xA;   }&#xA;char buff[1000];&#xA;unsigned long int msg;&#xA;void processIR(unsigned long int msg)&#xA;{&#xA;  sprintf(buff, &quot;READ IR %x \n&quot;, results.value);&#xA;  Serial.print(buff);&#xA;  switch (msg)&#xA;  {&#xA;    case UP:&#xA;      Serial.println(&quot;UP&quot;);&#xA;      break;&#xA;    case DOWN:&#xA;      Serial.println(&quot;DOWN&quot;);&#xA;      break;&#xA;    case LEFT:&#xA;      Serial.println(&quot;LEFT&quot;);&#xA;      break;&#xA;    case RIGHT:&#xA;      Serial.println(&quot;RIGHT&quot;);&#xA;      break;&#xA;    case k1:&#xA;      Serial.println(&quot;k1&quot;);&#xA;      break;&#xA;    case k2:&#xA;      Serial.println(&quot;k2&quot;);&#xA;      break;&#xA;    case k3:&#xA;      Serial.println(&quot;k3&quot;);&#xA;      break;&#xA;    case k4:&#xA;      Serial.println(&quot;k4&quot;);&#xA;      break;&#xA;    case k5:&#xA;      Serial.println(&quot;k5&quot;);&#xA;      break;&#xA;    case k6:&#xA;      Serial.println(&quot;k6&quot;);&#xA;      break;&#xA;    case k7:&#xA;      Serial.println(&quot;k7&quot;);&#xA;      break;&#xA;    case k8:&#xA;      Serial.println(&quot;k8&quot;);&#xA;      break;&#xA;    case k9:&#xA;      Serial.println(&quot;k9&quot;);&#xA;      break;&#xA;    case STAR:&#xA;      Serial.println(&quot;STAR&quot;);&#xA;      break;&#xA;    case k0:&#xA;      Serial.println(&quot;k0&quot;);&#xA;      break;&#xA;    case HASH:&#xA;      Serial.println(&quot;HASH&quot;);&#xA;      break;&#xA;    case HOLD:&#xA;      Serial.println(&quot;HOLD&quot;);&#xA;      break;&#xA;      //case default:&#xA;      //    delay(500);&#xA;      //       irrecv.decode(&amp;amp;results);&#xA;      //       msg = results.value;&#xA;      //       processIR(msg);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if (irrecv.decode(&amp;amp;results))&#xA;  {&#xA;    irrecv.resume();&#xA;    char buff[255];&#xA;    sprintf(buff, &quot;Val %010x \n &quot; , results.value );&#xA;    Serial.print(buff);&#xA;    //results.decode();&#xA;    //results.DumpResults();&#xA;    //      msg = results.value;&#xA;    //      Serial.println(msg, HEX);&#xA;    //      Serial.println(results.decode_type);&#xA;    //      processIR(msg);&#xA;&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And values, of course:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x000002fd &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x000022dd &#xA; Val 0x0000ffff &#xA; Val 0x0000c23d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x00005282 &#xA; Val 0x000038d6 &#xA; Val 0x0000ffff &#xA; Val 0x0000efb5 &#xA; Val 0x00006897 &#xA; Val 0x00006897 &#xA; Val 0x00006897 &#xA; Val 0x0000ffff &#xA; Val 0x00006897 &#xA; Val 0x00006897 &#xA; Val 0x0000ffff &#xA; Val 0x00006897 &#xA; Val 0x00009867 &#xA; Val 0x00009867 &#xA; Val 0x0000b04f &#xA; Val 0x0000ffff &#xA; Val 0x00004794 &#xA; Val 0x00009424 &#xA; Val 0x0000ffff &#xA; Val 0x000042bd &#xA; Val 0x0000ffff &#xA; Val 0x00004ab5 &#xA; Val 0x0000ffff &#xA; Val 0x000052ad &#xA; Val 0x0000ffff &#xA; Val 0x00004ab5 &#xA; Val 0x00005aa5 &#xA; Val 0x0000ffff &#xA; Val 0x000038c7 &#xA; Val 0x000010ef &#xA; Val 0x0000ffff &#xA; Val 0x000030cf &#xA; Val 0x0000ffff &#xA; Val 0x000018e7 &#xA; Val 0x0000ffff &#xA; Val 0x00007a85 &#xA; Val 0x0000ffff &#xA; Val 0x00004ec5 &#xA; Val 0x00007a2a &#xA; Val 0x00007d4f &#xA; Val 0x0000a33f &#xA; Val 0x00007a28 &#xA; Val 0x00008dd8 &#xA; Val 0x00004b78 &#xA; Val 0x0000144b &#xA; Val 0x00006781 &#xA; Val 0x0000040a &#xA; Val 0x0000ffbf &#xA; Val 0x00007d4f &#xA; Val 0x0000ee7c &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA; Val 0x0000629d &#xA; Val 0x0000ffff &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So each press of a key gives 2 values. &lt;/p&gt;&#xA;" OwnerUserId="16235" LastEditorUserId="6936" LastEditDate="2016-01-09T19:56:56.907" LastActivityDate="2020-03-22T21:52:11.967" Title="Arduino IR remote control hold value" Tags="|programming|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19365" PostTypeId="2" ParentId="19364" CreationDate="2016-01-09T01:15:18.487" Score="1" Body="&lt;p&gt;If I understand your question correctly, a button press will first generate a distinct hex code, and then after a while a series of &lt;code&gt;0xFFFFFF&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, why don't you simply store the last distinct code you received, and replace occurrences of &lt;code&gt;0xFFFFFF&lt;/code&gt; with the stored code?&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2016-01-09T01:15:18.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19366" PostTypeId="1" CreationDate="2016-01-09T02:11:28.540" Score="3" ViewCount="2699" Body="&lt;p&gt;I'm trying to use an Arduino to release a &lt;strong&gt;single drop&lt;/strong&gt; of water using a solenoid valve.  &lt;a href=&quot;http://www.davidhunt.ie/water-droplet-photography-with-raspberry-pi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This article&lt;/a&gt; describes how to create this circuit with a Raspberry Pi using a DC powered solenoid that opens and closes very quickly and they use this for photographing water drops.  Exactly what I need, if I could only get it to work with the starter kit items first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The design for the solenoid circuit from that site looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RU0ES.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RU0ES.png&quot; alt=&quot;Solenoid actuating circuit diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a solenoid yet, but I've been experimenting with the cheap motor that comes with the Arduino and a 9 V battery.  I've burned out several transistors in my attempts to get this working.  My schematic looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CA4f6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CA4f6.png&quot; alt=&quot;Motor actuating circuit with Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relays won't work.  They are too slow.  Also, I need to use an external battery.  I can't use the power from the Arduino because I will eventually be moving up to a 12 V battery and the Arduino won't be able to handle that.&lt;/p&gt;&#xA;" OwnerUserId="16239" LastEditorUserId="26916" LastEditDate="2017-11-04T19:01:44.950" LastActivityDate="2017-11-04T19:01:44.950" Title="Controlling a DC motor with an external power source" Tags="|power|motor|battery|transistor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19367" PostTypeId="2" ParentId="19352" CreationDate="2016-01-09T02:31:42.923" Score="0" Body="&lt;p&gt;As Majenko says, it is easily possible to implement using bit banging.  Assuming that you want to write your own protocol, you need to distinguish between the end of one data packet and the start of another.  This could be done by having all of the packets the same length (as in your example with length 2) or using a form of &lt;a href=&quot;https://en.wikipedia.org/wiki/Huffman_coding&quot; rel=&quot;nofollow&quot;&gt;Huffman coding&lt;/a&gt; where only the external nodes of the state tree are results so you know when a full packet has been received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a standard serial or I2C protocol would also work.  With serial you would be able to communicate via a serial emulator on a USB port so you could test with a computer.&lt;/p&gt;&#xA;" OwnerUserId="11898" LastActivityDate="2016-01-09T02:31:42.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19368" PostTypeId="2" ParentId="19326" CreationDate="2016-01-09T02:42:21.940" Score="1" Body="&lt;p&gt;It seems likely to me that you have not configured your serial monitor to send a newline. See the bottom line of the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/44gPd.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/44gPd.png&quot; alt=&quot;Serial monitor configuration&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is set to &quot;no line ending&quot; then when you send the line, you get the line only and no newline.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-09T02:42:21.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19369" PostTypeId="2" ParentId="19366" CreationDate="2016-01-09T02:42:55.380" Score="5" Body="&lt;p&gt;Seeing as you want to use a 12V battery, you should try an external motor controller. You would essentially connect the Arduino to the controller, then the external battery and motor to the controller. Dimension Engineering makes several high quality motor controllers that are compatible with Arduino and can handle the voltage (like &lt;a href=&quot;https://www.dimensionengineering.com/products/syren10&quot; rel=&quot;nofollow&quot;&gt;this controller&lt;/a&gt;). The site also includes Arduino libraries, documentation, and all the specifications on every product. I have used several of their products with my Arduino Uno and have had no problems.&lt;/p&gt;&#xA;" OwnerUserId="16094" LastEditorUserId="6936" LastEditDate="2016-01-11T13:12:50.743" LastActivityDate="2016-01-11T13:12:50.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19370" PostTypeId="1" CreationDate="2016-01-09T01:51:05.950" Score="0" ViewCount="988" Body="&lt;p&gt;I'm learning Arduino. I use Arduino Uno board with ATMEGA328-PU. I tried basic codes like LED blink, control of DC motor etc. Arduino board is used only when we program microcontroller, right? I mean, when we finish programming it, we can use microcontroller separately? If it can be used separately, we must have some &quot;external&quot; circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used? I'm new in this field so don't blame me because of amateur questions.&lt;/p&gt;&#xA;" OwnerUserId="16259" OwnerDisplayName="hari" LastEditorUserId="6936" LastEditDate="2018-12-04T12:51:15.570" LastActivityDate="2018-12-04T12:51:15.570" Title="How would I use Arduino microcontroller separately?" Tags="|atmega328|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19371" PostTypeId="2" ParentId="19370" CreationDate="2016-01-09T02:05:52.727" Score="2" Body="&lt;p&gt;Look at the &lt;a href=&quot;https://www.arduino.cc/en/Main/Boards&quot; rel=&quot;nofollow noreferrer&quot;&gt;schematics&lt;/a&gt; and see which bits you don't need. Leave those out and what's left is what your require. You then would need to design a circuit board for these parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xUoUO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xUoUO.png&quot; alt=&quot;Arduino schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, who &lt;em&gt;should&lt;/em&gt; we blame for your amateur questions? ;^)&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="transistor" LastActivityDate="2016-01-09T02:17:48.100" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19372" PostTypeId="2" ParentId="19370" CreationDate="2016-01-09T02:06:20.770" Score="2" Body="&lt;p&gt;There are two approaches to this.  One is to simply use the Arduino Uno board in your final product!  However, if you're making a large number of boards, it may be more cost efficient to develop a custom board with only the features you need.  It may be nothing more than a few GPIO pins and a power regulator!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing which can be important in these final products, no matter what board you are using, is that you can permanently burn your program into memory so that it always starts up when power is applied.&lt;/p&gt;&#xA;" OwnerUserId="8377" OwnerDisplayName="Cort Ammon" LastActivityDate="2016-01-09T02:06:20.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19373" PostTypeId="2" ParentId="19370" CreationDate="2016-01-09T02:07:34.690" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino board is used only when we program microcontroller, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not necessarily. The Arduino board is useful not only for programming, but because it provides required peripheral circuitry such as power regulation, USB-serial interface, convenient headers, and a crystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is perfectly fine to use the Arduino board to program your ATmega328 and then take it out and use it in another circuit.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If it can be used separately, we must have some &quot;external&quot; circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All the ATmega328 really needs is a stable power supply. If you're alright running it at 8MHz, you don't need an crystal. If you don't need in-circuit programming, you don't need an ISP connection or any USB-serial stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more powerful microcontrollers, you might require clock generation circuitry, multiple power rails, debug/programming connections, etc.&lt;/p&gt;&#xA;" OwnerUserId="16988" OwnerDisplayName="uint128_t" LastActivityDate="2016-01-09T02:07:34.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19374" PostTypeId="2" ParentId="19370" CreationDate="2016-01-09T02:21:53.930" Score="1" Body="&lt;p&gt;See this page on how to put an ATMega329 chip on a breadboard and have it run. I think this will explain things: &lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Standalone&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="BrianK" LastActivityDate="2016-01-09T02:21:53.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19375" PostTypeId="2" ParentId="19370" CreationDate="2016-01-09T02:27:02.393" Score="4" Body="&lt;p&gt;Assuming you are going to upload the program into the ATmega328 on the Arduino, then take the ATmega328 out of the socket, and use it in your circuit, then a simple answer is to search for &quot;&lt;a href=&quot;https://startpage.com/do/dsearch?query=minimal%20arduino%20circuit&amp;amp;cat=web&amp;amp;pl=opensearch&amp;amp;language=english&quot; rel=&quot;nofollow&quot;&gt;minimal Arduino circuit&lt;/a&gt;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example returned by that search is &quot;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;From Arduino to a Microcontroller on a Breadboard&lt;/a&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It lists:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a 16 MHz crystal,&lt;/li&gt;&#xA;&lt;li&gt;a 10k resistor, and&lt;/li&gt;&#xA;&lt;li&gt;two 18 to 22 picofarad (ceramic) capacitors&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That is enough to run the chip at the same speed as the Arduino, &lt;em&gt;and&lt;/em&gt; the code used on the Arduino to initialise its clock will work unchanged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This should run okay directly from a battery supply of about 4.5V or 4.8V, or a good 5V power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better circuit, which runs at the same 16MHz speed as the Arduino is '&lt;a href=&quot;http://shrimping.it/blog/shrimp/&quot; rel=&quot;nofollow&quot;&gt;Shrimp It&lt;/a&gt;'. That shows a similar minimal circuit and a better 'protected' circuit which has a more reliable approach for its power supply. This is all you need to run off a 4.5V (e.g. 3 1.5V) battery power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you don't care about running at 16MHz, you could ditch the crystal and capacitors, and use the internal 8MHz oscillator, that will need the code to be slightly different. For example, the 8MHz clock is 1/2 the speed of the Arduino's standard 16MHz, so code like &lt;code&gt;delay()&lt;/code&gt; will take 2ms instead of 1ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, the RESET button can be set up so it doesn't need the 10k pullup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, with some software changes (search the web for details), an ATmega328 could be used with &lt;strong&gt;no&lt;/strong&gt; external components. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you might want to use a better power supply, for example a voltage regulator with the circuit of the protected '&lt;a href=&quot;http://shrimping.it/blog/shrimp/&quot; rel=&quot;nofollow&quot;&gt;Shrimp It&lt;/a&gt;', &lt;em&gt;and&lt;/em&gt; be able to load the program onto the ATmega while on its board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are products which bundle that 'standard' set of parts (voltage regulator, plugs and sockets and protected '&lt;a href=&quot;http://shrimping.it/blog/shrimp/&quot; rel=&quot;nofollow&quot;&gt;Shrimp It&lt;/a&gt;' running exactly like an Arduino at 16MHz) with a very compact PCB. They are able to plug directly into a breadboard, and so can be used with veroboard/stripboard (or a PCB) to make the rest of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is a kit called '&lt;a href=&quot;https://learn.adafruit.com/boarduino-kits&quot; rel=&quot;nofollow&quot;&gt;Boarduino&lt;/a&gt;'from adafruit. That web site gives some details to sow how to do this yourself. It is a convenient-to-use version of the '&lt;a href=&quot;http://shrimping.it/blog/shrimp/&quot; rel=&quot;nofollow&quot;&gt;Shrimp It&lt;/a&gt;', on a compact PCB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative kit is the &lt;a href=&quot;https://moderndevice.com/product/rbbb-kit/&quot; rel=&quot;nofollow&quot;&gt;&quot;Really Bare Bones Board (RBBB) kit&lt;/a&gt;&quot;. However it is available as the PCB only, which is the &quot;&lt;a href=&quot;https://moderndevice.com/product/rbbb-pcb/&quot; rel=&quot;nofollow&quot;&gt;Really Bare Bones board (RBBB)&lt;/a&gt;&quot;, though the same supplier as the RRRB kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither Boarduino nor RRRB has on-board USB upload circuit. However, you can use your Arduino to do that, for example &quot;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Using an Arduino as an AVR ISP (In-System Programmer)&lt;/a&gt;&quot;. Or you could buy a USB to UART cable.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastEditorUserId="3493" LastEditDate="2016-01-09T10:44:40.427" LastActivityDate="2016-01-09T10:44:40.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19376" PostTypeId="2" ParentId="19326" CreationDate="2016-01-09T05:44:03.563" Score="2" Body="&lt;p&gt;The biggest problem I see is that when your &lt;code&gt;convert()&lt;/code&gt; function is called, if the user hasn't already typed something, then &lt;code&gt;Serial.available()&lt;/code&gt; is going to return 0 (zero) and the &lt;code&gt;while&lt;/code&gt; statement will never get executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, your &lt;code&gt;print&lt;/code&gt; statement that prints the prompt to the console will only get called &lt;em&gt;after&lt;/em&gt; you have already read a string from the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Third, you're trying to reinvent the wheel by writing your own function to read a string from the serial input. I suggest you use &lt;a href=&quot;https://www.arduino.cc/en/Serial/ReadStringUntil&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ReadStringUntil()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16241" LastEditorUserId="6936" LastEditDate="2016-01-10T16:26:18.463" LastActivityDate="2016-01-10T16:26:18.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19377" PostTypeId="2" ParentId="19333" CreationDate="2016-01-09T08:12:11.193" Score="4" Body="&lt;p&gt;I can't reproduce your problem still. See this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/noxJR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/noxJR.png&quot; alt=&quot;Compiler output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However if you are having problems (and frankly I expected you to) then you should read this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to avoid the quirks of the IDE sketch file pre-preprocessing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-i-actually-need-to-use-them&quot;&gt;How the IDE organizes things&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I can reproduce your problem in IDE 1.6.5 (not 1.6.7). The code generated by the IDE preprocessor is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#line 1 &quot;sketch_jan11a.ino&quot;&#xA;#ifdef __cplusplus&#xA;#include &quot;Arduino.h&quot;&#xA;void start_timer(void);&#xA;void setup();&#xA;void loop();&#xA;#line 2&#xA;extern &quot;C&quot; {&#xA;#endif&#xA;&#xA;void start_timer(void);&#xA;&#xA;#ifdef __cplusplus&#xA;}&#xA;#endif&#xA;&#xA;&#xA;void start_timer(void)&#xA;{&#xA;    Serial.println(&quot;2&quot;);&#xA;    Serial.begin(9600);&#xA;    delay(2000);&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;    start_timer();&#xA;    Serial.println(&quot;4&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(&quot;1&quot;);&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that in the automatic function prototype generation that the IDE &quot;helpfully&quot; generates for you, it puts the prototype for &lt;code&gt;start_timer&lt;/code&gt; outside the extern &quot;C&quot; declaration. Thus one function prototype has a declaration in C++ format, and the other in C format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why are you even doing this? I presume this is a small example of a larger problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you follow the suggestions in my link &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to avoid the quirks of the IDE sketch file pre-preprocessing&lt;/a&gt; - &lt;em&gt;did you read that?&lt;/em&gt; - the problem goes away, because .cpp files in IDE tabs are not subjected to this extra processing.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-11T08:36:07.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19378" PostTypeId="1" AcceptedAnswerId="19382" CreationDate="2016-01-09T08:43:56.090" Score="1" ViewCount="3445" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &quot;LGDP4535.h&quot; // Hardware-specific library&#xA;#include &amp;lt;zTouchScreen.h&amp;gt;&#xA;#define BOXSIZE   40&#xA;// Assign human-readable names to some common 16-bit color values:&#xA;#define BLACK   0x0000&#xA;#define BLUE    0x001F&#xA;#define RED     0xF800&#xA;#define GREEN   0x07E0&#xA;#define CYAN    0x07FF&#xA;#define MAGENTA 0xF81F&#xA;#define YELLOW  0xFFE0&#xA;#define WHITE   0xFFFF&#xA;&#xA;LGDP4535 tft; // Using the shield, all control and data lines are fixed&#xA;&#xA;#define YP A3  // must be an analog pin, use &quot;An&quot; notation!&#xA;#define XM A2  // must be an analog pin, use &quot;An&quot; notation!&#xA;#define YM 9   // can be a digital pin&#xA;#define XP 8   // can be a digital pin&#xA;&#xA;// You need to calibrate to fit your LCD&#xA;#define TS_MINX 930&#xA;#define TS_MINY 903&#xA;#define TS_MAXX 142&#xA;#define TS_MAXY 117&#xA;&#xA;#define PENRADIUS 3&#xA;#define MINPRESSURE 10&#xA;#define MAXPRESSURE 1000&#xA;&#xA;int matrix[2][3]; // Initial Declaration&#xA;int array[3]&#xA;&#xA;TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);&#xA;&#xA;// array = start with 1 but the variable read start with 0 &#xA;String ButtonAction[9]={&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;h&quot;, &quot;i&quot;};&#xA;boolean ActiveMenu=true;&#xA;&#xA;void setup(void) {&#xA;   Serial.begin(9600);&#xA;   tft.reset();&#xA;   tft.begin();&#xA;   ts.InitVariable(3, 240, 320, TS_MINX, TS_MAXX, TS_MINY, TS_MAXY, MINPRESSURE, MAXPRESSURE);&#xA;   tft.fillScreen(BLACK);&#xA;   DrawIt(CYAN, &quot;draw&quot;);&#xA;   DrawIt(BLACK, &quot;text&quot;);&#xA;}&#xA;&#xA;void loop() {//SOME OTHER STUFF}&#xA;&#xA;unsigned long DrawIt(uint16_t color, String CurrentAction) {&#xA;&#xA;  int timedcycle=0;&#xA;&#xA;  if (CurrentAction == &quot;text&quot;) {&#xA;     int matrix[2][3]={{25,150,265},{45,100,155}};&#xA;     int array[3]={3,3,3};&#xA;&#xA;     tft.setRotation(3);&#xA;     tft.setTextColor(BLACK);&#xA;     tft.setTextSize(1);&#xA;&#xA;     Serial.println(&quot;Text Columns&quot;);&#xA;  }&#xA;&#xA;  else if (CurrentAction == &quot;draw&quot;) {&#xA;    int matrix[2][3]={{260,140,20},{40,150,95}};&#xA;    int array[3]={3,3,3}; &#xA;  }&#xA;&#xA;  Serial.println(CurrentAction);&#xA;&#xA;  for(int j=0; j&amp;lt;3; j++) {&#xA;     for(int i=0; i&amp;lt;array[j]; i++) {&#xA;&#xA;       if (CurrentAction == &quot;draw&quot;) {&#xA;&#xA;         if (timedcycle == 7) {&#xA;           tft.fillCircle(100, 160, 15, WHITE);&#xA;         }         &#xA;         else {       &#xA;           tft.fillRect(matrix[1][j], matrix[0][i], 20,40, color);&#xA;         }&#xA;&#xA;       }  &#xA;       else if (CurrentAction == &quot;text&quot;) {&#xA;         if (timedcycle == 4) {&#xA;           true;&#xA;           //tft.fillCircle(100, 160, 15, WHITE);&#xA;         }         &#xA;         else {       &#xA;           tft.setCursor(matrix[0][j], matrix[1][i]);         &#xA;           tft.println(ButtonAction[timedcycle]);&#xA;         }&#xA;&#xA;       }&#xA;     timedcycle++;  &#xA;     } &#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So as you can see I'm trying to draw some things in a TFT Touch Screen. Everything seems to be working but no matter what I do I can't change the array value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I initialize the array variable with a predetermined value it won't change even if the statement is called correctly. I can see that it runs over serial but the array still doesn't change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose there's something wrong but I can't pinpoint what it is! Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2016-01-09T10:32:24.790" LastActivityDate="2018-11-26T11:13:01.523" Title="Why I cannot change array values even if a statement is successfully called? TFT Touch Screen" Tags="|arduino-uno|array|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19379" PostTypeId="2" ParentId="19366" CreationDate="2016-01-09T09:35:06.153" Score="2" Body="&lt;p&gt;I can think of a couple of things that you might consider. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor looks like a good surrogate for the solenoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're burning out transistors, look at the following 3 most probable causes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Voltage spike when you cut the current to the coil (motor or solenoid). If the fly-back diode is still intact, this should not be your case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Current spike exceeding Icmax. This is the maximum current your BJT can sustain without damage. An inductor like your solenoid or motor will reach in DC a maximum value dictated by Ohm's law. So measure the motor's resistance with a multimeter and calculate the Imax.&#xA;It should be Imax = (VDC - Vcesat)/Rcoil, where Vcesat is the saturation voltage of your BJT, somewhere around 0.3V.&#xA;Measuring the current of the motor connected to the battery also works if you measure it while you block the rotor.&#xA;Check that your transistor can handle the current.&#xA;Small signal transistors usually are rated at around 150mA, so this might be too little for your coil. So maybe you would need to buy/build a Darlington transistor that will have the amplification factor and current capacity to handle the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) If a and b are OK, then maybe the transistor is overheating? Your fingers will tell you :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once this works with the motor, you might need to recalculate to accommodate the (eventual) higher current of the solenoid.&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-09T09:35:06.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19380" PostTypeId="1" CreationDate="2016-01-09T09:48:42.663" Score="0" ViewCount="322" Body="&lt;p&gt;When I try to upload a sketch to my Arduino Uno R3 then sometimes I get the following issue:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the beginning the RX LED flashes three times and then I get errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd1&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    avrdude: ser_open(): can't open device &quot;\\.\COM3&quot;: Odmowa dostępu.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And sometimes Windows does not see the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this site &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt; I read that to check the programmer I must to connect RX with TX and GND with RESET pins and then plug Arduino to my computer, open Serial Monitor and write anything and if you receive the same characters from the Arduino, then the programmer and USB cable are OK. It worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have got one more info. When I plug Arduino with USB to my laptop the L led lights. When I press Reset on Arduino nothing happens, it still lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently bought a new USB cable, and it worked one day and then I could not upload sketches again. I uninstalled and installed drivers, but nothing changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a short video with my Arduino &lt;a href=&quot;https://drive.google.com/file/d/0ByeWvrEgy2gRbWdHQ3d5RWU3Mmc/view?usp=sharing&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/file/d/0ByeWvrEgy2gRbWdHQ3d5RWU3Mmc/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KzU3a.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KzU3a.jpg&quot; alt=&quot;Photo of Uno&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I will buy USBasp programator is it a good idea?&lt;/p&gt;&#xA;" OwnerUserId="16242" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2020-12-01T06:10:17.580" Title="Arduino does not work" Tags="|c++|c|programmer|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19382" PostTypeId="2" ParentId="19378" CreationDate="2016-01-09T10:29:12.593" Score="2" Body="&lt;p&gt;It's because you are defining a &lt;em&gt;new&lt;/em&gt; array every time, not modifying the existing one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int matrix[2][3]={{25,150,265},{45,100,155}};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line doesn't assign new values to the existing &lt;code&gt;matrix&lt;/code&gt; array, instead it creates a new array called &lt;code&gt;matrix&lt;/code&gt; which only exists within the current scope - that is, within the &lt;code&gt;{...}&lt;/code&gt; defined by the &lt;code&gt;if&lt;/code&gt; that it is within.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you either need to assign values directly to the existing matrix array on a slice-by-slice basis (you cannot use &lt;code&gt;{...}&lt;/code&gt; to assign them in bulk):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matrix[0][0] = 25;&#xA;matrix[0][1] = 150;&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively, since the values are static, you can pre-define the different matrices in the global scope and then switch between them.  This can be done with the right kind of pointer. For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int textMatrix[2][3] = {{260,140,20},{40,150,95}};&#xA;int (*matrix)[3];&#xA;&#xA;void whateverTheFunctionIs() {&#xA;    if (whatever...) {&#xA;        matrix = textMatrix;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that example &lt;code&gt;matrix&lt;/code&gt; is a pointer to an array of pointers, which is basically what a 2D array is internally.  It starts off by not being assigned to anything at all - it's just &quot;dangling in the breeze&quot;.  When the &lt;code&gt;if&lt;/code&gt; in your function is triggered the address that the &lt;code&gt;matrix&lt;/code&gt; pointer points to is changed to that of the &lt;code&gt;textMatrix&lt;/code&gt; 2D array, so any access to &lt;code&gt;matrix[x][y]&lt;/code&gt; will be identical to accesses to &lt;code&gt;textMatrix[x][y]&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-01-10T11:31:22.897" LastActivityDate="2016-01-10T11:31:22.897" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19384" PostTypeId="1" CreationDate="2016-01-09T11:27:12.393" Score="2" ViewCount="437" Body="&lt;p&gt;I had GRBL running on an Arduino UNO (China Copy). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I tried to update to the newest GRBL Version I was not able to upload the sketch:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I was unable to reprogram a bootloader via another ARDUINO (Arduino ISP) but I was able to update the firmware (dfu-programmer)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The funny thing is that I was only able to program the DFU as AT90USB82 not as ATmega8U2 while the chip has an ATmega8U2 printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can upload any example sketch from Arduino IDE but not GRBL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="16248" LastEditorUserId="6936" LastEditDate="2016-01-10T16:26:28.567" LastActivityDate="2016-01-10T16:26:28.567" Title="Why can't I upload GRBL but I can upload other sketches" Tags="|usb|uploading|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19385" PostTypeId="1" AcceptedAnswerId="19417" CreationDate="2016-01-09T13:19:49.457" Score="0" ViewCount="635" Body="&lt;p&gt;Hello I have made a small game using and Arduino Uno and a Nokia 5110 screen. I use bitmaps to draw the images onto the screen. The problem is that bitmaps take up a lot of space and I can only use up to three bitmaps before running out of space. Is it possible to use an SD card to store the bitmaps on and have a method in the Arduino code to load a bitmap at a certain time, like when a button is pushed?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="10907" LastEditDate="2016-01-12T05:12:29.893" LastActivityDate="2016-01-12T05:12:29.893" Title="Arduino loading variables from an SD card" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19386" PostTypeId="2" ParentId="19385" CreationDate="2016-01-09T13:35:25.973" Score="0" Body="&lt;p&gt;Yes, it is possible, but is it practical?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's basically two ways of doing it:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Load the entire bitmap into RAM for displaying multiple times&lt;/li&gt;&#xA;&lt;li&gt;Display the bitmap direct from the SD card.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As the Uno only has 2KiB of RAM that rather limits the size of bitmap that can be loaded into it. As you currently can have 3 bitmaps in flash (max 32KiB) I will assume they are considerably bigger than 2KiB each, so loading them into RAM is not really going to be doable on the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the second option - drawing it direct from the SD card - is really the only practical way. The problem with that is reading from the SD card is considerably slower than reading from the internal Flash.  That means that your screen updates could be really slow, which would seriously impact the playability of your game.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that happens when you draw a bitmap normally is that a loop iterates through the data and interprets each bit of each byte as a pixel being on or off and sets the relevant pixel to be on or off on the screen.  Instead of reading data from flash you just read bytes from the SD card and interpret them in exactly the same way.  If you take a look at the bitmap drawing routine in your LCD library you will see how simple it is - replacing the Flash access with SD card reading should be a simple enough matter to implement in your own copy of the routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A much better option would be to use a more powerful Arduino - one that has considerably more flash, such as the Mega2560.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-09T13:35:25.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19387" PostTypeId="1" AcceptedAnswerId="19394" CreationDate="2016-01-09T14:51:06.700" Score="0" ViewCount="461" Body="&lt;p&gt;I'm sending up a high-altitude balloon with an onboard &lt;a href=&quot;https://mightyohm.com/blog/products/geiger-counter/&quot; rel=&quot;nofollow&quot;&gt;Mighty Ohm Geiger Counter&lt;/a&gt; and some other sensors, all of which will be managed by an R Pi B+. I'll collect and store the data with the R Pi; all of that's fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to track and recover it, I'm using the HABDuino shield on an Arduino. It uses the APRS system and sends back short messages, giving the altitude, internal temp, my callsign, and coordinates. I'd like to add the Geiger counter's data to that, but I'll need to get it from the R Pi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm using an FTDI Friend to connect the Gieger counter to the R Pi, and getting the data from the serial port. I see &lt;a href=&quot;http://www.seeedstudio.com/recipe/166-basic-pi-lt-gt-arduino-communication-over-usb.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; that I can connect the Arduino and Pi vai USB, but... since there's already a USB connection to the Gieger counter, will there be a conflict? Is that something that I can work around? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="10605" LastActivityDate="2016-01-09T18:41:56.947" Title="Arduino and reading from multiple USB connections" Tags="|arduino-uno|" AnswerCount="1" CommentCount="7" ClosedDate="2016-01-21T20:48:30.210" ContentLicense="CC BY-SA 3.0" />
  <row Id="19390" PostTypeId="2" ParentId="9677" CreationDate="2016-01-09T17:14:49.173" Score="0" Body="&lt;p&gt;You aren't implementing the timeouts well and I don't see the point of this &lt;code&gt;if&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (true) {&#xA;   char c = (char)esp.read();&#xA;   t += c;&#xA;   Serial.print(c);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will always be executed. You have allotted 1500 ms to the whole process of reading the whole file, whether the ESP is done or not. Inside the loop, you are calling Serial.print(), as well as concatenating chars to a string, which takes a significant portion of the 1.5 secs. Get rid of the Serial.print() and use the timeout this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastRead = millis();&#xA;while (millis() - lastRead &amp;lt; 1500) {&#xA;    while (esp.available() {&#xA;        t += (char)esp.read();&#xA;        lastRead = millis();&#xA;    }&#xA;}&#xA;Serial.print(t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Storing the value of &lt;code&gt;millis()&lt;/code&gt; with an &lt;code&gt;int&lt;/code&gt; isn't a good idea since after about 33 seconds, it'll overflow. The code above will ensure that the last time a character was read is always stored in &lt;code&gt;lastRead&lt;/code&gt;; the end result is that no character is available from the ESP after a continuous 1500ms, we conclude that there's nothing more to be read or some error has occurred. Repeat this for the loop in &lt;code&gt;SerialDo&lt;/code&gt; as well. The &lt;code&gt;setTimeout&lt;/code&gt; in your setup() is also unneeded, in this case; you didn't call any &lt;code&gt;SoftwareSerial&lt;/code&gt; method that makes use of it, so remove the line. Also if your server supports HTTP 1.1, then try this request:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    String request = &quot;GET /test.txt HTTP/1.1\r\nHost: www.example.com\r\n\r\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-09T17:22:18.817" LastActivityDate="2016-01-09T17:22:18.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19391" PostTypeId="2" ParentId="16275" CreationDate="2016-01-09T17:48:09.790" Score="1" Body="&lt;p&gt;This is most likely a case of overrun SoftwareSerial buffer. You are reading too slowly from the modem, especially with the &lt;code&gt;Serial.print()&lt;/code&gt;s in your code. You should look for SoftwareSerial.h in &lt;code&gt;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial&lt;/code&gt; if you're using Win 8 and above. Or just search your PC for it. Look for this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #define _SS_MAX_RX_BUFF 64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change 64 to 256 and save. If it solves your problem, try reducing 256 to 128 to see if it still works. The greater the size of the buffer, the lesser the amount of memory available to the rest of your program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try this, to interact with the module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial SIM900(7,8);&#xA;&#xA;void setup() {&#xA;  Serial.begin(19200);&#xA;  SIM900.begin(19200);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  while (Serial.available() &amp;gt; 0){&#xA;    SIM900.write(Serial.read());&#xA;  }&#xA;  while (SIM900.available() &amp;gt; 0){&#xA;    Serial.write(SIM900.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does the same thing as your code and doesn't require adjusting buffer size, though I still recommend you make the change if you will use other sketches.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-11-07T03:40:08.503" LastActivityDate="2016-11-07T03:40:08.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19393" PostTypeId="2" ParentId="5395" CreationDate="2016-01-09T18:31:40.620" Score="1" Body="&lt;p&gt;The correct AT command is &lt;code&gt;AT+CREG?\r&lt;/code&gt;. A delay of at least 500ms is also advised after every command, though a timeout loop would be better. Since you didn't send any other commands, the modem will have no further responses for you and the Arduino will return -1 to any Serial.read()s, indicating there's nothing to be read.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-08T21:39:23.153" LastActivityDate="2016-04-08T21:39:23.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19394" PostTypeId="2" ParentId="19387" CreationDate="2016-01-09T18:41:56.947" Score="0" Body="&lt;p&gt;The FTDI should be showing up as &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; on the Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you connect an Arduino as well it will show up as &lt;code&gt;/dev/ttyACM0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have enough USB sockets then just add a USB hub.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-09T18:41:56.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19395" PostTypeId="2" ParentId="19304" CreationDate="2016-01-09T18:48:15.167" Score="1" Body="&lt;p&gt;24 VDC industrial circuits are typically based around 4-20mA measurement (AI) transmitters and outputs (AO) to valves and other actuators. There are also 24 VDC DI &amp;amp; DO's. I believe that you should investigate Analog Devices and Texas Instruments chips for 4-20 mA interfacing.  They have a number of chips for reading in and outputting 4-20 mA.  You can get started if you Google &quot;analog devices 4-20ma application note&quot; or &quot;texas instruments 4-20ma application note.&quot; If you Google &quot;4-20mA application note,&quot; you will find that there are any number of people that make these chips and lots of people that provide application notes for 4-20mA loops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any information provided here is on a Caveat Emptor basis.&lt;/p&gt;&#xA;" OwnerUserId="16258" LastActivityDate="2016-01-09T18:48:15.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19397" PostTypeId="1" AcceptedAnswerId="19398" CreationDate="2016-01-09T21:03:13.863" Score="0" ViewCount="1916" Body="&lt;p&gt;I'm trying to understand the power requirements of an SD card. I have a cheap breakout board from eBay that includes built-in level shifters, so I can plug it in directly to my Arduino. I provide power from one of the digital pins, and it works. This doesn't make sense to me, as I thought an SD card reader should draw upwards of 50-100 mA, well over the capacity of an individual digital pin on the Arduino. However, at least one &lt;a href=&quot;https://www.cooking-hacks.com/documentation/tutorials/arduino-micro-sd&quot; rel=&quot;nofollow noreferrer&quot;&gt;SD card manufacturer&lt;/a&gt; does this as well, so I'm not making this up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked, and the data is written no problem. I have connected an ammeter between the Arduino and the SD reader, and it never jumps above 3 mA? The only problem I have is when I switch from using the USB cable (connected to my computer) for power to a battery pack, the SD card starts acting erratically. Which makes sense, if it's not getting enough current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm wondering is why it &lt;em&gt;ever&lt;/em&gt; works when connected to a digital output pin? Clearly I'm missing something important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The reason why I thought they required a lot of current: I've seen comments like this on a number of &lt;a href=&quot;https://learn.adafruit.com/adafruit-micro-sd-breakout-board-card-tutorial/look-out&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorials&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One is that they are strictly 3.3V devices and the power draw when writing to the card can be fairly high, up to 100mA (or more)! &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Edit2: @dlu answer lead me to investigate the voltage I was sending to the SD card reader, which turns out to have been the problem. I was supplying the Vin pin with 5.2V, which was regulated down to 4V, presumably too low for the 5V-3.3V step-down at the SD card. Moving the battery power to the 5V pin corrected this. This also introduces some new risk, as the board is now &lt;a href=&quot;https://arduino.stackexchange.com/questions/4458/what-are-the-5v-and-vin-pins-for&quot;&gt;receiving unregulated power&lt;/a&gt;. But that is another problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit3: And finally, answering my original question: I found a note on the &lt;a href=&quot;https://www.adafruit.com/product/254&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit product pag&lt;/a&gt;e for a similar breakout that indicates:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Onboard 5v-&gt;3v regulator provides 150mA for power-hungry cards&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So despite only drawing 3mA of current from the Arduino pin, the actual SD card is supplied with &gt; 100mA from the regulator.&lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-11T07:00:38.053" Title="Why can I power an SD card reader from a digital pin?" Tags="|power|sd-card|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19398" PostTypeId="2" ParentId="19397" CreationDate="2016-01-09T21:13:32.380" Score="1" Body="&lt;p&gt;It seems that you've verified that the power requirements are within the range of a digital pin. Is there a reason why you thought they would be higher?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it sounds like the real question is &quot;why does the SD card work with USB power, but not with battery power?&quot; The first thing that occurs to me is that the battery is not providing sufficient voltage. What kind of battery are you using and where do you connect it to the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Almost any battery that you use will be able to provide sufficient current for a 3 mA load, but the voltage may not be adequate – especially if you are running a marginal battery (voltage wise) through the onboard regulator.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-09T21:13:32.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19399" PostTypeId="1" AcceptedAnswerId="19400" CreationDate="2016-01-09T21:16:22.037" Score="0" ViewCount="4011" Body="&lt;p&gt;I'm in the process of trying to take &lt;a href=&quot;https://github.com/tdicola/CloudThermometer/tree/master/CloudThermometer&quot; rel=&quot;nofollow&quot;&gt;this demo sketch&lt;/a&gt; and extract the necessary bits into a modular library that can be included in other sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/maketronica/Adafruit_CC3000_Dynamodb/tree/2ed5c6c8e251be4c0993ed0a1d68a85abe71d62d&quot; rel=&quot;nofollow&quot;&gt;Here's where I'm at so far&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;a href=&quot;https://github.com/maketronica/cc3000test/blob/d22022cb76c2dbc92547a1ce7bca0fe97e106a6b/cc3000test.ino&quot; rel=&quot;nofollow&quot;&gt;the test sketch&lt;/a&gt; that I'm including it in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I try to compile it right now, I'm getting...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libraries/Adafruit_CC3000_Dynamodb/sha256.cpp.o: In function `Sha256Class::init()':&#xA;/home/me/sketchbook/libraries/Adafruit_CC3000_Dynamodb/sha256.cpp:33: multiple definition of `Sha256Class::init()'&#xA;sketch/sha256.cpp.o:sketch/sha256.cpp:33: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been programming for years in other languages, but I'm not all that experienced in C. I'm sure I'm doing something completely stupid, but I can't figure out what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also aware that this code still needs a lot of cleanup work in general. Right now I'm just trying to work toward a basic MVP that works so that I start gradually cleaning things up and making it more OOP one step at a time.&lt;/p&gt;&#xA;" OwnerUserId="15405" LastEditorUserId="6936" LastEditDate="2016-01-09T22:13:06.117" LastActivityDate="2016-01-09T22:13:06.117" Title="Correct solution for &quot;multiple definition of&quot; compile error" Tags="|c|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19400" PostTypeId="2" ParentId="19399" CreationDate="2016-01-09T21:44:51.327" Score="2" Body="&lt;p&gt;You have an old copy of the sha256 files lingering in the build folder. These will have been output at some point in the past and never been cleaned up since they have been deleted from the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is probably a bug in the IDE that doesn't remove the old files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Restarting the IDE will cure the problem and allow you to compile.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-09T21:44:51.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19401" PostTypeId="2" ParentId="19355" CreationDate="2016-01-09T22:08:52.690" Score="0" Body="&lt;p&gt;So what I did was changing the codes by replacing the '0' from the other chipset to the '1' on the Atmega32u4&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UCSR1A |= (1&amp;lt;&amp;lt;U2X1);                                &#xA;UCSR1B |= (1&amp;lt;&amp;lt;RXEN1)  | (1&amp;lt;&amp;lt;TXEN1) | (1&amp;lt;&amp;lt;RXCIE1);   &#xA;UCSR1C |= (1&amp;lt;&amp;lt;UCSZ11) | (1&amp;lt;&amp;lt;UCSZ10)             ; &#xA;UBRR1H = 0;&#xA;UBRR1L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)&#xA;&#xA;ISR(USART_RX_vect) &#xA;{&#xA;  unsigned char b;&#xA;  b=UDR1;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think that this is the problem that causes freeze when I Open Serial.&#xA;Any advice? Thanks In advance&lt;/p&gt;&#xA;" OwnerUserId="16229" LastActivityDate="2016-01-09T22:08:52.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19403" PostTypeId="1" AcceptedAnswerId="19404" CreationDate="2016-01-09T23:30:10.390" Score="1" ViewCount="195" Body="&lt;p&gt;I'm learning &quot;Arduino&quot; (I don't have previous knowledge of microcontrollers). I have few questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the difference between programming a microcontroller in C and programming in &quot;Arduino?&quot;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it a good idea for beginners to start programming microcontrollers in Arduino and then start learning to program in C?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I have Arduino Uno with an Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? What are differences between various microcontrollers which can be used with this board?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If a microcontroller is already programmed, can we download the program from it to a PC and edit it in Arduino IDE? Or it is like a .exe on a PC, once compiled we can't get source, all we can do is reverse engineer? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That's it :)&lt;/p&gt;&#xA;" OwnerUserId="16259" OwnerDisplayName="hari" LastEditorUserId="10907" LastEditDate="2016-01-10T13:48:40.467" LastActivityDate="2016-01-11T09:29:02.463" Title="Few questions related to programming microcontrollers" Tags="|c|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19404" PostTypeId="2" ParentId="19403" CreationDate="2016-01-09T23:44:32.573" Score="4" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The Arduino IDE uses C++ primarily, which it preprocesses in order to make compilable. But you can still for the most part use C in the Arduino IDE and it will just work as normal; there's nothing requiring you to use C++ or the Arduino libraries (or even the Arduino IDE) for most tasks.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Not touching this one. And in the end it doesn't matter terribly since they're very close.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Any of the ATmegaXX8 or ATmega8 chips will fit the socket. Note that they will require separate cores if you're using the IDE. And you can use any chip without the board in the IDE as long as you can find a core for it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Not if you use a traditional compiled language to program it. If you use a VM then you conceivably could, but you'd have the source on your system regardless.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-01-09T23:44:32.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19405" PostTypeId="2" ParentId="19403" CreationDate="2016-01-10T00:26:02.487" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Nothing really.  The Arduino language is C++, a super-set of C. It contains a library of routines which are automatically included and linked, as well as a small amount of pre-processing to hide some of the pitfalls of C (e.g., automatically adding function prototypes for all functions to the top of your program so function ordering isn't something you now need to think about). Other than that, it is just C++, which is C with bells.&lt;/li&gt;&#xA;&lt;li&gt;If you learn the Arduino language you are learning C. If you learn C first then it gives you a good grounding in how to program the Arduino. Either way, by the time you have written your first Arduino program, you will be programming in C.&lt;/li&gt;&#xA;&lt;li&gt;There are a number of chips by Atmel that will work. You need, besides the &quot;core&quot; that Ignacio mentions, a board definition which defines what pins do what and what chip is in use. You also need a bootloader for that specific chip and some way to install that bootloader into the chip. There are tutorials on how to do that for commonly used chips - more uncommon ones may not have a bootloader readily available.&lt;/li&gt;&#xA;&lt;li&gt;When you program for the Arduino you are compiling the software. That is turning the source code first into object code and then linking the object code into an executable format - almost exactly the same as a .EXE on Windows. There is nothing you can do to &quot;undo&quot; that, only disassemble the raw instructions into assembly language and try to interpret what it is doing, which with assembly is a bit of a black art since it can be somewhat cryptic.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-10T00:26:02.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19406" PostTypeId="2" ParentId="19403" CreationDate="2016-01-10T00:26:47.703" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is difference between programming microcontroller in C and programming in Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The difference is that the Arduino core includes a set of functions and classes (C++) to make Arduino boards easier to program.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it good idea for beginners to start programming microcontrollers in Arduino and then start learning programming in C?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The whole idea with Arduino is to make it much easier to start embedded programming in C and/or C++. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have Arduino Uno board Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? What are differenes between various microcontrollers which are used with this board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;None. This is the controller for that board (though there are &quot;smaller&quot; versions).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If microcontroller is already programmed, can we download program from it to PC and edit it in Arduino IDE? Or it is like .exe on PC, once compiled we can't get source, only we can do is Reverse Eng.?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This you will have to explain better. Sounds like something bad and you should avoid that (or at least do not ask people to help you do a bad thing). &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-10T00:26:47.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19409" PostTypeId="1" CreationDate="2016-01-10T04:12:18.453" Score="1" ViewCount="92" Body="&lt;p&gt;I've got an Arduino faithfully monitoring our sewer lift pump. It talks to the world over Ethernet (with PoE). I'm wondering if there is any way to load new code over the Ethernet as well. Any ideas if this could be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine that using the boot loader might be out of the question, but perhaps it would be possible to upload a new system image – perhaps onto an SD card – and then use a modified boot loader to discover the new image and copy it into place.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-10T05:30:18.140" LastActivityDate="2016-01-11T02:26:40.760" Title="Update code over Ethernet?" Tags="|ethernet|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19413" PostTypeId="1" CreationDate="2016-01-10T12:47:28.380" Score="0" ViewCount="277" Body="&lt;p&gt;I am new in this Arduino coding world and I was trying to make a project. I normally used Arduino Unos all the time, but I was facing a problem and that is that the Arduino Uno has only 13 digital pins and 6 analog pins, and some of my friends advise me to use an Arduino Mega, but that costs too much, some to my friends also tell me that I could use only a Atmel chip, which will save money.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is that I can not burn these chips without a burner. I see online that Arduino Uno has Arduino ISP options also that will allow you to bootload or upload Arduino sketches to those kind of chips, but I have been trying for over 3 months and I cannot figure out how to do that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At present I am working with the ATmega8 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6v1rt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6v1rt.jpg&quot; alt=&quot;avrdude error - 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using stk500v1 but the problem is not resolved&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qjjbb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qjjbb.jpg&quot; alt=&quot;avrdude error - 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16272" LastEditorUserId="10794" LastEditDate="2016-01-11T21:03:32.993" LastActivityDate="2016-01-11T21:03:32.993" Title="How to upload Arduino sketches to Atmel chips" Tags="|arduino-uno|sketch|bootloader|avr|atmel-studio|" AnswerCount="1" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="19414" PostTypeId="1" AcceptedAnswerId="19418" CreationDate="2016-01-10T14:29:50.787" Score="1" ViewCount="3859" Body="&lt;p&gt;I have an Arduino Uno and for Wifi an ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ESP8266 Firmware is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+GMR&#xA;&#xA;AT version:0.40.0.0(Aug  8 2015 14:45:58)&#xA;SDK version:1.3.0&#xA;Ai-Thinker Technology Co.,Ltd.&#xA;Build:1.3.0.2 Sep 11 2015 11:48:04&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;baund = 115200,&#xA; Both NL &amp;amp; CR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Server -- www.linysoft.com&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The URL I want to send is either: &lt;code&gt;http://www.linysoft.com/arduino/?light=off&lt;/code&gt; OR &lt;code&gt;http://www.linysoft.com/arduino/?light=on&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on to the link I send the result should be either ==&gt; on or ==&gt; off on the page &lt;code&gt;http://www.linysoft.com/arduino/light.json&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to send an HTTP request (Weblink - &lt;code&gt;http://www.linysoft.com/arduino/?light=on&lt;/code&gt;) so it can write according to that link &quot;on&quot; in the &lt;code&gt;light.json&lt;/code&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AT command I am sending (my wifi module is connected to my wifi automatically):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WIFI CONNECTED&#xA;WIFI GOT IP&#xA;&#xA;AT+CWMODE=1&#xA;&#xA;OK&#xA;&#xA;AT+CIPMUX=1&#xA;&#xA;OK&#xA;&#xA;AT+CIPSTART=0,&quot;TCP&quot;,&quot;www.linysoft.com&quot;,80&#xA;&#xA;0,CONNECT&#xA;&#xA;OK&#xA;&#xA;AT+CIPSEND=0,200&#xA;&#xA;OK&#xA;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I am getting a problem after this &gt; I can't send &lt;code&gt;**GET /arduino/?light=on**&lt;/code&gt;. I also tried &lt;code&gt;GET /arduino/?light=on HTTP/1.0\r\n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After putting this line in the textbox, I press the Enter button or Send Button, but nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is stuck here &gt; for some time. And then it shows me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OK&#xA;&amp;gt; 0,CLOSED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pin Connection&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ARDUINO UNO        ESP8266&#xA;RX  --------------&amp;gt;  TX&#xA;TX  --------------&amp;gt; RX&#xA;VCC--------------&amp;gt; 3.3&#xA;CH_PD ----------&amp;gt; 3.3&#xA;GND -------------&amp;gt; GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16275" LastEditorUserId="10907" LastEditDate="2016-01-11T13:07:08.917" LastActivityDate="2017-02-02T10:45:56.720" Title="Can't send HTTP request using ESP8266 and Arduino Uno" Tags="|arduino-uno|esp8266|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19415" PostTypeId="2" ParentId="19414" CreationDate="2016-01-10T15:33:49.903" Score="1" Body="&lt;p&gt;The domain is missing. Try this instead:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET http://www.linysoft.com/arduino/?light=on HTTP/1.0\r\n\r\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref. &lt;a href=&quot;http://contractorwolf.com/esp8266-wifi-arduino-micro/&quot; rel=&quot;nofollow&quot;&gt;http://contractorwolf.com/esp8266-wifi-arduino-micro/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-10T16:18:40.933" LastActivityDate="2016-01-10T16:18:40.933" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19416" PostTypeId="2" ParentId="19380" CreationDate="2016-01-10T15:47:57.687" Score="1" Body="&lt;p&gt;It's normal that the &lt;code&gt;L-LED&lt;/code&gt; is steady &lt;code&gt;on&lt;/code&gt; after the USB connection is established. However, after pressing and releasing &lt;code&gt;Reset&lt;/code&gt; it should flicker for a second, then go back to &lt;code&gt;on&lt;/code&gt; again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting#toc1&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/Troubleshooting#toc1&lt;/a&gt; for reasons why you can't upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;http://www.arduino.org/products/boards/4-arduino-boards/arduino-uno&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.org/products/boards/4-arduino-boards/arduino-uno&lt;/a&gt; I've found:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I haven't found out so far, how to read the current values of the fuses.&lt;/p&gt;&#xA;" OwnerUserId="15427" LastActivityDate="2016-01-10T15:47:57.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19417" PostTypeId="2" ParentId="19385" CreationDate="2016-01-10T15:59:08.373" Score="0" Body="&lt;p&gt;Typically a bitmap for the Nokia 5110 (PCD8544) requires 504 bytes of memory (48*84/8). A bitmap as a initiated global variable will be stored in program memory, transfered to data memory on startup and then to the device (when drawn). Three bitmaps will use up 1.5 Kbyte. This is the limit for the Arduino Uno as an additional bitmap will require all data memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first trick that can be used is to define the bitmaps in &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;program memory&lt;/a&gt; with the attribute PROGMEM and when needed &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/pgmspace_8h.html&quot; rel=&quot;nofollow&quot;&gt;transfer&lt;/a&gt; to a buffer (504 byte) in data memory (and then to the device).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void *  memcpy_P (void *, const void *, size_t)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second trick is to transfer the bitmap directly from the program memory to the device. This may be supported by the library. If not the bitmap draw function will need to be updated to explicitly read program memory. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upper limit for the bitmaps is now the size of the program memory (30 Kbyte, 60 bitmaps).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-10T15:59:08.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19418" PostTypeId="2" ParentId="19414" CreationDate="2016-01-10T16:19:36.990" Score="1" Body="&lt;p&gt;linysoft.com is a virtual host. Just try going to &lt;a href=&quot;http://100.42.56.28/&quot; rel=&quot;nofollow&quot;&gt;http://100.42.56.28/&lt;/a&gt; and see that the connection is reset. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after the &lt;code&gt;GET /arduino/?light=on&lt;/code&gt;, you have to also send &lt;code&gt;Host: www.linysoft.com&lt;/code&gt; (on the next line).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-10T16:19:36.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19419" PostTypeId="1" CreationDate="2016-01-10T17:31:04.977" Score="1" ViewCount="1100" Body="&lt;p&gt;I'm trying to send data from an Arduino to an Android device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw an online guide for that which provided this code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() &#xA;{ &#xA;  Serial.begin(115200);&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  byte msg[64]; &#xA;  int len = Serial.available();&#xA;  if (len &amp;gt; 0)&#xA;  {&#xA;    len = Serial.readBytes((char*)msg, sizeof(msg)); // readBytes seems to need a char* not a byte*&#xA;    Serial.write(msg, len);&#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried that example and it is working perfectly!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I put &lt;code&gt;Serial.write(&quot;3&quot;);&lt;/code&gt;&#xA;in the setup loop after &lt;code&gt;Serial.begin(115200);&lt;/code&gt;&#xA;it appears as question mark on my Android device,&#xA;I guess that I'm not sending it as a byte,&#xA;I searched online but without any luck.&lt;/p&gt;&#xA;" OwnerUserId="8524" LastEditorUserId="4131" LastEditDate="2016-01-11T16:49:00.870" LastActivityDate="2016-01-12T04:54:08.343" Title="Sending number as byte through serial" Tags="|arduino-uno|serial|usb|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19420" PostTypeId="1" AcceptedAnswerId="19456" CreationDate="2016-01-10T18:05:14.870" Score="1" ViewCount="974" Body="&lt;p&gt;I have an ATTiny85 connected to an NRF24L01+ module using this wiring diagram: &lt;a href=&quot;https://www.hackster.io/arjun/nrf24l01-with-attiny85-3-pins-74a1f2&quot; rel=&quot;nofollow&quot;&gt;diagram&lt;/a&gt;. The ATTiny85 periodically goes in and out of sleep to send some value to a receiver, an Arduino Uno. If the ATTiny is running off the Arduino power supply (3.3v), everything works correctly. When I run the ATTiny off of a separate CR2032 coin cell that delivers around 3v, the Arduino never receives any data. I have a status LED hooked up to the ATTiny to ensure that the ATTiny is waking correctly, which it is. Here's the code for both:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&#xA;Connecting it to an external 3.3v not from the Uno makes everything work - why wouldn't the coin cell's voltage work? I think everything is rated below 2.8v, the CR2032 minimum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ATTiny Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;// Routines to set and claer bits (used in the sleep code)&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;#define CE_PIN 3&#xA;#define CSN_PIN 3 //Since we are using 3 pin configuration we will use same pin for both CE and CSN&#xA;&#xA;#include &quot;RF24.h&quot;&#xA;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;&#xA;byte address[11] = &quot;SimpleNode&quot;;&#xA;unsigned long payload = 0;&#xA;&#xA;void setup() {&#xA;  radio.begin(); // Start up the radio&#xA;  radio.setAutoAck(1); // Ensure autoACK is enabled&#xA;  radio.setRetries(15,15); // Max delay between retries &amp;amp; number of retries&#xA;  radio.openWritingPipe(address); // Write to device address 'SimpleNode'&#xA;  pinMode(4, OUTPUT);&#xA;  digitalWrite(4, HIGH);&#xA;  delay(500);&#xA;  digitalWrite(4, LOW);&#xA;  delay(500);&#xA;  digitalWrite(4, HIGH);&#xA;  delay(500);&#xA;  digitalWrite(4, LOW);&#xA;  delay(500);&#xA;  digitalWrite(4, HIGH);&#xA;  delay(500);&#xA;  digitalWrite(4, LOW);&#xA;  delay(1000);&#xA;  setup_watchdog(6);&#xA;}&#xA;&#xA;volatile int watchdog_counter = 0;&#xA;&#xA;ISR(WDT_vect) {&#xA;  watchdog_counter++;&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  sleep_mode(); //Go to sleep!&#xA;&#xA;  if(watchdog_counter &amp;gt;= 5)&#xA;  {&#xA;    digitalWrite(4, HIGH);&#xA;    watchdog_counter = 0;&#xA;    payload = 123456;&#xA;    radio.write( &amp;amp;payload, sizeof(unsigned long) ); //Send data to 'Receiver' ever second&#xA;    delay(1000);&#xA;    digitalWrite(4, LOW);&#xA;  }&#xA;}&#xA;&#xA;&#xA;&#xA;//Sleep ATTiny85&#xA;&#xA;void system_sleep() {&#xA;&#xA;  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF&#xA;&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here&#xA;  sleep_enable();&#xA;&#xA;  sleep_mode();                        // System actually sleeps here&#xA;&#xA;  sleep_disable();                     // System continues execution here when watchdog timed out &#xA;&#xA;  sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON&#xA;&#xA;}&#xA;&#xA;// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms&#xA;// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec&#xA;void setup_watchdog(int ii) {&#xA;&#xA;  byte bb;&#xA;  int ww;&#xA;  if (ii &amp;gt; 9 ) ii=9;&#xA;  bb=ii &amp;amp; 7;&#xA;  if (ii &amp;gt; 7) bb|= (1&amp;lt;&amp;lt;5);&#xA;  bb|= (1&amp;lt;&amp;lt;WDCE);&#xA;  ww=bb;&#xA;&#xA;  MCUSR &amp;amp;= ~(1&amp;lt;&amp;lt;WDRF);&#xA;  // start timed sequence&#xA;  WDTCR |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE);&#xA;  // set new watchdog timeout value&#xA;  WDTCR = bb;&#xA;  WDTCR |= _BV(WDIE);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiver Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define CE_PIN 7&#xA;#define CSN_PIN 8&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;&#xA;byte address[11] = &quot;SimpleNode&quot;;&#xA;unsigned long payload = 0;&#xA;&#xA;void setup() {&#xA;  while (!Serial);&#xA;  Serial.begin(115200);&#xA;  radio.begin(); // Start up the radio&#xA;  radio.setAutoAck(1); // Ensure autoACK is enabled&#xA;  radio.setRetries(15,15); // Max delay between retries &amp;amp; number of retries&#xA;  radio.openReadingPipe(1, address); // Write to device address 'SimpleNode'&#xA;  radio.startListening();&#xA;  Serial.println(&quot;Did Setup&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(void){&#xA;  if (radio.available()) {&#xA;&#xA;    radio.read( &amp;amp;payload, sizeof(unsigned long) );&#xA;    if(payload != 0){&#xA;        Serial.print(&quot;Got Payload &quot;);&#xA;        Serial.println(payload);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is the problem here that the ATTiny and Uno need to be turned on at the same time to establish a connection, or is it something to do with the battery, or something else entirely? Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15677" LastEditorUserId="4131" LastEditDate="2016-01-11T21:01:05.483" LastActivityDate="2016-01-12T01:33:38.150" Title="NRF24L01 Connection Not Working" Tags="|arduino-uno|attiny|nrf24l01+|wireless|sleep|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19421" PostTypeId="2" ParentId="19419" CreationDate="2016-01-10T18:09:56.373" Score="2" Body="&lt;p&gt;Start by changing it to &lt;code&gt;Serial.write(&quot;3&quot;, 1);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that help, you're missing the second parameter to the Serial.write call, which is the number of characters (bytes) to write. &lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-10T18:09:56.373" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19422" PostTypeId="1" AcceptedAnswerId="19423" CreationDate="2016-01-10T19:02:41.657" Score="2" ViewCount="991" Body="&lt;p&gt;According to the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;docs&lt;/a&gt;, the Arduino Leonardo uses digital pins 0 and 1 for the &lt;a href=&quot;https://en.wikipedia.org/wiki/USB&quot; rel=&quot;nofollow&quot;&gt;USB D- and D+&lt;/a&gt; lines. However, which is which? e.g. is D0=D+ or is D1=D+?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save space in a very tight project, I want to wire USB directly to these pins instead of using the USB plug, however, I can't find any resource that explains which pin goes to which USB line.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-01-10T20:05:01.533" Title="Pinout for Leonardo USB" Tags="|usb|arduino-leonardo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19423" PostTypeId="2" ParentId="19422" CreationDate="2016-01-10T20:04:42.290" Score="5" Body="&lt;p&gt;The USB does not go to pins 0 and 1.  The UART goes to pins 0 and 1 - that is a totally different interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The USB is connected to dedicated USB pins on the chip.  If you look at the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf&quot;&gt;Leonardo schematic&lt;/a&gt; you can see it is pins 3 and 4 on the chip. Note that that is not pins D3 and D4 on the board, but the third and fourth pins anti-clockwise from the &quot;pin 1&quot; dot on the main chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-10T20:04:42.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19424" PostTypeId="2" ParentId="19422" CreationDate="2016-01-10T20:05:01.533" Score="3" Body="&lt;p&gt;As shown in the ATmega32U4 datasheet, D- and D+ connect to pins 3 and 4 respectively &lt;strong&gt;&lt;em&gt;of the MCU&lt;/em&gt;&lt;/strong&gt;. But you don't want to wire directly to the chip unless you know what you are doing since the chip does not include the USB termination resistors. Follow the schematics given in the datasheet when connecting to the USB pins of the MCU.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-10T20:05:01.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19425" PostTypeId="2" ParentId="19414" CreationDate="2016-01-10T21:40:42.103" Score="0" Body="&lt;p&gt;Just found out a POST wouldn't work. Try this GET request to turn on the light.        &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    GET /arduino/?light=on HTTP/1.1\r\nHost: www.linysoft.com\r\n\r\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can get the status of the LED by GETting light.json like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    GET /arduino/light.json HTTP/1.1\r\nHost: www.linysoft.com\r\n\r\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-10T22:15:05.023" LastActivityDate="2016-01-10T22:15:05.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19426" PostTypeId="2" ParentId="16330" CreationDate="2016-01-10T21:59:43.650" Score="1" Body="&lt;p&gt;You can use a dog lead (or replace it with a fishing line). I made one my self. I used a rotary encoder and a dog lead, an Arduino board Paralax, and Excel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will use interrupts. Once the wire is triggered, the Arduino will send to Excel time and distance traveled. Once the weight goes down distance and time will be printed too, however distance will run in a minus direction. Later just press one button in Excel and each set of lifts will appear on the desktop. I can see my lift speed, power generated, distance travelled and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8lhAU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8lhAU.png&quot; alt=&quot;Excel example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16282" LastEditorUserId="6936" LastEditDate="2016-01-11T13:16:57.127" LastActivityDate="2016-01-11T13:16:57.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19427" PostTypeId="2" ParentId="19413" CreationDate="2016-01-10T22:29:05.763" Score="1" Body="&lt;p&gt;First thing you need to do in this situation is to crank up the verbosity level on the invocation of &lt;code&gt;avrdude&lt;/code&gt;. You do this by adding one or more &lt;code&gt;-v&lt;/code&gt; flags to the command line. With &lt;code&gt;-v -v -v -v&lt;/code&gt;, you get maximum verbosity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your two logs, it appears that the initial handshake with the microcontroller was successful (which would indicate that your connections were good), but then the signature reading turns out quite badly. This is a rather unusual combination which makes me wonder whether you may have misidentified what microcontroller you have.&lt;/p&gt;&#xA;" OwnerUserId="353" LastActivityDate="2016-01-10T22:29:05.763" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19428" PostTypeId="1" AcceptedAnswerId="19439" CreationDate="2016-01-10T22:29:53.313" Score="1" ViewCount="129" Body="&lt;p&gt;I would like to make a smart home using Arduino. My system must be wireless. I want to control power outlets and lamps and I want to be able to turn off and on power outlets and lamps wirelessly, using my android app, using nRF24L01. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need an Arduino for each power outlet and lamp? Do I need to put an Arduino, nRF24L01 and relay inside each power outlet and lamp?&lt;/p&gt;&#xA;" OwnerUserId="16283" LastEditorUserId="6936" LastEditDate="2016-01-10T23:59:40.487" LastActivityDate="2016-01-11T08:40:39.943" Title="Do I need a lot of Arduinos?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19429" PostTypeId="1" AcceptedAnswerId="19455" CreationDate="2016-01-10T23:27:00.410" Score="1" ViewCount="1373" Body="&lt;p&gt;The Wi-Fi connects when the Arduino is powered by my computer and a serial console is connected, but not if I plug into an outlet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems this is a power issue. I am powering the esp8266 from the Redboard 3.3v line that is only rated for 150mA. I will be switching to the 5v line with a 1A regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also switched to 9600 baud for communicating with the esp8266, added retries around all of esp8266 commands, and added reconnect logic in case the esp8266 reboots. With the changes, it works okay even with the underpowered 150mA line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's still a mystery to me why it works so well when connected to my Macbook.&lt;/p&gt;&#xA;" OwnerUserId="16284" LastEditorUserId="16284" LastEditDate="2016-01-14T01:30:41.630" LastActivityDate="2016-01-14T01:30:41.630" Title="ESP8266 (connected to Arduino) only works when plugged into USB power" Tags="|esp8266|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19430" PostTypeId="2" ParentId="19428" CreationDate="2016-01-11T00:28:04.163" Score="2" Body="&lt;p&gt;One arduino can control multiple relays. Beyond that, how many you need will depend on the details of your project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have a working example, you can build it using less expensive alternatives than regular Arduino boards.&lt;/p&gt;&#xA;" OwnerUserId="3956" LastActivityDate="2016-01-11T00:28:04.163" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19431" PostTypeId="2" ParentId="19409" CreationDate="2016-01-11T02:26:40.760" Score="1" Body="&lt;p&gt;A bootloader to network-boot might be too large to leave enough code space for your application. Your second suggestion sounds more workable - to collect &amp;amp; verify the entire new image in secondary storage first, then call a storage-to-flash boot loader. You really don't want to start loading an image that then suffers damage in transit, or to have the link go down mid-download. The likely only way out of that is a site-visit. Saving first lets you confirm the integrity of the new image before you start over-writing any of the old one.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-01-11T02:26:40.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19432" PostTypeId="1" CreationDate="2016-01-11T04:59:08.437" Score="1" ViewCount="3119" Body="&lt;p&gt;I want to pour 500ML of water with Arduino water flow controller with maximum accuracy.&#xA;How will I get the maximum accuracy with this sensor?&#xA;Could someone can give suggestion for accuracy or any other sensor that i can use?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/L6HQ7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L6HQ7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16292" LastEditorUserId="10907" LastEditDate="2016-01-13T05:37:58.687" LastActivityDate="2016-08-30T00:00:57.560" Title="I want to pour 500ml of Water in jar with Arduino water flow controller?" Tags="|arduino-uno|sensors|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19435" PostTypeId="1" CreationDate="2016-01-11T06:02:53.690" Score="2" ViewCount="4480" Body="&lt;p&gt;To control my robot, I need to generate negative and positive voltage in a single line, because the motor I try to control is an industrial one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any suggestion for it? How can I produce a negative voltage using an Arduino board and simple electrical elements?&lt;/p&gt;&#xA;" OwnerUserId="16294" LastEditorUserId="13749" LastEditDate="2016-01-11T21:04:05.043" LastActivityDate="2016-01-12T08:35:15.150" Title="Negative voltage: How do I scale a 0 to 5 V signal to -10 V to +10 V?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19436" PostTypeId="2" ParentId="19397" CreationDate="2016-01-11T07:00:38.053" Score="2" Body="&lt;p&gt;I just tested a SD card in an adapter (with level shifters). Without any activity the SD card is only drawing around 0.5 mA. So that is in the capability of an output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing a directory list appears to use a maximum of 7 mA, so that is OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing a file used a maximum of &lt;strong&gt;54.3 mA&lt;/strong&gt;, which is exceeding the absolute maximum ratings for an output pin (40 mA - recommended only 20 mA for continuous current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you may say that &quot;it works&quot; but the question is: for how long? Exceeding absolute maximum ratings is a path to damaging your processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to turn the SD card on and off from time to time, to reduce power, I suggest you arrange to switch the 5V line (and not use a digital output). For example from this &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about a low-power temperature sensor&lt;/a&gt; I have this schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vGoJg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vGoJg.png&quot; alt=&quot;Power switching MOSFET&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MOSFET there switches a 5V line on and off under program control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That particular design includes a SD card, and that particular gadget has been working for a couple of years now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Photo of hardware:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eECeL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eECeL.png&quot; alt=&quot;Temperature and humidity sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-11T07:00:38.053" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19439" PostTypeId="2" ParentId="19428" CreationDate="2016-01-11T08:40:39.943" Score="2" Body="&lt;p&gt;You might also consider using ESP8266 + relay combinations, instead of Pro Mini + nRF24L01 + relay sets.  An Arduino IDE setup is available to support C code on ESP8266 systems (&lt;a href=&quot;http://l0l.org.uk/2014/12/esp8266-modules-hardware-guide-gotta-catch-em-all/&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;http://makezine.com/2015/04/01/esp8266-5-microcontroller-wi-fi-now-arduino-compatible/&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module&quot; rel=&quot;nofollow&quot;&gt;3&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:  As a consequence of its higher clock speed and larger RAM size (80 MHz or 160 MHz clock, and 80 KB DRAM, vs Mini's 16 MHz clock and 2 KB SRAM) a typical ESP8266 board uses more power than a Pro Mini + nRF24L01 does.  According to &lt;a href=&quot;http://nrqm.ca/nrf24l01/hardware/&quot; rel=&quot;nofollow&quot;&gt;nrqm.ca/nrf24l01&lt;/a&gt;, the nRF24L01 draws around 11 or 12 mA when sending or receiving, and  22 μA in low-power standby mode.  According to &lt;a href=&quot;http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module#Electronic_Characteristics&quot; rel=&quot;nofollow&quot;&gt;wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module&lt;/a&gt;, an ESP8266 draws ~ 60 mA receiving and 135–215 mA sending.  (That current range covers a power output range of 5.5 dBm.  It probably supports a much bigger communication area than nRF24L01 does.)  Of course, if all your installations have mains power available, the power requirements might not matter much to you.  Note, ESP8266 boards typically run on 3.3 V power instead of 5 V power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as cost goes, at the moment Pro Mini clones cost about $2.15 each.  nRF24L01's run about $0.90.  ESP8266 modules are $2–$3 depending on model and level of module (&lt;a href=&quot;https://www.itead.cc/esp8266-serial-wifi-module.html&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;http://www.ebay.com/itm/ESP8266-Remote-Serial-Port-WIFI-Transceiver-Wireless-Module-Esp-07-AP-STA-OT8G-/371241185691?pt=LH_DefaultDomain_0&amp;amp;hash=item566fb2f19b&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt;).  You might save a few dollars on your whole system using ESP8266's, but the smaller-sized electronics they provide probably is more important.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-11T08:40:39.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19440" PostTypeId="2" ParentId="19403" CreationDate="2016-01-11T09:29:02.463" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the difference between programming a microcontroller in C and programming in &quot;Arduino?&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The default language is C++, but you can program in C. Thus the difference is &quot;not much&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it a good idea for beginners to start programming microcontrollers in Arduino and then start learning to program in C?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ah, if you program the Arduino you will be learning C. So &quot;goodness&quot; doesn't really enter into it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have Arduino Uno with an Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could conceivably remove the chip and replace it with an Atmega168P. I'm not sure why you would want to.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What are differences between various microcontrollers which can be used with this board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;RAM, program memory (flash) size, and EEPROM size.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If a microcontroller is already programmed, can we download the program from it to a PC and edit it in Arduino IDE? Or it is like a .exe on a PC, once compiled we can't get source, all we can do is reverse engineer?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. Like a PC, you can't get the source back. The compiler is a good, highly optimized one. The generated code won't look like the source.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-11T09:29:02.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19441" PostTypeId="1" CreationDate="2016-01-11T11:49:49.807" Score="1" ViewCount="451" Body="&lt;p&gt;I am working on an Arduino application which is dependant on a certain library. This library uses the &lt;code&gt;Ethernet&lt;/code&gt; class for network communications, but ideally, I would like it to be wireless (I have both an Ethernet and WiFi shield available for testing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When working on replacing the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Ethernet&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Ethernet&lt;/code&gt;&lt;/a&gt; functionality of the library with the corresponding &lt;a href=&quot;https://www.arduino.cc/en/Reference/WiFi&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;WiFi&lt;/code&gt;&lt;/a&gt; functionality, I noticed that the &lt;a href=&quot;https://www.arduino.cc/en/Reference/EthernetBegin&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Ethernet.begin()&lt;/code&gt;&lt;/a&gt; function requires a MAC address while the &lt;a href=&quot;https://www.arduino.cc/en/Reference/WiFiBegin&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;WiFi.begin()&lt;/code&gt;&lt;/a&gt; doesn't (it instead accepts SSID and password, among a couple of other things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As both come shipped with a MAC address sticker on them, I couldn't really figure out why this is the case (and if I need to supply the MAC address found on the WiFi shield in some other fashion).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this the case?&lt;/p&gt;&#xA;" OwnerUserId="15473" LastEditorUserId="10907" LastEditDate="2016-01-11T13:30:55.103" LastActivityDate="2016-01-11T13:33:39.830" Title="Why does Ethernet.begin() require a MAC address when WiFi.begin() doesn't?" Tags="|wifi|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19442" PostTypeId="1" CreationDate="2016-01-11T11:52:14.740" Score="0" ViewCount="20178" Body="&lt;p&gt;Currently I convert the characters in &lt;code&gt;char received[20]&lt;/code&gt; to string using &lt;code&gt;String randomString(received)&lt;/code&gt; and I am able to display it using &lt;code&gt;Serial.println(randomString)&lt;/code&gt;. After displaying the string, I would like to know the easiest way to clear out its contents.&lt;/p&gt;&#xA;" OwnerUserId="15686" LastEditorUserId="10907" LastEditDate="2016-01-12T13:45:49.687" LastActivityDate="2021-07-27T00:35:07.143" Title="How to clear of contents of string in Arduino?" Tags="|string|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19444" PostTypeId="2" ParentId="19442" CreationDate="2016-01-11T13:25:34.893" Score="2" Body="&lt;p&gt;In C and C++ a null terminated array of characters &lt;strong&gt;is&lt;/strong&gt; a string (although not a String). Many routines for reading input terminate the result with a null as does an assignment like&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char foo[] = &quot;This is a string.&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you would need to do to &quot;clear&quot; this string is to assign a null to the first character. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo[0] = '\0';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-11T13:25:34.893" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19445" PostTypeId="2" ParentId="19441" CreationDate="2016-01-11T13:33:39.830" Score="1" Body="&lt;p&gt;The flip answer would be &quot;because it doesn't need it…&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think what is going on is that older Ethernet shields did not have a MAC address and it was necessary for the code to set one (and I would guess that on at least some of them you can still set the MAC address, overriding the one that is on the sticker).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFi cards, I would guess, are newer and the MAC address is always there, so there is no need to require you to assign it.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-11T13:33:39.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19446" PostTypeId="1" AcceptedAnswerId="19451" CreationDate="2016-01-11T14:12:49.683" Score="0" ViewCount="7144" Body="&lt;p&gt;When I used to program PICs, there was a way to set the pins to input and output, at the same time. Can this be done on the Arduino? &#xA;I see the &lt;a href=&quot;https://www.arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow&quot;&gt;pinmode documentation&lt;/a&gt;, but nothing about being an IO port. &lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="10907" LastEditDate="2016-01-11T17:07:54.110" LastActivityDate="2016-01-11T17:07:54.110" Title="Can I set an Arduino pin as input and output?" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="3" ClosedDate="2016-01-21T20:46:57.640" ContentLicense="CC BY-SA 3.0" />
  <row Id="19447" PostTypeId="1" AcceptedAnswerId="19449" CreationDate="2016-01-11T14:35:55.423" Score="1" ViewCount="16666" Body="&lt;p&gt;I wanted to control an LED using a transistor (my first attempt at using a transistor). I connected a transistor (TL188) to pin 13 of an Arduino Uno accidentally and noticed something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E2VZV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E2VZV.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;em&gt;(The resistor I used was 150&amp;nbsp;ohms, and I forgot to change the resistor value in the diagram.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program on the Arduino Uno was the basic &lt;code&gt;Blink&lt;/code&gt; sketch. As per the program, the LED on the Arduino Uno was supposed to turn on for 1000&amp;nbsp;ms and turn off for 1000&amp;nbsp;ms. But when I connected the LED like the diagram below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For the first 1000 ms delay:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LED on pin 13 stayed &lt;strong&gt;on&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;LED connected using the transistor stayed &lt;strong&gt;off&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For the next 1000 ms delay:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;LED on pin 13 stayed &lt;strong&gt;partially on (it was dim)&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;LED with the transistor was &lt;strong&gt;on&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I know that the connection that I made is completely wrong. Can someone explain me how and also why the LED on the Arduino Uno was dim?&lt;/p&gt;&#xA;" OwnerUserId="6565" LastEditorUserId="510" LastEditDate="2016-01-11T21:02:00.440" LastActivityDate="2019-06-11T08:27:28.190" Title="Controlling an LED using a transistor (TL188)" Tags="|arduino-uno|transistor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19448" PostTypeId="2" ParentId="16280" CreationDate="2016-01-11T14:48:03.820" Score="1" Body="&lt;p&gt;The most you can do is define a certain amount of time between received characters, after which you can decide that there's nothing more to be read from the modem. Of course, the time taken for processing is longer for certain commands (and some provide no response at all, until you've completed entering their payload, like TCPSEND, in which case you should simply use &lt;code&gt;mySerial.write()&lt;/code&gt; to send said payload, and not your function), but once a response is ready and its first character is available, a timeout of 1 second between characters should be sufficient, for any reasonable baud rate. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TIMEOUT 1000&#xA;&#xA;void modem_command(String command){&#xA;  mySerial.println(command);&#xA;  Serial.println(command);&#xA;  while (mySerial.available() == 0);  // wait for first char&#xA;&#xA;  unsigned long lastRead = millis();   // last time a char was available&#xA;  while (millis() - lastRead &amp;lt; TIMEOUT){   &#xA;    while (mySerial.available()){&#xA;      Serial.write(mySerial.read());&#xA;      lastRead = millis();   // update the lastRead timestamp&#xA;    }&#xA;  }&#xA;  // No need for extra line feed since most responses contain them anyways&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you can always alter &lt;code&gt;TIMEOUT&lt;/code&gt; based on your findings.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-11T14:48:03.820" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19449" PostTypeId="2" ParentId="19447" CreationDate="2016-01-11T14:54:21.427" Score="3" Body="&lt;p&gt;You should have a resistor of a few hundred ohms on the base connection of the transistor - that is, between base and pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A PNP transistor is somewhat harder to get to grips with than an NPN transistor.  Much of it does things backwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The operation you see seems to be completely correct when you understand how a PNP works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With and NPN transistor a high voltage on the base turns it on and a low voltage turns it off. The opposite is true with a PNP transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you have a voltage close to or above the voltage at the emitter the transistor will be off.  That means, providing a HIGH to the base will turn it off.  A voltage on the base that is below the emitter voltage minus the threshold voltage of around 0.7V will turn the transistor on.  That means providing a LOW to the base will turn it on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that means that when the on-board LED is on the transistor is off, and so the LED on the transistor will be off.  When the LED on the board is off the transistor will be on, so the LED on the transistor will be on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;But&quot;, you say, &quot;the on-board LED doesn't turn off&quot;.  That is correct. It just gets dimmer.  That is, again, because of how the PNP transistor works.  Current (seen from the &lt;em&gt;conventional sense&lt;/em&gt; - i.e., flowing from + to -) enters the emitter and is then split between the collector and base. The amount of current allowed to flow out of the base defines how much is allowed to flow out of the collector (in an NPN it's current into the base and collector that combine to flow out of the emitter, and the amount that is allowed to flow into the base defines how much is allowed to flow into the collector). So there will be some current flowing out of the base - which makes its way to ground both through the microcontroller's IO pin and also through the LED on board, making it glow slightly*.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;*That is a little crudely put, but kind of illustrates what is going on.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-11T14:54:21.427" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="19450" PostTypeId="2" ParentId="16796" CreationDate="2016-01-11T15:33:00.237" Score="0" Body="&lt;p&gt;Looking at the &lt;code&gt;BH1750.cpp&lt;/code&gt; and &lt;code&gt;BH1750.h&lt;/code&gt; and I think i've noticed some errors:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change &lt;code&gt;#include &quot;Wire.h&quot;&lt;/code&gt; to &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt; in the header file, trivial perhaps but still...&lt;/li&gt;&#xA;&lt;li&gt;In the method &lt;code&gt;BH1750::readLightLevel&lt;/code&gt; in the .cpp, comment out &lt;code&gt;Wire.beginTransmission(BH1750_I2CADDR);&lt;/code&gt; and &lt;code&gt;Wire.endTransmission();&lt;/code&gt;; they aren't needed for a Read and may be responsible for the wrong value you're getting.&lt;/li&gt;&#xA;&lt;li&gt;You can also try replacing &lt;code&gt;_delay_ms(10);&lt;/code&gt; with &lt;code&gt;delay(10)&lt;/code&gt;, just in case&lt;/li&gt;&#xA;&lt;li&gt;You may also try commenting out &lt;code&gt;level = level/1.2;&lt;/code&gt; just to see if this division has any adverse effects.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Save the files after making the changes.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-11T15:39:33.497" LastActivityDate="2016-01-11T15:39:33.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19451" PostTypeId="2" ParentId="19446" CreationDate="2016-01-11T17:06:20.043" Score="3" Body="&lt;p&gt;No there is no function that lets you set all the pins to either input or output at the same time, but it wouldn't take much to write one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, you can't set an Arduino's pin as bidirectional.  If you are running out of pins look at IO expanders or multiple Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps, if not please feel free to clarify what it is you would like to know and we'll try and help.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-01-11T17:06:20.043" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19452" PostTypeId="2" ParentId="19435" CreationDate="2016-01-11T19:43:25.650" Score="3" Body="&lt;p&gt;Your question should read:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I scale a 0 to 5 V signal to -10 V to +10 V?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First write the conversion formula:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = 4 * Vin - 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Testing the formula gives the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Vin = 0.0 V ==&gt; Vout = -10 V&lt;/li&gt;&#xA;&lt;li&gt;Vin = 2.5 V ==&gt; Vout = 0 V&lt;/li&gt;&#xA;&lt;li&gt;Vin = 5.0 V ==&gt; Vout = +10 V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You will need an op-amp circuit to create this function. In addition you will need a +12 and -12 V supply.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/W1OR0.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fW1OR0.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;OA1 is an op-amp wired in an &lt;em&gt;inverting&lt;/em&gt; summing amplifier configuration. We'll address the inversion later but for now all the answers will be &quot;upside-down&quot;. The gain is set by -R2/R1 = -40k/10k = -4. If we feed 1 V in from the ADC we will get -4 V out.&lt;/li&gt;&#xA;&lt;li&gt;R3 provides a negative input. The gain will be set by -R2/R3 = -40k/48k = -5/6. Since it's connected to -12 it will contribute +10 V to the output.&lt;/li&gt;&#xA;&lt;li&gt;The actual output will be the sum of the two: in our example, +10 - 4 = 6 V.&lt;/li&gt;&#xA;&lt;li&gt;C1 and C2 provide noise filtering for the op-amp. Place them close to the chip.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now, what to do about the inversion? We have three choices:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Fix it in the micro controller code. Set +5 V as maximum reverse speed / torque. Set 0 V as maximum forward speed / torque.&lt;/li&gt;&#xA;&lt;li&gt;Fix it in the servo amplifier and tell it to reverse its command signal.&lt;/li&gt;&#xA;&lt;li&gt;Fix it in the electronics. By adding another inverting op-amp we can turn the signal the right way up.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The TL082 opamp suggested has two op-amps in the one 8-pin package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ref: &lt;a href=&quot;http://masteringelectronicsdesign.com/how-to-derive-the-transfer-function-of-the-inverting-summing-amplifier/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Inverting Summing Amplifier&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Servo Enable&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ilkCJ.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2filkCJ.png&quot;&gt;simulate this circuit&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Delay the servo enable until the micro controller has initialised and all other functions are ready. See manual Section 3.2.3, page 73. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this is a simplified relay drive schematic. You need a transistor drive and a snubbing / flyback diode around the relay so one of the small 5V relay boards would be a good solution as they are already built in. An opto-isolator would be simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ensure that safety circuits (guarding and e-stops) are correctly wired using safety-rated components (and not only, for example, the micro).&lt;/p&gt;&#xA;" OwnerUserId="13749" LastEditorUserId="13749" LastEditDate="2016-01-12T08:35:15.150" LastActivityDate="2016-01-12T08:35:15.150" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="19453" PostTypeId="2" ParentId="14683" CreationDate="2016-01-11T19:53:51.050" Score="0" Body="&lt;p&gt;To elaborate on your comment ~&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An easy way to prevent multiple definitions from re-inclusion of the same header file is to ensure it's only defining things once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g. my_header.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __MY_HEADER_H__&#xA;#define __MY_HEADER_H__&#xA;&#xA;// some header code.&#xA;&#xA;#endif //#ifndef __MY_HEADER_H__&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the header is &lt;em&gt;first&lt;/em&gt; compiled, the definition of &lt;code&gt;__MY_HEADER_H__&lt;/code&gt; gets created by the compiler due to the 2nd line of the file.  On subsequent compiles, which are caused by including the same header in more files, the 1st line '#ifndef' conditional skips everything down to the '#endif'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you write (or split) C / C++ code, it's common to wrap the class and function definitions (which go in the .h header file) in these compilation control blocks, and then the .c/.cpp file only gets the function bodies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.: my_rgb.h ~&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __MY_RGB_H__&#xA;#define __MY_RGB_H__&#xA;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;&#xA;uint32_t packRGB(uint8_t r, uint8_t g, uint8_t b);&#xA;&#xA;class RGB&#xA;{&#xA;public:&#xA;    RGB(uint8_t r, uint8_t g, uint8_t b);&#xA;&#xA;    void toGreyscale();&#xA;&#xA;private:&#xA;    uint8_t red;&#xA;    uint8_t green;&#xA;    uint8_t blue;&#xA;};&#xA;&#xA;#endif //#ifndef __MY_RGB_H__&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my_rgb.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;my_rgb.h&quot;&#xA;&#xA;// Note: this would typically be a member function&#xA;// but is separate to show a standalone function definition.&#xA;uint32_t packRGB(uint8_t r, uint8_t g, uint8_t b)&#xA;{&#xA;    uint32_t packed;&#xA;&#xA;    packed = (r &amp;lt;&amp;lt; 24) | (r &amp;lt;&amp;lt; 16) | b;&#xA;&#xA;    return packed;&#xA;}&#xA;&#xA;RGB:RGB(uint8_t r, uint8_t g, uint8_t b)&#xA;{&#xA;    red = r;&#xA;    green = g;&#xA;    blue = b;&#xA;}&#xA;&#xA;void RGB::toGreyscale()&#xA;{&#xA;    uint8_t grey = 0.2126 * (float)r + 0.7152 * (float)g + 0.0722 * (float)b;&#xA;    r = g = b = grey;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Including the header file multiple times will give &quot;redefinition&quot; errors at &lt;strong&gt;compile time&lt;/strong&gt;.  Including the same function multiple times will give double definitions at &lt;strong&gt;link time&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you stick to this method of laying out .h and .c/.cpp files you will never have a problem with multiple definitions on your own files.  (Unless you re-define a library function by accident, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course it's ok (and quite common) to define short little functions in the header/.h file too. (The compiler typically generates these as inline code though.)  I'm not trying to explain the complete workings of headers &amp;amp; .C files, just presenting you a method which will &lt;em&gt;always&lt;/em&gt; prevent multiple definition problems.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-01-11T20:22:25.947" LastActivityDate="2016-01-11T20:22:25.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19454" PostTypeId="1" CreationDate="2016-01-11T20:15:00.990" Score="-1" ViewCount="4334" Body="&lt;p&gt;I am trying to setup an automated relay for my aquarium. The Arduino should switch off the pump every 3 hours for 20 minutes, and feed at particular times during the day. The code works fine for the first two on/off cycles. However after that the system stops responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried many ways to solve the issue, I am led to believe that the issue could be a memory leak, which I have tried to fix that with watchdog timer reset, I have also tried resetting the Arduino but it doesn't work after the first reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am still not sure what the problem could be, so any information would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have included the code that I have stitched together using references from the web and a schematic of my circuit along with a picture of a tiny RTC module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kgoou.jpg&quot; alt=&quot;&quot;&gt;&#xA;Tiny RTC:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xrGPd.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is below, any advice would be appreciated.              &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA; #define DS1307_ADDRESS 0x68&#xA; #define RELAY_PIN 2&#xA; #define Feed_PIN 4&#xA; #define led13 13&#xA;&#xA; void setup() {&#xA;   Wire.begin();&#xA;   Serial.begin(9600);&#xA;   pinMode(RELAY_PIN, OUTPUT);&#xA;   pinMode(Feed_PIN, OUTPUT);&#xA;   pinMode(led13, OUTPUT);&#xA; }&#xA;&#xA; void loop() {  &#xA;   printDate();&#xA;   // digitalWrite(led13, HIGH);&#xA;   //delay(500);&#xA;   //delay(500);&#xA;   //digitalWrite(led13, LOW);&#xA;   // byte zero = 0x00;&#xA;   ///Wire.write(zero);&#xA; }&#xA;&#xA;&#xA; byte bcdToDec(byte val)  {&#xA;   // Convert binary coded decimal to normal decimal numbers&#xA;   return ( (val / 16 * 10) + (val % 16) );&#xA; }&#xA;&#xA;&#xA; void printDate() {&#xA;   // Reset the register pointer&#xA;   Wire.beginTransmission(DS1307_ADDRESS);&#xA;   byte zero = 0x00;&#xA;   Wire.write(zero);&#xA;   Wire.endTransmission();&#xA;   Wire.requestFrom(DS1307_ADDRESS, 7);&#xA;   int second = bcdToDec(Wire.read());&#xA;   int minute = bcdToDec(Wire.read());&#xA;   int hour = bcdToDec(Wire.read() &amp;amp; 0b111111); //24 hour time&#xA;   int weekDay = bcdToDec(Wire.read()); //0-6 -&amp;gt; sun-sat      &#xA;   int monthDay = bcdToDec(Wire.read());&#xA;   int month = bcdToDec(Wire.read());&#xA;   int year = bcdToDec(Wire.read());&#xA;   //print the date EG   3/1/11 23:59:59&#xA;   Serial.print(month);&#xA;   Serial.print(&quot;/&quot;);&#xA;   Serial.print(monthDay);&#xA;   Serial.print(&quot;/&quot;);&#xA;   Serial.print(year);&#xA;   Serial.print(&quot; &quot;);&#xA;   Serial.print(hour);&#xA;   Serial.print(&quot;:&quot;);&#xA;   Serial.print(minute);&#xA;   Serial.print(&quot;:&quot;);&#xA;   Serial.println(second);&#xA;   if ( (hour ==  9 &amp;amp;&amp;amp; (minute &amp;gt;= 00 &amp;amp;&amp;amp; minute &amp;lt;= 20)) ||&#xA;        (hour == 12 &amp;amp;&amp;amp; (minute &amp;gt;= 20 &amp;amp;&amp;amp; minute &amp;lt;= 40)) ||&#xA;        (hour == 15 &amp;amp;&amp;amp; (minute &amp;gt;= 40 &amp;amp;&amp;amp; minute &amp;lt;= 59)) ||&#xA;        (hour == 18 &amp;amp;&amp;amp; (minute &amp;gt;= 00 &amp;amp;&amp;amp; minute &amp;lt;= 20)) ||&#xA;        (hour == 20 &amp;amp;&amp;amp; (minute &amp;gt;= 20 &amp;amp;&amp;amp; minute &amp;lt;= 40)) ||&#xA;        (hour == 22 &amp;amp;&amp;amp; (minute &amp;gt;= 40 &amp;amp;&amp;amp; minute &amp;lt;= 59)) ||&#xA;        (hour ==  1 &amp;amp;&amp;amp; (minute &amp;gt;= 00 &amp;amp;&amp;amp; minute &amp;lt;= 20)) ||&#xA;        (hour ==  3 &amp;amp;&amp;amp; (minute &amp;gt;= 20 &amp;amp;&amp;amp; minute &amp;lt;= 40)) ||&#xA;        (hour ==  5 &amp;amp;&amp;amp; (minute &amp;gt;= 40 &amp;amp;&amp;amp; minute &amp;lt;= 59)))&#xA;   {&#xA;     Serial.print(month);&#xA;     Serial.print(&quot;/&quot;);&#xA;     Serial.print(monthDay);&#xA;     Serial.print(&quot;/&quot;);&#xA;     Serial.print(year);&#xA;     Serial.print(&quot; &quot;);&#xA;     Serial.print(hour);&#xA;     Serial.print(&quot;:&quot;);&#xA;     Serial.print(minute);&#xA;     Serial.print(&quot;:&quot;);&#xA;     Serial.println(second);&#xA;     Serial.print(':');&#xA;     Serial.print(':');&#xA;     Serial.println(&quot;, pump off!&quot;);&#xA;&#xA;     digitalWrite(RELAY_PIN, HIGH);  &#xA;   } else {&#xA;     digitalWrite(RELAY_PIN, LOW);  &#xA;   }&#xA;&#xA;   if ((hour ==  2 &amp;amp;&amp;amp; minute == 43 &amp;amp;&amp;amp; second &amp;gt;= 52) ||&#xA;       (hour == 10 &amp;amp;&amp;amp; minute == 00 &amp;amp;&amp;amp; second &amp;gt;= 52) ||&#xA;       (hour == 13 &amp;amp;&amp;amp; minute == 00 &amp;amp;&amp;amp; second &amp;gt;= 52) ||&#xA;       (hour == 16 &amp;amp;&amp;amp; minute == 00 &amp;amp;&amp;amp; second &amp;gt;= 52)) &#xA;   {&#xA;     digitalWrite(Feed_PIN, HIGH);&#xA;     Serial.println(&quot;feeding fish.....&quot;);&#xA;   } else { &#xA;     digitalWrite(Feed_PIN, LOW); &#xA;   }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16314" LastEditorUserId="2944" LastEditDate="2016-01-13T02:42:33.790" LastActivityDate="2020-07-05T11:21:33.167" Title="Strange problem. Arduino stops working after few hours. Opinions please" Tags="|motor|i2c|timers|relay|rtc|" AnswerCount="4" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="19455" PostTypeId="2" ParentId="19429" CreationDate="2016-01-11T21:32:50.030" Score="1" Body="&lt;p&gt;It sounds like your power supply is inadequate to the task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 is notoriously finicky about having a noise free power supply capable of delivering a lot of instantaneous power. If you are using a wallwart style supply it should promise at least 1A and more is better. Even though the actual use is more like 250 mA.&lt;/p&gt;&#xA;" OwnerUserId="16316" LastEditorUserId="10907" LastEditDate="2016-01-12T01:36:38.717" LastActivityDate="2016-01-12T01:36:38.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19456" PostTypeId="2" ParentId="19420" CreationDate="2016-01-11T21:45:49.983" Score="1" Body="&lt;p&gt;I was just researching the exact question and I have some bad news.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ORIGINAL nrf24l01+ alone use around 10-12 ma in transmitting, but unoriginal might even draw more. (&lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nevertheless a standard CR2032 battery is simply not made to supply more than a few milliamps at the best, leaving your nrf24L01+ lacking enough current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is something called shockburst which can lower your consumption considerably at the cost of range - but if it will succeed in transmitting with one CR2032 I'm not sure about. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;If you add a capacitor you need to cover at least a 10ma drain for around 15ms (turn on - send - turn of immediately), that will require a minimum of a 200µF capacitor at 3V to be able to deliver the current while keeping above 2.0v.&lt;/p&gt;&#xA;" OwnerUserId="16318" LastEditorUserId="10907" LastEditDate="2016-01-12T01:33:38.150" LastActivityDate="2016-01-12T01:33:38.150" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19457" PostTypeId="2" ParentId="9856" CreationDate="2016-01-11T22:27:47.070" Score="1" Body="&lt;p&gt;A common issue when using strings (character vectors) is that the vector size is not updated when the format is update. Check the size required for this data. Does it fit for the sprintf() statements?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char godz[8];&#xA;char data[5];&#xA;&#xA;void gettime()&#xA;{&#xA;  DateTime now = rtc.now();&#xA;  sprintf(godz,&quot;%02d:%02d:%02d &quot;,now.hour(),now.minute(),now.second());&#xA;  sprintf(data,&quot;%d.%d&quot;,now.day(),now.month());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the worst case size required? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-12T17:07:19.480" LastActivityDate="2016-01-12T17:07:19.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19459" PostTypeId="2" ParentId="19435" CreationDate="2016-01-12T00:26:47.090" Score="2" Body="&lt;p&gt;&quot;transistor&quot; has walked you through what is necessary. Just an additional point of note: if you don't have a +/- power supply, you can easily generate the negative voltage using eg ICL7660 or even using a 555: &lt;a href=&quot;https://www.ikalogic.com/555-based-voltage-inverter-schematic/&quot; rel=&quot;nofollow&quot;&gt;https://www.ikalogic.com/555-based-voltage-inverter-schematic/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just because I'm curious, could you add a link to the servo datasheet?&lt;/p&gt;&#xA;" OwnerUserId="16008" LastActivityDate="2016-01-12T00:26:47.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19460" PostTypeId="1" CreationDate="2016-01-12T00:34:00.037" Score="1" ViewCount="273" Body="&lt;p&gt;I am using an ATtiny85 to sleep for a long period of time, collect some data, send it over radio, and go back to sleep, after disabling everything possible. The ATtiny is currently powered by a coin cell. I can get quite some time off that coin cell, but it's simply not enough, and the coin cell cannot be changed once the board is deployed. Peak current draw is around 10-15 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My aim here is to find an alternative power source for my board. Some good news is that the boards are never more than one or two feet from a receiver, so rf-like power transmission may be possible. Some other options may be motion or heat (it's a wearable device). The amount of power could be pretty small, as I only need it at peak periods, so I could just charge up a supercapacitor for a while and drain it when power is needed after the Attiny wakes up for less than a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal situation would be to have a means of power transmission or generation that provides enough current to continuously power the microcontroller without the need for sleep, but I recognize that this is probably not feasible. However, due to the limited range it might be. Another concern is radiation to the wearer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has any experience in this kind of power transmission or generation or just any ideas I would love to hear it. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15677" LastEditorUserId="15677" LastEditDate="2016-01-12T01:07:33.990" LastActivityDate="2016-02-13T05:29:21.737" Title="No Battery Microcontroller Operation - (Motion, heat, induction etc)" Tags="|power|attiny|sleep|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19461" PostTypeId="1" AcceptedAnswerId="19464" CreationDate="2016-01-12T01:48:11.813" Score="0" ViewCount="291" Body="&lt;p&gt;As part of a larger script intended for a very simple arduino &quot;synthesizer&quot; I am trying to increment the amount of cycles a melody will be played once a key is pressed (the key in turn passes a value to the variable selectMel). The problem I encounter is that the moment I call my function in the main void loop() function, I cannot control the incrementation of the variable ncycles, which is intended to be only increased once per key press. I tried to solve this by creating a global switchVar variable as an &quot;on/off&quot; switch but that did not do much to solve the issue at hand.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips or help will be greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I have of course googled and tried the solutions posted on similar stackExchange posts but to no avail, sadly.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      void playMan (int ncycles, int mSpeed) {&#xA;&#xA;        switch (selectMel) {&#xA;        case 1:&#xA;          if (ncycles &amp;gt; 0) {&#xA;            tone(12, NOTE_B7, mSpeed);&#xA;            delay(100);&#xA;            tone(12, NOTE_B5, mSpeed);&#xA;            delay(100);&#xA;            tone(12, NOTE_B3, mSpeed);&#xA;            delay(100);&#xA;            tone(12, NOTE_B1, mSpeed);&#xA;            delay(100);&#xA;            ncycles--;&#xA;            break;&#xA;          case 2:&#xA;            if (millis() % 100 == 0) {&#xA;              if (switchVar == 1) {&#xA;                ncycles += 5;&#xA;                switchVar = 0;&#xA;              }&#xA;              Serial &amp;lt;&amp;lt; ncycles &amp;lt;&amp;lt; endl;&#xA;            }&#xA;            break;&#xA;          default:&#xA;            break;&#xA;          }&#xA;        }&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15863" LastEditorUserId="10907" LastEditDate="2016-01-12T05:04:13.117" LastActivityDate="2016-01-12T22:19:14.897" Title="One time execution of a variable incrementation" Tags="|arduino-uno|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19462" PostTypeId="1" CreationDate="2016-01-12T02:51:31.743" Score="1" ViewCount="98" Body="&lt;p&gt;I'm looking at making a pretty cheap and easy odometer, eventually for an electric car or similar vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to implement a big computer mouse, and track the speed with that: a computer mouse takes photos of the surface it is on, and finds the difference between sequential images in both the X and Y directions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am wanting to do is to attach a downwards-facing camera; something like &lt;a href=&quot;http://www.aliexpress.com/item/Guaranteed-New-1Pcs-Blue-OV7670-300KP-VGA-Camera-Module-for-Arduino-Free-Shipping/1377974232.html?spm=2114.01020208.3.2.Ku9fjM&amp;amp;ws_ab_test=searchweb201556_2,searchweb201644_2_10001_10002_10005_10006_10003_10004_62,searchweb201560_1,searchweb1451318400_6150&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, to the bottom of the vehicle, and use an Arduino Nano to do the image processing to achieve a result similar to a computer mouse. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering whether anyone knows of an libraries/documentation on anything similar, or if anyone has any pointers on reasons why this would not work, or ways it would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks all.&lt;/p&gt;&#xA;" OwnerUserId="15821" LastEditorUserId="10907" LastEditDate="2016-01-12T04:56:56.720" LastActivityDate="2016-01-12T11:10:22.250" Title="Using an Arduino as the processor for a computer-mouse-like speed detector" Tags="|arduino-nano|c|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19463" PostTypeId="2" ParentId="19419" CreationDate="2016-01-12T04:54:08.343" Score="0" Body="&lt;p&gt;I think this is a timing issue. It is fairly normal for a garbage byte or two to be received shortly after doing a &lt;code&gt;Serial.begin()&lt;/code&gt; because the transition of &quot;not defined&quot; (or high impedance) output to Serial (which is normally all 1-bits) can cause the receiver to think it got a start bit, and then misinterpret what follows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try adding a short delay after &lt;code&gt;Serial.begin&lt;/code&gt;. You could also try a pull-up resistor on the serial Tx line to ensure it is high prior to &lt;code&gt;Serial.begin&lt;/code&gt; being called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your use of &lt;code&gt;Serial.available&lt;/code&gt; effectively builds in a delay.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-12T04:54:08.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19464" PostTypeId="2" ParentId="19461" CreationDate="2016-01-12T04:56:56.847" Score="2" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/switches&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you need to detect the transition between the switch not being pressed before, and &lt;strong&gt;now&lt;/strong&gt; being pressed. This transition will occur once per press (possibly after you add debouncing). If you just test for the switch pressed naturally you will get multiple increments.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Assuming I add debouncing, how would it help in incrementing the value of ncycles only once ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To clarify, you increment once on a transition, note when you did this (eg, by calling &lt;code&gt;millis()&lt;/code&gt; ) and then ignore any further transitions for, say 10 ms.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-12T22:19:14.897" LastActivityDate="2016-01-12T22:19:14.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19465" PostTypeId="2" ParentId="18534" CreationDate="2016-01-12T07:11:38.750" Score="2" Body="&lt;p&gt;It sounds to me like your system works, but you have trouble if your voltage drops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all here's 2 tips that might solve your problem.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;instead of just making 1 reading do 10 and take an average - this reduces noise.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;the voltage reference is allready based on the voltage that powers the system so with your adjusted reading you try to accomplish something which has already happened an therefore has the opposite effect and actually increase the error.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;see &lt;a href=&quot;http://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/&lt;/a&gt; for a very good explanation.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Add a RC filter to removes random fluctuations in the signal from you photoresistor &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;see &lt;a href=&quot;https://electronics.stackexchange.com/questions/17754/where-to-place-a-capacitor-to-smoothen-ir-sensor-reading&quot;&gt;https://electronics.stackexchange.com/questions/17754/where-to-place-a-capacitor-to-smoothen-ir-sensor-reading&lt;/a&gt; for a short description and the calculated example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If however it is correct, and your readings of colors don't follow a linear scale, you would have to deduce that actual curve and apply it in the code - but that might not be easy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it would be much more easy to remove that variable by ensuring that the voltage is constant. Most Arduino boards have an 5V onboard voltage regulator that will keep the voltage exactly at 5 Volt when connected to battery via the &lt;strong&gt;power Jack!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(USB bypasses this regulator and have a little voltage drop so it is sligthly lower than 5V, and more very prone to fluctations if coming from a AC source affecting your analog read considerably)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The battery connected onboard voltage regulator however requires a higher input to do the regulation so the battery needs to supply atleast 6.2V or higher, in your case you would have to use a voltage source of less than 6.2V if this is the source of your problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(the voltage regulator on original arduino boards needs voltage of 1.2V higher than the needed output - clones might differ and require upto 2v more than the needed output)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hope this can help solve the issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mikael&lt;/p&gt;&#xA;" OwnerUserId="16318" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-01-12T07:11:38.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19466" PostTypeId="1" AcceptedAnswerId="19478" CreationDate="2016-01-12T08:18:33.543" Score="2" ViewCount="9384" Body="&lt;p&gt;For a project I need to connect a &lt;strong&gt;Bluetooth Remote control&lt;/strong&gt; with an &lt;strong&gt;Arduino Nano&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino-side I have an &lt;a href=&quot;http://www.exp-tech.de/media/archive/gm/service/datasheet/HC-Serial-Bluetooth-Products.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;HC-05-Bluetooth module&lt;/a&gt;. With the Android Application &quot;Bluetooth Terminal&quot; I can verify that the connection is ok, because I can send and receive Strings with an Android smartphone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the minimal example I send values from a sensor which is connected to my Arduino via bluetooth to the smartphone, which is working nice. So I guess the wiring is correct:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  sensorValue = analogRead( sensorPin );&#xA;  cm = 10650.08 * pow( sensorValue, -0.935 ) - 10;&#xA;  Serial.println( cm );&#xA;  softSerial.println(cm);&#xA;  delay( 500 );&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of sending sensor values, I need to connect said remote with the Arduino.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KUFzI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KUFzI.jpg&quot; alt=&quot;Picture of the remote&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Picture shows the basic model of said remote control.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The remote control has the Bluetooth class &lt;code&gt;20258C&lt;/code&gt; which means:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Major Device Class: Peripheral&lt;/li&gt;&#xA;&lt;li&gt;Limited Discoverable Mode&lt;/li&gt;&#xA;&lt;li&gt;Audio&lt;/li&gt;&#xA;&lt;li&gt;Pointing device&lt;/li&gt;&#xA;&lt;li&gt;Remote control&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Remote Control Bluetooth  Specifications:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;BT Device Name: YL-BTM3-xxxxxx&lt;/li&gt;&#xA;&lt;li&gt;Supplier ID and Product ID: 0x0A5C / 0x4503&lt;/li&gt;&#xA;&lt;li&gt;Class of Device: 0x20258C&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My Question is: How can I pair those two devices? I can get the remote control into &quot;Pairing mode&quot;, by pressing 2 Buttons. But how do I pair the Arduino-Bluetooth-module with this remote-control? Is it possible at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="4131" LastEditDate="2016-01-12T15:34:45.893" LastActivityDate="2017-03-03T13:02:01.417" Title="Connect Bluetooth remote control with Arduino" Tags="|bluetooth|arduino-nano|remote-control|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19467" PostTypeId="1" AcceptedAnswerId="19469" CreationDate="2016-01-12T08:46:50.470" Score="0" ViewCount="212" Body="&lt;p&gt;Just, to make sure how it works:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I will connect the module to Arduino&lt;/li&gt;&#xA;&lt;li&gt;it will create AP to which I can connect and send commands via HTTP&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I do not need any special equipment on PC side right, I can even connect to the ESP's AP with mobile, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible for the ESP to be WIFI client and connect to regular WIFI SSID (the PC will just communicate over regular network)?&#xA;Is it possible to communicate bidirectional somehow?&lt;/p&gt;&#xA;" OwnerUserId="16332" LastEditorUserId="10907" LastEditDate="2016-01-13T00:30:26.577" LastActivityDate="2016-01-13T00:30:26.577" Title="How to integrate ESP8266" Tags="|arduino-mega|esp8266|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19468" PostTypeId="2" ParentId="19462" CreationDate="2016-01-12T09:15:23.017" Score="1" Body="&lt;p&gt;Whooa, wait a minute. This sounds way too complicated, and my guess is that a Nano would be seriously underpowered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to do all that work, you probably would need to step up your processing power. I suggest that you do some calculations on that, the number of pixels per second that should be compared. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also factor in the time it takes to capture the image, the device you suggested is probably not fast enough. My guess is that by the time you can take next picture of the surface, you don't have any part of the image to compare with. According to &lt;a href=&quot;https://en.wikipedia.org/wiki/Optical_mouse&quot; rel=&quot;nofollow&quot; title=&quot;wikipedia&quot;&gt;wikipedia&lt;/a&gt;, a modern mouse has a 18 by 18 pixel sensor, and we're not talking a lot of (surface) speed here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there's a simpler solution; mount a magnet to one of the wheels (or axle) and a reed switch so that it is actuated as the magnet sweeps by. Then use the Nano (or a Trinket, no need for power here) to count the pulses from the reed switch. Do your math; (circumference of wheel) * (pulses per time unit). Convert to suitable format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Voila; speed! :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This method was used to get accurate speed for deadreckoning, before GPS was really usable on land.. OMG, I'm old.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible problems areas - dirt, debouncing the switch, timing of arduino. But these sound simple in comparison.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastEditorUserId="4909" LastEditDate="2016-01-12T11:10:22.250" LastActivityDate="2016-01-12T11:10:22.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19469" PostTypeId="2" ParentId="19467" CreationDate="2016-01-12T09:56:22.883" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So I do not need any special equipment on PC side right, I can even connect to the ESP's AP with mobile, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you set the ESP8266 in AP you can connect to it with every wifi capable device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can control an ESP8266 with just an Arduino, but you I would not recommend using your Arduino as the power supply. If I remember correctly the mega's VCC pins are rated for 200mA which may or may not be enough for your ESP8266 I'm not sure, but I would recommend using another power supply for the ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible for the ESP to be WIFI client and connect to regular WIFI SSID&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes that is possible. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to communicate bidirectional somehow?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I am not exactly sure what you want, but it is possible to communicate in both directions. Assuming you know the local IP address of your ESP8266, you could for example send an HTTP request to it using any browser to which the ESP8266 can reply with anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your ESP8266 can also send data to your computer, but it would require some program on your computer listening for incoming connections. Also possible, but more difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At last I would like to tell you that driving an ESP8266 with an Arduino is like driving a Ferrari with the engine from a tuk tuk. It will move, but you will never use all of it's features. I don't know which version of the ESP8266 you have, but there are versions out there that can be programmed via USB just as your Arduino and you can just use the Arduino IDE and all of it's features like the Arduino language.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2016-01-12T09:56:22.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19470" PostTypeId="2" ParentId="13991" CreationDate="2016-01-12T10:10:50.623" Score="2" Body="&lt;p&gt;There are several Arduino libraries for reading DHT22 and related DHT sensors.  The Adafruit DHT library does not compile for the Due since it uses AVR specific functions not available on ARM (Due).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Arduino Due use Rob Tillaart's DHTstable library available from his &lt;a href=&quot;https://github.com/RobTillaart/Arduino&quot; rel=&quot;nofollow&quot;&gt;github page&lt;/a&gt; where you can download a zip file.  Note that his project also has a &quot;DHTlib&quot; library which does not support the Due.  There exists yet more DHT libraries which Rob has listed on the &lt;a href=&quot;http://playground.arduino.cc/Main/DHTLib&quot; rel=&quot;nofollow&quot;&gt;DHTLib page on arduino.cc&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16334" LastActivityDate="2016-01-12T10:10:50.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19471" PostTypeId="2" ParentId="10330" CreationDate="2016-01-12T10:17:17.307" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.kinovea.org&quot; rel=&quot;nofollow&quot;&gt;Kinovea&lt;/a&gt; is good but this would be post processing not live. You need record video and then you can track each runner on time. Another one is Typhon program but it involves programming and calibrating (then you can track live).&lt;/p&gt;&#xA;" OwnerUserId="16282" LastEditorUserId="10907" LastEditDate="2016-01-13T00:32:05.410" LastActivityDate="2016-01-13T00:32:05.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19472" PostTypeId="2" ParentId="13037" CreationDate="2016-01-12T10:24:54.577" Score="0" Body="&lt;p&gt;You can use Excel to smooth out data and do graphs if you need to. That's what I use myself. Easiest way is to create a table and type formula to make average from range of numbers, smoother data needs a bigger range of numbers.&lt;/p&gt;&#xA;" OwnerUserId="16282" LastEditorUserId="10907" LastEditDate="2016-01-13T00:40:28.447" LastActivityDate="2016-01-13T00:40:28.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19473" PostTypeId="1" CreationDate="2016-01-12T11:58:15.900" Score="0" ViewCount="10007" Body="&lt;p&gt;I'm new to Arduino and Stack Exchange. I've been building a fitness tracker and am receiving a certain error in the serial monitor. The accelerometer seems the work, but it seems to go to sleep after a while. I'm using an Arduino Uno (for the time being), a Bluetooth HC-05 module and an MPU6050 accelerometer. I connect it to an app, Retroband to monitor the steps taken and calories burnt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've wired it like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Accelerometer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; SDA-A4&#xA; SCL-A5&#xA; VCC-3.3v&#xA; GND-GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Bluetooth:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; VCC-3.3v&#xA; GND-GND&#xA; TX-2&#xA; RX-3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code I'm using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;/* Bluetooth */&#xA;SoftwareSerial BTSerial(2, 3); //Connect HC-06. Use your (TX, RX) settings&#xA;&#xA;/* time */&#xA;#define SENDING_INTERVAL 1000&#xA;#define SENSOR_READ_INTERVAL 50&#xA;unsigned long prevSensoredTime = 0;&#xA;unsigned long curSensoredTime = 0;&#xA;&#xA;/* Data buffer */&#xA;#define ACCEL_BUFFER_COUNT 125&#xA;byte aAccelBuffer[ACCEL_BUFFER_COUNT];&#xA;int iAccelIndex = 2;&#xA;&#xA;/* MPU-6050 sensor */&#xA;#define MPU6050_ACCEL_XOUT_H 0x3B // R&#xA;#define MPU6050_PWR_MGMT_1 0x6B // R/W&#xA;#define MPU6050_PWR_MGMT_2 0x6C // R/W&#xA;#define MPU6050_WHO_AM_I 0x75 // R&#xA;#define MPU6050_I2C_ADDRESS 0x68&#xA;&#xA;typedef union accel_t_gyro_union {&#xA;  struct {&#xA;    uint8_t x_accel_h;&#xA;    uint8_t x_accel_l;&#xA;    uint8_t y_accel_h;&#xA;    uint8_t y_accel_l;&#xA;    uint8_t z_accel_h;&#xA;    uint8_t z_accel_l;&#xA;    uint8_t t_h;&#xA;    uint8_t t_l;&#xA;    uint8_t x_gyro_h;&#xA;    uint8_t x_gyro_l;&#xA;    uint8_t y_gyro_h;&#xA;    uint8_t y_gyro_l;&#xA;    uint8_t z_gyro_h;&#xA;    uint8_t z_gyro_l;&#xA;  } reg;&#xA;&#xA;  struct {&#xA;    int x_accel;&#xA;    int y_accel;&#xA;    int z_accel;&#xA;    int temperature;&#xA;    int x_gyro;&#xA;    int y_gyro;&#xA;    int z_gyro;&#xA;  } value;&#xA;};&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  int error;&#xA;  uint8_t c;&#xA;&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  BTSerial.begin(9600);  // set the data rate for the BT port&#xA;&#xA;  // default at power-up:&#xA;  // Gyro at 250 degrees second&#xA;  // Acceleration at 2g&#xA;  // Clock source at internal 8MHz&#xA;  // The device is in sleep mode.&#xA;  //&#xA;  error = MPU6050_read (MPU6050_WHO_AM_I, &amp;amp;c, 1);&#xA;  Serial.print(F(&quot;WHO_AM_I : &quot;));&#xA;  Serial.print(c,HEX);&#xA;  Serial.print(F(&quot;, error = &quot;));&#xA;  Serial.println(error,DEC);&#xA;&#xA;  // According to the datasheet, the 'sleep' bit&#xA;  // should read a '1'. But I read a '0'.&#xA;  // That bit has to be cleared, since the sensor&#xA;  // is in sleep mode at power-up. Even if the&#xA;  // bit reads '0'.&#xA;  error = MPU6050_read (MPU6050_PWR_MGMT_2, &amp;amp;c, 1);&#xA;  Serial.print(F(&quot;PWR_MGMT_2 : &quot;));&#xA;  Serial.print(c,HEX);&#xA;  Serial.print(F(&quot;, error = &quot;));&#xA;  Serial.println(error,DEC);&#xA;&#xA;  // Clear the 'sleep' bit to start the sensor.&#xA;  MPU6050_write_reg (MPU6050_PWR_MGMT_1, 0);&#xA;&#xA;  initBuffer();&#xA;}&#xA;&#xA;void loop() {&#xA;  curSensoredTime = millis();&#xA;&#xA;  // Read from sensor&#xA;  if(curSensoredTime - prevSensoredTime &amp;gt; SENSOR_READ_INTERVAL) {&#xA;    readFromSensor();  // Read from sensor&#xA;    prevSensoredTime = curSensoredTime;&#xA;&#xA;    // Send buffer data to remote&#xA;    if(iAccelIndex &amp;gt;= ACCEL_BUFFER_COUNT - 3) {&#xA;      sendToRemote();&#xA;      initBuffer();&#xA;      Serial.println(&quot;------------- Send 20 accel data to remote&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;/**************************************************&#xA; * BT Transaction&#xA; **************************************************/&#xA;void sendToRemote() {&#xA;  // Write gabage bytes&#xA;  BTSerial.write( &quot;accel&quot; );&#xA;  // Write accel data&#xA;  BTSerial.write( (char*)aAccelBuffer );&#xA;  // Flush buffer&#xA;  //BTSerial.flush();&#xA;}&#xA;&#xA;/**************************************************&#xA; * Read data from sensor and save it&#xA; **************************************************/&#xA;void readFromSensor() {&#xA;  int error;&#xA;  double dT;&#xA;  accel_t_gyro_union accel_t_gyro;&#xA;&#xA;  error = MPU6050_read (MPU6050_ACCEL_XOUT_H, (uint8_t *) &amp;amp;accel_t_gyro, sizeof(accel_t_gyro));&#xA;  if(error != 0) {&#xA;    Serial.print(F(&quot;Read accel, temp and gyro, error = &quot;));&#xA;    Serial.println(error,DEC);&#xA;  }&#xA;&#xA;  // Swap all high and low bytes.&#xA;  // After this, the registers values are swapped,&#xA;  // so the structure name like x_accel_l does no&#xA;  // longer contain the lower byte.&#xA;  uint8_t swap;&#xA;  #define SWAP(x,y) swap = x; x = y; y = swap&#xA;  SWAP (accel_t_gyro.reg.x_accel_h, accel_t_gyro.reg.x_accel_l);&#xA;  SWAP (accel_t_gyro.reg.y_accel_h, accel_t_gyro.reg.y_accel_l);&#xA;  SWAP (accel_t_gyro.reg.z_accel_h, accel_t_gyro.reg.z_accel_l);&#xA;  SWAP (accel_t_gyro.reg.t_h, accel_t_gyro.reg.t_l);&#xA;  SWAP (accel_t_gyro.reg.x_gyro_h, accel_t_gyro.reg.x_gyro_l);&#xA;  SWAP (accel_t_gyro.reg.y_gyro_h, accel_t_gyro.reg.y_gyro_l);&#xA;  SWAP (accel_t_gyro.reg.z_gyro_h, accel_t_gyro.reg.z_gyro_l);&#xA;&#xA;  // Print the raw acceleration values&#xA;  Serial.print(F(&quot;accel x,y,z: &quot;));&#xA;  Serial.print(accel_t_gyro.value.x_accel, DEC);&#xA;  Serial.print(F(&quot;, &quot;));&#xA;  Serial.print(accel_t_gyro.value.y_accel, DEC);&#xA;  Serial.print(F(&quot;, &quot;));&#xA;  Serial.print(accel_t_gyro.value.z_accel, DEC);&#xA;  Serial.print(F(&quot;, at &quot;));&#xA;  Serial.print(iAccelIndex);&#xA;  Serial.println(F(&quot;&quot;));&#xA;&#xA;  if(iAccelIndex &amp;lt; ACCEL_BUFFER_COUNT &amp;amp;&amp;amp; iAccelIndex &amp;gt; 1) {&#xA;    int tempX = accel_t_gyro.value.x_accel;&#xA;    int tempY = accel_t_gyro.value.y_accel;&#xA;    int tempZ = accel_t_gyro.value.z_accel;&#xA;    /*&#xA;    // Check min, max value&#xA;    if(tempX &amp;gt; 16380) tempX = 16380;&#xA;    if(tempY &amp;gt; 16380) tempY = 16380;&#xA;    if(tempZ &amp;gt; 16380) tempZ = 16380;&#xA;&#xA;    if(tempX &amp;lt; -16380) tempX = -16380;&#xA;    if(tempY &amp;lt; -16380) tempY = -16380;&#xA;    if(tempZ &amp;lt; -16380) tempZ = -16380;&#xA;&#xA;    // We dont use negative value&#xA;    tempX += 16380;&#xA;    tempY += 16380;&#xA;    tempZ += 16380;&#xA;    */&#xA;    char temp = (char)(tempX &amp;gt;&amp;gt; 8);&#xA;    if(temp == 0x00)&#xA;      temp = 0x7f;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;    temp = (char)(tempX);&#xA;    if(temp == 0x00)&#xA;      temp = 0x01;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;&#xA;    temp = (char)(tempY &amp;gt;&amp;gt; 8);&#xA;    if(temp == 0x00)&#xA;      temp = 0x7f;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;    temp = (char)(tempY);&#xA;    if(temp == 0x00)&#xA;      temp = 0x01;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;&#xA;    temp = (char)(tempZ &amp;gt;&amp;gt; 8);&#xA;    if(temp == 0x00)&#xA;      temp = 0x7f;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;    temp = (char)(tempZ);&#xA;    if(temp == 0x00)&#xA;      temp = 0x01;&#xA;    aAccelBuffer[iAccelIndex] = temp;&#xA;    iAccelIndex++;&#xA;  }&#xA;&#xA;  // The temperature sensor is -40 to +85 degrees Celsius.&#xA;  // It is a signed integer.&#xA;  // According to the datasheet:&#xA;  // 340 per degrees Celsius, -512 at 35 degrees.&#xA;  // At 0 degrees: -512 - (340 * 35) = -12412&#xA;//  Serial.print(F(&quot;temperature: &quot;));&#xA;//  dT = ( (double) accel_t_gyro.value.temperature + 12412.0) / 340.0;&#xA;//  Serial.print(dT, 3);&#xA;//  Serial.print(F(&quot; degrees Celsius&quot;));&#xA;//  Serial.println(F(&quot;&quot;));&#xA;&#xA;  // Print the raw gyro values.&#xA;//  Serial.print(F(&quot;gyro x,y,z : &quot;));&#xA;//  Serial.print(accel_t_gyro.value.x_gyro, DEC);&#xA;//  Serial.print(F(&quot;, &quot;));&#xA;//  Serial.print(accel_t_gyro.value.y_gyro, DEC);&#xA;//  Serial.print(F(&quot;, &quot;));&#xA;//  Serial.print(accel_t_gyro.value.z_gyro, DEC);&#xA;//  Serial.println(F(&quot;&quot;));&#xA;}&#xA;&#xA;/**************************************************&#xA; * MPU-6050 Sensor read/write&#xA; **************************************************/&#xA;int MPU6050_read(int start, uint8_t *buffer, int size)&#xA;{&#xA;  int i, n, error;&#xA;&#xA;  Wire.beginTransmission(MPU6050_I2C_ADDRESS);&#xA;&#xA;  n = Wire.write(start);&#xA;  if (n != 1)&#xA;    return (-10);&#xA;&#xA;  n = Wire.endTransmission(false); // hold the I2C-bus&#xA;  if (n != 0)&#xA;    return (n);&#xA;&#xA;  // Third parameter is true: relase I2C-bus after data is read.&#xA;  Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true);&#xA;  i = 0;&#xA;  while(Wire.available() &amp;amp;&amp;amp; i&amp;lt;size)&#xA;  {&#xA;    buffer[i++]=Wire.read();&#xA;  }&#xA;  if ( i != size)&#xA;    return (-11);&#xA;  return (0); // return : no error&#xA;}&#xA;&#xA;int MPU6050_write(int start, const uint8_t *pData, int size)&#xA;{&#xA;  int n, error;&#xA;&#xA;  Wire.beginTransmission(MPU6050_I2C_ADDRESS);&#xA;&#xA;  n = Wire.write(start); // write the start address&#xA;  if (n != 1)&#xA;    return (-20);&#xA;&#xA;  n = Wire.write(pData, size); // write data bytes&#xA;  if (n != size)&#xA;    return (-21);&#xA;&#xA;  error = Wire.endTransmission(true); // release the I2C-bus&#xA;  if (error != 0)&#xA;    return (error);&#xA;  return (0); // return : no error&#xA;}&#xA;&#xA;int MPU6050_write_reg(int reg, uint8_t data)&#xA;{&#xA;  int error;&#xA;  error = MPU6050_write(reg, &amp;amp;data, 1);&#xA;  return (error);&#xA;}&#xA;&#xA;&#xA;/**************************************************&#xA; * Utilities&#xA; **************************************************/&#xA;void initBuffer() {&#xA;  iAccelIndex = 2;&#xA;  for(int i=iAccelIndex; i&amp;lt;ACCEL_BUFFER_COUNT; i++) {&#xA;    aAccelBuffer[i] = 0x00;&#xA;  }&#xA;  aAccelBuffer[0] = 0xfe;&#xA;  aAccelBuffer[1] = 0xfd;&#xA;  aAccelBuffer[122] = 0xfd;&#xA;  aAccelBuffer[123] = 0xfe;&#xA;  aAccelBuffer[124] = 0x00;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the error I got in serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    WHO_AM_I : 0, error = 2&#xA;PWR_MGMT_2 : 0, error = 2&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, -3840, at 2&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 8&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 14&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 20&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 26&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 32&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 38&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 44&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 50&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 56&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 62&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 68&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 74&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 80&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 86&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 92&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 98&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 104&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: 2969, 409, 123, at 110&#xA;Read accel, temp and gyro, error = 2&#xA;accel x,y,z: -26357, -26367, 31488, at 116&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not too good at Arduino, and any help will be immensely appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16335" LastEditorUserId="6936" LastEditDate="2016-01-14T23:28:03.610" LastActivityDate="2016-06-13T12:23:24.717" Title="How to solve &quot;error 2&quot; from the Arduino MPU6050 accelerometer" Tags="|arduino-uno|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19474" PostTypeId="1" AcceptedAnswerId="19477" CreationDate="2016-01-12T12:02:07.797" Score="0" ViewCount="546" Body="&lt;p&gt;I am currently working on an arduino project and wanted to use a GSM module. This is my first time working with a GSM module. So I had a few queries.&lt;br&gt;&#xA;&lt;br&gt;&#xA;What can a GSM module sim900a do with arduino programming?&#xA;&lt;br&gt;Also can it do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Send sms when motion is detected by a PIR sensor&lt;/li&gt;&#xA;&lt;li&gt;Send sms to only a particular group of cell phones.&lt;/li&gt;&#xA;&lt;li&gt;Respond to a particular kind of sms&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2016-01-12T14:10:55.327" Title="Functions of GSM" Tags="|gsm|robotics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19475" PostTypeId="2" ParentId="19474" CreationDate="2016-01-12T12:07:28.483" Score="2" Body="&lt;p&gt;None of those things you ask are a function of the SIM900A GSM module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SIM900A GSM module is capable of sending and receiving text messages (SMS). What you do with those text messages, and what text messages you send to where is entirely down to your Arduino program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are asking is like &quot;Can this car drive from Manchester to Carlisle?&quot; The car can be driven from place to place, but it's &lt;em&gt;you&lt;/em&gt; that does the driving. So you should be asking &quot;I have a car. Am I capable of driving it from Manchester to Carlisle?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, the SIM900A GSM module is capable of being used to achieve those three things you ask, but the real question is not can the SIM900A do them, but &lt;em&gt;can you program the Arduino to get a SIM900A to do them?&lt;/em&gt; And the answer is &quot;Yes, it is perfectly possible if you know how&quot;, and we can help you to know how when you start working on the project and come across some stumbling blocks in your programming.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-12T12:07:28.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19476" PostTypeId="2" ParentId="19460" CreationDate="2016-01-12T12:20:30.633" Score="1" Body="&lt;p&gt;10mA is quite a lot for a coin cell. And of course the duration is really low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for wireless power transmission, I highly discourage you. Since you are using coin cell batteries I think that size is a must for you, and for wireless power you will need a really big antenna. If it is a wearable I think that the receiver is on the body too, and so much power is not a good thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my opinion and according to my experience you have two possibilities:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;use alkaline batteries (e.g. AAA). Use a step up driver to get 3.3V from 1.5V (since the current you need is low you can use simple charge pump regulators, so with a 10pin TSSOP integrate and three small capacitors you are done) and you will get a really long lasting circuit. Drawback: AAA batteries are a bit large, so probably you'll have to make a bigger receiver&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use lithium batteries (usually I use LiPo). You will then be able to recharge the battery with any power supply (I usually use an IC which can charge LiPos with a 5V source - USB - and a couple of other components (two capacitors and a LED with its resistor).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Personally I struggled with coin cells for a long time before giving up and sticking with lipos forever.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10907" LastEditDate="2016-01-14T04:35:46.837" LastActivityDate="2016-01-14T04:35:46.837" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19477" PostTypeId="2" ParentId="19474" CreationDate="2016-01-12T12:29:05.300" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Send sms when motion is detected by a PIR sensor&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;, write a function that does this. Basic support functions in libraries will help you send the sms and detect the PIR. You need to provide the logic. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;2&quot;&gt;&#xA;  &lt;li&gt;Send sms to only a particular group of cell phones.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the question is if the GSM module supports group send the answer is &lt;strong&gt;no&lt;/strong&gt;. You will have to write a function that sends the SMS to each number in the group.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol start=&quot;3&quot;&gt;&#xA;  &lt;li&gt;Respond to a particular kind of sms&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;, again but now you have to write a function that parses incoming messages and does some actions (just as any input parse). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to all these questions is &lt;strong&gt;no&lt;/strong&gt; if the function is already available in libraries. The answer is &lt;strong&gt;maybe&lt;/strong&gt; if someone has already done something similar. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-12T14:10:55.327" LastActivityDate="2016-01-12T14:10:55.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19478" PostTypeId="2" ParentId="19466" CreationDate="2016-01-12T12:30:04.473" Score="3" Body="&lt;p&gt;This should be a comment, but..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For starters, you'll need to do the pairing from the Arduino with the HC-05 in master mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check &lt;a href=&quot;https://alselectro.wordpress.com/2014/10/21/bluetooth-hc05-how-to-pair-two-modules/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; out.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-01-12T12:30:04.473" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19479" PostTypeId="2" ParentId="19473" CreationDate="2016-01-12T13:39:08.713" Score="1" Body="&lt;p&gt;You have a problem that you can see (the error 2) and a theory about what might be causing it (the accelerometer going to sleep). That's a great place to start from!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a few of suggestions to make:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Collect documentation for the components you are using, a data sheet for the accelerometer, tutorials and instructions for the code to drive it, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A search on:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;MPU6050 accelerometer data sheet&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;is likely to get you lots of links to sites hosting data sheets for the accelerometer. With luck you'll be able to find the actual vendor and in addition to the data sheet you may able to find application notes there as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the library, you may find a tutorial or an API description on the site where you downloaded it. You can also do a search on something like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;MPU6050 accelerometer tutorial&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to find suggestions for how to get started with the device and the code to use it. Tutorials often have sections on testing and avoiding common pitfalls with the device.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once you have some documentation see what you can learn about the error. Who generates &quot;error 2?&quot; What does it mean? When does it occur? Once you understand the problem, the answer may be obvious.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create minimal test cases. The code sample above is a lot for you, or us, to make sense of and then to test/debug. Pare your code down (or build it up, depending where you are in the process and how you like to work on problems) until you have the &lt;strong&gt;minimum&lt;/strong&gt; code needed to test the accelerometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you see the problem in that code? If you do, then you have many fewer possible problems to look at. If you don't, then add the next piece – perhaps in this case, try to exercise the condition that &quot;error 2&quot; is supposed to report (does it still seem likely that &quot;going to sleep&quot; is the problem?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you're still stumped at this point you've got the resources at hand to post a great question and the evidence that you've worked on it and understand it for yourself will go a long way towards establishing good will with the people who are trying to help you find answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is (potentially) a hardware &lt;strong&gt;and&lt;/strong&gt; a software problem, be sure to include an accurate schematic, or photo, of how your project is put together. If you are using someone else's schematic be especially cautious of any potential differences!&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-12T13:39:08.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19480" PostTypeId="2" ParentId="19447" CreationDate="2016-01-12T13:40:49.573" Score="1" Body="&lt;p&gt;It really doesn't matter if you use a PNP or NPN transistor, they are just mirrors of one another. If you have some common anode displays then just start directly with the PNP's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flaw I see in your circuit is that you should always use 2 resistors to drive a LED (See schematic). R2 (as you already have) will limit the current to the LED; 220 Ohm you as illustrated is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1 is needed between the I/O pin and your transistor. This will limit the current through the I/O pin. For what you are attempting a resistor in the range 1K to 2K should do, even if you're switching a few LED's in parallel. &#xA;If you provide complete details of your setup we can always refine the calculations. One can then take into account the total currents from your displays, the amplification factor of the transistor (hfe) etc. &lt;a href=&quot;https://i.stack.imgur.com/dGZvJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dGZvJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-12T13:40:49.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19481" PostTypeId="2" ParentId="19442" CreationDate="2016-01-12T14:25:33.027" Score="0" Body="&lt;p&gt;First version with conversion from char[] to Arduino String class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char received[20];&#xA;...&#xA;// Some code that assigns received&#xA;...&#xA;String randomString(received); &#xA;Serial.println(randomString);&#xA;&#xA;// Clear string&#xA;randomString = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second version without the Arduino String class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char received[20];&#xA;...&#xA;// Some code that assigns received&#xA;...&#xA;Serial.println(received);&#xA;&#xA;// Empty received buffer&#xA;received[0] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And third version where the buffer is cleared:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char received[20];&#xA;...&#xA;// Some code that assigns received&#xA;...&#xA;Serial.println(received);&#xA;&#xA;// Clear received buffer&#xA;memset(received, 0, sizeof(received)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-12T14:25:33.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19483" PostTypeId="2" ParentId="19460" CreationDate="2016-01-12T15:11:31.917" Score="0" Body="&lt;p&gt;This question seems to be aligned to your other question about nrf24l01+ transceiver. The charge pump is a good idea, but if this is still for the nrf24l01+ project i would not recommend it because it would cause ripples in the supplied power and RF noise which is really not something you want together with the nrf24l01+.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if the unit is to be strapped on the wrist or ankles a concept like the one in a shake/faraday flashligt might be implemented, but that would be a diy custom job. and probably require size, even though they can fit a similiar contraption into a wristwatch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But anyway I'm not sure if you are aware, but the nrf24l01+ has a function called enhanced shockburst which is designed for very low current consumption according to the datasheet it only requires 1% or 0.12ma at normal transmitting mode! this comes at the cost of transmitting power ofcourse but your receiver is only a few feet away so that is most likely not an issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf&lt;/a&gt; page 14&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure you already have optimised your current consumption, but one setting you might have missed is  the atTiny clockspeed which can be lowered to 1mHz instead of 8mHz this will lower the current to run the processor to 20 of the normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if these are not implemented already, then they might give you the needed battery life.&lt;/p&gt;&#xA;" OwnerUserId="16318" LastActivityDate="2016-01-12T15:11:31.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19484" PostTypeId="2" ParentId="14680" CreationDate="2016-01-12T16:07:01.707" Score="2" Body="&lt;p&gt;Although I am still figuring things out, but i hope the following things help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.solar4rschools.org/sites/default/files/robotic-sunflower-lesson4-handout4.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.solar4rschools.org/sites/default/files/robotic-sunflower-lesson4-handout4.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem, as far as I think is that the enable pins are the ones which are supposed to help you control the speed. Please connect them to the PWM ports on your Arduino/any other device you may be using for your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you can simply write a code which keeps on disabling and enabling the enable pins to get the desired speed (that's what PWM is supposed to do but you can try it this way, at least).&lt;/p&gt;&#xA;" OwnerUserId="16347" LastActivityDate="2016-01-12T16:07:01.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19485" PostTypeId="1" CreationDate="2016-01-12T16:09:04.490" Score="1" ViewCount="761" Body="&lt;p&gt;I will start by saying I am very new to using Arduino.  The project I am planning is to create several arrays of sensors (each array will consist of 4 DS18B20 sensors and one temperature/humidity sensor) and using a MUX connected to Arduino I want to read the data from each [ten] array.  I have found sketches I can modify to do this task in a continuous cycle but I need to be able to display data from an array for an extended time period of several minutes.  My Arduino will output to a 3.2&quot; LCD so there is only enough screen space to show data for one array at a time.  &lt;/p&gt;&#xA;" OwnerUserId="16346" LastActivityDate="2016-01-12T18:08:38.993" Title="Reading sensor data over MUX" Tags="|temperature-sensor|multiplexer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19486" PostTypeId="2" ParentId="18842" CreationDate="2016-01-12T16:23:10.270" Score="1" Body="&lt;p&gt;I don't really se anything wrong with the wiring, atleast your diagram seems to be in order. only thing I would ad is give the pin 8 a ceramic capacitor to ground&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but There is a few possible issues you can check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 -the sparks make me think that you had a Loose connection at the spark site on the breadboard, maybe the IC was not properly pushed Down in the breadboard, this happens alot, try Again and make sure the IC is complete inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - if this does not work You might have destroyed the first L293 or the breadboard tracks but if you have more than one try to see if a replacement or movement of the old ic does the trick&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 -  the motors are to large, and so the current drawn is to high for the L293 to handle and caused thermal shutdown of the L293, a very high current drain will also occur if the motor is stalled. Anyway add some current limiting resistors and see what happends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4 - if the motor hums without moving then it is because Both the forward and reverse input eg. 1 and 2 is enabled simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5 - the code is not appended, so that cannot be verfified, but the MPU 6050 is correctly installed&lt;/p&gt;&#xA;" OwnerUserId="16318" LastActivityDate="2016-01-12T16:23:10.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19487" PostTypeId="2" ParentId="8135" CreationDate="2016-01-12T16:48:24.493" Score="0" Body="&lt;p&gt;Should've been a comment, but...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, your questions 1 and 2: yes, that can be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd go for a HC-05 just like Omer suggests. And if you want to pair them, it is perfectly possible to pair one master with several slaves. Depending on implementation, a slave can connect to several masters too. The HC-05 can switch between these modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't do it with a NRF8001, as this is a BLE slave device only, it won't do scanning. Try to find a device that can do both, like &lt;a href=&quot;http://redbearlab.com/blemini/&quot; rel=&quot;nofollow&quot;&gt;BLE mini&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't mix BLE and Bluetooth devices for this, it's either or.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-01-12T16:48:24.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19488" PostTypeId="2" ParentId="19485" CreationDate="2016-01-12T17:44:28.353" Score="1" Body="&lt;p&gt;The DS18B20 is a &lt;a href=&quot;http://playground.arduino.cc/Learning/OneWire&quot; rel=&quot;nofollow&quot;&gt;1-Wire&lt;/a&gt; device and doesn't require a multiplexer, each device has its own address on the bus and you can connect a lot of them with a single wire. Depending on the humidity sensor you pick you may be able to use the same bus for it as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is harder to find 1-Wire humidity sensors, but you could use a &lt;a href=&quot;http://electronicdesign.com/test-amp-measurement/1-wire-technology-simplifies-humidity-and-temperature-measurement&quot; rel=&quot;nofollow&quot;&gt;DS2438 Smart Battery Monitor&lt;/a&gt; which also includes an ADC to give you values from an analog humidity sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The challenge of designing your project will be setting up an easy to understand display and controlling how/when it changes.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-12T18:08:38.993" LastActivityDate="2016-01-12T18:08:38.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19489" PostTypeId="1" CreationDate="2016-01-12T18:02:59.167" Score="2" ViewCount="13734" Body="&lt;p&gt;I have an Arduino Uno. It doesn't have a lot of memory space, which is a bit of a nuisance. I was wondering:  Is it possible to load a text file from an SD card and compile it on the Arduino into code that the Arduino can use. I don't really care if it is slow or uses 99% of the memory space just to load on the code. If it is possible would this work: use bootup code to load a piece of code to Arduino, dispose of bootup code so there is more code, do what ever that code does, dispose of that code, load new code.&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="3917" LastEditDate="2016-01-12T19:15:11.377" LastActivityDate="2016-01-13T00:04:02.420" Title="Load Arduino flash code from SD card" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19490" PostTypeId="2" ParentId="19454" CreationDate="2016-01-12T18:28:20.697" Score="1" Body="&lt;p&gt;Your code seems fine, I cannot give a comment yet due to me not being a high enough ranked member, so i will try to phrase this as annswer instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your arduino might be the problem, but I don't think it is likely as the clock is known to be troublesome, but as &quot;transistor&quot; suggested you should let it run on the serial for some time so that you can see if time is reported correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I time is not working then I would like to direct your attention to this thread on the arduino forum, as this is apperently a very poor module. Several people have clocks that doesn't function properbly and there is many post adressing troubleshooting, but since this is supposed to be answer I have taken the top issues and put in below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=177297.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=177297.0&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;primarely they problems come from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;an unrechargeable &lt;strong&gt;Cr&lt;/strong&gt;2032 battery is shipped, instead of a rechargeable &lt;strong&gt;li&lt;/strong&gt;2032, this cause the charging Circuit on the board to act up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fix : replace to &lt;strong&gt;li&lt;/strong&gt;2032 or remove charging circuitry - se link&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ungrounded crystal - may or may not be a real issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fix: ground the crystal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bad crystal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fix: replace crystal&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Error in design - Resistor nr. 7 in place&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fix: remove resistor&lt;/p&gt;&#xA;" OwnerUserId="16318" LastActivityDate="2016-01-12T18:28:20.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19491" PostTypeId="2" ParentId="19489" CreationDate="2016-01-12T19:12:55.177" Score="5" Body="&lt;p&gt;See &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=16812.0&quot; rel=&quot;noreferrer&quot;&gt;topic #16812&lt;/a&gt;, “Load sketch code from SD Card”, in forum.arduino.cc, which explains how to replace the ordinary Arduino bootloader with one that can load programs from an SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://dangerousprototypes.com/2012/02/22/bootdrive-load-arduino-sketches-from-a-sd-card/&quot; rel=&quot;noreferrer&quot;&gt;Bootdrive loads Arduino sketches from SD card&lt;/a&gt; at dangerousprototypes.com, which gives different code to do the same thing.  It also mentions &lt;a href=&quot;http://baldwisdom.com/bootdrive/&quot; rel=&quot;noreferrer&quot;&gt;BootDrive for Arduino&lt;/a&gt; from baldwisdom.com.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the program code that these loaders install into flash is already compiled, as opposed to being original C source code.  If you want to load source-level code into the Arduino, look for an interpreter / interpretive language to run on the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-12T19:12:55.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19492" PostTypeId="1" CreationDate="2016-01-12T19:14:20.733" Score="0" ViewCount="1474" Body="&lt;p&gt;I have replaced my Arduino, thinking it would solve the problem, but I still get it. Whenever I try to upload code, I get the error messages programmer is not responding and not in sync. Then I heard Arduino had drivers required. But my Windows 8.1 didn't recognize Arduino Uno. It was put in the other devices area as an unknown device in the device manager. The update driver button is greyed out. I get the message: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The drivers for this device are not installed (code 28). There are no&#xA;  compatible drivers for this device. To find a driver for this device,&#xA;  click update driver.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's the greyed out button… When I look at driver details, it says 'No driver files are required or have been loaded for this device.' For the not in sync/programmer not responding error, I've tried restarting the board before uploading, restarting whilst uploading, you say it, I've done it. How can I fix this so I can finally follow my dream to be an engineer/programmer?&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastEditorUserId="10907" LastEditDate="2016-01-13T00:48:07.263" LastActivityDate="2016-01-13T01:02:03.997" Title="Problems with Windows 8.1 install of Arduino IDE" Tags="|arduino-uno|windows|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19493" PostTypeId="1" AcceptedAnswerId="19494" CreationDate="2016-01-12T20:11:59.493" Score="2" ViewCount="1016" Body="&lt;p&gt;I'm looking for a way to measure temperatures in range of 40 to -200 °C (100 to −320 °F). The usual solution DS18B20 works only down to -55 °C (-67 °F).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;p.s.&lt;/em&gt; &#xA;Precision of 2 °C would be good enough.&lt;/p&gt;&#xA;" OwnerUserId="16353" LastActivityDate="2016-01-12T20:39:58.827" Title="Sensor for very low temperature (liquid nitrogen)" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19494" PostTypeId="2" ParentId="19493" CreationDate="2016-01-12T20:20:50.013" Score="2" Body="&lt;p&gt;You probably want a K-type thermocouple (the most common type).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have a range of around -200°C to +1350°C (depending on probe).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively a Resistive Temperature Device (RTD) can be used, since these have a typical range of around -240°C to 650°C with higher accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be of help to you: &lt;a href=&quot;http://digital.ni.com/public.nsf/allkb/C50FA55B3B2F85D9862572D00083350E&quot; rel=&quot;nofollow&quot;&gt;http://digital.ni.com/public.nsf/allkb/C50FA55B3B2F85D9862572D00083350E&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-12T20:20:50.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19495" PostTypeId="2" ParentId="19460" CreationDate="2016-01-12T20:26:18.470" Score="0" Body="&lt;p&gt;I just helped a friend install a Fitbit &quot;Zip&quot; model. In the process of doing that I noticed it is powered by a CR2025 (3V lithium button) battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their ads claim it runs &quot;up to 6 months&quot; on this battery. It communicates wirelessly (ie. Bluetooth) as well as having an LCD screen. It also takes measurements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, what you are trying to achieve sounds technically possible, as someone has done it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can get a few weeks depending upon usage, and I need a few months. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So to solve your problem it would help to know what your existing current consumption is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a project about an &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12769&quot; rel=&quot;nofollow&quot;&gt;ATtiny85 torch locator&lt;/a&gt;. That does not do radio transmission but &lt;strong&gt;does&lt;/strong&gt; flash an LED. I calculate the battery should last 3 years, and at this stage (almost a year after I made it) it is still working on the same battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may get some ideas from that link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I calculated (and confirmed by measurement) that in idle mode it uses 4.4 µA. You should be getting a similar figure during your sleep periods.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-12T20:26:18.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19496" PostTypeId="2" ParentId="19493" CreationDate="2016-01-12T20:39:58.827" Score="1" Body="&lt;p&gt;I did a search on &quot;cryogenic temperature sensors&quot; and found these from &lt;a href=&quot;http://www.lakeshore.com/products/Cryogenic-Temperature-Sensors/Pages/default.aspx&quot; rel=&quot;nofollow&quot;&gt;Lake Shore Cyrotronics&lt;/a&gt; – the price is shocking. It appears that you can use &lt;a href=&quot;http://www.lakeshore.com/products/cryogenic-temperature-sensors/silicon-diodes/dt-670/Pages/Overview.aspx&quot; rel=&quot;nofollow&quot;&gt;silicon diodes&lt;/a&gt; as cryogenic temperature sensors, so you might be able to use less expensive parts if you don't need a ton of accuracy.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-12T20:39:58.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19497" PostTypeId="2" ParentId="17609" CreationDate="2016-01-12T20:42:52.693" Score="1" Body="&lt;p&gt;To my understanding you want to make some sort of device that will count X min. To get X you configure the 4 dip switches to get the time (0000 - 1111 or 0 - 15). The easiest way is to configure 4 pins to INPUT_PULLUP then you wire your switch to those pins and to ground. If the pin is grounded (switch in the on state) it will register a 0 and if the pin is NOT grounded (switch in the off state) it will register a 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note: if all switch are &quot;off&quot; you will get a max value of 15 based on my example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long startTime;&#xA;void setup(){&#xA;    pinMode(7, INPUT_PULLUP); //8bit&#xA;    pinMode(6, INPUT_PULLUP); //4bit&#xA;    pinMode(5, INPUT_PULLUP); //2bit&#xA;    pinMode(4, INPUT_PULLUP); //1bit&#xA;&#xA;    startTime = millis();&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;    long inputTime = 0;&#xA;&#xA;    if(digitalRead(7))&#xA;        inputTime += 8;&#xA;&#xA;    if(digitalRead(6))&#xA;        inputTime += 4;&#xA;&#xA;    if(digitalRead(5))&#xA;        inputTime += 2;&#xA;&#xA;    if(digitalRead(4))&#xA;        inputTime += 1;&#xA;&#xA;    inputTime = 60000*inputTime;&#xA;&#xA;    if(millis() - startTime &amp;lt;= inputTime){&#xA;        //X min has passed -- Do something here if you like&#xA;&#xA;        startTime = millis(); //reset the timer&#xA;    }else{&#xA;        //Time not yet reached -- Do something here if you like&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5116" LastActivityDate="2016-01-12T20:42:52.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19498" PostTypeId="2" ParentId="18108" CreationDate="2016-01-12T21:12:40.350" Score="0" Body="&lt;p&gt;I think it depends on what you want to use it for. I compared using PWM and bit banging to run a small DC motor.  PWM produced an audible whine that I found very irritating.  Using the delay function removed that (a delay on/off cycle of 10 milliseconds).  I also found that it was relatively easy to control not only the ratio of on/off (PWM) but also the length of the cycle.  This was useful for starting the motor with a slightly higher &quot;push&quot; to get it moving. (I'm sure that this could be done using PWM too) With respect to performance of the engine, I didn't find much actual difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key issue with a DC motor is that while the digitalWrite() is LOW, the inertia of the motor carries the rotation on and so the effect of the delay is smoothed.  In addition the RPM of the motor wasn't critical for my application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if one was running a LED then using delay() might be visibly discernable and cause discomfort (and possibly seizures?).  For this, I'd definitely use PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;regards&#xA;Mark&lt;/p&gt;&#xA;" OwnerUserId="16356" LastActivityDate="2016-01-12T21:12:40.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19499" PostTypeId="2" ParentId="19467" CreationDate="2016-01-12T21:45:59.787" Score="0" Body="&lt;p&gt;Just wanted to second what @larzz11 says in the last para.  If you don't need the ADC's, running Arduino code on the device is definitely the simplest/easiest way to use the device.  The AT command firmware is challenging to get working in a stable fashion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also just to re-affirm the power requirements of the ESP8266 is higher than the 3v3 supply on the Arduino—you'll need a step-down converter from a sufficiently powerful 5v supply, or separate power supply, to get it working consistently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bidirectional comms are definitely doable, but the limited SRAM on Arduino make string parsing a real challenge, and even handling relatively small responses/requests can hit up against the available SRAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the nice things about using Arduino on the ESP8266 is that the ESP8266 has 8 times the amount of SRAM, making that more feasible also.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2016-01-12T21:45:59.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19500" PostTypeId="2" ParentId="19366" CreationDate="2016-01-12T22:10:32.020" Score="0" Body="&lt;p&gt;You will also need a ceramic capacitor connecting the wires of the motor. also the diode should be at least 1amp and the transistor have the specs to take the loadd.&lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2016-01-12T22:10:32.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19501" PostTypeId="1" AcceptedAnswerId="19502" CreationDate="2016-01-12T22:48:42.847" Score="2" ViewCount="1512" Body="&lt;p&gt;I'm developing up a project that is designed to run 24/7 (an energy monitor) logging via wifi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to a variety of considerations I've ended up with a design that links an Arduino Nano with an ESP8266-01.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was considering designing in a watchdog, but had the thought that each of these MCUs could act as the watchdog for the other.  My hypothesis is that the likelihood of both going down simultaneously is relatively low, and as both need to communicate with each other regularly, they will know when the other unit has become non-responsive, and they would also be able to initiate a hardware (rather than software) reset on the other device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a valid/workable approach?  Or is there something else I need to consider that would warrant an external watchdog(s)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: as there were a few comments re: low-power etc., just wanted to clarify that this will be powered from the 240v supply it monitors (using a switch-mode supply), so this isn't expected to be an issue.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastEditorUserId="15852" LastEditDate="2016-01-13T04:16:03.567" LastActivityDate="2016-01-13T10:37:53.237" Title="Watchdog approach" Tags="|arduino-nano|esp8266|reset|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19502" PostTypeId="2" ParentId="19501" CreationDate="2016-01-12T23:37:26.987" Score="2" Body="&lt;p&gt;I had a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12821&quot; rel=&quot;nofollow noreferrer&quot;&gt;similar project&lt;/a&gt; a while back, including the desire for the watchdog.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My hypothesis is that the likelihood of both going down simultaneously is relatively low ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the problem. If it is solar powered (or even just battery powered) then the likelihood is quite high that they will both get insufficient power at much the same time (ie. low voltage). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I noticed was that if voltage slowly drops (as it does when the sun goes down, and the battery discharges) then the processor can enter a brown-out situation where it basically just goes dead, without resetting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you &lt;strong&gt;can&lt;/strong&gt; set brown-out detection in the fuses, but the reference voltage generator, needed to make it work, itself increases the power consumption. So you get the situation where the brownout detection drains the battery, causing a brown-out situation, where without brownout detection it might have lasted all night.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Anyway, the net effect was that the design on the linked page wasn't as reliable as I hoped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make this answer more complete, here is my watchdog processor schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7P3Ox.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7P3Ox.png&quot; alt=&quot;Watchdog processor schematic&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this was the code for it:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Reset solar panel watchdog&#xA;// Author: Nick Gammon&#xA;// Date: 22 March 2015&#xA;&#xA;// ATMEL ATTINY 25/45/85 / ARDUINO&#xA;// Pin 1 is /RESET&#xA;//&#xA;//                  +-\/-+&#xA;// Ain0 (D 5) PB5  1|    |8  Vcc&#xA;// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1 &#xA;// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1&#xA;//            GND  4|    |5  PB0 (D 0) pwm0&#xA;//                  +----+&#xA;&#xA;/*&#xA;&#xA; After reset waits for TIME_TO_WAIT minutes, then brings D0 (pin 5) high for long&#xA; enough to activate a MOSFET and reset the other board.&#xA;&#xA; Fuses: Low: E2 High: DD&#xA;&#xA; (Brownout at 2.7V)&#xA;&#xA;*/&#xA;&#xA;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;    // Sleep Modes&#xA;#include &amp;lt;avr/power.h&amp;gt;    // Power management&#xA;#include &amp;lt;avr/wdt.h&amp;gt;      // Watchdog timer&#xA;&#xA;const byte MOSFET = 0;          // pin 5 &#xA;unsigned long counter = 0;&#xA;&#xA;const float TIME_TO_WAIT = 30; // minutes&#xA;const unsigned long SLEEPS_TO_WAIT = TIME_TO_WAIT * 60.0 / 8.0;  // 8 second sleeps&#xA;&#xA;// watchdog interrupt&#xA;ISR (WDT_vect) &#xA;  {&#xA;   wdt_disable();  // disable watchdog&#xA;  }  // end of WDT_vect&#xA;&#xA;#if defined(__AVR_ATtiny85__)  &#xA;  #define watchdogRegister WDTCR&#xA;#else&#xA;  #define watchdogRegister WDTCSR&#xA;#endif&#xA;&#xA;void setup ()&#xA;  {&#xA;  wdt_reset();  &#xA;  pinMode (MOSFET, OUTPUT);&#xA;  ADCSRA = 0;            // turn off ADC&#xA;  power_all_disable ();  // power off ADC, Timer 0 and 1, serial interface&#xA;  set_sleep_mode (SLEEP_MODE_PWR_DOWN);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  counter++;&#xA;&#xA;  if (counter &amp;gt;= SLEEPS_TO_WAIT)&#xA;    {&#xA;    digitalWrite (MOSFET, HIGH);&#xA;    delayMicroseconds (10000); &#xA;    digitalWrite (MOSFET, LOW);&#xA;    // our job here is done&#xA;    sleep_enable ();       // ready to sleep&#xA;    sleep_cpu ();          // sleep                &#xA;    }&#xA;&#xA;  goToSleep ();&#xA;  }  // end of loop&#xA;&#xA;void goToSleep ()&#xA;  {&#xA;  noInterrupts ();       // timed sequence coming up&#xA;  // pat the dog&#xA;  wdt_reset();  &#xA;&#xA;  // clear various &quot;reset&quot; flags&#xA;  MCUSR = 0;     &#xA;  // allow changes, disable reset, clear existing interrupt&#xA;  watchdogRegister = bit (WDCE) | bit (WDE) | bit (WDIF);&#xA;  // set interrupt mode and an interval (WDE must be changed from 1 to 0 here)&#xA;  watchdogRegister = bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 8 seconds delay&#xA;&#xA;  sleep_enable ();       // ready to sleep&#xA;  interrupts ();         // interrupts are required now&#xA;  sleep_cpu ();          // sleep                &#xA;  sleep_disable ();      // precaution&#xA;  }  // end of goToSleep &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The design intention here was that the watchdog processor would reset overnight (when the solar panel lost power and the supercapacitor eventually discharged) and in the morning it would power up, wait 30 minutes (for the sun to rise and the voltage to become stable) and then unconditionally reset the other processor from whatever state it was in.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;as there were a few comments re: low-power etc., just wanted to clarify that this will be powered from the 240v supply it monitors (using a switch-mode supply)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, well I also live in a country with 240V power. Today during 41°C heat the power failed a number of times for very short intervals. Various computers reset or behaved strangely. Like with a low voltage battery, a brown-out, or brief failure, of the mains power could simultaneously strike all your devices, including the watchdog device.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-13T10:37:53.237" LastActivityDate="2016-01-13T10:37:53.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19503" PostTypeId="2" ParentId="19489" CreationDate="2016-01-13T00:04:02.420" Score="1" Body="&lt;p&gt;The flash memory is only designed to be reloaded 10,000 times. While that might seem a lot, if you are planning a system where, every day you load some part of code into flash, and then some other part, etc. you will use up those 10,000 writes fairly quickly.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't really care if it is slow or uses 99% of the memory space just to load on the code. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, you &lt;strong&gt;will&lt;/strong&gt; care because if 99% of the memory space is the loader, you will only have 1% for the code, which defeats the purpose.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It doesn't have a lot of memory space, which is a bit of a nuisance.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I suggest a larger processor such as the Atmega1284 (128k of flash), Atmega2560 (256k of flash) or the Atmega644P (64k of flash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All but the Atmega2560 come in DIP versions of the chips, if that helps.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-13T00:04:02.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19504" PostTypeId="2" ParentId="19501" CreationDate="2016-01-13T00:20:27.123" Score="2" Body="&lt;p&gt;As a watchdog mechanism to protect against software lockup type issues then using one processor to detect issues and reset the other is an economical idea.  However, I would completely agree with Nick that if you want protection from hardware issues like brown outs or slow rise time of the power supply then both micros could share the same vulnerabilities that a dedicated watchdog device would be able to address.  How significant this is depends on your power arrangements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other case to consider is now much does the software of one device interact with and depend on that of the other device such that it is conceivable that one device locking up in some way could impact the other defeating the watchdog functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I've seen too many situations where an internal micro watchdog failed to detect and recover an issue so would always go for an external device in any professional product.  Even there I would advise the use of a devices which requires the watchdog to be kicked within a time window rather than just within a maximum time period - otherwise if things contrive to go wrong in such a way that the watchdog is permanently getting kicked it will not recover the situation.  [I saw the micro pin responsible for kicking a simple external watchdog accidentally reconfigured by runaway code as a timer output once.]   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that if you are thinking that your product needs a watchdog then it is worth doing properly with an external one.&lt;/p&gt;&#xA;" OwnerUserId="16146" LastActivityDate="2016-01-13T00:20:27.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19505" PostTypeId="2" ParentId="19454" CreationDate="2016-01-13T00:38:49.010" Score="0" Body="&lt;p&gt;Perhaps you can try &lt;code&gt;while (Wire.available() != 7);&lt;/code&gt; before calling &lt;code&gt;Wire.read()&lt;/code&gt; 7 times in succession. Also remove leading zeros in the integer literals of 0 in your IF conditions. And make &lt;code&gt;bcdToDec&lt;/code&gt; return an &lt;code&gt;int&lt;/code&gt; instead of a &lt;code&gt;byte&lt;/code&gt;, in the unlikely case of any overflow issues.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-13T00:38:49.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19506" PostTypeId="1" AcceptedAnswerId="19728" CreationDate="2016-01-13T01:00:08.340" Score="0" ViewCount="183" Body="&lt;p&gt;I'm using the Arduino UNO and started noticing some funny behavior when I was trying a few basic projects. Specifically when trying to write an analog signal through one of the PWM pins, then a digital signal through another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using some LED's connected to a few different permutations of pins 8-13, I found that when I have an analog output set for one of the pins (in this case 9, 10, or 11 as they're the only one's of the set capable of PWM) and then try to output a digital signal from a different pin to another LED the digital signal seems much weaker. That is, the LED shines very very dim.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins 2-7 work fine.&#xA;Does the behavior described above indicate anything wrong with the arduino? are those pins potentially damaged, or is there something I'm not understanding here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{}&#xA;&#xA;void loop()&#xA;{&#xA;   analogWrite(9, 255);&#xA;   delay(1000);&#xA;   analogWrite(9, 0);&#xA;   delay(2000);&#xA;   digitalWrite(8, HIGH);&#xA;   delay(1000);&#xA;   digitalWrite(8, LOW);&#xA;   delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l9DZ6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l9DZ6.png&quot; alt=&quot;Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16360" LastEditorUserId="313" LastEditDate="2016-01-16T18:35:10.367" LastActivityDate="2016-01-19T00:01:21.793" Title="Error when trying to write analog and digital signals from different pins (Arduino UNO)" Tags="|arduino-uno|pins|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19507" PostTypeId="2" ParentId="19492" CreationDate="2016-01-13T01:02:03.997" Score="1" Body="&lt;p&gt;Getting started with a new toolchain can be quite a challenge…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not a Windows guy, but it looks like there &lt;strong&gt;are&lt;/strong&gt; drivers that need to  be installed to get things working with the Arduino. I'm guessing that what is going on here is that Windows is looking locally for drivers and not finding them (or any indication that drivers are needed). I think the button was grayed out because it couldn't help – not because help wasn't needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a few sources that I found by searching on:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;arduino driver windows 8.1&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=205837.0&quot; rel=&quot;nofollow&quot;&gt;[SOLVED] Arduino drivers for Windows 8.1 64bit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://answers.microsoft.com/en-us/windows/forum/windows8_1-windows_install/windows-81-64bit-usb-serial-driver-for-arduino/418f4de7-1361-4f98-ace6-4f6c0c44340b?db=5&amp;amp;auth=1&quot; rel=&quot;nofollow&quot;&gt;Windows 8.1 (64bit) USB-serial driver for Arduino?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://openenergymonitor.org/emon/node/3727&quot; rel=&quot;nofollow&quot;&gt;Installing the Arduino IDE – Windows 8.1 &amp;amp; 10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://mytechblog.com/tutorials/arduino/install-arduino-drivers-on-windows-8/&quot; rel=&quot;nofollow&quot;&gt;Install Arduino Drivers on Windows 8&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;While we're at it, it is worth mentioning that &quot;out of sync&quot; error message from avrdude are very common. A bit of searching here will find you some good resources on solving them as well – deal with the drivers first, then see if errors persist. &lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-13T01:02:03.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19508" PostTypeId="1" CreationDate="2016-01-13T02:10:17.393" Score="0" ViewCount="1785" Body="&lt;p&gt;I have several Arduino Leonardos connected to a Raspberry Pi (running Ubuntu) via USB. They appear as &lt;code&gt;/dev/ttyACM0&lt;/code&gt;, &lt;code&gt;/dev/ttyACM1&lt;/code&gt;, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Occasionally, one will disappear and even pressing the Arduino's reset button won't bring it back. Is there any way to &quot;refresh&quot; or &quot;reinitialize&quot; the ttyACM* devices to make them reappear without having to reboot the Raspberry Pi?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="10907" LastEditDate="2016-01-13T15:14:01.773" LastActivityDate="2022-09-17T15:13:23.407" Title="Recovering from lost USB connection (Leonardo to Raspberry Pi)" Tags="|usb|arduino-leonardo|linux|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19509" PostTypeId="1" AcceptedAnswerId="19656" CreationDate="2016-01-13T02:25:42.187" Score="0" ViewCount="995" Body="&lt;p&gt;I was using an Arduino Leonardo (in the form of an &lt;a href=&quot;https://www.dfrobot.com/wiki/index.php?title=Raspberry_Pi_B%2B_Meet_Arduino_Shield_SKU:DFR0327&quot; rel=&quot;nofollow&quot;&gt;RPI hat&lt;/a&gt;) to control a single DC motor via a &lt;a href=&quot;https://www.pololu.com/product/2990&quot; rel=&quot;nofollow&quot;&gt;motor controller&lt;/a&gt;. I have it wired to set Phase and Enable to control motor speed and direction, and I read sensors on the motor's encoder to directly measure motor speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I triple checked all my wiring, and a test program I wrote to spin the motor at half-speed seemed to work just fine. Then it suddenly stopped working. Now, when I plug the Leonardo into my machine, the ttyACM0 device does not appear, and I seem to have no way to communicate with it anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've noticed that when I press the reset button, the Leonardo's status light flashes for a few seconds and ttyACM0 does momentarily appear. But as soon as the flashing stops, ttyACM0 disappears again. I tried upload a new sketch when the device reappears, but I get a &quot;broken pipe&quot; error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's going on here? Did I somehow fry my Leonardo, or is it possible I just screwed up the serial port? How do I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: For the host, I've tried Ubuntu 14 running on a Raspberry Pi 2 and a generic 64bit laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: My &lt;code&gt;setup()&lt;/code&gt; is simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void count_pan_changes(){&#xA;    /*&#xA;    CW  =&amp;gt; 11,00,11,00,...&#xA;    CCW =&amp;gt; 10,01,10,01,...&#xA;    */&#xA;    int a = digitalRead(MOTOR_ENCODER_A_PIN);&#xA;    int b = digitalRead(MOTOR_ENCODER_B_PIN);&#xA;    int direction = (a == b) ? +1 : -1;&#xA;    motor_controller.record_direction(direction);&#xA;}&#xA;&#xA;void setup(){&#xA;    attachInterrupt(digitalPinToInterrupt(MOTOR_ENCODER_A_PIN), count_pan_changes, CHANGE);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: I'm not sure why, but when I disconnected the Leonardo from it's 5V UBEC power supply and powered it directly from my laptop via USB, then ttyACM0 suddenly came back. However, when I reconnect it to its own power supply, I again have problems connecting to it. The first upload and serial terminal seem to work, but as soon as I disconnect, further uploads/serial connections seem to fail with a &quot;broken pipe&quot; error. I'm powering it via a UBEC by connecting the 5V and Gnd lines to one of the Leonardo's GVS headers (i.e. it's not going in through any onboard regulator on the Arduino or RPi). Should this work? The motor is behind a separate UBEC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Now power cycling isn't even fixing it. I tried erasing the contents using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -e&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as explained &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=261139.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. This keeps /dev/ttyACM0 from disappearing, but if I try and upload a sketch using &lt;code&gt;ano upload&lt;/code&gt;, I still get the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;IOError: [Errno 32] Broken pipe&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="4478" LastEditDate="2016-01-17T00:38:47.163" LastActivityDate="2016-01-17T03:24:14.120" Title="How to diagnose unresponsive Leonardo serial port?" Tags="|usb|arduino-leonardo|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19510" PostTypeId="2" ParentId="19508" CreationDate="2016-01-13T02:59:01.593" Score="3" Body="&lt;p&gt;The USB devices are created dynamically. You might find this question and answer from the SE Raspberry Pi helpful: &lt;a href=&quot;https://raspberrypi.stackexchange.com/questions/13455/how-to-force-rescan-of-usb-serial-devices&quot;&gt;How to force rescan of USB serial devices?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;strong&gt;dmesg(8)&lt;/strong&gt; command on the Pi to see the messages generated by the USB sub-system. Watch the output to see if there are errors associated with the Arduino dropping off the bus. This is what the output will look like (roughly, this is from an Uno connected to a Raspbian system), note the last line which is a disconnect from unplugging the Uno from the Pi. Resetting the Uno did not do anything that the Pi saw. I would guess that that is because the reset button on the Uno doesn't reset the 16U2 (the processor handling the USB port).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[  459.936719] usb 1-1.3: new full-speed USB device number 5 using dwc_otg&#xA;[  460.051182] usb 1-1.3: New USB device found, idVendor=2a03, idProduct=0043&#xA;[  460.051212] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[  460.051229] usb 1-1.3: Product: Arduino Uno&#xA;[  460.051245] usb 1-1.3: Manufacturer: Arduino Srl            &#xA;[  460.051262] usb 1-1.3: SerialNumber: 75431343334351F061E2&#xA;[  460.088018] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device&#xA;[  460.089250] usbcore: registered new interface driver cdc_acm&#xA;[  460.089270] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters&#xA;[  534.212365] usb 1-1.3: USB disconnect, device number 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From reading that question and its answers it appears that &lt;a href=&quot;https://www.raspberrypi.org/forums/viewtopic.php?f=91&amp;amp;t=59420&quot; rel=&quot;nofollow noreferrer&quot;&gt;some versions of the Leonardo may have problems&lt;/a&gt; that can cause this behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing that might be worth looking into is the power supply for the Leonardos. If they are being powered by the Pi through the USB interface that might be pushing the capability of the Pi to provide power.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2016-01-13T04:23:47.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19511" PostTypeId="1" CreationDate="2016-01-13T05:19:55.577" Score="2" ViewCount="727" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/19508/how-to-recreate-missing-ttyacm-devices&quot;&gt;This question&lt;/a&gt; got me thinking, the OP was wondering about how to &quot;bring back&quot; Leonardo boards connected to a Raspberry Pi via USB. The Leonardos would occasionally drop off line and could not be brought back by resetting the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I got curious and hooked a Uno up to a Pi via USB and started poking around. I had the idea that perhaps resetting the 16U2 would do the trick. It does not. After resetting the 16U2 (by grounding the reset pin in the ICSP connector). This is what I see in the kernel log on the Pi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 6277.570058] usb 1-1.3: USB disconnect, device number 11&#xA;[ 6278.576503] usb 1-1.3: new full-speed USB device number 12 using dwc_otg&#xA;[ 6278.684793] usb 1-1.3: New USB device found, idVendor=03eb, idProduct=2fef&#xA;[ 6278.684823] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0&#xA;[ 6278.684841] usb 1-1.3: Product: ATmega16U2 DFU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As opposed to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 6325.960510] usb 1-1.3: USB disconnect, device number 12&#xA;[ 6329.267003] usb 1-1.3: new full-speed USB device number 13 using dwc_otg&#xA;[ 6329.382675] usb 1-1.3: New USB device found, idVendor=2a03, idProduct=0043&#xA;[ 6329.382703] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=220&#xA;[ 6329.382720] usb 1-1.3: Product: Arduino Uno&#xA;[ 6329.382736] usb 1-1.3: Manufacturer: Arduino Srl            &#xA;[ 6329.382753] usb 1-1.3: SerialNumber: 75431343334351F061E2&#xA;[ 6329.384088] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is what I see if I unplug and replug the USB cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to know what happens differently during a 16U2 reset vs. an unplug/replug cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd also like to know if there is a way to simulate unplugging and replugging the USB cable. The 16U2 reset comes close (the Pi notices that something happened), but it would be nice if there were a way that either code on the Uno or on the Pi could &quot;wake up&quot; a down USB link.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-16T03:51:46.807" Title="Resetting 16U2 Processor on Uno (R3)" Tags="|arduino-uno|usb|atmega16u2|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19513" PostTypeId="2" ParentId="17436" CreationDate="2016-01-13T07:47:42.393" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;USB power vs linked&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just to add my 2 cents on your latest update about the USB or 5V from the PI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say you connect it to the VIN:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;as soon as I power the nano from the RPi (5V connected to vIn), the calculated pH value drops?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you look at the below image you see that Vin goes to a good old 7805, which needs a IN voltage &gt; 7.5V, thus the output when its connected to the 5V of the PI is going to be very low and thus mess up readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/52yDH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend you connect your &lt;strong&gt;&lt;em&gt;power from the PI to the arduino's VCC&lt;/em&gt;&lt;/strong&gt; as this is a regulated 5v and doesn't need to be regulated again.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-01-13T07:47:42.393" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19514" PostTypeId="2" ParentId="19432" CreationDate="2016-01-13T09:24:54.530" Score="0" Body="&lt;p&gt;You haven't specified what level of accuracy you are aiming for so I have assumed 0.01ml.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What ever solution you go for you will also need an accurate temperature and pressure sensor, because these will affect the density of the water.&#xA;Each individual sensor you use has a degree of error associated with them.  You would nee to calibrate each sensor to establish what level of error each individual instance of a sensor has.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Weight would seem to be the best solution.  Surface tension could affect a flow metre or a contact sensor.  I have to be honest I don't see how an ultrasonic sensor could give you any degree of accuracy.  With a weight sensor you would need to establish the dry weight of the container then pour the liquid in until the desired volume was achieved.  A quick response to close the very end of the inlet pipe would be required to prevent un-necessary drips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to marking the container, are you using some computer controlled marking tool, because if you are just drawing on the side with a Sharpie you may as well use a measuring jug. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to get a weighing PCB, a pressure and temperature sensor off any of the usual electronic sites to suit you budget and the libraries will be on Git hub.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-01-13T09:24:54.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19515" PostTypeId="2" ParentId="19432" CreationDate="2016-01-13T09:28:47.393" Score="1" Body="&lt;p&gt;The flow meter you specified, YF-S201 Hall Effect Water Flow Meter &lt;a href=&quot;https://www.olimex.com/Products/Components/Sensors/SNS-FLOW201/resources/Water_flow_sensor_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;(datasheet)&lt;/a&gt; measures the water flow rate, producing signal output frequency in range 16Hz (at 120L/H) to 90.2Hz (at 720L/H). Datasheet claims &quot;error range +/- 10)&quot;. &lt;strong&gt;Note that this only measures the rate of flow, it is not a valve and so does not control the flow.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem with using a flow rate sensor to measure total quantity of water, is that you must constantly integrate the flow rate over time to get the total volume. Any errors in rate measurement or integration time, will accumulate; so this is generally not an accurate approach. &lt;strong&gt;Cumulative errors are highly undesirable, because they are difficult to detect and compensate.&lt;/strong&gt; You have to not only measure the output frequency, but also carefully control the time between measurements, because you are integrating over time. This will be even more of a problem if you are printing out messages to the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the water supply is well regulated and always provides a steady flow, then you will open the valve for a specific time interval. But if the supply pressure is not well regulated, then you may accumulate integration errors and dispensing will not always be accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you care about dispensing precisely 500mL of water, a more practical solution is to use a weigh scale (&lt;em&gt;load cell&lt;/em&gt;). First, measure the &lt;em&gt;tare weight&lt;/em&gt; of the empty container, then dispense (using a control loop) until net increase in weight is 500g. With this setup, the dispenser accuracy is determined by the load cell repeatability error (0.1% for a good quality load cell, a couple % for a fair quality load cell) and the measurement accuracy of the ADC (depends on resolution and reference voltage stability). You could try using the Arduino's on-chip ADC which is only 10 bits, or for best accuracy use a real 24-bit weigh scale ADC. The load sensor's &lt;em&gt;offset error&lt;/em&gt; is set to zero by measuring the tare weight of the empty jug, so you only need to be concerned about &lt;em&gt;gain error&lt;/em&gt; at 500mL and &lt;em&gt;repeatability&lt;/em&gt; of the load sensor. &lt;strong&gt;This approach does not have cumulative errors.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have not specified what kind of valve you will use to control the flow. If you use a &lt;em&gt;solenoid value&lt;/em&gt;, the valve is only on-or-off, there may be some overshoot due to valve reaction time (10ms), so you will need to experiment and determine an &quot;off threshold&quot; before reaching 500g.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you have no way to compensate if the system overfills the jar, you will need to dampen the system response so that it slows down as it approaches the target level, without overfill. I'd therefore suggest using a &lt;em&gt;proportional valve&lt;/em&gt; instead of a solenoid valve. Start with a fast flow rate when net weight &amp;lt;400g and then switch to a slower rate as the jar reaches its target weight. &lt;/p&gt;&#xA;" OwnerUserId="7174" LastActivityDate="2016-01-13T09:28:47.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19517" PostTypeId="1" AcceptedAnswerId="19592" CreationDate="2016-01-13T13:29:32.877" Score="0" ViewCount="13013" Body="&lt;p&gt;For a project I need to connect a Bluetooth Remote control with an Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to setup a connection to said Bluetooth remote Control. This device is visible! (I have confirmed it with a smartphone)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the steps that I am trying to do with the Arduino and HC05 module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT &amp;lt;-- confirms, that Command Mode is running successfully&#xA;OK&#xA;&#xA;AT+ROLE? &amp;lt;-- 1 For Bluetooth Master Mode&#xA;+ROLE:1&#xA;OK &#xA;&#xA;AT+CMODE? &amp;lt;-- 1 allows connecting to any BT address&#xA;+CMOD:1&#xA;OK&#xA;&#xA;AT+INQM? &amp;lt;-- Show Inquiry access values&#xA;+INQM:1,1,48&#xA;OK&#xA;&#xA;AT+INQ &amp;lt;-- Inquiry Bluetooth Device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After ~60 seconds, it just says &quot;OK&quot;, but according to &lt;a href=&quot;https://alselectro.wordpress.com/2014/10/21/bluetooth-hc05-how-to-pair-two-modules/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;  or according to &lt;a href=&quot;https://youtu.be/Vr4cdpsoVEo?t=6m30s&quot; rel=&quot;nofollow noreferrer&quot;&gt;this youtube video&lt;/a&gt; it should display all Bluetooth-devices, that are ready to connect. &#xA;The BT device is definately visible. (I tried multiple BT devices like smartphones and peripheral devices).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why is the inquiry not working? What is wrong here?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The circuit is exactly like in this picture:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lwMAs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lwMAs.jpg&quot; alt=&quot;circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For setting up the Bluetooth-connection I wire the EN-Pin to +3,3V, which successfully activates &lt;strong&gt;AT-Command-Mode&lt;/strong&gt; &#xA;&lt;a href=&quot;http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/&quot; rel=&quot;nofollow noreferrer&quot;&gt;According to this site&lt;/a&gt;, you can do it like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code, that I use, to communicate with the module. - It works good!&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(2, 3); // RX | TX&#xA;// Connect the HC-05 TX to Arduino pin 2 RX. &#xA;// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.&#xA;// &#xA;&#xA;char c = ' ';&#xA;int buf[64]; //buffer to store AT commands&#xA;int len = 0; //stores the length of the commands&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Arduino is ready&quot;);&#xA;    delay(500);&#xA;    mySerial.begin(9600);  &#xA;    Serial.println(&quot;BlueTooth is ready&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  if(Serial.available())&#xA;  {&#xA;    len = Serial.available(); //store number of bytes to read&#xA;    for(int i = 0; i&amp;lt;len; i++) //store all bytes into the buffer&#xA;    {&#xA;      buf[i] = Serial.read();&#xA;    }&#xA;    for(int i = 0; i&amp;lt;len; i++)&#xA;    {&#xA;      mySerial.write(buf[i]);&#xA;      Serial.write(buf[i]);&#xA;    }&#xA;  }&#xA;&#xA;&#xA;  if(mySerial.available())&#xA;  {&#xA;    len = mySerial.available();&#xA;    for(int i = 0; i&amp;lt;len; i++)&#xA;    {&#xA;      buf[i] = mySerial.read();&#xA;    }&#xA;    for(int i = 0; i&amp;lt;len; i++)&#xA;    {&#xA;      Serial.write(buf[i]);&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/180962/hc-05-bluetooth-atinq-command-not-working&quot;&gt;Here is a related question but the answer doesn't help.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2019-09-27T20:01:35.993" Title="HC-05 Bluetooth Module - INQ-Command doesn't work" Tags="|bluetooth|arduino-nano|remote-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19518" PostTypeId="2" ParentId="19517" CreationDate="2016-01-13T14:19:16.647" Score="0" Body="&lt;p&gt;Try this example from the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+INIT&#xA;AT+INQM=1,9,48  // max of 9 devices, timeout of 61 seconds&#xA;AT+INQ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And use this in your loop() instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  while (Serial.available())&#xA;    mySerial.write(Serial.read());&#xA;  while (mySerial.available())&#xA;    Serial.write(mySerial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-13T14:19:16.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19519" PostTypeId="1" AcceptedAnswerId="19527" CreationDate="2016-01-13T14:35:25.873" Score="2" ViewCount="1201" Body="&lt;p&gt;I'm currently attempting to replace delay() in my project so that i may perform other tasks while waiting on a particular event to fire. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I'm having, is every example i've found using millis / elapsedmillis has everything inside the loop, where I'm trying to use it inside void buttons(). needless to say, either it's not going to work outside of loop, or I'm doing something ridiculous, and too tired, or too ignorant to see what i'm doing wrong..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end goal is to have the button draw over the top of the existing one, wait 1000ms then draw the next button. &#xA;(time interval will be changed later to sync with hardware spin down etc) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the complete sketch, perhaps someone can show me a reliable way to replace delay in the buttons funciton:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;TouchScreen.h&amp;gt;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;MCUFRIEND_kbv.h&amp;gt;&#xA;MCUFRIEND_kbv tft;&#xA;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;&#xA;elapsedMillis timer0;&#xA;elapsedMillis sinceTime1;&#xA;elapsedMillis sinceTime2;&#xA;elapsedMillis sinceTime3;&#xA;&#xA;#define debug = false;&#xA;//#define debug = true;&#xA;&#xA;#if defined(__SAM3X8E__)&#xA;#undef __FlashStringHelper::F(string_literal)&#xA;#define F(string_literal) string_literal&#xA;#endif&#xA;&#xA;// most mcufriend shields use these pins and Portrait mode:&#xA;uint8_t YP = A1;  // must be an analog pin, use &quot;An&quot; notation!&#xA;uint8_t XM = A2;  // must be an analog pin, use &quot;An&quot; notation!&#xA;uint8_t YM = 6;   // can be a digital pin&#xA;uint8_t XP = 7;   // can be a digital pin&#xA;uint8_t Landscape = 0;&#xA;&#xA;uint16_t TS_LEFT = 120;&#xA;uint16_t TS_RT = 940;&#xA;uint16_t TS_TOP = 940;&#xA;uint16_t TS_BOT = 180;&#xA;#define MINPRESSURE 10&#xA;#define MAXPRESSURE 1000&#xA;&#xA;// For better pressure precision, we need to know the resistance&#xA;// between X+ and X- Use any multimeter to read it&#xA;// For the one we're using, its 250 ohms across the X plate&#xA;TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);&#xA;&#xA;#define LCD_CS A3&#xA;#define LCD_CD A2&#xA;#define LCD_WR A1&#xA;#define LCD_RD A0&#xA;&#xA;// Assign human-readable names to some common 16-bit color values:&#xA;#define BLACK   0x0000&#xA;#define BLUE    0x001F&#xA;#define RED     0xF800&#xA;#define GREEN   0x07E0&#xA;#define CYAN    0x07FF&#xA;#define MAGENTA 0xF81F&#xA;#define YELLOW  0xFFE0&#xA;#define WHITE   0xFFFF&#xA;&#xA;int16_t BOXSIZE;&#xA;int16_t PENRADIUS = 3;&#xA;uint16_t oldcolor, currentcolor;&#xA;&#xA;#define SD_SCK 13&#xA;#define SD_MISO 12&#xA;#define SD_MOSI 11&#xA;#define SD_CS 10&#xA;// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  // Init TouchScreen&#xA;    ts = TouchScreen(XP, YP, XM, YM, 300);     //call the constructor AGAIN with new values.&#xA;&#xA;    BOXSIZE = tft.width() / 6;&#xA;    tft.fillScreen(BLACK);&#xA;&#xA;  // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;&#xA;  tft.reset();&#xA;&#xA;  uint16_t identifier = tft.readID();&#xA;if (identifier == 0x7789) {&#xA;        //Serial.println(F(&quot;Found ST7789V LCD driver&quot;));&#xA;        TS_LEFT = 120; TS_RT = 940; TS_TOP = 940; TS_BOT = 180;&#xA;        Landscape = 1;&#xA;    } else {&#xA;        //Serial.print(F(&quot;Unknown LCD driver chip: &quot;));&#xA;        //Serial.println(identifier, HEX);&#xA;        return;&#xA;    }&#xA;&#xA;    //Serial.print(F(&quot;Found LCD driver chip ID: &quot;));&#xA;    //Serial.println(identifier, HEX);&#xA;&#xA;  tft.begin(identifier);&#xA;&#xA;  //Serial.print(F(&quot;Initializing SD card...&quot;));&#xA;  if (!SD.begin(SD_CS, SD_MOSI, SD_MISO, SD_SCK)) {&#xA;    Serial.println(F(&quot;failed!&quot;));&#xA;    return;&#xA;  }&#xA;  //Serial.println(F(&quot;OK!&quot;));&#xA;  tft.begin(identifier);&#xA;  tft.setRotation(3);&#xA;  BOXSIZE = tft.width() / 6;&#xA;  tft.fillScreen(BLACK);&#xA;  bmpDraw(&quot;splash.bmp&quot;, 80, 20);&#xA;  delay(5000);&#xA;  loadhome();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;//DO STUFF HERE&#xA;&#xA;//Testing Text stuff here&#xA;  tft.setTextColor(BLACK);&#xA;  tft.setTextSize(2); &#xA;  tft.setCursor(15, 33);&#xA;  tft.print(&quot;123.456&quot;);&#xA;  tft.setTextColor(BLACK);&#xA;  tft.setCursor(115, 33);&#xA;  tft.print(&quot;543.210&quot;);&#xA;  tft.setTextColor(BLACK);&#xA;  tft.setCursor(215, 33);&#xA;  tft.print(&quot;789.654&quot;);&#xA;  buttons();&#xA;}&#xA;&#xA;void loadhome(){&#xA;  tft.setRotation(3);  &#xA;  BOXSIZE = tft.width() / 6;&#xA;  tft.fillScreen(BLACK);&#xA;  bmpDraw(&quot;cell.bmp&quot;, 10, 25);&#xA;  bmpDraw(&quot;cell.bmp&quot;, 110, 25);&#xA;  bmpDraw(&quot;cell.bmp&quot;, 210, 25);&#xA;  bmpDraw(&quot;stop.bmp&quot;, 15, 175);&#xA;  bmpDraw(&quot;locked.bmp&quot;, 90, 175);&#xA;  bmpDraw(&quot;play.bmp&quot;, 165, 175);&#xA;  bmpDraw(&quot;home.bmp&quot;, 240, 175);&#xA;  bmpDraw(&quot;coolstp.bmp&quot;, 15, 105);&#xA;  bmpDraw(&quot;spinstp.bmp&quot;, 240, 105);&#xA;&#xA;  tft.setTextColor(RED);&#xA;  tft.setTextSize(3); &#xA;  tft.setCursor(50, 3);&#xA;  tft.print(&quot;X&quot;);&#xA;  tft.setTextColor(RED);&#xA;  tft.setCursor(150, 3);&#xA;  tft.print(&quot;Y&quot;);&#xA;  tft.setTextColor(RED);&#xA;  tft.setCursor(250, 3);&#xA;  tft.print(&quot;Z&quot;);&#xA;&#xA;}&#xA;&#xA;int homer = 0;&#xA;int play = 1;&#xA;int lock = 0;&#xA;int cool = 0;&#xA;int spin = 0;&#xA;&#xA;&#xA;const int interval = 1000;&#xA;unsigned long curMillis; //Current millis&#xA;&#xA;void buttons(){&#xA;  //Touchscreen stuff&#xA;    TSPoint p = ts.getPoint();&#xA;&#xA;    // if sharing pins, you'll need to fix the directions of the touchscreen pins&#xA;    pinMode(XM, OUTPUT);&#xA;    pinMode(YP, OUTPUT);&#xA;&#xA;    p.x = map(p.x, TS_LEFT, TS_RT, 0, tft.width());&#xA;    p.y = map(p.y, TS_TOP, TS_BOT, 0, tft.height());&#xA;/*&#xA;//Use to map buttons&#xA;//Be sure to mark out button code before use!!&#xA; if (p.z &amp;gt; MINPRESSURE &amp;amp;&amp;amp; p.z &amp;lt; MAXPRESSURE) {&#xA;    Serial.print(F(&quot;p.y =&quot;));&#xA;    Serial.print(p.y);&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.print(F(&quot;p.x =&quot;));&#xA;    Serial.print(p.x);&#xA;    Serial.println(&quot;&quot;);&#xA; }&#xA;*/    &#xA;// Begin Buttons    &#xA;//Coolant Button&#xA;if (p.y &amp;gt; 110 &amp;amp;&amp;amp; p.y &amp;lt; 170 &amp;amp;&amp;amp; p.x &amp;gt; 250 &amp;amp;&amp;amp; p.x &amp;lt; 300) { // if stop area is pressed&#xA;  if(cool == 0){&#xA;   bmpDraw(&quot;coolen.bmp&quot;, 15, 105);&#xA;   //Serial.println(F(&quot;Coolant Button Pressed!&quot;));&#xA;   cool = 1;&#xA;  } else {&#xA;   bmpDraw(&quot;coolerr.bmp&quot;, 15, 105);&#xA;   sinceTime1 = 0;&#xA;   //delay(500); //replacing with millis()&#xA;   if (sinceTime1 &amp;gt;= 1000) {&#xA;   bmpDraw(&quot;coolstp.bmp&quot;, 15, 105);&#xA;   //Serial.println(F(&quot;Coolant Button Pressed!&quot;));&#xA;   cool = 0;&#xA;   }&#xA;  }&#xA;}&#xA;&#xA;//Stop Button&#xA;if (p.y &amp;gt; 185 &amp;amp;&amp;amp; p.y &amp;lt; 235 &amp;amp;&amp;amp; p.x &amp;gt; 250 &amp;amp;&amp;amp; p.x &amp;lt; 300) { // if stop area is pressed&#xA;   //Serial.println(F(&quot;Stop Button Pressed!&quot;));&#xA;   Serial.write(0x18);&#xA;   Serial.print(&quot;\n&quot;);&#xA;}&#xA;&#xA;//Lock Button&#xA;if (p.y &amp;gt; 185 &amp;amp;&amp;amp; p.y &amp;lt; 235 &amp;amp;&amp;amp; p.x &amp;gt; 182 &amp;amp;&amp;amp; p.x &amp;lt; 234) { // if stop area is pressed&#xA;  if(lock == 0){&#xA;    Serial.print(&quot;$X\n&quot;);&#xA;   bmpDraw(&quot;unlocked.bmp&quot;, 90, 175);&#xA;   //Serial.println(F(&quot;Lock/Unlock Button Pressed!&quot;));&#xA;   lock = 1;&#xA;  } else {&#xA;    Serial.print(&quot;$X\n&quot;);&#xA;   bmpDraw(&quot;locked.bmp&quot;, 90, 175);&#xA;   //Serial.println(F(&quot;Lock/Unlock Button Pressed!&quot;));&#xA;   lock = 0;  &#xA;  }&#xA;}&#xA;&#xA;//Play-Pause Button&#xA;if (p.y &amp;gt; 185 &amp;amp;&amp;amp; p.y &amp;lt; 235 &amp;amp;&amp;amp; p.x &amp;gt; 110 &amp;amp;&amp;amp; p.x &amp;lt; 160) { // if stop area is pressed&#xA;  if(play == 0){&#xA;   Serial.print(&quot;~\n&quot;);&#xA;   bmpDraw(&quot;play.bmp&quot;, 165, 175);&#xA;   //Serial.println(F(&quot;Play/Pause Button Pressed!&quot;));&#xA;   play = 1;&#xA;  } else {&#xA;   Serial.print(&quot;!\n&quot;);&#xA;   bmpDraw(&quot;pause.bmp&quot;, 165, 175);&#xA;   //Serial.println(F(&quot;Play/Pause Button Pressed!&quot;));&#xA;   play = 0;    &#xA;  }&#xA;}&#xA;&#xA;//Home Button&#xA;if (p.y &amp;gt; 185 &amp;amp;&amp;amp; p.y &amp;lt; 235 &amp;amp;&amp;amp; p.x &amp;gt; 35 &amp;amp;&amp;amp; p.x &amp;lt; 90) { // if stop area is pressed&#xA;  if(homer == 0){&#xA;   bmpDraw(&quot;homeg.bmp&quot;, 240, 175);&#xA;   //Serial.println(F(&quot;Home Button Pressed!&quot;));&#xA;   homer = 1;&#xA;  } else {&#xA;   Serial.print(&quot;$H\n&quot;);&#xA;   bmpDraw(&quot;homey.bmp&quot;, 240, 175);&#xA;   sinceTime2 = 0;&#xA;   //delay(500); //replacing with millis()&#xA;   if (sinceTime2 &amp;gt;= 1000) {&#xA;   bmpDraw(&quot;homer.bmp&quot;, 240, 175);&#xA;   }&#xA;   //delay(500); //replacing with millis()&#xA;   sinceTime2 = 0;&#xA;   if (sinceTime2 &amp;gt;= 1000) {&#xA;   //delay(750);&#xA;   bmpDraw(&quot;homeg.bmp&quot;, 240, 175);&#xA;   //Serial.println(F(&quot;Home Button Pressed!&quot;));&#xA;   }&#xA;   homer = 1;&#xA;  }&#xA;}&#xA;&#xA;//Spindle Button&#xA;if (p.y &amp;gt; 110 &amp;amp;&amp;amp; p.y &amp;lt; 170 &amp;amp;&amp;amp; p.x &amp;gt; 35 &amp;amp;&amp;amp; p.x &amp;lt; 90) { // if stop area is pressed&#xA;  if(spin == 0){&#xA;   bmpDraw(&quot;spinen.bmp&quot;, 240, 105);&#xA;   //Serial.println(F(&quot;Spindle Button Pressed!&quot;));&#xA;   spin = 1;&#xA;  } else {&#xA;   bmpDraw(&quot;spinerr.bmp&quot;, 240, 105);&#xA;   sinceTime3 = 0;&#xA;   //delay(500); //replacing with millis()&#xA;   if (sinceTime3 &amp;gt;= 1000) {&#xA;   bmpDraw(&quot;spinstp.bmp&quot;, 240, 105);&#xA;   //Serial.println(F(&quot;Spindle Button Pressed!&quot;));&#xA;   }&#xA;   spin = 0;   &#xA;  }&#xA;}&#xA;&#xA;}&#xA;&#xA;&#xA;#define BUFFPIXEL 15&#xA;&#xA;void bmpDraw(char *filename, int x, int y) {&#xA;&#xA;  File     bmpFile;&#xA;  int      bmpWidth, bmpHeight;   // W+H in pixels&#xA;  uint8_t  bmpDepth;              // Bit depth (currently must be 24)&#xA;  uint32_t bmpImageoffset;        // Start of image data in file&#xA;  uint32_t rowSize;               // Not always = bmpWidth; may have padding&#xA;  uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel in buffer (R+G+B per pixel)&#xA;  uint16_t lcdbuffer[BUFFPIXEL];  // pixel out buffer (16-bit per pixel)&#xA;  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer&#xA;  boolean  goodBmp = false;       // Set to true on valid header parse&#xA;  boolean  flip    = true;        // BMP is stored bottom-to-top&#xA;  int      w, h, row, col;&#xA;  uint8_t  r, g, b;&#xA;  uint32_t pos = 0, startTime = millis();&#xA;  uint8_t  lcdidx = 0;&#xA;  boolean  first = true;&#xA;&#xA;  if((x &amp;gt;= tft.width()) || (y &amp;gt;= tft.height())) return;&#xA;&#xA;  //Serial.println();&#xA;  //Serial.print(F(&quot;Loading image '&quot;));&#xA;  //Serial.print(filename);&#xA;  //Serial.println('\'');&#xA;  // Open requested file on SD card&#xA;  if ((bmpFile = SD.open(filename)) == NULL) {&#xA;    Serial.println(F(&quot;File not found&quot;));&#xA;    return;&#xA;  }&#xA;&#xA;  // Parse BMP header&#xA;  if(read16(bmpFile) == 0x4D42) { // BMP signature&#xA;    read32(bmpFile);&#xA;    //Serial.println(F(&quot;File size: &quot;)); &#xA;    //Serial.println(read32(bmpFile));&#xA;    (void)read32(bmpFile); // Read &amp;amp; ignore creator bytes&#xA;    bmpImageoffset = read32(bmpFile); // Start of image data&#xA;    //Serial.print(F(&quot;Image Offset: &quot;)); Serial.println(bmpImageoffset, DEC);&#xA;    // Read DIB header&#xA;    read32(bmpFile);&#xA;    //Serial.print(F(&quot;Header size: &quot;)); &#xA;    //Serial.println(read32(bmpFile));&#xA;&#xA;    bmpWidth  = read32(bmpFile);&#xA;    bmpHeight = read32(bmpFile);&#xA;    if(read16(bmpFile) == 1) { // # planes -- must be '1'&#xA;      bmpDepth = read16(bmpFile); // bits per pixel&#xA;      //Serial.print(F(&quot;Bit Depth: &quot;)); Serial.println(bmpDepth);&#xA;      if((bmpDepth == 24) &amp;amp;&amp;amp; (read32(bmpFile) == 0)) { // 0 = uncompressed&#xA;&#xA;        goodBmp = true; // Supported BMP format -- proceed!&#xA;       // Serial.print(F(&quot;Image size: &quot;));&#xA;       // Serial.print(bmpWidth);&#xA;       // Serial.print('x');&#xA;       // Serial.println(bmpHeight);&#xA;&#xA;        // BMP rows are padded (if needed) to 4-byte boundary&#xA;        rowSize = (bmpWidth * 3 + 3) &amp;amp; ~3;&#xA;&#xA;        // If bmpHeight is negative, image is in top-down order.&#xA;        // This is not canon but has been observed in the wild.&#xA;        if(bmpHeight &amp;lt; 0) {&#xA;          bmpHeight = -bmpHeight;&#xA;          flip      = false;&#xA;        }&#xA;&#xA;        // Crop area to be loaded&#xA;        w = bmpWidth;&#xA;        h = bmpHeight;&#xA;        if((x+w-1) &amp;gt;= tft.width())  w = tft.width()  - x;&#xA;        if((y+h-1) &amp;gt;= tft.height()) h = tft.height() - y;&#xA;&#xA;        // Set TFT address window to clipped image bounds&#xA;        tft.setAddrWindow(x, y, x+w-1, y+h-1);&#xA;&#xA;        for (row=0; row&amp;lt;h; row++) { // For each scanline...&#xA;          // Seek to start of scan line.  It might seem labor-&#xA;          // intensive to be doing this on every line, but this&#xA;          // method covers a lot of gritty details like cropping&#xA;          // and scanline padding.  Also, the seek only takes&#xA;          // place if the file position actually needs to change&#xA;          // (avoids a lot of cluster math in SD library).&#xA;          if(flip) // Bitmap is stored bottom-to-top order (normal BMP)&#xA;            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;&#xA;          else     // Bitmap is stored top-to-bottom&#xA;            pos = bmpImageoffset + row * rowSize;&#xA;          if(bmpFile.position() != pos) { // Need seek?&#xA;            bmpFile.seek(pos);&#xA;            buffidx = sizeof(sdbuffer); // Force buffer reload&#xA;          }&#xA;&#xA;          for (col=0; col&amp;lt;w; col++) { // For each column...&#xA;            // Time to read more pixel data?&#xA;            if (buffidx &amp;gt;= sizeof(sdbuffer)) { // Indeed&#xA;              // Push LCD buffer to the display first&#xA;              if(lcdidx &amp;gt; 0) {&#xA;                tft.pushColors(lcdbuffer, lcdidx, first);&#xA;                lcdidx = 0;&#xA;                first  = false;&#xA;              }&#xA;              bmpFile.read(sdbuffer, sizeof(sdbuffer));&#xA;              buffidx = 0; // Set index to beginning&#xA;            }&#xA;&#xA;            // Convert pixel from BMP to TFT format&#xA;            b = sdbuffer[buffidx++];&#xA;            g = sdbuffer[buffidx++];&#xA;            r = sdbuffer[buffidx++];&#xA;            lcdbuffer[lcdidx++] = tft.color565(r,g,b);&#xA;          } // end pixel&#xA;        } // end scanline&#xA;        // Write any remaining data to LCD&#xA;        if(lcdidx &amp;gt; 0) {&#xA;          tft.pushColors(lcdbuffer, lcdidx, first);&#xA;        } &#xA;       // Serial.print(F(&quot;Loaded in &quot;));&#xA;        //Serial.print(millis() - startTime);&#xA;        //Serial.println(&quot; ms&quot;);&#xA;      } // end goodBmp&#xA;    }&#xA;  }&#xA;&#xA;  bmpFile.close();&#xA;  if(!goodBmp) Serial.println(F(&quot;BMP format not recognized.&quot;));&#xA;}&#xA;&#xA;// These read 16- and 32-bit types from the SD card file.&#xA;// BMP data is stored little-endian, Arduino is little-endian too.&#xA;// May need to reverse subscript order if porting elsewhere.&#xA;&#xA;uint16_t read16(File f) {&#xA;  uint16_t result;&#xA;  ((uint8_t *)&amp;amp;result)[0] = f.read(); // LSB&#xA;  ((uint8_t *)&amp;amp;result)[1] = f.read(); // MSB&#xA;  return result;&#xA;}&#xA;&#xA;uint32_t read32(File f) {&#xA;  uint32_t result;&#xA;  ((uint8_t *)&amp;amp;result)[0] = f.read(); // LSB&#xA;  ((uint8_t *)&amp;amp;result)[1] = f.read();&#xA;  ((uint8_t *)&amp;amp;result)[2] = f.read();&#xA;  ((uint8_t *)&amp;amp;result)[3] = f.read(); // MSB&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12076" LastEditorUserId="10907" LastEditDate="2016-01-14T03:56:59.153" LastActivityDate="2016-01-14T03:56:59.153" Title="Replacing delay() with millis()" Tags="|timers|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19521" PostTypeId="2" ParentId="19432" CreationDate="2016-01-13T14:50:19.970" Score="0" Body="&lt;p&gt;Another option is to use a stepper motor and a Peristaltic Pump (or IV pump). You can use this to control the flow rate AND volume. For speed you need to make the motor run faster and for volume just run the stepper motor x times to get x volume. I do not know how precise it is. Good luck with what ever option you pick.&lt;/p&gt;&#xA;" OwnerUserId="5116" LastActivityDate="2016-01-13T14:50:19.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19524" PostTypeId="1" CreationDate="2016-01-13T19:03:11.170" Score="1" ViewCount="2500" Body="&lt;p&gt;So I am trying to get my arduino uno to talk to my arduino due but I'm having issues getting the data outputted on the due side. My arduino uno is the master while the due is the slave. The sensor is connected to the uno and I just require the arduino due to receive and spit out the data as it has a faster sampling rate than the arduino uno. I connected them along the serial (Tx and Rx) lines. And I'm using Serial3 on my arduino due to receive the transmitted data. Both arduinos are grounded together. But powered differently by usb cables connected to my machine. On the arduino uno end ( for brevity sake) the data is sent in binary with the $ sign as the starter bit. Here is the code for the receiving end ( the slave). I just can't seem to get the data out on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    byte b = '$';&#xA;    unsigned char buffer[12];&#xA;    int count =0;&#xA;&#xA;    void setup() {&#xA;    Serial.begin(115200);&#xA;    Serial3.begin(115200);&#xA;    delay(5);&#xA;&#xA;    }&#xA;&#xA;   void loop() {&#xA;   if(Serial.available())&#xA;   {&#xA;    if (b == Serial.available())&#xA;   {&#xA;    while(Serial.available())&#xA;    {&#xA;      buffer[count++] = Serial.read();&#xA;       if(count == 12)break;&#xA;      //Send the byte to serial port three&#xA;      Serial3.write(buffer, count);&#xA;    }&#xA; }&#xA;&#xA; if (Serial3.available()){&#xA;  //get a byte from serial port 3&#xA;  if(b == Serial3.available()){&#xA;    buffer[count++] = Serial3.read();&#xA;    //Send the byte to the USB serial port&#xA;    Serial.write(buffer, count);&#xA;  }&#xA; }&#xA; Serial.println(&quot;lyca&quot;);&#xA; }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14350" LastActivityDate="2016-06-21T15:48:34.403" Title="Connecting an arduino uno to an arduino due" Tags="|arduino-uno|serial|accelerometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19525" PostTypeId="2" ParentId="19524" CreationDate="2016-01-13T19:09:29.960" Score="1" Body="&lt;pre&gt;&lt;code&gt;if(Serial.available())&#xA;{&#xA; if (b == Serial.available())&#xA;{&#xA; while(Serial.available())&#xA; {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you may be getting your knickers in a twist there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... Is serial available? Yes. Is serial available? Still yes! But yes doesn't equal '$'!!!... WHAT?!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You really really need to rethink your understanding of serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Read this: &lt;a href=&quot;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/reading-serial-on-the-arduino&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-13T19:09:29.960" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19526" PostTypeId="1" CreationDate="2016-01-13T19:35:07.537" Score="4" ViewCount="831" Body="&lt;p&gt;Recently I bought the following matrix:&#xA;&lt;a href=&quot;https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I own an Arduino Uno for those who are interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got the 32x32 variant and I am very happy with it. I managed to connect all the wires correctly and get the examples of the library working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing right now is I can't get it to work properly for a personal project of mine. Somehow I am unable to use the serial functions and the matrix library functions in one project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently my project looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino is connected like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PCBt1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PCBt1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the code I wrote is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;gamma.h&amp;gt;&#xA;#include &amp;lt;RGBmatrixPanel.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;gfxfont.h&amp;gt;&#xA;&#xA;#define CLK 8&#xA;#define OE  9    &#xA;#define LAT 10&#xA;#define A   A0&#xA;#define B   A1&#xA;#define C   A2&#xA;#define D   A3&#xA;&#xA;RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);&#xA;String incomingCommand = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  matrix.begin();&#xA;  matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    int incomingByte = Serial.read();&#xA;    char receivedChar = (char) incomingByte;&#xA;    incomingCommand += receivedChar;&#xA;  }&#xA;&#xA;  if (incomingCommand.indexOf('#') &amp;gt; - 1 &amp;amp;&amp;amp; incomingCommand.indexOf('%') &amp;gt; - 1) {&#xA;    String rawCommand = incomingCommand.substring(incomingCommand.indexOf('#'), incomingCommand.indexOf('%') + 1);&#xA;    rawCommand = rawCommand.substring(1, rawCommand.length() - 1);&#xA;    Serial.print(&quot;Following command received: &quot;);&#xA;    Serial.println(rawCommand);&#xA;    if (rawCommand == &quot;turnledon&quot;) {&#xA;      matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));&#xA;    }&#xA;    incomingCommand = &quot;&quot;;&#xA;    rawCommand = &quot;&quot;;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The idea is that a command gets sent from the serial monitor. Based on the command one led on the matrix will turn on. An example of a future command will look similar to this: &quot;#drawPixel_X1_Y2%&quot;, hence the part that checks on &quot;#&quot; and &quot;&amp;amp;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the functionality of the serial monitor isn't working with line 14 and 48 of the code. As soon as I remove those lines, the serial monitor works perfectly and I can receive and write to the serial monitor. I have no idea what is causing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was wondering if someone ever faced a similar problem or knows what I am doing wrong right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance!&lt;/p&gt;&#xA;" OwnerUserId="16374" LastEditorUserId="4628" LastEditDate="2016-12-10T09:28:45.967" LastActivityDate="2016-12-10T09:28:45.967" Title="Unable to use RGB matrix and the serial monitor at once" Tags="|arduino-uno|adafruit|rgb-led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19527" PostTypeId="2" ParentId="19519" CreationDate="2016-01-13T19:51:20.280" Score="2" Body="&lt;p&gt;The usual technique at this scale of technology is to keep loop() pretty short, mostly making frequent calls to a timer function that keeps a list of things to be done (implemented with callback-functions) and the times at which to do them, and which calls those functions at the appropriate times. The upper level(s) of your sketch would schedule tasks by registering one or more callback-functions to be run at a given time or periodically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the timer function is called, if there is nothing to do, or when a callback-function returns, the timer function returns immediately to its caller (probably loop()). loop() can do other work, as long as it can still call the timer function as frequently as your task dispatching requires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;SimpleTimer library&lt;/a&gt; at Arduino Playground is an implementation of such a timer-function.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-01-13T19:51:20.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19528" PostTypeId="1" CreationDate="2016-01-13T20:53:05.607" Score="5" ViewCount="707" Body="&lt;p&gt;I want to connect a device to a door handle, so whenever someone opens the door I'll be able to send a message via my arduino that is connected to a WIFI shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a simple orientation sensor, so I know when the handle is being pushed. The problem is I don't want to keep the Arduino on all of the time (energy issues).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The orientation sensor closes a circuit for about 100ms, so I thought to connect the battery to the Arduino in series with the sensor, but the problem is that it might take more than 100ms to connect and send the data - I need at least 5 seconds to be sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to make the Arduino &quot;power up&quot; for 10 seconds each time someone uses the door handle and then to cut off the power?&lt;/p&gt;&#xA;" OwnerUserId="6804" LastEditorUserId="10907" LastEditDate="2016-01-14T04:02:09.867" LastActivityDate="2016-01-14T06:02:21.117" Title="Briefly &quot;wake up&quot; Arduino in response to an event" Tags="|sensors|power|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19529" PostTypeId="2" ParentId="19528" CreationDate="2016-01-13T20:58:08.903" Score="7" Body="&lt;p&gt;Easy answer: Don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have the Arduino sleep most of the time, and let the door handle invoke an interrupt that wakes it up. Then do whatever processing is required, and then go back to sleep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This won't work as well with a full Arduino as it would with a bare MCU since the rest of the board has its own quiescent load, but once you get it working with an Arduino you can get a bare MCU, wire it up, write the code to it, and away you go.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-13T20:58:08.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19531" PostTypeId="1" CreationDate="2016-01-13T21:49:23.100" Score="1" ViewCount="3123" Body="&lt;p&gt;I am playing with stepper motors and I need a precise square wave generator for f=29.710617283951Hz. I've done this on Raspberry Pi without any problems, but I need something smaller and with less power consumption. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it even possible to get that frequency? &lt;/p&gt;&#xA;" OwnerUserId="16377" LastEditorUserId="6936" LastEditDate="2016-01-14T23:28:25.027" LastActivityDate="2016-01-16T11:39:08.150" Title="How to make precise square wave?" Tags="|pwm|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19532" PostTypeId="2" ParentId="19528" CreationDate="2016-01-13T22:42:05.123" Score="4" Body="&lt;p&gt;I had a similar situation some time ago. I don't have the schematic at hand, but it looked more or less like the one below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nulp4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nulp4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Momentary switch closes and saturates Q1 via R1. It also powers the Arduino. The I/O in on the Arduino has not been programmed yet so it floats. Q1 energizes the coil of the relay which closes its N.O. contact. Now the circuit has latched and you have power to the Arduino for as long as you want.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino starts, does its work (xmits signal or whatever) and then programs the selected I/O pin as output and pulls it low. This will divert current away from the base of Q1, which will cut the current to the coil and everything closes down and no power is drawn from the battery.&#xA;R1 should be some 10 times greater than R2 for this to work. Say R1 = 1K, and R2 = 100 Ohm.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is a concept drawn from memory, it might require some refining :-)&lt;/p&gt;&#xA;" OwnerUserId="16218" LastEditorUserId="10907" LastEditDate="2016-01-14T04:05:23.820" LastActivityDate="2016-01-14T04:05:23.820" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19533" PostTypeId="1" AcceptedAnswerId="19542" CreationDate="2016-01-13T22:44:54.743" Score="2" ViewCount="773" Body="&lt;ol&gt;&#xA;&lt;li&gt;I'm compiling a simple sketch that reads values from an analog input&#xA;and activates a buzzer on a digital input.&lt;/li&gt;&#xA;&lt;li&gt;working on an Arduino uno.&lt;/li&gt;&#xA;&lt;li&gt;the sketch compiles and runs fine on windows and arch linux using the Arduino&#xA;IDE.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I recently tried to start working with Arduino-mk, I tried to compile the said sketch and got the following compiler error (analogVal is the variable holding the analogRead):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/usr/bin/avr-gcc -mmcu=atmega328p -Wl,--gc-sections -Os -o /home/niv/Gits/bin/uno/maglove/maglove.elf &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;~/Gits/bin/uno/maglove/maglove.ino.o ~/Gits/bin/uno/maglove/libcore.a  -lc -lm &#xA;/home/niv/Gits/bin/uno/maglove/maglove.ino.o: In function `_GLOBAL__sub_I_nothing':&#xA;maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xc): undefined reference to `__dso_handle'&#xA;maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xe): undefined reference to `__dso_handle'&#xA;maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0x18): undefined reference to `__cxa_atexit'&#xA;/usr/bin/avr-ld: /home/niv/Gits/bin/uno/maglove/maglove.elf: hidden symbol `__dso_handle' isn't defined&#xA;/usr/bin/avr-ld: final link failed: Bad value&#xA;collect2: error: ld returned 1 exit status&#xA;/home/niv/Gits/Arduino-Makefile/Arduino.mk:1416: recipe for target '/home/niv/Gits/bin/uno/maglove/maglove.elf' failed&#xA;make: *** [/home/niv/Gits/bin/uno/maglove/maglove.elf] Error 1&#xA;make: Target 'all' not remade because of errors.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not very experienced with Arduino yet, and google has failed me in finding this error or any keyword from it in the context of Arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks.&lt;/p&gt;&#xA;" OwnerUserId="15891" LastEditorUserId="37523" LastEditDate="2019-12-02T20:03:33.170" LastActivityDate="2019-12-02T20:03:33.170" Title="Compilation error using arduino-mk on arch Linux (undefined reference to __dso_handle)" Tags="|arduino-uno|compile|linux|avr-gcc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19534" PostTypeId="1" AcceptedAnswerId="19539" CreationDate="2016-01-13T22:45:45.090" Score="1" ViewCount="112" Body="&lt;p&gt;I'm very new to Arduino, and I was wanting to control my Arduino wirelessly. Some googling shows that there is a shield for Arduino called Xbee that allows wireless communication. Unfortunately, I just purchased the #1 shield without checking specifications, (went back later, couldn't find them :/) and now i have a shield that appears to small for my Uno. &lt;a href=&quot;https://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;(XBee Pro 60mW Wire Antenna - Series 1 (802.15.4))&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some more googling showed results that this was indeed the right shield, but I don't see how since the pin pattern is about half the size as the female ports on the Arduino. Is this the right shield? if so, how do I attach the two pieces of hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cu8xQ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cu8xQ.jpg&quot; alt=&quot;My arduino&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RcPsF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RcPsF.jpg&quot; alt=&quot;my xbee&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6578" LastEditorUserId="26916" LastEditDate="2017-09-08T09:58:49.140" LastActivityDate="2017-09-08T09:58:49.140" Title="Xbee for Arduino Uno" Tags="|arduino-uno|hardware|communication|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19535" PostTypeId="1" AcceptedAnswerId="19536" CreationDate="2016-01-13T22:15:23.680" Score="2" ViewCount="1024" Body="&lt;p&gt;&lt;strong&gt;Edit 2&lt;/strong&gt; &#xA;I made a function that works, but I'm still confused about just one thing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very confused about how variables work in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In this program...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  boolean debounce(void)&#xA;{&#xA;  static boolean buttonState=LOW;&#xA;  static boolean lastButtonState;&#xA;  boolean currentState = digitalRead(4);&#xA;  static unsigned long lastDebounceTime;&#xA;  if (currentState != lastButtonState){ //if the button state has changed&#xA;    lastDebounceTime=millis();  //reset timer&#xA;    }&#xA;&#xA;  if ((millis()-lastDebounceTime) &amp;gt; 50)  //if 50 milliseconds has passed since last bounce&#xA;  {  &#xA;    buttonState = currentState;  //read value again now that bouncing is over&#xA;&#xA;    }&#xA;  lastButtonState = currentState;&#xA;  return buttonState;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why does changing this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastButtonState = currentState;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lastButtonState = buttonState;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Make any difference in the program?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try the latter line of code, the whole function stops working and I don't understand why.&lt;/p&gt;&#xA;" OwnerUserId="16381" OwnerDisplayName="Dallin" LastEditorUserId="16381" LastEditDate="2016-01-15T22:16:35.273" LastActivityDate="2016-01-15T22:16:35.273" Title="Why doesn't this debounce function work?" Tags="|serial|programming|button|debounce|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19536" PostTypeId="2" ParentId="19535" CreationDate="2016-01-13T22:53:07.107" Score="4" Body="&lt;p&gt;This probably won't answer your question completely, but here are some notes from me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonState = current ;  //read value again now that bouncing is over&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This won't read the value again, it just copies &lt;code&gt;current&lt;/code&gt; into &lt;code&gt;buttonValue&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you wanted is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonState = digitalRead(BUTTON); // read value again now that bouncing is over&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have multiple issues with your &lt;code&gt;debounce&lt;/code&gt; call:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;lastTimeDebounce&lt;/code&gt; is never used by your code, so it is always zero. &lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;lastButtonState&lt;/code&gt; will be always &lt;code&gt;buttonVal&lt;/code&gt; making the debounce function useless.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some other tips:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't use the same names for parameters as for global variables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;boolean debounce(boolean lastButton, long lastDebounce, int BUTTON)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The global variable &lt;code&gt;BUTTON&lt;/code&gt; will be &lt;strong&gt;shadowed&lt;/strong&gt; by &lt;code&gt;int BUTTON&lt;/code&gt;, essentially overriding it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't use global variables (unless you have a very good reason)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would strongly recommend writing a function that debounces only &lt;strong&gt;one&lt;/strong&gt; pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because if you want a function which can debounce any pin you would need a state variable for each pin (which needs arrays hence a lot of space).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT2&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a debounce function that should work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t PIN = 13;&#xA;&#xA;/*&#xA; * Returns debounced value for `PIN`&#xA; */&#xA;boolean debounce(void)&#xA;{&#xA;    // Current state of the pin&#xA;    boolean currentState;&#xA;    // Last state of the pin, initial value is zero&#xA;    static boolean lastCurrentState = 0;&#xA;    // Timer&#xA;    static unsigned long debounceTimer = millis();&#xA;    // Debounced value, initial value is zero&#xA;    static boolean debouncedValue = 0;&#xA;&#xA;    // We first read the current state of the pin&#xA;    currentState = digitalRead(PIN);&#xA;&#xA;    // Then we look if the state has changed&#xA;    if (currentState != lastCurrentState) {&#xA;        // If it has, we need to reset the debounce timer&#xA;        debounceTimer = millis();&#xA;    }&#xA;&#xA;    // Then we check if the timer has expired&#xA;    if ((millis() - 50) &amp;gt; debounceTimer) {&#xA;        // The timer expired so we update the value&#xA;        debouncedValue = currentState;&#xA;    }&#xA;&#xA;    // Save the latest state&#xA;    lastCurrentState = currentState;&#xA;&#xA;    // We always return a debounced value:&#xA;    return debouncedValue;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But always test such things with an oscilloscope, no guarantee. FYI: this is not an ideal debounce function, but it should make the idea clear.&lt;/p&gt;&#xA;" OwnerUserId="16378" LastEditorUserId="16378" LastEditDate="2016-01-13T23:17:38.473" LastActivityDate="2016-01-13T23:17:38.473" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19537" PostTypeId="2" ParentId="19535" CreationDate="2016-01-13T22:58:25.463" Score="2" Body="&lt;p&gt;&quot;It worked perfectly&quot; is probably an overstatement. Yes, you saw the LED change when you pressed the button, but that doesn't mean it was getting debounced.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that you are trying to use global variables to remember the internal state of the debouncer function, and you're passing those variables into the function as parameters. In C (or C++, which is the underlying language that you're using), an assignment to a function parameter does NOT update the corresponding variable in the caller's environment. Therefore, &lt;code&gt;lastDebounceTime&lt;/code&gt; never gets updated, and your &lt;code&gt;debounce()&lt;/code&gt; function always just returns the current state of the button.&lt;/p&gt;&#xA;" OwnerUserId="614" LastActivityDate="2016-01-13T22:58:25.463" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19538" PostTypeId="2" ParentId="8473" CreationDate="2016-01-13T22:59:29.860" Score="0" Body="&lt;p&gt;RS 232 works on different voltage levels than Arduino, I believe the values you are getting on the screen will have no meaning whatsoever, If the scanner output is TTL then yes it would work, but in my own experience that logic is inverted and you have to add a 1 to software serial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SoftwareSerial mySerial(6, 7, 1); // RX, TX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first step is checking what voltage level is given by your scanner output.&lt;/p&gt;&#xA;" OwnerUserId="16380" LastActivityDate="2016-01-13T22:59:29.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19539" PostTypeId="2" ParentId="19534" CreationDate="2016-01-13T23:07:33.493" Score="3" Body="&lt;p&gt;What you have there is an XBee &lt;em&gt;module&lt;/em&gt;. It is designed to plug into an XBee &lt;em&gt;shield&lt;/em&gt; which then plugs into the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to buy more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the bad news.  The good news is that you have already bought the most expensive part, and the shield to go with it is pretty cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Numerous people make the shields, such as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/12847&quot; rel=&quot;nofollow&quot;&gt;Sparkfun&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.seeedstudio.com/depot/xbee-shield-v20-p-1375.html?cPath=132_134&quot; rel=&quot;nofollow&quot;&gt;Seeed&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Xbee_Shield_For_Arduino_%28no_Xbee%29_%28SKU:DFR0015%29&quot; rel=&quot;nofollow&quot;&gt;DFRobot&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also note that XBees talk to other XBees, so you need at least two of them to get any form of communication going.  If you want to talk to your computer there is a device called the &lt;a href=&quot;https://www.sparkfun.com/products/11812&quot; rel=&quot;nofollow&quot;&gt;XBee Explorer&lt;/a&gt; which plugs into the PC to allow you to communicate with an XBee module.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-13T23:07:33.493" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19540" PostTypeId="2" ParentId="19535" CreationDate="2016-01-13T23:22:33.850" Score="1" Body="&lt;p&gt;Im not an expert of C programming, but I can see lot of troubles in your programming, because you do call a function debounce(), but it is not a function that does a complete task, so you set additional variables outside of it. This is a bad practice, because you can't call the same function to compute multiple keys, that's what functons are for - make one function and call multiple times with different parameters. You should switch to pointer orented parameters for lastButtonState.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    boolean LastButton_1; // global or static variable&#xA;    long LastDebounce_1;&#xA;    int BUTTON_1;&#xA;        ... and so on&#xA;&#xA;&#xA;&#xA;    boolean debounce(boolean *LastButton, long *LastDebounce, int BUTTON)&#xA;        {&#xA;          //your code here, where you read and write to variables located at pointer&#xA;           boolean something, new_value;&#xA;           something = *LastButton; //read value at pointer address&#xA;           *LastButton = new_value; //store the value at pointer address&#xA;        } &#xA;//now you call this&#xA;debounce(&amp;amp;LastButton_1, &amp;amp;LastDebounce_1, BUTTON_1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Perhaps it is not correct, since I know only very basic C, but the way is the right one&lt;/p&gt;&#xA;" OwnerUserId="16379" LastEditorUserId="16379" LastEditDate="2016-01-13T23:53:29.107" LastActivityDate="2016-01-13T23:53:29.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19541" PostTypeId="2" ParentId="19519" CreationDate="2016-01-14T02:13:34.733" Score="0" Body="&lt;p&gt;Taking JRobert's advice, i checked out the simpletimer library.. the final solution was to set up three timers and change the way the buttons functioned. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;as per documentation of the simpletimer library, added the following global:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleTimer.h&amp;gt;&#xA;SimpleTimer timer;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then to setup, i added my three timers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;timer.setInterval(7000, spindle); //times based on hardware reality&#xA;timer.setInterval(2000, coolant);&#xA;timer.setInterval(21500, homer);&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then started the timers in loop by adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;timer.run();&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, i edited the buttons and added variables to denote state of button. &#xA;i.e. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;0 == on, &#xA;1 == transitional1 &#xA;2 == transitional2 &#xA;3 == stopped&#xA;*/&#xA;int homeb = 0;&#xA;int cool = 0;&#xA;int spin = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changed the touch screen code for each button to kick off the timers...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Coolant Button&#xA;if (p.y &amp;gt; 110 &amp;amp;&amp;amp; p.y &amp;lt; 170 &amp;amp;&amp;amp; p.x &amp;gt; 250 &amp;amp;&amp;amp; p.x &amp;lt; 300) { // if stop area is pressed&#xA;  if(cool == 3){&#xA;   bmpDraw(&quot;coolen.bmp&quot;, 15, 105);&#xA;   //PWM the spindle pin on&#xA;   cool = 0;&#xA;  } else {&#xA;    if(cool == 0){&#xA;      //PWM the spindle pin off&#xA;      cool = 1; //Start the timer sequence for stopping coolant&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then i added a void for each timer, this is where i redraw the buttons&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void coolant() {&#xA;  if (cool == 1){&#xA;   bmpDraw(&quot;coolerr.bmp&quot;, 15, 105);&#xA;   cool = 2;&#xA;  } else {&#xA;    if (cool = 2){&#xA;   bmpDraw(&quot;coolstp.bmp&quot;, 15, 105);&#xA;   cool = 3;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps someone else in the future, as it was a real pickle for me to figure out at first.. Thanks again, and credit goes to JRobert, his advice pointed me directly to the solution.&lt;/p&gt;&#xA;" OwnerUserId="12076" LastActivityDate="2016-01-14T02:13:34.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19542" PostTypeId="2" ParentId="19533" CreationDate="2016-01-14T03:16:51.237" Score="2" Body="&lt;p&gt;I can't say I fully understand what is going on, but it seems that if you add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void * __dso_handle;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may be able to eliminate one of the problems. You might try the same trick with &lt;code&gt;__cxa_atexit&lt;/code&gt; as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the idea by searching on:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;arduino __dso_handle&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=29&amp;amp;t=2196&amp;amp;p=13039&amp;amp;hilit=dso_handle#p13039&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; is the webpage that I found that suggested the &lt;code&gt;void *&lt;/code&gt; hack.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-14T03:55:17.967" LastActivityDate="2016-01-14T03:55:17.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19544" PostTypeId="2" ParentId="19528" CreationDate="2016-01-14T04:10:40.437" Score="2" Body="&lt;p&gt;You may find the answer to &lt;a href=&quot;https://electronics.stackexchange.com/questions/49182/how-can-a-let-my-atmega328-run-for-a-year-on-batteries/49233#49233&quot;&gt;How can a let my atmega328 run for a year on batteries?&lt;/a&gt; from SE Electrical Engineering helpful. It is a very detailed resource on power saving measures for the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-01-14T04:10:40.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19545" PostTypeId="1" AcceptedAnswerId="19548" CreationDate="2016-01-14T04:35:42.480" Score="2" ViewCount="427" Body="&lt;p&gt;Hey There Arduino Coders. I am a relatively seasoned C/C++ programmer. However, I'm still new to the Arduino Game. I'm coming here today to ask you guys a direct question that I couldn't find a direct answer for on google... here it goes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible,(also practical) to create my own arduino board? after creating a prototype with an arduino uno and various shields?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words. Is it possible to shrink the arduino(make a custom arduino), and all of its shields on to one board? It seems rather large to have to lug around all of those shields and such. CHEERS!&lt;/p&gt;&#xA;" OwnerUserId="15996" LastActivityDate="2016-01-14T06:32:06.813" Title="Custom arduino board" Tags="|shields|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19546" PostTypeId="2" ParentId="19545" CreationDate="2016-01-14T04:49:31.930" Score="3" Body="&lt;p&gt;Absolutely.  You might start with the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;Arduino to Breadboard Tutorial&lt;/a&gt; while defining your hardware requirement - for example, decide what voltage you are going to run at (and pick an appropriate regulator) and then decide if you can use the imprecise 8 MHz internal oscillator or if you need a more precise external resonator or crystal.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have determined your required circuitry you can advance to making  circuit board, and possibly switch from the DIP version of the ATmega to a QFP package which is smaller and potentially ultimately easier to work with (for production you might even use a QFN, though that is a bit more challenging to solder by hand).  You may also want to look at what package technology your peripheral chips come in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do note though both that you can buy smaller premade Arduion-compatible PCBs, and that there are other chips which are worth considering for a permanent project, some with Arduino compatible libraries available, and some without.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-01-14T04:49:31.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19548" PostTypeId="2" ParentId="19545" CreationDate="2016-01-14T05:51:05.567" Score="7" Body="&lt;p&gt;I have a page about a &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;noreferrer&quot;&gt;breadboard Arduino&lt;/a&gt; which is basically an Atmega328P processor (same as in the Uno, inter alia) on a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aaViV.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aaViV.jpg&quot; alt=&quot;Breadboard Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11109&quot; rel=&quot;noreferrer&quot;&gt;wire-wrapped Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YLNQj.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YLNQj.jpg&quot; alt=&quot;Wire-wrapped Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can go pretty minimalistic with a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12769&quot; rel=&quot;noreferrer&quot;&gt;ATtiny85 mounted on a button battery&lt;/a&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4I3tx.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4I3tx.jpg&quot; alt=&quot;ATtiny85&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to shrink the arduino(make a custom arduino), and all of its shields on to one board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ah there you might be asking a bit much. There are hundreds, if not thousands, of shields people have designed for it. Certainly you can make up your own board to meet a specific purpose.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-14T05:51:05.567" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19549" PostTypeId="2" ParentId="19528" CreationDate="2016-01-14T06:02:21.117" Score="2" Body="&lt;p&gt;You are much better off &lt;strong&gt;sleeping&lt;/strong&gt; the Arduino. In power-down mode the processor can use as little as 100 nA (0.1 µA) which is somewhat less than the self-discharge rate of batteries anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a page about &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;power saving techniques&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also would want to make a custom board, or at least choose an Arduino without a voltage regulator, LEDs, USB chip, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmega328P, when in power-down sleep mode, can be woken by an external interrupt, such as what your door could provide.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-14T06:02:21.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19551" PostTypeId="2" ParentId="19545" CreationDate="2016-01-14T06:32:06.813" Score="1" Body="&lt;p&gt;Yes it is possible. It can be as simple or as complex as you wish :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/How-to-make-your-own-Arduino-board/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-to-make-your-own-Arduino-board/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user10167" LastActivityDate="2016-01-14T06:32:06.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19553" PostTypeId="2" ParentId="19531" CreationDate="2016-01-14T07:04:35.967" Score="2" Body="&lt;p&gt;You can user Timer 1 on the Atmega328P (such as is found on the Uno) to get you into that ball park:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const unsigned long countTo = 33658;  // F_CPU / 8 / 29.71 / 2&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (10, OUTPUT);&#xA;&#xA;  // PWM, top at OCR1A&#xA;  TCCR1A = bit (WGM10) | bit (WGM11);  // PWM&#xA;  TCCR1B = bit (WGM13) | bit (CS11);   // PWM, prescaler of 8&#xA;  OCR1A = countTo - 1;                 // zero relative &#xA;  OCR1B = (countTo / 2) - 1;           // 50% duty cycle&#xA;  bitSet (TCCR1A, COM1B1);   // clear OC1B on compare&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I measured a frequency of 29.67 Hz on one device and 29.41 Hz on another. The Uno is driven by a resonator, not a crystal, so a couple of percent error is to be expected.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about the hardware timers&lt;/a&gt; and a cheat-sheet for Timer 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7l2L1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7l2L1.png&quot; alt=&quot;Timer 1 information&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-14T07:56:48.853" LastActivityDate="2016-01-14T07:56:48.853" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19554" PostTypeId="2" ParentId="4022" CreationDate="2016-01-14T10:14:33.710" Score="3" Body="&lt;p&gt;There is a trade-off between resolution and achievable frequencies. You mention Timer 2, but on the Atmega328P Timer 2 is an 8-bit timer, thus you would not be able to set the CTC to 1024.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume we are talking about an 16-bit timer, like Timer 1 on the Atmega328P. With a prescaler of one, you can time (assuming a 16 MHz clock) from 1 to 65536 &quot;ticks&quot;, that is 62.5 ns up to 4096 µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be the most &lt;em&gt;precise&lt;/em&gt; measurement because you are using one (processor) clock tick per timer tick (a prescaler of one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you plan to time for more than 4.096 ms then you need to bump up the prescaler. The next prescaler up on Timer 1 is 8, so now you can time for an interval 8 times as long (32768 µs) however your accuracy (precision) has now decreased by a factor of 8. The &lt;em&gt;granularity&lt;/em&gt; of the timer has increased from 62.5 ns to 62.5 * 8 ns, which is 500 ns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to time longer than 32.768 ms then the prescaler has to be larger again, the next one being 64. So now you can time up to 262144 µs, but with a granularity of 62.5 * 64, which is 4000 ns (4 µs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion would be to use the lowest prescaler that you can, but still get the interval you want. So obviously you can't use a prescaler of one to time 10 ms.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have a discussion about timers on &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/timers&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On that page is a chart which helps visualize the effects of different prescalers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9dz8M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9dz8M.png&quot; alt=&quot;Timers and prescalers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The top part (count of one) effectively gives you the granularity of each prescaler. For example, a prescaler of 256 has a granularity of 16,000 ns (16 µs). Certain frequencies (powers of 2) will lend themselves to combinations (eg. prescaler of 1 with a count of 256, or prescaler of 256 with a count of 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However for frequencies that don't have that property, the smaller prescaler will (if it can be used) give a finer granularity.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-14T21:47:03.403" LastActivityDate="2016-01-14T21:47:03.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19555" PostTypeId="2" ParentId="19535" CreationDate="2016-01-14T12:20:35.243" Score="0" Body="&lt;p&gt;If you only have one button to debounce, you can store it's state as&#xA;static variables in the &lt;code&gt;debounce()&lt;/code&gt; function itself, like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;bool debounce()&#xA;{&#xA;    const int pin = 4;&#xA;    static bool last_state;&#xA;    static unsigned long last_change;&#xA;    unsigned long now = millis();&#xA;&#xA;    if (now - last_change &amp;gt; 50) {&#xA;        bool state = digitalRead(pin);&#xA;        if (state != last_state) {&#xA;            last_change = now;&#xA;            last_state = state;&#xA;        }&#xA;    }&#xA;    return last_state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you may have to debounce more than one button, the cleaner way would&#xA;be to store the state inside an object, and have the debounce function&#xA;be one of its methods. That's what the&#xA;&lt;a href=&quot;https://github.com/thomasfredericks/Bounce2&quot; rel=&quot;nofollow&quot;&gt;Bounce library&lt;/a&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-01-14T12:20:35.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19559" PostTypeId="1" CreationDate="2016-01-14T16:15:09.043" Score="0" ViewCount="2464" Body="&lt;pre&gt;&lt;code&gt;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0f&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0f&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x30&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x0f&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16292" LastEditorUserId="2881" LastEditDate="2016-01-14T16:19:20.963" LastActivityDate="2016-01-18T22:26:54.090" Title="sketch uploading give error?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ClosedDate="2016-01-21T20:47:17.790" ContentLicense="CC BY-SA 3.0" />
  <row Id="19560" PostTypeId="2" ParentId="19559" CreationDate="2016-01-14T16:22:15.777" Score="0" Body="&lt;p&gt;This &lt;a href=&quot;http://www.instructables.com/id/A-solution-to-avrdude-stk500getsync-not-in-syn/&quot; rel=&quot;nofollow&quot;&gt;Instructables post&lt;/a&gt; has a list of potential causes for this error. Is this a new board? What board are you using? Is it a genuine Arduino board or a clone? Have you been able to upload to the board previously? &lt;/p&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2016-01-14T16:22:15.777" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19563" PostTypeId="2" ParentId="16878" CreationDate="2016-01-14T16:44:49.317" Score="0" Body="&lt;p&gt;If you are doing what you have said you are doing then I think the answer is so obvious no one will ever see it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say you have a 9V 1A power supply.  Since you are powering the Arduino from this it is DC.  Is that correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are connecting an &quot;AC Tube light&quot; to the relay (which supports 1A 12V DC).&#xA;If you are connecting an AC device to a DC supply then things probably do go wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test everything is working properly can you switch the AC light for a DC light?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you can get Relays with AC output and a DC Switching signal, but that will need a bit of research.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps, if not comment and I'll try again.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-01-14T16:44:49.317" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19564" PostTypeId="2" ParentId="10425" CreationDate="2016-01-14T16:57:17.007" Score="1" Body="&lt;p&gt;Reboot you PC, see if that clears it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not then fire up Device Manager and have a look at what COM ports you are using.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think there is a way of reassigning the ports used by the boards within the control panel, but I can't remember what it is at the moment, so have a quick google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its not the fact that its a Clone that's causing you an issue, its Windows drivers that have caused you issues.  If all else fails, uninstall the drivers, reboot twice and try again.  I also don't think using a newer version of the IDE will have a negative affect.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-01-14T16:57:17.007" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19565" PostTypeId="1" AcceptedAnswerId="19569" CreationDate="2016-01-14T17:26:11.600" Score="1" ViewCount="2049" Body="&lt;p&gt;Atmel stated in their website:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system. Regardless of what you choose, you will surely make something amazing.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I wonder how they do it? Is it just a plug-in meaning that we still have to install Arduino software? Or do they have their own compiler and debugger?&lt;/p&gt;&#xA;" OwnerUserId="16403" LastActivityDate="2017-12-05T21:53:56.447" Title="How Atmel Studio 7 compile Arduino code?" Tags="|atmel-studio|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19566" PostTypeId="1" AcceptedAnswerId="19578" CreationDate="2016-01-14T19:22:54.537" Score="1" ViewCount="812" Body="&lt;p&gt;I want to have an Arduino based game you can play on a nokia 5110 screen. The problem is you cant make a medium sized game on an Arduino because the flash size is only 32k. I sit possible to have multiple Arduino's connected to each other, communicating to make it possible to have a bigger game. If it is possible how does it work?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-01-14T22:04:06.820" Title="How to have arduinos work together?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19567" PostTypeId="2" ParentId="19566" CreationDate="2016-01-14T19:29:36.147" Score="1" Body="&lt;p&gt;Yes and no.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes you can make Arduinos communicate with each other and send messages to each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you use that to make a game?  Possibly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it worth the effort?  No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be a huge amount of work and be overly complex when you could just use a bigger Arduino, like a Mega2560 or a Due.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-14T19:29:36.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19568" PostTypeId="2" ParentId="19566" CreationDate="2016-01-14T19:30:23.630" Score="0" Body="&lt;p&gt;You can have two Arduinos communicate with each other but it is fairly complex.  See this &lt;a href=&quot;http://www.instructables.com/id/I2C-between-Arduinos/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;instructable&lt;/a&gt;.  One process is using the I2C protocol.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A far easier option is to use a larger Arduino &lt;a href=&quot;https://www.arduino.cc/en/Products/Compare&quot; rel=&quot;nofollow&quot;&gt;model&lt;/a&gt;.  Consider the Mega 2560 since it has 8 times the Flash memory. &lt;/p&gt;&#xA;" OwnerUserId="13992" LastActivityDate="2016-01-14T19:30:23.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19569" PostTypeId="2" ParentId="19565" CreationDate="2016-01-14T19:42:37.557" Score="1" Body="&lt;p&gt;It is almost always the case that a high-level environment like an IDE provides an interface to an existing tool-chain rather than being truly an all-in-one mega-application, which would a maintenance nightmare. Atmel Studio 7 is no exception, and &lt;a href=&quot;http://www.atmel.com/Microsite/atmel-studio/compiler-editor.aspx&quot; rel=&quot;nofollow&quot;&gt;according to Atmel&lt;/a&gt;, uses and includes (quite likely by downloading it during the install process) the GCC tool-chain.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why Atmel Studio asked about Arduino IDE path when I try to import Arduino sketch?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably for the Arduino libraries, which are contained within the Arduino IDE executable.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-01-21T14:20:26.890" LastActivityDate="2016-01-21T14:20:26.890" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19571" PostTypeId="2" ParentId="19531" CreationDate="2016-01-14T20:31:58.817" Score="3" Body="&lt;p&gt;Reducing the power requirement, compared to an R-Pi, should be straightforward, achieving 29.7106Hz is doable, reducing the size is harder (an R-Pi is quite compact).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the available options depend on your electronics skills, and budget. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll assume you want to use off-the-shelf hardware as much as practical, but are okay to wire 'modules' together (size could be a bit smaller than an R-Pi using off-the-shelf parts, but could be &lt;em&gt;significantly&lt;/em&gt; reduced by a custom made part). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll also assume you want to keep costs under $100. (I apologise if I am wrong, but this seems like a level that many of this community might find interesting :-)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Preamble:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Even at 16MHz, 29.7106Hz represents a count of approximately 538,528, which requires 19 bits. So I would &lt;em&gt;not&lt;/em&gt; use a chip with 8 or 16 bit timers. I would make my life easier by using a chip with 32 bit timers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, the code will be manipulating quantities with at-least 19 bits, so I would &lt;em&gt;not&lt;/em&gt; use an 8 or 16bit CPU. I would make my life easier by using a 32bit CPU that operates on 32bit quantities in a single operation. This may become very important if you opt for a software-heavy approach.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Initial Approach:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Lets assume our 32 bit processor has a clock of 64MHz.&lt;br&gt;&#xA;To generate a clock frequency close to 29.710617284Hz (as good as my calculator will do), load a timer with 2,154,112 (maybe 2,154,111, depending on how the counter triggers).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more accurate divisor is 2,154,112.094. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That count is within 0.05ppm (parts/million) of 29.710617284Hz at a 64MHz clock.&lt;br&gt;&#xA;Also, a count of +/- 1 is a change of less than 0.5ppm. That is about 30x better than the more relaxed requirement, '29.7106', mentioned in your comments. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 64MHz to drive the count will enable 4x better accuracy, 0.5ppm, than using a 16MHz clock, 2ppm, when we examine ways to implement this in the 'Options' section below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Summary so far:&lt;/em&gt; if the microcontroller had a very accurate clock (much better than 0.5ppm error), then the problem is solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the crystals used to drive the microcontroller typically have a frequency stability of 30-50ppm, and may be even worse.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Options to reach 0.5ppm:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;1. Replace the MCUs crystal with a much better part.&lt;/em&gt;&lt;br&gt;&#xA;This will typically require some soldering skill, and the parts I've seen (which are likely to replace the existing crystal) are stable at about 10ppm. That might be a factor of 3-5 better than the factory fitted crystal, so may be worth the effort, however there are better options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;2. Feed the MCU with a higher-stability clock source than a crystal.&lt;/em&gt;&lt;br&gt;&#xA;Most MCU's can accept an external clock source in place of the crystal. Temperature Compensated Crystal Oscillators (TCXO) cost about $5, and can achieve 0.5ppm (0 to 40C, 2ppm -30C to +85C). So an improvement over an 'ordinary' crystal of 30-100x. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is appealing, I'd actually recommend looking at ST Micro's Nucleo boards. They are low-cost (under $12), so not much wasted if it doesn't work, and many of the boards already take an external oscillator, so may be easier to change. (They are 32bit CPU's with 32bit timers, and can run at 64MHz,) I imagine folks can recommend other boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;3. 'Discipline' the square-wave counter with an external high-quality clock&lt;/em&gt;&lt;br&gt;&#xA;The idea is to use a very accurate external clock, and adjust the square-wave count to get high-accuracy than the existing MCU crystal. While counting the MCU clock for the square wave, use a second counter to count the number of MCU clock cycles a known, high-quality, external timing source event takes. The external clock source could be a TCXO, an Oven Controlled Oscillator (OCXO), which can achieve 0.001ppm) or GPS. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program code could estimate the error of the MCU clock vs higher-quality clock, and adjust the square-wave count &lt;em&gt;within each square-wave cycle&lt;/em&gt;. This may keep the square-wave within 0.5ppm using one or more +1 or -1 adjustment of the counter. This approach has the advantage that the only electronics is connecting the high-quality timing source to a pin on the microcontroller. The rest is (carefully written) software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;br&gt;&#xA;To be clear, this option 3 can use an unmodified, off-the-shelf, MCU development board. The original crystal is unchanged; there is no need to modify it to replace its crystal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it could use a small, e.g. Arduino-Nano size, microcontroller running at a reasonable rate (e.g. 64MHz) connected to a TCXO (or even OCXO), and get close to 0.5ppm error.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2016-01-16T11:39:08.150" LastActivityDate="2016-01-16T11:39:08.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19572" PostTypeId="2" ParentId="19473" CreationDate="2016-01-14T20:38:08.367" Score="1" Body="&lt;p&gt;From examination of the sketch, the error '2' that you are seeing is returned from &lt;code&gt;MPU6050_read()&lt;/code&gt;, by the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n = Wire.endTransmission(false); // hold the I2C-bus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the reference for the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire&lt;/a&gt; library, &lt;a href=&quot;https://www.arduino.cc/en/Reference/WireEndTransmission&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;endTransmission()&lt;/code&gt;&lt;/a&gt; returns 2 when&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2:received NACK on transmit of address&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, when you transmit to the MPU6050, the MPU6050 appears to be returning a Not Acknowledged (NACK) packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why a NACK is being returned is not too clear. From &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=238919.0&quot; rel=&quot;nofollow&quot;&gt;Mpu6050 - error 2 - endTransmission&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It means the chips is either not connected (or not correctly) or the wrong address was sent.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;MPU-6050 page on Arduino Playground&lt;/a&gt;, it seems that the address should be 0x68 or 0x69&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The pin &quot;AD0&quot; selects between I2C address 0x68 and 0x69. That makes it possible to have two of these sensors in a project. Most breakout boards have a pullup or pulldown resistor to make AD0 default low or high. Connect AD0 to GND or 3.3V for the other I2C address.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What is AD0 connected to? You do not mention that, in your wiring list for the MPU-6050. If you connect AD0 to GND then address 0x68 is used, if it is to 3.3V then the address is 0x69. From &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=103408.15&quot; rel=&quot;nofollow&quot;&gt;MPU6050 SparkFun Breakout to Arduino Uno - No Communication&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AD0 must be connected to ground or 3.3V (with solder jumper). Connect it to ground for I2C address 0x68.&#xA;  SCL and SDA are connected directly to the Arduino, but you could add extra pull-up resistors to the 3.3V. The resistors could be 4k7 or 10k (the board already has 10k pull-up resistors, but I prefer 4k7).&#xA;  You don't need the INT, you could leave it open.&#xA;  The CLKIN and FSYNC can be tied to ground, because they are not used.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would suggest checking your wiring, and look for any loose contacts on the MPU6050 board.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2016-01-15T08:12:36.750" LastActivityDate="2016-01-15T08:12:36.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19573" PostTypeId="1" CreationDate="2016-01-14T21:16:24.200" Score="0" ViewCount="449" Body="&lt;p&gt;I have a simple question to ask you about SDA and SCL pins.&#xA;I have a gyro and I use these 2 pins to make it work; how can I use an accelerometer combined to a Gyro if these 2 pins are used? I should need another 2 SDA and SCL pins for the accelerometer... Tell me that I don't need to buy an IMU :D &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I'm using Gyro LG3D20H from Adafruit, reading gyro values each 10 ms.&lt;/p&gt;&#xA;" OwnerUserId="15330" LastEditorUserId="15330" LastEditDate="2016-01-15T14:35:59.633" LastActivityDate="2016-01-15T14:35:59.633" Title="SDA and SCL problem with MEMS" Tags="|arduino-uno|accelerometer|gyroscope|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19574" PostTypeId="1" AcceptedAnswerId="19576" CreationDate="2016-01-14T21:07:21.777" Score="2" ViewCount="363" Body="&lt;p&gt;I have a spare Arduino Uno lying around, which I figured I could attempt to turn into a game controller. First clear issue, that immediately popped up, was that there are not enough digital input pins on the board, but I think I can get around that by using analog pins with appropriate external resistors (is that actually a possibility?). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another one, more severe, is that I'm not sure how I would need to go around wiring microswitch buttons with the board. Assuming they short the circuit when pushed (SPST), I could simply wire one contact to an input pin, set to &lt;code&gt;INPUT_PULLUP&lt;/code&gt; mode, and connect the other to ground. However, since I know little about how such circuits work, I'm immediately in doubt about two things. Considering the board would be used as a controller, an external power source is out of question and I'd only want to rely on the USB power. Since I want to use plenty of buttons (up to fifteen), out of caution I'm worried that shorting this many input pins to the ground at once could overload the... regulator I think?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is this: is it safe to use multiple, potentially simultaneously pressed, buttons connected to input pins on an Arduino Uno board, powered solely from a USB port? Additionally, just to be clear, is it normal to connect them all to a common ground on the board?&lt;/p&gt;&#xA;" OwnerUserId="16410" OwnerDisplayName="yakcyll" LastEditorUserId="56438" LastEditDate="2019-05-08T07:38:07.997" LastActivityDate="2019-05-08T07:38:07.997" Title="Arduino with multiple buttons - will power be an issue?" Tags="|usb|button|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19575" PostTypeId="2" ParentId="19574" CreationDate="2016-01-14T21:23:27.017" Score="2" Body="&lt;p&gt;Yes, it is safe to connect multiple buttons to ground. The pull-up resistors have a fairly high value - about 10 kΩ and we know from Ohm's Law that &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I = V / R = 5 V / 10k = 0.5 mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;per button. Your USB power is good for about 500 mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Welcome to StackExchange.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="transistor" LastEditorUserId="13749" LastEditDate="2016-01-14T22:37:05.003" LastActivityDate="2016-01-14T22:37:05.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19576" PostTypeId="2" ParentId="19574" CreationDate="2016-01-14T21:34:07.840" Score="2" Body="&lt;p&gt;Most of your idea is sensible. Let's go over the sensible part first, and then we'll cover the bits that need work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using an internal pullup and shorting the input to ground is the correct way to approach this. Note that the pins will read &lt;code&gt;HIGH&lt;/code&gt; when off and &lt;code&gt;LOW&lt;/code&gt; when triggered this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each pullup on an AVR is between 20kohm and 50kohm. This means that the current consumption if all 15 buttons are pressed is at most about \$15 \cdot {5 \text{V} \over 20\text{k}\Omega} = 3.75\text{mA}\$. This isn't enough for the USB connection to care about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for using the analog connections, A0 through A5 also have digital GPIO capability, which means that you would treat them exactly the same as you would the digital pins (A6 and A7 don't have digital GPIO unless you're running a ATmegaXX8PB with a special core).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now the bad news.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno is based on the ATmega328P, which &lt;em&gt;does not&lt;/em&gt; have native USB capability. It communicates with the host through a serial connection via a USB-UART bridge. If you're using a real (or real-enough) Uno then that bridge is a ATmega16U2 which is a MCU that &lt;em&gt;does&lt;/em&gt; have native USB capability, so it can be reprogrammed to interpret the serial stream from the '328P and talk USB to the host.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you aren't then you will either need to run a piece of software on the host that translates the serial stream to HID actions, or you will have to run a software USB stack on the '328P such as V-USB which will allow you to use Low-Speed USB 1.1 directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation is to see if you can get an Arduino or other AVR-based board that has an ATmegaXXU4 so that you can use &lt;code&gt;Mouse&lt;/code&gt; and &lt;code&gt;Keyboard&lt;/code&gt; directly instead of having to faff around with HID profiles and software USB. Unless that's your thing, of course.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-01-14T21:34:07.840" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19577" PostTypeId="2" ParentId="19573" CreationDate="2016-01-14T21:52:02.983" Score="2" Body="&lt;p&gt;I2C is designed to have multiple devices connected. Assuming the gyro and accelerometer have different I2C addresses they can both be connected to the same SDA and SCL pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/i2c&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally you can only &quot;talk to&quot; one at a time. You may need pull-up resistors on both SDA and SCL, unless the hardware already has them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-14T21:52:02.983" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19578" PostTypeId="2" ParentId="19566" CreationDate="2016-01-14T22:04:06.820" Score="1" Body="&lt;p&gt;You &lt;strong&gt;can&lt;/strong&gt; make quite an impressive game.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1qElu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1qElu.png&quot; alt=&quot;Toorum&amp;#39;s Quest&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Based on ATmega328P running at 16 Mhz (same as Arduino Uno).&lt;/li&gt;&#xA;&lt;li&gt;The game has a display resolution of 104x80 with 256 colors.&lt;/li&gt;&#xA;&lt;li&gt;Video mode is tile based and supports up to 3 sprites per scan line.&lt;/li&gt;&#xA;&lt;li&gt;Sprites are multiplexed so there can be unlimited number of sprites vertically on the screen.&lt;/li&gt;&#xA;&lt;li&gt;4 audio channels with triangle, pulse, sawtooth and noise waveforms.&lt;/li&gt;&#xA;&lt;li&gt;Chiptune music playroutine and sound effects.&lt;/li&gt;&#xA;&lt;li&gt;NES controller support.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Video of it in action:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=sLvgW_zb6bQ&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=sLvgW_zb6bQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=197983.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;post on the Arduino forum&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So, before you start wanting to connect lots of Arduinos together, investigate what can be achieved with just one. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to do, as others have mentioned, is to store static information into PROGMEM (see &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow noreferrer&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt; for more details). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If Petri Häkkinen can get his title screen, levels, sprites, music, and game logic into an Atmega328P you can too! Have fun!&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-14T22:04:06.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19579" PostTypeId="1" CreationDate="2016-01-15T01:57:08.203" Score="2" ViewCount="64" Body="&lt;p&gt;There is &lt;a href=&quot;https://github.com/MHeironimus/ArduinoJoystickLibrary&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt;, but it emulates only one throttle and one rudder. The X Y Z axis don't work because they are addressed from -127 to 127 and I need 0 to 255. I just need one more throttle axis. If it helps, I'm using an ATmega328 and read analog values in the 0 to 1024 range to read Logitech g27 pedals, then dividing by about 4 to fit the read value into the 0 to 255 range.&lt;/p&gt;&#xA;" OwnerUserId="16414" LastEditorUserId="4628" LastEditDate="2016-01-15T17:56:23.337" LastActivityDate="2016-01-15T17:56:23.337" Title="Does anyone know a library that can emulate 3 throttles?" Tags="|library|arduino-micro|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19580" PostTypeId="2" ParentId="1471" CreationDate="2016-01-15T02:24:49.160" Score="4" Body="&lt;p&gt;So I stumbled upon this thread while having similar problem, but with HC-05 module. So because I have too much free time on my hands during finals (no I don't) I decided to create a small github repo that might help someone sometime. &lt;a href=&quot;https://github.com/Sackhorn/HC-05-Pro-Micro-Hookup&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/Sackhorn/HC-05-Pro-Micro-Hookup&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Writen for pro micro&#xA;//These proved to be usefull &#xA;//http://arduino.stackexchange.com/questions/1471/arduino-pro-micro-get-data-out-of-tx-pin&#xA;//https://forum.sparkfun.com/viewtopic.php?f=32&amp;amp;t=38889&amp;amp;sid=8178cdb38005ff33cc380a5da34fb583&amp;amp;start=15&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(9, OUTPUT);  &#xA;  digitalWrite(9, HIGH); &#xA;  Serial.begin(9600);&#xA;  Serial1.begin(38400);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  //Serial1 is the physical Serial Connections on TX and RX pins&#xA;  if (Serial1.available()) Serial.write(Serial1.read());&#xA;&#xA;  // Serial is from my understanding the virtual connection with computer via USB &#xA;  if (Serial.available()) Serial1.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kNlx7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kNlx7.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8750" LastEditorUserId="6628" LastEditDate="2016-03-05T10:37:49.993" LastActivityDate="2016-03-05T10:37:49.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19581" PostTypeId="1" CreationDate="2016-01-15T04:03:46.607" Score="0" ViewCount="742" Body="&lt;p&gt;I noticed timing inconsistencies in my project, and further debugging pinpointed it to the problem below. The text should be updating every second, but the returned values are &gt;&gt; 1000ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify, the text is not showing up every second.  The delays between texts vary according to fluctuating start and finish values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a Teensy 3.2. Changing the baud rate doesn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my timing crystal busted? Is there a serial buffering issue? I don't know how to fix either of these.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VuTQD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VuTQD.png&quot; alt=&quot;example code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code if anyone wants to test.  I found that adding more delay functions screws the output up in completely unlinear ways.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;unsigned long start, finished, elapsed;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Start...&quot;);&#xA;  start = millis();&#xA;  Serial.println(start);&#xA;  delay(1000);&#xA;  finished = millis();&#xA;  Serial.println(finished);&#xA;  Serial.println(&quot;Finished&quot;);&#xA;  elapsed = finished - start;&#xA;  Serial.print(elapsed);&#xA;  Serial.println(&quot; milliseconds elapsed&quot;);&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit #2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it was worth showing everyone this screenshot.  It looks like &lt;code&gt;delay(1000)&lt;/code&gt; just isn't functioning at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BprVs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BprVs.png&quot; alt=&quot;screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit #3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I debugged it with an LED and it blinked at exactly 1s intervals.  It seems like &lt;code&gt;delay(1000)&lt;/code&gt; works, so the problem must be related to the serial buffering.  I also updated my software but that didn't help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit #4:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;New developments from further debugging:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The problem is not reproducible on a different computer.  The Arduino serial monitor on other computers displays correctly.&lt;/li&gt;&#xA;&lt;li&gt;Updating to the latest OSX, arduino IDE, and teensyduino did not help.&lt;/li&gt;&#xA;&lt;li&gt;Terminal 'screen' command surprisingly prints correct serial communication.&lt;/li&gt;&#xA;&lt;li&gt;Serial monitors from 3rd party apps, like CoolTerm and Arduino IDE do not work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16418" LastEditorUserId="16418" LastEditDate="2016-01-17T18:56:23.000" LastActivityDate="2016-01-17T18:56:23.000" Title="Delay function broken?" Tags="|teensy|timing|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="19582" PostTypeId="2" ParentId="16878" CreationDate="2016-01-15T05:07:47.413" Score="0" Body="&lt;p&gt;Finally I got this working using only ESP8266 and minor tweaks. I'll post the circuit here just in case if somebody is trying to do the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that this was done as a POC and I'm not from an electronics background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u316J.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u316J.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly note the blue wire from the GPIO 01 to resistor and an LED. I had to do this because when the circuit is powered on a HIGH signal is sent from the GPIO and the relay is turned on. I think it is the default behaviour of ESP8266. To suppress this initial flow, I did this (There may be a better way to do this according to electronics experts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diode used is 1N4001 Diode&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Decoupling capacitor is - 10nf/100V (0.01uf/100V) Box Capacitor - Polyester&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relay used is &lt;a href=&quot;http://www.amazon.in/gp/product/B00LL0M6RS?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o05_s00&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.in/gp/product/B00LL0M6RS?psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o05_s00&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transistor is bc547.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before connecting the devices, I flashed nodemcu firmware to ESP8266 so that I can write code in Lua script. Refer any of these to flash the firmware -  &lt;a href=&quot;https://www.youtube.com/watch?v=Gh_pgqjfeQc&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=Gh_pgqjfeQc&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=pp6O96B1-Jk&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=pp6O96B1-Jk&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used LuaLoader to transfer the following code to the ESP8266.&#xA;&lt;a href=&quot;http://randomnerdtutorials.com/esp8266-web-server/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://randomnerdtutorials.com/esp8266-web-server/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm posting my init.lua below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;init.lua&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wifi.setmode(wifi.STATION)&#xA;wifi.sta.config(&quot;&amp;lt;ssid&amp;gt;&quot;,&quot;&amp;lt;password&amp;gt;&quot;)&#xA;&#xA;cfg =&#xA;  {&#xA;    ip=&quot;192.168.1.101&quot;,&#xA;    netmask=&quot;255.255.255.0&quot;,&#xA;    gateway=&quot;192.1681.1&quot;&#xA;  }&#xA;  wifi.sta.setip(cfg)&#xA;&#xA;print(wifi.sta.getip())&#xA;led1 = 3&#xA;led2 = 4&#xA;gpio.mode(led1, gpio.OUTPUT)&#xA;gpio.mode(led2, gpio.OUTPUT)&#xA; gpio.write(led1, gpio.LOW)&#xA; gpio.write(led1, gpio.LOW)&#xA;srv=net.createServer(net.TCP)&#xA;srv:listen(80,function(conn)&#xA;    conn:on(&quot;receive&quot;, function(client,request)&#xA;print(&quot;receive&quot;)&#xA;        local buf = &quot;&quot;;&#xA;        local _, _, method, path, vars = string.find(request, &quot;([A-Z]+) (.+)?(.+) HTTP&quot;);&#xA;        if(method == nil)then&#xA;            _, _, method, path = string.find(request, &quot;([A-Z]+) (.+) HTTP&quot;);&#xA;        end&#xA;        local _GET = {}&#xA;        if (vars ~= nil)then&#xA;            for k, v in string.gmatch(vars, &quot;(%w+)=(%w+)&amp;amp;*&quot;) do&#xA;                _GET[k] = v&#xA;            end&#xA;        end&#xA;        buf = buf..&quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;meta name=\&quot;viewport\&quot; content=\&quot;width=device-width, initial-scale=1.0\&quot;&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt; Control Panel&amp;lt;/h1&amp;gt;&quot;;&#xA;        buf = buf..&quot;&amp;lt;p&amp;gt;Tubelight &amp;lt;a href=\&quot;?pin=ON1\&quot;&amp;gt;&amp;lt;button&amp;gt;ON&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;amp;nbsp;&amp;lt;a href=\&quot;?pin=OFF1\&quot;&amp;gt;&amp;lt;button&amp;gt;OFF&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;;&#xA;        local _on,_off = &quot;&quot;,&quot;&quot;&#xA;&#xA;print(wifi.sta.getip())&#xA;        if(_GET.pin == &quot;ON1&quot;)then&#xA;&#xA;              gpio.write(led1, gpio.HIGH);&#xA;&#xA;        elseif(_GET.pin == &quot;OFF1&quot;)then&#xA;              gpio.write(led1, gpio.LOW);&#xA;        elseif(_GET.pin == &quot;ON2&quot;)then&#xA;              gpio.write(led2, gpio.HIGH);&#xA;        elseif(_GET.pin == &quot;OFF2&quot;)then&#xA;              gpio.write(led2, gpio.LOW);&#xA;        end&#xA;&#xA;        client:send(&quot;HTTP/1.1 200 OK\r\n&quot;);&#xA;        client:send(&quot;Content-type: text/html\r\n&quot;);&#xA;        client:send(&quot;Connection: close\r\n\r\n&quot;);&#xA;        client:send(buf);&#xA;        client:close();&#xA;        collectgarbage();&#xA;    end)&#xA;end)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If everything is running, connect your phone or computer to the same wifi using &quot;&lt;code&gt;&amp;lt;ssid&amp;gt;&lt;/code&gt;&quot;,&quot;&lt;code&gt;&amp;lt;password&amp;gt;&lt;/code&gt;&quot; and access the IP 192.168.1.101 to see a webpage with one buttons &quot;ON&quot; and &quot;OFF&quot;. Click on it an check whether it is working.&lt;/p&gt;&#xA;" OwnerUserId="12116" LastEditorUserId="12116" LastEditDate="2016-01-15T05:27:47.097" LastActivityDate="2016-01-15T05:27:47.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19583" PostTypeId="2" ParentId="19581" CreationDate="2016-01-15T05:14:12.500" Score="4" Body="&lt;p&gt;After correcting the syntax error (missing semicolon) I tried your code on my Teensy 3.0. The results look OK to me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start...&#xA;1250&#xA;2250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;2250&#xA;3250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;3250&#xA;4250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;4250&#xA;5250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;5250&#xA;6250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;6250&#xA;7250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;7250&#xA;8250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;8250&#xA;9250&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since the code you posted doesn't compile, can you re-test please with your posted code, assuming you add in the semicolon, and put a space before &quot;milliseconds elapsed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Further down my test I see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start...&#xA;153258&#xA;154258&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;154259&#xA;155259&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&#xA;Start...&#xA;155259&#xA;156259&#xA;Finished&#xA;1000 milliseconds elapsed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now are you talking about the &quot;creep&quot; in the start time? That doesn't totally surprise me, because the rest of the code must take &lt;em&gt;some&lt;/em&gt; time to execute.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I know this isn't an &quot;answer&quot; per se, but I can't post this much information into a comment.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-15T05:14:12.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19584" PostTypeId="1" AcceptedAnswerId="19596" CreationDate="2016-01-15T05:36:38.503" Score="-1" ViewCount="1053" Body="&lt;p&gt;I would like to get one information about this TFT LCD module . This particular module works with parallel interface with arduino mega and uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to get rid of arduino in my project and use esp8266 itself. I have this module &lt;a href=&quot;http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854595985.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854595985.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has only the parallel interface pins mentioned which requires around more than 10 pins to make it work. Is there any possibility that there is an SPI interface supported for this one by  making use of any of the existing pins for the parallel interface. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think so but still can someone confirm that. If so I need to get SPI interface ready TFT LCDs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="15823" LastActivityDate="2016-02-14T11:39:01.060" Title="3.95 TFT LCD SPI or parallel interface" Tags="|arduino-mega|lcd|esp8266|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19586" PostTypeId="1" CreationDate="2016-01-15T07:19:11.703" Score="0" ViewCount="1359" Body="&lt;p&gt;i am looking to communicate text ( 40 char for each message ) between N arduino and a central one ( Communication is one way slaves to Master).I am looking for wire communication with 1 to 5 m distance.Does anyone know the best approach to do that ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vincent&lt;/p&gt;&#xA;" OwnerUserId="10564" LastActivityDate="2016-01-15T09:01:48.443" Title="Simple network protocol to communicate between N slave arduino and 1 central arduino?" Tags="|arduino-uno|arduino-ide|atmega328|networking|atmega16u2|" AnswerCount="2" CommentCount="0" ClosedDate="2016-01-21T20:46:11.363" ContentLicense="CC BY-SA 3.0" />
  <row Id="19590" PostTypeId="2" ParentId="19586" CreationDate="2016-01-15T08:24:56.533" Score="2" Body="&lt;p&gt;You have quite a few options available to you as your requirements are filled by quite a few protocols, I am not going to list all. You can use things such as I&lt;sup&gt;2&lt;/sup&gt;C, CAN, RS-485, RS-232. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find a few good examples from this &lt;a href=&quot;https://electronics.stackexchange.com/questions/35773/communication-between-multiple-microcontrollers&quot;&gt;EE.SE&lt;/a&gt; post from a search.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CAN option is quite a good one for your application and is easy to set up and there are quite a few libraries available for the &lt;a href=&quot;https://www.google.com/search?q=can%20controller%20IC&amp;amp;ie=utf-8&amp;amp;oe=utf-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;common chip&lt;/a&gt; MCP2525 and MCP2551. Yo can also get a 'shield' with this functionality from sparkfun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other options are discussed in the linked EE.SE post with regards to RS-485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/I%C2%B2C&quot; rel=&quot;nofollow noreferrer&quot;&gt;I&lt;sup&gt;2&lt;/sup&gt;C&lt;/a&gt; can be implemented with the Wire library of arduinos and other libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use RS-232, but I don't think it will be immune to noise at the distance you want, but you can still try. What you can do is use a multiplexer, such as this one &lt;a href=&quot;https://www.sparkfun.com/products/9056&quot; rel=&quot;nofollow noreferrer&quot;&gt;CD74HC4067&lt;/a&gt;, and use it to multiplex the TX line from each node to the RX of the master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From SFE's site:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For example, you could use it to connect the TX pins of 16 devices to one RX pin on your microcontroller. You can then select any one of those 16 devices to listen to. If you want two-way communications, you can add a second board to route your microcontroller’s TX line to 16 device’s RX lines. By using multiple boards, you can create similar arrangements for I2C, SPI, etc.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will probably want to add some sort of checksum/CRC to the data you send over the network too.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-01-15T08:24:56.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19591" PostTypeId="2" ParentId="19586" CreationDate="2016-01-15T09:01:48.443" Score="0" Body="&lt;p&gt;IMHO you should first decide your network topology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a &quot;star&quot; network, i.e. a network when every node is directly connected to the central one, you can use any protocol. Maybe even a multiplexed serial interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a daisy chain interface or a bus one use can or RS485.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I'd avoid I2C (it's good for on-board communication, but if the device is a few meters away the noise can break it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion: use serial over half duplex RS485: you can get very low price physical interfaces. Since it is half duplex, only one can &quot;speak&quot;, so the master first sends an address, then puts itself in listen mode and waits. The slave whose address was told puts itself in sending mode and sends the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This way you will have a bus (so you can simply attach a node to another node without having to place a wire till the masater) and you'll have a simple bus logic which will prevent the information to collide. And, most important, RS485 is very strong (up to 1km if I remember well).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CAN can (sorry) be simpler to use, since the anti-collision is &quot;embedded&quot; in the protocol, but it's a bit more complicated to use (you'll need a transceiver and to implement the whole logic in the microcontroller instead of using a dedicated peripheral like the serial interface).&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-15T09:01:48.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19592" PostTypeId="2" ParentId="19517" CreationDate="2016-01-15T09:19:17.510" Score="2" Body="&lt;p&gt;I did a factory reset of the device. That resolved the issue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ORGL&#xA;AT+RESET&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another thing that is very important: The KEY-Pin (EV-Pin on some boards) must be HIGH (3Volts), during the INQ-command. If this PIN is not High, the inq-command will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put 3V to this PIN and release it, you indeed are in AT-Command mode. But not all AT-commands work (e.g. the said at+inq command). If you want to enable all AT-commands the PIN &lt;strong&gt;must remain&lt;/strong&gt; high.&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="15493" LastEditDate="2016-01-27T11:04:00.837" LastActivityDate="2016-01-27T11:04:00.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19593" PostTypeId="1" AcceptedAnswerId="19594" CreationDate="2016-01-15T09:25:00.623" Score="1" ViewCount="3416" Body="&lt;p&gt;My project intend to command an Arduino UNO by my notebook without cable. I thought to use a RF Nordic nRF24L01 cabled on an Arduino UNO, and to use the wireless card of my notebook to send command to it. Is it possible? Any solution?&#xA;Is this hardware solution possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to send to Arduino four analog signals to setup the light of four led.&lt;/p&gt;&#xA;" OwnerUserId="16421" LastActivityDate="2016-01-15T09:57:02.793" Title="connection between Arduino Uno with nRF24L01 and notebook with wireless card" Tags="|arduino-uno|communication|nrf24l01+|wireless|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19594" PostTypeId="2" ParentId="19593" CreationDate="2016-01-15T09:57:02.793" Score="2" Body="&lt;p&gt;Absolutely no. Can you connect your bluetooth headset to the wireless router? No because even if they share the same band they &quot;speak&quot; different protocols. So why could you do that with the nRF24L01?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to communicate with your PC you have three options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Choose nRF24L01. In this case, since the PC does not have that device, you will need to make an adapter (the easiest one could be an USB adapter). You can connect a microcontroller to a USB to serial converter and to the nRF24L01 and use it as a bridge.&lt;/li&gt;&#xA;&lt;li&gt;Choose Wifi. Then you'll need a new transceiver for the arduino UNO you are using (maybe the ESP8266, which is around 2$) but can be a bit more complicated for just sharing data (I never used it, though, so I can be wrong).&lt;/li&gt;&#xA;&lt;li&gt;Choose bluetooth. Usually this is my preferred way to communicate with a board. Cheap (the HC-06 module is about 2-3 $) and easy to use (the interface is a plain serial).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Good luck ;)&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-15T09:57:02.793" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19596" PostTypeId="2" ParentId="19584" CreationDate="2016-01-15T10:53:42.650" Score="1" Body="&lt;p&gt;In general, no. The interface used by the chip is normally hard wired either in the connections to the Chip On Glass or in the connections of the shield (most commonly the former) and as such cannot really be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to either use a TFT screen that has the interface already set to SPI (and there are many) or use some form of SPI I/O expander to provide enough I/O pins to drive a parallel display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that using SPI to communicate with a screen makes the screen updates considerably slower than using a parallel interface. The bigger the screen the slower it gets.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-15T10:53:42.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19597" PostTypeId="1" CreationDate="2016-01-15T12:55:55.687" Score="2" ViewCount="7600" Body="&lt;p&gt;I am trying to pass a class internal function as a callback function within the class. The error behavior is similar to &lt;a href=&quot;https://arduino.stackexchange.com/questions/14480/pass-a-member-function-pointer-to-a-method-of-a-foreign-class-edb-lib&quot;&gt;this problem&lt;/a&gt;. Whatsoever, I was unable to construct working code based on that question's answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to pass over a callback function from within the class,in order to create a finite state machine, inspired by the examples I found on adafruit regarding multithreading. The idea is, that each state can call his successor. The class itself then represents the state machine and I just will call its update function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the following code does not resemble this utility, it resembles the problem in a minimal example (based on &lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot&quot; rel=&quot;nofollow noreferrer&quot;&gt;this larger codepiece&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass&#xA;{&#xA;  const byte theAnswer = 42;&#xA;  void (*myCallback)();&#xA;&#xA;  void setCallback(void (*callback)())&#xA;  {&#xA;    myCallback = callback;&#xA;  }&#xA;&#xA;  public:&#xA;&#xA;  void print_info()&#xA;  {&#xA;    Serial.println(theAnswer);&#xA;  }&#xA;&#xA;  void call()&#xA;  {&#xA;    myCallback();&#xA;  }&#xA;&#xA;   MyClass()&#xA;  {&#xA;    setCallback(&amp;amp;MyClass::print_info);&#xA;  }&#xA;};&#xA;&#xA;&#xA;MyClass AClassOfItsOwn();&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  while (! Serial); // Wait until Serial is ready&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  AClassOfItsOwn.call();&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get the following error code returned:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...testscript.ino: In constructor 'MyClass::MyClass()':&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;testscript:25: error: no matching function for call to&#xA;  'MyClass::setCallback(void (MyClass::*)())'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     setCallback(&amp;amp;MyClass::print_info);&#xA;&#xA;                                     ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;...\testscript.ino:25:41:&#xA;  note: candidate is:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...\testscript.ino:6:12:&#xA;  note: void MyClass::setCallback(void (*)())&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   void setCallback(void (*callback)())&#xA;&#xA;        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;...\testscript.ino:6:12:&#xA;  note:   no known conversion for argument 1 from 'void (MyClass::&lt;em&gt;)()'&#xA;  to 'void (&lt;/em&gt;)()'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...\testscript.ino:&#xA;  In function 'void loop()':&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;testscript:40: error: request for member 'call' in 'AClassOfItsOwn',&#xA;  which is of non-class type 'MyClass()'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   AClassOfItsOwn.call();&#xA;&#xA;                  ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;exit status 1 no matching function for call to&#xA;  'MyClass::setCallback(void (MyClass::*)())'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;fun times with polymorphism&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is code we discussed during looking for a solution. I leave it here for future reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried creating an instance of this wrapper within the actual class to hold the callback, but that did not work either. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CallbackWrapper&#xA;{&#xA;  void (*myCallback)();&#xA;  public:&#xA;&#xA;  void call()&#xA;  {&#xA;    myCallback();&#xA;  }&#xA;&#xA;  void setCallback(void (*callback)())&#xA;  {&#xA;    myCallback = callback;&#xA;  }&#xA;};&#xA;&#xA;class MyClass : public CallbackWrapper&#xA;{&#xA;  const byte theAnswer = 42;&#xA;  public:&#xA;&#xA;  void print_info()&#xA;  {&#xA;    Serial.println(theAnswer);&#xA;  }&#xA;&#xA;   MyClass()&#xA;  {&#xA;    CallbackWrapper::setCallback(&amp;amp;MyClass::print_info);&#xA;  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;trying to store the callback function in a wrapping class (also not working, &lt;code&gt;'((MyClass*)this)-&amp;gt;MyClass::CBW' does not have class type&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CallbackWrapper&#xA;{&#xA;  void (*myCallback)();&#xA;  public:&#xA;&#xA;  void call()&#xA;  { myCallback(); }&#xA;&#xA;  void setCallback(void (*callback)())&#xA;  { myCallback = callback; }&#xA;};&#xA;&#xA;class MyClass &#xA;{&#xA;  const byte theAnswer = 42;&#xA;  CallbackWrapper CBW();&#xA;  public:&#xA;  void print_info() { Serial.println(theAnswer); }&#xA;  void call() { CBW.call(); }&#xA;  MyClass()&#xA;  { CBW.setCallback(&amp;amp;MyClass::print_info); }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An update on why I want to change the callback function during runtime. Here I try to randomly change the callback function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass &#xA;{&#xA;  CallbackWrapper CBW();&#xA;  public:&#xA;  void do_this() { Serial.println(&quot;doing this&quot;); }&#xA;  void do_that() { Serial.println(&quot;doing that&quot;); }&#xA;  void call() &#xA;  { &#xA;    CBW.call();&#xA;    if (rand() &amp;gt; 0.5)&#xA;    {&#xA;      CBW.setCallback(&amp;amp;MyClass::do_this)&#xA;    }&#xA;    else&#xA;    {&#xA;      CBW.setCallback(&amp;amp;MyClass::do_that)&#xA;    }&#xA;  }&#xA;   MyClass()&#xA;  {  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For discussion with Michail&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CallbackWrapper&#xA;{&#xA;  public:&#xA;  void (*myCallback)();&#xA;  void call()&#xA;  { myCallback(); }&#xA;&#xA;  virtual void setCallback(void (*callback)())&#xA;  {  }&#xA;};&#xA;&#xA;class MyClass : public CallbackWrapper&#xA;{&#xA;  public:&#xA;  void setCallback(void (*callback)())&#xA;    { myCallback = callback; }&#xA;  void do_this() { Serial.println(&quot;doing this&quot;); }&#xA;  void do_that() { Serial.println(&quot;doing that&quot;); }&#xA;  void call() &#xA;  { &#xA;    CallbackWrapper::call();&#xA;    if (rand() &amp;gt; 0.5)&#xA;    { setCallback(&amp;amp;MyClass::do_this); }&#xA;    else&#xA;    { setCallback(&amp;amp;MyClass::do_that); }&#xA;  }&#xA;   MyClass()&#xA;  {  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16105" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-15T17:19:05.373" Title="pass class internal function as callback" Tags="|programming|c++|arduino-ide|class|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19599" PostTypeId="2" ParentId="19597" CreationDate="2016-01-15T13:11:30.453" Score="6" Body="&lt;p&gt;Unless you specifically limit yourself to one single class for a callback (i.e., include the class name in the function pointer specification) then you can ONLY use &lt;code&gt;static&lt;/code&gt; member functions as callbacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;static&lt;/code&gt; member functions appear as a normal function, not a member function, so don't have the implied &lt;code&gt;MyClass *this&lt;/code&gt; as a first parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to allow member functions that aren't &lt;code&gt;static&lt;/code&gt; you will have to make use of &lt;em&gt;polymorphism&lt;/em&gt; and have a single &lt;em&gt;base&lt;/em&gt; class that all classes which provide a callback function will inherit from.  Then you limit the callback function pointer to be members of that base class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to do it if you are happy to limit to just one class, though the syntax is rather cryptic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass &#xA;{&#xA;  const byte theAnswer = 42;&#xA;  void (MyClass::*myCallback)();&#xA;&#xA;public:&#xA;&#xA;  void call() {&#xA;    (this-&amp;gt;*myCallback)();&#xA;  }&#xA;&#xA;  void setCallback(void (MyClass::*callback)()) {&#xA;    myCallback = callback;&#xA;  }&#xA;&#xA;  void print_info() {&#xA;    Serial.println(theAnswer);&#xA;  }&#xA;&#xA;  MyClass() {&#xA;    setCallback(&amp;amp;MyClass::print_info);&#xA;  }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using polymorphism you can only pass a callback function that is a member of the parent class, so it looks like that method may be out.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-01-15T15:57:35.857" LastActivityDate="2016-01-15T15:57:35.857" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19600" PostTypeId="1" AcceptedAnswerId="19602" CreationDate="2016-01-15T15:07:06.003" Score="0" ViewCount="177" Body="&lt;p&gt;I have a PING Ultrasonic Sensor, Adafruit Absolute Orientation Sensor, and a Continuous rotation servo. All pins are connected to an Arduino Micro. However because the micro only has one 5V output, I used a rail from a breadboard. I connected the + &amp;amp; - leads from all the devices to the rail and then plugged in two leads connecting 5V and GND from the Micro to the rail. My goal was two send power from the Arduino Micro down the rail to all three devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plugged in the Micro, and instead of seeing green lights on the sensor (powered on), the blue light on the Micro turned off and the servo twitched. I have no idea why. Do I need external power for the 5V?&lt;/p&gt;&#xA;" OwnerUserId="7837" LastEditorUserId="2881" LastEditDate="2016-01-15T16:11:11.300" LastActivityDate="2016-01-15T16:11:11.300" Title="Arduino Micro blue light dimms and turns off when I plug in my circuit" Tags="|adafruit|arduino-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19601" PostTypeId="2" ParentId="19581" CreationDate="2016-01-15T15:30:08.517" Score="0" Body="&lt;p&gt;Since the subtraction's result (&lt;code&gt;finished - start&lt;/code&gt;) displays alright, it means the right number is being stored in the variable, so it's Serial that is screwing up the task of printing it. Try reducing the baud rate to 9600 and try again.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-15T15:30:08.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19602" PostTypeId="2" ParentId="19600" CreationDate="2016-01-15T15:32:19.007" Score="0" Body="&lt;p&gt;This sounds like a lot to have connected to the Micro's 5v pin. Without knowing your exact model of servo, I would still believe you are hitting the current limit. Can you try unplugging the servo and see if the circuit functions without the servo? I would power the servo externally with a 5v supply.&lt;/p&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2016-01-15T15:32:19.007" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19603" PostTypeId="1" AcceptedAnswerId="19604" CreationDate="2016-01-15T17:20:53.503" Score="0" ViewCount="541" Body="&lt;p&gt;I got:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDuemilanove&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardDuemilanove&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://wiki.iteadstudio.com/Stackable_SD_Card_shield_V3.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://wiki.iteadstudio.com/Stackable_SD_Card_shield_V3.0&lt;/a&gt; (set to 5V logic)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;with this &lt;a href=&quot;http://pastie.org/10691360&quot; rel=&quot;nofollow noreferrer&quot;&gt;sketch&lt;/a&gt; using SPI/SdFat+OneWire/DallasTemperature+EmonLib and no matter what I try I got corrupted files like &lt;a href=&quot;http://pastie.org/10691362&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I even haven't attached my sensors yet :(&#xA;I have tried with 3 SD cards so far, each formatted with &lt;a href=&quot;https://www.sdcard.org/downloads/formatter_4/&quot; rel=&quot;nofollow noreferrer&quot;&gt;SD Memory Card Formatter&lt;/a&gt; and each one has this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a separate question like that (&lt;a href=&quot;https://electronics.stackexchange.com/questions/57714/corrupted-files-generated-by-arduino-with-sd-library-how-to-avoid-that&quot;&gt;Corrupted files generated by Arduino with SD library. How to avoid that?&lt;/a&gt;) but it concerns SPI confict but here SD is my only SPI device on the bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="15934" OwnerDisplayName="Kodak" LastEditorUserId="27346" LastEditDate="2018-12-04T12:51:38.750" LastActivityDate="2018-12-04T12:51:38.750" Title="Corrupted files generated by Arduino with SdFat library. How to avoid that?" Tags="|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19604" PostTypeId="2" ParentId="19603" CreationDate="2016-01-15T17:40:32.300" Score="0" Body="&lt;p&gt;This SD shield has CS on D4, not D10&lt;/p&gt;&#xA;" OwnerUserId="15934" LastActivityDate="2016-01-15T17:40:32.300" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19605" PostTypeId="1" AcceptedAnswerId="19607" CreationDate="2016-01-15T18:10:00.933" Score="1" ViewCount="1827" Body="&lt;p&gt;I am just getting hands on to my Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am have finished the blinking light tutorial, managed to read a potentiometer, build a running light with delays and as well a binary counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I build a small project with 5 LEDs and a potentiometer to configure a running light and change the speed of the running light with the potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs are connected to the pins 13 to 9 and the potentiometer is connected A0 and 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also managed to program it without a delay function, but I think it is rather ugly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way of doing this like I did it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led1 = 13;&#xA;int led2 = 12;&#xA;int led3 = 11;&#xA;int led4 = 10;&#xA;int led5 = 9;&#xA;//the delay&#xA;int pause = 1500;&#xA;//count to decide which LEDs are HIGH and which are LOW&#xA;int count = 0;&#xA;// will store last time LED was updated&#xA;unsigned long previousMillis = 0;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {&#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led1, OUTPUT);&#xA;  pinMode(led2, OUTPUT);&#xA;  pinMode(led3, OUTPUT);&#xA;  pinMode(led4, OUTPUT);&#xA;  pinMode(led5, OUTPUT);&#xA;&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  // read the input on analog pin 0:&#xA;  pause = analogRead(A0);&#xA;  float voltage = pause * (5.0 / 1023.0);&#xA;&#xA;  // print out the value and teh corresponding voltage you read:&#xA;  //Serial.println(&quot;Value: %d and Voltage: %f&quot;, pause, voltage);&#xA;  Serial.print(&quot;Value: &quot;);&#xA;  Serial.println(pause);&#xA;  Serial.print(&quot;Volts: &quot;);&#xA;  Serial.println(voltage);&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= pause) {&#xA;    // save the last time you blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    if (count == 0) {&#xA;      digitalWrite(led1, HIGH);&#xA;      digitalWrite(led2, LOW);&#xA;      digitalWrite(led3, LOW);&#xA;      digitalWrite(led4, LOW);&#xA;      digitalWrite(led5, LOW);&#xA;    } &#xA;    else if (count == 1){&#xA;      digitalWrite(led2, HIGH);&#xA;    } &#xA;    else if (count == 2) {&#xA;      digitalWrite(led1, LOW);&#xA;      digitalWrite(led3, HIGH);&#xA;    } &#xA;    else if (count == 3) {&#xA;      digitalWrite(led2, LOW);&#xA;      digitalWrite(led4, HIGH);&#xA;    } &#xA;    else if (count == 4) {&#xA;      digitalWrite(led3, LOW);&#xA;      digitalWrite(led5, HIGH);&#xA;    } &#xA;    else if (count == 5) {&#xA;      digitalWrite(led4, LOW);&#xA;    } &#xA;    else if (count == 6) {&#xA;      digitalWrite(led4, HIGH);&#xA;    } &#xA;    else if (count == 7) {&#xA;      digitalWrite(led5, LOW);&#xA;      digitalWrite(led3, HIGH);&#xA;    } &#xA;    else if (count == 8) {&#xA;      digitalWrite(led4, LOW);&#xA;      digitalWrite(led2, HIGH);&#xA;    } &#xA;    else if (count == 9) {&#xA;      digitalWrite(led3, LOW);&#xA;      digitalWrite(led1, HIGH);&#xA;    } &#xA;    else if (count == 10) {&#xA;      digitalWrite(led2, LOW);&#xA;      digitalWrite(led1, HIGH);&#xA;      count = -1;&#xA;    }&#xA;    count++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16424" LastEditorUserId="10794" LastEditDate="2016-01-15T20:23:35.293" LastActivityDate="2016-01-15T21:07:14.913" Title="Running light, without delay, and a potentiometer" Tags="|c++|led|potentiometer|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19606" PostTypeId="2" ParentId="19605" CreationDate="2016-01-15T18:38:45.260" Score="1" Body="&lt;p&gt;Your Serial.print()s will print on every iteration of loop() even if that iteration doesn't operate on the LEDs. You'll be swamped with output on the terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One improvement I'd make would be to get rid of the counter and the if/else if/.../else if segment. Rotate a bit through a byte variable for as many bit-positions as you have LEDs. Then call a function with that byte, that will set each LED on or off according to the state of its respective bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more improvement can be had if you rotate the bits through bit positions 1 to 5 (in this case) of your byte variable, because you made the fortunate or perhaps intentional assignment of LED's to digital I/Os that are adjacent bits in PORT-B! One single &lt;code&gt;PORTB = [your byte];&lt;/code&gt; statement could set all 5 LEDS simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: &#xA;PORTB is a register in the UNO's Atmega328p MCU, one of three (PORTB, PORTC, and PORTD) that connect to all of the I/Os on the UNO (or any other '328 based MCU board). By setting the (up to) 8 bits in one port, a single assembly-language instruction can set that many I/Os simultaneously. It is incredibly efficient. The downside of doing that instead of calling digitalWrite() is that the sketch is then tailored to that particular processor. digitalWrite() uses more program memory and execution time (by a lot, especially when setting multiple I/Os), but keeps your sketch processor independent; digitalWrite() knows which processor it was compiled for and how to translate a Digital I/O number to a physical external pin on that processor, so you don't have to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For those interested in the low level details of the hardware, they are in the processor's &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-01-15T20:43:25.360" LastActivityDate="2016-01-15T20:43:25.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19607" PostTypeId="2" ParentId="19605" CreationDate="2016-01-15T18:41:09.657" Score="1" Body="&lt;p&gt;You can put the LED pin numbers into an array.  After each delay period, turn off the current LED, increment the count, and turn on that LED.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C prettyprint-override&quot;&gt;&lt;code&gt;// Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer&#xA;&#xA;// Set constants for pins with LEDs&#xA;enum { led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};&#xA;&#xA;// Make an array with the LED pin numbers&#xA;byte ledPins[] = { led1, led2, led3, led4, led5 };&#xA;&#xA;// # of entries in ledPins:&#xA;enum { numLeds = sizeof(ledPins) / sizeof ledPins[0]};&#xA;&#xA;//count to track which LEDs are HIGH and which are LOW&#xA;int count = numLeds-1;      // Will roll over to 0&#xA;&#xA;// To store last time LED was updated&#xA;unsigned long previousMillis = 0;&#xA;&#xA;void setup() {&#xA;  // initialize digital pin outputs&#xA;  for (byte i=0; i&amp;lt;numLeds; ++i)&#xA;    pinMode(ledPins[i], OUTPUT);&#xA;&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// loop() runs over and over again forever:&#xA;void loop() {&#xA;  unsigned long currentMillis = millis();&#xA;  // read input on analog pin 0:&#xA;  int deli = analogRead(A0);&#xA;  float voltage = deli * (5.0 / 1023.0);&#xA;&#xA;  // Print out the value and corresponding voltage you read:&#xA;  // Serial.println(&quot;Value: %d and Voltage: %f&quot;, pause, voltage);&#xA;  Serial.print(&quot;Value: &quot;);&#xA;  Serial.println(deli);&#xA;  Serial.print(&quot;Volts: &quot;);&#xA;  Serial.println(voltage);&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= deli) {&#xA;    // Save the last time we blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    // Turn off current LED, turn on next one&#xA;    digitalWrite(ledPins[count], LOW);&#xA;    count = (count+1) % numLeds;&#xA;    digitalWrite(ledPins[count], HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-15T18:52:54.387" LastActivityDate="2016-01-15T18:52:54.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19608" PostTypeId="1" CreationDate="2016-01-15T19:19:52.757" Score="3" ViewCount="1839" Body="&lt;p&gt;My apologies. This is my first time on this site and I wasn't even aware that it wasn't some sort of discussion forum until receiving the automated response message to my already submitted vague and open-ended question.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Thank you Nick Gammon&lt;/strong&gt; for pointing out Wanago's very interesting project, and I am sorry I did not provide enough information to show the difference in requirements. His solution is quite strictly structured and rigid (not just physically). But I wish to provide a solution that might allow anyone to fairly easily create an ad-hoc collection of any available arduino compatible hardware - which could also allow use of ESP devices for additional functionality if wished, but would not require ESPs as a means of connecting nodes. There may be a better solution than your RS485 Rolling Master for connecting nodes, but yours is the best solution I have yet seen so far, and not least because of the minimal resources required.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Thank you JBulmer&lt;/strong&gt; for your clear overview and assessment, which does now give me a point of focus. In order to pursue this, I must try to aquire sufficient skills to add some form of multiple-chunk protocol layer on top of Nick Gammons Rolling Master protocol. I don't know if I'll manage it because I'm a hacker not a programmer, therefore I would appreciate  if I could give my reasons for trying, because I would very much value your opinion as to whether you think it would be worth my efforts or not.&lt;/p&gt;&#xA;&lt;p&gt;Nicks protocol already provides auto-negotiating of nodes and takes care of most fault-tolerance type issues. I believe it auto-detects nodes and assigns them IDs which are stored in each individuals EEPROM, so he has already taken care of most of the connectivity side of things.&lt;/p&gt;&#xA;&lt;p&gt;And I think the main reason for him using a defined message length was in order for all nodes to be able to poll in timeslot sequence for opportunity to transmit as master, which means it ought to be possible to somehow sync up re-constitution of split message blocks.&lt;/p&gt;&#xA;&lt;p&gt;So apart from the protocol extension for handling of long strings, I don't see any other major obstacles which I can't imagine a solution for in principle even if not yet aware of how. I hasten to add that I am pushing myself way out of my comfort zone to try to achieve this because I think (though perhaps wrongly) that it might offer much benefit to ordinary arduino amateurs (such as myself) who I feel arduino is mainly aimed at. So the following example is not any specific requirement of mine, just something to illustrate some of the potential that could be offered to non-professionals - hopefully after the initial scene-setting, things can become more apparent...&lt;/p&gt;&#xA;&lt;p&gt;The majority of arduino project examples use the serial monitor as a quick and easy way for user interaction, which can then be expected to need customising for more practical methods of input and output - but clustered nodes communicating serially might allow many project examples to be used almost as is.&lt;/p&gt;&#xA;&lt;p&gt;An Infra-Red sender makes a good starting point. The IRremote library IRsendDemo.ino monitors the serial port for a keypress then calls a send routine, eg: irsend.sendSony. The incoming serial trigger could be made to be anything the user wished to use as a command, such as MyIRblaster, and could also include an equivalent text string of any required parameters for appropriate data conversion before use, ie:  MyIRblaster Sony(0xa90, 12)&#xA;All this can be developed and tested in independent isolation using the serial monitor, then when happy, add a 'common' block of RS485-based cluster-talk code, allowing any other node the ability to then send it a MyIRblaster command and parameter to action when needed.&lt;/p&gt;&#xA;&lt;p&gt;As the IR arduino is using the IRremote library anyway, we may as well also give it an IRread capability, which wouldn't even require any associated trigger command.&lt;/p&gt;&#xA;&lt;p&gt;It would be an advantage to be able to save IR signals somewhere though, but trying to squeeze on additional SD and FAT libraries as well as IRremote might be a step too far, so perhaps better just to add a separate SD node for storage. The SD node could have a file of saved IR codes, perhaps each with an asscociated corresponding simple text description such as TVmute, and have a suitable command+parameter capability added such as &amp;quot;SendBlaster (name)&amp;quot;. This would allow any node to issue eg: &amp;quot;SendBlaster TVmute&amp;quot; to the SD node which in turn could issue a corresponding MyIRblaster Sony(0xa90, 12) command to the IR node.&lt;/p&gt;&#xA;&lt;p&gt;And similarly to action any other types of node functionality for that matter - it would be relatively trivial to add some relays to the IR node if wished, and make the node recognise a &amp;quot;Relay (name)&amp;quot; command+parameter for instructing it to control any relay as required.&lt;/p&gt;&#xA;&lt;p&gt;But it would also be just as easy (if not easier from a software point of view) to add a separate Relay node if wished. And similarly, even a Trigger node perhaps offering 64 channels of interupt-driven inputs - which also wouldn't need to recognise any incoming command, just simply be able to issue perhaps a 'Triggered' command plus appropriate triggered channel number as a lookup instruction to the SD node. Every trigger input could be assigned its own corresponding list of responses in its config file entry, which could include any of the functionality that any of the nodes could respond to.&lt;/p&gt;&#xA;&lt;p&gt;Adding new functionality to the cluster would be as simple as adding another command keyword to a relevent nodes list of commands to be parsed for, which when matched would branch to an appropriate internal function.&lt;/p&gt;&#xA;&lt;p&gt;So adding a &amp;quot;WriteLOG&amp;quot; command to the SD node (and having it parse for an accompanying &amp;quot;Details&amp;quot; parameter) could provide a facility for every node to be able to record events to an event log just by sending the serial command &amp;quot;WriteLOG (details)&amp;quot;to the SD node.&lt;/p&gt;&#xA;&lt;p&gt;Commands don't have to be external, they could include any locally recognised macro-type commands for accessing any of the internal capability. So for instance the SD node could recognise a &amp;quot;Pause (duration)&amp;quot; instruction to invoke a non-blocking delay if wished. This could allow the SD node to send multiple IR code commands with pauses between each transmission. It might also recognise a 'No_Retrigger (duration)' timer to prevent unwanted repeat triggering of PIRs etc.&lt;/p&gt;&#xA;&lt;p&gt;To better appreciate the potential now, we could create a config file on SD that contains an appropriate channel entry # for every trigger input we might wish, be it IR receives, PIRs, switch contacts or whatever.&#xA;The channel #3 doorbell entry could be something like this...&lt;/p&gt;&#xA;&lt;h1&gt;3  Doorbell,  No_Retrigger (3mins),  MyIRblaster (TVmute),  Relay (Porchlight) (ON),  Relay (Doorbell) (ON),  Pause (3secs),  Relay (Doorbell) (OFF),   MyIRblaster (TVun_mute),  Pause (5mins), Relay (Porchlight) (OFF).&lt;/h1&gt;&#xA;&lt;p&gt;If the SD node receives a 'Triggered Doorbell' instruction it simply parses the corresponding #3 entry and sends any extracted commands out for the other nodes to action as appropriate. In this case it would ignore subsequent PIR retriggering for 3 minutes, send commands to mute the TV, turn on the porch light, ring the doorbell for 3 seconds, unmute the TV, then turn the porch light off after 5 minutes.&#xA;It could also easily include simple local conditional logic to only turn the Porchlight when dark etc, which could allow option for appropriate qualifiers to a commands parameters, ie: Porchlight (ON) (IF_dark).&lt;/p&gt;&#xA;&lt;p&gt;PIR sensors could select CCTV cameras, or even send IR commands to point a PTZ cam to preset positions, and all using just the same cluster functionality being used above.&lt;/p&gt;&#xA;&lt;p&gt;A voice node might be added to givie an &amp;quot;Announce (message)&amp;quot; command, then add appropriate config entries to provide appropriate voice announcements for any triggered events.&lt;/p&gt;&#xA;&lt;p&gt;Even amateurs could evolve quite sophisticated flexible ad-hoc systems without needing any rocket science, and without hardware constraints other than needing cheap RS485 adapters and sufficient memory for running the protocol and parsing out any commands plus conversion of any parameters.&lt;/p&gt;&#xA;&lt;p&gt;Although the SD node in the example above is tending towards becoming a systems co-ordinator, it is still just essentially another cluster peer node. But perhaps there could be good grounds for trying to modify Nicks Rolling Master to take advantage of what benefits an SD intelligent controller might offer, such as newly connecting nodes automatically obtaining assigned IDs plus other 'characteristics' and 'behaviour' from the centrally managed SD config file.&lt;/p&gt;&#xA;&lt;p&gt;I'm willing to roll up my sleeves and prepare for the long slog if the concept is considered realistic and worthwhile, but I would certainly welcome informed opinion as to whether it might be or not.&lt;/p&gt;&#xA;&lt;p&gt;-------Original---------&lt;/p&gt;&#xA;&lt;p&gt;I am looking into the feasibility of linking multiple Arduinos together to form a cluster of Arduino and ESP8266 nodes capable of sending sequences of plain text commands plus optional parameters to each other.&lt;/p&gt;&#xA;&lt;p&gt;This could offer a mechanism for any node to be able to access the functionality of any other node without having local burden of that functionality.&lt;/p&gt;&#xA;&lt;p&gt;For instance, only the SDcard node would require the libraries and overheads for accessing a centralised config file on SD card, but any of the other nodes could request appropriate entries from the config file whenever needed, or have ability to write event entries to a log file.&lt;/p&gt;&#xA;&lt;p&gt;Similarly for an InfraRed node and its IR libraries, allowing any other node to send it plain text commands and parameters to transmit any required IR code even though the other nodes don't have local IR functionality themselves.&lt;/p&gt;&#xA;&lt;p&gt;Basically, each individual arduino might just be considered a black box that does something useful and can be programmed to respond to certain external text commands (so in fact any other platforms with similar blackbox functionality could also easily be integrated to the cluster if wished).&#xA;Each node would parse an incoming string for a command that matched any of it's own local list of recognisable commands (ie: IRsend [code]) then branch as appropriate with any extracted accompanying parameters.&lt;/p&gt;&#xA;&lt;p&gt;A cluster could be built up to include any and all required arduino functionality even though all of that functionality could never be squeezed onto any single arduino.&lt;/p&gt;&#xA;&lt;p&gt;So an automation cluster could include things like voice announcements, web access, X-10 firecracker control etc just by including the appropriate nodes. Then tomorrow a voice recognition node might be easily added - needing to do nothing more than just issue appropriate text commands to also invoke any already existing functionality.&lt;/p&gt;&#xA;&lt;p&gt;In principle, anyone could have the capability for doing almost anything they might wish, so although I don't know if this cluster functionality idea can be practically achieved or not, but the possible potential offers much incentive for trying.&lt;/p&gt;&#xA;&lt;p&gt;And Nick Gammons excellent &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;RS485 Rolling Master article&lt;/a&gt; brings the possibility so tantalisingly close... but it uses fixed-length messages to achieve it's clever self-negotiating fault-tolerance, and I'm afraid I don't know enough to be able to merge variable-length long string capability with his enticing communications system.&lt;/p&gt;&#xA;&lt;p&gt;So I would appreciate any suggestions, even just informed advice telling me to forget it because it cannot be done (cos at least then I'd be able to get some sleep!).&lt;/p&gt;&#xA;&lt;p&gt;Thanks,&#xA;Robin Baker.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-17T19:41:44.757" Title="Arduino cluster functionality - feasibility advice for arduinos to communicate using variable-length long strings?" Tags="|programming|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19609" PostTypeId="1" AcceptedAnswerId="19612" CreationDate="2016-01-15T19:24:51.590" Score="0" ViewCount="1761" Body="&lt;p&gt;I am using the visual micro extension for Visual Studio 2015.  I would like to not use any .ino files since I'm trying to setup cppcheck which doesn't recogonize .cpp files, and its just what I'm used to.  However when I change my project.ino file to project.cpp the compile option is no longer available (I assume its looking for a .ino file).  Is there a project setting I can change to fix this?&lt;/p&gt;&#xA;" OwnerUserId="16253" LastActivityDate="2016-01-16T19:42:49.537" Title="Visual Micro without .ino files" Tags="|build|visualstudio|ino|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19610" PostTypeId="2" ParentId="19608" CreationDate="2016-01-15T20:19:19.927" Score="2" Body="&lt;p&gt;Someone (Wanago) has done a similar project &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=61643.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. However instead of ESP8266 he used I2C which sounds more practical to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See images:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nDEyq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nDEyq.jpg&quot; alt=&quot;Stack of processors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WUcnC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WUcnC.jpg&quot; alt=&quot;Another stack of processors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He had the same basic idea - each board has a specific task, and the work is shared between them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-15T20:19:19.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19611" PostTypeId="2" ParentId="19608" CreationDate="2016-01-15T20:19:31.537" Score="2" Body="&lt;p&gt;Many communication systems use fixed-length, or limited-length, data exchange at the lower levels. For example, the ethernet network, under TCP/IP, has a maximum package size of 1526 bytes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that doesn't prevent us moving large chunks of data, e.g. a DVD across the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common approach is to use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Protocol_stack&quot; rel=&quot;nofollow&quot;&gt;layered protocol suite&lt;/a&gt;. Each layer is responsible for providing a service to the higher layer by using the service of the lower layers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We talk about layered protocols because it provides a powerful, yet simplified way of thinking about communication problems. Rather than get bogged down in lots of detailed issues which need to be solved to work, we try to organise the problem into simpler and simpler solutions. Eventually things which we can implement without too much difficulty can be built, then higher layers are built from the simpler capabilities of lower layers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The highest level of your protocol would provide the sort of service you need. In this case, you want to be able to send long-ish string messages, so the highest level would do that by using a mid-level fixed-length service. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In its turn the mid-level fixed-length service might provide error-free fixed-length messages using a still-lower-level service which can move fixed-length messages, but can't correct some types of errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is just an illustration of the idea, please don't take this as a concrete suggestion on how to implement anything.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, don't think &quot;I don't know enough to be able to merge variable-length long string capability with his enticing communications system&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, ask the simpler question, &quot;how could I use that existing fixed-length communication system to send variable length strings?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer might be pretty simple if the underlying system guarantees the order that messages are received. For example, send a count of the message length (in one or more messages) then send that number of bytes. The receiver knows how much to expect, and needn't act to interpret the data until it is received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then how to tell the difference between the command and its parameters? The command might be the first 'parameter' in the string, and parameters come after it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I interpret your question, there may be several problems beyond sending variable length strings. There are potential problems like: adding or removing nodes, nodes failing, allocating 'names' to services on nodes (so commands can be sent to the appropriate node), etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the fundamental problem of sending long strings over a fixed-length communication channel is straightforward, and can be solved in a few different ways (I mentioned one, above).&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2016-01-16T01:17:44.420" LastActivityDate="2016-01-16T01:17:44.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19612" PostTypeId="2" ParentId="19609" CreationDate="2016-01-15T20:21:40.153" Score="2" Body="&lt;p&gt;Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... to the start of the .cpp file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12625&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to avoid the quirks of the IDE sketch file pre-preprocessing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To clarify the question about libraries ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do need to put into the .ino file an include for any libraries used in the project. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This effectively triggers the Arduino build process to link those libraries into the final executable file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related, my reply in this thread: &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the&quot;&gt;Classes and objects: how many and which file types do I actually need to use them?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-15T21:48:33.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19613" PostTypeId="2" ParentId="19605" CreationDate="2016-01-15T20:53:43.823" Score="0" Body="&lt;p&gt;Completed now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;@all: Thank you very much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@JRobert: Thanks a lot for the very good explanation&#xA;@jwpat7: Thanks for the code, it helped me a lot.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer&#xA;&#xA;// Set constants for pins with LEDs&#xA;enum { &#xA;  led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};&#xA;&#xA;// Make an array with the LED pin numbers&#xA;byte ledPins[] = { &#xA;  led1, led2, led3, led4, led5 };&#xA;&#xA;// # of entries in ledPins:&#xA;enum { &#xA;  numLeds = sizeof(ledPins) / sizeof ledPins[0]};&#xA;&#xA;//count to track which LEDs are HIGH and which are LOW&#xA;int count = numLeds-1;      // Will roll over to 0&#xA;&#xA;// To store last time LED was updated&#xA;unsigned long previousMillis = 0;&#xA;&#xA;//direction forward&#xA;boolean forward = true;&#xA;&#xA;void setup() {&#xA;  // initialize digital pin outputs&#xA;  for (byte i=0; i&amp;lt;numLeds; ++i)&#xA;    pinMode(ledPins[i], OUTPUT);&#xA;&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;// loop() runs over and over again forever:&#xA;void loop() {&#xA;  unsigned long currentMillis = millis();&#xA;  // read input on analog pin 0:&#xA;  int deli = analogRead(A0);&#xA;  float voltage = deli * (5.0 / 1023.0);&#xA;&#xA;  // Print out the value and corresponding voltage you read:&#xA;  // Serial.println(&quot;Value: %d and Voltage: %f&quot;, pause, voltage);&#xA;  // Serial.print(&quot;Value: &quot;);&#xA;  // Serial.println(deli);&#xA;  // Serial.print(&quot;Volts: &quot;);&#xA;  // Serial.println(voltage);&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= deli) {&#xA;    // Save the last time we blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    if(forward){&#xA;      // Turn off current LED, turn on next one&#xA;      digitalWrite(ledPins[count], LOW);&#xA;      count = (count+1) % numLeds;&#xA;      digitalWrite(ledPins[count], HIGH);&#xA;&#xA;      if(count == numLeds-1 ){&#xA;        forward = false;&#xA;        count = 0;&#xA;      }&#xA;    }&#xA;    else {&#xA;      digitalWrite(ledPins[count + numLeds-1], LOW);&#xA;      count = (count - 1) % numLeds;&#xA;      digitalWrite(ledPins[count + numLeds-1], HIGH);&#xA;&#xA;      if(count + numLeds-1 == 0){&#xA;        forward = true;&#xA;        count = 0;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DcB7w.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DcB7w.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16424" LastEditorUserId="16424" LastEditDate="2016-01-15T21:07:14.913" LastActivityDate="2016-01-15T21:07:14.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19614" PostTypeId="1" CreationDate="2016-01-15T22:02:48.617" Score="0" ViewCount="1736" Body="&lt;p&gt;I need to install my Arduino drivers, but Windows 8.1 doesn't seem to like Arduino, and it greys out the update driver button. Therefore I can't select the drivers from the drivers folder in my Arduino IDE folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are drivers that need to be installed. But Windows 8.1 greys out the &lt;code&gt;update driver software&lt;/code&gt; button. Also, it refers to Arduino Uno as an &lt;code&gt;unknown device&lt;/code&gt;. How do I install the Arduino drivers and make Windows let me install the drivers?&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastEditorUserId="59516" LastEditDate="2019-12-29T17:28:13.160" LastActivityDate="2019-12-29T17:28:13.160" Title="How do I install Arduino drivers?" Tags="|arduino-uno|windows|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19615" PostTypeId="1" AcceptedAnswerId="19622" CreationDate="2016-01-15T22:37:24.857" Score="2" ViewCount="208" Body="&lt;p&gt;On Arduino Due, I set-up DMA transfers using direct control of memory mapped hardware registers.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a 16-bit BTSIZE field in CTRLA which indicates the number of (width sized) transfers.  If I specify larger than 8191, the value of btcount is trimmed to 13 bits after the DMA channel is enabled.  I set chunk size src/dest to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ATMEL data sheet for the sam3x&lt;/a&gt; (linked from the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;due page&lt;/a&gt;) does not mention this 'limitation' (section 22.7.16), or possibly I'm using it wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What reference is canonical and correct for the DMAC (dma controller)?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As noted in the links in the comments, multi-buffer transfer can work around this, but since I don't know why it works or fails, it's hard to decide if that solution will work in all cases.&lt;/p&gt;&#xA;" OwnerUserId="16436" LastEditorUserId="16436" LastEditDate="2016-01-16T03:44:23.667" LastActivityDate="2016-01-16T03:44:23.667" Title="Due : DMAC BTSIZE trimmed modulo 8192?" Tags="|arduino-due|hardware|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19616" PostTypeId="1" AcceptedAnswerId="19719" CreationDate="2016-01-15T23:31:51.467" Score="1" ViewCount="967" Body="&lt;p&gt;I have an ATtiny85 and an Arduino Uno both using NRF24L01 chips to communicate with one another. The ATtiny85 is powered by a CR2032 coin cell. I am using tmrh20's fork of the RF24 library which can be found &lt;a href=&quot;http://tmrh20.github.io/RF24/classRF24.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Here's the problem I'm encountering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under the current code posted, the Uno will receive about 80 packets of data (80 packets times 2 seconds per packet is about 160 seconds of time) before the ATtiny will simply stop sending, and the Uno receives no more data. I can tell that it's the ATtiny, because I've got a DMM hooked up to it. Normally, my DMM tells me that the ATtiny is drawing less than 0.005mA of current, but at the instance of the stall the DMM reads approximately 1.4 mA of current draw, which makes sense because under normal conditions with no sleep the ATtiny draws about 1mA, and the radio not in power down mode and not transmitting draws 0.4mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've spent quite some time trying everything from setting the clock speed to a different value (it's at 1MHz) to changing the power amplifier value. The only thing I've tried that makes an impact is getting rid of the powerUp and powerDown function calls. Once these are removed everything works perfectly transmission-wise, except the only issue is that the whole system is drawing 0.4mA constantly, which is too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think the coin cell is a problem considering the system works when the powerUp and powerDown calls are removed. Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reciever:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CE_PIN 7&#xA;#define CSN_PIN 8&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;&#xA;byte address[11] = &quot;SimpleNode&quot;;&#xA;unsigned long payload = 0;&#xA;&#xA;void setup() {&#xA;  while (!Serial);&#xA;  Serial.begin(115200);&#xA;  radio.begin(); // Start up the radio&#xA;  radio.setAutoAck(1); // Ensure autoACK is enabled&#xA;  radio.setRetries(15,15); // Max delay between retries &amp;amp; number of retries&#xA;  radio.openReadingPipe(1, address); // Write to device address 'SimpleNode'&#xA;  radio.startListening();&#xA;  Serial.println(&quot;Did Setup&quot;);&#xA;&#xA;}&#xA;&#xA;long counter = 0;&#xA;&#xA;void loop(void){&#xA;  if (radio.available()) {&#xA;&#xA;    radio.read( &amp;amp;payload, sizeof(unsigned long) );&#xA;    if(payload != 0){&#xA;        Serial.print(&quot;Got Payload &quot;);&#xA;        Serial.print(payload);&#xA;        Serial.print(&quot; - &quot;);&#xA;        Serial.println(counter);&#xA;        counter++;&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Transmitter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Sleep&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const int sleepSecs = 2;&#xA;&#xA;//Radio&#xA;#define CE_PIN 3&#xA;#define CSN_PIN 3 //Since we are using 3 pin configuration we will use same pin for both CE and CSN&#xA;#include &quot;RF24.h&quot;&#xA;RF24 radio(CE_PIN, CSN_PIN);&#xA;byte address[11] = &quot;SimpleNode&quot;;&#xA;unsigned long payload = 0;&#xA;&#xA;void setup() {&#xA;  //Setup radio&#xA;  radio.begin(); // Start up the radio&#xA;  radio.setAutoAck(1); // Ensure autoACK is enabled&#xA;  radio.setRetries(15,15); // Max delay between retries &amp;amp; number of retries&#xA;  //RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX&#xA;  radio.setPALevel(RF24_PA_HIGH);&#xA;  radio.openWritingPipe(address); // Write to device address 'SimpleNode'&#xA;&#xA;  //Setup sleep&#xA;  setup_watchdog(6);&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN); //Power down everything, wake up from WDT&#xA;  sleep_enable();&#xA;}&#xA;&#xA;volatile int watchdog_counter = 0;&#xA;&#xA;ISR(WDT_vect) {&#xA;  watchdog_counter++;&#xA;}&#xA;&#xA;void loop() {&#xA;  sleep_mode(); //Go to sleep!&#xA;&#xA;  if(watchdog_counter &amp;gt;= sleepSecs)&#xA;  {&#xA;    ADCSRA |= (1&amp;lt;&amp;lt;ADEN);&#xA;    radio.powerUp();&#xA;    watchdog_counter = 0;&#xA;&#xA;    payload = 123456;&#xA;    radio.write(&amp;amp;payload, sizeof(unsigned long) ); //Send data to 'Receiver' every second  &#xA;&#xA;    radio.powerDown();&#xA;    ADCSRA &amp;amp;= ~(1&amp;lt;&amp;lt;ADEN); //Disable ADC, saves ~230uA&#xA;  }&#xA;}&#xA;&#xA;//Sets the watchdog timer to wake us up, but not reset&#xA;//0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms&#xA;//6=1sec, 7=2sec, 8=4sec, 9=8sec&#xA;//From: http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/&#xA;void setup_watchdog(int timerPrescaler) {&#xA;&#xA;  if (timerPrescaler &amp;gt; 9 ) timerPrescaler = 9; //Limit incoming amount to legal settings&#xA;&#xA;  byte bb = timerPrescaler &amp;amp; 7; &#xA;  if (timerPrescaler &amp;gt; 7) bb |= (1&amp;lt;&amp;lt;5); //Set the special 5th bit if necessary&#xA;&#xA;  //This order of commands is important and cannot be combined&#xA;  MCUSR &amp;amp;= ~(1&amp;lt;&amp;lt;WDRF); //Clear the watch dog reset&#xA;  WDTCR |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE); //Set WD_change enable, set WD enable&#xA;  WDTCR = bb; //Set new watchdog timeout value&#xA;  WDTCR |= _BV(WDIE); //Set the interrupt enable, this will keep unit from resetting after each int&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15677" LastActivityDate="2016-01-18T21:43:54.763" Title="RF24 Stalls Arduino Program with powerDown" Tags="|attiny|nrf24l01+|wireless|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19617" PostTypeId="2" ParentId="19616" CreationDate="2016-01-16T01:14:41.327" Score="1" Body="&lt;p&gt;After looking at the RF24 header file, I suggest you call &lt;code&gt;radio.stopListening()&lt;/code&gt; right before you call &lt;code&gt;write()&lt;/code&gt;. Also add a delay of 5 ms after &lt;code&gt;write()&lt;/code&gt;. It would be nice to know the exact point at which the program got stuck; add &lt;code&gt;digitalWrite(13, HIGH)&lt;/code&gt; inside the IF block, after &lt;code&gt;powerDown()&lt;/code&gt; and again outside the block, immediately after &lt;code&gt;sleep_mode()&lt;/code&gt;, but with a LOW argument instead, so you can know if the problem is that the AVR stops waking up at some point or if its the radio methods that is blocking, for some reason.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-16T13:48:36.820" LastActivityDate="2016-01-16T13:48:36.820" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19618" PostTypeId="2" ParentId="19609" CreationDate="2016-01-16T01:35:08.603" Score="1" Body="&lt;p&gt;As you have found, Visual Micro will not consider the project to be an Arduino project if you do not have a &quot;project_name.ino&quot; included in the project&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A cheat is to create a &quot;project_name.cpp&quot; and include it in the project. This will cause the .ino to be ignored during compilation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The project_name.cpp takes priority during compile, therefore the .ino just becomes a dummy. However the .ino will still be used for intellisense. The cpp should be #included in the .ino along with any libraries you want discovered by intellisense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Visual Micro release yesterday includes automatic &quot;library in library&quot; discovery which means you would no longer need to put all lib #include's in the project_name.ino. (tip: you can &lt;a href=&quot;http://www.visualmicro.com/post/2016/01/14/How-to-improve-compile-times-dramatically.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;switch the &quot;deep search&quot; feature off&lt;/a&gt; for each project via the Visual Micro menu. It slows the compile down with large libraries)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kcK3T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kcK3T.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2016-01-16T19:42:49.537" LastActivityDate="2016-01-16T19:42:49.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19619" PostTypeId="1" CreationDate="2016-01-16T02:16:17.937" Score="6" ViewCount="3233" Body="&lt;p&gt;How do you install the Arduino IDE on the Raspberry Pi running an ARM version of Ubuntu or Raspbian? There doesn't seem to be any &lt;a href=&quot;https://www.arduino.cc/en/Main/OldSoftwareReleases#00xx&quot;&gt;official ARM release&lt;/a&gt;. Both distros have an &quot;arduino&quot; package in their standard repos, but it only includes an ancient 1.0 version that's missing a lot of features.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-04-07T18:15:41.747" Title="How to install Arduino IDE on Raspberry Pi" Tags="|raspberrypi|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19620" PostTypeId="2" ParentId="8331" CreationDate="2016-01-16T02:26:10.530" Score="1" Body="&lt;p&gt;Check your power source, if you are powering the module from arduino/USB=&gt;part or something like that, there can be not much power for the module.&#xA;Also you can try powering it 5v (not 3,3 as they should be powered by reference).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I have had problems reading some types of cards, and I have solved that problems by giving better power supply, also higher power supply than in reference for some of the cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;By magic&quot; the cards that were not working started working as a charm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you should check if the cards you are using are all  ISO14443 A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only that kind of cards is compatible with that reader.&#xA;So if you got type B, or other type of ISO cards, that will not be working.&#xA;Some of them may use different frequency, there is a bunch of standards around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also as said before the cards can be damaged, or could be corrupted if you tried reading UID while writing to the card, the problem is known , and in that case you can damage the UID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it helps you.&#xA;cheers&lt;/p&gt;&#xA;" OwnerUserId="16415" LastActivityDate="2016-01-16T02:26:10.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19622" PostTypeId="2" ParentId="19615" CreationDate="2016-01-16T03:36:47.483" Score="2" Body="&lt;p&gt;I'll quote the answer given in &lt;a href=&quot;http://community.atmel.com/forum/synchronous-serial-controller-ssc-or-i2s-using-dma-controller-sam3x8e-incomplete-data-transfer&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; to help make this question more useful for future people who search this problem.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The dmac.h file in asf library has a macro named DMA_MAX_LENGTH set to 0xFFF = 4095. We tried changing it to higher values but still Buffer Transfer size (BTSIZE) register was showing only values till 4095. This seemed to us to a hardware limitation of the DMAC in Atmel SAM3x8E (which we did'nt see mentioned in the datasheet). So this closed the option of single buffer transfer for us and we moved to multi-buffer transfer&lt;/p&gt;&#xA;&lt;p&gt;It was a simple way out (even though I took some time to figure it out :P ) - &lt;em&gt;Use multi-buffer transfer with contiguous source address!&lt;/em&gt; (see table 22.4 Row 3)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-16T03:36:47.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19623" PostTypeId="2" ParentId="19511" CreationDate="2016-01-16T03:51:46.807" Score="2" Body="&lt;p&gt;What I think is happening here is that the HWBE fuse is set (hardware boot enable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the datasheet: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Hardware Boot Enable Fuse (HWBE) can be programmed so that upon&#xA;  special hardware conditions under reset, the bootloader execution is forced after reset.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What this means is that under normal booting (power-on reset) the bootloader is not entered, and the device immediately identifies as a TTY device (ttyACM0) as you saw:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 6329.384088] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However if you manually reset it, it enters DFU mode with its bootloader, so you can reprogram the main code. Thus it identifies differently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 6278.684841] usb 1-1.3: Product: ATmega16U2 DFU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, a forced reset via the Reset pin acts differently to a power-on rest. By design.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you search for &lt;code&gt;uno enter dfu mode&lt;/code&gt; you will get quite a few hits. People use that technique to reprogram their ATmega16U2 (eg. to act as a MIDI interface).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-16T03:51:46.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19624" PostTypeId="1" CreationDate="2016-01-16T04:52:15.687" Score="0" ViewCount="1590" Body="&lt;pre&gt;&lt;code&gt;C:\Users\Field\Documents\Arduino\Adafruit_TCS34725-master\examples\tcs34725autorange\tcs34725autorange.ino:2:31: fatal error: Adafruit_TCS34725.h: No such file or directory&#xA;&#xA; #include &quot;Adafruit_TCS34725.h&quot;&#xA;&#xA;                               ^&#xA;&#xA;compilation terminated.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;exit status 1&#xA;Error compiling.&lt;/p&gt;&#xA;" OwnerUserId="16439" LastEditorUserId="10794" LastEditDate="2016-01-16T06:59:05.533" LastActivityDate="2016-04-25T17:03:41.503" Title="Trying to understand compilation error message" Tags="|compile|adafruit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19625" PostTypeId="2" ParentId="19624" CreationDate="2016-01-16T05:27:54.817" Score="1" Body="&lt;p&gt;You are trying to use a library, but it is either not installed, or is installed in the wrong location. A library, in this context, is code that supports a sensor or some other hardware or that accomplishes a task. We call them libraries because we can share and reuse them – like borrowing a book from a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like you're trying to get the Adafruit TCS34725 color sensor going. The official source of the library is in the &lt;a href=&quot;https://github.com/adafruit/Adafruit_TCS34725&quot; rel=&quot;nofollow&quot;&gt;Adafruit's GitHub repository for the TCS34725&lt;/a&gt; and there is a link at the bottom of the README for how to install a library. I'll bet that will get you back on track.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-16T05:27:54.817" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19626" PostTypeId="1" CreationDate="2016-01-16T05:47:17.170" Score="0" ViewCount="1203" Body="&lt;p&gt;I am trying to dow what is demonstrated in this &lt;a href=&quot;http://www.instructables.com/id/Voice-Activated-Arduino-Bluetooth-Android/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;. I have altered the original setup a little by adding a level converter to not fry the Bluetooth module and resistors for the LEDs, as well as using only 2 instead of four LEDs (which I adjusted for in code later). other than that I am using the exact same setup, code,and procedure. Yet when I try to run my code on the Arduino. I get the error below. I believe it is due to using Tx/Rx and serial at the same time but I really don't know anything about this. Should I add more libraries?&#xA;Should I change the wiring shown in the tutorial link? It seems like I need to use Tx/Rx&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xce&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xce&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code I used from tutorial:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//Coded By: Angelo Casimiro (4/27/14)&#xA;//Voice Activated Arduino (Bluetooth + Android)&#xA;//Feel free to modify it but remember to give credit&#xA;&#xA;String voice;&#xA;int&#xA;led1 = 2, //Connect LED 1 To Pin #2&#xA;led2 = 3, //Connect LED 2 To Pin #3&#xA;led3 = 4, //Connect LED 3 To Pin #4&#xA;led4 = 5, //Connect LED 4 To Pin #5&#xA;led5 = 6; //Connect LED 5 To Pin #6&#xA;//--------------------------Call A Function-------------------------------// &#xA;void allon(){&#xA;     digitalWrite(led1, HIGH);&#xA;     digitalWrite(led2, HIGH);&#xA;     digitalWrite(led3, HIGH);&#xA;     digitalWrite(led4, HIGH);&#xA;     digitalWrite(led5, HIGH);&#xA;}&#xA;void alloff(){&#xA;     digitalWrite(led1, LOW);&#xA;     digitalWrite(led2, LOW);&#xA;     digitalWrite(led3, LOW);&#xA;     digitalWrite(led4, LOW);&#xA;     digitalWrite(led5, LOW);&#xA;}&#xA;//-----------------------------------------------------------------------// &#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(led1, OUTPUT);&#xA;  pinMode(led2, OUTPUT);&#xA;  pinMode(led3, OUTPUT);&#xA;  pinMode(led4, OUTPUT);&#xA;  pinMode(led5, OUTPUT);&#xA;}&#xA;//-----------------------------------------------------------------------// &#xA;void loop() {&#xA;  while (Serial.available()){  //Check if there is an available byte to read&#xA;  delay(10); //Delay added to make thing stable&#xA;  char c = Serial.read(); //Conduct a serial read&#xA;  if (c == '#') {break;} //Exit the loop when the # is detected after the word&#xA;  voice += c; //Shorthand for voice = voice + c&#xA;  } &#xA;  if (voice.length() &amp;gt; 0) {&#xA;    Serial.println(voice);&#xA;//-----------------------------------------------------------------------//   &#xA;  //----------Control Multiple Pins/ LEDs----------// &#xA;       if(voice == &quot;*all on&quot;) {allon();}  //Turn Off All Pins (Call Function)&#xA;  else if(voice == &quot;*all off&quot;){alloff();} //Turn On  All Pins (Call Function)&#xA;&#xA;  //----------Turn On One-By-One----------//&#xA;  else if(voice == &quot;*TV on&quot;) {digitalWrite(led1, HIGH);}&#xA;  else if(voice == &quot;*fan on&quot;) {digitalWrite(led2, HIGH);}&#xA;  else if(voice == &quot;*computer on&quot;) {digitalWrite(led3, HIGH);}&#xA;  else if(voice == &quot;*bedroom lights on&quot;) {digitalWrite(led4, HIGH);}&#xA;  else if(voice == &quot;*bathroom lights on&quot;) {digitalWrite(led5, HIGH);}&#xA;  //----------Turn Off One-By-One----------//&#xA;  else if(voice == &quot;*TV off&quot;) {digitalWrite(led1, LOW);}&#xA;  else if(voice == &quot;*fan off&quot;) {digitalWrite(led2, LOW);}&#xA;  else if(voice == &quot;*computer off&quot;) {digitalWrite(led3, LOW);}&#xA;  else if(voice == &quot;*bedroom lights off&quot;) {digitalWrite(led4, LOW);}&#xA;  else if(voice == &quot;*bathroom lights off&quot;) {digitalWrite(led5, LOW);}&#xA;//-----------------------------------------------------------------------// &#xA;voice=&quot;&quot;;}} //Reset the variable after initiating&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14820" LastEditorUserId="4131" LastEditDate="2016-01-16T15:08:36.943" LastActivityDate="2017-11-09T22:33:05.263" Title="bluetooth module with stk500_recv() error" Tags="|serial|bluetooth|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19627" PostTypeId="1" CreationDate="2016-01-16T06:28:05.807" Score="2" ViewCount="123" Body="&lt;p&gt;How would I refine this to only recognize red and green? I don't need the full functionality of this code, just the ability to distinguish between red and green, and output that respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also would like to eliminate the bleed over; meaning, the green led stays on slightly when I flood the Adafruit with red light and vice versa. I am not really familiar with the output of the Adafruit, but it seems this could be an analog &quot;question and answer&quot; situation; it's either green or red or nothing. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_TCS34725.h&quot;&#xA;&#xA;#ifndef _TCS34725_H_&#xA;#define _TCS34725_H_&#xA;&#xA;#if ARDUINO &amp;gt;= 100&#xA; #include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA; #include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define TCS34725_ADDRESS          (0x29)&#xA;&#xA;#define TCS34725_COMMAND_BIT      (0x80)&#xA;&#xA;#define TCS34725_ENABLE           (0x00)&#xA;#define TCS34725_ENABLE_AIEN      (0x10)    /* RGBC Interrupt Enable */&#xA;#define TCS34725_ENABLE_WEN       (0x08)    /* Wait enable - Writing 1 activates the wait timer */&#xA;#define TCS34725_ENABLE_AEN       (0x02)    /* RGBC Enable - Writing 1 actives the ADC, 0 disables it */&#xA;#define TCS34725_ENABLE_PON       (0x01)    /* Power on - Writing 1 activates the internal oscillator, 0 disables it */&#xA;#define TCS34725_ATIME            (0x01)    /* Integration time */&#xA;#define TCS34725_WTIME            (0x03)    /* Wait time (if TCS34725_ENABLE_WEN is asserted) */&#xA;#define TCS34725_WTIME_2_4MS      (0xFF)    /* WLONG0 = 2.4ms   WLONG1 = 0.029s */&#xA;#define TCS34725_WTIME_204MS      (0xAB)    /* WLONG0 = 204ms   WLONG1 = 2.45s  */&#xA;#define TCS34725_WTIME_614MS      (0x00)    /* WLONG0 = 614ms   WLONG1 = 7.4s   */&#xA;#define TCS34725_AILTL            (0x04)    /* Clear channel lower interrupt threshold */&#xA;#define TCS34725_AILTH            (0x05)&#xA;#define TCS34725_AIHTL            (0x06)    /* Clear channel upper interrupt threshold */&#xA;#define TCS34725_AIHTH            (0x07)&#xA;#define TCS34725_PERS             (0x0C)    /* Persistence register - basic SW filtering mechanism for interrupts */&#xA;#define TCS34725_PERS_NONE        (0b0000)  /* Every RGBC cycle generates an interrupt                                */&#xA;#define TCS34725_PERS_1_CYCLE     (0b0001)  /* 1 clean channel value outside threshold range generates an interrupt   */&#xA;#define TCS34725_PERS_2_CYCLE     (0b0010)  /* 2 clean channel values outside threshold range generates an interrupt  */&#xA;#define TCS34725_PERS_3_CYCLE     (0b0011)  /* 3 clean channel values outside threshold range generates an interrupt  */&#xA;#define TCS34725_PERS_5_CYCLE     (0b0100)  /* 5 clean channel values outside threshold range generates an interrupt  */&#xA;#define TCS34725_PERS_10_CYCLE    (0b0101)  /* 10 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_15_CYCLE    (0b0110)  /* 15 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_20_CYCLE    (0b0111)  /* 20 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_25_CYCLE    (0b1000)  /* 25 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_30_CYCLE    (0b1001)  /* 30 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_35_CYCLE    (0b1010)  /* 35 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_40_CYCLE    (0b1011)  /* 40 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_45_CYCLE    (0b1100)  /* 45 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_50_CYCLE    (0b1101)  /* 50 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_55_CYCLE    (0b1110)  /* 55 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_PERS_60_CYCLE    (0b1111)  /* 60 clean channel values outside threshold range generates an interrupt */&#xA;#define TCS34725_CONFIG           (0x0D)&#xA;#define TCS34725_CONFIG_WLONG     (0x02)    /* Choose between short and long (12x) wait times via TCS34725_WTIME */&#xA;#define TCS34725_CONTROL          (0x0F)    /* Set the gain level for the sensor */&#xA;#define TCS34725_ID               (0x12)    /* 0x44 = TCS34721/TCS34725, 0x4D = TCS34723/TCS34727 */&#xA;#define TCS34725_STATUS           (0x13)&#xA;#define TCS34725_STATUS_AINT      (0x10)    /* RGBC Clean channel interrupt */&#xA;#define TCS34725_STATUS_AVALID    (0x01)    /* Indicates that the RGBC channels have completed an integration cycle */&#xA;#define TCS34725_CDATAL           (0x14)    /* Clear channel data */&#xA;#define TCS34725_CDATAH           (0x15)&#xA;#define TCS34725_RDATAL           (0x16)    /* Red channel data */&#xA;#define TCS34725_RDATAH           (0x17)&#xA;#define TCS34725_GDATAL           (0x18)    /* Green channel data */&#xA;#define TCS34725_GDATAH           (0x19)&#xA;#define TCS34725_BDATAL           (0x1A)    /* Blue channel data */&#xA;#define TCS34725_BDATAH           (0x1B)&#xA;&#xA;typedef enum&#xA;{&#xA;  TCS34725_INTEGRATIONTIME_2_4MS  = 0xFF,   /**&amp;lt;  2.4ms - 1 cycle    - Max Count: 1024  */&#xA;  TCS34725_INTEGRATIONTIME_24MS   = 0xF6,   /**&amp;lt;  24ms  - 10 cycles  - Max Count: 10240 */&#xA;  TCS34725_INTEGRATIONTIME_50MS   = 0xEB,   /**&amp;lt;  50ms  - 20 cycles  - Max Count: 20480 */&#xA;  TCS34725_INTEGRATIONTIME_101MS  = 0xD5,   /**&amp;lt;  101ms - 42 cycles  - Max Count: 43008 */&#xA;  TCS34725_INTEGRATIONTIME_154MS  = 0xC0,   /**&amp;lt;  154ms - 64 cycles  - Max Count: 65535 */&#xA;  TCS34725_INTEGRATIONTIME_700MS  = 0x00    /**&amp;lt;  700ms - 256 cycles - Max Count: 65535 */&#xA;}&#xA;tcs34725IntegrationTime_t;&#xA;&#xA;typedef enum&#xA;{&#xA;  TCS34725_GAIN_1X                = 0x00,   /**&amp;lt;  No gain  */&#xA;  TCS34725_GAIN_4X                = 0x01,   /**&amp;lt;  4x gain  */&#xA;  TCS34725_GAIN_16X               = 0x02,   /**&amp;lt;  16x gain */&#xA;  TCS34725_GAIN_60X               = 0x03    /**&amp;lt;  60x gain */&#xA;}&#xA;tcs34725Gain_t;&#xA;&#xA;class Adafruit_TCS34725 {&#xA; public:&#xA;  Adafruit_TCS34725(tcs34725IntegrationTime_t = TCS34725_INTEGRATIONTIME_2_4MS, tcs34725Gain_t = TCS34725_GAIN_1X);&#xA;&#xA;  boolean  begin(void);&#xA;  void     setIntegrationTime(tcs34725IntegrationTime_t it);&#xA;  void     setGain(tcs34725Gain_t gain);&#xA;  void     getRawData(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c);&#xA;  uint16_t calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b);&#xA;  uint16_t calculateLux(uint16_t r, uint16_t g, uint16_t b);&#xA;  void     write8 (uint8_t reg, uint32_t value);&#xA;  uint8_t  read8 (uint8_t reg);&#xA;  uint16_t read16 (uint8_t reg);&#xA;  void setInterrupt(boolean flag);&#xA;  void clearInterrupt(void);&#xA;  void setIntLimits(uint16_t l, uint16_t h);&#xA;  void     enable(void);&#xA;&#xA; private:&#xA;  boolean _tcs34725Initialised;&#xA;  tcs34725Gain_t _tcs34725Gain;&#xA;  tcs34725IntegrationTime_t _tcs34725IntegrationTime; &#xA;&#xA;  void     disable(void);&#xA;};&#xA;&#xA;#endif&#xA;&#xA;// Pick analog outputs, for the UNO these three work well&#xA;// use ~560  ohm resistor between Red &amp;amp; Blue, ~1K for green (its brighter)&#xA;#define redpin 3&#xA;#define greenpin 5&#xA;#define bluepin 6&#xA;// for a common anode LED, connect the common pin to +5V&#xA;// for common cathode, connect the common to ground&#xA;&#xA;// set to false if using a common cathode LED&#xA;#define commonAnode true&#xA;&#xA;// our RGB -&amp;gt; eye-recognized gamma color&#xA;byte gammatable[256];&#xA;&#xA;&#xA;Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Color View Test!&quot;);&#xA;&#xA;  if (tcs.begin()) {&#xA;    Serial.println(&quot;Found sensor&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;No TCS34725 found ... check your connections&quot;);&#xA;    while (1); // halt!&#xA;  }&#xA;&#xA;  // use these three pins to drive an LED&#xA;  pinMode(redpin, OUTPUT);&#xA;  pinMode(greenpin, OUTPUT);&#xA;  pinMode(bluepin, OUTPUT);&#xA;&#xA;  // thanks PhilB for this gamma table!&#xA;  // it helps convert RGB colors to what humans see&#xA;  for (int i=0; i&amp;lt;256; i++) {&#xA;    float x = i;&#xA;    x /= 255;&#xA;    x = pow(x, 2.5);&#xA;    x *= 255;&#xA;&#xA;    if (commonAnode) {&#xA;      gammatable[i] = 255 - x;&#xA;    } else {&#xA;      gammatable[i] = x;      &#xA;    }&#xA;    //Serial.println(gammatable[i]);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  uint16_t clear, red, green, blue;&#xA;&#xA;  tcs.setInterrupt(false);      // turn on LED&#xA;&#xA;  delay(60);  // takes 50ms to read &#xA;&#xA;  tcs.getRawData(&amp;amp;red, &amp;amp;green, &amp;amp;blue, &amp;amp;clear);&#xA;&#xA;  tcs.setInterrupt(true);  // turn off LED&#xA;&#xA;  Serial.print(&quot;C:\t&quot;); Serial.print(clear);&#xA;  Serial.print(&quot;\tR:\t&quot;); Serial.print(red);&#xA;  Serial.print(&quot;\tG:\t&quot;); Serial.print(green);&#xA;  Serial.print(&quot;\tB:\t&quot;); Serial.print(blue);&#xA;&#xA;  // Figure out some basic hex code for visualization&#xA;  uint32_t sum = clear;&#xA;  float r, g, b;&#xA;  r = red; r /= sum;&#xA;  g = green; g /= sum;&#xA;  b = blue; b /= sum;&#xA;  r *= 256; g *= 256; b *= 256;&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);&#xA;  Serial.println();&#xA;&#xA;  //Serial.print((int)r ); Serial.print(&quot; &quot;); Serial.print((int)g);Serial.print(&quot; &quot;);  Serial.println((int)b );&#xA;&#xA;  analogWrite(redpin, gammatable[(int)r]);&#xA;  analogWrite(greenpin, gammatable[(int)g]);&#xA;  analogWrite(bluepin, gammatable[(int)b]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16439" LastEditorUserId="10794" LastEditDate="2016-01-16T06:58:26.733" LastActivityDate="2016-01-16T06:58:26.733" Title="Refine Colorview Code" Tags="|c++|adafruit|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19628" PostTypeId="1" CreationDate="2016-01-16T07:30:47.530" Score="3" ViewCount="2047" Body="&lt;p&gt;I want to upload an .hex file to an Atmega8 chip (SMD). I want to use the Arduino IDE and an Uno as the ISP program. But I'm unable to find any details on how to load a sketch which is in .hex format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is the batch file I created to use with avrdude. I would like to know if the Command is correct?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hardware\tools\avr\bin/avrdude -CC:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hardware\tools\avr\etc/avrdude.conf -v -v -v -v -patmega8 -cstk500&#xA; -P\\.\COM4 -b19200 -Uflash:w:C:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hexFiles\Heart.hex:i&#xA;&#xA;pause&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16442" LastEditorUserId="16442" LastEditDate="2016-01-16T09:56:20.740" LastActivityDate="2016-01-16T09:56:20.740" Title="How to upload .hex file to Atmega8 Using Arduino IDE and Uno as an Isp?" Tags="|arduino-uno|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19629" PostTypeId="1" CreationDate="2016-01-16T09:58:45.873" Score="0" ViewCount="1922" Body="&lt;p&gt;I'm currently experimenting with my arduino Uno. I control it via an mobile (android) but wanted to just use a microphone on the board so I don't need to carry my mobile around. It is possible to record flac files from a mic and send it to Google speech api and get a return? And then maybe output it via the synthesis. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is possible to do this on an arduino uno and with C. If doesnt is there any other way I can go? I could buy a raspberry pi but I don't an whole operating system like linux installed. So any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="16448" LastActivityDate="2016-02-16T18:41:05.747" Title="Arduino Google speech api" Tags="|arduino-uno|programming|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19630" PostTypeId="1" CreationDate="2016-01-16T10:25:15.747" Score="2" ViewCount="1151" Body="&lt;p&gt;For an ethernet project I do, I need to store the Ethernet Shield's MAC address.&#xA;I store it like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That works OK, but in my project I need all the SRAM available, so every byte of memory is important. I've used the F() macro and PROGMEM everywhere, but I couldn't manage to store the MAC byte array in the PROGMEM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I store it in PROGMEM? Is it even possible? &lt;/p&gt;&#xA;" OwnerUserId="9923" LastActivityDate="2016-02-16T04:40:20.517" Title="Saving byte array in PROGMEM instead of SRAM" Tags="|arduino-uno|ethernet|progmem|sram|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19631" PostTypeId="1" CreationDate="2016-01-16T11:40:26.187" Score="0" ViewCount="100" Body="&lt;p&gt;I have a Arduino Uno and a CC3000 shield. When I run the example code for Webclient from Adafruits libary it works perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I switch out address for reading a corresponding text file from my own server the code completes sporadically. The output in the serial window stops at differens places every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea how I can fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Adafruit points to this URL: &lt;a href=&quot;http://www.adafruit.com/testwifi/index.html&quot; rel=&quot;nofollow&quot;&gt;http://www.adafruit.com/testwifi/index.html&lt;/a&gt;&#xA;While mine points to this URL: &lt;a href=&quot;http://a.sjsd.li/test/test.html&quot; rel=&quot;nofollow&quot;&gt;http://a.sjsd.li/test/test.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16449" LastActivityDate="2016-01-17T12:18:11.743" Title="Adafruit libary and CC3000 shield" Tags="|arduino-uno|wifi|adafruit|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19632" PostTypeId="1" AcceptedAnswerId="19634" CreationDate="2016-01-16T12:06:44.303" Score="3" ViewCount="19715" Body="&lt;p&gt;I want to make a system using NeoPixels, an Arduino and an ESP8266 module to ping IP addresses on my network to determine if certain people are on our Wi-Fi (I'll be pinging mobile phones).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm finding it hard to find any help as to how to ping IP addresses from an Arduino using the ESP8266 module. I did find the &lt;a href=&quot;http://playground.arduino.cc/Code/ICMPPing&quot; rel=&quot;nofollow noreferrer&quot;&gt;ICMP Ping library&lt;/a&gt;, but it uses the Ethernet shield, and I'm quite new to Arduino so I don't even know if I could modify the library in any way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone could help me on my way, that'd be great!&lt;/p&gt;&#xA;" OwnerUserId="16450" LastEditorUserId="6936" LastEditDate="2016-12-10T00:19:34.860" LastActivityDate="2016-12-10T00:23:18.723" Title="Ping IP address using ESP8266 connected to Arduino" Tags="|esp8266|arduino-mini|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19633" PostTypeId="2" ParentId="8331" CreationDate="2016-01-16T13:29:20.623" Score="0" Body="&lt;p&gt;The MFRC522 reader is for 13.56 Mhz tags; these tags normally dont have the UID printed on them, in my experience. 125khz cards, however, usually have their SNs printed on them; as you can see all the cards that didnt work, have a 10 digit SN that seems to follow the same pattern. These card SNs can't be read by the MFRC522, as they follow a different protocol. When you buy a tag/card, make sure that its a 13.56 Mhz tag (look for Mifare tags), if you want the MFRC522 to be able to read it.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-16T13:29:20.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19634" PostTypeId="2" ParentId="19632" CreationDate="2016-01-16T14:11:11.867" Score="2" Body="&lt;p&gt;From what I could find, it seems theres a command for pinging a server. It returns the number of milliseconds taken for the server to respond. The command is: &lt;code&gt;AT+PING=&quot;web site&quot;&lt;/code&gt; or &lt;code&gt;AT+PING=&amp;lt;ip addr&amp;gt;&lt;/code&gt;, from 2 separate sources. You'll have to test them to see which (if not both) is correct.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-16T14:11:11.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19635" PostTypeId="1" AcceptedAnswerId="19638" CreationDate="2016-01-16T14:13:55.050" Score="0" ViewCount="302" Body="&lt;p&gt;I am thinking of working on a project based on a camera module OV7670. I am making a security system using an arduino where detected motion (I am also using a PIR sensor) will trigger the camera module. I wanted to get all kinds of information needed to work with the camera module in this kind of project.&#xA;&lt;br&gt;&lt;br&gt;&#xA;I am not expecting a very long answer rearding everything about the module. The most important points and maybe a few references would be enough. It would also be helpful if programming reference for the camera module is also provided.&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2016-01-16T16:47:17.883" Title="Details on OV7670" Tags="|arduino-uno|programming|sensors|sketch|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19636" PostTypeId="1" AcceptedAnswerId="19637" CreationDate="2016-01-16T14:20:43.660" Score="1" ViewCount="1726" Body="&lt;p&gt;I want to build some small wireless temperature measurement boards, to sprinkle around the house. I'd like to power these from a single coin cell battery (CR2032).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these I'd like to use the DS18B20 sensor. These sensor require a minimal voltage of 3v. A coin cell will however only provide 3v when it's full, and will drop to around 2.6v when 90% discharged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I've read the DS18B20 will give &lt;a href=&quot;http://openenergymonitor.org/emon/node/2303&quot; rel=&quot;nofollow noreferrer&quot;&gt;some strange results&lt;/a&gt; when the supply voltage is below 3v. Also the &lt;a href=&quot;http://openenergymonitor.org/emon/node/2331&quot; rel=&quot;nofollow noreferrer&quot;&gt;precision can be off&lt;/a&gt;, when the supply voltage isn't regulated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The ATMega328p and NRF24L01, I plan to use, will work just fine at voltages down to 2v, so only the DS18B20 requires 3.3v.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I've come up with the following solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use two coin cells, and a (low quiescent current) voltage regulator. (Disadvantage: takes more space, more batteries, slightly more expensive.)&lt;/li&gt;&#xA;&lt;li&gt;Use a boost regulator. (Disadvantage: even more expensive, and a lot more complex (for me at least).)&lt;/li&gt;&#xA;&lt;li&gt;Implement a voltage doubler to power the DS18B20 when needed (every 15 minutes). To regulate the voltage I'd add a 3.3v zener diode to the output. (dirt cheap to implement)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I tend to lean toward option 3, but my question is, could it even work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something to look out for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or is there an even better solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt; I was planning to use the Dickson doubler circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J6gVP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J6gVP.png&quot; alt=&quot;voltage doubler&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-01-16T15:35:13.540" LastActivityDate="2016-01-16T15:35:13.540" Title="Powering 3.3v sensors from a coin cell" Tags="|ds18b20|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19637" PostTypeId="2" ParentId="19636" CreationDate="2016-01-16T14:59:28.837" Score="2" Body="&lt;p&gt;You're missing out option 4, which is the option I would personally go for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a different temperature sensor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A quick parametric search on Microchip (my favourite, I'm a Microchip fanboy after all...) I find quite a nice one - the MCP9844.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Microchip Technology Inc.’s MCP9844 digital temperature sensor converts temperature from -40°C and +125°C to a digital word. This sensor meets JEDEC Specification JC42.4-TSE2004B1 mobile Platform Memory Module Thermal Sensor Component. It provides an accuracy of ±0.2°C/±1°C (typical/maximum) from +75°C to +95°C.   &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Operating Voltage Range (V): +1.7 to +3.6&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt; it is only available as a TDFN which makes prototyping difficult, although it is one of my two preferred footprints for real building - the other being variants of QFN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure you can search other makers for similarly specified chips that will do the job without the need for fancy boosters or doublers or the expense of multiple batteries etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the first steps of any design is the component identification. Often the chip or component that many people automatically reach for because it's the first one they used, or it's the one people most often talk about, may not be the right tool for the job. It pays to shop around a bit and look to see if there is something better that will fit the bill and save cost and time in the long run by ending up with a simpler system.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-16T14:59:28.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19638" PostTypeId="2" ParentId="19635" CreationDate="2016-01-16T15:12:10.810" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.arducam.com/camera-modules/0-3mp-ov7670/&quot; rel=&quot;nofollow&quot;&gt;This post&lt;/a&gt; is a link to a blog that describes the pinout and connections, along with some general information. They also have a link to &lt;a href=&quot;https://github.com/ArduCAM/Arduino/tree/master/ArduCAM&quot; rel=&quot;nofollow&quot;&gt;an &quot;ArduCAM&quot; library&lt;/a&gt; with &lt;a href=&quot;https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV7670_Camera_Playback/ArduCAM_OV7670_Camera_Playback.ino&quot; rel=&quot;nofollow&quot;&gt;an example&lt;/a&gt; utilizing your camera model. &lt;/p&gt;&#xA;" OwnerUserId="15201" LastEditorUserId="15201" LastEditDate="2016-01-16T16:47:17.883" LastActivityDate="2016-01-16T16:47:17.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19639" PostTypeId="1" AcceptedAnswerId="19640" CreationDate="2016-01-16T15:21:27.077" Score="0" ViewCount="2233" Body="&lt;p&gt;Hello I finally got my nokia 5110 lcd working, I have tested it by displaying bitmap images other people have made. I made my own image and then used lcd assistant to turn it into an array. First look at my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;U8glib.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int x = 5;&#xA;int y = 5;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;int level = 5;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;const uint8_t rook_bitmap[] U8G_PROGMEM = {&#xA;0x7E, 0x82, 0x04, 0x8E, 0x7A, 0x42, 0xB4, 0x24, 0x08, 0xD8, 0x48, 0x08, 0x08, 0x0C, 0x02, 0x22,&#xA;0xD9, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1E, 0x11, 0x21, 0x22, 0x14, 0x3B,&#xA;0xD4, 0x25, 0x29, 0x68, 0xA8, 0xA8, 0x74, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&#xA;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,&#xA;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&#xA;};&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void draw(void) {&#xA;  // graphic commands to redraw the complete screen should be placed here&lt;br&gt;&#xA;  u8g.drawBitmapP( 5, 5, 3,18, rook_bitmap);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void setup(void) {&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop(void) {&#xA;  // picture loop&#xA;  u8g.firstPage();&lt;br&gt;&#xA;  do {&#xA;    draw();&#xA;  } while( u8g.nextPage() );&lt;/p&gt;&#xA;&#xA;&lt;p&gt;// y++;&#xA;  // rebuild the picture after some delay&#xA;  delay(1000);&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The part that goes wrong is at u8g.drawBitmapP(5,5,21,18, rook_bitmap);&#xA;I know it is to do with the 21 and 18 being wrong because I don't know where to get those numbers. Is it the width and height of the image when it is in paint.net or what is it?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="16124" LastEditDate="2016-01-16T16:45:34.307" LastActivityDate="2016-01-16T16:54:58.930" Title="Arduino drawing a bitmap on nokia 5110 lcd" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19640" PostTypeId="2" ParentId="19639" CreationDate="2016-01-16T16:03:41.000" Score="0" Body="&lt;p&gt;The 21 and 18 are the dimensions of the image. It's not just pixels though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first number (21) is the number of &lt;em&gt;bytes&lt;/em&gt; in a row of the image - that is one eighth of the width in pixels.  The width &lt;em&gt;must&lt;/em&gt; be a multiple of 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second number is the number of rows in the image - basically the height in pixels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two numbers, when multiplied together, must equal the number of bytes in your array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://code.google.com/p/u8glib/wiki/userreference#drawBitmap&quot; rel=&quot;nofollow&quot;&gt;the documentation:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Draw a bitmap at the specified x/y position (upper left corner of the bitmap). Parts of the bitmap may be outside the display boundaries. The bitmap is specified by the array bitmap. A cleared bit means: Do not draw a pixel. A set bit inside the array means: Write pixel with the current color index. For a monochrome display, the color index 0 will usually clear a pixel and the color index 1 will set a pixel. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;Arguments:&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;u8g : Pointer to the u8g structure (C interface only).&lt;/li&gt;&#xA;  &lt;li&gt;x: X-position (left position of the bitmap).&lt;/li&gt;&#xA;  &lt;li&gt;y: Y-position (upper position of the bitmap).&lt;/li&gt;&#xA;  &lt;li&gt;cnt: Number of bytes of the bitmap in horizontal direction. The width of the bitmap is cnt*8.&lt;/li&gt;&#xA;  &lt;li&gt;h: Height of the bitmap. &lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It would appear your image data is complete gibberish.  This is what I decode it to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ######  #     #  #     &#xA; ###   # # ####  #    # &#xA;  # ## #  #  #     #    &#xA;   ## ##   #  #    #    &#xA;   #      ##     #      &#xA; #   #  #  ## #####     &#xA;&#xA;&#xA;        #        ####   &#xA;#   #   #    #   #   #  &#xA;  # #   ## ###    # # ##&#xA;# #  #  #  # #     # ## &#xA;   # # #   # # #  # ### &#xA;  ##    ##              &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-01-16T16:54:58.930" LastActivityDate="2016-01-16T16:54:58.930" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="19641" PostTypeId="1" CreationDate="2016-01-16T16:25:39.657" Score="2" ViewCount="744" Body="&lt;p&gt;I'm working on a prototype with a Particle Photon, but I've realized the required number of pins is bigger than the number of pins on my photon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I could have an Arduino Uno wired to some sensors, and link the Arduino to the photon via a Software Serial from the Arduino (as its serial pins will already be busy) to the Serial pins of the photon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible, and is there a better way to solve my problem?&lt;/p&gt;&#xA;" OwnerUserId="16230" LastActivityDate="2018-05-08T01:47:17.907" Title="Link Arduino Uno to Particle Photon" Tags="|arduino-uno|serial|softwareserial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19642" PostTypeId="1" AcceptedAnswerId="19643" CreationDate="2016-01-16T16:52:56.753" Score="3" ViewCount="5710" Body="&lt;p&gt;I am reading the value of six potentiometers with a TX Arduino and receiving that data and applying those numbers to a motor using serial. It is working fine through TTL but I am going to need to do this over a 60 ft tether.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done a little research and see that I could use RS 232 but that the maximum you should go with that is 50 ft, which will not work if I'm not mistaken. I have also seen RS 485 which will give us 4000 ft, which is overkill but will work. However, that only offers one-way communication, if I'm not mistaken. What I'm wondering is which protocol should I convert it to, and how I would have to adjust my RX and TX code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Transmitting Code&#xA;  Reads potentiometers and sends them through serial&#xA;*/&#xA;&#xA;int data [10];     // to send bytes&#xA;int start [2];&#xA;int pot0Pin = A0;  // analog pin used to connect the potentiometer&#xA;int pot0;          // variable to read the pot0ue from the analog pin&#xA;int pot1Pin = A1;&#xA;int pot1;&#xA;int pot2Pin = A2;&#xA;int pot2;&#xA;unsigned char checksum0;&#xA;unsigned char checksum1;&#xA;unsigned char checksum2;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;  pinMode(19, INPUT);&#xA;  pinMode(18, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;// READ THE POTENTIOMETERS:&#xA;&#xA;  pot0 = analogRead(pot0Pin);   // reads the value of the potentiometer (pot0ue between 0 and 1023)&#xA;  data[0] = pot0 &amp;amp; 0xFF; //least significant 8 bit byte&#xA;  data[1] = (pot0 &amp;gt;&amp;gt; 8); //most significant 2 bits&#xA;&#xA;  pot1 = analogRead(pot1Pin);&#xA;  data[2] = pot1 &amp;amp; 0xFF;&#xA;  data[3] = (pot1 &amp;gt;&amp;gt; 8);&#xA;&#xA;  pot2 = analogRead(pot2Pin);&#xA;  data[4] = pot2 &amp;amp; 0xFF;&#xA;  data[5] = (pot2 &amp;gt;&amp;gt; 8);&#xA;&#xA;// CREATE CHECKSUMS:&#xA;&#xA;  checksum0 = ~(data[0]+data[1]) + 1;&#xA;&#xA;  checksum1 = ~(data[2]+data[3]) + 1;&#xA;&#xA;  checksum2 = ~(data[2]+data[3]) + 1;&#xA;&#xA;// WRITE VALUES AND CHECKSUMS TO SERIAL:&#xA;&#xA;  Serial1.write(data[0]); &#xA;  Serial1.write(data[1]); &#xA;&#xA;  Serial1.write(data[2]);&#xA;  Serial1.write(data[3]); //bytes sent&#xA;&#xA;  Serial1.write(data[4]);&#xA;  Serial1.write(data[5]);&#xA;&#xA;  Serial1.write(checksum0);&#xA;&#xA;  Serial1.write(checksum1);&#xA;&#xA;  Serial1.write(checksum2); // send the checksum&#xA;&#xA; delay(10);        // delay in between reads for stability&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Receving Code&#xA;  Reads bytes from Transmitting Code and put thems back together&#xA;  Applies the read bytes to our motor control board&#xA;*/&#xA;unsigned char val[10];    // variable to read the value from the analog pin&#xA;int motorVal;&#xA;int coolVal;      // 0-1024 received from serial&#xA;int coolVal1;&#xA;int coolVal2;&#xA;unsigned char checksum1;&#xA;unsigned char checksum2;&#xA;unsigned char checksum3;&#xA;unsigned char checkit1;&#xA;unsigned char checkit2;&#xA;unsigned char checkit3;&#xA;int directionPin = 8;&#xA;int PWM_out_pin = 9; // works on pins 2 - 13 and 44 - 46&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;//  Serial1.begin(9600); &#xA;  pinMode(10, INPUT);&#xA;  pinMode(18, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (Serial1.available()&amp;gt;5) {  &#xA;&#xA;    val[0]=Serial1.read();         // least significant 8 bits&#xA;    val[1]=Serial1.read();         // most significant 2 bits   &#xA;&#xA;    val[2]=Serial1.read();&#xA;    val[3]=Serial1.read();&#xA;&#xA;    val[4]=Serial1.read();&#xA;    val[5]=Serial1.read(); &#xA;&#xA;    checksum1=Serial1.read();&#xA;    checksum2=Serial1.read();&#xA;    checksum3=Serial1.read();// get the checksum last&#xA;&#xA;    checkit1 = val[0]+val[1]+checksum1;&#xA;    checkit2 = val[2]+val[3]+checksum2;&#xA;    checkit3 = val[4]+val[5]+checksum3; &#xA;&#xA;  if (checkit1==0);  {&#xA;    coolVal = val[1]&amp;lt;&amp;lt;8 | val[0]; }&#xA;&#xA;  if (checkit2==0);  {&#xA;    coolVal1 = val[3]&amp;lt;&amp;lt;8 | val[2];}&#xA;&#xA;  if (checkit3==0);  {&#xA;    coolVal2 = val[5]&amp;lt;&amp;lt;8 | val[4];&#xA;    }&#xA;&#xA;    Serial.print(coolVal);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(coolVal1);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(coolVal2);&#xA;    delay(10);&#xA;&#xA;&#xA;  }&#xA;&#xA;&#xA;// FOR MOTOR 1 (more will be added once we achieve successful serial):   &#xA;  if (coolVal &amp;gt; 550) {&#xA;    digitalWrite (directionPin, HIGH);&#xA;    motorVal = map(coolVal, 550, 1023, 0, 1023);&#xA;    analogWrite (PWM_out_pin, motorVal / 4); }&#xA;&#xA;  if ((coolVal &amp;lt; 550) &amp;amp;&amp;amp; (coolVal &amp;gt; 500)) {&#xA;    digitalWrite (directionPin, HIGH);&#xA;    analogWrite (PWM_out_pin, 0); }&#xA;&#xA;  if (coolVal &amp;lt; 500) {&#xA;    digitalWrite (directionPin, LOW);&#xA;    motorVal = map(coolVal, 0, 500, 1023, 0);&#xA;    analogWrite (PWM_out_pin, motorVal / 4); }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16455" LastEditorUserId="10794" LastEditDate="2016-01-16T22:25:58.243" LastActivityDate="2016-01-16T22:25:58.243" Title="Long Distance Communication with Arduino" Tags="|serial|arduino-mega|c++|rs485|rs232|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19643" PostTypeId="2" ParentId="19642" CreationDate="2016-01-16T16:58:20.867" Score="2" Body="&lt;p&gt;You're right that 60' exceeds the spec for RS-232. That said, distance specs are often quite conservative (as they should be, the spec is a promise that it will work and needs to account for marginal components and an unfavorable environment). I think the 50' limit for RS-232 was more observed in the breach than in practice. So for starters I'd be inclined to see if you could get 60' using RS-232 – I'd be kind of surprised if it didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since reliability is important you're doing the right thing by checksumming and checking the data. If the checksum you use is good, it will go a long ways towards letting you detect corrupted data. Then, even if you are using a less than perfect underlying medium (e.g., RS-232 over a long distance), you can improve reliability by ignoring any corrupted values you receive. What that won't protect you from is a major data loss – for example a cut in your cable or a very noisy environment where most of your messages are getting lost. To defend against that you need a mechanism that also acknowledges your transmissions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, at this point you've got a choice – you could keep thinking of what might go wrong and designing solutions, or you could see if you could build on existing work. One thing you might want to look at is using something like the &lt;a href=&quot;https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol&quot; rel=&quot;nofollow&quot;&gt;SLIP&lt;/a&gt; (&lt;strong&gt;S&lt;/strong&gt;erial &lt;strong&gt;L&lt;/strong&gt;ine &lt;strong&gt;IP&lt;/strong&gt;) protocol which was developed to run TCP/IP over a dialup modem back in the dark ages of the Internet. I found, but haven't tried out, a couple of implementations for the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/SerialIP&quot; rel=&quot;nofollow&quot;&gt;SerialIP Library for Arduino&lt;/a&gt; - a &quot;proof of concept&quot; version on the Arduino Playground.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/sepal/Arduino-Serial-SLIP-OSC&quot; rel=&quot;nofollow&quot;&gt;Open Sound Control over SLIP&lt;/a&gt; - newer, but not sure how hard it would be to extract out the SLIP part.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;RS-485 is (can be) bi-directional, you just need a transmitter and receiver at each end. Another approach would be to use a &lt;a href=&quot;http://www.bapihvac.com/content/uploads/2010/07/Understanding-4-20-mA-Current_Loops.pdf&quot; rel=&quot;nofollow&quot;&gt;4-20 mA current loop&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might also want to look into making the controller wireless. That would get you some added convenience (at the expense of a tether to help you find where you put the box) as well as a reliable two-way communication protocol.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-16T18:47:28.147" LastActivityDate="2016-01-16T18:47:28.147" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="19644" PostTypeId="2" ParentId="19641" CreationDate="2016-01-16T17:29:25.510" Score="-1" Body="&lt;p&gt;Everything is possible, it is programming. People are doing software-only USB on AVRs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt that the effort is worth it, given how hard it is to debug such low-level code. Besides you can use on-board UART if you don't need the USB connectivity - just disable it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main question is - where is the main software run, aka &quot;Who's the Brain&quot;? If Photon, maybe you can use SPI? SPI is dead-simple to emulate in software.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-01-16T17:29:25.510" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19646" PostTypeId="1" CreationDate="2016-01-16T20:48:05.403" Score="0" ViewCount="9493" Body="&lt;p&gt;I have a Nokia 5110 screen using u8gliv. I have it displaying an image and I can get it to display text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   u8g.setFont(u8g_font_osb18);&#xA;   u8g.drawStr(0, 20, &quot;PRESS START&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that this font size is way too big. How can I make it smaller? Do I have to use different fonts? If so how do I do that?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="4628" LastEditDate="2016-03-17T14:14:22.040" LastActivityDate="2019-07-11T00:43:51.010" Title="Arduino U8glib: how to display text?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19647" PostTypeId="2" ParentId="19646" CreationDate="2016-01-16T20:58:07.860" Score="2" Body="&lt;p&gt;Just choose a smaller font. You know, I showed you the documentation earlier. You really should read it, because it contains all the information you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, here is the section on the available fonts: &lt;a href=&quot;https://code.google.com/p/u8glib/wiki/fontgroup&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/p/u8glib/wiki/fontgroup&lt;/a&gt; - each section contains a link to download the font group which of course you will need to do before you can use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might find something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;u8g.setFont(u8g_font_fixed_v0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;more to your liking. And don't forget to download it via the link above first.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-16T20:58:07.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19648" PostTypeId="1" AcceptedAnswerId="19649" CreationDate="2016-01-16T21:30:13.823" Score="15" ViewCount="51131" Body="&lt;p&gt;I use the Arduino IDE to upload sketches to my Arduino Uno. My OS is Linux Ubuntu 14.04 LTS. The Arduino IDE has two ports by default for communication with the Arduino Uno: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/dev/ttyACM0&#xA;/dev/ttyS0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the difference between these two ports ? &lt;/li&gt;&#xA;&lt;li&gt;What does &quot;ACM0&quot; and &quot;S0&quot; mean ?&lt;/li&gt;&#xA;&lt;li&gt;Are there configuration files somewhere in the OS folder structure that describe the parameters of these ports ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I know that when I select &lt;code&gt;/dev/ttyACM0&lt;/code&gt;, I am able to send data to my Arduino Uno. However it does not work when I select &lt;code&gt;/dev/ttyS0&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to better understand what these ports are exactly.&lt;/p&gt;&#xA;" OwnerUserId="16459" LastActivityDate="2016-09-26T15:30:35.120" Title="Difference between /dev/ttyACM0 and /dev/ttyS0 (Arduino IDE ports under Linux)" Tags="|arduino-uno|serial|arduino-ide|usb|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19649" PostTypeId="2" ParentId="19648" CreationDate="2016-01-16T21:35:56.693" Score="10" Body="&lt;p&gt;&lt;code&gt;/dev/ttyACM0&lt;/code&gt; is a USB &lt;a href=&quot;https://en.wikipedia.org/wiki/USB_communications_device_class&quot; rel=&quot;noreferrer&quot;&gt;communication device&lt;/a&gt; (CDC) of sub-type &quot;abstract control model&quot; (ACM). That is what the Arduino is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;/dev/ttyS0&lt;/code&gt; is a hardware serial port - the (typically) 9-pin D connector on the back of your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;code&gt;/dev/ttyS0&lt;/code&gt; (why would you?!) you will require a special cable that converts the RS-232 voltage signals from the 9-pin D connector into the right TTL level signals for the Ardiuno and wire it in to the right pins on the board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="26900" LastEditDate="2016-09-26T15:30:35.120" LastActivityDate="2016-09-26T15:30:35.120" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19650" PostTypeId="2" ParentId="16947" CreationDate="2016-01-16T21:38:58.203" Score="2" Body="&lt;p&gt;You can use a struct to send multiple things, like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;const byte SLAVE_ADDRESS = 42;&#xA;&#xA;struct t_message&#xA;{&#xA;  byte pin;&#xA;  byte speed;&#xA;} message;&#xA;&#xA;void setup ()&#xA;{&#xA;  Wire.begin ();   // initialize master&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;  // set desired parameters&#xA;  message.pin = 10;&#xA;  message.speed = 50;&#xA;&#xA;  // send the message&#xA;  Wire.beginTransmission (SLAVE_ADDRESS);  &#xA;  Wire.write ((byte *) &amp;amp;message, sizeof message);&#xA;  Wire.endTransmission ();&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More information about &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C - Two-Wire Peripheral Interface - for Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On that page is mentioned how to &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10896&amp;amp;reply=8#reply8&quot; rel=&quot;nofollow&quot;&gt;Send and receive any data type&lt;/a&gt;. This includes structs. Using the code there you could send a struct, and receive a struct.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-17T02:21:40.280" LastActivityDate="2016-01-17T02:21:40.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19651" PostTypeId="1" CreationDate="2016-01-16T22:22:48.967" Score="0" ViewCount="2322" Body="&lt;p&gt;So i'm trying to use the &lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot; rel=&quot;nofollow&quot;&gt;PubSubClient Library&lt;/a&gt; on my arduino mini pro, but I'm connecting to the internet via wifi using an ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a mini means I have to use software serial to connect to the ESP, but I've ran into a problem. I can't find anywhere such as &lt;code&gt;ESPWiFiClient&lt;/code&gt; to use with the examples from the PubSubClient library where they use &lt;code&gt;EthernetClient&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any available libraries that can emulate EthernetClient with an ESP module over software serial?&lt;/p&gt;&#xA;" OwnerUserId="16450" LastActivityDate="2016-01-19T06:06:02.313" Title="Use ESP8266 as WiFi client connected to Arduino Pro Mini" Tags="|wifi|esp8266|softwareserial|arduino-pro-mini|software|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19652" PostTypeId="2" ParentId="19642" CreationDate="2016-01-16T22:25:43.393" Score="0" Body="&lt;p&gt;You can do two-way communication with RS485. I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about RS485&lt;/a&gt; with schematics and code, including calculating checksums.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to use twisted cable, that would just add to the reliability. You would need 4 cores (power, ground, A and /B) however if the other end was self-powered (ie. a battery) then you could skip that. There has been a bit of debate about whether the ground wire is needed (assuming you don't send power) but it is probably sensible to include it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The page I linked above also describes a rolling master system, where each node has a chance to &quot;talk&quot; to other nodes. This demonstrates that you can send and receive on the same pair of wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my test of the rolling master (using UTP cable) I had it working over 40 meters (ignore the figure on the schematic). So your 50 feet range should be easily achievable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I5ZZa.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I5ZZa.png&quot; alt=&quot;RS485 connection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-16T22:25:43.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19653" PostTypeId="2" ParentId="19631" CreationDate="2016-01-16T23:31:13.767" Score="0" Body="&lt;p&gt;Perhaps the CC3000 isn't waiting long enough for the whole response to come in. Try increasing the variable &lt;code&gt;IDLE_TIMEOUT&lt;/code&gt; in the Web_Client sketch, near the top. Change its value to 10000 and see if you get the whole response this time.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-16T23:31:13.767" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19654" PostTypeId="1" AcceptedAnswerId="21357" CreationDate="2016-01-16T23:38:06.697" Score="1" ViewCount="6515" Body="&lt;p&gt;I have two XBee Pro S2Bs: one is plugged in to a USB explorer, and; the other is plugged into an Arduino Wireless Protoshield, which is connected to an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My XBee connected to the explorer is configured as the &lt;em&gt;coordinator&lt;/em&gt; in AT mode, and the XBee connected to the Arduino is configured as a &lt;em&gt;router&lt;/em&gt; in AT mode. As a side note, I tested the network with a second USB explorer, and I was able to communicate between both XBees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the following code to the Arduino (which is just a sample I pulled off the internet somewhere):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char rx_byte;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (Serial.available() &amp;gt; 0)&#xA;    {&#xA;        rx_byte = Serial.read();&#xA;        Serial.print(&quot;You Typed: &quot;);&#xA;        Serial.println(rx_byte);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I upload the code and turn on the serial monitor for the Arduino (using either the Arduino IDE or Visual Micro, with the Arduino plugged in via USB), and turn on the serial monitor on for the XBee connected to the USB explorer (using the serial monitor in XCTU), I get the following results:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If the wireless proto shield has its switch set to USB mode, then I can send data from the Arduino serial monitor to the serial monitor in XCTU, but the Arduino serial monitor doesn't receive data that is typed into the XCTU serial monitor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the wireless proto shield has its switch set to Micro mode, then I get mostly the opposite result.  I can send data from XCTU serial monitor to the Arduino serial monitor, which the result is returned to the XCTU serial monitor, e.g., if I type &quot;X&quot; in XCTU serial monitor, both serial monitors say &quot;You Typed: X&quot;.  However, if I try to send data through the Arduino's serial monitor, neither serial monitor displays anything.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What I would like to do is be able to type in either serial monitor and have the data displayed in both serial monitors, like you would expect in a simple chat program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone see where I have gone wrong and/or how to get to the correct result?&lt;/p&gt;&#xA;" OwnerUserId="16464" LastEditorUserId="6936" LastEditDate="2016-03-02T21:02:47.510" LastActivityDate="2016-03-15T03:22:04.563" Title="Communication between Arduino and XBee" Tags="|arduino-uno|serial|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19655" PostTypeId="1" CreationDate="2016-01-17T00:34:35.267" Score="1" ViewCount="3497" Body="&lt;p&gt;I have an Arduino Uno connected to an HC-05 Bluetooth sender/receiver chip. I am trying to create a Bluetooth connection between my Acer laptop running under Ubuntu 14.04 LTS and the HC-05 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ubuntu detects the HC-05 chip, as can be seen below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;phodor@ubuntu: hcitool scan&#xA;Scanning ...&#xA;    11:22:33:44:55:66   HC-05&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am able to create a pair between my laptop Bluetooth device and the HC-05 chip. However, I am unable to create a connection with that pair from the Ubuntu interface. The &quot;Connection&quot; button cannot be clicked on, as you can see on the figure below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried creating a connection using the terminal, but after that the terminal still did not detect any connection.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;phodor@ubuntu: sudo hcitool cc 11:22:33:44:55:66&#xA;[sudo] password for phodor: &#xA;phodor@ubuntu: hcitool con&#xA;Connections:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also checked that my computer Bluetooth device was working.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;phodor@ubuntu: hcitool dev&#xA;Devices:&#xA;    hci0    AA:BB:CC:DD:EE:FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea why the connection cannot be created ? Any idea on how to do it using the Ubuntu interface or the terminal ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dCsJp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dCsJp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16459" LastActivityDate="2021-07-09T03:35:39.253" Title="Bluetooth connection to HC-05 paired but not connected (in Linux)" Tags="|bluetooth|ubuntu|hc-05|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19656" PostTypeId="2" ParentId="19509" CreationDate="2016-01-17T00:41:38.763" Score="0" Body="&lt;p&gt;I think this might be a bug in Arturo. This is how I was able to fix my Leonardo:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Fix disappearing &lt;code&gt;/dev/ttyACM0&lt;/code&gt; by pressing reset to temporarily bring it back, then erase all content with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -e&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now /dev/ttyACM0 stays there, but trying to upload my sketch throws a broken pipe error.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Upload a blank sketch using the Arduino IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then I could upload my sketches normally.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-01-17T00:41:38.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19657" PostTypeId="2" ParentId="19509" CreationDate="2016-01-17T03:24:14.120" Score="1" Body="&lt;p&gt;Since your code does not open the serial port, it is entirely expected that the serial port will appear briefly on reset, and then disappear. Initially it appears as the bootloader looks for a new sketch, and disappears because your code does not open Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you time it correctly you should be able to upload a new sketch after pressing Reset. You need to press Reset fairly precisely after the IDE announces that is uploading. You only have a window of a second or so.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-17T03:24:14.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19658" PostTypeId="2" ParentId="19630" CreationDate="2016-01-17T03:53:21.520" Score="2" Body="&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt; for tips about putting stuff into PROGMEM. However personally I wouldn't get too excited about saving 6 bytes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Declare data globally:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte mac [6] PROGMEM = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Get a copy for use into a temporary variable:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  char foo [6];&#xA;  memcpy_P (foo, mac, sizeof foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-17T04:06:11.617" LastActivityDate="2016-01-17T04:06:11.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19660" PostTypeId="1" CreationDate="2016-01-17T09:30:07.237" Score="-1" ViewCount="3445" Body="&lt;p&gt;Hello I am using the u8glib library to draw text on the string but it keeps giving me an error with the string&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt; String name1 = &quot;&quot;;&#xA; ...&#xA; void draw(){&#xA;  u8g.setFont(u8g_font_micro);&#xA;  u8g.drawStr(22, 37, name1);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;why dosnt this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;C:\Program Files (x86)\Arduino\libraries\U8glib/U8glib.h:200:16: note:&#xA;  no known conversion for argument 3 from 'int' to 'const&#xA;  __FlashStringHelper*' no matching function for call to 'U8GLIB_PCD8544::drawStr(int, int, String&amp;amp;)'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="4131" LastEditDate="2016-01-17T18:26:41.317" LastActivityDate="2016-01-17T18:26:41.317" Title="Arduino String problem" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19661" PostTypeId="2" ParentId="19660" CreationDate="2016-01-17T09:41:44.733" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/olikraus/u8glib/wiki/userreference#drawstr&quot; rel=&quot;nofollow&quot;&gt;Like the documentation says&lt;/a&gt;, that method doesn't take a &lt;code&gt;String&lt;/code&gt; object. Call the &lt;code&gt;c_str()&lt;/code&gt; method of the &lt;code&gt;String&lt;/code&gt; object and pass that instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-17T09:41:44.733" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19662" PostTypeId="2" ParentId="19631" CreationDate="2016-01-17T12:18:11.743" Score="1" Body="&lt;p&gt;I have arrived at a solution that works for me. Instead of using Adafruit library I have adopted &lt;a href=&quot;https://github.com/sparkfun/SFE_CC3000_Library&quot; rel=&quot;nofollow&quot;&gt;Sparkfuns library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some adjustments in the setup for the pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CC3000_INT      3   // Needs to be an interrupt pin (D2/D3)&#xA;#define CC3000_EN       5   // Can be any digital pin&#xA;#define CC3000_CS       10  // Preferred is pin 10 on Uno&#xA;#define SD_CS           4   // Chip select for SD card&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then some adjustemnt in the block for the HTTP request:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.print(&quot;GET /index.html HTTP/1.1\r\n&quot;);&#xA;client.print(&quot;Host: &quot;);&#xA;client.print(server);&#xA;client.print(&quot;\r\n\r\n&quot;);&#xA;client.println();&#xA;Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not a solution for the Adafruit libary. But it helped me to continue my project.&lt;/p&gt;&#xA;" OwnerUserId="16449" LastActivityDate="2016-01-17T12:18:11.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19663" PostTypeId="2" ParentId="19660" CreationDate="2016-01-17T12:42:12.413" Score="2" Body="&lt;p&gt;String is evil and should be avoided at all costs (&lt;a href=&quot;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&quot; rel=&quot;nofollow&quot;&gt;http://hacking.majenko.co.uk/the-evils-of-arduino-strings&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The author of u8glib knows that and has refused (quite rightly) to implement them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should not use String either.  If you really &lt;em&gt;must&lt;/em&gt; for some obscure reason then you will have to pass the internal &quot;C string&quot; reference to the &lt;code&gt;drawStr&lt;/code&gt; function instead of the whole String object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;u8g.drawStr(22, 37, name1.c_str());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;only&lt;/em&gt; reason people use String is because they are too lazy to learn the proper way of handling textual data in C.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-17T12:42:12.413" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19665" PostTypeId="1" CreationDate="2016-01-17T15:50:06.293" Score="2" ViewCount="171" Body="&lt;p&gt;i am new to arduino and have no experience with programming&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have an uno r3 board, a wiznet ethernet sheild, and dh22 temp and humidity sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  I would like to have it update plot.ly to view the data.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;error returned on monitor is ...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POST /clientresp HTTP/1.1&#xA;Host: plot.ly:80&#xA;User-Agent: Arduino/0.6.0&#xA;Content-Length: 340&#xA;&#xA;version=2.3&amp;amp;origin=plot&amp;amp;platform=arduino&amp;amp;un=jozef.jones&amp;amp;key=tgcio4brx1&amp;amp;args=[{&quot;y&quot;: [], &quot;x&quot;: [], &quot;type&quot;: &quot;scatter&quot;, &quot;stream&quot;: {&quot;token&quot;: &quot;ke1f6fwqas&quot;, &quot;maxpoints&quot;: 100}}, {&quot;y&quot;: [], &quot;x&quot;: [], &quot;type&quot;: &quot;scatter&quot;, &quot;stream&quot;: {&quot;token&quot;: &quot;k5lmga9qrl&quot;, &quot;maxpoints&quot;: 100}}]&amp;amp;kwargs={&quot;fileopt&quot;: &quot;overwrite&quot;, &quot;filename&quot;: &quot;filename&quot;, &quot;world_readable&quot;: true}&#xA;... Sent message, waiting for plotly's response...&#xA;HTTP/1.1 200 OK&#xA;Content-Type: application/json&#xA;Date: Sun, 17 Jan 2016 16:22:32 GMT&#xA;Server: nginx/1.8.0&#xA;Set-Cookie: csrftoken=WknqVtPqjTYvlTyoKSC5QehqDgmt7Qp7; expires=Tue, 17-Jan-2017 16:22:32 GMT; Max-Age=31622400; Path=/; secure&#xA;Set-Cookie: anoncsrf=2UDFDiQhQq1zf5MIMaoRJ0ayaqs7g58R; expires=Mon, 18-Jan-2016 16:22:32 GMT; httponly; Max-Age=86400; Path=/&#xA;Vary: Accept-Encoding&#xA;Vary: Cookie&#xA;X-Frame-Options: SAMEORIGIN&#xA;Content-Length: 138&#xA;Connection: keep-alive&#xA;&#xA;{&quot;url&quot;: &quot;&quot;, &quot;message&quot;: &quot;&quot;, &quot;warning&quot;: &quot;&quot;, &quot;filename&quot;: &quot;&quot;, &quot;error&quot;: &quot;Missing required POST parameters: platform un key origin args kwargs&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;code is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &quot;plotly_streaming_ethernet.h&quot;&#xA;#include &quot;DHT.h&quot;&#xA;&#xA;&#xA;#define nTraces 2&#xA;&#xA;char *tokens[nTraces] = {&quot;ke1f6fwqas&quot;, &quot;k5lmga9qrl&quot;};&#xA;// arguments: username, api key, streaming token, filename&#xA;plotly graph(&quot;jozef.jones&quot;, &quot;tgcio4brx1&quot;, tokens, &quot;filename&quot;, nTraces);&#xA;&#xA;// DHT Sensor Setup&#xA;#define DHTPIN 2 // We have connected the DHT to Digital Pin 2&#xA;#define DHTTYPE DHT22 // This is the type of DHT Sensor (Change it to DHT11 if you're using that model)&#xA;DHT dht(DHTPIN, DHTTYPE); // Initialize DHT object&#xA;&#xA;byte mac[] = { 0x00, 0xAA, 0xBB, 0x00, 0x00, 0xCC };&#xA;byte my_ip[] = { 192, 168, 1, 117 }; // google will tell you: &quot;public ip address&quot;&#xA;&#xA;void startEthernet(){&#xA;    Serial.println(&quot;... Initializing ethernet&quot;);&#xA;    if(Ethernet.begin(mac) == 0){&#xA;        Serial.println(&quot;... Failed to configure Ethernet using DHCP&quot;);&#xA;        // no point in carrying on, so do nothing forevermore:&#xA;        // try to congifure using IP address instead of DHCP:&#xA;        Ethernet.begin(mac, my_ip);&#xA;    }&#xA;    Serial.println(&quot;... Done initializing ethernet&quot;);&#xA;    delay(1000);&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;  graph.maxpoints = 100;&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  startEthernet();&#xA;&#xA;  bool success;&#xA;  success = graph.init();&#xA;  if(!success){while(true){}}&#xA;  graph.openStream();&#xA;  dht.begin();&#xA;}&#xA;&#xA;float h, t;&#xA;&#xA;void loop() {&#xA;      h = dht.readHumidity();&#xA;      t = dht.readTemperature();&#xA;      graph.plot(millis(), t, tokens[0]);&#xA;      graph.plot(millis(), h, tokens[1]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16475" LastEditorUserId="2881" LastEditDate="2016-01-17T16:36:05.637" LastActivityDate="2016-01-17T16:36:05.637" Title="uno + ethernet sheild(wiznet) + dh22 temp humidity sensor + viewing data online" Tags="|arduino-uno|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19666" PostTypeId="1" CreationDate="2016-01-17T16:40:02.723" Score="2" ViewCount="595" Body="&lt;p&gt;I have been able to establish a successful connection between an RN-42 Bluetooth module and Arduino Uno, but I could not do the same with an Arduino Due. The module connects to the phone but whatever data I send is not registered. What is different on the Due in the context of Bluetooth connectivity? Baud-rate perhaps?&lt;/p&gt;&#xA;" OwnerUserId="13691" LastEditorUserId="10907" LastEditDate="2016-01-18T08:19:39.477" LastActivityDate="2016-01-18T08:19:39.477" Title="Bluetooth help with Arduino Due" Tags="|arduino-uno|bluetooth|arduino-due|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19667" PostTypeId="1" CreationDate="2016-01-17T17:21:15.703" Score="0" ViewCount="879" Body="&lt;p&gt;Greetings dear reader!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some trouble storing my IMEI code inside a variable. It always returns an error: &quot;void value not ignored as it ought to be&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since then I tried to write it to the serial line by just running the &lt;code&gt;gsm.SimpleWriteln(&quot;AT+GSN&quot;);&lt;/code&gt; AT command, but I am stuck at storing this displayed value inside a variable. Does anyone here know a way to store a serial value into a variable? I just want to send the IMEI code as an identifier to the cloud application...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance, your response is really appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SIM900.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;//#include &quot;inetGSM.h&quot;&#xA;//#include &quot;sms.h&quot;&#xA;//#include &quot;call.h&quot;&#xA;&#xA;//To change pins for Software Serial, use the two lines in GSM.cpp.&#xA;&#xA;//GSM Shield for Arduino&#xA;//www.open-electronics.org&#xA;//this code is based on the example of Arduino Labs.&#xA;&#xA;//Simple sketch to communicate with SIM900 through AT commands.&#xA;&#xA;//InetGSM inet;&#xA;//CallGSM call;&#xA;//SMSGSM sms;&#xA;&#xA;int numdata;&#xA;char inSerial[40];&#xA;int i=0;&#xA;boolean startUp = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;GSM Shield testing.&quot;);&#xA;&#xA;  //Start configuration of shield with baudrate.&#xA;  //For http uses it is recommended to use 4800 or slower.&#xA;  if (gsm.begin(9600)) {&#xA;    Serial.println(&quot;\nstatus=READY&quot;);&#xA;    getIMEI();&#xA;  } else Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;};&#xA;&#xA;void loop() {&#xA;  //Read for new byte on serial hardware,&#xA;  //and write them on NewSoftSerial.&#xA;  serialhwread();&#xA;  //Read for new byte on NewSoftSerial.&#xA;  serialswread();&#xA;};&#xA;&#xA;void serialhwread() {&#xA;  i=0;&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    while (Serial.available() &amp;gt; 0) {&#xA;      inSerial[i]=(Serial.read());&#xA;      delay(10);&#xA;      i++;&#xA;    }&#xA;    inSerial[i]='\0';&#xA;    if(!strcmp(inSerial,&quot;/END&quot;)) {&#xA;      Serial.println(&quot;_&quot;);&#xA;      inSerial[0]=0x1a;&#xA;      inSerial[1]='\0';&#xA;      gsm.SimpleWriteln(inSerial);&#xA;    }&#xA;    //Send a saved AT command using serial port.&#xA;    if(!strcmp(inSerial,&quot;TEST&quot;)) {&#xA;      Serial.println(&quot;SIGNAL QUALITY&quot;);&#xA;      gsm.SimpleWriteln(&quot;AT+CSQ&quot;);&#xA;    } else {&#xA;      Serial.println(inSerial);&#xA;      gsm.SimpleWriteln(inSerial);&#xA;    }&#xA;    inSerial[0]='\0';&#xA;  }&#xA;}&#xA;&#xA;void serialswread() {&#xA;  gsm.SimpleRead();&#xA;}&#xA;&#xA;void getIMEI() {&#xA;  long IMEI = gsm.SimpleWriteln(&quot;AT+GSN&quot;); // IMEI code&#xA;  Serial.println(IMEI);&#xA;  return IMEI&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16478" LastEditorUserId="4628" LastEditDate="2018-01-08T17:34:43.353" LastActivityDate="2018-01-08T17:34:43.353" Title="Gboard 800 (SIM900 + ATmega 328)" Tags="|serial|arduino-ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19668" PostTypeId="1" CreationDate="2016-01-17T17:44:17.617" Score="2" ViewCount="40" Body="&lt;p&gt;I've followed tutorials installing arduino drivers for a while, but this is getting in my way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ojXBc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ojXBc.png&quot; alt=&quot;The &amp;quot;Update driver software&amp;quot; button doesn&amp;#39;t show!&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The all-important &quot;Update driver software&quot; button isn't showing? Can anyone explain this and how I can fix it? Many thanks!&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastActivityDate="2016-01-17T18:10:36.070" Title="&quot;Update driver software&quot; not showing. :(" Tags="|windows|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19670" PostTypeId="2" ParentId="19629" CreationDate="2016-01-17T18:00:57.467" Score="1" Body="&lt;p&gt;You can use a special voice recognition shield (for example: &lt;a href=&quot;https://www.sparkfun.com/products/13316&quot; rel=&quot;nofollow&quot;&gt;EasyVR Shield 3.0 - Voice Recognition Shield&lt;/a&gt;) to integrate a simple and basic voice recognition. I think it's a very fast and easy prototyping way...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the use of the more complex Google Speech Recognition I would use a more powerful microcontroller (such as Raspberry PI or something like that)... &lt;/p&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2016-01-17T18:00:57.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19672" PostTypeId="1" AcceptedAnswerId="19678" CreationDate="2016-01-17T18:42:07.357" Score="0" ViewCount="3573" Body="&lt;p&gt;While I was researching ideas for an Arduino clock, I found several clocks that incorporated an RTC (Real Time Clock) module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why it is used in some clocks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How does an RTC module work?&lt;/li&gt;&#xA;&lt;li&gt;Do I have to use it &quot;like a rule&quot; (is an RTC necessary or unnecessary) in my clock?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="15855" LastEditorUserId="10907" LastEditDate="2016-01-17T21:55:12.627" LastActivityDate="2016-01-18T05:05:15.157" Title="Do I have to use an RTC to build a clock?" Tags="|arduino-uno|rtc|oscillator-clock|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19673" PostTypeId="1" AcceptedAnswerId="19674" CreationDate="2016-01-16T21:40:55.640" Score="0" ViewCount="40" Body="&lt;p&gt;İ'm making  a project on my arduino uno when i figured out i had no more GND left to finish the circuit. İs there any other way to optimize, use pins as input maybe. İ tried whit other websites, however, they weren't much of a use. Can you show an example also. &lt;br&gt;&#xA;Thank you sooo much in advance, &lt;br&gt;&#xA;Dario&lt;/p&gt;&#xA;" OwnerDisplayName="Douglas Maron" LastActivityDate="2016-01-17T19:34:22.473" Title="İs there any way different way than GND's Arduino" Tags="|input|arduino-uno|electronics|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19674" PostTypeId="2" ParentId="19673" CreationDate="2016-01-16T22:02:06.387" Score="1" Body="&lt;p&gt;Dario,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are only 3 ground pins on the Arduino Uno, but don't be afraid to &quot;breakout&quot; these pins with wire. It doesn't matter if you connect multiple component grounds together, as long as they are connected to ground with no resistance between them, the circuit will close. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strip board and pin headers will help you here, try this: &lt;a href=&quot;http://www.instructables.com/id/Home-Made-Arduino-Prototype-Shield/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Home-Made-Arduino-Prototype-Shield/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="Mike Armstrong" LastActivityDate="2016-01-16T22:02:06.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19677" PostTypeId="2" ParentId="19667" CreationDate="2016-01-17T19:53:03.957" Score="1" Body="&lt;p&gt;The &lt;code&gt;SimpleWriteln()&lt;/code&gt; function just sends an instruction. It doesn't return anything.  Once you have sent the instruction to retrieve the IMEI you then have to actually &lt;em&gt;read&lt;/em&gt; the IMEI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, fortunately, there is a function that does it for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char imei[20];&#xA;gsm.getIMEI(imei);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The IMEI should now be in the C string &lt;code&gt;imei&lt;/code&gt;. What you do with it then is up to you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-17T19:53:03.957" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19678" PostTypeId="2" ParentId="19672" CreationDate="2016-01-17T19:59:53.140" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How does a RTC module works?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It counts. As simple as that. Once a second it ticks and counts up. It also remembers - most have a battery backup and will continue ticking when you turn the main power off.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have to use it &quot;like a rule&quot; (if it is necessary or unnecesary) in my clock?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want accuracy and continuation, yes.  An RTC is designed to tick at (as close as reasonably possible) once per second. Trying to do that with just an Arduino is incredibly difficult. The ceramic resonator on an Arduino is not as accurate as the quartz crystals used with an RTC. After a week you may find you are an hour out.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-17T19:59:53.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19679" PostTypeId="1" AcceptedAnswerId="19681" CreationDate="2016-01-17T21:12:25.733" Score="0" ViewCount="212" Body="&lt;p&gt;How would iconnect my Arduino Mega to house Mains, without buying a transformer, and having to make a whole setup for that.  Can i just use a regular phone adapter?  Or is 1 Amp too large (or 2 Amps).&lt;/p&gt;&#xA;" OwnerUserId="14716" LastActivityDate="2016-01-17T21:26:40.290" Title="Connecting Arduino To mains" Tags="|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19680" PostTypeId="2" ParentId="19672" CreationDate="2016-01-17T21:19:55.383" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How does a RTC module works?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is a specialized counter. It counts seconds, minutes, hours, days, months and years, properly handling such annoying problems as leap year, different days in months, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally it allows powering with a battery, so that clock ticks even when the device is not powered on, until battery discharges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually RTC is clocked at 32768Hz using standarized quartz crystal.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have to use it &quot;like a rule&quot; (if it is necessary or unnecesary) in my clock?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unless your microcontroller has RTC built-in, you should use an external one. There are many RTCs with I2C interface. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Built-in timer available in Arduino is not accurate enough and cannot tick when you remove power. Inaccurate counter will cause your clock to drift considerably and no backup power forces your clock to be connected all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check out this example to see how to hook up:&#xA;&lt;a href=&quot;https://iobtoolkit.com/docs/tutorials/i2c_terminal_mcp7940n.html&quot; rel=&quot;nofollow&quot;&gt;https://iobtoolkit.com/docs/tutorials/i2c_terminal_mcp7940n.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: i'm the author of IOB, but you don't need to use it. It's just a nice analysis of a rather popular RTC.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-01-17T21:19:55.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19681" PostTypeId="2" ParentId="19679" CreationDate="2016-01-17T21:26:40.290" Score="3" Body="&lt;p&gt;Amps tell you how much current you can draw from the power supply, or &quot;how much it can do&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can hook up 3Amps power supply to a device that draws 1Amp and it will work ok, still having 2 amps of reserve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must pay attention to power supply &lt;strong&gt;voltage&lt;/strong&gt; and keep it in specified range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Mega has recommended input voltage of 7-12V, so you must deliver at least 7V. There are plenty of cheap wall power supplies with voltage regulation from 1.5V to 12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much current it will draw depends on your application, but I doubt that you can suck more than 0,5-1A in a typical application.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-01-17T21:26:40.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19682" PostTypeId="2" ParentId="18755" CreationDate="2016-01-17T21:47:54.647" Score="2" Body="&lt;p&gt;I have the same TX/RX modules and two Arduinos and can get pretty good transmission reliability all throughout my house but it took some experimenting to figure out the largest factors in play (for me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Module pairs should not matter, I got my 5 pairs jumbled up in a plastic bag, think only one was DOA. I use them together with Nexa wireless electric outlets and remotes since they operate on the same frequency and give me a decent reference point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I've noticed about the [receiver] modules is that they tend to auto-adjust to the signal strength. Blast at them with a transmitter at close range for a while and they will become worse at picking out the signs, from the noise at long range for some time. This appears to be true of the 433Mhz Nexa devices too.&#xA;When starting to transmit from further away, it may take longer before the receiver figures out it's found a signal.&#xA;Remember, these modules output only 1 or 0, not an analog signal, so they have to decide which level of noise to accept as 0 and when there is a 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first mistake was not using a well attached antenna. A simple piece of strong wire is good enough in itself, but only if it makes good contact with the module. Good soldering skills always  recommended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second mistake was not giving the transmitter enough power. It can handle 12V, so give it 12V (not on the data pin!). Only go lower after you got it to work at the needed distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try with a large ground plane for both transmitter and receiver (no contact with the device itself!). I got a very good range with my receiver on my computer case and the transmitter on my fridge!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could even get a reliable reading from a temp sensor from inside the garage 10m away from the house when getting about 2m off the ground, using 17cm plain straight wires as antennas with good ground planes. (Monopoles antennas need ground planes to bounce the signal off.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try visualizing the signal on the receiving side with an oscilloscope. If you gave an analog receiver it's probably easier to tell apart noise and real data. But if all you got is the RX module, hooking up the data pin to some kind of logged visualization will at least let you see how difficult it is to spot the data patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try increasing the length of your preamble before the actual data. It'll let the receiver adjust before it gets to the interesting bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat your transmitted data. Include a piece of id data which changes with each message, but not with each repetition, and store the last received id for comparison before relaying it to wherever.&lt;/p&gt;&#xA;" OwnerUserId="703" LastActivityDate="2016-01-17T21:47:54.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19683" PostTypeId="2" ParentId="19672" CreationDate="2016-01-17T21:52:30.820" Score="1" Body="&lt;p&gt;RTC modules are used because they make it easier to keep accurate time. They do this by maintaining time when the system is shut down or rebooted (by way of a battery or some other mechanism for keeping running independently of the host system) and by providing a time base that is, usually, more accurate than that of the host.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way to keep very accurate time (potentially better than you can get with all but the best RTC modules) is to get your time from a GPS or from the Internet using NTP. If you're going to use a GPS anyway or need an Internet connection then either of those approaches are very good ways to go. If you don't, then they are considerably more expensive than an RTC module.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-17T21:52:30.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19685" PostTypeId="1" CreationDate="2016-01-17T21:57:17.233" Score="1" ViewCount="534" Body="&lt;p&gt;I'm trying to figure out how to use an RTC to send interrupts to my arduino. I'm using a DS3232. I can get an 'edge' interrupt, with the following toy code (I know the code is silly, it's just a short example to test if I have actually set the RTC to send the interrupt, and that the Arduino receives it):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*----------------------------------------------------------------------*&#xA; * Minimal example of setting a recurring alarm with the DS3232 RTC     *&#xA; * Attach an LED to pin 7, which will flash when the alarm fires.       *&#xA; *                                                                      * &#xA; * Attach the RTC SQ/INT pin to Uno pin 2, with a 10K pull-up to VCC.   *&#xA; * Ard pin A4 -&amp;gt; RTC SDA, Ard A5 -&amp;gt; RTC SCL, 5v -&amp;gt; vcc, GND -&amp;gt; GND      *&#xA; *----------------------------------------------------------------------*/ &#xA;&#xA;#include &amp;lt;DS3232RTC.h&amp;gt;        //http://github.com/JChristensen/DS3232RTC&#xA;#include &amp;lt;Time.h&amp;gt;             //http://playground.arduino.cc/Code/Time&#xA;#include &amp;lt;Wire.h&amp;gt;             //http://arduino.cc/en/Reference/Wire&#xA;&#xA;#define WAKE_PIN 2&#xA;#define LED_PIN 7&#xA;&#xA;void setup(void)&#xA;{&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;&#xA;    // RTC config:&#xA;    RTC.squareWave(SQWAVE_NONE);&#xA;    pinMode(WAKE_PIN, INPUT_PULLUP);&#xA;    attachInterrupt(INT0, wakeUp, FALLING);&#xA;    RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 1);&#xA;    RTC.alarm(ALARM_2);&#xA;    RTC.alarmInterrupt(ALARM_2, true);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  if(RTC.alarm(ALARM_2)){&#xA;    digitalWrite(LED_PIN, HIGH);&#xA;    delay(5000);&#xA;    digitalWrite(LED_PIN, LOW);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void wakeUp (){&#xA;// no-op, just checking if the interrupt fired&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why doesn't this work if I set the interupt to &quot;LOW&quot;, ie., &lt;code&gt;attachInterrupt(INT0, wakeUp, LOW);&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I ask is I'm trying to use an RTC to wake from low power mode, and I think this &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;doesn't work with a 'falling' interrupt&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3956" LastEditorUserId="10794" LastEditDate="2016-01-18T06:02:01.180" LastActivityDate="2016-01-18T06:02:01.180" Title="Signal a LOW level interrupt with an RTC" Tags="|c++|interrupt|rtc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19686" PostTypeId="1" CreationDate="2016-01-17T21:59:33.983" Score="5" ViewCount="3544" Body="&lt;p&gt;I am trying to make an Arduino circuit as outlined here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TzGoO.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TzGoO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is for connecting an Arduino input to a DCC system. DCC is a command control system for model railways that uses the same two wires for power and data (there's a wikipedia article that explains it better than I can)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering what the optocoupler has more than 4 pins for? I'm new to this and I understand the purpose of the optocoupler but I am confused as to how this particular one works. It is a 6N136 optocoupler. I don't understand why it has the extra pins compared to 4 pin optocouplers, and I don't understand how it would read the polarity of the signal. DCC sends commands using polarity as I understand it, so I know I need to read the polarity, but how does the optocoupler do it here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a very limited knowledge of electronics right now so pardon anything stupid I said :P&lt;/p&gt;&#xA;" OwnerUserId="16484" LastEditorUserId="4143" LastEditDate="2016-01-17T22:22:55.667" LastActivityDate="2018-03-07T15:15:02.573" Title="Optocouplers for Arduino DCC decoder - Explain?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19687" PostTypeId="2" ParentId="19686" CreationDate="2016-01-17T22:22:13.590" Score="3" Body="&lt;p&gt;That specific chip (the 6N137) uses a more efficient IC detector rather than a simple transistor junction.  It also has an &quot;enable&quot; pin that allows it to be turned on or off.  Consequently it needs a power supply to run it. That all means extra pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This design allows for higher speed communication (it's a 10Mbaud chip) with less leakage when compared to a traditional design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin VE (pin 7) needs to be pulled up to make the chip work (the job of R2) and the output is pulled high (it's open drain) by R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The optocoupler will be on with one polarity and off with the other. It's as simple as that. The diode D1 protects the LED in the optocoupler from the reverse voltages.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-17T22:22:13.590" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19688" PostTypeId="1" CreationDate="2016-01-17T22:50:58.083" Score="0" ViewCount="844" Body="&lt;p&gt;I am using the Adafruit TCS34725 to sense color. I have used the Colorview code example to set it up to sense all colors, works great. The thing I want is for it to tell me if it is seeing either green or red, I don't care about the other colors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone suggest what I can do?&lt;/p&gt;&#xA;" OwnerUserId="16439" LastEditorUserId="6936" LastEditDate="2016-04-26T09:17:09.007" LastActivityDate="2016-07-25T10:47:36.807" Title="Use Adafruit Colorsensor to distinguish between green and red" Tags="|adafruit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19689" PostTypeId="1" AcceptedAnswerId="19691" CreationDate="2016-01-17T23:46:11.303" Score="1" ViewCount="7044" Body="&lt;p&gt;I'm printing an &quot;unsigned long&quot; value to HEX via:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;println(cardCode, HEX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value that I'm getting is: 69fb879d&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need it to be reversed as: 9d87fb69&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I populate cardCode via the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (i=1;i&amp;lt;bitCount;i++)&#xA;{&#xA;  cardCode &amp;lt;&amp;lt;=1;&#xA;  cardCode |= databits[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;going into this my bitCount value is 32, so basically I'm populating cardCode based on 32 bits from the variable databits which is of type unsigned char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am absolutely crap at bitwise conversions (bit-shifting, etc.), is there a simple way to do this reversal?  Is this even enough information to go on?&lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-01-19T14:39:32.317" Title="Reverse the order of a hex string" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19690" PostTypeId="2" ParentId="19688" CreationDate="2016-01-18T00:09:31.527" Score="1" Body="&lt;p&gt;Based on what I could find, you will have to calibrate the sensor to recognize these colours. First, run the Colourview code. Take down the raw RGB and CLEAR values obtained for an object you consider green and another you consider red. Find out if these values are consistent, each time you power down the sensor and turn it on again. If they aren't, record how much dead zone there is i.e. the maximum difference in readings (between resets) that you get for the same colour. Then using the values you get, try this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_TCS34725.h&quot;&#xA;&#xA;#define MAX_OFFSET 50  // the maximum diff you found between readings&#xA;&#xA;typedef struct {  // struct to hold raw color data &#xA;   uint16_t red;&#xA;   uint16_t green;&#xA;   uint16_t blue;&#xA;   uint16_t clear;&#xA;} Color;&#xA;&#xA;Color my_red = {3344, 3333, 23444, 3333}; //here you enter your minimum recorded values for red in the order of the struct members above&#xA;Color my_green = {22222, 4444, 5555, 3333}; //the same for green&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Color View Test!&quot;);&#xA;&#xA;  if (tcs.begin()) {&#xA;    Serial.println(&quot;Found sensor&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;No TCS34725 found ... check your connections&quot;);&#xA;    while (1); // halt!&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  uint16_t clear, red, green, blue;&#xA;&#xA;  tcs.setInterrupt(false);      // turn on LED&#xA;&#xA;  delay(60);  // takes 50ms to read &#xA;&#xA;  tcs.getRawData(&amp;amp;red, &amp;amp;green, &amp;amp;blue, &amp;amp;clear);&#xA;&#xA;  tcs.setInterrupt(true);  // turn off LED&#xA;  if (compare_colour(&amp;amp;my_red, red, green, blue, clear)){&#xA;      Serial.println(&quot;I see red.&quot;);&#xA;  }&#xA;  else if (compare_colour(&amp;amp;my_green, red, green, blue, clear)){&#xA;      Serial.println(&quot;I see green.&quot;);&#xA;  }&#xA;}&#xA;&#xA;boolean compare_color(Color * std, uint16_t r, uint16_t g, uint16_t b, uint16_c){&#xA;if ((r - std.red &amp;lt;= MAX_OFFSET) &amp;amp;&amp;amp; (r - std.red &amp;gt;= 0) &amp;amp;&amp;amp;&#xA;      (g - std.green &amp;lt;= MAX_OFFSET) &amp;amp;&amp;amp; (g - std.green &amp;gt;= 0) &amp;amp;&amp;amp;&#xA;      (b - std.blue &amp;lt;= MAX_OFFSET) &amp;amp;&amp;amp; (b - std.blue &amp;gt;= 0) &amp;amp;&amp;amp;&#xA;      (c - std.clear &amp;lt;= MAX_OFFSET) &amp;amp;&amp;amp; (c - std.clear &amp;gt;= 0))&#xA;  {&#xA;      return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this code directly after you have gotten the sensor readings for red and green objects.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-26T21:55:44.430" LastActivityDate="2016-01-26T21:55:44.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19691" PostTypeId="2" ParentId="19689" CreationDate="2016-01-18T00:18:22.243" Score="5" Body="&lt;p&gt;Your issue seems to be byte order (big endian) and not bit order. The simplest solution to byte order swap is to use the &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html&quot; rel=&quot;nofollow&quot;&gt;builtin&lt;/a&gt; functions provided by the compiler (AVR GCC).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long cardCode;&#xA;...&#xA;Serial.print(__builtin_bswap32(cardCode), HEX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are two compiler builtin functions for byte order swap. One for 16-bit data and one for 32-bit data. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t __builtin_bswap16(uint16_t);&#xA;uint32_t __builtin_bswap32(uint32_t);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AVR MCUs are little endian (least significant byte first in memory). There are many devices that use big endian (most significant byte first). This is also known as network order. There are a set of functions/macros to help write portable code, especially device drivers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;arpa/inet.h&amp;gt;&#xA;uint32_t htonl(uint32_t hostlong);&#xA;uint16_t htons(uint16_t hostshort);&#xA;uint32_t ntohl(uint32_t netlong);&#xA;uint16_t ntohs(uint16_t netshort);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These are used to map data from host to network byte order and reverse. They are defined as byte swap functions for hosts with little endian byte order. Unfortunately they are not available in the GCC AVR library but easy to define.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define htonl(x) __builtin_bswap32((uint32_t) (x))&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-19T14:39:32.317" LastActivityDate="2016-01-19T14:39:32.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19692" PostTypeId="2" ParentId="19672" CreationDate="2016-01-18T02:10:36.450" Score="0" Body="&lt;p&gt;For this &quot;rule&quot;, and for many &quot;rules&quot; like this, the answer is &quot;it's more of a guideline&quot; (usually &quot;it's not required, but may be easier that way&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keeping time requires 3 things: an accurate &quot;tick&quot;, a way of knowing the time initially, and counting the time since then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The (16mHz) clock on the Arduino will give you a reasonably accurate &quot;tick&quot; - on the order of 50 parts per million. That means, over a million seconds, your clock will drift about 50 seconds. This works about (ballpark) 1 minute per fortnight. Is this accurate enough? This depends on what you are using it for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next thing on the list is knowing the time initially. If you buy a RTC, it may be set to the right time, or it may not. Even if it is &quot;set&quot;, it may not be set to your timezone. Setting these is pretty easy. It will need to be set every time the clock (be it a RTC or your homebrew clock) loses power. For this reason, RTCs usually have a battery back up. How will your clock get it's time when it starts up? Note that, if your project is network connected, you may be able to get the clock from the internet - this will also mean the drift of your clock will not be an issue - you can retrieve it once per day, so it will never drift more than 4 seconds before it gets corrected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final thing that it needs (and the easiest) is a way of counting the time. This is probably the easiest - use the millis() function. Note that this overflows (resets to 0) after 4294967296 milliseconds - about once every 50 days. Millis() will tell you the number of milliseconds since the Arduino last rebooted. If you want your clock to run more than 50 days, you need to be prepared to that. This will happen part way through a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will give you milliseconds, and, fairly easily, seconds, minutes, hours. If you want the day (of the month), then you need to keep track of which month and year, since the length of each month will vary, as will leap days.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-01-18T02:10:36.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19693" PostTypeId="1" CreationDate="2016-01-18T03:20:06.563" Score="3" ViewCount="451" Body="&lt;p&gt;I'm trying to build a smart thermostat for a particular application. I have the following design criteria and goals for the system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Must be able to set up and monitor the device from either a mobile&#xA;phone or local network device. &lt;/li&gt;&#xA;&lt;li&gt;No go on Ethernet or other hardwired connection, except for initial setup.  This must be a wireless solution. I'm presuming WiFi is best.&lt;/li&gt;&#xA;&lt;li&gt;Needs a clock, an on time and an off time setting. &lt;/li&gt;&#xA;&lt;li&gt;The system does a system time verification check once daily.&lt;/li&gt;&#xA;&lt;li&gt;Needs a temperature input. &lt;/li&gt;&#xA;&lt;li&gt;Needs to run an existing heater system (24v) thru a relay. &lt;/li&gt;&#xA;&lt;li&gt;120v AC power (battery backup not required.)&lt;/li&gt;&#xA;&lt;li&gt;Needs to be &quot;hidden&quot; in existing wall as much as possible.  (i.e. small &amp;amp; compact)  My intent is to hide the unit behind a double wide electrical duplex dead panel. (i.e. 4&quot; x 4&quot; nominal access thru drywall)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's a visual of my design intent package:&lt;a href=&quot;https://i.stack.imgur.com/TxreZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TxreZ.jpg&quot; alt=&quot;Thermostat Design Package&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I review a number of different hardware controller devices, I can see some issues.  I am very familiar with the Intel Edison, and I know exactly how to do this project there, including using the controller as a stand alone web host. (The Edison uses Yocto Linux to create a node.js server using http module.)  I was hoping to save a few $$ on hardware using an alternative controller but not sure that will work.  I've been wading thru the code for both the Photon and generic Arduino devices, and I'm getting the impression that I may need a custom server / api tool for a web page interface.  Its not clear that those hardware choices will support an interactive web page, particularly for easy user data update via browser Submit button.  That's not a big problem, I'm a freelance software developer, handy in C/C++/Java, PHP and JavaScript. And as for the Raspberry Pi, I have no experience but the pricing on some of their boards is below $15.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Has anybody used an Arduino board to host an interactive web page, including user input via Submit / Form ?  (Can I declare a local network static IP address for an Arduino?)&lt;/li&gt;&#xA;&lt;li&gt;Has anybody used an Particle Photon board to host an interactive web page, including user input via Submit / Form? (It looks like declaring a local network static IP address on a Photon is anything but easy...)&lt;/li&gt;&#xA;&lt;li&gt;Has anybody written an API Restful server for their Arduino, with both &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;put&lt;/code&gt; functionality?  (I'm thinking PHP, or node.js makes the most sense for me.)  I know if I have to use Dynamic IP addressing to the controller, that I can always make an API system work for the system.  &lt;/li&gt;&#xA;&lt;li&gt;Other comments?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16491" LastActivityDate="2016-01-18T06:20:54.720" Title="Design Dilema -- What hardware?" Tags="|programming|web-server|edison|raspberrypi|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19694" PostTypeId="1" CreationDate="2016-01-18T03:23:25.157" Score="2" ViewCount="4129" Body="&lt;p&gt;I have two Lidar Lites, connected to one APM. I have no issue with getting data from one of them, i use the code below &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;I2C.h&amp;gt;&#xA;#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.&#xA;#define    RegisterMeasure     0x00          // Register to write to initiate ranging.&#xA;#define    MeasureValue        0x04          // Value to initiate ranging.&#xA;#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.&#xA;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); //Opens serial connection at 9600bps.     &#xA;  I2c.begin(); // Opens &amp;amp; joins the irc bus as master&#xA;  delay(100); // Waits to make sure everything is powered up before    sending or receiving data  &#xA;  I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails&#xA;}&#xA;&#xA;void loop(){&#xA; // Write 0x04 to register 0x00&#xA;  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses     &#xA;  while (nackack != 0){ // While NACK keep going (i.e. continue     polling until sucess message (ACK) is received )&#xA;    nackack = I2c.write(LIDARLite_ADDRESS,RegisterMeasure, MeasureValue); // Write 0x04 to 0x00&#xA;    delay(1); // Wait 1 ms to prevent overpolling&#xA;  }&#xA;&#xA;  byte distanceArray[2]; // array to store distance bytes from read function&#xA;&#xA;  // Read 2byte distance from register 0x8f&#xA;  nackack = 100; // Setup variable to hold ACK/NACK resopnses     &#xA;  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )&#xA;    nackack = I2c.read(LIDARLite_ADDRESS,RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in    array&#xA;   delay(1); // Wait 1 ms to prevent overpolling&#xA;  }&#xA;  int distance = (distanceArray[0] &amp;lt;&amp;lt; 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int&#xA;&#xA;  // Print Distance&#xA;  Serial.println(distance);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i can get the distance fine, now have two connected, as follows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ti90l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ti90l.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my noob question is how to i get data from the 2, my guess is the wiring is ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the code from &lt;a href=&quot;https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;any help would be appreciated. thanks. &lt;/p&gt;&#xA;" OwnerUserId="16420" LastActivityDate="2016-02-05T21:34:58.390" Title="Multiple I2C Devices connected parallel" Tags="|i2c|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19695" PostTypeId="2" ParentId="19694" CreationDate="2016-01-18T04:44:33.777" Score="1" Body="&lt;p&gt;Connect one at a time and run the &lt;a href=&quot;https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library/blob/master/LIDARLite/examples/Single%20Sensor/Change_I2C_Address/Change_I2C_Address.ino&quot; rel=&quot;nofollow&quot;&gt;change address sketch&lt;/a&gt; mentioned by Yeti.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Naturally change each one (one at a time) to different addresses (ex. 0x62, 0x64, 0x66).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;i still don't know whats the address of the 2nd one &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The address is what you change it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then connect them all back up again and run the I2C scanner. You should see all 3 addresses.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;documents state that address changes will be gone when i power it off&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If that is true, save the address for each module in EEPROM. Then use that code to change the module address in &lt;code&gt;setup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See the address in the code you posted?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't want to save the address in EEPROM just upload three versions of the sketch with a different address in each one. Note that the address must be even (eg. 0x62, 0x64, 0x66).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it would be very simple just to read from EEPROM in &lt;code&gt;setup&lt;/code&gt; and keep the address in a variable rather than a #define.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-18T05:08:23.357" LastActivityDate="2016-01-18T05:08:23.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19696" PostTypeId="2" ParentId="19693" CreationDate="2016-01-18T04:52:03.817" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Has anybody used an Arduino board to host an interactive web page, including user input via Submit / Form ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12942&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tiny Web Server&lt;/a&gt; for the Arduino. It is designed to be light-weight on RAM. It supports GET/POST/Cookies for interacting with web forms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yQCT5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yQCT5.png&quot; alt=&quot;Arduino web form&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code and more information on the linked page above.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(Can I declare a local network static IP address for an Arduino?)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Other comments?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could use NRF24L01 modules for short-range communication of wireless information. I have &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12821&quot; rel=&quot;nofollow noreferrer&quot;&gt;example code and schematics&lt;/a&gt;. My tests seemed to indicate 20m range was achievable.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-18T04:52:03.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19697" PostTypeId="2" ParentId="19672" CreationDate="2016-01-18T05:05:15.157" Score="1" Body="&lt;p&gt;I built a clock designed a while ago by Geoff Graham, who &lt;a href=&quot;http://geoffg.net/GPS_Synchronised_Clock.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;synchronized to a GPS&lt;/a&gt; around every 24 hours, and used the internal clock in-between. The GPS corrected for drift in the internal clock (and, of course, gave you the time accurately in the process).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is more expensive than a RTC, but more accurate. If you also had an RTC it would drift less during the day. Or, you could read from the GPS all the time and not have an RTC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11991&quot; rel=&quot;nofollow noreferrer&quot;&gt;GPS clock&lt;/a&gt; myself which does that - just shows the GPS time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aWQyV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aWQyV.jpg&quot; alt=&quot;GPS clock&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Higher-contrast image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NhA5R.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NhA5R.jpg&quot; alt=&quot;GPS clock face&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Internals:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r9MOy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r9MOy.jpg&quot; alt=&quot;Inside GPS clock&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;another project&lt;/a&gt; that uses an RTC clock chip (indicated on photo):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2EZ5o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2EZ5o.png&quot; alt=&quot;Temperature sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you go for just an RTC chip you can expect it to drift over time. They are more accurate than counting processor ticks (and survive a power outage because of the backup battery) but are not as accurate as the GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those clock chips are pretty cheap. I got 30 of them for $10 from eBay.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-18T05:05:15.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19698" PostTypeId="2" ParentId="4380" CreationDate="2016-01-18T05:40:31.947" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Would this affect code inside the main loop that relies on the millis() function since a significant amount of time is spent processing the ISRs?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To put a figure on it for you ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Frequency of the Timer 0 overflow ISR being called&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The code called by the (default) Timer 0 overflow interrupt vector (TIM0_OVF_vect) is used by &lt;code&gt;millis&lt;/code&gt; and &lt;code&gt;micros&lt;/code&gt; to help return their results. Its purpose is to count Timer 0 overflows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get accurate results this ISR must not miss an overflow. The timer is configured to &lt;strong&gt;tick&lt;/strong&gt; every 4 µs on a 16 MHz system (because of the prescaler of 64: &lt;code&gt;64 * 62.5 ns = 4000 ns&lt;/code&gt;) and &lt;strong&gt;overflow&lt;/strong&gt; every 1.024 ms (1024 µs) - because it overflows after 256 ticks ( &lt;code&gt;4 µs * 256 = 1024 µs&lt;/code&gt; ).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there is only one overflow flag, if the ISR misses an overflow then both millis and micros will be out by 1.024 ms (or more, if it misses multiple overflows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be certain of catching that overflow, the ISR therefore has to be called within 1.024 ms (probably slightly less because of the time taken to enter the ISR, so say: 1 ms).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Interrupt priority&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;On the Atmega328P (such as used in the Arduino Uno) these are the interrupt vector priorities:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 1  Reset &#xA; 2  External Interrupt Request 0  (pin D2)          (INT0_vect)&#xA; 3  External Interrupt Request 1  (pin D3)          (INT1_vect)&#xA; 4  Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)&#xA; 5  Pin Change Interrupt Request 1 (pins A0 to A5)  (PCINT1_vect)&#xA; 6  Pin Change Interrupt Request 2 (pins D0 to D7)  (PCINT2_vect)&#xA; 7  Watchdog Time-out Interrupt                     (WDT_vect)&#xA; 8  Timer/Counter2 Compare Match A                  (TIMER2_COMPA_vect)&#xA; 9  Timer/Counter2 Compare Match B                  (TIMER2_COMPB_vect)&#xA;10  Timer/Counter2 Overflow                         (TIMER2_OVF_vect)&#xA;11  Timer/Counter1 Capture Event                    (TIMER1_CAPT_vect)&#xA;12  Timer/Counter1 Compare Match A                  (TIMER1_COMPA_vect)&#xA;13  Timer/Counter1 Compare Match B                  (TIMER1_COMPB_vect)&#xA;14  Timer/Counter1 Overflow                         (TIMER1_OVF_vect)&#xA;15  Timer/Counter0 Compare Match A                  (TIMER0_COMPA_vect)&#xA;16  Timer/Counter0 Compare Match B                  (TIMER0_COMPB_vect)&#xA;17  Timer/Counter0 Overflow                         (TIMER0_OVF_vect)&#xA;18  SPI Serial Transfer Complete                    (SPI_STC_vect)&#xA;19  USART Rx Complete                               (USART_RX_vect)&#xA;20  USART, Data Register Empty                      (USART_UDRE_vect)&#xA;21  USART, Tx Complete                              (USART_TX_vect)&#xA;22  ADC Conversion Complete                         (ADC_vect)&#xA;23  EEPROM Ready                                    (EE_READY_vect)&#xA;24  Analog Comparator                               (ANALOG_COMP_vect)&#xA;25  2-wire Serial Interface  (I2C)                  (TWI_vect)&#xA;26  Store Program Memory Ready                      (SPM_READY_vect)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see from that list that TIMER0_OVF_vect is number 17 on that list, so any earlier priority interrupt would take precedence, for example external interrupts, pin change interrupts, the other timers (however not SPI / Serial / ADC / I2C).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If an overflow had &lt;strong&gt;just happened&lt;/strong&gt; then you would have practically 2 ms of grace (because you have 1 ms before the next and then another 1 ms before you need to notice it). However if the overflow is &lt;strong&gt;about to happen&lt;/strong&gt; then you only have the 1 ms grace period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mention this because if you have an external interrupt 0 event (INT0_vect) and the ISR takes 500 µs, and then external interrupt 1 event (INT1_vect) during that time (so another ISR will be serviced) then the timer interrupt might be blocked for a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is why &lt;strong&gt;all&lt;/strong&gt; ISRs should be short. It isn't good enough that some of them are.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Re-enabling interrupts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I strongly recommend &lt;strong&gt;against&lt;/strong&gt; this. The libraries are not designed to be re-entrant, and once you start enabling interrupts in one ISR you may find that it itself is called again when it is half-way through being called the first time. You may also conceivably interrupt a library function (eg. memcpy) that was not designed for it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, of course, if you are re-enabling interrupts inside an ISR &lt;strong&gt;because&lt;/strong&gt; the ISR takes a long time: well, that is the exact situation when you may trigger this re-entrancy.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;More information:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;Timers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/millis&quot; rel=&quot;nofollow&quot;&gt;Millis overflow&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-18T05:49:53.570" LastActivityDate="2016-01-18T05:49:53.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19699" PostTypeId="2" ParentId="19685" CreationDate="2016-01-18T06:00:16.583" Score="3" Body="&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;That page&lt;/a&gt; is incorrect, although it reflects what the datasheet says.&lt;/p&gt;&#xA;&lt;p&gt;The processor &lt;strong&gt;can&lt;/strong&gt; be woken from RISING/FALLING/CHANGE/LOW. I queried this with Atmel and got this response:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Commented by Manoraj Gnanadhas (Atmel)&lt;/p&gt;&#xA;&lt;p&gt;2015-01-20 06:23:36 GMT&lt;/p&gt;&#xA;&lt;p&gt;[Recipients: Nick Gammon]&lt;/p&gt;&#xA;&lt;p&gt;Hello Nick,&lt;/p&gt;&#xA;&lt;p&gt;Our design team has confirmed that “Note-3 mentioned under Table 10-1” is a datasheet bug. So you can use any type of interrupt (Rising edge/ Falling edge / Low level / Any logical change) to wake up from sleep mode. Sorry for the inconvenience caused.&lt;/p&gt;&#xA;&lt;p&gt;Best Regards,&lt;/p&gt;&#xA;&lt;p&gt;Manoraj Gnanadhas&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is mentioned on &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about interrupts&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Why does LOW hang the processor? The LOW interrupt is not an &lt;strong&gt;edge&lt;/strong&gt; interrupt but a &lt;strong&gt;continuous&lt;/strong&gt; one. Thus, while the signal is LOW the interrupt is being continually called, with only one processor instruction being executed after each call to the ISR (which itself takes around 5.125 µs). So, the ISR is not being interrupted, but effectively only one instruction of your code is being executed every 5.125 µs (probably about 1/40th of the usual speed).&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;and see how much of my problem is due to using an old and buggy IDE&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It's nothing to do with the IDE. Change to a FALLING interrupt and your problems should go away. You may also want to clear the interrupt flag (as documented on my page) in case the interrupt event has already happened before you go to sleep. Specifically:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-18T06:00:16.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19700" PostTypeId="1" AcceptedAnswerId="19733" CreationDate="2016-01-18T06:13:27.410" Score="1" ViewCount="736" Body="&lt;p&gt;I am trying to write a simple software PWM to fade some LEDs because I don't have enough PWM I/O Ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code evaluates how long you want the LED to fade, and breaks it down into a number of steps. During each step, it will evaluate the period the LED should be on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Led{&#xA;  public:&#xA;    Led(int pin);&#xA;    void setup();&#xA;    // void updateFadeDirection();&#xA;    void updateBrightness();&#xA;&#xA;  private:&#xA;    int _pin;&#xA;    unsigned long _currentTime;&#xA;    unsigned long _startTime; // Very beginning of fade period &#xA;    unsigned long _fadePeriod; // How long to fade on and off&#xA;    int _fadeStep; // current fade step i.e. 1/255&#xA;    int _fadeSteps; // How many steps to take until full brightness&#xA;    int _fadeDirection; // low to high or high to low?&#xA;    float _T_on; // Amount of time to turn LED on&#xA;    float _T_fadeStep; // Amount of time per step increment of brightness&#xA;    unsigned long _stepTime; // Start of current step period&#xA;&#xA;    bool _evaluated;&#xA;};&#xA;&#xA;Led::Led(int pin){&#xA;  _pin = pin;&#xA;}&#xA;&#xA;void Led::setup(){&#xA;  pinMode(_pin, OUTPUT);&#xA;  _startTime = micros();&#xA;  _fadePeriod = 2*1000000; //microseconds(us)&#xA;  _fadeStep = 50; // start at 0 brightness here&#xA;  _fadeSteps = 100;&#xA;  _fadeDirection = 1;&#xA;&#xA;  _T_fadeStep = _fadePeriod/_fadeSteps; // i.e. 2000000us/100steps = 20000us/step of brightness&#xA;  _T_on = (_fadeStep/_fadeSteps) * _T_fadeStep; // i.e. 20/100 * 20000us = 4000us on&#xA;&#xA;  _stepTime = micros();&#xA;  delayMicroseconds(200);&#xA;}&#xA;&#xA;void Led::updateBrightness(){&#xA;  _currentTime = micros();&#xA;&#xA;  if(_currentTime - _startTime &amp;lt; _fadePeriod){&#xA;    if (_currentTime - _stepTime &amp;gt; _T_on){&#xA;      digitalWrite(_pin, LOW);&#xA;    } else {&#xA;      digitalWrite(_pin, HIGH);&#xA;    }&#xA;&#xA;    if(_currentTime - _stepTime &amp;gt;= _T_fadeStep){&#xA;      // _fadeStep++;&#xA;      _stepTime = _currentTime;&#xA;      _T_on = (_fadeStep/_fadeSteps) * _T_fadeStep;&#xA;    }&#xA;  }&#xA;  else{&#xA;    digitalWrite(_pin, HIGH);&#xA;  }&#xA;}&#xA;&#xA;Led LED0(0);&#xA;&#xA;void setup() {&#xA;  LED0.setup();&#xA;}&#xA;&#xA;void loop() {&#xA;  LED0.updateBrightness();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The current behaviour when powered on is the single LED will be turned off, then will turn on after 2 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, it never seems to enter the &lt;code&gt;else&lt;/code&gt; part&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (_currentTime - _stepTime &amp;gt; _T_on){&#xA;    digitalWrite(_pin, LOW);&#xA;  } else {&#xA;    digitalWrite(_pin, HIGH);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the LED will never hit &lt;code&gt;HIGH&lt;/code&gt; until the outer &lt;code&gt;else&lt;/code&gt; is triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe it has to do with &lt;code&gt;_T_on&lt;/code&gt; being an &lt;code&gt;int&lt;/code&gt; and the timestamps being &lt;code&gt;unsigned long&lt;/code&gt; and me not casting it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The expected behaviour is 2 seconds of dimmed (50%) light, and then a full 100% when it hits the outer &lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6709" LastActivityDate="2016-01-19T01:25:23.580" Title="Arduino non-blocking software PWM LED fader not working" Tags="|arduino-uno|led|pwm|attiny|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19701" PostTypeId="2" ParentId="19693" CreationDate="2016-01-18T06:20:54.720" Score="2" Body="&lt;p&gt;Have you looked at the &lt;a href=&quot;https://www.adafruit.com/products/2471&quot; rel=&quot;nofollow&quot;&gt;Adafruit Huzzah&lt;/a&gt; boards? It's small, inexpensive ($10), comes with wireless capability and a 10-bit ADC for a temperature sensor. If you'll have access to the Internet, then you could use NTP to get time.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-18T06:20:54.720" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19702" PostTypeId="2" ParentId="19626" CreationDate="2016-01-18T08:16:16.757" Score="1" Body="&lt;p&gt;How did you upload the sketch? With the Bluetooth module still connected? In that case please disconnect it and the upload. Connect again after the upload.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-18T08:16:16.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19703" PostTypeId="2" ParentId="1344" CreationDate="2016-01-18T08:40:37.497" Score="3" Body="&lt;p&gt;You use the Serial.begin(9600) and other Serial functions in your sketch. Therefore the HardwareSerial library is included. Just avoid the Serial stuff in your sketch, it won't work anyway, because the DMX uses the same serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look to&#xA;&quot;Don't use the Arduino Serial implementation&quot;&#xA;in&#xA;&lt;a href=&quot;http://www.mathertel.de/Arduino/DMXSerial.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.mathertel.de/Arduino/DMXSerial.aspx&lt;/a&gt;&#xA;The Four Universes DMX 512 Library works the same way as the DMXSerial library.&lt;/p&gt;&#xA;" OwnerUserId="16495" LastActivityDate="2016-01-18T08:40:37.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19705" PostTypeId="1" AcceptedAnswerId="19710" CreationDate="2016-01-18T12:47:28.617" Score="1" ViewCount="1014" Body="&lt;p&gt;I am doing a project which needs to meet the following specifications.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On receiving an SMS arduino will start switching 1st relay on after some&#xA;  time duration(say 30 Seconds) relay 1 will be turned off and it will now turn on 2nd relay for (say 20seconds) so on 1&gt;2&gt;3&gt;4.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The problem im facing is managing the time intervals between the switching process,i did think of using millis() i.e &lt;strong&gt;(currentMillis-previousMillisx&gt;Intervalx)&lt;/strong&gt; as in blinkWithoutDelay ,how ever this will work only once as i dont not know when will the next SMS come to the system ,if the user decides to send the message after 1hour currentMillis-previousMillisx will always return true so i cannot keep the motor on for (Say 30 seconds) and same will happen with all 4 cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is any alternative logic for this problem please suggest me or can i just add RTC for my project to manage time easily&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You&lt;/p&gt;&#xA;" OwnerUserId="11916" LastActivityDate="2016-01-18T17:00:23.543" Title="Managing timer intervals using millis at random intervals" Tags="|arduino-uno|timers|rtc|millis|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19706" PostTypeId="2" ParentId="19705" CreationDate="2016-01-18T13:07:31.650" Score="-1" Body="&lt;p&gt;You could use timer interrupts. I've (successfully) used the &lt;a href=&quot;https://github.com/PaulStoffregen/TimerOne&quot; rel=&quot;nofollow&quot;&gt;TimerOne&lt;/a&gt; library. There are countless other libraries that allow you to use timer interrupts easily. &quot;Start&quot; the timer when you receive the SMS message. You could use a pair of boolean flags to keep track of the two relays with one timer.&lt;/p&gt;&#xA;" OwnerUserId="15201" LastActivityDate="2016-01-18T13:07:31.650" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19707" PostTypeId="1" CreationDate="2016-01-18T13:46:47.533" Score="0" ViewCount="939" Body="&lt;p&gt;I was wondering if it is possible to send commands through the OBD-II on my car via an Arduino Uno Rev 3 with a CAN-BUS Shield from SEEDStudio. I am just going for basic functions i.e. lock control, window control, lights nothing really outside of those basic functions. My shield is currently in the mail and I was hoping anyone could shed light as to if this is even possible. My car model is a 2004 Mini Cooper S. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="16500" LastActivityDate="2016-03-25T10:40:09.457" Title="Car Control via OBD-II port" Tags="|arduino-uno|can-bus|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19708" PostTypeId="1" CreationDate="2016-01-18T15:47:41.903" Score="1" ViewCount="6241" Body="&lt;p&gt;I have two, three-wire load sensors (&lt;a href=&quot;https://cdn.sparkfun.com//assets/parts/4/5/9/5/10245-01.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cdn.sparkfun.com//assets/parts/4/5/9/5/10245-01.jpg&lt;/a&gt;) hooked up in a half wheatstone bridge (I think), with two 1K resistors.  Using a multimeter, I am reading small voltage changes when applying pressure to either strain gauge, when measured on between the pins A+ and A- on the HX711 ADC amp, however my Arduino serial output shows all 0's when using a variety of code examples (for example, this one:  &lt;a href=&quot;http://www.dfrobot.com/wiki/index.php/Weight_Sensor_Module_V1#Sample_code&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.dfrobot.com/wiki/index.php/Weight_Sensor_Module_V1#Sample_code&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My concern is that my circuit is not setup correctly as I am fairly novice, however everything I have researched about wheatstone bridges, and half wheatstone bridges seems fairly straightforward, and seems to match my circuit.  Any guidance/advice on the attached breadboard circuit diagram would be extremely helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xkkqy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xkkqy.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16503" LastEditorUserId="4143" LastEditDate="2016-01-18T16:20:11.893" LastActivityDate="2016-02-08T15:07:47.447" Title="3-wire strain gauge - HX711 Issue" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19710" PostTypeId="2" ParentId="19705" CreationDate="2016-01-18T16:54:54.810" Score="2" Body="&lt;p&gt;Well, you need a sort of tracking for your active relay, don't you? So you just have to reset that tracking variable and the previousMillis variables and you are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some code (note: untested and moreover I don't know how you are receiving the SMS)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// The intervals for the different relays&#xA;const byte Intervals[] = {30, 20, 10, 5};&#xA;&#xA;// The current state. 0 means relay 1 on, &#xA;// 1 means relay 2 on, 2-&amp;gt;3 and 3-&amp;gt;4, while&#xA;// 4 means no relay activated&#xA;byte currentState = 4;&#xA;&#xA;unsigned long previousMillis;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    if (received_sms)&#xA;    {&#xA;        currentState = 0;&#xA;        previousMillis = millis();&#xA;        digitalWrite(RELAY1, HIGH);&#xA;        // Maybe turn off all the other relays?&#xA;    }&#xA;&#xA;    if (currentState &amp;lt; 4)&#xA;    { // Active state: check if we should advance&#xA;        unsigned long currentInterval = ((unsigned long)Intervals[currentState])*1000;&#xA;        while ((millis() - previousMillis) &amp;gt;= currentInterval)&#xA;        { // Advance to the next step&#xA;            switch(currentState)&#xA;            {&#xA;                case 0: // Advance from state 0 to 1&#xA;                    digitalWrite(RELAY1, LOW);&#xA;                    digitalWrite(RELAY2, HIGH);&#xA;                    // Maybe turn off all the other relays?&#xA;                    previousMillis += currentInterval;&#xA;                    currentState = 1;&#xA;                    break;&#xA;                ...&#xA;                // cases 1, 2, 3&#xA;                ...&#xA;                default:&#xA;                    // It should never reach this&#xA;                    previousMillis = millis();&#xA;                    currentState = 4;&#xA;                    break;&#xA;            }&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-18T16:54:54.810" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19711" PostTypeId="2" ParentId="19705" CreationDate="2016-01-18T17:00:23.543" Score="1" Body="&lt;p&gt;I do not really understand your problem. More specifically,&#xA;“currentMillis-previousMillisx will always return true” does not make&#xA;sense, as it is not a boolean expression (it's &lt;code&gt;unsigned long&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the technique shown in blinkWithoutDelay is the way to go. Here&#xA;is my (untested) version:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int relay_count = 4;  // we have 4 relays&#xA;const int relay_pins[relay_count] = {2, 3, 4, 5};&#xA;const unsigned long durations[relay_count] = {30000, 20000, 15000, 10000};&#xA;bool sms_received();  // you implement this one&#xA;&#xA;void loop()&#xA;{&#xA;    static int current_relay = -1;  // meaning: no active relay&#xA;    static unsigned long last_switch;&#xA;    unsigned long now = millis();&#xA;&#xA;    // If no relay is active, wait for an SMS.&#xA;    if (current_relay == -1) {&#xA;        if (sms_received()) {&#xA;            // Switch on first relay.&#xA;            current_relay = 0;&#xA;            digitalWrite(relay_pins[current_relay], HIGH);&#xA;            last_switch = now;&#xA;        }&#xA;    }&#xA;&#xA;    // Otherwise, switch relays when it is time to do so.&#xA;    else if (now - last_switch &amp;gt;= durations[current_relay]) {&#xA;        digitalWrite(relay_pins[current_relay], LOW);&#xA;        if (++current_relay == relay_count) {&#xA;            current_relay = -1;  // no active relay&#xA;        } else {&#xA;            digitalWrite(relay_pins[current_relay], HIGH);&#xA;            last_switch = now;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;BTW, you did not specify what should happen if you receive an SMS while&#xA;one of the relays is active. I assume the SMS are only acknowledged when&#xA;no relay is active. Otherwise you would have to change the code.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-01-18T17:00:23.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19713" PostTypeId="2" ParentId="19708" CreationDate="2016-01-18T18:28:24.473" Score="2" Body="&lt;p&gt;In your diagram, the fixed 1KΩ resistors both tie to +5V at one set of ends, and their other ends tie to A+ and A-.  The strain gauges are from A+ to ground and A- to ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a typical scale, where several strain gauges are similarly loaded, that topology will produce about zero volts between A+ and A-.  By contrast, the following  topology (from: &lt;a href=&quot;http://blog.l3l4.com/tag/load-cell/&quot; rel=&quot;nofollow noreferrer&quot;&gt;blog.l3l4.com&lt;/a&gt;) produces higher voltages for higher loading.  (Diagram uses S+, S- rather than A+, A-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I realize your question shows some voltage changes when sensors are separately loaded, so this answer might not be relevant to your current problem.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B4mFf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B4mFf.jpg&quot; alt=&quot;Wheatstone bridge on a SparkCore with HX711&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-18T18:28:24.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19714" PostTypeId="1" AcceptedAnswerId="19716" CreationDate="2016-01-18T19:23:35.533" Score="1" ViewCount="9583" Body="&lt;p&gt;In short, I've hooked up an HM-10 to digital pins 10 and 11 on my Uno (required because TX/RX (0/1) can't be used whilst a serial connection is present). The Bluetooth module is a &lt;a href=&quot;http://www.sunfounder.com/index.php?c=show&amp;amp;id=38&amp;amp;model=HM-10&quot; rel=&quot;nofollow&quot;&gt;Sunfounder HM-10&lt;/a&gt; which comes with a &lt;a href=&quot;http://www.sunfounder.com/js/edit/attached/file/Bluetooth4_en.zip&quot; rel=&quot;nofollow&quot;&gt;data sheet&lt;/a&gt;. I'm successfully communicating with the HM-10 and I've written a modified version of serial comms tutorial code provided so it stores the reads up in a buffer before outputting them which works fine, I can set all properties on the HM-10 using this method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The delays were necessary as it seems the clock cycle can't 'keep up' - bytes go missing when reading/writing, so if I attempt to write by just using &lt;code&gt;Serial.read()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt; alone then not all of it is read/written.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  delay(500);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.print(&quot;Wake up wake up wake up wake up wake up! Wake up wake up wake up wake up wake up!&quot;);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (mySerial.available()) {&#xA;    String s = &quot;&quot;;&#xA;    char c;&#xA;    while((c = mySerial.read()) != -1) {&#xA;      s += c;&#xA;      delay(10);&#xA;    }&#xA;&#xA;    Serial.println(&quot;Received: &quot; + s);&#xA;  }&#xA;&#xA;  if (Serial.available()) {&#xA;    String s = &quot;&quot;;&#xA;    char c;&#xA;    while((c = Serial.read()) != -1) {&#xA;      s += c;&#xA;      delay(10);&#xA;    }&#xA;&#xA;    delay(10);&#xA;&#xA;    Serial.println(&quot;Sent: &quot; + s);&#xA;&#xA;    mySerial.print(s);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows me to show input and output as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sent: AT+ADDR?&#xA;Received: OK+ADDR:F4B85EB42D64&#xA;Sent: AT+ADVI?&#xA;Received: OK+Get:0&#xA;Sent: AT+ALLO?&#xA;Received: OK+Get:0&#xA;Sent: AT+BATT?&#xA;Received: OK+Get:077&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So good so far. Here's what I can't figure out from the data sheet. How do I make the bluetooth module discoverable on, say, my Mac or from my iPhone? I've tested setting &lt;code&gt;AT+ROLE0&lt;/code&gt; or &lt;code&gt;AT+ROLE1&lt;/code&gt; followed by &lt;code&gt;AT+RESET&lt;/code&gt; and also set &lt;code&gt;AT+NAME&lt;/code&gt; so I know what to expect, yet I can't discover the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also to note, the status LED is flashing as per the specification as an unconnected status (500ms high, 500ms low) which indicates &lt;code&gt;AT+PIO10&lt;/code&gt; is setup. &lt;code&gt;AT+ADTY?&lt;/code&gt; is set to 0 which allows it to be advertising, responds to scanning and connectable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm likely missing something quite obvious. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="16507" OwnerDisplayName="Kezzer" LastActivityDate="2021-02-02T03:41:07.840" Title="Arduino Uno, HM-10 Bluetooth Module, Not Discoverable" Tags="|bluetooth|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19715" PostTypeId="1" CreationDate="2016-01-18T20:03:21.763" Score="0" ViewCount="3033" Body="&lt;p&gt;I'm using an Arduino Uno to read from a &quot;HID multiCLASS (RP40CKPNN) reader&quot;, which is a stand-alone reader that reads cards and returns a number of bits via Weigand Data0/Data1 protocol.  The &quot;multiCLASS&quot; readers can read both 125HZ PROX tags, and 13.57MHz mifare tags.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it reading and decoding 125HZ (multiple-PROX format) tags of various bit-lengths just fine, but when the reader is presented with a 13MHz card (specifically Mifare cards) the reader decodes the CSR/UID of ALL Mifare cards to 32bits.  The Mifare cards come in two types, Classic (that use a 4byte UID), and Ultra (that use a 7byte UID), so I would expect 32bits for the Classic cards, and 56bits for the Ultra, but I only ever get back 32bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reader's data-sheets specifically calls out that for mifare tags it should return a 32bit or 56bit CSR value based on the serial number of the card, but I've looked through lots of HID literature on this reader, and I can't find any specifics on how to change/modify its configuration. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any experience with these readers, and is there some trick to changing the configuration so that it returns more bits for Mifare cards?&lt;/p&gt;&#xA;" OwnerUserId="16487" LastEditorUserId="16487" LastEditDate="2016-01-18T22:40:06.143" LastActivityDate="2016-03-19T16:50:59.040" Title="HID multiCLASS RFID reader all Mifare to Wiegand 32bit" Tags="|rfid|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19716" PostTypeId="2" ParentId="19714" CreationDate="2016-01-18T20:06:48.933" Score="2" Body="&lt;p&gt;Ah, I jumped the gun. Just found out Mac/iPhone can't scan for BLE devices, so I downloaded a BLE scanning app and once I set AT+ROLE0 and AT+RESET it appeared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the answer is you need a BLE scanning application.&lt;/p&gt;&#xA;" OwnerUserId="16507" LastActivityDate="2016-01-18T20:06:48.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19717" PostTypeId="1" AcceptedAnswerId="19729" CreationDate="2016-01-18T20:51:47.527" Score="0" ViewCount="984" Body="&lt;p&gt;I send a date from my android to arduino without problem, but also i want send date from arduino to android later of received the date from android.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have time trying it, but i can not yet, help me.&#xA;My codec of arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char enter;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial conect(10,11);&#xA;&#xA;void setup()&#xA;{&#xA; pinMode(8,OUTPUT);&#xA; conect.begin(9600);&#xA; digitalWrite(8,LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA; if(conect.available()&amp;gt;0)&#xA;  {&#xA;   enter=conect.read();&#xA;   if(entrada=='1')&#xA;   {&#xA;    digitalWrite(8,HIGH);&#xA;    conect.print(&quot;1&quot;);&#xA;   }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the side from android this is my handler for drive the the date that arrive.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Handler mhandler=new Handler(){&#xA;    @Override&#xA;    public void handleMessage(Message msg)&#xA;    {&#xA;        super.handleMessage(msg);&#xA;        switch (msg.what)&#xA;        {&#xA;            case CONECTADO:&#xA;                //ManejarDatos msjre = new ManejarDatos((BluetoothSocket)msg.obj);&#xA;                msjre = new ManejarDatos((BluetoothSocket)msg.obj);&#xA;                break;&#xA;            case MENSAJELEYENDO:&#xA;                byte[] readBuf = (byte[])msg.obj;&#xA;                String string = new String(readBuf,0,msg.arg1);&#xA;                Toast.makeText(getApplicationContext(), string, Toast.LENGTH_LONG).show();&#xA;                break;&#xA;        }&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on my class for read and write i have this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private class ManejarDatos extends Thread&#xA;{&#xA;    private final OutputStream salidadatos;&#xA;    private final BluetoothSocket sockk;&#xA;    private final InputStream entradadatos;&#xA;    public ManejarDatos(BluetoothSocket socke1)&#xA;    {&#xA;        sockk=socke1;&#xA;        OutputStream temporalsalida=null;&#xA;        InputStream temporalentrada=null;&#xA;        try&#xA;        {&#xA;            temporalentrada=socke1.getInputStream();&#xA;            temporalsalida=socke1.getOutputStream();&#xA;        }catch (IOException e){}&#xA;        salidadatos=temporalsalida;&#xA;        entradadatos=temporalentrada;&#xA;    }&#xA;    public void run()&#xA;    {&#xA;        byte[] espera;&#xA;        int esperaalmacen;&#xA;        while (true) {&#xA;            try {&#xA;                espera=new byte [1024];&#xA;                esperaalmacen=entradadatos.read(espera);&#xA;                mhandler.obtainMessage(MENSAJELEYENDO,esperaalmacen,-1,espera)&#xA;                        .sendToTarget();&#xA;            }catch (IOException e){break;}&#xA;        }&#xA;    }&#xA;    public void escribe(byte[] bytes)&#xA;    {&#xA;        try {&#xA;            salidadatos.write(bytes);&#xA;            //handler.obtainMessage(MENSAJE_SALIDA,-1,-1,bytes).sendToTarget();&#xA;        }catch (IOException e){&#xA;            //Log.e(TAG, &quot;....Error al enviar dato&quot; + e.getMessage() + &quot;...&quot;);&#xA;        }&#xA;    }&#xA;    public void cancel()&#xA;    {&#xA;        try{&#xA;            sockk.close();&#xA;        }catch (IOException e){}&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When i push button, send a date to arduino, here my codec of button(i send 1 for bluetooth)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Enviar.setOnClickListener(new View.OnClickListener() {&#xA;        @Override&#xA;        public void onClick(View v) {&#xA;            String salida=&quot;1&quot;;&#xA;            msjre.escribe(salida.getBytes());&#xA;        }&#xA;    });&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13817" LastActivityDate="2016-01-19T00:27:21.123" Title="Connection bluetooth master and slave with Android" Tags="|arduino-uno|bluetooth|softwareserial|hc-05|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19718" PostTypeId="1" CreationDate="2016-01-18T21:06:02.620" Score="0" ViewCount="1161" Body="&lt;p&gt;I'm trying to use an Arduino Uno to read values from a 2-axis joystick analogue input, and alter these values. Rather than the true joystick values, I arithmetically convert the values at neutral to range between 0 - 5, with 'neutral', i.e. when the joystick isn't being pushed, being at roughly 2.5 for each axis. These joystick values currently output to a live text file, to be graphed in real-time. One function I'm trying to implement is that when the joystick value is greater or less than a defined value (e.g. in the code, greater than 4.55, or less than 0.5)  that the Arduino sets that point to be the new 'neutral' position (i.e. 2.5), however my code at the moment isn't working and I'm not sure how to go about attempting this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight would be most appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 2; &#xA;const int successPin = 13; &#xA;&#xA;int buttonState = 0;&#xA;&#xA;void setup() &#xA;{&#xA;// initialize serial communication at 9600 bits per second:&#xA;Serial.begin(9600);&#xA;pinMode (buttonPin, INPUT);&#xA;pinMode (successPin, OUTPUT);&#xA;while (digitalRead(buttonPin) == LOW) {};&#xA;}&#xA;&#xA;&#xA;void loop () {&#xA;&#xA;int sensorValueY = analogRead(A0);&#xA;int sensorValueX = analogRead(A1);&#xA;&#xA;&#xA;//arithmetic operation that maps output values from 0 - 5 instead of 0 - 1023&#xA;float voltageX = sensorValueX * (5.0 / 1023.0);&#xA;float voltageY = sensorValueY * (5.0 / 1023.0);&#xA;Serial.print(voltageX);&#xA;Serial.print(&quot; , &quot;);&#xA;Serial.print(voltageY);&#xA;&#xA;if (voltageX &amp;gt;= 4.55) {&#xA;  voltageX == 2.5;&#xA;  successPin==HIGH;&#xA;  delay(1);&#xA;  successPin==LOW;&#xA;}&#xA;&#xA;if (voltageX &amp;lt;= 0.5) {&#xA;  voltageX ==2.5;&#xA;  successPin==HIGH;&#xA;  delay(1);&#xA;  successPin==LOW;&#xA;}&#xA;&#xA;if (voltageY &amp;gt;=4.55) {&#xA;  voltageY == 2.5;&#xA;  successPin==HIGH;&#xA;  delay(1);&#xA;  successPin==LOW;&#xA;}&#xA;&#xA;if (voltageY &amp;lt;= 0.5) {&#xA;  voltageY ==2.5;&#xA;  successPin==HIGH;&#xA;  delay(1);&#xA;  successPin==LOW;&#xA;}&#xA;Serial.println();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16508" LastEditorUserId="10794" LastEditDate="2016-01-18T21:46:54.027" LastActivityDate="2016-01-18T22:12:00.593" Title="How to alter joystick values with Arduino Uno?" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19719" PostTypeId="2" ParentId="19616" CreationDate="2016-01-18T21:43:54.763" Score="0" Body="&lt;p&gt;A delay after the &lt;code&gt;powerUp()&lt;/code&gt; made the program work for longer, but it still stalled. More delays after &lt;code&gt;write()&lt;/code&gt; only exacerbated the issue. The only thing that I've done to get this to work is to put the sending code in the watchdog ISR itself. However, this is limited to only around 4 seconds max per sent packet because this is the watchdog's max value, but that's OK for my application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads me to believe that somehow the watchdog is interfering with sending, so possibly disabling it and reenabling after sending could have some effect if anyone else is having this problem.&lt;/p&gt;&#xA;" OwnerUserId="15677" LastActivityDate="2016-01-18T21:43:54.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19720" PostTypeId="2" ParentId="19718" CreationDate="2016-01-18T21:46:39.070" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if (voltageX &amp;gt;= 4.55) {&#xA;  voltageX == 2.5;&#xA;  successPin==HIGH;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last two lines (and all similar ones later) are wrong. &lt;code&gt;==&lt;/code&gt; is for &lt;strong&gt;comparing&lt;/strong&gt;, &lt;code&gt;=&lt;/code&gt; is for &lt;strong&gt;assigning&lt;/strong&gt;. So change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if (voltageX &amp;gt;= 4.55) {&#xA;  voltageX = 2.5;&#xA;  successPin = HIGH;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You did that in a lot of places, so fix that up and get back to us.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const int successPin = 13; &#xA;...&#xA;  successPin = HIGH;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming you fix the compare to an assign you will get an error message here. You define successPin as 13, and then try to change it to 1 (which is what HIGH is defined as). Do you mean, to write to that pin? Like this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite (successPin, HIGH);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need to change all those as well. And if you are hoping to see an LED on the pin flash, 1 ms is quite a small interval.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-18T22:12:00.593" LastActivityDate="2016-01-18T22:12:00.593" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19721" PostTypeId="2" ParentId="18886" CreationDate="2016-01-18T22:13:00.840" Score="0" Body="&lt;p&gt;There are newer long range RFID solutions. You can do a google search on &quot;Ultra Long-Range UHF Wireless RFID Sensors&quot; for more information, but almost all of these systems are still proprietary (i.e. I'm not aware of any hobbyist breakout-boards based around UHF tags yet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Disney MagicBands are an exact use-case of your question: Their magic bands use a combination of 13MHz RFID tags, and a new UHF active tag (it requires a small battery). They use them to collect data on how people flow through their Walt Disney World facility.  What bathrooms see the most activity, and when, for example.  There is actually a pretty decent amount of information available about the technology used in the Disney Magicbands if you're curious about the technology.&lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-01-18T22:13:00.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19722" PostTypeId="2" ParentId="19651" CreationDate="2016-01-18T22:15:45.163" Score="1" Body="&lt;p&gt;Ditch the Pro Mini.  Upload your Arduino code to the ESP directly. There's a GitHub repo with the details. ESP for Arduino IDE has a ton of libraries. I'm sure you'll find it there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you're bent on using the Pro Mini,  you'll have to use AT commands over serial to control it or flash a custom firmware into the ESP using Lua or something. And Pro Mini can use its hardware serial just like a Uno does. &lt;/p&gt;&#xA;" OwnerUserId="16511" LastEditorUserId="10794" LastEditDate="2016-01-19T06:06:02.313" LastActivityDate="2016-01-19T06:06:02.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19723" PostTypeId="2" ParentId="16261" CreationDate="2016-01-18T22:23:47.150" Score="0" Body="&lt;p&gt;There is also an excellent graphic of the various mifare card layouts, that someone has put together: &lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/MiFare_Byte_Layout.png/220px-MiFare_Byte_Layout.png&quot; rel=&quot;nofollow&quot;&gt;https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/MiFare_Byte_Layout.png/220px-MiFare_Byte_Layout.png&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-01-18T22:23:47.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19724" PostTypeId="2" ParentId="19559" CreationDate="2016-01-18T22:26:54.090" Score="0" Body="&lt;p&gt;Have you changed the atmega328 chip? If you have the new one may not have a bootloader or it may have one for a different board. Select every board option. Duemillemova maybe? &#xA;If you still have no luck, you might have over written your bootloader. Try burning the bootloader again. Instructables shows you how. &lt;/p&gt;&#xA;" OwnerUserId="16511" LastActivityDate="2016-01-18T22:26:54.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19725" PostTypeId="1" CreationDate="2016-01-18T22:29:28.917" Score="0" ViewCount="308" Body="&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;EthernetV2_0.h&amp;gt;&#xA;#include &amp;lt;EthernetClientV2_0.h&amp;gt;&#xA;#include &amp;lt;EthernetServerV2_0.h&amp;gt;&#xA;#include &amp;lt;EthernetUdpV2_0.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;#include &amp;lt;Client.h&amp;gt;&#xA;#include &amp;lt;WString.h&amp;gt;&#xA;     #include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;DhcpV2_0.h&amp;gt;&#xA;#include &amp;lt;DnsV2_0.h&amp;gt;&#xA;&#xA;int whiteLevel;&#xA;int colorLevel;&#xA;int blueLevel;&#xA;int standardLightingPattern[3] = { 200, 160, 250 };&#xA;int twilightLightingPattern[3] = { 20, 50, 100 };&#xA;int nightTimeLightingPattern[3] = { 0, 10, 40 };&#xA;int morningLightingPattern[3] = { 50, 50, 100 };&#xA;int deepNightLightingPattern[3] = { 0, 20, 80 };&#xA;int feedingLightingPattern[3] = { 20, 20, 50 };&#xA;int i;&#xA;int j;&#xA;char *buildUrlParameter(float ph, float temp1, float temp2);&#xA;&#xA;// Pin Delcarations&#xA;int temperaturePins[2] = { 30,31 };&#xA;int outletPins[] = { 22, 23, 24, 25, 26, 27 };&#xA;const int whiteLedString = 44;    // connected to LDD-700HW on white strand&#xA;const int colorLedString = 45;    // connected to LDD-1000HW on color strand&#xA;const int blueLedString = 46;     // connected to LDD-1000HW on royal blue     strand&#xA;&#xA;// Sensor Variables&#xA;float temps[2];&#xA;String sensorstring = &quot;&quot;;&#xA;boolean sensor_string_complete = false;&#xA;float pH;&#xA;&#xA;&#xA;// Variables for URL char buffer&#xA;char outBuf[100];&#xA;char charBuf[6];&#xA;char cnctPh[6];&#xA;char cnctTemp1[7];&#xA;char cnctTemp2[7];&#xA;char urlParameter[34];&#xA;char dest1[34];&#xA;&#xA;//char serverIP[] = &quot;74,125,224,80&quot;;&#xA;//char serverIP[] = &quot;192.168.1.107&quot;;&#xA;//char serverIP[] = &quot;www.arduino.cc&quot;;&#xA;&#xA;// assign a MAC address for the ethernet controller.&#xA;// fill in your address here:&#xA;byte mac[] = { &#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};&#xA;// fill in an available IP address on your network here,&#xA;// for manual configuration:&#xA;IPAddress ip(192,168,1,199);&#xA;&#xA;// fill in your Domain Name Server address here:&#xA;IPAddress myDns(8,8,8,8);&#xA;&#xA;// initialize the library instance:&#xA;EthernetClient client;&#xA;&#xA;char server[] = &quot;192.168.1.107&quot;;&#xA;&#xA;unsigned long lastConnectionTime = 0;          // last time you connected to the server, in milliseconds&#xA;boolean lastConnected = false;                 // state of the connection last time through the main loop&#xA;const unsigned long postingInterval = 10*1000;  // delay between updates, in milliseconds&#xA;#define W5200_CS  10&#xA;#define SDCARD_CS 4&#xA;void setup() {&#xA;   // start serial port:&#xA; Serial.begin(38400);&#xA; Serial3.begin(38400);&#xA; pinMode(SDCARD_CS,OUTPUT);&#xA;  digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card&#xA;  // give the ethernet module time to boot up:&#xA;   delay(1000);&#xA;  // start the Ethernet connection using a fixed IP address and DNS server:&#xA;  Ethernet.begin(mac, ip, myDns);&#xA;  // print the Ethernet board/shield's IP address:&#xA;  Serial.print(&quot;My IP address: &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;  char c;&#xA;  dimLights(standardLightingPattern);&#xA;  dimLights(nightTimeLightingPattern);&#xA;&#xA;&#xA;  // if there's no net connection, but there was one last time&#xA;  // through the loop, then stop the client:&#xA;  if (!client.connected() &amp;amp;&amp;amp; lastConnected) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;  }&#xA;  // if you're not connected, and ten seconds have passed since&#xA;  // your last connection, then connect again and send data:&#xA;  if(!client.connected() &amp;amp;&amp;amp; (millis() - lastConnectionTime &amp;gt;    postingInterval)) {&#xA;    getPh();&#xA;    getTemperature();&#xA;    httpRequest();&#xA;  }&#xA;  // store the state of the connection for next time through&#xA;  // the loop:&#xA;  lastConnected = client.connected();&#xA;}&#xA;&#xA;&#xA;void getPh() {&#xA;  Serial3.print(&quot;r&amp;lt;CR&amp;gt;&quot;);&#xA;  if (sensor_string_complete == true) {&#xA;   //Serial.println(sensorstring);&#xA;   if (isdigit(sensorstring[0])) {&#xA;      pH = sensorstring.toFloat();&#xA;    }&#xA;  }&#xA;&#xA; sensorstring = &quot;&quot;;&#xA; sensor_string_complete = false;&#xA;}&#xA;&#xA;void dimLights(int lightingBrightnessArray[]) {&#xA;  analogWrite(whiteLedString, lightingBrightnessArray[0]);&#xA;  analogWrite(colorLedString, lightingBrightnessArray[1]);&#xA;  analogWrite(blueLedString, lightingBrightnessArray[2]);&#xA;&#xA;}&#xA;&#xA;float getTemp(int pin) {&#xA;  OneWire ds(pin);&#xA;  byte k;&#xA;  byte present = 0;&#xA;  byte type_s = 0;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius;&#xA;  float fahrenheit;&#xA;&#xA;  if (!ds.search(addr)) {&#xA;    Serial.println(&quot;No more addresses.&quot;);&#xA;    Serial.println();&#xA;    ds.reset_search();&#xA;    delay(2500);&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;&#xA;  // start conversion, with parasite power on at the end&#xA;  ds.write(0x44, 1);&#xA;&#xA;  // maybe 750ms is enough, maybe not  &#xA;  delay(1000);&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);&#xA;&#xA;  // Read Scratchpad&#xA;  ds.write(0xBE);&#xA;&#xA;  // we need 9 bytes&#xA;  for (k = 0; k &amp;lt; 9; k++) {&#xA;    data[k] = ds.read();&#xA;  }&#xA;&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;&#xA;   // 9 bit resolution default&#xA;   raw = raw &amp;lt;&amp;lt; 3;&#xA;&#xA;   if (data[7] == 0x10) {&#xA;     // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;    } else {&#xA;      byte cfg = (data[4] &amp;amp; 0x60);&#xA;      // at lower res, the low bits are undefined, so let's zero them&#xA;      if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;      else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;      else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;&#xA;     // default is 12 bit resolution, 750 ms conversion time&#xA;    }&#xA;&#xA;    celsius = (float)raw / 16.0;&#xA;    fahrenheit = celsius * 1.8 + 32.0;&#xA;    return fahrenheit;&#xA;}&#xA;&#xA;void getTemperature() {&#xA;&#xA; //get temperature 1 from display&#xA;  temps[0] = getTemp(temperaturePins[0]);&#xA;  delay(1000);&#xA;&#xA;  //get temperature 2 from sump&#xA;  temps[1] = getTemp(temperaturePins[1]);&#xA;  delay(1000);&#xA;&#xA;  //used for building parameters for GET request for passing DB values&#xA;  Serial.println(&quot;&quot;);&#xA;  float temp1 = temps[0];&#xA;  float temp2 = temps[1];&#xA;  //converts pH sensor char buffer to float val&#xA;  //float pH = atof(stamp_data);  &#xA;&#xA;  //used for debugging&#xA;  Serial.println(&quot;Returned Temp 1: &quot;);&#xA;  Serial.println(temp1);&#xA;  Serial.println(&quot;Returned Temp 2: &quot;);&#xA;  Serial.println(temp2);&#xA;  Serial.println(&quot;ph val:&quot;);&#xA;  Serial.println(pH);&#xA;&#xA;  //build url for GET request using above parameters&#xA;  *buildUrlParameter(pH, temp1, temp2);&#xA;  Serial.println(dest1);&#xA;  //make HTTP request&#xA;   httpRequest();&#xA;}&#xA;&#xA;char *buildUrlParameter(float pH, float temp1, float temp2) {&#xA;  //builds char buffer from three float values passed from  &#xA;  //sensors and apends proper sensor monikers&#xA;  dtostrf(pH, 4, 2, cnctPh);&#xA;  dtostrf(temp1, 5, 2, cnctTemp1);&#xA;  dtostrf(temp2, 5, 2, cnctTemp2);&#xA;  strcpy(dest1, &quot;ph=&quot;);&#xA;  strcat(dest1, cnctPh);&#xA;  strcat(dest1, &quot;&amp;amp;T1=&quot;);&#xA;  strcat(dest1, cnctTemp1);&#xA;  strcat(dest1, &quot;&amp;amp;T2=&quot;);&#xA;  strcat(dest1, cnctTemp2);&#xA;&#xA;  return dest1;&#xA;}&#xA;&#xA; // this method makes a HTTP connection to the server:&#xA;   void httpRequest() {&#xA;&#xA;   sprintf(outBuf, &quot;GET http://192.168.1.107/ReefController/trunk/app/php/reef_controller_loadVals_all.php?%s HTTP/1.0&quot;, dest1);&#xA;   Serial.println(outBuf);&#xA;//Serial.println(&quot;connecting...&quot;);&#xA; delay(1000);&#xA;  //client.connect(server, 80);&#xA;&#xA;  // if there's a successful connection:&#xA;  if (client.connect(server, 80)) {&#xA;    client.println(outBuf);&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;    // send the HTTP PUT request:&#xA;    client.println(&quot;Host: localhost&quot;);&#xA;    client.println(&quot;User-Agent: arduino-ethernet&quot;);&#xA;    client.println(&quot;Content Type: application/json&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;&#xA;&#xA;    Serial.println(&quot;Successfully recorded to database&quot;);&#xA;    // note the time that the connection was made:&#xA;    lastConnectionTime = millis();&#xA;  } &#xA;  else {&#xA;    // if you couldn't make a connection:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    Serial.println(&quot;disconnecting.&quot;);&#xA;    client.stop();&#xA;  }&#xA;}`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is happening is when my program hits httpRequest the client.connect is successful maybe 2-3 times out of 5.  The PHP server is up and running fine.  It will just fall into the last else and give me connection failed / disconnecting when it isn't working.... when it does work I get a response back &lt;code&gt;500 internal server error&lt;/code&gt; yet the PHP script runs and records my posted values to the database.  Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="16513" LastEditorUserId="10794" LastEditDate="2016-01-19T06:08:17.380" LastActivityDate="2016-05-18T13:52:11.587" Title="Arduino Ethernet intermittently connects to server" Tags="|arduino-mega|c++|shields|ethernet|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19726" PostTypeId="2" ParentId="19506" CreationDate="2016-01-18T22:38:59.757" Score="0" Body="&lt;p&gt;The pin groups your describe are on different ports of the chip which have different current sourcing ratings. &#xA;I'm sure you'll find an even brightness using similar LEDs on all pins and using a 1K res in series with each led to limit current. &#xA;Also , to ensure the sourcing transistors are ON within the chip, be sure to declare the pins as output when required. &lt;/p&gt;&#xA;" OwnerUserId="16511" LastActivityDate="2016-01-18T22:38:59.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19727" PostTypeId="2" ParentId="19717" CreationDate="2016-01-18T22:56:24.433" Score="0" Body="&lt;p&gt;First try&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if(conect.available()&gt;0)&#xA; { &#xA;enter=conect.read();&#xA;if(1) &#xA;{ digitalWrite(8,HIGH);&#xA; conect.print(&quot;1&quot;); &#xA;}&#xA; }&#xA; }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that works,  think about what entreda is and that exactly you're trying to do there. &lt;/p&gt;&#xA;" OwnerUserId="16511" LastActivityDate="2016-01-18T22:56:24.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19728" PostTypeId="2" ParentId="19506" CreationDate="2016-01-19T00:01:21.793" Score="4" Body="&#xA;&#xA;&lt;p&gt;I tested your code and it does indeed behave the way you said. But that is because you have not declared any pins as output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;analogWrite&lt;/code&gt; does this for you automatically in the library, however &lt;code&gt;digitalWrite&lt;/code&gt; does not. This is because sending a digital pin &lt;code&gt;HIGH&lt;/code&gt; when it is &lt;code&gt;INPUT&lt;/code&gt; turns on the internal pull-up resistors. These are around 50k. Thus you will only see very dim output on the LED. Add this line to &lt;code&gt;setup&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; pinMode (8, OUTPUT); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(And preferably pin 9 as well, just in case you decide to change to digital writes later).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-19T00:01:21.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19729" PostTypeId="2" ParentId="19717" CreationDate="2016-01-19T00:27:21.123" Score="0" Body="&lt;p&gt;What is &lt;code&gt;entrada&lt;/code&gt;? Replace &lt;code&gt;entrada&lt;/code&gt; with &lt;code&gt;enter&lt;/code&gt; in your arduino code and try again. Also try this &lt;code&gt;run()&lt;/code&gt; code instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void run()&#xA;{&#xA;    byte[] espera = new byte[1024];&#xA;    int esperaalmacen;&#xA;    while (true) {&#xA;        try {&#xA;            esperaalmacen=entradadatos.read(espera);&#xA;            mhandler.obtainMessage(MENSAJELEYENDO,esperaalmacen,-1,espera)&#xA;                    .sendToTarget();&#xA;        }catch (IOException e){break;}&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-19T00:27:21.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19730" PostTypeId="1" AcceptedAnswerId="19735" CreationDate="2016-01-19T00:54:15.450" Score="0" ViewCount="3733" Body="&lt;p&gt;I am trying to figure out what I did wrong in my sketch.  In my void loop(), at the very bottom of the sketch, my if/else statement keeps compiling with the above error.  Originally, it was an if/else if/else statement.  I had the current else's an else if and the Update in my else.  Someone had corrected me on it and i removed the code and made the proper changes and the error started. Now, just for the sake of my sanity I went ahead and put the ';' at the end of my else, which I know is wrong, just to see if it compiled, which it did.  I ran the sketch and sure enough it broke the operation. I cannot figure out what it is looking for.  Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //ASHPD Barrel Version 4.0.2 (adding pulse) Created By Gixxerfool 01.11.2016&#xA;&#xA;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#ifdef __AVR__&#xA;  #include &amp;lt;avr/power.h&amp;gt;&#xA;#endif&#xA;&#xA;// Pattern types supported:&#xA;enum  pattern {NONE, CHASE, PULSE};&#xA;&#xA;&#xA;#define orange 255,128,0&#xA;#define blue 0,0,255&#xA;&#xA;char targetColor = '0,0,255';&#xA;&#xA;&#xA;&#xA;// NeoPattern Class&#xA;class NeoPatterns : public Adafruit_NeoPixel&#xA;{&#xA;  public:&#xA;&#xA;    // Member Variables:&#xA;    pattern  ActivePattern;  // which pattern is running&#xA;&#xA;&#xA;    unsigned long Interval;   // milliseconds between updates&#xA;    unsigned long lastUpdate; // last update of position&#xA;&#xA;    uint32_t Color1;  // What color is used&#xA;    uint16_t TotalSteps;  // total number of steps in the pattern&#xA;    uint16_t Index;  // current step within the pattern&#xA;&#xA;   // Constructor&#xA;    NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type)&#xA;    :Adafruit_NeoPixel(pixels, pin, type)&#xA;&#xA;{&#xA;&#xA;}&#xA;    // Update the pattern&#xA;    void Update() &#xA;    {&#xA;      if ((millis() - lastUpdate) &amp;gt; Interval) // time to update&#xA;      {&#xA;        lastUpdate = millis();&#xA;        switch (ActivePattern)&#xA;        {&#xA;          case CHASE:&#xA;            ChaseUpdate();&#xA;            break;&#xA;           // case PULSE:&#xA;            //PulseUpdate();&#xA;            //break;&#xA;          default:&#xA;            break;&#xA;        }&#xA;      }&#xA;    }&#xA;&#xA;    // Increment the Index and reset at the end&#xA;    void Increment()&#xA;    {&#xA;        Index++;&#xA;        if (Index &amp;gt;= TotalSteps)&#xA;        {&#xA;          Index = 0;&#xA;        }&#xA;      }&#xA;&#xA;&#xA;    // Calculate 50% dimmed version of a color (used by ChaseUpdate)&#xA;    uint32_t DimColor(uint32_t color)&#xA;    {&#xA;        // Shift R, G and B components one bit to the right&#xA;        uint32_t dimColor = Color(Red(color) &amp;gt;&amp;gt; 1, Green(color) &amp;gt;&amp;gt; 1, Blue(color) &amp;gt;&amp;gt; 1);&#xA;        return dimColor;&#xA;    }&#xA;    // Returns the Red component of a 32-bit color&#xA;    uint8_t Red(uint32_t color)&#xA;    {&#xA;        return (color &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;    // Returns the Green component of a 32-bit color&#xA;    uint8_t Green(uint32_t color)&#xA;    {&#xA;        return (color &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;    // Returns the Blue component of a 32-bit color&#xA;    uint8_t Blue(uint32_t color)&#xA;    {&#xA;        return color &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;&#xA;    // Initialize for a CHASE&#xA;&#xA;void Chase(uint32_t color1, uint8_t interval)&#xA;    {&#xA;        ActivePattern = CHASE;&#xA;        Interval = interval;&#xA;        TotalSteps = (numPixels());&#xA;        Color1 = color1;&#xA;        Index = 0;&#xA;    }&#xA;&#xA;    // Update the Chase Pattern&#xA;    void ChaseUpdate()&#xA;    { &#xA;        for (int i = 0; i &amp;lt; numPixels() + 1; i++)&#xA;        {&#xA;            if (i == Index)  // Scan Pixel&#xA;            {&#xA;                 setPixelColor(i, Color1);&#xA;            }&#xA;            else // Fading tail&#xA;            {&#xA;                 setPixelColor(i, DimColor(getPixelColor(i)));&#xA;            }&#xA;        }&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;&#xA;&#xA;//Initialize for a pulse&#xA;void Pulse(uint32_t color1, uint8_t interval)&#xA;    {&#xA;      ActivePattern = PULSE;&#xA;      Interval = interval;&#xA;      TotalSteps = 256;&#xA;      Color1 = color1;&#xA;      Index = 0;&#xA;    }&#xA;&#xA;    //Update the Pulse&#xA;    void PulseUpdate()&#xA;   {&#xA;   for (int h = 0; h &amp;lt; 256; h++)&#xA;    {&#xA;    for (int i = 0; i &amp;lt; 126; i++)&#xA;     {&#xA;      for (int j = 0; j &amp;gt; -1; j--)&#xA;      {&#xA;      if (h == Index)&#xA;      {&#xA;      setPixelColor(i, Color1);&#xA;      }&#xA;      else &#xA;      {&#xA;      setPixelColor(j, Color1);&#xA;      }&#xA;    }&#xA;    show();&#xA;    Increment();&#xA;   }&#xA;  }&#xA;}&#xA;&#xA;};&#xA;// Define some NeoPatterns&#xA;&#xA;NeoPatterns Ring3(16, 4, NEO_GRB + NEO_KHZ800);&#xA;NeoPatterns Ring2(12, 1, NEO_GRB + NEO_KHZ800);&#xA;NeoPatterns Ring1(7, 0, NEO_GRB + NEO_KHZ800);&#xA;&#xA;// Initialize everything and prepare to start&#xA;&#xA;void setup()&#xA;{&#xA;  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket&#xA;#if defined (__AVR_ATtiny85__)&#xA;  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;#endif&#xA;  // End of trinket special code&#xA;&#xA;pinMode(2, INPUT); //Sets pin 2 as an input&#xA;&#xA;  // Initialize all the pixels&#xA;&#xA;  Ring1.begin();&#xA;  Ring2.begin();&#xA;  Ring3.begin();&#xA;&#xA;  //Set all pixels to off&#xA;&#xA;  Ring1.show();&#xA;  Ring2.show();&#xA;  Ring3.show();&#xA;&#xA;  ring3Wipe(Ring3.Color(blue), 50); // Wipe ring 3 in blue once&#xA;  ring2Wipe(Ring2.Color(blue), 50); // wipe ring 2 in Blue once&#xA;  ring1FadeUpBlue(Ring1.Color(blue)); //Fade in ring1 once&#xA;&#xA;  //Start the idle pattern &#xA;  //Name.PatternName(Name.Color(targetColor), Interval) Changing Interval will adjust the speed of the pattern&#xA;  Ring1.Pulse(Ring1.Color(blue), 500);&#xA;  Ring2.Chase(Ring2.Color(blue), 55);//keep the interval 15ms above ring3 for synchronicity&#xA;  Ring3.Chase(Ring3.Color(blue), 40);//keep the interval 15ms below ring2 for synchronicity&#xA;&#xA;}&#xA;    void ring1FadeUpBlue(uint8_t wait)&#xA;    {&#xA;   for(int j = 0; j &amp;lt; 255; j++)&#xA;   {&#xA;      uint32_t color = Ring1.Color(0, 0, j );  // ramp up the blue only&#xA;      for(uint16_t i=0; i &amp;lt; Ring1.numPixels(); i++)&#xA;      {&#xA;         Ring1.setPixelColor(i, color);&#xA;      }&#xA;      delay(7);&#xA;      Ring1.show();&#xA;   }&#xA;}&#xA;//wipes the ring2 once in blue&#xA;void ring2Wipe(uint32_t c, uint8_t wait) &#xA;{&#xA;    for(uint16_t i=0; i &amp;lt; Ring2.numPixels(); i++)  //This for loop runs reverse to ring3 loop&#xA;   {&#xA;      Ring2.setPixelColor(i, c);&#xA;      Ring2.show();&#xA;      delay(wait);&#xA;   }&#xA;}&#xA;&#xA;&#xA;//wipes the ring3 once for the color blue   &#xA;void ring3Wipe(uint32_t c, uint8_t wait) &#xA;{ //uint32_t and uint8_t are the colorWipe parameters c=color wait=#of ms between pixels. larger # slows the action&#xA;    for(uint16_t i=0; i &amp;lt; Ring3.numPixels(); i++)&#xA;   {&#xA;      Ring3.setPixelColor(i, c);&#xA;      Ring3.show();&#xA;      delay(wait);&#xA;   } &#xA;}&#xA;&#xA;&#xA;// Main loop&#xA;void loop()&#xA;{&#xA;  // Update the rings.&#xA;  Ring1.Update();&#xA;  Ring2.Update();&#xA;  Ring3.Update();&#xA;&#xA;&#xA;  // check for button press:&#xA;  if (digitalRead(2) == LOW) // Button is pressed&#xA;  {&#xA;    Ring3.Color1 = Ring3.Color(orange);//Change the target color to orange&#xA;    Ring2.Color1 = Ring2.Color(orange);&#xA;    Ring1.Color1 = Ring1.Color(orange);&#xA;  }&#xA;  else (digitalRead(2) == HIGH)//Kicks the color back to blue after the button is let go&#xA;  {&#xA;    Ring3.Color1 = Ring3.Color(blue);//Change the target color back to blue&#xA;    Ring2.Color1 = Ring2.Color(blue);&#xA;    Ring1.Color1 = Ring1.Color(blue); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16021" LastActivityDate="2016-01-19T01:34:05.137" Title="expected ';' before '{' token error" Tags="|programming|arduino-ide|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19732" PostTypeId="2" ParentId="4307" CreationDate="2016-01-19T01:18:44.963" Score="1" Body="&lt;p&gt;That function is part of legacy code. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;NOTE: This solution (formerly known as &quot;Arduino IO Package&quot;) is no&#xA;  longer supported. It is recommended that you use Arduino support&#xA;  packages that are developed and supported by MathWorks:&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;MATLAB Support Package for Arduino Hardware: Read, write, and analyze data from Arduino sensors &#xA;  &lt;a href=&quot;http://www.mathworks.com/hardware-support/arduino-matlab.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.mathworks.com/hardware-support/arduino-matlab.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Simulink Support Package for Arduino Hardware: Develop algorithms that run standalone on your Arduino &#xA;  &lt;a href=&quot;http://www.mathworks.com/hardware-support/arduino-simulink.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.mathworks.com/hardware-support/arduino-simulink.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Use this legacy support only if one of the following is true: &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;- You are using MATLAB R2013b or earlier (but not earlier than R2011a).&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are using 2014a, so its probably the reason &lt;code&gt;analogRead&lt;/code&gt; isn't working. Get the more recent package and use this function instead:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tRM9A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tRM9A.png&quot; alt=&quot;MATLAB + Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-01-19T01:32:47.067" LastActivityDate="2016-01-19T01:32:47.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19733" PostTypeId="2" ParentId="19700" CreationDate="2016-01-19T01:25:23.580" Score="1" Body="&lt;p&gt;As @ott-- has mentioned, because of the &lt;code&gt;int&lt;/code&gt; datatype, &lt;code&gt;_fadeStep&lt;/code&gt;/&lt;code&gt;_fadeSteps&lt;/code&gt; will always evaluate to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the updated code along with some timing tweaks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float fadeSteps = 150; // How many steps to take until full brightness&#xA;&#xA;class Led{&#xA;  public:&#xA;    Led(int pin, float fadeStep=0);&#xA;    void setup();&#xA;    // void updateFadeDirection();&#xA;    void updateBrightness();&#xA;&#xA;  private:&#xA;    int _pin;&#xA;    unsigned long _currentTime;&#xA;    unsigned long _startTime; // Very beginning of fade period &#xA;    unsigned long _fadePeriod; // How long to fade on and off&#xA;    float _fadeStep; // current fade step i.e. 1/255&#xA;    int _fadeDirection; // low to high or high to low?&#xA;    unsigned long _T_on; // Amount of time to turn LED on&#xA;    unsigned long _T_fadeStep; // Amount of time per step increment of brightness&#xA;    unsigned long _stepTime; // Start of current step period&#xA;&#xA;    bool _evaluated;&#xA;};&#xA;&#xA;Led::Led(int pin, float fadeStep){&#xA;  _pin = pin;&#xA;  _fadeStep = fadeStep;&#xA;}&#xA;&#xA;void Led::setup(){&#xA;  pinMode(_pin, OUTPUT);&#xA;  _startTime = micros();&#xA;  _fadePeriod = 2000000; //microseconds(us)&#xA;  _fadeDirection = 1;&#xA;&#xA;  _T_fadeStep = _fadePeriod/2/fadeSteps; // i.e. 2000000us/100steps = 20000us/step of brightness&#xA;  _T_on = (_fadeStep/fadeSteps) * _T_fadeStep; // i.e. 20/100 * 20000us = 4000us on&#xA;&#xA;  _stepTime = micros();&#xA;}&#xA;&#xA;void Led::updateBrightness(){&#xA;  _currentTime = micros();&#xA;  if (_currentTime - _stepTime &amp;gt; _T_on){&#xA;    digitalWrite(_pin, LOW);&#xA;  } else {&#xA;    digitalWrite(_pin, HIGH);&#xA;  }&#xA;&#xA;  if(_currentTime - _stepTime &amp;gt;= _T_fadeStep){&#xA;    _fadeStep += _fadeDirection;&#xA;    _stepTime = _currentTime;&#xA;    _T_on = (_fadeStep/fadeSteps) * _T_fadeStep;&#xA;  }&#xA;&#xA;  if(_fadeStep &amp;gt;= fadeSteps-1) {&#xA;    _fadeDirection = -1;&#xA;  } else if(_fadeStep &amp;lt;= 1) {&#xA;    _fadeDirection = 1;&#xA;  }&#xA;}&#xA;&#xA;Led LED0(0);&#xA;Led LED1(1,fadeSteps/5);&#xA;Led LED2(2,2*fadeSteps/5);&#xA;Led LED3(3,3*fadeSteps/5);&#xA;Led LED4(4,4*fadeSteps/5);&#xA;&#xA;void setup() {&#xA;  LED0.setup();&#xA;  LED1.setup();&#xA;  LED2.setup();&#xA;  LED3.setup();&#xA;  LED4.setup();&#xA;}&#xA;&#xA;void loop() {&#xA;  LED0.updateBrightness();&#xA;  LED1.updateBrightness();&#xA;  LED2.updateBrightness();&#xA;  LED3.updateBrightness();&#xA;  LED4.updateBrightness();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some refactoring is needed to be more modular, but will fade (using software PWM) LEDs asynchronously on every digital OUT port on an attiny85. Can also set the starting brightness so that you can make an LED fading chaser.&lt;/p&gt;&#xA;" OwnerUserId="6709" LastActivityDate="2016-01-19T01:25:23.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19734" PostTypeId="2" ParentId="19730" CreationDate="2016-01-19T01:33:11.630" Score="0" Body="&lt;p&gt;This makes no sense - you can't store 7 characters in the space of one character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char targetColor = '0,0,255';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You're lacking an &quot;if&quot; here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;} else (digitalRead(2) == HIGH) { //Kicks the color back to blue ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You have numerous sign mismatches in comparisons.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-19T01:33:11.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19735" PostTypeId="2" ParentId="19730" CreationDate="2016-01-19T01:34:05.137" Score="1" Body="&lt;p&gt;The if-else construct is incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It needs to be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) &#xA;{ &#xA;    //actions&#xA;} else {&#xA;    //other actions&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which reads: if the conditions are true, then do actions, otherwise do other actions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR it can be like like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (condition) &#xA;{ &#xA;    //actions&#xA;} else {&#xA;    if (other condition){&#xA;    //other actions&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which reads: if conditions are true, then do actions, otherwise, if other conditions are true, then do other actions.  Note that in this structure, if neither conditions or &quot;other conditions&quot; are true, then we do nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if DigitalRead can &lt;strong&gt;only&lt;/strong&gt; be HIGH or LOW, then you don't need condition that in the &quot;else&quot; statement.  Your code can look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // check for button press:&#xA;  if (digitalRead(2) == LOW) // Button is pressed&#xA;  {&#xA;    Ring3.Color1 = Ring3.Color(orange);//Change the target color to orange&#xA;    Ring2.Color1 = Ring2.Color(orange);&#xA;    Ring1.Color1 = Ring1.Color(orange);&#xA;  }&#xA;  else &#xA;  {&#xA;    // digitalRead(2) must be HIGH if it's not LOW&#xA;    //Kicks the color back to blue after the button is let go&#xA;    Ring3.Color1 = Ring3.Color(blue);//Change the target color back to blue&#xA;    Ring2.Color1 = Ring2.Color(blue);&#xA;    Ring1.Color1 = Ring1.Color(blue); &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Only if digitalRead could return another value (e.g. 3, 100, 75 etc) then you would need the other conditions in your else clause, but the code would need to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // check for button press:&#xA;  if (digitalRead(2) == LOW) // Button is pressed&#xA;  {&#xA;    Ring3.Color1 = Ring3.Color(orange);//Change the target color to orange&#xA;    Ring2.Color1 = Ring2.Color(orange);&#xA;    Ring1.Color1 = Ring1.Color(orange);&#xA;  }&#xA;  else &#xA;  {&#xA;    if (digitalRead(2) == HIGH)//Kicks the color back to blue after the button is let go&#xA;    {&#xA;      Ring3.Color1 = Ring3.Color(blue);//Change the target color back to blue&#xA;      Ring2.Color1 = Ring2.Color(blue);&#xA;      Ring1.Color1 = Ring1.Color(blue); &#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: you don't actually need the braces around the second &quot;if&quot; statement there, but it makes the structure more clear.&lt;/p&gt;&#xA;" OwnerUserId="11580" LastActivityDate="2016-01-19T01:34:05.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19736" PostTypeId="1" CreationDate="2016-01-19T02:28:44.533" Score="1" ViewCount="627" Body="&lt;p&gt;Can you help me with the codes? I have gizduino(arduino clone), i used the codes in receiving sms from the internet but what i receive is a symbol &quot;y&quot; with two dots at the top. Whats wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My gsm is set to suart. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Example 55.4&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial SIM900(2,3);&#xA;&#xA;char incoming_char=0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(19200); // for serial monitor&#xA;  SIM900.begin(19200); // for GSM shield&#xA;  SIM900power();  // turn on shield&#xA;  delay(20000);  // give time to log on to network.&#xA;&#xA;  SIM900.print(&quot;AT+CMGF=1\r&quot;);  // set SMS mode to text&#xA;  delay(100);&#xA;  SIM900.print(&quot;AT+CNMI=2,2,0,0,0\r&quot;); &#xA;  // blurt out contents of new SMS upon receipt to the GSM shield's serial out&#xA;  delay(100);&#xA;}&#xA;&#xA;void SIM900power()&#xA;// software equivalent of pressing the GSM shield &quot;power&quot; button&#xA;{&#xA;  digitalWrite(9, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(9, LOW);&#xA;  delay(7000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Now we simply display any text that the GSM shield sends out on the serial monitor&#xA;  if(SIM900.available() &amp;gt;0)&#xA;  {&#xA;    incoming_char=SIM900.read(); //Get the character from the cellular serial port.&#xA;    Serial.print(incoming_char); //Print the incoming character to the terminal.&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Romz Marco" LastEditorUserId="4131" LastEditDate="2016-01-21T11:30:04.663" LastActivityDate="2016-02-20T19:53:48.133" Title="arduino and gsm module receive" Tags="|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19740" PostTypeId="2" ParentId="19725" CreationDate="2016-01-19T10:07:28.160" Score="1" Body="&lt;p&gt;This is why I think the server returns a HTTP500:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually in HTTP requests you do not include the ip address, so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;GET http://192.168.1.107/&amp;lt;really long part&amp;gt;?%s HTTP/1.0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;would become:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;GET /&amp;lt;really long part&amp;gt;?%s HTTP/1.0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also HTTP requests should use carriage return AND line feed to indicate the end of a line.&#xA;And an HTTP request should ALWAYS end in a full blank line.&#xA;You are using the HTTP1.0 protocol, so your request can be done in one line, so you can just end it with: &lt;code&gt;\r\n\r\n&lt;/code&gt;. If your request would be multiple lines, every line should also end with &lt;code&gt;\r\n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the result would be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;GET /&amp;lt;really long part&amp;gt;?%s HTTP/1.0\r\n\r\n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One &lt;code&gt;CRLF&lt;/code&gt; (the &lt;code&gt;\r\n&lt;/code&gt; part) to begin a new line and one more for the blank line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the connection problem, I think this has to do with the fact that you need to open AND close the connection for each HTTP request. You are using the HTTP1.0 protocol which does not support multiple HTTP requests in one connection. You can send multiple HTTP requests when using HTTP1.1, but then you also have to think about the TCP keepalive and it makes your request more complicated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try changing your HTTP request as mentioned above and call  client.connect() and a client.stop() for every HTTP request. And don't forget to tell us the results!&lt;/p&gt;&#xA;" OwnerUserId="13382" LastEditorUserId="13382" LastEditDate="2016-01-19T12:21:55.890" LastActivityDate="2016-01-19T12:21:55.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19742" PostTypeId="1" CreationDate="2016-01-19T13:44:31.083" Score="0" ViewCount="1735" Body="&lt;p&gt;I just brought the camera OV7670 with fifo but I am unable to get the wiring of board with arduino and also I do not find any arduino library for OV7670 with fifo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will great if you can help to find some link which can help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Somnath &lt;/p&gt;&#xA;" OwnerUserId="14130" LastActivityDate="2016-09-06T15:09:29.967" Title="OV 7670 + FIFO (AL422B) with arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19743" PostTypeId="2" ParentId="19742" CreationDate="2016-01-19T14:01:44.973" Score="1" Body="&lt;p&gt;Here is a &lt;a href=&quot;http://www.element14.com/community/docs/DOC-76210/l/trying-to-use-a-camera-module-to-show-footage-to-a-lcd-tft-screen&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;. Use google to find more. It is not difficult. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-19T14:01:44.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19744" PostTypeId="2" ParentId="19689" CreationDate="2016-01-19T14:32:51.243" Score="1" Body="&lt;p&gt;The title of this question is &quot;Reverse the order of a hex string&quot; but it was actually about reversing byte order in an unsigned long int.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an answer for reverse the order of a string (null terminated vector of char).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html#gacfdb3ab0c1f988f86d04d706d8e0ce3f&quot; rel=&quot;nofollow&quot;&gt;standard function&lt;/a&gt; for that in the C string function library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* strrev(char* s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-19T14:32:51.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19747" PostTypeId="2" ParentId="19715" CreationDate="2016-01-19T15:36:47.053" Score="1" Body="&lt;p&gt;For this specific reader, communication is only one way, from the reader to the Arduino via Weigand protocol.  Because of this, changes to the configuration for these readers is handled by proprietary RFID cards obtained from HID Global. The reader reads the card, and changes its configuration accordingly.  I was able to reach out to HID Global technical support and they are sending me a card that will change the configuration to output 56bit CSN/CSR/UID for mifare cards (which will cover the 7byte UID of mifare ultra).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the comments that helped me work this through.&lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-01-19T15:36:47.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19748" PostTypeId="1" CreationDate="2016-01-19T17:05:00.150" Score="4" ViewCount="27148" Body="&lt;p&gt;This may be an easy question, and if so im sorry, but i couldn't find out how to do this. I've programmed in python before and hoped that this would work, but it don't.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myArray1[] = {0, 2, 4, 5, 7, 9, 11};&#xA;int myArray2[] = {0, 2, 3, 5, 7, 8, 10};&#xA;int myArray3[] = {0, 3, 5, 6, 7, 10};&#xA;&#xA;int newArray[] = myArray2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wanted to only have to change one place in my code, which of the first three arrays i want my new array to take values from. Do anyone have any suggestions on how to do this? &lt;/p&gt;&#xA;" OwnerUserId="15313" LastActivityDate="2016-01-19T19:33:44.157" Title="Copy content of array" Tags="|array|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19749" PostTypeId="2" ParentId="19748" CreationDate="2016-01-19T17:31:40.400" Score="3" Body="&lt;p&gt;Make &lt;code&gt;newArray&lt;/code&gt; be a pointer to whichever array you wish to work with.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myArray1[] = {0, 2, 4, 5, 7, 9, 11};&#xA;int myArray2[] = {0, 2, 3, 5, 7, 8, 10};&#xA;int myArray3[] = {0, 3, 5, 6, 7, 10};&#xA;&#xA;int *newArray = myArray2;&#xA;&#xA;// ... work with selected array, via newArray[] subscripting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, you may need to set an array-length variable at the same time as choosing the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int *newArray = myArray2;&#xA;int newSize = sizeof(myArray2)/sizeof myArray2[0];&#xA;&#xA;// ... work with selected array&#xA;&#xA;newArray = myArray3;&#xA;newSize = sizeof(myArray3)/sizeof myArray3[0];&#xA;// ... work with selected array&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternately, add an array-end marker at the end of each array (eg, a negative number), or more elegantly, make all the arrays the same length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to make a new copy of the original array, such that modifying the new array won't change the old, use (eg) &lt;code&gt;memcpy()&lt;/code&gt;.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int newArray[7];&#xA;...&#xA;memcpy(newArray, myArray2, sizeof(myArray2));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;memcpy()&lt;/code&gt;'s size argument is given in bytes.  Also, if you need to declare &lt;code&gt;memcpy()&lt;/code&gt; [I don't recall whether it's automatically declared in the Arduino environment], add &lt;code&gt;#include &amp;lt;string.h&amp;gt;&lt;/code&gt; up front.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-19T19:33:44.157" LastActivityDate="2016-01-19T19:33:44.157" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19750" PostTypeId="1" CreationDate="2016-01-19T18:32:09.013" Score="2" ViewCount="548" Body="&lt;p&gt;According to datasheet of MCP3021 A/D converter (Microchip, page 16) the MCP3021 can be accessed by proper address bits in control byte. In case of MCP3021 &lt;em&gt;5AT&lt;/em&gt; the address is 101, in case of MCP3021 &lt;em&gt;4AT&lt;/em&gt; the address is 100. Does than mean that to interface two MCP3021 diveces in one circuit one have to purchase two devices with &lt;em&gt;different&lt;/em&gt; serial number, e.g. MCP3021 &lt;em&gt;5AT&lt;/em&gt; and &lt;em&gt;4AT&lt;/em&gt;?&lt;/p&gt;&#xA;" OwnerUserId="13392" LastActivityDate="2016-01-19T18:48:54.560" Title="Communication over I2C protocol with more than one A/D device" Tags="|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19751" PostTypeId="2" ParentId="19750" CreationDate="2016-01-19T18:48:54.560" Score="1" Body="&lt;p&gt;Yes, you need different devices for different addresses. Up to 8 addresses are possible:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The first part&#xA;  of the control byte consists of a 4-bit device code, which&#xA;  is set to 1001 for the MCP3021. The device code is fol-&#xA;  lowed by three address bits: A2, A1 and A0. The default&#xA;  address bits are 101 (contact the Microchip factory for&#xA;  additional address bit options).The address bits allow&#xA;  up to eight MCP3021 devices on the same bus and are&#xA;  used to determine which device is accessed&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The number after the A in the part number indicates the address: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D1MIO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D1MIO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Off the shelf you get address 5. If you want other addresses you have to order them specially from Microchip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device sacrifices flexibility in favour of size. If you want multiple devices on the same bus and not have to order different parts specially then you generally end up with a bigger chip with more pins to allow you to manually configure the sub-address.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-19T18:48:54.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19753" PostTypeId="1" CreationDate="2016-01-19T22:30:04.340" Score="0" ViewCount="385" Body="&lt;p&gt;I am unable to initialize a W5100 module using an Arduino Pro Mini. I try setting the MAC and IP addresses but read invalid values thereafter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Arduino program along with the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    uint8_t mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};&#xA;    uint8_t local_ip[] = {192, 168, 1, 100};&#xA;    Ethernet.begin(mac, local_ip);&#xA;    printMacAddress(); // OUTPUT: FF:FF:FF:FF:FF:FF&#xA;    printIpAddress(); // OUTPUT: 255.255.255.255&#xA;}&#xA;&#xA;void printMacAddress() {&#xA;    uint8_t mac[6];&#xA;    W5100.getMACAddress(mac);&#xA;    Serial.print(mac[0], HEX); Serial.print(&quot;:&quot;); Serial.print(mac[1], HEX); Serial.print(&quot;:&quot;);&#xA;    Serial.print(mac[2], HEX); Serial.print(&quot;:&quot;); Serial.print(mac[3], HEX); Serial.print(&quot;:&quot;);&#xA;    Serial.print(mac[4], HEX); Serial.print(&quot;:&quot;); Serial.print(mac[5], HEX); Serial.println();&#xA;}&#xA;&#xA;void printIpAddress() {&#xA;    IPAddress ip = Ethernet.localIP();&#xA;    Serial.println(ip);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I read in some blog posts that the Arduino may initialize before the W5100 initialization is completed so others recommend manually resetting the W5100 after Arduino initialization.&#xA;So I connected the W5100 reset pin to the Arduino digital output 4 and reset the W5100 during setup using the following code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int W5100_RESET_PIN = 4;&#xA;pinMode(W5100_RESET_PIN, OUTPUT);&#xA;digitalWrite(W5100_RESET_PIN, LOW); // Activate reset pin by asserting low&#xA;delay(5); // Wait for 5 msec&#xA;digitalWrite(W5100_RESET_PIN, HIGH); // Deactivate reset pin by asserting high&#xA;delay(300); // Wait for W5100 to initialize[/code]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I observed the W5100 resetting because the module LEDs flashed off and back on each time I manually reset the Arduino. However this does not fix the W5100 mac/IP initialization issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How should I troubleshoot this issue?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are pictures of the assembly.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cjnHE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/cjnHE.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an overview of the W5100 module.&#xA;&lt;a href=&quot;http://arduino-info.wikispaces.com/Ethernet&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://arduino-info.wikispaces.com/Ethernet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="user16534" LastActivityDate="2016-01-20T20:13:34.300" Title="Unable to initialize W5100 using Arduino Pro Mini" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19755" PostTypeId="1" AcceptedAnswerId="21705" CreationDate="2016-01-19T23:31:42.980" Score="3" ViewCount="1737" Body="&lt;p&gt;Adafruit carries a number of Bluetooth LE 4.0 modules in their store, notably the SPI (&lt;a href=&quot;https://www.adafruit.com/products/2633&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2633&lt;/a&gt;) and UART (&lt;a href=&quot;https://www.adafruit.com/product/2479&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/product/2479&lt;/a&gt;) version. I have used the NRF24L01 module with ATtiny85 via SPI to transmit data in the past, and this uses 3 pins. I used the following setup to do so: &lt;a href=&quot;https://www.hackster.io/arjun/nrf24l01-with-attiny85-3-pins-74a1f2&quot; rel=&quot;nofollow&quot;&gt;https://www.hackster.io/arjun/nrf24l01-with-attiny85-3-pins-74a1f2&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My previous system consisted of ATtiny85s communicating with a receiver (Bluefruit Feather) via NRF24L01 radios. As the receiver got data, it sent it to an iPhone app that I wrote. Now, I would like to cut out this receiver and BLE straight to the iPhone, which supports multiple peripheral connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, unlike the RF24 library, the Adafruit BLE SPI library needs the actual SPI library to compile correctly, which for some reason the RF24 library (this version: &lt;a href=&quot;http://tmrh20.github.io/RF24/&quot; rel=&quot;nofollow&quot;&gt;http://tmrh20.github.io/RF24/&lt;/a&gt;) doesn't. I don't quite get how the RF24 library can compile fine without the SPI library when targeting the ATtiny85 - Is there some way to get this to work similar to the RF24 library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, I think there is a way to do software UART on ATtiny85, which I know nothing about, so if there truly is no way to do SPI is UART possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that this is a question best asked to Adafruit, which I have done, but I thought I'd post it here and see if anyone can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Alex&lt;/p&gt;&#xA;" OwnerUserId="15677" LastActivityDate="2016-03-11T21:07:06.680" Title="BLE SPI Module with ATtiny85" Tags="|bluetooth|attiny|spi|adafruit|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19756" PostTypeId="1" AcceptedAnswerId="19757" CreationDate="2016-01-20T02:45:05.987" Score="19" ViewCount="11481" Body="&lt;p&gt;With reference to the Arduino Uno, Mega2560, Leonardo and similar boards:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How does serial communications work?&lt;/li&gt;&#xA;&lt;li&gt;How fast is serial?&lt;/li&gt;&#xA;&lt;li&gt;How do I connect between a sender and receiver?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Please note: This is intended as a reference question.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-09-27T07:29:36.203" Title="How does serial communications work on the Arduino?" Tags="|serial|c++|hardware|softwareserial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19757" PostTypeId="2" ParentId="19756" CreationDate="2016-01-20T02:45:05.987" Score="17" Body="&lt;p&gt;Asynchronous serial (usually referred to as serial) communications is used to send bytes from one device to another. A device could be one or more of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino&lt;/li&gt;&#xA;&lt;li&gt;PC&lt;/li&gt;&#xA;&lt;li&gt;GPS&lt;/li&gt;&#xA;&lt;li&gt;RFID card reader&lt;/li&gt;&#xA;&lt;li&gt;LCD display&lt;/li&gt;&#xA;&lt;li&gt;Modem&lt;/li&gt;&#xA;&lt;li&gt;Other&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Clock rate and sampling of data&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Unlike SPI / USB / I2C serial communications does not have a clock signal. The sampling clock is an agreed-upon sample rate (known as the baud rate). Both sender and receiver must be configured to be using the same rate or the receiver will receive meaningless data (due to the bits not being sampled at the same rate that they were sent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transmission is &lt;a href=&quot;https://en.wikipedia.org/wiki/Asynchronous_communication&quot; rel=&quot;noreferrer&quot;&gt;asynchronous&lt;/a&gt; which basically means that bytes can be sent at any time, with varying gaps between them. This graphic illustrates a single byte being sent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LcurN.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LcurN.png&quot; alt=&quot;Serial comms - sending one byte&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The graphic above shows the letter 'F' being transmitted. In ASCII this is 0x46 (in hex) or 0b01000110 (in binary). The &lt;em&gt;least&lt;/em&gt; significant (low-order) bit is transmitted first, thus in the above graphic you see the bits arriving in the order: &lt;code&gt;01100010&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;idle&quot; time between bytes is transmitted as continuous &quot;1&quot; bits (effectively, the transmit line is held high continuously).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To indicate the start of a byte, the &lt;em&gt;Start Bit&lt;/em&gt; is always indicated by pulling the line low as shown on the graphic. Once the receiver sees the start bit, it waits for 1.5 times the sample time, and then samples the data bits. It waits 1.5 times so that it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Skips the start bit&lt;/li&gt;&#xA;&lt;li&gt;Samples half-way through the next bit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the baud rate is 9600 baud, for example, then the sample rate will be &lt;code&gt;1/9600 = 0.00010416&lt;/code&gt; seconds (104.16 µs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, at 9600 baud, after receiving a start bit the receiver waits for 156.25 µs, and then samples every 104.16 µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SoFKx.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SoFKx.png&quot; alt=&quot;Start bit timing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose of the &lt;em&gt;Stop Bit&lt;/em&gt; is to ensure that there definitely is a 1-bit between each byte. Without the stop bit, if a byte ended in a zero, then it would be impossible for the hardware to tell the difference between that and the start bit of the next byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To produce the above output on an Uno you could write this code:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;  {&#xA;      Serial.begin(9600);&#xA;      Serial.print(&quot;F&quot;);&#xA;  }&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Number of data bits&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In order to save transmission time (in the olden days, heh) you were allowed to specify different numbers of data bits. The AtMega hardware supports data bits numbering from 5 to 9. Clearly the less data bits the less information you can send, but the faster it will be.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Parity bits&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You can optionally have a parity bit. This is calculated, if required, by counting the number of 1's in the character, and then making sure that this number is odd or even by setting the parity bit to 0 or 1 as required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, for the letter &quot;F&quot; (or 0x46 or 0b01000110) you can see that there are 3 ones there (in 01000110). Thus we already have odd parity. So, the parity bit would be as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;No parity: omitted&lt;/li&gt;&#xA;&lt;li&gt;Even parity: a 1 (3 + 1 is even)&lt;/li&gt;&#xA;&lt;li&gt;Odd parity: a 0 (3 + 0 is odd)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The parity bit, if present, appears after the last data bit but before the stop bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the receiver does not get the correct parity bit, that is called a &quot;parity error&quot;. It indicates that there is some problem. Possibly the sender and receiver are configured to use different baud (bit) rates, or there was noise on the line which turned a zero to a one or vice-versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some early systems also used &quot;mark&quot; parity (where the parity bit was always 1 regardless of the data), or &quot;space&quot; parity (where the parity bit was always 0 regardless of the data).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;9-bit transmission&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Some communication equipment uses 9-bit data, so in these cases the parity bit is turned into the 9th bit. There are special techniques for sending this 9th bit (the registers are 8-bit registers so the 9th bit has to be put somewhere else).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Number of stop bits&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Early equipment tended to be somewhat slower electronically, so to give the receiver time to process the incoming byte, it was sometimes specified that the sender would send two stop bits. This basically adds more time where the data line is held high (one more bit time) before the next start bit can appear. This extra bit time gives the receiver time to process the last incoming byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the receiver does not get a logical 1 when the stop bit is supposed to be, that is called a &quot;framing error&quot;. It indicates that there is some problem. Quite possibly the sender and receiver are configured to use different baud (bit) rates.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Notation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Commonly, serial communication is indicated by telling you the speed, number of data bits, type of parity, and number of stop bits, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;9600/8-N-1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is telling us:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;9600 bits per second&lt;/li&gt;&#xA;&lt;li&gt;8 data bits&lt;/li&gt;&#xA;&lt;li&gt;No parity (you might see instead: E=even, O=odd)&lt;/li&gt;&#xA;&lt;li&gt;1 stop bit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It is important that the sender and receiver agree on the above, otherwise communication is unlikely to be successful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Pin-outs&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno has digital pins 0 and 1 available for hardware serial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eFevW.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eFevW.png&quot; alt=&quot;Arduino Uno serial pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To connect two Arduinos you &lt;em&gt;swap&lt;/em&gt; Tx and Rx like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QJO4F.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QJO4F.png&quot; alt=&quot;Connecting two Arduinos together&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Speed&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A wide range of speeds is supported (see graphic below). &quot;Standard&quot; speeds are usually a multiple of 300 baud (eg. 300/600/1200/2400 etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other &quot;non-standard&quot; speeds can be handled by setting the appropriate registers. The HardwareSerial class does this for you. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.begin (115200);  // set speed to 115200 baud&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a rule-of-thumb, assuming you are using 8-bit data, then you can estimate the number of bytes you can transmit per second by dividing the baud rate by 10 (because of the start bit and stop bit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, at 9600 baud you can transmit 960 bytes (&lt;code&gt;9600 / 10 = 960&lt;/code&gt;) per second.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Baud rate errors&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The baud rate on the Atmega is generated by dividing down the system clock, and then counting up to a pre-set number. This table from the datasheet shows the register values, and error percentages, for a 16 MHz clock (such as the one on the Arduino Uno).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Dlzee.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dlzee.png&quot; alt=&quot;Baud rate errors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The U2Xn bit affects the clock rate divisor (0 = divide by 16, 1 = divide by 8). The UBRRn register contains the number the processor counts up to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So from the table above, we see that we get 9600 baud from a 16 MHz clock as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;16000000 / 16 / 104 = 9615&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We divide by 104 and not 103 because the counter is zero-relative. Thus the error here is &lt;code&gt;15 / 9600 = 0.0016&lt;/code&gt; which is close to what the table above says (0.02%).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will notice that some baud rates have a higher error amount than others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the datasheet the maximum error percentage for 8 data bits is in the range of 1.5% to 2.0% (see the datasheet for more details).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Arduino Leonardo&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Arduino Leonardo and Micro have a different approach to serial communications, as they connect directly via USB to the host computer, not via the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this, you must wait for Serial to become &quot;ready&quot; (as the software establishes an USB connection), with an extra couple of lines, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;  {&#xA;      Serial.begin(115200);&#xA;      while (!Serial)&#xA;      {}  // wait for Serial comms to become ready&#xA;      Serial.print(&quot;Fab&quot;);&#xA;  }&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, if you want to actually communicate via pins D0 and D1, (rather than by the USB cable) then you need to use Serial1 rather than Serial. You do so like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;  {&#xA;      Serial1.begin(115200);&#xA;      Serial1.print(&quot;Fab&quot;);&#xA;  }&#xA;&#xA;void loop ()&#xA;  {&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Voltage levels&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Note that the Arduino uses TTL levels for serial communications. This means that it expects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &quot;zero&quot; bit is 0V&lt;/li&gt;&#xA;&lt;li&gt;A &quot;one&quot; bit is +5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Older serial equipment designed to plug into a PC's serial port probably uses RS232 voltage levels, namely:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &quot;zero&quot; bit is +3 to +15 volts&lt;/li&gt;&#xA;&lt;li&gt;A &quot;one&quot; bit is −3 to −15 volts&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not only is this &quot;inverted&quot; with respect to TTL levels (a &quot;one&quot; is more negative than a &quot;zero&quot;), the Arduino cannot handle negative voltages on its input pins (nor positive ones greater than 5V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus you need an interface circuit for communicating with such devices. For input (to the Arduino) only, a simple transistor, diode, and a couple of resistors will do it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8WUMU.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8WUMU.png&quot; alt=&quot;Inverting buffer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For two-way communication you need to be able to generate negative voltages, so a more complex circuit is required. For example the MAX232 chip will do that, in conjunction with four 1 µF capacitors to act as charge-pump circuits.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Software Serial&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There is a library called SoftwareSerial that lets you do serial communications (up to a point) in software rather than hardware. This has the advantage that you can use different pin configurations for serial communications. The disadvantage is that doing serial in software is more processor-intensive and more prone to error. See &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;noreferrer&quot;&gt;Software Serial&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Mega2560&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Arduino &quot;Mega&quot; has 3 additional hardware serial ports. They are marked on the board as Tx1/Rx1, Tx2/Rx2, Tx3/Rx3. They should be used in preference to SoftwareSerial if possible. To open those other ports you use the names Serial1, Serial2, Serial3, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;Serial1.begin (115200);  // start hardware serial port Tx1/Rx1&#xA;Serial2.begin (115200);  // start hardware serial port Tx2/Rx2&#xA;Serial3.begin (115200);  // start hardware serial port Tx3/Rx3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Interrupts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Both sending and receiving, using the HardwareSerial library, use interrupts.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Sending&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;When you do a &lt;code&gt;Serial.print&lt;/code&gt;, the data you are trying to print is placed in an internal &quot;transmit&quot; buffer. If you have 1024 bytes or more of RAM (such as on the Uno) you get a 64-byte buffer, otherwise you get a 16-byte buffer. If the buffer has room, then the &lt;code&gt;Serial.print&lt;/code&gt; returns immediately, thus not delaying your code. If there is no room, then it &quot;blocks&quot; waiting for the buffer to be emptied enough for there to be room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, as each byte is transmitted by the hardware an interrupt is called (the &quot;USART, Data Register Empty&quot; interrupt) and the interrupt routine sends the next byte from the buffer out of the serial port.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Receiving&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;As incoming data is received an interrupt routine is called (the &quot;USART Rx Complete&quot; interrupt) and the incoming byte is placed into a &quot;receive&quot; buffer (the same size as the transmit buffer mentioned above).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you call &lt;code&gt;Serial.available&lt;/code&gt; you find out how many bytes are available in that &quot;receive&quot; buffer. When you call &lt;code&gt;Serial.read&lt;/code&gt; a byte is removed from the receive buffer and returned to your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduinos with 1000 bytes or more of RAM, there is no rush to remove data from the receive buffer, provided you don't let it fill up. If it fills up then any further incoming data is discarded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that because of the size of this buffer there is no point in waiting for a very large number of bytes to arrive, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;while (Serial.available () &amp;lt; 200)&#xA;  { }  // wait for 200 bytes to arrive&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will never work because the buffer cannot hold that much.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Tips&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Before reading, always make sure data is available. For example, this is wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;if (Serial.available ())&#xA;  {&#xA;      char a = Serial.read ();&#xA;      char b = Serial.read ();  // may not be available&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Serial.available&lt;/code&gt; test only ensures you have &lt;em&gt;one&lt;/em&gt; byte available, however the code tries to read two. It may work, if there are two bytes in the buffer, if not you will get -1 returned which will look like 'ÿ' if printed.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Be aware of how long it takes to send data. As mentioned above, at 9600 baud you an only transmit 960 bytes per second, so trying to send 1000 readings from an analog port, at 9600 baud, won't be very successful.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=10894&quot; rel=&quot;noreferrer&quot;&gt;Async (Serial) peripheral interface - for Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;noreferrer&quot;&gt;How to process incoming serial data without blocking&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/RS-232&quot; rel=&quot;noreferrer&quot;&gt;RS-232 - Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Reference/Serial&quot; rel=&quot;noreferrer&quot;&gt;Arduino Reference - Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-09-27T07:29:36.203" LastActivityDate="2016-09-27T07:29:36.203" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="19762" PostTypeId="1" AcceptedAnswerId="19784" CreationDate="2016-01-20T09:40:28.407" Score="2" ViewCount="1725" Body="&lt;p&gt;I am developing an educational product that I would like to mass produce. I am not sure of the quantity yet, but I imagine we will make a few hundred PCBs at least to begin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I spoke with an electrical engineering about how to take an Arduino prototype to mass production, and he warned me that the code written in the Arduino IDE cannot be fused onto the processor. (He used the term &quot;fuse&quot;, although I don't see this elsewhere in the forum. is this the right term?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He said that I would probably have to take each product, and load the Arduino code on manually, plugging in each one to a computer and upload like one would when prototyping. Also, he said the other option would be to recode my Arduino sketch from scratch using an AVR code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone shed some light on this for me? How can I take Arduino prototyping code and use it in mass production?&lt;/p&gt;&#xA;" OwnerUserId="16549" LastEditorUserId="2881" LastEditDate="2016-01-20T10:28:26.523" LastActivityDate="2016-01-20T20:00:08.293" Title="Take an Arduino or Teensy prototype to Mass production - Loading software onto microcontroller" Tags="|programming|sketch|teensy|software|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19765" PostTypeId="2" ParentId="19762" CreationDate="2016-01-20T10:31:11.823" Score="1" Body="&lt;p&gt;Arduino code and AVR code is essentially the same, at least once compiled it is. The only real difference is the existence of the bootloader, and that is not essential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For quantities of a hundred or so it is probably most cost effective to manually program them via an ISP connector to the board. For larger quantities Atmel provide a mass programming service to pre-program the chips, but that costs money so the more you have done at once the cheaper it is per chip. I am not sure on Atmel's procedure off hand but others I have used just take either a .elf or .hex file which the Arduino IDE is perfectly capable of producing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way you should design in an ISP connector on your board so the firmware can be upgraded in the future if needed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-20T10:31:11.823" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19766" PostTypeId="2" ParentId="19762" CreationDate="2016-01-20T10:35:17.690" Score="1" Body="&lt;p&gt;Arduino code &lt;strong&gt;is&lt;/strong&gt; AVR code. There's no real difference. The only thing is that Arduino's tend to use bootloaders, which might cause a problem. But in your case I'd advice to not use a bootloader anyways. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you plan to build a lot of them, you probably want to use bare ATMega chips, and not arduino boards. Bare chips don't have a bootloader to begin with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd program the boards using ISP.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-20T10:35:17.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19767" PostTypeId="1" AcceptedAnswerId="19772" CreationDate="2016-01-20T11:05:06.480" Score="1" ViewCount="6608" Body="&lt;p&gt;I am trying to write a sketch where a function will only be triggered when the ultrasound doesn't return back. Thus when the echo pin is checked after 1 second after the trigger pin was written high, it must be low. Will it be a digitalRead function?&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2016-01-20T11:50:43.117" Title="What if Ultrasonic sensor doesn't detect object?" Tags="|sensors|sketch|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19768" PostTypeId="1" AcceptedAnswerId="19776" CreationDate="2016-01-20T11:28:38.887" Score="2" ViewCount="616" Body="&lt;p&gt;Only 2 arduinos can normally be linked via serial port because TX and RX need to be cross-linked, and connecting multiple TXs together would cause conflict.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS485 allows multiple nodes connected in parallel on a 2 wire differential 'bus', using a TX ENABLE pin to allow one master to transmit while all other slaves listen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it should be possible to similarly connect multiple serial RXs together to give a common listening bus, and be able to use TX ENABLE on any one node at a time to transpose its RX and TX to allow its TX to transmit to the other RXs. This might be physically done using a changeover relay swapping RX with TX, but is it possible to somehow temporarily switch the TX and RX assignments on demand by software?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt the actual pin assignments can be changed in-situ, but perhaps the same results are achievable with some programming wizards sleight-of-hand trickery?&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2016-01-20T19:04:25.717" Title="Can RX and TX be temporarily transposed on demand?" Tags="|programming|communication|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19770" PostTypeId="2" ParentId="19768" CreationDate="2016-01-20T11:40:50.860" Score="1" Body="&lt;p&gt;It sounds to me like you are misunderstanding the purpose of the TX Enable pin and you are trying to come up with some convoluted method to do exactly what TX Enable actually does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under normal circumstances, in RS485, the UART's RX pin is connected to the bus.  When TX Enable is asserted the RX pin is disconnected and the TX pin is connected, thus allowing any node on the bus to be a transmitter and all the other nodes a receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main thing to watch out for though is that only one node is ever a transmitter at a time, otherwise you get a &lt;em&gt;collision&lt;/em&gt; which means that the data is completely garbled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way of stopping that happening is to have one node nominated as the &lt;em&gt;master&lt;/em&gt; and all the other nodes as &lt;em&gt;slaves&lt;/em&gt;.  The &lt;em&gt;master&lt;/em&gt; first initiates communication by making a request to a &lt;em&gt;slave&lt;/em&gt;.  The &lt;em&gt;slave&lt;/em&gt; will then respond with data (it becomes the transmitter and the &lt;em&gt;master&lt;/em&gt; a receiver) to send data to the master.  That way the only node that is a transmitter is either the &lt;em&gt;master&lt;/em&gt; making the request, or the &lt;em&gt;slave&lt;/em&gt; that is responding to a request. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want &quot;random&quot; peer-to-peer communication where any node could become a transmitter at any time it becomes a whole lot more complex.  There are things you should implement to try to avoid, or deal with, collisions, including monitoring the bus and only transmitting after a certain amount of idle time has been detected, reading the bus while writing to it (requires more hardware) and confirming that the data you read from the bus is the same as the data you wrote to the bus, and random delays before retrying a failed communication.  That last one is probably the trickiest to get right, since random numbers on Arduinos aren't really random unless you &quot;seed&quot; them from a truly random source. You don't want both ends delaying for the same amount of time to retry otherwise it will never complete.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since you apparently want to achieve that kind of thing but &lt;em&gt;without&lt;/em&gt; using RS485, it all gets much more complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No, you cannot &quot;swap&quot; the functionality of the TX and RX pins in the Arduino.  &lt;strong&gt;BUT&lt;/strong&gt; you can do serial communication (albeit somewhat heavyweight) using pure software.  Take a look at the SoftwareSerial library - you will most likely need to make modifications to that to achieve what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do it externally with hardware is possible, but the end result will most likely be more complex than just using a simple RS485 interface chip which are very inexpensive and easy to get hold of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you could use relays (&lt;em&gt;clunky&lt;/em&gt;) or buffers, or multiplexers, etc, but why would you when RS485 does what you want?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-01-20T12:12:20.567" LastActivityDate="2016-01-20T12:12:20.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19771" PostTypeId="1" AcceptedAnswerId="19773" CreationDate="2016-01-20T11:49:53.587" Score="6" ViewCount="15128" Body="&lt;p&gt;One of the FastLED examples that I've seen was using code that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;EVERY_N_MILLISECONDS( 300 ) { transition_step(); }&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've copied it and successfully used it in the same context - but I have no idea what it is or how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Google search finds no reference anywhere at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still a beginner with C but this looks like a Define to me - all being in uppercase - is it defined somewhere in the FastLED library?&lt;/p&gt;&#xA;" OwnerUserId="3377" LastActivityDate="2023-03-12T13:57:41.147" Title="&quot;EVERY_N_MILLISECONDS&quot;" Tags="|c|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19772" PostTypeId="2" ParentId="19767" CreationDate="2016-01-20T11:50:43.117" Score="2" Body="&lt;p&gt;What type of Ultrasonic sensor do you have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll go with HC-SR04, since I've got one of those laying around here. The other ultrasonic sensors should be working in the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Before you start!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read the datasheet. A fast search on google with: &quot;[manufacturer][device id][device description] datasheet .pdf&quot; will do good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: &lt;a href=&quot;http://www.micropik.com/PDF/HCSR04.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.micropik.com/PDF/HCSR04.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet will tell you important things/values and sometimes even interfacing examples or code.&#xA;Like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Max input voltage&lt;/li&gt;&#xA;&lt;li&gt;Max current&lt;/li&gt;&#xA;&lt;li&gt;Pin-out diagrams&lt;/li&gt;&#xA;&lt;li&gt;How to interface with the device&lt;/li&gt;&#xA;&lt;li&gt;Min/max operating temperature&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wiring up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet will tell you what to connect, to which pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We've got 5V, Trigger (input), Echo (output), 0V (ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(As per datasheet)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's best to do the wiring before you put power on it, because you can accidently short it when moving wires around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Interfacing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend checking some code examples before you attempt to roll your own. Or just start from an example and edit it to your specifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timing diagram shows us it needs a 10uS pulse on the trigger input.&#xA;And the duration of the echo will show the distance (58 uS per cm or 148 uS per inch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet also suggest to use over 60ms measurement cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking all that into account:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin 13&#xA;#define echoPin 12&#xA;#define led 11&#xA;#define led2 10&#xA;&#xA;const unsigned long timeout = 400*58; //Max of 400CM, adjust this to your own max.&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);//Stop using 9600 as default, it's not fast.&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(led, OUTPUT);&#xA;  pinMode(led2, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long distance;//unsigned, since we don't get negative distances.&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10); //10 uS pulse.&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  distance = round(pulseIn(echoPin, HIGH,timeout) /58);//Distance in CM's, use /148 for inches.&#xA;  if (distance == 0){//Reached timeout&#xA;    Serial.println(&quot;Out of range&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.print(distance);&#xA;    Serial.println(&quot; cm&quot;);&#xA;  }&#xA;  delay(60);//Wait 60 ms for next cycle.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To be honest, I'm not even slightly sure if this code is working.&#xA;I modified this code: &lt;a href=&quot;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that you're actually using the timeout right, and do the timing according to the datasheet.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-01-20T11:50:43.117" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19773" PostTypeId="2" ParentId="19771" CreationDate="2016-01-20T12:02:39.227" Score="5" Body="&lt;p&gt;Yes, it is defined in the FastLED library.  It is a &lt;em&gt;preprocessor macro&lt;/em&gt; which is replaced by a block of code when compiled:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a very convoluted bit of preprocessing code that is difficult (even for me) to follow through with lots of concatenations and multiple layers of definition, so my advice is to just not worry about it and just use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to try and decypher it all it's in the file &lt;code&gt;lib8tion.h&lt;/code&gt; in the FastLED library.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-20T12:02:39.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19774" PostTypeId="1" CreationDate="2016-01-20T12:11:22.410" Score="1" ViewCount="1287" Body="&lt;p&gt;I am trying to learn how to use a shift register to control 8 LEDs but for some reason my shift register is misbehaving and none of the LEDs are lighting up. I imagine that it's a problem with my wiring? I have replicated the circuit on 123D Circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UJOA9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UJOA9.png&quot; alt=&quot;circuit diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Pin connected to ST_CP of 74HC595&#xA;int latchPin = 8;&#xA;//Pin connected to SH_CP of 74HC595&#xA;int clockPin = 12;&#xA;////Pin connected to DS of 74HC595&#xA;int dataPin = 11;&#xA;&#xA;void setup() {&#xA;  //set pins to output so you can control the shift register&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // count from 0 to 255 and display the number &#xA;  // on the LEDs&#xA;  for (int numberToDisplay = 0; numberToDisplay &amp;lt; 256; numberToDisplay++) {&#xA;    // take the latchPin low so &#xA;    // the LEDs don't change while you're sending in bits:&#xA;    digitalWrite(latchPin, LOW);&#xA;    // shift out the bits:&#xA;    shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);  &#xA;&#xA;    //take the latch pin high so the LEDs will light up:&#xA;    digitalWrite(latchPin, HIGH);&#xA;    // pause before next value:&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16556" LastActivityDate="2016-01-20T13:32:26.763" Title="Shift Register Not Working" Tags="|shift-register|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19775" PostTypeId="2" ParentId="19774" CreationDate="2016-01-20T13:11:12.133" Score="1" Body="&lt;p&gt;From the Arduino website:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;h2&gt;shiftOut()&lt;/h2&gt;&#xA;  &#xA;  &lt;p&gt;Description&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Shifts out a byte of data one bit at a time. [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Note: if you're interfacing with a device that's clocked by rising&#xA;  edges, you'll need to make sure that the clock pin is low before the&#xA;  call to shiftOut(), e.g. with a call to digitalWrite(clockPin, LOW).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to pull &lt;code&gt;clockPin&lt;/code&gt; low before each &lt;code&gt;shiftOut()&lt;/code&gt; call, as the documentation says.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you have misunderstood the behaviour of the &lt;code&gt;latchPin&lt;/code&gt;. This can be high or low at any time; it's the &lt;em&gt;change from low to high&lt;/em&gt; that latches the data into the output cells.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2016-01-20T13:32:26.763" LastActivityDate="2016-01-20T13:32:26.763" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19776" PostTypeId="2" ParentId="19768" CreationDate="2016-01-20T13:45:24.473" Score="1" Body="&lt;p&gt;On an AVR-based Arduino, you can selectively enable the transmitter and&#xA;receiver side of the UART (c.f. the datasheet of your MCU). Thus, you&#xA;could in principle just connect all the TX and RX together, and make&#xA;sure only one transmitter is enabled at a time, while all the others are&#xA;in high impedance. If you do this, I would strongly recommend you put a&#xA;current-limiting resistor in series with each TX, just in case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, on an Arduino Uno&#xA;(&lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;Atmega328P&lt;/a&gt;),&#xA;you can use the following functions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;static inline void enable_tx()  { UCSR0B |=  _BV(TXEN0); }&#xA;static inline void disable_tx() { UCSR0B &amp;amp;= ~_BV(TXEN0); }&#xA;static inline void enable_rx()  { UCSR0B |=  _BV(RXEN0); }&#xA;static inline void disable_rx() { UCSR0B &amp;amp;= ~_BV(RXEN0); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Beware that &lt;code&gt;Serial.begin()&lt;/code&gt; enables both the transmitter and&#xA;the receiver.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-01-20T19:04:25.717" LastActivityDate="2016-01-20T19:04:25.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19777" PostTypeId="2" ParentId="61" CreationDate="2016-01-20T14:05:58.647" Score="11" Body="&lt;p&gt;I believe this &lt;a href=&quot;http://www.smashingrobotics.com/arduino-simulators-lineup-start-developing-without-real-board/&quot; rel=&quot;noreferrer&quot;&gt;website&lt;/a&gt; has a list of both emulators and simulators along with their price and availability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since some users mentioned there are broken links in that website, here's a selection of emulators I found. Note that some descriptions may have been taken from the mentioned link:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ghewgill/emulino&quot; rel=&quot;noreferrer&quot;&gt;Emulino&lt;/a&gt;: Is an open source linux based software in early development that emulates Arduino-specific MCUs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://emulare.sourceforge.net/&quot; rel=&quot;noreferrer&quot;&gt;Emulare&lt;/a&gt;: is a general purpose hardware emulator. It aims to provide a central interface to build electronic simulations for embedded software development. At present emulare focuses on the ATMega line of microcontrollers (Arduino UNO has the ATMega processor).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/buserror/simavr&quot; rel=&quot;noreferrer&quot;&gt;SimAVR&lt;/a&gt;: is a new AVR simulator for linux, or any platform that uses avr-gcc. The simulator loads ELF files directly, and there is even a way to specify simulation parameters directly in the emulated code using an .elf section. It supports emulation of many ATMega processors and it is mentioned that it's easy to even add new ones.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/tools/ATMELSTUDIO.aspx&quot; rel=&quot;noreferrer&quot;&gt;Amtel Studio&lt;/a&gt;: This doesn't seem to mention the term emulation, but it is a sophisticated IDE to debug your code for many platforms specially Arduino. Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can still use simulators such as &lt;a href=&quot;https://easyeda.com/&quot; rel=&quot;noreferrer&quot;&gt;EasyEDA&lt;/a&gt; to test your code and in most cases be able to run it on the device. But note that given the nature of electronic components, you may have to provide external resistors, capacitors etc to get the expected results.&lt;/p&gt;&#xA;" OwnerUserId="16558" LastEditorUserId="16558" LastEditDate="2016-01-20T21:31:36.720" LastActivityDate="2016-01-20T21:31:36.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19778" PostTypeId="1" AcceptedAnswerId="19779" CreationDate="2016-01-20T14:13:13.223" Score="1" ViewCount="953" Body="&lt;p&gt;I am trying to make a robot turn (dc motors are being used) back 180 degrees. So I used an l289n for it and made one wheel turn clockwise and vice-versa. &#xA;&lt;br&gt;&lt;br&gt;But as I wan't it to make only a 180 degrees turn, I wanted to set an amount of time for it to turn.  Is there any other way to do the same thing, if yes, please tell, if no, help me...&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2016-01-20T14:47:57.173" Title="How to make two wheels turn only for a particular amount of time?" Tags="|motor|sketch|robotics|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19779" PostTypeId="2" ParentId="19778" CreationDate="2016-01-20T14:47:57.173" Score="1" Body="&lt;p&gt;Use the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Delay&quot; rel=&quot;nofollow&quot;&gt;delay()&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pseudo code as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1) Turn clockwise motor on;&#xA;2) Turn counterclockwise motor on;&#xA;3) delay(&amp;lt;time&amp;gt;);&#xA;4) Turn CW motor off;&#xA;5) Turn CCW motor off.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-01-20T14:47:57.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19781" PostTypeId="1" CreationDate="2016-01-20T18:18:20.070" Score="2" ViewCount="364" Body="&lt;p&gt;So I bought a Bluetooth Shield from SeeedStudio lately (V2 model) and goofed around with it a little bit. I'm using my HTC One M8 to communicate with it just to send some dummy words. Whenever I send something from my phone to the Android, it works great and I'm pleased to see it's fast too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is fairly simple. I just send data from my phone, gets received to my arduino, prints it on the Arduino IDE terminal. Same thing for communication in the other way. Write something in the terminal, send it to the arduino and then, the phone. The last on doesn't work and I've tried a couple of things in the past 36 hours. Now, I'm just banging my head against the wall (literally). Here's my code (I'm sure you've seen it a couple of times before):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;   //Software Serial Port&#xA;#define RxD 6&#xA;#define TxD 7&#xA;&#xA;#define DEBUG_ENABLED  1&#xA;&#xA;SoftwareSerial blueToothSerial(RxD,TxD);&#xA;&#xA;void setup() &#xA;{ &#xA;  Serial.begin(9600);&#xA;  pinMode(RxD, INPUT);&#xA;  pinMode(TxD, OUTPUT);&#xA;  setupBlueToothConnection();&#xA;&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;  char recvChar;&#xA;  while(1){&#xA;    if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield&#xA;      recvChar = blueToothSerial.read();&#xA;      Serial.print(recvChar);&#xA;    }&#xA;    if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here&#xA;      recvChar  = Serial.read();&#xA;      blueToothSerial.print(recvChar);&#xA;    }&#xA;  }&#xA;} &#xA;&#xA;void setupBlueToothConnection()&#xA;{&#xA;  blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 38400&#xA;  blueToothSerial.print(&quot;\r\n+STWMOD=0\r\n&quot;); //set the bluetooth work in slave mode&#xA;  blueToothSerial.print(&quot;\r\n+STNA=SeeedBTSlave\r\n&quot;); //set the bluetooth name as &quot;SeeedBTSlave&quot;&#xA;  blueToothSerial.print(&quot;\r\n+STOAUT=1\r\n&quot;); // Permit Paired device to connect me&#xA;  blueToothSerial.print(&quot;\r\n+STAUTO=0\r\n&quot;); // Auto-connection should be forbidden here&#xA;  delay(2000); // This delay is required.&#xA;  blueToothSerial.print(&quot;\r\n+INQ=1\r\n&quot;); //make the slave bluetooth inquirable &#xA;  Serial.println(&quot;The slave bluetooth is inquirable!&quot;);&#xA;  delay(2000); // This delay is required.&#xA;  blueToothSerial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my phone, I use a simple Bluetooth SSP to pair and communicate. Btw, something odd: I can't change the name of the bluetooth device. When I try to connect it, it shows the same name in the SSP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: When I upload my code, I make sure I reset the arduino everytime. Oh and I changed the jumpers on my board to make sure it was set on the right one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note 2: I tried to see if the pins on the Shield (for RdX and TdX) were not starting with 0 by moving the jumpers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, it's pretty odd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help and don't hesitate to ask me question! It's my first time here!&lt;/p&gt;&#xA;" OwnerUserId="16562" LastEditorUserId="4131" LastEditDate="2016-01-21T12:38:52.410" LastActivityDate="2016-01-21T12:38:52.410" Title="Send data from computer to phone through bluetooth - Bluetooth SeeedStudio Shield V2.1" Tags="|bluetooth|shields|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19782" PostTypeId="1" AcceptedAnswerId="19783" CreationDate="2016-01-20T18:21:08.453" Score="0" ViewCount="624" Body="&lt;p&gt;My question is simple. Is the following possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using one Arduino Mega 2560 board and its SPI functionality to adjust voltages (0-4.096V) through a 12-bit DAC (MCP4822). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to measure the output voltages from the DAC by feeding them through a 12-bit ADC and back to the Arduino. The DAC's output voltages that will be directly measured by the ADC will be displayed on an LCD and on LabVIEW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible, given that both the DAC and the ADC have to be connected to the same SDI and SCK pins on the Arduino for SPI to work?&lt;/p&gt;&#xA;" OwnerUserId="16564" LastActivityDate="2016-01-20T18:22:47.927" Title="Arduino to DAC to ADC back to Arduino?" Tags="|arduino-mega|spi|digital-analog-conversion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19783" PostTypeId="2" ParentId="19782" CreationDate="2016-01-20T18:22:47.927" Score="2" Body="&lt;p&gt;Yes, perfectly possible. Just provide two separate CS pins to select between the two devices.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-20T18:22:47.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19784" PostTypeId="2" ParentId="19762" CreationDate="2016-01-20T20:00:08.293" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I spoke with an electrical engineering about how to take an Arduino prototype to mass production, and he warned me that the code written in the Arduino IDE cannot be fused onto the processor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's nonsense. The output from the IDE compiler is a .hex file which is then sent via &lt;code&gt;avrdude&lt;/code&gt; to program the board. If the output cannot be &quot;fused&quot; onto the processor how does he imagine we ever get anything done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly he is referring to changing the fuses to make it impossible to read the code back from the chip. This can be easily accomplished.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;He said that I would probably have to take each product, and load the Arduino code on manually, plugging in each one to a computer and upload like one would when prototyping. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have obviously spoken to someone with no experience in Arduinos, possibly one of those engineers with an active dislike of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written code to run on an Arduino to upload sketches to another board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read about it at &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow noreferrer&quot;&gt;Atmega chip stand-alone programmer to upload .hex files&lt;/a&gt;. The idea is you take your .hex file, put it onto an SD card and then program your target board in a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;User &quot;Crossroads&quot; from the Arduino forum has taken that idea and made a &lt;a href=&quot;http://crossroadsfencing.com/BobuinoRev17/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;stand-alone board&lt;/a&gt;, looking like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OQAQM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OQAQM.jpg&quot; alt=&quot;Hex programmer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You put up to 255 hex files onto the SD card. You dial-up which one you want with the rotary dial. You plug in the ICSP cable into your target board, and hit the &quot;program&quot; button. The whole thing takes a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is designed to be used &quot;in the field&quot;. All you have to do is plug in a power-pack to supply power to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you needed to protect the target boards with a fuse setting after uploading, you would modify the code in the programmer slightly to do that for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be helpful to have an ICSP header on your target boards, both for programming before deployment, and in case you find a bug and have to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Failing that you might put the chips into a suitable board first (eg. with a ZIF socket), program them off-board, and then solder them on. There are lots of options for you.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, he said the other option would be to recode my Arduino sketch from scratch using an AVR code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't see why that would be necessary, in any way.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-20T20:00:08.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19785" PostTypeId="2" ParentId="19753" CreationDate="2016-01-20T20:13:34.300" Score="1" Body="&#xA;&#xA;&lt;p&gt;One of the Ethernet examples shows you should test the result of the &lt;code&gt;begin&lt;/code&gt; function call, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// start the Ethernet connection:&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;    // try to congifure using IP address instead of DHCP:&#xA;    Ethernet.begin(mac, ip);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try displaying the return value from &lt;code&gt;begin&lt;/code&gt; to see if that initialization succeeded.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-20T20:13:34.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19786" PostTypeId="1" CreationDate="2016-01-20T23:09:52.547" Score="0" ViewCount="1187" Body="&lt;p&gt;New to Arduino, I plugged in DCMotorTest from the Adafruit site and got this error message: a fatal error exit status 1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* &#xA;This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2&#xA;It won't work with v1.x motor shields! Only for the v2's with built in PWM&#xA;control&#xA;&#xA;For use with the Adafruit Motor Shield v2 &#xA;----&amp;gt;   http://www.adafruit.com/products/1438&#xA;*/&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_MS_PWMServoDriver.h&quot;&#xA;&#xA;// Create the motor shield object with the default I2C address&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;// Or, create it with a different I2C address (say for stacking)&#xA;// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); &#xA;&#xA;// Select which 'port' M1, M2, M3 or M4. In this case, M1&#xA;Adafruit_DCMotor *myMotor = AFMS.getMotor(1);&#xA;// You can also make another motor on port M2&#xA;//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;  Serial.println(&quot;Adafruit Motorshield v2 - DC Motor test!&quot;);&#xA;&#xA;  AFMS.begin();  // create with the default frequency 1.6KHz&#xA;  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz&#xA;&#xA;  // Set the speed to start, from 0 (off) to 255 (max speed)&#xA;  myMotor-&amp;gt;setSpeed(150);&#xA;  myMotor-&amp;gt;run(FORWARD);&#xA;  // turn on motor&#xA;  myMotor-&amp;gt;run(RELEASE);&#xA;}&#xA;&#xA;void loop() {&#xA;  uint8_t i;&#xA;&#xA;  Serial.print(&quot;tick&quot;);&#xA;&#xA;  myMotor-&amp;gt;run(FORWARD);&#xA;  for (i=0; i&amp;lt;255; i++) {&#xA;    myMotor-&amp;gt;setSpeed(i);  &#xA;    delay(10);&#xA;  }&#xA;  for (i=255; i!=0; i--) {&#xA;    myMotor-&amp;gt;setSpeed(i);  &#xA;    delay(10);&#xA;  }&#xA;&#xA;  Serial.print(&quot;tock&quot;);&#xA;&#xA;  myMotor-&amp;gt;run(BACKWARD);&#xA;  for (i=0; i&amp;lt;255; i++) {&#xA;    myMotor-&amp;gt;setSpeed(i);  &#xA;    delay(10);&#xA;  }&#xA;  for (i=255; i!=0; i--) {&#xA;    myMotor-&amp;gt;setSpeed(i);  &#xA;    delay(10);&#xA;  }&#xA;&#xA;  Serial.print(&quot;tech&quot;);&#xA;  myMotor-&amp;gt;run(RELEASE);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;My error message was:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;/Users/student/Downloads/Adafruit_Motor_Shield_V2_Library-master/examples/DCMotorTest/DCMotorTest.ino:11:34:&#xA; fatal error: Adafruit_MotorShield.h: No such file or directory&#xA; #include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;                                  ^&#xA;compilation terminated.&#xA;exit status 1&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16573" LastEditorUserId="3917" LastEditDate="2016-01-20T23:40:10.250" LastActivityDate="2017-08-13T18:33:44.063" Title="DCMotorTest from the Adafruit site – got fatal error exit status 1" Tags="|adafruit|arduino-motor-shield|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19787" PostTypeId="1" AcceptedAnswerId="19811" CreationDate="2016-01-20T23:13:21.130" Score="9" ViewCount="13725" Body="&lt;p&gt;Short version: &#xA;I have a program that connects my ESP8266 to WIFI so I can control a relay connected to it over the internet or a button. I also have a sensor for my door. This software works perfectly, if I add a light dependent resistor to it (which is connected correctly since I do get readings from it) and start reading data I lose my WIFI connection. Has anyone got any idea why this is happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long version: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have this program running on my Esp8266&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;&#xA;IPAddress ip(192, 168, 0, 150);&#xA;IPAddress gateway(192, 168, 0, 1);&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;&#xA;const char* ssid = &quot;mySSID&quot;;&#xA;const char* password = &quot;myPSW&quot;;&#xA;const char* host = &quot;192.168.0.228&quot;;&#xA;&#xA;const int buttonPin = 0;&#xA;const int relayPin =  4;&#xA;const int doorPin = 5;&#xA;const int ldrPin = A0;&#xA;&#xA;&#xA;//int ldrState;&#xA;//int serialCount = 0;&#xA;//int ldrMin = 0;&#xA;//int ldrMax = 1024;&#xA;int buttonState = 0;&#xA;int doorState = 0;&#xA;byte Main_Light_State_Begin;&#xA;bool Main_Light_State;&#xA;bool doorNotified = false;&#xA;bool button_action_taken = false;&#xA;bool Main_Light_DBR = true;&#xA;String HTTP_Get_Response;&#xA;&#xA;WiFiServer server(80);&#xA;&#xA;//Functions&#xA;String HTTP_Get(char* Adress, String URL, bool Last_Line_Bool) {&#xA;  WiFiClient client;&#xA;  const int httpPort = 80;&#xA;  if (!client.connect(Adress, httpPort)) {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    return &quot;Failed&quot;;&#xA;  }&#xA;&#xA;  Serial.print(&quot;Requesting URL: &quot;);&#xA;  Serial.println(URL);&#xA;  Serial.println(&quot;at adress&quot;);&#xA;  Serial.println(Adress);&#xA;  client.print(String(&quot;GET &quot;) + URL + &quot; HTTP/1.1\r\n&quot; +&#xA;               &quot;Host: &quot; + Adress + &quot;\r\n&quot; +&#xA;               &quot;Connection: close\r\n\r\n&quot;);&#xA;  delay(10);&#xA;&#xA;  String Response;&#xA;  String Last_Line;&#xA;&#xA;  while (client.available()) {&#xA;    String line = client.readStringUntil('\r');&#xA;    Serial.print(line);&#xA;    Response = Response + line;&#xA;  }&#xA;  return Response;&#xA;&#xA;  Serial.println();&#xA;  Serial.println(&quot;closing connection&quot;);&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  delay(1000);&#xA;&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  Serial.print(&quot;Connecting to &quot;);&#xA;  Serial.println(ssid);&#xA;&#xA;&#xA;&#xA;  WiFi.begin(ssid, password);&#xA;  WiFi.config(ip, gateway, subnet);&#xA;&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;WiFi connected&quot;);&#xA;&#xA;  server.begin(); -&#xA;  Serial.println(&quot;Server started&quot;);&#xA;&#xA;  Serial.println(WiFi.localIP());&#xA;  pinMode(relayPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(doorPin, INPUT);&#xA;//  pinMode(ldrPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (WiFi.status() != WL_CONNECTED) {&#xA;    Serial.println(&quot;Wifi NOT Connected&quot;);&#xA;  }&#xA;  //Sensors&#xA;  buttonState = digitalRead(buttonPin);&#xA;  doorState = digitalRead(doorPin);&#xA;  //ldrState = map(analogRead(ldrPin), ldrMin, ldrMax, 0, 100);&#xA;  //Serial.println(analogRead(ldrPin));&#xA;//  if (serialCount == 1000) {&#xA;//    Serial.println(ldrState);&#xA;//    serialCount = 0;&#xA;//  } else {&#xA;//    serialCount ++;&#xA;//  }&#xA;&#xA;  //Doorsensor&#xA;  if (doorState == HIGH) {&#xA;    if (doorNotified == false) {&#xA;      Serial.println(&quot;DOOR&quot;);&#xA;      HTTP_Get_Response = HTTP_Get(&quot;192.168.0.228&quot;, &quot;/index.php/?door_opened=true&quot;, false);&#xA;      doorNotified = true;&#xA;    }&#xA;  } else if (doorState == LOW) {&#xA;    if (doorNotified == true) {&#xA;      doorNotified = false;&#xA;      delay(500);&#xA;    }&#xA;    else {&#xA;      doorNotified = false;&#xA;    }&#xA;  }&#xA;&#xA;  //Button&#xA;  if (buttonState == LOW) {&#xA;    if (button_action_taken == false) {&#xA;      if (Main_Light_State == true) {&#xA;        Serial.println(&quot;SWITCH&quot;);&#xA;        Main_Light_State = false;&#xA;        digitalWrite(relayPin, HIGH);&#xA;        delay(500);&#xA;        Main_Light_DBR = false;&#xA;      }&#xA;      else if (Main_Light_State == false) {&#xA;        Serial.println(&quot;SWITCH&quot;);&#xA;        Main_Light_State = true;&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(500);&#xA;        Main_Light_DBR = false;&#xA;      }&#xA;      button_action_taken = true;&#xA;    }&#xA;  } else if (buttonState == HIGH) {&#xA;    if (button_action_taken == true) {&#xA;      button_action_taken = false;&#xA;      delay(500);&#xA;    }&#xA;    else {&#xA;      button_action_taken = false;&#xA;    }&#xA;&#xA;  }&#xA;  //Main_Light_State&#xA;  if (Main_Light_State == true) {&#xA;    digitalWrite(relayPin, LOW);&#xA;    if (Main_Light_DBR == false) {&#xA;      HTTP_Get_Response = HTTP_Get(&quot;192.168.0.228&quot;, &quot;/index.php/?main_light_on_dbr=true&quot;, false);&#xA;      Main_Light_DBR = true;&#xA;    }&#xA;&#xA;  } else if (Main_Light_State == false) {&#xA;    digitalWrite(relayPin, HIGH);&#xA;    if (Main_Light_DBR == false) {&#xA;      HTTP_Get_Response = HTTP_Get(&quot;192.168.0.228&quot;, &quot;/index.php/?main_light_off_dbr=true&quot;, false);&#xA;      Main_Light_DBR = true;&#xA;    }&#xA;  }&#xA;&#xA;  WiFiClient client = server.available();&#xA;  if (!client) {&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println(&quot;new client&quot;);&#xA;  while (!client.available()) {&#xA;    delay(1);&#xA;  }&#xA;&#xA;  String req = client.readStringUntil('\r');&#xA;  Serial.println(req);&#xA;  client.flush();&#xA;&#xA;  if (req.indexOf(&quot;/main_light/on&quot;) != -1) {&#xA;    Main_Light_State = true;&#xA;    Main_Light_DBR = false;&#xA;  } else if (req.indexOf(&quot;/main_light/off&quot;) != -1) {&#xA;    Main_Light_State = false;&#xA;    Main_Light_DBR = false;&#xA;  } else if (req.indexOf(&quot;/main_light/switch&quot;) != -1) {&#xA;    Serial.println(&quot;SWITCH&quot;);&#xA;    if (Main_Light_State == true) {&#xA;      Main_Light_State = false;&#xA;    }&#xA;    else if (Main_Light_State == false) {&#xA;      Main_Light_State = true;&#xA;    }&#xA;    Main_Light_DBR = false;&#xA;  } else if (req.indexOf(&quot;/main_light/state&quot;) != -1) {&#xA;&#xA;  } else {&#xA;    Serial.println(&quot;invalid request&quot;);&#xA;    client.stop();&#xA;    return;&#xA;  }&#xA;&#xA;  client.flush();&#xA;&#xA;  String s = &quot;HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n&quot;;&#xA;  s += (Main_Light_State) ? &quot;1&quot; : &quot;0&quot;;&#xA;&#xA;  client.print(s);&#xA;  delay(1);&#xA;  Serial.println(&quot;Client disonnected&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With the lines I commented like above everything works fine. I have a light dependant resistor connected (correctly, I get correct measurements from it) to A0. From the moment on I uncomment the lines involving this LDR and thus start reading data from it I lose my wifi connection. Has anyone got any idea why this is? Thank you!&lt;/p&gt;&#xA;" OwnerUserId="16572" LastEditorUserId="37523" LastEditDate="2019-06-09T02:07:18.900" LastActivityDate="2019-06-09T02:07:18.900" Title="ESP8266 Analog read interferes with wifi?" Tags="|arduino-ide|wifi|esp8266|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19788" PostTypeId="1" CreationDate="2016-01-21T01:30:45.517" Score="0" ViewCount="1233" Body="&lt;p&gt;I have a problem. I try to open a channel to arduino and PHP talk, the PHP would send a command and the Arduino should answer that. It works, but only if I execute some steps before: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;sudo chmod 777 /dev/ttyACM0 &lt;/li&gt;&#xA;&lt;li&gt;sudo arduino &lt;/li&gt;&#xA;&lt;li&gt;Open the serial monitor in arduino IDE &lt;/li&gt;&#xA;&lt;li&gt;Close the serial monitor &lt;/li&gt;&#xA;&lt;li&gt;Now everything is ok, they can talk&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first step is ok, I really need to do this, the 2-4 seems irrelevant, but the communication do not start without it. I put one LCD in arduino to print what he receive, when I send &quot;HEYARD&quot; with PHP to him, the RX led blinks and the TX led also, but nothing is printed on LCD. If I do the 2-4 steps, when PHP send &quot;HEYARD&quot;, LCD show HEYARD and arduino answer with &quot;HEYPHP&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone could help? There is some way to open it via Terminal, or, at least, open the Serial Monitor from arduino and close to see if this start&lt;/p&gt;&#xA;" OwnerUserId="16576" LastEditorUserId="2881" LastEditDate="2016-01-21T10:08:37.743" LastActivityDate="2019-10-04T15:19:21.593" Title="Arduino and PHP communication only work if I open the Arduino IDE" Tags="|serial|linux|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19790" PostTypeId="1" CreationDate="2016-01-21T03:20:02.733" Score="2" ViewCount="522" Body="&lt;p&gt;I am communicating with two Arduinos with serial. The program works great for a while but then the serial monitor stops showing values in the RX code and will not work again unless the code is uploaded again. Why is this happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;  Transmitting Code&#xA;  Reads potentiometers and sends them through serial&#xA;*/&#xA;&#xA;int data [12];     // to send bytes&#xA;int start [2];&#xA;&#xA;int Pin1A = A0;  &#xA;int Joystick1A;  //crab&#xA;&#xA;int Pin1B = A1;&#xA;int Joystick1B;  //up down&#xA;&#xA;int Pin2A = A2;&#xA;int Joystick2A;   // pitch&#xA;&#xA;int Pin2B = A3;  &#xA;int Joystick2B;  // up down&#xA;&#xA;int Pin3A = A4;   // yaw r-l&#xA;int Joystick3A;&#xA;&#xA;int Pin3B = A5;&#xA;int Joystick3B;   // forward-back&#xA;&#xA;unsigned char checksum0;&#xA;unsigned char checksum1;&#xA;unsigned char checksum2;&#xA;unsigned char checksum3;&#xA;unsigned char checksum4;&#xA;unsigned char checksum5;&#xA;unsigned char handshake;&#xA;unsigned char handshake2;&#xA;unsigned char handshake3;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(4800);&#xA;  Serial1.begin(4800);&#xA;  pinMode(19, INPUT);&#xA;  pinMode(18, OUTPUT);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;// READ THE POTENTIOMETERS:&#xA;&#xA;  Joystick1A = analogRead(Pin1A);   // reads the value of the potentiometer (Joystick1Aue between 0 and 1023)&#xA;  data[0] = Joystick1A &amp;amp; 0xFF; //least significant 8 bit byte&#xA;  data[1] = (Joystick1A &amp;gt;&amp;gt; 8); //most significant 2 bits&#xA;&#xA;  Joystick1B = analogRead(Pin1B);&#xA;  data[2] = Joystick1B &amp;amp; 0xFF;&#xA;  data[3] = (Joystick1B &amp;gt;&amp;gt; 8);&#xA;&#xA;  Joystick2A = analogRead(Pin2A);&#xA;  data[4] = Joystick2A &amp;amp; 0xFF;&#xA;  data[5] = (Joystick2A &amp;gt;&amp;gt; 8);&#xA;&#xA;  Joystick2B = analogRead(Pin2B);   // reads the value of the potentiometer (Joystick1Aue between 0 and 1023)&#xA;  data[6] = Joystick2B &amp;amp; 0xFF; //least significant 8 bit byte&#xA;  data[7] = (Joystick2B &amp;gt;&amp;gt; 8); //most significant 2 bits&#xA;&#xA;  Joystick3A = analogRead(Pin3A);&#xA;  data[8] = Joystick3A &amp;amp; 0xFF;&#xA;  data[9] = (Joystick3A &amp;gt;&amp;gt; 8);&#xA;&#xA;  Joystick3B = analogRead(Pin3B);&#xA;  data[10] = Joystick3B &amp;amp; 0xFF;&#xA;  data[11] = (Joystick3B &amp;gt;&amp;gt; 8);&#xA;&#xA;// CREATE CHECKSUMS:&#xA;&#xA;  checksum0 = ~(data[0]+data[1]) + 1;&#xA;&#xA;  checksum1 = ~(data[2]+data[3]) + 1;&#xA;&#xA;  checksum2 = ~(data[4]+data[5]) + 1;&#xA;&#xA;  checksum3 = ~(data[6]+data[7]) + 1;&#xA;&#xA;  checksum4 = ~(data[8]+data[9]) + 1;&#xA;&#xA;  checksum5 = ~(data[10]+data[11]) + 1;&#xA;// WRITE VALUES AND CHECKSUMS TO SERIAL:&#xA;&#xA;while (Serial1.available()&amp;lt;3) { &#xA;  ; //wait for request from receiver&#xA;}&#xA;  handshake = Serial1.read();&#xA;  handshake2 = Serial1.read(); &#xA;  handshake3 = Serial1.read();&#xA;&#xA;  if ((handshake == 1) &amp;amp;&amp;amp; (handshake2 == 2) &amp;amp;&amp;amp; (handshake3 == 3)) {&#xA;&#xA;Serial1.write(1);&#xA;&#xA;  Serial1.write(data[0]); &#xA;  Serial1.write(data[1]); &#xA;    Serial1.write(checksum0);&#xA;&#xA;  Serial1.write(data[2]);&#xA;  Serial1.write(data[3]); //bytes sent&#xA;    Serial1.write(checksum1);&#xA;&#xA;  Serial1.write(data[4]);&#xA;  Serial1.write(data[5]);&#xA;    Serial1.write(checksum2);&#xA;&#xA;  Serial1.write(data[6]); &#xA;  Serial1.write(data[7]); &#xA;    Serial1.write(checksum3);&#xA;&#xA;  Serial1.write(data[8]);&#xA;  Serial1.write(data[9]); //bytes sent&#xA;    Serial1.write(checksum4);&#xA;&#xA;  Serial1.write(data[10]);&#xA;  Serial1.write(data[11]);&#xA;    Serial1.write(checksum5);&#xA;&#xA;Serial1.write(2);&#xA;&#xA;   delay(10);     // delay in between reads for stability&#xA;  }&#xA;&#xA;// VIEW IN SERIAL MONTIOR:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;  Receving Code&#xA;  Reads bytes from Transmitting Code and put thems back together&#xA;  Applies the read bytes to our motor control board&#xA;*/&#xA;&#xA;unsigned char val[12];    // variable to read the value from the analog pin&#xA;int Joystick1A;      // 0-1024 received from serial&#xA;int Joystick1B;&#xA;int Joystick2A;&#xA;int Joystick2B;      // 0-1024 received from serial&#xA;int Joystick3A;&#xA;int Joystick3B;&#xA;&#xA;unsigned char checksum0;&#xA;unsigned char checksum1;&#xA;unsigned char checksum2;&#xA;unsigned char checksum3;&#xA;unsigned char checksum4;&#xA;unsigned char checksum5;&#xA;unsigned char FirstByte;&#xA;unsigned char LastByte;&#xA;&#xA;unsigned char checkit0;&#xA;unsigned char checkit1;&#xA;unsigned char checkit2;&#xA;unsigned char checkit3;&#xA;unsigned char checkit4;&#xA;unsigned char checkit5;&#xA;&#xA;//ALL MOTORS:&#xA;int V1Direction = 31;&#xA;int V1PWM = 2;     //MOTOR V1 &#xA;int V1Motor;&#xA;&#xA;int V2Direction = 33;&#xA;int V2PWM = 3;     //MOTOR V2&#xA;int V2Motor;&#xA;&#xA;int V3Direction = 35;&#xA;int V3PWM = 4;     //MOTOR V3&#xA;int V3Motor;&#xA;&#xA;int V4Direction = 37;&#xA;int V4PWM = 5;     //MOTOR V4&#xA;int V4Motor;&#xA;&#xA;int H1Direction = 39;&#xA;int H1PWM = 6;     //MOTOR H1&#xA;int H1Motor;&#xA;&#xA;int H2Direction = 41;&#xA;int H2PWM = 7;     //MOTOR H2&#xA;int H2Motor;&#xA;&#xA;int H3Direction = 43;&#xA;int H3PWM = 8;     //MOTOR H3&#xA;int H3Motor;&#xA;&#xA;int H4Direction = 45;&#xA;int H4PWM = 9;     //MOTOR H4&#xA;int H4Motor;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(4800);&#xA;  Serial1.begin(4800);&#xA;//  Serial1.begin(4800); &#xA;  pinMode(10, INPUT);&#xA;  pinMode(18, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Serial1.write(1);&#xA;  Serial1.write(2);&#xA;  Serial1.write(3);&#xA;&#xA;  if (Serial1.available()&amp;gt;18) {  &#xA;&#xA;  FirstByte=Serial1.read();&#xA;&#xA;  if (FirstByte == 1) {&#xA;    val[0]=Serial1.read();         // least significant 8 bits&#xA;    val[1]=Serial1.read();         // most significant 2 bits   &#xA;     checksum0=Serial1.read();     // checksum&#xA;&#xA;    val[2]=Serial1.read();&#xA;    val[3]=Serial1.read();&#xA;     checksum1=Serial1.read();&#xA;&#xA;    val[4]=Serial1.read();&#xA;    val[5]=Serial1.read(); &#xA;     checksum2=Serial1.read();&#xA;&#xA;    val[6]=Serial1.read();         // least significant 8 bits&#xA;    val[7]=Serial1.read();         // most significant 2 bits   &#xA;     checksum3=Serial1.read();     // checksum&#xA;&#xA;    val[8]=Serial1.read();&#xA;    val[9]=Serial1.read();&#xA;     checksum4=Serial1.read();&#xA;&#xA;    val[10]=Serial1.read();&#xA;    val[11]=Serial1.read(); &#xA;     checksum5=Serial1.read();&#xA;&#xA;   LastByte = Serial1.read();&#xA;&#xA;// get the checksum last&#xA;&#xA;    checkit0 = val[0]+val[1]+checksum0;&#xA;    checkit1 = val[2]+val[3]+checksum1;&#xA;    checkit2 = val[4]+val[5]+checksum2; &#xA;    checkit3 = val[6]+val[7]+checksum3;&#xA;    checkit4 = val[8]+val[9]+checksum4;&#xA;    checkit5 = val[10]+val[11]+checksum5; &#xA;&#xA;if (LastByte == 2) {&#xA;  if (checkit0==0)  {&#xA;    Joystick1A = val[1]&amp;lt;&amp;lt;8 | val[0]; }&#xA;&#xA;  if (checkit1==0)  {&#xA;    Joystick1B = val[3]&amp;lt;&amp;lt;8 | val[2]; }&#xA;&#xA;  if (checkit2==0)  {&#xA;    Joystick2A = val[5]&amp;lt;&amp;lt;8 | val[4]; }&#xA;&#xA;  if (checkit3==0)  {&#xA;    Joystick2B = val[7]&amp;lt;&amp;lt;8 | val[6]; }&#xA;&#xA;  if (checkit4==0)  {&#xA;    Joystick3A = val[9]&amp;lt;&amp;lt;8 | val[8]; }&#xA;&#xA;  if (checkit5==0)  {&#xA;    Joystick3B = val[11]&amp;lt;&amp;lt;8 | val[10]; }&#xA;&#xA;}&#xA;else (Serial.println(&quot;Goodbye&quot;));&#xA;    Serial.print(Joystick1A);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(Joystick1B);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(Joystick2A);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(Joystick2B);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(Joystick3A);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(Joystick3B);&#xA;    delay(10);&#xA;&#xA;  }&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16455" LastEditorUserId="37523" LastEditDate="2019-07-22T22:30:42.920" LastActivityDate="2019-07-22T22:30:42.920" Title="Serial Monitor Just Stops Working" Tags="|serial|arduino-mega|communication|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="19791" PostTypeId="2" ParentId="13889" CreationDate="2016-01-21T04:35:43.013" Score="0" Body="&lt;p&gt;In Atmel Studio 7 you can create a project on Arduino Code.&#xA;For instance if you have a code for an Arduino UNO, it will ask for path of the sketch(a.ino file) and ask for device here it will be Atmega 328.&#xA;Now you can build the solution and it will generate code for Atmega 328.&#xA;Now you can rebuild the same solution by changing the device now select  AT90S8515.&#xA;In my case I built the code for a Atmega328. then rebuilt it by changing device to Atmega8. It worked&lt;/p&gt;&#xA;" OwnerUserId="16580" LastActivityDate="2016-01-21T04:35:43.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19792" PostTypeId="1" AcceptedAnswerId="19804" CreationDate="2016-01-21T05:07:02.713" Score="0" ViewCount="127" Body="&lt;p&gt;I have an RGB LED common Anode attached to my Uno and this code detects a long press to turn the LED on and off.  Short presses cycle through colors, then off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that a longpress is 2+sec, but it doesn't register until I release the button.  How would I set this up to execute the code at 2sec regardless of whether the button is released?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's probably not worth my time if it requres too much modification.  I have a working item, it's just not... ideal.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Xhunsigned long keyPrevMillis = 0;&#xA;const unsigned long keySampleIntervalMs = 25;&#xA;&#xA;int redPin = 11;&#xA;int greenPin = 10;&#xA;int bluePin = 9;&#xA;int LEDcolor=0; // 0=White, 1=Red, 2=Green, 3-Blue, 4=Yellow, 5=Purple, 6=Pink, 7=Orange, 8=Off &#xA;int LEDstatus =0; //0=Off, 1=On&#xA;int changed =0; //has the LEDstatus just changed?&#xA;byte longKeyPressCountMax = 80;    // 80 * 25 = 2000 ms&#xA;byte longKeyPressCount = 0;&#xA;&#xA;byte prevKeyState = HIGH;         // button is active low&#xA;const byte keyPin = 2;            // button is connected to pin 2 and GND&#xA;&#xA;// called when button is kept pressed for less than 2 seconds&#xA;void shortKeyPress() &#xA;{&#xA;   Serial.println(&quot;short&quot;);&#xA;   if (LEDstatus==1)&#xA;   {&#xA;      LEDcolor = LEDcolor +1;&#xA;      if (LEDcolor==0) {analogWrite(redPin, 0);analogWrite(greenPin, 0);analogWrite(bluePin, 0);Serial.println(&quot;White&quot;);}&#xA;      if (LEDcolor==1) {analogWrite(redPin, 0);analogWrite(greenPin, 255);analogWrite(bluePin, 255);Serial.println(&quot;Red&quot;);}&#xA;      if (LEDcolor==2) {analogWrite(redPin, 255);analogWrite(greenPin, 0);analogWrite(bluePin, 255);Serial.println(&quot;Green&quot;);}&#xA;      if (LEDcolor==3) {analogWrite(redPin, 255);analogWrite(greenPin, 255);analogWrite(bluePin, 0);Serial.println(&quot;Blue&quot;);}&#xA;      if (LEDcolor==4) {analogWrite(redPin, 0);analogWrite(greenPin, 0);analogWrite(bluePin, 255);Serial.println(&quot;Yellow&quot;);}&#xA;      if (LEDcolor==5) {analogWrite(redPin, 175);analogWrite(greenPin, 255);analogWrite(bluePin, 175);Serial.println(&quot;Purple&quot;);}&#xA;      if (LEDcolor==6) {analogWrite(redPin, 0);analogWrite(greenPin, 255);analogWrite(bluePin, 155);Serial.println(&quot;Pink&quot;);}&#xA;      if (LEDcolor==7) {analogWrite(redPin, 5);analogWrite(greenPin, 215);analogWrite(bluePin, 255);Serial.println(&quot;Orange&quot;);}&#xA;      if (LEDcolor==8) {analogWrite(redPin, 255);analogWrite(greenPin, 255);analogWrite(bluePin, 255);Serial.println(&quot;Off&quot;);LEDstatus=0;}&#xA;   }&#xA;}&#xA;&#xA;// called when button is kept pressed for more than 2 seconds&#xA;void longKeyPress() &#xA;{&#xA;   Serial.println(&quot;long&quot;);&#xA;   if (LEDstatus==0 &amp;amp;&amp;amp; changed==0)&#xA;   {&#xA;      analogWrite(redPin, 0);&#xA;      analogWrite(greenPin, 0); &#xA;      analogWrite(bluePin, 0);&#xA;      LEDcolor=0;&#xA;      changed=1;&#xA;      LEDstatus=1;Serial.println(&quot;On&quot;);&#xA;   }&#xA;   if (LEDstatus==1 &amp;amp;&amp;amp; changed==0)&#xA;   {&#xA;      analogWrite(redPin, 255);&#xA;      analogWrite(greenPin, 255); &#xA;      analogWrite(bluePin, 255);&#xA;      LEDcolor=0;&#xA;      changed=1;&#xA;      LEDstatus=0;Serial.println(&quot;Off&quot;);&#xA;   }&#xA;   changed=0;&#xA;}&#xA;&#xA;// called when key goes from not pressed to pressed&#xA;void keyPress() {&#xA;   Serial.println(&quot;key press&quot;);&#xA;   longKeyPressCount = 0;&#xA;}&#xA;&#xA;&#xA;// called when key goes from pressed to not pressed&#xA;void keyRelease() {&#xA;   Serial.println(&quot;key release&quot;);&#xA;&#xA;   if (longKeyPressCount &amp;gt;= longKeyPressCountMax) {&#xA;      longKeyPress();&#xA;   }&#xA;   else {&#xA;      shortKeyPress();&#xA;   }&#xA;}&#xA;&#xA;void setup() &#xA;{&#xA;   Serial.begin(9600);&#xA;   pinMode(keyPin, INPUT);&#xA;   digitalWrite(keyPin, HIGH);&#xA;   pinMode(redPin, OUTPUT);&#xA;   pinMode(greenPin, OUTPUT);&#xA;   pinMode(bluePin, OUTPUT); &#xA;   analogWrite(redPin, 255);&#xA;   analogWrite(greenPin, 255); &#xA;   analogWrite(bluePin, 255);&#xA;}&#xA;&#xA;void loop() {&#xA;// key management section&#xA;   if (millis() - keyPrevMillis &amp;gt;= keySampleIntervalMs) {&#xA;      keyPrevMillis = millis();&#xA;&#xA;      byte currKeyState = digitalRead(keyPin);&#xA;&#xA;      if ((prevKeyState == HIGH) &amp;amp;&amp;amp; (currKeyState == LOW)) {&#xA;         keyPress();&#xA;      }&#xA;      else if ((prevKeyState == LOW) &amp;amp;&amp;amp; (currKeyState == HIGH)) {&#xA;         keyRelease();&#xA;      }&#xA;      else if (currKeyState == LOW) {&#xA;         longKeyPressCount++;&#xA;      }&#xA;&#xA;      prevKeyState = currKeyState;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16582" LastEditorUserId="313" LastEditDate="2016-01-21T14:29:13.730" LastActivityDate="2016-01-21T14:29:13.730" Title="Changing how a longpress is executed" Tags="|led|button|rgb-led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19793" PostTypeId="1" CreationDate="2016-01-21T05:37:10.090" Score="0" ViewCount="335" Body="&lt;p&gt;Could I use something like this as a capacitive button for my arduino project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.banggood.com/10pcs-25mm-Vintage-Round-Metal-Buttons-Craft-Scrapbooking-Sewing-Suit-Shirt-Button-p-1011485.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/10pcs-25mm-Vintage-Round-Metal-Buttons-Craft-Scrapbooking-Sewing-Suit-Shirt-Button-p-1011485.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect it into something like this... &lt;a href=&quot;http://www.banggood.com/MPR121-Capacitive-Touch-Sensor-Module-For-Raspberry-Pi-Arduino-p-969002.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/MPR121-Capacitive-Touch-Sensor-Module-For-Raspberry-Pi-Arduino-p-969002.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would that make that button a capacitive button? Or am I totally barking up the wrong tree here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="14424" LastActivityDate="2016-01-21T10:15:08.843" Title="Could I use metal buttons as a capacitive button for my arduino project?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19795" PostTypeId="1" CreationDate="2016-01-21T07:35:15.470" Score="5" ViewCount="15374" Body="&lt;p&gt;I want to convert a bitmap into binary array. My bitmap image is 272*208 pixel monochromatic 1bpp image. I'm confused when the width I get from my image is 16 instead of 272, the height is corrected. And when I skip the bitmap header to get bitmap infomation, I got string of meaningless number in my text file.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;TFT.h&amp;gt;&#xA;&#xA;File bmpImage;&#xA;File textFile;&#xA;&#xA;void setup()&#xA;{&#xA;Serial.begin(9600);&#xA;while (!Serial) {&#xA;;&#xA;}&#xA;&#xA;Serial.print(&quot;Initializing SD card...&quot;);&#xA;if (!SD.begin(53)) {&#xA;  Serial.println(&quot;initialization failed!&quot;);&#xA;  return;&#xA;}&#xA;Serial.println(&quot;initialization done.&quot;);&#xA;int height = 0;&#xA;int width = 0;&#xA;&#xA;// Open&#xA;bmpImage = SD.open(&quot;Circle.bmp&quot;, FILE_READ);&#xA;textFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;&#xA;&#xA;bmpImage.seek(0x12);// width in pixel = 16&#xA;width = bmpImage.read();&#xA;bmpImage.seek(0x16);// height in pixel = 208&#xA;height = bmpImage.read();&#xA;Serial.println(width);&#xA;Serial.println(height);&#xA;&#xA;int imageSize = height*width;&#xA;&#xA;bmpImage.seek(0x36);//skip bitmap header&#xA;&#xA;for(int i = 0; i &amp;lt; height; i ++) {&#xA;  for (int j = 0; j &amp;lt; width; j ++) {&#xA;    textFile.write(bmpImage.read());&#xA;    textFile.write(&quot; &quot;);&#xA;  }&#xA;  textFile.write(&quot;\n&quot;);&#xA;}&#xA;&#xA;bmpImage.close();&#xA;textFile.close();&#xA;&#xA;&#xA;&#xA;Serial.println(&quot;done write&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // nothing happens after setup&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16583" LastEditorUserId="4131" LastEditDate="2016-01-21T16:49:33.770" LastActivityDate="2020-06-17T11:50:26.240" Title="How to read bitmap image on Arduino" Tags="|arduino-mega|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19797" PostTypeId="1" CreationDate="2016-01-21T08:48:37.163" Score="0" ViewCount="1209" Body="&lt;p&gt;Is Arduino uno SPI comunication can be also master and slave in the same time?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;OR master 2 slaves in the same time?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I want to recevice data from a sensor and display on OLED (all data transfer with SPI bus)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I master those two device (sensor &amp;amp; OLED) in the same time? (with SS pin to select slave )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OR Can I be both slave(recevices the data from sensor) and master (sent data to OLED) in the same time ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do ? and How can I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I read the SPI example code on the Official website , but I still have no ideal about it)&lt;/p&gt;&#xA;" OwnerUserId="16293" LastActivityDate="2016-01-21T10:04:15.733" Title="Is Arduino uno SPI comunication can be also master and slave in the same time?" Tags="|arduino-uno|spi|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19798" PostTypeId="2" ParentId="19797" CreationDate="2016-01-21T09:24:49.213" Score="1" Body="&lt;p&gt;You can have several devices on an SPI bus. Each must have a chip select. The Arduino SS pin (Uno pin 10) is often used for chip select. Chip select pins should then be in output mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the sensor and display to the SPI bus (MOSI, MISO, SCK) and use a chip select pin for each. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A driver (library) for a device connect to the SPI bus will typically assert the chip select pin and transfer commands and data. The SPI transfer is both read and write at the same time. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-21T09:24:49.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19799" PostTypeId="2" ParentId="19795" CreationDate="2016-01-21T09:41:56.353" Score="5" Body="&lt;p&gt;That was a very raw way of trying to read a &lt;a href=&quot;https://en.wikipedia.org/wiki/BMP_file_format&quot; rel=&quot;nofollow&quot;&gt;BMP&lt;/a&gt; file. There are a lot of assumptions that might give errors.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The file is a BMP file. The header signature is not checked. &lt;/li&gt;&#xA;&lt;li&gt;The image offset is assumed to be directly after the file header. It is not read. &lt;/li&gt;&#xA;&lt;li&gt;The image width is less than 256. Only the lowest byte of the 32-bit image width is read. As 272&gt;256 the low byte is 16.&lt;/li&gt;&#xA;&lt;li&gt;The image height is less than 256. Only the lowest byte of the 32-bit image height is read.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It is a small bitmap but it will take a very long time to read when reading a single byte at a time. There are methods to improve performance but that is an answer to another question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more robust method to read the BMP header and image information is to define them as a struct and read. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct bmp_file_header_t {&#xA;  uint16_t signature;&#xA;  uint32_t file_size;&#xA;  uint16_t reserved[2];&#xA;  uint32_t image_offset;&#xA;};&#xA;&#xA;struct bmp_image_header_t {&#xA;  uint32_t header_size;&#xA;  uint32_t image_width;&#xA;  uint32_t image_height;&#xA;  uint16_t color_planes;&#xA;  uint16_t bits_per_pixel;&#xA;  uint32_t compression_method;&#xA;  uint32_t image_size;&#xA;  uint32_t horizontal_resolution;&#xA;  uint32_t vertical_resolution;&#xA;  uint32_t colors_in_palette;&#xA;  uint32_t important_colors;&#xA;};&#xA;&#xA;bmpImage = SD.open(&quot;Circle.bmp&quot;, FILE_READ);&#xA;...&#xA;// Read the file header&#xA;bmp_file_header_t fileHeader;&#xA;bmpImage.read(&amp;amp;fileHeader, sizeof(fileHeader));&#xA;...&#xA;// Check signature&#xA;...&#xA;// Read the image header&#xA;bmp_image_header_t imageHeader;&#xA;bmpImage.read(&amp;amp;imageHeader, sizeof(imageHeader));&#xA;...&#xA;// Check image size and format&#xA;...&#xA;// Locate the pixels&#xA;bmpImage.seek(fileHeader.image_offset);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The file and image information are stored in little-endian so that works just fine on an AVR. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-21T17:28:32.293" LastActivityDate="2016-01-21T17:28:32.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19800" PostTypeId="2" ParentId="19795" CreationDate="2016-01-21T09:42:05.753" Score="3" Body="&lt;p&gt;First of all I suggest you to read the full specification of the bmp file header (for instance on &lt;a href=&quot;https://en.wikipedia.org/wiki/BMP_file_format&quot; rel=&quot;nofollow noreferrer&quot;&gt;wikipedia&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Particularly see that&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can have a color table (palette): consequently the starting address of the bitmap data CAN not be 0x36&lt;/li&gt;&#xA;&lt;li&gt;The pixels are not stored one per byte, but can be packed (see &lt;a href=&quot;https://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pixel storage&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;li&gt;There are different type of headers&lt;/li&gt;&#xA;&lt;li&gt;Width and Height are 4 byte integers, so your width is fine (272 = 256 + 16)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This said, &lt;em&gt;if&lt;/em&gt; your bitmap has a standard &lt;code&gt;BITMAPINFOHEADER&lt;/code&gt; header, and &lt;em&gt;if&lt;/em&gt; your bitmap has a 24 bit standard coding (16 millions of colors) you can do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int32_t readNbytesInt(File *p_file, int position, byte nBytes)&#xA;{&#xA;    if (nBytes &amp;gt; 4)&#xA;        return 0;&#xA;&#xA;    p_file-&amp;gt;seek(position);&#xA;&#xA;    int32_t weight = 1;&#xA;    int32_t result = 0;&#xA;    for (; nBytes; nBytes--)&#xA;    {&#xA;        result += weight * p_file-&amp;gt;read();&#xA;        weight &amp;lt;&amp;lt;= 8;&#xA;    }&#xA;    return result;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    while (!Serial);&#xA;&#xA;    Serial.print(&quot;Initializing SD card...&quot;);&#xA;    if (!SD.begin(53)) {&#xA;        Serial.println(&quot;initialization failed!&quot;);&#xA;        while (1); // &amp;lt;- this is how you should block execution, not with returns&#xA;    }&#xA;    Serial.println(&quot;initialization done.&quot;);&#xA;&#xA;&#xA;    // Open&#xA;    File bmpImage = SD.open(&quot;Circle.bmp&quot;, FILE_READ);&#xA;    File textFile = SD.open(&quot;test.txt&quot;, FILE_WRITE);&#xA;&#xA;    int32_t dataStartingOffset = readNbytesInt(&amp;amp;bmpImage, 0x0A, 4);&#xA;&#xA;    // Change their types to int32_t (4byte)&#xA;    int32_t width = readNbytesInt(&amp;amp;bmpImage, 0x12, 4);&#xA;    int32_t height = readNbytesInt(&amp;amp;bmpImage, 0x16, 4);&#xA;    Serial.println(width);&#xA;    Serial.println(height);&#xA;&#xA;    int16_t pixelsize = readNbytesInt(&amp;amp;bmpImage, 0x1C, 2);&#xA;&#xA;    if (pixelsize != 24)&#xA;    {&#xA;        Serial.println(&quot;Image is not 24 bpp&quot;);&#xA;        while (1);&#xA;    }&#xA;&#xA;    bmpImage.seek(dataStartingOffset);//skip bitmap header&#xA;&#xA;    // 24bpp means you have three bytes per pixel, usually B G R&#xA;&#xA;    byte R, G, B;&#xA;&#xA;    for(int32_t i = 0; i &amp;lt; height; i ++) {&#xA;        for (int32_t j = 0; j &amp;lt; width; j ++) {&#xA;            B = bmpImage.read();&#xA;            G = bmpImage.read();&#xA;            R = bmpImage.read();&#xA;            textFile.print(&quot;R&quot;);&#xA;            textFile.print(R);&#xA;            textFile.print(&quot;G&quot;);&#xA;            textFile.print(G);&#xA;            textFile.print(&quot;B&quot;);&#xA;            textFile.print(B);&#xA;            textFile.print(&quot; &quot;);&#xA;        }&#xA;        textFile.print(&quot;\n&quot;);&#xA;    }&#xA;&#xA;    bmpImage.close();&#xA;    textFile.close();&#xA;&#xA;    Serial.println(&quot;done write&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The text output of this should be a file with an array of strings like &lt;code&gt;R10G100B25&lt;/code&gt;, where R is the red component of the pixel, G is the green component and B the blue one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, this is only compatible with the 24bpp format. If you want to support more formats you will need to read the specs and code them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me know if this works for you&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="6936" LastEditDate="2017-06-06T01:10:06.767" LastActivityDate="2017-06-06T01:10:06.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19801" PostTypeId="2" ParentId="16301" CreationDate="2016-01-21T09:59:32.167" Score="1" Body="&lt;p&gt;A typical method of increasing the number of writes to EEPROM is to use a vector of counters instead of a single value. The counter value is written to the EEPROM vector in a cyclic fashion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On startup the vector is searched for current counter value, i.e. the highest counter in the vector. The write index is restored by locating the lowest counter value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of writes is increased with the length of the vector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please read more about this method &lt;a href=&quot;http://www.atmel.com/images/doc2526.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-21T09:59:32.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19802" PostTypeId="2" ParentId="19797" CreationDate="2016-01-21T10:04:15.733" Score="1" Body="&lt;p&gt;SPI is bi-directional, so sending data or receiving data doesn't indicate if it's a master or a slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The master is the one that initiates the communications, that's all. So the arduino is a master in both cases. The master send data to the OLED. The master requests data from the sensor.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-21T10:04:15.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19803" PostTypeId="2" ParentId="19793" CreationDate="2016-01-21T10:15:08.843" Score="1" Body="&lt;p&gt;Yes, that would work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing to watch out for is that the buttons might be plastic with a thin layer of metal on top (Chemical vapor deposition). &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-21T10:15:08.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19804" PostTypeId="2" ParentId="19792" CreationDate="2016-01-21T11:30:07.497" Score="1" Body="&lt;p&gt;I've rewritten the code entirely. Not that yours was terrible, it was just easier for me to start from scratch. You are left with a very empty &lt;code&gt;loop()&lt;/code&gt;, which I always prefer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code contains three 'colours' and an OFF state. You can add as many other colours as you wish: add an enumeration to &lt;code&gt;_LED_STATE&lt;/code&gt; and then add a corresponding &lt;code&gt;case(&amp;lt;NEW_COLOUR&amp;gt;)&lt;/code&gt; statement in &lt;code&gt;LEDcontrol()&lt;/code&gt;. I haven't included any &lt;code&gt;analogWrite()&lt;/code&gt; functions - or in fact any declarations for the LED pins at all - because I'm a little too lazy but it should be obvious where to put them within the case statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that in the final &lt;code&gt;case()&lt;/code&gt; statement, the LED state is changed from green to off. This means that a short press will turn the LED off after it has cycled through all the other colours, but will stay off until a long press. If you only want long pressed to switch off/on, change line 103 to &lt;code&gt;eLED_STATE = _LED_STATE_RED;&lt;/code&gt;, or whichever the first colour is.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define btn 3   // button pin&#xA;&#xA;#define SHORT_PRESS 100     // useful for debouncing, can be changed&#xA;#define LONG_PRESS  2000    // defines how long a 'long press' is&#xA;#define CYCLE       false&#xA;#define SHOW        true&#xA;&#xA;//--// You can add new colours in this enum block&#xA;enum _LED_STATE&#xA;{&#xA;    _LED_STATE_OFF,&#xA;    _LED_STATE_RED,&#xA;    _LED_STATE_BLUE,&#xA;    _LED_STATE_GREEN&#xA;};&#xA;&#xA;_LED_STATE eLED_STATE = _LED_STATE_OFF;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(btn, OUTPUT);&#xA;    LEDcontrol(SHOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;    if (digitalRead(btn))&#xA;        btnPressed();&#xA;}&#xA;&#xA;void btnPressed()&#xA;{&#xA;    unsigned long tStart = millis();&#xA;&#xA;    //--// Loop continuously while button is pressed&#xA;    while (digitalRead(btn))&#xA;    {&#xA;        //--// If LONG_PRESS is exceeded...&#xA;        if (millis() &amp;gt; tStart + LONG_PRESS)&#xA;        {&#xA;            //--// If LED is off, turn it on&#xA;            if (eLED_STATE == _LED_STATE_OFF)&#xA;                eLED_STATE = _LED_STATE_RED;        // Choose 'starting' colour&#xA;            //--// If LED is on, turn if off&#xA;            else&#xA;                eLED_STATE = _LED_STATE_OFF;&#xA;            //--// Update LED to display new eLED_STATE&#xA;            LEDcontrol(SHOW);&#xA;            //--// Now loop here until button is released&#xA;            while (digitalRead(btn));&#xA;        }&#xA;    }&#xA;&#xA;    //--// If button is released in between the two press times&#xA;    if ((millis() &amp;gt; tStart + SHORT_PRESS) &amp;amp;&amp;amp; (millis() &amp;lt; tStart + LONG_PRESS))&#xA;    {&#xA;        //--// Ignore if LED is off         ////// REMOVE ////////////////////&#xA;        if (eLED_STATE == _LED_STATE_OFF)   ////////// IF ////////////////////&#xA;            return;                         ///////////// NECESSARY //////////&#xA;&#xA;        //--// Change the LED colour&#xA;        LEDcontrol(CYCLE);&#xA;        //--// Update LED to display new eLED_STATE&#xA;        LEDcontrol(SHOW);&#xA;    }&#xA;&#xA;    //--// This helps to debounce; experiment with it&#xA;    delay(10);&#xA;}&#xA;&#xA;void LEDcontrol(bool SHOW_OR_CYCLE)&#xA;{&#xA;    switch (eLED_STATE)&#xA;    {&#xA;        case(_LED_STATE_RED) :&#xA;        {&#xA;            if (SHOW_OR_CYCLE)&#xA;            {&#xA;                // paint it red&#xA;                return;&#xA;            }&#xA;            eLED_STATE = _LED_STATE_GREEN;&#xA;            return;&#xA;        }&#xA;        case(_LED_STATE_GREEN) :&#xA;        {&#xA;            if (SHOW_OR_CYCLE)&#xA;            {&#xA;                // paint it green&#xA;                return;&#xA;            }&#xA;            eLED_STATE = _LED_STATE_BLUE;&#xA;            return;&#xA;        }&#xA;        case(_LED_STATE_BLUE) :&#xA;        {&#xA;            if (SHOW_OR_CYCLE)&#xA;            {&#xA;                // paint it blue&#xA;                return;&#xA;            }&#xA;            //--// What happens after last colour? Next colour or OFF?&#xA;            eLED_STATE = _LED_STATE_OFF;&#xA;            return;&#xA;        }&#xA;        case(_LED_STATE_OFF) :&#xA;        {&#xA;            if (SHOW_OR_CYCLE)&#xA;            {&#xA;                // paint it black&#xA;                return;&#xA;            }&#xA;            eLED_STATE = _LED_STATE_RED;&#xA;            return;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-01-21T11:30:07.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19805" PostTypeId="2" ParentId="286" CreationDate="2016-01-21T12:34:10.277" Score="8" Body="&lt;p&gt;A simple solution is to use a &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheduler&lt;/a&gt;. There are several implementations. This describes shortly one that is available for AVR and SAM based boards. Basically a single call will start a task; &quot;sketch within a sketch&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;....&#xA;void setup()&#xA;{&#xA;  ...&#xA;  Scheduler.start(taskSetup, taskLoop);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Scheduler.start() will add a new task that will run the taskSetup once and then repeatedly call taskLoop just as the Arduino sketch works. The task has its own stack. The size of the stack is an optional parameter. Default stack size is 128 bytes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To allow context switching the tasks need to call &lt;a href=&quot;https://www.arduino.cc/en/Reference/SchedulerYield&quot; rel=&quot;nofollow noreferrer&quot;&gt;yield()&lt;/a&gt; or &lt;a href=&quot;https://www.arduino.cc/en/Reference/Delay&quot; rel=&quot;nofollow noreferrer&quot;&gt;delay()&lt;/a&gt;. There is also a support macro for waiting for a condition. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;await(Serial.available());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The macro is syntactic sugar for the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (!(Serial.available())) yield();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Await can also be used to synchronize tasks. Below is an example snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int taskEvent = 0;&#xA;#define signal(evt) do { await(taskEvent == 0); taskEvent = evt; } while (0)&#xA;...&#xA;void taskLoop()&#xA;{&#xA;  await(taskEvent);&#xA;  switch (taskEvent) {&#xA;  case 1: &#xA;  ...&#xA;  }&#xA;  taskEvent = 0;&#xA;}&#xA;...&#xA;void loop()&#xA;{&#xA;  ...&#xA;  signal(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For further details see the &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/tree/master/examples&quot; rel=&quot;nofollow noreferrer&quot;&gt;examples&lt;/a&gt;. There are examples from multiple LED blink to debounce button and a simple shell with non-blocking command line read. Templates and namespaces can be used to help structure and reduce the source code. Below &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/blob/master/examples/SchedulerBlinkTemplateFunctions/SchedulerBlinkTemplateFunctions.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;sketch&lt;/a&gt; shows how to use template functions for multi-blink. It is sufficient with 64 bytes for the stack. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;&#xA;template&amp;lt;int pin&amp;gt; void setupBlink()&#xA;{&#xA;  pinMode(pin, OUTPUT);&#xA;}&#xA;&#xA;template&amp;lt;int pin, unsigned int ms&amp;gt; void loopBlink()&#xA;{&#xA;  digitalWrite(pin, HIGH);&#xA;  delay(ms);&#xA;  digitalWrite(pin, LOW);&#xA;  delay(ms);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Scheduler.start(setupBlink&amp;lt;11&amp;gt;, loopBlink&amp;lt;11,500&amp;gt;, 64);&#xA;  Scheduler.start(setupBlink&amp;lt;12&amp;gt;, loopBlink&amp;lt;12,250&amp;gt;, 64);&#xA;  Scheduler.start(setupBlink&amp;lt;13&amp;gt;, loopBlink&amp;lt;13,1000&amp;gt;, 64);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  yield();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also a &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/blob/master/examples/SchedulerBenchmark/SchedulerBenchmark.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;benchmark&lt;/a&gt; to give some idea of the performance, i.e. time to start task, context switch, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last, there are a few support classes for task level synchronization and communication; &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/blob/master/Scheduler/Queue.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;Queue&lt;/a&gt; and &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/blob/master/Scheduler/Semaphore.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;Semaphore&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2017-05-01T19:24:10.847" LastActivityDate="2017-05-01T19:24:10.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19807" PostTypeId="2" ParentId="19795" CreationDate="2016-01-21T14:02:18.200" Score="2" Body="&lt;p&gt;Or you could keep your old code with some adjustments, if you just want to read your image without bothering with too many checks.&lt;/p&gt;&#xA;&lt;p&gt;Change the type of imageSize to &lt;code&gt;unsigned long&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The height and width are 4-byte fields, so a single read() wont cut it. You have to declare the height and width as &lt;em&gt;long&lt;/em&gt; or &lt;em&gt;int32_t&lt;/em&gt; variables and then read 4 bytes at each offset, while using bit shifting to assemble the bytes into one number and remembering that it's little endian.&#xA;Something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;long width |= bmpImage.read();&#xA;width |= (long)(bmpImage.read()) &amp;lt;&amp;lt; 8;&#xA;width |= (long)(bmpImage.read()) &amp;lt;&amp;lt; 16;&#xA;width |= (long)(bmpImage.read()) &amp;lt;&amp;lt; 24;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Repeat this to get the height but use &lt;em&gt;abs()&lt;/em&gt; to get the absolute value since its usually negative.&#xA;You can also check for a colour table; usually the ColorDepth field is a good indicator (offset 28); if its less than 16, then you should expect a colour table. But if you know this already, you can skip it and get to the start offset, usually 0x36.&#xA;Your current code doesnt take the padding into account (even though your image doesn't have any padding) and it also isnt using the actual image width in bytes. To get this width, assuming the BMP uses RGB888 24 bits per pixel:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;width = ((width * 24) + 31) / 32;&#xA;width *= 4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With this, you can now read each row, though its usually arranged bottom-up. However, you arent writing properly to the file. You should use &lt;code&gt;textfile.print()&lt;/code&gt; and not &lt;code&gt;write()&lt;/code&gt;; the former will write the decimal value of each byte to your file while the latter will write the exact un-encoded byte to the text file, which would result in a lot of gibberish when you try to display the file's contents, say on Notepad, since the range of printable characters (under default ASCII encoding) is between 32 - 127 and your image probably has lots of bytes outside that range.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2020-06-17T11:50:26.240" LastActivityDate="2020-06-17T11:50:26.240" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="19808" PostTypeId="1" CreationDate="2016-01-21T14:30:50.803" Score="6" ViewCount="27790" Body="&lt;p&gt;I have bought a 2.5&amp;quot; TFT shield online, which is equipped with the ILI9341 controller. I need to dim the intensity of the background LEDs to match ambient light.&lt;/p&gt;&#xA;&lt;p&gt;This particular shield does not provide a pin to control the intensity of the LEDs with PWM via a separate input, so I need to dim the background LEDs of this display via software.&lt;/p&gt;&#xA;&lt;p&gt;The zip file with the libraries can be downloaded &lt;a href=&quot;http://forum.arduino.cc/index.php?action=dlattach;topic=314613.0;attach=121865&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Does one of you know how can issue a command to the TFT display to dim the background LEDs?&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&lt;h1&gt;UPDATE 1:&lt;/h1&gt;&#xA;&lt;p&gt;I wrote a new function to set the display's brightness by controlling the background LEDs, but something is missing as I can seem to be writing correctly to the display. So I'm trying to get the display to answer to a known command first, like 0x28 (Display Off).&lt;/p&gt;&#xA;&lt;p&gt;The new function is defined in Adafruit_TFTLCD.cpp:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Set display brightness (background LED's)&#xA;void Adafruit_TFTLCD::setDisplayBrightness(uint8_t x) {&#xA;  // Try with 0x28 (Display Off) to see if display reacts&#xA;  writeRegister8(0x28, 0);&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function prototype is defined in Adafruit_TFTLCD.h&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// New functions&#xA;void setDisplayBrightness(uint8_t x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then I call the function in my main loop. To make sure, I first write some rectangles on screen, wait 5 seconds, then fill the screen with blue, call the new function and enter an endless loop so no other commands can interfere:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  tft.fillScreen(BLUE);  &#xA;  tft.setDisplayBrightness(10); // Which really is command 0x28 to test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Any clues what I might be missing?&lt;/p&gt;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&lt;p&gt;UPDATE 2:&lt;/p&gt;&#xA;&lt;p&gt;I got so far as to have the ILI9341 react to some commands, but not all the time, and not to all commands. I suspect there is something in the way you issue the commands that I'm missing( timing?, sequence?, other?)&lt;/p&gt;&#xA;&lt;p&gt;Here is what I have found out so far:&lt;/p&gt;&#xA;&lt;p&gt;I can get the display to react to the Display Off command (0x28), but only when I issue it in the begin(..) function. So, the original code in Adafruit_TFTLCD.cpp is like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_TFTLCD::begin(uint16_t id) {&#xA;...&#xA;writeRegister8(ILI9341_DISPLAYON, 0); &#xA;delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If I change it to the following the display reacts by remaining white:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_TFTLCD::begin(uint16_t id) {&#xA;...&#xA;writeRegister8(ILI9341_DISPLAYON, 0); &#xA;writeRegister8(ILI9341_DISPLAYOFF, 0); // Display off is declared as 0x28&#xA;delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So, I have a reaction to command 28h.&lt;/p&gt;&#xA;&lt;p&gt;Then I tried function 0x51 like this in the begin(...) function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_TFTLCD::begin(uint16_t id) {&#xA;...&#xA;writeRegister8(ILI9341_DISPLAYON, 0); &#xA;delay(500);&#xA;writeRegister8(0x51, 0x80); // Test command 0x51 - background intensity&#xA;delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;To no effect :-(&lt;/p&gt;&#xA;&lt;p&gt;I even added command 0xBE (background PWM frequency) to see if it had any effect, but nothing :-(&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_TFTLCD::begin(uint16_t id) {&#xA;  ...&#xA;  writeRegister8(ILI9341_DISPLAYON, 0);&#xA;  writeRegister8(0xbe, 0x80);&#xA;  delay(500);&#xA;  writeRegister8(0x51, 0x0);&#xA;  delay(500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Also if I issue the 0x28 command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;writeRegister8(ILI9341_DISPLAYOFF, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;elsewhere in Adafruit_TFTLCD (e.g. in FillScreen, Fill Rect etc, it doesn't work either).&lt;/p&gt;&#xA;&lt;p&gt;Any ideas? They would be highly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="16218" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2020-03-02T05:11:06.703" Title="How to dim background LEDs on TFT display with ILI9341" Tags="|tft|" AnswerCount="5" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="19809" PostTypeId="2" ParentId="4273" CreationDate="2016-01-21T14:48:13.013" Score="0" Body="&lt;p&gt;Do you want to use a pushbutton to control the speed of the motor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then one way to go would be to increment a variable by say 10 every time the switch is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In pseudocode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// In the setup section:&#xA;speed =0&#xA;&#xA;// In the main loop:&#xA;Read pushbutton&#xA;if different from previous state then speed = speed + 5&#xA;if speed &amp;gt; 255 then speed = 0 // Go back to zero if over 255&#xA;&#xA;analogWrite(pin x, speed)  // This sets the PWM value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to have a more fancy control then you could increment speed every second by 5 while the pushbutton remains pressed, and also go back to zero speed in small decrement instead of in a single step.&lt;/p&gt;&#xA;" OwnerUserId="16218" LastActivityDate="2016-01-21T14:48:13.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19810" PostTypeId="1" CreationDate="2016-01-21T14:50:52.640" Score="1" ViewCount="5769" Body="&lt;p&gt;I have an arduino micro which I want to program from my Kubuntu 15.10 system. I installed the arduino software using apt-get, but when I try to upload the program (for test purpose I use the Basics\BareMinimum sketch) I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Found programmer: Id = &quot;0.00 V1&quot;; type =  &#xA;    Software Version = 0..; Hardware Version = 0.0&#xA;avrdude: error: buffered memory access not supported. Maybe it isn't&#xA;a butterfly/AVR109 but a AVR910 device?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The proper device &quot;Arduino Micro&quot; is selected and also the proper port &quot;/tty/ACM0&quot;. I found people on the internet which have the same error and could solve it by using another USB port or cable. But I tried it with two different cables and different ports and didn't manage to get it working. I even tried it on my Laptop running an older version of Kubuntu which produced the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I tried the newest version of the Arduino software from the arduino homepage. With this I get a different error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;/dev/ttyACM0&quot;: Device or resource busy&#xA;avrdude: ser_send(): write error: Bad file descriptor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My user is added to the dialout group, so I should have access to the port. It is also the right port as the port disappears from the arduino menu when I unplug the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino itself shouldn't be the problem, as I can upload the sketch from another windows laptop without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: when I plug in the arduino, the following is added to the &lt;code&gt;dmesg&lt;/code&gt; output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[ 8390.293960] usb 1-2: new full-speed USB device number 6 using xhci_hcd&#xA;[ 8390.424861] usb 1-2: New USB device found, idVendor=2341, idProduct=8037&#xA;[ 8390.424863] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0&#xA;[ 8390.424864] usb 1-2: Product: Arduino Micro&#xA;[ 8390.424865] usb 1-2: Manufacturer: Arduino LLC&#xA;[ 8390.425283] cdc_acm 1-2:1.0: ttyACM0: USB ACM device&#xA;[ 8390.426815] input: Arduino LLC Arduino Micro as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.2/0003:2341:8037.0007/input/input21&#xA;[ 8390.482163] hid-generic 0003:2341:8037.0007: input,hidraw4: USB HID v1.01 Mouse [Arduino LLC Arduino Micro] on usb-0000:00:14.0-2/input2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16590" LastEditorUserId="10794" LastEditDate="2016-01-25T09:39:07.617" LastActivityDate="2017-09-21T21:17:43.997" Title="Error uploading Arduino Micro Sketch using Kubuntu" Tags="|uploading|arduino-micro|ubuntu|" AnswerCount="5" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="19811" PostTypeId="2" ParentId="19787" CreationDate="2016-01-21T16:18:55.050" Score="8" Body="&lt;p&gt;I have found that this was caused by reading the analog pin to many times in a short period of time. I replaced &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ldrState = map(analogRead(ldrPin), ldrMin, ldrMax, 0, 100);&#xA;  Serial.println(analogRead(ldrPin));&#xA;  if (serialCount == 1000) {&#xA;    Serial.println(ldrState);&#xA;    serialCount = 0;&#xA;  } else {&#xA;    serialCount ++;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (serialCount == 10000) {&#xA;  ldrState = map(analogRead(ldrPin), ldrMin, ldrMax, 0, 100);&#xA;  Serial.println(ldrState);&#xA;  serialCount = 0;&#xA;} else {&#xA;  serialCount ++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although I thought of this approach before, my mistake was that I was still reading the sensor every time the code loops, I just wasn't printing it to the serial monitor until each 100th loop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This still gives me a reading several times per second, which is way more then I need. Anyway, now I know that I can't read my ESP8266 Analog pin to many times per second or the wifi will disconnect (at least when using it with the Arduino IDE)&lt;/p&gt;&#xA;" OwnerUserId="16572" LastActivityDate="2016-01-21T16:18:55.050" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19812" PostTypeId="2" ParentId="19788" CreationDate="2016-01-21T16:43:42.577" Score="1" Body="&lt;p&gt;Here the setup block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php &#xA;    require(&quot;php_serial.class.php&quot;);&#xA;    $serial = new phpSerial();&#xA;    $serial-&amp;gt;deviceSet(&quot;/dev/ttyACM0&quot;);&#xA;    $serial-&amp;gt;confBaudRate(9600);&#xA;    $serial-&amp;gt;confParity(&quot;none&quot;);&#xA;    $serial-&amp;gt;confCharacterLength(8);&#xA;    $serial-&amp;gt;confStopBits(1);&#xA;    $serial-&amp;gt;confFlowControl(&quot;none&quot;);&#xA;    $conect = mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;) or print (mysql_error()); &#xA;    mysql_select_db(&quot;ANM&quot;, $conect) or print(mysql_error()); &#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here the connection block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php &#xA;    $serial-&amp;gt;deviceOpen();&#xA;    exec(&quot;echo 'HEYARD' &amp;gt; /dev/ttyACM0&quot;);&#xA;    sleep(1);&#xA;    $read = $serial-&amp;gt;readPort();&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16576" LastActivityDate="2016-01-21T16:43:42.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19813" PostTypeId="2" ParentId="16429" CreationDate="2016-01-21T17:23:05.777" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to capture good sound with Aduino? I need to record street / birds / nature sounds.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer is &quot;no&quot; for AVR based Arduino boards. They have simply too low sampling rate, ADC resolution, limited buffering memory and processing speed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ADC sample rate is at most 9 K samples per second (112 us per sample) at highest resolution (10 bits). The resolution can be improved (e.g. 12 bits) by using &lt;a href=&quot;http://www.atmel.com/images/doc8003.pdf&quot; rel=&quot;nofollow&quot;&gt;oversampling&lt;/a&gt; but this is at the cost of sampling frequency. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno has only 2K byte memory. Using all that for buffering would give at most 1 K samples. That is little over a second sound data. A SD file could be used but requires a lot of smart programming to not drop samples at max sampling rate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Low quality, 8-bit samples, then &quot;yes&quot;. See &lt;a href=&quot;http://apcmag.com/arduino-projects-digital-audio-recorder.htm/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now an Arduino Due is much more powerful, has much more memory, etc. See &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-21T18:02:46.363" LastActivityDate="2016-01-21T18:02:46.363" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19814" PostTypeId="2" ParentId="19736" CreationDate="2016-01-21T18:09:51.277" Score="1" Body="&lt;p&gt;Most probably you are using &lt;code&gt;sim900&lt;/code&gt; or &lt;code&gt;sim800&lt;/code&gt; module. These modules would be either fixed to a certain baudrate like &lt;code&gt;9600&lt;/code&gt; or &lt;code&gt;115200&lt;/code&gt;, OR the module might be at &lt;code&gt;auto-baud&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In auto baud mode you need to send &lt;code&gt;AT\r&lt;/code&gt; to the modem after the modem is switched ON so it can know what baud you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check the following...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://GSM%20Modem/Module%20not%20responding%20to%20AT%20commands%20after%20firmware%20Upgrade??&quot; rel=&quot;nofollow&quot;&gt;GSM Modem/Module not responding to AT commands after firmware Upgrade??&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://simcom.ee/documents/SIM900/SIM900_Serial%20Port_Application%20Note_V1.03.pdf&quot; rel=&quot;nofollow&quot;&gt;Serial port AN&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3277" LastActivityDate="2016-01-21T18:09:51.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19815" PostTypeId="2" ParentId="17780" CreationDate="2016-01-21T18:16:49.070" Score="0" Body="&lt;p&gt;This is a question about data representation. The value you are entering is a string, a sequence of characters, e.g. 0x42. The string can be parsed and converted to binary form either on the transmitting or receiving side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The string must first be checked that it is valid. In this case a valid hex or decimal number. There are conversion functions that do both at the same time. The standard string function &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gaf8ce3b8dae3d45c34c3b172de503f7b3&quot; rel=&quot;nofollow&quot;&gt;strtol&lt;/a&gt;() is perfect for the job. With zero as base argument it will parse both hex, oct and dec number formats. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Receive string &#xA;char buf[BUF_MAX];&#xA;...&#xA;// Convert string to number&#xA;char* bp;&#xA;long value = strtol(buf, &amp;amp;bp, 0);&#xA;bool valid = (*bp == 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also an unsigned variant, &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gaea44aa48bda8261f794dcb2d1e7ab2b2&quot; rel=&quot;nofollow&quot;&gt;strtoul&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-21T18:16:49.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19816" PostTypeId="1" CreationDate="2016-01-21T19:52:38.880" Score="0" ViewCount="136" Body="&lt;p&gt;for my rc robot I want to use ir to send/receive the value from a jostick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible ? I can't use any other radio chip like nrf24l01.&lt;/p&gt;&#xA;" OwnerUserId="16323" LastActivityDate="2016-01-21T22:45:29.657" Title="Send analog value over IR?" Tags="|robotics|ir|wireless|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19817" PostTypeId="1" CreationDate="2016-01-21T19:58:49.440" Score="1" ViewCount="1537" Body="&lt;p&gt;I've just installed the last version of Arduino 1.6.7 plug my Arduino SmartEverything (&lt;a href=&quot;http://www.smarteverything.it/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.smarteverything.it/&lt;/a&gt;) to OS X 10.11.2, try to compile this project: &lt;a href=&quot;https://github.com/nicolsc/sigfox-weather-station/blob/master/sigfox_smart_weather.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/nicolsc/sigfox-weather-station/blob/master/sigfox_smart_weather.ino&lt;/a&gt; But i got this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware &quot;/Applications/Arduino.app/Contents/Java/hardware&quot; -hardware &quot;/Users/nunito/Library/Arduino15/packages&quot; -tools &quot;/Applications/Arduino.app/Contents/Java/tools-builder&quot; -tools &quot;/Applications/Arduino.app/Contents/Java/hardware/tools/avr&quot; -tools &quot;/Users/nunito/Library/Arduino15/packages&quot; -built-in-libraries &quot;/Applications/Arduino.app/Contents/Java/libraries&quot; -libraries &quot;/Users/nunito/Documents/Arduino/libraries&quot; -fqbn=AMEL:samd:AMEL_SmartEverything_native -vid-pid=0X2341_0XE002 -ide-version=10607 -build-path &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp&quot; -warnings=none -prefs=build.warn_data_percentage=75 -verbose &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/arduino_50d3a89dbbfb2b67c903ba23d4913431/sketch_jan21c.ino&quot;&#xA;/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware &quot;/Applications/Arduino.app/Contents/Java/hardware&quot; -hardware &quot;/Users/nunito/Library/Arduino15/packages&quot; -tools &quot;/Applications/Arduino.app/Contents/Java/tools-builder&quot; -tools &quot;/Applications/Arduino.app/Contents/Java/hardware/tools/avr&quot; -tools &quot;/Users/nunito/Library/Arduino15/packages&quot; -built-in-libraries &quot;/Applications/Arduino.app/Contents/Java/libraries&quot; -libraries &quot;/Users/nunito/Documents/Arduino/libraries&quot; -fqbn=AMEL:samd:AMEL_SmartEverything_native -vid-pid=0X2341_0XE002 -ide-version=10607 -build-path &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp&quot; -warnings=none -prefs=build.warn_data_percentage=75 -verbose &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/arduino_50d3a89dbbfb2b67c903ba23d4913431/sketch_jan21c.ino&quot;&#xA;Build options changed, rebuilding all&#xA;&quot;&quot;   -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_SMARTEVERYTHING -DARDUINO_ARCH_SAMD  -D__SAMD21J18A__        &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/cores/arduino&quot; &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/variants/AMEL_SmartEverything&quot; &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp/sketch/sketch_jan21c.ino.cpp&quot; -o &quot;/dev/null&quot;&#xA;&quot;&quot;   -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_SMARTEVERYTHING -DARDUINO_ARCH_SAMD  -D__SAMD21J18A__        &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/cores/arduino&quot; &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/variants/AMEL_SmartEverything&quot; &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp/sketch/sketch_jan21c.ino.cpp&quot; -o &quot;/dev/null&quot;&#xA;&quot;&quot;   -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_SMARTEVERYTHING -DARDUINO_ARCH_SAMD  -D__SAMD21J18A__        &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/cores/arduino&quot; &quot;-I/Users/nunito/Library/Arduino15/packages/AMEL/hardware/samd/1.1.0/variants/AMEL_SmartEverything&quot; &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp/sketch/sketch_jan21c.ino.cpp&quot; -o &quot;/var/folders/52/_nghc_ms7p52tqr5zdbwvj240000gn/T/build50d3a89dbbfb2b67c903ba23d4913431.tmp/preproc/ctags_target_for_gcc_minus_e.cpp&quot;&#xA;exec: &quot;-w&quot;: executable file not found in $PATH&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ksne5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ksne5.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16595" LastActivityDate="2016-01-22T08:00:17.963" Title="Error compiling Arduino" Tags="|compile|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19818" PostTypeId="1" AcceptedAnswerId="19819" CreationDate="2016-01-21T21:32:26.760" Score="2" ViewCount="1059" Body="&lt;p&gt;I have a PM10 sensor that I'd like to get the values from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the official documentation from the sensor: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/kyNv5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kyNv5.png&quot; alt=&quot; Sensor documentation &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked as serial communication, but how do i process byte by byte of information if it's coming in byte at a time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm looking at this example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;&amp;lt;Arduino is ready&amp;gt;&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  recvOneChar();&#xA;  showNewData();&#xA;}&#xA;&#xA;void recvOneChar() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    receivedChar = Serial.read();&#xA;    newData = true;&#xA;  }&#xA;}&#xA;&#xA;void showNewData() {&#xA;  if (newData == true) {&#xA;    Serial.print(&quot;This just in ... &quot;);&#xA;    Serial.println(receivedChar);&#xA;    newData = false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally, i'd like to get the PM2 and PM10 values and print them out. &lt;/p&gt;&#xA;" OwnerUserId="16593" LastActivityDate="2016-01-22T19:01:42.953" Title="Processing Serial data" Tags="|serial|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19819" PostTypeId="2" ParentId="19818" CreationDate="2016-01-21T21:43:30.377" Score="3" Body="&lt;p&gt;The proper method of receiving this kind of data is to use a &lt;em&gt;sliding window&lt;/em&gt;. That is you visualise the stream of bytes as just that - a stream of bytes (think letters on paper tape).  You then have a conceptual &quot;window&quot; on that data which is the width of the packet (10 bytes in this case).  As the data passes behind the window you see just 10 bytes of it. When that 10 bytes is in the &quot;right&quot; format (that is, it starts with 0xAA, ends with 0xAB and the checksum is valid) then you have a valid packet and can read the values from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest method of implementing that is with a 10-byte array. As a byte arrives on the serial port you shuffle all the bytes down the array to make room for the new byte at the top of the array.  Once 10 bytes have arrived that first byte should now have made its way to the bottom of the array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t window[10];&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (Serial.available()) {&#xA;        // Slide the window&#xA;        for (uint8_t i = 0; i &amp;lt; 9; i++) {&#xA;            window[i] = window[i + 1];&#xA;        }&#xA;        // Add the new character&#xA;        window[9] = Serial.read();&#xA;&#xA;        // Output the current window data for debugging&#xA;        dumpWin();&#xA;&#xA;        // Check the framing characters&#xA;        if ((window[0] == 0xAA) &amp;amp;&amp;amp; (window[9] == 0xAC)) {&#xA;            // Calculate the checksum&#xA;            uint8_t cs = 0;&#xA;            for (uint8_t i = 2; i &amp;lt; 8; i++) {&#xA;                cs += window[i];&#xA;            }&#xA;            // If the checksum matches...&#xA;            if (cs == window[8]) {&#xA;                // ...we have a valid packet!&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void dumpWin() {&#xA;    for (int i = 0; i &amp;lt; 10; i++) {&#xA;        Serial.print(window[i], HEX);&#xA;        Serial.print(&quot; &quot;);&#xA;    }&#xA;    Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Getting the data out of the valid packet is now a case of combining bytes into 16-bit integers then dividing them into floats.  For instance the PM2.5 would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t pm25i = (window[3] &amp;lt;&amp;lt; 8) | window[2];&#xA;float pm25 = (float)pm25i / 10.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The PM10 would be the same but with window[5] and window[4] of course.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since you can't really use the hardware UART for both communication with your sensor and communication with the PC you may want to investigate the use of &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; instead of the hardware UART pins for communicating with the sensor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-01-22T19:01:42.953" LastActivityDate="2016-01-22T19:01:42.953" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19820" PostTypeId="2" ParentId="19808" CreationDate="2016-01-21T22:10:53.133" Score="0" Body="&lt;p&gt;It looks like it should be controllable with command 0x51.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would modify the library and add a new method to the &lt;code&gt;Adafruit_ILI9341_8bit_AS&lt;/code&gt; class - something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Adafruit_ILI9341_8bit_AS::setBacklight(uint8_t brightness) {&#xA;    writeRegister8(0x51, brightness);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can change the brightness by calling that method on your TFT object in your sketch.  (Don't forget to add the prototype to the class definition in the header file of course).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-21T22:10:53.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19821" PostTypeId="2" ParentId="19817" CreationDate="2016-01-21T22:30:29.680" Score="1" Body="&lt;p&gt;Install Arduino SAMD Boards (32-bits ARM Cortex-M0+) board (using &quot;Tools&quot; -&gt; &quot;Board&quot; -&gt; &quot;Boards Manager&quot; menu). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just search for &quot;SAMD&quot; in the search bar, choose the latest version and install.&lt;/p&gt;&#xA;" OwnerUserId="16595" LastEditorUserId="10794" LastEditDate="2016-01-22T08:00:17.963" LastActivityDate="2016-01-22T08:00:17.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19822" PostTypeId="2" ParentId="19816" CreationDate="2016-01-21T22:45:29.657" Score="3" Body="&lt;p&gt;Yes, it is possible. That is already supported by the IR library. Please see this &lt;a href=&quot;http://garagelab.com/profiles/blogs/tutorial-arduino-ir-sender-and-receiver&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; for further details. The outline of the sender is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; uint16_t sample = analogRead(A0);&#xA; irsend.sendSony(sample, 16);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (irrecv.decode(&amp;amp;decodedSignal)) {&#xA;    uint16_t sample = decodedSignal.value;&#xA;    ...&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-21T22:45:29.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19825" PostTypeId="1" CreationDate="2016-01-22T02:12:36.560" Score="0" ViewCount="61" Body="&lt;p&gt;I'm trying to program my Arduino Uno with my Windows PC. I followed all the instructions on the site. I mistakenly downloaded the .zip file and didn't unzip it, before plugging in my Arduino Uno. So naturally, no message came up. I then followed the correct procedure, but Windows driver installer does not detect the Arduino Uno. What can I do to fix this?&lt;/p&gt;&#xA;" OwnerUserId="16599" LastEditorUserId="59516" LastEditDate="2019-12-27T16:55:52.033" LastActivityDate="2019-12-27T16:55:52.033" Title="Windows driver installer not detecting arduino" Tags="|arduino-uno|installation|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19826" PostTypeId="5" CreationDate="2016-01-22T02:37:07.363" Score="0" Body="&lt;p&gt;Use this tag for questions about the installation process itself (of the Arduino software). This tag should not be used for installing other hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible problems with installation might be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Incorrect cabling&lt;/li&gt;&#xA;&lt;li&gt;Wrong or missing device drivers&lt;/li&gt;&#xA;&lt;li&gt;Installation process itself fails&lt;/li&gt;&#xA;&lt;li&gt;Arduino IDE does not start up at all&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-22T02:37:07.363" LastActivityDate="2016-01-22T02:37:07.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19827" PostTypeId="4" CreationDate="2016-01-22T02:37:07.363" Score="0" Body="the process of installing the Arduino software on your PC / Laptop / Macintosh" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-22T02:37:07.363" LastActivityDate="2016-01-22T02:37:07.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19828" PostTypeId="2" ParentId="3462" CreationDate="2016-01-22T03:42:38.803" Score="3" Body="&lt;p&gt;HC-05 HC-06 and, for example, RN-42 HID are the same looking on hardware design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only difference is in firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For educational purposes you can dump firmware from RN42HID and flash HC-05/06 module and you've got a HID module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difference in costs of the HID modules is that CSR IDE costs $3000 per licence  + developer seat, and when someone invests in developing wants the incomes to come.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Byron's blog will guide you, you need a SPI programmer, but you can use Arduino as programmer/debugger. And you will need blueflash software to backup some info from Your module (calibration of crystal for example, and IDS/MAC/serial) than you can flash the RN firmware, and you have exact copy of RN, last thing is to restore the settings saved from your original firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just Google it, here is not much place to put all the data and images.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But yes it is possible.&lt;/p&gt;&#xA;" OwnerUserId="16415" LastEditorUserId="10794" LastEditDate="2016-01-22T06:50:14.313" LastActivityDate="2016-01-22T06:50:14.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19830" PostTypeId="2" ParentId="5155" CreationDate="2016-01-22T06:22:38.557" Score="0" Body="&lt;p&gt;I use &lt;a href=&quot;http://www.expresspcb.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ExpressSCH&lt;/a&gt; for doing schematics, usually for posting on web sites like this. It is free, runs on Windows only, and is simple enough to use that I picked it up quite quickly. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hccl8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hccl8.png&quot; alt=&quot;ExpressSCH example&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red arrows I added later in the GIMP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It comes with quite a few symbols pre-defined. You can make others from scratch (using boxes, lines, etc.) or take an existing one, &quot;break it apart&quot;, and then re-assemble to your desires. Once you have something the way you want it you &quot;group as symbol&quot; and it can be used again in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program has a sister program ExpressPCB for PCB layouts, however I haven't used that much.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-22T06:22:38.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19832" PostTypeId="1" AcceptedAnswerId="21117" CreationDate="2016-01-22T09:10:20.177" Score="3" ViewCount="5000" Body="&lt;p&gt;Except hardware UART. Main requirements are reliability and simplicity of use. Speed isn't as important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Pro Mini (ATmega328P 5V) controlled via UART.&lt;br&gt;&#xA;I wish to connect an ESP8266 with stripped-down NodeMCU to offer a web interface for the same functionalities, sending &amp;lt;=122 character strings to Arduino and possibly getting a short response.&lt;br&gt;&#xA;I do not want to use Arduino for processing the interface (too little memory) or use the ESP only (need a stable clock and multiple analog inputs).&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My research shows that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ESP8266 has obvious timing issues, having been designed for a different purpose.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/IRNAS/SimpleArduinoESP-Lua&quot; rel=&quot;nofollow noreferrer&quot;&gt;Controlling the ESP8266 from Arduino via hardware serial&lt;/a&gt; works fine, but I need it the other way around, too. Also, NodeMCU is rather chatty and I don't know how to suppress it, and I'd rather keep the hardware serial ports for programming.&lt;/li&gt;&#xA;&lt;li&gt;The same via &lt;a href=&quot;https://arduino.stackexchange.com/q/17184&quot;&gt;SoftwareSerial&lt;/a&gt; is &lt;a href=&quot;https://primalcortex.wordpress.com/2014/12/30/esp8266-nodemcu-and-lua-language-and-some-arduino-issues/&quot; rel=&quot;nofollow noreferrer&quot;&gt;unreliable&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Personal experience shows OneWire works poorly on ESP8266 (though it may have been fixed)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have no experience with I2C and SPI beyond polling a slave, and don't know about reliability on ESP8266.&lt;br&gt;&#xA;The Arduino already works as an I2C master.&lt;br&gt;&#xA;I'm assuming I2C is the way to go, but wanted to ask for opinions first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[EDIT]&lt;/strong&gt;&#xA;Seems I have once again neglected to set up the proper context. The reason I'm asking is that ESP8266 &lt;em&gt;can't do very precise timing&lt;/em&gt;, leading to communication problems. Hardware UART to hardware UART is shown to be reliable. For most other protocols, at least one side does bit-banging. I have not done or found extensive reliability tests for those options, and hope instead that the community can offer some insights. Can you?&lt;/p&gt;&#xA;" OwnerUserId="16606" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-03-08T09:10:06.927" Title="What is the best serial protocol for bidirectional communication with NodeMCU?" Tags="|serial|esp8266|arduino-pro-mini|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19833" PostTypeId="1" CreationDate="2016-01-22T11:08:15.053" Score="-1" ViewCount="99" Body="&lt;p&gt;I'm a newbie so forgive my ignorance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'am using the Morse code translator to light up the LED which is fine but after it has processed the sentence it turns off. How can I get it to loop the sentence continuously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16611" LastActivityDate="2016-01-22T20:42:23.070" Title="Morse code translator Loop the same sentence" Tags="|led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19834" PostTypeId="1" AcceptedAnswerId="19836" CreationDate="2016-01-22T13:18:52.050" Score="2" ViewCount="735" Body="&lt;p&gt;I used 6 rechargable AA batteries (total 7.2V) to power my Arduino (UNO R3) Car's two DC Motors (using L293D IC as motor driver). I used separate 9V battery to power arduino itself. But I want to share same 6 battery pack to power my arduino via barrel jack. Please suggest me how can I do this? What precautions Should I take? Like decoupling capacitors or any other?&lt;/p&gt;&#xA;" OwnerUserId="15310" LastActivityDate="2016-01-22T13:58:26.240" Title="Share battery pack with Arduino and DC motors" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19835" PostTypeId="1" AcceptedAnswerId="20001" CreationDate="2016-01-22T13:21:26.850" Score="5" ViewCount="4744" Body="&lt;p&gt;I have 64 hall effect sensors (magnetic field sensors) (&lt;a href=&quot;http://nl.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?partNumber=2455494&quot; rel=&quot;nofollow noreferrer&quot;&gt;DRV5023AJQLPG&lt;/a&gt;) connected to an Arduino MEGA 2560. For that, I use 48 digital pins and 16 analog pins as digital input pins. The program in the Arduino continuously reads out those 64 digital input pins (in a for-loop) and sends out a serial byte, to a laptop via a usb cable, whenever one of those input pins changes between LOW and HIGH. I also use the ATmega2560’s internal pullup resistors to prevent irregular readouts of the input pins when the sensor is not giving a 0v output (i.e. when it isn’t measuring a strong enough magnetic field).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is working fine when I only physically connect up to 16 of the sensors. The laptop then only receives bytes that correctly tell when a sensor measures a state-change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I start connecting more of those 64 sensors, then the laptop starts receiving irregular streams of bytes, erroneously suggesting that all the connected sensors measure changing magnetic fields (HIGH and LOW readouts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can think of two reasons why these irregular readouts occur:&#xA;1. Either, the ATmeag2560’s internal pullup resistors arent working as I think they should.&#xA;2. Or, the arduino board and &gt;16 hall effect sensors combined are pulling to much current.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pullup resistors not working?&lt;/strong&gt;&#xA;When testing with only 16 sensors connected, it is a stable, properly working setup. When I explicitly &lt;em&gt;don’t&lt;/em&gt; use the pullup resistors in the program then the setup &lt;em&gt;does&lt;/em&gt; start behaving irregular, also with just 16 sensors. So the internal pullup resistors seem to be properly activated by the program. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Arduino + 64 sensors draw to much current?&lt;/strong&gt;&#xA;Besides powering the Arduino board and sensors via the usb cable (providing 500mA), I’ve also tried external power sources that provide 1 or 2A. I’ve also powered the Arduino board via an external 5v, +1A voltage regulator, bypassing the Arduino’s onboard voltage regulator. This all doesn’t seem to make a difference in the system’s irregular behaviour. When measuring those setup’s current usage (with amperage meter) it didn’t go above &lt;strong&gt;250mA&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Calculating the combined current usage (using datasheet info), I came to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- sensor operating current:             2,7 mA&#xA;- sensor output current when in ‘active’ state:     0,25 mA&#xA;- TOTAL current of 64 sensors   (3mA*64=)       192 mA&#xA;- Arduino MEGA current (approx)             150 mA&#xA;- TOTAL current of 64 sensors + Arduino MEGA:       **342 mA**&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, both the calculated and measured current usage seem within the range of what can be handled by mentioned power sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m kinda stuck now. Can anyone suggest anything that might cause this problem? Or point to incorrect thinking of me? Thanks for any responses.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;'Schematic' (only showing first 8 sensors connected. The ArduinoMEGA is connected to a computer via a usb cable with disabled power line):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E57Se.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E57Se.jpg&quot; alt=&quot;&amp;#39;schematic&amp;#39; (only showing first 8 sensors connected. The ArduinoMEGA is connected to a computer via a usb cable with disabled power line)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Top-side: the hall effect sensors and Vcc an GND rails:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cuwYF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cuwYF.jpg&quot; alt=&quot;Top: the hall effect sensors and Vcc an GND rails&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottom-side: ArduinoMEGA + the 64 red sensor output lines to the input pins:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/0eqiP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0eqiP.jpg&quot; alt=&quot;Bottom: ArduinoMEGA + the 64 red sensor output lines to the input pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Arduino to Pd protocol&#xA;&#xA; Placing or removing a chess piece sends only one byte.&#xA; There’s no other serial data being communicated.&#xA;&#xA; event:                     byte value:&#xA; placing a chess piece on a square:     0-63&#xA; removing a chess piece from a square:          64-127&#xA;&#xA; ArduinoMEGA pin to byte value mapping:&#xA;  byte      pin&#xA;  0     6&#xA;  1     7&#xA;  2     8&#xA;  3     9&#xA;  …&#xA;  46        52&#xA;  47        53&#xA;&#xA;  48        A0 (analog 0)&#xA;  49        A1&#xA;  50        A2&#xA;  …&#xA;  62        A14&#xA;  63        A15&#xA;&#xA;*/&#xA;&#xA;byte prevSquares[64];  // array that holds previous readouts&#xA;byte i;                // variable used in for-loops&#xA;byte sensorValue;      // variable temp storing of digitalread&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  for (i = 0; i &amp;lt; 64 ; i++) {&#xA;    pinMode(i+6, INPUT_PULLUP);  // activate pullup resistor&#xA;  }&#xA;  for (i = 0; i &amp;lt; 64 ; i++) {&#xA;    prevSquares[i] = digitalRead(i+6);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  for (i = 0; i &amp;lt; 64 ; i++) {&#xA;    sensorValue = digitalRead(i+6);&#xA;    if (sensorValue != prevSquares[i]) {&#xA;      // chess piece was placed or removed from square&#xA;      if (sensorValue == 0) {&#xA;        // chess piece was placed&#xA;        // send serial byte (0-63):&#xA;        Serial.write(i);&#xA;      }&#xA;      else {&#xA;        // chess piece was removed&#xA;        // send serial byte (64-127):&#xA;        Serial.write(i + 64);&#xA;      }&#xA;      //update prevSquares array:&#xA;      prevSquares[i] = sensorValue;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16615" LastEditorUserId="4131" LastEditDate="2016-01-27T15:33:40.060" LastActivityDate="2019-08-30T22:47:03.013" Title="ArduinoMEGA: 64 digital inputs cause random digitalRead values" Tags="|arduino-mega|sensors|current|digital-in|pull-up|" AnswerCount="1" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="19836" PostTypeId="2" ParentId="19834" CreationDate="2016-01-22T13:52:12.660" Score="3" Body="&lt;p&gt;You may have read that the UNO can accept 7-12 volts as input power. Your AA battery pack (7.2 volts) is very near the low limit of 7 volts. After just a little discharge of the battery (and also voltage drop from motors running), your batteries are likely to deliver less than 7 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your AA battery goes below 7 volts, then the 5 volts (regulated) will also begin to go lower.  A reasonable scenario would be if AA battery was 6.5 volts (1/2 volt low), then the 5 volts regulated would be about 4.5 volts. The UNO is likely to operate ok at this voltage, but as voltage goes lower operation could become a problem depending upon your program used.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are experimenting with a toy car, I would say to go ahead and run both the motors and UNO from the same battery pack.  Not a lot to lose on trying.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The UNO already has decoupling capacitors in it's 5 volt regulator circuit.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just for fun,  you could use an Analog input to measure your 5 volts and if the voltage drops to 4.5 volts, you could dis-allow motor operation and flash an LED (or other action). Just a low battery indicator.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you decide to measure the 5 volts with an analog input,  read up on using resistor dividers and the Analog reference (A-ref). Because 5 volts dropping to 4.5 volts could effect your analog reading, depending upon what you use for Analog reference.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-01-22T13:58:26.240" LastActivityDate="2016-01-22T13:58:26.240" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19837" PostTypeId="1" CreationDate="2016-01-22T14:13:44.743" Score="1" ViewCount="1853" Body="&lt;p&gt;I'm trying to dim a 10w LED via Arduino PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the LED that I have: &lt;a href=&quot;http://www.banggood.com/10W-Warm-Pure-White-High-Brightest-Save-Power-LED-Light-Lamp-p-88169.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/10W-Warm-Pure-White-High-Brightest-Save-Power-LED-Light-Lamp-p-88169.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without knowing much about this stuff, I bought this (namely because it had LED, DIM, and PWM in its name): &lt;a href=&quot;http://www.ebay.com.au/itm/121437119430?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com.au/itm/121437119430?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't get the eBay dimmer to work for love or money.  When I connect it to ground directly on the battery terminal, it goes off, which means the dimmer circuit is working.  I don't even know where to start with MOSFET dimming solution, but I think that the IRFZ44N MOSFETs are the wrong ones because they won't turn on with 5v power (they need 10v or something, but those are the ones I have on hand).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't seem to find any good guides on how to do this after stacks of googling, and to be honest, I don't even know if those LED's can be dimmed in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to make this happen?&lt;/p&gt;&#xA;" OwnerUserId="14424" LastActivityDate="2016-02-01T10:06:32.093" Title="How can I dim a 10w LED?" Tags="|arduino-uno|led|pwm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19838" PostTypeId="1" CreationDate="2016-01-22T14:14:57.667" Score="3" ViewCount="2255" Body="&lt;p&gt;Does anyone know of any Pelco D libraries available for Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already have a PTZ joystick controlling 3 PTZ cameras, but I would like to add an Arduino 'intelligent' controller capable of sending automated sequences of Pelco D commands according to various PIR triggers etc.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2022-04-18T23:02:38.210" Title="Pelco D Library for Arduino" Tags="|programming|communication|rs485|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19839" PostTypeId="2" ParentId="19837" CreationDate="2016-01-22T14:24:04.187" Score="0" Body="&lt;p&gt;I would suggest the CAT4101 PWM controllable constant current sink LED driver.  You might want 2 in parallel for the higher current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can deal with up to 1A each (theoretically) though they may get a bit hot at that current level - so it would be better to parallel them so they deal with roughly 500mA each.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-22T14:24:04.187" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19840" PostTypeId="2" ParentId="19837" CreationDate="2016-01-22T15:06:37.307" Score="1" Body="&lt;p&gt;Well, it appears that your driver should do that for you. Since you already have the MBI6651 driver, read &lt;a href=&quot;http://www.ledlabs.ru/pdf/macroblock/mbi6651.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;its datasheet&lt;/a&gt; and so you can get a guess on how it should work:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;attach a 9-35V supply to the Vin-GND terminals. I suggest to use at least 12V&lt;/li&gt;&#xA;&lt;li&gt;attach the LED to the terminals LED+ and LED- (remember the polarity!)&lt;/li&gt;&#xA;&lt;li&gt;attach a transistor to pull down the pin DIM&lt;/li&gt;&#xA;&lt;li&gt;send a PWM signal (frequency between 100Hz and 1000Hz) to the transistor and you should see the LED light up and then dim&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If it works then you can try to send to DIM directly th PWM signal, but personally I don't recommend so (unless the board already have the transistor)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to attach an nMOS to the DIM pin. Since the pin is internally pulled up, you don't need any pullup. So you just need an nMOS. I suggest you to use a SOT-23 logic level nMOS connected this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Myxdh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Myxdh.png&quot; alt=&quot;nMOS connection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;no external components (as long as the nMOS supports 5V on the gate, but every discrete mosfet should). As for the nMOS, I prefer the SMD case because it is easy to solder also on perfboards (just use three pads forming an L shape and you'll see that you can easily solder it). Just choose any n-channel mosfet with a maximum threshold voltage of 2V or less and you are done&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2016-02-01T10:06:32.093" LastActivityDate="2016-02-01T10:06:32.093" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="19841" PostTypeId="1" CreationDate="2016-01-22T15:38:46.700" Score="1" ViewCount="2189" Body="&lt;p&gt;Does anyone know the voltage situation regarding multi-drop nodes on an RS485 bus please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammons RS485 article shows 2 different hardware configurations, one using 5v devices, and another using 3.3v devices, and I am fairly sure my Pelco PTZ CCTV system uses 12v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have never seen anything mentioned anywhere about needing to voltage-match nodes on an RS485 bus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am unsure whether the MAX driver chips isolate the RS485 bus voltage from the mcu logic levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do any lower voltage devices (3.3v or 5v) need logic-level matching to their MAX driver chips, which all need powering from the higher bus level (perhaps 12v)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I wish to add an 'intelligent' arduino controller to an existing ptz cctv system.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2016-01-23T12:23:31.053" Title="RS485 bus voltage?" Tags="|communication|rs485|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19842" PostTypeId="2" ParentId="19841" CreationDate="2016-01-22T17:00:28.950" Score="2" Body="&lt;p&gt;RS-485 is a differential bus. As long as the &lt;em&gt;difference&lt;/em&gt; in voltage between the two lines reaches certain thresholds the signal can be interpreted unambiguously regardless of the system supply voltages. Isolation (from ground loops) is not provided by default by the driver, but can be implemented easily enough.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-22T17:00:28.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19843" PostTypeId="1" CreationDate="2016-01-22T17:43:05.120" Score="0" ViewCount="127" Body="&lt;p&gt;I have an arduino &lt;a href=&quot;http://www.flexbot.cc/&quot; rel=&quot;nofollow&quot;&gt;flexbot&lt;/a&gt;, I was making some test and accidentally I connected the battery in the opposite way. The drone turned on the six motors when I connected the battery, but any led turned on to see if the processor was working. I disconnected the battery and connected it in the wrong way again same thing happened the six motors turned on again. Then I realize that the battery was connected in a wrong way and connected it in the right way. The LED's turned on as always, and also the blue-tooth module was working I could detect the device using the control-application. I tried to fly the drone but the motors didn't turn on, I could hear little click and I saw a little movement of a motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected my drone to my PC using the micro USB connection, also I connected the battery. I tried to turn on the drone and in this way it looks to work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I disconnect the USB port and I tried to fly it the same thing happens, the click and the little movement. Any idea of what can I do to fix this drone?&lt;/p&gt;&#xA;" OwnerUserId="16626" LastActivityDate="2016-01-22T19:38:34.873" Title="arduino flexbot drone connected in a wrong way" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19844" PostTypeId="1" AcceptedAnswerId="19845" CreationDate="2016-01-22T18:00:41.877" Score="1" ViewCount="3481" Body="&lt;p&gt;I want to make a standalone programmer for Teensy-LC in &lt;strong&gt;windows 8.1&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically I have provided the board to a client of mine and now I want to change the program loaded into the Teensy-LC board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the solution available right now is to send the &lt;a href=&quot;https://www.pjrc.com/teensy/loader.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Teensy Loader&lt;/a&gt; and send the hex file. But the teensy LC board is packed inside a device. So reset button cannot be pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it would be better if this code can be burned in an installer format instead of the &lt;a href=&quot;https://www.pjrc.com/teensy/loader.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Teensy Loader&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to make this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Teensy.exe does not have the option for program or reboot &#xA;The icons are not accessible&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZYGzx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZYGzx.png&quot; alt=&quot;Teensy.exe&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that mean my interrupts are disabled or there might be something else I am doing wrong?&#xA;My program loads on pressing the reset button but I cannot press the program button inside Teensy.exe&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I turn off the Auto Mode, all icons go grey.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d6vri.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d6vri.png&quot; alt=&quot;AutoMode turned off&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="10165" LastEditDate="2016-01-22T19:46:33.477" LastActivityDate="2016-10-28T02:46:52.183" Title="Use command line to upload program through hex file to Teensy-LC" Tags="|arduino-ide|uploading|bootloader|teensy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19845" PostTypeId="2" ParentId="19844" CreationDate="2016-01-22T18:41:02.923" Score="3" Body="&lt;p&gt;Paul Stoffregen (Teensy creator) has released a command line version of the Teensy Loader which can be found on &lt;a href=&quot;http://www.pjrc.com/teensy/loader_cli.html&quot; rel=&quot;nofollow&quot;&gt;his website&lt;/a&gt;. However, this program appears to be Linux only, so unless your client has Linux, that may be a non-starter. The &lt;a href=&quot;https://github.com/PaulStoffregen/teensy_loader_cli&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt; for the program is available, so you might be able to work out the logic and port it over to whatever platform you are wanting this to work on (just make sure you comply with the source code license).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that being said, pressing the reset button is not necessary for programming. The Teensy loader should be able to trigger a reset over USB all on its own. So unless the current program on the device disables interrupts that are necessary for the USB port to function, or it was programmed with the USB port disabled (by selecting &quot;No USB&quot; in the USB Type menu), physically pressing the reset button isn't necessary for programming. For more details you can see this &lt;a href=&quot;https://forum.pjrc.com/threads/30503-When-do-you-need-the-teensy-reset-button&quot; rel=&quot;nofollow&quot;&gt;forum post&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Loading Firmware Without Pressing the Button&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When programming via Arduino, it does a lot of things for you automatically. To replicate that manually, follow these steps:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect the Teensy to the computer via USB.&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;teensy.exe&lt;/code&gt; (found in &lt;code&gt;C:\Program Files (x86)\Arduino\hardware\tools&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Click the button on the left to select the hex file to load.&lt;/li&gt;&#xA;&lt;li&gt;Go ahead and leave Auto enabled (this actually doesn't matter).&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;teensy_reboot.exe&lt;/code&gt; (also found in &lt;code&gt;C:\Program Files (x86)\Arduino\hardware\tools&lt;/code&gt;, this will restart the Teensy, as if you had pressed the button, and automatically start the programming process.)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2016-10-28T02:46:52.183" LastActivityDate="2016-10-28T02:46:52.183" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19846" PostTypeId="2" ParentId="19841" CreationDate="2016-01-22T19:14:04.200" Score="2" Body="&lt;p&gt;According to my datasheet for the LTC1480:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;–7V to 12V Common Mode Range Permits ±7V Ground Difference Between Devices on the Data Line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Absolute maximum ratings&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supply Voltage (V CC ) : 7V&lt;/li&gt;&#xA;&lt;li&gt;Driver Input Voltage  : – 0.3V to V CC + 0.3V&lt;/li&gt;&#xA;&lt;li&gt;Driver Output Voltage : ±14V&lt;/li&gt;&#xA;&lt;li&gt;Receiver Input Voltage : ±14V&lt;/li&gt;&#xA;&lt;li&gt;Receiver Output Voltage : – 0.3V to V CC + 0.3V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am fairly sure my Pelco PTZ CCTV system uses 12v.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Judging by the above you would need to drop Vcc on the part involving your 12V gadget and use level shifters for the logic levels (if you used this particular chip).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-22T19:14:04.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19847" PostTypeId="1" AcceptedAnswerId="19848" CreationDate="2016-01-21T07:10:54.580" Score="1" ViewCount="1191" Body="&lt;p&gt;I'm writing some code for Arduino and I'm not sure if I'm checking the value of this character variable correctly. Can you please tell me if this is correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* front = &quot;front&quot;;&#xA;const char* back = &quot;back&quot;;&#xA;&#xA;eyeballs(front);&#xA;eyeballs(back);&#xA;&#xA;void eyeballs(const char* frontOrBack){ &#xA;&#xA;if (frontOrBack == &quot;front&quot;) {&#xA;    digitalWrite(frontEyes, LOW);}//end if   &#xA;  else if (frontOrBack == &quot;back&quot;) {&#xA;    digitalWrite(backEyes, LOW);}//end else*/&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7806" OwnerDisplayName="Michael Rader" LastActivityDate="2016-01-22T19:20:34.430" Title="Check the value of character variable" Tags="|c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19848" PostTypeId="2" ParentId="19847" CreationDate="2016-01-21T07:22:13.417" Score="6" Body="&lt;p&gt;Since you are using C strings (array of characters) instead of the C++ String class, you cannot use the == operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you can use the C style &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strcmp/&quot; rel=&quot;nofollow&quot;&gt;strcmp&lt;/a&gt; function, which is also part of the C++ library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;string.h&amp;gt;&#xA;       .&#xA;       .&#xA;       .&#xA;&#xA;    if (!strcmp(frontOrBack,&quot;front&quot;)) {&#xA;        digitalWrite(frontEyes, LOW);}//end if   &#xA;    else if (!strcmp(frontOrBack,&quot;back&quot;)) {&#xA;        digitalWrite(backEyes, LOW);}//end else*/&#xA;    } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="396" OwnerDisplayName="tcrosley" LastActivityDate="2016-01-21T07:31:27.190" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19849" PostTypeId="2" ParentId="19847" CreationDate="2016-01-21T13:49:12.637" Score="3" Body="&lt;p&gt;Another option would be an enum.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum&#xA;{&#xA;   FRONT,&#xA;   BACK&#xA;}&#xA;.&#xA;.&#xA;.&#xA;   if (frontOrBack == FRONT)&#xA;   {&#xA;      // Stuff&#xA;   }&#xA;   else if (frontOrBack == BACK)&#xA;   {&#xA;      // Some other stuff&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Swarles Barkely" LastActivityDate="2016-01-21T13:49:12.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19850" PostTypeId="2" ParentId="19843" CreationDate="2016-01-22T19:38:34.873" Score="2" Body="&lt;p&gt;The motors turning on is expected because or the reverse diode in the mosfets driving the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the schematic, it seems like the problem is on the 5v rail. If 5v isn't supplied by the USB port, it is provided by the LTC3200 (DC/DC converter)(U3 on the pcb). I think that's where the problem is, as that would explain why it only work when USB is connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To confirm this you'd have to measure the output voltage (pin1 (pin nearest to the ATMega) of U3, and see if it's 5 volt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix it you should ideally replace this part. But it might also work without, if you simply connect the battery voltage directly to the 5v (i.e. jumper pins 1 and 5).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-22T19:38:34.873" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19851" PostTypeId="1" AcceptedAnswerId="19862" CreationDate="2016-01-22T19:56:09.203" Score="0" ViewCount="841" Body="&lt;p&gt;Hello i am trying to reverse a dc motor direction upon hitting either limit switch. but noting is working can some one point me in right direction. all example i find use stepper motors and step count.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int sw2 = 2;          //Up Limit switch&#xA;const int sw3 = 3;          //Down Limit switch&#xA;const int ic1_2 = 8;        //TA8409S IN2&#xA;const int ic1_1 = 9;        //TA8409S IN1&#xA;const int enable = 10;      //TA8409S Enable (motor)&#xA;int sw2State = 0;&#xA;int sw3State = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(sw2, INPUT_PULLUP);&#xA;  pinMode(sw3, INPUT_PULLUP);&#xA;  pinMode(ic1_1, OUTPUT);&#xA;  pinMode(ic1_2, OUTPUT);&#xA;  pinMode(enable, OUTPUT);&#xA;  digitalWrite(enable, 1);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  tilt_up();&#xA;}&#xA;&#xA;void tilt_up()&#xA;{&#xA;Serial.print(&quot;up Started\n&quot;);&#xA;  digitalWrite(ic1_1, LOW);&#xA;  digitalWrite(ic1_2, HIGH);&#xA;  sw2State = digitalRead(sw2);&#xA;  if (digitalRead(sw2State == LOW)) {&#xA;    tilt_down();&#xA;    Serial.print(&quot;sw2 pressde\n&quot;);&#xA;  }&#xA;}&#xA;&#xA;void tilt_down()&#xA;{&#xA;  Serial.print(&quot;down Started\n&quot;);&#xA;  digitalWrite(ic1_1, HIGH);&#xA;  digitalWrite(ic1_2, LOW);&#xA;  sw3State = digitalRead(sw3);&#xA;  if (digitalRead(sw3State == LOW)) {&#xA;    tilt_up();&#xA;    Serial.print(&quot;sw3 Pressed\n&quot;);&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16629" LastEditorUserId="10794" LastEditDate="2016-01-22T20:44:59.607" LastActivityDate="2016-01-23T06:42:40.440" Title="How to properly reverse DC motor direction with 2 limit switchws" Tags="|c++|h-bridge|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19852" PostTypeId="1" AcceptedAnswerId="19854" CreationDate="2016-01-22T20:18:37.990" Score="0" ViewCount="876" Body="&lt;p&gt;I have 2 buttons and 2 voids (blink_slow) (blink_fast).&#xA;i need to be able to press button 1 and blink-slow void will run, then press button 2  and blink fast will run. none of my code works, any idea how i can do this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int btn1 1;&#xA;const int btn2 2;&#xA;const int led  13;&#xA;&#xA;void setup(){&#xA;pinMode(btn1,INPUT_PULLUP);&#xA;pinMode(btn2,INPUT_PULLUP);&#xA;pinMode(led,OUTPUT);&#xA;digitalWrite(led,HIGH);&#xA;}&#xA;void loop(){&#xA;if(digitalRead(btn2 =LOW)){&#xA;blink_slow();&#xA;}&#xA;if(digitalRead(btn3 =LOW)){&#xA;blink_fast();&#xA;}&#xA;&#xA;void blink_slow(){&#xA;digitalWrite(led,LOW);&#xA;delay(1000)&#xA;digitalWrite(led,HIGH);&#xA;delay(1000)&#xA;}&#xA;&#xA;void blink_fast(){&#xA;digitalWrite(led,LOW);&#xA;delay(500)&#xA;digitalWrite(led,HIGH);&#xA;delay(500)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16629" LastEditorUserId="10794" LastEditDate="2016-01-22T20:46:52.937" LastActivityDate="2016-01-23T09:13:15.743" Title="How to change Void with button press" Tags="|c++|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19853" PostTypeId="2" ParentId="18975" CreationDate="2016-01-22T20:23:23.897" Score="1" Body="&lt;p&gt;Echoing what Gerben said, in order to wrap up this question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If the Samsung cable has a micro-usb on one end, and a usb-a on the other side, then I don't see why not. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You just want to power it, not connect it to a PC? A regular USB port only supplies upto 500mA, so 1.5A is plenty.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The allowed input voltage range for this pin is 6-20 V. source‌​. So your 12v adapter is also fine.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-22T20:23:23.897" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19854" PostTypeId="2" ParentId="19852" CreationDate="2016-01-22T20:26:55.603" Score="3" Body="&lt;p&gt;Start by correcting the obvious:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int btn1 = 2;&#xA;const int btn2 = 3;&#xA;const int led = 13;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(btn1, INPUT_PULLUP);&#xA;  pinMode(btn2, INPUT_PULLUP);&#xA;  pinMode(led, OUTPUT);&#xA;  digitalWrite(led, HIGH);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (digitalRead(btn2) == LOW) {&#xA;    blink_slow();&#xA;  }&#xA;  else if (digitalRead(btn3) == LOW) {&#xA;    blink_fast();&#xA;  }&#xA;&#xA;void blink_slow()&#xA;{&#xA;  digitalWrite(led, LOW);&#xA;  delay(1000)&#xA;  digitalWrite(led, HIGH);&#xA;  delay(1000)&#xA;}&#xA;&#xA;void blink_fast()&#xA;{&#xA;  digitalWrite(led, LOW);&#xA;  delay(500)&#xA;  digitalWrite(led, HIGH);&#xA;  delay(500)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mistakes where 1) const variable assignment, 2) using pin 1 (TX) is a potential risk if you later what to use Serial for debugging, etc, 3) condition expression, and a lot of formatting. Open your C/C++ book and check the syntax. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your turn to improve this!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-23T09:13:15.743" LastActivityDate="2016-01-23T09:13:15.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19855" PostTypeId="2" ParentId="17172" CreationDate="2016-01-22T20:29:16.157" Score="1" Body="&lt;p&gt;The line in error can often be highlighted, however because of the way the IDE plays with your source file this is not always the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my post about &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-i-actually-need-to-use-them&quot;&gt;How the IDE organizes things&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IDE adds extra lines to your source, and then tries to hide that with #line directives. This can confuse the way error messages are handled. It is another example of the &quot;helpful&quot; IDE not always being helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any event, as Igor said, you can look for the line number in the error message and use that to find the error. Failing that, look at the quoted source code and search for that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-22T20:29:16.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19856" PostTypeId="2" ParentId="12307" CreationDate="2016-01-22T20:34:03.643" Score="1" Body="&lt;p&gt;As the OP reported: &lt;em&gt;It worked with a different cable.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I converted his comment to an answer so the system would regard this issue as solved. Please accept this answer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Some cheap USB cables only carry power, and not data. I have such a cable that came with a USB desk light. To save money they only run two wires and not four, since the desk light is not a data device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be cautious about grabbing any old cable from your desk for testing. Make sure it is designed for data use. If in doubt, try a known good cable.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-22T20:34:03.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19857" PostTypeId="2" ParentId="19833" CreationDate="2016-01-22T20:42:23.070" Score="1" Body="&lt;p&gt;I guess this is the &lt;a href=&quot;http://www.instructables.com/id/Morse-Code-Translator/step5/Program/&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; you are using. It reads characters from Serial and translates them to Morse code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do to make it loop a sentence is, 1) read a sentence into a buffer, 2) loop though the buffer and translate to Morse code. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-22T20:42:23.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19858" PostTypeId="2" ParentId="19851" CreationDate="2016-01-22T20:44:48.637" Score="1" Body="&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  tilt_up();&#xA;}&#xA;&#xA;void tilt_up()&#xA;{&#xA;...&#xA;  if (digitalRead(sw2State == LOW)) {&#xA;    tilt_down();&#xA;...&#xA;  }&#xA;}&#xA;&#xA;...&#xA;&#xA;void tilt_down()&#xA;{&#xA;...&#xA;  if (digitalRead(sw3State == LOW)) {&#xA;    tilt_up();&#xA;...&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are recursing here. &lt;code&gt;loop&lt;/code&gt; calls &lt;code&gt;tilt_up&lt;/code&gt; which eventually calls &lt;code&gt;tilt_down&lt;/code&gt; which calls &lt;code&gt;tilt_up&lt;/code&gt; and so on until you - rather quickly - run out of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rewrite so that you are not doing that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see what @MikaelPatel told you in &lt;a href=&quot;https://arduino.stackexchange.com/questions/19852/&quot;&gt;your other question&lt;/a&gt;. You have the brackets in the wrong place.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (digitalRead(sw2State == LOW)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (digitalRead(sw2State) == LOW) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-22T20:44:48.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19859" PostTypeId="2" ParentId="18295" CreationDate="2016-01-22T21:41:15.667" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Please tell me if it is broken and how to fix it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those tips may also help with fixing problems with your Mega (if you ever have them). ;)&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-22T21:41:15.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19860" PostTypeId="2" ParentId="19236" CreationDate="2016-01-22T22:21:39.043" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the Panstamp broken ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sounds like it. If one works, and the other does not, using the same wiring, it looks like you have a faulty one.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;or should I do a kind of factory reset?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can't really &quot;factory reset&quot; a chip like that. Possibly there is a problem with the fuses. You may be able to explore further here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-01-22T22:21:39.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19861" PostTypeId="2" ParentId="19825" CreationDate="2016-01-22T22:24:45.397" Score="1" Body="&lt;p&gt;Per my comment above, the drivers are not installed when using the Arduino editor from an extracted zip file. If you are feeling adventurous, they are located in the /drivers folder and you can install them manually, there are plenty of instructions elsewhere on the internet on how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My recommendation would be to just download and run the installer version of Arduino, as that will take care of registering the drivers for you. The installer can be found on the &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;download page&lt;/a&gt; indicated with the text &quot;Windows Installer&quot;.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-22T22:24:45.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19862" PostTypeId="2" ParentId="19851" CreationDate="2016-01-22T22:44:52.657" Score="1" Body="&lt;p&gt;If you want to reverse the movement you sould remember where you are going. This, along with the brackets correction suggested by @MikaelPatel and @NickGammon, leads to this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean moving_up = true;&#xA;&#xA;void loop() {&#xA;    if (moving_up)&#xA;        tilt_up();&#xA;    else&#xA;        tilt_down();&#xA;}&#xA;&#xA;void tilt_up()&#xA;{&#xA;    digitalWrite(ic1_1, LOW);&#xA;    digitalWrite(ic1_2, HIGH);&#xA;    if (digitalRead(sw2State) == LOW) {&#xA;        moving_up = false;&#xA;        Serial.println(&quot;sw2 Pressed&quot;);&#xA;        Serial.println(&quot;down Started&quot;);&#xA;    }&#xA;}&#xA;&#xA;void tilt_down()&#xA;{&#xA;    digitalWrite(ic1_1, HIGH);&#xA;    digitalWrite(ic1_2, LOW);&#xA;    sw3State = digitalRead(sw3);&#xA;    if (digitalRead(sw3State) == LOW) {&#xA;        moving_up = true;&#xA;        Serial.println(&quot;sw3 Pressed&quot;);&#xA;        Serial.println(&quot;up Started&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-22T22:44:52.657" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19864" PostTypeId="5" CreationDate="2016-01-23T04:28:21.643" Score="0" Body="&lt;p&gt;The &quot;communication&quot; tag is for the broad concept of communications between devices, including such things as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;/questions/tagged/bluetooth&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;bluetooth&amp;#39;&quot; rel=&quot;tag&quot;&gt;bluetooth&lt;/a&gt; &lt;a href=&quot;/questions/tagged/esp8266&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;esp8266&amp;#39;&quot; rel=&quot;tag&quot;&gt;esp8266&lt;/a&gt; &lt;a href=&quot;/questions/tagged/ethernet&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ethernet&amp;#39;&quot; rel=&quot;tag&quot;&gt;ethernet&lt;/a&gt; &lt;a href=&quot;/questions/tagged/firmata&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;firmata&amp;#39;&quot; rel=&quot;tag&quot;&gt;firmata&lt;/a&gt; &lt;a href=&quot;/questions/tagged/ftdi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ftdi&amp;#39;&quot; rel=&quot;tag&quot;&gt;ftdi&lt;/a&gt; &lt;a href=&quot;/questions/tagged/gsm&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;gsm&amp;#39;&quot; rel=&quot;tag&quot;&gt;gsm&lt;/a&gt; &lt;a href=&quot;/questions/tagged/i2c&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;i2c&amp;#39;&quot; rel=&quot;tag&quot;&gt;i2c&lt;/a&gt; &lt;a href=&quot;/questions/tagged/ir&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;ir&amp;#39;&quot; rel=&quot;tag&quot;&gt;ir&lt;/a&gt; &lt;a href=&quot;/questions/tagged/lan&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;lan&amp;#39;&quot; rel=&quot;tag&quot;&gt;lan&lt;/a&gt; &lt;a href=&quot;/questions/tagged/midi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;midi&amp;#39;&quot; rel=&quot;tag&quot;&gt;midi&lt;/a&gt; &lt;a href=&quot;/questions/tagged/networking&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;networking&amp;#39;&quot; rel=&quot;tag&quot;&gt;networking&lt;/a&gt; &lt;a href=&quot;/questions/tagged/nrf24l01%2b&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;nrf24l01+&amp;#39;&quot; rel=&quot;tag&quot;&gt;nrf24l01+&lt;/a&gt; &lt;a href=&quot;/questions/tagged/rf&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;rf&amp;#39;&quot; rel=&quot;tag&quot;&gt;rf&lt;/a&gt; &lt;a href=&quot;/questions/tagged/rs485&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;rs485&amp;#39;&quot; rel=&quot;tag&quot;&gt;rs485&lt;/a&gt; &lt;a href=&quot;/questions/tagged/serial&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;serial&amp;#39;&quot; rel=&quot;tag&quot;&gt;serial&lt;/a&gt; &lt;a href=&quot;/questions/tagged/softwareserial&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;softwareserial&amp;#39;&quot; rel=&quot;tag&quot;&gt;softwareserial&lt;/a&gt; &lt;a href=&quot;/questions/tagged/spi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;spi&amp;#39;&quot; rel=&quot;tag&quot;&gt;spi&lt;/a&gt; &lt;a href=&quot;/questions/tagged/tcpip&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;tcpip&amp;#39;&quot; rel=&quot;tag&quot;&gt;tcpip&lt;/a&gt; &lt;a href=&quot;/questions/tagged/uart&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;uart&amp;#39;&quot; rel=&quot;tag&quot;&gt;uart&lt;/a&gt; &lt;a href=&quot;/questions/tagged/usb&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;usb&amp;#39;&quot; rel=&quot;tag&quot;&gt;usb&lt;/a&gt; &lt;a href=&quot;/questions/tagged/virtualwire&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;virtualwire&amp;#39;&quot; rel=&quot;tag&quot;&gt;virtualwire&lt;/a&gt; &lt;a href=&quot;/questions/tagged/webserver&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;webserver&amp;#39;&quot; rel=&quot;tag&quot;&gt;webserver&lt;/a&gt; &lt;a href=&quot;/questions/tagged/wifi&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;wifi&amp;#39;&quot; rel=&quot;tag&quot;&gt;wifi&lt;/a&gt; &lt;a href=&quot;/questions/tagged/xbee&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;xbee&amp;#39;&quot; rel=&quot;tag&quot;&gt;xbee&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-23T04:28:21.643" LastActivityDate="2016-01-23T04:28:21.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19865" PostTypeId="4" CreationDate="2016-01-23T04:28:21.643" Score="0" Body="for questions about communication between multiple devices." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-23T04:28:21.643" LastActivityDate="2016-01-23T04:28:21.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19866" PostTypeId="5" CreationDate="2016-01-23T04:31:07.447" Score="0" Body="&lt;p&gt;From &lt;a href=&quot;https://en.wikipedia.org/wiki/Robotics&quot; rel=&quot;nofollow&quot;&gt;Robotics - Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Robotics is the branch of mechanical engineering, electrical engineering and computer science that deals with the design, construction, operation, and application of robots, as well as computer systems for their control, sensory feedback, and information processing.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Today, robotics is a rapidly growing field, as technological advances continue; researching, designing, and building new robots serve various practical purposes, whether domestically, commercially, or militarily. Many robots do jobs that are hazardous to people such as defusing bombs, mines and exploring shipwrecks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-23T04:31:07.447" LastActivityDate="2016-01-23T04:31:07.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19867" PostTypeId="4" CreationDate="2016-01-23T04:31:07.447" Score="0" Body="use this tag for questions about robotics." OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-23T04:31:07.447" LastActivityDate="2016-01-23T04:31:07.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19869" PostTypeId="2" ParentId="19851" CreationDate="2016-01-23T06:42:40.440" Score="0" Body="&lt;p&gt;I got it to work!!!&#xA;do not know if it is the right way ... but it works. thank you all for your input/advice. here is the new working code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;&#xA; */&#xA;&#xA;// set pin numbers:&#xA;const int sw2 = 2;           // Down limit&#xA;const int sw3 = 3;           // Up Limit&#xA;const int ledPin =  13;      // Pwr L.E.D&#xA;const int ic1_2 = 8;         // TA8409S IN2&#xA;const int ic1_1 = 9;         // TA8409S IN1&#xA;const int enable = 10;       // TA8409S Enable (motor)&#xA;&#xA;int sw2State = 0;            // Down Limit State&#xA;int sw3State = 0;            // Up   Limit State&#xA;&#xA;void setup() {&#xA;  // Setting L.E.D and Motor In, Enable pins as an output:&#xA;  pinMode(ic1_1, OUTPUT);&#xA;  pinMode(ic1_2, OUTPUT);&#xA;  pinMode(enable, OUTPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  // Setting limit switches pins as inputs&#xA;  pinMode(sw2, INPUT_PULLUP);&#xA;  pinMode(sw3, INPUT_PULLUP);&#xA;  // Enables motor&#xA;  digitalWrite(enable, 1);&#xA;  //Starts program down&#xA;  down();&#xA;}&#xA;&#xA;void loop() {&#xA;  // reads the state of the limit switches&#xA;  sw2State = digitalRead(sw2);&#xA;  sw3State = digitalRead(sw3);&#xA;&#xA;  if (sw3State == LOW) {&#xA;    down();&#xA;  }&#xA;  if (sw2State == LOW) {&#xA;    up();&#xA;  }&#xA;}&#xA;&#xA;void up() {&#xA;  digitalWrite(ic1_1, LOW);&#xA;  digitalWrite(ic1_2, HIGH);&#xA;}&#xA;&#xA;void down() {&#xA;  digitalWrite(ic1_1, HIGH);&#xA;  digitalWrite(ic1_2, LOW);&#xA;}&#xA;&#xA;void err() {&#xA;  digitalWrite(enable, LOW);&#xA;  digitalWrite(ic1_1, LOW);&#xA;  digitalWrite(ic1_2, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16629" LastActivityDate="2016-01-23T06:42:40.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19870" PostTypeId="2" ParentId="4261" CreationDate="2016-01-23T07:27:19.067" Score="0" Body="&lt;p&gt;Use nested loops.  Test each pin one by one.  For each one pin test, look for the correct wire to be on and check all the others and either look for an &quot;on&quot; or count how many bad on's there are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH.&lt;/p&gt;&#xA;" OwnerUserId="16638" LastActivityDate="2016-01-23T07:27:19.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19871" PostTypeId="1" CreationDate="2016-01-23T08:22:39.087" Score="-1" ViewCount="1819" Body="&lt;p&gt;I have ESP8266, FTD232 UART, Linux mint 17.3 OS, Arduino IDE 1.6.7,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following are the connections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;External Power source  ESP8266&#xA;  3.3 V                  VCC&#xA;  GND                    GND&#xA;  3.3 V                  CHPD&#xA;  3.3 V                  GPIO0&#xA;&#xA;FTD232 UART  ESP8266&#xA;    RX         TX&#xA;    TX         RX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plus FTD232 GND and Power Source GND are connected to make sure that there is a common reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I open the Arduino IDE and select Generic ESP 8266 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Serial Monitor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AT command, no response..?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried lots of different things found from web, even a new ESP8266, but no response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody provide help...?&lt;/p&gt;&#xA;" OwnerUserId="16639" LastEditorUserId="6936" LastEditDate="2016-01-24T21:37:45.740" LastActivityDate="2020-05-07T09:06:15.650" Title="ESP8266 is not responding" Tags="|esp8266|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19873" PostTypeId="1" CreationDate="2016-01-23T11:38:33.087" Score="1" ViewCount="1625" Body="&lt;p&gt;I need four Fast PWM signals for four different transistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use timers 1+2 (pins 3, 11, 9, 10) so it wouldn't interfere with &lt;code&gt;delay(...)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried setting the timers to Fast PWM mode, and applied different OCRnA/OCRnB values, but nothing really worked - at most, I managed to get two good PWM signals, &lt;em&gt;one from each timer&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I deal with &lt;code&gt;TCCRnA/TCCRnB, OCRnA/OCRnB&lt;/code&gt; to achieve 4 parallel PWM signals?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My latest attempt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Timer 1 Fast PWM setup: TOP=0x00FF, Update of OCRx at BOTTOM (0), TOV Flag Set on TOP&#xA;pinMode(9, OUTPUT); pinMode(10, OUTPUT);&#xA;TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10);&#xA;TCCR1B = _BV(WGM12) | _BV(CS11) | _BV(CS10); // Divisor 64&#xA;// Timer 2 Fast PWM setup: TOP=0xFF, Update of OCRx at BOTTOM (0), TOV Flag Set on MAX (0xFF)&#xA;pinMode(3, OUTPUT); pinMode(11, OUTPUT);&#xA;TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;TCCR2B = _BV(CS22); // Divisor 64&#xA;// ...&#xA;int val = 200; // Desired PWM output&#xA;OCR1A = val;&#xA;OCR1B = val;&#xA;OCR2A = val;&#xA;OCR2B = val;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16649" LastEditorUserId="4628" LastEditDate="2016-02-15T05:43:43.450" LastActivityDate="2016-02-15T05:43:43.450" Title="Four Fast PWM outputs, in parallel" Tags="|arduino-uno|motor|pwm|transistor|arduino-duemilanove|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19875" PostTypeId="1" CreationDate="2016-01-23T11:47:11.277" Score="2" ViewCount="11853" Body="&lt;p&gt;What is the cheapest and best method to convert 12v(14)&amp;lt;-&gt;5V(3.3)? Need to connect Arduino to a car.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need logical shifter not buck converter to connect Arduino to car 12v circuit. I would like to control electrical equipment of car by Arduino. For example, I want to connect input pin to heater, when heater is on from 12v circuit I get HIGH 12v signal which processes by Arduino, but like everyone knows, Arduino can handle only 5/3.3V. Then Arduino going to change state of equipment by connecting optocoupler/relay/transistor to  button(of elect. equip.) and will act like physical press. &#xA;P.P.S I know that more clever to hack and control by CAN bus. But not all eq. are connected to CAN bus and it`s a little bit risky but I'm working on it as well. &#xA;I'm looking for best low cost solution. I have found it on &lt;a href=&quot;http://www.ebay.com/itm/Level-Shifter-Logic-Level-Converter-12-Channel-5V-to-12V-or-12V-to-5V-/251604416861?hash=item3a94cab95d:g:DUYAAOSwxH1T2d~7&quot; rel=&quot;nofollow&quot;&gt;ebay&lt;/a&gt; . Will it work like I want? Offer DIY solutions as well.&lt;/p&gt;&#xA;" OwnerUserId="16647" LastEditorUserId="11529" LastEditDate="2016-01-27T15:35:05.460" LastActivityDate="2018-03-15T10:40:38.130" Title="Logic level converter 12v to 5v" Tags="|arduino-mega|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19876" PostTypeId="2" ParentId="19875" CreationDate="2016-01-23T11:59:11.310" Score="1" Body="&lt;p&gt;Use LM7805 linear voltage regulator to regulate to 5 v , it's all about 2-4$, you need LM chip and 2 capacitors, that's all :) and if you need 3.3 just search for linear voltage regulator&lt;/p&gt;&#xA;" OwnerUserId="16123" LastActivityDate="2016-01-23T11:59:11.310" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19878" PostTypeId="2" ParentId="19875" CreationDate="2016-01-23T12:04:48.053" Score="-1" Body="&lt;p&gt;What are you trying to achieve?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's simply unclear if you want to run the Arduino on 12v of the car battery. Or if you want to control the car-windows by hooking into them? Or if you want to read out your car using the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll go with the later since otherwise the question would be stated a little different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you're looking for something good/cheap.&#xA;You don't tell what type of car you want to connect to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I think this might help you out: &lt;a href=&quot;https://www.sparkfun.com/products/13262&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/13262&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;25€ isn't that pricey, compared to the car you're fiddling with... So you should go with a little quality (also, you don't need them in batch?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While a bit subjective, sparkfun could be considered a better vendor than most e-bay suppliers. Both in documentation and support. And in this case, their price isn't that bad. (I'm not affiliated with sparkfun, I actually never bought stuff of them, since e-bay works well for me. There may be hundreds of other good/better suppliers, but this one popped up first on google)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &quot;hacking&quot; your car can have serious safety risks.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-01-23T12:04:48.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19879" PostTypeId="1" AcceptedAnswerId="19885" CreationDate="2016-01-23T12:12:27.110" Score="0" ViewCount="4618" Body="&lt;p&gt;I am trying to build a WiFi humidity and temperature sensor. My board is a nodeMCU using the ESP8266 connected via USB. The board is working fine with various WiFi examples and various serial examples. Hence I guest my environment is OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am trying to connect a DHT22 to read temperature and humidity. To reduce the error sources I boiled down my code to the standard DHT example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example testing sketch for various DHT humidity/temperature sensors&#xA;// Written by ladyada, public domain&#xA;#include &quot;DHT.h&quot;&#xA;#define DHTPIN 2&#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;DHTxx test!&quot;);&#xA;  dht.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(2000);&#xA;&#xA;  float h = dht.readHumidity();&#xA;  float t = dht.readTemperature();&#xA;  float f = dht.readTemperature(true);&#xA;  if (isnan(h) || isnan(t) || isnan(f)) {&#xA;    Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.print(&quot;Humidity: &quot;);&#xA;  Serial.print(h);&#xA;  Serial.print(&quot; %\t&quot;);&#xA;  Serial.print(&quot;Temperature: &quot;);&#xA;  Serial.print(t);&#xA;  Serial.println(&quot; *C &quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nevertheless I always get the message &quot;Failed to read from DHT sensor!&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the hardware I tried connecting the sensor with or without the 10k resistor, tried different DHTs and different pins. To rule out the DHTs I connected them with an Arduino Nano where these are working fine (both with and without resistor and using the same code). The only difference I see is that the Arduino is using 5V while the ESP8266 is using 3.3V - which is nonetheless inside the rating of the DHT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="16648" LastActivityDate="2017-02-10T00:28:01.500" Title="ESP8266 cannot read DHT22" Tags="|arduino-nano|esp8266|temperature-sensor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19880" PostTypeId="2" ParentId="19841" CreationDate="2016-01-23T12:23:31.053" Score="0" Body="&lt;p&gt;I suspect that the line-driver Vcc may be using a commercial standard of 5v which we are not aware off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RS485 Vcc VMax is only 7v anyway, so presumably the thousands of different 12v RS485 CCTV devices on the market must use line-drivers chips with a Vcc of 5v because they were historically assumed to be interfacing to TTL logic levels, and therefore still will be for compatibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for integration, I think any 3.3v logic nodes will require level-matching up to a line-driver chip which has its Vcc connected to 5v for RS485 bus compatibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Line-driver Vcc would not normally be a problem for any home-brew systems, but could offer a potentially serious gotcha if mixing 3.3v home-brew with existing commercial 5v equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had been expecting it to be an already known problem, but apparently not, so it would seem to be something worth being aware of.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2016-01-23T12:23:31.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19881" PostTypeId="1" CreationDate="2016-01-23T12:35:16.067" Score="0" ViewCount="60" Body="&lt;p&gt;Using Temperation through arduino to trip off an ac device?&lt;/p&gt;&#xA;" OwnerUserId="16651" LastActivityDate="2016-01-23T13:21:06.410" Title="Using Temperature sensor arduino to trip off an ac device" Tags="|relay|" AnswerCount="1" CommentCount="4" ClosedDate="2016-01-24T03:43:54.973" ContentLicense="CC BY-SA 3.0" />
  <row Id="19882" PostTypeId="1" CreationDate="2016-01-23T12:37:04.993" Score="0" ViewCount="59" Body="&lt;p&gt;I'm still fairly new to the Arduino world. I got myself a kit with a clone board  couple of months ago and have successfully prototyped the project and got it to the state I want it to be. I now want to create 5 - 10 working models of what I've done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd seen on Amazon that I could get 5 Nano clones for about £10 and this seemed ideal to me. Until I saw that people were complaining that some Nano's aren't quite a direct replacement for the Uno that I have working. There's some kind of problem with loading the software from the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really don't want to do anything more than just load my software onto the Nanos &quot;As Is&quot; using the IDE I already have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone recommend what I need to look out for to ensure that the Nanos I buy will work this way please?&lt;/p&gt;&#xA;" OwnerUserId="3377" LastActivityDate="2016-01-23T15:27:31.527" Title="Porting my project to multiple Nanos" Tags="|arduino-ide|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19883" PostTypeId="2" ParentId="19882" CreationDate="2016-01-23T13:15:29.767" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... people were complaining that some Nano's aren't quite a direct replacement for the Uno&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First, I hope you have understood that the Nano and Uno have totally different board formats. The Uno is the classical Arduino format. And the Nano is for breadboards. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, (and this will have to be a guess in lack of info or reference in your question) the Nano USB hardware on clones may differ and require another device driver. There might be other component selections to reduce the cost such as alternative a crystal for the oscillator, protection fuse, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-23T13:15:29.767" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19884" PostTypeId="2" ParentId="19881" CreationDate="2016-01-23T13:21:06.410" Score="2" Body="&lt;p&gt;Yes, there are lots and lots of project descriptions similar to yours (if I guesstimate) on the web. Google is your friend. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one &lt;a href=&quot;http://makezine.com/2014/03/28/arduino-controlled-tec-coolingheating-system-for-beer-fermentation/&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; to an interesting project - if you are interested in brewing beer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-23T13:21:06.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19885" PostTypeId="2" ParentId="19879" CreationDate="2016-01-23T13:53:58.947" Score="5" Body="&lt;p&gt;I found, that the pin mapping printed at the board of the nodeMCU does NOT match the pin mapping in the library/software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;a href=&quot;https://github.com/esp8266/Arduino/issues/584&quot; rel=&quot;noreferrer&quot;&gt;this issue/solution&lt;/a&gt;. It states the correct pin mapping (e.g. pin 2 is &quot;D4&quot; at the board) and provides also an according workaround. My DHT22s are working now... :-)&lt;/p&gt;&#xA;" OwnerUserId="16648" LastActivityDate="2016-01-23T13:53:58.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19887" PostTypeId="2" ParentId="19882" CreationDate="2016-01-23T15:27:31.527" Score="2" Body="&lt;p&gt;The Arduino Uno and Arduino Nano are fairly compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problems:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The board layout isn't the same, Nano's won't wield a classic &quot;shield&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Nano's don't have a barrel jack.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nano's (usually) have a micro USB connector. While the Uno has another one.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But, Nano's are smaller, withouth leaving out the USB connection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But wait!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Microcontrollers of the same family are quite scaleable, Nano and Uno might even have the same micro on it! Be sure your Nano has the same Atmega328(P?) chip as your Uno.&#xA;Check if the pins you're using, are accessible on the Nano. Then you should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a little problem with cheap Arduino Nano's, I've bought 2, from 2 different vendors. They we're about 3$.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first one featured a counterfeit FTDI chip. By installing the latest FTDI drivers, my FTDI actually got bricked. I had to undo this by using M_PROG or some EEPROM flashing tool to unbrick the chip, and install older drivers (which didn't corrupt it).&lt;/li&gt;&#xA;&lt;li&gt;The second one featured an CH340G usb-serial chip. I had to download and install the drivers from a chinese website. But Windows wouldn't install unsinged drivers that easily. You have to go into advanced boot options mode and allow installing unsigned drivers.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Getting these Nano's working took me an reasonable amount of time. But they now are working quite well :)&#xA;It's something to take into account when buying cheap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wouldn't really bother for the alternative crystal, as long as they're 16Mhz. For time-critical behaviour, I wouldn't rely too much on your crystal.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-01-23T15:27:31.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19888" PostTypeId="2" ParentId="10352" CreationDate="2016-01-23T15:57:33.730" Score="2" Body="&lt;p&gt;It has been suggested to you to save the millis value in the EEPROM.&#xA;Although this can work, there is a big issue with the frequency at which&#xA;you save it. If you save too often, you will burn your EEPROM, as it is&#xA;only rated to 10&lt;sup&gt;5&lt;/sup&gt; writes. If you do not save often enough,&#xA;you will have most of the time a very outdated value in EEPROM. The&#xA;problem can be mitigated by adopting a wear-leveling strategy, but this&#xA;adds significant complexity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a simpler solution to this problem: instead of using the&#xA;EEPROM, save the value in RAM. Actually, the millis value already lives&#xA;in RAM, and since the RAM is not initialized by hardware on reset, you&#xA;will find, when your program starts, that the last millis is right where&#xA;you left it! It is then cleared by your program, in a function called&#xA;&lt;code&gt;__do_clear_bss&lt;/code&gt; that belongs to the C runtime and runs before&#xA;&lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to preserve millis across a reset, you can do the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Write a function that copies the millis value into some other global&#xA;variable. This function must run early in the startup sequence, before&#xA;&lt;code&gt;__do_clear_bss&lt;/code&gt; clears millis. This can be achieved by putting&#xA;the function in the &lt;em&gt;.init3&lt;/em&gt; section of the program, as explained in&#xA;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/mem_sections.html&quot; rel=&quot;nofollow&quot;&gt;the avr-libc documentation on memory&#xA;sections&lt;/a&gt;.&#xA;And the global variable must be in the &lt;em&gt;.noinit&lt;/em&gt; section in order for&#xA;the C runtime not to mess with it.&lt;/li&gt;&#xA;&lt;li&gt;In &lt;code&gt;setup()&lt;/code&gt;, restore the millis value from that global variable.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This way you will have a continuous millis across resets, with one&#xA;caveat: on a cold boot, it will start with an unpredictable value. This&#xA;should be no issue if you take care to never rely on absolute time but&#xA;only on time differences, which is a good practice if only to avoid&#xA;issues when millis rolls over. If you nevertheless want to reset millis&#xA;on a cold boot, you have several options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect a &quot;reset time&quot; button to your Arduino and hold the button&#xA;pressed when you power it up. &lt;code&gt;setup()&lt;/code&gt; would then know it should not&#xA;restore the millis value.&lt;/li&gt;&#xA;&lt;li&gt;Write some &lt;a href=&quot;https://en.wikipedia.org/wiki/Magic_number_%28programming%29&quot; rel=&quot;nofollow&quot;&gt;magic&#xA;number&lt;/a&gt;&#xA;in RAM. If you find this number at startup, it is extremely likely&#xA;that the program is starting from a warm reset.&lt;/li&gt;&#xA;&lt;li&gt;If your Arduino has a fairly recent version of optiboot, you&#xA;will find the reset flags in the CPU register r2 when your program&#xA;starts. These flags tell you whether you come from a cold boot or a&#xA;warm reset.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The program below is an example that implements strategy 2. It prints&#xA;the millis value on the serial port roughly every second. On reset, it&#xA;prints “-- starting --” and continues from where it left.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// If this is in RAM at startup, we come from a warm reset.&#xA;volatile const unsigned long magic = 0x12345678;&#xA;&#xA;// This is where Arduino core keeps the millis() value.&#xA;extern volatile unsigned long timer0_millis;&#xA;&#xA;// Here we will save a copy of timer0_millis.&#xA;unsigned long __attribute__((section(&quot;.noinit&quot;))) savedMillis;&#xA;&#xA;// Save the millis value at startup.&#xA;void __attribute__((section(&quot;.init3&quot;),naked)) saveMillis()&#xA;{&#xA;    if (magic == 0x12345678)  // very likely a reset&#xA;        savedMillis = timer0_millis;&#xA;    else                      // cold boot&#xA;        savedMillis = 0;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    // DO THIS FIRST: Restore the saved value of millis.&#xA;    noInterrupts();&#xA;    timer0_millis = savedMillis;&#xA;    interrupts();&#xA;&#xA;    // Other initializations can be done now.&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;-- starting --&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(millis());&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-01-23T15:57:33.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19889" PostTypeId="1" CreationDate="2016-01-23T16:02:19.233" Score="0" ViewCount="450" Body="&lt;p&gt;I have made a sumobot with an arduino, an afmotor shield and a 4-pin ping sensor when I upload my code it keeps giving me this error: &amp;quot;'Servo' does not name a type&amp;quot; here is my code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AFMotor.h&amp;gt;&#xA;#include &amp;lt;NewPing.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define TRIGGER_PIN  A0  // Arduino pin tied to trigger pin on the ultrasonic sensor.&#xA;#define ECHO_PIN     A2  // Arduino pin tied to echo pin on the ultrasonic sensor.&#xA;#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.&#xA;&#xA;NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.&#xA;&#xA; //speed variables for the left and right motor&#xA;int Lspeed = 180;&#xA;int Rspeed = 255;&#xA;&#xA;//declaring the left and right motors and attaching them to &#xA;//their corresponding connector on the motor shield&#xA;Servo leftMotor;&#xA;Servo rightMotor;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  //sets initial speed&#xA;  leftMotor.setSpeed(Lspeed);&#xA;  rightMotor.setSpeed(Rspeed);&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).&#xA;  unsigned int CM = uS / US_ROUNDTRIP_CM;&#xA;  &#xA;  if (CM &amp;amp;lt; 15 &amp;amp;&amp;amp; CM &amp;amp;gt; 0) {&#xA;    int iteration = 0;&#xA;    while( iteration == 0){&#xA;      leftMotor.run(FORWARD);&#xA;      rightMotor.run(BACKWARD);&#xA;      iteration = 1;&#xA;    }&#xA;    delay(600);&#xA;  }&#xA;  &#xA;  //starts motors going forward&#xA;  leftMotor.run(FORWARD);&#xA;  rightMotor.run(FORWARD);&#xA;  &#xA;  Serial.print(&amp;quot;Ping: &amp;quot;);&#xA;  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)&#xA;  Serial.println(&amp;quot;cm&amp;quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16658" LastEditorUserId="37622" LastEditDate="2021-12-01T13:33:17.680" LastActivityDate="2021-12-01T13:33:17.680" Title="afmotor saying &quot;servo does not name a type&quot;" Tags="|servo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="19890" PostTypeId="1" CreationDate="2016-01-23T16:33:50.327" Score="0" ViewCount="534" Body="&lt;p&gt;I need a command line implementation for uploading code to Teensy-LC through Windows 8.1 operating system&#xA;I know Paul has not released support for command line for Teensy-LC yet but i would like to know if any work has been done by anybody else in this regard.&lt;/p&gt;&#xA;&lt;p&gt;I asked &lt;a href=&quot;https://arduino.stackexchange.com/questions/19844/use-command-line-to-upload-program-through-hex-file-to-teensy-lc&quot;&gt;this&lt;/a&gt; and &lt;a href=&quot;https://arduino.stackexchange.com/questions/18679/is-it-possible-to-create-a-standalone-exe-which-can-burn-the-code-into-a-teensy&quot;&gt;this&lt;/a&gt;. But all these solutions include&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;sending the hex file to the user.&lt;/p&gt;&#xA;&lt;p&gt;Asking him to open Teensy.exe&lt;/p&gt;&#xA;&lt;p&gt;Asking him to upload the hex file into Teensy.ex&lt;/p&gt;&#xA;&lt;p&gt;Asking him to run teensy_reboot.exe&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So is it possible to create an installer of a sort for this purpose which eliminates the user performing all these operations separately and a guided installer simply with Next-&amp;gt;Next which does the entire job.&lt;/p&gt;&#xA;&lt;p&gt;But I suppose that since Command Line installer is not available for windows I don't know if this is possible for impossible.&lt;/p&gt;&#xA;&lt;p&gt;So if there is any way I can achieve an installer UI for Teensy-LC bootloader that would be perfect&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Other viable option&lt;/strong&gt;&#xA;If not that is it possible to make the entire process happen with the person not having direct access to the hex file.&#xA;Like sending a packaged installer or something&#xA;I am not sure how this would happen but if there is any possible way please help me out&lt;/p&gt;&#xA;" OwnerUserId="10165" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-27T09:23:32.280" Title="Use command line to upload hex code to teensy.ex" Tags="|uploading|bootloader|teensy|command-line|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19891" PostTypeId="2" ParentId="19889" CreationDate="2016-01-23T16:40:18.030" Score="1" Body="&lt;p&gt;You are creating &lt;code&gt;Servo&lt;/code&gt; objects instead of &lt;code&gt;AF_DCMotor&lt;/code&gt; objects. Change this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo leftMotor;&#xA;Servo rightMotor;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AF_DCMotor leftMotor(1);   // Change these numbers to the correct motor numbers&#xA;AF_DCMotor rightMotor(2);  // you are using on the shield&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-23T16:40:18.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19892" PostTypeId="1" AcceptedAnswerId="19894" CreationDate="2016-01-23T17:03:42.180" Score="20" ViewCount="16820" Body="&lt;p&gt;When one selects a board within Arduino IDE, a preprocessor definition is added to one of the behind-the-scenes files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a lot of hunting and some good fortune I found that the format of this definition is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ARDUINO_&amp;lt;PROCESSOR-DESCRIPTOR&amp;gt;_&amp;lt;BOARDNAME&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some are easy to guess (&lt;code&gt;ARDUINO_AVR_UNO&lt;/code&gt;, for example), but others are less so. The Pro Micro has '16' or '8' appended to the definition depending on the speed. I do not know if the definition is different for 5V or 3.3V. I haven't managed to guess the definition for the Mega2560, but it isn't anything obvious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 1&lt;/strong&gt;: Is there a list in existence of the possible definitions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question 2&lt;/strong&gt;: Is there any distinction, as far as compilation and preprocessor involvement is concerned, between &lt;em&gt;BoardX&lt;/em&gt;-5V and &lt;em&gt;BoardX&lt;/em&gt;-3.3V, and how is this distinction defined?&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2021-11-16T21:17:08.493" Title="List of Arduino board preprocessor #defines" Tags="|ide|c-preprocessor|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19893" PostTypeId="2" ParentId="19892" CreationDate="2016-01-23T17:16:41.377" Score="3" Body="&lt;p&gt;The first blank is the &lt;em&gt;platform&lt;/em&gt;. This is &quot;AVR&quot; for AVRs, &quot;SAM&quot; for SAM-based Arduinos, etc. This is derived from the platform directory containing the core.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second blank is the &lt;em&gt;board&lt;/em&gt;. This comes from the entry in &lt;code&gt;boards.txt&lt;/code&gt; in the core itself, and is the identifier before the first period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no difference between compilation processes with regards to voltages; any speed difference is given in &lt;code&gt;F_CPU&lt;/code&gt; and the board itself should not be checked for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there is no definitive list, since the list is of arbitrary size due to its source.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-23T17:16:41.377" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19894" PostTypeId="2" ParentId="19892" CreationDate="2016-01-23T17:40:01.630" Score="15" Body="&lt;p&gt;The list of board symbols can be generated by this shell command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ grep board= boards.txt | cut -f2 -d= | sort -u&#xA;AVR_ADK&#xA;AVR_BT&#xA;AVR_DUEMILANOVE&#xA;AVR_ESPLORA&#xA;AVR_ETHERNET&#xA;AVR_FIO&#xA;AVR_GEMMA&#xA;AVR_LEONARDO&#xA;AVR_LILYPAD&#xA;AVR_LILYPAD_USB&#xA;AVR_MEGA&#xA;AVR_MEGA2560&#xA;AVR_MICRO&#xA;AVR_MINI&#xA;AVR_NANO&#xA;AVR_NG&#xA;AVR_PRO&#xA;AVR_ROBOT_CONTROL&#xA;AVR_ROBOT_MOTOR&#xA;AVR_UNO&#xA;AVR_YUN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The boards are defined by the &quot;build.board&quot; property in the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/boards.txt&quot;&gt;boards.txt&lt;/a&gt; file. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mini.build.board=AVR_MINI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This property is used by the build &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/platform.txt#L52&quot;&gt;recipe&lt;/a&gt; together with ARDUINO_-prefix.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DARDUINO_{build.board} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-23T17:45:02.250" LastActivityDate="2016-01-23T17:45:02.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19896" PostTypeId="1" CreationDate="2016-01-23T20:17:41.380" Score="3" ViewCount="106" Body="&lt;p&gt;i'm trying to create a display that notifies me when someone goes live on twitch. I need to acess the API and check if the 'stream' object is null or not. Then, perform an action depending on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The address to the API is &lt;a href=&quot;http://api.twitch.tv/kraken/streams/pedrinholuizf&quot; rel=&quot;nofollow&quot;&gt;http://api.twitch.tv/kraken/streams/pedrinholuizf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can I do? I'm using an Arduino Leonardo with the Ethernet Shield.&lt;/p&gt;&#xA;" OwnerUserId="16664" LastActivityDate="2016-02-23T17:34:02.303" Title="Read information from Twitch's API and execute actions depending on the output" Tags="|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19897" PostTypeId="2" ParentId="12133" CreationDate="2016-01-23T20:22:43.020" Score="6" Body="&lt;p&gt;This fixed the problem for me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://blog.sengotta.net/signed-mac-os-driver-for-winchiphead-ch340-serial-bridge/&quot; rel=&quot;noreferrer&quot;&gt;http://blog.sengotta.net/signed-mac-os-driver-for-winchiphead-ch340-serial-bridge/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... and the &lt;a href=&quot;http://blog.sengotta.net/wp-content/uploads/2015/11/CH34x_Install.zip&quot; rel=&quot;noreferrer&quot;&gt;direct link&lt;/a&gt; to download.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I have one of the cheap clones with a CH340 USB chip. So this might not solve &lt;em&gt;your&lt;/em&gt; problem, but could be beneficial to others.&lt;/p&gt;&#xA;" OwnerUserId="16666" LastEditorUserId="16666" LastEditDate="2016-01-25T16:29:00.453" LastActivityDate="2016-01-25T16:29:00.453" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19898" PostTypeId="2" ParentId="2875" CreationDate="2016-01-23T20:59:34.153" Score="0" Body="&lt;p&gt;It is important to know that you do not measure the time from trigger start - by setting the Trigger pin HIGH - up to the Echo signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sensor HC-SR04 starts the measurement by receiving a HIGH on the Trigger input and then sends, a short time later, the time coded as the length of the HIGH level on the Echo pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;code&gt;pulseIn()&lt;/code&gt; 2 ms, i.e. 2000&amp;mu;s, after triggering, it should work fine.&lt;/p&gt;&#xA;" OwnerUserId="16667" LastEditorUserId="6936" LastEditDate="2016-01-24T20:59:17.607" LastActivityDate="2016-01-24T20:59:17.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19899" PostTypeId="1" CreationDate="2016-01-23T21:30:40.550" Score="0" ViewCount="354" Body="&lt;p&gt;Whenever I compile irrecvdemo of or remote library it gives error saying that fatal error saying &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;no file or directory exists &lt;code&gt;#include &amp;lt;WProgram.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;int RECV_PIN = 11;&#xA;&#xA;IRrecv irrecv(RECV_PIN);&#xA;&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    Serial.println(results.value, HEX);&#xA;    irrecv.resume(); // Receive the next value&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16668" LastEditorUserId="4143" LastEditDate="2016-01-25T20:52:33.437" LastActivityDate="2016-01-25T20:52:33.437" Title="Irrecvdemo program in or remote library gives fatal error #include&lt;WProgram.h&gt;" Tags="|arduino-uno|arduino-ide|remote-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19900" PostTypeId="2" ParentId="19899" CreationDate="2016-01-23T22:03:27.837" Score="2" Body="&lt;p&gt;You are using a very old library on a modern IDE.  The file that was called &lt;code&gt;WProgram.h&lt;/code&gt; in IDE version 0023 and below is now called &lt;code&gt;Arduino.h&lt;/code&gt;.  You will need to change any references to &lt;code&gt;WProgram.h&lt;/code&gt; to &lt;code&gt;Arduino.h&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well written libraries do this with a #ifdef block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if (ARDUINO &amp;gt;= 100)&#xA;# include &amp;lt;Arduino.h&amp;gt;&#xA;#else&#xA;# include &amp;lt;WProgram.h&amp;gt;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-23T22:03:27.837" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19901" PostTypeId="1" AcceptedAnswerId="19902" CreationDate="2016-01-23T22:45:04.570" Score="0" ViewCount="1087" Body="&lt;p&gt;I have an Arduino and I am building a space satellite, just for fun. I'm not going to launch it obviously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have built all the sensors and everything works. I was looking into communication because if a satellite is in space it needs to send down the data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to have radio communication between two Arduino or an Arduino and something else that are 100km apart, it doesn't need to particle, I'm just wondering if it is possible and how it works. Is it possible without going out to buy shields?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="10794" LastEditDate="2016-01-24T08:39:40.347" LastActivityDate="2016-01-24T08:39:40.347" Title="Arduino radio communications" Tags="|arduino-uno|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19902" PostTypeId="2" ParentId="19901" CreationDate="2016-01-23T23:09:25.697" Score="4" Body="&lt;p&gt;There are three basic factors that control long distance communication:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Transmitter Power&lt;/li&gt;&#xA;&lt;li&gt;Receiver Sensitivity&lt;/li&gt;&#xA;&lt;li&gt;Signal Directionality&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The more transmission power you have the &quot;louder&quot; your signal is at the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more sensitive your receiver the &quot;quieter&quot; the signals it can pick up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The more directional (focussed) your signal is the more arrives at the receiver and the less gets sent off elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would think get all three of those and you're laughing, but it's not that simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;High power transmission requires high-power power source&lt;/li&gt;&#xA;&lt;li&gt;Good focus requires heavy and bulky antennae.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Neither of those are very good on a satellite, since you want it to be as small and light as possible and use as little power as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in general you have a medium to low power transmitter on the satellite with &lt;em&gt;reasonable&lt;/em&gt; directionality, and put all the bulk on earth.  That is why satellite dishes are so big.  They give good focus, and the large size captures a lot of the signal making them more sensitive. You can also use very precise electronics to amplify the signal more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is, of course, nothing like that in a shield format, so you would have to create your own. The transmitter isn't so hard, since you don't want to have anything too meaty - the hard part comes when you want to make the base station.  If you can afford enough power to transmit a strong enough signal and have it with enough directionality you can use a satellite TV dish (not a little Sky dish, one of the bigger solid round ones - Sky satellites actually have quite powerful transmitters and the massive solar panels to go with it; not really practical for a small home-built satellite).  Getting the receiver and LNB (Low Noise Booster) tuned properly as well is vital - unless you're transmitting at the same frequency as the satellite the dish is intended to receive (which you mustn't or there'll be a lot of annoyed people around - there are specific frequency ranges you are allowed to use) then you will need to ensure the antenna is exactly the right length and that the LNB amplifies and filters the right frequency range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have got over all those hurdles the receiver is just a simple receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The actual transmitter and receiver circuits themselves can be something fairly off-the-shelf (the lower the frequency the better since that goes further than higher frequencies) - it's what goes between - the antenna and amplifier - that makes it much more special and long range.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-23T23:09:25.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19903" PostTypeId="1" CreationDate="2016-01-23T23:58:36.303" Score="2" ViewCount="1600" Body="&lt;p&gt;I have a Arduino Pro Mini 3.3V connected to a sim800l chip using a serial connection of 9600bps. When I connect the Arduino to the device, it seems I don't receive anything on the Arduino Rx pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then connected a FTDI that listen the sim800l Tx pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yqzfn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yqzfn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FTDI is able to receive data so this means the sim800l is working well by receiving data from the Arduino and responding accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So normal logic would say that the Arduino Rx pin is not working but when I connect the Arduino Rx and Tx pin together:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XAWDk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XAWDk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm able to receive what I send on Tx on the Rx pin.&#xA;Why would that be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried with AltSoftSerial and SoftwareSerial. The Arduino is powered by a FTDI connected to my computer via USB. The sim800l is powered by a second FTDI that is also powered by my computer USB. So all component uses the same ground and I verified that with my multi-meter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I use:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;AltSoftSerial sim800Serial(8,9); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  sim800Serial.begin(9600);&#xA;  void loop()&#xA;{&#xA;&#xA;while(1)&#xA;{&#xA;  if(sim800Serial.available())&#xA;  {&#xA;    Serial.write(sim800Serial.read());&#xA;  }&#xA;&#xA;  if(Serial.available())&#xA;  {    &#xA;    sim800Serial.write(Serial.read());&#xA;  }&#xA;}     &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16672" LastEditorUserId="37523" LastEditDate="2019-07-22T17:27:55.873" LastActivityDate="2019-07-22T17:27:55.873" Title="Why the serial connection only work when Tx and Rx are shorted?" Tags="|serial|softwareserial|ftdi|arduino-mini|simulator|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="19904" PostTypeId="2" ParentId="8847" CreationDate="2016-01-24T00:23:27.380" Score="1" Body="&lt;p&gt;Change baudrate to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UPLOAD_RATE=57600 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;Makefile&lt;/code&gt; (or via the GUI). I have seen your error many times and this fixes it, albeit on the 5V/16MHz mini USB variant. If 57600 does not work, try other values. I use this rate on my USB serial - may be different on bare Rx/Tx pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have probably not messed up your bootloader, that is rarer than people think. I think your Arduino has some invalid code running, and it keeps resetting until it finds valid code - when I had that problem, I pressed reset just before punching enter for 'make upload'. Even if it does that, you've got perhaps 0.5s to initiate an upload after reset. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do correct me if I'm wrong.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="6936" LastEditDate="2016-01-24T20:59:48.543" LastActivityDate="2016-01-24T20:59:48.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19905" PostTypeId="2" ParentId="19901" CreationDate="2016-01-24T01:41:02.840" Score="1" Body="&lt;p&gt;Majenko covered several aspects of radio communications between a satellite and a ground station.  An additional factor to consider is that the &lt;a href=&quot;https://en.wikipedia.org/wiki/Horizontal_coordinate_system&quot; rel=&quot;nofollow&quot;&gt;azimuth or altitude&lt;/a&gt; of a low-altitude satellite changes rapidly as it passes over a ground station.  For example, a satellite 100 km up takes about 86 minutes per orbit and travels at about 7.84 Km/s, and probably would be in view for less than a minute per pass.  [See eg &lt;em&gt;&lt;a href=&quot;http://keisan.casio.com/exec/system/1224665242&quot; rel=&quot;nofollow&quot;&gt;Orbit of a satellite Calculator&lt;/a&gt;&lt;/em&gt; at casio.com.]  Unless a phased array is used, and assuming communication is highly directional, the big dish on the ground will need to swing at up to 4.5° per second (about 270° per minute) as it tracks the satellite passing over.  The much smaller antenna on the spacecraft should rotate at the same rate, the opposite direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, an alternative to radio communications is a tight-beam laser system.  Rather than using big, bulky microwave or UHF antennas to achieve directionality, you would use a small telescope (a few cm of aperture) on the satellite and a larger telescope (as much aperture as you can afford) at the ground station.  Infrared or visible light lasers at each end of the link would be modulated to transmit at a high data rate.  Accurate tracking and aiming might end up being important research projects for this approach.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-24T01:41:02.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19906" PostTypeId="1" CreationDate="2016-01-24T02:16:25.053" Score="0" ViewCount="493" Body="&lt;p&gt;Over the years, I have acquired many TinkerKit modules for my Arduino Uno. My only issue is that I need to find a way to code using the native syntax, and not the less-powerful TinkerKit variation. To do this, I need to know if TinkerKit maps its 3-pin connector to the Arduino Board's pins (ex: 1, 3, 5). If it does, what are the mappings?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="16676" LastActivityDate="2016-01-24T09:30:15.243" Title="Converting TinkerKit to native Arduino pins" Tags="|pins|port-mapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19907" PostTypeId="2" ParentId="8847" CreationDate="2016-01-24T05:44:23.417" Score="2" Body="&lt;p&gt;I had the same problem and I used a magnifying glass to check the processor.  I bought my clones off of eBay and they are using the ATMega168 (3.3V, 8 MHZ) processor.  Once I realized my mistake and switched to the correct processor version, the upload was seamless.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an &quot;FTDI FT232RL USB to TTL Serial Converter Adapter Module 5V and 3.3V For Arduino&quot; for the programming connection, with&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DTS-DTS;&lt;/li&gt;&#xA;&lt;li&gt;Rx-Tx;&lt;/li&gt;&#xA;&lt;li&gt;Tx-Rx;&lt;/li&gt;&#xA;&lt;li&gt;VCC-VCC;&lt;/li&gt;&#xA;&lt;li&gt;GND-GND, and;&lt;/li&gt;&#xA;&lt;li&gt;GND-CTS.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I didn't even need to use the &quot;reset&quot; workaround of holding down the reset button before pressing the upload button and releasing when the words &quot;Maximum is ...&quot; appear in the output window.&lt;/p&gt;&#xA;" OwnerUserId="16680" LastEditorUserId="6936" LastEditDate="2016-01-24T20:44:06.350" LastActivityDate="2016-01-24T20:44:06.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19908" PostTypeId="2" ParentId="19906" CreationDate="2016-01-24T09:30:15.243" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://store.arduino.cc/product/T020010&quot; rel=&quot;nofollow&quot;&gt;TinkerKit Sensor Shield&lt;/a&gt; helps understand the mapping. There is also the &lt;a href=&quot;https://github.com/TinkerKit/TinkerKit/blob/master/TinkerKit.h&quot; rel=&quot;nofollow&quot;&gt;TinkerKit Header File&lt;/a&gt; with symbol mapping. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-24T09:30:15.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19909" PostTypeId="1" CreationDate="2016-01-24T11:26:52.477" Score="3" ViewCount="1786" Body="&lt;p&gt;I have been trying to make a communication with my industrial drive. All I want to do is read a few values of drive, like current, voltage etc.&#xA;For that I am using a library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand why it's happening. When the same code I have used before and the sketch was uploaded on the board, very well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code from an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleModbusMaster.h&amp;gt;&#xA;&#xA;// led to indicate that a communication error is present&#xA;#define connection_error_led 13&#xA;&#xA;//////////////////// Port information ///////////////////&#xA;#define baud 9600&#xA;#define timeout 1000&#xA;#define polling 200 // the scan rate&#xA;&#xA;// If the packets internal retry register matches&#xA;// the set retry count then communication is stopped&#xA;// on that packet. To re-enable the packet you must&#xA;// set the &quot;connection&quot; variable to true.&#xA;#define retry_count 10 &#xA;&#xA;// used to toggle the receive/transmit pin on the driver&#xA;#define TxEnablePin 2 &#xA;&#xA;// This is the easiest way to create new packets&#xA;// Add as many as you want. TOTAL_NO_OF_PACKETS&#xA;// is automatically updated.&#xA;enum&#xA;{&#xA;  PACKET1,&#xA;  PACKET2,&#xA;  // leave this last entry&#xA;  TOTAL_NO_OF_PACKETS&#xA;};&#xA;&#xA;// Create an array of Packets for modbus_update()&#xA;Packet packets[TOTAL_NO_OF_PACKETS];&#xA;&#xA;// Create a packetPointer to access each packet&#xA;// individually. This is not required you can access&#xA;// the array explicitly. E.g. packets[PACKET1].id = 2;&#xA;// This does become tedious though...&#xA;packetPointer packet1 = &amp;amp;packets[PACKET1];&#xA;packetPointer packet2 = &amp;amp;packets[PACKET2];&#xA;&#xA;// The data from the PLC will be stored&#xA;// in the regs array&#xA;unsigned int regs[9];&#xA;&#xA;void setup()&#xA;{&#xA;  // read 3 registers starting at address 0&#xA;  packet1-&amp;gt;id = 2;&#xA;  packet1-&amp;gt;function = READ_HOLDING_REGISTERS;&#xA;  packet1-&amp;gt;address = 0;&#xA;  packet1-&amp;gt;no_of_registers = 3;&#xA;  packet1-&amp;gt;register_array = regs;&#xA;&#xA;  // write the 9 registers to the PLC starting at address 3&#xA;  packet2-&amp;gt;id = 2;&#xA;  packet2-&amp;gt;function = PRESET_MULTIPLE_REGISTERS;&#xA;  packet2-&amp;gt;address = 3;&#xA;  packet2-&amp;gt;no_of_registers = 9;&#xA;  packet2-&amp;gt;register_array = regs;&#xA;&#xA;  // P.S. the register_array entries above can be different arrays&#xA;&#xA;  // Initialize communication settings etc...&#xA;  modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);&#xA;&#xA;  pinMode(connection_error_led, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned int connection_status = modbus_update(packets);&#xA;&#xA;  if (connection_status != TOTAL_NO_OF_PACKETS)&#xA;  {&#xA;    digitalWrite(connection_error_led, HIGH);&#xA;    // You could re-enable the connection by:&#xA;    //packets[connection_status].connection = true;&#xA;  }&#xA;  else&#xA;    digitalWrite(connection_error_led, LOW);&#xA;&#xA;  // update the array with the counter data&#xA;  regs[3] = packet1-&amp;gt;requests;&#xA;  regs[4] = packet1-&amp;gt;successful_requests;&#xA;  regs[5] = packet1-&amp;gt;total_errors;&#xA;  regs[6] = packet2-&amp;gt;requests;&#xA;  regs[7] = packet2-&amp;gt;successful_requests;&#xA;  regs[8] = packet2-&amp;gt;total_errors; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, here is the error I am receiving upon uploading the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;Arduino: 1.0.6 (Windows 7), Board: &quot;Arduino Uno&quot;&#xA;SimpleModbusMasterExample:110: error: 'packetPointer' does not name a type&#xA;SimpleModbusMasterExample:111: error: 'packetPointer' does not name a type&#xA;SimpleModbusMasterExample.ino: In function 'void setup()':&#xA;SimpleModbusMasterExample:120: error: 'packet1' was not declared in this scope&#xA;SimpleModbusMasterExample:127: error: 'packet2' was not declared in this scope&#xA;SimpleModbusMasterExample:136: error: invalid conversion from 'int' to 'HardwareSerial*'&#xA;SimpleModbusMasterExample:136: error: invalid conversion from 'Packet*' to 'unsigned char'&#xA;C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:143: error: too few arguments to function 'void modbus_configure(HardwareSerial*, long int, unsigned char, long int, long int, unsigned char, unsigned char, Packet*, unsigned int, unsigned int*)'&#xA;SimpleModbusMasterExample:136: error: at this point in file&#xA;C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h: In function 'void loop()':&#xA;C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:125: error: too many arguments to function 'void modbus_update()'&#xA;SimpleModbusMasterExample:143: error: at this point in file&#xA;SimpleModbusMasterExample:143: error: void value not ignored as it ought to be&#xA;SimpleModbusMasterExample:155: error: 'packet1' was not declared in this scope&#xA;SimpleModbusMasterExample:158: error: 'packet2' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16682" LastActivityDate="2016-06-17T15:40:29.093" Title="Arduino throwing error while using modbus RS485 code" Tags="|arduino-uno|c|rs485|modbus|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19910" PostTypeId="1" AcceptedAnswerId="19922" CreationDate="2016-01-24T12:47:43.007" Score="0" ViewCount="1360" Body="&lt;p&gt;I have successfully setup up a RFID reader with Arduino Uno and EM-18 Card Reader Module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its program for Arduino is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0; // count = 0&#xA;&#xA;char input[12];                                         // character array of size 12&#xA;&#xA;boolean flag = 0;                                       // flag =0&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);                                  // begin serial port with baud rate 9600bps&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   if(Serial.available())&#xA;&#xA;{&#xA;&#xA;count = 0;&#xA;&#xA;while(Serial.available() &amp;amp;&amp;amp; count &amp;lt; 12)          // Read 12 characters and store them in input array&#xA;&#xA;{&#xA;input[count] = Serial.read();&#xA;count++;&#xA;delay(5);&#xA;}&#xA;&#xA;//Serial.print(&quot;Card ID - &quot;);&#xA;&#xA;Serial.print(input);      // Print RFID tag number &#xA;&#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when try to read the code over serial in the program for locking/unlocking mouse in Processing the values of strings don't match.&#xA;Hence the mouse doesn't get unlocked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program for processing is as below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;import java.awt.AWTException;&#xA;import java.awt.Robot;&#xA;&#xA;Robot robot;&#xA;boolean locked = false;&#xA;Serial port;&#xA;void setup()&#xA;{&#xA;  println(Serial.list()); //Prints available ports&#xA;&#xA;  port = new Serial(this, Serial.list()[36], 9600); //Chooses the first available port&#xA;  try&#xA;  {&#xA;    robot = new Robot(); //Creates robot&#xA;  }&#xA;  catch (AWTException e)&#xA;  {&#xA;    e.printStackTrace();&#xA;  }&#xA;}&#xA;&#xA;void draw()&#xA;{&#xA;  if (locked == true) robot.mouseMove(0, 0); //If locked, moves mouse to top left corner&#xA;  while (port.available() &amp;gt; 0)&#xA;  {&#xA;    String input = port.readString(); &#xA;    //println(input);&#xA;    if (input.equals(&quot;11006F26DC84&quot;) == true) locked = false; //If it read my card it will unloack.&#xA;  }&#xA;}&#xA;&#xA;void keyPressed ()&#xA;{&#xA;  if (key == 'l')&#xA;  {&#xA;    locked = true; //Locks it&#xA;  }&#xA;&#xA;  if (key == 'u')&#xA;  {&#xA;    locked = false; //Unlocks it&#xA;  }&#xA;&#xA;  if (key == ESC)&#xA;  {&#xA;    key = 0; //Disables escape as quit&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please point the incorrect syntax and suggest correct one.&lt;/p&gt;&#xA;" OwnerUserId="8509" LastEditorUserId="2881" LastEditDate="2016-01-24T13:07:52.510" LastActivityDate="2016-01-24T17:32:49.510" Title="Read RFID Card Number in Processing over Serial" Tags="|arduino-uno|rfid|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19911" PostTypeId="1" AcceptedAnswerId="19915" CreationDate="2016-01-24T13:35:43.143" Score="0" ViewCount="445" Body="&lt;p&gt;Trying to latch a 200 mS, LOW event to log the event.  LOW only occurs when external Watchdog timer sends reset pulse to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is a D Latch suitable for this application?  It has been years since my digital class; help most appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you proceed?&lt;/p&gt;&#xA;" OwnerUserId="16684" LastActivityDate="2016-01-24T14:52:04.970" Title="How to latch a 200mS LOW pulse?" Tags="|hardware|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19912" PostTypeId="1" AcceptedAnswerId="19916" CreationDate="2016-01-24T13:46:42.653" Score="0" ViewCount="62" Body="&lt;p&gt;I am building a motion following robot. It has two PIR sensors on the left and right. It has an ultrasonic sensor in the front. When either of the PIR sensors detect motion then it turns to that side. &#xA;&lt;br&gt;&lt;br&gt;When both the PIR sensors sense motion then I calculate the distance first( with the ultrasonic sensor, if distance &amp;lt;= 50 cm and &gt; 5 cm then the robot moves forward. But it could mean that the motion is either in the front or in the back. Thus, my robot moves forward even the motion is behind it. &#xA;&lt;br&gt;&lt;br&gt; I need some help devising a method so that when motion is detected behind then the robot will turn back. I tried making the robot turn right when both the sensors detect motion, then it will turn towards the left(i.e. front) or right(i.e. back). But in reality this method is not so practical as it would to a lot of confusion when the intruder we are trying to detect is still in motion. Plz help. A sample sketch would help.&lt;/p&gt;&#xA;" OwnerUserId="16336" LastEditorUserId="16336" LastEditDate="2016-01-24T14:56:42.767" LastActivityDate="2016-01-24T15:39:58.327" Title="Detecting Motion behind a robot" Tags="|sensors|sketch|project|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19913" PostTypeId="1" AcceptedAnswerId="19914" CreationDate="2016-01-24T14:01:14.857" Score="4" ViewCount="4668" Body="&lt;p&gt;I am newbie, I need to measure precise voltage in range 0.00-0.80V, two digits precision. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage will not be greater than 1V-1.2V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if I need divider or not, I am sure that voltage won't rise above 1.2V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I connect the point to measure directly to analog input, or I still need to use divider? Please explain why. &lt;/p&gt;&#xA;" OwnerUserId="14025" LastEditorUserId="6936" LastEditDate="2016-02-18T12:28:25.143" LastActivityDate="2016-02-18T12:28:25.143" Title="Precision voltmeter using Arduino" Tags="|arduino-uno|arduino-nano|analogread|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19914" PostTypeId="2" ParentId="19913" CreationDate="2016-01-24T14:13:34.513" Score="7" Body="&lt;p&gt;A divider is used to (as the name suggests) reduce a higher voltage to a lower voltage.  Using a divider on a small voltage will only make it smaller and harder to measure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the most out of your measuring you need to have the &lt;em&gt;reference&lt;/em&gt; voltage as close to the highest voltage you want to measure as possible.  The highest voltage that can be applied is not dependent on the reference voltage, but the supply voltage, and as 1.2V is way less than 5V (or 3.3V on a 3.3V board) you have no worries there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to change the reference voltage - the voltage that the ADC uses as its upper &lt;em&gt;measurement&lt;/em&gt; voltage.  That's simple enough, since many of the Arduino boards include an internal 1.1V analog reference voltage generator that you can switch to (see: &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot;&gt;analogReference()&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when you have switched to the 1.1V analog reference the ADC is capable of measuring 0-1.1V in 1024 steps.  That's 1.1/1023=0.00107V per bit of precision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The formula is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V = ADC / 1023 * Vref&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So a reading of 1 would give you 0.00107V - a reading of 2 would be 0.00215V, etc.  That's plenty of resolution to meet your 2 decimal places requirement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;One thing to note&lt;/em&gt;&lt;/strong&gt; though is that the internal 1.1V reference isn't that stable or accurate (or not even there on some chips).  If you need better stability and accuracy then it could pay to use an external voltage reference chip.  These are like a linear voltage regulator but are far more accurate and stable (and can't provide lots of current).  Pick one that is greater than your upper measurement voltage but as close to it as you can get (so just above 0.8V) and feed the output into the external &lt;em&gt;ARef&lt;/em&gt; pin and switch the analog reference to the &lt;code&gt;EXTERNAL&lt;/code&gt; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; use a voltage divider on the external ARef pin to provide a low reference voltage, but the stability and accuracy will be no better (and probably worse) than the internal 1.1V voltage reference, so there really is no point.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-24T14:13:34.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19915" PostTypeId="2" ParentId="19911" CreationDate="2016-01-24T14:26:38.980" Score="1" Body="&lt;p&gt;I understand your question to be :  you want to latch (and indicate) whenever an external watchdog timer has reset your Arduino.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;D type flip flop (latch) can be used.  You would use the clock input as the trigger. However, most D types clock on a rising edge. You could use an inverter on the input to the clock to get the D type to clock on a falling edge. You would also connect the D (Data) input high (logic 1). Then when your input (event) goes low, the Q output will latch high.  The 200 mS is irrelevant because the latch ocurrs at the change from high to low (low to high on clock input).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would also need a means of resetting the latch, which many D types have a reset input or a clear input.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iLDH3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iLDH3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also use a more simple SR latch (set reset latch) using 2 Nand gates.  SR latch changes state when the “set” input goes low (providing that R input was high).  Make the R input go low to reset the latch.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nAjFT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nAjFT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;POSSIBLE ALTERNATIVE :  If you have some means of operator intervention (or even a switch).  You could have your program light an LED at startup.  Operator (person) could reset LED.  Then afterwards,  any reset (restart of program) would light the LED.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-01-24T14:52:04.970" LastActivityDate="2016-01-24T14:52:04.970" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19916" PostTypeId="2" ParentId="19912" CreationDate="2016-01-24T15:39:58.327" Score="1" Body="&lt;p&gt;This is a basic problem of only having two sensors.  There is no way that two sensors of this simple type (some motion yes/no) can be used to work out where the motion comes from except when there is a difference between the two sensors.  Anything else is, and always will be, ambiguous.&lt;/p&gt;&#xA;&lt;p&gt;If you think of it as a circle divided in two, you have only three possible conditions:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/d2Xeo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d2Xeo.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;That is, &lt;em&gt;left&lt;/em&gt;, &lt;em&gt;right&lt;/em&gt; or &lt;em&gt;somewhere&lt;/em&gt;.  Not ideal.&lt;/p&gt;&#xA;&lt;p&gt;So you need more data to be able to make a decision.  That means more sensors.  The ideal scenario is four sensors - left, right, front and rear.  That gives you many possible scenarios, including:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WPggl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WPggl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As you can see from that you have a full 360° idea of where the motion is. You can even know how far to the left it is by if the front or rear is also on.  For instance, using sailing terminology, those 8 circles would mean (in order):&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Motion on the left beam&lt;/li&gt;&#xA;&lt;li&gt;Motion on the port bow&lt;/li&gt;&#xA;&lt;li&gt;Motion dead ahead&lt;/li&gt;&#xA;&lt;li&gt;Motion on the starboard bow&lt;/li&gt;&#xA;&lt;li&gt;Motion on the starboard beam&lt;/li&gt;&#xA;&lt;li&gt;Motion on the starboard quarter&lt;/li&gt;&#xA;&lt;li&gt;Motion dead astern&lt;/li&gt;&#xA;&lt;li&gt;Motion on the port quarter&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Also the dead-ahead and dead-astern could be indicated by just the forward or rear sensor on and the left/right sensors both off.  You could even use that fact to give some indication of the distance of the motion depending on the angular coverage of the different sensors.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-24T15:39:58.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19917" PostTypeId="1" CreationDate="2016-01-24T15:58:42.800" Score="0" ViewCount="1737" Body="&lt;p&gt;How do I rectify this error?&#xA;Clearly it says there is some error in the library, so how do I correct it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:1: error: expected unqualified-id before 'if'&lt;/p&gt;&#xA;" OwnerUserId="16688" LastActivityDate="2016-01-25T17:28:22.863" Title="SoftwareSerial library" Tags="|softwareserial|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="19918" PostTypeId="1" AcceptedAnswerId="19923" CreationDate="2016-01-24T16:06:43.857" Score="1" ViewCount="308" Body="&lt;p&gt;I am trying to get this pH project working and I've noticed that the serialEvent3 never sets the boolean value sensor_string_complete to true.  I am not sure if it is actually capturing the values from the probe.  What I want is for every loop through it should grab a pH value and that is not happening right now.  Most times through the loop the serial3 port is not providing any values.  Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String sensorstring = &quot;&quot;;&#xA;boolean sensor_string_complete = false;&#xA;float pH;&#xA;&#xA;void setup() {&#xA;  Serial.begin(38400);&#xA;  Serial3.begin(38400); // pH stamp&#xA;}&#xA;&#xA;void serialEvent3() {                                 //if the hardware       serial port_3 receives a char&#xA;  sensorstring = Serial3.readStringUntil(13);         //read the string until we see a &amp;lt;CR&amp;gt;&#xA;  sensor_string_complete = true;                      //set the flag used to tell if we have received a completed string from the PC&#xA;}&#xA;&#xA;void loop() {&#xA;  getPh();&#xA;  if (sensor_string_complete == true) readph();&#xA;}&#xA;&#xA;void getPh() {&#xA;  Serial.println(&quot;we are here&quot;);&#xA;  Serial3.print(&quot;r&quot;);&#xA;  Serial3.print(13);&#xA;}&#xA;&#xA;void readph(){&#xA;  Serial.println(&quot;read ph here&quot;);&#xA;  if (isdigit(sensorstring[0])) {&#xA;    pH = sensorstring.toFloat();&#xA;    Serial.println(pH);&#xA;  }&#xA;  else{&#xA;    Serial.println(sensorstring);&#xA;  }&#xA;&#xA;  sensorstring = &quot;&quot;; &#xA;  sensor_string_complete = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This returns values such as&#xA;we are here&#xA;we are here&#xA;we are here&#xA;read ph here&#xA;7.0&#xA;we are here&#xA;read ph here&#xA;7.0&#xA;we are here&#xA;we are here&#xA;we are here&#xA;read ph here&#xA;7.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this to return these values every loop.  I expect to see:&#xA;We are here&#xA;read ph here&#xA;7.0&#xA;We are here&#xA;read ph here&#xA;7.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help on this would be great.  Thanks so much!&lt;/p&gt;&#xA;" OwnerUserId="16513" LastActivityDate="2016-01-24T17:55:00.103" Title="Atlas Scientific pH project - serialEvent3 problems" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19919" PostTypeId="1" CreationDate="2016-01-24T16:41:35.417" Score="2" ViewCount="2630" Body="&lt;p&gt;I have a project that involves sending messages from an Android device to an Arduino using a bluetooth module. I am using an HC-05 bluetooth module and an Arduino Mega 2560. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works as long as I power the Arduino to my laptop using a USB cable. However, I need to use an external power source and have been using a 6F22 9V battery connected through the VIN pin for this purpose, without facing any problems. But on connecting the HC-05, it does not even light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is also connected to four dc motors, five servo motors (all of which are externally powered, only get digital signals from the Arduino), and seven HC-SR04 ultrasound sensors, whcih are powered through the 5V pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected the HC-05 to the Arduino as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HC-05   Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VCC      3.3V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND      GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX       RX&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RX       TX           through a voltage divider&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to all this, and would be grateful for any help. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="16687" LastActivityDate="2016-01-24T17:25:22.503" Title="Using Bluetooth module HC-05 when Arduino is powered using a battery" Tags="|arduino-mega|bluetooth|battery|hc-05|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19920" PostTypeId="2" ParentId="19919" CreationDate="2016-01-24T17:25:22.503" Score="2" Body="&lt;p&gt;6F22 (PP3) batteries are among the wimpiest of batteries available.  They are not a good choice for anything except extreme low power applications, and anything involving radio transmitters is definitely not an extreme low power application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a better battery.  I would recommend 6 AA batteries (you can get 6xAA battery holders with the same connector as a PP3 battery) which will give you considerably more power than a little PP3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either that or a 7.2V &quot;2S&quot; Li-Ion battery pack.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-24T17:25:22.503" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19921" PostTypeId="2" ParentId="19896" CreationDate="2016-01-24T17:32:39.490" Score="2" Body="&lt;p&gt;Break your problem into small steps and try to identify the success criteria for each step. So you might:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try to set up the Ethernet shield and get it to respond to a ping on your local network.&lt;/li&gt;&#xA;&lt;li&gt;Try to connect to a site outside of your network.&lt;/li&gt;&#xA;&lt;li&gt;See if you can find some examples of using the Twitch API.&lt;/li&gt;&#xA;&lt;li&gt;Try to replicate one of the simple examples.&lt;/li&gt;&#xA;&lt;li&gt;See if you can get the Stream object that you want.&lt;/li&gt;&#xA;&lt;li&gt;See if you can read the value of the object.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you have a plan and try to follow it you'll be able to tell us what you've been doing and where you got stuck / confused. That is likely to get you better answers – both because we can be more specific and also because we can see that you're &quot;carrying your weight&quot; as we work on the problem.&lt;/p&gt;&#xA;" OwnerUserId="10907" LastActivityDate="2016-01-24T17:32:39.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19922" PostTypeId="2" ParentId="19910" CreationDate="2016-01-24T17:32:49.510" Score="1" Body="&lt;p&gt;&lt;code&gt;input&lt;/code&gt; has to be 13 characters in size; you forgot to include a byte for the null-terminator. Then right before &lt;code&gt;Serial.print(input)&lt;/code&gt;, you write &lt;code&gt;input[12] = 0&lt;/code&gt;. Also the argument to &lt;code&gt;string.equals()&lt;/code&gt; should be a String as well; you must write the statement like this: &lt;code&gt;input.equals(String(&quot;11006F26DC84&quot;));&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-01-24T17:32:49.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19923" PostTypeId="2" ParentId="19918" CreationDate="2016-01-24T17:55:00.103" Score="3" Body="&lt;p&gt;On a typical Arduino, the delay between &lt;code&gt;loop()&lt;/code&gt; ending and &lt;code&gt;loop()&lt;/code&gt; running again is a few microseconds.  &lt;code&gt;Serial.println()&lt;/code&gt; in &lt;code&gt;getPh()&lt;/code&gt; is interrupt-driven so that call too takes only a few microseconds.  Writing two bytes with &lt;code&gt;Serial3.print()&lt;/code&gt; at 38400 bps will take about half a millisecond.  In short, there is plenty of time for &lt;code&gt;loop()&lt;/code&gt; to run several times before  &lt;code&gt;serialEvent3()&lt;/code&gt; sets &lt;code&gt;sensor_string_complete&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To call  &lt;code&gt;getPh()&lt;/code&gt; once and &lt;code&gt;readph()&lt;/code&gt; once per &lt;code&gt;loop()&lt;/code&gt;, instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (sensor_string_complete == true) readph();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (!sensor_string_complete) {}&#xA;readph();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will stall the loop while the pH sensor takes and reports a reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, in &lt;code&gt;getPh()&lt;/code&gt; instead of using two separate &lt;code&gt;Serial3.print()&lt;/code&gt; statements, you can just say &lt;code&gt;Serial3.print(&quot;r\r&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-24T17:55:00.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19924" PostTypeId="1" AcceptedAnswerId="19925" CreationDate="2016-01-24T17:58:46.453" Score="3" ViewCount="3303" Body="&lt;p&gt;I am trying to build an oscilloscope using an Arduino Due and an LCD. I have the LCD running perfectly and started working on using the ADC peripheral to sample signals. Here's what I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SAMPLE_BUFFER_SIZE 800&#xA;volatile int sample_buffer[SAMPLE_BUFFER_SIZE];&#xA;volatile bool sample_buffer_full = 0;&#xA;volatile int sample_buffer_idx = 0;&#xA;&#xA;void adcm_init() {&#xA;    pmc_enable_periph_clk(ID_ADC); // To use peripheral, we must enable clock distributon to it&#xA;    adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST); // initialize, set maximum posibble speed&#xA;    adc_disable_interrupt(ADC, 0xFFFFFFFF);&#xA;    adc_set_resolution(ADC, ADC_12_BITS);&#xA;    adc_configure_power_save(ADC, 0, 0); // Disable sleep&#xA;    adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1); // Set timings - standard values&#xA;    adc_set_bias_current(ADC, 1); // Bias current - maximum performance over current consumption&#xA;    adc_stop_sequencer(ADC); // not using it&#xA;    adc_disable_tag(ADC); // it has to do with sequencer, not using it&#xA;    adc_disable_ts(ADC); // deisable temperature sensor&#xA;    adc_disable_channel_differential_input(ADC, ADC_CHANNEL_7);&#xA;    adc_configure_trigger(ADC, ADC_TRIG_SW, 1); // triggering from software, freerunning mode&#xA;    adc_disable_all_channel(ADC);&#xA;    adc_enable_channel(ADC, ADC_CHANNEL_7); // just one channel enabled&#xA;    adc_enable_interrupt(ADC, ADC_IER_DRDY);            // Data Ready Interrupt Enable&#xA;    NVIC_EnableIRQ(ADC_IRQn);&#xA;    adc_start(ADC);&#xA;}&#xA;&#xA;void ADC_Handler(void)  {&#xA;    if (!sample_buffer_full) {&#xA;&#xA;        if ((adc_get_status(ADC) &amp;amp; ADC_ISR_DRDY) == ADC_ISR_DRDY) {&#xA;&#xA;            sample_buffer[sample_buffer_idx] = adc_get_latest_value(ADC);&#xA;            sample_buffer_idx++;&#xA;&#xA;            if (sample_buffer_idx == SAMPLE_BUFFER_SIZE) {&#xA;                sample_buffer_full = 1;&#xA;                sample_buffer_idx = 0;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    adcm_init();&#xA;    Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.print(&quot;Loop\n&quot;);&#xA;    if (sample_buffer_full) {&#xA;        for (int i = 0; i &amp;lt; SAMPLE_BUFFER_SIZE; i++) {&#xA;            Serial.print(sample_buffer[i]);&#xA;            Serial.print(&quot; &quot;);&#xA;        }&#xA;        Serial.print(&quot;\n&quot;);&#xA;        sample_buffer_full = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was copied and slightly modified from somewhere on the internet (can't remember where, though). I have also studied the docs and this code seems to make perfect sense and it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is for the sampling to be interrupt-based. However, if I set the ADC to freerunning mode and enable interrupts, it just gives up and stops working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I mean by that is: on my serial monitor, after pressing reset, all I see are 2 lines saying &quot;Loop&quot; and it just stops there. Normally it should print &quot;Loop&quot; indefinitely, and also print ADC values from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I disable interrupts, &quot;Loop&quot; is printed indefinitely, but of course no values are shown. If I disable free-running mode, &quot;Loop&quot; is printed and no values are shown unless the buffer size is 1, in which case the same value is printed over and over (as expected, in that case the interrupt runs only once, right at the beginning).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CPU clock freq. is 84Mhz, I'm going for the fastest I can get out of the ADC, so a sample is taken (and an interrupt is fired) every 1Mhz. That means 84 clock cycles per interrupt. Don't know for sure if that is enough for the rest of the program to work, but my gut tells me that's not a problem. Besides, I tried with a lower ADC clock value and it still didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? I'm really at a loss here...&lt;/p&gt;&#xA;" OwnerUserId="16623" LastEditorUserId="16623" LastEditDate="2016-01-24T20:31:56.390" LastActivityDate="2016-01-24T20:38:41.060" Title="Arduino Due: Interrupt-based ADC hangs processing" Tags="|arduino-due|interrupt|adc|analog-sampling|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19925" PostTypeId="2" ParentId="19924" CreationDate="2016-01-24T19:09:45.167" Score="4" Body="&lt;p&gt;In your interrupt handler, &lt;code&gt;ADC_Handler()&lt;/code&gt;, you set &lt;code&gt;sample_buffer_full&lt;/code&gt; when the buffer is full.  &lt;s&gt;I don't see anywhere in the code where  &lt;code&gt;sample_buffer_full&lt;/code&gt; ever gets reset (cleared) once it's been set.&lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While &lt;code&gt;sample_buffer_full&lt;/code&gt; is set, it disables the body of the interrupt handler – ie, the handler's structure is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!sample_buffer_full) { ...body of handler... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;– and in particular, prevents &lt;code&gt;adc_get_latest_value(ADC);&lt;/code&gt; from occurring.  The &lt;a href=&quot;https://android.googlesource.com/platform/external/arduino-ide/+/f876b2abdebd02acfa4ba21e607327be4f9668d4/hardware/arduino/sam/system/libsam/source/adc.c?autodive=0%2F%2F%2F&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt; of &lt;code&gt;adc_get_latest_value();&lt;/code&gt; is like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t adc_get_latest_value(const Adc *p_adc) {&#xA;  return p_adc-&amp;gt;ADC_LCDR;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which accesses the ADC data register.  According to section 43.6.4 &lt;em&gt;Conversion Results&lt;/em&gt; on page 1322 of the data sheet, Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The channel EOC bit in the Status Register (ADC_SR) is set and the DRDY is set. In the case of a connected PDC channel, DRDY rising triggers a data transfer request. In any case, either EOC and DRDY can trigger an&#xA;  interrupt.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Reading one of the ADC_CDR registers clears the corresponding EOC bit. Reading ADC_LCDR clears the DRDY bit and EOC bit corresponding to the last converted channel.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It appears to me that your code enables interrupts, fills a buffer, sets &lt;code&gt;sample_buffer_full&lt;/code&gt;, then spins in &lt;code&gt;ADC_Handler()&lt;/code&gt;.  That is, repeatedly executes &lt;code&gt;ADC_Handler()&lt;/code&gt; without clearing the EOC bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, for  oscilloscope applications with a Due, I suggest using DMA buffers instead of one interrupt per conversion.  See &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=137635.5&quot; rel=&quot;nofollow&quot;&gt;thread #137635&lt;/a&gt;, &lt;em&gt;speed of analogRead&lt;/em&gt;, in forum.arduino.cc for DMA code to read one or two analog channels on a Due at one sample per microsecond.  Also see &lt;a href=&quot;http://www.edaboard.com/thread283843.html&quot; rel=&quot;nofollow&quot;&gt;edaboard.com/thread283843&lt;/a&gt; and &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=186169.0&quot; rel=&quot;nofollow&quot;&gt;forum.arduino.cc #186169&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit note:&lt;/em&gt; Although &lt;code&gt;sample_buffer_full&lt;/code&gt; does get reset, that reset happens after a time-consuming for-loop.  Whether it takes some hundreds of microseconds or a few milliseconds, the for-loop is enough of a delay that at least one more conversion and interrupt will occur before &lt;code&gt;sample_buffer_full&lt;/code&gt; gets cleared.  One unhandled conversion is enough to lock up the interrupt handler.  Here are some alternative approaches to consider:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Use a circular buffer, and never stop filling it.  This is ok if you are only interested in the most recent data, rather than a complete waveform record.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Set or reset &lt;code&gt;sample_buffer_full&lt;/code&gt; as now; and remove the initial if test from the handler.  Instead, put an &lt;code&gt;if&lt;/code&gt; before &lt;code&gt;sample_buffer_idx++;&lt;/code&gt;, to not increment if the buffer is full.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Turn off ADC's freerun mode.  This is a reasonable thing to do when not taking data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Turn off ADC's interrupt when not taking data.  Also reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Use multiple buffers.  Reasonable, but by itself doesn't avoid the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Read the latest value every time the handler executes [for example, say &lt;code&gt;int datum = adc_get_latest_value(ADC);&lt;/code&gt; as the first statement in the handler] and then only store that value in certain cases.  An easy and effective way to avoid problem.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-24T20:38:41.060" LastActivityDate="2016-01-24T20:38:41.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19926" PostTypeId="1" AcceptedAnswerId="19928" CreationDate="2016-01-24T21:03:40.513" Score="1" ViewCount="167" Body="&lt;p&gt;I'm new to electrical engineering and I am currently trying to make a motor turn on for one second, turn off for one second, and repeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Uno's &lt;code&gt;digitalWrite()&lt;/code&gt; feature to activate a transistor, allowing the external 9V battery to turn on the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although everything is responding, instead of the motor turning on and off like I want it to, it spins fast for a second, then spins slower for a second. I would like the motor to stop completely, but cannot figure out how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the schematic of my circuit:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EoTLx.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fEoTLx.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){    &#xA;  pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;void loop(){    &#xA;  digitalWrite(9, HIGH);    &#xA;  delay(1000);    &#xA;  digitalWrite(9, LOW);    &#xA;  delay(1000);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why isn't the motor completely turning off?&lt;/p&gt;&#xA;" OwnerUserId="16697" OwnerDisplayName="tethernova" LastEditorUserId="6936" LastEditDate="2016-01-24T21:27:57.417" LastActivityDate="2016-01-24T21:27:57.417" Title="Transistor slows motor instead of turning it off" Tags="|motor|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19927" PostTypeId="2" ParentId="19926" CreationDate="2016-01-24T21:11:17.280" Score="3" Body="&lt;p&gt;There are multiple things wrong with your drawn schematic:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The ground symbol is not wrong but really misleading. &lt;/li&gt;&#xA;&lt;li&gt;You forgot to add a flyback diode.&lt;/li&gt;&#xA;&lt;li&gt;You wired the load the wrong way: the load is placed between the collector and VCC, not between emitter and GND.&lt;/li&gt;&#xA;&lt;li&gt;The base resistor is way too high. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16378" OwnerDisplayName="d3l" LastActivityDate="2016-01-24T21:11:17.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19928" PostTypeId="2" ParentId="19926" CreationDate="2016-01-24T21:13:34.640" Score="6" Body="&lt;p&gt;I can't make much sense of your diagram-  but this is the correct way to do it: &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/cGWWK.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fcGWWK.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1 is low enough that the base gets 10-15mA of drive, sufficient for a few hundred mA of motor current. D1 protects the transistor Q1 when it turns off (from the motor inductance). The emitter of the NPN transistor should be grounded and then the collector will either be near ground or at the 9V level depending on whether it is off or on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have damaged the transistor you are using (due to breaking it down in reverse across the E-B junction) so I would suggest proceeding with a new one. You didn't mention it, but it probably got quite warm. &lt;/p&gt;&#xA;" OwnerUserId="5080" OwnerDisplayName="Spehro Pefhany" LastActivityDate="2016-01-24T21:17:38.810" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19930" PostTypeId="1" CreationDate="2016-01-25T00:02:33.770" Score="2" ViewCount="442" Body="&lt;p&gt;I want to make a MP3 player with arduino. My problem is what board should I use? There is the SparkFun MP3 Player Shield, SparkFun Audio-Sound Breakout - WTV020SD. Then I want to attach a 2.8 TFT touch screen to control volume,change track etc. Can I attach it to for example on top of MP3 player shield?I'm thinking in this one &lt;a href=&quot;https://www.adafruit.com/products/1651&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1651&lt;/a&gt;. And finally what speakers can I use with which board? I want some good small speakers, two to be exact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really need help with electronics and programming. Just need to know wich are the best components that can work with each other without spending a lot of money. Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best Regards&lt;/p&gt;&#xA;" OwnerUserId="16702" LastEditorUserId="11529" LastEditDate="2016-01-26T16:15:59.630" LastActivityDate="2017-06-17T19:19:40.043" Title="Arduino MP3 Player" Tags="|arduino-uno|electronics|audio|sound|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19931" PostTypeId="2" ParentId="19917" CreationDate="2016-01-25T00:05:05.833" Score="1" Body="&lt;p&gt;As you haven't shown the code that produces the error when it's compiled, I can't say for sure what the problem is.  However, here are links to three instances of the same error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• &lt;em&gt;&lt;a href=&quot;https://stackoverflow.com/q/8690446&quot;&gt;error: expected unqualified-id before 'if'&lt;/a&gt;&lt;/em&gt; on stackoverflow&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• &lt;em&gt;&lt;a href=&quot;https://stackoverflow.com/q/14538210&quot;&gt;Arduino: error: expected unqualified-id before 'if' (using ping sensor)&lt;/a&gt;&lt;/em&gt;, also on stackoverflow&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• &lt;em&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=26465.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;error: expected unqualified-id before 'if'&lt;/a&gt;&lt;/em&gt; on arduino.cc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In each case, the problem was due to executable code (as opposed to declarations) appearing outside of a function.  You may have put some executable statements outside of &lt;code&gt;loop()&lt;/code&gt; or &lt;code&gt;setup()&lt;/code&gt;, etc.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-01-25T00:05:05.833" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19932" PostTypeId="1" CreationDate="2016-01-25T00:07:13.313" Score="-2" ViewCount="9006" Body="&lt;pre&gt;&lt;code&gt;void GravaFicheiros(CONFERENCIA *co)&#xA;{&#xA;&#xA;    int i, ii, iii;&#xA;&#xA;    FILE *fp;&#xA;&#xA;    fp = fopen(&quot;grabameisso&quot;, &quot;wt&quot;);&#xA;&#xA;    fprintf (fp, &quot;%s\n&quot;, co-&amp;gt;nomeconf);&#xA;&#xA;    int k = NSessoes(co);&#xA;    fprintf (fp, &quot;%d\n&quot;, k);&#xA;&#xA;    for (i = 0; i &amp;lt; k; i++)&#xA;    {&#xA;&#xA;        fprintf (fp, &quot;%s\n%d\n%d\n&quot;, co-&amp;gt;sessoes[i].tema, co-&amp;gt;sessoes[i].hora, co-&amp;gt;sessoes[i].auditorio);&#xA;&#xA;        int a = NArtigos(co, i);&#xA;&#xA;        fprintf (fp, &quot;%d\n&quot;, a);&#xA;&#xA;        for (ii = 0; ii &amp;lt; a; ii++)&#xA;        {&#xA;&#xA;            fprintf (fp, &quot;%s\n&quot;, co-&amp;gt;sessoes[i].artigos[ii].titulo);&#xA;&#xA;            int aa = NAutores(co, i, ii);&#xA;&#xA;            fprintf (fp, &quot;%d\n&quot;, aa);&#xA;&#xA;            for (iii = 0; iii &amp;lt; aa, iii++)&#xA;            {&#xA;&#xA;                fprintf (fp, &quot;%s\n%d\n&quot;, co-&amp;gt;sessoes[i].artigos[ii].autores[iii].nome, co-&amp;gt;sessoes[i].artigos[ii].autores[iii].idade);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    fclose(fp);&#xA;    return;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16703" LastEditorUserId="10794" LastEditDate="2016-01-25T01:26:32.393" LastActivityDate="2016-01-25T01:30:38.927" Title="c expected ; before ) token" Tags="|c++|c|" AnswerCount="1" CommentCount="1" ClosedDate="2016-01-25T06:29:51.133" ContentLicense="CC BY-SA 3.0" />
  <row Id="19934" PostTypeId="2" ParentId="19932" CreationDate="2016-01-25T00:13:37.023" Score="3" Body="&lt;p&gt;Although you didn't ask a specific question I assume you want to know why there was an error in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of your for loops is missing a semi-colon.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (iii = 0; iii &amp;lt; aa, iii++) //this line gives the error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for (iii = 0; iii &amp;lt; aa; iii++) //the comma should be a semi-colon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When it says ; expected before token ). It means quite literally that there is a ; missing before a ).&lt;/p&gt;&#xA;" OwnerUserId="16705" LastEditorUserId="10794" LastEditDate="2016-01-25T01:30:38.927" LastActivityDate="2016-01-25T01:30:38.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19935" PostTypeId="1" AcceptedAnswerId="19944" CreationDate="2016-01-25T01:28:45.797" Score="2" ViewCount="5722" Body="&lt;p&gt;Is it possible to connect more than one or to be specific 5 MPU9250 into 1 Arduino lilypad? How will I set the addresses, and where should I put the pins for SDA and SCL? I hope someone out there could help me on this project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What if I have this working codes, how will I edit this to connect more than two MPU9250? Please guide me. Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Wire.h&amp;gt;&#xA; #include &amp;lt;TimerOne.h&amp;gt;&#xA;&#xA; #define    MPU9250_ADDRESS            0x68&#xA;&#xA;&#xA; #define    MAG_ADDRESS                0x0C&#xA;&#xA; #define    GYRO_FULL_SCALE_250_DPS    0x00  &#xA; #define    GYRO_FULL_SCALE_500_DPS    0x08&#xA; #define    GYRO_FULL_SCALE_1000_DPS   0x10&#xA; #define    GYRO_FULL_SCALE_2000_DPS   0x18&#xA;&#xA; #define    ACC_FULL_SCALE_2_G        0x00  &#xA; #define    ACC_FULL_SCALE_4_G        0x08&#xA; #define    ACC_FULL_SCALE_8_G        0x10&#xA; #define    ACC_FULL_SCALE_16_G       0x18&#xA;&#xA;&#xA;&#xA; // This function read Nbytes bytes from I2C device at address Address. &#xA;// Put read bytes starting at register Register in the Data array. &#xA;void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t*      Data)&#xA;{&#xA;// Set register address&#xA;Wire.beginTransmission(Address);&#xA;Wire.write(Register);&#xA;Wire.endTransmission();&#xA;&#xA;// Read Nbytes&#xA;Wire.requestFrom(Address, Nbytes); &#xA;uint8_t index=0;&#xA;while (Wire.available())&#xA;Data[index++]=Wire.read();&#xA;}&#xA;&#xA;&#xA;// Write a byte (Data) in device (Address) at register (Register)&#xA;void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data)&#xA;{&#xA;// Set register address&#xA;Wire.beginTransmission(Address);&#xA;Wire.write(Register);&#xA;Wire.write(Data);&#xA;Wire.endTransmission();&#xA;}&#xA;&#xA;&#xA;&#xA;// Initial time&#xA;long int ti;&#xA;volatile bool intFlag=false;&#xA;&#xA;// Initializations&#xA;void setup()&#xA;{&#xA;// Arduino initializations&#xA;Wire.begin();&#xA;Serial.begin(115200);&#xA;&#xA;// Set accelerometers low pass filter at 5Hz&#xA;I2CwriteByte(MPU9250_ADDRESS,29,0x06);&#xA;// Set gyroscope low pass filter at 5Hz&#xA;I2CwriteByte(MPU9250_ADDRESS,26,0x06);&#xA;&#xA;&#xA;// Configure gyroscope range&#xA;I2CwriteByte(MPU9250_ADDRESS,27,GYRO_FULL_SCALE_1000_DPS);&#xA;// Configure accelerometers range&#xA; I2CwriteByte(MPU9250_ADDRESS,28,ACC_FULL_SCALE_4_G);&#xA; // Set by pass mode for the magnetometers&#xA; I2CwriteByte(MPU9250_ADDRESS,0x37,0x02);&#xA;&#xA; // Request continuous magnetometer measurements in 16 bits&#xA; I2CwriteByte(MAG_ADDRESS,0x0A,0x16);&#xA;&#xA; pinMode(13, OUTPUT);&#xA; Timer1.initialize(10000);         // initialize timer1, and set a 1/2   second period&#xA; Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt&#xA;&#xA;&#xA; // Store initial time&#xA; ti=millis();&#xA; }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA; // Counter&#xA; long int cpt=0;&#xA;&#xA; void callback()&#xA;  { &#xA;  intFlag=true;&#xA;  digitalWrite(13, digitalRead(13) ^ 1);&#xA;  }&#xA;&#xA;  // Main loop, read and display data&#xA;  void loop()&#xA;  {&#xA;  while (!intFlag);&#xA;  intFlag=false;&#xA;&#xA;  // Display time&#xA;  Serial.print (millis()-ti,DEC);&#xA;  Serial.print (&quot;\t&quot;);&#xA;&#xA;&#xA;   // _______________&#xA;  // ::: Counter :::&#xA;&#xA;   // Display data counter&#xA;  //  Serial.print (cpt++,DEC);&#xA; //  Serial.print (&quot;\t&quot;);&#xA;&#xA;&#xA;&#xA;  // ____________________________________&#xA;  // :::  accelerometer and gyroscope ::: &#xA;&#xA; // Read accelerometer and gyroscope&#xA; uint8_t Buf[14];&#xA; I2Cread(MPU9250_ADDRESS,0x3B,14,Buf);&#xA;&#xA; // Create 16 bits values from 8 bits data&#xA;&#xA;// Accelerometer&#xA;int16_t ax=-(Buf[0]&amp;lt;&amp;lt;8 | Buf[1]);&#xA;int16_t ay=-(Buf[2]&amp;lt;&amp;lt;8 | Buf[3]);&#xA;int16_t az=Buf[4]&amp;lt;&amp;lt;8 | Buf[5];&#xA;&#xA;// Gyroscope&#xA;int16_t gx=-(Buf[8]&amp;lt;&amp;lt;8 | Buf[9]);&#xA;int16_t gy=-(Buf[10]&amp;lt;&amp;lt;8 | Buf[11]);&#xA;int16_t gz=Buf[12]&amp;lt;&amp;lt;8 | Buf[13];&#xA;&#xA; // Display values&#xA;&#xA;// Accelerometer&#xA;Serial.print (ax,DEC); &#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (ay,DEC);&#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (az,DEC);  &#xA;Serial.print (&quot;\t&quot;);&#xA;&#xA;// Gyroscope&#xA;Serial.print (gx,DEC); &#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (gy,DEC);&#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (gz,DEC);  &#xA;Serial.print (&quot;\t&quot;);&#xA;&#xA;&#xA;// _____________________&#xA;// :::  Magnetometer ::: &#xA;&#xA;&#xA;// Read register Status 1 and wait for the DRDY: Data Ready&#xA;&#xA;uint8_t ST1;&#xA;do&#xA;{&#xA; I2Cread(MAG_ADDRESS,0x02,1,&amp;amp;ST1);&#xA;}&#xA;while (!(ST1&amp;amp;0x01));&#xA;&#xA;// Read magnetometer data  &#xA;uint8_t Mag[7];  &#xA;I2Cread(MAG_ADDRESS,0x03,7,Mag);&#xA;&#xA;&#xA;// Create 16 bits values from 8 bits data&#xA;&#xA;// Magnetometer&#xA;int16_t mx=-(Mag[3]&amp;lt;&amp;lt;8 | Mag[2]);&#xA;int16_t my=-(Mag[1]&amp;lt;&amp;lt;8 | Mag[0]);&#xA;int16_t mz=-(Mag[5]&amp;lt;&amp;lt;8 | Mag[4]);&#xA;&#xA;&#xA;// Magnetometer&#xA;Serial.print (mx+200,DEC); &#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (my-70,DEC);&#xA;Serial.print (&quot;\t&quot;);&#xA;Serial.print (mz-700,DEC);  &#xA;Serial.print (&quot;\t&quot;);&#xA;&#xA;&#xA;&#xA;// End of line&#xA;Serial.println(&quot;&quot;);&#xA;//  delay(100);    &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="16602" LastEditDate="2016-01-27T02:32:17.200" LastActivityDate="2017-08-20T01:18:27.357" Title="How to use Multiple MPU9250 to Arduino Lilypad" Tags="|arduino-mega|accelerometer|gyroscope|magnetometer|" AnswerCount="4" CommentCount="0" ClosedDate="2018-02-07T10:00:00.797" ContentLicense="CC BY-SA 3.0" />
  <row Id="19936" PostTypeId="2" ParentId="19935" CreationDate="2016-01-25T01:40:06.127" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;https://moderndevice.com/wp-content/uploads/2014/09/PS-MPU-9250A-01.pdf&quot; rel=&quot;nofollow&quot;&gt;the datasheet&lt;/a&gt; the MPU-9250 can work in either I2C or SPI mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it is in SPI mode you can connect up as many MPU-9250s as you have spare IO pins.  With SPI the clock and data lines are all shared, and each slave device has its own Slave Select line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In I2C mode it is possible to only use 2 devices at once - the AD0 pin configures which is which device (connect it to GND or VCC to identify the two devices).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly the MPU-9250 does include an I2C master module for connecting other sensors to it. Theoretically it should be possible to connect the master port of an MPU-9250 to two other MPU-9250s, and each of those could connect to a further two MPU-9250s each, and so on and so forth in a huge tree.  However the programming of such an environment would be an absolute nightmare and not something I would like to undertake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in summary: use SPI mode, it's simpler.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T01:40:06.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19937" PostTypeId="2" ParentId="9744" CreationDate="2016-01-25T02:16:10.523" Score="1" Body="&lt;p&gt;There are two things I do; I use the Serial.print(F(&quot;string/n&quot;)); which prints the data from flash rather then copying it to ram.  Keep as many of your variables local as possible, that will save ram.  This is done by defining then in the function, the added advantage nothing outside the function can change them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Global and Static variables are the first things loaded into SRAM. They push the start of the heap upward toward the stack and they will occupy this space for all eternity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Variables created in functions, are dynamically allocated objects and data. Unlike Global and Static variables, these variables can be de-allocated to free up space at function exit. But Every function call creates a stack frame that makes the stack grow toward the heap. This data is usable within the function, but the space is 100% reclaimed when the function exits!&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2016-01-25T02:16:10.523" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19938" PostTypeId="2" ParentId="19935" CreationDate="2016-01-25T04:05:14.040" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;where should I put the pins for SDA and SCL?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Same as on a Uno:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SDA is on pin A4&lt;/li&gt;&#xA;&lt;li&gt;SCL is on pin A5&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you suggest me some links that can help me learn more about SPI?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow noreferrer&quot;&gt;an SPI page&lt;/a&gt; and also one about &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a page about SPI on this site: &lt;a href=&quot;https://arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino&quot;&gt;How do you use SPI on an Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use 5 devices, it sounds like Majenko's recommendation is good: Use SPI. You would share MOSI/MISO/SCK between all devices (D11/D12/D13), and give each one a separate SS (slave select) line.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-25T04:05:14.040" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19939" PostTypeId="1" CreationDate="2016-01-25T04:55:23.687" Score="0" ViewCount="1136" Body="&lt;p&gt;Could I get something like this, a 12v silicone heating pad, and vary its temperature with an arduino somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.banggood.com/Waterproof-Silicone-Flexible-Heating-Pad-6060MM-DC-12V-10W-p-972464.html&quot; rel=&quot;nofollow&quot;&gt;http://www.banggood.com/Waterproof-Silicone-Flexible-Heating-Pad-6060MM-DC-12V-10W-p-972464.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My grand plan is to put temperature sensors on it and make it hit a certain temperature, and make it hotter/cooler to try and reach a target temperature.&lt;/p&gt;&#xA;" OwnerUserId="14424" LastActivityDate="2017-06-26T11:28:23.303" Title="What could I use to vary the temperature of a Heating Pad?" Tags="|temperature-sensor|mosfet|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19941" PostTypeId="2" ParentId="19871" CreationDate="2016-01-25T06:13:13.763" Score="1" Body="&lt;p&gt;The ESP8266-01 will boot and show some boot up messages at baud rate 76800 before switching to the default configured baud rate of 9600 or 115200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try setting the baud rate to 76800 and reset the ESP8266 to see if you can see the boot up messages first to determine if your circuit is working. You might see something like this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ets Jan 8 2013,rst cause:4, boot mode:(3,7)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15819" LastActivityDate="2016-01-25T06:13:13.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19942" PostTypeId="2" ParentId="19939" CreationDate="2016-01-25T08:11:58.570" Score="4" Body="&lt;p&gt;In principle, I don't see any problems. Your heating pad uses 12V and 10W, which means it would be consuming slightly less than one amp of current. The MOSFET you linked can go up to 5A (needing a heat sink with over 1A).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use PWM (there are 6 pins on a Uno that can do that) to provide pulse-width modulation to control the amount of output you give to the heater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would, of course, need to measure the heat of the device to work out when to adjust the PWM output. You might look up using a PID algorithm to adjust the PWM output depending on the sensed heat input.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/pid&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pid&amp;#39;&quot; rel=&quot;tag&quot;&gt;pid&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/pwm&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;pwm&amp;#39;&quot; rel=&quot;tag&quot;&gt;pwm&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/mosfet&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;mosfet&amp;#39;&quot; rel=&quot;tag&quot;&gt;mosfet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;/questions/tagged/sensors&quot; class=&quot;post-tag&quot; title=&quot;show questions tagged &amp;#39;sensors&amp;#39;&quot; rel=&quot;tag&quot;&gt;sensors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-25T08:11:58.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19944" PostTypeId="2" ParentId="19935" CreationDate="2016-01-25T10:38:43.473" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to connect more than one or to be specific 5 MPU9250 into 1 Arduino lilypad? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, that is possible with both SPI and I2C. With SPI you will need MOSI(11), MISO(12), SCK(13), and CSn where CSn is CS0..CS4 are digital pins in output mode for chip select. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With I2C the following pins are needed SDA(A4), SCL(A5), and CSn. The chip select pin is connected to AD0 on the device. AD0 is used for the lowest bit in the I2C address. Addressing is achieved by connecting AD0 to CSn and keeping all high except the one that is addressed. The I2C address is the same for all access. The CSn pin defines which device will response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example code below uses the lower address and chip select is put low for the selected device. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Chip select pin device#0&#xA;const int CS0 = 4;&#xA;...&#xA;void setup() &#xA;{&#xA;  ...&#xA;  // Initiate chip select pin for device#0&#xA;  pinMode(CS0, OUTPUT);&#xA;  digitalWrite(CS0, HIGH);&#xA;  ...&#xA;}&#xA;...&#xA;void loop()&#xA;{&#xA;   ...&#xA;   // Select device#0 &#xA;   digitalWrite(CS0, LOW);&#xA;   MPU9250_someFunction();&#xA;   digitalWrite(CS0, HIGH);&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How will I set the addresses, and where should I put the pins for SDA and SCL?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SDA is connected to A4 and SCL to A5. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the above given example code (from the question) a rewrite of the I2Cread function could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This function read Nbytes bytes from MPU9250 device with chip select pin. &#xA;// Put read bytes starting at register Register in the Data array. &#xA;&#xA;void MPU9250_read(uint8_t CS, uint8_t Register, uint8_t Nbytes, uint8_t* Data)&#xA;{&#xA;  digitalWrite(CS, LOW);&#xA;&#xA;  // Set register address&#xA;  Wire.beginTransmission(MPU9250_ADDRESS);&#xA;  Wire.write(Register);&#xA;  Wire.endTransmission();&#xA;&#xA;  // Read Nbytes&#xA;  Wire.requestFrom(Address, Nbytes); &#xA;  uint8_t index = 0;&#xA;  while (Wire.available()) Data[index++] = Wire.read();&#xA;&#xA;  digitalWrite(CS, HIGH);&#xA;}&#xA;...&#xA;// Read magnetometer data from device#3&#xA;uint8_t Mag[7];  &#xA;MPU9250_read(CS3, 0x03, 7, Mag);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-27T08:59:08.887" LastActivityDate="2016-01-27T08:59:08.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19945" PostTypeId="2" ParentId="17710" CreationDate="2016-01-25T10:53:43.217" Score="2" Body="&lt;p&gt;This could be a general programming question. The only thing specific to&#xA;Arduino here is that you may want a solution that minimizes the use of&#xA;memory and avoids floating point operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a memory-friendly solution that reformats the string &lt;em&gt;in place&lt;/em&gt;,&#xA;i.e. it overwrites the original string. In many cases this is&#xA;appropriate, as it is unlikely that you need the original string later,&#xA;but you have to make sure it fits your application. It works by first&#xA;moving a few characters around in order to have the format &quot;dd.mmmmm&quot;,&#xA;then parsing the minutes and converting to fractional degrees, then&#xA;writing that in ASCII.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be noted that the only reason for dropping the last digit in&#xA;the minutes field is to avoid 32-bit operations. I compiled for an Uno&#xA;and checked the generated assembly: it uses only four bytes of RAM, in&#xA;the stack.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Convert the format of a latitude from &quot;ddmm.mmmm&quot; to &quot;dd.dddd&quot;.&#xA;// The string is converted in place.&#xA;void convertLat(char* s)&#xA;{&#xA;    // Convert ddmm.mmmm to dd.mmmmm&#xA;    s[4] = s[3];  // move minutes&#xA;    s[3] = s[2];  // move tens of minutes&#xA;    s[2] = '.';   // put decimal point&#xA;    s[8] = '\0';  // drop last digit&#xA;&#xA;    // Compute fractional degrees.&#xA;    uint16_t fraction = atoi(s + 3);  // unit = 1e-3 arcmin&#xA;    fraction /= 6;                    // unit = 1e-4 deg&#xA;&#xA;    // Write in ASCII, right to left.&#xA;    s[7] = '\0';&#xA;    for (int i = 6; i &amp;gt; 2; i--) {&#xA;        s[i] = fraction % 10 + '0';&#xA;        fraction /= 10;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use this same function to convert a longitude from &quot;dddmm.mmmm&quot;&#xA;to &quot;ddd.dddd&quot; by just skipping the first character:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;static inline void convertLon(char* s)&#xA;{&#xA;    convertLat(s + 1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: To answer Lipsyor comment, it is possible to have the&#xA;latitude in units of 1e-6 deg by using 32-bit arithmetic:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Convert the format of a latitude from &quot;ddmm.mmmm&quot; to &quot;dd.dddddd&quot;.&#xA;// The string is converted in place.&#xA;void convertLat(char* s)&#xA;{&#xA;    // Convert ddmm.mmmm to dd.mmmmmm&#xA;    s[4] = s[3];  // move minutes&#xA;    s[3] = s[2];  // move tens of minutes&#xA;    s[2] = '.';   // put decimal point&#xA;&#xA;    // Compute fractional degrees.&#xA;    uint32_t fraction = atol(s + 3);     // unit = 1e-4 arcmin&#xA;    fraction = (fraction * 10 + 3) / 6;  // unit = 1e-6 deg&#xA;&#xA;    // Write in ASCII, right to left.&#xA;    for (int i = 8; i &amp;gt; 2; i--) {&#xA;        s[i] = fraction % 10 + '0';&#xA;        fraction /= 10;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;+ 3&lt;/code&gt; in the computation is only to round to nearest. Dropping this&#xA;term should not make any significant difference.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-05-27T16:01:36.293" LastActivityDate="2016-05-27T16:01:36.293" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19946" PostTypeId="1" AcceptedAnswerId="19947" CreationDate="2016-01-25T12:06:57.283" Score="0" ViewCount="694" Body="&lt;p&gt;I'm currently working on a self-balancing robot with an Arduino Uno and a 10DOF ADXL345 sensor. Everything is going fine until I got to this PID tuning part. I've read about it several times but I'm unable to get the desired results. Can somebody give a detailed guide on PID tuning? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="16716" LastActivityDate="2016-01-26T02:41:10.310" Title="PID tuning help" Tags="|robotics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19947" PostTypeId="2" ParentId="19946" CreationDate="2016-01-25T12:21:50.887" Score="1" Body="&lt;p&gt;Maybe you can help yourself with this &lt;a href=&quot;http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; for PID line follower robot. I successfully tuned my PID for line following and had some success with PID for wall following with sonar.&lt;/p&gt;&#xA;" OwnerUserId="8308" LastActivityDate="2016-01-25T12:21:50.887" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19948" PostTypeId="2" ParentId="19871" CreationDate="2016-01-25T12:32:19.093" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dQo7D.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dQo7D.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;1.What firmware ? AT commands do not work in nodeMcu firmware. &#xA;Usually the AT firmware work to 115200 bps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.If your FTD232 works at 5V, you will need resistor between Arduino TX and ESP RX. ESP8266 only works at 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3.Try esplorer - is a very nice tool to test ESP8266:&#xA;&lt;a href=&quot;http://esp8266.ru/esplorer/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://esp8266.ru/esplorer/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16717" LastEditorUserId="16717" LastEditDate="2016-01-25T13:02:26.710" LastActivityDate="2016-01-25T13:02:26.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19950" PostTypeId="2" ParentId="19810" CreationDate="2016-01-25T14:17:41.197" Score="1" Body="&lt;p&gt;I have been meaning to try the Arduino IDE on Ubuntu. (I'm on Ubuntu 14.10 LTS and using an original Arduino UNO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the top, I installed using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install arduino arduino-core&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(from: &lt;a href=&quot;http://playground.arduino.cc/Linux/Ubuntu&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Linux/Ubuntu&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the older version 1.0.5 and loaded up the basic sketch. It worked straight off the bat. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just some quick thoughts:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Keyboard and mouse emulation&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I noticed the &lt;code&gt;hid-generic&lt;/code&gt; and was reminded of the caution on:&lt;br&gt;&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoLeonardoMicro#toc13&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/ re codig practices for keyboard and mouse emulation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;regarding coding practices for keyboard and mouse emulation. Does your old sketch utilise the keyboard/mouse libraries at all? It might come down to REALLY timing the reset perfectly.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The &lt;code&gt;reset&lt;/code&gt; problem&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Given that you're getting a communication error based on the virtual USB device in the Leonardo/Micro (single chip as opposed to the previous versions), and you're seeing it in the IDE but not via the &lt;code&gt;avrdude&lt;/code&gt; software, have you followed the &lt;code&gt;reset&lt;/code&gt; instructions from &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoLeonardoMicro#toc12&quot; rel=&quot;nofollow&quot;&gt;the above link&lt;/a&gt;? So back to timing the reset (emphasis mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In general, you upload code to the Leonardo or Micro as you would with the Uno or other Arduino boards. Click the upload button in the Arduino IDE and your sketch will be automatically uploaded onto the board and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the board, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;However, because the serial port is virtual, it disappears when the board resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo or Micro (using the serial port selected in the Tools &gt; Serial Port menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the bootloader. It then performs the upload on this newly-appeared port.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. &lt;strong&gt;Press and hold the reset button on the Leonardo or Micro, then hit the upload button in the Arduino software. Only release the reset button &lt;em&gt;AFTER&lt;/em&gt; you see the message &quot;Uploading...&quot; appear in the software's status bar.&lt;/strong&gt; When you do so, the bootloader will start, creating a new virtual (CDC) serial port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated when the computer opens the serial port at 1200 baud and then closes it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h1&gt;&lt;code&gt;avrdude&lt;/code&gt; command line&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Next, share your &lt;code&gt;avrdude&lt;/code&gt; command line and we can see if something is odd there. As an example with my UNO I see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build1362089533882735765.tmp/Blink.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/usr/share/arduino/hardware/tools/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/madivad/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM0&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: Send: 0 [30]   [20] &#xA;.... and so on ....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;USB 3 vs USB 2&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I probably could have put this closer to the top, but are you using a USB 2 or USB 3 port? If USB 3 are the correct drivers loaded? Have you tried a USB 2 port (if available)&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Good luck&lt;/h1&gt;&#xA;" OwnerUserId="304" LastActivityDate="2016-01-25T14:17:41.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19951" PostTypeId="1" AcceptedAnswerId="19960" CreationDate="2016-01-25T16:33:14.147" Score="1" ViewCount="9899" Body="&lt;p&gt;I am trying to compile my project, but unfortunately get errors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created class and separated implementation and declaration (cpp file and h file)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here they are &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;sensor.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef SENSOR_H&#xA;#define SENSOR_H&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;#include &quot;Arduino.h&quot;&#xA;// Sensor types&#xA;enum SensorType {&#xA;  ANY_SENSOR,&#xA;  UNKNOWN_SENSOR,&#xA;  WATER_SENSOR,&#xA;  TEMPERATURE_SENSOR,&#xA;  VIBRATION_SENSOR,&#xA;  INTERCOM_SENSOR,&#xA;  HUMIDITY_SENSOR,&#xA;  PIR_SENSOR,&#xA;  SOUND_SENSOR,&#xA;  LIGHT_SENSOR&#xA;};&#xA;class Sensor {&#xA;  public:&#xA;  // Variables declaration&#xA;    uint32_t sensorId;&#xA;    SensorType sensorType;&#xA;    float currentValue;&#xA;    bool isEnabled;&#xA;    float criticalLowerLevel;&#xA;    float criticalUpperLevel;&#xA;   // Methods declaration&#xA;    Sensor();&#xA;    Sensor(uint32_t id,SensorType type,long currentValue,bool isEnabled,long lower,long upper);&#xA;    String toString();&#xA;    bool isCriticalLevelRised() {&#xA;      return (this-&amp;gt;currentValue &amp;gt;= this-&amp;gt;criticalUpperLevel || this-&amp;gt;currentValue &amp;lt;= this-&amp;gt;criticalLowerLevel);&#xA;    };&#xA;    void enable(bool enable);&#xA;    void toggle();&#xA;    static String convertSensorTypeToString(SensorType sensorType);&#xA;};&#xA;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And cpp file &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;sensor.h&quot;&#xA;Sensor::Sensor()&#xA;{&#xA;  this-&amp;gt;sensorId = 0;&#xA;  this-&amp;gt;sensorType = UNKNOWN_SENSOR;&#xA;  this-&amp;gt;currentValue = 0;&#xA;  this-&amp;gt;isEnabled = false;&#xA;  this-&amp;gt;criticalLowerLevel = 0;&#xA;  this-&amp;gt;criticalUpperLevel = 0;&#xA;}&#xA;Sensor::Sensor(uint32_t id,SensorType type,long currentValue,bool isEnabled,long lower,long upper) {&#xA;  this-&amp;gt;sensorId = id;&#xA;  this-&amp;gt;sensorType = type;&#xA;  this-&amp;gt;currentValue = currentValue;&#xA;  this-&amp;gt;isEnabled = isEnabled;&#xA;  this-&amp;gt;criticalLowerLevel = lower;&#xA;  this-&amp;gt;criticalUpperLevel = upper;&#xA;}&#xA;void Sensor::enable(bool enable) { &#xA;   this-&amp;gt;isEnabled = enable;&#xA;}&#xA;void Sensor::toggle() {&#xA;  this-&amp;gt;enable(!this-&amp;gt;isEnabled);&#xA;}&#xA;String Sensor::toString()&#xA;{&#xA;  String response = &quot;&quot;;&#xA;  response += F(&quot;Sensor id is &quot;);&#xA;  response += this-&amp;gt;sensorId;&#xA;  response += '\n';&#xA;  response += F(&quot;Sensor type is &quot;);&#xA;  response += convertSensorTypeToString(this-&amp;gt;sensorType);&#xA;  response += '\n';&#xA;  response += F(&quot;Sensor current value is &quot;);&#xA;  response += this-&amp;gt;currentValue;&#xA;  response += '\n';&#xA;  response += F(&quot;Sensor isEnabled is &quot;);&#xA;  response += this-&amp;gt;isEnabled;&#xA;  response += '\n';&#xA;  response += F(&quot;Sensor criticalLowerLevel is &quot;);&#xA;  response += this-&amp;gt;criticalLowerLevel;&#xA;  response += '\n';&#xA;  response += F(&quot;Sensor criticalLowerLevel is &quot;);&#xA;  response += this-&amp;gt;criticalUpperLevel;&#xA;  response += '\n';&#xA;  return response;&#xA;}&#xA;String Sensor::convertSensorTypeToString(SensorType sensorType) {&#xA;  switch (sensorType) {&#xA;    case UNKNOWN_SENSOR:&#xA;      return F(&quot;UNKNOWN SENSOR&quot;);&#xA;    case ANY_SENSOR:&#xA;      return F(&quot;ANY_SENSOR&quot;);&#xA;    case WATER_SENSOR:&#xA;      return F(&quot;WATER_SENSOR&quot;);&#xA;    case TEMPERATURE_SENSOR:&#xA;      return F(&quot;TEMPERATURE_SENSOR&quot;);&#xA;    case VIBRATION_SENSOR:&#xA;      return F(&quot;VIBRATION_SENSOR&quot;);&#xA;    case HUMIDITY_SENSOR:&#xA;      return F(&quot;HUMIDITY_SENSOR&quot;);&#xA;    case PIR_SENSOR:&#xA;      return F(&quot;PIR_SENSOR&quot;);&#xA;    case SOUND_SENSOR:&#xA;      return F(&quot;SOUND_SENSOR&quot;);&#xA;    case LIGHT_SENSOR:&#xA;      return F(&quot;LIGHT_SENSOR&quot;);&#xA;    default:&#xA;      return F(&quot;UNKNOWN TYPE&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I got following errors &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ketch/NodeIntercom.ino.cpp.o: In function `sendSensorMessageToMaster(RF24Mesh*, SensorDataMessage*, char, unsigned int, bool)':&#xA;/home/iron/Arduino/What'sHappening/NetworkMaster/additional_functions.h:48: undefined reference to `Sensor::toString()'&#xA;sketch/NodeIntercom.ino.cpp.o: In function `handleSetSensorDataRequest(RF24NetworkHeader*)':&#xA;/home/iron/Arduino/What'sHappening/NodeIntercom/NodeIntercom.ino:97: undefined reference to `Sensor::toggle()'&#xA;/home/iron/Arduino/What'sHappening/NodeIntercom/NodeIntercom.ino:89: undefined reference to `Sensor::enable(bool)'&#xA;sketch/NodeIntercom.ino.cpp.o: In function `SensorDataMessage':&#xA;/home/iron/Arduino/What'sHappening/NetworkMaster/common.h:40: undefined reference to `Sensor::Sensor()'&#xA;sketch/NodeIntercom.ino.cpp.o: In function `__static_initialization_and_destruction_0':&#xA;/home/iron/Arduino/What'sHappening/NodeIntercom/NodeIntercom.ino:35: undefined reference to `Sensor::Sensor(unsigned long, SensorType, long, bool, long, long)'&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong ? &#xA;Please help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes main sketch compiles perfectly where this files are located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't want to duplicate common files in my all my arduino sketches withing the project, they are the same for whole project. Here my files location &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--ArduinoProjects&#xA;---NodeIntercom&#xA;----NodeIntercom.ino&#xA;---MasterNode&#xA;----MasterNode.ino&#xA;----sensor.h&#xA;----sensor.cpp&#xA;----common.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this files are only located in MasterNode directory &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I tried to include them like this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;/home/iron/Arduino/What'sHappening/NetworkMaster/common.h&quot;&#xA;#include &quot;/home/iron/Arduino/What'sHappening/NetworkMaster/additional_functions.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in common.h I include sensor.h &#xA;Also tried to include directly, but still the same&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But headers files included as above works perfectly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the right way to solve this problem, I don't want to duplicate this class in each folder whenever I change it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no way, maybe create symbolic link (I am using linux) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PARTIAL SOLUTION&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just use symbolic links in the sketch directory and this works perfectly&lt;/p&gt;&#xA;" OwnerUserId="14025" LastEditorUserId="10794" LastEditDate="2016-01-25T20:35:01.853" LastActivityDate="2016-01-26T09:02:42.780" Title="Arduino declaring class in h and cpp file Undefined Reference" Tags="|arduino-uno|c++|arduino-ide|class|ino|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19952" PostTypeId="2" ParentId="19951" CreationDate="2016-01-25T16:41:06.887" Score="2" Body="&lt;p&gt;There is nothing wrong with that class and its code (as far as I can tell) - it compiles perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is probably wrong is that the IDE isn't picking up the code and compiling it in to your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this class part of the sketch, or is it a separate library that you are writing?  If the latter you have to ensure that the IDE knows about it, and it can only look for it when you load the IDE, so if you haven't restarted the IDE since creating the library you must do that so it can find the new library.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T16:41:06.887" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19953" PostTypeId="2" ParentId="19810" CreationDate="2016-01-25T17:07:17.507" Score="1" Body="&lt;p&gt;You may find that there is a process on Ubuntu that is grabbing the newly created CDC/ACM port as soon as it enters programming mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the Leonardo and Micro you have a CDC/ACM port while it's running, and when the board resets to enter programming mode that CDC/ACM port is destroyed and an entirely new one (hopefully under the same name) is created.  The process &lt;code&gt;modem-manager&lt;/code&gt; can grab that newly created CDC/ACM device thinking it's a modem and try to configure it as such, thus locking you out of the port.  A similar process in Debian is &lt;code&gt;brltty&lt;/code&gt; which tries to configure the CDC/ACM port as a braille TTY interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can check to see what process has the CDC/ACM device node open if any with the &lt;code&gt;lsof&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo lsof /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you find that you do have &lt;code&gt;modem-manager&lt;/code&gt; running on your system (I'm not sure if it's still default or not, it's been a while since I used Ubuntu, preferring the purity of Debian) it's best to completely remove it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get remove modemmanager&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T17:07:17.507" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="19954" PostTypeId="2" ParentId="19917" CreationDate="2016-01-25T17:28:22.863" Score="0" Body="&lt;p&gt;Your copy of the SoftwareSerial library has become corrupted. Why is anyone's guess: maybe your hard drive is dying?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replacing the file with a good copy will solve the problem. The simplest way to do that is to reinstall the IDE.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T17:28:22.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19955" PostTypeId="1" AcceptedAnswerId="19957" CreationDate="2016-01-25T17:28:56.043" Score="1" ViewCount="2604" Body="&lt;p&gt;Probably something stupid, but I can't figure out how to work with these large numbers, then cast the result (which will be small) to an integer. I keep getting negative numbers, which I think means I'm overflowing somewhere.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freq = 440;&#xA;int len = 256;&#xA;long timer = 2000000.0 / (freq * len);&#xA;int roundedTimer = int(timer);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I should get 18, but I'm getting -108...&lt;/p&gt;&#xA;" OwnerUserId="16720" LastActivityDate="2016-01-25T18:16:38.610" Title="Trouble with large numbers" Tags="|data-type|mathematics|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19957" PostTypeId="2" ParentId="19955" CreationDate="2016-01-25T18:16:38.610" Score="3" Body="&lt;p&gt;&lt;code&gt;freq * long&lt;/code&gt;, since they are both integers, are calculated as integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;440*256=112640&lt;/code&gt; - in binary that is &lt;code&gt;1 1011 1000 0000 0000&lt;/code&gt; and trimmed to 16 bits becomes &lt;code&gt;1011 1000 0000 0000&lt;/code&gt; which is &lt;code&gt;-18432&lt;/code&gt; and that is where the heart of your problem is.  Unless you explicitly say otherwise the Arduino's compiler does all calculations (except floating point) as 16-bit signed integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By casting the values to &lt;code&gt;long&lt;/code&gt; it forces the compiler to 'overflow' the 16-bit limit and use a 32-bit limit instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long timer = 2000000 / ((long)freq * (long)len);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another alternative is to define &lt;code&gt;freq&lt;/code&gt; and &lt;code&gt;len&lt;/code&gt; to be &lt;code&gt;long&lt;/code&gt; from the outset instead of &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T18:16:38.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19958" PostTypeId="1" AcceptedAnswerId="19959" CreationDate="2016-01-25T15:57:01.863" Score="1" ViewCount="1381" Body="&lt;p&gt;I'm working on a Arduino-based synthesizer using &lt;a href=&quot;http://makezine.com/projects/make-35/advanced-arduino-sound-synthesis/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;, specifically using a wavetable and 1-bit DAC. I understand that the value for OCR2A register sets the frequency, but how do I calculate the value?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen &lt;a href=&quot;http://cdn.makezine.com/make/35/OCR2A-frequency-table.pdf&quot; rel=&quot;nofollow&quot;&gt;this list of notes&lt;/a&gt; which is great, but I want arbitrary frequencies in Hz...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code I'm working from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;// sinewave parameters&#xA;#define FREQ 18&#xA;#define PI2 6.283185    // 2*PI saves calculation later&#xA;#define AMP 127         // scaling factor for sine wave&#xA;#define OFFSET 128      // offset shifts wave to all &amp;gt;0 values&#xA;&#xA;#define LENGTH 256      // length of the wave lookup table&#xA;byte wave[LENGTH];      // wavetable&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  // populate wavetable&#xA;  for (int i = 0; i &amp;lt; LENGTH; i++) {&#xA;    float v = (AMP * sin((PI2 / LENGTH) * i));&#xA;    wave[i] = int(v + OFFSET);&#xA;  }&#xA;&#xA;  // set timer1 for 8-bit fast PWM output&#xA;  pinMode(9, OUTPUT);       // make timer’s PWM pin an output&#xA;  TCCR1B = (1 &amp;lt;&amp;lt; CS10);     // set prescaler to full 16MHz&#xA;  TCCR1A |= (1 &amp;lt;&amp;lt; COM1A1);  // pin low when TCNT1=OCR1A&#xA;  TCCR1A |= (1 &amp;lt;&amp;lt; WGM10);   // use 8-bit fast PWM mode&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;&#xA;  // set up timer2 to call ISR&#xA;  TCCR2A = 0;             // no options in control register A&#xA;  TCCR2B = (1 &amp;lt;&amp;lt; CS21);   // set prescaler to divide by 8&#xA;  TIMSK2 = (1 &amp;lt;&amp;lt; OCIE2A); // call ISR when TCNT2 = OCRA2&#xA;  OCR2A = FREQ;           // set frequency of generated wave&#xA;  sei();                  // enable interrupts to generate waveform!&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // nothing to do here!&#xA;}&#xA;&#xA;&#xA;// called every time TCNT2 = OCR2A&#xA;ISR (TIMER2_COMPA_vect) {   // called when TCNT2 == OCR2A&#xA;  static byte index = 0;    // points to each table entry&#xA;  OCR1AL = wave[index++];   // update the PWM output&#xA;  asm(&quot;NOP; NOP&quot;);          // fine tuning&#xA;  TCNT2 = 6;                // timing to compensate for ISR run time&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16720" OwnerDisplayName="JeffThompson" LastActivityDate="2016-01-26T13:56:37.190" Title="Calculate OCR2A from audio frequency" Tags="|audio|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19959" PostTypeId="2" ParentId="19958" CreationDate="2016-01-25T16:23:28.750" Score="4" Body="&lt;p&gt;The equation to calculate it is given in the first article you linked:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1NREx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1NREx.jpg&quot; alt=&quot;From linked Makezine article &amp;quot;Advanced Arduino Sound Synthesis&amp;quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 2MHz value comes from the factor of 8 prescale on the 16MHz clock and 256 is the size of the lookup table specified by your &lt;code&gt;LENGTH&lt;/code&gt; define. If you start from a frequency you want to synthesize, just use the above equation to solve for the necessary value of OCR2A. Note that since you have to input integer values to OCR2A, you can't really achieve &lt;em&gt;arbitrary&lt;/em&gt; frequencies, but you're certainly not locked in to the values given in the supplemental musical note PDF you reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to solve for OCR2A:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OCR2A = TCNT2_rate / (desiredFreq * wavetableLength);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16724" OwnerDisplayName="Cheibriados" LastEditorUserId="16720" LastEditDate="2016-01-26T13:56:37.190" LastActivityDate="2016-01-26T13:56:37.190" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="19960" PostTypeId="2" ParentId="19951" CreationDate="2016-01-25T19:57:49.967" Score="3" Body="&lt;p&gt;The Arduino build preprocessing cannot locate the sensor source and header files if they are located in another sketch directory. The files needs to be moved to separate directory if shared (as a library).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--Sketchbook&#xA;---NodeIntercom&#xA;----NodeIntercom.ino&#xA;---MasterNode&#xA;----MasterNode.ino&#xA;---libraries&#xA;----Sensor&#xA;-----Sensor.h&#xA;-----Sensor.cpp&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Sensor header is included with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Sensor.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the sketches that needs to use it. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-26T09:02:42.780" LastActivityDate="2016-01-26T09:02:42.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19961" PostTypeId="1" AcceptedAnswerId="19962" CreationDate="2016-01-25T20:22:07.387" Score="4" ViewCount="28983" Body="&lt;p&gt;As Arduino Uno has a 16 MHz oscillator but while running program it has less frequency because some of the processing power is used for running the program.&#xA;I have used the &lt;code&gt;delay(1)&lt;/code&gt; but it is giving me around 500 Hz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there any way to achieve more than 500 Hz?&lt;/li&gt;&#xA;&lt;li&gt;What would be the maximum frequency of digital signal for below program?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);          &#xA;  digitalWrite(13, LOW);         &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15187" LastEditorUserId="26916" LastEditDate="2017-11-04T08:16:36.440" LastActivityDate="2021-08-02T09:10:11.850" Title="Maximum frequency of digital signal in Arduino Uno?" Tags="|arduino-uno|frequency|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19962" PostTypeId="2" ParentId="19961" CreationDate="2016-01-25T20:33:26.420" Score="9" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Yes, use the hardware timers.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can achieve 8 MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Example sketch which outputs 8 MHz on pin 9 on a Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#ifdef __AVR_ATmega2560__&#xA;  const byte CLOCKOUT = 11;  // Mega 2560&#xA;#else&#xA;  const byte CLOCKOUT = 9;   // Uno, Duemilanove, etc.&#xA;#endif&#xA;&#xA;void setup ()&#xA;  {&#xA;  // set up 8 MHz timer on CLOCKOUT (OC1A)&#xA;  pinMode (CLOCKOUT, OUTPUT); &#xA;  // set up Timer 1&#xA;  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match&#xA;  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaling&#xA;  OCR1A =  0;       // output every cycle&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you change OCR1A you can get lower frequencies. If you change the prescaler you can get lower frequencies again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;noreferrer&quot;&gt;my page about timers&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-25T20:33:26.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19963" PostTypeId="1" AcceptedAnswerId="19968" CreationDate="2016-01-25T20:55:55.863" Score="1" ViewCount="1346" Body="&lt;p&gt;I'm looking for a limit switch to use with the Arduino. In my project I want to count how many times my &lt;a href=&quot;http://cdn.shopify.com/s/files/1/0220/4654/products/slider1_large.jpeg?v=1420208854&quot; rel=&quot;nofollow noreferrer&quot;&gt;turntable&lt;/a&gt; makes a full 360° rotation. An object (wheel, pipe, whatever) will be sticking out the side of the turntable and when it comes in contact with the limit switch that will be right next to the turntable, it should notify the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on which limit switch I should get?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks so much in advance!&lt;/p&gt;&#xA;" OwnerUserId="16723" LastEditorUserId="4628" LastEditDate="2018-01-09T19:44:04.560" LastActivityDate="2018-01-09T19:44:04.560" Title="Recommendations for limit switches for Arduino" Tags="|arduino-uno|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="19964" PostTypeId="1" AcceptedAnswerId="19965" CreationDate="2016-01-25T21:10:49.953" Score="2" ViewCount="1053" Body="&lt;p&gt;I am a beginner when it comes to electronics, coding and things like that (this is practically the first time I have done anything like this), so when building an application that is supposed to vibrate a vibration motor with a strength based on the distance measurement made by the ultrasonic rangefinder, I bumped up with a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MCP 41010 digital potentiometer seems to let electricity through only when it is given a SPI.transfer(128). Any other number stops the flow of electricity completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried some addresses such as 00, 0x00, 0x01 and 0x04 to replace the 0 and the result was the same. With addresses 0x11 and 0x08 the digital potentiometer didn't react at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to the code I have here I have tried just copy-pasting some of the tutorials I found from the internet, for example this one &lt;a href=&quot;https://arduino.stackexchange.com/questions/4952/digital-potentiometer-not-fading-led&quot;&gt;Digital Potentiometer not fading LED&lt;/a&gt; without really understanding the commands formats thing all that well. With that code I got a vibration that didn't seem to fade in or fade out at all, so the problem remains (I lack a way to properly test that though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So... what am I doing wrong and how to fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/klwYJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/klwYJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many tutorials were used when making the code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;&amp;#35;&amp;#105;&amp;#110;&amp;#99;&amp;#108;&amp;#117;&amp;#100;&amp;#101;&amp;#32;&amp;#60;&amp;#83;&amp;#80;&amp;#73;&amp;#46;&amp;#104;&amp;#62;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#118;&amp;#99;&amp;#99;&amp;#32;&amp;#61;&amp;#32;&amp;#50;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#97;&amp;#116;&amp;#116;&amp;#97;&amp;#99;&amp;#104;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#32;&amp;#50;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#118;&amp;#99;&amp;#99;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#32;&amp;#61;&amp;#32;&amp;#51;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#97;&amp;#116;&amp;#116;&amp;#97;&amp;#99;&amp;#104;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#32;&amp;#51;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#84;&amp;#114;&amp;#105;&amp;#103;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#101;&amp;#99;&amp;#104;&amp;#111;&amp;#32;&amp;#61;&amp;#32;&amp;#52;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#97;&amp;#116;&amp;#116;&amp;#97;&amp;#99;&amp;#104;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#32;&amp;#52;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#69;&amp;#99;&amp;#104;&amp;#111;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#103;&amp;#110;&amp;#100;&amp;#32;&amp;#61;&amp;#32;&amp;#53;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#97;&amp;#116;&amp;#116;&amp;#97;&amp;#99;&amp;#104;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#32;&amp;#53;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#71;&amp;#78;&amp;#68;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#101;&amp;#115;&amp;#116;&amp;#32;&amp;#61;&amp;#32;&amp;#50;&amp;#53;&amp;#48;&amp;#59;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#108;&amp;#111;&amp;#110;&amp;#103;&amp;#101;&amp;#115;&amp;#116;&amp;#32;&amp;#61;&amp;#32;&amp;#49;&amp;#50;&amp;#48;&amp;#48;&amp;#48;&amp;#59;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#105;&amp;#110;&amp;#116;&amp;#32;&amp;#67;&amp;#83;&amp;#32;&amp;#61;&amp;#32;&amp;#49;&amp;#48;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#102;&amp;#111;&amp;#114;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#32;&amp;#112;&amp;#111;&amp;#116;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#118;&amp;#111;&amp;#105;&amp;#100;&amp;#32;&amp;#115;&amp;#101;&amp;#116;&amp;#117;&amp;#112;&amp;#40;&amp;#41;&amp;#32;&amp;#123;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#80;&amp;#73;&amp;#46;&amp;#98;&amp;#101;&amp;#103;&amp;#105;&amp;#110;&amp;#32;&amp;#40;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#77;&amp;#111;&amp;#100;&amp;#101;&amp;#32;&amp;#40;&amp;#118;&amp;#99;&amp;#99;&amp;#44;&amp;#79;&amp;#85;&amp;#84;&amp;#80;&amp;#85;&amp;#84;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#77;&amp;#111;&amp;#100;&amp;#101;&amp;#32;&amp;#40;&amp;#103;&amp;#110;&amp;#100;&amp;#44;&amp;#79;&amp;#85;&amp;#84;&amp;#80;&amp;#85;&amp;#84;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#77;&amp;#111;&amp;#100;&amp;#101;&amp;#32;&amp;#40;&amp;#67;&amp;#83;&amp;#44;&amp;#32;&amp;#79;&amp;#85;&amp;#84;&amp;#80;&amp;#85;&amp;#84;&amp;#41;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#102;&amp;#111;&amp;#114;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#32;&amp;#112;&amp;#111;&amp;#116;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#105;&amp;#110;&amp;#105;&amp;#116;&amp;#105;&amp;#97;&amp;#108;&amp;#105;&amp;#122;&amp;#101;&amp;#32;&amp;#115;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#32;&amp;#99;&amp;#111;&amp;#109;&amp;#109;&amp;#117;&amp;#110;&amp;#105;&amp;#99;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#58;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#98;&amp;#101;&amp;#103;&amp;#105;&amp;#110;&amp;#40;&amp;#57;&amp;#54;&amp;#48;&amp;#48;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#125;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#118;&amp;#111;&amp;#105;&amp;#100;&amp;#32;&amp;#108;&amp;#111;&amp;#111;&amp;#112;&amp;#40;&amp;#41;&amp;#13;&amp;#10;&amp;#123;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#118;&amp;#99;&amp;#99;&amp;#44;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#101;&amp;#115;&amp;#116;&amp;#97;&amp;#98;&amp;#108;&amp;#105;&amp;#115;&amp;#104;&amp;#32;&amp;#118;&amp;#97;&amp;#114;&amp;#105;&amp;#97;&amp;#98;&amp;#108;&amp;#101;&amp;#115;&amp;#32;&amp;#102;&amp;#111;&amp;#114;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#103;&amp;#44;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#100;&amp;#105;&amp;#115;&amp;#116;&amp;#97;&amp;#110;&amp;#99;&amp;#101;&amp;#32;&amp;#114;&amp;#101;&amp;#115;&amp;#117;&amp;#108;&amp;#116;&amp;#32;&amp;#105;&amp;#110;&amp;#32;&amp;#105;&amp;#110;&amp;#99;&amp;#104;&amp;#101;&amp;#115;&amp;#32;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#99;&amp;#101;&amp;#110;&amp;#116;&amp;#105;&amp;#109;&amp;#101;&amp;#116;&amp;#101;&amp;#114;&amp;#115;&amp;#58;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#108;&amp;#111;&amp;#110;&amp;#103;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#84;&amp;#104;&amp;#101;&amp;#32;&amp;#80;&amp;#73;&amp;#78;&amp;#71;&amp;#41;&amp;#41;&amp;#41;&amp;#32;&amp;#105;&amp;#115;&amp;#32;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#103;&amp;#101;&amp;#114;&amp;#101;&amp;#100;&amp;#32;&amp;#98;&amp;#121;&amp;#32;&amp;#97;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#32;&amp;#112;&amp;#117;&amp;#108;&amp;#115;&amp;#101;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#50;&amp;#32;&amp;#111;&amp;#114;&amp;#32;&amp;#109;&amp;#111;&amp;#114;&amp;#101;&amp;#32;&amp;#109;&amp;#105;&amp;#99;&amp;#114;&amp;#111;&amp;#115;&amp;#101;&amp;#99;&amp;#111;&amp;#110;&amp;#100;&amp;#115;&amp;#46;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#71;&amp;#105;&amp;#118;&amp;#101;&amp;#32;&amp;#97;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#32;&amp;#76;&amp;#79;&amp;#87;&amp;#32;&amp;#112;&amp;#117;&amp;#108;&amp;#115;&amp;#101;&amp;#32;&amp;#98;&amp;#101;&amp;#102;&amp;#111;&amp;#114;&amp;#101;&amp;#104;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#101;&amp;#110;&amp;#115;&amp;#117;&amp;#114;&amp;#101;&amp;#32;&amp;#97;&amp;#32;&amp;#99;&amp;#108;&amp;#101;&amp;#97;&amp;#110;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#32;&amp;#112;&amp;#117;&amp;#108;&amp;#115;&amp;#101;&amp;#58;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#77;&amp;#111;&amp;#100;&amp;#101;&amp;#40;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#44;&amp;#32;&amp;#79;&amp;#85;&amp;#84;&amp;#80;&amp;#85;&amp;#84;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#44;&amp;#32;&amp;#76;&amp;#79;&amp;#87;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#101;&amp;#108;&amp;#97;&amp;#121;&amp;#77;&amp;#105;&amp;#99;&amp;#114;&amp;#111;&amp;#115;&amp;#101;&amp;#99;&amp;#111;&amp;#110;&amp;#100;&amp;#115;&amp;#40;&amp;#50;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#44;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#101;&amp;#108;&amp;#97;&amp;#121;&amp;#77;&amp;#105;&amp;#99;&amp;#114;&amp;#111;&amp;#115;&amp;#101;&amp;#99;&amp;#111;&amp;#110;&amp;#100;&amp;#115;&amp;#40;&amp;#53;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#116;&amp;#114;&amp;#105;&amp;#103;&amp;#44;&amp;#32;&amp;#76;&amp;#79;&amp;#87;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#84;&amp;#104;&amp;#101;&amp;#32;&amp;#115;&amp;#97;&amp;#109;&amp;#101;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#32;&amp;#105;&amp;#115;&amp;#32;&amp;#117;&amp;#115;&amp;#101;&amp;#100;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#114;&amp;#101;&amp;#97;&amp;#100;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#115;&amp;#105;&amp;#103;&amp;#110;&amp;#97;&amp;#108;&amp;#32;&amp;#102;&amp;#114;&amp;#111;&amp;#109;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#80;&amp;#73;&amp;#78;&amp;#71;&amp;#41;&amp;#41;&amp;#41;&amp;#58;&amp;#32;&amp;#97;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#112;&amp;#117;&amp;#108;&amp;#115;&amp;#101;&amp;#32;&amp;#119;&amp;#104;&amp;#111;&amp;#115;&amp;#101;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#105;&amp;#115;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#116;&amp;#105;&amp;#109;&amp;#101;&amp;#32;&amp;#40;&amp;#105;&amp;#110;&amp;#32;&amp;#109;&amp;#105;&amp;#99;&amp;#114;&amp;#111;&amp;#115;&amp;#101;&amp;#99;&amp;#111;&amp;#110;&amp;#100;&amp;#115;&amp;#41;&amp;#32;&amp;#102;&amp;#114;&amp;#111;&amp;#109;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#115;&amp;#101;&amp;#110;&amp;#100;&amp;#105;&amp;#110;&amp;#103;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#114;&amp;#101;&amp;#99;&amp;#101;&amp;#112;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#105;&amp;#116;&amp;#115;&amp;#32;&amp;#101;&amp;#99;&amp;#104;&amp;#111;&amp;#32;&amp;#111;&amp;#102;&amp;#102;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#97;&amp;#110;&amp;#32;&amp;#111;&amp;#98;&amp;#106;&amp;#101;&amp;#99;&amp;#116;&amp;#46;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#112;&amp;#105;&amp;#110;&amp;#77;&amp;#111;&amp;#100;&amp;#101;&amp;#40;&amp;#101;&amp;#99;&amp;#104;&amp;#111;&amp;#44;&amp;#73;&amp;#78;&amp;#80;&amp;#85;&amp;#84;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#61;&amp;#32;&amp;#112;&amp;#117;&amp;#108;&amp;#115;&amp;#101;&amp;#73;&amp;#110;&amp;#40;&amp;#101;&amp;#99;&amp;#104;&amp;#111;&amp;#44;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#105;&amp;#102;&amp;#32;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#62;&amp;#32;&amp;#50;&amp;#48;&amp;#48;&amp;#32;&amp;#38;&amp;#38;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#60;&amp;#32;&amp;#50;&amp;#50;&amp;#48;&amp;#41;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#76;&amp;#105;&amp;#109;&amp;#105;&amp;#116;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#111;&amp;#117;&amp;#116;&amp;#32;&amp;#97;&amp;#110;&amp;#32;&amp;#117;&amp;#110;&amp;#119;&amp;#97;&amp;#110;&amp;#116;&amp;#101;&amp;#100;&amp;#44;&amp;#32;&amp;#114;&amp;#97;&amp;#110;&amp;#100;&amp;#111;&amp;#109;&amp;#108;&amp;#121;&amp;#32;&amp;#97;&amp;#112;&amp;#112;&amp;#101;&amp;#97;&amp;#114;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#100;&amp;#105;&amp;#115;&amp;#116;&amp;#97;&amp;#110;&amp;#99;&amp;#101;&amp;#32;&amp;#109;&amp;#101;&amp;#97;&amp;#115;&amp;#117;&amp;#114;&amp;#101;&amp;#109;&amp;#101;&amp;#110;&amp;#116;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#109;&amp;#97;&amp;#100;&amp;#101;&amp;#32;&amp;#117;&amp;#115;&amp;#101;&amp;#108;&amp;#101;&amp;#115;&amp;#115;&amp;#32;&amp;#98;&amp;#121;&amp;#32;&amp;#108;&amp;#97;&amp;#116;&amp;#101;&amp;#114;&amp;#32;&amp;#99;&amp;#111;&amp;#100;&amp;#101;&amp;#32;&amp;#116;&amp;#104;&amp;#111;&amp;#117;&amp;#103;&amp;#104;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#123;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#40;&amp;#34;&amp;#69;&amp;#114;&amp;#114;&amp;#111;&amp;#114;&amp;#32;&amp;#34;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#40;&amp;#34;&amp;#92;&amp;#110;&amp;#34;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#114;&amp;#101;&amp;#116;&amp;#117;&amp;#114;&amp;#110;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#32;&amp;#125;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#67;&amp;#111;&amp;#109;&amp;#112;&amp;#114;&amp;#101;&amp;#115;&amp;#115;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#114;&amp;#101;&amp;#115;&amp;#117;&amp;#108;&amp;#116;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#100;&amp;#105;&amp;#115;&amp;#116;&amp;#97;&amp;#110;&amp;#99;&amp;#101;&amp;#32;&amp;#109;&amp;#101;&amp;#97;&amp;#115;&amp;#117;&amp;#114;&amp;#101;&amp;#109;&amp;#101;&amp;#110;&amp;#116;&amp;#32;&amp;#105;&amp;#110;&amp;#116;&amp;#111;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#115;&amp;#99;&amp;#97;&amp;#108;&amp;#101;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#48;&amp;#32;&amp;#45;&amp;#32;&amp;#49;&amp;#50;&amp;#56;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#105;&amp;#102;&amp;#32;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#60;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#101;&amp;#115;&amp;#116;&amp;#41;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#61;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#101;&amp;#115;&amp;#116;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#105;&amp;#102;&amp;#32;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#62;&amp;#32;&amp;#108;&amp;#111;&amp;#110;&amp;#103;&amp;#101;&amp;#115;&amp;#116;&amp;#41;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#61;&amp;#32;&amp;#108;&amp;#111;&amp;#110;&amp;#103;&amp;#101;&amp;#115;&amp;#116;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#61;&amp;#32;&amp;#40;&amp;#49;&amp;#46;&amp;#48;&amp;#102;&amp;#45;&amp;#40;&amp;#40;&amp;#102;&amp;#108;&amp;#111;&amp;#97;&amp;#116;&amp;#41;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#32;&amp;#45;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#101;&amp;#115;&amp;#116;&amp;#41;&amp;#32;&amp;#47;&amp;#32;&amp;#40;&amp;#102;&amp;#108;&amp;#111;&amp;#97;&amp;#116;&amp;#41;&amp;#40;&amp;#108;&amp;#111;&amp;#110;&amp;#103;&amp;#101;&amp;#115;&amp;#116;&amp;#32;&amp;#45;&amp;#32;&amp;#115;&amp;#104;&amp;#111;&amp;#114;&amp;#116;&amp;#101;&amp;#115;&amp;#116;&amp;#41;&amp;#41;&amp;#41;&amp;#32;&amp;#42;&amp;#32;&amp;#49;&amp;#50;&amp;#56;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#67;&amp;#83;&amp;#44;&amp;#32;&amp;#76;&amp;#79;&amp;#87;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#80;&amp;#73;&amp;#46;&amp;#116;&amp;#114;&amp;#97;&amp;#110;&amp;#115;&amp;#102;&amp;#101;&amp;#114;&amp;#40;&amp;#48;&amp;#41;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#48;&amp;#120;&amp;#48;&amp;#49;&amp;#32;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#48;&amp;#120;&amp;#48;&amp;#52;&amp;#32;&amp;#115;&amp;#101;&amp;#101;&amp;#109;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#34;&amp;#119;&amp;#111;&amp;#114;&amp;#107;&amp;#34;&amp;#32;&amp;#116;&amp;#111;&amp;#111;&amp;#46;&amp;#32;&amp;#87;&amp;#105;&amp;#116;&amp;#104;&amp;#32;&amp;#48;&amp;#120;&amp;#49;&amp;#49;&amp;#32;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#48;&amp;#120;&amp;#48;&amp;#56;&amp;#32;&amp;#110;&amp;#111;&amp;#32;&amp;#118;&amp;#111;&amp;#108;&amp;#116;&amp;#97;&amp;#103;&amp;#101;&amp;#32;&amp;#103;&amp;#111;&amp;#101;&amp;#115;&amp;#32;&amp;#116;&amp;#104;&amp;#114;&amp;#111;&amp;#117;&amp;#103;&amp;#104;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#80;&amp;#73;&amp;#46;&amp;#116;&amp;#114;&amp;#97;&amp;#110;&amp;#115;&amp;#102;&amp;#101;&amp;#114;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#41;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#115;&amp;#101;&amp;#110;&amp;#100;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#97;&amp;#32;&amp;#110;&amp;#117;&amp;#109;&amp;#98;&amp;#101;&amp;#114;&amp;#32;&amp;#102;&amp;#114;&amp;#111;&amp;#109;&amp;#32;&amp;#48;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#49;&amp;#50;&amp;#56;&amp;#32;&amp;#116;&amp;#111;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#32;&amp;#112;&amp;#111;&amp;#116;&amp;#101;&amp;#110;&amp;#116;&amp;#105;&amp;#111;&amp;#109;&amp;#101;&amp;#116;&amp;#101;&amp;#114;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#105;&amp;#103;&amp;#105;&amp;#116;&amp;#97;&amp;#108;&amp;#87;&amp;#114;&amp;#105;&amp;#116;&amp;#101;&amp;#40;&amp;#67;&amp;#83;&amp;#44;&amp;#32;&amp;#72;&amp;#73;&amp;#71;&amp;#72;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#40;&amp;#100;&amp;#117;&amp;#114;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#41;&amp;#59;&amp;#32;&amp;#47;&amp;#47;&amp;#32;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#105;&amp;#110;&amp;#103;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#114;&amp;#101;&amp;#115;&amp;#117;&amp;#108;&amp;#116;&amp;#32;&amp;#111;&amp;#102;&amp;#32;&amp;#116;&amp;#104;&amp;#101;&amp;#32;&amp;#109;&amp;#101;&amp;#97;&amp;#115;&amp;#117;&amp;#114;&amp;#101;&amp;#109;&amp;#101;&amp;#110;&amp;#116;&amp;#32;&amp;#97;&amp;#110;&amp;#100;&amp;#32;&amp;#99;&amp;#97;&amp;#108;&amp;#99;&amp;#117;&amp;#108;&amp;#97;&amp;#116;&amp;#105;&amp;#111;&amp;#110;&amp;#115;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#83;&amp;#101;&amp;#114;&amp;#105;&amp;#97;&amp;#108;&amp;#46;&amp;#112;&amp;#114;&amp;#105;&amp;#110;&amp;#116;&amp;#40;&amp;#34;&amp;#92;&amp;#110;&amp;#34;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#13;&amp;#10;&amp;#32;&amp;#32;&amp;#100;&amp;#101;&amp;#108;&amp;#97;&amp;#121;&amp;#40;&amp;#49;&amp;#48;&amp;#48;&amp;#41;&amp;#59;&amp;#13;&amp;#10;&amp;#125;&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="16665" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-25T21:35:25.750" Title="Problem with a digital potentiometer application" Tags="|potentiometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19965" PostTypeId="2" ParentId="19964" CreationDate="2016-01-25T21:35:25.750" Score="3" Body="&lt;p&gt;Digital potentiometers are not a good choice for controlling the speed of a motor. They are designed only for very low current applications - things like setting offset points for op-amps and things like that - things where you would use a small trimmer pot rather than a large power &lt;em&gt;rheostat&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should be controlling the motor using PWM and a transistor (&lt;a href=&quot;http://www.circuitstoday.com/pwm-generation-and-control-using-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;here is a good tutorial&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to help you understand the digital potentiometer and so you can work with it better:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Step one is always to read &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/11195c.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the datasheet&lt;/a&gt;.  That details the SPI communication protocol for you so you can know what numbers mean what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the protocol is made up of two bytes - a command byte and a data byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command byte is made up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2gUGj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2gUGj.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see it's in two parts - a command and a potentiometer selector.  So to set the resistance of potentiometer 0 you would need to craft a command byte that had the write command and the code for potentiometer 0.  That would be &lt;code&gt;0b00010001&lt;/code&gt; or 0x11 in hex.  So your transaction would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(CS, LOW);&#xA;SPI.transfer(0x11);&#xA;SPI.transfer(duration);&#xA;digitalWrite(CS, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another important part of the datasheet is the electrical characteristics.  That is a table that tells you the minimum, typical and/or maximum values for different parameters.  One important one here is the &lt;em&gt;wiper current&lt;/em&gt; which it states as being allowed between -1mA and +1mA.  That is the maximum current you are allowed to draw through the digital potentiometer before you risk damaging it.  That is why it's not good for powering things like motors, no matter how small.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T21:35:25.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19966" PostTypeId="1" AcceptedAnswerId="19983" CreationDate="2016-01-25T22:12:08.497" Score="0" ViewCount="368" Body="&lt;p&gt;I'm trying to control a 4-digit 7 segment display with an Arduino Nano, but I'm getting something wrong. I'm using the ICSP header to interface with a 74HC595 Shift Register which is then connected to the display. I've tested and retested the connections and everything seems to be alright, however the shift register doesn't have the desired output, and I notice it only shifs one single bit when I press the reset button on the arduino board.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;74HC595   |    A. Nano&#xA;DS     &amp;lt;-----&amp;gt; MOSI (ICSP)&#xA;SH_CP  &amp;lt;-----&amp;gt; SCK (ICSP)&#xA;ST_CP  &amp;lt;-----&amp;gt; D6&#xA;MR     &amp;lt;-----&amp;gt; 5V (ICSP)&#xA;OE     &amp;lt;-----&amp;gt; GND (ICSP)&#xA;VDD    &amp;lt;-----&amp;gt; 5V (ICSP)&#xA;GND    &amp;lt;-----&amp;gt; GND (ICSP)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//pin connected to STCP&#xA;const int latchPin = 6;&#xA;//pin connected to SHCP&#xA;const int clockPin = 17;&#xA;//pin connected to DS (MOSI)&#xA;const int dataPin = 11;&#xA;&#xA;byte val=0;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  //SPI pins are output&#xA;  pinMode(latchPin,OUTPUT);&#xA;  pinMode(clockPin,OUTPUT);&#xA;  pinMode(dataPin,OUTPUT);&#xA;&#xA;  pinMode(3,OUTPUT);&#xA;  updateRegister(0);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  digitalWrite(3,HIGH);  &#xA;  for (int i=0; i&amp;lt;8; i++) {&#xA;    updateRegister();&#xA;    delay(500);&#xA;  }   &#xA;&#xA;}&#xA;&#xA;void updateRegister() {&#xA;  //pull latch low to write new bits to the register&#xA;  digitalWrite(latchPin,LOW);&#xA;  //shift out the data&#xA;  shiftOut(dataPin,clockPin,LSBFIRST,val);&#xA;  //pull latch pin high so that the leds light up&#xA;  digitalWrite(latchPin,HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11399" LastEditorUserId="10794" LastEditDate="2016-01-26T07:12:35.287" LastActivityDate="2016-01-26T13:55:08.437" Title="Arduino Nano, ICSP header and 595 Shift register" Tags="|c++|arduino-nano|spi|shift-register|icsp|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19967" PostTypeId="1" AcceptedAnswerId="19970" CreationDate="2016-01-25T22:23:00.170" Score="1" ViewCount="1307" Body="&lt;p&gt;I used the example code AnalogReadSerial and tried it on all analog pins from A0 to A7. None of the analog pins were connected to anything so I expectedy to get 0 in the serial monitor. But as it turns out, I was wrong. Only pin A7 shows 0 to 19 values on the serial monitor. The rest have values ranging from 100 to 300 for pins A2, A3, A4, A5 and A6. The worst performers are A1 and A0 with values from 921 to 1023 showing on the serial monitor. What is the cause of this and how will I fix it?&lt;/p&gt;&#xA;" OwnerUserId="11333" LastActivityDate="2016-01-28T19:53:50.193" Title="Analog Pins are sensing Values" Tags="|analogread|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19968" PostTypeId="2" ParentId="19963" CreationDate="2016-01-25T22:25:28.480" Score="6" Body="&lt;p&gt;A $2 microswitch with a roller would be OK for a million revs or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/okIHN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/okIHN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would put a little ramp on the diameter and use it to trigger the switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Non-contact magnetic or optical could be better for more cycles or faster operation.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-01-26T03:48:46.890" LastActivityDate="2016-01-26T03:48:46.890" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="19969" PostTypeId="2" ParentId="19967" CreationDate="2016-01-25T22:27:06.353" Score="3" Body="&lt;p&gt;This is normal, as the unconnected pin may float from GND to VCC. You may  enable internal pull-up (to VCC). This is normal for all high-z inputs. If you read digital port you'll see that it floats too. Sometimes you can change digital I/O input value just by waving your hand above the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that reason we always tie high-z inputs to something. You can leave it floating - it won't damage anything, but the value obtained from free-floating input is useless.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-01-28T19:53:50.193" LastActivityDate="2016-01-28T19:53:50.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19970" PostTypeId="2" ParentId="19967" CreationDate="2016-01-25T22:28:16.547" Score="1" Body="&lt;p&gt;The ADC is multiplexed across the pins, and will carry a small charge from pin to pin.  If you want them to be zero, tie them to ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This answer, &lt;a href=&quot;https://arduino.stackexchange.com/a/575/6628&quot;&gt;https://arduino.stackexchange.com/a/575/6628&lt;/a&gt; , suggests pulling them to ground for higher accuracy.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-25T22:36:12.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19971" PostTypeId="1" AcceptedAnswerId="19972" CreationDate="2016-01-25T23:44:47.663" Score="4" ViewCount="2856" Body="&lt;p&gt;This isn't strictly limited to Arduino but I spend a lot of time with serial devices on my Arduino and I'm sure that others do as well: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here goes..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say a device sends three characters [ABC] via serial at 9600 8N1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And let's also say the device receiving the data only knows that it's serial stream and 8N1 but does not know the baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The receiving device would need to take a guess at the baud and so probably get it wrong. It would therefore receive weird characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway/anything around that a user could paste the strange characters into that would reverse engineer (from the bit stream) to give the correct baud and hence correct ascii characters [ABC]?&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="10794" LastEditDate="2018-02-03T04:45:20.860" LastActivityDate="2018-02-03T04:45:20.860" Title="Converting data between baud rates" Tags="|serial|baud-rate|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19972" PostTypeId="2" ParentId="19971" CreationDate="2016-01-25T23:59:32.130" Score="6" Body="&lt;p&gt;I am not aware of anything like that, no.  The problem is what you are seeing as characters are a complete corruption of the data. Only some part of it may have been interpreted as a valid bit sequence, and even then you can't know what bit it was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there is one magic character in UART communication: &lt;code&gt;U&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is special about that character is its binary pattern.  It is ASCII character 85, which in HEX is 0x55, or binary it's 0b01010101.  Add to that the start and stop bits, and invert it for the UART logic (1 = LOW, 0 = HIGH) and the signal that gets sent out of the UART looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;____start_____     _____     _____     _____     _____&#xA;    |   |  0  | 1 |  0  | 1 |  0  | 1 |  0  | 1 | stop&#xA;    -----     -----     -----     -----     -----&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yes, that's a pretty good square wave.  The frequency of that square wave will be exactly half the baud rate - so a frequency of 4800Hz will be a baud rate of 9600 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This effect is cleverly used for a system called &lt;a href=&quot;https://en.wikipedia.org/wiki/Automatic_baud_rate_detection&quot; rel=&quot;noreferrer&quot;&gt;Automatic baud rate detection&lt;/a&gt; whereby a receiver waits for a &lt;code&gt;U&lt;/code&gt; character to determine the baud rate to use.  Most modern microcontrollers have this facility available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't get the frequency of a block of &lt;code&gt;U&lt;/code&gt; characters you will have to examine the waveform with an oscilloscope.  It should be possible to identify the individual characters in the data stream as distinct blocks in the waveform.  From that you can then work out the width of one symbol and thus the baud rate.  It's best to use a DSO for this since you can then capture a short burst and use the markers to measure the time between different points in the waveform.  A logic analyser will also do the job quite well, and will most likely be able to decode the waveform and calculate the baud rate for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have neither of those it would be possible to program an Arduino to capture the time between transitions of an incoming signal and allow you to plot them in Excel to give you a waveform you can examine to determine the baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is just to keep trying different baud rates (there's relatively few &quot;standard&quot; baud rates) until you see the right text coming in.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-25T23:59:32.130" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19973" PostTypeId="2" ParentId="19966" CreationDate="2016-01-26T00:02:15.443" Score="1" Body="&lt;p&gt;Do you need to add the _  to the shiftOut(dataPin,clockPin,LSBFIRST,val); ?&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-01-26T00:02:15.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19974" PostTypeId="2" ParentId="19966" CreationDate="2016-01-26T00:20:20.047" Score="3" Body="&#xA;&#xA;&lt;p&gt;It is extremely confusing to have a variable &lt;code&gt;val&lt;/code&gt; and then use &lt;code&gt;_val&lt;/code&gt; in your function but then:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  shiftOut(dataPin,clockPin,LSBFIRST,val);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As James pointed out, you are not sending the value passed to the function, to the shift register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also this is just going to give you a boolean:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; updateRegister(!i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why take &quot;not i&quot; there?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suggest you use SPI and not muck around with shiftOut. I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow&quot;&gt;page about the 595 chip&lt;/a&gt; including example code. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const byte LATCH = 10;&#xA;&#xA;void setup ()&#xA;{&#xA;  SPI.begin ();&#xA;}  // end of setup&#xA;&#xA;byte c;&#xA;void loop ()&#xA;{&#xA;  c++;&#xA;  digitalWrite (LATCH, LOW);&#xA;  SPI.transfer (c);&#xA;  digitalWrite (LATCH, HIGH);&#xA;  delay (20);&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-26T00:20:20.047" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="19975" PostTypeId="2" ParentId="19971" CreationDate="2016-01-26T00:34:32.110" Score="2" Body="&lt;p&gt;My logic analyser has a &quot;guess baud rate&quot; feature, which usually is fairly accurate. If you analyse an incoming bit stream you can probably have a reasonably good guess. For example the shortest transition means the baud rate cannot be &lt;strong&gt;slower&lt;/strong&gt; than that. For example, at 9600 baud sooner or later you will get a transition in 104 µs (ie. &lt;code&gt;1/9600&lt;/code&gt;). Thus if you see that, the baud rate could not be 4800 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in general, there will be a gap between &quot;packets&quot;, so in your case after the &quot;ABC&quot; there would be a longer gap (of all 1s). You would assume then that the active time represents an integral number of bytes (eg. 3 bytes, 8 bytes, but not 1.5 bytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing is that baud rates are usually multiples of a power of 2 times 300 (ie. 300, 600, 1200, 2400, 4800). So this gives you a small range of possible baud rates to test. You could test (say for 9600) and see if you get reasonable results. A &quot;reasonable result&quot; would be a stop bit appearing 10 bits after a start bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my post: &lt;a href=&quot;https://arduino.stackexchange.com/questions/19756/how-does-serial-communications-work-on-the-arduino&quot;&gt;How does serial communications work on the Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-26T00:34:32.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19976" PostTypeId="2" ParentId="19971" CreationDate="2016-01-26T00:48:35.307" Score="2" Body="&lt;p&gt;Try measuring pulse width and match shortest pulse against pre-defined widths corresponding to available baudrates. This way you can detect baudrate by analysing random binary stream.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Signal glitches, such as very short spikes, will be filtered out, as they will never match the list of baudrates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repeat the measurement few times to raise accuracy and choose the most probable value from all guessed values.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-01-26T00:48:35.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19977" PostTypeId="2" ParentId="19961" CreationDate="2016-01-26T02:12:08.357" Score="2" Body="&lt;p&gt;Also, don't forget that there are alternative methods of toggling outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use PORTS to do the job. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a good &lt;a href=&quot;http://www.billporter.info/2010/08/18/ready-set-oscillate-the-fastest-way-to-change-arduino-pins/&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt;. And another &lt;a href=&quot;http://tronixstuff.com/2011/10/22/tutorial-arduino-port-manipulation/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this code is the idea behind it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  DDRD = B11111111; // set PORTD (digital 7~0) to outputs&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  PORTD = B11111111; // set PORTD pins (digital 7~0) high&#xA;  PORTD = B00000000; // set PORTD pins (digital 7~0) low&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S. Don't forget that the port numbering is in reference to the chip pins and not the Arduino pins/legs.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-01-26T02:12:08.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19979" PostTypeId="2" ParentId="19946" CreationDate="2016-01-26T02:30:47.630" Score="1" Body="&lt;p&gt;In real life there is no set equation to find the PID values. At best you'll get close with equations and then need to tune the parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For anyone into PID loops have a read of &lt;a href=&quot;http://controlguru.com/table-of-contents/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&#xA;I've found it to be excellent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My advice is to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;only use P&lt;/li&gt;&#xA;&lt;li&gt;set I &amp;amp; D to 0&lt;/li&gt;&#xA;&lt;li&gt;get it and good as you can by trial and error&lt;/li&gt;&#xA;&lt;li&gt;add I and trial it too&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;D is for experts really and may cause weird/undesirable jitter.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="16725" LastEditDate="2016-01-26T02:41:10.310" LastActivityDate="2016-01-26T02:41:10.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19980" PostTypeId="2" ParentId="19810" CreationDate="2016-01-26T06:42:48.580" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Therefore I tried the newest version of the Arduino software from the arduino homepage.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The package version I am using is 1:1.0.5+dfsg2-2, the other I tried was 2:1.0.5+dfsg2-4. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is not the newest version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the more recent versions of the IDE are more robust - after all they have fixed reported bugs. Try 1.6.5 or 1.6.7. The version 1.0.5 is pretty old.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I too have had &quot;upload completed&quot; on my Leonardo (virtually the same as the Micro) when it did no such thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Ubuntu 14.04 and don't have any problems programming my Micro with IDE 1.6.7.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When programming you should see the Tx/Rx and yellow LEDs flicker. If not, press Reset when it starts to upload and try again.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Have you followed the instructions here? &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Troubleshooting&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I installed the arduino software using apt-get ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Personally I download the IDE from this page: &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/Software&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Update&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I just compiled and uploaded &quot;Blink&quot; with IDE 1.6.7 to my Micro on Ubuntu 14.04. This is what I saw:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Forcing reset using 1200bps open/close on port /dev/ttyACM1&#xA;PORTS {/dev/ttyACM0, /dev/ttyACM1, } / {/dev/ttyACM0, } =&amp;gt; {}&#xA;PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, /dev/ttyACM1, } =&amp;gt; {/dev/ttyACM1, }&#xA;Found upload port: /dev/ttyACM1&#xA;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avrdude -C/home/nick/Development/arduino-1.6.7/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM1 -b57600 -D -Uflash:w:/tmp/build8f287ac41038dd4edf2d64ea95be7b6f.tmp/Blink.ino.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 19:04:16&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/home/nick/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyACM1&#xA;         Using Programmer              : avr109&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : butterfly&#xA;         Description     : Atmel AppNote AVR109 Boot Loader&#xA;&#xA;Connecting to programmer: .&#xA;Found programmer: Id = &quot;CATERIN&quot;; type = S&#xA;    Software Version = 1.0; No Hardware Version given.&#xA;Programmer supports auto addr increment.&#xA;Programmer supports buffered memory access with buffersize=128 bytes.&#xA;&#xA;Programmer supports the following devices:&#xA;    Device code: 0x44&#xA;&#xA;avrdude: devcode selected: 0x44&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e9587&#xA;avrdude: reading input file &quot;/tmp/build8f287ac41038dd4edf2d64ea95be7b6f.tmp/Blink.ino.hex&quot;&#xA;avrdude: writing flash (4456 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.33s&#xA;&#xA;avrdude: 4456 bytes of flash written&#xA;avrdude: verifying flash memory against /tmp/build8f287ac41038dd4edf2d64ea95be7b6f.tmp/Blink.ino.hex:&#xA;avrdude: load data flash data from input file /tmp/build8f287ac41038dd4edf2d64ea95be7b6f.tmp/Blink.ino.hex:&#xA;avrdude: input file /tmp/build8f287ac41038dd4edf2d64ea95be7b6f.tmp/Blink.ino.hex contains 4456 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 0.03s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 4456 bytes of flash verified&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can you please compare to what you get? Or post exactly what you see?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What do you see in your Port menu? This is what I see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OLmG8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OLmG8.png&quot; alt=&quot;Port menu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Installing Arduino on a fresh Ubuntu system&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I did the following steps to get Arduino up on Ubuntu 14.04, on a PC where it was not previously installed.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Download and install&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Downloaded Linux IDE 1.6.7 (64 bit) from &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/Software&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Un-archive downloaded file into &lt;code&gt;~/development&lt;/code&gt; folder&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Executed from terminal:  &lt;code&gt;./arduino&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Compile &quot;blink&quot;&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Selected Uno device type&lt;/li&gt;&#xA;&lt;li&gt;Loaded &quot;Blink&quot; from examples&lt;/li&gt;&#xA;&lt;li&gt;Uploaded (checked Uno showed in menu as shown above)&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Got error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: ser_open(): can't open device &quot;/dev/ttyACM0&quot;: Permission denied&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Check permissions, join dialout and tty groups&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;See owner of &lt;code&gt;/dev/ttyACM*&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ ls -l /dev/ttyACM*&#xA;crw-rw---- 1 root dialout 166, 0 Feb  1 07:32 /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I in that group? (No)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;getent group dialout&#xA;dialout:x:20:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to group &lt;code&gt;dialout&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo usermod -a -G dialout nick&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I in that group? (Yes)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ getent group dialout&#xA;dialout:x:20:nick&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;/dev/ttyACM0&quot;: Permission denied&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add to group &lt;code&gt;tty&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ sudo usermod -a -G tty nick&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check groups I am in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ groups nick&#xA;nick : nick adm tty dialout cdrom sudo dip plugdev lpadmin sambashare&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try again (same error).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Log out and log back in&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After logging out and back in, it uploaded OK! Changed to Micro board (very similar to Leonardo) - still uploaded OK (after changing board type in IDE).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Check USB for Micro&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After reset:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb | grep Arduino&#xA;Bus 002 Device 014: ID 2341:0036 Arduino SA &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After about 3 seconds:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb | grep Arduino&#xA;Bus 002 Device 015: ID 2341:8037 Arduino SA &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-31T21:01:01.607" LastActivityDate="2016-01-31T21:01:01.607" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="19981" PostTypeId="1" CreationDate="2016-01-26T09:38:02.270" Score="-3" ViewCount="84" Body="&lt;p&gt;I'd like the arduino to write to a file whenever an ajax call is made. The ajax works, but it doesn't write to the file. All other code inside the ajax handler does execute.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void handle_ajax() {&#xA;    int startUrlIndex = HTTP_req.indexOf(&quot;button&quot;);&#xA;    int endUrlIndex = HTTP_req.indexOf(&quot; HTTP&quot;);&#xA;    String url = HTTP_req.substring(startUrlIndex, endUrlIndex);&#xA;    int startButtonIndex = url.indexOf(&quot;device-&quot;) + 7;// 7 is length of device-, I really just want the number.&#xA;    int endButtonIndex = url.indexOf(&quot;&amp;amp;&quot;);&#xA;    String button = url.substring(startButtonIndex, endButtonIndex);&#xA;    int startStateIndex = url.indexOf(&quot;state=&quot;) + 6; // 6 is length of state=, I really just want the number.&#xA;    String state = url.substring(startStateIndex);&#xA;    int device = button.toInt();&#xA;    int newState = state.toInt();&#xA;    dim_light(device, newState * 12);&#xA;    write_config(&quot;&quot;, &quot;text&quot;);&#xA;}&#xA;&#xA;bool write_config(String line, String text) {&#xA;    configFile = SD.open(&quot;config.ini&quot;, FILE_WRITE);&#xA;&#xA;    if (configFile) {&#xA;        configFile.write(&quot;Dipshit&quot;);&#xA;    }&#xA;&#xA;    configFile.close();&#xA;    Serial.println(&quot;Works.&quot;);&#xA;    return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16733" LastEditorUserId="4143" LastEditDate="2016-01-26T13:53:08.040" LastActivityDate="2016-01-28T01:12:08.480" Title="Arduino uno not writing to file" Tags="|arduino-uno|programming|sd-card|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19983" PostTypeId="2" ParentId="19966" CreationDate="2016-01-26T13:55:08.437" Score="1" Body="&lt;p&gt;&lt;code&gt;const int clockPin = 17;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty sure that should be 13, not 17.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-26T13:55:08.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19985" PostTypeId="1" AcceptedAnswerId="19987" CreationDate="2016-01-26T16:03:28.863" Score="15" ViewCount="30939" Body="&lt;p&gt;I'm planning to buy an ESP8266. Do I really need to learn Lua to play with it? I have seen some people using it with the standard Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you need a custom firmware to use the Arduino IDE instead of Lua?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE seems better for me because I already know the syntax. Is there any downside to using the Arduino IDE instead of NodeMCU with Lua?&lt;/p&gt;&#xA;" OwnerUserId="16323" LastEditorUserId="4628" LastEditDate="2017-11-24T15:07:19.097" LastActivityDate="2018-03-24T22:21:18.753" Title="ESP8266, Arduino IDE vs Lua?" Tags="|arduino-ide|esp8266|nodemcu|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19986" PostTypeId="1" CreationDate="2016-01-26T16:06:35.260" Score="0" ViewCount="2503" Body="&lt;p&gt;I have an Arduino Uno and a W5100 Ethernet Shield. I am trying to post some data from the Arduino board to the WAMP server running on my computer. I do not have a router so I have directly connected my Ethernet shield stacked onto the Arduino Uno to the laptop's Ethernet port via an Ethernet cable. I have also assigned the Ethernet connection a static IP address 192.168.0.1 and my localhost page opens when I put this address in my browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my Arduino sketch I have assigned the Arduino shield an IP address 192.168.0.4, i.e. on the same IP segment. When I try to do client.connect to the server (192.168.0.1), i.e. localhost, I get &quot;Connection failed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0x6F, 0xED }; &#xA;IPAddress ip(192,168,0,4);&#xA;byte server[]={192,168,0,1};&#xA;&#xA;int value=9;&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  // Serial.begin starts the serial connection between computer and Arduino&#xA;  Serial.begin(9600);&#xA;  // start the Ethernet connection&#xA;  Ethernet.begin(mac,ip);&#xA;}&#xA;&#xA;void loop() {&#xA;  // Connect to the server (your computer or web page)  &#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;Connecting...&quot;);&#xA;    client.print(&quot;GET /Ethernet/getData.php?&quot;); // This&#xA;    client.print(&quot;value=&quot;); // This&#xA;    client.print(value); // And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor&#xA;    client.println(&quot; HTTP/1.1&quot;); // Part of the GET request&#xA;    client.println(&quot;Host: 192.168.0.1&quot;); &#xA;    client.println(&quot;Connection: close&quot;); &#xA;    client.println(); // Empty line&#xA;    client.println(); // Empty line&#xA;    client.stop();    // Closing connection to server&#xA;  }&#xA;&#xA;  else {&#xA;    // If Arduino can't connect to the server (your computer or web page)&#xA;    Serial.println(&quot;--&amp;gt; connection failed\n&quot;);&#xA;  }&#xA;  delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I upload the sketch onto the board and run the serial monitor, I get this output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qXM0T.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qXM0T.png&quot; alt=&quot;Serial monitor output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Ethernet connection detail screenshot is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DXR0n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DXR0n.png&quot; alt=&quot;Ethernet connection details&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell me any changes that I must make and also are there any WAMP settings which I should change to allow the connection to get established?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please consider the fact that I don't have a router anywhere in this connection - just my laptop and Ethernet shield connection.&lt;/p&gt;&#xA;" OwnerUserId="16744" LastEditorUserId="6936" LastEditDate="2016-03-01T20:25:17.727" LastActivityDate="2018-02-07T07:13:40.170" Title="Unable to connect Ethernet shield W5100 to localhost" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="19987" PostTypeId="2" ParentId="19985" CreationDate="2016-01-26T16:13:23.313" Score="13" Body="&lt;p&gt;Using the Arduino IDE &lt;em&gt;is&lt;/em&gt; custom firmware. That's what you're writing. You don't &lt;em&gt;need&lt;/em&gt; any new firmware because the new firmware is what you are writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't think of any downsides to using C++ to program the ESP8266 instead of Lua - in fact it can only be a benefit since you are not using an interpreted language which is going to be slower than natively compiled code.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4628" LastEditDate="2017-11-24T15:07:43.453" LastActivityDate="2017-11-24T15:07:43.453" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="19988" PostTypeId="1" AcceptedAnswerId="19994" CreationDate="2016-01-26T18:31:39.540" Score="10" ViewCount="17353" Body="&lt;p&gt;I've connected ESP8266 to Arduino UNO. After a getting a huge trouble I successfully managed to run some AT commands. I have also tested AP mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I got some trouble with software serial communication with Arduino and decided to change baud-rate to 9600 (previously it was 115200).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used &lt;code&gt;AT+IPR=9600&lt;/code&gt; command to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that blue led of esp stays on and not taking AT commands any more, but output some gibberish to serial monitor with few ascii text like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ets Jan  8 2013,rst cause:4, boot mode:(3,6)&#xA;&#xA;wdt reset&#xA;load 0x40100000, len 1396, room 16 &#xA;tail 4&#xA;chksum 0x89&#xA;load 0x3ffe8000, len 776, room 4 &#xA;tail 4&#xA;chksum 0xe8&#xA;load 0x3ffe8308, len 540, room 4 &#xA;tail 8&#xA;chksum 0xc0&#xA;csum 0xc0&#xA;&#xA;2nd boot version : 1.4(b1)&#xA;SPI Speed      : 40MHz&#xA;SPI Mode       : DIO&#xA;SPI Flash Size &amp;amp; Map: 8Mbit(512KB+512KB)&#xA;jump to run user1 @ 1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note: I know it consumes a lot power tried external 3.3V power supply and voltage divider for rx pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated. &lt;/p&gt;&#xA;" OwnerUserId="15310" LastActivityDate="2017-08-25T12:19:15.750" Title="Both red and blue led of ESP8266 stays on" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="19989" PostTypeId="2" ParentId="17188" CreationDate="2016-01-26T19:10:09.667" Score="0" Body="&lt;p&gt;You must need to add another power supply, which will give to the wifi module not just the correct voltage (3v) but the mA that it need.  / other thing you may need to do is connect the ground of Arduino to Ground of the power supply. For me works good.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;the connections would be like this&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;esp TX     &gt; arduino dpin 10  &lt;/li&gt;&#xA;&lt;li&gt;esp RX     &gt; arduino dpin 11&lt;/li&gt;&#xA;&lt;li&gt;esp CH     &gt; to VCC 3V&lt;/li&gt;&#xA;&lt;li&gt;esp RST    &gt; to pushbutton connected to gnd&lt;/li&gt;&#xA;&lt;li&gt;esp GpIO 0 &gt; none&lt;/li&gt;&#xA;&lt;li&gt;esp GpIO 2 &gt; none&lt;/li&gt;&#xA;&lt;li&gt;esp VCC &gt; power supply 3v&lt;/li&gt;&#xA;&lt;li&gt;esp GND &gt; power supply gnd&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16747" LastActivityDate="2016-01-26T19:10:09.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19990" PostTypeId="1" CreationDate="2016-01-26T20:03:32.270" Score="2" ViewCount="849" Body="&lt;p&gt;I have a value I'm taking from a sensor module, which is 2500 when the sensor is facing a light source. This reads to my code and can be saved perfectly fine. When I try to find the weighted average of a set of values (2500*1000+2500*2000+2500*3000 etc), the Arduino comes out with very weird answers. For example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2500*1000=9632&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I just compute 2500*1000 on its own, the answer still comes out the same! The results come out negative if I use int so I switched to using double (just in case the values created were too big), this stops producing negatives as expected but the result is still like it is above.. I have no idea why.. any ideas?&lt;/p&gt;&#xA;" OwnerUserId="11326" LastActivityDate="2016-01-26T20:12:57.493" Title="Arduino can't multiply?" Tags="|arduino-uno|c|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="19991" PostTypeId="2" ParentId="19990" CreationDate="2016-01-26T20:08:14.200" Score="4" Body="&lt;p&gt;2500 * 1000 = 9632 is exactly what you expect with 16-bit integers. You&#xA;should use long integers instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2500L * 1000L == 2500000L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Floats work also, but are more expensive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2500.0 * 1000.0 == 2500000.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;although I do not recommend testing for exact equality of floats (it&#xA;works here because these numbers are exactly representable).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-01-26T20:08:14.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19994" PostTypeId="2" ParentId="19988" CreationDate="2016-01-26T22:16:11.590" Score="4" Body="&lt;p&gt;If you have too, you can find the firmware for the ESP8266 &lt;a href=&quot;https://github.com/espressif/esp8266_at/tree/master/bin&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and re-flash it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's some good info &lt;a href=&quot;http://bbs.espressif.com/download/file.php?id=84&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; about the instruction set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With respect to your issue of the blue (traffic) light staying on, I can't imagine that the baud command would have caused an issue. Perhaps you need to double check your circuit and make sure that the Rx pin of the ESP8266 is not being held high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens with only 3.3V and GND connected to the ESP8266?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the output you're getting is similar to the output from “AT+GMR”. Are you sending it that in a loop by chance?&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="16725" LastEditDate="2016-01-26T22:23:48.883" LastActivityDate="2016-01-26T22:23:48.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="19995" PostTypeId="1" CreationDate="2016-01-27T01:09:03.527" Score="0" ViewCount="147" Body="&lt;p&gt;I am looking to setup a system where I have a master Arduino polling a number of sensors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I am thinking is hooking the master TX line to the sensors RX line(and the opposite for the other line)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How long can the lines be?&lt;/li&gt;&#xA;&lt;li&gt;Can the lines branch?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16754" LastEditorUserId="26916" LastEditDate="2017-09-08T21:50:06.770" LastActivityDate="2017-09-08T21:50:06.770" Title="Branching Bus for Sensor" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19996" PostTypeId="1" AcceptedAnswerId="19998" CreationDate="2016-01-27T01:10:45.653" Score="3" ViewCount="1018" Body="&lt;p&gt;I have seen it said over and over (in different places) that in order to achieve 640x480 resolution out to a DB15 VGA connection, the arduino would need to be clocked at 25Mhz or that at half resolution it would need to be clocked at 12.5Mhz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the relation between resolution and internal clock? I would expect that so long we can feed the signal fast enough that would be enough.&lt;/p&gt;&#xA;" OwnerUserId="16757" LastActivityDate="2016-01-27T20:12:36.993" Title="What is the relation between Arduino's clock and possible VGA resolution?" Tags="|oscillator-clock|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="19997" PostTypeId="2" ParentId="19995" CreationDate="2016-01-27T02:23:16.437" Score="0" Body="&lt;p&gt;How many sensors and what kind are they?&#xA;What Arduino do you have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you could use 1 Arduino Output per sensor if you have enough, or you are going to need to use a multiplex technique via additional electronic components. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other solution would be to use communication (I2C/Serial/etc) to receiving nodes at the sensor.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-01-27T02:23:16.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="19998" PostTypeId="2" ParentId="19996" CreationDate="2016-01-27T02:27:30.627" Score="5" Body="&#xA;&#xA;&lt;p&gt;I doubt if that would be fast enough. See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11608&quot; rel=&quot;nofollow noreferrer&quot;&gt;my thread about connecting to a VGA monitor&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Borrowing from that page, so as to not make a link-only answer ...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For 640x480 pixels of active video you have something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tGTx3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tGTx3.png&quot; alt=&quot;Video timing diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Vertical Sync&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Let's start with the vertical sync pulses. In fact, we'll show how all the timing data can be derived from three figures:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The screen refresh rate (eg. 60 Hz)&lt;/li&gt;&#xA;&lt;li&gt;The screen resolution (eg. 640 x 480)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So what is the refresh rate? It's the rate at which the entire screen is redrawn. If you ever looked at Windows screen resolution you probably saw something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cxDIR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cxDIR.png&quot; alt=&quot;Refresh rate&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the refresh rate: 60 Hz (60 times a second). This figure was probably originally chosen because it is the mains frequency in the USA, so that would minimize the artifact of mains hum bars appearing on the screen, in the days of CRT monitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other figure of interest is the screen resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In our case we are going for the minimum we can (640 x 480) and seeing where those figures lead us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Starting with the refresh rate, a 60 Hz refresh rate will require a &quot;vertical sync&quot; pulse 60 times a second, or a period of 1/60 (16.66 ms).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Generating vertical sync pulses&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This code in my VGA output sketch generates the vertical sync pulses:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // Timer 1 - vertical sync pulses&#xA;  pinMode (vSyncPin, OUTPUT); &#xA;  Timer1::setMode (15, Timer1::PRESCALE_1024, Timer1::CLEAR_B_ON_COMPARE);&#xA;  OCR1A = 259;  // 16666 / 64 uS = 260 (less one)&#xA;  OCR1B = 0;    // 64 / 64 uS = 1 (less one)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The clock period is 62.5 ns (1/16000000). By applying a prescaler of 1024 the timer counts up once every 64 µs. So to get a period of 1/60 of a second (16666 µs) we need to count up to 260 (16666 / 64 = 260). Since the timer counts are zero-relative we set OCR1A to count up to 259. This sets the frequency of Timer 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we need to set the pulse width by putting the correct value in OCR1B. We want a pulse width of two lines. One line is 1 / 60 / 525, namely 31.7 µs. So two lines would be 63.4 µs. This is close enough to exactly one timer count (64 µs). So OCR1B is set to zero (being zero-relative, making it zero gives a count of 1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer 1 is configured to &quot;clear B on compare&quot; which effectively means that it toggles the output pin (D10 on the Uno) so it is high for the duty cycle width (64 µs) and low the rest of the time. If you wanted the opposite sync pulse polarity, change CLEAR_B_ON_COMPARE to SET_B_ON_COMPARE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer is also set up to generate an interrupt, which is used to tell the code that we are starting another vertical cycle, by setting the line count to zero:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  vLine = 0;&#xA;  messageLine = 0;&#xA;  backPorchLinesToGo = verticalBackPorchLines;&#xA;  } // end of TIMER1_OVF_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Horizontal sync&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Horizontal sync pulses tell the monitor when to start drawing each line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate the horizontal sync frequency we need to divide the overall frame rate (60 Hz) by the number of total lines (525 if you count the sync pulse itself, and the front and back porches).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt; (1/60) / 525 * 1e6 = 31.74 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We also need to know the sync pulse width. That is documented to be 96 pixels, so we need to know the width of one pixel. That would be the figure above, divided by 800 (being the total screen width including the sync pulse, and front and back porches).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus that is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;((1/60) / 525 * 1e9) / 800 = 39.68  ns&#xA;1 / (((1/60) / 525 * 1e6) / 800) = 25.2 MHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So our pixel width is 39.68 ns and the pixel clock is 25.2 mHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The horizontal sync pulse width is 96 pixels, so we want a pulse of:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;96 * 39.68 ns = 3.8 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Generating horizontal sync pulses&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now we are ready to set up the timer for the horizontal sync pulses:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // Timer 2 - horizontal sync pulses&#xA;  pinMode (hSyncPin, OUTPUT); &#xA;  Timer2::setMode (7, Timer2::PRESCALE_8, Timer2::CLEAR_B_ON_COMPARE);&#xA;  OCR2A = 63;   // 32 / 0.5 µs = 64 (less one)&#xA;  OCR2B = 7;    // 4 / 0.5 µs = 8 (less one)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The clock period is 62.5 ns (1/16000000). By applying a prescaler of 8 the timer counts up once every 0.5 µs. So to get a period of 32 µs we need to count up to 64 (32 / 0.5 = 64). Since the timer counts are zero-relative we set OCR2A to count up to 63. This sets the frequency of Timer 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then we need to set the pulse width by putting the correct value in OCR2B. We want a pulse width of 96 pixels (3.8 µs). So OCR2B is set to 7 (being zero-relative, making it 7 gives a count of 8, which is 4 / 0.5).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, if you wanted the opposite sync pulse polarity, change CLEAR_B_ON_COMPARE to SET_B_ON_COMPARE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer is also set up to generate an interrupt, which has the sole purpose of waking the processor up from sleep, so it can draw each line with exactly the same delay after the pulse. If it wasn't asleep, there would be a variation of two to three clock cycles (since an interrupt cannot occur during a single instruction) and this gives very bad-looking &quot;jitter&quot; on the screen.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR (TIMER2_OVF_vect)&#xA;  {&#xA;  } // end of TIMER2_OVF_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Pixel data&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now things get tricky ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's see how long we have to draw 640 pixels:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;((1/60) / 525 * 1e9) / 800  * 640 = 25396.82 ns (25.39 µs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just can't be done on this processor. The clock period itself is only 62.5 ns, so there is no way we can output a pixel every 39.68 ns (that is: 25396.82 / 640 = 39.68).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fastest way we can get bits &quot;out the door&quot; is using the SPI hardware. That can run at a maximum clock rate of twice the system clock, that is, one pixel every 125 ns. So we will have to settle for having the pixels 4 times as wide. A horizontal resolution therefore of 160 pixels. Since we will display 8-pixel characters, that gives us 20 characters per line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Summary&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Even at 25 MHz processor speed (which exceeds its spec) you won't be able to clock out pixels fast enough for 640 pixel width (since the fastest SPI speed is half the processor clock speed).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would expect that so long we can feed the signal fast enough that would be enough.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's the tricky bit. To output data you have to do more than merely send it. You have to read it from memory, so it would take a least a couple of clock cycles to do that.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example of working at that resolution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A screen shot of my sketch in action (160 characters wide - 640 pixels and 30 characters high - 480 pixels, which is 16 pixels each as they were &quot;doubled&quot; in height to make them look in proportion). The font data was 8x8 pixels, and thus they appear as 16x16 on the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SC5PU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SC5PU.jpg&quot; alt=&quot;Example VGA output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So does that mean that there really isn't a direct relation between clock speed and resolution? Other than, the clock must be faster than this&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To work even at that speed the processor speed needs to be a multiple of the VGA clock, or close enough for the monitor to accept. (Looking at my figures the pixel rate is not in fact a multiple of 39.68 ns, so I am guessing that my monitor was able to adjust).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could get better results by having a system clock which was an exact multiple of 39.68 ns (around 25 MHz - precisely 25.201613 MHz) - which is what you suggested in the question. However that just gives more accurate timing, you would still get similar resolution to what I show here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, to work on more monitors you should have a direct relation between clock speed and resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I seem to have a 25.175 MHz crystal in my parts drawer, so perhaps I experimented with this a while back. Of course, you have to recalculate the other timings if you use that, and the processor is running out of spec.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-27T20:12:36.993" LastActivityDate="2016-01-27T20:12:36.993" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="19999" PostTypeId="2" ParentId="19995" CreationDate="2016-01-27T02:34:58.117" Score="2" Body="&lt;p&gt;I have a page about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;connecting Arduinos using RS485&lt;/a&gt;. You can connect multiple devices up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/auNfc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/auNfc.png&quot; alt=&quot;RS485 setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That has a reasonable range, 20 metres or more.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On that page I describe a &lt;em&gt;Rolling-master system&lt;/em&gt; where each device takes turns to be the master and transmit information to the other devices. It also manages some devices not responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This screenshot shows the various devices &quot;talking&quot; during their timeslot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XB5aq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XB5aq.png&quot; alt=&quot;Rolling master demo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that particular case there were 3 devices active out of 4 configured.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have a master ardunio polling a number of sensors. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm assuming in my answer that you have an Arduino at each sensor point (you could use a cheap ATtiny85 or something). That would be needed to run the rolling master code.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-27T02:34:58.117" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20000" PostTypeId="1" AcceptedAnswerId="20019" CreationDate="2016-01-27T04:00:20.803" Score="5" ViewCount="11615" Body="&lt;p&gt;I'm using the Adafruit Motor Shield v2.3. I'm powering the Arduino with a USB cable and I'm powering the motor shield with a 9 volt battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I removed the vin pin, and I'm using &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/install-software&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; tutorial/code to make the DC motor spin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried 3 different kinds of DC motors, but none of them will do anything. The Arduino works for normal sketches, like lighting up LEDs, but I can't get the motors to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I'm using Adafruit's &quot;Motor Test&quot; code from the Motor Shield v2 library, as shown below. The motor is on port 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Adafruit Motor shield library&#xA;// copyright Adafruit Industries LLC, 2009&#xA;// this code is public domain, enjoy!&#xA;&#xA;#include &amp;lt;AFMotor.h&amp;gt;&#xA;&#xA;AF_DCMotor motor(4);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;  Serial.println(&quot;Motor test!&quot;);&#xA;&#xA;  // turn on motor&#xA;  motor.setSpeed(200);&#xA;&#xA;  motor.run(RELEASE);&#xA;}&#xA;&#xA;void loop() {&#xA;  uint8_t i;&#xA;&#xA;  Serial.print(&quot;tick&quot;);&#xA;&#xA;  motor.run(FORWARD);&#xA;  for (i=0; i&amp;lt;255; i++) {&#xA;    motor.setSpeed(i);  &#xA;    delay(10);&#xA; }&#xA;&#xA;  for (i=255; i!=0; i--) {&#xA;    motor.setSpeed(i);  &#xA;    delay(10);&#xA; }&#xA;&#xA;  Serial.print(&quot;tock&quot;);&#xA;&#xA;  motor.run(BACKWARD);&#xA;  for (i=0; i&amp;lt;255; i++) {&#xA;    motor.setSpeed(i);  &#xA;    delay(10);&#xA; }&#xA;&#xA;  for (i=255; i!=0; i--) {&#xA;    motor.setSpeed(i);  &#xA;    delay(10);&#xA; }&#xA;&#xA;&#xA;  Serial.print(&quot;tech&quot;);&#xA;  motor.run(RELEASE);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NqNqb.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NqNqb.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7891" LastEditorUserId="7891" LastEditDate="2016-01-27T06:23:12.267" LastActivityDate="2019-12-12T15:56:52.737" Title="Why is my Adafruit motor shield not spinning my motors?" Tags="|arduino-uno|motor|adafruit|arduino-motor-shield|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20001" PostTypeId="2" ParentId="19835" CreationDate="2016-01-27T05:01:03.040" Score="3" Body="&lt;p&gt;After seeing your schematic, I think the general problem here is that you need to more closely read and follow the datasheet for this part. A lot of times, when you are hobbling a project together at a small scale there are a lot of things you can ignore and get away with, but as you scale up, all the rounded corners start to add up. In this case, you can get away with 16, but once you start adding too more, it becomes too much. Let's go over a few:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pull up resistors&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like I mentioned in the comments, relying on the internal pull ups is probably not a good idea. In my personal experience, they are only really good for adding a quick button input for debugging purposes. I'm not sure specifically what would cause issues only after 16 sensors. It could be that collectively internal pullups are subject to a different and lower current limit, but I'm not familiar enough with the internal architecture of the ATMega2560 to do more than just speculate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whatever the case, the best practice here would be to use separate external pull up resistors, within the specifications of the datasheet. (See equation 1 on page 13 of the datasheet.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Decoupling Capacitor&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per the datasheet, page 17:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A 0.01-µF (minimum) ceramic capacitor rated for VCC must be placed as close to the DRV5023 device as possible.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This capacitor is referred to as C1 in the datasheet figures and is required. This type of capacitor is called a decoupling capacitor, and one of the things it does is provide a local energy storage, so that when the sensor starts pulling a little extra current, it doesn't have to wait for the regulator to respond, it has some local energy already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your schematic indicates a single 1uF capacitor on the output of the voltage regulator, however, there are no capacitors for the sensors. The one capacitor is only for output filtering for the regulator, and will not satisfy any decoupling needs of the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Filtering Capacitor&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Referred to as C2 in the datasheet, this an optional capacitor to filter out high frequency noise. This isn't needed in most cases, in fact, per the datasheet, page 13:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Most applications do no require this C2 filtering capacitor.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, your project might not fall into &quot;most applications&quot; and there are a few things specifically that worry me.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have long wires that are basically acting as antennas that will capture any nearby noise.&lt;/li&gt;&#xA;&lt;li&gt;You have long power lines running parallel to your signal lines which can cause stray inductance which leads to other interesting things. (With the thickness of the plywood separating them, this might not be an issue, but it is something to be aware of).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would definitely try the first two ideas above to begin with, and only pursue this as a last resort. The  only way to know for sure if this is something you need is to stick an oscilloscope on the line and see how noisy it is, but that is not something you probably have handy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other Concerns&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just a little bit worried about voltage drop. Depending on the gauge of wire used, with all the sensors connected, at the end of a strand you might have a non-negligible voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that many wires running together into the Mega, there might be cross talk problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another common problem with scaling up is that there is a higher probability of having faulty components. This is especially with this part which per the datasheet indicates that is particularly sensitive to ESD. It could be that there is a dead sensor that has failed in such a way that it is causing problems for the other sensors. Maybe go through and test all 64 sensors, 8~16 at a time to make sure that separately they all work, and that the issue only occurs when all of them are connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Other Ideas&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many other comments on the question have suggested a multiplexer and/or multiplexing and I will just briefly echo that here. Multiplexers are typically used in situations where you don't have enough pins and you want to split a single pin to multiple other pins. While that isn't an issue here with the Mega (it appears you have enough pins to do what you are wanting to do), there are other benefits that can be derived from multiplexing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, one thing you could do is split up the board into 8 - 2 x 4 chunks and then have a multiplexer (such as a 4051 or a 74151) local to each chunk. Then you would have just 8 short wires going into the multiplexer, as opposed to having long antenna-like wires heading to the Mega. This could improve overall signal integrity.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-27T05:01:03.040" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20002" PostTypeId="2" ParentId="20000" CreationDate="2016-01-27T05:26:45.897" Score="3" Body="&lt;p&gt;Per the comments above, and the &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/faq#faq-14&quot; rel=&quot;nofollow&quot;&gt;documentation from Adafruit&lt;/a&gt;, a 9V battery is insufficient for use with motors as they do not provide enough current.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-27T05:26:45.897" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20003" PostTypeId="1" AcceptedAnswerId="20007" CreationDate="2016-01-27T07:16:09.950" Score="1" ViewCount="148" Body="&lt;p&gt;I'm using mthreads (&lt;a href=&quot;https://github.com/jlamothe/mthread&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jlamothe/mthread&lt;/a&gt;) for my arduino. But now as the project is getting bigger, it would make sense to break it up in several files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I successfully outsourced already a part which is not threaded. But somehow I cannot make up my mind how to use mthread in conjunction with several header files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is what I got: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;main: call header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;tcan.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tcan.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef tcan_h&#xA;#define tcan_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;class tcan : public Thread {&#xA;  public: tcan();&#xA;  protected: bool loop();&#xA;  private:&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;tcan.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;tcan.h&quot;&#xA;#include &amp;lt;mcp_can.h&amp;gt;&#xA;&#xA;bool tcan::loop() {&#xA;  // lala&#xA;  return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but I get an error when compiling:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;tcan.h:6:28: error: expected class-name before '{' token  class tcan :&#xA;  public Thread {&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="11150" LastActivityDate="2016-01-27T09:15:30.950" Title="mthread and multiple header files" Tags="|threads|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20004" PostTypeId="1" CreationDate="2016-01-27T00:47:46.890" Score="0" ViewCount="54" Body="&lt;p&gt;I purchased the arduino pro mini atmega328 and equipped it with FTDI breakout board with USB, a battery charging board, Wireless transmitter and a wireless receiver.  I'm assuming they can all be connected.  My question is, how do I download programs to the arduino board?  And where might I find specific programs to download?&lt;/p&gt;&#xA;" OwnerDisplayName="dcash3010" LastEditorUserId="2881" LastEditDate="2016-01-27T16:01:05.850" LastActivityDate="2017-09-09T08:05:13.467" Title="arduino pro mini downloading?" Tags="|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20005" PostTypeId="2" ParentId="20004" CreationDate="2016-01-27T03:38:38.330" Score="4" Body="&lt;p&gt;The Arduino Pro Mini has a row of connections at the small end that align with the connections on the USB-to-Serial board you have.  They are marked GND - VCC - RXI - TXI and should be in the same order as the connector on the FTDI board. I think that the pin marked GRN on the Arduino will align with the connector marked DTR on the USB-to-Serial board, but please make sure that VCC aligns with 5V!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the FTDI board plugged into the Arduino, you can plug your computer into the FTDI board's USB port and when you run the Arduino IDE programming tool, that USB port should say that it's connected to a serial port.  Pick the &quot;Arduino Pro or Pro Mini&quot; as your board, then pick your processor (most likely the &quot;ATmega328 (5V, 16MHz)&quot; and finally your port (that serial port you found).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when you upload your Arduino program to the Arduino, it will know the board your have and the port to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for programs to use, start simple and get the onboard LED to blink.  From there, you'll have the basics down for creating a program and getting it to the Arduino.  You'll find tons of example programs (called sketches in Arduino land) that will help you connect all your fun wireless gizmos!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted above - Google is your friend.  There are many places to go for examples and help.  Start with some of the commercial sites like Adafruit and SparkFun. Their staff really supports the Arduino community with how-to videos, libraries, examples, etc.&lt;/p&gt;&#xA;" OwnerDisplayName="Neutronned" LastEditorUserId="26916" LastEditDate="2017-09-09T08:05:13.467" LastActivityDate="2017-09-09T08:05:13.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20006" PostTypeId="1" AcceptedAnswerId="20011" CreationDate="2016-01-27T08:23:13.790" Score="1" ViewCount="928" Body="&lt;p&gt;I am Android application developer and I want to modify regular toy RC car which can be controlled by Android phone. I want to use 2 Android phones: 1 as remote controller, 1 as controller in RC car. I want to use sensors like GPS, Mobile network, Wifi in RC car in RC car side. I want to know: can I use Android phone as controller in RC car. I am thinking about 2 options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;phone as controller (without arduino) - this option would be the&#xA;best &lt;/li&gt;&#xA;&lt;li&gt;if phone cannot give commands maybe with arduino, while&#xA;using phone's sensors like gps, mobile network, wifi, bluetooth&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is this possible? If yes, what tools I should use to connect?&lt;/p&gt;&#xA;" OwnerUserId="16763" LastActivityDate="2016-01-27T10:49:44.753" Title="Can Android phone can be used instead of( or with) Arduino as controller?" Tags="|arduino-nano|remote-control|android|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20007" PostTypeId="2" ParentId="20003" CreationDate="2016-01-27T08:48:21.010" Score="1" Body="&lt;p&gt;The compiler error is due to that the compiler does not know what Thread is.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;tcan.h:6:28: error: expected class-name before '{' token class tcan : public Thread {&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The issue is that the header file is not complete. &lt;strong&gt;A good practice is to include all header files that are needed to read the header file.&lt;/strong&gt; As &lt;em&gt;Thread&lt;/em&gt; is defined in &lt;em&gt;mthread.h&lt;/em&gt; the &lt;em&gt;tcan.h&lt;/em&gt; file should be: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef tcan_h&#xA;#define tcan_h&#xA;&#xA;#include &amp;lt;mthread.h&amp;gt;&#xA;&#xA;class tcan : public Thread {&#xA;public: tcan();&#xA;protected: bool loop();&#xA;private:&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-27T09:15:30.950" LastActivityDate="2016-01-27T09:15:30.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20008" PostTypeId="2" ParentId="19890" CreationDate="2016-01-27T09:23:32.280" Score="1" Body="&lt;p&gt;This is starting to drift off topic for this site, but the best solution for making an automated programming utility for the Teensy on Windows, short of writing one yourself, would be to use some kind of UI automation framework to automate the process described in &lt;a href=&quot;https://arduino.stackexchange.com/a/19845/11086&quot;&gt;my earlier answer&lt;/a&gt;. My favorite one that I have used in the past is &lt;a href=&quot;https://www.autoitscript.com/site/autoit/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AutoIt&lt;/a&gt;. It has tools to inspect applications so that you can programmatically click buttons and fill out fields. There are even ways of having it run programs without them being visible to the user. There are plenty of tutorials on the web on how to use AutoIt so I would suggest googling for that. If you have further questions on how to do that, they would be more appropriate on a site other than Arduino.SE.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-27T09:23:32.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20011" PostTypeId="2" ParentId="20006" CreationDate="2016-01-27T10:49:44.753" Score="1" Body="&lt;p&gt;You cannot directly control your RC car using and Android phone if you are talking about a normal RC car. If you have an RC car that can be already connected via bluetooth this is another story.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for normal RC car you would need to have:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AndroidPhone -&gt; Network -&gt; AndroidPhone -&gt; SerialInterface -&gt; Arduino -&gt; RC&lt;/p&gt;&#xA;" OwnerUserId="8308" LastActivityDate="2016-01-27T10:49:44.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20015" PostTypeId="1" AcceptedAnswerId="20034" CreationDate="2016-01-27T14:08:58.223" Score="1" ViewCount="3161" Body="&lt;p&gt;I have an air conditioner switch rated at 32A/240V AC - how do I turn this on using Arduino and Relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm based in India and I am unable to find a relay switch rated higher than &lt;a href=&quot;http://www.amazon.in/Channel-Module-Shield-Arduino-Electronic/dp/B00C59NOHK/ref=pd_sim_sbs_147_6?ie=UTF8&amp;amp;dpID=51amkYDfw4L&amp;amp;dpSrc=sims&amp;amp;preST=_AC_UL160_SR160%2C160_&amp;amp;refRID=1DYV10685X37A49WG5NV&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to try anything that results in a fire hazard. My aim is to switch on the AC with my mobile phone. I'm using Arduino Uno with a 2.4GHz transceiver for communication.&lt;/p&gt;&#xA;" OwnerUserId="16775" LastActivityDate="2016-01-27T21:27:37.727" Title="How to switch on 32A/240VAC with Arduino?" Tags="|arduino-uno|relay|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20016" PostTypeId="2" ParentId="20015" CreationDate="2016-01-27T14:30:14.543" Score="2" Body="&lt;p&gt;The simple answer is: you need to find a relay rated high enough for the voltage and current. There's no way you can make a small relay handle a large current, and relays cannot be joined together to share the load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a relay is not available in your country (and I seriously doubt that - you're probably just looking in the wrong places - instead of looking for things on Amazon or eBay try looking at proper industrial electronics suppliers) then you would have to come up with something more creative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about designing and building a small electro-mechanical system that physically changes the position of the existing switch for you? Solenoids to press the right bits of the switch, or motors to turn the right bit round, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-27T14:30:14.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20017" PostTypeId="2" ParentId="17277" CreationDate="2016-01-27T14:39:17.197" Score="0" Body="&lt;p&gt;You can find some 3rd party library that does software emulation of threads.&#xA;For example: &lt;a href=&quot;https://github.com/ivanseidel/ArduinoThread&quot; rel=&quot;nofollow&quot;&gt;ArduinoThread&lt;/a&gt;.&#xA;With the use of such library I successfully developed an app that was switching LEDs on and off and at the same time listened to any data coming from Bluetooth (serial port). It is worth a try.&lt;/p&gt;&#xA;" OwnerUserId="8308" LastActivityDate="2016-01-27T14:39:17.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20018" PostTypeId="1" AcceptedAnswerId="20021" CreationDate="2016-01-27T15:48:03.587" Score="2" ViewCount="8132" Body="&lt;p&gt;Is it possible to emulate an RFID tag with the &lt;a href=&quot;http://playground.arduino.cc/Learning/MFRC522&quot; rel=&quot;nofollow&quot;&gt;RC522&lt;/a&gt;? (Spec sheet: &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&quot; rel=&quot;nofollow&quot;&gt;nxp MFRC522.pdf&lt;/a&gt;)&lt;br&gt;&#xA;I want the RC522 to act like a NTAG213 nxp.com/documents/data_sheet/NTAG213_215_216.pdf and to be read/write by other readers/writers.&lt;br&gt;&#xA;Are there libraries for that purpose?&lt;/p&gt;&#xA;" OwnerUserId="16778" LastEditorUserId="16778" LastEditDate="2016-01-27T17:34:34.537" LastActivityDate="2016-01-27T18:27:31.173" Title="How to emulate an RFID tag with the RC522" Tags="|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20019" PostTypeId="2" ParentId="20000" CreationDate="2016-01-27T16:38:48.437" Score="5" Body="&lt;p&gt;A couple of things I see...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.)&lt;/strong&gt; Your motor leads may be shorting out of the housing of the motor. make sure they are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.)&lt;/strong&gt; You may have the motor on the wrong port for the given code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On line 7 of the code it reads: &lt;code&gt;AF_DCMotor motor(4);&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So try switching physically your motor to port 4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.)&lt;/strong&gt; Also, this board has an I2C address and I dont see that addressed anywhere in the code. You can check to see what the I2C address is with this code. It will also show you that the motor control board is indeed responding.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// --------------------------------------&#xA;// i2c_scanner&#xA;//&#xA;// Version 1&#xA;//    This program (or code that looks like it)&#xA;//    can be found in many places.&#xA;//    For example on the Arduino.cc forum.&#xA;//    The original author is not know.&#xA;// Version 2, Juni 2012, Using Arduino 1.0.1&#xA;//     Adapted to be as simple as possible by Arduino.cc user Krodal&#xA;// Version 3, Feb 26  2013&#xA;//    V3 by louarnold&#xA;// Version 4, March 3, 2013, Using Arduino 1.0.3&#xA;//    by Arduino.cc user Krodal.&#xA;//    Changes by louarnold removed.&#xA;//    Scanning addresses changed from 0...127 to 1...119,&#xA;//    according to the i2c scanner by Nick Gammon&#xA;//    http://www.gammon.com.au/forum/?id=10896&#xA;// Version 5, March 28, 2013&#xA;//    As version 4, but address scans now to 127.&#xA;//    A sensor seems to use address 120.&#xA;// Version 6, November 27, 2015.&#xA;//    Added waiting for the Leonardo serial communication.&#xA;// &#xA;//&#xA;// This sketch tests the standard 7-bit addresses&#xA;// Devices with higher bit address might not be seen properly.&#xA;//&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;&#xA;  Serial.begin(9600);&#xA;  while (!Serial);             // Leonardo: wait for serial monitor&#xA;  Serial.println(&quot;\nI2C Scanner&quot;);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  byte error, address;&#xA;  int nDevices;&#xA;&#xA;  Serial.println(&quot;Scanning...&quot;);&#xA;&#xA;  nDevices = 0;&#xA;  for(address = 1; address &amp;lt; 127; address++ ) &#xA;  {&#xA;    // The i2c_scanner uses the return value of&#xA;    // the Write.endTransmisstion to see if&#xA;    // a device did acknowledge to the address.&#xA;    Wire.beginTransmission(address);&#xA;    error = Wire.endTransmission();&#xA;&#xA;    if (error == 0)&#xA;    {&#xA;      Serial.print(&quot;I2C device found at address 0x&quot;);&#xA;      if (address&amp;lt;16) &#xA;        Serial.print(&quot;0&quot;);&#xA;      Serial.print(address,HEX);&#xA;      Serial.println(&quot;  !&quot;);&#xA;&#xA;      nDevices++;&#xA;    }&#xA;    else if (error==4) &#xA;    {&#xA;      Serial.print(&quot;Unknow error at address 0x&quot;);&#xA;      if (address&amp;lt;16) &#xA;        Serial.print(&quot;0&quot;);&#xA;      Serial.println(address,HEX);&#xA;    }    &#xA;  }&#xA;  if (nDevices == 0)&#xA;    Serial.println(&quot;No I2C devices found\n&quot;);&#xA;  else&#xA;    Serial.println(&quot;done\n&quot;);&#xA;&#xA;  delay(5000);           // wait 5 seconds for next scan&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16779" LastActivityDate="2016-01-27T16:38:48.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20020" PostTypeId="2" ParentId="20015" CreationDate="2016-01-27T17:14:18.733" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't want to try anything that results in a fire hazard.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's a good idea. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides those toy relays there are real ones:&#xA;&lt;a href=&quot;http://uk.rs-online.com/web/p/non-latching-relays/8002896/&quot; rel=&quot;nofollow&quot;&gt;440 V AC * 63 A&lt;/a&gt; (Around there, you can find smaller ones too)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: Don't rely on what's printed on the relay itself, with cheap Arduino relay modules. 230V and some current need proper handling by the PCB board as well (size and distance of the copper tracks on the scondary side)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a solution that could be certified (or certifiable) as &quot;safe&quot; there probably won't be an Arduino involved or being built by anyone asking questions like you do  ;(   (sorry)&lt;/p&gt;&#xA;" OwnerUserId="16780" LastEditorUserId="16780" LastEditDate="2016-01-27T17:26:35.937" LastActivityDate="2016-01-27T17:26:35.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20021" PostTypeId="2" ParentId="20018" CreationDate="2016-01-27T18:27:31.173" Score="2" Body="&lt;p&gt;No. Looking at the datasheet, card emulation is not a feature provided by the RC522.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another popular chip, the &lt;a href=&quot;https://www.adafruit.com/datasheets/pn532ds.pdf&quot; rel=&quot;nofollow&quot;&gt;PN532&lt;/a&gt;, does seem to indicate support for that feature, however, looking at the most popular &lt;a href=&quot;https://github.com/adafruit/Adafruit-PN532&quot; rel=&quot;nofollow&quot;&gt;library for this chip&lt;/a&gt; from Adafruit, it does not implement this feature. Another &lt;a href=&quot;https://github.com/Seeed-Studio/PN532&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; from Seeed, does seem to implement it, but it looks rather limited as to which cards can be emulated, and the library itself hasn't been updated in a while.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-27T18:27:31.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20022" PostTypeId="1" CreationDate="2016-01-27T19:19:34.120" Score="0" ViewCount="151" Body="&lt;p&gt;So I recently bought an Arduino along with an LCD module and two extra ATmega328P-PU ICs. Yesterday it was working just fine then I disconnected everything and reconnected it and this happened.&lt;/p&gt;&#xA;&lt;p&gt;What could possibly go wrong?&lt;/p&gt;&#xA;&lt;p&gt;Setup:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mhd5m.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mhd5m.jpg&quot; alt=&quot;Photo of Arduino and 16 x 2 LCD display&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;with microcontroller that came with the board:&lt;/p&gt;&#xA;" OwnerUserId="16784" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-06T04:58:03.787" Title="Bad LCD? Bad microcontroller? Or what?" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20023" PostTypeId="2" ParentId="20015" CreationDate="2016-01-27T19:24:00.177" Score="2" Body="&lt;p&gt;What about staying with small relay and just add a contactor? The relay will deal with the low current 230v to drive the contactor and the contactor would deal with the high current.&lt;/p&gt;&#xA;" OwnerUserId="16784" LastEditorUserId="10794" LastEditDate="2016-01-27T20:15:42.920" LastActivityDate="2016-01-27T20:15:42.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20025" PostTypeId="1" AcceptedAnswerId="20029" CreationDate="2016-01-27T20:09:07.147" Score="2" ViewCount="1267" Body="&lt;p&gt;I have a question with the topic &lt;em&gt;variables&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, a variable is a place where you can store data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And when you make a variable with datatype int (&lt;code&gt;int ledpin=13;&lt;/code&gt;) then you store a value 10 in a variable named &lt;code&gt;ledpin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT how can the Arduino know it's a pin number 13 from Arduino or a random number 13 that we are storing there?&lt;/p&gt;&#xA;" OwnerUserId="16785" LastEditorUserId="10794" LastEditDate="2016-01-28T05:17:10.217" LastActivityDate="2016-01-28T22:52:20.240" Title="How can Arduino know that the number in a variable is a pin number and not something else?" Tags="|programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20026" PostTypeId="1" AcceptedAnswerId="20028" CreationDate="2016-01-27T20:13:31.950" Score="2" ViewCount="2404" Body="&lt;p&gt;I am building a little car project, and I have come across an issue that has made me go mental.&#xA;I have a single motor (3V-5V), that on direct 3.3V &amp;amp; 5V output works fine. However, when I connect this to a digital port, it for some reason doesn't power. Of course, I first thought it was not supplying correct power, so I got myself a voltage meter and tried that. 3.3V outputs, well 3.3V, all fine. The digital port outputs 4-5V (when it is coded to). So here is my question: Why aren't my motors powering/turning? &lt;/p&gt;&#xA;" OwnerUserId="16786" LastActivityDate="2016-01-27T20:22:51.847" Title="Powering Motor doesnt work from Digital Pin, but works on 5V power" Tags="|power|motor|digital|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20027" PostTypeId="2" ParentId="20025" CreationDate="2016-01-27T20:17:59.483" Score="3" Body="&lt;p&gt;Yes, a variable is just somewhere to store some data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's what you &lt;em&gt;do&lt;/em&gt; with the variable that is important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledpin = 13;&#xA;pinMode(ledpin, OUTPUT);&#xA;digitalWrite(ledpin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will set the variable &lt;code&gt;ledpin&lt;/code&gt; to 13, then the next line will query the &lt;code&gt;ledpin&lt;/code&gt; variable to find out what number it is, then pass that number to the &lt;code&gt;pinMode&lt;/code&gt; function to set the mode of the pin to &lt;code&gt;OUTPUT&lt;/code&gt;. The line after then does the same thing but passes the number 13 that it read from &lt;code&gt;ledpin&lt;/code&gt; to the &lt;code&gt;digitalWrite&lt;/code&gt; function to turn the LED on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledpin = 13;&#xA;pinMode(ledpin, OUTPUT);&#xA;ledpin = 10&#xA;digitalWrite(ledpin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then it will act just the same at first, but the &lt;code&gt;digitalWrite&lt;/code&gt; function will get the number 10 not the number 13 since the value in &lt;code&gt;ledpin&lt;/code&gt; has been changed to 10 in the third line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember: an integer is just a number - it's only when you do something with that number that it has any meaning.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-27T20:17:59.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20028" PostTypeId="2" ParentId="20026" CreationDate="2016-01-27T20:22:51.847" Score="3" Body="&lt;p&gt;Power is made up of two values, not one. Besides the voltage there is the current (P=VI), and it's the current you are lacking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A motor needs a large amount of current to start turning (called the &lt;em&gt;stall current&lt;/em&gt;) and a digital I/O pin can only supply a relatively small amount (absolute maximum 40mA, recommended maximum 25mA). The power pins though can supply many hundreds of mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should never try and power a motor directly from an I/O pin since you risk damaging the I/O pin.  Instead you should use the I/O pin to control an NPN transistor or N-channel FET, which is then used to switch the power (actually the ground connection) to the motor from one of the power pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a good tutorial: &lt;a href=&quot;http://www.circuitstoday.com/pwm-generation-and-control-using-arduino&quot; rel=&quot;nofollow&quot;&gt;http://www.circuitstoday.com/pwm-generation-and-control-using-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-27T20:22:51.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20029" PostTypeId="2" ParentId="20025" CreationDate="2016-01-27T20:23:11.523" Score="3" Body="&lt;p&gt;You need to put the correct number into the pinMode() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put the number into a variable like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;pinMode(ledPin, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or you can put a number straight into pinMode() like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(13, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whatever number you put in will be the pin that you start using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example to blink the onboard LED:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;                 // LED connected to digital pin 13&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledPin, OUTPUT);      // Whatever number is in ledPin is made an output.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(ledPin, HIGH);   // sets the LED on&#xA;  delay(1000);                  // waits for a second&#xA;  digitalWrite(ledPin, LOW);    // sets the LED off&#xA;  delay(1000);                  // waits for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="4143" LastEditDate="2016-01-27T20:24:16.177" LastActivityDate="2016-01-27T20:24:16.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20032" PostTypeId="2" ParentId="13826" CreationDate="2016-01-27T20:57:50.760" Score="0" Body="&lt;p&gt;The simplest solution to this is to just unplug the Bluetooth module from the TX and RX ports and click to upload. Your sketch will be uploaded and you can plug the pins back.&#xA;For a permanent solution use the digital pins aside 1 and 0 because they are the same pins your computer uses to upload your sketch to the Arduino board.&lt;/p&gt;&#xA;" OwnerUserId="16790" LastActivityDate="2016-01-27T20:57:50.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20033" PostTypeId="1" CreationDate="2016-01-27T21:08:40.070" Score="1" ViewCount="1278" Body="&lt;p&gt;vI have this functions in my loop() and it publishes temperature reading to Ubidots(an IoT cloud service) using the #include  library but it seems it returns a boolean and so the loop is delayed until a true or false value is return and this takes a while there by slowing  down my loop() function and other functions in it.&#xA;Is there a way I can call this function without it having to slow the loop?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;Ubidots.h&amp;gt;&#xA;#include &quot;rgb_lcd.h&quot;&#xA;#include &quot;Timer.h&quot;&#xA;//#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;//SoftwareSerial mySerial(11, 10); // RX, TX&#xA;&#xA;&#xA;char ssid[] = &quot;ROSTALECOM_6916&quot;;                                                 //your network SSID (name) &#xA;char pass[] = &quot;6PTDFYJD&quot;;                                                         //your network password (use for WPA, or use as key for WEP)&#xA;String api = &quot;875c4a17d995ce4977bdfc1ace55233fd0591c7ce&quot;;                             //your API Key number&#xA;String idvari = &quot;567d623a762542205cbc517f&quot;;                                          //the number of the Ubidots variable&#xA;String ctext = &quot;{\&quot;color\&quot;:\&quot;blue\&quot;,\&quot;status\&quot;:\&quot;active\&quot;}&quot;;&#xA;Ubidots ubiclient(api);                                                             //with that you call the api with the prefix ubiclient&#xA;&#xA;byte p5[8] = {&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F,&#xA;  0x1F&#xA;  };&#xA;&#xA;int a;&#xA;int temperature;&#xA;int B=3975;                  //B value of the thermistor&#xA;float resistance;&#xA;&#xA;String readString;&#xA;int val;&#xA;int hum = 70.35;&#xA;unsigned char base = 10;&#xA;&#xA;//Temperature Limits&#xA;int maxTemp = 29;&#xA;int minTemp = 28.5;&#xA;&#xA;//Declarations&#xA;rgb_lcd lcd;&#xA;Servo winServo;&#xA;&#xA;//Ubidots timer&#xA;Timer t;&#xA;&#xA;void setup() &#xA;{    &#xA;    //Loading character&#xA;    lcd.createChar(0, p5);&#xA;&#xA;Serial1.begin(9600);&#xA;Serial.begin(9600); &#xA;winServo.attach(3);&#xA;lcd.begin(16, 2);&#xA;//mySerial.begin(9600);&#xA;&#xA;&#xA;//Start Screen&#xA;lcd.print(&quot;--SmartGarden--&quot;);&#xA;for (int i = 0; i &amp;lt; 16; i++) &#xA;{&#xA;        // scroll one position left:&#xA;        lcd.setCursor(i, 1);&#xA;        lcd.write((uint8_t)0);&#xA;        delay(400);&#xA; }&#xA;lcd.clear();&#xA;lcd.print(&quot;Connecting...&quot;);&#xA;//connect to  wifi network&#xA;boolean response;                                                                &#xA;int status = WL_IDLE_STATUS;                                                                                                          &#xA;response = ubiclient.WifiCon(ssid, pass, status, api);                            &#xA;Serial.println(response);&#xA;&#xA;//&#xA;t.every(1000, sendToUbi);&#xA;&#xA;}&#xA;&#xA;&#xA;void readTemp()&#xA;{&#xA;   a=analogRead(0);&#xA;   resistance=(float)(1023-a)*10000/a;  &#xA;   temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;&#xA;&#xA;   //Send temperature via Bluetooth&#xA;   Serial.print(temperature);&#xA;&#xA;   //print temperature to LCD&#xA;   lcd.clear();&#xA;   lcd.setCursor(0,0);&#xA;   lcd.print(&quot;Tmp:&quot;);&#xA;   lcd.print(temperature);&#xA;   //print humidity to LCD&#xA;   lcd.setCursor(8,0);&#xA;   lcd.print(&quot;Hm:&quot;);&#xA;   lcd.print(&quot;50&quot;);&#xA;&#xA;   delay(1000);&#xA;&#xA;}&#xA;void writeServo()&#xA; {&#xA;  if (val != 0)&#xA;  {  &#xA;  //val = map(val, 0, 1023, 0, 180);     &#xA;  winServo.write(val);                  &#xA;  delay(100);    &#xA;  } &#xA; } &#xA;&#xA; void sendToUbi()&#xA; {&#xA; ubiclient.save_value(idvari, String(temperature));                                                  //this function is to post to ubidots and return True or False depending on the connection status&#xA; Serial.println(&quot;The sensor value &quot; + String(temperature) + &quot; was sent to Ubidots&quot;);                //print the sensor value     &#xA; }                    &#xA;&#xA;void timerMax()&#xA;{&#xA;  for (int i = 0; i &amp;lt; 60; i++) &#xA;  {&#xA;&#xA;   }&#xA;   winServo.write(180);&#xA; }&#xA;&#xA;void loop() &#xA;{&#xA;  //read temperature&#xA;  readTemp();&#xA;&#xA;  //Update ubidots timer&#xA;   t.update();&#xA;&#xA;  while (Serial1.available()) {&#xA;    delay(3);  &#xA;    char c = Serial1.read();&#xA;    readString += c; &#xA;  }&#xA;  if (readString.length() &amp;gt;0)&#xA;    {&#xA;      Serial.println(readString);&#xA;      delay(15);&#xA;&#xA;       val = readString.toInt();&#xA;       if (val != 0)&#xA;       {  &#xA;       //val = map(val, 0, 1023, 0, 180);     &#xA;        winServo.write(val);                  &#xA;       delay(100); &#xA;       readString = &quot;&quot;;   &#xA;       } &#xA;       //writeServo();&#xA;&#xA;&#xA;    if (readString == &quot;1&quot;)     &#xA;       {&#xA;        digitalWrite(13, HIGH);&#xA;       }&#xA;     if (readString == &quot;0&quot;)&#xA;       {&#xA;        digitalWrite(13, LOW);&#xA;       }&#xA;     readString = &quot;&quot;;&#xA;  } &#xA;&#xA;  if (temperature &amp;gt;= maxTemp)&#xA;  {&#xA;    timerMax();&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16790" LastEditorUserId="16790" LastEditDate="2016-01-27T22:09:09.983" LastActivityDate="2016-01-28T09:01:56.203" Title="How to avoid delays in the loop() function?" Tags="|arduino-uno|arduino-mega|arduino-ide|library|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20034" PostTypeId="2" ParentId="20015" CreationDate="2016-01-27T21:27:37.727" Score="0" Body="&lt;p&gt;Just go with a solid state relay: you can search on ebay for SSR-40DA (240V, 40A, from China around 4$) or, better, SSR-100DA (240V, 100A, from China around 6$). For 32A you should definitely mount it on an heatsink (they sell quite a lot of them on ebay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main advantage of that kind of SSR is that you can command them directly from the arduino. No transistors, no limiting resistors, just connect the ground and the pin and you are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a relay my arduino halted often (probably because of the 5V-12V boost, but it was necessary to drive the 12V relay). In the end I switched to an SSR and... Works like a charm. And since it is quite cheap I suggest you to use it.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-27T21:27:37.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20035" PostTypeId="1" CreationDate="2016-01-27T22:35:50.037" Score="4" ViewCount="6748" Body="&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;   /*&#xA; * --------------------------------------------------------------------------------------------------------------------&#xA; * Example sketch/program showing how to read data from a PICC to serial.&#xA; * --------------------------------------------------------------------------------------------------------------------&#xA; * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid&#xA; * &#xA; * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID&#xA; * Reader on the Arduino SPI interface.&#xA; * &#xA; * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE&#xA; * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When&#xA; * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output&#xA; * will show the ID/UID, type and any data blocks it can read. Note: you may see &quot;Timeout in communication&quot; messages&#xA; * when removing the PICC from reading distance too early.&#xA; * &#xA; * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading).&#xA; * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all&#xA; * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so&#xA; * keep the PICCs at reading distance until complete.&#xA; * &#xA; * @license Released into the public domain.&#xA; * &#xA; * Typical pin layout used:&#xA; * -----------------------------------------------------------------------------------------&#xA; *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino&#xA; *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro&#xA; * Signal      Pin          Pin           Pin       Pin        Pin              Pin&#xA; * -----------------------------------------------------------------------------------------&#xA; * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST&#xA; * SPI SS      SDA(SS)      10            53        D10        10               10&#xA; * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16&#xA; * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14&#xA; * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;#define RST_PIN         9          // Configurable, see typical pin layout above&#xA;#define SS_PIN          10       // Configurable, see typical pin layout above&#xA;&#xA;MFRC522 MFRC522(SS_PIN, RST_PIN);  // Create MFRC522 instance&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);     // Initialize serial communications with the PC&#xA;    while (!Serial);        // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;    SPI.begin();            // Init SPI bus&#xA;    MFRC522.PCD_Init();     // Init MFRC522&#xA;    MFRC522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details&#xA;    Serial.println(F(&quot;Scan PICC to see UID, type, and data blocks...&quot;));&#xA;  Serial.print(&quot;...&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    // Look for new cards&#xA;    if ( ! MFRC522.PICC_IsNewCardPresent()) {&#xA;    Serial.print(&quot;IsNewCardPresent&quot;);&#xA;        return;&#xA;    }&#xA;&#xA;    // Select one of the cards&#xA;    if ( ! MFRC522.PICC_ReadCardSerial()) {&#xA;    Serial.print(&quot;ReadCardSerial&quot;);&#xA;        return;&#xA;    }&#xA;&#xA;    // Dump debug info about the card; PICC_HaltA() is automatically called&#xA;    MFRC522.PICC_DumpToSerial(&amp;amp;(MFRC522.uid));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have recently purchased a RC522 RFID Module for my Arduino UNO. I connected everything, and started the IDE, downloaded the correct library, and ran the DumpInfo example program. The first time that I ran it, all went well, and when I swiped a card in fro, I recieved the correct data dump. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I started it up today, and reset everything, ran a new program to clear the Arduino, restarted my PC, and it still did not work. In the serial monitor it says that all is well, no error messages or anything. But, when I put a card in front of it, absolutely nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great!&lt;/p&gt;&#xA;" OwnerUserId="16792" LastEditorUserId="4131" LastEditDate="2016-01-28T16:00:52.170" LastActivityDate="2018-12-17T22:01:40.317" Title="MFRC522 Only working sometimes" Tags="|rfid|" AnswerCount="3" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="20036" PostTypeId="2" ParentId="20033" CreationDate="2016-01-27T22:37:49.520" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to avoid delays in the loop() function?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The question is why all the delays? Is there some logic missing? What are you trying to design?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using delays is often a sign of an attempt to synchronize with external events. Wait for additional input, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us walk through some of them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readTemp()&#xA;{&#xA;   ...&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is this about? The function does read an analog input BUT then there is a lot of output to Serial and LCD and last this delay. Why?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeServo()&#xA;{&#xA;  ...                &#xA; delay(100);    &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again the same pattern. Now for your question &quot;delays in the loop()&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{&#xA;   readTemp(); // hidden 1000 ms delay&#xA;&#xA;  while (Serial1.available()) {&#xA;    delay(3);  &#xA;    ... &#xA;  }&#xA;  if (readString.length() &amp;gt;0)&#xA;  {&#xA;     ...&#xA;     delay(15);&#xA;     ...&#xA;     if (val != 0)&#xA;     {  &#xA;       winServo.write(val);  // Possible hidden 100 ms delay                &#xA;       delay(100); &#xA;       ...&#xA;     } &#xA;     ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Consider using some logic instead of the delays. There seem to be a common pattern you are using. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-27T22:37:49.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20037" PostTypeId="2" ParentId="20022" CreationDate="2016-01-27T22:52:16.017" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So i recently bought an arduino along with lcd module and 2 extra atmega328p-pu ,yesterday it was working just fine then i disconnect everything and reconnect it and this happen, what could possibly go wrong ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I hope you understand how difficult it is for anyone to help with this type of question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My quick answer is &quot;follow the schematics and reconnect the wires correctly&quot; and &quot;double check all wires&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the picture it looks like you need to adjust the LCD contrast and reduce the back-light. Please see typical schematics for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another rule-of-thumb is to use wire colors in a meaningful way. For instance, black for GND, red for VCC, yellow for data, blue for control, green for clock, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-27T22:52:16.017" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20038" PostTypeId="2" ParentId="19981" CreationDate="2016-01-28T01:12:08.480" Score="0" Body="&lt;p&gt;You have run out of RAM. Consider moving string literals into flash with thr &lt;code&gt;F()&lt;/code&gt; macro.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-28T01:12:08.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20039" PostTypeId="2" ParentId="789" CreationDate="2016-01-28T02:53:55.490" Score="1" Body="&lt;p&gt;Perhaps you might want to calibrate your sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does it read when immersed in boiling water (assuming sea level) ? 102.5 Celsius?  That would give you a high-temperature calibration of -2.5C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously it's better to calibrate around the temperatures you expect to me measuring.  That means trusting (or averaging?) some measuring device and calibrating to that.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T02:53:55.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20040" PostTypeId="2" ParentId="20022" CreationDate="2016-01-28T03:03:52.267" Score="1" Body="&lt;p&gt;These 16x2 LCDs are fairly sensitive about their power requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a first step, I would check the VCC and GND wires are well connected, and closely connected on the breadboard near the LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your LCD display shows rubbish characters, check the 4 data lines are connected in the correct order.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it looks like the contrast is at minimum (or LED backlight at maximum).  It could just be the photo, but best check both of these.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-01-28T23:20:09.967" LastActivityDate="2016-01-28T23:20:09.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20041" PostTypeId="2" ParentId="14538" CreationDate="2016-01-28T03:16:02.653" Score="2" Body="&lt;p&gt;The boards in your link look funny.  Typical boards like this include the &quot;bluetooth circuit&quot; which piggy-backs onto that board, and is soldered at all those little pads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at say, the HC-05 board ~  &lt;a href=&quot;https://www.google.com.au/search?q=hc05+bluetooth+module&amp;amp;tbm=isch&quot; rel=&quot;nofollow&quot;&gt;https://www.google.com.au/search?q=hc05+bluetooth+module&amp;amp;tbm=isch&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's easy to see the part that's missing from the one in your link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these HC-05 boards, it's possible to pair two together.  They need to be configured as &quot;Master&quot; and &quot;Slave&quot; though.  Some bluetooth boards can do slave-mode only, so be careful before you purchase.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T03:16:02.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20042" PostTypeId="2" ParentId="13602" CreationDate="2016-01-28T03:31:40.133" Score="1" Body="&lt;p&gt;Is the device on the other side of the bluetooth connection running at 9600 baud too ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You say you transmit the state of the sensor - which BTW is only ever a space ' ', and never changes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that value gets written &lt;em&gt;out&lt;/em&gt; via the bluetooth connection.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then you read data &lt;em&gt;in&lt;/em&gt; from the other party to the bluetooth communications.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you expect the data written to the bluetooth output serial line to also be echoed back from the bluetooth input.  The serial transmit and receive are separate channels.  You are receiving on the bluetooth.read() whatever the device connected to it is sending, not what you write yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are sending goes only to the other side of the conversation.  The remote device would need to echo whatever it sees back for it to work how you describe.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T03:31:40.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20043" PostTypeId="2" ParentId="17028" CreationDate="2016-01-28T03:41:37.793" Score="0" Body="&lt;p&gt;Instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available()){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;please try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available() &amp;gt;= 4){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how your transmitting application is buffering the writes, the loop()'s password check may be triggering on a single byte of input each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to make the code a bit more fault-tolerant.  For example what if there's a bit of noise in the line, or the operator pushes [Enter] first before entering the code.  The input buffer will fill up a few characters, then the password will not match because it spans, say input bytes 3,4,5,6.  Maybe throw away any old input based on elapsed time, etc.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T03:41:37.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20044" PostTypeId="2" ParentId="12278" CreationDate="2016-01-28T03:47:49.080" Score="2" Body="&lt;p&gt;A simple 10k/20k voltage divider is enough to bring the 5V arduino logic-level voltage down to ~3.3 for the HC-05.  It worked for me anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default baud rate for HC-05 is 9600 baud.  So unless you've changed this with AT- commands you will run into issues.  Although I read that some boards default to 38400 - best check your documentation.  All the cheap HC-05 boards I've tested default to 9600.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-01-28T23:18:11.940" LastActivityDate="2016-01-28T23:18:11.940" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20047" PostTypeId="1" CreationDate="2016-01-28T07:03:16.770" Score="0" ViewCount="433" Body="&lt;p&gt;I am creating an electronic device that has a 4 position rotator switch and a SPST Momentary ON push button. For the knob, I plan for position 0 to be low (OFF). Position 1-3 are high (ON). But I want these positions to equate to a different signal so they each have different values. When push button is pressed, it sends a high (ON) signal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone point me into slightly setting up the circuit to accomplish this?&#xA;And how can I create a remapper program (preferably in C++) that detects the HID device and allows the end-user to remap the pushbutton signal to any QWERTY key? I want replicate this process for each input of my device.&lt;/p&gt;&#xA;" OwnerUserId="16796" LastActivityDate="2016-01-28T10:46:46.887" Title="How are HIDs (keyboard,joypad) created and mapped?" Tags="|electronics|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20048" PostTypeId="1" CreationDate="2016-01-28T07:20:26.940" Score="2" ViewCount="70" Body="&lt;p&gt;I'm just confused about the supply that I should use in driving my arduino. Is it okay to use a 3.7V with a 1000mAh to supply it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will be using a Lilypad Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your replies would be a big help to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="16544" LastEditorUserId="16544" LastEditDate="2016-01-28T07:50:08.780" LastActivityDate="2016-01-28T19:31:22.220" Title="What is the Proper Voltage to supply an enough Current to the Arduino" Tags="|arduino-mega|battery|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20049" PostTypeId="2" ParentId="20048" CreationDate="2016-01-28T08:25:20.010" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardLilyPad&quot; rel=&quot;nofollow&quot;&gt;Technical Specs&lt;/a&gt; say that 2.7-5.5V DC is ok so you should be good at 3.7V DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember though:  Power consumption = Current  x  Voltage&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So check that your power supply has enough current available. The current amount used will depend on how many pins you are using. The maximum each digital pin may use is 40mA. 1A (1000mA) will be plenty but mAh (milliampere hours) sounds like a battery specification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, a word from the wise is that some cheap power supplies can be bad (little spikes and dips). If you are having trouble with strange issues it can be a good idea to check the power is ok.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="16725" LastEditDate="2016-01-28T19:31:22.220" LastActivityDate="2016-01-28T19:31:22.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20050" PostTypeId="2" ParentId="20033" CreationDate="2016-01-28T08:46:15.460" Score="1" Body="&lt;p&gt;As short reply and a general note, there is the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Millis&quot; rel=&quot;nofollow&quot;&gt;millis() function&lt;/a&gt; that will be faster than a &lt;code&gt;delay()&lt;/code&gt;. It returns the number of milliseconds since the Arduino board began running the current program. You use maths to check if you've waited long enough. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // check to see if it's time to do something; that is, if the&#xA;  // difference between the current time and last time you blinked&#xA;  // the LED is bigger than the interval at which you want to&#xA;  // blink the LED.&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;    // save the last time you blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    // do something after the waiting interval here&#xA;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: One should also be aware of &lt;a href=&quot;http://playground.arduino.cc/Code/Interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;, but be warned they must be used correctly.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="16725" LastEditDate="2016-01-28T09:01:56.203" LastActivityDate="2016-01-28T09:01:56.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20051" PostTypeId="2" ParentId="20025" CreationDate="2016-01-28T09:44:18.350" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;BUT how can the Arduino know it's a pin number 13 from Arduino or a random number 13 that we are storing there?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino does not &quot;know&quot; the intention of a variable. The variable &quot;becomes&quot; a pin number when passed as an argument to pinMode() or digitalRead(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of a variable to &quot;name&quot; a pin is part of a programming style. There are a lot of examples sketches that try to convey programming style. One of these is to reduce the amount of ripple effects of change; reduce the number of line to change for a logical change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Continuing the LED pin number example above. The &quot;baseline&quot; code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  pinMode(13, OUTPUT);&#xA;  ...&#xA;}&#xA;void loop()&#xA;{&#xA;   digitalWrite(13, HIGH);&#xA;   ...&#xA;   digitalWrite(13, LOW);&#xA;   ...&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works just fine BUT what is the ripple effect if we change the pin &quot;13&quot;. The example uses symbols OUTPUT, HIGH and LOW which are also just numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically in C the tradition is to use the preprocessor and define a macro.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #define LED 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The preprocessor will replace LED in the source code with 13 and the compiler sees the same code as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is using a variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; int LED = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The drawback is that memory is allocated and it is possible to change the value at run-time which is often a very bad idea especially for a pin. The definition should actually be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; const int LED = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The drawback with the macro is that it is just a value. In C++ it is best to use a constant variable. This tells the compiler both what data type and value it is. A constant variable cannot be assigned (again). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next level to strength code quality and reduce ripple effects is to use lexical scope. A lexical scope such as a function body, class or namespace defines &quot;when&quot; a symbol is available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example; first global scope where definitions are available across the source code (just as for a macro): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const size_t BUF_MAX = 32;&#xA;static char buf[BUF_MAX];&#xA;&#xA;const char* read()&#xA;{&#xA;   ...&#xA;   for (int i = 0; i &amp;lt; BUF_MAX; i++) buf[i] = ...&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Local lexical scope; definitions within a function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char* read()&#xA;{&#xA;   const size_t BUF_MAX = 32;&#xA;   static char buf[BUF_MAX];&#xA;   ...&#xA;   for (int i = 0; i &amp;lt; BUF_MAX; i++) m_buf[i] = ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The symbols buffer &lt;em&gt;buf&lt;/em&gt; and the buffer size &lt;em&gt;BUF_MAX&lt;/em&gt; are only available in the function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Reader {&#xA;public:&#xA;  void read()&#xA;  {&#xA;    ...&#xA;    for (int i = 0; i &amp;lt; BUF_MAX; i++) m_buf[i] = ...&#xA;  }&#xA;protected:&#xA;  const size_t BUF_MAX = 32;&#xA;  char m_buf[BUF_MAX];&#xA;  ...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again the symbols are only available within the class and member function. Here is also another example of programming style. The prefix &lt;em&gt;m_&lt;/em&gt; is used to show that it is member data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last, the same example using a namespace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;namespace Reader {&#xA;  const size_t BUF_MAX = 32;&#xA;  char buf[BUF_MAX];&#xA;  ...&#xA;  void read() &#xA;  {&#xA;    ...&#xA;    for (int i = 0; i &amp;lt; BUF_MAX; i++) buf[i] = ...&#xA;  }&#xA;};&#xA;...&#xA;for (int i = 0; i &amp;lt; Reader::BUF_MAX; i++) Reader::buf[i] = ...;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All symbols must have the prefix Reader when used outside the namespace. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These techniques have been developed to allow writing larger programs with reuse. It is important to use them when writing a library for Arduino and especially when sharing. Ripple effects and symbol redefinition/collisions are reduced. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-28T22:52:20.240" LastActivityDate="2016-01-28T22:52:20.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20052" PostTypeId="2" ParentId="20047" CreationDate="2016-01-28T10:46:46.887" Score="1" Body="&lt;p&gt;When the Arduino sends data to the computer using the HID protocol it sends what is called a &lt;em&gt;HID Report&lt;/em&gt;. That is basically an array of numbers in a pre-defined format that correspond to what the computer is expecting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of keyboard events it sends a &lt;em&gt;HID Keyboard Report&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WM4Lg.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WM4Lg.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can send events for up to 6 keys at once along with up to 8 &lt;em&gt;meta&lt;/em&gt; keys.  How those key events are interpreted are down to the &lt;em&gt;Keyboard Mapping&lt;/em&gt; used on the computer.  This is the setting (usually in the &lt;em&gt;Language&lt;/em&gt; or &lt;em&gt;Regional&lt;/em&gt; settings of the computer) that defines the layout of your keyboard - UK, US, French &quot;AZERTY&quot;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it is possible to create custom key mappings in many operating systems it is usually a very difficult and involved task. Also the mapping takes effect for every keyboard attached to the system, including the one you type on. So changing the mapping at will is probably not a good idea since it could break your normal keyboard usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how would you go about doing what you want to do?  Well, my recommendation is not to do it on the computer, but to do it on the Arduino.  The Arduino has multiple interfaces available at once. As well as the HID interface for keyboard and mouse it also has the CDC/ACM interface for emulating serial. You can use both of these at once quite happily.  So you can use that USB serial interface to configure the way the Arduino works - including what key code to send for any particular event.  You could even write an easy-to-use GUI in Visual Basic or something that communicates with the Arduino over serial to adjust the settings.  How you do that communication (what protocol you come up with) is entirely up to you.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As for the hardware side of things - all you really need is just the switches / buttons and wire.  Just follow the on-line tutorials (there's millions of them) for connecting switches and buttons to the Arduino. Enable the internal pullups, and connect the switch between the I/O pin and ground.  For the rotary switch you will have 4 inputs and 1 output, so connect the 4 inputs to I/O pins and the 1 output to ground.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-28T10:46:46.887" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20053" PostTypeId="1" AcceptedAnswerId="20054" CreationDate="2016-01-28T11:05:47.090" Score="5" ViewCount="1920" Body="&lt;p&gt;I'm an Arduino beginner and I recently bought a cheap starter kit on eBay. One of the lessons in the starter kit is an &lt;a href=&quot;http://wiki.epalsite.com/index.php?title=Starter_Kit_for_Arduino#Lesson_6_RGB_LED_various_color_display&quot; rel=&quot;nofollow noreferrer&quot;&gt;RGB LED controlled by 3 PWM output pins&lt;/a&gt;. However, the arrangement of the connections seems a bit funny to me:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Qupku.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Qupku.jpg&quot; alt=&quot;Strange LED PWM setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To my surprise, it worked. I could see the three LEDs inside the plastic change colors. Why does this work? Do the PWM pins accept current whilst low? Is this a common arrangement? See the above link for the code provided in the lesson.&lt;/p&gt;&#xA;" OwnerUserId="16801" LastActivityDate="2016-01-28T22:26:43.737" Title="Why does an RGB LED between VCC and PWM work?" Tags="|led|pwm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20054" PostTypeId="2" ParentId="20053" CreationDate="2016-01-28T11:27:09.607" Score="6" Body="&lt;p&gt;This is a common arrangement and is known as &lt;em&gt;Common Anode&lt;/em&gt;, and the I/O pin is said to be &lt;em&gt;sinking&lt;/em&gt; current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To better understand what is happening here it's best to think of an I/O pin as a two-position switch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WJFVn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WJFVn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the I/O pin is HIGH point 1 is connected to point 2. When the I/O pin is LOW point 1 is connected to point 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when HIGH the circuit is Vcc -&gt; D1 -&gt; R1 -&gt; Vcc (or the other way around - I have done it that way because of the polarity of the LED), and no current can flow since it has nowhere that isn't at a lower potential than Vcc to flow to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when the I/O pin is LOW the circuit is now Vcc -&gt; D1 -&gt; R1 -&gt; GND and so current can flow through it all to ground.  As a result the LED now lights up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing you may have noticed now is that the operation is backwards.  Set the IO pin to LOW to turn the LED ON. That has the effect, as well, that PWM duty cycles are reversed.  &lt;code&gt;analogWrite(ledPin, 0)&lt;/code&gt; will be full brightness and &lt;code&gt;analogWrite(ledPin, 255)&lt;/code&gt; will be off.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-28T11:27:09.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20055" PostTypeId="2" ParentId="20053" CreationDate="2016-01-28T11:30:23.623" Score="1" Body="&lt;p&gt;The RGB LED is common anode. This is why it is connected to VCC and the PWM pins pulls down to light resp LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common cathode RGB LED would be connect to GND and the PWM pins would pull up to light&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-28T11:30:23.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20056" PostTypeId="1" CreationDate="2016-01-28T15:03:51.727" Score="0" ViewCount="345" Body="&lt;p&gt;So, I have bought this USB programmer with CH340G chip on it, but it seems, that I cannot program arduino mini clone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, this programmer has pinout of 5V|GND|TX|RX|3V3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected TX to TX and RX to RX (and also switched, because these programmers sometimes have marked where certain pins supposed to go, not what they represent).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also wired the DSR leg from the chip and connected it to the RESET on arduino mini clone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's still no connection between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm wondering, if I just connect the power supply and TX and RX connectors, when am I supposed to press reset for the succesfull programming?&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-01-28T15:13:52.670" Title="Arduino mini being programmed with CH340G" Tags="|programming|arduino-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20057" PostTypeId="2" ParentId="20056" CreationDate="2016-01-28T15:13:52.670" Score="1" Body="&lt;p&gt;First of all you should connect the DTR (not the DSR) pin to the reset terminal WITH a 100nF capacitor. See &lt;a href=&quot;http://playground.arduino.cc/Learning/AutoResetRetrofit&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; or &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;the arduino uno schematics&lt;/a&gt; to see how to put the capacitor (it's simply in series with the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I suggest you to start programming WITHOUT the autoreset; once you are sure that you can program it then try soldering that capacitor to program the arduino without having to hit the reset button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for when, watch the IDE status: when it stops compiling and shows the &quot;Uploading&quot; string, press the reset button on the board. You will usually have a couple of seconds to press it.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-01-28T15:13:52.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20059" PostTypeId="1" AcceptedAnswerId="20068" CreationDate="2016-01-28T16:24:11.790" Score="2" ViewCount="393" Body="&lt;p&gt;I'm programming C++ for arduino and today I have seen an example like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    byte variable = 0; // &amp;lt;&amp;lt; This variable is the question.&#xA;    //more stuff here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is the same as this?:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte variable = 0;&#xA;&#xA;void loop() {&#xA;    //stuff here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the answer is &quot;no&quot;, my question is &quot;why?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time!&lt;/p&gt;&#xA;" OwnerUserId="15855" LastActivityDate="2016-01-29T00:39:20.820" Title="What's the difference between setting a variable outside a function and setting a variable inside a function?" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20060" PostTypeId="2" ParentId="20059" CreationDate="2016-01-28T16:33:30.007" Score="4" Body="&lt;p&gt;No, it's not the same. Instructions within the loop() repeat every time the program gets to the end. If you set your variable at the start of the loop, it will automatically get reset to the default when you might not want it to be reset. The author of the example wants to reset to default every time the loop completes.&lt;/p&gt;&#xA;" OwnerUserId="16187" LastActivityDate="2016-01-28T16:33:30.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20062" PostTypeId="1" AcceptedAnswerId="20064" CreationDate="2016-01-28T16:48:35.920" Score="0" ViewCount="373" Body="&lt;p&gt;I have an Arduino UNO with Atmega 328 SMD, and I am trying to use PWM, but by setting registers, not using analogWrite(). My code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRD |= (1 &amp;lt;&amp;lt; PORTD6); //Setting pin D6 as output&#xA;OCR0A = 128; //50% duty cycle&#xA;TCCR0A |= (1 &amp;lt;&amp;lt; COM0A1)|(1 &amp;lt;&amp;lt; WGM01)|(1 &amp;lt;&amp;lt; WGM00); //setting mode and fast pwm&#xA;TCCR0B |= (1 &amp;lt;&amp;lt; CS01); //setting the prescaler to 8, which should yield PWM with frequency of 8 kHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is with the last line. No matter what I do, it results in PWM with frequency of 1 kHz. Setting different prescaler bits just yield 1 kHz PWM again. I was thinking that maybe its because I am programming this in Arduino IDE, and I kHz is Arduinos default frequency?&#xA;Or where am I making the mistake? Thanks for any answers.&lt;/p&gt;&#xA;" OwnerUserId="12154" LastEditorUserId="2881" LastEditDate="2016-01-28T17:05:11.930" LastActivityDate="2016-01-28T17:05:11.930" Title="Atmega328 PWM frequency setting not working" Tags="|pwm|c|atmega328|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20063" PostTypeId="1" CreationDate="2016-01-28T17:01:33.077" Score="3" ViewCount="247" Body="&lt;p&gt;Sorry in advance for the length of my question; I want to provide proper context. I wrote an audio visualization program in Java that (in addition to making &quot;pretty pictures&quot; based off of the amplitudes of different frequencies being sent from the computer) sends a color to an Arduino Uno based off the sound it is &quot;hearing.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know the algorithm for generating this color is functional (in addition to sending that color to the Arduino, it also changes the color of an item on the DrawingCanvas). When the color is sent to the Arduino (as 3 bytes representing red, green, and blue), though, the physical LEDs don't respond correctly (they become a random color for a few seconds then switch to another random color for a bit – the behavior is hard to describe, but certainly not desired!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been able to send colors to the Arduino using the same client program, but when the audio visualizer sends colors by the same method, this odd behavior occurs. My thought is that, because the audio visualizer sends color profiles dozens of times per second, the Arduino might be getting overloaded with data. Is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the relevant pieces of code from the client, the audio visualizer, and the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Client:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class Client extends WindowController{&#xA;  //USB is a class I wrote that extends PApplet. Unless baud rates are the issue, I don't think we need to worry about this.&#xA;  static USB port = new USB(&quot;COM3&quot;, 9600);&#xA;  byte[] code = new byte[LENGTH];&#xA;  static byte killTerm = -100;&#xA;  private AudioVisualizer vis;&#xA;&#xA;public void begin() {&#xA;  resize(1500,900);&#xA;  for (int k=0;k&amp;lt;LENGTH;k++){&#xA;    code[k]=killTerm;&#xA;  }&#xA;  vis = new AudioVisualizer(10,30,1200,300,canvas);&#xA;}&#xA;&#xA;public void onMouseClick(Location point) {&#xA;  runVis = !runVis;&#xA;  if(runVis) {&#xA;    vis.start();&#xA;    code[0]=-22;&#xA;    sendCodeUSB(code);&#xA;  } else&#xA;    vis.stop();&#xA;}&#xA;&#xA;public static void sendCodeUSB(byte[] code) {&#xA;  for (int k=0; k&amp;lt;code.length; k++) {&#xA;    port.writeProfile(code[k]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;AudioVisualizer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class AudioVisualizer implements Runnable {&#xA;  Thread thread = null;&#xA;  DrawingCanvas canvas;&#xA;  byte[] code = new byte[3];&#xA;  private int xPos;&#xA;  private int yPos;&#xA;  private int width;&#xA;  private int height;&#xA;  private int scale;&#xA;  private Location topLeft;&#xA;  private Location bottomRight;&#xA;  private FilledRect background;&#xA;  private int brightness=0;&#xA;  private boolean needOff = false;&#xA;&#xA;  public AudioVisualizer(int x, int y, int w, int h, DrawingCanvas myCanvas) {&#xA;    canvas=myCanvas;&#xA;    xPos=x;&#xA;    yPos=y;&#xA;    topLeft = new Location (xPos,yPos);&#xA;    bottomRight = new Location (xPos+width, yPos+height);&#xA;    width=w;&#xA;    height=h;&#xA;    background = new FilledRect(topLeft,width,height,canvas);&#xA;    background.setColor(Color.BLACK);&#xA;    initiateMonitor();&#xA;    scale = height/30;&#xA;  }&#xA;&#xA;  public void start() {&#xA;    if (thread == null) {&#xA;      thread = new Thread(this);&#xA;      thread.start();&#xA;    }&#xA;  }&#xA;&#xA;  public void stop() {&#xA;    thread=null;&#xA;  }&#xA;&#xA;  public void run() {&#xA;    while (thread != null) {&#xA;      try {&#xA;        Thread.sleep(40);&#xA;      } catch (InterruptedException e) {&#xA;      }&#xA;      graphAmps();&#xA;    }&#xA;    thread = null;&#xA;  }&#xA;&#xA;  public void graphAmps() {&#xA;    //there is a whole bunch of stuff here that is unrelated that I removed.&#xA;    //basically, just know that graphAmps() calls avgColors()&#xA;    avgColors();&#xA;  }&#xA;&#xA;  public void avgColors(){&#xA;    //there is stuff here that generates avgRed,avgGreen,and avgBlue (known to be working)&#xA;    Color c = new Color (avgRed,avgGreen,avgBlue);&#xA;    background.setColor(c);&#xA;    //so we don't spam the Arduino more than we need to&#xA;    if(avgRed&amp;gt;10 || avgGreen&amp;gt;10 || avgBlue&amp;gt;10) {&#xA;      sendArduinoColor(c);&#xA;      needOff = true;&#xA;    } else if (!(avgRed&amp;gt;10 || avgGreen&amp;gt;10 || avgBlue&amp;gt;10) &amp;amp;&amp;amp; needOff) {&#xA;      sendArduinoColor(c);&#xA;    }&#xA;  }&#xA;&#xA;  public void sendArduinoColor(Color c) {&#xA;    //takes the color and sets code = an array of 3 bytes with values from 0-100 (100 is the highest brightness I ever want the LEDs to be)&#xA;    //I am sure this is done correctly so I've left it out.&#xA;    constrainArduinoColor(c);&#xA;    //calls the static method from the client and passes in the byte array with the rgb values&#xA;    Client.sendCodeUSB(code);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;int redPin = 11;&#xA;int bluePin = 10;&#xA;int greenPin = 9;&#xA;//declared here for debugging ease of access&#xA;int r;&#xA;int g;&#xA;int b;&#xA;//are we going through the Spectrum Cycle loop for the first time?&#xA;boolean sclFirstTime = true;&#xA;//temporary initialization&#xA;boolean waiting = true;&#xA;int index = 0;&#xA;const int LENGTH = 20;&#xA;byte profile[LENGTH];&#xA;byte avProfile[3];&#xA;byte killTerm = -100;&#xA;byte audioVisualizationCode = -22;&#xA;&#xA;void setup() {&#xA;  //start the serial communication&#xA;  Serial.begin(9600);&#xA;  //initialize the profile to all -1 values&#xA;  clearProfile();&#xA;}&#xA;&#xA;void loop() {&#xA;  //if there is nothing over serial and nothing is in the EPROM, we are waiting&#xA;  if (!eepromProfileAvailable() &amp;amp;&amp;amp; Serial.available()==0){&#xA;    waiting = true;&#xA;  } else if (eepromProfileAvailable() &amp;amp;&amp;amp; Serial.available()==0) {&#xA;    //if there is something in EEPROM and nothing over Serial, we aren't waiting and load the EEPROM profile&#xA;    waiting = false;&#xA;    loadEEPROMProfile();&#xA;    //load the EPROM color profile into the array&#xA;  } else if (Serial.available()&amp;gt;0) {&#xA;    //if something enters over Serial, we aren't waiting, clear the profile, and load the new profile with the serial info&#xA;    waiting = false;&#xA;    clearProfile();&#xA;    while (Serial.available()&amp;lt;LENGTH) {}&#xA;    // Wait until there are LENGTH number of Bytes waiting&#xA;    for(int n=0; n&amp;lt;LENGTH; n++) {&#xA;      profile[n] = Serial.read(); // place them in the profile.&#xA;    }&#xA;    Serial.flush();&#xA;    //clear out the serial to prep for next time&#xA;  }&#xA;  //if we have a profile (either from EEPROM or Serial), save it, check for special codes (if found, apply the effect),&#xA;  //and if there are no special codes, the profile is a static color profile, and set LEDS to that.&#xA;  if(!waiting) {&#xA;    saveEEPROMProfile(); //omitted but working&#xA;    if (profile[0]==101) {&#xA;      while (Serial.available()==0)&#xA;        spectrumCycle(); //omitted but working&#xA;    } else if (profile[0]==-22) {&#xA;      audioVis();&#xA;    } else {&#xA;      anodeSafteyOut(redPin,profile[0]);&#xA;      anodeSafteyOut(greenPin,profile[1]);&#xA;      anodeSafteyOut(bluePin,profile[2]);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//a bunch of preset color effects omitted&#xA;//we are using a common Anode LED, so low value is 255 instead of 0&#xA;void anodeSafteyOut(int pin, int c) {&#xA;  if(c&amp;gt;=0) {&#xA;    c = 255 - c;&#xA;    //as a safety measure because there are no resistors (yes, I know im breaking an intergalactic law by not using any), make sure we aren't writing something too bright&#xA;    if (c&amp;gt;=155) {&#xA;      analogWrite(pin,c);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//wait for 3 bytes to come in, assign them to the avProfile, set the colors to that, do it again&#xA;//THIS IS PROBABLY WHERE THE PROBLEM IS&#xA;void audioVis() {&#xA;  while (Serial.available()&amp;lt;3);&#xA;  for (int k=0;k&amp;lt;3;k++)&#xA;    avProfile[k]=Serial.read();&#xA;  anodeSafteyOut(redPin,avProfile[0]);&#xA;  anodeSafteyOut(greenPin,avProfile[1]);&#xA;  anodeSafteyOut(bluePin,avProfile[2]);&#xA;  audioVis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that's a lot, and I've left a lot out that I didn't think was necessary, though I'm happy to provide the full programs if needed. Thanks for your help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is &lt;code&gt;constrainColorArduino&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void constrainArduinoColor(Color c) {&#xA;  int r = c.getRed();&#xA;  int b = c.getBlue();&#xA;  int g = c.getGreen();&#xA;  int r1 = (int)(r*0.4);&#xA;  int b1 = (int)(b*0.4);&#xA;  int g1 = (int)(g*0.4);&#xA;  byte r2=0;&#xA;  byte b2=0;&#xA;  byte g2=0;&#xA;  for (int k=0; k&amp;lt;r1; k++)&#xA;    r2++;&#xA;  for (int k=0; k&amp;lt;b1; k++)&#xA;    b2++;&#xA;  for (int k=0; k&amp;lt;g1; k++)&#xA;    g2++;&#xA;  System.out.println(r+&quot; &quot;+g+&quot; &quot;+b);&#xA;  System.out.println(r1+&quot; &quot;+g1+&quot; &quot;+b1);&#xA;  if (r2&amp;gt;100) r2=100;&#xA;  if (b2&amp;gt;100) b2=100;&#xA;  if (g2&amp;gt;100) g2=100;&#xA;  if (r2&amp;lt;0) r2=0;&#xA;  if (b2&amp;lt;0) b2=0;&#xA;  if (g2&amp;lt;0) g2=0;&#xA;  System.out.println(r2+&quot; &quot;+g2+&quot; &quot;+b2);&#xA;  code[0]=r2;&#xA;  code[1]=g2;&#xA;  code[2]=b2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16815" LastEditorUserId="4628" LastEditDate="2017-01-24T07:41:56.923" LastActivityDate="2017-08-23T14:27:37.713" Title="Problem sending colors from an audio visualizer to Arduino" Tags="|serial|rgb-led|java|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20064" PostTypeId="2" ParentId="20062" CreationDate="2016-01-28T17:02:26.780" Score="5" Body="&lt;p&gt;Your code assumes that TCCR0n are zero. But what if they are not. What if there is some hidden &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring.c#L263&quot;&gt;initialization&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer0 is used by the Arduino micro/millis counter and the prescale (TCCR0B) is initiated by setting bits CS00 and CS01 in init() before setup() is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to use Timer0 you will need to set/clear all the prescale bits. Alternatively clear the register before setting any bit. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-28T17:02:26.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20065" PostTypeId="1" AcceptedAnswerId="20072" CreationDate="2016-01-28T17:35:54.327" Score="2" ViewCount="138" Body="&lt;p&gt;I am totally new to Arduino and I'm a real beginner with electronics and robotics. I would like to know where to start, knowing that my ultimate goal is to build an autonomous robot (I know that I will not be able to do this project before learning a lot of things). I am a developer so I have no problem with C and C++, actually I am using C++ at work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16817" LastActivityDate="2016-01-28T23:49:08.053" Title="Where to start?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20067" PostTypeId="2" ParentId="20063" CreationDate="2016-01-28T18:22:55.450" Score="0" Body="&lt;p&gt;Your idea that there's a synchronization issue seems plausible.  Whenever any byte gets skipped, color assignments shift from RGB to GBR or BRG, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While sending a start code before the color profile is a possible approach to fixing the problem, it may be that occasionally one of the RGB values matches the start code, which could result in temporary desynchronization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an alternative method that doesn't require a start code, consider encoding the data into four bytes.  In the first byte, send the high two bits for RGB; in the second, the next two bits of each color; etc.  Set the low two bits of each byte to 11, 10, 01, 00 for first, second, third, fourth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, each byte you send would be encoded BBGGRRdd where the capital letters are appropriate bits from RGB brightness levels and dd indicates which pairs of bits are being sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some (untested) code that implements the decode:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;byte code = Serial.read();&#xA;byte shif = 2*(code &amp;amp; 3);&#xA;byte mask = ~(3&amp;lt;&amp;lt;shif);&#xA;code &amp;gt;&amp;gt;= 2;&#xA;for (byte i=0; i&amp;lt;3; ++i) {&#xA;  profile[i] = (profile[i] &amp;amp; mask) | ((code &amp;amp; 3)&amp;lt;&amp;lt;shif);&#xA;  code &amp;gt;&amp;gt;= 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following shows a function &lt;code&gt;sendData3()&lt;/code&gt; that encodes three bytes from an array of RGB data into four bytes to be sent to the Arduino.  It also shows a convenience function &lt;code&gt;sendDataRGB()&lt;/code&gt;.  A call like &lt;code&gt;sendDataRGB(100, 0, 42);&lt;/code&gt; puts three R, G, B values into a three-byte array and calls &lt;code&gt;sendData3()&lt;/code&gt; to send it off.  [Substitute as appropriate in place of &lt;code&gt;Serial.write&lt;/code&gt;] &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void sendData3 (byte *dataIn) { // dataIn[] has R,G,B levels&#xA;  byte code;&#xA;  byte mask=3;          // mask for low 2 bits of a byte&#xA;  for (int b=4; b; ) {&#xA;    --b;&#xA;    byte shif = 2*b;    // For moving bits to align with mask&#xA;    code = 0;&#xA;    for (int k=3; k; ) { // Loop to handle dIn[2], dIn[1], dIn[0]&#xA;      --k;&#xA;      code |= (dataIn[k]&amp;gt;&amp;gt;shif) &amp;amp; 3; // Pick off 2 color bits&#xA;      code &amp;lt;&amp;lt;= 2;            // Roll up&#xA;    }&#xA;    Serial.write (code | b);    // Send encoded bits&#xA;  }&#xA;}&#xA;&#xA;void sendDataRGB (byte R, byte G, byte B) {&#xA;  byte dataEg[] = { R, G, B };&#xA;  sendData3(dataEg);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-29T02:24:06.720" LastActivityDate="2016-01-29T02:24:06.720" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20068" PostTypeId="2" ParentId="20059" CreationDate="2016-01-28T18:25:23.723" Score="5" Body="&lt;p&gt;The difference is not only about where you set the variable, but about where you defined it as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Defined outside the function, it will have global scope and lifetime, meaning it is visible everywhere and it exists for the entire duration of the program.  If you then place an initializer inside the function, whatever value it had just before function-entry will be replaced by the initializer value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you define it inside the function (and without a &quot;static&quot; specifier) it only exists while that function is executing, and is only visible to code inside the function. Because it only comes into existence when the function is entered, you must initialize it within the function, somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you define it inside the function, but &lt;em&gt;with&lt;/em&gt; a static specifier,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static byte variable = 0; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then it will exist for the entire execution of the program but will only be visible to code within the function. In addition, an initializer on its definition (as opposed to other assignments to the variable) will only be executed once, just before the program begins executing, and &lt;em&gt;will not&lt;/em&gt; be executed within function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using local and static (as opposed to global) variables is considered good program-variable hygiene because it hides those variables (to a greater or lesser degree) from code that needn't and shouldn't be able see or alter them.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-01-29T00:39:20.820" LastActivityDate="2016-01-29T00:39:20.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20070" PostTypeId="2" ParentId="20065" CreationDate="2016-01-28T19:42:48.760" Score="1" Body="&lt;p&gt;Personally I think the best way to start is hands on with a small robot. I mean the kind that have a couple of wheels, are circular and only a few inches in diameter. You can add many kinds of sensors or actuators as you learn. You get to see it move and hold it and pick it up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to start with basic LED control and then get motors turning, sensors on, and then improvements and upgrades.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're ok at coding then electronics may be the bottle neck. Get a good book is my advice. As far has hardware the EEVBLOG guy Dave gives a good run down on what he recommends &lt;a href=&quot;https://www.youtube.com/watch?v=R_PbjbRaO2E&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just start.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-01-28T19:42:48.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20072" PostTypeId="2" ParentId="20065" CreationDate="2016-01-28T20:25:32.010" Score="4" Body="&lt;p&gt;I would start with a lot of small projects, each designed to give you confidence over one small aspect. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Detect variations in light with an LDR&lt;/li&gt;&#xA;&lt;li&gt;Operate a motor (there are various types of motors) - including controlling one with a MOSFET or BJT transistor&lt;/li&gt;&#xA;&lt;li&gt;Blink LEDs&lt;/li&gt;&#xA;&lt;li&gt;Connect something with a fancier interface (eg. I2C or SPI) and get the hang of &quot;talking&quot; to a more sophisticated interface chip (you'll probably need this for things like balancing)&lt;/li&gt;&#xA;&lt;li&gt;Try distance detection. Eg. with bouncing light or sound off an obstacle&lt;/li&gt;&#xA;&lt;li&gt;Communicate between two Arduinos - get used to communications protocols, reliability, packet loss, etc.&lt;/li&gt;&#xA;&lt;li&gt;Get used to detecting switch presses, either individual ones, or a keypad (or both)&lt;/li&gt;&#xA;&lt;li&gt;Look into reverse polarity protection&lt;/li&gt;&#xA;&lt;li&gt;Look into detecting low voltages on your batteries&lt;/li&gt;&#xA;&lt;li&gt;Try radio communications (probably need to send your robot instructions) - there are various different ways of doing that&lt;/li&gt;&#xA;&lt;li&gt;Possibly experiment with motor-driver boards (eg. H-bridges) which you may need for driving wheels&lt;/li&gt;&#xA;&lt;li&gt;Investigate reading continuous values (eg. potentiometers, rotary encoders)&lt;/li&gt;&#xA;&lt;li&gt;Investigate read-outs (eg. 7-segment LED displays, or LCD displays)&lt;/li&gt;&#xA;&lt;li&gt;Investigate generating sounds (beeps, tunes)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You could take a look at my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11506&quot; rel=&quot;nofollow noreferrer&quot;&gt;radio controlled car&lt;/a&gt; project. I look into some of those things there, and describe how I handled them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EGaij.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EGaij.jpg&quot; alt=&quot;Radio controlled car&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would do these things initially on the bench. Don't try to assemble something fancy until you have some experience with how the individual parts work.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-28T20:25:32.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20073" PostTypeId="1" CreationDate="2016-01-28T22:22:45.453" Score="0" ViewCount="219" Body="&lt;p&gt;Basically its an arduino project in which i am using an analog temperature sensor ky 013. The sensor is reading the temperatures correctly but what i want is to print the temperatures showed on the serial monitor to a lcd screen. I did the wiring and everything correctly  but there is something wrong with the code which i couldnt figure out. &#xA;Here is the code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 2);&#xA;&#xA;const int sensorPin = A0; &#xA;int switchState=0;&#xA;&#xA;&#xA;&#xA;double Thermistor(int RawADC) &#xA;{&#xA;    double Temp;&#xA;    Temp = log(((10240000/RawADC) - 10000));&#xA;    Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );&#xA;    Temp = Temp - 273.15;           &#xA;    return Temp;&#xA;}&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(9600);&#xA;    lcd.begin(16, 2);&#xA;    pinMode(sensorPin,INPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA; switchState=digitalRead(sensorPin);&#xA; int readVal=analogRead(sensorPin);&#xA; double temp =  Thermistor(readVal);&#xA; Serial.print(&quot;Temp. : &quot;);&#xA; Serial.print(temp); &#xA; Serial.println(&quot; Celsius&quot;);&#xA; lcd.clear();&#xA; lcd.setCursor(0,0);&#xA; lcd.print(&quot;Temp: &quot;);&#xA; lcd.print(temp);&#xA; lcd.print(&quot; C&quot;);&#xA; delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16827" LastEditorUserId="10794" LastEditDate="2016-01-29T01:16:46.040" LastActivityDate="2016-01-29T01:16:46.040" Title="Arduino code not working" Tags="|c++|temperature-sensor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20074" PostTypeId="2" ParentId="20053" CreationDate="2016-01-28T22:26:43.737" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Do the PWM pins accept current whilst low?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The pins &lt;strong&gt;sink&lt;/strong&gt; current when low. And yes, that is commonly done. The pins are &lt;strong&gt;not&lt;/strong&gt; &quot;do nothing&quot; at LOW, and &quot;put 5V there&quot; at HIGH. They are specifically designed to try to source (drive high) current when HIGH and sink (drive low) current when LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To have pins (more or less) do nothing, you have to set them to INPUT mode. Then they try to neither source nor sink. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Caveat:&lt;/em&gt; if you enable the internal pull-ups they will try to weakly source current.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this a common arrangement?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is quite common, depending on whether the device you are controlling is active high, or active low.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-28T22:26:43.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20075" PostTypeId="2" ParentId="16465" CreationDate="2016-01-28T23:14:55.393" Score="1" Body="&lt;p&gt;First: Your buttons are not wired up properly according to the diagram.  They seem to be only connected to 5V.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino buttons can be wired both active-high and active-low.  Active-high means then when the button is pressed you get a HIGH signal, and LOW otherwise.  Obviously active-low is the opposite.  The code below assumes active-high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to go do some reading on &quot;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;button de-bouncing&lt;/a&gt;&quot;.  I've included some rudimentary code to help, but it's not perfect.  A 0.1 micro-farad capacitor across the button terminals will help with this too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So ... onto the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really the game-loop that needs some work.&#xA;I'll assume your random LED-lighting code is in a function called newRandomLED(), and variables &lt;em&gt;ledLeftState&lt;/em&gt;, &lt;em&gt;hurt&lt;/em&gt;, etc. are globals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;new_pattern_time&lt;/em&gt; variable should probably also be set in newRandomLED() since they always are called together.  But I'm trying to help, not re-write ;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int debounce_time  =  30; // milliseconds&#xA;const int max_push_time  = 400; // milliseconds - How long is a turn&#xA;&#xA;// Draw the first LED pattern&#xA;newRandomLED();&#xA;&#xA;// the time the latest LED pattern was re-drawn&#xA;unsigned long new_pattern_time = millis();  &#xA;&#xA;// Reset the score&#xA;hurt = 0;&#xA;&#xA;while (true) // TODO: insert some game-length decision &#xA;{&#xA;    // Has the time to press a button expired?&#xA;    if (millis() - new_pattern_time &amp;gt; max_push_time)&#xA;    {&#xA;        // TODO: sound the buzzer for *fail*&#xA;&#xA;        // Time is up, penalise the user&#xA;        hurt += 10;&#xA;&#xA;        // Time for a new pattern&#xA;        newRandomLED();&#xA;        new_pattern_time = millis();&#xA;    }&#xA;&#xA;    // Perform the initial-read of the buttons&#xA;    int butt_left  = digitalRead(BUTTON_LEFT);&#xA;    int butt_mid   = digitalRead(BUTTON_MIDDLE);&#xA;    int butt_right = digitalRead(BUTTON_RIGHT);&#xA;&#xA;    // de-bounce the button presses&#xA;    delay(debounce_time); &#xA;    if (butt_left == HIGH)&#xA;        butt_left = digitalRead(BUTTON_LEFT);&#xA;    if (butt_mid  == HIGH)&#xA;        butt_mid = digitalRead(BUTTON_MIDDLE);&#xA;    if (butt_right == HIGH)&#xA;        butt_right = digitalRead(BUTTON_RIGHT);&#xA;&#xA;    // So now we have the state of the three buttons, de-bounced too.&#xA;    // Was there any input from the user?&#xA;    if (butt_left == HIGH || butt_mid == HIGH || butt_right == HIGH)&#xA;    {&#xA;        // So one (or more) buttons have been pressed&#xA;        // Check that for each LED that is on, that the button is pressed too&#xA;        boolean success = true;&#xA;        if (ledLeftState != butt_left)&#xA;            success = false;&#xA;        if (ledMiddleState != butt_middle)&#xA;            success = false;&#xA;        if (ledRightState != butt_right)&#xA;            success = false;&#xA;&#xA;        // Was the user correct?&#xA;        if (success == true)&#xA;        {&#xA;            // TODO: sound the buzzer for *WIN*&#xA;            hurt -= 10;&#xA;&#xA;            // And we need to show the next pattern&#xA;            newRandomLED();&#xA;            new_pattern_time = millis();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So essentially you're looping around checking to see if the player pressed anything.  Most of the time, there will be no input from the user, and this loop will spin thousands of times without any input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On each loop the code checks to see if the time is up, or some buttons were pushed.  In both cases, it's time for a new pattern.  A side effect of this code is that it allows for simultaneous button pushes, so at higher difficulty levels you could illuminate more than 1 LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: this code is a quick response to the question.  It may not be 100% correct, nor have flawless C-textbook syntax.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T23:14:55.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20076" PostTypeId="2" ParentId="20073" CreationDate="2016-01-28T23:35:04.063" Score="1" Body="&lt;p&gt;Please format your code.  I know it takes longer, but the payoff is in readability and maintainability.  It's well worth the extra effort.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 2);&#xA;&#xA;const int sensorPin = A0;&#xA;int switchState = 0;&#xA;&#xA;double Thermistor(int RawADC)&#xA;{&#xA;    double Temp;&#xA;    Temp = log(((10240000 / RawADC) - 10000));&#xA;    Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp)) * Temp);&#xA;    Temp = Temp - 273.15;&#xA;    return Temp;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    lcd.begin(16, 2);&#xA;    pinMode(sensorPin, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    switchState = digitalRead(sensorPin);&#xA;    int readVal = analogRead(sensorPin);&#xA;    double temp = Thermistor(readVal);&#xA;    Serial.print(&quot;Temp. : &quot;);&#xA;    Serial.print(temp);&#xA;    Serial.println(&quot; Celsius&quot;);&#xA;    lcd.clear();&#xA;    lcd.setCursor(0, 0);&#xA;    lcd.print(&quot;Temp: &quot;);&#xA;    lcd.print(temp);&#xA;    lcd.print(&quot; C&quot;);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the problem is the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try casting it to a float from a double (and two decimal places).  Maybe you just need the decimal places.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print((float)temp, 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T23:35:04.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20077" PostTypeId="2" ParentId="13060" CreationDate="2016-01-28T23:42:10.190" Score="1" Body="&lt;p&gt;What @dda says in his answer are good points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Removing the board USB for a few seconds, then re-plugging and re-selecting the COM port in the IDE usually fixes it.  Sometimes when you un-plug and re-plug the board it changes COM ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if you have a short-circuit wired to your arduino sometimes it becomes non-responsive in this manner.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T23:42:10.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20078" PostTypeId="2" ParentId="20065" CreationDate="2016-01-28T23:49:08.053" Score="2" Body="&lt;p&gt;It's sounds silly, but just get an UNO, a breadboard, wires, 1 resistor (220 ohm) and an LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire up a LED circuit, and program the Arduino to flash the LED.&#xA;(There's a million examples of this all over the internet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without getting into any sort of heavy circuits or complex programming, you'll have a quick stress-free introduction to Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will teach you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;using a breadboard&lt;/li&gt;&#xA;&lt;li&gt;wiring digital ports on the Arduino&lt;/li&gt;&#xA;&lt;li&gt;polarity of components (LED yes, Resistor no)&lt;/li&gt;&#xA;&lt;li&gt;using the Arduino IDE&lt;/li&gt;&#xA;&lt;li&gt;uploading to the board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This is a great jumping-in point because it's reasonably fool-proof.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sure you can eventually be PID-controlling the balance of a 2-wheel robot.  But build yourself a working foundation of good knowledge first.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-28T23:49:08.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20079" PostTypeId="2" ParentId="17263" CreationDate="2016-01-29T00:10:11.373" Score="1" Body="&lt;p&gt;A simple HC-05 module will give you a wireless bluetooth connection.  They're fairly simple to setup, and you can write data to them the same as one would the Arduino serial console.  Obviously they can read data too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial bt_serial(2, 3); // RX | TX&#xA;bt_serial.begin(9600);&#xA;&#xA;[...]&#xA;&#xA;if (led_state != last_led_state)&#xA;{&#xA;    if (led_state == HIGH)&#xA;        bt_serial.print(&quot;1&quot;);&#xA;    else&#xA;        bt_serial.print(&quot;0&quot;);&#xA;    last_led_state = led_state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the &quot;server&quot; side, a simple program reading the mapped bluetooth serial port would do the job.  For example, some python code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import sys&#xA;&#xA;serial_port = serial.Serial(port='COM8:', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE)&#xA;&#xA;try:&#xA;    serial_port.open()&#xA;except:&#xA;    print(&quot;Failed to open port&quot;)&#xA;    sys.exit(2)&#xA;&#xA;while (True):&#xA;    try:&#xA;        led_state = serial_port.read()&#xA;        if (led_state != 0):&#xA;            print(&quot;LED is on&quot;)&#xA;        else:&#xA;            print(&quot;LED is off&quot;)&#xA;    except:&#xA;        pass&#xA;&#xA;serial_port.close()   # yes, it never gets here    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-29T00:10:11.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20080" PostTypeId="2" ParentId="19810" CreationDate="2016-01-29T00:20:32.313" Score="0" Body="&lt;p&gt;This is all the symptoms of not having the correct board selected in the IDE.&#xA;The fact that the LEDs are flashing during uploading means it's probably not a comms issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand you wrote that you have selected the correct board already, but please double/triple-check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work with both UNOs and Nanos, this is a classic mistake I make all the time.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-01-29T00:20:32.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20081" PostTypeId="2" ParentId="10458" CreationDate="2016-01-29T00:27:48.647" Score="3" Body="&lt;p&gt;There are no CDMA (more correctly known as CDMA2000) modules for hobby projects. There are a lot of reasons for this, which I won't get into, but suffice it to say, it is the way it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Okay, I'll bite (just a little).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I think the most important reason is CDMA is actually kind of USA-centric technology. While there are now a few other countries that have CDMA networks deployed, it pales in comparison to the number GSM networks globally.&lt;/li&gt;&#xA;&lt;li&gt;So in the cellular services world there is a service offering called machine to machine (M2M). What this is is a service to allow various machines (think parking meters, vending machines, ATMs, etc.) to have a data connection for control and status messages. These services are usually bought in bulk at rates much lower than equivalent consumer services would cost.&lt;/li&gt;&#xA;&lt;li&gt;The rest from here on out is just economies of scale. If I am making an ATM machine, would I rather be limited to a handful of countries, or be able to sell in almost all countries. The obvious choice is the latter, so these manufacturers use GSM.&lt;/li&gt;&#xA;&lt;li&gt;The reason a hobbyist can get anything cheap is because some other industry is using a lot of them. For example accelerometers used to be crazy expensive, that was until millions of cell phones started shipping with them every year, and now you can get them for pretty cheap. GSM modules are relatively cheap because there are lot of devices being made with them for the above mentioned reasons. CDMA modules are not so cheap because there are not a lot of devices using them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2016-01-29T01:57:37.853" LastActivityDate="2016-01-29T01:57:37.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20082" PostTypeId="1" CreationDate="2016-01-29T00:28:58.167" Score="0" ViewCount="1005" Body="&lt;p&gt;I am using the Adafruit Motor Shield v2.3 for Arduino Uno. I am using the analogWrite() command to power my DC motor and have set the speed to 255. Is there any way to speed up the Arduino motor even further? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16831" LastEditorUserId="16831" LastEditDate="2016-01-29T00:35:57.143" LastActivityDate="2016-01-29T01:09:44.303" Title="Speeding up Arduino DC Motors" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20083" PostTypeId="1" AcceptedAnswerId="20084" CreationDate="2016-01-29T00:29:46.783" Score="1" ViewCount="70" Body="&lt;p&gt;I am doing a circuit for capturing light intensities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the &lt;a href=&quot;http://adilmoujahid.com/posts/2015/07/practical-introduction-iot-arduino-nodejs-plotly/&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial provided by Adil Moujahid&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yet, when I plug the jumper wires on 5V the circuit stops working and when I plug on 3.3V the analog in A0 sent back only a series of zero...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I missed? I acknowledge that I tried to be the most economical on the jumper wires...&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;The sketches, program and circuit given by Adil Mouhajid&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GCBiL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GCBiL.png&quot; alt=&quot;The program&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xev9a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xev9a.png&quot; alt=&quot;The circuit provided by the site&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;My attempt&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P6igk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P6igk.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15619" LastEditorUserId="10794" LastEditDate="2016-01-30T05:28:53.473" LastActivityDate="2016-01-30T05:28:53.473" Title="Analogue input 0 staying at 0 when sensing light with Arduino and a photocell" Tags="|sensors|hardware|prototype|analog-sampling|photoresistor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20084" PostTypeId="2" ParentId="20083" CreationDate="2016-01-29T00:44:49.697" Score="6" Body="&lt;p&gt;The two strips on either side of the bread board, color red and blue (typically) are power rails, and each strip is all connected. Your circuit connections that are on that strip are shorted together and will not work. I suggest following his layout exactly to begin with, and once you've learned the basics of breadboard connections, you can start doing your own layouts.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-29T00:44:49.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20085" PostTypeId="2" ParentId="20082" CreationDate="2016-01-29T00:49:17.890" Score="1" Body="&lt;p&gt;The speed of a motor is a function of the motor itself and the voltage applied to it. There is no programmatic way of increasing the speed of a motor. You would either need to increase the voltage being applied to the motor (as long as it is within the limits of your motor and speed controller) or find a different motor to use that is faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears the Adafruit motor shield accepts between 5-12 volts, if you are not already at the maximum of 12 volts, and your motor is rated to allow it, you can increase the voltage you are applying to the shield. All that &lt;code&gt;255&lt;/code&gt; means in this case is give the motor all the power that is available, so if you are only giving the controller 5 volts, it is only going to give the motor 5 volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;del&gt;Also I might recommend instead of using &lt;code&gt;analogWrite()&lt;/code&gt; that you use the &lt;a href=&quot;https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library&quot; rel=&quot;nofollow&quot;&gt;official Adafruit library&lt;/a&gt; to control your shield as it uses its own PWM library which is more performant for motor control than the built-in Arduino one.&lt;/del&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, with v2 of the shield, it has its own PWM driver controlled over I2C. In which case &lt;code&gt;analogWrite()&lt;/code&gt; shouldn't work at all, or at least it doesn't do what you think it does. Instead use the &lt;a href=&quot;https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library&quot; rel=&quot;nofollow&quot;&gt;official Adafruit library&lt;/a&gt; and I also recommend following the &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/overview&quot; rel=&quot;nofollow&quot;&gt;official tutorial&lt;/a&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastEditorUserId="11086" LastEditDate="2016-01-29T01:09:44.303" LastActivityDate="2016-01-29T01:09:44.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20086" PostTypeId="2" ParentId="20035" CreationDate="2016-01-29T01:44:24.137" Score="1" Body="&lt;p&gt;Check your power supply. I've seen so many weird results from inconsistent/under powered circuits. It's worth a look. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does your circuit look like?&#xA;Are you powering the RFID reader from the Arduino or it's own source?&#xA;Are the grounds coupled?&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-01-29T01:44:24.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20087" PostTypeId="1" AcceptedAnswerId="20089" CreationDate="2016-01-29T01:47:52.953" Score="0" ViewCount="684" Body="&lt;p&gt;I am looking for a compact solution to convert some 220V/20amp AC to something edible by our arduinos (like 5V/2amp DC). I would like to plug directly my arduino to the wall. I found many things like some Hi-link (&lt;a href=&quot;http://www.aliexpress.com/item/Free-Shipping-1pcs-lot-HLK-PM01-AC-DC-220V-to-5V-mini-power-supply-module-intelligent/32408565688.html&quot; rel=&quot;nofollow&quot;&gt;HLK-PM01&lt;/a&gt;) chips ... But I also found this one :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.aliexpress.com/item/PN8359-precision-CCCV-PSR-AC-DC-converter-PN8359-DIP-8-One-from-the-sale/32592989301.html&quot; rel=&quot;nofollow&quot;&gt;LNK564DN - US $0.34 / piece&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.aliexpress.com/item/LNK564DN-AC-DC-converter-switch-off-SMD-package/32518518757.html&quot; rel=&quot;nofollow&quot;&gt;LNK564DN - US $1.14 / piece&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That seems perfect, but unfortunatly, I can not find any tuto or example of use for this, shipping included, really cheap chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet &lt;a href=&quot;http://www.mouser.com/ds/2/328/lnk562-564-6129.pdf&quot; rel=&quot;nofollow&quot;&gt;is here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you think about it ?&lt;/p&gt;&#xA;" OwnerUserId="15886" LastEditorUserId="15886" LastEditDate="2016-01-29T04:40:50.533" LastActivityDate="2016-01-29T04:40:50.533" Title="Will this AC-DC converter chip really work with arduino?" Tags="|power|current|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20089" PostTypeId="2" ParentId="20087" CreationDate="2016-01-29T02:18:22.253" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What do you think about it ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you have to ask, don't do it. Mains voltage can be &lt;strong&gt;dangerous&lt;/strong&gt; and should only be done if you know what you are doing and how to be safe. The best choice is to just use pre-built adapters from reputable sources.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-29T02:18:22.253" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20090" PostTypeId="1" AcceptedAnswerId="20097" CreationDate="2016-01-29T03:15:02.007" Score="1" ViewCount="159" Body="&lt;p&gt;quick description of the sketch: its a clap on/off relay that turns on only when it's dark.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cannot seem to get the relays to stay off. What happens is they are off by default then when I do the double clap to turn them on that works, after this I double clap to turn them off and then go off then immediately go on again. I can get a single relay to work perfectly but when I uncomment the rest there seems to be a problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming it has something to do with the delay for the clap sensor, but I am not entirely sure-- I have tried quite a few things to try to resolve it but am really lost as to why this might be happening. ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int soundSensor = A2;&#xA;int relay = A0;&#xA;int relay2 = A3;&#xA;int relay3 = A4;&#xA;int relay4 = A5;&#xA;int claps = 0;&#xA;long detectionSpanInitial = 0;&#xA;long detectionSpan = 0;&#xA;boolean clapState = false;&#xA;int doubleClap = 0;&#xA;&#xA;&#xA;//Light sensor &#xA;int photocellPin = A1;     &#xA;int photocellReading;     &#xA;int LEDbrightness;       &#xA;&#xA;//int delayValue = 100;&#xA;int photoSensor = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(soundSensor, INPUT);&#xA;  pinMode(relay, OUTPUT);&#xA;  pinMode(relay2, OUTPUT);&#xA;  pinMode(relay3, OUTPUT);&#xA;  pinMode(relay4, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  /////////////&#xA;  // photo sensor&#xA;  //////////////////// &#xA;  photocellReading = analogRead(photocellPin);  &#xA;  photocellReading = 1023 - photocellReading;&#xA;  LEDbrightness = map(photocellReading, 0, 1023, 0, 255);&#xA;&#xA;  if(photocellReading &amp;gt; 500){&#xA;      photoSensor = 0;&#xA;  }&#xA;  if(photocellReading &amp;lt; 500){&#xA;    photoSensor = 1;&#xA;  }&#xA;&#xA;  /////////////&#xA;  // clap sensor&#xA;  /////////////////////&#xA;  int sensorState = digitalRead(soundSensor);&#xA;  //erial.println(sensorState);&#xA;  if (sensorState == 1)&#xA;  {&#xA;    if (claps == 0)&#xA;    {&#xA;      detectionSpanInitial = detectionSpan = millis();&#xA;      claps++;&#xA;    }&#xA;    else if (claps &amp;gt; 0 &amp;amp;&amp;amp; millis()-detectionSpan &amp;gt;= 50)&#xA;    {&#xA;      detectionSpan = millis();&#xA;      claps++;&#xA;    }&#xA;  }&#xA;&#xA;  if (millis()-detectionSpanInitial &amp;gt;= 500)&#xA;  {&#xA;    if (claps == 2)&#xA;    {&#xA;      if (doubleClap == 0)&#xA;        {&#xA;          doubleClap = 1;&#xA;        }&#xA;        else if (doubleClap == 1)&#xA;        {&#xA;          doubleClap = 0;&#xA;        }&#xA;    }&#xA;    claps = 0;&#xA;  }&#xA;&#xA;  if(doubleClap == 1 &amp;amp;&amp;amp; photoSensor == 0){ &#xA;    digitalWrite(relay, LOW);&#xA;    digitalWrite(relay2, LOW);&#xA;    digitalWrite(relay3, LOW);&#xA;    digitalWrite(relay4, LOW);&#xA;    Serial.println(&quot;off&quot;);&#xA;&#xA;  }&#xA;  else{ &#xA;    digitalWrite(relay, HIGH);&#xA;    digitalWrite(relay2, HIGH);&#xA;    digitalWrite(relay3, HIGH);&#xA;    digitalWrite(relay4, HIGH);&#xA;    Serial.println(&quot;on&quot;);&#xA;  };&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16832" LastEditorUserId="10794" LastEditDate="2016-01-29T05:05:53.087" LastActivityDate="2016-01-29T08:48:53.763" Title="multiple relays not triggering correctly" Tags="|c++|relay|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20096" PostTypeId="2" ParentId="20000" CreationDate="2016-01-29T07:02:12.857" Score="2" Body="&lt;p&gt;I see that this is still not working even with a proper battery. My next best guess is you need to update your library:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Adafruit Motor shield library &#xA;// copyright Adafruit Industries LLC, 2009&#xA;// this code is public domain, enjoy!&#xA;&#xA;#include &amp;lt;AFMotor.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Judging by &lt;code&gt;2009&lt;/code&gt; and &lt;code&gt;AFMotor.h&lt;/code&gt; you have a copy of an old version of the library. I recommend getting the &lt;a href=&quot;https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library&quot; rel=&quot;nofollow&quot;&gt;latest version&lt;/a&gt; and following the &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-dc-motors&quot; rel=&quot;nofollow&quot;&gt;official tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-01-29T07:02:12.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20097" PostTypeId="2" ParentId="20090" CreationDate="2016-01-29T08:40:37.743" Score="1" Body="&lt;p&gt;As it happens, you are debugging in the dark.  You have half a dozen devices attached to (presumably) some Arduino, driven by some hard-to-read code that might not work properly even if all the devices work ok, and definitely won't work properly if any of them fail or are incorrectly attached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can't tell from that code whether your photoSensor works, whether your clap sensor works, or whether your relays work.  Before messing around further trying to test all at once, run some definitive tests on each device individually.  For example, run the following sketch and see if your system is able to turn on all of the relays at the same time.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Test if relays work ok: First individually for a second each,&#xA;// then all together for 2.5 seconds&#xA;enum {relay=A0, relay2=A3, relay3=A4, relay4=A5, nRelays=4};&#xA;byte rePins[] = { relay, relay2, relay3, relay4};&#xA;&#xA;void setup() {&#xA;  for (int r=0; r&amp;lt;nRelays; ++r) {&#xA;    pinMode(rePins[r], OUTPUT);    // Set pin to outputs&#xA;    digitalWrite(rePins[r], LOW);  // Turn off relay&#xA;  }&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte r;&#xA;  // Turn relays on individually for a second each, with half-second gaps&#xA;  for (r=0; r&amp;lt;nRelays; ++r) {&#xA;    delay(500);         // Wait half a second&#xA;    Serial.print(&quot;Turning on relay #&quot;);&#xA;    Serial.print(r+1);&#xA;    Serial.print(&quot; at &quot;);&#xA;    Serial.println(millis());&#xA;    digitalWrite(rePins[r], HIGH); // Turn on relay&#xA;    delay(1000);           // One on for a second&#xA;    digitalWrite(rePins[r], LOW);  // Turn off relay&#xA;  }&#xA;&#xA;  // Turn all the relays on&#xA;  Serial.print(&quot;Turning all relays on at &quot;);&#xA;  Serial.println(millis());&#xA;  for (r=0; r&amp;lt;nRelays; ++r)&#xA;    digitalWrite(rePins[r], HIGH); // Turn on relay&#xA;&#xA;  delay(2500);          // Wait 2.5 seconds&#xA;&#xA;  // Turn all the relays off&#xA;  Serial.print(&quot;Turning all relays off at &quot;);&#xA;  Serial.println(millis());&#xA;  for (r=0; r&amp;lt;nRelays; ++r)&#xA;    digitalWrite(rePins[r], LOW); // Turn off relay&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, write a sketch to report results from photosensor and clap sensor readings.  Once you know if your hardware is working, try to get your double-clap logic to work without involving the photosensor, or vice versa.  Also, try to make the double-clap logic work just using a button in place of the clap sensor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, to shorten your code and to get rid of some of the features that make it hard to read, do some of the following changes.  With the code slightly shorter, it may be easier to comprehend and debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(a) Instead of introducing program constants as integer variables, introduce them as program constants.  For example, instead of the verbose&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int relay = A0;&#xA;int relay2 = A3;&#xA;int relay3 = A4;&#xA;int relay4 = A5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;say something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum {relay=A0, relay2=A3, relay3=A4, relay4=A5};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which tells the compiler that &lt;code&gt;relay&lt;/code&gt; is a constant with the value &lt;code&gt;A0&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(b) Since you don't use variable &lt;code&gt;LEDbrightness&lt;/code&gt; for anything, take it out.  With that gone, change the verbose&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;photocellReading = analogRead(photocellPin);  &#xA;photocellReading = 1023 - photocellReading;&#xA;LEDbrightness = map(photocellReading, 0, 1023, 0, 255);&#xA;&#xA;if(photocellReading &amp;gt; 500){&#xA;    photoSensor = 0;&#xA;}&#xA;if(photocellReading &amp;lt; 500){&#xA;  photoSensor = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;photoSensor = analogRead(photocellPin) &amp;gt; 523;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will set &lt;code&gt;photoSensor&lt;/code&gt; to 0 or 1 much as before.  (It is slightly different: It handles a &lt;code&gt;photocellReading==500&lt;/code&gt; case that your code ignores.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(c) Change the verbose and badly formatted &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (doubleClap == 0)&#xA;    {&#xA;      doubleClap = 1;&#xA;    }&#xA;    else if (doubleClap == 1)&#xA;    {&#xA;      doubleClap = 0;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; doubleClap = 1 - doubleClap;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(d) Refactor to cut about half the code involving &lt;code&gt;detectionSpan&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-01-29T08:48:53.763" LastActivityDate="2016-01-29T08:48:53.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20098" PostTypeId="1" CreationDate="2016-01-29T09:10:36.033" Score="1" ViewCount="78" Body="&lt;p&gt;Hello fellow Arduino enthusiasts,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created an Arduino project for a Mega2560 board in Microsoft Visual Studio.&#xA;Before loading the code on the board I want to test it on my Windows desktop computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to automatically provide input (e.g. with a file containing some values) for the 4 hardware Serials as well as the I2C/Wire bus and check their output for validity.&#xA;How can one achieve that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about mocking (e.g. &quot;Arduino-mock&quot;) but this does not seem to be what I need since it is more a way of ignoring the absence of object implementations.&#xA;Are there maybe some simulators that can automatically generate input and create output logs or even check the output?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for any advice!&lt;/p&gt;&#xA;" OwnerUserId="16839" LastActivityDate="2016-01-29T09:10:36.033" Title="How to test Arduino behaviour on Windows?" Tags="|hardware|emulation|testing|windows|" AnswerCount="0" CommentCount="2" ClosedDate="2016-01-29T20:19:34.817" ContentLicense="CC BY-SA 3.0" />
  <row Id="20099" PostTypeId="2" ParentId="19808" CreationDate="2016-01-29T11:31:55.817" Score="3" Body="&lt;p&gt;I got in contact with the manufacturer of the shield, they informed that the background LEDs are hardwired and not controllable via the ILI9341. So, it is not possible to dim the background light in this shield&lt;/p&gt;&#xA;&#xA;&lt;p&gt;:-(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will look for another TFT shield and make sure it's dimmable before buying.&lt;/p&gt;&#xA;" OwnerUserId="16218" LastEditorUserId="4628" LastEditDate="2018-02-21T04:57:55.633" LastActivityDate="2018-02-21T04:57:55.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20100" PostTypeId="1" CreationDate="2016-01-29T12:23:23.873" Score="0" ViewCount="317" Body="&lt;p&gt;there is AVR AVR ATmega32 and a board within. &#xA;there is outputs for all ports (A, B, C, D) on board, and Vcc. &#xA;the problem is - I have no external GND output.&#xA;to watch current - I should search for GND pin everytime. &#xA;and now I need ground on my solderless board for LEDs and temperature sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;let's guess that I have no idea what is current or electricity.&#xA;so the question is: where I can find ground to connect it to solderless board?&#xA;maybe I can use something else, except MCU? (like my hand or smth :D)&#xA;&lt;img src=&quot;https://pp.vk.me/c627928/v627928177/35713/n4HlnXV5PTo.jpg&quot; alt=&quot;board photo&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="16842" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.517" LastActivityDate="2019-02-27T15:03:52.487" Title="where I can find ground?" Tags="|avr|electronics|" AnswerCount="2" CommentCount="6" ClosedDate="2016-01-31T14:25:41.243" ContentLicense="CC BY-SA 3.0" />
  <row Id="20102" PostTypeId="1" AcceptedAnswerId="20111" CreationDate="2016-01-29T14:53:27.500" Score="1" ViewCount="822" Body="&lt;p&gt;I wanted to my GSM to recieve SMSs. I have written a sketch for it. But while verifying the sketch an error pops out in this part:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;if (sms.available()) {&#xA;      sms.remoteNumber(senderNnumber, 20);&#xA;      if (senderNumber == &quot;09432167015&quot;) {&#xA;        c = sms.read();&#xA;      if (c == &quot;yes&quot;) {&#xA;          alarm_police();&#xA;          }&#xA;        }&#xA;      }   &lt;/code&gt;&#xA;&lt;br&gt;&lt;br&gt;The error message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino: 1.6.5 (Windows 8.1), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;GuardDog_v2.5.ino: In function 'void loop()':&#xA;  GuardDog_v2.5:201: error: 'senderNnumber' was not declared in this scope&#xA;  GuardDog_v2.5:204: error: ISO C++ forbids comparison between pointer and &gt;integer [-fpermissive]&#xA;  'senderNnumber' was not declared in this scope&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This report would have more information with&#xA;   &quot;Show verbose output during compilation&quot;&#xA;   enabled in File &gt; Preferences.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&lt;Br&gt;I have checked the receiving sms example and have written the sketch according to the example.I need help regarding this error and how to fix it&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2016-02-02T09:45:07.900" Title="Problem while writing sketch for GSM module sim800" Tags="|gsm|sketch|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20103" PostTypeId="2" ParentId="10067" CreationDate="2016-01-29T14:54:55.420" Score="2" Body="&lt;p&gt;You should start from connecting Arduino UNO to PC. For this purpose use the following article: &lt;a href=&quot;http://privateblog.info/arduino-uno-i-kamera-ov7670-primer-ispolzovaniya/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno и камера ov7670 — пример использования&lt;/a&gt;. You can disregard the longer text in Russian on top, it discusses why choose exactly this camera.&lt;/p&gt;&#xA;&lt;p&gt;As listed in that source, the main problems you will find are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The camera input current is not 100% compatible with the Arduino current. You will need to use resistors. The linked blog includes a schematic how to connect both.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You will need to write code for connecting both. There are examples on the Internet. You can also see the code used in the link. The main gotcha here is that the camera works in YUV mode. Each pixel in that format is coded with two bytes. The first byte codes the grey gradient, the second carries the chroma information. For a simple test, it is sufficient to get a greyscale image, so discard the second byte.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The oscillograms in the linked site show the signal we are expecting, followed by the code needed to read the image information.&lt;/p&gt;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;The actual program for getting the image can be very simple. The author of the linked article wrote one. It reads from COM9, uses Java communication API and saves in bmp. You can download it &lt;a href=&quot;http://privateblog.info/files/FrameGrabber.7z&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This simple test connection has following disadvantages:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Without buffering, the picture smears&lt;/li&gt;&#xA;&lt;li&gt;There are synchronisation artefacts in the image&lt;/li&gt;&#xA;&lt;li&gt;You cannot change the focus, the subject has to be kept at the camera's focused distance.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Transferring data via Wi-Fi will be the next step. But it will be hard because Uno and Wi-Fi module are connected via UART interface and maximum speed is limited to 230.4Kbps.&lt;/p&gt;&#xA;&lt;p&gt;Here is example how to transmit image via bluetooth, &lt;a href=&quot;http://privateblog.info/peredacha-kartinki-s-ov7670-cherez-arduino-uno-na-android-telefon/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Передача картинки с OV7670 через Arduino Uno на Android телефон&lt;/a&gt;. It maybe useful to you.&lt;/p&gt;&#xA;&lt;p&gt;It assumes that you have connected the Arduino and the camera as described above, as step 1.&lt;/p&gt;&#xA;&lt;p&gt;In step 2, you have to solve the problem of speed mismatch. The HC-06 UART interface and the Arduino Uno have following speeds:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;HC-06: 1200 / 2400 / 4800 / 9600 / 19200 / 38400 / 57600 / 115200 / 230400 / 460800 / 921600 / 1382400&lt;/p&gt;&#xA;&lt;p&gt;Arduino Uno: 2400 / 4800 / 9600 / 14400 / 19200 / 28800 / 38400 / 57600 / 76800 / 115200 / 230400 / 250000 / 500000 / 1000000 / 2000000&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The maximum speed common to both is 230400, so you have to use that. You then need to reduce the internal processing speed with &lt;code&gt;wrReg(0x11, 31);&lt;/code&gt;. You still cannot send at 230400, because the picture is sent in two steps, first the even rows, then the odd ones. You have to write the Arduino application to capture the image.&lt;/p&gt;&#xA;&lt;p&gt;Finally, you can write the phone software. It only has to read the picture and show it on the page, nothing more. On a Bluetooth 2.1, the blog author measured more than 1 minute per frame, and the result was highly distorted. On Bluetooth 4.0, the picture quality was acceptable, and sending took less than 15 sec per frame.&lt;/p&gt;&#xA;" OwnerUserId="15624" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-03T16:23:05.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20104" PostTypeId="2" ParentId="20100" CreationDate="2016-01-29T16:24:59.330" Score="2" Body="&lt;p&gt;I've just sorted things out.&lt;br /&gt;&#xA;There is two interfaces - ISP and JTAG. ISP is busy with programmer everytime, but JTAG is free.&lt;br /&gt;&#xA;So, I have found pinout of JTAG interface and achieved GND.&lt;br /&gt;&#xA;There is pinout:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/l1oe6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l1oe6.jpg&quot; alt=&quot;isp-and-jtag&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://www.digital-circuitry.com/IMAGES/webpage/MyLAB/Altera/JTAG_ISP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;digital-circuitry.com&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="16842" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-02-27T15:03:52.487" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20105" PostTypeId="1" AcceptedAnswerId="20106" CreationDate="2016-01-29T17:50:00.697" Score="5" ViewCount="126" Body="&lt;p&gt;I need some expert advice. I'm using an Arduino Leonardo, which I have got working with a Nokia 3310 monochrome screen. I wrote some code to draw any graphics to the screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to know is, can I buy a chip from somewhere that will offload most of the CPU usage (for graphics from the Leonardo) that draws numbers and letters to the screen and basic graphics (different types of polygons and lines)? So I'm looking for a chip designed to do the graphical work and a data sheet reference for the chip.&lt;/p&gt;&#xA;" OwnerUserId="16846" LastEditorUserId="4628" LastEditDate="2016-01-30T14:50:50.887" LastActivityDate="2016-01-30T14:50:50.887" Title="Does a graphical driver chip exist for this project?" Tags="|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20106" PostTypeId="2" ParentId="20105" CreationDate="2016-01-29T18:41:26.317" Score="6" Body="&lt;p&gt;I have no idea if there is a chip or not, but I doubt it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But then, why do you need one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You already know how to communicate with the screen, so why not off-load those functions on to another Arduino (make your own small ATMega328P based board to do it) and then communicate with that through whatever means you like from your Leonardo?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't &lt;em&gt;need&lt;/em&gt; a dedicated chip to do what you can quite easily program an Arduino to do.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-01-29T18:41:26.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20108" PostTypeId="2" ParentId="20100" CreationDate="2016-01-29T20:15:24.230" Score="1" Body="&lt;p&gt;Pin 11 of the chip itself is GND (see below). In the photo it appears to have a decoupling capacitor between GND and VCC (pin 10). You could solder a wire onto pin 11 (on the chip socket, not the pin itself) - it might be easier on the back of the board. Also pin 31 would be an option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Wadpv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Wadpv.png&quot; alt=&quot;Atmega32 pinouts&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also the reset switch is almost certainly wired (on one side) to GND. It looks to me like most of the board is &quot;ground plane&quot; (continuous copper) so find which part of the switch is wired to that, and solder a wire to it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-29T20:15:24.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20109" PostTypeId="1" CreationDate="2016-01-29T20:45:48.657" Score="9" ViewCount="936" Body="&lt;p&gt;I will have many microcontroller-based devices which will be independent from each other, but all will run the same program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to upload a program to all of them at the same time with a wireless broadcast. Ideally the user would plug in a USB controller to his computer, and upload a program from the Arduino environment as if s/he were programming a single device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get a better idea of what I'm talking about, please take a look at &lt;a href=&quot;https://youtu.be/ISMwLCFwgK4?t=1m14s&quot; rel=&quot;nofollow&quot;&gt;this video&lt;/a&gt;. This was achieved with Atmel microcontrollers but a custom-made, non-Arduino bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a Google search for &quot;Arduino infrared programming&quot; &lt;a href=&quot;http://krazatchu.ca/2012/05/07/superduplex-an-infrared-bootloader-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;this interesting project came up&lt;/a&gt;. The main drawback is that the reset button still has to be pressed manually. Ideally I would like the devices to be in a low-power state by default, and wake up to receive a program when they sense a signal from the controller. Still, this may be a good starting point for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just wanted to get some perspectives from people who are familiar with Arduinos as to whether they think this is feasible before I jump in.&lt;/p&gt;&#xA;" OwnerUserId="16849" LastEditorUserId="9962" LastEditDate="2016-02-18T12:27:38.743" LastActivityDate="2016-02-21T20:06:40.763" Title="Programming many Arduinos simultaneously with a wireless broadcast" Tags="|programming|power|bootloader|wireless|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20110" PostTypeId="2" ParentId="18275" CreationDate="2016-01-29T22:16:31.703" Score="1" Body="&lt;p&gt;Normally (using the IDE via the serial/USB interface) the bootloader is retained, and the bootloader itself replaces the main code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do ICSP programming then the first thing the programmer has to do is erase the entire chip (including the bootloader). Now nothing is stopping you putting the bootloader back as part of the programming sequence (it would add to the programming time slightly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Chris Stratton suggests, this is basically combining the .hex file for the sketch, and the .hex file for the bootloader. I'm not sure that literally concatenating them would work because there are a couple of other &quot;record types&quot; in the .hex file which might confuse the programmer if they were encountered twice - in particular the &quot;end of file&quot; record type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However a strategy along these lines should give you a file that could be uploaded and put the bootloader back:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take the .hex file from the compiler, and copy up to, but excluding, the &quot;end of file&quot; record to a temporary file.&lt;/li&gt;&#xA;&lt;li&gt;Append the desired bootloader .hex file (including the &quot;end of file&quot; line).&lt;/li&gt;&#xA;&lt;li&gt;Program the chip with the resulting file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For larger chips (like the Atmega2560) you would need to be cautious about handling the &quot;extended segment address&quot; record because that sets the high-order byte of the address to be programmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hex file format, as documented in my &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow&quot;&gt;programmer sketch&lt;/a&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line format:&#xA;&#xA;  :nnaaaatt(data)ss&#xA;&#xA;  Where:&#xA;  :      = a colon&#xA;&#xA;  (All of below in hex format)&#xA;&#xA;  nn     = length of data part&#xA;  aaaa   = address (eg. where to write data)&#xA;  tt     = transaction type&#xA;           00 = data&#xA;           01 = end of file&#xA;           02 = extended segment address (changes high-order byte of the address)&#xA;           03 = start segment address *&#xA;           04 = linear address *&#xA;           05 = start linear address *&#xA;  (data) = variable length data&#xA;  ss     = sumcheck&#xA;&#xA;            * We don't use these&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-29T22:16:31.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20111" PostTypeId="2" ParentId="20102" CreationDate="2016-01-29T23:29:51.357" Score="2" Body="&lt;p&gt;You misspelled the variable &lt;code&gt;senderNumber&lt;/code&gt;. Correct it. Also you aren't reading the SMS properly or comparing the phone numbers properly. Your code should be like this (using the examples):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_MSG 50&#xA;&#xA;char senderNumber[20];&#xA;char sms_buf[MAX_MSG];   // a buffer for your sms, max len = 50&#xA;&#xA;if (sms.available()) {    // this part should be in loop()&#xA;  sms.remoteNumber(senderNumber, 20);&#xA;  if (strcmp(senderNumber, &quot;09432167015&quot;) == 0) { // compare numbers&#xA;    while (sms.available() == 0);   // wait for a char&#xA;    char i = 0;&#xA;    while (i &amp;lt; MAX_MSG - 1){    // till max len is reached; 1 byte for null&#xA;      c = sms.read();&#xA;      if (c == '\0')  // assuming the modem terminates sms with null&#xA;        break;&#xA;      sms_buf[i++] = c;   // write char to the buffer&#xA;      while (sms.available() == 0);   //wait for a char&#xA;    }&#xA;    sms_buf[i] = 0;   // terminate the string, just in case&#xA;    if (strstr(sms_buf, &quot;yes&quot;) != NULL)  // look for 'yes' in buffer&#xA;      alarm_police();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-02-02T09:45:07.900" LastActivityDate="2016-02-02T09:45:07.900" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20112" PostTypeId="2" ParentId="18954" CreationDate="2016-01-30T01:23:53.113" Score="3" Body="&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I had to create an interrupt timer ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Be warned that there are things you should not do in interrupts, like delays, serial printing, etc. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In the interests of answering the question though, this works:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// ATMEL ATTINY 25/45/85 / ARDUINO&#xA;// Pin 1 is /RESET&#xA;//&#xA;//                  +-\/-+&#xA;// Ain0 (D 5) PB5  1|    |8  Vcc&#xA;// Ain3 (D 3) PB3  2|    |7  PB2 (D 2) Ain1 &#xA;// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1&#xA;//            GND  4|    |5  PB0 (D 0) pwm0&#xA;//                  +----+&#xA;&#xA;ISR (TIMER1_COMPA_vect)&#xA;  {&#xA;  digitalWrite (4, ! digitalRead (4));  //toggle D4 (pin 3 on chip)&#xA;  }&#xA;&#xA;void setup() &#xA; {&#xA;  pinMode (4, OUTPUT);  // chip pin 3 &#xA;&#xA;  // Timer 1&#xA;  TCCR1 = bit (CTC1);   // Clear Timer/Counter on Compare Match&#xA;  TCCR1 |= bit (CS10) | bit (CS13);  // prescaler of 256&#xA;  OCR1C = 123;          // what to count to (zero-relative)&#xA;  TIMSK = bit (OCIE1A); // interrupt on compare&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop() &#xA;  { &#xA;  // other code here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can tweak the time delay by changing both the prescaler and the counter in OCR1C. The prescaler gives you coarse tuning, which gets you into the ballpark of the delay time. The timer then counts up to give you the final delay.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Prescaler values&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8kPDF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8kPDF.png&quot; alt=&quot;ATtiny85 timer 1 prescalers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my case I chose a prescaler of 256 which is or'ing together CS10 and CS13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The delay is then:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;125 ns * 256 * 124 = 3.968 ms&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 256 is the prescaler and 124 is what we are counting to. This is assuming an 8 MHz clock which gives a clock period of 125 ns.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Flashing more slowly&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you put an LED on pin 3 and want to &lt;strong&gt;see&lt;/strong&gt; the flashing, you need it much slower. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;TCCR1 |= bit (CS10) | bit (CS11) | bit (CS12) | bit (CS13);  // prescaler: 16384&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That toggles the pin every 254 ms, which is visible.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Warning&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;On this chip Timer 1 is an 8-bit timer, so you cannot put more than 255 into OCR1C.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;More information&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-01-30T01:36:27.673" LastActivityDate="2016-01-30T01:36:27.673" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20114" PostTypeId="2" ParentId="16236" CreationDate="2016-01-30T03:16:12.360" Score="2" Body="&lt;p&gt;A voltmeter does not have a ground reference. An Arduino plugged into the USB port would have one. Conceivably a battery-powered Arduino might work, however a safer solution would be to use an opto-isolator to isolate the voltage being tested from the Arduino. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tj7h0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tj7h0.png&quot; alt=&quot;Opto isolator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case you connect the &quot;data pin&quot; to the thing you are sensing. If it is at 5V then the LED will conduct (taking around 7 mA) and the transistor in the isolator will drive the Arduino pin &lt;code&gt;LOW&lt;/code&gt;. If the data pin goes to zero volts, the transistor will not conduct, and the 1k resistor will pull the Arduino pin &lt;code&gt;HIGH&lt;/code&gt;. Thus you can detect if the pin has changed voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 560 ohm resistor is a current-limiting resistor for the LED in the isolator. A 1k resistor would probably also work, reducing the current draw on the data pin to around 3.8 mA.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-30T03:16:12.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20115" PostTypeId="2" ParentId="10357" CreationDate="2016-01-30T03:32:03.730" Score="2" Body="&lt;p&gt;To make randomly-changing colours for the whole strip, change:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  rgbFadeInAndOut(0, 0, 255, ledFadeTime); // Blue&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  rgbFadeInAndOut(random (256), &#xA;                  random (256), &#xA;                  random (256), ledFadeTime); // random colour&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you want to make individual pixels different colours you could set up an array of colours, randomly initialize it, and use that. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;int PIN = 3;&#xA;int totalLEDs = 11;&#xA;int ledFadeTime = 5;&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(totalLEDs, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;  rgbFadeInAndOut(ledFadeTime);&#xA;}&#xA;&#xA;void rgbFadeInAndOut(uint8_t wait) {&#xA;&#xA;  uint8_t red [totalLEDs];&#xA;  uint8_t green [totalLEDs];&#xA;  uint8_t blue [totalLEDs];&#xA;&#xA;  // randomly set each colour&#xA;  for (int i = 0; i &amp;lt; totalLEDs; i++)&#xA;    {&#xA;    red [i] = random(256);&#xA;    green [i] = random(256);&#xA;    blue [i] = random(256);&#xA;    }&#xA;&#xA;  for(uint8_t b = 0; b &amp;lt;255; b++) {&#xA;     for(uint8_t i=0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, red [i] * b/255, green [i] * b/255, blue [i] * b/255);&#xA;     }&#xA;&#xA;     strip.show();&#xA;     delay(wait);&#xA;  }&#xA;&#xA;  for(uint8_t b=255; b &amp;gt; 0; b--) {&#xA;     for(uint8_t i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, red [i] * b/255, green [i] * b/255, blue [i] * b/255);&#xA;     }&#xA;     strip.show();&#xA;     delay(wait);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-30T03:32:03.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20116" PostTypeId="1" CreationDate="2016-01-30T03:42:06.433" Score="2" ViewCount="303" Body="&lt;p&gt;Friends Here is what i want to ask.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a midi keyboard that is casio cps7. Its an old model so its not a USB midi keyboard. &#xA;I use it with a cheap midi to usb cable.&#xA;I just wanted to use my arduino to act like a midi to USB adapter. So, i can use my midi keyboard with that too.&#xA;I found some tutorials that uses this arduino like usb serial device. And there is also a code for it. The code itself has a command to play midi notes.&#xA;We receive serial signals from arduino and convert them into midi (by using another software that is serial midi converter, there is also virtual midi port for it which is midi-yoke). Thats how i used my arduino board once but the program code for it (what i installed) plays its own notes. I just want to send my midi out (from my keyboard casio cps7) to pc as serial via arduino. Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you guys now understand what i wanted to say :)&lt;/p&gt;&#xA;" OwnerUserId="10984" LastEditorUserId="10984" LastEditDate="2016-02-01T01:02:57.450" LastActivityDate="2016-02-01T01:02:57.450" Title="sending midi to software using arduino" Tags="|arduino-uno|midi|" AnswerCount="0" CommentCount="3" ClosedDate="2016-01-31T14:26:43.603" ContentLicense="CC BY-SA 3.0" />
  <row Id="20117" PostTypeId="2" ParentId="9074" CreationDate="2016-01-30T03:42:17.623" Score="1" Body="&lt;p&gt;How about fastening a wire to the post, and then the other end, on the bike, goes into a &quot;jack&quot; (the sort of thing you plug headphones into). With the wire inserted, it makes a connection, and the Arduino knows the wire is there. As the thief steals the bicycle the plug (or loose wire) is pulled from the jack, breaking the connection. i.e.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2z3Oe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2z3Oe.png&quot; alt=&quot;Bicycle protection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-30T03:42:17.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20118" PostTypeId="2" ParentId="19329" CreationDate="2016-01-30T03:48:12.320" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a graphic on that page (reproduced below) which shows the general idea of what happens when you program using Tx/Rx after reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/14Whw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/14Whw.png&quot; alt=&quot;Optiboot programming&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could delve into the specs for the STK500 protocol (see linked page) and make your second Arduino follow that, to program from the SD card file.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-01-30T03:48:12.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20119" PostTypeId="2" ParentId="18888" CreationDate="2016-01-30T03:51:40.163" Score="1" Body="&lt;pre&gt;&lt;code&gt;  Wire.requestFrom(kClockAddress, 7); // request seven bytes of data&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just because you request 7 bytes doesn't necessarily mean you get them. I suggest before reading the date and time you set all those variables to something invalid (like 0xFF). Then after reading, if you get 0xFF in any of them, ignore the entire lot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;we are sending a start bit again, when we never sent a stop bit previosuly. ... Does this sound reasonable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really, because I2C doesn't have start and stop bits, it has &lt;em&gt;start condition&lt;/em&gt; and &lt;em&gt;stop condition&lt;/em&gt; which are specific changes to SDA and SCL which don't happen at any other times. See &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt; for a description. I would be checking the data for validity, as I said. There is no other way of knowing for sure that a transmission wasn't interrupted. If you request 7 bytes of data, the library tells you that you got 7, even if you did not. However if it cannot even find the target device, it returns 0 as the number of bytes (you aren't testing for that anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The very least you should do is test for a valid connection, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Wire.requestFrom(kClockAddress, 7) == 7)&#xA;  {&#xA;  // read the data&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That at least confirms that the clock chip responded in some way. Not checking error returns from function calls, where documented, is not wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly when you send your command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Wire.endTransmission();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Wire.endTransmission() != 0)&#xA;  {&#xA;  // handle error here&#xA;  return;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have no tests in your code for either the sending or receiving to be working. And then you are unconditionally using the resulting time values. That's like opening a file, and reading it, without checking if the file exists.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-01T19:45:07.880" LastActivityDate="2016-02-01T19:45:07.880" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20120" PostTypeId="2" ParentId="17851" CreationDate="2016-01-30T03:56:19.233" Score="2" Body="&lt;p&gt;As Majenko commented, you need to not only connect the data wires together but also the ground wire (from the Arduino to the Pi).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... the reading are very unstable ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Without a consistent &quot;ground reference&quot; the readings would indeed be unstable.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-30T03:56:19.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20121" PostTypeId="2" ParentId="16999" CreationDate="2016-01-30T04:11:44.207" Score="1" Body="&lt;p&gt;Converting Gerben's comment into an answer:&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;pow(x, 2) is the second power, in other words:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FxSj7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FxSj7.png&quot; alt=&quot;x squared&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;sqrt(x) is the square root of x, that is:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LrrbS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LrrbS.png&quot; alt=&quot;Square root of x&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;A whole circle is 360 degrees or 2π when measuring in radians. So this ratio of &lt;code&gt;180 / 3.141592&lt;/code&gt; is used to convert an angle in radians to an angle in degrees.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q7Zfk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q7Zfk.png&quot; alt=&quot;radians to degrees&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-01-30T04:20:50.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20125" PostTypeId="1" CreationDate="2016-01-30T07:08:53.083" Score="0" ViewCount="7205" Body="&lt;p&gt;I recently bought an HC-SR505 Mini PIR sensor. I connected its positive to my Arduino UNO's 5v, output to digital pin 2, and ground to ground. I used Adafruit's &lt;a href=&quot;https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/using-a-pir&quot; rel=&quot;nofollow&quot;&gt;code&lt;/a&gt; to test it, but all the serial monitor displayed was &quot;Motion detected&quot;, which meant the PIR was always on a HIGH state. I then also tried powering it using 3V3 but the PIR kept on cycling on a HIGH and LOW state. Any help on getting my sensor to actually work would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15984" LastActivityDate="2020-04-19T22:51:36.177" Title="HC-SR505 PIR Sensor only outputting HIGH" Tags="|arduino-uno|programming|sensors|" AnswerCount="5" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20126" PostTypeId="1" CreationDate="2016-01-30T07:40:13.517" Score="1" ViewCount="2468" Body="&lt;p&gt;I am new to these Arduino things, and I am currently using an Uno board for my projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how to control the DC motor with the help of digital pins via L293D. But I cannot use the PWM pins of Arduino, since I have already used them for controlling servos and other things, which need higher accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried using the &lt;a href=&quot;https://code.google.com/archive/p/rogue-code/wikis/SoftPWMLibraryDocumentation.wiki&quot; rel=&quot;nofollow&quot;&gt;SoftPWM library&lt;/a&gt; to control motor, but it is conflicting with other things like ultrasonic sensor. I don't know what the problem is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone suggest me a solution?&lt;/p&gt;&#xA;" OwnerUserId="16862" LastEditorUserId="6936" LastEditDate="2016-02-01T06:29:29.207" LastActivityDate="2016-03-02T07:38:16.323" Title="Arduino motor control using digital pins" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20127" PostTypeId="1" CreationDate="2016-01-30T08:16:34.383" Score="0" ViewCount="357" Body="&lt;p&gt;I am new to Arduino and I want to connect it to my 2.1 speakers and later to a 5.1 surround system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The purpose is to play some wav sounds when a button is clicked or when a trip laser is cut. What should I do in order to play those wav around through the speakers? I also have an SD shield.&lt;/p&gt;&#xA;" OwnerUserId="16864" LastEditorUserId="6936" LastEditDate="2016-02-01T07:00:50.893" LastActivityDate="2016-02-01T07:00:50.893" Title="Arduino Mega connect to 2.1 speakers" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20129" PostTypeId="2" ParentId="20127" CreationDate="2016-01-30T09:06:47.410" Score="1" Body="&lt;p&gt;First, you need to figure out the bandwidth requirements and if this is possible at all. You need to do some basic calculations and answer the question if the Arduino and the different components have the bandwidth (byte/second) that is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino MCU (AVR) is too &quot;weak&quot; to do this on it's own. A special shield is required. Such as &lt;a href=&quot;https://www.adafruit.com/products/1788&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1788&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due has more processing power but still not stereo quality; &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/SimpleAudioPlayer&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info to be googled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-30T09:06:47.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20130" PostTypeId="1" AcceptedAnswerId="20135" CreationDate="2016-01-30T10:16:01.820" Score="1" ViewCount="724" Body="&lt;p&gt;I've got an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was building a simple circuit with only one switch and it doesn't seem to work (I followed the Arduino project book from the Arduino starter kit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my circuit : &#xA;&lt;a href=&quot;https://i.stack.imgur.com/8fTTt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8fTTt.jpg&quot; alt=&quot;Photo of circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I try again to move the switch and then it works (but I don't understand why).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GFbIX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GFbIX.jpg&quot; alt=&quot;Photo of circuit with active LED&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried to understand where the error is and I try to read digital input from the simple circuit with only one LED :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0dBpT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0dBpT.jpg&quot; alt=&quot;Simple LED circuit&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is my code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int SWITCH = 13;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(SWITCH, INPUT);&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;    int val;&#xA;    val = digitalRead(SWITCH);&#xA;    if(val == HIGH) {&#xA;        Serial.println(&quot;OKAY&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I expect to see on the Serial Monitor &quot;OKAY OKAY&quot; and so on... but nothing appears on the Serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I try to change the condition : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(val == LOW)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now I see &quot;OKAY OKAY&quot; and so on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that there is something wrong with this Arduino... Can someone tell me something about what is happening? Am I stupid or there is really something wrong with this?&lt;/p&gt;&#xA;" OwnerUserId="16865" LastEditorUserId="6936" LastEditDate="2016-02-01T06:40:55.560" LastActivityDate="2016-02-01T06:40:55.560" Title="It seems my Arduino doesn't work" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20131" PostTypeId="2" ParentId="17326" CreationDate="2016-01-30T10:24:16.710" Score="2" Body="&lt;p&gt;You can use this info and code: &lt;a href=&quot;http://hykrion.com/arduino/hamming-8-4.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hamming(8,4) with Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a PDF with documentation about the process of creating a class that implements hamming(8,4) and a link to the source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use any class that derives from Stream (like Serial or SoftwareSerial).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; If you want to implement a Hamming ECC in a Arduino it would be useful to precompute all the possible message values (you'll find more info at the link above). In a Hamming(8,4) your message is 1byte = 4bits + parity 4 bits; so you must divide your bytes in nibbles. It would be better to put all that stuff (code, decode, manage the upper/lower part of the byte, etc...) in a class. An example using the Hamming class from the link above:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tx:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;hamming.h&amp;gt;&#xA;&#xA;Hamming hamming(&amp;amp;Serial);&#xA;char message[] = &quot;Hello World!!&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  delay(100);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  hamming.write(message);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rx:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;hamming.h&amp;gt;&#xA;&#xA;Hamming hamming(&amp;amp;Serial);&#xA;char message[Hamming::SIZE];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  delay(100);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(hamming.isMessageReady())&#xA;  {&#xA;    hamming.read(message);&#xA;    Serial.println(message);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to send other kind of info: a float, integer... you can do it, but I think it's a better idea to tokenize/detokenize your information and handle it like a &quot;string&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. You can use any kind of physical layer insofar as it's a child of Stream: Serial, SoftwareSerial...But I've only tested over Serial.&lt;/p&gt;&#xA;" OwnerUserId="16866" LastEditorUserId="16866" LastEditDate="2018-04-27T14:43:19.660" LastActivityDate="2018-04-27T14:43:19.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20133" PostTypeId="1" CreationDate="2016-01-30T12:49:12.283" Score="4" ViewCount="83" Body="&lt;p&gt;I've wired up a dot matrix, and I display characters on the screen by using something like the example code below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Char_B&lt;/code&gt; variable is a global variable in a library used by the Arduino, and &lt;code&gt;displayPixels()&lt;/code&gt; is called from inside the library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool Char_B[8][8] = {&#xA;{0,1,1,1,1,0,0,0},&#xA;{0,1,0,0,0,1,0,0},&#xA;{0,1,0,0,0,1,0,0},&#xA;{0,1,1,1,1,0,0,0},&#xA;{0,1,0,0,0,1,0,0},&#xA;{0,1,0,0,0,1,0,0},&#xA;{0,1,0,0,0,1,0,0},&#xA;{0,1,1,1,1,0,0,0}&#xA;};&#xA;&#xA;displayPixels(1000, Char_B);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, each time I declare a new character like the array above, I use a relatively massive amount of memory. Is there any way to reduce memory usage? Keep in mind I am willing to change the structure of the array if necessary, since I'll need well over 100 characters loaded onto the Arduino to write text.&lt;/p&gt;&#xA;" OwnerUserId="16869" LastEditorUserId="6936" LastEditDate="2016-02-01T07:15:26.960" LastActivityDate="2016-02-01T07:15:26.960" Title="Use large variables without using much memory" Tags="|c++|variables|memory-usage|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20134" PostTypeId="1" CreationDate="2016-01-30T13:07:09.557" Score="3" ViewCount="372" Body="&lt;p&gt;I would like to connect the DAC outputs of my arduino board to my pc sound card input so that I can use my sounds card as an osciloscope. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1- if I don't use an amplifier,  how can I protect the arduino from being damaged?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2- if I use an amplifier with dual rails,  do i still need to protect the arduino somehow? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that I know little about analog circuitry so a direct solution would be most appreciated. In short how would I use components to make sure I don't end up nuking my dac outputs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;" OwnerUserId="16558" LastActivityDate="2016-01-30T13:07:09.557" Title="Connecting Arduino Due's DAC output to pc sound card with protection" Tags="|arduino-due|digital-analog-conversion|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20135" PostTypeId="2" ParentId="20130" CreationDate="2016-01-30T13:24:00.437" Score="2" Body="&lt;p&gt;It looks to me like your arduino is working just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first two images you use the arduino only to provide 5v power to the circuit on the breadboard. In the first image you haven't connected your button to properly function as a button. I don't know the exact pin layout of the button (which should be explained in a datasheet of that button), but it is also good to know exactly how to holes in a breadboard are connected. This picture shows why your button works on your second image but not your first:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uhWCT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uhWCT.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This picture also shows how the breadboard holes are connected:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HtdSB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HtdSB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your third image you have practically connected input pin 13 to GND, so it makes sense that digitalRead(13) in your code always returns LOW. Thus, the variable var is always LOW (or 0). Thus, the comparison (var == HIGH) is FALSE, which won't send &quot;OKAY&quot; to the serial monitor. And, the comparison (var == LOW) is TRUE, which will* send &quot;OKAY&quot; to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you can follow the logical steps and it is clear to you what is happening.&lt;/p&gt;&#xA;" OwnerUserId="16615" LastActivityDate="2016-01-30T13:24:00.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20136" PostTypeId="2" ParentId="20133" CreationDate="2016-01-30T13:44:21.503" Score="2" Body="&lt;p&gt;Use a single byte to store a row of data. As a bool still takes a single byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optionally you could flip the axis, and store column data, instead of row data in the array. Since letters like &lt;code&gt;i&lt;/code&gt; use fewer columns that letters like &lt;code&gt;B&lt;/code&gt;. Even in your example you can see you have 3 columns with only &lt;code&gt;0&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A final suggestion would be to use &lt;code&gt;PROGMEM&lt;/code&gt; and use the &lt;code&gt;pgm_read_byte_near&lt;/code&gt; function. That way the data will remain in the flash memory, and will not take any space in the program-memory.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-30T13:44:21.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20137" PostTypeId="2" ParentId="20133" CreationDate="2016-01-30T13:50:19.550" Score="4" Body="&lt;p&gt;The data structure will take 64 bytes as sizeof bool is 1 byte not a bit. The first option is to pack each line (or column) in a byte (or bytes). The prefix 0b is for &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html&quot; rel=&quot;nofollow&quot;&gt;binary constant value&lt;/a&gt; (in gcc). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t Char_B[8] = {&#xA;0b01111000,&#xA;...&#xA;0b01111000&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second option is to move the data structure to program memory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t Char_B[8] PROGMEM = { ... };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will require reading each line with a special &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#ga73084a8bbde259ffae72980354b3f027&quot; rel=&quot;nofollow&quot;&gt;function&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int line = 0; line &amp;lt; sizeof(Char_B); line++) {&#xA;  uint8_t pixels = (uint8_t) pgm_read_byte(Char_B + line);&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-30T13:50:19.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20138" PostTypeId="2" ParentId="6712" CreationDate="2016-01-30T14:36:04.760" Score="3" Body="&lt;p&gt;Below you can find the code for a minimal bit-bang send serial implementation ideally suited for debugging. Code size is about 60 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gives 38400 baud for 1 MHz or 230400 baud on 8 MHz Attiny clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote it for an Attiny 85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ArminJo/AttinySendSerial_1Mhz_38400Bd&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArminJo/AttinySendSerial_1Mhz_38400Bd&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16872" LastEditorUserId="16872" LastEditDate="2018-03-06T12:06:14.857" LastActivityDate="2018-03-06T12:06:14.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20139" PostTypeId="1" CreationDate="2016-01-30T15:10:04.603" Score="2" ViewCount="2853" Body="&lt;p&gt;Problem in getting -5 V with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);&#xA;  delay(20);&#xA;  digitalWrite(13, LOW);&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above code is generating below digital signal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GGNoF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GGNoF.png&quot; alt=&quot;puredigi&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want this type of digital signal output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sruN8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sruN8.png&quot; alt=&quot;digiwithn&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read this for generating negative -5 V signal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/10322/what-is-negative-voltage&quot;&gt;https://electronics.stackexchange.com/questions/10322/what-is-negative-voltage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but not able to understand very well WRT Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also read this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/19435/negative-voltage-how-do-i-scale-a-0-to-5-v-signal-to-10-v-to-10-v&quot;&gt;Negative voltage: How do I scale a 0 to 5 V signal to -10 V to +10 V?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;seems to much complicated circuit diagram with TL802.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do I get above digital signal?&lt;/li&gt;&#xA;&lt;li&gt;I was wondering if we can use some 1 microF capacitor or transistor to generate negative signal? (simplest way) &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15187" LastEditorUserId="26916" LastEditDate="2017-11-04T08:22:39.517" LastActivityDate="2017-11-04T08:22:39.517" Title="Generating digital positive (+5 V) and negative (-5 V) signal?" Tags="|arduino-uno|voltage-level|electronics|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20140" PostTypeId="1" CreationDate="2016-01-30T15:22:31.897" Score="2" ViewCount="1581" Body="&lt;p&gt;I use the Arduino IDE 1.6.9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is a DMX Receiver which receives 1 channel and displays it on the serial monitor. When I try to compile the code, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Users\Helyx\AppData\Local\Temp\build25a76891c667e0896ec10beb77bd0478.tmp/core\core.a(HardwareSerial0.cpp.o): In function `__vector_25':&#xA;&#xA;D:\Programme\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial0.cpp:48: multiple definition of `__vector_25'&#xA;&#xA;sketch\DmxReceive.ino.cpp.o:C:\Users\Helyx\Documents\Arduino\DmxReceive/DmxReceive.ino:26: first defined here&#xA;&#xA;d:/programme/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions&#xA;&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&#xA;exit status 1&#xA;Fehler beim Kompilieren.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&#xA;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;#define F_CPU 16000000&#xA;&#xA;&#xA;#define DMX_BAUD 250000&#xA;#define DMX_LOST_TIMEOUT 8000&#xA;&#xA;volatile unsigned char dmx_buffer[10];&#xA;volatile unsigned int dmx_lost = DMX_LOST_TIMEOUT;&#xA;&#xA;volatile unsigned int dmx_adresse = 1;&#xA;&#xA;&#xA;&#xA;ISR (USART0_RX_vect)&#xA;&#xA;{&#xA;static unsigned int dmx_channel_rx_count = 0;&#xA;static unsigned char dmx_valid = 0;&#xA;unsigned char tmp = 0;&#xA;&#xA;tmp =  UDR0;&#xA;&#xA;if(UCSR0A&amp;amp;(1&amp;lt;&amp;lt;FE0))&#xA;{&#xA; if(dmx_channel_rx_count &amp;gt; 1)&#xA; {&#xA;   dmx_lost = 0;&#xA; }&#xA; dmx_channel_rx_count = 0;&#xA; dmx_buffer[0] = tmp;&#xA; if(dmx_buffer[0] == 0)&#xA; {&#xA;   dmx_valid = 1;&#xA;   dmx_channel_rx_count++;&#xA; }&#xA; else&#xA; {&#xA;   dmx_valid = 0;&#xA; }&#xA; return;&#xA;}&#xA;&#xA;if(dmx_valid)&#xA;{&#xA; dmx_buffer[dmx_channel_rx_count] = tmp;&#xA; if(dmx_channel_rx_count &amp;lt; 514)&#xA; {&#xA;   dmx_channel_rx_count++;&#xA; }&#xA; return;&#xA;}&#xA;}&#xA;&#xA;&#xA;&#xA;ISR (TIMER2_COMPA_vect)&#xA;&#xA;{&#xA; if(dmx_lost&amp;lt;DMX_LOST_TIMEOUT)&#xA; {&#xA;   dmx_lost++;&#xA; }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;&#xA;EICRA |= (1&amp;lt;&amp;lt;ISC11)|(1&amp;lt;&amp;lt;ISC10); //The rising edge of INT1 generates an interrupt request&#xA;EIMSK |= (1&amp;lt;&amp;lt;INT1); //External interrupt request 1 enable&#xA;&#xA;//Init usart DMX-BUS&#xA;UBRR0   = (F_CPU / (DMX_BAUD * 16L) - 1);&#xA;UCSR0B|=(1 &amp;lt;&amp;lt; RXEN0 | 1&amp;lt;&amp;lt; RXCIE0);&#xA;UCSR0C|=(1&amp;lt;&amp;lt;USBS0); //USBS0 2 Stop bits&#xA;sei();//Globale Interrupts Enable&#xA;&#xA;&#xA;TCCR2A |= (1&amp;lt;&amp;lt;WGM21);&#xA;TCCR2B |= (1&amp;lt;&amp;lt;CS22|1&amp;lt;&amp;lt;CS21|1&amp;lt;&amp;lt;CS20);&#xA;TIMSK2 |= (1&amp;lt;&amp;lt;OCIE2A);&#xA;OCR2A = F_CPU/1024/1000 - 1; //Tick 1ms&#xA;Serial.begin(57600);&#xA;&#xA;DDRC = (1&amp;lt;&amp;lt;PE3);&#xA;PORTB |= 0x3F;&#xA;PORTC |= 0xFF;&#xA;PORTC &amp;amp;=~(1&amp;lt;&amp;lt;PE3);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;if(dmx_lost==DMX_LOST_TIMEOUT)&#xA;{&#xA;  dmx_buffer[dmx_adresse] = 0;&#xA;&#xA;}&#xA;Serial.print(dmx_buffer[dmx_adresse]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16873" LastEditorUserId="6936" LastEditDate="2016-02-01T07:03:52.840" LastActivityDate="2016-02-21T04:21:31.273" Title="Error when using USART with Arduino Mega 2560" Tags="|arduino-mega|uart|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20142" PostTypeId="2" ParentId="20140" CreationDate="2016-01-30T15:41:28.970" Score="1" Body="&lt;p&gt;The compiler/linker is providing the answer. There are at least two definitions of the ISR for UART0 RX. One in your code and one in HardwareSerial. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-30T15:41:28.970" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20143" PostTypeId="2" ParentId="20139" CreationDate="2016-01-30T15:49:57.593" Score="4" Body="&lt;p&gt;It is not so easy to create a -5v power supply using a capacitor or transistor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very easy way is to use an additional Wall wart power supply to create -5 volts (while still using your original +5 volt power supply).   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the additional (new -5 volts power supply), use the two wires (positive and negative to create your -5 volts).   The positive lead goes to your board ground, and the negative lead becomes your -5 volts.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 1  :   Make certain that the Wall wart that you use is isolated from the mains voltage (line voltage you plug it into).  Most Wall warts are isolated,  but check to be sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need level translation, which can be done with an op-amp and a couple of resistors  :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4JGOJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4JGOJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have not mentioned what frequency (data rate) you need.  This circuit is not fast, so for high frequency or high data rates, the circuit could be improved.  &lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-02-01T12:43:01.980" LastActivityDate="2016-02-01T12:43:01.980" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20145" PostTypeId="2" ParentId="11694" CreationDate="2016-01-30T16:08:58.287" Score="4" Body="&lt;p&gt;There is an &lt;a href=&quot;https://github.com/balrog-kun/optiboot&quot; rel=&quot;nofollow&quot;&gt;Arduino optiboot fork&lt;/a&gt; for this now, which seems to handle what you want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would use a PC, RPi or whatever that could run &lt;code&gt;avrdude&lt;/code&gt; to send the update to an Arduino acting as the update server, which transmits the code to the client.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The instructions on the page seem quite comprehensive.&lt;/p&gt;&#xA;" OwnerUserId="16877" LastEditorUserId="6936" LastEditDate="2016-02-01T06:35:08.663" LastActivityDate="2016-02-01T06:35:08.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20146" PostTypeId="2" ParentId="20125" CreationDate="2016-01-30T16:10:08.320" Score="0" Body="&lt;p&gt;The PIR works at 5V but you need to tweak the amount of sensibility and the signal length.&#xA;Usually when a motion is detected, the PIR keeps sending HIGH until x seconds defined by a potentiometer on the board, when it goes down, the sensor is ready to capture another motion.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2016-01-30T16:10:08.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20147" PostTypeId="2" ParentId="17326" CreationDate="2016-01-30T16:40:45.893" Score="2" Body="&lt;p&gt;Could look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class HammingStream : public Stream {&#xA;public:&#xA;  HammingStream(Stream&amp;amp; ios) : m_ios(ios) {}&#xA;  virtual size_t write(uint8_t byte);&#xA;  virtual int read();&#xA;  virtual int available();&#xA;  virtual void flush();&#xA;protected:&#xA;  Stream&amp;amp; m_ios;&#xA;  uint8_t encode4(uint8_t nibble);&#xA;  uint8_t decode8(uint8_t code);&#xA;};&#xA;&#xA;size_t HammingStream::write(uint8_t byte)&#xA;{&#xA;   m_ios.write(encode4(byte &amp;gt;&amp;gt; 4));&#xA;   m_ios.write(encode4(byte &amp;amp; 0xf));&#xA;   return (1);&#xA;}&#xA;&#xA;int HammingStream::read()&#xA;{&#xA;  if (available() == 0) return (-1);&#xA;  uint8_t nibble = decode8(m_ios.read());&#xA;  return ((nibble &amp;lt;&amp;lt; 4) | decode8(m_ios.read());&#xA;}&#xA;&#xA;int HammingStream::available()&#xA;{&#xA;  return (m_ios.available() / 2);&#xA;}&#xA;&#xA;void HammingStream::flush()&#xA;{&#xA;  m_ios.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you could:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HammingStream HammingSerial(SoftwareSerial);&#xA;HammingSerial.println(F(&quot;hello world&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above leaves out the encoding/decoding but also error detection. Hamming decoding can capture up to two bit errors and do one bit correction (on 4-bit data).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of implementation of the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/libraries/HammingCodec_8_4/HammingCodec_8_4.hh&quot; rel=&quot;nofollow&quot;&gt;coder&lt;/a&gt; may be found in Cosa. Here Hamming(8, 4) is used to improve VirtualWire performance. Please note that the coder table is adjusted for RF and avoiding DC signal (i.e. long periods of zero or one). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-31T12:06:00.993" LastActivityDate="2016-01-31T12:06:00.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20148" PostTypeId="1" CreationDate="2016-01-30T17:12:17.437" Score="1" ViewCount="526" Body="&lt;p&gt;I have an Arduino Leonardo that can turn a relay off and on and the click is audible on the relay -this is simply done by making one of the control wires HIGH in the program code to turn the relay on and make the same control wire LOW to turn the relay off. In this way it can turn a set of relays on and off. By varying the patterns of on and off timings to the relay it make distinct sounds-it reminded me of a piezoelectric speaker for some of the programmed values. At fast on or off puling this 6V relay makes a buzzing noise. I was wondering if the sound emitted from the relay could be used as a crude speaker- I'm not talking about a quality speaker- just good enough to recognise a melody or speech. So my question &#xA;I was thinking the problem maybe be simplified if a set of relays is used buzzing at a certain frequency-corresponding to tones heard in the human voice to make it sound like speech. Im no expert in acoustics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) is  it theoretically possible to use the clicking noise from a set of relays only to act as a a crude speaker (so hear a crude known melody or a crude speech)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is there such a circuit (if so what is it exactly and the theory of how it works) that can be built with an arduino?-so it only used the noise from a relay to act as a crude speaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally think it possible it would be an interesting circuit to build as I have not seen a relay used like this before. I just think it sounds interesting that music or speech can possible be made by a circuit without using a speaker type component. Maybe there's another non-speaker component (i.e. a component that was not originally designed to make a sound) that can be used instead of a relay.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd love to know the answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update&#xA;I started on this. And the relays do make different tones-thats as far as I got.&#xA;So music seems to be possible; something like a famous melody of a song. I havent got any ideas yet for a another component instead of a relay.&lt;/p&gt;&#xA;" OwnerUserId="16846" LastEditorUserId="16846" LastEditDate="2016-02-01T13:50:07.010" LastActivityDate="2016-02-01T13:50:07.010" Title="Can an a Arduino make music or speech without a speaker?" Tags="|sketch|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20149" PostTypeId="2" ParentId="20148" CreationDate="2016-01-30T17:52:18.323" Score="3" Body="&lt;p&gt;Sound happens because of a disturbance in the air (or other conducting medium). So the short answer is an unqualified &quot;yes.&quot; To start making a recognizable &quot;tune&quot; or &quot;voice&quot; you would need to vary the frequency at which you create the disturbance. In the case of a relay, you'd be varying the rate at which you activate it. This would be very possible on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get recognizable sounds out of a relay you'd need one that can respond in the range of a few hundred Hz (which would give notes around middle C (roughly 260 Hz) up to a few KHz. From what is posted in @CharlieHanson's comments and answers, it doesn't seem like common relays can do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A function that takes agreements of pitch and duration, something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; note(hz, ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would give you a fairly easy way to describe the music you wanted to play.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just for fun, here are a few examples of &quot;speakerless devices&quot; making music:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://youtu.be/OUzDwCX1sKY&quot; rel=&quot;nofollow&quot;&gt;Floppy disc drive music&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://youtu.be/Tr4zb-HHZs4?t=30s&quot; rel=&quot;nofollow&quot;&gt;Lotus F1 car plays Happy Birthday&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-01-31T07:43:31.140" LastActivityDate="2016-01-31T07:43:31.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20150" PostTypeId="1" CreationDate="2016-01-30T19:40:27.227" Score="2" ViewCount="1683" Body="&lt;p&gt;I have a Funduino Joystick Shield (See here &lt;a href=&quot;http://www.gearbest.com/boards-shields/pp_236610.html?currency=GBP&amp;amp;gclid=CKvOx76k0soCFUieGwodKTcD-w&quot; rel=&quot;nofollow&quot;&gt;Funduino on Gearbeast store&lt;/a&gt;) which has some Bluetooth pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what pins they are connected to, and has anyone successfully connected to a BT HC-05 device using SoftwareSerial?&lt;/p&gt;&#xA;" OwnerUserId="16883" LastEditorUserId="6936" LastEditDate="2016-02-01T06:59:19.450" LastActivityDate="2016-05-01T15:42:56.043" Title="Funduino Joystick Shield with Bluetooth" Tags="|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20151" PostTypeId="1" AcceptedAnswerId="20159" CreationDate="2016-01-30T20:04:24.657" Score="1" ViewCount="4036" Body="&lt;p&gt;I know it's possible (in theory) to reprogram the VID PID details back into a chip. It is however way beyond me. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recently I learned that Microsoft distributed a piece of malicious software as part of their Windows update service. This virus was written by the FTDI chip makers to brick any chips such as the CH341's found in many cheaper Arduinos et al.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The virus attacked my CH341A serial to USB chip by writing 0's to the VID PIC and probably other locations. This makes the hardware 'Unknown' and even if you have the correct driver software, the device is never associated with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know a solution to get the zeroed information back into the CH341A?&lt;/p&gt;&#xA;" OwnerUserId="16725" LastActivityDate="2016-02-01T08:31:05.127" Title="Reprogram CH341A chips VID PID etc" Tags="|serial|ftdi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20152" PostTypeId="2" ParentId="20151" CreationDate="2016-01-30T20:40:32.760" Score="2" Body="&lt;p&gt;What you call a “virus” is, more properly, malware.  FTDI's driver that bricked fake FT232R chips was withdrawn from Windows Update in October of 2014.  (See, for example, discussion at &lt;a href=&quot;http://www.epanorama.net/newepa/2014/10/23/on-counterfeit-usb-serial-chips/&quot; rel=&quot;nofollow&quot;&gt;epanorama.net&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/news/1629&quot; rel=&quot;nofollow&quot;&gt;sparkfun&lt;/a&gt;, and &lt;a href=&quot;http://hackaday.com/2015/02/08/unbricking-a-counterfeit-ftdi-chip/&quot; rel=&quot;nofollow&quot;&gt;hackaday&lt;/a&gt;.  The hackaday article, “Unbricking a counterfeit FTDI chip”, has links to an article about unbricking counterfeits.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CH341A is not a fake FT232; it is a cheaper alternative that requires a different driver.  The driver is not automatically installed by Windows. Several web pages I've seen about it suggest downloading from Chinese-language web pages, which is a gamble if you don't understand what the page says.  [However, English-language &lt;a href=&quot;http://www.driverscape.com/download/usb-serial-ch341a&quot; rel=&quot;nofollow&quot;&gt;driverscape.com&lt;/a&gt; seems to have a CH341A driver at the moment.  I don't know if it works or whether it is free, and anyway have no Windows machine to test it on.]&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-01-30T20:40:32.760" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20153" PostTypeId="1" CreationDate="2016-01-30T20:50:13.757" Score="0" ViewCount="302" Body="&lt;p&gt;I am new to microcontrollers and just become confused trying to solve the following problem: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ATmega32 chip is connected to four on/off switches (SW0-SW3) and 4 LEDs (LED0-LED3). SWi is connected to PAi.  LEDi is connected to PA(4+i). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How will I code in such a way that turning a switch on, turns the corresponding LED on? For example, turning SW1 on will turn LED1 on. &lt;strong&gt;I am confused in the part that after taking input what will I send to port A&lt;/strong&gt;? Multiple switches can be switched on at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For clarification:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch0 is connected to PA0&#xA;switch1 is connected to PA1&#xA;switch2 is connected to PA2&#xA;switch3 is connected to PA3&#xA;&#xA;LED0 is connected to PA4&#xA;LED1 is connected to PA5&#xA;LED2 is connected to PA6&#xA;LED3 is connected to PA7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16887" LastEditorUserId="6936" LastEditDate="2016-02-01T07:06:14.860" LastActivityDate="2016-02-01T07:06:14.860" Title="Switching LED on and off using microcontroller" Tags="|atmega328|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20154" PostTypeId="2" ParentId="20153" CreationDate="2016-01-30T21:21:23.510" Score="1" Body="&lt;p&gt;A common approach is, to read the input pin, check the read value and then write to the output pin.&#xA;As the events on the input pin are generally asynchronous to your code, you have to check it more than once, which means in fact you have to check it regularily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in your arduino sketch you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA;  uint8_t pin1=digitalRead(PA0);&#xA;  if (pin1==HIGH)&#xA;  {&#xA;     digitalWrite(PA4, HIGH);&#xA;  }&#xA;  uint8_t pin2=digitalRead(PA1);&#xA;  if (pin2==HIGH)&#xA;  {&#xA;     digitalWrite(PA5, HIGH);&#xA;  }&#xA;  // and so on&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume you have already done the prerequisites in your setup() routine.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2016-01-31T15:42:10.510" LastActivityDate="2016-01-31T15:42:10.510" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20155" PostTypeId="2" ParentId="19127" CreationDate="2016-01-30T21:28:48.903" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am using the dynamic memory in AVR microcontroller, so How to know that there is collision between stack and heap or if the memory has been filled?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The first thing that happens is that malloc() will return NULL saying that memory could not be allocated. The &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/malloc.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR heap implementation&lt;/a&gt; has a few safety measures. One is to check that there is a minimum margin (__malloc_margin) between end of the heap and the top of the stack. This can be adjusted by the application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Lc5uw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Lc5uw.png&quot; alt=&quot;Heap-Stack&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically the minimum margin should be able to hold &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_ramoverlap&quot; rel=&quot;nofollow noreferrer&quot;&gt;the largest stack usage&lt;/a&gt; (typically deepest function call tree with the largest local variables usage) plus largest ISR stack usage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the stack runs into the heap the memory block/s at the end of the heap is/are corrupted. What happens depends on the type of data structure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not checking NULL return from malloc() gives some interesting errors on the AVR as the &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc#Register_Layout&quot; rel=&quot;nofollow noreferrer&quot;&gt;processors registers&lt;/a&gt; are memory mapped. NULL points to R0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RxwSL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RxwSL.jpg&quot; alt=&quot;AVR Memory Map&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good rule of thumb when using malloc() in small scale embedded systems is 1) avoid it, 2) allocate memory with malloc() during the setup(). All other dynamic memory need be allocated temporary on stack and only for the processing.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-01T10:51:48.233" LastActivityDate="2016-02-01T10:51:48.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20156" PostTypeId="1" CreationDate="2016-01-30T21:37:37.010" Score="1" ViewCount="1526" Body="&lt;p&gt;Ok so forgive me for being an amateur but I'm having a situation that's driving me nuts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a sensor that I have to cycle between +5VDC and +1.4VDC every 60 seconds. I'm using an ATTiny85 with the 8Mhz internal clock fuse set. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I was hoping was to use a 2N7000 N-Channel MOSFET to control the cycling of the voltage. So my thought is to have +5VDC on the Drain and a PWM signal on the Gate with the + side of the sensor connected to the Source. I am thinking that using PWM and adjusting the duty cycle on the Gate will allow me to adjust the voltage that is seen at the Source but what I'm seeing is a variation of +1.4VDC @28% duty cycle and +3.6VDC at 100% duty cycle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't figure out why +3.6VDC is the best I can do. The PWM is coming from PB1 on the ATTiny85 and the +5VDC is coming from the main voltage source that also feeds the ATTiny85. The current draw of the sensor is 140mA max.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Iv3Px.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Iv3Px.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok so I haven't had any luck using a BJT or a single component to perform this voltage change so I started on a different approach using two 1N7000, with one being in an inverter configuration.  My though is the pin from the MCU will go high, which will turn on both FET's, with one supplying 5V and the other sinking to ground.  When the MCU pin goes low, both FET's turn off, which stops the 5V flow and the sink to ground, which then will allow the path through a voltage divider into my sensor at 1.4V.  The issue I am having is the second FET is smoking, and by that I mean the sucker heats up like crazy and one even let the smoke out!  I cannot for the life of me figure out WTF I am missing in this configuration.  Here is the new schematic and Q1 is the FET that is smokin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bzTeI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bzTeI.png&quot; alt=&quot;Version 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16888" LastEditorUserId="16888" LastEditDate="2016-02-11T01:15:40.890" LastActivityDate="2016-05-11T02:48:09.823" Title="Use MOSFET to Change Voltage With PWM" Tags="|sensors|transistor|mosfet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20157" PostTypeId="1" AcceptedAnswerId="25325" CreationDate="2016-01-30T21:46:21.543" Score="2" ViewCount="20510" Body="&lt;p&gt;I would like to introduce myself as a student from Czech Republic. I'm currently I'm working on a Meteostation project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got Arduino set up, with plenty of weather sensors, as well as WH1080 sensors connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, I'm only able to read the data via serial port on computer with Arduino IDE or show it on my 20*4 display. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the distance between source of data and recipient of data, wireless data transfer is unsuitable for my application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found these MAX 485 modules on eBay for cheap:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gsqzK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gsqzK.jpg&quot; alt=&quot;max485 module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I quickly got 2 pieces, as well as 5v-3.3v logic level shifter, as I was concerned about different logics on Raspi. I don't know much about Raspi and their pins, as the only thing I ever used with them was DS3231 real time clock module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the thing I'm trying to achieve is this - I want to be running a bunch of sensors at roof of our house, and have the Arduino send the data to Raspi over the rs485 (on request? as the sensor loop would be like 10-15min so maybe communicate on interrupt?) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm planning to do with the data on the raspi would be running a software like WeeWx or wfrog to process them and possibly render a local website, that I could make public as port forwarding (I have public IP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are few questions I have, hopefully its not too much to ask&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How would the wiring look like? I was unable to find any dumb-proof tutorial online, as I don't know whether or how to use the logic level shifter.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I can read the data over serial port, would it be just a plain text (as shown on PC in Arduino ide serial monitor), or has each value its address that I could then easily accessing to a variable then being used to process the weather data?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I'm completely wrong in something, or there's some completely different way how these things are being done by more experienced people, I'd love to hear some suggestions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any kind of response, as this is at the moment causing me headaches, as I'm unable to do this on my own. I don't expect anyone to do all the work for me, maybe just point me in the right direction.&lt;/p&gt;&#xA;" OwnerUserId="16889" LastEditorUserId="9962" LastEditDate="2016-06-16T16:42:43.277" LastActivityDate="2016-12-14T04:22:22.480" Title="Arduino sending data over MAX485" Tags="|serial|sensors|hardware|communication|rs485|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20158" PostTypeId="2" ParentId="20156" CreationDate="2016-01-30T22:09:09.477" Score="1" Body="&lt;p&gt;Using a N-type transistor as a high-side switch is inefficient unless you have some way of driving the gate above the positive rail. The most you can reasonably expect at the source is the gate voltage minus the gate threshold voltage, V&lt;sub&gt;GS(th)&lt;/sub&gt;. The typical threshold voltage of the 2N7000 as given in the datasheet is 2.1V, which means that it is a bit remarkable that you are able to get a voltage as high as you have (5V - 2.1V = 2.9V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to fix this is to switch to a P-type transistor (and flip it around) since its threshold voltage is negative.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-30T22:09:09.477" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20159" PostTypeId="2" ParentId="20151" CreationDate="2016-01-30T22:09:53.070" Score="2" Body="&lt;p&gt;Here's the guide I used to correct the problem :-&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;HOW TO FIX THE USB-FTDI PROBLEM&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(on arduino nano, usb ttl, ft232, ...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There must have been a production of faulty ftdi drivers (version 2.12.0.0 or later) on august 2014 that makes some arduino boards and other usb devices not readable from the computer. The problem is random, meaning that it is possible to program the arduino a couple of times and then it comes out the ftdi problem, at that point the board isn't accessible anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you come up with this problem, upgrading/downgrading the drivers, the IDE or the bootloader is just a waste of time, as the ftdi driver installed leaves some wrong data. This guide followed step by step will completely fix the driver problem thus making your board working again. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 1: check if you have a faulty ftdi chip driver&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Not every ftdi chip has faulty drivers, so the first step is to check the chip's driver version. In order to check the version you need a software like usbview or usbdeview (both freeware and don't need any installation). Run the software and look for the &quot;USB serial converter&quot; device which is the one related to the ftdi driver, then read the vendor-id and the Product-id whose values should be 0x0403 for the vendor and 0x6001 for the product. The goal is to modify that 0x6001 value with 0x0000, and to do that we need some other software.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 2: modify values&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Unplug your arduino nano or usb device. In order to modify the driver values you need CDMUninstaller (no installation needed). Fill the vendor and product fields with the values found with usbview (0403 and 6001) and click 'add', finally click 'remove devices'.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 3: download the 2.10.0.0 ftdi driver&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Go to the ftdi website and download the 2.10.0.0 virtual driver choosing between 32 or 64 bit version, voiding the 'setup executable' file: just download the folder. After downloading the folder, we have to overwrite some files inside of it. Click &lt;a href=&quot;http://www.electrohobby.es/Archivos/ModificadosFTDI.rar&quot; rel=&quot;nofollow&quot;&gt;FTDI.rar&lt;/a&gt; to download the files already modified, and place them inside the 2.10.0.0 folder overwriting the old ones.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 4: connect your arduino board&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;connect your arduino board, and stop windows from looking for new drivers. Go to device manager and look for FT232 USB device, then right click on it, select Properties and click on update drivers. Manually select the place in which scan for the new drivers and choose the 2.10.0.0 driver folder with the modified files. Now windows will prompt you saying that it can't certificate the new drivers. Ignore the alert and proceed with the installation. Once installation has finished, windows should recognize the connected board as 'USB recuperacion'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Close the window and go to device manager, and look for the COM ports device. The connected device is now showing up like USB recuperation by ElectroHobby.es&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Step 5: modify the chip eeprom&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This is the last step and you need to restore the initial vendor and product values inside the ftdi chip eeprom. In order to do that you need to download and install Ftprog, click on the magnifing glass icon, select 'USB device descriptor' and again select 'custom pid'. Finally click on 'ftdi default'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A new window shows up and you just need to check flag the device list and then click on 'program'.&lt;/p&gt;&#xA;" OwnerUserId="521" LastEditorUserId="521" LastEditDate="2016-02-01T08:31:05.127" LastActivityDate="2016-02-01T08:31:05.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20160" PostTypeId="2" ParentId="10458" CreationDate="2016-01-30T23:12:49.710" Score="0" Body="&lt;p&gt;Take a look at this link, you should get the impression that CDMA envelopes a lot more then Cell Phones.&#xA;&lt;a href=&quot;http://www.slideshare.net/mnsh01987/bluetooth-technology?next_slideshow=1&quot; rel=&quot;nofollow&quot;&gt;http://www.slideshare.net/mnsh01987/bluetooth-technology?next_slideshow=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you did not state CDMA2000 and I was involved in the automotive industry I took that approach because you can use CAN, RS485 and many other adapters to implement it with the Arduino, to my knowledge a complete CDMA2000 package is not yet available to the Arduino users.  Initially we tested the CDMA theory with open collector transistors on a wire transmission line then we tested CSMANDA with the same hardware. From that point custom chips were designed and implemented. This was in the early 90's.&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2016-01-30T23:12:49.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20161" PostTypeId="2" ParentId="17392" CreationDate="2016-01-30T23:46:18.700" Score="0" Body="&lt;p&gt;CAT5 should work well with what you are trying to do, however stay away from power lines unless they are in a grounded conduit.  The phone lines would most likely generate interference when the phone is ringing as there is a lot of voltage transients on the line at that time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the full benefit of the twisted pairs send and receive your signals with differential transceivers, one transceiver per pair.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I will not connect a microprocessor pin to the outside world without some type of buffering isolation etc.  Those pins were not designed to drive long lines, although it may work eventually it will fail, that may be momentary to many years in the making but it will fail.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lines connected directly to the microprocessor pins will all act as bidirectional antennas. They are not only are sustainable to interference they also generate it.  Remember the wires are small inductors which can generate some huge voltages when the transition time is short. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I typically use Schmidt devices such as a 74C14, 74HC etc. as my input receivers for switches etc.  I normally use an active low input signal, this help to keep noise out of the power supply. The input to the gate is pulled up to the 12VDC with a 10K resistor, this keeps a minimum of about 1 mA through the contact. The other end of the resistor is connected to a 100K resistor that in turn connects to the microprocessor input pin. You can add a cap to de-bounce at the gate if you want. The software is easier as it is looking for an active high which is a logic &quot;1&quot;.  This circuit has been replicated hundreds of thousands of times and is very stable and reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are doing will work for dorm room, testing etc...&lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2016-01-30T23:46:18.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20162" PostTypeId="2" ParentId="13150" CreationDate="2016-01-31T00:02:01.073" Score="1" Body="&lt;p&gt;Check with your favorite automotive semiconductor supplier such as ST. In there automotive listings you will find drivers that will do exactly what you want and if shorted to long will shut down and come back when the short is removed.  I am not going to make a recommendation as there are literally hundreds of possibilities. These come from 1 driver per unit to 8 that would be easy to purchase. They have parallel and serial interfaces depending on what you want. If you want to be nasty get a 50 amp driver and put a huge power supply behind it, then enjoy the looks and smoke when shorted and you get the last laugh your Arduino will be OK.  Have Fun! &lt;/p&gt;&#xA;" OwnerUserId="14095" LastActivityDate="2016-01-31T00:02:01.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20163" PostTypeId="2" ParentId="20148" CreationDate="2016-01-31T00:59:58.270" Score="2" Body="&lt;p&gt;The operate/release time for a &lt;a href=&quot;http://www.omron.com/ecb/products/pdf/en-g5v_2.pdf&quot; rel=&quot;nofollow&quot;&gt;typical relay&lt;/a&gt; is 10ms/4ms - that means it takes 14ms for the contacts to close and open again. 14ms equates to a maximum 'click' frequency of 71Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical rates of cycles-before-failure are in the region of 100,000  minimum - but at a rate of 5 cycles per second. This will rapidly decrease as you increase the switching rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, as alluded to in the above datasheet, must-operate and must-release voltages increase as the number of completed cycles moves into the tens-of-thousands. Thus, if you were to find a relay that switched fast enough you will eventually (and maybe only after a 100 seconds of non-continuous operation) run its operating voltage above a level that can be achieved.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Due to the maximum switching frequency of a relay you &lt;strong&gt;cannot&lt;/strong&gt; use one, or many, to synthesise speech. Speech is an incredibly complex mixture of frequencies, the majority of which are well above those that can be produced by switching a relay on and off.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Music&lt;/em&gt; is a loose term. Simply switching the relay on and off once per second is technically a rythym, and therefore music. Different relay models will have different 'clicks' - the smaller the contacts the higher the click will be in pitch (logically speaking, that is). A collection of &lt;em&gt;different&lt;/em&gt; relays could definitely create music, akin to percussion, but by their &lt;em&gt;individual clicks&lt;/em&gt; and &lt;strong&gt;not by the rapid switching thereof&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2016-01-31T01:27:18.867" LastActivityDate="2016-01-31T01:27:18.867" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20164" PostTypeId="2" ParentId="19130" CreationDate="2016-01-31T02:25:08.443" Score="0" Body="&lt;p&gt;According to the Atmega32U4 datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The device is manufactured using ATMEL’s high-density nonvolatile memory technology. The On-chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I can't find the word &quot;ICSP&quot; in the datasheet. The quoted paragraph doesn't really explain the acronym. It could be an anagram of SPI. ;)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It seems clear to me that &quot;in system&quot; and &quot;in circuit&quot; are referring to the same thing. The program is serial rather than parallel as it uses SPI (Serial Peripheral Interface).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've shown two configurations in this question I just asked. Are they both ICSP?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really two configurations, because the ICSP header on the board is directly connected to the pins you showed in the other configuration. You may as well talk about using different ground pins as a &quot;different configuration&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-31T02:25:08.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20165" PostTypeId="2" ParentId="19129" CreationDate="2016-01-31T02:32:52.320" Score="1" Body="&lt;p&gt;Take a look at my circuit for a minimal &quot;Arduino&quot;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tdi6h.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tdi6h.png&quot; alt=&quot;Minimal circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The top image in the question uses the ICSP header, which you can see from the schematic &quot;mirrors&quot; pins on the processor. That is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SCK is D13&lt;/li&gt;&#xA;&lt;li&gt;MISO is D12&lt;/li&gt;&#xA;&lt;li&gt;MOSI is D11&lt;/li&gt;&#xA;&lt;li&gt;Reset on the target goes to D10 on the programming board&lt;/li&gt;&#xA;&lt;li&gt;Vcc and Gnd are connected&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Trace out the wires to the ICSP header and you will see.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So do I need a 10 uF capacitor between reset and ground? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No you do not.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have a bricked Arduino Uno and I want to try to flash the bootloader.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See my page about &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;programming a bootloader&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why are there two configurations?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Just different ways of connecting the same thing to the same thing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What's the upsides and downsides to either of them?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No difference.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-31T02:32:52.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20166" PostTypeId="2" ParentId="13150" CreationDate="2016-01-31T03:38:58.387" Score="0" Body="&lt;p&gt;See &lt;a href=&quot;http://www.rugged-circuits.com/10-ways-to-destroy-an-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;10 Ways to Destroy An Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the suggestions there for output pins was:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Put a 30mA resettable fuse (PTC) in series with every I/O pin. Not only is the current safely limited to 30mA under all conditions (more on this below), but the built-in 220 ohm resistance of the fuse naturally limits the current to 5V/220 = 23mA right off the bat.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You may also want to look at some of the suggestions on &lt;a href=&quot;https://arduino.stackexchange.com/questions/13126/&quot;&gt;the question about protecting input pins&lt;/a&gt; which could help with keeping spikes out of the output circuits.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-01-31T03:38:58.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20167" PostTypeId="1" AcceptedAnswerId="20168" CreationDate="2016-01-31T10:03:57.753" Score="5" ViewCount="1214" Body="&lt;p&gt;I have a question regarding &lt;em&gt;potentiometer example&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/AnalogReadSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/AnalogReadSerial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fYM1t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fYM1t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I turn the potentiometer to the marginal position and have 5V at A0 (and almost zero resistance at the pot), what limits the current flowing through the circuit?&lt;/p&gt;&#xA;" OwnerUserId="16764" LastEditorUserId="2881" LastEditDate="2016-01-31T14:11:05.240" LastActivityDate="2016-01-31T14:11:05.240" Title="Arduino potentiometer example: what limits the current?" Tags="|current|potentiometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20168" PostTypeId="2" ParentId="20167" CreationDate="2016-01-31T10:12:03.943" Score="5" Body="&lt;p&gt;A0 input is high impedance, so very little current is flowing into A0. The value is so small that you can simplify that it flows only from +5V through the potentiometer to GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some applications, when you are measuring high-impedance sources (a source that can deliver very little current) this simplification may not be correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find more detailed explaination in Atmel application note:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/atmel-8456-8-and-32-bit-avr-microcontrollers-avr127-understanding-adc-parameters_application-note.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/atmel-8456-8-and-32-bit-avr-microcontrollers-avr127-understanding-adc-parameters_application-note.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-01-31T10:17:17.180" LastActivityDate="2016-01-31T10:17:17.180" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20169" PostTypeId="2" ParentId="20167" CreationDate="2016-01-31T10:13:42.003" Score="3" Body="&lt;p&gt;Assuming A0 is set to &lt;strong&gt;input&lt;/strong&gt; then it is a high-impedance input. That is, the input has a high resistance, and only consumes enough current to &quot;sample&quot; the voltage.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-31T10:13:42.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20170" PostTypeId="2" ParentId="18329" CreationDate="2016-01-31T10:33:02.267" Score="2" Body="&lt;p&gt;How about little smart WiFi boards (such as &lt;a href=&quot;http://redbear.cc/wifi-micro/&quot; rel=&quot;nofollow&quot;&gt;Red Bear WiFi Micro&lt;/a&gt; or something similar), which are connected at your local home network? You can configure your own dyndns service or use a existing and built a web home appliances or web service for your own mobile application. In general please take care of security aspects, so that your home can not be manipulated...   &lt;/p&gt;&#xA;" OwnerUserId="4131" LastEditorUserId="4131" LastEditDate="2016-02-02T18:09:09.710" LastActivityDate="2016-02-02T18:09:09.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20171" PostTypeId="2" ParentId="13931" CreationDate="2016-01-31T12:01:25.407" Score="2" Body="&lt;p&gt;Here are a few examples how to pass vectors and variable number of arguments to a function in C/C++:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void foo(int* vector, size_t nmemb);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function &lt;em&gt;foo&lt;/em&gt; takes a &lt;em&gt;vector&lt;/em&gt; of integers and the number of members, &lt;em&gt;nmemb&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const size_t VECTOR_MAX = 5;&#xA;int vector[VECTOR_MAX] = { 0, 1, 3, 5, 7 };&#xA;&#xA;foo(vector, VECTOR_MAX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next variant is generalization. A vector of whatever, number of members, and size of each member;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void fie(void* vector, size_t nmemb, size_t size);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows the function to handle different types of element. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fie(vector, VECTOR_MAX, sizeof(int));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Examples of usage are the standard library functions &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gafd4bf2faec43342e7ad3d2ab37bac1fe&quot; rel=&quot;nofollow&quot;&gt;qsort()&lt;/a&gt; and &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga885c1ccefb716ff16ab73a57003140be&quot; rel=&quot;nofollow&quot;&gt;bsearch()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next variant is variable arguments. C/C++ allows the syntax &quot;...&quot; for a list of arguments. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void fum(size_t nmemb, ...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This allows the following call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fum(5, 0, 1, 3, 5, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The implementation of function must be able to &quot;parse&quot; the argument list.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdarg.h&amp;gt;&#xA;&#xA;void fum(size_t nmemb, ...)&#xA;{&#xA;  va_list ap;&#xA;  va_start(ap, nmemb);&#xA;  int arg;&#xA;  for (size_t i = 0; i &amp;lt; nmemb; i++) {&#xA;    va_arg(int, arg);&#xA;    ...&#xA;  }&#xA;  va_end(ap);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are four primary methods to determine the number of arguments and value types; 1) number of arguments as parameter and fixed data type, 2) special end parameter value, 3) indirect through format descriptor such as &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#ga4c04da4953607fa5fa4d3908fecde449&quot; rel=&quot;nofollow&quot;&gt;printf()&lt;/a&gt; format string, and 4) attribute-value pairs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is an example of variable number of arguments as attribute-value pairs. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void set_attrs(size nr, ...);&#xA;&#xA;set_attrs(5, X_POS, 10, Y_POS, 110, R_COLOR, 0, G_COLOR, 255, B_COLOR, 0); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A usage of this notation can be found in &lt;a href=&quot;http://www.opengroup.org/infosrv/openmotif/R2.1.30/motif/lib/Xm/VaSimple.c&quot; rel=&quot;nofollow&quot;&gt;Motif&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-01-31T12:01:25.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20172" PostTypeId="1" CreationDate="2016-01-31T15:08:44.493" Score="1" ViewCount="166" Body="&lt;p&gt;In my application all of the Arduino Uno LEDs will be invisible inside an enclosure, so I wish to provide panel-mounted Tx and Rx LEDS just replicating their on-board counterparts. Is there a way to drive any of the digital outputs to replicate those LEDs? I seem to recall that the Tx and Rx LEDs are driven directly from the FTDI logic, does this preclude hacking their states and sending them to two digital outputs? How could this be done? I could de-solder the LEDs and hardwire the panel LEDS to their pads, but I think this should be a last resort.&lt;/p&gt;&#xA;" OwnerUserId="16900" LastActivityDate="2016-02-01T10:46:44.330" Title="Replicating Tx and Rx LEDs" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20173" PostTypeId="2" ParentId="20172" CreationDate="2016-01-31T15:17:02.073" Score="1" Body="&lt;p&gt;The easiest thing to do would likely be to use an Arduino that does not have an on-board serial connection such as the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow&quot;&gt;Pro Mini&lt;/a&gt; and then add a separate USB-UART bridge with either bare pads you can solder panel-mount LEDs to or mounting holes that will allow you to mount it with the LEDs aligned to holes on the enclosure.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-31T15:17:02.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20174" PostTypeId="1" AcceptedAnswerId="20175" CreationDate="2016-01-31T15:20:23.607" Score="1" ViewCount="10904" Body="&lt;p&gt;Hello I have an Arduino programme that has a string with the words hello in it. &#xA;I can add characters and other strings to the end of that one using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   String test = &quot;hello&quot;;&#xA;   test+=&quot; jack&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it would then say &quot;hello jack&quot;&#xA;The problem is I want to get rid of the last character of the string every 2 seconds so it would be &quot;hello jac&quot; then &quot;hello ja&quot; and so on. How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="10794" LastEditDate="2016-01-31T21:10:20.973" LastActivityDate="2016-03-01T22:45:00.103" Title="Arduino subtracting chars from strings" Tags="|arduino-uno|c++|string|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20175" PostTypeId="2" ParentId="20174" CreationDate="2016-01-31T15:26:28.423" Score="4" Body="&lt;p&gt;You may use &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringRemove&quot; rel=&quot;nofollow&quot;&gt;remove()&lt;/a&gt; method to remove last character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String s = &quot;1234567890&quot;;&#xA;while(s.length() &amp;gt; 0) {&#xA;    int lastIndex = s.length() - 1;&#xA;    s.remove(lastIndex);&#xA;    Serial.println(s);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-03-01T22:45:00.103" LastActivityDate="2016-03-01T22:45:00.103" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20176" PostTypeId="2" ParentId="20174" CreationDate="2016-01-31T15:59:58.730" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to get rid of the last character of the string every 2 seconds so it would be &quot;hello jac&quot; then &quot;hello ja&quot; and so on. How can I do this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is how you could do that. Avoid using String and putting the string constants in program memory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// A buffer for the message&#xA;const size_t MSG_MAX = 16;&#xA;char msg[MSG_MAX];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  static int len = 0;&#xA;  // Check if it is time to create the initial message&#xA;  if (len == 0) {&#xA;    strcpy_P(msg, (const char*) F(&quot;hello&quot;));&#xA;    strcat_P(msg, (const char*) F(&quot; jack&quot;));&#xA;    len = strlen(msg) - 1;&#xA;  }&#xA;  // Otherwise shorten the message&#xA;  else {&#xA;    msg[len--] = 0;&#xA;  }&#xA;  // And print current message&#xA;  Serial.println(msg);&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-01-31T20:09:40.107" LastActivityDate="2016-01-31T20:09:40.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20177" PostTypeId="2" ParentId="20172" CreationDate="2016-01-31T16:00:49.960" Score="3" Body="&lt;p&gt;The USB to serial and LEDs are done with the ATmega16U2 (the chip near the USB socket). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look closely you'll see there are 4 pad near the chip, JP2 in the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;schematic&lt;/a&gt;. You could solder some wire to it to connect your leds. You could then slightly modify the &lt;a href=&quot;https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/firmwares/atmegaxxu2&quot; rel=&quot;nofollow&quot;&gt;firmware running on the ATMega16u2&lt;/a&gt;, and &lt;a href=&quot;https://www.arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;upload it using DFU&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did this on my arduino uno to break out the reset signal, so I could use my UNO to program an separate ATMega328 over serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case you could use the pads connected to PB4 and PB5 (as the original code uses PD4 and PD5), so the you only have to change &lt;code&gt;DDRD&lt;/code&gt; and &lt;code&gt;PORTD&lt;/code&gt;, to &lt;code&gt;DDRB&lt;/code&gt; and &lt;code&gt;PORTB&lt;/code&gt; in &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h&quot; rel=&quot;nofollow&quot;&gt;LED.h&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-01-31T16:00:49.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20178" PostTypeId="1" AcceptedAnswerId="20179" CreationDate="2016-01-31T19:59:38.470" Score="1" ViewCount="279" Body="&lt;p&gt;I want to send DMX with my Arduino Mega 2560. I'm using the IDE 1.6.7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the &lt;a href=&quot;http://www.ulrichradig.de/home/index.php/avr/atmega8-experimentierboard/avr---dmx&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR -&gt; DMX source code from Ulrich Radig&lt;/a&gt; and also the layout for the RS-485 transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I modified the code to fit the ATMega2560 but when I upload the code nothing happens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing I didn't do is to use the 22 Ohm resistors, is that a problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AA6Cx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AA6Cx.jpg&quot; alt=&quot;Photo of breadboarded RS-485 circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the source&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;#define F_CPU 16000000&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;#define DMX_BAUD 250000&#xA;#define DMX_BAUD_BREAK 80000&#xA;#define DMX_BAUD_BREAK_UBBR ((F_CPU+DMX_BAUD_BREAK*8)/(DMX_BAUD_BREAK*16)-1)&#xA;#define DMX_BAUD_UBBR ((F_CPU+DMX_BAUD*8)/(DMX_BAUD*16)-1)&#xA;&#xA;&#xA;volatile unsigned char dmx_buffer[512];&#xA;&#xA;&#xA;//############################################################################&#xA;//DMX Senderoutine&#xA;ISR (USART_TX_vect)&#xA;//############################################################################&#xA;{&#xA;  static unsigned int  dmx_channel_tx_count = 0;&#xA;  static unsigned char dmx_tx_state = 0;&#xA;&#xA;  switch (dmx_tx_state)&#xA;  {&#xA;    case (0):&#xA;      UBRR0   = DMX_BAUD_BREAK_UBBR;&#xA;      UDR0 = 0; //RESET Frame&#xA;      dmx_tx_state = 1;&#xA;      break;&#xA;&#xA;    case (1):&#xA;      UBRR0   = DMX_BAUD_UBBR;&#xA;      UDR0 = 0; //Start Byte&#xA;      dmx_tx_state = 2;&#xA;      break;&#xA;&#xA;    case (2):&#xA;      _delay_us(10);&#xA;      //Ausgabe des Zeichens&#xA;      UDR0 = dmx_buffer[dmx_channel_tx_count];&#xA;      dmx_channel_tx_count++;&#xA;&#xA;      if(dmx_channel_tx_count == 512)&#xA;      {&#xA;        dmx_channel_tx_count = 0;&#xA;        dmx_tx_state = 0;&#xA;      }&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA; //Init usart DMX-BUS&#xA; UBRR0   = DMX_BAUD_UBBR;&#xA;  DDRE |= (1&amp;lt;&amp;lt;PE1); //Output TXD Pin ATmega2560&#xA;  UCSR0B|=(1&amp;lt;&amp;lt;TXEN0)|(1&amp;lt;&amp;lt;TXCIE0); // TXEN0 Transmitter enable / TXCIE0 TX complete interrupt enable&#xA;  UCSR0C|=(1&amp;lt;&amp;lt;USBS0); //USBS0 2 Stop bits&#xA;  sei();//Globale Interrupts Enable&#xA;  UDR0 = 0;//Start DMX&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;    dmx_buffer[4]=255;&#xA;    _delay_ms(1000);&#xA;    dmx_buffer[5]=255;&#xA;     _delay_ms(1000);&#xA;    dmx_buffer[6]=255;&#xA;    _delay_ms(1000);&#xA;    dmx_buffer[4]=0;&#xA;    _delay_ms(1000);&#xA;    dmx_buffer[5]=0;&#xA;     _delay_ms(1000);&#xA;    dmx_buffer[6]=0;&#xA;     _delay_ms(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16875" LastEditorUserId="6936" LastEditDate="2016-02-01T06:50:07.387" LastActivityDate="2016-02-01T06:50:07.387" Title="Problem with sending DMX" Tags="|arduino-mega|uart|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20179" PostTypeId="2" ParentId="20178" CreationDate="2016-01-31T21:08:38.750" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The only thing I didnt do is to use the 22 Ohm resitors, is that a problem?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, that's a &lt;em&gt;huge&lt;/em&gt; problem. The resistors are there to &lt;a href=&quot;https://en.wikipedia.org/wiki/Reflections_of_signals_on_conducting_lines&quot; rel=&quot;nofollow&quot;&gt;prevent reflections from distorting the signal&lt;/a&gt;. Without them the best you can hope for is a garbled mess.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-01-31T21:08:38.750" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20180" PostTypeId="2" ParentId="20174" CreationDate="2016-01-31T21:09:46.243" Score="3" Body="&lt;p&gt;You are best of learning about C-style strings rather than the String class. The String class can eventually fragment dynamic memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To shorten a string a simple method is to move the &quot;string terminator&quot; inwards by overwriting the last byte of the message with zero, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const size_t MSG_MAX = 20;&#xA;char msg [MSG_MAX];&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  strcpy (msg, &quot;hello&quot;);  // initial message&#xA;  strcat (msg, &quot; jack&quot;);  // concatenate more stuff&#xA;  }  // end of setup&#xA;&#xA;  void loop ()&#xA;    {&#xA;    if (strlen (msg) &amp;gt; 0)&#xA;      {&#xA;      Serial.println (msg);  // display current message&#xA;      msg [strlen (msg) - 1] = 0;  // move null-terminator in&#xA;      delay (1000);&#xA;      }  // end of any message left&#xA;&#xA;    }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hello jack&#xA;hello jac&#xA;hello ja&#xA;hello j&#xA;hello &#xA;hello&#xA;hell&#xA;hel&#xA;he&#xA;h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-31T21:09:46.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20181" PostTypeId="1" AcceptedAnswerId="23984" CreationDate="2016-01-31T22:13:16.493" Score="0" ViewCount="4460" Body="&lt;p&gt;I'm trying to compile a simple I2C example to read data from an MPU-6050 accel/gyro sensor, but I'm getting the compilation error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:27:8: error: 'SPISettings' does not name a type&#xA; static SPISettings settings;&#xA;        ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectHigh()':&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:167:9: error: 'class SPIClass' has no member named 'endTransaction'&#xA;     SPI.endTransaction();&#xA;         ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectLow()':&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:176:9: error: 'class SPIClass' has no member named 'beginTransaction'&#xA;     SPI.beginTransaction(settings);&#xA;         ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:176:26: error: 'settings' was not declared in this scope&#xA;     SPI.beginTransaction(settings);&#xA;                          ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::init(uint8_t, uint8_t)':&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:269:3: error: 'settings' was not declared in this scope&#xA;   settings = SPISettings(250000, MSBFIRST, SPI_MODE0);&#xA;   ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:269:53: error: 'SPISettings' was not declared in this scope&#xA;   settings = SPISettings(250000, MSBFIRST, SPI_MODE0);&#xA;                                                     ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:275:7: error: 'class SPIClass' has no member named 'beginTransaction'&#xA;   SPI.beginTransaction(settings);&#xA;       ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:279:7: error: 'class SPIClass' has no member named 'endTransaction'&#xA;   SPI.endTransaction();&#xA;       ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::setSckRate(uint8_t)':&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:518:14: error: 'settings' was not declared in this scope&#xA;     case 0:  settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break;&#xA;              ^&#xA;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:518:66: error: 'SPISettings' was not declared in this scope&#xA;     case 0:  settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break;&#xA;                                                                  ^&#xA;make: *** [.build_ano/uno/SD/src/utility/Sd2Card.o] Error 1&#xA;Make failed with code 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've commented-out all code until it compiled without error, and I found that the error is caused by the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So my minimal code to reproduce the error is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup(){&#xA;}&#xA;&#xA;void loop(){&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is this include throwing this error? Why is it trying to compile code for accessing an SD card when I have no code that uses that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Arduino 1.6.1 and targeting the Uno. I found I can fix this error by copying version 1.0 of the Wire library into my local sketch folder.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-05-08T00:56:53.140" Title="SPISettings was not declared in this scope" Tags="|arduino-uno|compile|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20182" PostTypeId="2" ParentId="20150" CreationDate="2016-01-31T22:15:51.283" Score="2" Body="&lt;p&gt;Well, it turns out that the tx/rx for the board are connected to the standard pins 0 and 1 on the Arduino.&#xA;To use this, you can simply use Serial.write.&#xA;Of course, remember to take of the module when trying to upload your code.....&lt;/p&gt;&#xA;" OwnerUserId="16883" LastActivityDate="2016-01-31T22:15:51.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20183" PostTypeId="2" ParentId="20181" CreationDate="2016-01-31T22:42:21.180" Score="-1" Body="&lt;p&gt;Try a later version of the IDE. Try making a completely new sketch (don't just delete things from your current one). It looks to me like it is trying to compile things it shouldn't.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That doesn't seem relevant to your empty sketch.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-01-31T22:42:21.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20184" PostTypeId="1" CreationDate="2016-01-31T23:04:05.843" Score="2" ViewCount="1156" Body="&lt;p&gt;I can't flash my ESP8266 (ESP-01). I have 3.3 V and ground connected, Rx to Tx and Tx to Rx on my USB to serial adapter. I also have GPIO0 connected to ground too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an external power supply but the USB adapter and power adapter share a common ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a Mac and ESP tools to flash it, and it has worked before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The command I am using is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ./esptool.py --port /dev/tty.wchusbserial1410 write_flash 0x00000 AT22SDK10020150320boot12.bin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the response is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A fatal error occurred: Failed to connect to ESP8266&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This make me think something is wrong with receiving data from the ESP because when attempting to connect, the ESP's blue LED flashes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My USB to serial adapter works fine though as I've tested it with my Arduino.&lt;/p&gt;&#xA;" OwnerUserId="16450" LastEditorUserId="6936" LastEditDate="2016-04-27T04:20:47.723" LastActivityDate="2016-05-01T07:37:23.807" Title="Flashing ESP8266" Tags="|esp8266|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20187" PostTypeId="2" ParentId="19808" CreationDate="2016-02-01T03:36:02.353" Score="0" Body="&lt;p&gt;After looking at the schematic (mine is different) but on pin 16 is labeled as BL. If that is indeed the power for the LED backlights then a voltage applied to it should vary the brightness.  Caution:You need to know how much current the LEDs are pulling. If over the limit for a PWM pin you will have to run it through a transistor to boost the current.&lt;/p&gt;&#xA;" OwnerUserId="16908" LastActivityDate="2016-02-01T03:36:02.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20188" PostTypeId="1" AcceptedAnswerId="20225" CreationDate="2016-02-01T03:52:31.747" Score="1" ViewCount="6337" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AS361.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AS361.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;Anybody here have tried connecting multiple MPU9250 into multiplexer. Anyway, I've used the HD74LS151 as the substitute for the 74HC4051 multiplexer. I already tried running the program and just followed how it is connected as it is connected like in the picture. Please see the attached image in here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right after running the code I just only got zeros on the output. I hope someone could help me figure out what's going on with my program or  the connections of my pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the code I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;I2Cdev.h&amp;gt;&#xA;    #include &amp;lt;MPU6050.h&amp;gt;&#xA;&#xA;    // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE    implementation&#xA;    // is used in I2Cdev.h&#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &quot;Wire.h&quot;&#xA;    #endif&#xA;&#xA;    // class default I2C address is 0x68&#xA;    // specific I2C addresses may be passed as a parameter here&#xA;    // AD0 low = 0x68 (default for InvenSense evaluation board)&#xA;    // AD0 high = 0x69&#xA;    MPU6050 mpu_0(0x68);&#xA;    MPU6050 mpu_1(0x68);&#xA;    MPU6050 mpu_2(0x68);&#xA;    MPU6050 mpu_3(0x68);&#xA;    //MPU6050 accelgyro(0x69); // &amp;lt;-- use for AD0 high&#xA;&#xA;    int16_t ax_0, ay_0, az_0, ax_1, ay_1, az_1, ax_2, ay_2, az_2, ax_3, ay_3, az_3;&#xA;    int16_t gx_0, gy_0, gz_0, gx_1, gy_1, gz_1, gx_2, gy_2, gz_2, gx_3, gy_3, gz_3;&#xA;&#xA;   // uncomment &quot;OUTPUT_READABLE_ACCELGYRO&quot; if you want to see a tab-separated&#xA;  // list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read,&#xA; // not so easy to parse, and slow(er) over UART.&#xA; #define OUTPUT_READABLE_ACCELGYRO&#xA;&#xA; // uncomment &quot;OUTPUT_BINARY_ACCELGYRO&quot; to send all 6 axes of data as 16-bit&#xA; // binary, one right after the other. This is very fast (as fast as possible&#xA;// without compression or data loss), and easy to parse, but impossible to read&#xA;// for a human.&#xA;//#define OUTPUT_BINARY_ACCELGYRO&#xA;&#xA; #define LED_PIN 13&#xA; bool blinkState = false;&#xA;&#xA; //Mux control pins&#xA; int s0 = 5;&#xA; int s1 = 6;&#xA; int s2 = 7;&#xA;&#xA; //Mux in &quot;SIG&quot; pin&#xA; int SIG_pin = 0;&#xA;&#xA; const int MPU=0x68;&#xA;&#xA; void setup() {&#xA;&#xA;  pinMode(s0, OUTPUT); &#xA;  pinMode(s1, OUTPUT); &#xA;  pinMode(s2, OUTPUT); &#xA;&#xA;  //    delay(5);&#xA;  //    Wire.begin();&#xA;  //    Wire.beginTransmission(MPU);&#xA;  //    Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;  //    Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;  //    Wire.endTransmission(true);&#xA;  //    delay(15);&#xA; //&#xA; //    digitalWrite(s0, HIGH);&#xA; //    digitalWrite(s1, LOW);&#xA; //    digitalWrite(s2, LOW);&#xA;//    delay(5);&#xA;//    &#xA;//    Wire.begin();&#xA;//    Wire.beginTransmission(MPU);&#xA;//    Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;//    Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;//    Wire.endTransmission(true);&#xA;//    delay(15);&#xA;&#xA;// join I2C bus (I2Cdev library doesn't do this automatically)&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    Wire.begin();&#xA;#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;    Fastwire::setup(400, true);&#xA;#endif&#xA;&#xA;// initialize serial communication&#xA;// (38400 chosen because it works as well at 8MHz as it does at 16MHz, but&#xA;// it's really up to you depending on your project)&#xA;Serial.begin(38400);&#xA;&#xA;// ================= MPU: 0 =================&#xA;digitalWrite(s0, LOW);&#xA;digitalWrite(s1, LOW);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;Wire.begin();&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;Wire.endTransmission(true);&#xA;delay(15);&#xA;mpu_0.initialize();&#xA;Serial.println(&quot;Testing device connections #0 ...&quot;);&#xA;Serial.println(mpu_0.testConnection() ? &quot;MPU6050 connection #0 successful&quot; :      &quot;MPU6050 connection #0 failed&quot;);&#xA;delay(5);&#xA;&#xA;// ================= MPU: 1 =================&#xA;digitalWrite(s0, HIGH);&#xA;digitalWrite(s1, LOW);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;Wire.begin();&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;Wire.endTransmission(true);&#xA;delay(15);&#xA;mpu_1.initialize();&#xA;Serial.println(&quot;Testing device connections #1 ...&quot;);&#xA;Serial.println(mpu_1.testConnection() ? &quot;MPU6050 connection #1 successful&quot; :  &quot;MPU6050 connection #1 failed&quot;);&#xA;delay(5);&#xA;&#xA;// ================= MPU: 2 =================&#xA;digitalWrite(s0, LOW);&#xA;digitalWrite(s1, HIGH);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;Wire.begin();&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;Wire.endTransmission(true);&#xA;delay(15);&#xA;mpu_2.initialize();&#xA;Serial.println(&quot;Testing device connections #2 ...&quot;);&#xA;Serial.println(mpu_2.testConnection() ? &quot;MPU6050 connection #2 successful&quot; : &quot;MPU6050 connection #2 failed&quot;);&#xA;delay(5);&#xA;&#xA;// ================= MPU: 3 =================&#xA;digitalWrite(s0, HIGH);&#xA;digitalWrite(s1, HIGH);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;Wire.begin();&#xA;Wire.beginTransmission(MPU);&#xA;Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;Wire.endTransmission(true);&#xA;delay(15);&#xA;mpu_3.initialize();&#xA;Serial.println(&quot;Testing device connections #3 ...&quot;);&#xA;Serial.println(mpu_3.testConnection() ? &quot;MPU6050 connection #3 successful&quot; : &quot;MPU6050 connection #3 failed&quot;);&#xA;delay(5);&#xA;&#xA;// use the code below to change accel/gyro offset values&#xA;/*&#xA;Serial.println(&quot;Updating internal sensor offsets...&quot;);&#xA;// -76  -2359   1688    0   0   0&#xA;Serial.print(accelgyro.getXAccelOffset()); Serial.print(&quot;\t&quot;); // -76&#xA;Serial.print(accelgyro.getYAccelOffset()); Serial.print(&quot;\t&quot;); // -2359&#xA;Serial.print(accelgyro.getZAccelOffset()); Serial.print(&quot;\t&quot;); // 1688&#xA;Serial.print(accelgyro.getXGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(accelgyro.getYGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(accelgyro.getZGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(&quot;\n&quot;);&#xA;accelgyro.setXGyroOffset(220);&#xA;accelgyro.setYGyroOffset(76);&#xA;accelgyro.setZGyroOffset(-85);&#xA;Serial.print(accelgyro.getXAccelOffset()); Serial.print(&quot;\t&quot;); // -76&#xA;Serial.print(accelgyro.getYAccelOffset()); Serial.print(&quot;\t&quot;); // -2359&#xA;Serial.print(accelgyro.getZAccelOffset()); Serial.print(&quot;\t&quot;); // 1688&#xA;Serial.print(accelgyro.getXGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(accelgyro.getYGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(accelgyro.getZGyroOffset()); Serial.print(&quot;\t&quot;); // 0&#xA;Serial.print(&quot;\n&quot;);&#xA;*/&#xA;&#xA;// configure Arduino LED for&#xA;pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;// read raw accel/gyro measurements from device&#xA;//    accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;// these methods (and a few others) are also available&#xA;//accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;//accelgyro.getRotation(&amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;// ================= MPU: 0 =================&#xA;digitalWrite(s0, LOW);&#xA;digitalWrite(s1, LOW);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;mpu_0.getMotion6(&amp;amp;ax_0, &amp;amp;ay_0, &amp;amp;az_0, &amp;amp;gx_0, &amp;amp;gy_0, &amp;amp;gz_0);&#xA;#ifdef OUTPUT_READABLE_ACCELGYRO&#xA;    Serial.print(&quot;#0\ta/g:\t&quot;);&#xA;    Serial.print(ax_0); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(ay_0); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(az_0); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gx_0); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gy_0); Serial.print(&quot;\t&quot;);&#xA;    Serial.println(gz_0);&#xA;  #endif&#xA;  delay(5);&#xA;&#xA;// ================= MPU: 1 =================&#xA;digitalWrite(s0, HIGH);&#xA;digitalWrite(s1, LOW);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;mpu_1.getMotion6(&amp;amp;ax_1, &amp;amp;ay_1, &amp;amp;az_1, &amp;amp;gx_1, &amp;amp;gy_1, &amp;amp;gz_1);&#xA;#ifdef OUTPUT_READABLE_ACCELGYRO&#xA;    Serial.print(&quot;#1\ta/g:\t&quot;);&#xA;    Serial.print(ax_1); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(ay_1); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(az_1); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gx_1); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gy_1); Serial.print(&quot;\t&quot;);&#xA;    Serial.println(gz_1);&#xA;#endif&#xA;delay(5);&#xA;&#xA;// ================= MPU: 2 =================&#xA;digitalWrite(s0, LOW);&#xA;digitalWrite(s1, HIGH);&#xA;digitalWrite(s2, LOW);&#xA;delay(5);&#xA;mpu_2.getMotion6(&amp;amp;ax_2, &amp;amp;ay_2, &amp;amp;az_2, &amp;amp;gx_2, &amp;amp;gy_2, &amp;amp;gz_2);&#xA;#ifdef OUTPUT_READABLE_ACCELGYRO&#xA;    Serial.print(&quot;#2\ta/g:\t&quot;);&#xA;    Serial.print(ax_2); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(ay_2); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(az_2); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gx_2); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gy_2); Serial.print(&quot;\t&quot;);&#xA;    Serial.println(gz_2);&#xA;   #endif&#xA;   delay(5);&#xA;&#xA;   // ================= MPU: 3 =================&#xA;   digitalWrite(s0, HIGH);&#xA;   digitalWrite(s1, HIGH);&#xA;   digitalWrite(s2, LOW);&#xA;   delay(5);&#xA;   mpu_3.getMotion6(&amp;amp;ax_3, &amp;amp;ay_3, &amp;amp;az_3, &amp;amp;gx_3, &amp;amp;gy_3, &amp;amp;gz_3);&#xA;   #ifdef OUTPUT_READABLE_ACCELGYRO&#xA;    Serial.print(&quot;#3\ta/g:\t&quot;);&#xA;    Serial.print(ax_3); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(ay_3); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(az_3); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gx_3); Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gy_3); Serial.print(&quot;\t&quot;);&#xA;    Serial.println(gz_3);&#xA;    #endif&#xA;    delay(5);&#xA;&#xA;   //    #ifdef OUTPUT_BINARY_ACCELGYRO&#xA;     //        Serial.write((uint8_t)(ax &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(ax &amp;amp;    0xFF));&#xA;     //        Serial.write((uint8_t)(ay &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(ay &amp;amp; 0xFF));&#xA;     //        Serial.write((uint8_t)(az &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(az &amp;amp; 0xFF));&#xA;      //        Serial.write((uint8_t)(gx &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gx &amp;amp; 0xFF));&#xA;      //        Serial.write((uint8_t)(gy &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gy &amp;amp; 0xFF));&#xA;     //        Serial.write((uint8_t)(gz &amp;gt;&amp;gt; 8)); Serial.write((uint8_t)(gz &amp;amp; 0xFF));&#xA;     //    #endif&#xA;&#xA;    // blink LED to indicate activity&#xA;    blinkState = !blinkState;&#xA;    digitalWrite(LED_PIN, blinkState);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="16602" LastEditDate="2016-02-01T04:45:41.987" LastActivityDate="2016-02-02T04:36:49.043" Title="Multiple MPU9250 using Multiplexer" Tags="|arduino-mega|mpu6050|multiplexer|" AnswerCount="1" CommentCount="16" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20189" PostTypeId="1" CreationDate="2016-02-01T04:16:28.920" Score="0" ViewCount="5281" Body="&lt;p&gt;I recently got to work with Arduino and I want to get parallel input from 5 LDRs and at the same instance I need to light a LED corresponding to that LDR if the resistance got high. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about a finite state machine, but I couldn't understand how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it the only way for this type of problem or are there any other way? &lt;/p&gt;&#xA;" OwnerUserId="16910" LastEditorUserId="6936" LastEditDate="2016-02-01T06:31:35.850" LastActivityDate="2016-02-01T12:36:22.687" Title="Can I do parallel processing in Arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20190" PostTypeId="1" CreationDate="2016-02-01T04:50:38.907" Score="6" ViewCount="659" Body="&lt;p&gt;I am rewriting a set of LED manipulation functions to be more object oriented, and I have found that, mysteriously, my global variable memory space has been over consumed, despite a reduction of the use of global variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I played around with a number of things, and found something curious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a fragment of a function that does not live in an object, and is called directly from &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Animation *getNewAnim(int index)&#xA;{&#xA;    switch(index)&#xA;    {&#xA;        case 0:&#xA;            return new RedClouds();&#xA;        case 1:&#xA;            return new TwoLayerClouds();&#xA;        case 2:&#xA;            return new LavaLamp1();&#xA;        case 3:&#xA;            return new Bubbles1();&#xA;&#xA;        ...  (20 or so more cases)&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a function that lets me switch between display modes based on the value of &lt;code&gt;index&lt;/code&gt;.  Only one of these objects is ever created at a given time; I delete the old one before calling this, so there will never be multiple instances in use simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the curious thing is that if I remove a few of these return statements, collapsing the block into something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Animation *getNewAnim(int index)&#xA;{&#xA;    switch(index)&#xA;    {&#xA;        case 0:&#xA;        case 1:&#xA;        case 2:&#xA;        case 3:&#xA;            return new Bubbles1();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The amount of global memory space used falls considerably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My hypothesis is that the Arduino build environment is pre-allocating space for each of these objects in the global memory space before the program is even run, rather than doing so dynamically as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my hypothesis correct?  And if so, is there any way to tell the build environment not to do this, as I'd rather use the same memory for my new object that was used by the old one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify: When I build I see this sort of output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 6,550 bytes (21.3%) of program storage space. Maximum is 30,720 bytes.&#xA;Global variables use 1,167 bytes (57.0%) of dynamic memory, leaving 881 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I refer to &quot;global memory&quot; I am referring to the Global variables number on that output.  I'll also note that when I compile with the second example, the program storage space reported also falls dramatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NEW HYPOTHESIS&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I think may be going on.  When I omit the classes from the switch statement, the compiler seems to optimize them out of the codebase, which is what I expect, and is consistent with seeing the program storage space shrink.  Each class has a method that returns it's name.  This method contains an embedded string, and I now believe that this string is stored in the global variable space.  Therefore, if the class is included, more global variable space is consumed to hold the name, and if it is optimized out, less is consumed.  This theory is consistent with all the facts I have, and makes more sense than my previous hypothesis.&lt;/p&gt;&#xA;" OwnerUserId="16911" LastEditorUserId="16911" LastEditDate="2016-02-01T07:24:20.120" LastActivityDate="2023-07-18T13:23:54.533" Title="Understanding global variables on Arduino" Tags="|c++|memory-usage|build|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="20191" PostTypeId="2" ParentId="20126" CreationDate="2016-02-01T06:40:46.047" Score="1" Body="&lt;p&gt;You can implement PWM using digital pins by turning the pin on and off with respect to your duty cycle, because PWM (Pulse Width Modulation) depends upon the duty cycle the % amount during which the pin is HIGH or LOW&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let say pin 13 of arduino is connected to your l293D enable pin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample Code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void setup()&#xA;{&#xA;  pinMode(13, OUTPUT);&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void loop()&#xA;{&#xA;  digitalWrite(13, HIGH);&#xA;  delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz&#xA;  digitalWrite(13, LOW);&#xA;  delayMicroseconds(1000 - 100);&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details are also on Arduino Help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-02-01T06:40:46.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20196" PostTypeId="2" ParentId="18329" CreationDate="2016-02-01T07:49:27.420" Score="0" Body="&lt;p&gt;You connect your different sensors or devices to many slave arduinos and each slave arduino has its own bluwtooth module that send the data to Master Arduino that contains the Bluetooth and GSM Module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes you can connect max 7 bluetooth devices to 1 Bluetooth module at a time so in that manner you can connect 7 slave devices to Master Arduino&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-02-01T07:49:27.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20198" PostTypeId="1" AcceptedAnswerId="20202" CreationDate="2016-02-01T08:58:56.670" Score="0" ViewCount="4146" Body="&lt;p&gt;I am using a GSM module sim800. My module responds to the output given by my PIR sensor and sends sms according to it. My module has got +5V, GND, Rx and Tx pins. What are the pin connections that I have to make?&lt;/p&gt;&#xA;" OwnerUserId="16336" LastEditorUserId="16336" LastEditDate="2016-02-01T09:26:02.610" LastActivityDate="2017-12-14T20:36:53.637" Title="Using Rx and Tx pins(0 and 1) on Arduino Uno for GSM" Tags="|arduino-uno|sensors|gsm|sketch|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20200" PostTypeId="2" ParentId="20189" CreationDate="2016-02-01T09:57:19.833" Score="2" Body="&lt;p&gt;You do not need parallel processing or finite-state machines for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Vector with digital pin numbers for LEDs (with resistor to ground)&#xA;const int LED_MAX = 5;&#xA;const int LED[LED_MAX] = { 2, 3, 4, 5, 6 };&#xA;&#xA;// Vector with analog pin numbers for LDR (with pullup resistor)&#xA;const int LDR_MAX = 5;&#xA;const int LDR[LDR_MAX] = { A0, A1, A2, A3, A4 };&#xA;&#xA;// Analog value or lower when to light the LED&#xA;const int THRESHOLD = 200;&#xA;&#xA;void setup()&#xA;{&#xA;   // All LED pins should be digital output pins&#xA;   for (int i = 0; i &amp;lt; LED_MAX; i++) &#xA;     pinMode(LED[i], OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   // Read all LDRs and set LED pins according to threshold&#xA;   for (int i = 0; i &amp;lt; LDR_MAX; i++)&#xA;     digitalWrite(LED[i], analogRead(LDR[i]) &amp;lt; THRESHOLD);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if you really want to describe this as multiple tasks you could use the &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow&quot;&gt;Simple Scheduler library&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;&#xA;const int THRESHOLD = 200;    &#xA;&#xA;template&amp;lt;int LED&amp;gt; void setup()&#xA;{&#xA;   pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;template&amp;lt;int LED, int LDR&amp;gt; void loop()&#xA;{&#xA;   digitalWrite(LED, analogRead(LDR) &amp;lt; THRESHOLD);&#xA;   yield();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;   Scheduler.start(setup&amp;lt;2&amp;gt;, loop&amp;lt;2, A0&amp;gt;);&#xA;   Scheduler.start(setup&amp;lt;3&amp;gt;, loop&amp;lt;3, A1&amp;gt;);&#xA;   Scheduler.start(setup&amp;lt;4&amp;gt;, loop&amp;lt;4, A2&amp;gt;);&#xA;   Scheduler.start(setup&amp;lt;5&amp;gt;, loop&amp;lt;5, A3&amp;gt;);&#xA;   Scheduler.start(setup&amp;lt;6&amp;gt;, loop&amp;lt;6, A4&amp;gt;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   yield();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-01T12:36:22.687" LastActivityDate="2016-02-01T12:36:22.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20201" PostTypeId="2" ParentId="20198" CreationDate="2016-02-01T10:38:43.957" Score="0" Body="&lt;p&gt;You have a choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Always:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GND =&gt; GND&lt;/li&gt;&#xA;&lt;li&gt;+5V =&gt; +5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then, either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TX =&gt; RX (0)&lt;/li&gt;&#xA;&lt;li&gt;RX =&gt; TX (1) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and use the hardware UART &quot;Serial&quot;, but that then means that uploading new code to your Arduino becomes an arduous task since the usage pins 0 and 1 will interfere with that.  So the other option:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TX =&gt; Any pin&lt;/li&gt;&#xA;&lt;li&gt;RX =&gt; Any pin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And then use &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; to set up a secondary &quot;bit banged&quot; serial port on the two pins you choose.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-01T10:38:43.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20202" PostTypeId="2" ParentId="20198" CreationDate="2016-02-01T10:41:16.600" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My module has got +5V, GND, Rx and Tx pins. What are the pin connections that I have to make?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;TX =&gt; RX, RX =&gt; TX, that is Arduino TX to module RX, and TX to module RX. If you want to use &lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;Serial&lt;/a&gt; the pins are 0 for Arduino RX, and 1 for Arduino TX. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerialConstructor&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; you decide which pins to use (check the documentation for valid pins on your board).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Use software serial with pin 2 for rx and pin 3 for tx&#xA;SoftwareSerial gsm(2,3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-01T10:41:16.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20203" PostTypeId="2" ParentId="20172" CreationDate="2016-02-01T10:46:44.330" Score="1" Body="&lt;p&gt;Personally I would wrap all serial reading and writing in my own functions which, as well as doing the reading and writing, turn on an LED on any chosen GPIO and set a timer variable which is then used in the main loop to turn the LEDs off after a short period (otherwise they flicker too fast to be properly seen).  Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t readLedTimer = 0;&#xA;&#xA;// Call instead of Serial.read();&#xA;int mySerialRead() {&#xA;    if (Serial.available()) {&#xA;        digitalWrite(13, HIGH);&#xA;        readLedTimer = millis();&#xA;        return Serial.read();&#xA;    }&#xA;    return -1;&#xA;}&#xA;&#xA;// Call from loop();&#xA;void cancelLeds() {&#xA;    if ((readLedTimer &amp;gt; 0) &amp;amp;&amp;amp; (millis() - readLedTimer &amp;gt; 20)) {&#xA;        readLedTimer = 0;&#xA;        digitalWrite(13, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, replicate (with a different LED) for the any Serial.write or Serial.print functions you may want to do (use may use &lt;em&gt;overloading&lt;/em&gt; to pass different variable types to similar functions).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to directly modify the serial reading and writing routines within the Arduino AVR core to do the same thing, but that gets rather tricky when you update the IDE or want other people to use your code to build these widgets of yours.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-01T10:46:44.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20206" PostTypeId="1" CreationDate="2016-02-01T13:11:23.607" Score="1" ViewCount="557" Body="&lt;p&gt;As mentioned in the title I'm facing a problem in printing strings in the LCD. It's printing actually weird characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;void setup() {&#xA;  lcd.begin(16, 2);&#xA;  Serial.begin(9600);&#xA;&#xA;  lcd.print(&quot;hello, world!&quot;); &#xA;}&#xA;void loop() {&#xA;&#xA;&#xA; lcd.setCursor(0, 1);&#xA;  lcd.print(millis()/500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find the output of the LCD in the picture below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RbpMc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RbpMc.jpg&quot; alt=&quot;LCD error !!&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16926" LastEditorUserId="6936" LastEditDate="2016-02-02T06:34:33.840" LastActivityDate="2016-12-11T17:46:42.353" Title="LCD is not printing strings, only integers with Arduino" Tags="|arduino-uno|serial|programming|arduino-ide|lcd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20208" PostTypeId="1" AcceptedAnswerId="20209" CreationDate="2016-02-01T13:37:11.323" Score="0" ViewCount="75" Body="&lt;p&gt;I had attatched a GSM module to my arduino Uno board. The power had been switched on. The GSM 5V pin was connected to my board. I was still midway with my work so for some reason I gave an external power supply to my GSM module. Now smoke started coming out of my Uno board and a burning smell came from it. I immediately switched off the power supply. But now I am unable to burn sketches to my Arduino. It is showing error: Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&#xA;On opening the serial monitor it says: Board at COM3 not detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link from wher I bought the GSM module: &lt;a href=&quot;http://www.ebay.in/itm/GSM-Module-SIM800-Quadband-better-than-SIM-900-or-SIM900A-Modem-with-SMA-Antenna-/252053758680?hash=item3aaf9322d8&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.in/itm/GSM-Module-SIM800-Quadband-better-than-SIM-900-or-SIM900A-Modem-with-SMA-Antenna-/252053758680?hash=item3aaf9322d8&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16336" LastEditorUserId="16336" LastEditDate="2016-02-01T14:12:53.320" LastActivityDate="2016-02-01T14:19:16.133" Title="Problem with my arduino board" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20209" PostTypeId="2" ParentId="20208" CreationDate="2016-02-01T14:00:27.280" Score="1" Body="&lt;p&gt;Oops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You let the &lt;a href=&quot;https://en.wikipedia.org/wiki/Magic_smoke&quot; rel=&quot;nofollow&quot;&gt;Magic Smoke™&lt;/a&gt; escape from your Arduino.  Your Arduino is now somewhat dead.  Depending on &lt;em&gt;what&lt;/em&gt; died it may be repairable by replacing components, or it may be beyond resurrection and it'll be easier to buy a new one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now - why did it happen?  Looking at the board in your link it should have been OK with the 12V power you provided, since it has its own regulator on board that can supposedly take up to 12V.  So one of two things may have happened:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What you thought was 12V was actually higher than 12V and the regulator didn't cope with it.&lt;/li&gt;&#xA;&lt;li&gt;You connected the power backwards, so -12V was pumped straight through everything.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There seems to be no polarity protection on the board as far as I can see, and many regulators, if connected backwards, will just pass the power straight through with little or no change to it.  So my money is on having connected the power backwards.  Now, that might not be your fault, since on that site I can see no mention of which polarity the power connector uses - whether it is pin-positive or pin-negative.  The normal way (the way the Arduino board uses) is pin-positive, but that is not always the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, the Arduino is now dead, and the GSM module may be dead as well. In fact the whole lot may be dead.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-02-01T14:19:16.133" LastActivityDate="2016-02-01T14:19:16.133" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="20210" PostTypeId="1" AcceptedAnswerId="20216" CreationDate="2016-02-01T15:30:03.227" Score="1" ViewCount="16905" Body="&lt;p&gt;I wanted to know if my GSM sim800 is working or not. A mishap occured while I was experimenting around with my GSM module and I arduino uno. The link to the module which I bought: &lt;a href=&quot;http://www.ebay.in/itm/SIM800-Quad-Band-GSM-Module-with-SMA-Antenna-Better-than-SIM900A-or-SIM900-/301782413058?hash=item4643a22f02:g:8LsAAOSwwbdWMidW&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.in/itm/SIM800-Quad-Band-GSM-Module-with-SMA-Antenna-Better-than-SIM900A-or-SIM900-/301782413058?hash=item4643a22f02:g:8LsAAOSwwbdWMidW&lt;/a&gt; I want to know ow can I check if my module is fine?&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2018-08-06T08:27:01.180" Title="How to check if a GSM module is working or not?" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20211" PostTypeId="2" ParentId="8917" CreationDate="2016-02-01T15:46:07.053" Score="2" Body="&lt;p&gt;The Dout is a TTL threshold indicator; basically it goes high when a certain threshold of the sensor is reached, which is adjusted by the pot.  The Aout is the VRef of the sensor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the MG-811 is not the best sensor in the world; I did look at the &lt;a href=&quot;http://www.dfrobot.com/image/data/SEN0159/CO2b%20MG811%20datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; which shows this sensor outputs mV in relation to the PPM so a map function could be used such as 100-600mV maps to 400-10000ppm CO2, see &lt;a href=&quot;http://sandboxelectronics.com/?p=147&quot; rel=&quot;nofollow&quot;&gt;MG-811 CO2 Sensor Module&lt;/a&gt;, so you could feed this into a &lt;code&gt;map()&lt;/code&gt; function and get the result but since there is a signal conditioning circuit consisting of a op-amp I'm not sure what it does to the raw sensor voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the sandbox electronics module may not be identical to the SainSmart module, so you may need to reverse engineer the module you have to determine what is going on or use the schematic from the sandbox site to build your own and de-solder the MG-811 from the SainSmart module.&lt;/p&gt;&#xA;" OwnerUserId="16888" LastEditorUserId="6936" LastEditDate="2016-02-02T06:25:58.757" LastActivityDate="2016-02-02T06:25:58.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20212" PostTypeId="2" ParentId="13676" CreationDate="2016-02-01T16:23:42.767" Score="1" Body="&lt;p&gt;You could use a &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow&quot;&gt;scheduler&lt;/a&gt; and simply start tasks with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;...&#xA;void setup()&#xA;{&#xA;  ...&#xA;  Scheduler.start(servoSetup, servoLoop);&#xA;  Scheduler.start(sensorSetup, sensorLoop);&#xA;  ...&#xA;}&#xA;&#xA;void servoSetup()&#xA;{&#xA;  S.attach(servo);&#xA;}&#xA;&#xA;void servoLoop()&#xA;{&#xA;  int angle;&#xA;  for(angle = 0;angle &amp;lt;= 180; angle++) { &#xA;    S.write(angle); &#xA;    if (angle == 90) {&#xA;      delay(2000);&#xA;    }&#xA;  }&#xA;  delay(2000);&#xA;  ...&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tasks must call &lt;em&gt;yield()&lt;/em&gt; or &lt;em&gt;delay()&lt;/em&gt; to context switch. The &lt;em&gt;taskSetup&lt;/em&gt; function is called first and once by the task. The &lt;em&gt;taskLoop&lt;/em&gt; function is repeatedly called by the task. This can be viewed as running an additional sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see the &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler/tree/master/examples&quot; rel=&quot;nofollow&quot;&gt;example sketches&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-01T18:08:33.650" LastActivityDate="2016-02-01T18:08:33.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20216" PostTypeId="2" ParentId="20210" CreationDate="2016-02-01T19:59:15.757" Score="1" Body="&lt;p&gt;Power it up and check the 'status' light.  If it blinks with a 1 blink per second cycle, it is attempting to connect to the network.  If it connects, it does a slow blink at 1 blink/3s, it made the network connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if your board does an auto-power-on, but you might need to push the power button or reset button.  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-01T19:59:15.757" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20218" PostTypeId="1" AcceptedAnswerId="20349" CreationDate="2016-02-01T21:01:18.880" Score="0" ViewCount="926" Body="&lt;p&gt;I have 4 dot matrix displays, every one of them connected to an i2c and accessible with &lt;code&gt;0x70&lt;/code&gt;, &lt;code&gt;0x71&lt;/code&gt;, &lt;code&gt;0x72&lt;/code&gt; and &lt;code&gt;0x73&lt;/code&gt;. All these work just fine when I address them apart. What I want to achieve is a scrolling text throughout all 4 displays. How can I do this? Are there any libraries around that already do this? (I did not find any).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, this is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_LEDBackpack.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;&#xA;Adafruit_8x8matrix matrix[4];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;4x(8x8) LED Matrix Test&quot;);&#xA;  matrix[0].begin(0x70);&#xA;  matrix[1].begin(0x71);&#xA;  matrix[2].begin(0x72);&#xA;  matrix[3].begin(0x73);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16940" LastActivityDate="2016-02-05T09:55:13.800" Title="scroll text through multiple i2c connected dot matrix displays" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20219" PostTypeId="1" AcceptedAnswerId="20220" CreationDate="2016-02-01T21:49:41.693" Score="4" ViewCount="16316" Body="&lt;p&gt;Uploading a sketch to an ESP8266 board fails with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: failed reading byte&#xA;warning: espcomm_send_command: can't receive slip payload data&#xA;warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;espcomm cmd: receiving 2 bytes of data&#xA;warning: espcomm cmd: no final C0&#xA;warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is on OS X with a PL2303HXD USB-to-Serial cable, using the latest official Prolific signed &lt;a href=&quot;http://prolificusa.com/pl-2303hx-drivers/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OS X El Capitan-compatible drivers&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16852" LastEditorUserId="4628" LastEditDate="2017-01-18T15:55:59.023" LastActivityDate="2017-01-18T15:55:59.023" Title="Upload with esptool fails with &quot;espcomm_send_command: can't receive slip payload data&quot;" Tags="|uploading|esp8266|osx|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20220" PostTypeId="2" ParentId="20219" CreationDate="2016-02-01T21:49:41.693" Score="4" Body="&lt;p&gt;This is &lt;a href=&quot;https://github.com/igrr/esptool-ck/issues/9&quot; rel=&quot;nofollow&quot;&gt;a known issue&lt;/a&gt; with &lt;a href=&quot;https://github.com/igrr/esptool-ck&quot; rel=&quot;nofollow&quot;&gt;the included esptool&lt;/a&gt;, and for the Arduino IDE there are quite a few blog posts to be found on this problem. But most are outdated, and are not applicable when using &lt;a href=&quot;http://platformio.org&quot; rel=&quot;nofollow&quot;&gt;PlatformIO&lt;/a&gt; with some other IDE. So, February 2016:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Install &lt;a href=&quot;https://github.com/themadinventor/esptool&quot; rel=&quot;nofollow&quot;&gt;esptool.py&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;git clone https://github.com/themadinventor/esptool/&lt;/code&gt; (or download the ZIP file)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;cd esptool&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo python setup.py install&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When using Arduino IDE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open &lt;code&gt;~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.0.0/platform.txt&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Find the line &lt;code&gt;tools.esptool.upload.pattern&lt;/code&gt; and disable that by prefixing with a hash. Check that your version only mentions &lt;code&gt;-ca 0x00000&lt;/code&gt;, not &lt;code&gt;-ca 0x10000&lt;/code&gt; as well (like in most outdated blog posts):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# tools.esptool.upload.pattern=&quot;{path}/{cmd}&quot; {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp &quot;{serial.port}&quot; -ca 0x00000 -cf &quot;{build.path}/{build.project_name}.bin&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add the following, referring to the &lt;code&gt;esptool.py&lt;/code&gt; you installed above and also using different command line parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Fix for espcomm_send_command: cant receive slip payload data&#xA;tools.esptool.upload.pattern=&quot;/path/to/new/esptool.py&quot; --port &quot;{serial.port}&quot; --baud {upload.speed} write_flash 0x00000 &quot;{build.path}/{build.project_name}.bin&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart the IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(One might be tempted to just change &lt;code&gt;tools.esptool.path&lt;/code&gt; and &lt;code&gt;tools.esptool.cmd&lt;/code&gt; instead, but beware that the command line parameters need changing as well.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;When using PlatformIO&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will find the same &lt;code&gt;platform.txt&lt;/code&gt; file somewhere in &lt;code&gt;~/.platformio/packages/framework-arduinoespressif/platform.txt&lt;/code&gt;, but that file is not used for the upload. &lt;a href=&quot;https://github.com/platformio/platformio/issues/426&quot; rel=&quot;nofollow&quot;&gt;Instead&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;In &lt;code&gt;platformio.ini&lt;/code&gt; add:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# ...or whatever your port is named&#xA;upload_port = /dev/cu.usbserial&#xA;extra_script = /path/to/platformio_extra_script.py&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create a new file &lt;code&gt;/path/to/platformio_extra_script.py&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# Custom settings, as referred to as &quot;extra_script&quot; in platformio.ini&#xA;#&#xA;# See http://docs.platformio.org/en/latest/projectconf.html#extra-script&#xA;# See https://github.com/platformio/platformio/issues/426&#xA;&#xA;from SCons.Script import DefaultEnvironment&#xA;&#xA;env = DefaultEnvironment()&#xA;&#xA;# Must be full path, or use&#xA;# https://docs.python.org/2/library/os.path.html#os.path.expanduser&#xA;&#xA;env.Replace(&#xA;    LOCAL_UPLOADER=&quot;/Users/arjan/path/to/new/esptool.py&quot;,&#xA;    LOCAL_UPLOADERFLAGS=[&#xA;        &quot;--port&quot;, &quot;$UPLOAD_PORT&quot;,&#xA;        &quot;--baud&quot;, &quot;$UPLOAD_SPEED&quot;,&#xA;        &quot;write_flash&quot;, &quot;0x00000&quot;,&#xA;    ],&#xA;    UPLOADCMD='$LOCAL_UPLOADER $LOCAL_UPLOADERFLAGS $SOURCE'&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16852" LastEditorUserId="16852" LastEditDate="2016-04-24T14:55:10.440" LastActivityDate="2016-04-24T14:55:10.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20222" PostTypeId="2" ParentId="8559" CreationDate="2016-02-01T23:29:37.990" Score="1" Body="&lt;p&gt;This thread, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=215107.0&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE and ESET: Slow compilation&lt;/a&gt;, may be helpful if you use ESET (at least one user has reported that it helped), but it didn't help me since I'm using Comodo (and may be there are some other reasons).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's another thread, &lt;a href=&quot;http://www.johngineer.com/blog/?p=97&quot; rel=&quot;nofollow&quot;&gt;SLOW ARDUINO IDE&lt;/a&gt; regarding a solution which helped many users, since 2009 (the latest comment on the forum is dated year 2014).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several useful posts here as well, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=82527.15&quot; rel=&quot;nofollow&quot;&gt;Unbelievable slow compilation of simple sketches&lt;/a&gt;. Ok, I haven't tested all the solutions myself, but let me collect useful links here so that other guys can find them and I'll check them out, too. &lt;/p&gt;&#xA;" OwnerUserId="16944" LastEditorUserId="6936" LastEditDate="2016-02-02T06:29:30.790" LastActivityDate="2016-02-02T06:29:30.790" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20223" PostTypeId="1" AcceptedAnswerId="20224" CreationDate="2016-02-02T00:38:48.073" Score="1" ViewCount="1640" Body="&lt;p&gt;I am powering a UNO through the 5V pin. I am using a tftlcd shield (2.8&quot; mcufriend.com) on it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be able to use the shield with I2C I had to snip the RST leg from the shield. That was done because the shield used A4 which was required for I2C.&#xA; When I power the UNO through the USB port the program starts correctly and a bitmap is loaded onto the screen. When I power up from the 5V pin or the power adapter, the screen remains white. I have to manually press the reset button on the UNO and then the program loads the bitmap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ladyAda examples had this to say;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LCD_CS A3 // Chip Select goes to Analog 3&#xA;#define LCD_CD A2 // Command/Data goes to Analog 2&#xA;#define LCD_WR A1 // LCD Write goes to Analog 1&#xA;#define LCD_RD A0 // LCD Read goes to Analog 0&#xA;#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin&#xA;Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does that mean I should solder the lcd RST pin to the RESET on the UNO? (if so I am not sure how I can do that without taking the lcd shield to pieces).&lt;/p&gt;&#xA;" OwnerUserId="13330" LastEditorUserId="13330" LastEditDate="2016-02-02T11:36:36.920" LastActivityDate="2016-02-02T20:35:18.387" Title="Manual reset is required on power on" Tags="|power|lcd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20224" PostTypeId="2" ParentId="20223" CreationDate="2016-02-02T01:25:37.653" Score="1" Body="&lt;p&gt;It isn't clear from the description whether your setup has a hardware problem or a software problem.  For example, the rationale for “I had to snip the RST leg from the shield” is unclear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The comment in ladyAda's example, “Can alternately just connect to Arduino's reset pin”, means that it's suitable to hardware-reset the LCD at the same time the Arduino does a hardware reset.  If the “RST leg from the shield” that you snipped is the LCD reset pin, as opposed to a pin driven by the small tactile reset switch on the 2.8&quot; mcufriend shield, you probably should restore that pin.  In other words, unsolder and remove the stub of the pin you snipped off, insert a new pin, and solder it in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, just reinstalling the pin might make things work.  It's possible the LCD is sitting there in a permanently-reset  state, due to its RST input hanging open.  It's also possible the library is already driving RST properly but that drive isn't getting through, due to the missing pin.  Whatever the case may be, with the pin in place you should be able to software-reset the LCD by pulsing A4.  (Ie, with consecutive &lt;code&gt;digitalWrite()&lt;/code&gt; commands, in &lt;code&gt;setup()&lt;/code&gt; and before shield initialization, take A4 high and then low, or vice versa.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; If A4 isn't available for resetting the LCD (due to its use as the SDA signal for I2C, per comment) you might try adding a jumper wire from the shield's LCD_RS pin (above A4) to an available pin, and adjust the &lt;code&gt;#define LCD_RESET&lt;/code&gt; statement accordingly.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, to add a jumper wire, strip about 5 mm of each end of a short piece of #30 &lt;a href=&quot;https://en.wikipedia.org/wiki/Wire_wrap&quot; rel=&quot;nofollow&quot;&gt;wire-wrap&lt;/a&gt; wire.  Form a small hook at each end.  Hold a hook onto the solder of the pin you wish to attach to and briefly heat the solder, letting the hook sink into the solder.  If you don't have wire-wrap wire, use a single strand from some old stranded cable (eg, mouse or keyboard).  Use thin heatshrink tubing or a bit of stripped-off cable insulation to insulate the jumper.  To keep pins in place while soldering, seat the pins being worked on into an old disk-drive connector, or another shield, or if you have nothing else, an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case, an mcufriend shield on an Uno, no pins are available unless you co-opt one of the SD-card-slot signals.  But before doing that, it's probably worthwhile to try your original idea of wiring to the Uno's RESET pin.  Your jumper would run from J3's second pin (A4) to J4's last pin (Reset), installed on the LCD side of the shield.  You should be able to see the trace between the Reset pin and the Reset switch, when identifying the Reset pin.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-02T20:35:18.387" LastActivityDate="2016-02-02T20:35:18.387" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20225" PostTypeId="2" ParentId="20188" CreationDate="2016-02-02T04:21:59.777" Score="1" Body="&lt;p&gt;Your concept sounded sensible enough so I gave it a try-out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ip60w.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ip60w.png&quot; alt=&quot;Multiplexed I2C&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First point is: The master always generates the clock so we don't need to multiplex that. We only need to multiplex the data (SDA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code snippet:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// the multiplexer address select lines (A/B/C)&#xA;const byte addressA = 6; // low-order bit&#xA;const byte addressB = 5;&#xA;const byte addressC = 4; // high-order bit&#xA;&#xA;int selectTarget (const byte which)&#xA;  {&#xA;  // select correct MUX channel&#xA;  digitalWrite (addressA, (which &amp;amp; 1) ? HIGH : LOW);  // low-order bit&#xA;  digitalWrite (addressB, (which &amp;amp; 2) ? HIGH : LOW);&#xA;  digitalWrite (addressC, (which &amp;amp; 4) ? HIGH : LOW);  // high-order bit&#xA;  }  // end of readSensor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All you have to do is call &lt;code&gt;selectTarget(n)&lt;/code&gt; where &lt;code&gt;n&lt;/code&gt; is 0 to 7, and you redirect SDA to the desired chip. I suggest a 4.7k pull-up on the target side so that the line is pulled high when not selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it out and it seems to work OK.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The beauty of this setup is that you can multiplex 8 devices (eg. sensors) which happen to have the same I2C address, with only one additional chip. And, you can get 16-channel multiplexers if you want to take this further. Of course, in the code you still have to select the correct I2C address for the chip.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-02T04:36:49.043" LastActivityDate="2016-02-02T04:36:49.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20226" PostTypeId="1" AcceptedAnswerId="20227" CreationDate="2016-02-02T05:49:15.387" Score="0" ViewCount="597" Body="&lt;p&gt;I would like to upload my code to the Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The USB is fried hence I have to use the FTDI&lt;/li&gt;&#xA;&lt;li&gt;I've a FTDI cable, but it has only 4 wires, Vcc,GND,TX,RX&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How do you upload, as the ATmega is not responding to anything?&lt;/p&gt;&#xA;" OwnerUserId="16952" LastEditorUserId="6936" LastEditDate="2016-02-02T06:35:51.590" LastActivityDate="2019-06-20T01:34:35.410" Title="Upload Code on Arduino Mega using FTDI Cable" Tags="|arduino-mega|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20227" PostTypeId="2" ParentId="20226" CreationDate="2016-02-02T05:57:28.827" Score="0" Body="&lt;p&gt;FTDI cables usually have RTS which is used to bring &lt;code&gt;Reset&lt;/code&gt; low. If you only have four pins, press the Reset button on the board the moment you start the upload.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-02T05:57:28.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20228" PostTypeId="1" CreationDate="2016-02-02T07:36:09.467" Score="0" ViewCount="2169" Body="&lt;p&gt;The code below works fine when  one IMU (MPU9250). What I want to know is how can I edit this code to work perfectly with two IMU (MPU9250) in one arduino board ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can help me. THANKS :)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;////////////////////////////////////////////////////////////////////////////&#xA;      //&#xA;      //  This file is part of RTIMULib-Arduino&#xA;      //&#xA;      //  Copyright (c) 2014-2015, richards-tech&#xA;     //&#xA;     //  Permission is hereby granted, free of charge, to any person           obtaining a copy of &#xA;    //  this software and associated documentation files (the &quot;Software&quot;), to deal in &#xA;    //  the Software without restriction, including without limitation the rights to use, &#xA;   //  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the &#xA;   //  Software, and to permit persons to whom the Software is furnished to do so, &#xA;   //  subject to the following conditions:&#xA;   //&#xA;   //  The above copyright notice and this permission notice shall be included in all &#xA;  //  copies or substantial portions of the Software.&#xA;  //&#xA;  //  THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, &#xA;  //  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A &#xA;  //  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT &#xA;  //  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION &#xA;  //  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE &#xA;  //  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&#xA;&#xA;  #include &amp;lt;Wire.h&amp;gt;&#xA;  #include &quot;I2Cdev.h&quot;&#xA;  #include &quot;RTIMUSettings.h&quot;&#xA;  #include &quot;RTIMU.h&quot;&#xA;  #include &quot;RTFusionRTQF.h&quot; &#xA;  #include &quot;RTPressure.h&quot;&#xA;  #include &quot;CalLib.h&quot;&#xA;  #include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;  RTIMU *imu;                                           // the IMU object&#xA;  RTPressure *pressure;                                 // the pressure object&#xA;  RTFusionRTQF fusion;                                  // the fusion object&#xA;  RTIMUSettings settings;                               // the settings object&#xA;&#xA;  //  DISPLAY_INTERVAL sets the rate at which results are displayed&#xA;&#xA;  #define DISPLAY_INTERVAL  300                         // interval between   pose displays&#xA;&#xA; //  SERIAL_PORT_SPEED defines the speed to use for the debug serial port&#xA;&#xA; #define  SERIAL_PORT_SPEED  115200&#xA;&#xA;  unsigned long lastDisplay;&#xA;  unsigned long lastRate;&#xA;  int sampleCount;&#xA;&#xA;  void setup()&#xA;  {&#xA;  int errcode;&#xA;&#xA;  Serial.begin(SERIAL_PORT_SPEED);&#xA;  Wire.begin();&#xA;  imu = RTIMU::createIMU(&amp;amp;settings);                        // create the    imu object&#xA;  pressure = RTPressure::createPressure(&amp;amp;settings);         // create the  pressure sensor&#xA;&#xA;  if (pressure == 0) {&#xA;  Serial.println(&quot;No pressure sensor has been configured - terminating&quot;); &#xA;    while (1) ;&#xA;   }&#xA;&#xA;   Serial.print(&quot;ArduinoIMU10 starting using IMU &quot;); Serial.print(imu-   &amp;gt;IMUName());&#xA;   Serial.print(&quot;, pressure sensor &quot;); Serial.println(pressure-&amp;gt;pressureName());&#xA;   if ((errcode = imu-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA;   Serial.print(&quot;Failed to init IMU: &quot;); Serial.println(errcode);&#xA;   }&#xA;&#xA;   if ((errcode = pressure-&amp;gt;pressureInit()) &amp;lt; 0) {&#xA;   Serial.print(&quot;Failed to init pressure sensor: &quot;);  &#xA;   Serial.println(errcode);&#xA;   }&#xA;&#xA;   if (imu-&amp;gt;getCalibrationValid())&#xA;   Serial.println(&quot;Using compass calibration&quot;);&#xA;   else&#xA;   Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&#xA;    lastDisplay = lastRate = millis();&#xA;    sampleCount = 0;&#xA;&#xA;    // Slerp power controls the fusion and can be between 0 and 1&#xA;    // 0 means that only gyros are used, 1 means that only accels/compass are used&#xA;   // In-between gives the fusion mix.&#xA;&#xA;   fusion.setSlerpPower(0.02);&#xA;&#xA;   // use of sensors in the fusion algorithm can be controlled here&#xA;   // change any of these to false to disable that sensor&#xA;&#xA;    fusion.setGyroEnable(true);&#xA;    fusion.setAccelEnable(true);&#xA;    fusion.setCompassEnable(true);&#xA;    }&#xA;&#xA;     void loop()&#xA;     {  &#xA;     unsigned long now = millis();&#xA;     unsigned long delta;&#xA;     float latestPressure;&#xA;     float latestTemperature;&#xA;     int loopCount = 1;&#xA;&#xA;      while (imu-&amp;gt;IMURead()) {                                // get the latest data if ready yet&#xA;      // this flushes remaining data in case we are falling behind&#xA;      if (++loopCount &amp;gt;= 10)&#xA;         continue;&#xA;&#xA;      fusion.newIMUData(imu-&amp;gt;getGyro(), imu-&amp;gt;getAccel(), imu-&amp;gt;getCompass(), imu-&amp;gt;getTimestamp());&#xA;      sampleCount++;&#xA;      if ((delta = now - lastRate) &amp;gt;= 1000) {&#xA;      Serial.print(&quot;Sample rate: &quot;); Serial.print(sampleCount);&#xA;      if (imu-&amp;gt;IMUGyroBiasValid())&#xA;      Serial.println(&quot;, gyro bias valid&quot;);&#xA;      else&#xA;      Serial.println(&quot;, calculating gyro bias&quot;);&#xA;&#xA;        sampleCount = 0;&#xA;        lastRate = now;&#xA;       }&#xA;       if ((now - lastDisplay) &amp;gt;= DISPLAY_INTERVAL) {&#xA;        lastDisplay = now;&#xA;       //          RTMath::display(&quot;Gyro:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getGyro());  &#xA;                  // gyro data&#xA;        //          RTMath::display(&quot;Accel:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getAccel()); &#xA;                     // accel data&#xA;       //          RTMath::display(&quot;Mag:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getCompass());  &#xA;          // compass data&#xA;        RTMath::displayRollPitchYaw(&quot;Pose:&quot;,   (RTVector3&amp;amp;)fusion.getFusionPose()); // fused output&#xA;&#xA;        if (pressure-&amp;gt;pressureRead(latestPressure, latestTemperature)) {&#xA;            Serial.print(&quot;, pressure: &quot;); Serial.print(latestPressure);&#xA;            Serial.print(&quot;, temperature: &quot;);         &#xA;        Serial.print(latestTemperature);&#xA;        }&#xA;        Serial.println();&#xA;        }&#xA;        }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDITED CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       #include &amp;lt;Wire.h&amp;gt;&#xA;       #include &quot;I2Cdev.h&quot;&#xA;       #include &quot;RTIMUSettings.h&quot;&#xA;       #include &quot;RTIMU.h&quot;&#xA;       #include &quot;RTFusionRTQF.h&quot; &#xA;       #include &quot;RTPressure.h&quot;&#xA;       #include &quot;CalLib.h&quot;&#xA;       #include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;       RTIMU *imu;                                           // the IMU object&#xA;      RTPressure *pressure;                                 // the pressure object&#xA;      RTFusionRTQF fusion;                                  // the fusion object&#xA;      RTIMUSettings settings;                               // the settings object&#xA;&#xA;      //  DISPLAY_INTERVAL sets the rate at which results are displayed&#xA;&#xA;      #define DISPLAY_INTERVAL  300                         // interval between   pose displays&#xA;&#xA;     //  SERIAL_PORT_SPEED defines the speed to use for the debug serial port&#xA;&#xA;     #define  SERIAL_PORT_SPEED  115200&#xA;&#xA;    unsigned long lastDisplay;&#xA;    unsigned long lastRate;&#xA;    int sampleCount;&#xA;&#xA;&#xA;    // ================= MPU: 1 =================&#xA;&#xA;&#xA;&#xA;   RTIMU *imu1;                                           // the IMU object&#xA;   RTPressure *pressure1;                                 // the pressure object&#xA;   RTFusionRTQF fusion1;                                  // the fusion object&#xA;   RTIMUSettings settings1;                               // the settings object&#xA;&#xA;&#xA;   unsigned long lastDisplay1;&#xA;   unsigned long lastRate1;&#xA;   int sampleCount1;&#xA;&#xA;&#xA;   const int CS_MAX = 2;&#xA;   const int CS[CS_MAX] = { 7, 8 };&#xA;&#xA;&#xA;&#xA;   void setup()&#xA;   {&#xA;  for (int i = 0; i &amp;lt; CS_MAX; i++) {&#xA;  pinMode(CS[i], OUTPUT);&#xA;  digitalWrite(CS[i], HIGH);&#xA;  }&#xA;&#xA;  int errcode;&#xA;&#xA;  Serial.begin(SERIAL_PORT_SPEED);&#xA;  Wire.begin();&#xA;   imu = RTIMU::createIMU(&amp;amp;settings);                        // create the imu object&#xA;  pressure = RTPressure::createPressure(&amp;amp;settings);         // create the pressure sensor&#xA;&#xA;  if (pressure == 0) {&#xA;  Serial.println(&quot;No pressure sensor has been configured - terminating&quot;); &#xA;  while (1) ;&#xA;   }&#xA;&#xA;   Serial.print(&quot;ArduinoIMU10 starting using IMU &quot;); Serial.print(imu-&amp;gt;IMUName());&#xA;   Serial.print(&quot;, pressure sensor &quot;); Serial.println(pressure-&amp;gt;pressureName());&#xA;&#xA;  for (int i = 0; i &amp;lt; CS_MAX; i++) {&#xA;  digitalWrite(CS[i], LOW);&#xA;  if ((errcode = imu-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA;  Serial.print(&quot;Failed to init IMU: &quot;); Serial.println(errcode);&#xA;  }&#xA;&#xA;  if ((errcode = pressure-&amp;gt;pressureInit()) &amp;lt; 0) {&#xA;  Serial.print(&quot;Failed to init pressure sensor: &quot;); Serial.println(errcode);&#xA;  }&#xA;&#xA;  if (imu-&amp;gt;getCalibrationValid())&#xA;    Serial.println(&quot;Using compass calibration&quot;);&#xA;  else&#xA;    Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&#xA;  lastDisplay = lastRate = millis();&#xA;  sampleCount = 0;&#xA;&#xA;   // Slerp power controls the fusion and can be between 0 and 1&#xA;   // 0 means that only gyros are used, 1 means that only accels/compass are   used&#xA;  // In-between gives the fusion mix.&#xA;&#xA;  fusion.setSlerpPower(0.02);&#xA;&#xA;  // use of sensors in the fusion algorithm can be controlled here&#xA;  // change any of these to false to disable that sensor&#xA;&#xA;   fusion.setGyroEnable(true);&#xA;   fusion.setAccelEnable(true);&#xA;   fusion.setCompassEnable(true);&#xA;   digitalWrite(CS[i], HIGH);&#xA;   }&#xA;&#xA;&#xA;   int errcode1;&#xA;   Serial.begin(SERIAL_PORT_SPEED);&#xA;   Wire.begin();&#xA;   imu1= RTIMU::createIMU(&amp;amp;settings1);                        // create the imu object&#xA;   pressure1 = RTPressure::createPressure(&amp;amp;settings1);         // create the pressure sensor&#xA;&#xA;    if (pressure1 == 0) {&#xA;    Serial.println(&quot;No pressure sensor has been configured - terminating&quot;); &#xA;    while (1) ;&#xA;    }&#xA;&#xA;    Serial.print(&quot;ArduinoIMU10 starting using IMU &quot;); Serial.print(imu1-&amp;gt;IMUName());&#xA;    Serial.print(&quot;, pressure sensor &quot;); Serial.println(pressure1-&amp;gt;pressureName());&#xA;&#xA;    for (int i = 0; i &amp;lt; CS_MAX; i++) {&#xA;    digitalWrite(CS[i], LOW);&#xA;&#xA;&#xA;    if ((errcode1 = imu1-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA;    Serial.print(&quot;Failed to init IMU1: &quot;); Serial.println(errcode1);&#xA;    }&#xA;&#xA;    if ((errcode1 = pressure1-&amp;gt;pressureInit()) &amp;lt; 0) {&#xA;     Serial.print(&quot;Failed to init pressure sensor1: &quot;);  &#xA;     Serial.println(errcode1);&#xA;     }&#xA;&#xA;     if (imu1-&amp;gt;getCalibrationValid())&#xA;    Serial.println(&quot;Using compass calibration&quot;);&#xA;    else&#xA;    Serial.println(&quot;No valid compass calibration data1&quot;);&#xA;&#xA;    lastDisplay1 = lastRate1 = millis();&#xA;    sampleCount1 = 0;&#xA;&#xA;    // Slerp power controls the fusion and can be between 0 and 1&#xA;    // 0 means that only gyros are used, 1 means that only accels/compass are used&#xA;    // In-between gives the fusion mix.&#xA;&#xA;    fusion1.setSlerpPower(0.02);&#xA;&#xA;   // use of sensors in the fusion algorithm can be controlled here&#xA;   // change any of these to false to disable that sensor&#xA;&#xA;     fusion1.setGyroEnable(true);&#xA;     fusion1.setAccelEnable(true);&#xA;     fusion1.setCompassEnable(true);&#xA;&#xA;&#xA;     digitalWrite(CS[i], HIGH);&#xA;     }&#xA;     }&#xA;&#xA;     void loop()&#xA;     {  &#xA;     unsigned long now = millis();&#xA;     unsigned long delta;&#xA;     float latestPressure;&#xA;     float latestTemperature;&#xA;     int loopCount = 1;&#xA;&#xA;      while (imu-&amp;gt;IMURead()) {                                // get the   latest data if ready yet&#xA;      // this flushes remaining data in case we are falling behind&#xA;      if (++loopCount &amp;gt;= 10)&#xA;        continue;&#xA;&#xA;       fusion.newIMUData(imu-&amp;gt;getGyro(), imu-&amp;gt;getAccel(), imu-&amp;gt;getCompass(), imu-&amp;gt;getTimestamp());&#xA;        sampleCount++;&#xA;        if ((delta = now - lastRate) &amp;gt;= 1000) {&#xA;        Serial.print(&quot;Sample rate: &quot;); Serial.print(sampleCount);&#xA;        if (imu-&amp;gt;IMUGyroBiasValid())&#xA;            Serial.println(&quot;, gyro bias valid&quot;);&#xA;        else&#xA;            Serial.println(&quot;, calculating gyro bias&quot;);&#xA;&#xA;        sampleCount = 0;&#xA;        lastRate = now;&#xA;        }&#xA;        if ((now - lastDisplay) &amp;gt;= DISPLAY_INTERVAL) {&#xA;        lastDisplay = now;&#xA;        //          RTMath::display(&quot;Gyro:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getGyro()); &#xA;&#xA;         // gyro data&#xA;         //          RTMath::display(&quot;Accel:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getAccel());&#xA;&#xA;         // accel data&#xA;        //          RTMath::display(&quot;Mag:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getCompass());                 &#xA;        // compass data&#xA;          RTMath::displayRollPitchYaw(&quot;Pose:&quot;, &#xA;          (RTVector3&amp;amp;)fusion.getFusionPose()); // fused output&#xA;&#xA;         if (pressure-&amp;gt;pressureRead(latestPressure, latestTemperature)) {&#xA;            Serial.print(&quot;, pressure: &quot;); Serial.print(latestPressure);&#xA;            Serial.print(&quot;, temperature: &quot;);   &#xA;            Serial.print(latestTemperature);&#xA;        }&#xA;        Serial.println();&#xA;        }&#xA;        }&#xA;&#xA;&#xA;&#xA;       unsigned long now1 = millis();&#xA;      unsigned long delta1;&#xA;      float latestPressure1;&#xA;      float latestTemperature1;&#xA;      int loopCount1 = 1;&#xA;&#xA;      while (imu1-&amp;gt;IMURead()) {                                // get the latest data if ready yet&#xA;      // this flushes remaining data in case we are falling behind&#xA;      if (++loopCount1 &amp;gt;= 10)&#xA;        continue;&#xA;&#xA;      fusion1.newIMUData(imu1-&amp;gt;getGyro(), imu1-&amp;gt;getAccel(), imu1-  &amp;gt;getCompass(), imu1-&amp;gt;getTimestamp());&#xA;      sampleCount1++;&#xA;      if ((delta1 = now1 - lastRate1) &amp;gt;= 1000) {&#xA;        Serial.print(&quot;Sample rate: &quot;); Serial.print(sampleCount1);&#xA;        if (imu1-&amp;gt;IMUGyroBiasValid())&#xA;            Serial.println(&quot;, gyro bias valid&quot;);&#xA;        else&#xA;            Serial.println(&quot;, calculating gyro bias&quot;);&#xA;&#xA;        sampleCount1 = 0;&#xA;        lastRate1 = now1;&#xA;    }&#xA;    if ((now1 - lastDisplay1) &amp;gt;= DISPLAY_INTERVAL) {&#xA;        lastDisplay1 = now1;&#xA;      //          RTMath::display(&quot;Gyro1:&quot;, (RTVector3&amp;amp;)imu1-&amp;gt;getGyro());                   &#xA;      // gyro data&#xA;      //          RTMath::display(&quot;Accel1:&quot;, (RTVector3&amp;amp;)imu1-&amp;gt;getAccel());                 &#xA;      // accel data&#xA;      //          RTMath::display(&quot;Mag1:&quot;, (RTVector3&amp;amp;)imu1-&amp;gt;getCompass());                 &#xA;        // compass data&#xA;        RTMath::displayRollPitchYaw(&quot;Pose1:&quot;, (RTVector3&amp;amp;)fusion1.getFusionPose()); // fused output&#xA;&#xA;        if (pressure1-&amp;gt;pressureRead(latestPressure1, latestTemperature1)) {&#xA;            Serial.print(&quot;, pressure: &quot;); Serial.print(latestPressure1);&#xA;            Serial.print(&quot;, temperature: &quot;); Serial.print(latestTemperature1);&#xA;        }&#xA;        Serial.println();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="16544" LastEditorUserId="16544" LastEditDate="2016-02-03T01:54:52.610" LastActivityDate="2016-02-03T06:20:26.230" Title="How to connect two IMU in one arduino board?" Tags="|arduino-mega|mpu6050|" AnswerCount="1" CommentCount="0" ClosedDate="2018-02-07T08:02:51.323" ContentLicense="CC BY-SA 3.0" />
  <row Id="20229" PostTypeId="1" CreationDate="2016-02-02T07:53:05.790" Score="2" ViewCount="341" Body="&lt;p&gt;I have question about microphone and generating sound signal. I have microphone in my intercom at home. It is simple analog microphone, not digital.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is to connect arduino analog output to the microphone and generate some signal that will be heard like a voice at least few words. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do this ? Or it would be quite hard ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please suggest the easiest way to implement this.&lt;/p&gt;&#xA;" OwnerUserId="16955" LastActivityDate="2016-02-02T07:53:05.790" Title="How to generate Analog Signal (Voice) to the microphone" Tags="|programming|analogread|arduino-pro-mini|adc|sound|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20231" PostTypeId="1" CreationDate="2016-02-02T08:35:24.550" Score="0" ViewCount="219" Body="&lt;p&gt;I'm having an issue with my project. My project is 8 leds and a potentiometer on an arduino being read and controlled by a raspberry pi running python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I'm using a potentiometer the signal is received by my raspberry pi with python which then tells a set of leds to either turn on or off. However my leds flash on my low threshold when they shouldn't, the leds on my higher threshold work as expected and stay on till my pot is out of that range. How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my script!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from nanpy import Arduino&#xA;from nanpy import serial_manager&#xA;from time import sleep&#xA;&#xA;serial_manager.connect('/dev/ttyUSB0')&#xA;&#xA;POT = 0&#xA;LED1 = 13&#xA;LED2 = 12&#xA;LED3 = 11&#xA;LED4 = 10&#xA;LED5 = 9&#xA;LED6 = 8&#xA;LED7 = 7&#xA;LED8 = 6&#xA;&#xA;Arduino.pinMode(POT, Arduino.INPUT)&#xA;Arduino.pinMode(13, Arduino.OUTPUT)&#xA;Arduino.pinMode(12, Arduino.OUTPUT)&#xA;Arduino.pinMode(11, Arduino.OUTPUT)&#xA;Arduino.pinMode(10, Arduino.OUTPUT)&#xA;Arduino.pinMode(9, Arduino.OUTPUT)&#xA;Arduino.pinMode(8, Arduino.OUTPUT)&#xA;Arduino.pinMode(7, Arduino.OUTPUT)&#xA;Arduino.pinMode(6, Arduino.OUTPUT)&#xA;&#xA;print &quot;starting&quot;&#xA;while True:&#xA;    pot = Arduino.analogRead(POT)&#xA;#this is the section that is blinking when it should stay solid&#xA;   if pot &amp;lt; 450:&#xA;        Arduino.digitalWrite(LED1, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED2, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED3, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED4, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED5, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED6, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED7, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED8, Arduino.LOW)&#xA;        sleep(.5)&#xA;# end of section&#xA;   if pot &amp;lt; 650 &amp;gt; 450:&#xA;        Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED2, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED3, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED4, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED5, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED6, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED7, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED8, Arduino.LOW)&#xA;        sleep(.1)&#xA;    if pot &amp;gt; 650:&#xA;        Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED2, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED3, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED4, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED5, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED6, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED7, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED8, Arduino.HIGH)&#xA;        sleep(.5)&#xA;    print pot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16957" LastActivityDate="2016-02-03T02:00:09.560" Title="Led issue with arduino controled by raspberry pi/python" Tags="|serial|led|python|potentiometer|raspberrypi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20235" PostTypeId="2" ParentId="20228" CreationDate="2016-02-02T10:55:21.747" Score="1" Body="&lt;p&gt;Before editing the code to support an additional MPU9X50 you will need to figure out a way to address them on the I2C bus. Hopefully the MPU9X50 module you are using has a pin named AD0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two basic solutions to multiple MPU9X50. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first solution is to use the two different addresses. AD0 pin LOW on one and AD0 pin HIGH on the other. The sketch above would require two instances (imu), one for each module/address. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second solution, which works for several modules, is to hold the AD0 pin LOW for the module that is addresses and all other HIGH. The setting must be handled by a digital pin. One for each module. They will be used as chip/module select. Below the example code assumes that the MPU I2C address is with the lowest bit LOW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the setup() initiate these pins to output mode and high. The example code uses pin 7 and 8. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int CS_MAX = 2;&#xA;const int CS[CS_MAX] = { 7, 8 };&#xA;&#xA;void setup()&#xA;{&#xA;   ...&#xA;   for (int i = 0; i &amp;lt; CS_MAX; i++) {&#xA;     pinMode(CS[i], OUTPUT);&#xA;     digitalWrite(CS[i], HIGH);&#xA;   }&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set the digital pin LOW for the module you want to address before calling an MPU library function and back to HIGH afterwards. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(CS[0], LOW);&#xA;imu-&amp;gt;someMemberFunction();&#xA;digitalWrite(CS[0], HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If several functions are called in a block it can be convenient to run all of them per module. An example section from the setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; CS_MAX; i++) {&#xA;  digitalWrite(CS[i], LOW);&#xA;&#xA;  if ((errcode = imu-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA;    Serial.print(&quot;Failed to init IMU: &quot;); &#xA;    Serial.println(errcode);&#xA;  }&#xA;&#xA;  if (imu-&amp;gt;getCalibrationValid())&#xA;    Serial.println(&quot;Using compass calibration&quot;);&#xA;  else&#xA;    Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&#xA;  digitalWrite(CS[i], HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-03T06:20:26.230" LastActivityDate="2016-02-03T06:20:26.230" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20237" PostTypeId="1" CreationDate="2016-02-02T12:09:34.630" Score="0" ViewCount="59" Body="&lt;p&gt;How do we measure 100 Volts Arduino LCD &lt;a href=&quot;http://www.projehocam.com/arduino-lcd-voltmetre-yapimi/&quot; rel=&quot;nofollow&quot;&gt;Proje&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(7, 8, 9, 10, 11, 12);&#xA;int analogInput = 0;&#xA;float vout = 0.0;&#xA;float vin = 0.0;&#xA;float R1 = 100000.0; // 100K ohm direnç&#xA;float R2 = 10000.0; // 10K ohm direnç&#xA;int value = 0;&#xA;void setup(){&#xA;   pinMode(analogInput, INPUT);&#xA;   lcd.begin(16, 2);&#xA;   lcd.print(&quot;DC VOLTMETRE-PROJEHOCAM&quot;);&#xA;}&#xA;void loop(){&#xA;   // read the value at analog input&#xA;   value = analogRead(analogInput);&#xA;   vout = (value * 5.0) / 1024.0; &#xA;   vin = vout / (R2/(R1+R2)); &#xA;   if (vin&amp;lt;0.09) {&#xA;   vin=0.0;&#xA;} &#xA;lcd.setCursor(0, 1);&#xA;lcd.print(&quot;VOLTAJ V= &quot;);&#xA;lcd.print(vin);&#xA;delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16946" LastActivityDate="2016-02-02T15:43:41.090" Title="LCDs measuring volts arduino" Tags="|arduino-uno|lcd|voltage-level|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20238" PostTypeId="1" AcceptedAnswerId="20239" CreationDate="2016-02-02T12:52:40.930" Score="1" ViewCount="12743" Body="&lt;p&gt;What kind of a sim card is required for sim800 module? I know it must be activated and must be valid. But about 2g, 3g or LTE...What kind of a sim card in overall should I use with this module?&lt;/p&gt;&#xA;" OwnerUserId="16336" LastActivityDate="2019-09-22T13:40:51.490" Title="Sim800 sim card requirements" Tags="|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20239" PostTypeId="2" ParentId="20238" CreationDate="2016-02-02T13:11:37.320" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What kind of a sim card is required for sim800 module? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The SIM interface complies with the GSM Phase 1 specification and the new GSM Phase 2+ specification for FAST 64 kbps SIM card. Both 1.8V and 3.0V SIM card &#xA;are supported. The SIM interface is powered from an internal regulator in the module.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;https://www.adafruit.com/datasheets/sim800h_hardware_design_v1.00.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module/obtaining-a-sim&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. And remember &quot;Google is your friend&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-02T13:11:37.320" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20240" PostTypeId="1" CreationDate="2016-02-02T13:34:44.120" Score="10" ViewCount="32085" Body="&lt;p&gt;I am trying to receive and send some data from a computer to an ATtiny through USB. Can an ATtiny85 IC communicate with a computer through USB? If yes, how should it be connected?&lt;/p&gt;&#xA;" OwnerUserId="16965" LastEditorUserId="11086" LastEditDate="2016-02-03T15:11:28.697" LastActivityDate="2020-08-20T10:26:37.143" Title="ATtiny85 communication with computer through USB" Tags="|attiny|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20241" PostTypeId="2" ParentId="20240" CreationDate="2016-02-02T13:42:50.650" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can an ATtiny85 ic communicate with a computer through USB?if yes,how should be the connection?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Have you checked the web? There are many such projects. Here is a link to one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Digispark-DIY-The-smallest-USB-Arduino/&quot; rel=&quot;noreferrer&quot;&gt;http://www.instructables.com/id/Digispark-DIY-The-smallest-USB-Arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please remember &quot;Google is your friend&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-02T13:42:50.650" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20242" PostTypeId="1" CreationDate="2016-02-02T14:27:36.140" Score="2" ViewCount="68" Body="&lt;p&gt;I have tried to use different libraries like &lt;code&gt;TimeAlarms&lt;/code&gt; , &lt;code&gt;SimpleTimer&lt;/code&gt;, &lt;code&gt;Timer&lt;/code&gt; and others. My goal is to call function periodically every minute or so. Each library works fine when repeat time is less than 15 seconds ( maybe greater) but 30seconds,45seconds, 60seconds doesn't work at all.&lt;/p&gt;&#xA;&lt;p&gt;It seems something with internal timer.&lt;/p&gt;&#xA;&lt;p&gt;I also use NRF24l01 Mesh library.&lt;/p&gt;&#xA;&lt;p&gt;Please help to solve the problem&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;SOLVED&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;The issue was that I used int type instead of long. but I don't understand why 60 000 cannot be stored in int type which is 4 bytes (2^32)&lt;/p&gt;&#xA;" OwnerUserId="16955" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-02T18:49:22.380" Title="Arduino signed int can't fire timer &gt; 15 seconds" Tags="|timers|arduino-pro-mini|oscillator-clock|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20243" PostTypeId="2" ParentId="20237" CreationDate="2016-02-02T14:49:16.117" Score="1" Body="&lt;p&gt;The project that you show as your reference : &lt;a href=&quot;http://www.projehocam.com/arduino-lcd-voltmetre-yapimi/&quot; rel=&quot;nofollow noreferrer&quot;&gt;link in your question&lt;/a&gt;,  shows this picture :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5Dxpa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5Dxpa.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change R1 to 200 K ohms.   The Arduino will receive 4.76 volts when the input is 100 volts.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will also need to change your program line for float R1 = 100000.0;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;CAUTION :  Beware of high voltage.  Also, the Arduino is not isolated from the 100 volts.&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-02-02T15:43:41.090" LastActivityDate="2016-02-02T15:43:41.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20244" PostTypeId="1" CreationDate="2016-02-02T16:15:41.907" Score="1" ViewCount="4423" Body="&lt;p&gt;Since the AT89S52 controller is ISP programmable is it possible to use an Arduino UNO as a programmer to upload the hex file to the 8952 ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried various programmer softwares such as progisp, 8051 loader and ISP Prog v1.4 but the Arduino doesnt show up as a programmer on any of these. I've uploaded the ArduinoISP sketch on the UNO and then tried to program the 8952 without any luck. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to my understanding the ISP programmers use an ATMega8 ,so is what I'm trying to do possible or do I need to purchace an ISP programmer ? &lt;/p&gt;&#xA;" OwnerUserId="7193" LastEditorUserId="7193" LastEditDate="2016-02-02T16:35:46.960" LastActivityDate="2016-11-20T16:39:44.967" Title="Can an AT89S52 be programmed using an Arduino as ISP?" Tags="|arduino-uno|isp|programmer|arduinoisp|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20245" PostTypeId="2" ParentId="20231" CreationDate="2016-02-02T16:16:59.890" Score="1" Body="&lt;p&gt;Your second condition is written wrongly. It should be this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;elif pot &amp;gt;= 450 and pot &amp;lt;= 650:&#xA;    # do stuff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code should be such that only an option is chosen at any time. There should be only one 'if' condition at the top and the rest should be 'elif'.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-02-02T22:22:12.540" LastActivityDate="2016-02-02T22:22:12.540" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20247" PostTypeId="2" ParentId="20244" CreationDate="2016-02-02T17:27:38.943" Score="1" Body="&lt;p&gt;You should be able to use the Arduino as an ISP since an ISP is basically just a serial to SPI interface. If you are trying to use the arduino software to upload your program, you will need to edit your boards.txt file to be able to talk to the chip. If you are just using avrdude you will need to update your avrdude.conf.  &lt;a href=&quot;http://www.avrfreaks.net/forum/writing-at89s52-through-usbasp&quot; rel=&quot;nofollow&quot;&gt;AVR Freaks&lt;/a&gt; has a post on someone trying something similar and may be of some help. Without knowing your environment it's difficult to give more specific advice&lt;/p&gt;&#xA;" OwnerUserId="16679" LastActivityDate="2016-02-02T17:27:38.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20248" PostTypeId="1" CreationDate="2016-02-02T17:36:43.240" Score="0" ViewCount="101" Body="&lt;p&gt;arduino nano, the driver is not showing up in Port assignments. It has worked with this operating system before. I’ve messed something up.  “OS X EI Capitan ver. 10.11.3 I have check the posts but the serial port is a no show&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/faUOn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/faUOn.png&quot; alt=&quot;Available Ports &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16969" LastActivityDate="2016-02-02T20:40:18.490" Title="driver is not showing up in Port assignments mac" Tags="|port-mapping|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20249" PostTypeId="1" AcceptedAnswerId="20250" CreationDate="2016-02-02T10:54:47.093" Score="0" ViewCount="3590" Body="&lt;p&gt;Ive been working with a motor project for a while and i bought this H-bridge(LMD18200). I dont understand how im supposed to connect it to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the datasheet for the lmd18200:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://imagizer.imageshack.us/v2/484x397q90/924/KkI1QB.png&quot; alt=&quot;the datasheet&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="14149" OwnerDisplayName="Marc" LastActivityDate="2016-02-02T19:25:39.307" Title="How to wire an LMD18200 and an arduino?" Tags="|h-bridge|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20250" PostTypeId="2" ParentId="20249" CreationDate="2016-02-02T11:04:53.193" Score="1" Body="&lt;p&gt;Most basic way would be to use only DIR, PWM and Break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Break as enable (put high at begining of the program, put low when you want to start rotation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Dir to change rotation of the motor (usually high is CV, low is CCV, but you need to check the datasheet)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And hook up PWM to &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow&quot;&gt;PWM&lt;/a&gt; pin on arduino. This will control the speed. &lt;/p&gt;&#xA;" OwnerDisplayName="ursusd8" LastActivityDate="2016-02-02T11:04:53.193" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20251" PostTypeId="2" ParentId="789" CreationDate="2016-02-02T19:28:12.033" Score="2" Body="&lt;p&gt;In my case, the wiring between my uC and the sensor was too short, and was transmitting some heat. I thought that couldn't be the case at first, since another temp sensor was reporting accurate temps at the same distance. I moved it to another location on the board and voila!&lt;/p&gt;&#xA;" OwnerUserId="16954" LastActivityDate="2016-02-02T19:28:12.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20252" PostTypeId="2" ParentId="20248" CreationDate="2016-02-02T20:40:18.490" Score="2" Body="&lt;p&gt;If the port showed in earlier versions of OS X, but never showed after upgrading to El Capitan, then you probably used an unsigned driver, which is no longer allowed by Apple's new &lt;a href=&quot;https://support.apple.com/en-us/HT204899&quot; rel=&quot;nofollow noreferrer&quot;&gt;System Integrity Protection&lt;/a&gt; (a.k.a. &quot;Rootless&quot;; more details &lt;a href=&quot;https://developer.apple.com/videos/play/wwdc2015-706/&quot; rel=&quot;nofollow noreferrer&quot;&gt;in a WWDC session&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any unsigned drivers will have been disabled during the upgrade process. Even more, SIP does not allow &lt;em&gt;any&lt;/em&gt; non-Apple files in &lt;code&gt;/System&lt;/code&gt;, &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt; and &lt;code&gt;/usr&lt;/code&gt; (except for &lt;code&gt;/usr/local&lt;/code&gt;), so anything you had put in there will have been moved away as well. To see what has been disabled:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;ls -l &quot;/Incompatible Software&quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;ls -lR /Library/SystemMigration/History/Migration-*/QuarantineRoot/*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To get it working again: find a signed driver, or &lt;a href=&quot;https://apple.stackexchange.com/questions/208478/how-do-i-disable-system-integrity-protection-sip-aka-rootless-on-os-x-10-11&quot;&gt;Switch off SIP&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16852" LastEditorUserId="-1" LastEditDate="2017-04-13T12:45:32.257" LastActivityDate="2016-02-02T20:40:18.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20253" PostTypeId="2" ParentId="20244" CreationDate="2016-02-02T20:49:13.270" Score="1" Body="&lt;p&gt;You might be able to use the programmer sketch I wrote a while back (it runs on a Uno). You need an SD card interface so it can read the .hex file for programming. See: &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/uploader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You connect things up roughly like this (Atmega328P shown, your wiring would be different at the target chip side):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tscQr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tscQr.jpg&quot; alt=&quot;Chip programmer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need to modify the sketch to add the details for the AT89S52. As far as I can make out from the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Signature: 0x1E 0x52 0x06&lt;/li&gt;&#xA;&lt;li&gt;PROGMEM: 8k bytes&lt;/li&gt;&#xA;&lt;li&gt;RAM: 256 bytes&lt;/li&gt;&#xA;&lt;li&gt;Pinouts: Depending on the chip package. You need to identify MOSI/MISO/SCK/RESET along with Vcc and Gnd.&lt;/li&gt;&#xA;&lt;li&gt;Fuses: None that I can see&lt;/li&gt;&#xA;&lt;li&gt;Flash page size: 256 bytes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus you could modify the table of chips to add that one, along these lines:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// see Atmega datasheets&#xA;const signatureType signatures [] PROGMEM = &#xA;  {&#xA;//     signature        description   flash size   bootloader  flash  fuse&#xA;//                                                     size    page    to&#xA;//                                                             size   change&#xA;&#xA;  // AT89S52&#xA;  { { 0x1E, 0x52, 0x06 }, &quot;AT89S52&quot;,   8 * kb,           0,   256,   NO_FUSE },&#xA;&#xA;// ... other ones here ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't got an AT89S52 to test it on, so I can't say for sure I got those parameters right. I am assuming that the programming instructions for ICSP programming are the same as for the other chips in their range.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Sketch source: &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/nickgammon/arduino_sketches&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-02T20:49:13.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20256" PostTypeId="2" ParentId="20231" CreationDate="2016-02-02T22:25:25.653" Score="0" Body="&lt;p&gt;The problem is you're using multiple &lt;strong&gt;if&lt;/strong&gt; statements, whereas the if-blocks should be mutually exclusive, so &lt;strong&gt;elif&lt;/strong&gt; would be better.  It's not really clear what you intend in the 2nd clause either, since it's a typo(?) - not valid python syntax anyway.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (pot &amp;lt;= 450):&#xA;    Arduino.digitalWrite(LED1, Arduino.HIGH)&#xA;    ...&#xA;    time.sleep(0.5)&#xA;elif (pot &amp;gt; 450 and pot &amp;lt;= 650):&#xA;    Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;    ...&#xA;    time.sleep(0.1)&#xA;else # pot &amp;gt; 650&#xA;    Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;    ...&#xA;    time.sleep(0.5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think your LEDs were flashing because both the first and second &lt;strong&gt;if&lt;/strong&gt; clauses were evaluating to True, thus both code segments were being executed (were only the first four LEDs flashing?)  Using if/elif/else instead, ensures only ever one clause is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I might make a suggestion, assuming you want an LED bar graph based on the POT reading...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analogRead() will give you a result 0-1023. Graphed over 8 LEDs, this means one more LED should be illuminated roughly per 128 units.  Since you want a full bar when rounding makes the value near 1023, maybe something like 120 is a better divisor (I just guessed this, it's probably calculable).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple loop over your LEDs, summing units over each iteration gives an easy way of turning the LEDs on or off.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino.analogRead(POT)&#xA;led_bar_per_units = 120   # needs a better name&#xA;&#xA;### illuminate the LED-bar&#xA;bar_length = 0&#xA;for led in (LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8):&#xA;    bar_length += led_per_bar_units&#xA;    if (bar_length &amp;lt;= pot):&#xA;        Arduino.digitalWrite(led, Arduino.HIGH)&#xA;    else:&#xA;        Arduino.digitalWrite(led, Arduino.LOW)&#xA;time.sleep(0.5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: I know you don't need brackets around python &lt;strong&gt;if&lt;/strong&gt; statements.  I've been doing C/C++ code for so long I find bracketed-clauses easier to read, and thus code my python this way too.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-02T22:31:55.400" LastActivityDate="2016-02-02T22:31:55.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20257" PostTypeId="2" ParentId="5090" CreationDate="2016-02-02T23:11:18.443" Score="1" Body="&lt;p&gt;Floating point numbers are (should) be stored in &lt;a href=&quot;https://en.wikipedia.org/wiki/IEEE_floating_point&quot; rel=&quot;nofollow&quot;&gt;IEEE 754 format&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you simply write the binary bytes of a floating point number down the serial line, it should be possible to unpack them at the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this (Arduino C/C++), make a pointer from your variable, by casting the address of it to char*. Void* would probably work too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; float my_value = 22.812;&#xA; my_port.write((const char *)&amp;amp;my_value, sizeof(float)/*4*/);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the unpacking - there's a few ways to do this, but I like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; float incoming_value;&#xA; unsigned char buffer[4];&#xA;&#xA; // If we read enough bytes, unpacked it&#xA; if (my_serial.readBytes(buffer, sizeof(float)) == sizeof(float))&#xA;     memcpy(&amp;amp;incoming_value, buffer, sizeof(float));&#xA; else&#xA;     // I/O error - no data, not enough bytes, etc.&#xA;     incoming_value = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other end (python), bytes are best handled with the &lt;strong&gt;struct&lt;/strong&gt; module.  This will handle the packing and unpacking for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import struct&#xA;...&#xA;&#xA;try:&#xA;    ieee754_data = my_serial.read(4)&#xA;    my_float = struct.unpack('f', ieee754_data)&#xA;catch:&#xA;    # I/O Error, or junk data&#xA;    my_float = 0.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And packing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ieee754_data = struct.pack('f', my_float)&#xA; try:&#xA;     my_serial.write(ieee754_data)&#xA; catch:&#xA;     pass #TODO - I/O Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;One more note - You might consider using doubles instead of floats for extra precision.  Python floats have the precision of a C/C++ double already.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-02T23:17:24.123" LastActivityDate="2016-02-02T23:17:24.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20258" PostTypeId="2" ParentId="13823" CreationDate="2016-02-02T23:29:16.123" Score="0" Body="&lt;p&gt;Mr Gammon's comment about using a faster baud rate is an excellent idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also seem to be sending the number as a string.  Sending the integer as binary data (using python's struct module) would also reduce the amount of data that needs to be sent - significantly for larger numbers.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import struct&#xA;&#xA;...&#xA;&#xA;ser.write(struct.pack('I',int(avg)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the Arduino Side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t buffer[4];&#xA;uint32_t position;&#xA;&#xA;if (my_serial.read(buffer, sizeof(uint32_t)) == sizeof(uint32_t))&#xA;    memcpy(&amp;amp;position, buffer, sizeof(uint32_t));&#xA;&#xA;// alternatively in one step, without error checking&#xA;my_serial.read(&amp;amp;position, sizeof(uint32_t));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes a 32-bit integer is needed.&lt;br&gt;&#xA;Maybe you only need an unsigned short - this would halve the amount needed to transmit.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-02T23:29:16.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20259" PostTypeId="2" ParentId="8604" CreationDate="2016-02-02T23:43:40.383" Score="0" Body="&lt;p&gt;What are the variable types of &lt;code&gt;TC&lt;/code&gt; and &lt;code&gt;TF&lt;/code&gt; - int/float/double? Something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they're integers, you may be losing some numerical precision in the calculation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you get 50.25°C - have you checked the &lt;code&gt;Vin&lt;/code&gt; is correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when you write the values out, the serial.print() can take the number of decimal points as a second argument.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Print to three decimal places&#xA;Serial.print(&quot;TF=&quot;);&#xA;Serial.println((float)TF, 3);&#xA;Serial.print(&quot;TC=&quot;);&#xA;Serial.println((float)TC, 3);&#xA;Serial.print(&quot;Vin=&quot;);&#xA;Serial.println(Vin, DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-03T23:36:32.777" LastActivityDate="2016-02-03T23:36:32.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20262" PostTypeId="1" CreationDate="2016-02-03T01:50:10.417" Score="2" ViewCount="1336" Body="&lt;p&gt;My question is: how do I read multiple inputs at the same time without using interrupts on an UNO.  I'm building an RC drag strip with tree and finish line that will calculate run time as well as calculate each run in mph.  I'm using lasers and non modulated laser detectors for the beams and I'm using a 1&quot; beam gap(between 1st beam and 2nd beam) at the finish line(for mph calculation). My concern comes in when two cars come close enough at the finish line for one to break the first beam at set the win flag but the car in the other lane is close enough to cross the 1st beam before the 1st car actually crosses the 2nd beam then the detection loop is going to miss one of them. (just a note: a few of these cars can top 100 mph when crossing the line) &lt;/p&gt;&#xA;" OwnerUserId="16949" LastEditorUserId="10794" LastEditDate="2016-02-04T04:54:53.387" LastActivityDate="2017-07-11T15:05:22.593" Title="RC drag strip finish line with mph calculation (using 1&quot; spaced lasers)" Tags="|arduino-uno|c++|timers|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20263" PostTypeId="2" ParentId="20231" CreationDate="2016-02-03T02:00:09.560" Score="0" Body="&lt;p&gt;I figured it out.&#xA;Here is my new script.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from nanpy import Arduino&#xA;from nanpy import serial_manager&#xA;from time import sleep&#xA;&#xA;serial_manager.connect('/dev/ttyUSB0')&#xA;&#xA;POT = 0&#xA;LED1 = 13&#xA;LED2 = 12&#xA;LED3 = 11&#xA;LED4 = 10&#xA;LED5 = 9&#xA;LED6 = 8&#xA;LED7 = 7&#xA;LED8 = 6&#xA;&#xA;Arduino.pinMode(POT, Arduino.INPUT)&#xA;Arduino.pinMode(13, Arduino.OUTPUT)&#xA;Arduino.pinMode(12, Arduino.OUTPUT)&#xA;Arduino.pinMode(11, Arduino.OUTPUT)&#xA;Arduino.pinMode(10, Arduino.OUTPUT)&#xA;Arduino.pinMode(9, Arduino.OUTPUT)&#xA;Arduino.pinMode(8, Arduino.OUTPUT)&#xA;Arduino.pinMode(7, Arduino.OUTPUT)&#xA;Arduino.pinMode(6, Arduino.OUTPUT)&#xA;&#xA;print &quot;starting&quot;&#xA;while True:&#xA;    pot = Arduino.analogRead(POT)&#xA;    if pot &amp;lt; 450:&#xA;        Arduino.digitalWrite(LED1, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED2, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED3, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED4, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED5, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED6, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED7, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED8, Arduino.LOW)&#xA;        sleep(.01)&#xA;    elif pot &amp;gt; 650:&#xA;        Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED2, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED3, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED4, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED5, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED6, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED7, Arduino.HIGH)&#xA;        Arduino.digitalWrite(LED8, Arduino.HIGH)&#xA;        sleep(.01)&#xA;    else:&#xA;        Arduino.digitalWrite(LED1, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED2, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED3, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED4, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED5, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED6, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED7, Arduino.LOW)&#xA;        Arduino.digitalWrite(LED8, Arduino.LOW)&#xA;        sleep(.01)&#xA;    print pot&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16957" LastActivityDate="2016-02-03T02:00:09.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20266" PostTypeId="1" AcceptedAnswerId="20290" CreationDate="2016-02-03T02:51:48.387" Score="3" ViewCount="7193" Body="&lt;p&gt;I have this voice sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K48qt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K48qt.jpg&quot; alt=&quot;http://s3.amazonaws.com/img.iluria.com/product/22C645/5241CF/450xN.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to know how bytes pass through soundsensor into arduino and get this bytes and put out in a speaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read on the net a Lib PCM thats converts chars in voices, but how do I extract bytes from sound sensor in analog-in?&lt;/p&gt;&#xA;" OwnerUserId="16989" LastEditorUserId="9962" LastEditDate="2016-02-23T12:28:36.587" LastActivityDate="2021-07-04T04:16:28.783" Title="How do I use Sound Sensor LM393 + Speaker in Arduino" Tags="|arduino-uno|sensors|sound|tmrpcm|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20267" PostTypeId="2" ParentId="20262" CreationDate="2016-02-03T02:53:21.637" Score="0" Body="&lt;p&gt;One option, if you want very-real-time processing, for a task like this that break neatly into chunks: Have one Arduino per vehicle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos are cheap. If they are too expensive, use AtTiny's - they can be had for about a dollar a piece (depending on your currency). You can share a clock/power between a large number of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either have a &quot;master&quot; Arduino talk to each individual one, to collect the information, or have daisy-chained bus - each one can pass it's data to the next one in the chain (once is has the data, and the next one in the chain indicates it's ready for it). &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-02-03T02:53:21.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20268" PostTypeId="1" AcceptedAnswerId="20271" CreationDate="2016-02-03T03:55:09.807" Score="1" ViewCount="429" Body="&lt;p&gt;Problem: can't print to the serial monitor, it appears that the serial monitor disconnects itself after uploading a program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm brand new to arduino, and I'm trying to upload a basic program to print to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use an arduino uno and my OS is Ubuntu.&#xA;I am connecting the arduino to my PC via USB.&#xA;Using Arduino Studio Release 0.0.5 experimental build 0.0.5-16058&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I am able to communicate via the digital output pins, tested by making a simple circuit to make the led light blink)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.print(&quot;test&quot;);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the result of the build, look at the last line and it says the serial monitor was disconnected? Why would this happen automatically?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[2/2/2016 8:51:26 PM] - Start Building&#xA;[2/2/2016 8:51:26 PM] - CPP File Created [/tmp/build1454471486915/test.cpp]&#xA;[2/2/2016 8:51:26 PM] - test.cpp compiled&#xA;[2/2/2016 8:51:26 PM] - CDC.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HID.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HardwareSerial.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HardwareSerial0.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HardwareSerial1.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HardwareSerial2.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - HardwareSerial3.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - IPAddress.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - Print.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - Stream.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - Tone.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - USBCore.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - WInterrupts.c compiled&#xA;[2/2/2016 8:51:27 PM] - WMath.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - WString.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - abi.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - hooks.c compiled&#xA;[2/2/2016 8:51:27 PM] - main.cpp compiled&#xA;[2/2/2016 8:51:27 PM] - new.cpp compiled&#xA;[2/2/2016 8:51:28 PM] - wiring.c compiled&#xA;[2/2/2016 8:51:28 PM] - wiring_analog.c compiled&#xA;[2/2/2016 8:51:28 PM] - wiring_digital.c compiled&#xA;[2/2/2016 8:51:28 PM] - wiring_pulse.c compiled&#xA;[2/2/2016 8:51:28 PM] - wiring_shift.c compiled&#xA;[2/2/2016 8:51:28 PM] - CDC.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HID.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HardwareSerial.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HardwareSerial0.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HardwareSerial1.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HardwareSerial2.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - HardwareSerial3.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - IPAddress.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - Print.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - Stream.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - Tone.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - USBCore.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - WInterrupts.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - WMath.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - WString.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - abi.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - hooks.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - main.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - new.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - test.cpp.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - test.ino linked to core.a&#xA;[2/2/2016 8:51:28 PM] - wiring.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - wiring_analog.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - wiring_digital.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - wiring_pulse.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - wiring_shift.c.o linked to core.a&#xA;[2/2/2016 8:51:28 PM] - test.cpp.elf linked to core.a&#xA;[2/2/2016 8:51:28 PM] - test EEPROM&#xA;[2/2/2016 8:51:28 PM] - test.hex builded&#xA;[2/2/2016 8:51:28 PM] - Uploading...&#xA;[2/2/2016 8:51:30 PM] - Uploaded&#xA;[2/2/2016 8:51:30 PM] - [arduino ide - serial monitor] Serial monitor connected to /dev/ttyACM0&#xA;[2/2/2016 8:51:36 PM] - [arduino ide - serial monitor] Serial monitor disconnected from /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13605" LastEditorUserId="13605" LastEditDate="2016-02-03T04:51:01.410" LastActivityDate="2016-02-03T19:38:04.110" Title="Serial monitor disconnecting itself" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20270" PostTypeId="2" ParentId="20240" CreationDate="2016-02-03T05:04:25.263" Score="8" Body="&lt;p&gt;Digispark made a lot of these as part of a &quot;cheap Arduino USB interface&quot; project a while back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my Digispark, it's pretty cute:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0oXID.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0oXID.jpg&quot; alt=&quot;Digispark&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have a &lt;a href=&quot;https://digistump.com/wiki/digispark&quot; rel=&quot;noreferrer&quot;&gt;web page here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I got them for about $2 each. The board has the ATtiny85, a voltage regulator, and a handful of other parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic (courtesy of &lt;a href=&quot;https://digistump.com/wiki/digispark/tutorials/digispark&quot; rel=&quot;noreferrer&quot;&gt;Digistump Wiki&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Iv2bq.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Iv2bq.png&quot; alt=&quot;Digispark schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;More information about the Virtual USB idea at &lt;a href=&quot;http://blog.petrockblock.com/2012/05/19/usb-keyboard-with-arduino-and-v-usb-library-an-example/&quot; rel=&quot;noreferrer&quot;&gt;USB-Keyboard with Arduino and V-USB library, an example&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-03T05:04:25.263" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20271" PostTypeId="2" ParentId="20268" CreationDate="2016-02-03T05:07:50.480" Score="2" Body="&lt;p&gt;I'm not sure why your IDE is doing that, but the official Arduino IDE from &lt;a href=&quot;http://arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;Arduino.cc&lt;/a&gt; works on Ubuntu and does not have that issue. Download from &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino Software download page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-03T19:38:04.110" LastActivityDate="2016-02-03T19:38:04.110" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20272" PostTypeId="1" AcceptedAnswerId="20279" CreationDate="2016-02-03T07:01:13.730" Score="0" ViewCount="8486" Body="&lt;p&gt;I would like to use my arduino even where there's no wifi router. I've only found people saying that it needs to connect to a router, but isn't the phone like a router when it's in tethering mode? Do I still need a mobile internet connection or can I do it directly?&lt;/p&gt;&#xA;" OwnerUserId="16991" LastActivityDate="2017-02-10T13:45:55.240" Title="Can I connect an Arduino wifi module directly to my android phone?" Tags="|wifi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20273" PostTypeId="1" CreationDate="2016-02-03T08:40:08.873" Score="-3" ViewCount="1313" Body="&lt;p&gt;I can't figure out where I doing wrong&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=35NqOANmgUE&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=35NqOANmgUE&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my question in videos&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6TGmH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6TGmH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The both of two connect the same pin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(so the right display result is the correct  OLED)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My connecting table  (using SPI )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND              gnd&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VCC              5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D0(OLED_CLK)     10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D(OLED_MOSI)     9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RES(OLED_RESET)  13&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D/C(OLED_DC)     11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CS（OLED_CS）    12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but the left OLED doesn't have the &quot;RES&quot; pin&#xA;(so I didn't connect it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the left OLED just display the upper part &#xA;(and its the position of display picture is also wired ,too)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*********************************************************************&#xA;This is an example for our Monochrome OLEDs based on SSD1306 drivers&#xA;This example is for a 128x64 size display using SPI to communicate&#xA;4 or 5 pins are required to interface&#xA;&#xA;Adafruit invests time and resources providing this open source code, &#xA;please support Adafruit and open-source hardware by purchasing &#xA;products from Adafruit!&#xA;&#xA;Written by Limor Fried/Ladyada  for Adafruit Industries.  &#xA;BSD license, check license.txt for more information&#xA;All text above, and the splash screen must be included in any redistribution&#xA;*********************************************************************/&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;Adafruit_SSD1306.h&amp;gt;&#xA;&#xA;// If using software SPI (the default case):&#xA;#define OLED_MOSI   9&#xA;#define OLED_CLK   10&#xA;#define OLED_DC    11&#xA;#define OLED_CS    12&#xA;#define OLED_RESET 13&#xA;Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);&#xA;&#xA;/* Uncomment this block to use hardware SPI&#xA;#define OLED_DC     6&#xA;#define OLED_CS     7&#xA;#define OLED_RESET  8&#xA;Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);&#xA;*/&#xA;&#xA;#define NUMFLAKES 10&#xA;#define XPOS 0&#xA;#define YPOS 1&#xA;#define DELTAY 2&#xA;&#xA;#define LOGO16_GLCD_HEIGHT 16 &#xA;#define LOGO16_GLCD_WIDTH  16 &#xA;static const unsigned char PROGMEM logo16_glcd_bmp[] =&#xA;{ B00000000, B11000000,&#xA;  B00000001, B11000000,&#xA;  B00000001, B11000000,&#xA;  B00000011, B11100000,&#xA;  B11110011, B11100000,&#xA;  B11111110, B11111000,&#xA;  B01111110, B11111111,&#xA;  B00110011, B10011111,&#xA;  B00011111, B11111100,&#xA;  B00001101, B01110000,&#xA;  B00011011, B10100000,&#xA;  B00111111, B11100000,&#xA;  B00111111, B11110000,&#xA;  B01111100, B11110000,&#xA;  B01110000, B01110000,&#xA;  B00000000, B00110000 };&#xA;&#xA;#if (SSD1306_LCDHEIGHT != 64)&#xA;#error(&quot;Height incorrect, please fix Adafruit_SSD1306.h!&quot;);&#xA;#endif&#xA;&#xA;void setup()   {                &#xA;  Serial.begin(9600);&#xA;&#xA;  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)&#xA;  display.begin(SSD1306_SWITCHCAPVCC);&#xA;  // init done&#xA;&#xA;  // Show image buffer on the display hardware.&#xA;  // Since the buffer is intialized with an Adafruit splashscreen&#xA;  // internally, this will display the splashscreen.&#xA;  display.display();&#xA;  delay(2000);&#xA;&#xA;  // Clear the buffer.&#xA;  display.clearDisplay();&#xA;&#xA;  // draw a single pixel&#xA;  display.drawPixel(10, 10, WHITE);&#xA;  // Show the display buffer on the hardware.&#xA;  // NOTE: You _must_ call display after making any drawing commands&#xA;  // to make them visible on the display hardware!&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw many lines&#xA;  testdrawline();&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw rectangles&#xA;  testdrawrect();&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw multiple rectangles&#xA;  testfillrect();&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw mulitple circles&#xA;  testdrawcircle();&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw a white circle, 10 pixel radius&#xA;  display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  testdrawroundrect();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  testfillroundrect();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  testdrawtriangle();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  testfilltriangle();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw the first ~12 characters in the font&#xA;  testdrawchar();&#xA;  display.display();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // draw scrolling text&#xA;  testscrolltext();&#xA;  delay(2000);&#xA;  display.clearDisplay();&#xA;&#xA;  // text display tests&#xA;  display.setTextSize(1);&#xA;  display.setTextColor(WHITE);&#xA;  display.setCursor(0,0);&#xA;  display.println(&quot;Hello, world!&quot;);&#xA;  display.setTextColor(BLACK, WHITE); // 'inverted' text&#xA;  display.println(3.141592);&#xA;  display.setTextSize(2);&#xA;  display.setTextColor(WHITE);&#xA;  display.print(&quot;0x&quot;); display.println(0xDEADBEEF, HEX);&#xA;  display.display();&#xA;  delay(2000);&#xA;&#xA;  // miniature bitmap display&#xA;  display.clearDisplay();&#xA;  display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);&#xA;  display.display();&#xA;&#xA;  // invert the display&#xA;  display.invertDisplay(true);&#xA;  delay(1000); &#xA;  display.invertDisplay(false);&#xA;  delay(1000); &#xA;&#xA;  // draw a bitmap icon and 'animate' movement&#xA;  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&#xA;&#xA;void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {&#xA;  uint8_t icons[NUMFLAKES][3];&#xA;&#xA;  // initialize&#xA;  for (uint8_t f=0; f&amp;lt; NUMFLAKES; f++) {&#xA;    icons[f][XPOS] = random(display.width());&#xA;    icons[f][YPOS] = 0;&#xA;    icons[f][DELTAY] = random(5) + 1;&#xA;&#xA;    Serial.print(&quot;x: &quot;);&#xA;    Serial.print(icons[f][XPOS], DEC);&#xA;    Serial.print(&quot; y: &quot;);&#xA;    Serial.print(icons[f][YPOS], DEC);&#xA;    Serial.print(&quot; dy: &quot;);&#xA;    Serial.println(icons[f][DELTAY], DEC);&#xA;  }&#xA;&#xA;  while (1) {&#xA;    // draw each icon&#xA;    for (uint8_t f=0; f&amp;lt; NUMFLAKES; f++) {&#xA;      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);&#xA;    }&#xA;    display.display();&#xA;    delay(200);&#xA;&#xA;    // then erase it + move it&#xA;    for (uint8_t f=0; f&amp;lt; NUMFLAKES; f++) {&#xA;      display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, BLACK);&#xA;      // move it&#xA;      icons[f][YPOS] += icons[f][DELTAY];&#xA;      // if its gone, reinit&#xA;      if (icons[f][YPOS] &amp;gt; display.height()) {&#xA;    icons[f][XPOS] = random(display.width());&#xA;    icons[f][YPOS] = 0;&#xA;    icons[f][DELTAY] = random(5) + 1;&#xA;      }&#xA;    }&#xA;   }&#xA;}&#xA;&#xA;&#xA;void testdrawchar(void) {&#xA;  display.setTextSize(1);&#xA;  display.setTextColor(WHITE);&#xA;  display.setCursor(0,0);&#xA;&#xA;  for (uint8_t i=0; i &amp;lt; 168; i++) {&#xA;    if (i == '\n') continue;&#xA;    display.write(i);&#xA;    if ((i &amp;gt; 0) &amp;amp;&amp;amp; (i % 21 == 0))&#xA;      display.println();&#xA;  }    &#xA;  display.display();&#xA;}&#xA;&#xA;void testdrawcircle(void) {&#xA;  for (int16_t i=0; i&amp;lt;display.height(); i+=2) {&#xA;    display.drawCircle(display.width()/2, display.height()/2, i, WHITE);&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testfillrect(void) {&#xA;  uint8_t color = 1;&#xA;  for (int16_t i=0; i&amp;lt;display.height()/2; i+=3) {&#xA;    // alternate colors&#xA;    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);&#xA;    display.display();&#xA;    color++;&#xA;  }&#xA;}&#xA;&#xA;void testdrawtriangle(void) {&#xA;  for (int16_t i=0; i&amp;lt;min(display.width(),display.height())/2; i+=5) {&#xA;    display.drawTriangle(display.width()/2, display.height()/2-i,&#xA;                     display.width()/2-i, display.height()/2+i,&#xA;                     display.width()/2+i, display.height()/2+i, WHITE);&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testfilltriangle(void) {&#xA;  uint8_t color = WHITE;&#xA;  for (int16_t i=min(display.width(),display.height())/2; i&amp;gt;0; i-=5) {&#xA;    display.fillTriangle(display.width()/2, display.height()/2-i,&#xA;                     display.width()/2-i, display.height()/2+i,&#xA;                     display.width()/2+i, display.height()/2+i, WHITE);&#xA;    if (color == WHITE) color = BLACK;&#xA;    else color = WHITE;&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testdrawroundrect(void) {&#xA;  for (int16_t i=0; i&amp;lt;display.height()/2-2; i+=2) {&#xA;    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testfillroundrect(void) {&#xA;  uint8_t color = WHITE;&#xA;  for (int16_t i=0; i&amp;lt;display.height()/2-2; i+=2) {&#xA;    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);&#xA;    if (color == WHITE) color = BLACK;&#xA;    else color = WHITE;&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testdrawrect(void) {&#xA;  for (int16_t i=0; i&amp;lt;display.height()/2; i+=2) {&#xA;    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);&#xA;    display.display();&#xA;  }&#xA;}&#xA;&#xA;void testdrawline() {  &#xA;  for (int16_t i=0; i&amp;lt;display.width(); i+=4) {&#xA;    display.drawLine(0, 0, i, display.height()-1, WHITE);&#xA;    display.display();&#xA;  }&#xA;  for (int16_t i=0; i&amp;lt;display.height(); i+=4) {&#xA;    display.drawLine(0, 0, display.width()-1, i, WHITE);&#xA;    display.display();&#xA;  }&#xA;  delay(250);&#xA;&#xA;  display.clearDisplay();&#xA;  for (int16_t i=0; i&amp;lt;display.width(); i+=4) {&#xA;    display.drawLine(0, display.height()-1, i, 0, WHITE);&#xA;    display.display();&#xA;  }&#xA;  for (int16_t i=display.height()-1; i&amp;gt;=0; i-=4) {&#xA;    display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);&#xA;    display.display();&#xA;  }&#xA;  delay(250);&#xA;&#xA;  display.clearDisplay();&#xA;  for (int16_t i=display.width()-1; i&amp;gt;=0; i-=4) {&#xA;    display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);&#xA;    display.display();&#xA;  }&#xA;  for (int16_t i=display.height()-1; i&amp;gt;=0; i-=4) {&#xA;    display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);&#xA;    display.display();&#xA;  }&#xA;  delay(250);&#xA;&#xA;  display.clearDisplay();&#xA;  for (int16_t i=0; i&amp;lt;display.height(); i+=4) {&#xA;    display.drawLine(display.width()-1, 0, 0, i, WHITE);&#xA;    display.display();&#xA;  }&#xA;  for (int16_t i=0; i&amp;lt;display.width(); i+=4) {&#xA;    display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE); &#xA;    display.display();&#xA;  }&#xA;  delay(250);&#xA;}&#xA;&#xA;void testscrolltext(void) {&#xA;  display.setTextSize(2);&#xA;  display.setTextColor(WHITE);&#xA;  display.setCursor(10,0);&#xA;  display.clearDisplay();&#xA;  display.println(&quot;scroll&quot;);&#xA;  display.display();&#xA;&#xA;  display.startscrollright(0x00, 0x0F);&#xA;  delay(2000);&#xA;  display.stopscroll();&#xA;  delay(1000);&#xA;  display.startscrollleft(0x00, 0x0F);&#xA;  delay(2000);&#xA;  display.stopscroll();&#xA;  delay(1000);    &#xA;  display.startscrolldiagright(0x00, 0x07);&#xA;  delay(2000);&#xA;  display.startscrolldiagleft(0x00, 0x07);&#xA;  delay(2000);&#xA;  display.stopscroll();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16293" LastEditorUserId="6826" LastEditDate="2016-02-07T03:40:32.970" LastActivityDate="2016-02-07T03:40:32.970" Title="OLED display wrong (using SPI )" Tags="|arduino-uno|spi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20274" PostTypeId="1" CreationDate="2016-02-03T08:45:42.350" Score="2" ViewCount="402" Body="&lt;p&gt;I'm working on Arduino Nano and I have to use both the Bluetooth LE module &lt;strong&gt;Adafruit nRF8001&lt;/strong&gt; and &lt;strong&gt;ENC28J60&lt;/strong&gt; Ethernet module using &lt;a href=&quot;https://github.com/jcw/ethercard&quot; rel=&quot;nofollow&quot;&gt;Ethercard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea of the project is to receive data from smartphone via BLE and send it via Ethernet to check with server if the data is valid then the Arduino will send an &lt;strong&gt;ON&lt;/strong&gt; signal out of digital pin 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is when &lt;code&gt;uart.begin()&lt;/code&gt; (BLE) command invoked. I can no longer use the Ethernet module anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried remove the &lt;code&gt;uart.begin()&lt;/code&gt; part and Ethernet works fine.&#xA;I tried swap &lt;code&gt;uart.begin()&lt;/code&gt; to run before &lt;code&gt;ether.begin()&lt;/code&gt;. Ethernet cannot be initialized anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either way, the BLE module seems to work fine and the Arduino can respond to messages from smartphone. But sometimes it returns error code which I cannot understand. And after I pressed reset button on the Arduino it begins to work again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ACI Command 40&#xA;Evt Cmd respone: Error. Arduino is in an while(1); loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This version doesn't include the data verification part yet. Only send &lt;code&gt;open&lt;/code&gt; from smartphone to trigger the Ethernet request and the server will always return &lt;code&gt;you-are-good&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my sketch&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//BLUETOOTH&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;Adafruit_BLE_UART.h&quot;&#xA;&#xA;#define ADAFRUITBLE_REQ 8&#xA;#define ADAFRUITBLE_RDY 2&#xA;#define ADAFRUITBLE_RST 9&#xA;&#xA;Adafruit_BLE_UART uart = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);&#xA;static bool isBTConnected = false;&#xA;&#xA;//ETHERNET&#xA;#include &amp;lt;EtherCard.h&amp;gt;&#xA;#define ETH_CS 10&#xA;#define FORCE_STATIC_IP true&#xA;&#xA;static const byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };&#xA;byte Ethernet::buffer[140];&#xA;const char website[] PROGMEM = &quot;192.168.1.104&quot;;&#xA;const char website_path[] PROGMEM = &quot;/check&quot;;&#xA;&#xA;//TIMER AND OUTPUT&#xA;#define OUTPUT_PIN 4&#xA;#define OUTPUT_ON  LOW&#xA;#define OUTPUT_OFF HIGH&#xA;&#xA;static uint32_t timer;&#xA;static const uint16_t interval PROGMEM = 5000; // 5 seconds&#xA;static bool isOn = false;&#xA;&#xA;//ETHERNET&#xA;static void ethCallback (byte status, word off, word len) {&#xA;  Serial.println(F(&quot;&amp;gt;&amp;gt;&amp;gt; Response&quot;));&#xA;&#xA;  Ethernet::buffer[len + off] = 0;&#xA;  Serial.print((const char*) Ethernet::buffer + off);&#xA;  Serial.println(F(&quot;...&quot;));&#xA;  checkPermission(len + off);&#xA;}&#xA;&#xA;// check if the server returns exactly string &quot;you-are-good&quot;&#xA;void checkPermission (word len) {&#xA;  byte c;&#xA;  uint16_t i = 0;&#xA;  uint8_t found = 0;&#xA;&#xA;  const byte target[] PROGMEM = &quot;you-are-good&quot;;&#xA;  const uint8_t targetlen PROGMEM = 12;&#xA;&#xA;  do {&#xA;    c = Ethernet::buffer[i];&#xA;&#xA;    if (c == target[found]) {&#xA;      if (++found &amp;gt;= targetlen) {&#xA;        Serial.println(F(&quot;OK&quot;));&#xA;        outputON();&#xA;        return;&#xA;      }&#xA;    } else {&#xA;      found = 0;&#xA;    }&#xA;  } while (i++ &amp;lt;= len);&#xA;&#xA;  Serial.println(F(&quot;NOT OK&quot;));&#xA;  outputOFF();&#xA;}&#xA;&#xA;void sendRequest() {&#xA;  Serial.println();&#xA;  Serial.println(&quot;&amp;lt;&amp;lt;&amp;lt; REQ &quot;);&#xA;&#xA;  char params[64];&#xA;  String prm = &quot;?p=PARAMS_HERE&quot;;&#xA;  prm.toCharArray(params, 64);&#xA;&#xA;  ether.browseUrl(website_path, params, website, ethCallback);&#xA;}&#xA;&#xA;void initEthernet () {&#xA;  Serial.print(F(&quot;ETH:&quot;));&#xA;  if (ether.begin(sizeof Ethernet::buffer, mymac, ETH_CS) == 0)&#xA;    Serial.println(F(&quot;Failed&quot;));&#xA;  else&#xA;    Serial.println(F(&quot;OK&quot;));&#xA;&#xA;  Serial.print(F(&quot;DHCP:&quot;));&#xA;  if (FORCE_STATIC_IP || !ether.dhcpSetup()) {&#xA;    Serial.println(F(&quot;Failed\r\nStatic: &quot;));&#xA;&#xA;    byte ip[] = {192, 168, 1, 12};&#xA;    byte gw[] = {192, 168, 1, 1};&#xA;    byte dn[] = {192, 168, 1, 1};&#xA;    byte ms[] = {255, 255, 255, 0};&#xA;    ether.staticSetup(ip, gw, dn, ms);&#xA;  } else {&#xA;    Serial.println(F(&quot;OK&quot;));&#xA;  }&#xA;&#xA;  ether.printIp(F(&quot;IP:  &quot;), ether.myip);&#xA;  ether.printIp(F(&quot;GW:  &quot;), ether.gwip);&#xA;  ether.printIp(F(&quot;DNS: &quot;), ether.dnsip);&#xA;&#xA;  if (!ether.dnsLookup(website)) {&#xA;    Serial.println(F(&quot;Lookup failed&quot;));&#xA;    while (1) {&#xA;      digitalWrite(OUTPUT_PIN, HIGH);&#xA;      delay(500);&#xA;      digitalWrite(OUTPUT_PIN, LOW);&#xA;      delay(500);&#xA;    }&#xA;  }&#xA;&#xA;  ether.printIp(F(&quot;SRV: &quot;), ether.hisip);&#xA;}&#xA;&#xA;//BLUETOOTH&#xA;void initBluetooth () {&#xA;  uart.setRXcallback(rxCallback);&#xA;  uart.setACIcallback(aciCallback);&#xA;  uart.setDeviceName(PSTR(&quot;BLEUART&quot;)); /* 7 characters max! */&#xA;  Serial.print(F(&quot;BT:&quot;));&#xA;  if (uart.begin())&#xA;    Serial.println(F(&quot;OK&quot;));&#xA;  else&#xA;    Serial.println(F(&quot;FAILED&quot;));&#xA;}&#xA;&#xA;void aciCallback(aci_evt_opcode_t event) {&#xA;  switch (event)&#xA;  {&#xA;    case ACI_EVT_DEVICE_STARTED:&#xA;      Serial.println(F(&quot;Advertising started&quot;));&#xA;      break;&#xA;    case ACI_EVT_CONNECTED:&#xA;      isBTConnected = true;&#xA;      Serial.println(F(&quot;Connected!&quot;));&#xA;      break;&#xA;    case ACI_EVT_DISCONNECTED:&#xA;      isBTConnected = false;&#xA;      Serial.println(F(&quot;Disconnected or advertising timed out&quot;));&#xA;      break;&#xA;    default:&#xA;      Serial.print(F(&quot;ACI OPCODE:&quot;));&#xA;      Serial.println(event);&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;void rxCallback(uint8_t *buffer, uint8_t len) {&#xA;  uint8_t target_len = 4;&#xA;  const char* target = &quot;open&quot;;&#xA;  uint8_t counter = 0;&#xA;&#xA;  Serial.print(F(&quot;Received &quot;));&#xA;  Serial.print(len);&#xA;  Serial.print(F(&quot; bytes: &quot;));&#xA;  for (int i = 0; i &amp;lt; len; i++) {&#xA;    char ch = (char)buffer[i];&#xA;    Serial.print(ch);&#xA;    if (ch == target[counter]) {&#xA;      counter++;&#xA;    }&#xA;&#xA;    if (counter == target_len) {&#xA;      sendRequest();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//OUTPUT&#xA;void outputOFF() {&#xA;  digitalWrite(OUTPUT_PIN, LOW);&#xA;  isOn = false;&#xA;&#xA;  Serial.println(F(&quot;Locked&quot;));&#xA;}&#xA;&#xA;void outputON() {&#xA;  timer = millis() + interval;&#xA;  digitalWrite(OUTPUT_PIN, HIGH);&#xA;  isOn = true;&#xA;&#xA;  Serial.println(F(&quot;Unlocked&quot;));&#xA;}&#xA;&#xA;//ARDUINO&#xA;void setup () {&#xA;  pinMode(4, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  Serial.println(F(&quot;BT+ETH&quot;));&#xA;&#xA;  initEthernet();&#xA;  initBluetooth();&#xA;}&#xA;&#xA;void loop () {&#xA;  uart.pollACI();&#xA;  ether.packetLoop(ether.packetReceive());&#xA;&#xA;  if (isOn &amp;amp;&amp;amp; millis() &amp;gt; timer) {&#xA;    outputOFF();&#xA;  }&#xA;&#xA;  // debugging commands&#xA;  if (Serial.available()) {&#xA;    char c = Serial.read();&#xA;    if (c == '0') {&#xA;      Serial.println(F(&quot;Still OK&quot;));&#xA;    } else if (c == '1') {&#xA;      sendRequest();&#xA;    } else if (c == '2') {&#xA;      Serial.println(isBTConnected);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS. I don't know if it has something to do with the problem. But the Arduino compiler reports that Global variables use &lt;strong&gt;1,538 bytes (75%)&lt;/strong&gt; of dynamic memory. I'm planning to get another Arduino model to make sure it works fine after I added data verification part. Don't know if it will help with the problem.&lt;/p&gt;&#xA;" OwnerUserId="16960" LastEditorUserId="16960" LastEditDate="2016-02-10T07:32:06.093" LastActivityDate="2016-02-10T07:32:06.093" Title="Problem using Adafruit nRF8001 (BLE) with Ethernet module on Arduino Nano" Tags="|bluetooth|ethernet|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20276" PostTypeId="1" AcceptedAnswerId="20278" CreationDate="2016-02-03T11:04:05.750" Score="1" ViewCount="154" Body="&lt;p&gt;I'd like to offer some context about what I'd like to do because I might have misundertood something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to reduce power consumption on my device, an Arduino Mega 2560, and I've found this library&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/rocketscream/Low-Power&quot; rel=&quot;nofollow&quot;&gt;https://github.com/rocketscream/Low-Power&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which uses the Watchdog to put Arduino on power saving for a predetermined interval of time; after that it reactivates what has been disabled and let the program continue its flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched for more information about the Watchdog and I found out several warnings about dealing with Watchdog on an Arduino Mega 2560, stating that it would only work with a modified bootloader:&#xA;This scared me a bit because I'm not very keen on risking to brick my Arduino (I absolutely need it to work on the next few days).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I only have two Arduino Mega 2560 at my disposal and if I'm not mistaken, flashing the bootloader on an Arduino Mega 2560 using another Arduino Mega 2560 as a programmer can't be done because the procedure ends with errors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;( see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=126160.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=126160.0&lt;/a&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence my most important question: if I test the watchdog functionality on my code (the sketch) and the Arduino happens to continually reset, can I fix the situation by powering off the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(if you can help with my other issues as well, I'd be very grateful, I'm not sure I completely understood how these things work)&lt;/p&gt;&#xA;" OwnerUserId="15691" LastActivityDate="2016-02-03T12:43:03.263" Title="Is a power off sufficient to avoid problems with the Watchdog on Arduino Mega 2560?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20277" PostTypeId="2" ParentId="20262" CreationDate="2016-02-03T11:58:46.327" Score="2" Body="&lt;p&gt;&lt;strong&gt;ONE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is use a while loop waiting for the first pulse and then wait until the last pulse, for an idea look at &lt;a href=&quot;https://dl.dropboxusercontent.com/u/2253850/Chronograph_7_Seg_on_Nano.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;this code from &lt;/a&gt;Gadjet, he made a &lt;a href=&quot;http://gadjetsblog.blogspot.co.za/2013/02/air-rifle-chronograph.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;chronograph&lt;/a&gt; with a similar operation, you would just need to adapt the design, this might not be as accurate for an 1&quot;. Also it will be the issue of having ties between cars. This is short as I don't like this option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TWO:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option, although using what you don't want to use, would be using the interrupts on the Arduino. &lt;em&gt;I am basing the following on the fact that you are using two cars.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is have a &lt;code&gt;finish line&lt;/code&gt; for &lt;em&gt;both vehicles&lt;/em&gt; and detect a break with a interrupt, one interrupt pin per lane(UNO has to interrupts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick here is that you place both the outputs from one lane onto a single interrupt pin with a edge detector type of &lt;a href=&quot;https://electronics.stackexchange.com/questions/158015/how-to-turn-continuous-signal-into-a-short-pulse-using-logic-gates&quot;&gt;circuit&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; to generate a pulse while the vehicle crosses a point, especially important as it will be in the inch area for a while. The code handles the double pulse on one pin. I know this works as I used this on a ballistic chronograph which works in microseconds detecting shots &gt;2000fps over a 0.406 foot distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; This is an example of the circuit you would use at the output of each sensor before the OR gates:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/eXQMP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eXQMP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware would just become a duplicate for each lane, and to combine the input on one pin you can use an &lt;a href=&quot;http://www.digikey.com/product-search/en/integrated-circuits-ics/logic-gates-and-inverters/2556317&quot; rel=&quot;nofollow noreferrer&quot;&gt;OR gate IC&lt;/a&gt; or you can use diode OR gate:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ntAAj.gif&quot; alt=&quot;from ee.se&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupts are actually easy to use with Arduinos, and there are &lt;a href=&quot;https://www.google.com/search?q=arduino%20interrupts&amp;amp;spell=1&amp;amp;sa=X&amp;amp;ved=0ahUKEwjg9LD2m9vKAhXFRhQKHTY7A1oQvwUIGigA&quot; rel=&quot;nofollow noreferrer&quot;&gt;a lot of examples&lt;/a&gt; out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at the below flow chart to get an idea of operation in the code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/88Q1C.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/88Q1C.png&quot; alt=&quot;RSM code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A small thing would be that the code ignores a interrupt once the cars have passed so it doesn't calculate a second time.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-03T11:58:46.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20278" PostTypeId="2" ParentId="20276" CreationDate="2016-02-03T12:43:03.263" Score="0" Body="&lt;p&gt;The problem you have is that once the watchdog is turned on it is very hard to turn it off again. There are certain procedures you have to go through to ensure it's turned off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default bootloader doesn't turn the bootloader off, and a reset doesn't turn it off either. The watchdog then fires whilst the bootloader is still waiting for communication from the PC thus making it reboot before your sketch has had a chance to run. Hence the change needed in the bootooader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to clear the watchdog is to remove the power. However as soon as your sketch runs and turns the watchdog back on you are then back at square one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to upload a new sketch to stop that happening, but that is tricky, since the watchdog keeps resetting and interrupting the bootloader. So what do you do? Well, there's a specific sequence you need to do.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Unplug the mega&lt;/li&gt;&#xA;&lt;li&gt;Compile the new sketch&lt;/li&gt;&#xA;&lt;li&gt;Hold the reset button on the mega&lt;/li&gt;&#xA;&lt;li&gt;Plug in the mega&lt;/li&gt;&#xA;&lt;li&gt;Press upload&lt;/li&gt;&#xA;&lt;li&gt;As soon as avrdude starts release the reset button.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That way you have a chance of the bootloader running without your sketch having run first and enabled the watchdog. The bootloader runs just the once when the computer is tryung to upload the sketch, and with luck that will happen instead of your sketch running.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-03T12:43:03.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20279" PostTypeId="2" ParentId="20272" CreationDate="2016-02-03T12:48:44.290" Score="1" Body="&lt;p&gt;A phone running in wifi tethering (mobile hotspot) mode is no different to a wifi access point or router. So yes, you can use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chances are though that you will need a mobile internet connection in order to activate mobile hotspot mode in the first place.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-03T12:48:44.290" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20280" PostTypeId="1" CreationDate="2016-02-03T13:25:42.813" Score="1" ViewCount="167" Body="&lt;p&gt;I can't compile a simple blink sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Error is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[Stino - Start building &quot;t5&quot;...]&#xA;[  3%] Creating C:\Users\lov\AppData\Local\Temp\Stino_build\t5\t5.ino.cpp.o...&#xA;The filename, directory name, or volume label syntax is incorrect.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://arduino.stackexchange.com/questions/18601/sublime-text-compilation-issue&quot;&gt;see similar question, that answer not working here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Path to IDE app is &lt;code&gt;C:\Program Files (x86)\added\Arduino&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16999" LastEditorUserId="4628" LastEditDate="2017-01-30T05:13:42.363" LastActivityDate="2017-08-30T00:06:05.270" Title="Sublime Text 2 with stino, compilation gives &quot;filename ... is incorrect&quot; Arduino IDE 1.7.8" Tags="|arduino-ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20281" PostTypeId="2" ParentId="20280" CreationDate="2016-02-03T13:32:00.607" Score="1" Body="&lt;p&gt;Sorry but this is too big for a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly please can you check the obvious, in Windows Explorer paste the path C:\Users\lov\AppData\Local\Temp\Stino_build\t5 into the address bar and does the directory exist. (I have fallen for that so many times)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly do you have permission to create a file there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you updated the IDE? Does blink compile?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried running the IDE as admin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully one of those will fix it.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-02-03T13:32:00.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20282" PostTypeId="1" AcceptedAnswerId="20283" CreationDate="2016-02-03T14:49:35.573" Score="0" ViewCount="361" Body="&lt;p&gt;I would like to copy a file that is in the root folder of my Yun, to my Macbook. They are connected with an ethernet cable and I am logged into the Yun through ssh.&#xA;The Yun's IP is 192.168.2.16 while the Mac's is 192.168.2.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I copy a file from the Yun?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I tried to copy a file from the Macbook to the Yun using &quot;scp&quot; and it worked, but now I don't know how to do for the other direction&lt;/p&gt;&#xA;" OwnerUserId="15045" LastActivityDate="2016-02-03T14:51:57.430" Title="How to copy files from Yun to local computer?" Tags="|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20283" PostTypeId="2" ParentId="20282" CreationDate="2016-02-03T14:51:57.430" Score="2" Body="&lt;p&gt;You simply reverse the arguments.  Whatever you used to copy a file &lt;em&gt;to&lt;/em&gt; the Yun you just do the opposite to copy &lt;em&gt;from&lt;/em&gt; the Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you copied to the Yun using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scp /my/local/file root@192.168.2.16:/where/you/want/it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you would change it around to copy from the Yun thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;scp root@192.168.2.16:/path/to/file /where/you/want/it/to/go&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-03T14:51:57.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20284" PostTypeId="1" AcceptedAnswerId="20285" CreationDate="2016-02-03T14:59:02.573" Score="0" ViewCount="1097" Body="&lt;p&gt;Can somebody please tell me what is the operating voltage of ESP8266? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the A0 voltage range?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am powering it up from USB (5v) and have a sensor that comes back with Analog value, to calculate it correctly I am asked to provide &quot;Logical Voltage&quot; value that is either 3300 or 5000 (3.3v or 5v). Sensor is connected to 3.3V port as there is no 5v port on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I choose here 3300 or 5000 for NodeMCU V3?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="17003" LastEditorUserId="11529" LastEditDate="2016-02-03T18:30:49.267" LastActivityDate="2016-02-03T18:30:49.267" Title="ESP8266 NodeMCU v3 basic questions" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20285" PostTypeId="2" ParentId="20284" CreationDate="2016-02-03T15:04:24.357" Score="2" Body="&lt;p&gt;The subtle clue is in the voltage that is available. That is, the only voltage provided on the board is 3.3v. That's a slight hint that the board might run at 3.3v. And you would be right in that assumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 chips, as are most modern MCUs more powerful than 8-bit, 3.3v devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would choose 3300 as your &quot;Logical Voltage&quot; value.  Or better still, measure the 3.3V and find exactly what it is and use that value x 1000 (for example 3317 or 3295).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-03T15:04:24.357" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20286" PostTypeId="1" AcceptedAnswerId="20308" CreationDate="2016-02-03T17:04:19.050" Score="2" ViewCount="219" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9ee55.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9ee55.jpg&quot; alt=&quot;Picture of the boards&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to make motion capture and someone gave me these boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it's a test board for MPU 9500. I tried to google but I only found datasheets. What boards are these?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;ITG-3500 evb&quot; is written on the back of the green board.&lt;br&gt;&#xA;I think this is &lt;a href=&quot;http://store.invensense.com/datasheets/invensense/AN-IVS-0001EVB-00-v1-2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; of green board maybe  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;EV_ARM_XXAXA_D&quot; is written on the back of the blue board.&lt;/p&gt;&#xA;" OwnerUserId="17008" LastEditorUserId="17008" LastEditDate="2016-02-04T14:29:33.380" LastActivityDate="2016-02-04T14:29:33.380" Title="How to use ITG-3500 evb" Tags="|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20287" PostTypeId="2" ParentId="20286" CreationDate="2016-02-03T17:11:12.343" Score="1" Body="&lt;p&gt;The green board is an ITG-3500 (3 axis gyroscope) evaluation board of some form.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blue board is some form of microcontroller evaluation board. It probably has one of the Atmel SAM chips on it since it mentions ARM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's about all you'll get from us I'm afraid, unless there is the highly unlikely situation that someone here happens to have the exact same boards as you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-03T17:11:12.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20288" PostTypeId="1" AcceptedAnswerId="20289" CreationDate="2016-02-03T17:19:23.443" Score="0" ViewCount="3015" Body="&lt;p&gt;I want to run a 9g servo off of the pins from an arduino nano board, using only the 5v USB connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servo specifically is a SG90, which I have measured a stall current of ~250mA - I don't intend to stall it, just have it run with almost no load&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure which pins to power it off of from the arduino itself - do I use the VCC or the +5v? does it matter which ground I use? should I use a breadboard to help me place any other components that may be needed, i.e. a capacitor or something? does the arduino nano negotiate to get more than the default of 100mA from a USB power connection?&lt;/p&gt;&#xA;" OwnerUserId="10606" LastActivityDate="2016-02-03T21:52:39.517" Title="Can I power a 9g servo from an arduino nano with USB power only?" Tags="|power|usb|arduino-nano|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20289" PostTypeId="2" ParentId="20288" CreationDate="2016-02-03T17:35:11.523" Score="2" Body="&lt;p&gt;&lt;strike&gt;The max current of the Arduino-Nano 5V Pin is 200mA. So if you draw more than that it might damage your Arduino.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an interesting summary regarding the Maximum Ratings of the Arduino Nano: &lt;a href=&quot;https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins&quot;&gt;https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 5V pin of the arduino is not connected through the&#xA;  microcontroller. As such, it can source significantly more power. When&#xA;  you are powering your arduino from USB, the USB interface limits your&#xA;  total power consumption to 500 mA.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So yes, it actually seems you can draw 250mA out of the 5V PIN.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;do I use the VCC or the +5v?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You use +5V, because VCC is for powering your Arduino with an external Power Source. It allows you to use up to 7-12V (recommended), or up to 6-20V (limits).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;does it matter which ground I use?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Doesn't matter&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;should I use a breadboard to help me place any other components that may be needed, i.e. a capacitor or something?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A breadboard makes it easier for you, to test your circuit. But you can do it without if you like. Then you possibly have to solder some connections&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;offical Arduino Page&lt;/a&gt; for the Nano.&lt;/p&gt;&#xA;" OwnerUserId="15493" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-03T21:52:39.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20290" PostTypeId="2" ParentId="20266" CreationDate="2016-02-03T18:40:51.220" Score="2" Body="&lt;p&gt;Oh, the joys of buying something off the Internet with no datasheet, no part number and no clue how to use it. And then expecting somebody else to tell you how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That module looks like a KY-038, made by Keyes. No guarantees, though, because I'm not telepathic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bytes don't &quot;pass through the soundsensor&quot;. Bytes don't pass anywhere, in fact. That board has an analogue output, &lt;code&gt;A0&lt;/code&gt;, which is the amplified audio sensed by the microphone. It swings between 0 and 5 volts, and is 2.5V when no sound is being picked up. The board also has a digital output, &lt;code&gt;D0&lt;/code&gt;, which is &lt;strong&gt;active-low&lt;/strong&gt; when the intensity of the sound picked up by the microphone exceeds a thershold. I have no idea what this threshold is or what volume it represents, or if it can be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look at the pages on &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow&quot;&gt;AnalogRead()&lt;/a&gt; for information on how to convert analogue audio to a digital signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what you mean by &quot;a Lib PCM thats converts chars in voices&quot; - 'chars' as in the C-type &lt;code&gt;chars&lt;/code&gt; or do you mean literal 'characters from a voice', i.e. speech recognition? I cannot tell if you have misunderstood something or there's an unfortunate translation coincidence which is confusing matters.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-02-03T18:40:51.220" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20291" PostTypeId="2" ParentId="20273" CreationDate="2016-02-03T18:42:12.267" Score="0" Body="&lt;p&gt;Check the connections with that required by the software/library. If you intend to use SPI the pins on Arduino Uno are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SS   10&#xA;MOSI 11&#xA;MISO 12&#xA;SCK  13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You connections above are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VCC             =&amp;gt; 5V&#xA;D0(OLED_CLK)    =&amp;gt; 10 (SPI SS ??)&#xA;D(OLED_MOSI)    =&amp;gt; 9  &#xA;RES(OLED_RESET) =&amp;gt; 13 (SPI SCK ??)&#xA;D/C(OLED_DC)    =&amp;gt; 11 (SPI MOSI ??)&#xA;CS（OLED_CS）     =&amp;gt; 12 (SPI MISO ??)&#xA;GND             =&amp;gt; GND (??)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is not correct for SPI. Post link to library, oled hardware, and snippet of your code for more help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is more than the video that is out of focus :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-03T18:42:12.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20292" PostTypeId="2" ParentId="17479" CreationDate="2016-02-03T18:59:54.960" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I would like to know the specs of the accelerometer used on a LightBlue Bean before buying one, but I couldn't find any info online. Anybody has an idea?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Start by checking the Adafruit &lt;a href=&quot;https://www.adafruit.com/products/2732&quot; rel=&quot;nofollow&quot;&gt;LightBlue Bean&lt;/a&gt; product description. There you can find a link to the &lt;a href=&quot;https://www.adafruit.com/images/product-files/2732/Bean_revE_board_export.pdf&quot; rel=&quot;nofollow&quot;&gt;schematics and board layout&lt;/a&gt;. On page two there is accelerometer, a BMA250 just as @Jason links to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That took &quot;30 seconds&quot; web search plus writing this answer :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-03T18:59:54.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20293" PostTypeId="2" ParentId="20262" CreationDate="2016-02-03T19:34:57.623" Score="2" Body="&lt;p&gt;Building upon Nick Gammon's excellent answer at &lt;a href=&quot;https://arduino.stackexchange.com/questions/1784/how-many-interrupt-pins-can-an-uno-handle/12958#12958&quot;&gt;How many interrupt pins can an Uno handle?&lt;/a&gt; here's some untested code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; const int events = 256; // events to store&#xA; unsigned volatile int index;  &#xA; byte pinStates[events];&#xA; unsigned int times[events];&#xA;&#xA; ISR (PCINT1_vect) //  Watch for pin changes on the C port (Uno pins A0-A5)&#xA; {&#xA;   if (index == 0) { // start clock&#xA;    TCCR1B = bit(CS12) | bit (CS10) ;    // clock/1024 for &amp;lt;4.19s x 64us&#xA;    //TCCR1B = bit(CS12);                // clock/256  for &amp;lt;1.05s x 16us &#xA;    //TCCR1B = bit(CS11) | bit (CS10) ;  // clock/64   for &amp;lt;0.25s x 4us&#xA;    //TCCR1B = bit(CS11) ;               // clock/8    for &amp;lt;0.03s x 0.5us&#xA;    //TCCR1B = bit(CS10) ;               // clock/1    for &amp;lt;0.004s x 62ns&#xA;   }&#xA;   times[index] = TCNT1;&#xA;   pinStates[index] = PORTC;&#xA;   index = (index+1) &amp;amp; 0xff; // increment and protect from overflow&#xA;&#xA; }  // end of PCINT1_vect&#xA;&#xA;void setup ()&#xA;  { &#xA;  // activate pin change interrupts on port C / pins A0-A5&#xA;&#xA;  PCICR   =  bit (PCIE1);    // enable PCINT[14:8] pin triggers &#xA;  PCMSK1 |=  bit (PCINT8) | &#xA;             bit (PCINT9) | &#xA;             bit (PCINT10) | &#xA;             bit (PCINT11) | &#xA;             bit (PCINT12) | &#xA;             bit (PCINT13);     // enable individual pins&#xA;&#xA;  // stop and clear 16 bit timer  CS1[0-2]=0; TCNT1 = 0;&#xA;  TCCR1A = 0;  // no comparisons, normal WGM mode, stop the counting &#xA;  TCCR1B = 0;  &#xA;  TCNT1  = 0;  // Clear the counter&#xA;&#xA;  pinMode (A0, INPUT_PULLUP);&#xA;  pinMode (A1, INPUT_PULLUP);&#xA;  pinMode (A2, INPUT_PULLUP);&#xA;  pinMode (A3, INPUT_PULLUP);&#xA;  pinMode (A4, INPUT_PULLUP);&#xA;  pinMode (A5, INPUT_PULLUP);&#xA;&#xA;  index = 0 ; // nothing happened yet&#xA;&#xA;  pinMode (5, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;   // check index, parse and report times, check for arming, etc...&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point is to use the pin change interrupt to record state changes on the pins and the times.   The clock/1024 prescaler would give a 1/16MhZ*1024*65536= 4.19s window at 64us resolution timing counts, but you could go to higher resolution with a tighter window by using a smaller prescaler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you wanted longer timing windows, you could cascade timer1 into timer0 (messing up millis(), etc.,) and get 24 bits of range before overflow, but a better way than cascading timers might be to add another interrupt to increment a variable.  For much longer timing windows add another quick interrupt to handle for timer1 overflow.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;volatile unsigned long int t1Cycles,times[events];&#xA;...&#xA;&#xA;ISR(TIMER1_OVF_vect){t1Cycles++;}  &#xA;&#xA;void setup(){&#xA;    ...&#xA;    TIMSK1 = bit(TOIE1);&#xA;    t1Cycles = 0;&#xA;    ...&#xA;} &#xA;&#xA;ISR (PCINT1_vect)&#xA;{&#xA;    ...&#xA;    times[index] = t1Cycles &amp;lt;&amp;lt; 16 | TCNT1; // store 32 bit count of clocks&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is still untested, but it looks like it could be capable of 268 seconds worth of 62ns resolution multichannel timing.  With the longer period, you could move the conditional clock-starting code out of the pin-change ISR.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-02-04T05:11:11.963" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20294" PostTypeId="1" CreationDate="2016-02-03T20:32:01.750" Score="20" ViewCount="21580" Body="&lt;p&gt;Please, help me to set up Clion + Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clion has an Arduino plugin which I've installed. Here is some instruction on Github but I'm fully noob about &lt;code&gt;cmake&lt;/code&gt; and other things which are talking about in instruction. I have only used Arduino IDE before for my simple projects. Now in CLion I can create an Arduino projects but autocompletion doesn't work. Actually it works but does it on true C, not for Arduino code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you can please explain like for complete idiot, what I should change to get working Arduino autocompletion. &lt;/p&gt;&#xA;" OwnerUserId="16647" LastEditorUserId="6936" LastEditDate="2018-07-19T20:26:18.857" LastActivityDate="2020-07-06T19:52:15.520" Title="CLion + Arduino" Tags="|arduino-ide|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20295" PostTypeId="1" CreationDate="2016-02-03T22:22:14.653" Score="-1" ViewCount="154" Body="&lt;p&gt;i' m trying to simulate a robot' s movement on a 2d array. In my case, robot goes forward firstly, if it sees a engel, it turns left and continues its movement. The problem is that, i could not present turning left and moving on left-direction on the initial matrix. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here' s my code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#define x 7                                         //Matrix dimensions&#xA;#define y 7&#xA;&#xA;const int trigPin = 12;&#xA;const int echoPin = 11;&#xA;&#xA;Servo myServo;                                     //variable definations&#xA;Servo myServo2;&#xA;&#xA;int pos = 0;&#xA;&#xA;int counter;&#xA;int counter1 = 0;&#xA;int counter2;&#xA;int counter3;&#xA;&#xA;int integer;&#xA;int integer2;&#xA;int integer4;&#xA;&#xA;long duration;&#xA;long distance;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    myServo.attach(9);&#xA;    myServo2.attach(10);&#xA;    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output&#xA;    pinMode(echoPin, INPUT); // Sets the echoPin as an Input&#xA;}&#xA;&#xA;void loop() {&#xA;    int my2dArray[x][y] = {                          // initial matrix&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;        {1, 1, 1, 0, 1, 1, 1},&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;        {1, 1, 1, 1, 1, 1, 1},&#xA;    };&#xA;    // Clears the trigPin&#xA;    digitalWrite(trigPin, LOW);&#xA;    delayMicroseconds(2);&#xA;// Sets the trigPin on HIGH state for 10 micro seconds&#xA;    digitalWrite(trigPin, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(trigPin, LOW);&#xA;// Reads the echoPin, returns the sound wave travel time in microseconds&#xA;    duration = pulseIn(echoPin, HIGH);&#xA;// Calculating the distance&#xA;    distance = duration * 0.034 / 2;&#xA;    int robot = my2dArray[3][3];                   // first place of robot&#xA;&#xA;    if (counter1 &amp;gt; 0) {&#xA;        for (integer = 0;  integer &amp;lt; counter1; integer += 1) {&#xA;            if (distance &amp;lt; 10) {                                  //seeing     the object&#xA;                for (pos = 0; pos &amp;lt;= 180 ; pos += 1) {              //turning left&#xA;                    myServo.write(pos);&#xA;                }&#xA;&#xA;                for (pos = 0; pos &amp;lt;= 180  ; pos += 1) {            //moving on after turning&#xA;                    myServo.write(pos);&#xA;                    myServo2.write(pos);&#xA;&#xA;                    if (pos == 180) {&#xA;                        counter3 +=  1;&#xA;                    }&#xA;                }&#xA;&#xA;                Serial.println(integer);&#xA;&#xA;                for (integer4 = 0;  integer4 &amp;lt; counter3; integer4 += 1) {     //modifying matrix if there is an object&#xA;                    my2dArray[3 + integer][3 + integer4] = robot * my2dArray[3 + integer][3 + integer4];&#xA;                }&#xA;&#xA;                Serial.println(&quot;Break condition.&quot;);&#xA;                break;&#xA;            } else {&#xA;                my2dArray[3 + integer][3] = robot * my2dArray[3 + integer][3];    //modifying matrix in case of there is no object&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    for (integer2 = 0; integer2 &amp;lt; 7; integer2++) {                          //displaying matrix&#xA;        Serial.print(my2dArray[integer2][0]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.print(my2dArray[integer2][1]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.print(my2dArray[integer2][2]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.print(my2dArray[integer2][3]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.print(my2dArray[integer2][4]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.print(my2dArray[integer2][5]);&#xA;        Serial.print(&quot;|&quot;);&#xA;        Serial.println(my2dArray[integer2][6]);&#xA;    }&#xA;&#xA;    Serial.println();&#xA;&#xA;    for (pos = 0; pos &amp;lt;= 180  ; pos += 1) {                               // moving forward as first movement&#xA;        myServo.write(pos);&#xA;        myServo2.write(pos);&#xA;&#xA;        if (pos == 180) {&#xA;            counter1 +=  1;&#xA;        }&#xA;    }&#xA;&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem part is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (integer4 = 0;  integer4 &amp;lt; counter3; integer4 += 1){      //modifying matrix if there is an object&#xA;&#xA;    my2dArray[3 + integer][3+integer4] = robot * my2dArray[3 + integer][3+integer4];&#xA;&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;integer&quot; value does not change in the problem part, it' s always 0 in despite of the first for loop. How can i pass the &quot;integer&quot; to the problem part properly? &lt;/p&gt;&#xA;" OwnerUserId="16134" LastEditorUserId="4143" LastEditDate="2016-02-04T11:36:56.333" LastActivityDate="2022-12-01T23:02:35.247" Title="For loop question-Simulating a robot' s movement on a 2d array" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20296" PostTypeId="2" ParentId="20294" CreationDate="2016-02-03T23:00:54.567" Score="25" Body="&lt;p&gt;Rather than using any plugin, I am using CLion with &lt;a href=&quot;http://platformio.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PlatformIO&lt;/a&gt;, which supports several IDEs. CLion then not only gives you code completion, but also full support for refactoring, Git, and much much more.&lt;/p&gt;&#xA;&lt;p&gt;From &lt;a href=&quot;https://docs.platformio.org/en/latest/integration/ide/clion.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;its documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[...] generate project via &lt;code&gt;platformio init --ide&lt;/code&gt; command:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;platformio init --ide clion --board %TYPE%&#xA;&#xA;# For example, generate project for Arduino UNO&#xA;platformio init --ide clion --board uno&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Then import the project in CLion and you're about done.&lt;/p&gt;&#xA;&lt;p&gt;Some hints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure your code is in the &lt;code&gt;src&lt;/code&gt; folder, and that the main file has a &lt;code&gt;.cpp&lt;/code&gt; extension.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For other files: either rename all &lt;code&gt;.ino&lt;/code&gt; files to use &lt;code&gt;.cpp&lt;/code&gt;, or tell CLion to associate the &lt;code&gt;.ino&lt;/code&gt; extension with C++ files. (Preferences, Editors, File Types.)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Whenever adding libraries to the &lt;code&gt;lib&lt;/code&gt; folder (and using &lt;code&gt;#include&lt;/code&gt; to refer to them), just run the above &lt;code&gt;init&lt;/code&gt; command again.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you're using ESP-boards and changed &lt;code&gt;platform.txt&lt;/code&gt; for an alternative &lt;code&gt;esptool&lt;/code&gt;, then note that PlatformIO &lt;a href=&quot;https://arduino.stackexchange.com/questions/20219/upload-with-esptool-fails-with-espcomm-send-command-cant-receive-slip-payload/20220#20220http://&quot;&gt;needs a different hack&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rather than using the CLion Serial Monitor plugin, I simply use a Terminal within CLion to upload and start the monitor as soon as possible:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;pio run -t upload; pio device monitor -b 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you always want to upload and monitor whenever using &lt;code&gt;pio run&lt;/code&gt;, then add:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[env]&#xA;targets = upload, monitor&#xA;upload_protocol = esptool&#xA;upload_speed = 115200&#xA;monitor_speed = 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Nowadays, &lt;a href=&quot;https://plugins.jetbrains.com/plugin/13922-platformio-for-clion&quot; rel=&quot;nofollow noreferrer&quot;&gt;CLion has a PlatformIO plugin&lt;/a&gt; as well, including a menu Tools, PlatformIO with commands such as Re-init.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16852" LastEditorUserId="16852" LastEditDate="2020-07-06T19:52:15.520" LastActivityDate="2020-07-06T19:52:15.520" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="20298" PostTypeId="1" AcceptedAnswerId="20305" CreationDate="2016-02-04T00:18:59.027" Score="0" ViewCount="257" Body="&lt;p&gt;I build a circuit that work on breadboard now i try to prototype it,so i start solder it on a prototype board and the arduino is out of sync.So i check the tension and for some reason it's 4.4~4.6 on the Vin pin of Atmega328 so i try to find how to debug.I don't have a lot of theorical knowledge on electronic,but my thougt was as long as everything is plug in parrallel the tension should remain the same ( and i don't have any thing in serie) so for the tension to drop i may have something acting as Resistor, and i try to find how and what.&#xA;I use 22AWG 0.7mm wire o create a 5V line and my GND line on each side of the Atmega ( roughly 7 cm on each side),i start to wondering if it was not a bad idea. I have picture of my prototype bellow,but it's messy so not sure it help. My question is how to you proceed to troubleshoot this thing ? What are the step you do to find out where is the problem &lt;a href=&quot;https://i.stack.imgur.com/WgnF6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WgnF6.jpg&quot; alt=&quot;Atmega328&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10564" LastActivityDate="2016-02-04T05:20:13.383" Title="Arduino on breadboard Tension is 4.4V instead of 5 V,looking for some guidance" Tags="|arduino-uno|atmega328|electronics|prototype|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20300" PostTypeId="2" ParentId="18432" CreationDate="2016-02-04T00:25:52.913" Score="0" Body="&lt;p&gt;Your system works in pure C too:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct _MenuItem&#xA;{&#xA;    const char *label; // or String if you like&#xA;    void (*callback)();&#xA;} MenuItem;&#xA;&#xA;void testCallback()&#xA;{&#xA;    Serial.println(&quot;testCallback() Called&quot;);&#xA;}&#xA;&#xA;MenuItem menu_system[10];    &#xA;void setup()&#xA;{&#xA;    menu_system[0].label    = &quot;Test&quot;;&#xA;    menu_system[0].callback = testCallback;&#xA;&#xA;    ... # more menu definitions with callbacks&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    unsigned int user_menu_selection;&#xA;&#xA;    ... # some menu code, user selection in &amp;lt;user_menu_selection&amp;gt;&#xA;&#xA;    menu_system[user_menu_selection].callback();  // TODO: error checking&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might be a good idea to store any static Menu Strings into &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;PROGMEM&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-04T00:25:52.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20301" PostTypeId="1" AcceptedAnswerId="20302" CreationDate="2016-02-04T00:57:19.780" Score="1" ViewCount="1800" Body="&lt;p&gt;I'm doing a little project that, on a press of a button, will light up three LEDs and then will turn off the LEDs in different times. I'm using the &lt;code&gt;millis()&lt;/code&gt; function to control the time that each LED will be on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the first time that I press the button, everything works fine. But the problem starts when I press the button for the second time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I press the button soon after the loop ends, something goes wrong and the behavior of the LED become a mess (just one or two LEDs light up in weird times). But, if I wait about 2 seconds before pressing the button for the second time, everything goes right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin1 =  11;&#xA;  const int ledPin2 =  12;&#xA;  const int ledPin3 =  13;&#xA;  const int buttonPin = 2; &#xA;&#xA;  int buttonState = 0;&#xA;  long previousMillis1 = 0;&#xA;  long previousMillis2 = 0;&#xA;  long previousMillis3 = 0;&#xA;&#xA;  int state = 0;&#xA;&#xA;  void setup() &#xA;  {&#xA;    pinMode(ledPin1, OUTPUT);&#xA;    pinMode(ledPin2, OUTPUT);&#xA;    pinMode(ledPin3, OUTPUT);   &#xA;    pinMode(buttonPin, INPUT);&#xA;&#xA;    Serial.begin(9600);&#xA;  }&#xA;&#xA;  void loop()&#xA;  {&#xA;&#xA;       buttonState = digitalRead(buttonPin);&#xA;&#xA;       if (buttonState == HIGH) {&#xA;        state = 1;&#xA;       }&#xA;&#xA;       if (state == 1)&#xA;       {&#xA;        taskExecute(3000, 2000, 4000);&#xA;       }&#xA;  }&#xA;&#xA;  void taskExecute(int tMotor1, int tMotor2, int tMotor3)&#xA;  {&#xA;&#xA;    int ledState1 = HIGH; &#xA;    int ledState2 = HIGH;&#xA;    int ledState3 = HIGH; &#xA;&#xA;    digitalWrite(ledPin1, ledState1);&#xA;    digitalWrite(ledPin2, ledState2);&#xA;    digitalWrite(ledPin3, ledState3);&#xA;&#xA;    do&#xA;    {&#xA;      unsigned long currentMillis = millis();&#xA;&#xA;      if(currentMillis - previousMillis1 &amp;gt; tMotor1) &#xA;      {&#xA;        previousMillis1 = currentMillis;   &#xA;&#xA;        if (ledState1 == HIGH)&#xA;          ledState1 = LOW;&#xA;&#xA;        digitalWrite(ledPin1, ledState1);&#xA;      }&#xA;&#xA;      if(currentMillis - previousMillis2 &amp;gt; tMotor2) &#xA;      {&#xA;        previousMillis2 = currentMillis;   &#xA;&#xA;        if (ledState2 == HIGH)&#xA;          ledState2 = LOW;&#xA;&#xA;        digitalWrite(ledPin2, ledState2);&#xA;      }&#xA;&#xA;      if(currentMillis - previousMillis3 &amp;gt; tMotor3) &#xA;      {&#xA;        previousMillis3 = currentMillis;   &#xA;&#xA;        if (ledState3 == HIGH)&#xA;          ledState3 = LOW;&#xA;&#xA;        digitalWrite(ledPin3, ledState3);&#xA;      }&#xA;    } while (ledState1 == HIGH || ledState2 == HIGH || ledState3 == HIGH);&#xA;    state = 0;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other strange thing that happens is that sometimes the time that i've been set in millis for the led get on become a little different. Example: when I press the button, the LED 1 needs to light up for 3 seconds, but he lights up just 2.5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What i'm doing wrong? Thanks!!&lt;/p&gt;&#xA;" OwnerUserId="17016" LastEditorUserId="6936" LastEditDate="2016-02-04T13:58:08.463" LastActivityDate="2016-02-04T13:58:08.463" Title="millis() not working properly" Tags="|millis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20302" PostTypeId="2" ParentId="20301" CreationDate="2016-02-04T01:14:33.350" Score="1" Body="&lt;p&gt;The variables &lt;code&gt;previousMillis&lt;/code&gt; (1-3) are not properly initialised.  So if you wait a while before pressing the button, that delay time becomes part of the time that the LED is illuminated for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your &lt;code&gt;taskExecute()&lt;/code&gt; function sets them before the loop, this will fix that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void taskExecute(int tMotor1, int tMotor2, int tMotor3)&#xA;{&#xA;    int ledState1 = HIGH;&#xA;    int ledState2 = HIGH;&#xA;    int ledState3 = HIGH;&#xA;&#xA;    digitalWrite(ledPin1, ledState1);&#xA;    digitalWrite(ledPin2, ledState2);&#xA;    digitalWrite(ledPin3, ledState3);&#xA;&#xA;    unsigned long time_now = millis();&#xA;    previousMillis1 = time_now;&#xA;    previousMillis2 = time_now;&#xA;    previousMillis3 = time_now;&#xA;&#xA;    do &#xA;    {&#xA;        ...&#xA;    } while (ledState1 == HIGH || ledState2 == HIGH || ledState3 == HIGH);&#xA;    state = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On a coding-style note - I did not initially see the resetting of the global variable &lt;code&gt;state=0&lt;/code&gt; at the end of the &lt;code&gt;taskExecute()&lt;/code&gt; function.  It might be better to move this up to underneath the initial call to &lt;code&gt;taskExecute()&lt;/code&gt; so all the &lt;code&gt;state&lt;/code&gt; handling is in one place.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-04T01:20:48.923" LastActivityDate="2016-02-04T01:20:48.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20303" PostTypeId="1" CreationDate="2016-02-04T03:48:29.117" Score="2" ViewCount="3575" Body="&lt;p&gt;I have done a lot of tries to make my two IMU work with my arduino. I'm also done with many research about it and I found this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; // I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class&#xA; // 10/7/2011 by Jeff Rowberg &amp;lt;jeff@rowberg.net&amp;gt;&#xA; // Updates should (hopefully) always be available at&#xA; //https://github.com/jrowberg/i2cdevlib&#xA; //&#xA;// Changelog:&#xA;//     2011-10-07 - initial release&#xA;&#xA;/* ============================================&#xA; I2Cdev device library code is placed under the MIT license&#xA; Copyright (c) 2011 Jeff Rowberg&#xA;&#xA;&#xA;&#xA;&#xA; // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE   implementation&#xA; // is used in I2Cdev.h&#xA; #include &quot;Wire.h&quot;&#xA;&#xA; // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files&#xA;// for both classes must be in the include path of your project&#xA; #include &quot;I2Cdev.h&quot;&#xA; #include &quot;MPU6050.h&quot;&#xA;&#xA;// class default I2C address is 0x68&#xA;// specific I2C addresses may be passed as a parameter here&#xA;// AD0 low = 0x68; (default for InvenSense evaluation board)&#xA;//AD0 high = 0x69;&#xA;MPU6050 accelgyro;&#xA;// accelgyroIC1.initialize();&#xA;//accelgyroIC2.initialize();&#xA;MPU6050 accelgyroIC1(0x69);&#xA;MPU6050 accelgyroIC2(0x68);&#xA;&#xA;int16_t ax1, ay1, az1;&#xA;int16_t gx1, gy1, gz1;&#xA;&#xA;int16_t ax2, ay2, az2;&#xA;int16_t gx2, gy2, gz2;&#xA;&#xA;#define LED_PIN 13&#xA;bool blinkState = false;&#xA;&#xA;void setup() {&#xA;// join I2C bus (I2Cdev library doesn't do this automatically)&#xA;Wire.begin();&#xA;&#xA;// initialize serial communication&#xA;// (38400 chosen because it works as well at 8MHz as it does at 16MHz, but&#xA;// it's really up to you depending on your project)&#xA;Serial.begin(38400);&#xA;&#xA;// initialize device&#xA;Serial.println(&quot;Initializing I2C devices...&quot;);&#xA;//accelgyro.initialize();&#xA;accelgyroIC1.initialize();&#xA;accelgyroIC2.initialize();&#xA;&#xA;// verify connection&#xA;Serial.println(&quot;Testing device connections...&quot;);&#xA;Serial.println(accelgyroIC1.testConnection() ? &quot;MPU6050 #1 connection successful&quot; : &quot;MPU6050 connection failed&quot;);   &#xA;Serial.println(accelgyroIC2.testConnection() ? &quot;MPU6050 #2 connection successful&quot; : &quot;MPU6050 connection failed&quot;);  &#xA;&#xA;// configure Arduino LED for&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;// read raw accel/gyro measurements from device&#xA;accelgyroIC1.getMotion6(&amp;amp;ax1, &amp;amp;ay1, &amp;amp;az1, &amp;amp;gx1, &amp;amp;gy1, &amp;amp;gz1);&#xA;accelgyroIC2.getMotion6(&amp;amp;ax2, &amp;amp;ay2, &amp;amp;az2, &amp;amp;gx2, &amp;amp;gy2, &amp;amp;gz2);&#xA;&#xA;// these methods (and a few others) are also available&#xA;//accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;//accelgyro.getRotation(&amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;// display tab-separated accel/gyro x/y/z values&#xA;Serial.println(&quot;MPU1:&quot;);      Serial.print(&quot;\t&quot;    );     Serial.print(&quot;\t&quot;      );     &#xA;Serial.print(ax1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;Serial.print(ay1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;Serial.print(az1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;Serial.print(gx1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;Serial.print(gy1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;Serial.println(gz1);&#xA;delay(1000);&#xA;&#xA;&#xA;// display tab-separated accel/gyro x/y/z values&#xA;Serial.println(&quot;MPU2:&quot;);     Serial.print(&quot;\t&quot;    );     Serial.print(&quot;\t&quot;    );    &#xA;Serial.print(ax2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;Serial.print(ay2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;Serial.print(az2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;Serial.print(gx2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;Serial.print(gy2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;Serial.println(gz2);&#xA;delay(1000);&#xA;&#xA;&#xA;// blink LED to indicate activity&#xA;blinkState = !blinkState;&#xA;digitalWrite(LED_PIN, blinkState);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After running it, I'm wondering why the two MPU connections failed. Please see the attached image for the result I got.&lt;a href=&quot;https://i.stack.imgur.com/LA6ke.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LA6ke.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I guess that should be the probable reason why everytime I try to move the MPU1, the MPU2 varies like what is happening to the MPU1, and there are times that they get the same value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also even tried to edit the code I posted above, and here it goes...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;MPU9250.h&amp;gt;&#xA;&#xA; // I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class&#xA; // 10/7/2011 by Jeff Rowberg &amp;lt;jeff@rowberg.net&amp;gt;&#xA; // Updates should (hopefully) always be available at&#xA; //https://github.com/jrowberg/i2cdevlib&#xA; //&#xA; // Changelog:&#xA; //     2011-10-07 - initial release&#xA;&#xA;&#xA;&#xA;// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation&#xA; // is used in I2Cdev.h&#xA; #include &quot;Wire.h&quot;&#xA;&#xA; // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files&#xA; // for both classes must be in the include path of your project&#xA; #include &quot;I2Cdev.h&quot;&#xA; #include &quot;MPU6050.h&quot;&#xA;&#xA; // class default I2C address is 0x68&#xA; // specific I2C addresses may be passed as a parameter here&#xA;  int AD0LOW= 0x68; //(default for InvenSense evaluation board)&#xA;  int AD0HIGH= 0x69;&#xA;  //MPU9250 accelgyro;&#xA;  int accelgyroIC1 ();&#xA;  int accelgyroIC2 ();&#xA;  //MPU9250 accelgyroIC1(0x68);&#xA;  //MPU9250 accelgyroIC2(0x69);&#xA;&#xA;  int16_t ax1, ay1, az1;&#xA;  int16_t gx1, gy1, gz1;&#xA;  int16_t mx1, my1, mz1;&#xA;&#xA;  int16_t ax2, ay2, az2;&#xA;  int16_t gx2, gy2, gz2;&#xA;  int16_t mx2, my2, mz2;&#xA;&#xA;  #define LED_PIN 13&#xA;  bool blinkState = false;&#xA;&#xA;  void setup() {&#xA;   // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;   Wire.begin();&#xA;   Serial.begin(38400);&#xA;&#xA;  // initialize device&#xA;   Serial.println(&quot;Initializing I2C devices...&quot;);&#xA;  //accelgyro.initialize();&#xA;  int accelgyroIC1();&#xA;  int accelgyroIC2();&#xA;&#xA;   // verify connection&#xA;   Serial.println(&quot;Testing device connections...&quot;);&#xA;   //    Serial.println(accelgyroIC1.testConnection() ? &quot;MPU9250 #1     connection successful&quot; : &quot;MPU9250 connection failed&quot;);   &#xA;   //    Serial.println(accelgyroIC2.testConnection() ? &quot;MPU9250 #2 connection successful&quot; : &quot;MPU9250 connection failed&quot;);  &#xA;&#xA;    // configure Arduino LED for&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    }&#xA;&#xA;    void loop() {&#xA;   // read raw accel/gyro measurements from device&#xA;   //    accelgyroIC1.getMotion9(&amp;amp;ax1, &amp;amp;ay1, &amp;amp;az1, &amp;amp;gx1, &amp;amp;gy1, &amp;amp;gz1);&#xA;   //  accelgyroIC2.getMotion9(&amp;amp;ax2, &amp;amp;ay2, &amp;amp;az2, &amp;amp;gx2, &amp;amp;gy2, &amp;amp;gz2);&#xA;&#xA;&#xA;    accelgyroIC1.getMotion9(&amp;amp;ax1, &amp;amp;ay1, &amp;amp;az1, &amp;amp;gx1, &amp;amp;gy1, &amp;amp;gz1, &amp;amp;mx1, &amp;amp;my1, &amp;amp;mz1);&#xA;    accelgyroIC2.getMotion9(&amp;amp;ax2, &amp;amp;ay2, &amp;amp;az2, &amp;amp;gx2, &amp;amp;gy2, &amp;amp;gz2, &amp;amp;mx2, &amp;amp;my2, &amp;amp;mz2);&#xA;&#xA;&#xA;    // these methods (and a few others) are also available&#xA;    //accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;    //accelgyro.getRotation(&amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA;    // display tab-separated accel/gyro x/y/z values&#xA;    /*Serial.println(&quot;MPU1:&quot;);      Serial.print(&quot;\t&quot;    );              Serial.print(&quot;\t&quot;    );     &#xA;   Serial.print(ax1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;   Serial.print(ay1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;   Serial.print(az1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    );    &#xA;   Serial.print(gx1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;    Serial.print(gy1);        Serial.print(&quot;\t&quot;    );  Serial.print(&quot;\t&quot;    ); &#xA;    Serial.println(gz1);&#xA;    delay(1000);&#xA;&#xA;&#xA;    // display tab-separated accel/gyro x/y/z values&#xA;     Serial.println(&quot;MPU2:&quot;);     Serial.print(&quot;\t&quot;    );     Serial.print(&quot;\t&quot;    );    &#xA;    Serial.print(ax2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;    Serial.print(ay2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;    Serial.print(az2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;    Serial.print(gx2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;    Serial.print(gy2);       Serial.print(&quot;\t&quot;    );   Serial.print(&quot;\t&quot;    );&#xA;    Serial.println(gz2);&#xA;    delay(1000);*/&#xA;&#xA;    Serial.print(&quot;MPU1:&quot;);&#xA;    Serial.print(ax); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(ay); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(az); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gy); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(gz); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(mx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.print(my); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;    Serial.println(mz);&#xA;&#xA;&#xA;     Serial.print(&quot;MPU2:&quot;);&#xA;    Serial.print(ax); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);     Serial.print(&quot;\t&quot;);&#xA;     Serial.print(ay); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(az); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(gx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(gy); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(gz); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(mx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;     Serial.print(my); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;      Serial.println(mz);&#xA;&#xA;&#xA;     // blink LED to indicate activity&#xA;     blinkState = !blinkState;&#xA;     digitalWrite(LED_PIN, blinkState);&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And please see the error that it displayed: (please see attached image)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Hnc47.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hnc47.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a result of: (please see image attched)&lt;a href=&quot;https://i.stack.imgur.com/x1Zb6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x1Zb6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me with these. I'm getting confused with my codes that I should be using and how to edit them. Please guide me on how to put connections in between them..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...Thom&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error message I copied:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 8.1), Board: &quot;Arduino Mega ADK&quot;&#xA;&#xA;C:\Users\Jasmin.Morales\Desktop\_2MPU_Practice\_2MPU_Practice.ino: In function 'void loop()':&#xA;&#xA;_2MPU_Practice:70: error: request for member 'getMotion9' in 'accelgyroIC1', which is of non-class type 'int()'&#xA;&#xA;   accelgyroIC1.getMotion9(&amp;amp;ax1, &amp;amp;ay1, &amp;amp;az1, &amp;amp;gx1, &amp;amp;gy1, &amp;amp;gz1, &amp;amp;mx1, &amp;amp;my1, &amp;amp;mz1);&#xA;&#xA;                ^&#xA;&#xA;_2MPU_Practice:71: error: request for member 'getMotion9' in 'accelgyroIC2', which is of non-class type 'int()'&#xA;&#xA;   accelgyroIC2.getMotion9(&amp;amp;ax2, &amp;amp;ay2, &amp;amp;az2, &amp;amp;gx2, &amp;amp;gy2, &amp;amp;gz2, &amp;amp;mx2, &amp;amp;my2, &amp;amp;mz2);&#xA;&#xA;                ^&#xA;&#xA;_2MPU_Practice:100: error: 'ax' was not declared in this scope&#xA;&#xA;     Serial.print(ax); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:101: error: 'ay' was not declared in this scope&#xA;&#xA;     Serial.print(ay); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:102: error: 'az' was not declared in this scope&#xA;&#xA;     Serial.print(az); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:103: error: 'gx' was not declared in this scope&#xA;&#xA;     Serial.print(gx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:104: error: 'gy' was not declared in this scope&#xA;&#xA;     Serial.print(gy); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:105: error: 'gz' was not declared in this scope&#xA;&#xA;     Serial.print(gz); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:106: error: 'mx' was not declared in this scope&#xA;&#xA;     Serial.print(mx); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:107: error: 'my' was not declared in this scope&#xA;&#xA;     Serial.print(my); Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);   Serial.print(&quot;\t&quot;);&#xA;&#xA;                  ^&#xA;&#xA;_2MPU_Practice:108: error: 'mz' was not declared in this scope&#xA;&#xA;     Serial.println(mz);&#xA;&#xA;                    ^&#xA;&#xA;exit status 1&#xA;request for member 'getMotion9' in 'accelgyroIC1', which is of non-class type 'int()'&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="10794" LastEditDate="2016-02-04T08:01:09.677" LastActivityDate="2018-07-18T07:26:03.757" Title="Two MPU 9250 connected to one arduino (Code of the MPU6050 edited for MPU9250)" Tags="|arduino-mega|accelerometer|mpu6050|gyroscope|magnetometer|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20304" PostTypeId="1" CreationDate="2016-02-04T03:59:49.603" Score="0" ViewCount="562" Body="&lt;p&gt;I just stayed on &lt;code&gt;delay()&lt;/code&gt; since that is the only thing I know but the thing is &lt;code&gt;delay()&lt;/code&gt; cannot be interrupted. What I'm trying to achieve with this code is: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When the soilSensor detects moisture it would send a text message to a number only ONCE without terminating the program even if in the next loop the soilSensor is still detecting moisture. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The soilSensor's delay is &lt;code&gt;delay(60000)&lt;/code&gt; and we would still wait for while to finish the delay but what if in the middle of the soilSensor's &lt;code&gt;delay(60000)&lt;/code&gt; there is a movement for just about 5 seconds? What to do so that the tiltSensor can overlap the soilSensor's delay and sends a message to a number? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I want this program to run forever. Please help me! I needed this ASAP!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial SIM900(7, 8);&#xA;int led=22;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  SIM900.begin(19200);&#xA;  pinMode(led, OUTPUT);&#xA;  delay(1000); &#xA;}&#xA;&#xA;void sendSMS1()&#xA;{&#xA;  SIM900.println(&quot;AT + CMGS = \&quot;+************\&quot;&quot;);&#xA;  delay(100);&#xA;  Serial.println(&quot;Water Detected&quot;);&#xA;  delay(100);&#xA;  SIM900.println(&quot;Water Detected&quot;); &#xA;  delay(100);&#xA;  SIM900.println((char)26); &#xA;  delay(100);&#xA;  SIM900.println();&#xA;  delay(100); &#xA;}&#xA;&#xA;&#xA;void sendSMS2()&#xA;{&#xA;  SIM900.println(&quot;AT + CMGS = \&quot;+************\&quot;&quot;);&#xA;  delay(100);&#xA;  Serial.println(&quot;Movement Detected&quot;);&#xA;  delay(100);&#xA;  SIM900.println(&quot;Movement Detected&quot;); &#xA;  delay(100);&#xA;  SIM900.println((char)26); &#xA;  delay(100);&#xA;  SIM900.println();&#xA;  delay(100);  &#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{    &#xA;  int soilSensor = analogRead(A0);&#xA;  int tiltSensor = analogRead(A1);&#xA;&#xA;  if(soilSensor &amp;gt;= 10)&#xA;  {&#xA;    digitalWrite(22, HIGH);&#xA;    Serial.println(soilSensor);&#xA;    sendSMS1();&#xA;    delay(60000);&#xA;  }&#xA;  else&#xA;  {&#xA;    digitalWrite(22, LOW);&#xA;    delay(60000); &#xA;  } &#xA;&#xA;  if (tiltSensor &amp;gt;= 100)&#xA;  {&#xA;    digitalWrite(led, HIGH);&#xA;    Serial.println(tiltSensor);&#xA;    sendSMS2();&#xA;    delay(60000);&#xA;  }&#xA;  else &#xA;  {&#xA;    digitalWrite(led, LOW);&#xA;    Serial.println(tiltSensor);&#xA;    delay(60000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17020" LastEditorUserId="6936" LastEditDate="2016-02-04T08:02:26.183" LastActivityDate="2016-02-04T22:38:34.043" Title="How to limit the number of message that an Arduino sends to a phone without terminating it" Tags="|programming|arduino-mega|sensors|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20305" PostTypeId="2" ParentId="20298" CreationDate="2016-02-04T05:14:36.610" Score="0" Body="&lt;p&gt;The yellow-boxed 5V and Gnd buses on the &lt;a href=&quot;http://www.freetronics.com.au/products/protoshield-basic#.VrLTZt_U2kA&quot; rel=&quot;nofollow&quot;&gt;freetronics.com.au ProtoShield Basic for Arduino&lt;/a&gt; [like you used] already have copper strips connecting the holes.  The strips run on both sides of the board and the holes are plated-through, so there's no need (for this kind of circuit) to have additional bus wire running along above the boxes.  Having that extra wire there gets in the way of making changes, whether for debugging the circuit or for adding or replacing components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://s12.postimg.org/99wap5rr1/MG_3581.jpg&quot; rel=&quot;nofollow&quot;&gt;frontside picture&lt;/a&gt;, it appears you may have a voltage regulator on board.  (However, I don't see the connections to 5V and Gnd, so might be misinterpreting things.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your board input is 5 VDC from an external supply, feeding that 5 V into a regulator will lose half a volt or so, which may account for what you are seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, let's instead suppose you are putting 7 to 12 VDC into an on-board 5V regulator and then measuring 4.4-4.6 V out.  One possibility is the regulator isn't working.  This can happen if the regulator's input or output capacitors are the wrong sizes or wrong kinds, and cause oscillation.  Diagnosing that kind of problem is straightforward if you look at the 5V line with an oscilloscope.  Another possibility is something drawing a &lt;em&gt;lot&lt;/em&gt; of current (eg a couple of amps) and taking the 5V line out of regulation.  That's usually easy to diagnose because of all the resulting smoke and heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Drawing a good schematic is an excellent step to take to allow better problem debugging.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other steps to take:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Measure the amount of current the whole board is drawing, or that the NRF24L01 is drawing.  (For the latter measurement, you might need to lift your ground lead off the NRF24L01 board and put the ammeter into the ground circuit.  In general you want all the grounds to be at the same voltage, so the voltage drop across the ammeter is a problem, but not much of one.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Pull the '328P chip and see if that makes any difference.  In general, it's a good idea to work out a prototype board's power supply problems – such as shorts, reversed electrolytics, incorrect resistors – in advance of installing a microcontroller chip onto the board.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Remove the NRF24L01, if feasible, while debugging the power supply.  If you can't easily remove it, check your schematic and see if all of its pins except 5V and Gnd are open when the '328P chip is pulled.  If so, you can detach the NRF24L01  ground lead to take it out of the circuit.  If, during testing, you unsolder and remove the NRF24L01 board, consider making a socket for it from two 5-pin female header strips.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-04T05:20:13.383" LastActivityDate="2016-02-04T05:20:13.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20306" PostTypeId="1" AcceptedAnswerId="20312" CreationDate="2016-02-04T05:35:59.970" Score="0" ViewCount="1726" Body="&lt;p&gt;I am trying ... with minimal success to change/Check and also run voids through the serial monitor .the code i  put i am having probles is that when i am try to send a value larger than 9 the value assigns a diffrent number Ex i set to 200 but arduino sets it as 512.. i got around it deviding the value by 1.6 and got me the new number and only works upto 90 , but i am tryn to see how it should be done correctly...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint16_t inputLength = 512;&#xA;int ss = 0;&#xA;int bHold = 0;&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA; }&#xA;&#xA; void loop() {&#xA;  if ( Serial.available() &amp;gt; 0 )&#xA;  {&#xA;    static char input[inputLength];&#xA;    static uint16_t i;&#xA;    char c = Serial.read();&#xA;&#xA;    if ( c != '\r' &amp;amp;&amp;amp; c != '\n' &amp;amp;&amp;amp; i &amp;lt; inputLength - 1)&#xA;      input[i++] = c;&#xA;&#xA;    else&#xA;    {&#xA;      input[i] = '\0';&#xA;      i = 0;&#xA;&#xA;      uint16_t array[80];&#xA;      uint16_t j = 0;&#xA;&#xA;      if ( !strncmp(input, &quot;ss&quot;, 2) )&#xA;      {        &#xA;        char* p = input + 2;&#xA;        while ( (p = strchr(p, ' ')) != NULL )&#xA;          array[j++] = strtol(p, &amp;amp;p, 10); //&amp;lt; changed from 16&#xA;&#xA;        for ( uint8_t i = 0; i &amp;lt; j; i++ )&#xA;        {&#xA;          ss = array[i];&#xA;          Serial.println(ss);&#xA;        }&#xA;      }&#xA;&#xA;      if ( !strncmp(input, &quot;bHold&quot;, 5) )&#xA;      {        &#xA;        char* p = input + 5;&#xA;        while ( (p = strchr(p, ' ')) != NULL )&#xA;          array[j++] = strtol(p, &amp;amp;p, 10);   //&amp;lt; changed from 16&#xA;&#xA;        for ( uint8_t i = 0; i &amp;lt; j; i++ )&#xA;        {&#xA;         bHold = array[i];&#xA;        // bHold=bHold /1.6;            &#xA;         Serial.println(bHold);&#xA;        }&#xA;      }&#xA;&#xA;      if ( !strncmp(input, &quot;Whos There&quot;, 10) )&#xA;      {&#xA;        Serial.print(&quot;me&quot;);&#xA;      }&#xA;      if ( !strncmp(input, &quot;hello&quot;, 5) )&#xA;      {&#xA;        Serial.print(&quot;hi&quot;);&#xA;      }&#xA;      if ( !strncmp(input, &quot;sa&quot;, 2) )&#xA;      {&#xA;        Serial.print(&quot;  ss= &quot;);&#xA;        Serial.print(ss);&#xA;&#xA;        Serial.print(&quot;  bHold= &quot;);&#xA;        Serial.print(bHold);&#xA;&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.println(&quot;==============================&quot;);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you for any tips you can give...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I am trying to pass a new value with command on the serial monitor &quot;ss 500&quot;..so that in the arsuino ss = 500. but in this case it makes it equal to 1280.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2: Chaged the strol to 10...works perfectly ...Thank you TisteAndii!!!!&lt;/p&gt;&#xA;" OwnerUserId="16629" LastEditorUserId="16629" LastEditDate="2016-02-04T18:58:57.077" LastActivityDate="2016-02-04T18:58:57.077" Title="How to change Multiple variable values through Serial Monitor" Tags="|serial|variables|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20307" PostTypeId="1" AcceptedAnswerId="20311" CreationDate="2016-02-04T05:53:30.980" Score="0" ViewCount="4437" Body="&lt;p&gt;How do I connect a function generator that generates an analog signal to an Arduino Uno?&lt;/p&gt;&#xA;&lt;p&gt;I don't know how to begin, so could you also tell me the settings for the function generator, e.g. its amplitude, frequency, etc, that won't damage my Arduino?&lt;/p&gt;&#xA;&lt;p&gt;I plan to visualize the output on Processing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vi4dQ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vi4dQ.jpg&quot; alt=&quot;Agilent 33220A Function Generator&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;https://www.sonoma.edu/users/m/marivani/es110/images/fg_big.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;sonoma.edu&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="17022" LastEditorUserId="27346" LastEditDate="2023-01-02T20:28:03.143" LastActivityDate="2023-01-02T20:28:03.143" Title="Connect function generator to Arduino" Tags="|arduino-uno|signal-processing|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="20308" PostTypeId="2" ParentId="20286" CreationDate="2016-02-04T06:05:55.953" Score="0" Body="&lt;p&gt;I have had to, briefly, play with these boards a while back, and although I used different revisions and versions of the boards, they are probably the same functionally. Unfortunately, I don't have any of my old notes as I have moved country. Regardless...&lt;/p&gt;&#xA;&lt;p&gt;As Majenko says in his &lt;a href=&quot;https://arduino.stackexchange.com/questions/20286/how-to-use-itg-3500-evb#answer-20287&quot;&gt;answer&lt;/a&gt; the green board is an evaluation board for the ITG-3500 3-axis gyroscope, which is presumably the SMD chip (in a QFN format) mounted on it, in the lower part of the board (looking at your photo). A &lt;a href=&quot;https://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;data sheet on the &lt;em&gt;similar&lt;/em&gt; ITG-3200&lt;/a&gt; (note &lt;em&gt;not&lt;/em&gt; the evaluation board itself)  can be found on SparkFun. To quote part of the product description:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The ITG-3200 is the world’s first single-chip, digital-output, 3-axis&#xA;MEMS gyro IC optimized for gaming, 3D mice, and 3D remote control&#xA;applications. The part features enhanced bias and sensitivity&#xA;temperature stability, reducing the need for user calibration. Low&#xA;frequency noise is lower than previous generation devices, simplifying&#xA;application development and making for more-responsive remote&#xA;controls.&lt;/p&gt;&#xA;&lt;p&gt;The ITG-3200 features three 16-bit analog-to-digital&#xA;converters (ADCs) for digitizing the gyro outputs, a user-selectable&#xA;internal low-pass filter bandwidth, and a Fast-Mode I2C (400kHz)&#xA;interface. Additional features include an embedded temperature sensor&#xA;and a 2% accurate internal oscillator. This breakthrough in gyroscope&#xA;technology provides a dramatic 67% package size reduction, delivers a&#xA;50% power reduction, and has inherent cost advantages compared to&#xA;competing multi-chip gyro solutions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In addition, in case it is of any use, here is the &lt;a href=&quot;http://store.invensense.com/datasheets/invensense/PS-ITG-3701.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet for the, again similar, ITG-3701&lt;/a&gt;, which I located on the &lt;a href=&quot;http://www.digikey.com/product-detail/en/ITG-3701/1428-1050-1-ND/5015524&quot; rel=&quot;nofollow noreferrer&quot;&gt;Digi sales site&lt;/a&gt;. Frustratingly, I am unable to locate a datasheet for the ITG-3500 - however, you mentioned that you found some datasheets - could you edit your answer to include the links, please?&lt;/p&gt;&#xA;&lt;p&gt;The Blue board is a &amp;quot;Gyroscope Evaluation Board: EV_INV-ARM&amp;quot; manufactured by InvenSense Inc., and to quote its &lt;a href=&quot;http://store.invensense.com/ProductDetail/EVINVARMG-InvenSense-Inc/425140/&quot; rel=&quot;nofollow noreferrer&quot;&gt;product description&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The InvenSense ARM reference board provides a bridge function between InvenSense evaluation boards and a PC. It connects to a PC via USB and to InvenSense evaluation boards via SPI or I2C. The ARM processor on the reference board is not meant to be reprogrammed by the user. It contains all code necessary to be used in conjunction InvenSense evaluation boards. (Note that separate demonstration software may accompany the individual evaluation boards with which this device connects.)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here is a link to the &lt;a href=&quot;http://store.invensense.com/datasheets/invensense/AN-000039%20v1.0.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;EV_INV-ARM DataSheet&lt;/a&gt;. The Atmel chip on it is possibly the AT91SAM7SE512 MCU, and here is a link to its &lt;a href=&quot;http://www.atmel.com/devices/SAM7SE512.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;product specification&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Software wise, you may find this &lt;a href=&quot;https://android.googlesource.com/kernel/tegra.git/+/eb72d0308d4f46ff106f7097a3c040cfda83733d/drivers/staging/iio/imu/inv_mpu/README&quot; rel=&quot;nofollow noreferrer&quot;&gt;Linux kernel driver for the ITG-3500&lt;/a&gt; extremely useful.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;TL;DR&lt;/h3&gt;&#xA;&lt;p&gt;It seems like you need to get hold of the separate demonstration software for the ITG-3500 evaluation board, according to the EV-INV_ARM's product description, in order to &lt;em&gt;easily&lt;/em&gt; make it do something.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-04T06:16:03.743" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20309" PostTypeId="2" ParentId="20307" CreationDate="2016-02-04T06:35:56.700" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know how to begin, so could you also tell me the settings for the function generator, e.g. its amplitude, frequency, etc, that won't damage my Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is not an Arduino question. That is a question about how to operate the function generator. Please check the users manual. You need to set the voltage output (DC + AC) so that it matches the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An analog signal should go to an analog pin on the Arduino (not pin 8). It is also important to connect GND. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-04T06:35:56.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20310" PostTypeId="2" ParentId="20307" CreationDate="2016-02-04T06:38:16.243" Score="0" Body="&lt;p&gt;Looking at the &lt;a href=&quot;http://cp.literature.agilent.com/litweb/pdf/33220-90002.pdf&quot; rel=&quot;nofollow&quot;&gt;Agilent 33220A 20 MHz Waveform Generator User's Guide&lt;/a&gt;, I can see that the Function Generator has a USB port. If you have, or can get hold of, a &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoUSBHostShield&quot; rel=&quot;nofollow&quot;&gt;USB &lt;em&gt;Host&lt;/em&gt; shield&lt;/a&gt; for the Arduino, you should be able to link the two together physically. Then, using the &lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0&quot; rel=&quot;nofollow&quot;&gt;USB Host Library for Arduino&lt;/a&gt;, you could get the two talking to each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, if you fancy a bit more hard work, then you could get a MAX3421E, and wired it up yourself as an interface, but I wouldn't recommended it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: If you have an Arduino Due (I know that you say that you have an Uno, but just in case) then you could use the &lt;a href=&quot;https://www.arduino.cc/en/Reference/USBHost&quot; rel=&quot;nofollow&quot;&gt;USBHost library&lt;/a&gt; to connect the two directly, without the need for a USB Host shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding, getting the two to talk together, that may not be exactly easy. From the manual I can see that the PC software can auto-configure the function generator, however, for receiving data it may not be so easy. You appear to have to send a &lt;strong&gt;GTL&lt;/strong&gt; command to get the data sent to the USB (p251, and onwards, of the manual). Good Luck! :-)&lt;/p&gt;&#xA;" OwnerUserId="6936" LastActivityDate="2016-02-04T06:38:16.243" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20311" PostTypeId="2" ParentId="20307" CreationDate="2016-02-04T07:03:52.173" Score="3" Body="&lt;h2&gt;Confirm with an oscilloscope&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When I connect my function generator I &lt;s&gt;usually&lt;/s&gt; always make sure that the output is in the range 0 to 5V, with my oscilloscope. The default is probably more like ±2.5V - but I don't have an Agilent so you would have to check. Press the &lt;code&gt;Ampl&lt;/code&gt; button to check. (Mine reads 5V&lt;sub&gt;PP&lt;/sub&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jn5AO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jn5AO.png&quot; alt=&quot;Default operation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from the above image that we indeed have (roughly) 5V&lt;sub&gt;PP&lt;/sub&gt; - and that there is a -2.56V component, which will damage the Arduino, being negative.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Add an offset&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So press the &lt;code&gt;Offset&lt;/code&gt; button and add a 2.5V DC offset. Now the voltage jumps 2.5V and is between 0 and 5V:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kk2e1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kk2e1.png&quot; alt=&quot;With 2.5V offset&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scope confirms that the minimum is 80mV and the maximum is 4.96V, which is in range for an Arduino pin (assuming you are running an Arduino at 5V, which is not always the case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you should be safe to experiment with different frequencies and wave-forms. Just leave the Amplitude and Offset alone. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Extra precautions&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You could feed the function generator through an input protection circuit, just in case you absent mindedly forget to carry out the appropriate steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Pm0WV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Pm0WV.png&quot; alt=&quot;Input protection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The zener diode will conduct negative voltages to ground (dissipated through the 1k resistor) and will also limit positive voltages to around 5.1V.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-04T07:03:52.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20312" PostTypeId="2" ParentId="20306" CreationDate="2016-02-04T08:41:11.397" Score="0" Body="&lt;p&gt;You are setting the input string's base to 16 instead of 10 in your &lt;code&gt;strtol&lt;/code&gt; conversions, which is why you are getting 1280 when you expect 500. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-04T08:41:11.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20313" PostTypeId="2" ParentId="20295" CreationDate="2016-02-04T11:44:41.137" Score="0" Body="&lt;p&gt;Your program is hard to follow with all those meaningless &quot;integer&quot; and &quot;counter&quot; variables, and the logic seems a little odd in places, but I believe the cause of your problems is the &lt;code&gt;break&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (integer = 0; integer &amp;lt; counter1; integer += 1) {&#xA;    if (distance &amp;lt; 10) {&#xA;        // ...&#xA;        for (integer4 = 0;  integer4 &amp;lt; counter3; integer4 += 1) {     //modifying matrix if there is an object&#xA;            my2dArray[3 + integer][3 + integer4] = robot * my2dArray[3 + integer][3 + integer4];&#xA;        }&#xA;        break; // &amp;lt;&amp;lt; HERE&#xA;    } else {&#xA;        // ...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the purpose of that &lt;code&gt;break&lt;/code&gt;? I think you are using it to jump out of the &lt;code&gt;if&lt;/code&gt; so that it doesn't run the &lt;code&gt;else&lt;/code&gt;, which it &lt;em&gt;won't run anyway since it's an else condition&lt;/em&gt;. Instead, what the &lt;code&gt;break&lt;/code&gt; is actually doing is terminating the &lt;code&gt;for&lt;/code&gt; loop after the first iteration that hits that inner &lt;code&gt;if&lt;/code&gt; condition. That is, as long as the distance is less than 10 it will only ever run the &lt;code&gt;for&lt;/code&gt; once, and so &lt;code&gt;integer&lt;/code&gt; will only ever be 0.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-04T11:44:41.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20314" PostTypeId="1" AcceptedAnswerId="20315" CreationDate="2016-02-04T12:00:14.357" Score="9" ViewCount="2272" Body="&lt;p&gt;Of course I know it is usefull to control the time of a delay, but any other use? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 16Mhz clock, each line of my program will take 1/16000000 second, right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;even a very very big line will only take 1/16000000 of a second ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a 8MHz clock, each line will take the double of the time, right? &#xA;So the whole &quot;main loop&quot;  will take the double time too, right? &lt;/p&gt;&#xA;" OwnerUserId="16323" LastEditorUserId="16323" LastEditDate="2016-02-04T17:46:55.903" LastActivityDate="2016-02-04T21:15:46.813" Title="Why is there a clock in my arduino?" Tags="|oscillator-clock|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20315" PostTypeId="2" ParentId="20314" CreationDate="2016-02-04T12:19:51.393" Score="13" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why is there a clock in my arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because that is how computers and microcontrollers, etc, work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With a 16mhz clock, each line of my program will take 1/16000000 second, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;even a very very big line will only take 1/16000000 of a second ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The clock defines at what speed the &lt;em&gt;machine code instructions&lt;/em&gt; are fetched from memory and executed. Most instructions take 1 clock cycle, but some take more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One line of C code may be compiled into any number of assembly instructions, which then get converted into machine code (raw numbers).  That could be anywhere from 1 assembly instruction to thousands of assembly instructions, depending on what the line does.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With a 8mhz clock, each line will take the double of the time, right? So the whole &quot;main loop&quot; will take the double time too, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Every operation in the chip is governed by the clock. If the clock is half the speed the chip is running at half the speed, so every operation will take twice as long, yes.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-04T12:19:51.393" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20316" PostTypeId="1" CreationDate="2016-02-04T12:46:58.930" Score="1" ViewCount="8546" Body="&lt;p&gt;Help me to find out how to connect an Ethernet shield over the internet using a LAN cable. I have tried many times but I'm not getting a MAC and IP address.&lt;/p&gt;&#xA;" OwnerUserId="17028" LastEditorUserId="6936" LastEditDate="2016-02-06T04:12:45.017" LastActivityDate="2016-03-07T04:17:14.467" Title="How to get the MAC address of an Ethernet shield, if it is not printed on it?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20317" PostTypeId="1" AcceptedAnswerId="20342" CreationDate="2016-02-04T12:53:54.890" Score="0" ViewCount="5690" Body="&lt;p&gt;i am not able to communicate over i2c with my esp-01 as master and UNO as slave. i get special characters sent back to esp, but my esp is sending correctly...&#xA;output on my esp-01&#xA;&lt;a href=&quot;https://i.stack.imgur.com/iBFZA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iBFZA.png&quot; alt=&quot;output on my esp-01&quot;&gt;&lt;/a&gt; &#xA;output on my UNO is &#xA;&lt;a href=&quot;https://i.stack.imgur.com/LkRcZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LkRcZ.png&quot; alt=&quot;output on my UNO&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;connections are esp-01 gpio-0 to uno A4 and gpio-2 to uno A5&#xA;is it because i am not using a level shifter or any mistake in my code..?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my esp master code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#define I2CAddressESPWifi 6&#xA;int x=32;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin(0,2);//Change to Wire.begin() for non ESP.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Wire.beginTransmission(I2CAddressESPWifi);&#xA;  Wire.write(x);&#xA;  Wire.endTransmission();&#xA;  x++;&#xA;  delay(1);//Required. Not sure why!&#xA;&#xA;  Wire.requestFrom(I2CAddressESPWifi,10);&#xA;  Serial.print(&quot;Request Return:[&quot;);&#xA;  while (Wire.available())&#xA;  {&#xA;    delay(100);&#xA;    char c = Wire.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  Serial.println(&quot;]&quot;);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is my Uno slave code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#define I2CAddressESPWifi 6&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin(I2CAddressESPWifi);&#xA;  Wire.onReceive(espWifiReceiveEvent);&#xA;  Wire.onRequest(espWifiRequestEvent);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(1);&#xA;}&#xA;&#xA;void espWifiReceiveEvent(int count)&#xA;{&#xA;  Serial.print(&quot;Received[&quot;);&#xA;  while (Wire.available())&#xA;  {&#xA;    char c = Wire.read();&#xA;    Serial.print(c);&#xA;  }&#xA;  Serial.println(&quot;]&quot;);&#xA;}&#xA;&#xA;void espWifiRequestEvent()&#xA;{&#xA;  String ts = getTime();&#xA;  Serial.print(&quot;Sending:[&quot;);&#xA;  Serial.print(ts.c_str());&#xA;  Serial.println(&quot;]&quot;);&#xA;  Wire.write(ts.c_str());&#xA;}&#xA;&#xA;String getTime(){&#xA;  int sec = millis() / 1000;&#xA;  int min = sec / 60;&#xA;  int hr = min / 60;&#xA;  String ts = &quot;U:&quot;;&#xA;  if (hr&amp;lt;10) ts+=&quot;0&quot;;&#xA;  ts += hr;&#xA;  ts +=&quot;:&quot;;&#xA;  if ((min%60)&amp;lt;10) ts+=&quot;0&quot;;&#xA;  ts += min % 60;&#xA;  ts +=&quot;:&quot;;&#xA;  if ((sec%60)&amp;lt;10) ts+=&quot;0&quot;;&#xA;  ts += sec % 60;&#xA;  return(ts);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17029" LastEditorUserId="17029" LastEditDate="2016-02-04T12:58:36.327" LastActivityDate="2018-12-02T20:58:29.407" Title="esp8266-01 and arduino UNO communicating over i2c" Tags="|i2c|esp8266|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20318" PostTypeId="1" CreationDate="2016-02-04T13:05:38.153" Score="3" ViewCount="7898" Body="&lt;p&gt;I'm trying to use Arduino as a DAQ but the &lt;code&gt;Serial.print()&lt;/code&gt; is not working as fast as I expected. How many bits are sent if you are using a int, because if I use a &lt;code&gt;uint8_t&lt;/code&gt;, it's taking the same amount of time? How I could improve the speed of the &lt;code&gt;Serial.print()&lt;/code&gt;? I'm already working at 115200 baud.&lt;/p&gt;&#xA;" OwnerUserId="17026" LastEditorUserId="6936" LastEditDate="2016-02-06T04:14:33.557" LastActivityDate="2016-02-06T20:53:25.250" Title="Serial.print() is slower than it should be" Tags="|serial|data-type|" AnswerCount="5" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20319" PostTypeId="2" ParentId="20316" CreationDate="2016-02-04T13:05:53.603" Score="1" Body="&lt;p&gt;If you do not have a MAC address then you have to make one up.  There are a couple of rules and regulations about what a MAC address can be, but most of the time you can just make one up:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It must be unique on &lt;em&gt;your&lt;/em&gt; network&lt;/li&gt;&#xA;&lt;li&gt;There are a set of prefixes that are reserved for special purposes:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The lowest bit of the first byte must be 0&lt;/li&gt;&#xA;&lt;li&gt;The second bit of the first byte must be 1&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can read more about it here: &lt;a href=&quot;https://en.wikipedia.org/wiki/MAC_address&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/MAC_address&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have provided a MAC address and physically connected it to the network then you need an IP address and netmask.  There are two ways you can get the IP address and netmask:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Through DHCP - For example your home internet router would provide the IP address for you.&lt;/li&gt;&#xA;&lt;li&gt;By allocating your own. This must be within the range of your network's IP addresses, typically something like 192.168.0.x where x is between 1 and 255.  The IP address must be unique on your network.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The netmask, again, can be given by DHCP, otherwise you will have to enter the netmask of your network, typically 255.255.255.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to access the internet itself you need to provide (or be provided with through DHCP) the address of the internet gateway and possibly a DNS server address. On a home network they are typically the address of the router, which may well be 192.168.0.1 or something similar.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-04T13:05:53.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20320" PostTypeId="2" ParentId="20318" CreationDate="2016-02-04T13:34:20.197" Score="2" Body="&lt;p&gt;By not using &lt;code&gt;Serial.print&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.print&lt;/code&gt; will format the number as a string of ASCII characters. The number of characters depends on the size of the number. Yes, that is very wasteful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are sending values between 0 and 255 (&lt;code&gt;uint8_t&lt;/code&gt;) you can just send the raw value as a single ASCII character, since there are 256 of those.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(myVal);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For anything greater than 255, i.e., you want to send an &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;uint16_t&lt;/code&gt; then you will have to come up with some better way. You can't send one byte for the full value, so you would have to send it as two bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write((myVal &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);&#xA;Serial.write(myVal &amp;amp; 0xFF);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;HOWEVER... how do you know which byte coming in is which? It's very very easy to get out of sync and not get the right values when you read the data in.  So you need some way of &quot;packetizing&quot; the data so that you know &quot;This is a correct set of values&quot;.  Just how you do that is entirely up to you - do you just wrap each pair of bytes in a special set of other bytes? Nah - that becomes as wasteful as &lt;code&gt;Serial.print&lt;/code&gt;. Instead it's better to buffer up a batch of values and send them as a block with just a few extra bytes to define the packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example of doing that is my &lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC/&quot; rel=&quot;nofollow&quot;&gt;ICSC library&lt;/a&gt;. Take a look at it and you can see how you can craft a packet to send lots of data as one stream of data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-04T13:34:20.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20321" PostTypeId="2" ParentId="20318" CreationDate="2016-02-04T13:34:29.620" Score="1" Body="&lt;p&gt;&lt;code&gt;Serial.print&lt;/code&gt; sends the ASCII representation of the data. So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t data8 = 102;&#xA;uint32_t data32 = 102;&#xA;char datastring[] = &quot;102&quot;;&#xA;Serial.print(each_of_the_previous_data);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;each of these are sent exactly in the same way, i.e. three bytes ('1', '0', '2', so 0x31 0x30 0x32).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This, as you noticed, is highly inefficient. What I suggest you is to send them in binary mode, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t *convertToByteArrayLittleEndian(uint8_t *buffer, int32_t val)&#xA;{&#xA;    uint8_t i;&#xA;    for (i = 0; i &amp;lt; 4; i++)&#xA;    {&#xA;        buffer[i] = val &amp;amp; 0xFF;&#xA;        val = val &amp;gt;&amp;gt; 8;&#xA;    }&#xA;    return buffer;&#xA;}&#xA;uint8_t *convertToByteArrayBigEndian(uint8_t *buffer, int32_t val)&#xA;{&#xA;    uint8_t i;&#xA;    for (i = 0; i &amp;lt; 4; i++)&#xA;    {&#xA;        buffer[3-i] = val &amp;amp; 0xFF;&#xA;        val = val &amp;gt;&amp;gt; 8;&#xA;    }&#xA;    return buffer;&#xA;}&#xA;&#xA;uint8_t supportArray[4];&#xA;uint8_t data8 = 102;&#xA;uint32_t data32 = 102;&#xA;char datastring[] = &quot;102&quot;;&#xA;Serial.write(data8); // Sends 0x64 = 100&#xA;Serial.print(convertToByteArrayLittleEndian(supportArray,data32),4); // Sends 0x64 0x00 0x00 0x00&#xA;Serial.print(convertToByteArrayBigEndian(supportArray,data32),4); // Sends 0x00 0x00 0x00 0x64&#xA;Serial.print(datastring); // Sends 0x31 0x30 0x32&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had to use an helper function to convert from int to byte array, since Serial.write does not support directly an int. You can choose if you want to send the data in big endian or little endian format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, in binary mode the amount of data exchanged varies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just three more things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) you probably can go higher in frequency (maybe 1Mbit/s) with the serial. Just try it out&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If you decide to use binary mode, maybe you will need some synchronization (i.e. a start byte) to ensure you are not listening a stream from a &quot;middle&quot; point. There are various techniques (prevent use of some bits in the stream, use some forbidden values and escape it)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) If you want to go faster, I suggest you to switch peripheral. For instance use SPI (of course you won't be able to use a common USB-UART interface, but you can create a native USB dongle with an SPI interface to get the connection)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to other info from the OP:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data is 10 bits. Let's split it into two 5bits data, so we can use the upper 3 bits for sending sync info (to understand which byte comes first). The required rate is 6kHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made some calculations, and it looks like that you can use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TimerOne.h&quot;&#xA;&#xA;bool timerHasBeenTriggered = false;&#xA;&#xA;void setup()&#xA;{&#xA;    Timer1.initialize(167);         // initialize timer1, and set a 6kHz frequency&#xA;    Timer1.attachInterrupt(callback);&#xA;    Serial.begin(#HIGHER_THAN_115200#);&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;    timerHasBeenTriggered = true;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int16_t val = analogRead(ANALOG_PIN); // takes 104us&#xA;    Serial.write((val &amp;amp; 0x1F) | 0xA0); // Send lower 5 bits, upper 3 set to 101&#xA;    Serial.write((val &amp;gt;&amp;gt; 5) &amp;amp; 0x1F); // Send lower 5 bits, upper 3 set to 000&#xA;    while (!timerHasBeenTriggered);&#xA;    timerHasBeenTriggered = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the loop has an execution time of around 104us (serial calls just store the values in a queue). The vast majority of the time is spent acquiring from a channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a timer to trigger the next acquisition so it can be more precise (and the millis() function is useless, since you want to trigger it 6 times per millisecond).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the PC you will receive two bytes. The first one is in the form &lt;code&gt;0b101XXXXX&lt;/code&gt;, the second &lt;code&gt;0b000YYYYY&lt;/code&gt;. You will only have to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;wait for a byte starting with 101&lt;/li&gt;&#xA;&lt;li&gt;save the other 5 bits (XXXXX)&lt;/li&gt;&#xA;&lt;li&gt;get the next byte and check it starts with 000&lt;/li&gt;&#xA;&lt;li&gt;the data will be just the concatenation of the two 5-bits chunks: YYYYYXXXXX&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that the limiting factor of the timing is the analogRead function. If you want to go faster (or to acquire from multiple channels) you will need to change the ADC clock prescaler. This, however, will make your ADC frequency higher than 200kHz, which is not recommended (you will get less precise data).&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2016-02-05T09:36:13.190" LastActivityDate="2016-02-05T09:36:13.190" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20322" PostTypeId="1" AcceptedAnswerId="20324" CreationDate="2016-02-04T13:42:35.717" Score="2" ViewCount="5203" Body="&lt;p&gt;I've bought a cheap I2C LCD display (specs in the end of this question). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't make it print. I've tested with two displays of same model, so nothing is broken. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the NewliquidCrystal 1.3.4 library, ie not the &quot;normal&quot; LiquidCrystal library. I'm trying with the I2C example called HelloWorld_i2c (&lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal/raw/20245cfb111aadad288f73102fcf353356a89651/examples/HelloWorld_i2c/HelloWorld_i2c.pde&quot; rel=&quot;nofollow noreferrer&quot;&gt;link to example code&lt;/a&gt;). I've only changed the address from 0x37 to 0x27. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It compiles fine, but the result is only that the display flickers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong and how do I fix it?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Super simple example flickers too&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Well, this one gives just one blink. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address&#xA;void setup()&#xA;{&#xA;  lcd.begin(16,2);               // initialize the lcd &#xA;  lcd.home ();                   // go home&#xA;  lcd.print(&quot;Hello, ARDUINO &quot;);  &#xA;}&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Pictures&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In the light it shows that the writing to the display is randomly jumping around. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cybkA.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cybkA.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the dark, it shows that the background light flickers:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hd20P.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hd20P.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Details about the LCD display&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Text on the backside&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;YwRobot Arduino&#xA;QAPASS&#xA;LCM1602 IIC V1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Text on the chip&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TLPCF85747&#xA;HA&#xA;T62281&#xA;A N 1&#xA;I L knM988223&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3267" LastEditorUserId="3267" LastEditDate="2016-02-04T13:50:58.897" LastActivityDate="2016-04-16T16:05:32.843" Title="NewliquidCrystal example HelloWorld_i2c just flickers" Tags="|lcd|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20323" PostTypeId="1" CreationDate="2016-02-04T14:04:52.273" Score="2" ViewCount="558" Body="&lt;p&gt;I am working on a smart device using esp-01 to pull data from internet and display on Nokia 5110 LCD display, and send back the resistive touch inputs to my server and display those on my lcd I am using an Arduino UNO as a secondary device that talks to esp-01, my display and the resistive touch panel. As the esp-01 has got a system on chip, I can program it and do most of the thing my UNO is doing, but because of lack of ports I am using UNO (as far as i know that's the only limitation.. I dont exactly know how is the analog pins on UNO different from the gpio pins on esp) is there any ways if I can do the whole task using only my esp-01 by eliminating UNO. If its only about the less gpio pins on esp-01, will I be able to eliminate UNO by using higher esp such as esp-07 or esp-12E? if not, could you suggest a best way of bi-directional communication between esp and UNO? (so that esp can sent the display info to uno and based on that info, uno can send the resistive touch inputs to esp)&lt;/p&gt;&#xA;" OwnerUserId="17029" LastActivityDate="2016-03-18T10:35:32.797" Title="How to control nokia 5110 display using esp-01" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="1" ClosedDate="2016-03-19T00:46:00.410" ContentLicense="CC BY-SA 3.0" />
  <row Id="20324" PostTypeId="2" ParentId="20322" CreationDate="2016-02-04T14:48:57.730" Score="3" Body="&lt;p&gt;I was able to make the example run as intended, by using a different constructor call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am not able to tell you, what these parameters and values mean. However, the documentation for this constructor is shown below (&lt;a href=&quot;https://github.com/marcmerlin/NewLiquidCrystal/blob/master/LiquidCrystal_I2C.h#L100&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*!&#xA;    @method     &#xA;    @abstract   Class constructor. &#xA;    @discussion Initializes class variables and defines the I2C address of the&#xA;    LCD. The constructor does not initialize the LCD.&#xA;&#xA;    @param      lcd_Addr[in] I2C address of the IO expansion module. For I2CLCDextraIO,&#xA;    the address can be configured using the on board jumpers.&#xA;    @param      En[in] LCD En (Enable) pin connected to the IO extender module&#xA;    @param      Rw[in] LCD Rw (Read/write) pin connected to the IO extender module&#xA;    @param      Rs[in] LCD Rs (Reset) pin connected to the IO extender module&#xA;    @param      d0[in] LCD data 0 pin map on IO extender module&#xA;    @param      d1[in] LCD data 1 pin map on IO extender module&#xA;    @param      d2[in] LCD data 2 pin map on IO extender module&#xA;    @param      d3[in] LCD data 3 pin map on IO extender module&#xA;    */&#xA;   LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, &#xA;                     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3 )&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2016-02-04T14:48:57.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20325" PostTypeId="1" AcceptedAnswerId="20330" CreationDate="2016-02-04T15:09:38.487" Score="2" ViewCount="419" Body="&lt;p&gt;I read a few 3x3x3 LED tutorials, e.g. let us take this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Making-an-Arduino-3X3-LED-Cube-in-Less-Than-30-Min/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Making-an-Arduino-3X3-LED-Cube-in-Less-Than-30-Min/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I understand, you can address any of the 3x3 &lt;em&gt;light columns&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*  *  *       1  2  3&#xA;*  *  *       4  5  6&#xA;*  *  *       7  8  9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and each of the three vertical layers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;top&#xA;middle&#xA;bottom&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But can I address each of the 27 leds separately? In other words, can I light up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1+  2   3         bottom layer&#xA;4   5+  6&#xA;7   8   9&#xA;&#xA;1   2+  3         middle layer&#xA;4+  5   6&#xA;7   8   9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16764" LastEditorUserId="16764" LastEditDate="2016-02-04T15:17:32.947" LastActivityDate="2016-02-04T19:07:53.500" Title="Addressing EACH of the 3x3x3 LEDs separately" Tags="|programming|led|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20326" PostTypeId="2" ParentId="20325" CreationDate="2016-02-04T15:49:28.487" Score="4" Body="&lt;p&gt;No, the three transistors are there to select the layer you want to control. At every moment only ONE layer can be on. But if you switch through controlling these layers fast enough, you can create the illusion of having multiple leds on even across layers. THis is because the human eyes are just not capable of seeing lights flashing at a high rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR&#xA;No you can't address them individually, but you can create the illusion that you can.&lt;/p&gt;&#xA;" OwnerUserId="13382" LastActivityDate="2016-02-04T15:49:28.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20327" PostTypeId="1" AcceptedAnswerId="20338" CreationDate="2016-02-04T16:02:33.810" Score="2" ViewCount="12127" Body="&lt;p&gt;I'm trying to make my chinese arduino (which use a chinese CH340G chip) speaks to itself via serial.&#xA;I have wired rx/tx together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, I run the arduino IDE and go to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I write a message, the arduino should respond with the exact same message, right ? Actually, when I write a message, the arduino doesn't respond anything...&lt;/p&gt;&#xA;" OwnerUserId="16323" LastActivityDate="2016-09-22T12:05:58.893" Title="Arduino UNO Rx/Tx speaks to itself" Tags="|serial|" AnswerCount="4" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="20328" PostTypeId="1" CreationDate="2016-02-04T16:46:11.600" Score="0" ViewCount="1042" Body="&lt;p&gt;I was trying to switch to Atmel Studio for programming my Due project since it became more and more complex.&#xA;I managed to use the Arduino Importer Wizard to load a blink.ino file and included all the requested libraries more or less my hand that were marked as missing during compiling.&#xA;Now the compiling kind of works, but I still get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error       (inkerScript): No such file or directory    ECU arm-none-eabi-g++.exe   0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;(inkerScript):&lt;/code&gt; part is no typo. It is really like this in the console.&#xA;Taking a look in the Toolchain Options I have these settings (which I am not able to edit):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Jx8rV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jx8rV.png&quot; alt=&quot;Linker Options&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going into the Miscellaneous Part of the Options I can edit these fields:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GJijt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GJijt.png&quot; alt=&quot;Miscellaneous Options&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By editing the Linker Flags field, I can change the error message from &lt;code&gt;(inkerScript): No such file or directory&lt;/code&gt; to e.g. &lt;code&gt;HelloWorld: No such file or directory&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything wrong with my options? What is the correct setting for &quot;Linker Flags&quot; and what are they doing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately I am not a pro with C++ Compiling / Linker Errors / Settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="17033" LastActivityDate="2016-02-18T19:41:42.077" Title="Arduino Due with Atmel Studio 7" Tags="|c++|arduino-due|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20329" PostTypeId="2" ParentId="20327" CreationDate="2016-02-04T18:57:19.967" Score="2" Body="&lt;p&gt;After some research I found the below schematics of an Arduino UNO with CH340G. A loop-back is not possible as there is a voltage divider (1K ohm, i.e. RX/TX LED) resistors on the RX and TX line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rm50J.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rm50J.jpg&quot; alt=&quot;UNO with CH340G&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tested on a Chinese Arduino Uno clone (VISduino) with CH340G and just as you wrote a loop-back does not work. Tested also an Arduino Mega 2560 clone with CH340G and a Duemilanove clone with FTDI. Both these work just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-04T19:53:41.653" LastActivityDate="2016-02-04T19:53:41.653" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20330" PostTypeId="2" ParentId="20325" CreationDate="2016-02-04T19:07:53.500" Score="2" Body="&lt;p&gt;3 * 3 * 3 = 27&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The easy/overkill way&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could do this by assigning a pin to every LED (on an arduino Mega)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The overkill way&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use shift registers, almost any arduino will do.&#xA;The shift register will set it's outputs according to the amount of high/low signals being clocked in.&#xA;In theory, you can address an infinite amount of LED's (only limited by space, time or funds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breaking it down&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can break it down, so that you control each layer at once.&#xA;Effectively you only drive 9 LED's (1 layer).&#xA;And attach a transistor to the negative side of the layer.&#xA;This way you can choose a LED with the positive side, and a layer with the negative (per layer) control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switching these layers rapidly, will make the changes invisible to the eye. So it seems that the LED's are on all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;To infinity&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combine the overkill way (shift registers) with breaking it down (to reduce cost/size) and you'll be able to create a (somewhat) scalable design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are an awfull lot of tutorials, I suggest you choose one you can understand, try to make a smaller cube, and scale up from there!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Scaling issues&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You'll need a better powersupply for each series of LED's you add.&lt;/li&gt;&#xA;&lt;li&gt;Costs.&lt;/li&gt;&#xA;&lt;li&gt;Processing time, the arduino might not be able to clock the signals fast enough, making it visible for eyes. (depends on the amount of LED's)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Be sure to check/measure/calculate these things along the project.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-02-04T19:07:53.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20331" PostTypeId="2" ParentId="20327" CreationDate="2016-02-04T19:36:26.027" Score="0" Body="&lt;p&gt;There is no problem doing a loopback on an Arduino Uno, but you cannot&#xA;use the serial monitor at the same time. I wrote the following test&#xA;program, which works as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const int LED_PIN = 13;&#xA;&#xA;void setup() {&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    uint8_t data = random();&#xA;    Serial.write(data);&#xA;    while (!Serial.available()) { /* wait */ }&#xA;    if (Serial.read() == data) {&#xA;&#xA;        // Two short pulses = success&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(100);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(700);&#xA;    } else {&#xA;&#xA;        // One long pulse = failure&#xA;        digitalWrite(LED_PIN, HIGH);&#xA;        delay(500);&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        delay(500);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are, however, two caveats with this naive program:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the loopback wire has to be removed before uploading&lt;/li&gt;&#xA;&lt;li&gt;after connecting the wire, the Arduino has to be reset to get out of&#xA;the while loop.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-04T19:36:26.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20332" PostTypeId="2" ParentId="4595" CreationDate="2016-02-04T20:19:30.453" Score="0" Body="&lt;p&gt;&lt;em&gt;Converted Gerben's comment to an answer&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That is not safe. Maximum voltage on the analog pins is 3.3v, according to the datasheet. But why don't you power it from 3.3v? Minimal voltage for that unit is 2.5v. And it uses only 2mA.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-04T20:19:30.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20333" PostTypeId="2" ParentId="6489" CreationDate="2016-02-04T20:33:20.920" Score="3" Body="&#xA;&#xA;&lt;p&gt;You can download the &lt;strong&gt;hex machine code&lt;/strong&gt; from the Arduino by using an ISP programmer, like this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QQsov.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QQsov.jpg&quot; alt=&quot;ISP programmer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A command like this could be used to read the flash memory and save it into &lt;code&gt;myfile.hex&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;avrdude -c avrisp -p m328p -U flash:r:myfile.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However be warned that this file will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;:100000000C945C000C946E000C946E000C946E00CA&#xA;:100010000C946E000C946E000C946E000C946E00A8&#xA;:100020000C946E000C946E000C946E000C946E0098&#xA;:100030000C946E000C946E000C946E000C946E0088&#xA;:100040000C9488000C946E000C946E000C946E005E&#xA;:100050000C946E000C946E000C946E000C946E0068&#xA;:100060000C946E000C946E00000000080002010069&#xA;:100070000003040700000000000000000102040863&#xA;:100080001020408001020408102001020408102002&#xA;:10009000040404040404040402020202020203032E&#xA;:1000A0000303030300000000250028002B000000CC&#xA;:1000B0000000240027002A0011241FBECFEFD8E043&#xA;:1000C000DEBFCDBF21E0A0E0B1E001C01D92A930AC&#xA;:1000D000B207E1F70E94F1010C9401020C940000B8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, you haven't really got &quot;the program&quot; back.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Mikael Patel points out, you can at least turn it into assembler by doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;avr-objdump -j .sec1 -d -m avr5 myfile.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However the output is still not C code like you see in the IDE:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;  d4:   0e 94 f1 01     call    0x3e2   ;  0x3e2&#xA;  d8:   0c 94 01 02     jmp 0x402   ;  0x402&#xA;  dc:   0c 94 00 00     jmp 0   ;  0x0&#xA;  e0:   61 e0           ldi r22, 0x01   ; 1&#xA;  e2:   8d e0           ldi r24, 0x0D   ; 13&#xA;  e4:   0c 94 81 01     jmp 0x302   ;  0x302&#xA;  e8:   61 e0           ldi r22, 0x01   ; 1&#xA;  ea:   8d e0           ldi r24, 0x0D   ; 13&#xA;  ec:   0e 94 ba 01     call    0x374   ;  0x374&#xA;  f0:   68 ee           ldi r22, 0xE8   ; 232&#xA;  f2:   73 e0           ldi r23, 0x03   ; 3&#xA;  f4:   80 e0           ldi r24, 0x00   ; 0&#xA;  f6:   90 e0           ldi r25, 0x00   ; 0&#xA;  f8:   0e 94 f5 00     call    0x1ea   ;  0x1ea&#xA;  fc:   60 e0           ldi r22, 0x00   ; 0&#xA;  fe:   8d e0           ldi r24, 0x0D   ; 13&#xA; 100:   0e 94 ba 01     call    0x374   ;  0x374&#xA; 104:   68 ee           ldi r22, 0xE8   ; 232&#xA; 106:   73 e0           ldi r23, 0x03   ; 3&#xA; 108:   80 e0           ldi r24, 0x00   ; 0&#xA; 10a:   90 e0           ldi r25, 0x00   ; 0&#xA; 10c:   0c 94 f5 00     jmp 0x1ea   ;  0x1ea&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unless you are an assembler expert, making sense of that would be pretty hard, and the time taken to do it would be better spent simply rewriting the code from scratch.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-05T20:57:56.937" LastActivityDate="2016-02-05T20:57:56.937" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20335" PostTypeId="2" ParentId="20314" CreationDate="2016-02-04T21:12:06.673" Score="10" Body="&lt;p&gt;Not answered in @Majenko's post: Yes, with a 8MHz clock, each line will take the double of the time. Unless the line waits for something that is not clock driven - e.g. external input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to @Majenko's answer, a CPU has a clock to ensure the instructions are complete, before the next step starts. A CPU is made out of lots of transistors (I found a reference that indicated the AtMega was in the range of low millions, give-or-take an order of magnitude).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;During a cycle, the electricity flows through the chip, turning transistors on/off, the results of which will turn more transistors on/off, and so forth down the line. While this is happening, some parts of the chip have a &quot;wrong&quot; value - you can think of this as being half-way through a calculation (you've added the one's column and the 10s column, and are about to start on the 100s column). You don't want this to affect the outside world, so (for example) your output pins are latched - held at whatever value they are - until the instruction is complete. How long it takes to complete an instruction varies, but the manufacturer works out the slowest instruction under the worst circumstances.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the AtMega (which is the chip on the Arduino), Atmel (who designed the chip) has declared this is 1/20,000,000 of a second - this is 20MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that not all microprocessors run all their instructions at 1 instruction per cycle - some instructions might take 1, or 2, or 10 cycles. Pipelining makes things even more complicated - a processor might do some of the work (e.g. fetch the next instruction) in one cycle, execute it in the next - but while it is executing instruction 1, it can also fetch the next instruction. To do this, it might need to take a guess at what instruction comes next (in the case of the machine-code equivalent of a &quot;goto&quot; - such is used for loops), and if it guesses wrong, it has to cope with that; throw away the instruction it retrieved and retrieve the next one, losing a cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Wikipedia page on &lt;a href=&quot;https://en.wikipedia.org/wiki/Instruction_pipelining&quot;&gt;instruction pipelining&lt;/a&gt; shows an example of a RISC chip pipelining in 5 stages - instruction fetch, instruction decode, execute, memory access, and write-back. So, you can have 5 instructions at some stage of execution, overlapping. Until the &quot;writeback&quot; phase, the instructions have no real effect. You can think of this as an assembly line - it takes 7 minutes to put a widget together, but it can be broken down into 5 stages, the longest stage taking 2 minutes. Once every two minutes, each partly completed widget is moved by the assembly line to the next station. You get one widget out every two minutes - The &quot;clock&quot; can only tick as fast as the slowest step. If you push the widget out any faster, the &quot;bottleneck&quot; will get more and more widgets queued up.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="7508" LastEditDate="2016-02-04T21:15:46.813" LastActivityDate="2016-02-04T21:15:46.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20336" PostTypeId="2" ParentId="11749" CreationDate="2016-02-04T21:31:53.203" Score="4" Body="&lt;p&gt;You can, and I do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not technically an Arduino anymore, I guess. I made my own board, replacing a resonator on a board will require some fine soldering, but it is definitely possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some gotchas: Anything time-related (e.g. millis() ) will be run faster than is should - 25% more millis() per second. Also, the bootloader expects 16mhz, so you won't be able to reprogram it at this speed. I purchased a USBASP programmer - it hooks into the 2x3 pin grid on one side of the board, and lets you reprogram it without the bootloader (this is how the bootloader is put on in the first place!). You will need at least 4.5 volts at 20mhz to avoid problems, compared to 3.78 volts for 16mhz - this means batteries will drain somewhat quicker (3x1.5v batteries will run down pretty quick), and if you have any motors or other draw on the batteries, 3 1.5v batteries will probably not work even if they are fresh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, going in the exact opposite direction, the lower the clock speed, the less voltage is required - for some projects, you might not need the clock speed - you can go down to 1.8v running at 4mhz.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-02-04T21:31:53.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20338" PostTypeId="2" ParentId="20327" CreationDate="2016-02-04T22:33:01.557" Score="5" Body="&lt;p&gt;As Mikael Patel pointed out in his answer, you have set up a voltage divider. Mikael has thoughtfully provided a schematic of the clone Uno, where the relevant part is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YKHdw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YKHdw.png&quot; alt=&quot;Clone schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Equivalent circuit&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you jumper together pins D0 and D1 (Rx and Tx) on the Uno effectively you have made this circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oM9IO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oM9IO.png&quot; alt=&quot;Loop-back voltage divider&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Testing&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If I set up this with a function generator, I get this result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2j648.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2j648.png&quot; alt=&quot;Loop-back scope results&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see that for a square-wave input of 0 to 5V, we only get an output of 2.16 to 5V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;What is LOW?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now looking at the datasheet for the DC characteristics we see:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sNI3Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sNI3Y.png&quot; alt=&quot;DC characteristics&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an input to register as LOW it has to be no higher than &lt;code&gt;0.3 * Vcc = 0.3 * 5&lt;/code&gt;. Thus the voltage cannot be higher than 1.5V. Since we are measuring 2.16V, that will not count as a LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now admittedly that is for the Atmega328P and not the CH340G, but it will probably have similar characteristics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a datasheet for the CH340G, and that shows even stricter requirements for a LOW signal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FBn9B.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FBn9B.png&quot; alt=&quot;CH340G datasheet&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Official Uno&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Comparing to the official Uno circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Oj1bl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oj1bl.png&quot; alt=&quot;Uno schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will note there that the indicator LEDs are on a different circuit, and thus do not form a voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;The Maths&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The clone Uno circuit above can be re-arranged like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hv5FO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hv5FO.png&quot; alt=&quot;Re-arranged circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the LEDs have a voltage drop of 1.86V (measured in practice, and about right for the red LEDs I am using) then effectively we have the resistors R1 and R2 connected to 3.14V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since they are in parallel they are effectively 500 ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now using the formula for voltage dividers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1000 / (1000 + 500) * (5 - 1.86) = 2.09V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is close enough to the observed result. I didn't check each resistor to make sure it was exactly in spec.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think R4 affects the results because it is effectively &quot;floating&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-04T23:45:14.310" LastActivityDate="2016-02-04T23:45:14.310" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20339" PostTypeId="2" ParentId="20304" CreationDate="2016-02-04T22:38:34.043" Score="1" Body="&lt;p&gt;You use millis() to keep track of time and also prevent blocking. Replicating your program logic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long soil_timer = 0;&#xA;long tilt_timer = 0;&#xA;char soil_flag = 1;&#xA;char tilt_flag = 1;&#xA;&#xA;void loop() { &#xA;    int soilSensor = analogRead(A0); &#xA;    int tiltSensor = analogRead(A1); &#xA;&#xA;  if (soil_flag == 1) {&#xA;    if (soilSensor &amp;gt;= 10) { &#xA;      digitalWrite(22, HIGH);&#xA;      Serial.println(soilSensor);&#xA;      sendSMS1(); &#xA;    }&#xA;   else { &#xA;      digitalWrite(22, LOW);&#xA;    }&#xA;    soil_timer = millis();&#xA;    soil_flag = 0;&#xA;  }&#xA;&#xA;  if (tilt_flag == 1) {&#xA;    if (tiltSensor &amp;gt;= 100) { &#xA;       digitalWrite(led, HIGH); &#xA;       Serial.println(tiltSensor);&#xA;       sendSMS2();&#xA;    } &#xA;    else { &#xA;       digitalWrite(led, LOW); &#xA;       Serial.println(tiltSensor);&#xA;    } &#xA;    tilt_flag = 0;&#xA;    tilt_timer = millis();&#xA;  }&#xA;  if (millis() - soil_timer &amp;gt;= 60000){&#xA;     soil_flag = 1;&#xA;  }&#xA;  if (millis() - tilt_timer &amp;gt;= 60000){&#xA;     tilt_flag = 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-04T22:38:34.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20340" PostTypeId="1" AcceptedAnswerId="21274" CreationDate="2016-02-04T22:43:57.300" Score="0" ViewCount="408" Body="&lt;p&gt;I'm trying to hook up a nRF24L01+ wireless transmitter to an Arduino Yun Mini on SPI, but I'm having a hard time. After a few minutes Linino crashes and becomes completetly inaccessible - until I upload a new sketch to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the SPI pins (MOSI, MISO and SCK) to the corrensponding pins of the Yun. I connected CE to pin 3 and CSN to pin 2. I'm using the RF24 library found here: &lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following little code is enough to make Linino crash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;&#xA;RF24 radio(3,2);&#xA;&#xA;void setup() {&#xA;  radio.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong here? Any ideas? Any help is greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="17043" LastActivityDate="2016-03-01T14:49:10.110" Title="Arduino Yun &amp; nRF24L01+ -&gt; Linino crashing" Tags="|arduino-yun|nrf24l01+|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20342" PostTypeId="2" ParentId="20317" CreationDate="2016-02-04T23:07:05.863" Score="0" Body="&lt;p&gt;Perhaps the &lt;code&gt;Serial.print()&lt;/code&gt;s in the slave's request event function are causing too much delay (clock stretching?). You should make the &lt;code&gt;Wire.write()&lt;/code&gt; the second statement in that function right after the &lt;code&gt;getTime&lt;/code&gt; call. Or you could use &lt;code&gt;Wire.write(&quot;Hello&quot;)&lt;/code&gt; as the only statement in the function, so you can narrow down the problem.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-04T23:07:05.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20344" PostTypeId="1" AcceptedAnswerId="20345" CreationDate="2016-02-05T03:38:50.327" Score="3" ViewCount="469" Body="&lt;p&gt;I am new into Arduino. So if I program the microcontroller using the Arduino board and once it is doing what I want can I just take the microcontroller out of the board and use the microcontroller itself? If so could you please guide me to some tutorials on how to use it?&lt;/p&gt;&#xA;" OwnerUserId="16996" LastEditorUserId="26916" LastEditDate="2017-11-04T18:58:54.610" LastActivityDate="2017-11-04T18:58:54.610" Title="Using Arduino microcontrollers without board" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20345" PostTypeId="2" ParentId="20344" CreationDate="2016-02-05T03:48:10.777" Score="5" Body="&lt;p&gt;I have a post about a &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;breadboard Arduino&lt;/a&gt; - in that I demonstrate the minimal amount of parts you need to use the controller (which is not much).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of wiring it up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bJdmz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bJdmz.jpg&quot; alt=&quot;Minimal Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use an external crystal or resonator you can add that to the board like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DHOaY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DHOaY.jpg&quot; alt=&quot;Crystal on board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8 MHz crystal shown, but you could use 16 MHz. Or change the fuses and use the internal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Schematic showing how you could (if you wanted) add an ICSP header and an FTDI header:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XHxrG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XHxrG.png&quot; alt=&quot;Simplified Arduino schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-05T03:48:10.777" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20347" PostTypeId="2" ParentId="20318" CreationDate="2016-02-05T04:23:19.257" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I need a sample rate of 6 kHz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;OK, so that means you need to sample and send every 1/6000 seconds (167 µs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;noreferrer&quot;&gt;lengthy discussion about the ADC hardware&lt;/a&gt;. Amongst other things is a table of conversion times for the different ADC prescalers, assuming a 16 MHz clock:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Prescaler&#xA;    2    * 13 * 1/16E6  = 0.000001625 (  1.625 µs)&#xA;    4    * 13 * 1/16E6  = 0.00000325  (  3.25  µs)&#xA;    8    * 13 * 1/16E6  = 0.0000065   (  6.5   µs)&#xA;   16    * 13 * 1/16E6  = 0.000013    ( 13     µs)&#xA;   32    * 13 * 1/16E6  = 0.000026    ( 26     µs)&#xA;   64    * 13 * 1/16E6  = 0.000052    ( 52     µs)&#xA;  128    * 13 * 1/16E6  = 0.000104    (104     µs)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you go for maximum resolution (10 bits) you need a prescaler of 128, which takes 104 µs. The number of conversions you can do a second (taking the inverse of the above) is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Prescaler  Conversions/sec&#xA;  2           615,385&#xA;  4           307,692&#xA;  8           153,846&#xA; 16            76,923&#xA; 32            38,462&#xA; 64            19,231&#xA;128             9,615&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You also need to take into account the transmission time. At 115200 baud you can transmit one byte every 1/11520 seconds (86.8 µs) so therefore two bytes (16 bits) would take 173.6 µs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you sample then transmit you will therefore take, per sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;104 + 174 = 278 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is too slow if you want to achieve it inside 167 µs. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can sample asynchronously (in the background) so you transmit one sample while taking the next one, but you are still limited by the transmission speed of serial, so it would still take 174 µs per sample.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, fiddling with the prescaler isn't really the issue here because the serial transmission time is the limiting factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forget about the ADC and how it works for the moment. At 115200 baud you can't transmit 2 x 6000 bytes per second. That is simply because the maximum is 11520 bytes per second.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-05T04:23:19.257" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20348" PostTypeId="1" AcceptedAnswerId="20350" CreationDate="2016-02-05T09:34:37.063" Score="0" ViewCount="84" Body="&lt;p&gt;I found this sketch online and would like to reuse it. I do have a dot-matrix-display, that is accessable through an i2c with the address 0x70. How do I change the code to be able to use the hardware address instead of the &lt;code&gt;Data&lt;/code&gt;, &lt;code&gt;Load&lt;/code&gt; and &lt;code&gt;CLK&lt;/code&gt; pins?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DS1307RTC.h&amp;gt;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;LedControl.h&quot;&#xA;&#xA;//Pin definition constants&#xA;const int mDataIn=12, mLoad=11, mClk=10;  //Max7219 LED matrix&#xA;&#xA;int h1, h2, m1, m2, s1, s2; // Each digit&#xA;int tChange; //Scratch used during change time via pushbutton&#xA;&#xA;// Matrix library instance&#xA;LedControl lc=LedControl(mDataIn, mClk, mLoad,1); //Pin assignments and number of matrices (1)&#xA;&#xA;void setup() {&#xA;&#xA;  // Notify Arduimo that the RTC is the external time provider&#xA;  setSyncProvider(RTC.get);   &#xA;&#xA;  //Initialize the MAX72XX in power-saving mode.&#xA;  lc.shutdown(0,false);&#xA;  lc.setIntensity(0,1); // Set brightness to a low value&#xA;  lc.clearDisplay(0); // Clear the display&#xA;  delay(100); // Wait after initializing display&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  //Isolate hours, minutes, seconds, one digit to each LED matrix column.&#xA;  h1=n1(hour());&#xA;  h2=n2(hour());&#xA;  m1=n1(minute());&#xA;  m2=n2(minute());&#xA;  s1=n1(second());&#xA;  s2=n2(second());&#xA;&#xA;  // Cast as (change integer to) byte, write to LED row.&#xA;  // (Row runs from pin to pin on model used.)&#xA;  lc.setRow(0,7,byte(h1));&#xA;  lc.setRow(0,6,byte(h2));&#xA;  lc.setRow(0,4,byte(m1));&#xA;  lc.setRow(0,3,byte(m2));&#xA;  lc.setRow(0,1,byte(s1));&#xA;  lc.setRow(0,0,byte(s2));&#xA;  }&#xA;&#xA;&#xA;  int n1(int num) {  // Function to isolate first digit of 2-digit integer&#xA;    num = num / 10; //Integer division by 10 (discard remainder)&#xA;    return num;&#xA;  }&#xA;&#xA;  int n2(int num) {  // Function to isolate second digit of 2-digit integer&#xA;    num = num % 10; //Modulo division by 10 (keep remainder only)&#xA;    return num;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16940" LastActivityDate="2016-02-05T10:26:20.797" Title="i2c address instead of assigning pins" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20349" PostTypeId="2" ParentId="20218" CreationDate="2016-02-05T09:55:13.800" Score="0" Body="&lt;p&gt;This is what I found behind the link @mikael-patel posted, and with a little configuration it does exactly what I want. Basically the &lt;code&gt;scroll()&lt;/code&gt;-method handles anything neccessary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_LEDBackpack.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;&#xA;#define NUM_MATRICES 2&#xA;Adafruit_8x8matrix matrix[NUM_MATRICES];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;8x8 LED Matrix Test&quot;);&#xA;&#xA;  for(uint8_t m=0; m&amp;lt;NUM_MATRICES; m++) {&#xA;    matrix[m].begin(0x70 + m);&#xA;    matrix[m].clear();&#xA;    matrix[m].setTextSize(1);&#xA;    matrix[m].setTextWrap(false);  // we dont want text to wrap so it scrolls nicely&#xA;    matrix[m].setTextColor(LED_GREEN);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  scroll(&quot;Hello World!&quot;);&#xA;}&#xA;&#xA;void scroll(char* text) {&#xA;  int scrollPositions = (strlen(text) * 8) + 32;&#xA;&#xA;  for (int x=(8 * NUM_MATRICES); x&amp;gt;=-scrollPositions; x--) {&#xA;   for(uint8_t m=0; m&amp;lt;NUM_MATRICES; m++) {&#xA;    matrix[m].clear();&#xA;    matrix[m].setCursor((x - (m * 8)), 0);&#xA;    matrix[m].print(text);&#xA;    matrix[m].writeDisplay();&#xA;   }&#xA;   delay(80);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16940" LastActivityDate="2016-02-05T09:55:13.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20350" PostTypeId="2" ParentId="20348" CreationDate="2016-02-05T10:26:20.797" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How do I change the code to be able to use the hardware address instead of the Data, Load and CLK pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is not possible as this is two totally different LED drivers. MAX72XX uses a protocol with those signals, while the dot-matrix LED display uses I2C. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always port the library to the dot-matrix. Or rewrite the sketch with the dot-matrix library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-05T10:26:20.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20351" PostTypeId="2" ParentId="19269" CreationDate="2016-02-05T10:34:05.300" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I've been given a digispark and am looking to write straight assembly code for it. Anyone know how to get started with this? I've been successful in getting the Arduino IDE set-up but would really like to avoid writing assembly in-line... &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE build support assembly files (.S). Nerd Ralph has written a  &lt;a href=&quot;http://nerdralph.blogspot.se/2013/12/writing-avr-assembler-code-with-arduino.html&quot; rel=&quot;nofollow&quot;&gt;blog&lt;/a&gt; on the subject. There you will find all the details and how to write both inline and pure assembly files. He is really god at digging out all the details and sharing his findings. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-05T10:34:05.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20352" PostTypeId="1" AcceptedAnswerId="20353" CreationDate="2016-02-05T14:22:42.697" Score="3" ViewCount="1177" Body="&lt;p&gt;The definition for Analog Reference is as follows: The reference voltage used for analog input (i.e. the value used as the top of the input range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By default you have analog reference of 5V. So the precision of analogRead is 5 / 1023 = 0.0048875.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what happens if I lower the analog reference to let's say 1V. Does that mean that the precision now is 1 / 1023 (and the arduino can't measure voltages higher than 1V) or it is the same precision as before with the only difference being the fact that the arduino can't measure voltages higher than 1V anymore?&lt;/p&gt;&#xA;" OwnerUserId="14308" LastActivityDate="2020-09-20T03:30:44.720" Title="Does lowering arduino analog reference increase precision in measuring low voltage?" Tags="|arduino-uno|analogread|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20353" PostTypeId="2" ParentId="20352" CreationDate="2016-02-05T14:54:51.460" Score="2" Body="&lt;p&gt;The former, i.e precision would now be 1/1023 but the accuracy of the AD converter is 4 / 1024 or 1 part in 256  i.e. 0.25%. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also be aware that the internal reference voltages themselves are not very accurate : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;DEFAULT: depends on your computer power supply USB2  Vbus = 4.4V - 5.25V, Vint 1 = 1.1V  actually 1.0 -- 1.2V, Vint 2 = 2.56V  actually 2.4 -- 2.8V&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2016-02-05T14:54:51.460" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20354" PostTypeId="1" CreationDate="2016-02-05T16:15:42.103" Score="0" ViewCount="1854" Body="&lt;p&gt;I got this sensor some time ago because I wanted to play with measuring the temperature. I don't remember how I got it or if it has a name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've Googled around, and obviously is has the following&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;LM358 op amp&lt;/li&gt;&#xA;&lt;li&gt;&quot;103&quot; thermistor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When googling for help I mostly find stuff about how to use the LM358 which is way above my skill level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is this and how do use it? :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PfCqp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PfCqp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2016-02-05T17:12:33.713" Title="What is this temperature sensor module? (LM358, 103)" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20355" PostTypeId="2" ParentId="20354" CreationDate="2016-02-05T17:11:23.913" Score="0" Body="&lt;p&gt;Connect VCC to +5V, GND to GND, then S to A0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do an analogRead() of A0 and then convert that to temperature using the Steinhart-Hart equation, inserting the three values A B and C which you don't know because you have no documentation for the thermistor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-05T17:11:23.913" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20356" PostTypeId="2" ParentId="20354" CreationDate="2016-02-05T17:12:33.713" Score="1" Body="&lt;p&gt;&quot;103&quot; is standard resistor (and other component) numbering - the first two digits specify a value and the third is a power-of-ten multiplier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 0 3 = 10 * 10^3 = 10K&#xA;&#xA;4 7 2 = 47 * 10^2 = 4.7K&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For devices that are typically measured in &lt;em&gt;thousandths&lt;/em&gt;, &lt;em&gt;millionths&lt;/em&gt; or smaller (like a capacitor) then the third digit is a &lt;em&gt;minus&lt;/em&gt; power-of-ten:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 0 6 = 10 * 10^-6 = 1u&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That black disc labelled '103' is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Thermistor&quot; rel=&quot;nofollow&quot;&gt;thermistor&lt;/a&gt; - a temperature-controlled resistor. It is most likely NTC, or negative-temperature coeffiecient, thus the resistance decreases as the temperature increases. This is contrary to typical physics where an increase in the temperature of a generic conductive material results in an increase in its electrical resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LM358 is included to &lt;em&gt;buffer&lt;/em&gt; the thermistor from the Arduino/microcontroller. In simple terms, this means that the effective resistance of the analogue input pin does not have to be taken into consideration when converting the voltage measured to into a value for the temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without a better picture of both sides of the board, or better yet a circuit diagram, it is not possible to determine what the voltage on pin &lt;code&gt;S&lt;/code&gt; will be for a given temperature. However, it seems that the thermistor is in series with another 10K resistor (&lt;code&gt;R3&lt;/code&gt;, marked '103' of course) such that an increase in temperature results in an increase in voltage. At roughly 20 degrees Celsius (it depends on the manufacturer and their specifications) the resistance of the thermistor will be 10K, thus the voltage at &lt;code&gt;S&lt;/code&gt; will be &lt;code&gt;Vcc/2&lt;/code&gt;. Calculating the voltage for different temperatures requires you to know the temperature coefficient, which can be found from the datasheet or by measuring the resistance at various known temperatures and plugging those values into an equation.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-02-05T17:12:33.713" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20357" PostTypeId="1" AcceptedAnswerId="20358" CreationDate="2016-02-05T18:06:38.177" Score="0" ViewCount="3704" Body="&lt;p&gt;Hello in a previous question i was able to set variables through if statements&lt;/p&gt;&#xA;&#xA;  &lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  const uint16_t inputLength = 512;&#xA;int ss = 0;&#xA;int bHold = 0;&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600);&#xA; }&#xA;&#xA; void loop() {&#xA;  if ( Serial.available() &amp;gt; 0 )&#xA;  {&#xA;    static char input[inputLength];&#xA;    static uint16_t i;&#xA;    char c = Serial.read();&#xA;&#xA;    if ( c != '\r' &amp;amp;&amp;amp; c != '\n' &amp;amp;&amp;amp; i &amp;lt; inputLength - 1)&#xA;      input[i++] = c;&#xA;&#xA;    else&#xA;    {&#xA;      input[i] = '\0';&#xA;      i = 0;&#xA;&#xA;      uint16_t array[80];&#xA;      uint16_t j = 0;&#xA;&#xA;      if ( !strncmp(input, &quot;ss&quot;, 2) )&#xA;      {        &#xA;        char* p = input + 2;&#xA;        while ( (p = strchr(p, ' ')) != NULL )&#xA;          array[j++] = strtol(p, &amp;amp;p, 10); //&#xA;&#xA;        for ( uint8_t i = 0; i &amp;lt; j; i++ )&#xA;        {&#xA;          ss = array[i];&#xA;          Serial.println(ss);&#xA;        }&#xA;      }&#xA;&#xA;      if ( !strncmp(input, &quot;bHold&quot;, 5) )&#xA;      {        &#xA;        char* p = input + 5;&#xA;        while ( (p = strchr(p, ' ')) != NULL )&#xA;          array[j++] = strtol(p, &amp;amp;p, 10);  &#xA;&#xA;        for ( uint8_t i = 0; i &amp;lt; j; i++ )&#xA;        {&#xA;         bHold = array[i];                   &#xA;         Serial.println(bHold);&#xA;        }&#xA;      }&#xA;&#xA;      if ( !strncmp(input, &quot;Whos There&quot;, 10) )&#xA;      {&#xA;        Serial.print(&quot;me&quot;);&#xA;      }&#xA;      if ( !strncmp(input, &quot;hello&quot;, 5) )&#xA;      {&#xA;        Serial.print(&quot;hi&quot;);&#xA;      }&#xA;      if ( !strncmp(input, &quot;sa&quot;, 2) )&#xA;      {&#xA;        Serial.print(&quot;  ss= &quot;);&#xA;        Serial.print(ss);&#xA;&#xA;        Serial.print(&quot;  bHold= &quot;);&#xA;        Serial.print(bHold);&#xA;&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.println(&quot;==============================&quot;);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if works! but if i keep adding variables i have to keep adding if statements and this will get longer. so then i went with code like this that allows me to set all variables at once&lt;/p&gt;&#xA;&#xA;  &lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define INPUT_SIZE 30&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;&#xA;&#xA;    int _mode = Serial.parseInt();&#xA;    int _ss = Serial.parseInt();&#xA;    int _bHold = Serial.parseInt();&#xA;&#xA;    if (Serial.read() == '\n') {&#xA;      ss = _ss;&#xA;      bHold = _bHold;&#xA;      mode = _mode;&#xA;&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this works awesome! but i have to set all variables at once. my question is is there a way i can simply input a command like ss = 10 press enter then bHold = 30 and not have to input any other variable?&#xA;thanks i advance. please point me in right direction  Maybe make a function?&lt;/p&gt;&#xA;" OwnerUserId="16629" LastEditorUserId="4131" LastEditDate="2016-02-05T21:31:38.453" LastActivityDate="2016-02-06T00:54:12.200" Title="Edit variables through Serial?" Tags="|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20358" PostTypeId="2" ParentId="20357" CreationDate="2016-02-05T18:24:15.990" Score="0" Body="&lt;p&gt;Somewhere along the line you have to tell your program how to map names to actual variables. Once you have compiled your program it forgets the names of the variables - those only exist in the source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have to have some other manual list of those variable names - be that in the form of &lt;code&gt;if(...)&lt;/code&gt; statements, or an array of structs with the name in them, or whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no getting away from it - you need that manual mapping in some form or other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The closest you could get would be to set up some kind of &lt;em&gt;hash&lt;/em&gt; system using structs and linked lists, whereby you could set any key/value pair, but then of course your program would still have to know to look for certain keys in the hash to do things with them, so that would be pretty pointless since you've just moved the variable mapping from one place to another.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-05T18:24:15.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20359" PostTypeId="2" ParentId="20323" CreationDate="2016-02-05T20:45:52.317" Score="1" Body="&lt;p&gt;Yes, you can use a NodeMCU ESP12E board for example as a standalone microcontroller, you actually don't need an Arduino in your case.&lt;/p&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2016-02-05T20:45:52.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20361" PostTypeId="1" CreationDate="2016-02-05T22:02:26.113" Score="0" ViewCount="559" Body="&lt;p&gt;What is the ideal power supply for this module? What do you use that works ok?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will the &lt;a href=&quot;http://www.ebay.com/itm/5PCS-5V-to-3-3V-DC-DC-Step-Down-Power-Supply-Buck-Module-AMS1117-LDO-800MA-CM10-/321963058956?hash=item4af67e670c:g:6hcAAOSwo3pWfi4t&quot; rel=&quot;nofollow&quot;&gt;AMS1117&lt;/a&gt; work?&lt;/p&gt;&#xA;" OwnerUserId="17069" LastEditorUserId="6936" LastEditDate="2016-02-06T04:10:20.303" LastActivityDate="2016-02-06T04:10:20.303" Title="Ideal power supply for ESP8266" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20362" PostTypeId="2" ParentId="20361" CreationDate="2016-02-05T22:09:10.613" Score="1" Body="&lt;p&gt;Yes, that will work. However, ignore the entire description.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is &lt;strong&gt;NOT&lt;/strong&gt; a buck regulator - it is a low-dropout &lt;strong&gt;linear&lt;/strong&gt; regulator.  Thus it will waste power as heat - the more current you draw the hotter it will get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The '1117' range of regulators are pretty much ubiquitous. I use them in a wide range of products and situations where power consumption isn't critical (i.e., not battery based products). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For lower power requirements you want to get a &lt;em&gt;real&lt;/em&gt; buck regulator. Something more like this: &lt;a href=&quot;http://www.ebay.co.uk/itm/301842020065&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/301842020065&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that it's an adjustable module, and you will need to first use a multimeter to adjust the output to 3.3V before you connect it up.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because they are adjustable they are a great thing to keep around since you can use them for all sorts of different situations.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-05T22:09:10.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20364" PostTypeId="2" ParentId="8873" CreationDate="2016-02-05T23:00:40.847" Score="1" Body="&lt;p&gt;Open an account and try to implement their API using something like Chrome REST client. Then do the same through the ESP8266. I would personally relay it through my own web service/ url. You could also take a look at: &lt;a href=&quot;http://www.instructables.com/id/Send-SMS-from-Arduino-over-the-Internet-using-ENC2/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Send-SMS-from-Arduino-over-the-Internet-using-ENC2/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17069" LastActivityDate="2016-02-05T23:00:40.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20366" PostTypeId="1" CreationDate="2016-02-06T00:49:16.463" Score="2" ViewCount="82" Body="&lt;p&gt;I read an article that said that shorting an IO pin to ground would destroy the pin.  I've done this before when I connected a buzzer to an IO pin and to ground without resistors, the buzzer is only 14 ohms so the current would be quite high through the pins.  Why is my Arduino still working,  and how should I know when to use resistors or what rating to use?&lt;/p&gt;&#xA;" OwnerUserId="17072" LastEditorUserId="6936" LastEditDate="2016-02-06T04:11:17.730" LastActivityDate="2016-02-06T10:36:17.150" Title="Why is my Arduino still working?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20367" PostTypeId="2" ParentId="20357" CreationDate="2016-02-06T00:54:12.200" Score="0" Body="&lt;p&gt;You can store variables on the fly in a simple array or linked list.&#xA;A linked list would probably be better, but for now we'll just use an array.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_VARS = 10;&#xA;const int NAME_SIZE = 16;&#xA;&#xA;typedef _var&#xA;{&#xA;    char  name[NAME_SIZE];&#xA;    int   value;&#xA;} Var;&#xA;&#xA;&#xA;Var variables[MAX_VARS];&#xA;unsigned int var_count = 0;&#xA;&#xA;void loop()&#xA;{&#xA;    char *command = getSerialInput(); // get a line of input from the serial stream&#xA;&#xA;    // parse the command &quot;set varname=value&quot;&#xA;    if (strncmp(command, &quot;set &quot;, 4) == 0)&#xA;    {&#xA;        char *new_name = command + 4; // skip the 'set '&#xA;&#xA;        char *ptr = strchr(command,'='); // find the equals character&#xA;        if (ptr != NULL)&#xA;        {&#xA;             *ptr = '\0';              // Break the string in half about the '='&#xA;             char *new_value = ptr+1;  // Everything after the equals is the value&#xA;&#xA;             // Now we have a parsed variable name, and value&#xA;             // Have we already stored this variable?&#xA;             int i;&#xA;             for (i=0; i&amp;lt;var_count; i++)&#xA;             {&#xA;                 if (strcmp(variables[i].name, new_name) == 0)&#xA;                 {&#xA;                     // Found an existing copy - update it&#xA;                     variables[i].value = new_value;&#xA;                     break;&#xA;                 }&#xA;             }&#xA;&#xA;             // Did we find the variable already?  No - add a new one&#xA;             if (i == var_count &amp;amp;&amp;amp; i&amp;lt; MAX_VARS)&#xA;             {&#xA;                 strncpy(variables[i].name, new_name, NAME_SIZE);&#xA;                 variables[i].name[NAME_SIZE-1] = '\0'; // fix any strncpy() overflow&#xA;                 variables[i].value = new_value;&#xA;                 var_count += 1;&#xA;             }&#xA;             else if (i == MAX_VARS)&#xA;             {&#xA;                 Serial.println(&quot;Out of variable slots&quot;);&#xA;             }&#xA;        }&#xA;    }&#xA;    // parse the command &quot;get varname&quot;&#xA;    else if (strncmp(command, &quot;get &quot;, 4) == 0)&#xA;    {&#xA;         char *new_name = command+4;&#xA;         int i;&#xA;         for (i=0; i&amp;lt;var_count; i++)&#xA;         {&#xA;             if (strcmp(variables[i].name, new_name) == 0)&#xA;             {&#xA;                 // Found an existing copy - output it&#xA;                 Serial.println(value, DEC);&#xA;                 break;&#xA;             }&#xA;         }&#xA;&#xA;         // Did we find the variable already?  No - error&#xA;         if (i == var_count)&#xA;         {&#xA;              Serial.print(new_name);&#xA;              Serial.println(&quot; - not found&quot;);&#xA;         }&#xA;    }&#xA;}&#xA;else&#xA;{&#xA;    Serial.println(&quot;HELP: \&quot;set &amp;lt;name&amp;gt;=&amp;lt;value&amp;gt;\&quot; or \&quot;get &amp;lt;name&amp;gt;\&quot;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This would be better with dynamically allocated memory, so the programme only uses exactly what it needs.  But I wanted to show a way of storing a list of user input without complications.  Obviously this programme omits a lot of error checking too - like when you run out of array slots in &lt;code&gt;variables&lt;/code&gt;; or when the user input is bad.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-06T00:54:12.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20368" PostTypeId="2" ParentId="20366" CreationDate="2016-02-06T02:20:09.773" Score="3" Body="&lt;p&gt;You don't necessarily destroy the pin, but it won't do it any good. To work out the resistors use Ohm's Law. The continuous output of a pin should not exceed 20 mA, thus:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V = I * R&#xA;R = V / I&#xA;R = 5 / 0.020&#xA;R = 250&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus 250 ohms, from the pin to ground, would allow a safe amount of current to flow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the rating, that resistor would dissipate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;W = V * I&#xA;W = 5 * 0.020&#xA;W = 0.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus a resistor that could handle 100 mW would be required. More reasonably, a quarter watt resistor should be fine.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-06T02:20:09.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20369" PostTypeId="2" ParentId="20366" CreationDate="2016-02-06T10:36:17.150" Score="3" Body="&lt;p&gt;The Arduino is tougher than it looks. ;-) Or maybe you were just lucky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exact point of failure of an IC is hard to predict, because of part&#xA;to part variations, and because it can depend on many uncontrolled&#xA;factors (duration of fault, temperature, voltages and currents on other&#xA;pins, part history...). Then, the &lt;em&gt;absolute maximum ratings&lt;/em&gt; are not the&#xA;predicted point of failure. They are rather a lower bound:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The part &lt;em&gt;should not&lt;/em&gt; fail if you do not exceed the ratings&lt;/li&gt;&#xA;&lt;li&gt;it &lt;em&gt;may&lt;/em&gt; fail anywhere beyond those limits.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Time is, however, also a factor. The manufacturer says that operating&#xA;the part close to the limits for an extended period may shorten its&#xA;lifespan.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-06T10:36:17.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20371" PostTypeId="1" AcceptedAnswerId="20375" CreationDate="2016-02-06T11:03:40.143" Score="1" ViewCount="748" Body="&lt;p&gt;I have an Arduino Uno and one of these nRF24L01+ from china (see image)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/YMLJG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YMLJG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the module i wanted to use the library provided by Adafruit (&lt;a href=&quot;http://playground.arduino.cc/InterfacingWithHardware/Nrf2401&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://playground.arduino.cc/InterfacingWithHardware/Nrf2401&lt;/a&gt;). My problem is, that they're using different names for some pins, because the library is designed for a different module with the following pin outs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2aT18.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2aT18.jpg&quot; alt=&quot;i.stack.imgur.com/2aT18.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know which PIN from the China module corresponds to the DAT and DR1 Pin on the Adafruit module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it OK to use the library in conjunction with the china module?&lt;/li&gt;&#xA;&lt;li&gt;What are the DAT and DR1 PIN on the module from China ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What I know so far:&#xA;- took a look into the library and into the documentation at playground.arduino.cc/InterfacingWithHardware/Nrf2401 and found out that the DR1 pin is for the available() function to check if data is available to be read.&lt;/p&gt;&#xA;" OwnerUserId="17080" LastEditorUserId="11529" LastEditDate="2016-02-06T12:20:50.543" LastActivityDate="2016-02-06T12:20:50.543" Title="Pin Mapping of nRF2401L01+ using Adafruit's nRF24L01+ library" Tags="|communication|nrf24l01+|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20374" PostTypeId="2" ParentId="14567" CreationDate="2016-02-06T12:04:12.153" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Since Arduino Due board is based on the Atmel SAM3X8E ARM Cortex-M3 CPU and QNX® Neutrino® RTOS supports that processor, I was wondering if it is possible make them work together.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does QNX really support ARM Cortex-M3? I believe that is not possible as the processor does not have the necessary hardware support. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IkCPG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IkCPG.png&quot; alt=&quot;QNX Neutrino RTOS Architectuer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see the &lt;a href=&quot;http://community.qnx.com/sf/wiki/do/viewPage/projects.bsp/wiki/BSPAndDrivers&quot; rel=&quot;nofollow noreferrer&quot;&gt;BSP&lt;/a&gt; list. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-06T12:04:12.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20375" PostTypeId="2" ParentId="20371" CreationDate="2016-02-06T12:14:04.863" Score="2" Body="&lt;pre&gt;&lt;code&gt;DR1 is MISO&#xA;DAT is MOSI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though I'd advice using the &lt;a href=&quot;https://github.com/tmrh20/RF24/&quot; rel=&quot;nofollow&quot;&gt;RF24 library&lt;/a&gt;, as it's a lot more recent than the one from 2009 you linked to.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-02-06T12:14:04.863" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20376" PostTypeId="2" ParentId="20318" CreationDate="2016-02-06T15:35:39.953" Score="1" Body="&lt;p&gt;If your signal of interest is of short-enough duration, you might get by by collecting the data into memory, then dumping it at whatever speed you can. If you're using an Uno or other AtMega328 based Arduino, the RAM size, and therefore, your buffer, will be quite limited. Storing the first value as int and subsequent values as one-byte differences can help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An on-board memory device, like an &lt;a href=&quot;https://www.adafruit.com/index.php?q=FRAM&amp;amp;main_page=adasearch&quot; rel=&quot;nofollow&quot;&gt;FRAM&lt;/a&gt;, could buffer 8K or 32K bytes (or half as many ints).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or the same differences technique can be used to send one-byte binary differences and improve your sample transmission rate. It's easy to get out of sync, though. This won't be too reliable for continuous or long data streams.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, you're just baud-bound. How fast can you drive the serial output and the receiver still be able to keep up? You're pushing the edges of what the device can do. It's an interesting problem and possibly fun to solve, but I'm reminded of the old adage about alligators and needing to drain the swamp! :)&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-02-06T15:35:39.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20378" PostTypeId="2" ParentId="13016" CreationDate="2016-02-06T16:14:05.427" Score="1" Body="&lt;p&gt;Try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern  PGM_P * const NApowerCodes[] PROGMEM;&#xA;extern  PGM_P * const EUpowerCodes[] PROGMEM;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The definition of PGM_P is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PGM_P const char *&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which gives &quot;const const&quot; and gives &quot;error: duplicate 'const'&quot;. But it is the variable that should be const. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-06T16:14:05.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20379" PostTypeId="1" AcceptedAnswerId="20381" CreationDate="2016-02-06T19:21:44.503" Score="0" ViewCount="3880" Body="&lt;pre&gt;&lt;code&gt;const unsigned long C1 = 30 * 1000;&#xA;const unsigned long C2 = (300 * 1000)/C1; // must be = 10&#xA;&#xA;void setup() {&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;\n-------&quot;);&#xA;  Serial.print(&quot;C1 = &quot;); Serial.println(C1);&#xA;  Serial.print(&quot;C2 = &quot;); Serial.println(C2);&#xA;&#xA;  unsigned long V1 = (300 * 1000)/C1;   // must be = 10&#xA;  Serial.print(&quot;V1 = &quot;); Serial.println(V1);&#xA;&#xA;  long V2 = (300 * 1000)/30000; // must be = 10&#xA;  Serial.print(&quot;V2 = &quot;); Serial.println(V2);&#xA;&#xA;  int V3 = (300 * 1000)/30000; // must be = 10&#xA;  Serial.print(&quot;V3 = &quot;); Serial.println(V3);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO printed in monitor console:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C1 = 30000   (ok)&#xA;C2 = 143164  (must be = 10)&#xA;V1 = 143164  (must be = 10)&#xA;V2 = 0       (must be = 10)&#xA;V3 = 0       (must be = 10)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is wrong?&lt;/p&gt;&#xA;" OwnerUserId="17092" LastActivityDate="2018-10-05T12:23:37.557" Title="Multiplication, division. What is wrong?" Tags="|programming|data-type|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20381" PostTypeId="2" ParentId="20379" CreationDate="2016-02-06T20:08:00.450" Score="5" Body="&lt;pre&gt;&lt;code&gt;300&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long V2 = (300 * 1000)/30000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;really does is take the &lt;em&gt;integers&lt;/em&gt; 300 and 1000 multiply them. This calculation overflows, and equals -27680. Dividing that by 30000 yields 0. What you added in your comment isn't a hack, it's the proper solution. By including the suffix L or UL you tell the compiler that you want longs, not ints.&lt;/p&gt;&#xA;" OwnerUserId="14035" LastActivityDate="2016-02-06T20:08:00.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20382" PostTypeId="2" ParentId="20379" CreationDate="2016-02-06T20:12:51.550" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is wrong?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are assuming that the expression is long int but it is actually int. The literals are int. You need to convince the compiler that the expression is actually long int. That can be done by cast:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;((long) 30000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or literal long integer syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;30000L&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The AVR GCC compiler uses int defined as 16-bit. Expression and literals are implict 16-bit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More on the representation of C/C++ data types, expressions, and calling conventions can be found &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-06T20:12:51.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20383" PostTypeId="1" AcceptedAnswerId="20388" CreationDate="2016-02-06T20:21:44.480" Score="1" ViewCount="1115" Body="&lt;p&gt;Hello I recently purchased some atmel AVR chips. You can programme them in Arduino. I was wondering if it is possible to programme them in any other language except for C or Arduino. Also can you use just binary instead of C?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-02-06T20:59:30.930" Title="Atmel AVR languages" Tags="|atmega328|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20384" PostTypeId="1" AcceptedAnswerId="20395" CreationDate="2016-02-06T16:53:07.023" Score="1" ViewCount="18006" Body="&lt;p&gt;I have three stepper motors connected to the drv8825 drivers to an arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the example code below (from &lt;a href=&quot;http://www.geeetech.com/wiki/index.php/DRV8825_Motor_Driver_Board&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;), which works fine for moving multiple stepper motors at the same time BUT they all move for the same number of steps and in the same direction. I would like to tweak the code so that all of them move at the same time but each one for a different number of steps and in different directions. The motor with the least steps would probably have to wait for the motor with the most steps to finish its movement before going again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int dirPin = 8;&#xA;int stepperPin = 7;&#xA;int bdirPin = 6;&#xA;int bstepperPin = 5;&#xA;&#xA;void setup() {&#xA; pinMode(dirPin, OUTPUT);&#xA; pinMode(stepperPin, OUTPUT);&#xA; pinMode(bdirPin, OUTPUT);&#xA; pinMode(bstepperPin, OUTPUT);&#xA;}&#xA; void step(boolean dir,int steps){&#xA; digitalWrite(dirPin,dir);&#xA; digitalWrite(bdirPin,dir);&#xA; delay(50);&#xA; for(int i=0;i&amp;lt;steps;i++){&#xA; digitalWrite(stepperPin, HIGH);&#xA; digitalWrite(bstepperPin, HIGH);&#xA; delayMicroseconds(800);&#xA; digitalWrite(stepperPin, LOW);&#xA; digitalWrite(bstepperPin, LOW);&#xA; delayMicroseconds(800);&#xA; }&#xA;}&#xA;void loop(){&#xA; step(true,1600);&#xA; delay(500);&#xA; step(false,1600*5);&#xA; delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for your help!&lt;/p&gt;&#xA;" OwnerUserId="17101" OwnerDisplayName="the_plds" LastEditorUserId="3917" LastEditDate="2016-02-07T00:05:26.317" LastActivityDate="2017-02-26T06:57:24.977" Title="Controlling 3 stepper motors simultaneously" Tags="|arduino-uno|programming|motor|stepper|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20385" PostTypeId="2" ParentId="20384" CreationDate="2016-02-06T19:30:10.397" Score="2" Body="&lt;p&gt;You need a struct for each stepper with a timestamp, a position and rate of change and a loop that updates the postion based on rate which is the change in position over some time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct stepper {&#xA;  unsigned long timestamp;&#xA;  int position;&#xA;  int rate;&#xA;};&#xA;&#xA;// init steppers array&#xA;&#xA;while (keepGoing()) {&#xA;  unsigned long now = millis();&#xA;  int si;&#xA;&#xA;  delay(10);&#xA;&#xA;  for (si = 0; si &amp;lt; 3; si++) {&#xA;    struct stepper *stepper = &amp;amp;steppers[si];&#xA;&#xA;    if (steppers[si].timestamp &amp;gt; now) {&#xA;       steppers[si].position += steppers[si].rate;&#xA;       steppers[si].timestamp = now + 100;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a back-of-a-napkin sketch of course. It is only supposed to illustrate how you can update any number of things concurrently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The important thing is that you only call delay once. And presumably it would be only a very short delay compared to the unit of time for the rate. In the above example it would adjust the stepper position every 100ms. You would need to experiment with the timing to find a good behavior given the speed of the stepper, speed of the code and maximum permitted rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beware that there is a lot to think about beyond this. For example, you should initialize the timstamps with different timestamps so that the motors are not all running at the same instant and thus &lt;em&gt;try&lt;/em&gt; to minimize the total power consumed by the motors at any particular time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I have never played around with stepper motors but this type of loop is a common programming idiom for handling things concurrently.&lt;/p&gt;&#xA;" OwnerUserId="20626" OwnerDisplayName="squarewav" LastActivityDate="2016-02-06T19:30:10.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20386" PostTypeId="2" ParentId="20383" CreationDate="2016-02-06T20:41:49.207" Score="1" Body="&lt;p&gt;You can program them in C or C++ through the avr-gcc compiler. Arduino uses C++ (&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/platform.txt#L30&quot; rel=&quot;nofollow&quot;&gt;-std=gnu++11&lt;/a&gt;) and automatically includes a few libraries, as well as generating forward declarations for anything in the top level .ino file automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write AVR assembly and translate it to machine code using avr-as (a portion of avr-gcc) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing stopping you from just writing whatever bytes you want to program memory if you want to write machine code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look through the &lt;a href=&quot;http://www.atmel.com/images/atmel-0856-avr-instruction-set-manual.pdf&quot; rel=&quot;nofollow&quot;&gt;avr instruction set&lt;/a&gt; if you are interested in those last two options.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-02-06T20:41:49.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20387" PostTypeId="2" ParentId="20318" CreationDate="2016-02-06T20:53:25.250" Score="1" Body="&lt;p&gt;Some benchmarking of Serial.print() and comparing to clib functions (itoa/ltoa) might give some insight. First, printing int and long int with DEC base using Arduino core Print functions (Arduino IDE 1.6.7, Arduino Mega2560).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(12345, DEC): 240 us&#xA;Serial.print(12345678L, DEC): 388 us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second, use HEX base.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(0x1234, HEX): 204 us&#xA;Serial.print(0x12345678L, HEX): 384 us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Third, use the AVR clib functions to convert number to a string and then print the string. 10 and 16 base.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(itoa(12345, buf, 10)): 104 us&#xA;Serial.print(ltoa(12345678L, buf, 10)): 240 us&#xA;&#xA;Serial.print(itoa(0x1234, buf, 16)): 80 us&#xA;Serial.print(ltoa(0x12345678L, buf, 16)): 240 us&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Below is the test sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  uint32_t start, stop, us;&#xA;  char buf[16];&#xA;  Serial.begin(9600);&#xA;&#xA;  start = micros();&#xA;  Serial.print(12345, DEC);&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(12345, DEC): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(12345678L, DEC);&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(12345678L, DEC): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(0x1234, HEX);&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(0x1234, HEX): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(0x12345678L, HEX);&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(0x12345678L, HEX): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(itoa(12345, buf, 10));&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(itoa(12345, buf, 10)): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(ltoa(12345678L, buf, 10));&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(ltoa(12345678L, buf, 10)): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(itoa(0x1234, buf, 16));&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(itoa(0x1234, buf, 16)): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;  start = micros();&#xA;  Serial.print(ltoa(0x12345678L, buf, 16));&#xA;  stop = micros();&#xA;  us = stop - start;&#xA;  Serial.println();&#xA;  Serial.print(F(&quot;Serial.print(ltoa(0x12345678L, buf, 16)): &quot;));&#xA;  Serial.print(us);&#xA;  Serial.println(F(&quot; us&quot;));&#xA;  Serial.flush();&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The clib itoa/ltoa are regarded to be relative slow and there are proposals to improve performance. Please see, for instance, this &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=627899&quot; rel=&quot;nofollow&quot;&gt;bug report&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-06T20:53:25.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20388" PostTypeId="2" ParentId="20383" CreationDate="2016-02-06T20:59:30.930" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I was wondering if it is possible to programme them in any other language except for C or Arduino. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have seen this question before. Here is a great answer with a lot of links:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/6590161/programming-languages-targeting-arduino-avr&quot;&gt;https://stackoverflow.com/questions/6590161/programming-languages-targeting-arduino-avr&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also a number of libraries/platforms/frameworks as the Arduino core to help you up from &quot;bare metal&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-02-06T20:59:30.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20389" PostTypeId="1" CreationDate="2016-02-06T12:59:45.170" Score="0" ViewCount="131" Body="&lt;p&gt;I'd like catch up the Arduino concepts (programming &amp;amp; IDE). There are excellent online tutorials available for Arduino but all of them which I saw are made for those who didn't have embedded/electronics background. Going through them is heavily time consuming as I'm already familiar with the embedded programming other than Arduino or Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does any one know any quick reference materials for Arduino which excludes electronic/embedded basics which is meant for experienced embedded programmer? That could be a big time saver for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!  &lt;/p&gt;&#xA;" OwnerUserId="17099" OwnerDisplayName="user3214692" LastEditorUserId="26916" LastEditDate="2017-09-08T21:52:23.140" LastActivityDate="2017-09-08T21:52:23.140" Title="Quick start on Arduino for experienced embedded programmer?" Tags="|documentation|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="20390" PostTypeId="2" ParentId="20389" CreationDate="2016-02-06T15:20:19.757" Score="5" Body="&lt;p&gt;As far as I know, there is no tutorials about using Arduino's for, e.g. &quot;multi-tasking, real time response&quot;. That is not the focus of the Arduino community.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino UNO development board is built around Atmel's &lt;a href=&quot;http://www.atmel.com/devices/atmega328.aspx&quot; rel=&quot;noreferrer&quot;&gt;ATmega328&lt;/a&gt;. The &lt;a href=&quot;http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Summary.pdf&quot; rel=&quot;noreferrer&quot;&gt;Summary datasheet&lt;/a&gt; gives an overview of its hardware capabilities on the first page. If you are familiar with MCU development, that should give you a feel for its hardware capabilities. The complete &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;noreferrer&quot;&gt;ATmega8/168/328 datasheet&lt;/a&gt; is over 600 pages, and describes every feature, with all registers in detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE uses gcc under the covers. So you likely already know how to use that. When you download and install the Arduino IDE, gcc and gnu binutils for AVR will be installed too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE has all of the Atmel header files, so much of the code in the datasheet should compile, link and upload. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IDE is really designed for beginners. It is to easy to use, but has very few features beyond basic editing, compiling and loading. It does support a serial-monitor to see text printed by the uploaded application, but it doesn't support a debugger like GDB out-of-the-packet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it doesn't prevent you writing C++ code and header files, and it will build the whole collection of files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the IDE lets you create and edit C++ directly, you can install the IDE on any of the three main platforms, and get started very quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will probably want to visit &lt;a href=&quot;http://www.avrfreaks.net/&quot; rel=&quot;noreferrer&quot;&gt;AVRFreaks&lt;/a&gt; who tend to focus at a lower level than Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;noreferrer&quot;&gt;AVR LibC library&lt;/a&gt; which points you at the documentation for the AVR upload tool, avrdude, and debugger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summary: Install Arduino IDE, do a couple of quick projects to get a feel for the system. Then start writing C++ as normal. Install &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;noreferrer&quot;&gt;AVR LibC library&lt;/a&gt; for a more traditional library, and visit &lt;a href=&quot;http://www.avrfreaks.net/&quot; rel=&quot;noreferrer&quot;&gt;AVRFreaks&lt;/a&gt; forums for more technical help and information.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastActivityDate="2016-02-06T15:20:19.757" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20391" PostTypeId="1" AcceptedAnswerId="20402" CreationDate="2016-02-07T07:38:33.833" Score="0" ViewCount="7472" Body="&lt;p&gt;Recently I bought a GPS module (&lt;a href=&quot;http://www.ebay.de/itm/311397889516&quot; rel=&quot;nofollow noreferrer&quot;&gt;ublox neo-6M-0-001&lt;/a&gt;) for my Arduino Mega 2560. I connected Vcc and Gnd (LED at GPS module glows blue and sometimes blinking).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPS module RX port is connected to the Arduino's TX3, Port 14.&#xA;GPS module TX port is connected to the Arduino's RX3, Port 15.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a first step I just want to print the serial data received from the GPS module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SoftwareSerial.h&quot;&#xA;&#xA;SoftwareSerial mySerial(15, 14); // RX, TX&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;uBlox Neo 6M Test&quot;);&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;   if (mySerial.available())&#xA;     Serial.write(mySerial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Saldy, there is no data received from the GPS module. According to &lt;a href=&quot;http://arduino-ua.com/docs/NEO-6_DataSheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the datasheet&lt;/a&gt; the baud rate 9600 seems to be correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to configure the GPS module somehow before it delivers data? Do I need to buy an external antenna?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="11839" LastEditorUserId="4628" LastEditDate="2017-04-02T15:01:34.227" LastActivityDate="2017-05-14T06:03:46.170" Title="Ublox GPS with Arduino Mega 2560 not working" Tags="|arduino-mega|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20392" PostTypeId="1" AcceptedAnswerId="20430" CreationDate="2016-02-07T08:38:00.003" Score="0" ViewCount="832" Body="&lt;p&gt;There is very cool &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/modules.html&quot; rel=&quot;nofollow&quot;&gt;avr-libc library&lt;/a&gt; that provides direct access for all functions of AVR microcontrollers. I'm writing a project for &lt;strong&gt;Arduino Due&lt;/strong&gt; and I want to use timers and ISRs directly. Is there a library like &lt;code&gt;avr-libc&lt;/code&gt; for ARM Cortex M3?&lt;/p&gt;&#xA;" OwnerUserId="16074" LastEditorUserId="6936" LastEditDate="2016-02-10T13:40:42.807" LastActivityDate="2016-02-10T13:40:42.807" Title="Arduino &amp; ARM - Replacement for avr-libc?" Tags="|programming|c++|arduino-due|c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20393" PostTypeId="2" ParentId="9998" CreationDate="2016-02-07T08:46:53.923" Score="2" Body="&lt;p&gt;I have a post &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt; - that describes various tests you can carry out to isolate where the problem is.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-07T08:46:53.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20394" PostTypeId="2" ParentId="20392" CreationDate="2016-02-07T09:30:36.043" Score="2" Body="&lt;p&gt;I think &lt;code&gt;newlib&lt;/code&gt; is the one you want.&#xA;&lt;a href=&quot;https://balau82.wordpress.com/2010/12/16/using-newlib-in-arm-bare-metal-programs/&quot; rel=&quot;nofollow&quot;&gt;howto&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11568" LastActivityDate="2016-02-07T09:30:36.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20395" PostTypeId="2" ParentId="20384" CreationDate="2016-02-07T09:56:49.097" Score="0" Body="&lt;p&gt;You would first have to provide all the necessary information to your&#xA;&lt;code&gt;step()&lt;/code&gt; function: direction and number of steps for &lt;em&gt;each&lt;/em&gt; motor. Then&#xA;you just have to stop the loop at different points for each motor. You&#xA;do this by running the loop up to the number of steps of whichever motor&#xA;needs to run for longer, and making the steps of each motor conditional&#xA;on the loop index, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void step(boolean dir0, int steps0,&#xA;          boolean dir1, int steps1,&#xA;          boolean dir2, int steps2) {&#xA;    digitalWrite(dir0Pin, dir0);&#xA;    digitalWrite(dir1Pin, dir1);&#xA;    digitalWrite(dir2Pin, dir2);&#xA;    delay(50);&#xA;    int max_steps = max(max(steps0, steps1), steps2);&#xA;    for (int i = 0; i &amp;lt; max_steps; i++) {&#xA;        if (i &amp;lt; steps0) digitalWrite(stepper0Pin, HIGH);&#xA;        if (i &amp;lt; steps1) digitalWrite(stepper1Pin, HIGH);&#xA;        if (i &amp;lt; steps2) digitalWrite(stepper2Pin, HIGH);&#xA;        delayMicroseconds(800);&#xA;        if (i &amp;lt; steps0) digitalWrite(stepper0Pin, LOW);&#xA;        if (i &amp;lt; steps1) digitalWrite(stepper1Pin, LOW);&#xA;        if (i &amp;lt; steps2) digitalWrite(stepper2Pin, LOW);&#xA;        delayMicroseconds(800);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be more elegant to put the data for all the motors in an array,&#xA;and you would probably want to do so if you have more than three motors.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-07T09:56:49.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20396" PostTypeId="1" AcceptedAnswerId="20397" CreationDate="2016-02-07T10:22:34.140" Score="0" ViewCount="18008" Body="&lt;p&gt;I have three sensors latched on to three different Arduino devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The respective Arduino devices are connected on to an Arduino Mega on Serial1, Serial2 and Serial3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data from each device component (i.e., an Arduino with an accompanying sensor) were sent in data packets with different starter byte headers ('$' , '/' &amp;amp; '#' ) accompanying the buffered data from each individual device component onto the Mega on the Tx/Rx lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question here is, how can I simultaneously read out all the data from the different serial ports on the Arduino mega sketch?&lt;/p&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="6936" LastEditDate="2016-02-14T11:32:32.797" LastActivityDate="2016-02-14T11:32:32.797" Title="Simultaneously reading data from multiple serial ports" Tags="|serial|sensors|arduino-due|datalogging|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20397" PostTypeId="2" ParentId="20396" CreationDate="2016-02-07T11:32:55.827" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question here is how can I simultaneously read out all the data from the different serial ports on the arduino mega sketch.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As you are using several serial ports data can already be received simultaneously. Each serial software class (Serial1, Serial2, Serial3) has an internal buffer where data is stored until it is read. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only need to read the data before the internal buffers are filled and there is a risk for over-flow. Check that data is available and read as usual per serial port. Avoid any blocking calls to avoid buffer over-flow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-07T11:32:55.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20398" PostTypeId="2" ParentId="20389" CreationDate="2016-02-07T12:10:20.393" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;But I suppose to debug an existing Arduino project (which my friend gave to me because the developer left from his small electronic company) developed for GSM based remote motor control product. They haven't used Arduino board but used Arduino IDE/library for coding. Flashed the hex output from Arduino on their custom board with Atmel processor. So I need to go through the existing Arduino code and help them to solve the issue that they are facing.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is maybe one of the worst type of projects to get involved in. Code that needs debugging on a platform that you have not used before. Code that you might not know the status of and where the requirements are loose. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would recommend starting by getting all the details on the table. Understand the intended software architecture, estimate memory foot-print, and processing, etc - if the product is feasible. There might be a reason for the developer ditching this project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVR is small scale embedded and that implies a very different implementation strategy. There is no operating system and much of the code is bare metal. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino core is a platform (library) that abstracts a small set of basic hardware functions. It was originally intended for Media/Design Students. &#xA;To help reduce the threshold when getting started the IDE has build support, i.e. pre-processing, such as an implicit add of the Arduino header file (Arduino.h) and generation of forward declarations for functions in a sketch. The IDE does not use make/makefiles. Source code is C/C++ (AVR GCC) and if necessary AVR assembly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The quick reference for the Arduino core function can be found &lt;a href=&quot;https://www.arduino.cc/en/Reference/HomePage&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. There is also a list of &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;libraries&lt;/a&gt;. Some are packaged with the Arduino IDE/core while others need to be installed. There is a library manager in the IDE to download and install some of the libraries. New libraries are added more or less daily right now. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the code you will have to read more about the libraries used and/or internal AVR hardware (registers, functions, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-07T12:10:20.393" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20400" PostTypeId="1" AcceptedAnswerId="20405" CreationDate="2016-02-07T12:16:16.313" Score="4" ViewCount="345" Body="&lt;p&gt;I am reading &lt;em&gt;Arduino for Dummies&lt;/em&gt;, and I am blocked at the pitch follower exercise. It consists in making a piezo vary with a light sensor. I can't see the point of the resistor (and why 4.7?) in this sketch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ja5ht.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ja5ht.jpg&quot; alt=&quot;http://media.wiley.com/Lux/98/381398.image0.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help for a dummy is appreciated! :-)&lt;/p&gt;&#xA;" OwnerUserId="17100" LastEditorUserId="10907" LastEditDate="2016-02-08T06:23:02.210" LastActivityDate="2016-02-08T06:23:02.210" Title="Why the 4.7 K Ω resistor in this pitch follower sketch?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20401" PostTypeId="2" ParentId="15910" CreationDate="2016-02-07T12:16:20.313" Score="0" Body="&lt;p&gt;EEPROM can store one byte at a location. To store value of int, it requires two consecutive location. For double, it requires four memory location. I have written code to store and read, int &amp;amp; double to and from built-in EEPROM. Modify as per your need.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  StackExchange Question: &quot;How to Store 2 analogRead values and read using EEPROM for Arduino uno?&quot;&#xA;  Question Id: 15910 (http://arduino.stackexchange.com/questions/15910/how-to-store-2-analogread-values-and-read-using-eeprom-for-arduino-uno)&#xA;  Author: Anurag S. Vasanwala (AnuragVasanwala@gmail.com)&#xA;&#xA;  Tested on Arduino Version 1.6.7&#xA;&#xA;  Description:  This sketch helps to store and read, Integer &amp;amp; Double to and from built-in EEPROM.&#xA;  Objectives:&#xA;    + Write Integer @ Specified Address (Fn: EEPROM_Write_Int)&#xA;      + Conversion from Integer to Byte Array&#xA;      + Store Bytes&#xA;    + Read Integer from Specified Address (Fn: EEPROM_Read_Int)&#xA;      + Read Bytes&#xA;      + Conversion from Byte Array to Integer&#xA;    + Write Double @ Specified Address (Fn: EEPROM_Write_Double)&#xA;      + Conversion from Double to Byte Array&#xA;      + Store Bytes&#xA;    + Read Double from Specified Address (Fn: EEPROM_Read_Double)&#xA;      + Read Bytes&#xA;      + Conversion from Byte Array to Double&#xA; */&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;// MACRO : Combines FROM_BYTES into TO_OBJECT of datatype &quot;DATATYPE&quot;&#xA;#define CombineBytes(FROM_BYTES, DATATYPE, TO_OBJECT) \&#xA;  TO_OBJECT = *((DATATYPE *)FROM_BYTES);&#xA;&#xA;// MACRO : Splits FROM_DATA of DATATYPE into equivalent byte array TO_BYTES&#xA;#define GetBytes(FROM_DATA, DATATYPE, TO_BYTES) \&#xA;  *((DATATYPE *)TO_BYTES) = FROM_DATA;&#xA;&#xA;// Writes Integer's equivalent bytes to Address and Address + 1&#xA;void EEPROM_Write_Int(unsigned int Address, int Data)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(int);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  // Call macro to store byte array into Temp_Buffer from Data&#xA;  GetBytes(Data, int, Temp_Buffer);&#xA;&#xA;  // Write number of bytes to memory location specified in Address and so on&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    EEPROM.write(Address + Index, Temp_Buffer[Index]);&#xA;  }&#xA;}&#xA;&#xA;// Reads two bytes from Address and Address + 1 and returns equivalent int&#xA;int EEPROM_Read_Int(unsigned int Address)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(int);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  int Result;&#xA;&#xA;  // Read number of bytes from memory location&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    Temp_Buffer[Index] = EEPROM.read(Address + Index);&#xA;  }&#xA;&#xA;  // Call macro to combine bytes into equivalent to int&#xA;  CombineBytes(Temp_Buffer, int, Result);&#xA;&#xA;  return Result;&#xA;}&#xA;&#xA;// Writes Double's equivalent bytes to Address, Address + 1, Address + 2 and Address + 3&#xA;void EEPROM_Write_Double(unsigned int Address, double Data)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(double);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  // Call macro to store byte array into Temp_Buffer from Data&#xA;  GetBytes(Data, double, Temp_Buffer);&#xA;&#xA;  // Write number of bytes to memory location specified in Address and so on&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    EEPROM.write(Address + Index, Temp_Buffer[Index]);&#xA;  }&#xA;}&#xA;&#xA;// Reads four bytes from Address, Address + 1, Address + 2 and Address + 3 and returns equivalent double&#xA;double EEPROM_Read_Double(unsigned int Address)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(double);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  double Result;&#xA;&#xA;  // Read number of bytes from memory location&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    Temp_Buffer[Index] = EEPROM.read(Address + Index);&#xA;  }&#xA;&#xA;  // Call macro to combine bytes into equivalent to double&#xA;  CombineBytes(Temp_Buffer, double, Result);&#xA;&#xA;  return Result;&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialize Serial @ 9600 baud&#xA;  Serial.begin(9600);&#xA;&#xA;  // Print size of datatype just for reference&#xA;  /* Serial.print(&quot;Size of byte = &quot;);&#xA;  Serial.println(sizeof(byte));&#xA;  Serial.print(&quot;Size of int = &quot;);&#xA;  Serial.println(sizeof(int));&#xA;  Serial.print(&quot;Size of float = &quot;);&#xA;  Serial.println(sizeof(float));&#xA;  Serial.print(&quot;Size of double = &quot;);&#xA;  Serial.println(sizeof(double)); */&#xA;&#xA;  int myInt1 = -290;&#xA;  int myInt2;&#xA;  double myDbl1 = 23.41;&#xA;  double myDbl2;&#xA;&#xA;  // Write myInt1 @ 100 memory location; It requires 2 consequtive memory location to store integer&#xA;  EEPROM_Write_Int(100, myInt1);&#xA;&#xA;  // Read integer located @ memory location 100 and assign it to myInt2&#xA;  myInt2 = EEPROM_Read_Int(100);&#xA;  Serial.println(myInt2);&#xA;&#xA;  // Write myInt1 @ 200 memory location; it requires 4 consequtive memory location to store double&#xA;  EEPROM_Write_Double(200, myDbl1);&#xA;&#xA;  // Read double located @ memory location 200 and assign it to myDbl2&#xA;  myDbl2 = EEPROM_Read_Double(200);  &#xA;  Serial.println(myDbl2);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This code is successfully tested on Arduino Version &quot;1.6.7&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15547" LastEditorUserId="15547" LastEditDate="2016-02-07T12:23:22.990" LastActivityDate="2016-02-07T12:23:22.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20402" PostTypeId="2" ParentId="20391" CreationDate="2016-02-07T12:19:28.083" Score="3" Body="&lt;p&gt;The Arduino Mega 2560 has three additional hardware serial ports. Why not use one of them instead? &lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;Serial1&lt;/a&gt; on pins 19 (RX) and 18 (TX).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;uBlox Neo 6M Test&quot;);&#xA;  Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  if (Serial1.available())&#xA;     Serial.write(Serial1.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-07T12:19:28.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20403" PostTypeId="2" ParentId="9349" CreationDate="2016-02-07T12:29:41.023" Score="2" Body="&lt;p&gt;EEPROM can store one byte at a location. To store Integer variable, it requires two consecutive location. For Double, it requires four consecutive memory location. I have written function to store and read, int &amp;amp; double to and from built-in EEPROM. As per your question, you can modify it as per your need.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Actually this answer was copied from &lt;a href=&quot;https://arduino.stackexchange.com/questions/15910/how-to-store-2-analogread-values-and-read-using-eeprom-for-arduino-uno/20401#20401&quot;&gt;another thread&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  StackExchange Question: &quot;How to Store 2 analogRead values and read using EEPROM for Arduino uno?&quot;&#xA;  Question Id: 15910 (https://arduino.stackexchange.com/questions/15910/how-to-store-2-analogread-values-and-read-using-eeprom-for-arduino-uno)&#xA;  Author: Anurag S. Vasanwala (AnuragVasanwala@gmail.com)&#xA;&#xA;  Tested on Arduino Version 1.6.7&#xA;&#xA;  Description:  This sketch helps to store and read, Integer &amp;amp; Double to and from built-in EEPROM.&#xA;  Objectives:&#xA;    + Write Integer @ Specified Address (Fn: EEPROM_Write_Int)&#xA;      + Conversion from Integer to Byte Array&#xA;      + Store Bytes&#xA;    + Read Integer from Specified Address (Fn: EEPROM_Read_Int)&#xA;      + Read Bytes&#xA;      + Conversion from Byte Array to Integer&#xA;    + Write Double @ Specified Address (Fn: EEPROM_Write_Double)&#xA;      + Conversion from Double to Byte Array&#xA;      + Store Bytes&#xA;    + Read Double from Specified Address (Fn: EEPROM_Read_Double)&#xA;      + Read Bytes&#xA;      + Conversion from Byte Array to Double&#xA; */&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;// MACRO : Combines FROM_BYTES into TO_OBJECT of datatype &quot;DATATYPE&quot;&#xA;#define CombineBytes(FROM_BYTES, DATATYPE, TO_OBJECT) \&#xA;  TO_OBJECT = *((DATATYPE *)FROM_BYTES);&#xA;&#xA;// MACRO : Splits FROM_DATA of DATATYPE into equivalent byte array TO_BYTES&#xA;#define GetBytes(FROM_DATA, DATATYPE, TO_BYTES) \&#xA;  *((DATATYPE *)TO_BYTES) = FROM_DATA;&#xA;&#xA;// Writes Integer's equivalent bytes to Address and Address + 1&#xA;void EEPROM_Write_Int(unsigned int Address, int Data)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(int);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  // Call macro to store byte array into Temp_Buffer from Data&#xA;  GetBytes(Data, int, Temp_Buffer);&#xA;&#xA;  // Write number of bytes to memory location specified in Address and so on&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    EEPROM.write(Address + Index, Temp_Buffer[Index]);&#xA;  }&#xA;}&#xA;&#xA;// Reads two bytes from Address and Address + 1 and returns equivalent int&#xA;int EEPROM_Read_Int(unsigned int Address)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(int);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  int Result;&#xA;&#xA;  // Read number of bytes from memory location&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    Temp_Buffer[Index] = EEPROM.read(Address + Index);&#xA;  }&#xA;&#xA;  // Call macro to combine bytes into equivalent to int&#xA;  CombineBytes(Temp_Buffer, int, Result);&#xA;&#xA;  return Result;&#xA;}&#xA;&#xA;// Writes Double's equivalent bytes to Address, Address + 1, Address + 2 and Address + 3&#xA;void EEPROM_Write_Double(unsigned int Address, double Data)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(double);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  // Call macro to store byte array into Temp_Buffer from Data&#xA;  GetBytes(Data, double, Temp_Buffer);&#xA;&#xA;  // Write number of bytes to memory location specified in Address and so on&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    EEPROM.write(Address + Index, Temp_Buffer[Index]);&#xA;  }&#xA;}&#xA;&#xA;// Reads four bytes from Address, Address + 1, Address + 2 and Address + 3 and returns equivalent double&#xA;double EEPROM_Read_Double(unsigned int Address)&#xA;{&#xA;  // Get the size of datatype to write number of bytes&#xA;  const byte SizeOf_DataType = sizeof(double);&#xA;&#xA;  // Create tem buffer to get Bytes of Datatype&#xA;  byte Temp_Buffer[SizeOf_DataType];&#xA;&#xA;  double Result;&#xA;&#xA;  // Read number of bytes from memory location&#xA;  for(byte Index = 0; Index &amp;lt; SizeOf_DataType; Index++)&#xA;  {&#xA;    Temp_Buffer[Index] = EEPROM.read(Address + Index);&#xA;  }&#xA;&#xA;  // Call macro to combine bytes into equivalent to double&#xA;  CombineBytes(Temp_Buffer, double, Result);&#xA;&#xA;  return Result;&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  // Initialize Serial @ 9600 baud&#xA;  Serial.begin(9600);&#xA;&#xA;  // Print size of datatype just for reference&#xA;  /* Serial.print(&quot;Size of byte = &quot;);&#xA;  Serial.println(sizeof(byte));&#xA;  Serial.print(&quot;Size of int = &quot;);&#xA;  Serial.println(sizeof(int));&#xA;  Serial.print(&quot;Size of float = &quot;);&#xA;  Serial.println(sizeof(float));&#xA;  Serial.print(&quot;Size of double = &quot;);&#xA;  Serial.println(sizeof(double)); */&#xA;&#xA;  int myInt1 = -290;&#xA;  int myInt2;&#xA;  double myDbl1 = 23.41;&#xA;  double myDbl2;&#xA;&#xA;  // Write myInt1 @ 100 memory location; It requires 2 consequtive memory location to store integer&#xA;  EEPROM_Write_Int(100, myInt1);&#xA;&#xA;  // Read integer located @ memory location 100 and assign it to myInt2&#xA;  myInt2 = EEPROM_Read_Int(100);&#xA;  Serial.println(myInt2);&#xA;&#xA;  // Write myInt1 @ 200 memory location; it requires 4 consequtive memory location to store double&#xA;  EEPROM_Write_Double(200, myDbl1);&#xA;&#xA;  // Read double located @ memory location 200 and assign it to myDbl2&#xA;  myDbl2 = EEPROM_Read_Double(200);  &#xA;  Serial.println(myDbl2);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This code is successfully tested on Arduino Version &quot;1.6.7&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="15547" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-02-07T12:29:41.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20404" PostTypeId="2" ParentId="20400" CreationDate="2016-02-07T12:39:04.897" Score="1" Body="&lt;p&gt;&lt;em&gt;Arduino measures Voltages on pins A0 to A5; but the LDR is a variable resistor (varying with Light). So we need to convert the varying resistance to a voltage that the Arduino can measure.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;http://www.instructables.com/id/How-to-Use-a-Light-Dependent-Resistor-LDR/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-07T12:39:04.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20405" PostTypeId="2" ParentId="20400" CreationDate="2016-02-07T12:39:18.580" Score="7" Body="&lt;p&gt;The resistor couples with the LDR to form a &lt;em&gt;voltage divider&lt;/em&gt;. The voltage at the point where the resistor and LDR join will vary depending on the ratio of the two resistances - the resistance of the LDR and the 4700 ohm resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The value of 4700 is chosen to allow a reasonable range of voltages when in a ratio with the LDR, and the best value depends on the resistance range of the LDR.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-07T12:39:18.580" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20410" PostTypeId="1" CreationDate="2016-02-07T14:38:35.280" Score="0" ViewCount="297" Body="&lt;p&gt;I am thinking about buying some Teensy micro-controllers, but I want to know if the &lt;a href=&quot;https://www.adafruit.com/?q=teensy&amp;amp;&quot; rel=&quot;nofollow&quot;&gt;teensy&lt;/a&gt; are compatible with the &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;arduino keyboard library.&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="17096" LastEditDate="2016-02-07T21:29:01.183" LastActivityDate="2016-02-07T21:29:01.183" Title="Is Teensy compatible with the Arduino keyboard library?" Tags="|library|teensy|keyboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20411" PostTypeId="2" ParentId="18734" CreationDate="2016-02-07T16:29:34.083" Score="3" Body="&lt;p&gt;I'm unable to provide a complete answer yet but my research so far into a similar quest to use a similar remote can at least answer why you are getting two values for the same button on the remote. This is by design: the Nokia-32 RCMM protocol of this remote uses toggling codes that flip between one value and another on alternating presses of the same button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My quest and the challenges of decoding this remote are documented in this thread: &lt;a href=&quot;https://github.com/bengtmartensson/harctoolboxbundle/issues/97&quot; rel=&quot;nofollow&quot;&gt;https://github.com/bengtmartensson/harctoolboxbundle/issues/97&lt;/a&gt; where I discover that my IR remote uses Nokia 32 protocol but with mark and space timings slightly different from what most Arduino libraries are programmed for requiring a tweak to the signal in order to enable other libraries to decode it successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further information here: &lt;a href=&quot;http://www.avsforum.com/forum/93-remote-control-area/1517341-theater-master-mx-500-remote-won-t-learn-bell-fibe-remote-any-help.html#post24345872&quot; rel=&quot;nofollow&quot;&gt;http://www.avsforum.com/forum/93-remote-control-area/1517341-theater-master-mx-500-remote-won-t-learn-bell-fibe-remote-any-help.html#post24345872&lt;/a&gt; where we learn:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;it is different from most IR signals, because it has 4 different off durations, denoting zero, one, two , or three, while traditionally IR protocols have used just two off durations signifying zero or one.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17096" LastEditorUserId="17096" LastEditDate="2016-02-07T19:30:48.777" LastActivityDate="2016-02-07T19:30:48.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20412" PostTypeId="2" ParentId="16493" CreationDate="2016-02-07T16:49:01.790" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm looking for a library to decode RAW IR signals from an IR sensor&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/bengtmartensson/AGirs&quot; rel=&quot;nofollow&quot;&gt;AGirs&lt;/a&gt; includes a comprehensive library designed to work with raw IR signals. I've used GirsLite in an Arduino and &lt;a href=&quot;https://github.com/bengtmartensson/harctoolboxbundle/tree/master/IrScrutinizer&quot; rel=&quot;nofollow&quot;&gt;IrScrutinzer&lt;/a&gt; in Windows to do advance IR protocol snooping.&lt;/p&gt;&#xA;" OwnerUserId="17096" LastActivityDate="2016-02-07T16:49:01.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20413" PostTypeId="2" ParentId="20410" CreationDate="2016-02-07T16:56:08.280" Score="1" Body="&lt;p&gt;It looks like the Teensy designer uses the standard Arduino mouse and keyboard library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.pjrc.com/teensy/td_keyboard.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_keyboard.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On another note, I'm sure Teensy is a fine product, but I prefer other open hardware solutions like Pro Micro which can be had on &lt;a href=&quot;http://www.aliexpress.com/w/wholesale-arduino-pro-micro.html?spm=2114.01010208.0.334.k7qlR1&amp;amp;site=glo&amp;amp;SearchText=arduino%20pro%20micro&amp;amp;g=y&amp;amp;SortType=price_asc&amp;amp;groupsort=1&quot; rel=&quot;nofollow&quot;&gt;AliExpress.com for  under $4 ea.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17096" LastEditorUserId="17096" LastEditDate="2016-02-07T20:16:41.893" LastActivityDate="2016-02-07T20:16:41.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20414" PostTypeId="2" ParentId="9349" CreationDate="2016-02-07T17:15:51.850" Score="2" Body="&lt;p&gt;You can have a global variable in EEPROM if the EEPROM is &lt;a href=&quot;https://en.wikipedia.org/wiki/Memory-mapped_I/O&quot; rel=&quot;nofollow&quot;&gt;memory&#xA;mapped&lt;/a&gt;. Memory-mapping&#xA;the EEPROM &lt;a href=&quot;http://atmel.force.com/support/articles/en_US/FAQ/Memory-mapping-of-EEPROM-in-XMEGA-devices&quot; rel=&quot;nofollow&quot;&gt;is possible on ATxmega&#xA;chips&lt;/a&gt;.&#xA;Notice that writes go to a temporary buffer, not the EEPROM itself,&#xA;until you explicitly issue a write command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduinos, however, use ATmega chips, which do not have this&#xA;feature. I am not aware of any xmega-based Arduino or clone.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-07T17:15:51.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20419" PostTypeId="1" CreationDate="2016-02-07T20:47:07.863" Score="2" ViewCount="144" Body="&lt;p&gt;How can I get the exact rotation of the Genuino 101? I would like to create a plumb rule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the example app with processing, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Genuino101CurieIMUOrientationVisualiser&quot; rel=&quot;nofollow&quot;&gt;Arduino/Genuino 101 CurieIMU Orientation Visualiser&lt;/a&gt;, but it didn't get the correct rotation. Sometimes the object on the screen has a different rotation from the board itself.&lt;/p&gt;&#xA;" OwnerUserId="17120" LastEditorUserId="6936" LastEditDate="2016-02-10T04:52:03.640" LastActivityDate="2016-02-10T04:52:03.640" Title="Get the rotation on Genuino 101" Tags="|accelerometer|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20420" PostTypeId="2" ParentId="8176" CreationDate="2016-02-07T21:58:44.670" Score="2" Body="&lt;p&gt;it's been a while but a long time later I found that the cable I was using was broken. A different cable worked.&lt;/p&gt;&#xA;" OwnerUserId="5165" LastActivityDate="2016-02-07T21:58:44.670" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20421" PostTypeId="2" ParentId="8945" CreationDate="2016-02-07T22:06:53.307" Score="1" Body="&lt;p&gt;&lt;em&gt;Answered by Edgar Bonet&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;There needs to be an empty line between the headers and the body of the request. Therefore you have to &lt;code&gt;println()&lt;/code&gt; (not &lt;code&gt;print()&lt;/code&gt;) the end of the last header.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="61722" LastEditDate="2024-03-11T01:50:16.460" LastActivityDate="2024-03-11T01:50:16.460" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20422" PostTypeId="1" CreationDate="2016-02-07T23:05:16.987" Score="3" ViewCount="125" Body="&lt;p&gt;My Arduino Yún is not detecting my previously working SD card. The metal contacts &lt;em&gt;are&lt;/em&gt; closed. There is &lt;em&gt;no&lt;/em&gt; dmesg output after plugging in the SD. It does not detect a different SD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas for what's wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/xxh1k.jpg&quot; alt=&quot;SD card plugged into Arduino Yún&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="4664" LastEditorUserId="6936" LastEditDate="2016-02-08T06:39:25.533" LastActivityDate="2016-02-08T06:39:25.533" Title="Yún not detecting SD card" Tags="|arduino-yun|sd-card|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20423" PostTypeId="1" AcceptedAnswerId="20424" CreationDate="2016-02-08T00:30:13.100" Score="1" ViewCount="247" Body="&lt;p&gt;In tutorials I've seen, people connect every LED of a RGB LED to a resistance. I understand the purpose, but could we simply put the same resitance once, if we connect it to the common cathode or annode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i6kkB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i6kkB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16230" LastActivityDate="2016-02-08T00:41:30.053" Title="RGB LED Resistance" Tags="|led|rgb-led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20424" PostTypeId="2" ParentId="20423" CreationDate="2016-02-08T00:41:30.053" Score="5" Body="&lt;p&gt;The problem with one resistor in common anode/cathode is that when you activate more than one colour of the RGB LED, you will have additional current flowing through the one resistor which will cause increased voltage drop across the one resistor due to ohms law which will cause less forward voltage across the LED and likely extinguish it or at least make it much less bright. &lt;/p&gt;&#xA;" OwnerUserId="17096" LastActivityDate="2016-02-08T00:41:30.053" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20425" PostTypeId="1" AcceptedAnswerId="20434" CreationDate="2016-02-07T11:43:15.267" Score="5" ViewCount="1163" Body="&lt;p&gt;Novice mode, please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I programmed my ATTiny84 using Arduino Ethernet (Arduino IDE 1.6.7) using &lt;a href=&quot;https://github.com/damellis/attiny%20branch&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/damellis/attiny branch&lt;/a&gt; - &lt;code&gt;1 MHz internal oscillator&lt;/code&gt; mode. I uploaded ISP sketch to Arduino with all cables disconnected (first I did it with all of them connected but Arduino didn't seem to mind), connected the whole setup using 10 uF capacitor and the sketch got sent into ATTiny84 without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blink sketch is using atttiny84's digital pin 7 (that is physical leg No. 6) set to 1 s blink rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, when I connect an yellow LED, it won't blink. I'm not yet good enough with my oscilloscope (don't know how to hook it up) but my multimeter is showing something weird - voltage is slowly rising on DP7 (I measured against ground) - over approx. 5-6 seconds to 400 mV, then immediately jumps to 1V (not sure about this, could be measurement bug) and then right to 0V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blink sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led = 7;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm clueless. Please confer. &#xA;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Images of my setup:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uCfvn.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uCfvn.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17126" OwnerDisplayName="summer.breeze" LastActivityDate="2016-02-08T14:20:14.050" Title="ATTiny84 blink mystery" Tags="|attiny|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20426" PostTypeId="1" CreationDate="2016-02-08T05:36:13.227" Score="5" ViewCount="2756" Body="&lt;p&gt;If I connect to an Arduino Uno via a serial console to read debugging statements and then disconnect, the Arduino appears to reset. How do I stop this from happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to program an Arduino to receive a &quot;shutdown&quot; signal from a Raspberry Pi via serial, which will make the Arduino cut the RPi's power. However, this will also cut the serial connection, and if it causes the Arduino to reset, it'll reactivate power.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-02-09T05:35:55.663" Title="How to stop Arduino from reseting after serial connection lost" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20427" PostTypeId="2" ParentId="20426" CreationDate="2016-02-08T06:18:28.683" Score="4" Body="&lt;p&gt;There is a link on the Uno marked RESET-EN which links the Atmega16U2 (or 8U2) which handles incoming serial data to the main chip, the Atmega328P. If you cut that link (eg. with a knife) then it won't reset. However uploading new sketches will be harder because you will have to manually press the Reset button when the IDE starts to upload a new sketch.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9S21W.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9S21W.jpg&quot; alt=&quot;RESET_EN link&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CY6Lk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CY6Lk.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;One thing that people do is put a 10 µF capacitor between RESET and GND. That holds enough current to &quot;weather&quot; the reset pulse, and that stops the board resetting. You can always remove the capacitor to reprogram the board.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-08T06:18:28.683" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20428" PostTypeId="1" CreationDate="2016-02-08T07:00:44.083" Score="6" ViewCount="212" Body="&lt;p&gt;I got a RePaper 2.7' eInk display that unfortunately doesn't support Arduino Mega because of its limited SRAM capacity (8k bytes). I am porting the library to Arduino Due because of its sufficient RAM capacity (96 KB in two banks: 64KB and 32KB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the thread &lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=22&amp;amp;t=47571&quot; rel=&quot;nofollow noreferrer&quot;&gt;rePaper - 2.7&quot; Graphic eInk Dev Board Headers &lt;/a&gt; and I've done all the modifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone successfully ported the library to Arduino Due? Also, does anyone have a library for Dynamic Printing for this display?&lt;/p&gt;&#xA;" OwnerUserId="17125" LastEditorUserId="4628" LastEditDate="2017-04-04T04:17:53.260" LastActivityDate="2018-04-30T14:57:11.753" Title="RePaper 2.7&quot; eInk Display with Arduino Due" Tags="|lcd|display|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20429" PostTypeId="2" ParentId="20384" CreationDate="2016-02-08T07:02:46.097" Score="2" Body="&lt;p&gt;I have two ideas:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I don't have personal experience working with the &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/AccelStepper/&quot; rel=&quot;nofollow&quot;&gt;AccelStepper Library&lt;/a&gt;, but I believe it implements a class that allows you to work with multiple steppers. &lt;/li&gt;&#xA;&lt;li&gt;I plan on controlling two steppers for a project of my own (a self-balancing robot implemented with an STM32 processor), and I plan on using hardware timer interrupts to control the speed of my motors. A quick &lt;a href=&quot;https://www.google.com/search?num=20&amp;amp;q=arduino+timer+interrupts&quot; rel=&quot;nofollow&quot;&gt;google search&lt;/a&gt; shows that a similar approach is possible with Arduino. You can probably use &lt;code&gt;Timer0&lt;/code&gt;, as 1ms is fairly fast for a single step. This has several benefits...&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The refresh function will run on set intervals, (allowing you to control the speed very precisely.&lt;/li&gt;&#xA;&lt;li&gt;It will run with the correct timing, even if there is a function in &lt;code&gt;loop()&lt;/code&gt; that is taking a long time.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note: do NOT put any &lt;code&gt;delay&lt;/code&gt; statements in your interrupt handlers.&lt;/strong&gt; If you do this, it will probably prevent other interrupts from occurring and cause some API functions (such as &lt;code&gt;millis&lt;/code&gt; or &lt;code&gt;micros&lt;/code&gt;) to misbehave. In addition, the execution of anything in &lt;code&gt;loop&lt;/code&gt; is halted while the interrupt is being handled, meaning that you would effectively stop everything until the interrupt is done. See the caveat in Arduino reference page for &lt;code&gt;delay&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17124" LastActivityDate="2016-02-08T07:02:46.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20430" PostTypeId="2" ParentId="20392" CreationDate="2016-02-08T08:41:39.583" Score="1" Body="&lt;p&gt;I found the official library here: &lt;a href=&quot;http://www.atmel.com/tools/atmel-arm-toolchain.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/tools/atmel-arm-toolchain.aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have finally understood understand how &lt;strong&gt;exactly&lt;/strong&gt; Arduino accesses specific ARM features. It includes &lt;code&gt;sam.h&lt;/code&gt; file which in turn contains &lt;a href=&quot;http://asf.atmel.com/docs/latest/cmsis.html&quot; rel=&quot;nofollow&quot;&gt;Cortex Microcontroller Software Interface Standard&lt;/a&gt;. With this cool interface anyone can use so many cool features: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Timers&lt;/li&gt;&#xA;&lt;li&gt;Advanced interrupts&lt;/li&gt;&#xA;&lt;li&gt;Power saving mode&lt;/li&gt;&#xA;&lt;li&gt;SIMD instructions&lt;/li&gt;&#xA;&lt;li&gt;And many other&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16074" LastEditorUserId="16074" LastEditDate="2016-02-10T10:38:13.247" LastActivityDate="2016-02-10T10:38:13.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20432" PostTypeId="1" CreationDate="2016-02-08T11:17:23.683" Score="-1" ViewCount="754" Body="&lt;p&gt;&lt;strong&gt;The code works but there was a problem on the output. When the PIR detect the presence of motion the output (pin 12) would not give an instant HIGH state on the output, it has more than 10 sec delay to provide a HIGH state on PIN 12. HOw can I lessen the time that once the PIR sensors detected motion it would give a HIGH state to the output (pin 12)? please help me regarding this problem! Thanks&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup()&#xA;{&#xA;    //Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    pinMode(13,OUTPUT);//output 1&#xA;    pinMode(12,OUTPUT);//output 2&#xA;    int pirOuts=11;pinMode(pirOuts,INPUT); /*PIR sensor 1*/&#xA;    int pirOut = 10;pinMode(pirOut,INPUT); /*PIR sensor 2*/&#xA;&#xA;&#xA;    if (digitalRead(pirOut) || digitalRead(pirOuts) == HIGH){ &#xA;        digitalWrite(12,HIGH);&#xA;        tone(13, 50132); delay(100); noTone(13); delay(10);&#xA;        tone(13,54621);  delay(50);  noTone(13); delay(50);&#xA;        tone(13,35689);  delay(60);  noTone(13);&#xA;    } &#xA;    else if (digitalRead(pirOut)||digitalRead(pirOuts)==LOW){&#xA;        digitalWrite(12,LOW);&#xA;        tone(13,50132); delay(100); noTone(13); delay(10);&#xA;        tone(13,54621);  delay(50);  noTone(13); delay(50);&#xA;        tone(13,35689);  delay(60);  noTone(13);&#xA;    } &#xA;    else&#xA;    {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13535" LastActivityDate="2016-02-08T17:46:59.840" Title="PIR sensor issues" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20433" PostTypeId="2" ParentId="20109" CreationDate="2016-02-08T13:58:42.653" Score="2" Body="&lt;h3&gt;TL;DR -&lt;/h3&gt;&#xA;&lt;p&gt;You have the options of either BlueTooth or XBee (amongst others: IR, for example?) for wireless uploading. However, I believe that only one board can be uploaded to, at a time, so you will need to cycle through the boards one at a time, see &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=166451.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programming multiple ATMegas/Arduinos at once&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When uploading a sketch or using a programmer (for sketch or bootloader), the software does not just write the code, it actually communicates with the microcontroller.&lt;/p&gt;&#xA;&lt;p&gt;You can't program them all at once. But you can program them one by one in some automatic way.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Your question is a very interesting one, and asks a question that I am sure that I would never have thought of, but would be extremely useful and labour saving, especially if one has, as I do, many Arduino controlled sensor points located around the house. Here is one rather inelegant solution that may be worth trying.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Wireless upload hardware&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you use &lt;strong&gt;BlueTooth&lt;/strong&gt; to wirelessly upload your sketches, then this solution might be of use, &lt;a href=&quot;http://www.instructables.com/id/Wireless-upload-program-to-Arduino-without-USB-cab/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wireless upload program to Arduino without USB cable&lt;/a&gt;. Note that this solution ties up pins D0 and D1:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;But be careful that it maybe not compatible with some projects which need to use the D0 and D1 as hardware UART TX, RX. Because the wireless programmer needs to permanently occupy the two pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Looking at it, it employs a custom &lt;a href=&quot;https://www.itead.cc/arduino-wireless-programmer.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Wireless Programmer&lt;/a&gt;, to which you may have been referring in your question. However, don't be fooled by the name, it is simply a Bluetooth shield. It is basically a BT HC-05 (or similar) device, bolted onto an Arduino, see also &lt;a href=&quot;http://www.instructables.com/id/Bluetooth-Wireless-Upload/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bluetooth Wireless Upload&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, en lieu of BlueTooth, you could use &lt;strong&gt;XBee&lt;/strong&gt; devices, see &lt;a href=&quot;http://www.instructables.com/id/Wireless-Programming-of-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wireless Programming of Arduino&lt;/a&gt;. The advantage of using XBees is that you would not have to go through the pairing new device loop (see below), that would be required when using BT. Instead you would merely have to cycle through the XBee network IDs.&lt;/p&gt;&#xA;&lt;p&gt;However, in addition to that, you would need to automate the switching of BT devices, selecting the appropriate port and uploading to each Arduino in turn, as &lt;em&gt;you are not able to broadcast sketches&lt;/em&gt;. (If am I wrong, then will someone please correct me).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Selecting the port and uploading the sketch&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You could use a script along with the command line version of the Arduino IDE, to select the port that the BT device is connected to, before each upload. How you do this will vary for which ever platform you are compiling upon, see &lt;a href=&quot;https://stackoverflow.com/questions/8189306/command-line-arduino-compiling-and-downloading&quot;&gt;Command line Arduino compiling and downloading?&lt;/a&gt; This can be done using the environment variable &lt;code&gt;ARDUINO_COMPORT&lt;/code&gt; (see the possibly out of date &lt;a href=&quot;http://playground.arduino.cc/Code/WindowsCommandLine&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows command line build&lt;/a&gt;), or the arduino cmd line option &lt;code&gt;--port &amp;lt;portname&amp;gt;&lt;/code&gt; ( see the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;nofollow noreferrer&quot;&gt;man page&lt;/a&gt;). The sketch would then be uploaded using the option &lt;code&gt;--upload &amp;lt;filename&amp;gt;&lt;/code&gt;. You could do this in one fell swoop:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;arduino --upload --port &amp;lt;portname&amp;gt; FILE.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that on Windows you should use &lt;code&gt;arduino_debug.exe&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Or you could use &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Ino&lt;/a&gt;, if you are &lt;em&gt;not&lt;/em&gt; using a Windows PC... but that might make the next part, which deals with the looping more complex than it needs be.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Selecting each of the Arduinos (i.e. the BT devices)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Next, you would need to add a loop to the script, that pairs the PC to each BT device in turn and thereafter calls the Arduino IDE, for the port selection and uploading. Unfortunately, this would not be platform agnostic at all, and would require a different solution for what ever platform you are using. Take a look at &lt;a href=&quot;https://stackoverflow.com/questions/756555/bluetooth-from-the-command-line&quot;&gt;Bluetooth from the Command Line&lt;/a&gt;, but for Windows you would probably require the &lt;a href=&quot;http://bluetoothinstaller.com/bluetooth-command-line-tools/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blue Tooth Command Line tools suite&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On OS X you may be best off resorting to using AppleScript, see &lt;a href=&quot;https://stackoverflow.com/questions/17519804/connect-to-bluetooth-device-iphone-via-command-line-on-macosx&quot;&gt;Connect to bluetooth device (iPhone) via command line on MacOSX&lt;/a&gt;, as the cmd line tools for controlling BT seem a little scant - there is &lt;a href=&quot;http://www.frederikseiffert.de/blueutil/&quot; rel=&quot;nofollow noreferrer&quot;&gt;BlueUtil&lt;/a&gt;, see &lt;a href=&quot;https://apple.stackexchange.com/questions/47503/how-to-control-bluetooth-wireless-radio-from-the-command-line#comment-54464&quot;&gt;How to control Bluetooth wireless radio from the command line?&lt;/a&gt; but that only appears to turn the BT on of off. However, bolting AppleScript on to the rest of the Arduino IDE control script quickly makes things more complex, although you could just put the Arduino command within the AppleScript, I guess.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-10T05:05:07.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20434" PostTypeId="2" ParentId="20425" CreationDate="2016-02-08T14:20:14.050" Score="1" Body="&lt;p&gt;I solved my own problem. Wiring was completely OK, so was flashing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was RESET pin (4th physical pin). As soon as I disconnected it after flashing, LED started blinking. If someone knows why, I'd appreciate some info.&lt;/p&gt;&#xA;" OwnerUserId="17126" LastActivityDate="2016-02-08T14:20:14.050" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20435" PostTypeId="1" CreationDate="2016-02-08T14:54:08.167" Score="0" ViewCount="347" Body="&lt;p&gt;I'm trying to build a cat motion detector but, to avoid getting false alarms when a person walks by, I was thinking of using RFID. i.e. the cat has a collar and the detector senses the collar when they get within a couple of feet and makes a noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem there seems to be with RFID is that the range is so short - e.g. 4&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have a better solution?&lt;/p&gt;&#xA;" OwnerUserId="17135" LastActivityDate="2016-02-08T17:33:12.877" Title="Cat motion detector that can tell the difference from humans" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20437" PostTypeId="2" ParentId="20435" CreationDate="2016-02-08T15:24:45.817" Score="1" Body="&lt;p&gt;Place an additional motion sensor such that it can only detect motion from things significantly taller than cats, and use that as an inhibitor/classifier of the cat motion signal.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-08T15:24:45.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20438" PostTypeId="1" AcceptedAnswerId="29671" CreationDate="2016-02-08T15:32:23.273" Score="2" ViewCount="19286" Body="&lt;p&gt;I successfully run the &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/AccelStepper/examples.html&quot; rel=&quot;nofollow&quot;&gt;AccelStepper examples&lt;/a&gt; on an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega&lt;/a&gt; with a &lt;a href=&quot;http://reprap.org/wiki/RAMPS_1.4&quot; rel=&quot;nofollow&quot;&gt;RAMPS 1.4&lt;/a&gt; shield, two &lt;a href=&quot;https://www.pololu.com/product/1182&quot; rel=&quot;nofollow&quot;&gt;A4988 stepper motor drivers&lt;/a&gt; and two &lt;a href=&quot;http://www.omc-stepperonline.com/nema-17-bipolar-stepper-motor-028a-36ncm51ozin-17hs160284s-p-80.html&quot; rel=&quot;nofollow&quot;&gt;17HS16-0284S stepper motors&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used 3 jumpers on the RAMPS to set the microstep resolution to 1/16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used this code inspired by the &lt;a href=&quot;https://github.com/euphy/polargraph_server_polarshield&quot; rel=&quot;nofollow&quot;&gt;Polargraph Server&lt;/a&gt; for &lt;a href=&quot;http://www.polargraph.co.uk/&quot; rel=&quot;nofollow&quot;&gt;Polargraph&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;/* &#xA;// for the Arduino Uno + CNC shield V3&#xA;&#xA;#define MOTOR_A_ENABLE_PIN 8&#xA;#define MOTOR_A_STEP_PIN 2&#xA;#define MOTOR_A_DIR_PIN 5&#xA;&#xA;#define MOTOR_B_ENABLE_PIN 8&#xA;#define MOTOR_B_STEP_PIN 3&#xA;#define MOTOR_B_DIR_PIN 6&#xA;*/&#xA;&#xA;// for the Arduino Mega + RAMPS 1.4&#xA;#define MOTOR_A_ENABLE_PIN 30&#xA;#define MOTOR_A_STEP_PIN 36&#xA;#define MOTOR_A_DIR_PIN 34&#xA;&#xA;#define MOTOR_B_ENABLE_PIN 56&#xA;#define MOTOR_B_STEP_PIN 60&#xA;#define MOTOR_B_DIR_PIN 61&#xA;&#xA;AccelStepper motorA(1, MOTOR_A_STEP_PIN, MOTOR_A_DIR_PIN); &#xA;AccelStepper motorB(1, MOTOR_B_STEP_PIN, MOTOR_B_DIR_PIN); &#xA;&#xA;void setup()&#xA;{&#xA;  motorA.setEnablePin(MOTOR_A_ENABLE_PIN);&#xA;  motorA.setPinsInverted(false, false, true);&#xA;  motorB.setEnablePin(MOTOR_B_ENABLE_PIN);&#xA;  motorB.setPinsInverted(false, false, true);&#xA;&#xA;  motorA.setAcceleration(100);  &#xA;  motorA.move(1000);&#xA;  //motorA.setMaxSpeed(100);&#xA;  //motorA.setSpeed(100);&#xA;&#xA;  motorB.setAcceleration(100);  &#xA;  motorB.move(1000);&#xA;  //motorB.setMaxSpeed(100);&#xA;  //motorB.setSpeed(100);&#xA;&#xA;  motorA.enableOutputs();&#xA;  motorB.enableOutputs();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  motorA.run();&#xA;  motorB.run();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to use the same code with the same stepper motor drivers and motors on a &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno&lt;/a&gt; and a &lt;a href=&quot;http://blog.protoneer.co.nz/arduino-cnc-shield-v3-00-assembly-guide/&quot; rel=&quot;nofollow&quot;&gt;CNC shield v3&lt;/a&gt; without success (I also used the 3 jumpers to set the microstep resolution to 1/16). The motors do not work and jitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong with my code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bonus questions&lt;/strong&gt;:&#xA;I have taken this setup and code from the Polargraph server but I didn't get how I'm suppose to know how to use &lt;code&gt;setEnablePin()&lt;/code&gt; and &lt;code&gt;setPinsInverted()&lt;/code&gt; methods. In fact, I have troubles finding documentation about the CNC shield V3 and the A4988 drivers (I only found &lt;a href=&quot;http://blog.protoneer.co.nz/arduino-cnc-shield-v3-00-assembly-guide/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;) to work with AccelStepper.&lt;/p&gt;&#xA;" OwnerUserId="17140" LastEditorUserId="17140" LastEditDate="2016-02-08T15:53:54.533" LastActivityDate="2018-09-25T10:05:27.673" Title="Arduino uno + cnc shield v3 + Stepper Motor Driver A4988 + AccelStepper?" Tags="|arduino-uno|programming|motor|shields|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20439" PostTypeId="1" AcceptedAnswerId="20449" CreationDate="2016-02-08T15:37:03.077" Score="2" ViewCount="2124" Body="&lt;p&gt;I'm using a library that, by default, wants to use Serial2 as the interface to a display, however, I'm working with an UNO which only has one serial interface, so the compile fails. I'm trying to use a SoftwareSerial instead, but I can't figure out how to override the #define statement in the library without editing the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing since the software serial port isn't generated at compile time, I can't. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define nexSerial HMI&#xA;#include &amp;lt;Nextion.h&amp;gt;&#xA;&#xA;SoftwareSerial HMI(8,9);&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't started writing code yet, can't get past the attempt to redirect the serial interface to a software serial.&lt;/p&gt;&#xA;" OwnerUserId="17137" LastActivityDate="2016-03-09T21:12:05.530" Title="Override #define statements in libraries" Tags="|serial|library|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20440" PostTypeId="1" CreationDate="2016-02-08T16:13:27.763" Score="1" ViewCount="651" Body="&lt;h2&gt;BACKGROUND&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To test the capability of uploading program to ESP8266,  I use an empty program with only a blank setup function and a blank loop function. The result showed me that there are a &lt;strong&gt;espcomm_sync error&lt;/strong&gt; and a &lt;strong&gt;espcomm_open error&lt;/strong&gt;. Any idea to solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;HARDWARE&lt;/h2&gt;&#xA;&#xA;&lt;h2&gt;&lt;a href=&quot;https://i.stack.imgur.com/jHQP2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jHQP2.jpg&quot; alt=&quot;Foca v2.2&quot;&gt;&lt;/a&gt; &lt;a href=&quot;https://i.stack.imgur.com/6Z1PO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Z1PO.jpg&quot; alt=&quot;ESP8266&quot;&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;PIN CONNECTION&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Foca v2.2 &amp;lt;-&amp;gt; ESP8266&#xA;        TXD &amp;lt;-&amp;gt; RXD&#xA;        RXD &amp;lt;-&amp;gt; TXD&#xA;        DTR &amp;lt;-&amp;gt; RST&#xA;&#xA;Arduino UNO &amp;lt;-&amp;gt; ESP8266&#xA;        GND &amp;lt;-&amp;gt; GND&#xA;       3.3V &amp;lt;-&amp;gt; Vcc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;PIN DIAGRAMS&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Foca v2.2&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8s6D0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8s6D0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP8266&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/1Ksvu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Ksvu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;ON LINUX UBUNTU 15.04&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R8SPR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R8SPR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;ON WINDOWS 10&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eq5MJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eq5MJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;REFERENCE&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bring IoT to Arduino, together [Getting Started] - &lt;a href=&quot;http://www.arduinesp.com/getting-started&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduinesp.com/getting-started&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8072" LastEditorUserId="8072" LastEditDate="2016-02-10T14:25:26.920" LastActivityDate="2019-02-28T21:10:06.317" Title="Error on Uploading Program to ESP8266 via Foca v2.2 (USB to TTL Adapter)" Tags="|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20441" PostTypeId="1" CreationDate="2016-02-08T16:28:32.340" Score="2" ViewCount="549" Body="&lt;p&gt;Hello I want to program an Attiny13a with Arduino code. I always have this error  when I add repository &quot;no file board.txt&quot; in path.&#xA;How to successfully configure IDE to able burn on it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use :&lt;br&gt;&#xA;&lt;a href=&quot;http://sourceforge.net/projects/ard-core13/?source=typ_redirect&quot; rel=&quot;nofollow&quot;&gt;Link 1&lt;/a&gt;&lt;br&gt;&#xA;And :&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/jensh/attiny13a&quot; rel=&quot;nofollow&quot;&gt;Link 2&lt;/a&gt;&lt;br&gt;&#xA;But nothing changed . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using IDE Arduino v1.6.7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I import ATTiny13 &lt;a href=&quot;http://sourceforge.net/projects/ard-core13/&quot; rel=&quot;nofollow&quot;&gt;(link)&lt;/a&gt; now these errors appear:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Board attiny13:avr:attiny13 doesn't define a 'build.board'&#xA;preference.Auto-set to: AVR_ATTINY13&#xA;&#xA;Board attiny13:avr:attiny13at4 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY13AT4&#xA;&#xA;Board attiny13:avr:attiny13at9 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY13AT9&#xA;&#xA;Warning: platform.txt from core 'Attiny13' contains deprecated compiler.path={runtime.ide.path}/hardware/tools/avr/bin/, automatically converted to compiler.path={runtime.tools.avr-gcc.path}/bin/. Consider upgrading this core.&#xA;&#xA;Warning: platform.txt from core 'Attiny13' contains deprecated tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude, automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude. Consider upgrading this core.&#xA;&#xA;&#xA;Warning: platform.txt from core 'Attiny13' contains deprecated tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf, automatically converted to tools.avrdude.config.path={path}/etc/avrdude.conf. Consider upgrading this core.&#xA;&#xA;Warning: platform.txt from core 'Attiny13' contains deprecated recipe.ar.pattern=&quot;{compiler.path}{compiler.ar.cmd}&quot; {compiler.ar.flags} {compiler.ar.extra_flags} &quot;{build.path}/{archive_file}&quot; &quot;{object_file}&quot;, automatically converted to recipe.ar.pattern=&quot;{compiler.path}{compiler.ar.cmd}&quot; {compiler.ar.flags} {compiler.ar.extra_flags} &quot;{archive_file_path}&quot; &quot;{object_file}&quot;. Consider upgrading this core.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17143" LastEditorUserId="11529" LastEditDate="2016-02-08T20:01:32.837" LastActivityDate="2016-02-08T20:01:32.837" Title="Arduino programming attiny13a" Tags="|arduino-uno|programming|arduino-ide|bootloader|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20442" PostTypeId="2" ParentId="20435" CreationDate="2016-02-08T17:33:12.877" Score="0" Body="&lt;p&gt;What about a transmitter on the collar - Bluetooth, or a coded infra red pulse, that could be detected by fixed stations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Battery life and safety (swallowing batteries!) would be serious considerations though...&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-02-08T17:33:12.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20444" PostTypeId="1" AcceptedAnswerId="20454" CreationDate="2016-02-08T17:45:53.637" Score="-1" ViewCount="1167" Body="&lt;p&gt;I have searched google and I now know that if we change the resistance, we can change the brightness of an LED, but I was wondering how to change resistance by using a micro controller.&lt;/p&gt;&#xA;" OwnerUserId="15759" LastEditorUserId="6936" LastEditDate="2016-02-08T21:30:41.330" LastActivityDate="2016-02-08T21:35:51.197" Title="Control brightness of 20 watt street LED light using Arduino" Tags="|arduino-uno|arduino-mega|arduino-ide|arduino-due|arduino-nano|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20445" PostTypeId="2" ParentId="20432" CreationDate="2016-02-08T17:46:59.840" Score="1" Body="&lt;p&gt;Check to make sure your PIR sensor reads high when triggered. Most of them will trigger high, but I've seen a few that will trigger low. Also, some PIR sensors have potentiometers to control delay. Some delay the trigger, some delay the reset between triggers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The delay may not be coming from the Arduino, but from the sensor itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the first if statement is formatted incorrectly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(pirOut) || digitalRead(pirOuts) == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should probably be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(pirOut) == HIGH || digitalRead(pirOuts) == HIGH)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works the way you coded it because you're doing a logical OR of the two input values (which will be 0 or 1) then comparing the result to HIGH. As I said it will work, but probably not best practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in your code, I don't understand why you're using else if instead of just else.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else if (digitalRead(pirOut)||digitalRead(pirOuts)==LOW){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, your first if statement has to be false (so both pirOut and pirOuts must both be low) so your if statement as written will always be true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your intent was to execute that code when either pirOut or pirOuts goes LOW, then it should be a separate if statement, not an else if.&lt;/p&gt;&#xA;" OwnerUserId="17137" LastActivityDate="2016-02-08T17:46:59.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20447" PostTypeId="1" CreationDate="2016-02-08T18:07:13.427" Score="3" ViewCount="2883" Body="&lt;p&gt;I have bought 10 Arduino Mega 2560 clones and all of them have the same problem. When I connect the to my PC I get a message that windows cannot recognize that device and the LED at the board in R17 blinks non stop. normally this led stops when the arduino is ready. Also in the Arduino IDE I don't see the port option enable.&lt;/p&gt;&#xA;" OwnerUserId="16864" LastEditorUserId="11529" LastEditDate="2016-02-08T18:47:38.150" LastActivityDate="2016-02-08T18:51:16.600" Title="Arduino mega R17 led blink continuously" Tags="|arduino-mega|" AnswerCount="1" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="20448" PostTypeId="2" ParentId="20439" CreationDate="2016-02-08T18:09:45.440" Score="0" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you are doing in your code is providing a #define to the instance of the header file that is included in your sketch file. You have no way of modifying the instance that is included in the library's source files.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-08T18:09:45.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20449" PostTypeId="2" ParentId="20439" CreationDate="2016-02-08T18:34:40.427" Score="1" Body="&lt;p&gt;You're allowed to modify the header file.  The &lt;a href=&quot;https://github.com/bborncr/nextion/blob/master/Nextion.h#L47&quot; rel=&quot;nofollow&quot;&gt;version I looked at&lt;/a&gt; says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define USE_SOFTWARE_SERIAL //Comment this line for use  HardwareSerial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...but I think he meant &quot;comment this line out to use HardwareSerial&quot;.  Or conversely, &quot;uncomment this line to use SoftwareSerial.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you just pass your &lt;code&gt;SoftwareSerial&lt;/code&gt; instance into the &lt;code&gt;Nextion&lt;/code&gt; constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial HMI( 8,9 );&#xA;Nextion nextion( HMI );&#xA;&#xA;void setup()&#xA;{&#xA;   HMI.begin( 9600 ); // or whatever speed...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, because you are using pins 8 &amp;amp; 9, I would &lt;strong&gt;strongly&lt;/strong&gt; recommend using &lt;a href=&quot;https://github.com/PaulStoffregen/AltSoftSerial&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt; instead.  It is much more reliable and efficient.  MUCH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to modify the Nextion files to either (1) search and replace all occurrences of &lt;code&gt;SoftwareSerial&lt;/code&gt; with &lt;code&gt;AltSoftSerial&lt;/code&gt;, or (2) add a third choice to the author's &lt;code&gt;#ifdef/#endif&lt;/code&gt; sections.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define USE_SOFTWARE_SERIAL // uncomment this line to use SoftwareSerial&#xA;#define USE_ALTSOFT_SERIAL  // uncomment this line to use AltSoftSerial&#xA;                            // comment both above  to use HardwareSerial&#xA;&#xA;#if defined(USE_SOFTWARE_SERIAL)&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#elsif definied(USE_ALT_SOFTSERIAL)&#xA;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;#endif&#xA;&#xA;class Nextion{&#xA; private:&#xA;  void flushSerial();&#xA;#if defined(USE_SOFTWARE_SERIAL)&#xA;  SoftwareSerial *nextion;&#xA;#elsif defined(USE_ALTSOFT_SERIAL)&#xA;  AltSoftSerial *nextion;&#xA;#else&#xA;  HardwareSerial *nextion;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do either one of those things in all files that refer to the &lt;code&gt;Nextion&lt;/code&gt; serial member; Nextion.CPP certainly needs it.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-02-08T18:34:40.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20450" PostTypeId="1" AcceptedAnswerId="20452" CreationDate="2016-02-08T18:45:51.833" Score="0" ViewCount="4133" Body="&lt;p&gt;I am developing a project to operate a load of about 12Vdc.  I considered the use of an optocoupler to avoid mechanical wear of a relay.  The design I have tried is &lt;a href=&quot;http://123d.circuits.io/circuits/1573080-optoacoplador-con-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W3OtZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W3OtZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This configuration seems to work OK, but I am a biologist and this is my first attempt with an opto of any kind!!!!  I had a lot of trouble with the transistor until I changed to a PNP.  Is this right?  Can it be done with an NPN or even without any transistor at all?&lt;/p&gt;&#xA;" OwnerUserId="17148" LastActivityDate="2016-02-08T19:35:14.693" Title="How should I use an optocoupler to control a 12Vcc load with Arduino?" Tags="|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20451" PostTypeId="2" ParentId="20447" CreationDate="2016-02-08T18:51:16.600" Score="2" Body="&lt;p&gt;You need CH340G drivers. CH340G is a chip that basically replaces the usual ATMega 8U2/16U2 that is used for USB to serial interface. As CH340 cannot be reprogrammed it means that you can't emulate other USB devices with your arduino for example a keyboard.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can download the drivers &lt;a href=&quot;http://www.5v.ru/ch340g.htm&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-02-08T18:51:16.600" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="20452" PostTypeId="2" ParentId="20450" CreationDate="2016-02-08T19:23:46.157" Score="1" Body="&lt;p&gt;If your load draws a small amount of current (less than about 30 mA current), your 4N35 optocoupler could drive the load directly on 12 volts.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ignore my use of 4N28 (similar to 4N35). It is the symbol that I had.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears that your PNP transistor circuit is something like this :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2kUIv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2kUIv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The PNP transistor circuit can work well depending upon your load current.  The PNP circuit has some problems with the transistor not turning on fully (and won't be described here).  You may not get the full 12 volts to your Load. But, if it works for your load, then be happy with the PNP circuit.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit below is for a NPN transistor circuit  :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h6eMQ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h6eMQ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the NPN circuit allows (in this case) for the transistor to turn on fully, leaving almost the full 12 volts for your Load.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Important Note :  The NPN transistor circuit produces an output that is the LOGIC opposite of the PNP circuit.   Notice that for the PNP circuit, a logic 1 to the input of the optocoupler (LED on) turns on power to your Load.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the NPN circuit, a logic zero (0) to the optocoupler LED is required to turn on your Load.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another variation of the circuit is below, and does NOT have the reverse logic situation.  In other words, it will behave like the PNP circuit. When LED is on, the Load will be on  :   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WkbZy.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WkbZy.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can experiment with the value of R1 in the NPN circuits. You could experiment with lower value, down to 1K (1000 ohms) if you are using a power transistor to drive high current loads. &lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-02-08T19:35:14.693" LastActivityDate="2016-02-08T19:35:14.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20454" PostTypeId="2" ParentId="20444" CreationDate="2016-02-08T19:43:01.720" Score="2" Body="&lt;p&gt;Did you do a web search? &quot;&lt;a href=&quot;https://www.google.co.th/search?q=arduino%20pwm%20high%20power%20led%20driver&quot; rel=&quot;nofollow&quot;&gt;arduino pwm high power led driver&lt;/a&gt;&quot; gives all the info you may need to answer this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a nice youtube clip, by &lt;a href=&quot;https://www.youtube.com/channel/UCmHvGf00GDuPYG9DZqQKd9A&quot; rel=&quot;nofollow&quot;&gt;Julian Ilett&lt;/a&gt; that explains how to do this: &lt;a href=&quot;https://www.youtube.com/watch?v=V7CA1brVXDA&quot; rel=&quot;nofollow&quot;&gt;60W High Power LED Driver with PWM #2 - Brightness Control&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="6936" LastEditDate="2016-02-08T21:35:51.197" LastActivityDate="2016-02-08T21:35:51.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20455" PostTypeId="1" CreationDate="2016-02-08T21:03:07.133" Score="1" ViewCount="31" Body="&lt;p&gt;When I pass an array, and it's len to the constructor of a class. I store the length, and access it later, it's value changes, seemingly at random. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;#define NUMSENSORS 2&#xA;const byte dataPins[] = {A5, A4};&#xA;&#xA;class B {&#xA;    public:&#xA;        B(byte pin) { _pin = pin; }&#xA;        byte getPin() { return _pin; }&#xA;    private:&#xA;        byte _pin;&#xA;};&#xA;&#xA;class A {&#xA;    public:&#xA;        A(const byte sensorPins[], int len) {&#xA;            Serial.print(&quot;provided len is: &quot;);&#xA;            Serial.println(len);&#xA;            _len = len;&#xA;            Serial.print(&quot;Stored len is: &quot;);&#xA;            Serial.println(_len);&#xA;            for (int i=0; i&amp;lt;len; i++) { myBarray[i] = new B(sensorPins[i]); }&#xA;        }&#xA;        B* myBarray[];&#xA;        int _len;&#xA;        void printLen() {&#xA;            Serial.print(&quot;Length is: &quot;);&#xA;            Serial.println(_len);&#xA;        }&#xA;};&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    A test(dataPins, NUMSENSORS);&#xA;    for (uint8_t i=0; i&amp;lt;10; i++) {&#xA;        test.printLen();&#xA;        delay(100);&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value of len is fine in the constructor,  but is different when I call it in the function &quot;getLen&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel as though it has something to do with pointers. Because if I comment out the for loop in the constructor of A, the value is correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated, thanks in advance. &lt;/p&gt;&#xA;" OwnerUserId="17151" LastEditorUserId="4143" LastEditDate="2016-02-08T21:04:54.620" LastActivityDate="2016-02-09T07:27:46.440" Title="Data changes when working with classes" Tags="|programming|arduino-mega|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20456" PostTypeId="1" CreationDate="2016-02-08T21:13:35.127" Score="2" ViewCount="15674" Body="&lt;p&gt;I am creating a menu for adjusting system variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The menu is made up of pointers like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* options4[] = {&quot;hMin1&quot;, &quot;hMax1&quot;, &quot;refr1&quot;, &quot;fSpeed1&quot;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to pass the selected string as the parameter for an 'adjust' function for use in some conditional logic and for display on a HCMAX7219 7 segment display. Here's what I've got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int option = 0;&#xA;float variable = 82.0;&#xA;&#xA;if(Serial.available() &amp;gt; 0) {&#xA;  key = Serial.read();&#xA;  if(key == back) {&#xA;    return;&#xA;  } else if(key == fwd) {&#xA;    float newVar = adjust(String(options4[option%4]), variable);&#xA;  } else if(key == down) {&#xA;    option++;&#xA;  } else if(key == up) {&#xA;    option--;&#xA;  }&#xA;}&#xA;&#xA;float adjust(char* str, float var) {&#xA;  ...do some stuff...&#xA;  display.print7Seg(str, 8);&#xA;  EDIT: forgot this call..&#xA;  display.print7Seg(var, 1, 4);&#xA;  ...do stuff to var...&#xA;  return var;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The library function takes &lt;code&gt;(char[] TextString, unsigned int Offset)&lt;/code&gt; as it's parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: the library also has functions &lt;code&gt;print7Seg(long number, byte decimalPlace, unsigned int Offset)&lt;/code&gt; and &lt;code&gt;print7Seg(long number, unsigned int Offset)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm new to pointers, but I can see that I am passing a pointer to my adjust function, and expecting it to dig out a char array from memory. I can't see any problems with that, though I may be missing something. When I try to compile, the IDE just crashes with exit status 84; so no debug info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I going about this the wrong way?&lt;/p&gt;&#xA;" OwnerUserId="17150" LastEditorUserId="17150" LastEditDate="2016-02-08T22:18:13.947" LastActivityDate="2016-04-08T23:34:50.353" Title="How can I pass a char array as the parameter to a function?" Tags="|c++|arduino-ide|string|pointer|array|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20458" PostTypeId="2" ParentId="20456" CreationDate="2016-02-08T21:46:59.220" Score="1" Body="&lt;p&gt;There are one or two things missing in your code. Where is setup() and loop()? Or is it just a snippet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But answer to the question first. This is not right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;newVar = adjust(String(options4[option%4]), variable);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;newVar = adjust(options4[option%4], variable);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You want to index the vector of strings and pass one of the elements to the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-08T21:46:59.220" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20459" PostTypeId="1" AcceptedAnswerId="20465" CreationDate="2016-02-08T22:03:19.377" Score="1" ViewCount="2537" Body="&lt;p&gt;There are two events I plan to log; using no switches or requiring manual input of some kind.  One of the events is whenever the Arduino Serial Monitor is opened; the other, is when external event occurs that causes a Arduino RESET.  Second event produces a LOW pulse used to CLK the J-K Flip-flop.  digitalRead of J-K Flip-flop Q; using a conditional statement, if Q = HIGH log to SD Card as event1 date/time stamp else log to SD Card as event2 date/time stamp.  I need the J-K Output Q to be STORED thru the Arduino RESET, so Q can be read. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading Q, will need to clear Q; plan to do this from running sketch with a DigitalWrite&lt;/p&gt;&#xA;&#xA;&lt;p&gt;74HC73 is the chip I plan to use; it is triggered with a negative going CLK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What needs to happen with the J and K inputs?  Will this work in toggle mode; with both J and K tried to +5 volts?&lt;/p&gt;&#xA;" OwnerUserId="16684" LastActivityDate="2016-12-23T14:48:40.610" Title="Setup J-K Flip-flop for logging on Arduino RESET" Tags="|hardware|reset|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20460" PostTypeId="1" AcceptedAnswerId="20464" CreationDate="2016-02-08T22:07:57.013" Score="0" ViewCount="1353" Body="&lt;p&gt;Good evening!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am quite new with Arduino but not in programming. Still, I have already done some programs with few leds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was just wandering how to create a circuit and a program that would play the &quot;happy birthday&quot; song with the following materials:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/G8oWw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/G8oWw.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a breadbord and some wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Else, do you have some links where I could start learning how to play music with it?&lt;/p&gt;&#xA;" OwnerUserId="15619" LastActivityDate="2016-02-08T23:32:44.260" Title="Playing music with an Arduino" Tags="|sound|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20461" PostTypeId="1" AcceptedAnswerId="20484" CreationDate="2016-02-08T22:28:13.180" Score="2" ViewCount="1577" Body="&lt;p&gt;I used to use Arduino on Windows but I changed to Linux last week and I was wondering how to have a maintained version of the Arduino terminal:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, I'm not sure my version is quite recent:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vcyLD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vcyLD.png&quot; alt=&quot;Screenshot of Arduino IDE on Ubuntu&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The icon seems to have lived ages without a little lifting...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe I'm wrong but it seems so when I open the &quot;Tools&quot; option for instance...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore I tried to copy and paste this code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//ONG LIT YIT 2013-07-20&#xA;//This following code plays happy birthday melody on Arduino&#xA;//Put Piezo Buzzer on GDN and 9 (Positive and negative are reversible)&#xA;//this project requires a Piezo Buzzer and&#xA;&#xA;// an Arduino board and&#xA;&#xA;//jumper wires to connect Buzzer's (+) to ~9 and (-) to GND (any GND)&#xA;&#xA;//HAVE FUN&#xA;&#xA;//this project requires a Piezo Buzzer and&#xA;&#xA;// an Arduino board and&#xA;&#xA;//jumper wires to connect Buzzer's (+) to ~9 and (-) to GND (any GND)&#xA;&#xA;//HAVE FUN&#xA;&#xA;int speakerPin = 9;&#xA;&#xA;int length = 28; // the number of notes&#xA;&#xA;char notes[] = &quot;GGAGcB GGAGdc GGxecBA yyecdc&quot;;&#xA;&#xA;int beats[] = { 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8,8, 16, 1, 2,2,8,8,8,8,16, 1,2,2,8,8,8,16 };&#xA;&#xA;int tempo = 150;&#xA;&#xA;void playTone(int tone, int duration) {&#xA;&#xA;for (long i = 0; i &amp;lt; duration * 1000L; i += tone * 2) {&#xA;&#xA;   digitalWrite(speakerPin, HIGH);&#xA;&#xA;   delayMicroseconds(tone);&#xA;&#xA;   digitalWrite(speakerPin, LOW);&#xA;&#xA;   delayMicroseconds(tone);&#xA;&#xA;}&#xA;&#xA;}&#xA;&#xA;void playNote(char note, int duration) {&#xA;&#xA;char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B',           &#xA;&#xA;                 'c', 'd', 'e', 'f', 'g', 'a', 'b',&#xA;&#xA;                 'x', 'y' };&#xA;&#xA;int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014,&#xA;&#xA;                 956,  834,  765,  593,  468,  346,  224,&#xA;&#xA;                 655 , 715 };&#xA;&#xA;int SPEE = 5;&#xA;&#xA;// play the tone corresponding to the note name&#xA;&#xA;for (int i = 0; i &amp;lt; 17; i++) {&#xA;&#xA;   if (names[i] == note) {&#xA;    int newduration = duration/SPEE;&#xA;     playTone(tones[i], newduration);&#xA;&#xA;   }&#xA;&#xA;}&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA;pinMode(speakerPin, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;for (int i = 0; i &amp;lt; length; i++) {&#xA;&#xA;   if (notes[i] == ' ') {&#xA;&#xA;     delay(beats[i] * tempo); // rest&#xA;&#xA;   } else {&#xA;&#xA;     playNote(notes[i], beats[i] * tempo);&#xA;&#xA;   }&#xA;&#xA;   // pause between notes&#xA;&#xA;   delay(tempo);&#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And not all of it appeared in the Arduino terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hIwAn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hIwAn.png&quot; alt=&quot;Screenshot of Arduino IDE with badly pasted code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15619" LastEditorUserId="4131" LastEditDate="2016-03-26T23:00:24.420" LastActivityDate="2016-03-26T23:00:24.420" Title="Maintaining Arduino on Ubuntu 14.04" Tags="|linux|ubuntu|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20462" PostTypeId="2" ParentId="20455" CreationDate="2016-02-08T22:42:18.557" Score="2" Body="&lt;p&gt;Let us do this with a template class and avoid malloc, etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define membersof(x) (sizeof(x) / sizeof(x[0]))&#xA;&#xA;const byte dataPins[] = { A5, A4 };&#xA;&#xA;class B {&#xA;public:&#xA;  byte getPin() { return (_pin); }&#xA;  void setPin(byte pin) { _pin = pin; }&#xA;private:&#xA;  byte _pin;&#xA;};&#xA;&#xA;template&amp;lt;unsigned len&amp;gt;&#xA;class A {&#xA;public:&#xA;  A(const byte sensorPins[]) {&#xA;    for (unsigned i = 0; i &amp;lt; len; i++)&#xA;      _vec[i].setPin(sensorPins[i]);&#xA;  }&#xA;  unsigned getLen() { return (len); }&#xA;  B* getB(unsigned ix) { return (ix &amp;lt; len ? &amp;amp;_vec[ix] : NULL); }&#xA;&#xA;private:&#xA;  B _vec[len];&#xA;};&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  A&amp;lt;membersof(dataPins)&amp;gt; test(dataPins);&#xA;  unsigned len = test.getLen();&#xA;  Serial.print(F(&quot;test.getLen()=&quot;));&#xA;  Serial.println(len);&#xA;  for (unsigned i = 0; i &amp;lt; len; i++) {&#xA;    B* bp = test.getB(i);&#xA;    Serial.print(F(&quot;test::B[&quot;));&#xA;    Serial.print(i);&#xA;    Serial.print(F(&quot;].getPin()=&quot;));&#xA;    Serial.println(bp-&amp;gt;getPin());&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-09T07:27:46.440" LastActivityDate="2016-02-09T07:27:46.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20463" PostTypeId="2" ParentId="20456" CreationDate="2016-02-08T22:43:47.813" Score="0" Body="&lt;p&gt;Ah .. ok I've just figured it out..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;is&lt;/em&gt; a legitimate way to pass char arrays to functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The original &lt;code&gt;char* options4[]&lt;/code&gt; array is just an array of pointers to char arrays in memory, so passing one of these pointers to a function works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The culprite was actually my float parameter, I was trying to make a library function call with a float to this function: &lt;code&gt;print7Seg(long number, byte decimalPlace, unsigned int Offset)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what was causing the IDE to crash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got around it by having an int version of each of the variables I need to set. Then typecasting and dividing by a float to get variables that will be used in the main program. like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int hMin1Int = 820;&#xA;float hMin1 = (float)hMin1Int / 10.0;&#xA;int hMax1Int = 880;&#xA;float hMax1 = (float)hMax1Int / 10.0;&#xA;int refr1 = 30; //minutes&#xA;int fSpeed1 = 128;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was then able to change my function to accept an &lt;code&gt;int&lt;/code&gt;, the library function, so far, seems to be ok treating an int as a long, but if not I can just make all my ints longs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int adjust(char* str, int var) {&#xA;  ...do some stuff...&#xA;  display.print7Seg(str, 8);&#xA;  display.print7Seg(var, 1, 4);&#xA;  ...do stuff to var...&#xA;  return var;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was asking the wrong question!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still I hope this will be useful to someone, so I will leave it up. Thanks for the response Mikael Patel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moral of the story, know your library.&lt;/p&gt;&#xA;" OwnerUserId="17150" LastActivityDate="2016-02-08T22:43:47.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20464" PostTypeId="2" ParentId="20460" CreationDate="2016-02-08T23:32:44.260" Score="0" Body="&#xA;&#xA;&lt;p&gt;Thanks to Mikael Patel for suggesting &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=178460.0&quot; rel=&quot;nofollow&quot;&gt;that link&lt;/a&gt; (your Google-Fu must be strong!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pasting the code below so that this answer survives any possible future deletion of the read-only part of the Arduino Forum.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;//ONG LIT YIT 2013-07-20&#xA;//This following code plays happy birthday melody on Arduino&#xA;//Put Piezo Buzzer on GDN and 9 (Positive and negative are reversible)&#xA;//this project requires a Piezo Buzzer and&#xA;&#xA;// an Arduino board and&#xA;//jumper wires to connect Buzzer's (+) to ~9 and (-) to GND (any GND)&#xA;&#xA;const int speakerPin = 9;&#xA;const int LENGTH = 28; // the number of notes&#xA;const char notes[LENGTH + 1] = &quot;GGAGcB GGAGdc GGxecBA yyecdc&quot;;&#xA;const int beats[LENGTH] = { 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 16 };&#xA;const int tempo = 150;&#xA;&#xA;void playTone(int tone, int duration) &#xA;  {&#xA;  for (long i = 0; i &amp;lt; duration * 1000L; i += tone * 2) &#xA;    {&#xA;    digitalWrite(speakerPin, HIGH);&#xA;    delayMicroseconds(tone);&#xA;    digitalWrite(speakerPin, LOW);&#xA;    delayMicroseconds(tone);&#xA;    }&#xA;  } // end of playTone&#xA;&#xA;void playNote(const char note, const int duration) &#xA;  {&#xA;  char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B',&#xA;                  'c', 'd', 'e', 'f', 'g', 'a', 'b',&#xA;                  'x', 'y'&#xA;                 };&#xA;  const int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014,&#xA;                  956,  834,  765,  593,  468,  346,  224,&#xA;                  655 , 715&#xA;                };&#xA;  const int SPEE = 5;&#xA;&#xA;  // play the tone corresponding to the note name&#xA;  for (int i = 0; i &amp;lt; 17; i++) &#xA;    {&#xA;    if (names[i] == note) {&#xA;      int newduration = duration / SPEE;&#xA;      playTone(tones[i], newduration);&#xA;    }&#xA;  }&#xA;} // end of playNote&#xA;&#xA;void setup() &#xA;  {&#xA;  pinMode(speakerPin, OUTPUT);&#xA;  } // end of setup&#xA;&#xA;void loop() &#xA;  {&#xA;  for (int i = 0; i &amp;lt; LENGTH; i++) &#xA;    {&#xA;    if (notes[i] == ' ') &#xA;      {&#xA;      delay(beats[i] * tempo); // rest&#xA;      } &#xA;    else &#xA;    {&#xA;      playNote(notes[i], beats[i] * tempo);&#xA;    }&#xA;&#xA;    // pause between notes&#xA;    delay(tempo);&#xA;  }&#xA;} // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also cleaned up the code a bit.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-08T23:32:44.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20465" PostTypeId="2" ParentId="20459" CreationDate="2016-02-09T00:09:51.773" Score="0" Body="&lt;p&gt;Rather than having events that set 1Q or 2Q, consider having the external events take 1R\ or 2R\ low, to reset 1Q or 2Q.  When your sketch starts up, it would read 1Q and 2Q.  If one or the other is low, its event occurred and you can log it.  Then the sketch sets both Q's by dropping the CP lines with J's wired high and K's wired low.  You'd use three I/O pins: two for reading 1Q and 2Q, one for strobing the CP lines to set the Q's after reading them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino AVR pins default to inputs on Reset so the Arduino can reset without affecting the 74HC73's state.  A 10 to 20KΩ resistor to passively pull the CP lines high is reasonable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Note, 1R\ and 2R\ operate asynchronously, and are independent of clock inputs.  This leads to simpler interface requirements for your external events.  However, it may also increase sensitivity to electrical noise; if your system is in a noisy environment a different approach might be needed.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-09T01:50:37.233" LastActivityDate="2016-02-09T01:50:37.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20467" PostTypeId="1" AcceptedAnswerId="26134" CreationDate="2016-02-09T01:20:32.923" Score="2" ViewCount="127" Body="&lt;p&gt;I recently bought a Velleman KA02 Arduino Audio Shield (&lt;a href=&quot;http://www.velleman.co.uk/contents/en-uk/p579_ka02.html&quot; rel=&quot;nofollow&quot;&gt;http://www.velleman.co.uk/contents/en-uk/p579_ka02.html&lt;/a&gt;), which uses an ISD1760PY audio chip and soldered it together. The first time I fired it up, it worked fine, I had freshly soldered it together. But from the next time up to now, if I press any button but the reset button, the onboard LED blinks 7 times and it doesn't record or do anything. I checked the solder joints and nothing fell out and I also checked the ISD1760PY datasheet but found nothing about my problem. Is there a way to fix this and why it it happening? Please note that I am not controlling the shield with SPI or with the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question was put on hold in the EE section so I an posting it here because the reason was that it has something to do with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="17159" LastActivityDate="2016-07-08T22:11:32.057" Title="Arduino Audio Shield Problems" Tags="|shields|audio|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20468" PostTypeId="1" CreationDate="2016-02-09T03:21:50.973" Score="0" ViewCount="2592" Body="&lt;p&gt;I started off attempting to use the  IRRemote    Library and a VS1838B Sensor to capture the Daikin air condition signal.  I’ve read about the timing and in all honesty, I don’t think I can do it on my own so I looked to find the code others had created and adapt it to my own, trying their remote controls first thinking Daikin may only have a few sets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can’t confirm that will work as yet because I’ve only been able to find the code below but I’m not quite sure what is the best practice for ripping (stripping out the parts I don’t need) it apart.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I attempted to capture the IR codes, most of the time I get nothing at all.  My stereo remote is immediate displayed though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the good news,  based on Harizanov’s work, he’s mapped the ARC533 Remote,  which is the same model that I have.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My Model : FTM18NV2S&lt;/li&gt;&#xA;&lt;li&gt;Remote:  ARC533A55&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.daikin.co.th/en/product/smash/&quot; rel=&quot;nofollow&quot;&gt;Daikin - Smash&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;NV2S  (On the Inverter)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remote:  Doesn’t say anything of use&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.daikinac.com/content/residential/single-zone/15-series/&quot; rel=&quot;nofollow&quot;&gt;15-Series Wall Mount&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Code Here: &lt;a href=&quot;http://harizanov.com/2012/02/control-daikin-air-conditioner-over-the-internet/&quot; rel=&quot;nofollow&quot;&gt;Control Daikin air conditioner over the Internet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code here: &lt;a href=&quot;https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet&quot; rel=&quot;nofollow&quot;&gt;Github: mharizanov/Daikin-AC-remote-control-over-the-Internet&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone provide a recommendation on how I could trim up this code to try it?&lt;/p&gt;&#xA;" OwnerUserId="17161" LastEditorUserId="6936" LastEditDate="2016-02-09T04:15:44.473" LastActivityDate="2020-04-10T07:01:30.217" Title="Daikin Remote ARC" Tags="|remote-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20469" PostTypeId="1" AcceptedAnswerId="20498" CreationDate="2016-02-09T03:39:21.343" Score="0" ViewCount="1887" Body="&lt;p&gt;I'm in need of flexible pressure sensors that can read how much force is exerted on someone's foot while running (these sensors would be placed inside the shoe). Since pressure can often be three times the weight of the person, I need something fairly strong. Are there fairly cheap sensors that are available or hacks that could do the same thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11385" LastEditorUserId="11385" LastEditDate="2016-02-09T05:31:47.520" LastActivityDate="2016-02-09T17:14:23.043" Title="Are there flexible pressure sensors for Arduino that can measure forces of at least 600 lbs?" Tags="|sensors|project|components|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20470" PostTypeId="1" AcceptedAnswerId="20478" CreationDate="2016-02-09T03:47:44.483" Score="1" ViewCount="6815" Body="&lt;p&gt;I would like to detect how long the state on/off is going on for. Is there a way to do that? I would like to do that for two reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I would be able to make a very simple toggle button. (I know about the other way with the old value and new value).&lt;/li&gt;&#xA;&lt;li&gt;I can make the button being pressed for a long time be like a return button.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Anyone got any ideas?&lt;/p&gt;&#xA;" OwnerUserId="17162" LastEditorUserId="6936" LastEditDate="2016-02-09T04:16:30.090" LastActivityDate="2016-02-11T20:08:07.307" Title="Detect how long a push button is being pressed?" Tags="|programming|button|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20471" PostTypeId="2" ParentId="20470" CreationDate="2016-02-09T04:45:29.197" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;Note the time the switch is pressed (with &lt;code&gt;millis()&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Note the time the switch was released.&lt;/li&gt;&#xA;&lt;li&gt;When the switch is released calculate the difference. If it is a &quot;long&quot; time do one thing, otherwise do something else.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-09T04:45:29.197" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20472" PostTypeId="1" AcceptedAnswerId="20473" CreationDate="2016-02-09T04:51:33.347" Score="2" ViewCount="1281" Body="&lt;p&gt;When comparing the value of millis() numerous times per loop(), are there reasons for/against storing it in a variable once at the top of loop(), v.s.  calling millis() each time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most basic example code &quot;Blink Without Delay&quot; is written as such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  //...&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;    // save the last time you blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    // Do stuff&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't really she why the example code above bothers storing millis() in a variable &quot;currentMillis&quot; at all. (I realize that in such a simple program, there would be no noticeable difference.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I imagine that if I use a variable, the longer the duration of loop(), and the further down my use of the &quot;currentMillis&quot; variable, the more deviated the stored value will be.&lt;br&gt;&#xA;&lt;em&gt;I'm wondering the other ramifications of either method as well.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does calling millis() directly hog resources of any sort? If not, I imagine it would be better to not use a variable, so as to get a more accurate time value and save a bit of memory. &lt;/p&gt;&#xA;" OwnerUserId="4455" LastEditorUserId="4455" LastEditDate="2016-02-09T05:53:47.437" LastActivityDate="2016-02-09T05:53:47.437" Title="Should millis() be stored in a variable once each loop, or called for every reference?" Tags="|time|millis|timing|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20473" PostTypeId="2" ParentId="20472" CreationDate="2016-02-09T05:08:28.110" Score="4" Body="&lt;p&gt;The primary downside to calling a function each time is that it may take more CPU cycles to complete the overall loop. The difference in CPU cycles, if any, depends on the actual implementation of the function and how the compiler optimises the call. For low-CPU sketches, this difference is probably unnoticeable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, it is good programming practice to avoid calling a function more times than is necessary. Really the function should be called directly only if you have reasons to believe, based on desired timing and procedure order, that using the same return value in multiple places could create problems. In the example sketch given, there would be almost no functional difference between using a variable or calling the function inline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another advantage to using a variable is that you can give it a name that makes the code clearer to understand. In the example given, the relationship between &lt;code&gt;currentMillis&lt;/code&gt; and &lt;code&gt;previousMillis&lt;/code&gt; is very clear. In the case where a function returns a more complex object, such as a class or structure instance, using a variable (of the appropriate type) can be really useful since this would allow multiple members of the returned data to be accessed without calling the function multiple times. In fact, even in the given example, the function would have to be called twice since &lt;code&gt;currentMillis&lt;/code&gt; appears twice in the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as memory goes, an unsigned long uses very little.&lt;/p&gt;&#xA;" OwnerUserId="15303" LastActivityDate="2016-02-09T05:08:28.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20474" PostTypeId="2" ParentId="20426" CreationDate="2016-02-09T05:35:55.663" Score="0" Body="&lt;p&gt;I found the solution to my problem was this &lt;a href=&quot;https://raspberrypi.stackexchange.com/a/31298/29103&quot;&gt;answer&lt;/a&gt;, which works for me on both a normal laptop and Raspberry Pi without having to modify any Arduino hardware.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2016-02-09T05:35:55.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20475" PostTypeId="1" CreationDate="2016-02-09T05:58:11.170" Score="1" ViewCount="1723" Body="&lt;p&gt;I want to use 21 servo (&lt;a href=&quot;https://www.adafruit.com/product/155&quot; rel=&quot;nofollow&quot;&gt;SG5010&lt;/a&gt;) motors using Mega board. Is it possible to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possibility is all the servos will be operating at the same time, with average load of ~3.5 KG, and each using 1A, so 21 servos will use 21A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will be able to supply power? If yes then how do I go about it?&lt;/p&gt;&#xA;" OwnerUserId="17166" LastEditorUserId="6936" LastEditDate="2016-02-09T09:20:49.630" LastActivityDate="2016-05-09T14:03:24.727" Title="21 Servo on Mega?" Tags="|arduino-mega|power|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20477" PostTypeId="2" ParentId="20475" CreationDate="2016-02-09T07:21:01.267" Score="0" Body="&lt;p&gt;The Mega board will not be able to supply that much current, no. If you consult the schematic, you will see that the 5V regulator is rated for a maximum current of 800mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A computer PSU would be an appropriate power supply (a typical 350W PSU will happily supply &gt;30A on the 5V rail). Be aware that some PSUs have a minimum load; you may need to add a power resistor or other load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that if you want individual control of all the servos, the ATmega1280 only has 16 PWM outputs (IIRC), so you would need software PWM or an external PWM IC.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-02-09T07:21:01.267" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20478" PostTypeId="2" ParentId="20470" CreationDate="2016-02-09T07:22:46.750" Score="2" Body="&lt;p&gt;This needs a combination of patterns. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the button pin needs to be debounced. This can be done with the &quot;blink-without-delay&quot;-pattern where the button pin is sampled with a low period (40 ms in the example code below). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, a simple state-machine is needed to keep track of the button state but also if the return button action function, doReturnButton(), has already been called. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The button is assumed to be connected from GND to pin4. The button action function, doButton(), is called when the button is pushed (goes LOW). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 4;&#xA;const unsigned long debounceInterval = 40;&#xA;const unsigned long returnInverval = 400;&#xA;bool buttonState = true;&#xA;bool returnButtonState = false;&#xA;unsigned long buttonDownMillis = 0L;&#xA;&#xA;void doButton()&#xA;{&#xA;  Serial.print(buttonDownMillis);&#xA;  Serial.println(F(&quot;:doButton&quot;));&#xA;}&#xA;&#xA;void doReturnButton()&#xA;{&#xA;  Serial.print(buttonDownMillis);&#xA;  Serial.println(F(&quot;:doReturnButton&quot;));&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  while (!Serial);&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  unsigned long currentMillis = millis();&#xA;  static unsigned long previousMillis = 0L;&#xA;&#xA;  // Check if it is time to sample the button pin&#xA;  if (currentMillis - previousMillis &amp;gt;= debounceInterval) {&#xA;    previousMillis = currentMillis;&#xA;&#xA;    // Did the button change&#xA;    if (digitalRead(buttonPin) != buttonState) {&#xA;      buttonState = !buttonState;&#xA;&#xA;      // Was the button released&#xA;      if (buttonState) {&#xA;        returnButtonState = false;&#xA;      }&#xA;&#xA;      // Was the button pushed&#xA;      else {&#xA;        buttonDownMillis = currentMillis;&#xA;        returnButtonState = true;&#xA;        doButton();&#xA;      }&#xA;    }&#xA;&#xA;    // Check if button was pushed and time for return action&#xA;    else if (returnButtonState) {&#xA;      if (currentMillis - buttonDownMillis &amp;gt;= returnInverval) {&#xA;        returnButtonState = false;&#xA;        doReturnButton();&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does the code do?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It samples the button pin with a debounce interval.&lt;/li&gt;&#xA;&lt;li&gt;If the button state changes: &#xA;a. High to Low it calls the doButton() function and captures a timestamp. It also allows detect of return time interval. &#xA;b. Low to High. Return time interval is not allowed any more.&lt;/li&gt;&#xA;&lt;li&gt;It checks if the return time interval has elapsed and if so calls the doReturnButton() function. The detect is then not allowed any more.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The doButton() function is called when the button is pushed (transition high to low), only once. The doReturnButton() function is called if the return time limit exceeds and the button is still low. Both are only called once per push (transition high to low). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid the multiple transitions that occur when a button is pushed a debounce time period is used. The can also be done in hardware with a RC-circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With some abstraction it could be rewritten as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timemark.h&amp;gt;&#xA;&#xA;Timemark debounce(40);&#xA;Timemark buttonHold(400);&#xA;&#xA;const int buttonPin = 4;&#xA;bool buttonState;&#xA;&#xA;void doButton()&#xA;{&#xA;  Serial.println(F(&quot;doButton&quot;));&#xA;}&#xA;&#xA;void doReturnButton()&#xA;{&#xA;  Serial.println(F(&quot;doReturnButton&quot;));&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;  Serial.println(F(&quot;started&quot;));&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;  buttonState = digitalRead(buttonPin);&#xA;  debounce.start();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (debounce.expired()) {&#xA;    bool currentState = digitalRead(buttonPin);&#xA;    if (currentState != buttonState) {&#xA;      buttonState = currentState;&#xA;      if (buttonState) {&#xA;        if (buttonHold.expired())&#xA;          doReturnButton();&#xA;        else&#xA;          doButton();&#xA;        buttonHold.stop();&#xA;      }&#xA;      else {&#xA;        buttonHold.start();&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also demonstrates the callback on the release of the button. The &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Timemark&quot; rel=&quot;nofollow&quot;&gt;Timemark&lt;/a&gt; class hides all the time intervals, expire calculations, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-11T20:08:07.307" LastActivityDate="2016-02-11T20:08:07.307" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="20479" PostTypeId="1" AcceptedAnswerId="20544" CreationDate="2016-02-09T08:52:06.913" Score="2" ViewCount="493" Body="&lt;p&gt;Recently hit the dreaded 0x7000 / 28k~ AVRDUDE+LUFA limit.  It states everywhere this is because the bootloader uses 4KB, thus reducing the 32KB to 28KB.  Makes sense, except...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blank sketches on the 32U4 take nearly 4KB from the get go, which I thought was attributed to the bootloader?  So now I'm confused.  If I'm losing 4KB off the top, and 4KB off the bottom - is the bootloader 8KB?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:  In case the above is unclear, it appears my sketches only have ~24k of the 32k available to them.  Is this expected behavior?&lt;/p&gt;&#xA;" OwnerUserId="17170" LastEditorUserId="17170" LastEditDate="2016-02-10T20:35:38.963" LastActivityDate="2016-02-10T20:43:48.733" Title="ATmega32U4 (Leonardo/Pro Micro) bootloader, 8K rather than 4K?" Tags="|arduino-leonardo|bootloader|avrdude|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20480" PostTypeId="2" ParentId="20475" CreationDate="2016-02-09T09:26:17.407" Score="2" Body="&lt;p&gt;There is a &lt;a href=&quot;http://www.ebay.co.uk/itm/Mega-Sensor-Shield-V2-0-V2-Arduino-ATMEGA-2560-R3-1280-ATmega8U2-ATMEL-AVR-/391374794831&quot; rel=&quot;nofollow noreferrer&quot;&gt;servo/sensor shield for the Arduino Mega&lt;/a&gt; that can control up to 54 servos. This shield will only fit the Mega, unlike the usual 14 servo Arduino shield, which is shaped to fit most Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/l5Kz7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/l5Kz7.jpg&quot; alt=&quot;Photo of Arduino Mega servo shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an easier to view diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J3aAn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J3aAn.jpg&quot; alt=&quot;Diagram of Arduino Mega servo shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible, and &lt;strong&gt;advisable&lt;/strong&gt;, to supply power via the screw terminals from an external power source, rather than use the Arduino's own power. Even just one servo can have difficulty in working from the Arduino's on board power supply, especially if just using USB to power the Arduino. However, even with the use of an external power source powering the shield, I have my doubts as to whether the shield could support 21A without burning out. Someone may be able to clarify this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find this page, &lt;a href=&quot;https://arduino-info.wikispaces.com/SensorShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Servo Shield&lt;/a&gt;, useful:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;MEGA Sensor Shield&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Arduino MEGA has many more I/O pins (54 Digital pins and 16 Analog&#xA;  pins)than a standard Arduino. This shield also has connectors&#xA;  specifically for some external devices like an SD Card, Radio&#xA;  communications (Bluetooth and others). It also has an option to power&#xA;  the &quot;V&quot; pins on all the Digital I/O 3-pin groups from an external&#xA;  power supply instead of the Arduino +5V. This is good for large&#xA;  numbers of servos etc. The &quot;Analog&quot; 3-pin groups still use the Arduino&#xA;  +5V which is better from an electrical noise perspective. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This version has two options of +5V supply to all the &quot;V&quot; pins: &lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Jumper on: +5 comes&#xA;  from the Arduino. Should be limited to about 300 ma &lt;/li&gt;&#xA;  &lt;li&gt;Jumper off: +5 (or&#xA;  other appropriate voltage) comes from an external supply connected to&#xA;  the blue terminal strip. External power Ground must also be connected&#xA;  to the blue terminal strip.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Using an external supply allows more current than the Arduino or Mega&#xA;  can supply, such as current for control of many servos or relays, and&#xA;  other attached devices. Usually this is +5V because most external&#xA;  devices require it. It is possible to use +6 volts if ALL the attached&#xA;  devices are the same such as Servos with that rating.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="6936" LastEditDate="2016-02-09T09:34:12.957" LastActivityDate="2016-02-09T09:34:12.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20481" PostTypeId="1" CreationDate="2016-02-09T10:49:10.557" Score="-1" ViewCount="707" Body="&lt;p&gt;I'm using an Arduino shield connected to an Arduino Uno for sending text messages. I'm using one of the in built examples from the Arduino IDE for sending SMS by name - &lt;code&gt;sendsms&lt;/code&gt; in the GSM examples. However, the code doesnt work at all... it keeps hanging at the line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (gsmAccess.begin(PINNUMBER) == GSM_READY)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and never goes beyond it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't keep any pincode for my SIM card. please help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gi77X.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gi77X.jpg&quot; alt=&quot;Screenshot of code&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17176" LastEditorUserId="6936" LastEditDate="2016-02-09T21:17:45.540" LastActivityDate="2023-02-18T21:07:20.873" Title="SendSMS example sketch hangs at PINMUNBER if statement" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20482" PostTypeId="1" AcceptedAnswerId="20495" CreationDate="2016-02-09T11:00:54.467" Score="0" ViewCount="4847" Body="&lt;p&gt;I am newbie, I have never used MQTT before, so I have some questions.&#xA;Here is my topology. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have several sensors (Arduino Pro Mini + NRF24L01) and main server/handler(Arduino Mega + Ethernet Shield or ESP module) to receive/send messages to/from sensor nodes, so all network is build on NRF24L01 (NRF24 Mesh library). But I need to be able to communicate with all these sensors from outside over the internet. Previously I implemented simple socket communication.&lt;br&gt;&#xA;I have recently discovered MQTT protocol and it is awesome. I want to implement communication between main server and outside world using it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What part of my topology should implement broker in? I think it should be on the main server (Arduino Mega) but again communication between main server/master server is implemented via NRF24L01 modules and custom protocol.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or in my case is better to use HTTP communication with master server? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Please explain this topic and suggest how to implement this correctly in my case.&lt;/p&gt;&#xA;" OwnerUserId="16955" LastEditorUserId="6936" LastEditDate="2016-03-25T11:04:00.930" LastActivityDate="2016-03-25T11:04:00.930" Title="MQTT broker and Arduino + Sensors NRF24L01" Tags="|arduino-mega|sensors|ethernet|arduino-pro-mini|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20484" PostTypeId="2" ParentId="20461" CreationDate="2016-02-09T11:49:07.300" Score="4" Body="&lt;p&gt;If you want to get maintained (automatically updated) version of Arduino IDE then you install if from a package repository with its dependencies e.g. using &lt;code&gt;apt-get&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get update&#xA;sudo apt-get install arduino arduino-core&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this way you get a very old version (currently &lt;em&gt;1.0.5&lt;/em&gt;). Obviously, it is not updated too often if at all.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you already installed from the package repository via apt-get you can uninstall the package and its dependencies like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get remove arduino arduino-core&#xA;sudo apt-get autoremove&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Better way is to download and install Arduino IDE yourself.&lt;/strong&gt; This way Arduino software won't automatically be updated, so you should check Arduino website every now and then and download a new version if one is available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open a terminal window (e.g. by pressing &lt;em&gt;CTRL-ALT-T&lt;/em&gt;), and run &lt;code&gt;uname -m&lt;/code&gt; to check if you are running 32 bit or 64 bit platform:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uname -m&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x86_64 ==&amp;gt; 64-bit kernel&#xA;i686   ==&amp;gt; 32-bit kernel&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Go to Arduino Download page on &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Download the Arduino Software&lt;/a&gt; and download the 32 bit or 64 bit version, depending on the Ubuntu version installed on your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a terminal window extract the package and move it to your preferred location, e.g. &lt;code&gt;/opt&lt;/code&gt;. You need sudo rights to move it to &lt;code&gt;/opt&lt;/code&gt;. Finally, run the install script if you want to start the IDE graphically (adds desktop icon, MIME type, default application for &lt;code&gt;.ino&lt;/code&gt;). See the example commands below for installing the latest 32 bit version as of the time of writing to &lt;code&gt;/opt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cd ~/Downloads&#xA;tar xf arduino-1.6.7-linux32.tar.xz&#xA;sudo mv arduino-1.6.7 /opt&#xA;/opt/arduino-1.6.7/install.sh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also start the IDE from the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/opt/arduino-1.6.7/arduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16298" LastEditorUserId="16298" LastEditDate="2016-02-10T06:09:10.600" LastActivityDate="2016-02-10T06:09:10.600" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20486" PostTypeId="2" ParentId="20469" CreationDate="2016-02-09T13:27:12.963" Score="1" Body="&lt;p&gt;Sensors such as you describe are usually called &quot;Load Cell&quot;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the 600 pound weight, I haven't found any &quot;flexible&quot; load cells. A sensor would have to be quite robust.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flexible might not be the best answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.futek.com/product.aspx?t=load&quot; rel=&quot;nofollow noreferrer&quot;&gt;This load cell page&lt;/a&gt; has quite a range of load cells, several thousand pounds, also not very inexpensive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might be difficult to install in running shoes :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/S0bFJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/S0bFJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-02-09T13:27:12.963" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20488" PostTypeId="1" AcceptedAnswerId="20490" CreationDate="2016-02-09T14:26:40.067" Score="0" ViewCount="62" Body="&lt;p&gt;Sorry if there is an obvious answer to this - I'm pretty new at Arduino and electronics. I've searched a bunch, but I think I'm too vague - and don't know what terms to look for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a pretty simple project using a 3.3v Arduino Pro Mini (&lt;a href=&quot;https://www.adafruit.com/products/2377&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2377&lt;/a&gt;) and a 12v button/LED (&lt;a href=&quot;https://www.adafruit.com/products/1185&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1185&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to give the LED the full 12v so the light is a bright as possible. The system will be battery operated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question is&lt;/strong&gt;: Do I &lt;em&gt;need&lt;/em&gt; a 12v power supply or can I use a 3.7v power supply and upgrade it somehow? I know I can power the LED with 3.7v but then it's really dim. Is there a way to &quot;upgrade&quot; the 3.7v to 12v? I would assume this would draw more power and drain the battery faster, but I think that would be ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm hoping to get away with a 3.7v power supply because I want to use a lithium ion polymer battery (&lt;a href=&quot;https://www.adafruit.com/products/328&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/328&lt;/a&gt;) - since it's small and rechargeable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems like if I go with 12v source then I need a much bigger battery pack, and I'm hoping to keep the project small. Not sure if it would help to know, but I only need the device to run for 4+ hours between charges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing people will say to go with 12v since the Pro Mini can downgrade the 12v supply so there'd be less parts I have to deal with (I can already make this work). But, again, I was hoping to get away with a small rechargeable power supply. Or, are there good, small 12v batteries - I can't seem to find any on Adafruit or SparkFun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any recommendations? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="2885" LastActivityDate="2016-02-09T14:48:00.933" Title="Power converting - up or down?" Tags="|power|electricity|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20489" PostTypeId="2" ParentId="20488" CreationDate="2016-02-09T14:44:12.603" Score="1" Body="&lt;p&gt;Basically you have two choices. There is a third, but you don't wan to take that route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third route is to directly power the system with 12V and rely on the Arduino's regulator to drop it to the right voltage for the Arduino. That is very very inefficient and wasteful, and your battery won't last very long - plus the regulator will get hot. So don't even consider that option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the two sensible options - start with 3.7V and step it up to 12V using a &lt;em&gt;boost regulator&lt;/em&gt;, or start at 12V and step it down using a &lt;em&gt;buck regulator&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which of those will be the easiest and most efficient?  Well, there's not much to choose between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With either of those solutions you are converting voltage and current. With a buck regulator you are converting voltage into current, and with a boost regulator you are converting current into voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start at 12V and step it down yes you need more cells, but each cell can be smaller since each one will have to supply less current.  With 3.7V and stepping up you will have just one cell, but it will need to be bigger since it will have to supply more current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a charging perspective it is easier to charge a single cell since you don't have to worry about cell balancing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a price and availability point of view, buck (step-down) regulators are cheaper and easier to get hold of on places like eBay than boost (step-up) regulators as pre-built circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really the choice is yours - 12V (well, 11.4V it would really be - 3S LiIon / Li-Poly) and buck regulator, or 3.7V and boost regulator. Both will work, both will be about as efficient as each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally there are boost regulators specifically designed for driving LEDs from battery sources - you might like to look around to see what is available in that way.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-09T14:44:12.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20490" PostTypeId="2" ParentId="20488" CreationDate="2016-02-09T14:48:00.933" Score="3" Body="&lt;p&gt;Since your project is to be battery powered, you want to make your system as efficient as is reasonable.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I am going to take an approach that ends up improving the efficiency of your project.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The button you describe in your link states :  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This button has a domed red plastic cover with a black retaining ring around it. There's an optional LED included  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Further, the LED included has a &quot;built in resistor&quot;, so that the LED can operate from 12 volts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you would have to install the &quot;optional LED&quot;,  why not purchase a Red LED that operates from lower voltage. You will still need a resistor but you won't need to have a voltage converter.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example  :  Their LED probably has a 2 volt LED (approximate) that operates at perhaps 20 mA).  This would require a 500 ohm resistor (which they incorporate into the LED).  The power loss (wasted) in the resistor is 0.2 watts (200 mW).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Improved Example :  With LED of about 2 volts operating from 3.3 volt power source.  This would require a 68 ohm resistor.  The power loss in the resistor would be 0.027 watts (27 mW).  A substantial improvement in efficiency.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The manufacturer of the button does not give specifications for the LED (the one with the resistor included).  You should connect their LED to a 12 volt power supply and measure the current drawn.  It is possible their LED draws more current than I have shown in the examples.  This would require a re-calculation of the resistor values.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But in any case, the improvement in efficiency will still exist.  &lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-02-09T14:48:00.933" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20491" PostTypeId="1" CreationDate="2016-02-09T14:53:26.173" Score="1" ViewCount="150" Body="&lt;p&gt;I'm planning to buy SIM900A GSM/GPRS Shield for Arduino Uno. I wanted to create an application that sends SMS to a list of mobile numbers, let's say 1000 mobile numbers. Is it applicable to use SIM900A GSM/GPRS shield for bulk messaging? Did anyone of you tested the sms transaction sent per second/minute using this shield? I accept any suggestion that would be helpful. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="17183" LastActivityDate="2016-02-09T14:53:26.173" Title="SIM900A GSM/GPRS Shield Transaction per minute" Tags="|arduino-uno|shields|gsm|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20492" PostTypeId="1" CreationDate="2016-02-09T15:01:29.140" Score="2" ViewCount="391" Body="&lt;p&gt;I am trying to use a moisture sensor to identify the moisture value of my plants. (As every one does.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor was connected to VCC all the time and my battery goes empty after a short time. So I decided to connect power only at the time I read from the sensor (on the arduino with &lt;code&gt;digitalWrite(moisture_vcc, HIGH)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To problem is that the values were too high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm wondering if these kind of sensors need a &quot;warm-up time&quot;? And If so, how long is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any experience with it?&lt;/p&gt;&#xA;" OwnerUserId="17134" LastEditorUserId="6936" LastEditDate="2016-02-09T21:13:00.930" LastActivityDate="2016-02-09T23:15:10.843" Title="Does a moisture sensor need warm-up time?" Tags="|sensors|power|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20493" PostTypeId="2" ParentId="20481" CreationDate="2016-02-09T15:01:57.180" Score="0" Body="&lt;p&gt;Try this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial gsm(2,3);&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  gsm.begin(9600);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  while (gsm.available() &amp;gt; 0)&#xA;    Serial.write(gsm.read());&#xA;  while (Serial.available() &amp;gt; 0)&#xA;    gsm.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sketch will help troubleshoot exactly what's wrong with your setup, without the clutter of a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the shield's TX pin to Arduino pin 2 and the shield's RX pin to Arduino pin 3. Ensure that all GNDs are connected. Upload the sketch. Set your serial monitor to &lt;code&gt;BOTH NL &amp;amp; CR&lt;/code&gt; and the baud rate to 9600. Enter &lt;code&gt;AT&lt;/code&gt; from the serial monitor. If you recieve &lt;code&gt;OK&lt;/code&gt;, it means comms have been established with the shield. If you receive gibberish, change the SoftwareSerial baud rate to values from 19200, 57600, etc. until you get a legible response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then send the command &lt;code&gt;AT+CREG?&lt;/code&gt; to check the SIM's registration status. If you get something like &lt;code&gt;+CREG: *, 1&lt;/code&gt; or &lt;code&gt;+CREG: *, 5&lt;/code&gt; (* means 'dont care'), then your SIM has been registered on the network. Report your results here.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-09T15:01:57.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20494" PostTypeId="1" AcceptedAnswerId="20496" CreationDate="2016-02-09T15:59:03.927" Score="4" ViewCount="1172" Body="&lt;p&gt;I have a general question regarding the power-supply of the electronic components, that are attached to an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I have a device that operates at voltages between 3,3V and 5V (&lt;a href=&quot;http://www.emartee.com/product/41777/RS232%20TTL%20Converter%20MAX3232%20Module&quot; rel=&quot;nofollow&quot;&gt;e.g. this RS232 to ttl converter&lt;/a&gt;), what is the best way to connect it with the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Connect 3.3V or 5V power supply between VCC and GND&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know, that you can not draw as much current out of the 3,3V Pin like on the 5V Pin. But what if I don't need much current anyways (like in the linked example)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What ware the advantages / disadvantages of connecting it to 3.3V and 5V?&lt;/p&gt;&#xA;" OwnerUserId="15493" LastActivityDate="2016-02-09T16:28:02.307" Title="Do I use 3,3V or 5V, when device supports both?" Tags="|power|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20495" PostTypeId="2" ParentId="20482" CreationDate="2016-02-09T16:14:29.493" Score="1" Body="&lt;p&gt;The normal topology is sensor nodes publishing topic-data on a MQTT broker. And the broker distributing updates to subscribing clients. The MQTT broker is responsible for several levels of QoS (Quality of Service) such as storing attribute/topic-values (persistence), checking that messages are delivered, etc. Typically the broker runs on a server with disk, multiple network connections, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possible solution is to send sensor messages to a bridge that translates and publishes the message on the MQTT broker. The sensors may use a simple cheap local wireless network (such as based on NRF24L01) and the bridge would publish over IP (Ethernet, WiFi, etc) to the MQTT broker. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some sensors/actuators might need configuration/control (alarm thresholds, resolution, etc). In this case they need to subscribe to messages (topic updates) from the MQTT broker. Again the bridge needs to provide the subscription and message translation/routing back to the sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last, topics naming is a challenge as the bridge should be transparent in the naming structure but still configurable. The bridge configuration (e.g. network address/topic translation) could also be handled as a bridge topic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-09T16:14:29.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20496" PostTypeId="2" ParentId="20494" CreationDate="2016-02-09T16:28:02.307" Score="7" Body="&lt;p&gt;Using the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/max3232.pdf&quot; rel=&quot;noreferrer&quot;&gt;MAX3232 data sheet&lt;/a&gt; , which is what the TTL Converter has on it's board :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main difference between using 3.3v or 5v is on the receiver data line &quot;R&quot; (or Rout as it is called on the MAX3232).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply put, you want to power the TTL converter from the same voltage as your Arduino is using (3.3v or 5v). Meaning the voltage that your I/O pins will put out and accept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The received data line R will go between 0 volts and Vcc.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would NOT want to power the TTL converter at 5 volts if you are using the converter for a 3.3v Arduino, as the received data line would go to 5 volts when high. Actually Vcc - 0.1 volts (typ.)  (5 - .1 = 4.9)  as per this specification : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ARWv9.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ARWv9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you power the TTL converter from 3.3 volts, the received data line (Rout) switches between 0v and 3.3v   as shown here :  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lVVRi.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lVVRi.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;   &lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-02-09T16:28:02.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20497" PostTypeId="1" AcceptedAnswerId="20510" CreationDate="2016-02-09T16:59:27.567" Score="1" ViewCount="46" Body="&lt;p&gt;My code is supposed to generate a random number and then display it in binary using four LEDs. After you press it, it waits for two seconds before checking your number of pushbutton presses to see if they equal the random number, and it turns the green/red LED on accordingly and restarts the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't do that, and also it counts multiple pushes if you keep the button pressed in, since it reads the pushbutton as being &quot;on&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//VARIABLES:&#xA;const int ledPin1 = 2;&#xA;const int ledPin2 = 3;&#xA;const int ledPin3 = 4;&#xA;const int ledPin4 = 5;&#xA;const int buttonPin = 6;        //push button&#xA;const int ledPincorrect = 8;   //green LED that switches on for correct answer&#xA;const int ledPinfalse = 9;    //red LED that switches on for wrong answer&#xA;&#xA;&#xA;int randomNumber = 0;&#xA;int buttonState = HIGH;&#xA;int buttonPushCounter = 0;             //counter for button presses&#xA;int lastButtonState = HIGH;             //previous state of the button&#xA;int getal;&#xA;int i;                              //for the ConvertBinary function, i serves as a variable for the LED's&#xA;unsigned long Timer;               //Timer, switches on after buttonstate = LOW, and after 2 seconds the game restarts&#xA;long lastDebounceTime = 0;         // the last time the output pin was toggled&#xA;long debounceDelay = 50;    // the debounce time; increase if the output flickers&#xA;int ledState = HIGH;&#xA;int remember;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(ledPin3, OUTPUT);&#xA;  pinMode(ledPin4, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(ledPincorrect, OUTPUT);&#xA;  pinMode(ledPinfalse, OUTPUT);&#xA;  Serial.begin(9600);&#xA;  randomSeed(analogRead(0));&#xA;  buttonState = digitalRead(buttonPin);&#xA;  Timer = millis(); // unsigned long Timer = millis();&#xA;&#xA;}&#xA;void loop()&#xA;{&#xA;  if (randomNumber == 0) {&#xA;    Serial.print(&quot;lets start with random&quot;);&#xA;    getal = random(1, 16);&#xA;    Serial.print(&quot;random is: &quot;);&#xA;    Serial.println(getal);&#xA;    randomNumber = 1;&#xA;  }&#xA;&#xA;&#xA;   int remember = getal;&#xA;   for (int i = 2; i &amp;lt; 6; i++) {&#xA;   remember = remember / 2;&#xA;      if (remember % 2 == 1){&#xA;       digitalWrite (i, HIGH);&#xA;      }&#xA;     else ((digitalWrite(i, LOW)));&#xA;    }&#xA;&#xA;&#xA;    // reading the button state&#xA;&#xA;&#xA;&#xA;    // read the state of the switch into a local variable:&#xA;    int reading = digitalRead(buttonPin);&#xA;&#xA;    if (reading != lastButtonState) {&#xA;      lastDebounceTime = millis();&#xA;      if (reading == LOW) {                    // if (reading == LOW) ????&#xA;        buttonPushCounter++;&#xA;        Serial.println(&quot;on&quot;);&#xA;        Serial.print(&quot;number of button pushes:  &quot;);&#xA;        Serial.println(buttonPushCounter);&#xA;        Timer = millis();&#xA;        lastButtonState = buttonState;&#xA;&#xA;&#xA;      } else {&#xA;      // if the current state is LOW then the button wend from on to off:&#xA;      Serial.println(&quot;off&quot;);&#xA;    }&#xA;&#xA;&#xA;      if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;    if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;      lastButtonState = reading;&#xA;    }&#xA;&#xA;&#xA;    if (Timer &amp;gt;= 2000UL) {&#xA;      if (buttonPushCounter == getal) {&#xA;        digitalWrite(ledPincorrect, HIGH);&#xA;        digitalWrite(ledPinfalse, LOW);&#xA;        digitalWrite(ledPin1, LOW);&#xA;      digitalWrite(ledPin2, LOW);&#xA;      digitalWrite(ledPin3, LOW);&#xA;      digitalWrite(ledPin4, LOW);&#xA;      randomNumber = 0;&#xA;      buttonPushCounter = 0;&#xA;      }&#xA;      else {&#xA;        digitalWrite(ledPinfalse, HIGH);&#xA;        digitalWrite(ledPincorrect, LOW);&#xA;        digitalWrite(ledPin1, LOW);&#xA;      digitalWrite(ledPin2, LOW);&#xA;      digitalWrite(ledPin3, LOW);&#xA;      digitalWrite(ledPin4, LOW);&#xA;      randomNumber = 0;&#xA;      buttonPushCounter = 0;&#xA;      }&#xA;}&#xA;&#xA;    }&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="user16934" LastEditorUserId="6936" LastEditDate="2016-02-09T21:19:37.313" LastActivityDate="2016-02-09T21:19:37.313" Title="What is preventing my code from checking the number of pushbutton values for a correct/wrong answer?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20498" PostTypeId="2" ParentId="20469" CreationDate="2016-02-09T17:14:23.043" Score="0" Body="&lt;p&gt;As you are presumably measuring changing (dynamic) loads, you could consider a piezo electric sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the simplest, use a piezo element usually sold as a buzzer (make sure you get the plain element with no electronics included, some 'buzzers' also have drive circuitry).&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/fqvSV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fqvSV.jpg&quot; alt=&quot;Piezo element&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will give you a voltage pulse proportional to applied pressure, which might give you the precision that you need, and is very small and light to insert in a shoe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://electronics.stackexchange.com/questions/18048/glowing-pressure-plate&quot;&gt;this question&lt;/a&gt; for a similar solution (and the above image!)&lt;/p&gt;&#xA;" OwnerUserId="17186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-09T17:14:23.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20501" PostTypeId="1" AcceptedAnswerId="20577" CreationDate="2016-02-09T18:10:45.463" Score="4" ViewCount="5471" Body="&lt;p&gt;Are there sensors that can detect the color of an LED?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on an Arduino project that needs to detect the color of an LED on an external device. I am trying to identify a light sensor that can be connected to the Arduino's input that can tell me the color of light the LED is currently emitting. The LED is capable of displaying red, green and yellow.&lt;/p&gt;&#xA;" OwnerUserId="17189" LastActivityDate="2016-02-11T21:53:44.960" Title="Are there sensors that can detect the color of an LED?" Tags="|sensors|led|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20502" PostTypeId="2" ParentId="18903" CreationDate="2016-02-09T18:16:13.263" Score="-1" Body="&lt;p&gt;Here is how to send commands to an ESP8266, without using an FTDI Programmer (NOTE: the IC used is LM117 (5V to 3.3v) IC for level shifting.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iDPPb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iDPPb.jpg&quot; alt=&quot;ESP8266 connection diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17192" LastEditorUserId="6936" LastEditDate="2016-02-09T20:14:30.880" LastActivityDate="2016-02-09T20:14:30.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20503" PostTypeId="1" CreationDate="2016-02-09T19:30:46.977" Score="5" ViewCount="8300" Body="&lt;p&gt;I bought a &lt;a href=&quot;http://www.ebay.com/itm/L293D-Motor-Drive-Shield-Expansion-Board-For-Arduino-Duemilanove-Mega-UNO-/221798329172&quot; rel=&quot;noreferrer&quot;&gt;L293D motor driver shield&lt;/a&gt; and have used it with a pre-made sketch for driving a pair of stepper motors, but I'm not familiar with its capabilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/MarginallyClever/Makelangelo-firmware/releases/tag/1.0.2&quot; rel=&quot;noreferrer&quot;&gt;sketch&lt;/a&gt; I've used so far doesn't use microstepping when it's set up for this shield (though it does use it with the Adafruit shield).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done some searching, and it's not clear if the L293D chips on the shield can do microstepping, and if so, how.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are L293D chips (and thus the motor driver shield that uses them) capable of microstepping? If so, how can I add this capability into my sketch?&lt;/p&gt;&#xA;" OwnerUserId="3720" LastActivityDate="2016-03-27T18:00:36.720" Title="Can an L293D motor driver shield do microstepping?" Tags="|arduino-motor-shield|stepper|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20505" PostTypeId="1" AcceptedAnswerId="20507" CreationDate="2016-02-09T19:41:17.870" Score="1" ViewCount="1687" Body="&lt;p&gt;I am new to arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does this not work the way it's supposed to?&#xA;&lt;br&gt;Shouldn't it block all interrupts for 3secs after it received one from digi pin 2?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I accomplish this:&#xA;Running a method whenever the value on this pin changes, execute it and then listen for more interrupts from that pin?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  attachInterrupt(digitalPinToInterrupt(2), test, CHANGE);&#xA;}&#xA;&#xA;int i = 0;&#xA;&#xA;void loop(){}&#xA;&#xA;void test(){&#xA;  noInterrupts();&#xA;  Serial.println(&quot;Interrupt registered - waiting &quot; + i);&#xA;  delay(3000);&#xA;  Serial.println(&quot;done waiting!&quot; + i);&#xA;  i++;&#xA;  interrupts();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16302" LastActivityDate="2016-02-10T12:11:16.923" Title="Cannot disable interrupts" Tags="|arduino-nano|interrupt|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20506" PostTypeId="2" ParentId="20501" CreationDate="2016-02-09T19:46:19.123" Score="3" Body="&lt;p&gt;You can use an LED as a light sensor - &lt;a href=&quot;http://www.instructables.com/id/LEDs-as-light-sensors/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/LEDs-as-light-sensors/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, LEDs should be most sensitive to the frequency it emits - if this is true, the same type of red/green/yellow LED would be best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how sensitive this will be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you control the &quot;external device&quot;, then you could get much better accuracy by blinking the LED at very high rates (not visible to the human eye). Or, if you can get at the legs of the LED, you can tap into the signal directly (you should use an opto-isolator - even if powered at a few volts, the ground of your project may be different from the ground of the external device, causing 100s of volts to run through your Arduino - not good!).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-02-09T19:46:19.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20507" PostTypeId="2" ParentId="20505" CreationDate="2016-02-09T19:59:22.787" Score="2" Body="&lt;p&gt;You could achieve that by this simple rewrite:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  attachInterrupt(digitalPinToInterrupt(2), test, CHANGE);&#xA;}&#xA;&#xA;volatile bool changed = false;&#xA;int i = 0;&#xA;&#xA;void loop() {&#xA;  if (!changed) return;&#xA;  Serial.print(F(&quot;Interrupt registered - waiting &quot;));&#xA;  Serial.println(i);&#xA;  delay(3000);&#xA;  Serial.print(F(&quot;done waiting &quot;));&#xA;  Serial.println(i);&#xA;  i += 1;&#xA;  changed = false;&#xA;  clearInterrupt(digitalPinToInterrupt(2));&#xA;  attachInterrupt(digitalPinToInterrupt(2), test, CHANGE);&#xA;}&#xA;&#xA;void test() {&#xA;  changed = true;&#xA;  detachInterrupt(digitalPinToInterrupt(2));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The interrupt service routine (ISR), test(), is really short and does not call functions that actually need interrupts to work (e.g. delay(), Serial). Please see Nick Gammon's comment below on clearInterrupt(), i.e. EIFR = bit (INTF0); &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative rewrite is to use the BlinkWithDelay-pattern and a somewhat more complex state-machine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile bool changed = false;&#xA;bool waiting = false;&#xA;&#xA;const unsigned long waitIntervalMillis = 3000UL;&#xA;unsigned long waitStartMillis = 0L;&#xA;&#xA;int i = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  attachInterrupt(digitalPinToInterrupt(2), test, CHANGE);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Check for change&#xA;  if (!changed) return;&#xA;&#xA;  // Check for change before wait interval&#xA;  if (!waiting) {&#xA;    Serial.print(F(&quot;Interrupt registered - waiting &quot;));&#xA;    Serial.println(i);&#xA;    waiting = true;&#xA;    waitStartMillis = millis();&#xA;  }&#xA;&#xA;  // Check if wait interval has expired&#xA;  else {&#xA;    unsigned long currentMillis = millis();&#xA;    if ((currentMillis - waitStartMillis) &amp;gt;= waitIntervalMillis) {&#xA;      Serial.print(F(&quot;done waiting &quot;));&#xA;      Serial.println(i);&#xA;      i += 1;&#xA;      changed = false;&#xA;      waiting = false;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void test() {&#xA;  changed = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A third rewrite is possible. Assuming that the pin is connected to a push button, the interrupt handler can be replaced by simply reading the pin with a low frequency (for debouncing). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-10T12:11:16.923" LastActivityDate="2016-02-10T12:11:16.923" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20508" PostTypeId="2" ParentId="20505" CreationDate="2016-02-09T20:02:49.527" Score="1" Body="&lt;p&gt;Probably your biggest problem is that &lt;code&gt;delay()&lt;/code&gt; cannot be used inside interrupt service routines (ISR's) and it doesn't work if interrupts are turned off because it uses interrupts to function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ISR's should be as short as possible, because they stop normal operation of the device while they execute. A good ISR will set a few variables, and then return, while the main program loop checks the state of those variables and actually does stuff. &lt;a href=&quot;https://arduino.stackexchange.com/a/20507/3720&quot;&gt;Mikael Patel's answer&lt;/a&gt; shows how you can rewrite your sketch to do this.&lt;/p&gt;&#xA;" OwnerUserId="3720" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-02-09T20:02:49.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20509" PostTypeId="2" ParentId="20501" CreationDate="2016-02-09T20:08:22.427" Score="3" Body="&lt;p&gt;There are a few different things you can do to detect a color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino starter kit that I got when I first got into Arduino had some photoresistors plus some colored films. One of the projects in the project book had you put a different color film over each photoresistor, so that only that color of light would hit the sensor. You could do something like that if you only need to check for a small number of distinct colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also a wide array of color sensors and sensor modules available (just search your favorite online store for &quot;color sensor&quot; or &quot;arduino color sensor&quot;), which will allow for far more detailed and precise color readings, but at a higher price point.&lt;/p&gt;&#xA;" OwnerUserId="3720" LastActivityDate="2016-02-09T20:08:22.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20510" PostTypeId="2" ParentId="20497" CreationDate="2016-02-09T20:16:46.807" Score="1" Body="&lt;p&gt;Let us start with the simplest issue in your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Timer = millis();&#xA;...&#xA;if (Timer &amp;gt;= 2000UL) {&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After 2000 ms this is always true (for about 49 days)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please format your code if you expect anybody to take the time to read it and help. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-09T20:16:46.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20512" PostTypeId="2" ParentId="16265" CreationDate="2016-02-09T22:20:40.200" Score="2" Body="&lt;p&gt;I have cobbled together, from the library examples, a program to log temperature and humidity to an MQTT server. The SSID/password, MQTT server and port, and the MQTT publish path can all be set at run time. Once they are set, the device will remember and re-use the settings next time it boots.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Arduino IDE to program an ESP8266-01. It, in turn, talks to a DHT11 sensor for temperature and humidity data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is found at &lt;a href=&quot;https://github.com/PabluskiNC/TempHumidityLogger&quot; rel=&quot;nofollow&quot;&gt;https://github.com/PabluskiNC/TempHumidityLogger&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;FS.h&amp;gt;                   //this needs to be first, or it all crashes and burns...&#xA;&#xA;    #include &quot;DHT.h&quot;&#xA;    #define DHTPIN 2&#xA;    #define DHTTYPE DHT11&#xA;    DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;    #include &amp;lt;ESP8266WiFi.h&amp;gt;          //https://github.com/esp8266/Arduino&#xA;&#xA;    //needed for library&#xA;    #include &amp;lt;DNSServer.h&amp;gt;&#xA;    #include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;    #include &amp;lt;WiFiManager.h&amp;gt;          //https://github.com/tzapu/WiFiManager&#xA;&#xA;    #include &amp;lt;ArduinoJson.h&amp;gt;          //https://github.com/bblanchon/ArduinoJson&#xA;&#xA;    #include &amp;lt;PubSubClient.h&amp;gt;&#xA;    WiFiClient espClient;&#xA;    PubSubClient client(espClient);&#xA;    long mqtt_lastMsg = 0;&#xA;    char mqtt_msg[50];&#xA;    int  mqtt_value = 0;&#xA;&#xA;    //define your default values here, if there are different values in config.json, they are overwritten.&#xA;    char mqtt_server[40];&#xA;    char mqtt_port[6] = &quot;1883&quot;;&#xA;    char mqtt_topic[34] = &quot;OutTopic&quot;;&#xA;&#xA;    //flag for saving data&#xA;    bool shouldSaveConfig = false;&#xA;&#xA;    //callback notifying us of the need to save config&#xA;    void saveConfigCallback () {&#xA;      Serial.println(&quot;Should save config&quot;);&#xA;      shouldSaveConfig = true;&#xA;    }&#xA;&#xA;&#xA;    void setup() {&#xA;      // put your setup code here, to run once:&#xA;      Serial.begin(115200);&#xA;      Serial.println();&#xA;&#xA;      //clean FS, for testing&#xA;      //SPIFFS.format();&#xA;&#xA;      //read configuration from FS json&#xA;      Serial.println(&quot;mounting FS...&quot;);&#xA;&#xA;      if (SPIFFS.begin()) {&#xA;        Serial.println(&quot;mounted file system&quot;);&#xA;        if (SPIFFS.exists(&quot;/config.json&quot;)) {&#xA;          //file exists, reading and loading&#xA;          Serial.println(&quot;reading config file&quot;);&#xA;          File configFile = SPIFFS.open(&quot;/config.json&quot;, &quot;r&quot;);&#xA;          if (configFile) {&#xA;            Serial.println(&quot;opened config file&quot;);&#xA;            size_t size = configFile.size();&#xA;            // Allocate a buffer to store contents of the file.&#xA;            std::unique_ptr&amp;lt;char[]&amp;gt; buf(new char[size]);&#xA;&#xA;            configFile.readBytes(buf.get(), size);&#xA;            DynamicJsonBuffer jsonBuffer;&#xA;            JsonObject&amp;amp; json = jsonBuffer.parseObject(buf.get());&#xA;            json.printTo(Serial);&#xA;            if (json.success()) {&#xA;              Serial.println(&quot;\nparsed json&quot;);&#xA;&#xA;              strcpy(mqtt_server, json[&quot;mqtt_server&quot;]);&#xA;              strcpy(mqtt_port, json[&quot;mqtt_port&quot;]);&#xA;              strcpy(mqtt_topic, json[&quot;mqtt_topic&quot;]);&#xA;&#xA;            } else {&#xA;              Serial.println(&quot;failed to load json config&quot;);&#xA;            }&#xA;          }&#xA;        }&#xA;      } else {&#xA;        Serial.println(&quot;failed to mount FS&quot;);&#xA;      }&#xA;      //end read&#xA;&#xA;&#xA;&#xA;      // The extra parameters to be configured (can be either global or just in the setup)&#xA;      // After connecting, parameter.getValue() will get you the configured value&#xA;      // id/name placeholder/prompt default length&#xA;      WiFiManagerParameter custom_mqtt_server(&quot;server&quot;, &quot;mqtt server&quot;, mqtt_server, 40);&#xA;      WiFiManagerParameter custom_mqtt_port(&quot;port&quot;, &quot;mqtt port&quot;, mqtt_port, 5);&#xA;      WiFiManagerParameter custom_mqtt_topic(&quot;topic&quot;, &quot;mqtt topic&quot;, mqtt_topic, 32);&#xA;&#xA;      //WiFiManager&#xA;      //Local intialization. Once its business is done, there is no need to keep it around&#xA;      WiFiManager wifiManager;&#xA;&#xA;      //set config save notify callback&#xA;      wifiManager.setSaveConfigCallback(saveConfigCallback);&#xA;&#xA;      //set static ip&#xA;      //wifiManager.setSTAStaticIPConfig(IPAddress(10, 0, 1, 99), IPAddress(10, 0, 1, 1), IPAddress(255, 255, 255, 0));&#xA;&#xA;      //add all your parameters here&#xA;      wifiManager.addParameter(&amp;amp;custom_mqtt_server);&#xA;      wifiManager.addParameter(&amp;amp;custom_mqtt_port);&#xA;      wifiManager.addParameter(&amp;amp;custom_mqtt_topic);&#xA;&#xA;      //reset settings - for testing&#xA;      //wifiManager.resetSettings();&#xA;&#xA;      //set minimu quality of signal so it ignores AP's under that quality&#xA;      //defaults to 8%&#xA;      //wifiManager.setMinimumSignalQuality();&#xA;&#xA;      //sets timeout until configuration portal gets turned off&#xA;      //useful to make it all retry or go to sleep&#xA;      //in seconds&#xA;      //wifiManager.setTimeout(120);&#xA;&#xA;      //fetches ssid and pass and tries to connect&#xA;      //if it does not connect it starts an access point with the specified name&#xA;      //here  &quot;AutoConnectAP&quot;&#xA;      //and goes into a blocking loop awaiting configuration&#xA;      if (!wifiManager.autoConnect(&quot;AutoConnectAP&quot;, &quot;password&quot;)) {&#xA;        Serial.println(&quot;failed to connect and hit timeout&quot;);&#xA;        delay(3000);&#xA;        //reset and try again, or maybe put it to deep sleep&#xA;        ESP.reset();&#xA;        delay(5000);&#xA;      }&#xA;&#xA;      //if you get here you have connected to the WiFi&#xA;      Serial.println(&quot;connected...yeey :)&quot;);&#xA;&#xA;      //read updated parameters&#xA;      strcpy(mqtt_server, custom_mqtt_server.getValue());&#xA;      strcpy(mqtt_port, custom_mqtt_port.getValue());&#xA;      strcpy(mqtt_topic, custom_mqtt_topic.getValue());&#xA;&#xA;      //save the custom parameters to FS&#xA;      if (shouldSaveConfig) {&#xA;        Serial.println(&quot;saving config&quot;);&#xA;        DynamicJsonBuffer jsonBuffer;&#xA;        JsonObject&amp;amp; json = jsonBuffer.createObject();&#xA;        json[&quot;mqtt_server&quot;] = mqtt_server;&#xA;        json[&quot;mqtt_port&quot;] = mqtt_port;&#xA;        json[&quot;mqtt_topic&quot;] = mqtt_topic;&#xA;&#xA;        File configFile = SPIFFS.open(&quot;/config.json&quot;, &quot;w&quot;);&#xA;        if (!configFile) {&#xA;          Serial.println(&quot;failed to open config file for writing&quot;);&#xA;        }&#xA;&#xA;        json.printTo(Serial);&#xA;        json.printTo(configFile);&#xA;        configFile.close();&#xA;        //end save&#xA;      }&#xA;&#xA;      client.setServer(mqtt_server, stringToNumber(mqtt_port));&#xA;      client.setCallback(callback);&#xA;      Serial.println(&quot;local ip&quot;);&#xA;      Serial.println(WiFi.localIP());&#xA;      dht.begin();&#xA;    }&#xA;&#xA;    int stringToNumber(String thisString) {&#xA;      int i, value, length;&#xA;      length = thisString.length();&#xA;      char blah[(length + 1)];&#xA;      for (i = 0; i &amp;lt; length; i++) {&#xA;        blah[i] = thisString.charAt(i);&#xA;      }&#xA;      blah[i] = 0;&#xA;      value = atoi(blah);&#xA;      return value;&#xA;    }&#xA;&#xA;    void callback(char* topic, byte* payload, unsigned int length) {&#xA;      Serial.print(&quot;Message arrived [&quot;);&#xA;      Serial.print(topic);&#xA;      Serial.print(&quot;] &quot;);&#xA;      for (int i = 0; i &amp;lt; length; i++) {&#xA;        Serial.print((char)payload[i]);&#xA;      }&#xA;      Serial.println();&#xA;&#xA;      // Switch on the LED if an 1 was received as first character&#xA;      if ((char)payload[0] == '1') {&#xA;        digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level&#xA;        // but actually the LED is on; this is because&#xA;        // it is acive low on the ESP-01)&#xA;      } else {&#xA;        digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    void reconnect() {&#xA;      // Loop until we're reconnected&#xA;      while (!client.connected()) {&#xA;        Serial.print(&quot;Attempting MQTT connection...&quot;);&#xA;        Serial.print(mqtt_server);&#xA;        Serial.print(&quot;:&quot;);&#xA;        Serial.print(mqtt_port);&#xA;        Serial.print(&quot;...&quot;);&#xA;        // Attempt to connect&#xA;        if (client.connect(&quot;ESP8266Client&quot;)) {&#xA;          Serial.println(&quot;connected&quot;);&#xA;          // Once connected, publish an announcement...&#xA;          client.publish(mqtt_topic, &quot;Reconnected&quot;);&#xA;          // ... and resubscribe&#xA;          //client.subscribe(&quot;inTopic&quot;);&#xA;        } else {&#xA;          Serial.print(&quot;failed, rc=&quot;);&#xA;          Serial.print(client.state());&#xA;          Serial.println(&quot; try again in 5 seconds&quot;);&#xA;          // Wait 5 seconds before retrying&#xA;          delay(5000);&#xA;        }&#xA;      }&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // put your main code here, to run repeatedly:&#xA;&#xA;      float h = dht.readHumidity();&#xA;      float t = dht.readTemperature();&#xA;      if (isnan(t) || isnan(h)) {&#xA;        Serial.println(&quot;Failed to read from DHT&quot;);&#xA;      } else {&#xA;        Serial.print(&quot;Temp:&quot;);&#xA;        Serial.print(t);&#xA;        Serial.print( &quot;*C  Humidity:&quot;);&#xA;        Serial.print(h);&#xA;        Serial.println(&quot;%&quot;);&#xA;        if (!client.connected()) {&#xA;          reconnect();&#xA;        }&#xA;        client.loop();&#xA;&#xA;        //long now = millis();&#xA;        //if (now - mqtt_lastMsg &amp;gt; 2000) {&#xA;        //  lastMsg = now;&#xA;        //  ++mqtt_value;&#xA;        char temp[7];&#xA;        dtostrf(t,4,2,temp); //convert float to char&#xA;        snprintf (mqtt_msg, 50, &quot;%s C&quot;, temp);&#xA;        //  Serial.print(&quot;Publish message: &quot;);&#xA;        //  Serial.println(msg);&#xA;        //  client.publish(mqtt_topic, msg);&#xA;        //}&#xA;        char pub_topic[34];&#xA;        strcpy(pub_topic,mqtt_topic);&#xA;        strcat(pub_topic,&quot;/temperature&quot;);&#xA;        client.publish( pub_topic , mqtt_msg);&#xA;        Serial.print(&quot;Publish: &quot;);&#xA;        Serial.print(pub_topic);&#xA;        Serial.print(&quot; , &quot;);&#xA;        Serial.println(mqtt_msg);&#xA;&#xA;        dtostrf(h,4,2,temp); //convert float to char&#xA;        snprintf (mqtt_msg, 50, &quot;%s %&quot;, temp);&#xA;&#xA;        strcpy(pub_topic,mqtt_topic);&#xA;        strcat(pub_topic,&quot;/humidity&quot;);&#xA;        client.publish(pub_topic,mqtt_msg);&#xA;        Serial.print(&quot;Publish: &quot;);&#xA;        Serial.print(pub_topic);&#xA;        Serial.print(&quot; , &quot;);&#xA;        Serial.println(mqtt_msg);&#xA;      }&#xA;      delay(5000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17197" LastEditorUserId="6936" LastEditDate="2016-02-10T04:56:17.960" LastActivityDate="2016-02-10T04:56:17.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20513" PostTypeId="1" CreationDate="2016-02-09T22:57:19.183" Score="1" ViewCount="1582" Body="&lt;p&gt;I'm trying to create a car that's being controlled by an Arduino.&#xA;I'm using the following chasis:&#xA;&lt;a href=&quot;http://www.aliexpress.com/item-img/New-2WD-car-chassis-DC-gear-motor-wheels-easy-assembly-and-expansion-car-toys-robot-toys/32310649967.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item-img/New-2WD-car-chassis-DC-gear-motor-wheels-easy-assembly-and-expansion-car-toys-robot-toys/32310649967.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And L298N motor driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is it's hard to make the car go straight. Giving the same PWM value to the motors still makes them spin in different speeds, trying to calibrate the value is hard and every time I recharge my batteries the value changes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are my options on making the car go straight when I want (well, sometimes I'll want to turn it around of course)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've thought about using an encoder but I wish to avoid that since it will complicate the whole project, is there any other viable option? and even when using an encoder, Does it means I will need to keep track all the time and always adjust the motors value continuously? is there some built-in library for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="6804" LastActivityDate="2017-01-06T18:22:02.300" Title="Calibrate motors using arduino" Tags="|motor|arduino-motor-shield|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20514" PostTypeId="2" ParentId="20492" CreationDate="2016-02-09T23:15:10.843" Score="1" Body="&lt;p&gt;Photograph of the YL-69 Sensor  : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yA3vN.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yA3vN.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Most of this content was generated by :  Conner Wolf&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, that sensor works by measuring the resistance between the two &quot;pins&quot; of the PCB stake. It does this by applying a voltage across the pins, and measuring the current flow. So, the intention is that more water means less resistance, means less voltage, and a fall in the voltage sent to the ADC of the processor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this is also going to lead to the metal from one of the pins being eaten away by galvanic action (electrolysis).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other pin is likely to have accumulation of materials rather than being eaten away.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This electrolysis and coating of the pins results in a change in surface area of the pins and causes resistance measured to change (for the same given moisture content).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to squeeze as much life out of the thing as possible, there are a few things you can do.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;DO NOT leave the sensor powered. When you want to take a reading, power the sensor for maybe a few seconds, and take your readings. Then power it off again. Don't take readings too often.&lt;/li&gt;&#xA;&lt;li&gt;Periodically reverse the pins of the electrical connection between the readout board and the &quot;stake&quot; board. Since only one terminal will be eaten away at a time, this should spread the decay out a bit.&lt;/li&gt;&#xA;&lt;li&gt;Be aware that ANY mechanical disturbance of the &quot;stake&quot; board will probably cause a large shift in readout value. Your &quot;jiggling the wires&quot; causing a shift in values probably came from the mechanical force transmitted to the PCB through the wiring. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;An improved version for this sort of thing use a AC bias on the sensor, which minimizes galvanic corrosion. AC bias reverses the voltage applied to the sensor, attempting to eliminate electrolysis on the sensor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Higher Quality soil moisture sensors use capacitive sensor, and therefore make the sensor immune to the corrosion issue, but are much more complex and expensive.&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-02-09T23:15:10.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20515" PostTypeId="1" CreationDate="2016-02-09T23:34:44.213" Score="2" ViewCount="149" Body="&lt;p&gt;Given that every ATTiny connected already has a bootloader (micronucleus) installed, here's my theoretical chain:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Computer &gt; Master ATTiny (Connected via USB) &gt; ATTiny Slave A &gt; ATTiny Slave B&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to flash an individual slave (say, slave B) with new software without replicating it to all of the other slaves, or altering the master?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be done with the normal MISO/MOSI/SCK/RESET method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done some research (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=166451.0&quot; rel=&quot;nofollow&quot;&gt;Programming multiple ATMegas/Arduinos at once&lt;/a&gt;) but I'm not looking for a batch flashing method; I want to upload custom programming to a &lt;strong&gt;single&lt;/strong&gt; slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I'm not trying to pass data between the master and the slaves. What I want is to reprogram the slaves from a single USB connection. It's also important that each slave has a fixed identity so I know exactly which one I'm flashing every time I boot the &quot;system&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclosure: I'm an arduino novice and programming intermediate. This is my first project utilizing serial communication.&lt;/p&gt;&#xA;" OwnerUserId="17165" LastEditorUserId="6936" LastEditDate="2016-02-10T04:58:26.457" LastActivityDate="2016-02-10T04:58:26.457" Title="Reprogramming a specific slave from the master ATTiny 85 (connected to IDE)?" Tags="|arduino-ide|i2c|attiny|isp|arduinoisp|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20517" PostTypeId="2" ParentId="17820" CreationDate="2016-02-10T02:02:35.533" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can anyone confirm that connecting some I2C Arduinos without master is something that cannot be done? (or do I have to look for some other reason)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no master except during transmissions. Thus it is possible to rotate the job of master if you want. You would need some way of deciding when it was a particular board's turn to be master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have code &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&amp;amp;reply=2#reply2&quot; rel=&quot;nofollow&quot;&gt;here on my RS485 page&lt;/a&gt; about how you can set up a rolling master using Serial communications. The same basic idea could be used to make a rolling I2C master.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-10T02:02:35.533" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20518" PostTypeId="1" CreationDate="2016-02-10T02:15:13.817" Score="-1" ViewCount="113" Body="&lt;p&gt;When this code is uploaded I get an &quot;Error Compiling&quot;. Any help is very much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;MeetAndroid.h&amp;gt;&#xA;#define supplyVolts 6&#xA;#define motorVolts 5&#xA;#define baudRate 57600&#xA;// If you are using a General Bluetooth adapter (available on buildcircuit.net), then, it works with 9600bps baud rate&#xA;MeetAndroid phone;&#xA;int left = 255; // midpoint&#xA;int right = 255;&#xA;int pwmLeftPin = 3;  1 int pwmRightPin = 11;&#xA;int directionLeftPin = 12;&#xA;int directionRightPin = 13;&#xA;void setup() {&#xA;  pinMode(pwmLeftPin, OUTPUT);&#xA;  pinMode(pwmRightPin, OUTPUT);&#xA;  pinMode(directionLeftPin, OUTPUT);&#xA;  pinMode(directionRightPin, OUTPUT);&#xA;  setMotors();&#xA;  // use the baud rate your bluetooth module is configured to&#xA;  Serial.begin(baudRate);&#xA;  phone.registerFunction(setLeft, 'l');&#xA;  phone.registerFunction(setRight, 'r');&#xA;}&#xA;&#xA;void loop() {&#xA;  phone.receive();&#xA;}&#xA;&#xA;void setLeft(byte ignore, byte count) {&#xA;  int value = phone.getInt();&#xA;  left = value;&#xA;  setMotors();&#xA;}&#xA;&#xA;void setRight(byte ignore, byte count) {&#xA;  int value = phone.getInt();&#xA;  right = value;&#xA;  setMotors();&#xA;}&#xA;&#xA;void setMotors() {&#xA;  int vLeft = abs(left - 255) * motorVolts / supplyVolts;&#xA;  int vRight = abs(right - 255) * motorVolts / supplyVolts;&#xA;  int dLeft = (left &amp;gt; 255);&#xA;  int dRight = (right &amp;gt; 255);&#xA;  if (vLeft &amp;lt; 50) {&#xA;    vLeft = 0;&#xA;  }&#xA;  if (vRight &amp;lt; 50) {&#xA;    vRight = 0;&#xA;  }&#xA;  analogWrite(pwmLeftPin, vLeft);&#xA;  analogWrite(pwmRightPin, vRight);&#xA;  digitalWrite(directionLeftPin, dLeft);&#xA;  digitalWrite(directionRightPin, dRight);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="4628" LastEditDate="2016-02-10T15:28:39.573" LastActivityDate="2016-02-10T15:28:39.573" Title="Arduino error when compiling" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20520" PostTypeId="2" ParentId="16037" CreationDate="2016-02-10T03:47:39.377" Score="1" Body="&lt;pre&gt;&lt;code&gt;int inPin_0 = A0; // choose the input pin (sensor #1)&#xA;int inPin_1 = A1; // choose the input pin (sensor #2) //ADDED FOR SECOND BUTTON/&#xA;&#xA;...&#xA;&#xA;  senseval=SensorVal+String(inPin_0);&#xA;  senseval=SensorVal+String(inPin_1); //ADDED FOR SECOND BUTTON//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above is wrong because you are sending the &lt;strong&gt;pin numbers&lt;/strong&gt; and not the values read from those pins. You previously read them here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  sensorSense_0=analogRead(inPin_0);&#xA;  ...&#xA;  sensorSense_1=analogRead(inPin_1); //ADDED FOR SECOND BUTTON//&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is &lt;code&gt;sensorSense_0&lt;/code&gt; and &lt;code&gt;sensorSense_1&lt;/code&gt; that you should be sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as Damiano Verzulli pointed out, your second assignment to &lt;code&gt;senseval&lt;/code&gt; clobbers the first. You want something more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  senseval  = SensorVal + String(analogRead(inPin_0)) + &quot;, &quot;;&#xA;  senseval += SensorVal + String(analogRead(inPin_1)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even that may not be perfect, I didn't read your PHP side.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Looking at the PHP side now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$query = &quot;INSERT INTO $tablename VALUES ($senseval,now())&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That isn't going to work too well for two values. I don't know your database schema, but that won't handle two values very well. A bit of tweaking and it might, or you could do two &lt;code&gt;INSERT&lt;/code&gt; statements.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-10T04:30:16.563" LastActivityDate="2016-02-10T04:30:16.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20521" PostTypeId="1" AcceptedAnswerId="20522" CreationDate="2016-02-10T04:05:46.010" Score="2" ViewCount="668" Body="&lt;p&gt;I was trying out the &lt;a href=&quot;http://playground.arduino.cc/Code/NewPing&quot; rel=&quot;nofollow noreferrer&quot;&gt;NewPing library&lt;/a&gt; (the main example sketch) and when I compile it and check the serial monitor, it seems like it works for about 10 seconds, then instead of giving distance values it just writes out random characters. The only thing I can think of is that my sensor is bad. Any suggestions before I get another Ping sensor? I'm unsure if the same thing will happen. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PEHid.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PEHid.png&quot; alt=&quot;Screenshot of NewPing output on serial monitor showing 10 seconds of output and then random characters&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17202" LastEditorUserId="6936" LastEditDate="2016-02-10T05:01:21.020" LastActivityDate="2016-02-10T05:01:21.020" Title="Arduino Ping sensor with NewPing library" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20522" PostTypeId="2" ParentId="20521" CreationDate="2016-02-10T04:20:40.817" Score="2" Body="&lt;p&gt;The main example sketch has this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your serial monitor is set to 9600 baud (bottom RH corner). Change that to match the setting in the sketch.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-10T04:20:40.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20525" PostTypeId="1" AcceptedAnswerId="20526" CreationDate="2016-02-10T08:23:58.910" Score="3" ViewCount="2412" Body="&lt;pre&gt;&lt;code&gt;byte subkeys[16][48/8];&#xA;&#xA;for (size_t address = 0; address &amp;lt; 16*6; address++)&#xA;    Serial.println( (byte) *(subkeys + address) ); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why won't the compiler handle this? It tells me &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;cast from 'byte* {aka unsigned char*}' to 'byte {aka unsigned char}' loses precision [-fpermissive]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I omit the &lt;code&gt;(byte)&lt;/code&gt; part, it tells me&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;call of overloaded 'println(byte [6])' is ambiguous&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have no idea what's happening.&lt;/p&gt;&#xA;" OwnerUserId="17207" LastEditorUserId="6936" LastEditDate="2016-02-10T13:53:20.303" LastActivityDate="2016-02-10T13:53:20.303" Title="Serial.println for pointers to the byte datatype behaves unexpectedly" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20526" PostTypeId="2" ParentId="20525" CreationDate="2016-02-10T08:32:21.637" Score="3" Body="&lt;p&gt;A &lt;code&gt;byte&lt;/code&gt; is to small to store a pointer value. Instead to casting to&#xA;byte, you should cast to &lt;code&gt;uintptr_t&lt;/code&gt;, which is guaranteed to be large&#xA;enough. On an AVR-based device like the Uno, this is the same as&#xA;&lt;code&gt;uint16_t&lt;/code&gt; or &lt;code&gt;unsigned int&lt;/code&gt;, but &lt;code&gt;uintptr_t&lt;/code&gt; is more general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: From your comment it would seem you want to print the contents&#xA;of the array instead of the addresses of the rows. The obvious way is to&#xA;loop with two indices:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;for (size_t i = 0; i &amp;lt; 16; i++) for (size_t j = 0; j &amp;lt; 6; j++)&#xA;    Serial.println(subkeys[i][j]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you really want to use &lt;code&gt;subkeys&lt;/code&gt; as a 1D array, then cast it to a&#xA;&lt;code&gt;byte *&lt;/code&gt;, which is the type a 1D array would naturally decay to:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;for (size_t address = 0; address &amp;lt; 16*6; address++)&#xA;    Serial.println(((byte *) subkeys)[address]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-02-10T09:38:06.433" LastActivityDate="2016-02-10T09:38:06.433" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20528" PostTypeId="2" ParentId="20109" CreationDate="2016-02-10T11:30:40.117" Score="0" Body="&lt;p&gt;You could use ESP-LINK to program the Arduino over WiFi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 is simple cheap Wi-Fi MCU that can be programmed with Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP-LINK is firmware for the ESP8266 that makes the ESP act like serial connection (USB) to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The firmware can be found here at &lt;a href=&quot;https://github.com/jeelabs/esp-link&quot; rel=&quot;nofollow&quot;&gt;ESP-LINK ESP8266&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17211" LastEditorUserId="6936" LastEditDate="2016-02-10T13:54:59.967" LastActivityDate="2016-02-10T13:54:59.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20530" PostTypeId="2" ParentId="20518" CreationDate="2016-02-10T12:14:11.937" Score="4" Body="&lt;p&gt;Take a close look at this line. The compiler will not like that as it does not have the right syntax.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pwmLeftPin = 3;  1 int pwmRightPin = 11;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pwmLeftPin = 3;&#xA;int pwmRightPin = 11;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should at least remove the first issue with your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-10T12:14:11.937" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20531" PostTypeId="1" AcceptedAnswerId="20533" CreationDate="2016-02-10T12:48:37.267" Score="1" ViewCount="1914" Body="&lt;p&gt;I am using an arduino UNO and a Cooking Hacks CAN BUS module through a Cooking Hacks Multiprotocol radio shield. I plan to read the CAN messages through the car's OBD-II port. I have connected the components according to the tutorial and though there is no LED to indicate that the shield and CAN bus module are ON, I verified that they are indeed ON by using a multimeter. Also, when the reset button is pressed on either the shield or the CAN module, the arduino resets so I guess they are powered up. Coming to my problem, I uploaded the code and connected the setup to the OBD-II port and turned the ignition ON. I expected to see the CAN messages on the arduino serial monitor but I didn't see anything. I also took up this issue with the cooking hacks support team who told me that the libraries were updated and that I should use the updated ones. So I downloaded the revised libraries to use with my code but I am unable to upload the code itself to the arduino because of an error during compilation.&lt;/p&gt;&#xA;&lt;p&gt;C:\Users\user\Documents\Arduino\libraries\arduinoCANBUS\arduinoCAN.cpp:26:49: fatal error: ../arduino-api/arduinoMultiprotocol.h: No such file or directory&lt;/p&gt;&#xA;&lt;p&gt;The major difference as far as I can tell between the old and the new libraries is the addition of two lines in the arduinocan.cpp file :&lt;/p&gt;&#xA;&lt;h1&gt;include &amp;quot;../arduino-api/arduinoMultiprotocol.h&amp;quot;&lt;/h1&gt;&#xA;&lt;h1&gt;include &amp;quot;../arduino-api/arduinoUtils.h&amp;quot;&lt;/h1&gt;&#xA;&lt;p&gt;Both of these are header files in another library that was included as part of the whole library that you can download from their website.&lt;/p&gt;&#xA;&lt;p&gt;I realise I might have confused whoever's reading but please have a look at the arduino code. Hopefully, that should clear things up. Any help would be highly appreciated. Thanks.&lt;/p&gt;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;arduinoCAN.h&amp;gt;&#xA;    #include &amp;lt;arduinoClasses.h&amp;gt;&#xA;    #include &amp;lt;arduinoMultiprotocol.h&amp;gt;&#xA;    #include &amp;lt;arduinoUART.h&amp;gt;&#xA;    #include &amp;lt;arduinoUtils.h&amp;gt;&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;    // Create an instance of the object&#xA;    CAN myCAN = CAN();&#xA;&#xA;    // Setting up our devices and I/Os&#xA;    void setup() {&#xA;    // Using the Socket 0 onto which Can bus module is plugged in&#xA;    Utils.setONSocket0();&#xA;    Utils.setMUXSocket0();&#xA;    // Initializes the UART&#xA;    Serial.begin(115200);&#xA;    delay(100);&#xA;&#xA;    myCAN.begin(500); // Start talking to the BUS. Speed= 500 Kbps&#xA;    }&#xA;&#xA;    void loop() {&#xA;    // 1. Receive data&#xA;&#xA;    if (myCAN.messageAvailable()) {&#xA;    // Read the last message received.&#xA;    myCAN.getMessage(&amp;amp;myCAN.messageRx);&#xA;    // Print in the serial monitor the received message&#xA;    myCAN.printMessage(&amp;amp;myCAN.messageRx);&#xA;     }&#xA;    }  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;EDIT: PROBLEM SOLVED!&lt;/p&gt;&#xA;&lt;p&gt;Putting the header file's full path in the sketch did not solve it. The compiler still displayed the same error. I then made a backup copy of all the files containing the #include &amp;quot;arduinoMultiprotocol.h&amp;quot; statement and edited them to contain the full path. Initially, the error didn't change and I moved onto the next suggestions, all of which did not change the error. However, I went back to the edited files and replaced the backslash() with the slash(/). This time, the compiler did not throw the same error, instead saying it cannot find arduinoUtils.h.&#xA;So I proceeded to do the same thing with arduinoUtils.h, editing all the files containing it to mention the full path. And this time it worked and the sketch works as well. Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="17215" OwnerDisplayName="Varun Raman" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-11T06:08:24.597" Title="Problem receiving CAN messages using arduino, MCP2515 CAN module and multiprotocol radio shield" Tags="|can-bus|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20532" PostTypeId="1" CreationDate="2016-02-10T13:24:52.473" Score="-1" ViewCount="278" Body="&lt;p&gt;I am trying to read a text file and send the info to 2D array, but after loading the array, it reads all zeroes. What can I do to stop the Arduino from doing this and get the array with my required data?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/* This program was created by ScottC on 8/5/2012 to receive serial signals from a computer to turn on/off 1-9 LEDs */&#xA;&#xA;int** ptr;&#xA;&#xA;void setup() {&#xA;  // initialize the digital pins as an output.&#xA;  pinMode(13, OUTPUT);&#xA;  // Turn the Serial Protocol ON&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte byteRead;&#xA;&#xA;  if (Serial.available()) {&#xA;&#xA;    /* read the most recent byte */&#xA;    byteRead = Serial.read();&#xA;    //You have to subtract '0' from the read Byte to convert from text to a number.&#xA;    byteRead = byteRead - '0';&#xA;    ptr = new int* [byteRead];&#xA;&#xA;    int i,j;&#xA;    for ( i = 0; i &amp;lt; byteRead; i++) {&#xA;      ptr[i] = new int[3];&#xA;      for ( j = 0; j &amp;lt; 3; j++) {&#xA;        if (Serial.available()) {&#xA;&#xA;            /* read the most recent byte */&#xA;            byteRead = Serial.read();&#xA;            //You have to subtract '0' from the read Byte to convert from text to a number.&#xA;            byteRead = byteRead - '0';&#xA;            ptr[i][j] = byteRead; &#xA;            Serial.print(ptr[i][j]);&#xA;        }&#xA;      } &#xA;    } &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17212" LastEditorUserId="6936" LastEditDate="2016-02-10T15:19:26.867" LastActivityDate="2016-02-10T15:19:26.867" Title="text to 2D array on Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20533" PostTypeId="2" ParentId="20531" CreationDate="2016-02-10T13:39:11.843" Score="0" Body="&lt;p&gt;The compiler is saying it can't find the header files. The part of the path &lt;code&gt;../arduino-api/&lt;/code&gt; is suspicious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be because the header files are expected to be somewhere else, or their is a small error which has had a knock on effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - Find arduinoMultiprotocol.h&lt;br&gt;&#xA;Put its full path into the include statement, e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &quot;C:\Users\user\Documents\Arduino\libraries\arduinoCANBUS\wibble\arduinoMultiprotocol.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If that is still broken, but a new error is printed, copy the error. If the error doesn't change, then make a backup copy of every file you can find containing &lt;code&gt;#include &amp;lt;arduinoMultiprotocol.h&amp;gt;&lt;/code&gt; and edit it to contain the full path. It looks like starting with arduinocan.cpp is a good place to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - If that doesn't fix the error, create an empty sketch, including all those headers, e.g.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;arduinoCAN.h&amp;gt;&#xA;    #include &amp;lt;arduinoClasses.h&amp;gt;&#xA;    #include &amp;lt;arduinoMultiprotocol.h&amp;gt;&#xA;    #include &amp;lt;arduinoUART.h&amp;gt;&#xA;    #include &amp;lt;arduinoUtils.h&amp;gt;&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;    void setup() { }&#xA;&#xA;    void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compile and copy the error message.&#xA;Move the &lt;code&gt;#include &amp;lt;arduinoMultiprotocol.h&amp;gt;&lt;/code&gt; a bit later in the sequence of #includes. If the error changes copy that for later, and record which sequence changed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 - Change &lt;code&gt;#include &amp;lt;arduinoMultiprotocol.h&amp;gt;&lt;/code&gt; in that empty sketch&#xA;to the full path (as in step 1). If that doesn't fix it, copy that error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still need help, please update your question with the results of those tests.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastActivityDate="2016-02-10T13:39:11.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20535" PostTypeId="2" ParentId="20532" CreationDate="2016-02-10T14:53:21.747" Score="1" Body="&lt;p&gt;There are several issues with your code but instead of correcting I recommend that you start by checking that your assumptions about the format is correct. Send your data to this &quot;reduced&quot; variant of your sketch. Does it work? Did you receive what you expected?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize the digital pins as an output.&#xA;  pinMode(13, OUTPUT);&#xA;  // Turn the Serial Protocol ON&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte byteRead;&#xA;&#xA;  if (Serial.available()) {&#xA;&#xA;    /* read the most recent byte */&#xA;    byteRead = Serial.read();&#xA;    //You have to subtract '0' from the read Byte to convert from text to a number.&#xA;    byteRead = byteRead - '0';&#xA;    Serial.print(F(&quot;byteRead = &quot;));&#xA;    Serial.println(byteRead);&#xA;&#xA;    int i,j;&#xA;    for ( i = 0; i &amp;lt; byteRead; i++) {&#xA;      for ( j = 0; j &amp;lt; 3; j++) {&#xA;        if (Serial.available()) {&#xA;&#xA;            /* read the most recent byte */&#xA;            byteRead = Serial.read();&#xA;            //You have to subtract '0' from the read Byte to convert from text to a number.&#xA;            byteRead = byteRead - '0';&#xA;            Serial.print(i);&#xA;            Serial.print(':');&#xA;            Serial.print(j);&#xA;            Serial.print(F(&quot;:byteRead = &quot;));&#xA;            Serial.println(byteRead);&#xA;        }&#xA;      } &#xA;    } &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you see the issue with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    for ( i = 0; i &amp;lt; byteRead; i++) {&#xA;    ...&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-10T14:53:21.747" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20537" PostTypeId="2" ParentId="9888" CreationDate="2016-02-10T15:58:38.863" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I parse this string in the arduino to get an array of hex values:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are a few standard library (&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gaf8ce3b8dae3d45c34c3b172de503f7b3&quot; rel=&quot;nofollow&quot;&gt;stdlib&lt;/a&gt;) functions that can help you with that. Below is a snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buf[] = &quot;0x0F 0x2C 0x98 0xBD&quot;;&#xA;uint8_t val[4];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  char* bp = buf;&#xA;  int i = 0;&#xA;  do {&#xA;    char* ep;&#xA;    val[i] = strtol(bp, &amp;amp;ep, 16);&#xA;    Serial.println(val[i], HEX);&#xA;    bp = ep;&#xA;    i += 1;&#xA;  } while (*bp != 0);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-10T15:58:38.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20538" PostTypeId="1" CreationDate="2016-02-10T16:12:32.980" Score="1" ViewCount="1083" Body="&lt;p&gt;This is a bit home automation but if I want to control my 12v LEDs and I have 8 free pins would it be possible to drive 16 lights as a matrix. I was looking into running 8 LEDs with an 8 channel relay but the I got to thinking if I wire up 16 LEDs in a matrix I could still control them all with those 8 channels. Problem is I was looking at mechanical relays that would burn out very quickly with that kind of switching. Are there any other solutions?&lt;/p&gt;&#xA;" OwnerUserId="17225" LastActivityDate="2017-01-06T17:21:28.910" Title="Is it possible to control a 12v led matrix with an arduino?" Tags="|led|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20540" PostTypeId="1" AcceptedAnswerId="20541" CreationDate="2016-02-10T18:59:07.993" Score="6" ViewCount="1424" Body="&lt;p&gt;I have just gone through all my code. At max I use 60 bytes. I have done everything in order to minimize its usage - I even store booleans as bits, not bytes! What could be happening here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing that comes to my mind are extremely large arrays, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t SBoxes[8][4][16] PROGMEM;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, these are stored in the program memory as you can see. How can I check they are really there and my memory usage? My code is too large to post it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IDE tells me (even though I believe it's very inaccurate):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Sketch uses 7,898 bytes (24%) of program storage space. Maximum is 32,256 bytes.&#xA;  Global variables use 1,023 bytes (49%) of dynamic memory, leaving 1,025 bytes for local variables. Maximum is 2,048 bytes.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;All my literal strings use F() and there are not many of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://pastebin.com/0ZduU2JJ&quot; rel=&quot;nofollow&quot;&gt;Code on pastebin.&lt;/a&gt; Just for a quick glance, it is really large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT3:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;Serial&lt;/code&gt; prints&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ready&#xA;some numbers (that's ok I ask it to print out an array)&#xA;ENready&#xA;again numburs&#xA;Enready&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I ask it to print &lt;code&gt;ready&lt;/code&gt; at the very beginning of my program. I ask it to println &lt;code&gt;End of encr&lt;/code&gt; near the end of my &lt;code&gt;setup&lt;/code&gt; funciton, but as you see it never finishes the printing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It always behaves like that when I run out of SRAM.&lt;/p&gt;&#xA;" OwnerUserId="17207" LastEditorUserId="17207" LastEditDate="2016-02-10T21:44:34.123" LastActivityDate="2016-02-10T21:44:34.123" Title="Why is my SRAM so quickly filled? There are not more than 60 bytes" Tags="|arduino-uno|sram|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="20541" PostTypeId="2" ParentId="20540" CreationDate="2016-02-10T19:44:16.380" Score="5" Body="&lt;p&gt;When you are asking yourself what is eating so much RAM, the first step&#xA;is to look at the symbol table in the ELF file. If you use a makefile, you&#xA;probably know where to find the ELF file. If you are using the Arduino&#xA;IDE, go to File / Preferences, check “Show verbose output during&#xA;compilation”, compile and look at the output: you will see the temporary&#xA;directory where the compiler puts your ELF file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now run the command &lt;code&gt;avr-nm -Crtd --size-sort your_elf_file&lt;/code&gt; and look&#xA;for symbols of type 'D' (data), 'V' (vtable) and 'B' (BSS), in either&#xA;upper or lower case. On a Unix-style OS you would pipe through&#xA;&lt;code&gt;grep -i ' [dbv] '&lt;/code&gt;. Running this on your program gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000068 B tx_buffer&#xA;00000068 B rx_buffer&#xA;00000034 B Serial&#xA;00000021 B lcd&#xA;00000016 V vtable for HardwareSerial&#xA;00000008 V vtable for LiquidCrystal&#xA;00000004 B timer0_overflow_count&#xA;00000004 B timer0_millis&#xA;00000002 D __malloc_margin&#xA;00000002 D __malloc_heap_start&#xA;00000002 D __malloc_heap_end&#xA;00000002 B __flp&#xA;00000002 B __brkval&#xA;00000001 b timer0_fract&#xA;00000001 D encr&#xA;00000001 B debug&#xA;00000001 B EEPROM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, this cannot account for the 1,023 bytes of static RAM your&#xA;program is using. What this command misses is the literal arrays and&#xA;strings. These can be seen with the command&#xA;&lt;code&gt;avr-objdump -j .data -s your_elf_file&lt;/code&gt;. The literal strings are quite&#xA;obvious in the output, the literal arrays less so. Running this on your&#xA;program gives a long listing starting with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Contents of section .data:&#xA;800100 00000005 2000010e 040d0102 0f0b0803  .... ...........&#xA;800110 0a060c05 09000700 0f07040e 020d010a  ................&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, on the source code we see:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const uint8_t SBoxes[8][4][16] PROGMEM = {&#xA;{{14,  4,  13,  1,   2, 15,  11,  8,   3, 10,   6, 12,   5,  9,   0,  7},&#xA; { 0, 15,   7,  4,  14,  2,  13,  1,  10,  6,  12, 11,   9,  5,   3,  8},&#xA; { 4,  1,  14,  8,  13,  6,   2, 11,  15, 12,   9,  7,   3, 10,   5,  0},&#xA; {15, 12,   8,  2,   4,  9,   1,  7,   5, 11,   3, 14,  10,  0,   6, 13} },&#xA; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you translate this to hexadecimal, you get &lt;code&gt;0e 04 0d 01 02 0f...&lt;/code&gt;,&#xA;which appears also by the end of the first line of previous listing. So&#xA;there is your culprit: all the big PROGMEM arrays. The compiler does not&#xA;honor the PROGMEM attribute on local variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought was to make the arrays global, and this does solve the&#xA;problem. However, as pointed out by Mikael Patel in a comment, the&#xA;documentation on PROGMEM states that “variables must be either globally&#xA;defined, OR defined with the static keyword, in order to work with&#xA;PROGMEM.” Then, making the arrays &lt;code&gt;static const PROGMEM&lt;/code&gt; is a cleaner&#xA;solution.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-02-10T21:04:45.117" LastActivityDate="2016-02-10T21:04:45.117" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20542" PostTypeId="2" ParentId="20440" CreationDate="2016-02-10T19:56:15.013" Score="1" Body="&lt;p&gt;by the comments I think you are not understanding correctly how to connect Reset and GPIO_0 of ESP. To set esp-01 into flash mode (to program) you need to set GPIO_0 Low (GND) and then also apply Low on RST ESP pin.&#xA;To debug the things and be certain that there is no hardware problem let just start by doing these connections:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Foca v2.2 &amp;lt;-&amp;gt; ESP =1&#xA;      TXD &amp;lt;-&amp;gt; RXD&#xA;      RXD &amp;lt;-&amp;gt; TXD&#xA;      GND &amp;lt;-&amp;gt; GND&#xA;  Arduino &amp;lt;-&amp;gt; ESP 01&#xA;     3.3V &amp;lt;-&amp;gt; 3.3V&#xA;     3.3V &amp;lt;-&amp;gt; CH_PD&#xA;     GND  &amp;lt;-&amp;gt; GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, with a wire, &lt;strong&gt;connect GPIO_0 to ground&lt;/strong&gt;. With another wire, &lt;strong&gt;briefly&lt;/strong&gt; connect &lt;strong&gt;RST of the ground&lt;/strong&gt; to make ESP reset. You should be now in flash mode. Remove the connection on GPIO_0 and make it float. Now upload the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; this is basically the option C on the link you provide. If you have some buttons you can make it too:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9SBe2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9SBe2.jpg&quot; alt=&quot;Manually Flash&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://www.arduinesp.com/arduinesp/wp-content/uploads/2015/04/TTL-to-ESP01-blink-upload-and-reset-button.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduinesp.com&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Now, does the code upload in Arduino IDE?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the answer is still no, try to add a small capacitor between 3.3v and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the answer is yes, now you can move on and try the other options described in the link you provide. I recommend using the option A:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bE5r0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bE5r0.png&quot; alt=&quot;Automatic Upload&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://www.arduinesp.com/arduinesp/wp-content/uploads/2015/07/TTL-to-ESP01-blink-NPN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduinesp.com&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any generic npn transistor should work&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="27346" LastEditDate="2019-02-28T21:10:06.317" LastActivityDate="2019-02-28T21:10:06.317" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20543" PostTypeId="2" ParentId="20540" CreationDate="2016-02-10T19:56:45.080" Score="4" Body="&lt;p&gt;To elaborate on Edgar Bonet's answer and my comment under it, you cannot usefully put PROGMEM variables as local variables because local (non-static) variables have to be allocated on the stack.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void lookUpInSBox(size_t which, byte *address, byte* binaryOutcome, size_t addressFrom){&#xA;&#xA;   ...&#xA;&#xA;    const uint8_t SBoxes[8][4][16] PROGMEM = {&#xA;&#xA;                             /*S1*/&#xA;&#xA;   { {14,  4,  13,  1,   2, 15,  11,  8,   3, 10,   6, 12,   5,  9,   0,  7},&#xA;     { 0, 15,   7,  4,  14,  2,  13,  1,  10,  6,  12, 11,   9,  5,   3,  8},&#xA;     { 4,  1,  14,  8,  13,  6,   2, 11,  15, 12,   9,  7,   3, 10,   5,  0},&#xA;     {15, 12,   8,  2,   4,  9,   1,  7,   5, 11,   3, 14,  10,  0,   6, 13}    },&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could make them global. But if you prefer  not to do that, put &lt;code&gt;static&lt;/code&gt; in front of them. Doing that on your code reduced it to 247 bytes.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Global variables use 247 bytes (12%) of dynamic memory, leaving 1,801 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You expect a bit more than the 60 you counted. The serial buffers take a bit (128 bytes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt; for more information. On a tiny sketch I found the following 346 bytes already in use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;34 bytes for the HardwareSerial instance (Serial)&lt;/li&gt;&#xA;&lt;li&gt;64 bytes for the Serial transmit buffer&lt;/li&gt;&#xA;&lt;li&gt;64 bytes for the Serial receive buffer&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for the Serial transmit buffer head and tail pointers&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for the Serial receive buffer head and tail pointers&lt;/li&gt;&#xA;&lt;li&gt;9 bytes for keeping track of millis / micros&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for memory allocation (__malloc_heap_start, __malloc_margin)&lt;/li&gt;&#xA;&lt;li&gt;128 bytes for the heap safety margin&lt;/li&gt;&#xA;&lt;li&gt;6 bytes for a few nested function calls (main -&gt; setup -&gt; getFreeMemory)&lt;/li&gt;&#xA;&lt;li&gt;16 bytes for the compiler vtable for HardwareSerial&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for variables __brkval and __flp (used in memdebug)&lt;/li&gt;&#xA;&lt;li&gt;2 bytes pushed onto the stack in main (to save registers)&lt;/li&gt;&#xA;&lt;li&gt;2 bytes pushed onto the stack in setup (to save registers)&lt;/li&gt;&#xA;&lt;li&gt;4 bytes pushed onto the stack in getFreeMemory (to save registers)&lt;/li&gt;&#xA;&lt;li&gt;1 byte because the stack pointer starts at 0x8FF rather than 0x900&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The sketch on my page used dynamic memory allocation so it used a bit more than yours does (for keeping track of it). &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Once it starts printing gibberish or looping (that means it prints something and starts again from the beginning of the program) I know I have run out of SRAM&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm a bit puzzled by all the &lt;code&gt;new&lt;/code&gt;/&lt;code&gt;delete&lt;/code&gt; you are doing. Why do that? For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;byte *E;&#xA;E = new byte[48/8];  &#xA;for(size_t i = 0; i &amp;lt; 48; i++){&#xA;    insertBit( E, i, bitValue( R, E_BIT[i]-1 ) );&#xA;}&#xA;&#xA;// XOR Kn and  E(Rn-1)&#xA;byte KxorE[48/8]; &#xA;for (size_t i = 0; i &amp;lt; 48; i++){&#xA;    insertBit( KxorE, i, bitValue( K, i ) ^ bitValue( E, i ) );&#xA;}&#xA;delete[] E;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Massive amounts of dynamic memory allocation may fragment memory. Can't you rewrite to not do that? You can pass arrays by reference, it just seems weird (and slow) to do all that allocation.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-10T20:22:26.200" LastActivityDate="2016-02-10T20:22:26.200" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="20544" PostTypeId="2" ParentId="20479" CreationDate="2016-02-10T20:43:48.733" Score="2" Body="&lt;p&gt;The bootloader needs a USB stack to work. It is possible to run the main sketch without a bootloader. So yes, I suppose you must have two of them. Looking at the assembler output for a blank sketch, it appears that you get the USB code in it by default. As I said, they have to assume you may not have the bootloader around, so they can't just execute the stack from the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-10T20:43:48.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20545" PostTypeId="2" ParentId="16355" CreationDate="2016-02-10T21:00:35.343" Score="0" Body="&lt;p&gt;Switching the selector did not help. I received a new one which worked perfectly following the steps from before. Apparently the issue was hardware related, possibly a cold solder joint preventing the motor driver section to work while still letting everything else continue normally.&lt;/p&gt;&#xA;" OwnerUserId="8046" LastActivityDate="2016-02-10T21:00:35.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20546" PostTypeId="2" ParentId="13931" CreationDate="2016-02-10T21:25:12.290" Score="2" Body="&lt;p&gt;Arrays in C/C++ are handled as a pointer.  That means the value of the pointer is the location in memory of the first element in the array.  The next element is at that starting address, plus the size of each element.  So for an array of 1-byte characters, each item in the array is at the very next address.  For 32-bit members, it's at +4, and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're storing an array of values to compare with analogRead() - so uint16_t (aka: short int) will be large enough for each element, without wasting too much memory.  But we also need to store a count of them, I'll assume 32-bits is enough readings.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t *comparison_points;&#xA;uint32_t  comparison_point_count;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These can be declared statically like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t  comparison_points[] = { 2, 4, 6, 8, 47 };&#xA;uint32_t  comparison_point_count = 5;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Giving you a comparison function like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool readingInSet(uint16_t reading, uint16_t *check_points, uint32_t check_points_length)&#xA;{&#xA;    bool found = false;&#xA;    for (uint32_t i=0; i&amp;lt;check_points_length; i++)&#xA;    {&#xA;        if (reading == check_points[i])&#xA;        {&#xA;            found = true;&#xA;            break;&#xA;        }&#xA;    }&#xA;    return found;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you could also make the array into an object, embedding this functionality&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class AnalogueVector&#xA;{&#xA;public:&#xA;    AnalogueVector(uint32_t size, uint16_t *points)&#xA;    {&#xA;        comparison_point_count = size;&#xA;        comparison_points = points;&#xA;    }&#xA;&#xA;    bool readingIn(uint16_t reading)&#xA;    {&#xA;        bool found = false;&#xA;        for (uint32_t i=0; i&amp;lt;comparison_point_count; i++)&#xA;        {&#xA;            if (reading == comparison_points[i])&#xA;            {&#xA;                found = true;&#xA;                break;&#xA;            }&#xA;        }&#xA;        return found;&#xA;    }&#xA;&#xA;private:&#xA;    uint16_t *comparison_points;&#xA;    uint32_t  comparison_point_count;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Giving a usage like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t  comparison_points[] = { 2, 4, 6, 8, 47 };&#xA;uint32_t  comparison_point_count = 5;&#xA;&#xA;AnalogueVector cmp_points(comparison_point_count, comparison_points);&#xA;&#xA;if (cmp_points.readingIn(analogRead(A1)))&#xA;    Serial.println(&quot;Matched&quot;);&#xA;else&#xA;    Serial.println(&quot;no&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously if you're reading these data points in from a file, or other external media, then you would need to allocate space for the items, and store them in the object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As with most coding problems, there's multiple solutions.  Here I've tried to keep it simple, and explore different ways of handling array data, without getting to far away from that fact that an array in C/C++ is just a big contiguous block of data in memory somewhere.  The address of that data, (aka the &lt;em&gt;pointer&lt;/em&gt;), is simply the address of that first element.  &lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-10T22:53:16.647" LastActivityDate="2016-02-10T22:53:16.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20548" PostTypeId="1" CreationDate="2016-02-10T22:37:43.990" Score="0" ViewCount="371" Body="&lt;p&gt;I'm new to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm passing some data from my Android phone to my Macbook via bluetooth (throught the app Sensoduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do now is to export that data to my Arduino Mini Pro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to achieve it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(NOTE: I'm not able to connect my Android Phone directly to the Arduino via Sensoduino)&lt;/p&gt;&#xA;" OwnerUserId="17237" LastActivityDate="2016-02-10T23:19:51.200" Title="How to read data from PC" Tags="|bluetooth|arduino-mini|osx|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20549" PostTypeId="5" CreationDate="2016-02-10T23:04:05.560" Score="0" Body="" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-02-10T23:04:05.560" LastActivityDate="2016-02-10T23:04:05.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20550" PostTypeId="4" CreationDate="2016-02-10T23:04:05.560" Score="0" Body="Use this tag if your question is related to signal processing techniques (within the Arduino's capability)." OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-02-10T23:04:05.560" LastActivityDate="2016-02-10T23:04:05.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20551" PostTypeId="2" ParentId="20548" CreationDate="2016-02-10T23:19:51.200" Score="1" Body="&lt;p&gt;A simple bluetooth module like a HC-05 wired to your Arduino will give you a  serial stream that can be read and/or written.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the RX/TX connected to say pins 10 &amp;amp; 11, a SoftwareSerial() object will provide access:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;&#xA;void setup() &#xA;{&#xA;    mySerial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    int value;&#xA;&#xA;    if (mySerial.available(sizeof(int)))&#xA;    {&#xA;        value = mySerial.parseInt();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you connect the module to pins 0 &amp;amp; 1 - you can just use the Arduino standard Serial functions, but it will cause problems uploading to the board.  In which case you would disconnect the bluetooth module for uploading.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-10T23:19:51.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20552" PostTypeId="1" AcceptedAnswerId="20556" CreationDate="2016-02-10T23:25:28.180" Score="3" ViewCount="4439" Body="&lt;p&gt;Here's the deal, I'm attempting to learn how to use an FFT (Fast Fourier Transformation) Library for sound analysis (link is &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). My issue is that this comes with included C++ code to show users how to use the FFT library. There are three examples, but I'll show this one because it's closest to the application I have planned for it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;fft_adc_serial.pde&#xA;guest openmusiclabs.com 7.7.14&#xA;example sketch for testing the fft library.&#xA;it takes in data on ADC0 (Analog0) and processes them&#xA;with the fft. the data is sent out over the serial&#xA;port at 115.2kb.&#xA;*/&#xA;&#xA;#define LOG_OUT 1 // use the log output function&#xA;#define FFT_N 256 // set to 256 point fft&#xA;&#xA;#include &amp;lt;FFT.h&amp;gt; // include the library&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200); // use the serial port&#xA;  TIMSK0 = 0; // turn off timer0 for lower jitter&#xA;  ADCSRA = 0xe5; // set the adc to free running mode&#xA;  ADMUX = 0x40; // use adc0&#xA;  DIDR0 = 0x01; // turn off the digital input for adc0&#xA;}&#xA;&#xA;void loop() {&#xA;  while(1) { // reduces jitter&#xA;    cli();  // UDRE interrupt slows this way down on arduino1.0&#xA;    for (int i = 0 ; i &amp;lt; 512 ; i += 2) { // save 256 samples&#xA;      while(!(ADCSRA &amp;amp; 0x10)); // wait for adc to be ready&#xA;      ADCSRA = 0xf5; // restart adc&#xA;      byte m = ADCL; // fetch adc data&#xA;      byte j = ADCH;&#xA;      int k = (j &amp;lt;&amp;lt; 8) | m; // form into an int&#xA;      k -= 0x0200; // form into a signed int&#xA;      k &amp;lt;&amp;lt;= 6; // form into a 16b signed int&#xA;      fft_input[i] = k; // put real data into even bins&#xA;      fft_input[i+1] = 0; // set odd bins to 0&#xA;     }&#xA;    fft_window(); // window the data for better frequency response&#xA;    fft_reorder(); // reorder the data before doing the fft&#xA;    fft_run(); // process the data in the fft&#xA;    fft_mag_log(); // take the output of the fft&#xA;    sei();&#xA;    Serial.println(&quot;start&quot;);&#xA;    for (byte i = 0 ; i &amp;lt; FFT_N/2 ; i++) { &#xA;      Serial.println(fft_log_out[i]); // send out the data&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, with that said, I have a very general grasp of the idea that those lines referencing some variable called ADMUX and ADCSRA have to do with the analogRead() method and that the ADCH and ADCL refer to another two components that are combined to provide the returned integer that analogRead() spits out. What I don't understand whatsoever are those seemingly random strings of characters that these are being set equal to. For example, what does 0x40 or 0x01 or 0xe5 even refer to in the setup() method (if nothing else maybe somebody could point me in the right direction for this, because that part I really am entirely clueless about). And furthermore, why manipulate these directly in the first place, because if you reference the &lt;a href=&quot;http://garretlab.web.fc2.com/en/arduino/inside/arduino/wiring_analog.c/analogRead.html&quot; rel=&quot;nofollow&quot;&gt;source code&lt;/a&gt; for analogRead() they look awfully similar. Thanks for any help in advance!&lt;/p&gt;&#xA;" OwnerUserId="17238" LastActivityDate="2016-02-11T10:24:54.477" Title="Help Understanding FFT Analysis and analogRead()?" Tags="|programming|c++|library|analogread|sound|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20553" PostTypeId="2" ParentId="9716" CreationDate="2016-02-10T23:56:24.023" Score="0" Body="&lt;p&gt;I realise your question was but a simple query on syntax. But I would like to point out that the whole idea of object orientation is encapsulating functions and data so that external calls do not have to know about the internal-workings of that class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's common with object oriented programming to use 'getters' and 'setters' to modify private member-variables of the class. You really should not be giving a pointer to a &lt;em&gt;private&lt;/em&gt; member. If you need to read/write it, add a setter function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class RaceHandler&#xA;{&#xA;public:&#xA;    void setStartTime()&#xA;    {&#xA;        race_start_time = micros();&#xA;    }&#xA;&#xA;    void setStartTime(unsigned long start_time)&#xA;    {&#xA;        race_start_time = start_time;&#xA;    }&#xA;&#xA;    unsigned long getStartTime()&#xA;    {&#xA;        return race_start_time;&#xA;    }&#xA;&#xA;    unsigned long getElapsedRaceTime()&#xA;    {&#xA;        return micros() - race_start_time;&#xA;        // TODO: handle overflow of micros() after ~72 minutes&#xA;        // maybe use millis() instead&#xA;    }&#xA;&#xA;&#xA;private:&#xA;    unsigned long race_start_time;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously this is laborious.  Some languages have special support for getters and setters to provide the functionality with less syntax. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Time is always positive, use an unsigned long.  As people have already said, millis() &amp;amp; micros() return an unsigned long too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RaceHandler race1;&#xA;&#xA;race1.setStartTime();&#xA;&#xA;[...]&#xA;&#xA;unsigned long elapsed_time = race1.getElapsedRaceTime();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-10T23:56:24.023" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20554" PostTypeId="1" AcceptedAnswerId="20555" CreationDate="2016-02-11T02:55:22.517" Score="2" ViewCount="56" Body="&lt;p&gt;I am writing a project that involves using complementary filters to combine gyroscope and accelerator readings in 3 directions. The relevant code is below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CompFilter {&#xA; public:&#xA;   long prevTime;&#xA;   float alpha;&#xA;   int angle;&#xA;&#xA;   CompFilter(float Alph);&#xA;   int combine (float gyroRate, float accelAngle);&#xA;};&#xA;&#xA;CompFilter::CompFilter(float Alph) {&#xA; alpha = Alph;&#xA; prevTime = 0;&#xA; angle = 0;&#xA;}&#xA;&#xA;int CompFilter::combine(float gyroRate, float accelAngle){&#xA;  Serial.println(&quot;Here THREE&quot;);&#xA;&#xA; long timeStep = millis() - prevTime;&#xA; if (timeStep == 0) { timeStep = 1;}&#xA;&#xA; angle = alpha * (angle + gyroRate * timeStep);&#xA;&#xA; angle += (1.0 - alpha) * accelAngle;&#xA;&#xA; prevTime = millis();&#xA;&#xA; return angle;&#xA;}&#xA;&#xA;//Global Objects&#xA;CompFilter *senPitch; CompFilter *senRoll;  //Declare Complementary Filters&#xA;&#xA;&#xA;//Adjustable Parameters&#xA;float alpha = .5;   //Constant affecting Gyro's vs. Accel's influence on sensor reading&#xA;&#xA;void setup(void)&#xA;{&#xA;  //Open Data Channel&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;IMU Complementary Filter Tester&quot;)); Serial.println(&quot;&quot;);&#xA;&#xA; //Initialise TMU sensors&#xA; sensorInit(accel, mag, gyro);&#xA; senPitch = new CompFilter(alpha); senPitch = new CompFilter(alpha);&#xA;  Serial.println(&quot;HERE ONE&quot;);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA; //Variables for reading sensors&#xA; sensors_event_t accel_event, mag_event, gyro_event;&#xA; sensors_vec_t   orientation;&#xA;&#xA; // Retrieve Sensor Readings&#xA; accel.getEvent(&amp;amp;accel_event);&#xA; gyro.getEvent(&amp;amp;gyro_event);&#xA; mag.getEvent(&amp;amp;mag_event);&#xA;&#xA; Serial.println(&quot;HERE TWO&quot;);&#xA;&#xA; int anglePitch = senPitch-&amp;gt;combine(gyro_event.gyro.y, orientation.pitch);&#xA; int angleRoll = senRoll-&amp;gt;combine(gyro_event.gyro.x, orientation.roll);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to keep track of a couple of pieces of information for each direction, so rather than trying to use parallel arrays, I created a CompFilter class. I think I am using the correct syntax in the class and constructing the object, but I am getting very unusual outputs from Serial.print(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RE ONE&#xA;RE TWO&#xA;Here THREE&#xA;Here THREE&#xA;entary Filter Tester&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how I fiddle with the code, I can get setup() repeating over and over or loop() running once before silently failing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that I have misdirected a pointer somewhere, but I am not sure. I would appreciate any help.&lt;/p&gt;&#xA;" OwnerUserId="17242" LastEditorUserId="17242" LastEditDate="2016-02-11T03:00:33.380" LastActivityDate="2016-02-11T04:26:03.863" Title="Mysterious behavior when using objects" Tags="|arduino-mega|c++|class|pointer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20555" PostTypeId="2" ParentId="20554" CreationDate="2016-02-11T04:26:03.863" Score="3" Body="&lt;p&gt;Dave X is absolutely right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I never assigned the senRoll pointer to an object. Then when I tried to dereference it, it went to some random address. I guess there are very few memory protections, so rather than causing a seg fault it just caused erratic behavior. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help.&lt;/p&gt;&#xA;" OwnerUserId="17242" LastActivityDate="2016-02-11T04:26:03.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20556" PostTypeId="2" ParentId="20552" CreationDate="2016-02-11T05:30:25.710" Score="1" Body="&#xA;&#xA;&lt;p&gt;It would have been preferable if the author of that code had used proper bit masks. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  ADCSRA = 0xe5; // set the adc to free running mode&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RpyEo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RpyEo.png&quot; alt=&quot;ADCSRA&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, &lt;strong&gt;0xe5&lt;/strong&gt; is &lt;strong&gt;11100101&lt;/strong&gt; in binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that line could have been written:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  ADCSRA = bit (ADEN) | bit (ADSC) | bit (ADATE) | bit (ADPS2) | bit (ADPS0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The last two (ADPS2 and ADPS0) give the prescaler (of 32):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MpmBO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MpmBO.png&quot; alt=&quot;ADC prescaler&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other bits are explained in the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bit 7 – ADEN: ADC Enable&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Writing this bit to one enables the ADC. By writing it to zero, the ADC is turned off. Turning the ADC off while a&#xA;conversion is in progress, will terminate this conversion.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bit 6 – ADSC: ADC Start Conversion&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Single Conversion mode, write this bit to one to start each conversion. In Free Running mode, write this bit to&#xA;one to start the first conversion. The first conversion after ADSC has been written after the ADC has been&#xA;enabled, or if ADSC is written at the same time as the ADC is enabled, will take 25 ADC clock cycles instead of&#xA;the normal 13. This first conversion performs initialization of the ADC.&#xA;ADSC will read as one as long as a conversion is in progress. When the conversion is complete, it returns to&#xA;zero. Writing zero to this bit has no effect.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bit 5 – ADATE: ADC Auto Trigger Enable&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this bit is written to one, Auto Triggering of the ADC is enabled. The ADC will start a conversion on a&#xA;positive edge of the selected trigger signal. The trigger source is selected by setting the ADC Trigger Select bits,&#xA;ADTS in ADCSRB.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can work through the other registers in a similar way.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-11T05:30:25.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20557" PostTypeId="2" ParentId="20538" CreationDate="2016-02-11T06:32:32.060" Score="1" Body="&lt;p&gt;You can use &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/uln2803a.pdf&quot; rel=&quot;nofollow&quot;&gt;ULN2803&lt;/a&gt; driver IC on sink side (cathode), P channel MOSFET on anode/source side of common anode LED matrix. Since you need only 4 sinks you can pair every 2 i/o of ULN2803 so you can drive/sink 1A max load per row. This IC is cheap and widely available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MOSFET current and speed should match those of ULN2803. You can use BJT instead of MOSFET, but voltage drop on BJT will be higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar design is here: &lt;a href=&quot;http://www.avrfreaks.net/sites/default/files/Matrix_display2.png&quot; rel=&quot;nofollow&quot;&gt;8x8 LED matrix&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="13594" LastEditDate="2016-02-11T06:43:09.080" LastActivityDate="2016-02-11T06:43:09.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20558" PostTypeId="2" ParentId="20513" CreationDate="2016-02-11T08:15:19.917" Score="0" Body="&lt;p&gt;Modern tiny $20 toy quadcopters use a magnetometer to maintain a steady heading.    Duplicating that effect could be cheaper and more reliable than dual encoders.  On certain surfaces, like carpet, even perfect encoding with perfect voltage and wheels can't guarantee maintaining the heading.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One viable option might be to drive one wheel with your control system, drive the other wheel to maintain the magnetometer heading, and then steer by adjusting the target heading.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-11T08:15:19.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20561" PostTypeId="2" ParentId="20552" CreationDate="2016-02-11T10:24:54.477" Score="1" Body="&lt;p&gt;Nick Gammon already gave a very fine answer about the meaning of the&#xA;mysterious numbers you were wondering about. Here I am trying to answer&#xA;only your last question:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;why manipulate these directly in the first place, because if you&#xA;  reference the source code for analogRead() they look awfully similar.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;One of the reasons is, as Dave X said in a comment, to get a higher&#xA;sample rate. Assuming this is an Arduino Uno or similar (ATmega328P @&#xA;16 MHz), the Arduino core normally configures the ADC prescaler to 128.&#xA;This gives a conversion time of 104 µs (equal to 13 × prescaler ÷&#xA;F_CPU), and a maximum sample rate of about 9.6 kHz. This is fine for&#xA;telephone quality audio, but insufficient for hi-fi applications. This&#xA;example code sets the prescaler to 32 for a conversion time of 26 µs and&#xA;a maximum sample rate around 38 kHz. According to Atmel, the ADC should&#xA;work fine with this kind of sample rate, except that you should not&#xA;expect to get the full resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason, however, is not to get a &lt;em&gt;fast&lt;/em&gt; sample rate, but rather&#xA;to get a &lt;em&gt;consistent&lt;/em&gt; sample rate. The problem with &lt;code&gt;analogRead()&lt;/code&gt; is&#xA;that it is a &lt;em&gt;blocking&lt;/em&gt; function. If you look at its source code you&#xA;will see a busy wait like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ADSC is cleared when the conversion finishes&#xA;while (bit_is_set(ADCSRA, ADSC));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the CPU is not doing anything useful while waiting for&#xA;the ADC to finish the conversion. If you do &lt;code&gt;analogRead()&lt;/code&gt; in a loop,&#xA;the CPU will wait for the ADC, then the ADC will be idle while the CPU&#xA;completes the loop and so on. The conversion period is then the time&#xA;required by the ADC &lt;em&gt;plus&lt;/em&gt; the time taken by the CPU to loop. And the&#xA;CPU time is hard to predict because it can be influenced by interrupts&#xA;and by conditional branches inside the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code, in contrast, configures the ADC to work in &lt;em&gt;free running&#xA;mode&lt;/em&gt;. In this mode, the ADC starts a new conversion as soon as the&#xA;previous one is done. This way you get a steady sample rate while the&#xA;ADC and the CPU work in parallel. In the loop you see these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(!(ADCSRA &amp;amp; 0x10)); // wait for adc to be ready&#xA;ADCSRA = 0xf5; // restart adc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments are a bit misleading. The first line (which I would rather&#xA;write &lt;code&gt;loop_until_bit_is_set(ADCSRA, ADIF);&lt;/code&gt;) waits for a flags that is&#xA;set when the current conversion is done and the data register updated.&#xA;The next line does not restart the ADC (it restarted itself, as it is in&#xA;free running mode): it only clears the flag so that it can be&#xA;meaningfully tested on the next iteration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I have a few comments on this code that are not directly related to&#xA;your question, but may be useful if you are going to build your program&#xA;on this basis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, it should be noticed that the whole ADC-reading loop is done with&#xA;interrupts disabled. This is &lt;em&gt;not&lt;/em&gt; normally needed, as the free running&#xA;mode gives you a steady sampling even if the CPU timing is somewhat&#xA;jittery. The only valid reason I see for disabling interrupts is if&#xA;one of your ISRs takes so long to execute that you may miss one sample.&#xA;This could very well be the case with such a high sampling frequency.&#xA;But still, there is no point in keeping the interrupts disabled during&#xA;the FFT processing. And there is no point in turning off Timer 0 if you&#xA;are disabling interrupts anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My second point is about the three lines starting with &lt;code&gt;byte m = ADCL;&lt;/code&gt;.&#xA;Those are meant to read the ADC data register in the proper order: low&#xA;byte first. However, the C compiler is well aware of the proper way to&#xA;do read a 16-bit I/O register (see “Accessing 16-bit Registers” in the&#xA;datasheet chapter about Timer 1). Thus, these three lines can be&#xA;simplified to just &lt;code&gt;int k = ADC;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My last point is that having the CPU left adjust the result (&lt;code&gt;k &amp;lt;&amp;lt;= 6&lt;/code&gt;)&#xA;takes some time, as it is implemented as a loop. There is no point in&#xA;doing this when the ADC can do it for free: you just have to set the&#xA;ADLAR bit when configuring ADMUX in &lt;code&gt;setup()&lt;/code&gt;. Then the 5 lines starting&#xA;with &lt;code&gt;byte m = ADCL;&lt;/code&gt; would be reduced to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int k = ADC - 0x8000;  // ADC reading as a 16 bit signed int&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-11T10:24:54.477" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20562" PostTypeId="1" AcceptedAnswerId="20563" CreationDate="2016-02-11T10:27:16.400" Score="0" ViewCount="2120" Body="&lt;p&gt;I have two Nano boards, but the first one seems the CH340 chipset was burn. :( ,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Nano v3, CH340 chipset but unable to identify after connect to my Mac using USB&lt;/li&gt;&#xA;&lt;li&gt;Nano v3, FTDI chipset and in good condition&lt;/li&gt;&#xA;&lt;li&gt;USB to Serial module, using FTDI chipset&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am trying to upload a sketch via a USB-to-Serial module OR another Nano board (or UNO board v3) to my CH340 Nano Board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to wire them up?&lt;/li&gt;&#xA;&lt;li&gt;Is it need upload a &quot;Arduino as ISP&quot; first?&lt;/li&gt;&#xA;&lt;li&gt;step-by-step tutorial or website talking about this ??&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4833" LastActivityDate="2016-02-16T01:26:50.770" Title="How to upload a sketch via Arduino Nano" Tags="|serial|arduino-nano|isp|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20563" PostTypeId="2" ParentId="20562" CreationDate="2016-02-11T10:49:17.377" Score="2" Body="&lt;p&gt;I presume you have boot loader on your Nano, so you can use your USB to serial, just wire (D0)TX-&gt;RX(USB), (D1)RX-&gt;TX(USB), GND-GND and supply power to the target Nano. You will need to reboot Nano just before the uploading the code. Uploading is same as usual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using other Arduino as ISP needs more wires as well as 2nd Arduino, so i would use above method.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-02-11T10:49:17.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20565" PostTypeId="1" CreationDate="2016-02-11T11:37:23.083" Score="4" ViewCount="1261" Body="&lt;p&gt;I am using an Arduino UNO along with a Cooking Hacks CAN Bus Module and Multiprotocol Radio Shield. The CAN module is connected to the radio shield which is plugged into the Arduino. I got this radio shield keeping future applications in mind where I can combine multiple protocols, for eg. CAN and Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected them through an OBD2-DB9 cable to the car's OBD port but noticed that I was not really getting any messages. Well I am getting messages but just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   -- Constructor Can(uint16_t speed) --&#xA;   SPI configured&#xA;   The MCP2515 has been successfully reset, configuration mode activated&#xA;   Speed=500kps&#xA;   -- End Constructor Can(uint16_t speed) --&#xA;&#xA;   Data in buffer 0&#xA;   id: 7FF  rtr: FFFFFFFF =&amp;gt; Data in buffer 0&#xA;   id: 7FF  rtr: FFFFFFFF =&amp;gt; Data in buffer 0&#xA;   id: 7FF  rtr: FFFFFFFF =&amp;gt; Data in buffer 0 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After analysing the connections, I realised that the hardware is probably fine since the continuity between the pins of the cables is fine and the CAN module(MCP2515 + MCP2551) is receiving power and I also checked the voltages at the pins and think they're mostly fine apart from a few pins which I'm not sure about. Which brings me to the software issue. I can see that the SPI is not getting configured properly and the MCP2515 controller doesn't enter configuration mode which means the bit times defined are not being used and hence the controller is not initialising like it should. I even tried manually changing to configuration mode by changing the values of the REQOP bits of the CANCTRL register as opposed to doing a software reset which was how I was doing it initially. Even then, no luck. To verify the SPI connection, I chose a random read/write control register like BFPCTRL and wrote a value to it and then read it back to verify that it matched the values I wrote. However, the value read back is not the same as the value I wrote. Also, the controller only has trouble going into configuration mode. It seems to change to normal and listen only mode without problem since the CANSTAT register displays the correct values for the REQOP bits. I don't understand why the controller has problem entering configuration mode but no problem changing to the other modes. Can anybody help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    bool CAN::begin(uint16_t speed)&#xA;    {&#xA;    #if (DEBUGMODE ==1 )&#xA;    Serial.println(&quot;-- Constructor Can(uint16_t speed) --&quot;);&#xA;    #endif&#xA;&#xA;    //Initialization SPI&#xA;    SPI.begin();&#xA;    SPI.detachInterrupt(); &#xA;    SPI.setBitOrder(MSBFIRST);&#xA;    // both mode 0 &amp;amp; 3 should work&#xA;    SPI.setDataMode(SPI_MODE0); &#xA;&#xA;    //Set the SPI frequency&#xA;    SPI.setClockDivider(SPI_CLOCK_DIV4);&#xA;&#xA;    #if (DEBUGMODE==1)&#xA;    Serial.println(&quot;SPI configured&quot;);&#xA;    #endif&#xA;&#xA;    //Configure MCP2515 pins&#xA;    pinMode(CAN_CS,OUTPUT);&#xA;    pinMode(CAN_INT,INPUT);&#xA;    digitalWrite(CAN_CS,HIGH);&#xA;&#xA;    writeRegister(BFPCTRL, (1&amp;lt;&amp;lt;B0BFM) | (1&amp;lt;&amp;lt;B1BFM));&#xA;    int dat = readRegister(BFPCTRL&amp;lt;&amp;lt;2);&#xA;    Serial.println(dat);&#xA;&#xA;    //Software resets MCP2515&#xA;    reset();&#xA;    delay(100);&#xA;    //After the reset, controller enters configuration mode &#xA;    dispMode();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I read back the values of B0BFM and B1BFM bits, they should be 1 but the display says that their values are 0. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   void CAN::writeRegister( char direction, char data )&#xA;   {&#xA;   //CS low to select the MCP2515 &#xA;   digitalWrite(CAN_CS,LOW);&#xA;&#xA;  SPI.transfer(SPI_WRITE);&#xA;  SPI.transfer(direction);&#xA;  SPI.transfer(data);&#xA;&#xA;  //CS line again to release &#xA;  digitalWrite(CAN_CS,HIGH);&#xA;   }&#xA;&#xA;  char CAN::readRegister(char direction)&#xA;  {&#xA;  char data;&#xA;  //CS low to select the MCP2515 &#xA;  digitalWrite(CAN_CS,LOW);&#xA;&#xA;  SPI.transfer(SPI_READ);&#xA;  SPI.transfer(direction); &#xA;  //Read data SPI&#xA;  data = SPI.transfer(0xff); &#xA;&#xA;  //CS line again to release &#xA;  digitalWrite(CAN_CS,HIGH);&#xA;  return data;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17215" LastEditorUserId="17215" LastEditDate="2016-02-29T05:13:39.640" LastActivityDate="2016-03-25T10:38:34.317" Title="Arduino CAN SPI Configuration problem" Tags="|arduino-uno|spi|can-bus|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20574" PostTypeId="1" AcceptedAnswerId="20575" CreationDate="2016-02-11T19:51:44.303" Score="1" ViewCount="9007" Body="&lt;p&gt;I am trying to get an Arduino to work with some Adafruit Motor shields. &#xA;Everything seemed to work fine, but when I tried to create a function, I get the error in the subject. As far as I can tell, everything was declared properly (the array is initialized and is indexed elsewhere with without issue). Only the function seems to cause an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would anyone have a guess at what's wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //////// Imports&#xA;    #include &amp;lt;Wire.h&amp;gt;&#xA;    #include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;    #include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;    ////////My globals. Times are in milliseconds&#xA;    unsigned long currentTime = 0;&#xA;    unsigned long elapsedTime = 0;&#xA;    unsigned long startTime = 0;&#xA;    byte currentMotor = 1;&#xA;    byte currentShield = 1;&#xA;    byte motorRunning = 0;&#xA;&#xA;    //// Settings&#xA;&#xA;    // How many seconds between motors&#xA;    unsigned long endTime = 4000;&#xA;&#xA;    // How many shields and motors per shield&#xA;    const int nShields = 1;&#xA;    const int nMotorsPerShield = 3;&#xA;&#xA;    /////////MicroManager globals&#xA;    unsigned int version_ = 2;&#xA;    const unsigned long timeOut_ = 1000;&#xA;    byte currentPattern_ = 0;&#xA;    unsigned long time;&#xA;&#xA;    /////////Adafruit globals&#xA;    Adafruit_MotorShield afms[nShields];&#xA;    Adafruit_DCMotor *motor[nShields][nMotorsPerShield];&#xA;&#xA;    ////////////Setup&#xA;    void setup() {&#xA;      Serial.begin(57600);&#xA;&#xA;      unsigned char address = 96;&#xA;&#xA;      for (int i = 0; i &amp;lt; nShields; i++) {&#xA;        afms[i] = Adafruit_MotorShield(address);&#xA;        address = ++address;&#xA;        afms[i].begin();&#xA;      }&#xA;&#xA;      for (int i = 0; i &amp;lt; nShields; i++) {&#xA;        for (int j = 0; j &amp;lt; nMotorsPerShield; j++) {&#xA;          motor[i][j] = afms[i].getMotor(j + 1);&#xA;          motor[i][j]-&amp;gt;setSpeed(255);&#xA;        }&#xA;      }&#xA;&#xA;      pinMode(13, OUTPUT);&#xA;    }&#xA;&#xA;    ////////////////////Main&#xA;    void loop() {&#xA;      currentTime = millis();&#xA;      elapsedTime = currentTime - startTime;&#xA;&#xA;      if (elapsedTime &amp;gt; endTime) {&#xA;        startTime = currentTime;&#xA;        currentMotor = currentMotor + 1;&#xA;        if (currentMotor &amp;gt; nMotorsPerShield) {&#xA;          currentMotor = 1;&#xA;        }&#xA;      }&#xA;&#xA;      if (Serial.available() &amp;gt; 0) {&#xA;        int inByte = Serial.read();&#xA;&#xA;        switch (inByte) {&#xA;          case 1:&#xA;            if (waitForSerial(timeOut_)) {&#xA;              currentPattern_ = Serial.read();&#xA;              if (currentPattern_ == 0) {&#xA;                for (int i = 0; i &amp;lt; nShields; i++) {&#xA;                  for (int j = 0; j &amp;lt; nMotorsPerShield; j++) {&#xA;                    motor[1][j]-&amp;gt;run(RELEASE);&#xA;                  }&#xA;                }&#xA;              }&#xA;              else {&#xA;                switchMotor();&#xA;              }&#xA;              Serial.write( byte(1));&#xA;              digitalWrite(13, HIGH);&#xA;            }&#xA;            break;&#xA;&#xA;          case 30:&#xA;            Serial.println(&quot;MM-Ard&quot;);&#xA;            break;&#xA;&#xA;          case 31:&#xA;            Serial.println(version_);&#xA;            break;&#xA;        }&#xA;      }&#xA;&#xA;      digitalWrite(13, LOW);&#xA;    }&#xA;&#xA;&#xA;    ////////////////Function definitions&#xA;&#xA;    bool waitForSerial(unsigned long timeOut)&#xA;    {&#xA;      unsigned long starTime = millis();&#xA;      while (Serial.available() == 0 &amp;amp;&amp;amp; (millis() - starTime &amp;lt; timeOut) ) {}&#xA;      if (Serial.available() &amp;gt; 0)&#xA;        return true;&#xA;      return false;&#xA;    }&#xA;&#xA;    void switchMotor()&#xA;    {&#xA;      int shield = currentShield - 1;&#xA;      int motor = currentMotor - 1;&#xA;      for (int i = 0; i &amp;lt; nShields; i++) {&#xA;        for (int j = 0; j &amp;lt; nMotorsPerShield; j++) {&#xA;          if (i == shield &amp;amp;&amp;amp; j == motor)&#xA;            motor[i][j]-&amp;gt;run(FORWARD);&#xA;          else&#xA;            motor[i][j]-&amp;gt;run(RELEASE);&#xA;        }&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17267" LastEditorUserId="6936" LastEditDate="2016-02-12T04:20:54.730" LastActivityDate="2019-01-23T06:16:59.397" Title="Error: invalid types 'int[int]' for array subscript" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20575" PostTypeId="2" ParentId="20574" CreationDate="2016-02-11T19:59:45.387" Score="2" Body="&lt;p&gt;Take a close look at this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;motor[1][j]-&amp;gt;run(RELEASE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looks like it should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;motor[i][j]-&amp;gt;run(RELEASE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise it is an illegal index (as there is only one shield). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next error is in the function switchMotor(). Again, have a close look at the definition of &quot;motor&quot;. There is a local variable with that name but you want to also access the global array with the same name.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void switchMotor()&#xA;{&#xA;  int shield = currentShield - 1;&#xA;  int motor = currentMotor - 1;&#xA;      ^&#xA;  for (int i = 0; i &amp;lt; nShields; i++) {&#xA;    for (int j = 0; j &amp;lt; nMotorsPerShield; j++) {&#xA;      if (i == shield &amp;amp;&amp;amp; j == motor)&#xA;        motor[i][j]-&amp;gt;run(FORWARD);&#xA;        ^&#xA;      else&#xA;        motor[i][j]-&amp;gt;run(RELEASE);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My guess is that this is where the compiler give you the error message!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-11T21:03:40.550" LastActivityDate="2016-02-11T21:03:40.550" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20576" PostTypeId="1" AcceptedAnswerId="20595" CreationDate="2016-02-11T21:00:33.513" Score="2" ViewCount="173" Body="&lt;p&gt;I have tried everything but I can't get my binary clock to display correctly. The diagram and code are here: &lt;a href=&quot;https://123d.circuits.io/circuits/1586601-binary-clock&quot; rel=&quot;nofollow&quot;&gt;Binary Clock | Electronics Lab&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware is based off this (it also explains the process that my program is trying to do): &lt;a href=&quot;http://www.danielandrade.net/2008/07/15/binary-clock-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;DIY: Binary Clock with Arduino&lt;/a&gt;. The problems lie in a, probably, simple error as my variable &lt;code&gt;tempTime&lt;/code&gt;, which is used to convert the individual digits to their binary equivalent, does not change when I tell it to. All this occurs in the display function. (Sorry, I'm new Here and only a high school student)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While debugging it I realized that the only problem is the variable &lt;code&gt;tempTime&lt;/code&gt; - the hardware and other functions work as they were intended. &#xA;Can anyone help? (Sorry if this is not very well documented).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int digitPins[4][4] = {{13,6,-1,-1},{12,7,3,1},{11,8,4,-1},{10,9,5,2}};&#xA;int time[4] = {0,0,0,0};&#xA;int steps[4]={1,2,4,8};&#xA;int tempTime = 0;&#xA;void setup(){&#xA;  for(int x = 0; x &amp;lt; 4; x++){&#xA;    for(int y =0; y&amp;lt;4; y++){&#xA;    pinMode(digitPins[x][y],OUTPUT);&#xA;    }&#xA;  }&#xA;    Serial.begin(9600);&#xA;    convertHour(12);&#xA;    convertMinute(57);&#xA;    Serial.println(&quot;The time is:&quot;);&#xA;&#xA;  for(int z = 0; z &amp;lt; 4; z++){&#xA;    if(z == 2){&#xA;    Serial.print(&quot;:&quot;);&#xA;    }&#xA;  Serial.print(time[z]);&#xA;  }&#xA;  display();&#xA;}&#xA;void loop(){&#xA;&#xA;}&#xA;void display(){&#xA;  int displayer[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};&#xA;/*&#xA;0 - Hour&#xA;1 - Hour&#xA;2 - Minute&#xA;3 - Minute&#xA;4 - Hour(Total)&#xA;5 - Minute(Total)&#xA;*/&#xA;&#xA;  int counter1 = 0;&#xA;  for(int i = 0; i &amp;lt; 4; i++){ //Loop for the individual digits&#xA;    tempTime = time[i];&#xA;    if(tempTime &amp;gt;= 10){&#xA;    tempTime = tempTime % 10;&#xA;    }&#xA;    Serial.print(&quot;\nBegining new iteration i = &quot;);&#xA;    Serial.print(&quot;\nStarting with digit: &quot;);&#xA;    Serial.print(tempTime);&#xA;    Serial.print(i);&#xA;    Serial.println(&quot;&quot;);&#xA;    for(int j = 3; j &amp;gt;= 0; j--){//Loop to determin the arrangement&#xA;      if(time[i]/steps[j] &amp;gt;= 1 &amp;amp;&amp;amp; steps[j] &amp;gt; 0 &amp;amp;&amp;amp; digitPins[i][j] &amp;gt; 0){&#xA;        Serial.print(&quot;\n&quot;);&#xA;        Serial.print(time[i]);&#xA;        Serial.print(&quot;/&quot;);&#xA;        Serial.print(steps[j]);&#xA;        Serial.print(&quot; = &quot;);&#xA;        Serial.print(time[i]/steps[j]);&#xA;        tempTime =tempTime - (time[i]*steps[j]);&#xA;        displayer[counter1] = digitPins[i][j];&#xA;        Serial.print(&quot;\nAdded: &quot;);&#xA;        Serial.print(digitPins[i][j]);&#xA;        counter1++;&#xA;      }&#xA;    }&#xA;&#xA;  }&#xA;  clear();&#xA;  for(int a = 0; a &amp;lt; 13; a++){&#xA;  digitalWrite(displayer[a],HIGH);&#xA;  }&#xA;}&#xA;void clear(){&#xA;  for(int x = 0; x &amp;lt; 4; x++){&#xA;    for(int y =0; y&amp;lt;4; y++){&#xA;    digitalWrite(digitPins[x][y],LOW);&#xA;    }&#xA;  }&#xA;}&#xA;  void convertHour(int value){&#xA;    int digits[] = {0,0};&#xA;    if(value &amp;gt;= 10){&#xA;        debug(&quot;Bigger than 10&quot;);&#xA;        if(value &amp;gt;= 20){&#xA;            digits[0] = 2;  &#xA;        }else{&#xA;            digits[0] = 1;&#xA;        }&#xA;    }&#xA;    digits[1] = value - (digits[0] * 10);&#xA;    //String hour = digits[0]+&quot;&quot;+digits[1];&#xA;    //Serial.print(digits[0]);&#xA;    //Serial.print(digits[1]);&#xA;    time[0] = digits[0];&#xA;    time[1] = digits[1];&#xA;  }&#xA;void convertMinute(int value){&#xA;  int digits[2] = {0,0};&#xA;  int val = value;&#xA;  if(value &amp;gt;= 10){&#xA;    digits[0] = val/10;&#xA;  }&#xA;  digits[1] = value - (digits[0] * 10);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  Serial.print(digits[0]);&#xA;  Serial.print(digits[1]);&#xA;  time[2] = digits[0];&#xA;  time[3] = digits[1];&#xA;}&#xA;  void debug(String value){&#xA;    boolean de = true;&#xA;    if(de){&#xA;    Serial.println(value);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17269" LastEditorUserId="17269" LastEditDate="2016-02-12T04:39:55.980" LastActivityDate="2016-02-12T11:21:13.630" Title="Need help debugging my Binary Clock" Tags="|c++|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20577" PostTypeId="2" ParentId="20501" CreationDate="2016-02-11T21:53:44.960" Score="2" Body="&lt;p&gt;You mean like this one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/products/1334?gclid=CM-al4jZ8MoCFQtFaQoddHEFxg&quot; rel=&quot;nofollow&quot;&gt;Adafruit RGB Color Sensor&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have similar products in different form factors.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2016-02-11T21:53:44.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20578" PostTypeId="2" ParentId="14018" CreationDate="2016-02-11T21:57:35.557" Score="0" Body="&lt;p&gt;My version of OS X 10.11 did not have the driver installed for the FTDI cable that I had.  I downloaded the drivers here (for free): &lt;a href=&quot;http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&amp;amp;pcid=41&quot; rel=&quot;nofollow&quot;&gt;PL2303 Mac OS X Driver Download&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17270" LastEditorUserId="6936" LastEditDate="2016-02-12T03:54:28.707" LastActivityDate="2016-02-12T03:54:28.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20579" PostTypeId="2" ParentId="20190" CreationDate="2016-02-11T22:02:05.787" Score="1" Body="&lt;p&gt;I suggest you take a look at &lt;a href=&quot;https://stackoverflow.com/questions/16274451/operator-new-for-arduino&quot;&gt;https://stackoverflow.com/questions/16274451/operator-new-for-arduino&lt;/a&gt; the new operator is not coming from the c++ libraries, it is coming from the Arduino libraries.  It's a wrapper for malloc &lt;a href=&quot;https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino&quot;&gt;Is using malloc() and free() a really bad idea on Arduino?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2837" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-02-11T22:02:05.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20581" PostTypeId="2" ParentId="20574" CreationDate="2016-02-11T23:02:26.153" Score="0" Body="&lt;p&gt;I get a warning flag in UECIDE for the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address = ++address;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;‣ operation on 'address' may be undefined [-Wsequence-point]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Increment address, and then assign the new value from address into address.  That seems a bit odd to me.  I think you just meant to increment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address++;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address = address + 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also it flags up the &lt;code&gt;1&lt;/code&gt; instead of &lt;code&gt;i&lt;/code&gt; that Mikael found:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;‣ array subscript is above array bounds [-Warray-bounds]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And of course there is the (somewhat hard to spot - Kudos to Mikael for finding it - it took me a bit to see it myself) naming conflict:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;‣ invalid types 'int[int]' for array subscript&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It was only when I used the advanced editing facilities of UECIDE to highlight all occurrences of &lt;code&gt;motor&lt;/code&gt; that I found there was extra ones that shouldn't have been there causing the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/65Hhb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/65Hhb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So just changing the integer variable name from &lt;code&gt;motor&lt;/code&gt; to something else fixes it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void switchMotor()&#xA;{&#xA;  int shield = currentShield - 1;&#xA;  int thismotor = currentMotor - 1;       // RENAMED MOTOR&#xA;  for (int i = 0; i &amp;lt; nShields; i++) {&#xA;    for (int j = 0; j &amp;lt; nMotorsPerShield; j++) {&#xA;      if (i == shield &amp;amp;&amp;amp; j == thismotor)  // RENAMED MOTOR&#xA;        motor[i][j]-&amp;gt;run(FORWARD);&#xA;      else&#xA;        motor[i][j]-&amp;gt;run(RELEASE);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-11T23:02:26.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20582" PostTypeId="1" CreationDate="2016-02-12T06:43:23.147" Score="2" ViewCount="6226" Body="&lt;p&gt;It looks like on ATMega based boards, &lt;code&gt;float&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt; are equivalent 32-bit (4-byte) data types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, on the Arduino Due, &lt;code&gt;doubles&lt;/code&gt; are 64-bit (8-byte) where &lt;code&gt;floats&lt;/code&gt; are 32-bit (4-byte), same as the ATMega boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also saw one source on avr-gcc that listed &lt;code&gt;double&lt;/code&gt; as non-standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, when writing code for ATMega based boards are &lt;code&gt;floats&lt;/code&gt; preferable to using &lt;code&gt;doubles&lt;/code&gt;, since that would make the code equivalent for Due boards? Or are &lt;code&gt;doubles&lt;/code&gt; preferable for any reason?&lt;/p&gt;&#xA;" OwnerUserId="12146" LastEditorUserId="37523" LastEditDate="2019-11-16T20:02:58.833" LastActivityDate="2019-11-16T20:02:58.833" Title="Since double and float represent the same data type (usually), which is preferable?" Tags="|programming|arduino-ide|avr|data-type|avr-gcc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20583" PostTypeId="2" ParentId="20582" CreationDate="2016-02-12T07:14:37.973" Score="2" Body="&lt;p&gt;See &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc&quot; rel=&quot;nofollow&quot;&gt;avr-gcc&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Deviations from the Standard&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;double&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;double is only 32 bits wide and implemented in the same way as float&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when writing code for ATMega based boards ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They are the same, therefore.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When writing code, is it then preferable to using one over the other?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't really understand your question. You asked about writing code for the ATMega based boards. Do you really mean, if you are writing code for the Due? The quick answer would be, on the Due, double takes twice the RAM, however it is over twice as precise - around 7.2 decimal digits for float compared to 15.9 for double. (I'm not sure about the speed, probably double would be slower, unless it is implemented in floating-point hardware - however I cannot see any reference to that on the AT91SAM3X8E datasheet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;https://en.wikipedia.org/wiki/Floating_point&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Floating_point&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want more precision (however slower and taking more RAM) then you could use &lt;code&gt;double&lt;/code&gt; - which won't make any difference on the ATmega based boards, but will on the Due.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As Edgar Bonet said:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I would use float so that anyone reading my code, who may not know about the non-standard AVR double, knows what precision to expect.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That makes quite a bit of sense.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I warn you though that &quot;preferable&quot; is subjective. It is close to asking &quot;what is best&quot;? To which the reply is: &quot;best for what?&quot;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-13T02:20:02.393" LastActivityDate="2016-02-13T02:20:02.393" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="20584" PostTypeId="1" CreationDate="2016-02-12T07:37:25.670" Score="1" ViewCount="191" Body="&lt;p&gt;I have two Arduino Uno R3 boards and both of them now seem to have an issue. There's a micro sized 8 Pin chip near the dc power port. This seems to get incredibly hot (i managed to get a blister from touching it) and the &quot;L&quot; Led seems to stay dimly lit even when the reset button is pressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno was working fine during operation and only started giving me this problem recently, i cant seem to find any visible short or loose terminal on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see that the reset function is being used as my LCD does reset. &#xA;Would anyone have a reason for this mysterious issue?&lt;/p&gt;&#xA;" OwnerDisplayName="Cameron" LastEditorUserId="9962" LastEditDate="2016-02-12T23:26:43.163" LastActivityDate="2016-06-12T01:26:08.457" Title="Arduino Hardware Issue" Tags="|hardware|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20586" PostTypeId="2" ParentId="1829" CreationDate="2016-02-12T09:43:43.150" Score="0" Body="&lt;p&gt;Just an idea. On adafruit.com there's a product called Trinket which is an ATtiny85 microcontroller board. It can communicate over I2C using their TinyWireM library. Maybe you should  check it out for reference. I hope it helps :)&lt;/p&gt;&#xA;" OwnerUserId="17279" LastEditorUserId="11529" LastEditDate="2016-02-12T11:24:29.097" LastActivityDate="2016-02-12T11:24:29.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20587" PostTypeId="2" ParentId="20582" CreationDate="2016-02-12T09:45:43.343" Score="1" Body="&lt;p&gt;Neither are preferable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless your microcontroller has a hardware floating point unit using float or double results in huge overheads for your program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead use integer mathematics whenever possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of working in Volts, work in millivolts, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if your MCU does have an FPU, and some modern more powerful ones do, then you should use the size of float or double that is native to the FPU. If it is a 32 bit FPU then use float. If it is a 64 bit FPU then you can use double.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-12T09:45:43.343" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20588" PostTypeId="1" CreationDate="2016-02-12T09:59:01.257" Score="2" ViewCount="1076" Body="&lt;p&gt;I'm learning &lt;a href=&quot;http://www.atmel.com/images/Atmel-42301-SAM3-4S-4L-4E-4N-4CM-4C-G-Timer-Counter-TC-Driver_ApplicationNote_AT07898.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;this note&lt;/a&gt; about timer's api on &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Due&lt;/a&gt;. Interrupt can be attached with the next function:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void tc_enable_interrupt(&#xA;       Tc * p_tc,&#xA;       uint32_t ul_channel,&#xA;       uint32_t ul_sources)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where the input parameter ul_sources can be one or more of the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_COVFS&lt;/strong&gt; Enables the Counter Overflow Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_LOVRS&lt;/strong&gt; Enables the Load Overrun Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_CPAS&lt;/strong&gt;  Enables the RA Compare Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_CPBS&lt;/strong&gt;  Enables the RB Compare Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_CPCS&lt;/strong&gt;  Enables the RC Compare Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_LDRAS&lt;/strong&gt; Enables the RA Load Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_LDRBS&lt;/strong&gt; Enables the RB Load Interrupt&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TC_IER_ETRGS&lt;/strong&gt; Enables the External Trigger Interrupt&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I'm more like mobile developer and I don't understand what does all this interrupt types mean.&lt;/p&gt;&#xA;" OwnerUserId="16074" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-13T10:45:01.300" Title="Understanding types of timer interrupts" Tags="|arduino-due|interrupt|timers|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20589" PostTypeId="1" CreationDate="2016-02-12T10:13:27.153" Score="1" ViewCount="513" Body="&lt;p&gt;I'm new to this Arduino programming. So I want to ask about my current project. My lecturer told me to make a temperature sensor using an LM35, where a green LED will light up when below some certain temperature that I set. The same goes for yellow and red LEDs for medium, and high temperatures. The tricky part here is that I need to make sure my buzzer (piezo) is on forever if it reaches the high temperature, until I press a button to reset it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my coding so far:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;const int greenLed = 3;&#xA;const int redLed = 4;&#xA;const int yellowLed = 5;&#xA;float tempC;&#xA;int reading;&#xA;int tempPin = 0;&#xA;int speakerOut = 11;&#xA;const int buttonPin = 2;     &#xA;int buttonState = 0;     &#xA;long duration = 10000;&#xA;int tempo = 0;&#xA;&#xA;void setup() {&#xA;// initialize digital pin 13 as an output.&#xA;pinMode(3, OUTPUT);&#xA;pinMode(4, OUTPUT);&#xA;pinMode(5, OUTPUT);&#xA;pinMode(2, INPUT);&#xA;pinMode(11, OUTPUT);&#xA;analogReference(INTERNAL);&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;buttonState = digitalRead(buttonPin);&#xA;reading = analogRead(tempPin);&#xA;tempC = reading / 9.31;&#xA;Serial.println(tempC);&#xA;delay(500);&#xA;&#xA;if (tempC &amp;lt; 30.00) {&#xA;//Serial.println(&quot;Temp LOW&quot;);&#xA;digitalWrite(3, HIGH);&#xA;delay(10);&#xA;}else {&#xA;digitalWrite(3,LOW);&#xA;delay(10);&#xA;&#xA;}&#xA;&#xA;if (31.00 &amp;lt; tempC &amp;lt; 33){&#xA;//Serial.println(&quot;Temp MED&quot;);&#xA;digitalWrite(4,HIGH);&#xA;digitalWrite(5,LOW);&#xA;delay(50);&#xA;digitalWrite(4,LOW);&#xA;digitalWrite(5,HIGH);&#xA;delay(50);&#xA;&#xA;}else {&#xA;digitalWrite(4,LOW);&#xA;digitalWrite(5,LOW);&#xA;&#xA;}&#xA;&#xA;if(tempC &amp;gt;= 34){&#xA;**WHAT SHOULD I FILL UP HERE TO MAKE SURE MY PIEZO BUZZER ON FOREVER**&#xA;}&#xA;if(buttonState = 1);{&#xA;digitalWrite(11, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be great. Or if you have a better idea on how to do this, I'm gonna love it.&lt;/p&gt;&#xA;" OwnerUserId="17280" LastEditorUserId="6936" LastEditDate="2016-02-18T12:13:08.170" LastActivityDate="2016-02-18T12:13:08.170" Title="Arduino Infinity Loop" Tags="|programming|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20590" PostTypeId="1" CreationDate="2016-02-12T10:38:22.547" Score="1" ViewCount="175" Body="&lt;p&gt;I have a school project, where I'm going to make a traffic light system on a pls. I want to try it out on an Arduino first, just to get the hang of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it a little bit more advanced than I have found on the internet, I want to make the lights go in &quot;emergency mode&quot; if the green lights in both directions are on at the same time. It will then go into a yellow blink. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is something like this: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Yellow blinking if fault in the system or operator activates it&#xA;int killState = digitalRead(Kill);&#xA;int resState = digitalRead(Res);&#xA;if (killState == HIGH /*|| greenlights in both directions */) {&#xA; while (resState == LOW;) { // Yellow blink as long as system is not reset&#xA;  BLINK();&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I guess I need a variable or two that tells what state the lights are in, but I'm stuck. Any good solutions out there? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing is the reset button. I haven't put much effort in it, but I want it to go into the starting point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link to the complete script can be found &lt;a href=&quot;https://www.dropbox.com/s/evygp3w2gwvtxm9/lyskryss_v2.ino?dl=0&quot; rel=&quot;nofollow&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17282" LastEditorUserId="6936" LastEditDate="2016-02-18T12:31:28.000" LastActivityDate="2016-02-18T12:31:28.000" Title="Another traffic light project" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20592" PostTypeId="2" ParentId="20589" CreationDate="2016-02-12T10:44:19.177" Score="5" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://playground.arduino.cc/Code/ToneAC&quot;&gt;toneAC&lt;/a&gt; library, which allows even better handling of piezo speakers then the standard &quot;tone&quot;-functions.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt; Nearly twice the volume (because it uses two out of phase pins in push/pull fashion)&#xA;      Higher quality (less clicking)&#xA;      Capability of producing higher frequencies (even if running at a lower clock speed)&#xA;      Nearly 1.5k smaller compiled code&#xA;      Bug fixes (standard tone library can generate some odd and unpredictable results)&#xA;      Can set not only the frequency but also the sound volume&#xA;      Less stress on the speaker so it will last longer and sound better &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the library you can do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freq = 1000&#xA;int vol = 10&#xA;int length = 0&#xA;boolean background = true&#xA;&#xA;toneAC(freq, vol, length, background);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The tone now will play forever in the background, until you stop it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;toneAC(0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15493" LastActivityDate="2016-02-12T10:44:19.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20593" PostTypeId="2" ParentId="20590" CreationDate="2016-02-12T10:46:25.993" Score="1" Body="&lt;p&gt;For starters, take a close look at this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (resState == LOW;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is not the correct syntax. But the real issue is how is this while loop terminated? The value is never set again? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-12T10:46:25.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20594" PostTypeId="2" ParentId="20589" CreationDate="2016-02-12T10:50:22.543" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The answer is simple add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(speakerOut,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Common mistake made by beginners is to use assign operator instead of compare operator&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonState=1) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should actually be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonState==1)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Never pull that pin LOW&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonState = 1);{&#xA;digitalWrite(11, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is wrong use the below code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonState == 1){&#xA;    digitalWrite(11, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Don't forget to connect the button to buttonPin or you will get random HIGH or LOW from that pin since its floating&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="11916" LastEditorUserId="11529" LastEditDate="2016-02-12T12:18:30.463" LastActivityDate="2016-02-12T12:18:30.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20595" PostTypeId="2" ParentId="20576" CreationDate="2016-02-12T10:53:23.573" Score="0" Body="&lt;p&gt;In your “Loop to determin the arrangement”, you are erroneously using&#xA;&lt;code&gt;time[i]&lt;/code&gt; in several places where you mean &lt;code&gt;tempTime&lt;/code&gt;. Also, to update&#xA;&lt;code&gt;tempTime&lt;/code&gt; you only have to subtract &lt;code&gt;steps[j]&lt;/code&gt;. With these fixes, your&#xA;loop becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(int j = 3; j &amp;gt;= 0; j--){//Loop to determin the arrangement&#xA;  if(tempTime/steps[j] &amp;gt;= 1 &amp;amp;&amp;amp; steps[j] &amp;gt; 0 &amp;amp;&amp;amp; digitPins[i][j] &amp;gt; 0){&#xA;    Serial.print(&quot;\n&quot;);&#xA;    Serial.print(tempTime);&#xA;    Serial.print(&quot;/&quot;);&#xA;    Serial.print(steps[j]);&#xA;    Serial.print(&quot; = &quot;);&#xA;    Serial.print(tempTime/steps[j]);&#xA;    tempTime = tempTime - steps[j];&#xA;    displayer[counter1] = digitPins[i][j];&#xA;    Serial.print(&quot;\r\nAdded: &quot;);&#xA;    Serial.print(digitPins[i][j]);&#xA;    counter1++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, if you learn a little bit about how binary numbers work, and about&#xA;the binary operators in C and C++, you can rewrite your loop in a&#xA;simpler form:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int j = 3; j &amp;gt;= 0; j--) {&#xA;  int weight = 1 &amp;lt;&amp;lt; j;      // 2 raised to the power j&#xA;  if (tempTime &amp;amp; weight) {  // if bit j of tempTime is set&#xA;    displayer[counter1++] = digitPins[i][j];&#xA;    Serial.print(&quot;Added bit &quot;);&#xA;    Serial.print(j);&#xA;    Serial.print(&quot;, weight &quot;);&#xA;    Serial.print(weight);&#xA;    Serial.print(&quot;, output &quot;);&#xA;    Serial.println(digitPins[i][j]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As a side note, it is considered good practice to print a new line at&#xA;the &lt;em&gt;end&lt;/em&gt; of each string you print (using &lt;code&gt;println()&lt;/code&gt;), rather than at&#xA;the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: As your &lt;code&gt;display()&lt;/code&gt; function is way too complex for what it&#xA;does, I did not resist the temptation to simplify it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void display() {&#xA;  for (int i = 0; i &amp;lt; 4; i++)&#xA;    for (int j = 0; j &amp;lt; 4 &amp;amp;&amp;amp; digitPins[i][j] &amp;gt;= 0; j++)&#xA;      digitalWrite(digitPins[i][j], time[i] &amp;amp; (1&amp;lt;&amp;lt;j));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-02-12T11:21:13.630" LastActivityDate="2016-02-12T11:21:13.630" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20596" PostTypeId="1" CreationDate="2016-02-12T13:11:52.743" Score="-1" ViewCount="288" Body="&lt;p&gt;I am trying to read a 93lc46b EEPROM chip using Arduino. I am reusing the code from &lt;a href=&quot;http://owlsan.blogspot.de/2012/10/accessing-93c4693c46n-serial-eeprom.html&quot; rel=&quot;nofollow&quot;&gt;http://owlsan.blogspot.de/2012/10/accessing-93c4693c46n-serial-eeprom.html&lt;/a&gt;, except I have modified it for 93lc46b chip, plus I am using Arduino Uno and not Arduino Mega. The problem I am facing is, I get different set of bytes every time I try to read 93lc46b EEPROM chip. I doubt this might be some garbage data. Can you please explain me what and where exactly I am doing something wrong. The modified code snippet is as follows: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;#define CLEAN 0b00000000&#xA;&#xA;#define DDR93LC46B  _SFR_IO8(0x04)&#xA;#define PORT93LC46B _SFR_IO8(0x05)&#xA;#define PIN93LC46B  _SFR_IO8(0x03)&#xA;&#xA;#define SK 13 &#xA;#define DO 12 &#xA;#define DI 11 &#xA;#define CS 10 &#xA;&#xA;#define READ 0x02 &#xA;&#xA;#define SET_CS PORT93LC46B |= (1 &amp;lt;&amp;lt; CS)&#xA;#define CLR_CS PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; CS)&#xA;&#xA;#define SET_SK {PORT93LC46B |= (1 &amp;lt;&amp;lt; SK); _delay_us(0.01);}&#xA;#define CLR_SK PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; SK)&#xA;&#xA;#define SET_DI PORT93LC46B |= (1 &amp;lt;&amp;lt; DI)&#xA;#define CLR_DI PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; DI)&#xA;&#xA;class SPI_93LC46B {&#xA;  private:&#xA;    uint8_t Transfer(uint8_t data) {&#xA;      SPDR = data;&#xA;      while(!(SPSR &amp;amp; (1 &amp;lt;&amp;lt; SPIF))); // Wait for SPI interrupt flag&#xA;      return SPDR;                  // Return byte gathered from SPI data register&#xA;    }&#xA;    void Opcode(uint8_t opcode, uint8_t address) {&#xA;      SET_CS;&#xA;      SPCR &amp;amp;= ~(1 &amp;lt;&amp;lt; SPE);               // SPI disable&#xA;     _delay_us(1);&#xA;      CLR_SK;&#xA;      SET_DI;                            // Send start bit&#xA;      SET_SK;&#xA;      CLR_SK;&#xA;      SPCR |= (1 &amp;lt;&amp;lt; SPE);         // SPI enable&#xA;      Transfer((opcode &amp;lt;&amp;lt; 6) | address); // Transmit byte&#xA;    }&#xA;  public:&#xA;    SPI_93LC46B() {&#xA;      SPCR =    CLEAN        // Set SPI control register&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; SPIE)  // SPI interrupt disable&#xA;         |  (1 &amp;lt;&amp;lt; SPE)   // SPI enable&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; DORD)  // MSB first&#xA;         |  (1 &amp;lt;&amp;lt; MSTR)  // SPI master device&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; CPOL)  // SPI&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; CPHA)  //  mode 0&#xA;         |  (1 &amp;lt;&amp;lt; SPR1)  // XX/64 MHz&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; SPR0); //  speed&#xA;      SPSR =    CLEAN         // Init SPI status register&#xA;         &amp;amp; ~(1 &amp;lt;&amp;lt; SPI2X); // SPI double speed&#xA;      DDR93LC46B =    CLEAN      // Set up inputs/outputs&#xA;             |  (1 &amp;lt;&amp;lt; SK)  // Serial clock output&#xA;             |  (1 &amp;lt;&amp;lt; DI)  // Data input (MOSI) output&#xA;             |  (1 &amp;lt;&amp;lt; CS)  // Chip select output&#xA;             &amp;amp; ~(1 &amp;lt;&amp;lt; DO); // Data output (MISO) input&#xA;      PORT93LC46B |= (1 &amp;lt;&amp;lt; DO); // Data output (MISO) high&#xA;      CLR_DI;&#xA;      CLR_CS;    &#xA;      CLR_SK;&#xA;     _delay_us(1);&#xA;    }&#xA;    ~SPI_93LC46B() {&#xA;      //&#xA;    }&#xA;    uint16_t Read(uint8_t address) {&#xA;      uint16_t data = 0;&#xA;      Opcode(READ, address);              &#xA;      CLR_DI;&#xA;      SET_SK;                             &#xA;      CLR_SK;&#xA;      SPCR |=  (1 &amp;lt;&amp;lt; CPHA);       &#xA;      data = Transfer(0);&#xA;      data = (data &amp;lt;&amp;lt; 8) | (Transfer(0));&#xA;     _delay_us(1);&#xA;      CLR_CS;&#xA;      CLR_DI;&#xA;      SPCR &amp;amp;= ~(1 &amp;lt;&amp;lt; CPHA);   &#xA;      return data;&#xA;   }&#xA;};&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(115200);&#xA;  _delay_ms(100);&#xA;  Serial.println(&quot;EEPROM writing/reading&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  Serial.println(&quot;new round&quot;);&#xA;  SPI_93LC46B _93LC46B;&#xA;  int i;&#xA;  uint16_t data;&#xA;  for(i = 0; i &amp;lt; 64; i++) {&#xA;    data = _93LC46B.Read(i);&#xA;    _delay_ms(50);&#xA;    Serial.print(data, HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;    if((i + 1) % 8 == 0)&#xA;      Serial.println();&#xA;  }&#xA;  _delay_ms(10000);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17287" LastEditorUserId="4131" LastEditDate="2016-02-13T11:26:20.613" LastActivityDate="2016-02-13T11:46:19.757" Title="Trying to read a 93lc46b chip using Arduino" Tags="|arduino-uno|eeprom|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20597" PostTypeId="1" CreationDate="2016-02-12T18:33:39.607" Score="0" ViewCount="2084" Body="&lt;p&gt;I have 2 Arduino Nanos which don't output anything on any controllable pins except for RX and TX pins. I used an LED which I have tested works on the 3.3v/GND and 5.0v/GND. When I try to control the RX and TX pins (1 and 2) the LED lights up on the board and the external LED I am using to test. I am using the example &quot;Blink&quot; program to test it, and I've tried it on both nanos. I've tested pins 26 (serial), 5 (digital) and 15 (digital) and none output anything. Why isn't it working?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;  Blink&#xA;  Turns on an LED on for one second, then off for one second, repeatedly.&#xA;&#xA;  This example code is in the public domain.&#xA; */&#xA;&#xA;// Pin 13 has an LED connected on most Arduino boards.&#xA;// Pin 11 has the LED on Teensy 2.0&#xA;// Pin 6  has the LED on Teensy++ 2.0&#xA;// Pin 13 has the LED on Teensy 3.0&#xA;// give it a name:&#xA;int led = 26;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17298" LastEditorUserId="17298" LastEditDate="2016-02-12T19:16:29.610" LastActivityDate="2018-01-07T06:38:00.080" Title="Arduino Nano no output on any controllable pins except for RX and TX pins" Tags="|led|arduino-nano|digital|" AnswerCount="2" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="20598" PostTypeId="2" ParentId="20584" CreationDate="2016-02-12T20:24:59.037" Score="1" Body="&lt;p&gt;There are two issues here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The &quot;L&quot; LED lighting. On the R3 Uno this is driven by an op-amp and if pin 13 is &quot;floating&quot; the op-amp may, or may not, turn the LED on. So this is normal.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The 8-pin chip near the power plug getting very hot. This is definitely not normal. You must be consuming a lot of current to do that. You could try measuring it. A Uno running an &quot;empty&quot; sketch should be consuming around 50 mA. Note that this chip is the op-amp mentioned in my first point. Possibly you have damaged it. Did you connect an LED (or motor) or similar to pin D13? If so, what current-limiting precautions did you take?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Try running an empty sketch (or the Blink sketch) with no hardware connected to the board, to see if it still happens.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try measuring the power consumption, if possible, with a meter measuring the input through the 5V pin, if you have a 5V power supply you could use for this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Are these genuine boards, or cheap clones from eBay?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-12T20:24:59.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20599" PostTypeId="2" ParentId="20590" CreationDate="2016-02-12T20:34:44.830" Score="1" Body="&lt;p&gt;You could do something simple to test if both red and green are on,  eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead (RED_PIN) == HIGH &amp;amp;&amp;amp; digitalRead (GREEN_PIN) == HIGH)&#xA;  {&#xA;  digitalWrite (RED_PIN, LOW);  // turn off red&#xA;  digitalWrite (GREEN_PIN, LOW);  // turn off green&#xA;  while (true)&#xA;    {&#xA;    digitalWrite (YELLOW_PIN, HIGH);&#xA;    delay (500);&#xA;    digitalWrite (YELLOW_PIN, LOW);&#xA;    delay (500);&#xA;    }  // end of while&#xA;  }  // end of it&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you have other questions please post your code and not a &lt;a href=&quot;http://snippets-r-us.com/&quot; rel=&quot;nofollow&quot;&gt;snippet&lt;/a&gt; - however I suggest you try to get further on your own. This is obviously an exercise, and the more you try to work it out yourself the more you will learn.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-12T20:34:44.830" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20600" PostTypeId="2" ParentId="20597" CreationDate="2016-02-12T20:53:05.607" Score="3" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;I've tested pins 26 (serial), 5 (digital) and 15 (digital) and none output anything.&lt;/p&gt;&#xA;&lt;p&gt;No, the LED doesn't need a resistor ...&lt;/p&gt;&#xA;&lt;p&gt;because I tested it with the 5v and 3.3v therefore higher voltages doesn't blow it up&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Sounds to me like you have damaged your output pins. Read &lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/LEDs.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The care and feeding of LEDs&lt;/a&gt; by Mike Cook.&lt;/p&gt;&#xA;&lt;p&gt;The LED may briefly light up, but without a resistor you are damaging both the LED and the output pin. It is no surprise then, that afterwards the pins &amp;quot;none output anything&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;Without a limiting resistor the output driver on the Arduino is overloaded and may burn out. Whether you have damaged the LED, the pin, or both, is hard to say.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;still doesn't work on pins that I haven't used ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Can you slow down a bit?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I've tested pins 26 (serial) ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There is no pin 26 from the IDE point of view. On the board pin 26 is A7 (analog input 7) which &lt;strong&gt;cannot be used for digital input/output&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Please specify exactly what pin you tried (just choose one) and stick to the Arduino number (printed on the board, eg. D05) and then show the code you used to access that pin.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;According to this ... the analogue pins can be used just the same as digital pins&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;That page shows a Uno. You have a Nano.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Nano - Arduino.cc&lt;/a&gt;. On that page:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Analog pins 6 and 7 cannot be used as digital pins.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-19T20:49:35.667" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20601" PostTypeId="1" CreationDate="2016-02-12T23:01:47.970" Score="3" ViewCount="1735" Body="&lt;p&gt;I was looking at some macro use in an Arduino code. I believe what this macro does is it expands into a state that basically sets a pin to either input or output, but I'm a little confused about everything going on in this macro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do understand the point behind the do{...} while(0), but I'm sure what the ## are accomplishing. Also, what if anything do the underscores before DDR and PIN do? I would very appreciative of a simple clarification. Thank you!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MASK(PIN)  (1 &amp;lt;&amp;lt; PIN)&#xA;&#xA;/// set pin as input&#xA;#define _SET_INPUT(IO) do {DIO ##  IO ## _DDR &amp;amp;= ~MASK(DIO ## IO ## _PIN); } while (0)&#xA;/// set pin as output&#xA;#define _SET_OUTPUT(IO) do {DIO ##  IO ## _DDR |=  MASK(DIO ## IO ## _PIN); } while (0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2016-02-12T23:37:18.033" Title="Double ## in macros" Tags="|programming|pins|sketch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20602" PostTypeId="1" CreationDate="2016-02-12T23:17:23.337" Score="0" ViewCount="712" Body="&lt;p&gt;I'm using an rfid-rc522 and I want to print to the serial a string of text if two rfid tags have been read in a given time period. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially this:&lt;br&gt;&#xA; 1. First tag is read (print to serial: Tag 1 has been read)&lt;br&gt;&#xA; 2. Wait 2 seconds&lt;br&gt;&#xA; 3. Second tag is read (print to serial: Tag 2 has been read)&lt;br&gt;&#xA; 4. Print to serial: Tag 1 and Tag 2 has been read)&lt;br&gt;&#xA; 5. Bonus: Keep this state - and then when a button is pressed (print to serial: Tag 1 and Tag 2 are finished)&lt;br&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to read the UID and print to the serial if one is read. &#xA;Thank you so much for your help, it's greatly appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &amp;lt;Adafruit_ST7735.h&amp;gt; // Hardware-specific library&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;// For the breakout, you can use any 2 or 3 pins&#xA;// These pins will also work for the 1.8&quot; TFT shield&#xA;#define sclk 4  // SainSmart: SCL&#xA;#define mosi 5  // SainSmart: SDA&#xA;#define cs   6  // SainSmart: CS&#xA;#define dc   7  // SainSmart: RS/DC&#xA;#define rst  8  // SainSmart: RES&#xA;&#xA;Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);&#xA;&#xA;#define SS_PIN 10&#xA;#define RST_PIN 9&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);&#xA;&#xA;&#xA;float p = 3.1415926;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  SPI.begin();&#xA;  Serial.print(&quot;Starting cornhole leaderboard...&quot;);&#xA;  mfrc522.PCD_Init(); // Init MFRC522 card&#xA;  Serial.println(&quot;Scan PICC to see UID and type...&quot;);&#xA;  // Use this initializer if you're using a 1.8&quot; TFT&#xA;  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab&#xA;&#xA;  // Use this initializer (uncomment) if you're using a 1.44&quot; TFT&#xA;  //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab&#xA;&#xA;  Serial.println(&quot;Initialized&quot;);&#xA;&#xA;  uint16_t time = millis();&#xA;  tft.fillScreen(ST7735_BLACK);&#xA;  time = millis() - time;&#xA;&#xA;  Serial.println(time, DEC);&#xA;&#xA;  // large block of text&#xA;  tft.fillScreen(ST7735_BLACK);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Look for new cards&#xA;    if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;        return;&#xA;    }&#xA;&#xA;    // Select one of the cards&#xA;    if ( ! mfrc522.PICC_ReadCardSerial()) {&#xA;        return;&#xA;    }&#xA;&#xA;    if (mfrc522.uid.uidByte[0] == 0xA4 &amp;amp;&amp;amp; &#xA;       mfrc522.uid.uidByte[1] == 0xB8 &amp;amp;&amp;amp;&#xA;       mfrc522.uid.uidByte[2] == 0xB8 &amp;amp;&amp;amp;&#xA;       mfrc522.uid.uidByte[3] == 0x96) {&#xA;          Serial.println(&quot;Nate has checked in to the game.&quot;);&#xA;          tft.fillScreen(ST7735_BLUE);&#xA;          tft.setTextSize(2);&#xA;          tft.setCursor(0, 0);&#xA;          tft.setTextColor(ST7735_YELLOW);&#xA;          tft.print(&quot;Nate &quot;);&#xA;          tft.setTextColor(ST7735_WHITE);&#xA;          tft.println(&quot;has checked in &quot;);&#xA;          tft.setTextSize(2);&#xA;          tft.println(&quot;to the game.&quot;);&#xA;          delay(2000);&#xA;          tft.fillScreen(ST7735_BLACK);&#xA;    }&#xA;&#xA;    if (mfrc522.uid.uidByte[0] == 0x03 &amp;amp;&amp;amp; &#xA;       mfrc522.uid.uidByte[1] == 0xFD &amp;amp;&amp;amp;&#xA;       mfrc522.uid.uidByte[2] == 0xBC &amp;amp;&amp;amp;&#xA;       mfrc522.uid.uidByte[3] == 0x02) {&#xA;          Serial.println(&quot;Ted has checked in to the game.&quot;);&#xA;          tft.fillScreen(ST7735_RED);&#xA;          tft.setTextSize(2);&#xA;          tft.setCursor(0, 0);&#xA;          tft.setTextColor(ST7735_CYAN);&#xA;          tft.print(&quot;Ted &quot;);&#xA;          tft.setTextColor(ST7735_WHITE);&#xA;          tft.println(&quot;has checked in &quot;);&#xA;          tft.setTextSize(2);&#xA;          tft.println(&quot;to the game.&quot;);&#xA;          delay(2000);&#xA;          tft.fillScreen(ST7735_BLACK);&#xA;&#xA;    }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17305" LastActivityDate="2018-11-12T09:44:40.890" Title="How to perform action if two rfid tag UIDs have been detected?" Tags="|serial|rfid|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20603" PostTypeId="2" ParentId="20601" CreationDate="2016-02-12T23:25:56.030" Score="7" Body="&lt;p&gt;&lt;code&gt;##&lt;/code&gt; is the concatenation operator in macros. It joins two macros or pieces of text together when expanded.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define _SET_INPUT(IO) do {DIO ##  IO ## _DDR &amp;amp;= ~MASK(DIO ## IO ## _PIN); } while (0)&#xA;&#xA;_SET_INPUT(3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;woukd expand to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do {DIO3_DDR &amp;amp;= ~MASK(DIO3_PIN); } while (0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can read more about how it works here: &lt;a href=&quot;https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html&quot;&gt;https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-02-12T23:37:18.033" LastActivityDate="2016-02-12T23:37:18.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20604" PostTypeId="1" AcceptedAnswerId="20628" CreationDate="2016-02-12T23:51:18.940" Score="2" ViewCount="582" Body="&lt;p&gt;I have a little clock with a button on it that i need to push four times every second hour. I am trying to get the arduino micro to do it for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to figure out how to connect the arduino to trigger it. The clock is operated by a CR2 (3.0V) cell battery. Is there a way to do this without a transistor? If not what do i need? How can i find out how much amp my circuit requires?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red arrow is pointing on the cable i think triggers the clock, and i think the black arrow is pointing on the cable that is the clock gnd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(edit: I have found similar questions explaining the process with transistor, but not without..)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ou1Rz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ou1Rz.jpg&quot; alt=&quot;Picture of the button that i need to push&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17306" LastEditorUserId="17306" LastEditDate="2016-02-13T08:40:58.490" LastActivityDate="2016-02-14T00:51:33.343" Title="Connecting arduino to an existing circuit" Tags="|arduino-micro|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20608" PostTypeId="1" AcceptedAnswerId="20609" CreationDate="2016-02-13T03:29:30.537" Score="1" ViewCount="2673" Body="&lt;p&gt;I am trying to write a library for encoders.&lt;/p&gt;&#xA;&lt;p&gt;main.ino:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;./Encoders.h&amp;gt;&#xA;&#xA;Encoders encoders();&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){               &#xA;    Serial.print(&amp;quot;&amp;quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Encoders.h:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef Encoders_h&#xA;#define Encoders_h&#xA;&#xA;#include &amp;quot;Arduino.h&amp;quot;&#xA;&#xA;class Encoders{&#xA;    public:&#xA;        Encoders();&#xA;        void EncodersSetup();&#xA;        long RightCount;&#xA;        long LeftCount;&#xA;        void R_A_RISE();&#xA;        void R_A_FALL();&#xA;        void R_B_RISE();&#xA;        void R_B_FALL();&#xA;        void L_A_RISE();&#xA;        void L_A_FALL();&#xA;        void L_B_RISE();&#xA;        void L_B_FALL();&#xA;    private:&#xA;        short R_A_SIG, R_B_SIG, L_A_SIG, L_B_SIG;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Encoders.cpp&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;Arduino.h&amp;quot;&#xA;#include &amp;quot;Encoders.h&amp;quot;&#xA;&#xA;long RightCount;&#xA;long LeftCount;&#xA;long R_A_SIG, R_B_SIG, L_A_SIG, L_B_SIG;&#xA;&#xA;Encoders::Encoders(){&#xA;    attachInterrupt(0, R_A_RISE, RISING);&#xA;    attachInterrupt(1, R_B_RISE, RISING);&#xA;    attachInterrupt(2, L_A_RISE, RISING);&#xA;    attachInterrupt(3, L_B_RISE, RISING);&#xA;    R_A_RISE();&#xA;}&#xA;&#xA;void Encoders::R_A_RISE(){&#xA;    detachInterrupt(0);&#xA;    R_A_SIG = 1;&#xA;    if(R_B_SIG == 0){&#xA;        RightCount++;&#xA;    }&#xA;    if(R_B_SIG == 1){&#xA;        RightCount--;&#xA;    }&#xA;    attachInterrupt(0, R_A_FALL, FALLING);&#xA;}&#xA;void Encoders::R_A_FALL(){&#xA;    detachInterrupt(0);&#xA;    R_A_SIG = 0;&#xA;    if(R_B_SIG == 1){&#xA;        RightCount++;&#xA;    } &#xA;    if(R_B_SIG == 0){&#xA;        RightCount--;&#xA;    }&#xA;    attachInterrupt(0, R_A_RISE, RISING);&#xA;}&#xA;void Encoders::R_B_RISE(){&#xA;    detachInterrupt(1);&#xA;    R_B_SIG = 1;&#xA;    if(R_A_SIG == 1){&#xA;        RightCount++;&#xA;    }&#xA;    if(R_A_SIG == 0){&#xA;        RightCount--;&#xA;    }&#xA;    attachInterrupt(1, R_B_FALL, FALLING);&#xA;}&#xA;void Encoders::R_B_FALL(){&#xA;    detachInterrupt(1);&#xA;    R_B_SIG = 0;&#xA;    if(R_A_SIG == 0){&#xA;        RightCount++;&#xA;    }&#xA;    if(R_A_SIG == 1){&#xA;        RightCount--;&#xA;    }   &#xA;    attachInterrupt(1, R_B_RISE, RISING);&#xA;}&#xA;void Encoders::L_A_RISE(){&#xA;    detachInterrupt(2);&#xA;    L_A_SIG = 1;&#xA;    if(L_B_SIG == 0){&#xA;        LeftCount++;&#xA;    }&#xA;    if(L_B_SIG == 1){&#xA;        LeftCount--;&#xA;    }&#xA;    attachInterrupt(2, L_A_FALL, FALLING);&#xA;}&#xA;void Encoders::L_A_FALL(){&#xA;    detachInterrupt(2);&#xA;    L_A_SIG = 0;&#xA;    if(L_B_SIG == 1){&#xA;        LeftCount++;&#xA;        } &#xA;    if(L_B_SIG == 0){&#xA;        LeftCount--;&#xA;        }&#xA;    attachInterrupt(2, L_A_RISE, RISING);   &#xA;}&#xA;void Encoders::L_B_RISE(){&#xA;    detachInterrupt(3);&#xA;    L_B_SIG = 1;&#xA;    if(L_A_SIG == 1){&#xA;        LeftCount++;&#xA;    }&#xA;    if(L_A_SIG == 0){&#xA;        LeftCount--;&#xA;    }&#xA;    attachInterrupt(3, L_B_FALL, FALLING);&#xA;}&#xA;void Encoders::L_B_FALL(){&#xA;    detachInterrupt(3);&#xA;    L_B_SIG = 0;&#xA;    if(L_A_SIG == 0){&#xA;        LeftCount++;&#xA;    }&#xA;    if(L_A_SIG == 1){&#xA;        LeftCount--;&#xA;    }   &#xA;    attachInterrupt(3, L_B_RISE, RISING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I try to compile this, I get errors like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C:/Users/marcel/Documents/dev/Arduino/encodeurs/Encoders.cpp:10:38: error: cannot convert 'Encoders::R_B_RISE' from type 'void (Encoders::)()' to type 'void (*)()'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried answers on other threads. Most said to make the functions passed to &lt;code&gt;attachInterrupt()&lt;/code&gt; &lt;code&gt;static&lt;/code&gt;. That threw different errors:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;C:/Users/marcel/Documents/dev/Arduino/encodeurs/Encoders.cpp:16:33: error: cannot declare member function 'void Encoders::R_A_RISE()' to have static linkage [-fpermissive]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, &amp;amp;Encoders::R_A_RISE, this, RISING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;with no success.&lt;/p&gt;&#xA;&lt;p&gt;The Arduino in question is a Mega but I doubt that matters.&lt;/p&gt;&#xA;&lt;h1&gt;Edit: Per Nick Gammon's answer, I now have this.&lt;/h1&gt;&#xA;&lt;p&gt;MotorEncoderMaster.ino&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;/home/marcel/dev/Arduino/encoders/MotorEncoderMaster/Encoders.h&amp;gt;&#xA;Encoders * Encoders::instances [2] = { NULL, NULL };&#xA;&#xA;&#xA;// instances of our class&#xA;Encoders right;&#xA;Encoders left;&#xA;&#xA;void setup (){&#xA;    right.begin (2);   // pin D2&#xA;    left.begin (3);   // pin D3&#xA;}  // end of setup&#xA;&#xA;void loop (){&#xA;    // whatever&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Encoders.h:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class Encoders{&#xA;    volatile bool switchChanged;&#xA;&#xA;    static Encoders * instances [2];&#xA;&#xA;    static void switchPressedExt0(){&#xA;        if(Encoders::instances [0] != NULL){&#xA;            Encoders::instances [0]-&amp;gt;switchPressed();&#xA;        }&#xA;    }&#xA;&#xA;    static void switchPressedExt1 (){&#xA;        if (Encoders::instances [1] != NULL){&#xA;            Encoders::instances [1]-&amp;gt;switchPressed();&#xA;        }&#xA;    }&#xA;&#xA;&#xA;    public:&#xA;        void begin (const int whichPin){&#xA;            pinMode (whichPin, INPUT_PULLUP);&#xA;            switch (whichPin){&#xA;                case 2:&#xA;                    attachInterrupt(0, switchPressedExt0, CHANGE);&#xA;                    instances [0] = this;&#xA;                    break;&#xA;&#xA;                case 3:&#xA;                    attachInterrupt(1, switchPressedExt1, CHANGE);&#xA;                    instances [1] = this;&#xA;                    break;&#xA;&#xA;            }&#xA;        }&#xA;&#xA;        void switchPressed(){&#xA;            switchChanged = true;&#xA;        }&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I try to compile this, I get :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;In file included from MotorEncoderMaster.ino:1:0:&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h: In static member function ‘static void Encoders::switchPressedExt0()’:&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:7:34: error: ‘NULL’ was not declared in this scope&#xA;    if(Encoders::instances [0] != NULL){&#xA;                                  ^&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h: In static member function ‘static void Encoders::switchPressedExt1()’:&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:13:35: error: ‘NULL’ was not declared in this scope&#xA;    if (Encoders::instances [1] != NULL){&#xA;                                   ^&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h: In member function ‘void Encoders::begin(int)’:&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:21:24: error: ‘INPUT_PULLUP’ was not declared in this scope&#xA;     pinMode (whichPin, INPUT_PULLUP);&#xA;                        ^&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:21:36: error: ‘pinMode’ was not declared in this scope&#xA;     pinMode (whichPin, INPUT_PULLUP);&#xA;                                    ^&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:24:45: error: ‘CHANGE’ was not declared in this scope&#xA;       attachInterrupt(0, switchPressedExt0, CHANGE);&#xA;                                             ^&#xA;/home/marcel/dev/Arduino/encoders/Encoders.h:24:51: error: ‘attachInterrupt’ was not declared in this scope&#xA;       attachInterrupt(0, switchPressedExt0, CHANGE);&#xA;                                                   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17310" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-18T20:01:20.083" Title="Pass class's public function as an argument to external command" Tags="|library|class|callbacks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20609" PostTypeId="2" ParentId="20608" CreationDate="2016-02-13T05:07:36.220" Score="5" Body="&#xA;&#xA;&lt;h1&gt;Interrupt Service Routine (ISR) outside a class&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Let's consider a simple use of interrupts:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile bool switchChanged;&#xA;&#xA;void switchPressed ()&#xA;  {&#xA;  switchChanged = true;&#xA;  }  // end of switchPressed&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (2, INPUT_PULLUP);&#xA;  attachInterrupt (0, switchPressed, CHANGE);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever    &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That compiles fine.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;ISR inside a class as a class function (method)&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Now let's imagine we want to put the interrupt handling into a class for our convenience.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class myClass&#xA;  {&#xA;  volatile bool switchChanged;&#xA;&#xA;  public:&#xA;&#xA;  void begin ()&#xA;    {&#xA;    pinMode (2, INPUT_PULLUP);&#xA;    attachInterrupt (0, switchPressed, CHANGE);   // &amp;lt;--- line 10&#xA;    }  // end of myClass::begin&#xA;&#xA;  void switchPressed ()&#xA;    {&#xA;    switchChanged = true;&#xA;    }  // end of myClass::switchPressed&#xA;&#xA;  };  // end of class myClass&#xA;&#xA;myClass foo;  // make an instance of myClass&#xA;&#xA;void setup ()&#xA;  {&#xA;  foo.begin ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever    &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does &lt;strong&gt;not&lt;/strong&gt; compile:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR_in_class_test.ino: In member function ‘void myClass::begin()’:&#xA;ISR_in_class_test:10: error: argument of type ‘void (myClass::)()’ does not match ‘void (*)()’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ISRs have to be static functions, taking no arguments. However (non-static) class functions have an implied &lt;code&gt;this-&amp;gt;&lt;/code&gt; pointer which points to the particular &lt;em&gt;instance&lt;/em&gt; of the class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if we have two instances:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;myClass foo;  &#xA;myClass bar; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we call foo.begin() then &lt;code&gt;this-&amp;gt;&lt;/code&gt; points to &quot;foo&quot;, and if we call bar.begin then &lt;code&gt;this-&amp;gt;&lt;/code&gt; points to &quot;bar&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However an ISR, when fired by the processor, cannot know whether &lt;code&gt;this-&amp;gt;&lt;/code&gt; is &quot;foo&quot; or &quot;bar&quot; or something else. Thus the compiler cannot compile that line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;ISR inside a class as a static class function&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;We can try to work around this by making the class function &lt;strong&gt;static&lt;/strong&gt;. Doing that means that the function is not tied to any particular instance, and thus the attachInterrupt line will compile.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class myClass&#xA;  {&#xA;  volatile bool switchChanged;   // &amp;lt;--- line 3&#xA;&#xA;  public:&#xA;&#xA;  void begin ()&#xA;    {&#xA;    pinMode (2, INPUT_PULLUP);&#xA;    attachInterrupt (0, switchPressed, CHANGE);&#xA;    }  // end of myClass::begin&#xA;&#xA;  static void switchPressed ()&#xA;    {&#xA;    switchChanged = true;   // &amp;lt;--- line 15&#xA;    }  // end of myClass::switchPressed&#xA;&#xA;  };  // end of class myClass&#xA;&#xA;myClass foo;  // make an instance of myClass&#xA;&#xA;void setup ()&#xA;  {&#xA;  foo.begin ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever    &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However now we have a different problem:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;ISR_in_class_test.ino: In static member function ‘static void myClass::switchPressed()’:&#xA;ISR_in_class_test:3: error: invalid use of member ‘myClass::switchChanged’ in static member function&#xA;ISR_in_class_test:15: error: from this location&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A non-static class variable cannot be called from a static class function. Why? Because the compiler doesn't know &lt;em&gt;which&lt;/em&gt; variable you want. Is it &lt;code&gt;foo.switchChanged&lt;/code&gt; or &lt;code&gt;bar.switchChanged&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;ISR inside a class as a static class function with static variables&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;To make the static function work, it can only access static variables. So we can make switchChanged static. Plus we need to define an instance of this static variable.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class myClass&#xA;  {&#xA;  static volatile bool switchChanged;  // declare&#xA;&#xA;  public:&#xA;&#xA;  void begin ()&#xA;    {&#xA;    pinMode (2, INPUT_PULLUP);&#xA;    attachInterrupt (0, switchPressed, CHANGE);&#xA;    }  // end of myClass::begin&#xA;&#xA;  static void switchPressed ()&#xA;    {&#xA;    switchChanged = true;&#xA;    }  // end of myClass::switchPressed&#xA;&#xA;  };  // end of class myClass&#xA;&#xA;volatile bool myClass::switchChanged;  // define&#xA;&#xA;myClass foo;  // make an instance of myClass&#xA;&#xA;void setup ()&#xA;  {&#xA;  foo.begin ();&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever    &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the class compiles. However we have thrown away most of the advantages of having a class in the first place, as we are forced to use a static function, and that static function can only access static variables.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Glue routines&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;To work around this problem we can write short &quot;glue&quot; routines. These are functions that interface between an ISR and an &lt;strong&gt;instance&lt;/strong&gt; of a class.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;class myClass&#xA;  {&#xA;  volatile bool switchChanged;&#xA;&#xA;  static myClass * instances [2];&#xA;&#xA;  static void switchPressedExt0 ()&#xA;    {&#xA;    if (myClass::instances [0] != NULL)&#xA;      myClass::instances [0]-&amp;gt;switchPressed ();&#xA;    }  // end of myClass::switchPressedExt0&#xA;&#xA;  static void switchPressedExt1 ()&#xA;    {&#xA;    if (myClass::instances [1] != NULL)&#xA;      myClass::instances [1]-&amp;gt;switchPressed ();&#xA;    }  // end of myClass::switchPressedExt1&#xA;&#xA;&#xA;  public:&#xA;&#xA;  void begin (const byte whichPin)&#xA;    {&#xA;    pinMode (whichPin, INPUT_PULLUP);&#xA;    switch (whichPin)&#xA;      {&#xA;      case 2: &#xA;        attachInterrupt (0, switchPressedExt0, CHANGE);&#xA;        instances [0] = this;&#xA;        break;&#xA;&#xA;      case 3: &#xA;        attachInterrupt (1, switchPressedExt1, CHANGE);&#xA;        instances [1] = this;&#xA;        break;&#xA;&#xA;      } // end of switch&#xA;    }  // end of myClass::begin&#xA;&#xA;  void switchPressed ()&#xA;    {&#xA;    switchChanged = true; &#xA;    }&#xA;&#xA;  };  // end of class myClass&#xA;&#xA;myClass * myClass::instances [2] = { NULL, NULL };&#xA;&#xA;// instances of our class  &#xA;myClass foo; &#xA;myClass bar;&#xA;&#xA;void setup ()&#xA;  {&#xA;  foo.begin (2);   // pin D2&#xA;  bar.begin (3);   // pin D3&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  // whatever    &#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a bit fiddly, however what it is doing is remembering in an array which instance of the class is associated with which interrupt. The &quot;glue&quot; routines switchPressedExt0 and switchPressedExt1 call the appropriate instance of the switchPressed function by using the remembered class pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the non-static function switchPressed can access non-static class variables.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Adapted from my web page &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12983&quot; rel=&quot;noreferrer&quot;&gt;Calling an ISR from a class&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-13T05:07:36.220" CommentCount="21" ContentLicense="CC BY-SA 3.0" />
  <row Id="20610" PostTypeId="2" ParentId="5388" CreationDate="2016-02-13T05:35:42.967" Score="0" Body="&lt;p&gt;The question is - are you &quot;listening&quot;  to the port? &#xA;Per doc SoftwareSerial will discard the data if not in&quot;listening state&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real question is - when not in listening state how does &quot;available&quot; becomes &gt; 0 (true) AKA there is data in SoftwareSerial &quot;buffer&quot;? &#xA;It really looks as if there is no real data in the buffer - character count 1 and up to 254 , the buffer content is 255 == -1 which &quot;available&quot; will evaluate as &quot;true&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can be verified using code to actually get the buffer character count returned from &quot;available&quot; and not just test for if () validity. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(int count = child1.available())&#xA;{&#xA;    than print count - how many characters in buffer for real &#xA;or&#xA;&#xA;if(child1.available() != -1) to test for real data in buffer. &#xA;&#xA;&#xA;if(child1.available() &amp;gt; 0){ // anything != 0 will ring true &#xA;    Serial.print(&quot;ParentReceived Something from child 1\n&quot;);&#xA;    while(child1.available()){// anything != 0 will ring true &#xA;      recvBuffer1[i] = child1.read();&#xA;      Serial.print(recvBuffer1[i], DEC); Serial.print(&quot; &quot;);&#xA;      Serial.print(i, DEC); Serial.print(&quot; &quot;);&#xA;      i++;&#xA;      if(i == FRAME_SIZE) break;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7201" LastEditorUserId="10794" LastEditDate="2016-02-13T06:17:21.990" LastActivityDate="2016-02-13T06:17:21.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20611" PostTypeId="2" ParentId="20602" CreationDate="2016-02-13T06:05:36.607" Score="1" Body="&lt;p&gt;What you can do is store the current time whenever a card is swiped, and then when another card is swiped check how long it's been since the last card was swiped&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first create a couple of variables&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long swipedTime;&#xA;int tag1 = 0;&#xA;int tag2 = 0;&#xA;int swipeTimeOut = 10000; // how much time in MS you have to swipe both cards&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next we'll jump down to where where you read the cards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      if (mfrc522.uid.uidByte[0] == 0xA4 &amp;amp;&amp;amp; &#xA;           mfrc522.uid.uidByte[1] == 0xB8 &amp;amp;&amp;amp;&#xA;           mfrc522.uid.uidByte[2] == 0xB8 &amp;amp;&amp;amp;&#xA;           mfrc522.uid.uidByte[3] == 0x96) {&#xA;&#xA;               ........&#xA;&#xA;               if (tag2 == 1 &amp;amp;&amp;amp; millis() - swipedTime &amp;lt; swipeTimeOut ){&#xA;                   // both tags have been swiped, print serial message here&#xA;                }&#xA;&#xA;                tag1 = 1;&#xA;                swipedTime = millis();     &#xA;        }&#xA;&#xA;        if (mfrc522.uid.uidByte[0] == 0x03 &amp;amp;&amp;amp; &#xA;           mfrc522.uid.uidByte[1] == 0xFD &amp;amp;&amp;amp;&#xA;           mfrc522.uid.uidByte[2] == 0xBC &amp;amp;&amp;amp;&#xA;           mfrc522.uid.uidByte[3] == 0x02) {&#xA;&#xA;               ........&#xA;&#xA;&#xA;               if (tag1 == 1 &amp;amp;&amp;amp; millis() - swipedTime &amp;lt; swipeTimeOut ){&#xA;                   // both tags have been swiped, print serial message here&#xA;                }&#xA;                tag2 = 1;&#xA;                swipedTime = millis();     &#xA;&#xA;&#xA;         }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You'll also want to come up with a system for resetting &lt;code&gt;tag1&lt;/code&gt; and &lt;code&gt;tag2&lt;/code&gt; to 0 or &quot;checking them out&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4172" LastActivityDate="2016-02-13T06:05:36.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20614" PostTypeId="2" ParentId="20604" CreationDate="2016-02-13T09:54:54.943" Score="0" Body="&lt;p&gt;Yes, This can be achieved without a transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the circuits would be on isolated power supplies: Arduino circuit on one and the clock on another, you can use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Solid-state_relay&quot; rel=&quot;nofollow noreferrer&quot;&gt;Solid State Relay&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P2xyt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P2xyt.jpg&quot; alt=&quot;SSR&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the relay with your Arduino (5v or 3.3v) and wire the relay contacts parallel to the clock switch. This will isolate any power issues as clock will be powered with its own power and Arduino will be powered with its own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can program Arduino with proper delays to actuate the relay accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastEditorUserId="9962" LastEditDate="2016-02-13T23:09:38.950" LastActivityDate="2016-02-13T23:09:38.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20615" PostTypeId="1" AcceptedAnswerId="20620" CreationDate="2016-02-13T11:15:56.160" Score="1" ViewCount="106" Body="&lt;p&gt;I am tring to use ShorTie8's new arduino ARM installer on my RPI B+ by copying this into my terminal:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;cd&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;sudo apt-get update -y &amp;amp;&amp;amp; sudo apt-get dist-upgrade -y&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;wget &lt;a href=&quot;https://raw.githubusercontent.com/ShorTie8/Arduino_IDE/master/Arduino_IDE_builder.bash&quot; rel=&quot;nofollow&quot;&gt;https://raw.githubusercontent.com/ShorTie8/Arduino_IDE/master/Arduino_IDE_builder.bash&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;chmod +x Arduino_IDE_builder.bash&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;sudo ./Arduino_IDE_builder.bash&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;sudo Arduino/build/linux/work/./arduino&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;sudo Arduino/build/linux/work/./install.sh&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;sudo apt-get install -y mercurial subversion build-essential gperf bison ant texinfo zip automake flex libusb-dev libusb-1.0-0-dev libtinfo-dev pkg-config libwxbase3.0-dev libtools&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But Getting The following Error at sudo ./Arduino_IDE_builder.bash&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;echo -e '\n\nConfiguration values\n\n'&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;Configuration values&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Stable=1.6.7&lt;/li&gt;&#xA;  &lt;li&gt;Update_me=yes&lt;/li&gt;&#xA;  &lt;li&gt;Silence_is_Golden=yes&lt;/li&gt;&#xA;  &lt;li&gt;echo -e '\n\nSystem check\n\n'&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &#xA;  &lt;p&gt;System check&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;++ date&#xA;  + start_time='Sat 13 Feb 11:12:37 GMT 2016'&#xA;  ++ pwd&#xA;  + Start_Directory=/home/pi&#xA;  ++ pwd&#xA;  + Working_Directory=/home/pi/Arduino/build&#xA;  + echo -e '\n\nChecking for root .. \n'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Checking for root .. &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;++ id -u&#xA;  + '[' 0 '!=' 0 ']'&#xA;  + echo 'Yuppers .. :)~'&#xA;  Yuppers .. :)~&#xA;  + [[ yes == \y\e\s ]]&#xA;  + echo -e '\n\nChecking to see if I'\''m update\n'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Checking to see if I'm update&lt;/p&gt;&#xA;  &#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;git remote update&#xA;  fatal: Not a git repository (or any of the parent directories): .git&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16147" LastEditorUserId="16147" LastEditDate="2016-02-13T14:17:18.910" LastActivityDate="2016-02-13T14:17:18.910" Title="Raspberry Pi Arduino Installer broken" Tags="|arduino-ide|raspberrypi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20616" PostTypeId="1" AcceptedAnswerId="20617" CreationDate="2016-02-13T11:17:18.627" Score="0" ViewCount="2299" Body="&lt;p&gt;So in a laptop you have a CPU and a hard drive. The hard drive feeds data to the CPU and the CPU executes it. In Arduino you flash the CPU and the &quot;hard drive&quot; is built into it. Is it possible to have a hard drive or SD card feed data into the Arduino to be executed and then feed more data in and so on? If it is possible how is it done?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="4628" LastEditDate="2016-02-13T14:51:15.400" LastActivityDate="2016-02-13T14:51:15.400" Title="Arduino and hard drive" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20617" PostTypeId="2" ParentId="20616" CreationDate="2016-02-13T11:38:26.193" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to have a harddrive or sd card feed data into the Arduino to be executed and then feed more data in and so on. If it is possible how is it done?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A harddrive would be difficult to connect, but an SD card will work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can write a sketch that reads data from an SD card. There is library support for both SD and FAT16/32 file systems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another interpretation of your question is; is it possible to load a sketch from an SD card. The answer is yes; there are a number of projects that have done that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="2881" LastEditDate="2016-02-13T13:20:48.373" LastActivityDate="2016-02-13T13:20:48.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20618" PostTypeId="2" ParentId="20596" CreationDate="2016-02-13T11:46:19.757" Score="0" Body="&lt;p&gt;This code is over complicated and has a lot of errors. Let us start with the obvious. Look closely at this section. Do you see the error(s)?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SK 13 &#xA;#define DO 12 &#xA;#define DI 11 &#xA;#define CS 10 &#xA;&#xA;#define READ 0x02 &#xA;&#xA;#define SET_CS PORT93LC46B |= (1 &amp;lt;&amp;lt; CS)&#xA;#define CLR_CS PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; CS)&#xA;&#xA;#define SET_SK {PORT93LC46B |= (1 &amp;lt;&amp;lt; SK); _delay_us(0.01);}&#xA;#define CLR_SK PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; SK)&#xA;&#xA;#define SET_DI PORT93LC46B |= (1 &amp;lt;&amp;lt; DI)&#xA;#define CLR_DI PORT93LC46B &amp;amp;= ~(1 &amp;lt;&amp;lt; DI)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The symbols SK, D0, DI, CS seem to be pin numbers but look how they are used in the SET_XX and CLR_XX macros. That is very wrong. They should be the bit numbers in the PORT register instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is more. How about this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_delay_us(0.01);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the intention? _delay_ns(10)??? In any case yet another error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-13T11:46:19.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20620" PostTypeId="2" ParentId="20615" CreationDate="2016-02-13T14:06:36.877" Score="1" Body="&lt;p&gt;Instead of manually downloading a file from the github repository, check out the repository properly with &lt;code&gt;git clone 《repository》&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-13T14:06:36.877" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20621" PostTypeId="1" AcceptedAnswerId="20890" CreationDate="2016-02-13T14:39:12.917" Score="0" ViewCount="1205" Body="&lt;p&gt;I'm trying to make dimmer for heater using Arduino Due. I'm using a variant of this very common scheme: &lt;a href=&quot;https://i.stack.imgur.com/pOmnJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pOmnJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My scheme has MOC3043 with zero-crossing detection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use two pins to control the dimmer: &lt;strong&gt;detectorPin&lt;/strong&gt; to analyse input voltage wave and &lt;strong&gt;controlPin&lt;/strong&gt; to drive optocoupler. The program is very simple thanks to zero-crossing MOC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I attached an &lt;code&gt;interrupt&lt;/code&gt; to the input &lt;strong&gt;detectorPin&lt;/strong&gt; on &lt;code&gt;CHANGE&lt;/code&gt; event. And &lt;strong&gt;controlPin&lt;/strong&gt; is used as digital output. When I test detection with &lt;strong&gt;controlPin&lt;/strong&gt; unplugged everything works fine. But when &lt;strong&gt;controlPin&lt;/strong&gt; is connected, value which is read inside the interrupt becomes wrong! So my dimmer cannot detect any half-wave and reports errors. This happens at the moment when &lt;strong&gt;controlPin&lt;/strong&gt; value is set to &lt;code&gt;HIGH&lt;/code&gt; with help of &lt;code&gt;digitalWrite()&lt;/code&gt; func. After nearly 40-50 milliseconds detected values go back to normal, so most of time my dimmer work as expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I measured current on the &lt;strong&gt;controlPin&lt;/strong&gt;, it's only 3.2mA, which is lower than maximum possible current for Arduino Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this with &lt;strong&gt;detectorPin&lt;/strong&gt; = 51, and different &lt;strong&gt;controlPins&lt;/strong&gt;: 52, 36, 31.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do you think, what is the problem? Is my Arduino broken?&lt;/p&gt;&#xA;" OwnerUserId="16074" LastActivityDate="2016-02-19T21:08:52.813" Title="Dimmer on Due: digitalWrite on one pin affects digital value of another" Tags="|arduino-due|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20622" PostTypeId="2" ParentId="20621" CreationDate="2016-02-13T14:57:54.837" Score="1" Body="&lt;p&gt;There are a few issues with your circuit.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;First, you need to add a diode to your 4N25 circuit.&lt;/s&gt;  &lt;em&gt;See EDIT below&lt;/em&gt;.     You should still put a diode across your 4N25 LED.  &lt;s&gt;Right now, your 4N25 diode (LED) gets a high voltage across it 1/2 of the time.&lt;/s&gt;  Because you have 60K (30K+30K) in the circuit, the LED is likely not damaged, however the LED isn't really designed to handle reverse voltage more than 6 volts. Depending upon the reverse characteristics of the Bridge diodes (leakage current), your 4N25 LED could be experiencing greater than 6 volts.  Using devices beyond their &quot;maximum specification&quot; can produce unusual side effects. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Place the new diode (1N4007 is good, almost any diode will work) across the LED on your 4N25. Wire the new diode with new diode anode to the LEd cathode. Now, the LED will turn on during 1/2 cycle of the AC,  and be protected against overvoltage during the other half of the cycle.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second,  rearrange your circuit for the Triac.  The data sheet for your &lt;a href=&quot;http://www.mouser.com/ds/2/149/MOC3043M-195994.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOC3043 triac driver&lt;/a&gt; shows a typical schematic.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FyKG4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FyKG4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the 39 ohm resistor and the 0.01 uf capacitor in the circuit.  This is called a snubber and will reduce interference and voltage spikes. This type of interference is famous for disrupting low voltage circuits such as micro-controllers.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without seeing your code, I can't say much on that.  However, I presume that you are trying to detect the zero cross, and then waiting a certain amount of time AFTER the zero cross to turn on the Triac.   &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I measured current on the controlPin, it's only 3.2mA   &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your 3.2mA may not be enough to drive the LED in your dimmer circuit. You will likely need 10mA to assure proper operation.  You can reduce the resistor to achieve higher current to the MOC3043.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT  :  I just realized that your bridge rectifier protects the LED (4N25) from reverse voltage. &lt;/p&gt;&#xA;" OwnerUserId="6945" LastEditorUserId="6945" LastEditDate="2016-02-13T17:26:19.823" LastActivityDate="2016-02-13T17:26:19.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20625" PostTypeId="2" ParentId="20604" CreationDate="2016-02-13T17:05:16.310" Score="0" Body="&lt;p&gt;Connect the Arduino and your clock grounds together.&#xA;Get a small resistor - no less than 1 kOhm - and connect your VOM (in current mode) in series with the resistor and your Arduino output pin. &#xA;Set the output pin to LOW and observe &#xA;Did the clock reset? &#xA;What was the current on your VOM? &#xA;If the clock reset and the current was more than 20 mA get a bigger ( 10 kOhms )  resistor and try it again. &#xA;If the clock reset and your current was less than 20 mA you are done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you really want to isolate the clock from Arduino use low current LED and connect the cathode to the output pin and anode to the clock.&#xA;Keep the resistor in the circuit.&lt;br&gt;&#xA;Than you will also have an indicator of &quot;circuit is active&quot;. &lt;/p&gt;&#xA;" OwnerUserId="7201" LastEditorUserId="7201" LastEditDate="2016-02-14T00:51:33.343" LastActivityDate="2016-02-14T00:51:33.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20626" PostTypeId="1" CreationDate="2016-02-13T17:09:39.720" Score="0" ViewCount="755" Body="&lt;p&gt;I'm trying to blink an LED on an ATMega328P (same MCU as Arduino I think..) using the internal timer but I'm stuck since it doesn't seem to light the LED at all....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;//#include &amp;lt;avr/delay.h&amp;gt;&#xA;&#xA;void delay(void);&#xA;&#xA;void delay_long(void);&#xA;&#xA;int main(void) {&#xA;&#xA;  DDRB = 0xFF;                   // port B is configured as output   DDRB : 0b11111111&#xA;  DDRB &amp;amp;= ~(1&amp;lt;&amp;lt;PB1);             // pin 1 of port B is configured as input  DDRB : 0b11111101&#xA;  PORTB = 0x00;                  // pins of port B are low (output) and with no pull-up resistor (input)&#xA;  PORTB |= (1&amp;lt;&amp;lt;PB0)|(1&amp;lt;&amp;lt;PB1);    // pin 0 is high (output) and pin 1 is pulled high (input)    PORTB : 0b00000011&#xA;&#xA;  while(1) {&#xA;    PORTB &amp;amp;= ~(1&amp;lt;&amp;lt;PB0);&#xA;    delay();&#xA;    PORTB |= 1&amp;lt;&amp;lt;PB0;&#xA;    delay();&#xA;    PORTB = ~(1&amp;lt;&amp;lt;PB0);&#xA;    delay_long();&#xA;    PORTB = 1&amp;lt;&amp;lt;PB0;&#xA;    delay_long();      &#xA;  }&#xA;&#xA;  return 1;&#xA;&#xA;}&#xA;&#xA;void delay(void) {&#xA;  TCNT0 = 0x00;&#xA;  TCCR0B = 0x05;&#xA;  while ( (TIFR0 &amp;amp; TOV0) == 0 ) &#xA;    ;&#xA;  TCCR0B = 0x00;&#xA;  TIFR0 |= 1&amp;lt;&amp;lt;TOV0;&#xA;}&#xA;&#xA;void delay_long(void) {&#xA;  TCNT0 = 0x00;&#xA;  TCCR0B = 0x05;&#xA;  while ( (TIFR0 &amp;amp; TOV0) == 0 ) &#xA;    ;&#xA;  TCCR0B = 0x00;&#xA;  TIFR0 |= 1&amp;lt;&amp;lt;TOV0;&#xA;  TCCR0B = 0x05;&#xA;  while ( (TIFR0 &amp;amp; TOV0) == 0 ) &#xA;    ;&#xA;  TCCR0B = 0x00;&#xA;  TIFR0 |= 1&amp;lt;&amp;lt;TOV0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I remove the body of the event loop it lights up... so I think I must be missing something in the delay functions...&lt;/p&gt;&#xA;" OwnerUserId="17326" LastEditorUserId="6936" LastEditDate="2016-02-14T11:59:35.187" LastActivityDate="2016-02-14T11:59:35.187" Title="Timer/Counter programming Arduino" Tags="|c|atmega328|timers|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20627" PostTypeId="2" ParentId="20597" CreationDate="2016-02-13T17:18:14.927" Score="1" Body="&lt;p&gt;No, the LED doesn't need a resistor ...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is correct, but the processor I/O - output pin - does. &#xA;Check the schematic to see how RX /TX LEDs are connected. &lt;/p&gt;&#xA;" OwnerUserId="7201" LastActivityDate="2016-02-13T17:18:14.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20628" PostTypeId="2" ParentId="20604" CreationDate="2016-02-13T17:29:42.480" Score="0" Body="&lt;p&gt;You might try attaching an Arduino IO through a resistor to pin 4 (where your red arrow points), and Arduino ground to pin 1 (where your black arrow points).  Because the clock is battery-operated, you can connect its ground to the Arduino's ground without problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before attaching the Arduino, use your DVM to measure the voltage between pins 4 and 1, with the switch open and with the switch closed.  In following, I'll suppose you have measured 3V when the switch is open and 0V when it's closed.  This would indicate that the clock's circuit pulls or drives pin 4 high when the switch is open.  In initial experiments, I'd start with a 1KΩ or so resistor (eg, any resistor between 500Ω and 2000Ω) in series with an ammeter and the Arduino IO.  If you measure at most a few microamps of current in both the “switch open” and “switch closed” cases (see below) then the circuit should function ok with the resistor in place (since there will be only a tiny voltage drop across it).  [If, on the other hand, you measure several milliamps of current in either case, then my ideas about the clock circuit might not apply; in which case you might need an optoisolator or relay.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To represent switch operation, put the Arduino IO into INPUT mode to represent an open switch, and into OUTPUT LOW to represent a closed switch.  For example, in &lt;code&gt;setup()&lt;/code&gt; say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(ClockPin, INPUT);  // Also does digitalWrite(ClockPin, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in your &lt;code&gt;loop()&lt;/code&gt; say stuff like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (TheTimeHasCome) {&#xA;   for (int k=0; k&amp;lt;4; ++k) {&#xA;      pinMode(ClockPin, OUTPUT);  // Presses the button&#xA;      delay(50);                  // Holds the button&#xA;      pinMode(ClockPin, INPUT);   // Releases the button&#xA;      delay(50);                  // Wait between buttons&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comment &lt;code&gt;// Also does digitalWrite(ClockPin, LOW);&lt;/code&gt; is a reminder that &lt;code&gt;pinMode(ClockPin, INPUT);&lt;/code&gt; has two actions: it sets ClockPin to be an input instead of an output, and takes the corresponding PORTx bit low (ie, resets a bit in PORTB, PORTC, PORTD, or whatever).  If we had said &lt;code&gt;pinMode(ClockPin, INPUT_PULLUP);&lt;/code&gt;, then the corresponding PORTx bit would have been set high, and the pin would be weakly pulled to Vcc, eg +5V.  It would be a mistake to send 5V to the clock, as it's likely that would exceed its voltage tolerance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since &lt;code&gt;pinMode(ClockPin, INPUT);&lt;/code&gt; leaves the appropriate PORTx bit low, there is no need to use &lt;a href=&quot;https://www.arduino.cc/en/Reference/DigitalWrite&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;digitalWrite()&lt;/code&gt;&lt;/a&gt; separately in the sketch.  When ClockPin is an input, its high impedance allows the clock to pull pin 4 high; when ClockPin is an output, its 0 level connects pin 4 to pin 1.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-13T18:03:49.027" LastActivityDate="2016-02-13T18:03:49.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20630" PostTypeId="1" AcceptedAnswerId="20632" CreationDate="2016-02-13T18:52:23.323" Score="1" ViewCount="2391" Body="&lt;p&gt;I guess it's all in the title. When using Vin as input, does it go through voltage regulator, or must I feed it precisely 5V?&lt;/p&gt;&#xA;" OwnerUserId="15273" LastActivityDate="2016-02-14T13:37:13.467" Title="Is the Uno Vin pin protected by the voltage regulator?" Tags="|arduino-uno|power|voltage-protection|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20632" PostTypeId="2" ParentId="20630" CreationDate="2016-02-13T19:21:41.160" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YRA3i.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YRA3i.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;noreferrer&quot;&gt;schematic&lt;/a&gt; you'll see Vin is connected to the input of the voltage regulator. Just like the barrel-jack (except for the diode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the same input-voltage of    7-12V applies to Vin.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-02-13T19:21:41.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20634" PostTypeId="1" CreationDate="2016-02-13T20:40:34.280" Score="0" ViewCount="1630" Body="&lt;p&gt;I followed Great Scott's video on YouTube for uploading to an ATtiny85. When I tried I got the following error messages:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Arduino: 1.6.7 (Windows Vista), Board: &amp;quot;ATtiny85 (internal 8 MHz clock)&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;Board attiny-master:attiny:attiny85-20 doesn't define a 'build.board' &amp;gt;preference. Auto-set to: ATTINY_ATTINY85-20&lt;/p&gt;&#xA;&lt;p&gt;Board attiny-master:attiny:attiny45-8 doesn't define a 'build.board' &amp;gt;preference. Auto-set to: ATTINY_ATTINY45-8&lt;/p&gt;&#xA;&lt;p&gt;Board attiny-master:attiny:attiny85-8 doesn't define a 'build.board' &amp;gt;preference. Auto-set to: ATTINY_ATTINY85-8&lt;/p&gt;&#xA;&lt;p&gt;Board attiny-master:attiny:attiny44 doesn't define a 'build.board' &amp;gt;preference. Auto-set to: ATTINY_ATTINY44&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;etc. etc. ...&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;exec: &amp;quot;-w&amp;quot;: executable file not found in %PATH%&#xA;Error compiling.`&lt;/p&gt;&#xA;&lt;p&gt;This report would have more information with&#xA;&amp;quot;Show verbose output during compilation&amp;quot;&#xA;enabled in File &amp;gt; Preferences.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;When I unplug  my ATtiny85 and restart Arduino, I have no problems uploading, though I get about 8 error messages saying something like:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Board attiny-master:attiny:attiny84 doesn't define a 'build.board' preference. Auto-set to: ATTINY_ATTINY84&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17202" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2021-02-28T21:02:45.230" Title="Error uploading to ATtiny" Tags="|avr|avrdude|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20635" PostTypeId="1" AcceptedAnswerId="30492" CreationDate="2016-02-13T22:05:38.447" Score="1" ViewCount="1382" Body="&lt;p&gt;Has anyone connected BLE devices with Python + GUI on OSX? I've looked into a few libraries (most are old), but one that has the most success if Adafruit's BlueFruit library. However, this library works poorly with GUI's since it requires use of the main event loop (which GUI's usually use). After doing a bunch of Google searches, I couldn't find any good examples of using a GUI with Python + BLE. There seems to be no good BLE libraries for Python either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically looking for help integrating BLE with Kivy, but other GUI toolkit examples should be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also trying to gauge interest in this to see if I can do development to solve this (if it really is a problem).&lt;/p&gt;&#xA;" OwnerUserId="15236" LastEditorUserId="15236" LastEditDate="2016-02-14T13:14:44.153" LastActivityDate="2016-10-24T12:22:49.523" Title="BLE Python with GUI on OSX" Tags="|serial|bluetooth|python|wireless|" AnswerCount="1" CommentCount="1" ClosedDate="2016-10-26T08:29:45.873" ContentLicense="CC BY-SA 3.0" />
  <row Id="20636" PostTypeId="2" ParentId="20634" CreationDate="2016-02-13T23:00:04.870" Score="1" Body="&lt;p&gt;It's likely that a compiler's file name is missing from a command line the IDE is trying to execute.  To find out more about what the command looks like (which will let you figure out what name is missing), turn on verbose output during compilation.  That is, click File, Preferences in the IDE, then click the box in front of “compilation”.  After you find out what's missing, you can then turn off verbose output and fix &lt;code&gt;platform.txt&lt;/code&gt;, which is the file the IDE looks at to find out what commands to execute when compiling sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get rid of the warnings about undefined &lt;code&gt;build.board&lt;/code&gt; values, add lines like the following to the &lt;code&gt;boards.txt&lt;/code&gt; file in the &lt;code&gt;tiny/avr/&lt;/code&gt; directory (or whereever you installed it).  (Your 1.6 IDE wants &lt;code&gt;build.board&lt;/code&gt; definitions, which IIRC weren't needed by 1.5 and earlier IDEs.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attiny85-20.build.board=ATTINY_ATTINY85-20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each of the lines you add will contain the Auto-set value, prefaced by a string made up of a board-type and &lt;code&gt;.build.board=&lt;/code&gt; concatenated together.  Add each line just before or after other &lt;code&gt;.build.&lt;/code&gt;-containing lines.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-02-13T23:00:04.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20637" PostTypeId="1" CreationDate="2016-02-13T23:23:19.120" Score="1" ViewCount="8096" Body="&lt;p&gt;I have an UNIX Timestamp in my Arduino Sketch and would like to get the day of the week of this timestamp (1-7). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I convert the timestamp to get the day of the week?&lt;/p&gt;&#xA;" OwnerUserId="17335" LastEditorUserId="9962" LastEditDate="2016-02-14T15:39:16.160" LastActivityDate="2016-02-14T15:39:16.160" Title="Convert UNIX Timestamp" Tags="|time|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20638" PostTypeId="2" ParentId="20637" CreationDate="2016-02-13T23:52:44.003" Score="2" Body="&lt;p&gt;The simplest solution to that problem is to download the &lt;a href=&quot;https://github.com/PaulStoffregen/Time&quot; rel=&quot;nofollow&quot;&gt;Time&lt;/a&gt; library and use the &lt;a href=&quot;https://github.com/PaulStoffregen/Time/blob/master/TimeLib.h#L114&quot; rel=&quot;nofollow&quot;&gt;weekday()&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int weekday(time_t t); // the weekday for the given time &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-13T23:52:44.003" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20639" PostTypeId="2" ParentId="20626" CreationDate="2016-02-13T23:53:52.803" Score="1" Body="&lt;p&gt;It seems that the offending line is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while ( (TIFR0 &amp;amp; TOV0) == 0 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;TOV0&lt;/code&gt; by itself equals 0, so the above loop will never end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; while ( (TIFR0 &amp;amp; (1&amp;lt;&amp;lt;TOV0)) == 0 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead.&lt;/p&gt;&#xA;" OwnerUserId="13725" LastActivityDate="2016-02-13T23:53:52.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20640" PostTypeId="2" ParentId="20602" CreationDate="2016-02-14T00:41:32.040" Score="0" Body="&lt;p&gt;You could try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte tag1[] = {0xA4, 0xB8, 0xB8, 0x96}; &#xA;byte tag1_read = 0;    // flag is set when tag 1 is read&#xA;byte tag2[] = {0x3, 0xFD, 0xBC, 0x02}; &#xA;byte tag2_read = 0;    // flag is set when tag 2 is read&#xA;&#xA;int BUTTON = 3;&#xA;&#xA;void setup(){&#xA;    pinMode(BUTTON, INPUT_PULLUP);  //set button as input pulled high&#xA;    .... // the rest of your setup()&#xA;} &#xA;&#xA;void loop() {&#xA;&#xA;  // Look for new cards&#xA;    if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;        return;&#xA;    }&#xA;&#xA;    // Select one of the cards&#xA;    if ( ! mfrc522.PICC_ReadCardSerial()) {&#xA;        return;&#xA;    }&#xA;&#xA;    if (tag1_read == 0 &amp;amp;&amp;amp; memcmp(mfrc522.uid.uidByte, tag1, 4) == 0){&#xA;          Serial.println(&quot;Tag 1 has been read.&quot;);&#xA;          tag1_read = 1;   //tag 1 has been read&#xA;          //delay(2000);   //not sure why u need the delay&#xA;    }&#xA;&#xA;    if (tag1_read &amp;amp;&amp;amp; tag2_read == 0 &amp;amp;&amp;amp; memcmp(mfrc522.uid.uidByte, tag2, 4) == 0) {&#xA;          Serial.println(&quot;Tag 2 has been read.&quot;);&#xA;          tag2_read = 1;    // tag 2 has been read&#xA;          Serial.println(&quot;Both tags have been read.&quot;);&#xA;    }&#xA;&#xA;    if (digitalRead(BUTTON) == LOW &amp;amp;&amp;amp; tag1_read &amp;amp;&amp;amp; tag2_read){&#xA;        Serial.println(&quot;Both tags are finished.&quot;);&#xA;        tag1_read = 0; tag2_read = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code assumes the cards must be presented and read in order.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-14T00:41:32.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20642" PostTypeId="2" ParentId="20396" CreationDate="2016-02-14T01:13:56.047" Score="0" Body="&lt;p&gt;The easiest and most overlooked way to read ANY hardware serial ( Serialx) is to utilize Arduino IDE main() function layout and let the serialEventx do the work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is much simplified layout of IDE main () function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;main()&#xA;{&#xA;Setup()&#xA;for(;;)&#xA;{&#xA;loop()&#xA;serialEventx()&#xA;}&#xA;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However using serialEvent requires much different approach to your program flow - the loop() cannot have any logic which would introduce a delay.&#xA;Your program must process the serialEvent FIRST, loop() processing is secondary.&lt;/p&gt;&#xA;" OwnerUserId="7201" LastActivityDate="2016-02-14T01:13:56.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20643" PostTypeId="1" CreationDate="2016-02-14T04:13:20.677" Score="0" ViewCount="982" Body="&lt;p&gt;I am adding a distance sensor to existing project that uses Arduino due, do I connect the trigger pin and the echo pin of the HC-SR04 ultrasonic sensor directly to  Arduino due which uses 3.3V   while HC-SR04 ultrasonic sensor uses 5V or do I need to use a voltage divider?&lt;/p&gt;&#xA;" OwnerUserId="17339" LastEditorUserId="11529" LastEditDate="2016-02-14T15:53:20.573" LastActivityDate="2016-02-14T15:53:20.573" Title="Distance sensor" Tags="|arduino-due|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20644" PostTypeId="2" ParentId="20643" CreationDate="2016-02-14T08:08:52.073" Score="0" Body="&lt;p&gt;Well, it depends on the sensor itself. Some sensors run on both 5V and 3.3V. There's a similar question here on StackExchange: &lt;a href=&quot;https://arduino.stackexchange.com/questions/795/how-to-connect-5v-sensors-to-3-3v-digital-input-due&quot;&gt;How to connect 5V sensors to 3.3V digital input (Due)?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in short, if the sensor can't operate in 3.3V, you'll need a level converter /shifter. &lt;/p&gt;&#xA;" OwnerUserId="11982" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-02-14T11:31:14.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20645" PostTypeId="2" ParentId="20396" CreationDate="2016-02-14T10:54:02.620" Score="1" Body="&lt;p&gt;I had my arduino mega receiving the data from Serial2 and Serial3, by adopting a sketch that was developed by @Majenko in answer to the post &lt;a href=&quot;https://arduino.stackexchange.com/questions/19818/processing-serial-data&quot;&gt;Processing Serial data&lt;/a&gt;. The sketch below outputs data to the serial monitor. The NEW problem I have now is trying to develop a python sketch that would seperate the data from the buffers into two different csv files, with each csv files representing the data from each of the two sensors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    static char buffer[20];&#xA;    int count =0;&#xA;&#xA;    void setup() &#xA;   {&#xA;    Serial.begin(115200);&#xA;    Serial2.begin(115200);&#xA;    Serial3.begin(115200);&#xA;    delay(50);&#xA;&#xA;    }&#xA;&#xA;    void loop(){&#xA;&#xA;if (Serial.available()){  //Slide the window&#xA;   for(count=0; count&amp;lt;10; count++){&#xA;      buffer[count] = Serial.read();&#xA;      //Add the new character&#xA;      buffer[9] = Serial.read();&#xA;&#xA;      //Check the framing window&#xA;   if((buffer[0] == '$') &amp;amp;&amp;amp; (buffer[9] == 0xAC)){&#xA;     //Calculate the checksum&#xA;      uint16_t cs = 0;&#xA;   for (uint16_t i = 2; i &amp;lt; 8; i++){&#xA;    cs += buffer[i];&#xA;    }&#xA;    //if the checksum matches....&#xA;    if(cs == buffer[8]){&#xA;      //Send the byte to serial port three&#xA;      Serial2.write(buffer, count); &#xA;  }&#xA;  }&#xA;&#xA; }&#xA;}&#xA;&#xA; if (Serial2.available()){&#xA;    for(count=0; count&amp;lt;10; count++){&#xA;      buffer[count] = Serial2.read();&#xA;      //Send the byte to serial port three&#xA;      Serial.write(buffer, count); &#xA;     }&#xA; }&#xA;&#xA; if (Serial.available()){  //Slide the window&#xA;   for(count=11; count&amp;lt;20; count++){&#xA;      buffer[count] = Serial.read();&#xA;      //Add the new character&#xA;      buffer[19] = Serial.read();&#xA;&#xA;      //Check the framing window&#xA;   if((buffer[11] == '+') &amp;amp;&amp;amp; (buffer[19] == 0xAE)){&#xA;     //Calculate the checksum&#xA;      uint16_t cs2 = 0;&#xA;   for (uint16_t i = 6; i &amp;lt; 18; i++){&#xA;    cs2 += buffer[i];&#xA;    }&#xA;    //if the checksum matches....&#xA;    if(cs2 == buffer[18]){&#xA;      //Send the byte to serial port three&#xA;      Serial3.write(buffer, count); &#xA;  }&#xA;  }&#xA;&#xA; }&#xA;}&#xA;&#xA; if (Serial3.available()){&#xA;    for(count=11; count&amp;lt;20; count++){&#xA;      buffer[count] = Serial3.read();&#xA;      //Send the byte to serial port three&#xA;      Serial.write(buffer, count); &#xA;     }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-14T10:59:38.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20646" PostTypeId="2" ParentId="8204" CreationDate="2016-02-14T11:18:57.643" Score="2" Body="&lt;p&gt;I had the same problem (random, milliseconds), and in my case what I needed to make was a toy, able to Blink its eye (LED) in a more human way, with variable intervals, so I used the basic &quot;blink without delay&quot; and tweaked until I got a result I wanted. &#xA;This is my first post here so I hope I'm doing it correctly. Here is the code that worked for me: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin =  13;      // the number of the LED pin&#xA;unsigned long previousMillis = 0;        // will store last time LED was     updated&#xA;&#xA; long interval = 4000;           // starting interval at which to blink   (milliseconds)&#xA;&#xA;void setup() {&#xA;Serial.begin(9600); &#xA;// set the digital pin as output:&#xA;pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;digitalWrite(ledPin, HIGH);   &#xA;&#xA;unsigned long currentMillis = millis();&#xA;&#xA;&#xA;if(currentMillis - previousMillis &amp;gt;= interval) &#xA;&#xA;{&#xA;  // save the last time you blinked the LED &#xA;  previousMillis  = currentMillis;&#xA;  interval = random((3, 14) * 1000); &#xA;&#xA;Serial.println(&quot;Blink&quot;);&#xA;Serial.println(interval);  // Just so I can confirm if the effect seems natural&#xA;digitalWrite(ledPin, LOW);&#xA;delay(250);&#xA;digitalWrite(ledPin, HIGH);&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17344" LastActivityDate="2016-02-14T11:18:57.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20647" PostTypeId="1" AcceptedAnswerId="20651" CreationDate="2016-02-14T11:29:02.117" Score="12" ViewCount="10809" Body="&lt;p&gt;I have a number of sketches that I keep wanting to load into the Arduino but I don't necessarily need to recompile them because I haven't changed anything since the last compile. Since the compile takes a minute or 2 each time, this would save me some waiting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see that the IDE has the option to &quot;Export Compiled Binary&quot;, but doesn't seem to have the converse option of Uploading a previously compiled binary. Is there any way to do this?&lt;/p&gt;&#xA;" OwnerUserId="3377" LastEditorUserId="3377" LastEditDate="2019-07-27T16:06:50.187" LastActivityDate="2019-12-18T02:01:40.043" Title="Is it possible to upload previously compiled binary?" Tags="|uploading|ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20648" PostTypeId="2" ParentId="20630" CreationDate="2016-02-14T13:37:13.467" Score="1" Body="&lt;p&gt;when you connect you regulated 5V at Vin port your 5V output will be lower than 5V as it have to pass through the 5V regulator. The input voltage should range from 7-12V.&lt;/p&gt;&#xA;" OwnerUserId="17339" LastActivityDate="2016-02-14T13:37:13.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20649" PostTypeId="2" ParentId="20643" CreationDate="2016-02-14T13:41:58.157" Score="0" Body="&lt;p&gt;The trigger pin is an input, so you can connect that directly to the Due. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The echo pin will however output 5v. You could use a voltage divider to bring that down to 3.3v or a bit lower.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-02-14T13:41:58.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20650" PostTypeId="1" CreationDate="2016-02-14T14:10:22.157" Score="2" ViewCount="348" Body="&lt;p&gt;I'm using arduino uno with cc3000 shield and I'm trying to get some sort of data from my server but I only get some of it and the remaining part is delivered after so long, when I send the request I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HTTP/1.1 200 OK.&#xA;Date: Sun, 14 Feb 2016 14:00:46 GMT.&#xA;Server: Apache.&#xA;Last-Modified: Sun, 14 Feb 2016 11:58:31 GMT.&#xA;Accept-Ranges: bytes.&#xA;Content-Length: 16.&#xA;Keep-Alive: timeout=2, max=100.&#xA;Connection: Keep-Alive.&#xA;Content-Type: application/json.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the full data should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HTTP/1.1 200 OK.&#xA;Date: Sun, 14 Feb 2016 13:59:26 GMT.&#xA;Server: Apache.&#xA;Last-Modified: Sun, 14 Feb 2016 11:58:31 GMT.&#xA;Accept-Ranges: bytes.&#xA;Content-Length: 16.&#xA;Keep-Alive: timeout=2, max=100.&#xA;Connection: Keep-Alive.&#xA;Content-Type: application/json.&#xA;{&quot;light&quot;: &quot;off&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;{&quot;light&quot;: &quot;off&quot;}&lt;/code&gt; part takes too long to get parsed to my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000.h&amp;gt;&#xA;#include &amp;lt;SFE_CC3000_Client.h&amp;gt;&#xA;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;&#xA;// Pins&#xA;#define CC3000_INT      3   // Needs to be an interrupt pin (D2/D3)&#xA;#define CC3000_EN       5   // Can be any digital pin&#xA;#define CC3000_CS       10  // Preferred is pin 10 on Uno&#xA;&#xA;// Connection info data lengths&#xA;#define IP_ADDR_LEN     4   // Length of IP address in bytes&#xA;&#xA;// Constants&#xA;char ap_ssid[] = &quot;xxxxx&quot;;                  // SSID of network&#xA;char ap_password[] = {0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX};          // Password of network&#xA;unsigned int ap_security = WLAN_SEC_WEP; // Security of network&#xA;unsigned int timeout = 30000;             // Milliseconds&#xA;&#xA;#define SERVER &quot;XXXXX&quot;&#xA;#define DIRECTORY      &quot;/esp8266pir/light.json&quot;&#xA;&#xA;const int pin        = 2;&#xA;#define IDLE_TIMEOUT_MS  5000&#xA;&#xA;// Global Variables&#xA;SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);&#xA;SFE_CC3000_Client client = SFE_CC3000_Client(wifi);&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(pin, OUTPUT); &#xA;  pinMode(pin, HIGH);&#xA;&#xA;  ConnectionInfo connection_info;&#xA;  int i;&#xA;&#xA;  // Initialize Serial port&#xA;  Serial.begin(115200);&#xA;  Serial.println();&#xA;  Serial.println(&quot;---------------------------&quot;);&#xA;  Serial.println(&quot;SparkFun CC3000 - WebClient&quot;);&#xA;  Serial.println(&quot;---------------------------&quot;);&#xA;&#xA;  // Initialize CC3000 (configure SPI communications)&#xA;  if ( wifi.init() ) {&#xA;    Serial.println(&quot;CC3000 initialization complete&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;Something went wrong during CC3000 init!&quot;);&#xA;  }&#xA;&#xA;  // Connect using DHCP&#xA;  Serial.print(&quot;Connecting to SSID: &quot;);&#xA;  Serial.println(ap_ssid);&#xA;  if(!wifi.connect(ap_ssid, ap_security, ap_password, timeout)) {&#xA;    Serial.println(&quot;Error: Could not connect to AP&quot;);&#xA;  }&#xA;&#xA;  // Gather connection details and print IP address&#xA;  if ( !wifi.getConnectionInfo(connection_info) ) {&#xA;    Serial.println(&quot;Error: Could not obtain connection details&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;IP Address: &quot;);&#xA;    for (i = 0; i &amp;lt; IP_ADDR_LEN; i++) {&#xA;      Serial.print(connection_info.ip_address[i]);&#xA;      if ( i &amp;lt; IP_ADDR_LEN - 1 ) {&#xA;        Serial.print(&quot;.&quot;);&#xA;      }&#xA;    }&#xA;    Serial.println();&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  send_request();&#xA;}&#xA;&#xA;void send_request () {&#xA;&#xA;  client.connect(SERVER, 80);&#xA;  if (client.connected()) &#xA;  {&#xA;    client.print(F(&quot;GET &quot;));&#xA;    client.print(DIRECTORY);&#xA;    client.print(F(&quot; HTTP/1.1\r\n&quot;));&#xA;    client.print(F(&quot;Host: &quot;)); client.print(SERVER); client.print(F(&quot;\r\n&quot;));&#xA;    client.print(F(&quot;Connection: keep-alive\r\n\r\n&quot;));&#xA;    client.println();&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;failed to connect&quot;));&#xA;    return;&#xA;  }&#xA;  // read response&#xA;  String section=&quot;header&quot;;&#xA;  unsigned long lastRead = millis();&#xA;  while (client.connected()&amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    while (client.available()) {&#xA;    String line = client.readStringUntil('\r');&#xA;    Serial.print(line);&#xA;    // we’ll parse the HTML body here&#xA;    if (section==&quot;header&quot;) { // headers..&#xA;      Serial.print(&quot;.&quot;);&#xA;      if (line==&quot;\n&quot;) { // skips the empty space at the beginning &#xA;        section=&quot;json&quot;;&#xA;      }&#xA;    }&#xA;    else if (section==&quot;json&quot;) {  // print the good stuff&#xA;      section=&quot;ignore&quot;;&#xA;      String result = line.substring(1);&#xA;&#xA;      // Parse JSON&#xA;      int size = result.length() + 1;&#xA;      char json[size];&#xA;      result.toCharArray(json, size);&#xA;      StaticJsonBuffer&amp;lt;200&amp;gt; jsonBuffer;&#xA;      JsonObject&amp;amp; json_parsed = jsonBuffer.parseObject(json);&#xA;      if (!json_parsed.success())&#xA;      {&#xA;        Serial.println(&quot;parseObject() failed&quot;);&#xA;        return;&#xA;      }&#xA;&#xA;      // Make the decision to turn off or on the LED&#xA;      if (strcmp(json_parsed[&quot;light&quot;], &quot;on&quot;) == 0) {&#xA;        digitalWrite(pin, HIGH); &#xA;        Serial.println(&quot;LED ON&quot;);&#xA;      }&#xA;      else {&#xA;        digitalWrite(pin, LOW);&#xA;        Serial.println(&quot;led off&quot;);&#xA;      }&#xA;    }&#xA;  lastRead = millis();&#xA;  }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is my &lt;code&gt;light.json&lt;/code&gt; code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php  &#xA;$light = $_GET['light'];&#xA;if($light == &quot;on&quot;) {  &#xA;  $file = fopen(&quot;light.json&quot;, &quot;w&quot;) or die(&quot;can't open file&quot;);&#xA;  fwrite($file, '{&quot;light&quot;: &quot;on&quot;}');&#xA;  fclose($file);&#xA;} &#xA;else if ($light == &quot;off&quot;) {  &#xA;  $file = fopen(&quot;light.json&quot;, &quot;w&quot;) or die(&quot;can't open file&quot;);&#xA;  fwrite($file, '{&quot;light&quot;: &quot;off&quot;}');&#xA;  fclose($file);&#xA;}&#xA;?&amp;gt;&#xA;&#xA;&amp;lt;a href=&quot;?light=on&quot;&amp;gt;Turn On&amp;lt;/a&amp;gt;  &#xA;&amp;lt;a href=&quot;?light=off&quot;&amp;gt;Turn Off&amp;lt;/a&amp;gt;  &#xA;&amp;lt;div&amp;gt;  &#xA;  &amp;lt;?php&#xA;    if($light==&quot;on&quot;) {&#xA;      echo(&quot;Turn LED on.&quot;);&#xA;    }&#xA;    else if ($light==&quot;off&quot;) {&#xA;      echo(&quot;Turn LED off.&quot;);&#xA;    }&#xA;    else {&#xA;      echo (&quot;Do something.&quot;);&#xA;    }&#xA;  ?&amp;gt;&#xA;&amp;lt;/div&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;memory statistics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Global variables use 1,187 bytes (57%) of dynamic memory, leaving 861 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did some enhancement to my arduino code and used adafruit library but still the server response takes too long to get it (up to 10 seconds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my new code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*************************************************** &#xA;  This is an example for the Adafruit CC3000 Wifi Breakout &amp;amp; Shield&#xA;&#xA;  Designed specifically to work with the Adafruit WiFi products:&#xA;  ----&amp;gt; https://www.adafruit.com/products/1469&#xA;&#xA;  Adafruit invests time and resources providing this open source code, &#xA;  please support Adafruit and open-source hardware by purchasing &#xA;  products from Adafruit!&#xA;&#xA;  Written by Kevin Townsend &amp;amp; Limor Fried &amp;amp; Rick Lesniak for Adafruit Industries.  &#xA;  BSD license, all text above must be included in any redistribution&#xA; ****************************************************/&#xA;&#xA;/*&#xA;&#xA;This example does a test of the SNTP (Simple Network Time Protocol) client:&#xA;* Initialization&#xA;* SSID Scan&#xA;* AP connection&#xA;* DHCP printout&#xA;* SNTP time synchronization&#xA;* Extract and print current time and date information&#xA;&#xA;*/&#xA;&#xA;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;//#include &quot;utility/NetTime.h&quot;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;&#xA;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;#include &amp;lt;TextFinder.h&amp;gt;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                                         SPI_CLOCK_DIV2); // you can change this clock speed but DI&#xA;Adafruit_CC3000_Client client;&#xA;TextFinder finder(client);&#xA;&#xA;#define WLAN_SSID       &quot;XXXXX&quot;   // cannot be longer than 32 characters!&#xA;const char WLAN_PASS[] = {0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0x00};&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WEP&#xA;&#xA;&#xA;#define SERVER &quot;XXXXX&quot;&#xA;String DIRECTORY   =   &quot;XXXXX&quot;;&#xA;&#xA;uint32_t ip;&#xA;&#xA;const int pin        = 2;&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Sets up the HW and the CC3000 module (called automatically&#xA;            on startup)&#xA;*/&#xA;/**************************************************************************/&#xA;void setup()&#xA;{&#xA;  pinMode(pin, OUTPUT); &#xA;  pinMode(pin, HIGH);&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); &#xA;&#xA;  Serial.print(&quot;Free RAM: &quot;); Serial.println(getFreeRam(), DEC);&#xA;&#xA;&#xA;  /* Initialise the module */&#xA;  Serial.println(F(&quot;\nInitialising the CC3000 ...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Unable to initialise the CC3000! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Optional: Update the Mac Address to a known value */&#xA;/*&#xA;  uint8_t macAddress[6] = { 0x08, 0x00, 0x28, 0x01, 0x79, 0xB7 };&#xA;   if (!cc3000.setMacAddress(macAddress))&#xA;   {&#xA;     Serial.println(F(&quot;Failed trying to update the MAC address&quot;));&#xA;     while(1);&#xA;   }&#xA;*/&#xA;&#xA;  uint16_t firmware = checkFirmwareVersion();&#xA;  if (firmware &amp;lt; 0x113) {&#xA;    Serial.println(F(&quot;Wrong firmware version!&quot;));&#xA;    for(;;);&#xA;  } &#xA;&#xA;  /* Delete any old connection data on the module */&#xA;  Serial.println(F(&quot;\nDeleting old connection profiles&quot;));&#xA;  if (!cc3000.deleteProfiles()) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Attempt to connect to an access point */&#xA;  char *ssid = WLAN_SSID;             /* Max 32 chars */&#xA;  Serial.print(F(&quot;\nAttempting to connect to &quot;)); Serial.println(ssid);&#xA;&#xA;  /* NOTE: Secure connections are not available in 'Tiny' mode! */&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;&#xA;  ip = 0;&#xA;  // Try looking up the website's IP address&#xA;  Serial.print(SERVER); Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;  while (ip == 0) {&#xA;    if (! cc3000.getHostByName(SERVER, &amp;amp;ip)) {&#xA;      Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;&#xA;  client = cc3000.connectTCP(ip, 80);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(!cc3000.checkConnected())&#xA;  {&#xA;    cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);&#xA;    Serial.println(&quot;connection was lost but succefully retrieved&quot;);&#xA;  }&#xA;  if(!client.connected())&#xA;  {&#xA;    client = cc3000.connectTCP(ip, 80);&#xA;    Serial.println(&quot;client lost connection but succefully retrieved it&quot;);&#xA;  }&#xA;&#xA;  String request = &quot;GET &quot; + DIRECTORY + &quot; HTTP/1.1\r\n&quot; +&#xA;               &quot;Host: &quot; + SERVER + &quot;\r\n&quot; + &#xA;               &quot;Connection: keep-alive\r\n\r\n&quot;;&#xA;  send_request(request);&#xA;}&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Tries to read the CC3000's internal firmware patch ID&#xA;*/&#xA;/**************************************************************************/&#xA;uint16_t checkFirmwareVersion(void)&#xA;{&#xA;  uint8_t major, minor;&#xA;  uint16_t version;&#xA;&#xA;#ifndef CC3000_TINY_DRIVER  &#xA;  if(!cc3000.getFirmwareVersion(&amp;amp;major, &amp;amp;minor))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the firmware version!\r\n&quot;));&#xA;    version = 0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;Firmware V. : &quot;));&#xA;    Serial.print(major); Serial.print(F(&quot;.&quot;)); Serial.println(minor);&#xA;    version = major; version &amp;lt;&amp;lt;= 8; version |= minor;&#xA;  }&#xA;#endif&#xA;  return version;&#xA;}&#xA;&#xA;void send_request (String request) {&#xA;  String req = request;&#xA;  if (client.connected()) &#xA;    {&#xA;      client.print(req);&#xA;      delay(5);&#xA;      client.println();&#xA;      delay(5);&#xA;    }&#xA;    else&#xA;    {&#xA;      Serial.print(F(&quot;failed to connect from loop&quot;));&#xA;      return;&#xA;    }&#xA;&#xA;  // read response&#xA;  while (client.connected()) {&#xA;    while (client.available()) {&#xA;      if(finder.find(&quot;\n\r&quot;)){&#xA;    int line = finder.getValue();&#xA;    Serial.print(line);&#xA;      if (line == 1) {&#xA;        digitalWrite(pin, HIGH); &#xA;        Serial.println(&quot;LED ON&quot;);&#xA;      }&#xA;      else {&#xA;        digitalWrite(pin, LOW);&#xA;        Serial.println(&quot;led off&quot;);&#xA;      }&#xA;    }&#xA;    }&#xA;  }&#xA;  client.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can somene tell me how to reduce this delay time?&lt;/p&gt;&#xA;" OwnerUserId="17349" LastEditorUserId="17349" LastEditDate="2016-02-16T14:29:03.237" LastActivityDate="2016-02-16T14:29:03.237" Title="error parsing data from server using arduino uno and cc3000 shield" Tags="|arduino-uno|arduino-ide|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20651" PostTypeId="2" ParentId="20647" CreationDate="2016-02-14T14:46:36.390" Score="14" Body="&lt;p&gt;Yes!&#xA;Its possible that you can upload a previously complied binary, using &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AVRDUDE - a command line utility which is actually used to upload binaries, behind the arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find AVRDUDE in&#xA;Arduino folder &gt; hardware  &gt; tools &gt; avr &gt; bin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This some documentation for AVRDUDE&#xA;&lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude.html&quot;&gt;http://www.nongnu.org/avrdude/user-manual/avrdude.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;else simplest thing you can do is turn on verbose output during upload and watch for a command in the end with AVRDUDE in it along with the path of hex file, just copy paste &amp;amp;  run the same command in CommandLine; your task is accomplished.&lt;/p&gt;&#xA;" OwnerUserId="3557" LastActivityDate="2016-02-14T14:46:36.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20653" PostTypeId="2" ParentId="20643" CreationDate="2016-02-14T15:45:17.633" Score="1" Body="&lt;p&gt;As suggested in previous answers, you can directly use a Due output to drive the HC-SR04's Trig pin; according to the HC-SR04 spec sheet, that pin operates at TTL levels.  It will see 0 V as a 0-input and will see 3.3 V as a 1-input since it exceeds 2.4 V.  Also see  &lt;a href=&quot;https://electronics.stackexchange.com/q/58498&quot;&gt;3.3v input to Arduino digital pin&lt;/a&gt; in electronics.stackexchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Due's inputs are not 5 V tolerant, so you will need to use a voltage divider between the Echo pin and a Due input.  See second paragraph of arduino.cc's &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow noreferrer&quot;&gt;ArduinoBoardDue&lt;/a&gt; article:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Warning: Unlike most Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-14T15:45:17.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20655" PostTypeId="2" ParentId="19873" CreationDate="2016-02-14T16:10:13.373" Score="1" Body="&lt;p&gt;Basically, your question comes down to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;How to generate two PWM signals with only one timer.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Once you've got that figured out, you could set up 6 PWM channels)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that there also are PWM generator IC's, if you don't want to use up all your timers, which can be usefull for other things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IF you really want to set all outputs to toggle at the same time (based on your code example) why won't you just use one PWM signal, and drive all the 4 devices with the same signal? (Given you're not going to change it)&#xA;IF you're going to drive motors, why would you need 4 different PWM signals? It's often enough to only use one PWM signal for the right tires/tracks and one PWM signal for the left tires/tracks.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setting the max&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since we want to generate different PWM signals from one timer, we can't just make the timer overrun (and generate a pulse or switch polarity at that point).&#xA;We want to let the timer run to completion over and over, and only change the signal when it reaches a set value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet tells us this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The TOP value can be assigned to be the fixed value 0xFF&#xA;  (MAX) or the value stored in the OCR0A Register. (328P datasheet 15.2.1 Definitions)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setting a limit per pin&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want to set 2 limits on one timer, each timer has an output compare register (OCR), the action will be generated when the timer hits this value.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Timer/Counter (TCNT0) and Output Compare Registers (OCR0A and OCR0B) are 8-bit registers. Interrupt&#xA;  request (abbreviated to Int.Req. in the figure) signals are all visible in the Timer Interrupt Flag Register (TIFR0).&#xA;  All interrupts are individually masked with the Timer Interrupt Mask Register (TIMSK0). (328P datasheet 15.2.2 Registers)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra info on compare&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below you can read some extra info on the signaling.&#xA;What actually will happen, depends on how the WGM&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;15.5 Output Compare Unit&#xA;  The 8-bit comparator continuously compares TCNT0 with the Output Compare Registers (OCR0A and&#xA;  OCR0B). Whenever TCNT0 equals OCR0A or OCR0B, the comparator signals a match. A match will set the&#xA;  Output Compare Flag (OCF0A or OCF0B) at the next timer clock cycle. If the corresponding interrupt is&#xA;  enabled, the Output Compare Flag generates an Output Compare interrupt. The Output Compare Flag is&#xA;  automatically cleared when the interrupt is executed. Alternatively, the flag can be cleared by software by writing&#xA;  a logical one to its I/O bit location. The Waveform Generator uses the match signal to generate an output&#xA;  according to operating mode set by the WGM02:0 bits and Compare Output mode (COM0x1:0) bits. The max&#xA;  and bottom signals are used by the Waveform Generator for handling the special cases of the extreme values in&#xA;  some modes of operation (”Modes of Operation” on page 98).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Fast PWM&lt;/strong&gt;&#xA;The actual settings are different per mode/modus, but for fast PWM we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Table 15-3. Compare Output Mode, Fast PWM Mode(1)&#xA;COM0A1 COM0A0 Description&#xA;0      0      Normal port operation, OC0A disconnected.&#xA;0      1      WGM02 = 0: Normal Port Operation, OC0A Disconnected.&#xA;              WGM02 = 1: Toggle OC0A on Compare Match.&#xA;1      0      Clear OC0A on Compare Match, set OC0A at BOTTOM, (non-inverting mode).&#xA;1      1      Set OC0A on Compare Match, clear OC0A at BOTTOM, (inverting mode).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The table tells us we need to set COM0A1 and COM0A0 to 1.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;COM0B1 COM0B0 Description&#xA;0      0      Normal port operation, OC0B disconnected.&#xA;0      1      Reserved&#xA;1      0      Clear OC0B on Compare Match, set OC0B at BOTTOM, (non-inverting mode)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This table tells us we need to set COM0B1 and COM0B0 to 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;WGM mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's all set up, we only need to put the PWM in the right mode.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mode WGM02 WGM01 WGM00 Timer/Counter TOP  Update-OCRx TOV-on&#xA;0    0     0     0     Normal        0xFF Immediate   MAX&#xA;1    0     0     1     PWM,P-Correct 0xFF TOP         BOTTOM&#xA;2    0     1     0     CTC           OCRA Immediate   MAX&#xA;3    0     1     1     Fast PWM      0xFF BOTTOM      MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So we'll need to set WGM02 to 0 and WGM01 and WGM00 to 1, to use fast PWM.F&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Succes?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should now be able to change the PWM's of these pins by setting the output compare registers of these.&#xA;Getting the double PWM of the other timer ready, shouldn't be much more different.&#xA;Be sure to set the right prescaler. Though it depends on a lot of external things.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-02-14T16:10:13.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20656" PostTypeId="1" CreationDate="2016-02-14T11:17:50.953" Score="0" ViewCount="757" Body="&lt;p&gt;I programming atmega328P bootloaded with an FTDI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some tutorial mentions that you have to connect the DTR to the reset pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://electronics-diy.com/FT232RL_USB_to_Serial_Adapter_for_PIC_AVR_ATMEGA_ARDUINO_MCUs.php&quot; rel=&quot;nofollow&quot;&gt;http://electronics-diy.com/FT232RL_USB_to_Serial_Adapter_for_PIC_AVR_ATMEGA_ARDUINO_MCUs.php&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that so? Because some don't, they just say rx,tx is enough. I still can't program the chip with the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; avrdude -p m328p -P /dev/ttyUSB0 -c avrisp -b 9600 -n -v -v -v&#xA;&#xA;avrdude: Version 5.11.1, compiled on Oct 18 2011 at 21:17:35&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/root/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/ttyUSB0&#xA;         Using Programmer              : avrisp&#xA;         Overriding Baud Rate          : 9600&#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried different baud rates, no matter what it's not responding. Linux recognizes the FTDI as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sat Feb 13 22:52:14 2016] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0&#xA;[Sat Feb 13 22:52:14 2016] ftdi_sio 1-2.1:1.0: device disconnected&#xA;[Sat Feb 13 22:52:19 2016] usb 1-2.1: new full-speed USB device number 73 using uhci_hcd&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: New USB device found, idVendor=0403, idProduct=6001&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: Product: FT232R USB UART&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: Manufacturer: FTDI&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: SerialNumber: A6004mhS&#xA;[Sat Feb 13 22:52:20 2016] ftdi_sio 1-2.1:1.0: FTDI USB Serial Device converter detected&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: Detected FT232RL&#xA;[Sat Feb 13 22:52:20 2016] usb 1-2.1: FTDI USB Serial Device converter now attached to ttyUSB0&#xA;[Sat Feb 13 22:56:25 2016] usb 1-2.1: USB disconnect, device number 73&#xA;[Sat Feb 13 22:56:25 2016] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0&#xA;[Sat Feb 13 22:56:25 2016] ftdi_sio 1-2.1:1.0: device disconnected&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Well my questions now are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1, When I use the Arduino IDE to program a barebone 328P with this FTDI what should be the &lt;strong&gt;BOARD&lt;/strong&gt; and what should be the &lt;strong&gt;PROGRAMMER&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I have it on Arduino Nano/Atmega328 + AVRISP mkII&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I tried almost all... I think something else is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2, Should I be able to get any result with doing the previous:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; avrdude -p m328p -P /dev/ttyUSB0 -c avrisp -b 9600 -n -v -v -v&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;command WITHOUT connecting the barebone chip? I think not, since this doesn't act like a fully fledged MCU just like a serial converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="16175" OwnerDisplayName="munin24" LastActivityDate="2016-02-14T21:18:57.553" Title="FTDI stdk 500k not responding" Tags="|ftdi|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20657" PostTypeId="2" ParentId="20656" CreationDate="2016-02-14T15:10:08.717" Score="0" Body="&lt;p&gt;You need to connect DTR to the reset pin because the Arduino IDE (really avrdude) needs to be able to reset the processor in order to return control to the bootloader, which will then receive the new program. When an Arduino board is running your sketch, the serial port is available for use by the sketch; it can't be used to upload a new program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your first question, you should set the board to whatever your board actually is. You don't have to worry about the programmer. It's only used if you use the &quot;upload with programmer&quot; function. The normal &quot;upload&quot; function uses the serial port to send the sketch to the board via the bootloader. That's what you want. Note that while you don't have to set the programmer, you do have to set the port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use avrdude to program the Arduino through the serial port via the bootloader. That's exactly what the IDE does. You have to specify the port just as you do in the IDE. To determine the other settings, look up your board in the Arduino IDE's boards.txt file. Most of what boards.txt does is tell the IDE how to invoke avrdude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that one reason why avrdude isn't working for you is that you've set the baud rate to 9600.  According to boards.txt the upload speed for the Nano with the ATmega328P is 57600.&lt;/p&gt;&#xA;" OwnerDisplayName="Willis Blackburn" LastActivityDate="2016-02-14T15:10:08.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20658" PostTypeId="1" CreationDate="2016-02-14T19:03:00.150" Score="2" ViewCount="158" Body="&lt;p&gt;I found this thread here which describes procedure to change the produce-name of Teensy&#xA;However when we open device properties we see 'Teensy USB Serial (COM xx) in the Device function summary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please find the image below to understand what I am referring to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/A1a0u.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/A1a0u.jpg&quot; alt=&quot;Teensy Device Properies&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there any way to change this details as well?&lt;/p&gt;&#xA;" OwnerUserId="10165" LastActivityDate="2016-02-14T19:03:00.150" Title="Change device Function Summary for Teensy-LC" Tags="|usb|teensy|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20659" PostTypeId="1" CreationDate="2016-02-14T19:55:36.943" Score="2" ViewCount="46577" Body="&lt;p&gt;I need to operate 2 different sensors (gas and temp) simultaneously. &#xA;I have managed to run each one of them separately and I don't know how to manipulate the code so they could work together. My background in coding is basic and I'm not the one who wrote these codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the sketches:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thermistor code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //This function gets called when the Arduino starts&#xA;  Serial.begin(9600);&#xA;  //This code sets up the Serial port at 9600 baud rate&#xA;}&#xA;&#xA;void loop() {&#xA;  //This function loops while the arduino is powered&#xA;  int val; //Create an integer variable&#xA;  val=analogRead(0);&#xA;  //Read the analog port 0 and store the value in val&#xA;  Serial.println(val);&#xA;  //Print the value to the serial port&#xA;  delay(1000);&#xA;  //Wait one second before we do it again&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the gas detector code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* GAS Sensor MQ-2&#xA;This sensor detects flammable gasses&#xA;the board has four pins&#xA;connect AO to Arduino pin A0&#xA;connect DO to Arduino pin 2&#xA;connect Gnd to Arduino Gnd&#xA;connect Vcc to Arduino 5 volts&#xA;*/&#xA;&#xA;int sensorPin = A0;&#xA;// select the input pin for the potentiometer&#xA;int DOPin = 2;&#xA;// select the pin for the LED&#xA;int sensorValue = 0;&#xA;// variable to store the value coming from the sensor&#xA;int ledPin =13;&#xA;&#xA;void setup() {&#xA;  // declare the ledPin as an OUTPUT:&#xA;  pinMode(DOPin, INPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the value from the sensor:&#xA;  sensorValue = analogRead(sensorPin);&#xA;  Serial.print(&quot;Analog Output = &quot;);&#xA;  Serial.println(sensorValue);&#xA;  // turn the ledPin on if triggered&#xA;  if (digitalRead(DOPin) ==HIGH) {&#xA;    digitalWrite(ledPin, LOW);&#xA;    Serial.println(&quot;Digital Output = OFF&quot;);&#xA;  } else {&#xA;    digitalWrite(ledPin, HIGH);&#xA;    Serial.println(&quot;Digital Output = ON&quot;);&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18355" LastEditorUserId="4628" LastEditDate="2017-10-28T11:55:48.487" LastActivityDate="2018-07-01T07:09:43.703" Title="Combining code for multiple sensors in one program" Tags="|programming|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20660" PostTypeId="1" AcceptedAnswerId="20665" CreationDate="2016-02-14T20:06:21.587" Score="4" ViewCount="9971" Body="&lt;p&gt;I was learning to program for a &lt;em&gt;void obstacle robot&lt;/em&gt; but when I looked at the code I saw two data types long and int.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Int are datatypes that holds  -2,147,483,648 to 2,147,483,647.&#xA;Long are also datatypes that holds -2,147,483,648 to 2,147,483,647.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Int and long are like same but I came up with the code where two types of datatype is used as seen below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int trigPin = 2;&#xA;int echoPin = 4;&#xA;long duration, cm, inches;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But how can you know when to use which datatype? I searched a lot in the web but I didn't understand so can someone explain this to me please.&lt;/p&gt;&#xA;" OwnerUserId="16785" LastEditorUserId="10794" LastEditDate="2016-02-14T20:23:17.477" LastActivityDate="2022-08-28T00:26:38.133" Title="Difference between data type int and long on Arduino" Tags="|programming|c++|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20661" PostTypeId="2" ParentId="20659" CreationDate="2016-02-14T20:17:25.440" Score="5" Body="&lt;p&gt;You just need to assign the sensors different pins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* GAS Sensor MQ-2&#xA;This sensor detects flammable gasses&#xA;the board has four pins&#xA;connect AO to Arduino pin A0&#xA;connect DO to Arduino pin 2&#xA;connect Gnd to Arduino Gnd&#xA;connect Vcc to Arduino 5 volts&#xA;*/&#xA;&#xA;int gasSensorPin= A0; // GAS sensor pin&#xA;int DOpin= 2; // select the pin for the LED&#xA;int gasSensorValue= 0; // variable to store the value coming from the sensor&#xA;int ledPin = 13;&#xA;&#xA;int tempSensorPin = A1;  //Temperature sensor pin&#xA;int tempSensorValue;&#xA;&#xA;void setup() {&#xA; // declare the ledPin as an OUTPUT:&#xA; pinMode(DOPin, INPUT);&#xA; pinMode(ledPin, OUTPUT);&#xA; Serial.begin(9600);&#xA; }&#xA;&#xA;&#xA;void loop() {&#xA; // read the value from the sensor:&#xA; gasSensorValue= analogRead(gasSensorPin);&#xA; Serial.print(&quot;Analog Output = &quot;);&#xA; Serial.println(gasSensorValue);&#xA; // turn the ledPin on if triggered&#xA; //&#xA; if (digitalRead(DOpin) == HIGH){&#xA; digitalWrite(ledPin, LOW);&#xA; Serial.println(&quot;Digital Output = OFF&quot;);&#xA; }&#xA;   else {&#xA;     digitalWrite(ledPin, HIGH);&#xA;     Serial.println(&quot;Digital Output = ON&quot;);&#xA;  }&#xA;&#xA;Serial.print(&quot;Temperture: &quot;);&#xA;tempSensorValue = analogRead(tempSensorPin));&#xA;Serial.println(tempSensorPin);  //Print the value of pin A4&#xA;&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is your combined sketch.&lt;/p&gt;&#xA;" OwnerUserId="7123" LastEditorUserId="7123" LastEditDate="2016-02-14T20:23:18.157" LastActivityDate="2016-02-14T20:23:18.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20664" PostTypeId="2" ParentId="20660" CreationDate="2016-02-14T20:23:52.893" Score="4" Body="&lt;p&gt;&lt;code&gt;int&lt;/code&gt; in AVR GCC is &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc#Type_Layout&quot;&gt;&lt;strong&gt;16&lt;/strong&gt; bits&lt;/a&gt;, &lt;em&gt;not&lt;/em&gt; 32.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-14T20:23:52.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20665" PostTypeId="2" ParentId="20660" CreationDate="2016-02-14T20:24:19.107" Score="8" Body="&lt;p&gt;On the Arduino (AVR models) an &lt;code&gt;int&lt;/code&gt; is 16 bits, not 32 bits. Thus it goes from -32768 to +32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is &lt;strong&gt;different&lt;/strong&gt; from &lt;code&gt;long&lt;/code&gt; which is 32 bits.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-14T20:24:19.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20666" PostTypeId="1" AcceptedAnswerId="20669" CreationDate="2016-02-14T20:36:41.843" Score="2" ViewCount="1219" Body="&lt;p&gt;While working for the automation side of my new house, I'm currently in the process of installing several reed switches on top of external doors and windows. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if this could be used as a &quot;security&quot; infrastructure, I'm more interested, at the moment, at the &quot;automation&quot; side (&lt;em&gt;checking the status of door and windows without the need to physically watch them&lt;/em&gt;) and as such, I'm going to extend the arduino-based infrastructure I've already planned and prototyped [&lt;em&gt;more details &lt;a href=&quot;https://arduino.stackexchange.com/questions/15834/how-to-interconnect-multiple-arduinos-with-a-rpi-to-control-home-lights-switches&quot;&gt;here&lt;/a&gt;&lt;/em&gt;].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the reed-switch I've installed (1€ coin added for size reference):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hFchU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hFchU.png&quot; alt=&quot;reed switch photo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and this is the related circuits:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gq0GH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gq0GH.png&quot; alt=&quot;reed switch circuits&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, it comes with two circuits: one related to the &quot;switch&quot; funcionality; another one as a safety-measure to catch some &quot;cuts&quot; along the wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check its status, currently, I've configured:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;contact circuit&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one end to an Arduino GROUND_PIN;&lt;/li&gt;&#xA;&lt;li&gt;the other end to Digital PIN 52 (REED1_SW_Pin);&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;tamper circuit&quot;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;one end to an Arduino GROUND_PIN (same GND pin as above);&lt;/li&gt;&#xA;&lt;li&gt;the other end to Digital PIN 50 (REED1_AT_Pin);&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino setup:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;pinMode(REED1_SW_Pin, INPUT_PULLUP)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pinMode(REED1_AT_Pin, INPUT_PULLUP)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the main code-block handling REED events is reported below&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Even tough everything is working fine, I wonder if there are better approaches, expecially inchecking the status of door and windows without the need to physically watch them terms of POWER-CONSUMPTION. So, here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;TAMPER-Circuit&lt;/strong&gt;: due to its nature, it will always be a &quot;closed&quot; circuit, with current flowing inside, from REED1_AT_Pin to GND. Currently I'm checking its state every 1 second (&lt;code&gt;#define REED_AT_CHECKDELAY   1000&lt;/code&gt;) but a frequency of once every 5 seconds, or even 10 seconds would be acceptable (for me). So I would like to have the current flowing &lt;em&gt;ONLY&lt;/em&gt; during the &quot;checking-timeframe&quot;. Something like:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;every 5 seconds...&lt;/li&gt;&#xA;&lt;li&gt;power-up something, getting the current flowing along the circuit;&lt;/li&gt;&#xA;&lt;li&gt;check if the current flows;&lt;/li&gt;&#xA;&lt;li&gt;if yes =&gt; OK&lt;/li&gt;&#xA;&lt;li&gt;if no =&gt; set/keep the ALARM state &lt;/li&gt;&#xA;&lt;li&gt;power-down the &quot;something&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Is it feasible? If yes, how? Also: is it worth the effort?&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;REED-switch circuit&lt;/strong&gt;: same as above. Polling approach is still acceptable (for me) but frequency need to be relatively high (5 seconds max), in order to keep of sort of &quot;near-real-time feedback&quot; when opening/closing windows. Best would be 2 secs polling-interval.&#xA;With such a timing, does the polling-approach make sense?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;from an &quot;electronic&quot; point of view, what is the &quot;to-be-preferred-scenario&quot; for the Arduino board: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;having a small, fixed, steady current, flowing out from a PIN, for &lt;em&gt;YEARS&lt;/em&gt; on a 24/7/365 basis or...&lt;/li&gt;&#xA;&lt;li&gt;having a continuosly transition from LOW-&gt;HIGH-&gt;LOW for a Digital PIN, say once every 5 seconds, again, for YEARS?&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Every comment, sidenotes, hints, critics, whatever... is &lt;strong&gt;REALLY&lt;/strong&gt; welcomed/appreciated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Arduino code-block handling REED events&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;BTW: the full-code, where the REED switch is handled togheter with pushbuttons and relays, &lt;a href=&quot;https://github.com/verzulli/arduino-smart-home/tree/master/TEST_NETWORKED_BUTTON_WITH_REED&quot; rel=&quot;nofollow noreferrer&quot;&gt;it's available on GitHub&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;    [...]&#xA;    if (reed_sw1_state != reed_sw1_previous_state) {&#xA;        // a change occurred. Are we in a &quot;boucing&quot; window?&#xA;        if (millis() - last_reed_sw1_debounce &gt; REED_DEBOUNCE) {&#xA;          // no. So it's a real change&#xA;          // Let's handle the event...&#xA;          Serial.print(millis());&#xA;          Serial.print(&quot;[REED] - SW1 state CHANGED from [&quot;);&#xA;          Serial.print(reed_sw1_previous_state);&#xA;          Serial.print(&quot;] to [&quot;); &#xA;          Serial.print(reed_sw1_state);&#xA;          Serial.println(&quot;]&quot;);&#xA;          reed_sw1_previous_state = reed_sw1_state;&#xA;          last_reed_sw1_debounce = millis();&#xA;        } else {&#xA;          // yes. Let's ignore it&#xA;        }   &#xA;      }&#xA;&#xA;      // Let's check REED Switches anti-tamper state&#xA;      if (millis()-reed_at1_lastcheck &gt; REED_AT_CHECKDELAY) {&#xA;         reed_at1_state = ! digitalRead(REED1_AT_Pin);&#xA;         if (reed_at1_state == HIGH ) {&#xA;            Serial.print(millis());&#xA;            Serial.print(&quot;[REED] - AT1 state OK [&quot;);&#xA;            Serial.print(reed_at1_state);&#xA;            Serial.println(&quot;]&quot;);&#xA;         } else {&#xA;            Serial.print(millis());&#xA;            Serial.print(&quot;[REED] - AT1 state ALARM - OnGoing TAMPER!!! [&quot;);&#xA;            Serial.print(reed_at1_state);&#xA;            Serial.println(&quot;]&quot;);          &#xA;         }&#xA;         reed_at1_lastcheck = millis();&#xA;      }&#xA;      [...]&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-02-14T21:23:05.770" Title="&quot;tamper&quot; circuit of a reed switch: can I connect the two wires to an INPUT and an OUTPUT pin?" Tags="|arduino-mega|sensors|power|current|system-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20667" PostTypeId="1" AcceptedAnswerId="20668" CreationDate="2016-02-14T20:36:55.623" Score="2" ViewCount="742" Body="&lt;p&gt;I am using the following code to enable an interrupt for a pin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin&#xA;PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt&#xA;PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't disable it. I am trying with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (*digitalPinToPCMSK(pin) == 0)&#xA;*digitalPinToPCICR(pin) &amp;amp;= ~(1&amp;lt;&amp;lt;digitalPinToPCICRbit(pin));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but it isn't working.&lt;/p&gt;&#xA;" OwnerUserId="7123" LastEditorUserId="10794" LastEditDate="2016-02-14T21:00:08.917" LastActivityDate="2016-02-14T21:00:08.917" Title="Detaching interrupts" Tags="|arduino-uno|c++|interrupt|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20668" PostTypeId="2" ParentId="20667" CreationDate="2016-02-14T20:59:21.520" Score="1" Body="&lt;p&gt;Don't you mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  PCICR  &amp;amp;= ~bit (digitalPinToPCICRbit(pin));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-14T20:59:21.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20669" PostTypeId="2" ParentId="20666" CreationDate="2016-02-14T21:07:56.293" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So I would like to have the current flowing ONLY during the &quot;checking-timeframe&quot;. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Turn off the pull-up until just before checking. Allow a few milliseconds for the pull-up to raise the voltage.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With such a timing, does the polling-approach make sense?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Certainly, if you are trying to save battery power. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Bear in mind the voltage drops over long cable runs (and also possibly induced spikes). You might want a more powerful pull-up (eg. 10k) rather than the inbuilt 50k. You can still organize that by having an output pin turn on the voltage to the pull-up. Or, have the pull-up wired in permanently but instead of running the other side to ground, set the &quot;ground&quot; wire to &lt;code&gt;OUTPUT&lt;/code&gt; and write &lt;code&gt;LOW&lt;/code&gt; to it - and then set it to &lt;code&gt;INPUT&lt;/code&gt; when you want it to be inactive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my post about &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;Power saving&lt;/a&gt; - you could use a watchdog timer to wake the device at (say) every 4 seconds, to check things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to add in input-circuit protection (eg. a couple of diodes) to dampen down any incoming spikes. Even something simple like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hAkDB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hAkDB.png&quot; alt=&quot;Input protection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-14T21:23:05.770" LastActivityDate="2016-02-14T21:23:05.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20670" PostTypeId="2" ParentId="20656" CreationDate="2016-02-14T21:18:57.553" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Right now I have it on Arduino Nano/Atmega328 + AVRISP mkII&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Tha AVRISP is not an FTDI programmer. How do you have it wired up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;How to make an Arduino-compatible minimal board&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that page, this is how I hooked up my FTDI cable:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0ymm8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0ymm8.jpg&quot; alt=&quot;FTDI connections&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And a close-up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V9wye.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V9wye.jpg&quot; alt=&quot;Close-up of FTDI&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need RTS, via a 0.1 µF capacitor (in series) in order to trigger a reset.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-14T21:18:57.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20671" PostTypeId="1" AcceptedAnswerId="20673" CreationDate="2016-02-14T21:30:49.040" Score="0" ViewCount="2612" Body="&lt;p&gt;This is my first question on this site, and I'm relatively new with Arduino. I do have some experience using the board to reprogram a robot that used infrared proximity sensors, servos, and switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add a sensor on to the robot that will allow him to recognize specific &quot;obstacles&quot; that I will put in his environment (not walls!) For instance, when he sees a red card, he needs to spin, but when he sees a green card, he needs to roll in the opposite direction. I do not want to spend much on the cards, but I would be willing to put a small battery and LED in them if I had to. The cards do not necessarily need to be colored, I was just using that as an example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot will be in a well-lit room with noise in the background. He will be controlled by an Arduino Uno, an infrared sensor and a remote control. He can be pretty close to the cards if he has to (3 centimeters or so would be enough). It would be ideal if he could discern different types of cards, but that is not necessary as long as he's able to tell a card from the rest of his environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am simply not sure how to go about implementing this. I have read about using photoresistors to differentiate color, and they're really cheap, but will they be accurate enough from a distance? This is the light sensor I was considering using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mouser.com/ProductDetail/Adafruit/161/?qs=GURawfaeGuDpQ5XPTNqKUw%3D%3D&amp;amp;gclid=Cj0KEQiA6IC2BRDcjPrjm_istoUBEiQASrLz1rQNwZgntUcccnOmrFph-pCbu60R00GNozB_XbZxYz0aAn0j8P8HAQ&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/ProductDetail/Adafruit/161/?qs=GURawfaeGuDpQ5XPTNqKUw%3D%3D&amp;amp;gclid=Cj0KEQiA6IC2BRDcjPrjm_istoUBEiQASrLz1rQNwZgntUcccnOmrFph-pCbu60R00GNozB_XbZxYz0aAn0j8P8HAQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm willing to pay about 5$ for one if I need to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the light sensor method, can I just use brightly colored cards or will I need to use LEDs? Is there a better way to accomplish my goal that you are aware of?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your time. If there is missing information in my question, please tell me and I will add it.&lt;/p&gt;&#xA;" OwnerUserId="18356" LastActivityDate="2016-02-15T03:37:02.840" Title="How can I get my Arduino to recognize a specific object using some kind of sensor?" Tags="|sensors|photoresistor|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20672" PostTypeId="1" AcceptedAnswerId="20682" CreationDate="2016-02-14T22:03:10.093" Score="0" ViewCount="45" Body="&lt;p&gt;I have 5 LDR and Arduino Mega. I connect them and get light level.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;// print the analog output in milli volts&#xA;int w=analogRead(west);&#xA;Serial.print(&quot;west = &quot;);&#xA;&#xA;Serial.print(w);&#xA;Serial.println(&quot; mv&quot;);&#xA;&#xA;int e=analogRead(east);&#xA;Serial.print(&quot;east = &quot;);&#xA;&#xA;Serial.print(e);&#xA;Serial.println(&quot; mv&quot;);&#xA;&#xA;int n=analogRead(north);&#xA;Serial.print(&quot;north = &quot;);&#xA;&#xA;Serial.print(n);&#xA;Serial.println(&quot; mv&quot;);&#xA;&#xA;int s=analogRead(south);&#xA;Serial.print(&quot;south = &quot;);&#xA;&#xA;Serial.print(s);&#xA;Serial.println(&quot; mv&quot;);&#xA;&#xA;int c=analogRead(control);&#xA;Serial.print(&quot;control = &quot;);&#xA;&#xA;Serial.print(c);&#xA;Serial.println(&quot; mv&quot;);&#xA;&#xA;delay(1000);&#xA;&#xA;if(e &amp;gt; w)&#xA;Serial.println(&quot;west&quot;);&#xA;&#xA;else if(e &amp;lt; w)&#xA;Serial.println(&quot;east&quot;);&#xA;&#xA;else if(s &amp;gt; n)&#xA;Serial.println(&quot;south&quot;);&#xA;&#xA;else(s &amp;lt; n);&#xA;Serial.println(&quot;north&quot;);&#xA;&#xA;Serial.println(&quot;\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is my loop and I always see east-north. When west is bigger than east I also see east. What &lt;/p&gt;&#xA;" OwnerUserId="8761" LastEditorUserId="1585" LastEditDate="2016-02-14T22:08:00.507" LastActivityDate="2016-02-15T02:28:56.107" Title="while compare, something is wrong" Tags="|sensors|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20673" PostTypeId="2" ParentId="20671" CreationDate="2016-02-14T22:07:33.410" Score="0" Body="&lt;p&gt;If you are controlling your robot with a remote control, why do you need it to detect cards, instead you can tell it to do whatever you want right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to detect specific objects according to their colors, arduino is not a platform i will choose, because it doesn't have processing power to do image processing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But take a look at this, &lt;a href=&quot;http://charmedlabs.com/default/pixy-cmucam5/&quot; rel=&quot;nofollow&quot;&gt;http://charmedlabs.com/default/pixy-cmucam5/&lt;/a&gt; it can talk to arduino, and you can train it by telling it identify colored objects which i might think is apt for your case.&#xA;RFID tags will be a good idea as @Majenko said. &lt;/p&gt;&#xA;" OwnerUserId="13910" LastActivityDate="2016-02-14T22:07:33.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20674" PostTypeId="1" AcceptedAnswerId="20676" CreationDate="2016-02-14T22:15:00.927" Score="1" ViewCount="1203" Body="&lt;p&gt;Anybody here knows the physical dimensions(size) of the new Aduino MKR1000 board?&lt;/p&gt;&#xA;" OwnerUserId="16790" LastActivityDate="2016-02-14T22:48:53.387" Title="Physical dimensions(size) of the new MKR1000 board?" Tags="|arduino-uno|arduino-mega|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20675" PostTypeId="2" ParentId="20672" CreationDate="2016-02-14T22:43:13.067" Score="2" Body="&#xA;&#xA;&lt;p&gt;Here:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;else(s &amp;lt; n);&#xA;-----------^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is wrong. See &lt;a href=&quot;http://www.gammon.com.au/tips#trap13&quot; rel=&quot;nofollow&quot;&gt;Arduino programming traps, tips and style guide&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Trap #13: Don't put a semicolon at the end of every line&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Semicolons end statements. However &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; are &lt;em&gt;compound&lt;/em&gt; statements, so they should &lt;em&gt;not&lt;/em&gt; have a semicolon after them like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wrong! ...&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  if (temperature &amp;gt; 40);    // &amp;lt;----- this semicolon is incorrect!&#xA;    {&#xA;    digitalWrite (furnaceControl, LOW);&#xA;    digitalWrite (warningLight, HIGH);&#xA;    }&#xA;&#xA;  for (int i = 0; i &amp;lt; 10; i++);   // &amp;lt;----- this semicolon is incorrect!&#xA;    digitalWrite (i, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The semicolons above (as indicated) terminate the &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;for&lt;/code&gt; so they don't do anything useful. The lines following them are just unconditional blocks of code which are always executed, once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Correct:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  if (temperature &amp;gt; 40)&#xA;    {&#xA;    digitalWrite (furnaceControl, LOW);&#xA;    digitalWrite (warningLight, HIGH);&#xA;    }&#xA;&#xA;  for (int i = 0; i &amp;lt; 10; i++)&#xA;    digitalWrite (i, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-14T22:43:13.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20676" PostTypeId="2" ParentId="20674" CreationDate="2016-02-14T22:48:53.387" Score="1" Body="&lt;p&gt;If the diagram on &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoMKR1000&quot; rel=&quot;nofollow&quot;&gt;the main page&lt;/a&gt; is to scale, then it's approximately 2.2 inches by 1.0 inches.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-14T22:48:53.387" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20677" PostTypeId="1" AcceptedAnswerId="20679" CreationDate="2016-02-14T23:00:02.020" Score="0" ViewCount="239" Body="&lt;p&gt;Lately, we got an old arduino uno donated from a friend and have been trying to get it to work with servos. We have been having very perplexing results. We have tried many different &quot;stock&quot; code and servo combinations with our servos, but here is the behavior:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;180 Servos automatically move to right max as soon as power is applied.&lt;/li&gt;&#xA;&lt;li&gt;Sail Winch servo moves a tiny amount and then stops. If power wire is removed and then reapplied, the servo moves another tiny amount.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The code is very simple. First we call the &lt;code&gt;servo.attach(pin)&lt;/code&gt;, and confirm the pin. We have also tried doing the manual uSec definition: &lt;code&gt;servo.attach(pin, 600, 2400)&lt;/code&gt;. In our loop() we have tried &lt;code&gt;servo.write(*value from 0-180*)&lt;/code&gt; and &lt;code&gt;servo.writeMicroseconds(*value in PWM range*)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power is being supplied by a 9v battery, the sensor (yellow) is directly in digital pwm pin, while red (power) is in &lt;strong&gt;+&lt;/strong&gt; and black (ground) is in &lt;strong&gt;-&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I'm trying to decide whether I should invest in another arduino system.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;servos:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.servocity.com/html/hs-322hd_standard_deluxe.html&quot; rel=&quot;nofollow&quot;&gt;180 servos&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/__20853__SW5513_4MA_Sailwinch_Servo_10_63kg_55g_0_9.html&quot; rel=&quot;nofollow&quot;&gt;Sail Winch servo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17309" LastEditorUserId="17309" LastEditDate="2016-02-14T23:24:22.760" LastActivityDate="2016-02-15T02:24:45.040" Title="Do I have a faulty arduino uno, or have I found an Arduino bug?" Tags="|arduino-uno|servo|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20678" PostTypeId="1" CreationDate="2016-02-14T23:29:23.017" Score="0" ViewCount="460" Body="&lt;p&gt;I am currently working on a program for an Arduino uno and want to, in the program, when it receives a 16 digit number from a serial transmition, it will split the 16 digit number into 4 separate 4 digit numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Example: &#xA;The computer sends the Arduino the number 1100115011001150 and I want the Arduino to break the number so that &quot;Avalue&quot; would equal 1100, &quot;Bvalue&quot; would equal 1150, &quot;Cvalue&quot; would equal 1100 and so on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help you can provide!&lt;/p&gt;&#xA;" OwnerUserId="18358" LastActivityDate="2016-03-23T10:02:44.170" Title="Splitting String from Serial" Tags="|serial|string|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20679" PostTypeId="2" ParentId="20677" CreationDate="2016-02-14T23:54:25.243" Score="2" Body="&lt;p&gt;If the Arduino &quot;fails&quot; the moment you apply power to a motor, you can bet that it is a power issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or possibly you are exceeding the output rating of the output pin. You should not draw more than 20 mA from each output pin continuously.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm trying to decide whether I should invest in another arduino system.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Power the motor independently of the Arduino. This is normal advice for all but very small motors. Also make sure that you have a suitable driving transistor / MOSFET if the motor draws more than 20 mA. Take into account any surge startup current.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/motors&quot; rel=&quot;nofollow noreferrer&quot;&gt;Driving motors, lights, etc. from an Arduino output pin&lt;/a&gt; for some design ideas.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/evRtg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/evRtg.png&quot; alt=&quot;MOSFET driver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-15T02:24:45.040" LastActivityDate="2016-02-15T02:24:45.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20680" PostTypeId="2" ParentId="20678" CreationDate="2016-02-15T00:01:33.287" Score="0" Body="&lt;pre&gt;&lt;code&gt;int nums[] = {0, 0, 0, 0};   // must be always reset to zero if you will repeat this process&#xA;while (Serial.available() &amp;lt; 16);   // wait for 16 chars to come in; easiest way to do this&#xA;for (int i = 0; i &amp;lt; 4; i++){      // for each number&#xA;    for (int j = 0; j &amp;lt; 4; j++){    // for each digit in the number&#xA;        nums[i] *= 10;   &#xA;        nums[i] += Serial.read() - '0';&#xA;&#xA;//while (Serial.available() == 0);&#xA;//Serial.read();  // in case you use an extra character to separate numbers&#xA;&#xA;A = nums[0];&#xA;B = nums[1];&#xA;C = nums[2];&#xA;D = nums[3];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are using a character or characters to delimit the 16-digit numbers being received, make sure to read off those extra characters before running the while loop again. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-15T00:01:33.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20681" PostTypeId="2" ParentId="20660" CreationDate="2016-02-15T02:20:26.483" Score="5" Body="&lt;p&gt;According to the C language specification, &lt;code&gt;int&lt;/code&gt; must be at least 16 bits or longer and &lt;code&gt;long&lt;/code&gt; must be at least 32 bits or longer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is OK for a compiler to implement &lt;code&gt;int&lt;/code&gt; as 32 bits or even 64 bits. It is OK for a compiler to implement &lt;code&gt;long&lt;/code&gt; as 64 bits or longer. But it is not allowed for a compiler to implement &lt;code&gt;long&lt;/code&gt; as 16 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when to use which type?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the values you will be working with can be represented within 16 bits then it's OK to use &lt;code&gt;int&lt;/code&gt;. If you need more than 16 bits use &lt;code&gt;long&lt;/code&gt;. If you need more than 32 bits use &lt;code&gt;long long&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do not be caught up with compiler and/or CPU specifics. As mentioned by others, even within the same product range, Arduinos, there are 16 and 32 bit CPUs available. Instead, only trust what the standard guarantees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full specification of types in C are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;char&lt;/code&gt; must be at least 8 bits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;int&lt;/code&gt; must be at least 16 bits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;long&lt;/code&gt; must be at least 32 bits&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;long long&lt;/code&gt; must be at least 64 bits&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: It is perfectly legal for compilers to implement char, int, long and long long as 64 bits. This is in fact not uncommon among DSPs.&lt;/p&gt;&#xA;" OwnerUserId="18361" LastActivityDate="2016-02-15T02:20:26.483" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20682" PostTypeId="2" ParentId="20672" CreationDate="2016-02-15T02:28:56.107" Score="3" Body="&lt;p&gt;Nick Gammon correctly points out a problem due to an extra semicolon, but you should also note what the construct &lt;code&gt;else(s &amp;lt; n)&lt;/code&gt; is doing.  When the &lt;code&gt;if&lt;/code&gt; condition that this &lt;code&gt;else&lt;/code&gt; gives an alternative to is false, the statement   &lt;code&gt;(s &amp;lt; n)&lt;/code&gt; gets executed.  That statement is an expression statement, and its value is the evaluation of &lt;code&gt;s&amp;lt;n&lt;/code&gt;, either true or false.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the semicolon after &lt;code&gt;(s &amp;lt; n)&lt;/code&gt; weren't there, you'd get a compile error because &lt;code&gt;(s &amp;lt; n) serial.println(&quot;north&quot;)&lt;/code&gt; is not a valid statement.  You may have meant to say &lt;code&gt;else if(s &amp;lt; n)&lt;/code&gt; instead of &lt;code&gt;else(s &amp;lt; n)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, in the sequence&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (e &amp;gt; w)&#xA;   Serial.println(&quot;west&quot;);&#xA;else if (e &amp;lt; w)&#xA;   Serial.println(&quot;east&quot;);&#xA;else if (s &amp;gt; n)&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that last &lt;code&gt;else&lt;/code&gt; typically is reached only rarely, because the only condition to get to it is &lt;code&gt;e&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt; being equal.  Due to sensor noise and signal processing noise, the chance of &lt;code&gt;e&lt;/code&gt; and &lt;code&gt;w&lt;/code&gt; being equal is probably at most a few percent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your north/south test sequence is supposed to be independent of your east/west test sequence, leave out the second &lt;code&gt;if&lt;/code&gt; and second &lt;code&gt;else&lt;/code&gt; .  That is, instead say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (e &amp;gt; w)&#xA;   Serial.println(&quot;west&quot;);&#xA;else&#xA;   Serial.println(&quot;east&quot;);&#xA;if (s &amp;gt; n)&#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-02-15T02:28:56.107" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20683" PostTypeId="2" ParentId="20660" CreationDate="2016-02-15T02:36:48.320" Score="2" Body="&lt;p&gt;I like to use types from &lt;code&gt;stdint.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While they do have minor drawbacks, the benefit they provide is you know exactly the size your are handling, even when compiling on other architectures.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;&#xA;&#xA;uint8_t  my_byte = 0xf0;&#xA;int16_t  trig_pin = 2;&#xA;int16_t  echo_pin = 4;&#xA;uint32_t duration, cm , blah;&#xA;uint64_t big_int;&#xA;&#xA;// etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But obviously you don't want to be moving around a bunch of int32_t when your data only needs int16_t.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-15T02:36:48.320" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20685" PostTypeId="2" ParentId="14487" CreationDate="2016-02-15T02:56:35.547" Score="1" Body="&lt;p&gt;The issue with the ESP8266 is that it is multitasking, and only 80% of the CPU time is available to developers. This manifests as an outage of 100-200us every 500ms or so, which rather complicates all sorts of software serial interfaces, such as I2C, SPI and UART. As a bus master the ESP8266 hides these issues as it is responsible for the bus clock, but as a bus slave it needs to halt data transfer for the duration of these random events.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A typical solution for this inter-CPU issue is to provide an external RAM cache to act as a mailbox, where each CPU will periodically check to see if any actions are outstanding and leave any requested data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone explored this option for the Arduino to ESP8266 interface?&lt;/p&gt;&#xA;" OwnerUserId="18362" LastEditorUserId="6936" LastEditDate="2016-02-17T06:40:16.177" LastActivityDate="2016-02-17T06:40:16.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20686" PostTypeId="2" ParentId="20671" CreationDate="2016-02-15T03:22:52.107" Score="0" Body="&lt;p&gt;Detecting colour with RGB illumination and an LDR is not particularly accurate in my experience.  The idea is you illuminate the card (or whatever) with red light, take an LDR reading, then with green then blue.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives you a set of 3 light levels for the different colour components of the object.  Combining them together gives you an RGB signature for the object.  Ideally, on say a red card, the value from the LDR under red illumination is much stronger, and blue &amp;amp; green much weaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RGB LED + LDR colour detection &lt;em&gt;does work&lt;/em&gt;, but it's not accurate, and it helps to block out ambient lighting.  Maybe if you put a lot of time into calibration, it would for you.  I had a classroom of 14 kids, each made-up one of these circuits, yet only a couple had any moderate success, if at all.&#xA;That said, we were using very cheap RGB LEDs and similar quality LDRs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a bunch of stuff you can do to help the accuracy, like subtract readings with only ambient illumination, take multiple readings, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you would save yourself a lot of time and frustration buy using a purpose-made colour sensor.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like the ADAFruit Colour Sensor -  &lt;a href=&quot;https://www.adafruit.com/products/1334&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1334&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-15T03:37:02.840" LastActivityDate="2016-02-15T03:37:02.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20687" PostTypeId="2" ParentId="20671" CreationDate="2016-02-15T03:32:15.447" Score="1" Body="&lt;p&gt;You can get an RFID reader for $7 from eBay:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iRHQx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iRHQx.jpg&quot; alt=&quot;RFID reader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cards are around 30 cents:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HF3h5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HF3h5.jpg&quot; alt=&quot;RFID card&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have example code for an &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12869&quot; rel=&quot;nofollow noreferrer&quot;&gt;entry control system&lt;/a&gt; which uses that reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cards tend to activate at around 3 cm to 5 cm, so that sounds about right. Of course they aren't particularly directional, but if you are driving in a certain direction and it detects a card it is probably in front of you (however possibly off to one side). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could combine card detection with simple range finding using an ultrasonic detector.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-15T03:32:15.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20688" PostTypeId="2" ParentId="20678" CreationDate="2016-02-15T03:52:04.890" Score="1" Body="&lt;pre&gt;&lt;code&gt;char ArrayBuffer[][4] = {};         // holds four characters, must be &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;declared as global to loop() &lt;/p&gt;&#xA;&#xA;&lt;p&gt;in &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA;byte Index = 0;                    // initialize array index &#xA;if(Serial.available())             // have data in Serial buffer &#xA;{&#xA;byte Count = Serial.readBytes(ArrayBuffer[Index],4); // read       //4             //characters     into array buffer , returns actual number //of        characters //read and times out if less than 4 characters are //currently in Serial buffer &#xA; Serial.println(ArrayBuffer[Index]); // print buffer to monitor &#xA;}while(++Index != 4);              // read 4 by 4 characters from incoming stream &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...&#xA;continue with loop - process ArrayBuffer as required &#xA;} &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is one way to get the incoming stream from Serial buffer into for individual buffers, however, it is better, less chance of misdirecting the data into wrong buffer (index)  to read the entire buffer at once instead of using he readBytes four times. &#xA;Just my opinion, your mileage will vary. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS what is the trick to format the code and text correctly ? &#xA;This is a mess. &#xA;I cannot get the code block to indent, I can get only the first ( four spaces line. &lt;/p&gt;&#xA;" OwnerUserId="7201" LastEditorUserId="7201" LastEditDate="2016-02-15T03:57:44.163" LastActivityDate="2016-02-15T03:57:44.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20689" PostTypeId="1" AcceptedAnswerId="20690" CreationDate="2016-02-15T04:01:52.523" Score="1" ViewCount="184" Body="&lt;p&gt;I am trying to hide libraries behind another, for simplicity. But I can't deal with the objects required by the libraries. Basically I want to use the objects both in my .cpp and .ino file, but I am getting errors about double definition, or not declared in this scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;test.ino&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;lib.h&quot;&#xA;#include &quot;obj.cpp&quot;&#xA;&#xA;void setup() {&#xA;  mesh.setNodeID(40);&#xA;  mesh.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  mesh.update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;lib.cpp&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;lib.h&quot;&#xA;&#xA;#include &quot;obj.cpp&quot;&#xA;&#xA;int message = 1;&#xA;&#xA;void send() {&#xA;&#xA;  if (!mesh.write(&amp;amp;message, 'C', sizeof(message))) {&#xA;&#xA;    // If a write fails, check connectivity to the mesh network&#xA;    if ( ! mesh.checkConnection() ) {&#xA;      //refresh the network address&#xA;      Serial.println(&quot;Renewing Address&quot;);&#xA;      mesh.renewAddress();&#xA;    } else {&#xA;      Serial.println(&quot;Sending failed, Test OK&quot;);&#xA;    }&#xA;  } else {&#xA;    Serial.print(&quot;Sent OK&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;lib.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef lib_h&#xA;#define lib_h&#xA;&#xA;void send();&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;obj.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;RF24.h&quot;&#xA;#include &quot;RF24Network.h&quot;&#xA;#include &quot;RF24Mesh.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;RF24 radio(7, 8);&#xA;RF24Network network(radio);&#xA;RF24Mesh mesh(radio, network);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7123" LastActivityDate="2016-02-15T04:53:11.840" Title="Defining object" Tags="|c++|library|compile|class|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20690" PostTypeId="2" ParentId="20689" CreationDate="2016-02-15T04:14:40.073" Score="1" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;obj.cpp&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't include .cpp files. That gets them compiled twice (or more) and then you get duplicate definitions. Include .h files only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are calling obj.cpp should probably be obj.h, however I haven't actually tried to compile it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;it says that I have multiple definitions of the three objects&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried compiling but I don't have the RF24 library. Anyway, this is wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;obj.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;RF24.h&quot;&#xA;#include &quot;RF24Network.h&quot;&#xA;#include &quot;RF24Mesh.h&quot;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;RF24 radio(7, 8);&#xA;RF24Network network(radio);&#xA;RF24Mesh mesh(radio, network);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can't &lt;em&gt;define&lt;/em&gt; things there (like &lt;code&gt;radio&lt;/code&gt;) which get included in multiple files. &lt;code&gt;obj.h&lt;/code&gt; or &lt;code&gt;obj.cpp&lt;/code&gt; it will be the same thing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These lines need to be in &lt;strong&gt;one&lt;/strong&gt; .cpp file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;RF24 radio(7, 8);&#xA;RF24Network network(radio);&#xA;RF24Mesh mesh(radio, network);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus you cannot include that file in another file. However you can refer to them by making them &lt;code&gt;extern&lt;/code&gt; in a header file, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;extern RF24 radio;&#xA;extern RF24Network network;&#xA;extern RF24Mesh mesh;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-15T04:53:11.840" LastActivityDate="2016-02-15T04:53:11.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20691" PostTypeId="1" CreationDate="2016-02-15T04:44:21.780" Score="1" ViewCount="1639" Body="&lt;p&gt;Im using an HC-05 Bluetooth module connected to my Arduino MEGA. The Arduino has an SD card with some data files stored (sensor readings). After the sensor readings are done, the Arduino then connects to Android phone via Bluetooth and transfers the file data.&#xA;This is working fine. Arduino sends the data to HC-05 over Serial port, which transfers it over the air to my Android phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But its kinda slow and I hence had a question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;QUESTION: Does the HC-05 buffer the data coming from the Arduino Serial and then send efficiently filled packets over the air. I would like to make sure that the HC-05 isn't inefficiently sending just a single byte or so per Bluetooth packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6930" LastActivityDate="2019-06-17T06:31:31.533" Title="Arduino Bluetooth data (large data files) transfer efficiency using HC05 module" Tags="|arduino-mega|bluetooth|hc-05|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20692" PostTypeId="2" ParentId="4076" CreationDate="2016-02-15T04:48:30.367" Score="6" Body="&lt;p&gt;&lt;code&gt;myservo.detach();&lt;/code&gt; is what you are looking for. Moving it to a location than detaching. This is good when you want to use it to control a servo and not have it continue to take power like when using a battery.  Here is a example. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo;  // create servo object to control a servo&#xA;&#xA;void setup() {&#xA;  myservo.attach(9);&#xA;  // attaches the servo on pin 9 to the servo object&#xA;}&#xA;&#xA;void loop() {&#xA;  myservo.attach(9);&#xA;  // attaches the servo on pin 9 to the servo object&#xA;  delay(15);&#xA;  myservo.write(1);&#xA;  // sets the servo position according to the scaled value&#xA;  delay(1000);&#xA;  // waits for it to get to the position&#xA;  myservo.detach();&#xA;  delay(1000);&#xA;  myservo.attach(9);&#xA;  // attaches the servo on pin 9 to the servo object&#xA;  delay(15);&#xA;  myservo.write(179);&#xA;  // sets the servo position according to the scaled value&#xA;  delay(1000); // waits for it to get to the position&#xA;  myservo.detach();&#xA;  delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18365" LastEditorUserId="4628" LastEditDate="2017-10-05T04:04:04.830" LastActivityDate="2017-10-05T04:04:04.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20693" PostTypeId="1" AcceptedAnswerId="20701" CreationDate="2016-02-15T06:06:55.263" Score="1" ViewCount="1571" Body="&lt;p&gt;As a follow up to my earlier post: &lt;a href=&quot;https://arduino.stackexchange.com/questions/20396/simultaneously-reading-data-from-multiple-serial-ports/20642#20642&quot;&gt;Simultaneously reading data from multiple serial ports&lt;/a&gt;, I am stuck trying to develop a python sketch that can read the incoming serial data from the com port on my Arduino and unpack them from the buffer into two separate cvs files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the csv files would contain the data from the first sensor, while the other would contain the data from the second sensor. I have been able to develop the sketch to a point where on receiving the first header byte the first sensor data is unpacked. I am finding it hard to adjust the sketch to allow for the second byte header to be called to unpack the second sensor data from the data packet. Below is my abbreviated sketch thus far. Thanks all.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;def run(self):&#xA;    #Creating a csv file to read data from the first sensor&#xA;    self.click = open(&quot;ball_Data.csv&quot;, &quot;wb&quot;)&#xA;    #Creating a csv file to read data from the second sensor&#xA;    self.flick = open(&quot;rugby_Data.csv&quot;, &quot;wb&quot;)&#xA;    #creating the serial port object&#xA;    self.push = serial.Serial('COM6', 9600)&#xA;    while True:&#xA;        #If the incoming byte is equivalent to '$'&#xA;        if node == b'$':&#xA;            # the byte object is equivalent to the available bytes&#xA;            node = self.push.read()&#xA;            #an array to hold the sensor data&#xA;            sensor_array = []&#xA;            i = 0&#xA;            #This while loop initiates a count from 0 to 9&#xA;            #through the sensor array&#xA;            while i &amp;lt; 10:&#xA;                #The available byte present&#xA;                malcolm = self.push.read()&#xA;                #The next byte&#xA;                turnbull = self.push.read()&#xA;                #The incoming uint_16 data is unpacked into the variable lingo&#xA;                lingo= (struct.unpack('b', turnbull)[0] &amp;lt;&amp;lt; 8) | struct.unpack('B',malcolm)[0]&#xA;                #The variable lingo is then appended to the sensor array&#xA;                sensor_array.append(lingo)&#xA;                #If the length of the sensor array is equivalent to 9&#xA;                #write the data through each count into the sensor array&#xA;                if len(sensor_array) == 9:&#xA;                    self.click.write(str(sensor_array[0] ..+ str(sensor_array[9]))&#xA;                    #My idea is that this else statement was supposed to trigger&#xA;                    #the next header for the second sensor which would be an '#'&#xA;                    #sign before unpacking the data&#xA;                    else:&#xA;                        oldde = self.push.read()&#xA;                        sensor_array = []&#xA;                        i = 10&#xA;                        while i &amp;lt; 20:&#xA;                            #The available byte present&#xA;                            malcolm = self.push.read()&#xA;                            #The next byte&#xA;                            turnbull = self.push.read()&#xA;                            lingo= (struct.unpack('b', turnbull)[10]&amp;lt;&amp;lt;8)|struct.unpack('B',malcolm)[10]&#xA;                            sensor_array.append(lingo)&#xA;                            if len(sensor_array) &amp;gt; 19:&#xA;                                self.flick.write(str(sensor_array[10]..+ str(sensor_array[19]))&#xA;&#xA;                                The Packet data structure for the first and second sensor is:&#xA;                                    Packet1 from sensor 1:&#xA;                                        data_array[0] = headerbyte('#')&#xA;                                        data_array[1] = acceleration_xAxis&#xA;                                        data_array[2] = acceleration_yAxis&#xA;                                        data_array[3] = acceleration_zAxis&#xA;                                        data_array[4] = temperature&#xA;                                        data_array[5] = gyro_xAxis&#xA;                                        data_array[6] = gyro_yAxis&#xA;                                        data_array[7] = gyroz_xAxis&#xA;                                        data_array[8] = checksum&#xA;                                        Packet2 from sensor 2:&#xA;                                            data_array[9] = headerbyte('$')&#xA;                                            .&#xA;                                            .&#xA;                                            .&#xA;                                            data_array[17] = checksum&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14350" LastEditorUserId="37523" LastEditDate="2019-08-27T21:18:23.213" LastActivityDate="2019-08-27T21:18:23.213" Title="Unpacking Arduino binary data on a python sketch" Tags="|serial|arduino-mega|python|datalogging|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 4.0" />
  <row Id="20695" PostTypeId="1" CreationDate="2016-02-15T08:11:50.710" Score="2" ViewCount="263" Body="&lt;p&gt;I'm already done copying/pasting the libraries that I know is needed to run the program, but I wonder why I always get this error every time I tried to run the code. What do you think would be the possible reason why I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:64:14: warning:       &#xA;  #warning Using current Arduino IDE with Wire library is functionally  &#xA;  limiting.   [-Wcpp]&#xA;&#xA;  #warning Using current Arduino IDE with Wire library is functionally limiting.&#xA;&#xA;          ^&#xA;&#xA;  C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:65:14: warning: &#xA;  #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation   &#xA;  is recommended. [-Wcpp]&#xA;&#xA;  #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation &#xA;  is recommended.&#xA;&#xA;          ^&#xA;&#xA; C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:66:14: warning:&#xA; #warning This I2Cdev implementation does not support: [-Wcpp]&#xA;&#xA; #warning This I2Cdev implementation does not support:&#xA;&#xA;          ^&#xA;&#xA; C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:67:14: warning: &#xA; #warning - Timeout detection (some Wire requests block forever) [-Wcpp]&#xA;&#xA; #warning - Timeout detection (some Wire requests block forever)&#xA;&#xA;          ^&#xA;&#xA; In file included from C:\Program Files     &#xA; (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:27:0:&#xA;&#xA; C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member  &#xA; function 'bool RTIMUHal::HALRead(unsigned char, unsigned char, unsigned &#xA; char, unsigned char*, const char*)':&#xA;&#xA; C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37: error:   &#xA;'class HardwareSerial' has no member named 'printf'&#xA;&#xA; #define HAL_ERROR1(m, x)     Serial.printf(m, x);&#xA;&#xA;                                 ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:73:13: note:  &#xA;in expansion of macro 'HAL_ERROR1'&#xA;&#xA;         HAL_ERROR1(&quot;I2C read failed - %s\n&quot;, errorMsg);&#xA;&#xA;         ^&#xA;&#xA;  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member   &#xA;  function 'bool RTIMUHal::HALWrite(unsigned char, unsigned char, unsigned &#xA;  char, const unsigned char*, const char*)':&#xA;&#xA;  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37: error:  &#xA;  'class HardwareSerial' has no member named 'printf'&#xA;&#xA;  #define HAL_ERROR1(m, x)     Serial.printf(m, x);&#xA;&#xA;                                 ^&#xA;&#xA;  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:96:13: &#xA;  note: in expansion of macro 'HAL_ERROR1'&#xA;&#xA;         HAL_ERROR1(&quot;I2C write failed - %s\n&quot;, errorMsg);&#xA;&#xA;         ^&#xA;&#xA;   C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member    &#xA;   function 'bool RTIMUHal::HALWrite(unsigned char, unsigned char, unsigned &#xA;   char, const char*)':&#xA;&#xA;   C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37: &#xA;   error: 'class HardwareSerial' has no member named 'printf'&#xA;&#xA;   #define HAL_ERROR1(m, x)     Serial.printf(m, x);&#xA;&#xA;                                 ^&#xA;&#xA;  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:119:13: &#xA;  note: in expansion of macro 'HAL_ERROR1'&#xA;&#xA;         HAL_ERROR1(&quot;I2C write failed - %s\n&quot;, errorMsg);&#xA;&#xA;         ^&#xA;&#xA;  exit status 1&#xA;  Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16602" LastActivityDate="2016-02-15T08:11:50.710" Title="Is it possible to run the Teensy to the Arduino?" Tags="|arduino-mega|teensy|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20697" PostTypeId="1" CreationDate="2016-02-15T09:18:25.453" Score="0" ViewCount="2763" Body="&lt;p&gt;What is the maximum of bits that an Arduino can read on the digital input, which model in the Arduino range can read the most bits?&lt;/p&gt;&#xA;" OwnerUserId="18370" LastActivityDate="2016-02-15T22:51:00.470" Title="How many bits can an Arduino uno read?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20698" PostTypeId="2" ParentId="20697" CreationDate="2016-02-15T09:34:50.340" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What is the maximum of bits that an Arduino can read on the digital input, which model in the Arduino range can read the most bits?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A digital input is by nature binary (i.e. a single bit). The answer to your question is therefore one bit per digital input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The total number of digital inputs depends on the board. It ranges from Arduino Micro (which has fewest less with than 10) to Arduino Mega which has the most with more than 60). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible interpretation of your question is the resolution of an analog pin (ADC). The AVR has max 10 bit resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-15T09:34:50.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20700" PostTypeId="1" AcceptedAnswerId="20760" CreationDate="2016-02-15T11:13:19.493" Score="1" ViewCount="1921" Body="&lt;p&gt;I'm currently working on a project where I need to use PID to get the correct speed for a motor when it is angled a certain amount. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I'm only getting 0.00 and 255.00 as the speed. Nothing in between. The code is supposed to activate when the angle value is more than 1300 and less than -1300. The &lt;code&gt;ax&lt;/code&gt; variable is from an MPU6050 sensor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int16_t ax, ay, az;&#xA;&#xA;double Setpoint, Input, Output;&#xA;//Specify the links and initial tuning parameters&#xA;double Kp=2, Ki=5, Kd=1;&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint, Kp,Ki,Kd, DIRECT);&#xA;&#xA;void setup() {&#xA;  Input = analogRead(ax);&#xA;  Setpoint = 100;&#xA;  //turn the PID on&#xA;  myPID.SetMode(AUTOMATIC);&#xA;}&#xA;&#xA;void loop() {&#xA;  accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;  int a=ax+10900;&#xA;  //Here I set the used variable to around 0. ax is actually around -10900&#xA;  //This is always true, this won't be in the final code. This is just making it work.&#xA;  if(1) {&#xA;    int val;&#xA;    val = map(a, -1300, 1300, 0, 1023);&#xA;    Input = val;&#xA;    myPID.Compute();&#xA;    Serial.println(Output);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="6936" LastEditDate="2016-02-17T07:44:49.483" LastActivityDate="2016-02-18T12:47:44.900" Title="PID not working correctly" Tags="|arduino-uno|motor|mpu6050|pid|" AnswerCount="2" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20701" PostTypeId="2" ParentId="20693" CreationDate="2016-02-15T11:53:03.193" Score="4" Body="&lt;p&gt;I'm somewhat confused by the flow of your program, so instead I will tell you how I would handle the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a single-byte header, then 7 bytes of data, followed by a single byte checksum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PySerial's read is (I believe) blocking by default, so it's simple to read the next serial character - unlike an Arduino.  It also has a &quot;multi-byte&quot; read version where it can read a pre-set number of bytes from the stream for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my methodology would be:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read a byte.  Is it a '#' or a '$'?&lt;/li&gt;&#xA;&lt;li&gt;If it is, remember which stream you are dealing with, then:&lt;/li&gt;&#xA;&lt;li&gt;Read 7 bytes with &lt;code&gt;this.push.read(7)&lt;/code&gt; into a byte array (or a string in python &amp;lt; 2.6)&lt;/li&gt;&#xA;&lt;li&gt;Read one byte for the checksum. If the checksum is correct (whatever calculation you use for that) then unpack the data in the array.&lt;/li&gt;&#xA;&lt;li&gt;Write the data to the correct file depending on the stream you remembered in step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That way you're not duplicating code for each sensor stream, you are just saying &quot;this packet is stream 2&quot; and using that remembered fact once you have received the packet and verified that it's correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better protocol arrangement, though, which is more reliable, involves both a start byte and an end byte, and your whole packet is wrapped in that pair of bytes.  You then have a &quot;sliding window&quot; arrangement whereby the incoming data bytes scroll past a window of a fixed width, and when the first and last characters in that window match your start and end bytes you then extract the middle section and do what you need to do with it.  That way if you have a $ or a # that is midway through a stream of data it won't trigger reception since the end byte doesn't match. It makes the whole synchronisation of the data more reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you have the current data packet that looks like &lt;code&gt;$ho9*$fup&lt;/code&gt; and you miss the first bit of the data for whatever reason (arduino started transmitting before you were ready to receive, for instance) it might trigger reception on the second &lt;code&gt;$&lt;/code&gt; which would give you incorrect values.  So instead if you have the start character as &lt;code&gt;$&lt;/code&gt; and the end character as &lt;code&gt;#&lt;/code&gt; and include a stream number, so your packet looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$1ho9*$fup#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when you scroll that past the window it would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; $         #&#xA; v         v&#xA;[..........$]&#xA;[.........$1]&#xA;[........$1h]&#xA;[.......$1ho]&#xA;[......$1ho9]&#xA;[.....$1ho9*]&#xA;[....$1ho9*$]&#xA;[...$1ho9*$f]&#xA;[..$1ho9*$fu]&#xA;[.$1ho9*$fup]&#xA;[$1ho9*$fup#]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the first and last characters match, so you receive the content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to miss the first $ the second $ wouldn't match - say the extended stream looks like: &lt;code&gt;$1ho9*$fup#$2hdiw83bf#&lt;/code&gt; and you missed $1, the window would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; $         #&#xA; v         v&#xA;[..........o]&#xA;[.........o9]&#xA;[........o9*]&#xA;[.......o9*$]&#xA;[......o9*$f]&#xA;[.....o9*$fu]&#xA;[....o9*$fup]&#xA;[...o9*$fup#]&#xA;[..o9*$fup#$]&#xA;[.o9*$fup#$2]&#xA;[o9*$fup#$2h]&#xA;[9*$fup#$2hd]&#xA;[*$fup#$2hdi]&#xA;[$fup#$2hdiw] &amp;lt;= Doesn't match even though it starts with $&#xA;[fup#$2hdiw8]&#xA;[up#$2hdiw83]&#xA;[p#$2hdiw83b]&#xA;[#$2hdiw83bf]&#xA;[$2hdiw83bf#] &amp;lt;= Matches - starts with $ and ends with #&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the synchronising of your packet is then much more reliable. It would normally have incorrectly triggered on the first $ it saw.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is always a chance that there may be a $ and a # in just the right positions within successive packets to fool the system, but the chances of that are somewhat slim.  You can add extra protection against that by &quot;escaping&quot; the start and stop bytes if they appear within your stream. There's many possible ways of handling that if you really need it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-15T11:53:03.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20703" PostTypeId="2" ParentId="20700" CreationDate="2016-02-15T12:42:27.500" Score="2" Body="&lt;p&gt;Please respect others by presenting code that is readable. By doing that you may also find obvious errors in your code. Let me clean up the loop() and you will see what I mean.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    int a = ax + 10900;&#xA;    if (1) {&#xA;      int val;&#xA;      val = map(ax, -1300, 1300, 0, 1023);&#xA;      Input = val;&#xA;      myPID.Compute();&#xA;      Serial.println(Output);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what is &quot;int a = ax + 10900&quot;? &quot;ax&quot; is not defined but the other use of it is as an analog pin number &quot;Input = analogRead(ax)&quot;. And &quot;a&quot; is not used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a condition that is always true &quot;if (1)&quot; and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-15T12:42:27.500" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="20705" PostTypeId="2" ParentId="20660" CreationDate="2016-02-15T14:28:11.533" Score="3" Body="&lt;p&gt;It's the same reasoning as in C: the size of the &lt;code&gt;int&lt;/code&gt; type is expected to be &lt;em&gt;the natural word size that your system handles most efficiently&lt;/em&gt;. It must also be at least 16 bits wide, no smaller than a &lt;code&gt;short&lt;/code&gt;, and no larger than a &lt;code&gt;long&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So an &lt;code&gt;int&lt;/code&gt; may be 16-, 32-, or 64-bits, based on the whatever your system handles best, and so is most likely to be 16 bits wide on an 8- or 16-bit CPU, 32 on a 32-bit CPU etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use &lt;code&gt;int&lt;/code&gt; when I want the best performance, whilst taking care to guard when I need more range than offered by 16 bits. These days, you tend to know when you are writing application code for 16-bit systems, although that's not so true for &quot;library&quot; code where portability may be of greater concern.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example, assuming the author had chosen their types carefully, the &lt;code&gt;int&lt;/code&gt; variables probably require a small range and could afford to be word-size, leading to potentially shorter or faster code (or both). The &lt;code&gt;long&lt;/code&gt; ones presumably required more than 16-bit range (they are guaranteed to be at least 32 bits wide). On the processor you'd selected as a compilation target, it looks like &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;long&lt;/code&gt; were both implemented as 32-bit; this would be different (or &lt;em&gt;should&lt;/em&gt; be) if you selected a 16-bit target CPU. &lt;/p&gt;&#xA;" OwnerUserId="18380" LastEditorUserId="18380" LastEditDate="2016-02-15T18:09:31.477" LastActivityDate="2016-02-15T18:09:31.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20706" PostTypeId="2" ParentId="20678" CreationDate="2016-02-15T15:22:28.343" Score="1" Body="&lt;pre&gt;&lt;code&gt;while (Serial.available() &amp;lt; 16);   // wait for 16 chars to come          easiest way to do this&#xA;for (int i = 0; i &amp;lt; 4; i++){      // for each number&#xA;    for (int j = 0; j &amp;lt; 4; j++){    // for each digit in the number&#xA;        nums[i] *= 10;   &#xA;        nums[i] += Serial.read() - '0';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where did my last post - comment on this code went?&#xA;It was suppose to wait for &quot;peers&quot; approval, per note I got after I posted it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is not the best way to use &quot;available()&quot;, beside what will happen if 16 characters never arrive? &lt;/p&gt;&#xA;" OwnerUserId="7201" LastActivityDate="2016-02-15T15:22:28.343" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20707" PostTypeId="1" AcceptedAnswerId="20743" CreationDate="2016-02-15T16:01:33.950" Score="1" ViewCount="841" Body="&lt;p&gt;I currently have an Arduino Mega project that uses a relay to switch some high voltage loads. Currently, I use a scheduler library so that every 250ms I check if certain conditions are met and if so I turn off or on the relay. The relay is active when pulled down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to figure out how to transition this project to using a shift register. If the pin needs to be pulled low to be turned on and I want to keep it on, how do I supply a steady &quot;low&quot; signal using a shift register if the register is clocked to only latch every 8 clock cycles (not to mention I only run this code every 250ms). Even if every bit that gets sent by the shift register is low, do I need to no longer use the scheduling library so that every time through the Arduino loop I am sending the low signal so that the low signal can remain constant? With the standard Arduino pin once I set it to low it stays low until I switch it to high. But with a shift register can I keep it low &quot;until I switch it high?&quot;&lt;/p&gt;&#xA;" OwnerUserId="18363" LastActivityDate="2016-02-17T17:25:52.827" Title="Maintaining pull down on a relay with a shift register" Tags="|relay|shift-register|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20708" PostTypeId="1" AcceptedAnswerId="20709" CreationDate="2016-02-15T16:21:58.307" Score="0" ViewCount="911" Body="&lt;p&gt;Hello I have just got my Arduino to read text from a text file and it is running perfectly. I was interested in being able to load a sketch into the Arduino and having it execute it, from and SD card. The Arduino wouldn't be connected to my laptop at all. I researched it and it is possible, with a different boot loader. Which is a bit annoying because I don't want to change the boot loader on my Arduino. I could put it on a standalone atmega chip but lets pretend I don't have those. So I was thinking if you had pre-compiled Arduino code. Which is in hex format and ready to be put on the board, would it be able to be loaded from the SD card? If so how would I go about doing this?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-02-15T16:26:02.790" Title="Arduino compiled sketch on sd card" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20709" PostTypeId="2" ParentId="20708" CreationDate="2016-02-15T16:26:02.790" Score="0" Body="&lt;p&gt;Yes it is possible:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;With a different bootloader&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need something which will erase the old sketch from the chip, read the data from the SD card, and write that into the flash of the chip. The only thing that can do that is the bootloader or some external device (another ATMega328p chip which we have to pretend you don't have).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the way the architecture works you can only execute code out of the flash, so you need to program your sketch into the flash somehow. And that is the role of the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-15T16:26:02.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20711" PostTypeId="1" CreationDate="2016-02-15T18:16:24.643" Score="1" ViewCount="4647" Body="&lt;p&gt;&lt;strong&gt;Is it possible to change pin operation from output to input within the Arduino loop (event-driven)?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to change the operation of a couple of Arduino pins from input to output during execution of the Arduino loop in an event-driven way. Is this possible please?&lt;/p&gt;&#xA;" OwnerUserId="10231" LastEditorUserId="6936" LastEditDate="2016-02-18T12:13:52.487" LastActivityDate="2020-09-24T23:25:20.907" Title="Is it possible to change pin operation from output to input within the Arduino loop (event-driven)?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20712" PostTypeId="1" AcceptedAnswerId="20718" CreationDate="2016-02-15T18:43:58.490" Score="0" ViewCount="118" Body="&lt;p&gt;Hello I have a String that contains the following: &quot;println('hello world')&quot;.&#xA;I want to be able to remove everything from the String except for the text insie the brackets. Bear in mind that this text will change multiple times as the programme runs. How can I remove everything except for what is in the brackets from the string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    String line1 = &quot;println('hello world')&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me thx.&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-02-15T20:39:40.120" Title="Arduino disecting a string" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20713" PostTypeId="1" CreationDate="2016-02-15T18:58:41.640" Score="1" ViewCount="1570" Body="&lt;p&gt;I'm trying to control a pellet stove auger motor in such a way that I can use a toggle switch to do High/Low (H/L) - so the way that I have it now is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup() {&#xA;   // initialize digital pin 13 as an output.&#xA;   pinMode(13, OUTPUT);&#xA;   pinMode(12, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  digitalWrite(12, HIGH);&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(2850);              // wait for a second&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(11250);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is just LED on/off but it also controls another relay that controls the blower motor - what I'm trying to set up is a H setting that would be the 2850 delay-ON - and then have say: pin 11 have a delay-OFF of 7000, and have pin 13 still resetting to the delay-ON of 2850.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I mean is: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;loop A: pin12 on -delay 2850 pin12 off -delay 11250&lt;/li&gt;&#xA;&lt;li&gt;loop B: pin13 on -delay 2850 pin13 off -delay 7000&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I saw and tried the code for 'multi-blink' - as the one I use is pretty much modified 'blink'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any assistance would be awesome - I run the one I show above now, on my pellet stove and it was recently -31.4 and worked like a charm, but I'd like to be able to have a high/low option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I also have a coffee roaster control project as well... help on that one is always appreciated as well.&lt;/p&gt;&#xA;" OwnerUserId="18383" LastEditorUserId="6936" LastEditDate="2016-02-17T06:33:34.543" LastActivityDate="2018-05-03T18:24:39.653" Title="Trying to run two simultaneous loops that do the same task with different delay cycles" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20714" PostTypeId="2" ParentId="20711" CreationDate="2016-02-15T19:09:49.813" Score="6" Body="&lt;p&gt;Yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just call &lt;code&gt;pinMode([pin], [mode])&lt;/code&gt; whenever you want to change from input to output or output to input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to decide when to do that is entirely up to you. You can do it any time you choose using any stimulus you like.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-15T19:09:49.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20716" PostTypeId="1" AcceptedAnswerId="20830" CreationDate="2016-02-15T19:26:18.687" Score="1" ViewCount="2389" Body="&lt;p&gt;I have burned out a few Pro Micro clones now. Initially I ran them using a 12VDC external raw power supply but two Pro Micro clones burned out pretty quickly this way. Another thread suggested that the Pro Micro clones use regulators that are not very robust. Since then, I've been using just USB power for my 5V/16MHz Pro Micro clones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third clone has been working fine on USB power only. I estimate that I uploaded a sketch I was working on about a dozen times. Suddenly the RxLED stayed lit and I can't upload to it anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug it in, Windows assigns a COM port successfully. The Arduino IDE sees the port and I can select it. This tells me the Pro Micro is not entirely dead. When I enable verbose mode for uploading in the Arduino IDE, here's what I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 3,914 bytes (13%) of program storage space. Maximum is 28,672 bytes.&#xA;Global variables use 148 bytes (5%) of dynamic memory, leaving 2,412 bytes for local variables. Maximum is 2,560 bytes.&#xA;Forcing reset using 1200bps open/close on port COM3&#xA;PORTS {COM3, } / {COM3, } =&amp;gt; {}&#xA;[repeating 19 more times]&#xA;Uploading using selected port: COM3&#xA;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\Bartman\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.2/avrdude.conf -v -patmega32u4 -cavr109 -PCOM3 -b57600 -D -Uflash:w:C:\Users\Bartman\AppData\Local\Temp\buildb15cf522f4023b15f86cbd1c900761d6.tmp/sketch_feb15a.ino.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Users\Bartman\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.2/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM3&#xA;         Using Programmer              : avr109&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega32U4&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PA0&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00&#xA;           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : butterfly&#xA;         Description     : Atmel AppNote AVR109 Boot Loader&#xA;&#xA;Connecting to programmer: .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and after some time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: butterfly_recv(): programmer is not responding&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my working Pro Micro clone, I get the following after instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Found programmer: Id = &quot;CATERIN&quot;; type = S&#xA;    Software Version = 1.0; No Hardware Version given.&#xA;Programmer supports auto addr increment.&#xA;Programmer supports buffered memory access with buffersize=128 bytes.&#xA;&#xA;Programmer supports the following devices:&#xA;    Device code: 0x44&#xA;&#xA;avrdude: devcode selected: 0x44&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% -0.00s&#xA;&#xA;avrdude: Device signature = 0x1e9587&#xA;avrdude: reading input file &quot;C:\Users\Bartman\AppData\Local\Temp\buildb15cf522f4023b15f86cbd1c900761d6.tmp/sketch_feb15a.ino.hex&quot;&#xA;avrdude: writing flash (3914 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.30s&#xA;&#xA;avrdude: 3914 bytes of flash written&#xA;avrdude: verifying flash memory against C:\Users\Bartman\AppData\Local\Temp\buildb15cf522f4023b15f86cbd1c900761d6.tmp/sketch_feb15a.ino.hex:&#xA;avrdude: load data flash data from input file C:\Users\Bartman\AppData\Local\Temp\buildb15cf522f4023b15f86cbd1c900761d6.tmp/sketch_feb15a.ino.hex:&#xA;avrdude: input file C:\Users\Bartman\AppData\Local\Temp\buildb15cf522f4023b15f86cbd1c900761d6.tmp/sketch_feb15a.ino.hex contains 3914 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 0.04s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 3914 bytes of flash verified&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the now non-functional one, I tried using a jumper from RST to GND, tapping this twice quickly in succession and uploading from the IDE in an attempt to recover the Pro Micro but this doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think it's a bootloader problem since the Pro Micro does get a COM port assigned to it but never-the-less, I tried burning a new bootloader from my working Pro Micro. Here's my Pro Micro to Pro Micro wiring:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/d6G4t.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d6G4t.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the IDE, I've selected:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Board: SparkFun Pro Micro&lt;br&gt;&#xA;  Processor: ATmega32U4 (5V, 16 MHz)&lt;br&gt;&#xA;  Port: [current COM port of working Pro Micro]&lt;br&gt;&#xA;  Programmer: Arduino as ISP&lt;br&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But when I select &lt;code&gt;Tools-&amp;gt;Burn Bootloader&lt;/code&gt;, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 10), Board: &quot;SparkFun Pro Micro, ATmega32U4 (5V, 16 MHz)&quot;&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\Bart_S\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.3/avrdude.conf -v -patmega32u4 -cstk500v1 -PCOM6 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xCB:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Users\Bart_S\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.3/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM6&#xA;         Using Programmer              : stk500v1&#xA;         Overriding Baud Rate          : 19200&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it permanently damaged? What are the next steps to troubleshoot this Pro Micro clone?&lt;/p&gt;&#xA;" OwnerUserId="17096" LastEditorUserId="17096" LastEditDate="2016-02-17T21:00:55.117" LastActivityDate="2016-02-18T14:53:37.240" Title="Pro Micro clone worked fine, now RxLED stays on and can't program it" Tags="|arduino-pro-micro|clones|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="20717" PostTypeId="2" ParentId="20713" CreationDate="2016-02-15T19:43:11.180" Score="2" Body="&lt;p&gt;The Arduino &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Simple Timer library&lt;/a&gt; (and other similar timer libraries) are made for exactly this kind of application. Your &lt;code&gt;setup()&lt;/code&gt; routine calls the SimpleTimer library, naming a callback-function and how often it should get called. Your loop function must then call &lt;code&gt;timer.run()&lt;/code&gt; reasonably frequently (where &#xA;reasonably frequently&quot; depends on the timing accuracy and jitter tolerance of your application). &lt;code&gt;timer.run()&lt;/code&gt; will call each of your callback-functions at its appropriate time. You write the callback-functions to do whatever you need them to do when the timer calls them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are one-shot timers and repeating timers - it sounds like your application could one of each per LED: One that fires periodically, to to call a turn-on-LED12 function every (ON_TIME_12+OFF_TIME_12) ms, and a one-shot that calls a turn-off-LED12 function, started by the turn-on-LED_12 function for (ON_TIME_12) msec. Same for LED13, ( ..., etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your loop function is free to do whatever else, as long as it calls &lt;code&gt;timer.run()&lt;/code&gt; frequently enough that your application can meet its timing requirements.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2018-05-03T18:24:39.653" LastActivityDate="2018-05-03T18:24:39.653" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20718" PostTypeId="2" ParentId="20712" CreationDate="2016-02-15T20:39:40.120" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I remove everything except for what is in the brackets from the string?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are a number of &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;String class&lt;/a&gt; member functions that can help with this. First, &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringIndexOf&quot; rel=&quot;nofollow&quot;&gt;indexOf(val)&lt;/a&gt; will help locate the character of interest. Second, &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringSubstring&quot; rel=&quot;nofollow&quot;&gt;substring()&lt;/a&gt; will help cut out the part you want. And as a bonus, using &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringLastIndexOf&quot; rel=&quot;nofollow&quot;&gt;lastIndexOf()&lt;/a&gt; will allow brackets within the string.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String s = &quot;println('hello world')&quot;;&#xA;s = s.substring(s.indexOf('(') + 1);&#xA;s = s.substring(0, s.lastIndexOf(')'));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-15T20:39:40.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20719" PostTypeId="1" CreationDate="2016-02-15T20:43:15.963" Score="3" ViewCount="327" Body="&lt;p&gt;I'm using Arduino: 1.6.7 (Mac OS X 10.11.3), Board: &quot;Arduino Leonardo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to program my code, it works without problems. &#xA;When I want to open the built-in Serial Monitor or Serial Plotter, it says &quot;Board at /dev/cu.usbmodem1421 is not available&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is available and my simple code even works using &quot;SerialTools&quot; from Mac App Store. So there must be some problem with the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No serial related messages on dmesg. Comically it mounts and umounts my Boot OS X and Recovery HD partitions every time I unplug the Leonardo.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hfs: mounted Recovery HD on device disk0s3&#xA;hfs: unmount initiated on Recovery HD on device disk0s3 hfs: mounted&#xA;Boot OS X on device disk2s3 ioqueue_depth = 64,   ioscale = 2 hfs:&#xA;unmount initiated on Boot OS X on device disk2s3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int inByte = 0;         // incoming serial byte&#xA;&#xA;void setup() {&#xA;&#xA;    // start serial port at 9600 bps:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    inByte = Serial.read();&#xA;    Serial.println(&quot;Hi&quot;);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15226" LastEditorUserId="37523" LastEditDate="2019-05-14T19:15:43.067" LastActivityDate="2019-05-14T19:15:43.067" Title="Arduino IDE programs Leonardo but cannot open serial terminal" Tags="|serial|arduino-ide|usb|arduino-leonardo|mac-os|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20720" PostTypeId="2" ParentId="20713" CreationDate="2016-02-15T21:06:07.950" Score="2" Body="&lt;p&gt;This seems to be the perfect example for &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow&quot;&gt;the simple scheduler&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;&#xA;const int pinA = 12;&#xA;const int pinB = 13;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;  Scheduler.start(setupA, loopA);&#xA;  Scheduler.start(setupB, loopB);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.print(millis());&#xA;  Serial.print(F(&quot;:pinA=&quot;));&#xA;  Serial.print(digitalRead(pinA));&#xA;  Serial.print(F(&quot;,pinB=&quot;));&#xA;  Serial.println(digitalRead(pinB));&#xA;  delay(1000);&#xA;}&#xA;&#xA;void setupA()&#xA;{&#xA;  pinMode(pinA, OUTPUT);&#xA;}&#xA;&#xA;void loopA()&#xA;{&#xA;  digitalWrite(pinA, HIGH);&#xA;  delay(2850);&#xA;  digitalWrite(pinA, LOW);&#xA;  delay(11250);&#xA;}&#xA;&#xA;void setupB()&#xA;{&#xA;  pinMode(pinB, OUTPUT);&#xA;}&#xA;&#xA;void loopB()&#xA;{&#xA;  digitalWrite(pinB, HIGH);&#xA;  delay(2850);&#xA;  digitalWrite(pinB, LOW);&#xA;  delay(7000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-15T21:12:23.843" LastActivityDate="2016-02-15T21:12:23.843" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20721" PostTypeId="1" CreationDate="2016-02-15T21:19:40.433" Score="3" ViewCount="377" Body="&lt;p&gt;I have been trying to grasp a better understand of registers and port manipulation. I have been looking through the ATmega 328P datasheet to look at the different registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some of the registers, I see that there are two addresses listed. For example, for PORTB is listed at 0x05 (0x25). Similarly, for its DDRB and PINB, they are listed at 0x04 (0x24), and 0x03 (0x23), respectively. What does this mean for the register? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2016-02-15T21:34:54.060" Title="What does it mean when there are two addresses listed in the data sheet for a particular register?" Tags="|pins|port-mapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20722" PostTypeId="2" ParentId="20721" CreationDate="2016-02-15T21:34:54.060" Score="4" Body="&lt;p&gt;One (the lower number) is the IO port address which is used when using the IN or OUT op-code. The other (higher number) is the memory mapped address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different methods of access are more programatically efficient depending on how you are manipulating the values. For instance IN and OUT are more efficient at setting or reading the entire register value, but SBI and CBI on the memory mapped address are more efficient when manipulating individual bits.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-15T21:34:54.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20723" PostTypeId="1" AcceptedAnswerId="20725" CreationDate="2016-02-15T21:56:24.457" Score="0" ViewCount="1525" Body="&lt;p&gt;Hello  I have an Arduino programme where a string is loaded from an SD card. That all works fine. I want to see if the string that has been loaded contains a certain phrase. I am using substring but it doesn't seem to be working. What am I doing wrong? Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file = SD.open(&quot;/classes/basic.txt&quot;, FILE_READ);&#xA; Serial.print(&quot;Reading, Checking and Compiling \n&quot;);  &#xA;  while(file.available()) {&#xA;   character23 = file.read();&#xA;   content.concat(character23); &#xA;  }    &#xA;if (content != &quot;&quot;) {&#xA;  l1 = content;&#xA;  Serial.println(l1 + &quot;\n&quot;);&#xA;}&#xA;&#xA;if(l1.substring(0) == &quot;print&quot;){&#xA;  printlnMethod(); &#xA;}&#xA;file.close();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it all works until it gets to l1.substring and that doesn't work because the method inside doesn't run. The string that gets loaded into the Arduino from the SD card is : println(&quot;hello world&quot;);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-02-15T22:10:33.233" Title="Arduino substring not working" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20724" PostTypeId="1" CreationDate="2016-02-15T22:07:02.170" Score="3" ViewCount="2324" Body="&lt;p&gt;I can't appear to get my MKR1000 to list a port on my mac in the arduino ide, am i missing something obvious or does it need additional drivers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also &#xA;➜  ~  csrutil status&#xA;System Integrity Protection status: disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;running OSX 10.11.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Board appears to be working, default led flashing&lt;/p&gt;&#xA;" OwnerUserId="18391" LastEditorUserId="18391" LastEditDate="2016-02-15T22:31:59.310" LastActivityDate="2016-10-17T14:00:21.857" Title="MKR1000 not showing up on OSX" Tags="|osx|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20725" PostTypeId="2" ParentId="20723" CreationDate="2016-02-15T22:10:33.233" Score="0" Body="&lt;p&gt;Substring takes either one or two arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the single-argument version that you are using the argument specifies the &lt;em&gt;start&lt;/em&gt; of the substring. The substring then contines to the end of the string.  So, since you are asking it to start at index 0 the returned value is the entire string - from 0 to the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you probably want to use the two-argument version. In that version you provide two numbers - the index in the string to start from, and the index in the string after the last character you want.  So if the string starts with &quot;print&quot; you then want to use &lt;code&gt;l1.substring(0, 5)&lt;/code&gt; to get the characters 0 to 4 inclusive.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-15T22:10:33.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20726" PostTypeId="2" ParentId="20697" CreationDate="2016-02-15T22:51:00.470" Score="0" Body="&lt;p&gt;Do you mean &lt;em&gt;simultaneous&lt;/em&gt; read or write? The AVR processors are 8-bit processors and their I/Os are grouped into 8-bit registers. If you configure all of the bits in a register to the same direction - all inputs or all outputs - then the entire 8 bits could be read/written at once. in C/C++ you would use the `PORTWhich I/Os are assigned to which register is designed into the chip - but the data sheet describes which physical pins are connected to which I/O register. You can take advantage of that to make use of a single register's-worth of pins for up to 8 signals that need to be set or read simultaneously.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-02-15T22:51:00.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20727" PostTypeId="1" CreationDate="2016-02-16T00:09:55.180" Score="2" ViewCount="302" Body="&lt;p&gt;I have been wanting to create a Arduino watch. I built the circuit with an Adafruit Trinket 3v and an Adafruit LED matrix backpack (8*8). When I try to upload this example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*************************************************** &#xA;  This is a library for our I2C LED Backpacks&#xA;&#xA;  Designed specifically to work with the Adafruit LED Matrix backpacks &#xA;  ----&amp;gt; http://www.adafruit.com/products/872&#xA;  ----&amp;gt; http://www.adafruit.com/products/871&#xA;  ----&amp;gt; http://www.adafruit.com/products/870&#xA;&#xA;  These displays use I2C to communicate, 2 pins are required to &#xA;  interface. There are multiple selectable I2C addresses. For backpacks&#xA;  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks&#xA;  with 3 Address Select pins: 0x70 thru 0x77&#xA;&#xA;  Adafruit invests time and resources providing this open source code, &#xA;  please support Adafruit and open-source hardware by purchasing &#xA;  products from Adafruit!&#xA;&#xA;  Written by Limor Fried/Ladyada for Adafruit Industries.  &#xA;  BSD license, all text above must be included in any redistribution&#xA; ****************************************************/&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;Adafruit_LEDBackpack.h&quot;&#xA;#include &quot;Adafruit_GFX.h&quot;&#xA;&#xA;Adafruit_8x8matrix matrix = Adafruit_8x8matrix();&#xA;&#xA;void setup() {&#xA;  // Serial.begin(9600);&#xA;  // Serial.println(&quot;8x8 LED Matrix Test&quot;);&#xA;&#xA;  matrix.begin(0x70);  // pass in the address&#xA;}&#xA;&#xA;static const uint8_t PROGMEM&#xA;  smile_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10100101,&#xA;    B10011001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  neutral_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10111101,&#xA;    B10000001,&#xA;    B01000010,&#xA;    B00111100 },&#xA;  frown_bmp[] =&#xA;  { B00111100,&#xA;    B01000010,&#xA;    B10100101,&#xA;    B10000001,&#xA;    B10011001,&#xA;    B10100101,&#xA;    B01000010,&#xA;    B00111100 };&#xA;&#xA;void loop() {&#xA;  matrix.clear();&#xA;  matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);&#xA;  matrix.writeDisplay();&#xA;  delay(500);&#xA;&#xA;  matrix.clear();&#xA;  matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_ON);&#xA;  matrix.writeDisplay();&#xA;  delay(500);&#xA;&#xA;  matrix.clear();&#xA;  matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON);&#xA;  matrix.writeDisplay();&#xA;  delay(500);&#xA;&#xA;  matrix.clear();      // clear display&#xA;  matrix.drawPixel(0, 0, LED_ON);  &#xA;  matrix.writeDisplay();  // write the changes we just made to the display&#xA;  delay(500);&#xA;&#xA;  matrix.clear();&#xA;  matrix.drawLine(0,0, 7,7, LED_ON);&#xA;  matrix.writeDisplay();  // write the changes we just made to the display&#xA;  delay(500);&#xA;&#xA;  matrix.clear();&#xA;  matrix.drawRect(0,0, 8,8, LED_ON);&#xA;  matrix.fillRect(2,2, 4,4, LED_ON);&#xA;  matrix.writeDisplay();  // write the changes we just made to the display&#xA;  delay(500);&#xA;&#xA;  matrix.clear();&#xA;  matrix.drawCircle(3,3, 3, LED_ON);&#xA;  matrix.writeDisplay();  // write the changes we just made to the display&#xA;  delay(500);&#xA;&#xA;  matrix.setTextSize(1);&#xA;  matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely&#xA;  matrix.setTextColor(LED_ON);&#xA;  for (int8_t x=0; x&amp;gt;=-36; x--) {&#xA;    matrix.clear();&#xA;    matrix.setCursor(x,0);&#xA;    matrix.print(&quot;Hello&quot;);&#xA;    matrix.writeDisplay();&#xA;    delay(100);&#xA;  }&#xA;  matrix.setRotation(3);&#xA;  for (int8_t x=7; x&amp;gt;=-36; x--) {&#xA;    matrix.clear();&#xA;    matrix.setCursor(x,0);&#xA;    matrix.print(&quot;World&quot;);&#xA;    matrix.writeDisplay();&#xA;    delay(100);&#xA;  }&#xA;  matrix.setRotation(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;In file included from matrix8x8.ino:23:0:&#xA;C:\Users\My_Username\Documents\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:30:24: fatal error: TinyWireM.h: No such file or directory&#xA;  #include &amp;lt;TinyWireM.h&amp;gt;&#xA;                        ^&#xA;compilation terminated.&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have installed TinyWireM, Adafruit_GFX, and Adafruit_LEDBackpack. Why would I get this error? &#xA;&lt;a href=&quot;https://i.stack.imgur.com/Xg4c3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Xg4c3.png&quot; alt=&quot;My Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18390" LastActivityDate="2016-02-16T00:09:55.180" Title="Adafruit Trinket 3v with LED matrix backpack producing error" Tags="|i2c|library|adafruit|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20728" PostTypeId="1" AcceptedAnswerId="20737" CreationDate="2016-02-16T01:04:27.443" Score="0" ViewCount="130" Body="&lt;p&gt;I am creating a miniature computer using an Arduino, and I am creating a full-scale interpreter for it. Everything works, and the code begins to run after calling the runCode method, but once the run is finished it doesn't return to the calling function. I have Serial outputs to tell me where the code reaches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code contains an &lt;strong&gt;&quot;Function&quot; object&lt;/strong&gt; with a name and a function pointer, an &lt;strong&gt;object to run the code&lt;/strong&gt; (with a working Lexer object that splits the inputted code by spaces), and an &lt;strong&gt;in-computer editor&lt;/strong&gt; (which completely works except the one function) to input programs to be run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function that calls the runCode method for my code-running object (called Joker) &lt;strong&gt;is in the editor&lt;/strong&gt;. The problem is, once the runCode finishes, it does not return. &lt;strong&gt;The system halts.&lt;/strong&gt; I will post the Function class, runCode Method, and calling method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. There are Serial prints to determine where the code reaches. It outputs &quot;Function End!&quot;, but not &quot;Failed!&quot;/&quot;Succeeded&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.P.S. It uses a parallax 4x20 Back-lit Single-pin Serial LCD which completely 100% works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.P.P.S It uses the QueueList library which is basically a dynamic list that works like a stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more note: The code heavliy uses dynamic lists, function pointers, and lambda expressions, so.... be prepared....&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Code for Function class (no it does not have any actual functions):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Function {&#xA;public:&#xA;  String f_name;&#xA;  bool (*f_run) (QueueList&amp;lt;float&amp;gt; &amp;amp;stack, SoftwareSerial &amp;amp;lcd);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code for runCode method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool Joker::runCode(QueueList&amp;lt;String&amp;gt; lineTable, SoftwareSerial &amp;amp;lcd) {&#xA;  // Set up lexer&#xA;  Lexer lexer;&#xA;  // Get all lexer words&#xA;  lexer.getWords(lineTable);&#xA;&#xA;  String cur_word = &quot;&quot;;&#xA;  float num_val = 0.0f;&#xA;  bool quit = false;&#xA;&#xA;  while(!quit) {&#xA;    cur_word = lexer.nextWord();&#xA;    if(cur_word == &quot;&quot;)&#xA;      quit = true;&#xA;    else {&#xA;      // Get word in uppercase&#xA;      cur_word.toUpperCase();&#xA;&#xA;      Serial.println(cur_word);&#xA;&#xA;      // Parse the first number from it&#xA;      num_val = cur_word.toFloat();&#xA;&#xA;      // Check if we have a function&#xA;      if(queueListContains(cur_word, dictionary)) {&#xA;        Function theFunc = getDictionaryFunction(cur_word, dictionary);&#xA;        if(!theFunc.f_run(stack, lcd)) {&#xA;          error(F(&quot;Unable to process word!!&quot;), lcd);&#xA;          return false;&#xA;        }&#xA;      } else if(num_val != 0) {         // check if the parse was good&#xA;        stack.push(num_val);            // if it was: push num to the stack&#xA;      } else if(num_val == 0) {         // if zero it could be parsing a zero or it could have failed&#xA;        if(cur_word.indexOf(&quot;0&quot;) != -1) // if it didn't fail:&#xA;          stack.push(num_val);          // push to the stack&#xA;        else {                          // otherwise:&#xA;          error(F(&quot;Unknown word!!&quot;), lcd);   // Unknown word error&#xA;          return false;&#xA;        }&#xA;      } else {&#xA;        error(F(&quot;Unknown word!!&quot;), lcd);&#xA;        return false;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  // Test printing the stack&#xA;  /*while(!stack.isEmpty()) {&#xA;    lcd.print(stack.pop());&#xA;    lcd.print(' ');&#xA;  }*/&#xA;&#xA;  Serial.print(F(&quot;Function end!&quot;));&#xA;  return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the caller method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void line_editor::RunProgram(SoftwareSerial &amp;amp;lcd) {&#xA;  Serial.println(&quot;Running program!!&quot;);&#xA;  // Move to top line&#xA;  currentLine = 0;&#xA;  while(!lineTableB.isEmpty()) {&#xA;    lineTableA.push(lineTableB.pop());&#xA;    // Serial.print(lineTableB.peek());&#xA;  }&#xA;&#xA;  // Clear the string&#xA;  lcd.write(12);&#xA;  delay(5);&#xA;  lcd.write(128);&#xA;&#xA;  // Joker language object&#xA;  Joker joker;&#xA;&#xA;  QueueList&amp;lt;Function&amp;gt; PrintingWords;&#xA;&#xA;  // Create the printing functions&#xA;  Function printWord;&#xA;  printWord.f_name = &quot;BC&quot;; // print &quot;Beginning Card&quot;&#xA;  printWord.f_run = [] (QueueList&amp;lt;float&amp;gt; &amp;amp;stack, SoftwareSerial &amp;amp;lcd) {&#xA;    if(stack.isEmpty()) {&#xA;      return false;&#xA;    }&#xA;&#xA;    float num = stack.pop();&#xA;    lcd.print(num);&#xA;    lcd.write(13);&#xA;&#xA;    return true;&#xA;  };&#xA;  PrintingWords.push(printWord);&#xA;&#xA;  // Print the whole stack&#xA;  Function printStack;&#xA;  printStack.f_name = &quot;AC&quot;; // print &quot;All Cards&quot;&#xA;  printStack.f_run = [] (QueueList&amp;lt;float&amp;gt; &amp;amp;stack, SoftwareSerial &amp;amp;lcd) {&#xA;    while(!stack.isEmpty()) {&#xA;      lcd.print(stack.pop());&#xA;      lcd.print(' ');&#xA;    }&#xA;&#xA;    lcd.write(13);&#xA;&#xA;    return true;&#xA;  };&#xA;  PrintingWords.push(printStack);&#xA;&#xA;  // Add all the functions&#xA;  joker.addWords(PrintingWords);&#xA;&#xA;  // Run Program here...&#xA;  if(joker.runCode(lineTableA, lcd))&#xA;    Serial.println(&quot;Success!!&quot;);&#xA;  else&#xA;    Serial.println(&quot;Failed!!&quot;);&#xA;&#xA;  // lineTableA.push(lineTableB.pop());&#xA;&#xA;  Serial.println(&quot;Here!!&quot;);&#xA;&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry if I confused anyone. If there are any questions, then leave a comment, and I'll try to clear up the confusion. Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT::ADDING FULL CODE:&lt;/strong&gt;&#xA;Here is a &lt;a href=&quot;https://github.com/blueOkiris/TASIC-PC/tree/master&quot; rel=&quot;nofollow&quot;&gt;LINK&lt;/a&gt; to the rest of the code on github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, here is the rest of the Joker.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Joker::addWords(QueueList&amp;lt;Function&amp;gt; new_dict) {&#xA;  while(!new_dict.isEmpty()) {&#xA;    dictionary.push(new_dict.pop());&#xA;  }&#xA;}&#xA;&#xA;bool Joker::queueListContains(String theWord, QueueList&amp;lt;Function&amp;gt; &amp;amp;list) {&#xA;  Serial.println(&quot;Finding word:&quot;);&#xA;&#xA;  QueueList&amp;lt;Function&amp;gt; temp;&#xA;&#xA;  while(!list.isEmpty()) {&#xA;    Function r = list.pop();&#xA;    temp.push(r);&#xA;&#xA;    Serial.print(&quot;&amp;gt;&amp;gt; &quot;);&#xA;    Serial.println(theWord);&#xA;    Serial.print(&quot;&amp;gt;&amp;gt; equals? &quot;);&#xA;    Serial.println(r.f_name);&#xA;    delay(5);&#xA;&#xA;    if(r.f_name.equals(theWord)) {&#xA;      while(!temp.isEmpty())&#xA;        list.push(temp.pop());&#xA;      return true;&#xA;    }&#xA;  }&#xA;&#xA;  while(!temp.isEmpty())&#xA;    list.push(temp.pop());&#xA;&#xA;  return false;&#xA;}&#xA;&#xA;Function Joker::getDictionaryFunction(String theWord, QueueList&amp;lt;Function&amp;gt; &amp;amp;list) {&#xA;  QueueList&amp;lt;Function&amp;gt; temp;&#xA;&#xA;  while(!list.isEmpty()) {&#xA;    Function theFunction = list.pop();&#xA;    temp.push(theFunction);&#xA;&#xA;    if(theFunction.f_name.equals(theWord)) {&#xA;      while(!temp.isEmpty()) {&#xA;        list.push(temp.pop());&#xA;      }&#xA;      return theFunction;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void Joker::error(String message, SoftwareSerial &amp;amp;lcd) {&#xA;  lcd.write(12);&#xA;  delay(5);&#xA;  lcd.write(128);&#xA;&#xA;  lcd.print(message);&#xA;&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#pragma once&#xA;&#xA;class Joker {&#xA;private:&#xA;  bool queueListContains(String theWord, QueueList&amp;lt;Function&amp;gt; &amp;amp;list);&#xA;  Function getDictionaryFunction(String theWord, QueueList&amp;lt;Function&amp;gt; &amp;amp;list);&#xA;&#xA;public:&#xA;  QueueList&amp;lt;float&amp;gt; stack;&#xA;  QueueList&amp;lt;Function&amp;gt; dictionary;&#xA;&#xA;  void error(String message, SoftwareSerial &amp;amp;lcd);&#xA;  void addWords(QueueList&amp;lt;Function&amp;gt; new_dict);&#xA;  bool runCode(QueueList&amp;lt;String&amp;gt; lineTable, SoftwareSerial &amp;amp;lcd);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18396" LastEditorUserId="18396" LastEditDate="2016-02-16T21:31:31.890" LastActivityDate="2016-02-18T22:55:51.753" Title="Why doesn't my object's method return back to my caller method?" Tags="|serial|programming|arduino-mega|c++|pointer|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20729" PostTypeId="1" CreationDate="2016-02-16T01:25:42.400" Score="1" ViewCount="1482" Body="&lt;p&gt;I've gotten contradicting information on the subject.  Some say that digital input pins send out positive voltage, and if it goes to ground (for example) it reads LOW but if the pin is connected to power, it will read HIGH.  On the other hand, some say that the input pin is receiving voltage from either power (+5V) or ground (0V).  which one is it?&lt;/p&gt;&#xA;" OwnerUserId="18397" LastActivityDate="2016-02-16T06:37:28.133" Title="do digital input pins act as a positive or negative" Tags="|arduino-uno|pins|input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20730" PostTypeId="2" ParentId="20562" CreationDate="2016-02-16T01:26:50.770" Score="0" Body="&lt;p&gt;Check this video &lt;a href=&quot;https://www.youtube.com/watch?v=0zuRukW7o0A&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=0zuRukW7o0A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reboot and press CMD+R immediately after reboot to enter in Recovery Mode&lt;/li&gt;&#xA;&lt;li&gt;Open Terminal from Recovery mode&lt;/li&gt;&#xA;&lt;li&gt;Run the command csrutil enable --without kext&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;li&gt;Install driver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13984" LastActivityDate="2016-02-16T01:26:50.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20732" PostTypeId="2" ParentId="12133" CreationDate="2016-02-16T01:52:11.507" Score="1" Body="&lt;p&gt;Check this video &lt;a href=&quot;https://www.youtube.com/watch?v=0zuRukW7o0A&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=0zuRukW7o0A&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Reboot and press CMD+R immediately after reboot to enter in Recovery Mode&lt;/li&gt;&#xA;&lt;li&gt;Open Terminal from Recovery mode&lt;/li&gt;&#xA;&lt;li&gt;Run the command csrutil enable --without kext&lt;/li&gt;&#xA;&lt;li&gt;Reboot&lt;/li&gt;&#xA;&lt;li&gt;Install driver&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="13984" LastActivityDate="2016-02-16T01:52:11.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20734" PostTypeId="1" CreationDate="2016-02-16T02:32:41.893" Score="0" ViewCount="5564" Body="&lt;p&gt;I have moved the MCU of the Arduino to a breadboard using these steps &lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Standalone&lt;/a&gt; then interfaced it with an LM35 temperature sensor to the ADC0. But I can't get proper values from the LM35. I think it's because of the Aref or AVcc. Both are just connected to +5? &#xA;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;float tempC;&#xA;float reading;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    reading = analogRead(0);&#xA;    tempC = (reading * 0.4882815) + 5;&#xA;    Serial.print(tempC);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get hex values and sometime high values. What to do with Aref and AVcc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I get values like these &#xA;€&#xA;Œ&lt;/p&gt;&#xA;" OwnerUserId="18398" LastEditorUserId="11529" LastEditDate="2016-02-16T11:06:48.933" LastActivityDate="2016-02-16T22:49:18.940" Title="Arduino to breadboard with LM35 temp sensor" Tags="|arduino-uno|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="20735" PostTypeId="2" ParentId="20729" CreationDate="2016-02-16T03:12:46.223" Score="1" Body="&lt;p&gt;It's both, depending on whether or not the internal pullup has been enabled (&lt;code&gt;INPUT&lt;/code&gt; versus &lt;code&gt;INPUT_PULLUP&lt;/code&gt;). The pullup ties the input to the positive supply through a moderately large resistance, meaning that it is possible to source a small amount of current from the input pin.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-16T03:12:46.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20736" PostTypeId="2" ParentId="20734" CreationDate="2016-02-16T04:44:06.317" Score="1" Body="&lt;p&gt;Check the &lt;code&gt;baud rate&lt;/code&gt; of your serial monitor matches what you have set in your setup() function.  In the above code that is 9600.  If the baud rate is incorrect you typically get rubbish output in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7oANR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7oANR.png&quot; alt=&quot;Serial Monitor set at 9600 baud&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to change the Serial.print(tempC) to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(tempC,2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To get some decimal places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the circuit ~&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vs7wj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vs7wj.png&quot; alt=&quot;Ricardo Sequeria&amp;#39;s example Arduio &amp;amp; LM35&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You don't need ARef connected. &lt;/li&gt;&#xA;&lt;li&gt;The LM35 VCC should be connected to Arduino 5V &lt;/li&gt;&#xA;&lt;li&gt;The LM35 GND to Arduino Gnd (any of them) &lt;/li&gt;&#xA;&lt;li&gt;Finally LM35 signal (Vout) to Arduino A0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-16T05:48:18.583" LastActivityDate="2016-02-16T05:48:18.583" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20737" PostTypeId="2" ParentId="20728" CreationDate="2016-02-16T05:08:54.477" Score="1" Body="&lt;p&gt;The short answer here is - It does not return because you have corrupted the stack.&lt;br&gt;&#xA;The return address is pushed onto the stack as part of the function call.  If you overwrite (corrupt) that address the program cannot jump back to where it was (return).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So where is the cause of the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does &lt;code&gt;getDictionaryFunction(cur_word, dictionary)&lt;/code&gt; ever return NULL or an invalid pointer?  The code tries to execute it anyway.  EDIT: What happens below when &lt;em&gt;theWord&lt;/em&gt; is not matched or &lt;em&gt;list&lt;/em&gt; is empty?  Actually I'm surprised this compiles, since there's a few paths where no value is returned.  (I'm no expert on the GCC AVR compiler, but what happens if we don't assign a return value at all?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Function Joker::getDictionaryFunction(String theWord, QueueList &amp;lt; Function &amp;gt; &amp;amp;list)&#xA;{&#xA;    QueueList &amp;lt; Function &amp;gt; temp;&#xA;&#xA;    while (!list.isEmpty())&#xA;    {&#xA;        Function theFunction = list.pop();&#xA;        temp.push(theFunction);&#xA;&#xA;        if (theFunction.f_name.equals(theWord))&#xA;        {&#xA;            while (!temp.isEmpty())&#xA;            {&#xA;                list.push(temp.pop());&#xA;            }&#xA;            return theFunction;&#xA;        }&#xA;    }&#xA;    // BAD-JUJU HAPPENS IF WE GET HERE&#xA;    assert(false);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Coding style tip: except in trivial cases, it's good to only return from the bottom of your function.  Then the above never happens, and supposedly it's easier for the compiler to optimise.  NOTE: I'm unsure if &lt;code&gt;assert()&lt;/code&gt; will even do anything on Arduino.  It's left as a marker to mean &lt;em&gt;Handle Error Here&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Function Joker::getDictionaryFunction(String theWord, QueueList &amp;lt; Function &amp;gt; &amp;amp;list)&#xA;{&#xA;    Function dict_func = NULL;&#xA;    QueueList &amp;lt; Function &amp;gt; temp;&#xA;&#xA;    while (!list.isEmpty())&#xA;    {&#xA;        Function theFunction = list.pop();&#xA;        temp.push(theFunction);&#xA;&#xA;        if (theFunction.f_name.equals(theWord))&#xA;        {&#xA;            while (!temp.isEmpty())&#xA;                list.push(temp.pop());&#xA;            dict_func = theFunction;&#xA;            break;&#xA;        }&#xA;    }&#xA;    assert(dict_func != NULL);  // This should never happen&#xA;    return dict_func;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Coding style tip: WoRd CasE ~ lower_case, mixedCase, CapitalCase, UPPER_CASE.  I use lower case for all_variable_names, mixed case for functionNames(), capital case for ClassNames and StructureNames, and upper case for MACROS and CONSTANT_DEFINITIONS.  Pick a system, and stick to it absolutely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you run out of memory - the stack could have hit the heap.&#xA;What sort of Arduino are you using?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On an Uno, with only 2k of RAM, you might need to make some scope-cuts.&#xA;Even on an Arduino Mega, you still only have 8k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you can make use of a &lt;code&gt;freeMemory()&lt;/code&gt; function.  This will give you an indication of the free space between the stack and the heap.  The AdaFruit version is below, but there are others too.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int freeRam () &#xA;{&#xA;  extern int __heap_start, *__brkval; &#xA;  int v; &#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It may be worthwhile reading their &lt;a href=&quot;https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory&quot; rel=&quot;nofollow&quot;&gt;page on Arduino memory usage&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after having a browse through your code, I can't see any obvious problems.  Fix the &lt;code&gt;getDictionaryFunction()&lt;/code&gt; so you know if it's failing.  Check to see if you're running out of RAM - you are making heavy use of it copying strings around, especially with that template class.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe consider re-compiling the code on a workstation in GCC - it wouldn't take much, just change your serial outputs to printf(), and hard-code your input data (or read from a file).  That will enable easier debugging.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastEditorUserId="2926" LastEditDate="2016-02-18T22:55:51.753" LastActivityDate="2016-02-18T22:55:51.753" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20738" PostTypeId="2" ParentId="20729" CreationDate="2016-02-16T06:37:28.133" Score="2" Body="&lt;p&gt;Digital pins sink or source current. They don't provide negative voltages. If the pin is set to &lt;code&gt;INPUT&lt;/code&gt; then it is high impedance and will not &quot;send out positive voltage&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you activate the internal pull-ups, as Ignacio said, then effectively the pin is connected to +5V via (approximately) a 50k resistor.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-16T06:37:28.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20739" PostTypeId="2" ParentId="16959" CreationDate="2016-02-16T07:01:51.567" Score="1" Body="&lt;p&gt;The Teensy 3.2 board is based on MK20DX256. The processor core is an ARM and not AVR. The best way to learn about security on the MK20DX256 is to read the &lt;a href=&quot;https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Chapter 8 Security&#xA;  8.1 Introduction&#xA;  This device implements security based on the mode selected from the flash module. The following sections provide an overview of flash security and details the effects of security on non-flash modules.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;8.2 Flash Security&#xA;  The flash module provides security information to the MCU based on the state held by the FSEC[SEC] bits. The MCU, in turn, confirms the security request and limits access to flash resources. During reset, the flash module initializes the FSEC register using data read from the security byte of the flash configuration field.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;NOTE The security features apply only to external accesses: debug and&#xA;  EzPort. CPU accesses to the flash are not affected by the status&#xA;  of FSEC. In the unsecured state all flash commands are available to the programming interfaces (JTAG and EzPort), as well as user code execution of Flash Controller commands. When the flash is secured (FSEC[SEC] = 00, 01, or 11), programmer interfaces are only allowed to launch mass erase operations and have no access to memory locations.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Further information regarding the flash security options and enabling/disabling flash security is available in the Flash Memory Module.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The next step is to search for an open-source project that uses the FSEC setting. And by chance the mbed does. Here is &lt;a href=&quot;https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_TEENSY3_1/TOOLCHAIN_ARM_STD/startup_MK20DX256.S#L287&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; to how it is done in the mbed CMSIS Cortex-M4 Core Device Startup File for the MK20DX256. There should be the same setting in the Teensy Arduino core. Locating that is left to the reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-16T07:01:51.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20740" PostTypeId="1" CreationDate="2016-02-16T07:37:27.180" Score="4" ViewCount="11598" Body="&lt;p&gt;Does anyone know how to do the run time calibration for MPU9250 ?&lt;/p&gt;&#xA;" OwnerUserId="16602" LastEditorUserId="6936" LastEditDate="2016-02-17T07:00:06.550" LastActivityDate="2016-11-04T20:06:30.370" Title="How to do run time calibration for MPU9250?" Tags="|arduino-uno|mpu6050|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20742" PostTypeId="1" CreationDate="2016-02-16T08:51:49.260" Score="-1" ViewCount="650" Body="&lt;p&gt;I tried to build a simple l-meter with my arduino due. I programmed a simple frequency meter with one timer and one counter. The timer takes an interrupt each 10s, 100ms, 10ms and 1ms. But ones the interrupt is taken it is stopped and even a short &lt;code&gt;Serial.println(&quot;Hello World&quot;);&lt;/code&gt; does not appear in the serial monitor of the arduino IDE. I don't know what I forgot. &#xA;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define voltage 26&#xA;&#xA;volatile uint32_t current_range = 10000;               //starts with highest range and decrements. longer measurements produce more precise results. measurements for small l values require 11.111ms&#xA;volatile const double c_1 = 2533029590000000.0;        //constant value for l value calculation&#xA;volatile double correction_value = 0;&#xA;volatile boolean calib = true;&#xA;volatile uint32_t counter_value = 0;&#xA;&#xA;void initCounter(){&#xA;    pmc_enable_periph_clk(ID_TC0);              //enable peripheral clock for TC0&#xA;&#xA;    REG_TC0_CMR0 = TC_CMR_TCCLKS_XC0;           //External clock 0 connected to PB26 (Digital Pin 22)&#xA;    REG_TC0_CCR0 = TC_CCR_CLKEN;                //Enable clock&#xA;}&#xA;&#xA;void initTimer(){&#xA;    pmc_enable_periph_clk(ID_TC1);              //enable peripheral clock for TC1&#xA;&#xA;    REG_TC0_CMR1 = TC_CMR_TCCLKS_TIMER_CLOCK1;  //42MHz clock&#xA;    REG_TC0_IER1 = TC_IER_CPCS;                 //Enable compare RC interrupt&#xA;    REG_TC0_IDR1 = ~TC_IDR_CPCS;                //Enable compare RC interrupt (disbale interrupt = 0)&#xA;    REG_TC0_CCR1 = TC_CCR_CLKEN;                //Enable clock&#xA;&#xA;    NVIC_EnableIRQ(TC1_IRQn);                   //Enable interrupt in nested vectored interrupt controller NVIC (IRQN number = TC number * channels + channel number)&#xA;}&#xA;&#xA;double calc_l(uint32_t CV){&#xA;    double freq = (double)CV / ((double)current_range / 1000.0);&#xA;    freq = freq * freq;&#xA;&#xA;    return c_1 / freq;&#xA;}&#xA;&#xA;void calibrate(){&#xA;    Serial.println(&quot;---Calibrating... shorten inputs then press enter---&quot;);&#xA;    while(!(Serial.available() == '\n'));&#xA;    Serial.print(&quot;Start calibration\n&quot;);&#xA;    initCounter();                              //initialize counter&#xA;    initTimer();                                //initialize timer&#xA;&#xA;    REG_TC0_RC1  = 0x1908B100;                  //RC = 420.000.000 to run 10.000ms&#xA;&#xA;    REG_TC0_BCR = TC_BCR_SYNC;                  //reset and start timer and counter simultaneously&#xA;}&#xA;&#xA;void measure(){&#xA;    calib = false;&#xA;&#xA;    //Serial.println(&quot;---Measure... connect inductivity then press any key---&quot;);&#xA;    //while(!(Serial.available() &amp;gt; 0));&#xA;    initCounter();                              //initialize counter&#xA;    initTimer();                                //initialize timer  &#xA;    REG_TC0_RC1  = 0x1908B100;                  //RC = 420.000.000 to run 10.000ms&#xA;&#xA;    REG_TC0_BCR = TC_BCR_SYNC;                  //reset and start timer and counter simultaneously&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(250000);&#xA;&#xA;    pmc_set_writeprotect(false);                //disable writeprotect for pmc &#xA;    pinMode(13, OUTPUT);&#xA;    pinMode(voltage, OUTPUT);                   //set digital pin 26 as output&#xA;    digitalWrite(voltage, HIGH);                //set digital pin 26 HIGH&#xA;    delay(1000);                                //wait 1 second to get circuit working&#xA;&#xA;    calibrate();&#xA;}&#xA;&#xA;void loop() {&#xA;    analogWrite(13, 25);&#xA;    delay(100);&#xA;    Serial.print(REG_TC0_SR1);&#xA;    Serial.print(&quot;;&quot;);&#xA;    Serial.print(REG_TC0_CMR1);&#xA;    Serial.print(&quot;;&quot;);&#xA;    Serial.print(REG_TC0_IER1);&#xA;    Serial.print(&quot;;&quot;);&#xA;    Serial.print(REG_TC0_IDR1);&#xA;    Serial.print(&quot;;&quot;);&#xA;    Serial.print(REG_TC0_CCR1);&#xA;    Serial.print(&quot;\n&quot;);&#xA;}&#xA;&#xA;void TC1_Handler(){&#xA;&#xA;    uint32_t SR = REG_TC0_SR0;                    //save status register &#xA;    uint32_t CV = REG_TC0_CV0;                    //save counter value&#xA;&#xA;    if((SR &amp;amp; TC_SR_CLKSTA) == TC_SR_CLKSTA){      //check whether counter clock is enabled&#xA;        if((SR &amp;amp; TC_SR_COVFS) == TC_SR_COVFS){      //check whether counter overflow accured&#xA;            switch(current_range){                    //check current range. decrement until smallest range is reached. then print error&#xA;                case 10000: REG_TC0_RC1  = 0x280DE80;                   //RC = 42.000.000 to run 1.000ms          &#xA;                            current_range = 1000;&#xA;                            REG_TC0_BCR  = TC_BCR_SYNC;&#xA;                            break;&#xA;                case 1000:  REG_TC0_RC1  = 0x401640;                    //RC = 4.200.000 to run 100ms&#xA;                            current_range = 100;&#xA;                            REG_TC0_BCR  = TC_BCR_SYNC;&#xA;                            break;&#xA;                case 100:   REG_TC0_RC1  = 0x668A0;                     //RC = 420.000 to run 10ms&#xA;                            current_range = 10;&#xA;                            REG_TC0_BCR  = TC_BCR_SYNC;&#xA;                            break;&#xA;                case 10:    REG_TC0_RC1  = 0xA410;                      //RC = 42.000 to run 1ms&#xA;                            current_range = 1;&#xA;                            REG_TC0_BCR  = TC_BCR_SYNC;&#xA;                            break;&#xA;                case 1:     //Serial.println(&quot;Error: l value out of range!&quot;);&#xA;                            REG_TC0_CCR0 = ~TC_CCR_CLKEN;&#xA;                            REG_TC0_CCR1 = ~TC_CCR_CLKEN;&#xA;                            break;&#xA;            }&#xA;        } else {&#xA;            if(calib){&#xA;                if(CV &amp;lt; 10){&#xA;                    //Serial.println(&quot;Error: wrong calibration value!&quot;);&#xA;                    REG_TC0_CCR0 = ~TC_CCR_CLKEN;&#xA;                    REG_TC0_CCR1 = ~TC_CCR_CLKEN;&#xA;                } else {&#xA;                    //correction_value = calc_l(CV);&#xA;                    measure();&#xA;                }&#xA;            } else {&#xA;                if(CV &amp;lt; 10){                           //check if counter value is below 10. then l value is to high to get accurate results&#xA;                    //Serial.println(&quot;Error: l value out of range!&quot;);&#xA;                    REG_TC0_CCR0 = ~TC_CCR_CLKEN;&#xA;                    REG_TC0_CCR1 = ~TC_CCR_CLKEN;&#xA;                } else {                               //l value in nH; &#xA;                    counter_value = CV;&#xA;                    //Serial.print(calc_l(CV) - correction_value);&#xA;                    //Serial.print(&quot; nH; &quot;);&#xA;                    //Serial.print(CV);&#xA;                    //Serial.print(&quot; ticks in &quot;);&#xA;                    //Serial.print(current_range);&#xA;                    //Serial.println(&quot;ms.&quot;);&#xA;                    REG_TC0_CCR0 = ~TC_CCR_CLKEN;&#xA;                    REG_TC0_CCR1 = ~TC_CCR_CLKEN;&#xA;                }&#xA;            }&#xA;        }&#xA;    } else {&#xA;        REG_TC0_CCR0 = TC_CCR_CLKEN;&#xA;        REG_TC0_BCR  = TC_BCR_SYNC;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be very nice if someone could help me with this.&lt;/p&gt;&#xA;" OwnerUserId="11980" LastEditorUserId="11980" LastEditDate="2016-02-17T06:59:57.870" LastActivityDate="2016-10-14T21:18:10.503" Title="Arduino Due interrupt is taken but not executed completely" Tags="|arduino-due|interrupt|timers|isr|" AnswerCount="1" CommentCount="12" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20743" PostTypeId="2" ParentId="20707" CreationDate="2016-02-16T08:54:22.960" Score="2" Body="&lt;p&gt;You have misunderstood how shift registers work - and one of the main reasons they exist in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shift register ICs have a common 'latch' pin which latches the data present at the input of the cell into the cell, thus updating the output. Some ICs also offer an &quot;output enable&quot;, which switches the outputs to a high-impedance state irrespective of the values in the cells - this might not be useful in your case, but the feature exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a serial-to-parallel shift register you can shift in as many bits as you want, at whatever rate you choose, and the outputs will never change &lt;strong&gt;until you trigger a rising edge on the LATCH pin&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How a (latching) Shift Register works:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have eight spaces within the register:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             ___    ___    ___    ___    ___    ___    ___    ___ &#xA;[DATA_IN]--&amp;gt;|___|--|___|--|___|--|___|--|___|--|___|--|___|--|___|--&amp;gt;[DATA_OUT]&#xA;            BIT0                                              BIT7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 'spaces' are chained together; at one end of the chain is the &lt;code&gt;DATA_IN&lt;/code&gt; pin and at the other end is the &lt;code&gt;DATA_OUT&lt;/code&gt; pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time there is a rising edge on the &lt;code&gt;CLOCK&lt;/code&gt; pin, data is &lt;em&gt;shifted&lt;/em&gt; down the chain from &lt;code&gt;DATA_IN&lt;/code&gt; to &lt;code&gt;DATA_OUT&lt;/code&gt;, one space at a time. For example, if the state of the 'spaces' is as the left hand column, then upon the rising edge of the &lt;code&gt;CLOCK&lt;/code&gt; pin the spaces will change to the values in the right hand column:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; DATA_IN PIN = 1  -&amp;gt;  C  -&amp;gt; ?&#xA;BIT0 'SPACE' = 0  -&amp;gt;  L  -&amp;gt; 1&#xA;BIT1 'SPACE' = 1  -&amp;gt;  O  -&amp;gt; 0&#xA;BIT2 'SPACE' = 1  -&amp;gt;  C  -&amp;gt; 1&#xA;BIT3 'SPACE' = 0  -&amp;gt;  K  -&amp;gt; 1&#xA;BIT4 'SPACE' = 0  -&amp;gt;  E  -&amp;gt; 0&#xA;BIT5 'SPACE' = 1  -&amp;gt;  D  -&amp;gt; 0&#xA;BIT6 'SPACE' = 1  -&amp;gt;  G  -&amp;gt; 1&#xA;BIT7 'SPACE' = 0  -&amp;gt;  E  -&amp;gt; 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will see that &lt;code&gt;BIT(n)&lt;/code&gt; changes to the value of &lt;code&gt;BIT(n-1)&lt;/code&gt;, with &lt;code&gt;BIT0&lt;/code&gt; changing to the value of &lt;code&gt;DATA_IN&lt;/code&gt;. The &lt;code&gt;DATA_OUT&lt;/code&gt; pin is used to daisy-chain multiple shift registers together. The important thing to note here is that &lt;strong&gt;the outputs do not change without a rising edge on the &lt;code&gt;LATCH&lt;/code&gt; pin&lt;/strong&gt;. You can pulse &lt;code&gt;CLOCK&lt;/code&gt; as many times as you want, with whatever values on &lt;code&gt;DATA_IN&lt;/code&gt;, and the outputs will not change. Ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you finally trigger the &lt;code&gt;LATCH&lt;/code&gt; pin, the value in each 'space' is latched into a second row of 'spaces' - these represent the outputs. On a latch trigger, the outputs therefore change to the values of the &lt;em&gt;last eight&lt;/em&gt; bits that were shifted into the &lt;code&gt;DATA_IN&lt;/code&gt; pin. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OUTPUT = 11001010&#xA;                   SHIFT IN &quot;01101111&quot; (starting with RHS first)&#xA;                               TRIGGER RISING EDGE ON 'LATCH' PIN&#xA;OUTPUT = 01101111&#xA;                   SHIFT IN &quot;11110000110011001100&quot;&#xA;                               TRIGGER RISING EDGE ON 'LATCH' PIN&#xA;OUTPUT = 11110000   i.e. the LAST EIGHT BITS that were shifted in&#xA;                   SHIFT IN &quot;10&quot;&#xA;                               TRIGGER RISING EDGE ON 'LATCH' PIN&#xA;OUTPUT = 10111100   again the LAST EIGHT BITS that were shifted in&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is generally never the case with a serial-in-parallel-out register that you would ever shift in less that eight bits at a time, so the last example is only there to illustrate the functioning of the IC.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="10003" LastEditDate="2016-02-17T17:25:52.827" LastActivityDate="2016-02-17T17:25:52.827" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20744" PostTypeId="2" ParentId="20707" CreationDate="2016-02-16T09:17:05.633" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... relay ... active when pulled down ... shift register ... latch ... Arduino ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ti.com/product/TPIC6C595&quot; rel=&quot;nofollow&quot;&gt;TPIC6C595&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;shiftOut()&lt;/code&gt; and the '595&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-16T09:17:05.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20747" PostTypeId="1" AcceptedAnswerId="20748" CreationDate="2016-02-16T11:26:42.853" Score="1" ViewCount="167" Body="&lt;p&gt;I am using the pin 4 as an OUTPUT and pin 8 as an INPUT to turn on/off the light, but for some reason it is not working. Light is on all the time, but when I try to input something it gets brighter and doesn't turn off when I don't give anything to pin 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED is connected to pin 4 with a 220 R, and the other side to GND. When pin 8 is connected to 5V pin then the light should come on, and off when I disconnect them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(8, INPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;   bool on = digitalRead(8);&#xA;   if(on)&#xA;   {&#xA;     digitalWrite(4, HIGH);&#xA;   }&#xA;   else&#xA;   {&#xA;     digitalWrite(4, LOW);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="16996" LastEditorUserId="2881" LastEditDate="2016-02-16T16:46:12.793" LastActivityDate="2016-02-16T16:46:12.793" Title="Turn on a light when there is an input" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20748" PostTypeId="2" ParentId="20747" CreationDate="2016-02-16T11:36:47.413" Score="3" Body="&lt;p&gt;Use input with pullup on pin 8 and a button to ground (GND). See below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin = 4;&#xA;const int buttonPin = 8;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;   digitalWrite(ledPin, digitalRead(buttonPin));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using the pin as input and disconnecting is not the same as GND. The pin is floating. By using the internal pullup resistor the pin is HIGH when the button is not connected to GND. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-16T12:19:30.637" LastActivityDate="2016-02-16T12:19:30.637" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20750" PostTypeId="1" CreationDate="2016-02-16T13:02:15.023" Score="2" ViewCount="416" Body="&lt;p&gt;I have designed a circuit for an SGX EC410 oxygen sensor by using these application note -PAGE 4, FIGURE 4 - (&lt;a href=&quot;http://www.sgxsensortech.com/content/uploads/2014/08/A1A-EC_SENSORS_AN2-Design-of-Electronics-for-EC-Sensors-V3.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.sgxsensortech.com/content/uploads/2014/08/A1A-EC_SENSORS_AN2-Design-of-Electronics-for-EC-Sensors-V3.pdf&lt;/a&gt;). When I try to measure the biased voltage between working (SENS) and reference (REF) electrode, the value of -600 mV is held for about one second and goes down to few milli volts rapidly. The same happens when I connect the sensor without voltmeter. Am I doing something totally wrong, or the circuit is not quite right? &#xA;&lt;a href=&quot;https://i.stack.imgur.com/Zc5Ii.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zc5Ii.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;     &lt;/p&gt;&#xA;" OwnerUserId="13392" LastActivityDate="2016-02-16T16:25:32.347" Title="Problem with biased circuit for oxygen sensor (SGX EC410)" Tags="|sensors|signal-processing|" AnswerCount="0" CommentCount="1" ClosedDate="2016-02-16T16:25:59.877" ContentLicense="CC BY-SA 3.0" />
  <row Id="20751" PostTypeId="1" CreationDate="2016-02-16T14:59:47.390" Score="0" ViewCount="179" Body="&lt;p&gt;Recently I ordered some ATtiny85's from &lt;a href=&quot;http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_2151312_-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Jameco&lt;/a&gt;, and I've been trying to upload code to them through an Arduino Uno, following the instructions from &lt;a href=&quot;https://www.youtube.com/watch?v=9LjfkjwMqXI&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video on YouTube&lt;/a&gt;. I've been getting a lot of unexpected errors and I am now wondering if the chips I bought are the problem. Here are the specs from the Jameco website:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Flash (Kbytes): 8 Kbytes&lt;/p&gt;&#xA;&lt;p&gt;Pin Count: 8&lt;/p&gt;&#xA;&lt;p&gt;Max. Operating Frequency: 20 MHz&lt;/p&gt;&#xA;&lt;p&gt;Power Supply: 2.7 - 5.5V&lt;/p&gt;&#xA;&lt;p&gt;Operational Range: Industrial (A) (-40°C to 85°C)&lt;/p&gt;&#xA;&lt;p&gt;CPU: 8-bit AVR&lt;/p&gt;&#xA;&lt;p&gt;Number of Touch Channels: 3&lt;/p&gt;&#xA;&lt;p&gt;Hardware QTouch Acquisition: No&lt;/p&gt;&#xA;&lt;p&gt;Max I/O Pins: 6&lt;/p&gt;&#xA;&lt;p&gt;Ext Interrupts: 6&lt;/p&gt;&#xA;&lt;p&gt;USB Speed: No&lt;/p&gt;&#xA;&lt;p&gt;USB Interface: No&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Does the &amp;quot;USB Speed: No; USB Interface: No&amp;quot; mean these aren't programmable by my set up? Or is there is anything else I should know about these chips? Do I need to get new ones that are different?&lt;/p&gt;&#xA;" OwnerUserId="17202" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-06-23T15:52:18.603" Title="Programming an ATtiny85" Tags="|attiny|avr|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20752" PostTypeId="1" AcceptedAnswerId="20755" CreationDate="2016-02-16T15:34:06.060" Score="2" ViewCount="1248" Body="&lt;p&gt;I bought some material on the net to start working with Arduino. I didn't want to buy an Arduino, since it costs a bit too much IMHO, so I bought an ATMega328P-PU, and made an Arduino on a breadboard. However, when I use my USBasp to program it it says that he can't set sck period (settings are: Arduino Uno as Board, USBasp as Programmer). It says that it has loaded the bootloader/program anyway, so I tried to go on and ignore it. The blink program can be loaded via programmer, but it doesn't blink (I'm using a small lamp, connecting it directly to 5V and ground works). Here I describe the circuit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;First Atmega Pin, Arduino Reset -&gt; 10 kOhm Resistor (Brown, Black, Black, Red, Brown) -&gt; Ground (not GND pin);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;1st pin, Arduino Reset -&gt; also to USBasp RST;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;7th pin, Arduino VCC -&gt; directly to 5V (and USBasp VCC);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;8th, GND -&gt; directly to Ground (and USBasp GND);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;9th, XTAL -&gt; to one pin of the 16MHz Crystal Oscillator, and to 22 pF capacitor, which connects to ground (not the pin);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;10th, XTAL -&gt; exactly as above, but it's connected to the other pin of the same crystal;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;17th, digital 11 -&gt; USBasp MOSI;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;18th, dig 12 -&gt; USBasp MISO;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;19th, dig 13 -&gt; USBasp SCK, and to the lamp whose other pin goes to ground (neither pin nor direct works), but the lamp needs to be disconnected while loading programs to prevent errors (target not responding);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;20th, AVCC, and 21st, AREF -&gt; directly to 5V;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;22nd -&gt; directly to ground (not pin).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16991" LastEditorUserId="10794" LastEditDate="2016-02-16T21:45:08.520" LastActivityDate="2016-02-16T21:45:08.520" Title="ATMega328P-PU not working" Tags="|atmega328|hardware|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20753" PostTypeId="2" ParentId="20752" CreationDate="2016-02-16T15:42:21.143" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The blink program can be loaded via programmer, but it doesn't blink (I'm using a small lamp, connecting it directly to 5V and ground works).&lt;/p&gt;&#xA;&lt;p&gt;19th, dig 13 -&amp;gt; USBasp SCK, and to the lamp whose other pin goes to ground (neither pin nor direct works), but the lamp needs to be disconnected while loading programs to prevent errors (target not responding);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The lamp needs to be low power (&amp;lt; 20 mA) to work this way. If it uses more power you will burn the MCU pin.&lt;/p&gt;&#xA;&lt;p&gt;Use a LED and a resistor instead. Or at least use a voltmeter.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;21st, AREF -&amp;gt; directly to 5V;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is not a good idea. Should be capacitor to ground. See for instance &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uno schematics&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-16T15:47:43.830" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20755" PostTypeId="2" ParentId="20752" CreationDate="2016-02-16T15:55:02.937" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;First Atmega Pin, Arduino Reset -&gt; 10 kOhm Resistor (Brown, Black, Black, Red, Brown) -&gt; Ground (not GND pin);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So it's permanently in RESET mode then? How can it ever do anything if you're holding it in RESET all the time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RESET should be pulled UP by the resistor, not DOWN.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-16T15:55:02.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20756" PostTypeId="2" ParentId="8651" CreationDate="2016-02-16T16:43:25.053" Score="1" Body="&lt;p&gt;The simplest way I've found to do this is store the libraries in your local sketch directory and create a symbolic link in the [HOME]/Arduino/libraries directory.  Then you can check them in to Git easily with your sketch/project and Arduino's still happy because the libraries are accessible in the global folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe even create an install script that creates these links automatically and check that into Git too.&lt;/p&gt;&#xA;" OwnerUserId="18414" LastActivityDate="2016-02-16T16:43:25.053" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20757" PostTypeId="2" ParentId="20734" CreationDate="2016-02-16T17:35:54.983" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;clearly it's not flashing every second.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is it flashing about every .73 seconds? That would be the period you'd expect if you have a 22.000MHz crystal: period = (16/22 * 1.00 sec). (If so, that is a rather high over-clock rate for the chip but suggests just how hardy they really are.)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I haven't bought any 16 MHz crystal. What will I do?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Buy a 16MHz crystal. That's the right fix. But you might (if I guessed correctly that you have a 22MHz crystal) - &lt;em&gt;might&lt;/em&gt; - get away with trying a baud rate of (16/22) times your present baud rate, de-rating it to compensate for the clock rate. Be as precise as you can. You'll need to reprogram the chip with your Arduino board because the chip's bootloader expects a 16MHz clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if it's not 22MHz, you could time a number of blinks (50 or 100), calculate the clock rate error, and re-calculate a baud rate the way I did above. Use a lower baud rate to start with; it is likely to be less affected by small timing errors.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-02-16T22:49:18.940" LastActivityDate="2016-02-16T22:49:18.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20758" PostTypeId="1" AcceptedAnswerId="20763" CreationDate="2016-02-16T18:51:35.413" Score="1" ViewCount="7180" Body="&lt;p&gt;Here's the whole error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Arduino: 1.6.7 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA; *\readMifare\readMifare.ino: In function 'void loop()':&#xA;&#xA; readMifare:113: error: expected primary-expression before ']' token&#xA;&#xA;    if (uid[] == { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {&#xA;&#xA;            ^&#xA;&#xA; readMifare:113: error: expected primary-expression before '{' token&#xA;&#xA;    if (uid[] == { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {&#xA;&#xA;                 ^&#xA;&#xA; readMifare:113: error: expected ')' before '{' token&#xA;&#xA; readMifare:121: error: expected '}' at end of input&#xA;&#xA;    }&#xA;&#xA;    ^&#xA;&#xA; exit status 1&#xA; expected primary-expression before ']' token&#xA;&#xA;   This report would have more information with&#xA;   &quot;Show verbose output during compilation&quot;&#xA;   enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Wire.h&amp;gt;&#xA; #include &amp;lt;SPI.h&amp;gt;&#xA; #include &amp;lt;Adafruit_PN532.h&amp;gt;&#xA;&#xA; // If using the breakout with SPI, define the pins for SPI communication.&#xA; #define PN532_SCK  (2)&#xA; #define PN532_MOSI (3)&#xA; #define PN532_SS   (4)&#xA; #define PN532_MISO (5)&#xA; // If using the breakout or shield with I2C, define just the pins connected&#xA; // to the IRQ and reset lines.  Use the values below (2, 3) for the shield!&#xA; #define PN532_IRQ   (2)&#xA; #define PN532_RESET (3)  // Not connected by default on the NFC Shield&#xA;&#xA; // Uncomment just _one_ line below depending on how your breakout or shield&#xA; // is connected to the Arduino:&#xA;&#xA; // Use this line for a breakout with a software SPI connection (recommended):&#xA; Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);&#xA;&#xA; // Use this line for a breakout with a hardware SPI connection.  Note that&#xA; // the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's&#xA; // hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are&#xA; // SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.&#xA; //Adafruit_PN532 nfc(PN532_SS);&#xA;&#xA; // Or use this line for a breakout or shield with an I2C connection:&#xA; //Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);&#xA;&#xA; #if defined(ARDUINO_ARCH_SAMD)&#xA; // for Zero, output on USB Serial console, remove line below if using      programming port to program the Zero!&#xA; // also change #define in Adafruit_PN532.cpp library file&#xA; #define Serial SerialUSB&#xA; #endif&#xA; #include &amp;lt;Servo.h&amp;gt;&#xA;&#xA; Servo servo1;&#xA;&#xA; void setup(void) {&#xA;   #ifndef ESP8266&#xA;   while (!Serial); // for Leonardo/Micro/Zero&#xA;   #endif&#xA;   Serial.begin(115200);&#xA;   Serial.println(&quot;Hello!&quot;);&#xA;&#xA;   nfc.begin();&#xA;&#xA;   uint32_t versiondata = nfc.getFirmwareVersion();&#xA;   if (! versiondata) {&#xA;     Serial.print(&quot;Didn't find PN53x board&quot;);&#xA;     while (1); // halt&#xA;   }&#xA;   // Got ok data, print it out!&#xA;   Serial.print(&quot;Found chip PN5&quot;); Serial.println((versiondata&amp;gt;&amp;gt;24) &amp;amp; 0xFF, HEX); &#xA;   Serial.print(&quot;Firmware ver. &quot;); Serial.print((versiondata&amp;gt;&amp;gt;16) &amp;amp; 0xFF, DEC); &#xA;   Serial.print('.'); Serial.println((versiondata&amp;gt;&amp;gt;8) &amp;amp; 0xFF, DEC);&#xA;&#xA;   // configure board to read RFID tags&#xA;   nfc.SAMConfig();&#xA;&#xA;   Serial.println(&quot;Waiting for an ISO14443A Card ...&quot;);&#xA;   servo1.attach(9); &#xA; }&#xA;&#xA;&#xA; void loop(void) {&#xA;   uint8_t success;&#xA;   uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID&#xA;   uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)&#xA;&#xA;   // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found&#xA;   // 'uid' will be populated with the UID, and uidLength will indicate&#xA;   // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)&#xA;   success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;&#xA;   if (uid[] = { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {&#xA;&#xA;      int position;&#xA;      for(position = 0; position &amp;lt; 180; position += 2){&#xA;       servo1.write(position);&#xA;       delay(20);&#xA;      }&#xA;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that I'm using an example from the &lt;em&gt;Adafruit official PN532 library examples&lt;/em&gt; and trying to edit it.&lt;/p&gt;&#xA;" OwnerUserId="18415" LastEditorUserId="6936" LastEditDate="2016-02-17T06:28:56.497" LastActivityDate="2019-11-07T13:21:36.877" Title="Exit status 1 expected primary-expression before ']' Arduino" Tags="|arduino-uno|library|adafruit|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20759" PostTypeId="2" ParentId="20758" CreationDate="2016-02-16T19:12:48.163" Score="1" Body="&lt;p&gt;You probably need something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t uidTarget[] = { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 };&#xA;&#xA;...&#xA;if (success &amp;amp;&amp;amp; !strncmp((const char*) uidTarget,(const char*)uidSource,8)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your '=' tries to do an assignment, and an '==' would check if the pointers to the arrays are identical, rather than the contents of the arrays.  strncmp() tests equality of strings of characters, and the (const char*) casts the uint8_t values as characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon's answer is better.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-02-16T21:41:40.170" LastActivityDate="2016-02-16T21:41:40.170" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20760" PostTypeId="2" ParentId="20700" CreationDate="2016-02-16T19:36:50.973" Score="2" Body="&lt;p&gt;How fast is your system compared to the loop() sampling time?  Does (100-map((ax+10900),-1300,1300,0,1024)) change appreciably during the sub-millisecond loop()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With kI=5, an error of only 10 will saturate your 0-255 speed output in 26 iterations of loop(), potentially producing the behavior you see.  If you don't have control of your sampling time, the integral error can wind up (or down) to the process limits very quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Map&lt;/a&gt; map() only linearly transforms the input data to the output data, but does not constrain() it to those limits.  If ax=-9000, then val would be greater than 1024.   Still, taking the normal working range of ax+10900 to be (-1300,1300) which is then mapped into  (0,1024), the Kp=2 term with a setpoint of 100 would produce a range of (-200,2048) constrained to the default (0,255) limits.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working backwards from the setpoint of 100, through the 0-1024 map is 0.0975 along the (-1300 to 1300) range, or val = -949, or ax = -11849.  And the kP=2 times the mapping factor of 1024/2600 would change the output by 2*1024/2600=0.79 points for each step difference of ax from -11849.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/MPU-6050&lt;/a&gt; pages says the acceleration registers are 16 bit with high sensitivity, and suggests that 50 points of noise is a small variation.  If the sensor set for 16 bits for +/-2G into ax, then, each step change 60 micro-G.  If that is the source of your ax, then the small variations could easily saturate your control system, making it bang-bang between its output limits with only milli-G variations at the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Slow down your sampling time, reduce kI, and think of your Kp, Ki, and Kd as conversions of your measured and translated variable ax errors into output space (0-255 speed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in choosing a sampling time, consider how often you want the PID to make adjustments to the process.  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-02-18T12:47:44.900" LastActivityDate="2016-02-18T12:47:44.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20761" PostTypeId="1" AcceptedAnswerId="20762" CreationDate="2016-02-16T20:41:20.300" Score="-1" ViewCount="656" Body="&lt;p&gt;So I have a programme that loads a text file from an sd card into a string array. Each line in the text file is stored in a different string in a string array. Well its supposed to be.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;file = SD.open(&quot;/classes/basic.txt&quot;, FILE_READ);&#xA;Serial.print(&quot;Reading, Checking and Compiling \n\n\n&quot;);  &#xA;&#xA;for(int i = 0; i &amp;lt; sizeof(result)-1;i++){&#xA; while(file.available()) {&#xA;  character23 = file.read();&#xA;  content.concat(character23); &#xA;&#xA;}    &#xA;if (content != &quot;&quot;) {     &#xA;  result[i] = content;&#xA;    Serial.println(content);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want each line in the txt file to be stored in a different string in the array, in chronological order and each string has to be accessible individually. The problem with this code is that it stores the whole text file in one string. How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: here is what I have now&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  file = SD.open(&quot;/classes/basic.txt&quot;, FILE_READ);&#xA;  Serial.print(&quot;Reading, Checking and Compiling \n\n\n&quot;);  &#xA;&#xA; for(int i = 0; i &amp;lt; sizeof(result)-1;i++){&#xA;   while(file.available()) {&#xA;  character23 = file.read();&#xA;  if (character23 == '^') break;&#xA;  content.concat(character23); &#xA;&#xA;}    &#xA;if (content != &quot;&quot;) {     &#xA;  result[i] = content;&#xA;  Serial.println(content);&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&#xA; Serial.println(result[3]);&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="16124" LastEditDate="2016-02-16T21:20:23.550" LastActivityDate="2016-02-16T21:20:23.550" Title="Arduino array length" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20762" PostTypeId="2" ParentId="20761" CreationDate="2016-02-16T20:50:36.273" Score="1" Body="&lt;p&gt;To do that, you need to read the file until you reach a line break. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(file.available()) {&#xA;  character23 = file.read();&#xA;  content.concat(character23);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(file.available()) {&#xA;   character23 = file.read();&#xA;   if (character23 == '\n') break;&#xA;   content.concat(character23);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6424" LastActivityDate="2016-02-16T20:50:36.273" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="20763" PostTypeId="2" ParentId="20758" CreationDate="2016-02-16T21:10:05.733" Score="3" Body="&lt;p&gt;I wouldn't use &lt;code&gt;strncmp&lt;/code&gt; because the UID might have zeroes in it. This looks safer:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;   uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID&#xA;   uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)&#xA;&#xA;   const uint8_t wantedUid [] = { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 };&#xA;&#xA;   // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found&#xA;   // 'uid' will be populated with the UID, and uidLength will indicate&#xA;   // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)&#xA;   success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;&#xA;   if (success &amp;amp;&amp;amp; &#xA;      uidLength == sizeof (wantedUid) &amp;amp;&amp;amp;&#xA;      memcmp (uid, wantedUid, sizeof wantedUid) == 0) {&#xA;      ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I threw in a test for the uidLength being the expected size, otherwise you might find a 4-byte card happens to match the first four bytes of the wanted UID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;memcmp&lt;/code&gt; compares a block of memory for the number of bytes you specify. It returns zero on a match.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-16T21:10:05.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20765" PostTypeId="2" ParentId="20751" CreationDate="2016-02-16T21:53:03.723" Score="2" Body="&lt;p&gt;Before you panic (try not to panic) and buy new chips, test the existing ones. See my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11633&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about detecting chip signatures&lt;/a&gt; which has links to &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow noreferrer&quot;&gt;code on Github&lt;/a&gt; for a sketch you can run on your Uno, to test the ATtiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OMHlr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OMHlr.jpg&quot; alt=&quot;Chip detector wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also upload code from a .hex file (which the IDE produces) by using a different sketch (same code link) from &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow noreferrer&quot;&gt;this page about a hex uploader&lt;/a&gt; and wiring like this (you also need an SD card adapter):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7JMKQ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7JMKQ.jpg&quot; alt=&quot;Chip programmer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The first sketch and wiring should at least confirm your chips are OK. The second one is an alternative way of programming them.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-16T21:53:03.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20770" PostTypeId="1" AcceptedAnswerId="20795" CreationDate="2016-02-16T23:52:02.043" Score="1" ViewCount="4537" Body="&lt;p&gt;I'm working on a project where I need a high torque stepper motor. The stepper motor being used is rated at 12 - 24 volts and when I used a 12 volt battery supply composed of 8 AA batteries it appeared to work fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because I wanted higher torque I set the pot on the Easy Driver to 0.5 amps which is within what was recommended for the motor, and used a Lithium Ion battery originally being used for a power drill rated at 18V and 1.5Ah. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connected the battery to the easy driver the motor got very hot and would shake when I tried to turn it but not turn. Now the motor will not work with the 8 AA batteries either. Heres a link to the motor &lt;a href=&quot;http://www.ebay.com/itm/US-Ship-OSM-5-1-Planetary-Gearbox-Nema-8-Stepper-Motor-Samll-Size-High-Torque-/231616295885?hash=item35ed6833&quot; rel=&quot;nofollow noreferrer&quot;&gt;US Ship OSM 5:1 Planetary Gearbox Nema 8 Stepper Motor Samll Size High Torque&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/snDwc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/snDwc.jpg&quot; alt=&quot;Project&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What did I do wrong and how can I fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I am using a photon as the micro controller and the motor is being controlled using the Blynk app I eliminated the chance of it having to do with the photon or Blynk App.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found out that the battery I'm using is the Makita BL1815 and it is really composed of 2 batteries which are both rated at 15C. I am not sure if C-rating adds or stays the same when you are using two batteries. When I measure the Voltage on the test points I get 4.27V and when using a formula to find current for the Easy Driver I get 0.480A.&lt;/p&gt;&#xA;" OwnerUserId="18421" LastEditorUserId="-1" LastEditDate="2016-02-18T01:50:25.657" LastActivityDate="2016-02-18T01:50:25.657" Title="Powering a stepper motor" Tags="|motor|battery|stepper|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20771" PostTypeId="1" AcceptedAnswerId="20786" CreationDate="2016-02-17T00:23:46.860" Score="1" ViewCount="256" Body="&lt;p&gt;I'm having problem  on how can I use IMU and NRF24 together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that i'm trying to use,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /*&#xA; Copyright (C) 2012 James Coliz, Jr. &amp;lt;maniacbug@ymail.com&amp;gt;&#xA; This program is free software; you can redistribute it and/or&#xA; modify it under the terms of the GNU General Public License&#xA; version 2 as published by the Free Software Foundation.&#xA;&#xA; Update 2014 - TMRh20&#xA;*/&#xA;/**&#xA;* Simplest possible example of using RF24Network &#xA;*&#xA;* TRANSMITTER NODE&#xA;* Every 2 seconds, send a payload to the receiver node.&#xA;*/&#xA;#include &amp;lt;RF24Network.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;RTIMUSettings.h&quot;&#xA;#include &quot;RTIMU.h&quot;&#xA;#include &quot;RTFusionRTQF.h&quot; &#xA;#include &quot;CalLib.h&quot;&#xA;&#xA;&#xA;RTIMU *imu;                                           // the IMU object&#xA;RTFusionRTQF fusion;                                  // the fusion object&#xA;RTIMUSettings settings;                               // the settings object&#xA;&#xA;//  DISPLAY_INTERVAL sets the rate at which results are displayed&#xA;&#xA;#define DISPLAY_INTERVAL  300                         // interval between      &#xA;pose displays&#xA;&#xA;//  SERIAL_PORT_SPEED defines the speed to use for the debug serial port&#xA;&#xA;#define  SERIAL_PORT_SPEED  11520&#xA;unsigned long lastDisplay1;&#xA;unsigned long lastRate1;&#xA;int sampleCount1;&#xA;&#xA;&#xA;&#xA;&#xA; RF24 radio(7,8);                    // nRF24L01(+) radio attached using    &#xA; Getting Started board &#xA; RF24Network network(radio);          // Network uses that radio&#xA; const uint16_t this_node = 01;        // Address of our node in Octal  &#xA; format&#xA; const uint16_t other_node = 00;       // Address of the other node in Octal   &#xA; format&#xA; const unsigned long interval = 2000; //ms  // How often to send 'hello   &#xA; world to the other unit&#xA; unsigned long last_sent;             // When did we last send?&#xA; unsigned long packets_sent;          // How many have we sent already&#xA; struct payload_t {                  // Structure of our payload&#xA; unsigned long ms;&#xA; unsigned long counter;&#xA; };&#xA; void setup(void)&#xA; {&#xA; int errcode;&#xA;&#xA; Serial.begin(SERIAL_PORT_SPEED);&#xA; Wire.begin();&#xA; imu = RTIMU::createIMU(&amp;amp;settings);                        // create the imu  &#xA; object&#xA;&#xA; Serial.print(&quot;ArduinoIMU starting using device &quot;); Serial.println(imu- &#xA; &amp;gt;IMUName());&#xA; if ((errcode = imu-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA; Serial.print(&quot;Failed to init IMU: &quot;); Serial.println(errcode);&#xA; }&#xA;&#xA; if (imu-&amp;gt;getCalibrationValid())&#xA;    Serial.println(&quot;Using compass calibration&quot;);&#xA; else&#xA;    Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&#xA; lastDisplay = lastRate = millis();&#xA; sampleCount = 0;&#xA;&#xA;// Slerp power controls the fusion and can be between 0 and 1&#xA;// 0 means that only gyros are used, 1 means that only accels/compass are used&#xA;// In-between gives the fusion mix.&#xA;&#xA;fusion.setSlerpPower(0.02);&#xA;&#xA;// use of sensors in the fusion algorithm can be controlled here&#xA;// change any of these to false to disable that sensor&#xA;&#xA;fusion.setGyroEnable(true);&#xA;fusion.setAccelEnable(true);&#xA;fusion.setCompassEnable(true);&#xA;&#xA;Serial.println(&quot;RF24Network/examples/helloworld_tx/&quot;);&#xA;&#xA;SPI.begin();&#xA;radio.begin();&#xA;network.begin(/*channel*/ 90, /*node address*/ this_node);&#xA;}&#xA;void loop() {&#xA;&#xA;unsigned long now1 = millis();&#xA;unsigned long delta1;&#xA;int loopCount1 = 1;&#xA;&#xA;while (imu-&amp;gt;IMURead()) {                                // get the latest  &#xA;data if ready yet&#xA;// this flushes remaining data in case we are falling behind&#xA;if (++loopCount1 &amp;gt;= 10)&#xA;        continue;&#xA;    fusion.newIMUData(imu-&amp;gt;getGyro(), imu-&amp;gt;getAccel(), imu-&amp;gt;getCompass(),   &#xA;imu-&amp;gt;getTimestamp());&#xA;    sampleCount++;&#xA;    if ((delta1 = now1 - lastRate1) &amp;gt;= 1000) {&#xA;        Serial.print(&quot;Sample rate: &quot;); Serial.print(sampleCount);&#xA;        if (imu-&amp;gt;IMUGyroBiasValid())&#xA;            Serial.println(&quot;, gyro bias valid&quot;);&#xA;        else&#xA;            Serial.println(&quot;, calculating gyro bias&quot;);&#xA;&#xA;        sampleCount = 0;&#xA;        lastRate1 = now1;&#xA;    }&#xA;    if ((now1 - lastDisplay1) &amp;gt;= DISPLAY_INTERVAL) {&#xA;        lastDisplay1 = now1;&#xA;     RTMath::display(&quot;Gyro:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getGyro());                // gyro data&#xA;      RTMath::display(&quot;Accel:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getAccel());              // accel data&#xA;      RTMath::display(&quot;Mag:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getCompass());              // compass data&#xA;        RTMath::displayRollPitchYaw(&quot;Pose:&quot;, (RTVector3&amp;amp;)fusion.getFusionPose()); // fused output&#xA;       Serial.println();&#xA;    }&#xA;}&#xA;&#xA;   network.update();                          // Check the network regularly&#xA;&#xA;  unsigned long now = millis();              // If it's time to send a &#xA;  message, send it!&#xA;  if ( now - last_sent &amp;gt;= interval  )&#xA;  {&#xA;  last_sent = now;&#xA;  Serial.print(&quot;Sending...&quot;);&#xA;  payload_t payload = { millis(), packets_sent++ };&#xA;   RF24NetworkHeader header(/*to node*/ other_node);&#xA;   bool ok = network.write(header,&amp;amp;payload,sizeof(payload));&#xA;  if (ok)&#xA;  Serial.println(&quot;ok.&quot;);&#xA;  else&#xA;  Serial.println(&quot;failed.&quot;);&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My question is what  should I put in this part&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   [code]struct payload_t {                  // Structure of our payload&#xA;    unsigned long ms;&#xA;    unsigned long counter;&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that the output for &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; RTMath::display(&quot;Gyro:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getGyro());                //  &#xA; gyro data&#xA;      RTMath::display(&quot;Accel:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getAccel());                &#xA; // accel data&#xA;      RTMath::display(&quot;Mag:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getCompass());              &#xA; // compass data&#xA;      RTMath::displayRollPitchYaw(&quot;Pose:&quot;, &#xA; (RTVector3&amp;amp;)fusion.getFusionPose()); // fused output[/code] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will Transmit to the RX ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will I put in this part :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   Serial.print(&quot;Sending...&quot;);&#xA;   payload_t payload = { millis(), packets_sent++ };&#xA;   RF24NetworkHeader header(/*to node*/ other_node);&#xA;   bool ok = network.write(header,&amp;amp;payload,sizeof(payload));&#xA;   if (ok)&#xA;   Serial.println(&quot;ok.&quot;);&#xA;   else&#xA;   Serial.println(&quot;failed.&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help me guys. Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="16191" LastEditorUserId="16191" LastEditDate="2016-02-18T01:17:48.407" LastActivityDate="2016-02-18T01:17:48.407" Title="Don't know how to work IMU and NRF24 together" Tags="|arduino-mega|mpu6050|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20773" PostTypeId="1" CreationDate="2016-02-17T02:16:41.623" Score="3" ViewCount="2351" Body="&lt;p&gt;I have an Arduino MEGA hooked up with a NRF24L01, and working nicely, talking with another Arduino Uno. It works as described, power supply to 3.3V, and SPI lines (MISO,MOSI,CLK) connected directly to the Arduino;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I hook up a level converter in the end (5V to 3V, bidirectional) (making the NRF module in the middle, like in a T connection), the module stops working, and I don't know why. How does the level converter module is interfering in the connection? Is there any way I can prevent this and use it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I intend in adding in the future, modules that talk in 3.3V SPI;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the level converter I'm using:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jHsyc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jHsyc.jpg&quot; alt=&quot;JY-MCU 5V-3V four channel convert module&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://ralphfox.at-the.space/imglink/hGTdg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;at-the.space&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it is because of the pullups (5 think that these 10k&amp;Omega; resistors are pull-ups, but I'm a noob in that part), but I really don't know if that is the problem, as the seller advertises it as being compatible with SPI, I2C, and UART. I have successfully used these for a UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked &lt;a href=&quot;https://arduino.stackexchange.com/questions/9616/slaving-multiple-arduinos-via-spi&quot;&gt;Slaving multiple Arduinos via SPI&lt;/a&gt; and tried using an external 5V supply, and a 3.3V supply, but no dice.. However, the 3V side has no connections to it; But, being bi-directional, I don't think there is a problem with this...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found that 74HCT245D works very well for this, but I'd like to know why with the level converter from JY-MCU this won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Providing the library and connections just in case (the module works without the level converter):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Library &amp;amp; sketch comes from &lt;a href=&quot;http://tmrh20.github.io/RF24/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Optimized High Speed NRF24L01+ Driver Class Documenation&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connection:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;NRF2401 Pinout:&#xA;&lt;a href=&quot;http://ralphfox.at-the.space/imglink/nrf24l01.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;NRF24l01 http://ralphfox.at-the.space/imglink/nrf24l01.jpg&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;My connection:&#xA;&lt;a href=&quot;http://ralphfox.at-the.space/imglink/nrf_bb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino with NRF24l01 and Level Converter  http://ralphfox.at-the.space/imglink/nrf_bb.png&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18426" LastEditorUserId="27346" LastEditDate="2019-03-09T22:25:15.090" LastActivityDate="2019-03-09T22:25:15.090" Title="SPI with a level converter in the other end of connection" Tags="|arduino-mega|voltage-level|spi|nrf24l01+|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="20774" PostTypeId="1" CreationDate="2016-02-17T03:30:02.440" Score="6" ViewCount="3519" Body="&lt;p&gt;When I learn the tutorial in&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/AnalogReadSerial&quot; rel=&quot;noreferrer&quot;&gt;Analog Read Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalReadSerial&quot; rel=&quot;noreferrer&quot;&gt;Digital Read Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;both of the code examples have a line of code of &lt;code&gt;delay(1)&lt;/code&gt; and I cannot understand the comments clearly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; delay(1);        // delay in between reads for stability&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;stability&lt;/strong&gt; for/of what?&lt;/p&gt;&#xA;" OwnerUserId="18431" LastEditorUserId="6936" LastEditDate="2016-02-17T06:52:06.317" LastActivityDate="2016-02-23T02:19:38.637" Title="Why need a delay between readings?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20775" PostTypeId="2" ParentId="20774" CreationDate="2016-02-17T04:34:46.220" Score="9" Body="&lt;p&gt;Those delays are nonsense. They don't add to the stability of anything. The best you could say is that they stop you spamming your serial port. (However 1 ms is not very long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes people throw in a delay because &quot;it seems to work better&quot; without examining the underlying cause. I would speculate that in this case the author may have been using delays to improve receiving serial data, and got the idea into their head that the occasional delay now and then &quot;improves stability&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-17T04:34:46.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20776" PostTypeId="2" ParentId="20323" CreationDate="2016-02-17T10:00:29.337" Score="0" Body="&lt;p&gt;The ESP-12 (don't know about other versions) does have one ADC pin.&#xA;&lt;a href=&quot;https://github.com/esp8266/Arduino/blob/master/doc/reference.md#analog-input&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino/blob/master/doc/reference.md#analog-input&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know how much your pins display needs. If this is more than one, then you will need a seperate ADC. There are many available as a single chip, but you could also use an arduino as you're doing now.&lt;/p&gt;&#xA;" OwnerUserId="18440" LastActivityDate="2016-02-17T10:00:29.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20777" PostTypeId="2" ParentId="19832" CreationDate="2016-02-17T10:28:38.617" Score="1" Body="&lt;p&gt;While possibly not &quot;the best&quot;, I have found I2C to be sufficient for &lt;a href=&quot;https://github.com/mamert/iot-a&quot; rel=&quot;nofollow&quot;&gt;my needs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple to use, if a bit different conceptually (master-slave).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My tests have shown it to be reliable thus far, zero errors over 20 minutes (sending &amp;amp; receiving 20 bytes each time), as long as there were sufficient pauses between calls.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am going to make the Arduino switch its i2c master/slave role based on the state of other pins. Master most of the time (to use a DS1307 RTC, etc), switching to slave whenever NodeMCU (which can only work as master) has something to say. Thanks to Zeph for the idea.&lt;/p&gt;&#xA;" OwnerUserId="16606" LastEditorUserId="16606" LastEditDate="2016-03-08T09:10:06.927" LastActivityDate="2016-03-08T09:10:06.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20778" PostTypeId="2" ParentId="8651" CreationDate="2016-02-17T10:34:29.490" Score="5" Body="&lt;p&gt;I recently tested this local library structure. It works with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;libs/MyNewLib/MyNewLib.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE 1.6.7 build pre-processing will even pick up the source code for the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-17T10:34:29.490" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20779" PostTypeId="2" ParentId="19632" CreationDate="2016-02-17T10:45:53.360" Score="1" Body="&lt;p&gt;Not all devices (including) phones respond to ICMP Ping. This may differ for each (mobile) OS and version and phone make and model. But assuming your phone does respond to ping...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the ESP with just the default firmware (a waste of a perfectly capable microcontroller), then indeed use the AT+PING command from the other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use the ESP directly, you may be out of luck. Both the nocemcu lua firmware and the arduino api for esp seem to lack icmp ping functionality.&lt;/p&gt;&#xA;" OwnerUserId="18440" LastActivityDate="2016-02-17T10:45:53.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20780" PostTypeId="1" AcceptedAnswerId="20781" CreationDate="2016-02-17T11:32:48.537" Score="1" ViewCount="22221" Body="&lt;p&gt;Hello  have an array of strings that loads strings from a txt file on an sd card.&#xA;The txt file on the SD card can change from time to time(not while the Arduino is running).I want to be able to get the amount of elements in the array after the txt file has been loaded into the array. The txt file has lines of txt in it. Each line in the file is put into a string in the array. I want to be able to get the amount of elements in the array how can I do this?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2019-10-26T01:21:55.717" Title="Arduino how to get amount of elements in an array?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20781" PostTypeId="2" ParentId="20780" CreationDate="2016-02-17T11:38:26.613" Score="6" Body="&lt;p&gt;You can't. That concept does not exist in C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An array has a fixed size - as such you know how many elements are in it, since that is the number of elements you created it with.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String myStrings[4];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is an array of 4 String objects. It has 4 elements. It will always have 4 elements.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-17T11:38:26.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20782" PostTypeId="1" AcceptedAnswerId="20790" CreationDate="2016-02-17T12:27:26.197" Score="0" ViewCount="1500" Body="&lt;p&gt;I have a Genuino 101 which has a built in Bluetooth LE module. I have been trying to connect this to my phone using phonegap. I have been using &lt;a href=&quot;https://github.com/randdusing/cordova-plugin-bluetoothle&quot; rel=&quot;nofollow&quot;&gt;cordova-plugin-bluetootle&lt;/a&gt; and with it I have been able to receive data from the arduino and display that data on the phone.&lt;br&gt;&#xA;I tired adapting it so that I could send data from the phone to the arduino. I noticed in the CurieBle examples there was a project called &quot;Callback LED&quot; but when I connected to the Arduino from the Phone gap app I noticed in the debug message about characteristics it said &lt;code&gt;&quot;properties&quot;:{&quot;notify&quot;: true, &quot;read&quot;: true}&lt;/code&gt; but nothing about write. I tried writing &quot;Hello world&quot; (converted into bytes then encoded string) I got an error similar to (I couldn't copy it exactly as it was an alert on the phone): &lt;code&gt;&quot;error&quot;: &quot;write&quot;, &quot;message&quot;: &quot;Error Domain=CBATTErrorDomain Code = 3 \&quot;Writing is not permitted.\&quot; ...&quot;...&lt;/code&gt;There is more detail to the error message that is not at all relevant and is slightly repetitive.&lt;br&gt;&#xA;Here is the arduino code (which is almost straight from the example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;CurieBle.h&amp;gt;&#xA;&#xA;const int ledPin = 13; // set ledPin to use on-board LED&#xA;BLEPeripheral blePeripheral; // create peripheral instance&#xA;&#xA;BLEService ledService(&quot;19B10000-E8F2-537E-4F6C-D104768A1214&quot;); // create service&#xA;&#xA;// create switch characteristic and allow remote device to read and write&#xA;BLECharCharacteristic switchChar(&quot;19B10001-E8F2-537E-4F6C-D104768A1214&quot;, BLERead | BLEWrite);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT); // use the LED on pin 13 as an output&#xA;  digitalWrite(ledPin, HIGH);&#xA;  while(!Serial);&#xA;  digitalWrite(ledPin, LOW);&#xA;  // set the local name peripheral advertises&#xA;  blePeripheral.setLocalName(&quot;LEDCB&quot;);&#xA;  // set the UUID for the service this peripheral advertises&#xA;  blePeripheral.setAdvertisedServiceUuid(ledService.uuid());&#xA;&#xA;  // add service and characteristic&#xA;  blePeripheral.addAttribute(ledService);&#xA;  blePeripheral.addAttribute(switchChar);&#xA;&#xA;  // assign event handlers for connected, disconnected to peripheral&#xA;  blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);&#xA;  blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);&#xA;&#xA;  // assign event handlers for characteristic&#xA;  switchChar.setEventHandler(BLEWritten, switchCharacteristicWritten);&#xA;// set an initial value for the characteristic&#xA;  switchChar.setValue(0);&#xA;&#xA;  // advertise the service&#xA;  blePeripheral.begin();&#xA;  Serial.println((&quot;Bluetooth device active, waiting for connections...&quot;));&#xA;}&#xA;&#xA;void loop() {&#xA;  // poll peripheral&#xA;  blePeripheral.poll();&#xA;}&#xA;&#xA;void blePeripheralConnectHandler(BLECentral&amp;amp; central) {&#xA;  // central connected event handler&#xA;  Serial.print(&quot;Connected event, central: &quot;);&#xA;  Serial.println(central.address());&#xA;}&#xA;&#xA;void blePeripheralDisconnectHandler(BLECentral&amp;amp; central) {&#xA;  // central disconnected event handler&#xA;  Serial.print(&quot;Disconnected event, central: &quot;);&#xA;  Serial.println(central.address());&#xA;}&#xA;&#xA;void switchCharacteristicWritten(BLECentral&amp;amp; central, BLECharacteristic&amp;amp; characteristic) {&#xA;  // central wrote new value to characteristic, update LED&#xA;  Serial.print(&quot;Characteristic event, written: &quot;);&#xA;&#xA;  if (switchChar.value()) {&#xA;    Serial.println(&quot;LED on&quot;);&#xA;    digitalWrite(ledPin, HIGH);&#xA;  } else {&#xA;    Serial.println(&quot;LED off&quot;);&#xA;    digitalWrite(ledPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the write function (phonegap) which is where the error is being produced from : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var string = &quot;Hello World&quot;;&#xA;var bytes = bluetoothle.stringToBytes(string);&#xA;var encodedString = _arrayBufferToBase64(bytes);&#xA;alert(&quot;Service : &quot; + connection.service + &quot;  char : &quot; + connection.char + &quot; Address: &quot; + address);&#xA;var params = {&quot;value&quot;:encodedString,&quot;service&quot;:connection.service,&quot;characteristic&quot;:connection.char,&quot;address&quot;:address};&#xA;alert(&quot;params : &quot; + JSON.stringify(params));&#xA;bluetoothle.write(function(res) {&#xA;alert(&quot;Success writing : &quot; + JSON.stringify(res));&#xA;}, function(err) {&#xA;alert(&quot;Error writing: &quot; + JSON.stringify(err));&#xA;}, params);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the error lies in the fact that the Arduino appears not to be advertising the &quot;write&quot; characteristic.&#xA;BTW the phone tells me that the service was &lt;code&gt;180d&lt;/code&gt; and the characteristic was &lt;code&gt;2a37&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18442" LastActivityDate="2016-02-17T14:54:34.953" Title="Writing not permitted on genuino 101 Built in Bluetooth LE (phonegap)" Tags="|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20784" PostTypeId="2" ParentId="16919" CreationDate="2016-02-17T12:50:08.160" Score="0" Body="&lt;p&gt;Why not build a small board that converts the pins from V, G, A5, A4 to V, G, A4, A5? Or modify the PCB e.g. cut and rewire the signals in the order you want. It is only two pins!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-17T12:50:08.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20786" PostTypeId="2" ParentId="20771" CreationDate="2016-02-17T13:24:27.157" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is what should I put in this part&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to take the data from IMU sensor and put it into the payload. Remember that NRF24L01 allows max 32 byte payload and the library uses some of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RTVector3 is a C++ class with 3 floating point numbers. With AVR float/double that is 12 bytes. This means that you will have to send several messages. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum {&#xA;   GYRO_TYPE = 0,&#xA;   ACCEL_TYPE = 1,&#xA;   COMPASS_TYPE =2&#xA;};&#xA;&#xA;struct payload_t {&#xA;  int8_t type;&#xA;  float data[3];&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes that the sender and receiver have the same data representation. The type field is for the value type (GYRO, ACCEL, COMPASS).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-17T13:24:27.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20787" PostTypeId="1" CreationDate="2016-02-17T13:57:02.887" Score="2" ViewCount="483" Body="&lt;p&gt;I'm with some friends from my school and we have started to do a project where we send an SMS text message to our Arduino UNO (with GSM module), which then print the text message on a thermal printer(tx, rx). we've got huge problems, and now we can not figure it out anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We started making a machine that will print out a message that is sent from any mobile.So I send an SMS message with my mobile to Arduino connected to a GSM shield (SIM800L). Then sends the Arduino the message to the thermal printer via TX RX, and then the message should be printed out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have spent two examples, GSM shield from Arduino itself, and thermal printer example from SparkFun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two files work fine separately, but when we try to merge them together, there is a compilation error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The printer model from Sparkfun.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define PINNUMBER &quot;&quot;&#xA;&#xA;//Printer&#xA;SoftwareSerial Thermal(6, 7);&#xA;//GSM modul&#xA;//SoftwareSerial GSM(4, 5);&#xA;&#xA;int heatTime = 10;&#xA;int heatInterval = 2;&#xA;char printDensity = 15; &#xA;char printBreakTime = 15;&#xA;&#xA;// initialize the library instances&#xA;&#xA;GSM_SMS sms;&#xA;&#xA;// Array to hold the number a SMS is retreived from&#xA;char senderNumber[20];&#xA;&#xA;void setup() {&#xA;// Open serial communications and wait for port to open:&#xA;Serial.begin(9600);&#xA;  while (!Serial) {&#xA;; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;&#xA;// connection state&#xA;boolean notConnected = true;&#xA;&#xA;&#xA;&#xA; Thermal.println(&quot;GSM initialized&quot;);&#xA; Thermal.println(&quot;Waiting for messages&quot;);&#xA; }    &#xA; /*{&#xA; Thermal.begin(19200); // to write to our new printer&#xA; initPrinter();&#xA; }&#xA; */&#xA;void initPrinter()&#xA;{&#xA; //Modify the print speed and heat&#xA; Thermal.write(27);&#xA; Thermal.write(55);&#xA; Thermal.write(7); //Default 64 dots = 8*('7'+1)&#xA; Thermal.write(heatTime); //Default 80 or 800us&#xA; Thermal.write(heatInterval); //Default 2 or 20us&#xA; //Modify the print density and timeout&#xA; Thermal.write(18);&#xA; Thermal.write(35);&#xA; int printSetting = (printDensity&amp;lt;&amp;lt;4) | printBreakTime;&#xA; Thermal.write(printSetting); //Combination of printDensity and     printBreakTime&#xA;&#xA; }&#xA; void loop() {&#xA; char c;&#xA;&#xA; // If there are any SMSs available()&#xA;  if (sms.available()) {&#xA;  Thermal.println(&quot;Message received from:&quot;);&#xA;&#xA;// Get remote number&#xA;sms.remoteNumber(senderNumber, 20);&#xA;Thermal.println(senderNumber);&#xA;&#xA;// An example of message disposal&#xA;// Any messages starting with # should be discarded&#xA;if (sms.peek() == '#') {&#xA;  Thermal.println(&quot;Discarded SMS&quot;);&#xA;  sms.flush();&#xA;}&#xA;&#xA;// Read message bytes and print them&#xA;while (c = sms.read()) {&#xA;  Thermal.print(c);&#xA;}&#xA;&#xA;}&#xA;&#xA;delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18444" LastEditorUserId="11529" LastEditDate="2016-02-20T17:04:56.707" LastActivityDate="2016-02-20T17:04:57.003" Title="Help with school project (Arduino GSM and Thermal printer)" Tags="|programming|gsm|project-critique|" AnswerCount="0" CommentCount="4" ClosedDate="2017-10-30T15:20:36.623" ContentLicense="CC BY-SA 3.0" />
  <row Id="20788" PostTypeId="1" CreationDate="2016-02-17T14:05:29.667" Score="2" ViewCount="145" Body="&lt;p&gt;Hello I have a method where when you press a button a string is compared with a substring to see if the string contains the substring. The problem is when I load in the string I call the check button press and substring comparing method. Which only ever happens once. I want to know how I can keep calling the method. It sounds simple but it isn't.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loadPrograme(){&#xA;   file = SD.open(&quot;/classes/basic.txt&quot;, FILE_READ);&#xA;   Serial.print(&quot;Reading, Checking and Compiling \n\n\n&quot;);  &#xA;&#xA;&#xA;   for (int i = 0; i &amp;lt; arraysize; i++) { &#xA;      while (file.available()) { &#xA;         character23 = file.read(); &#xA;         if (character23 == '\n') break; &#xA;         if (character23 != '^') { &#xA;            content += character23; &#xA;         } &#xA;      } &#xA;      content.trim(); &#xA;      if (content != &quot;&quot;) { &#xA;         result[i] = content; &#xA;         content = &quot;&quot;;&#xA;         delay(1000); &#xA;      } &#xA;   }&#xA;   for (int i = 0; i &amp;lt;arraysize; i++) {&#xA;      if(result[i].substring(0,5) == &quot;print&quot;){&#xA;         printlnMethod(result[i]);  &#xA;&#xA;      }else&#xA;         if(result[i].substring(0,5) == &quot;delay&quot;){&#xA;            delayMethod(result[i]);      &#xA;         }else&#xA;            if(result[i].substring(0,11) == &quot;buttonPress&quot;){&#xA;               buttonMethod(result[i]);  &#xA;&#xA;            }&#xA;&#xA;   }&#xA;&#xA;   file.close();&#xA;}&#xA;&#xA;void buttonMethod(String s){ &#xA;   s = s.substring(s.indexOf('{') + 1);&#xA;   s = s.substring(0, s.lastIndexOf('}'));&#xA;   String btn =&quot; &quot;;&#xA;   String daction = &quot; &quot;;&#xA;   String indaction = &quot; &quot;;&#xA;   btn= s.substring(s.indexOf('&quot;')+1 );&#xA;   btn= btn.substring(0, btn.lastIndexOf('&quot;'));&#xA;   daction = s.substring(s.indexOf(',')+1);&#xA;   daction = daction.substring(0, daction.lastIndexOf('('));&#xA;   indaction = s.substring(s.indexOf('~')+1);&#xA;   indaction = indaction.substring(0, indaction.lastIndexOf('~'));&#xA;   int buttonpressed;&#xA;   if(btn == &quot;BUTTON_PIN_ENTER&quot;){&#xA;      buttonpressed = 2;&#xA;   }else if(btn == &quot;BUTTON_PIN_LEFT&quot;){&#xA;      buttonpressed = 3;&#xA;   }else if(btn == &quot;BUTTON_PIN_RIGHT&quot;){&#xA;      buttonpressed = 4;&#xA;   }else if(btn == &quot;BUTTON_PIN_DOWN&quot;){&#xA;      buttonpressed = 5;&#xA;   }else if(btn == &quot;BUTTON_PIN_UP&quot;){&#xA;      buttonpressed = 6;&#xA;   }else if(btn == &quot;BUTTON_PIN_ACTION&quot;){&#xA;      buttonpressed = 7;&#xA;   }&#xA;&#xA;   int btncheck = digitalRead(buttonpressed);&#xA;   if(btncheck == LOW){&#xA;      if(daction.substring(0,5) == &quot;print&quot;){&#xA;         printlnMethod(indaction);  &#xA;&#xA;      }else if(daction.substring(0,5) == &quot;delay&quot;){&#xA;         delayMethod(indaction);      &#xA;      }&#xA;   }&#xA;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So basically it loads in the txt file into the string array and loops through it and reads each line. each line is executed. for example if it get the substring of buttonpressed it goes to the buttonmethod(). The problem is in the button method. I want to have the button method keep looping until the button is pressed but it only runs through that method once. How can I keep running threw this method until the button is pressed?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="313" LastEditDate="2016-02-17T14:11:24.787" LastActivityDate="2016-02-17T17:06:12.947" Title="Arduino how to loop a method" Tags="|arduino-uno|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20789" PostTypeId="2" ParentId="20788" CreationDate="2016-02-17T14:44:00.503" Score="4" Body="&lt;p&gt;Testing for string equality with '==' is a mistake: &lt;a href=&quot;https://stackoverflow.com/questions/8004237/how-do-i-properly-compare-strings-in-c&quot;&gt;https://stackoverflow.com/questions/8004237/how-do-i-properly-compare-strings-in-c&lt;/a&gt;  The '==' operator on strings will compare the pointers to the strings rather than their content and likely always fail the if() tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To loop and block on the last bit, if that is what you mean, you might try: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   int btncheck;&#xA;   ...&#xA;   while(btncheck = digitalRead(buttonpressed)){ // wait for button&#xA;      if(strcmp(daction.substring(0,5),&quot;delay&quot;)){&#xA;         delayMethod(indaction);      &#xA;      }&#xA;   }  // blocked until btncheck == LOW&#xA;   if(strcmp(daction.substring(0,5), &quot;print&quot;)){&#xA;         printlnMethod(indaction);  &#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the blocking on non-pressed button feature, but also has the same logic as the original.  If the string equality tests do not match, it appears you want to do nothing and quickly pass on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To loop buttonMethod(), put it in a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(1)buttonMethod(string);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to condition on getting the button press that corresponds with the string, I'd make buttonMethod return a value and loop conditionally on that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buttonMethod(...&#xA;    int retVal = 0;&#xA;    ...&#xA;&#xA;  if(btncheck == LOW){&#xA;     retVal = 1;&#xA;     ...&#xA;  }&#xA;  return(retVal);&#xA;}&#xA;&#xA;...&#xA;while(!buttonMethod(result[i]));  // wait for the button&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-02-17T17:06:12.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20790" PostTypeId="2" ParentId="20782" CreationDate="2016-02-17T14:54:34.953" Score="1" Body="&lt;p&gt;I finally figured it out thanks to finding &lt;a href=&quot;https://github.com/01org/corelibs-arduino101/issues/96&quot; rel=&quot;nofollow&quot;&gt;this GitHub issue&lt;/a&gt;. It turns out to be an error with CurieBLE which manifests in a way that means that on IOS it reads the original characteristics and services so when I tried to write it was still thought that the characteristic was &lt;code&gt;read-only&lt;/code&gt;. I had to restart my phone and it is working now.&lt;br&gt;&#xA;There was another thing which is that I needed to send a shorter message, I think it was 20 bytes max per message although I'm not sure, but I sent &quot;h&quot; and the Arduino received it.&lt;/p&gt;&#xA;" OwnerUserId="18442" LastActivityDate="2016-02-17T14:54:34.953" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20791" PostTypeId="1" CreationDate="2016-02-17T14:59:35.263" Score="0" ViewCount="1532" Body="&lt;p&gt;If so, please tell me and also tell me if any interfacing of other microcontroller needed?&lt;/p&gt;&#xA;" OwnerUserId="18449" LastEditorUserId="4628" LastEditDate="2016-02-18T11:04:22.837" LastActivityDate="2016-02-18T11:04:22.837" Title="Can we detect a magnet using Arduino? If so how?" Tags="|arduino-uno|sensors|hardware|" AnswerCount="2" CommentCount="1" ClosedDate="2016-02-19T09:00:07.100" ContentLicense="CC BY-SA 3.0" />
  <row Id="20792" PostTypeId="2" ParentId="20791" CreationDate="2016-02-17T15:28:51.087" Score="4" Body="&lt;p&gt;I can't comment yet but you probably are looking for a hall effect sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this is a simple version of the sensor. &lt;a href=&quot;https://www.sparkfun.com/products/9312&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9312&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then do a digitalRead on the DO pin to detect if a magnet is near the sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would connect the Vdd to 5v arduino supply and GND to the GND of the board.&lt;/p&gt;&#xA;" OwnerUserId="18451" LastActivityDate="2016-02-17T15:28:51.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20793" PostTypeId="2" ParentId="20742" CreationDate="2016-02-17T15:34:09.403" Score="1" Body="&lt;p&gt;Maybe I'm dense, but I don't understand why most of the config code is in the ISR.  If the system is getting bound up there, I'd move much of it out and try to simplify it as much as possible, maybe saving only the counter value and the fact that the timer triggered on interrupt, and saving the overflow value if it overflowed.  Then, outside the ISR, on the reporting timescale, I'd check that there was valid data and report or reconfigure as needed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int validReading = 0;&#xA;uint32_t measuredCount;&#xA;int overflowed =0; &#xA;&#xA;&#xA;void TC1_Handler(){&#xA;    measuredCount = REG_TC0_CV0;    &#xA;    if((SR &amp;amp; TC_SR_COVFS) == TC_SR_COVFS){  //counter overflow occurred&#xA;       validMeasurement=0;&#xA;       overflow=1;&#xA;    else {&#xA;       validMeasurement = 1;&#xA;       // either reset counter and clock or stop handling interrupts &#xA;    }&#xA; }&#xA;&#xA;&#xA; loop(){&#xA;   ...&#xA;   if (validReading) { // report&#xA;      ...&#xA;   } else {&#xA;   if (overflowed ) { // shorten sampling time, calibrate, and initialize&#xA;      ...&#xA;   } &#xA;   if ( measuredCount &amp;lt; 10 ) { // lengthen sampling time? &#xA;      ...&#xA;   }&#xA;   // calibrate and reinitialize  &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-17T15:34:09.403" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20794" PostTypeId="2" ParentId="20791" CreationDate="2016-02-17T16:23:45.780" Score="3" Body="&lt;p&gt;If you don't care about measuring the strength of the magnetic field, you can use a magnetic switch (sometimes called a reed switch). A magnetic switch closes when a magnet is put up to it and opens when there is not. The only problem with this is that the magnet has to be within about one inch from the switch. The magnetic switch works just like a normal switch and usually has two contacts. &lt;a href=&quot;http://www.mouser.com/ProductDetail/Standex-Electronics/ORD324-1520/?qs=JzJq8kwFq1kL6csKqXqJlw%3D%3D&amp;amp;gclid=CjwKEAiA0ZC2BRDpo_Pym8m-4n4SJAB5Bn4xq9r0brZEKWex5eS-FfwskFgNwpZVISwIe8pVCaHRaBoCKxnw_wcB&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is an example.&lt;/p&gt;&#xA;" OwnerUserId="18453" LastActivityDate="2016-02-17T16:23:45.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20795" PostTypeId="2" ParentId="20770" CreationDate="2016-02-17T17:02:20.943" Score="2" Body="&lt;p&gt;How did you set the amps on the &lt;a href=&quot;http://www.schmalzhaus.com/EasyDriver/&quot; rel=&quot;nofollow&quot;&gt;http://www.schmalzhaus.com/EasyDriver/&lt;/a&gt; to 0.5A?   What was the voltage at the test point?  The EasyDriver v4.5 schematic says the formula for coil current is A = V/6.  So rearranging, V=A*6, and to get 0.5A, the voltage should be 0.5*6=3V at the motor driver's test point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The linked motor spec is 0.6A max per coil, and if things went wrong, you could have overloaded a motor.  The 18V battery could have easily provided 1.8 amps to the 10ohm coil in the motor for a bit, before 3x the rated current of the coils would burn it out, or the easydriver went into thermal shutdown or something.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easydriver looks like it would be capable of controlling the current adequately, but if misconfigured, could easily overcurrent the motor. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-02-17T19:48:06.007" LastActivityDate="2016-02-17T19:48:06.007" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20796" PostTypeId="2" ParentId="18955" CreationDate="2016-02-17T17:43:55.297" Score="1" Body="&lt;p&gt;arcore creator Ralf Kistner provided the &lt;a href=&quot;https://github.com/rkistner/arcore/issues/19&quot; rel=&quot;nofollow&quot;&gt;answer&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// The pitch bend value is a 14-bit number (0-16383). 0x2000 (8192) is the default / middle value.&#xA;&#xA;// First byte is the event type (0x0E = pitch bend change).&#xA;// Second byte is the event type, combined with the channel.&#xA;// Third byte is the 7 least significant bits of the value.&#xA;// Fourth byte is the 7 most significant bits of the value.&#xA;void pitchBendChange(byte channel, int value) {&#xA;  byte lowValue = value &amp;amp; 0x7F;&#xA;  byte highValue = value &amp;gt;&amp;gt; 7;&#xA;  MIDIEvent event = {0x0E, 0xE0 | channel, lowValue, highValue};&#xA;  MIDIUSB.write(event);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3505" LastActivityDate="2016-02-17T17:43:55.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20797" PostTypeId="2" ParentId="17" CreationDate="2016-02-17T18:35:22.157" Score="6" Body="&lt;p&gt;For people using Linux Mint I found that by selecting the &quot;TTY SO&quot; port instead of the one labeled &quot;Arduino&quot; it would work (I can't tell you exactly because I don't have that computer in front of me right now). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the next time I used the Arduino I again got the same message so I switched back to the &quot;Arduino&quot; port and it has worked that way ever since.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not as technically knowledgeable as the rest of you guys so I have no idea why this works or what the problem was, but it worked which is all I care about.  Maybe this will be useful to someone.&lt;/p&gt;&#xA;" OwnerUserId="17348" LastActivityDate="2016-02-17T18:35:22.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20798" PostTypeId="1" CreationDate="2016-02-17T19:00:04.137" Score="1" ViewCount="8632" Body="&lt;p&gt;I have a question. How to run stepper motor (Nema 17) that has 5 wires with arduino and stepper driver.&#xA;Here is the driver, stepper and Arduino when stepper has 4 wires.&#xA;&lt;a href=&quot;http://jdreyer.com/projects/Arduino/ArduinoEasyDriverStepperMotorv1_Resize.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://jdreyer.com/projects/Arduino/ArduinoEasyDriverStepperMotorv1_Resize.png&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help identifying the wires on my hibrid stepper motor. I will provide picture of dissasembled motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Wires identification?&lt;/li&gt;&#xA;&lt;li&gt;How to connect it to ArduinoEasyDriver?&lt;/li&gt;&#xA;&lt;li&gt;Code example desired.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cMHwS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cMHwS.jpg&quot; alt=&quot;Dissasembled stepper&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T5Bk9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T5Bk9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am now thinking of making it bipolar (4 wires), because now in 5&#xA;  wires configuration motor is unipolar. I did some research and this&#xA;  motor is HIBRID. It can be driven as unipolar or bipolar. I will try&#xA;  to troubleshoot the wiring and find the common wire. Ill keep you&#xA;  informed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10131" LastEditorUserId="10131" LastEditDate="2016-02-18T15:02:10.677" LastActivityDate="2016-02-18T15:02:10.677" Title="How to run 5 wires hibrid stepper motor with arduino uno?" Tags="|arduino-uno|motor|electronics|stepper|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20801" PostTypeId="2" ParentId="20798" CreationDate="2016-02-17T20:02:51.717" Score="1" Body="&lt;p&gt;&lt;strong&gt;Finding the ground pin&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We should start off by finding the Ground/GND pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have an Ohm-meter? I believe one of the pins should be GND/ground, and should have low resistance when referenced to the other pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wiring the stepper&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steppers have a coil and thus are an inductive load, you should really check your wiring with sources, to be sure they're valid.&#xA;(At this point I can't give you a 100% accurate wiring diagram, but it should be easy to find, as wiring steppers is quite common.)&#xA;You could use a pre-assembled stepper-driver. Having such a thing is usefull when you want to design the circuitry yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Driving the steppers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should generate a signal like this: &lt;a href=&quot;https://en.wikipedia.org/wiki/Stepper_motor#Phase_current_waveforms&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Stepper_motor#Phase_current_waveforms&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The source/link describes the different forms of stepping. Like &quot;Wave drive (one phase on)&quot; in which each coil is activated/deactivated in a rotary fashion, making the core turn around.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit always has extremely well documented tutorials for beginners:&#xA;&lt;a href=&quot;https://learn.adafruit.com/all-about-stepper-motors/types-of-steppers&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/all-about-stepper-motors/types-of-steppers&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiki of RepRap should be a good source, since steppers are the hearth of 3D printers (RepRap is a 3D printer brand):&#xA;&lt;a href=&quot;http://reprap.org/wiki/Stepper_wiring&quot; rel=&quot;nofollow&quot;&gt;http://reprap.org/wiki/Stepper_wiring&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-02-17T20:02:51.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20802" PostTypeId="1" AcceptedAnswerId="20806" CreationDate="2016-02-17T20:03:29.187" Score="0" ViewCount="156" Body="&lt;p&gt;Hello I have a programme that loads a piece of text from a file. In this case it loads &quot;drawrect(4,10,20,20);&quot; from the txt file and stores it in a string. I then use substrings to change the string into just &quot;4,10,20,20&quot; which is good but I need to simplify it down even more to four strings each with one of those 4 numbers in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void drawRectMethod(String s){&#xA;  String var1,var2,var3,var4;&#xA;  s = s.substring(s.indexOf('(') + 1);&#xA;  s = s.substring(0, s.lastIndexOf(')'));&#xA;  Serial.println(s);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to simplify the string down to &quot;4,10,20,20&quot; but this wont work to store each number in a separate string. How can I can I store each variable in a separate string. The numbers will be stored in var1 - var4.&lt;/p&gt;&#xA;" OwnerUserId="16124" LastEditorUserId="16124" LastEditDate="2016-02-17T20:35:15.260" LastActivityDate="2016-02-18T11:37:20.010" Title="Arduino loading from file" Tags="|arduino-uno|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20803" PostTypeId="2" ParentId="20798" CreationDate="2016-02-17T20:05:35.350" Score="2" Body="&lt;p&gt;On stepper motors there are a few types of wiring, but essentially there are two coils inside the stepper motor. To figure out where the wiring is you need a way to test if the coils are being connected. On your setup I would suggest to connect two of the wires together at a time and spin the shaft. If the shaft offers resistance then you have found the two wires for one coil. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your stepper motor it looks like it may have three coils, but out of the 6 wires you may also only come up with 4 wires; which would equal 2 coils.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as connecting it to an easy driver, the easy driver only takes two coils. you would need to find a driver that can take three coils, or just connect two coils out of the three and hope for the best.&lt;/p&gt;&#xA;" OwnerUserId="18458" LastActivityDate="2016-02-17T20:05:35.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20804" PostTypeId="2" ParentId="16572" CreationDate="2016-02-17T20:24:45.813" Score="0" Body="&lt;p&gt;You could create your own custom shield with an Arduino mega and 6 Stepper sticks &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00NCSK6T2&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Hobbypower-StepStick-4-layer-DRV8825-Stepper/dp/B00NCSK6T2/ref=sr_1_1?ie=UTF8&amp;amp;qid=1455740571&amp;amp;sr=8-1&amp;amp;keywords=DRV8825&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to the stepper sticks I was talking about. To make this work you would need to be able to solder the breadboard together and set up the arduino to accept pins from the breadboard. You would also need a 12v power supply to give the motors power&lt;/p&gt;&#xA;" OwnerUserId="18458" LastActivityDate="2016-02-17T20:24:45.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20805" PostTypeId="2" ParentId="20798" CreationDate="2016-02-17T20:35:18.630" Score="3" Body="&lt;p&gt;1) it is probably something like A1, A2, Common, B1, B2.  You could confirm this with an ohmmeter. Common to any of the others would be a certain resistance X, while between any of the others (A1-A2, B1-B2, A1-B1, A1-B2, B1 A2) would be 2X. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) You can't.  It is a unipolar stepper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The EasyDriver faq number 5.1 at &lt;a href=&quot;http://www.schmalzhaus.com/EasyDriver/&quot; rel=&quot;nofollow&quot;&gt;http://www.schmalzhaus.com/EasyDriver/&lt;/a&gt; says:  &quot;... The only kind you can't use is 5-wire stepper motors. (They need uni-polar drivers.)&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The difficulty with the 5-wire steppers is that they short the middle of the two coils together, which makes it hard to drive the coils independently.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you have the motor open, you might be able to do some surgery and disconnect the centers of the coils from each other, but you'll probably be better off getting a 4, 6 or 8 wire stepper instead.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-02-17T20:40:31.493" LastActivityDate="2016-02-17T20:40:31.493" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20806" PostTypeId="2" ParentId="20802" CreationDate="2016-02-17T20:45:22.290" Score="2" Body="&lt;p&gt;Need some more help? As I previously wrote that snippet I might as well continue until you understand how to use indexOf() and substring(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String s = &quot;draw(10,20,30,40)&quot;;&#xA;&#xA;  // Parse the argument list&#xA;  s = s.substring(s.indexOf('(') + 1);&#xA;  s = s.substring(0, s.lastIndexOf(')'));&#xA;&#xA;  // Parse comma separated arguments&#xA;  String arg[4];&#xA;  for (int i = 0; i &amp;lt; 3; i++) {&#xA;    int ix = s.indexOf(',');&#xA;    arg[i] = s.substring(0, ix);&#xA;    s = s.substring(ix + 1);&#xA;    Serial.println(arg[i]);&#xA;  }&#xA;  arg[3] = s;&#xA;  Serial.println(arg[3]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is absolutely no error handling in this. You will have to add that. You can also improve the parse of the right parenthesis. That could be added last instead.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later in the game we will come to why using String is a bad idea and why a character buffer and the standard library functions such as &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html#ga6ace85338eafe22a0ff52c00eb9779b8&quot; rel=&quot;nofollow&quot;&gt;strtok()&lt;/a&gt; is a much better solution strategy both performance and memory footprint and especially heap. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  char* s = (char*) &quot;draw(10,20,30,40)&quot;;&#xA;  s = strtok(s, &quot;(),&quot;);&#xA;  Serial.println(s);&#xA;  while ((s = strtok(NULL, &quot;(),&quot;)) != NULL)&#xA;    Serial.println(s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe the simplest solution is to use &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html&quot; rel=&quot;nofollow&quot;&gt;sscanf()&lt;/a&gt;. That will also do the conversion from text to binary.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  const char* s = &quot;draw(10,20,30,40)&quot;;&#xA;  int x, y, w, h;&#xA;  int n = sscanf(s, &quot;draw(%d,%d,%d,%d)&quot;, &amp;amp;x, &amp;amp;y, &amp;amp;w, &amp;amp;h);&#xA;  Serial.print(F(&quot;n=&quot;));&#xA;  Serial.println(n);&#xA;  Serial.print(F(&quot;x=&quot;));&#xA;  Serial.println(x);&#xA;  Serial.print(F(&quot;y=&quot;));&#xA;  Serial.println(y);&#xA;  Serial.print(F(&quot;w=&quot;));&#xA;  Serial.println(w);&#xA;  Serial.print(F(&quot;h=&quot;));&#xA;  Serial.println(h);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-18T11:37:20.010" LastActivityDate="2016-02-18T11:37:20.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20807" PostTypeId="2" ParentId="20716" CreationDate="2016-02-17T21:43:15.430" Score="1" Body="&lt;p&gt;To make things simpler, try flashing the Pro Micro firmware with another UNO (or compatible) hardware. I prefer an UNO clone with CH340 chip or a pro mini with a FTDI cable. Just to keep things simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flash the UNO with Arduiono as ISP sketch. Use connection guidance from Arduino tutorial:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;Using an Arduino as an AVR ISP&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j6Wh1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j6Wh1.png&quot; alt=&quot;connection diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once this is done, AVRDUDE will see the source Arduino as &lt;strong&gt;AVR ISP&lt;/strong&gt; and you can flash the firmware on the target Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;a href=&quot;http://blog.bhargavaz.us/2011/08/programming-arduino-bootloader-on-mega8.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this post&lt;/a&gt; for guidance as well.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastEditorUserId="9962" LastEditDate="2016-02-18T02:35:47.807" LastActivityDate="2016-02-18T02:35:47.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20808" PostTypeId="1" CreationDate="2016-02-17T22:55:50.197" Score="4" ViewCount="220" Body="&lt;p&gt;During the last two months I have been working on a project that consists of using a Seeeduino Stalker V2.3, two AM2305 sensors, a TSL2561 sensor, an HC-05 XBee module, a 1,800 mAh 3.7V LiPo, a 7 cm x 7 cm 5V solar cell, and a waterproof suction box, to assemble a portable and waterproof environmental data logger that can be used to take samples on a continuous basis (1 sample every 30 minutes, 48 samples per day).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After struggling to make my logger work, I finally did it last week. It all runs fine, except that the intervals between readings are incorrect. When I program my board to store samples every 30 minutes (1,800,000), it takes them every 30 minutes and some extra seconds. When I try the same but with a rate of 1 sample every 10 seconds, my device logs data every 13 seconds more or less...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I have been using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SPI.h&quot;&#xA;#include &quot;Wire.h&quot;&#xA;#include &quot;SD.h&quot;&#xA;#include &quot;DS3231.h&quot;**&#xA;&#xA;DS3231 clock;&#xA;RTCDateTime dt;&#xA;&#xA;#include &quot;DHT.h&quot;&#xA;&#xA;#define DHTPIN 8&#xA;#define DHTTYPE DHT21&#xA;DHT dht1(DHTPIN, DHTTYPE);&#xA;#define DHTPIN2 7&#xA;DHT dht2(DHTPIN2, DHTTYPE);&#xA;#include &quot;TSL2561.h&quot;&#xA;TSL2561 tsl(TSL2561_ADDR_FLOAT);&#xA;&#xA;const int chipSelect = 10;&#xA;int XBEE = 5;&#xA;int FLASH = 4;&#xA;&#xA;void setup() {&#xA;  pinMode(5, OUTPUT);&#xA;  digitalWrite(XBEE, HIGH);&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  clock.begin();&#xA;  analogReference(INTERNAL);&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(4, INPUT);&#xA;  SD.begin(10);&#xA;  dht1.begin();&#xA;  dht2.begin();&#xA;  Serial.println(&quot;EcoLOGGER DE PRUEBA PARA GENERACION DE DATOS ...&quot;);&#xA;  Serial.println(&quot; &quot;);&#xA;  delay(3000);&#xA;  Serial.println(&quot;RECUERDA QUE ESTE PROYECTO NO HUBIERA SIDO POSIBLE SIN LA AYUDA DE LA COMUNIDAD ARDUINO...&quot;);&#xA;  Serial.println(&quot; &quot;);&#xA;  delay(3000);&#xA;}&#xA;&#xA;int counter = 0;&#xA;&#xA;void loop() {&#xA;  float h = dht1.readHumidity();&#xA;  float t = dht1.readTemperature();&#xA;  float f = dht1.readTemperature(true);&#xA;  float h2 = dht2.readHumidity();&#xA;  float t2 = dht2.readTemperature();&#xA;  float f2 = dht2.readTemperature(true);&#xA;  dt = clock.getDateTime();&#xA;  if (tsl.begin()) {&#xA;  } else {&#xA;    while (1);&#xA;  }&#xA;  tsl.setGain(TSL2561_GAIN_0X);&#xA;  tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS);&#xA;  uint16_t x = tsl.getLuminosity(TSL2561_FULLSPECTRUM);&#xA;  uint32_t lum = tsl.getFullLuminosity();&#xA;  uint16_t ir, full;&#xA;  ir = lum &amp;gt;&amp;gt; 16;&#xA;  full = lum &amp;amp; 0xFFFF;&#xA;  float vis = full-ir;&#xA;  Serial.print(&quot;Muestreo: &quot;);&#xA;  Serial.println(counter);&#xA;  Serial.print(&quot;Fecha: &quot;);&#xA;  Serial.print(dt.day);&#xA;  Serial.print('/');&#xA;  Serial.print(dt.month);&#xA;  Serial.print('/');&#xA;  Serial.println(dt.year);&#xA;  Serial.print(&quot;Hora: &quot;);&#xA;  Serial.print(dt.hour);&#xA;  Serial.print(':');&#xA;  Serial.print(dt.minute);&#xA;  Serial.print(':');&#xA;  Serial.println(dt.second);&#xA;  Serial.print(&quot;Temperatura sistema: &quot;);&#xA;  Serial.print(clock.readTemperature());&#xA;  Serial.println(&quot;*C &quot;);&#xA;  Serial.print(&quot;Voltaje bateria: &quot;);&#xA;  Serial.print(analogRead(A7) * (1.1 / 1024)* (10+2)/2);&#xA;  Serial.println(&quot; V &quot;);&#xA;  Serial.print(&quot;Carga bateria: &quot;);&#xA;  Serial.print(-149.4 + 59.52 * (analogRead(A7) * (1.1 / 1024)* (10+2)/2));&#xA;  Serial.println(&quot;% &quot;);&#xA;  Serial.print(&quot;Luz FULL: &quot;);&#xA;  Serial.println(full);&#xA;  Serial.print(&quot;Temperatura ambiente: &quot;);&#xA;  Serial.print(t);&#xA;  Serial.println(&quot; *C &quot;);&#xA;  Serial.print(&quot;Humedad relativa: &quot;);&#xA;  Serial.print(h);&#xA;  Serial.println(&quot;%&quot;);&#xA;  Serial.print(&quot;Temperatura suelo: &quot;);&#xA;  Serial.print(t2);&#xA;  Serial.println(&quot; *C &quot;);&#xA;  Serial.print(&quot;Humedad suelo: &quot;);&#xA;  Serial.print(h2);&#xA;  Serial.println(&quot;%&quot;);&#xA;  Serial.println(&quot; &quot;);&#xA;  digitalWrite (FLASH, HIGH);&#xA;  File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;  if (dataFile) {&#xA;    dataFile.print(&quot; Muestreo: &quot;);&#xA;    dataFile.print(counter);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Fecha: &quot;);&#xA;    dataFile.print(dt.day);&#xA;    dataFile.print('/');&#xA;    dataFile.print(dt.month);&#xA;    dataFile.print('/');&#xA;    dataFile.print(dt.year);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Hora: &quot;);&#xA;    dataFile.print(dt.hour);&#xA;    dataFile.print(':');&#xA;    dataFile.print(dt.minute);&#xA;    dataFile.print(':');&#xA;    dataFile.print(dt.second);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Temperatura sistema: &quot;);&#xA;    dataFile.print(clock.readTemperature());&#xA;    dataFile.print(&quot;*C &quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Voltaje bateria: &quot;);&#xA;    dataFile.print(analogRead(A7) * (1.1 / 1024)* (10+2)/2);&#xA;    dataFile.print(&quot; V &quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Porcentaje carga: &quot;);&#xA;    dataFile.print(-149.4 + 59.52 * (analogRead(A7) * (1.1 / 1024)* (10+2)/2));&#xA;    dataFile.print(&quot;% &quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Luz FULL: &quot;);&#xA;    dataFile.print(full);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Temperatura ambiente: &quot;);&#xA;    dataFile.print(t);&#xA;    dataFile.print(&quot; *C &quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Humedad relativa: &quot;);&#xA;    dataFile.print(h);&#xA;    dataFile.print(&quot;%&quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Temperatura suelo: &quot;);&#xA;    dataFile.print(t2);&#xA;    dataFile.print(&quot; *C &quot;);&#xA;    dataFile.print(&quot;,&quot;);&#xA;    dataFile.print(&quot; Humedad suelo: &quot;);&#xA;    dataFile.print(h2);&#xA;    dataFile.print(&quot;%&quot;);&#xA;    dataFile.println(&quot;&quot;);&#xA;    dataFile.close();&#xA;    digitalWrite (FLASH, LOW);&#xA;  } else {&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.println(&quot;IMPOSIBLE GUARDAR DATOS&quot;);&#xA;    Serial.println(&quot;&quot;);&#xA;  }&#xA;  counter++;&#xA;  if (counter &amp;gt; 5) {&#xA;    delay (1000);&#xA;    digitalWrite (XBEE, LOW);&#xA;    delay (1799000);&#xA;  } else&#xA;    digitalWrite (XBEE, HIGH);&#xA;  delay (10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have been trying to find possible solutions, but I am just lost. Do any of you have an idea of what could be going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance :)&lt;/p&gt;&#xA;" OwnerUserId="18461" LastEditorUserId="4628" LastEditDate="2016-02-18T11:04:42.320" LastActivityDate="2016-02-18T11:04:42.320" Title="Problem with inaccurate delays between sensor readings" Tags="|code-optimization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20809" PostTypeId="2" ParentId="20808" CreationDate="2016-02-17T23:35:13.837" Score="3" Body="&lt;p&gt;The problem is that you are using &lt;code&gt;delay()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;delay()&lt;/code&gt; will wait, from the moment &lt;code&gt;delay()&lt;/code&gt; is called, for the given number of milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, in more structured terms:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do something&lt;/li&gt;&#xA;&lt;li&gt;Do something else&lt;/li&gt;&#xA;&lt;li&gt;Do something more&lt;/li&gt;&#xA;&lt;li&gt;Wait 30 minutes&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That will only take precisely 30 minutes if steps 1 to 3 take absolutely no time at all.  And that will never be the case. Things take time. Reading from sensors, writing to SD cards, etc, all take time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So waiting for 30 minutes between doing things means that every 30 minutes will be slightly later than the one before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as you saw the difference is more pronounced when you have 10 seconds instead - it ends up as 13 seconds.  So your other actions - reading from sensors, writing to SD card, etc, must be taking about 3 seconds each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So instead of &quot;Stop everything for half an hour&quot;, you need to think slightly differently:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Look at the time.&lt;/li&gt;&#xA;&lt;li&gt;Decide if 30 minutes have passed since the last time you ran the code&lt;/li&gt;&#xA;&lt;li&gt;Remember the time so you can know when 30 minutes have elapsed next time&lt;/li&gt;&#xA;&lt;li&gt;Do your sensor/SD actions.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since you're now keying things happening on the difference between now and when you last &lt;em&gt;started&lt;/em&gt; to do things you get a 30 minute &lt;em&gt;total&lt;/em&gt; delay, rather than a 30 minute delay &lt;em&gt;plus other bits&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an example of how this is done programatically you can look at the &lt;em&gt;BlinkWithoutDelay&lt;/em&gt; example in the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-17T23:35:13.837" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20810" PostTypeId="1" AcceptedAnswerId="20814" CreationDate="2016-02-18T03:00:48.453" Score="3" ViewCount="383" Body="&lt;p&gt;I recently got the RedBearLabs BLE shield to use it to control two high spped continuous rotation servos. I have the BLE example sketch loaded and the ios controller app works. The problem is that the servos are too fast to control and I want to slow them down. I cannot use the app to slow them down. I was wondering how I could modify the example sketch or servo library to change the ax speed or something. Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BLE Shield Homepage: &lt;a href=&quot;http://redbearlab.com/bleshield/&quot; rel=&quot;nofollow&quot;&gt;http://redbearlab.com/bleshield/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BLE Libraries and Example Sketch: &lt;a href=&quot;https://github.com/RedBearLab/nRF8001&quot; rel=&quot;nofollow&quot;&gt;https://github.com/RedBearLab/nRF8001&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15407" LastActivityDate="2016-02-18T05:16:25.807" Title="Change Servo Speed With RedBearLabs BLE Shield" Tags="|arduino-uno|bluetooth|servo|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20811" PostTypeId="2" ParentId="20808" CreationDate="2016-02-18T03:13:36.417" Score="2" Body="&lt;p&gt;The second problem is that delay() on the arduino uses the on-board clock cycle. This is powered by a resonator, which can be off by as much as 10%. If you need accurate timings and timestamps, you will want to use a Real-Time Clock (RTC) module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using delay, the loop() asks the RTC what time it is, and uses that to determine if it's time to take another reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another very common thing for this type of monitoring is for the arduino to go into sleep mode and be woken by a tick from the RTC every second (or longer), in order to extend the battery life.&lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-02-18T03:13:36.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20812" PostTypeId="2" ParentId="20798" CreationDate="2016-02-18T04:25:11.747" Score="1" Body="&lt;p&gt;Instead of doing surgery on your unipolar stepper, you can use it like a unipolar stepper. Some transistors to hook the motor to power (just get a darlington array chip), and four output pins on the arduino. Works fine.&lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-02-18T04:25:11.747" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20813" PostTypeId="1" AcceptedAnswerId="20821" CreationDate="2016-02-18T04:36:50.470" Score="1" ViewCount="644" Body="&lt;p&gt;I am doing a motorcycle security system. In this system, I will receive a message from GSM in the form &lt;code&gt;{password:operation (like start,stop,alarm):time}&lt;/code&gt;.&#xA;Example:(9990:start:30)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now i need to split  each term seperately (a=9990,b=start,c=30).help me to solve&lt;/p&gt;&#xA;" OwnerUserId="18466" LastEditorUserId="18466" LastEditDate="2016-03-01T17:33:00.717" LastActivityDate="2016-03-01T17:33:00.717" Title="How to split a string received via a GSM module (message)" Tags="|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20814" PostTypeId="2" ParentId="20810" CreationDate="2016-02-18T05:16:25.807" Score="2" Body="&lt;p&gt;The bi-directional Parallax &lt;a href=&quot;https://www.parallax.com/product/900-00025&quot; rel=&quot;nofollow&quot;&gt;High Speed Continuous Rotation Servo&lt;/a&gt; responds to “simple pulse-width modulation”, according to its web page.  That is, pulse widths in the range from about 500 μs to 2500 μs will set the speed and direction, with some value near 1500 μs corresponding to zero RPM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in the &lt;a href=&quot;https://codebender.cc/sketch:245943#BLEControllerSketch.ino&quot; rel=&quot;nofollow&quot;&gt;BLEControllerSketch&lt;/a&gt; uses the following bits of code, among others, to initialize servo-control data structures and to control them:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;...&#xA;byte pin_servo[TOTAL_PINS];&#xA;Servo servos[MAX_SERVOS];&#xA;...&#xA;      case 'O': // set Servo&#xA;        {&#xA;          byte pin = ble_read();&#xA;          byte value = ble_read();&#xA;&#xA;          if (IS_PIN_SERVO(pin))&#xA;            servos[PIN_TO_SERVO(pin)].write(value);&#xA;          pin_servo[pin] = value;&#xA;          reportPinServoData(pin);&#xA;        }&#xA;        break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus, you will need to send an &lt;code&gt;O&lt;/code&gt; message from your iOS app, together with servo pin number and control value, to set a servo's speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted on the &lt;a href=&quot;https://www.arduino.cc/en/Reference/ServoWrite&quot; rel=&quot;nofollow&quot;&gt;ServoWrite&lt;/a&gt; page at arduino.cc, the parameter to Servo's &lt;code&gt;.write()&lt;/code&gt; method is a number:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can find out a little more by looking at Servo's &lt;code&gt;.write()&lt;/code&gt; method in Servo.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void Servo::write(int value)&#xA;{&#xA;  if(value &amp;lt; MIN_PULSE_WIDTH)&#xA;  {  // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)&#xA;    if(value &amp;lt; 0) value = 0;&#xA;    if(value &amp;gt; 180) value = 180;&#xA;    value = map(value, 0, 180, SERVO_MIN(),  SERVO_MAX());&#xA;  }&#xA;  this-&amp;gt;writeMicroseconds(value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SERVO_MIN()&lt;/code&gt; and &lt;code&gt;SERVO_MAX()&lt;/code&gt; are macros that access &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; fields in a &lt;code&gt;Servo&lt;/code&gt; object and convert them to microsecond values.  Because the code in BLEControllerSketch.ino lets those fields default, the range evidently will be from 544 to 2400 μs (see the values given in Servo.h).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can get better resolution – hence, better speed control – by sending values in that range of microseconds to your servos, instead of trying to control it using values in degrees.  The &lt;code&gt;.write()&lt;/code&gt; method will interpret such numbers as microseconds instead of as degrees.  Servo.cpp appears to use half-microsecond timer ticks; and each degree corresponds to about 10 μs of pulse width; so resolution using microsecond values should be about 10 times better than using degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, it appears that you should do some experimenting with &lt;code&gt;O&lt;/code&gt; messages that send values around 1500, to find the values that correspond to slowest forward and backward speeds.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-02-18T05:16:25.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20815" PostTypeId="1" CreationDate="2016-02-18T06:36:13.597" Score="2" ViewCount="629" Body="&lt;p&gt;I have this double clap sensor code written, it seems it would work but it seems to trigger the double clap even on a single clap, any ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int soundSensor = A1;&#xA;int relay = A2;&#xA;int relay2 = A3;&#xA;int relay3 = A4;&#xA;int relay4 = A5;&#xA;int claps = 0;&#xA;long detectionSpanInitial = 0;&#xA;long detectionSpan = 0;&#xA;boolean clapState = false;&#xA;int doubleClap = 0;&#xA;&#xA;&#xA;//Light sensor &#xA;int photocellPin = A0;     // the cell and 10K pulldown are connected to a0&#xA;int LEDbrightness;       &#xA;&#xA;//int delayValue = 100;&#xA;int photoSensor = 0;&#xA;&#xA;// sound sample&#xA;const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)&#xA;unsigned int sample;&#xA;&#xA;//other&#xA;boolean isRelaysOn = false;&#xA;void setup() {&#xA;  pinMode(soundSensor, INPUT);&#xA;  pinMode(relay, OUTPUT);&#xA;  pinMode(relay2, OUTPUT);&#xA;  pinMode(relay3, OUTPUT);&#xA;  pinMode(relay4, OUTPUT);&#xA;  turnRelayOff();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;boolean state = false;&#xA;boolean lastState = true;&#xA;boolean lightTurnedItOff = false;&#xA;void loop() {&#xA;&#xA;  /////////////&#xA;  // photo sensor&#xA;  //////////////////// &#xA;&#xA;  photoSensor = analogRead(photocellPin) &amp;gt; 623;&#xA;&#xA;  /////////////&#xA;  // clap sensor&#xA;  /////////////////////&#xA;  double sensorState = getSoundLevel();&#xA;  Serial.println(sensorState);&#xA;  double threshold = .2;&#xA;&#xA;&#xA;  if (sensorState &amp;gt; threshold)&#xA;  {&#xA;    if (claps == 0)&#xA;    {&#xA;      detectionSpanInitial = detectionSpan = millis();&#xA;      claps++;&#xA;    }&#xA;    else if (claps &amp;gt; 0 &amp;amp;&amp;amp; millis()-detectionSpan &amp;gt;= 50)&#xA;    {&#xA;      detectionSpan = millis();&#xA;      claps++;&#xA;      Serial.println(&quot; CLAP ADDED!!!!&quot;);&#xA;    }&#xA;  }&#xA;&#xA;&#xA;&#xA;  if (millis()-detectionSpanInitial &amp;gt;= 400){&#xA;&#xA;    if (claps == 2)&#xA;    {&#xA;      claps++;&#xA;      doubleClap = 1 - doubleClap;&#xA;      state = !state;&#xA;      Serial.println(&quot;TWO claps!&quot;);&#xA;&#xA;      if(lastState == state ){&#xA;        relayControl(doubleClap);&#xA;        lastState = !lastState;&#xA;      }&#xA;    }&#xA;    claps = 0;&#xA;  }&#xA;&#xA;  if(isRelaysOn == true &amp;amp;&amp;amp; photoSensor == 1){&#xA;    turnRelayOff();&#xA;    lightTurnedItOff = true;&#xA;  }&#xA;  if(isRelaysOn == true &amp;amp;&amp;amp; photoSensor == 0 &amp;amp;&amp;amp; lightTurnedItOff == true){&#xA;    turnRelayOn();&#xA;    lightTurnedItOff = false;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void relayControl(int doubleClap){&#xA;  /////////////&#xA;  // relay control&#xA;  /////////////////////&#xA;&#xA;  if(doubleClap == 1){ &#xA;    turnRelayOn();&#xA;    Serial.println(&quot;on&quot;);&#xA;    isRelaysOn = true;&#xA;&#xA;  }&#xA;  else{ &#xA;    turnRelayOff();&#xA;    Serial.println(&quot;off&quot;);&#xA;    isRelaysOn = false;&#xA;  }; &#xA;&#xA;&#xA;}&#xA;&#xA;void turnRelayOn(){&#xA;  int delayAmount = 100;&#xA;  digitalWrite(relay, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay2, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay3, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay4, LOW);&#xA;  delay(100);&#xA;  digitalWrite(relay4, HIGH);&#xA;  delay(100);&#xA;  digitalWrite(relay4, LOW);&#xA;}&#xA;&#xA;void turnRelayOff(){&#xA;  digitalWrite(relay, HIGH);&#xA;  digitalWrite(relay2, HIGH);&#xA;  digitalWrite(relay3, HIGH);&#xA;  digitalWrite(relay4, HIGH);&#xA;}&#xA;&#xA;double getSoundLevel(){&#xA;&#xA;  unsigned long startMillis= millis();  // Start of sample window&#xA;  unsigned int peakToPeak = 0;   // peak-to-peak level&#xA;&#xA;  unsigned int signalMax = 0;&#xA;  unsigned int signalMin = 1024;&#xA;&#xA;  // collect data for 50 mS&#xA;  while (millis() - startMillis &amp;lt; sampleWindow)&#xA;  {&#xA;    sample = analogRead(soundSensor);&#xA;    if (sample &amp;lt; 1024)  // toss out spurious readings&#xA;    {&#xA;      if (sample &amp;gt; signalMax)&#xA;      {&#xA;        signalMax = sample;  // save just the max levels&#xA;      }&#xA;      else if (sample &amp;lt; signalMin){&#xA;        signalMin = sample;  // save just the min levels&#xA;      }&#xA;    }&#xA;  }&#xA;  peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude&#xA;  double volts = (peakToPeak * 3.3) / 1024;  // convert to volts&#xA;&#xA;  return volts;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0.02&#xA;  0.02&#xA;  0.02&#xA;  0.02&#xA;  0.01&#xA;  0.01&#xA;  2.20&#xA;  0.30  CLAP ADDED!!!!&#xA;  0.13&#xA;  0.09&#xA;  0.04&#xA;  0.02&#xA;  0.02&#xA;  0.01&#xA;  0.02 TWO claps! on&#xA;  1.11&#xA;  0.06&#xA;  0.05&#xA;  0.07&#xA;  0.15&#xA;  0.10&#xA;  0.03&#xA;  0.10&#xA;  0.06&#xA;  0.03&#xA;  0.04&#xA;  0.06&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16832" LastEditorUserId="16832" LastEditDate="2016-05-14T18:51:29.757" LastActivityDate="2016-05-14T18:51:29.757" Title="Double clap sensor not working as intended" Tags="|relay|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20816" PostTypeId="2" ParentId="20815" CreationDate="2016-02-18T08:44:09.317" Score="0" Body="&lt;p&gt;I have noticed that you have used analogue inputs as your digital outputs by connecting relays to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is wrong. You should connect your digital signals to the digital pins.&lt;/p&gt;&#xA;" OwnerUserId="17339" LastEditorUserId="9962" LastEditDate="2016-02-18T12:14:19.420" LastActivityDate="2016-02-18T12:14:19.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20817" PostTypeId="1" AcceptedAnswerId="20820" CreationDate="2016-02-18T09:39:15.957" Score="2" ViewCount="1567" Body="&lt;p&gt;For a project I'm using 2 Arduino Uno's, where Arduino#1 (master) sends raw data to Arduino#2 (slave). The slave should receive and encrypt the data and afterwards send the encrypted data back to the master. I'm building my project from the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterWriter&quot; rel=&quot;nofollow&quot;&gt;sketch found at arduino.cc&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I make the slave send back data, if he's the only one listening on incoming data, should both arduinos be listening to each other, and how to achieve this?&lt;/p&gt;&#xA;" OwnerUserId="18472" LastActivityDate="2016-02-18T09:58:23.857" Title="Send AND Receive through i2c / set Arduino as master AND slave" Tags="|arduino-uno|serial|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20818" PostTypeId="5" CreationDate="2016-02-18T09:49:06.230" Score="0" Body="&lt;p&gt;&lt;strong&gt;Forms of remote-control&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remote control can be separated in two categories: wired or wireless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remote control is different from remote communication in a way that the second device usually does not change the logic and that each signal usually represents an action rather than information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(In consumer electronics, a remote control is the device to control a TV or set-top box. Also an RC-car is an (often radio) controlled miniature vehicle.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wired&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A wired remote control system isn't all that different from a regular system. The increased length of wiring might bring in problems though.&#xA;For long-distance wiring, interference and signal strength might become a real problem. The use of differential signals (RS-422, RS-485) in combination with quality (shielded) twisted pair cables should extend the maximum possible cable length.&#xA;The use of internet might also be a solid option for wiring remote control systems, but you should be very wary of security risks (and even then, it's still a risk). High-risk applications are &quot;never&quot; connected to the internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wireless&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For setting up a wireless connection, there are several protocols/implementations around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Such as: Bluetooth (HC-05/06), WiFi (Esp2866), Light/IR, radio signals or magnetics (limited range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The security of wireless can also be a risk, since the signal could be intercepted/altered.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Directional&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some remote control applications are bi-directional, which means that there is no defined &quot;master&quot;  or &quot;slave&quot; device. And that both the devices can control each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Related&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remote-control is closely related with:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remote-interface and remote-communication&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="27346" LastEditDate="2018-11-14T23:16:03.400" LastActivityDate="2018-11-14T23:16:03.400" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20819" PostTypeId="4" CreationDate="2016-02-18T09:49:06.230" Score="0" Body="Used to describe the act of (often wirelessly) controlling another system." OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-02-18T13:53:05.410" LastActivityDate="2016-02-18T13:53:05.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20820" PostTypeId="2" ParentId="20817" CreationDate="2016-02-18T09:58:23.857" Score="1" Body="&lt;p&gt;The I2C protocol is both read and write. Master/Slave depends on who initiates the communication. Typically the master will issue a read command to the slave to retrieve the results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-18T09:58:23.857" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20821" PostTypeId="2" ParentId="20813" CreationDate="2016-02-18T10:04:43.247" Score="3" Body="&lt;p&gt;Simplest solution is to use &lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/scanf/&quot; rel=&quot;nofollow&quot;&gt;sscanf()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int password;&#xA;  char operation;&#xA;  int time;&#xA;  char* buf = &quot;{14:C:123}&quot;;&#xA;  int n = sscanf(buf, &quot;{%d:%c:%d}&quot;, &amp;amp;password, &amp;amp;operation, &amp;amp;time);&#xA;  Serial.print(F(&quot;n=&quot;));&#xA;  Serial.println(n);&#xA;  Serial.print(F(&quot;password=&quot;));&#xA;  Serial.println(password);&#xA;  Serial.print(F(&quot;operation=&quot;));&#xA;  Serial.println(operation);&#xA;  Serial.print(F(&quot;time=&quot;));&#xA;  Serial.println(time);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-18T10:04:43.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20822" PostTypeId="1" CreationDate="2016-02-18T11:43:30.770" Score="3" ViewCount="710" Body="&lt;p&gt;Well im new to coding, but i do have the basic knowledge.&#xA;I'm using an UNO to measure a duty cycle.&#xA;The source of pulse is a Tektronic signal generator (Duty cycle set to 50.000 with frequency of 2khz).&#xA;my code is as follows,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte PWM_PIN = 3;&#xA;float pwm_value_H;&#xA;float pwm_value_L;&#xA;float D;&#xA;&#xA;void setup() {&#xA;    pinMode(PWM_PIN, INPUT);&#xA;    Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;    pwm_value_H = pulseIn(PWM_PIN, HIGH);&#xA;    Serial.println(pwm_value_H);&#xA;    pwm_value_L = pulseIn(PWM_PIN, LOW);&#xA;    Serial.println(pwm_value_L);&#xA;    D = ((pwm_value_H) / (pwm_value_H + pwm_value_L)) * 100.0;&#xA;    Serial.print(&quot;D=&quot;);&#xA;    Serial.println(D);&#xA;    Serial.print(&quot;D=%&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the problem is that my output value of &quot;D&quot; keeps on varying between 49.71, 49.90, 50.00 and 50.7&#xA;Is this because of PULSEIN() function ineffiency?&#xA;or can anyone suggest a better way to measure the duty cycle with +/- 0.01 accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Cj &lt;/p&gt;&#xA;" OwnerUserId="18476" LastEditorUserId="4143" LastEditDate="2016-02-18T11:44:36.990" LastActivityDate="2016-02-18T21:43:22.207" Title="how to solve Varing duty cycle value while using Pulsein()" Tags="|arduino-uno|pwm|pulsein|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20823" PostTypeId="2" ParentId="20822" CreationDate="2016-02-18T11:51:55.613" Score="2" Body="&lt;p&gt;I would start by removing Serial interrupts from the pulseIn period.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    pwm_value_H = pulseIn(PWM_PIN, HIGH);&#xA;    pwm_value_L = pulseIn(PWM_PIN, LOW);&#xA;    Serial.println(pwm_value_H);&#xA;    Serial.println(pwm_value_L);&#xA;    D = ((pwm_value_H) / (pwm_value_H + pwm_value_L)) * 100.0;&#xA;    Serial.print(&quot;D=&quot;);&#xA;    Serial.println(D);&#xA;    Serial.print(&quot;D=%&quot;);&#xA;    Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For higher accuracy I would then look to the Timer based Input Capture. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-18T21:43:22.207" LastActivityDate="2016-02-18T21:43:22.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20824" PostTypeId="2" ParentId="20822" CreationDate="2016-02-18T11:52:22.313" Score="2" Body="&lt;p&gt;There's two basic things wrong with what you are doing there:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;pulseIn()&lt;/code&gt; isn't good for very accurate measurements&lt;/li&gt;&#xA;&lt;li&gt;The signal is still happening while you're doing other things, such as printing the high/low times.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You're not actually measuring the duty cycle of one single cycle, but the HIGH time of one cycle followed by the low cycle of a later one. If you want to do it properly you will have to ditch &lt;code&gt;pulseIn()&lt;/code&gt; and instead get your head around interrupts and timestamps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic method is to present the signal to one of the INT pins, and attach an interrupt to that pin with the trigger set to CHANGE.  The interrupt routine you specify will then be triggered every time the signal changes from HIGH to LOW or from LOW to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the interrupt routine does very little.  It basically records the time the interrupt happened (that must be the very first thing you do), then looks to see if it's a HIGH or a LOW signal on the pin.  You then use the previous timestamp from the last time the interrupt was triggered to work out how long the previous phase lasted and set either a HIGH or a LOW variable depending on the current level of the state (if it's low set a high variable since that was the previous phase level, and if it's high set a low variable) with the time that phase lasted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in your main loop you interrogate those variables periodically to display the duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that still isn't accurate enough then you should look at the hardware &lt;em&gt;Input Capture&lt;/em&gt; module built into the MCU. That uses a hardware timer in much the same way as the interrupt but is able to capture a much more accurate time stamp for you since the time stamp is grabbed the moment the signal changes, rather than after a short delay once the interrupt routine has been called.  Details can be found in the datasheet for the MCU on your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-18T11:52:22.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20826" PostTypeId="2" ParentId="15827" CreationDate="2016-02-18T12:37:06.310" Score="0" Body="&lt;p&gt;Try the &lt;a href=&quot;https://github.com/jantje/libraries/tree/master/simplot&quot; rel=&quot;nofollow&quot;&gt;simplot library&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is from the author of the plugin and works with both 32 and 8 bit processors. There is an example included that should get you going.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plotter itself automatically connects to the first serial connection so there is no connect needed for the plotter like there is for the serial connection.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-02-22T19:47:41.920" LastActivityDate="2016-02-22T19:47:41.920" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20829" PostTypeId="2" ParentId="1013" CreationDate="2016-02-18T14:18:54.010" Score="7" Body="&lt;p&gt;Simplest solution is to use &lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/scanf/&quot; rel=&quot;noreferrer&quot;&gt;sscanf()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int id1, id2, id3;&#xA;  int pos1, pos2, pos3;&#xA;  char* buf = &quot;1:90&amp;amp;2:80&amp;amp;3:180&quot;;&#xA;  int n = sscanf(buf, &quot;%d:%d&amp;amp;%d:%d&amp;amp;%d:%d&quot;, &amp;amp;id1, &amp;amp;pos1, &amp;amp;id2, &amp;amp;pos2, &amp;amp;id3, &amp;amp;pos3);&#xA;  Serial.print(F(&quot;n=&quot;));&#xA;  Serial.println(n);&#xA;  Serial.print(F(&quot;id1=&quot;));&#xA;  Serial.print(id1);&#xA;  Serial.print(F(&quot;, pos1=&quot;));&#xA;  Serial.println(pos1);&#xA;  Serial.print(F(&quot;id2=&quot;));&#xA;  Serial.print(id2);&#xA;  Serial.print(F(&quot;, pos2=&quot;));&#xA;  Serial.println(pos2);&#xA;  Serial.print(F(&quot;id3=&quot;));&#xA;  Serial.print(id3);&#xA;  Serial.print(F(&quot;, pos3=&quot;));&#xA;  Serial.println(pos3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This give the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;n=6&#xA;id1=1, pos1=90&#xA;id2=2, pos2=80&#xA;id3=3, pos3=180&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-18T14:18:54.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20830" PostTypeId="2" ParentId="20716" CreationDate="2016-02-18T14:53:37.240" Score="1" Body="&lt;p&gt;After many hours of unsuccessful bootloader reprogramming attempts, I was able to revive the Pro Micro by trying different timing of double tapping RST while the IDE was compiling/uploading a sketch. After several attempts the Pro Micro suddenly took a sketch and seems to be working now. Not sure how long it will stay this way or how often I will loose it and have to go through these shenanigans again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to all for the help.&lt;/p&gt;&#xA;" OwnerUserId="17096" LastActivityDate="2016-02-18T14:53:37.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20831" PostTypeId="1" CreationDate="2016-02-18T15:33:43.723" Score="4" ViewCount="2460" Body="&lt;p&gt;I have a few Arduino sketches that take 70-90% of dynamic memory. It seems that over 70%, the compiler gives the warning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Low memory available, stability problems may occur.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but otherwise I wasn't noticing any problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I uploaded a sketch that took 89%, which logged String data to the serial port, and found that only newlines were being written out. When I commented out some global variables so that dynamic memory usage got to 88%, then it started printing out the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any hard/fast rule on when this problem occurs? I was surprised by this problem, because the global variables I removed weren't even being used in the sketch, so I had thought the compiler would have removed or optimized them so they didn't waste any space. Are there any ways to automatically improve compilation efficiency and detect wasteful variables?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-02-18T17:26:35.567" Title="At what level does low dynamic memory effect performance?" Tags="|memory-usage|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20832" PostTypeId="2" ParentId="20831" CreationDate="2016-02-18T15:46:39.427" Score="1" Body="&lt;p&gt;The problems occur when you run out of memory. That all depends on what you are doing with the memory that is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;String objects are not good and are wasteful of memory. They really should be avoided, since they use dynamic memory allocation, which uses the &quot;spare&quot; memory that is what's left over from what the compiler says is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no rule, other than &quot;don't run out of memory&quot;, and tracking dynamic usage can be very hard, so try to avoid using it if you can.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-18T15:46:39.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20833" PostTypeId="2" ParentId="20831" CreationDate="2016-02-18T17:26:35.567" Score="4" Body="&lt;p&gt;The typical build memory statistics is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Global variables use XXX bytes (X%) of dynamic memory, &#xA;leaving YYY bytes for local variables. &#xA;Maximum is ZZZ bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is all this about? First, the maximum number of bytes SRAM depends on the MCU. Arduino Uno is ATmega328 based and has 2K byte SRAM. Arduino Mega2560 has 8K byte. &quot;Dynamic memory&quot; in the print out is SRAM. It is not the heap (malloc/free). To avoid confusion I will use &quot;data memory&quot; below. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler allocates memory for all global variable (objects, struct, etc). It also allocates memory for literal strings (character vectors). These are copied from program memory to data memory at startup. All static variables in functions are also allocated. The sum of all these allocations are the &quot;Global variables&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To execute the sketch data memory is used for the stack. It contains the function parameters, local variables in called functions (that are not allocated to registers), saved registers such as return address to the caller, etc. The size of the frame is known by the compiler and may be found in the assembly listing of a sketch. The maximum stack size required is tricky to calculate as it is the call chain with the largest frame size sum. This is not necessarily the deepest call chain. Also the compiler does to a fair amount of inlining.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The heap (malloc/free) is used by classes such as String. The heap starts directly after the global variables in data memory and grows towards the stack. The heap is blocks of memory allocated and deallocated during the execution of the sketch. This behavior may give heap fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interrupt Service Routines (ISR) need to be able to execute &quot;on top of&quot; any function call. The ISRs are typically called on hardware events such as USART data received. The compiler has to generate code that stores the machine state on stack to execute the ISR. Depending on how many registers the ISR needs more or less of the machine state (registers) need to be stored. The worst case is all 32 registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The warning at 30% of SRAM is at approx. 600 bytes left (Arduino Uno, 2K byte). That has to cover the stack and possible heap usage together with ISRs. With a stack heap limit of 32-128 byte, ISR frame of 32-64 byte, that actually leaves worst case approx. 400 bytes for local variables in functions and possible usage of the heap (such as String).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-18T17:26:35.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20834" PostTypeId="1" CreationDate="2016-02-18T17:40:32.207" Score="2" ViewCount="217" Body="&lt;p&gt;I'm trying to connect Maltab and Arduino by this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino=serial('COM7','BaudRate',9600);&#xA;fopen(arduino);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get this message: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open failed: Port: COM7 is not available. No ports are available. Use&#xA;  INSTRFIND to determine if other instrument objects are connected to&#xA;  the requested device.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What might be a proper reason? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have another question which is; How can I save a text file &lt;code&gt;(.txt)&lt;/code&gt; from Matlab to Arduino SD card .. ? Wether opening a &lt;code&gt;.txt&lt;/code&gt; file in arduino or saving it from Matlab directly to Arduino SD card.&lt;/p&gt;&#xA;" OwnerUserId="18488" LastActivityDate="2016-02-18T17:40:32.207" Title="Connection between Matlab and Arduino" Tags="|programming|sd-card|matlab|java|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20835" PostTypeId="1" CreationDate="2016-02-18T17:50:57.893" Score="0" ViewCount="331" Body="&lt;p&gt;I am attempting to receive GPS data from a GPS SD Shield V2-B purchased from maplin. I have attempted the very simple sketch they provide on their website linksprite.com.&#xA;I have also tried following a tutorial found here: &lt;a href=&quot;http://tronixstuff.com/2014/01/15/tutorial-arduino-mediatek-3329-gps/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://tronixstuff.com/2014/01/15/tutorial-arduino-mediatek-3329-gps/&lt;/a&gt;. &#xA;This is the code i am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // Example 19.1&#xA;&#xA;    #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;    SoftwareSerial GPS(2,3); // configure software serial port - &#xA;&#xA;    void setup()&#xA;    {&#xA;      GPS.begin(9600);&#xA;      Serial.begin(9600);&#xA;      pinMode(13,OUTPUT);&#xA;    }&#xA;    void loop()&#xA;    {&#xA;      byte a;&#xA;        if (GPS.available() &amp;gt; 0 )&#xA;      {&#xA;        a = GPS.read(); // get the byte of data from the GPS&#xA;        Serial.write(a);&#xA;        digitalWrite(13,HIGH);&#xA;        delay(1000);&#xA;        digitalWrite(13,LOW);&#xA;        delay(1000);&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino 101. The jumpers on the GPS shield are set up as follows:&lt;a href=&quot;https://i.stack.imgur.com/cPMDt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cPMDt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attempted using both power simply from my Mac and an external 9V battery connected to the Arduino.&#xA;The 'blink' has been added the sketch to test whether data was being received but there was a problem with the serial monitor. This is not the case because the blink did not occur. It however did occur when moved outside of the if statement as you would expect.&#xA;Any help or suggestions would be much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="18487" LastActivityDate="2019-12-21T23:02:20.473" Title="Cannot receive data from GPS SD Shield V2-B" Tags="|arduino-uno|arduino-ide|softwareserial|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20836" PostTypeId="1" AcceptedAnswerId="20839" CreationDate="2016-02-18T18:48:05.457" Score="3" ViewCount="3782" Body="&lt;p&gt;I have an arduino micro and several clone &quot;pro micro&quot;'s both of which are based on the 32u4, i'm trying to make my project have a debug mode which is only active when the serial port is open, the documentation states that using:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;on these boards should only return true if the port is open (on uart based connections it always returns true), i wrote my sketch to take advantage of that but it didn't seem to be working properly, so i stripped back to basics and wrote this sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    pinMode(2, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;    if (Serial){&#xA;        digitalWrite(2, HIGH);&#xA;    }&#xA;    else{&#xA;        digitalWrite(2, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I connected an LED to pin 2 and then tested it by connecting and disconnecting the arduino from the PC, and opening and closing the com port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;after freshly connecting the arduino to the PC the LED is off, when i open a connection to the virtual com port the LED turns on.&#xA;however i would expect the LED to go out once the port is closed, but it remains on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;br&gt;&#xA;1) have i got an out of date bootloader?&lt;br&gt;&#xA;2) if so how do i check?&lt;br&gt;&#xA;3) is this intended behavior and if so why?&lt;br&gt;&#xA;4) is this a bug in the arduino bootloader or libraries?&lt;br&gt;&#xA;5) short of having to change my code to look for serial data to start and stop the debug mode (serial comms are being used for other things in the background) is there any way i can work around this? reading from hidden registers etc?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;br&gt;&#xA;should have mentioned i'm seeing this behavior with or without a call to &lt;code&gt;Serial.begin&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18489" LastEditorUserId="18489" LastEditDate="2016-02-18T19:16:08.057" LastActivityDate="2016-02-20T21:48:31.273" Title="if(Serial) not working correctly on micro or pro micro" Tags="|serial|arduino-micro|arduino-pro-micro|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20838" PostTypeId="1" CreationDate="2016-02-18T19:19:56.787" Score="1" ViewCount="1332" Body="&lt;p&gt;I'm a member of a &lt;a href=&quot;https://en.wikipedia.org/wiki/Formula_SAE&quot; rel=&quot;nofollow&quot;&gt;Formula SAE&lt;/a&gt; team and we use the Performance Electronics ECU which uses the CAN protocol with a speed of 250&amp;nbsp;kbit/s and works fine with our 2D Recording Systems Data logger, but we're trying to build a telemetry system which gathers the same data from the CAN bus using an Arduino Uno and CAN shield provided by SparkFun Electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the CAN shield we're trying to use has failed to initialise the communication with the bus. Kindly help me out on what can be done or are there any alternatives of communicating using CAN with Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. The link for the CAN shield: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/can-bus-shield-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;CAN-Bus Shield Hookup Guide&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18545" OwnerDisplayName="Yashasvi Karnena" LastEditorUserId="6936" LastEditDate="2016-02-19T11:15:42.207" LastActivityDate="2016-06-16T16:06:23.633" Title="CAN communication with Arduino" Tags="|can-bus|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20839" PostTypeId="2" ParentId="20836" CreationDate="2016-02-18T19:30:35.833" Score="9" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;1) have i got an out of date bootloader?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. This has nothing to do with the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) if so how do i check?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See above.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;3) is this intended behavior and if so why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In a manner of speaking, yes - see below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;4) is this a bug in the arduino bootloader or libraries?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. Elsewhere.  See below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;5) short of having to change my code to look for serial data to start and stop the debug mode (serial comms are being used for other things in the background) is there any way i can work around this? reading from hidden registers etc?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can, but only once you understand exactly what is going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with USB serial (AKA CDC/ACM) communication is that there is no way of knowing if the port has been opened by the computer or not.  That functionality was just never designed into the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are two virtual modem signals that the computer can assert that the CDC/ACM device at the other end can examine - one is the equivalent of DTR and the other the equivalent of RTS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's CDC/ACM code examines those, and if either are asserted then it assumes the CDC/ACM port is open. If neither are asserted then it assumes the port is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now comes the tricky part:  You have little or no control over when those signals are asserted or not.  There are three separate factors that decide what happens:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The software being run can manually control the signals.  The Arduino IDE does this to ensure boards that use DTR to reset (like the Uno, etc) actually do reset.&lt;/li&gt;&#xA;&lt;li&gt;The drivers on the computer can decide to automatically control the signals when the port is opened or closed&lt;/li&gt;&#xA;&lt;li&gt;The operating system itself can control the signals when the port is opened or closed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some software will control the RTS/DTR signals properly, some won't. Some drivers will control the signals for you, some won't. Some operating systems (such as Linux) will, unless otherwise instructed, default to automatically controlling the modem lines properly. Others, like Windows, won't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the only way you can be sure that these signals are being controlled properly is to manually control them from your own software used for debugging, or to find a specific terminal emulator that controls the lines properly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-18T19:30:35.833" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20840" PostTypeId="2" ParentId="20328" CreationDate="2016-02-18T19:41:42.077" Score="1" Body="&lt;p&gt;I just encountered this.  After looking at other examples in the compiler command line options, it looks like it should be $(LinkerScript) instead of ($LinkerScript).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Atmel Studio, go to project properties, toolchain, ARM/GNU Linker, Miscellaneous to find the option to change.&lt;/p&gt;&#xA;" OwnerUserId="18492" LastActivityDate="2016-02-18T19:41:42.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20846" PostTypeId="1" CreationDate="2016-02-18T22:43:19.397" Score="1" ViewCount="3663" Body="&lt;p&gt;Does the VCC Output pin always give out a consistent 5V Voltage supply? What is the current output?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the Chip I have. On the chip it says ProMini R160JAC6v. and When i program it. It programs under 5V 16MHz with ATmega 328&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/meuD5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/meuD5.jpg&quot; alt=&quot;5V 16MHz with ATmega 328. If I want to power a 3.3V bluetooth chip can I do it with my board? &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the bluetooth chip I am powering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1iVWM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1iVWM.jpg&quot; alt=&quot;Back Side&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18496" LastActivityDate="2016-02-18T22:59:38.870" Title="Does the VCC Output pin always give out a consistent 5V Voltage supply? What is the current output?" Tags="|power|atmega328|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20847" PostTypeId="1" CreationDate="2016-02-18T22:51:44.833" Score="2" ViewCount="5803" Body="&lt;p&gt;I have an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if RX1 and TX0 the same thing as TX and RX? Will there be a difference in the way I program it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, do I treat RX1 and TX0 as RX and TX in the Arduino IDE when coding?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the chip I have. On the chip it says &quot;ProMini R160JAC6v&quot; and when I program it, it programs under 5V 16MHz with ATmega 328. Notice RST RX1 and TX0 are on the top left corner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WP92A.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WP92A.jpg&quot; alt=&quot;ProMini R160JAC6v 5V 16MHz with ATmega 328&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18496" LastEditorUserId="6936" LastEditDate="2016-02-19T11:12:52.957" LastActivityDate="2016-02-19T11:12:52.957" Title="Is RX1 and TX0 the same thing as TX and RX? Will there be a difference in the way I program it?" Tags="|pins|atmega328|port-mapping|coding-standards|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20848" PostTypeId="2" ParentId="20846" CreationDate="2016-02-18T22:53:55.517" Score="1" Body="&lt;p&gt;If you power from USB the vcc pin gives you the voltage that USB is providing. Somewhere between 4.75 and 5.25v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use external power it provides 5v since that is what the regulator provides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current limit is either the limit of the usb port or the limit of the regulator on your board. Check the datasheet for that regulator (hint: read the schematic to find the model of the regulator).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-02-18T22:59:38.870" LastActivityDate="2016-02-18T22:59:38.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20849" PostTypeId="2" ParentId="20847" CreationDate="2016-02-18T22:55:49.090" Score="5" Body="&lt;p&gt;It's not RX1 and TX0 but RXI and TXO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is receive input and transmit output,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Exactly the same as RX and TX just with the data direction explicitly shown in the lettering.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-18T22:55:49.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20850" PostTypeId="2" ParentId="20847" CreationDate="2016-02-18T23:03:14.177" Score="1" Body="&lt;p&gt;Yes you treat them the same, they are the same pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like (in the photo) you're connecting a bluetooth module.&#xA;Be careful when uploading your sketch.  If you connect something to TX/RX (pins 0 &amp;amp; 1) it may be necessary to disconnect it for arduino-uploading to work.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may find it a more convenient solution to declare a SoftwareSerial on different ports and use that for the bluetooth communications.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-02-18T23:03:14.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20851" PostTypeId="2" ParentId="12462" CreationDate="2016-02-19T01:48:24.300" Score="1" Body="&lt;p&gt;Instead of thinking of the PID output as pid_speed, think of it as motor_power, and what the PI controller is doing is translating errors in rpm into a motor power setting.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are probably getting oscillation because of integral windup.  If your loop is fast relative to your system, each loop worth of error adds to integrator quickly/quicker than the system can adjust.   For example, if a loop takes 1ms, an error of 100rpm could overflow the &quot;int integrator&quot; past 32768 in only 0.327 seconds, and past the threshold where the integrator could peg the output 25500 (=255/Ki) in only 0.255sec  If the integrator is faster than the system, it can easily cause overshoot.  You might consider slowing the loop down to 10ms, 100ms or 1000s to match the physical process and make the kI term be a sane conversion of the integrator's rpmError&lt;em&gt;seconds/100, rpmError&lt;/em&gt;seconds/10, or rpmError*seconds into output power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To handle the numerics and constraints better, like overflowing integrators and negative output values, it would probably be best to use the Arduino PID library from &lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/PIDLibrary&lt;/a&gt; as in Edgar Bonet's comment.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-19T01:48:24.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20852" PostTypeId="1" CreationDate="2016-02-19T02:39:44.600" Score="1" ViewCount="143" Body="&lt;p&gt;Do any shields (or similar boards) exist to let the Mega 2560 (or Due) output a full 100mA per pin on at least 24 pins, in a digital on/off fashion? I know there is a motor shield, but it looks to have only a handful of outputs. It seems very common that people need to output higher current than the MCU can provide safely (if at all), but there do not appear to be any shields for this. Of course individual transistors are fine for a few outputs, and some chips can do up to 8, but what about the rest of us who want to use all those nice pins on the Mega, Due, or similar but who need more power?&lt;/p&gt;&#xA;" OwnerUserId="15303" LastActivityDate="2016-04-19T20:53:44.713" Title="Driver shield providing 24+ pins at 100mA (for Mega 2560)" Tags="|arduino-mega|shields|current|stepper|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20853" PostTypeId="1" CreationDate="2016-02-19T03:41:49.763" Score="0" ViewCount="847" Body="&lt;p&gt;I have a project where it would make a lot of sense to generate Arduino compatible source code, compile it and flash it based on some settings in the project software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to do this without having to rely on the user having installed the Arduino IDE/java?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ideal would be a self-contained library that could be linked to my C/C++ program.&lt;/p&gt;&#xA;" OwnerUserId="18460" LastActivityDate="2016-02-19T10:16:31.770" Title="Using Arduino IDE as an API" Tags="|c++|arduino-ide|compile|flash|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20854" PostTypeId="1" AcceptedAnswerId="20859" CreationDate="2016-02-19T03:49:27.757" Score="0" ViewCount="900" Body="&lt;p&gt;I've got an arduino due and I'm having great difficulty connecting to it. The problem seems to come and go, I was using it just fine only 3 or 4 hours ago but now it just won't connect. I've got the board set to the Arduino Due Native Port and the port set to the /dev/cu.usbmodem1421 (Arduino Due Native Port). Every time I try and upload the sketch however, it gives me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Arduino: 1.6.6 (Mac OS X), Board: &quot;Arduino Due (Native USB Port)&quot;&#xA;&#xA;Sketch uses 10,316 bytes (1%) of program storage space. Maximum is 524,288 bytes.&#xA;processing.app.debug.RunnerException&#xA;    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:130)&#xA;    at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)&#xA;    at processing.app.Sketch.upload(Sketch.java:1178)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1152)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1124)&#xA;    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2452)&#xA;    at java.lang.Thread.run(Thread.java:745)&#xA;Caused by: processing.app.SerialException: Error touching serial port '/dev/cu.usbmodem1421'.&#xA;    at processing.app.Serial.touchForCDCReset(Serial.java:87)&#xA;    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:119)&#xA;    ... 6 more&#xA;Caused by: jssc.SerialPortException: Port name - /dev/cu.usbmodem1421; Method name - openPort(); Exception type - Port not found.&#xA;    at jssc.SerialPort.openPort(SerialPort.java:167)&#xA;    at processing.app.Serial.touchForCDCReset(Serial.java:81)&#xA;    ... 7 more&#xA;Error opening serial port '/dev/cu.usbmodem1421'. (Port not found)&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="18429" LastEditDate="2016-02-19T03:55:26.553" LastActivityDate="2016-02-19T06:18:19.057" Title="Arduino Due Port Not Found" Tags="|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20855" PostTypeId="2" ParentId="20853" CreationDate="2016-02-19T03:53:20.687" Score="1" Body="&lt;p&gt;Have you tried &lt;a href=&quot;https://github.com/ThrowTheSwitch/arduino_c_scaffold&quot; rel=&quot;nofollow&quot;&gt;Arduino C Scaffold project&lt;/a&gt;? &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...the scaffolding lives on Github in the Throw The Switch organization as the Arduino C Scaffold project. This should have everything you need to deploy a C project on an Arduino UNO without the Arduino IDE. If you know your way around Git, you can clone this repository and get to work. If you’d rather not mess with Git right now, you can download the latest revision of the scaffold in a zip file. Once you have the scaffold, take a look at the README. This will walk you through getting the AVR toolchain setup on your environment and describe some of the different ways to use the scaffold.&#xA;  -- &lt;a href=&quot;https://spin.atomicobject.com/2011/10/15/taking-the-training-wheels-off-the-arduino/&quot; rel=&quot;nofollow&quot;&gt;https://spin.atomicobject.com/2011/10/15/taking-the-training-wheels-off-the-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18499" LastActivityDate="2016-02-19T03:53:20.687" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20856" PostTypeId="1" AcceptedAnswerId="20857" CreationDate="2016-02-19T04:47:20.443" Score="3" ViewCount="7540" Body="&lt;p&gt;I'm trying to create an array of objects and later iterate over it and do something with each object. My C++ skills just don't go far enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have so far. I've tried to strip out all the meaningless code. Whats wrong is my tr object is not what I expect it to be. It's numOfCars property is 0 so I know I'm not accessing the train object that I expected. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;class Train {&#xA;    public:&#xA;        int numOfCars;&#xA;        void init();&#xA;        void move();&#xA;};&#xA;&#xA;void Train::init() {&#xA;    //code intentionally removed&#xA;}&#xA;&#xA;void Train::move() {&#xA;    //code intentionally removed&#xA;}&#xA;&#xA;const int trainCount = 2;&#xA;Train train1;&#xA;Train train2;&#xA;Train trains[trainCount] {train1, train2};&#xA;&#xA;void setup() {  &#xA;    Serial.begin(9600);&#xA;    train1.numOfCars = 5;&#xA;    train1.init();&#xA;&#xA;    train2.numOfCars = 5;&#xA;    train2.init();&#xA;}&#xA;&#xA;void loop() {&#xA;    for(int n = 0; n &amp;lt; trainCount; n++) {&#xA;        Train tr = trains[n];&#xA;        Serial.println(tr.numOfCars); //always prints 0&#xA;        tr.move();    &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="69" LastEditorUserId="69" LastEditDate="2016-02-19T14:13:27.200" LastActivityDate="2020-05-17T17:31:52.207" Title="Iterate an Object Array" Tags="|c++|array|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20857" PostTypeId="2" ParentId="20856" CreationDate="2016-02-19T05:36:04.397" Score="5" Body="&lt;p&gt;You are not creating an array of references, you are creating the array from the objects; they are being copied. You can see that this by moving the line (and adding an equals)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Train trains[trainCount] = {train1, train2};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to the bottom of your setup method. However, that is beside the point, as you are not fully using the power of arrays. You needn't create separate objects everywhere, simply create an array of objects right off the bat with &lt;code&gt;new[]&lt;/code&gt; and use them. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;class Train {&#xA;    public:&#xA;        int numOfCars;&#xA;        void init();&#xA;        void move();&#xA;};&#xA;&#xA;void Train::init() {}&#xA;void Train::move() {}&#xA;&#xA;const int trainCount = 2;&#xA;Train* trains = new Train[trainCount];&#xA;&#xA;void setup() {&#xA;    // initialize trains&#xA;    for (int i = 0; i &amp;lt; trainCount; ++i) {&#xA;        trains[i].numOfCars = 5;&#xA;        trains[i].init();&#xA;    }&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    for(int n = 0; n &amp;lt; trainCount; n++) {&#xA;        Serial.println(trains[n].numOfCars); //always prints 0&#xA;        trains[n].move();    &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-02-19T05:36:04.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20858" PostTypeId="1" CreationDate="2016-02-19T06:04:52.053" Score="-2" ViewCount="1317" Body="&lt;p&gt;I would start to learn the best programming language for embedded systems to control devices. What I have heard about that is Assembly Language. I want to know if there is any better languages to code for embedded systems?&lt;/p&gt;&#xA;" OwnerUserId="17054" LastActivityDate="2016-02-19T07:44:34.307" Title="What isthe best programming language for embedded systems?" Tags="|programming|home-automation|automatization|" AnswerCount="1" CommentCount="4" ClosedDate="2016-02-19T08:34:20.950" ContentLicense="CC BY-SA 3.0" />
  <row Id="20859" PostTypeId="2" ParentId="20854" CreationDate="2016-02-19T06:18:19.057" Score="0" Body="&lt;p&gt;Not sure what all that was but a simple restart of my computer seemed to fix it.&lt;/p&gt;&#xA;" OwnerUserId="18429" LastActivityDate="2016-02-19T06:18:19.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20860" PostTypeId="1" CreationDate="2016-02-19T06:35:31.730" Score="1" ViewCount="1911" Body="&lt;p&gt;I need two Arduino units with the HC-06 Bluetooth board to communicate with each other and one of these Arduino units also connected to my Android phone. Is this possible to do with just two HC-06 modules, or even three? Or is there a better solution for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To reiterate what is going on here:&#xA;I have two Arduinos that are running off battery. Arduino 1 is sending data every 0.5 seconds to the Arduino 2. Arduino 2 collects this, adds its own bit of data to it, and then sends this new data packet to my Android phone which will only be connected to Arduino 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't completely decided upon what kind of Arduino board to get, but it needs to be fairly small, but I am planning on the Adafruit Pro-Trinket 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully you get the basic scenario, let me know if you need more clarification and what you think could be done here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot! &lt;/p&gt;&#xA;" OwnerUserId="11385" LastActivityDate="2017-10-27T07:08:39.847" Title="3-Way Bluetooth Communication?" Tags="|sensors|bluetooth|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20861" PostTypeId="2" ParentId="20858" CreationDate="2016-02-19T07:44:34.307" Score="2" Body="&lt;p&gt;Before your question gets closed:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;There is no such thing as &quot;the best&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Assembly&lt;/strong&gt;&#xA;Assembly can be a very powerful language. But at the cost of some:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Assembly is different per machine. &lt;a href=&quot;https://cs.stackexchange.com/questions/46935/is-a-universal-assembly-language-for-all-computers-possible&quot;&gt;https://cs.stackexchange.com/questions/46935/is-a-universal-assembly-language-for-all-computers-possible&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Assembly is somewhat less readable as other programming languages in my honest opinion.&lt;/li&gt;&#xA;&lt;li&gt;I personally feel that assembly should only be used for optimalization rather than standard use of code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C&lt;/strong&gt; C can be as powerful as assembly, only when used correct. In fact, in C (and C++) you can actually inline assembly. &lt;a href=&quot;https://en.wikipedia.org/wiki/Inline_assembler&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Inline_assembler&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C++&lt;/strong&gt; C++ is mostly backwards compatible with C, any C compiler (should?) be able to interpret/compile C code. Which also means you could use inline assembly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C++ also comes with a lot of usefull tools, though, when used wrongly it can actually backfire you. (Which is with most programming languages that allow a lot, but also give you the possibility to do a lot)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe, that C++'s Object Oriented code, with the somewhat backward compatiblity and a little abstraction from the machine (being able to port it to other machines) would be the way to go.&#xA;Though, a good C/assembly programmer will out-play an average C++ programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What about the other languages&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C/C++ could be considered as the standard for embedded devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best thing would be, to ask for individual programming languages, and why one would be better than the other. Or what the differences are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I havent yet found anything that could &quot;compile&quot; Java for embedded devices. Java typically runs in a &quot;run-time evironment&quot;. Which would come down to the fact that it needs an OS or atleast some resources for the code to be run-time interpreted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C/C++ is also known for being &quot;hard real-time&quot; or atleast deterministic qua timing. Which is probably because of the same reason, not needing another layer and being pre-compiled. (And not having an runtime environment)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By these arguments, I believe C++ or C or Assembly would be the best. Or atleast most widely accepted.&#xA;You should check per project, which languages are known by your developers and which other requirements there are (porting to other platforms).&#xA;And it's a bit of a taste issue. I think Object Oriented code is very usefull. But some may see it as excessive/annoying.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="-1" LastEditDate="2017-04-13T12:48:37.497" LastActivityDate="2016-02-19T07:44:34.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20862" PostTypeId="1" AcceptedAnswerId="20891" CreationDate="2016-02-19T08:07:50.013" Score="0" ViewCount="1774" Body="&lt;p&gt;I have a very basic script that is supposed to display something to the serial monitor but no matter what I try the serial monitor won't display anything...I;ve watched about 5 tutorials now and each one has failed to display anything. Any ideas what I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char rx_byte;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available() &amp;gt; 0){&#xA;    rx_byte = Serial.read();&#xA;    Serial.print(&quot;You typed: &quot;);&#xA;    Serial.println(rx_byte);&#xA;    digitalWrite(13, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(13, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="10794" LastEditDate="2016-02-19T20:52:12.210" LastActivityDate="2016-02-19T21:22:41.557" Title="Serial Monitor not displaying anything" Tags="|serial|c++|arduino-due|display|" AnswerCount="3" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="20863" PostTypeId="2" ParentId="20862" CreationDate="2016-02-19T08:24:27.630" Score="0" Body="&lt;p&gt;Try replacing the line &lt;code&gt;char rx_byte;&lt;/code&gt; with &lt;code&gt;int rx_byte=0;&lt;/code&gt;. Use &lt;code&gt;Serial.println(rx_byte,DEC);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rx_byte=0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available() &amp;gt; 0){&#xA;    rx_byte = Serial.read();&#xA;    Serial.print(&quot;You typed: &quot;);&#xA;    Serial.println(rx_byte,DEC);&#xA;    digitalWrite(13, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(13, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10131" LastActivityDate="2016-02-19T08:24:27.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20864" PostTypeId="2" ParentId="20862" CreationDate="2016-02-19T08:34:57.157" Score="1" Body="&lt;p&gt;You have to change the baud rate at the right bottom corner of the serial monitor to 115200 which you have assigned initially.&#xA;I have tested it  and&#xA;It doesn't matter if its int/char&lt;/p&gt;&#xA;" OwnerUserId="18503" LastEditorUserId="18503" LastEditDate="2016-02-19T09:30:13.123" LastActivityDate="2016-02-19T09:30:13.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20865" PostTypeId="2" ParentId="20856" CreationDate="2016-02-19T09:59:42.977" Score="2" Body="&lt;p&gt;As uint128_t has already put it, your problem is that you are creating&#xA;an array of copies. You should really avoid copying trains around,&#xA;especially if you are going to put a significant amount of data in them.&#xA;Instead, just create them once in the array, and then you can either&#xA;invoke them as array members directly (e.g. &lt;code&gt;trains[0].init();&lt;/code&gt;) or use&#xA;references.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you initialize your trains like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int trainCount = 2;&#xA;Train trains[trainCount];&#xA;Train &amp;amp;train1 = trains[0];&#xA;Train &amp;amp;train2 = trains[1];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the &quot;real&quot; trains live in the array, and &lt;code&gt;train1&lt;/code&gt; and &lt;code&gt;train2&lt;/code&gt; are&#xA;references to them. The rest of your code should work fine unchanged. I&#xA;would however suggest to avoid copying the trains in loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    for(int n = 0; n &amp;lt; trainCount; n++) {&#xA;        Train &amp;amp;tr = trains[n];        // notice the '&amp;amp;'!&#xA;        Serial.println(tr.numOfCars);&#xA;        tr.move();    &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-19T09:59:42.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20866" PostTypeId="2" ParentId="20853" CreationDate="2016-02-19T10:16:31.770" Score="1" Body="&lt;p&gt;For compiling and uploading Arduino code, you do not need Java, nor the&#xA;Arduino IDE: you need avr-gcc, avr-libc, the Arduino core library and&#xA;avrdude. With a proper Makefile, your program just needs to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;system(&quot;make upload&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C.f. the tutorial &lt;a href=&quot;http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile&quot; rel=&quot;nofollow&quot;&gt;Compiling Arduino sketches using&#xA;Makefile&lt;/a&gt;.&#xA;On an Ubuntu or other Debian-like OS, you would just&#xA;&lt;code&gt;sudo apt-get install arduino-mk make&lt;/code&gt; to get everything you need installed.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-19T10:16:31.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20868" PostTypeId="1" CreationDate="2016-02-19T13:52:00.020" Score="3" ViewCount="436" Body="&lt;p&gt;I am using the MATLAB Arduino Support Package to create a setup where I can read force data from a load cell and positional data from an incremental encoder - then plot them on MATLAB. It must be done at the same time in order to produce a material stress-strain curve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking of using the &lt;a href=&quot;http://uk.mathworks.com/help/supportpkg/arduinoio/spi-sensors.html&quot; rel=&quot;nofollow&quot;&gt;SPI Device functions to do this&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the data from the load cell and encoder be read synchronously?&lt;/p&gt;&#xA;" OwnerUserId="18509" LastActivityDate="2017-08-15T07:49:03.477" Title="MATLAB - Read from 2 SPI inputs synchronously" Tags="|arduino-uno|matlab|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20869" PostTypeId="2" ParentId="20868" CreationDate="2016-02-19T14:39:05.933" Score="2" Body="&lt;p&gt;Yes and No.&#xA; Synchronously in development slang means step-by-step execution. Asyncronously mean by some event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino has only one core. Even if you use interrupt, Arduino can only execute one command at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best way for you I guess would be read both on Arduino and combine into single value to read at once. Just reading both with &lt;a href=&quot;http://www.mathworks.com/help/supportpkg/arduinoio/ref/readdigitalpin.html&quot; rel=&quot;nofollow&quot;&gt;readDigitalPin&lt;/a&gt;  would give huge latency.&lt;/p&gt;&#xA;" OwnerUserId="18510" LastActivityDate="2016-02-19T14:39:05.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20871" PostTypeId="1" AcceptedAnswerId="20874" CreationDate="2016-02-19T15:06:49.623" Score="-1" ViewCount="213" Body="&lt;p&gt;Currently I'm working on a vending machine project. The vending machine works using 3 button on LCD Keypad Shield DFRobot where 1 button of it assigned as 0.10 cent,the other two 0.20 cent and 0.50 cent respectively. My problem here is how can my system keep track on the balance/coin inserted so that whenever I pressed &lt;code&gt;button 1 = balance 0.10&lt;/code&gt; then later I pressed &lt;code&gt;button 2 = balance 0.30&lt;/code&gt; (because 0.20 cent added to the system). Or if you have a better idea for my code, that should be great. This is my code so far:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#xA;    int lcd_key     = 0;&#xA;    int adc_key_in  = 0;&#xA;    #define btnRIGHT  0&#xA;    #define btnUP     1&#xA;    #define btnDOWN   2&#xA;    #define btnLEFT   3&#xA;    #define btnSELECT 4&#xA;    #define btnNONE   5&#xA;    volatile float balance = 0.00;&#xA;    float number1 = 0.10;&#xA;    float number2 = 0.20;&#xA;    float number3 = 0.50;&#xA;    int read_LCD_buttons()&#xA;    {&#xA;    adc_key_in = analogRead(0);      // read the value from the sensor &#xA;    if (adc_key_in &amp;gt; 1000) return btnNONE; &#xA;    if (adc_key_in &amp;lt; 50)   return btnRIGHT;  &#xA;    if (adc_key_in &amp;lt; 195)  return btnUP; &#xA;    if (adc_key_in &amp;lt; 380)  return btnDOWN; &#xA;    if (adc_key_in &amp;lt; 555)  return btnLEFT; &#xA;    if (adc_key_in &amp;lt; 790)  return btnSELECT;   &#xA;    return btnNONE;  &#xA;    }&#xA;&#xA;    void setup()&#xA;    {&#xA;    lcd.begin(16, 2);            &#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;TouchNGo Machine&quot;); &#xA;    }&#xA;&#xA;    void loop()&#xA;    {&#xA;    lcd.setCursor(0,1);         &#xA;    lcd.print(&quot;Balance=&quot;);      &#xA;    lcd.setCursor(10,1);           &#xA;    lcd_key = read_LCD_buttons(); &#xA;    balance = 0.00 ;&#xA;&#xA;    switch(lcd_key)&#xA;    {&#xA;    case(btnLEFT):&#xA;    {&#xA;    balance = balance + number1  ;&#xA;    lcd.print(&quot;RM&quot;);&#xA;    lcd.println(balance);&#xA;    break;&#xA;    }&#xA;    case(btnRIGHT):&#xA;    {&#xA;    balance = balance + number2 ;&#xA;&#xA;    lcd.print(&quot;RM&quot;);&#xA;    lcd.println(balance);&#xA;    break;&#xA;    }&#xA;    case(btnUP):&#xA;    {&#xA;    balance = balance + number3  ;&#xA;    lcd.print(&quot;RM&quot;);&#xA;    lcd.println(balance);&#xA;    break;&#xA;    }&#xA;    }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would love to hear any comment from you guys.Thanks for the help!&lt;/p&gt;&#xA;&#xA;&#xA;" OwnerUserId="17280" LastEditorUserId="37523" LastEditDate="2019-09-18T13:23:40.510" LastActivityDate="2019-09-18T13:23:40.510" Title="Arduino Vending Machine problem" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20874" PostTypeId="2" ParentId="20871" CreationDate="2016-02-19T16:41:02.590" Score="1" Body="&lt;p&gt;Remove &quot;balance = 0.0;&quot; from you main loop.  It's always clearing your balance.&lt;/p&gt;&#xA;" OwnerUserId="12010" LastActivityDate="2016-02-19T16:41:02.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20877" PostTypeId="2" ParentId="20815" CreationDate="2016-02-19T17:02:47.830" Score="1" Body="&lt;p&gt;If your first clap rings for more than 50ms, the program counts it as a second clap.  After detecting a clap, you need to wait for the sound to die down before you start listening for a second clap.&lt;/p&gt;&#xA;" OwnerUserId="12010" LastActivityDate="2016-02-19T17:02:47.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20878" PostTypeId="2" ParentId="20852" CreationDate="2016-02-19T17:16:54.973" Score="0" Body="&lt;p&gt;You'll likely have to use an &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoProtoShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoProtoShield&lt;/a&gt; with 3+ of those chips you like that do up to 8.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-19T17:16:54.973" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20879" PostTypeId="1" CreationDate="2016-02-19T09:33:27.970" Score="1" ViewCount="634" Body="&lt;p&gt;I am trying to get output from a sensor (micro-structure 5852D), but I only get two outputs: 11 and 255 for even applying pressure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is my code, please show me how to over come this problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#define addrs 0x5F // I2C bus address&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;Wire.begin();&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;   byte lobyte;&#xA;   byte hibyte;&#xA;   int Press;&#xA;&#xA;   Wire.beginTransmission(addrs);&#xA;   Wire.write(1);        &#xA;   int x = Wire.endTransmission(); &#xA;&#xA;   Serial.print(&quot;endTransmission: &quot;);&#xA;   Serial.println(x, DEC);&#xA;&#xA;   Wire.requestFrom(addrs, 2); // contents of your first two registers&#xA;   while(Wire.available() &amp;lt; 2 );          // Check for data from slave&#xA;   {   &#xA;      delay(1000);&#xA;      lobyte = Wire.read();       // Read press high byte&#xA;      Serial.println(lobyte, DEC);&#xA;      hibyte = Wire.read();      // Read press low byte&#xA;      Serial.println(hibyte, DEC);&#xA;&#xA;      Press = toPressure(hibyte, lobyte);&#xA;      Serial.print(&quot;Pressure: &quot;);&#xA;      Serial.println(Press);&#xA;&#xA;      delay(1000);&#xA;   } &#xA;&#xA;}&#xA;&#xA;&#xA;float toPressure(byte hi, byte lo)&#xA;{&#xA;  int a = (hi * 256 + lo) &amp;amp; 0x3FFF;  // see pdf, mask 14 bit&#xA;&#xA;  float rv = (a - 116)* 0.8606; // faster //(t - 1638.0) / 30.84 + 600.0&#xA;  return rv;&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18535" OwnerDisplayName="Shripad Puntambekar" LastActivityDate="2021-04-14T01:14:01.857" Title="Regarding using I2C with Arduino for Silicon Micro-structure 5852 D 1.5 psi" Tags="|i2c|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="20880" PostTypeId="1" CreationDate="2016-02-19T17:51:25.300" Score="2" ViewCount="7341" Body="&lt;p&gt;I'm building a control system for three sump pumps using a single Arduino and a set of relays.  I have float sensors for each one, and need the Arduino to trigger the relays when the float sensors are triggered.  Sensor 1 triggers pump 1, sensor 2 triggers pump 2, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple enough, but I also need each pump to remain on for 30 seconds after its float sensor returns to normal.  This throws me for a loop since I need the other pumps and sensors to function during this delay time.  I quickly found that the blocking &lt;code&gt;delay()&lt;/code&gt; function is no longer feasible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I trigger the relays, keep them on for 30 seconds after the sensors return to normal, but all the while still monitor and control the other sensors/relays?  Would a non-blocking timer solution work?  Would I have to delve into interrupts?&lt;/p&gt;&#xA;" OwnerUserId="18522" LastEditorUserId="9962" LastEditDate="2016-02-23T12:28:49.713" LastActivityDate="2019-01-17T12:53:40.757" Title="Multiple non-blocking countdown timers?" Tags="|arduino-uno|programming|sensors|relay|time|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20881" PostTypeId="2" ParentId="20880" CreationDate="2016-02-19T18:08:53.373" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Would a non-blocking timer solution work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.  Your &quot;timer&quot; doesn't have to be anything more than a start time from &lt;code&gt;millis()&lt;/code&gt; and a flag.  Then your loop just compares the start time to the current &lt;code&gt;millis()&lt;/code&gt; value, and if it's more than the interval you wanted, do the &quot;thing&quot;.  In code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t startTime;&#xA;bool waiting = false;&#xA;const uint32_t PUMP_DURATION = 30000UL;&#xA;&#xA;void setup()&#xA;{&#xA;  // start the &quot;timer&quot;&#xA;  startTime = millis();&#xA;  waiting = true;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (waiting &amp;amp;&amp;amp; (millis() - startTime &amp;gt;= PUMP_DURATION)) {&#xA;    waiting = false;&#xA;    // do something now!&#xA;    foo();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The flag keeps it from checking when the pump &lt;em&gt;isn't&lt;/em&gt; running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have multiple timed things, just make another set of variables (i.e., &lt;code&gt;startTime2&lt;/code&gt; and &lt;code&gt;waiting2&lt;/code&gt;).  Give 'em better names, eh?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also Arduino libraries that encapsulate this common design pattern.  &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Timemark&quot; rel=&quot;nofollow&quot;&gt;TimeMark&lt;/a&gt; is one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=223286.0&quot; rel=&quot;nofollow&quot;&gt;sample code&lt;/a&gt; on the Arduino forum.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-02-19T18:08:53.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20882" PostTypeId="2" ParentId="20880" CreationDate="2016-02-19T18:35:36.937" Score="3" Body="&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;blink-without-delay&quot;-pattern&lt;/a&gt; shows how this can be solved but with several time periods and logic this becomes complex. Some abstraction is needed. The &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Timemark&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timemark&lt;/a&gt; library provides a solution. Belows is the logic for a single sensor-relay pair with a state trace to serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timemark.h&amp;gt;&#xA;&#xA;const uint32_t TURN_OFF_TIMEOUT = 30000L;&#xA;Timemark turnOff(TURN_OFF_TIMEOUT);&#xA;const int sensorPin = 2;&#xA;const int relayPin = 3;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;&#xA;  pinMode(sensorPin, INPUT_PULLUP);&#xA;  pinMode(relayPin, OUTPUT);&#xA;  digitalWrite(relayPin, LOW);&#xA;&#xA;  trace.start();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (trace.expired()) {&#xA;    Serial.print(millis());&#xA;    Serial.print(F(&quot;:sensor=&quot;));&#xA;    Serial.print(digitalRead(sensorPin));&#xA;    Serial.print(F(&quot;, relay=&quot;));&#xA;    Serial.println(digitalRead(relayPin));&#xA;  }&#xA;&#xA;  if (digitalRead(sensorPin) == LOW) {&#xA;    digitalWrite(relayPin, HIGH);&#xA;    turnOff.start();&#xA;  }&#xA;  else if (turnOff.expired()) {&#xA;    digitalWrite(relayPin, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Expanding to three sensor-relays becomes: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timemark.h&amp;gt;&#xA;&#xA;const uint32_t TURN_OFF_TIMEOUT = 30000L;&#xA;const int CONTROL_MAX = 3;&#xA;Timemark turnOff[CONTROL_MAX];&#xA;const int sensorPin[CONTROL_MAX] = { 2, 4, 6 };&#xA;const int relayPin[CONTROL_MAX] = { 3, 5, 7 };&#xA;&#xA;void setup()&#xA;{&#xA;  for (int i = 0; i &amp;lt; CONTROL_MAX; i++) {&#xA;    turnOff[i].limitMillis(TURN_OFF_TIMEOUT);&#xA;    pinMode(sensorPin[i], INPUT_PULLUP);&#xA;    pinMode(relayPin[i], OUTPUT);&#xA;    digitalWrite(relayPin[i], LOW);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{   &#xA;  for (int i = 0; i &amp;lt; CONTROL_MAX; i++) {&#xA;    if (digitalRead(sensorPin[i]) == LOW) {&#xA;      digitalWrite(relayPin[i], HIGH);&#xA;      turnOff[i].start();&#xA;    }&#xA;    else if (turnOff[i].expired()) {&#xA;      digitalWrite(relayPin[i], LOW);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative solution is to use the &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow noreferrer&quot;&gt;Scheduler&lt;/a&gt; library. Below is a rewrite using template functions and a controller task per sensor-relay pair. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;&#xA;const uint32_t TURN_OFF_TIMEOUT = 30000L;&#xA;const uint32_t DEBOUNCE_TIMEOUT = 40L;&#xA;&#xA;template&amp;lt;const int sensorPin, const int relayPin&amp;gt; void setupController()&#xA;{&#xA;  pinMode(sensorPin, INPUT_PULLUP);&#xA;  pinMode(relayPin, OUTPUT);&#xA;  digitalWrite(relayPin, LOW);&#xA;}&#xA;&#xA;template&amp;lt;const int sensorPin, const int relayPin&amp;gt; void loopController()&#xA;{&#xA;  if (digitalRead(sensorPin) == LOW) {&#xA;    digitalWrite(relayPin, HIGH);&#xA;    while (digitalRead(sensorPin) == LOW) delay(DEBOUNCE_TIMEOUT);&#xA;    delay(TURN_OFF_TIMEOUT);&#xA;    digitalWrite(relayPin, LOW);&#xA;  }&#xA;  yield();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Scheduler.start(setupController&amp;lt;2,3&amp;gt;, loopController&amp;lt;2,3&amp;gt;);&#xA;  Scheduler.start(setupController&amp;lt;4,5&amp;gt;, loopController&amp;lt;4,5&amp;gt;);&#xA;  Scheduler.start(setupController&amp;lt;6,7&amp;gt;, loopController&amp;lt;6,7&amp;gt;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  yield();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that the Scheduler requires yield() or delay() to switch between the tasks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2019-01-17T12:53:40.757" LastActivityDate="2019-01-17T12:53:40.757" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="20885" PostTypeId="2" ParentId="20879" CreationDate="2016-02-19T19:14:08.887" Score="2" Body="&lt;p&gt;The issues in your code:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When communicating with the sensor, the sensor expects a &lt;strong&gt;register address&lt;/strong&gt; after the device address. Instead of providing it the register address, you sent the &lt;em&gt;number of bytes you would like to receive&lt;/em&gt;. Good guess, but unfortunately the device was not designed that way.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You did not combine the least significant bits and most significant bits of the sensor output correctly. The LSB contains the 6 (&lt;strong&gt;not 8&lt;/strong&gt;) least significant bits, while the MSB contains the 6 most significant bits. You first combined them like &lt;code&gt;00MMMMMM00LLLLLL&lt;/code&gt; (where bits marked L come from the LSB and bits marked M come from the MSB), and then masked off the upper two bits as in &lt;code&gt;MMMMMM00LLLLLL&lt;/code&gt;. The proper way would have been to only left shift the MSB 6 bits, producing &lt;code&gt;0000MMMMMMLLLLLL&lt;/code&gt;, and then masking away the upper 4 bits leaving &lt;code&gt;MMMMMMLLLLLL&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You should avoid 32 bit floating point math on 8-bit microcontrollers at all costs unless you have a huge amount of processor cycles to spare.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In order to read data from the sensor you must first select the register you want to read. To select a register you must first send the device address (95 in decimal, 5F in hexadecimal) with the write request bit set, and then the register address of the byte you want to read.&lt;br&gt;&#xA;You can then read the contents of the selected register by first sending the device address, this time with the write request bit clear, and then receiving one byte of data immediately followed by a not acknowledge (NACK) to end the transmission.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The internal registers are organized as in the following table:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZFjGh.png&quot; alt=&quot;register table&quot;&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my take on the code. It compiles fine, but obviously I cannot test if it actually works as I don't have the sensor. I removed the scaling routine, as it would be wise to first get it working to some level before implementing less essential features.  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;&#xA;#define SENSOR_I2C_ADDR 95   &#xA;#define SENSOR_REG_PRESSURE_LSB 128  &#xA;#define SENSOR_REG_PRESSURE_MSB 129  &#xA;&#xA;void setup()&#xA;{&#xA;    Wire.begin();&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Wire.beginTransmission(SENSOR_I2C_ADDR);        //Send the address of the register where the least&#xA;    Wire.write(SENSOR_REG_PRESSURE_LSB);            //..significant bits of the pressure measurement are found&#xA;    Wire.endTransmission(false);                    //Send a repeated start&#xA;    Wire.requestFrom(SENSOR_I2C_ADDR, 1, false);    //Request 1 byte of data, followed by a repeated start&#xA;&#xA;    Wire.beginTransmission(SENSOR_I2C_ADDR);        //Send the address of the register where the most&#xA;    Wire.write(SENSOR_REG_PRESSURE_MSB);            //..significant bits of the pressure measurement are found     &#xA;    Wire.endTransmission(false);                    //Send a repeated start&#xA;    Wire.requestFrom(SENSOR_I2C_ADDR, 1, true);     //Request 1 byte of data, followed by a stop, ending the transaction.&#xA;&#xA;    uint16_t pressureRaw;&#xA;&#xA;    //There should now be two bytes of data in the receive buffer.&#xA;    if(Wire.available() == 2)&#xA;    {&#xA;        uint8_t lsb = Wire.read();                  //The first byte contains the 6 least significant bits&#xA;        uint16_t msb = Wire.read();                 //The second byte contains the 6 most significant bits&#xA;        pressureRaw = (msb &amp;lt;&amp;lt; 6 | lsb) &amp;amp; 0x0FFF;    //The most significant bits are aligned and combined with the  &#xA;                                                    //..least significant bits. As the resulting value only has   &#xA;                                                    //..12 bits of precision the upper 4 bits are masked to zero.&#xA;&#xA;        Serial.print(&quot;Raw pressure value: &quot;);&#xA;        Serial.println(pressureRaw);&#xA;    }  &#xA;    else                                            //If more or less than 2 bytes have been received something isn't right.&#xA;    {&#xA;        while(Wire.available())                     //Clear the buffer&#xA;            Wire.read();&#xA;        Serial.println(&quot;I2C transaction error&quot;);&#xA;    }&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some unfathomable reason Silicon Microstructures decided to not include the I2C interface specification in the &lt;a href=&quot;http://www.si-micro.com/upload/product/pdf/SM5852-003-004-015_Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; itself. The information is instead found in a separate &lt;a href=&quot;http://www.si-micro.com/ci2/userfiles/files/40an0110.02.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;application note&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;br&gt;&#xA;Apparently Wire.flush() does absolutely nothing. Implementation from Wire.cpp:  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void TwoWire::flush(void)&#xA;{&#xA;    // XXX: to be implemented.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And no, the implementation isn't in the base class either: &lt;code&gt;virtual void flush() = 0;&lt;/code&gt;. To work around this, I replaced the flush call with a read() loop.&lt;/p&gt;&#xA;" OwnerUserId="18524" LastEditorUserId="18524" LastEditDate="2016-02-20T18:28:45.657" LastActivityDate="2016-02-20T18:28:45.657" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20886" PostTypeId="1" AcceptedAnswerId="20962" CreationDate="2016-02-19T19:29:09.430" Score="2" ViewCount="1946" Body="&lt;p&gt;I am working on a project for tracking cars. I am using an Arduino UNO to receive the position from GPS/GPRS shield. I am OK on obtaining the coordinates position.&#xA;Now I need to send the position to a webserver and then show it on a webpage using the Google Maps API. Which accepts it in a POST or GET method.&#xA;Here is the shield model:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HfhAU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;U-blox Sara G-350&lt;/a&gt;&#xA;and this is its manual &lt;a href=&quot;https://www.u-blox.com/sites/default/files/u-blox-ATCommands_Manual_(UBX-13002752).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;String.h&amp;gt;&#xA;&#xA;&#xA;SoftwareSerial gprsSerial(7 ,8);&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  gprsSerial.begin(19200);                &#xA;  Serial.begin(19200);     &#xA;  delay(2000);&#xA;&#xA; gprsSerial.println(&quot;AT+CGDCONT=3,\&quot;IP\&quot;,\&quot;weborange\&quot;&quot;);&#xA; toSerial();&#xA; delay(2000);&#xA;&#xA; gprsSerial.println(&quot;AT+UHTTP=0&quot;);&#xA; toSerial();&#xA; delay(2000);&#xA; gprsSerial.println(&quot;AT+UHTTP=2,1,\&quot;www.navtec.16mb.com\&quot;&quot;);&#xA;                   //AT+UHTTP=&amp;lt;profile_id&amp;gt;,&amp;lt;op_code&amp;gt;,&amp;lt;HTTP_server_name&amp;gt;&#xA; toSerial();&#xA; delay(2000);&#xA;&#xA; gprsSerial.println(&quot;AT+UHTTP=0,5,80&quot;);&#xA; toSerial();&#xA; delay(2000);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA; //gprsSerial.println(&quot;AT+UHTTP=2,1,\&quot;submit\&quot;&quot;);&#xA;                    //AT+UHTTP=&amp;lt;profile_id&amp;gt;,&amp;lt;op_code&amp;gt;,&amp;lt;param_val&amp;gt;[,&amp;lt;param_val1&amp;gt;]&#xA; //toSerial();&#xA; //delay(2000);&#xA;&#xA; gprsSerial.println(&quot;AT+UHTTPC=2,1,\&quot;/add.php\&quot;,\&quot;filename\&quot;&quot;);  //Problem here!!!!!!!!&#xA;                   //AT+UHTTPC=&amp;lt;profile_id&amp;gt;,&amp;lt;http_command&amp;gt;,&amp;lt;path&amp;gt;,&amp;lt;filename&amp;gt;[,&amp;lt;param1&amp;gt;[,&amp;lt;param2&amp;gt;[,&amp;lt;param3&amp;gt;]]]&#xA; toSerial();&#xA; delay(2000);&#xA;}&#xA;&#xA;void toSerial()&#xA;{&#xA;  while(gprsSerial.available()!=0)&#xA;  {&#xA;    Serial.write(gprsSerial.read());&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+CGDCONT=3,&quot;IP&quot;,&quot;weborange&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&#xA;  +UHTTP=0&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&#xA;  +UHTTP=2,1,&quot;www.navtec.16mb.com&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&#xA;  +UHTTP=0,5,80&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;OK&#xA;  +UHTTPC=2,1,/add.php,filename&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;ERROR&#xA;  +UHTTPC=2,1,/add.php,filename&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;ERROR&#xA;  +UHTTPC=2,1,/add.php,filename&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;ERROR&#xA;  +UHTTPC=2,1,/add.php,filename&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;ERROR ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time, I am waiting for your support, any ideas could help. Sorry for my bad English&lt;/p&gt;&#xA;" OwnerUserId="18525" LastEditorUserId="18525" LastEditDate="2016-02-21T15:25:12.310" LastActivityDate="2016-10-11T20:14:12.597" Title="Sending data to a webserver with GPRS/GPS Shield (U-blox Sara G-350)" Tags="|arduino-uno|shields|gsm|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20888" PostTypeId="2" ParentId="20880" CreationDate="2016-02-19T20:16:31.790" Score="0" Body="&lt;p&gt;You might use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define AMOUNT_OF_TIMERS 10&#xA;unsigned int timer[AMOUNT_OF_TIMERS];&#xA;unsigned int sensors[AMOUNT_OF_TIMERS];&#xA;unsigned int pumps[AMOUNT_OF_TIMERS];&#xA;void setup()&#xA;{&#xA;  sensors[0] = 1;&#xA;  sensors[1] = 2;&#xA;  sensors[2...&#xA;  ......s[9] = 12;&#xA;  pumps[0] = 13;&#xA;  pumps[1....&#xA;  ....s[9] = 22;&#xA;  for(unsigned int i = 0; i&amp;lt; AMOUNT_OF_TIMERS; i++){&#xA;    PinMode(sensors[i],INPUT);&#xA;    PinMode(pumps[i],OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  checkPins();&#xA;  decreaseTimers();&#xA;  delay(1000);&#xA;}&#xA;&#xA;void checkPins(){&#xA;  for(unsigned int i = 0; i&amp;lt; AMOUNT_OF_TIMERS; i++){&#xA;    if(digitalRead(sensors[i])&#xA;    pump[i] = 30;&#xA;  }&#xA;}&#xA;&#xA;void decreaseTimers(){&#xA;  for(unsigned int i = 0; i&amp;lt; AMOUNT_OF_TIMERS; i++){&#xA;    if(timer[i]&amp;gt;0)&#xA;    timer--;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Personally, I think, handling the timing events in an interrupt is way better. Which might also be for the sensor inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not the neatest thing, but it will do.&#xA;Using interrupts should make it even more efficient.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should use interrupts.&lt;/li&gt;&#xA;&lt;li&gt;You might use unsigned chars to preserve extra RAM.&lt;/li&gt;&#xA;&lt;li&gt;You should adjust the timers/delay. (set timer to 300, and delay to 100ms) for better result.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-02-19T20:16:31.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20889" PostTypeId="1" CreationDate="2016-02-19T20:49:18.123" Score="1" ViewCount="3360" Body="&lt;p&gt;I was trying to connect my Arduino Nano to my home Wi-Fi. To do that, I connected my Arduino to ESP8266 module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected pins&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino  | ESP8266&#xA;3.3V     | VCC&#xA;3.3V     | CH_PD&#xA;D10      | RXD&#xA;D11      | TXD&#xA;GND      | GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to connect to Wi-Fi, I used code which I found on internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm getting is &lt;code&gt;&quot;FAILED - Timeout exceeded&quot;&lt;/code&gt; which indicates there is no response from the ESP module. Is it possible I did something wrong and I fried it, or I connected it wrong? Or maybe it does not have enough power (I'm powering my Arduino via computer USB port)? I also read reviews which indicates customers who bought similar product from different vendors they had issues with firmware. Is it possible I have same problem?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial softSerial(10, 11); // RX, TX&#xA;String WSSID = &quot;xxxxxxxxxxxx&quot;;&#xA;String WPASS = &quot;xxxxxxxxxxxx&quot;;&#xA;bool r;&#xA;&#xA;void setup() {&#xA;  /* SETUP SERIAL COMMUNICATION */&#xA;  espSerialSetup();&#xA;  delay(2000); // Without this delay, sometimes, the program will not start until Serial Monitor is connected&#xA;  r = espSendCommand( &quot;AT+CIFSR&quot; , &quot;OK&quot; , 5000 );&#xA;  if( !r ) {&#xA;    r = espSendCommand( &quot;AT+CWMODE=1&quot; , &quot;OK&quot; , 5000 );&#xA;    r = espSendCommand( &quot;AT+CWJAP=\&quot;&quot;+WSSID+&quot;\&quot;,\&quot;&quot;+WPASS+&quot;\&quot;&quot; , &quot;OK&quot; , 15000 );&#xA;  }&#xA;}&#xA;&#xA;void loop(){    &#xA;  r = espSendCommand( &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;108.59.11.102\&quot;,80&quot; , &quot;OK&quot; , 5000 );&#xA;  String getRequest = &quot;GET /shiznic/ HTTP/1.1\r\nHost: www.rootpower.com\r\n&quot;;&#xA;  int getRequestLength = getRequest.length() + 2; // add 2 because \r\n will be appended by SoftwareSerial.println().&#xA;  r = espSendCommand( &quot;AT+CIPSEND=&quot; + String(getRequestLength) , &quot;OK&quot; , 5000 );&#xA;  r = espSendCommand( getRequest , &quot;+IPD&quot; , 15000 );&#xA;  //r = espSendCommand( getRequest , &quot;world&quot; , 15000 ); // page should respond with Hello, world.&#xA;  if( !r ) {&#xA;    Serial.println( &quot;Something wrong...Attempting reset...&quot;);&#xA;    espSendCommand( &quot;AT+RST&quot; , &quot;ready&quot; , 20000);&#xA;    espSendCommand( &quot;AT+CWMODE=1&quot; , &quot;OK&quot; , 5000 );&#xA;    espSendCommand( &quot;AT+CWJAP=\&quot;&quot;+WSSID+&quot;\&quot;,\&quot;&quot;+WPASS+&quot;\&quot;&quot; , &quot;OK&quot; , 15000 );&#xA;  }    &#xA;  delay(3000);   &#xA;}&#xA;&#xA;void espSerialSetup() {&#xA;&#xA;  // change baud rate so SoftwareSerial works better -- need a certain version of ESP for this to work and be retained after power cycle&#xA;  // make sure Serial Monitor port speed is set to 9600&#xA;  softSerial.begin(115200); // default baud rate for ESP8266&#xA;  delay(1000);&#xA;  softSerial.println(&quot;AT+CIOBAUD=9600&quot;);&#xA;  delay(1000);&#xA;  softSerial.begin(9600);&#xA;  Serial.begin(9600);  &#xA;}&#xA;&#xA;bool espSendCommand(String cmd, String goodResponse, unsigned long timeout) {&#xA;  Serial.println(&quot;espSendCommand( &quot; + cmd + &quot; , &quot; + goodResponse + &quot; , &quot; + String(timeout) + &quot; )&quot; );&#xA;  softSerial.println(cmd);&#xA;  unsigned long tnow = millis();&#xA;  unsigned long tstart = millis();&#xA;  unsigned long execTime = 0;&#xA;  String response = &quot;&quot;;&#xA;  char c;&#xA;  while( true ) {&#xA;    if( tnow &amp;gt; tstart + timeout ) {&#xA;      Serial.println(&quot;espSendCommand: FAILED - Timeout exceeded &quot; + String(timeout) + &quot; seconds&quot; );&#xA;      if( response.length() &amp;gt; 0 ) {&#xA;        Serial.println(&quot;espSendCommand: RESPONSE:&quot;);&#xA;        Serial.println( response );&#xA;      } else {&#xA;        Serial.println(&quot;espSendCommand: NO RESPONSE&quot;);&#xA;      }&#xA;      return false;&#xA;    }&#xA;    c = softSerial.read();&#xA;    if( c &amp;gt;= 0 ) {&#xA;      response += String(c);&#xA;      if( response.indexOf(goodResponse) &amp;gt;= 0 ) {&#xA;&#xA;        execTime = ( millis() - tstart );&#xA;        Serial.println(&quot;espSendCommand: SUCCESS - Response time: &quot; + String(execTime) + &quot;ms&quot;);&#xA;        Serial.println(&quot;espSendCommand: RESPONSE:&quot;);&#xA;        Serial.println(response);&#xA;        while(softSerial.available() &amp;gt; 0) {&#xA;          Serial.write(softSerial.read());&#xA;        }&#xA;        return true;&#xA;      }&#xA;    }&#xA;    tnow = millis();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&#xA;I changed connections to &#xA;  D11      | RXD&#xA;  D10      | TXD&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and i also simplified my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp(10, 11);&#xA;&#xA;void setup() {&#xA;   Serial.begin(115200);&#xA;  while (!Serial);&#xA;  Serial.println(&quot;Started&quot;);&#xA;  esp.begin(115200);&#xA;  esp.write(&quot;AT\r\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (esp.available()) {&#xA;    Serial.write(esp.read());&#xA;  }&#xA;&#xA;  if (Serial.available()) {&#xA;    esp.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now I'm sending basic AT command to test connection, and still not getting any response. LED on ESP module is on, so I'm assuming it is working.&lt;/p&gt;&#xA;" OwnerUserId="17231" LastEditorUserId="17231" LastEditDate="2016-02-21T21:28:18.667" LastActivityDate="2016-02-24T03:23:11.797" Title="Did I fry my ESP8266 module or was it something wrong with it?" Tags="|arduino-nano|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20890" PostTypeId="2" ParentId="20621" CreationDate="2016-02-19T21:08:52.813" Score="0" Body="&lt;p&gt;The problem with wrong input was caused by floating base of optocoupler:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qdCG9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qdCG9.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;100k pull-down will fix it.&lt;/p&gt;&#xA;" OwnerUserId="16074" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-19T21:08:52.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20891" PostTypeId="2" ParentId="20862" CreationDate="2016-02-19T21:22:41.557" Score="2" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Which one are you using?&lt;/p&gt;&#xA;&lt;p&gt;The one closest to the reset button, I believe its the native...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is more confusing than I realized. The Due has two ports:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FSR1a.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FSR1a.jpg&quot; alt=&quot;Due ports&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Programming port&lt;/h2&gt;&#xA;&lt;p&gt;For programming, the programming port is easiest to use. &lt;strong&gt;And&lt;/strong&gt; you can &amp;quot;talk&amp;quot; to the serial port using &lt;code&gt;Serial&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&amp;quot;Hello, world!&amp;quot;);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;Native USB port&lt;/h2&gt;&#xA;&lt;p&gt;This lets you emulate USB devices (eg. keyboard, mice). However if you want to use it for Serial communications you need to use a different class &lt;code&gt;SerialUSB&lt;/code&gt; like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  SerialUSB.begin(115200);&#xA;  while (!SerialUSB) ; // wait for it to become ready&#xA;  SerialUSB.println (&amp;quot;Starting ...&amp;quot;);&#xA;  }  // end of setup&#xA;&#xA;unsigned long i;&#xA;&#xA;void loop ()&#xA;  {&#xA;  SerialUSB.print (&amp;quot;Hello, world! Count = &amp;quot;);&#xA;  SerialUSB.println (++i);&#xA;  delay (1000);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It also helps to wait for the serial port to become ready, as I did in &lt;code&gt;setup&lt;/code&gt;. Otherwise you may miss the first 10 lines or so of serial output.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-19T21:22:41.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20892" PostTypeId="2" ParentId="20889" CreationDate="2016-02-19T21:41:44.387" Score="3" Body="&lt;p&gt;By the looks of the information you have provided, it looks as though you have not made the crossed serial connection: &lt;code&gt;rx-tx tx-rx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your wiring:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino  | ESP8266&#xA;3.3V     | VCC&#xA;3.3V     | CH_PD&#xA;D10      | RXD&#xA;D11      | TXD&#xA;GND      | GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And when you intialize the software serial library: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial softSerial(10, 11); // RX, TX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You declare &lt;code&gt;D10&lt;/code&gt; as &lt;code&gt;RX&lt;/code&gt; and then connect it to the ESPs &lt;code&gt;RX&lt;/code&gt; and ditto for the &lt;code&gt;TX&lt;/code&gt; line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino  | ESP8266&#xA;3.3V     | VCC&#xA;3.3V     | CH_PD&#xA;D10      | TXD   //change to this&#xA;D11      | RXD   //change to this&#xA;GND      | GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you need to ensure that the arduino TX line does not exceed 3.3V you can use a voltage divider, logic-level shifter board or a 74LVC245. This is important as the 5V arduino pins will damage a 3.3V device. This is a note as arduino nano is a 5V device from what I know(I may be corrected).&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-02-19T21:41:44.387" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20893" PostTypeId="1" AcceptedAnswerId="20894" CreationDate="2016-02-19T21:46:10.613" Score="2" ViewCount="555" Body="&lt;p&gt;I have built a system using arduino and Ethernet shield. It gets rgb values through URL and changes an rgb led's value. Today I bought an ESP 8266 12E. I want to change to wifi but I cannot find an arduino library that uses spi to connect the arduino to the ESP. I do not want to use only the ESP. Do you know any libraries to do the job or any tutorials.&lt;/p&gt;&#xA;" OwnerUserId="8275" LastActivityDate="2016-02-20T03:02:53.163" Title="ESP 8266 web server using arduino" Tags="|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20894" PostTypeId="2" ParentId="20893" CreationDate="2016-02-19T21:53:40.123" Score="4" Body="&lt;p&gt;The ESP communicates using the UART, not SPI. It uses modem-like AT commands. Unless you write your own ESP firmware, in which case how it communicates is up to you - and so is the accompanying Arduino library.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-19T21:53:40.123" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20896" PostTypeId="2" ParentId="20836" CreationDate="2016-02-19T22:38:26.897" Score="2" Body="&lt;p&gt;I am experiencing the same problem. My environment is Windows 10 on the host side and Arduino 1.6.7 with a genuine Arduino Micro board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the OP's sketch, after compiling and uploading, the light does not go on until you open the serial monitor. This is as expected and shows that the Arduino side has some way of knowing that the serial monitor has started. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you close the serial monitor, the light stays on. It also stays on if you unplug the USB cable. It goes off when you plug the cable back in and goes back on when you restart the serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With some further experimentation and poking around the code, I found that _usbLineInfo.lineState &gt; 0 and thus Serial returns True if either DTR or RTS from the host is nonzero. DTR goes to 0 when the serial monitor is closed but RTS stays HIGH so Serial stays True.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fix is to use the (undocumented) method Serial.dtr(). This is True only if the serial monitor is running. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[edit] If your system has external power so that it should keep working with the USB cable unplugged, testing Serial.dtr() works as long as you you always close the serial monitor before unplugging the USB cable. However it will remain True if the cable is unplugged before closing the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To detect the cable being unplugged, add the line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;USBCON |= 1&amp;lt;&amp;lt;OTGPADE;&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;to setup(). This enables detection of an unplugged USB cable. Then in your loop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;(USBSTA &amp;amp; (1&amp;lt;&amp;lt;VBUS))&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;will be True if the USB cable is plugged in and has power.&lt;/p&gt;&#xA;" OwnerUserId="18526" LastEditorUserId="18526" LastEditDate="2016-02-20T21:48:31.273" LastActivityDate="2016-02-20T21:48:31.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20897" PostTypeId="1" AcceptedAnswerId="20900" CreationDate="2016-02-19T20:17:13.810" Score="1" ViewCount="2674" Body="&lt;p&gt;I'm looking for a way to use Arduino UNO's as serial outputs or input &quot;individually&quot;, I don want to have an RX pin for each TX pin. I know the library &lt;em&gt;SoftwareSerial&lt;/em&gt;, but I'm not sure if it is posible to achieve my objective with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also read that in this library &quot;If using multiple software serial ports, only one can receive data at a time&quot;. Is there any library or method I can use to achieve both of my objectives, using pins &quot;individually&quot; and receiving data from more than a pin at a time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your time.&lt;/p&gt;&#xA;" OwnerUserId="18528" OwnerDisplayName="Lucas" LastActivityDate="2016-02-20T00:03:52.507" Title="Use only one pin as serial output/input with arduino" Tags="|serial|pins|library|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20898" PostTypeId="2" ParentId="20897" CreationDate="2016-02-19T20:37:41.087" Score="1" Body="&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc0941.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR304, &quot;Half Duplex Interrupt Driven Software UART on tinyAVR and megaAVR devices&quot;&lt;/a&gt; describes how to implement a half-duplex software UART using 2 pins. Simply omit the half of the UART that you do not need in your own implementation.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-02-19T20:37:41.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20899" PostTypeId="2" ParentId="20897" CreationDate="2016-02-19T21:04:56.463" Score="0" Body="&lt;p&gt;Serial ports do not require both directions to work. You can connect just one if you want. Of course you won't be able to reply or receive but you know that. Multiple TX from a microcontroller is easy. Just send the data at the speed required. RX is harder because you have to be able to read multiple high speed random inputs at the same time. It requires careful and complicated coding and will not be small or simple. You may not be able to do it and the rest of your project as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are ICs or setups that can multiplex serial lines though. See &lt;a href=&quot;https://electronics.stackexchange.com/questions/111491/multiplexing-ttl-serial-lines-with-transistors&quot;&gt;https://electronics.stackexchange.com/questions/111491/multiplexing-ttl-serial-lines-with-transistors&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-19T21:04:56.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20900" PostTypeId="2" ParentId="20897" CreationDate="2016-02-20T00:03:52.507" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't want to have an RX pin for each TX pin ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I adapted the SoftwareSerial library a while ago to omit the receiving part. You can download that from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/Arduino/SendOnlySoftwareSerial.zip&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/Arduino/SendOnlySoftwareSerial.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use that like SoftwareSerial but if you read you will always get -1 returned, and &lt;code&gt;available&lt;/code&gt; always returns 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The constructor only has the transmit pin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  SendOnlySoftwareSerial(uint8_t transmitPin, bool inverse_logic = false);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any library or method I can use to achieve both of my objectives, using pins &quot;individually&quot; and receiving data from more than a pin at a time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't want an Rx pin, but you want to receive from more than one pin at a time? Now you've lost me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sounds like an &lt;a href=&quot;http://xyproblem.info/&quot; rel=&quot;nofollow&quot;&gt;X-Y Problem&lt;/a&gt; - maybe describe this requirement in more detail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, hardware serial can receive from one pin while the processor is doing something else. If you have a Mega you could receive from 4 ports at once (it has 4 x hardware serial ports).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-20T00:03:52.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20901" PostTypeId="1" CreationDate="2016-02-20T01:05:05.803" Score="2" ViewCount="4936" Body="&lt;p&gt;I have been working on a hydroponic garden that is controlled with Arduinos. I have everything working except for the user interface. What I would like to do is have an LCD screen paired with a rotary encoder for use on the garden, and an ESP8266 WiFi module set as a server working with a custom Android app that I am writing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been working on writing the app and the code that will allow the Arduino and the app to talk to each other, but I have been running into a problem. Sometimes the serial data between the ESP266 and the Arduino is not being picked up by the Arduino. I have verified that the data coming out of the WiFi module is correct, but the Arduino seems to be missing characters. This seems to happen almost at random. Sometimes it will work, and other times it will simply get stuck. I used a SoftwareSerial library to add an extra serial port and printed what the Arduino was receiving from the WiFi module, and it just seems to be missing random characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Up until now I have had the WiFi module connected and the LCD screen. I was using the LCD screen to display debugging messages. I took the LCD screen off and deleted all the LCD code and now everything seems to work just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD screen uses I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does disconnecting the LCD screen solve the issue? Is there a way to make both run at the same time? The LCD uses I2C. I am unaware of anything that would prevent this from working. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.  &lt;/p&gt;&#xA;" OwnerUserId="18531" LastEditorUserId="4628" LastEditDate="2017-01-15T15:32:46.097" LastActivityDate="2017-11-12T07:52:47.497" Title="Serial not working with I2C" Tags="|arduino-uno|serial|i2c|lcd|esp8266|" AnswerCount="1" CommentCount="3" ClosedDate="2017-11-17T01:32:47.690" ContentLicense="CC BY-SA 3.0" />
  <row Id="20902" PostTypeId="2" ParentId="20893" CreationDate="2016-02-20T01:11:34.433" Score="0" Body="&lt;p&gt;The following link is a great resource for learning how to use the WiFi module.  It has all the commands you are likely to need.  The guide is written with the intent that the user will use the module as a standalone device without the Arduino, but at the end of the guide the commands given are all the same.  This is the reference I use for projects like this.  &lt;a href=&quot;http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf&quot; rel=&quot;nofollow&quot;&gt;ESP8622 Quick Start Guide&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18531" LastEditorUserId="18531" LastEditDate="2016-02-20T03:02:53.163" LastActivityDate="2016-02-20T03:02:53.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20903" PostTypeId="2" ParentId="19786" CreationDate="2016-02-20T04:03:01.700" Score="1" Body="&lt;p&gt;Based on the error report it seems that you have just opened the example program from the downloaded folder. In order to add library files (which includes the header files, c++ source code, etc.) you have to move the &lt;em&gt;Adafruit_Motor_Shield_V2_Library-master&lt;/em&gt; folder to the libraries folder. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Documents &gt; arduino &gt; libraries&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If no such folder exist, then create a new folder and name it &lt;em&gt;libraries&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check weather the libraries have been installed, open arduino IDE goto &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;file &gt; example and check weather the example programs are added (you will see &quot;adafruit&quot; in the list)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now, restart the arduino IDE and things should get going.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&#xA;Do not use &quot;-&quot; and do not include space while naming a folder, as the compiler may throw up error. Instead you are free to use &quot;_&quot;,&quot;$&quot;. Name of a folder should always start with a letter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more detail visit &lt;a href=&quot;https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use/how-to-install-a-library&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use/how-to-install-a-library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18534" LastActivityDate="2016-02-20T04:03:01.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20904" PostTypeId="2" ParentId="20901" CreationDate="2016-02-20T04:46:33.180" Score="0" Body="&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SoftwareSerial library requires continually polling the serial ports over short periods of time therefore it presents a problem of having to parse received data into something usable, which is going to be nearly impossible as your program is going to be too busy trying to keep up with all the incoming NMEA characters to assemble it all into something meaningful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in your situation the data from the ESP8266 module is probably fine as you say, but parsing it and sending it to the lcd over I2C is a lot of work and sometimes it will &quot;lose&quot; data it simply doesn't have time to process. This explains why the data loss is hit and miss, and gets resolved when you reduce the processing workload of your program by removing the lcd component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need here is to use an interrupt-driven SoftwareSerial library instead, which works by filling a buffer in the background with received data and allows a little breathing room to process the serial data. A great example is the &lt;a href=&quot;http://arduiniana.org/libraries/NewSoftSerial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;NewSoftwareSerial&lt;/a&gt; library. This link will show you how to use the library , also expand into the details my answer to give you a deeper understanding.&lt;/p&gt;&#xA;" OwnerUserId="11306" LastEditorUserId="4628" LastEditDate="2017-01-15T15:33:30.573" LastActivityDate="2017-01-15T15:33:30.573" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20905" PostTypeId="1" AcceptedAnswerId="20916" CreationDate="2016-02-20T04:50:17.090" Score="0" ViewCount="1447" Body="&lt;p&gt;I'm new to arduino. I had found an interesting project to work on with, but unfortunately I'm held up at compilation error. I tried finding answers to this problem but not able to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    // Include Libraries&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Adafruit_TCS34725.h&amp;gt;&#xA;&#xA;// Initialize Sensors&#xA;Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);&#xA;Servo myservoRed;&#xA;Servo myservoGreen;&#xA;Servo myservoBlue;&#xA;&#xA;&#xA;int posRed = 0;   &#xA;int posGreen = 0;&#xA;int posBlue = 0; &#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Color View Test!&quot;);&#xA;&#xA;  if (tcs.begin()) {&#xA;    Serial.println(&quot;Found sensor&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;No TCS34725 found ... check your connections&quot;);&#xA;    while (1); // halt!&#xA;  }&#xA;&#xA;  //Attach servos to ouput pins&#xA;  myservoRed.attach(9);   &#xA;  myservoGreen.attach(6);&#xA;  myservoBlue.attach(3);&#xA;&#xA;  // Initialize Fan pin&#xA;  pinMode(7, OUTPUT);&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  uint16_t clear, red, green, blue;&#xA;  tcs.setInterrupt(false);      &#xA;  delay(60);  // takes 50ms to read &#xA;  tcs.getRawData(&amp;amp;red, &amp;amp;green, &amp;amp;blue, &amp;amp;clear);&#xA;  tcs.setInterrupt(true);  &#xA;  Serial.print(&quot;C:\t&quot;); Serial.print(clear);&#xA;  Serial.print(&quot;\tR:\t&quot;); Serial.print(red);&#xA;  Serial.print(&quot;\tG:\t&quot;); Serial.print(green);&#xA;  Serial.print(&quot;\tB:\t&quot;); Serial.print(blue);&#xA;&#xA;  // Map color to motor position&#xA;  posRed = map(red,100,10000,10,80);&#xA;  Serial.print(&quot;\tRedPos:\t&quot;); Serial.print(posRed);&#xA;  posGreen = map(green,100,10000,10,80);&#xA;  Serial.print(&quot;\tGreenPos:\t&quot;); Serial.print(posGreen);&#xA;  posBlue = map(blue,100,10000,10,80);&#xA;  Serial.print(&quot;\tBluePos:\t&quot;); Serial.print(posBlue);&#xA;  Serial.println();&#xA;&#xA;  // Write position to motor&#xA;  myservoRed.write(posRed);&#xA;  delay(100); &#xA;  myservoGreen.write(posGreen); &#xA;  delay(100); &#xA;  myservoBlue.write(posBlue); &#xA;  delay(100);          &#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the Wire.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * TwoWire.h - TWI/I2C library for Linux Userspace&#xA; * Copyright (c) 2013 Parav https://github.com/meanbot.&#xA; * All rights reserved.&#xA; *&#xA; * This library is free software; you can redistribute it and/or&#xA; * modify it under the terms of the GNU Lesser General Public&#xA; * License as published by the Free Software Foundation; either&#xA; * version 2.1 of the License, or (at your option) any later version.&#xA; *&#xA; * This library is distributed in the hope that it will be useful,&#xA; * but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&#xA; * Lesser General Public License for more details.&#xA; *&#xA; * You should have received a copy of the GNU Lesser General Public&#xA; * License along with this library; if not, write to the Free Software&#xA; * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&#xA; */&#xA;&#xA;#ifndef TwoWire_h&#xA;#define TwoWire_h&#xA;&#xA;#include &quot;Stream.h&quot;&#xA;#include &quot;variant.h&quot;&#xA;&#xA;#define BUFFER_LENGTH 32&#xA;#define I2C2 0x4819c000&#xA;#define I2C1 0x00000000&#xA;#define WIRE_INTERFACES_COUNT 1&#xA;&#xA;class TwoWire : public Stream {&#xA;public:&#xA;    TwoWire(void(*begin_cb)(void));&#xA;    void begin();&#xA;    void begin(uint8_t);&#xA;    void begin(int);&#xA;    void beginTransmission(uint8_t);&#xA;    void beginTransmission(int);&#xA;    uint8_t endTransmission(void);&#xA;    uint8_t endTransmission(uint8_t);&#xA;    uint8_t requestFrom(uint8_t, uint8_t);&#xA;    uint8_t requestFrom(uint8_t, uint8_t, uint8_t);&#xA;    uint8_t requestFrom(int, int);&#xA;    uint8_t requestFrom(int, int, int);&#xA;    virtual size_t write(uint8_t);&#xA;    virtual size_t write(const uint8_t *, size_t);&#xA;    virtual int available(void);&#xA;    virtual int read(void);&#xA;    virtual int peek(void);&#xA;    virtual void flush(void);&#xA;    void onReceive(void(*)(int));&#xA;    void onRequest(void(*)(void));&#xA;&#xA;    inline size_t write(unsigned long n) { return write((uint8_t)n); }&#xA;    inline size_t write(long n) { return write((uint8_t)n); }&#xA;    inline size_t write(unsigned int n) { return write((uint8_t)n); }&#xA;    inline size_t write(int n) { return write((uint8_t)n); }&#xA;    using Print::write;&#xA;&#xA;    void onService(void);&#xA;&#xA;private:&#xA;    // RX Buffer&#xA;    uint8_t rxBuffer[BUFFER_LENGTH];&#xA;    uint8_t rxBufferIndex;&#xA;    uint8_t rxBufferLength;&#xA;&#xA;    // TX Buffer&#xA;    uint8_t txAddress;&#xA;    uint8_t txBuffer[BUFFER_LENGTH];&#xA;    uint8_t txBufferLength;&#xA;&#xA;    // Service buffer&#xA;    uint8_t srvBuffer[BUFFER_LENGTH];&#xA;    uint8_t srvBufferIndex;&#xA;    uint8_t srvBufferLength;&#xA;&#xA;    // Callback user functions&#xA;    void (*onRequestCallback)(void);&#xA;    void (*onReceiveCallback)(int);&#xA;&#xA;    // Called before initialization&#xA;    void (*onBeginCallback)(void);&#xA;&#xA;    // Timeouts (&#xA;    static const uint32_t RECV_TIMEOUT = 100000;&#xA;    static const uint32_t XMIT_TIMEOUT = 100000;&#xA;&#xA;    uint8_t adapter_nr;&#xA;    int i2c_fd;&#xA;    int i2c_transfer;&#xA;};&#xA;&#xA;#if WIRE_INTERFACES_COUNT &amp;gt; 0&#xA;extern TwoWire Wire;&#xA;#endif&#xA;#if WIRE_INTERFACES_COUNT &amp;gt; 1&#xA;extern TwoWire Wire1;&#xA;#endif&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is Wire.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * TwoWire.h - TWI/I2C library for Linux Userspace&#xA; * Copyright (c) 2013 Parav https://github.com/meanbot.&#xA; * All rights reserved.&#xA; *&#xA; * This library is free software; you can redistribute it and/or&#xA; * modify it under the terms of the GNU Lesser General Public&#xA; * License as published by the Free Software Foundation; either&#xA; * version 2.1 of the License, or (at your option) any later version.&#xA; *&#xA; * This library is distributed in the hope that it will be useful,&#xA; * but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&#xA; * Lesser General Public License for more details.&#xA; *&#xA; * You should have received a copy of the GNU Lesser General Public&#xA; * License along with this library; if not, write to the Free Software&#xA; * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&#xA; */&#xA;&#xA;extern &quot;C&quot; {&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;i2c.h&amp;gt;&#xA;}&#xA;&#xA;#include &quot;Wire.h&quot;&#xA;&#xA;#include &amp;lt;Mux.h&amp;gt;&#xA;#include &amp;lt;trace.h&amp;gt;&#xA;#define MY_TRACE_PREFIX &quot;Wire&quot;&#xA;&#xA;TwoWire::TwoWire(void(*_beginCb)(void)) : rxBufferIndex(0), rxBufferLength(0),&#xA;                      txAddress(0), txBufferLength(0),&#xA;                      srvBufferIndex(0), srvBufferLength(0),&#xA;                      onBeginCallback(_beginCb),&#xA;                      adapter_nr(-1), i2c_fd(-1),&#xA;                      i2c_transfer(0)&#xA;{&#xA;    // Empty&#xA;}&#xA;&#xA;void TwoWire::begin(void)&#xA;{&#xA;    muxSelectI2c(0);&#xA;    if (onBeginCallback)&#xA;        onBeginCallback();&#xA;    if ((adapter_nr = i2c_getadapter(I2C2)) &amp;lt; 0) {&#xA;        return;&#xA;    }&#xA;    if ((i2c_fd = i2c_openadapter(adapter_nr)) &amp;lt; 0) {&#xA;        return;&#xA;    }&#xA;&#xA;}&#xA;&#xA;void TwoWire::begin(uint8_t address)&#xA;{&#xA;    if (onBeginCallback)&#xA;        onBeginCallback();&#xA;}&#xA;&#xA;void TwoWire::begin(int address)&#xA;{&#xA;    begin((uint8_t) address);&#xA;}&#xA;&#xA;uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)&#xA;{&#xA;    if (quantity &amp;gt; BUFFER_LENGTH)&#xA;        quantity = BUFFER_LENGTH;&#xA;&#xA;    /* Set slave address via ioctl  */&#xA;    i2c_setslave(i2c_fd, address);&#xA;&#xA;    if(i2c_transfer) {&#xA;    /* Need to perform a combined read/write operation&#xA;     */&#xA;        i2c_transfer = 0;&#xA;        if (sendStop == false)&#xA;            return 0;&#xA;        i2c_add_to_buf(address, 1, rxBuffer, quantity);&#xA;        if (!i2c_readwrite(i2c_fd)) {&#xA;            rxBufferIndex = 0;&#xA;            rxBufferLength = quantity;&#xA;            i2c_transfer = 0;&#xA;            return quantity;&#xA;        } else&#xA;            return 0;&#xA;    }&#xA;    if (i2c_readbytes(i2c_fd, rxBuffer, quantity) &amp;lt; 0)&#xA;        return 0;&#xA;    // set rx buffer iterator vars&#xA;    rxBufferIndex = 0;&#xA;    rxBufferLength = quantity;&#xA;&#xA;    return quantity;&#xA;}&#xA;&#xA;uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)&#xA;{&#xA;    return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) true);&#xA;}&#xA;&#xA;uint8_t TwoWire::requestFrom(int address, int quantity)&#xA;{&#xA;    return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) true);&#xA;}&#xA;&#xA;uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)&#xA;{&#xA;    return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) sendStop);&#xA;}&#xA;&#xA;void TwoWire::beginTransmission(uint8_t address)&#xA;{&#xA;    if (i2c_fd &amp;lt; 0 || adapter_nr &amp;lt; 0)&#xA;        return;&#xA;    /* set slave address via ioctl in case we need to perform terminating&#xA;     * write operation&#xA;     */&#xA;    i2c_setslave(i2c_fd, address);&#xA;    // save address of target and empty buffer&#xA;    txAddress = address;&#xA;    txBufferLength = 0;&#xA;}&#xA;&#xA;void TwoWire::beginTransmission(int address)&#xA;{&#xA;    beginTransmission((uint8_t) address);&#xA;}&#xA;&#xA;//&#xA;//  Originally, 'endTransmission' was an f(void) function.&#xA;//  It has been modified to take one parameter indicating&#xA;//  whether or not a STOP should be performed on the bus.&#xA;//  Calling endTransmission(false) allows a sketch to&#xA;//  perform a repeated start.&#xA;//&#xA;//  WARNING: Nothing in the library keeps track of whether&#xA;//  the bus tenure has been properly ended with a STOP. It&#xA;//  is very possible to leave the bus in a hung state if&#xA;//  no call to endTransmission(true) is made. Some I2C&#xA;//  devices will behave oddly if they do not see a STOP.&#xA;//&#xA;uint8_t TwoWire::endTransmission(uint8_t sendStop)&#xA;{&#xA;    int err;&#xA;    if (sendStop == true) {&#xA;&#xA;        // transmit buffer (blocking)&#xA;        if (txBufferLength &amp;gt; 1)&#xA;            err = i2c_writebytes(i2c_fd, txBuffer, txBufferLength);&#xA;        else if (txBufferLength == 1)&#xA;            err = i2c_writebyte(i2c_fd, *txBuffer);&#xA;        else&#xA;        /* FIXME: A zero byte transmit is typically used to check for an&#xA;         * ACK from the slave device. I'm not sure if this is the&#xA;         * correct way to do this.&#xA;         */&#xA;            err = i2c_readbyte(i2c_fd);&#xA;        // empty buffer&#xA;        txBufferLength = 0;&#xA;        if (err &amp;lt; 0)&#xA;            return 2;&#xA;        return 0;&#xA;    } else {&#xA;    /* sendStop = false&#xA;     * pretend we have held the bus while&#xA;     * actually waiting for the next operation&#xA;     */&#xA;        i2c_add_to_buf(txAddress, 0, txBuffer, txBufferLength);&#xA;        i2c_transfer = 1;&#xA;        return 0;&#xA;    }&#xA;}&#xA;&#xA;//  This provides backwards compatibility with the original&#xA;//  definition, and expected behaviour, of endTransmission&#xA;//&#xA;uint8_t TwoWire::endTransmission(void)&#xA;{&#xA;    return endTransmission(true);&#xA;}&#xA;&#xA;size_t TwoWire::write(uint8_t data)&#xA;{&#xA;    if (txBufferLength &amp;gt;= BUFFER_LENGTH)&#xA;        return 0;&#xA;    txBuffer[txBufferLength++] = data;&#xA;    return 1;&#xA;}&#xA;&#xA;size_t TwoWire::write(const uint8_t *data, size_t quantity)&#xA;{&#xA;    for (size_t i = 0; i &amp;lt; quantity; ++i) {&#xA;        if (txBufferLength &amp;gt;= BUFFER_LENGTH)&#xA;            return i;&#xA;        txBuffer[txBufferLength++] = data[i];&#xA;    }&#xA;    return quantity;&#xA;}&#xA;&#xA;int TwoWire::available(void)&#xA;{&#xA;    return rxBufferLength - rxBufferIndex;&#xA;}&#xA;&#xA;int TwoWire::read(void)&#xA;{&#xA;    if (rxBufferIndex &amp;lt; rxBufferLength)&#xA;        return rxBuffer[rxBufferIndex++];&#xA;    return -1;&#xA;}&#xA;&#xA;int TwoWire::peek(void)&#xA;{&#xA;    if (rxBufferIndex &amp;lt; rxBufferLength)&#xA;        return rxBuffer[rxBufferIndex];&#xA;    return -1;&#xA;}&#xA;&#xA;void TwoWire::flush(void)&#xA;{&#xA;    // Do nothing, use endTransmission(..) to force&#xA;    // data transfer.&#xA;}&#xA;&#xA;void TwoWire::onReceive(void(*function)(int))&#xA;{&#xA;    onReceiveCallback = function;&#xA;}&#xA;&#xA;void TwoWire::onRequest(void(*function)(void)) {&#xA;    onRequestCallback = function;&#xA;}&#xA;&#xA;void TwoWire::onService(void)&#xA;{&#xA;}&#xA;&#xA;#if WIRE_INTERFACES_COUNT &amp;gt; 0&#xA;static void Wire_Init(void)&#xA;{&#xA;}&#xA;&#xA;TwoWire Wire = TwoWire(Wire_Init);&#xA;&#xA;void WIRE_ISR_HANDLER(void) {&#xA;    Wire.onService();&#xA;}&#xA;#endif&#xA;&#xA;#if WIRE_INTERFACES_COUNT &amp;gt; 1&#xA;static void Wire1_Init(void)&#xA;{&#xA;    if ((adapter_nr = i2c_getadapter(I2C1)) &amp;lt; 0) {&#xA;        return;&#xA;    }&#xA;    if ((i2c_fd = i2c_openadapter) &amp;lt; 0) {&#xA;        return;&#xA;    }&#xA;}&#xA;&#xA;TwoWire Wire1 = TwoWire(Wire1_Init);&#xA;&#xA;void WIRE1_ISR_HANDLER(void) {&#xA;    Wire1.onService();&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the error message i got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libraries\Servo\Wire.cpp.o: In function `WIRE_ISR_HANDLER()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:186: multiple definition of `TwoWire::write(unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:186: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::write(unsigned char const*, unsigned int)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:194: multiple definition of `TwoWire::write(unsigned char const*, unsigned int)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:194: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::requestFrom(unsigned char, unsigned char, unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:204: multiple definition of `TwoWire::available()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:204: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::read()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:209: multiple definition of `TwoWire::read()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:209: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::peek()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:216: multiple definition of `TwoWire::peek()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:216: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::flush()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:223: multiple definition of `TwoWire::flush()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:223: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::TwoWire(void (*)())':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:32: multiple definition of `TwoWire::TwoWire(void (*)())'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:32: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::TwoWire(void (*)())':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:32: multiple definition of `TwoWire::TwoWire(void (*)())'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:32: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::begin()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:43: multiple definition of `TwoWire::begin()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:43: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::begin(unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:57: multiple definition of `TwoWire::begin(unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:57: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::begin(int)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:63: multiple definition of `TwoWire::begin(int)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:63: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::requestFrom(unsigned char, unsigned char, unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:68: multiple definition of `TwoWire::requestFrom(unsigned char, unsigned char, unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:68: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::requestFrom(unsigned char, unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:100: multiple definition of `TwoWire::requestFrom(unsigned char, unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:100: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::requestFrom(int, int)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:105: multiple definition of `TwoWire::requestFrom(int, int)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:105: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::requestFrom(int, int, int)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:110: multiple definition of `TwoWire::requestFrom(int, int, int)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:110: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::beginTransmission(unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:115: multiple definition of `TwoWire::beginTransmission(unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:115: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::beginTransmission(int)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:128: multiple definition of `TwoWire::beginTransmission(int)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:128: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::endTransmission(unsigned char)':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:146: multiple definition of `TwoWire::endTransmission(unsigned char)'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:146: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::endTransmission()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:181: multiple definition of `TwoWire::endTransmission()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:181: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::onReceive(void (*)(int))':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:229: multiple definition of `TwoWire::onReceive(void (*)(int))'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:229: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::onRequest(void (*)())':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:233: multiple definition of `TwoWire::onRequest(void (*)())'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:233: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `TwoWire::onService()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:238: multiple definition of `TwoWire::onService()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:238: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `WIRE_ISR_HANDLER()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:248: multiple definition of `WIRE_ISR_HANDLER()'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:248: first defined here&#xA;&#xA;libraries\Servo\Wire.cpp.o: In function `WIRE_ISR_HANDLER()':&#xA;&#xA;C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Servo\src/Wire.cpp:186: multiple definition of `Wire'&#xA;&#xA;libraries\Wire\Wire.cpp.o:C:\Users\Danush\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\Wire\src/Wire.cpp:186: first defined here&#xA;&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&#xA;exit status 1&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18534" LastEditorUserId="18534" LastEditDate="2016-02-20T04:58:50.713" LastActivityDate="2016-02-20T12:31:48.357" Title="compilation error in arduino" Tags="|arduino-uno|arduino-ide|compile|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20906" PostTypeId="1" AcceptedAnswerId="20907" CreationDate="2016-02-20T07:21:33.300" Score="3" ViewCount="935" Body="&lt;p&gt;I'd like to ask you some questions about ARM processor from Atmel like the SAM3X8E, the one used in the Arduino Due. I have found this [AVR programming guide] from abcminiuser on avrfreaks very helpful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1. Why are there no ICSP pins in Arduino Due to use it to program the SAM3X8E from an external programmer instead of the USB port in the Due board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2. If I want to program an Arduino Due from an external programmer which of the programmers in abcminiuser guide will do the job and give me the ability to program 8/16/32bit AVR and ARM chips from Atmel at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q3. On the Arduino Due website I read this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Uploading sketches to the SAM3X is different than the AVR Microcontrollers found in other Arduino boards because the flash memory needs to be erased before being re-programmed. Upload to the chip is managed by ROM on the SAM3X, which is run only when the chip's flash memory is empty. &quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What is that mean?&lt;/p&gt;&#xA;" OwnerUserId="4533" OwnerDisplayName="Haider" LastEditorUserId="16988" LastEditDate="2016-02-21T00:30:14.840" LastActivityDate="2016-02-21T00:30:14.840" Title="Need some explain before desigin my own custom Arduino Due board" Tags="|arduino-due|icsp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20907" PostTypeId="2" ParentId="20906" CreationDate="2016-02-20T09:13:42.800" Score="3" Body="&lt;ol&gt;&#xA;&lt;li&gt;Because it is not needed. The chip comes with the bootloader pre programmed in  ROM, not in Flash. It cannot be replaced, upgraded, removed, etc like other more sensible chips. So there is no real need for ICSP since the main use for that is putting the bootloader on.&lt;/li&gt;&#xA;&lt;li&gt;Unknown.&lt;/li&gt;&#xA;&lt;li&gt;Unlike the AVR chips, whose bootloader always runs first for about 2 seconds, the SAM3X's boot loader only runs if the flash is empty. As a result there is a way to empty the flash built in to the Arduino code, so that it can be erased by software. That means that the software has to be working right though, which isn't always the case, since people write bad code which crashes the chip. As a result they added a erase button to the board so you can manually erase the chip and get the bootloader to run.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have always maintained that the SAM3X is a really idiotically designed chip and I wouldn't ever use it in a design of my own.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-02-20T09:18:47.880" LastActivityDate="2016-02-20T09:18:47.880" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20908" PostTypeId="1" AcceptedAnswerId="20912" CreationDate="2016-02-20T09:29:48.667" Score="0" ViewCount="9540" Body="&lt;p&gt;I want to get the GPS ordinates in degrees with 6 decimal accuracy. I can obtain this by creating a gps object with TinyGPS library. but In the TinyGPS example codes, its written&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(gps.location.lat(), 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I actually want to store this latitude degrees in a variable of type string or float. when i write this;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double Tiny_latitude = (gps.location.lat());&#xA;Serial.print(&quot;Tiny lat:&quot;);&#xA;Serial.println(Tiny_latitude);      &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it returns me Tiny lat:33.55 on serial monitor. But i want 33.546600.&#xA;How do I do that ? &lt;/p&gt;&#xA;" OwnerUserId="13754" LastEditorUserId="13754" LastEditDate="2016-02-20T09:48:50.960" LastActivityDate="2016-02-20T11:12:29.927" Title="Store TinyGPS++ latitude value into a variable of type string or float" Tags="|arduino-mega|gps|tinygps|float|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="20909" PostTypeId="2" ParentId="5028" CreationDate="2016-02-20T09:30:01.887" Score="0" Body="&lt;pre&gt;&lt;code&gt;while ( !(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0)) );  // wait for another char - WARNING this will wait forever if nothing is received&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comment hits the nail on the head.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'll wait forever, but it's so because it has been &quot;designed&quot; in such a way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've got 2 options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Re-think your &quot;design&quot;:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Do not make your UART wait for an n-amount of characters. You could buffer the received characters, and handle/clear the buffer. There should be a lot of info about this on the web.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Quick and dirty fix:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Add a timeout to the waiting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (unsigned int timeout = 16000; (!(UCSR0A &amp;amp; (1&amp;lt;&amp;lt;RXC0))) &amp;amp;&amp;amp; timeout &amp;gt; 0; timeout-- );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This isn't very efficient, but should work.&#xA;Be sure to check for what reason the waiting stopped (if the timeout ran out, or if you actually received something), to avoid pushing in nonesense that's in the UDR0 at that moment (when you timeout).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-05-20T11:51:45.017" LastActivityDate="2016-05-20T11:51:45.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20910" PostTypeId="1" CreationDate="2016-02-20T10:40:34.460" Score="0" ViewCount="1519" Body="&lt;p&gt;How best might arduino nodes pass incoming serial ascii messages out as ascii network broadcasts for all others to receive and pass out through their serial ports? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;ie: typing a msg from the IDE serial monitor of any ethernet node should cause that msg to be output to the serial monitors of all other nodes.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2016-02-20T11:30:45.400" Title="Is there a practical way to broadcast and receive ascii payloads over ethernet or wifi?" Tags="|serial|wifi|ethernet|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20911" PostTypeId="1" AcceptedAnswerId="20913" CreationDate="2016-02-20T11:09:40.033" Score="5" ViewCount="35570" Body="&lt;p&gt;I have a float variable lng = 33.785469 and lat = 78.126548. Now can I convert them to String and append in a String variable &quot;my_location&quot; as &quot;your location is \nlng = 33.785469 \nlat = 78.126548&quot;. I was trying to do this with &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char charVal[5];               //temporarily holds data from vals &#xA;    String stringVal = &quot;&quot;;     //data on buff is copied to this string&#xA;&#xA;    dtostrf(lng , 4, 2, charVal);  //4 is mininum width, 2 is precision; float value is copied onto buff&#xA;    //convert chararray to string&#xA;    for(int i=0;i&amp;lt;sizeof(charVal);i++)&#xA;    {&#xA;    stringVal+=charVal[i];&#xA;    }&#xA;    GPS_string = GPS_string + &quot;Car location: \nlat:&quot; + stringVal; &#xA;    stringVal = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it given me an error :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: cannot convert 'String' to 'double' for argument '1' to 'char* dtostrf(double, signed char, unsigned char,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13754" LastActivityDate="2016-02-20T11:25:37.043" Title="How to append float value of into a string ?" Tags="|arduino-uno|c|string|float|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20912" PostTypeId="2" ParentId="20908" CreationDate="2016-02-20T11:12:29.927" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;it returns me Tiny lat:33.55 on serial monitor. But i want 33.546600. How do I do that? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The issue is simply the number of decimal places. That can be added to the Serial.println(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double Tiny_latitude = (gps.location.lat());&#xA;Serial.print(&quot;Tiny lat:&quot;);&#xA;Serial.println(Tiny_latitude, 6);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Now if i want to make a String &quot;your location is \nlat:33.546600 \nlong: 75.456912&quot; , i.e. my String variable are stored in Tiny_latitude and Tiny_longitude and want to make a string my_Location. How do i do that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would use sprintf() for that but as that requires some additional build parameters the easiest way is to use String. Some special care is needed to increase the number of decimal places. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  ...&#xA;  float latitude = 33.546600;&#xA;  float longitude = 75.456912;&#xA;  String buf;&#xA;  buf += F(&quot;your location is \nlat:&quot;);&#xA;  buf += String(latitude, 6);&#xA;  buf += F(&quot;\nlong:&quot;);&#xA;  buf += String(longitude, 6);&#xA;  Serial.println(buf);&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-20T11:12:29.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20913" PostTypeId="2" ParentId="20911" CreationDate="2016-02-20T11:16:50.870" Score="5" Body="&lt;p&gt;This has been answered in the previous &lt;a href=&quot;https://arduino.stackexchange.com/questions/20908/store-tinygps-latitude-value-into-a-variable-of-type-string-or-float&quot;&gt;question&lt;/a&gt; but I can repeat it here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  ...&#xA;  float latitude = 33.546600;&#xA;  float longitude = 75.456912;&#xA;  String buf;&#xA;  buf += F(&quot;your location is \nlat:&quot;);&#xA;  buf += String(latitude, 6);&#xA;  buf += F(&quot;\nlong:&quot;);&#xA;  buf += String(longitude, 6);&#xA;  Serial.println(buf);&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;An alternative is to use &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga060c998e77fb5fc0d3168b3ce8771d42&quot; rel=&quot;noreferrer&quot;&gt;dtostrf()&lt;/a&gt; as in your snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  ...    &#xA;  float latitude = 33.546600;&#xA;  float longitude = 75.456912;&#xA;  const int BUF_MAX = 64;&#xA;  char buf[BUF_MAX];&#xA;  const int VAL_MAX = 16;&#xA;  char val[VAL_MAX];&#xA;  strcpy_P(buf, (const char*) F(&quot;your location is \nlat:&quot;));&#xA;  dtostrf(latitude, 8, 6, val);&#xA;  strcat(buf, val);&#xA;  strcat_P(buf, (const char*) F(&quot;\nlong:&quot;));&#xA;  dtostrf(longitude, 8, 6, val);&#xA;  strcat(buf, val);&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-20T11:25:37.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20914" PostTypeId="2" ParentId="20910" CreationDate="2016-02-20T11:30:45.400" Score="1" Body="&lt;p&gt;The magical trick you are looking for is Ethernet UDP Broadcast. By chance there is an example sketch in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/UDPSendReceiveString&quot; rel=&quot;nofollow&quot;&gt;Arduino Tutorial&lt;/a&gt;. I cannot say if it is up to date but this will help you get started. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-20T11:30:45.400" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20915" PostTypeId="1" CreationDate="2016-02-20T12:10:30.103" Score="11" ViewCount="421" Body="&lt;p&gt;I'm using the Arduino Starter Kit so I have a Uno R3 and going through the examples I'm trying to read temperature data from my controller in Arduino Studio.&lt;/p&gt;&#xA;&lt;p&gt;In essence my problem can be reduced down to&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.print(&amp;quot;stuff&amp;quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Which I'd expect to keep printing &amp;quot;stuff&amp;quot; on the serial monitor.&lt;/p&gt;&#xA;&lt;p&gt;(In practice I'm running &lt;a href=&quot;https://codebender.cc/example/10.StarterKit/p03_LoveOMeter#p03_LoveOMeter.ino&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; exact code but all the temperature-reading going on feels irrelevant to my problem, I'm simply mentioning it because I can observe that mye LEDs light up when the temperature rises so I know the code is uploaded and running on the Duo).&lt;/p&gt;&#xA;&lt;p&gt;I'm not seeing any errors in the studio console, and if I connect using &lt;code&gt;gtkterm&lt;/code&gt; or &lt;code&gt;screen&lt;/code&gt; I can see data being sent so the problem seems to be isolated to the AndroidStudio serial monitor itself.&lt;/p&gt;&#xA;&lt;p&gt;I'm running Ubuntu 14.04 and I've connected via USB on &lt;code&gt;/dev/ttyACM3&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I tried running&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;stty -F /dev/ttyACM3 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;as suggested &lt;a href=&quot;http://playground.arduino.cc/Interfacing/LinuxTTY&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; and I also tried with baud 115200, taking care to also change the value in my &lt;code&gt;setup&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;p&gt;I also ran&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;chmod a+rw /dev/ttyACM3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But I'm still not seeing any errors or output. How do I proceed to debug this issue?&lt;/p&gt;&#xA;&lt;p&gt;Running &lt;code&gt;ls -l /dev/ttyACM*&lt;/code&gt; gives&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;crw-rw---- 1 root dialout 166, 0 feb.  20 14:22 /dev/ttyACM0&lt;/p&gt;&#xA;&lt;p&gt;crw-rw---- 1 root dialout 166, 1 feb.  20 14:22 /dev/ttyACM1&lt;/p&gt;&#xA;&lt;p&gt;crw-rw---- 1 root dialout 166, 2 feb.  20 14:22 /dev/ttyACM2&lt;/p&gt;&#xA;&lt;p&gt;crw-rw-rw- 1 root dialout 166, 3 feb.  20 14:30 /dev/ttyACM3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18542" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-08-07T19:25:01.780" Title="I can't seem to receive data to the ArduinoStudio serial monitor on ubuntu 14.04" Tags="|arduino-uno|arduino-ide|ubuntu|" AnswerCount="1" CommentCount="16" ClosedDate="2017-08-07T21:55:43.160" ContentLicense="CC BY-SA 3.0" />
  <row Id="20916" PostTypeId="2" ParentId="20905" CreationDate="2016-02-20T12:31:48.357" Score="1" Body="&lt;p&gt;Looks like the Servo library has Wire source files in it for some reason. I checked my Servo library, and it doesn't have those, so not sure what's going on there, but maybe try removing Wire.cpp from Servo/src/? (keep in the file so you can put it back if necessary)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;credits to uint128_t&lt;/strong&gt;(in the comments) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on his suggestion i removed the &#xA;&lt;em&gt;wire&lt;/em&gt; library files present in servo library folder and things worked just fine. &lt;/p&gt;&#xA;" OwnerUserId="18534" LastActivityDate="2016-02-20T12:31:48.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20919" PostTypeId="1" CreationDate="2016-02-20T16:56:20.960" Score="2" ViewCount="352" Body="&lt;p&gt;I have an Arduino Nano, and I have some issues with it. Basically it needs to control the brightness of a lamp via PWM (plus some circuitry of course). It's hooked up via serial to a little x86 embedded board which runs Linux, and that board is telling the Arduino the desired brightness level (0-255) every 5 seconds over serial. So the only thing the Arduino has to do is retrieve numbers from the other device over serial, and set the PWM output to those values. Here's the code that runs on the Arduino (I inserted some comments so it's easier to read):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Edit: I removed the original code to clean things up as it's not relevant anymore, but you can still view it &lt;a href=&quot;http://pastebin.com/RpELDBx2&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing fancy about the code really. It checks for incoming data about 10 times a second, and if there's any, it converts it into an &lt;code&gt;int&lt;/code&gt; and sets the PWM output to that value. I know, that part where I manually extract the number characters probably could be replaced by Arduino library calls for cleaner code, but whatever. It works just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The incoming data as I mentioned is the textual representation of an integer ranging from 0-255 followed by a new line character. This data is sent to the Arduino once every 5 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So whenever I turn this on, it works just fine for a day or so. But this is supposed to be a system that's constantly on 24/7. If I leave it running for a day or so, the output will start acting weird. I already checked, and the values that the other device sends are perfectly normal. It's the Arduino that messes up something. The brightness is NOT what it needs to be. The Arduino is outputting wrong PWM values. If I simply reset the Arduino (without restarting the other device), everything goes back to normal, and it works again for a day, so the problem is definitely in the Arduino somewhere. But I don't think it's in my code. This piece of code looks super simple and innocent, and I bet it is. I have no idea what causes this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could this be a hardware problem? I do have another Arduino, so I could try replacing it with that one. I haven't tried that yet since I already put all components in a case, fixed everything in place with screws, and soldered wires directly to the Arduino, so I would rather not replace it if it's not necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, any ideas on what could cause this?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I updated the programs on both devices to use a more error-prone protocol for communicating (as suggested &lt;a href=&quot;https://arduino.stackexchange.com/a/20989/17324&quot;&gt;here&lt;/a&gt;), which is kind of similar to the &lt;a href=&quot;https://en.wikipedia.org/wiki/NMEA_0183&quot; rel=&quot;nofollow noreferrer&quot;&gt;NMEA 0183&lt;/a&gt; protocol (basically a simplified version of that). The sender sends the data in the following format now:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A single &lt;code&gt;$&lt;/code&gt; character to indicate the beginning of the data&lt;/li&gt;&#xA;&lt;li&gt;The data itself (which is the textual representation of a single integer)&lt;/li&gt;&#xA;&lt;li&gt;A single &lt;code&gt;*&lt;/code&gt; character to indicate the end of the data&lt;/li&gt;&#xA;&lt;li&gt;An exactly two digit long hexadecimal checksum value. This is the bitwise XOR of the ASCII codes of all the characters between &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;*&lt;/code&gt; (not including those). Letters (if any) are always uppercase.&lt;/li&gt;&#xA;&lt;li&gt;The packet is finished up with either &lt;code&gt;\n&lt;/code&gt; or &lt;code&gt;\r\n&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An example would be &lt;code&gt;$178*3E\n&lt;/code&gt;, where \n of course means a newline character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code running on the Arduino now is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Time.h&amp;gt;&#xA;&#xA;#define _analogWrite(a, b) analogWrite(a, 255-(b))&#xA;#define clamp(X, minVal, maxVal) min(max(X, minVal), maxVal)&#xA;&#xA;const PROGMEM int pwmPin = 3;&#xA;time_t lastUpdate = 0;&#xA;String incoming = &quot;&quot;;&#xA;int pwmValue = 0;&#xA;&#xA;inline void flushSerialBuffer() {&#xA;    while (Serial.available()) Serial.read();&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.setTimeout(500);&#xA;    pinMode(pwmPin, OUTPUT);&#xA;    _analogWrite(pwmPin, 0);&#xA;}&#xA;&#xA;void loop() {&#xA;    time_t currentTime = now();&#xA;&#xA;    if (Serial.available()) {&#xA;        delay(250); // Just to make sure that all data has arrived in the buffer&#xA;        incoming = &quot;&quot;;&#xA;        incoming = Serial.readStringUntil('\n');&#xA;        flushSerialBuffer();&#xA;        int b = incoming.indexOf('$') + 1;&#xA;        if (b == 0) return; // -1 was returned&#xA;        int e = incoming.indexOf('*', b);&#xA;        if (e == -1) return;&#xA;        int checksum = 0x0;&#xA;        for (int i=b; i&amp;lt;e; i++) checksum ^= incoming[i];&#xA;        String hexString = String(checksum, HEX);&#xA;        hexString.toUpperCase();&#xA;        if (hexString.length() &amp;lt; 2) hexString = String(&quot;0&quot;) + hexString;&#xA;        if (!hexString.equals(incoming.substring(e+1, e+3))) return;&#xA;&#xA;        pwmValue = incoming.substring(b, e).toInt();&#xA;&#xA;        if (pwmValue &amp;lt; 0 || pwmValue &amp;gt; 255) pwmValue = 0;&#xA;        lastUpdate = currentTime;&#xA;    }&#xA;&#xA;    if (currentTime - lastUpdate &amp;gt; 30) pwmValue = 0;&#xA;&#xA;    _analogWrite(pwmPin, pwmValue);&#xA;&#xA;    delay(250);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like it's working so far, although I'm still testing if this is reliable over a longer period of time. I will edit the question once again to let you know.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still no success. After a while it just gets stuck on one PWM value and keeps outputting that, regardless of what it receives over serial. It's kind of like it ignores the incoming data after a day or so. I can verify that the other device still sends data correctly, since if I only restart the Arduino, everything goes back to normal.&lt;/p&gt;&#xA;" OwnerUserId="17324" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-02-27T18:07:08.510" Title="Arduino Nano PWM output acting strange after running for a day or so" Tags="|pwm|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20921" PostTypeId="1" CreationDate="2016-02-20T18:33:16.313" Score="1" ViewCount="313" Body="&lt;p&gt;So, first of all I just want to point out this code is from: &lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;Reading Rotary Encoders&lt;/a&gt; and is not mine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a magnetic shaft encoder mounted on a regular DC motor, my problem is that I cannot receive the exact angle of the motor. The encoder outputs &lt;code&gt;+1&lt;/code&gt; each 90 degrees (I then multiply by 90). And is there any relationship between &lt;code&gt;valx&lt;/code&gt;, &lt;code&gt;valy&lt;/code&gt;, &lt;code&gt;valz&lt;/code&gt; and the angle?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define encoder0PinA 2&#xA;#define encoder0PinB 3&#xA;int rounds= 0;&#xA;volatile unsigned int encoder0Pos = 0;&#xA;unsigned int tmp_Pos = 1;&#xA;unsigned int valx;&#xA;unsigned int valy;&#xA;unsigned int valz;&#xA;&#xA;boolean A_set;&#xA;boolean B_set;&#xA;&#xA;int enA = 9;&#xA;int in1 = 10;&#xA;int in2 = 11;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(encoder0PinA, INPUT); &#xA;  pinMode(encoder0PinB, INPUT); &#xA;  // encoder pin on interrupt 0 (pin 2)&#xA;  attachInterrupt(0, doEncoderA, CHANGE);&#xA;&#xA;  // encoder pin on interrupt 1 (pin 3)&#xA;  attachInterrupt(1, doEncoderB, CHANGE);&#xA;  Serial.begin( 9600 );&#xA;&#xA;  pinMode(enA, OUTPUT);&#xA;&#xA;  pinMode(in1, OUTPUT);&#xA;  pinMode(in2, OUTPUT);&#xA;  digitalWrite(in1, HIGH);&#xA;  digitalWrite(in2, LOW); &#xA;  analogWrite(enA, 225);&#xA;  Serial.begin (9600);&#xA;}&#xA;&#xA;&#xA;void loop(){ &#xA;//Check each second for change in position&#xA;&#xA;  if (tmp_Pos != encoder0Pos) {&#xA;    Serial.print(&quot;Index:&quot;); Serial.print(encoder0Pos * 90,DEC);&#xA;    Serial.println();&#xA;    Serial.print(&quot;valx:&quot;);Serial.print(valx,DEC);&#xA;    Serial.println();&#xA;    Serial.print(&quot;valy:&quot;);Serial.print(valy,DEC);&#xA;    Serial.println();&#xA;    Serial.print(&quot;valz:&quot;);Serial.print(valz,DEC);&#xA;    Serial.println();&#xA;    tmp_Pos = encoder0Pos;&#xA;  }&#xA;}&#xA;&#xA;&#xA;// Interrupt on A changing state&#xA;void doEncoderA(){&#xA;&#xA;  // Low to High transition?&#xA;  if (digitalRead(encoder0PinA) == HIGH) { &#xA;    A_set = true;&#xA;    if (!B_set) {&#xA;      encoder0Pos = encoder0Pos + 1;&#xA;      valx=analogRead(0);&#xA;      valy=analogRead(1);&#xA;      valz=analogRead(2);&#xA;    }        &#xA;  }&#xA;&#xA;  // High-to-low transition?&#xA;  if (digitalRead(encoder0PinA) == LOW) {&#xA;    A_set = false;&#xA;  }    &#xA;}&#xA;&#xA;// Interrupt on B changing state&#xA;void doEncoderB(){&#xA;&#xA;  // Low-to-high transition?&#xA;  if (digitalRead(encoder0PinB) == HIGH) {   &#xA;    B_set = true;&#xA;    if (!A_set) {&#xA;      encoder0Pos = encoder0Pos - 1;&#xA;    }&#xA;  }&#xA;&#xA;  // High-to-low transition?&#xA;  if (digitalRead(encoder0PinB) == LOW) {&#xA;    B_set = false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18548" LastEditorUserId="6936" LastEditDate="2016-02-20T19:18:26.923" LastActivityDate="2017-12-02T21:25:21.093" Title="Shaft Encoder Accuracy" Tags="|sensors|interrupt|rotary-encoder|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20922" PostTypeId="1" AcceptedAnswerId="20932" CreationDate="2016-02-20T18:47:13.630" Score="5" ViewCount="788" Body="&lt;p&gt;I noticed that both the Uno and Wifi101 are FCC certified.  Does this mean that these components can actually be used in commercial applications?  This never really occured to me before I noticed the markings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure there is more to a commercial product than just FCC certification but I know that the certification process isn't cheap!&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2020-12-31T13:31:23.633" Title="FCC Certification" Tags="|wifi|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20923" PostTypeId="1" AcceptedAnswerId="20929" CreationDate="2016-02-20T18:51:36.890" Score="1" ViewCount="635" Body="&lt;p&gt;I am trying to connect a CMOS flash memory Winbond W49F002U-12B to an Arduino Mega, but failing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4rh9M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4rh9M.png&quot; alt=&quot;Winbond W49F002U-12B&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read the Winbond W49F002U-12B datasheet. The key points are: CE - chip enabled; OE - output enabled; WE - write enabled and this table:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3YZyj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3YZyj.png&quot; alt=&quot;Winbond W49F002U-12B Operating Modes&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Wrote this code and uploaded to Mega2560: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int A_pins[18] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};&#xA;int DQ_pins[8] = {40, 41, 42, 43, 44, 45, 46, 47};&#xA;int CE = 50;&#xA;int OE = 49;&#xA;int WE = 48;&#xA;&#xA;char ch;&#xA;char addrs[5];&#xA;unsigned long address;&#xA;unsigned int result;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  for(int i=0; i&amp;lt;18; ++i)&#xA;      pinMode(A_pins[i], INPUT);&#xA;  for(int i=0; i&amp;lt;8; ++i)&#xA;      pinMode(DQ_pins[i], OUTPUT);&#xA;  pinMode(CE, OUTPUT);&#xA;  pinMode(OE, OUTPUT);&#xA;  pinMode(WE, OUTPUT);&#xA;  digitalWrite(WE, HIGH);&#xA;  digitalWrite(OE, HIGH);&#xA;  digitalWrite(CE, LOW);&#xA;&#xA;}&#xA;&#xA;void func(unsigned long adr)&#xA;{&#xA;  for(int i=0; i&amp;lt;18; ++i){&#xA;    if(adr &amp;amp; (1ul &amp;lt;&amp;lt; i)){&#xA;      digitalWrite(A_pins[i], HIGH);&#xA;      Serial.print(&quot;A_pins[&quot;);&#xA;      Serial.print(i);&#xA;      Serial.println(&quot;] = HIGH&quot;);}&#xA;    else{&#xA;      digitalWrite(A_pins[i], LOW);}}&#xA;  digitalWrite(OE, LOW);&#xA;  delay(100);&#xA;  for(int i=0; i&amp;lt;8; ++i){&#xA;    if(digitalRead(DQ_pins[i]) == HIGH){&#xA;      result|=1&amp;lt;&amp;lt;i;&#xA;      Serial.print(&quot;DQ_pins[&quot;);&#xA;      Serial.print(i);&#xA;      Serial.println(&quot;] = HIGH&quot;);}&#xA;  }&#xA;  Serial.println(result);&#xA;  digitalWrite(OE, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  {&#xA;   address = (unsigned long)Serial.parseInt();&#xA;   Serial.print(&quot;address = &quot;);&#xA;   Serial.println(address);&#xA;   func(address);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What this code is doing is basically after reading serial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; takes the value as address&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; changes pins A0-A17 to select particular address cell&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; changes OE to LOW&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; reads DQ0-DQ7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; coverts those readings into int&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-&gt; prints result out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of Arduino IDE Serial Monitor inputs/ouputs stuff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;address = 0&#xA;0&#xA;address = 1232&#xA;A_pins[4] = HIGH&#xA;A_pins[6] = HIGH&#xA;A_pins[7] = HIGH&#xA;A_pins[10] = HIGH&#xA;0&#xA;address = 131072&#xA;A_pins[17] = HIGH&#xA;0&#xA;address = 245760&#xA;A_pins[14] = HIGH&#xA;A_pins[15] = HIGH&#xA;A_pins[16] = HIGH&#xA;A_pins[17] = HIGH&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino Mega board is 100% functioning. I don't think Winbond w49f002u-12b is not working. Where am I wrong?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Here is fixed code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int A_pins[18] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};&#xA;int DQ_pins[8] = {40, 41, 42, 43, 44, 45, 46, 47};&#xA;int CE = 50;&#xA;int OE = 49;&#xA;int WE = 48;&#xA;&#xA;unsigned long address;&#xA;unsigned int result;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  for(int i=0; i&amp;lt;18; ++i)&#xA;      pinMode(A_pins[i], OUTPUT);&#xA;  for(int i=0; i&amp;lt;8; ++i)&#xA;      pinMode(DQ_pins[i], INPUT);&#xA;  pinMode(CE, OUTPUT);&#xA;  pinMode(OE, OUTPUT);&#xA;  pinMode(WE, OUTPUT);&#xA;  digitalWrite(WE, HIGH);&#xA;  digitalWrite(OE, HIGH);&#xA;  digitalWrite(CE, LOW);&#xA;&#xA;}&#xA;&#xA;void func(unsigned long adr)&#xA;{&#xA;  result = 0;&#xA;  for(int i=0; i&amp;lt;18; ++i){&#xA;    if(adr &amp;amp; (1ul &amp;lt;&amp;lt; i)){&#xA;      digitalWrite(A_pins[i], HIGH);&#xA;    }&#xA;    else{&#xA;      digitalWrite(A_pins[i], LOW);}}&#xA;  digitalWrite(OE, LOW);&#xA;  //delay(100);&#xA;  for(int i=0; i&amp;lt;8; ++i){&#xA;    if(digitalRead(DQ_pins[i]) == HIGH){&#xA;      result|=1&amp;lt;&amp;lt;i;&#xA;    }}&#xA;  Serial.println(result);&#xA;  digitalWrite(OE, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  {&#xA;   address = (unsigned long)Serial.parseInt();&#xA;   Serial.print(address);&#xA;   Serial.print(&quot;: &quot;);&#xA;   func(address);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Changed code using PORTs, Thanks to @MikaelPatel for reminding about PORTs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long address;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  DDRL = B00000000; //  DQ7-DQ0 42-49&#xA;  DDRA = B11111111; //  A7-A0   29-22&#xA;  DDRC = B11111111; //  A15-A8  30-37&#xA;  DDRG |= B00000011; // A17-A16 40-41&#xA;  DDRB |= B00000111; // WE, OE, CE&#xA;&#xA;  PORTB = B00000110; // WE - HIGH, OE - HIGH, CE - LOW&#xA;}&#xA;&#xA;void func(unsigned long adr)&#xA;{&#xA;  PORTA = adr;&#xA;  PORTC = (adr&amp;gt;&amp;gt;8L);&#xA;  PORTG = (adr&amp;gt;&amp;gt;16L);&#xA;  PORTB = B00000100; //OE - LOW&#xA;  Serial.println(PINL);&#xA;  PORTB = B00000110; //OE - HIGH&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  {&#xA;   address = (unsigned long)Serial.parseInt();&#xA;   Serial.print(address);&#xA;   Serial.print(&quot;: &quot;);&#xA;   func(address);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18388" LastEditorUserId="18388" LastEditDate="2016-02-21T18:06:53.180" LastActivityDate="2016-02-21T18:06:53.180" Title="Connecting Winbond W49F002U-12B to Arduino Mega" Tags="|arduino-mega|memory-usage|flash|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20924" PostTypeId="2" ParentId="20919" CreationDate="2016-02-20T19:46:24.087" Score="0" Body="&lt;p&gt;You have a&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Race_condition&quot; rel=&quot;nofollow&quot;&gt;race condition&lt;/a&gt; in your&#xA;code: if you try to read a message while it's being sent, you may catch&#xA;only a partial message, and end up reading the wrong numbers. My bet is&#xA;that this is exactly what is biting you. Once this happens once, it is&#xA;bound to happen again for some time, since 5&amp;nbsp;seconds is a multiple&#xA;of your 100&amp;nbsp;ms delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The right thing to do would be to wait until you get the new-line&#xA;character (then you know you have a complete message) before trying to&#xA;parse the message. A quick and dirty hack is to just &lt;code&gt;delay(10)&lt;/code&gt; after&#xA;&lt;code&gt;Serial.available()&lt;/code&gt; but before &lt;code&gt;Serial.readString()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-20T19:46:24.087" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20927" PostTypeId="1" AcceptedAnswerId="20930" CreationDate="2016-02-20T20:09:08.823" Score="11" ViewCount="5395" Body="&lt;p&gt;Often I put a bunch of &lt;code&gt;Serial.print( F(&quot;debugging messages&quot;) )&lt;/code&gt; in my Arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally those messages go up a USB cable to a host PC so those messages can be seen on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to install this Arduino as part of a stand-alone system far from any PC and plug the &quot;host&quot; end of the USB cable into a wall-wart USB charger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without anything to accept those messages, the buffer on the Arduino eventually fills up, right?&#xA;Do I need to do anything to keep the Arduino from overflowing and crashing when it's not connected to a host PC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it make any difference if I'm using a (1) &quot;single-chip&quot; Arduino-compatible where the processor includes on-chip USB, vs. (2) an Arduino-compatible with separate &quot;USB interface chip&quot; and &quot;processor chip&quot;?&#xA;(By &quot;single-chip Arduino-compatible&quot;, I mean things like the Arduino Leonardo, Arduino Yún, LilyPad Arduino USB, Arduino Micro, the Teensy-LC, etc.)&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="6936" LastEditDate="2016-02-21T07:23:21.107" LastActivityDate="2020-07-15T19:05:05.357" Title="Is it OK to Serial.print(message), when the USB cable is not connected to a host PC?" Tags="|serial|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20929" PostTypeId="2" ParentId="20923" CreationDate="2016-02-20T20:29:01.873" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What this code is doing is basically after reading serial: ... -&gt; reads DQ0-DQ7&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But all the DQn pins are in OUTPUT mode and the A pins in INPUT mode. Seems to be a mix up. BW: it is the same with all of the pins. The pin mode is from the Arduinos point of view and not the memory chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-21T00:16:19.400" LastActivityDate="2016-02-21T00:16:19.400" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="20930" PostTypeId="2" ParentId="20927" CreationDate="2016-02-20T20:41:43.210" Score="8" Body="&lt;p&gt;It is OK to write out serial data with nothing connected.&lt;/p&gt;&#xA;&lt;p&gt;In case (2) &amp;quot;Arduino + USB interface chip&amp;quot;, the arduino has no idea if anything is connected or listening to the serial port. The code will transmit the bytes and act exactly the same whether plugged in to anything or not.&lt;/p&gt;&#xA;&lt;p&gt;In case (1) &amp;quot;arduino with built in USB&amp;quot; it has some idea, but just drops bytes that are going to be transmitted when the USB port is not connected.&lt;/p&gt;&#xA;&lt;p&gt;Hardware serial (case 2) has an output buffer, but that just makes the program a little faster. When the buffer is empty, a call to &lt;code&gt;serial.{print, write}&lt;/code&gt; will place bytes in the buffer and move on. When it's full, &lt;code&gt;Serial.{print,write}&lt;/code&gt; will wait until there is enough room to put the rest of the message in the buffer and move on. The hardware UART and interrupts it generates will keep taking bytes out of the buffer and transmitting them at a constant rate whether something is plugged in or not. In any case, the buffer is a fixed size and will never overflow.&lt;/p&gt;&#xA;&lt;p&gt;As far as I can tell USB-Serial (case 1) only buffers incoming data. Since the calls to &lt;code&gt;Serial.{print, write}&lt;/code&gt; do nothing when not connected, they may take less time than they would otherwise. If your code is really unsafe about timing, that could cause a problem, but I doubt it will.&lt;/p&gt;&#xA;&lt;p&gt;Many examples that come with the Arduino IDE have the following bit of code that pauses native USB Arduino-compatibles until the USB connection is initialized:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This code stops the Arduino from doing anything until the USB cable is connected.&#xA;Comment out or delete those 3 lines if you want the Arduino to run &amp;quot;stand-alone&amp;quot; without a USB cable connection (&lt;a href=&quot;https://books.google.com/books?id=3b3dDwAAQBAJ&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Cookbook&lt;/a&gt; p. 117) --&#xA;after you delete those lines, if you later plug in a USB cable, the USB will initialize correctly, and &lt;em&gt;then&lt;/em&gt; you will see on your serial monitor everything printed by any &lt;em&gt;later&lt;/em&gt; Serial.print() commands that run. (Tested on a Teensy LC).&lt;/p&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="186" LastEditDate="2020-07-15T19:05:05.357" LastActivityDate="2020-07-15T19:05:05.357" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="20931" PostTypeId="1" AcceptedAnswerId="20937" CreationDate="2016-02-20T20:43:23.077" Score="1" ViewCount="1573" Body="&lt;p&gt;I recently bought an Arduino MEGA2560 and a &lt;a href=&quot;http://www.sainsmart.com/sainsmart-instabots-robot-controller-shield-for-arduino-mega2560-r3-robot-arm-control.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;SainSmart InstaBots Robot Controller Shield for Arduino MEGA2560 R3 Robot Arm Control&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand how to control a servo in the method described in &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Sweep&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sweep&lt;/a&gt;. However, I want to control six servos using the shield area circled in red below. Could anyone provide the code to setup and control servos from the area circled in red?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me I am a beginner in robotics and I need this for a project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iVWnv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iVWnv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18552" LastEditorUserId="6936" LastEditDate="2016-02-21T04:05:00.030" LastActivityDate="2019-05-04T13:21:00.377" Title="Code to control servo with shield" Tags="|servo|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20932" PostTypeId="2" ParentId="20922" CreationDate="2016-02-20T21:01:12.180" Score="4" Body="&lt;p&gt;These products are not certified, they merely have been verified and issued a Declaration of Conformity. The WiFi module on the WiFi shield itself has been certified, as indicated by the FCC ID on its label.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To explain what that means, I am going to give a simplified explanation. If you are looking to make a commercial product and you are not sure what you need to do to be compliant, hire out a professional to help you through the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the eyes of the FCC, devices fall into one of two categories, devices that are intentional transmitters, and devices that are not. Devices that are intentional transmitters need to be certified. Certification is a process of making sure that it is only transmitting on the frequency band it specified, that it is maintaining certain power limits, and that it will not cause interference with other devices. This is a very expensive testing procedure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Devices that are not intentional transmitters, only need to get a verification. What this means is that the devices is not designed to transmit anything and is test to makes sure that it indeed does not. If you pass the verification you are issued a Declaration of Conformity basically stating that the device is not unintentionally transmitting any frequencies. This is usually a lot less expensive than than certification (but still in the few thousand USD range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C5tH2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C5tH2.jpg&quot; alt=&quot;WiFi Shield Module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So taking the WiFi shield as an example, the module shown above circled in red is an intentional transmitter, i.e. it is designed to transmit on a particular frequency band (in this case 2.4 GHz ISM band). The device is certified to make sure that its emissions are within FCC specifications and it is issued an FCC ID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now at this point only the module is certified and is good to be used in a product, however, now that it is on a shield with extra circuitry added to it, the extra circuitry could be unintentionally transmitting. So now the whole shield is tested to make sure that the added circuitry does not have any emissions exceeding the FCC specifications and is issued a Declaration of Conformity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now fast forward to making your own thing, the module is certified, the WiFi shield and the Uno are verified, you add your own additional circuity around those components that may emit electromagnetic fields. You now may have to get your product verified to ensure that the added components to the system have not caused it to unintentionally emit radio frequencies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole process, conditions, and requirements are a lot more nuanced than my description above. So this should in no way be used as the basis for product development or legal advice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Image borrowed from &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield101&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/ArduinoWiFiShield101&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="11086" LastActivityDate="2016-02-20T21:01:12.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20933" PostTypeId="1" AcceptedAnswerId="20934" CreationDate="2016-02-20T21:17:54.557" Score="1" ViewCount="633" Body="&lt;p&gt;I am messing around with an ATmega328P hooked on a Raspberry Pi, communicating over I2C. The ATmega is the slave (details at the end). While testing the basics of the concept, I faced an interesting problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code on the ATmega:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADRESS 0x1A&#xA;#define LED 6&#xA;&#xA;int count = 10;&#xA;void setup()&#xA;{&#xA;    pinMode(LED, OUTPUT);&#xA;    /*for(int i=1; i&amp;lt;=3; i++)&#xA;    {&#xA;      digitalWrite(LED, HIGH);&#xA;      delay(100);&#xA;      digitalWrite(LED, LOW);&#xA;      delay(100);&#xA;    }*/&#xA;    Wire.begin(SLAVE_ADRESS);&#xA;    Wire.onReceive(receiveEvent);&#xA;    Wire.onRequest(requestEvent);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  delay(10);&#xA;}&#xA;&#xA;void receiveEvent(int received_bytes)&#xA;{&#xA;  while(Wire.available())&#xA;  {&#xA;    unsigned char i = Wire.read();&#xA;    if(1)&#xA;    {&#xA;      int j = 5;&#xA;      while(j&amp;gt;0)&#xA;      {&#xA;        digitalWrite(LED, HIGH);&#xA;        delay(300);&#xA;        digitalWrite(LED, LOW);&#xA;        delay(300);&#xA;        j-=1;&#xA;      }&#xA;    }&#xA;    delay(1);&#xA;  }&#xA;}&#xA;&#xA;void requestEvent()&#xA;{&#xA;  Wire.write(count);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you would expect it to do is blink the LED connected to pin 6 five times when the Pi sends a byte to the ATmega slave. (Things like &lt;code&gt;if(1)&lt;/code&gt; are there because the code was much more specific originally.) The strange thing is that this is not the case:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The LED only blinks 1 time.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I honestly have no idea why. This &quot;stdio-fitted&quot; version of the problematic loop ran on the RPi as expected, prints 5*2 times:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;int main()&#xA;{&#xA;  int j = 5;&#xA;  while(j&amp;gt;0)&#xA;  {&#xA;    printf(&quot;LED, HIGH\n&quot;);&#xA;    printf(&quot;LED, LOW\n&quot;);&#xA;    j-=1;&#xA;  }&#xA;  return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Circumstances:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I compile the code in the Arduino IDE on the Pi, then upload it&#xA;using AVRDUDE to the ATmega with the Pi's GPIOs. No error messages&#xA;over the process.&lt;/li&gt;&#xA;&lt;li&gt;The ATmega gets 3.3 V supply voltage from the Pi, and operates on&#xA;16.000 MHz. Only the LED and the Pi is connected to it.&lt;/li&gt;&#xA;&lt;li&gt;The (Python) code I use on the Pi to write and read a byte is the following. Reading works well, and I know by tests that the ATmega actually receives the correct byte:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;import pigpio&#xA;import time&#xA;&#xA;pi = pigpio.pi()&#xA;atmega = pi.i2c_open(1, 0x1A)&#xA;&#xA;for i in range(6):&#xA;    a = pi.i2c_read_byte(atmega)&#xA;    print a&#xA;&#xA;pi.i2c_write_byte(atmega, 0x05)&#xA;time.sleep(1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18551" LastEditorUserId="26916" LastEditDate="2017-09-09T02:14:22.443" LastActivityDate="2017-09-09T02:14:22.443" Title="Loop behaves oddly in I2C receiveEvent" Tags="|i2c|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20934" PostTypeId="2" ParentId="20933" CreationDate="2016-02-20T21:34:20.773" Score="0" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void receiveEvent(int received_bytes)&#xA;{&#xA;  while(Wire.available())&#xA;  {&#xA;    unsigned char i = Wire.read();&#xA;    if(1)&#xA;    {&#xA;      int j = 5;&#xA;      while(j&amp;gt;0)&#xA;      {&#xA;        digitalWrite(LED, HIGH);&#xA;        delay(300);&#xA;        digitalWrite(LED, LOW);&#xA;        delay(300);&#xA;        j-=1;&#xA;      }&#xA;    }&#xA;    delay(1);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;receiveEvent&lt;/code&gt; is an ISR (interrupt service routine). Don't do &lt;code&gt;delay&lt;/code&gt; in an ISR. That will hang indefinitely. Thus the LED only blinks once. You could do &lt;code&gt;delayMicroseconds&lt;/code&gt; for &lt;em&gt;testing&lt;/em&gt;. In general an ISR should be &lt;strong&gt;short&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;I2C&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-20T21:34:20.773" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20935" PostTypeId="1" CreationDate="2016-02-20T22:41:35.047" Score="2" ViewCount="1642" Body="&lt;p&gt;I have a ICT a6-15scp-usd4-ii. I have all of the wires for it. I dont have the gambling machine it came out of and it was laying around. Is it possible to make a Light come on when a bill is put in? Can it be wired to the arduino to act as a switch per-say? If more info is needed let me know. I will make a tutorial for this if it works.&lt;/p&gt;&#xA;" OwnerUserId="18553" LastActivityDate="2021-03-03T11:47:29.977" Title="ICT Bill Accepter" Tags="|arduino-uno|serial|programming|c++|led|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20936" PostTypeId="1" CreationDate="2016-02-20T23:12:43.930" Score="2" ViewCount="540" Body="&lt;p&gt;Recently we purchased servos for use in an Arduino and began testing with servos. It turned out that the uSec for the servos differed from the online documentation and we had to find the min and maxes of the uSecs manually:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial.available()) {&#xA;    char c = Serial.read();  //gets one byte from serial buffer&#xA;    readString += c; //makes the string readString&#xA;    delay(2);  //slow looping to allow buffer to fill with next character&#xA;}&#xA;&#xA;if (readString.length() &amp;gt;0) {&#xA;    Serial.println(readString);  //so you can see the captured string &#xA;    int n = readString.toInt();  //convert readString into a number&#xA;    Serial.print(&quot;writing Microseconds: &quot;);&#xA;    Serial.println(n);&#xA;    myServo.writeMicroseconds(n);&#xA;    readString = &quot;&quot;; //empty for next input&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is that the servos don't travel the full 180 degree advertised price (more like 135-160) and that lack of angular distance is affecting performance of one of our products. &lt;strong&gt;The servos can even mechanically travel a noticeable distance farther than 180, but not &quot;programmatically&quot; farther even when given a larger PWM uSec value that the observed &quot;max&quot; PWM value&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I've found&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked around and apparently there are &lt;a href=&quot;http://www.instructables.com/id/Hitec-HFP-25-Programmer-How-to-Adjust-Hitec-Digita/&quot; rel=&quot;nofollow&quot;&gt;&quot;Servo Programmers&quot;&lt;/a&gt; to calibrate endpoints and midpoints, but cost an arm and a leg. I find it strange that I would have to &quot;program&quot; my servos. I was part of an First (FTC) robotics team using tetrix/nxt electronic control systems, and never noticed a problem with uSec values or not getting the full range of motion using the same brand of servos I currently am now.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I perform a low cost, easy way to simply &lt;strong&gt;get the full range&#xA;  of motion I paid for&lt;/strong&gt;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="17309" LastActivityDate="2016-04-22T15:47:02.727" Title="Get servo to travel full length" Tags="|arduino-uno|pwm|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20937" PostTypeId="2" ParentId="20931" CreationDate="2016-02-20T23:36:04.297" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However, I want to control six servos using the shield area circled in red below. Could anyone provide the code to setup and control servos from the area circled in red?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the limited amount of info you have provided about the shield this will have to be a wild guess. I am assuming that the pins are S(ignal), V(cc) and G(nd) for pins 8-13. On an Arduino Mega these can be used for PWM and therefore Servo control. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Include the Servo library, attach the pin and set the angle. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo[6];   &#xA;&#xA;void setup() &#xA;{&#xA;  ...&#xA;  for (int i = 0; i &amp;lt; 6; i++)&#xA;    servo[i].attach(8 + i);&#xA;  ...&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;   ...&#xA;   servo[i].write(pos);&#xA;   ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: Do not forget to provide the correct power supply. If USB Port is left, then the upper pin is positive and the lower pin negative.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2018-12-01T15:03:47.847" LastActivityDate="2018-12-01T15:03:47.847" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="20938" PostTypeId="1" CreationDate="2016-02-21T00:25:53.357" Score="3" ViewCount="23834" Body="&lt;p&gt;I have a statement:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if(control &amp;gt; 100 &amp;amp;&amp;amp; control &amp;lt; 130)&#xA;{&#xA;&#xA;  //count time 30 seconds and open pin1 for 3 seconds.&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I count 30 seconds and open a pin for 3 seconds?&lt;/p&gt;&#xA;" OwnerUserId="8761" LastEditorUserId="37523" LastEditDate="2019-06-14T05:15:35.597" LastActivityDate="2019-06-14T05:15:35.597" Title="How do I count time in seconds?" Tags="|programming|timers|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="20940" PostTypeId="2" ParentId="20140" CreationDate="2016-02-21T04:21:31.273" Score="0" Body="&lt;p&gt;If I understand you correctly, you want to receive serial data (in DMX format) on one serial port, and then display that data on the serial monitor (using a different serial port).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega 2560 is an excellent choice, because it has &lt;a href=&quot;http://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;4 hardware UARTs&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alas, there is really only 3 hardware UARTs that you can actually connect to external hardware. USART0 (the Mega pins labeled &quot;TX0&quot; and &quot;RX0&quot;) are &lt;em&gt;already&lt;/em&gt; connected to the USB interface; the Arduino calls that USART &quot;Serial.&quot; (without a number).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I avoid connecting anything to the &quot;TX0&quot; or &quot;RX0&quot; pins on the Mega, so I can use &quot;Serial.&quot; (USART0) for sending debugging messages to the serial terminal over the USB cable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// doesn't compile&#xA;ISR (USART0_RX_vect)&#xA;{&#xA;    // ...&#xA;}&#xA;// ...&#xA;void loop()&#xA;{&#xA;    // ...&#xA;    Serial.print(dmx_buffer[dmx_adresse]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This looks inconsistent to me.&#xA;One part of your program is trying to use USART0 (&quot;Serial.&quot;) for sending and receiving messages to the serial monitor on the PC.&#xA;Another part of your program is trying to use the same USART0 (&quot;Serial.&quot;) for sending and receiving messages on the DMX network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried connecting the DMX interface to the other available hardware USARTs -- perhaps USART1 (&quot;Serial1.&quot;, the pins labeled TX1 and RX1), or USART2 (&quot;Serial2.&quot;, the pins labeled TX2 and RX2), or USART3 (&quot;Serial3.&quot;, the pins labeled TX3 and RX3)?&#xA;Then your code would look more like other people recieving DMX on an Arduino Mega -- &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=50696.0&quot; rel=&quot;nofollow&quot;&gt;(a)&lt;/a&gt;, &lt;a href=&quot;http://github.com/phoeve/NPCC_DMX/blob/master/npcc_dmx_servo_mega&quot; rel=&quot;nofollow&quot;&gt;(b)&lt;/a&gt;, &lt;a href=&quot;http://github.com/rad1o/l0unge-sender/blob/master/arduino_dmx/libraries/Conceptinetics/Conceptinetics.cpp&quot; rel=&quot;nofollow&quot;&gt;(c)&lt;/a&gt;, etc.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the ISR setup that the other DMX-on-Arduino-Mega people use:&#xA;ISR( USART3_RX_vect ){&#xA;    // ...&#xA;}&#xA;// ...&#xA;void loop(){&#xA;    // ...&#xA;    Serial.print(dmx_buffer[dmx_adresse]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="186" LastActivityDate="2016-02-21T04:21:31.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20941" PostTypeId="2" ParentId="1180" CreationDate="2016-02-21T04:50:13.400" Score="2" Body="&lt;p&gt;You can try out the software I developed for that propose. It's aimed to be easy to use. See &lt;a href=&quot;https://github.com/newtonis/SerialGraphicator/&quot; rel=&quot;nofollow&quot;&gt;SerialGraphicator&lt;/a&gt; - Open Source Free Serial Port Client capable of graph values that are received in JSON format.&lt;/p&gt;&#xA;" OwnerUserId="18557" LastEditorUserId="6936" LastEditDate="2016-02-21T04:58:20.773" LastActivityDate="2016-02-21T04:58:20.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20942" PostTypeId="2" ParentId="20931" CreationDate="2016-02-21T04:50:16.533" Score="0" Body="&lt;p&gt;The SVG connectors on your board appear to be lacking header pins:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ofsli.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ofsli.jpg&quot; alt=&quot;Three pin header&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These should have been supplied with the board. If not you will need to source some. Either way, you will need to solder them on. I don't understand why they are not already attached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the other images of the board on the SainSmart web page, the header pins are clearly visible:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/o9yaD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o9yaD.jpg&quot; alt=&quot;SainSmart shield with header pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The S pin of each SVG is the same as the output pins, near the green light, but for ease of use, they are replicated in the SVG pins, so that a servo plug can be easily, and conveniently plugged in, with out the user having to wire up power and ground separately.  If you look at the plug attached to the end of the cable coming from your servo, you will see the servo connector, like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mylsp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mylsp.jpg&quot; alt=&quot;Servo connector&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the board has arranged the pins in the SVG order, that means that it will support the Futaba J type connectors (but not the Airtronics, as the power and ground pins are reversed):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sy2RH.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sy2RH.gif&quot; alt=&quot;Futaba and Airtronics connectors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, Hitec and JR Radio connectors are supported by your board, as they have the same pin out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kjs4s.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kjs4s.gif&quot; alt=&quot;JR Radio and HiTec connectors&quot;&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, take a look at &lt;a href=&quot;http://www.hooked-on-rc-airplanes.com/rc-servos.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Choosing RC Servos&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, as Mikael says, you will also need to attach an external power supply to the green terminals &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XI6lw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XI6lw.jpg&quot; alt=&quot;SainSmart shield showing green external power connector&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as the on board power regulator of the Arduino can not supply enough power to the servos, via the shield, by itself, neither with the USB, nor an external wall wart PSU, supplying power to the Arduino. So, use a bench power supply, battery pack, or otherwise and supply that power directly to the board via the Green power terminals at the end of the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have done all of that, and got the hardware out of the way, then the software provided in &lt;a href=&quot;https://arduino.stackexchange.com/questions/20931/code-to-control-servo-with-shield#answer-20937&quot;&gt;Mikael's answer&lt;/a&gt; will work perfectly.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-02-21T04:50:16.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20943" PostTypeId="2" ParentId="19089" CreationDate="2016-02-21T04:59:04.840" Score="0" Body="&lt;p&gt;I have found the solution to my question so I thought to post it here so that others could also get benefit out of it. Here's the link to &lt;a href=&quot;http://www.theengineeringprojects.com/2015/12/gps-library-proteus.html&quot; rel=&quot;nofollow&quot;&gt;GPS Library for Proteus - A complete step by step tutorial on How to download GPS Library for Proteus&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From this link you can download the GPS Library which you need to add to the libraries folder of your Proteus software and you will have the GPS module in Proteus and you can design your simulation quite easily. More details are given in this link.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastEditorUserId="6936" LastEditDate="2016-02-21T06:49:36.680" LastActivityDate="2016-02-21T06:49:36.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20944" PostTypeId="2" ParentId="19089" CreationDate="2016-02-21T06:00:02.480" Score="0" Body="&lt;p&gt;If you will be using the computer to interface, &lt;strong&gt;you don't really need Arduino in the middle&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can hook the GPS module to the computer using a USB-UART bridge like one below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/769N1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/769N1.jpg&quot; alt=&quot;USB to serial&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual GPS modules (ebay or other hobby stores) output NMEA sentences over their serial port. Check the datasheet of your GPS module for the baud rate and the RX/TX pins. Connect the RX and TX lines of your GPS to the USB-serial module and you should be able to see NMEA output on a terminal emulator (set to right baud).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you see NMEA sentences over a terminal emulator, you can parse those in your application directly (bypassing terminal emulator) instead of using an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastActivityDate="2016-02-21T06:00:02.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20946" PostTypeId="2" ParentId="20938" CreationDate="2016-02-21T07:09:53.460" Score="1" Body="&lt;p&gt;Rearrange the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot;&gt;Blink&lt;/a&gt; example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(control&amp;gt;100 &amp;amp;&amp;amp; control&amp;lt;130)&#xA;{&#xA;  //**count time 30 seconds and open pin1 for 3 seconds.**&#xA;  delay(30000);             // wait for 30 seconds&#xA;  digitalWrite(1, HIGH);    // turn the LED on (HIGH is the voltage level)&#xA;  delay(3000);              // wait for 3 seconds&#xA;  digitalWrite(1, LOW);     // turn the LED off by making the voltage LOW&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6936" LastEditDate="2016-02-21T07:19:39.997" LastActivityDate="2016-02-21T07:19:39.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20947" PostTypeId="1" CreationDate="2016-02-21T07:41:22.673" Score="2" ViewCount="1102" Body="&lt;p&gt;I am sending some data over an NRF24 link, using the &lt;a href=&quot;https://github.com/TMRh20/RF24Network&quot; rel=&quot;nofollow&quot;&gt;RF24Network&lt;/a&gt;  library. So far I have only sent numbers, now I also want to send a string, so I have set up my payload struct as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct payload_t {                  // Structure of our payload&#xA;   unsigned long data;&#xA;   unsigned long datatype;&#xA;   char sensorid[20];&#xA;   unsigned long counter;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As far as I do understand, I can not use string here, since I need to know the length of the data I am sending. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment I am using sensors without an internal ID, so in &lt;code&gt;loop()&lt;/code&gt;, I am calling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; writeToNetwork(voltage,'v',&quot;nosid&quot;,packets_sent++);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;code&gt;writeToNetwork&lt;/code&gt; function is defined as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; bool writeToNetwork(unsigned long data,unsigned long type,char sid[20],unsigned long package){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and within that, I am setting up the payload with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; payload_t payload = { data,type,sid, package };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives me an&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive] &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Clearly, I have no interest of the address the pointer is referencing, so I need to somehow dereference the &lt;code&gt;sid&lt;/code&gt; - pointer to get my array into the struct. How can I do that? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or am I barking up the wrong tree? I tried to transfer the id as a string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;string.h&amp;gt;&#xA;bool writeToNetwork(unsigned long data,unsigned long type,String sid,unsigned long package){&#xA;char sidchar[20];&#xA;sid.toCharArray(sidchar,20);&#xA;payload_t payload = { data,type,sidchar, package };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives me the error &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;array must be initialized with a brace-enclosed initializer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which I do not understand. Doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char sidchar[20]={0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives me the same error.&lt;/p&gt;&#xA;" OwnerUserId="16770" LastEditorUserId="16770" LastEditDate="2016-02-21T08:04:11.347" LastActivityDate="2016-02-21T10:08:47.793" Title="Dereferencing char into a struct" Tags="|nrf24l01+|pointer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20948" PostTypeId="1" AcceptedAnswerId="20949" CreationDate="2016-02-21T08:23:54.317" Score="3" ViewCount="1572" Body="&lt;p&gt;It's my understanding that when a Timer is used on an Arduino (in my case the Arduino Mega), it can disable analog write on some PWM pins, which pins depends on the Timer being used. For instance on the Mega, pins 44,45,46 are controlled by Timer 5.  If I enable Timer 5, does that mean that I can't use these pins for anything else? Or does it only mean I can't use those pins for AnalogWrite, and that I can still use those pins for DigitalWrite.&lt;/p&gt;&#xA;" OwnerUserId="18363" LastActivityDate="2016-02-21T10:06:39.573" Title="If a Timer is used, disabling some PWM pins, can I still use those pins for Digital write?" Tags="|arduino-mega|pwm|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20949" PostTypeId="2" ParentId="20948" CreationDate="2016-02-21T09:30:14.570" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If I enable Timer 5, does that mean that I can't use these pins for anything else? Or does it only mean I can't use those pins for AnalogWrite, and that I can still use those pins for DigitalWrite.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can view the connection between the Timer and the pins as programmable. The connection is enabled by, for instance, analogWrite(). The Timer control registers have a setting for both the connection and control logic of the pin (clean, set or toggle on timer value match). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the Timer to generate interrupts without connecting a pin. This is the case with micros() and millis() which get their values from a counter which is updated by an ISR on Timer 0 (overflow). analogWrite() on pin 5 and 6 connects to Timer 0 value match logic. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;analogWrite() uses the Timer value match and connects the pins. Enabling only the Timer (as you suggest) will allow you to use the pins with digitalWrite(). You can also use the Timer ISR for overflow. The Timer prescale is set for analogWrite(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-21T09:30:14.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20950" PostTypeId="2" ParentId="20938" CreationDate="2016-02-21T10:03:27.700" Score="2" Body="&lt;p&gt;What you can also use is non-blocking code, where &lt;code&gt;delay()&lt;/code&gt; would block for the 30s. My suggesting makes use of &lt;code&gt;millis()&lt;/code&gt;, one could say similar to blink without delay code example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of what you could place in the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//declared variable stuff here&#xA;&#xA;if(control &amp;gt; 100 &amp;amp;&amp;amp; control &amp;lt; 130 &amp;amp;&amp;amp; !toggled_bit){&#xA;&#xA;    toggled_bit = true;     //to control the timing section&#xA;    start_time = millis();&#xA;}&#xA;else if (!(control &amp;gt; 100 &amp;amp;&amp;amp; control &amp;lt; 130)){&#xA;    toggled_bit = false;&#xA;}&#xA;&#xA;if (toggled_bit){&#xA;        test1 = millis()&#xA;    if(test1 - start_time &amp;gt; 30000){&#xA;&#xA;        digitalWrite(1, HIGH);&#xA;            short_wait = millis();&#xA;            // wait for 3s after fist time&#xA;                if(short_wait - start_time &amp;gt; 33000)&#xA;                    digitalWrite(1, LOW);&#xA;                    toggled_bit = false;&#xA;                }&#xA;        }&#xA;}&#xA;&#xA;// other code here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code sets a 'flag', &lt;code&gt;toggled_bit&lt;/code&gt;, which is checked by the &lt;code&gt;if()&lt;/code&gt; later on in the loop, also it sets &lt;code&gt;start_time&lt;/code&gt;. It then checks if 30s has passed and then waits an extra 3s to turn the output off after being turned on. It then resets the &lt;code&gt;toggled_bit&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will also allow you to check or do other things while waiting.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-02-21T10:03:27.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20951" PostTypeId="2" ParentId="20948" CreationDate="2016-02-21T10:06:39.573" Score="2" Body="&lt;p&gt;When using an timer (other than by PWM) you can choose to enable it's output to a pin (which basically is what PWM does). So you can still use them as a digital pin (if you choose not to).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could set up an PWM signal and enable timer interrupts afaik. But changing PWM, would also change the timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a difference in only using Arduino functions, or changing the registers directly.&#xA;Try to read the &quot;timers&quot; part of the datasheet and find some tutorials about avr/atmel/atmega register changing or/and setting up timers.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-02-21T10:06:39.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20952" PostTypeId="2" ParentId="20947" CreationDate="2016-02-21T10:08:47.793" Score="4" Body="&lt;p&gt;In your situation, your best bet is probably to use the standard C function &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strcpy/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;strcpy&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;payload_t payload;&#xA;char* source = &quot;abcdef&quot;;&#xA;strcpy(payload.sensorid, source);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that source string does not have to be declared as &lt;code&gt;char source[20]&lt;/code&gt; and can be declared as the rather standard C string &lt;code&gt;char*&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since you are limiting the size of the string to be passed in &lt;code&gt;payload&lt;/code&gt;, you may prefer to use &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strncpy/&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;strncpy&lt;/code&gt;&lt;/a&gt; which will ensure no more than 20 characters get copied:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;payload_t payload;&#xA;char* source = &quot;abcdef&quot;;&#xA;strncpy(payload.sensorid, source, 20);&#xA;// Explicitly add a string termination to the end of string&#xA;payload.sensorid[19] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the snippet above, please notice the last line, it is necessary in the situation where &lt;code&gt;source&lt;/code&gt; string length is 20 or more non-null characters, as in this case, &lt;code&gt;strncpy&lt;/code&gt; will copy all 20 characters but will not add the terminating 0 at the end of the string.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-02-21T10:08:47.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20953" PostTypeId="2" ParentId="20938" CreationDate="2016-02-21T10:58:53.387" Score="5" Body="&lt;p&gt;A non-blocking version is often needed as there is often other tasks to be performed during the wait. The &quot;blink-without-delay&quot;-pattern is a solution but unfortunately it becomes tedious to use with several time periods and logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Timemark&quot; rel=&quot;noreferrer&quot;&gt;Timemark&lt;/a&gt; library helps abstract the pattern and hide a lot of the details. The below sketch uses two timemarks and a simple state-machine to help reduce complexity. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timemark.h&amp;gt;&#xA;&#xA;Timemark turnOnWait(30000L);&#xA;Timemark turnOffWait(3000L);&#xA;&#xA;enum {&#xA;  IDLE,&#xA;  TURN_ON_WAIT,&#xA;  TURN_OFF_WAIT&#xA;};&#xA;int state = IDLE;&#xA;&#xA;const int pin = 4;&#xA;int control = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  ...&#xA;  pinMode(pin, OUTPUT);&#xA;  digitalWrite(pin, LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  ...&#xA;  switch (state) {&#xA;  case IDLE:&#xA;    if ((control &amp;gt; 100) &amp;amp;&amp;amp; (control &amp;lt; 130)) {&#xA;      turnOnWait.start();&#xA;      state = TURN_ON_WAIT;&#xA;    }&#xA;    break;&#xA;  case TURN_ON_WAIT:&#xA;    if (turnOnWait.expired()) {&#xA;      digitalWrite(pin, HIGH);&#xA;      turnOffWait.start();&#xA;      state = TURN_OFF_WAIT;&#xA;    }&#xA;    break;&#xA;  case TURN_OFF_WAIT:&#xA;    if (turnOffWait.expired()) {&#xA;      digitalWrite(pin, LOW);&#xA;      state = IDLE;&#xA;    }&#xA;    break;&#xA;  default:&#xA;    ;&#xA;  }&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Two timemarks are used for clarity. It is possible to use a single timemark and reinitiate it with a new time limit. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Timemark.h&amp;gt;&#xA;&#xA;const uint32_t TURN_ON_TIMEOUT = 30000L;&#xA;const uint32_t TURN_OFF_TIMEOUT = 3000L;&#xA;&#xA;Timemark timemark;&#xA;&#xA;enum {&#xA;  IDLE,&#xA;  TURN_ON_WAIT,&#xA;  TURN_OFF_WAIT&#xA;};&#xA;int state = IDLE;&#xA;&#xA;const int pin = 4;&#xA;int control = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  ...&#xA;  pinMode(pin, OUTPUT);&#xA;  digitalWrite(pin, LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  ...&#xA;  switch (state) {&#xA;  case IDLE:&#xA;    if ((control &amp;gt; 100) &amp;amp;&amp;amp; (control &amp;lt; 130)) {&#xA;      timemark.limitMillis(TURN_ON_TIMEOUT);&#xA;      timemark.start();&#xA;      state = TURN_ON_WAIT;&#xA;    }&#xA;    break;&#xA;  case TURN_ON_WAIT:&#xA;    if (timemark.expired()) {&#xA;      digitalWrite(pin, HIGH);&#xA;      timemark.limitMillis(TURN_OFF_TIMEOUT);&#xA;      timemark.start();&#xA;      state = TURN_OFF_WAIT;&#xA;    }&#xA;    break;&#xA;  case TURN_OFF_WAIT:&#xA;    if (timemark.expired()) {&#xA;      digitalWrite(pin, LOW);&#xA;      state = IDLE;&#xA;    }&#xA;    break;&#xA;  default:&#xA;    ;&#xA;  }&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;noreferrer&quot;&gt;Scheduler&lt;/a&gt; library allows the blocking version (delay) to be used. Non-blocking is achieved by context switching on yield() or delay(). Below is a rewrite using this style:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Scheduler.h&amp;gt;&#xA;&#xA;const int pin = 4;&#xA;int control = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  ...&#xA;  Scheduler.start(setupController, loopController);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  ...&#xA;  delay(1000);&#xA;}&#xA;&#xA;void setupController()&#xA;{&#xA;  ...&#xA;  pinMode(pin, OUTPUT);&#xA;  digitalWrite(pin, LOW);&#xA;}&#xA;&#xA;void loopController()&#xA;{&#xA;  ...&#xA;  if ((control &amp;gt; 100) &amp;amp;&amp;amp; (control &amp;lt; 130)) {&#xA;    delay(30000L);&#xA;    digitalWrite(pin, HIGH);&#xA;    delay(3000L);&#xA;    digitalWrite(pin, LOW);&#xA;  }&#xA;  else {&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-21T12:50:53.273" LastActivityDate="2016-02-21T12:50:53.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20955" PostTypeId="2" ParentId="19971" CreationDate="2016-02-21T15:50:00.740" Score="2" Body="&lt;p&gt;In the days of dumb terminals and time sharing systems, setting the baud rate was accomplished by the terminal sending a pre-determined series of characters with gaps between them and the host changing its baud rate and looking for the expected data. It is best to start at a high baud rate and drop the rate between tries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example the terminal user would hit Enter repeadedly and the host would try decreasing baud rates until it saw the Carriage Return character. When it saw the CR, it would respond with &quot;Login Please&quot; and you would know you were good to go.&lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-21T15:50:00.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20956" PostTypeId="2" ParentId="20919" CreationDate="2016-02-21T18:30:08.240" Score="0" Body="&lt;p&gt;Your problem may be related to the dynamic memory allocation of your String objects. Each time the Arduino receives data, you are creating two new String objects. Perhaps the memory is not being released properly, causing eventual exhaustion of your RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could make your Strings global and empty them out each time, but a far better solution would be to replace all your string manipulation with a call to Serial.ParseInt() so your big if block becomes&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;if (Serial.available()) {&#xA;        pwmValue = Serial.ParseInt();&#xA;        while(Serial.available() &amp;gt; 0 {&#xA;          Serial.read();    // flush anything after the integer&#xA;        // Save the current time&#xA;        lastUpdate = currentTime;&#xA;    }&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial.ParseInt also makes use of the timeout so you don't have to worry about partial values being read.  &lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-21T18:30:08.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20957" PostTypeId="1" AcceptedAnswerId="20958" CreationDate="2016-02-21T18:35:26.280" Score="1" ViewCount="1042" Body="&lt;p&gt;I bought an Arduino Due, and I noticed unlike the other boards, the onboard LED does not flash after reset. I prefer this behavior, so I want to modify the bootloader to do this behavior when it starts. I have burnt bootloaders before, but I never modified one before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;" OwnerUserId="16096" LastActivityDate="2016-02-21T20:59:37.223" Title="Modify Arduino Due's Bootloader to flash when reset" Tags="|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20958" PostTypeId="2" ParentId="20957" CreationDate="2016-02-21T18:43:09.857" Score="2" Body="&lt;p&gt;The Arduino Due bootloader is built-in. If you check the Arduino SAM core there are no bootloader files. There is a firmware file for the ATmega16u2 on the Programming Port. You might be able to modify this to do that (given that there is a LED to flash). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The alternative solution to a modified bootloader is modifing the init() of the Arduino SAM core. Please see &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/cores/arduino/main.cpp#L36&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/cores/arduino/main.cpp#L36&lt;/a&gt; or &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/variants/arduino_due_x/variant.cpp#L372&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/sam/variants/arduino_due_x/variant.cpp#L372&lt;/a&gt;. Blink code as proposed by Majenko could be added there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-21T20:59:37.223" LastActivityDate="2016-02-21T20:59:37.223" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20959" PostTypeId="2" ParentId="20938" CreationDate="2016-02-21T18:59:41.843" Score="1" Body="&lt;p&gt;Well 30s equals 30,000ms and the arduino comes with a native function that counts in Milliseconds so the following code should work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Time = millis();  //time passed before entering loop…&#xA;If((control &amp;gt; 100) &amp;amp;&amp;amp; (control &amp;lt; 130))&#xA;{ &#xA;While (millis() &amp;lt; Time + 30000) //counts to Thirty seconds &#xA;{&#xA;While (millis() &amp;lt; Time + 3000) // counts to three seconds&#xA;{&#xA;DigitalWrite(1,HIGH);&#xA;};};};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you can add some code in the while loops if u want to multitask.&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-02-21T18:59:41.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20960" PostTypeId="2" ParentId="20957" CreationDate="2016-02-21T19:28:30.137" Score="1" Body="&lt;p&gt;You cannot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SAM3X's bootloader is hard-coded into ROM and can never be changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, I know, it sucks, doesn't it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the bootloader only executes if the flash is empty (bit of an odd choice if you ask me, but there you go) so you could &quot;emulate&quot; the operation by flashing an LED as the first thing in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(13, OUTPUT);&#xA;for (int i = 0; i &amp;lt; 5; i++) {&#xA;    digitalWrite(13, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(13, LOW);&#xA;    delay(100);&#xA;}&#xA;pinMode(13, INPUT); // This will &quot;reset&quot; the pin to default.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-02-21T19:47:41.223" LastActivityDate="2016-02-21T19:47:41.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20961" PostTypeId="2" ParentId="20109" CreationDate="2016-02-21T20:06:40.763" Score="0" Body="&lt;p&gt;One can use something like &lt;a href=&quot;https://github.com/nekromant/rf24boot&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. It is a custom bootloader to update a Arduino's code via a NRF24L01+ radio module.*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*It only works under Linux machines.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-02-21T20:06:40.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20962" PostTypeId="2" ParentId="20886" CreationDate="2016-02-21T21:02:12.357" Score="1" Body="&lt;p&gt;I worked on a project similar to yours. I think you forgot to &lt;strong&gt;establish a connection first&lt;/strong&gt;.&#xA;Just add those lines of code at the top of &lt;code&gt;setup()&lt;/code&gt; method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; gprsSerial.println(&quot;AT+UPSDA=2,0&quot;); //Reset connection&#xA; toSerial();&#xA; delay(2000);&#xA;  gprsSerial.println(&quot;AT+UPSD=2,1,\&quot;weborange\&quot;&quot;); //Establish a new one&#xA; toSerial();&#xA; delay(2000);&#xA; gprsSerial.println(&quot;AT+UPSDA=2,3&quot;); &#xA; toSerial();&#xA; delay(2000);&#xA; gprsSerial.println(&quot;AT+UPSND=2,0&quot;);&#xA; toSerial();&#xA; delay(2000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope it works for you. Else, you can use &lt;code&gt;AT+UHTTPER=2&lt;/code&gt; after all to check for error source.&lt;/p&gt;&#xA;" OwnerUserId="18572" LastEditorUserId="6826" LastEditDate="2016-02-21T21:27:12.097" LastActivityDate="2016-02-21T21:27:12.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20963" PostTypeId="1" AcceptedAnswerId="20986" CreationDate="2016-02-21T21:41:03.060" Score="1" ViewCount="1907" Body="&lt;p&gt;As told in this post:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php/topic,16612.0.html#&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php/topic,16612.0.html#&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino can achive up to 62.5khz with 8 bits resolution&lt;/p&gt;&#xA;&#xA;&lt;p&gt;adding this line in the setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0x01&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;sets the divisor of the timer to 1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int output = 5;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0x01;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  analogWrite(output,127);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I need a frequency of 100khz or as close as possible, the 8 bits resolution is not necessary of my porpouse, it will work just fine with 6 or 7 bits.&lt;/p&gt;&#xA;" OwnerUserId="18574" LastActivityDate="2016-02-23T18:58:00.003" Title="how to change increase pwm frequency by changing resolution?" Tags="|pwm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20964" PostTypeId="1" AcceptedAnswerId="20966" CreationDate="2016-02-21T22:41:37.503" Score="1" ViewCount="90" Body="&lt;p&gt;I tried to assemble Adafruit's Arduino LCD 16 x 2 using the instructions &lt;a href=&quot;https://learn.adafruit.com/rgb-lcd-shield/assembly&quot; rel=&quot;nofollow&quot;&gt;RGB LCD Shield: Control a 16x2 Character LCD using 2 pins - Assembly&lt;/a&gt;  without any success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After assembly, I uploaded the &lt;a href=&quot;https://github.com/adafruit/Adafruit-RGB-LCD-Shield-Library&quot; rel=&quot;nofollow&quot;&gt;HelloWorld example sketch&lt;/a&gt; on to the Arduino. The shield doesn't seem to be working. The LCD didn't turn on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I push back/press the LCD it turn on. Any idea on how to troubleshoot this?&lt;/p&gt;&#xA;" OwnerUserId="18575" OwnerDisplayName="user1261620" LastEditorUserId="6936" LastEditDate="2016-03-28T18:29:11.713" LastActivityDate="2016-03-28T18:29:11.713" Title="Troubleshoot Arduino LCD 16 x 2 shield" Tags="|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20966" PostTypeId="2" ParentId="20964" CreationDate="2016-02-21T23:00:20.677" Score="0" Body="&lt;p&gt;By visually assessing the pictures, the issue seems to be due to poor soldering job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should try re-heating the soldering joints and make sure they are clean. There could be dry joints that may not be conducting signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you should upload pictures to your question post, not as an answer.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastActivityDate="2016-02-21T23:00:20.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20967" PostTypeId="1" CreationDate="2016-02-22T00:56:25.330" Score="2" ViewCount="1168" Body="&lt;p&gt;I have been running a simple weather station composed of a Sparkfun Pro Micro (8kHz/3.3V), a DHT22 and a NRF24L01+ transceiver during the last couple of months, and I can tell you up here in Canada weather stations save lives...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board checks the temperature and the humidity once every second and transmits the new measurements back to my home server over RF if the changes are above some threshold. As such, the board sleeps most of the time, and the transmissions happen rarely (about once to thrice per minute).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The system has been running off an iPhone charger up to now, but I am now thinking of weaning it off the mains. The maximum power consumption of the whole circuit when DHT22 is on and RF chip is transmitting remains below 200mA and many articles suggest that &lt;a href=&quot;http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/&quot; rel=&quot;nofollow noreferrer&quot;&gt;with some optimization one can reduce the power draw by levels of magnitude&lt;/a&gt;. Actually, from what I read &lt;a href=&quot;http://www.instructables.com/id/SOLAR-POWERED-ARDUINO-WEATHER-STATION/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;I gather that the average consumption of the circuit can be pushed below 1mA&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I was thinking of adding a solar panel, a charging circuit and a Li-ion battery to my setup, when I discovered these low-cost solar-powered USB power banks on several vendor websites. They make outrageous claims about their charge capacity, that in my experience one has to divide at least by two (20,000 ~= 10,000), but they are pretty rugged and seem appropriate for outdoor installation. The units seem to use a 6V/0.6W (100mA) solar cell that should theoretically be sufficient for charging the battery even if some days are less sunny or shorter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if anyone has used one of these as a continuous power supply for an arduino kit, or can inform me about the possible limitations. The idea is not to deal with the power apparatus myself each time I want to assemble a kit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QzJfE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QzJfE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UShbd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UShbd.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14578" LastActivityDate="2016-02-22T00:56:25.330" Title="Sustainable power source for outdoor arduino weather station" Tags="|battery|arduino-micro|solar|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20968" PostTypeId="1" AcceptedAnswerId="20973" CreationDate="2016-02-22T02:11:02.237" Score="0" ViewCount="1432" Body="&lt;p&gt;Can anyone help me on how to correct my program ? I want to transmit value in string form. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put this to TX code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct payload_t&#xA;{&#xA;&#xA; String sensor1;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..................&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the loop part I put this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String sensor1 = (String(x) + &quot;,&quot; + String(y) + &quot;,&quot; + String(z)) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the RX part I put this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; struct payload_t&#xA;{&#xA;&#xA; String sensor1;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the loop part &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24NetworkHeader header;&#xA;payload_t payload;&#xA;network.read(header,&amp;amp;payload,sizeof(payload)); &#xA;&#xA;Serial.println(&quot;Sensor1 &quot;); &#xA;&#xA;Serial.println(payload.sensor1); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is the Attach picture result of RX code.&lt;a href=&quot;https://i.stack.imgur.com/RDwN1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RDwN1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance :)&lt;/p&gt;&#xA;" OwnerUserId="16544" LastActivityDate="2016-02-27T00:05:31.650" Title="How to set string in the structure part of NRF24?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20970" PostTypeId="1" AcceptedAnswerId="20972" CreationDate="2016-02-22T02:54:17.017" Score="1" ViewCount="2599" Body="&lt;p&gt;I have an Arduino Mega communicating with a Bluetooth adapter through one of the auxiliary hardware serial ports. It works, but there appears to be a corruption rate of approximately 1 in 200 small packets. In other words, about 0.5% of the packets are being corrupted, it seems. I have the option of configuring the serial mode on both ends. While I cannot decrease the baud rate for bandwidth reasons, I do have enough room to enable &lt;em&gt;parity&lt;/em&gt; or a larger &lt;em&gt;stop bit&lt;/em&gt; if that would help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Granted the corruption is on the serial line and not on the Bluetooth, if I enable parity, will this actually decrease the corruption rate? Or will the corrupt bytes simply be dropped without being re-sent? In other words, what happens when the hardware detects a bad byte?&lt;/p&gt;&#xA;" OwnerUserId="15303" LastEditorUserId="15303" LastEditDate="2016-02-22T06:33:24.410" LastActivityDate="2016-02-22T21:36:41.323" Title="Will enabling parity bit actually decrease corruption?" Tags="|serial|arduino-mega|bluetooth|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="20971" PostTypeId="2" ParentId="20970" CreationDate="2016-02-22T03:27:50.470" Score="3" Body="&lt;p&gt;Parity by itself does not reduce the error rate, it is used to detect errors. It is up to higher level protocols to determine what to do when the error is detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your question about stop bits, going to two &lt;em&gt;might&lt;/em&gt; help. The extra stop bit adds a 1-bit-time gap between characters and gives the receiver a little more time to sync up with the transmitter. If the baud rates are a little off between the sender and receiver, it would make it more likely that errors would be limited to one character rather than a whole string of them. That said, the 2 stop bit option is mostly a relic from the days of mechanical Teletype machines. These days it is usually better to make sure both clocks are at the correct frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you determined where the errors are occurring - in the serial connection between the Mega and the BT adapter, in the BT link itself, or at the other end? With short wires, correct baud rates (check for the correct clock frequency), a good ground, and correct logic voltages, the raw error rate in the serial connection should be extremely low. I would focus on finding the source of the errors before trying to correct them. &lt;/p&gt;&#xA;" OwnerUserId="18526" LastEditorUserId="18526" LastEditDate="2016-02-22T17:20:08.957" LastActivityDate="2016-02-22T17:20:08.957" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20972" PostTypeId="2" ParentId="20970" CreationDate="2016-02-22T03:32:33.890" Score="5" Body="&lt;p&gt;Parity doesn't, and was never intended to, decrease corruption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All parity does is allow you to DETECT errors. If you detect errors, you still have to handle them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Parity in memory is usually fatal - your code or data is corrupt, the solution is to halt the box, to stop this corruption (in memory) getting on to disk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When used in communication (as it is here), parity errors usually mean you have to request a re-transmit (or, if acknowledgements are sent back, fail to send an acknowledgement and wait for an automatic re-transmit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, be aware that the relevant error rate is per bit, not per packet. If a small packet (very small!) is 20 bytes, and there is corruption 0.5% of those packets, this indicates a 0.5% / 20 bytes per packet / 8 bits per byte (assuming 7 data bits, 1 parity bit, for example). This comes out to 0.003% errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that parity checks only work for 1-bit errors - in fact, a 2-bit error (in the same byte), the parity change will cancel out, and it will look ok. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative to requesting re-transmits, is to use forward error correction - send redundant data (reducing your bandwidth). A very easy scheme is to send each packet twice (halving your bandwidth). You still need error checking (or some checksum) - if two packets are different, you still need to know which one was right. Checksums, on a more complex device, could let you try each combination, but for an Arduino, this would probably be too expensive (the code would take up sizable space, which an Arduino may, or may not, have spare).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of this is usually written into higher level protocols (TCP, used for most internet file transmission, ZModem file transfer used for modems prior to the Internet). Other protocols, such as internet radio, will use either forward error correction, or will accept the occasional glitch.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-02-22T03:32:33.890" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20973" PostTypeId="2" ParentId="20968" CreationDate="2016-02-22T04:08:31.757" Score="2" Body="&lt;p&gt;Did you actually 'instantiate' the struct in the TX and construct &lt;code&gt;sensor1&lt;/code&gt; as &lt;code&gt;payload.sensor1 = ...&lt;/code&gt;? Anyways, there's still a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are using &lt;code&gt;String&lt;/code&gt; in your payload. The third argument to &lt;code&gt;read&lt;/code&gt; is the maximum message length that can be stored in &lt;code&gt;payload&lt;/code&gt;. In your &lt;code&gt;read&lt;/code&gt; call, you passed the size of payload as &lt;code&gt;MAX_LEN&lt;/code&gt;. You will receive incomplete payloads since the String object in the RX &lt;code&gt;payload&lt;/code&gt; struct has no content in it yet and thus &lt;code&gt;payload&lt;/code&gt;'s size, which you passed as &lt;code&gt;MAX_LEN&lt;/code&gt;, will be less than that of the actual payload that was transmitted. Just ditch the Strings and try:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TX:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int vals = {x, y, z};   // guessing they are ints&#xA;&#xA;network.write(header, &amp;amp;vals, sizeof(vals));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int vals[3];&#xA;network.read(header, &amp;amp;vals, sizeof(vals));&#xA;&#xA;Serial.print(vals[0]); Serial.print(',');&#xA;Serial.print(vals[1]); Serial.print(',');&#xA;Serial.println(vals[2]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-02-27T00:05:31.650" LastActivityDate="2016-02-27T00:05:31.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20976" PostTypeId="1" CreationDate="2016-02-22T07:55:09.693" Score="0" ViewCount="143" Body="&lt;p&gt;Sir/ Ma'am,&#xA;.&#xA;How to read the dimension labels of this IC?&lt;a href=&quot;https://i.stack.imgur.com/36PTZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/36PTZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18584" LastActivityDate="2016-02-22T12:20:09.463" Title="(HELP)How to read Physical Dimensions in datasheets" Tags="|electronics|components|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20977" PostTypeId="2" ParentId="20976" CreationDate="2016-02-22T08:16:06.697" Score="1" Body="&lt;p&gt;Values above the horizontal lines are in inches. Values below it are in mm.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-02-22T08:16:06.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20978" PostTypeId="1" AcceptedAnswerId="20979" CreationDate="2016-02-22T09:10:04.733" Score="7" ViewCount="8830" Body="&lt;p&gt;My company is developing a programmable remote control car which is driven by an Arduino Nano. We would like a way for the user to install software updates to the Arduino, but we don't want to give the user access to the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to compile Arduino code without automatically uploading it, so that I can put the pre-compiled binary up for download on a website? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then after this how would I go about manually uploading it (to the Arduino)?&lt;/p&gt;&#xA;" OwnerUserId="18587" LastEditorUserId="19409" LastEditDate="2016-10-15T20:06:04.860" LastActivityDate="2019-10-04T11:32:19.647" Title="Is there a way to upload precompiled code to an arduino?" Tags="|arduino-nano|uploading|compile|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20979" PostTypeId="2" ParentId="20978" CreationDate="2016-02-22T09:30:20.297" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to compile arduino code without automatically uploading it, so that I can put the pre-compiled binary up for download on a website? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can save the .hex file produced by the compiler. If you turn on verbose output from the compiler you can find the temporary directory where it is stored. Simply copy from there to a folder for download on the website.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And then after this how would I go about manually uploading it (To the arduino)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can do that with the command line tool avrdude but as that is somewhat complex with a lot of parameters it might be easier to use a graphical front-end. One such tool is &lt;a href=&quot;http://russemotto.com/xloader/&quot;&gt;xloader&lt;/a&gt;. There are several. This depends on your end-users and the host machine that they will be using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find some more info &lt;a href=&quot;https://github.com/euphy/polargraph/wiki/Uploading-precompiled-binary-hex-files&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-22T10:23:02.880" LastActivityDate="2016-02-22T10:23:02.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20981" PostTypeId="1" CreationDate="2016-02-22T10:01:06.700" Score="0" ViewCount="1704" Body="&lt;p&gt;I'm not expert in electrical circuits, maybe I am making a very simple mistake or missing some basic points with my circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to achieve is simple, to run 2 DC motors with an ultrasonic sensor to detect obstacles and change direction. When I unplug the ultrasonic sensor everything is working fine as expected without obstacle detection but when I connect the ultrasonic sensor, sensor always responds with 0 cm distance. Then I removed 9 V battery from the circuit and plug Arduino to computer via USB, sensor works fine but motors are not working properly, it looks like the power from USB is not enough to drive motors at the same time. I've added my circuit scheme below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aBHPi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aBHPi.png&quot; alt=&quot;Circuit Scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18591" LastEditorUserId="26916" LastEditDate="2017-11-04T23:08:40.750" LastActivityDate="2017-11-04T23:08:40.750" Title="Problem with running 2 DC motors with ultrasonic sensor" Tags="|motor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20982" PostTypeId="2" ParentId="20976" CreationDate="2016-02-22T12:20:09.463" Score="2" Body="&lt;p&gt;I have annotated your drawing a little to help you understand it better:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hMxQV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hMxQV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-22T12:20:09.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20983" PostTypeId="2" ParentId="20970" CreationDate="2016-02-22T13:37:14.687" Score="1" Body="&lt;p&gt;I am guessing that the problem is that your clock is not 100% divisable to produce exactly 115200. If so it makes sense that communication sometimes fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://electronics.stackexchange.com/q/7334/568&quot;&gt;this question&lt;/a&gt; for more details, in particular &#xA;the link to &lt;a href=&quot;http://wormfood.net/avrbaudcalc.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;WormFood's AVR Baud Rate Calculator&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3821" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-22T13:37:14.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20986" PostTypeId="2" ParentId="20963" CreationDate="2016-02-22T15:59:19.150" Score="1" Body="&lt;p&gt;Here's code for timer 1 on a atmega32u tested in a Teensy 2.0:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;   // Timer 1 Fast PWM mode *toggling* OC1A at 50kHz with *two* OCR1A counts&#xA;   // And 7.32 bits 0-159 PWM on OC1B at 100kHz&#xA;   // Output on OC1B  &#xA;   // Set at TOP, Clear at OCR1B&#xA;   // WGM =15 0b1111 &#xA;&#xA;   DDRB |= bit(DDB5) | bit(DDB6);  // atmega32u OC1A and OC1B outputs&#xA;  // DDRB |= bit(DDB1) | bit(DDB2);  // atmega168/UNO OC1A and OC1B (Tested by OP/Luis)&#xA;&#xA;   TCCR1A =  bit(WGM11) | bit(WGM10) | bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM13) | bit(WGM12) | bit(CS10);  // Set /1 prescaler&#xA;   OCR1A  = 159 ;//79;    // Set TOP count to 16000000/(2*PreScaler*Ftoggle)&#xA;                          // or 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = 10;           // 10/160 duty cycle&#xA;   TCNT1 = 0 ;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  OCR1B = 160/4 -1 ; // 25% duty cycle. &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The trick here is using OCRxA to set the TOP value/resolution/frequency of the timer, and then using OCRxB as the PWM-controlled output.  The popular examples aim for a specific frequency with toggling, but often don't go into showing the PWM with the non-TOP OCRxx registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you check the registers for your chip, this should also adapt to the other timers.  Here, I used timer1 to avoid confusing delay() and millis().&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-02-23T18:58:00.003" LastActivityDate="2016-02-23T18:58:00.003" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="20989" PostTypeId="2" ParentId="20919" CreationDate="2016-02-22T16:58:34.937" Score="1" Body="&lt;p&gt;After trying the original code using Arduino IDE 1.6.7, I do not see a problem with using up memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the nature of the errors you are seeing, another possible explanation is that you are getting spurious data between real events. If electrical noise or whatever produces one or more characters on the serial line in the long interval between real data points, the current code will treat it as a new data point. If the bogus characters are numeric, they will be sent to the pwm. In the more likely case of non-numeric data, this code converts them to a value of 0 and sends that to the port. This situation is likely if the Arduino is more than a few feet from the PC. A slew rate limited differential driver and receiver like the MAX488 should greatly reduce the chance of this happening. Also make sure there is a good ground between the ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also reduce the chance of undetected data errors by delimiting your data with something like a '$' to start, then the data, then '*' then a checksum then a newline. The checksum could be simply the sum of all the characters up to the *, truncated to 8 bits and sent as 2 hex characters. This is what the NMEA protocol used by GPS receivers does. At the receiving end you only accept data packets with the proper format and checksum.&lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-22T16:58:34.937" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="20990" PostTypeId="2" ParentId="20970" CreationDate="2016-02-22T17:26:20.753" Score="1" Body="&lt;p&gt;Parity checking will only let your code detect a corrupted byte, and not very well at that. Assuming your primary goal is to get packets transferred reliably, you'd be better off to add a checksum to each packet sent, testing the checksum when the packet is received, and asking the transmitter to re-send a failed packet. Since you only expect 1 packet in 200 to be retransmitted, your bandwidth shouldn't take a big hit.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-02-22T21:36:41.323" LastActivityDate="2016-02-22T21:36:41.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20991" PostTypeId="2" ParentId="11909" CreationDate="2016-02-22T20:05:13.993" Score="1" Body="&lt;p&gt;V2.2 is pretty old by now.&#xA;As far as I recall it should work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;V2.2 of the Arduino eclipse plugin should work fine with the Arduino IDE version 1.5.8. &#xA;What that phrase wants to say is: the plugin V2.2 was released before Arduino IDE 1.5.8 was released; as such the code can not make a statement on the compatibility. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But again V2.2 is old. We hope to release V3.0 end of February 2016&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="11529" LastEditDate="2016-03-24T19:26:05.430" LastActivityDate="2016-03-24T19:26:05.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20993" PostTypeId="2" ParentId="12187" CreationDate="2016-02-22T21:09:23.000" Score="1" Body="&lt;p&gt;I suspect that this is a String class heap-fragementation issue (again). To test this you could sending a fixed string buffer (vector of characters, &quot;Hello world&quot; :). Do not use String and SD/FAT in the test. Just send a large number of lines with dummy data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this works replace the String usage with a character buffer. Fill it from the SD file (buffer size at a time) and write to Serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-22T21:09:23.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20994" PostTypeId="1" CreationDate="2016-02-22T21:28:25.200" Score="8" ViewCount="19477" Body="&lt;p&gt;I am familiar with the keyword &lt;code&gt;Volatile&lt;/code&gt; being used to declare variables that are shared among multiple threads on a software application (basically on a multithreaded application).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why do I need to declare a variable as &lt;code&gt;Volatile&lt;/code&gt; when running the code on an an Arduino interrupt? Is the code running in the interrupt executing on different thread? Is there something else going on?&lt;/p&gt;&#xA;" OwnerDisplayName="T555" LastEditorUserId="10794" LastEditDate="2016-02-23T00:28:27.413" LastActivityDate="2021-10-22T15:36:25.273" Title="Why the need to use the volatile keyword on global variables when handling interrupts in Arduino?" Tags="|c++|interrupt|isr|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="20995" PostTypeId="2" ParentId="20994" CreationDate="2016-02-22T21:34:26.177" Score="7" Body="&lt;p&gt;&lt;code&gt;volatile&lt;/code&gt; has nothing to do with multithreading per se, and it seems to be among the most miused keywords in that area. It is never a substitute for proper synchronization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per standard C, &lt;code&gt;volatile&lt;/code&gt; invokes mostly implementation defined behaviour of telling the compiler to not optimize away accesses to the memory a variable resides in, even if the compiler thinks there can't be any other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This &lt;em&gt;can&lt;/em&gt; be useful in the following situations where the compiler is not aware that outside means can change a variable:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;memory mapped hardware registers &lt;/li&gt;&#xA;&lt;li&gt;variables accessed from other threads but checked in a tight loop&lt;/li&gt;&#xA;&lt;li&gt;variables accessed from interrupt or signal handlers but checked in a tight loop&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerDisplayName="PlasmaHH" LastActivityDate="2016-02-22T21:34:26.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="20996" PostTypeId="2" ParentId="20880" CreationDate="2016-02-22T22:42:23.260" Score="0" Body="&lt;p&gt;Using info from every suggestion, I've so far come up with the following.  I may not need to touch this code again for years and years (or a new house owner may need to look at it should I move out), so I tried to comment it as much as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't like that I've repeated so much code in the readFloatSensor functions, but this is where I am so far.  How can I eliminate the code duplication?  I believe I could use arrays and &lt;code&gt;for&lt;/code&gt; loops but now I've entered another grey area for my knowledge level.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// PumpController.ino&#xA;&#xA;// ----CONSTANTS&#xA;// ----Edit these if you need to change the pin layout or pump duration&#xA;&#xA;#define RELAY_ON 0                     // The pump relays are active-LOW; on when LOW (0)&#xA;#define RELAY_OFF 1                    // and off when HIGH (1). These #defines just help keep track.&#xA;&#xA;const int pumpRelayPin1 =  12;         // Pin numbers for the pump relays&#xA;const int pumpRelayPin2 =  11;&#xA;const int pumpRelayPin3 =  10;&#xA;&#xA;const int floatSensorPin1 = 7;         // Pin numbers for the float sensors&#xA;const int floatSensorPin2 = 8;&#xA;const int floatSensorPin3 = 9;&#xA;&#xA;const int pumpDuration = 500;          // Number of millisecs that the pumps run&#xA;                                       // after the float sensors no longer detect water&#xA;&#xA;// ----VARIABLES&#xA;&#xA;byte pumpState1 = RELAY_OFF;           // Used to record whether the pumps are on or off&#xA;byte pumpState2 = RELAY_OFF;           // (default to HIGH/OFF)&#xA;byte pumpState3 = RELAY_OFF;&#xA;&#xA;unsigned long currentMillis = 0;       // Stores the value of millis() in each iteration of loop()&#xA;&#xA;unsigned long pumpTimerMillis1 = 0;    // Stores the times when the float sensors were last triggered&#xA;unsigned long pumpTimerMillis2 = 0;&#xA;unsigned long pumpTimerMillis3 = 0;&#xA;&#xA;&#xA;// ----SETUP (Sets up the pins at startup/reset)&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;    // Debug&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Starting PumpController.ino&quot;);&#xA;&#xA;    // Pump relays are active-LOW. Initialize pump&#xA;    // pins HIGH so the relays are inactive at startup/reset&#xA;    digitalWrite(pumpRelayPin1, RELAY_OFF);&#xA;    digitalWrite(pumpRelayPin2, RELAY_OFF);&#xA;    digitalWrite(pumpRelayPin3, RELAY_OFF);&#xA;&#xA;    // THEN set the pins as outputs&#xA;    pinMode(pumpRelayPin1, OUTPUT);&#xA;    pinMode(pumpRelayPin2, OUTPUT);&#xA;    pinMode(pumpRelayPin3, OUTPUT);&#xA;&#xA;    // Set the float sensor pins as inputs and use the built-in pullup resistors&#xA;    pinMode(floatSensorPin1, INPUT_PULLUP);&#xA;    pinMode(floatSensorPin2, INPUT_PULLUP);&#xA;    pinMode(floatSensorPin3, INPUT_PULLUP);&#xA;&#xA;}&#xA;&#xA;&#xA;// ----MAIN LOOP&#xA;&#xA;void loop()&#xA;{&#xA;    // Get the current clock count&#xA;&#xA;    currentMillis = millis() + pumpDuration;       // We add the countdown timer duration to&#xA;                                                   // the clock to prevent the pumps from&#xA;                                                   // running at boot time, while the clock&#xA;                                                   // counter is still below the timer value&#xA;&#xA;    // Call the functions that do the work&#xA;&#xA;    readFloatSensor1();             // check each float sensor and decide whether&#xA;    readFloatSensor2();             // to start the pump and countdown timer&#xA;    readFloatSensor3();&#xA;    triggerPumps();                 // Actually toggles the relay pins based on&#xA;}                                   // the data from the above functions.&#xA;&#xA;&#xA;// ----WORKER FUNCTIONS&#xA;&#xA;void readFloatSensor1()&#xA;{&#xA;    if (digitalRead(floatSensorPin1) == LOW)   // If the float sensor is tripped (pulled low)&#xA;    {&#xA;        pumpState1 = RELAY_ON;                 // then trigger the pump relay pin&#xA;        pumpTimerMillis1 = currentMillis;      // and set the pump countdown timer to the current clock time&#xA;    }&#xA;&#xA;    if (currentMillis - pumpTimerMillis1 &amp;gt;= pumpDuration)   // If the countdown timer has expired,&#xA;    {&#xA;        pumpState1 = RELAY_OFF;                             // then turn off the pump relay pin&#xA;        pumpTimerMillis1 = 0;                               // and reset the timer to 0 for the next trigger&#xA;    }&#xA;}&#xA;&#xA;//========&#xA;&#xA;void readFloatSensor2()&#xA;{&#xA;    if (digitalRead(floatSensorPin2) == LOW)   // If the float sensor is tripped (pulled low)&#xA;    {&#xA;        pumpState2 = RELAY_ON;                 // then trigger the pump relay pin&#xA;        pumpTimerMillis2 = currentMillis;      // and set the pump countdown timer to the current clock time&#xA;    }&#xA;&#xA;    if (currentMillis - pumpTimerMillis2 &amp;gt;= pumpDuration)   // If the countdown timer has expired,&#xA;    {&#xA;        pumpState2 = RELAY_OFF;                             // then turn off the pump relay pin&#xA;        pumpTimerMillis2 = 0;                               // and reset the timer to 0 for the next trigger&#xA;    }&#xA;}&#xA;&#xA;//========&#xA;&#xA;void readFloatSensor3()&#xA;{&#xA;    if (digitalRead(floatSensorPin3) == LOW)   // If the float sensor is tripped (pulled low)&#xA;    {&#xA;        pumpState3 = RELAY_ON;                 // then trigger the pump relay pin&#xA;        pumpTimerMillis3 = currentMillis;      // and set the pump countdown timer to the current clock time&#xA;    }&#xA;&#xA;    if (currentMillis - pumpTimerMillis3 &amp;gt;= pumpDuration)   // If the countdown timer has expired,&#xA;    {&#xA;        pumpState3 = RELAY_OFF;                             // then turn off the pump relay pin&#xA;        pumpTimerMillis3 = 0;                               // and reset the timer to 0 for the next trigger&#xA;    }&#xA;}&#xA;&#xA;//========&#xA;&#xA;void triggerPumps()&#xA;{&#xA;    // Toggle the pump relay pins on and off based on&#xA;    // pumpState from the readFloatSensor functions&#xA;&#xA;    digitalWrite(pumpRelayPin1, pumpState1);&#xA;    digitalWrite(pumpRelayPin2, pumpState2);&#xA;    digitalWrite(pumpRelayPin3, pumpState3);&#xA;}&#xA;&#xA;//=====END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18522" LastActivityDate="2016-02-22T22:42:23.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20997" PostTypeId="2" ParentId="20981" CreationDate="2016-02-23T00:13:46.600" Score="1" Body="&lt;p&gt;How (acoustically) loud are the motors?  If they're the typical RC car motors, they can screech harmonics right up into the 40 KHz range typical of ultrasound ranging sensors, interfering with the sensor's ability to work at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How (electrically) loud are the motors?  If RC as above, they throw all sorts of transients onto the power lines (and everything else within electrical pickup range).  You might want to put some ceramic capacitors across the motor leads to absorb some of those transients.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kudos for the suggestions to provide separate power supplies for the motors and the Arduino / sensor combination.  I'd go even further, and provide separate power for all three, and use opto-isolators for the connection between the ultrasound and the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some years ago I used two &lt;a href=&quot;http://teamnovak.com/products/esc/super_rooster/index.html&quot; rel=&quot;nofollow&quot;&gt;Novak Super-Rooster&lt;/a&gt; motor drivers for a battle-bot competition.  They were driven by PWM outputs of an Arduino, where 50% duty cycle was off, 0% was full speed reverse, and 100% was full speed ahead.  These were powered by a sealed lead acid battery, and driven full-out, the motors got +/- 12VDC at about 40 amps.  There was a common ground with the Arduino, going to the Super Roosters, but not the motors, and the drivers took care of the electrical shielding, with a little help from the ceramic bypass capacitors I mentioned.  Worked great!&lt;/p&gt;&#xA;" OwnerUserId="18614" LastActivityDate="2016-02-23T00:13:46.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="20998" PostTypeId="2" ParentId="20994" CreationDate="2016-02-23T00:27:08.280" Score="16" Body="&lt;p&gt;First, it's &lt;code&gt;volatile&lt;/code&gt; not &lt;code&gt;Volatile&lt;/code&gt;. I cover these concepts in my page about &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;noreferrer&quot;&gt;Interrupts&lt;/a&gt; however to avoid giving a link-only answer I'll repeat the relevant bits.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;What are &quot;volatile&quot; variables?&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Variables &lt;strong&gt;shared&lt;/strong&gt; between ISR functions and normal functions should be declared &lt;code&gt;volatile&lt;/code&gt;. This tells the compiler that such variables might change at any time, and thus the compiler must reload the variable whenever you reference it, rather than relying upon a copy it might have in a processor register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile boolean flag;&#xA;&#xA;// Interrupt Service Routine (ISR)&#xA;void isr ()&#xA;{&#xA; flag = true;&#xA;}  // end of isr&#xA;&#xA;void setup ()&#xA;{&#xA;  attachInterrupt (0, isr, CHANGE);  // attach interrupt handler&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;  if (flag)&#xA;    {&#xA;    // interrupt has occurred&#xA;    }&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Critical sections ... accessing volatile variables&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are some subtle issues regarding variables which are shared between interrupt service routines (ISRs) and the main code (that is, the code not in an ISR).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since an ISR can fire at any time when interrupts are enabled, you need to be cautious about accessing such shared variables, as they may be being updated at the very moment you access them.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;First ... when do you use &quot;volatile&quot; variables?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A variable should only be marked volatile if it is used both inside an ISR, and outside one.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variables &lt;strong&gt;only&lt;/strong&gt; used &lt;strong&gt;outside&lt;/strong&gt; an ISR should &lt;strong&gt;not&lt;/strong&gt; be volatile.&lt;/li&gt;&#xA;&lt;li&gt;Variables &lt;strong&gt;only&lt;/strong&gt; used &lt;strong&gt;inside&lt;/strong&gt; an ISR should &lt;strong&gt;not&lt;/strong&gt; be volatile.&lt;/li&gt;&#xA;&lt;li&gt;Variables used both &lt;strong&gt;inside and outside&lt;/strong&gt; an ISR &lt;strong&gt;should be&lt;/strong&gt; volatile.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile int counter;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Marking a variable as volatile tells the compiler to not &quot;cache&quot; the variable's contents into a processor register, but always read it from memory, when needed. This may slow down processing, which is why you don't just make every variable volatile, when not needed.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Atomic access&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Consider this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile byte count;&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  count = 10;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  }&#xA;&#xA;void loop () &#xA;  {&#xA;  count++;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code generated for &lt;code&gt;count++&lt;/code&gt; (add 1 to count) is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 14c:   80 91 00 02     lds r24, 0x0200&#xA; 150:   8f 5f           subi    r24, 0xFF     &amp;lt;&amp;lt;---- problem if interrupt occurs before this is executed&#xA; 152:   80 93 00 02     sts 0x0200, r24   &amp;lt;&amp;lt;---- problem if interrupt occurs before this is executed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that it adds 1 by subtracting -1)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two danger points here, as marked. If the interrupt fires after the lds (load register 24 with the variable &lt;code&gt;count&lt;/code&gt;), but before the sts (store back into the variable &lt;code&gt;count&lt;/code&gt;) then the variable might be changed by the ISR (TIMER1_OVF_vect), however &lt;strong&gt;this change is now lost&lt;/strong&gt;, because the variable in the register was used instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We need to protect the shared variable by turning off interrupts briefly, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile byte count;&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  count = 10;&#xA;  }  // end of TIMER1_OVF_vect&#xA;&#xA;void setup ()&#xA;  {&#xA;  }  // end of setup&#xA;&#xA;void loop () &#xA;  {&#xA;  noInterrupts ();&#xA;  count++;&#xA;  interrupts ();&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the update of &lt;code&gt;count&lt;/code&gt; is done &quot;atomically&quot; ... that is, it cannot be interrupted.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;Multi-byte variables&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Let's make &lt;code&gt;count&lt;/code&gt; a 2-byte variable, and see the other problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile unsigned int count;&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  count++;&#xA;  } // end of TIMER1_OVF_vect&#xA;&#xA;void setup ()&#xA;  {&#xA;  pinMode (13, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop () &#xA;  {&#xA;  if (count &amp;gt; 20)&#xA;     digitalWrite (13, HIGH);&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OK, we are not changing &lt;code&gt;count&lt;/code&gt; any more, so is there still a problem? Sadly, yes. Let's look at the generated code for the &quot;if&quot; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 172:   80 91 10 02     lds r24, 0x0210&#xA; 176:   90 91 11 02     lds r25, 0x0211  &amp;lt;&amp;lt;---- problem if interrupt occurs before this is executed&#xA; 17a:   45 97           sbiw    r24, 0x15   &#xA; 17c:   50 f0           brcs    .+20        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Imagine that &lt;code&gt;count&lt;/code&gt; was 0xFFFF and was about to &quot;wrap around&quot; back to zero. We load 0xFF into one register, but before we load the second 0xFF the variable changes to 0x00. Now we think &lt;code&gt;count&lt;/code&gt; is 0x00FF which is neither the value it had before (0xFFFF) or now (0x0000).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So again we have to &quot;protect&quot; the access to the shared variable, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop () &#xA;  {&#xA;  noInterrupts ();&#xA;  if (count &amp;gt; 20)&#xA;     digitalWrite (13, HIGH);&#xA;  interrupts ();&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h3&gt;What if you are not sure interrupts are on or off?&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There is a final &quot;gotcha&quot; here. What if interrupts might be off already? Then turning them back on afterwards is a Bad Idea.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case you need to save the processor status register like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int getCount ()&#xA;  {&#xA;  unsigned int c;&#xA;  byte oldSREG = SREG;   // remember if interrupts are on or off&#xA;&#xA;  noInterrupts ();   // turn interrupts off&#xA;  c = count;         // access the shared variable&#xA;  SREG = oldSREG;    // turn interrupts back on, if they were on before&#xA;&#xA;  return c;          // return copy of shared variable&#xA;  }  // end of getCount&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This &quot;safe&quot; code saves the current status of interrupts, turns them off (they may already be off), gets the shared variable into a temporary variable, turns interrupts back on - if they were on when we entered the function - and then returns the copy of the shared variable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Summary&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Code may &quot;appear to work&quot; even if you don't take the above precautions. That is because the chances of the interrupt occurring at the exact wrong moment is fairly low (maybe 1 in 100, depending on the code size). But sooner or later it will happen at the wrong moment, and your code will either crash, or occasionally return the wrong results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for reliable code, pay attention to protecting access to shared variables.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-23T00:27:08.280" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="20999" PostTypeId="1" CreationDate="2016-02-22T23:46:57.053" Score="3" ViewCount="34563" Body="&lt;p&gt;I'm working on a project where I need to have Bluetooth capability on my Arduino Nano to send data from a sensor over to the computer. Unfortunately, I'm having a difficult time figuring out how to establish a connection from the HC-06 to the computer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've hooked up the HC-06 to my Arduino in a fashion similar to the picture shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/2xars.png&quot; alt=&quot;HC-06 to Arduino Nano&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also been testing it with various code that I've found online that deal with tutorials on the HC-06.  The current code I'm working with is below.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial BT(1, 0); &#xA;&#xA;void setup()  &#xA;{&#xA;  // set digital pin to control as an output&#xA;  pinMode(13, OUTPUT);&#xA;  // set the data rate for the SoftwareSerial port&#xA;  BT.begin(9600);&#xA;  // Send test message to other device&#xA;  BT.println(&quot;Hello from Arduino&quot;);&#xA;}&#xA;char a; // stores incoming character from other device&#xA;void loop() &#xA;{&#xA;  if (BT.available())&#xA;  // if text arrived in from BT serial...&#xA;  {&#xA;    a=(BT.read());&#xA;    if (a=='1')&#xA;    {&#xA;      digitalWrite(13, HIGH);&#xA;      BT.println(&quot;LED on&quot;);&#xA;    }&#xA;    if (a=='2')&#xA;    {&#xA;      digitalWrite(13, LOW);&#xA;      BT.println(&quot;LED off&quot;);&#xA;    }&#xA;    if (a=='?')&#xA;    {&#xA;      BT.println(&quot;Send '1' to turn LED on&quot;);&#xA;      BT.println(&quot;Send '2' to turn LED on&quot;);&#xA;    }   &#xA;    // you can add more &quot;if&quot; statements with other characters to add more commands&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I search for a connection on my computer, it finds the HC-06 and I can then attempt to establish a connection.  I enter the pairing code of 1234.  It then says that a connection has been established so I go into the Bluetooth Services tab where it tells me what COM port to use (either COM7 or COM4 depending on which computer I try it on.  I've tried this on two separate computers.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I open a PuTTY session and attempt to connect to the indicated COM port.  About 50% of the time, it says that a connection could not be established to the indicated COM port.  The other 50% of the time, I am able to open a PuTTY session but then nothing happens.  The green LED on the HC-06 continues to blink away no matter what I try to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be VERY appreciated as I feel like I've tried everything I can think of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!  &lt;/p&gt;&#xA;" OwnerDisplayName="TheFaceOfBoe" LastEditorUserId="11529" LastEditDate="2017-03-17T20:38:49.123" LastActivityDate="2017-03-17T20:38:49.123" Title="HC-06 Bluetooth Module on Arduino Nano" Tags="|bluetooth|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21000" PostTypeId="2" ParentId="20978" CreationDate="2016-02-23T01:28:46.610" Score="1" Body="&lt;p&gt;I think if you do not publish the source code, the project will be a little bit unconstructive, both for developers and users, especially when it is based in open hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put hex files available to users, but also the source code, allowing the community to participate in the development of your product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, if you use third-party code in your project, such as libraries, remember to respect their licenses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards. Good luck with the project.&lt;/p&gt;&#xA;" OwnerUserId="18617" LastActivityDate="2016-02-23T01:28:46.610" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21003" PostTypeId="2" ParentId="20774" CreationDate="2016-02-23T02:11:11.800" Score="0" Body="&lt;p&gt;&lt;strong&gt;Analog Stability&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Datasheet of ATMEGA328&lt;/a&gt; Page 240:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;When the bandgap reference voltage is used as input to the ADC, it will take a certain time for the voltage to stabilize. If not stabilized, the first value read after the first conversion may be wrong.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you are doing multiple reads, you need to wait a few cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Delays are not required when using auto-triggering:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;When Auto Triggering is used, the prescaler is reset when the trigger event occurs. This assures a fixed delay from the trigger event to the start of conversion. In this mode, the sample-and-hold takes place two ADC clock cycles after the rising edge on the trigger source signal. Three additional CPU clock cycles are used for synchronization logic.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also if reading different channels of the same ADC module, you need to provide a delay between the reads so that the analog MUX is positioned and the S&amp;amp;H capacitor is charged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This information is from hardware perspective and I'm not sure if Arduino internal ADC routines compensate for those delays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Digital Stability&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the digital read tutorial schmatic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GiHD6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GiHD6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the schematic, the push button is not electrically de-bounced. A delay in reading states would help de-bounce it in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Nick Gammon suggested, they also improve serial flooding.&lt;/p&gt;&#xA;" OwnerUserId="9962" LastEditorUserId="9962" LastEditDate="2016-02-23T02:19:38.637" LastActivityDate="2016-02-23T02:19:38.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21006" PostTypeId="2" ParentId="20999" CreationDate="2016-02-23T05:17:35.947" Score="1" Body="&lt;p&gt;I agree with TisteAndii's comment. Your voltage divider is in the wrong place. You are dividing down the 3.3V signal from the HC-06 to be a maximum of 2.269 volts. However the Nano requires at least 3.5V to be considered HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus, you are putting 5V from the Nano into the HC-06 which may damage it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-23T05:17:35.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21008" PostTypeId="2" ParentId="14293" CreationDate="2016-02-23T07:32:20.370" Score="1" Body="&lt;p&gt;I have shorted my bords a few time and they always came back to &quot;life&quot; after a minute. Maybe you should be more concern about the voltage you supply to the board. Even if it can take up to 12 volt I never use more then 9 volt on the board. And if you run motors on them its always good to supply them with an external power source and use something like a H bridge to power your devices. I made mistakes and my board are still in mint conditions.&lt;/p&gt;&#xA;" OwnerUserId="18621" LastActivityDate="2016-02-23T07:32:20.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21010" PostTypeId="1" CreationDate="2016-02-23T09:45:39.887" Score="0" ViewCount="854" Body="&lt;p&gt;I am starting to get into i2C, SPI, and other forms of communication. I have read about them and have a fuzzy idea of how they work electrically, but can someone explain how I would turn the electronic portion into the coding/controlling portion? I really want to get a great understanding of it.&lt;/p&gt;&#xA;" OwnerUserId="5078" LastActivityDate="2016-02-23T21:56:49.483" Title="Can someone explain how to program i2C communications without using the library?" Tags="|arduino-uno|i2c|communication|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21013" PostTypeId="2" ParentId="21010" CreationDate="2016-02-23T10:51:26.160" Score="1" Body="&lt;p&gt;The AVR microcontrollers that Arduino uses have built-in hardware support for the said protocols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that you don't have to write program to control the transmission/reception process but you only need to configure the appropriate registers and the hardware will initiate transfer and inform you when it's done.  I suggest you carefully read the datasheet of the microcontroller you are using with your Arduino and you should find all the information there.  It even has code examples, so you can actually copy-paste functions and use them in your program, here is one of the examples:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SPI_MasterInit(void)&#xA;{&#xA;    /* Set MOSI and SCK output, all others input */&#xA;    DDR_SPI = (1&amp;lt;&amp;lt;DD_MOSI)|(1&amp;lt;&amp;lt;DD_SCK);&#xA;    /* Enable SPI, Master, set clock rate fck/16 */&#xA;    SPCR = (1&amp;lt;&amp;lt;SPE)|(1&amp;lt;&amp;lt;MSTR)|(1&amp;lt;&amp;lt;SPR0);&#xA;}&#xA;&#xA;void SPI_MasterTransmit(char cData)&#xA;{&#xA;    /* Start transmission */&#xA;    SPDR = cData;&#xA;    /* Wait for transmission complete */&#xA;    while(!(SPSR &amp;amp; (1&amp;lt;&amp;lt;SPIF)));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The keywords with the capital letters are usually register and bit names: you can look them up in the datasheet.&lt;/p&gt;&#xA;" OwnerUserId="18609" LastEditorUserId="14955" LastEditDate="2016-02-23T21:56:49.483" LastActivityDate="2016-02-23T21:56:49.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21014" PostTypeId="2" ParentId="21010" CreationDate="2016-02-23T11:39:08.970" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can someone explain how to program i2C communications without using the library?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The AVR has hardware support for this but you can implement it with the pin functions. I2C is a lot about timing the signals and detecting the reply signal from the slave. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware support for I2C requires understanding of a complex state-machine. If you have implemented the I2C protocol it becomes easy to understand the hardware support and how this help remove a lot of work from the processor core. The state machine, control and status registers and interrupts, are described in the AVR product specification. There are also lots of excellent descriptions on the web. Do not miss the AVR application notes for the I2C. Most of the code in the Arduino core originated from them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-23T11:39:08.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21015" PostTypeId="2" ParentId="13715" CreationDate="2016-02-23T12:52:39.893" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to Publish to MQTT with retain option?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The quick answer is add payload length, and retained as true as the last parameters to publish(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int BUF_MAX = 8;&#xA;char buf[BUF_MAX];&#xA;itoa(ledBrightness, buf, 10);&#xA;strcat(buf, &quot;%&quot;);&#xA;int len = strlen(buf) + 1;&#xA;MQTTClient.publish(&quot;/maison/GF/Escalier/stairLight/b&quot;, buf, len, true);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above is a rewrite with the extra parameter for &quot;retained&quot;, payload length, and payload as a null-terminated string. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-23T12:52:39.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21016" PostTypeId="1" AcceptedAnswerId="21018" CreationDate="2016-02-23T13:11:23.003" Score="2" ViewCount="11479" Body="&lt;p&gt;&lt;strong&gt;Desired Behaviour&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to send RGB values from my Arduino Uno PWM pins to an RGB LED strip.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I've Tried&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've purchased this &lt;a href=&quot;http://www.ebay.com.au/itm/331584281701&quot; rel=&quot;nofollow noreferrer&quot;&gt;RGB LED strip&lt;/a&gt; and &lt;a href=&quot;http://www.ebay.com.au/itm/261991816695&quot; rel=&quot;nofollow noreferrer&quot;&gt;12V power supply&lt;/a&gt; (specs below). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to follow &lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips/usage&quot; rel=&quot;nofollow noreferrer&quot;&gt;this adafruit tutorial&lt;/a&gt; but am finding the diagram references unclear.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've mocked up a diagram but am not sure it would work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z8H11.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z8H11.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;( I haven't used the &lt;code&gt;Vin&lt;/code&gt; pin before, so, just to be clear, that is the pin that is connected to the positive line on the breadboard - is that how to transfer the 12V power to the breadboard? )  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;01)&lt;/strong&gt;  Is the above diagram safe and sound? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;02)&lt;/strong&gt;  How do I connect the power supply to the RGB LED strip?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;03)&lt;/strong&gt;  Is it ok to keep the Arduino 'powered' by the USB whilst plugged in to the 12V power (so that it can keep sending the RGB values to the LED strip via the PWM pins)?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;04)&lt;/strong&gt;  I've seen references to &lt;code&gt;grounding&lt;/code&gt; the power source, how do I do that?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;05)&lt;/strong&gt;  Are the MOSFETS I have from the Arduino Uno starter kit sufficient for this task?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Printed Text on MOSFET:  IRF520 Y32K BE  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MOSFET Datasheet:  &lt;a href=&quot;https://www.arduino.cc/documents/datasheets/MosfetTransistor.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Link&lt;/a&gt; (IRF520NPbF)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Specifications&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;RGB LED Strip&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;LED type:  5050 SMD  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Color:  RGB  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;LED quantity:  300LED  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Package:  5 Meter/REEL  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Voltage:: 12V DC  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Working Power:    14.4W  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Working temperature: -20° to 50°  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Size: ⌀180mm  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Length :  5m  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Life Span:    50000+hours  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Weight:   0.3kg&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Power Supply&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Input Voltage: AC 100 - 240V  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Output Voltage : DC 12V, 6A  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Power : 72 Watts  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connector Size:  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;External Diameter: 5.5mm  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Internal Diameter: 2.5mm  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="6445" LastEditorUserId="6445" LastEditDate="2016-02-23T13:38:45.483" LastActivityDate="2016-02-23T13:49:15.520" Title="How to connect a 12V power supply to an RGB LED strip receiving RGB values via Arduino Uno PWM pins?" Tags="|arduino-uno|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21017" PostTypeId="2" ParentId="13165" CreationDate="2016-02-23T13:20:11.667" Score="7" Body="&lt;p&gt;Seems like the Arduino core is missing a function to read the pinMode(). Here is a possible implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pinMode(uint8_t pin)&#xA;{&#xA;  if (pin &amp;gt;= NUM_DIGITAL_PINS) return (-1);&#xA;&#xA;  uint8_t bit = digitalPinToBitMask(pin);&#xA;  uint8_t port = digitalPinToPort(pin);&#xA;  volatile uint8_t *reg = portModeRegister(port);&#xA;  if (*reg &amp;amp; bit) return (OUTPUT);&#xA;&#xA;  volatile uint8_t *out = portOutputRegister(port);&#xA;  return ((*out &amp;amp; bit) ? INPUT_PULLUP : INPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It handles illegal pin numbers (return -1), and all pin modes; OUTPUT, INPUT and INPUT_PULLUP. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BW: I have added this as an &lt;a href=&quot;https://github.com/arduino/Arduino/issues/4606&quot; rel=&quot;noreferrer&quot;&gt;issue&lt;/a&gt; on the Arduino github repository. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-23T13:45:30.393" LastActivityDate="2016-02-23T13:45:30.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21018" PostTypeId="2" ParentId="21016" CreationDate="2016-02-23T13:49:15.520" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;01) Is the above diagram safe and sound?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It looks to be OK, except one thing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current you can draw from the Arduino's VIN pin is limited to about 1A. That is a sixth of what your power supply can provide, and the LED strip when everything is on needs more than that (1.2A), so you could run into problems.  The limit is threefold:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The barrel jack itself is rated at up to 1A&lt;/li&gt;&#xA;&lt;li&gt;There is a protection diode with a limit of 1A&lt;/li&gt;&#xA;&lt;li&gt;The header pins are rated at up to 1A&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And of course the Arduino itself needs to use some of that available 1A.  So you might be better off splicing your LED circuit into the power supply's wire before it enters the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;02) How do I connect the power supply to the RGB LED strip?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Power goes in (+) to the common pin of the LED strip and then out of any of the three colour pins that happen to be connected to the ground of the power supply. That is, the ground of the Arduino in your schematic since they are (as they should be) all shared.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;03) Is it ok to keep the Arduino 'powered' by the USB whilst plugged in to the 12V power (so that it can keep sending the RGB values to the LED strip via the PWM pins)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. There is circuitry on the Arduino that allows both the USB and barrel jack to be plugged in together.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;04) I've seen references to grounding the power source, how do I do that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That refers to connecting the external power supply's ground and the Arduino's ground together. By using the barrel jack that is all taken care of for you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;05) Are the MOSFETS I have from the Arduino Uno starter kit sufficient for this task?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not really.  They are designed to be switched with a higher voltage than the Arduino's IO pins provide.  While they will work, they may cause the LEDs to be dimmer than they should be, or the MOSFETs might get hot.  Basically a MOSFET has a &quot;threshold&quot; voltage range which is the voltage range at which the MOSFET transitions from off to on. That is 2V - 4V for that MOSFET, which while within the range of an IO pin isn't really that great. At 4V the MOSFET still isn't completely on. You may notice from the datasheet that the &quot;R_DS(ON)&quot; value - that is the resistance of the MOSFET when it is on, is measured with the gate voltage at 10V. That is a voltage where the MOSFET is guaranteed to be fully on. Anything less than that and the resistance will be higher causing more losses across the MOSFET.  I could see that instantly from the model number - it starts with &quot;IRF&quot;.  There is a specific range from International Rectifier which is designed to be directly driven by an IO pin - these are the &quot;IRL&quot; (for &lt;em&gt;International Rectifier Logic-level&lt;/em&gt;) series.  These have their R_DS(ON) values measured typically at a gate voltage of 4.5V and a threshold voltage in the region of 500mV to 1.5V. When directly driving from an Arduino these IRL (or equivalent from other manufacturers) are preferred.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-23T13:49:15.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21019" PostTypeId="2" ParentId="6586" CreationDate="2016-02-23T14:36:47.020" Score="1" Body="&lt;p&gt;I was able to achieve the result using my suggested method in the question. &#xA;As BrettAM stated, the signals are wasted on the other 3 pins when checking 1.&#xA;This solution was suitable as a proof of concept&lt;/p&gt;&#xA;" OwnerUserId="6318" LastActivityDate="2016-02-23T14:36:47.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21020" PostTypeId="2" ParentId="14266" CreationDate="2016-02-23T15:32:55.553" Score="1" Body="&lt;p&gt;As far as I understand you are using eclipse CDT directly. (I mean you are not using an &quot;arduino eclipse plugin&quot; that does the stuff below for you)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing to understand is that a arduino library is not treated as a library when compiling a arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words in the Arduino IDE, a arduino library is compiled like standard source code just like your .ino files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such there is no SPI.a file created during the compilation process.&#xA;In CDT you can have both options (with or  without .a file) but the Arduino IDE way is the easiest, by far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So lets first assume you want to compile the &quot;Arduino way&quot; aka without SPI.a.&#xA;What you need to do is simply drag and drop the files in your project. If you want to drop in a subfolder (like libraries/SPI) you will need to add those folders to your include path.&#xA;That is all there is to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to treat the library as a real library (saying you want a SPI.a) the best thing I can think of is to create a new library project for each sketch-project . Drag and drop the SPI code in that project (like above) and make your project dependent on the library project. There are probably some include path issues but the .a file should be found and included in the build&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the second approach makes that you will need a SPI project for each and every (arduino) board you have. If you want to use project defines it is even more difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would strongly advise to start your arduino eclipse development with &lt;a href=&quot;http://eclipse.baeyens.it&quot; rel=&quot;nofollow&quot;&gt;my arduino eclipse plugin&lt;/a&gt; because it is simply easier. Later you can evolve to the full freedom of CDT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to drag and drop folders instead of the .h and .cpp files you will have to add exclusion rules to your include path. This because otherwise all the examples of the library will be in your project making you have multiple setup and loop functions.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-23T15:32:55.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21022" PostTypeId="2" ParentId="17994" CreationDate="2016-02-23T16:19:46.707" Score="2" Body="&lt;p&gt;Your requirements for not having &lt;code&gt;.ino&lt;/code&gt; files and wanting to be able to work with the Arduino IDE are conflicting. Assume we drop that requirement it is very much possible to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Eclipse plugin has been supporting &lt;code&gt;.ino&lt;/code&gt; files for a long time now. You can simply compile Arduino IDE-made sketches. You do not have to make links and so make the folder where your Arduino IDE makes its sketches the workspace in Eclipse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Eclipse, for each sketch you want to edit, start the new sketch wizard and use a project name that is the same as the sketch name in the Arduino IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can work in the Arduino Eclipse plugin and the Arduino IDE on the same files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; In Windows, if you use a version of the plugin from before March 3, 2016, you need to delete the &lt;code&gt;.ino.cpp&lt;/code&gt; file before starting the Arduino IDE. In Linux, the Arduino IDE ignores this file, but in 1.6.7 on Windows (just tested it) the file gets picked up by the Arduino IDE. You need to restart the Arduino IDE to tell it the file is gone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From March 3, 2016 onwards, the code in the &lt;code&gt;.ino.cpp&lt;/code&gt; file is inside a &lt;code&gt;#ifdef&lt;/code&gt; that is not defined in Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="4628" LastEditDate="2016-03-12T16:02:55.500" LastActivityDate="2016-03-12T16:02:55.500" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="21024" PostTypeId="2" ParentId="17653" CreationDate="2016-02-23T16:31:33.673" Score="0" Body="&lt;p&gt;You are using the wrong upload tool.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The due is not using avr dude as upload tool.&#xA;You need to use bossac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you turn on verbose upload in the arduino ide preferences you will see&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...arduino\tools\bossac\1.6.1-arduino/bossac.exe ... &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-23T16:31:33.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21025" PostTypeId="2" ParentId="14345" CreationDate="2016-02-23T16:34:34.407" Score="1" Body="&lt;p&gt;With arduino eclipse plugin 2.4 you simply install the boards with the arduino ide -like you described- and you can use then in the arduino eclipse plugin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Version 3.0 (that is the nightly as 3.0 still needs to be released) contains it's own boards and library manager in windows-&gt;preferences-&gt;arduino.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-23T16:34:34.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21026" PostTypeId="1" CreationDate="2016-02-23T18:46:12.787" Score="2" ViewCount="1534" Body="&lt;p&gt;Nick Gammon's cheatsheet for the Ardunino UNO's ATmega328P (below) shows some hints on the Clear Timer on Compare (CTC) modes of AVR chips.  Most of the examples for CTC mode I find use the COMxxx registers of 01 = toggle to control the OCxx pin, which would give a 50% duty cycle at 1/2 the frequency of the timer clearing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is about using the non-toggling COMxxx modes of Clear and Set, which don't seem to provide an automatic way to reset into the opposite state, as in the PWM modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;   // Timer 1 CTC mode Clearing OC1B at 0.25Hz using OCR1A to set frequency&#xA;   // Output on OC1B  &#xA;   // Clear at OCR1B&#xA;   // WGM =15 0b0100 &#xA;&#xA;   DDRB |= bit(DDB5)| bit(DDB6);  // Teensy2.0 atmega32u OC1A and OC1B outputs&#xA;  // DDRB |= bit(DDB1)| bit(DDB2);  // atmega168/UNO OC1A and OC1B (Tested by OP/Luis)&#xA;   TCCR1A =  bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM12)  | bit(CS12);  // Set /1 prescaler&#xA;   TCCR1C = 0;  // Note that it is good to initialize the timer&#xA;                // into a known mode before trying to set interesting TOPs &#xA;   OCR1A  = 62500U ;    // Set TOP count to 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = OCR1A/2;    //  ~50% duty cycle&#xA;   TCCR1A =  bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM12)  | bit(CS12) | bit(CS10);  // Set /1024 prescaler&#xA;   TCNT1 = 0 ;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  //OCR1B = 62500U/4-1; // 25% duty cycle. &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I try the above code, I get a 0.125Hz ( 8s period signal) on PB5 and a constant low on PB6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the way to set OC1B high to be cleared by the timer match?  And similarly, vice versa: clearing OC1B to be set by the timer match?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a direct way or do you fiddle with COM1Bx, trigger FOC1B, and then fiddle COM1B back?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7l2L1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7l2L1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code uses the TCCR1C:FOC1B register to set the bit by messing with the TCCR1A:COM1Bx bits, but it seems awkward:  &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;   // Timer 1 CTC mode Clearing OC1B at 0.25Hz using OCR1A to set frequency&#xA;   // Output on OC1B  &#xA;   // Clear at OCR1B&#xA;   // WGM =15 0b0100 &#xA;&#xA;   DDRB |= bit(DDB5)| bit(DDB6);  // Teensy2.0 atmega32u OC1A and OC1B outputs&#xA;  // DDRB |= bit(DDB1)| bit(DDB2);  // atmega168/UNO OC1A and OC1B (Tested by OP/Luis)&#xA;   TCCR1A =  bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM12)  | bit(CS12);  // Set /1 prescaler&#xA;   TCCR1C = 0;  // Note that it is good to initialize the timer&#xA;                // into a known mode before trying to set interesting TOPs &#xA;   OCR1A  = 62500U ;    // Set TOP count to 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = OCR1A/2;    //  ~50% duty cycle&#xA;   TCCR1A =  bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM12)  | bit(CS12) | bit(CS10);  // Set /1024 prescaler&#xA;   TCNT1 = 0 ;&#xA;}&#xA;&#xA;void loop() {&#xA;  int saveCOM;&#xA;  Serial.println(TCCR1A,BIN);&#xA;  delay(7000); // 7 seconds&#xA;  saveCOM = TCCR1A; &#xA;  TCCR1A |= bit(COM1B1) | bit(COM1B0) ; // config for set OC1B&#xA;  TCCR1C = bit(FOC1B); // force a compare to set bit&#xA;  TCCR1A = saveCOM ; // restore mode&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code has the 0.125Hz on OC1A, and a semi-random series of 1-4 second long pulses on OC1B.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was interested in playing with the CTC modes for doing long cycle/low frequency PWM.  With the normal PWMs you could range from a 1-bit 50% PWM at 8MHz to a 16 bit PWM at a frequency of 0.119Hz (8.388s)  With the CTC modes, if you could manage the sets and clears in an TIMERx_OVF_vect with a couple 16 bit registers, you could extend it to 32 bits of PWM resolution with a period up to 152 hours.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="37523" LastEditDate="2019-05-14T06:40:21.797" LastActivityDate="2019-05-14T06:40:21.797" Title="Timer CTC Set and Clear modes -- How to un-Clear and un-Set?" Tags="|pwm|timers|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="21027" PostTypeId="2" ParentId="21010" CreationDate="2016-02-23T19:03:40.907" Score="0" Body="&lt;p&gt;A good way to learn how to code for these interfaces is to look at the source code for the libraries themselves. In the PC world, these will be in the directory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program files (x86)\Arduino\hardware\arduino\avr\libraries&lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-23T19:03:40.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21030" PostTypeId="2" ParentId="10211" CreationDate="2016-02-23T21:48:07.093" Score="1" Body="&lt;p&gt;Old post, but here was my solution. Had to pickup some shielded cable. Pics below should clearly explain how everything was wired up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QvScY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QvScY.jpg&quot; alt=&quot;Wiring into Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BqEx9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BqEx9.jpg&quot; alt=&quot;Wiring into reciever&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8585" LastActivityDate="2016-02-23T21:48:07.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21031" PostTypeId="2" ParentId="8026" CreationDate="2016-02-23T22:39:25.337" Score="0" Body="&lt;p&gt;Sorry .. my answer comes late ..&#xA;I had the same issue, this has nothing to do with bad connexion between wires (not only at least).&#xA;But by playing with some parameter (current value &amp;gt; 60mA) I noticed that the module begin to freeze more often.&#xA;To fix that :&#xA;You need to add a small delay within your readbyte function after a i2c.stop()&lt;/p&gt;&#xA;&lt;p&gt;I found that an issue had been written about that : &lt;a href=&quot;https://github.com/adafruit/VCNL4000/issues/1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/VCNL4000/issues/1&lt;/a&gt;&#xA;They recommand a 170us delay&lt;/p&gt;&#xA;&lt;p&gt;I'm testing myself at full current and max speed (an since 30min it didn't freeze)... Before it could freeze in a second.&lt;/p&gt;&#xA;&lt;p&gt;Hope it helps ;)&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;EDIT :&#xA;In order to better understand where the freeze comes from, I re-write a simple I2C library. I could get rid of the freeze by simple add a small delay in the i2c_start function (that send the start condition along with the slave address)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t i2c_start(uint8_t i2c_slave_address){&#xA;       //reset TWI control register&#xA;       TWCR = 0;&#xA;       //transmit start condition &#xA;       TWCR = (1&amp;lt;&amp;lt;TWINT) | (1&amp;lt;&amp;lt;TWSTA) | (1&amp;lt;&amp;lt;TWEN);&#xA;       //wait for end of transmission&#xA;       while((TWCR &amp;amp; (1&amp;lt;&amp;lt;TWINT))==0){&#xA;              _delay_us(75); // &amp;lt;-- here is the trick&#xA;       }&#xA;       if( (TWSR &amp;amp; 0xF8)!= TW_START ){&#xA;              return -1;&#xA;       }&#xA;       // load slave address into data register&#xA;       TWDR = i2c_slave_address;&#xA;       //start address transmission&#xA;       TWCR = (1&amp;lt;&amp;lt;TWINT) | (1&amp;lt;&amp;lt;TWEN);&#xA;       //wait for transmission&#xA;       while ( (TWCR &amp;amp; (1&amp;lt;&amp;lt;TWINT))==0 );&#xA;       //check if the slave did acknoledge the Read/Write mode&#xA;       uint8_t twst = TW_STATUS &amp;amp; 0xF8;&#xA;       if ( (twst != TW_MT_SLA_ACK) &amp;amp;&amp;amp; (twst != TW_MR_SLA_ACK) ){&#xA;               return -1;&#xA;       }&#xA;       return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;you will need to add these libraries :&#xA;util/twi.h (for the macro TW_STATUS .. TTW_MT_SLA_ACK and so on)&lt;/p&gt;&#xA;&lt;p&gt;util/delay.h&lt;/p&gt;&#xA;&lt;p&gt;stdlib.h (for the uint8_t way of typing variable ..not actually 100% sure)&lt;/p&gt;&#xA;&lt;p&gt;I'm still not fully satisfy by this solution, but it is still more effective that the one that adafruit propose.&lt;/p&gt;&#xA;&lt;p&gt;I suggest you write you own i2c library (5 functions : init / start / read / write / stop) you now have the start already .. so 4 left ;)&lt;/p&gt;&#xA;&lt;p&gt;If you're still to much afraid : in twi.c ( .\arduino\avr\libraries\Wire\utility\twi.c) and twi_readFrom(...) function.&#xA;On line 155 and 159 you will see that arduino send the start condition, but do not wait / take care that the transmission as been done... you can add a while function as previously describe to ensure it.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;MASTER EDIT :&lt;/p&gt;&#xA;&lt;p&gt;My previous solution didn't solve the issue neither...&#xA;Actually reading the application note (Designing VCNL4000 into an Application : google that)&#xA;gives the solution (page 7) &lt;a href=&quot;https://i.stack.imgur.com/4vcQ0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4vcQ0.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;after you send the command to perform a single measurement, you need to wait.&#xA;I put a delay of 500ms and have none anywhere else. This works like a charm.&lt;/p&gt;&#xA;&lt;p&gt;But for energy efficiency I recommend to put the uC in sleep mode for that period of time.&lt;/p&gt;&#xA;" OwnerUserId="12035" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-02-25T13:42:22.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21032" PostTypeId="1" AcceptedAnswerId="21043" CreationDate="2016-02-24T00:30:34.810" Score="9" ViewCount="5427" Body="&lt;p&gt;I'm looking for a simple way to send a signal from my arduino to a vga monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the easiest method, and what components would be needed? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't need to display an image, just a solid colour. &lt;/p&gt;&#xA;" OwnerUserId="17175" LastActivityDate="2016-02-25T06:34:44.020" Title="Sending colours to vga monitor" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21033" PostTypeId="2" ParentId="21032" CreationDate="2016-02-24T01:08:08.243" Score="4" Body="&lt;p&gt;A quick Google search for &quot;Arduino VGA&quot; will give you a lot of information. There are a few variations on both circuits and programming, which also vary in resolution and color depth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was searching for this a few days ago, and these are my favorite (so far):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://labdegaragem.com/profiles/blogs/gerando-sinal-vga-colorido-com-arduino-completo&quot; rel=&quot;nofollow&quot;&gt;http://labdegaragem.com/profiles/blogs/gerando-sinal-vga-colorido-com-arduino-completo&lt;/a&gt; (it is in portuguese, but you can get a pretty good idea of what to do)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=320238.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=320238.0&lt;/a&gt; (read the whole discussion, pretty nice results)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If using a TV is also a plausible option, check the Arduino TV out library. It can be installed directly from the Arduino IDE and has a good demo.&lt;/p&gt;&#xA;" OwnerUserId="18565" LastActivityDate="2016-02-24T01:08:08.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21034" PostTypeId="1" AcceptedAnswerId="21041" CreationDate="2016-02-24T02:27:11.570" Score="4" ViewCount="2430" Body="&lt;p&gt;I'have been looking at the &lt;a href=&quot;https://learn.adafruit.com/search?q=neopixels&quot; rel=&quot;nofollow&quot;&gt;AdaFruit NeoPixels&lt;/a&gt; recently and am trying to understand how the addressing scheme works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the examples I've seen explicitly identify the length of the string (number of neopixel units) and are typically set using an array of 24-bit values to control the color of a particular neopixel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is two fold:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How do the neopixels know where they are in a string to allow for addressing?&lt;/li&gt;&#xA;&lt;li&gt;If the neopixels know where they are in the string, would it not be possible to potentially feed the output of the last neoxpixel back to a microcontroller to determine the number of neopixels in the string?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OP Note&lt;/strong&gt; (this is my interpretation and may be suspect, but it is more or less my take away)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for all the answers on this - it has been very enlightening from ALL of the answers. General take away, the NeoPixel is not &quot;directly&quot; addressable in the sense that you can pick pixel &quot;X&quot; of &quot;n&quot; pixels. The string of NeoPixels acts essentially as a gigantic shift-register (as stated in one of the answers) so to &quot;address&quot; a particular pixel you have to update a buffer that represents the state of the entire string and then shift it down the wire. This is why micro-controllers, such as an Arduino, would have limitations on how many NeoPixels it could control. This is also why it is more practical to define the number of pixels in the string and allocate memory to represent that state.&lt;/p&gt;&#xA;" OwnerUserId="1604" LastEditorUserId="1604" LastEditDate="2016-02-26T13:03:29.013" LastActivityDate="2016-03-11T01:09:13.407" Title="Is it possible to infer the length of a neopixel string using 1-wire protocol?" Tags="|neopixel|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21035" PostTypeId="2" ParentId="14293" CreationDate="2016-02-24T02:44:37.357" Score="0" Body="&lt;p&gt;I just checked the link and the item is not available anymore. That way it is impossible to say which driver you should install.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree with the answers and comments so far, get the real board. I've heard of people who fried their USB ports because of Arduino clones and their terrible/absent circuit protection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't afford the original board, what will you do if it damages your computer?&lt;/p&gt;&#xA;" OwnerUserId="18565" LastActivityDate="2016-02-24T02:44:37.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21036" PostTypeId="2" ParentId="20889" CreationDate="2016-02-24T03:23:11.797" Score="2" Body="&lt;p&gt;As far as I know, the 3.3v on the Arduino board might not have enough current for the ESP module, as it is very 'power hungry'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had some hard time making my modules work properly, and your problem could be a number of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will stick to Ockam's razor principle and go by the simple side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code you are using 9600 baud,but the ESP8266 'base' speed is 115200. Try that speed (and CR+LF) also on your Usb cable and it might work.&lt;/p&gt;&#xA;" OwnerUserId="18565" LastActivityDate="2016-02-24T03:23:11.797" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21037" PostTypeId="2" ParentId="21034" CreationDate="2016-02-24T04:20:27.647" Score="2" Body="&lt;p&gt;As far as I can make out (eg. &lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot; rel=&quot;nofollow&quot;&gt;NeoPixels Revealed: How to (not need to) generate precisely timed signals&lt;/a&gt;) the NeoPixels are not in fact addressed, but are like a long shift register. Thus if you have 10 pixels, you have to send out 10 lots of RGB colours and then latch them. This is why you need to know how many pixels you have, so that you send out the right number of RGB bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think it would be particularly practical to try to detect how many pixels are in the chain, because the individual ones &quot;reshape&quot; the timing pulses.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-24T04:20:27.647" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21038" PostTypeId="2" ParentId="21034" CreationDate="2016-02-24T04:44:30.603" Score="4" Body="&lt;p&gt;Each pixel &quot;peels off&quot; the first data word before passing on the rest, so the payload gets shorter and shorter as you move down the chain.  Although the data wire may look continuous it isn't - the signal is electrically re-driven from each unit to the next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the RGB ones, they are logically three monochrome pixels of different colors, so they peel off three words rather than just one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At any point in the chain you can determine how many logical pixels potentially remain to be updated, by counting the words you are passing on.  You can't of course tell if they are actually there, or if there are further pixels for which no data is being provided.  And you can't tell how many pixels preceded, other than to bound it by the amount of gap time from the previous update you received.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-02-24T04:44:30.603" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21039" PostTypeId="2" ParentId="21032" CreationDate="2016-02-24T04:53:25.167" Score="3" Body="&lt;p&gt;Not needing to display an actual image simplifies things substantially, as an Arduino lacks the memory and (except in a crude sense) the bandwidth to do so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you cannot simply apply a steady analog voltage to the R, G, and B lines.  Not only do you have to drive horizontal and vertical sync signals, you have to blank the RGB signals when not on the active portion of the screen, otherwise the monitor will assume their steady voltage means &quot;black&quot; and your colors will last only as a brief flash when your device is first connected or enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generating a large rectangular field of color from an Arduino is likely to be rather challenging, but probably not impossible.  You may be able to use hardware PWM channels for the horizontal and a &quot;color enable&quot;, and tightly coded software counters for the vertical aspect.  You can then use the &quot;color enable&quot; to gate a network of potentially variable resistors to establish the single color of particular interest.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-02-25T06:34:44.020" LastActivityDate="2016-02-25T06:34:44.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21040" PostTypeId="2" ParentId="14572" CreationDate="2016-02-24T05:07:56.433" Score="0" Body="&lt;p&gt;In addition to my previous comment-suggestion that you could implement communication over SPI by adding functionality to both the ISP sketch and the target program, it now occurs to me that another approach would be to implement software serial functionality on both, assigned to some of the pins used for ISP during that process.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-02-24T05:07:56.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21041" PostTypeId="2" ParentId="21034" CreationDate="2016-02-24T06:25:38.720" Score="3" Body="&lt;p&gt;As noted in Chris Stratton's answer, “Each pixel &quot;peels off&quot; the first data word before passing on the rest, so the payload gets shorter and shorter as you move down the chain”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This behavior is spelled out clearly in WS2812.pdf and WS2812B.pdf datasheets from &lt;a href=&quot;http://www.world-semi.com&quot; rel=&quot;nofollow&quot;&gt;http://www.world-semi.com&lt;/a&gt; : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The data transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller, the first pixel collect initial 24bit data then sent to the internal data latch, the other data which reshaping by the internal signal reshaping amplification circuit sent to the next cascade pixel through the DO port. After transmission for each pixel, the signal to reduce 24bit. pixel adopt auto resha-ping transmit technology, making the pixel cascade number is not limited the signal transmission, only depend  on the speed of signal transmission.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means that each WS2812 unit in a chain picks off the first 24-bit data packet, latches that data into an internal register, and passes the rest of the data on out, through reshaping circuitry.  Hence, if you put &lt;em&gt;m&lt;/em&gt; packets of data into a chain and &lt;em&gt;k&lt;/em&gt; packets come out, the chain length is &lt;em&gt;m-k&lt;/em&gt; or more.  (The chain length may be more than &lt;em&gt;m-k&lt;/em&gt; when &lt;em&gt;k&lt;/em&gt; is zero.)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-02-24T06:25:38.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21043" PostTypeId="2" ParentId="21032" CreationDate="2016-02-24T07:21:29.740" Score="7" Body="&lt;p&gt;My page about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11608&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno output to VGA monitor&lt;/a&gt; has a lot of theory on it, including a sketch that produces colour bars like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EBkxW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EBkxW.jpg&quot; alt=&quot;Colour bars&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;To produce a single colour is slightly simpler, this sketch did it for me:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; VGA colour video generation&#xA;&#xA; Author:   Nick Gammon&#xA; Date:     22nd April 2012&#xA; Version:  1.0&#xA;&#xA; Connections:&#xA;&#xA; D3 : Horizontal Sync (68 ohms in series) --&amp;gt; Pin 13 on DB15 socket&#xA; D4 : Red pixel output (470 ohms in series) --&amp;gt; Pin 1 on DB15 socket&#xA; D5 : Green pixel output (470 ohms in series) --&amp;gt; Pin 2 on DB15 socket&#xA; D6 : Blue pixel output (470 ohms in series) --&amp;gt; Pin 3 on DB15 socket&#xA; D10 : Vertical Sync (68 ohms in series) --&amp;gt; Pin 14 on DB15 socket&#xA;&#xA; Gnd : --&amp;gt; Pins 5, 6, 7, 8, 10 on DB15 socket&#xA;&#xA;*/&#xA;&#xA;#include &amp;lt;TimerHelpers.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const byte hSyncPin = 3;     // &amp;lt;------- HSYNC&#xA;&#xA;const byte redPin = 4;       // &amp;lt;------- Red pixel data&#xA;const byte greenPin = 5;     // &amp;lt;------- Green pixel data&#xA;const byte bluePin = 6;      // &amp;lt;------- Blue pixel data&#xA;&#xA;const byte vSyncPin = 10;    // &amp;lt;------- VSYNC&#xA;&#xA;const int horizontalBytes = 60;  // 480 pixels wide&#xA;const int verticalPixels = 480;  // 480 pixels high&#xA;&#xA;// Timer 1 - Vertical sync&#xA;&#xA;// output    OC1B   pin 16  (D10) &amp;lt;------- VSYNC&#xA;&#xA;//   Period: 16.64 ms (60 Hz)&#xA;//      1/60 * 1e6 = 16666.66 µs&#xA;//   Pulse for 64 µs  (2 x HSync width of 32 µs)&#xA;//    Sync pulse: 2 lines&#xA;//    Back porch: 33 lines&#xA;//    Active video: 480 lines&#xA;//    Front porch: 10 lines&#xA;//       Total: 525 lines&#xA;&#xA;// Timer 2 - Horizontal sync&#xA;&#xA;// output    OC2B   pin 5  (D3)   &amp;lt;------- HSYNC&#xA;&#xA;//   Period: 32 µs (31.25 kHz)&#xA;//      (1/60) / 525 * 1e6 = 31.74 µs&#xA;//   Pulse for 4 µs (96 times 39.68 ns)&#xA;//    Sync pulse: 96 pixels&#xA;//    Back porch: 48 pixels&#xA;//    Active video: 640 pixels&#xA;//    Front porch: 16 pixels&#xA;//       Total: 800 pixels&#xA;&#xA;// Pixel time =  ((1/60) / 525 * 1e9) / 800 = 39.68  ns&#xA;//  frequency =  1 / (((1/60) / 525 * 1e6) / 800) = 25.2 MHz&#xA;&#xA;// However in practice, it we can only pump out pixels at 375 ns each because it&#xA;//  takes 6 clock cycles to read one in from RAM and send it out the port.&#xA;&#xA;&#xA;const byte verticalBackPorchLines = 35;  // includes sync pulse?&#xA;const int verticalFrontPorchLines = 525 - verticalBackPorchLines;&#xA;&#xA;volatile int vLine;&#xA;volatile byte backPorchLinesToGo;&#xA;&#xA;#define nop asm volatile (&quot;nop\n\t&quot;)&#xA;&#xA;// ISR: Vsync pulse&#xA;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  vLine = 0; &#xA;  backPorchLinesToGo = verticalBackPorchLines;&#xA;  } // end of TIMER1_OVF_vect&#xA;&#xA;// ISR: Hsync pulse ... this interrupt merely wakes us up&#xA;EMPTY_INTERRUPT  (TIMER2_OVF_vect)&#xA;&#xA;void setup()&#xA;  {&#xA;&#xA;  // disable Timer 0&#xA;  TIMSK0 = 0;  // no interrupts on Timer 0&#xA;  OCR0A = 0;   // and turn it off&#xA;  OCR0B = 0;&#xA;&#xA;  // Timer 1 - vertical sync pulses&#xA;  pinMode (vSyncPin, OUTPUT); &#xA;  Timer1::setMode (15, Timer1::PRESCALE_1024, Timer1::CLEAR_B_ON_COMPARE);&#xA;  OCR1A = 259;  // 16666 / 64 µs = 260 (less one)&#xA;  OCR1B = 0;    // 64 / 64 µs = 1 (less one)&#xA;  TIFR1 = bit (TOV1);   // clear overflow flag&#xA;  TIMSK1 = bit (TOIE1);  // interrupt on overflow on timer 1&#xA;&#xA;  // Timer 2 - horizontal sync pulses&#xA;  pinMode (hSyncPin, OUTPUT); &#xA;  Timer2::setMode (7, Timer2::PRESCALE_8, Timer2::CLEAR_B_ON_COMPARE);&#xA;  OCR2A = 63;   // 32 / 0.5 µs = 64 (less one)&#xA;  OCR2B = 7;    // 4 / 0.5 µs = 8 (less one)&#xA;  TIFR2 = bit (TOV2);   // clear overflow flag&#xA;  TIMSK2 = bit (TOIE2);  // interrupt on overflow on timer 2&#xA;&#xA;  // prepare to sleep between horizontal sync pulses  &#xA;  set_sleep_mode (SLEEP_MODE_IDLE);  &#xA;&#xA;  // pins for outputting the colour information&#xA;  pinMode (redPin, OUTPUT);&#xA;  pinMode (greenPin, OUTPUT);&#xA;  pinMode (bluePin, OUTPUT);&#xA;&#xA;}  // end of setup&#xA;&#xA;// draw a single scan line&#xA;void doOneScanLine ()&#xA;  {&#xA;&#xA;  // after vsync we do the back porch&#xA;  if (backPorchLinesToGo)&#xA;    {&#xA;    backPorchLinesToGo--;&#xA;    return;   &#xA;    }  // end still doing back porch&#xA;&#xA;  // if all lines done, do the front porch&#xA;  if (vLine &amp;gt;= verticalPixels)&#xA;    return;&#xA;&#xA;  PORTD = bit (5) | bit (6);  // cyan (green + blue)&#xA;  delayMicroseconds (27);     // one scan line&#xA;&#xA;  PORTD = 0;  // back to black&#xA;  // finished this line &#xA;  vLine++;&#xA;&#xA;  }  // end of doOneScanLine&#xA;&#xA;void loop() &#xA;  {&#xA;  // sleep to ensure we start up in a predictable way&#xA;  sleep_mode ();&#xA;  doOneScanLine ();&#xA; }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As @ChrisStratton suggested, the hardware timers are a big help.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Wiring&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I wired it up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KpXrW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KpXrW.png&quot; alt=&quot;VGA wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zvu7k.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zvu7k.jpg&quot; alt=&quot;VGA pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;TimerHelpers library&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;TimerHelpers.h&lt;/strong&gt; library is described on my &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;timers&lt;/a&gt; page, a copy is below:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; Timer Helpers library.&#xA;&#xA;Devised and written by Nick Gammon.&#xA;Date: 21 March 2012&#xA;Version: 1.0&#xA;&#xA;Licence: Released for public use.&#xA;&#xA;See: http://www.gammon.com.au/forum/?id=11504&#xA;&#xA; Example:&#xA;&#xA; // set up Timer 1&#xA; TCNT1 = 0;         // reset counter&#xA; OCR1A =  999;       // compare A register value (1000 * clock speed)&#xA;&#xA; // Mode 4: CTC, top = OCR1A&#xA; Timer1::setMode (4, Timer1::PRESCALE_1, Timer1::CLEAR_A_ON_COMPARE);&#xA;&#xA; TIFR1 |= bit (OCF1A);    // clear interrupt flag&#xA; TIMSK1 = bit (OCIE1A);   // interrupt on Compare A Match  &#xA;&#xA;*/&#xA;&#xA;#ifndef _TimerHelpers_h&#xA;#define _TimerHelpers_h&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;/* ---------------------------------------------------------------&#xA; Timer 0 setup&#xA; --------------------------------------------------------------- */&#xA;&#xA;namespace Timer0 &#xA;{&#xA;  // TCCR0A, TCCR0B&#xA;  const byte Modes [8] [2] = &#xA;  {&#xA;&#xA;  { 0,                         0 },            // 0: Normal, top = 0xFF&#xA;  { bit (WGM00),               0 },            // 1: PWM, Phase-correct, top = 0xFF&#xA;  {               bit (WGM01), 0 },            // 2: CTC, top = OCR0A&#xA;  { bit (WGM00) | bit (WGM01), 0 },            // 3: Fast PWM, top = 0xFF&#xA;  { 0,                         bit (WGM02) },  // 4: Reserved&#xA;  { bit (WGM00),               bit (WGM02) },  // 5: PWM, Phase-correct, top = OCR0A&#xA;  {               bit (WGM01), bit (WGM02) },  // 6: Reserved&#xA;  { bit (WGM00) | bit (WGM01), bit (WGM02) },  // 7: Fast PWM, top = OCR0A&#xA;&#xA;  };  // end of Timer0::Modes&#xA;&#xA;  // Activation&#xA;  // Note: T0 is pin 6, Arduino port: D4&#xA;  enum { NO_CLOCK, PRESCALE_1, PRESCALE_8, PRESCALE_64, PRESCALE_256, PRESCALE_1024, T0_FALLING, T0_RISING };&#xA;&#xA;  // what ports to toggle on timer fire&#xA;  enum { NO_PORT = 0, &#xA;&#xA;    // pin 12, Arduino port: D6&#xA;    TOGGLE_A_ON_COMPARE  = bit (COM0A0), &#xA;    CLEAR_A_ON_COMPARE   = bit (COM0A1), &#xA;    SET_A_ON_COMPARE     = bit (COM0A0) | bit (COM0A1),&#xA;&#xA;    // pin 11, Arduino port: D5&#xA;    TOGGLE_B_ON_COMPARE  = bit (COM0B0), &#xA;    CLEAR_B_ON_COMPARE   = bit (COM0B1), &#xA;    SET_B_ON_COMPARE     = bit (COM0B0) | bit (COM0B1),&#xA;  };&#xA;&#xA;&#xA;  // choose a timer mode, set which clock speed, and which port to toggle&#xA;  void setMode (const byte mode, const byte clock, const byte port)&#xA;  {&#xA;  if (mode &amp;lt; 0 || mode &amp;gt; 7)  // sanity check&#xA;    return;&#xA;&#xA;  // reset existing flags&#xA;  TCCR0A = 0;&#xA;  TCCR0B = 0;&#xA;&#xA;  TCCR0A |= (Modes [mode] [0]) | port;  &#xA;  TCCR0B |= (Modes [mode] [1]) | clock;&#xA;  }  // end of Timer0::setMode&#xA;&#xA;}  // end of namespace Timer0 &#xA;&#xA;/* ---------------------------------------------------------------&#xA; Timer 1 setup&#xA; --------------------------------------------------------------- */&#xA;&#xA;namespace Timer1 &#xA;{&#xA;  // TCCR1A, TCCR1B&#xA;  const byte Modes [16] [2] = &#xA;  {&#xA;&#xA;  { 0,                         0 },            // 0: Normal, top = 0xFFFF&#xA;  { bit (WGM10),               0 },            // 1: PWM, Phase-correct, 8 bit, top = 0xFF&#xA;  {               bit (WGM11), 0 },            // 2: PWM, Phase-correct, 9 bit, top = 0x1FF&#xA;  { bit (WGM10) | bit (WGM11), 0 },            // 3: PWM, Phase-correct, 10 bit, top = 0x3FF&#xA;  { 0,                         bit (WGM12) },  // 4: CTC, top = OCR1A&#xA;  { bit (WGM10),               bit (WGM12) },  // 5: Fast PWM, 8 bit, top = 0xFF&#xA;  {               bit (WGM11), bit (WGM12) },  // 6: Fast PWM, 9 bit, top = 0x1FF&#xA;  { bit (WGM10) | bit (WGM11), bit (WGM12) },  // 7: Fast PWM, 10 bit, top = 0x3FF&#xA;  { 0,                                       bit (WGM13) },  // 8: PWM, phase and frequency correct, top = ICR1    &#xA;  { bit (WGM10),                             bit (WGM13) },  // 9: PWM, phase and frequency correct, top = OCR1A    &#xA;  {               bit (WGM11),               bit (WGM13) },  // 10: PWM, phase correct, top = ICR1A    &#xA;  { bit (WGM10) | bit (WGM11),               bit (WGM13) },  // 11: PWM, phase correct, top = OCR1A&#xA;  { 0,                         bit (WGM12) | bit (WGM13) },  // 12: CTC, top = ICR1    &#xA;  { bit (WGM10),               bit (WGM12) | bit (WGM13) },  // 13: reserved&#xA;  {               bit (WGM11), bit (WGM12) | bit (WGM13) },  // 14: Fast PWM, TOP = ICR1&#xA;  { bit (WGM10) | bit (WGM11), bit (WGM12) | bit (WGM13) },  // 15: Fast PWM, TOP = OCR1A&#xA;&#xA;  };  // end of Timer1::Modes&#xA;&#xA;  // Activation&#xA;  // Note: T1 is pin 11, Arduino port: D5&#xA;  enum { NO_CLOCK, PRESCALE_1, PRESCALE_8, PRESCALE_64, PRESCALE_256, PRESCALE_1024, T1_FALLING, T1_RISING };&#xA;&#xA;  // what ports to toggle on timer fire&#xA;  enum { NO_PORT = 0, &#xA;&#xA;    // pin 15, Arduino port: D9&#xA;    TOGGLE_A_ON_COMPARE  = bit (COM1A0), &#xA;    CLEAR_A_ON_COMPARE   = bit (COM1A1), &#xA;    SET_A_ON_COMPARE     = bit (COM1A0) | bit (COM1A1),&#xA;&#xA;    // pin 16, Arduino port: D10&#xA;    TOGGLE_B_ON_COMPARE  = bit (COM1B0), &#xA;    CLEAR_B_ON_COMPARE   = bit (COM1B1), &#xA;    SET_B_ON_COMPARE     = bit (COM1B0) | bit (COM1B1),&#xA;  };&#xA;&#xA;  // choose a timer mode, set which clock speed, and which port to toggle&#xA;  void setMode (const byte mode, const byte clock, const byte port)&#xA;  {&#xA;  if (mode &amp;lt; 0 || mode &amp;gt; 15)  // sanity check&#xA;    return;&#xA;&#xA;  // reset existing flags&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;&#xA;  TCCR1A |= (Modes [mode] [0]) | port;  &#xA;  TCCR1B |= (Modes [mode] [1]) | clock;&#xA;  }  // end of Timer1::setMode&#xA;&#xA;}  // end of namespace Timer1 &#xA;&#xA;/* ---------------------------------------------------------------&#xA; Timer 2 setup&#xA; --------------------------------------------------------------- */&#xA;&#xA;namespace Timer2 &#xA;{&#xA;  // TCCR2A, TCCR2B&#xA;  const byte Modes [8] [2] = &#xA;  {&#xA;&#xA;  { 0,                         0 },            // 0: Normal, top = 0xFF&#xA;  { bit (WGM20),               0 },            // 1: PWM, Phase-correct, top = 0xFF&#xA;  {               bit (WGM21), 0 },            // 2: CTC, top = OCR2A&#xA;  { bit (WGM20) | bit (WGM21), 0 },            // 3: Fast PWM, top = 0xFF&#xA;  { 0,                         bit (WGM22) },  // 4: Reserved&#xA;  { bit (WGM20),               bit (WGM22) },  // 5: PWM, Phase-correct, top = OCR2A&#xA;  {               bit (WGM21), bit (WGM22) },  // 6: Reserved&#xA;  { bit (WGM20) | bit (WGM21), bit (WGM22) },  // 7: Fast PWM, top = OCR2A&#xA;&#xA;  };  // end of Timer2::Modes&#xA;&#xA;  // Activation&#xA;  enum { NO_CLOCK, PRESCALE_1, PRESCALE_8, PRESCALE_32, PRESCALE_64, PRESCALE_128, PRESCALE_256, PRESCALE_1024 };&#xA;&#xA;  // what ports to toggle on timer fire&#xA;  enum { NO_PORT = 0, &#xA;&#xA;    // pin 17, Arduino port: D11&#xA;    TOGGLE_A_ON_COMPARE  = bit (COM2A0), &#xA;    CLEAR_A_ON_COMPARE   = bit (COM2A1), &#xA;    SET_A_ON_COMPARE     = bit (COM2A0) | bit (COM2A1),&#xA;&#xA;    // pin 5, Arduino port: D3&#xA;    TOGGLE_B_ON_COMPARE  = bit (COM2B0), &#xA;    CLEAR_B_ON_COMPARE   = bit (COM2B1), &#xA;    SET_B_ON_COMPARE     = bit (COM2B0) | bit (COM2B1),&#xA;  };&#xA;&#xA;&#xA;  // choose a timer mode, set which clock speed, and which port to toggle&#xA;  void setMode (const byte mode, const byte clock, const byte port)&#xA;  {&#xA;  if (mode &amp;lt; 0 || mode &amp;gt; 7)  // sanity check&#xA;    return;&#xA;&#xA;  // reset existing flags&#xA;  TCCR2A = 0;&#xA;  TCCR2B = 0;&#xA;  TimerHelpers.h&#xA;  TCCR2A |= (Modes [mode] [0]) | port;  &#xA;  TCCR2B |= (Modes [mode] [1]) | clock;&#xA;  }  // end of Timer2::setMode&#xA;&#xA;}  // end of namespace Timer2 &#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;References&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;Timers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Interrupts&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=11608&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno output to VGA monitor&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-24T20:55:24.303" LastActivityDate="2016-02-24T20:55:24.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21044" PostTypeId="1" AcceptedAnswerId="21045" CreationDate="2016-02-24T07:58:13.287" Score="0" ViewCount="446" Body="&lt;p&gt;The way I understand SPI is that 3 wires are shared (MOSI, MISO, &amp;amp; SCHK). The slave select is pulled high when you want to write to a specific device. The 3 shared wires can be daisy chained. The TLC5940 LED Driver says that it uses SPI but I don't see any documentation about a slave select. Can I just include this in the standard daisy chaining and assign a new slave select? In some forums online some people seem to indicate you can't use the TLC5940 on the same SPI bus as other devices. I thought that was the whole point of SPI. Are there different forms of SPI? I'm quite confused, can I use the TLC5940 with other SPI devices?&lt;/p&gt;&#xA;" OwnerUserId="18363" LastActivityDate="2016-02-24T09:53:55.013" Title="Can I use the TLC5940 LED Driver if I'm already using other SPI devices on my Arduino mega?" Tags="|arduino-mega|led|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21045" PostTypeId="2" ParentId="21044" CreationDate="2016-02-24T09:48:33.863" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I just include this in the standard daisy chaining and assign a new slave select? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SPI is normally used as a parallel bus and requires MISO to be tri-state (disconnected when not selected). &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In some forums online some people seem to indicate you can't use the TLC5940 on the same SPI bus as other devices. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The device does not have a chip select which gives a challenge. No direct wiring is possible but can be solved. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there different forms of SPI? I'm quite confused, can I use the TLC5940 with other SPI devices?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is possible to connect the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/tlc5940.pdf&quot; rel=&quot;nofollow&quot;&gt;TLC5940&lt;/a&gt; but it requires some extra logic. You can for instance block the clock signal when it is not selected. This can be done with a MOSFET or &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/74HC_HCT125.pdf&quot; rel=&quot;nofollow&quot;&gt;74HC125&lt;/a&gt; and a pull-low resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-24T09:53:55.013" LastActivityDate="2016-02-24T09:53:55.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21047" PostTypeId="1" CreationDate="2016-02-24T12:14:04.313" Score="1" ViewCount="5376" Body="&lt;p&gt;I'm trying to setup home automation system controlled with webpage stored in SD card of Arduino, I was thinking if it was possible to set a login page, only combination of correct user id &amp;amp; password will be able to access the control page.&lt;/p&gt;&#xA;" OwnerUserId="18655" LastEditorUserId="11529" LastEditDate="2016-02-26T15:06:23.903" LastActivityDate="2016-03-14T09:03:26.870" Title="A simple login page on Arduino Uno" Tags="|arduino-uno|ethernet|web-server|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21048" PostTypeId="2" ParentId="8847" CreationDate="2016-02-24T13:22:31.073" Score="6" Body="&lt;p&gt;rx -&gt; tx&lt;br&gt;&#xA;tx -&gt; rx&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check your connections.&lt;/p&gt;&#xA;" OwnerUserId="18658" LastEditorUserId="11529" LastEditDate="2016-02-24T13:57:19.807" LastActivityDate="2016-02-24T13:57:19.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21049" PostTypeId="1" AcceptedAnswerId="21051" CreationDate="2016-02-24T13:26:14.780" Score="0" ViewCount="608" Body="&lt;p&gt;If my arduino is the master device in a SPI network, hence not using the slave select SS pin, can I use the same pin as IO10?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am actually using an Intel Galileo, with the same pinout as an Arduino Uno Rev3.&lt;/p&gt;&#xA;" OwnerUserId="10859" LastActivityDate="2016-02-25T07:34:50.537" Title="Can I use IO10 as digital IO while using SPI interface?" Tags="|pins|spi|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21050" PostTypeId="1" AcceptedAnswerId="21072" CreationDate="2016-02-24T13:53:43.960" Score="1" ViewCount="2186" Body="&lt;p&gt;I'm trying to control an Arduino Barebone from an arduino with relays.&#xA;Basically when the attiny starts it should switch on the arduino for 4 seconds.&#xA;The Arduino sends a signal back to a digital pin of the attiny and as long as it is set to high the attiny should leave it working.&#xA;If it is low the attiny should switch the relay of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the problem is some changes to the code make the interrupt reset the attiny (which would switch of the arduino) othertimes- in this case.&#xA;the interrupt doesn't work at all.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;int pinBoard = 0;&#xA;bool boardOn = false;&#xA;bool startBoard_flag = false;&#xA;int pinBoardReturn = 3;&#xA;&#xA;volatile boolean f_wdt = 1;&#xA;&#xA;void setup() {&#xA;  cli();//disable interrupts during setup&#xA;  pinMode(pinBoard, OUTPUT);&#xA;  pinMode(pinBoardReturn, INPUT);&#xA;  setup_watchdog(9);&#xA;  cbi(ADCSRA, ADEN);                   // switch Analog to Digitalconverter OFF&#xA;  // cli();//disable interrupts during setup&#xA;  for (int i = 0; i &amp;lt; 10; i++) {&#xA;    digitalWrite(pinBoard, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(pinBoard, LOW);&#xA;    delay(100);&#xA;  }&#xA;&#xA;  PCMSK |= (1 &amp;lt;&amp;lt; PCINT1); //sbi(PCMSK,INTERRUPTPIN) also works but I think this is more clear // tell pin change mask to listen to pin2 /pb3 //SBI&#xA;  GIMSK |= (1 &amp;lt;&amp;lt; PCIE);   // enable PCINT interrupt in the general interrupt mask //SBI&#xA;&#xA;  startBoard();&#xA;&#xA;  DDRB &amp;amp;= ~(1 &amp;lt;&amp;lt; DDB1); //cbi(DDRB, DATADIRECTIONPIN);//  set up as input  - pin2 clear bit  - set to zero&#xA;  PORTB |= (1 &amp;lt;&amp;lt; PB1); //cbi(PORTB, PORTPIN);// disable pull-up. hook up pulldown resistor. - set to zero&#xA;}&#xA;&#xA;&#xA;void startBoard() {&#xA;  digitalWrite(pinBoard, HIGH);&#xA;  boardOn = true;&#xA;  startBoard_flag = false;&#xA;  cli();                                  // Disable interrupts&#xA;  delay(4000);&#xA;}&#xA;&#xA;void shutdownBoard() {&#xA;  digitalWrite(pinBoard, LOW);&#xA;  boardOn = false;&#xA;}&#xA;&#xA;void loop() {&#xA;  if (f_wdt == 1) { // wait for timed out watchdog / flag is set when a watchdog timeout occurs&#xA;    f_wdt = 0;     // reset flag&#xA;    if (startBoard_flag) {&#xA;      startBoard();&#xA;    }&#xA;    bool boardReturn = digitalRead(pinBoardReturn);&#xA;    if (boardOn &amp;amp;&amp;amp; !boardReturn) {&#xA;      shutdownBoard();&#xA;    }&#xA;    system_sleep();&#xA;  }&#xA;}&#xA;&#xA;//****************************************************************&#xA;// set system into the sleep state&#xA;// system wakes up when wtchdog is timed out&#xA;void system_sleep() {&#xA;&#xA;  // GIMSK |= _BV(PCIE);                     // Enable Pin Change Interrupts&#xA;  // PCMSK |= _BV(PCINT3);                   // Use PB3 as interrupt pin&#xA;&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement&#xA;  sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)&#xA;  sleep_cpu();                            // sleep&#xA;&#xA;  // PCMSK &amp;amp;= ~_BV(PCINT3);                  // Turn off PB3 as interrupt pin&#xA;  sleep_disable();                        // Clear SE bit&#xA;&#xA;  // sei();                                  // Enable interrupts&#xA;}&#xA;&#xA;//****************************************************************&#xA;// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms&#xA;// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec&#xA;void setup_watchdog(int ii) {&#xA;&#xA;  byte bb;&#xA;  int ww;&#xA;  if (ii &amp;gt; 9 ) ii = 9;&#xA;  bb = ii &amp;amp; 7;&#xA;  if (ii &amp;gt; 7) bb |= (1 &amp;lt;&amp;lt; 5);&#xA;  bb |= (1 &amp;lt;&amp;lt; WDCE);&#xA;  ww = bb;&#xA;&#xA;  MCUSR &amp;amp;= ~(1 &amp;lt;&amp;lt; WDRF);&#xA;  // start timed sequence&#xA;  WDTCR  |= (1 &amp;lt;&amp;lt; WDCE) | (1 &amp;lt;&amp;lt; WDE);&#xA;  // set new watchdog timeout value&#xA;  WDTCR  = bb;&#xA;  WDTCR  |= _BV(WDIE);&#xA;}&#xA;//****************************************************************&#xA;// Watchdog Interrupt Service / is executed when  watchdog timed out&#xA;ISR(WDT_vect) {&#xA;  f_wdt = 1; // set global flag&#xA;}&#xA;&#xA;ISR(PCINT_VECTOR) {&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    digitalWrite(pinBoard, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(pinBoard, LOW);&#xA;    delay(1000);&#xA;  }&#xA;  startBoard_flag = true;&#xA;  f_wdt = 1; // set global flag&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18659" LastEditorUserId="11529" LastEditDate="2016-02-24T17:29:31.087" LastActivityDate="2016-02-25T05:28:08.037" Title="ATTiny watchdog and interrupt" Tags="|interrupt|attiny|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21051" PostTypeId="2" ParentId="21049" CreationDate="2016-02-24T13:55:54.833" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use IO10 as digital IO while using SPI interface?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On AVR it must be OUTPUT when using SPI in master mode and INPUT in slave mode. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If my arduino is the master device in a SPI network, hence not using the slave select SS pin, can I use the same pin as IO10?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The SS pin (D10) has to be OUTPUT when using SPI master mode. It can be used for chip select on the SPI bus (slave select) or some other output function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far the Arduino design with AVR (e.g. ATmega328). The Intel Galileo based Arduino has the following block diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/57yHU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/57yHU.jpg&quot; alt=&quot;Intel Galileo Logic Schematics&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IO10-IO14 are multiplexed from SPI1 or GPIO. This implies that the SPI SS (IO10) signal is hardwired to the SPI controller when enabled. Last, according to the &lt;a href=&quot;https://www.arduino.cc/en/ArduinoCertified/IntelGalileo&quot; rel=&quot;nofollow noreferrer&quot;&gt;product info&lt;/a&gt; SPI is master only. More details schematics details &lt;a href=&quot;http://www.intel.com/content/dam/support/us/en/documents/galileo/sb/galileo_schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-25T07:34:50.537" LastActivityDate="2016-02-25T07:34:50.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21052" PostTypeId="2" ParentId="21047" CreationDate="2016-02-24T14:19:10.487" Score="-1" Body="&lt;p&gt;I guess you could do it with Javascript and HTML, and put the pages in the micro SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it will make it harder (if not impossible) to make the automation.&lt;/p&gt;&#xA;" OwnerUserId="18660" LastEditorUserId="10794" LastEditDate="2016-02-26T01:03:03.107" LastActivityDate="2016-02-26T01:03:03.107" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21054" PostTypeId="2" ParentId="12723" CreationDate="2016-02-24T15:29:27.040" Score="1" Body="&lt;p&gt;The atod clock is set in the mode register. The clock is 42MHz/(PRESCAL#+1). One way of setting it is the use ADC-&gt;ADCMR = ADC_MR_PRESCAL(PRESCAL#), where PRESCAL# is some integer.  These symbols are defined in component_adc.h in the Arduino source code. &#xA; In the AVR data sheet, the recommended clock is MIN=1MHz, MAX=20 MHZ, corresponding to numbers between 41 and 1. Look in the data sheet, section 43.&lt;/p&gt;&#xA;" OwnerUserId="18662" LastActivityDate="2016-02-24T15:29:27.040" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21055" PostTypeId="1" CreationDate="2016-02-24T15:45:16.407" Score="1" ViewCount="203" Body="&lt;p&gt;I'm researching options for a project in which I need to send/receive SMS messages to/from multiple users of different service providers.&lt;br&gt;&#xA;Hoping to reduce costs, I'm thinking of forwarding the messages to a different SIM card, depending of the user's service provider (since all of them have plans with free SMS for numbers of the same provider).&lt;br&gt;&#xA;Arduino GSM Shield seemed like a good option, except the shield has only one SIM card slot.&lt;br&gt;&#xA;I wonder: would it be possible to stack 3 shields (there are 3 mayor service providers in my country) on the same Arduino Board and use some reasonably straightforward programming to handle the task?&lt;br&gt;&#xA;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="18661" LastActivityDate="2017-03-21T15:28:09.810" Title="Arduino GSM Shields stacking" Tags="|shields|gsm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21059" PostTypeId="2" ParentId="21034" CreationDate="2016-02-24T18:36:35.913" Score="4" Body="&lt;p&gt;It is possible to do this by feeding the end of the strip back into the arduino.  bunnie Huang blogged about doing this a few years ago: &lt;a href=&quot;http://www.bunniestudios.com/blog/?p=3345&quot; rel=&quot;nofollow&quot;&gt;http://www.bunniestudios.com/blog/?p=3345&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;He has &lt;a href=&quot;http://bunniefoo.com/bunnie/phage-armband.PDF&quot; rel=&quot;nofollow&quot;&gt;schematics&lt;/a&gt; and &lt;a href=&quot;https://github.com/ThePhage/phage-armband&quot; rel=&quot;nofollow&quot;&gt;firmware&lt;/a&gt; which uses a &lt;a href=&quot;https://github.com/bunnie/Adafruit_NeoPixel&quot; rel=&quot;nofollow&quot;&gt;modified neopixel library&lt;/a&gt; that can measure the length of the strip.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2016-02-24T18:36:35.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21060" PostTypeId="2" ParentId="21055" CreationDate="2016-02-24T19:01:42.140" Score="0" Body="&lt;p&gt;Stacking might be hard, since they communicate on pins 2&amp;amp;3.  But if you work around that somehow, you could use Software Serial to access multiple GSM devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the GSM library has hardcoded the pins, and it might not share well with multiple, but you might be able to use SoftwareSerial or AltSoftSerial to do multiple connections, but that would be less straightforward.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-24T19:01:42.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21061" PostTypeId="1" AcceptedAnswerId="21063" CreationDate="2016-02-24T19:56:11.733" Score="5" ViewCount="10426" Body="&lt;p&gt;I was surprised that this question had no answer on Stack Exchange and I can't find much about it elsewhere so, in the hopes that it will be useful to people other than myself, I'd like to ask:&lt;/p&gt;&#xA;&lt;p&gt;How can one power two arduinos using the same power source? Such that the first is connected by barrel jack to a 12v transformer.&lt;/p&gt;&#xA;&lt;p&gt;I saw &lt;a href=&quot;https://www.youtube.com/watch?v=Jndb2vpAWwU&quot; rel=&quot;nofollow noreferrer&quot;&gt;this youtube video&lt;/a&gt; which &lt;em&gt;very&lt;/em&gt; briefly mentions doing this by make the connections:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ardu1 --&amp;gt; Ardu2&lt;/p&gt;&#xA;&lt;p&gt;5V --&amp;gt; 5V&lt;/p&gt;&#xA;&lt;p&gt;GND --&amp;gt; GND&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This surprised me as I was not aware the 5V could operate as a power input. I was expecting the use of the &lt;code&gt;VIN&lt;/code&gt; pin somewhere along the line.&lt;/p&gt;&#xA;&lt;p&gt;Am I correct in thinking that the second arduino would take power on it's &lt;code&gt;VIN&lt;/code&gt; pin from &lt;code&gt;5V&lt;/code&gt; on arduino one?&lt;/p&gt;&#xA;&lt;p&gt;If so, where should the second arduino ground to?&lt;/p&gt;&#xA;" OwnerUserId="17150" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2023-03-04T09:56:52.963" Title="Two arduinos one power source" Tags="|power|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21062" PostTypeId="2" ParentId="21061" CreationDate="2016-02-24T20:33:22.180" Score="3" Body="&lt;p&gt;You could put the 12v from the barrel jack on both Arduninos Vin pins by jumpering the Vin pins together instead of the Vin-&gt;+5 or +5-&gt;+5.  Then they'd have independent protection and regulation of 1A, 5V through their NCP1117ST50T3G chips.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-24T20:33:22.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21063" PostTypeId="2" ParentId="21061" CreationDate="2016-02-24T20:54:49.957" Score="1" Body="&lt;p&gt;I have powered numerous arduino's via the 5V pin. I would however call this an advanced usage because there are some limitation/dangers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all: Power your arduino via 5V and plugin a powered USB cable or a powered plug and it may (probably will) damage your USB or arduino or both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly; it is best to assume that all arduino's are different on behalf of the behaviour of the +5V pin. I know for a fact there is a difference with uno,yun,due. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;thirdly: The way it is used on the video -you linked to- (power jack 5V arduino 1 to 5V arduino 2 and ground arduino 1 to ground arduino 2) makes that all power goes through the voltage converter on the Arduino 1.&#xA;These voltage converters can not handle much current. This is only sufficient in very low power drawing applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It s not a good idea to connect the 5V pin of arduino 1 to Vin of the arduino 2. This because the voltage converter on arduino 2 will not be able to provide 5V to The 5V cirquitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is mutch smarter to connect the Vin from arduino 1 to Vin of Arduino2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I power arduino's from &quot;standard batteries&quot; I use a switching power supply that powers the arduino over a cut in halve USB cable. This way it is lots safer as I can add power over the jack and I can not plugin a second USB cable.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-24T20:54:49.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21064" PostTypeId="2" ParentId="21061" CreationDate="2016-02-24T21:31:49.863" Score="2" Body="&lt;p&gt;Connecting the +5V pins together is acceptable providing you don't exceed the total load that the source of the +5V can provide. This would be either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The maximum the &lt;em&gt;USB interface&lt;/em&gt; can provide: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 003 Device 013: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)&#xA;Device Descriptor:&#xA;...&#xA;  bDeviceClass            2 Communications&#xA;...&#xA;  idVendor           0x2341 Arduino SA&#xA;  idProduct          0x0043 Uno R3 (CDC ACM)&#xA;...&#xA;  Configuration Descriptor:&#xA;...&#xA;    MaxPower              100mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would seem to be 100 mA from doing &lt;code&gt;lsusb -v&lt;/code&gt; on my Ubuntu system.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The maximum that the &lt;em&gt;voltage regulator&lt;/em&gt; can provide (if you are using the power jack, &lt;strong&gt;or&lt;/strong&gt; V&lt;sub&gt;in&lt;/sub&gt;). This would depend on the model of Arduino, plus what your input voltage is (the higher the input voltage, the hotter the voltage regulator will get).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;When I am testing things like sending I&lt;sup&gt;2&lt;/sup&gt;C from one Arduino to another, I will often connect the USB to one of them, and just connect together the +5V pins (&lt;strong&gt;and ground&lt;/strong&gt; of course) so that the second Arduino gets powered.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt; : my &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about power&lt;/a&gt; indicates that without using sleep modes and other techniques, a Uno may consume 50 mA on its own. Thus connecting two Unos is likely to be reaching the limit that the USB interface can provide. Connecting three or more is likely to be problematic.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Regarding the USB power issue, see &lt;a href=&quot;https://electronics.stackexchange.com/questions/5498/how-to-get-more-than-100ma-from-a-usb-port&quot;&gt;How to get more than 100mA from a USB port&lt;/a&gt;. On that page it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;USB-100mA&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;USB by default will deliver 100mA of current (it is 500mW power because we know it is 5v, right?) to a device. This is the most you can pull from a USB hub that does not have its own power supply, as they never offer more than 4 ports and keep a greedy 100mA for themselves.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;...&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Near the end of enumeration you setup device parameters. Very specifically the configuration descriptors. If you look on this website they will show you all of the different pieces that can be set. It shows that you can get right up to 500mA of power requested.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As the negotiation in this case appears to be requesting 100 mA (and not 500 mA) the port on the PC may well limit you to that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-25T05:06:55.677" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21066" PostTypeId="2" ParentId="21061" CreationDate="2016-02-24T23:37:19.840" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;This surprised me as I was not aware the 5V could operate as a power input. I was expecting the use of the VIN pin somewhere along the line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Power is just power. It doesn't have a &quot;direction&quot; like an IO pin. It just flows from a point of higher potential to a point of lower potential. If you put a load onto the 5V pin then the power will flow out of the 5V pin, through the load, to the lower GROUND potential. And that is all the other Arduino is - a load. The power flows out of the 5V, into the other Arduino, through it, and down to the lower GROUND potential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's just like a rechargeable battery. Put a light on the battery and the electricity flows out of the battery to light the lamp. Apply a higher voltage to the battery from another supply and the power flows out of the supply into the battery, recharging it (or making it explode if the voltage is too high).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-24T23:37:19.840" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21068" PostTypeId="1" CreationDate="2016-02-25T04:06:28.283" Score="0" ViewCount="1231" Body="&lt;p&gt;I'm using a hall effect sensor A1356 (linear application) to measure the amount of fluid in a container. The fluid is in constant use. My doubt is I'm placing the sensor and the magnet assembly in place, such that when it is exactly half filled, the magnet's center will align with the center of the sensor. In this condition I get 100% duty cycle output from the sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Condition 1: If the fluid is filled then the magnet moves above the sensor and the duty cycle reduces say to 90%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Condition 2: If the fluid is consumed then the magnet will move below the sensor and the duty cycle reduces to say 90%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I differentiate between the rise and fall of the fluid? Or is there a better way of orienting the magnet and the sensor such that this problem could be avoided?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm interfacing it with an Arduino UNO&lt;/p&gt;&#xA;" OwnerUserId="18476" LastEditorUserId="9962" LastEditDate="2016-02-25T05:17:14.067" LastActivityDate="2016-02-25T13:44:31.400" Title="Hall effect sensor direction detection using arduino" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21069" PostTypeId="1" CreationDate="2016-02-25T04:59:38.643" Score="0" ViewCount="208" Body="&lt;p&gt;I have an Adafruit Motor Shield, the V1. I have been using this thing with my OPSEPP Uno and a stepper motor with no issues. (Powered by 12v DC wall wart [CASIO]).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question, or issue, not sure yet, is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why when I connect my motor directly to the 12v power supply it operates efficiently (for my purposes) and when I run it through my Arduino with the Adafruit Motor.h library does it not power the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically on direct connection it works fine, but I want to be able to regulate the connection and reverse it, change the speed, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible I am utilizing the library or the board wrong. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone indicate why the power or, torque seems to drop when through the board. I have tried all KHZ all speeds etc, no way to get the same 12v power directly and modulate it?&lt;/p&gt;&#xA;" OwnerUserId="18680" LastEditorUserId="11529" LastEditDate="2016-02-25T08:48:59.113" LastActivityDate="2016-02-25T08:48:59.113" Title="Motor Shield not giving full power, LED DIMS" Tags="|power|motor|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21070" PostTypeId="2" ParentId="21069" CreationDate="2016-02-25T05:15:29.537" Score="1" Body="&lt;p&gt;According to the &lt;a href=&quot;https://www.adafruit.com/products/81&quot; rel=&quot;nofollow&quot;&gt;Adafruit page&lt;/a&gt; the V1 version of the shield is not as powerful as their V2 version. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where is the 12V coming from to get to the shield? There isn't really 12V broken out on the Uno anywhere. If it comes from V&lt;sub&gt;in&lt;/sub&gt; then there is a 0.7V drop through the reverse polarity protection diode. Plus, the tracks on the Arduino board may not be thick enough to provide enough current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the shield may take an external power source (it is hard to tell because they discontinued it). You could try using that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-25T05:15:29.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21071" PostTypeId="1" CreationDate="2016-02-25T05:17:56.850" Score="2" ViewCount="756" Body="&lt;p&gt;ESP8266 (01-512k,) Arduino Uno (clone), Arduino IDE, Python 2.7.6 on Macbook pro running OSX 10.10.4 64-bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hello!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a motion sensor with the following setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno+motion sensor &gt;&gt;&gt;sensor values&gt;&gt;&gt;USB Serial&gt;&gt;&gt;Laptop running Python code&gt;&gt;&gt;Notification&gt;&gt;&gt;WiFi&gt;&gt;&gt;Web&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor generates a value. The value is displayed on the serial monitor. The python program is triggered into action by a specific value appearing on the serial monitor and the program sends an email notification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to replace that setup with the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Uno+motion sensor&gt;&gt;&gt;sensor values&gt;&gt;&gt;ESP8266 as transparent WiFi to Serial bridge&gt;&gt;&gt;Laptop running Python code&gt;&gt;&gt;Notification&gt;&gt;&gt;WiFi&gt;&gt;&gt;Web&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, I want to get rid of the USB cable and use the ESP8266 as a transparent WiFi to Serial bridge. Of course, a battery would power the Arduino and ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read &lt;a href=&quot;http://hackaday.com/2015/09/18/transparent-esp8266-wifi-to-serial-bridge/&quot; rel=&quot;nofollow&quot;&gt;this post&lt;/a&gt;  and the Jeelabs/ ESP Link Readme. It seems that the ESP8266, once flashed with ESP Link, could replace a serial cable. But, can ESP Link replace the USB Serial in my current setup? If so, are there tutorials explaining how this can be done?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did some further reading and researched the matter but so far I only found one use case similar to what I want to do. In the said use case, a virtual serial connection through WiFi was being executed via a server within the ESP8266. Unfortunately, there were no detailed explanations on how this was achieved and I don't think this would be suitable for my specific use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know if further information or clarification is needed.&lt;/p&gt;&#xA;" OwnerUserId="17046" LastEditorUserId="17046" LastEditDate="2016-02-25T14:44:17.543" LastActivityDate="2016-02-25T18:26:14.967" Title="Is replacing USB serial WITH ESP8266+ESP link feasible?" Tags="|arduino-uno|serial|arduino-ide|esp8266|softwareserial|" AnswerCount="0" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21072" PostTypeId="2" ParentId="21050" CreationDate="2016-02-25T05:28:08.037" Score="4" Body="&lt;p&gt;Disassembling the &lt;code&gt;delay&lt;/code&gt; code indicates it uses &lt;code&gt;micros&lt;/code&gt; which needs interrupts on to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void delay(unsigned long ms)&#xA;{&#xA; 27a:   cf 92           push    r12&#xA; 27c:   df 92           push    r13&#xA; 27e:   ef 92           push    r14&#xA; 280:   ff 92           push    r15&#xA; 282:   cf 93           push    r28&#xA; 284:   df 93           push    r29&#xA; 286:   6b 01           movw    r12, r22&#xA; 288:   7c 01           movw    r14, r24&#xA;    uint16_t start = (uint16_t)micros();&#xA; 28a:   d3 df           rcall   .-90        ; 0x232 &amp;lt;micros&amp;gt;&#xA; 28c:   eb 01           movw    r28, r22&#xA;&#xA;    while (ms &amp;gt; 0) {&#xA; 28e:   c1 14           cp  r12, r1&#xA; 290:   d1 04           cpc r13, r1&#xA; 292:   e1 04           cpc r14, r1&#xA; 294:   f1 04           cpc r15, r1&#xA; 296:   79 f0           breq    .+30        ; 0x2b6 &amp;lt;delay+0x3c&amp;gt;&#xA;        yield();&#xA; 298:   ea d0           rcall   .+468       ; 0x46e &amp;lt;yield&amp;gt;&#xA;        if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA; 29a:   cb df           rcall   .-106       ; 0x232 &amp;lt;micros&amp;gt;&#xA; 29c:   6c 1b           sub r22, r28&#xA; 29e:   7d 0b           sbc r23, r29&#xA; 2a0:   68 3e           cpi r22, 0xE8   ; 232&#xA; 2a2:   73 40           sbci    r23, 0x03   ; 3&#xA; 2a4:   a0 f3           brcs    .-24        ; 0x28e &amp;lt;delay+0x14&amp;gt;&#xA;            ms--;&#xA; 2a6:   81 e0           ldi r24, 0x01   ; 1&#xA; 2a8:   c8 1a           sub r12, r24&#xA; 2aa:   d1 08           sbc r13, r1&#xA; 2ac:   e1 08           sbc r14, r1&#xA; 2ae:   f1 08           sbc r15, r1&#xA;            start += 1000;&#xA; 2b0:   c8 51           subi    r28, 0x18   ; 24&#xA; 2b2:   dc 4f           sbci    r29, 0xFC   ; 252&#xA; 2b4:   ec cf           rjmp    .-40        ; 0x28e &amp;lt;delay+0x14&amp;gt;&#xA;        }&#xA;    }&#xA;}&#xA; 2b6:   df 91           pop r29&#xA; 2b8:   cf 91           pop r28&#xA; 2ba:   ff 90           pop r15&#xA; 2bc:   ef 90           pop r14&#xA; 2be:   df 90           pop r13&#xA; 2c0:   cf 90           pop r12&#xA; 2c2:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That appears to confirm that the code in &lt;code&gt;wiring.c&lt;/code&gt; is indeed what is being used on the ATtiny85 core:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void delay(unsigned long ms)&#xA;{&#xA;    uint16_t start = (uint16_t)micros();&#xA;&#xA;    while (ms &amp;gt; 0) {&#xA;        yield();&#xA;        if (((uint16_t)micros() - start) &amp;gt;= 1000) {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turning interrupts off and then doing a &lt;code&gt;delay&lt;/code&gt; is a Bad Idea&lt;sup&gt;TM&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So i would rather have a counter for the watchdog in order to wait for the specified time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Using the watchdog timer is certainly one way of waiting for 4 seconds.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-25T05:28:08.037" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21074" PostTypeId="2" ParentId="21047" CreationDate="2016-02-25T07:52:55.420" Score="-1" Body="&lt;p&gt;Make simple webpage and put it in sd card. If it's just one page with few buttons and bit js even flash memory of controller would suffice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In arduino code add lines that can detect click on particular button of webpage and control relay/motor etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Knowledge of basic post request using js can help. You can't implement php page in arduino as it needs complex processing at arduino side&lt;/p&gt;&#xA;" OwnerUserId="18683" LastActivityDate="2016-02-25T07:52:55.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21075" PostTypeId="1" AcceptedAnswerId="21077" CreationDate="2016-02-25T11:44:35.120" Score="0" ViewCount="1431" Body="&lt;p&gt;I'm trying to write to and read from an AT93C46D eeprom using an Arduino UNO but for some reason the output I'm getting is not what I expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The eeprom has a data structure of 128 words of 8 bits each and I'm trying to write 10000010 to each word. When reading back the data however I get 11000001.&#xA;When I write 00000000 to all words I get 10000000 for all words when reading. I tested my code on 2 AT93C46D eeproms and both gave the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the MSB is always 1 (when reading) for some reason. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm probably making a stupid mistake but I can't seem to find it, any help is greatly appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Datasheet: &lt;a href=&quot;http://www.atmel.com/images/atmel-5193-seeprom-at93c46d-datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/atmel-5193-seeprom-at93c46d-datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SPI.h&amp;gt;&#xA;#define DATAOUT 11//MOSI&#xA;#define DATAIN  12//MISO &#xA;#define SPICLOCK  13//sck&#xA;#define SS 10//ss&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(SS,OUTPUT);&#xA;  pinMode(DATAOUT, OUTPUT);&#xA;  pinMode(DATAIN, INPUT);&#xA;  pinMode(SPICLOCK,OUTPUT);&#xA;  digitalWrite(SS,LOW);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));&#xA;&#xA;  fill();&#xA;&#xA;  dump();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&#xA;void fill()&#xA;{&#xA;  Serial.println(&quot;Send EWEN opcode&quot;);&#xA;  digitalWrite(SS,HIGH);&#xA;  SPI.transfer(B10011); //EWEN&#xA;  SPI.transfer(B0000000);&#xA;  digitalWrite(SS,LOW);&#xA;&#xA;  delay(100);&#xA;&#xA;  for (int i=0; i &amp;lt; 128; i++) {&#xA;    digitalWrite(SS,HIGH);&#xA;    SPI.transfer(B101);&#xA;    SPI.transfer(i);&#xA;    SPI.transfer(B10000010);&#xA;    delay(10);&#xA;    digitalWrite(SS,LOW);&#xA;  }&#xA;&#xA;  delay(100);&#xA;&#xA;  Serial.println(&quot;Send EWDS opcode&quot;);&#xA;  digitalWrite(SS,HIGH);&#xA;  SPI.transfer(B1000); //EWDS&#xA;  SPI.transfer(B00000000);&#xA;  digitalWrite(SS,LOW);&#xA;&#xA;  delay(10);&#xA;}&#xA;&#xA;void dump(){&#xA;  Serial.println(&quot;Dumping AT93C46D&quot;);&#xA;&#xA;  byte b;&#xA;&#xA;  for (int i=0; i &amp;lt; 128; i++) {&#xA;    digitalWrite(SS,HIGH);&#xA;    SPI.transfer(B110); //read opcode&#xA;    SPI.transfer(i);&#xA;    b = SPI.transfer(B00000000); //clock data out&#xA;    digitalWrite(SS,LOW);&#xA;    Serial.println(b, BIN);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18689" LastActivityDate="2016-02-26T16:40:44.777" Title="Arduino UNO and SPI eeprom (AT93C46D)" Tags="|arduino-uno|spi|eeprom|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21076" PostTypeId="2" ParentId="21068" CreationDate="2016-02-25T13:44:31.400" Score="2" Body="&lt;p&gt;According to the data sheet (see below) the no-field PWM output is mid-range; north poles reduce it &amp;amp; south increase.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you had an arrangement whereby the float had north down &amp;amp; south up, ie a vertical bar-magnet, this would presumably give a rise-before-0 or fall-before-0 at the float vanishes, or a fall-to-minimum an rise-to-maximum as the float centres? The bit in the middle could be interesting!    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the datasheet:&#xA;&quot;The presence of a south polarity magnetic field,&#xA;perpendicular to the branded surface of the package face,&#xA;increases the output duty cycle from its quiescent value toward&#xA;the maximum duty cycle limit. The amount of the output duty&#xA;cycle increase is proportional to the magnitude of the magnetic&#xA;field applied. Conversely, the application of a north polarity&#xA;field decreases the output duty cycle from its quiescent value.&quot;&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2016-02-25T13:44:31.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21077" PostTypeId="2" ParentId="21075" CreationDate="2016-02-25T14:02:42.143" Score="0" Body="&lt;p&gt;After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer but transfer can be byte aligned with the start bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;READ is op-code(10) followed by 7-bit address, a dummy bit and the read value. That is in total 11+8-bits. Mapping that to 8-bit transfer would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spi.transfer(0b110);&#xA;spi.transfer(addr &amp;lt;&amp;lt; 1);&#xA;data = spi.transfer(0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will give 5-bit zero, start-bit, op-code in the first transfer, and followed by 7-bit address and dummy bit (LSB) in second transfer. The third transfer is the read data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EWEN would map to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spi.transfer(0b1001);&#xA;spi.transfer(0b10000000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The WRITE operation becomes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;spi.transfer(0b10);&#xA;spi.transfer(0x80 | addr);&#xA;spi.transfer(data);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-26T16:40:44.777" LastActivityDate="2016-02-26T16:40:44.777" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21078" PostTypeId="2" ParentId="18358" CreationDate="2016-02-25T14:29:09.637" Score="1" Body="&lt;p&gt;I would advice to use the arduino eclipse plugin and not use the eclipse C++ arduino extension.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The eclipse C++ arduino extension is still very much in development. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino eclipse plugin has been around for years and contains far more features. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use V3 (that is still the nightly at the time of writing) you can use the boards manager and the cosa json file to import the cosa boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Importing a lib is a matter of typing &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;libname&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and saving.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-25T14:29:09.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21081" PostTypeId="1" AcceptedAnswerId="21084" CreationDate="2016-02-25T17:42:42.327" Score="1" ViewCount="517" Body="&lt;p&gt;I found that using more float variable in arduino uno(atmega328p) slows it down (very muck that i can get slow response)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so, how to speed up it processing ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my data are euler's angle with 2 digits and 2 decimals like give below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;XX.XX , where X is number Eg.(85.63,34.65,etc) (from MPU6050)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to process it fast?&lt;/p&gt;&#xA;" OwnerUserId="7412" LastActivityDate="2016-02-25T19:51:26.080" Title="How to speed up" Tags="|arduino-uno|programming|mpu6050|float|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21082" PostTypeId="1" AcceptedAnswerId="21087" CreationDate="2016-02-25T17:56:05.570" Score="0" ViewCount="792" Body="&lt;p&gt;I am new to Arduino and physical computing When I measure the wire coming from any &lt;strong&gt;UNSET&lt;/strong&gt; Arduino uno pin, the result is approximately 2 volts &lt;strong&gt;even the &quot;ANALOG IN&quot; pins&lt;/strong&gt;. Considering that the pins which been set to HIGH and LOW are giving 5 and 0 volts &quot;which is cool&quot;.&#xA;Is that the nature of Arduino or is that a failure caused by short or anything else?&lt;/p&gt;&#xA;" OwnerUserId="18699" LastActivityDate="2021-02-16T03:12:11.447" Title="Why all unset pins of my Arduino Uno are outputting 2 volts?" Tags="|arduino-uno|pins|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21083" PostTypeId="2" ParentId="20503" CreationDate="2016-02-25T18:00:07.430" Score="1" Body="&lt;p&gt;Not directly. The L293D is a digital H-bridge chip. L293 series devices allow you to supply enough power for small motors, and the &quot;D&quot; model has internal protection diodes. There are other ICs and breakout boards that are designed specifically for microstepping. Here are a few options...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://www.sparkfun.com/products/12779&quot; rel=&quot;nofollow&quot;&gt;SparkFun EasyDriver&lt;/a&gt; ($14.95) will probably be the quickest solution.&lt;/li&gt;&#xA;&lt;li&gt;There are a variety of &lt;a href=&quot;http://www.mouser.com/Semiconductors/Power-Management-ICs/Motor-Motion-Ignition-Controllers-Drivers/_/N-41dum?P=1z0vpfyZ1z0z63xZ1z0yyznZ1z0y0t6Z1z0y325Z1yzbn3rZ1z0z44dZ1z0y33tZ1z0y33vZ1z0y22tZ1z0y33rZ1yzua75&quot; rel=&quot;nofollow&quot;&gt;stepper driver ICs&lt;/a&gt; on the market with a wide range of power ratings. For instance, ST makes the &lt;a href=&quot;http://www.mouser.com/ProductDetail/STMicroelectronics/E-L6219/?qs=sGAEpiMZZMtKB4wrjsn3lSPJ0ZpNBlDPTInlIKiwZOA%3d&quot; rel=&quot;nofollow&quot;&gt;L6219&lt;/a&gt; ($4.86) and ON also makes several versions of the &lt;a href=&quot;http://www.mouser.com/Semiconductors/Power-Management-ICs/Motor-Motion-Ignition-Controllers-Drivers/_/N-41dum?P=1z0vpfyZ1z0z63xZ1yzr60o&quot; rel=&quot;nofollow&quot;&gt;LB1847&lt;/a&gt; ($4.19-$6.90). TI also makes a few. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Datasheets will typically say whether a driver is capable of microstepping at the beginning. Just make sure the driver you choose is capable of handling the stall current of your stepper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are your steppers unipolar (6+ wires) or bipolar (4 wires)? That may make a difference in how you wire them, although some unipolar motors can be driven as if they were bipolar.&lt;/p&gt;&#xA;" OwnerUserId="17124" LastEditorUserId="17124" LastEditDate="2016-03-27T05:12:32.377" LastActivityDate="2016-03-27T05:12:32.377" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21084" PostTypeId="2" ParentId="21081" CreationDate="2016-02-25T18:07:08.143" Score="3" Body="&lt;p&gt;A technique commonly used in digital signal processing is using &lt;a href=&quot;https://en.wikipedia.org/wiki/Fixed-point_arithmetic&quot; rel=&quot;nofollow&quot;&gt;fixed-point arithmetic&lt;/a&gt; instead of &lt;a href=&quot;https://en.wikipedia.org/wiki/Floating_point&quot; rel=&quot;nofollow&quot;&gt;floating point&lt;/a&gt;.  In fixed-point arithmetic, one calculates using numbers multiplied by some power of two or ten, and in effect mentally positions a binary or decimal point several bits or digits up while calculating. &lt;a href=&quot;https://en.wikipedia.org/wiki/Numerical_analysis#Generation_and_propagation_of_errors&quot; rel=&quot;nofollow&quot;&gt;Numerical analysis&lt;/a&gt; may be needed to determine if the arithmetic is accurate enough and whether numbers will stay in bounds, or overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question doesn't say what's being calculated; it's possible fixed-point arithmetic might work, or might not.  A short self-contained fixed-point calculation that starts with MPU6050 sensor readings is likely to be ok, but long-term calculations (eg, integration of accelerations to get velocities and positions) that let error accumulate without reset may go too far astray.  In such a case, numerical analysis can indicate what intermediate results need to be stored most accurately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, when slow code is posted someone can point out speedups, from a few percent up to dozens of times faster.  Changes may range from adding or removing parentheses or temporary variables, to refactoring, to substitution of a new algorithm.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-02-25T19:51:26.080" LastActivityDate="2016-02-25T19:51:26.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21085" PostTypeId="1" CreationDate="2016-01-24T09:49:23.707" Score="3" ViewCount="207" Body="&lt;p&gt;I am using an Arduino Due as a prototyping board for a microcontroller project. The due has the chip Atmel ATSAM3X8E, with an ARM Cortex-M3 core. I am programming the flash directly using Atmel Studio and SAM-BA over USB, I am not using the arduino tools or bootloader in any way, at least not to my knowledge. I am powering it over the USB port on the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to program the flash and select flash for boot, but the problem is that the chip never works the first time I plug in the power. But if I cut the power and try again, it boots normally and the program starts. Then if I cut the power and wait a while, I have to power it up another two times before it works. It's like there is some volatile charge or RAM in there that needs to have been powered within the last minute for the chip to boot at power up like it should, but I don't know what. The result is the same if I plug the USB into my computer, or from a phone charger. Also the same whether I use the native or arduino programming USB port to power it.&lt;/p&gt;&#xA;" OwnerDisplayName="GrixM" LastActivityDate="2016-02-25T18:16:06.823" Title="Atmel SAM MCU (on Arduino Due) only boots after second power up" Tags="|power|bootloader|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21087" PostTypeId="2" ParentId="21082" CreationDate="2016-02-25T18:31:50.647" Score="1" Body="&lt;p&gt;After a microcontroller reset, AVR IO pins default to input.  In this state they have high impedance.  For example, according to the Atmel ATmega328 spec sheet doc8271 Table 29-15, analog input impedance typically can be taken as 100 MΩ for design purposes.  (Input pin impedance may in fact be orders of magnitude more, effectively an open circuit except for leakage currents of a few nanoamps.)  Each pin has a few pF (5-10?) of capacitance [&lt;a href=&quot;https://electronics.stackexchange.com/questions/67171/input-impedance-of-arduino-uno-analog-pins&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;http://www.avrfreaks.net/forum/avr-input-capacitance&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;http://www.avrfreaks.net/forum/avr-io-pin-capacitance-considerations&quot; rel=&quot;nofollow noreferrer&quot;&gt;3&lt;/a&gt;,&lt;a href=&quot;http://www.avrfreaks.net/forum/comparator-input-impedance?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=73009&quot; rel=&quot;nofollow noreferrer&quot;&gt;4&lt;/a&gt;] which in general is small compared to stray capacitances of attached wiring.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When stray electromagnetic fields charge the pin and stray capacitances, a small voltage develops on the pin.  You could connect a 1 to 10 MΩ resistor between the pin and ground, to avoid the 2 V you are seeing.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-25T18:31:50.647" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21089" PostTypeId="1" CreationDate="2016-02-25T18:51:03.083" Score="1" ViewCount="842" Body="&lt;p&gt;I have an Arduino Leonardo that I am using to emulate a Keyboard using the keyboard.press function with the Keyboard.h libraries. I have gotten the Keyboard.press function to work on my windows and mac- the keystroke I used was CTRL N to test- this worked well. So my ultimate goal was to emulate a keystroke ,F1, on a PC that is not running an OS- meaning I want the sketch to run in BIOS. for context, This keystroke (F1) tells the computer to use the a bootable USB to run a certain MathWorks OS. &#xA;The problem, when it is plugged in the Arduino shows that power is receieved by lighting the POWER LED but it does not begin the sketch. The RED LED that usually flashes ( TX or RX im not sure) when it is running a sketch is not happening (not illuminating). &#xA;How can I troubleshoot this and what could be happening? I have read that maybe too much serial info is going to the board so it confuses the board and does not begin the sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate all the following help!!&lt;/p&gt;&#xA;" OwnerUserId="18702" LastActivityDate="2016-05-27T15:00:19.833" Title="Arduino Leonardo Pro Mini will not begin sketch when connected to BIOS not an OS" Tags="|arduino-leonardo|keyboard|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21091" PostTypeId="2" ParentId="21089" CreationDate="2016-02-25T20:02:50.210" Score="2" Body="&lt;p&gt;Because the computer doesn't have a full OS at POST time any USB keyboards attached to the system have to operate in a special &quot;Boot Keyboard&quot; mode. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Keyboards that implement the USB Boot Keyboard profile specified in the USB Device Class Definition for Human Interface Devices (HID) v1.11 and are explicitly configured to use the boot protocol will interrupt the CPU every time the keyboard is polled even if there is no change in state unless the USB controller overrides this behavior, and are limited to 6-key rollover (6KRO). This profile is intended to allow the BIOS to handle a USB keyboard in the absence of a USB-aware operating system. The recommended profile for keyboards that are not in boot mode in this specification limits keyboards to 6KRO and causes them to respond to an interrupt with a status report at least every half second even if there is no state change in the keyboard unless the USB controller overrides this behavior in order to implement typematic (the function that causes keys to repeat when they are held long enough). However, keyboards in non-boot mode are free to implement an alternative HID profile.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;-- Wikipedia&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since it was not expected that anyone would be using the Leonardo to operate in the BIOS that functionality has never been implemented. The choice was to implement the entire system, which would have left less room for your sketch, or to just implement the parts that the majority of people would find useful (that is keyboard, mouse, joystick, etc) and leave out the extra stuff, leaving as much room for sketches as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They chose the latter, since as I am sure you are well aware: &quot;The needs of the many outweigh the needs of the one&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your rather specific case it may be easiest to butcher an old USB keyboard and work out which pair of inputs to the matrix, when connected together, perform the function you require and design some small interface circuit to allow the Arduino to trigger that function.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-25T20:02:50.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21092" PostTypeId="1" AcceptedAnswerId="21093" CreationDate="2016-02-25T20:36:28.483" Score="0" ViewCount="75" Body="&lt;p&gt;I have accidentally released the magic smoke from the regulator on a digispark board. I did this when I accidentally plugged a circuit into the 5V and the VIn instead of the 5V and Gnd, and then plugged the board into the USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The attiny chip still works - I know because I plugged it in to the USB ,with no circuitry attached, and the uploaded program still runs happily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, is there any possibility that when the magic smoke was released from the regulator, the attiny was also damaged? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, is there any harm in leaving the dead regulator on the board? Or am I better off cutting it off?&lt;/p&gt;&#xA;" OwnerUserId="18709" LastActivityDate="2016-02-25T21:04:14.627" Title="Regulator magic smoke" Tags="|attiny|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21093" PostTypeId="2" ParentId="21092" CreationDate="2016-02-25T21:04:14.627" Score="2" Body="&lt;p&gt;Linear voltage regulators have an internal parasitic diode that shorts the output to the input. You have burned out this diode which has destroyed the regulator, but it is highly unlikely that any other components have been damaged. You can get away with cutting away the legs of the regulator, but complete removal will be difficult due to the large size of the tab connection and will likely result in damage to the other components.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-25T21:04:14.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21094" PostTypeId="1" AcceptedAnswerId="21108" CreationDate="2016-02-25T20:56:00.310" Score="0" ViewCount="4815" Body="&lt;p&gt;Here is my setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to read the GPS data from SKG13BL which is connected to an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GPS seems to be working fine as I could see the green status light blinks after a while (I think it takes time to fix the position).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected TTL of SKG13BL to UNO Digital pins 2 &amp;amp; 3 and connected the ground as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the image of the connection:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QFt2H.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QFt2H.jpg&quot; alt=&quot;Photo of GPS Receiver SKG13BL and Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the TinyGPS test with GPS device sketch to read the data. but I always get something like this, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;**** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   30862 0         116&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   30885 0         116&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   30929 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   30952 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   30985 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   31019 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   31041 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   31086 0         117&lt;br&gt;&#xA;  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** &lt;strong&gt;*   0        0.00   *&lt;/strong&gt;   31109 0         117      &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried swapping the pins, using external power source instead of Arduino's  3.3, but there is no change in the result, any advice would greatly help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2/26&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the pin here to 10 &amp;amp; 11, and using this code &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;TinyGPS gps; // create gps object&#xA;&#xA;long lat,lon; // create variable for latitude and longitude object&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (mySerial.available()) {&#xA;    Serial.write(mySerial.read());&#xA;    //gps.encode(mySerial.read());&#xA;    if(gps.encode(mySerial.read()))&#xA;      { // encode gps data&#xA;      gps.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude&#xA;      // display position&#xA;      Serial.print(&quot;Position: &quot;);&#xA;      Serial.print(&quot;lat: &quot;);Serial.print(lat);Serial.print(&quot; &quot;);// print latitude&#xA;      Serial.print(&quot;lon: &quot;);Serial.println(lon); // print longitude&#xA;      }&#xA;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this only displays the below, &lt;code&gt;lon&lt;/code&gt; and &lt;code&gt;lat&lt;/code&gt; not coming up in the feed even after waiting for an hour. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;$GPRMC,043721.000,A,1301.6666,N,07740.9169,E,0.13,343.86,260216,,,D*61&#xA;  $GPGGA,043722.000,1301.6666,N,07740.9169,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*72 $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37&#xA;  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71&#xA;  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46&#xA;  $GPGSV,4,3,13,27,18,238,12,25,15,087,16,26,13,180,,08,11,268,*7A&#xA;  $GPGSV,4,4,13,11,09,311,20*43&#xA;  $GPRMC,043722.000,A,1301.6666,N,07740.9169,E,0.26,343.86,260216,,,D*64&#xA;  $GPGGA,043723.000,1301.6665,N,07740.9169,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*70 $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37&#xA;  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71&#xA;  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46&#xA;  $GPGSV,4,3,13,27,18,238,12,25,15,087,16,26,13,180,,08,11,268,*7A&#xA;  $GPGSV,4,4,13,11,09,311,20*43&#xA;  $GPRMC,043723.000,A,1301.6665,N,07740.9169,E,0.33,343.86,260216,,,D*62&#xA;  $GPGGA,043724.000,1301.6664,N,07740.9170,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*7E $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37&#xA;  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71&#xA;  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46&#xA;  $GPGSV,4,3,13,27,18,238,,25,15,087,16,26,13,180,,08,11,268,*79&#xA;  $GPGSV,4,4,13,11,09,311,20*43&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updated code on 3/1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one works perfectly and provides the latitude and longitude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you @slash-dev and @altinturk&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;TinyGPS gps; // create gps object&#xA;&#xA;long lat,lon; // create variable for latitude and longitude object&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(57600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (mySerial.available()) {&#xA;&#xA;char c = mySerial.read();&#xA;Serial.write( c );&#xA;if (gps.encode( c ))&#xA;      { // encode gps data&#xA;      gps.get_position(&amp;amp;lat,&amp;amp;lon); // get latitude and longitude&#xA;      // display position&#xA;      Serial.print(&quot;Position: &quot;);&#xA;      Serial.print(&quot;lat: &quot;);Serial.print(lat);Serial.print(&quot; &quot;);// print latitude&#xA;      Serial.print(&quot;lon: &quot;);Serial.println(lon); // print longitude&#xA;      }&#xA;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the output&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;$GPGSA,A,3,14,20,21,18,29,15,10,,,,,,2.59,1.13,2.33*0E&#xA;  $GPGSV,4,1,13,29,63,172,35,40,59,241,34,15,45,039,43,18,44,324,51*7A&#xA;  $GPGSV,4,2,13,21,42,350,46,10,27,284,46,24,27,116,19,14,25,209,17*76&#xA;  $GPGSV,4,3,13,20,24,037,46,193,23,064,39,25,10,180,16,26,08,268,*44&#xA;  $GPGSV,4,4,13,16,01,294,*42&#xA;  $GPRMC,003218.000,A,1301.6703,N,07740.9225,E,0.02,0.00,010316,,,D*6D&lt;br&gt;&#xA;  &lt;strong&gt;Position: lat: 1******8 lon: 7*****42&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="18711" OwnerDisplayName="Ramasubramanian Sabapathy" LastEditorUserId="6936" LastEditDate="2016-03-04T12:10:43.780" LastActivityDate="2016-08-17T06:28:57.917" Title="GPS Receiver SKG13BL + Arduino - Having trouble receiving data" Tags="|arduino-uno|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21095" PostTypeId="1" CreationDate="2016-02-25T22:10:42.743" Score="1" ViewCount="6719" Body="&lt;p&gt;I've nine functions each of type void as follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void zero();&#xA;void one();&#xA;void two();&#xA;void three();&#xA;void four();&#xA;void five();&#xA;void six();&#xA;void seven();&#xA;void eight();&#xA;void nine();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've put all these functions into an array pointer as follow (without any error):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void (*num_func) ();&#xA;num_func functions[] = { zero, one, two, three, four, five, six, seven, eight, nine};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm writing an arduino library and wanting to achieve the same, but after hours of thinking I'm not able to achieve. Please help me how can I accomplish this in a library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="18713" LastEditorUserId="13432" LastEditDate="2016-02-25T22:31:10.457" LastActivityDate="2016-02-27T03:09:41.253" Title="How to write array of functions in arduino library?" Tags="|programming|arduino-mega|c++|c|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="21097" PostTypeId="2" ParentId="21095" CreationDate="2016-02-25T22:35:08.193" Score="1" Body="&lt;p&gt;First you need a header file - let's say lib.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef LIB_H&#xA;#define LIB_H&#xA;&#xA;typedef void (*num_func) ();&#xA;extern num_func functions[];&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then the implementation, lib.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;lib.h&quot;&#xA;&#xA;void zero();&#xA;void one();&#xA;void two();&#xA;void three();&#xA;void four();&#xA;void five();&#xA;void six();&#xA;void seven();&#xA;void eight();&#xA;void nine();&#xA;&#xA;num_func functions[] = { zero, one, two, three, four, five, six, seven, eight, nine};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The functions could be declared as static (if you want to hide them) and they do need implementation. They are only forward declarations above. Below is a snippet of a sketch using the library (assuming that it is within the sketch folder).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;lib.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;  ...&#xA;}&#xA;void loop()&#xA;{&#xA;  ...&#xA;  // Call to the one() function&#xA;  functions[1]();&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-02-25T23:13:47.113" LastActivityDate="2016-02-25T23:13:47.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21098" PostTypeId="1" AcceptedAnswerId="21102" CreationDate="2016-02-25T22:41:30.987" Score="3" ViewCount="94" Body="&lt;p&gt;I have the following problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a pro mini clone, with 328/5V. It was successfully working in my board. I pulled it out of the board, and wanted to update my software. I connected it to my FTDI, arduino was normal by this time. Power on LED was on. I stared uploading, my sketch compiled and started writing. While it was writing, my 3.5 year old daughter who approached me from behind and whom I did not see pulled the Arduino out of FTDI - &quot;what is that nice red light?&quot; Of course writing failed. &#xA;Now, when I connect the arduino to FTDI, it is dead. No LEDs light up, no sync... what to do? Any chance to revive it?&lt;/p&gt;&#xA;" OwnerUserId="18715" LastActivityDate="2016-02-25T23:12:30.170" Title="Arduino Pro Mini" Tags="|programming|uploading|arduino-pro-mini|ftdi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21099" PostTypeId="2" ParentId="17225" CreationDate="2016-02-25T22:42:20.943" Score="1" Body="&lt;p&gt;Definitely a baud rate problem. The GPS is sending at 9600. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use a sketch to receive the data, the SoftwareSerial .begin should be set to 9600. The Serial.begin should be set to a rate higher than 9600, so that the Arduino cannot fall behind in relaying the data to the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this does not solve you problem, please post your sketch and a wiring diagram so we can analyze it further.&lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-25T22:42:20.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21101" PostTypeId="1" AcceptedAnswerId="21360" CreationDate="2016-02-25T22:46:49.453" Score="1" ViewCount="3259" Body="&lt;p&gt;I have an arduino UNO hooked up to a neopixel LED strip with 148 lights.  Most of the time it works fine, but when I upload a program that changes the brightness frequently, particularly when I increase brightness, only the first 8 LEDs continue responding.  The rest get stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example of the kind of code that sets this issue off.  To fix it, I usually have to restart the lights and the arduino and sometimes upload a blank program to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty new to arduino programming so and help would be really appreciated.  Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;FastLED.h&quot;&#xA;&#xA;FASTLED_USING_NAMESPACE &#xA;&#xA;// FAST LED definitions&#xA;#define DATA_PIN    3&#xA;#define LED_TYPE    WS2812B&#xA;#define COLOR_ORDER GRB&#xA;#define NUM_LEDS    148&#xA;&#xA;CRGB leds[NUM_LEDS];&#xA;#define DATA_PIN 3 // Output Pin to Data Line on Strip&#xA;&#xA;int fadeAmount = 5;  &#xA;int brightness = 0;&#xA;&#xA;void setup()&#xA;{&#xA;   FastLED.addLeds&amp;lt;LED_TYPE,DATA_PIN,COLOR_ORDER&amp;gt;(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   for(int i = 0; i &amp;lt; NUM_LEDS; i++ )&#xA;   {&#xA;   leds[i].setRGB(0,255,0);  &#xA;   leds[i].fadeLightBy(brightness);&#xA;  }&#xA;  FastLED.show();&#xA;  brightness = brightness + fadeAmount;&#xA;  // reverse the direction of the fading at the ends of the fade:&#xA;  if(brightness == 0 || brightness == 255)&#xA;  {&#xA;    fadeAmount = -fadeAmount ;&#xA;  }   &#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15299" LastActivityDate="2016-03-10T21:53:47.637" Title="Neopixel led strip stops responding after change in brightness" Tags="|arduino-uno|led|neopixel|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21102" PostTypeId="2" ParentId="21098" CreationDate="2016-02-25T23:12:30.170" Score="2" Body="&lt;p&gt;Check for physical damage! Solder connection of the programming pins to the board was damaged in my case. Resoldering helped!&lt;/p&gt;&#xA;" OwnerUserId="18715" LastActivityDate="2016-02-25T23:12:30.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21104" PostTypeId="2" ParentId="21101" CreationDate="2016-02-25T23:39:39.273" Score="1" Body="&lt;p&gt;It is almost certainly a power issue. The &lt;a href=&quot;https://www.adafruit.com/products/2547&quot; rel=&quot;nofollow&quot;&gt;Adafruit page&lt;/a&gt; about one of those types of Neopixels says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Don't forget, with 256 LEDs, you could use over 15A of current if you turn on all the LEDs on to white (which we really do not recommend because we don't think the flex PCB can handle that much current). Try to keep the current draw at under 5A ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Increasing the brightness increases the current drawn. Do you have a heavy-duty power supply? Are the connecting leads sufficient for (say) 8 amps of current?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;New information based on comments made&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Based on comments by Lorenz I now think it is more likely to be that they are overheating.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have the strip embedded in a picture frame with epoxy resin over it. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That makes it difficult for the ICs to cool down, and LEDs generate heat. If you search for &quot;neopixels heat&quot; you find quite a few matches. Some suggestions made are to use a heat sink or a fan. If this isn't practical for you, then running at a lower PWM rate (ie. not as bright) and not as saturated colour, could help keep the heat down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't want to &quot;cook&quot; one of the early pixels, because each one has to pass the data on to the next one in sequence, so if you lose an early one, you lose everything after it, particularly if you can't get at it to replace one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Postscript regarding heat&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have been testing a NeoPixel with a temperature sensor. Displaying full white (255/255/255) it has reached about 44°C. So clearly it warms up. However this is in the open air with just some sticky-tape holding the sensor onto the LED. According to the spec the chip can operate at up to 80°C, so this is within range. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if the whole thing was sealed in epoxy, then the heat being generated would have much less chance of escaping into the ambient air, and thus would be likely to get a lot hotter.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-10T21:53:47.637" LastActivityDate="2016-03-10T21:53:47.637" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="21107" PostTypeId="1" AcceptedAnswerId="21110" CreationDate="2016-02-26T00:30:07.797" Score="2" ViewCount="4803" Body="&lt;p&gt;I need to update simultaneously all the outputs of a specific port.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am familiar with using micro-processors assembly language. After initializing a port (Data Direction Register), I can write to that port and all outputs will update simultaneously.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino commands  : I am aware of how to configure pins, such as pinMode(pin, mode), to make a pin an output or input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know of the digitalWrite(pin, value) , but this only updates one pin per command.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For timing reasons, I need to update several (same port) outputs without any time delay.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally (using assembly language) , I would keep a register with the data I desire on the output port, and write that register's data to the port.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a command I can use in Arduino to accomplish the same thing?&lt;br&gt;&#xA;If not a single command, what other choices do I have?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use Arduino  micro,  UNO,  but I think the question might be valid for most Arduino&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-02-27T14:35:53.237" Title="How to update multiple outputs simultaneously" Tags="|digital|timing|port-mapping|assembly|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21108" PostTypeId="2" ParentId="21094" CreationDate="2016-02-26T00:30:45.273" Score="1" Body="&lt;p&gt;Seems you are able to receive data properly (according to your the update.) I was using TinyGPS++, an advanced version of TinyGps (&lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;http://arduiniana.org/libraries/tinygpsplus/&lt;/a&gt;), maybe those can help you:&#xA;Try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;LAT=&quot;);  Serial.println(gps.location.lat(), 6);&#xA;Serial.print(&quot;LONG=&quot;); Serial.println(gps.location.lng(), 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;GPS cannot get any data indoors. Put your gps close to a window or better -directly outside. First of everything you will get a date&amp;amp;time data on the output, then number of satellites, then the Lat/lon data. But GPS has to receive data indoors.&#xA;On some chips there is a LED starts blinking once it gets a fix from any satellite. Keep an eye on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realized this small issue when my phone (used for &quot;calibration&quot;) couldn't get a fix by its embedded GPS without any cell/network assistance. You should try if you get any signals where you put your device.&lt;/p&gt;&#xA;" OwnerUserId="16064" LastEditorUserId="16064" LastEditDate="2016-02-27T13:49:22.907" LastActivityDate="2016-02-27T13:49:22.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21109" PostTypeId="2" ParentId="21095" CreationDate="2016-02-26T00:56:36.077" Score="2" Body="&lt;p&gt;This was a bit fiddly to get right. I got inspiration from &lt;a href=&quot;https://isocpp.org/wiki/faq/pointers-to-members#array-memfnptrs&quot; rel=&quot;nofollow&quot;&gt;How do I create and use an array of pointer-to-member-function?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12607&quot; rel=&quot;nofollow&quot;&gt;post about Function pointers / function callbacks / function variables&lt;/a&gt; I modified it to work with class functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class foo {&#xA;&#xA;  public:&#xA;&#xA;   void doAction0 ()&#xA;    {&#xA;      Serial.println (0);&#xA;    }&#xA;&#xA;    void doAction1 ()&#xA;    {&#xA;      Serial.println (1);&#xA;    }&#xA;&#xA;    void doAction2 ()&#xA;    {&#xA;      Serial.println (2);&#xA;    }&#xA;&#xA;    void doAction3 ()&#xA;    {&#xA;      Serial.println (3);&#xA;    }&#xA;&#xA;    void doAction4 ()&#xA;    {&#xA;      Serial.println (4);&#xA;    }&#xA;&#xA;   // typedef for class function&#xA;   typedef void (foo::*GeneralFunction) ();&#xA;&#xA;   // array of function pointers&#xA;    GeneralFunction doActionsArray [5] =&#xA;    {&#xA;      &amp;amp;foo::doAction0, &#xA;      &amp;amp;foo::doAction1, &#xA;      &amp;amp;foo::doAction2, &#xA;      &amp;amp;foo::doAction3, &#xA;      &amp;amp;foo::doAction4, &#xA;    };&#xA;&#xA;};  // end of class foo&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (F(&quot;Starting&quot;));&#xA;&#xA;  // test instance of foo&#xA;  foo bar;&#xA;&#xA;  for (int i = 0; i &amp;lt; 5; i++)&#xA;    {&#xA;    // get member function pointer from array&#xA;    foo::GeneralFunction f = bar.foo::doActionsArray [i];&#xA;    // call the function&#xA;    (bar.*f) ();&#xA;    }  // end of for loop&#xA;&#xA;}  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This compiles OK and prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting&#xA;0&#xA;1&#xA;2&#xA;3&#xA;4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Amended answer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I was wondering why you needed to specify &lt;code&gt;bar&lt;/code&gt; in this line above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    foo::GeneralFunction f = bar.foo::doActionsArray [i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The reason is that the code above had the array as non-static, and thus a copy belonged to each instance of the class. This doesn't make a huge amount of sense, so the modified code below makes the array &lt;code&gt;static&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt;. That is, the array should be the same for every instance of &lt;code&gt;foo&lt;/code&gt; and also never change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modified code below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class foo {&#xA;&#xA;  public:&#xA;&#xA;   void doAction0 ()&#xA;    {&#xA;      Serial.println (0);&#xA;    }&#xA;&#xA;    void doAction1 ()&#xA;    {&#xA;      Serial.println (1);&#xA;    }&#xA;&#xA;    void doAction2 ()&#xA;    {&#xA;      Serial.println (2);&#xA;    }&#xA;&#xA;    void doAction3 ()&#xA;    {&#xA;      Serial.println (3);&#xA;    }&#xA;&#xA;    void doAction4 ()&#xA;    {&#xA;      Serial.println (4);&#xA;    }&#xA;&#xA;   // typedef for class function&#xA;   typedef void (foo::*GeneralFunction) ();&#xA;&#xA;   static const GeneralFunction doActionsArray [5];&#xA;&#xA;};  // end of class foo&#xA;&#xA; // array of function pointers&#xA;const foo::GeneralFunction foo::doActionsArray [5] =&#xA;  {&#xA;    &amp;amp;foo::doAction0, &#xA;    &amp;amp;foo::doAction1, &#xA;    &amp;amp;foo::doAction2, &#xA;    &amp;amp;foo::doAction3, &#xA;    &amp;amp;foo::doAction4, &#xA;  };&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  Serial.println (F(&quot;Starting&quot;));&#xA;&#xA;  // test instance of foo&#xA;  foo bar;&#xA;&#xA;  for (int i = 0; i &amp;lt; 5; i++)&#xA;    {&#xA;    // get member function pointer from array&#xA;    foo::GeneralFunction f = foo::doActionsArray [i];&#xA;    // call the function&#xA;    (bar.*f) ();&#xA;    }&#xA;&#xA;}  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will also save RAM, as the array of function pointers only exists once, not once per instance of the class.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-02-27T03:09:41.253" LastActivityDate="2016-02-27T03:09:41.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21110" PostTypeId="2" ParentId="21107" CreationDate="2016-02-26T00:58:22.710" Score="4" Body="&lt;p&gt;Yes, the ports of an Uno are addressed in C/C++ as PORTB, PORTC, and PORTD respectively, each 8 bits wide. You can read them or assign to them. Other processors' ports have similar names. Of course the pins' port assignments and functions differ from one to the other, which is one reason for providing the single-pin pinMode() and digitalRead(), digitalWrite() functions. But where you need to deal directly with the hardware (and probably don't care about chip-to-chip portability), the registers are exposed with the above symbols.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that most other CPU registers are exposed the same way - the ports' data-direction registers as DDRA, DDRB, DDRC. You may not care about setting them up simultaneously, but if you wanted to make all of your hardware accesses similarly (and save the flash space for the portable pin functions), you could.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a specific command I can use ? Such as Write PortD ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can use the PORTx names like any other C/C++ variable:&lt;br&gt;&#xA;&lt;code&gt;PORTD = 0xFF;&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;PORTD ^= 0x02;&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;if( (PORTD &amp;amp; 0x40) != 0 ){&lt;/code&gt;&lt;br&gt;, for just a couple of examples - just like real C! :-) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: &lt;a href=&quot;http://www.pighixxx.com/test/&quot; rel=&quot;nofollow&quot;&gt;Pighixxx&lt;/a&gt; makes absolutely top-notch pinout diagrams for boards &amp;amp; processors. Here is his diagram for the &lt;a href=&quot;http://www.pighixxx.com/test/portfolio-items/atmega328/?portfolioID=337&quot; rel=&quot;nofollow&quot;&gt;28-pin DIP-packaged AtMega328p&lt;/a&gt; for instance. They're extremely useful when you're working with a chip at the port or board level.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-02-27T14:35:53.237" LastActivityDate="2016-02-27T14:35:53.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21111" PostTypeId="2" ParentId="21107" CreationDate="2016-02-26T01:27:38.127" Score="3" Body="&lt;p&gt;If you need to do more than 8 (especially LOTS more), and timing is very critical, you can use a Serial In, Parallel Out (SIPO) chip, such as the 74HC595 - it also saves a lot of pins on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it, you need 3 pins connected to the Arduino. You send one bit to the chip from the Arduino for each output, then when you have them all set, you toggle the Latch pin - all output pins change at the same time. The chip has 8 outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another advantage of a chip like this is that you can daisy-chain them - with the same 3 pins, you can control as many pins as you like (subject to power availability, of course!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ShiftOut&lt;/a&gt; for more information on how to use them. They are dirt cheap (about US$1.26 each if you buy 10 from AliExpress, shipped to NZ, which is where I am).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-02-26T01:27:38.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21112" PostTypeId="1" AcceptedAnswerId="21113" CreationDate="2016-02-26T04:12:34.050" Score="1" ViewCount="8068" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0Yo2s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0Yo2s.png&quot; alt=&quot;Serial Monitor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Serial Monitor is displaying unreadable characters.  If anybody can give me some insight on why this would be happening please let me know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You.&lt;/p&gt;&#xA;" OwnerUserId="4735" LastEditorUserId="11529" LastEditDate="2016-02-26T15:00:22.703" LastActivityDate="2023-04-26T03:08:47.880" Title="Serial monitor listing unreadable characters" Tags="|arduino-uno|serial|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21113" PostTypeId="2" ParentId="21112" CreationDate="2016-02-26T05:30:43.607" Score="6" Body="&lt;p&gt;Change &lt;code&gt;Serial.write&lt;/code&gt; to &lt;code&gt;Serial.print&lt;/code&gt; (or &lt;code&gt;Serial.println&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;write&lt;/code&gt; writes in binary, which gives you unprintable characters.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-26T05:30:43.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21114" PostTypeId="2" ParentId="13020" CreationDate="2016-02-26T05:56:51.597" Score="2" Body="&lt;p&gt;Pin 0 and 1 are the Hardware Serial of Arduino you cannot use it as the software serial and I also used that code once use pin 2 and 3 its issue regarding the configuration of your XBEE? Check your XBEE configuration XCTU&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-02-26T05:56:51.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21115" PostTypeId="1" CreationDate="2016-02-26T06:16:35.613" Score="1" ViewCount="1239" Body="&lt;p&gt;Proceeding is the relevant part of the code for the problem I'm asking assistance with.  I'm attempting to vary the speed of the robots motors with PWM. The left motor speed can be varied numerical. The right motor fails to move. Any ideas is appreciated. The motor speed code is at the end of the sketch.&#xA;Any assistance is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Below are the symbolic constants. Instead of having to type in a non-sensical pin number each time we want to do something we can write an easy to understand name which represents the pin, the compiler will then replace the names with the numbers&#xA; #define LeftMotorForward 8&#xA; #define LeftMotorBackward 9&#xA; #define LeftMotorSpeed 10&#xA; #define RightMotorForward 6&#xA; #define RightMotorBackward 7&#xA; #define RightMotorSpeed 5&#xA; #define USTrigger 3&#xA; #define USEcho 2&#xA; #define MaxDistance 100&#xA; #define LED 13&#xA;&#xA;&#xA;&#xA;//Here we have created two 'objects', one for the servo and one for the ultrasonic sensor&#xA; Servo servo;&#xA; NewPing sonar(USTrigger, USEcho, MaxDistance);&#xA;&#xA;//Below we are creating unsigned integer variables which we will use later on in the code. They are unsigned as they will only have postive values&#xA; unsigned int duration;&#xA; unsigned int distance;&#xA; unsigned int FrontDistance;&#xA; unsigned int LeftDistance;&#xA; unsigned int RightDistance;&#xA; unsigned int Time;&#xA; unsigned int CollisionCounter;&#xA;&#xA; void setup()                                            //This block happens once on startup&#xA; {&#xA;  Serial.begin(9600);                              //I have included the serial initialize but commented it out, if you want to debug and print information to the serial monitor just uncomment&#xA;&#xA;  //Here we are setting the pin modes. As we will sending out signals from the pins we set them as outputs&#xA;  pinMode(LeftMotorForward, OUTPUT);&#xA;  pinMode(LeftMotorBackward, OUTPUT);&#xA;  pinMode(LeftMotorSpeed, OUTPUT);&#xA;  pinMode(RightMotorForward, OUTPUT);&#xA;  pinMode(RightMotorBackward, OUTPUT);&#xA;  pinMode(RightMotorSpeed, OUTPUT);&#xA;  pinMode(LED, OUTPUT);&#xA;  servo.attach(11);                                    //The servo is attached to pin 4&#xA; }&#xA;&#xA; void loop()                                           //This block repeats itself while the Arduino is turned on&#xA; {&#xA;  servo.write(90);                                    //Rotate the servo to face the front                  &#xA;  scan();                                             //Go to the scan function&#xA;  FrontDistance = distance;                           //Set the variable FrontDistance to the value of the distance returned from the scan function&#xA;  Serial.println(&quot;Front distance = &quot;);&#xA;  Serial.print(distance);&#xA;  if(FrontDistance &amp;gt; 40 || FrontDistance == 0)        //If there is nothing infront of the robot within 40cm or the distance value is 0 (which for the newping libary means no ping was returned) then...&#xA;  {&#xA;   moveForward();                                     //Go to the moveForward function&#xA;  } &#xA;  else                                                //Else (if there is something infront of the robot within 40cm) then...&#xA;  {&#xA;    CollisionCounter = CollisionCounter + 1;&#xA;    moveStop();                                       //Go to the moveStop function&#xA;    navigate();&#xA;  }&#xA; }&#xA;&#xA; void moveForward()                                    //This function tells the robot to go forward &#xA; {&#xA;&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;Moving forward&quot;);&#xA;  //Turn on left motor&#xA;  digitalWrite (LeftMotorBackward, LOW);&#xA;  digitalWrite(LeftMotorForward, HIGH);&#xA;  //set speed&#xA;  analogWrite(LeftMotorSpeed, 100);&#xA;&#xA; // turn on right motor&#xA;  digitalWrite(RightMotorBackward, LOW);&#xA;  digitalWrite(RightMotorForward, HIGH);&#xA;// set speed&#xA;   analogWrite (RightMotorSpeed, 75);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="6936" LastEditDate="2019-06-07T11:44:45.007" LastActivityDate="2019-06-07T11:44:45.007" Title="Speed Control L298 motors" Tags="|arduino-uno|motor|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21116" PostTypeId="2" ParentId="20815" CreationDate="2016-02-26T08:44:03.410" Score="1" Body="&lt;p&gt;What you probably want to track is something more like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;high sound period of highMin to highMax ms &lt;/li&gt;&#xA;&lt;li&gt;low sound period of lowMin to lowMax ms &lt;/li&gt;&#xA;&lt;li&gt;high sound period of highMin to highMax ms &lt;/li&gt;&#xA;&lt;li&gt;low sound period of at least lowDone ms (no max needed)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anything not meeting those time bounds is not two claps, reset state and timers.  If you get to the end of the fourth step, accept as two claps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not tested timing of claps to estimate the periods needed; you need to tweak that with the hardware you are actually using; for example, different microphones may ring for different times after a sharp clap impulse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;States could be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;waiting for start of first clap (sample until &gt; threshold) &lt;/li&gt;&#xA;&lt;li&gt;waiting for end of first clap (sample until &amp;lt; threshold or timeout)&lt;/li&gt;&#xA;&lt;li&gt;waiting for start of second clap (sample until &gt; threshold or timeout)&lt;/li&gt;&#xA;&lt;li&gt;waiting for end of second clap (sample until &amp;lt; threshold or timeout)&lt;/li&gt;&#xA;&lt;li&gt;got second clap&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2016-02-26T08:44:03.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21117" PostTypeId="2" ParentId="19832" CreationDate="2016-02-26T09:05:48.297" Score="3" Body="&lt;p&gt;So you are asking how to use an Arduino Pro Mini as a smart peripheral connected to a NodeMCU master, without making use of the hardware serial port on the latter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, this is either going to operate slowly enough that you can guarantee reception, or you will need to use some kind of flow control or acknowledgement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One question is whether the APM can always receive at any time, or whether it has to do things which would cause it to not respond for some while and possibly lose data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware I2c or SPI, with a software flow control protocol using additional pins, are probably your best bets if you cannot use async serial.  For example the APM sets OK2SEND high when it's ready to receive (this is an APM output pin connected to a NodeMCU input pin).  When NodeMCU detects this high, it writes to I2C and then sets HAVESENT high.  When the APM detects &amp;amp; processes incoming data as I2C slave, it sets OK2SEND low.  NodeMCU sees OK2SEND low (ack'ing the byte) and sets HAVESENT low.  APM detects HAVESENT low which completes the handshake.  When APM is ready for another byte, it sets OK2SEND high again.  etc.  Variants could send more than one byte per handshake, if performance needs that; APM asserting OK2SEND would be contracting to handle that number of bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can guarantee that the APM will respond quickly enough to interrupts, you could use an interrupt driven I2C slave system on it, and simplify the above.  The APM could be like a dedicated I2C peripheral, albeit a slow one.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastActivityDate="2016-02-26T09:05:48.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21118" PostTypeId="1" AcceptedAnswerId="21120" CreationDate="2016-02-26T10:10:16.843" Score="-1" ViewCount="250" Body="&lt;p&gt;I am new to Arduino and bit blur on how it works. lack of info on the net about it. please help me with these questions!&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Does Arduino due allow you to upload a program on programming port and then run it through Native port?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I work with SerialUSB instance in Programming port?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18732" LastActivityDate="2016-02-26T10:24:13.480" Title="Programing uploading to Arduino due" Tags="|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21119" PostTypeId="1" AcceptedAnswerId="21126" CreationDate="2016-02-26T10:13:38.723" Score="1" ViewCount="336" Body="&lt;p&gt;Can I upgrade my ESP8266 firmware by connecting the pins in Arduino Uno, or do I still need a USB UART to Serial?&lt;/p&gt;&#xA;" OwnerUserId="18734" LastEditorUserId="6936" LastEditDate="2016-03-16T00:42:29.070" LastActivityDate="2016-04-15T01:31:04.683" Title="ESP8266 Firmware Upgrade" Tags="|esp8266|firmware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21120" PostTypeId="2" ParentId="21118" CreationDate="2016-02-26T10:24:13.480" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Does Arduino due allow you to upload a program on programming port and then run it through Native port?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You don't run a program &lt;em&gt;through&lt;/em&gt; anything. You run it &lt;em&gt;on&lt;/em&gt; the Due. Where you send text to is entirely up to you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I work with SerialUSB instance in Programming port?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have no idea what you are asking there. Both the Programming port and Native port are capable of being used as virtual USB COM ports. They use CDC/ACM. One is directly connected to the SAM3X chip's USB peripheral, and the other is connected to the SAM3X's UART interface via another microcontroller as a USB to UART converter.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-26T10:24:13.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21121" PostTypeId="1" CreationDate="2016-02-26T11:36:10.320" Score="2" ViewCount="266" Body="&lt;p&gt;I want to implement an Arduino module with some sensors and send the info through WiFi to a server. I'm looking for the best board or component combination to make this. What is the best board or solution you would use in my case? Maybe Arduino Yun or Intel Edison Kit for Arduino...¿?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've developed a sensor module with Redbear Blend board which use Bluetooth to communicate with an Android app to send sensor data, but now looking for WiFi connection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry if it's a stupid question, I'm new in this Arduino world. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="18736" LastActivityDate="2016-02-26T11:46:55.147" Title="What Arduino board with WiFi should I choose" Tags="|shields|wifi|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21122" PostTypeId="2" ParentId="21121" CreationDate="2016-02-26T11:46:55.147" Score="3" Body="&lt;p&gt;I'd recommend ESP8266 (model 07) based board. &#xA;&lt;a href=&quot;https://i.stack.imgur.com/QSZWO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QSZWO.png&quot; alt=&quot;ESP8266 model 07&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can be programmed the same way as other Arduinos&lt;/li&gt;&#xA;&lt;li&gt;Cheap&lt;/li&gt;&#xA;&lt;li&gt;Enough storage for code&lt;/li&gt;&#xA;&lt;li&gt;Fairly low power&lt;/li&gt;&#xA;&lt;li&gt;Large community (more code examples and better library support)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-02-26T11:46:55.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21123" PostTypeId="2" ParentId="21047" CreationDate="2016-02-26T12:32:56.287" Score="2" Body="&lt;p&gt;&lt;s&gt;Arduino cannot run a web server so it is not possible to do what you want with just using an Arduino board?.&lt;/s&gt;&#xA;It seems we can run a web server, look at the answer by @Nick Gammon below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using a wifi shield and connecting to a local or public web server where your page is hosted you should be able to to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't expect to load a full fledged page on an Arduino you have to try posting a few post and get requests to get this working. It will look like a terminal based login.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the control page you are trying to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are ok with spending more money try using a Raspberry pi + Arduino combination.&lt;/p&gt;&#xA;" OwnerUserId="18738" LastEditorUserId="18738" LastEditDate="2016-03-14T09:03:26.870" LastActivityDate="2016-03-14T09:03:26.870" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21124" PostTypeId="1" CreationDate="2016-02-26T14:18:10.100" Score="1" ViewCount="744" Body="&lt;p&gt;Is there Arduino shields with blocks of 4 pins that you can plug your servos into and use the fourth pin as signal pin to the Arduino Mega board?&lt;/p&gt;&#xA;" OwnerUserId="16844" LastEditorUserId="11529" LastEditDate="2016-02-26T14:58:54.590" LastActivityDate="2016-02-26T14:58:54.590" Title="Sensor/servo shield for Arduino Mega" Tags="|arduino-mega|shields|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21125" PostTypeId="2" ParentId="21124" CreationDate="2016-02-26T14:34:44.047" Score="1" Body="&lt;p&gt;Do you mean something like a &lt;a href=&quot;https://arduino-info.wikispaces.com/SensorShield#SSM&quot; rel=&quot;nofollow noreferrer&quot;&gt;sensor shield&lt;/a&gt;? They have three pins (Vcc, GND, signal), not four (because servos have three pins), but they are designed for connecting a large number of servos &lt;a href=&quot;https://i.stack.imgur.com/60Mf8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/60Mf8.jpg&quot; alt=&quot;Arduino Mega sensor shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These can be found easily and cheaply all over the internet.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-02-26T14:34:44.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21126" PostTypeId="2" ParentId="21119" CreationDate="2016-02-26T15:24:03.090" Score="1" Body="&lt;p&gt;Looking at the schematic of arduino UNO &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; you can see that Pin 0 and Pin 1 are connected to the same line of RX TX of the ATMEGA8U2. So in theory (and assuming the ATMEGA8U2 behaves like any usb to uart IC) if you remove or disable the ATMEGA328P, your arduino should behave like any cheap usb to serial. The way you can &quot;disable&quot; ATMEGA328P is by setting it in constant reset mode as explained &lt;a href=&quot;http://www.princetronics.com/arduino-uno-as-usb-to-serial-ttl-converter/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By manually reseting and setting the esp into flashing mode, you should be able to upload the new firmware to it from arduino IDE for example by selecting the ESP device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Two notes on this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1&lt;/strong&gt; - The TX line of the ATMEGA8U2 is the marked RX on arduino Uno board and RX line of the ATMEGA8U2 is the marked to TX on arduino Uno board. That means your ESP RX should connect to pin 0 on arduino and TX of ESP should connect to pin 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt; - You might need voltage level conversion on pin 0 as ESP is a 3.3V device although in schematic there is 1K resistor in that line&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-02-26T15:24:03.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21127" PostTypeId="1" CreationDate="2016-02-26T15:52:39.293" Score="2" ViewCount="105" Body="&lt;p&gt;I have a Micro (original) and I am (trying to) using it under windows XP.&#xA;I was successful in installing its drivers (by swithching to ad Admin account) and uploading sketches to it, no problem. Even when I switched to my limited account, I was able to upload new sketches without error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everytime I reboot my computer, as soon as I connect the Micro to the usb port, I get a &quot;New hardware found&quot; popup window from Windows. If I ignore the window I do not see the board in Arduino's IDE. If I choose to install the drivers (by loggin in that window as an admin and then fetching them from the Arduino folder) I end up seeing the board, selecting the COM port and then when compiling, getting the dreadful&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: butterfly_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I press the reset button I get the &quot;Found new hardware window&quot; again and the cycle repeats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it work again I have to log off, log in in an admin user account, and install the friggin drivers from there. After that, if I log off and enter into my limited account, I can see board, port and I can finally upload my sketches (or at least that was the case the last two times).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it supposed to work this way?&#xA;Can I make it work like a Nano: install drivers &lt;strong&gt;only once&lt;/strong&gt; and then just use the board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS&#xA;I have to mention that I happen to have 5 compatible Nanos with a ch340G chipset that work like a charm (and cost one tenth of the Micro). I installed the drivers ONCE and forgot about that.&#xA;I also happen to have a keyboard and a mouse, and they do not require me to install their drivers every time I plug the USB connector off.&#xA;Why is the Micro misbehaving this way?&lt;/p&gt;&#xA;" OwnerUserId="8506" LastActivityDate="2016-02-26T15:52:39.293" Title="Micro + restricted user Win XP = avrdude: butterfly_recv(): programmer is not responding" Tags="|arduino-micro|installation|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21128" PostTypeId="2" ParentId="21094" CreationDate="2016-02-26T15:58:25.307" Score="3" Body="&lt;p&gt;You are consuming the received characters with the debug print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(mySerial.read());&#xA;//gps.encode(mySerial.read());&#xA;if(gps.encode(mySerial.read()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char c = mySerial.read();&#xA;Serial.write( c );&#xA;if (gps.encode( c ))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;SoftwareSerial&lt;/code&gt; is a real CPU-killer.  Try &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoSWSerial&lt;/a&gt; instead.  It's much more efficient and reliable.  Sometimes other interrupts, like &lt;code&gt;Serial.print&lt;/code&gt;, can cause &lt;code&gt;SoftwareSerial&lt;/code&gt; to be unreliable.  Echoing the received characters may be enough to cause characters to be lost.  NeoSWSerial is not nearly as susceptible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And while you're at it, take a look at another library I wrote, &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt;.  It's the fastest and smallest library out there, especially when you configure it to only parse the fields and messages that you use.  For example, if you only need lat/lon, disable all the other fields (time, alt, speed, sats, etc.) and all the other messages (just RMC, no GGA, no GSA, no GSV).  Saves lots of RAM and CPU time!&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-02-26T15:58:25.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21129" PostTypeId="1" AcceptedAnswerId="21148" CreationDate="2016-02-26T16:28:39.183" Score="2" ViewCount="6711" Body="&lt;p&gt;I want to send a JSON string over serial from arduiono device to my computer. The JSON string contains a sensor value array. To fill this array I use String.concat(&quot;value&quot;) function. But If I have more than 100 values I get the JSON string with an empty array and an error message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[],&quot;landscape&quot;: PUF}&#xA;VMDPE_1|3147_VMDPE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there any other way to send more than 100 values in one message? The arduino device is running with a battery and the communication is wireless. So I want to save energy and reduce the send interval. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading the answers I updated my sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;{\&quot;deviceID\&quot;:\&quot;ZB_ROUTER_1\&quot;,&quot;);&#xA;    Serial.print(&quot;\&quot;sensorID\&quot;:\&quot;MMA8451\&quot;,&quot;);&#xA;    Serial.print(&quot;\&quot;sensorType\&quot;:\&quot;accelerator\&quot;,&quot;);    &#xA;&#xA;    Serial.print(&quot;\&quot;aX\&quot;:[&quot;);&#xA;    for (int i = 0; i &amp;lt; samples; i++)&#xA;    {&#xA;        if(i != 0)&#xA;        {&#xA;            Serial.print(&quot;,&quot;);&#xA;        }&#xA;&#xA;        Serial.print(xArray[i]);&#xA;    }   &#xA;    Serial.print(&quot;],&quot;);&#xA;&#xA;    Serial.print(&quot;\&quot;aY\&quot;:[&quot;);&#xA;    for (int i = 0; i &amp;lt; samples; i++)&#xA;    {&#xA;        if(i != 0)&#xA;        {&#xA;            Serial.print(&quot;,&quot;);&#xA;        }&#xA;&#xA;        Serial.print(yArray[i]);&#xA;    }&#xA;    Serial.print(&quot;],&quot;);&#xA;&#xA;    Serial.print(&quot;\&quot;aZ\&quot;:[&quot;);&#xA;    for (int i = 0; i &amp;lt; samples; i++)&#xA;    {&#xA;        if(i != 0)&#xA;        {&#xA;            Serial.print(&quot;,&quot;);&#xA;        }&#xA;&#xA;        Serial.print(zArray[i]);&#xA;    }&#xA;    Serial.print(&quot;],&quot;);&#xA;&#xA;    Serial.print(&quot;\&quot;landscape\&quot;:\&quot;&quot;);&#xA;    Serial.print(orientation);&#xA;    Serial.println(&quot;\&quot;}&quot;);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the xArray, yArray and zArray, there are 50 double values stored. One double value needs 4B. So that shouldn't be too much. But there are problems when I receive the JSON string on my computer: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[-1.17,-1.31,-1.26,-1.25,-1.16,-1.09,-1.40,-0.91,-0.94,-0.97,-1.39,-1.06,-0.91,-0.75,-0.78,-0.83,-0.72,-0.62,-0.74,-0.53,-0.82,-0.86,-0.84,-0.79,-0.79,-0.76,-0.83,-0.82,-0.97,-1.07,-0.92,-0.87,-0.97,-1.20,-1.51,-1.53,-1.82,-0.99,-1.04,-0.41,-0.54,-0.27,-0.24,-0.08,-0.02,-0.63,-0.{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[0.16,-0.04,-0.18,-0.03,0.01,-0.17,-0.10,-0.30,-0.31,-0.21,-0.16,-0.16,-0.15,-0.19,-0.17,-0.17,-0.17,-0.18,-0.16,-0.17,-0.17,-0.20,-0.18,-0.16,-0.17,-0.16,-0.15,-0.13,-0.20,-0.19,0.37,-0.88,-0.20,-0.05,-0.12,-0.21,-0.20,-0.17,-0.17,-0.17,-0.17,-0.17,-0.19,-0.17,-0.19,-0.16,-0.18,-0.17,-0.18,-0.17],&quot;aY&quot;:[9.80,8.63,8.37,9.05,9.19,8.83,9.01,9.69,8.42,7.94,7.72,7.83,8.43,8.82,9.24,9.21,8.79,8.60,8.39,8.44,8.61,8.77,8.87,8.76,8.66,8.59,8.54,8.73,8.879,8.73,8.66,8.60,8.61,8.68,8.71,8.76,8.71,8.66,8.60,8.63,8.69,8.71],&quot;aZ&quot;:[-4.81,-4..28,-4.02,-4.02,-4.29,-4.49,-4.67,-4.63,-4.46,-4.32,-4.28,-4.38,-4.42,-4.52,-4.58,-4-4.52,-4.52,-4.42,-4.39,-4.34,-4.40,-4.47,-4.51,-4.47,-4.44,-4.38],&quot;landscape&quot;:&quot; PDB{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[-0.18,-0.17,-0.19,-0.20,-0.18,-0.17,-0.18,-0.19,-0.19,-0.20,-0.17,-0.18,-0.17,-0.18,-0.16,-0.18,-0.18,-0.18,-0.17,-0.16,-0.19,-0.18,-0.17,-0.17,-0.16,-0.18,-0.17,-0.18,-0.18,-0.18,-0.16,-0.19,-0.17,-0.16,-0.17,-0.18,-0.17,-0.17,-0.17,-0.16,-0.17,-0.19,-0.18,-0.18,-0.17,-0.18,-0.17,-0.18,-0.17,-0.18],&quot;aY&quot;:[8.67,8.68,8.69,8.68,8.68,8.68,8.66,8.68,8.69,8.69,8.69,8.67,8.69,8.70,8.68,8.67,8.68,8.69,8.69,8.68,8.67,8.69,8.69,8.70,8.68,8.66,8.67,8.67,66,8.76,8.80,8.98,8.99,8.76,8.46,8.37,8.55,8.71,8.80,8.85,8.74,8.59,8.58,8.64,8.70,8.44,-4.43,-4.43,-4.44,-4.42,-4.43,-4.43,-4.43,-4.42,-4.44,-4.43,-4.44,-4.43,-4.41,-44.13,-4.20,-4.44,-4.58,-4.68,-4.60,-4.41,-4.31,-4.29,-4.40,-4.50,-4.52,-4.48,-4.41,-{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[-0.18,-0.19,-0.22,-0.15,-0.15,-0.19,-0.23,-0.13,-0.16,-0.21,-0.20,-0.17,-0.15,-0.10,-0.16,-0.18,-0.24,-0.17,-0.12,-0.20,-0.28,-0.20,-0.13,-0.19,-0.21,-0.17,-0.18,-0.20,-0.19,-0.17,-0.17,-0.17,-0.17,-0.15,-0.18,-0.16,-0.18,-0.19,-0.18,-0.16,-0.17,-0.18,-0.19,-0.17,-0.19,-0.18,-0.17,-0.16,-0.17,-0.17],&quot;aY&quot;:[8.67,8.55,8.61,8.73,8.82,8.73,8.66,8.54,8.54,8.60,8.67,8.60,8.77,8.88,8.79,8.57,8.60,8.51,8.79,8.72,8.83,8.72,8.66,8.68,8.79,8.76,8.67,8.58,75,8.78,8.63,8.63,8.70,8.79,8.77,8.72,8.71,8.67,8.67,8.66,8.70,8.70,8.70,8.69,8.66,87,-4.47,-4.45,-4.32,-4.36,-4.31,-4.41,-4.30,-4.37,-4.46,-4.42,-4.20,-4.39,-4.49,-4.4.40,-4.35,-4.36,-4.39,-4.41,-4.43,-4.40,-4.41,-4.39,-4.40,-4.40,-4.41,-4.42,-4.44,-4{&quot;deviceID&quot;:&quot;ZB_ROUTER_1&quot;,&quot;sensorID&quot;:&quot;MMA8451&quot;,&quot;sensorType&quot;:&quot;accelerator&quot;,&quot;aX&quot;:[-0.19,-0.18,-0.18,-0.17,-0.17,-0.18,-0.18,-0.17,-0.19,-0.18,-0.18,-0.17,-0.17,-0.17,-0.18,-0.18,-0.18,-0.18,-0.20,-0.18,-0.16,-0.17,-0.17,-0.18,-0.18,-0.17,-0.18,-0.19,-0.17,-0.19,-0.19,-0.19,-0.17,-0.18,-0.16,-0.18,-0.18,-0.18,-0.19,-0.20,-0.18,-0.17,-0.17,-0.17,-0.18,-0.22,-0.18,-0.17,-0.17,-0.17],&quot;aY&quot;:[8.69,8.68,8.69,8.68,8.69,8.68,8.69,8.70,8.69,8.69,8.70,8.68,8.69,8.69,8.70,8.70,8.69,8.67,8.66,8.62,8.73,8.80,8.79,8.75,8.68,8.57,8.60,8.66,8,8.67,8.66,8.69,8.62,8.67,8.76,8.75,8.71,8.71,8.70,8.66,8.67,8.66],&quot;aZ&quot;:[-4.43,-4.4-4.41,-4.40,-4.41,-4.42,-4.43,-4.44,-4.47,-4.36,-4.30,-4.30,-4.39,-4.45,-4.51,-4.52,,-4.49,-4.42,-4.35,-4.32,-4.37,-4.38,-4.41,-4.42,-4.46,-4.43],&quot;landscape&quot;:&quot; PDB&quot;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sometimes there is &quot;aZ&quot; missing, sometimes I get wired array values like &lt;code&gt;8.83.2&lt;/code&gt; (values with two &quot;.&quot;). Do I have to many &lt;code&gt;Serial.print&lt;/code&gt; operations? The sending interval is 500ms.&lt;/p&gt;&#xA;" OwnerUserId="16920" LastEditorUserId="16920" LastEditDate="2016-02-27T11:02:19.227" LastActivityDate="2018-03-31T11:47:33.283" Title="Send multiple sensor values over serial" Tags="|serial|sensors|string|accelerometer|wireless|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21130" PostTypeId="2" ParentId="21115" CreationDate="2016-02-26T16:34:20.993" Score="1" Body="&lt;p&gt;First try commenting out the &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Servo servo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line, and all other bits using the servo.  If it works then there's your problem - use the Mega possibly as this allows more PWM outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't work with the Servo bits removed, then report back and include the Arduino model you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-02-26T16:34:20.993" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21131" PostTypeId="2" ParentId="21129" CreationDate="2016-02-26T17:11:12.507" Score="7" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any other way to send more than 100 values in one message?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. Don't use String. Don't use &lt;code&gt;concat()&lt;/code&gt;. Just print each bit as a separate &lt;code&gt;Serial.print()&lt;/code&gt; function call.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-26T17:11:12.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21132" PostTypeId="2" ParentId="21129" CreationDate="2016-02-26T17:14:25.347" Score="2" Body="&lt;p&gt;Maybe avoid doing the dynamic string manipulations?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;{\&quot;deviceID\&quot;:\&quot;ZB_ROUTER_1\&quot;,\&quot;sensorID\&quot;:\&quot;MMA8451\&quot;,\&quot;sensorType\&quot;:\&quot;accelerator\&quot;,\&quot;aX\&quot;:[&quot;);&#xA;for(i=0; i &amp;lt;10000; i++){ &#xA;   if (! i==0) Serial.print(',');&#xA;   Serial.print(i);&#xA;}&#xA;Serial.print(&quot;],\&quot;landscape\&quot;: PUF} VMDPE_1|3147_VMDPE&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-26T17:14:25.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21133" PostTypeId="2" ParentId="21047" CreationDate="2016-02-26T17:41:23.040" Score="1" Body="&lt;p&gt;Have you tried to change Arduino Uno board to Arduino Yun board?&#xA;Yun has a Linux distribution onboard and you can easy configure a web page to control physical objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here some examples:&lt;/strong&gt;&#xA;&lt;a href=&quot;http://scuola.arduino.cc/lesson/b4EoRkV/Arduino_Yn_Intro_to_web_server&quot; rel=&quot;nofollow&quot;&gt;http://scuola.arduino.cc/lesson/b4EoRkV/Arduino_Yn_Intro_to_web_server&lt;/a&gt;&#xA;&lt;a href=&quot;https://github.com/mat-lo/yun-examples&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mat-lo/yun-examples&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18744" LastActivityDate="2016-02-26T17:41:23.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21135" PostTypeId="1" AcceptedAnswerId="21143" CreationDate="2016-02-26T21:59:40.470" Score="1" ViewCount="282" Body="&lt;p&gt;I'm testing the &lt;strong&gt;SN76489AN&lt;/strong&gt; chip with Arduino and I'm able to play the 3 tones I want etc BUT I don't understand why the READY pin is not working? The datasheet says the pin goes high when the chip is ready and low when it's busy with processing a command. But the &lt;strong&gt;READY pin is always low!&lt;/strong&gt; I've got 2 brand new pieces of the chip and they both act this way. I've even tried to pull-up this pin but it didn't help. I see everyone is just using &lt;code&gt;delayMicroseconds&lt;/code&gt; in their examples, so I guess it is a common problem but it's just strange... Is it a bug in the chip or what? Does anyone know?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2021-07-19T02:26:15.250" Title="SN76489 - Ready pin not working?" Tags="|audio|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21137" PostTypeId="1" AcceptedAnswerId="21257" CreationDate="2016-02-26T22:53:39.907" Score="16" ViewCount="18521" Body="&lt;p&gt;I want to write a sketch that can be compiled on different Arduino boards.&#xA;I want to display on the PC which board is currently connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the user connects the PC via USB cable to the Arduino/Teensy board in which runs my sketch and my sketch tells the PC via Serial which board is connected. On the PC runs my C# application which receives this data and displays it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I need the board that has been selected when the sketch has been compiled:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cd3oZ.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cd3oZ.png&quot; alt=&quot;Arduino Board selector&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the code on &lt;a href=&quot;https://github.com/backupbrain/ArduinoBoardManager&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/backupbrain/ArduinoBoardManager&lt;/a&gt;&#xA;but it does not give correct results (apart from the fact that several boards are missing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here a snippet from the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t BOARD_MICRO= 0x04;&#xA;&#xA;....&#xA;#elif defined(__AVR_Atmega32U4__) // Yun 16Mhz, Micro, Leonardo, Esplora&#xA;  static const uint8_t BOARD = 0x04;&#xA;  static const uint8_t NUM_BITS = 8;&#xA;  static const uint16_t CPU = __AVR_Atmega32U4__;&#xA;  static const unsigned long SRAM_SIZE = 2500;&#xA;  static const unsigned long EEPROM_SIZE = 1000;&#xA;  static const unsigned long FLASH_SIZE = 32000;&#xA;#elif defined(.....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this code gives the same result (BOARD = 0x04 = Micro) for Yun 16MHz, Micro, Leonardo y Esplora.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to get in my C code exactly the string that the user has selecetd in the menu of the Arduino compiler?&lt;/p&gt;&#xA;" OwnerUserId="18754" OwnerDisplayName="Elmue" LastEditorUserId="18754" LastEditDate="2016-02-29T14:17:02.017" LastActivityDate="2023-09-14T17:15:47.307" Title="Arduino: How to get the board type in code" Tags="|c|" AnswerCount="6" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21138" PostTypeId="2" ParentId="21137" CreationDate="2016-02-26T23:40:43.277" Score="0" Body="&lt;p&gt;The exact names in the menu come from boards.txt file in your Arduino IDE (Arduino\hardware\arduino\avr\boards.txt). I think you would have to parse the file by yourself and find the detected board there.&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-02-26T23:40:43.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21140" PostTypeId="2" ParentId="20724" CreationDate="2016-02-27T00:08:42.467" Score="-1" Body="&lt;p&gt;See if this answers your question:&#xA;&lt;a href=&quot;https://www.hackster.io/charifmahmoudi/arduino-mkr1000-getting-strarted-08bb4a&quot; rel=&quot;nofollow&quot;&gt;https://www.hackster.io/charifmahmoudi/arduino-mkr1000-getting-strarted-08bb4a&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, go to your Board Manager (this happened to me too) and search MKR1000. There should be another install to do. Install that one and you should be good.&lt;/p&gt;&#xA;" OwnerUserId="18756" LastActivityDate="2016-02-27T00:08:42.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21141" PostTypeId="1" CreationDate="2016-02-27T05:11:21.770" Score="1" ViewCount="1137" Body="&lt;p&gt;I was following a tutorial similar to this:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ShiftOut&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ShiftOut&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, an array of 8 LEDs that lit up accordingly to the binary representation of a number, which was given in a loop from 0 to 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when invoked shiftOut() over certain numbers (such as 5, 9 or 13), the LEDs didn't lit as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I even tried replacing the IC, but what finally solved this issue was to disconnect IC's pin 8 (GND) and let only pin 13 (OE) connected to Arduino's ground pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Does anyone know the reason this strange behavior happens on 595 IC?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a video showing the circuit finally working (without IC's GND pin connected): &lt;a href=&quot;https://www.youtube.com/watch?v=NGfpk-kjemo&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=NGfpk-kjemo&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18758" LastActivityDate="2016-03-29T23:07:04.767" Title="Strange behavior on 74HC595 Shift Register IC when its GND pin is used" Tags="|shift-register|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21142" PostTypeId="2" ParentId="21115" CreationDate="2016-02-27T06:45:15.547" Score="0" Body="&lt;p&gt;I commented all references to servo, the same results. Comment out the servo code doesn't seem to make a difference. What's going on is when the speed is numerically controlled the motor speed varies. At 50 the right motors slows down and the left motor HALTS, Not sure what's going on.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//This function tells the robot to go forward &#xA;int value;&#xA;for(value = 0 ; value &amp;lt;= 75; value+=5)&#xA;    //if value is &amp;lt;=50 left motor does not spin. &amp;gt;75 both motors turn&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.println(&quot;Moving forward&quot;);&#xA;    analogWrite(LeftMotorSpeed, value);//int value has no effect on speed&#xA;    analogWrite(RightMotorSpeed, value);// same as LeftMotor)&#xA;&#xA;    digitalWrite(LeftMotorBackward, LOW);&#xA;    digitalWrite(LeftMotorForward, HIGH);&#xA;    digitalWrite(RightMotorBackward, LOW);&#xA;    digitalWrite(RightMotorForward, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="11548" LastEditDate="2018-05-01T16:00:39.140" LastActivityDate="2018-05-01T16:00:39.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21143" PostTypeId="2" ParentId="21135" CreationDate="2016-02-27T08:53:41.330" Score="2" Body="&lt;p&gt;The READY signal is &lt;a href=&quot;https://en.wikipedia.org/wiki/Open_collector&quot; rel=&quot;nofollow&quot;&gt;open-collector&lt;/a&gt;. It will therefore require a pullup-resistor. Test circuit in datasheet shows a 2 kohm resistor. You could try with that. Alternatively use the internal pullup resistor on the input pin but this may be too large (weak).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-27T08:53:41.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21144" PostTypeId="2" ParentId="13830" CreationDate="2016-02-27T09:49:36.237" Score="2" Body="&lt;p&gt;I've built MotioSuit, a mocap suit based on the BNO055 which currently has 9 sensors but could go up to 18.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://hackaday.io/project/9266-motiosuit&quot; rel=&quot;nofollow&quot;&gt;https://hackaday.io/project/9266-motiosuit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor board and library are open-source and documented in the link, I hope it helps! &lt;/p&gt;&#xA;" OwnerUserId="18762" LastEditorUserId="18762" LastEditDate="2016-02-27T10:28:40.543" LastActivityDate="2016-02-27T10:28:40.543" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21145" PostTypeId="1" CreationDate="2016-02-27T10:21:05.837" Score="0" ViewCount="512" Body="&lt;p&gt;Sorry, im a beginner, i tried to program an automatic doorlock using sms. But, I dont understand what happen with this error, what should I do? Add library? The error said that Pstring wasnt declared, but i dont know how to declare this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &quot;SIM900.h&quot;&#xA;#include &quot;sms.h&quot;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;#include &quot;sms.h&quot;&#xA;&#xA;SMSGSM sms;&#xA;boolean started=false;&#xA;char buffer[160];&#xA;char smsbuffer[160];&#xA;char n[20];&#xA;int pintu=5;&#xA;int buttonState;&#xA;int lastButtonState = LOW;&#xA;long lastDebounceTime = 0;&#xA;long debounceDelay = 50;&#xA;boolean st=false;&#xA;int buzzer=6;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(pintu,OUTPUT);&#xA;  pinMode(buzzer,OUTPUT);&#xA;&#xA;  digitalWrite(pintu,LOW);&#xA; if (gsm.begin(9600))&#xA; {&#xA;  started=true; &#xA;   digitalWrite(buzzer,HIGH);&#xA;   delay(100);&#xA;   digitalWrite(buzzer,LOW);&#xA;   delay(100);&#xA;   digitalWrite(buzzer,HIGH);&#xA;   delay(100);&#xA;   digitalWrite(buzzer,LOW);&#xA;   delay(100);&#xA;   digitalWrite(buzzer,HIGH);&#xA;   delay(100);&#xA;   digitalWrite(buzzer,LOW);&#xA;   delay(100);&#xA;  }&#xA;   if(started)&#xA;  {&#xA;   delsms();&#xA;   sms.SendSMS(&quot;08970869443&quot;,&quot;Pintu SMS Menyala&quot;);&#xA;  }&#xA;  else{digitalWrite(buzzer,HIGH); delay(2000); digitalWrite(buzzer,LOW);&#xA;  }&#xA;&#xA;&#xA;   }&#xA;&#xA;   void loop()&#xA;   {&#xA;&#xA;   int pos=0;&#xA;  if (gsm.begin(9600))&#xA;  {&#xA;  if (started){&#xA;  pos=sms.IsSMSPresent(SMS_ALL);&#xA;  if(pos)&#xA;  {&#xA;   sms.GetSMS(pos,n,smsbuffer,100);&#xA;   delay(2000);&#xA;    if(!strcmp(smsbuffer,&quot;bukapintu&quot;))&#xA;    {&#xA;      PString str(buffer, sizeof(buffer));&#xA;    str.begin();&#xA;    str.print(&quot;Pintu Dibuka&quot;);&#xA;    digitalWrite(pintu,HIGH);&#xA;   // String a=str&#xA;    sms.SendSMS(n,buffer);&#xA;    }&#xA;    if(!strcmp(smsbuffer,&quot;tutuppintu&quot;))&#xA;    {&#xA;      PString str(buffer, sizeof(buffer));&#xA;    str.begin();&#xA;    str.print(&quot;Kunci Pintu Ditutup&quot;);&#xA;    digitalWrite(pintu,LOW);&#xA;   // String a=str&#xA;    sms.SendSMS(n,buffer);&#xA;    }&#xA;    delsms();&#xA;   }&#xA;   }&#xA;   }&#xA;   }&#xA;&#xA;   void delsms()&#xA;   {&#xA;   for (int i=0; i&amp;lt;10; i++)&#xA;  {  &#xA;     int pos=sms.IsSMSPresent(SMS_ALL);&#xA;    if (pos!=0)&#xA;   {&#xA;    if (sms.DeleteSMS(pos)==1){}else{}&#xA;   }&#xA;   }&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error message :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     Arduino: 1.6.7 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;      D:\Kuliah\Project\Skripsi\pintu_sms\pintu_sms.ino: In function 'void loop()':&#xA;&#xA;      pintu_sms:67: error: 'PString' was not declared in this scope&#xA;&#xA;       PString str(buffer, sizeof(buffer));&#xA;&#xA;       ^&#xA;&#xA;      pintu_sms:67: error: expected ';' before 'str'&#xA;&#xA;       PString str(buffer, sizeof(buffer));&#xA;&#xA;               ^&#xA;&#xA;     pintu_sms:68: error: 'str' was not declared in this scope&#xA;&#xA;     str.begin();&#xA;&#xA;     ^&#xA;&#xA;    pintu_sms:76: error: 'PString' was not declared in this scope&#xA;&#xA;       PString str(buffer, sizeof(buffer));&#xA;&#xA;       ^&#xA;&#xA;    pintu_sms:76: error: expected ';' before 'str'&#xA;&#xA;       PString str(buffer, sizeof(buffer));&#xA;&#xA;               ^&#xA;&#xA;     pintu_sms:77: error: 'str' was not declared in this scope&#xA;&#xA;     str.begin();&#xA;&#xA;     ^&#xA;&#xA;     exit status 1&#xA;  'PString' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18763" LastEditorUserId="18763" LastEditDate="2016-02-27T10:35:40.830" LastActivityDate="2018-04-21T21:46:04.897" Title="What should I do to communicate with GSM module?" Tags="|arduino-uno|arduino-ide|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21146" PostTypeId="2" ParentId="21145" CreationDate="2016-02-27T10:44:19.877" Score="1" Body="&lt;p&gt;The compiler does not know what PString is. It is not declared in any of the libraries you have included.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could rewrite to something like this. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strcat(buffer, &quot;Pintu Dibuka&quot;);&#xA;n = strlen(buffer);&#xA;digitalWrite(pintu,HIGH);&#xA;sms.SendSMS(n,buffer);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please change the other block in the same way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are more errors. You also need to change &quot;int n[20]&quot; to &quot;int n&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is a good start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-27T10:44:19.877" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21148" PostTypeId="2" ParentId="21129" CreationDate="2016-02-27T12:23:32.650" Score="3" Body="&lt;p&gt;I have had a very similar problem and the Arduino core team has accepted a change from me to facilitate this functionality.&#xA;It is a complex story so you may have to reread a couple of times.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;1) Serial.print returns before the data is send over serial.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The first thing to realize is that when you do serial.print() the data is not actually send over serial.&#xA;When your code looks like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serial.print(&quot;I'm dead&quot;);&#xA;resetArduino(); //This method does not exists in the arduino core&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The message &quot;I'm dead&quot; will not be send over serial. That is because Serial print does not wait until the data has been delivered.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2) There is a software buffer used for serial.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The second thing to realize is that when you do serial.print() the data is not actually send but is put into a software buffer. A interrupted routine sends the data from the buffer over the &quot;transport layer&quot; (like in the osi model) here the serial connection.&#xA;This buffer uses the same memory that your string is using. In other words you are storing the string 2 times. This is why I agree with majenko when he states &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Don't use String. Don't use concat(). Just print each bit as a separate Serial.print() function call.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;3) If the software buffer is full serial.print will wait&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you do serial.print and the software buffer is full the function will not return until all data is in the buffer.&#xA;In other words: If a sketch tries to send more data than is transmittable over the serial connection the behaviour of the sketch will change over time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Serial is slow&#xA;115200 baut may seem lightning fast but it is slow compared to what your arduino can do.&#xA;In other words: if you send lots of data you will need to calculate wether the serial connection can handle that amount of data.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;So how can you improve on the situation.&lt;/h2&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As majenko implied: Only use the buffer of serial.&lt;/li&gt;&#xA;&lt;li&gt;Reduce the amount of data you send. Jason is not a good way to send lots of similar data over a serial line because you have to add the variable name each time. I have split my variable names from the data to do reduce the amount of data to send.&lt;/li&gt;&#xA;&lt;li&gt;If you send bursts of data bigger than the software buffer; increase the buffer. This is the change Arduino core team accepted from me.you can set the define SERIAL_TX_BUFFER_SIZE for changing the send buffer size and SERIAL_RX_BUFFER_SIZE for changing the receive buffer size. The default is 64 which means 64 characters.&lt;/li&gt;&#xA;&lt;li&gt;Only send changed data.&lt;/li&gt;&#xA;&lt;li&gt;Preprocess your data so you can send less data&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-27T12:23:32.650" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21149" PostTypeId="2" ParentId="21137" CreationDate="2016-02-27T12:42:47.040" Score="4" Body="&lt;p&gt;note this is a windows mod something similar must exist on linux.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first is quick and easy. Simply modify the platform.txt files you are using as described nelow. The draw back of this is that you will need to change platform.txt files with each release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;add -DBOARD=\&quot;${build.board}\&quot; to the recipe. This will allow for&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   const char boardName[]=BOARD;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which gives you the string &quot;ARDUINO_AVR_LEONARDO&quot; (for the leonardo) in boardName.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second way is to switch to a better IDE (like already proposed by others). As the creator of the arduino eclipse plugin I would advice to use the arduino eclipse plugin. In the arduino eclipse plugin you do this as follows:&#xA;Right click on the project-&gt;properties-&gt;arduino-&gt;tab &quot;compile options&quot; put &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DBOARD=\&quot;${A.BUILD.BOARD}\&quot; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the append to C and C++ field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will make the code above to compile&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Adendum&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I wasn't aware you wanted the &quot;nice name&quot;. I'm not sure this can be fixed in the platform.txt in arduino IDE. In the arduino eclipse plugin change the fixe above in&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DBOARD=\&quot;${A.NAME}\&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to get the nice name (for the leonardo &quot;Arduino Leonardo&quot;) in the define Board. &lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-03-01T12:30:52.307" LastActivityDate="2016-03-01T12:30:52.307" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21151" PostTypeId="2" ParentId="21089" CreationDate="2016-02-27T13:38:50.920" Score="1" Body="&lt;p&gt;Thanks for the Input, you were quite right Majenko. The keyboard.press does not work in BIOS. The problem has been solved by a patch ( I'm not sure if that's the correct terminology) I found on github. By a Nicohood, here is the project if anyone find this having the same issues as me.&lt;a href=&quot;https://github.com/NicoHood/HID?files=1&quot; rel=&quot;nofollow&quot;&gt;https://github.com/NicoHood/HID?files=1&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18702" LastActivityDate="2016-02-27T13:38:50.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21152" PostTypeId="2" ParentId="21115" CreationDate="2016-02-27T13:44:30.730" Score="2" Body="&lt;p&gt;You are not sending a speed command to the motor, you are sending it an analog voltage with the analogWrite. If that voltage is too low, the motor will stall. A higher value should make it spin faster. If you want the speed to be more tightly controlled, you will need encoders on the motors to sense how fast they are spinning, or use stepper motors.&lt;/p&gt;&#xA;" OwnerUserId="18526" LastActivityDate="2016-02-27T13:44:30.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21153" PostTypeId="1" CreationDate="2016-02-27T15:18:19.387" Score="2" ViewCount="1481" Body="&lt;p&gt;I am creating pwm from an arduino pin with 50% duty cycle. I just want to know how can i detect its every falling edge using timer interrupt? I don't want to connect that PWM pin to an external interrupt pin. Please help me.&lt;/p&gt;&#xA;" OwnerUserId="18767" LastActivityDate="2016-02-27T19:18:55.943" Title="Arduino PWM Pins Interrupt" Tags="|arduino-mega|pwm|interrupt|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21154" PostTypeId="2" ParentId="21153" CreationDate="2016-02-27T16:51:21.100" Score="3" Body="&lt;p&gt;You can define an interrupt service routine (ISR) for each Timer and PWM pin that it handles. These are known as TIMERn_COMPA_vect, TIMERn_COMPB_vect and TIMERn_COMPC_vect. The Mega has six Timers (n=0..5). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMERn_COMPA_vect)&#xA;{&#xA;// Timer/Counter compare match A&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Check the PWM configuration for how the pin is set, cleared or toggled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-02-27T16:51:21.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21155" PostTypeId="1" CreationDate="2016-02-27T17:05:34.790" Score="0" ViewCount="1033" Body="&lt;p&gt;I'm at a loss. I have many boards and have not had much trouble in the past uploading to feather, uno, light blue bean and others. I have a lot of boards loaded in the board manager and I'd rather not delete everything just yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, after taking a month off of arduino programming I've come back to the app to discover that I can't upload &lt;em&gt;anything&lt;/em&gt; to &lt;em&gt;any&lt;/em&gt; board. I've tried a brand new uno, an adafruit feather and the light blue bean. In each case I can see the port, but the upload just hangs like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oNxqH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oNxqH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the board the light that normally blinks during upload never blinks. It's like the upload just isn't happening. But there is no error in the app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried reinstalling the app, but that didn't help. My next thought is to delete everything, and do a fresh install. Which will be annoying. Is that my only hope?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the settings from the tools menu as requested:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pb46x.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pb46x.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q7ClZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q7ClZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="8769" LastEditDate="2016-02-27T17:21:41.017" LastActivityDate="2019-03-14T14:37:35.523" Title="Arduino app hangs on upload for all boards" Tags="|uploading|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21156" PostTypeId="2" ParentId="21153" CreationDate="2016-02-27T19:18:55.943" Score="2" Body="&lt;p&gt;Referring to the datasheet of ATMega328P: If you want to generate an interrupt every falling edge you must know if the Pin is inverse mode or not. As you can see from the timing diagram the Pin stays high until the compare unit matches (current value of the TCNCT == value stored in OCRn ) and then goes low in the normal mode or works as opposite in the inverting mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could be regulated by changing the bits COMnx in the TCCRn register. If, for example: COM0 = 1 and COM1 = 1 the table says: Set OC0A on Compare Match, clear OC0A at BOTTOM, (inverting mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now with these settings the falling edge happens when the timer overflow, so the ISR must occur when the timer reach its maximum value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/421Ol.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/421Ol.png&quot; alt=&quot;PWM timing diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-02-27T19:18:55.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21157" PostTypeId="1" AcceptedAnswerId="21165" CreationDate="2016-02-27T19:33:56.143" Score="2" ViewCount="24143" Body="&lt;p&gt;I want to trigger an arduino from a sound from an audio jack from a mobile phone. The audio is a 1 Khz sound that the mobile will play. I want to avoid accidental triggering of the audio by testing for specifically that frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found several tutorials using analog read, but the output is not in hertz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do i get the output in Hertz?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int incomingAudio;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);  &#xA;}&#xA;&#xA;void loop(){&#xA;  incomingAudio = analogRead(A0);//read voltage at A0&#xA;  incomingAudio = (incomingAudio+1)/4 - 1;//scale from 10 bit (0-1023) to 8 bit (0-255)&#xA;  if (incomingAudio&amp;lt;0){//deal with negative numbers&#xA;    incomingAudio = 0;&#xA;  }&#xA;  PORTD = incomingAudio;&#xA;  Serial.println(PORTD);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16593" LastActivityDate="2018-05-12T13:34:16.673" Title="Arduino: Read frequency of input from audio jack" Tags="|arduino-uno|analogread|input|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21158" PostTypeId="2" ParentId="17297" CreationDate="2016-02-27T20:06:00.570" Score="0" Body="&lt;p&gt;The Arduino IDE and the arduino eclipse plugin support assembly.&lt;br&gt;&#xA;Taken from the platform.txt  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;{compiler.path}{compiler.c.cmd}&quot; {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;compiler.S.flags is empty and so is compiler.S.extra_flags and builds.extra_flags&lt;/p&gt;&#xA;&#xA;&lt;p&gt;leaving us with something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which is something I think you can handle.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-27T20:06:00.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21160" PostTypeId="2" ParentId="21155" CreationDate="2016-02-27T20:31:45.167" Score="1" Body="&lt;p&gt;I tried that once. A very common reason for this problem is a different cable. Some USB cables are not suited for uploading the data to the Uno board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you brought a new cable? If so, switch back to the old one. It may not look like it makes a difference, but it requires attention.&lt;/p&gt;&#xA;" OwnerDisplayName="user15297" LastActivityDate="2016-02-27T20:31:45.167" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21161" PostTypeId="1" CreationDate="2016-02-27T20:35:31.370" Score="0" ViewCount="1318" Body="&lt;p&gt;I faced a problem in my graduation project and I hope you can help me to solve it :)  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My project is connecting Arduino Uno to 16x32 Dot Matrix Display(DMD) and display messages on it from VB.net program. I wrote my VB.net program to convert the input text into 2D binary array. The number of columns depend on the text width.&#xA;as we know Arduino Uno SRAM is too small just 2 KBytes, so can't receive all the columns and display it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to receive 100 columns in the Arduino code and display it, then send star &lt;code&gt;*&lt;/code&gt; to computer to receive the second 100 columns and display it and so on but it didn't work. I see the RX and TX of Arduino LEDs flicker but then nothing gets displayed on the DMD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me where is the error part in the code, or if you have another idea to solve this problem :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;VB.net Code for sending the 2D array &lt;code&gt;ar(,)&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click&#xA;        SerialPort2.Open()&#xA;        Dim la As String&#xA;        If CheckBox1.Checked Then&#xA;            la = &quot;arabic&quot;&#xA;        Else&#xA;            la = &quot;english&quot;&#xA;        End If&#xA;        SerialPort2.Write(&quot;#&quot; + cols.ToString + &quot;#&quot; + &quot;*&quot; + la + &quot;*&quot;)&#xA;        Dim INDEX As Integer = 0&#xA;&#xA;        While INDEX &amp;lt;= cols&#xA;            Dim see As String = SerialPort2.ReadLine().ToString()&#xA;            If see = &quot;*&quot; Then&#xA;                Dim BUFFER(16) As Byte&#xA;                For I = INDEX To INDEX + 100&#xA;                    If I &amp;lt; cols Then&#xA;                        For J = 0 To rows - 1&#xA;                            BUFFER(J) = ar(I, J)&#xA;                        Next&#xA;                        SerialPort2.Write(BUFFER, 0, 16)&#xA;                    End If&#xA;                Next&#xA;                INDEX += 100&#xA;            End If&#xA;        End While&#xA;        SerialPort2.Close()&#xA;End Sub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C++ Code for receiving 100 columns and display them:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;DMD2.h&amp;gt;&#xA;&#xA;SoftDMD dmd(1,1);&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  dmd.setBrightness(255); &#xA;  dmd.begin();&#xA;}&#xA;long Wid;&#xA;void loop() {&#xA;  if(Serial.available()){&#xA;    String st = String(Serial.readString());&#xA;    Wid = (st.substring(st.indexOf('#')+1, st.lastIndexOf('#'))).toInt();&#xA;    //String Language = st.substring(st.indexOf('*')+1, st.lastIndexOf('*'));&#xA;  }&#xA;  long ind = Wid ;&#xA;  while(ind &amp;gt;= 0 ){&#xA;    Serial.println(&quot;*&quot;);&#xA;    if(Serial.available()&amp;gt;1 ){&#xA;      boolean pixls[16][100];&#xA;      getArray(pixls);&#xA;      displayArray(pixls);&#xA;      ind-=100;&#xA;    }&#xA;    if(ind &amp;gt;=Wid){&#xA;      ind = wid ;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void getArray(boolean arr[16][100]){&#xA;  byte serialData[16];  &#xA;  for(int k = 0 ; k &amp;lt; 100 ; k++){&#xA;    Serial.readBytes(serialData,16);&#xA;    for(int i = 0 ; i &amp;lt; 16 ; i++){&#xA;      arr[i][k]= serialData[i];&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;void displayArray(boolean arr[16][100]){&#xA;  for(int h = 0 ; h &amp;lt;= 100-33 ; h++){&#xA;    for (int i = 0 ,g=h; i &amp;lt; 32 ,g&amp;lt;h+32; i++ ,g++){&#xA;      for (int j = 0 ; j &amp;lt; 16 ; j++){&#xA;        dmd.setPixel(i,j,(arr[j][g] == 1) ? GRAPHICS_ON : GRAPHICS_OFF);&#xA;      }&#xA;    }  &#xA;    delay(100); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This VB code works for me when sending just 100 columns of the array:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SerialPort2.Open()&#xA;&#xA;        Dim BUFFER(16) As Byte&#xA;        For J = 0 To 100&#xA;            For I = 0 To rows - 1&#xA;                BUFFER(I) = ar(J, I)&#xA;            Next&#xA;            SerialPort2.Write(BUFFER, 0, 16)&#xA;        Next&#xA;        SerialPort2.Close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C++ code:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;DMD2.h&amp;gt;&#xA;SoftDMD dmd(1,1);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  dmd.setBrightness(255);&#xA;  dmd.begin();&#xA;}&#xA;void loop() {&#xA;    boolean pixls[16][100];&#xA;    for(int i=0 ;i&amp;lt;100 ; i++){&#xA;      for(int j=0 ;j&amp;lt;16 ; j++){&#xA;        pixls[j][i]=0;&#xA;      }&#xA;    }&#xA;    if(Serial.available()&amp;gt;0){&#xA;      getArray(pixls); &#xA;      for(int i=0 ; i&amp;lt;100 ; i++)&#xA;      {&#xA;        displayArray(pixls);&#xA;      }&#xA;    }&#xA;}&#xA;void getArray(boolean arr[16][100]){&#xA;  byte serialData[16];  &#xA;  for(int k = 0 ; k &amp;lt; 100 ; k++){&#xA;    Serial.readBytes(serialData,16);&#xA;    for(int i = 0 ; i &amp;lt; 16 ; i++){&#xA;      arr[i][k]= serialData[i];&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;void displayArray(boolean arr[16][100]){&#xA;  for(int h = 0 ; h &amp;lt;= 100-33 ; h++){&#xA;    for (int i = 0 ,g=h; i &amp;lt; 32 ,g&amp;lt;h+32; i++ ,g++){&#xA;      for (int j = 0 ; j &amp;lt; 16 ; j++){&#xA;        dmd.setPixel(i,j,(arr[j][g] == 1) ? GRAPHICS_ON : GRAPHICS_OFF);&#xA;      }&#xA;    }  &#xA;    delay(100); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14471" LastEditorUserId="19409" LastEditDate="2018-10-09T14:32:27.520" LastActivityDate="2019-09-14T11:42:57.540" Title="Dot Matrix Display with Arduino UNO (PROBLEM)" Tags="|arduino-uno|serial|c++|array|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="21162" PostTypeId="2" ParentId="21161" CreationDate="2016-02-27T20:57:02.577" Score="3" Body="&lt;pre&gt;&lt;code&gt;  boolean pixls[16][100];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are running out of RAM, amongst other possible problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That array alone takes 1600 bytes out of 2048 on the Uno. Since you are using Serial that also takes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;34 bytes for the HardwareSerial instance (Serial)&lt;/li&gt;&#xA;&lt;li&gt;64 bytes for the Serial transmit buffer&lt;/li&gt;&#xA;&lt;li&gt;64 bytes for the Serial receive buffer&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for the Serial transmit buffer head and tail pointers&lt;/li&gt;&#xA;&lt;li&gt;4 bytes for the Serial receive buffer head and tail pointers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That's another 170 bytes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftDMD dmd(1,1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I presume that also uses RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to rework. You don't need to store 100 bytes before displaying. How about reading each byte and displaying it? That saves almost 1600 bytes.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-27T20:57:02.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21163" PostTypeId="1" CreationDate="2016-02-27T21:47:01.947" Score="2" ViewCount="680" Body="&lt;p&gt;I am making a controller for a model railway turntable and I need to control a single DC motor and read a hall effect sensor. I have the hall effect sensor connected to pin 2 on my Uno (since 2/3 are the only pins that support interrupts) but whenever I turn the motor on it triggers the interrupt on pin 2 despite the fact that the motor PWM pin is on pin 11 and I have disconnected alternate PWM pin 3. This is with the official Arduino motor shield and an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm at a loss here, any ideas? I know it's not the motor triggering the hall effect sensor because I connected a resistor in place of the motor and it still happened.&lt;/p&gt;&#xA;" OwnerUserId="16484" LastActivityDate="2016-02-27T21:47:01.947" Title="Motor shield causing problems with interrupts?" Tags="|interrupt|arduino-motor-shield|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="21164" PostTypeId="2" ParentId="20999" CreationDate="2016-02-27T22:02:20.517" Score="0" Body="&lt;p&gt;Try changing the order of the pins on the Software Serial declaration, the correct order is (Rx,Tx), so SoftwareSerial BT(0, 1); &#xA;Or, just forget Software Serial altogether and remove the first two lines and change &quot;BT&quot; to &quot;Serial&quot; to use the hardware UART on those same pins which works better.&lt;/p&gt;&#xA;" OwnerUserId="18762" LastEditorUserId="18762" LastEditDate="2016-02-27T22:26:14.603" LastActivityDate="2016-02-27T22:26:14.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21165" PostTypeId="2" ParentId="21157" CreationDate="2016-02-27T22:08:42.957" Score="6" Body="&lt;p&gt;You can measure a single &quot;pure&quot; frequency by counting the number of times that the pin changes, by using the inbuilt timers. Here is a sketch from &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about timers&lt;/a&gt; that accomplishes that:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Timer and Counter example&#xA;// Author: Nick Gammon&#xA;// Date: 17th January 2012&#xA;&#xA;// Input: Pin D5&#xA;&#xA;// these are checked for in the main program&#xA;volatile unsigned long timerCounts;&#xA;volatile boolean counterReady;&#xA;&#xA;// internal to counting routine&#xA;unsigned long overflowCount;&#xA;unsigned int timerTicks;&#xA;unsigned int timerPeriod;&#xA;&#xA;void startCounting (unsigned int ms) &#xA;  {&#xA;  counterReady = false;         // time not up yet&#xA;  timerPeriod = ms;             // how many 1 ms counts to do&#xA;  timerTicks = 0;               // reset interrupt counter&#xA;  overflowCount = 0;            // no overflows yet&#xA;&#xA;  // reset Timer 1 and Timer 2&#xA;  TCCR1A = 0;             &#xA;  TCCR1B = 0;              &#xA;  TCCR2A = 0;&#xA;  TCCR2B = 0;&#xA;&#xA;  // Timer 1 - counts events on pin D5&#xA;  TIMSK1 = bit (TOIE1);   // interrupt on Timer 1 overflow&#xA;&#xA;  // Timer 2 - gives us our 1 ms counting interval&#xA;  // 16 MHz clock (62.5 ns per tick) - prescaled by 128&#xA;  //  counter increments every 8 µs. &#xA;  // So we count 125 of them, giving exactly 1000 µs (1 ms)&#xA;  TCCR2A = bit (WGM21) ;   // CTC mode&#xA;  OCR2A  = 124;            // count up to 125  (zero relative!!!!)&#xA;&#xA;  // Timer 2 - interrupt on match (ie. every 1 ms)&#xA;  TIMSK2 = bit (OCIE2A);   // enable Timer2 Interrupt&#xA;&#xA;  TCNT1 = 0;      // Both counters to zero&#xA;  TCNT2 = 0;     &#xA;&#xA;  // Reset prescalers&#xA;  GTCCR = bit (PSRASY);        // reset prescaler now&#xA;  // start Timer 2&#xA;  TCCR2B =  bit (CS20) | bit (CS22) ;  // prescaler of 128&#xA;  // start Timer 1&#xA;  // External clock source on T1 pin (D5). Clock on rising edge.&#xA;  TCCR1B =  bit (CS10) | bit (CS11) | bit (CS12);&#xA;  }  // end of startCounting&#xA;&#xA;ISR (TIMER1_OVF_vect)&#xA;  {&#xA;  ++overflowCount;               // count number of Counter1 overflows  &#xA;  }  // end of TIMER1_OVF_vect&#xA;&#xA;&#xA;//******************************************************************&#xA;//  Timer2 Interrupt Service is invoked by hardware Timer 2 every 1 ms = 1000 Hz&#xA;//  16Mhz / 128 / 125 = 1000 Hz&#xA;&#xA;ISR (TIMER2_COMPA_vect) &#xA;  {&#xA;  // grab counter value before it changes any more&#xA;  unsigned int timer1CounterValue;&#xA;  timer1CounterValue = TCNT1;  // see datasheet, page 117 (accessing 16-bit registers)&#xA;  unsigned long overflowCopy = overflowCount;&#xA;&#xA;  // see if we have reached timing period&#xA;  if (++timerTicks &amp;lt; timerPeriod) &#xA;    return;  // not yet&#xA;&#xA;  // if just missed an overflow&#xA;  if ((TIFR1 &amp;amp; bit (TOV1)) &amp;amp;&amp;amp; timer1CounterValue &amp;lt; 256)&#xA;    overflowCopy++;&#xA;&#xA;  // end of gate time, measurement ready&#xA;&#xA;  TCCR1A = 0;    // stop timer 1&#xA;  TCCR1B = 0;    &#xA;&#xA;  TCCR2A = 0;    // stop timer 2&#xA;  TCCR2B = 0;    &#xA;&#xA;  TIMSK1 = 0;    // disable Timer1 Interrupt&#xA;  TIMSK2 = 0;    // disable Timer2 Interrupt&#xA;&#xA;  // calculate total count&#xA;  timerCounts = (overflowCopy &amp;lt;&amp;lt; 16) + timer1CounterValue;  // each overflow is 65536 more&#xA;  counterReady = true;              // set global flag for end count period&#xA;  }  // end of TIMER2_COMPA_vect&#xA;&#xA;void setup () &#xA;  {&#xA;  Serial.begin(115200);       &#xA;  Serial.println(&quot;Frequency Counter&quot;);&#xA;  } // end of setup&#xA;&#xA;void loop () &#xA;  {&#xA;  // stop Timer 0 interrupts from throwing the count out&#xA;  byte oldTCCR0A = TCCR0A;&#xA;  byte oldTCCR0B = TCCR0B;&#xA;  TCCR0A = 0;    // stop timer 0&#xA;  TCCR0B = 0;    &#xA;&#xA;  startCounting (500);  // how many ms to count for&#xA;&#xA;  while (!counterReady) &#xA;     { }  // loop until count over&#xA;&#xA;  // adjust counts by counting interval to give frequency in Hz&#xA;  float frq = (timerCounts *  1000.0) / timerPeriod;&#xA;&#xA;  Serial.print (&quot;Frequency: &quot;);&#xA;  Serial.print ((unsigned long) frq);&#xA;  Serial.println (&quot; Hz.&quot;);&#xA;&#xA;  // restart timer 0&#xA;  TCCR0A = oldTCCR0A;&#xA;  TCCR0B = oldTCCR0B;&#xA;&#xA;  // let serial stuff finish&#xA;  delay(200);&#xA;  }   // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Feeding in a 1 kHz sine wave (from 0V to 5V) I get this output:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Frequency Counter&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1002 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1002 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1000 Hz.&#xA;Frequency: 1000 Hz.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is the occasional mis-reading but it looks accurate enough. You might sample a few times, and if you get something between 990 and 1010, five times, you might consider that a match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to make sure that the input is in the range for triggering the input circuitry of the Arduino. It should be around 4 to 5V, and not higher than 5V (for a high). It also should not go negative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this will protect the input pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FrMkW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FrMkW.png&quot; alt=&quot;Input protection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt; - audio from an audio jack will be AC and it &lt;strong&gt;will&lt;/strong&gt; go negative. Make sure you use a suitable input protection.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Amplification&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After looking at &lt;a href=&quot;https://en.wikipedia.org/wiki/Line_level&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia - Line level&lt;/a&gt; it seems likely that the output from your phone will not be high enough (around 700 mV probably). Therefore a simple transistor amplifier will probably be required to raise it to a level that can be detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inspired by &lt;a href=&quot;https://electronics.stackexchange.com/questions/36795/using-a-microphone-with-an-arduino&quot;&gt;this post&lt;/a&gt; on Electronics Stack Exchange, I made up a simple amplifier:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EhTvy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EhTvy.png&quot; alt=&quot;Audio amplifier schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing out with around 500mV peak-to-peak input indicates that it successfully amplified it to 0 to 5V DC:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2uAIi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2uAIi.png&quot; alt=&quot;Audio amplifier scope trace&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Alternative method with analog comparator&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Based on suggestions by Chris Stratton, there is another way of doing this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11916&quot; rel=&quot;nofollow noreferrer&quot;&gt;analog comparator&lt;/a&gt; to detect an analog signal passing a threshold, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cimBo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cimBo.png&quot; alt=&quot;Analog comparator schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set up the voltage divider to trigger at 0.265V, so that a 500 mV signal should provide an acceptable triggering range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the sketch, at these frequencies we can do something simpler than what I posted before:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;volatile bool counting;&#xA;volatile unsigned long count;&#xA;&#xA;ISR (ANALOG_COMP_vect)&#xA;  {&#xA;  if (counting)&#xA;    count++;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  ADCSRB = 0;           // (Disable) ACME: Analog Comparator Multiplexer Enable&#xA;  ACSR =  bit (ACI)     // (Clear) Analog Comparator Interrupt Flag&#xA;        | bit (ACIE)    // Analog Comparator Interrupt Enable&#xA;        | bit (ACIS1);  // ACIS1, ACIS0: Analog Comparator Interrupt Mode Select (trigger on falling edge)&#xA;   }  // end of setup&#xA;&#xA;unsigned long startTime;&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  if (!counting)&#xA;    {&#xA;    startTime = micros ();&#xA;    count = 0;&#xA;    counting = true;&#xA;    }&#xA;  else&#xA;    {&#xA;    // is a second up? (1000000 microseconds)&#xA;    if (micros () - startTime &amp;gt;= 1000000)&#xA;      {&#xA;      counting = false;&#xA;      Serial.print (count);&#xA;      Serial.println (F(&quot; Hz.&quot;));&#xA;      }  // end of a second being up&#xA;&#xA;    }  // end of if&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-02-28T02:44:54.680" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21166" PostTypeId="1" CreationDate="2016-02-27T23:06:21.027" Score="1" ViewCount="3931" Body="&lt;p&gt;I'm trying to program an Arduino Pro Micro with another Arduino Pro Micro. The purpose is to verify that I can use this Pro Micro board reliably as an ISP to program another Arduino device that does not have a USB interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are actually Pro Micro clones but they seem to work quite well using the Arduino Leonardo profile. I'm following &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#hardware-overview-pro-micro&quot; rel=&quot;nofollow noreferrer&quot;&gt;this pinout&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the photo of the setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2rHti.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2rHti.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;red&quot; Pro Micro is set up as ISP using the stock ArduinoISP sketch (didn't think anything needed changing). The &quot;white&quot; Pro Micro is the one I'm trying to program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins are connected, 5V - 5V, GND - GND, MISO - MISO, MOSI - MOSI, SCLK - SCLK, Pin 10 - Pin 10 (reset? this might be wrong).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've confirmed the ISP sketch is running by the green heartbeat LED. The three LEDs on the red board are connected to pins 7 (top), 8, 9 (bottom), with 9 being the heartbeat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I loaded the Blink sketch and changed the LED pin to pin 9 since the default pin 14 on the white board is being used as the MISO pin for programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the IDE, I set the board to Arduino Leonardo, port to the red board's port, programmer to &quot;Arduino as ISP&quot; and ran &quot;Upload Using Programmer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only output I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Yikes!  Invalid device signature.&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I'm really just beginning all of this, I'm a bit confused what might be wrong and what could be a next troubleshooting step. Any help appreciated.&lt;/p&gt;&#xA;" OwnerUserId="18795" OwnerDisplayName="Ana" LastActivityDate="2016-02-28T00:19:17.963" Title="Trying to verify that Arduino Pro Micro ISP is working" Tags="|isp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21167" PostTypeId="2" ParentId="21166" CreationDate="2016-02-28T00:19:17.963" Score="2" Body="&lt;p&gt;As Mikael Patel notes, pin 10 on the programmer Pro Micro should run to RST on the target.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might or might not fix the problem.  In some previous instances of the “Yikes! Invalid device signature” [&lt;a href=&quot;https://arduino.stackexchange.com/questions/3781/when-using-arduino-uno-as-isp-does-yikes-invalid-device-signature-mean-a-bad&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=152587.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;] bad breadboard connections turned out to be the problem.  I suggest you run a second (or even a third) set of jumpers in parallel with the first set.  Of course use matching colors to avoid confusion.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-28T00:19:17.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21168" PostTypeId="2" ParentId="17184" CreationDate="2016-02-28T00:50:38.493" Score="0" Body="&lt;p&gt;From my experience, if you want to have a consistent data transfer over the softserial, you must disable (in Arduino) the global interrupts for the time of transmission. To disable global interrupts use cli() command, to enable it again use sei() command.&lt;/p&gt;&#xA;" OwnerUserId="18772" LastEditorUserId="18772" LastEditDate="2016-02-28T00:56:10.553" LastActivityDate="2016-02-28T00:56:10.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21169" PostTypeId="2" ParentId="19347" CreationDate="2016-02-28T01:59:11.780" Score="1" Body="&lt;p&gt;Newer versions of the library CAN use fonts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Fonts/FreeSerifBold12pt7b.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;matrix.setFont(&amp;amp;FreeSerifBold12pt7b);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whether they work or not, I dunno. &lt;strong&gt;&lt;em&gt;Case closed, lol!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="11853" LastActivityDate="2016-02-28T01:59:11.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21170" PostTypeId="2" ParentId="19233" CreationDate="2016-02-28T02:22:20.583" Score="0" Body="&lt;p&gt;You can't have a single ESP8266 be both an access point and a client, at least not using the exposed API (recall that the Arduino libaries do not implement much functionality themselves, all they do is call the underlying RTOS API).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, a signal repeater is not a radio-only device. It would have to understand the low-level 802.11* protocols and packet types so you don't end up with forwarding loops. You can't do it just by connecting a pair of 8266s back-to-back over SPI and blindly forward packets; there is a lot of networking code that would have to be written.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-02-28T02:22:20.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21172" PostTypeId="1" CreationDate="2016-02-28T05:31:27.667" Score="2" ViewCount="23442" Body="&lt;p&gt;I'm trying to make my esp8266 work with my arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I send AT commands I get some weird symbols and some functions return &quot;ERROR&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code I'm using.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SoftwareSerial.h&quot;&#xA;&#xA;SoftwareSerial esp8266(6, 7); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); // serial port used for debugging&#xA;  esp8266.begin(115200);  // your ESP's baud rate might be different&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(esp8266.available())  // check if the ESP is sending a message&#xA;  {&#xA;    while(esp8266.available())&#xA;    {&#xA;      char c = esp8266.read();  // read the next character.&#xA;&#xA;      Serial.write(c);  // writes data to the serial monitor&#xA;    }&#xA;  }&#xA;&#xA;  if(Serial.available())&#xA;  {&#xA;    delay(10);  // wait to let all the input command in the serial buffer&#xA;&#xA;    // read the input command in a string&#xA;    String cmd = &quot;&quot;;&#xA;    while(Serial.available())&#xA;    {&#xA;      cmd += (char)Serial.read();&#xA;    }&#xA;    // send to the esp8266&#xA;    esp8266.println(cmd); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the Serial Monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&#xA;&#xA;OK&#xA;AT+RST&#xA;&#xA;OK&#xA;&#xA;&#xA; ets Jan  8 2013,rst catse:2, boot lode:(3,7)&#xA;&#xA;loab 0x40100000&amp;amp; len 1396, qoom 16 &#xA;tail 4C�,kk�������e&#xA;load 0x3fge8000, len 776, room 4 tak0  t0�v�&#xA;�!jH+��&#xA;����(j5�!&#xA;,�2%1�&#xA;&#xA;j&#xA;�sl��o�&#xA;Ai,Thinker Technology Co. Ltd.&#xA;&#xA;invalid&#xA;AT+CWMODE?&#xA;&#xA;+CWMODE:1&#xA;&#xA;OK&#xA;&#xA;AT+GMR&#xA;&#xA;AT version;0.25.0.0(Juo  5 2015 17:27:16)&#xA;SDK version:1.0&#xA;ryJ 0&#xA;&#xA;AT+CWLAP&#xA;&#xA;+CWLAP:(4,&quot;�P��R�*bj��b���*��2��*����Ҋ�b�Jj&#xA;��*A�B�br������Յź�aj��b����2j&#xA;&quot;:6�*AՉ����J&#xA;&quot;�́������&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The commands where, &lt;code&gt;AT&lt;/code&gt;, &lt;code&gt;AT+RST&lt;/code&gt;, &lt;code&gt;AT+CWMODE?&lt;/code&gt;, &lt;code&gt;AT+GMR&lt;/code&gt;, &lt;code&gt;AT+CWLAP&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why am I getting this weird symbols and etc? I haven't upgraded the firmware, should I?  There other commands I tried return &quot;ERROR&quot; or even &quot;ERROQ&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have a USB to TTL or any other board. I connected my board in the arduino with this schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nVxnL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nVxnL.png&quot; alt=&quot;esp8266 connection to arduino using voltage regulator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cap = 10uF&#xA;VolReg = LM1117 3.3v&lt;/p&gt;&#xA;" OwnerUserId="18720" LastActivityDate="2017-08-13T08:58:15.637" Title="Esp8266-01 AT commands returns random chars and/or &quot;ERROR&quot;" Tags="|serial|esp8266|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21175" PostTypeId="2" ParentId="21157" CreationDate="2016-02-28T07:07:18.047" Score="5" Body="&lt;p&gt;If your signal is a pure 1&amp;nbsp;kHz tone, then you should use Nick&#xA;Gammon's counting method, as it is the most straight-forward solution.&#xA;If, however, you are picking the signal through a microphone, chances&#xA;are you will also get some background noise, and this can make the&#xA;counting method unreliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In such a case, you will have to use some kind of digital filter to&#xA;extract the desired signal from the noise. I would recommend using&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Homodyne_detection&quot; rel=&quot;nofollow&quot;&gt;homodyne detection&lt;/a&gt;,&#xA;which is both simple and very robust against wide-spectrum noise: let&#xA;&lt;em&gt;f&lt;/em&gt;&amp;nbsp;=&amp;nbsp;1&amp;nbsp;kHz be the frequency you want to detect, and &lt;em&gt;t&lt;/em&gt;&#xA;be the current time, then&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;compute cos(2 π &lt;em&gt;f t&lt;/em&gt; ) and sin(2 π &lt;em&gt;f t&lt;/em&gt; ): these two periodic signals,&#xA;in quadrature to one another, are called “the local oscillator”&lt;/li&gt;&#xA;&lt;li&gt;multiply your signal independently by the above cos() and sin()&lt;/li&gt;&#xA;&lt;li&gt;low-pass filter the two products, which gives you the&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Quadrature_amplitude_modulation&quot; rel=&quot;nofollow&quot;&gt;I and Q demodulated&lt;/a&gt; signals&lt;/li&gt;&#xA;&lt;li&gt;compute the instantaneous power = I&lt;sup&gt;2&lt;/sup&gt;&amp;nbsp;+&amp;nbsp;Q&lt;sup&gt;2&lt;/sup&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You know the phone is ringing when this power goes above some&#xA;experimentally-determined threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know all this sounds like heavy math, but it need not be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All the computations are amenable to efficient fixed-point&#xA;implementations, and you can do the math in parallel with the&#xA;analog-to-digital conversion.&lt;/li&gt;&#xA;&lt;li&gt;The scheme works even with crude approximations of the sin() and cos()&#xA;functions. Even square waves (sin() and cos() being always +1 or −1)&#xA;work quite decently.&lt;/li&gt;&#xA;&lt;li&gt;The low-pass filter can be implemented as an&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average&quot; rel=&quot;nofollow&quot;&gt;exponential moving&#xA;average&lt;/a&gt;,&#xA;which is only a bit shift, an add and a subtract.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I can try to write some sample code, but I would go through the trouble&#xA;only if there is interest. If your signal is so clean that Nick Gammon's&#xA;method works reliably, there probably is no point.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: I wrote a program to demonstrate this approach, just for the&#xA;fun. It's available as a GitHub gist:&#xA;&lt;a href=&quot;https://gist.github.com/edgar-bonet/0b03735d70366bc05fc6&quot; rel=&quot;nofollow&quot;&gt;homodyne.ino&lt;/a&gt;.&#xA;I am not copying the whole program here, just adding some explanations:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing is to take care of the sampling frequency. Whenever one&#xA;wants to do signal processing, it is very desirable to sample at a fixed&#xA;and known frequency. This is next to impossible to achieve by looping&#xA;over &lt;code&gt;analogRead()&lt;/code&gt;, because the CPU time needed to go through the loop&#xA;is hard to predict, as it can be influenced by interrupts and by&#xA;conditional branches. &lt;code&gt;analogRead()&lt;/code&gt; is also highly inefficient, as it&#xA;locks the CPU in a busy loop while it waits for the analog-to-digital&#xA;converter (ADC) to do its job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is to put the ADC in the so called &quot;free running mode&quot;. In&#xA;this mode, it starts a conversion as soon as the previous one is&#xA;finished, which gives a very steady sampling rate of 9.615&amp;nbsp;kHz (one&#xA;sample every 104&amp;nbsp;µs). The samples are handled by an interrupt&#xA;service routine called &lt;code&gt;ISR(ADC_vect)&lt;/code&gt; which gets triggered every time a&#xA;sample is ready. This is also where all the signal processing is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a detailed explanation of every line of code in the ISR:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int8_t sample = ADCH - 128;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading the ADC result is the first thing to do in the ISR. Since we do&#xA;not need the full 10 bit resolution, the ADC was configured to&#xA;left-adjust its result. Then we get an 8-bit result by just reading the&#xA;high byte of the ADC data register. We subtract 128 to remove the DC&#xA;offset and get a signed number in the range [−128&amp;nbsp;..&amp;nbsp;+127].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, we update the phase of our local oscillator:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;static uint16_t phase;&#xA;phase += PHASE_INC;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;We need not worry about possible overflows: since the phase is kept in&#xA;units of 1/2&lt;sup&gt;16&lt;/sup&gt;&amp;nbsp;cycles, the increment automatically works&#xA;modulo one cycle. The phase increment should theoretically be 6815.744,&#xA;which is rounded to 6816. This makes the local oscillator fast by&#xA;0.0376&amp;nbsp;Hz, which is negligible given the accuracy of the Arduino&#xA;clock. The phase could be kept in an 8-bit variable, but the rounding&#xA;error would then make the oscillator fast by 14&amp;nbsp;Hz, which can be&#xA;borderline unacceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next we need to build two square waves in quadrature, which will be used&#xA;as rough approximations of sin() and cos(). But since the most&#xA;significant bit of the phase is on during half of the cycle, it can be&#xA;used as one of our square waves. The other wave is obtained in a similar&#xA;way, after adding 1/4 cycle to the phase. So here is how we multiply our&#xA;sample by the square waves:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int8_t x = sample;&#xA;if (((phase&amp;gt;&amp;gt;8) + 0x00) &amp;amp; 0x80) x = -1 - x;&#xA;int8_t y = sample;&#xA;if (((phase&amp;gt;&amp;gt;8) + 0x40) &amp;amp; 0x80) y = -1 - y;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The expression &lt;code&gt;phase&amp;gt;&amp;gt;8&lt;/code&gt; is only meant to hint the compiler that it&#xA;needs only to consider the most significant byte of the phase. This&#xA;should normally not be needed, but I noticed that, without this hint,&#xA;gcc generates suboptimal code. The &lt;code&gt;-1&lt;/code&gt; in the above lines are for&#xA;avoiding a possible overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next comes the low-pass filter:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;signal_I += x - (signal_I &amp;gt;&amp;gt; LOG_TAU);&#xA;signal_Q += y - (signal_Q &amp;gt;&amp;gt; LOG_TAU);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;signal_I&lt;/code&gt; and &lt;code&gt;signal_Q&lt;/code&gt; are &lt;code&gt;volatile int16_t&lt;/code&gt; globals, and&#xA;&lt;code&gt;LOG_TAU&lt;/code&gt; is 6. This filters with a time constant&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;τ = 64 × 104 µs = 6.656 ms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which translates to a −3&amp;nbsp;dB bandwidth of&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Δf = 1/(2πτ) = 23.9 Hz.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;which is fairly narrow for a 1&amp;nbsp;kHz signal. The significance of τ is&#xA;that, once the tone starts, it takes the filter about&#xA;2.3&amp;nbsp;τ&amp;nbsp;≈&amp;nbsp;15&amp;nbsp;ms to reach 90% of its final output. Both&#xA;τ and Δf can be changed by simply changing &lt;code&gt;LOG_TAU&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This ISR takes about 176&amp;nbsp;CPU cycles (11&amp;nbsp;µs, including the&#xA;4&amp;nbsp;cycles needed to put the CPU in interrupt mode) every&#xA;1664&amp;nbsp;cycles (104&amp;nbsp;µs). This amounts to about 10.6% of the&#xA;available CPU power. And since everything is done inside the ISR, the&#xA;program is free to do whatever else needs to be done while the data&#xA;acquisition and digital filtering happens in the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the program by sending it a sine wave of 4.36&amp;nbsp;V&#xA;peak-to-peak amplitude. The reported power fluctuated quite a bit, but&#xA;here are the approximate average readings as a function of the input&#xA;frequency:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;frequency  |  power&#xA;-----------+-------&#xA;   929 Hz  |   480&#xA;   976 Hz  |  2400&#xA;  1005 Hz  |  4600&#xA;  1028 Hz  |  2700&#xA;  1079 Hz  |   480&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-03-01T12:08:38.077" LastActivityDate="2016-03-01T12:08:38.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21176" PostTypeId="2" ParentId="21141" CreationDate="2016-02-28T10:17:14.173" Score="2" Body="&lt;p&gt;Disconnecting the ground pin was not a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is hard to be certain from video but the resistor values are likely too small because I can't see any color on the bands.  They are 100?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look closely at the driver data sheet.  It may say an output pin maximum current is +/-35 mA which would suggest that the 100 ohm resistor is okay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a red LED has a of around 1.6 V.  You are using Vcc=3.3, so a 100 ohm resistor limits the current to &amp;lt;17 mA ((3.3-1.6)/100).  The actual current will be a somewhat smaller as the Vf increases with current..  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you also stay within the maximum Icc and Ignd on the data sheet.  These limits are not necessarily 8 x 35 mA.  For example an NXP max Icc is 70 mA.  That means you cannot drive all the outputs at maximum current, just 2.  This is a logic chip, not a driver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is other hint that you should not using all the outputs at the max current spec in the section where the Voh and Vol are described.  The current at which the voltage is specified is 6 mA, which is the maximum you should use if all output are going to source or sink at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A common LED current is 5 mA, so this chip could drive 8 simultaneously.  If you want high brightness, you need to add a driver such as ULN2003.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the schematic shows red LED's.  &lt;strong&gt;The color is important&lt;/strong&gt;.  Different LED's have different forward voltage.  The blue LED have the highest in the range of 3.3 V and higher.  So with a Vcc=3.3 there is barely enough voltage to light the blue LED.  The red and yellow have much lower forward voltage.  When the chip tries to light the red and blue at same time, the output voltage is dropping enough that the blue is not visible, but the red is easily lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the video, it looks that you have the same resistor on all the LED's.  On different color LED's this will not achieve the same brightness on all LED's.  You need different resistors for each color if you want them the same brightness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Up the Vcc to 5V so that you can reliably light the blue LED's.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Increase the resistor values start with 510 for red and 220 for blue.  This should be about 6 mA for both.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3742" LastEditorUserId="3742" LastEditDate="2016-02-28T22:54:57.867" LastActivityDate="2016-02-28T22:54:57.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21179" PostTypeId="1" AcceptedAnswerId="21182" CreationDate="2016-02-28T13:10:47.253" Score="0" ViewCount="271" Body="&lt;p&gt;Just trying to find out if my Arduino UNO R1 board is broken or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, everything seems normal, Arduino board shows &quot;on&quot; (green) when I plug it on my computer, I also can verify and upload programs to my Arduino board. But, no matter what program I upload the pin 13 turns on and off 3 times and that's it. I'm checkin it by using a LED. &#xA;Eg. if I want to use another pin (ex. 7, 8, 12) it doesn't work, or even to write a program for turning on/off 9 times pin 13 doesn't work... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I noticed that pin 8 turns the LED for less than a 1/2 a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried to restart board by bridging the reset pin and also by pushing reset directly on the board, I also reinstalled Arduino Genuino Application. I thought to update Atmega8U2 firmware but accordingly to Arduino &lt;a href=&quot;https://www.arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;site&lt;/a&gt; I don't need to update since I have firmware rev. 0.01.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be also great not to have to buy a new Arduino UNO. Thanks for your help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Here is how I'm trying to make pin 12 work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 12;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(2000);&#xA;    digitalWrite(ledPin, LOW);&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18783" LastEditorUserId="18783" LastEditDate="2016-02-28T14:33:14.213" LastActivityDate="2016-02-28T14:33:14.213" Title="Is my Arduino board defect? No matter what program I upload the pin 13 turns on and off 3 times and that's it" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21180" PostTypeId="2" ParentId="21172" CreationDate="2016-02-28T13:39:53.117" Score="1" Body="&lt;p&gt;The problem is mainly in using Serial and SoftwareSerial together. Or it can be due the esp getting less current than it requires from the Arduino(you are also damaging your Arduino!), use an external 5V source (I use my computer USB)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why dont you directly use Serial for communication with pins 0 and 1. Just upload a blank sketch, connect Arduino Tx, Rx to esp's Tx, Rx(reverse Tx, Rx if not working). What you type into Serial will then be sent to the esp. Later if you wish to communicate to esp in sketches, use only SoftwareSerial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the esp is not 5V tolerant so you need to use a level shifter(like the cd4050 ic) or a voltage divider(less efficient) for signals from the Arduino to the esp. 3.3V is considered as a logical HIGH so you dont need to do any changes for signals from esp to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I highly recommend getting a USB TTL converter, this will save you a lot of headaches and debugging will be easy. I did things without it for 1-2months and now I can totally feel the difference.&lt;/p&gt;&#xA;" OwnerUserId="18785" LastActivityDate="2016-02-28T13:39:53.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21181" PostTypeId="1" CreationDate="2016-02-28T14:04:06.237" Score="0" ViewCount="101" Body="&lt;p&gt;I need help with my coding. I'm still learning on how to use interval &lt;code&gt;millis()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I'm working on a water heater with a safety feature. This means that you can only pour water out when you activate the child-lock feature. The child-lock feature will turn on for 5 seconds and within that 5 seconds if you pour the water out, the timer will pause until you finish pouring your water and the 5 second timer will start again and the system goes off after that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the child lock feature on for 5 second without any action, it will turn off the system again. My lecturer does not allow me to use the &lt;code&gt;delay()&lt;/code&gt; function so I already did my coding using &lt;code&gt;millis()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int redLed = 2;&#xA;const int greenLed = 3;&#xA;const int yellowLed = 4;&#xA;const int greenbigLed = 7;&#xA;&#xA;const int buttonPin1 = 5;&#xA;const int buttonPin2 = 6;&#xA;&#xA;int buttonState1 = 0;&#xA;int buttonState2 = 0;&#xA;float tempC ;&#xA;int analogPin = A0;&#xA;int yellowLedState = 0;&#xA;&#xA;const long interval1 =0;&#xA;const long interval2 = 5000;&#xA;unsigned long previousMillis = 0;   &#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;pinMode(2,OUTPUT);&#xA;pinMode(3,OUTPUT);&#xA;pinMode(4,OUTPUT);&#xA;pinMode(5,INPUT);&#xA;pinMode(6,INPUT);&#xA;Serial.begin(9600);&#xA;digitalWrite(yellowLed,yellowLedState);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;int analogValue = analogRead(analogPin);&#xA;int buttonState1 = digitalRead(buttonPin1);&#xA;int buttonState2 = digitalRead(buttonPin2);&#xA;int yellowLedState = digitalRead(yellowLed);&#xA;tempC = analogValue / 10 ;&#xA;Serial.println(tempC);&#xA;unsigned long currentMillis = millis();&#xA;unsigned long currentMillis2 = millis();&#xA;&#xA;if (tempC &amp;lt;= 89.9 &amp;amp;&amp;amp; tempC &amp;gt;= 0){&#xA;  digitalWrite(redLed,HIGH);&#xA;  digitalWrite(greenLed,LOW);&#xA;}else if(tempC == 102){&#xA;  digitalWrite(redLed,LOW);&#xA;  digitalWrite(greenLed,HIGH);&#xA;}&#xA;&#xA;if(currentMillis - previousMillis &amp;gt;= interval2){&#xA;  previousMillis = currentMillis;&#xA;  if(buttonState1 == HIGH){&#xA;   // if(currentMillis2 - previousMillis2 &amp;gt;=interval2){&#xA;     if (yellowLedState == LOW) {&#xA;          yellowLedState = HIGH;&#xA;} &#xA;digitalWrite(yellowLed, yellowLedState);&#xA;  } else{&#xA;  digitalWrite(yellowLed,LOW);&#xA;    }&#xA;}&#xA;&#xA;&#xA;if (buttonState2 == HIGH &amp;amp;&amp;amp; yellowLedState == HIGH){&#xA;  digitalWrite(greenbigLed, HIGH);&#xA;}else{&#xA;  digitalWrite(greenbigLed,LOW);&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I'm able to pour out water when child lock feature activated, but the problem is the timer (interval) still ticking. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any solution on how can I pause the interval whenever I'm pouring water (button2) and the interval starts back 5 sec when I release button2 (pouring water)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would glad if someone can help me. Ask me anything about my code.&lt;/p&gt;&#xA;" OwnerUserId="17280" LastEditorUserId="6936" LastEditDate="2016-03-15T05:28:02.563" LastActivityDate="2016-03-15T05:28:02.563" Title="Water heater coding problem" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21182" PostTypeId="2" ParentId="21179" CreationDate="2016-02-28T14:29:53.517" Score="1" Body="&lt;p&gt;The best way to check if Arduino is working or not is to install Firmata. Here's the necessary steps:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Download Firmata application from the &lt;a href=&quot;http://www.firmata.org/wiki/Main_Page#Firmata_Test_Program&quot; rel=&quot;nofollow&quot;&gt;official website&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Connect Arduino to the computer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Open the Arduino IDE and burn the example Standard Firmata [File - Examples - Firmata - Standard Firmata]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Open the application, leaving the Arduino connected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) Chose the right serial port and debug every pin =D&lt;/p&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-02-28T14:29:53.517" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21184" PostTypeId="2" ParentId="21172" CreationDate="2016-02-28T15:55:10.237" Score="1" Body="&lt;p&gt;SoftwareSerial is reliable only up to 9600 baud or so. You can either swap ports and use Software serial as your debug output (but requires disconnecting/reconnecting the ESP8266 chip each time you upload to the UNO); or write a short sketch to set the device's baud rate to 9600 baud (and convince yourself that at least that much ran OK!) and set your SoftwareSerial to that rate.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-02-28T21:28:05.710" LastActivityDate="2016-02-28T21:28:05.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21185" PostTypeId="2" ParentId="17263" CreationDate="2016-02-28T16:00:08.260" Score="1" Body="&lt;p&gt;Even though I like Kingsley's answer I thought I'd add to this using Wi-Fi becuase you had mentioned LAN.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two links should be enough to help you:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiChatServer&quot; rel=&quot;nofollow&quot;&gt;WifiChatServer&lt;/a&gt;&#xA;and &lt;a href=&quot;http://www.codeproject.com/Articles/19071/Quick-tool-A-minimalistic-Telnet-library&quot; rel=&quot;nofollow&quot;&gt;C# Telnet Library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those links can sort of be dissected to fit your needs, but if you need some actual code just tell me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I am aware that &lt;strong&gt;the Arduino is acting as a server and the computer acts as a client&lt;/strong&gt;, but I believe this setup is better because it's easier to manipulate connecting to servers on the computer rather than on the arduino side.&lt;/p&gt;&#xA;" OwnerUserId="18787" LastActivityDate="2016-02-28T16:00:08.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21186" PostTypeId="1" CreationDate="2016-02-28T17:26:44.933" Score="1" ViewCount="3100" Body="&lt;p&gt;I would like to connect the Atmega328p chip to my desktop, through the USB, so I can run teraterm or hyperterminal for debugging purposes. &#xA;I have already ordered a USB to TTL serial cable but it won't be arriving for about a week. &#xA;I recently bought a usbASP ISP to program the chip on my Arduino. &#xA;My question is: can I use the usbASP in place of the TTL cable? or is there some conditioning circuit in the usbASP that won't allow this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems for the usb to ttl, all that is required to interface with the chip is VCC, GRD, RX and TX. So, which pins are the RX and TX?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope my question makes sense, they usually don't! thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="18790" LastEditorUserId="18790" LastEditDate="2016-02-28T18:04:40.233" LastActivityDate="2016-02-28T18:04:40.233" Title="Debugging with ISP" Tags="|isp|debugging|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21187" PostTypeId="2" ParentId="21186" CreationDate="2016-02-28T17:34:54.813" Score="2" Body="&lt;p&gt;There &lt;em&gt;is&lt;/em&gt; provision in the &lt;a href=&quot;http://www.fischl.de/usbasp/&quot; rel=&quot;nofollow&quot;&gt;USBasp specification&lt;/a&gt; for a UART connection, &lt;strong&gt;however&lt;/strong&gt;, not all manufacturers copy the original schematic exactly, and no firmware actually contains the appropriate code for CDC/ACM required in order to enable it. And even if they did, technically low-speed CDC/ACM is a violation of the USB protocol and not all operating systems will acknowledge it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your title of &quot;Debugging with ISP&quot;, if you have an Atmel programmer and are using Atmel Studio then you &lt;em&gt;can&lt;/em&gt; perform debugging over ISP (actually debugWIRE, but they use the same connections).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-28T17:34:54.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21188" PostTypeId="2" ParentId="18448" CreationDate="2016-02-28T17:38:57.267" Score="1" Body="&lt;p&gt;The video you show shows movement of far more than 1mm.  This indicates that the steps per unit is far different than you are configuring the Marlin software for.  With a +/-1mm and 212 steps per mm, there should have been 212 steps sent to your stepper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recalculate your steps/mm values and slow down the feed rate to get something reliable.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For experimenting, in Pronterface, set the feedrate of 10mm/sec (600mm/min) or 1mm/sec (60mm/min) to slow things down so you can hear or count the steps with your ear, then choose smaller steps, like +0.1mm and see if you get the planned displacement.  If, at a really slow speed, you don't get the corresponding movement, then your steps/mm need adjustment to match your system.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eyeballing it, I'd say the called-for 1mm or 212 steps is moving the stage about 10mm, so you would need numbers more like this for the x and y axes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DEFAULT_AXIS_STEPS_PER_UNIT {21 ,21 ,8034.69,196.52}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-02-28T17:38:57.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21189" PostTypeId="2" ParentId="18604" CreationDate="2016-02-28T17:44:02.613" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/18604/send-stepper-to-position-and-back-accelstepper#comment34648_18604&quot;&gt;Gerben's comment&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You need to call stepper.run() instead of runSpeed, for moveTo to work.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;provides the answer. The updated code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;AccelStepper stepper(1, 5, 4);&#xA;&#xA;int spd = 1000;    // The current speed in steps/second&#xA;int sign = 1;      // Either 1, 0 or -1&#xA;&#xA;int buttonState = 0;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  stepper.setMaxSpeed(1000);&#xA;  stepper.setSpeed(1000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  char c;&#xA;  if (Serial.available()) {&#xA;    c = Serial.read();&#xA;    if (c == 'f') {  // forward&#xA;      sign = 1;&#xA;    }&#xA;    if (c == 'r') {  // reverse&#xA;      sign = -1;&#xA;    }&#xA;    if (c == 's') {  // stop&#xA;      sign = 0;&#xA;    }&#xA;    if (c == '1') {  // super slow&#xA;      spd = 100;&#xA;    }&#xA;    if (c == '2') {  // medium&#xA;      spd = 900;&#xA;    }&#xA;    if (c == '3') {  // fast&#xA;      spd = 1000;&#xA;    }&#xA;    if (c == '4') {&#xA;      //not working, does anyone know how to do this?&#xA;      stepper.moveTo(500);&#xA;    }&#xA;    stepper.setSpeed(sign * spd);&#xA;  }&#xA;  stepper.run(); //You need to call stepper.run() instead of runSpeed, for moveTo to work. – Gerben&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-12-25T16:25:32.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21196" PostTypeId="1" AcceptedAnswerId="21197" CreationDate="2016-02-28T19:25:27.243" Score="1" ViewCount="797" Body="&lt;p&gt;I bought the following USBasp off of Aliexpress. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x4B7c.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x4B7c.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Cmd07.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cmd07.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino UDE doesn't recognize it. When I try to run avrdude with it, it says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -cusbasp -Pusb -patmega328p&#xA;avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking at the USB enumeration, it says:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USBHID:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Product ID:   0xc8b4&#xA;  Vendor ID:    0x03eb  (Atmel Corporation)&#xA;  Version:  1.00&#xA;  Speed:    Up to 1.5 Mb/sec&#xA;  Manufacturer: zhifengsoft&#xA;  Location ID:  0x14200000 / 8&#xA;  Current Available (mA):   1000&#xA;  Current Required (mA):    100&#xA;  Extra Operating Current (mA): 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looking online, I see one blog post (&lt;a href=&quot;http://www.sciencetronics.com/greenphotons/?p=938&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.sciencetronics.com/greenphotons/?p=938&lt;/a&gt;) about a device with the same VID/PID, and it says it can be reprogrammed but is not clear how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I know there is a jumper that I need to set to put it in self-programming mode but I can't figure out where to put this jumper. Once the jumper is in, I understand I just match the SPI pins and program it using the firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-02-28T20:05:00.157" Title="Is this a USBasp I can use with Arduino?" Tags="|isp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21197" PostTypeId="2" ParentId="21196" CreationDate="2016-02-28T20:05:00.157" Score="3" Body="&lt;p&gt;That's not a USBasp, that's some other programmer that has co-opted Atmel's vendor ID invalidly. If you want to use it then you will need to find and use some program called &quot;ProgISP&quot; that is only available for Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That particular device does not show the jumper required for reprogramming, so I wouldn't attempt it (and in fact I would find the nearest bin to toss it in and get a couple from Baite and/or LC Tech instead).&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-02-28T20:05:00.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21198" PostTypeId="2" ParentId="21172" CreationDate="2016-02-28T21:00:51.300" Score="0" Body="&lt;ul&gt;&#xA;&lt;li&gt;The Arduino pin 7 (TX) signal must be level-shifted from 5V to 3.3V using a voltage divider, because the ESP cant handle 5V signals.&lt;/li&gt;&#xA;&lt;li&gt;The Serial baud is a lot lower than that of SoftwareSerial plus you are spending a lot of time waiting for the whole command to come in. SoftwareSerial is also unreliable at 115200 baud. Use 57600 baud for both serial ports.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial esp8266(6, 7); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600); &#xA;  esp8266.begin(57600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  while (Serial.available())&#xA;    esp8266.write(Serial.read());&#xA;  while (esp8266.available())&#xA;    Serial.write(esp8266.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will do the exact same thing you want to do. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-28T21:00:51.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21200" PostTypeId="1" CreationDate="2016-02-28T22:02:34.000" Score="1" ViewCount="4625" Body="&lt;p&gt;I am going to be controlling 2 servo motors with an arduino. I will use an external battery pack for power. Do I need to connect the negative of the battery to ground on the arduino? If I just use the battery pack to power an LED, it works without connecting it to ground. Can someone please explain the logic behind this in simple wording? Thank you&lt;/p&gt;&#xA;" OwnerUserId="18804" OwnerDisplayName="Nick Solonko" LastActivityDate="2016-02-29T05:38:30.590" Title="Do external battery packs need to connect to ground on the arduino?" Tags="|servo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21201" PostTypeId="2" ParentId="21200" CreationDate="2016-02-28T22:21:00.343" Score="4" Body="&lt;p&gt;Ground is merely a label. It is a logical point in the circuit relative to which you measure all other voltages against.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the 5V pin on the Arduino is actually 5V &lt;em&gt;relative to the ground pin&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 12V battery's &lt;code&gt;+&lt;/code&gt; terminal is 12V &lt;em&gt;relative to the &lt;code&gt;-&lt;/code&gt; terminal&lt;/em&gt;. In this situation the &lt;code&gt;-&lt;/code&gt; pin can be labelled Ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Electricity only ever flows when there is a circuit.  That is, current can only flow when it has some way of flowing back to where it came from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A battery with an LED and resistor attached has a circuit: &lt;em&gt;Battery -&gt; LED -&gt; Resistor -&gt; Battery&lt;/em&gt;.  An Arduino itself is a circuit: &lt;em&gt;Power -&gt; Arduino -&gt; Internal Gubbins -&gt; Power&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the rule above, electricity can only ever flow out of an I/O pin if it has some way of getting back to where it came from. That route back is the Ground pin of the Arduino.  Interfacing some external device with the Arduino, whether it has its own power supply or not, requires that connection back to the Arduino's ground in order for the signal you send from the Arduino to have a complete circuit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-28T22:21:00.343" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21202" PostTypeId="1" AcceptedAnswerId="21203" CreationDate="2016-02-28T22:26:30.987" Score="0" ViewCount="12375" Body="&lt;p&gt;I'm creating a real-time vehicle tracking Android application using the Arduino Uno and SIM900 GPS. I want to use Firebase as the database for the coordinates which will hold just the longitude and latitude. My question is about sending the data through the GPRS to Firebase. Right now I've only been able to use a terminal program to send AT commands to create a connection but I've been getting errors when connecting to firebase using AT+CIPSEND. I know that it only excepts https traffic so I've been trying commands from &lt;a href=&quot;http://www.jarzebski.pl/datasheets/SIM900_https-121018-1.00.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Here is some code that I've tried: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;OK&#xA;AT+CREG?&#xA;+CREG: 0,1&#xA;&#xA;OK&#xA;AT+CGATT?&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;AT+CIPSTATUS&#xA;OK&#xA;&#xA;STATE: IP INITIAL&#xA;AT+CIPMUX=0&#xA;OK&#xA;AT+CSTT=&quot;att.mvno&quot;,&quot;&quot;,&quot;&quot;&#xA;OK&#xA;AT+CIICR&#xA;OK&#xA;AT+CIPSTART=&quot;TCP&quot;,&quot;https://mygpstracker.firebaseio.com&quot;,&quot;80&quot;&#xA;OK&#xA;CONNECT OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CIPSHUT&#xA;OK&#xA;AT+CIPSTART=&quot;TCP&quot;,&quot;https://mygpstracker.firebaseio.com&quot;,&quot;443&quot;&#xA;OK&#xA;CONNECT OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I use CIPSEND, how should my message be formatted to send lat or long in a way Firebase can interpret?&#xA;Or am I going about this in a convoluted manner? Is there an easier way? I appreciate any help/comment. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="18800" LastActivityDate="2019-11-07T01:35:53.307" Title="How to send data from Arduino Uno with SIM900 GPRS to Firebase" Tags="|arduino-uno|shields|gps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21203" PostTypeId="2" ParentId="21202" CreationDate="2016-02-28T22:50:18.897" Score="2" Body="&lt;p&gt;Like you said, Firebase only accepts HTTPS traffic, which the Arduino Uno cant generate. Your HTTP requests first need to be sent through a proxy server that supports SSL, before being sent on to your Firebase database using a PUT or POST request. &lt;a href=&quot;http://www.devacron.com/arduino-firebase/&quot; rel=&quot;nofollow&quot;&gt;This site&lt;/a&gt; explains how to do everything from setting up your own proxy server to writing the GPS data (in your case) to Firebase. You may want to look at alternatives if this is too tedious for your purposes.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-28T22:50:18.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21204" PostTypeId="2" ParentId="21200" CreationDate="2016-02-29T00:34:56.403" Score="3" Body="&lt;p&gt;I like the Majenko's answer, but I'm going to explain it with a different approach. You know that there are some quantities that are measurable in an absolute way (mass, lenght, weight) and other that need a starting point to refer. Think about the &lt;strong&gt;distance&lt;/strong&gt;: you cannot say &quot;New York&quot; is distant 10km.. the question that obviously would come in mind is: 10km from what? So you have to decide a point in the world, from which you can measure the distance of every city.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage measure the potential, that is the energy that a single charge would have. Now the question is: is the potential energy an absolute value? Of course not, i have to define a point where it is zero, and measure everything from it. In a circuit this point is called Ground, evry potential measured in the circuit is calculated to the ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last step is to know that charges goes from the points at higher pot to the lowest one (the ground), usually preferring the path with lower resistsnce (but that's another story). &lt;strong&gt;A wire has the same potential all along it&lt;/strong&gt; and in order to compare the voltage of arduino and the battery pack they must refer to the same ground. &lt;/p&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-02-29T00:34:56.403" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21205" PostTypeId="1" AcceptedAnswerId="21206" CreationDate="2016-02-29T01:22:00.293" Score="1" ViewCount="757" Body="&lt;p&gt;I'm trying to replicate this: &lt;a href=&quot;https://zhengludwig.wordpress.com/projects/self-driving-rc-car/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://zhengludwig.wordpress.com/projects/self-driving-rc-car/&lt;/a&gt; using pretty much the exact same controller and car.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've soldered 4 wires to the controller, 1 for each direction. If I let the wires touch the ground on the controller everything works perfect. However, when I connect the wires to the Arduino nothing works. Sometimes left/right works for about 0.5 seconds then it goes back to doing nothing. Any idea on what the problem might be? Do I need to connect the controllers ground to the Arduino ground?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried removing the batteries from the controller and connecting 3.3V and ground from the Arduino, which sorta works but I feel like it shouldn't be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the buttons on the controller while it's connected to the Arduino it goes either forward, right or forward+right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I'm using to test everything looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  //Initialize the pins and serial&#xA;  pinMode(reversePin, OUTPUT);  &#xA;  pinMode(forwardPin, OUTPUT);&#xA;  pinMode(leftPin, OUTPUT);&#xA;  pinMode(rightPin, OUTPUT);&#xA;}&#xA;&#xA;void reset() {&#xA;  digitalWrite(forwardPin, HIGH);&#xA;  digitalWrite(reversePin, HIGH);&#xA;  digitalWrite(leftPin, HIGH);&#xA;  digitalWrite(rightPin, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  reset();&#xA;&#xA;  digitalWrite(forwardPin, LOW);&#xA;  delay(4000);&#xA;  reset();&#xA;  digitalWrite(reversePin, LOW);&#xA;  delay(4000);&#xA;  reset();&#xA;  digitalWrite(leftPin, LOW);&#xA;  delay(4000);&#xA;  reset();&#xA;  digitalWrite(rightPin, LOW);&#xA;  delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Images: &lt;a href=&quot;https://i.stack.imgur.com/mCpcI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/mCpcI.jpg&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18805" LastEditorUserId="18805" LastEditDate="2016-02-29T14:36:34.900" LastActivityDate="2020-03-24T07:19:51.043" Title="Controlling an RC car using Arduino" Tags="|arduino-uno|digital|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21206" PostTypeId="2" ParentId="21205" CreationDate="2016-02-29T01:53:04.907" Score="0" Body="&lt;p&gt;Can you measure how much current goes through the wire when grounded (A: 2 mA from measurements in comments) ? And the open circuit voltage between the controller's ground and the control wire?  (A: 3.1V, from 2xAA)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the current isn't more than the 40mA per pin/100mA per port, 200mA total, and the open circuit voltage of the controller pins is less than 5V, then you should be able to connect the Arduino's output pins and ground to your controller's wires and ground.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the voltages and currents are higher, then you would need protection to prevent damaging your Arduino.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The controller and the Arduino should share a common ground, but without a circuit and without the controller's voltages and currents, it is hard to tell exactly what is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Since the controller's open circuit voltage and short-circuit currents (3.1 V, 2mA max) fit within the Arduino's capabilities, you can wire them directly to the pin outputs, and make sure the controller and the arduino share a common ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a fifth wire between the controller ground to the Arduino ground to make the logic levels actually communicate between the two devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You likely also need some 5V-&gt;3V level shifting to isolate the Arduino's output levels from the controller's inputs.   Top of the line would be MOSFETS, but you could possibly use a voltage dividing resistor pair.  See the hints in &lt;a href=&quot;https://arduino.stackexchange.com/a/419/6628&quot;&gt;https://arduino.stackexchange.com/a/419/6628&lt;/a&gt;  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-29T18:15:47.383" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="21207" PostTypeId="1" CreationDate="2016-02-29T01:59:28.170" Score="2" ViewCount="239" Body="&lt;p&gt;tldr; I am writing a mesh network software using arduinos. I need to wirelessly receive, process, and transmit data, all simultaneously. I am aware of protothreads library, and the other software solutions, such as using interrupts, however, I am using relatively high baud rates. Thus each nanosecond is of the essence. Does anyone have any other ideas for me to achieve this? my initial thought is to have 2 Arduinos functioning as a single node in the mesh. One will receive while the other transmits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently using &lt;a href=&quot;http://oliverwhysall.co.uk/wp-content/uploads/2015/02/antenna-placement.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;these&lt;/a&gt; antennas to receive and send messages. I want to create a mesh network of Arduinos using these modules. I found several mesh libraries for Arduino, but none seem to quite do the task I need. So here is my plan which I will work through using an example. (This is a very naive explanation, and has flaws in it's implementation. This is just to give off the general idea). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each Arduino will be connected to a receiver &lt;em&gt;and&lt;/em&gt; a transmitter. Let's say I have just 4 nodes in the mesh.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Node #1 -&gt; Address = 0xA031&lt;/li&gt;&#xA;&lt;li&gt;Node #2 -&gt; Address = 0xB042&lt;/li&gt;&#xA;&lt;li&gt;Node #3 -&gt; Address = 0xC053&lt;/li&gt;&#xA;&lt;li&gt;Node #4 -&gt; Address = 0xD064&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I send a message to node A through USB. Let's say the message is &quot;SOS!&quot;&#xA;Node A will reconstruct the message in the following way so that the new message is &quot;0xA031_SOS!&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, Node A will begin transmitting this message continually. Let's say only Node C picks up the message. Node C will pick up the message and perform the following checks. (I will have 2 queues. A receiving queue and a transmitting queue. So as soon as a node receives a message, it will be placed in the receiving queue. And then it will run the following checks before sending it to the transmitting queue.)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is the address a recognized/valid address? Handle appropriately&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is the address of the received message the same as the node's own address? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;If address is same, check if the message received is the same message being transmitted currently by itself. If so, discard the message and tell transmitter to stop transmitting that message(This means that the message was originally transmitted to another node and came back, which means, it doesn't need to be re-transmitted any more). If the address is not the same, then send the message to the transmission queue.&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now the transmission will be handled the following way. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check if there is anything in the transmission queue. If there is, transmit this message continually until told not to. &lt;/li&gt;&#xA;&lt;li&gt;If the transmitter is told to not transmit that message any longer, that message will be popped of the queue.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So what happens? Node A continually sends a message. Node C receives the message and re-transmits. Because Node C was able to pick up Node A's message, it is in range and Node A will pick up Node C's message. Now, Node A will check the address, and say &quot;oh, this is the same address as me.&quot; Then it will check if the message being transmitted is the same as what was received. If so, then it will tell the transmission queue to no longer transmit that message. (This almost like a form of back propagation). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I realize there are a million ways to have collisions and infinite loops. I will be eventually writing a software to resolve these things. But I hope I am giving off the general idea of how the network will work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;As is clear from my explanation, because I am receiving and transmitting simultaneously, is there a way for me to do multi-threading? I am aware of protothreads and the other things mentioned in this &lt;a href=&quot;https://arduino.stackexchange.com/questions/286/how-can-i-create-multiple-running-threads&quot;&gt;post&lt;/a&gt;. However, all of them only offer a software solution, and not a hardware solution. So does anyone have any ideas of how I'd work around this? My initial thought is to have each node be composed of 2 Arduinos. Any one have any other ideas?&lt;/li&gt;&#xA;&lt;li&gt;Also, does anyone have a better idea of implementing the mesh to do what I want it to?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I know this is a very convoluted, hefty post. Please let me know what I should clarify. Thank you. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-02-29T08:55:37.750" Title="Receiving and transmitting messages simultaneously" Tags="|library|communication|networking|threads|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="21208" PostTypeId="2" ParentId="1180" CreationDate="2016-02-29T05:33:02.493" Score="0" Body="&lt;p&gt;Almost useful. It needs: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;logging serial data to a file OR  &lt;/li&gt;&#xA;&lt;li&gt;graphing from a file and updating every xxx milliseconds.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://live-graph.sourceforge.net/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Live Graph&lt;/a&gt; is a better option and I use it in conjunction with &lt;a href=&quot;https://ttssh2.osdn.jp/index.html.en&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tera Term&lt;/a&gt; which gets the data via the USB/serial link (and saves it to a log file which then Live Graph polls). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Live Graph is slightly buggy when caching data and I haven't found a way to set a moving window to display results. Also, showing multiple graphs requires manual scaling, but in spite of all this, it's still very useful. It's written in java so you'll need the JRE. I prefer this over having to install python like some of the other graphing programs do. another downside is that it opens 4 different windows, which is a pain when I want to flip between it and Tera Term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've yet to find software that's&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;An executable (.EXE) so it has no external reliance&lt;/li&gt;&#xA;&lt;li&gt;Includes a terminal emulator or serial data logger&lt;/li&gt;&#xA;&lt;li&gt;Logs serial data&lt;/li&gt;&#xA;&lt;li&gt;Graphs multiple items from a CSV&lt;/li&gt;&#xA;&lt;li&gt;Allows for CSV AND tab-delimited data (which is way easier to read as it scrolls along while &lt;em&gt;simultaneously&lt;/em&gt; monitoring the graph.&lt;/li&gt;&#xA;&lt;li&gt;Allows setting of different scales for each overlaid graph without having to scale everything to [0..1] or setting a multiplier, i.e. allowing setting an [y0..y1] range for each item graphed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18808" LastEditorUserId="19409" LastEditDate="2019-07-01T01:49:41.880" LastActivityDate="2019-07-01T01:49:41.880" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="21209" PostTypeId="2" ParentId="21200" CreationDate="2016-02-29T05:38:30.590" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;so because the arduino is sending a signal to one of the pins on the servo, the servo needs to be connected to Arduino's ground.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here is typically how you might wire a servo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N7p69.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N7p69.jpg&quot; alt=&quot;Servo wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note the shared ground. The Arduino provides the control signal (data) via the orange wire. The battery provides the motor power via the red wire. The grounds must be shared or the voltages on each wire are meaningless.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-02-29T05:38:30.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21210" PostTypeId="1" AcceptedAnswerId="21226" CreationDate="2016-02-29T05:50:28.370" Score="0" ViewCount="2151" Body="&lt;p&gt;I bought a &lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0&quot; rel=&quot;nofollow&quot;&gt;Gsm module&lt;/a&gt; recently(not official arduino shield) and i connect it to Arduino uno. The problem (I guess) is , i can't set delay properly, the terminal send it too fast that i missed it or too slow even i set its baud rate to 4800 (I have tried it with many baud from 4800-to-115200).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the code to Git ,with &lt;a href=&quot;https://github.com/zigi1/Test/blob/master/gsm.c&quot; rel=&quot;nofollow&quot;&gt;this address&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details: For example when i enter &lt;code&gt;d&lt;/code&gt; in terminal it act like this message came up : &lt;code&gt;+CMTI: &quot;SM&quot;,3&lt;/code&gt; and it want to save it but it miss plus at first of it and it save &lt;code&gt;CMTI: &quot;SM&quot;,3&lt;/code&gt;,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that it perform this : &lt;code&gt;AT+CMGR=3&lt;/code&gt; the terminal show the message in half size : &lt;code&gt;+CMGR: &quot;REC UNREAD&quot;,&quot;+9*********2&quot;,&quot;H/E.3D/1&quot;,&quot;16/02/28,00:27:02+14&quot;&lt;/code&gt; which totally missed body part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The weird thing is when i put some println on the program it miss more characters , and second weird thing is it missed more character in second run or i push d again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to change the delays but no success.How can i fix it ? any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If i make it simpler, when i use these code i get half message :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial serialGPRS(7, 8);&#xA;void setup()&#xA;{  &#xA;  Serial.begin(19200);          &#xA;  serialGPRS.begin(19200);              &#xA;}&#xA;void loop()&#xA;{&#xA;  serialGPRS.println(&quot;AT+CMGR=1&quot;);&#xA;  delay(1000);&#xA;  while(serialGPRS.available()!=0)&#xA;    Serial.write(serialGPRS.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;like: &lt;code&gt;+CMGR: &quot;REC READ&quot;,&quot;+9*******&quot;,&quot;.H/E.3D/1&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="18777" LastEditorUserId="18777" LastEditDate="2016-02-29T08:10:40.443" LastActivityDate="2016-02-29T12:42:05.807" Title="How to set Delay on GSM shield?" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21213" PostTypeId="1" AcceptedAnswerId="21225" CreationDate="2016-02-29T06:56:44.343" Score="1" ViewCount="3217" Body="&lt;p&gt;I'm planning to connect GPS to IMU, Is't possible ? I tried my best to find an article that can help solving my curiosity.  How can i connect GPS and MPU to arduino uno?&lt;/p&gt;&#xA;" OwnerUserId="18813" LastActivityDate="2016-02-29T11:27:22.947" Title="How to connect GPS to IMU?" Tags="|arduino-uno|mpu6050|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21214" PostTypeId="1" CreationDate="2016-02-29T07:02:36.120" Score="0" ViewCount="4850" Body="&lt;p&gt;I have been experiment with the arduino uno board from few days but can't seem to make it serve web page stored in SD card of ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I print the contents of the file to serial it works properly, even embedding the HTML code works fine, but &lt;code&gt;client.write()&lt;/code&gt; just produces a never ending garbage text of &lt;code&gt;ÿÿÿÿÿÿÿÿÿÿÿÿ&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;IPAddress ip(192, 168, 0, 115);&#xA;EthernetServer server(80);&#xA;&#xA;File webFile;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(4, OUTPUT);&#xA;    digitalWrite(4, HIGH);&#xA;    Ethernet.begin(mac, ip);&#xA;    server.begin();&#xA;    Serial.begin(9600);&#xA;&#xA;// initialize SD card&#xA;Serial.println(&quot;Initializing SD card...&quot;);&#xA;if (!SD.begin(4)) {&#xA;    Serial.println(&quot;ERROR - SD card initialization failed!&quot;);&#xA;    return;&#xA;}&#xA;&#xA;Serial.println(&quot;SUCCESS - SD card initialized.&quot;);&#xA;// check for index.htm file&#xA;if (!SD.exists(&quot;index.htm&quot;)) {&#xA;    Serial.println(&quot;ERROR - Can't find index.htm file!&quot;);&#xA;    return;  // can't find index file&#xA;}&#xA;Serial.println(&quot;SUCCESS - Found index.htm file.&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;EthernetClient client = server.available();  // try to get client&#xA;&#xA;if (client) {  // got client?&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;        if (client.available()) {   // client data available to read&#xA;            char c = client.read(); // read 1 byte (character) from client&#xA;            // last line of client request is blank and ends with \n&#xA;            // respond to client only after last line received&#xA;            if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;                // send a standard http response header&#xA;                client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;                client.println(&quot;Content-Type: text/html&quot;);&#xA;                client.println(&quot;Connection: close&quot;);&#xA;                Serial.println(&quot;starting to open htm&quot;);&#xA;                client.println();&#xA;                // send web page&#xA;                webFile = SD.open(&quot;index.htm&quot;);        // open web page file&#xA;                if (webFile) {&#xA;                    while(webFile.available()) {&#xA;                        client.write(webFile.read()); // send web page to client&#xA;                    }&#xA;                    webFile.close();&#xA;                }&#xA;                break;&#xA;            }&#xA;            // every line of text received from the client ends with \r\n&#xA;            if (c == '\n') {&#xA;                // last character on line of received text&#xA;                // starting new line with next character read&#xA;                currentLineIsBlank = true;&#xA;            } &#xA;            else if (c != '\r') {&#xA;                // a text character was received from client&#xA;                currentLineIsBlank = false;&#xA;            }&#xA;        } // end if (client.available())&#xA;    } // end while (client.connected())&#xA;    delay(1);      // give the web browser time to receive the data&#xA;    client.stop(); // close the connection&#xA;} // end if (client)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sorry for the poor formatting, I just copied it from tutorial, please help me out.&lt;/p&gt;&#xA;" OwnerUserId="18655" LastActivityDate="2019-12-20T03:03:00.630" Title="Simple webpage serve with Arduino ethernet shield on SD card" Tags="|arduino-uno|ethernet|sd-card|web-server|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21215" PostTypeId="1" CreationDate="2016-02-29T07:32:01.090" Score="27" ViewCount="112769" Body="&lt;p&gt;I just plugged my arduino in and the light is on, but the blink test failed to upload. here is my error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino: 1.6.7 (Linux), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: ser_open(): can't open device &quot;/dev/ttyUSB0&quot;: Permission denied&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;noreferrer&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &gt; Preferences.&lt;/p&gt;&#xA;" OwnerDisplayName="user18719" LastActivityDate="2019-06-27T20:57:46.660" Title="First time set up- permission denied to usb port- ubuntu 14.04" Tags="|usb|ubuntu|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21218" PostTypeId="2" ParentId="21214" CreationDate="2016-02-29T08:09:56.113" Score="1" Body="&lt;p&gt;&quot;ÿ&quot; is character code 255, the erased state of a Flash/EPROM/SD. Check if your SD card format OK, 'index.htm' file is there, and your code can read it.&lt;/p&gt;&#xA;" OwnerUserId="18814" LastActivityDate="2016-02-29T08:09:56.113" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21219" PostTypeId="2" ParentId="21215" CreationDate="2016-02-29T08:41:29.407" Score="41" Body="&lt;p&gt;From &lt;a href=&quot;https://www.arduino.cc/en/Guide/Linux#toc6&quot; rel=&quot;noreferrer&quot;&gt;the documentation&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Open Terminal and type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls -l /dev/ttyACM*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;you will get something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;The &quot;0&quot; at the end of ACM might be a different number, or multiple entries might be returned. The data we need is &quot;dialout&quot; (is the group owner of the file).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Now we just need to add our user to the group:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo usermod -a -G dialout $USER&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo chmod a+rw /dev/ttyACM0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;You will need to log out and log in again for this change to take effect.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Note that the preceding is old Ubuntu instructions. On modern distros that use ConsoleKit create the file &lt;code&gt;/etc/udev/rules.d/01-ttyusb.rules&lt;/code&gt; containing the following and then reload the udev rules and replug the Arduino device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEMS==&quot;usb-serial&quot;, TAG+=&quot;uaccess&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="26916" LastEditDate="2017-10-15T00:35:14.437" LastActivityDate="2017-10-15T00:35:14.437" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="21220" PostTypeId="2" ParentId="19310" CreationDate="2016-02-29T09:15:37.277" Score="2" Body="&lt;p&gt;I do not use Gentoo, but I can tell you how things work on Ubuntu 14.04,&#xA;which also installs Arduino 1.0.5. I assume Gentoo should not be that&#xA;different... The dependency tree is like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The package named &quot;arduino&quot;, version 1.0.5, contains the IDE. It&#xA;depends on Java and on arduino-core.&lt;/li&gt;&#xA;&lt;li&gt;arduino-core, version 1.0.5 also, has the Arduino core libraries. It&#xA;depends on gcc-avr, avrdude and avr-libc.&lt;/li&gt;&#xA;&lt;li&gt;gcc-avr comes as version 4.8, avr-libc is version 1.8.0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When you compile a program for an Uno, on the link stage avr-g++ gets&#xA;called, and it is asked to link your object files with libcore.a (the&#xA;Arduino core) and -lm (the math library). avr-g++ in turn calls the&#xA;linker (collect2) and asks it to link together&#xA;/usr/lib/avr/lib/avr5/crtm328p.o (the C runtime), your object files,&#xA;libcore.a, -lgcc (the GCC support libraries), -lm and -lc (avr-libc).&#xA;Notice that there is no crtatmega328p.o, it's called crtm328p.o instead.&#xA;And there is no -latmega328p.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For diagnosing your problem, you can set an IDE preference so that it&#xA;shows you the exact command lines it runs for compiling your program.&#xA;You can then copy and paste the last command (link stage) on a terminal.&#xA;If you add the &lt;code&gt;-v&lt;/code&gt; option (meaning “verbose”), you will see what gcc is&#xA;asking the linker to put together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to fix your problem with a simple symlink from&#xA;crtm328p.o to crtm328p.o. If you are using vanilla Gentoo packages, you&#xA;should then file a bug to the packager. On Ubuntu, you type&#xA;&lt;code&gt;sudo apt-get install arduino&lt;/code&gt; and it just works.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-02-29T09:15:37.277" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="21223" PostTypeId="1" AcceptedAnswerId="21224" CreationDate="2016-02-29T11:17:00.717" Score="1" ViewCount="1278" Body="&lt;p&gt;I have been wondering how to remote control my arduino robot using an old 2.4ghz car toy transmitter which has 4 buttons, up down left and right. &#xA;I have the nRF24L01(+) 2.4GHz transceiver to use it as a receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anyway to detect the signals going out from the remote controller and use them to make my arduino works,&#xA;I am a newbie so i am sorry if any mistake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks guys!&lt;/p&gt;&#xA;" OwnerUserId="18821" LastActivityDate="2016-02-29T11:22:52.117" Title="How to remote control Arduino using an old 2.4Ghz toy remote controller?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21224" PostTypeId="2" ParentId="21223" CreationDate="2016-02-29T11:22:52.117" Score="3" Body="&lt;p&gt;You have two options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use an nRF24L01+ on the Arduino and dismantle the controller to rip out the innards, replacing them with another Arduino and another nRF24L01+.&lt;/li&gt;&#xA;&lt;li&gt;Do not use the nRF24L01+, instead, rip apart the car and salvage the receiver from it, then work out how you can wire that to the Arduino.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The car's controller will not talk to the nRF24L01+. Yes, they may be in the same frequency band, but they do not talk the same language. After all, your WiFi is on the same band and that doesn't talk to the car, and your microwave, which is also 2.4GHz, doesn't sit and watch satellite TV all day. As you can see the 2.4GHz band is used by a huge number of devices (the band is actually getting quite crowded) and everything talked to everything else in the same band it would be utter chaos.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-29T11:22:52.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21225" PostTypeId="2" ParentId="21213" CreationDate="2016-02-29T11:27:22.947" Score="3" Body="&lt;p&gt;Is not really connecting GPS to IMU, is more like you read GPS values, read IMU values and after apply what is called a sensor fusion algorithm. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the most common used sensor fusion algorithms is called Kalman filter (the Extended Kalman Filter more likelly). However, if you do not have some basis on control theory you may have more trouble in applying it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://publications.lib.chalmers.se/records/fulltext/159412.pdf&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; is a good example of use of this kind of sensors and fusion algorithms. It is also very commonly used in drones or autonomous vehicles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The implementation will be specific to what you are trying to do.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-02-29T11:27:22.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21226" PostTypeId="2" ParentId="21210" CreationDate="2016-02-29T12:42:05.807" Score="2" Body="&lt;p&gt;The &lt;code&gt;SoftwareSerial&lt;/code&gt; receive buffer is getting filled up and discarding characters. You are not reading fast enough from the buffer. Adding &lt;code&gt;Serial.println()&lt;/code&gt; will slow down your &lt;code&gt;read&lt;/code&gt;ing even more. The simplest solution to this is to increase the size of the &lt;code&gt;SoftwareSerial&lt;/code&gt; buffer from its default size of 64 bytes to 256 bytes (or smaller, depending on what works for you). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a Windows PC, go to &lt;code&gt;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial&lt;/code&gt;. Open &lt;code&gt;SoftwareSerial.h&lt;/code&gt; and change the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define _SS_MAX_RX_BUFF 64 // RX buffer size&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define _SS_MAX_RX_BUFF 256 // RX buffer size&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save the file and try your sketch again.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-02-29T12:42:05.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21227" PostTypeId="2" ParentId="19986" CreationDate="2016-02-29T14:48:55.337" Score="1" Body="&lt;p&gt;After uploading the sketch from your laptop you should disconnect your Arduino and Ethernet shield setup from your laptop and then use a switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the same setup to the switch at one end and the other end of the switch must be connected to your laptop then you can try to access your web page using IP address you specified in Ethernet sketch. &lt;/p&gt;&#xA;" OwnerUserId="18825" LastEditorUserId="6936" LastEditDate="2016-03-02T10:32:56.637" LastActivityDate="2016-03-02T10:32:56.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21228" PostTypeId="1" AcceptedAnswerId="21229" CreationDate="2016-02-29T14:58:23.103" Score="0" ViewCount="2198" Body="&lt;p&gt;I'm writing a library which controls a device using SPI bus. For the communication I need to manually toggle the chip select pin. On most Arduinos SS pin is on D10, but there are also other models where it's different like D53 on Mega. Is there a way to know where it is? Like a global #define? I would like to avoid any pin configuration parameters in my library. At least for default configuration...&lt;/p&gt;&#xA;" OwnerUserId="18824" LastActivityDate="2016-02-29T15:11:11.677" Title="Are there any constants for default SPI port pins defined?" Tags="|library|spi|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21229" PostTypeId="2" ParentId="21228" CreationDate="2016-02-29T15:10:15.647" Score="5" Body="&lt;p&gt;Yes there are. They are defined in pins_arduino.h Below the pins for the yun.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Map SPI port to 'new' pins D14..D17&#xA;static const uint8_t SS   = 17;&#xA;static const uint8_t MOSI = 16;&#xA;static const uint8_t MISO = 14;&#xA;static const uint8_t SCK  = 15;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use SS MOSI MISO and SCK in your code&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-02-29T15:10:15.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21230" PostTypeId="2" ParentId="21228" CreationDate="2016-02-29T15:11:11.677" Score="1" Body="&lt;p&gt;This is defined in the platform variant specific file &lt;code&gt;pins_arduino.h&lt;/code&gt; in the variants folder (\hardware\arduino\avr\variants). Each platform variant (standard, mega, leonardo etc) gets their pin definitions set here. For instance the mega:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t SS   = 53;&#xA;static const uint8_t MOSI = 51;&#xA;static const uint8_t MISO = 50;&#xA;static const uint8_t SCK  = 52;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6703" LastActivityDate="2016-02-29T15:11:11.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21231" PostTypeId="2" ParentId="21181" CreationDate="2016-02-29T16:07:19.610" Score="2" Body="&lt;p&gt;Thanks @Arjan for reminding me. I would love to contribute to the community. So this is my final coding and its worked for me :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int redLed = 2;&#xA;const int greenLed = 3;&#xA;const int yellowLed = 4;&#xA;const int greenbigLed = 7;&#xA;&#xA;const int buttonPin1 = 5;&#xA;const int buttonPin2 = 6;&#xA;&#xA;int buttonState1 = 0;&#xA;int buttonState2 = 0;&#xA;float tempC ;&#xA;int analogPin = A0;&#xA;int yellowLedState = 0;&#xA;&#xA;const long interval = 5000;&#xA;unsigned long previousMillis = 0;   &#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;pinMode(2,OUTPUT);&#xA;pinMode(3,OUTPUT);&#xA;pinMode(4,OUTPUT);&#xA;pinMode(5,INPUT);&#xA;pinMode(6,INPUT);&#xA;Serial.begin(9600);&#xA;digitalWrite(yellowLed,yellowLedState);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;int analogValue = analogRead(analogPin);&#xA;int buttonState1 = digitalRead(buttonPin1);&#xA;int buttonState2 = digitalRead(buttonPin2);&#xA;int yellowLedState = digitalRead(yellowLed);&#xA;tempC = analogValue / 10 ;&#xA;Serial.println(tempC);&#xA;unsigned long currentMillis = millis();&#xA;&#xA;if (tempC &amp;lt;= 89.9 &amp;amp;&amp;amp; tempC &amp;gt;= 0){&#xA;  digitalWrite(redLed,HIGH);&#xA;  digitalWrite(greenLed,LOW);&#xA;}else if(tempC == 102){&#xA;  digitalWrite(redLed,LOW);&#xA;  digitalWrite(greenLed,HIGH);&#xA;}&#xA;&#xA;if(currentMillis - previousMillis &amp;gt;= interval){&#xA;  previousMillis = currentMillis;&#xA;      if(buttonState1 == HIGH){&#xA;         if (yellowLedState == LOW) {&#xA;              yellowLedState = HIGH;&#xA;    } &#xA;    digitalWrite(yellowLed, yellowLedState);&#xA;  } else{&#xA;      digitalWrite(yellowLed,LOW);&#xA;    }&#xA;}&#xA;&#xA;&#xA;if (buttonState2 == HIGH &amp;amp;&amp;amp; yellowLedState == HIGH){&#xA;  digitalWrite(greenbigLed, HIGH);&#xA;  digitalWrite(yellowLed,HIGH);&#xA;}else{&#xA;  digitalWrite(greenbigLed,LOW);&#xA;  if(currentMillis - previousMillis &amp;gt;= interval){&#xA;  previousMillis = currentMillis;&#xA;      if(buttonState1 == HIGH){&#xA;         if (yellowLedState == LOW) {&#xA;              yellowLedState = HIGH;&#xA;    } &#xA;    digitalWrite(yellowLed, yellowLedState);&#xA;  } else{&#xA;      digitalWrite(yellowLed,LOW);&#xA;    }&#xA;}&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17280" LastActivityDate="2016-02-29T16:07:19.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21235" PostTypeId="1" CreationDate="2016-02-29T18:04:40.373" Score="0" ViewCount="191" Body="&lt;p&gt;I have switch is a line connected to Digital pins 1,2,3,4,5 . When pins 1 connects, I need a timer to start. as the rest connect i need it to mark the time in the console output of each one and End on the timer on connection to pin 5. ex&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;START:&#xA;0.00&#xA;1.43&#xA;2.12&#xA;2.94&#xA;3.89&#xA;END&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also is there a way to Save the data to a log (.txt or whatever) If not its fine but I need to record results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is for a school project)&#xA;THANKS!&lt;/p&gt;&#xA;" OwnerUserId="18831" LastEditorUserId="18831" LastEditDate="2016-02-29T19:02:29.577" LastActivityDate="2016-02-29T19:08:35.607" Title="Start timer when pins connected" Tags="|arduino-uno|timers|time|wires|digital|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21237" PostTypeId="1" CreationDate="2016-02-29T18:38:57.673" Score="3" ViewCount="2774" Body="&lt;p&gt;I've just buy this 8x8 LED matrix &lt;a href=&quot;https://upverter.com/upn/eca2aa194e82bd81/&quot; rel=&quot;nofollow&quot;&gt;WLG M20088A/BEG&lt;/a&gt; and I'm trying to light all the LEDs in one single color (green) but I don't understand how the 24 pins work for this specific model. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that every manufacturer makes different models. Does anyone have any experience with this particular model?&lt;/p&gt;&#xA;" OwnerUserId="18660" LastEditorUserId="46" LastEditDate="2016-02-29T20:02:13.423" LastActivityDate="2016-03-02T11:36:17.243" Title="How to use a Bi-color matrix led 8x8 with 24 pins?" Tags="|led|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21238" PostTypeId="2" ParentId="21237" CreationDate="2016-02-29T18:47:08.123" Score="1" Body="&lt;p&gt;It seems to be:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Row 1 - 8 --&gt; common cathode pins per row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To light up a whole row, you must connect row X pin to Gnd and all green or red columns to High (Vcc). Do not forget to add a resistance in series!&lt;/p&gt;&#xA;" OwnerUserId="14766" LastActivityDate="2016-02-29T18:47:08.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21239" PostTypeId="2" ParentId="21237" CreationDate="2016-02-29T18:49:32.250" Score="4" Body="&lt;p&gt;Take a closer look at the device schematic diagram, which I copy below. It will tell you how each of the LEDs are wired. For example, the green LED on the upper-left corner (which I marked with a green circle) has its anode (positive terminal) wired to pin 5, while its cathode (negative terminal) is wired to pin 1. Can you see that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nVXFo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nVXFo.png&quot; alt=&quot;LED matrix schematic diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To light up that LED (&lt;strong&gt;green&lt;/strong&gt; LED on the upper-left corner), you must apply voltage (with limited current), to pins 1 (-) and 5 (+). If you wanted to light up the &lt;strong&gt;red&lt;/strong&gt; LED at the same position instead, you should apply voltage to pins 1 (-) and 20 (+).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To light up all LEDs of a given color, you'll have to connect pins 1, 2, 3, 4, 21, 22, 23 and 24 to the negative terminal of your power supply. These are the LED common anodes. They are called common because they are shared among each pair of red and green LEDs. If you choose to use the red LEDs, you'll also have to wire pins 13 through 20 to your positive supply. On the other hand, if you pick green, you'll wire pins 5 through 12. These are the LED cathodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget to wire a current limiting resistor in series with each LED.&lt;/p&gt;&#xA;" OwnerUserId="46" LastEditorUserId="46" LastEditDate="2016-03-02T11:36:17.243" LastActivityDate="2016-03-02T11:36:17.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21240" PostTypeId="2" ParentId="21235" CreationDate="2016-02-29T19:07:36.787" Score="2" Body="&lt;p&gt;I will not give you code, only clues on how to write the code yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way to tackle this is to (at first) remove the Arduino from the equation. Replace it, instead, with you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine you are doing the timing yourself. How would &lt;em&gt;you&lt;/em&gt; go about doing it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I would set about the task:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When the first button gets pressed I would look at the clock and jot down the current time.&lt;/li&gt;&#xA;&lt;li&gt;When the second button gets pressed I would again look at the clock, and subtract the first time from the current time to find out how much time has elapsed. I would jot that down.&lt;/li&gt;&#xA;&lt;li&gt;When the third button is pressed I would do the same again - look at the clock, subtract the start time, and jot down the difference.&lt;/li&gt;&#xA;&lt;li&gt;And I would keep going until I had run out of buttons.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So now you need to find the right code to read what buttons are doing, get the current time, and finally send the times somewhere useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For all those there are many many many examples on the web.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-29T19:07:36.787" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21241" PostTypeId="2" ParentId="21235" CreationDate="2016-02-29T19:08:35.607" Score="2" Body="&lt;p&gt;Are you familiar with interrupts? The best/most efficient way to do this is with pin interrupts on each input pin (and make sure your switches are wired correctly and debounced).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, within the Arduino libraries, there are only two pin interrupts (0 and 1), which correspond to pins 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a polling solution. Use one pin with an interrupt to start the timer (save the value of &lt;code&gt;millis()&lt;/code&gt;) and then poll the other switches in a loop, capturing the &lt;code&gt;millis()&lt;/code&gt; value at each switch closure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, the ATmega can fire an interrupt when &lt;em&gt;any&lt;/em&gt; pin in a port changes, but IIRC this isn't built into the Arduino libraries and requires direct register manipulation.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-02-29T19:08:35.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21242" PostTypeId="1" AcceptedAnswerId="21243" CreationDate="2016-02-29T19:11:59.623" Score="-3" ViewCount="83" Body="&lt;pre&gt;&lt;code&gt;int k ;&#xA;int q ;&#xA;int f;//pot&#xA;&#xA;void setup() {&#xA;  pinMode(k, OUTPUT);&#xA;  pinMode(q, OUTPUT);&#xA;  pinMode(f, INPUT);&#xA;}&#xA;void loop() {&#xA;  zzf();&#xA;}&#xA;&#xA;void gf()&#xA;{&#xA;  int a = f;//test the conditions of f and store in new variable int a&#xA;  if (a == 80)//if a reads 80 then increment a by 1&#xA;  {&#xA;    ei();//run the ei() function&#xA;  }&#xA;}&#xA;&#xA;void ei() {&#xA;  int k = 3;&#xA;  int a = Serial.read();&#xA;  {&#xA;    digitalWrite(k, a);&#xA;  }&#xA;}&#xA;&#xA;void zzf() {&#xA;  for (f = 0; f &amp;lt; 80; f++) {&#xA;    analogWrite(q, f);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18832" LastEditorUserId="18832" LastEditDate="2016-03-01T06:35:11.300" LastActivityDate="2016-03-01T06:35:11.300" Title="questions about sketch" Tags="|sketch|" AnswerCount="1" CommentCount="7" ClosedDate="2016-03-03T20:55:15.513" ContentLicense="CC BY-SA 3.0" />
  <row Id="21243" PostTypeId="2" ParentId="21242" CreationDate="2016-02-29T19:42:07.417" Score="5" Body="&lt;p&gt;Lean the proper C syntax. This is completely wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void gf()&#xA;int a = f;//test the conditions of f and store in new variable int a&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is just as wrong for the same reasons:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ei()&#xA;int k = 3&#xA;int a = Serial.read();&#xA;{digitalWrite(k, a);}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-02-29T19:42:07.417" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="21244" PostTypeId="1" CreationDate="2016-02-29T20:14:42.993" Score="5" ViewCount="979" Body="&lt;p&gt;I've a &lt;a href=&quot;https://github.com/mamert/iot-a/blob/master/_60_led_clock/_60_led_clock.ino&quot; rel=&quot;noreferrer&quot;&gt;wall clock&lt;/a&gt; (sorry, code's a mess, look for &lt;code&gt;updateClockVars&lt;/code&gt;) which makes use of the &lt;a href=&quot;https://github.com/JChristensen/Timezone&quot; rel=&quot;noreferrer&quot;&gt;Timezone library&lt;/a&gt; (and ultimately &lt;a href=&quot;http://playground.arduino.cc/Code/Time&quot; rel=&quot;noreferrer&quot;&gt;Time&lt;/a&gt;). Nothing fancy, call millis() every loop; turn to Hrs, Mins, Secs; display on LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The magnitude of the drift I am seeing on my 2 Arduino Pro Mini - compatible boards - up to ~8% lag, not a typo - blows my mind. Replacing the 16MHz quartz with one bought at a local retailer didn't help much (~33% improvement). Is something else at play here?&lt;/p&gt;&#xA;" OwnerUserId="16606" LastActivityDate="2016-03-01T09:48:36.397" Title="Clock drift - is the precision of the crystal the only culprit?" Tags="|time|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21245" PostTypeId="2" ParentId="1180" CreationDate="2016-02-29T20:20:09.667" Score="6" Body="&lt;p&gt;Nobody had mentioned Processing which is super versatile. You can do a lot more than just plotting but if that's all you want to do you can use the gwoptics library; hook up Arduino and Processing as directed &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2810" LastEditorUserId="11529" LastEditDate="2016-03-01T17:15:49.037" LastActivityDate="2016-03-01T17:15:49.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21246" PostTypeId="2" ParentId="21137" CreationDate="2016-02-29T20:25:40.537" Score="1" Body="&lt;p&gt;I asked a &lt;a href=&quot;https://arduino.stackexchange.com/questions/19892/list-of-arduino-board-preprocessor-defines&quot;&gt;related question&lt;/a&gt; a while ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An internal *.h file exists which is created by the IDE, and holds in it the type of board that has been selected. The list of possible options is given in the linked question, but only for AVR boards. I believe the non-AVR list is much shorter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is simply a matter of adding some conditional statements to send the PC the correct information. A simple example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//...within your code, perhaps during setup()...&#xA;#ifdef ARDUINO_AVR_UNO&#xA;    serial.println(&quot;UNO&quot;);&#xA;#endif&#xA;#ifdef ARDUINO_AVR_LEONARDO&#xA;    serial.println(&quot;LEONARDO&quot;);&#xA;#endif&#xA;// etc...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to refer to the board type more than once in the sketch, use the following format:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//...BEFORE setup(), or otherwise in the global namespace...&#xA;#ifdef ARDUINO_AVR_UNO&#xA;    #define __BOARD_TYPE &quot;UNO&quot;&#xA;#endif&#xA;#ifdef ARDUINO_AVR_LEONARDO&#xA;    #define __BOARD_TYPE &quot;LEONARDO&quot;&#xA;#endif&#xA;// etc...&#xA;&#xA;// within your code, wherever necessary:&#xA;serial.println(__BOARD_TYPE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The latter is much tidier, even if you only need &lt;code&gt;__BOARD_TYPE&lt;/code&gt; once, as it removes the cumbersome &lt;code&gt;#ifdef&lt;/code&gt; chunk from your functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will, of course, have to write one for each board that you expect your end-user could have, and you will possibly need to update this list as new models appear.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-15T12:55:41.517" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21248" PostTypeId="2" ParentId="21244" CreationDate="2016-02-29T22:29:30.100" Score="3" Body="&lt;p&gt;TL;DR You're doing it wrong. Use RTC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, longer explaination is required here. &lt;code&gt;millis()&lt;/code&gt; is not accurate and here is why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, grab official Arduino source code from their &lt;a href=&quot;https://github.com/arduino/Arduino&quot; rel=&quot;nofollow&quot;&gt;Github repo&lt;/a&gt;.&#xA;The file &lt;code&gt;Arduino-master/hardware/arduino/avr/cores/arduino/Arduino.h&lt;/code&gt;&#xA;contains few interesting macros (I'm pasting &lt;code&gt;grep&lt;/code&gt; output here):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino.h:#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )&#xA;Arduino.h:#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )&#xA;Arduino.h:#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At 16MHz &lt;code&gt;clockCyclesPerMicrosecond()&lt;/code&gt; will evaluate to &lt;code&gt;16&lt;/code&gt;. Keep this number in memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those macros are used in &lt;code&gt;Arduino-master/hardware/arduino/avr/cores/arduino/wiring.c&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the prescaler is set so that timer0 ticks every 64 clock cycles, and the&#xA;// the overflow handler is called every 256 ticks.&#xA;#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))&#xA;&#xA;// the whole number of milliseconds per timer0 overflow&#xA;#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;MICROSECONDS_PER_TIMER0_OVERFLOW&lt;/code&gt; macro is evaluated as &lt;code&gt;(64 * 256)/16&lt;/code&gt; -  a dodgy looking &lt;strong&gt;1024&lt;/strong&gt;. Look how they round it down to calcuate &lt;code&gt;MILLIS_INC&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume that you run your Arduino with &lt;strong&gt;ideal&lt;/strong&gt; main clock signal.&#xA;At 16MHz main clock, the timer frequency is 1.024kHz, not 1kHz. This results in 2.4% inaccuracy. You can get away with that in most cases, but &lt;strong&gt;not when you're building a clock&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This 2.4% error is best case. Your main oscillator is not 16MHz - it has it's own inaccuracy, that is unknown and it sums up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should use an external, accurate time reference provided by RTC module. When assembled properly, they guarante low time drift, temperature compensation and other goodies. Be smart - use RTC. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are scared of I2C RTC modules, you may find my &lt;a href=&quot;https://iobtoolkit.com/docs/tutorials/i2c_terminal_mcp7940n.html#mcp7940n-chip&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;&#xA;and &lt;a href=&quot;https://iobtoolkit.com/docs/tutorials/i2c_python_mcp7940n.html&quot; rel=&quot;nofollow&quot;&gt;another tutorial&lt;/a&gt; on MCP7940N RTC module. Know-how is applicable with other RTCs as well.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-02-29T22:39:48.903" LastActivityDate="2016-02-29T22:39:48.903" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21249" PostTypeId="2" ParentId="21244" CreationDate="2016-02-29T22:45:16.927" Score="6" Body="&lt;p&gt;The problem is the interaction between the interrupt handler that updates the value for the millis() function and the neopixels show() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To maintain the counter for the millis() function a interrupt is triggered approximately every 1.024 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the show() function is called all interrupts are disabled to get the precise timing needed to send the data to the neopixels.  For a 60 led strip this takes about 1800 microseconds (60 leds * 24 bits * 1.25 us per bit) so at least one interrupt is skipped each time you update the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/&quot;&gt;This page&lt;/a&gt; has details about how the millis() function works.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2016-02-29T22:45:16.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21250" PostTypeId="1" AcceptedAnswerId="21252" CreationDate="2016-03-01T00:13:06.317" Score="2" ViewCount="164" Body="&lt;p&gt;A friend of mine gave me a 2in. 4 digit seven segment display. But when I sat down and looked at it, I found it has 7 pins on one side and 5 on the other and no indicators of its pinout on it. The only information I could gleam from it was the (presumably its model number) which said &quot;PARA LIGHT A-5V4G-12-U1 H H0615&quot;. I searched online for it but only found ambiguous information that didn't help me. I have a feeling this is a fairly easy question, if so: sorry I am a noob.&lt;/p&gt;&#xA;" OwnerUserId="17269" LastActivityDate="2016-03-01T13:14:00.880" Title="Need help figuring out the pinout of a seven segmented display" Tags="|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21252" PostTypeId="2" ParentId="21250" CreationDate="2016-03-01T02:03:02.197" Score="7" Body="&lt;p&gt;Without an image of the display, I'll have to guess. With 12 pins in total, what you most likely have is: 8 pins for 7 segments and the decimal point, and 4 COMMON anodes or cathodes, a detail you will have to discover yourself. This process requires a power source that can safely light LEDs. A multimeter in diode test mode will do since theres usually about 2 V across the probes and some internal resistance, enough to light up the LEDs in the display, though they wont be very bright. I will try to list the minimum number of steps needed to determine the pinout using this method.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Using a multimeter set to diode test mode, place the red probe on any pin (though its good to start at the edges). Now lazily run (i.e. make contact) the black probe through the remaining pins. If the display is a &lt;em&gt;common anode&lt;/em&gt; display, you should see the all the segments of a &lt;strong&gt;particular&lt;/strong&gt; digit (not &lt;strong&gt;different&lt;/strong&gt; digits) light up in sequence.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Else, keep running the black probe through the pins until any segment at all lights up. Hold the black probe on that pin that caused the segment to turn on. Now run the red probe through the other pins. If all the segments of a particular digit light up in sequence, this indicates a &lt;em&gt;common cathode&lt;/em&gt; display.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Another possibility is that no segment lights up at all, despite steps 1 &amp;amp; 2. Substitute the red probe, where it is held steady, for the black probe. Run the red probe through the remaining pins. If all the segments of a particular digit light up, then the display is a &lt;em&gt;common cathode&lt;/em&gt; display.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;On the other hand, if no digit's segments light up sequentially while running the red probe through the pins, but at least one segment of any digit lights up, then hold the red probe steady on its current pin, and run the black probe instead through the other pins. If all the segments of a digit light up in sequence, then you have a &lt;em&gt;common anode&lt;/em&gt; display.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Take note of the pin that was held constant, in any of the cases above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that you know what kind of display you have, you now need to discover the pinout for the segments and common anodes/cathodes. Get paper and pen so you can label each pin with its function. Create a table with pin numbers in one column (pin 1 - 12) and the pin functions (which you will find out) in the second column.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DxMY6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DxMY6.png&quot; alt=&quot;none&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This image shows the segment labels. During the testing above, one&#xA;probe (PROBE A) was held steady on one pin while the other (PROBE B)&#xA;was run through the other pins. This caused all the segments of a&#xA;digit to turn on. The pin connected steadily to PROBE A is the COMMON pin for&#xA;the digit whose segments lit up. So in your table, &lt;strong&gt;Pin xx = COMMON&#xA;for Digit yy&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;To get the COMMON for other digits, move PROBE A to another pin and&#xA;run PROBE B through the other pins until another digit has all its&#xA;segments turned on in sequence. The pin connected to PROBE A is the&#xA;COMMON for that digit. Include this in your table. Repeat until you&#xA;have identified the COMMON for each digit.&lt;/li&gt;&#xA;&lt;li&gt;Finally to get the segment pins A - G and DP, place PROBE A on any of the COMMONs you have in your table and run PROBE B through the other pins. Each time a segment lights up, the pin connected to PROBE B should be associated with that segment's label in your table. E.g. if segment C lights up when PROBE B is on pin 10, then the table should have something like &lt;strong&gt;pin 10 = C&lt;/strong&gt;. Keep going until you have all the segment pins identified. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-01T13:14:00.880" LastActivityDate="2016-03-01T13:14:00.880" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21253" PostTypeId="2" ParentId="8411" CreationDate="2016-03-01T02:43:21.737" Score="1" Body="&lt;p&gt;Note that lsusb does not guarantee the drives are loaded (See &lt;a href=&quot;https://superuser.com/questions/165733/will-lsusb-and-lspci-list-devices-for-which-the-system-has-no-drivers&quot;&gt;https://superuser.com/questions/165733/will-lsusb-and-lspci-list-devices-for-which-the-system-has-no-drivers&lt;/a&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per the &lt;a href=&quot;https://stackoverflow.com/a/14586884/1653571&quot;&gt;https://stackoverflow.com/a/14586884/1653571&lt;/a&gt; answer, try an 'lsmod' and see whether you have a 'cdc_acm' module loaded.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-01T02:43:21.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21254" PostTypeId="1" CreationDate="2016-03-01T03:07:13.863" Score="1" ViewCount="627" Body="&lt;p&gt;I am building a weather station, using a battery-operated outside unit, that transmits data from a DHT22 sensor to a unit inside my house. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The inside unit is using I2C communications from my Arduino Uno to my LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to add a BMP180 sensor which also uses I2C communications. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, how would you write a sketch to incorporate both the BMP180 sensor and the LCD display on to one I2C line?&lt;/p&gt;&#xA;" OwnerDisplayName="Rando" LastEditorUserId="84" LastEditDate="2016-12-27T10:38:22.737" LastActivityDate="2017-01-26T16:21:31.987" Title="How to write a sketch when adding more devices to an I2C data line?" Tags="|i2c|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21255" PostTypeId="1" CreationDate="2016-03-01T03:48:45.807" Score="1" ViewCount="7541" Body="&lt;p&gt;I am using Arduino Uno and the image size is 12.7 kb. I want to read a jpeg image from computer and convert into bitmap in arduino. Later on it will be implemented using SD card.Is it possible to read a .jpeg image from computer to Arduino using serial communication? If yes, then how?&lt;/p&gt;&#xA;" OwnerUserId="6549" LastEditorUserId="6549" LastEditDate="2016-03-01T06:10:55.237" LastActivityDate="2016-03-01T10:45:54.680" Title="How to serially transfer/read an image to Arduino" Tags="|serial|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21256" PostTypeId="1" AcceptedAnswerId="21554" CreationDate="2016-03-01T04:27:51.587" Score="0" ViewCount="4235" Body="&lt;p&gt;I'm trying to control Philips Hue lights through an Arduino Uno (with a WiFi shield &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model R3&lt;/a&gt;). Both the shield and the Philips Hue &lt;a href=&quot;http://www2.meethue.com/en-us/productdetail/philips-hue-bridge&quot; rel=&quot;nofollow noreferrer&quot;&gt;Bridge&lt;/a&gt; are connected to the same network and I'm trying to send JSON commands from the Arduino to the Hue Bridge from the following code taken from &lt;a href=&quot;http://www.makeuseof.com/tag/control-philips-hue-lights-arduino-and-motion-sensor#WorkingFromArduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;mynetwork&quot;;     //  your network SSID (name)&#xA;char pass[] = &quot;mypass&quot;;  // your network password&#xA;int status = WL_IDLE_STATUS;     // the Wifi radio's status&#xA;&#xA;//Hue constants&#xA;const char hueHubIP[] = &quot;192.168.0.50&quot;;  //Hue Bridge IP&#xA;const char hueUsername[] = &quot;myhue&quot;;  //Hue username&#xA;const int hueHubPort = 80;&#xA;&#xA;IPAddress server(192,168,0,50);&#xA;WiFiClient client;&#xA;&#xA;//Hue variables&#xA;boolean hueOn;  // on/off&#xA;int hueBri;  // brightness value&#xA;long hueHue;  // hue value&#xA;String hueCmd;  // Hue command&#xA;&#xA;unsigned long buffer=0;  //buffer for received data storage&#xA;unsigned long addr;&#xA;IPAddress ip;&#xA;&#xA;void setup()&#xA;{&#xA; //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(&quot;WiFi shield not present&quot;);&#xA;    // don't continue:&#xA;    while (true);&#xA;  }&#xA;&#xA;  // attempt to connect to Wifi network:&#xA;  while (status != WL_CONNECTED) {&#xA;    Serial.print(&quot;Attempting to connect to WPA SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;    delay(10000);&#xA;  }&#xA;&#xA;  // you're connected now, so print out the data:&#xA;  Serial.print(&quot;You're connected to the network&quot;);&#xA;  printCurrentNet();&#xA;  printWifiData();&#xA;&#xA;  ip = WiFi.localIP();&#xA;  Serial.println(ip);&#xA;&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;    String command = &quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;;&#xA;    setHue(1,command);&#xA;    command = &quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;; &#xA;    setHue(2,command);&#xA;    command = &quot;{\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;;&#xA;    setHue(1,command);&#xA;    command = &quot;{\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;; &#xA;    setHue(2,command);&#xA;&#xA;}&#xA;&#xA;&#xA;/* setHue() is our main command function, which needs to be passed a light number and a &#xA; * properly formatted command string in JSON format (basically a Javascript style array of variables&#xA; * and values. It then makes a simple HTTP PUT request to the Bridge at the IP specified at the start.&#xA; */&#xA;boolean setHue(int lightNum,String command)&#xA;{&#xA;  if (client.connect(server, 80))&#xA;  {&#xA;    Serial.println(F(&quot;connected to server&quot;));&#xA;    while (client.connected()&amp;amp;&amp;amp; status == WL_CONNECTED)&#xA;    {&#xA;      client.print(F(&quot;PUT /api/&quot;));&#xA;      client.print(hueUsername);&#xA;      client.print(F(&quot;/lights/&quot;));&#xA;      client.print(lightNum);  // hueLight zero based, add 1&#xA;      client.println(F(&quot;/state HTTP/1.1&quot;));&#xA;      client.println(F(&quot;keep-alive&quot;));&#xA;      client.print(F(&quot;Host: &quot;));&#xA;      client.println(hueHubIP);&#xA;      client.print(F(&quot;Content-Length: &quot;));&#xA;      client.println(command.length());&#xA;      client.println(F(&quot;Content-Type: text/plain;charset=UTF-8&quot;));&#xA;      client.println();  // blank line before body&#xA;      client.println(command);  // Hue command&#xA;    }&#xA;    client.stop();&#xA;    return true;  // command executed&#xA;  }&#xA;  else&#xA;    return false;  // command failed&#xA;}&#xA;&#xA;  //client.flush();&#xA;  //client.stop();&#xA;&#xA;/* A helper function in case your logic depends on the current state of the light. &#xA; * This sets a number of global variables which you can check to find out if a light is currently on or not&#xA; * and the hue etc. Not needed just to send out commands&#xA; */&#xA;boolean getHue(int lightNum)&#xA;{&#xA;  if (client.connect(server, 80))&#xA;  {&#xA;    client.print(F(&quot;GET /api/&quot;));&#xA;    client.print(hueUsername);&#xA;    client.print(F(&quot;/lights/&quot;));&#xA;    client.print(lightNum);  &#xA;    client.println(F(&quot; HTTP/1.1&quot;));&#xA;    client.print(F(&quot;Host: &quot;));&#xA;    client.println(hueHubIP);&#xA;    client.println(F(&quot;Content-type: application/json&quot;));&#xA;    client.println(F(&quot;keep-alive&quot;));&#xA;    client.println();&#xA;    while (client.connected()&amp;amp;&amp;amp; status == WL_CONNECTED)&#xA;    {&#xA;      if (client.available())&#xA;      {&#xA;        client.findUntil(&quot;\&quot;on\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueOn = (client.readStringUntil(',') == &quot;true&quot;);  // if light is on, set variable to true&#xA;&#xA;        client.findUntil(&quot;\&quot;bri\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueBri = client.readStringUntil(',').toInt();  // set variable to brightness value&#xA;&#xA;        client.findUntil(&quot;\&quot;hue\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueHue = client.readStringUntil(',').toInt();  // set variable to hue value&#xA;&#xA;        break;  // not capturing other light attributes yet&#xA;      }&#xA;    }&#xA;    client.stop();&#xA;    return true;  // captured on,bri,hue&#xA;  }&#xA;  else&#xA;    return false;  // error reading on,bri,hue&#xA;}&#xA;&#xA;&#xA;void printWifiData() {&#xA;&#xA;  //WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Address: &quot;);&#xA;  Serial.println(ip);&#xA;}&#xA;&#xA;  void printCurrentNet() {&#xA;  //SSID of the network you're attached to:&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above code gets my Arduino connected to &lt;code&gt;mynetwork&lt;/code&gt; and I have also connected Hue Bridge to the same but it throws an error of &lt;code&gt;No Socket Available&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tub4E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tub4E.png&quot; alt=&quot;Error message&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE (9th March 2016):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented suggestions &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt; given by slash-dev and was able to get rid of &lt;code&gt;No Socket Available&lt;/code&gt; error. Following is the updated code:&lt;/p&gt;&#xA;&#xA;   &lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;mynetwork&quot;;     //  your network SSID (name)&#xA;char pass[] = &quot;mypass&quot;;  // your network password&#xA;int status = WL_IDLE_STATUS;     // the Wifi radio's status&#xA;&#xA;//Hue constants&#xA;const char hueHubIP[] = &quot;192.168.0.50&quot;;  //Hue hub IP&#xA;const char hueUsername[] = &quot;myhue&quot;;  //Hue username&#xA;const int hueHubPort = 80;&#xA;&#xA;IPAddress server(192,168,0,50);&#xA;WiFiClient client;&#xA;&#xA;//Hue variables&#xA;boolean hueOn;  // on/off&#xA;int hueBri;  // brightness value&#xA;long hueHue;  // hue value&#xA;String hueCmd;  // Hue command&#xA;&#xA;unsigned long buffer=0;  //buffer for received data storage&#xA;unsigned long addr;&#xA;IPAddress ip;&#xA;&#xA;void setup()&#xA;{&#xA; //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(F(&quot;WiFi shield not present&quot;));&#xA;    // don't continue:&#xA;    while (true);&#xA;  }&#xA;&#xA;  // attempt to connect to Wifi network:&#xA;  while (status != WL_CONNECTED) {&#xA;    Serial.print(F(&quot;Attempting to connect to WPA SSID: &quot;));&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;    delay(10000);&#xA;  }&#xA;&#xA;  // you're connected now, so print out the data:&#xA;  Serial.print(F(&quot;You're connected to the network&quot;));&#xA;  printCurrentNet();&#xA;  printWifiData();&#xA;}&#xA;&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;    String command = &quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;;&#xA;    setHue(1,command);&#xA;    command = &quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;; &#xA;    setHue(2,command);&#xA;    command = &quot;{\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;;&#xA;    setHue(1,command);&#xA;    command = &quot;{\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;+String(random(15,25))+&quot;}&quot;; &#xA;    setHue(2,command);&#xA;&#xA;}&#xA;&#xA;&#xA;/* setHue() is our main command function, which needs to be passed a light number and a &#xA; * properly formatted command string in JSON format (basically a Javascript style array of variables&#xA; * and values. It then makes a simple HTTP PUT request to the Bridge at the IP specified at the start.&#xA; */&#xA;boolean setHue(int lightNum,String command)&#xA;{&#xA;  client.stop();&#xA;  if (client.connect(server, 80))&#xA;  {&#xA;    Serial.println(F(&quot;connected to server&quot;));&#xA;    while (client.connected()&amp;amp;&amp;amp; status == WL_CONNECTED)&#xA;    {&#xA;      client.print(F(&quot;PUT /api/&quot;));&#xA;      client.print(hueUsername);&#xA;      client.print(F(&quot;/lights/&quot;));&#xA;      client.print(lightNum);  // hueLight zero based, add 1&#xA;      client.println(F(&quot;/state HTTP/1.1&quot;));&#xA;      client.println(F(&quot;Connection: keep-alive&quot;));&#xA;      client.print(F(&quot;Host: &quot;));&#xA;      client.println(hueHubIP);&#xA;      client.print(F(&quot;Content-Length: &quot;));&#xA;      client.println(command.length());&#xA;      client.println(F(&quot;Content-Type: text/plain;charset=UTF-8&quot;));&#xA;      client.println();  // blank line before body&#xA;      client.println(command);  // Hue command&#xA;    }&#xA;    client.flush();&#xA;    client.stop();&#xA;    return true;  // command executed&#xA;  }&#xA;  else&#xA;    return false;  // command failed&#xA;}&#xA;&#xA;&#xA;/* A helper function in case your logic depends on the current state of the light. &#xA; * This sets a number of global variables which you can check to find out if a light is currently on or not&#xA; * and the hue etc. Not needed just to send out commands&#xA; */&#xA;boolean getHue(int lightNum)&#xA;{&#xA;  client.stop();&#xA;  if (client.connect(server, 80))&#xA;  {&#xA;    client.print(F(&quot;GET /api/&quot;));&#xA;    client.print(hueUsername);&#xA;    client.print(F(&quot;/lights/&quot;));&#xA;    client.print(lightNum);  &#xA;    client.println(F(&quot; HTTP/1.1&quot;));&#xA;    client.print(F(&quot;Host: &quot;));&#xA;    client.println(hueHubIP);&#xA;    client.println(F(&quot;Content-type: application/json&quot;));&#xA;    client.println(F(&quot;Connection: keep-alive&quot;));&#xA;    client.println();&#xA;    while (client.connected()&amp;amp;&amp;amp; status == WL_CONNECTED)&#xA;    {&#xA;      if (client.available())&#xA;      {&#xA;        client.findUntil(&quot;\&quot;on\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueOn = (client.readStringUntil(',') == &quot;true&quot;);  // if light is on, set variable to true&#xA;&#xA;        client.findUntil(&quot;\&quot;bri\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueBri = client.readStringUntil(',').toInt();  // set variable to brightness value&#xA;&#xA;        client.findUntil(&quot;\&quot;hue\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueHue = client.readStringUntil(',').toInt();  // set variable to hue value&#xA;&#xA;        break;  // not capturing other light attributes yet&#xA;      }&#xA;    }&#xA;    client.flush();&#xA;    client.stop();&#xA;    return true;  // captured on,bri,hue&#xA;  }&#xA;  else&#xA;    return false;  // error reading on,bri,hue&#xA;}&#xA;&#xA;void printWifiData() {&#xA;&#xA;  //WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(F(&quot;IP Address: &quot;));&#xA;  Serial.println(ip);&#xA;}&#xA;&#xA;  void printCurrentNet() {&#xA;  //SSID of the network you're attached to:&#xA;  Serial.print(F(&quot;SSID: &quot;));&#xA;  Serial.println(WiFi.SSID());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18846" LastEditorUserId="18846" LastEditDate="2016-03-10T04:33:42.407" LastActivityDate="2021-10-03T04:10:15.350" Title="Connecting Arduino with Philips Hue" Tags="|wifi|networking|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21257" PostTypeId="2" ParentId="21137" CreationDate="2016-03-01T05:24:53.187" Score="21" Body="&lt;p&gt;Thanks to the help of Charlie Hanson and jantje I found the universal solution!&lt;/p&gt;&#xA;&lt;p&gt;Because it is a pity that every Arduino programmer has to go through the same pain to figure out how to get the board name, I will offer my code to the public so everybody can just copy and paste it.&lt;/p&gt;&#xA;&lt;p&gt;Here it is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(TEENSYDUINO) &#xA;&#xA;    //  --------------- Teensy -----------------&#xA;&#xA;    #if defined(__AVR_ATmega32U4__)&#xA;        #define BOARD &amp;quot;Teensy 2.0&amp;quot;&#xA;    #elif defined(__AVR_AT90USB1286__)       &#xA;        #define BOARD &amp;quot;Teensy++ 2.0&amp;quot;&#xA;    #elif defined(__MK20DX128__)       &#xA;        #define BOARD &amp;quot;Teensy 3.0&amp;quot;&#xA;    #elif defined(__MK20DX256__)       &#xA;        #define BOARD &amp;quot;Teensy 3.2&amp;quot; // and Teensy 3.1 (obsolete)&#xA;    #elif defined(__MKL26Z64__)       &#xA;        #define BOARD &amp;quot;Teensy LC&amp;quot;&#xA;    #elif defined(__MK64FX512__)&#xA;        #define BOARD &amp;quot;Teensy 3.5&amp;quot;&#xA;    #elif defined(__MK66FX1M0__)&#xA;        #define BOARD &amp;quot;Teensy 3.6&amp;quot;&#xA;    #elif defined(__IMXRT1062__) &amp;amp;&amp;amp; defined(ARDUINO_TEENSY40)&#xA;        #define BOARD &amp;quot;Teensy 4.0&amp;quot;&#xA;    #elif defined(__IMXRT1062__) &amp;amp;&amp;amp; defined(ARDUINO_TEENSY41)&#xA;        #define BOARD &amp;quot;Teensy 4.1&amp;quot;&#xA;    #else&#xA;       #error &amp;quot;Unknown board&amp;quot;&#xA;    #endif&#xA;&#xA;#else // --------------- Arduino ------------------&#xA;&#xA;    #if   defined(ARDUINO_AVR_ADK)       &#xA;        #define BOARD &amp;quot;Mega Adk&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_BT)    // Bluetooth&#xA;        #define BOARD &amp;quot;Bt&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_DUEMILANOVE)       &#xA;        #define BOARD &amp;quot;Duemilanove&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_ESPLORA)       &#xA;        #define BOARD &amp;quot;Esplora&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_ETHERNET)       &#xA;        #define BOARD &amp;quot;Ethernet&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_FIO)       &#xA;        #define BOARD &amp;quot;Fio&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_GEMMA)&#xA;        #define BOARD &amp;quot;Gemma&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_LEONARDO)       &#xA;        #define BOARD &amp;quot;Leonardo&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_LILYPAD)&#xA;        #define BOARD &amp;quot;Lilypad&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_LILYPAD_USB)&#xA;        #define BOARD &amp;quot;Lilypad Usb&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_MEGA)       &#xA;        #define BOARD &amp;quot;Mega&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_MEGA2560)       &#xA;        #define BOARD &amp;quot;Mega 2560&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_MICRO)       &#xA;        #define BOARD &amp;quot;Micro&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_MINI)       &#xA;        #define BOARD &amp;quot;Mini&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_NANO)       &#xA;        #define BOARD &amp;quot;Nano&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_NG)       &#xA;        #define BOARD &amp;quot;NG&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_PRO)       &#xA;        #define BOARD &amp;quot;Pro&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_ROBOT_CONTROL)       &#xA;        #define BOARD &amp;quot;Robot Ctrl&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_ROBOT_MOTOR)       &#xA;        #define BOARD &amp;quot;Robot Motor&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_UNO)       &#xA;        #define BOARD &amp;quot;Uno&amp;quot;&#xA;    #elif defined(ARDUINO_AVR_YUN)       &#xA;        #define BOARD &amp;quot;Yun&amp;quot;&#xA;&#xA;    // These boards must be installed separately:&#xA;    #elif defined(ARDUINO_SAM_DUE)       &#xA;        #define BOARD &amp;quot;Due&amp;quot;&#xA;    #elif defined(ARDUINO_SAMD_ZERO)       &#xA;        #define BOARD &amp;quot;Zero&amp;quot;&#xA;    #elif defined(ARDUINO_ARC32_TOOLS)       &#xA;        #define BOARD &amp;quot;101&amp;quot;&#xA;    #else&#xA;       #error &amp;quot;Unknown board&amp;quot;&#xA;    #endif&#xA;   &#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can even put this code into a new header file and #include it into your project.&lt;/p&gt;&#xA;&lt;p&gt;P.D.&#xA;If you want to know additionaly to the board also the CPU model, search for the file avr_cpunames.h&lt;/p&gt;&#xA;" OwnerUserId="18754" LastEditorUserId="18754" LastEditDate="2023-09-14T17:15:47.307" LastActivityDate="2023-09-14T17:15:47.307" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21258" PostTypeId="2" ParentId="18153" CreationDate="2016-03-01T06:16:45.340" Score="0" Body="&lt;p&gt;I had a similar issue (port busy, RN42+Win 8.1) and find a solution by changing the usb bluetooth dongle of the computer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one which finally works for me was the Adafruit &lt;a href=&quot;https://www.adafruit.com/product/1327&quot; rel=&quot;nofollow&quot;&gt;Bluetooth 4.0 USB Module (v2.1 Back-Compatible)&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2016-03-01T06:16:45.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21262" PostTypeId="2" ParentId="21244" CreationDate="2016-03-01T09:48:36.397" Score="3" Body="&lt;p&gt;Expanding on my previous comment...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said before, I suspect the NeoPixel library to be blocking&#xA;interrupts for too long when you &lt;code&gt;strip.show()&lt;/code&gt;. If a timer interrupt&#xA;fires while interrupts are blocked... it's not a big deal: the interrupt&#xA;request is put on hold and serviced as soon as interrupts are enabled&#xA;again. If &lt;strong&gt;two&lt;/strong&gt; timer interrupts fire while interrupts are blocked...&#xA;you have a problem: the interrupt service routine will be called only&#xA;once, and your clock will miss a tick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Craig has worked out the timings in his answer: the timer interrupt&#xA;fires every 1.024&amp;nbsp;ms, and NeoPixel blocks interrupts for&#xA;1.8&amp;nbsp;ms. So it is perfectly expected that, from time to time, you&#xA;will have two timer interrupts within this 1.8&amp;nbsp;ms window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a quick hack that could solve your problem: if you&#xA;&lt;code&gt;strip.show()&lt;/code&gt; &lt;em&gt;right after&lt;/em&gt; a timer interrupt is serviced, then only&#xA;one more interrupt should fire during the subsequent 1.8&amp;nbsp;ms window,&#xA;and you should be fine. So you could simply add this &lt;em&gt;right before&lt;/em&gt;&#xA;&lt;code&gt;strip.show()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/* Wait for a timer interrupt to be serviced. */&#xA;uint32_t lastMillis = millis();&#xA;while (millis() == lastMillis) /* wait */;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A possibly better solution would be to avoid blocking interrupts for so&#xA;long. NeoPixel blocks them in order to comply with the very tight timing&#xA;requirements of the WS2812 LEDs. But it turns out the WS2812s are not&#xA;nearly as picky about timings as their datasheet suggests. You can drive&#xA;them in a more relaxed way, with interrupts enabled except for 1-bit&#xA;durations, and they still work fine. For a detailed explanation and&#xA;sample code, see &lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot; rel=&quot;nofollow&quot;&gt;NeoPixels Revealed: How to (not need to) generate&#xA;precisely timed&#xA;signals&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third solution would be to follow the general advice given here and&#xA;grab an RTC. However, although it certainly is a good and clean&#xA;solution, I have to admit I completely agree with your comment “&lt;em&gt;I still&#xA;didn't catch WHY that is better – it's a quartz either way&lt;/em&gt;”.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-01T09:48:36.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21263" PostTypeId="2" ParentId="19305" CreationDate="2016-03-01T09:49:01.143" Score="1" Body="&lt;p&gt;Since your project is about acquiring signals I guess that the sample frequency is important for you. In fact you need to know exactly how much time passes from one sample to another. This cannot be achieved by simple reading the ADC in your loop(). The easiest implementation is to use an interrupt that occurs every n seconds (e.g. every overflow of timerX).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm going to write a pseudo-code for this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SetTimer()&#xA;{  TISREG |= 1&amp;lt;&amp;lt;Prescaler_bit   //set the prescaler&#xA;   TICNT = 0   //sdt the tarting value&#xA;   TIINT |= 1&amp;lt;&amp;lt;OVF_Interrupt_enable&#xA;   sei() //enable global interrupt&#xA;}&#xA;&#xA;ISR(TIM1_OVF_vect)   //happens every [prescaler*2^bit_timer/F_CPU] seconds&#xA;{&#xA;   while( !(ADCSREG &amp;amp;= (1&amp;lt;&amp;lt;bit_is_ready)) ) ; //usually there is a bit that is 1 while the ADC has read the data, and 0 while it is doing the conversions&#xA;&#xA;//imagine the ADC stores the 3 MSBits in the ADCHI&#xA;//and the LSBits in the  ADCLO&#xA;&#xA;value_high = (ADCHI &amp;amp; 0b00000111);  &#xA;value_low = ADCLO;&#xA;&#xA;value = (value_high &amp;lt;&amp;lt; 7) | value_low;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-03-01T09:49:01.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21264" PostTypeId="2" ParentId="21255" CreationDate="2016-03-01T10:31:01.300" Score="4" Body="&lt;p&gt;You can send anything you like through the serial port. It is just 8-bit raw data. The onus is on you, however, to implement a suitable high level protocol with which to transfer the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important thing to bear in mind though: JPEG is a highly compressed complex image format. I am not aware that anyone has ever managed to squeeze JPEG decompression into a lowly Arduino. Instead you will need to use a decompressed image format such as BMP, or do the decompression on the computer before-hand and send the raw RGB image data over the serial instead.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-01T10:31:01.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21265" PostTypeId="1" CreationDate="2016-03-01T10:39:02.667" Score="4" ViewCount="7259" Body="&lt;p&gt;Apologies if this question appears to be too vague but I would like to know the key differences between these two clients. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While WiFiClient comes pre-loaded with Arduino IDE, HttpClient doesn't. Also, to send HTTP commands to a server (XML/JSON), which one to go for?&lt;/p&gt;&#xA;" OwnerUserId="18856" LastActivityDate="2020-10-20T19:57:51.477" Title="Difference between WiFiClient and HttpClient" Tags="|wifi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21266" PostTypeId="2" ParentId="21255" CreationDate="2016-03-01T10:45:54.680" Score="0" Body="&lt;p&gt;Of course you can, but as stated in the comments and in the other answer JPEG use a complex algorithm to compress the images, and most computers have a dedicated hardware to perform the cosens discrete transform. Anyway the answer to your question is yes, and it's not hard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just have to split the image into bytes, send them through the serial port and make Arduino read and save them into an array. To avoid errors create a protocol that can decode what are you doing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;0b1111000 for 3 times = Start sending&#xA;0b00011000 = new line &#xA;and so on..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing that come in my mind is to use the pySerial library, that can automate the process. Python is perfect for prototyping: open the image (maybe using the numpy library instead of using lists) and with a for loop send every byte over the serial port in according to the protocol you created. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Arduino just code the protocol to understand every bite and save the image in an array. &lt;/p&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-03-01T10:45:54.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21267" PostTypeId="2" ParentId="21265" CreationDate="2016-03-01T10:54:25.553" Score="5" Body="&lt;p&gt;WiFiClient provides a raw connection to the internet through a WiFi access point (such as your home router).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HttpClient provides a connection to a web server via an existing Client connection, such as a WiFiClient connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the simplest answer to your question&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;to send HTTP commands to a server (XML/JSON), which one to go for?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;is &quot;Use both&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use WiFiClient to connect to the internet, then you use HttpClient on your WiFiClient connection to communicate with a website.  As it states in the readme on HttpClient's github repository:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Because it expects an object of type Client, you can use it with any of the networking classes that derive from that. Which means it will work with EthernetClient, WiFiClient and GSMClient.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To understand the concept more fully you will first need to understand the &lt;a href=&quot;https://en.wikipedia.org/wiki/OSI_model&quot; rel=&quot;noreferrer&quot;&gt;OSI 7-Layer Model&lt;/a&gt; which is essential reading for anyone doing anything with networking software.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-01T10:59:45.190" LastActivityDate="2016-03-01T10:59:45.190" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21268" PostTypeId="2" ParentId="1180" CreationDate="2016-03-01T11:07:44.110" Score="6" Body="&lt;p&gt;You might be interested in &lt;code&gt;Telemetry&lt;/code&gt; &lt;a href=&quot;https://github.com/Overdrivr/Telemetry&quot; rel=&quot;noreferrer&quot;&gt;See on Github&lt;/a&gt; . It is a communication protocol, highly simple to use, with a clean interface, that enables bidirectionnal communication with Arduino/Mbed devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to read this long post, see &lt;a href=&quot;https://github.com/Overdrivr/Telemetry/wiki/Awesome-features-overview&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;A walkthrough of all the awesome features in it&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power of this library comes from the desktop command line interface (that requires &lt;strong&gt;no&lt;/strong&gt; programming skills in python).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is able to open high-performance plots (much higher that what can be done with matplotlib) &lt;strong&gt;just by typing a command&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The protocol supports &lt;strong&gt;complexes data structures&lt;/strong&gt;. For now &lt;strong&gt;arrays&lt;/strong&gt; and sparse arrays can be send from the embedded board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The plots opened from the command line interface understand the type of data, and for arrays, rather than plotting each sample versus time, sample will be plotted against its own index.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a near future, it is planned to add &lt;strong&gt;support for spatial coordinates&lt;/strong&gt; (xyz data), that will allow you to plot immediately spatial data. Once, again the plots will figure everything out, plot your data in 2D or 3D space and you can focus on developping your app.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe those features are simply &lt;strong&gt;unique&lt;/strong&gt; for such a project.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Pytelemetry CLI &lt;a href=&quot;https://badge.fury.io/py/pytelemetrycli&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://badge.fury.io/py/pytelemetrycli.svg&quot; alt=&quot;PyPI version&quot;&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once installed with &lt;code&gt;pip&lt;/code&gt;, the command line can be started with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pytlm&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can &lt;code&gt;connect&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;(list) received topics, &lt;code&gt;print&lt;/code&gt; data received on a topic, &lt;code&gt;pub&lt;/code&gt;(publish) on a topic, or open a &lt;code&gt;plot&lt;/code&gt; on a topic to display received data in real-time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Exo7a.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Exo7a.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q3rvr.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q3rvr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Get started&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/Overdrivr/Telemetry/wiki&quot; rel=&quot;noreferrer&quot;&gt;Wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;PS : I am the author.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I developed it because I could not find a solution that would allow me to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;write quickly PC scripts to control an Arduino &lt;/li&gt;&#xA;&lt;li&gt;debug quickly&lt;/li&gt;&#xA;&lt;li&gt;plot complex data (not just a time varying value)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;all of the above without using proprietary solutions or bloated GUIs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this library, the time to setup a communication between Arduino and PC went from usually half a day to 5 minutes.&lt;/p&gt;&#xA;" OwnerUserId="17188" LastActivityDate="2016-03-01T11:07:44.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21270" PostTypeId="2" ParentId="21254" CreationDate="2016-03-01T11:42:15.323" Score="0" Body="&lt;p&gt;Like Nick Gammon said, they have different addresses, so there shouldn't be a problem. Connect their SDAs and SCLs together, with the necessary pull-ups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The libraries you are using should handle the low-level reading and writing. Proceed as though they are any 2 devices connected to your Uno. Print to the LCD as usual, and poll the sensor with library functions.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="4628" LastEditDate="2016-12-27T15:20:54.647" LastActivityDate="2016-12-27T15:20:54.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21271" PostTypeId="1" CreationDate="2016-03-01T12:46:30.330" Score="-1" ViewCount="209" Body="&lt;p&gt;How would I use a photoresistor like a switch. My issue is it is always bleeding out a little bit of power and always on. Is there a way to connect it to a digital pin and when a resistance of xxx is ment, set another digital pin to On?&lt;/p&gt;&#xA;" OwnerUserId="18831" LastActivityDate="2016-03-01T15:42:32.247" Title="Photoresistor Switch" Tags="|arduino-uno|relay|digital|resistor|photoresistor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21273" PostTypeId="1" AcceptedAnswerId="21281" CreationDate="2016-03-01T13:57:10.167" Score="0" ViewCount="1966" Body="&lt;p&gt;i want to know code for counting the flashes of LEDs and display no. of flashes in particular time given.by using LDR.&#xA;basically i tried it with interrupts but i'm not getting it,so please help in this regard.&lt;/p&gt;&#xA;" OwnerUserId="18861" LastActivityDate="2016-03-01T18:52:06.690" Title="how to count blinking LED flashes using arduino uno boards and LDR?" Tags="|arduino-uno|sensors|sketch|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21274" PostTypeId="2" ParentId="20340" CreationDate="2016-03-01T14:49:10.110" Score="0" Body="&lt;p&gt;I finally managed to get it running. It really seems to be a problem with radio interference. I failed to hook up an external WLAN antenna to the Arduino Yun mini but I found a very useful workaround with a usb adapter here:&#xA;&lt;a href=&quot;http://www.lucadentella.it/en/2014/11/08/yun-adattatore-wifi-usb/&quot; rel=&quot;nofollow&quot;&gt;http://www.lucadentella.it/en/2014/11/08/yun-adattatore-wifi-usb/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This workaround is possible with an Arduino Yun mini as well but you'll need the Arduino Yun Linux OS from here:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Software&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;because the necessary packages are not available for the Linino system that comes with the Yun mini. Then, you can connect the WiFi adapter to USB+, USB-, 5V and GND of the Yun mini and you're good to go.&lt;/p&gt;&#xA;" OwnerUserId="17043" LastActivityDate="2016-03-01T14:49:10.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21275" PostTypeId="2" ParentId="21273" CreationDate="2016-03-01T15:12:22.747" Score="1" Body="&lt;p&gt;LDRs only give an analog output, proportional to the amount of light. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make it give a HIGH and LOW value, you have to tweak the other resistor used in the voltage divider. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could use &lt;code&gt;analogRead&lt;/code&gt; and add a threshold value in your code.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-01T15:12:22.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21276" PostTypeId="1" CreationDate="2016-03-01T15:38:47.397" Score="2" ViewCount="449" Body="&lt;p&gt;I'm trying to add a bootloader hex to Nick Gammon's Atmega Board Programmer sketch, and I can't seem to get a hex file to convert.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to convert &quot;Arduino-usbserial-atmega16u2-Uno-Rev3.hex&quot;, but that wasn't working so I thought I'd try converting one that's already used in the sketch, &quot;Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex&quot;, but that's not working either. I've followed the instructions from &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/bootloader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried it using Wine and Paralells. Clicking the copy button when using Wine causes the program to stop responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of the error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sa7dr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sa7dr.png&quot; alt=&quot;Error Screenshot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="18863" LastActivityDate="2016-03-01T21:27:18.697" Title="Nick Gammon's Hex Converter Error" Tags="|arduino-uno|bootloader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21277" PostTypeId="2" ParentId="21271" CreationDate="2016-03-01T15:42:32.247" Score="1" Body="&lt;p&gt;To turn an analog signal into a digital signal, at some sort of threshold xxx, you need to either condition it in electronic circuitry, with something like an amplifier or a comparator, or read the analog signal directly and apply the threshold in software.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You likely need to connect the photoresistor as half of a voltage divider, as in &lt;a href=&quot;https://arduino.stackexchange.com/q/7921/6628&quot;&gt;Why do you need a second resistor when using a photoresistor/LDR?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-01T15:42:32.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21278" PostTypeId="2" ParentId="19986" CreationDate="2016-03-01T16:05:51.600" Score="1" Body="&lt;p&gt;Well, the problem has been solved. The Ethernet shield was not properly stacked onto the Arduino board which caused connection to fail. &lt;/p&gt;&#xA;" OwnerUserId="16744" LastEditorUserId="6936" LastEditDate="2016-03-01T20:11:04.087" LastActivityDate="2016-03-01T20:11:04.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21279" PostTypeId="1" AcceptedAnswerId="21296" CreationDate="2016-03-01T16:30:50.117" Score="1" ViewCount="3052" Body="&lt;p&gt;I was reading this thread:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/18183/read-rc-receiver-channels-using-interrupt-instead-of-pulsein/21233#21233&quot;&gt;Read RC receiver channels using Interrupt instead of PulseIn&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I have been trying to understand the code provided within.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I was able to udnerstand most of it, I am still unable to find proper documentation on Arduino PCIFR and PINC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="18829" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-03-02T09:30:18.993" Title="Arduino documentation on PCIFR and PINC" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21280" PostTypeId="1" CreationDate="2016-03-01T18:06:02.777" Score="0" ViewCount="11114" Body="&lt;p&gt;I'm trying to send a POST request to IFTTT from a Node MCU. Instead of writing the code from the scratch, I've tweaked an already existing code (for GET request). It does not seem to work, what am I doing wrong? Needless to say, I replaced the WIFI ssid, the password and the IFTTT token. When testing the POST request with CURL, it works perfectly. Here's how the request should look like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://maker.ifttt.com/trigger/&quot; rel=&quot;nofollow&quot;&gt;https://maker.ifttt.com/trigger/&lt;/a&gt;{event_name}/with/key/my_super_secret_token&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...and the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;&#xA;const char* ssid     = &quot;mywifi&quot;;&#xA;const char* password = &quot;mywifipassword&quot;;&#xA;&#xA;const char* host = &quot;maker.ifttt.com&quot;;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  delay(100);&#xA;&#xA;  // We start by connecting to a WiFi network&#xA;&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  Serial.print(&quot;Connecting to &quot;);&#xA;  Serial.println(ssid);&#xA;&#xA;  WiFi.begin(ssid, password);&#xA;&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;WiFi connected&quot;);  &#xA;  Serial.println(&quot;IP address: &quot;);&#xA;  Serial.println(WiFi.localIP());&#xA;}&#xA;&#xA;int value = 0;&#xA;&#xA;void loop() {&#xA;  delay(5000);&#xA;  ++value;&#xA;&#xA;  Serial.print(&quot;connecting to &quot;);&#xA;  Serial.println(host);&#xA;&#xA;  // Use WiFiClient class to create TCP connections&#xA;  WiFiClient client;&#xA;  const int httpPort = 80;&#xA;  if (!client.connect(host, httpPort)) {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // We now create a URI for the request&#xA;  String url = &quot;trigger/{trigga}/with/key/IFTTT_token&quot;;&#xA;  Serial.print(&quot;Requesting URL: &quot;);&#xA;  Serial.println(url);&#xA;&#xA;  // This will send the request to the server&#xA;client.print(String(&quot;POST &quot;) + url + &quot; HTTP/1.1\r\n&quot; +&#xA;               &quot;Host: &quot; + host + &quot;\r\n&quot; + &#xA;               &quot;Connection: close\r\n\r\n&quot;);&#xA;&#xA;    // Read all the lines of the reply from server and print them to Serial&#xA;  while(client.available()){&#xA;    String line = client.readStringUntil('\r');&#xA;    Serial.print(line);&#xA;  }&#xA;&#xA;  Serial.println();&#xA;  Serial.println(&quot;closing connection&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4367" LastEditorUserId="4131" LastEditDate="2016-03-10T07:16:13.623" LastActivityDate="2016-09-25T12:50:42.000" Title="HTTP POST request to IFTTT" Tags="|esp8266|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21281" PostTypeId="2" ParentId="21273" CreationDate="2016-03-01T18:52:06.690" Score="0" Body="&lt;p&gt;An hardware solution could be achieved by putting a photodiode or a photoresistance near the flashing LED. Connect it to a pin that supports external interrupt and you're done. With a bit more circuitry you can ensure that the value on the pin doesn't oscillate: put a Schmit Trigger after the photodiode or resitance with its output on the input pin. &lt;/p&gt;&#xA;" OwnerUserId="18770" LastActivityDate="2016-03-01T18:52:06.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21283" PostTypeId="1" AcceptedAnswerId="21301" CreationDate="2016-03-01T19:19:22.273" Score="6" ViewCount="2164" Body="&lt;p&gt;I'm working on adding my Arduino to continuous integration and I came across two different possible ways of doing this, &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;noreferrer&quot;&gt;Arduino command line&lt;/a&gt;, and &lt;a href=&quot;https://github.com/arduino/arduino-builder&quot; rel=&quot;noreferrer&quot;&gt;arduino-builder&lt;/a&gt;.  Can someone explain why the arduino-builder tool exists separately from calling Arduino from the command line?  And what are the advantages of using one over the other?&lt;/p&gt;&#xA;" OwnerUserId="16253" LastEditorUserId="16253" LastEditDate="2016-03-01T19:34:05.657" LastActivityDate="2018-03-08T13:55:51.927" Title="Arduino command line vs. Arduino builder" Tags="|programming|build|command-line|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21284" PostTypeId="2" ParentId="21276" CreationDate="2016-03-01T20:33:25.990" Score="1" Body="&lt;p&gt;&lt;s&gt;I can't reproduce that.&lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My apologies - I couldn't quite read the error message in the screen dump. What you got was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Don't know end address for 0&#xA;Please add to table: end_addresses&#xA;Run-time error&#xA;World: smaug2&#xA;Immediate execution&#xA;[string &quot;Immediate&quot;]:96: Cannot continue&#xA;stack traceback:&#xA;        [C]: in function 'error'&#xA;        [string &quot;Immediate&quot;]:96: in function 'process'&#xA;        [string &quot;Immediate&quot;]:134: in main chunk&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The relevant error is the first line. That file has code for address 0 - which is not part of the bootloader. It tries to detect bootloader addresses, and zero is not one of them. Looking at the start of the file I see this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:1000000090C00000A9C00000A7C00000A5C000006B&#xA;:10001000A3C00000A1C000009FC000009DC0000060&#xA;:100020009BC0000099C0000097C0000048C40000B9&#xA;:100030000CC4000091C000008FC000008DC0000003&#xA;:100040008BC0000089C0000087C0000085C0000090&#xA;:1000500083C0000081C000007FC0000002C100001A&#xA;:100060007BC0000079C0000077C0000075C00000B0&#xA;:1000700073C0000071C000006FC000006DC00000C0&#xA;:100080006BC0000069C0000067C0000065C00000D0&#xA;:1000900063C0000061C000001201100102000008EE&#xA;:1000A0004123430001000102DC0109023E0002017C&#xA;:1000B00000C0320904000001020201000524000111&#xA;:1000C0001004240206052406000107058203080027&#xA;:1000D000FF09040100020A000000070504024000B5&#xA;:1000E00001070583024000010403090432034100B3&#xA;:1000F00072006400750069006E006F002000280027&#xA;:100100007700770077002E006100720064007500B0&#xA;:1001100069006E006F002E0063006300290000007C&#xA;:10012000000011241FBECFEFD2E0DEBFCDBF11E033&#xA;:10013000A0E0B1E0ECEAFFE002C005900D92A6312C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In particular the format is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; :10 0000 00 90C00000A9C00000A7C00000A5C00000 6B&#xA;  ^  ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^&#xA;len  addr TT   data                          sumcheck&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this file includes code for the Atmega16U2 &lt;em&gt;as well as&lt;/em&gt; the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch is not designed to program non-bootloaders (it is a bootloader programmer after all).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Scroll down that page for &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&amp;amp;reply=2#reply2&quot; rel=&quot;nofollow noreferrer&quot;&gt;how to reprogram the Atmega16U2 chip&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bootloader programmer sketch (as published) will put the &lt;strong&gt;bootloader&lt;/strong&gt; onto the Atmega16U2. Then follow the instructions on that page, or on this page, below, for entering DFU mode and uploading the main part of the code (not the bootloader part).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Entering DFU mode&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you have just flashed the bootloader using the bootloader programmer sketch then it should enter DFU mode, visible because the pin 13 LED flashes rapidly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, enter DFU mode by shorting together Reset and Ground briefly with a screwdriver or similar. They are the two left-most pins visible in the image above, nearest to the Reset button and below the hole on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Don't keep them shorted, just a brief touch should do it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FHKp3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FHKp3.jpg&quot; alt=&quot;Enter DFU mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once in DFU mode, you should see it appear as an Atmel USB device, if you type &lt;code&gt;lsusb&lt;/code&gt; (on Linux):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb&#xA;...&#xA;Bus 003 Device 092: ID 03eb:2fef Atmel Corp. &#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A Uno which is not in USB mode might look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ lsusb&#xA;...&#xA;Bus 003 Device 090: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(or not appear at all if there is no firmware on it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using Ubuntu or similar you can obtain the DFU programmer as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; sudo apt-get install dfu-programmer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can obtain the code for the firmware from here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/Arduino/Arduino-atmega16u2-Uno-firmware-Rev3.hex&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://gammon.com.au/Arduino/Arduino-atmega16u2-Uno-firmware-Rev3.hex&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(RH-click and &quot;save as&quot; to put a copy on your hard disk).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming you place that firmware in the current directory of your terminal window, you can now flash the code as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo dfu-programmer atmega16u2 flash Arduino-atmega16u2-Uno-firmware-Rev3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should see a message like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Validating...&#xA;4034 bytes used (32.83%)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can unplug the USB cable, plug it back in, and the USB interface should be back to factory settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For other operating systems, such as Windows, you should be able to get a copy of the DFU programmer from:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/dfu-programmer/dfu-programmer&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/dfu-programmer/dfu-programmer&lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://dfu-programmer.github.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://dfu-programmer.github.io/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-01T21:27:18.697" LastActivityDate="2016-03-01T21:27:18.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21285" PostTypeId="1" CreationDate="2016-03-01T21:59:13.800" Score="1" ViewCount="528" Body="&lt;p&gt;I found this software:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;&#xA;AC Voltage dimmer with Zero cross detection&#xA;Author: Charith Fernanado &amp;lt;a href=&quot;http://www.inmojo.com&quot;&amp;gt;  http://www.inmojo.com&#xA;&#xA;&amp;lt;/a&amp;gt;&#xA;Adapted by DIY_bloke&#xA;License: Creative Commons Attribution Share-Alike 3.0 License.&#xA;Attach the Zero cross pin of the module to Arduino External Interrupt pin&#xA;Select the correct Interrupt # from the below table &#xA;(the Pin numbers are digital pins, NOT physical pins: &#xA;digital pin 2 [INT0]=physical pin 4 and digital pin 3 [INT1]= physical pin 5)&#xA;check: &amp;lt;a href=&quot;http://arduino.cc/en/Reference/attachInterrupt&quot;&amp;gt;  http://www.inmojo.com&#xA;&#xA;&amp;lt;/a&amp;gt;&#xA;&#xA;Pin    |  Interrrupt # | Arduino Platform&#xA;---------------------------------------&#xA;2      |  0            |  All -But it is INT1 on the Leonardo&#xA;3      |  1            |  All -But it is INT0 on the Leonardo&#xA;18     |  5            |  Arduino Mega Only&#xA;19     |  4            |  Arduino Mega Only&#xA;20     |  3            |  Arduino Mega Only&#xA;21     |  2            |  Arduino Mega Only&#xA;0      |  0            |  Leonardo&#xA;1      |  3            |  Leonardo&#xA;7      |  4            |  Leonardo&#xA;The Arduino Due has no standard interrupt pins as an iterrupt can be attached to almosty any pin. &#xA;&#xA;In the program pin 2 is chosen&#xA;*/&#xA;int AC_LOAD = 3;    // Output to Opto Triac pin&#xA;int dimming = 128;  // Dimming level (0-128)  0 = ON, 128 = OFF&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output&#xA;  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above&#xA;}&#xA;&#xA;//the interrupt function must take no parameters and return nothing&#xA;void zero_crosss_int()  //function to be fired at the zero crossing to dim the light&#xA;{&#xA;  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms &#xA;  // Every zerocrossing thus: (50Hz)-&amp;gt; 10ms (1/2 Cycle) &#xA;  // For 60Hz =&amp;gt; 8.33ms (10.000/120)&#xA;  // 10ms=10000us&#xA;  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =&amp;gt;65&#xA;&#xA;  int dimtime = (75*dimming);    // For 60Hz =&amp;gt;65    &#xA;  delayMicroseconds(dimtime);    // Wait till firing the TRIAC      &#xA;  digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC&#xA;  delayMicroseconds(10);         // triac On propogation delay &#xA;                 // (for 60Hz use 8.33) Some Triacs need a longer period&#xA;  digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC&#xA;}&#xA;&#xA;void loop()  {&#xA;  for (int i=5; i &amp;lt;= 128; i++){&#xA;    dimming=i;&#xA;    delay(10);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But don't uderstand this part:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;(10000us - 10us) / 128 = 75 (Approx) For 60Hz =&gt;65&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I know 10000us is 10ms, and we need to wait less then 10ms to dim light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But don't understand why here we has -10us and /128.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone know why is that?&lt;/p&gt;&#xA;" OwnerUserId="18888" OwnerDisplayName="Vladimir Djukic" LastEditorUserId="27346" LastEditDate="2018-12-12T15:10:58.887" LastActivityDate="2024-01-10T14:53:38.123" Title="Arduino controlled light dimmer software" Tags="|voltage|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21286" PostTypeId="2" ParentId="21285" CreationDate="2016-03-01T23:27:05.330" Score="3" Body="&lt;p&gt;-10uS because of the 10uS delay at the end of the loop, and /128 because he has decided there will be 128 possible dimming levels.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-01T23:27:05.330" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21287" PostTypeId="1" AcceptedAnswerId="21291" CreationDate="2016-03-02T00:17:30.010" Score="1" ViewCount="1021" Body="&lt;p&gt;I've bought some nice looking LED potentiometers from Ebay. They look like &lt;a href=&quot;https://www.google.co.uk/search?q=b10k%20potentiometer&amp;amp;espv=2&amp;amp;biw=1270&amp;amp;bih=701&amp;amp;site=webhp&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ved=0ahUKEwjM7-TM26DLAhUBOJoKHT3hAAUQ_AUIBygC#tbm=isch&amp;amp;q=b10k%20potentiometer%20linear%20led&amp;amp;imgrc=XY_E0nFmWPaxzM%3A&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&#xA;I'm very new to low level electronics/hardware and I don't know how to wire it. It has 4+2 pins.&#xA;Also, how to use it in the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="18874" LastActivityDate="2016-03-02T03:48:38.497" Title="How to wire and use a B10K linear LED potentiometer?" Tags="|led|analogread|potentiometer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21289" PostTypeId="1" AcceptedAnswerId="21293" CreationDate="2016-03-02T03:23:59.913" Score="8" ViewCount="5484" Body="&lt;p&gt;Does anyone know how to prevent the Uno from running the last program when it's powered on?&lt;/p&gt;&#xA;&lt;p&gt;Many times I have changed hardware and wiring without clearing the program first.  Then when I power it on to upload the new program it will run the old program until it's uploaded.  This has many potential unwanted effects when the old program is running with the new hardware installed.&lt;/p&gt;&#xA;" OwnerUserId="15341" LastEditorUserId="395" LastEditDate="2021-03-22T20:31:23.963" LastActivityDate="2021-03-22T20:31:23.963" Title="How to stop uno from running program when powered on?" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21290" PostTypeId="1" AcceptedAnswerId="21292" CreationDate="2016-03-02T03:46:36.880" Score="5" ViewCount="6318" Body="&lt;p&gt;Background: I am using an analog pressure sensor with a range from 0-100PSI returning voltage values .44v to 4.44v. It's open air (or 0 PSI) voltage on the signal pin is .47 volts. I have a function that subtracts that .47v (to make zero) and then multiplies it by 25 (25 PSI per volt). Due to signal noise or other factors, sometimes my function returns a negative number, which wreaks havoc on my math. I would like to return a value of 0 when my offset math returns a negative number, but I'm having a problem with it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that I wrote that doesn't work: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double EngineOilPressure() {&#xA;    //insert oil pressure code here&#xA;    int reading = analogRead(sensorPin3);&#xA;    float voltage = reading * 5.0;&#xA;    voltage /=1024.0;&#xA;&#xA;    Serial.print(voltage); Serial.println(&quot; volts&quot;);&#xA;&#xA;    if (voltage-.47 &amp;lt; 0)&#xA;    {&#xA;        float voltadj = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;        float voltadj = (voltage-.47);&#xA;    }&#xA;&#xA;    float pressureP = voltadj * 25;&#xA;    return PSIToPascal(pressureP);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error that I get is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dynamic_engine.pde: In function 'double EngineOilPressure()':&#xA;dynamic_engine.pde:41:23: error: 'voltadj' was not declared in this scope&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code that works but sometimes returns a very wrong value: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double EngineOilPressure() {&#xA;    int reading = analogRead(sensorPin3);&#xA;    float voltage = reading * 5.0;&#xA;    voltage /=1024.0;&#xA;&#xA;    Serial.print(voltage); Serial.println(&quot; volts&quot;);&#xA;&#xA;    float pressureP = (voltage - .47) * 25;&#xA;    return PSIToPascal(pressureP);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-02T13:19:25.563" Title="Return value of 0 if value is less than zero" Tags="|programming|sensors|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21291" PostTypeId="2" ParentId="21287" CreationDate="2016-03-02T03:48:38.497" Score="2" Body="&lt;p&gt;The Taiwan Alpha &lt;a href=&quot;http://www.taiwanalpha.com.tw/english2014/p_e_086.htm&quot; rel=&quot;nofollow&quot;&gt;spec sheet page 2&lt;/a&gt; for this type of pot shows a little information about the pinout.  Refer to the second “P.C.B. MOUNTING HOLE DETAIL” diagram, which apparently shows the top side PCB layout.  The LED's anode is at lower right, marked B; its cathode is lower left, marked E.  It doesn't say what L (the pin next to E) is.  The three numbered pins most probably are: 1 and 3, ends of the resistive element.  2, wiper.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is correct, you could attach pin 1 to 5V, pin 3 to ground, and pin 2 to an analog input.  Before hooking it up like that, however, take ohmmeter readings from pin 1 to pin 2 as you move the slider from one end to the other and see if readings change proportionately to position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the phrase “Center Dent” on the ebay page probably should instead be “Center Detent” or  “Center Click”.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-02T03:48:38.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21292" PostTypeId="2" ParentId="21290" CreationDate="2016-03-02T03:55:13.303" Score="5" Body="&lt;p&gt;The scope of each of the two different and unrelated &lt;code&gt;voltadj&lt;/code&gt; variables that your code (as below) declares is limited to within its enclosing set of braces.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (voltage-.47 &amp;lt; 0)&#xA;{&#xA;    float voltadj = 0;&#xA;}&#xA;else&#xA;{&#xA;    float voltadj = (voltage-.47);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead perhaps say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltadj = voltage-.47;&#xA;if (voltadj &amp;lt; 0) voltadj = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or perhaps&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltadj = voltage &amp;lt; .47? 0 : voltage-.47;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltadj = constrain(voltage-0.47, 0.0, 5.0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float voltadj = max(0.0, voltage-0.47);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://www.arduino.cc/en/Reference/Max&quot;&gt;max()&lt;/a&gt; and &lt;a href=&quot;https://www.arduino.cc/en/Reference/Constrain&quot;&gt;constrain()&lt;/a&gt; reference pages at arduino.cc.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-02T04:03:34.170" LastActivityDate="2016-03-02T04:03:34.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21293" PostTypeId="2" ParentId="21289" CreationDate="2016-03-02T05:29:21.273" Score="13" Body="&lt;p&gt;The simplest thing is to upload the new program before connecting the hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this isn't practical, connect a jumper wire from the Reset pin to ground (Gnd) before powering it on. This will hold in a reset state, and the program won't run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, compile and upload your program. As it starts to upload remove the reset wire. That should upload it without running any existing program.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-02T05:29:21.273" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21294" PostTypeId="1" CreationDate="2016-03-02T06:43:30.840" Score="1" ViewCount="299" Body="&lt;p&gt;I am trying to send/receive data from Android to my Arduino (via a HC-05) and later from Arduino to Android. I have configured my HC-05 as slave, and the UART=9600,0,0.... To send data from Android to Arduino I don´t have problem but to send data Arduino to Android I can not...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my sketch: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;char data;&#xA;int a=1;&#xA;int v=1;&#xA;#include SoftwareSerial connection(10,11);//RX|TX&#xA;void setup() &#xA;{&#xA; pinMode(7,OUTPUT);&#xA; connection.begin(9600);&#xA; digitalWrite(7,LOW);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA; if(connection.available()&amp;gt;0)&#xA; {&#xA;  data=connection.read();&#xA;   if(data=='1')&#xA;   {&#xA;    digitalWrite(7,HIGH);&#xA;    connection.write(data);&#xA;    delay(200);&#xA;   }&#xA;   //connection.write(data);&#xA;  }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MY HANDLER IN THE MAIN:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       mhandler=new Handler()        {&#xA;        public void handleMessage(android.os.Message msg)            {&#xA;            switch (msg.what)&#xA;            {&#xA;                case MENSSAGESEND:&#xA;                    msg = new DriveData((BluetoothSocket)msg.obj);    //DriveData msg = new DriveData((BluetoothSocket)msg.obj);&#xA;                    break;&#xA;                case MESSAGEREADING:&#xA;                    byte[] bufferget = (byte[])msg.obj;&#xA;                    String men = new String(bufferget,0,msg.arg1);&#xA;                    sb.append(men);&#xA;                    int endline=sb.indexOf(&quot;\n&quot;);&#xA;                    if(endline&amp;gt;0)&#xA;                    {&#xA;                        String print=sb.substring(0,endline);&#xA;                        sb.delete(0, sb.length());&#xA;                        Toast.makeText(getApplicationContext(),&quot;menssage&quot;+&quot; &quot;+print,Toast.LENGTH_LONG).show();&#xA;                        txtData.setText(print);&#xA;                    }&#xA;                    break;&#xA;&#xA;            }&#xA;        };&#xA;    };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MY METHOD FOR RECEIVER AND SEND DATA&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  public void run()&#xA;    {&#xA;        byte[] wait=new byte[1024];&#xA;        int bytesReceived;&#xA;        while (true) {&#xA;            try {&#xA;                 bytesReceived=entrydata.read(wait);//entrydata is my inputstream&#xA;                mhandler.obtainMessage(MESSAGEREADING,bytesReceived,-1,wait).sendToTarget();&#xA;            }catch (IOException e){&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13817" LastEditorUserId="13817" LastEditDate="2016-03-03T19:52:15.917" LastActivityDate="2016-03-03T19:52:15.917" Title="Configure HC-05" Tags="|arduino-uno|bluetooth|android|hc-05|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="21296" PostTypeId="2" ParentId="21279" CreationDate="2016-03-02T09:30:18.993" Score="3" Body="&lt;p&gt;Welcome to Arduino.SE. The documentation that you seek on &lt;code&gt;PCIFR&lt;/code&gt; and &lt;code&gt;PINC&lt;/code&gt; would not be documented under Arduino, this is as these are directly related to the ATMega328 (AVR Atmel micrcontroller) which is on the Arduino, they are &lt;a href=&quot;https://en.wikipedia.org/wiki/Atmel_AVR#Internal_registers&quot; rel=&quot;nofollow noreferrer&quot;&gt;registers&lt;/a&gt; which are inside the microcontroller and &lt;code&gt;PCIFR&lt;/code&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Atmel_AVR#GPIO_ports&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;PINC&lt;/code&gt;&lt;/a&gt; are mnemonics. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the ATMega328 you will find the documentation to these registers in the &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; (a good read with coffee), or in tutorials written by others explaining this information in an easy to grasp way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;PCIFR&lt;/code&gt; register is the Pin Change interrupt flag register(description on pg 73 of linked datasheet), this holds the flag bit to tell the microcontroller that there was an interrupt and runs the &lt;code&gt;ISR()&lt;/code&gt; routine that one has set out. Read this &lt;a href=&quot;http://gammon.com.au/interrupts#reply6&quot; rel=&quot;nofollow noreferrer&quot;&gt;post&lt;/a&gt; by Nick Gammon on Pin Change Interrupts, and then read all of the post to get a better idea of interrupts in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The register &lt;code&gt;PINC&lt;/code&gt; is for the inputs to the microcontroller, when one uses &lt;code&gt;staus = digitalRead(A0);&lt;/code&gt; they are in effect using a wrapped up version of bitwise math and bit manipulation when simplified to &lt;code&gt;status = PINC &amp;amp; (1 &amp;lt;&amp;lt; PC0);&lt;/code&gt; thus &lt;code&gt;PINx&lt;/code&gt; (x is for the register name ABCD) represents the state of the pin, either &lt;em&gt;HIGH(1, 5V, true)&lt;/em&gt; or &lt;em&gt;LOW(0, 0V, False)&lt;/em&gt;. Borrowing from the below linked tutorial:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/cq3aC.png&quot; alt=&quot;maxembedded&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another nice description of the input ports &lt;a href=&quot;http://maxembedded.com/2011/06/port-operations-in-avr/&quot; rel=&quot;nofollow noreferrer&quot;&gt;in this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the image you see that moving a bit to a position and then bitwise &lt;code&gt;&amp;amp;&lt;/code&gt; that with &lt;code&gt;PINx&lt;/code&gt; you will have a value returned if there is a 1 in &lt;strong&gt;that&lt;/strong&gt; position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; PINC      0b00001001    &#xA;(1 &amp;lt;&amp;lt; PC0) 0b00000001    &#xA;         &amp;amp; __________    &#xA;status  =  0b00000001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above shows how you only get the state of the first input and how the 4&lt;sup&gt;th&lt;/sup&gt; input is ignored as it was not needed. Also worth noting PIN is the register description and is not the same as a physical pin that sticks out the IC's body.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-03-02T09:30:18.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21297" PostTypeId="1" AcceptedAnswerId="21298" CreationDate="2016-03-02T09:51:21.690" Score="5" ViewCount="5887" Body="&lt;p&gt;I need to hard code 8 byte addresses into char arrays of length 8. This must be done many places in my code (in function scope), so I have tried to come up with a one-liner. The following works perfectly in C when compiling with gcc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char a[8];&#xA;&#xA;void cpaddr(char target[], char *source) {&#xA;    int i;&#xA;    for (i=0; i&amp;lt;8; i++)&#xA;        target[i] = source[i];&#xA;}&#xA;&#xA;int main() {&#xA;    char b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};&#xA;    cpaddr(a, b);&#xA;&#xA;    // line below does not compile with Arduino IDE&#xA;    cpaddr(a, (char[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When compiling on Arduino the last line, which is the one-liner I was aiming for, does not compile. It gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/bob/Desktop/ate/Ate.ino: In function 'int main()':&#xA;Ate:101: error: taking address of temporary array&#xA;cpaddr(a, (char[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});&#xA;^&#xA;exit status 1&#xA;taking address of temporary array&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the problem here, that apparently is not a problem with gcc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix it?&lt;/p&gt;&#xA;" OwnerUserId="3267" LastEditorUserId="37523" LastEditDate="2019-11-06T02:05:32.137" LastActivityDate="2019-11-06T02:05:32.137" Title="Works with gcc, not with Arduino. error: taking address of temporary array" Tags="|c++|array|pointer|gcc|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21298" PostTypeId="2" ParentId="21297" CreationDate="2016-03-02T10:18:04.673" Score="4" Body="&lt;p&gt;It is quite right, using that kind of syntax is not allowed. It's a bit of a pain, but it's ok since there is an alternative method - kind of a &quot;trick&quot; if you will.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That trick is to use a string, not an array. After all, a string is just an array, it's just handled slightly differently by the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;{...}&lt;/code&gt; use &lt;code&gt;&quot;...&quot;&lt;/code&gt; and use the hexadecimal character escape sequence &lt;code&gt;\xNN&lt;/code&gt;, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cpaddr(a, &quot;\x00\x10\xFF\xCA\x00\x00\xA2\x7D&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even lose your custom function and use a standard library function - &lt;code&gt;memcpy()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(a, &quot;\x00\x10\xFF\xCA\x00\x00\xA2\x7D&quot;, 8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the 8-bit AVRs you can save RAM by using the progmem variant and the &lt;code&gt;F()&lt;/code&gt; macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy_P(a, F(&quot;\x00\x10\xFF\xCA\x00\x00\xA2\x7D&quot;), 8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-02T10:18:04.673" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="21299" PostTypeId="2" ParentId="21290" CreationDate="2016-03-02T10:57:02.617" Score="1" Body="&lt;p&gt;Another method, though one that is quite cryptic to understand, would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float pressureP = voltage &amp;gt; 0.47 ? (voltage - 0.47) * 25 : 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is known (by me at least) as an &lt;em&gt;inline conditional&lt;/em&gt;.  The &lt;code&gt;?&lt;/code&gt; acts as an &lt;code&gt;if&lt;/code&gt; operator, and the &lt;code&gt;:&lt;/code&gt; as an else.  Basically it's saying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Voltage is greater than 0.47&#xA;Is that true?&#xA;    then subtract 0.47 and multiply by 25 and assign it&#xA;otherwise:&#xA;    assign 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The format is simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value = {condition} ? {true value or expression} : {false value or expression};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If can be quite useful when you want to conditionally calculate or assign something.  @jwpat7 makes mention of a &lt;code&gt;max()&lt;/code&gt; function above.  That &lt;code&gt;max()&lt;/code&gt; function can itself be written with this inline conditional format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;maxval = a &amp;gt; b ? a : b;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or: If &lt;code&gt;a&lt;/code&gt; is greater than &lt;code&gt;b&lt;/code&gt; then assign &lt;code&gt;a&lt;/code&gt; otherwise assign &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-02T10:57:02.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21301" PostTypeId="2" ParentId="21283" CreationDate="2016-03-02T11:09:25.090" Score="9" Body="&lt;p&gt;The Arduino IDE command line predates arduino-builder and was made available when the source pre-processing and compiling was implemented by a Java class (deeply) embedded in the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current IDE uses arduino-builder behind the scenes to process and compile the code so if you use arduino-builder you avoid having to load the whole Java IDE. Try it out it does some pretty cool stuff&lt;/p&gt;&#xA;" OwnerUserId="18885" LastActivityDate="2016-03-02T11:09:25.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21302" PostTypeId="1" CreationDate="2016-03-02T12:38:35.920" Score="2" ViewCount="2647" Body="&lt;p&gt;I am desperate to get my SIM800L module (&lt;a href=&quot;http://www.ebay.co.uk/itm/SIM800L-GPRS-GSM-Module-Board-Quadband-QUAD-BAND-Antenna-for-MCU-Arduino-/321992759287&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.co.uk/itm/SIM800L-GPRS-GSM-Module-Board-Quadband-QUAD-BAND-Antenna-for-MCU-Arduino-/321992759287&lt;/a&gt;) sending POST requests for a long period of time... Sometimes it stops after 100 requests in a row, sometimes 300 so it's really weird.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everytime I run it, it sends the request for a while (between 1 and 3 hours) and suddenly stops on these AT commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---&amp;gt; AT+HTTPINIT&#xA;&amp;lt;---&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When it works the OK is on the same line and it goes on to the next AT command.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        ---&amp;gt; AT+HTTPTERM&#xA;    &amp;lt;--- ERROR&#xA;         ---&amp;gt; AT+HTTPINIT&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPPARA=&quot;CID&quot;&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPPARA=&quot;UA&quot;&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPPARA=&quot;URL&quot;&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPPARA=&quot;CONTENT&quot;&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPDATA=1221,10000&#xA;    &amp;lt;--- DOWNLOAD&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPACTION=1&#xA;    &amp;lt;--- OK&#xA;Status: 201&#xA;Len: 0&#xA;    ---&amp;gt; AT+HTTPREAD&#xA;    &amp;lt;--- OK&#xA;    ---&amp;gt; AT+HTTPTERM&#xA;    &amp;lt;--- OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thought it was a powering problem so I connected the module to the VIN pin of my arduino mega via a buck converter but the problem is still here!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody have any idea what could be wrong? I can send you the code if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many thanks in advance&#xA;Pauline&lt;/p&gt;&#xA;" OwnerUserId="18887" LastEditorUserId="8033" LastEditDate="2016-03-02T15:06:17.680" LastActivityDate="2017-05-31T04:32:19.347" Title="Sim800L HTTP post request stop working after a while" Tags="|arduino-mega|power|gsm|debugging|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21303" PostTypeId="2" ParentId="21290" CreationDate="2016-03-02T13:19:25.563" Score="1" Body="&lt;p&gt;The Arduino way is to use &lt;a href=&quot;https://www.arduino.cc/en/Reference/Constrain&quot; rel=&quot;nofollow&quot;&gt;constrain&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float pressureP = constrain ((voltage - 0.47) * 25 , 0 [The Maximum your code can handle]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will return the value ((voltage - 0.47) * 25) but never less than 0 and never more than The maximum you provide.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-02T13:19:25.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21305" PostTypeId="1" AcceptedAnswerId="21306" CreationDate="2016-03-02T14:46:43.803" Score="0" ViewCount="1119" Body="&lt;p&gt;I've designed an PCB and due tot the delivery times, I kinda want to order it right now.&#xA;I don't yet have the components, so I haven't actually tried it on a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm unsure if the PCB would work, as this also is my first try in PCB design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a single-sided PCB.&#xA;All parts (should be) through hole.&#xA;I would be using SoftwareSerial since the ATTiny does not have serial (Rx/Tx).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[TL:DR] Would this PCB work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some points of which I'm unsure, or might be a problem: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is the spacing of the board/lines to other components/side big enough?&lt;/li&gt;&#xA;&lt;li&gt;Should I use a copper/ground fill? Which and why?&lt;/li&gt;&#xA;&lt;li&gt;Are the rounded-off traces actually better as sharp edges?&lt;/li&gt;&#xA;&lt;li&gt;It says: 36mm by 15mm isn't this too small to fit all those components?&lt;/li&gt;&#xA;&lt;li&gt;Can I actually use the RESET pin as other functions (without changing fuse bits)?&lt;/li&gt;&#xA;&lt;li&gt;Doesn't it need any resistors? I've seen some on the RS485 breakout boards.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Breadboard&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/okCNw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/okCNw.png&quot; alt=&quot;Breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Schematic&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1iPyH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1iPyH.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Layout&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9lvmo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9lvmo.png&quot; alt=&quot;Layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;File&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If someone needs the file:&#xA;It's opensource, no restrictions. Would be nice to give me some credits/donation, but you can freely use it for even commercial projects.&#xA;Download below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/s/lggjg5fxd6s3kqc/ATTINY485.fzz?dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/s/lggjg5fxd6s3kqc/ATTINY485.fzz?dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some credits to &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nick Gammon&lt;/a&gt;, I've used his schematics as a reference (especially on the TX enable pin, which was quite smart, using only 1 pin).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Version2!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aFiLp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aFiLp.png&quot; alt=&quot;schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/saaRD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/saaRD.png&quot; alt=&quot;layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changes:&#xA; - replaced the &quot;V&quot; shape.&#xA; - pull-up on the reset pin.&#xA; - decoupling capacitors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: It's better not to use a pull-up resistor on the reset line. The ATtiny85 has this internally.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-05T18:29:14.833" LastActivityDate="2016-07-05T08:57:14.047" Title="Fritzing PCB design review/questions" Tags="|pcb-design|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21306" PostTypeId="2" ParentId="21305" CreationDate="2016-03-02T15:06:04.327" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Would this PCB work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Possibly, sometimes, under some conditions. See below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the spacing of the board/lines to other components/side big enough?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Plenty.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Should I use a copper/ground fill? Which and why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For your circuit there is no real electrical reason to use a ground plane. However, many fab houses like you to use at least a copper fill in the empty areas since it means less copper has to be etched off the board, and so their etchant lasts longer before it needs to be replaced.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are the rounded-off traces actually better as sharp edges?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. Always try to avoid right-angles. Sharp corners radiate EMI noise, mitred corners radiate a lot less.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It says: 36mm by 15mm isn't this too small to fit all those components?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not in the slightest.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I actually use the RESET pin as other functions (without changing fuse bits)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can only disable the RESET functionality of the RESET pin using the fuse bits - and then it becomes somewhat difficult to program: you need a HVSP (High Voltage Serial Programmer) to get it back into programming mode again.  &lt;a href=&quot;http://projectsfromtech.blogspot.co.uk/2013/04/using-reset-pin-as-io-on-attiny8545.html&quot; rel=&quot;nofollow&quot;&gt;This blog post details how it is done.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Doesn't it need any resistors? I've seen some on the RS485 breakout boards.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your circuit isn't complete.  There are a couple of things missing that you need to add, and some that you might want to add.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The things that are missing:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Decoupling capacitors (100nF) on the power pins of both chips&lt;/li&gt;&#xA;&lt;li&gt;You should have one larger (10µF typical) reservoir capacitor at the power entry to the board&lt;/li&gt;&#xA;&lt;li&gt;(Assuming RESET is enabled) Pullup resistor on the RESET pin&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The things you might want to add:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RS-485 bus termination resistors&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The latter are optional depending on where in the bus your module is. You need termination resistors at both ends, so it is common to have them on the boards but with jumpers to enable/disable them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-02T15:06:04.327" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21307" PostTypeId="2" ParentId="21305" CreationDate="2016-03-02T15:23:17.487" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the spacing of the board/lines to other components/side big enough?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looks ok.  You might be able to squeeze it a few mm smaller each way, although since the board already is small, that probably would make little difference in cost.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Should I use a copper/ground fill? Which and why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Copper/ground fill on a single-sided board won't make much difference for this circuit.  It would be reasonable, however, to make the ground traces two or three times as wide as they are.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are the rounded-off traces actually better as sharp edges?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you mean, make square corners rather than the 45° turns as shown, either way will make little difference for this circuit.  The 45° turns are ok.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, sharp V-notches, like the one inside the traces at pin 2 of the Tiny85, are undesirable; I think they etch less accurately than more-open junctions do.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It says: 36mm by 15mm isn't this too small to fit all those components?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looks like there's room to spare and the board could be made slightly smaller.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For homemade boards that are drilled using a hand-cranked XY table, keeping drilled holes on the intersections of a .1&quot;x.1&quot; grid is a good idea.  For commercially-made boards, it's less important but can help with assembly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Regarding “Making ground traces bigger makes sense, but does that also mean 5V traces should be bigger?”, yes, both ground and power traces typically should be large, if board layout allows.  It's desirable that those traces have low inductance and it's ok to have high capacitance between ground and power traces.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding how long it takes to get your PCB back from a manufacturer: The &lt;a href=&quot;http://pcbshopper.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PCBshopper.com website&lt;/a&gt; makes it easy to compare time vs cost across a range of manufacturers.  For small circuits like yours, &lt;a href=&quot;https://oshpark.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OSHpark&lt;/a&gt; is an inexpensive choice (you would get three double-sided boards for under $5, in about 15 days).  If you need up to about 10 medium-size boards, &lt;a href=&quot;http://makerstudio.cc/index.php?main_page=index&amp;amp;cPath=8&quot; rel=&quot;nofollow noreferrer&quot;&gt;Maker Studio&lt;/a&gt; is quite economical but standard delivery may be slow (2-3 weeks).  If you are in a hurry and need a larger number of boards, consider (eg) &lt;a href=&quot;http://www.pcbway.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PCBway&lt;/a&gt;.  By paying $25 for DHL shipping, you can have a batch of boards in 9 or 10 days – about three days for manufacture and a week for delivery.  The pictures below show an example of PCBway's order tracking, the left side at about two days after the order was placed, the right side 11 hours later.  This order for 50 each 36 mm x 56 mm two-layer boards with silk both sides cost $27 for manufacture and $25 for delivery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/00HuV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/00HuV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-02T17:43:02.580" LastActivityDate="2016-03-02T17:43:02.580" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21308" PostTypeId="1" CreationDate="2016-03-02T15:59:33.990" Score="5" ViewCount="2983" Body="&lt;p&gt;I'm trying to connect an Arduino to an Electronic Speed Control and failing horribly. I'll explain what I've done so far, and then I'll explain the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before we get there, here's the list of parts I'm using:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino Uno (genuine)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;6V to 8.4V rated 18300 RPM 350 g-cm brushed motor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Traxxas XL-5 brushed motor ESC. 1600 Hz is the highest PWM signal it accepts, if I'm not wrong.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Venom 4200mAh NiMH 8.4V battery pack (will replace soon with a 7.2V).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So I first connected the ESC to the motor. The connection is this bullet lead connection (the connection seems intact), and then the ESC to the Arduino. I connected the white wire to pin 9 and the black wire to ground. If I'm not wrong, this is the standard servo motor setup. I then plugged the Arduino into my computer, which has an intact USB port. Lastly, I connected the battery pack to the ESC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I've tried to upload some basic code to try and calibrate my ESC, but it just plain our refuses to work. Under no circumstances will the motor run.&#xA;The code I'm using just sends the signal sent by the signal monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a complete noob to Arduino, so I don't know what could be wrong. The program I have in mind needs to be able to run while not connected to the computer, activate when a push-button switch is activated, run the motor for a certain distance (which involves an encoder, right?), and then stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers or things I could be doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int value = 0;&#xA;Servo myservo;&#xA;void setup() {&#xA;    firstESC.attach(9);    // attached to pin 9&#xA;    Serial.begin(9600);    &#xA;}&#xA;void loop() {&#xA;    myservo.writeMicroseconds(value);&#xA;    if(Serial.available()) &#xA;        value = Serial.parseInt();    // Parse an Integer from Serial&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the one here: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#define MAX_SIGNAL 2000&#xA;#define MIN_SIGNAL 700&#xA;#define MOTOR_PIN 9&#xA;Servo motor;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Program begin...&quot;);&#xA;    Serial.println(&quot;This program will calibrate the ESC.&quot;);&#xA;&#xA;    motor.attach(MOTOR_PIN);&#xA;&#xA;    Serial.println(&quot;Now writing maximum output.&quot;);&#xA;    Serial.println(&quot;Turn on power source, then wait 2 seconds and press any key.&quot;);&#xA;&#xA;    motor.writeMicroseconds(MAX_SIGNAL);&#xA;&#xA;    // Wait for input&#xA;    while (!Serial.available());&#xA;    Serial.read();&#xA;&#xA;    // Send min output&#xA;    Serial.println(&quot;Sending minimum output&quot;);&#xA;    motor.writeMicroseconds(MIN_SIGNAL);&#xA;}&#xA;void loop() {  &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;^shamelessly copied from the internet&lt;/p&gt;&#xA;" OwnerUserId="18864" LastEditorUserId="6936" LastEditDate="2017-06-28T08:05:56.313" LastActivityDate="2018-04-29T12:56:34.947" Title="How do I calibrate an ESC after connecting it to an Arduino?" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21309" PostTypeId="1" CreationDate="2016-03-02T17:10:41.470" Score="5" ViewCount="14699" Body="&lt;p&gt;I just installed the 1.6.7 version and want to upload it a sketch to Arduino UNO hardware. I get error message:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/home/pali/Irataim/TarBalls/Arduino/arduino-1.6.7/hardware/tools/avr/bin/avrdude: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm on Gentoo linux operating system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By following this link:  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forums.gentoo.org/viewtopic-p-7815500.html?sid=f67283068e3655b2f9e259a2097efef6&quot; rel=&quot;nofollow&quot;&gt;https://forums.gentoo.org/viewtopic-p-7815500.html?sid=f67283068e3655b2f9e259a2097efef6&lt;/a&gt;&lt;br&gt;&#xA;I just add tinfo USE flag to ncurses package, re-emerged it and can run Arduino IDE that I emerged from Gentoo repository.&lt;/p&gt;&#xA;" OwnerUserId="18811" LastEditorUserId="612" LastEditDate="2016-10-15T20:14:00.427" LastActivityDate="2016-12-14T23:27:44.273" Title="error while loading libtinfo.so.5 - SOLVED" Tags="|upload|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21310" PostTypeId="2" ParentId="21309" CreationDate="2016-03-02T17:14:42.660" Score="2" Body="&lt;p&gt;Install &lt;code&gt;libtinfo5&lt;/code&gt;, the terminfo library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help, you can try to debug the problem yourself. First,&#xA;check which libtinfo avrdude is looking for:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ldd arduino-1.7.8-linux64/hardware/tools/avr/bin/avrdude_bin | grep libtinfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my Ubuntu, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libtinfo.so.5 =&amp;gt; /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fa74a888000)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, see where your libtinfo is installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;find /lib /usr/lib -name 'libtinfo*'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my system I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/lib/x86_64-linux-gnu/libtinfo.so.5&#xA;/lib/x86_64-linux-gnu/libtinfo.so.5.9&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any discrepancy between the two?&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-03-03T09:34:42.840" LastActivityDate="2016-03-03T09:34:42.840" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21311" PostTypeId="2" ParentId="21308" CreationDate="2016-03-02T17:25:59.503" Score="1" Body="&lt;p&gt;The is a standard with RC connectors, that is Black always goes to ground white/orange goes to the signal and red/brown goes to 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if you have made a typo, but you need to connect the white to D9 and the black to GND. &lt;a href=&quot;http://m.instructables.com/id/ESC-Programming-on-Arduino-Hobbyking-ESC/http://m.instructables.com/id/ESC-Programming-on-Arduino-Hobbyking-ESC/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;Here is a instructables post&lt;/a&gt;, it describes using a brushed ESC step two reiterates the colour code standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would also need a rotary encoder or shaft encoder to tell the distance moved, there are lots of ways to achieve this from simple(coded disk and IR arrangement) to custom made PCB add-ons.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-03-02T17:25:59.503" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21312" PostTypeId="1" CreationDate="2016-03-02T18:05:29.377" Score="1" ViewCount="7051" Body="&lt;p&gt;I'm trying to get an effect like (&lt;a href=&quot;https://vine.co/v/Mwwbi5a1BFK&quot; rel=&quot;nofollow&quot;&gt;https://vine.co/v/Mwwbi5a1BFK&lt;/a&gt;) using a neopixel ring. I can get the neopixels to turn on and off in a circle motion and I can get the neopixels to fade all at once. What I can't get working is combining the two together. Any help would be much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt; Tried making fade with the circle motion&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;          // Library for NeoPixels&#xA;&#xA;#define pinPix 6                       // Pin driving NeoPixel Ring or String&#xA;#define numPix 8                       // Number of NeoPixels in the Ring or Strip&#xA;&#xA;// Setup NeoPixel Ring&#xA;// Parameter 1 = number of pixels in strip&#xA;// Parameter 2 = pin number driving the strip&#xA;// Parameter 3 = pixel type flags, add together as needed:&#xA;//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)&#xA;//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)&#xA;//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)&#xA;//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)&#xA;Adafruit_NeoPixel myNeoPixels = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800);&#xA;&#xA;&#xA;void setup() {&#xA;  myNeoPixels.begin();   // Initialize the NeoPixel array in the Arduino's memory,&#xA;  myNeoPixels.show();    // turn all pixels off, and upload to ring or string&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  ledTrail(50, 100, 100,255,255, 0,0,0);       // Pause; R,G,B foreground; R,G,B background&#xA;}&#xA;&#xA;&#xA;// Pause = delay between transitions&#xA;// Rf, Gf, Bf = RGB &quot;Foreground&quot; values&#xA;// Rb, Gb, Bb = RGB &quot;Background&quot; values&#xA;const byte extra = 4;  // how many ahead, and behind, to light up&#xA;&#xA;// Pause = delay between transitions&#xA;// Rf, Gf, Bf = RGB &quot;Foreground&quot; values&#xA;// Rb, Gb, Bb = RGB &quot;Background&quot; values&#xA;void ledTrail(int pause, int steps, byte Rf, byte Gf, byte Bf, byte Rb, byte Gb, byte Bb) { &#xA;&#xA;  int tmpR, tmpG, tmpB;         // Temp values&#xA;  // Fade up&#xA;  for (int s=1; s&amp;lt;=steps; s++) {&#xA;    tmpR = (Rf * s) / steps;     // Multiply first to avoid truncation errors  &#xA;    tmpG = (Gf * s) / steps;&#xA;    tmpB = (Bf * s) / steps;&#xA;&#xA;&#xA;&#xA;  for (int i=0; i&amp;lt;numPix; i++) {&#xA;    myNeoPixels.setPixelColor(i,Rf,Gf,Bf);&#xA;&#xA;    // now go &quot;extra&quot; pixels ahead and behind&#xA;    for (int s = 1; s &amp;lt; extra + 1; s++)&#xA;      {&#xA;      tmpR = (Rf * (extra - s)) / extra;     // Multiply first to avoid truncation errors  &#xA;      tmpG = (Gf * (extra - s)) / extra;&#xA;      tmpB = (Bf * (extra - s)) / extra;&#xA;      myNeoPixels.setPixelColor((i + s) % numPix,tmpR,tmpG,tmpB);&#xA;      myNeoPixels.setPixelColor((i + numPix - s) % numPix,tmpR,tmpG,tmpB);&#xA;      }&#xA;&#xA;        // Fade down&#xA;  for (int s=steps; s&amp;gt;0; s--) {&#xA;    tmpR = (Rf * s) / steps;     // Multiply first to avoid truncation errors  &#xA;    tmpG = (Gf * s) / steps;&#xA;    tmpB = (Bf * s) / steps;&#xA;  }&#xA;&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;LED TRAIN CODE&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;          // Library for NeoPixels&#xA;&#xA;#define pinPix 6                       // Pin driving NeoPixel Ring or String&#xA;#define numPix 8                       // Number of NeoPixels in the Ring or Strip&#xA;&#xA;// Setup NeoPixel Ring&#xA;// Parameter 1 = number of pixels in strip&#xA;// Parameter 2 = pin number driving the strip&#xA;// Parameter 3 = pixel type flags, add together as needed:&#xA;//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)&#xA;//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)&#xA;//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)&#xA;//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)&#xA;Adafruit_NeoPixel myNeoPixels = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800);&#xA;&#xA;&#xA;void setup() {&#xA;  myNeoPixels.begin();   // Initialize the NeoPixel array in the Arduino's memory,&#xA;  myNeoPixels.show();    // turn all pixels off, and upload to ring or string&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  ledTrail(100, 255,255,255, 0,0,0);       // Pause; R,G,B foreground; R,G,B background&#xA;}&#xA;&#xA;&#xA;// Pause = delay between transitions&#xA;// Rf, Gf, Bf = RGB &quot;Foreground&quot; values&#xA;// Rb, Gb, Bb = RGB &quot;Background&quot; values&#xA;void ledTrail(int pause, byte Rf, byte Gf, byte Bf, byte Rb, byte Gb, byte Bb) { &#xA;&#xA;  for (int i=0; i&amp;lt;numPix; i++) {&#xA;    myNeoPixels.setPixelColor(i,Rf,Gf,Bf);&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }&#xA;&#xA;  for (int i=0; i&amp;lt;numPix; i++) {&#xA;    myNeoPixels.setPixelColor(i,Rb,Gb,Bb);&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;BREATHING CODE&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;          // Library for NeoPixels&#xA;&#xA;#define pinPix 6                       // Pin driving NeoPixel Ring or String&#xA;#define numPix 8                       // Number of NeoPixels in the Ring or Strip&#xA;&#xA;// Setup NeoPixel Ring&#xA;// Parameter 1 = number of pixels in strip&#xA;// Parameter 2 = pin number driving the strip&#xA;// Parameter 3 = pixel type flags, add together as needed:&#xA;//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)&#xA;//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)&#xA;//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)&#xA;//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)&#xA;Adafruit_NeoPixel myNeoPixels = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800);&#xA;&#xA;&#xA;void setup() {&#xA;  myNeoPixels.begin();   // Initialize the NeoPixel array in the Arduino's memory,&#xA;  myNeoPixels.show();    // turn all pixels off, and upload to ring or string&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  breathe(20, 100, 255,255,255);       // Pause; Number of steps; Full-on R,G,B values&#xA;}&#xA;&#xA;&#xA;// Pause = delay between transitions&#xA;// Steps = number of steps&#xA;// R, G, B = Full-on RGB values&#xA;void breathe(int pause, int steps, byte R, byte G, byte B) { &#xA;&#xA;  int tmpR, tmpG, tmpB;         // Temp values&#xA;&#xA;  // Fade up&#xA;  for (int s=1; s&amp;lt;=steps; s++) {&#xA;    tmpR = (R * s) / steps;     // Multiply first to avoid truncation errors  &#xA;    tmpG = (G * s) / steps;&#xA;    tmpB = (B * s) / steps;&#xA;&#xA;    for (int i=0; i&amp;lt;numPix; i++) {&#xA;      myNeoPixels.setPixelColor(i,tmpR,tmpG,tmpB);&#xA;    }&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }    &#xA;&#xA;  // Fade down&#xA;  for (int s=steps; s&amp;gt;0; s--) {&#xA;    tmpR = (R * s) / steps;     // Multiply first to avoid truncation errors  &#xA;    tmpG = (G * s) / steps;&#xA;    tmpB = (B * s) / steps;&#xA;&#xA;    for (int i=0; i&amp;lt;numPix; i++) {&#xA;      myNeoPixels.setPixelColor(i,tmpR,tmpG,tmpB);&#xA;    }&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }    &#xA;&#xA;  delay(pause * 30);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18898" LastEditorUserId="18898" LastEditDate="2016-03-04T21:38:27.960" LastActivityDate="2016-03-04T21:38:27.960" Title="Neopixel Ring - How to breathe in a circle motion?" Tags="|arduino-uno|led|neopixel|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21314" PostTypeId="2" ParentId="21312" CreationDate="2016-03-02T20:28:47.473" Score="1" Body="&lt;p&gt;I don't have any NeoPixels to try it with (yet) however this should do it. Replace the ledTrail function by this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte extra = 4;  // how many ahead, and behind, to light up&#xA;&#xA;// Pause = delay between transitions&#xA;// Rf, Gf, Bf = RGB &quot;Foreground&quot; values&#xA;// Rb, Gb, Bb = RGB &quot;Background&quot; values&#xA;void ledTrail(int pause, byte Rf, byte Gf, byte Bf, byte Rb, byte Gb, byte Bb) { &#xA;&#xA;  int tmpR, tmpG, tmpB;         // Temp values&#xA;&#xA;  for (int i=0; i&amp;lt;numPix; i++) {&#xA;    myNeoPixels.setPixelColor(i,Rf,Gf,Bf);&#xA;&#xA;    // now go &quot;extra&quot; pixels ahead and behind&#xA;    for (int s = 1; s &amp;lt; extra + 1; s++)&#xA;      {&#xA;      tmpR = (Rf * (extra - s)) / extra;     // Multiply first to avoid truncation errors  &#xA;      tmpG = (Gf * (extra - s)) / extra;&#xA;      tmpB = (Bf * (extra - s)) / extra;&#xA;      myNeoPixels.setPixelColor((i + s) % numPix,tmpR,tmpG,tmpB);&#xA;      myNeoPixels.setPixelColor((i + numPix - s) % numPix,tmpR,tmpG,tmpB);&#xA;      }&#xA;&#xA;    myNeoPixels.show();&#xA;    delay(pause);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this is doing is having an inner loop that &quot;looks ahead&quot; and behind another &lt;code&gt;extra&lt;/code&gt; pixels and makes them brighter/darker. Debugging code (since removed) shows the effect:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;i = 4, R = 255, G = 255, B = 255   &amp;lt;-- original code&#xA;i = 5, R = 191, G = 191, B = 191   &amp;lt;-- one ahead  (darker)&#xA;i = 3, R = 191, G = 191, B = 191   &amp;lt;-- one behind (darker)&#xA;i = 6, R = 127, G = 127, B = 127   &amp;lt;-- two ahead  (darker still)&#xA;i = 2, R = 127, G = 127, B = 127   &amp;lt;-- two behind (darker still)&#xA;i = 7, R = 63, G = 63, B = 63      &amp;lt;-- and so on&#xA;i = 1, R = 63, G = 63, B = 63&#xA;i = 8, R = 0, G = 0, B = 0&#xA;i = 0, R = 0, G = 0, B = 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-02T20:28:47.473" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21315" PostTypeId="2" ParentId="21297" CreationDate="2016-03-02T20:38:44.923" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/questions/15458883/using-array-init-list-as-temporary-in-c11&quot;&gt;Using array init list as temporary in C++11?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can solve it by using &lt;code&gt;const&lt;/code&gt;. This compiles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char a[8];&#xA;&#xA;void cpaddr(char target[], const byte *source) {&#xA;    int i;&#xA;    for (i=0; i&amp;lt;8; i++)&#xA;        target[i] = source[i];&#xA;}&#xA;&#xA;int main() {&#xA;    byte b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};&#xA;    cpaddr(a, b);&#xA;    cpaddr(a, (const byte[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note I had to change your array from &lt;code&gt;char&lt;/code&gt; to &lt;code&gt;byte&lt;/code&gt; because I was getting (valid) warnings that things like 0xCA don't fit into a char.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-02T20:38:44.923" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21316" PostTypeId="1" CreationDate="2016-03-02T22:22:17.183" Score="1" ViewCount="18969" Body="&lt;p&gt;I have my ESP8266 connected via serial to USB like the image shows: &lt;a href=&quot;https://i.stack.imgur.com/Eqq6f.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Eqq6f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It worked just fine, however, when I tried flashing Blynk code&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#define BLYNK_PRINT Serial    &#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;BlynkSimpleEsp8266.h&amp;gt;&#xA;&#xA;&#xA;char auth[] = &quot;YourAuthToken&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Blynk.begin(auth, &quot;ssid&quot;, &quot;pass&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Blynk.run();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It started outputting loads of garbage in the serial monitor, while Blynk app said ESP is not connected to network. I've tried since then flashing empty sketches or some other stuff, whatever I do, serial monitor shows loads of junk. I've tried changing modes, I've tried changing baud rates (57600 was default, and AT worked just fine). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Junk example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  …ÕZªP‚,JHVYº—¡VÕ]­J*ÉW¥¡Õ¥Õ-”ªUŠQd®”¡âJ%H&#xA;!HiZÊIIRPÖuUPÒ‚BñZT¥ *EUeZB\)*EVjU!\©Š_¥¢”ÅVªqYiUµP”¬ÕPQT°*uH)HZKB*ÕXªuH!HBHBH…µEIâHBH!H©ªqY+hZVB\BH!HÊ*Òµe�qHBHBHŠ*i±…Z¦-hUµPÔ¬ÔPQT°*uH)H-KB*ÕXªuH!HBHBH…µE­B\!H!HBVªqY+iZVB\BH!HeVÒZ¢qHBHBHŠ*iQ…Z¦-hUµPÔ¬ÔPQTaYRB\    jHiBHªaYRB\BH!HBVªaYRB\BH!HBVªqY+iZVB\BH!HÊVÒZ¢qHBHBHŠ*i±Õ\V&#xA;iUµPÔ¬ÕPQT°*uH)H-JBVªaYRB\BH!H!VªaYR!\BHBH!Vªq©+hZW!\BHBHJ*iµE�âHBH!HŠ*i±…Z¦-hUµPÕ¬ÔPQTaYR!\    %Hi!HÕXªuH!HBHBH…µEIqHBHBH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18902" LastEditorUserId="4131" LastEditDate="2016-04-04T23:20:57.717" LastActivityDate="2022-03-14T13:47:38.430" Title="ESP8266 shows garbage in serial monitor" Tags="|esp8266|" AnswerCount="6" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21317" PostTypeId="2" ParentId="16750" CreationDate="2016-03-02T22:43:07.557" Score="0" Body="&lt;p&gt;Since you are reading received data into array &lt;code&gt;newData&lt;/code&gt;, you should replace &lt;code&gt;System.out.println(&quot;Read &quot; + numRead + &quot; bytes.&quot;);&lt;/code&gt; with &lt;code&gt;System.out.print(newData);&lt;/code&gt; (not sure about the syntax, since I dont know Java) if you want to print the actual data received and not just the number of bytes received. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-02T22:43:07.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21319" PostTypeId="1" CreationDate="2016-03-03T00:06:01.303" Score="2" ViewCount="408" Body="&lt;p&gt;I'm quite new to Arduino and the programming of the board, but I wanted to have a go at making a traffic light based on an example I found online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example supplied a simple layout which I roughly copied with the components I had.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Uv0b2.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Uv0b2.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then created the following code to mimic the traffic lights of my local area.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int red = 13;   int yellow = 12;   int green = 11;&#xA;&#xA;void setup(){&#xA;    pinMode(red,OUTPUT);&#xA;    pinMode(yellow,OUTPUT);&#xA;    pinMode(green,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;    changeLights();&#xA;}&#xA;&#xA;void changeLights(){&#xA;    // red on, other off for 3 seconds&#xA;    digitalWrite(green,LOW); &#xA;    digitalWrite(yellow,LOW);&#xA;    digitalWrite(red,HIGH); &#xA;    delay(3000);&#xA;&#xA;    // red on, amber on,green off for 3 seconds &#xA;    digitalWrite(green,LOW);&#xA;    digitalWrite(yellow,HIGH); &#xA;    digitalWrite(red,HIGH); &#xA;    delay(3000);&#xA;&#xA;    // red off, amber off,green on for 3 seconds &#xA;    digitalWrite(green,HIGH);&#xA;    digitalWrite(yellow,LOW); &#xA;    digitalWrite(red,LOW); &#xA;    delay(3000);&#xA;&#xA;    // red off, amber on,green on for 3 seconds &#xA;    digitalWrite(green,HIGH);&#xA;    digitalWrite(yellow,HIGH); &#xA;    digitalWrite(red,LOW); &#xA;    delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm wanting to achieve next is a button which resets the code back to the top of &lt;code&gt;void changeLights&lt;/code&gt;. &#xA;I assume I would be able to do this using a push-to-make switch, but I'm not sure how to incorporate it into my circuit or if it is even possible to reset using this.&lt;/p&gt;&#xA;" OwnerUserId="17175" LastEditorUserId="10794" LastEditDate="2016-03-04T04:45:40.513" LastActivityDate="2016-03-04T08:58:37.410" Title="Adding button which resets to top of void" Tags="|arduino-uno|c++|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21321" PostTypeId="1" AcceptedAnswerId="21325" CreationDate="2016-03-03T01:44:10.943" Score="0" ViewCount="2201" Body="&lt;p&gt;This photoresistor has a min/max of 0-1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to scale the brightness of a cathode RGB LED based on the sensor's value, but based on my current lighting, the min/max readings I generally am getting are 100-700.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I scale the sensor reading so that 100 = no light on the LED and 700 = max brightness? &lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-03T03:22:45.787" Title="How do I adjust the scale/calibration of a photoresistor?" Tags="|led|rgb-led|photoresistor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21322" PostTypeId="1" AcceptedAnswerId="21327" CreationDate="2016-03-03T02:54:07.027" Score="-1" ViewCount="406" Body="&lt;p&gt;I have done extensive research into the differences and here are the questions i have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What is a micro controller and what differs it from the raspberry pi system&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Why buy the Arduino when it is less powerful than the raspberry pi&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What projects would either system be better for&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Does Arduino run a full OS&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Where is the best place to buy arduino and raspberry pi&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the difference in the ad dons &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Which has the most tutorials&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the different's in power supply and usages&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I know i'm asking this on a forum with arduino fans (There is no arduino vs raspberry pi forum) but opinions aside which is the best for beginners (I can program C++ and python as well as building hardware components) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What is the general price different overall including buying extra ad dons/shields &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you for your answers :)&lt;/p&gt;&#xA;" OwnerUserId="18907" LastActivityDate="2016-03-03T04:44:36.617" Title="Arduino vs Raspberry, Advantages And Disadvantes" Tags="|programming|power|raspberrypi|" AnswerCount="1" CommentCount="3" ClosedDate="2016-03-03T06:58:12.873" ContentLicense="CC BY-SA 3.0" />
  <row Id="21323" PostTypeId="1" CreationDate="2016-03-03T03:00:57.047" Score="0" ViewCount="5504" Body="&lt;p&gt;What I've tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I downloaded the package for 1.6.7 on Ubuntu 14.04 LTS but when I open it no matter what I try it will not start.&lt;/li&gt;&#xA;&lt;li&gt;I installed 1.0.5 from the Ubuntu Software Center. I tried to update it but found no solution.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;UPDATE: I found my answer in talamaki's answer on that other question linked above.&lt;/p&gt;&#xA;" OwnerUserId="18908" LastEditorUserId="11529" LastEditDate="2016-03-26T23:02:47.313" LastActivityDate="2016-03-26T23:02:47.313" Title="How do I install the latest Arduino IDE on Ubuntu 14.04LTS?" Tags="|arduino-ide|ubuntu|installation|" AnswerCount="1" CommentCount="3" ClosedDate="2016-03-03T20:53:59.170" ContentLicense="CC BY-SA 3.0" />
  <row Id="21324" PostTypeId="1" CreationDate="2016-03-03T03:17:15.187" Score="0" ViewCount="4134" Body="&lt;p&gt;We have an arduino due with a Tiny RTC I2C module and we're trying to print the current time to the serial monitor. However its not working, currently its printing the time as 2165/165/165 (Monday) 165:165:85 (it should read something like 2016/3/3 (Thursday) 4:15:00). Interestingly it continues to read the same thing, it doesn't change, even if I remove the module from the breadboard completely. I have tried this with two of the modules and both have the same exact results. Does anyone know how to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My schematics are the same as shown here:&#xA;&lt;a href=&quot;http://www.hobbyist.co.nz/?q=real_time_clock&quot; rel=&quot;nofollow&quot;&gt;http://www.hobbyist.co.nz/?q=real_time_clock&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code, it's just the example code from the imported library for the clock.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Date and time functions using a DS1307 RTC connected via I2C and Wire lib&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;#if defined(ARDUINO_ARCH_SAMD)&#xA;// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!&#xA;   #define Serial SerialUSB&#xA;#endif&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;char daysOfTheWeek[7][12] = {&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;};&#xA;&#xA;void setup () {&#xA;&#xA;#ifndef ESP8266&#xA;  while (!Serial); // for Leonardo/Micro/Zero&#xA;#endif&#xA;&#xA;  Serial.begin(57600);&#xA;  if (! rtc.begin()) {&#xA;    Serial.println(&quot;Couldn't find RTC&quot;);&#xA;    while (1);&#xA;  }&#xA;&#xA;  if (! rtc.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;    // This line sets the RTC with an explicit date &amp;amp; time, for example to set&#xA;    // January 21, 2014 at 3am you would call:&#xA;    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));&#xA;  }&#xA;}&#xA;&#xA;void loop () {&#xA;    DateTime now = rtc.now();&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(&quot; (&quot;);&#xA;    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);&#xA;    Serial.print(&quot;) &quot;);&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;&#xA;    Serial.print(&quot; since midnight 1/1/1970 = &quot;);&#xA;    Serial.print(now.unixtime());&#xA;    Serial.print(&quot;s = &quot;);&#xA;    Serial.print(now.unixtime() / 86400L);&#xA;    Serial.println(&quot;d&quot;);&#xA;&#xA;    // calculate a date which is 7 days and 30 seconds into the future&#xA;    DateTime future (now + TimeSpan(7,12,30,6));&#xA;&#xA;    Serial.print(&quot; now + 7d + 30s: &quot;);&#xA;    Serial.print(future.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(future.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(future.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(future.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(future.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(future.second(), DEC);&#xA;    Serial.println();&#xA;&#xA;    Serial.println();&#xA;    delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="18429" LastEditDate="2016-03-03T18:29:42.237" LastActivityDate="2016-03-22T06:41:13.787" Title="Arduino is not responding to a Tiny RTC I2C modules, How to fix?" Tags="|arduino-due|rtc|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="21325" PostTypeId="2" ParentId="21321" CreationDate="2016-03-03T03:22:45.787" Score="2" Body="&lt;p&gt;You can easily scale in Arduino code with the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;map()&lt;/a&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MIN_LIGHT 100;&#xA;const int MAX_LIGHT 700;&#xA;&#xA;int light_reading = analogRead(A0);&#xA;&#xA;// Convert MIN reading (100) -&amp;gt; MAX reading (700) to a range 0-&amp;gt;100.&#xA;int percentage_bright = map(light_reading, MIN_LIGHT, MAX_LIGHT, 0, 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you may need some calibration of your system to handle different ambient light situations. What reading do you get in direct sunlight for example?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I assume you're using PWM (Pulse Width Modulation) to drive the LED.  This requires a value between 0 &amp;amp; 255.  Once again we can use the map() function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Convert light-value % (0-100) to PWM speed (0-255)&#xA;int led_brightness = map(percentage_bright, 0, 100, 0, 255);&#xA;analogWrite(LED_PIN_RED, led_brightness);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously these bits of code can be reduced down to a single line - mapping directly from the reading to the desired result.&lt;/p&gt;&#xA;" OwnerUserId="2926" LastActivityDate="2016-03-03T03:22:45.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21327" PostTypeId="2" ParentId="21322" CreationDate="2016-03-03T04:44:36.617" Score="1" Body="&lt;p&gt;1) Here is a great article about microcontrollers and how they differ from a full computer: &lt;a href=&quot;http://electronics.howstuffworks.com/microcontroller1.htm&quot; rel=&quot;nofollow&quot;&gt;http://electronics.howstuffworks.com/microcontroller1.htm&lt;/a&gt; &#xA;tl;dr: A Raspberry Pi runs a full desktop OS (often Linux) and as such, can do most of the things a &quot;typical&quot; computer can do, such as browse the internet or install different programs. An Arduino, however, cannot do that. An Arduino can run one piece of software that you program to it (called a sketch in the Arduino world) and repeat that same program over and over. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) They have different purposes. A Raspberry Pi is designed as a low-cost desktop computer that you can put anywhere, and also as a platform that is easy to put into different projects. An Arduino is better suited for attaching sensors to, controlling motors, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) see #2&#xA;Also, a Raspberry Pi is typically used when a GUI is wanted, or when more computing power is required. An Arduino is typically used for more real time things such as reading sensors or controlling LED's. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) No, it does not. Arduino's run C++ compiled as machine code object files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;5) For the Raspberry Pi, Here is the list of official resellers: &lt;a href=&quot;https://www.raspberrypi.org/products/model-b-plus/&quot; rel=&quot;nofollow&quot;&gt;https://www.raspberrypi.org/products/model-b-plus/&lt;/a&gt;&#xA;For the arduino, it depends on what kind you're buying and where you live, there are many different styles. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;6) As a general rule, Arduino's have more shields. But, a raspberry pi typically needs a screen, mouse, keyboard, etc. Everything a standard computer needs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;7) Entirely depends on what you're trying to do. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;8) Both take a 5V input voltage. An Arduino can take up to a 20v input (again, depending on the model) whereas the Raspberry Pi can just be powered with 5v over USB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;9) Again, depends on what you're trying to do. A Raspberry Pi is &quot;easier&quot; to use, as it's a full computer. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-03T04:44:36.617" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21328" PostTypeId="1" CreationDate="2016-03-03T05:31:22.403" Score="0" ViewCount="307" Body="&lt;p&gt;I'm working on the Adafruit Firewalker shoes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't make my code compile to test my flora project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 10), Board: &quot;Adafruit Flora&quot;&#xA;&#xA;C:\Users\Devi\Documents\Arduino\test_2\test_2.ino\test_2.ino.ino:1:29: fatal error: Adafruit_NeoPixel: No such file or directory&#xA;&#xA;&#xA; #include &amp;lt;Adafruit_NeoPixel&amp;gt;&#xA;&#xA;                             ^&#xA;&#xA;compilation terminated.&#xA;&#xA;exit status 1&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/firewalker-led-sneakers/test-circuit&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/firewalker-led-sneakers/test-circuit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;const int analogInPin = A9;  // Analog input pin that the potentiometer is attached to&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, 6, NEO_GRB + NEO_KHZ800);&#xA;int sensorValue = 0;        // value read from the pot&#xA;&#xA;void setup() {&#xA;  // initialize serial communications at 9600 bps:&#xA;  Serial.begin(9600);&#xA; pinMode(9, INPUT_PULLUP); &#xA;   strip.begin();&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the analog in value:&#xA;  sensorValue = analogRead(analogInPin);              &#xA;  // print the results to the serial monitor:&#xA;  Serial.print(&quot;sensor = &quot; );                       &#xA;  Serial.println(sensorValue);      &#xA;&#xA;if (sensorValue &amp;lt; 100){&#xA;  Serial.println(&quot;leds triggered&quot;); &#xA;colorWipe(strip.Color(255, 0, 0), 25);&#xA;colorWipe(strip.Color(0, 0, 0), 25);&#xA;}  &#xA;&#xA;}&#xA;&#xA;void colorWipe(uint32_t c, uint8_t wait) {&#xA;  for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, c);&#xA;      strip.show();&#xA;      delay(wait);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18912" LastEditorUserId="10794" LastEditDate="2016-03-03T09:39:32.953" LastActivityDate="2019-12-22T09:01:20.153" Title="help compiling code for flora project" Tags="|c++|compile|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21330" PostTypeId="2" ParentId="17301" CreationDate="2016-03-03T06:19:03.450" Score="2" Body="&lt;p&gt;I got this working using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Servo&quot; rel=&quot;nofollow&quot;&gt;Servo library&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You set the input method to PWM.&lt;/li&gt;&#xA;&lt;li&gt;Connect your RX on the motor controller and hook it up to the servo pin.&lt;/li&gt;&#xA;&lt;li&gt;Connect the ground of the Arduino to the ground of the JRK 21v3.&lt;/li&gt;&#xA;&lt;li&gt;Then use the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Knob&quot; rel=&quot;nofollow&quot;&gt;knob servo sample&lt;/a&gt; by hooking up a pot to a Arduino.&lt;/li&gt;&#xA;&lt;li&gt;The calibrate the JRK 21v3 by selecting learn.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now you can use the actuator as a servo.&lt;/p&gt;&#xA;" OwnerUserId="18913" LastEditorUserId="6936" LastEditDate="2016-03-16T07:37:02.743" LastActivityDate="2016-03-16T07:37:02.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21331" PostTypeId="2" ParentId="21323" CreationDate="2016-03-03T06:19:17.643" Score="0" Body="&lt;p&gt;Follow the following step to download, install and run Arduino IDE on Ubuntu&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First Download the Tar (tar-bal) from this link &lt;a href=&quot;http://arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;http://arduino.cc/en/Main/Software&lt;/a&gt; (download the correct 32 / 64 bit linux version ) depends upon your Ubuntu version.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Then goto download folder using terminal (shell) or the folder where you downloaded the tar and unpacked that tar using the following commands&#xA;like &#xA;cd /Downloads&#xA;tar -zxvf arduino-1.6.7-linux32.tgz&#xA;where 1.6.7 is the version of ide &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you also need java runtime environment for arduino IDE download and install it using the following command&#xA;   sudo apt-get install openjdk-7-jre&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you also need to provide the UART permissions for your hardware using following commands&#xA;sudo chmod a+rw /dev/ttyACM0&#xA;where ACM0 is the port number if you are using multiple or many arduinos just give permissions using the above commands by replacing the ACM0 to ACM1 to ACMN&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;5&quot;&gt;&#xA;&lt;li&gt;then create a shortcut of arduino ide from the folder where you extract the tar&#xA;cd ~/Desktop&#xA;ln -s /Downloads/arduino-1.6.7/arduino&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;and then double click the shortcut to run arduino if it gives permission error then right click the shortcut and in file preferences gives permissions to the shortcut&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-03-03T06:19:17.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21333" PostTypeId="1" AcceptedAnswerId="21348" CreationDate="2016-03-03T07:17:39.800" Score="2" ViewCount="887" Body="&lt;p&gt;In my house, I have a low voltage AC signal (0-10V) that is proportional to the amount of current that is drawn at any moment (or as it is presented: kW) (europe, 50Hz). Presently, it is just shown as a dial in my kitchen, of course I would to log this. I want to rectify and integrate this singnal over an appropriate time span (maybe on minute) As far as I can see, I basically have two ways of doing this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The pure arduino approach: Using a voltage divider to get it down to 0-5 V (after rectification) (and maybe throw in a zener diode as an extra protection) Then using an adc in the arduino and measure the voltage directly. The problem I foresee with this approach is that I will need a pretty high sampling rate to make sure I get the peak values. If I managed to sample at exactly the same frequency as my mains,I could just calibrate the measured value (unless I managed to hit the cross overs) but I do not think that would be feasible So I think I need to maybe sample on approx 500 Hz and pick out the highest value from each 1/50 second.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Using an opamp, a few resistors and a capasitor to set up an analog integration circuit, then use the arduino to read out and reset that at appropriate times. Setting up the integration circuit is no problem for me, but I need some feedback on the reset circuit. I have been looking around a bit, but I have not found any standard way to reset an integrator circuit, it seems like the idea is that it should be integrating for as long as it is running.. As far as I can see, as long as it running on &amp;lt;= 5V, I could use an input on the arduino to drain it? - I would then need to make the dimensions such that the low current the arduino input draws will allow the integrator to be reset fast enough.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any comments? Have I overlooked something? is there a third approach that I have not been thinking about? Is the 1st approach easier that what I think?&lt;/p&gt;&#xA;" OwnerUserId="16770" LastActivityDate="2016-03-03T10:58:02.327" Title="Integration of signal" Tags="|adc|analog-sampling|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21334" PostTypeId="2" ParentId="21328" CreationDate="2016-03-03T07:28:33.917" Score="-1" Body="&lt;p&gt;i think issue is in your this path &#xA;C:\Users\Devi\Documents\Arduino\test_2\test_2.ino\test_2.ino.ino:1:29: fatal error: Adafruit_NeoPixel: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;make new arduino file and copy the same code and save it on other folder on desktop or other drive then compile it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Compilation&lt;/strong&gt;&#xA;I compiled you same code and my stored path of .ino file is&#xA;C:\Users\Muhammad Hassaan\Documents\Arduino\sketch_mar04a&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UapSn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UapSn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16299" LastEditorUserId="16299" LastEditDate="2016-03-04T05:59:43.670" LastActivityDate="2016-03-04T05:59:43.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21335" PostTypeId="2" ParentId="21294" CreationDate="2016-03-03T08:01:08.703" Score="2" Body="&lt;p&gt;You are missing the line termination&#xA;you must send '\n' after your data in order to receive the data&#xA;or use &#xA;conexion.println(entrada) &#xA;rather then&#xA;conexion.write(entrada)&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-03-03T08:01:08.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21336" PostTypeId="2" ParentId="21333" CreationDate="2016-03-03T08:09:14.763" Score="0" Body="&lt;p&gt;I'm not quite clear on the 'peak' detection - this would mean your reading would be changing several times a second potentially. Does the current in your house vary that much per second? I don't think your electricity meter is that clever anyway (there must be a smoothing effect, I reckon). For example, if you turned on your electric kettle for 1/50th of a second, would your domestic meter accurately record that (or the 0-10V signal vary)? I personally doubt it but I'm no meter designer! Anyway, you also mention that you want to log over a minute? I'm unclear on the exact requirements here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, if you are reading the 'max' current (so you can accurately calculate bills, for example) I think your first approach would work - after all a 50Hz sampling rate is very low for an Arduino. You won't need a 500Hz sample rate as the data doesn't change &lt;em&gt;that&lt;/em&gt; frequently anyway, does it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps you could trigger the sampling activity by synchronising to the mains frequency (which you sort of allude to) and then do the reading? Use an analog input to detect the rising LV mains cycle and then do the reading? Or use a Schmidt trigger to trigger the Arduino (sounds a bit of overkill, I think the Arduino could do it all).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Experimentation is called for to see what works and what doesn't but your first approach seems eminently feasible to me.&lt;/p&gt;&#xA;" OwnerUserId="18870" LastActivityDate="2016-03-03T08:09:14.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21337" PostTypeId="1" CreationDate="2016-03-03T08:28:54.883" Score="3" ViewCount="1424" Body="&lt;p&gt;Consider this image from &lt;a href=&quot;https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi&quot; rel=&quot;nofollow noreferrer&quot;&gt;sparkfun&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EGm4Q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EGm4Q.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I have this setup, a master and &lt;em&gt;n&lt;/em&gt; slaves, plus a programmer connected to the SPI lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I program the master (Arduino), the Arduino is reset. This means that all the data pins go low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since SS is active low, all the SS pins on the slaves go active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this means that all the slaves start driving the same MISO line (blue arrow from slaves to master), either high or low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doesn't this result in bus contention on that line? If not, what's the mechanism that prevents bus contention from happening?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-03-03T08:51:05.603" Title="Why isn't there bus contention on the MISO line during SPI-based programming?" Tags="|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21338" PostTypeId="2" ParentId="21337" CreationDate="2016-03-03T08:42:24.823" Score="3" Body="&lt;p&gt;Yes, you &lt;em&gt;can&lt;/em&gt; get SPI bus contention when using multiple SPI slave devices. It is up to you, the designer, to ensure that each SPI slave device has its chip select (CS or SS) asserted only when no other devices are driving MISO. Normally that is achieved by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;initialize all of the CS pins high (inactive) during setup&lt;/li&gt;&#xA;&lt;li&gt;in the code that accesses SPI device #1,&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;assert SPI device #1 CS1 low (active)&lt;/li&gt;&#xA;&lt;li&gt;perform SPI transfers on SPI device #1&lt;/li&gt;&#xA;&lt;li&gt;release SPI device #1 CS1 high (inactive)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;in the code that accesses SPI device #2,&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;assert SPI device #2 CS2 low (active)&lt;/li&gt;&#xA;&lt;li&gt;perform SPI transfers on SPI device #1&lt;/li&gt;&#xA;&lt;li&gt;release SPI device #2 CS2 high (inactive)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;SPI bus contention can also occur during device programming (loading the bootloader or firmware image), if there is an attached SPI slave device, and its chip select (SS) is not pulled inactive by a pullup resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had a problem with this on one of my designs a few weeks ago. I was trying to burn the bootloader into some blank ATmega328-AU chips post-assembly, and my device programmer wasn't able to successfully program the chips because my one slave device had its chip select connected only to an ATmega328 pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had previously breadboarded this design using an Arduino Pro Mini board, and it was working fine; but when I moved to first prototype PCB there was bus contention on MISO -- the blank ATmega328 wasn't driving the slave device's chip select high or low, but it floated low (active), causing MISO contention.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution (workaround) was temporarily contacting the chip-select to VDD 3.3V through a 10kohm resistor. This made my SPI slave device inactive, allowing the device programmer to successfully load the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think there would be no harm in leaving the pullup resistor on chip select (since it's an active-low signal), but it was only really necessary when using the device programmer. After I had the prototype boards initialized with the bootloader image, I was subsequently able to load firmware images as usual.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(One minor unrelated issue was that my assembler purchased ATmega328-AU when I had specified ATmega328P-AU -- they are almost the same, and it doesn't make a difference for my application, but it was annoying that I had to use a slightly different command line argument than then one I used with the Arduino Pro Mini board.)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7174" LastEditorUserId="7174" LastEditDate="2016-03-03T08:51:05.603" LastActivityDate="2016-03-03T08:51:05.603" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21340" PostTypeId="1" CreationDate="2016-03-03T09:49:33.800" Score="3" ViewCount="16109" Body="&lt;p&gt;I need to include a 3 digit ascii representation of message length number in the message header, but I am having difficulty trying to pad the number with leading '0' zeros in order to keep the number of 'length' digits needing to be appended always 3 even when the message length is only one or two digits long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Addendum:&#xA;The problem, more specifically, is how to left-pad a char array containing the number representation. &#xA;I got as far as defining what and where, but I couldn't figure out &lt;strong&gt;how&lt;/strong&gt; to shift the char[] contents right in order to insert the &quot;0&quot; at msglength[0].  (I tried using strcat, but that didn't work).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char msglength[4]          //(3 digits + nul)&#xA;for (int pad=1; pad&amp;lt;=3-strlen(msglength); pad++)&#xA;{&#xA;    // add a leading zero char to msglength, but that involves&#xA;    // somehow shifting all its contents to the right&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16433" LastEditorUserId="10003" LastEditDate="2016-03-03T15:24:54.657" LastActivityDate="2016-03-04T08:56:36.247" Title="How to pad an ascii number with leading zeros?" Tags="|serial|programming|communication|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21341" PostTypeId="2" ParentId="21333" CreationDate="2016-03-03T10:02:06.473" Score="1" Body="&lt;p&gt;With an Arduino Uno, you can get 9615 samples per second from an analog&#xA;input, and do the data processing at the same time. That's more than&#xA;enough to reliably detect a peak. For this, you have to set the ADC to&#xA;&quot;free running mode&quot; and do the processing in the ADC interrupt service&#xA;routine. Se &lt;a href=&quot;https://arduino.stackexchange.com/a/21175&quot;&gt;this answer&lt;/a&gt; for&#xA;a detailed explanation and code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and instead of peak detection, you could just integrate your signal.&#xA;That should be simpler, and simple is good for interrupt-driven data&#xA;processing.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-03T10:02:06.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21343" PostTypeId="2" ParentId="21319" CreationDate="2016-03-03T10:24:15.193" Score="4" Body="&lt;p&gt;As currently written, your changeLights() function, which is repeatedly called over and over again by the Arduino loop() function, runs a timed sequence of lights.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Red light is on for 3000 ms&lt;/li&gt;&#xA;&lt;li&gt;Amber is on for 3000 ms&lt;/li&gt;&#xA;&lt;li&gt;Green is on for 3000 ms&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This sequence could also be implemented using a state machine, but as it is right now, it's just a simple sequence of operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now you have a new feature request &lt;em&gt;(heh, this happens all the time in pro software development)&lt;/em&gt;: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;hardware will include a momentary switch to ground&lt;/li&gt;&#xA;&lt;li&gt;when the switch is pressed, the changeLights() sequence will skip to the next Red light&lt;/li&gt;&#xA;&lt;li&gt;we might also want to do other kinds of sequence change, not just reset&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The simplest way to code this would be to use digitalRead() to test whether the switch is pressed. You could test just after each of the delay(3000) calls. Technically this would work, but it would only sense the switch state just at the instant that digitalRead() is called. So for most of your 9-second sequence, it will ignore the switch, and only briefly test. The user will have to hold the button for 3 seconds to be sure the program senses the switch press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some better ways to make this work. The delay(3000) actually makes the program do nothing else but watch the clock for the full delay interval, it doesn't do anything else during this time. So instead of delay(3000) you could use a for loop, and test whether the button has been pressed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Spend 3 seconds waiting; exit the function if BUTTON1 is pressed.&#xA;for(int count = 300; count &amp;gt; 0; count--) {&#xA;    delay(10); // test the button every 10 ms&#xA;    if (digitalRead(BUTTON1) == LOW) {&#xA;        return; // skip out of the changeLights() function&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Just saw Edgar Bonet's comment about the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;blink without delay&lt;/a&gt; Ardino example, which is another valid way to do the same thing. You could also use the millis() function and calculate the time when the next state transition should happen.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is an educational example, it's worth looking into how you would implement this as a &lt;strong&gt;state machine&lt;/strong&gt;. (The traffic lights controller is often used as an introduction to state machines.) There's two types of state machines, Mealy and Moore, the difference is that one kind the outputs are determined only by the internal state, and the other kind, the outputs are a function of the internal state and the inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple traffic light controller state machine might look like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;state 0: initialize; next state=1&lt;/li&gt;&#xA;&lt;li&gt;state 1: Red light on, timer=5 seconds, next state=2&lt;/li&gt;&#xA;&lt;li&gt;state 2: Green light on, timer=3 seconds, next state=3&lt;/li&gt;&#xA;&lt;li&gt;state 3: Amber light on, timer=1 seconds, next state=1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Use a timing countdown like in the example above, and when the countdown reaches 0, advance to the next state.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int S0_INIT = 0; // state 0: initialize&#xA;const int S1_RED = 1; // state 1: Red light on&#xA;const int S2_GREEN = 2; // state 2: Green light on&#xA;const int S3_AMBER = 3; // state 3: Amber light on&#xA;int state = S0_INIT;&#xA;int stateTimer = 0;&#xA;// void setup() not shown; configures input and output pins by pinMode(...)&#xA;void loop()&#xA;{&#xA;    if (stateTimer &amp;lt; 0) { stateTimer = 0; state = S0_INIT; return; }&#xA;    if (stateTimer &amp;gt; 0) {&#xA;        stateTimer = stateTimer - 1;&#xA;        delay(10); // 10 ms interval&#xA;        return;&#xA;    }&#xA;    switch(state) {&#xA;    case S0_INIT: // state 0: initialize; next state=1&#xA;        stateTimer = 0;&#xA;        state = S1_RED;&#xA;        break;&#xA;    case S1_RED: // state 1: Red light on, timer=5 seconds, next state=2&#xA;        // digitalWrite(... etc.) Red light on&#xA;        stateTimer = 500;&#xA;        state = S2_GREEN;&#xA;        break;&#xA;    case S2_GREEN: // state 2: Green light on, timer=3 seconds, next state=3&#xA;        // digitalWrite(... etc.) Green light on&#xA;        stateTimer = 300;&#xA;        state = S3_AMBER;&#xA;        break;&#xA;    case S3_AMBER: // state 3: Amber light on, timer=1 seconds, next state=1&#xA;        // digitalWrite(... etc.) Amber light on&#xA;        stateTimer = 100;&#xA;        state = S1_RED;&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A more advanced traffic light controller (that responds to input) might look like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;state 0: initialize; next state=1&lt;/li&gt;&#xA;&lt;li&gt;state 1: Red light on, next state=2 (unless SWITCH1=HIGH, next state=4)&lt;/li&gt;&#xA;&lt;li&gt;state 2: Green light on, next state=3 (unless SWITCH1=HIGH, next state=4)&lt;/li&gt;&#xA;&lt;li&gt;state 3: Amber light on, next state=1 (unless SWITCH1=HIGH, next state=4)&lt;/li&gt;&#xA;&lt;li&gt;state 4: Red light on, next state=5 (unless SWITCH1=LOW, next state=2)&lt;/li&gt;&#xA;&lt;li&gt;state 5: no lights on, next state=4 (unless SWITCH1=LOW, next state=2)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An external input SWITCH1 switches this traffic controller between Red-Amber-Green sequence (states 1-2-3) and flashing-Red sequence (states 4-5). Adding constants for S4_BLINKING_RED=4 and S5_BLINKING_RED=5 and replacing the switch(state):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    switch(state) {&#xA;    case S0_INIT:&#xA;        stateTimer = 0;&#xA;        state = S1_RED;&#xA;        break;&#xA;    case S1_RED:&#xA;        // digitalWrite(... etc.) Red light on&#xA;        stateTimer = 500;&#xA;        state = S2_GREEN;&#xA;        if (digitalRead(SWITCH1) == HIGH) {&#xA;            state = S4_BLINKING_RED;&#xA;        }&#xA;        break;&#xA;    case S2_GREEN:&#xA;        // digitalWrite(... etc.) Green light on&#xA;        stateTimer = 300;&#xA;        state = S3_AMBER;&#xA;        if (digitalRead(SWITCH1) == HIGH) {&#xA;            state = S4_BLINKING_RED;&#xA;        }&#xA;        break;&#xA;    case S3_AMBER:&#xA;        // digitalWrite(... etc.) Amber light on&#xA;        stateTimer = 100;&#xA;        state = S1_RED;&#xA;        if (digitalRead(SWITCH1) == HIGH) {&#xA;            state = S4_BLINKING_RED;&#xA;        }&#xA;        break;&#xA;    case S4_BLINKING_RED:&#xA;        // digitalWrite(... etc.) Red light on&#xA;        stateTimer = 50;&#xA;        state = S5_BLINKING_RED;&#xA;        if (digitalRead(SWITCH1) == LOW) {&#xA;            state = S2_GREEN;&#xA;        }&#xA;        break;&#xA;    case S5_BLINKING_RED:&#xA;        // digitalWrite(... etc.) no lights on&#xA;        stateTimer = 50;&#xA;        state = S4_BLINKING_RED;&#xA;        if (digitalRead(SWITCH1) == LOW) {&#xA;            state = S2_GREEN;&#xA;        }&#xA;        break;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Remember to define the SWITCH1 pin, and configure pinMode(SWITCH1 ) in setup().)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course a &lt;em&gt;real&lt;/em&gt; traffic light controller has more lights, say Northbound-Red, Northbound-Amber, Northbound-Green, Westbound-Red, Westbound-Amber, Westbound-Green, etc. Not to mention left turn arrows and maybe even &quot;vehicle present&quot; sensors. For a smart traffic light controller like that, the state is named by what traffic flow is authorized during that state:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;state 1: northbound-southbound traffic green, 5 seconds, next state 2&lt;/li&gt;&#xA;&lt;li&gt;state 2: northbound-southbound traffic amber, 2 seconds, next state 3&lt;/li&gt;&#xA;&lt;li&gt;state 3: all lights red, 0.5 second, next state 4 (unless no vehicles waiting west-east lanes, then next state 6)&lt;/li&gt;&#xA;&lt;li&gt;state 4: westbound-eastbound traffic green, 5 seconds, next state 5&lt;/li&gt;&#xA;&lt;li&gt;state 5: westbound-eastbound traffic amber, 2 seconds, next state 6&lt;/li&gt;&#xA;&lt;li&gt;state 6: all lights red, 0.5 second, next state 7 (unless no vehicles waiting N-W nor S-E left turn bays, then next state 9)&lt;/li&gt;&#xA;&lt;li&gt;state 7: north-to-west left turn and south-to-east left turn green, 3 seconds, next state 8&lt;/li&gt;&#xA;&lt;li&gt;state 8: north-to-west left turn and south-to-east left turn amber, 2 seconds, next state 9&lt;/li&gt;&#xA;&lt;li&gt;state 9: all lights red, 0.5 second, next state 10 (unless no vehicles waiting W-S nor E-N left turn bays, then next state 12)&lt;/li&gt;&#xA;&lt;li&gt;state 10: west-to-south left turn and east-to-north left turn green, 3 seconds, next state 11&lt;/li&gt;&#xA;&lt;li&gt;state 11: west-to-south left turn and east-to-north left turn amber, 2 seconds, next state 1&lt;/li&gt;&#xA;&lt;li&gt;state 12: all lights red, 0.5 second, next state 1 (unless no vehicles waiting north-south lanes, then next state 3)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The power of using state machines is that they all use the same basic &quot;engine&quot;, just with more states, more outputs, more inputs. If the traffic engineer wants to adjust the timing to improve the flow of traffic, that only requires adjusting some of the data, which is much lower risk than rewriting code.  ... and of course state machines apply to more than just traffic lights, it's a very generally useful design technique.&lt;/p&gt;&#xA;" OwnerUserId="7174" LastActivityDate="2016-03-03T10:24:15.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21345" PostTypeId="2" ParentId="21340" CreationDate="2016-03-03T10:40:52.450" Score="5" Body="&lt;p&gt;This is the kind of situation where &lt;code&gt;printf()&lt;/code&gt; comes handy:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;printf(&quot;%03d&quot;, number);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;prints the number in the format you described. Alas, &lt;code&gt;printf()&lt;/code&gt; is not&#xA;part of the standard Arduino API. But you can have it, nonetheless, at&#xA;least on AVR-based Arduinos, as it is provided by the avr-libc, which is&#xA;always linked with all Arduino programs. Some setup is needed to tell&#xA;avr-libc about where is its “standard output”. We can use the macro&#xA;&lt;code&gt;fdev_setup_stream()&lt;/code&gt; to tell it to just push the bytes through&#xA;&lt;code&gt;Serial.write()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;static int Serial_write(char c, FILE *) {&#xA;    if (c == '\n') Serial.write('\r');  // convert LF -&amp;gt; CRLF&#xA;    return Serial.write(c);&#xA;}&#xA;&#xA;static FILE mystdout;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    stdout = &amp;amp;mystdout;&#xA;    fdev_setup_stream(stdout, Serial_write, NULL, _FDEV_SETUP_WRITE);&#xA;}&#xA;&#xA;void loop() {&#xA;    static int count;&#xA;    printf(&quot;%03d and counting...\n&quot;, count++);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C.f. the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#details&quot; rel=&quot;noreferrer&quot;&gt;manual of avr-libc's&#xA;stdio.h&lt;/a&gt;&#xA;for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pros of this method&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;printf()&lt;/code&gt; has plenty of options to control the formatting of your&#xA;messages.&lt;/li&gt;&#xA;&lt;li&gt;It's very standard C, understood by anyone having programmed in that&#xA;language.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This can make your compiled program bigger than it would be if&#xA;sticking with the Arduino API.&lt;/li&gt;&#xA;&lt;li&gt;It's not the “Arduino way”.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-03-03T10:54:04.970" LastActivityDate="2016-03-03T10:54:04.970" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21348" PostTypeId="2" ParentId="21333" CreationDate="2016-03-03T10:58:02.327" Score="3" Body="&lt;p&gt;Sorry, but.. Why integration? Just use a peak detector like this one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6voW0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6voW0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output will &quot;float&quot; to the peak value of the input signal, minus the voltage drop across the diode:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lafnM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lafnM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output oscillates between 9.7V and 9.2V, which is a 5% maximum error. If you want to reduce it, sample with a sample rate not multiple of 50Hz and average the measures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RC constant is 500ms. This means that it will require less than a second to pass from a value to a lower one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q5reW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q5reW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here in almost 500ms it will go from 10V to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to reduce the diode effect (9.7V instead of 10V) use a schottky diode. This, however, will not reduce the 9.2V effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should divide by 2 the voltage; you can either&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;divide it before the diode (but then the diode effect will be more evident - you can however correct it in software&lt;/li&gt;&#xA;&lt;li&gt;divide it after the circuit (In this case, replace the 500k resistor with two 250k resistors and take the voltage in the middle)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of course 500k and 250k are not standard values, but you can use any nearby value without affecting the behavior&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-03T10:58:02.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21350" PostTypeId="2" ParentId="21319" CreationDate="2016-03-03T12:05:54.930" Score="2" Body="&lt;p&gt;MarkU provided a pretty thorough answer with all the whys and hows of&#xA;state machines. This is definitely the way to go, and I encourage you to&#xA;read that answer very carefully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a comment to your question where I suggest dropping &lt;code&gt;delay()&lt;/code&gt; in&#xA;order for your loop to never block and your program to be responsive to&#xA;user input. Now I am writing this answer only to show you how to combine&#xA;both ideas, i.e. implement a state machine without delays. I do not&#xA;think this code needs any explanation besides those in &lt;a href=&quot;https://arduino.stackexchange.com/a/21343&quot;&gt;MarkU's&#xA;answer&lt;/a&gt; and in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blink&#xA;without delay&lt;/a&gt;&#xA;Arduino example.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// Pinout.&#xA;const int red = 13, yellow = 12, green = 11, reset = 10;&#xA;&#xA;void setup() {&#xA;    pinMode(red,    OUTPUT);&#xA;    pinMode(yellow, OUTPUT);&#xA;    pinMode(green,  OUTPUT);&#xA;    pinMode(reset,  INPUT_PULLUP);  // use internal pull-up&#xA;}&#xA;&#xA;void loop() {&#xA;    static enum { INIT, RED, RED_AMBER, GREEN, GREEN_AMBER } state = INIT;&#xA;    static uint32_t duration;&#xA;    static uint32_t last_change;&#xA;    uint32_t now = millis();&#xA;&#xA;    // Sense the reset button.&#xA;    if (digitalRead(reset) == LOW)&#xA;        state = INIT;&#xA;&#xA;    // Wait at this state for the specified duration.&#xA;    if (state != INIT &amp;amp;&amp;amp; now - last_change &amp;lt; duration)&#xA;        return;&#xA;&#xA;    // Switch to next state.&#xA;    switch (state) {&#xA;        case INIT:&#xA;        case GREEN_AMBER:&#xA;            state = RED;&#xA;            duration = 3000;&#xA;            digitalWrite(green,  LOW);&#xA;            digitalWrite(yellow, LOW);&#xA;            digitalWrite(red,    HIGH);&#xA;            break;&#xA;        case RED:&#xA;            state = RED_AMBER;&#xA;            duration = 3000;&#xA;            digitalWrite(green,  LOW);&#xA;            digitalWrite(yellow, HIGH);&#xA;            digitalWrite(red,    HIGH);&#xA;            break;&#xA;        case RED_AMBER:&#xA;            state = GREEN;&#xA;            duration = 3000;&#xA;            digitalWrite(green,  HIGH);&#xA;            digitalWrite(yellow, LOW);&#xA;            digitalWrite(red,    LOW);&#xA;            break;&#xA;        case GREEN:&#xA;            state = GREEN_AMBER;&#xA;            duration = 3000;&#xA;            digitalWrite(green,  HIGH);&#xA;            digitalWrite(yellow, HIGH);&#xA;            digitalWrite(red,    LOW);&#xA;            break;&#xA;    }&#xA;    last_change = now;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would normally have declared &lt;code&gt;duration&lt;/code&gt; as a &lt;code&gt;static const&lt;/code&gt;. I kept it&#xA;non-const only to follow MarkU's steps and make it easy to have&#xA;different durations for different states (really, the green light should&#xA;last longer...).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-04T08:30:22.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21351" PostTypeId="2" ParentId="21340" CreationDate="2016-03-03T12:48:49.833" Score="2" Body="&lt;p&gt;There is always brute force. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* itob(int val, char* buf, size_t n)&#xA;{&#xA;  char* bp = buf + n;&#xA;  do {&#xA;    *--bp = (val % 10) + '0';&#xA;    val = val / 10;&#xA;  } while (bp != buf);&#xA;  return (buf);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;&#xA;  const int BUF_MAX = 3;&#xA;  char buf[BUF_MAX];&#xA;&#xA;  Serial.write(itob(42, buf, BUF_MAX));&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please observe that the buffer is not null-terminated, therefore the Serial.write().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Several possible optimizations from the simple solution such as detect when the value is zero and short-cut. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-03T12:48:49.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21352" PostTypeId="1" CreationDate="2016-03-03T13:30:18.657" Score="0" ViewCount="20226" Body="&lt;p&gt;I connect my Bluetooth hc-05. But the blind led in the Bluetooth module is not stable when I connect with my Android phone. Help help me to solve this.&lt;/p&gt;&#xA;" OwnerUserId="18794" LastActivityDate="2019-05-07T10:36:48.363" Title="Can not connect with Bluetooth hc-05" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21353" PostTypeId="1" CreationDate="2016-03-03T14:15:28.423" Score="2" ViewCount="216" Body="&lt;p&gt;I accidentally short-circuited my Arduino mega(ended up connecting the 5V and ground pins). Physically from observation nothing seems to be burnt on the board but I am not able to upload new codes to it again. I am quite sure that the last code I uploaded still run on it because when I plug it in all seems to be normal.&#xA;I tried to upload codes to it with the CP2012 programmer I use for my pro mini and that doesn't help either.&#xA;Is there any way I can manage to upload codes to the board again or it is dead?&lt;/p&gt;&#xA;" OwnerUserId="16790" LastEditorUserId="10214" LastEditDate="2016-03-03T15:24:50.377" LastActivityDate="2016-03-03T15:24:50.377" Title="Is my Arduino mega dead?" Tags="|arduino-mega|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21356" PostTypeId="2" ParentId="21340" CreationDate="2016-03-03T17:48:34.763" Score="3" Body="&lt;p&gt;One straightforward way to do this is to extract digits separately (using integer division and mod).  For example, the hundreds digit of a positive or unsigned &lt;code&gt;int x&lt;/code&gt; is &lt;code&gt;(x/100)%10&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sketch shown below uses the statement &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; b/100 &amp;lt;&amp;lt; (b/10)%10 &amp;lt;&amp;lt; b%10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to print a space and three digits of a positive number, with leading zeroes.  Here are the first 18 lines of output from the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015&#xA; 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031&#xA; 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047&#xA; 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063&#xA; 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079&#xA; 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095&#xA; 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111&#xA; 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127&#xA; 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143&#xA; 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159&#xA; 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175&#xA; 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191&#xA; 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207&#xA; 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223&#xA; 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239&#xA; 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255&#xA; 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015&#xA; 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;//char b=0;    // char is signed; messy when hi bit is on&#xA;byte b=0;    // byte is unsigned, all ok&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  // To emulate&#xA;  //    Serial &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; setw(3) &amp;lt;&amp;lt; setfill('0') &amp;lt;&amp;lt; b;&#xA;  // or&#xA;  //    Serial &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; b&amp;lt;100? '0': '' &amp;lt;&amp;lt; b&amp;lt;10? '0': '' &amp;lt;&amp;lt; b;&#xA;  // write (eg)&#xA;  Serial &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; b/100 &amp;lt;&amp;lt; (b/10)%10 &amp;lt;&amp;lt; b%10;&#xA;  // or if b is an int instead of a byte, write&#xA;  //    Serial &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; (b/100)%10 &amp;lt;&amp;lt; (b/10)%10 &amp;lt;&amp;lt; b%10;&#xA;&#xA;  ++b;&#xA;  if (b%16 == 0) Serial.println();&#xA;  delay(17);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code shown above uses &lt;code&gt;Streaming.h&lt;/code&gt;, a &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;contributed library&lt;/a&gt; that adds some “syntactic sugar” to Arduino C.  That is, at compile time it converts C++-like &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; Serial stream operators to &lt;code&gt;Serial.print&lt;/code&gt; statements, without increasing code size.  If you don't have &lt;code&gt;Streaming.h&lt;/code&gt; installed, either install it via &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow&quot;&gt;arduiniana.org&lt;/a&gt; or manually translate the &lt;code&gt;Serial &amp;lt;&amp;lt; ...&lt;/code&gt; statement to &lt;code&gt;Serial.print&lt;/code&gt; statements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if the &lt;code&gt;Streaming.h&lt;/code&gt; library supported &lt;code&gt;setw()&lt;/code&gt; and &lt;code&gt;setfill()&lt;/code&gt;, they could be used to set field width and fill character.  (See comments in sketch.)  However, the current implementation merely translates the stream insertion operator &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; form into &lt;code&gt;print()&lt;/code&gt; form.  It supports four base-conversion specifiers, _HEX, _DEC, _OCT, and _BIN; a _FLOAT function with number of decimal places specified; and &lt;code&gt;endl&lt;/code&gt;.  Some _FILL functions are suggested at the Arduiniana.org link.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-03T17:48:34.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21357" PostTypeId="2" ParentId="19654" CreationDate="2016-03-03T18:20:41.760" Score="2" Body="&lt;p&gt;Check out &lt;a href=&quot;https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide/example-communication-test&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide/example-communication-test&lt;/a&gt;&#xA;Essentially you need to set up Software Serial for your xbee to communicate on a couple of digital pins, instead of using hardware serial. When using hardware serial (the RX and TX pins) only one device works on it at a time, hence why you can't use the xbee and the serial monitor at the same time. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-03T18:20:41.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21358" PostTypeId="1" CreationDate="2016-03-03T19:56:27.237" Score="2" ViewCount="234" Body="&lt;p&gt;I have the same problem with these two boards: Ruggeduino (Uno compatible) and DFRobot Romeo 1 (Duemilanove compatible). On one of my Macs (a Macbook Pro running 10.11.4), I can see a new port  /dev/cu.usbmodem641 or /dev/a4005g3t depending on the board. On the other computer (a Mac Mini late 2014), they just won't show. Same cable, same boards, and no hub. I don't know where to look to see an indication of a failure of some sort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These two ones use a type-b USB socket (printer style)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also on the Mac Mini that won't see any of those boards, I can connect an EtherMega2560 (Arduino Mega 2560) which happens to use a micro USB socket. I don't know if that is related to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both computers run the same OS (OS X 10.11.4) and the latest version of Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a difference (found in /var/log/system.log):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the working computer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mar  3 22:20:42 pc101 kernel[0]: AppleUSBFTDI: fInBufPool,kMaxInBufPool 8,64 &#xA;Mar  3 22:20:42 pc101 kernel[0]: AppleUSBFTDI: Version number - 5.0.0, Input buffers 8, Output buffers 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the non working one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cfprefsd[114]: BUG in libdispatch: 15E49a - 1718 - 0x0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;..&lt;/p&gt;&#xA;" OwnerUserId="13512" LastEditorUserId="13512" LastEditDate="2016-03-03T22:07:45.607" LastActivityDate="2017-02-15T00:31:28.460" Title="Board won't show on one of my computers" Tags="|serial|usb|osx|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21359" PostTypeId="2" ParentId="21340" CreationDate="2016-03-03T19:59:11.403" Score="0" Body="&lt;p&gt;Thank you all for your suggestions.&#xA;This is what I came up with, which seems to work ok.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char lengthstr[4]=&quot;7&quot;;  &#xA;Serial.print(&quot;lengthstr='&quot;); Serial.print(lengthstr); Serial.println(&quot;'&quot;);&#xA;int maxsize=sizeof(lengthstr);  // size of lengthstr array&#xA;int steps=strlen(lengthstr)+1;  // number of chars to be moved&#xA;int hop=maxsize-steps;          // number of steps to be jumped over each move&#xA;if((steps&amp;gt;1)&amp;amp;&amp;amp;(maxsize&amp;gt;steps)) {  &#xA;   for (int pos=steps; pos &amp;gt;= 0; pos--) {&#xA;      lengthstr[pos+hop] = lengthstr[pos];&#xA;      lengthstr[pos]='0';&#xA;   }&#xA;}&#xA;Serial.print(&quot;lengthstr='&quot;); Serial.print(lengthstr); Serial.println(&quot;'&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16433" LastEditorUserId="7508" LastEditDate="2016-03-04T08:56:36.247" LastActivityDate="2016-03-04T08:56:36.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21360" PostTypeId="2" ParentId="21101" CreationDate="2016-03-03T20:08:28.860" Score="1" Body="&lt;p&gt;After doing more research and getting feedback on the Adafruit forum &lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=8&amp;amp;t=91214&amp;amp;p=459815&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, it appears that the problem was a cracked solder joint.  I managed to get access to the strip and wiggled it a little and the problem has gone away.  The recommendation is to reflow the joint by adding a little solder over the data connection between where the LEDs stop being responsive.&lt;/p&gt;&#xA;" OwnerUserId="15299" LastActivityDate="2016-03-03T20:08:28.860" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21361" PostTypeId="1" AcceptedAnswerId="21754" CreationDate="2016-03-03T20:14:42.397" Score="0" ViewCount="857" Body="&lt;p&gt;I have an Elecrow GPRS shield which I want to use to post temperatures from 3 x DS18B20s to Xively. The example code is a mystery to me. You can find in full at this link: &lt;a href=&quot;http://www.elecrow.com/wiki/index.php?title=GPRS/GSM_Shield_v1.0#A_Simple_Source_Code_Example&quot; rel=&quot;nofollow&quot;&gt;http://www.elecrow.com/wiki/index.php?title=GPRS/GSM_Shield_v1.0#A_Simple_Source_Code_Example&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relevant function is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;///send2Pachube()///&#xA;///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function///&#xA;void Send2Pachube()&#xA;{&#xA;mySerial.println(&quot;AT+CGATT?&quot;);&#xA;delay(100);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CSTT=\&quot;CMNET\&quot;&quot;);//start task and setting the APN,&#xA;delay(1000);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIICR&quot;);//bring up wireless connection&#xA;delay(300);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIFSR&quot;);//get local IP adress&#xA;delay(2000);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIPSPRT=0&quot;);&#xA;delay(3000);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIPSTART=\&quot;tcp\&quot;,\&quot;api.cosm.com\&quot;,\&quot;8081\&quot;&quot;);//start up the connection&#xA;delay(2000);&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIPSEND&quot;);//begin send data to remote server&#xA;delay(4000);&#xA;ShowSerialData();&#xA;String humidity = &quot;1031&quot;;//these 4 line code are imitate the real sensor data, because the demo did't add other sensor, so using 4 string variable to replace.&#xA;String moisture = &quot;1242&quot;;//you can replace these four variable to the real sensor data in your project&#xA;String temperature = &quot;30&quot;;//&#xA;String barometer = &quot;60.56&quot;;//&#xA;mySerial.print(&quot;\&quot;method\&quot;: \&quot;put\&quot;,\&quot;resource\&quot;: \&quot;/feeds/43634/\&quot;,\&quot;params\&quot;&quot;);//here is the feed you apply from pachube&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;: ,\&quot;headers\&quot;: \&quot;X-PachubeApiKey\&quot;:&quot;);//in here, you should replace your pachubeapikey&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot; \&quot;_cXwr5LE8qW4a296O-cDwOUvfddFer5pGmaRigPsiO0&quot;);//pachubeapikey&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;jEB9OjK-W6vej56j9ItaSlIac-hgbQjxExuveD95yc8BttXc&quot;);//pachubeapikey&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;Z7_seZqLVjeCOmNbEXUva45t6FL8AxOcuNSsQS\&quot;,\&quot;body\&quot;:&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot; \&quot;version\&quot;: \&quot;1.0.0\&quot;,\&quot;datastreams\&quot;: &quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;[\&quot;id\&quot;: \&quot;01\&quot;,\&quot;current_value\&quot;: \&quot;&quot; + barometer + &quot;\&quot;,&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;\&quot;id\&quot;: \&quot;02\&quot;,\&quot;current_value\&quot;: \&quot;&quot; + humidity + &quot;\&quot;,&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;\&quot;id\&quot;: \&quot;03\&quot;,\&quot;current_value\&quot;: \&quot;&quot; + moisture + &quot;\&quot;,&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;\&quot;id\&quot;: \&quot;04\&quot;,\&quot;current_value\&quot;: \&quot;&quot; + temperature + &quot;\&quot;],\&quot;token\&quot;: \&quot;lee\&quot;&quot;);&#xA;&#xA;&#xA;delay(500);&#xA;ShowSerialData();&#xA;&#xA;mySerial.println((char)26);//sending&#xA;delay(5000);//waitting for reply, important! the time is base on the condition of internet &#xA;mySerial.println();&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIPCLOSE&quot;);//close the connection&#xA;delay(100);&#xA;ShowSerialData();&#xA;&#xA;}&#xA;void ShowSerialData()&#xA;{&#xA;while(mySerial.available()!=0)&#xA;Serial.write(mySerial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that although this is called &quot;send2Pachube&quot; it uses the Cosm API, which still works. &#xA;The section following the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mySerial.println(&quot;AT+CIPSEND&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is where the HTTP gets formulated. I've assembled the string in the example code and it looks odd. The API key goes on about four times longer than it should. I'm not sure what all those colons are doing in there, are they a String operator? Can anyone give me an example of an HTTP PUT request for Cosm or Xively that illustrates how this string should be assembled?&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="18901" LastActivityDate="2016-03-13T08:54:28.770" Title="What are the components of a Xively HTTP PUT request to send to my SIM800 GPRS module?" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21362" PostTypeId="1" CreationDate="2016-03-03T20:41:55.153" Score="1" ViewCount="51" Body="&lt;p&gt;I've made a home-made Arduino based on &lt;a href=&quot;https://www.youtube.com/watch?v=sNIMCdVOHOM&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt;. The problem is that I can't upload anything, it doesn't react, only the LED double blinks in every second. What does that mean? How to fix it? Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/REGTX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/REGTX.jpg&quot; alt=&quot;photo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18874" LastEditorUserId="18874" LastEditDate="2016-03-03T21:05:04.740" LastActivityDate="2016-03-03T21:17:10.403" Title="Custom built Arduino is not working - double blinks" Tags="|atmega328|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21363" PostTypeId="2" ParentId="21362" CreationDate="2016-03-03T21:17:10.403" Score="1" Body="&lt;p&gt;It's a reasonably clear photo (another couple would help) however I do see at least one major problem. Pin 8 (and pin 22) are Ground, but I don't see any wires running to that. Also the 22 pF (or similar) capacitors connected to the crystal should have their other sides grounded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you look at my page &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Breadboard Arduino&lt;/a&gt; which has clear photos and wiring guides. In particular:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mZ4n8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mZ4n8.jpg&quot; alt=&quot;Minimal Arduino&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the ground wire, and how the capacitors are connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you double-check all wiring, and make sure it is very similar to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pIXMx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pIXMx.png&quot; alt=&quot;Atmega328P wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-03T21:17:10.403" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21364" PostTypeId="1" CreationDate="2016-03-03T21:50:40.667" Score="7" ViewCount="825" Body="&lt;p&gt;I have a microSD connected to an Arduino and I can't program it over ISP without removing the SD card. Does anybody know how to prevent the SD card from interfering with the ISP programming?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the microSD breakout: &lt;a href=&quot;https://www.adafruit.com/products/254&quot; rel=&quot;noreferrer&quot;&gt;https://www.adafruit.com/products/254&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an ATMEGA328P at 3.3V 8MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not using a bootloader and, for several reasons, I can't use the serial port for programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="18935" LastActivityDate="2018-06-03T16:15:13.680" Title="MicroSD interfering with ISP programming" Tags="|isp|arduino-pro-micro|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21365" PostTypeId="1" CreationDate="2016-03-03T21:53:51.010" Score="1" ViewCount="2237" Body="&lt;p&gt;I'm having a problem with my MPU6050. I'm using PID to speed up a motor with the MPU values. What could the problem be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to a previous question that I asked concerning a problem with pid: &lt;a href=&quot;https://arduino.stackexchange.com/questions/20700/pid-not-working-correctly/20703?noredirect=1#comment39146_20703&quot;&gt;PID not working correctly&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the values that I'm getting, which repeat forever. The values are: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;motor speed;&lt;/li&gt;&#xA;&lt;li&gt;the value that changes the motor speed;&lt;/li&gt;&#xA;&lt;li&gt;the MPU value;&lt;/li&gt;&#xA;&lt;li&gt;the change that PID made.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0.00&#xA;0&#xA;10900&#xA;4800&#xA;&#xA;0.00&#xA;0&#xA;10900&#xA;4800&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here is the code itself.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int16_t ax, ay, az;&#xA;&#xA;double Setpoint, Input, Output;&#xA;//Specify the links and initial tuning parameters&#xA;double Kp=2, Ki=5, Kd=1;&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint, Kp,Ki,Kd, DIRECT);&#xA;&#xA;void setup() {&#xA; Input = analogRead(ax);&#xA;  Setpoint = 100;&#xA;  //turn the PID on&#xA;   myPID.SetMode(AUTOMATIC);&#xA;}&#xA;&#xA;void loop() {&#xA; accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az);&#xA;  int a=ax+10900;&#xA;//Here I set the used variable to around 0. ax is actually around -10900&#xA;//This is always true, this won't be in the final code. This is just making        it work.&#xA;&#xA;if(1) {&#xA; int val;&#xA;  val = map(a, -1300, 1300, 0, 1023);&#xA;   Input = val;&#xA;    myPID.Compute();&#xA;     Serial.println(Output);&#xA;&#xA;digitalWrite(motorPin2, HIGH);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.println(ax);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.println(a);&#xA;Serial.print(&quot;\t&quot;);&#xA;Serial.println(val);&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2020-11-21T08:20:06.273" Title="MPU 6050 stuck on same values" Tags="|arduino-uno|motor|mpu6050|pid|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21367" PostTypeId="2" ParentId="21364" CreationDate="2016-03-03T22:03:58.253" Score="3" Body="&lt;p&gt;Because the SD card is an SPI device it shares the same pins as the ISP interface. The only way to not have the SD card interfere with the ISP is to not have the SD card connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you have seen, that can be achieved by removing the card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can also be achieved by adding a tri-state buffer between the MCU and the card so the MCU only connects the card to the SPI bus when it is ready to use it - under default operation the card is disconnected.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-03T22:03:58.253" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21368" PostTypeId="1" AcceptedAnswerId="21373" CreationDate="2016-03-03T22:11:29.410" Score="4" ViewCount="2853" Body="&lt;p&gt;I have a SD card reader that is working fine exept that sometimes SD.begin fails for no apparent reason.&#xA;To work around this issue I have put the SD.begin in a while loop and then I display the error on my LCD. When the error happens I then remove and reinsert the card witch works usualy on the first or second try. I have never seen any problem ones the card is initilized.&#xA;Does anyone has any idea what might be the problem?&lt;/p&gt;&#xA;" OwnerUserId="18894" LastActivityDate="2016-03-04T03:09:51.567" Title="SD card initialization fails randomly" Tags="|sd-card|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21369" PostTypeId="2" ParentId="21365" CreationDate="2016-03-03T22:55:00.627" Score="2" Body="&lt;p&gt;Let's deconstruct this down to a simple example which we can test without the MPU6050:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;PID_v1.h&amp;gt;&#xA;&#xA;double Setpoint, Input, Output;&#xA;//Specify the links and initial tuning parameters&#xA;double Kp = 2, Ki = 5, Kd = 1;&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint, Kp, Ki, Kd, DIRECT);&#xA;&#xA;void setup() {&#xA;  Setpoint = 100;&#xA;  //turn the PID on&#xA;  myPID.SetMode(AUTOMATIC);&#xA;  Serial.begin (115200);&#xA;  Serial.println (F(&quot;\n\nStarting\n\n&quot;));&#xA;}&#xA;&#xA;void loop() {&#xA;  int a = 0;&#xA;  int val = map(a, -1300, 1300, 0, 1023);&#xA;  Input = val;&#xA;  myPID.Compute();&#xA;  Serial.print (F(&quot;Input = &quot;));&#xA;  Serial.println(Input);&#xA;  Serial.print (F(&quot;Setpoint = &quot;));&#xA;  Serial.println(Setpoint);&#xA;  Serial.print (F(&quot;Output = &quot;));&#xA;  Serial.println(Output);&#xA;  Serial.println();&#xA;  delay (300);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Starting&#xA;&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = 0.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = 0.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = 0.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Indeed it isn't changing. Let's analyze why:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The input is 511&lt;/li&gt;&#xA;&lt;li&gt;The setpoint is 100&lt;/li&gt;&#xA;&lt;li&gt;Therefore the error is 100 - 511 = -411&lt;/li&gt;&#xA;&lt;li&gt;Disregarding (for the moment) the integral and differential terms, you have a proportional term of 2 (Kp) so the algorithm tries to output 2 * Error&lt;/li&gt;&#xA;&lt;li&gt;Output would be 2 * -411 = -822&lt;/li&gt;&#xA;&lt;li&gt;However the maximum and minimum limits default to 0 to 255, and thus the output is clamped to 0.&lt;/li&gt;&#xA;&lt;li&gt;The algorithm outputs 0. &lt;/li&gt;&#xA;&lt;li&gt;And the next time it does the same thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is a function &lt;code&gt;SetOutputLimits&lt;/code&gt; which can be used to change the default minimum and maximum output values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Ki and Kd values might eventually have an impact, but you won't notice anything with the output clamped to zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, adding this line in &lt;code&gt;setup&lt;/code&gt; gives different results:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  myPID.SetOutputLimits (-5000, 5000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Result:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Starting&#xA;&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -5000.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -1233.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -1438.50&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -1644.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -1849.50&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -2055.00&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -2260.50&#xA;&#xA;Input = 511.00&#xA;Setpoint = 100.00&#xA;Output = -2466.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whether they are valid limits depend on what you are attempting to do exactly.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-03T22:55:00.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21370" PostTypeId="2" ParentId="21365" CreationDate="2016-03-03T23:30:20.160" Score="1" Body="&lt;p&gt;The problem was that I had the SCL and SDA pins connected to the wrong Arduino pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for bothering your time. Thanks for the tips.&lt;/p&gt;&#xA;" OwnerUserId="14149" LastEditorUserId="6936" LastEditDate="2016-03-04T09:48:04.270" LastActivityDate="2016-03-04T09:48:04.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21371" PostTypeId="1" AcceptedAnswerId="21384" CreationDate="2016-03-04T00:40:41.277" Score="0" ViewCount="628" Body="&lt;p&gt;So, I guess what I'm trying to do here is properly understand the FFT library posted &lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFFT&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; by Open Music Labs, done in C++. I believe I understand the Fourier transform, but the FFT has some nuance that I'm not quite familiar with. From what I understand, the FFT takes a amplitude vs. time signal and transforms it into its constituent frequencies like a normal Fourier transform, but it only does so at given points that break down the signal into the Arduino's clock speed divided by the number of bins decided on, for the sake of efficiency. Thus each bin actually accounts for a number of frequencies that is also equal to the clock speed divided by bin number. I'm correct so far, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here's my question. I have a very specific application of the FFT that requires reading only frequencies at roughly 0-100 Hz. Everything else I don't need, and I want to know how to achieve such high resolution. I imagine that because the number of bins seems to be capped at around 512, that there must be some sort of way to decrease the clock speed to an exorbitantly low number in order to read these frequencies. How might I go about doing that? Or maybe there is a better way to apply the transform to the data at such low frequencies through some other method outside of FFT?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, I'm wondering how performing multiple FFTs simultaneously will affect performance, and if there is some way I can export this data to another program in order to do the heavy lifting regarding data storage, seeing as I imagine performing many FFTs all at once will decimate the available memory on the Arduino itself if all of those values aren't being kept on my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any insight you guys might be able to provide&lt;/p&gt;&#xA;" OwnerUserId="17238" LastActivityDate="2016-03-04T10:26:26.213" Title="Help with a rather specific implementation of FFT Library?" Tags="|programming|c++|library|sound|analog-sampling|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21372" PostTypeId="1" AcceptedAnswerId="21389" CreationDate="2016-03-04T01:34:55.957" Score="6" ViewCount="666" Body="&lt;p&gt;I am interested in teaching young kids how to build arduino projects. I was thinking that using a breadboard may be difficult for them, as the holes are all very close together. It is easy to put the pins in the wrong hole.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any breadboards with larger hole spacings that could make it easier to use for kids?&lt;/p&gt;&#xA;" OwnerUserId="16549" LastActivityDate="2016-03-04T14:35:06.203" Title="Breadboard for kids" Tags="|hardware|mechanical|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21373" PostTypeId="2" ParentId="21368" CreationDate="2016-03-04T03:09:51.567" Score="3" Body="&lt;p&gt;I have seen SD cards that do not like this section of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // command to go idle in SPI mode&#xA;  while (cardCommand(CMD0, 0) != R1_IDLE_STATE) {&#xA;    if (((uint16_t)millis() - t0) &amp;gt; SD_INIT_TIMEOUT) {&#xA;      error(SD_CARD_ERROR_CMD0);&#xA;      goto fail;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Some SD cards (mine, of course) seem to need a little quiet time to finish their INIT process.  Adding a delay of &amp;lt;something&amp;gt; made the INIT process complete successfully, first time through the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm &lt;em&gt;guessing&lt;/em&gt; that the SD card spends so much time handling the repeated CMD0 commands (continuously sent by above loop) that they don't get to spend time on the INIT process.  IIRC, the standard says the card is allowed to take up to 2 seconds to INIT (!).  I can't recall, but I think I tried 150ms or so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // command to go idle in SPI mode&#xA;  while (cardCommand(CMD0, 0) != R1_IDLE_STATE) {&#xA;    delay( 150 ); // let SD get some time to work&#xA;    if (((uint16_t)millis() - t0) &amp;gt; SD_INIT_TIMEOUT) {&#xA;      error(SD_CARD_ERROR_CMD0);&#xA;      goto fail;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do recall that reinserting the card would sometimes make it work.  I have suggested this to at least one SD card library maintainer, but I think we're all reluctant to impose a delay on &lt;em&gt;all&lt;/em&gt; cards.  OTOH, it is just during &lt;code&gt;::begin&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might work for you, though.  The above snippet is from SdSpiCard.cpp, but you may have to go looking for it in other places, depending on which library and version you're using.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-03-04T03:09:51.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21374" PostTypeId="1" AcceptedAnswerId="22800" CreationDate="2016-03-04T03:36:46.763" Score="1" ViewCount="16374" Body="&lt;p&gt;I m working on a project in which I am using HC04 module so can anyone give me any Arduino Library for Proteus which have HC05 in it. Or tell me how to use HC05 in Proteus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2017-03-18T06:13:20.520" Title="Bluetooth HC-05 Library for Proteus" Tags="|programming|" AnswerCount="3" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21375" PostTypeId="2" ParentId="21372" CreationDate="2016-03-04T03:41:01.293" Score="6" Body="&lt;p&gt;Breadboards are made to work with components of a standard size - a breadboard with larger hole spacing would not be able to fit standard through-hole chips. I have never seen such an item.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, I have had a lot of success using alligator clips. You can clip them directly on to wires for LEDs, resistors, capacitors, so long as you make sure they legs/clips don't touch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there are made-for-children systems, snap-together, like &lt;a href=&quot;http://www.vk3bq.com/2013/08/17/snap-circuits-electronics-kits/&quot;&gt;http://www.vk3bq.com/2013/08/17/snap-circuits-electronics-kits/&lt;/a&gt; or &lt;a href=&quot;http://mashable.com/2013/05/21/lightup-magnetic-building-blocks/#t5Kq_yIDpaqr&quot;&gt;http://mashable.com/2013/05/21/lightup-magnetic-building-blocks/#t5Kq_yIDpaqr&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-04T03:41:01.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21376" PostTypeId="1" CreationDate="2016-03-04T03:45:59.210" Score="4" ViewCount="55363" Body="&lt;p&gt;I'm getting a &lt;code&gt;&quot;'Serial' does not name a type&quot;&lt;/code&gt; error when this program is compiled. I need for the 8 channels of voltage to be displayed. I'm sure it's a simple fix, however I'm still learning Arduino programming. I thank you for your help. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin_Out_S0 = 8;&#xA;int pin_Out_S1 = 9;&#xA;int pin_Out_S2 = 10;&#xA;int pin_In_Mux1 = A0;&#xA;int Mux1_State[8] = {0};&#xA;//float Mux1_State[i] =0;&#xA;int RawValue=0;&#xA;float Voltage = 0;&#xA;void setup() {&#xA;  pinMode(pin_Out_S0, OUTPUT);&#xA;  pinMode(pin_Out_S1, OUTPUT);&#xA;  pinMode(pin_Out_S2, OUTPUT);&#xA;  pinMode(pin_In_Mux1, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA; RawValue = analogRead(pin_In_Mux1);&#xA; Voltage = (RawValue * 5.0) / 1024; //scale the ADC&#xA;  updateMux1();&#xA;  //Serial.println(Mux1_State);&#xA;  for(int i = 0; i &amp;lt; 8; i ++) {&#xA;    if(i == 7) {&#xA;      Serial.println(Mux1_State[i]);&#xA;    } else {&#xA;      Serial.print(Mux1_State[i]);&#xA;      Serial.print(&quot;,&quot;);&#xA;      //vout = (value * 5.0) / 1024.0;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void updateMux1 () {&#xA;  for (int i = 0; i &amp;lt; 8; i++){&#xA;    digitalWrite(pin_Out_S0, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000001));&#xA;    digitalWrite(pin_Out_S1, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000010));&#xA;    digitalWrite(pin_Out_S2, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000100));&#xA;    Mux1_State[i] = analogRead(pin_In_Mux1);&#xA;  }&#xA;}&#xA;Serial.print(&quot;Raw  Value = &quot; );&#xA;Serial.print(RawValue); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" OwnerDisplayName="Tom Evans" LastEditorUserId="16988" LastEditDate="2016-03-04T07:14:06.273" LastActivityDate="2018-08-24T17:10:46.393" Title="&quot;'Serial' does not name a type&quot; error" Tags="|serial|programming|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21377" PostTypeId="2" ParentId="21376" CreationDate="2016-03-04T04:01:52.480" Score="10" Body="&lt;p&gt;Your last two lines are not in any function. This confuses the compiler. You need to move those two statements inside a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because those statements refer to &lt;code&gt;RawValue&lt;/code&gt;, I'm guessing you want to put them in &lt;code&gt;loop()&lt;/code&gt;, where RawValue is being updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, remember that the IDE will tell you on which line the error is, which is helpful when debugging compilation errors.&lt;/p&gt;&#xA;" OwnerUserId="16988" OwnerDisplayName="uint128_t" LastActivityDate="2016-03-04T04:01:52.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21379" PostTypeId="2" ParentId="21374" CreationDate="2016-03-04T06:43:51.320" Score="1" Body="&lt;p&gt;I don't know Proteus, but I think HC05 a bluetooth module? If so, the module interface from HC05 &amp;lt;==&gt; arduino is done through Serial (UART) communication. &#xA;Arduino has built in support for this - you don't need any special libraries besides SoftwareSerial.&#xA;wire up the module as such:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lxRbc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lxRbc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then run the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define rxPin 10 // connected to TX pin of HC05&#xA;#define txPin 11 // connected to RX pin of HC05&#xA;&#xA;SoftwareSerial mySerial(rxPin, txPin); // RX, TX&#xA;char bt; &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);   &#xA;  Serial.println(&quot;Hello&quot;);&#xA;&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;World&quot;);&#xA;}&#xA;&#xA;void loop(){&#xA;  while(mySerial.available()){&#xA;    bt = mySerial.read();&#xA;    Serial.print(bt);&#xA;  }&#xA;&#xA;  while(Serial.available()){&#xA;   bt= Serial.read();&#xA;   mySerial.print(bt);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11492" LastActivityDate="2016-03-04T06:43:51.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21380" PostTypeId="2" ParentId="21352" CreationDate="2016-03-04T06:50:33.333" Score="0" Body="&lt;p&gt;Through which android app you are connecting because normally android only pair and will connect to device if you are sharing some data or files or you can connect to android device using any bluetooth app like bluetooth terminal or dual bluetooth chat&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-03-04T06:50:33.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21381" PostTypeId="2" ParentId="21372" CreationDate="2016-03-04T08:43:36.517" Score="3" Body="&lt;p&gt;Build your own breadboard!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Literally, a wooden board with a grid of small woodscrews screwed into it, each screw holding down a cup washer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections are made by trapping component leads and wires under the edge of the cup washer before screwing it down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need components with reasonably long leads, and it might still be necessary to solder longer wires to the leads in some cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am told that in the olde days, this is how hobbyists used to do it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a link to an example (I read a copy of this book as a kid):&#xA;&lt;a href=&quot;http://www.mds975.co.uk/Content/george_dobbs_trf_radio.html&quot; rel=&quot;nofollow&quot;&gt;http://www.mds975.co.uk/Content/george_dobbs_trf_radio.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10135" LastEditorUserId="10135" LastEditDate="2016-03-04T08:54:14.563" LastActivityDate="2016-03-04T08:54:14.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21382" PostTypeId="2" ParentId="21319" CreationDate="2016-03-04T08:58:37.410" Score="0" Body="&lt;p&gt;The best way to handle this problem is using a state machine, as shown in all the other answers. In fact, this IS the classical problem to learn how to use and implement state machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just wanted to add the &quot;fast&quot; solution to your problem, which will enable you to do what you want without changing your code too much:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void changeLights(){&#xA;    unsigned long startTime;&#xA;&#xA;    // red on, other off for 3 seconds&#xA;    digitalWrite(green,LOW); &#xA;    digitalWrite(yellow,LOW);&#xA;    digitalWrite(red,HIGH); &#xA;    startTime = millis();&#xA;    while ((millis() - startTime) &amp;lt; 3000)&#xA;    { // Wait for 3 seconds while checking for the button&#xA;        if (digitalRead(buttonPin) == HIGH)&#xA;            return; // Just exit this function; the loop will start again&#xA;    }&#xA;&#xA;    [ repeat for the other colors ]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-04T08:58:37.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21384" PostTypeId="2" ParentId="21371" CreationDate="2016-03-04T10:26:26.213" Score="2" Body="&lt;p&gt;As Edgar has mentioned you are confusing things slightly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First there is your sampling frequency. According to the Shannon-Nyquist theorem that is at a minimum of 2x the maximum frequency in your signal. So that is 2x100 = 200Hz. That's the number of samples per second in your sample set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly is your sample size, which is directly related to the FFT bucket size. For every two samples you can get one bucket. The more samples you have the more buckets you have, and the higher the resolution each bucket is. But for FFT to work you need a power-of-two sized sample set. That means 2, 4, 8, 16 etc samples.  So 256 samples would give you 128 buckets. That would be a little under 1Hz per bucket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make things cleaner though you can back-apply the last calculation to the first and get them to match. 256 samples at 256 samples per second will give you 128 buckets covering 0-128Hz so 1Hz per bucket.  Double that to 512 samples and you get 256 buckets at 0.5Hz per bucket. Double it again and you get double the resolution again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main speed issue that you will come across is not the time taken to do the FFT, but the time taken to capture your sample set. 256 samples at 256 samples per secod will, of course, take 1 second to capture. 512 samples will be 2 seconds, etc. Far longer than a decent FFT takes to calculate.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-04T10:26:26.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21385" PostTypeId="1" CreationDate="2016-03-04T10:59:16.683" Score="1" ViewCount="5762" Body="&lt;p&gt;I want to connect a Bluetooth module to arduino and check if my module is connected or not.. Through serial monitor. Is there and particular code to connect with that?&lt;/p&gt;&#xA;" OwnerUserId="18794" LastActivityDate="2016-09-02T23:49:36.230" Title="How to know if my Bluetooth HC-05 is connected through serial monitor" Tags="|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21386" PostTypeId="2" ParentId="4530" CreationDate="2016-03-04T11:02:35.990" Score="0" Body="&lt;p&gt;The important parts are the &lt;code&gt;GPS.end()&lt;/code&gt; which removes the interrupt routine and effectively stops listening to input although the data continues and the &lt;code&gt;GPS.begin(baud)&lt;/code&gt; which reinstates the interrupt routine.  The other statements are program specific and could be anything that you want to do while the input data processing is off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using it on a project where I smooth scroll time/date on an LED matrix but the SoftwareSerial interrupt routine makes the scrolling jerky.  I have reduced the NMEA sentences to just one but it still takes a noticeable amount of time to process it.  So the GPS is always on and sending but I only listen 4 times per hour by doing an &lt;code&gt;ss.begin()&lt;/code&gt; for 5 second (or until valid data), save it then do the &lt;code&gt;ss.end()&lt;/code&gt;.  Problem solved.  I get mildly jerky scrolling for 5 seconds but it is rarely noticed and my time is always right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will post the routine on my web site, &lt;a href=&quot;http://www.iliketheinternet.com/&quot; rel=&quot;nofollow&quot;&gt;ILikeTheInternet.com&lt;/a&gt;, in a few days.&lt;/p&gt;&#xA;" OwnerUserId="18945" LastEditorUserId="6936" LastEditDate="2016-03-04T13:27:05.733" LastActivityDate="2016-03-04T13:27:05.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21388" PostTypeId="2" ParentId="21385" CreationDate="2016-03-04T11:25:22.623" Score="1" Body="&lt;p&gt;If your board is actually a HC-05, you can&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pull the KEY pin to Vcc (see note)&lt;/li&gt;&#xA;&lt;li&gt;Write the serial command &lt;code&gt;AT&lt;/code&gt; on the serial interface&lt;/li&gt;&#xA;&lt;li&gt;Look at the output: if you receive &lt;code&gt;AT&lt;/code&gt; or &lt;code&gt;OK&lt;/code&gt; then the module is connected, otherwise it is not&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note: The key pin is the number 34 on the SMT module (with the antenna pointing upwards, its the pin in the top-right corner). If you have a THT module (so the one with about 6 pins) MAYBE this pin is connected to one of the pins you don't usually use (they are named EN, STATE, ...). Check with a multimeter if it is connected to one of these. If it is not, then you'll have to solder a wire from it to an arduino pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, on the other hand, your board is a HC-06 (almost identical to HC-05, but with a different firmware - it is a slave-only bt device), then keep it disconnected from the master and perform steps 2 and 3: when not connected, in fact, the HC-06 is already in AT mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More information on &lt;a href=&quot;http://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this webpage&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-04T11:25:22.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21389" PostTypeId="2" ParentId="21372" CreationDate="2016-03-04T12:30:53.627" Score="4" Body="&lt;p&gt;The problem (probably) isn't only because it's too small, wiring can be hard to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this might be a solution:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/d8law.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/d8law.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'll cost you some work. But it will get difficult for them to wire it wrongly.&#xA;Also, I believe coloring them, will make the kids understand it much better. This way they would also be less likely to short out pins etc. Saving you some rangers/arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure that the power-connectors are not reversible. And you should use a separated supply (with overcurrent protection and what not) and tie the GND to the arduino GND. This way you could even use the supply power for heavier devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not a 100% sure on the resistors though, they might interfere with some things you want to make/show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe even add blue color for inputs and yellow for outputs (or whatever the standard is). Or you might even make generic connectors, like on the Lego NXT robots, that's some really easy wiring! &lt;a href=&quot;http://www.philohome.com/nxtldraw/NXTkitLDview.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.philohome.com/nxtldraw/NXTkitLDview.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or check out projects like: &quot;LittleBits Arduino&quot;.&#xA;&lt;a href=&quot;https://s3.amazonaws.com/lb-spree/spree/products/2003/large/ArduinoDetail4.png?1423167488&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://s3.amazonaws.com/lb-spree/spree/products/2003/large/ArduinoDetail4.png?1423167488&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, check &lt;a href=&quot;http://www.rugged-circuits.com/ruggeduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.rugged-circuits.com/ruggeduino/&lt;/a&gt; on 10-ways to destroy your arduino. If you take these things into mind, you can make a pretty solid Arduino, so that wrong wiring won't lead to any damaged Arduino's etc.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-03-04T12:36:13.660" LastActivityDate="2016-03-04T12:36:13.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21391" PostTypeId="1" AcceptedAnswerId="21396" CreationDate="2016-03-04T13:55:45.070" Score="1" ViewCount="14786" Body="&lt;p&gt;Can anyone explain how things like strtok() and strstr() can be used to provide a numeric value for a substring location position within the mainstring array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to understand from the C++ examples, but their 'position' locations of the substring within the mainstring (which I need) are returned in C++ as %d variables, whereas all I can get returned by the arduino 'char * pointer=' is the actual substring chars if they exist, rather than a number for their start position locations within the mainstring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The C++ examples show that it is possible to discover the position values from %d,  but how can I get that equivalent position value in arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to parse a char header[30] array for occurances of things like &quot;s=123&quot; and &quot;d=789&quot; in order to extract and assign the specified values to any appropriate variables (source or destination etc).&lt;/p&gt;&#xA;" OwnerUserId="16433" LastActivityDate="2016-03-05T00:39:56.613" Title="How to use strtok() and strstr() with arduino?" Tags="|programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21393" PostTypeId="1" AcceptedAnswerId="21528" CreationDate="2016-03-04T14:16:49.323" Score="1" ViewCount="355" Body="&lt;p&gt;Good day everyone,&#xA;I'm returning to the Arduino world after my a 3 year hiatus following the birth of my son.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to push a button connected to pin 2 and have that send a 'd' to SoftwareSerial on pins 10,11. This should trigger an output back from the device connected to the SoftwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm encountering an issue:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I press the button it sends about 15 d's. I would like to limit this to just one char per button press, I attempted to build an if statement but it seems to ignore the conditions.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// software serial #1: TX = digital pin 10, RX = digital pin 11&#xA;SoftwareSerial portOne(10, 11);&#xA;const int buttonPin = 2;     // the number of the pushbutton pin&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;int button1State = 0;&#xA;&#xA;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;// initialize digital pin 13 as an output.&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // Start each software serial port&#xA;  portOne.begin(4800);&#xA;  while (!portOne) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  int Once = 0;&#xA;  buttonState = digitalRead(buttonPin);&#xA;&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (buttonState == HIGH ) { &#xA;    if (Once == 0) {&#xA;      Once = 1;&#xA;      // turn LED on:&#xA;      digitalWrite(ledPin, HIGH);&#xA;      // send D to Radio&#xA;      portOne.write(&quot;d&quot;);&#xA;      Serial.write(&quot;d&quot;);&#xA;      Serial.print(Once);&#xA;      Serial.println();&#xA;      delay(1);&#xA;    }&#xA;  }&#xA;  else (buttonState == LOW) {&#xA;    // turn LED off:&#xA;    Once = 0;&#xA;&#xA;    digitalWrite(ledPin, LOW);&#xA;&#xA;  }&#xA;  portOne.listen();&#xA;  // while there is data coming in, read it&#xA;  // and send to the hardware serial port:&#xA;  while (portOne.available() &amp;gt; 0) {&#xA;    char inByte = portOne.read();&#xA;    Serial.print(inByte);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18948" LastEditorUserId="7508" LastEditDate="2016-03-04T16:48:38.577" LastActivityDate="2016-03-07T14:27:31.317" Title="Trying to pass a char to software serial with a button press" Tags="|softwareserial|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21394" PostTypeId="2" ParentId="21372" CreationDate="2016-03-04T14:35:06.203" Score="4" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Fqs65.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fqs65.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1H0Os.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1H0Os.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe use something like &lt;a href=&quot;http://littlebits.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Littlebits&lt;/a&gt;, which uses magnets, but is kind of expensive.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-04T14:35:06.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21396" PostTypeId="2" ParentId="21391" CreationDate="2016-03-04T16:13:22.253" Score="1" Body="&lt;p&gt;You have to define a format for the header you will be parsing and stick to that format. Say this is a sample &lt;code&gt;header&lt;/code&gt; terminated by null:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s=123 d=789 e=463&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A common property of each assignment in the string is the '=' symbol. You can use that to locate each variable and the value assigned to it. &lt;code&gt;strchr&lt;/code&gt; is the function to use to locate a single character. Once you locate the = character, you move back and then forward along the array to obtain the variable and its value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will make some assumptions here: that your variable names will be single character, that numbers assigned will be no bigger than ints, and a space character is used to separate assignments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char header[] = &quot;s=123 d=789 e=463&quot;;&#xA;&#xA;int d, s, e;   //your variables to be assigned to&#xA;char * ptr = header;&#xA;char * eq = NULL; //locate assmts&#xA;int * num = NULL; //just for starters&#xA;while (1){&#xA;  eq = strchr(ptr, '=');&#xA;  ptr = eq; // update the pointer&#xA;  if (ptr == NULL) // found no = chars&#xA;    break;&#xA;  switch (*(ptr - 1)){ &#xA;    case 'd':    //all the possible variables&#xA;      num = &amp;amp;d; break;&#xA;    case 's': &#xA;      num = &amp;amp;s; break;&#xA;    case 'e': &#xA;      num = &amp;amp;e; break;&#xA;    default:   //unknown variable&#xA;      num = NULL;&#xA;  }&#xA;  ptr++;&#xA;  if (num == NULL) //unrecognized var&#xA;    continue;   // locate next = char&#xA;  *num = 0;&#xA;  while (*ptr &amp;amp;&amp;amp; (*ptr != ' ')){  // while space or end of string not yet reached&#xA;    *num *= 10;  // extract each int&#xA;    *num += *ptr - '0';&#xA;    ptr++;&#xA;  }&#xA;}&#xA;&#xA;Serial.println(d);  //now contains the numbers in the header&#xA;Serial.println(s);&#xA;Serial.println(e);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Untested but it should work for the header sample I gave.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-05T00:39:56.613" LastActivityDate="2016-03-05T00:39:56.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21397" PostTypeId="2" ParentId="21393" CreationDate="2016-03-04T16:54:21.157" Score="4" Body="&lt;p&gt;As pointed out by Edgar you should debounce the button. Perhaps increasing the delay() should do the trick. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try with 100-200 milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this edit you can delete Once unless you are planning on using it somewhere else. &lt;/p&gt;&#xA;" OwnerUserId="11152" LastEditorUserId="11152" LastEditDate="2016-03-04T16:59:53.143" LastActivityDate="2016-03-04T16:59:53.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21398" PostTypeId="1" CreationDate="2016-03-04T17:10:14.527" Score="2" ViewCount="1046" Body="&lt;p&gt;I'm trying to send heximal values from arduino to PZEM-04 power module (it shows voltage, current and ect.) over serial communication in heximal format and get values in decimal format for further actions with them. Any help with the code please? &#xA;One of the commands: &#xA;Send command: B4 C0 A8 01 01 00 1E&#xA;Reply data: A4 00 00 00 00 00 A4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I am connecting wires from PZEM module TTL to arduino &quot;serial port&quot;: TX-RX, RX-TX, VCC-VCC, GND-GND, so it's serial communication.. &#xA;    PZEM module: &lt;a href=&quot;http://www.aliexpress.com/store/product/PEACEFAIR-AC-100A-Electric-power-monitoring-and-communication-module-power-meter-power-energy-Volt-Ammeter/1773456_32373508101.html&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/store/product/PEACEFAIR-AC-100A-Electric-power-monitoring-and-communication-module-power-meter-power-energy-Volt-Ammeter/1773456_32373508101.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18951" LastEditorUserId="18951" LastEditDate="2016-03-04T18:00:11.837" LastActivityDate="2016-06-20T10:16:05.090" Title="Arduino serial hex decimal values code" Tags="|serial|uart|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21399" PostTypeId="1" AcceptedAnswerId="21400" CreationDate="2016-03-04T19:09:39.963" Score="0" ViewCount="1211" Body="&lt;p&gt;I have a project that I am putting an Arduino Nano in an enclosed box that will light LEDs in a pattern. I am planning to power it with a 5 V power brick but I would like to build a way a update the code to the Arduino without needing to disassemble the box. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I use an OTG cable with power (OTG Y cable)  to accomplish this? or is there a better way to do this? &lt;/p&gt;&#xA;" OwnerUserId="18954" LastEditorUserId="6936" LastEditDate="2016-04-22T09:52:22.460" LastActivityDate="2016-04-22T09:52:22.460" Title="Power Arduino Nano with OTG cable" Tags="|power|usb|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21400" PostTypeId="2" ParentId="21399" CreationDate="2016-03-04T19:27:12.010" Score="0" Body="&lt;p&gt;It is possible to use a OTG Y cable just plug it into your phone, power cable into the power source and use the third connector to connect  to your PC. (Assuming the PC only gets GND, D+ and D- and battery bank GND, 5V) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to reprogram an Arduino with an Android device that has OTG support.&#xA;Would save you a bit of hassle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Android phone (LG D605) with &lt;a href=&quot;https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid2&quot; rel=&quot;nofollow&quot;&gt;ArduinoDroid&lt;/a&gt; can easily upload code to my Nano and Uno.&lt;/p&gt;&#xA;" OwnerUserId="11529" LastEditorUserId="11529" LastEditDate="2016-03-05T06:57:52.043" LastActivityDate="2016-03-05T06:57:52.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21401" PostTypeId="1" CreationDate="2016-03-04T19:36:03.163" Score="1" ViewCount="1113" Body="&lt;p&gt;I'm curious about what some of my code is being compiled into, is there a way to have the compiler save the intermediate assembly files, ideally somewhere in the project folder?  I read some forum posts about holding down shift when compiling from the Arduino IDE, but even that seems pretty hackish.&lt;/p&gt;&#xA;" OwnerUserId="16253" LastActivityDate="2016-03-04T21:14:13.883" Title="See compiled assembly output (Visual Micro)" Tags="|build|visualstudio|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21402" PostTypeId="1" AcceptedAnswerId="21610" CreationDate="2016-03-04T20:07:57.117" Score="1" ViewCount="665" Body="&lt;p&gt;I have my arduino connected to my PC and another serial device.&#xA;This serial device sends a 3 line piece of info on bootup then if I trip a zone it will send information regarding the radio transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I first power up the device I see the information from the device in the serial monitor (SELFTEST-PASS) however that is the last information I receive from it until I powercycle the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected it directly to my PC comport and verified information is being sent via Serial however the arduino seems to quit after the first bit of info... any idea where to proceed from here?&#xA;PS I have tried both SoftwareSerial and NewSoftSerial&lt;br&gt;&#xA;Here is an example of the data sent from the serial device as viewed by hyperterminal:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;1234 #3F-&amp;gt;0000 1234-&amp;gt;FFFF D_ALARM&amp;gt;&#xA;&amp;lt;FFFF #3F-&amp;gt;1234 FFFF-&amp;gt;1234 P_ACK&amp;gt;&#xA;&amp;lt;1234 #40-&amp;gt;0000 1234-&amp;gt;FFFF D_ZREST&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code that is currently not working:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;AltSoftSerial.h&amp;gt;&#xA; AltSoftSerial portOne;&#xA;&#xA;void setup() {&#xA;&#xA;&#xA;                Serial.begin(4800);&#xA;                while (!Serial) {; // wait for serial port to connect. Needed for native USB port only&#xA;                }&#xA;                // Start each software serial port&#xA;                portOne.begin(4800);&#xA;&#xA;              }&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() &#xA;{&#xA;  if (portOne.available())&#xA;  {&#xA;    Serial.write(portOne.read());&#xA;  }&#xA;&#xA;  if (Serial.available())&#xA;  {&#xA;    portOne.write(Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18948" LastEditorUserId="10794" LastEditDate="2016-03-04T22:42:26.000" LastActivityDate="2016-03-09T13:15:42.327" Title="Issues with AltSoftSerial" Tags="|serial|softwareserial|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21403" PostTypeId="2" ParentId="21401" CreationDate="2016-03-04T21:14:13.883" Score="2" Body="&lt;p&gt;Turn on Verbose Compiling in the Arduino IDE and you will see all the intermediate file names (they are done in a temporary folder).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/nick/Development/arduino-1.6.7/arduino-builder -dump-prefs -logger=machine -hardware &quot;/home/nick/Development/arduino-1.6.7/hardware&quot; -hardware &quot;/home/nick/.arduino15/packages&quot; -hardware &quot;/home/nick/Arduino/hardware&quot; -tools &quot;/home/nick/Development/arduino-1.6.7/tools-builder&quot; -tools &quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr&quot; -tools &quot;/home/nick/.arduino15/packages&quot; -built-in-libraries &quot;/home/nick/Development/arduino-1.6.7/libraries&quot; -libraries &quot;/home/nick/Arduino/libraries&quot; -fqbn=arduino:avr:uno -ide-version=10607 -build-path &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp&quot; -warnings=default -prefs=build.warn_data_percentage=75 -verbose &quot;/tmp/arduino_1cdca0d02fcf3112936d1438c170697d/sketch_mar03b.ino&quot;&#xA;/home/nick/Development/arduino-1.6.7/arduino-builder -compile -logger=machine -hardware &quot;/home/nick/Development/arduino-1.6.7/hardware&quot; -hardware &quot;/home/nick/.arduino15/packages&quot; -hardware &quot;/home/nick/Arduino/hardware&quot; -tools &quot;/home/nick/Development/arduino-1.6.7/tools-builder&quot; -tools &quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr&quot; -tools &quot;/home/nick/.arduino15/packages&quot; -built-in-libraries &quot;/home/nick/Development/arduino-1.6.7/libraries&quot; -libraries &quot;/home/nick/Arduino/libraries&quot; -fqbn=arduino:avr:uno -ide-version=10607 -build-path &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp&quot; -warnings=default -prefs=build.warn_data_percentage=75 -verbose &quot;/tmp/arduino_1cdca0d02fcf3112936d1438c170697d/sketch_mar03b.ino&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-g++&quot; -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/cores/arduino&quot; &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/variants/standard&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch/sketch_mar03b.ino.cpp&quot; -o &quot;/dev/null&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-g++&quot; -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/cores/arduino&quot; &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/variants/standard&quot; &quot;-I/home/nick/Arduino/libraries/PID_v1&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch/sketch_mar03b.ino.cpp&quot; -o &quot;/dev/null&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-g++&quot; -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/cores/arduino&quot; &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/variants/standard&quot; &quot;-I/home/nick/Arduino/libraries/PID_v1&quot; &quot;/home/nick/Arduino/libraries/PID_v1/PID_v1.cpp&quot; -o &quot;/dev/null&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-g++&quot; -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/cores/arduino&quot; &quot;-I/home/nick/Development/arduino-1.6.7/hardware/arduino/avr/variants/standard&quot; &quot;-I/home/nick/Arduino/libraries/PID_v1&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch/sketch_mar03b.ino.cpp&quot; -o &quot;/dev/null&quot;&#xA;...&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-ar&quot; rcs  &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/core/core.a&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/core/main.cpp.o&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-ar&quot; rcs  &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/core/core.a&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/core/new.cpp.o&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-gcc&quot;  -Os -Wl,--gc-sections -mmcu=atmega328p  -o &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch_mar03b.ino.elf&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch/sketch_mar03b.ino.cpp.o&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/libraries/PID_v1/PID_v1.cpp.o&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/core/core.a&quot; &quot;-L/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp&quot; -lm&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-objcopy&quot; -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0  &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch_mar03b.ino.elf&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch_mar03b.ino.eep&quot;&#xA;&quot;/home/nick/Development/arduino-1.6.7/hardware/tools/avr/bin/avr-objcopy&quot; -O ihex -R .eeprom  &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch_mar03b.ino.elf&quot; &quot;/tmp/build1cdca0d02fcf3112936d1438c170697d.tmp/sketch_mar03b.ino.hex&quot;&#xA;Using library PID_v1 in folder: /home/nick/Arduino/libraries/PID_v1 (legacy)&#xA;&#xA;Sketch uses 6,484 bytes (20%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 285 bytes (13%) of dynamic memory, leaving 1,763 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Of interest are the last couple - the &lt;code&gt;xxx.elf&lt;/code&gt; file and the &lt;code&gt;xxx.hex&lt;/code&gt; file (where xxx is your sketch name).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;xxx.hex&lt;/code&gt; file is what is uploaded to your Arduino (well, it is decoded by Avrdude).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;xxx.elf&lt;/code&gt; file can be used to get assembly output, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -Sz xxx.elf &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That outputs to the screen. I usually output to a file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -Sz xxx.elf &amp;gt; /tmp/avr_dump.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;      ec:   0f 93           push    r16&#xA;      ee:   1f 93           push    r17&#xA;  Setpoint = 100;&#xA;      f0:   80 e0           ldi r24, 0x00   ; 0&#xA;      f2:   90 e0           ldi r25, 0x00   ; 0&#xA;      f4:   a8 ec           ldi r26, 0xC8   ; 200&#xA;      f6:   b2 e4           ldi r27, 0x42   ; 66&#xA;      f8:   80 93 73 01     sts 0x0173, r24&#xA;      fc:   90 93 74 01     sts 0x0174, r25&#xA;     100:   a0 93 75 01     sts 0x0175, r26&#xA;     104:   b0 93 76 01     sts 0x0176, r27&#xA;  //turn the PID on&#xA;  myPID.SetMode(AUTOMATIC);&#xA;     108:   61 e0           ldi r22, 0x01   ; 1&#xA;     10a:   70 e0           ldi r23, 0x00   ; 0&#xA;     10c:   82 e3           ldi r24, 0x32   ; 50&#xA;     10e:   91 e0           ldi r25, 0x01   ; 1&#xA;     110:   0e 94 04 04     call    0x808   ; 0x808 &amp;lt;_ZN3PID7SetModeEi&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this particular  case &lt;code&gt;Setpoint&lt;/code&gt; was a double so it took 8 instructions to load a literal into it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-04T21:14:13.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21404" PostTypeId="2" ParentId="21398" CreationDate="2016-03-04T21:23:09.907" Score="2" Body="&lt;p&gt;A possible implementation of the protocol using serial read/write of binary data (command and response).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void send(Stream&amp;amp; ios, uint8_t cmd[6])&#xA;{&#xA;  uint8_t sum = 0;&#xA;  for (int i = 0; i &amp;lt; 6; i++) {&#xA;    uint8_t c = cmd[i];&#xA;    sum += c;&#xA;    ios.print((char) c);&#xA;  }&#xA;  ios.print((char) sum);&#xA;}&#xA;&#xA;bool recv(Stream&amp;amp; ios, uint8_t res[6])&#xA;{&#xA;  uint8_t sum = 0;&#xA;  uint8_t c;&#xA;  for (int i = 0; i &amp;lt; 6; i++) {&#xA;    while (!ios.available());&#xA;    c = ios.read();&#xA;    sum += c;&#xA;    res[i] = c;&#xA;  }&#xA;  while (!ios.available());&#xA;  c = ios.read();&#xA;  return (sum == c);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  while (!Serial);&#xA;&#xA;  uint8_t cmd[] = { 0xB4, 0xC0, 0xA8, 0x01, 0x01, 0x00 };&#xA;  uint8_t res[6];&#xA;  send(Serial, cmd);&#xA;  recv(Serial, res);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-03-05T15:33:17.307" LastActivityDate="2016-03-05T15:33:17.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21405" PostTypeId="2" ParentId="21376" CreationDate="2016-03-04T21:27:32.333" Score="1" Body="&lt;p&gt;Please put these lines inside the loop() function block:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Raw  Value = &quot; );&#xA;Serial.print(RawValue); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should look something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA; RawValue = analogRead(pin_In_Mux1);&#xA; Voltage = (RawValue * 5.0) / 1024; //scale the ADC&#xA;  updateMux1();&#xA;  //Serial.println(Mux1_State);&#xA;  for(int i = 0; i &amp;lt; 8; i ++) {&#xA;    if(i == 7) {&#xA;      Serial.println(Mux1_State[i]);&#xA;    } else {&#xA;      Serial.print(Mux1_State[i]);&#xA;      Serial.print(&quot;,&quot;);&#xA;      //vout = (value * 5.0) / 1024.0;&#xA;    }&#xA;  }&#xA;  Serial.print(&quot;Raw  Value = &quot; );&#xA;  Serial.print(RawValue); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should at least remove the first issue with your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-04T21:27:32.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21406" PostTypeId="1" AcceptedAnswerId="21407" CreationDate="2016-03-04T21:34:10.347" Score="3" ViewCount="135" Body="&lt;p&gt;I had a problem in a program where the result of product is not what it's supposed to be. For example: 775*775 gives 10801 instead of 6006025.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To try to isolate and resolve the problem, I made a simple sketch to test the result of different products. What I found is that if I do the same product in this way: 775/100.00*775/100.00 then multiply the result by 10000 I get the right value: 600625.00&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The attached pictures illustrate what I said.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I can use this solution in my initial program by I still want to do the multiplication directly as more operations means more time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate any help. Thank you.&lt;a href=&quot;https://i.stack.imgur.com/IJbFY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IJbFY.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I8zD8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I8zD8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18958" LastActivityDate="2016-03-04T21:37:06.590" Title="Why is the result of this product operation wrong?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21407" PostTypeId="2" ParentId="21406" CreationDate="2016-03-04T21:37:06.590" Score="6" Body="&lt;p&gt;Integer overflow. You're multiplying an &lt;code&gt;int&lt;/code&gt; by an &lt;code&gt;int&lt;/code&gt; then assigning it to a &lt;code&gt;long&lt;/code&gt;.  Instead if you multiply a &lt;code&gt;long&lt;/code&gt; by a &lt;code&gt;long&lt;/code&gt;, or an &lt;code&gt;int&lt;/code&gt; by a &lt;code&gt;long&lt;/code&gt;, or a &lt;code&gt;long&lt;/code&gt; by an &lt;code&gt;int&lt;/code&gt;, it should work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long res = 775L * 775;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;L&lt;/code&gt; suffix tells the compiler to treat it as a long, not an int.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-04T21:37:06.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21408" PostTypeId="2" ParentId="21402" CreationDate="2016-03-04T22:45:21.173" Score="0" Body="&lt;p&gt;Try SoftwareSerial rather than AltSoftSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see the point in these lines, I think you can remove them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (Serial.available())&#xA;  {&#xA;    portOne.write(Serial.read());&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have connected directly to a pic and verified the radio I'm connecting to does indeed continue to send data.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If that is the case, that it sends data anyway, then you could just use HardwareSerial. Connect the radio to Rx (D0 on the Uno) and leave Tx unconnected. Then just read from Serial, and write to Serial. You should see the results on the Serial Monitor. (Disconnect this wire when uploading new versions of the sketch).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-07T19:57:06.810" LastActivityDate="2016-03-07T19:57:06.810" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="21410" PostTypeId="2" ParentId="13299" CreationDate="2016-03-04T23:34:49.080" Score="0" Body="&lt;p&gt;I've also had this error message when I've left another serial terminal connected to the same port the Arduino IDE is trying to use.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="6936" LastEditDate="2016-03-25T10:32:33.203" LastActivityDate="2016-03-25T10:32:33.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21412" PostTypeId="1" CreationDate="2016-03-05T00:30:22.340" Score="0" ViewCount="39" Body="&lt;p&gt;With the source code below, I'm getting what I think to be strange behaviour with the serial port output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;int c = 0;    &#xA;void loop() {&#xA;  Serial.println(c++);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Presumably what this will do is starting printing incrementing numbers, one on each line, starting from 0. However, my serial monitor only starts printing these numbers after the 3000 mark. I found this behaviour only after discovered in another sketch that I was losing data at the beginning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this normal Arduino behaviour? Or a serial monitor problem? Or something else?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-03-05T01:04:48.123" Title="Arduino serial port eats data for 3 seconds before it sends?" Tags="|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21413" PostTypeId="1" CreationDate="2016-03-05T00:47:57.193" Score="1" ViewCount="1477" Body="&lt;p&gt;I have a Arduino Pro Micro and use the USB port for programming. Is it possible to use the hardware serial port for connecting with a peripheral while I'm using the USB port (and hence the hardware serial port) for programming? Or must I disconnect the USB cable or otherwise reconfigure the hardware?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-03-05T01:59:08.423" Title="Possible to use the hardware serial port for peripheral on ATmega32u4 when using USB for programming?" Tags="|serial|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21415" PostTypeId="2" ParentId="21412" CreationDate="2016-03-05T01:04:48.123" Score="2" Body="&lt;p&gt;Is this a Leonardo or Yun?  If it is, you have to wait until the &lt;code&gt;Serial&lt;/code&gt; object says the USB connection is really ready:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read &lt;a href=&quot;https://www.arduino.cc/en/Serial/IfSerial&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because you did't wait, your &lt;code&gt;loop&lt;/code&gt; is able to execute 3000 times before &lt;code&gt;Serial&lt;/code&gt; actually sends something back to the PC.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-03-05T01:04:48.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21416" PostTypeId="2" ParentId="21413" CreationDate="2016-03-05T01:59:08.423" Score="3" Body="&lt;p&gt;I have a Teensy 2.0 with a ATmega32u4 and I can use both, with the USB as Serial.* and the hardware UART as Serial1.* &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Arduino Pro Micro it is the same.  See &lt;a href=&quot;https://arduino.stackexchange.com/q/1471/6628&quot;&gt;Arduino Pro Micro, get data out of Tx pin?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Teensy, see &lt;a href=&quot;https://www.pjrc.com/teensy/td_uart.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.pjrc.com/teensy/td_uart.html&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-05T01:59:08.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21419" PostTypeId="1" CreationDate="2016-03-05T02:49:13.603" Score="1" ViewCount="1061" Body="&lt;p&gt;Background: I'm using an Atmega1284P to add sensors to an off road racing truck onto a CANBUS network. The standard automotive sensors are thermistors, but the Dallas 1 wire temp sensors (DS18B20) with an integrated ADC caught my eye. They don't, however, come in a package that would work for my purposes so I would have to build one. I haven't been able to find one waterproofed in an NPT fitting with only a 1&quot; probe length. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: how much more accurate would the 1 wire be over a thermistor? &#xA;How much of a difference would it make for processor efficiency to not have to do the math involved with thermistors and just read the value from the 1 wire? I don't mind building them, I just want to make sure they're worth it first. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-05T14:19:55.323" Title="Digital Vs. Analog Sensor" Tags="|sensors|code-optimization|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21424" PostTypeId="1" CreationDate="2016-03-05T11:13:57.517" Score="1" ViewCount="445" Body="&lt;p&gt;I'm trying to make a web server using an Arduino R3 and Sparkfun ESP8266 Wifi Shield. I've built a webpage that has a form I would like to control the Arduino with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently my sketch can successfully send the webpage, but when I use the form, 9 / 10 times I see no output on the serial monitor, and the 1/10 times I see the frame from the client the sketch seems to hang and the client keeps waiting for more data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the Sparkfun ESP8266 libraries for the product I bought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think this is a hardware problem, I've visually inspected the Arduino and ESP pins and they seem ok. I don't think it's a memory problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've put the salient part of the sketch below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serverDemo()&#xA;{&#xA;  // available() is an ESP8266Server function which will&#xA;  // return an ESP8266Client object for printing and reading.&#xA;  // available() has one parameter -- a timeout value. This&#xA;  // is the number of milliseconds the function waits,&#xA;  // checking for a connection.&#xA;  ESP8266Client client = server.available(1000);&#xA;  char clientline[BUFSIZ];&#xA;  int index = 0;&#xA;&#xA;  if (client) &#xA;  {&#xA;    Serial.println(F(&quot;Client Connected!&quot;));&#xA;    // an http request ends with a blank line&#xA;    boolean currentLineIsBlank = true;&#xA;&#xA;    while (client.connected()) &#xA;    {&#xA;      if (client.available()) &#xA;      {&#xA;        char c = client.read();&#xA;&#xA;        if( index &amp;lt; BUFSIZ ) {&#xA;          clientline[index++] = c;&#xA;        } // end of if&#xA;&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) &#xA;        {&#xA;          clientPrintProgmemArray(htmlHeaderTable, htmlHeaderTableSize, client);&#xA;          clientPrintProgmemArray(webpageTable, webpageTableSize, client);&#xA;          Serial.println(F(&quot;Page sent&quot;));&#xA;          break;&#xA;        } // end of if&#xA;&#xA;        if (c == '\n') &#xA;        {&#xA;          currentLineIsBlank = true;&#xA;        } // end of if&#xA;&#xA;        else if (c != '\r') &#xA;        {&#xA;          // you've gotten a character on the current line&#xA;          currentLineIsBlank = false;&#xA;        } // end of if&#xA;      } // end of if( client.available() )&#xA;    } // end of while ( client.connected() )&#xA;    delay(10);&#xA;    client.stop();&#xA;    Serial.println(F(&quot;Client disconnected&quot;));&#xA;    Serial.print(F(&quot;Index: &quot;));&#xA;    Serial.println(index);&#xA;    Serial.print(F(&quot;Clientline: \&quot;&quot;));&#xA;    for( int i = 0; i &amp;lt;= index; i++)&#xA;    {&#xA;      Serial.print(clientline[i]);&#xA;    }&#xA;    Serial.print(F(&quot;\&quot;\r\n&quot;));&#xA;    if( strstr(clientline, &quot;e=1&quot;) != 0) {&#xA;      Serial.println(&quot;hooray!&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The header and webpage the Arduino sends to the client is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HTTP/1.1 200 OK&#xA;Content-Type: text/html&#xA;Connection: close&#xA;&amp;lt;!DOCTYPE HTML&amp;gt;&#xA;&amp;lt;html&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;&amp;lt;form action=&quot;/?&quot; method=&quot;get&quot;&amp;gt;&#xA;    &amp;lt;input name=&quot;e&quot; type=&quot;submit&quot; value=&quot;0&quot;&amp;gt;&#xA;    &amp;lt;input name=&quot;e&quot; type=&quot;submit&quot; value=&quot;1&quot;&amp;gt;&#xA;&amp;lt;/form&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output I get on the serial monitor is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESP8266 Shield Present&#xA;Mode set to station&#xA;Connected to: XXXXX&#xA;My IP: 192.168.0.13&#xA;Server started! Go to 192.168.0.13&#xA;&#xA;Client Connected!&#xA;Page sent&#xA;Client disconnected&#xA;Index: 2&#xA;Clientline: &quot;&#xA; &quot;&#xA;Client Connected!&#xA;Page sent&#xA;Client disconnected&#xA;Index: 2&#xA;Clientline: &quot;&#xA; &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd be very grateful if anybody has any advice on where the problem lies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="18975" LastActivityDate="2017-08-24T18:05:46.973" Title="Not seeing frames returned from client when using ESP8266 Wifi Shield" Tags="|arduino-uno|esp8266|web|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21426" PostTypeId="2" ParentId="21419" CreationDate="2016-03-05T11:53:50.003" Score="2" Body="&lt;p&gt;To make an informed decision you first need to understand a few basic concepts and some pros and cons of each system.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly there are the concepts of &lt;em&gt;precision&lt;/em&gt; and &lt;em&gt;accuracy&lt;/em&gt;. These are two very different properties and each is important in their own way. On the face of it they may sound the same, but they aren't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Precision&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how close to the real value your measurements are. This is the &quot;±&quot;  value that datasheets list. It's how close a match to the actual temperature the measured temperature is.  So a ±0.5° measurement could be anywhere within half a degree of the actual temperature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Accuracy&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can also be considered as the &lt;em&gt;resolution&lt;/em&gt; of the measurement. It is how fine a difference in temperatures the device is able to measure. For instance you may be able to detect 0.0125° differences.  This is mostly defined by the resolution of the ADC in the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And now the pros and cons:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Digital&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These devices can be factory calibrated for a more precise reading. The accuracy is usually pretty good too, but is fixed by the design of the device. Communication is generally reliable and wire length doesn't generally affect the values reported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Communication protocols can have some large overheads limiting the number of samples you can take per second (not just on one sensor but across the whole array of sensors). Excess EMI noise (especially from engines) can corrupt the communication signals over long connections unless extra care is taken (such as implementing a balanced line communication medium).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Analog&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very simple to connect up and samples can be read very rapidly. Accuracy is determined by the ADC you choose to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire length can have a detrimental affect on the values read unless special wiring and sensor schemes are used to cancel out the resistance of the wires. Noise induced into the wires is very hard to detect or cancel out and can give spurious results. Requires more complex mathematics to calculate a resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in short: Digital can give you more reliable communication of your sampled values over longer distances but at the cost of reduced sampling speeds.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-05T11:53:50.003" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21427" PostTypeId="1" AcceptedAnswerId="21429" CreationDate="2016-03-05T13:44:46.213" Score="2" ViewCount="196" Body="&lt;p&gt;I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = 0;&#xA;char serial_char;&#xA;char serial_message[96];&#xA;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  while(Serial.available() &amp;gt; 0){&#xA;&#xA;    serial_char = Serial.read();&#xA;    if (serial_char == '\n' || serial_char == '\r'){&#xA;&#xA;      serial_message[count] = 0; // &amp;lt;&amp;lt;-- What does this line do?&#xA;      count = 0;&#xA;      Serial.println(serial_message);&#xA;&#xA;    }&#xA;    else{&#xA;      serial_message[count++] = serial_char;&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this code, I can type a message into the serial monitor, and it will print the message back at me. So if I type 'Goodbye', it returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Goodbye&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I send it another message 'Word', it returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Word&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, my questions is when I comment out the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serial_message[count] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then I repeat the same sequence of actions before, 'Goodbye' returns 'Goodbye', but when next I enter 'Word', it returns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wordbye&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could anyone explain this to me? I am really curious to know why this occurs. What does adding that 0 in the char array accomplish? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12039" LastEditorUserId="12039" LastEditDate="2016-03-05T14:36:41.863" LastActivityDate="2016-04-16T09:18:16.117" Title="A question about chars and Serial" Tags="|serial|string|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21428" PostTypeId="2" ParentId="21427" CreationDate="2016-03-05T14:08:19.380" Score="4" Body="&lt;p&gt;The zero-value, the &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Null_character&quot; rel=&quot;nofollow&quot;&gt;null character&lt;/a&gt;&quot;, indicates the end of the string. For strings, you allocate some maximum space, in your case 96 bytes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char serial_message[96];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When storing variable-length strings in that, you need to indicate where the string ends. That's what the zero value does in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Null-terminated_string&quot; rel=&quot;nofollow&quot;&gt;null-terminated string&lt;/a&gt;. (Note that &lt;code&gt;0&lt;/code&gt; is really binary &lt;code&gt;0x00&lt;/code&gt; here; it's not the ASCII &lt;em&gt;character&lt;/em&gt; 48, &lt;code&gt;0x30&lt;/code&gt;.) So, the 96 bytes allow for a string of at most 95 characters, followed by the terminator. When printing, it prints the memory contents until it finds that null character.&lt;/p&gt;&#xA;" OwnerUserId="16852" LastEditorUserId="16852" LastEditDate="2016-04-16T09:18:16.117" LastActivityDate="2016-04-16T09:18:16.117" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21429" PostTypeId="2" ParentId="21427" CreationDate="2016-03-05T14:11:04.030" Score="1" Body="&lt;p&gt;There is a difference between char[] and String.&lt;br&gt;&#xA;You are using char[] which is the best way to work on a small processor like the Arduino. However; it is also a bit more difficult.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Char array is just a piece of memory that can contain any data. Because we want to put a variable length string in there we need a convention to know what is the last character of the string. By convention this is a value 0.&lt;br&gt;&#xA;This is why we speak about &quot;null terminated strings&quot;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This explains why after sending word (without adding the 0 at the end&quot; you get &quot;Wordbye&quot; because the memory contains 'W' 'o' 'r' 'd' 'b' 'y' 'e' and 0.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why it works OK with 'Goodbye' is because all memory gets set to 0 at startup of the processor.&lt;br&gt;&#xA;So as long as the last send word is longer than the previous it works fine.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A last thing. The memory does not actually contain 'W' 'o' 'r' 'd' 'b' 'y' 'e'. The memory contains the ASCII values of the letters 'W' 'o' 'r' 'd' 'b' 'y' 'e'   &lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-05T14:11:04.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21430" PostTypeId="2" ParentId="21419" CreationDate="2016-03-05T14:19:55.323" Score="0" Body="&lt;p&gt;I fully agree with Majenko except for the cons for analog.&lt;br&gt;&#xA;Basically it is not easy to get a (very) accurate ADC reading with an arduino.&#xA;The main problem is the reference voltage that fluctuates.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the main reason why I prefer digital to analog when it needs to be &quot;correct&quot; &lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-05T14:19:55.323" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21433" PostTypeId="1" CreationDate="2016-03-05T15:58:17.867" Score="-1" ViewCount="1934" Body="&lt;p&gt;How can I burn the Arduino Bootloader on an ATmega168PA-PU with an Arduino Uno?&lt;/p&gt;&#xA;" OwnerUserId="2871" LastEditorUserId="6936" LastEditDate="2016-03-06T21:41:32.837" LastActivityDate="2016-03-06T21:41:32.837" Title="How to burn Arduino Bootloader on ATmega168PA-PU?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21434" PostTypeId="1" CreationDate="2016-03-05T16:26:31.887" Score="-1" ViewCount="322" Body="&lt;p&gt;I have an arduino board connected to 2 temperature sensors, 2 switch buttons and 1 lcd display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the switch button changes to off, &quot;off&quot; is printed on the lcd display. When the button state is on, the temperature is printed on the lcd display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when it shows &quot;off&quot; its still possible to see the temperature value for &quot;1 millisecond&quot; each second. I don't know what is causing the &quot;off&quot; message to change for a millisecond.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;#define DS18B20_SENSOR1 2               // pino de dados do DS18D20&#xA;#define DS18B20_SENSOR2 4               // pino de dados do DS18D20&#xA;&#xA;int buttonState1 = 0;&#xA;int lastButtonState1 = 0;&#xA;int buttonState2 = 0;&#xA;int lastButtonState2 = 0;&#xA;&#xA;float Temp1, Temp2;&#xA;&#xA;OneWire oneWire1(DS18B20_SENSOR1);       // Objeto do baramento One-wire&#xA;DallasTemperature sensor1(&amp;amp;oneWire1);     // Objeto do sensor DS18D20&#xA;&#xA;OneWire oneWire2(DS18B20_SENSOR2);       // Objeto do baramento One-wire&#xA;DallasTemperature sensor2(&amp;amp;oneWire2);     // Objeto do sensor DS18D20&#xA;&#xA;// Set the LCD address to 0x27 for a 16 chars and 2 line display&#xA;LiquidCrystal_I2C lcd(0x27, 16, 2);&#xA;&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(3000);&#xA;  Serial &amp;lt;&amp;lt; F(&quot;Teste do Sensor 1&quot;) &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; F(&quot;Teste do Sensor 2&quot;) &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&#xA;  sensor1.begin();&#xA;  sensor2.begin();&#xA;  lcd.begin();&#xA;  lcd.setBacklight(HIGH);&#xA;&#xA;&#xA;  /*&#xA;   * Control Variables&#xA;   */&#xA;&#xA;  pinMode(5, INPUT);&#xA;  pinMode(7, INPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;  pinMode(12, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void turnAllOff1(){&#xA;  digitalWrite(11, LOW); &#xA;  digitalWrite(12, LOW); &#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&#xA;void turnAllOff2(){&#xA;  digitalWrite(8, LOW); &#xA;  digitalWrite(9, LOW);&#xA;  digitalWrite(10, LOW);&#xA;}&#xA;&#xA;void printTemp1(){&#xA;  lcd.setCursor (0,0);&#xA;  lcd.print(&quot;Sensor1: &quot;);&#xA;  lcd.print(Temp1);&#xA;  lcd.print(&quot;C&quot;);&#xA;}&#xA;&#xA;void printOff1(){&#xA;  lcd.setCursor (0,0);&#xA;  lcd.print(&quot;Sensor1: &quot;);&#xA;  lcd.print(&quot; off   &quot;);  &#xA;}&#xA;&#xA;void printTemp2(){&#xA;  lcd.setCursor (0,1);&#xA;  lcd.print(&quot;Sensor2: &quot;);&#xA;  lcd.print(Temp2);&#xA;  lcd.print(&quot;C&quot;); &#xA;}&#xA;&#xA;void printOff2(){&#xA;  lcd.clear();&#xA;  lcd.setCursor (0,1);&#xA;  lcd.print(&quot;Sensor2: &quot;);&#xA;  lcd.print(&quot; off   &quot;); &#xA;}&#xA;&#xA;void loop(){&#xA;  buttonState1 = digitalRead(5);&#xA;  buttonState2 = digitalRead(7); &#xA;&#xA;  if(buttonState1 != lastButtonState1){&#xA;    if(buttonState1 == HIGH){&#xA;      sensor1.requestTemperatures();&#xA;      Temp1 = sensor1.getTempCByIndex(0);&#xA;      turnAllOff1();&#xA;      if(Temp1 &amp;lt; 36){&#xA;        digitalWrite(13, HIGH);&#xA;      }&#xA;      else if(Temp1 &amp;gt; 38){&#xA;        digitalWrite(11, HIGH); &#xA;      }&#xA;      else{&#xA;        digitalWrite(12, HIGH);&#xA;      }&#xA;      printTemp1();&#xA;    }&#xA;    else{&#xA;      printOff1();&#xA;    }&#xA;  }&#xA;  lastButtonState1 = buttonState1;&#xA;&#xA;  if(buttonState2 != lastButtonState2){  &#xA;    if(buttonState2 == HIGH){&#xA;      sensor2.requestTemperatures();&#xA;      Temp2 = sensor2.getTempCByIndex(0);&#xA;      turnAllOff2();&#xA;      if(Temp2 &amp;lt; 0){&#xA;        digitalWrite(10, HIGH);&#xA;      }&#xA;      else if(Temp2 &amp;gt; 2){&#xA;        digitalWrite(8, HIGH); &#xA;      }&#xA;      else{&#xA;        digitalWrite(9, HIGH); &#xA;      }&#xA;      printTemp2();&#xA;    }&#xA;    else{&#xA;      printOff2(); &#xA;    }&#xA;  }&#xA;  lastButtonState2 = buttonState2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18979" LastActivityDate="2016-06-04T16:52:01.050" Title="Arduino LiquidCrystal_I2C fast overwritting" Tags="|arduino-uno|lcd|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21435" PostTypeId="1" AcceptedAnswerId="21436" CreationDate="2016-03-05T18:16:18.110" Score="5" ViewCount="486" Body="&lt;p&gt;The Arduino can be programmed using SPI without a boot loader. Without a boot loader, the Arduino starts running its sketch right away. So, how does the Arduino know that it is being programmed via SPI vs regular SPI traffic already present on the SPI bus? Was is the pin-level, electrical signal that let's the Arduino know the difference?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-03-05T18:30:13.127" Title="How does Arduino distinguish between SPI programming data and regular data?" Tags="|icsp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21436" PostTypeId="2" ParentId="21435" CreationDate="2016-03-05T18:30:13.127" Score="10" Body="&lt;p&gt;In-system programmer is activated with RESET line. During normal operation reset line is not active and ISP module is disabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find detailed description of AVR ISP in this document:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/doc0943.pdf&quot;&gt;http://www.atmel.com/images/doc0943.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-03-05T18:30:13.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21437" PostTypeId="1" CreationDate="2016-03-05T18:34:26.370" Score="0" ViewCount="61" Body="&lt;p&gt;Recently I bought the following USB to Serial cable: &lt;a href=&quot;https://www.adafruit.com/products/954&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/954&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This cable has grd, vcc, rx and tx lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking to use this cable to interface with my desktop computer with a program like Tera Term or Hyperterminal so i can output messages for debugging purposes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I am trying to stay from using the Arduino IDE. I would prefer using C and flashing in the hex manually. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can anyone point me to a tutorial or explain how to make this happen?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks people.&lt;/p&gt;&#xA;" OwnerUserId="18790" LastActivityDate="2020-10-31T04:06:10.680" Title="Interfacing with desktop computer console software" Tags="|usb|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21438" PostTypeId="1" CreationDate="2016-03-05T20:59:40.983" Score="2" ViewCount="502" Body="&lt;p&gt;I need to stop 1st interrupt from 2nd interrupt till 2nd interrup finish work... How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my 2nd interrupt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void CHECK_IR(){&#xA;  detachInterrupt(0);&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    switch(results.value){&#xA;      case 16753245:&#xA;      Serial.println(results.value);&#xA;      if(level == 1){&#xA;       level = 1; &#xA;&#xA;      }else {&#xA;        level = 1;&#xA;      }&#xA;      break;&#xA;      case 16724175:&#xA;      level = 1.6;&#xA;      break;&#xA;      case 16718055:&#xA;      level = 3;&#xA;      break;&#xA;      case 16743045:&#xA;      level = 5;&#xA;      break;&#xA;      case 16716015:&#xA;      level = 9.9;&#xA;      break;&#xA;    }&#xA;    irrecv.resume();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;1st interrupt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void zero_crosss_int() {&#xA;&#xA;   delayMicroseconds(level*1000);  &#xA;  digitalWrite(AC_LOAD, HIGH);&#xA;    delayMicroseconds(100); &#xA;  digitalWrite(AC_LOAD, LOW);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I &lt;code&gt;detachInterrupt(0);&lt;/code&gt; detach 1st interrupt, but it is not right because I need it to work again, so i need interrupt 1st to sleep till 2nd intrrupt finish switch statment. Any solution for this?&lt;/p&gt;&#xA;" OwnerUserId="18888" LastEditorUserId="18888" LastEditDate="2016-03-05T21:42:12.977" LastActivityDate="2016-03-06T04:40:44.490" Title="Interrupts detach" Tags="|arduino-uno|interrupt|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21439" PostTypeId="2" ParentId="21437" CreationDate="2016-03-05T21:49:56.880" Score="1" Body="&lt;p&gt;&lt;strong&gt;For debugging:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Configure the UART on the ATmega to output TTL serial. If you are using the Arduino libraries, then &lt;code&gt;Serial&lt;/code&gt; is what you want. Connect the TX pin of the ATmega to the RX of the USB/Serial cable, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open the serial device on your computer in the program of your choice. When you write to the UART on the ATmega, you should see the messages in your terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pretty straightforward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;For programming:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're going to be using C and flashing things manually, you'd best go and buy an AVR programmer so you can program the ATmega directly without messing about with a bootloader. A programmer is ~15USD, so you might as well buy one. Then you can use the GNU AVR toolchain, which is very easy to use. Compile code with &lt;code&gt;avr-gcc&lt;/code&gt;, and program the device with &lt;code&gt;avrdude&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to use programming over serial, you'll have to manually hit the reset button each time you program the chip, because (as Mikael pointed out), that serial cable lacks the lines necessary to automatically reset the chip (and drop to the bootloader).&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-03-05T21:49:56.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21440" PostTypeId="2" ParentId="21424" CreationDate="2016-03-05T23:43:04.763" Score="1" Body="&lt;p&gt;So I figured out the answer to my own question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out there must be a mistake in the example sketches that come with the ESP8266 shield I bought, as the function to begin Arduino/ESP8266 communications didn't have any arguments when the function expected parameters. So it appeared to be trying to set their baud rate to 0!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I edited the library to have a hard value of 57600 and now it seems to work far more reliably.&lt;/p&gt;&#xA;" OwnerUserId="18975" LastActivityDate="2016-03-05T23:43:04.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21441" PostTypeId="2" ParentId="21433" CreationDate="2016-03-05T23:46:02.323" Score="1" Body="&lt;p&gt;The official Arduino documentation has detailed instructions on how to transform Arduino board into an ISP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-03-05T23:46:02.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21442" PostTypeId="1" AcceptedAnswerId="21539" CreationDate="2016-03-06T00:11:55.887" Score="1" ViewCount="1587" Body="&lt;p&gt;I'm trying to create a flexible but reliable system for arduinos to interact using serial ascii strings. &#xA;I'm using a message structure comprised of Command[10] + (optional) Params[20] + (optional) Header[30] + '\0' ( terminator).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each arduino node looks for incoming serial Commands (plus any appropriate optional Parameters) that it must respond to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;During development and debugging it's sufficient to send Commands and Parameters using the IDE serial monitor without optional Header block or error-checking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for interactive node-to-node communications, an optional 'Header' (technically a Footer) block is automatically added to the end of the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If an incoming serial message includes a header block, it means that the message was sent automatically from another node (rather than manually from the IDE serial monitor), and consequently the message integrity should be checked against any relevent accompanying header contents, then an acknowledgement returned to the sender if the message was received ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Header contents can optionally contain any of the following, and in any order:- s(source)=nnn, d(destination)=nnn, i(id)=nnn, l(msg length)=nnn, and non-critical mixtures of commas and/or spaces can be used as delimters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test for message length, the transmitted l=nnn value (text representation) is padded to 3 digits with leading zeros, so the length stays the same whatever the value (eg:.anything from 000 to 999 still requires 3 digits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far so good. But although a length test is better than nothing, it doesn't trap for corrupt characters, and the plan is for nodes to communicate via UDP broadcasts, so some form of error-checking and acknowledgement is essential.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the plan was to (also, or instead) use an optional c(checksum)=nnn in the header, whose value would be the mod sum of everything EXCEPT itself in the header entry. This is easily enough achieved for transmission by taking the mod sum of everything else when assembling the message, then adding the c=modsum on the end (or anywhere in the Header for that matter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, the receiving end just needs to remove the c=nnn entry (plus any preceding delimter) from wherever it is in the Header, then compare the remaining message's calculated mod sum value against the transmitted c=nnn value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice, I don't know how to exclude the c=nnn entry from the header in order to calculate the remaining modsum, without being forced to accept and pander to unwelcome restrictive assumptions, such as the c=nnn value having to be the final entry, and having to use very strict delimiting. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to keep things as flexible and informal as possible, so that other x=nnn type instruction options may be added anywhere to the header if needed without risk of breaking existing rigidity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps I should add that this time a year ago I hadn't touched an arduino or C, and that this project has long ago changed from my original automation/security needs to become a goal for providing a simple-to-use interactive arduino distributed functionality cluster system suitable for anyone to use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The end finally seems to be in sight, which is thanks to the help and advice from you guys (a quick look through my questions shows how far you've brought me), so hopefully your greater experience and wisdom may also be able to offer a more satisfactory integrity-test solution if it is possible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would also welcome any other comments that might help me improve on what I'm trying to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;ADDITIONAL INFO&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;New incoming serial messages are received in char Buffer[64].&#xA;This gets split by delimiters into Command[10], Params[20] and Header[30], but these sizes are only arbitrary first guestimates which may change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Commands and Parameters can be whatever the node has been programmed to respond to. A trivial 'Blink' example might be a couple of nodes, one looking for incoming &quot;PING&quot; Commands and responding by returning &quot;PONG&quot; Commands, and the other node vice- versa. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more useful example could be an IR receiver node issuing instructions to a remote IR blaster node, so the &quot;Command+Param+Header&quot; string might be:- &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;IRSEND 'NEC 0xFFEEAB99, 32', s=1, d=2, l=044&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Command/Params parser accepts comma or space as delimiter except if they are contained within quotes. Quotes may be sent inside of quotes of the other type (single or double). Mr T's invaluable Header parser is slightly modified to also accept comma's or spaces as delimiters in the Header, therefore &quot; ,  s=nnn,d=nnn, i=nnn    l=nnn , &quot; all extracts ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the above is working ok in a very messy and disjointed proof-of-concept form.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    static char buffer[64];&#xA;    int msgpos = 0;&#xA;    int msglength;&#xA;    int quotes=0;&#xA;    int parseMode=0;&#xA;    bool echo=false;&#xA;    bool ack=false;&#xA;    byte chksum=0;&#xA;    int modchk = 0;                 &#xA;&#xA;    char command[10];&#xA;    char param[20];&#xA;    char header[30];&#xA;    int snum=0, dnum=0, inum=0, lnum=0, cnum=0;&#xA;&#xA;  void setup()&#xA;  {   &#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Ready&quot;);&#xA;  }&#xA;&#xA;  int readline(int readch, char *buffer, int len) { //  If a CR terminated ascii string is received, returns string length, else returns -1&#xA;    static int pos = 0;&#xA;    int rpos;&#xA;    if (readch &amp;gt;0) {                               // if a valid ascii character&#xA;      msgpos++; &#xA;      if (msgpos == 1) resetBuffer();              // First chr, so reset everything to make a new start&#xA;      if (!(pos &amp;lt; len-1)) Serial.println(&quot;Error: Msg too big for buffer&quot;);&#xA;      else if ((readch !=10) &amp;amp;&amp;amp; (readch != 13)) {&#xA;        buffer[pos++] = readch;&#xA;        modchk += readch; &#xA;        modchk %= 100;                  &#xA;    //  Serial.print(&quot;modsum%='&quot;); Serial.print(modchk); Serial.println(&quot;'&quot;); &#xA;        buffer[pos] = 0;&#xA;      }  // end if (pos &amp;lt; len-1) &#xA;      switch(readch) {      &#xA;      case 10: break;                                                                             // Ignore new-lines&#xA;      case 39: if (quotes==0) quotes=1; else if (quotes==1) quotes=0; else addChr(readch); break; // Turn on or off single-quotes&#xA;      case 34: if (quotes==0) quotes=2; else if (quotes==2) quotes=0; else addChr(readch); break; // Turn on or off double-quotes&#xA;      case 33: if (quotes==0) parseMode=-1; else addChr(readch); break;                           // ! Header info&#xA;      case 32: if ((quotes&amp;gt;0) || (parseMode==-1)) addChr(readch); else parseModeBump(); break;    // space delimiter&#xA;      case 44: if ((quotes&amp;gt;0) || (parseMode==-1)) addChr(readch); else parseModeBump(); break;    // comma delim &#xA;      case 13:                                                                                    // CR stop char&#xA;        if (parseMode==0) {Serial.println(&quot;Error: blank or corrupt message&quot;); pos=0;  return 0; }&#xA;        else if(quotes&amp;gt;0) {Serial.println(&quot;Error: open quotes not closed&quot;); pos=0;  return 0; }&#xA;        else {// new msg recvd ready for processing. TODO: check if msglength and/or checksum sent, if so and if correct, return ack to sender&#xA;          rpos = pos;  &#xA;          pos = 0;    // Reset position index ready for next time&#xA;          return rpos;&#xA;        }&#xA;        break;     &#xA;      default:&#xA;        addChr(readch); &#xA;        break;     &#xA;      }  // end case&#xA;    } // end if (readch &amp;gt;0);&#xA;    return -1;        // No end of line CR yet, so return -1.&#xA;  }&#xA;&#xA;  void resetBuffer() {&#xA;    modchk=0; quotes=0; parseMode=0; command[0]='\0'; param[0]='\0'; header[0]='\0';&#xA;    snum=0; dnum=0; inum=0; lnum=0; cnum=0;&#xA;  }&#xA;&#xA;  bool parseModeBump() {&#xA;    switch (parseMode) {&#xA;    case  0: parseMode=1; break;&#xA;    case  1: parseMode=2; break;&#xA;    case  2: parseMode=-1; break;&#xA;    case -1: Serial.println(&quot;Error: too many delimited parameters&quot;); return false;&#xA;    }&#xA;    return true;   &#xA;  }&#xA;&#xA;  bool addChr(char readch)  {                  //&#xA;    char addch[2];&#xA;    bool ret=true;&#xA;    addch[0]=readch; addch[1]='\0'; &#xA;    if (parseMode==0) parseMode=1;&#xA;    switch (parseMode) {&#xA;    case  1: strcat(command,addch); break;&#xA;    case  2: strcat(param,addch); break;&#xA;    case -1: strcat(header,addch); break;&#xA;    default: &#xA;      Serial.println(&quot;addChr Error: too many delimited parameters&quot;); ret = false;&#xA;    }&#xA;    return ret;  &#xA;  }    &#xA;&#xA;  void show() {&#xA;    Serial.print(&quot;SHOW: Command='&quot;); Serial.print(command); Serial.print(&quot;'&quot;); &#xA;    Serial.print(&quot; Parameter='&quot;); Serial.print(param); Serial.print(&quot;' &quot;); &#xA;    Serial.print(&quot; Header='&quot;); Serial.print(header); Serial.println(&quot;'&quot;); Serial.println();&#xA;    Serial.print(&quot;Msg Length='&quot;); Serial.print(msglength); Serial.println(&quot;'&quot;);&#xA;    if (snum) { Serial.print(&quot;snum=&quot;); Serial.println(snum); }&#xA;    if (dnum) { Serial.print(&quot;dnum=&quot;); Serial.println(dnum); }&#xA;    if (inum) { Serial.print(&quot;inum=&quot;); Serial.println(inum); }&#xA;    if (lnum) { Serial.print(&quot;lnum=&quot;); Serial.println(lnum); }&#xA;    if (cnum) { Serial.print(&quot;cnum=&quot;); Serial.println(cnum); }&#xA;  }&#xA;&#xA;  /*&#xA;  bool padzeros() {  // Flawed - redo from scratch using 2 for loop passes&#xA;    char lengthstr[4]=&quot;7&quot;;  &#xA;    Serial.print(&quot;lengthstr='&quot;); Serial.print(lengthstr); Serial.println(&quot;'&quot;);&#xA;    int maxsize=sizeof(lengthstr);  // size of lengthstr array&#xA;    int steps=strlen(leng)+1;       // number of chars to be moved&#xA;    int hop=maxsize-steps;          // number of steps to be jumped over each move&#xA;    if((steps&amp;gt;1)&amp;amp;&amp;amp;(maxsize&amp;gt;steps)) {  &#xA;      for (int pos=steps-1; pos &amp;gt;= 0; pos--) {&#xA;        lengthstr[pos+hop] = lengthstr[pos];&#xA;        lengthstr[pos]='0';&#xA;      }&#xA;    }&#xA;    Serial.print(&quot;lengthstr='&quot;); Serial.print(lengthstr); Serial.println(&quot;'&quot;);&#xA;  }&#xA;  */&#xA;&#xA;  unsigned int calcmodsum(char* s){&#xA;    unsigned int i = 0;&#xA;    int m=0;&#xA;    byte b;&#xA;    do { b = s[i]; m += s[i]; i++; } &#xA;    while (b != 0); //keep going until null terminator found at end of string&#xA;    m %= 100;                   //&#xA;    return m;    &#xA;  }&#xA;&#xA;  int getheader() {      // extract values from header&#xA;  //  char header[] = &quot;s=123 d=789 c=463&quot;;&#xA;    ack=false; echo=false;&#xA;    char * ptr = header; // header string pointer&#xA;    char * eq = NULL;    // search char (=) &#xA;    int * num = NULL;    // empty at start&#xA;    int c = 0;&#xA;    while (1){&#xA;      eq = strchr(ptr, '=');&#xA;      ptr = eq;          // update the pointer&#xA;      if (ptr == NULL)  break;  // found no '=' chars &#xA;      switch (*(ptr - 1)){ &#xA;        case 'd': num = &amp;amp;dnum; break;&#xA;        case 's': num = &amp;amp;snum; break;&#xA;        case 'i': num = &amp;amp;inum; break;&#xA;        case 'l': num = &amp;amp;lnum; break;&#xA;        case 'c': num = &amp;amp;cnum; c=3; break;&#xA;        default:  num = NULL;&#xA;      }&#xA;      ptr++;&#xA;      if (num == NULL) //unrecognized var&#xA;        continue;      // locate next = char&#xA;      *num = 0;&#xA;      while (*ptr &amp;amp;&amp;amp; (*ptr != ' ') &amp;amp;&amp;amp; (*ptr != ',') &amp;amp;&amp;amp; isdigit(*ptr)) {  // while valid digit and end of string not yet reached&#xA;        *num *= 10;    // extract each int&#xA;        *num += *ptr - '0';&#xA;        c++;&#xA;        ptr++;&#xA;      }&#xA;    }                  // Now Process any extracted header values      &#xA;    if (lnum) {&#xA;      Serial.print(&quot;Msg length=&quot;); Serial.print(strlen(buffer)); Serial.println();&#xA;      Serial.print(&quot;lnum=&quot;); Serial.print(lnum); Serial.println();&#xA;      if (lnum==strlen(buffer)) Serial.println(&quot;* Msg length OK&quot;); else Serial.println(&quot;* Incorrect msg length&quot;);  &#xA;    }&#xA;    if (cnum) {&#xA;      Serial.print(&quot;calcmodsum='&quot;); Serial.println(calcmodsum(buffer));&#xA;      Serial.print(&quot;cnum='&quot;); Serial.print(cnum); Serial.println(&quot;'&quot;);&#xA;      Serial.print(&quot;count='&quot;); Serial.print(c); Serial.println(&quot;'&quot;);&#xA;      if (modchk==cnum) Serial.println(&quot;* Checksum OK&quot;); else Serial.println(&quot;* Incorrect checksum&quot;);  &#xA;    }&#xA;  }&#xA;&#xA;  void loop() { &#xA;    //  Check for new received serial string&#xA;    msglength = readline(Serial.read(), buffer, 64);  // Returns length of new ascii string, or -1 while receiving, or 0 if received msg is corrupt&#xA;    if(msglength==0  ) { Serial.println(&quot;ERROR: received serial message was invalid and discarded&quot;);show(); resetBuffer();} &#xA;    else if(msglength &amp;gt; 0) {  // New msg to deal with&#xA;      if (header) getheader();&#xA;      show();&#xA;&#xA;      msgpos=0;  // reset ready for new msg after finished with last msg&#xA;    }   &#xA;  } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once I can finalise a satisfactory c=nnn validity test, I shall tidy up this working 'receiver' part and move on to doing the 'sender' part, which I'm hoping should be quite trival in comparison. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose it would be 'proper' to assemble the outgoing message into something like a  char outmsg[64] string, but I'm trying to keep resources minimal to maximise the resources available for the arduino's 'real' functionality, so perhaps it may be better just to send the outgoing msg as consecutive serial chunks, ie:-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial.print(Command); Serial.print(Params); Serial.println(Header);  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The header will be built up as required. If s=nnn (source) was received it will be assumed that an acknowledgement response is required by the source to prevent it repeating failed transmissions, so the received s=nnn would be used as the outgoing d=nnn destination to respond to - outgoing msgs need only include a source s=nnn if they requires a response back. The i=nnn (msg id) isn't yet used, but could eventually be for re-assembling individual chunks of larger msgs, or keeping track of msg order if multiple msgs are expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The l=nnn is a zero-padded count of all transmitted characters (excluding the terminating ), so can be anywhere within the Header string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be preferable if the zero-padded c=nnn checksum could also be anywhere in the Header, but this will require a checksum() calculator function to be able to apply its calculation to all Header characters except the nnn data characters of c=nnn.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As things are, I can jump straight to &quot;c=&quot; wearing blinkers, but that offers no relative position info, so leaves me oblivious of everthing before it. &#xA;And I'd prefer not having to split Header[] into seperate Left[] and Right[] chunks which would unnecessarily wastes at least [30+30] chars of memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I think I must sequentially step through all Header characters looking for &quot;=&quot; while applying the mod sum calc to each, except for the 3 following chars when the preceeding char is &quot;c&quot;, but I can't quite get my head around how to do that yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the C string functions could return relative string positions instead of absolute * pointers it could all be so much more straightforward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know of any alternative string-relative functions that might be available?  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;NEW INFO 2 *&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most &quot;Hello world&quot; examples (eg: IRlib) demonstrate functionality using the IDE serial monitor for user interaction. Whatever the functionality, they can all be considered as just a black box capable of recognising a few incoming serial plain-text commands and actioning as appropriate, possibly by also issuing serial text command responses of their own. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The aim of my project is for a user to easily turn that existing and already-proven serial user interaction into an automatic arduino to arduino serial interaction if wished. The headers are just an optional bolt-on for arduino to arduino reliability, but during dev and debugging the various optional header contents will still need to be read and written by users with the IDE serial monitor, which only allows ascii text interaction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this sort of system would not be the preferred solution for experts, it offers much advantage for non-experts. Un-skilled hackers could create effective working solutions without needing to aquire any rocket science first, and without needing to worry too much about resource limitations, or the problems and complexity of trying to consolidate incompatable or conflicting functionality onto any single device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they have an arduino that can serially interact, they can use it as an interactive node. If two can interact over serial, then more can serially interact using RS485, or using serial Ethernet UDP slaves (ESP8266's are small and cheap). &#xA;Only nodes that 'recognise' an incoming command would respond to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Triggers node could send ascii Alerts such as 'Mailbox Opened', 'Gate1 Visitor', Shed Door Opened' etc.  A Responder node could parse such incoming Alerts to match against entries in a config file, then parse the corresponding config entry for appropriate Response commands to be issued to other cluster nodes, such as 'Mailbox: Announce Mailbox Delivery', or 'Zone2: Announce Zone 2 Activity, CCTV: Select Zone2'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would allow new node functionality to be added easily just by updating the Responders appropriate config file entry to include any additional Response commands that become available from any new nodes. So adding an X10 node for instance might offer a new Response command such as 'X10, A12 ON', which only the newly added X10 node would be looking for and respond to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A cluster system could be evolved into whatever sophisticated functionality was required, with minimal software skills and knowledge. Commands and parameters could be any plain-text names that the user prefers, which when matched during input parsing would branch to any required local function. &#xA;Despite any resulting complexity, all individual nodes could still just be considered as relatively simple black boxes capable of recognising a few incoming serial plain-text trigger commands and replying with plain-text responses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cluster nodes aren't even limited to being arduinos, because they could include ANY devices capable of receiving and responding to simple ascii command strings. This offers easy gradual progression to other platforms if wished without needing to abandon all existing efforts and start over again from scratch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I knew I was biting off more than I could chew, but each time I play devils advocate trying to avoid wasting my time going up a dead-end, the more benefits become apparent to make the effort seem worthwhile. The forums are littered with questions and libraries aiming in a similar direction, but I haven't yet found anything which offers that simple black-box plain-text interaction capability, hence my continued struggle. I'm not a programmer so I'll never be able to offer an efficient library solution, but I must try to keep going until I've got something that is usable, and if others find it useful then maybe eventually it might offer incentive for someone to wish to optimise and improve on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully the following should do what I want as far as ignoring &quot;c=nnn&quot; from the mod checksum wherever it finds it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int calcmodsum(char* passedstr){     // calculates the mod sum of passedstr excluding the 3 &quot;c=nnn&quot; value digits&#xA;  int pos = 0;                         &#xA;  int modsum=0;&#xA;  byte b;&#xA;  do { &#xA;    b = passedstr[pos]; &#xA;    if ((passedstr[pos]=='c')&amp;amp;&amp;amp;(passedstr[pos+1]=='=')&amp;amp;&amp;amp;(pos&amp;gt;2)) pos=pos+4; else modsum += passedstr[pos]; // skip next 3 digits after finding c=&#xA;    pos++; &#xA;  } &#xA;  while (b != 0); // keep going until null terminator found at end of string&#xA;  modsum %= 100;         &#xA;  return modsum;    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16433" LastEditorUserId="16433" LastEditDate="2016-03-07T18:58:59.260" LastActivityDate="2016-03-07T20:42:36.313" Title="Advice for checking integrity of serial char strings?" Tags="|serial|programming|networking|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21444" PostTypeId="1" CreationDate="2016-03-06T01:43:20.023" Score="2" ViewCount="420" Body="&lt;p&gt;I wanted to know what type of component or module I could use to make a hollow ball move.  I have these hollow plastic balls (think empty easter eggs) that I was going to put a nano in and a sound detector and was just hoping to just get it to move.  I prefer a sort of a tilt left and right effect, but if it just rolls randomly that would work as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking just a simple vibration, but it doesn't really shift the ball at all, so I'm at a loss without building something quite complex with magnets or something.  Perhaps a motor stuck to the side?&lt;/p&gt;&#xA;" OwnerUserId="18989" LastEditorUserId="6936" LastEditDate="2016-03-06T21:33:43.377" LastActivityDate="2016-07-27T19:34:48.453" Title="What type of hardware could make a ball tilt or roll?" Tags="|arduino-nano|" AnswerCount="4" CommentCount="3" ClosedDate="2016-08-09T04:02:53.030" ContentLicense="CC BY-SA 3.0" />
  <row Id="21445" PostTypeId="2" ParentId="21324" CreationDate="2016-03-06T02:05:36.933" Score="5" Body="&lt;p&gt;You have a couple of problems (although the lack of pull-up resistors is not one of them, because the board you linked has pull-up resistors on it).&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The DS1307 needs to operate at a minimum of 4.5 volts, so you can't connect it to the 3.3V pin on the Due. (You need to supply it with 5V).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;However the Due is a 3.3V device on its data pins, and thus you can't connect the DS1307 directly to SDA/SDL or you will damage the Due.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus you need to supply the clock board with 5V, and use a bi-directional logic-level converter, such as this (using two logic-level MOSFETs):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rkj8N.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rkj8N.png&quot; alt=&quot;Logic level converter&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can buy level-converter boards, but as you can see, one is easy enough to make up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the clock chip runs at 5V, but the logic levels are converted to 3.3V for the Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this with mine, and it worked OK.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 myclock;&#xA;&#xA;void setup () {&#xA;    Serial.begin(115200);&#xA;    Wire.begin();&#xA;    myclock.begin();&#xA;}&#xA;&#xA;void loop () {&#xA;    DateTime now = myclock.now();&#xA;&#xA;    Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(' ');&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;&#xA;    Serial.print(&quot; since midnight 1/1/1970 = &quot;);&#xA;    Serial.print(now.unixtime());&#xA;    Serial.print(&quot;s = &quot;);&#xA;    Serial.print(now.unixtime() / 86400L);&#xA;    Serial.println(&quot;d&quot;);&#xA;&#xA;    Serial.println();&#xA;    delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;2016/3/6 12:0:20&#xA; since midnight 1/1/1970 = 1457265620s = 16866d&#xA;&#xA;2016/3/6 12:0:23&#xA; since midnight 1/1/1970 = 1457265623s = 16866d&#xA;&#xA;2016/3/6 12:0:26&#xA; since midnight 1/1/1970 = 1457265626s = 16866d&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;A useful technique for debugging is to run the &quot;I2C scanner&quot; I have on my &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C page&lt;/a&gt;. The code is:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// I2C Scanner&amp;lt;!-- language-all: lang-none --&amp;gt;&#xA;// Written by Nick Gammon&#xA;// Date: 20th April 2011&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Serial.begin (115200);&#xA;&#xA;  // Leonardo: wait for serial port to connect&#xA;  while (!Serial) &#xA;    {&#xA;    }&#xA;&#xA;  Serial.println ();&#xA;  Serial.println (&quot;I2C scanner. Scanning ...&quot;);&#xA;  byte count = 0;&#xA;&#xA;  Wire.begin();&#xA;  for (byte i = 8; i &amp;lt; 120; i++)&#xA;  {&#xA;    Wire.beginTransmission (i);&#xA;    if (Wire.endTransmission () == 0)&#xA;      {&#xA;      Serial.print (&quot;Found address: &quot;);&#xA;      Serial.print (i, DEC);&#xA;      Serial.print (&quot; (0x&quot;);&#xA;      Serial.print (i, HEX);&#xA;      Serial.println (&quot;)&quot;);&#xA;      count++;&#xA;      delay (1);  // maybe unneeded?&#xA;      } // end of good response&#xA;  } // end of for loop&#xA;  Serial.println (&quot;Done.&quot;);&#xA;  Serial.print (&quot;Found &quot;);&#xA;  Serial.print (count, DEC);&#xA;  Serial.println (&quot; device(s).&quot;);&#xA;}  // end of setup&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you don't see your device appear in the Serial Monitor, there is no point wondering why the date doesn't change, because it hasn't found the clock at all. You should see something like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;I2C scanner. Scanning ...&#xA;Found address: 104 (0x68)&#xA;Done.&#xA;Found 1 device(s).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;How the level converter works&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;For more information, read the &lt;a href=&quot;http://cdn.sparkfun.com/tutorialimages/BD-LogicLevelConverter/an97055.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Philips Application Note AN97055&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In brief (taking SDA as an example):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If neither side is driving SDA low, then V&lt;sub&gt;GS&lt;/sub&gt; is zero (they are both 3.3V) and the MOSFET does not conduct. Hence each side is &quot;pulled-up&quot; to their respective voltages. The low side is pulled up to 3.3V and the high side is pulled up to 5V.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the low side drives SDA low, then V&lt;sub&gt;GS&lt;/sub&gt; is 3.3V which is high enough for the MOSFET to conduct. Since it conducts it also drags the high side low as well (overpowering the 10k pull-up resistor).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the high side drives SDA low, current initially flows through the drain substrate diode of the MOSFET (it will be a diode drop above 0V, namely 0.7V), lowering the voltage at the source, until V&lt;sub&gt;GS&lt;/sub&gt; is high enough for the MOSFET to conduct. Once it starts conducting then the low side is pulled further lower.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do you have an actual photograph of this? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've pulled it all apart days ago, however thankfully I took a snapshot before I did.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QGg5i.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QGg5i.jpg&quot; alt=&quot;Photo of schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be honest, the schematic is easier to follow. When looking at photos it can be hard to see exactly what is plugged into where.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-22T06:41:13.787" LastActivityDate="2016-03-22T06:41:13.787" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21446" PostTypeId="1" CreationDate="2016-03-06T02:12:01.183" Score="-1" ViewCount="4287" Body="&lt;p&gt;I'm making a posture control experiment in which a series of images (stimuli) are presented to a person and I'm trying to measure the displacement of this person as a result of these stimuli. To do so I'm planning to use 3 Arduinos:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &quot;Arduino Tx 1&quot;: an Arduino nano with an Xbee shield and an MPU unit attached for sensing displacement. This implementation has to be wireless because the subject must be able to move freely. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &quot;Arduino Tx 2&quot;: an arduino uno for reading an analog signal that indicates when an image (stimulus) is presented to the person&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) &quot;Arduino Rx&quot;: an arduino uno connected to a computer and reading data from both &quot;Arduino Tx 1&quot; and &quot;Arduino Tx 2&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to make sure that signals coming from &quot;Arduino Tx 1&quot; and &quot;Arduino Tx 2&quot; are synchronised. That is: if an image is presented at &lt;em&gt;t=t0&lt;/em&gt; (signal sensed by &quot;Arduino Tx 2&quot;) then I want to be able to tell that the displacement sensed by &quot;Arduino Tx 1&quot; at &lt;em&gt;t=t0+dt&lt;/em&gt; corresponds to this stimulus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: is it possible to ensure that signals coming from &quot;Arduino Tx 1&quot; and &quot;Arduino Tx 2&quot; are synchronised when read by &quot;Arduino Rx&quot;?&lt;/p&gt;&#xA;" OwnerUserId="18990" LastActivityDate="2021-08-08T02:01:25.143" Title="How to sync multiple arduinos?" Tags="|arduino-uno|arduino-nano|xbee|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21447" PostTypeId="2" ParentId="21433" CreationDate="2016-03-06T02:24:30.307" Score="2" Body="&lt;p&gt;I have a bootloader-programmer sketch here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/bootloader&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you connect up the boards like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino Uno         Target ATmega168PA&#xA;&#xA;D10 (SS)            Reset (pin 1)&#xA;D11 (MOSI)          MOSI  (pin 17)&#xA;D12 (MISO)          MISO  (pin 18)&#xA;D13 (SCK)           SCK   (pin 19)&#xA;&#xA;Gnd                 Gnd   (pins 8 &amp;amp; 22)&#xA;+5V                 +5V   (pins 7 &amp;amp; 20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then download the sketch from &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt; - the one you want is in the &lt;strong&gt;Atmega_Board_Programmer&lt;/strong&gt; folder. Run that and follow the instructions in the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information see the link above.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="6936" LastEditDate="2016-03-06T21:38:47.787" LastActivityDate="2016-03-06T21:38:47.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21448" PostTypeId="1" CreationDate="2016-03-06T03:18:14.500" Score="0" ViewCount="326" Body="&lt;p&gt;I have the ground for an SD card module, LED, and piezo sensor all plugged into the same ground rail. When doing this I get a low &quot;hum&quot; in the piezo readings where instead of reading ground voltage (0) when there's no vibration, it cycles between 4 and 6. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I switch the piezo's ground onto ground rail connected to different ground pin on my Arduino, the hum goes away. If I keep the piezo on original ground and move the SD card module's ground, the hum comes back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very new to electronics, so I'm wonder what's going on? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Here's a diagram of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4ji8K.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4ji8K.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18992" LastEditorUserId="18992" LastEditDate="2016-03-06T06:02:50.713" LastActivityDate="2019-12-18T18:03:05.697" Title="Why does analog sensor &quot;hum&quot; when plugged into common ground?" Tags="|analogread|sd-card|piezo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21450" PostTypeId="1" CreationDate="2016-03-06T04:41:43.787" Score="-2" ViewCount="156" Body="&lt;p&gt;I want to control arduino through Internet without using Ethernet shield. I know there is a way. So can you help me what things I'll be needing for that&lt;/p&gt;&#xA;" OwnerUserId="18794" LastActivityDate="2016-03-06T05:12:19.073" Title="Controlling arduino over webserver" Tags="|ethernet|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21451" PostTypeId="2" ParentId="21450" CreationDate="2016-03-06T05:12:19.073" Score="3" Body="&lt;p&gt;This is incredibly broad: you could use an Arduino Ethernet, which has built in Ethernet, or you could use an ENC28J60 Ethernet module, or any of the many, many WiFi peripherals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, consider using the ESP8266, instead of an Arduino with an Ethernet/WiFi peripheral. The ESP8266 can be programmed directly from the Arduino IDE with Arduino-style syntax, and can also run the NodeMCU firmware (programmed in Lua).&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-03-06T05:12:19.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21452" PostTypeId="1" CreationDate="2016-03-06T06:01:41.907" Score="2" ViewCount="172" Body="&lt;p&gt;I have &lt;a href=&quot;http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0&quot; rel=&quot;nofollow&quot;&gt;GSM shield&lt;/a&gt; (and Arduino UNO) works fine with &lt;a href=&quot;https://github.com/Seeed-Studio/GPRS_SIM900&quot; rel=&quot;nofollow&quot;&gt;this code&lt;/a&gt; :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GPRS_Shield_Arduino.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Suli.h&amp;gt;&#xA;&#xA;#define PIN_TX    7&#xA;#define PIN_RX    8&#xA;#define BAUDRATE  9600&#xA;&#xA;#define MESSAGE_LENGTH 160&#xA;char message[MESSAGE_LENGTH];&#xA;int messageIndex = 0;&#xA;&#xA;char phone[16];&#xA;char datetime[24];&#xA;&#xA;GPRS gprsTest(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,PWR,BaudRate&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while(0 != gprsTest.init()) {&#xA;      delay(1000);&#xA;      Serial.print(&quot;init error\r\n&quot;);&#xA;  }&#xA;  delay(3000);  &#xA;  Serial.println(&quot;Init Success, please send SMS message to me!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   messageIndex = gprsTest.isSMSunread();&#xA;   if (messageIndex &amp;gt; 0) { //At least, there is one UNREAD SMS&#xA;      gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);           &#xA;      //In order not to full SIM Memory, is better to delete it&#xA;      gprsTest.deleteSMS(messageIndex);&#xA;      Serial.print(&quot;From number: &quot;);&#xA;      Serial.println(phone);  &#xA;      Serial.print(&quot;Datetime: &quot;);&#xA;      Serial.println(datetime);        &#xA;      Serial.print(&quot;Recieved Message: &quot;);&#xA;      Serial.println(message);   &#xA;      String msassages = message;&#xA;        if(msassages == &quot;Hello&quot;){&#xA;          gprsTest.sendSMS(phone,&quot;hello to you&quot;);&#xA;        }&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After adding &lt;code&gt;#include &amp;lt;TinyGPS.h&amp;gt; ;&lt;/code&gt;  it works fine too but after adding &lt;code&gt;TinyGPS gps;&lt;/code&gt; (&lt;strong&gt;and nothing else&lt;/strong&gt;) to the code header, everything stop working and i can't see anything in terminal and the program stop sending SMS back. I should mention , TinyGPS works fine individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why this happen ?&lt;/p&gt;&#xA;" OwnerUserId="18777" LastEditorUserId="18777" LastEditDate="2016-03-06T06:11:41.533" LastActivityDate="2016-03-06T06:11:41.533" Title="Why After instancing TinyGPS , serial stop working?" Tags="|arduino-uno|gsm|softwareserial|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21454" PostTypeId="1" AcceptedAnswerId="21495" CreationDate="2016-03-06T08:55:30.647" Score="0" ViewCount="782" Body="&lt;p&gt;I am a new learner on Arduino. I am trying to learn how to control the LCD. I looked in the article, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/HelloWorld&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Hello World!&quot;&lt;/a&gt;, and followed the instructions but it did not work (I checked it many times). The result I got is shown below (the text is not showing). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me. Any help is appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qRxNR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qRxNR.jpg&quot; alt=&quot;Photo of LCD not displaying correctly&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;    #include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;    LiquidCrystal lcd(12, 11, 5,4,3,2);&#xA;&#xA;    void setup() {&#xA;      // set up the LCD's number of columns and rows:&#xA;     lcd.begin(16, 2);&#xA;&#xA;    lcd.print(&quot;hello, world!&quot;);&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // set the cursor to column 0, line 1&#xA;      // (note: line 1 is the second row, since counting begins with 0):&#xA;      lcd.setCursor(0, 1);&#xA;      // print the number of seconds since reset:&#xA;      lcd.print(millis() / 1000);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18999" LastEditorUserId="6936" LastEditDate="2016-03-06T21:28:20.203" LastActivityDate="2016-03-07T02:49:54.507" Title="LCD not working with Arduino Uno" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21456" PostTypeId="1" CreationDate="2016-03-06T09:05:25.687" Score="0" ViewCount="673" Body="&lt;p&gt;I am trying to check whether the input string in my serial is inside my string array, but it seems like that the condition if(array[i]==inputString) does not print true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String array[4]={&quot;hey&quot;,&quot;jude&quot;,&quot;jane&quot;},inputString,test;&#xA;boolean stringComplete=false;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  //int store=0;&#xA;  serialEvent();&#xA;  if(stringComplete){&#xA;    Serial.println(inputString);&#xA;    for(int i=0;i&amp;lt;4;i++){&#xA;      Serial.println(&quot;..&quot;);&#xA;      //test=array[i];&#xA;      Serial.println(array[i]);&#xA;      if(inputString==array[i]){&#xA;        Serial.println(&quot;true&quot;);&#xA;        break;&#xA;      }&#xA;    }&#xA;  inputString=&quot;&quot;;&#xA;  stringComplete=false;&#xA;  }&#xA;   //Serial.println(store);&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available()) {&#xA;    char inChar = (char)Serial.read();&#xA;    inputString += inChar;&#xA;    if (inChar == '\n') {&#xA;      stringComplete = true;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19000" LastEditorUserId="10794" LastEditDate="2016-03-06T20:50:19.543" LastActivityDate="2020-10-31T03:03:45.357" Title="Arduino serial communication input string checking" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21457" PostTypeId="1" CreationDate="2016-03-06T09:41:24.013" Score="0" ViewCount="294" Body="&lt;p&gt;I have created an app which is connencted to my arduino via bluetoth. The user of the app can turn on and off a led which is connented to the arduino. But I want to take it a step further... I want the user to be able to give the time and the date when the light should turn on and additionally the time that sould pass until the led turns off again. Is it significantly harder? I have thought of using an already existing alarm app but I am pretty stuck, so could anyone give me some suggestions? &lt;/p&gt;&#xA;" OwnerUserId="19002" LastActivityDate="2016-03-06T14:48:53.873" Title="Picking the time a led on an arduino should turn on, via android" Tags="|timers|time|android|arduino-mini|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21458" PostTypeId="2" ParentId="21456" CreationDate="2016-03-06T09:59:21.197" Score="1" Body="&lt;p&gt;First, you declare an array of 4 items and provide an initializer for 3. Don't know how it can even compile, maybe it is tolerated but in doubt&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String [] array = {&quot;hey&quot;,&quot;jude&quot;,&quot;jane&quot;,&quot;foo&quot;}; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, your serialEvent function appends &lt;code&gt;\n&lt;/code&gt; to the string. Even if you receive string jane, you will compare &lt;code&gt;jane&lt;/code&gt; from array with &lt;code&gt;jane\n&lt;/code&gt; from serial&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char inChar = (char)Serial.read();&#xA;if( inChar == '\n')&#xA;   stringComplete = true;&#xA;else&#xA;   inputString += inChar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17188" LastActivityDate="2016-03-06T09:59:21.197" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21460" PostTypeId="1" CreationDate="2016-03-06T11:32:02.857" Score="-3" ViewCount="344" Body="&lt;p&gt;I need have two stepping motors working at the same time each with a different number of steps. But loops (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;) don't work with this task using type of interrupt above. What is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sr3Sg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sr3Sg.jpg&quot; alt=&quot;Screenshot of update function&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Driver {&#xA;    int pinStep;&#xA;    long times;&#xA;    int state;&#xA;    unsigned long previousTime;&#xA;&#xA;  public:&#xA;    Driver(int pin, long interval) {&#xA;      pinStep = pin;&#xA;      pinMode(pinStep, OUTPUT);&#xA;      times = interval;&#xA;      state = LOW;&#xA;      previousTime = 0;&#xA;    }&#xA;&#xA;    void update(unsigned long currentTime) {&#xA;      int iteration;&#xA;      while ((iteration &amp;lt; 5) &amp;amp; (currentTime - previousTime &amp;gt;= times)) {&#xA;        previousTime = currentTime;&#xA;        if (state == LOW) {&#xA;          state = HIGH;&#xA;        } else {&#xA;          state = LOW;&#xA;        }&#xA;        digitalWrite(pinStep, state);&#xA;        iteration++;&#xA;      }&#xA;    }&#xA;};&#xA;&#xA;Driver drv1(5, 2);&#xA;Driver drv2(7, 50);&#xA;&#xA;// set timer behavior&#xA;void setup() {&#xA;  OCR0A = 0x80; // 128&#xA;  TIMSK0 |= _BV(OCIE0A);&#xA;}&#xA;&#xA;// interrupt handler&#xA;SIGNAL(TIMER0_COMPA_vect) {&#xA;  unsigned long currentTime = millis();&#xA;  drv1.update(currentTime);&#xA;  drv2.update(currentTime);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19005" LastEditorUserId="6936" LastEditDate="2016-03-16T07:58:16.793" LastActivityDate="2016-03-16T07:58:16.793" Title="Why doesn't interrupt TIMER0_COMPA work with loops?" Tags="|c++|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21462" PostTypeId="2" ParentId="21446" CreationDate="2016-03-06T14:04:46.353" Score="0" Body="&lt;p&gt;Have TX2 also emit an infrared pulse that initiates the timing reported by TX1.  TX1 should report dt rather than t_tx1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The common real-time clocks for for Arduino report at 1 second resolution, which does not sound as if it is accurate enough for your needs.  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-06T14:04:46.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21463" PostTypeId="2" ParentId="21444" CreationDate="2016-03-06T14:13:55.010" Score="0" Body="&lt;p&gt;Maybe some sort of bristlebot?  Try a &lt;a href=&quot;https://www.hexbug.com/nano&quot; rel=&quot;nofollow&quot;&gt;hexbug nano&lt;/a&gt; and see if it behaves acceptably.  The key behind them is a vibrating motor on top of a biased bristle that turns the vibration into a biased motion.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-06T23:48:56.463" LastActivityDate="2016-03-06T23:48:56.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21464" PostTypeId="2" ParentId="21457" CreationDate="2016-03-06T14:48:53.873" Score="1" Body="&lt;p&gt;Make the Bluetooth message send how many seconds it is until the light should be on, and how many seconds it should stay on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the arduino code can just handle everything with millis(). You know the millis() you were asked to start, add the delay, and wait for that time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Delays less than 50 days (wrap around of millis ())  take no effort to handle it you embrace the overflow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Handling delays greater than 50 days can be achieved by watching for millis() overflows and counting them. You could also make your own timer based counter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If&lt;/em&gt; you care about recovery after power loss / reset you could use an RTC module. Depending on its complexity, it could interrupt you or you poll it to check for a date you saved to Arduino eeprom.  You would have to consider what the system should do it the alarm would have happened during the power loss...&lt;/p&gt;&#xA;" OwnerUserId="10827" LastActivityDate="2016-03-06T14:48:53.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21467" PostTypeId="2" ParentId="21434" CreationDate="2016-03-06T15:29:49.180" Score="0" Body="&lt;p&gt;You need to use INPUT_PULLUP pin mode and connect the buttons between the pins and ground.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(5, INPUT_PULLUP);&#xA;pinMode(7, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Later on you will also have to debounce the button but that is another question (where you can find plenty of answers already). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-06T15:29:49.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21468" PostTypeId="1" AcceptedAnswerId="21469" CreationDate="2016-03-06T16:38:00.230" Score="0" ViewCount="382" Body="&lt;p&gt;I have a PPD42NS dust sensor I'd like to hook up to an ESP8266-01 microcontroller. The ESP8266 uses 3.3v logic, but the PPD42NS uses 5v. The PPD42NS uses low pulse occupancy as output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to use parts I have on hand, and I was wondering if a simple voltage divider built from 2 resistors can reliably shift the voltage without distorting the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, could an NPN transistor do the job instead?&lt;/p&gt;&#xA;" OwnerUserId="18992" LastActivityDate="2016-03-07T07:57:40.143" Title="Low-Pulse Occupancy and Voltage Divider" Tags="|esp8266|voltage-level|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21469" PostTypeId="2" ParentId="21468" CreationDate="2016-03-06T17:46:43.730" Score="0" Body="&lt;p&gt;While the PPD42NS has a 5-pin connector, it is shown at &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor&quot; rel=&quot;nofollow&quot;&gt;seeedstudio.com&lt;/a&gt; and &lt;a href=&quot;http://www.howmuchsnow.com/arduino/airquality/grovedust/&quot; rel=&quot;nofollow&quot;&gt;howmuchsnow.com&lt;/a&gt; connected up with three wires: +5V, Ground, and an LPO or “Low Occupancy Output” signal, which goes low when a particle occludes an LED beam path.  LPO is used as an input to let sketches measure the fraction of time the beam's  occluded, which correlates with number of dust particles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, a resistive voltage divider will let you use the 0-to-5V occupancy signal as an input to your 3.3V-tolerant ESP8266. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What values of resistors should be used?  Because input pin capacitance is small (eg under 10 pF), signal &quot;crispness&quot; should be about the same over a broad range of resistances – say from a 100Ω+200Ω divider up past 1KΩ+2KΩ;  even 10KΩ+20KΩ might be ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.seeedstudio.com/wiki/images/4/4c/Grove_-_Dust_sensor.pdf&quot; rel=&quot;nofollow&quot;&gt;Grove_-_Dust_sensor.pdf&lt;/a&gt; data sheet at seeedstudio.com says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Output Method  Negative Logic, Digital output,&lt;br&gt;&#xA;  Hi : over 4.0V(Rev.2) Lo : under 0.7V&lt;br&gt;&#xA;  (As Input impedance : 200kΩ) OP-Amp output, Pull-up resistor : 10kΩ&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This suggests (but doesn't clearly indicate) that some sort of open-drain output might be used.  If so, instead of using a voltage divider one could remove the 10kΩ pull-up on the sensor, and pull the output to 3.3 V instead of 5 V, via either an external resistor or using an INPUT_PULLUP pinmode setting (if available on the ESP8266).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Regarding the comment, “I'm considering use it in conjunction with an MCP23017 I/O expander IC. The GPIO pins on the chip appear to be rated at a max capacitance of 50 pF. Will that affect the range of resistors available? How does resistor choice affect the crispness of the signal, and how can I determine it for myself?”:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The “max capacitance of 50 pF” spec, which is parameter D101 in table 2.1 of the MCP23017 spec sheet, refers to “Capacitive Loading Specs on Output Pins”, ie, how much capacitance MCP23017 outputs can drive.  It doesn't refer to input pin capacitance, so isn't relevant here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, when a signal edge (a rise or fall) arrives at an input pin, the input pin's voltage doesn't change instantaneously.  The input pin's capacitance needs to charge or discharge.  (It charges for a rising edge, discharges for a falling edge.)  The speed of change depends on the RC time constant of the circuit.  A delay occurs, probably 1–3 time constants long, before the pin starts to switch.  (The switch may take a few tens or hundreds of nanoseconds.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if input circuit capacitance is 10 pF and its effective resistance is 100kΩ, RC = 10 pF · 100kΩ = 10⁻¹¹·10⁵ = 10⁻⁶ seconds = 1 microsecond.  Whether that's large enough to matter for your measurements depends on how many time constants have to occur before the pin starts switching, and on how narrow the LPO signals are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, compute RC, and if it's more than a few microseconds, use a smaller value of R.  Alternately, if you have access to an oscilloscope, attach it to the input and try various resistance values in the voltage divider, to get a feel for how the signals degrade as the resistors in the divider get bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, using a voltage divider causes different RC values for falling edges than for rising edges.  For example, suppose an actively driven 0-5V signal enters a divider with 10KΩ in series with 20KΩ, and the 0-3.3 V signal is taken from the resistors' junction.  Then R is 10KΩ for a rising edge, and 20KΩ for a falling edge.  If the 0-5V signal weren't actively driven high, but instead pulled up via a pullup resistor R' when a transistor turns off, then the rising edge R value would be R'+10KΩ for this example.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-07T07:57:40.143" LastActivityDate="2016-03-07T07:57:40.143" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21470" PostTypeId="1" AcceptedAnswerId="21502" CreationDate="2016-03-06T17:49:57.950" Score="0" ViewCount="699" Body="&lt;p&gt;Friends, my team and I are working on a gsm based wireless display as a part of our project. We are using Arduino UNO as the microcontroller which is interfaced with a sim900 module. Upon arrival of a new sms in the gsm module, its contents will be passed on to the dot matrix led display through SoftwareSerial. We almost got the code working but the problem we now encounter is the reception of new sms. The code works fine for the first sms but to display the next new sms, we had to manually reset the Arduino every time. Can you guys help me? This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;      &#xA;#include &amp;lt;DMD.h&amp;gt;        &#xA;#include &amp;lt;TimerOne.h&amp;gt;   &#xA;#include &quot;SystemFont5x7.h&quot;&#xA;#include &quot;Arial_black_16.h&quot;&#xA;&#xA;#define DISPLAYS_ACROSS 1&#xA;#define DISPLAYS_DOWN 1&#xA;DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);&#xA;&#xA;int temp=0,i=0,x=0,k=0;&#xA;char str[160],msg[160];&#xA;void ScanDMD()&#xA;{ &#xA;  dmd.scanDisplayBySPI();&#xA;}&#xA;&#xA;SoftwareSerial SIM900(0, 1);&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;&#xA;   Timer1.initialize( 5000 );          &#xA;   Timer1.attachInterrupt( ScanDMD );   &#xA;&#xA;&#xA;   dmd.clearScreen( true );   &#xA;   Serial.begin(9600); &#xA;&#xA;   SIM900.begin(9600); &#xA;   void SIM900power();&#xA;   delay(20000);  &#xA;&#xA;     SIM900.print(&quot;AT+CMGF=1\r&quot;);  &#xA;  delay(100);&#xA;  SIM900.print(&quot;AT+CNMI=2,2,0,0,0\r&quot;); &#xA;  delay(100);  &#xA;}&#xA;&#xA;  void SIM900power()&#xA;&#xA;{&#xA;  digitalWrite(9, HIGH);&#xA;  delay(1000);&#xA;  digitalWrite(9, LOW);&#xA;  delay(7000);&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;for(unsigned int t=0;t&amp;lt;60000;t++){&#xA;  void serialEvent();&#xA;  if(temp==1)&#xA;  {&#xA;    x=0,k=0,temp=0;&#xA;    while(x&amp;lt;i)&#xA;    {&#xA;      while(str=='#')&#xA;&#xA;      {&#xA;        x++;&#xA;        while(str!='*')&#xA;&#xA;        {&#xA;          msg[k++]=str[x++];&#xA;        }&#xA;      }&#xA;      x++;&#xA;    }&#xA;   }&#xA;  }&#xA;     const char* dchars;&#xA;      dchars=msg;&#xA;     dmd.clearScreen( true );&#xA;   dmd.selectFont(Arial_Black_16);&#xA;&#xA;  for(unsigned int i=0;i&amp;lt;=300;i++){&#xA;   dmd.drawMarquee(dchars,strlen(dchars),(32*DISPLAYS_ACROSS)-1,0);&#xA;   long start=millis();&#xA;   long timer=start;&#xA;   boolean ret=false;&#xA;   while(!ret){&#xA;     if ((timer+30) &amp;lt; millis()){&#xA;       ret=dmd.stepMarquee(-1,0);&#xA;       timer=millis();&#xA;     }&#xA;   }&#xA; }&#xA;}&#xA;&#xA;void serialEvent(){ &#xA;  while(Serial.available())&#xA;  {&#xA;    char ch=(char)Serial.read();&#xA;    str[i++]=ch;&#xA;    if(ch == '*')&#xA;    {&#xA;      temp=1;&#xA;    }&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The DMD library was found on the net.&lt;/p&gt;&#xA;" OwnerUserId="19010" LastEditorUserId="6628" LastEditDate="2016-03-07T08:58:08.947" LastActivityDate="2016-03-07T08:58:08.947" Title="Arduino hangs on second GSM message (was GSM based led matrix display)" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21471" PostTypeId="1" CreationDate="2016-03-06T17:58:56.937" Score="1" ViewCount="430" Body="&lt;p&gt;So playing around with an arduino uno, I was powering it with a 12volt battery (putting power between Vin and Gnd) and I fat fingered the battery terminals, putting them in reverse (oops)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see smoke coming out of the 5 volt regulator (the little 3 pin IC). I immediately pull out the battery thinking I've just bricked this thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a minute or two I plug the battery in again (taking care to plug it in straight this time) and to my surprise it works, works pretty well. The last sketch I uploaded works perfectly fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using the same thing for an hour or so. But now I wanted to upload another sketch and it doesn't upload. The voltages seem to be fine, I'm putting in 11.8 volts on Vin, there is 5.12 volts on 5v and 3.34 volts on 3v3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought there may be some problem with the voltage regulator, so I tried connecting it directly to the USB (powering it from USB) but still the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find it intriguing that it works perfectly for everything except uploading new sketches, especially after such an explosive oopsie. Can any of you chaps deduce what the problem might be? I have a USBasp module so I can reburn the bootloader, but I doubt that's the problem. &lt;/p&gt;&#xA;" OwnerUserId="18961" LastActivityDate="2016-03-06T18:17:08.680" Title="Unable to upload sketches after little oopsie (reversed input polarity)" Tags="|arduino-uno|power|uploading|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21473" PostTypeId="2" ParentId="21471" CreationDate="2016-03-06T18:17:08.680" Score="2" Body="&lt;p&gt;The atmega328 that runs the sketch is fine, but the communication is broken somehow.  See the steps in &lt;a href=&quot;https://arduino.stackexchange.com/a/13293/6628&quot;&gt;https://arduino.stackexchange.com/a/13293/6628&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-06T18:17:08.680" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21474" PostTypeId="1" AcceptedAnswerId="21475" CreationDate="2016-03-06T18:26:06.870" Score="0" ViewCount="1213" Body="&lt;p&gt;I have an Arduino Nano with two attached Motion sensors &lt;strong&gt;&quot;PIXNOR HC-SR501&quot;&lt;/strong&gt;. This sensor puts 5V on its middle Pin, when it detects motion. I have connected this Pin to my Arduino and read the value with &lt;code&gt;digitalRead&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the simplified code of my loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    motion1 = digitalRead(motion_pin1);&#xA;    motion2 = digitalRead(motion_pin2);&#xA;&#xA;    if(motion1== HIGH) {&#xA;      if(debug){&#xA;        Serial.println(&quot;Motion 1&quot;);&#xA;      }&#xA;    }&#xA;    if(motion2== HIGH) {&#xA;      if(debug){&#xA;        Serial.println(&quot;Motion 2&quot;);&#xA;      }&#xA;    }&#xA;&#xA;    // Wait 1,0 Second&#xA;    Sleepy::loseSomeTime(1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Problem is... This used to work fine, but I had to extend the cable to the motion sensors from ~10 cm to 500 cm. Now I have the problem, that the Arduino sometimes (quite often) detects voltage on the motion pins, although there is no motion. I guess the Input-pins are is too sensitive? &#xA;&lt;strong&gt;What can I do to prevent this flickering?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="15493" LastActivityDate="2016-03-06T19:24:25.853" Title="Digital Input with long cable - flickering values" Tags="|sensors|arduino-nano|input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21475" PostTypeId="2" ParentId="21474" CreationDate="2016-03-06T19:24:25.853" Score="3" Body="&lt;p&gt;That device (&lt;a href=&quot;https://www.mpja.com/download/31227sc.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;) puts out 3.3V on the OUT pin, not 5V:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;◦ TTL output: 3.3V, 0V&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The excess cable is most likely picking up EMI and creating spurious pulses on the input. There are two basic ways of combating this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Increase the drive strength (especially the sink capacity) of the output&lt;/li&gt;&#xA;&lt;li&gt;Implement a balanced line communication system&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can combine both those quite easily, whilst at the same time boosting the output voltage to 5V using a 74HCT04 hex inverter chip (make sure it's the HCT variant).  Powered from 5V it will boost the logic level from 3.3V to 5V, and it will have a greater drive strength than the PIR chip alone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the trick is to use multiple gates in the right way to make a crude balanced line system:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oFBRV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oFBRV.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you're double-inverting the signal so it remains the same logic level (high = high, low = low) but has higher drive strength, and you're also single-inverting the signal so it has inverted logic (high = low, low = high).  You then connect those to two different IO pins on the Arduino. Read both pins (instead of just one) and as long as the signal are opposite (Q = HIGH and !Q == LOW) then you have a valid signal. If both signals are HIGH then you have noise and you can ignore it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to ensure you select the right kind of cable. Ideally you need a cable with at least one twisted pair in it so that the Q and !Q signals are twined around each other. This ensures that if EMI is induced into the wire it's induced into both signals equally.  CAT5 Ethernet cable is often quite a good choice.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-06T19:24:25.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21476" PostTypeId="1" AcceptedAnswerId="21482" CreationDate="2016-03-06T19:55:49.133" Score="2" ViewCount="607" Body="&lt;p&gt;I am working on an Arduino Uno battle bot that uses a Sabertooth moter controller. Right now it is connected to the Arduino through Serial communication. Which is would be faster (So I can increase response time on my robot) Serial, or pwm using DigitalWrite?&lt;/p&gt;&#xA;" OwnerUserId="16094" LastActivityDate="2016-03-07T11:35:03.303" Title="Which is faster, Serial or DigitalWrite?" Tags="|arduino-uno|c++|motor|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21477" PostTypeId="1" CreationDate="2016-03-06T19:56:44.107" Score="0" ViewCount="85" Body="&lt;p&gt;Might someone shed some light on the 52 pin connectors on the end of the prototype board? Both boards have no 52 pin female connectors, the board that doesn't include the breadboard wire has a male connector that is not 52 pins. The female connectors are hard to find. I've only looked on Ebay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Gqh7S.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Gqh7S.jpg&quot; alt=&quot;no 52 pin connectors[![][1]&quot;&gt;&lt;/a&gt;]&lt;a href=&quot;https://i.stack.imgur.com/SRCjV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15103" LastActivityDate="2021-12-06T05:08:15.737" Title="Aurduino Mega prototype board connectors" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21478" PostTypeId="1" CreationDate="2016-03-06T20:05:06.240" Score="0" ViewCount="113" Body="&lt;p&gt;In the Arduino IDE on my RPi on the top there is a header that says, File, Edit, Tools and help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following a Magpi article it said to go to tools then serial port and change that depending on what board you use. The only problem is that it's not there, when I click tools I scroll down and there &lt;strong&gt;grayed out&lt;/strong&gt; it says, serial port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this grayed out? And why can I not change it? Also, what port should be used for an Uno?&lt;/p&gt;&#xA;" OwnerUserId="19014" LastEditorUserId="10794" LastEditDate="2016-03-07T08:57:23.340" LastActivityDate="2019-06-19T12:07:40.173" Title="serial port on RPi" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21480" PostTypeId="2" ParentId="21478" CreationDate="2016-03-06T20:19:10.667" Score="2" Body="&lt;p&gt;It's greyed out because it can't find any serial ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That could be because:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There aren't any detected (not got the right kernel modules loaded)&lt;/li&gt;&#xA;&lt;li&gt;You don't have permission to access the serial ports (are you in the &lt;code&gt;dialout&lt;/code&gt; group?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Have you followed the Linux installation instructions? &lt;a href=&quot;http://playground.arduino.cc/Linux/All&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Linux/All&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-06T20:19:10.667" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21481" PostTypeId="2" ParentId="21476" CreationDate="2016-03-06T20:30:23.887" Score="0" Body="&lt;p&gt;pwm is faster.&#xA;PWM is directly to the port. Serial goers to a buffer is send char by char and the receiver needs to wait for all the data to arrive.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-06T20:30:23.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21482" PostTypeId="2" ParentId="21476" CreationDate="2016-03-06T20:30:34.343" Score="2" Body="&lt;p&gt;Using &lt;code&gt;digitalWrite()&lt;/code&gt; is the slowest by far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using PWM could be the fastest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using Serial could be the fastest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PWM:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to filter the PWM output to be a smooth analogue signal for it to be of any use. The filtering adds an inherent sluggishness, or response time, to the system - the harder the filtering the slower the reaction to changes in the PWM duty cycle. Adjusting the filter component's values will give an optimum point between smoothness and response time. Bear in mind that the motors may respond erratically if there is insufficient damping of the signal. This will probably give the Sabertooth a hard time, too. The datasheet recommends are filter response time of greater than 1ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Serial:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are considering the 2x 60Amp version (thanks for adding plenty of information in the question, by the way) then the fastest baud rate is 384kbps - or 48k commands per second. The Arduino will of course not be churning data continuously because it'll be busy running the rest of the program, but using serial it is theoretically possible to send commands &lt;em&gt;faster than the motor controller's output PWM&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So which is faster?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No idea. Only you can determine this, and I doubt you'll be able to determine the answer without wasting your time on some experiments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motors will have an inherent mechanical dampening thus creating an overall bottleneck in the whole system response time. I can almost guarantee that both PWM and Serial methods will be much faster than the response time of the motors themselves.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastActivityDate="2016-03-06T20:30:34.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21483" PostTypeId="2" ParentId="21460" CreationDate="2016-03-06T20:44:07.527" Score="1" Body="&lt;pre&gt;&lt;code&gt;void update(unsigned long currentTime) {&#xA;      int iteration;&#xA;      while ((iteration &amp;lt; 5)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code take a variable with an undefined value (&lt;code&gt;iteration&lt;/code&gt;) and loops while it is less than 5. How is this useful? Perhaps set iteration to zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      int iteration = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But cycles (for, while) don't work with this task using type of interrupt above. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Please define what &quot;don't work&quot; means here. It does too much? Too little? Nothing at all?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And Serial.print prints out iteration value as &quot;111111&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The only way that could happen is if &lt;code&gt;currentTime - previousTime &amp;gt;= times&lt;/code&gt; is false. Which it would be.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  while ((iteration &amp;lt; 5) &amp;amp; (currentTime - previousTime &amp;gt;= times)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you mean: &lt;code&gt;currentTime - previousTime &amp;lt; times&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-07T07:03:22.240" LastActivityDate="2016-03-07T07:03:22.240" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21484" PostTypeId="1" AcceptedAnswerId="21487" CreationDate="2016-03-06T20:46:25.903" Score="0" ViewCount="261" Body="&lt;p&gt;I've used the piezo on other projects with no problem, but for some reason this project isn't working out so hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a photo of my current set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AF4VW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AF4VW.jpg&quot; alt=&quot;Uno layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the basic code that I presumed would make a sound, but no such luck.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {}&#xA;&#xA;void loop() { &#xA;  tone(12,260);&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Not sure where to begin debugging this...&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="4131" LastEditDate="2016-03-10T07:12:26.700" LastActivityDate="2016-03-10T07:12:26.700" Title="Piezo not making sound" Tags="|arduino-uno|piezo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21485" PostTypeId="2" ParentId="21477" CreationDate="2016-03-06T20:46:59.013" Score="1" Body="&lt;p&gt;I presume the pictured board has pins underneath (like an Arduino shield). It would be designed so you can stack more than one on top of each other.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-06T20:46:59.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21487" PostTypeId="2" ParentId="21484" CreationDate="2016-03-06T21:06:47.433" Score="4" Body="&lt;p&gt;As Majenko pointed out, the wires are not connected to the piezo.  By moving the piezo to the correct rails on the other side of the board, the circuit would be completed and the piezo should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; &#xA;Building on Nick Gammon's comment, the rows of each side of a breadboard are not connected (to allow DIP packages).&lt;/p&gt;&#xA;" OwnerUserId="19017" LastEditorUserId="19017" LastEditDate="2016-03-06T21:41:25.750" LastActivityDate="2016-03-06T21:41:25.750" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21488" PostTypeId="2" ParentId="21476" CreationDate="2016-03-06T21:12:29.993" Score="0" Body="&lt;p&gt;Both are (relatively) slow.  &lt;strong&gt;When speed is of the essence, use &#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;port manipulation&lt;/a&gt;.&lt;/strong&gt; This can execute a pin change as fast as a single clock cycle--&lt;em&gt;faster than any library.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="19017" LastEditorUserId="19017" LastEditDate="2016-03-07T00:06:43.913" LastActivityDate="2016-03-07T00:06:43.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21489" PostTypeId="1" AcceptedAnswerId="21497" CreationDate="2016-03-06T23:11:12.987" Score="0" ViewCount="2056" Body="&lt;p&gt;I am working on an IoT project to send data acquired from DHT11 and PulseSensor to a website. I can send the data properly when I use each of sensors alone but when I write a wrapper to use both sensors simultaneously, DHT11 returns check-sum error. PulseSensor uses interrupt based on TIMER2 , whenever I remove interruptSetup(); from setup block the problem is solved but obviously the PulseSensor does not work in this case.&#xA;I searched inside the DHT11 library, as far as I could understand it does not use any Timer or interrupt to make a conflict with PulseSensor requirements. &#xA;This project use to serial port to communicate with PC for debugging and another one to communicate with ESP8266.&#xA;Please help me in finding a solution for this problem. Or guide me to websites that Arduino gurus track more :)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;dht.h&amp;gt;&#xA;&#xA;&#xA;dht DHT;&#xA;//DHT11 PIN&#xA;#define DHT11_PIN 5&#xA;// LED &#xA;int ledPin = 13;&#xA;&#xA;// Heart_Sensor_Variables&#xA;int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0&#xA;int blinkPin = 10;                // pin to blink led at each beat&#xA;&#xA;// Volatile Variables, used in the interrupt service routine!&#xA;volatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS&#xA;volatile int Signal;                // holds the incoming raw data&#xA;volatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded! &#xA;volatile boolean Pulse = false;     // &quot;True&quot; when User's live heartbeat is detected. &quot;False&quot; when not a &quot;live beat&quot;. &#xA;volatile boolean QS = false;        // becomes true when Arduoino finds a beat.&#xA;&#xA;//ISR variables&#xA;volatile int rate[10];                    // array to hold last ten IBI values&#xA;volatile unsigned long sampleCounter = 0;          // used to determine pulse timing&#xA;volatile unsigned long lastBeatTime = 0;           // used to find IBI&#xA;volatile int P =512;                      // used to find peak in pulse wave, seeded&#xA;volatile int T = 512;                     // used to find trough in pulse wave, seeded&#xA;volatile int thresh = 525;                // used to find instant moment of heart beat, seeded&#xA;volatile int amp = 100;                   // used to hold amplitude of pulse waveform, seeded&#xA;volatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM&#xA;volatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM&#xA;&#xA;//function Prototypes&#xA;void interruptSetup(void);&#xA;&#xA;//Thingspeak API key&#xA;String apiKey = &quot;REMOVED FOR SECURITY REASONS&quot;;&#xA;&#xA;// connect 11 to TX of Serial USB&#xA;// connect 12 to RX of serial USB&#xA;SoftwareSerial ser(11, 12); // RX, TX&#xA;&#xA;// this runs once&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(ledPin, OUTPUT);  &#xA;&#xA;&#xA;  // enable debug serial&#xA;  Serial.begin(57600); &#xA;  // enable software serial&#xA;  ser.begin(57600);&#xA;  // reset ESP8266&#xA;  Serial.println(&quot;AT+RST&quot;);&#xA;&#xA;  // sets up to read Pulse Sensor signal every 2mS           &#xA;   interruptSetup();  &#xA;}&#xA;&#xA;&#xA;// the loop &#xA;void loop() {&#xA;  // blink LED on board&#xA;  digitalWrite(ledPin, HIGH);   &#xA;  delay(200);               &#xA;  digitalWrite(ledPin, LOW);&#xA;&#xA;//Read DH11 Data&#xA;  int chk = DHT.read11(DHT11_PIN);&#xA;&#xA;// DISPLAY DATA&#xA;switch(chk) {&#xA;  case 0: ser.println(&quot;OK&quot;); break;&#xA;  case -1: ser.println(&quot;Checksum error!&quot;); break;&#xA;}&#xA;&#xA;  ser.print(DHT.humidity, 1);&#xA;  ser.print(&quot;,\t&quot;);&#xA;  ser.println(DHT.temperature, 1);&#xA;&#xA;&#xA;if (QS == true){     // A Heartbeat Was Found&#xA;  ser.println(&quot;BPM and IBI have been Determined&quot;);&#xA;  ser.println(BPM, 1);&#xA;  ser.println(IBI, 1);&#xA;&#xA;                       // BPM and IBI have been Determined&#xA;                       // Quantified Self &quot;QS&quot; true when arduino finds a heartbeat&#xA;        digitalWrite(blinkPin,HIGH);     // Blink LED, we got a beat. &#xA;&#xA;        QS = false;                      // reset the Quantified Self flag for next time    &#xA;  }&#xA;&#xA;  // TCP connection&#xA;  String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;  cmd += &quot;184.106.153.149&quot;; // api.thingspeak.com&#xA;  cmd += &quot;\&quot;,80&quot;;&#xA;  Serial.println(cmd);&#xA;  delay(1000);&#xA;&#xA;  if(Serial.find(&quot;Error&quot;)){&#xA;    ser.println(&quot;AT+CIPSTART error&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // prepare GET string&#xA;  String getStr = &quot;GET /update?api_key=&quot;;&#xA;  getStr += apiKey;&#xA;  getStr +=&quot;&amp;amp;field1=&quot;;&#xA;  getStr += String(DHT.humidity);&#xA;  getStr +=&quot;&amp;amp;field2=&quot;;&#xA;  getStr += String(DHT.temperature);&#xA;  getStr +=&quot;&amp;amp;field3=&quot;;&#xA;  getStr += String(BPM);&#xA;  getStr +=&quot;&amp;amp;field4=&quot;;&#xA;  getStr += String(IBI);&#xA;  getStr += &quot;\r\n\r\n&quot;;&#xA;&#xA;  // send data length&#xA;  cmd = &quot;AT+CIPSEND=&quot;;&#xA;  cmd += String(getStr.length());&#xA;  Serial.println(cmd);&#xA; delay(500);&#xA;  if(Serial.find(&quot;&amp;gt;&quot;)){&#xA;    Serial.print(getStr);&#xA;  }&#xA;  else{&#xA;    Serial.println(&quot;AT+CIPCLOSE&quot;);&#xA;    // alert user&#xA;    ser.println(&quot;AT+CIPCLOSE&quot;);&#xA;  }&#xA;&#xA;  // thingspeak needs 15 sec delay between updates&#xA;  delay(16000);&#xA;}&#xA;&#xA;&#xA;void interruptSetup(){     &#xA;  // Initializes Timer2 to throw an interrupt every 2mS.&#xA;  TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE&#xA;  TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER &#xA;  OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE&#xA;  TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A&#xA;  sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED      &#xA;} &#xA;&#xA;// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE. &#xA;// Timer 2 makes sure that we take a reading every 2 miliseconds&#xA;ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124&#xA;  cli();                                      // disable interrupts while we do this&#xA;  Signal = analogRead(pulsePin);              // read the Pulse Sensor &#xA;  sampleCounter += 2;                         // keep track of the time in mS with this variable&#xA;  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise&#xA;&#xA;    //  find the peak and trough of the pulse wave&#xA;  if(Signal &amp;lt; thresh &amp;amp;&amp;amp; N &amp;gt; (IBI/5)*3){       // avoid dichrotic noise by waiting 3/5 of last IBI&#xA;    if (Signal &amp;lt; T){                        // T is the trough&#xA;      T = Signal;                         // keep track of lowest point in pulse wave &#xA;    }&#xA;  }&#xA;&#xA;  if(Signal &amp;gt; thresh &amp;amp;&amp;amp; Signal &amp;gt; P){          // thresh condition helps avoid noise&#xA;    P = Signal;                             // P is the peak&#xA;  }                                        // keep track of highest point in pulse wave&#xA;&#xA;  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT&#xA;  // signal surges up in value every time there is a pulse&#xA;  if (N &amp;gt; 250){                                   // avoid high frequency noise&#xA;    if ( (Signal &amp;gt; thresh) &amp;amp;&amp;amp; (Pulse == false) &amp;amp;&amp;amp; (N &amp;gt; (IBI/5)*3) ){        &#xA;      Pulse = true;                               // set the Pulse flag when we think there is a pulse&#xA;      digitalWrite(blinkPin,HIGH);                // turn on pin 13 LED&#xA;      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS&#xA;      lastBeatTime = sampleCounter;               // keep track of time for next pulse&#xA;&#xA;      if(secondBeat){                        // if this is the second beat, if secondBeat == TRUE&#xA;        secondBeat = false;                  // clear secondBeat flag&#xA;        for(int i=0; i&amp;lt;=9; i++){             // seed the running total to get a realisitic BPM at startup&#xA;          rate[i] = IBI;                      &#xA;        }&#xA;      }&#xA;&#xA;      if(firstBeat){                         // if it's the first time we found a beat, if firstBeat == TRUE&#xA;        firstBeat = false;                   // clear firstBeat flag&#xA;        secondBeat = true;                   // set the second beat flag&#xA;        sei();                               // enable interrupts again&#xA;        return;                              // IBI value is unreliable so discard it&#xA;      }   &#xA;&#xA;&#xA;      // keep a running total of the last 10 IBI values&#xA;      word runningTotal = 0;                  // clear the runningTotal variable    &#xA;&#xA;      for(int i=0; i&amp;lt;=8; i++){                // shift data in the rate array&#xA;        rate[i] = rate[i+1];                  // and drop the oldest IBI value &#xA;        runningTotal += rate[i];              // add up the 9 oldest IBI values&#xA;      }&#xA;&#xA;      rate[9] = IBI;                          // add the latest IBI to the rate array&#xA;      runningTotal += rate[9];                // add the latest IBI to runningTotal&#xA;      runningTotal /= 10;                     // average the last 10 IBI values &#xA;      BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM!&#xA;      QS = true;                              // set Quantified Self flag &#xA;      // QS FLAG IS NOT CLEARED INSIDE THIS ISR&#xA;    }                       &#xA;  }&#xA;&#xA;  if (Signal &amp;lt; thresh &amp;amp;&amp;amp; Pulse == true){   // when the values are going down, the beat is over&#xA;   digitalWrite(blinkPin,LOW);            // turn off pin 13 LED&#xA;    Pulse = false;                         // reset the Pulse flag so we can do it again&#xA;    amp = P - T;                           // get amplitude of the pulse wave&#xA;    thresh = amp/2 + T;                    // set thresh at 50% of the amplitude&#xA;    P = thresh;                            // reset these for next time&#xA;    T = thresh;&#xA;  }&#xA;&#xA;  if (N &amp;gt; 2500){                           // if 2.5 seconds go by without a beat&#xA;    thresh = 512;                          // set thresh default&#xA;    P = 512;                               // set P default&#xA;    T = 512;                               // set T default&#xA;    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date        &#xA;    firstBeat = true;                      // set these to avoid noise&#xA;    secondBeat = false;                    // when we get the heartbeat back&#xA;  }&#xA;&#xA;  sei();                                   // enable interrupts when youre done!&#xA;}// end isr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11523" LastEditorUserId="4131" LastEditDate="2016-03-10T07:15:39.747" LastActivityDate="2016-03-10T20:57:07.650" Title="DHT11 and Pulse sensor incompatibility?" Tags="|sensors|interrupt|timers|temperature-sensor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21490" PostTypeId="1" CreationDate="2016-03-06T23:49:39.370" Score="1" ViewCount="9695" Body="&lt;p&gt;I have an &lt;a href=&quot;https://i.stack.imgur.com/oOtkU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Pro Mini&lt;/a&gt; that I use with a USBASP to program. These are actually a clone Pro Mini and a clone USBASP I'm using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this configuration, is it possible for me to access the serial port on the Arduino, through the USBASP, using the IDE serial terminal? If so, this would alleviate another connection to the computer for debugging. How to do this?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="18795" LastEditDate="2016-03-07T00:04:51.480" LastActivityDate="2018-05-06T01:37:49.990" Title="How to access serial terminal through USBASP?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21491" PostTypeId="1" AcceptedAnswerId="21501" CreationDate="2016-03-07T00:58:18.307" Score="0" ViewCount="534" Body="&lt;p&gt;I know similar questions to this have been asked before, but I have a &quot;resp=0x&lt;strong&gt;10&lt;/strong&gt;&quot; which I haven't found elsewhere, so maybe it's different, the board is also not an Arduino Uno although it's should be fully compatible with it in adition to the Bluetooth part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a beginner to Arduino (and electronics in general) and I bought a &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Bleduino board&lt;/a&gt;. It was working without problems, I've tested a servo and a DC motor (with a motors shield) without problems. But, it suddenly stopped working! I basically can't upload any sketch no matter what I try, giving me this error (10 attempts):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         Using Port                    : COM11&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 115200&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x10&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x10&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did try the reset button before uploading (actually tried both black and white reset buttons on this board), double checked I'm using the correct board and ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used an old 12V power supply with 1000mA, so maybe that damaged the main chip? The L and LINK LEDs light up though when connected to usb or jack, and the bluetooth also connects to the IOS App. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read [this][3] thorough answer for similar problems and my board passes the loopback test, but while uploading, only the L and RX LEDs flash!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have I damaged the main chip? Do I have to buy a AVR programmer and burn a new Bootloader?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A screenshot of wiring to test the Atmega16U2chip:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1LkXg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1LkXg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATmega328Pchip Response:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Atmega chip detector.        &#xA;Written by Nick Gammon.        &#xA;Version 1.18        &#xA;Compiled on Apr 10 2016 at 10:30:58 with Arduino IDE 10607.        &#xA;Attempting to enter ICSP programming mode ...        &#xA;Entered programming mode OK.        &#xA;Signature = 0x1E 0x95 0x0F         &#xA;Processor = ATmega328P        &#xA;Flash memory size = 32768 bytes.        &#xA;LFuse = 0xFF         &#xA;HFuse = 0xDE         &#xA;EFuse = 0xFF         &#xA;Lock byte = 0xFF         &#xA;Clock calibration = 0x96         &#xA;Bootloader in use: Yes        &#xA;EEPROM preserved through erase: No        &#xA;Watchdog timer always on: No        &#xA;Bootloader is 512 bytes starting at 7E00        &#xA;&#xA;Bootloader:        &#xA;&#xA;7E00: 0x11 0x24 0x84 0xB7 0x14 0xBE 0x81 0xFF 0xF0 0xD0 0x85 0xE0 0x80 0x93 0x81 0x00         &#xA;7E10: 0x82 0xE0 0x80 0x93 0xC0 0x00 0x88 0xE1 0x80 0x93 0xC1 0x00 0x86 0xE0 0x80 0x93         &#xA;7E20: 0xC2 0x00 0x80 0xE1 0x80 0x93 0xC4 0x00 0x8E 0xE0 0xC9 0xD0 0x25 0x9A 0x86 0xE0         &#xA;7E30: 0x20 0xE3 0x3C 0xEF 0x91 0xE0 0x30 0x93 0x85 0x00 0x20 0x93 0x84 0x00 0x96 0xBB         &#xA;7E40: 0xB0 0x9B 0xFE 0xCF 0x1D 0x9A 0xA8 0x95 0x81 0x50 0xA9 0xF7 0xCC 0x24 0xDD 0x24         &#xA;7E50: 0x88 0x24 0x83 0x94 0xB5 0xE0 0xAB 0x2E 0xA1 0xE1 0x9A 0x2E 0xF3 0xE0 0xBF 0x2E         &#xA;7E60: 0xA2 0xD0 0x81 0x34 0x61 0xF4 0x9F 0xD0 0x08 0x2F 0xAF 0xD0 0x02 0x38 0x11 0xF0         &#xA;7E70: 0x01 0x38 0x11 0xF4 0x84 0xE0 0x01 0xC0 0x83 0xE0 0x8D 0xD0 0x89 0xC0 0x82 0x34         &#xA;7E80: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7E90: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7EA0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7EB0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7EC0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7ED0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7EE0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7EF0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF         &#xA;7F00: 0xA6 0x01 0xA0 0xE0 0xB1 0xE0 0x2C 0x91 0x30 0xE0 0x11 0x96 0x8C 0x91 0x11 0x97         &#xA;7F10: 0x90 0xE0 0x98 0x2F 0x88 0x27 0x82 0x2B 0x93 0x2B 0x12 0x96 0xFA 0x01 0x0C 0x01         &#xA;7F20: 0x87 0xBE 0xE8 0x95 0x11 0x24 0x4E 0x5F 0x5F 0x4F 0xF1 0xE0 0xA0 0x38 0xBF 0x07         &#xA;7F30: 0x51 0xF7 0xF6 0x01 0xA7 0xBE 0xE8 0x95 0x07 0xB6 0x00 0xFC 0xFD 0xCF 0x97 0xBE         &#xA;7F40: 0xE8 0x95 0x26 0xC0 0x84 0x37 0xB1 0xF4 0x2E 0xD0 0x2D 0xD0 0xF8 0x2E 0x2B 0xD0         &#xA;7F50: 0x3C 0xD0 0xF6 0x01 0xEF 0x2C 0x8F 0x01 0x0F 0x5F 0x1F 0x4F 0x84 0x91 0x1B 0xD0         &#xA;7F60: 0xEA 0x94 0xF8 0x01 0xC1 0xF7 0x08 0x94 0xC1 0x1C 0xD1 0x1C 0xFA 0x94 0xCF 0x0C         &#xA;7F70: 0xD1 0x1C 0x0E 0xC0 0x85 0x37 0x39 0xF4 0x28 0xD0 0x8E 0xE1 0x0C 0xD0 0x85 0xE9         &#xA;7F80: 0x0A 0xD0 0x8F 0xE0 0x7A 0xCF 0x81 0x35 0x11 0xF4 0x88 0xE0 0x18 0xD0 0x1D 0xD0         &#xA;7F90: 0x80 0xE1 0x01 0xD0 0x65 0xCF 0x98 0x2F 0x80 0x91 0xC0 0x00 0x85 0xFF 0xFC 0xCF         &#xA;7FA0: 0x90 0x93 0xC6 0x00 0x08 0x95 0x80 0x91 0xC0 0x00 0x87 0xFF 0xFC 0xCF 0x80 0x91         &#xA;7FB0: 0xC0 0x00 0x84 0xFD 0x01 0xC0 0xA8 0x95 0x80 0x91 0xC6 0x00 0x08 0x95 0xE0 0xE6         &#xA;7FC0: 0xF0 0xE0 0x98 0xE1 0x90 0x83 0x80 0x83 0x08 0x95 0xED 0xDF 0x80 0x32 0x19 0xF0         &#xA;7FD0: 0x88 0xE0 0xF5 0xDF 0xFF 0xCF 0x84 0xE1 0xDE 0xCF 0x1F 0x93 0x18 0x2F 0xE3 0xDF         &#xA;7FE0: 0x11 0x50 0xE9 0xF7 0xF2 0xDF 0x1F 0x91 0x08 0x95 0x80 0xE0 0xE8 0xDF 0xEE 0x27         &#xA;7FF0: 0xFF 0x27 0x09 0x94 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x04 0x04         &#xA;&#xA;MD5 sum of bootloader = 0xEA 0x3C 0x5C 0xA9 0x35 0xD1 0x36 0xA6 0x71 0xD1 0xB2 0x3F 0x7E 0x62 0x79 0x6F         &#xA;Bootloader MD5 sum not known.        &#xA;&#xA;First 256 bytes of program memory:        &#xA;&#xA;0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;10: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;20: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;30: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;40: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;50: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;60: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;70: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00         &#xA;80: 0x10 0x20 0x40 0x80 0x01 0x02 0x04 0x08 0x10 0x20 0x01 0x02 0x04 0x08 0x10 0x20         &#xA;90: 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x02 0x02 0x02 0x02 0x02 0x02 0x03 0x03         &#xA;A0: 0x03 0x03 0x03 0x03 0x00 0x00 0x00 0x00 0x25 0x00 0x28 0x00 0x2B 0x00 0x00 0x00         &#xA;B0: 0x00 0x00 0x24 0x00 0x27 0x00 0x2A 0x00 0x2A 0x01 0x7D 0x02 0x11 0x24 0x1F 0xBE         &#xA;C0: 0xCF 0xEF 0xD8 0xE0 0xDE 0xBF 0xCD 0xBF 0x11 0xE0 0xA0 0xE0 0xB1 0xE0 0xE2 0xE0         &#xA;D0: 0xF8 0xE0 0x02 0xC0 0x05 0x90 0x0D 0x92 0xA8 0x30 0xB1 0x07 0xD9 0xF7 0x21 0xE0         &#xA;E0: 0xA8 0xE0 0xB1 0xE0 0x01 0xC0 0x1D 0x92 0xA7 0x31 0xB2 0x07 0xE1 0xF7 0x10 0xE0         &#xA;F0: 0xCC 0xEB 0xD0 0xE0 0x04 0xC0 0x22 0x97 0xFE 0x01 0x0E 0x94 0xFB 0x03 0xC8 0x3B         &#xA;&#xA;Programming mode off.        &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19020" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-04-10T08:39:26.577" Title="Arduino IDE stopped uploading sketches to BLEduino board" Tags="|arduino-uno|bluetooth|bootloader|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21492" PostTypeId="1" AcceptedAnswerId="21494" CreationDate="2016-03-07T00:59:57.183" Score="12" ViewCount="11100" Body="&lt;p&gt;Okay, we all have seen those questions all over the web such as Arduino v.s. C++, or other similar questions. And a vast majority of the answers do not even touch compilation differences other than through abstracted information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question aims to solve the actual differences (not preferences) in how a .ino file renamed to a .cpp file or other similar file extension for c++ would compile using GCC-AVR. I know that at a minimum you have to include the Arduino header file, but beyond that, what would cause a compilation error if compiling said .ino to .cpp file using, say, for instance GCC-AVR. For simplicity's sake, lets use the classic blink example to explain what the differences are. Or if you have a better code snippet to use, please by all means, include the snippet in your answer and explain the differences thoroughly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please no opinions as to which is a better way or tool to use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI. I use Platformio for development and I notice a conversion process happening behind the scenes during compilation. I am tryng to understand what is actually happening there, so when I code in Arduino, I understand the &quot;pure&quot; C++ version as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your thoughtful answers to my question in advance. &lt;/p&gt;&#xA;" OwnerUserId="3022" LastEditorUserId="37523" LastEditDate="2019-11-06T21:07:40.607" LastActivityDate="2022-08-08T07:05:24.470" Title="Will a .ino Arduino Sketch compile directly on GCC-AVR?" Tags="|programming|c++|compile|avr-gcc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21493" PostTypeId="2" ParentId="21490" CreationDate="2016-03-07T02:23:52.203" Score="3" Body="&lt;p&gt;From the USBASP documentation:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Planned: serial interface to target (e.g. for debugging).&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;..and further on..&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Firmware:&#xA;  The firmware dosn't support USB Suspend Mode. A bidirectional serial&#xA;  interface to slave exists in hardware but the firmware doesn't support it yet.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Keep in mind, that's from 2011, so it's possible someone has built an updated version of the firmware with that functionality. You'd have to do some searching (I'm not familiar with any such firmware).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now, your best bet is just getting a TTL serial-USB converter (they're cheap) and connecting it directly to the Pro Mini.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-03-07T02:23:52.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21494" PostTypeId="2" ParentId="21492" CreationDate="2016-03-07T02:24:37.043" Score="14" Body="&lt;p&gt;See my answer here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the&quot;&gt;Classes and objects: how many and which file types do I actually need to use them?&lt;/a&gt; - specifically: &lt;a href=&quot;https://arduino.stackexchange.com/a/13182/10794&quot;&gt;How the IDE organizes things&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I know that at a minimum you have to include the Arduino header file&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes you would need to do that.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but beyond that, what would cause a compilation error if compiling said .ino to .cpp file using, say, for instance GCC-AVR.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The IDE generates function prototypes for you. Code in a .ino file may or may not need this (it probably will unless the author is disciplined enough to code in the usual C++ way and do them themselves).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the &quot;sketch&quot; contains other files (eg. other .ino, .c or .cpp files) then these would need to be incorporated in the compile process as I describe in my answer mentioned above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you would need to (compile and) link in any libraries used by the sketch.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You haven't asked about the linking side of things, but naturally the various files, as compiled, need to be linked together, and then turned into a .elf and .hex file for uploading purposes. See below.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example makefile&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Based on the IDE output I made a simple makefile &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=308853.msg2145054#msg2145054&quot; rel=&quot;noreferrer&quot;&gt;a while back&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#&#xA;# Simple Arduino Makefile&#xA;#&#xA;# Author: Nick Gammon&#xA;# Date: 18th March 2015&#xA;&#xA;# where you installed the Arduino app&#xA;ARDUINO_DIR = C:/Documents and Settings/Nick/Desktop/arduino-1.0.6/&#xA;&#xA;# various programs&#xA;CC = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-gcc&quot;&#xA;CPP = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-g++&quot;&#xA;AR = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-ar&quot;&#xA;OBJ_COPY = &quot;$(ARDUINO_DIR)hardware/tools/avr/bin/avr-objcopy&quot;&#xA;&#xA;MAIN_SKETCH = Blink.cpp&#xA;&#xA;# compile flags for g++ and gcc&#xA;&#xA;# may need to change these&#xA;F_CPU = 16000000&#xA;MCU = atmega328p&#xA;&#xA;# compile flags&#xA;GENERAL_FLAGS = -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU)L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106&#xA;CPP_FLAGS = $(GENERAL_FLAGS) -fno-exceptions&#xA;CC_FLAGS  = $(GENERAL_FLAGS)&#xA;&#xA;# location of include files&#xA;INCLUDE_FILES = &quot;-I$(ARDUINO_DIR)hardware/arduino/cores/arduino&quot; &quot;-I$(ARDUINO_DIR)hardware/arduino/variants/standard&quot;&#xA;&#xA;# library sources&#xA;LIBRARY_DIR = &quot;$(ARDUINO_DIR)hardware/arduino/cores/arduino/&quot;&#xA;&#xA;build:&#xA;&#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(MAIN_SKETCH) -o $(MAIN_SKETCH).o&#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/malloc.c -o malloc.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)avr-libc/realloc.c -o realloc.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WInterrupts.c -o WInterrupts.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring.c -o wiring.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_analog.c -o wiring_analog.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_digital.c -o wiring_digital.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_pulse.c -o wiring_pulse.c.o &#xA;    $(CC) $(CC_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)wiring_shift.c -o wiring_shift.c.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)CDC.cpp -o CDC.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HardwareSerial.cpp -o HardwareSerial.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)HID.cpp -o HID.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)IPAddress.cpp -o IPAddress.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)main.cpp -o main.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)new.cpp -o new.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Print.cpp -o Print.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Stream.cpp -o Stream.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)Tone.cpp -o Tone.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)USBCore.cpp -o USBCore.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WMath.cpp -o WMath.cpp.o &#xA;    $(CPP) $(CPP_FLAGS) $(INCLUDE_FILES) $(LIBRARY_DIR)WString.cpp -o WString.cpp.o &#xA;    rm core.a&#xA;    $(AR) rcs core.a malloc.c.o &#xA;    $(AR) rcs core.a realloc.c.o &#xA;    $(AR) rcs core.a WInterrupts.c.o &#xA;    $(AR) rcs core.a wiring.c.o &#xA;    $(AR) rcs core.a wiring_analog.c.o &#xA;    $(AR) rcs core.a wiring_digital.c.o &#xA;    $(AR) rcs core.a wiring_pulse.c.o &#xA;    $(AR) rcs core.a wiring_shift.c.o &#xA;    $(AR) rcs core.a CDC.cpp.o &#xA;    $(AR) rcs core.a HardwareSerial.cpp.o &#xA;    $(AR) rcs core.a HID.cpp.o &#xA;    $(AR) rcs core.a IPAddress.cpp.o &#xA;    $(AR) rcs core.a main.cpp.o &#xA;    $(AR) rcs core.a new.cpp.o &#xA;    $(AR) rcs core.a Print.cpp.o &#xA;    $(AR) rcs core.a Stream.cpp.o &#xA;    $(AR) rcs core.a Tone.cpp.o &#xA;    $(AR) rcs core.a USBCore.cpp.o &#xA;    $(AR) rcs core.a WMath.cpp.o &#xA;    $(AR) rcs core.a WString.cpp.o &#xA;    $(CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(MAIN_SKETCH).elf $(MAIN_SKETCH).o core.a -lm &#xA;    $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(MAIN_SKETCH).elf $(MAIN_SKETCH).eep &#xA;    $(OBJ_COPY) -O ihex -R .eeprom $(MAIN_SKETCH).elf $(MAIN_SKETCH).hex &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In that particular case, the .ino file compiled without any problems &lt;strong&gt;after&lt;/strong&gt; renaming it to Blink.cpp and adding this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-07T02:30:35.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21495" PostTypeId="2" ParentId="21454" CreationDate="2016-03-07T02:49:54.507" Score="0" Body="&lt;p&gt;There are 3 things you can try. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt;&#xA;If you have any male pins, solder those to the lcd screen, then stick it in the breadboard. After that you can stick the wires in the breadboard appropriately. The first time I tried this the wires were either touching or not connected enough to the lcd screen.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Double check all the connections made. This also happened to me, just make sure all the wires are in their right places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Have you tried adjusting the potentiometer? Thats what its there for. Try turning it &lt;strong&gt;slowly&lt;/strong&gt; both directions to adjust the background and letter brightness. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the looks of the picture, number 3 may be your problem. Try that step first, and if it doesn't work you can try the other two. Hope this helps! &lt;/p&gt;&#xA;" OwnerUserId="16094" LastActivityDate="2016-03-07T02:49:54.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21496" PostTypeId="1" CreationDate="2016-03-07T03:11:39.183" Score="1" ViewCount="977" Body="&lt;p&gt;This posting contains 2 sketches. the analogmux1 compiles successfully. Concerning analogmuvvolts sketch an error stating updateMux1 was not declared in this scope results. The int Mux1_State [8] = 0: is defined exactly the same in both however the error results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm learning Arduino programming so there are other errors in the sketch. What I'm trying to accomplish is to display the actual voltage of each channel, not numbers which appear in the analogMux. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be appreciated if the community could provide me with some guidance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Analogmux:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin_Out_S0 = 8;&#xA;int pin_Out_S1 = 9;&#xA;int pin_Out_S2 = 10;&#xA;int pin_In_Mux1 = A0;&#xA;int Mux1_State[8] = {0};&#xA;&#xA;void setup() {&#xA;  pinMode(pin_Out_S0, OUTPUT);&#xA;  pinMode(pin_Out_S1, OUTPUT);&#xA;  pinMode(pin_Out_S2, OUTPUT);&#xA;  //pinMode(pin_In_Mux1, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  updateMux1();&#xA;  for(int i = 0; i &amp;lt; 8; i ++) {&#xA;    if(i == 7) {&#xA;      Serial.println(Mux1_State[i]);&#xA;    } else {&#xA;      Serial.print(Mux1_State[i]);&#xA;      Serial.print(&quot;,&quot;);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void updateMux1 () {&#xA;  for (int i = 0; i &amp;lt; 8; i++){&#xA;    digitalWrite(pin_Out_S0, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000001));&#xA;    digitalWrite(pin_Out_S1, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000010));&#xA;    digitalWrite(pin_Out_S2, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000100));&#xA;    Mux1_State[i] = analogRead(pin_In_Mux1);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And  analogmuxvolts&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pin_Out_S0 = 8;&#xA;int pin_Out_S1 = 9;&#xA;int pin_Out_S2 = 10;&#xA;int pin_In_Mux1 = A0;&#xA;int Mux1_State[8] = {0};&#xA;//float Mux1_State[i] =0;&#xA;int RawValue=0;&#xA;float Voltage = 0;&#xA;void setup() {&#xA;  pinMode(pin_Out_S0, OUTPUT);&#xA;  pinMode(pin_Out_S1, OUTPUT);&#xA;  pinMode(pin_Out_S2, OUTPUT);&#xA;  pinMode(pin_In_Mux1, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA; RawValue = analogRead(pin_In_Mux1);&#xA; Voltage = (RawValue * 5.0) / 1024; //scale the ADC&#xA;  updateMux1();&#xA;  Serial.println(Mux1_State);&#xA;  for(int i = 0; i &amp;lt; 8; i ++) {&#xA;    if(i == 7) {&#xA;      Serial.println(Mux1_State[i]);&#xA;    } else {&#xA;      Serial.print(Mux1_State[i]);&#xA;      Serial.print(&quot;,&quot;);&#xA;      //vout = (value * 5.0) / 1024.0;&#xA;    }&#xA;  }&#xA;  Serial.print(&quot;Raw  Value = &quot; );&#xA;  Serial.print(RawValue); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="6628" LastEditDate="2016-03-07T04:03:44.770" LastActivityDate="2016-04-06T06:52:38.937" Title="int not declared in this scope" Tags="|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21497" PostTypeId="2" ParentId="21489" CreationDate="2016-03-07T03:22:44.153" Score="0" Body="&lt;p&gt;The DHT requires some precise timing on its one-wire interface e.g. a &gt;40us HIGH pulse == 1, while a &amp;lt;40us HIGH pulse == 0. Your DHT library doesnt use interrupts directly but it does use &lt;code&gt;micros()&lt;/code&gt; which is based on regular interrupts, which are disabled automatically when you are within the TIMER2 ISR (no need for your explicit &lt;code&gt;cli()&lt;/code&gt; and &lt;code&gt;sei()&lt;/code&gt;, by the way). If you waste too much time in your ISR, you'll miss bits/pulses on the DHT line and obtain incorrect data, hence your checksum error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution I can think of is to disable the TIMER2 interrupt before the &lt;code&gt;read11()&lt;/code&gt; call and enable it again after. I dont have much experience with AVR interrupts but I think this small change should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TIM2_EN() (TIMSK2 = 0x02)&#xA;#define TIM2_DIS() (TIMSK2 = 0x00)&#xA;&#xA;// your code as usual&#xA;&#xA;void loop(){&#xA;  // ...as before...&#xA;&#xA;  TIM2_DIS(); //Enable TIMER2 Interrupt&#xA;&#xA;  //Read DH11 Data&#xA;  int chk = DHT.read11(DHT11_PIN);&#xA;&#xA;  TIM2_EN(); //Disable TIMER2 Interrupt&#xA;&#xA; //...as before...&#xA;}&#xA;&#xA;// your code as before&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11523" LastEditDate="2016-03-10T07:15:12.153" LastActivityDate="2016-03-10T07:15:12.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21498" PostTypeId="2" ParentId="21047" CreationDate="2016-03-07T04:03:10.427" Score="3" Body="&lt;p&gt;I have a page about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12942&quot; rel=&quot;nofollow&quot;&gt;a tiny web server&lt;/a&gt; for the Arduino Uno or similar boards. It simply isn't true that you can't make one, or that a much more powerful processor would be better. There are &lt;em&gt;some&lt;/em&gt; limitations imposed by small amounts of RAM, but the library described there decodes incoming HTTP information &quot;on the fly&quot; so it can handle a reasonably large page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put the data to be display into PROGMEM (more information &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) or onto an SD card as someone suggested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The login and password could be stored in EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-07T04:03:10.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21499" PostTypeId="1" CreationDate="2016-03-07T03:51:10.713" Score="-1" ViewCount="1944" Body="&lt;p&gt;I have bought the following SIM900A GSM/GPRS module. I need to connect it to an Arduino Mega. Can anyone answer me which pin I need to connect to the Arduino?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AxKag.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AxKag.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19060" OwnerDisplayName="ram shayan" LastEditorUserId="61722" LastEditDate="2022-06-24T07:14:59.480" LastActivityDate="2022-06-24T07:14:59.480" Title="Connecting SIM900A GSM/GPRS module Arduino Mega" Tags="|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21500" PostTypeId="2" ParentId="21496" CreationDate="2016-03-07T05:01:28.420" Score="1" Body="&lt;p&gt;Declare the updateMux() function by copying it from your first sketch into your second sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void updateMux1 () {&#xA;  for (int i = 0; i &amp;lt; 8; i++){&#xA;    digitalWrite(pin_Out_S0, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000001));&#xA;    digitalWrite(pin_Out_S1, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000010));&#xA;    digitalWrite(pin_Out_S2, HIGH &amp;amp;&amp;amp; (i &amp;amp; B00000100));&#xA;    Mux1_State[i] = analogRead(pin_In_Mux1);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And do the conversions on the stored Mux1_State[] values during printing like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(int i = 0; i &amp;lt; 8; i ++) {&#xA;    Serial.println(Mux1_State[i]*5.0/1024.0);&#xA;    if(i == 7) { &#xA;       Serial.println();&#xA;    } else {     &#xA;       Serial.print(&quot;,&quot;);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-07T05:01:28.420" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21501" PostTypeId="2" ParentId="21491" CreationDate="2016-03-07T05:10:36.647" Score="0" Body="&lt;p&gt;Looking at &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;this post about the uploading process&lt;/a&gt; a response of 0x10 is &lt;strong&gt;STK_OK&lt;/strong&gt;. Now while that looks fine, if the uploader is expecting &lt;strong&gt;STK_INSYNC&lt;/strong&gt; then it's not OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you go through more of the steps in the &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;link you posted&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the &quot;board detector&quot; sketch mentioned on that page, to see if the main chip is completely gone, or if there is another issue. Other issues might be things plugged into D0 and D1, wrong baud rate, wrong clock rate, etc.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-07T05:10:36.647" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="21502" PostTypeId="2" ParentId="21470" CreationDate="2016-03-07T05:15:38.487" Score="2" Body="&lt;p&gt;Does nothing clear 'i' at the end of a message?  If not, then long/unexpected/multiple messages can overflow your str[160] buffer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also looks like writing to the msg[160] buffer isn't well protected from overflow.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-07T05:15:38.487" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21503" PostTypeId="2" ParentId="21256" CreationDate="2016-03-07T05:19:16.913" Score="3" Body="&lt;p&gt;I wonder if you are running out of RAM? Those sockets use RAM, and you have quite a few string constants, like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  client.println(&quot;Content-Type: text/plain;charset=UTF-8&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change that (and all similar ones) to use the &lt;code&gt;F()&lt;/code&gt; macro:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  client.println(F(&quot;Content-Type: text/plain;charset=UTF-8&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-07T05:19:16.913" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21504" PostTypeId="1" AcceptedAnswerId="21508" CreationDate="2016-03-07T05:53:48.707" Score="2" ViewCount="3951" Body="&lt;p&gt;Referring to guide at &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow&quot;&gt;High-low tech&lt;/a&gt;, I were able to flash ATTiny84 via UNO through Arduino IDE 1.6.7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I loaded a simple blink LED program on IDE pin 0 (physical Attiny84 pin 13, PA0) and everything works fine for pin 0 till 7 at Port A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if I want to access or blink a LED at one of the pins at Port B? Example, PB0 (physical pin 2)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following is my current code to blink PA7&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led=7; //PA7&#xA;&#xA;void setup() {&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);&#xA;  delay(100);&#xA;  digitalWrite(led,LOW);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4990" LastActivityDate="2023-02-18T05:42:57.020" Title="How to access Attiny84 port B in Arduino IDE code?" Tags="|arduino-ide|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21505" PostTypeId="1" CreationDate="2016-03-07T06:28:01.170" Score="0" ViewCount="1604" Body="&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/7CR3B.jpg&quot; alt=&quot;I want to control an LED using a relay..&quot; /&gt;&#xA;How to I connect the pins of one channel relay to control and led which is connected to pin 13 of an arduino uno.can you tell me the steps which pin will go to which pin&lt;/p&gt;&#xA;" OwnerUserId="18794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-09T09:43:51.227" Title="How to connect relay" Tags="|relay|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21506" PostTypeId="2" ParentId="21504" CreationDate="2016-03-07T06:58:55.280" Score="4" Body="&lt;p&gt;According to the ATtiny web-page the pin/ports are numbered as below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7KtrR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7KtrR.png&quot; alt=&quot;ATtiny44/ATtiny84&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The physical pin 2 is the Arduino ATtiny core pin 10. You can also find this well documented in the &lt;a href=&quot;https://github.com/damellis/attiny/blob/master/variants/tiny14/pins_arduino.h#L33&quot; rel=&quot;nofollow noreferrer&quot;&gt;pins_arduino.h&lt;/a&gt; file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-07T06:58:55.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21508" PostTypeId="2" ParentId="21504" CreationDate="2016-03-07T07:41:14.507" Score="0" Body="&lt;p&gt;Refer to url link by @Mikael, this is the answer I'm looking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino IDE &amp;amp; Pin Mapping &#xA;// ATMEL ATTINY84 / ARDUINO&#xA;//&#xA;//                           +-\/-+&#xA;//                     VCC  1|    |14  GND&#xA;//             (D 10)  PB0  2|    |13  AREF (D  0)&#xA;//             (D  9)  PB1  3|    |12  PA1  (D  1) &#xA;//                     PB3  4|    |11  PA2  (D  2) &#xA;//  PWM  INT0  (D  8)  PB2  5|    |10  PA3  (D  3) &#xA;//  PWM        (D  7)  PA7  6|    |9   PA4  (D  4) &#xA;//  PWM        (D  6)  PA6  7|    |8   PA5  (D  5)        PWM&#xA;//                           +----+&#xA;&#xA;IDE Attiny84 Physical Pin&#xA;  0      PA0           13&#xA;  1      PA1           12&#xA;  2      PA2           11&#xA;  3      PA3           10&#xA;  4      PA4            9&#xA;  5      PA5            8&#xA;  6      PA6            7&#xA;  7      PA7            6&#xA;  8      PB2            5&#xA;  9      PB1            3&#xA; 10      PB0            2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to blink PB0, I would need to replace my code with &lt;code&gt;int led=2; //PB0&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4990" LastActivityDate="2016-03-07T07:41:14.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21509" PostTypeId="2" ParentId="21505" CreationDate="2016-03-07T08:02:58.427" Score="0" Body="&lt;p&gt;It looks like &lt;a href=&quot;http://www.elesof.com/electronics/product/one_6v_spdt_relay_board&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.elesof.com/electronics/product/one_6v_spdt_relay_board&lt;/a&gt;  , &lt;a href=&quot;http://shop.ciseco.co.uk/jqc-3f-t73-5v-pcb-relay/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://shop.ciseco.co.uk/jqc-3f-t73-5v-pcb-relay/&lt;/a&gt; and it probably works like &lt;a href=&quot;http://www.electronics-tutorials.ws/blog/relay-switch-circuit.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.electronics-tutorials.ws/blog/relay-switch-circuit.html&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd bet that the I/P line connects to the center pin on the transistor through one of those resistors.    If so,  I'd put a 5V 100mA source on the GND +5 pins on the side, then I'd use a jumper from the +5 on the end to the I/P on the end, and see if it triggers the relay as expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, I'd siconnect the jumper and I'd connect the end terminal's GND to the arduino GND, and (maybe?) pin 13 to the I/P line and expect the Blink tutorial that blinks the Arduino's LED to click the relay in time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are asking which are the outputs and which are the inputs of the relay board, I can't tell from the pictures. Look at the bottom of the board and compare it to the datasheet of the relay: &lt;a href=&quot;http://langir.com/pdf/pcb-relay-T73.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://langir.com/pdf/pcb-relay-T73.pdf&lt;/a&gt;  --&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ODdCU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ODdCU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd bet that screw terminals are the outputs, connecting to the right hand pair of outputs, and the center of the left hand three inputs.   And that the  control terminals are the pin connectors, with the I/P conneting through the transistor to one end of the coil, with the other end of the coil going to the +5V/12V pin connector.  There are likely two sets of pin connectors to provide for a separate coil/relay supply on the GND,5V12V connector versus a signal or signal plus power on the GND,I/P,5V/12V pin connector.  I'd bet the same-named pin connectors are electrically identical.  i.e. GND=GND and 5V/12V=5V/12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are controlling other than low voltage devices with this, I suggest you make certain you are safe before applying potentially dangerous currents.  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-07T16:09:26.827" LastActivityDate="2016-03-07T16:09:26.827" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21512" PostTypeId="1" AcceptedAnswerId="21540" CreationDate="2016-03-07T09:04:15.740" Score="0" ViewCount="1543" Body="&lt;p&gt;I have a prototyping shield with mini breadboard similar to &lt;a href=&quot;http://www.adafruit.com/products/2077&quot; rel=&quot;nofollow&quot;&gt;Adafruit Proto Shield for Arduino Kit - Stackable Version R3&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a Fritzing file for this.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-03-07T21:25:32.563" Title="Fritzing file for prototyping shield" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21513" PostTypeId="2" ParentId="21256" CreationDate="2016-03-07T09:18:56.760" Score="1" Body="&lt;p&gt;With reference to &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiWebClientRepeating&quot; rel=&quot;nofollow&quot;&gt;this example&lt;/a&gt;, perhaps you should call &lt;code&gt;client.stop()&lt;/code&gt; right before you call &lt;code&gt;client.connect()&lt;/code&gt; at the start of &lt;code&gt;setHue()&lt;/code&gt; and &lt;code&gt;getHue()&lt;/code&gt;. You should also call not only &lt;code&gt;client.stop()&lt;/code&gt;, but also &lt;code&gt;client.flush()&lt;/code&gt; at the end of both functions, just in case: Flush first, then stop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a different note, correct your HTTP headers from &lt;code&gt;client.println(F(&quot;keep-alive&quot;));&lt;/code&gt; to &lt;code&gt;client.println(F(&quot;Connection: keep-alive&quot;));&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-07T09:18:56.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21514" PostTypeId="1" CreationDate="2016-03-07T09:24:51.517" Score="3" ViewCount="12050" Body="&lt;p&gt;The Arduino 101 came out recently, and it has built-in &quot;Bluetooth Low Energy&quot; capabilities. The tutorials and code examples that can be found for the 101 all seem to be about &lt;em&gt;transmitting&lt;/em&gt; data, but I can't find anything about &lt;em&gt;receiving&lt;/em&gt; data. I've tried to go through the source code of the CurieBle library to find some hints, but I feel a little overwhelmed/lost. Could someone point me to a code example which demonstrates how to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context: I was previously using an HC-05 module paired with an Arduino Nano in order to receive data. In this case it is quite easy to connect the HC-05 to the Nano's digital pins and receive data like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RxD 7 // This is the pin that the Bluetooth (BT_TX) &#xA;              // will transmit to the Arduino (RxD)&#xA;#define TxD 8 // This is the pin that the Bluetooth (BT_RX) &#xA;              // will receive from the Arduino (TxD)&#xA;&#xA;SoftwareSerial blueToothSerial(RxD,TxD);&#xA;&#xA;void setup() { &#xA;  blueToothSerial.begin(9600);&#xA;  Serial.begin(9600);&#xA;  // Allow Serial communication via USB cable to computer&#xA;  pinMode(RxD, INPUT);&#xA;  // Set up the Arduino to receive INPUT from the HC-05 on Digital Pin 7&#xA;  pinMode(TxD, OUTPUT);&#xA;  // Set up the Arduino to send OUTPUT to the HC-05 on Digital Pin 8&#xA;}&#xA;&#xA;void loop() { &#xA;  char recvChar;&#xA;  while(1) {&#xA;    if(blueToothSerial.available()) {&#xA;      recvChar = blueToothSerial.read();&#xA;      Serial.print(&quot;Read character: &quot;);&#xA;      Serial.println(recvChar);&#xA;      // Print the character received to the Serial Monitor&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there equivalent, and equally simple, code available, which would do the same thing via the BLE built into the Arduino 101?&lt;/p&gt;&#xA;" OwnerUserId="18587" LastEditorUserId="4628" LastEditDate="2016-04-24T08:41:13.890" LastActivityDate="2018-06-10T13:06:12.617" Title="How to receive data via Bluetooth on an Arduino 101?" Tags="|bluetooth|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21515" PostTypeId="2" ParentId="21492" CreationDate="2016-03-07T09:37:37.123" Score="12" Body="&lt;p&gt;I would just like to add a few points to Nick Gammon's answer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You do not need to rename a .ino file in order to compile it: if you&#xA;explicitly tell the compiler it's C++ (option &lt;code&gt;-x c++&lt;/code&gt;), it will&#xA;ignore the unusual file extension and compile it as C++.&lt;/li&gt;&#xA;&lt;li&gt;You do not need to add &lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&lt;/code&gt; in the .ino file: you&#xA;can tell the compiler to do that for you (&lt;code&gt;-include Arduino.h&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Using those tricks, I can compile Blink.ino with &lt;em&gt;no modification&lt;/em&gt;, just&#xA;by invoking avr-g++ with the proper command-line options:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;avr-g++ -mmcu=atmega328p -DARDUINO=105 -DF_CPU=16000000L \&#xA;    -I/usr/share/arduino/hardware/arduino/cores/arduino \&#xA;    -I/usr/share/arduino/hardware/arduino/variants/standard \&#xA;    -Os -fno-exceptions -ffunction-sections -fdata-sections \&#xA;    -Wl,--gc-sections -g -Wall -Wextra \&#xA;    -x c++ -include Arduino.h \&#xA;    /usr/share/arduino/examples/01.Basics/Blink/Blink.ino \&#xA;    -x none /usr/local/lib/arduino/uno/libcore.a -lm \&#xA;    -o Blink.elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few notes on the above command-line:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;/usr/local/lib/arduino/uno/libcore.a&lt;/code&gt; is where I saved the compiled&#xA;Arduino core. I hate recompiling over and over again the same stuff.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-x none&lt;/code&gt; is needed to tell the compiler to mind the file extensions&#xA;again. Without it, it would assume libcore.a is a C++ file.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I learned those tricks from &lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;noreferrer&quot;&gt;Sudar Muthu's&#xA;Arduino-Makefile&lt;/a&gt;. This is a&#xA;very general Makefile that works with many boards and with libraries.&#xA;The only thing missing relative to the Arduino IDE is the forward&#xA;declarations.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-07T09:37:37.123" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21516" PostTypeId="2" ParentId="21476" CreationDate="2016-03-07T09:59:57.247" Score="1" Body="&lt;p&gt;The fastest would be “Simplified Serial Mode” at 38400&amp;nbsp;bps.&#xA;In this mode, a command is a single byte, transmitted as ten bits&#xA;(1 start + 8 data + 1 stop), which would take 0.26&amp;nbsp;ms to be transmitted.&#xA;Compare with the ≈&amp;nbsp;1&amp;nbsp;ms lag you would get with an analog&#xA;filter. As per the data sheet, the caveats are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;resolution reduced to 7 bits&lt;/li&gt;&#xA;&lt;li&gt;the communication may not be reliable at this fast speed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: The fastest may actually be PWM, if you “cheat” a little bit&#xA;with the analog filter. The Sabertooth datasheet recommends&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PWM frequency = 1 kHz&lt;/li&gt;&#xA;&lt;li&gt;filter with 10 kΩ + 0.1 µF.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This gives a time constant RC = 1&amp;nbsp;ms, which is one PWM period.&#xA;You can then expect a worst case ripple of 1.22&amp;nbsp;V peak-to-peak.&#xA;The datasheet says you can increase the frequency or the capacitance&#xA;beyond those minimum recommended values. In both cases you would get&#xA;less ripple. But if we assume that this level of ripple is acceptable,&#xA;we can make things faster by decreasing both the PWM period and the&#xA;filter's time constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The trick is to configure the PWM output to run as fast as possible. The&#xA;outputs of the Uno can run as fast as 62.5&amp;nbsp;kHz at 8-bit resolution,&#xA;but for this we have to configure a timer using low-level port access,&#xA;instead of relying on the &lt;code&gt;analogWrite()&lt;/code&gt; Arduino function. I would&#xA;rather avoid messing with Timer 0, because that would break all the&#xA;Arduino timing functions (&lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;micros()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt; and&#xA;&lt;code&gt;delayMicroseconds()&lt;/code&gt;). Here is an example program that uses Timer 2 to&#xA;output two PWM waveforms at 62.5&amp;nbsp;kHz on outputs 11 (aka OC2A) and 3&#xA;(aka OC2B):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    DDRB  |= _BV(PB3);    // OC2A = PB3 = Arduino 11 as output&#xA;    DDRD  |= _BV(PD3);    // OC2B = PD3 = Arduino  3 as output&#xA;    OCR2A  = 127;         // output A starts at 2.5 V&#xA;    OCR2B  = 127;         // same for output B&#xA;    TCCR2A = _BV(COM2A1)  // output A in non-inverting mode&#xA;           | _BV(COM2B1)  // same for B&#xA;           | _BV(WGM21)   // fast PWM&#xA;           | _BV(WGM20);  // ditto&#xA;    TCCR2B = _BV(CS20);   // clock with no prescaling&#xA;}&#xA;&#xA;void loop() {&#xA;    // Full forward both motors.&#xA;    OCR2A  = 255;&#xA;    OCR2B  = 255;&#xA;    delay (1000);&#xA;&#xA;    // Stop.&#xA;    OCR2A  = 127;&#xA;    OCR2B  = 127;&#xA;    delay (1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could then smooth these outputs with an RC filter of&#xA;2.2&amp;nbsp;kΩ and 10&amp;nbsp;nF. That would give a time constant of&#xA;22&amp;nbsp;µs, longer than the PWM period which is 16&amp;nbsp;µs, and a&#xA;worst-case ripple of 0.9&amp;nbsp;V peak-to-peak.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-03-07T11:35:03.303" LastActivityDate="2016-03-07T11:35:03.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21517" PostTypeId="1" AcceptedAnswerId="21693" CreationDate="2016-03-07T10:41:38.823" Score="1" ViewCount="1356" Body="&lt;p&gt;I'm trying to communicate some numbers between a Linux program and my Ardunino Uno. To this end I wrote a C++ program which somehow contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;int a,b;&#xA;a = 1;&#xA;b = 2000;&#xA;&#xA;File* serial = fopen(&quot;/dev/ttyACM0&quot;,&quot;w&quot;);&#xA;fprintf(serial,&quot;%d,%d\n&quot;,a,b);&#xA;fclose(serial);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now out of standards I guess, the baud rate is 9600 bit/s. If I use &lt;code&gt;stty -F /dev/ttyACM0 115200&lt;/code&gt; I can change the baude rate of that port to 115200 bit/s. However the communication does not work anymore. My arduino program waiting for &lt;code&gt;number,number&lt;/code&gt; does not show any action to the same code as before. Oh, and in the Arduino program of course I changed the code to &lt;code&gt;serial.begin(115200);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change the baude rate in such a setup? If it is a concern, I'm using Ubuntu and an Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2016-03-11T14:38:48.610" Title="Baud rate Arduino/Linux" Tags="|serial|linux|baud-rate|rs232|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21518" PostTypeId="1" AcceptedAnswerId="21530" CreationDate="2016-03-07T10:51:48.887" Score="0" ViewCount="217" Body="&lt;p&gt;Still very new to Arduino, so bare with me. I've been all over Google looking for ways to hack my alarm keypad. This is my first time using the Arduino to hack something  :smiley-confuse: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The keypad has a 13.7v input. Every other contact I can touch shows 5v or less. I realized quickly that the key buttons were producing various voltages. A quick search revealed that it was a voltage divider. I can see the resistors on the ladder. I though about mimicking the ladder via the Arduino and using a common ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can see two shift resistors that say HEF4094BT. My guess is that these power the led's on the board.&#xA;I can also see a chip that reads KSL1 r1342 that I can't seem to find a datasheet on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a few questions, but I guess I need to tell you my end goal. I want to make my keypad an IoT device. I want to be able to read the status of the alarm, and possibly mimick the keypresses to disable the alarm or activate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1st. I was thinking I could share a common ground, and read a led state for high/low. Like the &quot;Armed&quot; Led. Thought I'd ask the community before I go and short something  :( &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2nd. How can I mimick the keypad's output voltages? Maybe a DAC? If so, what do you recommend? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other Information: It's a DSC PC1550 - 6 zone alarm. (...and I'm also guessing the Rx/Tx are some DSC proprietary serial connection for security :/ )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&#xA;Robert.&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-07T16:20:36.700" Title="Arduino Mimicking Voltage Dividing Keypad / Matrix" Tags="|sensors|communication|hardware|analogread|voltage-level|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21519" PostTypeId="2" ParentId="21517" CreationDate="2016-03-07T10:57:16.850" Score="3" Body="&lt;p&gt;Setting baud rates in a C program isn't a trivial task. You need to use the low-level &lt;code&gt;open()&lt;/code&gt; instead of &lt;code&gt;fopen()&lt;/code&gt; and act on the returned file descriptor with &lt;code&gt;ioctl()&lt;/code&gt; or &lt;code&gt;tcsetattr() / tcgetattr()&lt;/code&gt;.  The former method allows the setting of non-standard baud rates while the latter only allows specific baud rates to be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a C++ class to deal with it all for me a while back. You are welcome to examine the methodology and/or steal whatever bits of it you like to use in your own program.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/majenkotech/SerialPort&quot; rel=&quot;nofollow&quot;&gt;https://github.com/majenkotech/SerialPort&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-07T10:57:16.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21520" PostTypeId="1" CreationDate="2016-03-07T11:17:10.933" Score="1" ViewCount="1004" Body="&lt;p&gt;I have a library that uses conditional compilation based on the preprocessor variables. The library is a separate &lt;code&gt;.cpp&lt;/code&gt; object file with a header file.&lt;/p&gt;&#xA;&lt;p&gt;How can I pass preprocessor variables to the compilation of the library? Standard &lt;code&gt;#define&lt;/code&gt; in a sketch file wouldn't work, since their life will be limited to my sketch object file(s), not the library's.&lt;/p&gt;&#xA;&lt;p&gt;Normally it is solved by the &lt;code&gt;./configure&lt;/code&gt; script and/or the custom make process. How can I do it on Arduino?&lt;/p&gt;&#xA;&lt;p&gt;Supplying a separate compilation/source code of the library for all 2^8 combinations of the preprocessor switches doesn't seem feasible...&lt;/p&gt;&#xA;" OwnerUserId="7329" LastEditorUserId="58969" LastEditDate="2023-01-07T15:52:54.177" LastActivityDate="2023-01-07T15:52:54.177" Title="Arduino configure script for conditional compilation of libraries" Tags="|c++|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21521" PostTypeId="2" ParentId="21520" CreationDate="2016-03-07T11:27:31.957" Score="1" Body="&lt;p&gt;There's two basic methods:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Provide a config.h file with the options in that the user modifies&lt;/li&gt;&#xA;&lt;li&gt;Place the options on the command line with -D&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;A decent IDE allows you to modify the compilation command line to add options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My IDE, UECIDE, allows the creation of menu entries that set library options.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-07T11:27:31.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21522" PostTypeId="2" ParentId="21520" CreationDate="2016-03-07T11:38:51.647" Score="0" Body="&lt;p&gt;Another solution: Rename the library's &lt;code&gt;.cpp&lt;/code&gt; file into another &lt;code&gt;.hpp&lt;/code&gt;, and let the user include it in exactly one object file of his.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;User would configure the library in &lt;code&gt;lib_customization.h&lt;/code&gt; included before every &lt;code&gt;#include&amp;lt;lib.h&amp;gt;&lt;/code&gt;. User would also need to include an extra source file &lt;code&gt;object_file_that_defines_lib.cpp&lt;/code&gt; which includes library definitions.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;Sketch.ino:&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&quot;lib_customization.h&quot;&#xA;#include&amp;lt;lib.h&amp;gt;&#xA;&#xA;void loop() {}&#xA;void setup() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;lib_customization.h:&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LIB_INCLUDE_FEATURE_A&#xA;#define LIB_INCLUDE_FEATURE_B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;&lt;code&gt;object_file_that_defines_lib.cpp:&lt;/code&gt;&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&quot;lib_customization.h&quot;&#xA;#include&amp;lt;lib_definitions.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7329" LastActivityDate="2016-03-07T11:38:51.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21523" PostTypeId="1" AcceptedAnswerId="21525" CreationDate="2016-03-07T12:33:10.010" Score="1" ViewCount="471" Body="&lt;p&gt;I have a motor shield.&#xA;I can put it on top of my arduino Mega and works perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since the shield plugs in on top of the arduino board, I don't have access to 5V and GND from Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just have holes on the board with 5V and GND. (look at image)&lt;a href=&quot;https://i.stack.imgur.com/xf5Vg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xf5Vg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to solder a cable there to have access to 5V and GND? or there is another easier way?&lt;/p&gt;&#xA;" OwnerUserId="10031" LastActivityDate="2018-03-17T03:26:51.283" Title="Shield board with holes, do I need to solder?" Tags="|arduino-mega|shields|arduino-motor-shield|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21524" PostTypeId="1" AcceptedAnswerId="58699" CreationDate="2016-03-07T13:06:05.190" Score="1" ViewCount="1767" Body="&lt;p&gt;My Arduino Nano v3.0 (made by Gravitech US) is behaving in an unexpected manner. Whenever I try to upload a simple Blink program on the board it always give error which is shown below. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x01&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have another Nano (a Clone) and an Arduino UNO, both of which work perfectly using the same USB cable and PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;History: When I used this Nano (original) for the first time, it was having some issue related to the FTDI chip. The FTDI USB was locking up on power up. I referred an answer from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=23025.0&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano 3.0: FTDI USB locks up on power up&lt;/a&gt;.  I shorted the pin no. 26 (TEST) and 25 (AGND) on the FTDI chip, and then I was able to use it. I uploaded the Blink program and tested it, which was working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, at present (three years later), when I try to upload even a simple Blink example sketch on it, it never succeeds, and gives me the above mentioned error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried holding the reset button and releasing it when it shows&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Uploading...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Another Issue: Sometimes when I just check the continuity on my Arduino Nano just to confirm whether the hardware is okay or not, it gives me unexpected results. On checking, the Pins RST and GND get shorted sometimes. And sometimes even VCC, RST and GND get shorted. I also checked the small reset switch on board, and it is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I contacted Gravitech, but they aren't responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be the issue with my arduino Nano? I haven't used it yet in any of my project. Just the Blink program that I uploaded 3 years ago on it, was the last time I saw it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19036" LastEditorUserId="6936" LastEditDate="2016-03-16T02:38:40.000" LastActivityDate="2019-01-11T12:02:25.577" Title="Unable to upload code on Arduino Nano" Tags="|arduino-uno|arduino-ide|arduino-nano|ftdi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21525" PostTypeId="2" ParentId="21523" CreationDate="2016-03-07T13:35:50.883" Score="4" Body="&lt;p&gt;Since there are two grounds, a 2-pin terminal block of the type already on the board may fit. Or, since the shield doesn't obscure the far end of the Mega (the end with the high numbered I/Os), you could pick up 5V and Gnd there. The ends of the double-row female header have respectively, 2 each 5V and Gnd connectors. You would pick those up with breadboard wires, though it is admittedly less secure.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-07T13:35:50.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21526" PostTypeId="2" ParentId="21520" CreationDate="2016-03-07T14:07:18.443" Score="3" Body="&lt;p&gt;The problem here is that the Arduino IDE is not setup for doing this. Any real IDE has the possibility to set defines.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your library to be used by arduino IDE users you will have to go to dirty routes like the #include and config.h approach already mentioned.&#xA;If I'm not mistaken arduino IDE compiles libraries with the full include path so you can have the config.h next to your sketch.ino file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the library is not intended for arduino IDE users I would advice using a real IDE like my Arduino Eclipse Plugin.  &lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-07T14:07:18.443" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21528" PostTypeId="2" ParentId="21393" CreationDate="2016-03-07T14:27:31.317" Score="0" Body="&lt;p&gt;As Edgar stated my issue was I didn't make the Once variable static&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;1) You should debounce your button. 2) You should qualify Once as static, otherwise it's reset to zero (actually, recreated) every time you enter loop().&quot;&lt;/p&gt;&#xA;" OwnerUserId="18948" LastActivityDate="2016-03-07T14:27:31.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21530" PostTypeId="2" ParentId="21518" CreationDate="2016-03-07T16:20:36.700" Score="2" Body="&lt;p&gt;Reading the leds would work. Depending on the voltage going out of the shift register, you might need to add a buffer chip, to lower the voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the keypad I'd probably go with a variable resistor, better known as a digital potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could probably add a way to also read the keypad, from the arduino. Which might be useful, maybe.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-07T16:20:36.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21531" PostTypeId="1" CreationDate="2016-03-07T16:36:31.877" Score="0" ViewCount="779" Body="&lt;p&gt;Serial is causing me a lot of pain, and I think there are certain basic principles that I simple have not understood. I hope that by understanding how to test/demonstrate the buffer size, I will come one big step closer to understanding how serial works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect it is only possible to demonstrate this by writing a piece of software for &quot;the other end&quot;; the pc. I do understand Python, and to some extent how to work with serial on Python, so if possible, please write the pc code in Python. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you supply an example (piece of code), please explain &lt;em&gt;how&lt;/em&gt; the example works. &lt;/p&gt;&#xA;" OwnerUserId="3267" LastEditorUserId="3267" LastEditDate="2016-03-07T21:07:42.053" LastActivityDate="2016-03-07T21:07:42.053" Title="How can I test/demonstrate what the serial input and output buffers are?" Tags="|serial|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21532" PostTypeId="1" CreationDate="2016-03-07T17:09:32.283" Score="-5" ViewCount="597" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;// import the serial library&#xA;&#xA;SoftwareSerial Genotronex(10, 11); // RX, TX&#xA;int ledpin=13; // led on D13 will show blink on / off&#xA;int BluetoothData; // the data given from Computer&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Genotronex.begin(9600);&#xA;  Genotronex.println(&quot;Bluetooth On please press 1 or 0 blink LED ..&quot;);&#xA;  pinMode(ledpin,OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;   if (Genotronex.available()){&#xA;BluetoothData=Genotronex.read();&#xA;   if(BluetoothData=='1'){   // if number 1 pressed ....&#xA;   digitalWrite(ledpin,1);&#xA;   Genotronex.println(&quot;LED  On D13 ON ! &quot;);&#xA;   }&#xA;  if (BluetoothData=='0'){// if number 0 pressed ....&#xA;  digitalWrite(ledpin,0);&#xA;   Genotronex.println(&quot;LED  On D13 Off ! &quot;);&#xA;   }&#xA;}&#xA;delay(100);// prepare for next data ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can anyone help me how to write the sketch for voice recognition of the    above code.&#xA;I'm using AMR/BT voice control app`for voice recognition.&lt;/p&gt;&#xA;" OwnerUserId="19045" LastEditorUserId="6628" LastEditDate="2016-03-13T00:39:07.490" LastActivityDate="2016-03-13T00:39:07.490" Title="String matching serial input (was Code for voice recognition for arduino uno)" Tags="|sketch|" AnswerCount="1" CommentCount="16" ClosedDate="2016-03-13T01:09:11.183" ContentLicense="CC BY-SA 3.0" />
  <row Id="21533" PostTypeId="1" AcceptedAnswerId="21534" CreationDate="2016-03-07T17:35:53.207" Score="1" ViewCount="3708" Body="&lt;p&gt;I have a strange problem. I am trying to upload a .hex file to my lovely Arduino Pro Micro, but am unable to do so. If I use the Arduino IDE, it goes through perfectly fine and uploads the sketch. However, if I try to use avrdude from the terminal I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: error: programmer did not respond to command: leave prog mode&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: error: programmer did not respond to command: exit bootloader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My commandline is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -patmega32u4 -cavr109 -P/dev/ttyACM0 -t&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the full output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding&#xA;&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;Found programmer: Id = &quot;&quot;; type = &#xA;    Software Version = .; Hardware Version = .&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: error: buffered memory access not supported. Maybe it isn't&#xA;a butterfly/AVR109 but a AVR910 device?&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding&#xA;&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;Found programmer: Id = &quot;&quot;; type = &#xA;Software Version = .; Hardware Version = .&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;avrdude: error: buffered memory access not supported. Maybe it isn't&#xA;a butterfly/AVR109 but a AVR910 device?&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;    avrdude: error: programmer did not respond to command: leave prog mode&#xA;    avrdude: butterfly_recv(): programmer is not responding&#xA;    avrdude: error: programmer did not respond to command: exit bootloader&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you for any help, it is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--Dominic&lt;/p&gt;&#xA;" OwnerUserId="19039" LastEditorUserId="19409" LastEditDate="2016-10-16T17:13:03.633" LastActivityDate="2020-01-07T10:07:59.400" Title="I can not upload hex files outside of the Arduino IDE to my Pro Micro" Tags="|usb|uploading|avrdude|arduino-pro-micro|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21534" PostTypeId="2" ParentId="21533" CreationDate="2016-03-07T18:49:54.860" Score="2" Body="&lt;p&gt;Unlike the 328P and similar boards the 32U4 has no hardware method for triggering a reset to enter the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the boards with a UART -&gt; USB interface the USB interface chip manually toggles the RESET pin to activate the bootloader. Without that chip a reset can't be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So a different method had to be invented. That method involves opening the serial port at 1200 baud and immediately closing it. That triggers a reboot into the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE manually performs that task when you press the upload button. It is not something that avrdude knows how to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will have to come up with some method of opening the serial port at 1200 baud immediately before running avrdude. Of course, it means the serial interface device disappears for a short while whilst the chip reboots and enters the bootloader, so you need to ensure you have a delay between the reset method and the call to avrdude - a delay that is long enough for your OS to redetect the chip, yet not so long that the bootloader times out.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-07T18:49:54.860" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21535" PostTypeId="2" ParentId="21531" CreationDate="2016-03-07T19:40:13.637" Score="2" Body="&lt;p&gt;You can think of the incoming serial buffer as a bucket of water under a dripping tap. Next to the bucket is a cup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Water arrives through the tap and drips into the bucket. When you want to get some water, if there is enough water in the bucket, you dip the cup in and remove a cupful of water. If there isn't enough water you don't get anything in your cup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't dip the cup in for a while too much water will dribble into the bucket and it will overflow all over the floor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's exactly the same with serial data. It arrives through the UART hardware and is placed into the &quot;bucket&quot; by the UART receive interrupt. If you don't dip your cup in fast enough (Serial.read()) the bucket will overflow and any new data that arrives will spill onto the metaphorical floor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test this out you can just send more data to the Arduino than will fit into the serial buffer (typically 64 bytes) without reading any. Then after you have finished flooding the buffer you can read what is actually in the buffer and send it back again (maybe formatted nicely) so you can see what has actually ended up in the buffer and what hasn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One quick and dirty test would be to send the raw bytes 0 to 255 to the Arduino, then after a delay read them back and display the DEC values for them (&lt;code&gt;Serial.print(Serial.read(), DEC))&lt;/code&gt;) to see exactly which bytes arrived and which didn't (hint: you should see the numbers 0 to 63 if the buffer is 64 bytes big).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the transmit buffer it's slightly different.  You can think of it more as a bucket with a small hole in the bottom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You pour data (water) in the top at whatever speed you want, and it trickles out of the bottom at a pre-set rate (the baud rate - the size of the hole). You don't like wet messes though, so if the bucket is full you wait a while before putting more water into it. Just like with serial - if the transmit buffer is full any attempts to add to it will &lt;em&gt;block&lt;/em&gt; until data has been sent out by the UART transmit interrupt.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-07T19:40:13.637" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21536" PostTypeId="1" CreationDate="2016-03-07T19:45:26.617" Score="1" ViewCount="15332" Body="&lt;p&gt;I need the Arduino to read about 100 analog inputs. Is this even doable? If not what is the maximum analog inputs I can read into the Arduino (The maximum non trivially would be to use the analog pins that the board already provides).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But can I expand those out? Thanks!!&lt;/p&gt;&#xA;" OwnerUserId="19048" LastEditorUserId="10794" LastEditDate="2016-03-07T22:42:23.053" LastActivityDate="2021-02-14T21:28:06.380" Title="Expanding analog inputs to the Arduino" Tags="|adc|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21537" PostTypeId="2" ParentId="21536" CreationDate="2016-03-07T19:56:51.277" Score="6" Body="&lt;p&gt;There are two methods of doing what you want:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Add more ADC channels&lt;/li&gt;&#xA;&lt;li&gt;Multiplex the existing ADC channels&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;SPI or I2C ADC chips are readily available in a range of resolutions, sampling speeds and number of channels.  They are fairly simple to add to any Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the MCP3208 will give 8 channels of 12-bit resolution on SPI, which means 3 pins (MOSI/MISO/SCK) + 1 per chip (SS). So 1 chip would be 4 pins, 2 chips 5 pins, 3 chips 6 pins, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding lots of chips to the SPI bus though can itself be troublesome with the increased capacitance of all those inputs meaning you have to reduce your communication speed somewhat or add extra buffering to drive the bus with more current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I2C chips can be harder to have lots of them since there are only a limited number of addresses on an I2C bus - plus on many Arduinos the I2C is also two of the analog pins, which you may not want to sacrifice. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second option involves using analog multiplexers (eg the 4051) to switch different sources in to the existing analog inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A third option which you probably haven't considered is to have multiple arduinos (or other low-cost microcontrollers) each doing some of the sampling and then implementing some kind of communication method between them (or to a single master). This has the added advantage that it's then possible to sample multiple channels at once (one per microcontroller) speeding up your operation somewhat.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-07T19:56:51.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21538" PostTypeId="2" ParentId="21536" CreationDate="2016-03-07T20:12:43.837" Score="7" Body="&lt;p&gt;Expanding on part of Majenko's answer, you can use an analog multiplexer like the 74HC4051 to turn one analog port into 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NqeY6.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NqeY6.png&quot; alt=&quot;Analog multiplexer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its cousin, the 74HC4067, will multiplex 16 ports. Now with 6 analog inputs on the Arduino Uno, you could have 6 x 16 inputs = 96. The A/B/C controls signals could be paralleled up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would let you handle 96 inputs with only 6 extra chips, and pretty simple code. I have code examples on my page about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11976&quot; rel=&quot;noreferrer&quot;&gt;74HC4051 multiplexer / demultiplexer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 8 inputs the code is:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Example of using the 74HC4051 multiplexer/demultiplexer&#xA;&#xA;// Author: Nick Gammon&#xA;// Date:   14 March 2013&#xA;&#xA;const byte sensor = A0;  // where the multiplexer in/out port is connected&#xA;&#xA;// the multiplexer address select lines (A/B/C)&#xA;const byte addressA = 6; // low-order bit&#xA;const byte addressB = 5;&#xA;const byte addressC = 4; // high-order bit&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Starting multiplexer test ...&quot;);&#xA;  pinMode (addressA, OUTPUT); &#xA;  pinMode (addressB, OUTPUT); &#xA;  pinMode (addressC, OUTPUT); &#xA;  }  // end of setup&#xA;&#xA;int readSensor (const byte which)&#xA;  {&#xA;  // select correct MUX channel&#xA;  digitalWrite (addressA, (which &amp;amp; 1) ? HIGH : LOW);  // low-order bit&#xA;  digitalWrite (addressB, (which &amp;amp; 2) ? HIGH : LOW);&#xA;  digitalWrite (addressC, (which &amp;amp; 4) ? HIGH : LOW);  // high-order bit&#xA;  // now read the sensor&#xA;  return analogRead (sensor);&#xA;  }  // end of readSensor&#xA;&#xA;void loop ()&#xA;  {&#xA;  // show all 8 sensor readings&#xA;  for (byte i = 0; i &amp;lt; 7; i++)&#xA;    {&#xA;    Serial.print (&quot;Sensor &quot;);&#xA;    Serial.print (i);&#xA;    Serial.print (&quot; reads: &quot;);&#xA;    Serial.println (readSensor (i));&#xA;    }&#xA;  delay (1000);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-07T20:12:43.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21539" PostTypeId="2" ParentId="21442" CreationDate="2016-03-07T20:42:36.313" Score="3" Body="&lt;p&gt;Hmm... the length of your question makes it difficult to focus an answer. I'll try by stating my interpretation, then I'll provide a &lt;em&gt;longer&lt;/em&gt; answer ;-)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a way to wrap a text message between two Arduinos &lt;br&gt;&#xA;  &amp;nbsp;&amp;nbsp;(to increase reliability), but would still &lt;br&gt;&#xA;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;allow me to do testing without the wrapper?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I assume that's what you're asking, then the above comments have touched on various aspects of an answer: &quot;Yes.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's progress through my interpretation:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&quot;Text&quot; means ASCII values between 32 and 126 (SP and '~', the &lt;em&gt;printable&lt;/em&gt; characters).&lt;/li&gt;&#xA;&lt;li&gt;&quot;Wrapping a message&quot; means sending some bytes before and possibly after the text.&lt;/li&gt;&#xA;&lt;li&gt;&quot;Increasing reliability&quot; means &lt;em&gt;detecting&lt;/em&gt; and/or &lt;em&gt;correcting&lt;/em&gt; characters that get corrupted.&lt;/li&gt;&#xA;&lt;li&gt;&quot;Testing without the wrapper&quot; means that you would like to use the Serial Monitor to send example commands while you're in a noise-free environment, testing the logic of the command execution, not the mechanism of communicating reliably.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;Wrapping&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You're on the right path by prefixing the text with a binary header, and Nick's library shows how to use a &quot;special&quot; start and end byte to delimit the messages.  (This is also called message &quot;framing&quot;.)  If the START byte can appear inside the message elsewhere, you will need to either (1) &quot;escape&quot; the START byte when it appears inside the message, (2) provide a second method of verifying that the message is framed correctly (e.g., an END byte and/or a length), or (3) decrease the odds of a false start by using a multiple-byte START sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You appear to have chosen (2).  You are free to chose the bytes that follow the START byte.  Addressing, sequence number and message type are common.  Of course, the message length is in there somewhere.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Reliability.&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If you're happy to simply detect an error at the receiving end, a checksum is sufficient.  I'd like to suggest the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fletcher&amp;#39;s_checksum&quot; rel=&quot;nofollow&quot;&gt;Fletcher checksum&lt;/a&gt;, as it is simple, quick and fairly robust.  CRCs are more robust, but a little more expensive to compute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But because they are calculated over the rest of the message (the &quot;payload&quot;), they almost always appear at the end, before any END sequence.  This also makes it easier for the receiver, because it can accumulate the checksum as the bytes are received, and reject the message if the received checksum does not match the calculated checksum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use error detection to help with acknowledgements, if you decide to implement them.  An alternative to ACK/NAK messages is to request the current state (a poll command), expecting that it should reflect the previous (unacknowledged) command.  If the state doesn't match, send the command again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you also want to perform error correction, there are &lt;a href=&quot;https://en.wikipedia.org/wiki/Error_detection_and_correction&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;numerous&lt;/em&gt;&lt;/a&gt; ways to add that.  All of them will increase the size of the message, as well as the CPU time.  (Sorry, Nick, but sending complemented nybbles is not a very robust detection scheme, and it doubles the message size without adding correction capability.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Testing without the wrapper&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You could use CR/LF as your message framing and assume that anything after CR/LF is the start of an unwrapped message.  If it starts unwrapped, set a &lt;code&gt;bool&lt;/code&gt; flag that skips the checksum part and END byte.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Final notes&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Your current program is structured to hold the complete message in RAM for processing (sent or received).  This is not always feasible in the Arduino environment.  You don't put all the print chars in a buffer, then do one big &lt;code&gt;Serial.print( buffer )&lt;/code&gt;, do you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just like breaking a &lt;code&gt;Serial.print&lt;/code&gt; into several smaller prints, reception can be performed the same way.  You can watch for keywords, or accumulate parameter values &lt;em&gt;without&lt;/em&gt; buffering the entire message.  While it saves a lot of RAM, it also saves CPU time because each received character is handled once.  With a buffered approach, each character is handled multiple times: &lt;code&gt;read()&lt;/code&gt; into a buffer, then compared during a search, and maybe parsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of my &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=384191.msg2650191#msg2650191&quot; rel=&quot;nofollow&quot;&gt;recent posts&lt;/a&gt; has some general structure information, snipped a little for here:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Reading data on the Arduino is different from most PC applications.  Calling Serial.read() does not always return data.  Well, it returns -1 (or 0xFF) if no characters are available.  In a PC app, calling read will usually wait until a data has been received: the PC app is &quot;blocked&quot; until a character comes in.  That's not very noticeable because the PC has a nice multitasking OS so your pointer keeps moving and other windows respond, even though the one app is waiting for a character.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;On the Arduino, you can make it block the same way, but there's no OS that will let you do something else while you're waiting for data (yes, there are multitasking solutions, but let's avoid that for now).  So blocking on the Arduino can keep you from doing other things you may need to do, like blinking an LED or catching a button press.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;There are a few common ways to write an Arduino sketch that can cope with this speed disparity:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;1) Force the Arduino to wait for each character (i.e., block), and write the sketch in a very linear, top-to-bottom fashion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial1.available() == 0)&#xA;  ; // wait&#xA;  inByte1 = Serial1.read();&#xA;&#xA;  if (inByte1 == 0x3E){ // START byte&#xA;    buffer[0] = inByte1;&#xA;&#xA;    while (Serial1.available() == 0)&#xA;      ; // wait&#xA;    inByte1 = Serial1.read();&#xA;&#xA;    if (inByte1 == 0x03){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;2) Save each character in a buffer as it arrives until you have received an entire packet.  Then parse the packet all at once with similar linear code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static uint8_t count = 0; // keeps its value across calls to loop&#xA;&#xA;if (Serial1.available()) {&#xA;  inByte1 = Serial1.read();&#xA;&#xA;  if (inByte1 == 0x3E) { // START character&#xA;&#xA;    // Next packet starting, process the current one we've been saving,&#xA;    //   if we have saved enough bytes (skips small/bad packets).&#xA;&#xA;    if ((count &amp;gt; 6) &amp;amp;&amp;amp; (buffer[0] == 0x3E)) {&#xA;&#xA;      // SNIP: handle previous packet&#xA;&#xA;    }&#xA;&#xA;    // Reset the count to start a new packet with the 0x3E we just received.&#xA;    count = 0;&#xA;  }&#xA;&#xA;  // Save the current byte&#xA;  if (count &amp;lt; sizeof(buffer))&#xA;    buffer[ count ] = inByte1;&#xA;  count++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;3) Parse each character as it arrives, picking up where you left off after doing other things.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;void loop()&#xA;    {&#xA;        // statics keep values across calls to loop&#xA;        static uint8_t count         = 0;&#xA;        static bool    skipping      = true;&#xA;        static uint8_t messageLength = 0;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (Serial1.available()) { // or 'while'&#xA;&#xA;      uint8_t inByte = Serial1.read();&#xA;&#xA;      if (inByte == 0x3E) { // START  byte&#xA;&#xA;          // Starting a new packet!&#xA;&#xA;          buffer[0] = inByte;&#xA;          count    = 1;&#xA;          skipping = false;&#xA;&#xA;      } else if (!skipping) {&#xA;&#xA;          // Saving a packet, store the current byte&#xA;&#xA;          if (count &amp;lt; sizeof(buffer))&#xA;            buffer[ count ] = inByte;&#xA;&#xA;          // Use the current byte, depending on 'count'&#xA;          switch (count) {&#xA;            case 1:&#xA;              if (inByte != 0x03)&#xA;                skipping = true; // ignore other packet selector values&#xA;              break;&#xA;&#xA;            case 2:&#xA;              messageLength = inByte;&#xA;              // Error check?&#xA;              if (messageLength != 40)&#xA;                skipping = true;&#xA;              break;&#xA;&#xA;            case 3:&#xA;              // packetID = inByte; ?&#xA;              buffer[3] = inByte;&#xA;              break;&#xA;&#xA;            case SNIPPED: other header information fields&#xA;            case SNIPPED: accumulate/parse payload&#xA;            case SNIPPED: verify checksum (ignore packet or execute packet)&#xA;         }&#xA;&#xA;         count++;&#xA;     }&#xA; }&#xA;&#xA; // Do other things, too?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;}&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Choice 1 is very linear.  The disadvantage is that it blocks and does not recover from data errors very well.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Choice 2 is pretty easy to understand and it doesn't block; other tasks can do things while waiting for a complete packet.  The disadvantage is that all the packet processing happens when the last byte is received (actually, the first byte of the next packet in that code).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Choice 3 is more difficult to understand, because the entire section is executed for each character, either starting a new packet or using the switch statement to handle each char.  Different cases do a little work, depending on the count.  The advantage is that the processing is spread out over each character, and you can decide to skip the rest of a packet at any point.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is actually a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;Finite-State machine&lt;/a&gt; approach, and Nick Gammon has a &lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;great description&lt;/a&gt;, too.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-03-07T20:42:36.313" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21540" PostTypeId="2" ParentId="21512" CreationDate="2016-03-07T21:25:32.563" Score="0" Body="&lt;p&gt;A quick google search turned up a solution in the very first result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=31&amp;amp;t=36560&quot; rel=&quot;nofollow&quot;&gt;https://forums.adafruit.com/viewtopic.php?f=31&amp;amp;t=36560&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a contribution from an Adafruit customer. &#xA;All credits go to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source thread: &lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=31&amp;amp;t=36560&quot; rel=&quot;nofollow&quot;&gt;https://forums.adafruit.com/viewtopic.php?f=31&amp;amp;t=36560&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19016" LastActivityDate="2016-03-07T21:25:32.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21541" PostTypeId="1" AcceptedAnswerId="21543" CreationDate="2016-03-07T22:25:23.683" Score="0" ViewCount="176" Body="&lt;p&gt;I experience that if the Arduino (Teensy 3.2) writes a rather long stream of characters to serial, the python script on the other end only receives the first 640 characters. I have found this result both by printing chars, printing lines and by using ArduinoJson's prettyPrintTo(Serial). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, that it does not matter what chunks of characters I read in the Python scripts, whether it is &lt;code&gt;read(5)&lt;/code&gt; or &lt;code&gt;read(1000)&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the Arduino Serial Monitor, I get all the data, ie more than the 640 characters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I can understand, it is not possible for a sketch to write &quot;too fast&quot; or &quot;too much&quot; to the serial, so there must be something on the pc side receiving the data. However, the Python script for some reason does not get all the data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the problem here? Where should I look for the problem/solution? Perhaps this is more a Linux or Python question, but I will try here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sketch - printLines()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void printLines() {&#xA;  for (int i=0; i&amp;lt;100; i++) {&#xA;    // length below is 40 incl end of line character&#xA;    Serial.printf(&quot;abcdefthijklmnopqrstuvxyz123456789--%03d\n&quot;, i);&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  delay(500);&#xA;  printLines();&#xA;  //printChars();&#xA;  //printJson();&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sketch - printChars()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void printLines() {&#xA;  for (int i=0; i&amp;lt;1000; i++) {&#xA;    Serial.write('x');&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sketch - printJson()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void printJson() {&#xA;  StaticJsonBuffer&amp;lt;10000&amp;gt; jsonBuffer;&#xA;  JsonArray &amp;amp;root = jsonBuffer.createArray();&#xA;  for (int i=0; i&amp;lt;700; i++) {&#xA;    root.add(i);&#xA;  }&#xA;  root.prettyPrintTo(Serial);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Python script&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;&#xA;ser = serial.Serial('/dev/ttyACM0')&#xA;ser.timeout = 0.5&#xA;&#xA;# PARAMETERS:&#xA;# (As long as num_iterations*num_chars &amp;gt;= 640, EXACTLY 640 characters are read)&#xA;num_chars = 100&#xA;num_iterations = 10&#xA;&#xA;chars_read = 0&#xA;for i in range(num_iterations):&#xA;    s = ser.read(num_chars)&#xA;    chars_read += len(s)&#xA;    print(&quot;### i: %d, reading %d chars, char %d to %d, len(s): %d, total chars: %d&quot; &#xA;        % (i,num_chars, i * num_chars, i * num_chars + num_chars -1, len(s), chars_read ))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Terminal output&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;jan@jan:~/Desktop/batlogger/localserver$ sudo python localserver.py &#xA;### i: 0, reading 100 chars, char 0 to 99, len(s): 100, total chars: 100&#xA;### i: 1, reading 100 chars, char 100 to 199, len(s): 100, total chars: 200&#xA;### i: 2, reading 100 chars, char 200 to 299, len(s): 100, total chars: 300&#xA;### i: 3, reading 100 chars, char 300 to 399, len(s): 100, total chars: 400&#xA;### i: 4, reading 100 chars, char 400 to 499, len(s): 100, total chars: 500&#xA;### i: 5, reading 100 chars, char 500 to 599, len(s): 100, total chars: 600&#xA;### i: 6, reading 100 chars, char 600 to 699, len(s): 40, total chars: 640&#xA;### i: 7, reading 100 chars, char 700 to 799, len(s): 0, total chars: 640&#xA;### i: 8, reading 100 chars, char 800 to 899, len(s): 0, total chars: 640&#xA;### i: 9, reading 100 chars, char 900 to 999, len(s): 0, total chars: 640&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3267" LastEditorUserId="3267" LastEditDate="2016-03-08T08:35:09.770" LastActivityDate="2016-03-08T08:35:09.770" Title="Script on pc only gets 640 characters via serial" Tags="|serial|python|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21542" PostTypeId="2" ParentId="21541" CreationDate="2016-03-07T23:08:32.300" Score="0" Body="&lt;p&gt;I wouldn't be running as root. Why do that, just to execute a Python script?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, your problem is that you are not waiting for input. Your Python script is executing faster than the Arduino can pump out the bytes. At 9600 baud you send one byte every 1/960 of a second, so to send 4000 bytes (100 x 40) would take 4000 * 1/960 = 4.166 seconds. However your Python script powers along, getting the first 600 or so which may have been buffered already, and then finishes. You need to rewrite so you wait for a line to arrive. For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;&#xA;ser = serial.Serial('/dev/ttyACM0')&#xA;&#xA;while True:&#xA;  s = ser.readline()&#xA;  print (s)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I ran that I saw all 100 lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, you need to modify that to break out of the loop. Maybe a special character would do that. Typically a newline is used.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;PySerial's read function is blocking by default. - or it has a long timeout anyway&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not when I tested it. Using the code in the question, and without the Arduino even plugged in, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;### i: 0, reading 100 chars, char 0 to 99, len(s): 0, total chars: 0&#xA;### i: 1, reading 100 chars, char 100 to 199, len(s): 0, total chars: 0&#xA;### i: 2, reading 100 chars, char 200 to 299, len(s): 0, total chars: 0&#xA;### i: 3, reading 100 chars, char 300 to 399, len(s): 0, total chars: 0&#xA;### i: 4, reading 100 chars, char 400 to 499, len(s): 0, total chars: 0&#xA;### i: 5, reading 100 chars, char 500 to 599, len(s): 0, total chars: 0&#xA;### i: 6, reading 100 chars, char 600 to 699, len(s): 0, total chars: 0&#xA;### i: 7, reading 100 chars, char 700 to 799, len(s): 0, total chars: 0&#xA;### i: 8, reading 100 chars, char 800 to 899, len(s): 0, total chars: 0&#xA;### i: 9, reading 100 chars, char 900 to 999, len(s): 0, total chars: 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Execution time: 5.5 s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the code sets the timeout to 0.5s. But that isn't good enough. You can't assume that 400 bytes will arrive within 0.5s. They &lt;em&gt;should&lt;/em&gt; if both sides are perfectly synchronized (at 9600 baud it would take 0.416s). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But serial doesn't work that way. You can't just read for 0.5s and hope everything you want arrives in that time. Heck, it may not have even started sending.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;OK, I admit I tested with my Uno and not a Teensy, but this amended Python script shows similar results:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;&#xA;ser = serial.Serial('/dev/ttyACM2')&#xA;ser.timeout = 0.5&#xA;&#xA;# PARAMETERS:&#xA;# (As long as num_iterations*num_chars &amp;gt;= 640, EXACTLY 640 characters are read)&#xA;num_chars = 100&#xA;num_iterations = 10&#xA;&#xA;chars_read = 0&#xA;result = &quot;&quot;&#xA;for i in range(num_iterations):&#xA;    s = ser.read(num_chars)&#xA;    result = result + str(s)&#xA;    chars_read += len(s)&#xA;    print(&quot;### i: %d, reading %d chars, char %d to %d, len(s): %d, total chars: %d&quot;&#xA;        % (i,num_chars, i * num_chars, i * num_chars + num_chars -1, len(s), chars_read ))&#xA;    print (&quot;String = &quot; + str (s))&#xA;    print ()&#xA;&#xA;print (&quot;-&quot; * 70)&#xA;print (&quot;Total output =&quot;)&#xA;print (result)&#xA;print (&quot;Total length =&quot;, len (result))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;### i: 0, reading 100 chars, char 0 to 99, len(s): 100, total chars: 100&#xA;String = b'thijz123456789--69\nabcdefthijklmnopqrstuvxyz123456789--70\nabcdefthijklmnopqrstuvxyz123456789yz123456'&#xA;&#xA;### i: 1, reading 100 chars, char 100 to 199, len(s): 100, total chars: 200&#xA;String = b'789--68\nabcdefthijklmnopqrstuvxyz123456789--69\nabcdefthijklmnopqrstuvxyz123456789--70\nabcdefthijklmn'&#xA;&#xA;### i: 2, reading 100 chars, char 200 to 299, len(s): 21, total chars: 221&#xA;String = b'opqrstuvxyz123456789\xff'&#xA;&#xA;### i: 3, reading 100 chars, char 300 to 399, len(s): 0, total chars: 221&#xA;String = b''&#xA;&#xA;### i: 4, reading 100 chars, char 400 to 499, len(s): 0, total chars: 221&#xA;String = b''&#xA;&#xA;### i: 5, reading 100 chars, char 500 to 599, len(s): 0, total chars: 221&#xA;String = b''&#xA;&#xA;### i: 6, reading 100 chars, char 600 to 699, len(s): 100, total chars: 321&#xA;String = b'abcdefthijklmnopqrstuvxyz123456789--0\nabcdefthijklmnopqrstuvxyz123456789--1\nabcdefthijklmnopqrstuvxy'&#xA;&#xA;### i: 7, reading 100 chars, char 700 to 799, len(s): 100, total chars: 421&#xA;String = b'z123456789--2\nabcdefthijklmnopqrstuvxyz123456789--3\nabcdefthijklmnopqrstuvxyz123456789--4\nabcdefthij'&#xA;&#xA;### i: 8, reading 100 chars, char 800 to 899, len(s): 100, total chars: 521&#xA;String = b'klmnopqrstuvxyz123456789--5\nabcdefthijklmnopqrstuvxyz123456789--6\nabcdefthijklmnopqrstuvxyz123456789'&#xA;&#xA;### i: 9, reading 100 chars, char 900 to 999, len(s): 100, total chars: 621&#xA;String = b'--7\nabcdefthijklmnopqrstuvxyz123456789--8\nabcdefthijklmnopqrstuvxyz123456789--9\nabcdefthijklmnopqrst'&#xA;&#xA;----------------------------------------------------------------------&#xA;Total output =&#xA;b'thijz123456789--69\nabcdefthijklmnopqrstuvxyz123456789--70\nabcdefthijklmnopqrstuvxyz123456789yz123456'b'789--68\nabcdefthijklmnopqrstuvxyz123456789--69\nabcdefthijklmnopqrstuvxyz123456789--70\nabcdefthijklmn'b'opqrstuvxyz123456789\xff'b''b''b''b'abcdefthijklmnopqrstuvxyz123456789--0\nabcdefthijklmnopqrstuvxyz123456789--1\nabcdefthijklmnopqrstuvxy'b'z123456789--2\nabcdefthijklmnopqrstuvxyz123456789--3\nabcdefthijklmnopqrstuvxyz123456789--4\nabcdefthij'b'klmnopqrstuvxyz123456789--5\nabcdefthijklmnopqrstuvxyz123456789--6\nabcdefthijklmnopqrstuvxyz123456789'b'--7\nabcdefthijklmnopqrstuvxyz123456789--8\nabcdefthijklmnopqrstuvxyz123456789--9\nabcdefthijklmnopqrst'&#xA;Total length = 669&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since the output of the Uno would be deterministic (it would do the same thing every time) the problem is in the way you are processing the data at the Python end. Look at the line numbers in the above list. They don't even start at 0.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-08T04:38:54.170" LastActivityDate="2016-03-08T04:38:54.170" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21543" PostTypeId="2" ParentId="21541" CreationDate="2016-03-07T23:28:41.590" Score="3" Body="&lt;p&gt;You are not using a serial connection, you are using a USB CDC/ACM connection, and that is a very very different thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a serial connection when you send data it gets sent regardless of whether there is anything listening for it - the TX IO pin toggles high and low regardless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, with a CDC/ACM connection it's only possible to send data when there is something actively listening at the remote end - that is, when the port /dev/ttyACM0 has been opened by an application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until that port has been opened any data sent will remain in internal buffers.  These buffers are 64 bytes each in size (that's the size of a CDC/ACM packet), and there are (I would guess) 10 of them on the Teensy3.  After these buffers are full, because there is nothing receiving the data, there can never be any more room made for more data, so instead of blocking like a serial connection does it just discards the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have filled the buffers with 640 bytes of data and thrown away the rest.  That data just sits there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then eventually you open the /dev/ttyACM0 port and the Teensy3 is now able to send CDC/ACM packets through the USB.  And it has 10 of those packets sat there waiting to go out, so it sends them.  So you receive the 640 bytes of data that you had buffered up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your mistake is basically not waiting for the port to be opened before sending data to the remote end.  You can test the state of the port (kind of, but that's &lt;a href=&quot;https://arduino.stackexchange.com/questions/20836/ifserial-not-working-correctly-on-micro-or-pro-micro/20839#20839&quot;&gt;a whole other subject&lt;/a&gt;) by examining the Serial object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial) {&#xA;    // ... the port is open&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In general you can usually just wait at the start of your program before starting anything else with a simple while:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (!Serial); // Wait for the port to be opened&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-07T23:28:41.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21544" PostTypeId="1" AcceptedAnswerId="21546" CreationDate="2016-03-07T23:37:47.727" Score="0" ViewCount="169" Body="&lt;p&gt;When I release my hand from the button on pin 2, the stepper motor takes at least few seconds to stop, but I want it stop immediately. here's my codes:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt; #include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;    const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution&#xA;    // for your motor&#xA;&#xA;    // initialize the stepper library on pins 8 through 11:&#xA;    Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);&#xA;&#xA;    bool dir = false;&#xA;    bool power = true;&#xA;&#xA;    void dir_pin() {&#xA;      if (!digitalRead(3)) {&#xA;        dir = !dir;&#xA;      }&#xA;    }//when the switch is being pressed&#xA;    //it condition would be different from last time&#xA;&#xA;    void setup() {&#xA;      // set the speed at 60 rpm:&#xA;      myStepper.setSpeed(60);&#xA;      // initialize the serial port:&#xA;      Serial.begin(9600);&#xA;      pinMode(2, INPUT_PULLUP);//it is a easier way to using INPUT-PULLUP&#xA;      //cause you dont have to use a real resistor&#xA;      pinMode(3, INPUT_PULLUP);//why choose those two pins&#xA;      //cause for uno, the interrupt pin are pin 2 and pin 3&#xA;      attachInterrupt(digitalPinToInterrupt(3), dir_pin, FALLING);&#xA;      pinMode(A0, INPUT);&#xA;    }&#xA;&#xA;    void loop() {&#xA;      int pwr = analogRead(A0) / 100;&#xA;      Serial.print(&quot;power:&quot;);&#xA;      Serial.print(power);&#xA;      Serial.print(&quot;  pwr:&quot;);&#xA;      Serial.print(pwr);&#xA;      Serial.print(&quot;  dir:&quot;);&#xA;      Serial.println(dir);&#xA;      while (digitalRead(2) == 0)&#xA;      {&#xA;        if (pwr) {&#xA;          myStepper.setSpeed(pwr);&#xA;          int pwr = analogRead(A0) / 100;&#xA;&#xA;          if (dir) {&#xA;            //Serial.println(&quot;clockwise&quot;);&#xA;            myStepper.step(stepsPerRevolution);&#xA;            //delay(500);&#xA;          }&#xA;          // step one revolution in the other direction:&#xA;          else if (!dir) {&#xA;            //Serial.println(&quot;counterclockwise&quot;);&#xA;            myStepper.step(-stepsPerRevolution);&#xA;            //delay(500);&#xA;          }&#xA;        }&#xA;        else&#xA;        {&#xA;          myStepper.step(0);&#xA;        }&#xA;      }&#xA;      while (digitalRead(2) == 1)&#xA;      {&#xA;        pwr = 0;&#xA;        myStepper.step(0);&#xA;      }&#xA;      delay(10);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19052" LastEditorUserId="4131" LastEditDate="2016-03-10T07:12:46.873" LastActivityDate="2016-03-10T07:12:46.873" Title="Stepper motor doesn't start immediately when i pressed the button" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21545" PostTypeId="1" CreationDate="2016-03-08T00:22:45.707" Score="1" ViewCount="1915" Body="&lt;p&gt;I am having trouble getting this module to work using the tmrh20 lib. I am using these modules with two arduino mega and a 3.3V external power supply. I also placed 10 uF in parallel with the modules power pin. I would really appreciate any comments or suggustions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code below all I am trying to do is turn on a led.&#xA;Here are my pin assignment for both arduinos&#xA;CE -&gt; 7&#xA;CSN -&gt; 8&#xA;SCK -&gt; 52&#xA;MOSI -&gt; 51&#xA;MISO -&gt; 50&#xA;IRQ -&gt; unconnected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Transmitter&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//#include &amp;lt;DigitalIO.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;#include &amp;lt;printf.h&amp;gt;&#xA;RF24 radio(7,8);&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;unsigned long msg = 375983;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    printf_begin();&#xA;    Serial.println(&quot;Transmitter&quot;);&#xA;    pinMode(9, INPUT);&#xA;    radio.begin();&#xA;    radio.setChannel(108);&#xA;    radio.openWritingPipe(pipe);&#xA;    radio.startListening();&#xA;    radio.printDetails();&#xA;}&#xA;&#xA;void loop() {&#xA;  radio.stopListening();&#xA;  if (digitalRead(9) == HIGH)&#xA;  {&#xA;    while (!radio.write(&amp;amp;msg, sizeof(msg))){&#xA;      radio.write(&amp;amp;msg, sizeof(msg));&#xA;}&#xA;  Serial.println(&quot;Sending.....&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;Awaiting Input....&quot;);&#xA;  }&#xA;  delay(500);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;print detail report&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1&#xA;RX_ADDR_P0-1 = 0xffffffffff 0xffffffffff&#xA;RX_ADDR_P2-5 = 0x7f 0xff 0x7f 0xff&#xA;TX_ADDR = 0x0000000000&#xA;RX_PW_P0-6 = 0xff 0x7f 0xff 0x7f 0xff 0xff&#xA;EN_AA = 0xff&#xA;EN_RXADDR = 0xff&#xA;RF_CH = 0xff&#xA;RF_SETUP = 0xff&#xA;CONFIG = 0xff&#xA;DYNPD/FEATURE = 0x7f 0xff&#xA;Data Rate = 1MBPS&#xA;Model = nRF24L01&#xA;CRC Length = Disabled&#xA;PA Power = PA_MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiver&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//#include &amp;lt;DigitalIO.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;RF24.h&quot;&#xA;#include &amp;lt;printf.h&amp;gt;&#xA;RF24 radio(7,8);&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;unsigned long msg;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    printf_begin();&#xA;    Serial.println(&quot;Receiver&quot;);&#xA;    pinMode(9, OUTPUT);&#xA;    radio.begin();&#xA;    radio.setChannel(108);&#xA;    radio.openReadingPipe(0,pipe);&#xA;    radio.printDetails();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;   radio.startListening();&#xA;   digitalWrite(9, LOW);&#xA;  if(radio.available()){&#xA;    while(radio.available())&#xA;    {&#xA;    radio.read(&amp;amp;msg, sizeof(msg));&#xA;    Serial.println(&quot;Incoming...&quot;);&#xA;    delay(500);&#xA;    Serial.println(msg);&#xA;    }&#xA;  }&#xA;  else{&#xA;    Serial.println(&quot;No Msg&quot;);&#xA;  }&#xA;  radio.stopListening();&#xA;  Serial.println(msg);&#xA;  if (msg == 375983){&#xA;    digitalWrite(9, HIGH);&#xA;    Serial.println(msg);&#xA;  }&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;print detail report&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0&#xA;RX_ADDR_P0-1 = 0x0000000000 0x0000000000&#xA;RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00&#xA;TX_ADDR = 0x0000000000&#xA;RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00&#xA;EN_AA = 0x00&#xA;EN_RXADDR = 0x00&#xA;RF_CH = 0x00&#xA;RF_SETUP = 0x00&#xA;CONFIG = 0x00&#xA;DYNPD/FEATURE = 0x00 0x00&#xA;Data Rate = 1MBPS&#xA;Model = nRF24L01&#xA;CRC Length = Disabled&#xA;PA Power = PA_MIN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&#xA;Transmitter PrintDetail&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0&#xA;RX_ADDR_P0-1     = 0x00000000e1 0xc2c2c2c2c2&#xA;RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6&#xA;TX_ADDR      = 0x00000000e1&#xA;RX_PW_P0-6   = 0x20 0x00 0x00 0x00 0x00 0x00&#xA;EN_AA        = 0x3f&#xA;EN_RXADDR    = 0x02&#xA;RF_CH        = 0x6c&#xA;RF_SETUP     = 0x07&#xA;CONFIG       = 0x0f&#xA;DYNPD/FEATURE    = 0x00 0x00&#xA;Data Rate    = 1MBPS&#xA;Model        = nRF24L01+&#xA;CRC Length   = 16 bits&#xA;PA Power     = PA_MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results form tmrh20 Getting Started Example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sent 8340224, Got response 0, Round-trip delay 547172 microseconds&#xA;Now sending&#xA;Sent 9889124, Got response 0, Round-trip delay 511072 microseconds&#xA;Now sending&#xA;Sent 11401920, Got response 0, Round-trip delay 43348 microseconds&#xA;Now sending&#xA;Sent 12446992, Got response 0, Round-trip delay 635580 microseconds&#xA;Now sending&#xA;Sent 14084352, Got response 0, Round-trip delay 1620788 microseconds&#xA;Now sending&#xA;Sent 16706968, Got response 0, Round-trip delay 1227548 microseconds&#xA;Now sending&#xA;Sent 18936340, Got response 0, Round-trip delay 145372 microseconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*** PRESS 'T' to begin transmitting to the other node&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second arduino is not printing anything on the serial monitor, no matter what I enter.&lt;/p&gt;&#xA;" OwnerUserId="19054" LastEditorUserId="19054" LastEditDate="2016-03-08T22:26:39.850" LastActivityDate="2016-12-27T12:07:55.660" Title="Arduino Mega with nRF24L01+ module" Tags="|arduino-mega|nrf24l01+|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21546" PostTypeId="2" ParentId="21544" CreationDate="2016-03-08T01:04:00.260" Score="0" Body="&lt;p&gt;You tell it to move whole 200-step revolutions, so once it begins a revolution, it must continue.  At 60 RPM, that should be up to 1 full second after you open pin 2.   Depending on the analogRead(A0)/100, a full revolution could take much longer than 1 second -- maybe 5.86s to 6000s&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it to stop immediately, disregarding full revolutions, you could:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      stepsPerButtonpress = 1;&#xA;&#xA;      ...&#xA;&#xA;      if (dir) {&#xA;        //Serial.println(&quot;clockwise&quot;);&#xA;        myStepper.step(stepsPerButtonpress);&#xA;        //delay(500);&#xA;      }&#xA;      // step one revolution in the other direction:&#xA;      else if (!dir) {&#xA;        //Serial.println(&quot;counterclockwise&quot;);&#xA;        myStepper.step(-stepsPerButtonpress);&#xA;        //delay(500);&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could reduce stepsPerRevolution to the fraction of steps you want to treat as a unit, and increase rpm proportionally.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-08T01:10:47.257" LastActivityDate="2016-03-08T01:10:47.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21547" PostTypeId="1" CreationDate="2016-03-08T01:42:03.263" Score="3" ViewCount="2786" Body="&lt;p&gt;Is it possible to program the Arduino Due without the Arduino IDE? Is there a standalone program that can be downloaded, and be used to upload a .bin file (which has already been generated from the arduino IDE) to the Due? Any guidance appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about SAM-BA programmer, downloaded it but double clicking the .exe file does nothing. Something seems to open but it disappers.&lt;/p&gt;&#xA;" OwnerUserId="19056" LastActivityDate="2016-03-08T16:16:25.983" Title="How to program arduino due without arduino ide" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21548" PostTypeId="2" ParentId="21547" CreationDate="2016-03-08T02:24:44.030" Score="2" Body="&lt;p&gt;The standalone program for most arduinos is avrdude: &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avrdude/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, for the Due, it is &lt;a href=&quot;https://sourceforge.net/projects/b-o-s-s-a/&quot; rel=&quot;nofollow&quot;&gt;BOSSA&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Unlike other Arduino boards which use avrdude for uploading, the Due&#xA;  relies on &lt;a href=&quot;http://sourceforge.net/projects/b-o-s-s-a/&quot; rel=&quot;nofollow&quot;&gt;bossac&lt;/a&gt;. &#xA;   -- &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;Arduino Due Overview&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-08T16:16:25.983" LastActivityDate="2016-03-08T16:16:25.983" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21549" PostTypeId="1" AcceptedAnswerId="21562" CreationDate="2016-03-08T02:26:07.043" Score="0" ViewCount="61" Body="&lt;p&gt;I'm planning to use a KPCI-3101 Keithley with a computer to creat a DAS with a sensor to show the data on computer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can i replace the Card and computer with an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="19057" LastActivityDate="2016-03-08T10:39:54.697" Title="Can a KCPI-3101 be replaced with an Arduino?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21550" PostTypeId="1" CreationDate="2016-03-08T02:30:34.460" Score="2" ViewCount="612" Body="&lt;p&gt;Is it possible to communicate with and use the GSM shield directly from the computer, without using an arduino board?&lt;/p&gt;&#xA;" OwnerUserId="18661" LastActivityDate="2016-04-07T04:08:25.730" Title="Can I connect an Arduino GSM Shield directly to a PC?" Tags="|shields|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21551" PostTypeId="2" ParentId="21550" CreationDate="2016-03-08T02:40:07.123" Score="1" Body="&lt;p&gt;You can connect a &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoGSMShield&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoGSMShield&lt;/a&gt; to your computer with a USB-TTL serial cable, but you need to make sure you supply enough 700-1000ma to drive the GSM when it is transmitting.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Power&#xA;  It is recommended that the board be powered with an external power supply that can provide between 700mA and 1000mA. Powering an Arduino and the GSM shield from a USB connection is not recommended, as USB cannot provide the required current for when the modem is in heavy use. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T02:40:07.123" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21552" PostTypeId="2" ParentId="21499" CreationDate="2016-03-08T02:51:35.360" Score="0" Body="&lt;p&gt;From your pic, it looks like the upper left corner has a jumper with TTL level TX, RX, GND.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T02:51:35.360" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21553" PostTypeId="2" ParentId="21549" CreationDate="2016-03-08T02:58:17.693" Score="1" Body="&lt;p&gt;You can't replace the &lt;a href=&quot;http://www.testequipmentdepot.com/keithley/multifunction-boards/kpci-3101a.htm&quot; rel=&quot;nofollow&quot;&gt;KPCI-3101 Keithley's&lt;/a&gt; 16 channels of 12 bit 225kS/s with an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T02:58:17.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21554" PostTypeId="2" ParentId="21256" CreationDate="2016-03-08T02:58:54.540" Score="1" Body="&lt;p&gt;I suspect a low RAM failure.  Here are some suggestions that will dramatically lower your RAM usage:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; You still have &lt;code&gt;Serial.print&lt;/code&gt; using double-quoted C string constants.  Use &lt;code&gt;F(&quot;C string&quot;)&lt;/code&gt; for those, too.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println( F(&quot;WiFi shield not present&quot;) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every double-quoted C string uses RAM in addition to FLASH program space.  You have already saved a bunch, but you should get rid of the above uses.&#xA;&lt;hr&gt;&#xA;&lt;strong&gt;2) Don't use &lt;code&gt;String&lt;/code&gt; for &lt;code&gt;setHue&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TL;DR - it will use extra RAM, FLASH, CPU time, and cause inexplicable or random failures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, use C strings, aka &lt;code&gt;char&lt;/code&gt; arrays for variables, or double-quoted string constants.  When the constants are wrapped with the &lt;strong&gt;F()&lt;/strong&gt; macro, they don't use &lt;em&gt;any&lt;/em&gt; RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of how to define and call a &lt;code&gt;setHue&lt;/code&gt; with C strings instead of &lt;code&gt;String&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; See complete code below in UPDATE 3/9/2016 section &amp;lt;--&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This just prints the C strings to &lt;code&gt;Serial&lt;/code&gt;, but I hope you can see how they could also be printed to the &lt;code&gt;client&lt;/code&gt;.&#xA;&lt;hr&gt;&#xA;&lt;strong&gt;3) Don't use &lt;code&gt;String&lt;/code&gt; for &lt;code&gt;getHue&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example of how to define and call a &lt;code&gt;getHue&lt;/code&gt; that uses C strings instead of &lt;code&gt;String&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;--&amp;gt; See complete code below in UPDATE 3/9/2016 section &amp;lt;--&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just copy and paste the displayed JSON into the Serial Monitor &quot;Send&quot; field.  The debug prints will display what gets parsed.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;NOTE: It's not clear if the JSON attributes always come back in the same order.  This example expects the same order in which they were sent.  Other techniques would have to be used to accommodate &lt;em&gt;any&lt;/em&gt; order. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;4)&lt;/strong&gt; Be sure to call &lt;code&gt;client.flush()&lt;/code&gt; before &lt;em&gt;every&lt;/em&gt; &lt;code&gt;client.stop()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;Summary:&lt;/strong&gt;  I would guess that the combination of non-F() &quot;C strings&quot; wasting RAM, plus the &lt;code&gt;String&lt;/code&gt; use of RAM (doubled or more), is leading to a low-RAM failure.  The above approach will lower RAM usage dramatically, and also save more than 1.6kB in program space.  After implementing these changes, almost all RAM will be available for the WiFi libraries.&#xA;&lt;hr&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;UPDATE 3/9/2016&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Here's my changes, merged into your second sketch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;mynetwork&quot;;     //  your network SSID (name)&#xA;char pass[] = &quot;mypass&quot;;  // your network password&#xA;int status = WL_IDLE_STATUS;     // the Wifi radio's status&#xA;&#xA;//Hue constants&#xA;const char hueHubIP[] = &quot;192.168.0.50&quot;;  //Hue hub IP&#xA;const char hueUsername[] = &quot;myhue&quot;;  //Hue username&#xA;const int hueHubPort = 80;&#xA;&#xA;IPAddress server(192,168,0,50);&#xA;&#xA;// Uncomment this to *really* use the Wi-Fi sheild.&#xA;// Comment this to read &amp;amp; write everything to the Serial Monitor for testing.&#xA;//#define REAL_WIFI&#xA;#ifdef REAL_WIFI&#xA;WiFiClient client;&#xA;#else&#xA;HardwareSerial &amp;amp; client = Serial; // redirect 'client' to the Serial Monitor&#xA;#endif&#xA;&#xA;//Hue variables&#xA;boolean hueOn;  // on/off&#xA;int hueBri;  // brightness value&#xA;long hueHue;  // hue value&#xA;String hueCmd;  // Hue command&#xA;&#xA;unsigned long buffer=0;  //buffer for received data storage&#xA;unsigned long addr;&#xA;IPAddress ip;&#xA;&#xA;void setup()&#xA;{&#xA; //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(F(&quot;WiFi shield not present&quot;));&#xA;    // don't continue:&#xA;#ifdef REAL_WIFI&#xA;    while (true);&#xA;#else&#xA;    status = WL_CONNECTED;&#xA;#endif&#xA;  }&#xA;&#xA;  // attempt to connect to Wifi network:&#xA;  while (status != WL_CONNECTED) {&#xA;    Serial.print(F(&quot;Attempting to connect to WPA SSID: &quot;));&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;    delay(10000);&#xA;  }&#xA;&#xA;  // you're connected now, so print out the data:&#xA;  Serial.print(F(&quot;You're connected to the network&quot;));&#xA;  printCurrentNet();&#xA;  printWifiData();&#xA;}&#xA;&#xA;&#xA;void loop() &#xA;{&#xA;  setHue&#xA;    ( 1,&#xA;      F(&quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;),&#xA;      random(15,25),&#xA;      F(&quot;}&quot;)&#xA;    );&#xA;&#xA;  delay( 10000 );&#xA;&#xA;  setHue&#xA;    ( 2,&#xA;      F(&quot;{\&quot;on\&quot;: true,\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;),&#xA;      random(15,25),&#xA;      F(&quot;}&quot;)&#xA;    ); &#xA;&#xA;  delay( 10000 );&#xA;&#xA;  setHue&#xA;    ( 1,&#xA;      F(&quot;{\&quot;hue\&quot;: 65280,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;),&#xA;      random(15,25),&#xA;      F(&quot;}&quot;)&#xA;    );&#xA;&#xA;  delay( 10000 );&#xA;&#xA;  setHue&#xA;    ( 2,&#xA;      F(&quot;{\&quot;hue\&quot;: 50100,\&quot;sat\&quot;:255,\&quot;bri\&quot;:255,\&quot;transitiontime\&quot;:&quot;),&#xA;      random(15,25),&#xA;      F(&quot;}&quot;)&#xA;    );&#xA;&#xA;  delay( 10000 );&#xA;&#xA;//  getHue( 1 );&#xA;//  getHue( 2 );&#xA;}&#xA;&#xA;&#xA;/* setHue() is our main command function, which needs to be passed a light number and a &#xA; * properly formatted command string in JSON format (basically a Javascript style array of variables&#xA; * and values. It then makes a simple HTTP PUT request to the Bridge at the IP specified at the start.&#xA; */&#xA;boolean setHue&#xA;  ( int                        lightNum,&#xA;    const __FlashStringHelper *header,&#xA;    int                        parameter,&#xA;    const __FlashStringHelper *trailer )&#xA;{&#xA;#ifdef REAL_WIFI&#xA;  client.stop();&#xA;&#xA;  if (client.connect(server, 80))&#xA;#endif&#xA;  {&#xA;&#xA;    Serial.println(F(&quot;connected to server&quot;));&#xA;#ifdef REAL_WIFI&#xA;    if (client.connected()&amp;amp;&amp;amp; status == WL_CONNECTED)&#xA;#endif&#xA;    {&#xA;      client.print(F(&quot;PUT /api/&quot;));&#xA;      client.print(hueUsername);&#xA;      client.print(F(&quot;/lights/&quot;));&#xA;      client.print(lightNum);  // hueLight zero based, add 1&#xA;      client.println(F(&quot;/state HTTP/1.1&quot;));&#xA;      client.println(F(&quot;Connection: keep-alive&quot;));&#xA;      client.print(F(&quot;Host: &quot;));&#xA;      client.println(hueHubIP);&#xA;&#xA;      // Calculate total command length.&#xA;      int cmdLength =&#xA;        strlen_P( (const prog_char *)header ) +&#xA;        1 +   //   Assume one digit for parameter...&#xA;        strlen_P( (const prog_char *)trailer );&#xA;&#xA;      //  ... and add room for more digits if necessary.&#xA;      if (parameter &amp;gt; 9)&#xA;        cmdLength++;&#xA;      if (parameter &amp;gt; 99)&#xA;        cmdLength++;&#xA;&#xA;      client.print(F(&quot;Content-Length: &quot;));&#xA;      client.println( cmdLength );&#xA;      client.println(F(&quot;Content-Type: text/plain;charset=UTF-8&quot;));&#xA;      client.println();  // blank line before body&#xA;      client.print( header );  // Hue command pieces&#xA;      client.print( parameter );&#xA;      client.println( trailer );&#xA;    }&#xA;    client.flush();&#xA;#ifdef REAL_WIFI&#xA;    client.stop();&#xA;#endif&#xA;    return true;  // command executed&#xA;  }&#xA;#ifdef REAL_WIFI&#xA;  else&#xA;    return false;  // command failed&#xA;#endif&#xA;}&#xA;&#xA;//---------------------------------------------------------------------&#xA;// Utility function to extract one `bool` value from the client stream.&#xA;//   No buffers are used.  Each character is handled as it is received.&#xA;//   (you may want/need to add a timeout)&#xA;&#xA;static bool clientParseBool( char delim )&#xA;{&#xA;  bool val = false;&#xA;  uint8_t count = 0; // number of chars we've read for the value&#xA;&#xA;  while (status == WL_CONNECTED) {&#xA;    if (client.available()) {&#xA;      char c = client.read();&#xA;      if (c == delim)&#xA;        break; // done!&#xA;      if ((c == ' ') || (count++ &amp;gt; 0))&#xA;        continue; // skip spaces and anything after the first non-space char&#xA;&#xA;      if (c == 't')&#xA;        val = true;&#xA;    }&#xA;  }&#xA;&#xA;  // Debug prints&#xA;  Serial.print( F(&quot;bool &quot;) );&#xA;  Serial.println( val );&#xA;&#xA;  return val;&#xA;}&#xA;&#xA;//-------------------------------------------&#xA;// Utility function to extract one 'unsigned 16-bit int' value from the client stream.&#xA;//   No buffers are used.  Each character is handled as it is received.&#xA;//   (you may want/need to add a timeout)&#xA;&#xA;static uint16_t clientParseUint( char delim )&#xA;{&#xA;  uint16_t val = 0;&#xA;&#xA;  while (status == WL_CONNECTED) {&#xA;    if (client.available()) {&#xA;      char c = client.read();&#xA;      if (c == delim)&#xA;        break; // done!&#xA;      if (c == ' ')&#xA;        continue; // skip spaces&#xA;&#xA;      if (isdigit(c))&#xA;        val = val*10 + (c - '0'); // accumulate one digit of the bri value&#xA;    }&#xA;  }&#xA;&#xA;  // Debug prints&#xA;  Serial.print( F(&quot;int &quot;) );&#xA;  Serial.println( val );&#xA;&#xA;  return val;&#xA;}&#xA;&#xA;//-------------------------------------------&#xA;&#xA;/* A helper function in case your logic depends on the current state of the light. &#xA; * This sets a number of global variables which you can check to find out if a light is currently on or not&#xA; * and the hue etc. Not needed just to send out commands&#xA; */&#xA;boolean getHue(int lightNum)&#xA;{&#xA;  bool gotHue = false;&#xA;&#xA;#ifdef REAL_WIFI&#xA;  client.stop();&#xA;  if (client.connect(server, 80))&#xA;#endif&#xA;  {&#xA;&#xA;    client.print(F(&quot;GET /api/&quot;));&#xA;    client.print(hueUsername);&#xA;    client.print(F(&quot;/lights/&quot;));&#xA;    client.print(lightNum);  &#xA;    client.println(F(&quot; HTTP/1.1&quot;));&#xA;    client.print(F(&quot;Host: &quot;));&#xA;    client.println(hueHubIP);&#xA;    client.println(F(&quot;Content-type: application/json&quot;));&#xA;    client.println(F(&quot;Connection: keep-alive&quot;));&#xA;    client.println();&#xA;&#xA;    if (status == WL_CONNECTED)&#xA;    {&#xA;        client.findUntil(&quot;\&quot;on\&quot;:&quot;, &quot;\0&quot;);&#xA;        hueOn = clientParseBool(',');&#xA;&#xA;        if (status == WL_CONNECTED)&#xA;        {&#xA;            client.findUntil(&quot;\&quot;bri\&quot;:&quot;, &quot;\0&quot;);&#xA;            hueBri = clientParseUint(',');&#xA;&#xA;            if (status == WL_CONNECTED)&#xA;            {&#xA;                client.findUntil(&quot;\&quot;hue\&quot;:&quot;, &quot;\0&quot;);&#xA;                hueHue = clientParseUint(',');&#xA;&#xA;                gotHue = true;  // captured all three: on,bri,hue&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    client.flush();&#xA;#ifdef REAL_WIFI&#xA;    client.stop();&#xA;#endif&#xA;  }&#xA;&#xA;  return gotHue;&#xA;}&#xA;&#xA;void printWifiData() {&#xA;&#xA;  //WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(F(&quot;IP Address: &quot;));&#xA;  Serial.println(ip);&#xA;}&#xA;&#xA;void printCurrentNet() {&#xA;  //SSID of the network you're attached to:&#xA;  Serial.print(F(&quot;SSID: &quot;));&#xA;  Serial.println(WiFi.SSID());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A few notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I did not have the extra blank line in my original &lt;code&gt;setHue&lt;/code&gt;, so I put it back in to match your sketch.&lt;/li&gt;&#xA;&lt;li&gt;I added a &lt;code&gt;REAL_WIFI&lt;/code&gt; define that I could comment out for testing on &lt;code&gt;Serial&lt;/code&gt;.  When I run it, I get this output:&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;WiFi shield not present&lt;br&gt;&#xA;  You're connected to the networkSSID:&lt;br&gt;&#xA;  IP Address: 0.0.0.0&lt;br&gt;&#xA;  connected to server&lt;br&gt;&#xA;  PUT /api/myhue/lights/1/state HTTP/1.1&lt;br&gt;&#xA;  Connection: keep-alive&lt;br&gt;&#xA;  Host: 192.168.0.50&lt;br&gt;&#xA;  Content-Length: 65&lt;br&gt;&#xA;  Content-Type: text/plain;charset=UTF-8&lt;br&gt;&#xA;  &lt;br&gt;&#xA;  {&quot;on&quot;: true,&quot;hue&quot;: 50100,&quot;sat&quot;:255,&quot;bri&quot;:255,&quot;transitiontime&quot;:22}&lt;br&gt;&#xA;  connected to server&lt;br&gt;&#xA;  PUT /api/myhue/lights/2/state HTTP/1.1&lt;br&gt;&#xA;  Connection: keep-alive&lt;br&gt;&#xA;  Host: 192.168.0.50&lt;br&gt;&#xA;  Content-Length: 65&lt;br&gt;&#xA;  Content-Type: text/plain;charset=UTF-8&lt;br&gt;&#xA;  &lt;br&gt;&#xA;  {&quot;on&quot;: true,&quot;hue&quot;: 65280,&quot;sat&quot;:255,&quot;bri&quot;:255,&quot;transitiontime&quot;:24}&lt;br&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can copy and paste the above output if you want to add and test &lt;code&gt;getHue&lt;/code&gt; with just the Serial Monitor (i.e., comment out &lt;code&gt;#define REAL_WIFI&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;I added a 10-second delay between each &lt;code&gt;setHue&lt;/code&gt;, just to pace the output, and to give the &quot;transition-time&quot; um... some time to work.  The transition time is in seconds, so &lt;code&gt;loop&lt;/code&gt; will call &lt;code&gt;setHue&lt;/code&gt; again, &lt;em&gt;before&lt;/em&gt; the requested transition has completed.  You won't see much change when you keep telling it to gradually change to the new color, but it only gets to transition a little bit.  Without any delay, I don't think you'll see anything.  This could be your current problem!  With 10 seconds, at least it will get about half-way there.  :-(&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="18846" LastEditDate="2016-03-10T15:04:18.233" LastActivityDate="2016-03-10T15:04:18.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21555" PostTypeId="1" CreationDate="2016-03-08T03:12:22.560" Score="0" ViewCount="48" Body="&lt;p&gt;I was getting started with programming a motor controller with the Arduino Uno, in this case it's a mega motor shield (&lt;a href=&quot;http://www.robotshop.com/en/arduino-compatible-mega-motor-shield-1a-5-28v.html#Useful%20Links&quot; rel=&quot;nofollow&quot;&gt;the motor driver shield I'm using&lt;/a&gt;). &#xA;The problem I have doing this is that I'm not sure what variables to use for the motor which is connected to two outputs labeled MA and MB.  I used motorValue to set the speed previously and used motorPin for writing the speed with the Arduino and a breadboard, but I'm not sure what to use in place of that for the motor being connected to the driver shield outputs.&lt;/p&gt;&#xA;" OwnerUserId="19055" LastActivityDate="2016-03-08T10:29:08.143" Title="What variables to declare for controlling a motor with high power motor controller" Tags="|arduino-motor-shield|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21556" PostTypeId="2" ParentId="21545" CreationDate="2016-03-08T03:57:53.953" Score="0" Body="&lt;p&gt;Try these:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set pin 9 on the TX side as a pulled-up input i.e. &lt;code&gt;pinMode(9, INPUT_PULLUP);&lt;/code&gt;&#xA;Connect one end of the switch to GND and the other to pin 9. Then in your code, test for a button press like this: &lt;code&gt;if (digitalRead(9) == LOW){...}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use a byte array for holding the address instead of the 64-bit int you're using. &lt;/li&gt;&#xA;&lt;li&gt;Remove the &lt;code&gt;stopListening()&lt;/code&gt; call in your RX loop(); there is no need for it since all its doing is receiving.&lt;/li&gt;&#xA;&lt;li&gt;Remove the 500 ms delays in the RX loop() just in the unlikely case that its causing you to lose bytes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-08T20:12:59.903" LastActivityDate="2016-03-08T20:12:59.903" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21557" PostTypeId="2" ParentId="9941" CreationDate="2016-03-08T04:25:55.970" Score="1" Body="&lt;p&gt;Without seeing the code you are using, it is difficult to know if you are attempting to drive the servo correctly.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember, with a servo, the PWM signal is a positioning signal, not a duty cycle signal as used with speed control on regular dc motors.  &lt;/p&gt;&#xA;" OwnerUserId="19058" LastEditorUserId="19058" LastEditDate="2016-03-08T21:48:18.060" LastActivityDate="2016-03-08T21:48:18.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21559" PostTypeId="2" ParentId="21280" CreationDate="2016-03-08T05:39:29.647" Score="2" Body="&lt;p&gt;Problem I see is that the request is incomplete - the server will be waiting for your payload.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.print(String(&quot;POST &quot;) + url + &quot; HTTP/1.1\r\n&quot; +&#xA;           &quot;Host: &quot; + host + &quot;\r\n&quot; + &#xA;           &quot;Connection: close\r\n\r\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You haven't specified a &lt;code&gt;Content-Length&lt;/code&gt; header so the payload should start after the headers finish - but you don't send anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to (at least):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;add a payload &lt;em&gt;or&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;add a &lt;code&gt;Content-Length: 0&lt;/code&gt; header &lt;em&gt;or&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;add a payload with a matching &lt;code&gt;Content-Length:&lt;/code&gt; header.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;curl&lt;/code&gt; to see a full set of valid &lt;code&gt;POST&lt;/code&gt; headers like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;curl -v -d &quot;&quot; http://localhost&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use Chrome and Firefox's Web Inspector's Network tab to look at the raw headers of requests too.&lt;/p&gt;&#xA;" OwnerUserId="10827" LastActivityDate="2016-03-08T05:39:29.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21560" PostTypeId="1" CreationDate="2016-03-08T08:26:23.410" Score="2" ViewCount="2338" Body="&lt;p&gt;I bought a &lt;a href=&quot;http://www.elechouse.com/elechouse/index.php?main_page=product_info&amp;amp;cPath=90_93&amp;amp;products_id=2242&quot; rel=&quot;nofollow&quot;&gt;PN532 from Elechouse&lt;/a&gt; (&lt;a href=&quot;http://www.elechouse.com/elechouse/images/product/PN532_module_V3/PN532_%20Manual_V3.pdf&quot; rel=&quot;nofollow&quot;&gt;documentation here&lt;/a&gt;) because I need to read IDs from &lt;code&gt;Type B&lt;/code&gt; NFC cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that even if they say the hardware supports &lt;code&gt;Type B&lt;/code&gt;, the official libraries an examples they provide are not made to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not problem reading &lt;code&gt;Type A&lt;/code&gt; cards, but nothing happends when I tap &lt;code&gt;Type B&lt;/code&gt; cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After long searchs on internet I found that absolutely every &lt;code&gt;PN532&lt;/code&gt; sellers have chosen to support only &lt;code&gt;Type A&lt;/code&gt; cards in their libraries because according to them, a librari supporting both types would have taken too much space in Arduino's memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So today my problem is as simple as that: &lt;strong&gt;how to read Type B NFC cards using PN532 on an Arduino UNO?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a bit new in Arduino so after many hours of searching and trying I couldn't figure out how to do it.&lt;/p&gt;&#xA;" OwnerUserId="19065" LastEditorUserId="11529" LastEditDate="2016-03-13T14:14:24.357" LastActivityDate="2018-11-04T07:15:17.923" Title="Read ISO/IEC 14443B (NFC Type B) with PN532" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21561" PostTypeId="2" ParentId="21555" CreationDate="2016-03-08T10:29:08.143" Score="1" Body="&lt;p&gt;Variables are just names assigned to numbers. The names, as far as your program is concerned, are completely meaningless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the numbers you assign to the variables and, more importantly, what you &lt;em&gt;do&lt;/em&gt; with those variables that is important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your shield seems to have jumpers to select what I/O pins perform which function, so you just need to write the software to control the chosen I/O pins in the right way.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-08T10:29:08.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21562" PostTypeId="2" ParentId="21549" CreationDate="2016-03-08T10:39:54.697" Score="2" Body="&lt;p&gt;An Arduino's ADC cannot sample fast enough to sustain 225ksps over 16 channels. That equates to a total of 3.6Msps.  The Arduino can manage something like 120ksps in total.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not to say there aren't microcontrollers that can't do that kind of speed - there are.  The PIC32MZ, for instance, can run at 15Msps (although it's somewhat buggy still) and there are many other microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main bottleneck though is in the communication between the microcontroller and the computer.  Regardless of the sampling speed of an Arduino the serial interface is too slow for high speed sampling. Even at its practical maximum of around 2Mbps it gives you 200000 bytes per second, which with 2 bytes per sample would be 100ksps maximum throughput, not taking into account any protocol overheads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's where having a PCI card is a big advantage. A 32-bit (or even 64-bit on PCI64) 66MHz direct channel to the CPU means you can shift considerably more data. And having the computer perform DMA access means that smooth data transfers without the CPU needing to be involved can be performed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-08T10:39:54.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21563" PostTypeId="2" ParentId="21547" CreationDate="2016-03-08T13:00:45.660" Score="0" Body="&lt;p&gt;Usually when on opening a program you get a console that pops on, it means that this program is meant for commandline usage and not CLI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should open a terminal, &lt;code&gt;cd&lt;/code&gt; in the downloaded .exe directory, and then type that tool's name. You might want to try adding &lt;code&gt;--help&lt;/code&gt; after the program's name to learn how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another good idea is to look at what Arduino does by clicking on the verbose option in the preferences. Then you'll be able to copy/paste the command call and modify it to upload the firmware blob you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, if you look up &quot;AVR SAMX upload tool windows&quot; on google you might find a GUI wrapper for the command line tool.&lt;/p&gt;&#xA;" OwnerUserId="379" LastActivityDate="2016-03-08T13:00:45.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21564" PostTypeId="2" ParentId="21532" CreationDate="2016-03-08T13:15:59.633" Score="2" Body="&lt;p&gt;&lt;strong&gt;Your question is not very specific.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I think your talking about the AMR_Voice application for Android, and your trying to use the HC-05 BT to connect to your cell. I hope I'm right in my guess, and funny enough, someone over at Instructables did exactly the same thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Voice-recognition-Via-Bluetooth-HC-05/&quot; rel=&quot;nofollow&quot;&gt;Arduino Voice recognition Via Bluetooth HC-05 - http://www.instructables.com/id/Arduino-Voice-recognition-Via-Bluetooth-HC-05/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-08T13:15:59.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21565" PostTypeId="2" ParentId="21505" CreationDate="2016-03-08T13:30:14.997" Score="1" Body="&lt;p&gt;Wiring Diagram to Pin 13 for a single relay? This might help.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BHVtF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BHVtF.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-08T13:30:14.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21566" PostTypeId="1" CreationDate="2016-03-08T14:15:43.670" Score="2" ViewCount="2427" Body="&lt;p&gt;&lt;strong&gt;i am using ESP8266 module serially with PC and i also tried it using uno&#xA;I am stuck at the following point&#xA;I am able to made connection to server but when i will send the following command&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;POST /test.php HTTP/1.1\r\nHost: 192.168.1.36\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 5\r\n\r\nb1=ON\r\n\r\n&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;every time i get the following server timeout error after 3 sec&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;+IPD,4,500:HTTP/1.1 408 Request Timeout&#xA;Date: Tue, 08 Mar 2016 14:10:07 GMT&#xA;Server: Apache/2.4.9 (Win64) PHP/5.5.12&#xA;Content-Length: 305&#xA;Connection: close&#xA;Content-Type: text/html; charset=iso-8859-1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;&#xA;408 Request Timeout&#xA;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Request Timeout&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Server timeout waiting for the HTTP request from the client.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80&#xA;&#xA;&lt;p&gt;&#xA;4,CLOSED&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And i am getting same issue whether i will use local server or online server&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-03-08T14:15:43.670" Title="ESP8266 GET OR POST Request Timeout Error" Tags="|arduino-uno|esp8266|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21568" PostTypeId="1" CreationDate="2016-03-08T14:43:16.373" Score="3" ViewCount="974" Body="&lt;p&gt;I am designing an motorcycle security system and I need to receive the message  from the user.Hence i need to detect the incoming message and read the number and data from the message&lt;/p&gt;&#xA;" OwnerUserId="18466" LastActivityDate="2016-04-02T21:50:32.867" Title="how to detect the incoming message from sim800 GSM module" Tags="|gsm|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21571" PostTypeId="2" ParentId="19619" CreationDate="2016-03-08T18:14:57.103" Score="1" Body="&lt;p&gt;Arduino at &lt;a href=&quot;http://playground.arduino.cc/Linux/Raspbian&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Linux/Raspbian&lt;/a&gt; recommends:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install arduino &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but indeed warns that the version is old:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: This will install an old version of Arduino, and may not support&#xA;  some of the newer boards. You can not download a newer version from&#xA;  the website, because there is no ARM version. -- &lt;a href=&quot;http://playground.arduino.cc/Linux/Raspbian&quot; rel=&quot;nofollow&quot;&gt;Arduino wiki on Raspbian&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looking at the raspbian respository at &lt;a href=&quot;http://archive.raspbian.org/raspbian/pool/main/a/arduino/&quot; rel=&quot;nofollow&quot;&gt;http://archive.raspbian.org/raspbian/pool/main/a/arduino/&lt;/a&gt; currently lists 1.0.5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are folks working newer versions of Arduino for ARM at &lt;a href=&quot;https://github.com/arduino/Arduino/issues/3334&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/issues/3334&lt;/a&gt; but it isn't finished yet.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T18:14:57.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21572" PostTypeId="2" ParentId="16083" CreationDate="2016-03-08T18:45:32.303" Score="1" Body="&lt;p&gt;6 months after figuring out the answer, I found this question again. I solved this question by adding &lt;code&gt;system(&quot;ifup eth0&quot;)&lt;/code&gt; which completely solved the problem.&lt;/p&gt;&#xA;" OwnerUserId="8722" LastActivityDate="2016-03-08T18:45:32.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21573" PostTypeId="1" CreationDate="2016-03-08T18:54:37.480" Score="-2" ViewCount="536" Body="&lt;p&gt;This is my program. The LED should turn off after four seconds.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int vraag = 7;&#xA;int gloeikaars = 5;&#xA;unsigned long previousMillis3;&#xA;boolean gloeistate = true;&#xA;&#xA;void setup() {&#xA;    pinMode(gloeikaars, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    int x = digitalRead(vraag);&#xA;    if (x == 0) {&#xA;        digitalWrite(gloeikaars, !LOW);&#xA;    } else {&#xA;        Gloeikaars();    &#xA;    }&#xA;}&#xA;&#xA;// *********************************************************************&#xA;// Gloeikaars aansturing&#xA;// *********************************************************************&#xA;void Gloeikaars() {&#xA;    unsigned long huidig = millis();&#xA;    digitalWrite(gloeikaars, !HIGH);&#xA;    if ((gloeistate == true) &amp;amp;&amp;amp; (huidig - previousMillis3 &amp;gt;= 4000)) {&#xA;        huidig = previousMillis3;&#xA;        digitalWrite(gloeikaars, !LOW);&#xA;        gloeistate = false;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone help me because it won't work?&lt;/p&gt;&#xA;" OwnerUserId="19082" LastEditorUserId="6936" LastEditDate="2016-12-06T22:01:20.857" LastActivityDate="2016-12-06T22:02:04.540" Title="Arduino millis() won't work" Tags="|millis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21574" PostTypeId="2" ParentId="21573" CreationDate="2016-03-08T19:16:03.073" Score="1" Body="&lt;p&gt;Your &lt;code&gt;previousMillis&lt;/code&gt; variable is never set.  Two changes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;previousMillis3 = millis();&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;previousMillis3 = huidig;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6936" LastEditDate="2016-12-06T22:02:04.540" LastActivityDate="2016-12-06T22:02:04.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21575" PostTypeId="1" CreationDate="2016-03-08T20:21:42.253" Score="0" ViewCount="3229" Body="&lt;p&gt;I am using Linux Fedora 20. In order to compile C programs for the Arduino, as described in the book &quot;C Programming with Arduino&quot; by Warwick A Smith, pub by Elektor, I have downloaded and untarred/unzipped &quot;avr8-gnu-toolchain-3.5.1.1671-linux.any.x86.tar.gz&quot;. That's as far as I can get. Please how do I proceed from this point? Is there anything else I need or should have done?&lt;/p&gt;&#xA;" OwnerUserId="1631" LastActivityDate="2021-10-16T10:14:51.977" Title="In Linux how do I start up Atmel Studio" Tags="|arduino-uno|linux|atmel-studio|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21576" PostTypeId="2" ParentId="21575" CreationDate="2016-03-08T21:22:51.010" Score="-1" Body="&lt;p&gt;Atmel Studio is a windows only product.&#xA;The only way to run it on linux is in a virtual machine running windows.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-08T21:22:51.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21577" PostTypeId="2" ParentId="11824" CreationDate="2016-03-08T21:25:18.620" Score="10" Body="&lt;p&gt;Please take a look at &lt;a href=&quot;http://arduinohistory.github.io&quot;&gt;The Untold History of Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19086" LastEditorUserId="10794" LastEditDate="2016-03-09T04:37:02.843" LastActivityDate="2016-03-09T04:37:02.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21578" PostTypeId="2" ParentId="18903" CreationDate="2016-03-08T22:08:52.163" Score="0" Body="&lt;p&gt;Fritzing's wiring diagram has errors. 1) the serial connections wrong way around. You need to swap them so that &#xA;Arduino TX -&gt; ESP Rx and &#xA;Arduino RX &amp;lt;- ESP Tx. Also 2) the ESP-01 require more than 200mA so supplying voltage reg cannot be provided from the Arduino 5V pin. It must be supplied by VIN with a supply able to provide 1A.&lt;/p&gt;&#xA;" OwnerUserId="19087" LastEditorUserId="19087" LastEditDate="2016-03-08T22:14:03.437" LastActivityDate="2016-03-08T22:14:03.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21579" PostTypeId="2" ParentId="3512" CreationDate="2016-03-08T22:19:57.630" Score="1" Body="&lt;p&gt;So atan2(y,x) gives the angle CCW from the x axis in radians, limited to [-pi,pi].  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it converted to degrees CW from the Y axis, you would do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;azimuth=90.0-atan2(y,x)*57.295779;  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you need to constrain it to -70,70 then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;azimuth_constrained=constrain(azimuth,-70,70);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T22:19:57.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21581" PostTypeId="1" CreationDate="2016-03-08T22:47:56.800" Score="2" ViewCount="954" Body="&lt;p&gt;I've just tried out my new TFT_ILI9163C display with &lt;a href=&quot;https://github.com/sumotoy/TFT_ILI9163C&quot; rel=&quot;nofollow noreferrer&quot;&gt;TFT_ILI9163C&lt;/a&gt; library but I'm having an issue with it. The graphics has moved down (the &quot;hello world&quot; should be in the top left) and the leftover space looks like there was no signal. Can be seen in the photo.&#xA;What could be wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TdGMl.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TdGMl.jpg&quot; alt=&quot;looks kind of no signal&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18874" LastActivityDate="2019-06-03T20:26:16.767" Title="ILI9163C screen not working properly" Tags="|display|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21582" PostTypeId="1" CreationDate="2016-03-08T23:06:27.730" Score="1" ViewCount="4984" Body="&lt;pre&gt;&lt;code&gt;int firstAnalogPin = 0;         &#xA;int secondAnalogPin = 5;  &#xA;int firstVal = 0;  &#xA;int secondVal = 0;  &#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);          //  setup serial&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;firstVal = analogRead(firstAnalogPin); &#xA;   // read the input pin&#xA;&#xA;secondVal = analogRead(secondAnalogPin); &#xA;   // read the input pin&#xA;&#xA;Serial.print(firstVal); &#xA;&#xA;Serial.print(&quot;\t&quot;);&#xA;&#xA;Serial.println(secondVal);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I want to know how to convert from the baud rate to the number of times &lt;code&gt;loop()&lt;/code&gt; runs per second. How do I control the number of &lt;code&gt;loop()&lt;/code&gt;s per second?&lt;/p&gt;&#xA;" OwnerUserId="19089" LastEditorUserId="11763" LastEditDate="2016-03-09T06:36:27.883" LastActivityDate="2019-06-15T19:53:34.333" Title="How do you control the amount of times the void loop loops per second?" Tags="|arduino-uno|serial|pins|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21583" PostTypeId="1" AcceptedAnswerId="22047" CreationDate="2016-03-08T23:13:02.573" Score="0" ViewCount="106" Body="&lt;p&gt;I'm just got a Galileo Gen2 and wanted to try a simple blinking-led. The firmware have been updated to 1.0.4. My problem is whenever I try to upload the code I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 83,775 bytes (0%) of program storage space. Maximum is 10,000,000 bytes.&#xA;...&#xA;echo &quot;Sending Command String to move to download if not already in download mode&quot;&#xA;echo &quot;~sketch downloadGalileo&quot; &amp;gt; $tty_port_id&#xA;&#xA;Deleting existing sketch on target&#xA;#Move the existing sketch on target.&#xA;echo &quot;Deleting existing sketch on target&quot;&#xA;&quot;$fixed_path/lsz.exe&quot; --escape -c &quot;mv -f /sketch/sketch.elf /sketch/sketch.elf.old&quot; &amp;lt;&amp;gt; $tty_port_id 1&amp;gt;&amp;amp;0&#xA;Login timed out after 60 secondsPoky 9.0.2 (Yocto Project 1.4 Reference Distro) 1.4.2 clanton /dev/ttyS1clanton login:`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19088" LastEditorUserId="19409" LastEditDate="2016-10-16T17:12:40.523" LastActivityDate="2016-10-16T17:12:40.523" Title="Stuck on uploading sketch via USB 6 pin" Tags="|sketch|uploading|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21584" PostTypeId="2" ParentId="6506" CreationDate="2016-03-08T23:27:08.277" Score="1" Body="&lt;p&gt;You setup interpretation should be more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; setSyncProvider(RTC.get);&#xA; if(timeStatus()!= timeSet) &#xA;   Serial.println(&quot;RTC has never been set&quot;);&#xA; else&#xA;    Serial.println(&quot;RTC has a time&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To conditionally sync the clock to the compilation time if the clock is not running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (! RTC.isrunning()) {&#xA;   Serial.println(&quot;RTC is NOT running!&quot;);&#xA;   // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;   // uncomment it &amp;amp; upload to set the time, date and start run the RTC!&#xA;   RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;}&#xA;// following line unconditionally resets the RTC to the date &amp;amp; time this sketch was compiled&#xA;// uncomment it &amp;amp; upload to set the time, date and start run the RTC!&#xA;// RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To unconditionally sync it to the compilation time, uncomment the last line and reload for one cycle, then re-comment it and reload to let the clock run itself.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-08T23:27:08.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21585" PostTypeId="2" ParentId="21582" CreationDate="2016-03-08T23:30:25.240" Score="1" Body="&lt;p&gt;If your goal is to control how often the sensor is polled and printed to SD card, I would suggest you check out Blink Without Delay &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt; it would be a much cleaner way than trying to slow down the loop to a specified time. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-08T23:30:25.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21586" PostTypeId="2" ParentId="21582" CreationDate="2016-03-09T00:48:49.350" Score="3" Body="&lt;p&gt;The number of times &lt;code&gt;loop()&lt;/code&gt; runs every second depends on the time taken for the execution of the instructions &lt;em&gt;within&lt;/em&gt; &lt;code&gt;loop()&lt;/code&gt;. For instance, in your code, the time taken for one &lt;code&gt;loop()&lt;/code&gt; is roughly equal to the time taken for the MCU to execute all the statements in &lt;code&gt;loop()&lt;/code&gt; (more specifically, the time taken for each operation or function from call to return): in your case, the time taken for the &lt;code&gt;Serial.print()&lt;/code&gt;s + the time taken for the &lt;code&gt;analogRead()&lt;/code&gt;s (not considering any interrupts between statements). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you generally don't want to control the interval between &lt;code&gt;loop()&lt;/code&gt;s; I assume you actually want to control the interval between the execution of certain operations within your &lt;code&gt;loop()&lt;/code&gt;. Say, you want to set the time between executions of &lt;code&gt;analogRead(0)&lt;/code&gt; to 500 ms. This can be done like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define INTERVAL 500   // time between reads&#xA;unsigned long lastRead = 0;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);          //  setup serial&#xA;}&#xA;&#xA;void loop(){&#xA;  //....your other code....&#xA;&#xA;  if (millis() - lastRead &amp;gt;= INTERVAL){  // if INTERVAL has passed&#xA;    val = analogRead(0);&#xA;    lastRead = millis(); &#xA;    Serial.println(val);&#xA;    //...anything else&#xA;  }&#xA;&#xA;  //...your other code...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this code, you now have about 2 &lt;code&gt;analogRead&lt;/code&gt; samples every second. Of course, this is only useful if &lt;code&gt;loop()&lt;/code&gt; runs faster than your chosen interval. If there are function calls, or any operations otherwise, in &lt;code&gt;loop()&lt;/code&gt; (within or outside the IF block) that always take more time than your interval, then this code would serve no purpose.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-09T00:48:49.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21587" PostTypeId="2" ParentId="21581" CreationDate="2016-03-09T00:51:34.653" Score="1" Body="&lt;p&gt;I wrote my own driver for DisplayCore for that very same board a while back and found the exact same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is just the setting for the offset of the GRAM which it looks like there is a setting for in the library you are using.  Get that value right and you will have a proper display.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-09T00:51:34.653" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21590" PostTypeId="1" AcceptedAnswerId="21592" CreationDate="2016-03-09T02:17:12.730" Score="1" ViewCount="808" Body="&lt;p&gt;I am wandering how I would make it so the arduino uno will start a timer when button a is pressed and send &quot;Start&quot; or &quot;Begin&quot; or something like that to the console window. after the timer has started when button b is pressed it will mark the time from start of the timer and put it in the console window. After the timer has started when button c is pressed it will mark the time from start of the timer and put it in the console window. So on and so forth until button e, when button e is pressed i need the time to get logged in the console and they say &quot;End&quot; or &quot;Stop&quot; or something and then pause the sequence until I restart the board. This is for a school project and my only issue really is how to log the times On a timer loop persay.&lt;/p&gt;&#xA;" OwnerUserId="18553" LastEditorUserId="18553" LastEditDate="2016-03-09T02:43:25.467" LastActivityDate="2016-03-09T05:49:10.713" Title="Arduino Timer Button" Tags="|arduino-uno|led|arduino-ide|timers|time|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21591" PostTypeId="1" AcceptedAnswerId="21599" CreationDate="2016-03-09T03:53:08.103" Score="3" ViewCount="2962" Body="&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/AnalogInput&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/AnalogInput&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Knob&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Knob&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For first line of both examples(not in comments), it define the same pin, analog pin 0, but they use different values. why and can use A1, A2, etc. to define other analog pins?&lt;/p&gt;&#xA;" OwnerUserId="18431" LastActivityDate="2016-03-09T06:00:59.600" Title="why does it use A0 to define analog pin 0 in some case and why use 0 directly?" Tags="|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21592" PostTypeId="2" ParentId="21590" CreationDate="2016-03-09T04:13:31.280" Score="1" Body="&lt;p&gt;Ordinarily, posters are expected to say what they've tried so far, and to show the code they've written.  However, with a problem as difficult as this one, it seems reasonable to illustrate a complete program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, this program assumes that one side of each button goes to Ground and the other side goes to a digital pin with its input pullup turned on.  (If you connect one side to +5V instead of to ground, you will need additional circuitry to sense button presses.)  The digital pins that are used are selected by changing the values swA, swB, and so forth, in the third line of the program.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;//  jw - 8 Mar 2016 - Program for buttons demo&#xA;// Ref: http://arduino.stackexchange.com/questions/21590/arduino-timer-button&#xA;enum { swA=8, swB=9, swC=10, swD=11, swE=12}; // Switchbutton lines&#xA;enum { nSwitches=5 };&#xA;byte buttonPins[nSwitches]={swA, swB, swC, swD, swE};&#xA;byte buttonBusy[nSwitches]={  0,   0,   0,   0,   0};&#xA;unsigned long startTime;&#xA;//--------------------------------------------------------&#xA;void setup() {&#xA;  for (int i=0; i&amp;lt;nSwitches; ++i)&#xA;  // Note, this code assumes one side of button goes to Ground&#xA;  // and other side to a digital pin with its input pullup turned on&#xA;    pinMode(buttonPins[i], INPUT_PULLUP);&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Program begins&quot;);&#xA;}&#xA;//--------------------------------------------------------&#xA;void doButton(byte b) {&#xA;  char *blabels[] = {&quot;A, Start&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E, End&quot;};&#xA;  if (digitalRead(buttonPins[b]) &amp;amp;&amp;amp; !buttonBusy[b]) {&#xA;    // The b'th button has freshly turned on.&#xA;    unsigned long now = millis();&#xA;    if (b&amp;gt;0 &amp;amp;&amp;amp; !buttonBusy[0]) // To ignore B-E if A isn't on&#xA;      return;&#xA;    buttonBusy[b] = 1;&#xA;    if (b==0) startTime = now;  // Button A resets timer&#xA;    Serial.print(&quot;Button &quot;);&#xA;    Serial.print(blabels[b]);&#xA;    Serial.print(&quot; at time &quot;);&#xA;    Serial.println(now-startTime);&#xA;    if (b==nSwitches-1) {   // Last Button ends timing, restarts cycle&#xA;      for (byte k=0; k&amp;lt;nSwitches; ++k)&#xA;        buttonBusy[b] = 0;  // Clear all the busy-flags&#xA;    }&#xA;  }&#xA;}&#xA;//--------------------------------------------------------&#xA;void loop() {&#xA;  for (int b=0; b&amp;lt;nSwitches; ++b)&#xA;    doButton(b);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Note that triggering messages on button-release instead of button-press would be relatively easy if buttons didn't bounce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before explaining that, let's look at why the above code should work.  Assume the cycle (buttons A and later E getting pressed, and possibly some of B, C, D too) lasts at least a couple of seconds.  Assume we have ordinary button hardware, and that contacts can bounce for several milliseconds at each make or break.  When you press a button the Arduino sees a lot of pin-turning-on events, eventually settling at pin-is-on.  When you release a button the Arduino sees a lot of pin-turning-off events, eventually settling at pin-is-off.  And finally, assume each button press is long enough that at least one &lt;code&gt;digitalRead()&lt;/code&gt; happens while contacts are closed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under those assumptions, the very first time in each cycle that we see a given button closed, we know that button has just been pressed.  Also, we can plausibly expect closure of button A to register before closures of other buttons, and can expect the closure of E to register after that of other buttons.  So we can ignore bounce.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, with on-release triggering we need to distinguish whether a pin-turning-off event is due to contact bounce of a button just pressed, or is actually part of a button-release bounce sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a method worth considering if you want to implement trigger-on-release:&lt;br&gt;&#xA; • First, add a &lt;code&gt;delay(1)&lt;/code&gt; call, in &lt;code&gt;loop()&lt;/code&gt;.  This will make the code timing less processor-dependent, so it can run on a 48- or 72-MHz system as well as on 16-MHz Unos.&lt;br&gt;&#xA;• Each time you detect that button b is on, execute &lt;code&gt;buttonBusy[b] = 40&lt;/code&gt; to start (or restart) a 40-ms timeout.  That is, while a button is held down, we keep setting its timeout to 40.  (40 ms may be overly conservative.  20 ms should work ok with most switches, and 10 is ok with a lot of them.)&lt;br&gt;&#xA;• When you detect that button b is off,&lt;br&gt;&#xA;&lt;code&gt;&lt;/code&gt; • if &lt;code&gt;buttonBusy[b]&lt;/code&gt; is zero, do nothing.&lt;br&gt;&#xA;&lt;code&gt;&lt;/code&gt; • if &lt;code&gt;buttonBusy[b] &amp;gt; 0&lt;/code&gt;, then decrement &lt;code&gt;buttonBusy[b]&lt;/code&gt; and test if it now is equal to 1.  When it's equal to 1, regard b as released, so do its action.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-09T05:49:10.713" LastActivityDate="2016-03-09T05:49:10.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21593" PostTypeId="1" CreationDate="2016-03-09T04:21:27.313" Score="0" ViewCount="397" Body="&lt;p&gt;I have downloaded code from below link&lt;a href=&quot;http://lelylan.github.io/lab-projects/arduino-ethernet-light/&quot; rel=&quot;nofollow&quot;&gt;Link of code&lt;/a&gt;. I am trying test code from below. I am getting warning for below code.I couldnot able to find how to sort out&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;PubSubClient.h&amp;gt;&#xA;&#xA;&#xA;/* ------------------ */&#xA;/* SKETCH CREDENTIALS */&#xA;/* ------------------ */&#xA;&#xA;&#xA;&#xA;const char *deviceId     = &quot;&amp;lt;D56debb6351d9d4e74e000015&amp;gt;&quot;;             // * set your device id (will be the MQTT client username)&#xA;const char *deviceSecret = &quot;&amp;lt;Y4h+R1NRAxrhFciRhtHLj66ERSv8RExu&amp;gt;&quot;;         // * set your device secret (will be the MQTT client password)&#xA;const char *outTopic     = &quot;devices/&amp;lt;D56debb6351d9d4e74e000015&amp;gt;/set&quot;; // * MQTT channel where physical updates are published&#xA;const char *inTopic      = &quot;devices/&amp;lt;D56debb6351d9d4e74e000015&amp;gt;/get&quot;; // * MQTT channel where lelylan updates are received&#xA;const char *clientId     = &quot;&amp;lt;CLIENT-ID&amp;gt;&quot;;             // * set a random string (max 23 chars, will be the MQTT client id)&#xA;&#xA;&#xA;/* ------------ */&#xA;/* SKETCH LOGIC */&#xA;/* ------------ */&#xA;&#xA;/* Server settings */&#xA;byte server[] = { 178, 62, 108, 47 }; // MQTT server address&#xA;&#xA;/* Sample payload published to lelylan */&#xA;/* The id is the status property id of the basic light /*&#xA;  /* http://lelylan.github.io/types-dashboard-ng/#/types/518be107ef539711af000001/ */&#xA;const char *payloadOn  = &quot;{\&quot;properties\&quot;:[{\&quot;id\&quot;:\&quot;56debb6351d9d4e74e000015\&quot;,\&quot;value\&quot;:\&quot;on\&quot;}]}&quot;;&#xA;const char *payloadOff = &quot;{\&quot;properties\&quot;:[{\&quot;id\&quot;:\&quot;56debb6351d9d4e74e000015\&quot;,\&quot;value\&quot;:\&quot;off\&quot;}]}&quot;;&#xA;&#xA;/* Ethernet configuration */&#xA;byte mac[] = { 0xA0, 0xA0, 0xBA, 0xAC, 0xAE, 0x12 };&#xA;EthernetClient ethClient;&#xA;&#xA;/* MQTT communication */&#xA;void callback(char* topic, byte* payload, unsigned int length); // subscription callback&#xA;PubSubClient client(server, 1883, callback, ethClient);         // mqtt client&#xA;&#xA;/* Pins configuration */&#xA;int inPin = 2; // button&#xA;int outPin = 4; // led&#xA;&#xA;/* Button and led logics */&#xA;int state = HIGH;     // current state of the output pin&#xA;int reading;          // current reading from the input pin&#xA;int previous = LOW;   // previous reading from the input pin&#xA;long time = 0;        // the last time the output pin was toggled&#xA;long debounce = 200;  // the debounce time, increase if the output flickers&#xA;&#xA;/* arduino setup */&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  delay(500);&#xA;&#xA;  Ethernet.begin(mac);&#xA;  Serial.print(&quot;Connected with IP: &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;&#xA;  lelylanConnection();      // MQTT server connection&#xA;  pinMode(inPin, INPUT);    // button pin setup&#xA;  pinMode(outPin, OUTPUT);  // led pin setup&#xA;}&#xA;&#xA;/* arduino loop */&#xA;void loop() {&#xA;  lelylanConnection();&#xA;&#xA;  const char *value;&#xA;  reading = digitalRead(inPin);  // read the button state&#xA;&#xA;  // if the input just went from LOW and HIGH and we've waited long enough to ignore&#xA;  // any noise on the circuit, toggle the output pin and remember the time&#xA;  if (reading == HIGH &amp;amp;&amp;amp; previous == LOW &amp;amp;&amp;amp; millis() - time &amp;gt; debounce) {&#xA;    if (state == LOW) {&#xA;      Serial.println(&quot;[PHYSICAL] Led turned on&quot;);&#xA;      lelylanPublish(&quot;on&quot;);&#xA;      state = HIGH;&#xA;    } else {&#xA;      Serial.println(&quot;[PHYSICAL] Led turned off&quot;);&#xA;      lelylanPublish(&quot;off&quot;);&#xA;      state = LOW;&#xA;    }&#xA;&#xA;    time = millis();&#xA;  }&#xA;&#xA;  // effectively update the light status&#xA;  digitalWrite(outPin, state);&#xA;  previous = reading;&#xA;}&#xA;&#xA;/* MQTT server connection */&#xA;void lelylanConnection() {&#xA;  // add reconnection logics&#xA;  if (!client.connected()) {&#xA;    // connection to MQTT server&#xA;    if (client.connect(clientId, deviceId, deviceSecret)) {&#xA;      Serial.println(&quot;[PHYSICAL] Successfully connected with MQTT&quot;);&#xA;      lelylanSubscribe(); // topic subscription&#xA;    }&#xA;  }&#xA;  client.loop();&#xA;}&#xA;&#xA;/* MQTT publish */&#xA;void lelylanPublish(char *value) {&#xA;  if (value == &quot;on&quot;)&#xA;    client.publish(outTopic, payloadOn); // light on&#xA;  else&#xA;    client.publish(outTopic, payloadOff); // light off&#xA;}&#xA;&#xA;/* MQTT subscribe */&#xA;void lelylanSubscribe() {&#xA;  client.subscribe(inTopic);&#xA;}&#xA;&#xA;/* Receive Lelylan message and confirm the physical change */&#xA;void callback(char* topic, byte* payload, unsigned int length) {&#xA;  // copu the payload content into a char*&#xA;  const char *json;&#xA;  json = (char *) malloc(length + 1);&#xA;  memcpy(json, payload, length);&#xA;  json[length] = &quot;\0&quot;;&#xA;&#xA;  // update the physical status and confirm the executed update&#xA;  if (String(payloadOn) == String(json)) {&#xA;    Serial.println(&quot;[LELYLAN] Led turned on&quot;);&#xA;    lelylanPublish(&quot;on&quot;);&#xA;    state = HIGH;&#xA;  } else {&#xA;    Serial.println(&quot;[LELYLAN] Led turned off&quot;);&#xA;    lelylanPublish(&quot;off&quot;);&#xA;    state = LOW;&#xA;  }&#xA;&#xA;  digitalWrite(outPin, state);&#xA;  free(json);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino: 1.6.6 (Windows 8.1), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino: In function 'void&#xA;  loop()':&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino:77:26: warning:&#xA;  deprecated conversion from string constant to 'char*'&#xA;  [-Wwrite-strings]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   lelylanPublish(&quot;on&quot;);&#xA;&#xA;                      ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino:81:27: warning:&#xA;  deprecated conversion from string constant to 'char*'&#xA;  [-Wwrite-strings]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   lelylanPublish(&quot;off&quot;);&#xA;&#xA;                       ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino: In function 'void&#xA;  callback(char*, byte*, unsigned int)':&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;IOT_Testcode:124: error: invalid conversion from 'const void*' to&#xA;  'void*' [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;memcpy(json, payload, length);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                           ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;In file included from C:\Program Files&#xA;  (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:25:0,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             from sketch\IOT_Testcode.ino.cpp:1:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;c:\program files&#xA;  (x86)\arduino\hardware\tools\avr\avr\include\string.h:117:14: error:&lt;br&gt;&#xA;  initializing argument 1 of 'void* memcpy(void*, const void*, size_t)'&#xA;  [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;extern void *memcpy(void *, const void *, size_t);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;IOT_Testcode:125: error: assignment of read-only location '*(json +&#xA;  ((sizetype)length))'&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;json[length] = &quot;\0&quot;;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;IOT_Testcode:125: error: invalid conversion from 'const char*' to&#xA;  'char' [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino:130:24: warning:&#xA;  deprecated conversion from string constant to 'char*'&#xA;  [-Wwrite-strings]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; lelylanPublish(&quot;on&quot;);&#xA;&#xA;                    ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\Ajit\Desktop\IOT_Testcode\IOT_Testcode.ino:134:25: warning:&#xA;  deprecated conversion from string constant to 'char*'&#xA;  [-Wwrite-strings]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; lelylanPublish(&quot;off&quot;);&#xA;&#xA;                     ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;IOT_Testcode:139: error: invalid conversion from 'const void*' to&#xA;  'void*' [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;free(json);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;In file included from C:\Program Files&#xA;  (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:23:0,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             from sketch\IOT_Testcode.ino.cpp:1:&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;c:\program files&#xA;  (x86)\arduino\hardware\tools\avr\avr\include\stdlib.h:305:13: error:&lt;br&gt;&#xA;  initializing argument 1 of 'void free(void*)' [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;extern void free(void *__ptr);&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;         ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;exit status 1 invalid conversion from 'const void*' to 'void*'&#xA;  [-fpermissive]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This report would have more information with   &quot;Show verbose output&#xA;  during compilation&quot;   enabled in File &gt; Preferences.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Kindly let me know how to resolve these warning&lt;/p&gt;&#xA;" OwnerUserId="904" LastActivityDate="2016-04-08T21:34:50.263" Title="IOt application example Error" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21597" PostTypeId="1" AcceptedAnswerId="21600" CreationDate="2016-03-09T05:51:22.280" Score="1" ViewCount="95" Body="&lt;p&gt;So I'm going through Getting Started With Arduino. I skipped to making a LED blink when you press a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I wrote the code, then I copied it directly from the .pdf I have, neither has worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Example 02: Turn on LED while the button is pressed&#xA;const int LED = 13;   // the pin for the LED&#xA;const int BUTTON = 7; // the input pin where the&#xA;                      // pushbutton is connected&#xA;int val = 0;          // val will be used to store the state&#xA;                      // of the input pin&#xA;void setup() {&#xA;  pinMode(LED, OUTPUT);   // tell Arduino LED is an output&#xA;  pinMode(BUTTON, INPUT); // and BUTTON is an input&#xA;}&#xA;void loop(){&#xA;  val = digitalRead(BUTTON); // read input value and store it&#xA;  // check whether the input is HIGH (button pressed)&#xA;  if (val == HIGH) {&#xA;    digitalWrite(LED, HIGH); // turn LED ON&#xA;  } else {&#xA;    digitalWrite(LED, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/EcvIR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="19093" LastEditorUserId="2944" LastEditDate="2016-03-09T23:18:12.017" LastActivityDate="2016-03-09T23:18:12.017" Title="Brand new to Arduino, and can't even make an LED blink" Tags="|arduino-nano|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21598" PostTypeId="2" ParentId="21591" CreationDate="2016-03-09T05:58:30.553" Score="1" Body="&lt;p&gt;You can use 0 to 5 for &lt;code&gt;analogRead&lt;/code&gt; of pins A0 to A5. However if you want to do &lt;code&gt;digitalRead&lt;/code&gt; or &lt;code&gt;digitalWrite&lt;/code&gt; on those pins then you have to use &lt;code&gt;A0&lt;/code&gt; through to &lt;code&gt;A5&lt;/code&gt; in order to avoid confusing them with the digital pins 0 to 5 (on the other side of the board).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;can use A1, A2, etc. to define other analog pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-09T05:58:30.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21599" PostTypeId="2" ParentId="21591" CreationDate="2016-03-09T06:00:59.600" Score="4" Body="&lt;p&gt;The answer is in the source code. Keep in mind that for this answer, I'm assuming you have a standard Arduino Uno. For other Arduino platforms the values are different but the situation is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the analog pin definitions in &lt;code&gt;hardware/arduino/avr/variants/standard/pins_arduino.h&lt;/code&gt;, you'll find these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t A0 = 14;&#xA;static const uint8_t A1 = 15;&#xA;static const uint8_t A2 = 16;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which tells you that if you call &lt;code&gt;analogRead(A0)&lt;/code&gt;, it is equivalent to calling &lt;code&gt;analogRead(14)&lt;/code&gt;. So, really, the question is &quot;How can calling &lt;code&gt;analogRead(0)&lt;/code&gt; work?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to that is in &lt;code&gt;hardware/arduino/avr/cores/arduino/wiring_analog.c&lt;/code&gt;. If you wade through the defines, you'll see that at the top of &lt;code&gt;analogRead&lt;/code&gt;, there is the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (pin &amp;gt;= 14) pin -= 14; // allow for channel or pin numbers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result is that passing either &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;A0&lt;/code&gt; results in &lt;code&gt;0&lt;/code&gt; being used in the &lt;code&gt;analogRead&lt;/code&gt; code.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-03-09T06:00:59.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21600" PostTypeId="2" ParentId="21597" CreationDate="2016-03-09T06:15:05.360" Score="2" Body="&lt;p&gt;Other than what what Nick Gammon said that you need the resistor from the board to led, as that will cause your microcontroller pins to get damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other possible problem is the two breadboards you have put together, the power rails have not been bridged between the two boards. This means that the switch is not providing any logical state to the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the only reason why the led is show in the book as a separate thing is that it is meant as an educational exercise to make you build something, the &lt;code&gt;L&lt;/code&gt; led will do the same thing.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-03-09T06:15:05.360" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21601" PostTypeId="1" CreationDate="2016-03-09T06:46:56.557" Score="1" ViewCount="948" Body="&lt;p&gt;I am still new to Aduino and I am trying to use a library's example sketch but I don't understand the following part of the code. I want to trigger an led when the &quot;Pressed&quot; condition is fulfilled. Pardon my ignorance.   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (b != ClickEncoder::Open) {&#xA;Serial.print(&quot;Button: &quot;);&#xA;#define VERBOSECASE(label) case label: Serial.println(#label); break;&#xA;switch (b) {&#xA;  VERBOSECASE(ClickEncoder::Pressed);&#xA;  VERBOSECASE(ClickEncoder::Held)&#xA;  VERBOSECASE(ClickEncoder::Released)&#xA;  VERBOSECASE(ClickEncoder::Clicked)&#xA;&#xA;  case ClickEncoder::DoubleClicked:&#xA;      Serial.println(&quot;ClickEncoder::DoubleClicked&quot;);&#xA;      encoder-&amp;gt;setAccelerationEnabled(!encoder-&amp;gt;getAccelerationEnabled());&#xA;      Serial.print(&quot;  Acceleration is &quot;);&#xA;      Serial.println((encoder-&amp;gt;getAccelerationEnabled()) ? &quot;enabled&quot; : &quot;disabled&quot;);&#xA;      setMode = true;&#xA;       value = 0;&#xA;    break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="19095" LastActivityDate="2016-03-09T09:52:34.340" Title="How do I statements for the various conditions of this function?" Tags="|arduino-uno|c++|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21603" PostTypeId="1" CreationDate="2016-03-09T08:18:08.740" Score="1" ViewCount="5065" Body="&lt;p&gt;I've decided to use Sparkfun's Pro Mini boards to make my project into a semi-professional product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first thought turned to enclosures - of which the entire internet seems to be bereft. If I ever DO see an enclosure, it's for the Uno sized board and costs about twice the price of the board, which seems incredible to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No matter, I have found a way to make quite good enclosures for the Pro Mini pretty easily and cheaply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HOWEVER, the next problem is mounting the board inside the box. I would like to be able to mount it firmly to the base but in a way which allows it to be removed if necessary. Obviously, there's not a lot of scope for putting screws through the board. It occurs to me that anything which holds it would need to do so by gripping the edges or the corners. Is there such a thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there's nothing that fits the bill, would the board be OK if I were to HOT GLUE it to the base of the enclosure? &lt;/p&gt;&#xA;" OwnerUserId="3377" LastActivityDate="2021-11-15T12:18:52.213" Title="Mounting Arduino in an enclosure" Tags="|arduino-pro-mini|enclosure|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21604" PostTypeId="2" ParentId="21601" CreationDate="2016-03-09T09:52:34.340" Score="1" Body="&lt;p&gt;You will have to explicitely expand the case &lt;code&gt;ClickEncoder::Pressed&lt;/code&gt;. So instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VERBOSECASE(ClickEncoder::Pressed);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you should write something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case ClickEncoder::Pressed:&#xA;    Serial.println(&quot;ClickEncoder::Pressed&quot;);&#xA;    digitalWrite(ledpin, HIGH);&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course then you'll have to turn it off then, but.. Well, that's another problem&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-09T09:52:34.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21605" PostTypeId="1" CreationDate="2016-03-09T09:55:43.140" Score="2" ViewCount="7611" Body="&lt;p&gt;I have connected a Raspberry Pi 2 model B to an Arduino Uno via Bi-Directional Level shifter, from this &lt;a href=&quot;http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/&quot; rel=&quot;nofollow noreferrer&quot;&gt;BLOG&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Raspberry pi    GND    ----------   GND     Arduino&#xA;                3.3v   ----------   5v&#xA;                SCL    ----------   A5&#xA;                SDA    ----------   A4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope my I2C connection is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And my Arduino is connected to an 8-Channel relay board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have written code in which I can control the relay board with the Raspberry Pi. For example, if I Press '1', relay 1 goes high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to send data back from the Arduino to the Raspberry Pi in order to cross-check if relay 1 is high or not. If relay 1 is high then it should send some data back to the Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Raspberry Pi code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import smbus&#xA;import time&#xA;# for RPI version 1, use &quot;bus = smbus.SMBus(0)&quot;&#xA;bus = smbus.SMBus(1)&#xA;&#xA;# This is the address we setup in the Arduino Program&#xA;address = 0x04&#xA;&#xA;def writeNumber(value):&#xA;    bus.write_byte(address, value)&#xA;    # bus.write_byte_data(address, 0, value)&#xA;    return -1&#xA;&#xA;def readNumber():&#xA;    number = bus.read_byte(address)&#xA;    # number = bus.read_byte_data(address, 1)&#xA;    return number&#xA;&#xA;while True:&#xA;    var = input(&quot;&quot;)&#xA;    if not var:&#xA;        continue&#xA;    writeNumber(var)&#xA;    number = readNumber()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SLAVE_ADDRESS 0x04&#xA;#define RELAY1 9&#xA;&#xA;int number = 0;&#xA;int state = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(RELAY1, OUTPUT);&#xA;    Serial.begin(9600); // start serial for output&#xA;    // initialize i2c as slave&#xA;    Wire.begin(SLAVE_ADDRESS);&#xA;    // define callbacks for i2c communication&#xA;    Wire.onReceive(receiveData);&#xA;    Wire.onRequest(sendData);&#xA;    Serial.println(&quot;Ready!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(100);&#xA;}&#xA;&#xA;// callback for received data&#xA;void receiveData(int byteCount){&#xA;    while(Wire.available()) {&#xA;       number = Wire.read();&#xA;       Serial.print(&quot;data received: &quot;);&#xA;       Serial.println(number);&#xA;        if (number == 1) {&#xA;            if (state == 0){&#xA;                digitalWrite(RELAY1, HIGH); // set the LED on&#xA;                state = 1;&#xA;            } else {&#xA;                digitalWrite(RELAY1, LOW); // set the LED off&#xA;                state = 0;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;// callback for sending data&#xA;void sendData(){&#xA;    Wire.write(number);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if I type 1, and due to some loose connection relay 1 doesn't go high, I want the Arduino to take data from the relay board and send it to the Raspberry Pi every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will be great if someone can explain also that how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope I was able to explain the problem. I have done lots of research but was not able to find some answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a beginner in Python so please help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="19099" LastEditorUserId="4628" LastEditDate="2017-07-02T06:18:21.870" LastActivityDate="2017-09-01T10:21:08.513" Title="How to read data from Arduino with Raspberry Pi via I2C?" Tags="|arduino-uno|i2c|python|raspberrypi|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21606" PostTypeId="2" ParentId="21603" CreationDate="2016-03-09T11:07:00.380" Score="5" Body="&lt;p&gt;What type of box?&#xA;Howmany times/how easily do you want to remove the Arduino Mini?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hot glue&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hot glue is the way to go in many occasions.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It does not conduct electricity, so is pretty safe. (Please check your specific hot glue first)&lt;/li&gt;&#xA;&lt;li&gt;It sticks quite well, for quite a time. You should also check if it's water resistant or fit for your target environment though.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But, it may have some side-effects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It can get quite messy (which does not look really professional)&lt;/li&gt;&#xA;&lt;li&gt;It's not that easily removable and has to be &quot;re-glued&quot; when you want to stick it back.&lt;/li&gt;&#xA;&lt;li&gt;It might be too sticky (in a carboard box, you won't be able to just rip out the Arduino, withouth damaging the box).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You could use double sided tape, which might actually work fine. Or atleast better/neater as the hot glue.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sticky velcro&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A neat solution would be sticky velcro. You can easily attach, detach and re-attach the arduino to the velcro. It looks quite fancy and should hold well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, you should check the specific velcro, it might not last 1000+ times of re-attaching (become loose or smh). But will be a good option overall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3edeI.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3edeI.jpg&quot; alt=&quot;sticky velcro&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use mint-boxes as an enclosure. But they're usually made of tin or another conductive material. Please take care and cover the back of your arduino (or box) with electrical tape, to avoid shorts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra-extra, you should (for &quot;replacability&quot;) add connectors or headers to your Arduino. Since soldering the leads directly will still give the need to un-solder or resolder your Arduino when replacing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note on making your Arduino project a consumer item&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might save yourself quite some money by using a barebones arduino. Or actually, an ATmega 328P chip. Which is around 3€.&#xA;These will be a little more difficult to program, but might also look more professional.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also enable &quot;program protection&quot; fuse bits, so that others can't download the code from your arduino/microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-09T11:07:00.380" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21608" PostTypeId="1" AcceptedAnswerId="21628" CreationDate="2016-03-09T12:27:14.983" Score="8" ViewCount="25335" Body="&lt;p&gt;Please take this question as an example to (my own) answer below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got an 7 segment, 4 digit LED display, but I don't have any idea on how to wire it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand the difference between common anode/cathode, and I don't have 2 pins per LED, which is strange. &#xA;Quite recently, a question on a &quot;7 segment 4 digit common anode&quot; got deleted. &#xA;At that very moment I was typing an answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though, I still want to share my answer with you, or the person who asked it.&#xA;Please verify/update my answer with more information. &#xA;Specifically, could someone add working code, I can't at the moment.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="29234" LastEditDate="2017-02-07T12:50:41.117" LastActivityDate="2017-02-07T12:50:41.117" Title="How to use a common anode 7-segment, 4-digit display?" Tags="|led|display|rgb-led|multiplexer|7-segment|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21609" PostTypeId="2" ParentId="21608" CreationDate="2016-03-09T12:27:14.983" Score="5" Body="&lt;p&gt;I'll try and take you through the complete basics of LED's etc.&#xA;As 4-digit 7-segment displays are a combination of multiple &quot;LED techniques&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wiring LED's&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED's, or Light Emitting Diodes, are one of the fun things of Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, they're easy to use, power them up and they'll light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can be annoying, because they have some kind of polarity, meaning that they will only work when you wire them right. If you reverse positive and negative voltage, they won't light up at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Annoying as it is, it's also quite usefull.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Cathode vs Anode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a traditional LED, the long lead is the (+), Anode.&#xA;The other lead being the (-) Cathode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Or, if someone’s trimmed the legs, try finding the flat edge on the LED’s outer casing. The pin nearest the flat edge will be the negative, cathode pin.&quot; - Sparkfun&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity&quot; rel=&quot;noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PLjNd.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PLjNd.png&quot; alt=&quot;Sparkfun&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Basic wiring&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this is correct, since I ripped the image from the internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tiPJk.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tiPJk.gif&quot; alt=&quot;Basic LED wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring an LED is quite easy, the Anode (+) connects to positive voltage, preferably through a current limiting resistor.&#xA;The Cathode (-) connects to ground (with a current limiting resistor, if you didn't have one on the positive side).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current limiting resistor will avoid the LED from shorting out, damaging the LED or Microcontroller/Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Multiple LEDs, matrices, RGB leds&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With multiple LED's you often have them with the positive side connected (+), &quot;common Anode&quot; or all connected to the (-) &quot;common Cathode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it'll come down to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/egSqx.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/egSqx.png&quot; alt=&quot;RGB common cathode/anode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a common cathode, you supply current to the pins that you want to have on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a common anode, you sink the current through the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Multiplexing (multiple digit, 7-segments)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should check out the tutorial of parallax: &lt;a href=&quot;http://learn.parallax.com/4-digit-7-segment-led-display-arduino-demo&quot; rel=&quot;noreferrer&quot;&gt;http://learn.parallax.com/4-digit-7-segment-led-display-arduino-demo&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UH0ut.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UH0ut.png&quot; alt=&quot;Parallax 4digit7seg&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you've got a lot of LED's, it's often smart to &quot;multiplex&quot; them. Usually you go through &quot;groups&quot; of LED's rapidly, so that it looks like they're all on at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually you sink current from a column of LED's and supply current to individual LED's of a row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, you supply current to a column of LED's and sink current from individual LED's of a row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that you can choose which column to activate, and which LED's of that column to light up. Changing these columns/rows rapidly will enable you to control multiple LED's with a lot less pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There even are display controllers for this, if you don't want to take care of the switching in your software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So when you have a 4 digit, multiplexed 7 segment, common anode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diagram will be more like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YUpEy.gif&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YUpEy.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.mytutorialcafe.com/Microcontroller%20Application%20C%207segmen.htm&quot; rel=&quot;noreferrer&quot;&gt;http://www.mytutorialcafe.com/Microcontroller%20Application%20C%207segmen.htm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-09T12:27:14.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21610" PostTypeId="2" ParentId="21402" CreationDate="2016-03-09T13:15:42.327" Score="0" Body="&lt;p&gt;Device connected to arduino had DTR/DSR. I had to jumper one to the other to convince it to flow data to the arduino.&lt;/p&gt;&#xA;" OwnerUserId="18948" LastActivityDate="2016-03-09T13:15:42.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21611" PostTypeId="1" CreationDate="2016-03-09T13:32:03.013" Score="1" ViewCount="589" Body="&lt;p&gt;I'm using the arduino to generate a 100kHz pwd using timer 1&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;   // Timer 1 Fast PWM mode *toggling* OC1A at 50kHz with *two* OCR1A counts&#xA;   // And 7.32 bits 0-159 PWM on OC1B at 100kHz&#xA;   // Output on OC1B  &#xA;   // Set at TOP, Clear at OCR1B&#xA;   // WGM =15 0b1111 &#xA;&#xA;   DDRB |= bit(DDB1) | bit(DDB2);  // atmega168/UNO OC1A and OC1B (Tested by OP/Luis)&#xA;&#xA;   TCCR1A =  bit(WGM11) | bit(WGM10) | bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM13) | bit(WGM12) | bit(CS10);  // Set /1 prescaler&#xA;   OCR1A  = 159 ;//79;    // Set TOP count to 16000000/(2*PreScaler*Ftoggle)&#xA;                          // or 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = 10;           // 10/160 duty cycle&#xA;   TCNT1 = 0 ;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  OCR1B = 160/4 -1 ; // 25% duty cycle. &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used this to test the modules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Receiver&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;RF24.h&quot;&#xA;int msg[1];&#xA;RF24 radio(9,10);&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;int LED1 = 3;&#xA;&#xA;void setup(void){&#xA; Serial.begin(9600);&#xA; radio.begin();&#xA; radio.openReadingPipe(1,pipe);&#xA; radio.startListening();&#xA; pinMode(LED1, OUTPUT);}&#xA;&#xA;void loop(void){&#xA; if (radio.available()){&#xA;   bool done = false;    &#xA;   while (!done){&#xA;     done = radio.read(msg, 1);      &#xA;     Serial.println(msg[0]);&#xA;     if (msg[0] == 111){delay(10);digitalWrite(LED1, HIGH);}&#xA;     else {digitalWrite(LED1, LOW);}&#xA;     delay(100);}}&#xA; else{Serial.println(&quot;No radio available&quot;);}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Transmitter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include  &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;RF24.h&quot;&#xA;int msg[1];&#xA;RF24 radio(9,10);&#xA;const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;int SW1 = 7;&#xA;&#xA;void setup(void){&#xA; Serial.begin(9600);&#xA; radio.begin();&#xA; radio.openWritingPipe(pipe);}&#xA;&#xA;void loop(void){&#xA; if (digitalRead(SW1) == HIGH){&#xA; msg[0] = 111;&#xA; radio.write(msg, 1);}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using this library&#xA;&lt;a href=&quot;https://github.com/TMRh20/RF24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And it works ok, now first issue is that both, RF24 and the pwm &#xA;are using the pin 10 but the library allows you  to change it, so now I'm using pin 7 instead. I tested it again and still works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I add the lines at the setup to use the pwd  the communication doesn't work&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   DDRB |= bit(DDB1) | bit(DDB2);  // atmega168/UNO OC1A &#xA;&#xA;   TCCR1A =  bit(WGM11) | bit(WGM10) | bit(COM1A0) | bit(COM1B1)  ; // Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM13) | bit(WGM12) | bit(CS10);  // Set /1 prescaler&#xA;   OCR1A  = 159 ;//79;    // Set TOP count to 16000000/(2*PreScaler*Ftoggle)&#xA;                          // or 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = 10;           // 10/160 duty cycle&#xA;   TCNT1 = 0 ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I try line by line and the issue is here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TCCR1B =  bit(WGM13) | bit(WGM12) | bit(CS10);  // Set /1 prescaler&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When setting the prescaler at 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which is the dependency of the RF24 on this timer? and which options to I have to make it work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm using pins 6 and 7 for CE and CS&#xA;Also removed  &quot;| bit(COM1A0) &quot; form the register  setting&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still doesn't work&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(void)&#xA;{&#xA;&#xA;  /// RF settings&#xA;&#xA;  Serial.begin(9600);&#xA; radio.begin();&#xA; //radio.openReadingPipe(1,pipe);&#xA; //radio.startListening();&#xA; pinMode(LED1, OUTPUT);&#xA;&#xA; /// end RF settings&#xA;&#xA;&#xA;  //// pwd settings&#xA; DDRB |= bit(DDB1) | bit(DDB2);  &#xA;   OCR1A  = max_count;       // 16000000/(PreScaler *Ftimer)&#xA;   OCR1B  = 10;           &#xA;   TCCR1A =  bit(WGM11) | bit(WGM10) |  bit(COM1B1); // bit(COM1A0) | Toggle OC1A, Clear on OC1B    &#xA;   TCCR1B =  bit(WGM13) | bit(WGM12) | bit(CS10);  // Set /1 prescaler&#xA;   TCNT1 = 0 ;&#xA;&#xA;  //// &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I put the settings for the PWM before the settings for the RF24 then the PWM doesn't work, the RF settings at first the the communications doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;radio.begin() must be overwriting the registers but I haven't found how.&lt;/p&gt;&#xA;" OwnerUserId="18574" LastEditorUserId="11529" LastEditDate="2016-03-14T11:00:51.740" LastActivityDate="2016-03-14T11:00:51.740" Title="RF24 + High speed pwd" Tags="|pwm|nrf24l01+|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21612" PostTypeId="2" ParentId="21593" CreationDate="2016-03-09T15:22:53.963" Score="1" Body="&lt;p&gt;This code was written and tested using an earlier Arduino IDE version, the author's upload of the source files happened over a year ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Within the Arduino 1.6.x branch the preprocessor and compiler behaviour have changed (among other things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Older libraries will require an earlier Arduino IDE version (i.e. the 1.5.x branch) from &lt;a href=&quot;https://www.arduino.cc/en/Main/OldSoftwareReleases#previous&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/OldSoftwareReleases#previous&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, we have to keep in mind that there are differences between Arduino.cc and Arduino.org. Those two projects split apart, their IDEs aren't equivalent any more.&lt;/p&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-09T17:44:43.723" LastActivityDate="2016-03-09T17:44:43.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21613" PostTypeId="2" ParentId="21582" CreationDate="2016-03-09T15:56:54.673" Score="0" Body="&lt;p&gt;Marcello Romani's &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;SimpleTimer library&lt;/a&gt; was made for this kind of problem. You let &lt;code&gt;loop()&lt;/code&gt; run as fast as possible but only maintain the timers and do other &lt;em&gt;short&lt;/em&gt; tasks. The timer library runs your periodic tasks when necessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleTimer.h&amp;gt;&#xA;SimpleTimer timer;         // creates a set of timers&#xA;&#xA;// A timer call-back function - there can be more than one&#xA;void onTimer(void){&#xA;   ;   // do stuff here, keep it short&#xA;}&#xA;&#xA;void setup(void){&#xA;   ;   // Serial.begin() and other setup&#xA;&#xA;   timer.setInterval(1000L, onTimer); // set a 1-sec repeating timer&#xA;}&#xA;&#xA;void loop(void){&#xA;   timer.run();   // updates timers, maybe calls a callback func&#xA;   ;              // whatever other loop code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-09T15:56:54.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21614" PostTypeId="2" ParentId="20921" CreationDate="2016-03-09T16:22:14.277" Score="2" Body="&lt;p&gt;If the encoder only gives +1 pulse per 90 degrees, you aren't going to get better than 90 degree accuracy out of it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example code at the link, the val{x,y,z} are measured analog variables of some other thing that are sampled at each encoder lcoation: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My project is a data loger where three analogue inputs are sampled&#xA;  each time a rotary encoder pulse steps clockwise. On an Arduino, time&#xA;  is of the essence to get this data sampled and saved somewhere (I have&#xA;  not included the 'saving somewhere' part of this project yet.) In&#xA;  order to save some processor cycles, I have slightly redesigned the&#xA;  interrupt system to maintain a pair of boolean states outside of the&#xA;  interrupt loop.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These are not directly related to the positioning of the encoder, and there is no reason to think they provide angle information. &lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-09T16:22:14.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21615" PostTypeId="1" AcceptedAnswerId="21633" CreationDate="2016-03-09T17:21:38.923" Score="4" ViewCount="11227" Body="&lt;p&gt;I would like to create a program with separated modules, is this this possible using Arduino IDE?&lt;/p&gt;&#xA;" OwnerUserId="18611" LastActivityDate="2017-11-24T00:24:33.527" Title="How to write modular code for arduino?" Tags="|arduino-ide|" AnswerCount="5" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21616" PostTypeId="1" AcceptedAnswerId="21711" CreationDate="2016-03-09T11:31:54.117" Score="2" ViewCount="3106" Body="&lt;p&gt;I know there is a lot on this subject on the net but i cant seem to be able to join the dots together. &#xA;I am trying to make sensor system than can run for as long as possible if not indefinitely using an Arduino, and also to do so very cheaply. I have a £1 Arduino Nano clone that is running with sensor and alarm fine, but currently its runs off USB power from PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have followed this guide to minimize power usage code side: &lt;a href=&quot;https://www.openhomeautomation.net/arduino-battery/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.openhomeautomation.net/arduino-battery/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I have read that the Vin pin needs at least 7 volts to work properly, so 2 volts would be wasted in heat making a 5V level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a 3.7V lithium cell 4300mAh so I thought I would need a step up boost module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it looks like the Nano can run using 3V. But the 3.3V rail is apparently made for external sensors, assuming I want a mixture of cheap/simple and high efficiency. Can i just hook a 3.7 lipo into the 5V rail of the Nano and a 5V solar panel (with diode) up to same point? Will this kill my Nano? &#xA;If not, is it worth stepping the 3.7V down to the minimum the Nano can run with?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Underclocking is not an issue, it essentially wakes up every hour reads 5 sensors and if all is well (99% of the time) goes back to sleep for an hour.&#xA;Linear voltage regulators seem to burn the excess voltage as heat. And then what will happen when the battery dies off and is no longer 3.7 volts? And if my solar panel is around 5V in good light, if its partly shaded and only has 3.5 volts for example it would not charge my lipo to 100% capacity. Should I step up DC/DC boost the panel voltage to charge my cell. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Guidance please.  &lt;/p&gt;&#xA;" OwnerUserId="19223" OwnerDisplayName="Arthur" LastEditorUserId="19445" LastEditDate="2017-10-31T15:38:24.093" LastActivityDate="2017-10-31T15:38:24.093" Title="Arduino minimal power usage" Tags="|power|arduino-nano|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21617" PostTypeId="2" ParentId="21616" CreationDate="2016-03-09T11:54:30.297" Score="6" Body="&lt;p&gt;Arduinos are for rapidly getting something going without having to know much about the underlying electronics and microcontroller.  As a result, some design tradeoffs were made for you, generally optimized for development simplicity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now have a different primary concern, which is low power consumption.  If that is truly important, then you have to design the system with that goal up front.  This means starting with the bare microcontroller, designing the electronics around it carefully to minimize power, and designing the firmware architecture to minimize high-power cycles and maximize sleep time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are asking where to strap the big engine on a Honda Civic to make a high performance racing car.  You can make a Civic higher performance, but to get really high performance you have to start with that goal from the beginning.&lt;/p&gt;&#xA;" OwnerDisplayName="Olin Lathrop" LastActivityDate="2016-03-09T12:29:07.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21618" PostTypeId="1" CreationDate="2016-03-09T17:38:40.663" Score="1" ViewCount="326" Body="&lt;p&gt;Good day,&#xA;I have a serial device that when connected via hyper terminal gives me a status report when I press the letter 'd' no enter key or anything required just the letter d. Also Ctrl-t will give me some routing information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to press a button connected to the arduino and send the b to the serial device and view the status information back from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I have the Serial device connected to the arduino and am able to see messages from it, however when I press the switch connected to pin 2 the serial device does not send me the status output as expected and as seen via direct serial connection to my computer with hyperterminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have an experience or input regarding this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// software serial #1: TX = digital pin 10, RX = digital pin 11&#xA; SoftwareSerial portOne(10, 11);&#xA; const int buttonPin = 2;     // the number of the pushbutton pin&#xA; const int button1Pin = 4;&#xA; const int ledPin =  13;      // the number of the LED pin&#xA;//define char to send to serial&#xA;&#xA;char stat = 'd';&#xA;char route = '\x14';&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;int button1State = 0;&#xA;&#xA;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;                pinMode(ledPin, OUTPUT);&#xA;                pinMode(buttonPin, INPUT);&#xA;                pinMode(button1Pin, INPUT);&#xA;                Serial.begin(4800);&#xA;                while (!Serial) {; // wait for serial port to connect. Needed for native USB port only&#xA;                }&#xA;                // Start each software serial port&#xA;                portOne.begin(4800);&#xA;                while (!portOne) {; // wait for serial port to connect. Needed for native USB port only&#xA;                }&#xA;              }&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;            static int Once = 0;&#xA;            static int Once1 = 0;&#xA;            buttonState = digitalRead(buttonPin);&#xA;            button1State = digitalRead(button1Pin);&#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;            if (buttonState == HIGH ) { &#xA;                                      if (Once == 0) {&#xA;                                                        Once = 1;&#xA;                                                        // turn LED on so I can tell the button is working&#xA;                                                        digitalWrite(ledPin, HIGH);&#xA;                                                        // send d to Radio&#xA;                                                        portOne.write(stat);&#xA;                                                        // send d to serial monitor so I can see the charector&#xA;                                                        Serial.print(stat);&#xA;                                      }&#xA;                                      }&#xA;&#xA;&#xA;if (buttonState == LOW) {&#xA;                          // turn LED off:&#xA;                          Once = 0;&#xA;                          digitalWrite(ledPin, LOW);&#xA;&#xA;                          }&#xA;&#xA;&#xA;  // check if the other pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if (button1State == HIGH) {&#xA;    if (Once1 == 0) {&#xA;          Once1 = 1;&#xA;    // turn LED on:&#xA;   // digitalWrite(ledPin, HIGH);&#xA;    // send ctrl-t to radio&#xA;    portOne.write(route);&#xA;    } &#xA;  }&#xA;  if (button1State == LOW) {&#xA;    // turn LED off:&#xA;    //digitalWrite(ledPin, LOW);&#xA;    Once1 = 0;&#xA;  }&#xA;    portOne.listen();&#xA;      // read data from the Software Serial portOne&#xA;   // and send to the hardware serial port:&#xA;   while (portOne.available() &amp;gt; 0) {&#xA;     char inByte = portOne.read();&#xA;     Serial.print(inByte);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BUnZv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BUnZv.jpg&quot; alt=&quot;Breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18948" LastEditorUserId="18948" LastEditDate="2016-03-09T20:45:13.957" LastActivityDate="2016-03-09T20:45:13.957" Title="Trying to pass a single char to a serial device" Tags="|softwareserial|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21619" PostTypeId="1" AcceptedAnswerId="21630" CreationDate="2016-03-09T17:49:05.800" Score="0" ViewCount="4196" Body="&lt;p&gt;I am trying to build a mobile device that turns itself on when removed from its usual location. I am attempting to do this with an Adafruit PN532 RFID reader and a MiFare card. Using the sample code I can detect when the card is present &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;success= nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;Serial.println(&quot;Scanning&quot;);&#xA;if (success){&#xA;  Serial.println(&quot;FOUND&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I try to detect the absence of the card using the following code it will tell me &quot;Present&quot; over and over (since its in the Loop) while the RFID card is present but when it is removed it stops printing &quot;Present&quot; but never prints &quot;Card Gone&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;success= nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;    Serial.println(&quot;Present&quot;);&#xA;    if (!success){&#xA;      Serial.println(&quot;Card Gone&quot;);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this a function of how Im using ! or is there something else at play here? I have found very few suggestions regarding detecting the absence of an RFID card and none of them seem to provide any useful answer. Most suggest some other hardware methodology as the solution. That is not the type of answer Im interested in for the moment. I would simply like to figure out why my code is incorrect.&lt;/p&gt;&#xA;" OwnerUserId="14705" LastActivityDate="2017-08-26T22:50:59.373" Title="Detect when RFID card is absent" Tags="|arduino-uno|rfid|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21620" PostTypeId="2" ParentId="21615" CreationDate="2016-03-09T17:54:48.413" Score="2" Body="&lt;p&gt;Arduino sketches can include Libraries (see &lt;a href=&quot;https://www.arduino.cc/en/Guide/Libraries&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/Libraries&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to work with the Arduino IDE, such a library is required to adhere to a certain folder structure and naming convention (as described in the above guide). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, it's similar to modularized code in any other language. The canonical language in Arduino libraries is C++. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since a regular Arduino IDE installation already comes preinstalled with a multitude of libraries, you can take a look and go from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend that you look through the example sketches (from the &quot;Examples&quot; menu option). Whenever you see an #include statement at the top of the sketch, you have a hint where to look next in order to gain a better understanding about the inner works. &lt;/p&gt;&#xA;" OwnerUserId="19016" LastActivityDate="2016-03-09T17:54:48.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21621" PostTypeId="1" CreationDate="2016-03-09T17:55:54.877" Score="2" ViewCount="1154" Body="&lt;p&gt;I was wondering if I would be able to use specific parts of the c++ library for my arduino sketch. For example the arduino library has a queue array but I wanted to use a priority queue for my sketch and I am unsure how to modify the queue header file to do that. Also if I can use the priority queue from the c++ library can you please tell me how I would go about doing that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank-you&lt;/p&gt;&#xA;" OwnerUserId="19110" LastActivityDate="2016-03-09T17:55:54.877" Title="How to implement a priority queue" Tags="|c++|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21622" PostTypeId="1" CreationDate="2016-03-09T18:09:01.340" Score="0" ViewCount="130" Body="&lt;p&gt;I'm developing a program to calculate static margin of an aircraft through the calculations of mass,moment and arm. Essentially dealing with large numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having difficulty in setting up my code in the way so that the arithmetic is applied correctly to larger numbers. What I have so far works but only when the input is 0-9. The arithmetic fails to calculate digits beyond. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that I'm breaking the digits into separate variables as to convert them from ASCII format to their intended value. The problem is in putting those digits back together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is probably very simple but I'm picking up arduino again after a long break and I'm very rusty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code thus far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long batterymoment,num1,num2,answer;&#xA;int batterymass = 720;&#xA;int batteryposition;&#xA;boolean mySwitch = false;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  num1=0;&#xA;  num2=0;&#xA;  Serial.println(&quot;Enter battery position&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial.available()){&#xA;   batteryposition = Serial.read();&#xA;&#xA;   if(batteryposition&amp;gt;47 &amp;amp;&amp;amp; batteryposition&amp;lt;58){  &#xA;     if(!mySwitch){&#xA;       num1=(num1*10)+(batteryposition-48);&#xA;     }else{&#xA;       num2=(num2*10)+(batteryposition-48);&#xA;     }&#xA;   }&#xA;&#xA;   answer=num1+num2;&#xA;   batterymoment=answer*batterymass;&#xA;   Serial.print(&quot;Battery moment is: &quot;);&#xA;   Serial.println(batterymoment);&#xA;   num1=0;&#xA;   num1=0;&#xA;   mySwitch=false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="19111" LastEditorUserId="6628" LastEditDate="2016-03-09T18:20:41.700" LastActivityDate="2016-05-08T19:36:31.423" Title="Simple Arduino Serial Arithmetic" Tags="|arduino-uno|serial|data-type|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21623" PostTypeId="2" ParentId="21622" CreationDate="2016-03-09T18:24:14.270" Score="1" Body="&lt;p&gt;Do you mean to repeat num1=0; in loop()?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is only reading one character per loop() because loop() happens much faster than Serial.available() and Serial.read().  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the reporting and clearing when you receive some sort of separator/non-digit character.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-09T18:24:14.270" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21624" PostTypeId="1" CreationDate="2016-03-09T19:47:49.400" Score="1" ViewCount="2472" Body="&lt;p&gt;I have just connected a Libelium shield to connect many sensors to Arduino UNO, that measure water ph level, temperature,...etc. I really couldn't figure out how do I upload the sensor data into a database(MySQL). I have the code for database connectivity, but still couldn't figure out how(Querying) to upload the sensor data into the database.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem here is how do I make the arduino recognize the sensor data to upload it into database or send to to another Arduino or Raspberry pi through XBee.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code for database connectivity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sendData(){&#xA;&#xA;          Serial.println(&quot;Connecting...&quot;);&#xA;          if (my_conn.mysql_connect(server_addr, 3306, user, password)){&#xA;            delay(500);&#xA;            Serial.println(&quot;Starting SQL!&quot;);&#xA;            Serial.println(INSERT_SQL);&#xA;            my_conn.cmd_query(INSERT_SQL);&#xA;            Serial.println(&quot;Query Success!&quot;);&#xA;            my_conn.disconnect();&#xA;            Serial.println(&quot;\n&quot;);&#xA;          } &#xA;          else {&#xA;            Serial.println(&quot;Connection failed!&quot;);&#xA;          }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19115" LastEditorUserId="19116" LastEditDate="2016-03-11T22:30:03.870" LastActivityDate="2016-11-07T02:08:42.873" Title="How do I upload the sensor data from arduino into a database?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21625" PostTypeId="1" CreationDate="2016-03-09T20:24:07.627" Score="2" ViewCount="1516" Body="&lt;p&gt;I just got 4 nrf24l01+ modules with the external antennas, but I'm not able to make them work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using arduino nanos and MySensors to create a gateway and a sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The funny thing is that when I put a antenna nrf as the gateway and a pcb nrf as sensor, they work just fine, but the other way doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried two nrfs as gateway and sensor, but the behavior does not look good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could it be? Wifi router interference? Channel? Baud rate? Data rate?&lt;/p&gt;&#xA;" OwnerUserId="16211" LastActivityDate="2016-03-10T10:03:27.997" Title="nrf24l01+ with antenna problem" Tags="|sensors|arduino-nano|nrf24l01+|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21626" PostTypeId="2" ParentId="21560" CreationDate="2016-03-09T21:28:47.917" Score="1" Body="&lt;p&gt;I dont have an exact reply but&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) are you certain the other tags are type b?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) hace you tried connecting the reader using a UART USB cable? You could use libnfc, to check if the reader works.&#xA;And going forward &lt;a href=&quot;http://www.nxp.com/documents/user_manual/141520.pdf&quot; rel=&quot;nofollow&quot;&gt;at commands FOR the reader&lt;/a&gt; are a good way to debbug.&lt;/p&gt;&#xA;" OwnerUserId="14464" LastActivityDate="2016-03-09T21:28:47.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21627" PostTypeId="1" AcceptedAnswerId="21629" CreationDate="2016-03-09T21:40:06.883" Score="5" ViewCount="6076" Body="&lt;p&gt;I was looking how a servomotor works. I realized that a standard servo can only turn up to 180°, but I didn't understand why. Is it because of the potentiometer?&lt;/p&gt;&#xA;" OwnerUserId="16785" LastEditorUserId="37" LastEditDate="2016-03-10T05:06:03.483" LastActivityDate="2018-05-24T13:35:07.553" Title="Why can't most servos rotate more than around 180°" Tags="|servo|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21628" PostTypeId="2" ParentId="21608" CreationDate="2016-03-09T21:45:54.237" Score="5" Body="&lt;p&gt;Just as a complement to Paul's answer, I wrote a short program to show&#xA;how to drive the 7-segment 4-digit display of his figure:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/UH0ut.png&quot; alt=&quot;wiring schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is actually a common cathode display, so the program assumes that,&#xA;as well as the particular wiring of the figure. The interesting part is&#xA;the &lt;code&gt;refresh_display()&lt;/code&gt; function, which should be called periodically.&#xA;The algorithm is as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;drive the 7 anodes with the appropriate signals for one of the digits&#xA;we want to show&lt;/li&gt;&#xA;&lt;li&gt;set &lt;code&gt;HIGH&lt;/code&gt; the output that controls that digit's cathode through the&#xA;NPN transistor&lt;/li&gt;&#xA;&lt;li&gt;wait for 2.5 ms (for a refresh rate of 100 Hz)&lt;/li&gt;&#xA;&lt;li&gt;set &lt;code&gt;LOW&lt;/code&gt; the cathode-controlling output&lt;/li&gt;&#xA;&lt;li&gt;move to the next digit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It should be noted that the waiting is done without blocking the CPU, by&#xA;using the technique described in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;noreferrer&quot;&gt;Blink Without&#xA;Delay&lt;/a&gt; Arduino&#xA;tutorial. Here is the program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int NB_DIGITS     = 4;  // 4-digit display&#xA;const int FIRST_ANODE   = 2;  // anodes a..g on pins 2..8&#xA;const int FIRST_CATHODE = 9;  // cathodes, right to left, on pins 9..12&#xA;&#xA;// Digits to display, from right to left.&#xA;uint8_t digits[NB_DIGITS];&#xA;&#xA;// Set all the used pins as outputs.&#xA;void init_display()&#xA;{&#xA;    for (int i = 0; i &amp;lt; 7; i++)&#xA;        pinMode(FIRST_ANODE + i, OUTPUT);&#xA;    for (int i = 0; i &amp;lt; NB_DIGITS; i++)&#xA;        pinMode(FIRST_CATHODE + i, OUTPUT);&#xA;}&#xA;&#xA;// This should be called periodically.&#xA;void refresh_display()&#xA;{&#xA;    // Our 7-segment &quot;font&quot;.&#xA;    static const uint8_t font[10] = {&#xA;        //abcdefg&#xA;        0b1111110, // 0&#xA;        0b0110000, // 1&#xA;        0b1101101, // 2&#xA;        0b1111001, // 3&#xA;        0b0110011, // 4&#xA;        0b1011011, // 5&#xA;        0b1011111, // 6&#xA;        0b1110000, // 7&#xA;        0b1111111, // 8&#xA;        0b1111011  // 9&#xA;    };&#xA;&#xA;    // Wait for 2.5 ms before switching digits.&#xA;    static uint32_t last_switch;&#xA;    uint32_t now = micros();&#xA;    if (now - last_switch &amp;lt; 2500) return;&#xA;    last_switch = now;&#xA;&#xA;    // Switch off the current digit.&#xA;    static uint8_t pos;&#xA;    digitalWrite(FIRST_CATHODE + pos, LOW);&#xA;&#xA;    // Set the anodes for the next digit.&#xA;    pos = (pos + 1) % NB_DIGITS;&#xA;    uint8_t glyph = font[digits[pos]];&#xA;    for (int i = 0; i &amp;lt; 7; i++)&#xA;        digitalWrite(FIRST_ANODE + i, glyph &amp;amp; 1 &amp;lt;&amp;lt; (6-i));&#xA;&#xA;    // Switch digit on.&#xA;    digitalWrite(FIRST_CATHODE + pos, HIGH);&#xA;}&#xA;&#xA;/***********************************************************************&#xA; * Example usage.&#xA; */&#xA;&#xA;void setup()&#xA;{&#xA;    init_display();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    uint32_t now = millis();&#xA;&#xA;    // Change the number displayed every second.&#xA;    static uint32_t last_change;&#xA;    if (now - last_change &amp;gt;= 1000) {&#xA;        digits[3] = digits[2];&#xA;        digits[2] = digits[1];&#xA;        digits[1] = digits[0];&#xA;        digits[0] = (digits[0] + 1) % 10;&#xA;        last_change = now;&#xA;    }&#xA;&#xA;    refresh_display();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Paul provided a link to a &lt;a href=&quot;http://learn.parallax.com/4-digit-7-segment-led-display-arduino-demo&quot; rel=&quot;noreferrer&quot;&gt;tutorial on&#xA;Parallax&lt;/a&gt;&#xA;that suggests using the&#xA;&lt;a href=&quot;https://github.com/jhartshorn/Arduino/tree/master/libraries/Multiplex7Seg&quot; rel=&quot;noreferrer&quot;&gt;Multiplex7Seg&lt;/a&gt;&#xA;Arduino library. That library is more general than the example code&#xA;above, as it does not make assumptions about the pins used. But the big&#xA;difference between the library and this code is in the way the timings&#xA;are managed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The library is driven by the Timer 2 overflow interrupt. This should&#xA;provide a very steady timing, at the cost of having one timer&#xA;dedicated to this job.&lt;/li&gt;&#xA;&lt;li&gt;The code above relies on the user calling &lt;code&gt;refresh_display()&lt;/code&gt; often&#xA;enough. It doesn't require dedicated hardware resources, but it&#xA;doesn't play well with programs that take too long to &lt;code&gt;loop()&lt;/code&gt;: it&#xA;won't like you calling &lt;code&gt;delay()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-09T21:45:54.237" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21629" PostTypeId="2" ParentId="21627" CreationDate="2016-03-09T22:12:46.603" Score="6" Body="&lt;p&gt;Fundamentally, because the systems they were designed for convert rotary motion to linear, typically with a range substantially less than 180 degrees (probably more like 120 degrees).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, because the control scheme of PWM &lt;em&gt;position&lt;/em&gt; pulses is not able to convey requests over an arbitrary range - the mapping of pulse width to position must be limited, and it is sensibly set up to map to something related to the useful range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because these limitations in task, a fairly ordinary rotary potentiometer of less than 360 degree range can be employed for position sensing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the useful range is limited, and the potentiometer relatively easy to damage by over rotation, the gearbox is typically constructed with a mechanical rotation stop somewhere outside the normal range of self rotation.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-03-09T22:12:46.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21630" PostTypeId="2" ParentId="21619" CreationDate="2016-03-09T23:50:25.947" Score="2" Body="&lt;p&gt;First, your code isn't structured properly. It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;&#xA;if (success)&#xA;  Serial.println(&quot;Present&quot;);&#xA;else&#xA;  Serial.println(&quot;Card Gone&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From what I could find in the library, the reason you aren't getting either the 'Card Gone' or 'Present' message when there is no card is because &lt;code&gt;nfc.readPassiveTargetID()&lt;/code&gt; is a blocking function. It will wait forever until a tag is detected, at which point it returns to the caller. When you bring a card within the reader's range, the function returns quickly and &lt;code&gt;loop()&lt;/code&gt; runs smoothly, giving you the 'Present' message over and over again. When you remove the card however, on the next call of &lt;code&gt;nfc.readPassiveTargetID()&lt;/code&gt;, the function tries to locate a card but finds none and then it keeps trying and does not return. So &lt;code&gt;loop()&lt;/code&gt; never gets past that point, until you bring a card within range again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To detect the presence or absence of something, an observer must observe for some &lt;em&gt;pre-determined period of time&lt;/em&gt; before making a decision. So, I suggest you get the &lt;a href=&quot;https://github.com/adafruit/Adafruit_NFCShield_I2C&quot; rel=&quot;nofollow&quot;&gt;latest version&lt;/a&gt; of this library which gives you the option of adding a milliseconds &lt;code&gt;timeout&lt;/code&gt; argument to &lt;code&gt;nfc.readPassiveTargetID()&lt;/code&gt;. That way, you can specify how long you want the function to try detecting a card before concluding there is no card and returning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could use your existing function as is but in &lt;code&gt;setup()&lt;/code&gt; you need to set the maximum number of re-tries before the &lt;code&gt;nfc.readPassiveTargetID()&lt;/code&gt; returns. This is done with &lt;code&gt;setPassiveActivationRetries()&lt;/code&gt;. Any argument from 0x00 to 0xFE indicates a finite number of tries, while 0xFF is to wait forever:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;nfc.setPassiveActivationRetries(0x9A); // for example&#xA;nfc.SAMConfig();  // this comes next&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-09T23:50:25.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21631" PostTypeId="2" ParentId="21611" CreationDate="2016-03-10T03:24:43.270" Score="1" Body="&lt;p&gt;Maybe doing 100kHz PWM with timer2 instead of timer1 would be good.  The registers look similar to timer1, but they are only 8 bit, so you can't go bigger than 255 in the compare and count registers. The prescaler would be the same, and the timer controlled pins would be D11 and D3:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  //// pwm settings for 100kHz on Timer 2&#xA;  //// Toggle OC2A/D11/PB3 at 50kHz, PWM OC2B/D3/PD3 at 100kHz:&#xA;   DDRB |= bit(DDB3); //Enable output&#xA;   DDRD |= bit(DDD3); //Enable output &#xA;   // WGM2x=0b111 for fast PWM with TOP=OCR2A&#xA;   // COM2Ax=0b01 for toggle OC2A at OCR2A&#xA;   // COM2Bx=0b10 for set@bottom-clear@match_OCR2B PWM &#xA;   TCCR2A =   bit(WGM21)  | bit(WGM20)  &#xA;            | bit(COM2B1)  // PWM on OC2B&#xA;            | bit(COM2A0); // Toggle OC2A    &#xA;   TCCR2B =   bit(WGM22) | bit(CS20);  // Set /1 prescaler&#xA;   OCR2A  = 159;       // 16000000/(PreScaler *Ftimer)-1&#xA;   OCR2B  = 10;        // 6.25% PWM&#xA;   TCNT2 = 0 ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested this on an Uno/Atmega328P, but it looks reasonable per the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet (p153-157)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want both the 50kHz toggle and 100kHz PWM outputs, (as in your posted code,) you could disable one or the other and adjust the frequency as needed.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-10T14:07:15.930" LastActivityDate="2016-03-10T14:07:15.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21632" PostTypeId="1" CreationDate="2016-03-10T03:25:20.750" Score="0" ViewCount="89" Body="&lt;p&gt;Why is my machine suddenly turns ON when I unplugged the USB on my computer? Does it have connection on the auto reset feature of my arduino board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AG4aC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AG4aC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String input = &quot;&quot;;&#xA;&#xA;void setup(){&#xA;&#xA;  Serial.begin(9600);   // Sets up communication with the serial port&#xA;&#xA;  pinMode(6,OUTPUT);&#xA;  pinMode(7,OUTPUT);&#xA;  pinMode(8,OUTPUT);&#xA;  pinMode(9,OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(11,OUTPUT);   // for start of program operation&#xA;&#xA;&#xA;  digitalWrite(6,HIGH);&#xA;  digitalWrite(7,HIGH);&#xA;  digitalWrite(8,HIGH);&#xA;  digitalWrite(9,HIGH);&#xA;  digitalWrite(10,HIGH);&#xA;&#xA;  digitalWrite(11,LOW);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  int recipe;&#xA;  //Serial.print(&quot;Enter recipe number: &quot;);&#xA;&#xA;  while(Serial.available()==0){    // Waits for data from serial port&#xA;  }&#xA;&#xA;  while(Serial.available() &amp;gt; 0){&#xA;    int data = Serial.read();&#xA;      // convert the incoming byte to a char&#xA;      // and add it to the string&#xA;    input += (char)data;&#xA;&#xA;    recipe = input.toInt()+'0';    //recipe=0 if not a digit&#xA;    if(recipe == '0')&#xA;      recipe = data;&#xA;&#xA;    if(data == '\n'){&#xA;      //Serial.print(&quot;Recipe: &quot;);&#xA;      //Serial.println(recipe);&#xA;      //Serial.print(&quot;String: &quot;);&#xA;      //Serial.println(input);&#xA;      input = &quot;&quot;;&#xA;    }&#xA;  }&#xA;&#xA;  if(recipe == 's'){     &#xA;    digitalWrite(11,HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(11,LOW);&#xA;&#xA;    digitalWrite(6,LOW);&#xA;    digitalWrite(7,LOW);&#xA;    digitalWrite(8,LOW);&#xA;    digitalWrite(9,LOW);&#xA;    digitalWrite(10,LOW);    &#xA;  }&#xA;&#xA;  else if(recipe&amp;gt;'0' &amp;amp;&amp;amp; recipe&amp;lt;'32'){    &#xA;&#xA;    recipe = recipe-'0';&#xA;    char binary[7] = {0};   // This is where the binary representation will be stored&#xA;    recipe += 32; // Adding 32 so that there will always be 6 digits in the string&#xA;    itoa(recipe,binary,2);  // Convert recipe to a string of base 2 and save it in array 'binary'&#xA;    char* signals = binary + 1; // Get rid of the most significant digit to get the 5 bits&#xA;&#xA;  //Serial.print(signals);  // Print out the signals in binary&#xA;&#xA;    int i;&#xA;    for(i=0; i&amp;lt;5; i++){&#xA;      if(signals[i] == '0')&#xA;        signals[i] = '1';&#xA;      else&#xA;        signals[i] = '0';&#xA;      digitalWrite(i+6, signals[i]-'0');    // write to pin; converts the bit of the string to HIGH or LOW&#xA;      //Serial.print(signals[i]);&#xA;    }&#xA;&#xA;  }&#xA;  else&#xA;    loop();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19121" LastEditorUserId="6628" LastEditDate="2016-03-10T04:34:32.313" LastActivityDate="2016-03-10T05:05:45.277" Title="Machine installed with arduino suddenly turns on when usb is unplugged" Tags="|arduino-mega|electronics|project|home-automation|automatization|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="21633" PostTypeId="2" ParentId="21615" CreationDate="2016-03-10T04:19:43.580" Score="3" Body="&lt;p&gt;While you can create your own libraries for the Arduino, a simple way to make reusable code is to create a header (.h) file that contains the code you would like to make reusable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, in the Arduino IDE &lt;a href=&quot;https://www.arduino.cc/en/Guide/Environment#toc8&quot; rel=&quot;nofollow&quot;&gt;create a new tab&lt;/a&gt; with some name &lt;code&gt;foo.h&lt;/code&gt;, and in your main tab, add &lt;code&gt;#include &quot;foo.h&quot;&lt;/code&gt; at the top of your code. What this does is essentially copy paste the code from &lt;code&gt;foo.h&lt;/code&gt; into your code during the &lt;a href=&quot;https://www.arduino.cc/en/Hacking/BuildProcess&quot; rel=&quot;nofollow&quot;&gt;build process&lt;/a&gt;. While simple in execution, it really helps organize more complex code, and in your case, helps with reusing code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can alternativly use &quot;Normal Arduino code files (no visible extension), C files (.c extension), C++ files (.cpp), or header files (.h).&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one extra note to help you - the header files do not have access to some of the typical Arduino commands and functionality, such as &lt;code&gt;delay()&lt;/code&gt; or &lt;code&gt;Serial&lt;/code&gt; unless you add &lt;code&gt;#include &quot;Arduino.h&quot;&lt;/code&gt;. However, for IDE versions less than 1.0, use &lt;code&gt;#include &quot;WProgram.h&quot;&lt;/code&gt;. This will give you access to those functions.&lt;/p&gt;&#xA;" OwnerUserId="19090" LastActivityDate="2016-03-10T04:19:43.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21634" PostTypeId="1" CreationDate="2016-03-10T04:35:04.323" Score="1" ViewCount="59" Body="&lt;p&gt;I'm building a CANBUS network based on an arduino to go into an offroad racing truck. The vehicle has two separate battery systems, and I would like to monitor the voltage while still electrically isolating them from the arduino itself. For the voltage monitoring itself, I assume I can use a simple voltage divider into an Analog pin. To electrically isolate the arduino, would an Opto Isolator work? I found this one: &lt;a href=&quot;https://www.sparkfun.com/products/9118&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9118&lt;/a&gt; But it appears that it's designed for low voltage to control high voltage, as opposed to the other way around. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-10T09:53:38.310" Title="Opto Isolator question" Tags="|electricity|voltage-protection|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21635" PostTypeId="2" ParentId="21632" CreationDate="2016-03-10T04:39:21.313" Score="1" Body="&lt;p&gt;Do not call &lt;code&gt;loop&lt;/code&gt; from &lt;code&gt;loop&lt;/code&gt;. You will quickly run out of RAM and the sketch will crash:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void loop(){&#xA;&#xA;  int recipe;&#xA;  //Serial.print(&quot;Enter recipe number: &quot;);&#xA;&#xA;  while(Serial.available()==0){    // Waits for data from serial port&#xA;  }&#xA;&#xA;  while(Serial.available() &amp;gt; 0){&#xA;...&#xA;&#xA;  }&#xA;  else&#xA;    loop();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the pins that are supposed to be high, I suggest pull-up resistors:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  pinMode(6,OUTPUT);&#xA;  pinMode(7,OUTPUT);&#xA;  pinMode(8,OUTPUT);&#xA;  pinMode(9,OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(11,OUTPUT);   // for start of program operation&#xA;&#xA;&#xA;  digitalWrite(6,HIGH);&#xA;  digitalWrite(7,HIGH);&#xA;  digitalWrite(8,HIGH);&#xA;  digitalWrite(9,HIGH);&#xA;  digitalWrite(10,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When the Arduino powers up it enters the bootloader for a second or so. Those pins won't be set high yet. A pull-up resistor would make sure they are high until such time as you want to drive them low.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you are saying that the machine powers up when you &lt;strong&gt;disconnect&lt;/strong&gt; the power to the Arduino, that is still a good reason for using pull-up resistors, to make sure that it does not operated until commanded to do so.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;where will i connect the pull up resistors and how?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Typically pull-up resistors will be around 10k, and are connected from the pin to +5V. Of course, if the Arduino is not powered, then you need another source of the +5V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;please to clarify the &quot;do not call from loop to loop&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Remove these two lines:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;else&#xA;    loop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;loop&lt;/code&gt; exits, is it immediately re-called. You don't need to do it that way, in fact it is a Bad Idea.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-10T04:52:33.263" LastActivityDate="2016-03-10T04:52:33.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21636" PostTypeId="2" ParentId="21632" CreationDate="2016-03-10T04:39:56.197" Score="0" Body="&lt;p&gt;It looks like the this line in your setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  digitalWrite(11,LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... would trigger contact input 211, and do &quot;Start of Program Operation when D11 switches from off to on&quot; every time the sketch starts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the arduino resets, it will pull this line low.  Autoreset would initiate this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By changing the line to the following, the code will wait until it gets an 's' before pulling the line low.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  digitalWrite(11,HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't have an Arduino, but perhaps &lt;a href=&quot;http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection&lt;/a&gt; may help in managing the Auto-Reset issue.  &lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-10T05:05:45.277" LastActivityDate="2016-03-10T05:05:45.277" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21637" PostTypeId="2" ParentId="21634" CreationDate="2016-03-10T05:42:22.397" Score="2" Body="&lt;p&gt;An optoisolator is good for digital signals, but won't transfer an analog signal accurately.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you could put ADCs on the different circuits and optoisolate their communication with a master Arduino.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-10T05:42:22.397" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21639" PostTypeId="2" ParentId="21444" CreationDate="2016-03-10T06:46:11.390" Score="0" Body="&lt;p&gt;Read up on Muscle Wire! I'm sure this will be the easiest most elegant solution.&#xA;Basically apply a small voltage to a section of this wire in response to sound detection and it will deform, changing the centre of gravity of the ball at rest, making it move. Use two pieces and you will manage to get it to move or tilt in two directions!&lt;/p&gt;&#xA;" OwnerUserId="19125" LastActivityDate="2016-03-10T06:46:11.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21642" PostTypeId="2" ParentId="21625" CreationDate="2016-03-10T09:28:15.173" Score="3" Body="&lt;p&gt;It's likely an issue related to the modules'  electric supply. The effects can be packet loss (even down to zero bps) or loss of communication with the module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two things have to be covered with the nRF modules for them to work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;current draw (i.e. power),&lt;/li&gt;&#xA;&lt;li&gt;decoupling/filtering (i.e. bypass capacitors).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since you don't mention specific devices, I'm assuming you refer to an 'antenna' module with SMA (or RP-SMA) connector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nordic Semiconductor nRF24l01+ that is typically used in these modules has a maximum power consumption well below 100mW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A module with power amplifier (PA) draws significantly more power than the nRF chip alone, the total power consumption will be larger than 100mW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino can only supply power according to it's onboard regulator capabilities. &#xA;The Minis (and Micros) feature a smaller regulator that cannot drive both the Atmel AVR microcontroller and the PA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;provide a separate 3.3V regulator for the nRF module(s),&lt;/li&gt;&#xA;&lt;li&gt;place a capacitor directly at the modules' connector's supply pins. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Link:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo#PP&quot; rel=&quot;nofollow&quot;&gt;https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo#PP&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-10T10:03:27.997" LastActivityDate="2016-03-10T10:03:27.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21643" PostTypeId="2" ParentId="21634" CreationDate="2016-03-10T09:53:38.310" Score="1" Body="&lt;p&gt;1) using current sensors based on Hall effect: &lt;a href=&quot;https://www.sparkfun.com/products/8882&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/8882&lt;/a&gt;. Their sensing circuit/leads and analog parts are electrically isolated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The drawbacks are: to calculate the voltage, need to wire some load resistor with known value to batteries, but you can switch on the load circuit by relay during measurement; susceptible to magnetic field, some shielding might be needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) to use &lt;a href=&quot;https://electronics.stackexchange.com/questions/51116/measuring-voltage-while-maintaining-isolation&quot;&gt;isolation amplifiers&lt;/a&gt;: please see &lt;a href=&quot;http://www.analog.com/en/products/amplifiers/isolation-amplifiers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.analog.com/en/products/amplifiers/isolation-amplifiers.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-03-10T09:53:38.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21644" PostTypeId="1" CreationDate="2016-03-10T10:00:01.797" Score="-2" ViewCount="778" Body="&lt;p&gt;How to I control arduino with voice. I got an Android app but it works only with Internet connectivity. So I was an Android app with works offline when I connect to my Bluetooth HC-05. Please suggest me some ideas&lt;/p&gt;&#xA;" OwnerUserId="18794" LastEditorUserId="6628" LastEditDate="2016-03-13T02:22:54.737" LastActivityDate="2016-03-13T02:22:54.737" Title="Bluetooth Arduino control (was Speech recognition arduino control)" Tags="|bluetooth|" AnswerCount="1" CommentCount="8" ClosedDate="2016-03-13T01:01:31.180" ContentLicense="CC BY-SA 3.0" />
  <row Id="21645" PostTypeId="1" CreationDate="2016-03-10T10:14:15.393" Score="0" ViewCount="606" Body="&lt;p&gt;I'm running the WiFiWebClient example which comes preloaded with Arduino IDE 1.6.7. I'm using Arduino Uno board with WiFi Shield Model R3.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Web client&#xA;&#xA; This sketch connects to a website (http://www.google.com)&#xA; using a WiFi shield.&#xA;&#xA; This example is written for a network using WPA encryption. For&#xA; WEP or WPA, change the Wifi.begin() call accordingly.&#xA;&#xA; This example is written for a network using WPA encryption. For&#xA; WEP or WPA, change the Wifi.begin() call accordingly.&#xA;&#xA; Circuit:&#xA; * WiFi shield attached&#xA;&#xA; created 13 July 2010&#xA; by dlf (Metodo2 srl)&#xA; modified 31 May 2012&#xA; by Tom Igoe&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;Vanilla Sky&quot;; //  your network SSID (name)&#xA;char pass[] = &quot;mypass&quot;;    // your network password (use for WPA, or use as key for WEP)&#xA;int keyIndex = 0;            // your network key Index number (needed only for WEP)&#xA;&#xA;int status = WL_IDLE_STATUS;&#xA;// if you don't want to use DNS (and reduce your sketch size)&#xA;// use the numeric IP instead of the name for the server:&#xA;//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)&#xA;char server[] = &quot;www.google.com&quot;;    // name address for Google (using DNS)&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server&#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;WiFiClient client;&#xA;&#xA;void setup() {&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // check for the presence of the shield:&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(&quot;WiFi shield not present&quot;);&#xA;    // don't continue:&#xA;    while (true);&#xA;  }&#xA;&#xA;  String fv = WiFi.firmwareVersion();&#xA;  if (fv != &quot;1.1.0&quot;) {&#xA;    Serial.println(&quot;Please upgrade the firmware&quot;);&#xA;  }&#xA;&#xA;  // attempt to connect to Wifi network:&#xA;  while (status != WL_CONNECTED) {&#xA;    Serial.print(&quot;Attempting to connect to SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;&#xA;    // wait 10 seconds for connection:&#xA;    delay(10000);&#xA;  }&#xA;  Serial.println(&quot;Connected to wifi&quot;);&#xA;  printWifiStatus();&#xA;&#xA;  Serial.println(&quot;\nStarting connection to server...&quot;);&#xA;  // if you get a connection, report back via serial:&#xA;  if (client.connect(server, 80) == 0) {&#xA;    Serial.println(&quot;connected to server&quot;);&#xA;    // Make a HTTP request:&#xA;    client.println(&quot;GET /search?q=arduino HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.google.com&quot;);&#xA;    client.println(&quot;Connection: keep-alive&quot;);&#xA;    client.println();&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // if there are incoming bytes available&#xA;  // from the server, read them and print them:&#xA;  while (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.write(c);&#xA;  }&#xA;&#xA;  // if the server's disconnected, stop the client:&#xA;  if (!client.connected()) {&#xA;    Serial.println();&#xA;    Serial.println(&quot;disconnecting from server.&quot;);&#xA;    client.stop();&#xA;&#xA;    // do nothing forevermore:&#xA;    while (true);&#xA;  }&#xA;}&#xA;&#xA;&#xA;void printWifiStatus() {&#xA;  // print the SSID of the network you're attached to:&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;&#xA;  // print your WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Address: &quot;);&#xA;  Serial.println(ip);&#xA;&#xA;  // print the received signal strength:&#xA;  long rssi = WiFi.RSSI();&#xA;  Serial.print(&quot;signal strength (RSSI):&quot;);&#xA;  Serial.print(rssi);&#xA;  Serial.println(&quot; dBm&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It gets my WiFi shield connected to &lt;code&gt;Vanilla Sky&lt;/code&gt; but doesn't fetch the HTTP request (see image below). What is getting wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cTNC9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cTNC9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18846" LastEditorUserId="18846" LastEditDate="2016-03-10T15:41:18.757" LastActivityDate="2016-08-07T19:07:14.560" Title="Problem running WiFiWebClient example" Tags="|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21646" PostTypeId="1" AcceptedAnswerId="21650" CreationDate="2016-03-10T10:16:04.107" Score="0" ViewCount="2203" Body="&lt;p&gt;Can you power the Arduino off a USB cable alone, without using the regular power connection? If so, what's the point of the additional power connection: to provide extra power?&#xA;Also Why not just have two usb ports one for power one for connecting to the computer, or a micro usb.&lt;/p&gt;&#xA;" OwnerUserId="19126" LastActivityDate="2016-03-10T13:09:54.393" Title="Why does the Arduino UNO have a separate power port if USB also powers it?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21647" PostTypeId="2" ParentId="21646" CreationDate="2016-03-10T10:24:59.730" Score="1" Body="&lt;p&gt;Arduino, in its very esence, is an embedded system and can be used as a standalone device. The USB port is provided for:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;To power up the device.&lt;/li&gt;&#xA;&lt;li&gt;To &lt;strong&gt;program&lt;/strong&gt; it through a computer i.e. dump the sketch on it which one can program in the Arduino IDE.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Once you have dumped the program on it, it will stay on it forever unless you change/erase it and hence you can use the Arduino anywhere without actually bringing a computer (USB port) along.&lt;/p&gt;&#xA;" OwnerUserId="18846" LastEditorUserId="18846" LastEditDate="2016-03-10T11:26:32.433" LastActivityDate="2016-03-10T11:26:32.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21648" PostTypeId="2" ParentId="21624" CreationDate="2016-03-10T10:27:23.810" Score="1" Body="&lt;p&gt;First you have to create the table in your MySQL database, like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CREATE TABLE IF NOT EXISTS `table_log` (&#xA;  `log_id` int(11) NOT NULL AUTO_INCREMENT,&#xA;  `log_date` date NOT NULL,&#xA;  `log_time` time NOT NULL,&#xA;  `log_t1` float NOT NULL,&#xA;  `log_t2` float NOT NULL,&#xA;  `log_t3` float NOT NULL,&#xA;  `log_t4` float NOT NULL,&#xA;  `log_vbatt` float NOT NULL,&#xA;  PRIMARY KEY (`log_id`)&#xA;) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can execute it in your phpmyadmin page (or create the table manually there). Above we have columns for auto-increment id ('log_id' - necessary), date &amp;amp; time, 4 temperature values and voltage value (modify these according your requirements).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Than the query to create a new record would be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;INSERT INTO `table_log` (`log_id`, `log_date`, `log_time`, `log_t1`, `log_t2`, `log_t3`, `log_t4`, `log_vbatt`) VALUES&#xA;    (0, '2016-03-04', '01:53:30', 1.0, 2.0, 3.0, 4.0, 3.0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to create this string dynamically (with real values) and use instead of INSERT_SQL.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-03-10T10:27:23.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21649" PostTypeId="1" CreationDate="2016-03-10T10:33:45.063" Score="1" ViewCount="773" Body="&lt;p&gt;I want to gain from recent advice from this forum by re-doing my project using 'state machine' logic if possible, in an effort to reduce wasted processor time and variables usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm starting from Nick Gammons '&lt;em&gt;state machine to process input from the serial port&lt;/em&gt;' example &lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/statemachine&lt;/a&gt;, which shows all the different possible combinations for all the special control character 'events' against all the possible machine states - essentially a 2-dimensional grid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've refined my goal to the processing of serial input in a format of &quot;&lt;strong&gt;command  [parameters]  [options]&lt;/strong&gt;&quot;, similar to a DOS command-line format, eg:  &lt;strong&gt;DIR  &quot;c:\program files&quot;  /w /s&lt;/strong&gt;. This would free me from needing large Buffer[] and Header[] string, and avoides any parsing, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore my event control characters are space, comma, single-quote, double-quote, forward-slash, Carraige Return, and my 'states' are &lt;strong&gt;NULL, COMMAND, PARAMETER, OPTIONS&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OPTIONS state adds characters to a temporary option[] string until a comma or space delimiter or Carraige Return causes that option to be processed as appropriate, perhaps saving its value to a recognised variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The COMMAND and PARAMETER 'states' add characters to their corresponding command[] and parameters[] strings, including the special control characters if they are contained within either single or double quotes (thereby allowing quotes as part of a string if used within a pair of the other type). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there appears to be a second state machine needed for &lt;strong&gt;NoQuotes, SingleQuotes and DoubleQuotes&lt;/strong&gt; to modify the operation of the COMMAND, PARAMETER and OPTIONS states.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is where I run out of neurons, because all I see is an impossibly complex 2-machine-state 3-dimensional grid with too many possible permutations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I suspect there must be a very practical way to implement this, because it lies at the heart of almost all command-line utilities dating back to a time when processor power and memory availability were scarcer than hens teeth, and those old DOS command-line utilities needed to be as mimimal as was possible, including their command-line parsing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can anybody suggest a feasible model (machine-state or otherwise) for getting command-line type format from input?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh dear... I've just seen another complication I hadn't spotted before, which is that '/' options are not necessarily always at the end, which means that except if the options state changes by carraige-return, options state change by delimiter have to return to the state prior to the options state change (phew, I hope that makes some sense).  Anyway, I think it's back to drawing board because this approach seems likely to be too complicated, as the 2 answers already suggest.&lt;/p&gt;&#xA;" OwnerUserId="16433" LastEditorUserId="16433" LastEditDate="2016-03-10T14:52:23.167" LastActivityDate="2016-03-10T16:48:27.720" Title="Combining 2 State Machines?" Tags="|serial|programming|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21650" PostTypeId="2" ParentId="21646" CreationDate="2016-03-10T10:48:40.917" Score="1" Body="&lt;p&gt;As Hyperbola pointed out, the USB port function is primarily to allow for programming the board. Now, since the USB port has the power cables too, it is convenient to power the device from the USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main drawback of USB port powering, however, is that it can supply a limited current: usually the USB2 ports can deliver up to 500mA before shutting down. In order for the arduino board to be compliant with this, consequently, a 500mA fuse was put on the board just after the 5V usb input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, what if your final circuit requires more than 500mA? Will you have to change board? Of course not! you can just use the external power input to power the arduino board and all the other circuitry without worrying about the 500mA limitation. Of course the onboard regulator has limits too, but you have more flexibility.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover portable applications run on batteries. No battery can supply exactly 5V (usually alkaline ones deliver 1.5V per battery, while lithium have usually 3.7V/cell, but this varies over time). Consequently they put an onboard regulator for providing 5V from any 6.5V+ source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Summarizing: the USB power is convenient, since you will usually power it from the PC when programming. An external connector, however, is very important because it gives you more flexibility when choosing the power supply. You don't have to use both: you can just choose the most suitable for your needs.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-10T10:48:40.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21651" PostTypeId="2" ParentId="21645" CreationDate="2016-03-10T12:54:39.687" Score="1" Body="&lt;p&gt;Let's break it down :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Please upgrade the firmware&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Visit here to upgrade the firmware of your board. Your original post doesn't show the fw version, but could have outdated library references and has been noted many times that outdated fw will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also add this to your project to help us determine your firmware:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.print(&quot;Firmware version: &quot;);&#xA;  Serial.println(WiFi.firmwareVersion());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My guess is that it is less than 1.1.0. If the Arduino IDE is out of date, and the board is newer,  the NOT EQUAL TO(!=) may suggest that the firmware is newer than the library which could also be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just b/c it connects to your router, doesn't mean that it can still communicate correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last side note, some versions of Arduino IDE have proven to be problematic with uploading a sketch to a wifi shield. A quick search with your Arduino version followed by the Wifi Shield not connecting could point you in the right direction. eg- Arduino x.xx wifi shield not connecting&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-10T12:54:39.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21652" PostTypeId="2" ParentId="21646" CreationDate="2016-03-10T13:09:54.393" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you power the Arduino off a USB cable alone, without using the&#xA;  regular power connection?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use the USB cable alone to power the board.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If so, what's the point of the additional power connection: to provide&#xA;  extra power?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use either to power the board. By using just the power plug you can make your Arduino portable by using a &lt;a href=&quot;http://www.aliexpress.com/item/Battery-Case-with-Clip-for-4pcs-AA-battery-Arduino-Storage-Holder-Box-Case-Lead-FZ0975/32371855864.html?spm=2114.01010208.3.20.FsRn6V&amp;amp;ws_ab_test=searchweb201556_9,searchweb201602_2_505_506_503_504_10032_10020_502_10001_10002_10017_10005_10006_10003_10021_10004_10022_10018_10019,searchweb201603_9&amp;amp;btsid=5dfc0189-3cc3-4582-846c-0eb45294bea7&quot; rel=&quot;nofollow noreferrer&quot;&gt;battery box&lt;/a&gt; or power it via a &lt;a href=&quot;http://www.aliexpress.com/item/9V-1A-AC-DC-Power-Suppy-Adapter-WALL-WART-PLUG-Arduino/32614338731.html?spm=2114.01010208.3.2.LTo710&amp;amp;ws_ab_test=searchweb201556_9,searchweb201602_2_505_506_503_504_10032_10020_502_10001_10002_10017_10005_10006_10003_10021_10004_10022_10018_10019,searchweb201603_9&amp;amp;btsid=2d7049b6-4056-45c3-aeba-8d9667ab7e8a&quot; rel=&quot;nofollow noreferrer&quot;&gt;wall plug&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also Why not just have two usb ports one for power one for connecting&#xA;  to the computer, or a micro usb.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Only ONE USB is needed to power and program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nQQUn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nQQUn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i1TAB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i1TAB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kc9QH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kc9QH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-10T13:09:54.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21653" PostTypeId="2" ParentId="21644" CreationDate="2016-03-10T13:13:54.080" Score="1" Body="&lt;p&gt;You might find your answer with someone else who has done the same thing on Instructables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Arduino-Voice-recognition-Via-Bluetooth-HC-05/&quot; rel=&quot;nofollow&quot;&gt;Arduino Voice recognition Via Bluetooth HC-05 - http://www.instructables.com/id/Arduino-Voice-recognition-Via-Bluetooth-HC-05/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-10T13:13:54.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21654" PostTypeId="2" ParentId="17236" CreationDate="2016-03-10T13:22:14.217" Score="1" Body="&lt;p&gt;Sorry to dredge up an old thread (well, really only replying to one that got robo-dredged :), but maybe this will help someone someday.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A /dev/cu.&amp;lt;something&amp;gt; is a unix port designation. &quot;cu.&quot; meant a port used for modems, back in the mists of time but probably isn't relevant today. But what we do learn from it is that the OP is probably using a Mac, and for sure, not Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;/dev/cu.usbmodem1421&quot; is a typical device name for an Arduino as seen by a Mac on a particular one of its USB ports - the numeric part varies according to which Mac USB port the Arduino is connected to each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos &amp;amp; FTDI devices do not need additional drivers on Mac OS (that may not be true for other, non-FTDI USB-to-serial devices).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, the OS already reports seeing (what looks like) an Arduino. The suggestion already put forward, checking the board-type and port selections in the IDE's 'Tools' menu, is the place to start.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-10T13:57:25.877" LastActivityDate="2016-03-10T13:57:25.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21656" PostTypeId="2" ParentId="21649" CreationDate="2016-03-10T14:02:51.810" Score="2" Body="&lt;p&gt;Personally I don't think Nick advised to do command line pattern parsing with a state machine. His example is about changing a state machine based on command line input.&lt;br&gt;&#xA;I have written some command line parsers and I never used a state machine to do so. I would not advice to use a state machine to do so.&lt;br&gt;&#xA;Simple string parsing is far easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit To answer the remark below:&lt;/strong&gt;&lt;br&gt;&#xA;I would not advice to go byte by byte. I'd advice to go the line by line way.&#xA;I have written a library to do read line by line and an article on how that one works. &lt;a href=&quot;http://blog.baeyens.it/#post16&quot; rel=&quot;nofollow&quot;&gt;http://blog.baeyens.it/#post16&lt;/a&gt;&lt;br&gt;&#xA;Here a link to the lib &lt;a href=&quot;https://github.com/jantje/libraries/tree/master/SerialCommunicator&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jantje/libraries/tree/master/SerialCommunicator&lt;/a&gt;.&lt;br&gt;&#xA;Here is a parcing code example. It is not so interesting for you as I have it done in a stage by stage way in a very high level way of coding.&#xA;&lt;a href=&quot;https://github.com/jantje/libraries/blob/master/SerialBridgeCommunicator/SerialBridgeCommunicator.cpp#L21&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jantje/libraries/blob/master/SerialBridgeCommunicator/SerialBridgeCommunicator.cpp#L21&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the algorithm is=&lt;br&gt;&#xA;1 Take the first word;&lt;br&gt;&#xA;2 identify the word.&lt;br&gt;&#xA;3 If the command is complete -&gt;do it&lt;br&gt;&#xA; else Send the rest of the string to a specialized piece of code. (which has the same algorithm)   &lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-03-10T16:48:27.720" LastActivityDate="2016-03-10T16:48:27.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21657" PostTypeId="2" ParentId="21649" CreationDate="2016-03-10T14:09:50.550" Score="2" Body="&lt;p&gt;Suggestion: - don't try to &quot;moosh&quot; (that's a technical-term!) the state-machine heirarchy down into one large, flat state-machine. That way lies madness. Keep your { NULL, COMMAND, PARAMETER, OPTIONS } state machine, for instance, and, wherever you need something more than simple string collection in one of those states, call a parser SM appropriate to the kind(s) of input you expect at that point - a number, a quoted string, an option specifier, etc.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-10T14:09:50.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21658" PostTypeId="2" ParentId="17237" CreationDate="2016-03-10T14:28:37.853" Score="3" Body="&lt;p&gt;This is how it looks when they fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DHTxx are very low cost sensors, optimised for cheap volume production. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We don't know under what condition you actually use your sensors. Also, there's the phenomenon of knock-offs and low-grade selling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In his comprehensive test, Robert J. Smith found a failure rate of 33% and concludes a mean life expectancy of one to two years.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A slightly more expensive alternative is the SHT series of temperature and humidity sensors. My personal experience is that they tend to tolerate some abuse (i.e. complete submersion in water) and don't age as quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;failure analysis: &lt;a href=&quot;http://www.kandrsmith.org/RJS/Misc/Hygrometers/dht22_first_failure.html&quot; rel=&quot;nofollow&quot;&gt;http://www.kandrsmith.org/RJS/Misc/Hygrometers/dht22_first_failure.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;general writeup: &lt;a href=&quot;http://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_dht22_dht11_sht71.html#conclusions&quot; rel=&quot;nofollow&quot;&gt;http://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_dht22_dht11_sht71.html#conclusions&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-10T14:42:15.670" LastActivityDate="2016-03-10T14:42:15.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21660" PostTypeId="2" ParentId="17237" CreationDate="2016-03-10T16:11:55.703" Score="2" Body="&lt;p&gt;I have had the exact same experience using a DHT11 with Huzzah. I found that the problem tends to happen after high humidity conditions (&gt;85% relative), my solution was to place silicone caulk and heatshrink tubing around the connections to prevent dew buildup. That solved my problem with my third replacement. It has been two months now with no issues. &lt;/p&gt;&#xA;" OwnerUserId="3022" LastActivityDate="2016-03-10T16:11:55.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21661" PostTypeId="2" ParentId="21446" CreationDate="2016-03-10T16:29:33.780" Score="0" Body="&lt;p&gt;IMHO the delays are negligible if you are detecting times in the range of milliseconds. Just give us some more info (e.g. what is the maximum error you can tolerate).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case you can implement a round-trip-time estimator. For instance&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RX sends a packet (or even just a single byte) to one TX to set it in &quot;RTT measuring mode&quot;.&lt;/li&gt;&#xA;&lt;li&gt;TX reads the packet and sends an ack. This is required for avoiding errors when the TX is busy doing something else.&lt;/li&gt;&#xA;&lt;li&gt;When the ACK is received, the RX sends a message and starts measuring the time.&lt;/li&gt;&#xA;&lt;li&gt;When TX receives the message, immediately sends back a reply&lt;/li&gt;&#xA;&lt;li&gt;When RX receives the reply, stops the timer. The communication delay is half the time measured&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Just repeat this procedure for both TX1 and TX2; this way you will have an estimate on how long it takes to receive a message from each of them. Then, when you receive a packet, you know how much time passed since it was transmitted (and so you can synchronize them)&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-10T16:29:33.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21662" PostTypeId="1" CreationDate="2016-03-10T17:12:12.407" Score="3" ViewCount="1723" Body="&lt;p&gt;I am trying to save some data to the SD card using the memory shield module that I read from HC-SR04 Ultrasonic Module. The data that gets printed indicates error. This is how my SD card module is connected.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SD card attached to SPI bus as&lt;br&gt;&#xA;  VCC -Arduino 5v&lt;br&gt;&#xA;  GND- Arduino GND&lt;br&gt;&#xA;  MOSI - pin 11&lt;br&gt;&#xA;  MISO - pin 12&lt;br&gt;&#xA;  CLK - pin 13&lt;br&gt;&#xA;  CS - pin 4&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Still, Arduino complains that there was an error opening the file in SD card. My sketch is this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#define echoPin 6 // Echo Pin&#xA;#define trigPin 7 // Trigger Pin&#xA;&#xA;int maximumRange = 250; // Maximum range needed&#xA;int minimumRange = 1; // Minimum range needed&#xA;long duration, distance; // Duration used to calculate distance&#xA;const int chipSelect = 4;&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;  // see if the card is present and can be initialized:&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&quot;Card failed, or not present&quot;);&#xA;    // don't do anything more:&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;card initialized.&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  readDistance();&#xA;  if(distance&amp;gt;minimumRange &amp;amp;&amp;amp; distance &amp;lt; maximumRange){&#xA;    String string = &quot;distance is&quot; + distance;&#xA;    // open the file. note that only one file can be open at a time,&#xA;    // so you have to close this one before opening another.&#xA;    File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&#xA;    // if the file is available, write to it:&#xA;    if( dataFile ){&#xA;      dataFile.println(string);&#xA;      dataFile.close();&#xA;      Serial.println( string );&#xA;    }else{&#xA;      // if the file isn't open, pop up an error:&#xA;      Serial.println(&quot;error opening datalog.txt&quot;);&#xA;      dataFile.close();&#xA;    }&#xA;  }else{&#xA;    Serial.println(&quot;Out of range...&quot;);&#xA;  }&#xA;  delay(50);&#xA;}&#xA;&#xA;int readDistance(){&#xA;  digitalWrite(trigPin, LOW); &#xA;  delayMicroseconds(2); &#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10); &#xA;  digitalWrite(trigPin, LOW);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;  distance = duration/58.2;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rror opening datalog.txt&#xA;rror opening datalog.txt&#xA;error opening datalog.txt&#xA;rror opening datalog.txt&#xA;error opening datalog.txt&#xA;error opening datalog.txt&#xA;error opening datalog.txt&#xA;error opening datalog.txt&#xA;error opening datalog.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I solve this to save the readings to SD card?&lt;/p&gt;&#xA;" OwnerUserId="19140" OwnerDisplayName="Winne Nair" LastEditorUserId="19140" LastEditDate="2016-03-10T17:21:04.927" LastActivityDate="2021-07-07T09:35:55.473" Title="How to save data to SD card using Memory Shield Module SPI" Tags="|arduino-uno|sensors|arduino-ide|shields|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21664" PostTypeId="1" AcceptedAnswerId="21669" CreationDate="2016-03-10T18:03:14.833" Score="0" ViewCount="82" Body="&lt;p&gt;just a question that requires a simple answer. How do I process a large number of arithmetic steps in arduino efficiently and precisely? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I have this code function setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void calc() {&#xA;  batterymoment = input*batterymass;&#xA;  totalmoment = 149650+batterymoment;&#xA;  buoyancymoment = buoyancymass*centrebuoyancy;&#xA;  wheelmoment = totalmoment - buoyancymoment;&#xA;  wheelweight = totalmass - buoyancymass;&#xA;  cgwheels = wheelmoment/wheelweight;&#xA;  maindistance = mainarm - wheelweight;&#xA;  nosedistance = wheelweight - nosearm;&#xA;  mainmass = (((wheelweight)*(1-((maindistance)/(maindistance+nosedistance))))/2);&#xA;  nosemass = (((wheelweight)*(1-((nosedistance)/(nosedistance+maindistance))))/2);&#xA;  mainmoment = mainmass*mainarm;&#xA;  nosemoment = nosemass*nosearm;&#xA;  netmoment = buoyancymoment+mainmoment+nosemoment;&#xA;  netcg = netmoment/totalmass;&#xA;  staticmargin = adc - netcg;&#xA;  answer = staticmargin/meanadc;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I've properly setup up data types for all of these variables and they are a combination of float, int and long. I don't think it's a problem with the data type. What I'm getting when I print final answer in the serial is the same number regardless the input the user enters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing I need to format the code in such a way that it performs each line step by step and verifies the answer before proceeding to the next arithmetic line. If so would I need a function for each arithmetic step? Or is there a simpler way to process this that I'm missing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance is appreciated. Thanks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code in its entirety:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long batterymoment,num1,num2,input,totalmoment;&#xA;double buoyancymoment,wheelmoment,cgwheels,mainmass,nosemass,maindistance,nosedistance;&#xA;double mainmoment,nosemoment,netmoment,netcg,staticmargin,answer;&#xA;double centrebuoyancy = 14.164;&#xA;double mainarm = 14.3;&#xA;double adc = 11.4;&#xA;double meanadc = 22.65;&#xA;double nosearm = 1.8;&#xA;int totalmass = 12404;&#xA;int batterymass = 720;&#xA;int buoyancymass = 4401;&#xA;int batteryposition,wheelweight;&#xA;boolean mySwitch = false;&#xA;&#xA;void calc() {&#xA;  batterymoment = input*batterymass;&#xA;  totalmoment = 149650+batterymoment;&#xA;  buoyancymoment = buoyancymass*centrebuoyancy;&#xA;  wheelmoment = totalmoment - buoyancymoment;&#xA;  wheelweight = totalmass - buoyancymass;&#xA;  cgwheels = wheelmoment/wheelweight;&#xA;  maindistance = mainarm - wheelweight;&#xA;  nosedistance = wheelweight - nosearm;&#xA;  mainmass = (((wheelweight)*(1-((maindistance)/(maindistance+nosedistance))))/2);&#xA;  nosemass = (((wheelweight)*(1-((nosedistance)/(nosedistance+maindistance))))/2);&#xA;  mainmoment = mainmass*mainarm;&#xA;  nosemoment = nosemass*nosearm;&#xA;  netmoment = buoyancymoment+mainmoment+nosemoment;&#xA;  netcg = netmoment/totalmass;&#xA;  staticmargin = adc - netcg;&#xA;  answer = staticmargin/meanadc;  &#xA; }&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  num1=0;&#xA;  num2=0;&#xA;  Serial.println(&quot;Enter battery position&quot;);&#xA; }&#xA;&#xA;void loop() {&#xA;  while (Serial.available()){&#xA;    batteryposition = Serial.read();&#xA;    if(batteryposition&amp;gt;47 &amp;amp;&amp;amp; batteryposition&amp;lt;58){  &#xA;      if(!mySwitch){&#xA;         num1=(num1*10)+(batteryposition-48);&#xA;      }else{&#xA;         num2=(num2*10)+(batteryposition-48);&#xA;        }&#xA;       }&#xA;&#xA;if(batteryposition==61){&#xA;  input=num1+num2;&#xA;  calc();&#xA;  Serial.print(&quot;Static margin is: &quot;);&#xA;  Serial.println(answer);&#xA;  num1=0;&#xA;  num1=0;&#xA;  mySwitch=false;&#xA;  }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So depending on the user input, the calculations will change the final output answer. For example if a 5 should be entered the output should be -4.22 based on my calculations in excel. &lt;/p&gt;&#xA;" OwnerUserId="19111" LastEditorUserId="19111" LastEditDate="2016-03-10T18:29:11.813" LastActivityDate="2016-03-10T20:39:04.870" Title="How to properly process large arithmetic" Tags="|arduino-uno|serial|data-type|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21667" PostTypeId="2" ParentId="21664" CreationDate="2016-03-10T18:54:02.420" Score="0" Body="&lt;p&gt;Per your comments, the calc() function is not acting as expected.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change calc() to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void calc() {&#xA;  Serial.print(&quot;input:&quot;);Serial.println(input);&#xA;  batterymoment = input*batterymass;&#xA;  totalmoment = 149650+batterymoment;&#xA;  buoyancymoment = buoyancymass*centrebuoyancy;&#xA;  wheelmoment = totalmoment - buoyancymoment;&#xA;  wheelweight = totalmass - buoyancymass;&#xA;  cgwheels = wheelmoment/wheelweight;&#xA;  maindistance = mainarm - wheelweight;&#xA;  nosedistance = wheelweight - nosearm;&#xA;  mainmass = (((wheelweight)*(1-((maindistance)/(maindistance+nosedistance))))/2);&#xA;  nosemass = (((wheelweight)*(1-((nosedistance)/(nosedistance+maindistance))))/2);&#xA;  mainmoment = mainmass*mainarm;&#xA;  nosemoment = nosemass*nosearm;&#xA;  netmoment = buoyancymoment+mainmoment+nosemoment;&#xA;  netcg = netmoment/totalmass;&#xA;  staticmargin = adc - netcg;&#xA;  answer = staticmargin/meanadc;&#xA;  Serial.print(&quot;answer:&quot;);Serial.println(answer);  &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and see if it gets the expected inputs and works as expected.  Then add debugging statements in-process until you discover the mismatch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd turn in into more of a function, or a series of better defined functions, and then test them individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your code is there is interaction between global variables, serial parsing, and calculations.  If you break it into distinct pieces, you can isolate where the problem is.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="6628" LastEditDate="2016-03-10T20:17:55.973" LastActivityDate="2016-03-10T20:17:55.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21668" PostTypeId="2" ParentId="21034" CreationDate="2016-03-10T20:20:54.307" Score="1" Body="&lt;p&gt;This is certainly possible as I have now confirmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code below will detect the length of a string of NeoPixels up to 10000 long. &lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * &#xA; * Find length of NeoPixel string.&#xA; * Author: Nick Gammon&#xA; * Date:   11 March 2016&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const unsigned long LIMIT = 10000;  // maximum pixels to test&#xA;&#xA;// Note: Connect NeoPixels to MOSI (pin D11 on a Uno, pin D51 on a Mega)&#xA;//       Connect the other end of the NeoPixels to D2 (External Interrupt 0)&#xA;&#xA;void sendByte (byte b)&#xA;  {&#xA;    // send one byte to the Neopixels - note that the &quot;off&quot; gap is partly handled by the loop overhead&#xA;    //   gaps measured empirically to be 1.7 µs to 2 µs, so we don't need to add any more of our own&#xA;    for (byte bit = 0; bit &amp;lt; 8; bit++)  &#xA;      {&#xA;      if (b &amp;amp; 0x80) // is high-order bit set?&#xA;        SPI.transfer (0b11111100);  // 1 bit - 750 ns on + 250 ns off (acceptable &quot;on&quot; range 550 ns to 850 ns)&#xA;      else&#xA;        SPI.transfer (0b11100000);  // 0 bit - 375 ns on + 625 ns off (acceptable &quot;on&quot; range 200 ns to 500 ns)&#xA;      b &amp;lt;&amp;lt;= 1; // shift next bit into high-order position&#xA;    } // end of for each bit&#xA;} // end of sendByte&#xA;&#xA;void ledsetup() &#xA;{&#xA;  SPI.begin ();&#xA;  SPI.setClockDivider (SPI_CLOCK_DIV2);&#xA;  SPI.setBitOrder (MSBFIRST);&#xA;  SPI.setDataMode (SPI_MODE1);   // MOSI normally low.&#xA;} // end of ledsetup&#xA;&#xA;void sendPixel (const byte r, const byte g, const byte b) &#xA;  {&#xA;  sendByte (g);       &#xA;  sendByte (r);&#xA;  sendByte (b);&#xA;  } // end of sendPixel&#xA;&#xA;void show() &#xA;  {&#xA;  delayMicroseconds (7);&#xA;  } // end of show&#xA;&#xA;volatile bool triggered;&#xA;&#xA;void myISR ()&#xA;  {&#xA;  triggered = true;&#xA;  } // end of myISR&#xA;&#xA;void setup() &#xA;  {&#xA;  ledsetup();&#xA;  Serial.begin (115200);&#xA;  Serial.println (F(&quot;Starting ...&quot;));&#xA;  attachInterrupt (0, myISR, RISING);&#xA;  } // end of setup&#xA;&#xA;unsigned int increment = 1000;&#xA;unsigned int counter = increment;&#xA;&#xA;void loop() &#xA;  {&#xA;  noInterrupts ();&#xA;  triggered = false;&#xA;  EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;&#xA;  for (unsigned int i = 0; i &amp;lt; counter; i++)&#xA;    sendPixel (5, 0, 0);&#xA;  TIMSK0 = bit (TOIE0);  // throw away timer overflow interrupt&#xA;  interrupts ();&#xA;  show ();  // latch the colours - handle the interrupt meantime&#xA;&#xA;  if (triggered)&#xA;    {&#xA;    if (increment &amp;lt;= 1)&#xA;      {&#xA;      Serial.print (F(&quot;There are &quot;));&#xA;      Serial.print (counter - 1);&#xA;      Serial.println (F(&quot; NeoPixels in the string.&quot;));&#xA;      Serial.flush ();&#xA;      exit (0);&#xA;      }&#xA;    else&#xA;      {  // binary search&#xA;      counter -= increment;&#xA;      increment /= 2;&#xA;      } // end of if &#xA;    } // end of if triggered&#xA;&#xA;  counter += increment;&#xA;&#xA;  if (counter &amp;gt; LIMIT)&#xA;    {&#xA;    Serial.print (F(&quot;Could not find any NeoPixels after trying &quot;));&#xA;    Serial.print (LIMIT);&#xA;    Serial.println (F(&quot; pixels.&quot;));&#xA;    Serial.flush ();&#xA;    exit (0);&#xA;    }&#xA;&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works by sending out increasingly long strings of 24 bits, and waiting for one to &quot;shuffle off&quot; the other end of the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the Data In of the NeoPixels to MOSI (pin D11 on a Uno, pin D51 on a Mega) as this sketch uses SPI to generate the timed sequences. Connect the far end of the NeoPixels (Data Out) to pin D2 which is External Interrupt 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch pumps out batches of pixels, and waits for an external interrupt. When that occurs it indicates that the last pixel in the chain was reached, and passed the pixel data out Data Out to the non-existent pixel past the end of the chain. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of pixels needed to do this is then noted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch does a &quot;binary search&quot; to speed things up for long strings of pixels. The worst-case scenario (where you have either 10000 pixels, or none at all) takes 6 seconds to execute. With less pixels it will be faster. I had under a second execution time for 3 pixels in my test string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch outputs a dull red (intensity 5) so you should see the pixels light up in red if all is well. If you wanted to do it unobtrusively, you could output black (as that still results in bits being sent down the string).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Starting ...&#xA;There are 3 NeoPixels in the string.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-11T01:09:13.407" LastActivityDate="2016-03-11T01:09:13.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21669" PostTypeId="2" ParentId="21664" CreationDate="2016-03-10T20:39:04.870" Score="3" Body="&lt;p&gt;You're getting the same value every time because that is the value that is being calculated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you have something wrong with how you have implemented your formula.  If you start from &quot;answer = &quot; and repeatedly substitute the variables with the formulae or values that make up those variables you end up with this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;answer = (11.4 - (((4401 * 14.164) + ((((12404 - 4401)*(1-((14.3 - (12404 - 4401))/((14.3 - (12404 - 4401))+(12404 - 4401 - 1.8)))))/2) * 14.3) + ((((12404 - 4401)*(1-((12404 - 4401 - 1.8)/((12404 - 4401 - 1.8)+(14.3 - (12404 - 4401))))))/2) * 1.8)) / 12404)) / 22.65&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's nothing variable about that at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your input value is being used to calculate &lt;code&gt;batterymoment&lt;/code&gt;. &lt;code&gt;batterymoment&lt;/code&gt; us being used to calculate &lt;code&gt;totalmoment&lt;/code&gt;. &lt;code&gt;totalmoment&lt;/code&gt; is being used to calculate &lt;code&gt;wheelmoment&lt;/code&gt;. &lt;code&gt;wheelmoment&lt;/code&gt; is being used to calculate &lt;code&gt;cgwheels&lt;/code&gt;. &lt;strong&gt;&lt;code&gt;cgwheels&lt;/code&gt; is never used for anything&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-10T20:39:04.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21670" PostTypeId="1" AcceptedAnswerId="21671" CreationDate="2016-03-10T20:45:29.683" Score="2" ViewCount="844" Body="&lt;p&gt;It looks like the 5 volt version used the 16MHz external crystal while the 3.3V one uses the 8MHz crystal. I need to use 3.3v as my operating voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I just remove the linear regulator and bring in 3.3V. I still have to select the 5V 16MHz version in the Arduino IDE, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino-Pro-Mini-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/uploads/Main/Arduino-Pro-Mini-schematic.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13520" LastActivityDate="2016-03-10T20:52:56.390" Title="Why does the Pro Mini 5 v and 3.3 v version have different clock frequencies?" Tags="|arduino-pro-mini|oscillator-clock|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21671" PostTypeId="2" ParentId="21670" CreationDate="2016-03-10T20:52:56.390" Score="2" Body="&lt;p&gt;The ATMega328p is not rated to operate at 16 MHz on a 3.3v supply.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practice it may sometimes work, but cannot be considered reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The data sheet will show the actual clock rate vs. voltage tradeoffs, so there might be an intermediate value that is workable for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino toolchain needs to know the CPU clock frequency for the serial baud rates, timing delay code, and any time-based use of the timer peripherals to come out right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a special case where if the configured clock rate and the actual clock rate differ by a factor of two, you may be able to cover that by selecting a similarly wrong baud rate - however, the baud rate in the bootloader was set in comparison to the &lt;em&gt;expected&lt;/em&gt; clock frequency when it was compiled before flashing, and the baud rate &lt;em&gt;expected&lt;/em&gt; of the bootloader is set in the boards file, so less readily changed than it is in something like the serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-03-10T20:52:56.390" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21672" PostTypeId="2" ParentId="21489" CreationDate="2016-03-10T20:57:07.650" Score="0" Body="&lt;pre&gt;&lt;code&gt;// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE. &#xA;// Timer 2 makes sure that we take a reading every 2 miliseconds&#xA;ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124&#xA;  cli();                                      // disable interrupts while we do this&#xA;  Signal = analogRead(pulsePin);              // read the Pulse Sensor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Interrupts are automatically disabled in an ISR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't do lengthy things in an ISR (like analogRead). That takes 104 µs when an ISR should take only a few µs.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-10T20:57:07.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21673" PostTypeId="1" CreationDate="2016-03-10T21:16:27.287" Score="3" ViewCount="743" Body="&lt;p&gt;I have a PIR sensor attached to a Amica nodeMCU board routing 5v from VIN and attached via USB port for testing. When motion is deteted it connects to the internet and sends data to IFTTT which i receive a notification on my phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I power up, the PIR pauses for calibration and then immediately goes HIGH and fires the motion detected call which i receive on my phone. However From then on it never goes LOW but every 5-8 minutes sends another HIGH call through even if there is no motion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Tried using separate 5v supply to PIR same thing happens&lt;/li&gt;&#xA;&lt;li&gt;I have tried both retrigger modes (H &amp;amp; L) and experienced the same result&lt;/li&gt;&#xA;&lt;li&gt;The same happens with the Adafruit featherwing huzzah board.&lt;/li&gt;&#xA;&lt;li&gt;I have tested the PIR without a micro-controller and can confirm that it &lt;strong&gt;functions correctly&lt;/strong&gt; &lt;em&gt;-lighting an led&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;I have tested with an Arduino Nano with the same code and it &lt;strong&gt;functions correctly&lt;/strong&gt; &lt;em&gt;- lighting an led&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Code&lt;/strong&gt; modified version of &lt;a href=&quot;http://playground.arduino.cc/Code/PIRsense&quot; rel=&quot;nofollow&quot;&gt;Arduino Playground PIR Project&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Sends IFTTT every 5 minutes it detects motion&#xA;&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;//WiFi Settings&#xA;&#xA;// Set up macros for wifi and connection.&#xA;#define SSID &quot;my-network&quot;    // SSID&#xA;#define PASS &quot;mypassphrase&quot;      // Network Password&#xA;#define HOST &quot;maker.ifttt.com&quot;  // Webhost&#xA;//-------------------------------&#xA;const char* streamId   = &quot;test&quot;;&#xA;const char* privateKey = &quot;mysecretkey&quot;;&#xA;&#xA;//PIR Settings&#xA;//the time we give the sensor to calibrate (10-60 secs according to the datasheet)&#xA;int calibrationTime = 10;        &#xA;&#xA;//the time when the sensor outputs a low impulse&#xA;long unsigned int lowIn;         &#xA;&#xA;//the amount of milliseconds the sensor has to be low &#xA;//before we assume all motion has stopped&#xA;long unsigned int pause = 5000;  &#xA;&#xA;&#xA;int  interval = 1000; // Wait between dumps&#xA;boolean lockLow = true;&#xA;boolean takeLowTime;  &#xA;int ledPin = 1;&#xA;int pirPin = 2;    //the digital pin connected to the PIR sensor's output&#xA;int nPIR_detect;&#xA;int motion = 2;&#xA;&#xA;int minSecsBetweenUpdates = 300; // 5 minutes&#xA;long lastSend = -minSecsBetweenUpdates * 1000l;&#xA;//-------------------------------&#xA;&#xA;// Begin Setup&#xA;void setup(){&#xA;  Serial.begin(115200);&#xA;  pinMode(pirPin, INPUT);&#xA;  digitalWrite(pirPin, LOW);&#xA;&#xA;  //give the sensor some time to calibrate&#xA;  Serial.print(&quot;calibrating sensor &quot;);&#xA;  for(int i = 0; i &amp;lt; calibrationTime; i++){&#xA;    Serial.print(&quot;.&quot;);&#xA;    delay(1000);&#xA;    }&#xA;  Serial.println(&quot; done&quot;);&#xA;  Serial.println(&quot;SENSOR ACTIVE&quot;);&#xA;  delay(50);&#xA;   nPIR_detect = 0;  &#xA;&#xA;  // Test ESP8266 module.&#xA;  Serial.println(&quot;AT&quot;);&#xA;  delay(5000);&#xA;  if(Serial.find(&quot;OK&quot;)){&#xA;    connectWiFi();&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA; if(digitalRead(pirPin) == HIGH){&#xA;       digitalWrite(BUILTIN_LED, HIGH);   //the led visualizes the sensors output pin state&#xA;       if(lockLow){  &#xA;         //makes sure we wait for a transition to LOW before any further output is made:&#xA;         lockLow = false;            &#xA;         Serial.println(&quot;---&quot;);&#xA;         Serial.print(&quot;motion detected at &quot;);&#xA;         Serial.print(millis()/1000);&#xA;         Serial.println(&quot; sec&quot;); &#xA;         sendData(String(motion));&#xA;         delay(50);&#xA;         }         &#xA;         takeLowTime = true;&#xA;       }&#xA;&#xA;     if(digitalRead(pirPin) == LOW){       &#xA;       digitalWrite(BUILTIN_LED, LOW);  //the led visualizes the sensors output pin state&#xA;&#xA;       if(takeLowTime){&#xA;        lowIn = millis();          //save the time of the transition from high to LOW&#xA;        takeLowTime = false;       //make sure this is only done at the start of a LOW phase&#xA;        }&#xA;       //if the sensor is low for more than the given pause, &#xA;       //we assume that no more motion is going to happen&#xA;       if(!lockLow &amp;amp;&amp;amp; millis() - lowIn &amp;gt; pause){  &#xA;           //makes sure this block of code is only executed again after &#xA;           //a new motion sequence has been detected&#xA;           lockLow = true;                        &#xA;           Serial.print(&quot;motion ended at &quot;);      //output&#xA;           Serial.print((millis() - pause)/1000);&#xA;           Serial.println(&quot; sec&quot;);&#xA;           delay(50);&#xA;           }&#xA;       }&#xA;}&#xA;&#xA;void sendData(String motion){&#xA;&#xA;  //Send the motion to IFTTT value1&#xA;  Serial.print(&quot;connecting to &quot;);&#xA;  Serial.println(HOST);&#xA;&#xA;  // Use WiFiClient class to create TCP connections&#xA;  WiFiClient client;&#xA;  const int httpPort = 80;&#xA;  if (!client.connect(HOST, httpPort)) {&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // We now create a URI for the request&#xA;  String url = &quot;/trigger/&quot;;&#xA;  url += streamId;&#xA;  url += &quot;/with/key/&quot;;&#xA;  url += privateKey;&#xA;  url += &quot;?value1=&quot;;&#xA;  url += &quot;motion&quot;;&#xA;&#xA;  Serial.print(&quot;Requesting URL: &quot;);&#xA;  Serial.println(url);&#xA;&#xA;  // This will send the request to the server&#xA;  client.print(String(&quot;GET &quot;) + url + &quot; HTTP/1.1\r\n&quot; +&#xA;               &quot;Host: &quot; + HOST + &quot;\r\n&quot; + &#xA;               &quot;Connection: close\r\n\r\n&quot;);&#xA;  delay(10);&#xA;&#xA;  // Read all the lines of the reply from server and print them to Serial&#xA;  while(client.available()){&#xA;    String line = client.readStringUntil('\r');&#xA;    Serial.print(line);&#xA;  }&#xA;&#xA;  Serial.println();&#xA;  Serial.println(&quot;closing connection&quot;);&#xA;&#xA;}&#xA;&#xA;boolean connectWiFi(){&#xA;  Serial.println(&quot;AT+CWMODE=1&quot;);&#xA;  delay(2000);&#xA;  String cmd=&quot;AT+CWJAP=\&quot;&quot;;&#xA;  cmd+=SSID;&#xA;  cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;  cmd+=PASS;&#xA;  cmd+=&quot;\&quot;&quot;;&#xA;  Serial.println(cmd);&#xA;  delay(5000);&#xA;  if(Serial.find(&quot;OK&quot;)){&#xA;    Serial.println(&quot;Connection&quot;);&#xA;    return true;&#xA;  }&#xA;  else{&#xA;    Serial.println(&quot;No Connection&quot;);&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OQ: Why does my PIR sensor stay high with ESP8266 breakout board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;In essence, I never see the serial message &quot;motion ended at..&quot;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="19149" LastActivityDate="2017-07-23T13:01:52.390" Title="Why does my PIR sensor stay high with ESP8266 breakout board?" Tags="|esp8266|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21674" PostTypeId="1" AcceptedAnswerId="21678" CreationDate="2016-03-10T22:11:04.620" Score="1" ViewCount="2859" Body="&lt;p&gt;As a student I'm working on a project where we use 434 MHz RF Transmitter and receiver pairs for distance measurement. I know that this technology is not a good choice for this, but we have to deal with this problem due to external constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the receiver: &lt;a href=&quot;https://www.sparkfun.com/products/10532&quot; rel=&quot;nofollow&quot;&gt;RF Link Receiver - 4800bps (434MHz)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a little bit of research how these receivers works, but I found it a bit overwhelming to understand them bit by bit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want to use the signal strength for distance measurement. So we tried sending pulses of signals from one transmitter to a receiver. If the amplitude of the signal received is higher than a certain value (let's say 3V), it sends back a signal (let's call it trigger signal) in the gap between the two pulses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that that these signals seems to affect each other even though they are not in the same time (so it's not superposition that we are talking about). When there is a signal sent back, the next pulse will be lower, which results in false distance measurement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole difficulty is (to me it seems) that we are not using these signals to send data, we are using it for distance measurement. My idea is that we are using too long pulses and the AC coupling in the receiver doesn't tolerate it, but again, I don't have enough electrical knowledge to safely say that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this is not descriptive, but I don't know how to make it more descriptive, so I'm happy to answer more questions on demand. &lt;/p&gt;&#xA;" OwnerUserId="19145" LastEditorUserId="6936" LastEditDate="2016-03-30T22:16:33.900" LastActivityDate="2016-03-30T22:16:33.900" Title="434 RF Transmitter and Receiver for distance measurement problem" Tags="|arduino-uno|electronics|rf|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21675" PostTypeId="1" AcceptedAnswerId="21676" CreationDate="2016-03-10T23:05:01.220" Score="1" ViewCount="255" Body="&lt;p&gt;The model name is 5161BS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0oNbq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0oNbq.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 3/8 are input and the rest are output for each individual segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected pin 3 to the 5v pin on the Arduino, and the rest to individual digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With a simple sketch with the pins set to mode output, all segments are lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My concern is that the way I am turning off each segment is by setting the output pin to high. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meaning &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5v pin --&amp;gt; LED &amp;lt;-- Digital pin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this dangerous to have two voltage sources going in the same direction? Is there another way to do this?&lt;/p&gt;&#xA;" OwnerUserId="19150" LastEditorUserId="19150" LastEditDate="2016-03-11T18:10:40.837" LastActivityDate="2016-03-11T18:10:40.837" Title="Digit LED has single input, multiple outputs for each segment. Concerns about &quot;sinking&quot; 5v supply into digital pins" Tags="|led|arduino-nano|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21676" PostTypeId="2" ParentId="21675" CreationDate="2016-03-10T23:20:19.783" Score="1" Body="&lt;p&gt;This is called a common-anode LED. The anodes (+ side) are shared. They probably dedicate two pins (3 and 8) to share the current to the anodes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connecting the common anode to +5V is fine. However you &lt;em&gt;should have&lt;/em&gt; current-limiting resistors between each of the other pins (the cathodes) and the Arduino digital pin. Otherwise you are getting the Arduino to try to &quot;sink&quot; its own 5V supply through a digital pin, which far exceeds its rating. You will probably damage the output driver MOSFETs and they will stop working. Plus the excessive current will damage the LEDs as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;http://led.linear1.org/1led.wiz&quot; rel=&quot;nofollow&quot;&gt;LED resistor calculator&lt;/a&gt;. Something like a 330 ohm resistor, in series with &lt;em&gt;each&lt;/em&gt; of the cathodes, should be adequate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, setting the digital pins to output will &quot;sink&quot; 10 mA or thereabouts from +5V, through the LED (which lights up) and through the digital pin to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You control what &quot;number&quot; you see on the LED by turning off the appropriate pins, to make the segments light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/LEDs.html&quot; rel=&quot;nofollow&quot;&gt;The care and feeding of LEDs&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-10T23:20:19.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21677" PostTypeId="2" ParentId="21675" CreationDate="2016-03-10T23:33:24.880" Score="2" Body="&lt;p&gt;The device you have is a common anode display. This means that the anodes (+ve terminals) of all the LEDs are connected to one common pin (well, 2 pins actually, pin 3 and 8 are connected internally) . Their cathodes (-ve terminals) are what make up the remaining pins. Now, to light up any LED, you need 5 V at its anode and GND at its cathode. You have connected 5 V to pin 3, which stands for the common anode of every LED, so all that is left for any LED to turn on, is for you to connect GND to its corresponding cathode. So when you made all the remaining pins (the cathodes) OUTPUT, by default the Nano sets those pins to a logic LOW (or GND) value, so ALL the LEDs got lit up. Each LED now has &lt;code&gt;5 - 0 = 5 V&lt;/code&gt; across its terminals and is forward-biased. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when you write HIGH to any cathode, the potential difference across the associated LED/segment is now zero, because that LED has 5 V at its anode (pin 3/8) and 5 V at its cathode (as a result of writing HIGH), and &lt;code&gt;5 - 5 = 0 V&lt;/code&gt; so it is reverse-biased (at least 2 V or thereabouts is needed for a red LED to become forward-biased) and so the segment turns off. And this is how you control which segment is on at any time: You write a LOW to a cathode to turn on the associated segment, and write HIGH to turn it off. It sounds counter-intuitive but it follows if you think about it. Regarding your question, there's no damage being done to anything; the minimum voltage across the LED is 0 V (well below its maximum peak inverse voltage), while the maximum voltage across the LED is around 2 V, if you use the &lt;strong&gt;highly recommended&lt;/strong&gt; current-limiting resistors (220/330 ohms is good) in series between each cathode and its Arduino digital pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without any resistors, you will be drawing a lot of current through each pin, in total, a lot more than the Nano can safely supply. Use resistors that limit the current through each LED to 10-20mA.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-10T23:38:27.453" LastActivityDate="2016-03-10T23:38:27.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21678" PostTypeId="2" ParentId="21674" CreationDate="2016-03-11T01:56:49.857" Score="1" Body="&lt;p&gt;It is very likely you have an AGC problem. Try to slow down the measurement. The sender shall send data not often than once per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This idea is not fully perfect for doing a distance measurement. It measures incoming power strength - affected by walls, reflection, AGC of the receiver, and a lot more. If you have a scope, measure the waveform on the pin 3 of the module (linear out). It is not a constant voltage, I am afraid, so you need some sort of averaging too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A tricky way to get along even if you have an AGC is to measure how long the AGC needs to settle. The AGC works as follows: it detects the signal, and within some time (say, 2ms) it will change the amplification so that the signal will look having the full amplitude. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;compare on a two channel scope the signal pulse driving the transmitter&lt;/li&gt;&#xA;&lt;li&gt;and the signal on the pin 3 of the receiver module&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you are lucky, you'll see that actually pin3 or pin2 output is delayed a bit compared to the transmitter driving pulse. The delay depends on the power of the incoming signal to the receiver, which depends on the distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to make an acceptable distance sensor from a standard AGC enabled IR receiver using the principles above.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-11T01:56:49.857" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21679" PostTypeId="1" AcceptedAnswerId="21682" CreationDate="2016-03-11T03:40:59.703" Score="0" ViewCount="174" Body="&lt;p&gt;I have these 3 wires coming from a servo motor. They're very thin and flimsy and despise staying in a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/htu5c.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/htu5c.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to add headers to these wires to make them easier to put in a breadboard? (Like the attached image) And if so, where would one procure such a thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Uz1Hn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Uz1Hn.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-11T13:18:41.917" Title="Attach headers to servo wires?" Tags="|electronics|wires|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21681" PostTypeId="1" CreationDate="2016-03-11T03:52:28.973" Score="2" ViewCount="210" Body="&lt;p&gt;I am using an Arduino Uno board for sensing analog input. &#xA;I have connected the board only through a USB cable to my laptop, but the board does not sense analog input, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it necessary to use an external power supply ?&lt;/p&gt;&#xA;" OwnerUserId="19153" LastEditorUserId="6936" LastEditDate="2016-03-16T07:51:03.027" LastActivityDate="2016-03-16T07:51:03.027" Title="Analog sensing needs external power supply" Tags="|arduino-uno|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21682" PostTypeId="2" ParentId="21679" CreationDate="2016-03-11T06:18:36.757" Score="3" Body="&lt;p&gt;What I do in situations like that is get some of those breadboard hookup wires, like you have in your second photo, cut them in the middle (giving yourself two wires, each with a bare end, and a end with a plug on them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Strip the bare end, and then solder it to the servo motor wires. Before commencing soldering, slip some heat-shrink tubing onto the wire. Once the wires are soldered together, move the heat-shrink tubing over the join and shrink it (with a hair-dryer, or heat gun).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You now have a plug for your breadboard which is designed to be mechanically strong, and the heat-shrink tubing over the join protects it from being flexed too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could put some thicker heat-shrink over all three wires, to give additional stability.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-11T06:18:36.757" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21684" PostTypeId="1" AcceptedAnswerId="21686" CreationDate="2016-03-11T06:44:26.377" Score="0" ViewCount="3238" Body="&lt;p&gt;I just got an DS18B20 Temperature sensor and am trying to modify the example code to use a function instead. Below is my &lt;code&gt;getTemp&lt;/code&gt; function. It's working but returning results with a 0 value part of the time for example:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Temperature = 72.39&lt;br&gt;&#xA;  Temperature = 0.00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If I add &lt;code&gt;Serial.print(fahrenheit);&lt;/code&gt; within the function I am always provided with the correct temperature. I though this may have to do with needing a delay but adding &lt;code&gt;delay(5000);&lt;/code&gt; in my loop didn't help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm assuming it's something simple I'm not understanding about how &lt;code&gt;floats&lt;/code&gt; return. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;// OneWire DS18S20, DS18B20, DS1822 Temperature Example&#xA;//&#xA;// http://www.pjrc.com/teensy/td_libs_OneWire.html&#xA;//&#xA;// The DallasTemperature library can do all this work for you!&#xA;// http://milesburton.com/Dallas_Temperature_Control_Library&#xA;&#xA;OneWire  ds(2);  // on pin 10 (a 4.7K resistor is necessary)&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;float getTemp(char tScale) {&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s = 0;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius, fahrenheit;&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return false;&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;  delay(1000);     // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;&#xA;  }&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;  celsius = (float)raw / 16.0;&#xA;  fahrenheit = celsius * 1.8 + 32.0;&#xA;  if (tScale == 'C') {&#xA;    return celsius;&#xA;  }&#xA;  else if (tScale == 'F') {&#xA;    return fahrenheit;&#xA;  }&#xA;&#xA;}&#xA;void loop(void) {&#xA;    Serial.print(&quot;Temperature = &quot;);&#xA;    Serial.println( getTemp( 'F' ) );&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Interesting enough, adding an &lt;code&gt;if&lt;/code&gt; statement to the loop fixes this, however. I'd still like to understand what is going on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;  if ( getTemp( 'F' ) == 0 ){&#xA;    Serial.print( &quot;Temperature = &quot; );&#xA;    Serial.println( getTemp( 'F' ) );&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13210" LastEditorUserId="13210" LastEditDate="2016-03-11T06:52:58.637" LastActivityDate="2016-03-11T08:54:28.917" Title="DS18B20 Temperature Sensor return as float function returning null 50% of the time" Tags="|arduino-uno|temperature-sensor|float|ds18b20|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21685" PostTypeId="1" CreationDate="2016-03-11T06:56:56.960" Score="2" ViewCount="219" Body="&lt;p&gt;Is there a library or shape file available that allows an Arduino to approximate a timezone based on a latitude/longitude coordinate? There is a &lt;a href=&quot;http://efele.net/maps/tz/world/&quot; rel=&quot;nofollow&quot;&gt;timezone shape file&lt;/a&gt; available, but it's too detailed and too large. I am hoping someone knows of a simplified version small enough for an Arduino and/or a library that's able to handle this task.&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="27346" LastEditDate="2018-11-23T11:49:29.630" LastActivityDate="2018-11-23T11:49:29.630" Title="Simplified timezone shapefile suitable for Arduino?" Tags="|time|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21686" PostTypeId="2" ParentId="21684" CreationDate="2016-03-11T07:20:28.143" Score="1" Body="&lt;p&gt;You have intermittent communication problems. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your address search occasionally fails and &lt;code&gt;getTemp()&lt;/code&gt; returns false. In C++ (and many other languages) false will be implicitly cast to &lt;code&gt;(int) 0&lt;/code&gt;, &lt;code&gt;(float) 0.0f&lt;/code&gt;, and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &lt;code&gt;getTemp()&lt;/code&gt; function  also is difficult to debug because the multiple return statements have different meaning. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the &lt;code&gt;delay(250);&lt;/code&gt; you do a &lt;code&gt;return false;&lt;/code&gt; in order to skip the rest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example at &lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_OneWire.html&quot; rel=&quot;nofollow&quot;&gt;https://www.pjrc.com/teensy/td_libs_OneWire.html&lt;/a&gt; the meaning of the &lt;code&gt;return&lt;/code&gt; statement(s) is different. There the return happens within the &lt;code&gt;void loop()&lt;/code&gt; function, where it simply means to interrupt the current execution (without returning a value) and continue with the next loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it is generally okay to have multiple &lt;code&gt;return&lt;/code&gt;, it can sometimes be problematic and I recommend to avoid it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to clean this up while still preserving the ability to detect a fault, you have a couple of options (order from most to least recommended):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;do the setup/checking in a different function (and only call the second one if the first one succeeded), i.e. &lt;code&gt;if (isReady()) { Serial.println(getTemp()); }&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;set a separate error variable, i.e. &lt;code&gt;error = true; return 0;&lt;/code&gt; (and then check &lt;code&gt;error&lt;/code&gt; later)&lt;/li&gt;&#xA;&lt;li&gt;define a 'default' value that you interpret as an error (and never expect to be a temperature), i.e. &lt;code&gt;return NAN; // not a number&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-11T08:54:28.917" LastActivityDate="2016-03-11T08:54:28.917" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21687" PostTypeId="2" ParentId="169" CreationDate="2016-03-11T08:58:44.787" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://www.aliexpress.com/item/Free-shipping-NANO-3-0-controller-Terminal-Adapter-for-NANO-terminal-expansion-board-for-arduino-Nano/1921109123.html&quot; rel=&quot;nofollow&quot;&gt;Here's what I use&lt;/a&gt;, repeatedly, successfully. It fits the Nano headers, and gives you screw terminals for proto work.&lt;/p&gt;&#xA;" OwnerUserId="19161" LastActivityDate="2016-03-11T08:58:44.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21688" PostTypeId="1" AcceptedAnswerId="21800" CreationDate="2016-03-11T13:04:49.693" Score="1" ViewCount="11127" Body="&lt;p&gt;I'm trying to send a JSON POST in SIM900 shield with AT commands. After I call the  &lt;strong&gt;AT+HTTPACTION=1&lt;/strong&gt; command, it returns a 601 error: &lt;strong&gt;+HTTPACTION:1,601,0&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw here that the error was 601 Network Error. Could someone help me? Following is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void connectInternet() {&#xA;  if(digitalRead(9 != LOW)) {&#xA;    Serial.print(&quot;\r\n&quot;);&#xA;    Serial.print(&quot;------------------------------------------------- \r\n&quot;);&#xA;    Serial.print(&quot; CONNECT ON INTERNET \r\n&quot;);&#xA;    Serial.print(&quot;------------------------------------------------- \r\n&quot;);&#xA;    Serial.print(&quot;\r\n&quot;);&#xA;    Serial.println(&quot;Connecting...\r&quot;);&#xA;    cmdAT(&quot;AT&quot;);&#xA;    cmdAT(&quot;AT+CIPSHUT&quot;);&#xA;    cmdAT(&quot;AT+CIPMUX=1&quot;);&#xA;    cmdAT(&quot;AT+CSTT=\&quot;zap.vivo.com.br\&quot;,\&quot;vivo\&quot;,\&quot;vivo\&quot;&quot;);&#xA;    cmdAT(&quot;AT+CIICR&quot;);&#xA;    cmdAT(&quot;AT+CDNSCFG=\&quot;8.8.8.8\&quot;,\&quot;8.8.4.4\&quot;&quot;);&#xA;    Serial.print(&quot;IP Device: &quot;);&#xA;    cmdAT(&quot;AT+CIFSR&quot;);&#xA;  }&#xA;}&#xA;&#xA;void send2Api() {&#xA;  Serial.print(&quot;\r\n&quot;);&#xA;  Serial.print(&quot;------------------------------------------------- \r\n&quot;);&#xA;  Serial.print(&quot; SEND TO API\r\n&quot;);&#xA;  Serial.print(&quot;------------------------------------------------- \r\n&quot;);&#xA;  Serial.print(&quot;\r\n&quot;);&#xA;  cmdAT(&quot;AT+CSQ&quot;);&#xA;  cmdAT(&quot;AT+CGATT?&quot;);&#xA;  cmdAT(&quot;AT+SAPBR=2,1&quot;);&#xA;  // Query if the connection is setup properly, if we get back a IP address then we can proceed&#xA;  cmdAT(&quot;AT+HTTPPARA=\&quot;CID\&quot;,1&quot;);&#xA;  // Set the HTTP session.&#xA;  cmdAT(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;http://api.com.br/endpoint\&quot;&quot;);&#xA;  // set endPoint&#xA;  cmdAT(&quot;AT+HTTPPARA=\&quot;CONTENT\&quot;,\&quot;application/json\&quot;&quot;);&#xA;  // set content json&#xA;  cmdAT(&quot;AT+HTTPDATA=100,5000&quot;);&#xA;  // POST session start&#xA;  // JSON payload&#xA;  cmdAT(&quot;{\&quot;timestamp\&quot;:\&quot;2016-03-08T19:36:45.000Z\&quot;,\&quot;latitude\&quot;:\&quot;-24.9458581\&quot;,\&quot;longitude\&quot;:\&quot;-53.4968357\&quot;}&quot;);&#xA;  delay(100);&#xA;  cmdAT(&quot;AT+HTTPACTION=1&quot;);&#xA;  // POST session start&#xA;  cmdAT(&quot;AT+HTTPREAD&quot;);&#xA;  // Read the data of HTTP server&#xA;  cmdAT(&quot;AT+HTTPTERM&quot;);&#xA;  // terminate http&#xA;  ShowSerialData();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19165" LastEditorUserId="4628" LastEditDate="2016-03-12T08:01:23.493" LastActivityDate="2016-03-14T13:10:27.090" Title="Send JSON via POST on SIM900 shield with AT commands" Tags="|arduino-uno|serial|programming|gsm|softwareserial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21689" PostTypeId="2" ParentId="21679" CreationDate="2016-03-11T13:18:41.917" Score="0" Body="&lt;p&gt;I have bought a crimping tool. With the correct dice and crimps and crimp holders you get a professional finish.&#xA;The crimps and crimp holders themselves are cheap (buy in multiples of 100) but the crimping tool and dice are expensive.&#xA;It takes some practise before you make &quot;high quality good contacting crimp&quot; connections. You need to crimp in such a way that the strength comes from the connection between the wire insulation and the crimp and not loose electrical contact.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also it is not so easy to find the &quot;correct&quot; crimps and crimp holders.&lt;br&gt;&#xA;So this is only an option if you are willing to invest in your hobby (or you know someone who has ;-) )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is a DIY job I would go with nick solution.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-11T13:18:41.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21690" PostTypeId="1" CreationDate="2016-03-11T13:28:37.607" Score="-3" ViewCount="149" Body="&lt;p&gt;Can you help me writing a code for this question guys??&#xA;You have an Arduino Uno with 8 LEDs connected to digital pins 2 to 9.&#xA;Create an array of 8 elements. Fill it with random numbers between 2 and 9 (all inclusive)&#xA;Write a program which determines the greatest number among them. Save this number in a variable named max. Print this number on serial monitor. Blink the LED connected to this number. Let the delay time be 0.5 second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the random function may result in duplicate numbers generated. For example, the generated array may be {3,4, 4, 7,6, 2,5,7}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The maximum number will be 7.Since it occurred twice in the array, then you should blink it twice ^_^&#xA;It the maximum number occured 3 times in the array, then you should blink it 3 times, and so for any number of occurrences &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written this so far but I'm sure it's all wrong&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pins[8]={2, 3, 4, 5, 6, 7, 8,9};&#xA;&#xA;void setup() &#xA;{&#xA;   pinMode(pins[8], OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    x=random(0, 8);&#xA;    digitalWrite(pins[x], HIGH);&#xA;    delay(1000)&#xA;    digitalWrite(pins[x], LOW);&#xA;    delay(1000)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19167" LastEditorUserId="6628" LastEditDate="2016-03-11T19:58:40.613" LastActivityDate="2016-03-12T17:30:49.780" Title="How do I learn C? (was Computer project)" Tags="|programming|code-optimization|array|" AnswerCount="1" CommentCount="8" ClosedDate="2016-03-13T00:44:53.303" ContentLicense="CC BY-SA 3.0" />
  <row Id="21693" PostTypeId="2" ParentId="21517" CreationDate="2016-03-11T14:38:48.610" Score="0" Body="&lt;p&gt;Actually, I tried it again with exactly the same settings and it worked. It seems, as if Linux uses the settings of ssty, when referring to the &quot;file&quot; of a serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks anyway!&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2016-03-11T14:38:48.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21694" PostTypeId="2" ParentId="17344" CreationDate="2016-03-11T15:02:28.517" Score="2" Body="&lt;p&gt;The Particle Photon is a replacement for the Spark Core module. This module was exploiting the Texas Instrument CC3000 chip. It was this chip that handle the very simple and convenient Wi-Fi configuration of the Spark Core. Texas Instrument named this method : &lt;a href=&quot;http://www.ti.com/ww/en/simplelink_embedded_wi-fi/tools_software.html&quot; rel=&quot;nofollow&quot;&gt;SimpleLink&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Particle Photon is now using a different module than the Core : a Broadcom BCM43362 instead of the CC3000. It's seems to work in a similar manner even if I was not able to find any information on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found on the George Howkins &lt;a href=&quot;http://depletionregion.blogspot.fr/&quot; rel=&quot;nofollow&quot;&gt;Depletion Region blog&lt;/a&gt;  multiple articles that explain how the CC3000 SimpleLink works.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://depletionregion.blogspot.fr/2013/10/cc3000-smart-config-transmitting-ssid.html&quot; rel=&quot;nofollow&quot;&gt;CC3000 Smart Config - transmitting SSID and keyphrase&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://depletionregion.blogspot.fr/2013/10/cc3000-advertises-presence-on-network.html&quot; rel=&quot;nofollow&quot;&gt;CC3000 advertises presence on network via DNS-SD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All the posts : &lt;a href=&quot;http://depletionregion.blogspot.fr/search?q=smart+config&quot; rel=&quot;nofollow&quot;&gt;http://depletionregion.blogspot.fr/search?q=smart+config&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19174" LastActivityDate="2016-03-11T15:02:28.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21695" PostTypeId="2" ParentId="21690" CreationDate="2016-03-11T15:15:37.697" Score="2" Body="&lt;p&gt;First hint: pinMode() only applies to one pin at a time. You'll need to execute it 8 times to intialize 8 I/O pins' modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second hint: As @ChrisStratton tried to suggest, generate the random number set first; then &quot;figure out&quot; (set some variables in memory that will tell you) what do with the terminal output and the digital I/Os; then do each of those things. It helps to partition a larger problem into smaller ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Considering your updated title, &lt;em&gt;How do I learn C?&lt;/em&gt;, and since the question reads like a homework assignment, aren't you already taking a class in C or C++? If so, how do you find it lacking, i.e., what additional resources or direction would be most helpful to you? There are a number of good books on the C language, and one of those would be a good place to start. If you don't already have a favorite one, you can't go wrong with &lt;em&gt;The C Programming Language&lt;/em&gt;, by Brian Kernighan &amp;amp; Dennis Ritchie, the authors/designers of the C language and its early compilers. It is book on the C language, not on programming per-se, so if you are new to programming as well, a programming tutorial would be an excellent additional choice (sorry I don't have one to recommend).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, beat up on the example programs that come with the ArduinoIDE: click the &quot;Open&quot; button [uparrow icon on the IDE toolbar; not the File | Open menu] and you'll see a menu of your current sketches and, below the break, categories of example programs. Pick one of the examples, read it and try to understand what it does and why it is written the way it is. Then tweak the ###p out of it - both to understand how make it behave differently, and to &lt;strong&gt;break&lt;/strong&gt; it. You'll learn a lot by a) interpreting error messages from the compiler, and b) finding and fixing your mistakes. If you're not breaking your programs at least twice as often as you're succeeding, you're not trying hard enough!&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-12T17:30:49.780" LastActivityDate="2016-03-12T17:30:49.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21696" PostTypeId="1" CreationDate="2016-03-11T17:07:02.823" Score="1" ViewCount="1935" Body="&lt;p&gt;I am trying to read an EEPROM chip that supports the &lt;strong&gt;&lt;em&gt;I2C&lt;/em&gt;&lt;/strong&gt; protocol (cannot tell the IC model number as it is not printed). For sure it supports the I2C protocol, since I wrote a code to detect it using the I2C library and the device address I got it return is &lt;strong&gt;&lt;em&gt;0x51&lt;/em&gt;&lt;/strong&gt;. Now I am trying to write a code that reads data from this IC chip. The code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int addr = 0;&#xA;&#xA;void setup() {&#xA;    Wire.begin(); // initialise the connection&#xA;    Serial.begin(9600);&#xA;    while (!Serial) {}&#xA;    delay(100);&#xA;}&#xA;&#xA;void loop() {&#xA;  byte deviceAddress = 0x51;&#xA;  byte data = readData(addr, deviceAddress);&#xA;  Serial.print(data, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  addr++;&#xA;  if(addr%16 == 0) {&#xA;     Serial.print('\n');&#xA;  }&#xA;  // check for 1Kbits first&#xA;  if (addr%128 == 0) {&#xA;     Serial.println(&quot;round complete&quot;);&#xA;     Serial.println();&#xA;     addr = 0;&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&#xA;byte readData(int address, int deviceAddress) {&#xA;  // sending device address&#xA;  Wire.beginTransmission(deviceAddress);&#xA;  Wire.write(address);&#xA;  Wire.endTransmission();&#xA;  Wire.requestFrom((short int)deviceAddress, 1);&#xA;  if(Wire.available()) {&#xA;    byte data = Wire.read();&#xA;    return data;  &#xA;  }&#xA;  return 0xAA; // random data&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing is, I get back the address (from which I want to read the data) as the data itself (For e.g. read(0) returns 0, read(1) returns 1 and so on). I even tried to debug the I2C communication using the logic analyzer (Saleae logic in this case). A screenshot is shown below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u1W9F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u1W9F.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The screenshot shows the logic for a read operation from a single address (0x78), but the story holds for each and every address i.e. I get back the address instead of the data from the address.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output of the above code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0 1 2 3 4 5 6 7 8 9 A B C D E F &lt;br&gt;&#xA;  10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F &lt;br&gt;&#xA;  20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F &lt;br&gt;&#xA;  30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F &lt;br&gt;&#xA;  40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F &lt;br&gt;&#xA;  50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F &lt;br&gt;&#xA;  60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F &lt;br&gt;&#xA;  70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F &lt;br&gt;&#xA;  round complete&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Can you help me identifying what possibly I am doing wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="17287" LastEditorUserId="4628" LastEditDate="2017-01-06T05:22:56.767" LastActivityDate="2017-12-06T13:16:06.250" Title="Problem reading an EEPROM chip using the I2C protocol" Tags="|arduino-uno|i2c|c|eeprom|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="21698" PostTypeId="1" AcceptedAnswerId="21699" CreationDate="2016-03-11T17:20:16.870" Score="0" ViewCount="122" Body="&lt;p&gt;I am a newbie on this hardware stuff. I need help on purchasing the components&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Brief description of my project&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need a device that would remotely detect weight or pressure when somebody push on it and send the info to the webserver or websockets. The device could be located up to 300 ft.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing some research on it I learned that I need, arduino uno as the device main platform, xbee for wireless communication with the web, xbee shield for the xbee and Force sensitive resistor sensor to detect small weight or pressure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;First am I correct above mentioned components would solve what I am trying to do? If not what am I missing? Anything I mis-stated?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I have learned that there are stuff like xbee explorer, Arduino stackable headers, break-away headers, and breadboard. Do I really need these?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;In the future I want to be able do other experiments with the board like use ultrasonic sensor with it or infrared sensor to detect objects. Will I need to buy anything specific to make these sensors compatible with the board or they are all standard?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I want to buy everything I need in one shot. Thank you in advance. Any help will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19181" OwnerDisplayName="sparks" LastEditorUserId="10794" LastEditDate="2016-03-12T06:00:44.200" LastActivityDate="2016-03-12T06:00:44.200" Title="I need help purchasing components for my Arduino project" Tags="|arduino-uno|arduino-mega|xbee|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21699" PostTypeId="2" ParentId="21698" CreationDate="2016-03-11T17:49:16.803" Score="0" Body="&lt;p&gt;I would rather go with ESP8266. You can program that from the Arduino IDE. You don't need anything else than a programming cable (an USB-UART adapter), and you can connect the force sensor to the analog input with one pullup resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a similar idea with one button here:&#xA;&lt;a href=&quot;https://www.hackster.io/noelportugal/esp8266-ifttt-easy-button-888a87&quot; rel=&quot;nofollow&quot;&gt;https://www.hackster.io/noelportugal/esp8266-ifttt-easy-button-888a87&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can build your own force sensor:&#xA;&lt;a href=&quot;http://www.todayifoundout.com/index.php/2010/01/how-to-make-a-ridiculously-cheap-analog-pressure-sensor/&quot; rel=&quot;nofollow&quot;&gt;http://www.todayifoundout.com/index.php/2010/01/how-to-make-a-ridiculously-cheap-analog-pressure-sensor/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't really need to measure the force, there are much easier solutions to detect weight of a person. These give a simple contact once pressed, and can be used like a button (see the first link in my answer).&#xA;&lt;a href=&quot;http://learning.media.mit.edu/projects/gogo/documents/making%20sensors.html#Paper&quot; rel=&quot;nofollow&quot;&gt;http://learning.media.mit.edu/projects/gogo/documents/making%20sensors.html#Paper&lt;/a&gt; and Aluminum foil.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not really possible to buy everything as one batch :) I would say you need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connection wires&lt;/li&gt;&#xA;&lt;li&gt;plyers&lt;/li&gt;&#xA;&lt;li&gt;some cheap multimeter&lt;/li&gt;&#xA;&lt;li&gt;you may wish to power your device from a battery, so you may need a battery holder and batteries&lt;/li&gt;&#xA;&lt;li&gt;battery voltage may not be a perfect match for ESP8266, so you might want to get a board with internal regulator, such as &lt;a href=&quot;https://www.adafruit.com/products/2471&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2471&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;it is handy to start with a breadboard with jumper wires, something like &lt;a href=&quot;https://startingelectronics.org/beginners/start-electronics-now/tut1-breadboard-circuits/building-cct-step5.jpg&quot; rel=&quot;nofollow&quot;&gt;https://startingelectronics.org/beginners/start-electronics-now/tut1-breadboard-circuits/building-cct-step5.jpg&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I suggest you to find an ESP8266 based tutorial, Adafruit has a lot of those, and then you'll have an understanding about the tools and components needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you buy some Arduino, consider buying the ones using 32u4 chip, such as Arduino Leonardo or Arduino Micro. The 32u4 chip has more memory, and more performance than the original Arduino Uno, plus it can work as an USB mouse or an USB keyboard too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For infra (do you mean a PIR which detects humans, or a reflective sensor?) you have quite a lot of possibilities. In case of using ESP8266 directly, check that the sensors work on 3.3V. Some stuff works on 5V, others on 3.3V. You can interface them easily, but this is just another extra thing to cover, so better go with a dedicated 3.3V sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultrasonic sensors are coming also in a lot of varieties. Do you need something ridiculously cheap? A sensor with a short range? A sensor with a longer range? I think you have to set up your goal first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Leonardo and Uno and Micro boards work both with 5V and 3.3V sensors. Driving these sensors are quite standard, you need to power them with two wires, and have one wire which goes from 0V to 5V (or vice versa) when something is detected. Ultrasonic sensors vary: there are sensors with one analog output, giving a voltage between 0V and 5V propoprtional to the distance. However most of ultrasonic sensors are simple as the ultrasonic principles: they have one input what you drive, and will give one output of the recived echo signal. In this case you have to measure the time elapsed between the drive signal and the echo, which depends on the distance of the object from the sensor.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-11T17:49:16.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21700" PostTypeId="1" AcceptedAnswerId="21712" CreationDate="2016-03-11T09:33:59.903" Score="-1" ViewCount="24211" Body="&lt;p&gt;We are trying to control a robotic arm using the &lt;em&gt;Tower Pro MG 996R 180°&lt;/em&gt; high torque servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly we tried to power the servo from Arduino's default 5V, but it didn't work, then we power it from an external source, the servo ran, but only in one direction. Then it stopped rotating. We used the sweep code from the Arduino examples to test the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;  // create servo object to control a servo&#xA;// twelve servo objects can be created on most boards&#xA;&#xA;int pos = 0;    // variable to store the servo position&#xA;&#xA;void setup() {&#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object&#xA;}&#xA;&#xA;void loop() {&#xA;  for (pos = 0; pos &amp;lt;= 180; pos += 1) { // goes from 0 degrees to 180 degrees&#xA;    // in steps of 1 degree&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;  for (pos = 180; pos &amp;gt;= 0; pos -= 1) { // goes from 180 degrees to 0 degrees&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone please specify what are we doing wrong, and what is the right way to do it.&lt;/p&gt;&#xA;" OwnerUserId="19196" OwnerDisplayName="Sashanka Kumar Pramanik" LastEditorUserId="6936" LastEditDate="2016-03-30T22:22:41.010" LastActivityDate="2019-09-14T05:27:42.893" Title="Tower Pro MG996R 180° high torque servo controlling using Arduino" Tags="|servo|robotics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21701" PostTypeId="2" ParentId="21696" CreationDate="2016-03-11T18:36:30.457" Score="0" Body="&lt;p&gt;Without the specific chip info this will be difficult.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, my experience with EEPROMs and I2C is that the first action is to write a command, then write the parameter(s) for that command, then read the response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Often, there is a status register in the EEPROM that needs to be read (by writing a command, then reading the response) to determine if the EEPROM is ready to receive a different command, like writing to set the address for a read/or/write, then the actual read command.&lt;/p&gt;&#xA;" OwnerUserId="7352" LastEditorUserId="4628" LastEditDate="2017-01-06T11:23:35.703" LastActivityDate="2017-01-06T11:23:35.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21702" PostTypeId="2" ParentId="4163" CreationDate="2016-03-11T19:12:18.820" Score="1" Body="&lt;p&gt;Use a scope to check levels on the TX of the BT module. Some HC-xx modules come with 3.3V levels which can make problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest using the same speed for the serial port and for the bt dongle. You have a glitch here, which may make problems:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(BtDongle.available()) {&#xA;  unsigned char data = BtDongle.read();&#xA;  Serial.println(data, HEX);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Eventually, the Bluetooth module sends you data at a high bit rate. You get the first letter, then send it out to the PC at a lower bit rate. Sending it out to the PC takes as long time as the BT dongle sends four more characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although there are serial buffers in the Arduino, this problem will easily cause a loss of data, as @Avamander has pointed out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on your comment telling that you were able to get an endless mess from Putty, this can escalate to losing the sync on the RX from the BT module, and then further bits will start a new byte, giving you a total mess. However, OK must work, so you likely have also level problems.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="4628" LastEditDate="2017-02-05T09:33:28.147" LastActivityDate="2017-02-05T09:33:28.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21705" PostTypeId="2" ParentId="19755" CreationDate="2016-03-11T21:07:06.680" Score="0" Body="&lt;p&gt;I find the ATTiny85 working well with software serial port. Serial UART (or in fact any of the protocols like I2C or SPI) are just bit banging - and you can do that pretty well in software. Of course, having a hardware support makes things easier and faster, but there is nothing badly wrong with a software uart either. Except that you have to continuously check if there is some data arrives. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using software serial on Adafruit Trinket (ATTiny85) in various projects to talk to a Bluetooth 2.1 module, and it worked pretty well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here&#xA;&lt;a href=&quot;http://arduining.com/category/trinket-projects/&quot; rel=&quot;nofollow&quot;&gt;http://arduining.com/category/trinket-projects/&lt;/a&gt; they use the same approach to talk to an ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may wish to look for the SoftwareSerial lib for Trinket, or in certain cases you may want to go for the SendOnlySoftwareSerial lib (send only, but smaller code footprint).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a hardware based serial lib is available:&#xA;&lt;a href=&quot;https://blog.adafruit.com/2013/09/30/hardware-serial-library-for-the-trinket/&quot; rel=&quot;nofollow&quot;&gt;https://blog.adafruit.com/2013/09/30/hardware-serial-library-for-the-trinket/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-11T21:07:06.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21706" PostTypeId="1" AcceptedAnswerId="21719" CreationDate="2016-03-11T22:19:21.003" Score="2" ViewCount="1543" Body="&lt;p&gt;What is the smallest size digital 3-axis gyroscope pcb compatible with an arduino that I can buy or maybe make if its simple enough. I need one really really tiny probably around 0.8x0.1x0.5 (doesn't have to be that small but the smaller the better).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&lt;/p&gt;&#xA;" OwnerUserId="19212" OwnerDisplayName="I am Legend" LastActivityDate="2016-03-14T21:51:17.213" Title="Smallest digital 3-axis gyroscope pcb for arduino?" Tags="|gyroscope|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21707" PostTypeId="1" AcceptedAnswerId="23229" CreationDate="2016-03-11T20:07:39.390" Score="2" ViewCount="819" Body="&lt;p&gt;I am trying to code my 12 pin seven segment display to display the temperature from my grove temperature sensor. I am new to this and I have been struggling, so if anyone could help that would be much appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My temperature sensor is displaying its information in the serial monitor, however I want the temperature displayed with the 7 segment display - that's where I need help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Temperature Variables&#xA;//thermistor = value of the thermistor&#xA;int a;&#xA;float temperature;&#xA;int thermistor=3975;&#xA;float resistance;&#xA;boolean DigitOn = LOW;&#xA;boolean DigitOff = HIGH;&#xA;boolean SegOn=HIGH;&#xA;boolean SegOff=LOW;&#xA;&#xA;int DigitPins[] = {2, 3, 4, 5};&#xA;int SegmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};&#xA;&#xA;//N is for numbers and NxP is a number with a decimal point behind&#xA;int BLANK[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW};&#xA;int N0[]    = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW};&#xA;int N0P[]   = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, HIGH};&#xA;int N1[]    = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW};&#xA;int N1P[]   = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, HIGH};&#xA;int N2[]    = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, LOW};&#xA;int N2P[]   = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH};&#xA;int N3[]    = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH, LOW};&#xA;int N3P[]   = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH, HIGH};&#xA;int N4[]    = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH, LOW};&#xA;int N4P[]   = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH, HIGH};&#xA;int N5[]    = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW};&#xA;int N5P[]   = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, HIGH};&#xA;int N6[]    = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};&#xA;int N6P[]   = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};&#xA;int N7[]    = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW};&#xA;int N7P[]   = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, HIGH};&#xA;int N8[]    = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};&#xA;int N8P[]   = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};&#xA;int N9[]    = {HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, LOW};&#xA;int N9P[]   = {HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, HIGH};&#xA;int MIN[]   = {LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW};&#xA;&#xA;//Array of pointers for the 4 digits&#xA;int* lights[4];&#xA;&#xA;//char array coming from the serial interface&#xA;//4 numbers or chars, 4 optional decimal points, 1 end-of-line char&#xA;char incoming[9] = {};&#xA;&#xA;void setup() {&#xA;  Serial.begin(19200);&#xA;  for (byte digit=0;digit&amp;lt;4;digit++) {&#xA;    pinMode(DigitPins[digit], OUTPUT);&#xA;  }&#xA;&#xA;  for (byte seg=0;seg&amp;lt;8;seg++) {&#xA;    pinMode(SegmentPins[seg], OUTPUT);&#xA;  }&#xA;&#xA;  //initialize display with 1.234&#xA;  lights[0] = N7;&#xA;  lights[1] = N9P;&#xA;  lights[2] = N3;&#xA;  lights[3] = N4;&#xA;}&#xA;&#xA;void loop() {&#xA;  //Temperature Sensor&#xA;    a=analogRead(5);&#xA;    resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;&#xA;    temperature=1/(log(resistance/10000)/thermistor+1/298.15)-273.15;&#xA;//convert to temperature via datasheet&amp;amp;nbsp;;&#xA;    //delay(1000);&#xA;    Serial.print(&quot;Current temperature is &quot;);&#xA;    Serial.println(temperature);&#xA;    //delay(500);&#xA;  //read the numbers and / or chars from the serial interface&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    int i = 0;&#xA;    //clear the array of char&#xA;    memset(incoming, 0, sizeof(incoming));&#xA;    while (Serial.available() &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt; sizeof(incoming) - 1) {&#xA;      incoming[i] = Serial.read();&#xA;      i++;&#xA;      delay(3);&#xA;    }&#xA;    Serial.println(incoming);&#xA;&#xA;    //show the input values&#xA;    for (int y = 0; y &amp;lt; 4; y++) {&#xA;      Serial.print(y);&#xA;      Serial.print(&quot;: &quot;);&#xA;      for (int z = 0; z &amp;lt; 8; z++) {&#xA;        Serial.print(lights[y][z]);&#xA;      }&#xA;      Serial.println(&quot;&quot;);&#xA;    }&#xA;  }&#xA;&#xA;      //end if, i.e. reading from serial interface&#xA;      //This part of the code is from the library SevSeg by Dean Reading&#xA;&#xA;  for (byte seg=0;seg&amp;lt;8;seg++) {&#xA;        //Turn the relevant segment on&#xA;    digitalWrite(SegmentPins[seg],SegOn);&#xA;    //For each digit, turn relevant digits on&#xA;    for (byte digit=0;digit&amp;lt;4;digit++){&#xA;      if (lights[digit][seg]==1) {&#xA;        digitalWrite(DigitPins[digit],DigitOn);&#xA;      }&#xA;      //delay(200); //Uncomment this to see it in slow motion&#xA;    }&#xA;    //Turn all digits off&#xA;    for (byte digit=0;digit&amp;lt;4;digit++){&#xA;      digitalWrite(DigitPins[digit],DigitOff);&#xA;    }&#xA;    //Turn the relevant segment off&#xA;    digitalWrite(SegmentPins[seg],SegOff);&#xA;  } &#xA;    //end of for&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20333" OwnerDisplayName="K-Dawg" LastEditorUserId="6936" LastEditDate="2016-04-17T14:50:14.080" LastActivityDate="2016-04-17T14:50:14.080" Title="Problems coding a 12 pin 7 segment display and grove temperature sensor with Arduino Uno" Tags="|sensors|c++|temperature-sensor|7-segment|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21708" PostTypeId="2" ParentId="21707" CreationDate="2016-03-11T21:18:54.657" Score="0" Body="&lt;p&gt;You loop over the segments. For each segment you set the output high, then pull the digit output low for each digit that should have that segment lit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The big issue I see is that you turn the digits off immediately after turning them on. The digits are on for only a few processor cycles. If you delay for a few ms before turning all the digits off, you'll probably see them better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usual way I've seen this code written, and written it myself, is to loop over digits in the outer loop and set all the segments for one digit at once. You're setting all the digits for one segment. The way you do it, if the display is showing all 8s with decimal points, each segment will be on 1/8 of the time. If you loop over digits, each segment will be on 1/4 the time, and the display will be brighter. Looping over digits lets you illuminate up to 8 segments at once instead of 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, doing this with digitalWrite is very inefficient. If you connect the segments to digital ports 0-7 you can set them all simultaneously by writing a byte to PORTD.&lt;/p&gt;&#xA;" OwnerDisplayName="Willis Blackburn" LastActivityDate="2016-03-11T21:18:54.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21709" PostTypeId="2" ParentId="21616" CreationDate="2016-03-11T23:43:22.723" Score="7" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;noreferrer&quot;&gt;project along those lines&lt;/a&gt;. I am reading temperature, humidity, and light level and logging it, with a timestamp, to an SD card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Schematic (click for larger image):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/krOrb.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/krOrb.png&quot; alt=&quot;Temperature sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Photo:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZrGW4.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZrGW4.png&quot; alt=&quot;Temperature sensor photo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was designed with low power in mind. It runs from 3 x AA batteries which I think I have only changed once since I made it (in August 2013).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also see my &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;noreferrer&quot;&gt;page about power saving&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see any problem with running it directly from 3.7V - you would need to slow the processor down to 8 MHz (which I did anyway in that project).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code (available &lt;a href=&quot;http://gammon.com.au/Arduino/Temperature_Monitor.ino&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt;) compiles under the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-11T23:43:22.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21710" PostTypeId="2" ParentId="21706" CreationDate="2016-03-12T00:41:09.917" Score="0" Body="&lt;p&gt;Bosch CNO055 chip is an IMU-Cortex combo capable of outputting 3-D coordinates directly in several formats via several data interfaces. Adafruit has a product based on this chip, along with Arduino library (the CNO055 is in the middle to get you an idea about minimum size) -&gt; &lt;a href=&quot;https://www.adafruit.com/products/2472&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/2472&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="6667" LastActivityDate="2016-03-12T00:41:09.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21711" PostTypeId="2" ParentId="21616" CreationDate="2016-03-12T01:29:22.883" Score="4" Body="&lt;p&gt;I have to agree with @Olin Lathrop about the fact that Arduinos are not really tuned for your goals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am doing microcontroller projects for like 20 years, and I found the nanowatt PIC microcontrollers offering the best price/performance/tricks ratio if you need to have something running on batteries for a seriously long time (and has not too much to calculate). There we're talking about nanoamperes in sleep, and there are a lot more tricks you can consider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have chosen Arduino for a valid set of good reasons. But which Arduino please? They come with different CPUs and hardware!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you go with Uno:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;power your board directly by batteries, e.g. 3xAA batteries at the 5V pin to bypass power loss on the 5 V regulator (you can also give a try to feed power via the USB socket if you feel that more convenient)&lt;/li&gt;&#xA;&lt;li&gt;remove the 3.3 V regulator (assume you don't need 3.3 V)&lt;/li&gt;&#xA;&lt;li&gt;sleep a lot and sleep well, listen to @Nick Gammon and check his page about power saving&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then comes the minor tricks:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;do not let any pin float. Before going to sleep, put all inputs to output. I.e. if you have a button input, change port direction to output and set to 0. (assuming that you don't need the button in sleep)&lt;/li&gt;&#xA;&lt;li&gt;turn off not only all internal peripherals, but also external ones. For example, things like I2C temperature sensors may have remarkable 0.5 mA sleep current. The easiest thing is to power those from a port pin, and set the port to 0 before going to sleep.&lt;/li&gt;&#xA;&lt;li&gt;turn off all pullups (and all inputs to outputs), don't forget the I2C as well. Although the bus will be idle, there is a serious leakage current (serious means microamperes, and you wanna go to the nanoampere range, right?)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then if you want to go really to the hard parts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;throw away all hardware you don't need. The power checking comparators (I am referring to this schematics &lt;a href=&quot;http://brittonkerin.com/annotateduino/arduino_uno_rev3_schematic.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://brittonkerin.com/annotateduino/arduino_uno_rev3_schematic.png&lt;/a&gt;), the USB interface chip altogether &lt;/li&gt;&#xA;&lt;li&gt;throw away u1 (the 5 V regulator) - also has some leakage current &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And the final steps:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I would check the electrolytic capacitors on the power rails, e.g. C2. These also have a leakage.&lt;/li&gt;&#xA;&lt;li&gt;Although Arduino does not have suppressor diodes to protect anything from any voltage spikes, I have to emphasize that single high capacity unipolar and bipolar suppressor diodes may have a leakage current of 1 uA.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note about underclocking: this is not necessarily a wise thing to do. It is true that on slower speed the CPU consumes less. However at slower speed the CPU has to stay awake much longer to perform the same tasks. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I found that if you need to perform some complex calculations (not just reading some sensors) it may make sense to switch to a higher CPU speed, and do the calculation in less time and go back to sleep more efficient. &lt;/li&gt;&#xA;&lt;li&gt;On the other hand, if your CPU is awake just to wait for some sensor readings and just burning cycles while waiting, a slower CPU speed is more beneficial.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="26916" LastEditDate="2017-09-09T14:49:21.763" LastActivityDate="2017-09-09T14:49:21.763" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21712" PostTypeId="2" ParentId="21700" CreationDate="2016-03-12T01:34:38.987" Score="1" Body="&lt;p&gt;The Arduino's 5V is hardly enough for driving servos. I found that even a simple 9g micro servo draws well over 1A spikes, which causes the board to reset itself.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Power the servo from an external battery pack (e.g. 3xAA or 4xAA batteries will do);&lt;/li&gt;&#xA;&lt;li&gt;Ensure that the GND of the battery pack is connected to the GND of the servo &lt;em&gt;as well as&lt;/em&gt; to the GND of the Arduino;&lt;/li&gt;&#xA;&lt;li&gt;So you'll have two wires between the Arduino and the motor: GND and the driving signal.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It has to work, servos are pretty standard stuff. &lt;em&gt;However&lt;/em&gt; there are many complaints against this particular type at this link &lt;a href=&quot;http://www.hobbyking.com/hobbyking/store/__6221__Towerpro_MG996R_10kg_Servo_10kg_0_20sec_55g.html&quot; rel=&quot;nofollow&quot;&gt;Towerpro MG996R 10kg Servo 10kg / 0.20sec / 55g&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="6936" LastEditDate="2016-03-30T22:14:47.807" LastActivityDate="2016-03-30T22:14:47.807" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21713" PostTypeId="1" AcceptedAnswerId="21717" CreationDate="2016-03-12T02:43:21.163" Score="7" ViewCount="20037" Body="&lt;p&gt;There is &lt;code&gt;String.toInt()&lt;/code&gt;, but no &lt;code&gt;String.toLong()&lt;/code&gt; or the many other variations. Do I have to resort to &lt;code&gt;atol(String.c_str())&lt;/code&gt; or is there a better way to convert a &lt;code&gt;String&lt;/code&gt; to a long?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2021-04-11T10:56:37.943" Title="How to convert string to long?" Tags="|convert|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21714" PostTypeId="1" CreationDate="2016-03-12T04:47:22.993" Score="1" ViewCount="194" Body="&lt;p&gt;I'm trying to create an ISR which operates for 15 seconds when a particular button is pressed. I'm attempting to use the AVR functions on my Arduino Uno to start counting when it enters the ISR, then quit the loop when it reaches 15 seconds. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having difficulty reasoning out where the counter is actually stored that I want to use for my while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define button_pin 2&#xA;#define duration 15&#xA;#define osc_in 0&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;const float convert = 5.0/1023.0;&#xA;&#xA;void setup() {&#xA;&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;  TCNT1 = 0;&#xA;  attachInterrupt(digitalPinToInterrupt(button_pin), button_interrupt, CHANGE);&#xA;&#xA;  sei();&#xA;&#xA;  pinMode(button_pin, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    //int channel1 = analogRead(osc_in);&#xA;&#xA;//while (millis() &amp;lt; 10000)&#xA;  //Serial.println(millis());&#xA;  //Serial.println(channel1 * convert);&#xA;  //channel2 = channel1;&#xA;}&#xA;&#xA;void button_interrupt(){&#xA;  //(# timer counts + 1) = (target time) / (timer resolution)&#xA;  //int timer_counts = duration/(pow(6.4, -5));&#xA;  //int dur = 234374;&#xA;  OCR1A = 234374;&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;&#xA;  while (????????){&#xA;    int channel1 = analogRead(osc_in);&#xA;    Serial.println(channel1 * convert);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19188" LastActivityDate="2016-05-11T05:48:37.343" Title="Using AVR Timer Within an ISR" Tags="|arduino-uno|avr|isr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21716" PostTypeId="2" ParentId="21714" CreationDate="2016-03-12T04:57:54.150" Score="1" Body="&lt;p&gt;Don't do delays inside an ISR. Don't do serial prints inside an ISR. Read &lt;a href=&quot;http://www.gammon.com.au/interrupts&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to redesign. The ISR can set a flag, that you then test in &lt;code&gt;loop&lt;/code&gt;. Do the delay in &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-12T04:57:54.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21717" PostTypeId="2" ParentId="21713" CreationDate="2016-03-12T05:00:16.917" Score="8" Body="&lt;p&gt;Using &lt;code&gt;atol(String.c_str())&lt;/code&gt; looks OK to me. If there was a &lt;code&gt;String.toLong()&lt;/code&gt; it would be written that way anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, looking at the code for &lt;code&gt;String.toInt()&lt;/code&gt; that's exactly what it does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long String::toInt(void) const&#xA;{&#xA;    if (buffer) return atol(buffer);&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the answer is: use &lt;code&gt;String.toInt()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-12T05:00:16.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21718" PostTypeId="2" ParentId="21707" CreationDate="2016-03-12T05:55:34.200" Score="0" Body="&lt;p&gt;The &lt;em&gt;simple&lt;/em&gt; way is to use a MAX7219 chip which does most of the work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't said what LED device you have but an example of wiring it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/T6DXN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T6DXN.png&quot; alt=&quot;MAX7219 wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That chip does the multiplexing for you. I have a detailed description &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to use another chip you could use 12 of your Arduino pins. It's a little tedious because you need to be refreshing the display even while you are doing other things. You could use a timer interrupt for that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code you posted looks like it might work. In what way does it not work?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have been struggling ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That doesn't tell us much. Do all segments light up? None? Incorrect ones? Does it flicker? What is the problem exactly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please read &lt;a href=&quot;https://arduino.stackexchange.com/help/how-to-ask&quot;&gt;How do I ask a good question?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-12T05:55:34.200" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21719" PostTypeId="2" ParentId="21706" CreationDate="2016-03-12T07:20:48.427" Score="3" Body="&lt;p&gt;smallest board is no board.  pick a small BGA or LGA shaped accelerometer and superglue it face down to the arduino board then solder fine wires beween the chip terminals and arduino terminals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;search digikey for 'spi accelerometer'&lt;/p&gt;&#xA;" OwnerUserId="11568" LastActivityDate="2016-03-12T07:20:48.427" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21721" PostTypeId="1" AcceptedAnswerId="21780" CreationDate="2016-03-12T07:50:41.163" Score="1" ViewCount="469" Body="&lt;p&gt;I'm doing that for my school project, but I have few questions before I purchase the components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all, let me explain how it will work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There will be 4x20 LCD, an Arduino and probably two potentiometers (due to the potentiometer's sensitivity). When the user turns the potentiometers, the program adds the first potentiometer's value to the other potentiometer's value, because of sensitivity issues. Then the program checks which element corresponds to the two potentiometers' values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, the program shows that element's information in the LCD (like its name, symbol, neutron number, proton number, valence electrons, ...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;There are around 118 elements in the periodic table. I'm not an expert with programming, but this means there will be 118 &lt;code&gt;if ... else if ...&lt;/code&gt; statements. I can shorten the inside of the &lt;code&gt;if&lt;/code&gt; statement by function, but there will be still 118 &lt;code&gt;if&lt;/code&gt; statements. I'm afraid it will be over the memory (sketch size limit) limit of the Arduino. How can I shorten the code?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Should I buy a Mega or will a Uno be enough?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Will there be any problems if I connect a 5V Arduino pin to both potentiometers and 4x20 backlight? If not, how can I fix this? I don't want to use any other power source except Arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19192" LastEditorUserId="6936" LastEditDate="2016-03-13T07:52:06.710" LastActivityDate="2016-03-13T20:59:57.430" Title="I am planning to do a periodic table with Arduino's help but I have a few questions" Tags="|arduino-mega|lcd|potentiometer|sketch-size|" AnswerCount="4" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="21722" PostTypeId="1" AcceptedAnswerId="21723" CreationDate="2016-03-12T08:31:01.933" Score="1" ViewCount="96" Body="&lt;p&gt;I am reading a 50Hz AC voltage using the analogue inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I set the analogReference() to INTERNAL, meaning 1.1V on the Arduino Uno, what will happen if a voltage greater than 1.1V is supplied to the pin? Will the board be damaged? If not, what value will the ADC give?&lt;/p&gt;&#xA;" OwnerUserId="19193" LastActivityDate="2016-03-12T10:02:25.767" Title="What will happen if I supply greater than 1.1V to analogue inputs if analogReference set to INTERNAL?" Tags="|analogread|adc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21723" PostTypeId="2" ParentId="21722" CreationDate="2016-03-12T10:02:25.767" Score="3" Body="&lt;p&gt;You will read 1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The limit of the voltage is not the reference voltage but the chip supply voltage - so 5v on a 5v board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-12T10:02:25.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21724" PostTypeId="1" CreationDate="2016-03-12T10:13:52.247" Score="-4" ViewCount="13130" Body="&lt;p&gt;I got a sketch from the internet &lt;a href=&quot;https://www.instructables.com/How-to-build-an-8x8x8-LED-cube-and-control-it-with/&quot; rel=&quot;nofollow noreferrer&quot;&gt;(http://www.instructables.com/id/How-to-build-an-8x8x8-LED-cube-and-control-it-with/)&lt;/a&gt; for controlling the display of an 8x8x8 LED cube. The program won't compile and the error says &amp;quot;stray '#' in program&amp;quot;. I looked it up on google but nothing appears to be relevant.&#xA;Here's a part of the code. (The error occurs at the &lt;code&gt;baseColor = color(#222222);&lt;/code&gt; line)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int rectX, rectY;      // Position of square button&#xA;int ROWX, ROWY;&#xA;int rectSizeX = 80;     // Width of rect&#xA;int rectSizeY = 20;     // Height of rect&#xA;int circleSize = 20;   // Diameter of circle&#xA;color rectColor, circleColorOff, circleColorOn, baseColor;&#xA;color rectHighlight, circleHighlight;&#xA;color circleCurrentColor;&#xA;color rectCurrentColor;&#xA;boolean rectOver = false;&#xA;&#xA;// State of LEDs&#xA;boolean[][] circleOn;&#xA;&#xA;// Position of LED buttons&#xA;int[][] circlePos;&#xA;&#xA;// Mouse Over LED buttons?&#xA;boolean [][] circleOver;&#xA;&#xA;int delayedby = 50;&#xA;&#xA;void setup() {&#xA; //number of rows and columns&#xA; ROWX= 8;&#xA; ROWY= 8;&#xA;&#xA; size((ROWX*40+10), (ROWY*44+30));&#xA; noStroke();&#xA; frameRate(10);&#xA; smooth();&#xA; rectX = ROWX*20-30;&#xA; rectY = ROWY*44+5;&#xA; &#xA; // Colors&#xA; rectColor = color(#FF0000);&#xA; rectHighlight = color(#FFFF00);&#xA; circleColorOff = color(#444444);&#xA; circleColorOn = color(#ff0000);&#xA; circleHighlight = color(#CCFF00);&#xA; baseColor = color(#222222);&#xA; circleCurrentColor = circleColorOff;&#xA; rectCurrentColor = rectColor;&#xA;&#xA;circleOn = new boolean[ROWX][ROWY];&#xA;for(int i=0; i&amp;lt;=(ROWY-1); i++) {&#xA; for(int j=0; j&amp;lt;=(ROWX-1); j++) {&#xA;   circleOn[j][i] = false;&#xA;    }&#xA;}&#xA;circlePos = new int[2][(ROWX*ROWY+1)];&#xA;&#xA;// X Posistions&#xA;for(int i=0; i&amp;lt;(ROWX*ROWY-(ROWX-1)); i=i+ROWX) {&#xA;int Xpos = 25;&#xA;  for(int ii=0; ii&amp;lt;ROWX; ii++) {&#xA;     circlePos[0][i+ii] = Xpos;&#xA;     Xpos += 40;&#xA;  }&#xA;}&#xA;&#xA;// Y Positions&#xA;int Ypos = 40;&#xA; for(int i=0; i&amp;lt;(ROWX*ROWY-(ROWX-1)); i+=ROWX) {&#xA;  for(int ii=0; ii&amp;lt;ROWX; ii++) {&#xA;     circlePos[1][i+ii] = Ypos;&#xA;  }&#xA;        Ypos += 40;&#xA; }&#xA;&#xA;&#xA;circleOver = new boolean[ROWX][ROWY];&#xA;for(int i=0; i&amp;lt;=(ROWY-1); i++) {&#xA; for(int j=0; j&amp;lt;=(ROWX-1); j++) {&#xA;   circleOver[j][i] = false;&#xA; }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It turns out that the code was compiled in the earlier beta versions of the Arduino IDE, and now I don't know what I need to do for it to be compiled by my 1.6.5 version.&lt;/p&gt;&#xA;" OwnerUserId="14129" LastEditorUserId="27346" LastEditDate="2022-02-25T17:09:23.707" LastActivityDate="2022-02-25T17:09:23.707" Title="Problem: &quot;stray '#' in program&quot;" Tags="|sketch|ide|" AnswerCount="1" CommentCount="4" ClosedDate="2016-03-13T14:11:08.777" ContentLicense="CC BY-SA 4.0" />
  <row Id="21726" PostTypeId="1" CreationDate="2016-03-12T15:07:34.297" Score="0" ViewCount="4703" Body="&lt;p&gt;I need to send Arduino some instructions from the web. Basically I would have a web app with a few buttons, and when I press them they send an instruction to Arduino to move for example a motor or turn a lamp. This has to function remotely, so not locally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Yùn. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I do this? Websocket? How? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19199" LastActivityDate="2016-03-13T12:27:20.780" Title="Send commands to Arduino from the WEB" Tags="|arduino-yun|web-server|remote-control|web-service|web|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21727" PostTypeId="2" ParentId="20125" CreationDate="2016-03-12T17:00:31.787" Score="0" Body="&lt;p&gt;I have similar problem with the HC-SR505 sensor. First few seconds it holds 0 on the output pin, and then always 1.&#xA;I think it was bad batch of sensors. Bad batch in chinese manufacturing means thousands (or hundreds of thousands) bad modules flooded the market.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile I decided to choose one of options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Stick with HC-SR501 sensor. It's bigger but works more or less.&lt;/li&gt;&#xA;&lt;li&gt;Buy expensive ($5.90) &lt;a href=&quot;http://www.seeedstudio.com/depot/Mini-PIR-Motion-Sensor-Module-p-1729.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;PIR sensor from seeed&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Build my own PIR module by my required dimensions and function (in progress).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&#xA;From 5 sensors received 2 do the job. Supply voltage must be 5V or higher. First 20-60 seconds the output is not reliable and should be ignored. Then it works OK (if it works at all). Since the module has 3.3V LDO onboard the output signal is 3.3V.&lt;/p&gt;&#xA;" OwnerUserId="19203" LastEditorUserId="19203" LastEditDate="2018-02-02T08:48:51.463" LastActivityDate="2018-02-02T08:48:51.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21728" PostTypeId="2" ParentId="21726" CreationDate="2016-03-12T17:09:12.600" Score="1" Body="&lt;p&gt;It becomes lots easier if you see the yun as a linux computer with a arduino connected over serial.&lt;br&gt;&#xA;Then the question becomes: what is the best way to send commands over the internet to a (linux) computer.&lt;br&gt;&#xA;Answer: there are so many ways because there is no best way.&lt;br&gt;&#xA;What are the main key drivers:&#xA;Your linux computer needs to be reachable from the internet. That means opening your local network(firewall). The firewall is there for a reason. Do you have the skills to open your firewall and still be safe? If so you can run a service (lots of options) and reach your yun from anywhere on the internet. Just as you do locally.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not you will need to go to a polling system. You use a server which is on the internet and send you request to that server. Your yun polls that server to get the messages you send.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a third option: If you can open your firewall from the internet, and you are the only user of the service and you very rarely need the service you can temporarily open the firewall when you need it&#xA;.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-12T17:09:12.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21729" PostTypeId="2" ParentId="21726" CreationDate="2016-03-12T17:51:01.270" Score="0" Body="&lt;p&gt;Another option, if you can be limited to controlling your device from a mobile app, is &lt;a href=&quot;http://blynk.cc&quot; rel=&quot;nofollow&quot;&gt;blynk.cc&lt;/a&gt;. They provide mobile apps for Android and iOS, that let you build a control panel via drag-and-drop, and embedded platform libraries for Arduino, standalone ESP8266, RPi, and others, that talk both ways between the app and your embedded device, as well as between devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The embedded devices and the mobile apps communicate as clients to their servers (or to your server, if you choose to host the open-source server code) so you don't have to open any ports on your router or firewall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't have the full freedom (or requirement!) of designing custom web-pages; but OTOH, you can be up and running with their example code in a few minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a couple of room-temperature monitors on my desk that can report the temperature (plus history) to me anywhere I can get a web connection. I put two buttons on my panel to turn on, or blink, 2 LEDs on the board. With my feet up on the hearth I control the LEDs. There are slider-controls that can talk to the PWM ports as well. All the capabilities you need are there, at least to get started.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-12T17:51:01.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21730" PostTypeId="1" CreationDate="2016-03-12T12:14:08.977" Score="0" ViewCount="396" Body="&lt;p&gt;I am doing a project on a ATtiny85 which involves using 433MHz RF modules. Whenever I want to compile any sketch using the Manchester library I always get these errors : &quot;Manchester library doesnt support your microcontroller&quot;. Could anyone help me solving this?&lt;/p&gt;&#xA;" OwnerUserId="19206" OwnerDisplayName="user103320" LastActivityDate="2017-01-07T05:23:16.410" Title="Problem with ATtiny85 and RF modules" Tags="|attiny|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21731" PostTypeId="2" ParentId="21730" CreationDate="2016-03-12T12:42:36.310" Score="0" Body="&lt;p&gt;If you are using arduino IDE, only limited functions are supported for the ATtiny85, and if that library requires some of the function from the IDE (Probably Serial), then it will not work. There are few solutions: 1, use an atmega Chip; 2, get another library; 3, write your own code.&lt;/p&gt;&#xA;" OwnerDisplayName="Atmega 328" LastActivityDate="2016-03-12T12:42:36.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21732" PostTypeId="2" ParentId="21730" CreationDate="2016-03-12T19:06:02.270" Score="1" Body="&lt;p&gt;Somehow I got it working. I don't know the cause of the problem but in order to fix it I had to Arduino 1.0 IDE; use &lt;a href=&quot;https://code.google.com/archive/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; ATtiny support and &lt;a href=&quot;https://github.com/mchr3k/arduino-libs-manchester&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; Manchester library. Thank you all for your help.&lt;/p&gt;&#xA;" OwnerUserId="19206" LastActivityDate="2016-03-12T19:06:02.270" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21733" PostTypeId="1" AcceptedAnswerId="21739" CreationDate="2016-03-12T19:13:37.700" Score="5" ViewCount="1772" Body="&lt;p&gt;To use the onboard LED on an Arduino one usually has to know the pin number (13 in most cases), but is there a constant in the Arduino IDE one can use as well? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is it possible to use something like &lt;code&gt;int LED = ONBOARDLED;&lt;/code&gt; instead of using &lt;code&gt;int LED = 13;&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="15569" LastEditorUserId="6936" LastEditDate="2016-03-13T03:15:57.937" LastActivityDate="2016-03-13T03:15:57.937" Title="Arduino onboard LED pin number as a constant" Tags="|led|arduino-ide|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21734" PostTypeId="1" AcceptedAnswerId="21735" CreationDate="2016-03-12T11:24:26.437" Score="2" ViewCount="3376" Body="&lt;p&gt;I am writing a small library to move some code out of the arduino sketch and make it reusable. Problem is that it does not compile since &amp;quot;String does not name a type&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;This is my code (reduced):&lt;/p&gt;&#xA;&lt;p&gt;myESP.h:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef MYESP_H&#xA;#define MYESP_H&#xA;&#xA;#include &amp;quot;Arduino.h&amp;quot;&#xA;&#xA;#include &amp;lt;String&amp;gt;&#xA;&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;ESP8266WiFiMulti.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;#include &amp;lt;WiFiClientSecure.h&amp;gt;&#xA;#include &amp;lt;WiFiServer.h&amp;gt;&#xA;#include &amp;lt;WiFiUdp.h&amp;gt;&#xA; &#xA;class myESP {&#xA;    private:&#xA;        const char* _ssid;&#xA;        const char* _password;&#xA;        const char* _host;&#xA;    public:&#xA;        myESP();&#xA;        myESP(char * ssid, char * pwd, char * host);&#xA;        String macToStr(const uint8_t* mac);&#xA;        String doGet(String data, String sensor, int duration);&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;myESP.cpp:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;String&amp;gt;&#xA;&#xA;#include &amp;quot;Arduino.h&amp;quot;&#xA;#include &amp;quot;myESP.h&amp;quot;&#xA;&#xA;myESP::myESP() {}&#xA;&#xA;myESP::myESP(char * ssid, char * pwd, char * host) {&#xA;    _host = host;&#xA;    _password = pwd;&#xA;    _ssid = ssid;&#xA;}&#xA;&#xA;myESP::String macToStr(const uint8_t* mac) {&#xA;}&#xA;&#xA;myESP::String doGet(String data, String sensor, int duration) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When i try to compile it, I get the following:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:14:1:&#xA;error: 'String' in 'class myESP' does not name a type  myESP::String&#xA;macToStr(const uint8_t* mac) {&lt;/p&gt;&#xA;&lt;p&gt;/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:22:1:&#xA;error: 'String' in 'class myESP' does not name a type  myESP::String&#xA;doGet(String data, String sensor, int duration) {&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have tried to change the order of the imports, change libraries, but still it does not compile.&lt;/p&gt;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;" OwnerDisplayName="lbedogni" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-12T19:20:28.967" Title="Can't compile my library because &quot;String does not name a type&quot;" Tags="|library|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21735" PostTypeId="2" ParentId="21734" CreationDate="2016-03-12T11:50:41.747" Score="2" Body="&lt;p&gt;Your syntax is wrong in myESP.cpp. Change this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myESP::String macToStr(const uint8_t* mac) {&#xA;}&#xA;&#xA;myESP::String doGet(String data, String sensor, int duration) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String myESP::macToStr(const uint8_t* mac) {&#xA;}&#xA;&#xA;String myESP::doGet(String data, String sensor, int duration) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The return type is &lt;code&gt;String&lt;/code&gt; and the function implementation should be prefixed with the class name &lt;code&gt;myESP::&lt;/code&gt;. Obviously, you also need to fill in the body of the implementation or you'll get more errors because you don't actually return anything.&lt;/p&gt;&#xA;" OwnerUserId="5063" OwnerDisplayName="Roger Rowland" LastActivityDate="2016-03-12T11:50:41.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21736" PostTypeId="1" AcceptedAnswerId="21737" CreationDate="2016-03-12T11:17:21.830" Score="0" ViewCount="5115" Body="&lt;p&gt;My question is simple: there is any Pascal or Pascal-class (FPC, Delphi, mikroPascal) programming language for Arduino?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Preferably (I hope I don't ask too much) that language should not be older than 10 years. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;br&gt;&#xA;Let's not start a flame war about &quot;why the xxx programming language is so much better Pascal&quot; and keep focus on the core of this question. I know that Pascal has it flaws (nothing its perfect, right?). I accept them and I still want to use it :)&lt;br&gt;&#xA;Many thanks.&lt;/p&gt;&#xA;" OwnerUserId="19209" OwnerDisplayName="Kenny" LastEditorUserId="19209" LastEditDate="2016-03-15T10:35:24.437" LastActivityDate="2019-03-22T21:57:38.780" Title="Programming Arduino in Pascal?" Tags="|arduino-uno|arduino-mega|arduino-due|arduino-nano|" AnswerCount="4" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="21737" PostTypeId="2" ParentId="21736" CreationDate="2016-03-12T12:35:42.710" Score="4" Body="&lt;p&gt;Not Pascal, but Ada, which is much less restrictive than Pascal while enjoying the same advantages over low-level programming, and much more actively supported with language revisions as recently as 2012 and the formally provable SPARK language, for when you need your code to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any processor which gcc supports can potentially support Ada, whose Gnat compiler is fully part of gcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not the whole story because you also need run-time system support for Ada's facilities, but for the Arduino's AVR processor there is a well established environment in the form of the &lt;a href=&quot;https://sourceforge.net/p/avr-ada/wiki/Home/&quot;&gt;AVR-Ada project&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It generates nice tight little executables, you'll be amazed how much less space simple Gnat executables take compared to Arduino ones - unless you've already made the same comparison between Arduino and C ... which after all uses the same gcc compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For ARM-based Arduinos (Arduino Due at least) the same is possible, though the support is newer and possibly less well established, see &lt;a href=&quot;https://sourceforge.net/projects/cortex-gnat-rts/?source=directory&quot;&gt;the Cortex-GNAT project&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Leaving the Arduino, Ada has also been demonstrated on the &lt;a href=&quot;https://sourceforge.net/projects/msp430ada/?source=recommended&quot;&gt;MSP430 processor&lt;/a&gt; - my own project, sadly neglected at the moment.&lt;/p&gt;&#xA;" OwnerUserId="19213" OwnerDisplayName="Brian Drummond" LastActivityDate="2016-03-12T12:44:14.080" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21738" PostTypeId="2" ParentId="21733" CreationDate="2016-03-12T19:24:31.780" Score="4" Body="&lt;p&gt;Try &lt;code&gt;LED_BUILTIN&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pins_arduino.h:static const uint8_t LED_BUILTIN = 13;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-12T19:24:31.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21739" PostTypeId="2" ParentId="21733" CreationDate="2016-03-12T19:24:51.607" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;#define LED_BUILTIN 13&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;https://github.com/arduino/Arduino/blob/435fc323e0ab3b03bc5835e5309b5022bf57388a/hardware/arduino/sam/variants/arduino_due_x/variant.h#L97&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-12T19:24:51.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21741" PostTypeId="1" AcceptedAnswerId="21742" CreationDate="2016-03-12T20:30:29.900" Score="0" ViewCount="1523" Body="&lt;p&gt;I have had this problem a few times, it seems the Arduino IDE and the serial monitor is incredibly unstable, unless it's user error but judging from the fact that I hadn't even touched anything before it broke, I would say it's not me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was working the night before but this morning it just wouldn't print anything to the serial monitor from my code, however if I start one of the communication example codes like the ASCII example, it prints fine...I'm using the arduino uno, but I have a couple of dues too, so I tried the script on the due and it printed fine to the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code, could someone check my code and see if they can print to the serial monitor or not?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;   Pins:&#xA;&#xA;   RTC:&#xA;   5V to VCC&#xA;   GND to GDN&#xA;   A4 to SDA&#xA;   A5 to SLC&#xA;*/&#xA;&#xA;&#xA;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;#if defined(ARDUINO_ARCH_SAMD)&#xA;// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!&#xA;#define Serial SerialUSB&#xA;#endif&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;char daysOfTheWeek[7][12] = {&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;};&#xA;&#xA;//Words     //0      //1     //2    //3     //4     //5     //6    //7      //8      //9     //10   //11      //12      //13        //14        //15       //16       //17         //18        //19        //20      //21       //22    //23     //24                    //25//26 //27&#xA;char* w[] = {&quot;Zero&quot;, &quot;One&quot;, &quot;Two&quot;, &quot;Three&quot;, &quot;Four&quot;, &quot;Five&quot;, &quot;Six&quot;, &quot;Seven&quot;, &quot;Eight&quot;, &quot;Nine&quot;, &quot;Ten&quot;, &quot;Eleven&quot;, &quot;Twelve&quot;, &quot;Thirteen&quot;, &quot;Fourteen&quot;, &quot;Fifteen&quot;, &quot;Sixteen&quot;, &quot;Seventeen&quot;, &quot;Eighteen&quot;, &quot;Nineteen&quot;, &quot;Twenty&quot;, &quot;Thirty&quot;, &quot;Forty&quot;, &quot;Fifty&quot;, &quot;Keeg Jo And Mat 2016&quot;, &quot;&quot;, &quot; &quot;, &quot;Good&quot;,&#xA;             //28       //29         //30       //31     //32    //33  //34       //35    //36       //37  //38&#xA;             &quot;Morning&quot;, &quot;Afternoon&quot;, &quot;Evening&quot;, &quot;It Is&quot;, &quot;Past&quot;, &quot;To&quot;, &quot;Quarter&quot;, &quot;Half&quot;, &quot;O'Clock&quot;, &quot;AM&quot;, &quot;PM&quot;&#xA;            };&#xA;&#xA;//End Words&#xA;&#xA;int timeType = 0;&#xA;int _hour = 0;&#xA;&#xA;int dayInput = 0;&#xA;int hourInput = 0;&#xA;int minuteInput = 0;&#xA;&#xA;int iDay = 0;&#xA;int iHour = 0;&#xA;int iMinute = 0;&#xA;&#xA;&#xA;void setup () {&#xA;&#xA;#ifndef ESP8266&#xA;  while (!Serial); // for Leonardo/Micro/Zero&#xA;#endif&#xA;&#xA;  Serial.begin(57600);&#xA;  pinMode(11, INPUT);//Minutes&#xA;  pinMode(12, INPUT);//Hours&#xA;  pinMode(13, INPUT);//Day&#xA;&#xA;  if (! rtc.begin()) {&#xA;    Serial.println(&quot;Couldn't find RTC&quot;);&#xA;    while (1);&#xA;  }&#xA;&#xA;  if (! rtc.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;    //rtc.adjust(DateTime(2016, 3, 11, 10, 51, 0));&#xA;  }&#xA;&#xA;  //rtc.adjust(DateTime(2016, 3, 11, 1, 0, 50));&#xA;  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;}&#xA;&#xA;void loop () {&#xA;  DateTime now = rtc.now();&#xA;&#xA;  minuteInput = digitalRead(11);&#xA;  hourInput = digitalRead(12);&#xA;  dayInput = digitalRead(13);&#xA;&#xA;  if (minuteInput == HIGH) {&#xA;    Serial.println(&quot;Minute&quot;);&#xA;  } else if (hourInput == HIGH) {&#xA;    Serial.println(&quot;Hour&quot;);&#xA;  } else if (dayInput == HIGH) {&#xA;    Serial.println(&quot;Day&quot;);&#xA;  }&#xA;&#xA;  Line();&#xA;&#xA;  if (now.minute() == 0) {&#xA;    timeType = 0;&#xA;  } else if (now.minute() &amp;gt; 0 &amp;amp;&amp;amp; now.minute() &amp;lt;= 20) {&#xA;    timeType = 1;&#xA;  } else if (now.minute() &amp;gt; 20 &amp;amp;&amp;amp; now.minute() &amp;lt; 50 &amp;amp;&amp;amp; now.minute() != 30 &amp;amp;&amp;amp; now.minute() != 45) {&#xA;    timeType = 0;&#xA;  } else if (now.minute() &amp;gt;= 50 &amp;amp;&amp;amp; now.minute() &amp;lt; 60) {&#xA;    timeType = 2;&#xA;  } else if (now.minute() == 30) {&#xA;    timeType = 3;&#xA;  } else if (now.minute() == 45) {&#xA;    timeType = 4;&#xA;  }&#xA;&#xA;  ps(&quot;Time Type: &quot;);&#xA;  pi(timeType);&#xA;&#xA;  Line();&#xA;  Line();&#xA;&#xA;  //Greeting&#xA;  p(27);&#xA;  Space();&#xA;  if (now.hour() &amp;gt;= 0 &amp;amp;&amp;amp; now.hour() &amp;lt; 12) {&#xA;    p(28);&#xA;  } else if (now.hour() &amp;gt;= 12 &amp;amp;&amp;amp; now.hour() &amp;lt; 18) {&#xA;    p(29);&#xA;  } else if (now.hour() &amp;gt;= 18 &amp;amp;&amp;amp; now.hour() &amp;lt; 24) {&#xA;    p(30);&#xA;  }&#xA;&#xA;  Line();&#xA;  Line();&#xA;&#xA;  //Time (It Is) Time Type 0&#xA;  if (timeType == 0) {&#xA;    Itis();&#xA;    hours(0);&#xA;    Space();&#xA;    _minutes();&#xA;    OClock();&#xA;  }&#xA;&#xA;  //Time (Past) Time Type 1&#xA;  if (timeType == 1) {&#xA;    Itis();&#xA;    _minutes();&#xA;    Past();&#xA;    hours(0);&#xA;    OClock();&#xA;  }&#xA;&#xA;  //Time (To) Time Type 2&#xA;  if (timeType == 2) {&#xA;    Itis();&#xA;    _minutes();&#xA;    To();&#xA;    hours(0);&#xA;    OClock();&#xA;  }&#xA;&#xA;  //Time (Half Past) Time Type 3&#xA;  if (timeType == 3) {&#xA;    Itis();&#xA;    p(35);&#xA;    Past();&#xA;    hours(0);&#xA;  }&#xA;&#xA;  //Time (Quarter To) Time Type 4&#xA;  if (timeType == 4) {&#xA;    Itis();&#xA;    p(34);&#xA;    To();&#xA;    hours(1);&#xA;  }&#xA;&#xA;  //AM/PM&#xA;  AMPM();&#xA;&#xA;  Line();&#xA;  Line();&#xA;&#xA;  //Day&#xA;  //Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);&#xA;  ps(daysOfTheWeek[now.dayOfTheWeek()]);&#xA;&#xA;  Line();&#xA;  Line();&#xA;&#xA;  pl(24);&#xA;&#xA;  Serial.println(&quot;--------------------------------------------------&quot;);&#xA;  Serial.println(&quot;--------------------------------------------------&quot;);&#xA;&#xA;  delay(1000);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;//------------------------------------------------&#xA;&#xA;void Line() {&#xA;  pl(25);&#xA;}&#xA;&#xA;void Itis() {&#xA;  p(31);&#xA;  Space();&#xA;}&#xA;&#xA;void Past() {&#xA;  Space();&#xA;  p(32);&#xA;  Space();&#xA;}&#xA;&#xA;void To() {&#xA;  Space();&#xA;  p(33);&#xA;  Space();&#xA;}&#xA;&#xA;void Space() {&#xA;  p(26);&#xA;}&#xA;&#xA;void OClock() {&#xA;  DateTime now = rtc.now();&#xA;  if (now.minute() == 0 || now.minute() == 60) {&#xA;    Space();&#xA;    p(36);&#xA;  }&#xA;}&#xA;&#xA;void AMPM() {&#xA;  Space();&#xA;&#xA;  DateTime now = rtc.now();&#xA;&#xA;  bool am = false;&#xA;&#xA;  if (now.hour() &amp;gt; 12) {&#xA;    am = false;&#xA;  } else {&#xA;    am = true;&#xA;  }&#xA;&#xA;  if (am) {&#xA;    p(37);&#xA;  } else {&#xA;    p(38);&#xA;  }&#xA;}&#xA;&#xA;void p(int i) {&#xA;  Serial.print(w[i]);&#xA;}&#xA;&#xA;void pl(int i) {&#xA;  Serial.println(w[i]);&#xA;}&#xA;&#xA;void ps(char* i) {&#xA;  Serial.print(i);&#xA;}&#xA;&#xA;void pi(int i) {&#xA;  Serial.print(i);&#xA;}&#xA;&#xA;void _minutes() {&#xA;  DateTime now = rtc.now();&#xA;  int minutes = 0;&#xA;&#xA;  if (timeType == 2) {&#xA;    minutes = 60 - now.minute();&#xA;  } else {&#xA;    minutes = now.minute();&#xA;  }&#xA;&#xA;  int i = minutes;&#xA;&#xA;  if (i &amp;lt;= 20 &amp;amp;&amp;amp; i != 0) {&#xA;    p(i);&#xA;  } else if (i &amp;gt; 20 &amp;amp;&amp;amp; i &amp;lt; 30) {&#xA;    p(20);&#xA;    Space();&#xA;    p(i - 20);&#xA;  } else if (i &amp;gt; 30 &amp;amp;&amp;amp; i &amp;lt; 40) {&#xA;    p(21);&#xA;    Space();&#xA;    p(i - 30);&#xA;  } else if (i &amp;gt; 40 &amp;amp;&amp;amp; i &amp;lt; 50 &amp;amp;&amp;amp; i != 45) {&#xA;    p(22);&#xA;    Space();&#xA;    p(i - 40);&#xA;  } else if (i &amp;gt; 50 &amp;amp;&amp;amp; i &amp;lt; 60) {&#xA;    p(23);&#xA;    Space();&#xA;    p(i - 50);&#xA;  } else if (i == 30) {&#xA;    p(35);&#xA;  } else if (i == 40) {&#xA;    p(22);&#xA;  } else if (i == 50) {&#xA;    p(23);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void hours(int m) {&#xA;  DateTime now = rtc.now();&#xA;&#xA;  if (now.hour() &amp;gt; 12) {&#xA;    _hour = now.hour() - 12;&#xA;  } else {&#xA;    _hour = now.hour();&#xA;  }&#xA;&#xA;  _hour = _hour + m;&#xA;&#xA;  p(_hour);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="10794" LastEditDate="2016-03-12T21:05:05.530" LastActivityDate="2016-03-12T21:05:05.530" Title="Serial Monitor Suddenly Doesn't Work" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21742" PostTypeId="2" ParentId="21741" CreationDate="2016-03-12T21:03:04.280" Score="1" Body="&lt;pre&gt;&lt;code&gt;  //rtc.adjust(DateTime(2016, 3, 11, 1, 0, 50));&#xA;  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every time you reset the Arduino, the RTC clock will be set back to the date/time you compiled the sketch. Surely you don't want that?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The serial monitor is not at all unstable, as you agree when you try a different sketch. Therefore your sketch has a bug, which you need to find.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible issue is hardware. The default Wire library will hang if communications are lost when doing a read. Can you describe your clock hardware? Is it a chip you soldered yourself? A board? If so, which one? Do you have pull-up resistors on SDA/SCL?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an &lt;a href=&quot;http://dsscircuits.com/articles/arduino-i2c-master-library&quot; rel=&quot;nofollow&quot;&gt;alternate I2C library&lt;/a&gt; that you could try.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your method of printing is certainly unusual. You call, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Line ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you could just as easily (and a lot more readably) call:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Similarly for &lt;code&gt;Space&lt;/code&gt; and so on.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Still, despite the very hard-to-read code, I can't see any loops that might cause printing to fail. I suggest you comment out the calls to &lt;code&gt;rtc.now()&lt;/code&gt; and test it. If it works, that confirms you have a clock issue, not a printing issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I note that you have multiple calls to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DateTime now = rtc.now();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... sprinkled throughout your code. Surely you only need to read the time once, per loop?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the &lt;code&gt;now&lt;/code&gt; variable outside loop, and call it once only, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DateTime now; &#xA;&#xA;void loop () {&#xA;  now = rtc.now();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then remove the other calls to &lt;code&gt;rtc.now()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I found when I tested (without a RTC connected) that it did indeed hang. But that was the &lt;code&gt;rtc.now()&lt;/code&gt; call failing. If you comment that out, it prints fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Minute&#xA;&#xA;Time Type: 0&#xA;&#xA;Good Morning&#xA;&#xA;It Is Six Twenty Eight AM&#xA;&#xA;&#xA;&#xA;Keeg Jo And Mat 2016&#xA;--------------------------------------------------&#xA;--------------------------------------------------&#xA;Minute&#xA;&#xA;Time Type: 0&#xA;&#xA;Good Morning&#xA;&#xA;It Is Six Twenty Eight AM&#xA;&#xA;&#xA;&#xA;Keeg Jo And Mat 2016&#xA;--------------------------------------------------&#xA;--------------------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That shows it is definitely a clock issue, not a serial printing issue.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-12T21:03:04.280" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21743" PostTypeId="1" CreationDate="2016-03-12T21:20:33.727" Score="0" ViewCount="53" Body="&lt;p&gt;I'd like to define a function such that I return a string and a boolean indicating whether the result is valid. Like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool getStringOrTimeout(String *s) {&#xA;  ...&#xA;  if (timed_out) {&#xA;    return false;&#xA;  } else {&#xA;    *s = String(&amp;lt;some value&amp;gt;);&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this going to cause a memory problem because the string is allocated on the stack and deallocated when it leaves scope, or is this okay?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="10794" LastEditDate="2016-03-13T00:34:12.207" LastActivityDate="2016-05-12T02:26:43.343" Title="Is this method to a String from a function going to cause memory corruption?" Tags="|c++|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21744" PostTypeId="1" CreationDate="2016-03-12T21:21:58.857" Score="0" ViewCount="1015" Body="&lt;pre&gt;&lt;code&gt;/**************************************/&#xA;const int lowestPin = 1;//the lowest one attach to&#xA;const int speaker = 13;&#xA;int ts = 4;//how many beats you want&#xA;int count = 1;&#xA;const int keyPin = 12;&#xA;int buttonState = 0;&#xA;int bpm = 120;&#xA;/**************************************/&#xA;void setup()&#xA;{&#xA;  for (int thisPin = 1; thisPin &amp;lt;= ts; thisPin++)&#xA;  {&#xA;    pinMode(thisPin, OUTPUT); //initialize thisPin as an output&#xA;    pinMode(6, INPUT);&#xA;&#xA;&#xA;  }&#xA;  pinMode(keyPin, INPUT);&#xA;}&#xA;&#xA;/****************************************/&#xA;void loop()&#xA;{&#xA;&#xA;  //iterate over the pins&#xA;  //turn the led on from lowest to the highest&#xA;&#xA;&#xA;&#xA;  if (digitalRead(keyPin) == HIGH &amp;amp;&amp;amp; ts == 2) {&#xA;    ts = 3;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  else if (digitalRead(keyPin) == HIGH &amp;amp;&amp;amp; ts == 3) {&#xA;    ts = 4;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  else if (digitalRead(keyPin) == HIGH &amp;amp;&amp;amp; ts == 4)&#xA;  {&#xA;    ts = 2;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  for (int thisPin = 1; thisPin &amp;lt;= ts; thisPin++)&#xA;  {&#xA;&#xA;    bpm = pulseIn(6, HIGH);&#xA;&#xA;    pinMode(13, OUTPUT);&#xA;    if (ts &amp;gt; 4)&#xA;    {&#xA;      if (count &amp;gt; 3)&#xA;        for (int a = 4; a &amp;lt;= ts; a++) {&#xA;          digitalWrite(a - 3, HIGH);&#xA;        }&#xA;&#xA;    }&#xA;    else&#xA;      digitalWrite(thisPin, HIGH);&#xA;&#xA;    if (count == 1)&#xA;      tone(13, 1500, 100);&#xA;    else&#xA;      tone(13, 1000, 100);&#xA;&#xA;    delay(bpm - 52);&#xA;    pinMode(13, INPUT);&#xA;    digitalWrite(thisPin, LOW);&#xA;&#xA;&#xA;    count++;&#xA;    if (count &amp;gt; ts)&#xA;      count = 1;&#xA;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am trying to make a metronome using Arduino Uno, with 4 LEDs, each LED is a beat. I want to change the time signature every time I press the pushbutton, so that there are different number of beats per measure, but when I do press the button, it runs the code for 2 and 3 beats per measure once, and then goes back to its default, 4 beats per measure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, it even changes without pressing the button, randomly. I am using a 220 ohm resister instead of 10, as 10 starts much more randomly than the 220. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aXmSB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aXmSB.jpg&quot; alt=&quot;Metronome project picture&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19210" LastEditorUserId="10794" LastEditDate="2016-03-13T00:26:36.267" LastActivityDate="2016-12-09T05:55:12.917" Title="Arduino metronome - Change time signature on button press" Tags="|arduino-uno|c++|button|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21745" PostTypeId="1" CreationDate="2016-03-13T00:15:41.900" Score="2" ViewCount="1217" Body="&lt;p&gt;Has anyone here setup an MQTT Broker on an Arduino?  I am looking to use &lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot; rel=&quot;nofollow&quot;&gt;pubsubclient&lt;/a&gt; to send sensor data from 12 individual wireless sensors to an Arduino every 250ms.  I know this can be done using a Raspberry Pi, but I am new to all this and am just now comfortable with programming an Arduino.  I also looked at using XBee, but have heard it may not be able to handle the data frequency.  I am only sending 1 byte of data from each sensor each time.  Any help or suggestion is appreciated.&lt;/p&gt;&#xA;" OwnerDisplayName="user19216" LastEditorUserId="6936" LastEditDate="2016-03-16T00:43:41.757" LastActivityDate="2016-03-16T00:43:41.757" Title="MQTT Broker on an Arduino" Tags="|arduino-uno|sensors|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21746" PostTypeId="2" ParentId="21743" CreationDate="2016-03-13T00:34:02.860" Score="1" Body="&lt;p&gt;You are better off passing the string by reference, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool getStringOrTimeout(String &amp;amp; s)&#xA;{&#xA;  if (timed_out)&#xA;    return false;&#xA;  s = &quot;foo&quot;;&#xA;  return true;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That means the &lt;em&gt;caller's&lt;/em&gt; string will be modified. And you no longer need to pass down a pointer to a string.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T00:34:02.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21747" PostTypeId="1" CreationDate="2016-03-13T00:47:24.837" Score="0" ViewCount="623" Body="&lt;p&gt;So this is a question not just about the #include  but most all includes you find while programming in C. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I understand a library is prewritten code and when you include that library are you able to used certain function that are included in that library. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have always wanted to know is: where can you find the &quot;instruction set&quot;, in C, for these libraries?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I find out what commands are available for me to use with this library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;hope this makes sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thank you everyone.&lt;/p&gt;&#xA;" OwnerUserId="18790" LastEditorUserId="18790" LastEditDate="2016-03-13T01:19:28.137" LastActivityDate="2016-03-13T01:19:28.137" Title="Understanding the contents of a library in C" Tags="|programming|library|c|atmega328|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21748" PostTypeId="2" ParentId="21724" CreationDate="2016-03-13T00:48:36.743" Score="3" Body="&lt;p&gt;From the Instructable you linked:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;matrix8x8.pde is a program in Processing to build your own displays. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You downloaded the &lt;strong&gt;Processing&lt;/strong&gt; code, not the &lt;strong&gt;Arduino&lt;/strong&gt; code. See above that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;cube8x8x8.pde is the &lt;em&gt;Arduino code&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So basically you are compiling the wrong code. Go back and re-read that page.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T00:48:36.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21749" PostTypeId="2" ParentId="21747" CreationDate="2016-03-13T01:13:56.747" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What I have always wanted to know is: where can you find the &quot;instruction set&quot;, inc C, for these libraries?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The libraries are usually found in the &lt;code&gt;libraries&lt;/code&gt; sub-folder under your sketchbook folder (wherever that is). There is also another &lt;code&gt;libraries&lt;/code&gt; folder inside the IDE install folder for the &quot;official libraries&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I find out what commands are available for me to use with this library?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Usually the library documents them in one way or another. Try looking inside the &lt;code&gt;.h&lt;/code&gt; file used by the library to see what functions are exposed.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T01:13:56.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21750" PostTypeId="2" ParentId="21721" CreationDate="2016-03-13T03:42:27.173" Score="1" Body="&lt;p&gt;You probably don't need a Mega for this, but think about it as a long term investment if you want to keep messing around with the Arduino/move on to bigger projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, typing all the code out will be quite tedious. But you can make separate arrays for strings of all the element names:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://stackoverflow.com/questions/1088622/how-do-i-create-an-array-of-strings-in-c&quot;&gt;https://stackoverflow.com/questions/1088622/how-do-i-create-an-array-of-strings-in-c&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can make corresponding arrays for all of the numerical data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you take the signal, do some math to figure out how you can use the signal to obtain an integer from 1-118, write that into an integer (say i), and then write name[i], symbol[i], neutnum[i], and so on to the LED screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardest part will be doing math so that the transition between two elements in terms of turning the potentiometer feels natural.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if your math somehow generates 200, then name[200] will most likely write random values from memory to your LED screen. I think. If your LED screen is displaying nonsense, then that is what you should look at/debug first.&lt;/p&gt;&#xA;" OwnerUserId="18718" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-13T03:42:27.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21751" PostTypeId="1" CreationDate="2016-03-12T12:15:00.173" Score="0" ViewCount="278" Body="&lt;p&gt;I'm trying to port the MFRC522 Arduino library (from &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;) to the ARM MCUs.&#xA;My problem is with the PCD_ReadRegister function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * Reads a number of bytes from the specified register in the MFRC522 chip.&#xA; * The interface is described in the datasheet section 8.1.2.&#xA; */&#xA;void MFRC522::PCD_ReadRegister( byte reg,       ///&amp;lt; The register to read from. One of the PCD_Register enums.&#xA;                                byte count,     ///&amp;lt; The number of bytes to read&#xA;                                byte *values,   ///&amp;lt; Byte array to store the values in.&#xA;                                byte rxAlign    ///&amp;lt; Only bit positions rxAlign..7 in values[0] are updated.&#xA;                                ) {&#xA;&#xA;    if (count == 0) {&#xA;        return;&#xA;    }&#xA;    //Serial.print(F(&quot;Reading &quot;));  Serial.print(count); Serial.println(F(&quot; bytes from register.&quot;));&#xA;    byte address = 0x80 | (reg &amp;amp; 0x7E);     // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3.&#xA;    byte index = 0;                         // Index in values array.&#xA;    SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus&#xA;    digitalWrite(_chipSelectPin, LOW);      // Select slave&#xA;    count--;                                // One read is performed outside of the loop&#xA;    SPI.transfer(address);                  // Tell MFRC522 which address we want to read&#xA;    while (index &amp;lt; count) {&#xA;        if (index == 0 &amp;amp;&amp;amp; rxAlign) {        // Only update bit positions rxAlign..7 in values[0]&#xA;            // Create bit mask for bit positions rxAlign..7&#xA;            byte mask = 0;&#xA;            for (byte i = rxAlign; i &amp;lt;= 7; i++) {&#xA;                mask |= (1 &amp;lt;&amp;lt; i);&#xA;            }&#xA;            // Read value and tell that we want to read the same address again.&#xA;            byte value = SPI.transfer(address);&#xA;            // Apply mask to both current value of values[0] and the new data in value.&#xA;            values[0] = (values[index] &amp;amp; ~mask) | (value &amp;amp; mask);&#xA;        }&#xA;        else { // Normal case&#xA;            values[index] = SPI.transfer(address);  // Read value and tell that we want to read the same address again.&#xA;        }&#xA;        index++;&#xA;    }&#xA;    values[index] = SPI.transfer(0);            // Read the final byte. Send 0 to stop reading.&#xA;    digitalWrite(_chipSelectPin, HIGH);         // Release slave again&#xA;    SPI.endTransaction(); // Stop using the SPI bus&#xA;&#xA;} // End PCD_ReadRegister()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I read the datasheet several times &amp;amp; can't understand what's the function of this parameter!&#xA;Based on datasheet for reading a register from rc522:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/IZuzZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IZuzZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19251" OwnerDisplayName="Mahmoud HD" LastEditorUserId="27346" LastEditDate="2018-11-28T15:16:36.723" LastActivityDate="2024-01-09T12:05:45.670" Title="Function of rxAlign parameter in the PCD_ReadRegister function in MFRC522 Library" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="21754" PostTypeId="2" ParentId="21361" CreationDate="2016-03-13T08:54:28.770" Score="0" Body="&lt;p&gt;I've got a working solution to this issue. Here's the values you can edit and the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String FEED = &quot;YOUR_FEED&quot;;&#xA;String KEY = &quot;YOUR_API_KEY&quot;;&#xA;String DATASTREAM1 = &quot;YOUR_DATASTREAM1_NAME&quot;;&#xA;Int VALUE1 = YOUR_VALUE1;&#xA;String DATASTREAM2 = &quot;YOUR_DATASTREAM2_NAME&quot;;&#xA;Int VALUE2 = YOUR_VALUE2;&#xA;&#xA;void send2Cosm()&#xA;{&#xA;mySerial.println(&quot;AT+CGATT?&quot;);&#xA;delay(100);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CSTT=\&quot;CMNET\&quot;&quot;);//start task and setting the APN,&#xA;delay(1000);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CIICR&quot;);//bring up wireless connection&#xA;delay(300);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CIFSR&quot;);//get local IP adress&#xA;delay(2000);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CIPSPRT=0&quot;);&#xA;delay(3000);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CIPSTART=\&quot;tcp\&quot;,\&quot;api.cosm.com\&quot;,\&quot;8081\&quot;&quot;);//start up the connection&#xA;delay(2000);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;AT+CIPSEND&quot;);//begin send data to remote server&#xA;delay(4000);&#xA;ShowSerialData();&#xA;&#xA;mySerial.print(&quot;{\&quot;method\&quot;: \&quot;put\&quot;,\&quot;resource\&quot;: \&quot;/feeds/&quot; + FEED + &quot;/\&quot;,\&quot;params\&quot;&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;: {},\&quot;headers\&quot;: {\&quot;X-ApiKey\&quot;:&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;\&quot;&quot; + KEY + &quot;\&quot;},\&quot;body\&quot;:&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot; {\&quot;version\&quot;: \&quot;1.0.0\&quot;,\&quot;datastreams\&quot;:&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;[{\&quot;id\&quot;: \&quot;&quot; + DATASTREAM1 + &quot;\&quot;,\&quot;current_value\&quot;: \&quot;&quot;);&#xA;mySerial.print(VALUE1);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.print(&quot;\&quot;},{\&quot;id\&quot;: \&quot;&quot; + DATASTREAM2 + &quot;\&quot;,\&quot;current_value\&quot;: \&quot;&quot;);&#xA;mySerial.print(VALUE2);&#xA;delay(500);&#xA;ShowSerialData();&#xA;mySerial.println(&quot;\&quot;}]}}&quot;);&#xA;delay(500);&#xA;ShowSerialData();&#xA;&#xA;mySerial.println((char)26); //sending = ctrl+z&#xA;delay(5000);//waitting for reply, important! the time is base on the condition of internet &#xA;mySerial.println();&#xA;&#xA;ShowSerialData();&#xA;&#xA;mySerial.println(&quot;AT+CIPCLOSE&quot;);//close the connection&#xA;delay(100);&#xA;ShowSerialData();&#xA;&#xA;}&#xA;&#xA;&#xA;void ShowSerialData()&#xA;{&#xA;while(mySerial.available()!=0)&#xA;Serial.write(mySerial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To answer part of my question: no, the colons aren't a String operator, they're part of the HTML. Here's an example of the formed URL that gets sent:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;method&quot;: &quot;put&quot;,&quot;resource&quot;: &quot;/feeds/YOUR_FEED/&quot;,&quot;params&quot;: {},&quot;headers&quot;: {&quot;X-ApiKey&quot;:&quot;YOUR_API&quot;},&quot;body&quot;: {&quot;version&quot;: &quot;1.0.0&quot;,&quot;datastreams&quot;:[{&quot;id&quot;: &quot;DATASTREAM1&quot;,&quot;current_value&quot;: &quot;VALUE1&quot;},{&quot;id&quot;: &quot;DATASTREAM2&quot;,&quot;current_value&quot;: &quot;VALUE2&quot;}]}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code updates my feed but after several hours the updates stop. I'm still troubleshooting this new problem so I'm not 100% sure that this code is good. I will post back if the problem's in here. &lt;/p&gt;&#xA;" OwnerUserId="18901" LastActivityDate="2016-03-13T08:54:28.770" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21755" PostTypeId="2" ParentId="21721" CreationDate="2016-03-13T09:03:11.647" Score="1" Body="&lt;p&gt;Rather than manually putting all of the periodic-table data into a program in just the right form (which would be quite tedious), you could use a program on your software development computer to read periodic-table data files and create the corresponding C-program data structures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The python program shown below gives an example of that approach.  (It contains a data table in a list of tuples, ie doesn't read data; but data like that in the tuples &lt;em&gt;can&lt;/em&gt; be read from a file, or with a bit of programming, from a &lt;a href=&quot;http://www.meta-synthesis.com/webbook/35_pt/pt_database.php?PT_id=194&quot; rel=&quot;nofollow&quot;&gt;spreadsheet of periodic-table data&lt;/a&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The python program opens file &lt;code&gt;datatables.data.c&lt;/code&gt; for output, then it writes C statements into that file, which subsequently can be added into a sketch, &lt;code&gt;datatables.ino&lt;/code&gt;, as shown later.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Python program, &lt;code&gt;densconmelt.py&lt;/code&gt;:&lt;/h1&gt;&#xA;&#xA;&lt;pre class=&quot;lang-py prettyprint-override&quot;&gt;&lt;code&gt;#!/usr/bin/python&#xA;# From data as shown in slide 19 of 39 at&#xA;# http://www.slideshare.net/bravetiger1964/lecture-11-metals-and-its-alloys-their-crystalline-structure-and-properties&#xA;&#xA;# Physical Properties of several Metals and Alloys.&#xA;#   Metal or Alloy&#xA;#     Density (kg/m3) &#xA;#       Thermal conductivity W/(m*K) (t=20 C)&#xA;#         Melting point (Tm) (C)&#xA;adtm = [&#xA;    ('Aluminum', '2712', '204', '659'),&#xA;    ('Aluminum alloys', '7700-8700', '120-180', '462-671'),&#xA;    ('Brass-casting', '8400-8700',  '',  '990-1025'),&#xA;    ('Red Brass',     '8746', '159', '1027'),&#xA;    ('Yellow Brass',  '8470', '115', '930'),&#xA;    ('Bronze - lead', '7700-8700', '',  '850-1000'),&#xA;    ('Copper', '8930', '385', '1083'),&#xA;    ('Gold', '19320',  '318', '1063'),&#xA;    ('Pure iron',     '6800-7800', '72', '1530'),&#xA;    ('Cast Iron',     '7850', '', 'Gray 1370, Malleable 1360, White 1370'),&#xA;    ('Wrought Iron',  '7750', '58', '1450'),&#xA;    ('Lead',  '11340', '35.3', '327'),&#xA;    ('Nickel', '8800', '89', '1453'),&#xA;    ('Silver', '10490', '406', '961'),&#xA;    ('Solder 50/50 Pb/Sn', '8885', '', ''),&#xA;    ('Non-alloyed and low-alloy steel', '7850', '53.6', '1480'),&#xA;    ('Stainless Steel', '7480-8000', '12.11-45.0', '1430-1500'),&#xA;    ('Tin',  '7280', '63', '232'),&#xA;    ('Zinc', '7135', '115', '419')&#xA;    ]&#xA;&#xA;locs = []&#xA;# To track current offset into datatext, and longest single string part&#xA;used = longy = 0 &#xA;with open('datatables.data.c', 'w') as fo:&#xA;    fo.write('#ifdef ADDTABLE  // Disallows separate compile\n')&#xA;    fo.write('const char datatext[] PROGMEM = \n  ')&#xA;    for i in adtm:&#xA;        #a, d, t, m = i&#xA;        #print '{:20} {:12} {:12} {:12}'.format(a, d, t, m)&#xA;        for x in i:&#xA;            locs.append(used)&#xA;            used += len(x)+1&#xA;            longy = max(longy, len(x)+1) &#xA;            fo.write('&quot;{}\\0&quot; '.format(x))&#xA;        fo.write('\n  ')&#xA;    fo.write(';\nconst int offsets[] = {')&#xA;    for o in locs:&#xA;        fo.write(' {},'.format(o))&#xA;    fo.write(' {}{};\n'.format(used, '}'))&#xA;    fo.write('enum {} LONGSTR={}, ITEMS={}{};\n'.format('{', longy, len(adtm), '}'))&#xA;    fo.write('char buffy[LONGSTR];\n')&#xA;    fo.write('#endif\n')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, the out-commented lines &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        #a, d, t, m = i&#xA;        #print '{:20} {:12} {:12} {:12}'.format(a, d, t, m)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be an appropriate place to modify the python program so it prints out how the lines will look when displayed on the 4x20 LCD.  Rather than repeatedly downloading files to your Uno or Mega just to fix lines that are a little too long, or misaligned, etc., you could make the python program show the display appearance in the same loop where it generates data structures to be included in the Arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if you aren't familiar with the &lt;code&gt;with&lt;/code&gt; construct, see the &lt;em&gt;With Statement&lt;/em&gt; section of pythonforbeginners.com's &lt;a href=&quot;http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python&quot; rel=&quot;nofollow&quot;&gt;Reading and Writing Files in Python&lt;/a&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;What the Python program generates:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Some lines from the file generated by &lt;code&gt;densconmelt.py&lt;/code&gt; are shown below, interspersed with comments about what those lines do.  Later, the whole of the file &lt;code&gt;datatables.data.c&lt;/code&gt; is shown.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef ADDTABLE  // Disallows separate compile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line is a preprocessor statement to keep &lt;code&gt;datatables.data.c&lt;/code&gt; from being compiled alone.  During compilations, the Arduino IDE will copy &lt;code&gt;datatables.ino&lt;/code&gt; and &lt;code&gt;datatables.data.c&lt;/code&gt; into a temporary work directory and will compile each of them.  However, the body of &lt;code&gt;datatables.data.c&lt;/code&gt; won't compile correctly alone (outside the sketch), so is guarded from causing compile errors by surrounding it with &lt;code&gt;#ifdef ... #endif&lt;/code&gt; lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char datatext[] PROGMEM =&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line tells the C compiler to store the value of &lt;code&gt;datatext[]&lt;/code&gt; into program memory.  It also says the value and content of &lt;code&gt;datatext&lt;/code&gt; are constant, and &lt;code&gt;datatext&lt;/code&gt; is an array of characters.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &quot;Aluminum\0&quot; &quot;2712\0&quot; &quot;204\0&quot; &quot;659\0&quot; &#xA;  &quot;Aluminum alloys\0&quot; &quot;7700-8700\0&quot; &quot;120-180\0&quot; &quot;462-671\0&quot; &#xA;  &quot;Brass-casting\0&quot; &quot;8400-8700\0&quot; &quot;\0&quot; &quot;990-1025\0&quot; &#xA;...&#xA;  &quot;Tin\0&quot; &quot;7280\0&quot; &quot;63\0&quot; &quot;232\0&quot; &#xA;  &quot;Zinc\0&quot; &quot;7135\0&quot; &quot;115\0&quot; &quot;419\0&quot; &#xA;  ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those lines each give the name of a metal or alloy, its density, its thermal conductivity, and its melting point.  Values are strings instead of numbers, so ranges and missing values can be handled.  Note that by rules of C, strings with no operators between them concatenate together.  For example, the line &lt;code&gt;&quot;Tin\0&quot; &quot;7280\0&quot; &quot;63\0&quot; &quot;232\0&quot;&lt;/code&gt; is equivalent to the line &lt;code&gt;&quot;Tin\07280\063\0232\0&quot;&lt;/code&gt;.  Note, each &lt;code&gt;\0&lt;/code&gt; is a null character at the end of a substring.  If space were short, one could leave out all the &lt;code&gt;\0&lt;/code&gt;s and compute string lengths as differences of adjacent entries in &lt;code&gt;offsets[]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int offsets[] = { 0, 9, 14, ... 524, 528, 533, 538, 542, 546};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line tells where each substring begins, within the big string  &lt;code&gt;datatext&lt;/code&gt;.  This method of storing offsets and substrings takes 12 bytes per item, ie 4·2 bytes for 4 &lt;code&gt;int&lt;/code&gt; values plus 4 bytes for null characters.  There are half a dozen ways to reduce the overhead to 5 to 10 bytes per item, but the most effective simple change would be to put &lt;code&gt;offsets[]&lt;/code&gt; in PROGMEM.  In addition, one might change some fields from strings to integers or floats, which would not need null separators or offset values if placed at fixed offsets at the front of an item's record.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { LONGSTR=38, ITEMS=19};&#xA;char buffy[LONGSTR];&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those lines create two constants, LONGSTR and ITEMS, telling the length of the longest substring and the number of items; allocate a buffer, as long as the longest substring; and close the guarding &lt;code&gt;#ifdef ... #endif&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;&lt;code&gt;datatables.data.c&lt;/code&gt;, shown whole:&lt;/h1&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#ifdef ADDTABLE  // Disallows separate compile&#xA;const char datatext[] PROGMEM = &#xA;  &quot;Aluminum\0&quot; &quot;2712\0&quot; &quot;204\0&quot; &quot;659\0&quot; &#xA;  &quot;Aluminum alloys\0&quot; &quot;7700-8700\0&quot; &quot;120-180\0&quot; &quot;462-671\0&quot; &#xA;  &quot;Brass-casting\0&quot; &quot;8400-8700\0&quot; &quot;\0&quot; &quot;990-1025\0&quot; &#xA;  &quot;Red Brass\0&quot; &quot;8746\0&quot; &quot;159\0&quot; &quot;1027\0&quot; &#xA;  &quot;Yellow Brass\0&quot; &quot;8470\0&quot; &quot;115\0&quot; &quot;930\0&quot; &#xA;  &quot;Bronze - lead\0&quot; &quot;7700-8700\0&quot; &quot;\0&quot; &quot;850-1000\0&quot; &#xA;  &quot;Copper\0&quot; &quot;8930\0&quot; &quot;385\0&quot; &quot;1083\0&quot; &#xA;  &quot;Gold\0&quot; &quot;19320\0&quot; &quot;318\0&quot; &quot;1063\0&quot; &#xA;  &quot;Pure iron\0&quot; &quot;6800-7800\0&quot; &quot;72\0&quot; &quot;1530\0&quot; &#xA;  &quot;Cast Iron\0&quot; &quot;7850\0&quot; &quot;\0&quot; &quot;Gray 1370, Malleable 1360, White 1370\0&quot; &#xA;  &quot;Wrought Iron\0&quot; &quot;7750\0&quot; &quot;58\0&quot; &quot;1450\0&quot; &#xA;  &quot;Lead\0&quot; &quot;11340\0&quot; &quot;35.3\0&quot; &quot;327\0&quot; &#xA;  &quot;Nickel\0&quot; &quot;8800\0&quot; &quot;89\0&quot; &quot;1453\0&quot; &#xA;  &quot;Silver\0&quot; &quot;10490\0&quot; &quot;406\0&quot; &quot;961\0&quot; &#xA;  &quot;Solder 50/50 Pb/Sn\0&quot; &quot;8885\0&quot; &quot;\0&quot; &quot;\0&quot; &#xA;  &quot;Non-alloyed and low-alloy steel\0&quot; &quot;7850\0&quot; &quot;53.6\0&quot; &quot;1480\0&quot; &#xA;  &quot;Stainless Steel\0&quot; &quot;7480-8000\0&quot; &quot;12.11-45.0\0&quot; &quot;1430-1500\0&quot; &#xA;  &quot;Tin\0&quot; &quot;7280\0&quot; &quot;63\0&quot; &quot;232\0&quot; &#xA;  &quot;Zinc\0&quot; &quot;7135\0&quot; &quot;115\0&quot; &quot;419\0&quot; &#xA;  ;&#xA;const int offsets[] = { 0, 9, 14, 18, 22, 38, 48, 56, 64, 78, 88, 89, 98, 108, 113, 117, 122, 135, 140, 144, 148, 162, 172, 173, 182, 189, 194, 198, 203, 208, 214, 218, 223, 233, 243, 246, 251, 261, 266, 267, 305, 318, 323, 326, 331, 336, 342, 347, 351, 358, 363, 366, 371, 378, 384, 388, 392, 411, 416, 417, 418, 450, 455, 460, 465, 481, 491, 502, 512, 516, 521, 524, 528, 533, 538, 542, 546};&#xA;enum { LONGSTR=38, ITEMS=19};&#xA;char buffy[LONGSTR];&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Sketch to get item data from program memory and display it:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;We've used &lt;code&gt;densconmelt.py&lt;/code&gt; to generate &lt;code&gt;datatables.data.c&lt;/code&gt; as above, and now will show a sketch that gets an item's data out of program memory and displays it, whenever the sketch receives an item number via Serial input.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sketch that accepts a number via serial input, and responds with&#xA;// two lines of data via serial output.  The reply-data consists of an&#xA;// Alloy name on the first line, and Density, Thermal conductivity,&#xA;// and Melting point on the next line.&#xA;&#xA;// See http://arduiniana.org/libraries/streaming/ for Streaming library&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;// This sets up datatext in PROGMEM; offsets[]; buffy; LONGSTR; ITEMS&#xA;#define ADDTABLE&#xA;#include &quot;./datatables.data.c&quot;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);         // init serial port&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial &amp;lt;&amp;lt; &quot;Please enter item number from 1 to &quot; &amp;lt;&amp;lt; _DEC(ITEMS) &amp;lt;&amp;lt; &quot;: &quot;;&#xA;  int item = 0;&#xA;  while (1) {&#xA;    while (!Serial.available()) {}; // Wait for a character&#xA;    int c = Serial.read();&#xA;    if (c == '\n') break;&#xA;    item = 10*item + c - '0';&#xA;  }&#xA;  if (item &amp;lt; 1 || item &amp;gt; ITEMS) {&#xA;    Serial &amp;lt;&amp;lt; item &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; item &amp;lt;&amp;lt; &quot; is out of range -- try again.\n&quot;;&#xA;    return;&#xA;  }&#xA;  // Display specified item's title on first line&#xA;  strcpy_P(buffy, datatext + offsets[item*4-4]);&#xA;  Serial &amp;lt;&amp;lt; item &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; &quot;Item #&quot; &amp;lt;&amp;lt; item &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; buffy &amp;lt;&amp;lt; endl;&#xA;  // Show other data items on next line&#xA;  strcpy_P(buffy, datatext + offsets[item*4-3]);&#xA;  Serial &amp;lt;&amp;lt; &quot;Density &quot; &amp;lt;&amp;lt; buffy;&#xA;  strcpy_P(buffy, datatext + offsets[item*4-2]);&#xA;  Serial &amp;lt;&amp;lt; &quot;   Thermal cond. &quot; &amp;lt;&amp;lt; buffy;&#xA;  strcpy_P(buffy, datatext + offsets[item*4-1]);&#xA;  Serial &amp;lt;&amp;lt; &quot;   Melt@ &quot; &amp;lt;&amp;lt; buffy &amp;lt;&amp;lt; &quot; C&quot; &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, for a description of &lt;code&gt;strcpy_P()&lt;/code&gt; arguments, see nongnu.org's &lt;strong&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;avr/pgmspace.h : Program Space Utilities&lt;/a&gt;&lt;/strong&gt; page.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See arduino.cc's &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;PROGMEM&lt;/a&gt; page for a cursory overview of PROGMEM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See avrfreaks.net's &lt;a href=&quot;http://www.avrfreaks.net/forum/tut-c-gcc-and-progmem-attribute?page=all&quot; rel=&quot;nofollow&quot;&gt;GCC and the PROGMEM Attribute&lt;/a&gt; page for detailed coverage of PROGMEM, and see Nick Gammon's &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;Putting constant data into program memory (PROGMEM)&lt;/a&gt; page as well.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Example of program output, as in Serial Monitor box:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Following is an example of program output as shown in the Serial Monitor box after I typed several numbers into the input line and pressed enter after each.   (Note, at the bottom of the Serial Monitor box, set Line Ending to &lt;code&gt;Newline&lt;/code&gt; and data rate to 115200 bps.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Please enter item number from 1 to 19: 18&#xA;Item #18, Tin&#xA;Density 7280   Thermal cond. 63   Melt@ 232 C&#xA;&#xA;Please enter item number from 1 to 19: 19&#xA;Item #19, Zinc&#xA;Density 7135   Thermal cond. 115   Melt@ 419 C&#xA;&#xA;Please enter item number from 1 to 19: 20&#xA;20 is out of range -- try again.&#xA;Please enter item number from 1 to 19: -2220&#xA;-2220 is out of range -- try again.&#xA;Please enter item number from 1 to 19: 2&#xA;Item #2, Aluminum alloys&#xA;Density 7700-8700   Thermal cond. 120-180   Melt@ 462-671 C&#xA;&#xA;Please enter item number from 1 to 19: 0&#xA;0 is out of range -- try again.&#xA;Please enter item number from 1 to 19: 5&#xA;Item #5, Yellow Brass&#xA;Density 8470   Thermal cond. 115   Melt@ 930 C&#xA;&#xA;Please enter item number from 1 to 19: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch echoes the user-input item number twice, so it appears at the end of each input solicitation as well as in line labels like “Item #5, Yellow Brass”. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-13T09:38:41.553" LastActivityDate="2016-03-13T09:38:41.553" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21756" PostTypeId="2" ParentId="21721" CreationDate="2016-03-13T09:10:19.570" Score="0" Body="&lt;p&gt;i think you might have to buy a mega(probably more expensive!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i also fear someone putting countless nights into coding (preferably on pc for me, because 1: sketch is only available as an ancient version on raspberrypi. &amp;amp; 2: easier transfer of code.)&lt;/p&gt;&#xA;" OwnerUserId="19221" LastActivityDate="2016-03-13T09:10:19.570" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21759" PostTypeId="2" ParentId="21726" CreationDate="2016-03-13T12:27:20.780" Score="0" Body="&lt;p&gt;The simplest way to do this would be to host a webpage with the buttons on the Yùn itself, like for example &lt;a href=&quot;http://www.instructables.com/id/Arduino-Webserver-Control-Lights-Relays-Servos-etc/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this here&lt;/a&gt;. There are loads of examples for stuff like this out there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To access it &quot;remotely&quot; - I presume you mean from anywhere on the internet - you would have to forward a port from your home router to the Yùn, &lt;a href=&quot;http://www.pcworld.com/article/244314/how_to_forward_ports_on_your_router.html&quot; rel=&quot;nofollow&quot;&gt;like this&lt;/a&gt;. This will make the Yùn accessible from the internet. You only have to know your outside address (Google: &quot;Find my IP&quot;) and then you can access your arduino from all over the world.&lt;/p&gt;&#xA;" OwnerUserId="19227" LastActivityDate="2016-03-13T12:27:20.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21760" PostTypeId="2" ParentId="3625" CreationDate="2016-03-13T12:48:58.030" Score="3" Body="&lt;p&gt;What is connected to LCD pin 3? Pin 3 is the contrast V0 and needs to be connected with a 10 KOhm potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some LCD's need a negative contrast voltage, check the datasheet of the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the contrast voltage is not correct the display will stay blank. &#xA;I came across the same problem until i saw the negative voltage must be applied :-)&lt;/p&gt;&#xA;" OwnerUserId="19228" LastEditorUserId="2944" LastEditDate="2016-03-17T14:14:31.087" LastActivityDate="2016-03-17T14:14:31.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21761" PostTypeId="1" CreationDate="2016-03-13T13:18:14.137" Score="4" ViewCount="2014" Body="&lt;p&gt;I'm brand new to this community, and in electronics as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a software developer and I want to start a new journey with a project in mind: I want to control a 5 meters addressable LED strip for my living-room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need all the components for this project... I already know eclipse and Java world, but I need help in choosing the components for the project:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;which Arduino (starter package maybe?)&lt;/li&gt;&#xA;&lt;li&gt;LED strip (&lt;code&gt;smd 5050&lt;/code&gt; on &lt;code&gt;sw2812b&lt;/code&gt;, &lt;code&gt;sk6812&lt;/code&gt;, &lt;code&gt;APA104&lt;/code&gt;...) more than 60 LEDs/m &lt;/li&gt;&#xA;&lt;li&gt;Power Supply for the project&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can you point me to the right direction, posts that can be useful to me, so I can start on good basis?&lt;/p&gt;&#xA;" OwnerUserId="19229" LastEditorUserId="10794" LastEditDate="2016-03-14T19:40:36.437" LastActivityDate="2017-09-20T12:59:03.383" Title="RGBW LED strip: which components are required?" Tags="|rgb-led|eclipse|neopixel|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21762" PostTypeId="1" CreationDate="2016-03-13T13:29:34.010" Score="1" ViewCount="1560" Body="&lt;p&gt;I am pretty new to Arduino and programming too. &#xA;I want to sweep a servo using DIP switch. At the moment, I use 4 position DIP switch. To each of the switches, I want to set the number of times the servo has to run. Eg., Pos 1 of DIP switch says, sweep for 5 times. Pos 2 says, sweeps for 10 times etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;  &#xA;int pos = 0; &#xA;int count = 0;   // might need later&#xA;int runXTimes = 0;&#xA;&#xA;#define S1 2&#xA;#define S2 3&#xA;#define S3 4&#xA;#define S4 5&#xA;&#xA;int s1state = HIGH;&#xA;int s2state = HIGH;&#xA;int s3state = HIGH;&#xA;int s4state = HIGH;&#xA;&#xA;&#xA;void setup() {&#xA;   myservo.attach(9);&#xA;   pinMode(S1, INPUT_PULLUP);&#xA;   pinMode(S2, INPUT_PULLUP);&#xA;   pinMode(S3, INPUT_PULLUP);&#xA;   pinMode(S4, INPUT_PULLUP);&#xA;   pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;   s1state = digitalRead(S1);&#xA;   s2state = digitalRead(S2);&#xA;   s3state = digitalRead(S3);&#xA;   s4state = digitalRead(S4);&#xA;&#xA;&#xA;   // Servo control through Switch 1&#xA;   if (s1state == LOW) {     // read the input pin&#xA;      for (int runXTimes = 0; runXTimes &amp;lt; 5; runXTimes++) {    // Servo to     sweep for 5 times&#xA;         for (pos = 0; pos &amp;lt;= 80; pos += 1)  // goes from 0 degrees to 80 degrees in steps of  degree&#xA;&#xA;         {                                   &#xA;            myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;            delay(5);&#xA;         }&#xA;&#xA;         for(pos = 80; pos&amp;gt;=0; pos-=1)     // goes from 80 degrees to 0 degrees&#xA;         {                               &#xA;            myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;            delay(5);&#xA;         }&#xA;&#xA;      }&#xA;&#xA;   }&#xA;&#xA;   // Servo control through Switch 2. Used servo detach here&#xA;   else if (s2state == LOW) {  // read the input pin&#xA;      for (int runXTimes = 0; runXTimes &amp;lt; 10; runXTimes++) {  // Servo to sweep for 10 times&#xA;         for (pos = 0; pos &amp;lt;= 80; pos += 1)  // goes from 0 degrees to 80 degrees in steps of  degree&#xA;         {                                  &#xA;            myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;            delay(5); &#xA;         }&#xA;&#xA;         for(pos = 80; pos&amp;gt;=0; pos-=1)     // goes from 80 degrees to 0 degrees&#xA;         {                               &#xA;            myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;            delay(5);  &#xA;         }&#xA;&#xA;      }&#xA;      myservo.detach();&#xA;   }&#xA;&#xA;   // Servo control through Switch 3&#xA;   else if (s3state == LOW) {  // read the input pin&#xA;      for (pos = 0; pos &amp;lt;= 80; pos += 1)  // goes from 0 degrees to 80 degrees in steps of  degree&#xA;      {                                  // &#xA;         myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;         delay(5); &#xA;      }&#xA;&#xA;      for(pos = 80; pos&amp;gt;=0; pos-=1)     // goes from 80 degrees to 0 degrees&#xA;      {                               &#xA;         myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;         delay(5);  &#xA;      }&#xA;   }&#xA;&#xA;   // Servo control through Switch 4&#xA;   else if (s4state == LOW) {  // read the input pin&#xA;      for (pos = 0; pos &amp;lt;= 80; pos += 1)  // goes from 0 degrees to 80 degrees  in steps of  degree&#xA;      {                                 &#xA;         myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;&#xA;         delay(5); &#xA;      }&#xA;&#xA;      for(pos = 80; pos&amp;gt;=0; pos-=1)     // goes from 80 degrees to 0 degrees&#xA;      {                               &#xA;         myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;         delay(5);  &#xA;      }&#xA;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actions that happen with the above code are:&#xA;1) Servo control through Switch 1 - If I switch ON (0) and then OFF (1) immediately, the servo sweeps for 5 times. Works more like a button switch. If I switch ON and OFF (immediately) again, I am able to sweep 5 times again. But, if I leave the switch in 1, the sweep does not stop after 5 times.&lt;br&gt;&#xA;2) Servo control through Switch 2: If I switch ON, the servo sweeps for 10 times and stops as per my interest. But, if I change the switch to 0 and 1 again, the sequence does not start. In fact, no other switch works. I need to power OFF the Arduino to run the program again. &#xA;3) Servo control through Switch 3 (= switch 4): If my switch is 1, the servo sweeps. If my switch is 0, the servo stops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you please suggest:&#xA;1) How to write the code so that my servo sweeps only for the set number of times even when the switch is in 1 always or whenever I toggle between 0 and 1?&#xA;2) I do not want to use serial communication (or typically a PC). Is it possible to interface a 7-segment  or LCD to display the number of sweeps completed or still left. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance. &lt;/p&gt;&#xA;" OwnerUserId="19230" LastEditorUserId="313" LastEditDate="2016-03-13T15:33:07.317" LastActivityDate="2016-12-10T12:24:14.097" Title="Servo control using DIP switch" Tags="|programming|servo|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21764" PostTypeId="2" ParentId="21761" CreationDate="2016-03-13T14:57:48.730" Score="3" Body="&lt;p&gt;I like the &lt;code&gt;ws2812&lt;/code&gt; RGB LEDs with integrated controller. They can be found on &lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices&quot; rel=&quot;nofollow&quot;&gt;adafruit.com&lt;/a&gt;, e.g. here: &lt;a href=&quot;https://www.adafruit.com/products/1487&quot; rel=&quot;nofollow&quot;&gt;Adafruit NeoPixel NeoMatrix 8x8&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some good tutorials on adafruit.com:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-neopixel-uberguide/overview&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Choosing your Arduino you have to keep in Mind that the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardDue&quot; rel=&quot;nofollow&quot;&gt;Arduino Due&lt;/a&gt; runs at 3.3 V, while the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega&lt;/a&gt; runs at 5 V. The &lt;code&gt;ws2812&lt;/code&gt;. But you can use a &lt;a href=&quot;https://www.adafruit.com/product/1787&quot; rel=&quot;nofollow&quot;&gt;level shifter&lt;/a&gt; to connect an Arduino Due to the &lt;code&gt;ws2812&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Arduino is powered via USB, the LED matrices / stripes need their own power supply, but a DC 5V wall plug (something like a cell phone charger) will do the work (check the max. ampere ratings to be high enough for your LEDs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A starter package depends on what you already have. Some &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00M5WLZDW&quot; rel=&quot;nofollow&quot;&gt;jumper cables&lt;/a&gt; are always good to have, basic tools for electronics as well, e.g. a soldering iron or some &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B004RXKWDQ&quot; rel=&quot;nofollow&quot;&gt;prototyping board&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="15569" LastActivityDate="2016-03-13T14:57:48.730" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21765" PostTypeId="2" ParentId="21762" CreationDate="2016-03-13T15:38:31.373" Score="0" Body="&lt;p&gt;If you put the sweep-code in the setup function, it would execute once (because setup() is only called once) and you would see what you expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, as it is in the loop() function, it executes each time the loop() function executes - that is the point of the loop() function. As another alternative, you could put an infinite- or forever loop &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(;;)&#xA;   ;    // program hangs here forever&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;at the end of the loop() function to prevent it returning and getting called again. Either way, you would see a single pass over the steps you coded.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-13T15:38:31.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21766" PostTypeId="2" ParentId="16383" CreationDate="2016-03-13T15:49:01.740" Score="0" Body="&lt;p&gt;It is quite a lot simpler to obtain an &lt;a href=&quot;https://www.sparkfun.com/products/9718&quot; rel=&quot;nofollow&quot;&gt;FTDI USB - TTL Serial cable&lt;/a&gt;. (The link goes to the American supplier, Sparkfun, but such cables are available from many online suppliers.) They are typically made with a 6-pin female header instead of a USB B connector; you may have to make up that part yourself, if it is important to you. If you only need USB functionality for programming, one cable can serve any number of boards (one at a time, of course), no need to build it into each board.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-14T12:48:11.263" LastActivityDate="2016-03-14T12:48:11.263" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21769" PostTypeId="1" AcceptedAnswerId="23056" CreationDate="2016-03-13T16:41:37.863" Score="2" ViewCount="4403" Body="&lt;p&gt;I followed &lt;a href=&quot;http://www.instructables.com/id/Programming-an-ATTiny13A-using-Arduino-servo-int/step3/Programming/&quot; rel=&quot;nofollow&quot;&gt;this guide&lt;/a&gt; to program AtTiny using Arduino as ISP. The problem is that it has some file missing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;java.io.FileNotFoundException: C:\...\arduino-1.6.8\hardware\attiny\variants\platform.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The attiny directory is &lt;a href=&quot;https://github.com/tekstop/attiny/tree/Arduino1&quot; rel=&quot;nofollow&quot;&gt;clone of this repository&lt;/a&gt;. How do I make it work?&lt;/p&gt;&#xA;" OwnerUserId="2955" LastActivityDate="2016-06-11T23:26:00.107" Title="Adding Attiny to Arduino IDE - attiny\variants\platform.txt file missing" Tags="|arduino-ide|attiny|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21770" PostTypeId="2" ParentId="21769" CreationDate="2016-03-13T16:47:28.590" Score="1" Body="&lt;p&gt;The way of adding boards has changed in the newer version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try finding a tutorial for 1.6, or download the older &lt;a href=&quot;http://arduino.cc/download_handler.php?f=/arduino-1.0.6-windows.exe&quot; rel=&quot;nofollow&quot;&gt;1.0 version&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-03-13T17:13:50.327" LastActivityDate="2016-03-13T17:13:50.327" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21771" PostTypeId="1" AcceptedAnswerId="21772" CreationDate="2016-03-13T15:28:02.387" Score="0" ViewCount="2597" Body="&lt;p&gt;I'm rather disappointed because I just bought arduino and I am unable to upload any projects. The error I get is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\COM3&quot;: Časový limit semaforu vypršel.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can be translated as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\COM3&quot;: Semaphore time out&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I expected to brute-force all available ports to see which one is reserved for arduino? How can I, on Windows 7, quickly determine which port to use given that the IDE for some reason can't do that for me.&lt;/p&gt;&#xA;" OwnerUserId="2955" OwnerDisplayName="Tomáš Zato" LastActivityDate="2016-03-13T21:54:10.923" Title="How can I easily see which COM port is used by Arduino?" Tags="|windows|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21772" PostTypeId="2" ParentId="21771" CreationDate="2016-03-13T15:58:29.747" Score="2" Body="&lt;p&gt;Start | Control Panel | System | Device Manager | Ports (COM &amp;amp; LTP).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Watch the list change as you plug / unplug the Arduino. The new port is the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="transistor" LastActivityDate="2016-03-13T15:58:29.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21773" PostTypeId="1" AcceptedAnswerId="31905" CreationDate="2016-03-13T17:17:51.783" Score="0" ViewCount="156" Body="&lt;p&gt;With the new 1.6.x version of the Arduino IDE, obscurity of adding new chips has gained new level. It now seems you have to add HTTP links to some JSON files in single-line edit field in settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did so and to add AtTiny to Arduino IDE, I used this JSON file: &lt;a href=&quot;https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json&quot; rel=&quot;nofollow&quot;&gt;https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have AtTiny 13 however. It's same as the others, according to datasheet, but has different signature:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Expected signature for ATtiny45 is 1E 92 06&#xA;         Double check chip, or use -F to override this check.&#xA;Wrong microcontroller found.  Did you select the right board from the Tools &amp;gt; Board menu?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried to search ATTiny45 and the signature over the files - no success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I need is to add the ATTiny13 to the list so that I can finally actually do some programming, instead of being completely helpless.&lt;/p&gt;&#xA;" OwnerUserId="2955" LastEditorUserId="2955" LastEditDate="2016-12-04T16:10:48.253" LastActivityDate="2016-12-04T16:21:03.120" Title="Where are the chip configurations stored in IDE 1.6.x? How to modify them?" Tags="|arduino-ide|attiny|attiny13|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21774" PostTypeId="1" AcceptedAnswerId="21781" CreationDate="2016-03-13T18:12:12.363" Score="1" ViewCount="999" Body="&lt;p&gt;I am looking to take the analogRead Value of the x, y and z axis (at pins 0, 2 and 4) and if it's a motion state, perform a rainbow, cylone and cascade LED sequences using Adafruit Neopixel library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using serial connection, I saw that x,y,z axis are read at values of approximately 300.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the code it executed the three Neopixel sequences (redPin at pin 3, GreenPin at pin 5 and BluePin at pin 6) and then continues, even if there is no change of the accelerometer position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&#xA;I am using Arduino Trinket Pro 5V and working with the x-axis and RGB strip at pin 3 only to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &quot;WS2812_Definitions.h&quot;&#xA;&#xA;#define PIN1 3&#xA;#define LED_COUNT1 5&#xA;#define PIN2 5&#xA;#define LED_COUNT2 5&#xA;#define PIN3 6&#xA;#define LED_COUNT3 5&#xA;&#xA;// Create an instance of the Adafruit_NeoPixel class called &quot;leds&quot;.&#xA;// That'll be what we refer to from here on...&#xA;Adafruit_NeoPixel RedPin = Adafruit_NeoPixel(LED_COUNT1, PIN1, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel GreenPin = Adafruit_NeoPixel(LED_COUNT2, PIN2, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel BluePin = Adafruit_NeoPixel(LED_COUNT3, PIN3, NEO_GRB + NEO_KHZ800);&#xA;&#xA;const int sensorPinRed = A0;&#xA;const int sensorPinGreen = A2;&#xA;const int sensorPinBlue = A4;&#xA;&#xA;int analogValue = 0;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  RedPin.begin();  // Call this to start up the LED strip.&#xA;  //GreenPin.begin();&#xA;  //BluePin.begin();&#xA;  clearLEDs();   // This function, defined below, turns all LEDs off...&#xA;  RedPin.show();   // ...but the LEDs don't actually update until you call this.&#xA;  //GreenPin.show();&#xA;  //BluePin.show()}&#xA;&#xA;void loop()&#xA;{&#xA;  do{&#xA;   analogValue = analogRead(sensorPinRed);&#xA;  // Ride the Rainbow Road&#xA;  for (int i=0; i&amp;lt;LED_COUNT1*10; i++)&#xA;  {&#xA;    rainbow(i);&#xA;    delay(100);  // Delay between rainbow slides&#xA;  }&#xA;&#xA;  // Indigo cylon&#xA;  // Do a cylon (larson scanner) cycle 10 times&#xA;  for (int i=0; i&amp;lt;10; i++)&#xA;  {&#xA;    // cylon function: first param is color, second is time (in ms) between cycles&#xA;    cylon(INDIGO, 500);  // Indigo cylon eye!&#xA;  }&#xA;&#xA;  // A light shower of spring green rain&#xA;  // This will run the cascade from top-&amp;gt;bottom 20 times&#xA;  for (int i=0; i&amp;lt;20; i++)&#xA;  {&#xA;    // First parameter is the color, second is direction, third is ms between falls&#xA;    cascade(MEDIUMSPRINGGREEN, TOP_DOWN, 100); &#xA;  }&#xA;  } while (analogValue&amp;gt;300);&#xA;}&#xA;&#xA;// Implements a little larson &quot;cylon&quot; sanner.&#xA;// This'll run one full cycle, down one way and back the other&#xA;void cylon(unsigned long color, byte wait)&#xA;{&#xA;  // weight determines how much lighter the outer &quot;eye&quot; colors are&#xA;  const byte weight = 4;  &#xA;  // It'll be easier to decrement each of these colors individually&#xA;  // so we'll split them out of the 24-bit color value&#xA;  byte red = (color &amp;amp; 0xFF0000) &amp;gt;&amp;gt; 16;&#xA;  byte green = (color &amp;amp; 0x00FF00) &amp;gt;&amp;gt; 8;&#xA;  byte blue = (color &amp;amp; 0x0000FF);&#xA;&#xA;  // Start at closest LED, and move to the outside&#xA;  for (int i=0; i&amp;lt;=LED_COUNT1-1; i++)&#xA;  {&#xA;    clearLEDs();&#xA;    RedPin.setPixelColor(i, red, green, blue);  // Set the bright middle eye&#xA;    // Now set two eyes to each side to get progressively dimmer&#xA;    for (int j=1; j&amp;lt;3; j++)&#xA;    {&#xA;      if (i-j &amp;gt;= 0)&#xA;        RedPin.setPixelColor(i-j, red/(weight*j), green/(weight*j), blue/(weight*j));&#xA;      if (i-j &amp;lt;= LED_COUNT1)&#xA;        RedPin.setPixelColor(i+j, red/(weight*j), green/(weight*j), blue/(weight*j));&#xA;    }&#xA;    RedPin.show();  // Turn the LEDs on&#xA;    delay(wait);  // Delay for visibility&#xA;  }&#xA;&#xA;  // Now we go back to where we came. Do the same thing.&#xA;  for (int i=LED_COUNT1-2; i&amp;gt;=1; i--)&#xA;  {&#xA;    clearLEDs();&#xA;    RedPin.setPixelColor(i, red, green, blue);&#xA;    for (int j=1; j&amp;lt;3; j++)&#xA;    {&#xA;      if (i-j &amp;gt;= 0)&#xA;        RedPin.setPixelColor(i-j, red/(weight*j), green/(weight*j), blue/(weight*j));&#xA;      if (i-j &amp;lt;= LED_COUNT1)&#xA;        RedPin.setPixelColor(i+j, red/(weight*j), green/(weight*j), blue/(weight*j));&#xA;      }&#xA;&#xA;    RedPin.show();&#xA;    delay(wait);&#xA;  }&#xA;}&#xA;&#xA;// Cascades a single direction. One time.&#xA;void cascade(unsigned long color, byte direction, byte wait)&#xA;{&#xA;  if (direction == TOP_DOWN)&#xA;  {&#xA;    for (int i=0; i&amp;lt;LED_COUNT1; i++)&#xA;    {&#xA;      clearLEDs();  // Turn off all LEDs&#xA;      RedPin.setPixelColor(i, color);  // Set just this one&#xA;      RedPin.show();&#xA;      delay(wait);&#xA;    }&#xA;  }&#xA;  else&#xA;  {&#xA;    for (int i=LED_COUNT1-1; i&amp;gt;=0; i--)&#xA;    {&#xA;      clearLEDs();&#xA;      RedPin.setPixelColor(i, color);&#xA;      RedPin.show();&#xA;      delay(wait);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;// Sets all LEDs to off, but DOES NOT update the display;&#xA;// call leds.show() to actually turn them off after this.&#xA;void clearLEDs()&#xA;{&#xA;  for (int i=0; i&amp;lt;LED_COUNT1; i++)&#xA;  {&#xA;    RedPin.setPixelColor(i, 0);&#xA;  }&#xA;}&#xA;&#xA;// Prints a rainbow on the ENTIRE LED strip.&#xA;//  The rainbow begins at a specified position. &#xA;// ROY G BIV!&#xA;void rainbow(byte startPosition) &#xA;{&#xA;  // Need to scale our rainbow. We want a variety of colors, even if there&#xA;  // are just 10 or so pixels.&#xA;  int rainbowScale = 192 / LED_COUNT1;&#xA;&#xA;  // Next we setup each pixel with the right color&#xA;  for (int i=0; i&amp;lt;LED_COUNT1; i++)&#xA;  {&#xA;    // There are 192 total colors we can get out of the rainbowOrder function.&#xA;    // It'll return a color between red-&amp;gt;orange-&amp;gt;green-&amp;gt;...-&amp;gt;violet for 0-191.&#xA;    RedPin.setPixelColor(i, rainbowOrder((rainbowScale * (i + startPosition)) % 192));&#xA;  }&#xA;  // Finally, actually turn the LEDs on:&#xA;  RedPin.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15366" LastActivityDate="2017-12-09T16:21:36.510" Title="Accelerometer axis inputs driving three RGB LED strips - Trinket Pro 5V" Tags="|arduino-uno|analogread|accelerometer|rgb-led|neopixel|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21775" PostTypeId="2" ParentId="21773" CreationDate="2016-03-13T18:16:11.933" Score="0" Body="&lt;p&gt;You are importing a json file provided by someone for free.&lt;br&gt;&#xA;The best thing you can do is contribute by adding ATTiny13 to this repository.&lt;br&gt;&#xA;To do so:&lt;br&gt;&#xA;So go to github (create a account if you do not have one);&lt;br&gt;&#xA;create a fork of the repository.&lt;br&gt;&#xA;Add your ATTiny13 board to the boards.txt file.&lt;br&gt;&#xA;mod the json file to contain a new version and the attiny13.&lt;br&gt;&#xA;Test and if everything works fine&lt;br&gt;&#xA;Create a pull request&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-03-14T11:11:50.200" LastActivityDate="2016-03-14T11:11:50.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21776" PostTypeId="1" CreationDate="2016-03-13T18:46:31.007" Score="1" ViewCount="431" Body="&lt;p&gt;I want to make either an alarm clock or countdown timer whose alarm is loud enough to notice, but soft enough to not wake me up when asleep. My idea is to use the sound of an analog clock that I have - powered by a single AA 1.5V battery. I like this sound. So, I'd like to create an alarm or a timer that can turn on the power to this analog clock for a few minutes at least. Ideally, it would be something I could use daily for a couple hours without replacing the timer/alarm battery too often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked at these programmable relay timers: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00P0TZ5CY&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/dp/B00P0TZ5CY/&lt;/a&gt; but the voltage seems kindof overkill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also considered an arduino board, but I'd like to be able to set the time on the device without plugging it into a computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a developer, so I could do arduino programming if needed, but I don't know much about circuitry &amp;amp; hardware. I've also never done an arduino project, so I'm starting from 101.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas where I could start? The timer I mentioned above would be perfect if it didn't require 12V power. My knowledge is limited, so maybe that's less of a big deal than I think.&lt;/p&gt;&#xA;" OwnerUserId="19239" LastEditorUserId="15569" LastEditDate="2016-03-13T20:03:37.290" LastActivityDate="2016-03-13T20:58:45.067" Title="Timer to control 1.5V clock" Tags="|timers|relay|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21778" PostTypeId="2" ParentId="21744" CreationDate="2016-03-13T20:43:55.397" Score="1" Body="&lt;p&gt;You must have resistors in series with the LEDs. See &lt;a href=&quot;http://www.thebox.myzen.co.uk/Tutorial/LEDs.html&quot; rel=&quot;nofollow&quot;&gt;The care and feeding of LEDs&lt;/a&gt;. 330 ohms in series with each LED would be about right in your situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With no resistors you are drawing far too much current from the output pins. That would drop the voltage and the processor would reset. Thus it goes back to the default of 4 beats per measure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also damages both the processor and the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tell if the processor resets by putting extra code into &lt;code&gt;setup&lt;/code&gt;. For example, after setting the pins to outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for (int i = 0; i &amp;lt; 10; i++)&#xA;    {&#xA;    digitalWrite (3, HIGH);&#xA;    delay (200);&#xA;    digitalWrite (3, LOW);&#xA;    delay (200);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you see pin 3 flashing 10 times, you know the processor has reset.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think your problem now is that you have a floating input for the switch. When I tried your sketch, with a couple of modifications, it worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**************************************/&#xA;const int lowestPin = 1;//the lowest one attach to&#xA;const int speaker = 13;&#xA;int ts = 4;//how many beats you want&#xA;int count = 1;&#xA;const int keyPin = 12;&#xA;int buttonState = 0;&#xA;int bpm = 120;&#xA;/**************************************/&#xA;void setup()&#xA;{&#xA;  for (int thisPin = 1; thisPin &amp;lt;= ts; thisPin++)&#xA;  {&#xA;    pinMode(thisPin, OUTPUT); //initialize thisPin as an output&#xA;    pinMode(6, INPUT);&#xA;  }&#xA;  pinMode(keyPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;/****************************************/&#xA;void loop()&#xA;{&#xA;&#xA;  //iterate over the pins&#xA;  //turn the led on from lowest to the highest&#xA;&#xA;  if (digitalRead(keyPin) == LOW &amp;amp;&amp;amp; ts == 2) {&#xA;    ts = 3;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  else if (digitalRead(keyPin) == LOW &amp;amp;&amp;amp; ts == 3) {&#xA;    ts = 4;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  else if (digitalRead(keyPin) == LOW &amp;amp;&amp;amp; ts == 4)&#xA;  {&#xA;    ts = 2;&#xA;    delay(2000);&#xA;  }&#xA;&#xA;  for (int thisPin = 1; thisPin &amp;lt;= ts; thisPin++)&#xA;  {&#xA;&#xA;    bpm = pulseIn(6, HIGH);&#xA;    //bpm = 1000;&#xA;&#xA;    pinMode(speaker, OUTPUT);&#xA;    if (ts &amp;gt; 4)&#xA;    {&#xA;      if (count &amp;gt; 3)&#xA;        for (int a = 4; a &amp;lt;= ts; a++) {&#xA;          digitalWrite(a - 3, HIGH);&#xA;        }&#xA;    }&#xA;    else&#xA;      digitalWrite(thisPin, HIGH);&#xA;&#xA;    if (count == 1)&#xA;      tone(speaker, 1500, 100);&#xA;    else&#xA;      tone(speaker, 1000, 100);&#xA;&#xA;    unsigned long now = millis ();&#xA;    while (millis () - now &amp;lt; (bpm - 52))&#xA;      {&#xA;      // quit delay if switch pressed&#xA;      if (digitalRead(keyPin) == LOW)&#xA;        break;&#xA;      }&#xA;&#xA;    pinMode(speaker, INPUT);&#xA;    digitalWrite(thisPin, LOW);&#xA;&#xA;    count++;&#xA;    if (count &amp;gt; ts)&#xA;      count = 1;&#xA;&#xA;  } // end of for each pin&#xA;&#xA;} // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the input from the switch is now INPUT_PULLUP which means it is pulled HIGH by an internal resistor. Thus, the tests are now for &lt;code&gt;== LOW&lt;/code&gt; rather than &lt;code&gt;== HIGH&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, instead of a delay for the timing of the metronome, I changed it to testing &lt;code&gt;millis()&lt;/code&gt; and seeing if time is up. Otherwise you have to hold the switch down for the entire time that a cycle repeats.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-14T01:44:48.933" LastActivityDate="2016-03-14T01:44:48.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21779" PostTypeId="2" ParentId="21776" CreationDate="2016-03-13T20:58:45.067" Score="1" Body="&lt;p&gt;I suggest a simple setup (similar to my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow&quot;&gt;temperature and humidity sensor&lt;/a&gt; but less complex).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can run from 3 x AA batteries, and have an RTC clock to keep track of the time. You can use a MOSFET to turn on your analog clock when required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The processor can be asleep most of the time, using the watchdog timer to wake up and check the time from the RTC. Don't use an Arduino &quot;board&quot; unless you are running from a wall-wart because the voltage regulator, USB interface, and power LED, will consume too much power.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T20:58:45.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21780" PostTypeId="2" ParentId="21721" CreationDate="2016-03-13T20:59:57.430" Score="1" Body="&lt;p&gt;Expanding an answer from my comment on your question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First thing is to define a struct that holds all the data you want to&#xA;store and display for one element:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;struct Element {&#xA;    char symbol[3];&#xA;    char name[16];&#xA;    float mass;&#xA;    char electronic_state[9];&#xA;    // etc...&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do not store the atomic number, as it will be deduced from the index on&#xA;the array you will build. Each string in this struct (symbol, name...)&#xA;should be big enough to store the longest possible string, including the&#xA;final NULL terminator. The compiler will help you here: if you do not&#xA;allocate enough room, it will later say something like “&lt;em&gt;error:&#xA;initializer-string for array of chars is too long&lt;/em&gt;”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is obviously somewhat inefficient to allocate each string the maximum&#xA;possible length. I suggest you do this for the sake of simplicity, and&#xA;because I do not think you should be short on flash, even on an Uno. If&#xA;you really end up being short on flash, then I suggest you seriously&#xA;consider jwpat7's answer. It is somewhat complicated, but likely to be&#xA;significantly more efficient than mine in terms of flash usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second step is to write down the periodic table as a PROGMEM array:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;const Element periodic_table[] PROGMEM = {&#xA;    // symbol  name    mass      electronic state&#xA;    {&quot;H&quot;,  &quot;Hydrogen&quot;, 1.008,    &quot;1s1&quot;     },&#xA;    {&quot;He&quot;, &quot;Helium&quot;,   4.002602, &quot;1s2&quot;     },&#xA;    {&quot;Li&quot;, &quot;Lithium&quot;,  6.94,     &quot;[He] 2s1&quot;},&#xA;    // etc...&#xA;};&#xA;const size_t table_length = sizeof periodic_table / sizeof *periodic_table;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then your program will only have to browse through this table in order&#xA;to get the needed information. The only tricky part here is that you&#xA;will have to copy the data to RAM before using it, for example with&#xA;something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Element elt;  // element in RAM&#xA;memcpy_P(&amp;amp;elt, &amp;amp;periodic_table[i], sizeof elt);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I do not have an LCD, so I wrote a test program that simply dumps the&#xA;table through the serial port:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    Serial.println(F(&quot;Z  Symbol  Name  Atomic mass  El. state&quot;));&#xA;    Serial.println(F(&quot;---------------------------------------&quot;));&#xA;    for (size_t i = 0; i &amp;lt; table_length; i++) {&#xA;        Element elt;  // element in RAM&#xA;        memcpy_P(&amp;amp;elt, &amp;amp;periodic_table[i], sizeof elt);&#xA;        Serial.print(i+1);  // Z = i+1&#xA;        Serial.print(F(&quot;    &quot;));&#xA;        Serial.print(elt.symbol);&#xA;        Serial.print(F(&quot;     &quot;));&#xA;        Serial.print(elt.name);&#xA;        Serial.print(F(&quot;  &quot;));&#xA;        Serial.print(elt.mass);&#xA;        Serial.print(F(&quot;  &quot;));&#xA;        Serial.println(elt.electronic_state);&#xA;    }&#xA;    Serial.println();&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This program only takes 4480 bytes of flash. This means I could expand&#xA;the table to 118 elements and over 200 bytes of data per element before&#xA;running out of flash on an Uno.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-13T20:59:57.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21781" PostTypeId="2" ParentId="21774" CreationDate="2016-03-13T21:08:21.487" Score="1" Body="&lt;p&gt;It seems to me that you are coding to always display something on the LEDs:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  void loop()&#xA;  {&#xA;    do {&#xA;      analogValue = analogRead(sensorPinRed);&#xA;      // display stuff&#xA;    } while (analogValue &amp;gt; 300);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming that you want the LEDs off when &lt;code&gt;analogValue&lt;/code&gt; is &amp;lt;= 300, you have the test in the wrong place. That always does the loop at least once. How about:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  void loop()&#xA;    {&#xA;    analogValue = analogRead(sensorPinRed);&#xA;    if (analogValue &amp;gt; 300) &#xA;      {&#xA;      // display stuff&#xA;      }&#xA;    else&#xA;      {&#xA;      clearLEDs();   // Turn all LEDs off...&#xA;      RedPin.show(); &#xA;      BluePin.show(); &#xA;      GreenPin.show(); &#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T21:08:21.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21782" PostTypeId="1" AcceptedAnswerId="21799" CreationDate="2016-03-13T21:41:22.430" Score="1" ViewCount="1795" Body="&lt;p&gt;I'm trying to shorten the code under &quot;setup&quot; below, where I have over 120 variables that are being read from an external EEPROM. There is a pattern where the variable that stores the position of the EEPROM address is the name of the variable being populated, plus the word &quot;Pos&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte fanSpeed, nl1Toggle, ledsToggle;&#xA;byte fanSpeedPos = 12, nl1TogglePos = 95, ledsTogglePos = 7;&#xA;&#xA;void setup() {&#xA;  fanSpeed = readEE(fanSpeedPos);&#xA;  nl1Toggle = readEE(nl1TogglePos);&#xA;  ledsToggle = readEE(ledsTogglePos);&#xA;  //there are over 120 of the above readEE statements in the actual code.&#xA;}&#xA;&#xA;uint8_t readEE(uint8_t entry) {&#xA;  readEEPROM(AT24C32_ADDRESS, 1, entry);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally I would like it to work like this (I'm using pseudo code because I don't know how to do this):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* variableNames [] = { &quot;fanSpeed&quot;, &quot;nl1Toggle&quot;, &quot;ledsToggle&quot; };&#xA;byte fanSpeedPos = 12, nl1TogglePos = 95, ledsTogglePos = 7;&#xA;&#xA;void setup() {&#xA;  for (int i = 1; i &amp;lt; 120; i++;) {&#xA;    variableNames[i] = readEE(variableNames[i] + 'Pos');&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this possible using C++ / Arduino?&lt;/p&gt;&#xA;" OwnerUserId="11174" LastActivityDate="2016-03-14T11:40:35.700" Title="Append Text to Variable Names: Please Help Me Shorten This Code" Tags="|c++|variables|array|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21783" PostTypeId="2" ParentId="21761" CreationDate="2016-03-13T21:49:55.330" Score="5" Body="&lt;h2&gt;NeoPixels&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The strips based on the WS2812 / SK6812 and similar chips, known by some as &lt;em&gt;NeoPixels&lt;/em&gt;, are clever ways of implementing fully-addressable 24-bit colour LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the clever things is that they only require one data wire, plus power and Gnd, i.e.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;+5V&lt;/li&gt;&#xA;&lt;li&gt;Data&lt;/li&gt;&#xA;&lt;li&gt;Gnd&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The pixel information is sent by precisely timed sequences of 24 bits per pixel. The first pixel &quot;peels off&quot; these 24 bits (ie. 3 x red / green / blue) and then passes the rest on to the next pixel, and so on.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Libraries&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Various people have written libraries to do this for you including:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel&quot;&gt;Adafruit library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot;&gt;NeoPixels Revealed: How to (not need to) generate precisely timed signals&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=13357&quot;&gt;My own library which uses SPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Power&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Each pixel draws around 60 mA at maximum brightness (showing white) so you need to allow for a heavy-duty power supply. Particularly if you have 5m of 144 pixels/m then that is 720 pixels, which would require 43.2 amps!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to Adafruit:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To estimate power supply needs, multiply the number of pixels by 20, then divide the result by 1,000 for the “rule of thumb” power supply rating in Amps.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Even that means you need 14.4 amps for your 720 pixels!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So bear that in mind when sizing your power supply.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Addressing methods&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The Adafruit library (as far as I can tell) holds the pixel information in RAM, and then &quot;dumps&quot; it to the NeoPixels in one operation. This lets you do fancy things in memory, and copy the results to the pixels. However that means you need enough RAM for all this. At 3 bytes per pixel (24 bits), if you have 720 pixels, that will be 2160 bytes, which is more RAM than the smaller processors (like the Uno) have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Larger processors (like the Mega) have more RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative method, as explained &lt;a href=&quot;http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/&quot;&gt;here&lt;/a&gt; does not keep the data in RAM, but generates the colours &quot;procedurally&quot; on-the-fly. This is much less RAM-intensive, but perhaps less flexible. On that page he links to a &lt;a href=&quot;https://www.youtube.com/watch?v=I-lR19_kigs&quot;&gt;YouTube video&lt;/a&gt; which shows a humble Arduino Duemilanove (similar to a Uno) driving over 1000 pixels!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Procedural generation however can do quite a lot, for example you can set the entire string to a single colour, change that rapidly, or make a rainbow effect by increasing (say) the red value for each successive pixel. You can also make &quot;chaser&quot; effects quite simply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;http://www.gammon.com.au/forum/?id=13357&quot;&gt;library I wrote&lt;/a&gt; is also designed to allow you to use minimal RAM. You could conceivably add in your own storage scheme, perhaps only storing one byte per pixel, with less bits per colour (eg. 2 bits each for red, green, blue) and that would reduce RAM requirements by a third.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Cabling run&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You could try sending the data over 2m. I warn you that the timing for a zero-bit is that it has to go HIGH and then LOW within about 400 ns, so you can't afford to have the data signal degrade too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I had a similar string of coloured LEDs set up at Xmas time (not NeoPixels however) I had a long run of a 5V power supply (just using a pair of figure-8 wire), and situated the processor quite close to the pixels. This is probably the safest way of doing it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T21:49:55.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21784" PostTypeId="2" ParentId="21771" CreationDate="2016-03-13T21:54:10.923" Score="1" Body="&lt;p&gt;You may have to install a device driver. There is a &quot;drivers&quot; directory in the IDE download with some in it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VffAl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VffAl.png&quot; alt=&quot;Windows drivers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the readme.txt file:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;With this version of Arduino a new all-in-one driver (with&#xA;  security signature for Windows 8) is supplied.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The old (deprecated) drivers are still available in the&#xA;  Old_Arduino_Drivers.zip&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-13T21:54:10.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21785" PostTypeId="2" ParentId="21782" CreationDate="2016-03-13T22:24:59.433" Score="3" Body="&lt;pre&gt;&lt;code&gt;variableNames[i] = readEE(variableNames[i] + 'Pos');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this possible using C++ / Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No! Very few programming languages allow that as it requires a lot of run-time information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let us instead revisit you issue; Load a large set of variables from &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html&quot; rel=&quot;nofollow&quot;&gt;EEPROM&lt;/a&gt;. What mechanisms do we have in C/C++ and AVR library that could help with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a really simple solution that results in a &quot;one-liner&quot;; eeprom_read_block(). &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct var_t {&#xA;  byte fanSpeed, nl1Toggle, ledsToggle;&#xA;};&#xA;var_t var;&#xA;const void* pos = ...;&#xA;eeprom_read_block(&amp;amp;var, pos, sizeof(var));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously &lt;code&gt;var_t&lt;/code&gt; and &lt;code&gt;var&lt;/code&gt; are not very good names (and you will have to come up with something better) and this is for the internal EEPROM but the same technique can be used for the I2C EEPROM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BW: What AT24CXXX library are you using? Because this looks strange.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; uint8_t readEE(uint8_t entry) {&#xA;   readEEPROM(AT24C32_ADDRESS, 1, entry);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No return statement, etc. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-03-13T23:03:06.443" LastActivityDate="2016-03-13T23:03:06.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21786" PostTypeId="2" ParentId="16383" CreationDate="2016-03-13T22:40:53.633" Score="0" Body="&lt;p&gt;If you wanted a more permanent option on the board, you could also add a USB to FTDI chip like this: &lt;a href=&quot;http://www.mouser.com/Search/m_ProductDetail.aspx?FTDI%2fFT232RL-REEL%2f&amp;amp;qs=D1%2fPMqvA103RC6OU6bKtoA%3d%3d&amp;amp;gclid=CNmDjr7dvssCFYZefgod9jgPeQ&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/Search/m_ProductDetail.aspx?FTDI%2fFT232RL-REEL%2f&amp;amp;qs=D1%2fPMqvA103RC6OU6bKtoA%3d%3d&amp;amp;gclid=CNmDjr7dvssCFYZefgod9jgPeQ&lt;/a&gt; &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-13T22:40:53.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21789" PostTypeId="1" CreationDate="2016-03-14T00:16:03.400" Score="0" ViewCount="1931" Body="&lt;p&gt;I have an arduino uno rev 3 and it works perfectly fine. I the OS I am using is Kali Linux 2.0 and you can upload everything as normal to the arduino.&#xA;I am following this tutorial:&lt;a href=&quot;http://www.kevindemarco.com/2014/01/02/arduino-uno-as-a-usb-hid-interface/&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno as usb HID interface device&lt;/a&gt;&#xA;to use my arduino uno r3 as a hid device. After I upload the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino-keyboard-0.3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;file, I plug cycle the board and I try uploading the example blink program. It always says:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial Port /dev/ttyACM0 not found.&#xA;Retry the upload with another serial port?&#xA;/dev/ttyS0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the /dev/ttyACM0 is my default arduino port and /dev/ttyS0 is one of my usb devices that is plugged in. Neverless, I tried uploading but it says board isnt responding. Can someone help me with this please?&lt;/p&gt;&#xA;" OwnerUserId="19246" LastActivityDate="2016-03-14T19:36:00.547" Title="Arduino Uno not working as usb HID interface" Tags="|arduino-uno|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21790" PostTypeId="2" ParentId="21789" CreationDate="2016-03-14T00:32:32.720" Score="2" Body="&lt;p&gt;You have reprogrammed the ATMega16U2 chip to be a HID device. Thus it no longer functions as a serial interface between the Atmega328P and your computer. You need to reflash the firmware on the ATMega16U2 to return to normal operation.&lt;/p&gt;&#xA;&lt;p&gt;I have instructions for how you might to this on my &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;bootloader uploader&lt;/a&gt; page. In brief, you need to put the original hex file back:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo dfu-programmer atmega16u2 flash Arduino-atmega16u2-Uno-firmware-Rev3.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There are other ways of turning your Uno into a HID device. Search for &amp;quot;Virtual USB Arduino&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;More easily, get a Arduino Leonardo or Arduino Micro which are designed for this sort of thing.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Yes but how can I use &lt;strong&gt;it&lt;/strong&gt; as a HID? ...  it cannot detect &lt;strong&gt;it&lt;/strong&gt; so how would I be able to upload code to &lt;strong&gt;it&lt;/strong&gt;  ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What is &amp;quot;it&amp;quot; here? Look at this photo:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W0qfY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W0qfY.jpg&quot; alt=&quot;Uno from above&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are two processors on the Uno. It sounds like you have reflashed the ATMega16U2. Do you want to use the ATMega16U2 as a HID or the Atmega328P as a HID? They need totally different techniques.&lt;/p&gt;&#xA;&lt;p&gt;Once you reflash the ATMega16U2 you can't &amp;quot;get to&amp;quot; the Atmega328P via the USB interface.&lt;/p&gt;&#xA;&lt;p&gt;On the page you linked there is a workflow for programming the ATMega16U2. Are you following it? If so, which part is not working for you? If not, why not?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-14T19:36:00.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21791" PostTypeId="2" ParentId="17169" CreationDate="2016-03-14T00:40:02.767" Score="3" Body="&lt;p&gt;This is now 5 months later - but I recently had the same problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the TMRpcm library plays through pulse width modulation, make sure your speakers are hooked up to a PWM capable pin.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That caused me no end of headaches trying to figure out.&lt;/p&gt;&#xA;" OwnerUserId="19249" LastEditorUserId="6936" LastEditDate="2016-03-15T04:37:24.780" LastActivityDate="2016-03-15T04:37:24.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21792" PostTypeId="2" ParentId="21751" CreationDate="2016-03-14T01:13:33.707" Score="0" Body="&lt;p&gt;Concerning the image in your post about 'SPI Read Data', that simply says the first byte received over MISO is discarded, which is done in &lt;code&gt;PCD_ReadRegister()&lt;/code&gt; right before the &lt;code&gt;for&lt;/code&gt; loop, and then &lt;code&gt;n&lt;/code&gt; bytes are read, with 0 transferred the last time to stop reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick look at the library and datasheet shows that the &lt;code&gt;rxAlign&lt;/code&gt; argument is used in identifying the first valid bit in the first received byte. &lt;code&gt;txLastBits&lt;/code&gt; serves a similar purpose, only for transmission of the final byte. Both are written to &lt;code&gt;BitFramingReg&lt;/code&gt; of the MFRC522 and are necessary for bit-oriented frames between the MFRC522 and a card/tag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in the function you have above, if &lt;code&gt;rxAlign = 3&lt;/code&gt;, it means only bits 7 to 3 are valid in the first &lt;strong&gt;received byte&lt;/strong&gt;, extracted with bit mask &lt;code&gt;11111000&lt;/code&gt;. So the first &lt;strong&gt;valid 'byte'&lt;/strong&gt; comprises bits 7 to 3 of the first received byte concatenated with bits 2 - 0 of the next received byte. Similarly, in transmission, &lt;code&gt;txLastBits&lt;/code&gt; indicates the number of bits of the last byte that are to be transmitted to the card/tag. In both cases, what is transmitted or received over the RF field may not be a multiple of 8, hence the need for these arguments and &lt;code&gt;BitFramingReg&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyways, this shouldn't interfere at all with porting the library. Simply replace the Arduino-specific functions/interfaces and allow the library's existing logic to remain as is.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll try to answer your questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In this context, 106kBd refers to the data rate between the RC522 and a card, and not between the RC522 and the MCU. The maximum is about 848kBd, i think. Check the datasheet for more details.&lt;/li&gt;&#xA;&lt;li&gt;Bit-oriented frames are &lt;strong&gt;necessary&lt;/strong&gt; for the anti-collision process. Superimposed bits in the Manchester encoding, when several cards attempt to communicate with the RC522 at once, require that individual bits be processed as opposed to the usual byte-sized units. Look up anti-collision techniques.&lt;/li&gt;&#xA;&lt;li&gt;Anticollision is necessary if the same reader will possibly have multiple tags within its range. From an IEEE article:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tag collisions can impose a major inefficiency in RFID systems, resulting in low identification rates, short reading range and ineffective resource utilization. They are more problematic in passive tags due to limitations on power and functionality.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, if you will be presenting only one card at a time, then you should be safe without implementing anticollision in your code. Else, I'm afraid you have no choice unless you want to confuse the reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all you want to do is read UIDs and read from/write to blocks on a card (one at a time), you may want to try porting this straightforward &lt;a href=&quot;https://github.com/zodier/MFRC522-UART-Arduino&quot; rel=&quot;nofollow&quot;&gt;MFRC522 UART library&lt;/a&gt;, which doesnt implement anitcollision, by the way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to port the SPI-based library, then, a few suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want to replace the SPI interface with UART. This is low-level stuff, all contained within a few functions like &lt;code&gt;PCD_ReadRegister()&lt;/code&gt;, &lt;code&gt;PCD_WriteRegister()&lt;/code&gt; and a few others. These functions serve higher-level functions, which have no clue of their internal implementation, but expect certain behaviour from them. Swap the SPI functions for their UART equivalents, as soon as you understand how to talk to the reader over UART. Once your ARM UART functions behave exactly like the SPI functions, your work is almost done; there is no need to learn the reason for everything in the higher-level functions since they dont relate to anything interface-specific. This includes everything concerning &lt;code&gt;rxAlign&lt;/code&gt; and whatnot. Good luck :).&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-15T00:00:11.020" LastActivityDate="2016-03-15T00:00:11.020" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21793" PostTypeId="1" AcceptedAnswerId="21847" CreationDate="2016-03-14T02:24:26.753" Score="1" ViewCount="1547" Body="&lt;p&gt;I was working on controlling a high power motor with a heavy duty motor controller, and I was able to make my motor spin, but I wasn't able to incorporate a program for my pressure sensor and make it determine the speed of the motor.  I'm pretty sure I connected the parts correctly on my circuit board, so I figure my code must have some mistake, or something missing.&#xA;The pressure sensor I'm using: &#xA;The motor controller I'm using: &lt;a href=&quot;http://www.robotshop.com/en/arduino-compatible-mega-motor-shield-1a-5-28v.html#Useful&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.robotshop.com/en/arduino-compatible-mega-motor-shield-1a-5-28v.html#Useful&lt;/a&gt; &#xA;The code I have: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int motorValue=0;&#xA;int sensorValue=0;&#xA;int sensorPin=A0;&#xA;int EnablePin=8;&#xA;int PWMPin2=3; &#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;pinMode(EnablePin, OUTPUT);&#xA;//pinMode(sensorPin, OUTPUT);&#xA;Serial.begin(9600);&#xA;pinMode(PWMPin2, OUTPUT);&#xA;pinMode(sensorPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;// put your main code here, to run repeatedly:&#xA;sensorValue = analogRead(sensorPin);&#xA;&#xA;//float voltage = sensorValue * (5.0 / 1023.0);&#xA;&#xA;//Serial.println(voltage);&#xA;&#xA;delay(50);&#xA;&#xA;motorValue=map(sensorValue,0,1023,0,255);&#xA;//motorValue=sensorValue / 4;&#xA;//analogWrite(motorPin,motorValue);&#xA;digitalWrite(EnablePin, HIGH);&#xA;analogWrite(PWMPin2, motorValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: The sensor works by reading the voltage.  Here's an actual picture of how I wired it: &lt;a href=&quot;https://i.stack.imgur.com/FxJZY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FxJZY.jpg&quot; alt=&quot;Here&amp;#39;s how I wired it&quot;&gt;&lt;/a&gt; I used this wiring to print out the voltage with just the Arduino and it worked, and I'm using it with the same wiring but while having the motor shield on top, so that's why I'm guessing that I must not be programming the sensor right with the motor controller.  I couldn't get the voltage readings when I used this setup with the motor driver shield.    &lt;/p&gt;&#xA;" OwnerUserId="19055" LastEditorUserId="19055" LastEditDate="2016-03-14T22:49:33.267" LastActivityDate="2016-03-15T19:39:24.477" Title="How to program pressure sensor and motor with motor shield" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21795" PostTypeId="1" AcceptedAnswerId="21801" CreationDate="2016-03-14T07:19:24.400" Score="0" ViewCount="1313" Body="&lt;p&gt;I would like to know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Pin 6, 7, 8 and 9 as INPUT_PULLUP. I have switch to each other pin. Why when I press switch at PIN 6. &lt;strong&gt;SOMETIMES&lt;/strong&gt; PIN 7 also getting input. Other case, also when I press switch at 7, other pin also trigger. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This case is random. Sometimes everything is ok when I press 10 times, but after that other pin also trigger. Another case only 4-5 times press, then other pin also trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use switch on/off not temporary switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to fix this? Is it common problem with arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Program. (Simple Program)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int led1 = 1;&#xA;int led2 = 2;&#xA;int led3 = 3;&#xA;int led4 = 5;&#xA;&#xA;int switch1 = 6;&#xA;int switch2 = 7;&#xA;int switch3 = 8;&#xA;int switch4 = 9;&#xA;&#xA;int led = 13;&#xA;&#xA;//int counter = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  // put your setup code here, to run once&#xA;      pinMode(led1, OUTPUT);&#xA;      pinMode(led2, OUTPUT);&#xA;      pinMode(led3, OUTPUT);&#xA;      pinMode(led4, OUTPUT);&#xA;      pinMode(switch1, INPUT_PULLUP);&#xA;      pinMode(switch2, INPUT_PULLUP);&#xA;      pinMode(switch3, INPUT_PULLUP);&#xA;      pinMode(switch4, INPUT_PULLUP);&#xA;      pinMode(led, OUTPUT);&#xA;}  &#xA;void loop()&#xA;{&#xA;&#xA;if (digitalRead(switch1) == 0){&#xA;  digitalWrite(led1, HIGH);&#xA;  }&#xA;&#xA; if (digitalRead(switch1) == 1){&#xA;  digitalWrite(led1, LOW);&#xA;  } &#xA;&#xA;if (digitalRead(switch2) == 0){&#xA;  digitalWrite(led2, HIGH);&#xA;  }&#xA;&#xA; if (digitalRead(switch2) == 1){&#xA;  digitalWrite(led2, LOW);&#xA;  } &#xA;&#xA;&#xA;if (digitalRead(switch3) == 0){&#xA;  digitalWrite(led3, HIGH);&#xA;  }&#xA;&#xA; if (digitalRead(switch3) == 1){&#xA;  digitalWrite(led3, LOW);&#xA;  } &#xA;&#xA;&#xA;if (digitalRead(switch4) == 0){&#xA;  digitalWrite(led4, HIGH);&#xA;  }&#xA;&#xA; if (digitalRead(switch4) == 1){&#xA;  digitalWrite(led4, LOW);&#xA;  } &#xA;&#xA;digitalWrite(led, HIGH);&#xA;&#xA;delay(1000);&#xA;&#xA;digitalWrite(led, LOW);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Schematic&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZeoMR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZeoMR.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Circuit is simple as like that for the input. For the output only to led, resistor and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found similar case &lt;a href=&quot;http://www.instructables.com/id/Arduino-Push-Switch-Debouncing-Interrupts/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-Push-Switch-Debouncing-Interrupts/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On the website, He said, &quot;The problem with this setup was when the&#xA;  button was pressed the interrupt was being called multiple times and&#xA;  even toggling other buttons. Why was this happening? It is caused from&#xA;  a switch bouncing feedback.&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is there any solution without modifying the hardware?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SOLVE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the wire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My wire for switch is jumper cable, and each other closer (touch) to each other cable. I try to separate, and works. There is no other pin will be trigger.&lt;/p&gt;&#xA;" OwnerUserId="19254" LastEditorUserId="19254" LastEditDate="2016-03-15T06:01:29.300" LastActivityDate="2016-03-15T06:01:29.300" Title="SOLVED -- Switch PIN, Also Trigger Other Pin in Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="21799" PostTypeId="2" ParentId="21782" CreationDate="2016-03-14T11:20:22.663" Score="3" Body="&lt;p&gt;This can be achieved with a simple preprocessor macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define readEE(VAR) VAR = readEEPROM(AT24C32_ADDRESS, 1, VAR ## Pos)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readEE(foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will be expanded out to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = readEEPROM(AT24C32_ADDRESS, 1, fooPos);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;##&lt;/code&gt; operator in macros expands out both sides (VAR and Pos) and then concatenates the results together. Since VAR itself is a macro (whatever you pass when you call the macro) it gets replaced with that value, but Pos, because it isn't a macro, just stays as Pos. So you end up with your variable name concatenated with the word Pos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can't use that in a loop with variable names in an array - simply because variable names only exist in the source code, not in the compiled code, so you can't do anything with those variable names once the code is compiled.  Hence you have to use the preprocessor to do the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it means you still have to write 120 lines of code for all 120 variables, but they are just shortened to &lt;code&gt;readEE(varname);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However a better solution is to either use Mikael's struct method, or to just use an array and think differently about the concept of names:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t data[120];&#xA;for (int i = 0; i &amp;lt; 120; i++) {&#xA;    data[i] = readEEPROM(AT24C32_ADDRESS, 1, i);&#xA;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now all your variable values are in the &lt;code&gt;data[]&lt;/code&gt; array, and you just need to know, in your program, which value is which - and you can do that by defining names for each position as preprocessor macros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define FAN_SPEED 12&#xA;#define N1_TOGGLE 95&#xA;#define LEDS_TOGGLE 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then use those macros in place of the numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(data[FAN_SPEED]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively you could use the macros to &quot;mask&quot; variable names:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define fanSpeed data[12]&#xA;#define n1Toggle data[95]&#xA;#define ledsToggle data[7]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is one thing you might have noticed though: Nothing here shortens your code, it just moves things around a bit. Let's face it - you have 120 variables stored in 120 locations. Whatever you do you're still going to have to have 120 pointers of some form to those variables and their locations. All you can really do is choose the method that provides the most readability so that someone else looking at your code can understand what is going on. Whatever you do you have a long list of variables or variable names to define or set up, which means a lot of typing.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-14T11:40:35.700" LastActivityDate="2016-03-14T11:40:35.700" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21800" PostTypeId="2" ParentId="21688" CreationDate="2016-03-14T13:10:27.090" Score="2" Body="&lt;p&gt;The PDP context setup is missing from your code. Many years ago I figured out that this initialization sequence works (i.e. extend your connectToInternet):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        //--if autobauding was enabled, send a blank AT&#xA;        command:='AT';&#xA;        send_gprs;&#xA;&#xA;        //--switch to minimal mode - this is required to reset the SIM card&#xA;        command:='AT+CFUN=0';&#xA;        send_gprs;&#xA;&#xA;        //--set dce speed&#xA;        command:='AT+IPR=57600';&#xA;        send_gprs;&#xA;&#xA;        //--turn off command echo&#xA;        command:='ATE0';&#xA;        send_gprs;&#xA;&#xA;        //--turn off command echo again - sometimes the first command is ignored&#xA;        command:='ATE0';&#xA;        send_gprs;&#xA;&#xA;        //--turn on extended error messages     &#xA;        command:='AT+CMEE=1';&#xA;        send_gprs;&#xA;&#xA;        //--set module to full function &#xA;        command:='AT+CFUN=1';&#xA;        send_gprs;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then it is very important to unlock your SIM card. The simplest solution is to disable PIN request (put your SIM to a real phone, and use the phone to set up this.) Verify if the module can proceed on SIM authorization:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        //--check pin &#xA;        command:='AT+CPIN?';&#xA;        send_gprs;&#xA;        //--right answer is +CPIN: READY&#xA;        //--wrong answer is +CME ERROR: 772&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then set up the APN. This will actually initiate an asynchronous APN request, and you shall not proceed until the AT+CSTT returns OK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    repeat&#xA;        //--reset connection&#xA;        command:='AT+CIPSHUT';&#xA;        send_gprs;&#xA;&#xA;        //--set GPRS APN&#xA;        command:='AT+CSTT=&quot;internet.vodafone.net&quot;';&#xA;        send_gprs;&#xA;    until is_ok=1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And finally, open a GPRS connection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    repeat&#xA;        //--Open gprs connection&#xA;        command:='AT+CIICR';&#xA;        send_gprs; &#xA;&#xA;        //--Get local address - for some reason this is required&#xA;        command:='AT+CIFSR';&#xA;        send_gprs;&#xA;&#xA;        //--Suppress &quot;SEND OK&quot; after at+cipsend&#xA;        command:='AT+CIPSPRT=2';&#xA;        send_gprs;&#xA;&#xA;    until is_ok=1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Ok sorry, this code is pascal and not especially golden, but you got the point about the sequence of the commands.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two very important things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;any command can fail - it is a good idea to send back the response to an AT command to your console window&lt;/li&gt;&#xA;&lt;li&gt;AT+CIFSR is evil. If you don't use AT+CIFSR at the right sequence, the communication simply does not work. I was using SIM900D modules. Although you might feel it is optional to get your IP, actually it is not optional at all for some reason.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I was using AT+CIPSEND for the actual data communication. HTTP is so easy, and it is better to be in control.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-14T13:10:27.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21801" PostTypeId="2" ParentId="21795" CreationDate="2016-03-14T13:17:45.323" Score="0" Body="&lt;p&gt;You may be getting switching noise between the button wires, which is low-level and brief, but with no debouncing, it could be just enough to cause the effect you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest 1) writing a short function that &lt;a href=&quot;http://gammon.com.au/switches&quot; rel=&quot;nofollow&quot;&gt;debounces&lt;/a&gt; and reads any button; and 2) using if/else statements instead of testing each button twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick test is to hold one pair of wires closer together or farther apart from each other while you press one of those two buttons, and see whether the distance apart changes the effect. If it does, you've found the cause.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-14T13:17:45.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21803" PostTypeId="2" ParentId="21774" CreationDate="2016-03-14T14:30:51.960" Score="1" Body="&lt;p&gt;Thanks to @nick-gammon for debugging my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cleaned it up so below is the working sample. X-axis of the accelerometer is related to PWM pin 3 RGB LED strip, Y axis of pin 5 and Z axis to pin 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LED sequence cascades once in spring green color in response to the tilt in direction.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &quot;WS2812_Definitions.h&quot;&#xA;&#xA;#define PIN1 3&#xA;#define LED_COUNT1 5&#xA;#define PIN2 5&#xA;#define LED_COUNT2 5&#xA;#define PIN3 6&#xA;#define LED_COUNT3 5&#xA;&#xA;// Create an instance of the Adafruit_NeoPixel class called &quot;XPin&quot;, &quot;YPin&quot; and &quot;ZPin&quot;.&#xA;// That'll be what we refer to from here on...&#xA;Adafruit_NeoPixel XPin = Adafruit_NeoPixel(LED_COUNT1, PIN1, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel YPin = Adafruit_NeoPixel(LED_COUNT2, PIN2, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel ZPin = Adafruit_NeoPixel(LED_COUNT3, PIN3, NEO_GRB + NEO_KHZ800);&#xA;&#xA;const int sensorPinX = A0;&#xA;const int sensorPinY = A2;&#xA;const int sensorPinZ = A4;&#xA;&#xA;int analogValueX = 0;&#xA;int analogValueY = 0;&#xA;int analogValueZ = 0;&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  XPin.begin();  // Call this to start up the LED strip.&#xA;  YPin.begin();&#xA;  ZPin.begin();&#xA;  clearLEDs();   // This function, defined below, turns all LEDs off...&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   analogValueX = analogRead(sensorPinX);&#xA;   analogValueY = analogRead(sensorPinY);&#xA;   analogValueZ = analogRead(sensorPinZ);&#xA;   if ((analogValueX &amp;gt; 400) || (analogValueY &amp;gt; 400) || (analogValueZ &amp;gt; 400) )&#xA;   {&#xA;&#xA;  // A light shower of spring green rain&#xA;  // This will run the cascade from top-&amp;gt;bottom i times&#xA;  for (int i=0; i&amp;lt;1; i++)&#xA;  {&#xA;    // First parameter is the color, second is direction, third is ms between falls&#xA;    cascade(MEDIUMSPRINGGREEN, TOP_DOWN, 100); &#xA;  }&#xA;   }&#xA;   else&#xA;   {&#xA;     clearLEDs(); // Turn all LEDs off&#xA;   }&#xA;}&#xA;&#xA;// Cascades a single direction. One time.&#xA;void cascade(unsigned long color, byte direction, byte wait)&#xA;{&#xA;  if (direction == TOP_DOWN)&#xA;  {&#xA;    for (int i=0; i&amp;lt;LED_COUNT1; i++)&#xA;    {&#xA;      clearLEDs();  // Turn off all LEDs&#xA;      XPin.setPixelColor(i, color);  // Set just this one&#xA;      XPin.show();&#xA;      delay(wait);&#xA;    }&#xA;&#xA;    for (int i=0; i&amp;lt;LED_COUNT2; i++)&#xA;    {&#xA;      clearLEDs();  // Turn off all LEDs&#xA;      YPin.setPixelColor(i, color);  // Set just this one&#xA;      YPin.show();&#xA;      delay(wait);&#xA;    }&#xA;    for (int i=0; i&amp;lt;LED_COUNT3; i++)&#xA;    {&#xA;      clearLEDs();  // Turn off all LEDs&#xA;      ZPin.setPixelColor(i, color);  // Set just this one&#xA;      ZPin.show();&#xA;      delay(wait);&#xA;    }&#xA;  }&#xA;  else&#xA;  {&#xA;    for (int i=LED_COUNT1-1; i&amp;gt;=0; i--)&#xA;    {&#xA;      clearLEDs();&#xA;      XPin.setPixelColor(i, color);&#xA;      XPin.show();&#xA;      delay(wait);&#xA;    }&#xA;&#xA;    for (int i=LED_COUNT2-1; i&amp;gt;=0; i--)&#xA;    {&#xA;      clearLEDs();&#xA;      YPin.setPixelColor(i, color);&#xA;      YPin.show();&#xA;      delay(wait);&#xA;    }&#xA;&#xA;    for (int i=LED_COUNT3-1; i&amp;gt;=0; i--)&#xA;    {&#xA;      clearLEDs();&#xA;      ZPin.setPixelColor(i, color);&#xA;      ZPin.show();&#xA;      delay(wait);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;// Sets all LEDs to off, but DOES NOT update the display;&#xA;// call leds.show() to actually turn them off after this.&#xA;void clearLEDs()&#xA;{&#xA;  for (int i=0; i&amp;lt;LED_COUNT1; i++)&#xA;  {&#xA;    XPin.setPixelColor(i, 0);&#xA;  }&#xA;  for (int i=0; i&amp;lt;LED_COUNT2; i++)&#xA;  {&#xA;    YPin.setPixelColor(i, 0);&#xA;  }&#xA;  for (int i=0; i&amp;lt;LED_COUNT3; i++)&#xA;  {&#xA;    ZPin.setPixelColor(i, 0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15366" LastEditorUserId="10794" LastEditDate="2016-03-14T19:37:07.060" LastActivityDate="2016-03-14T19:37:07.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21806" PostTypeId="1" CreationDate="2016-03-14T17:59:27.743" Score="0" ViewCount="742" Body="&lt;p&gt;I am now hopelessly stuck and need help please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building an automated observatory and now at the stage of trying to control the observatory dome rotation. The dome is rotated using a step motor and it works fine. The rotation of the dome also turns a rotary encoder to give an independent verification that the dome is moving. Although the RE is a quadrature type I am simply counting RE ticks from both channels as I don't need direction information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to do now is to count how many motor driving pulses occur between each pair of RE ticks. The reasoning behind this is to monitor the dome movements and detect jamming. The actual motor pulses will be used for all dome position calculations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve this, I have built a small board with a ULN2803A inverting buffer and an Arduino Nano. The Nano uses Pin Change interrupts on pins D11 and D12 to count the RE ticks. Pin D7 will also be used to monitor a Home Position sensor although this doesn't exist at present. The motor pulses are sent via the buffer to Pin D2 (INT0) and the motor direction is sent via the buffer to pin D3 (INT1). The external interrupts are then used to count the motor pulses, up or down depending on the motor direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For information, there is another board present, a Velleman VM110 USB breakout board, that also receives the rotary encoder ticks. This gives me a simple way to check that my board gives the same answer when I rotate the rotary encoder shaft by hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK - sorry this is so long winded but now it gets weird.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I rotate the RE without the motor running everything is fine. I get four times as many pulses as the Velleman board as I am using Pin Changes, triggering on each rise and fall, not on full cycles of the encoder. This does happen as predicted and everything is nice and stable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT - when I start the motor running, I get hundreds of RE ticks every time I move the encoder and sometimes I get increasing RE ticks without touching the encoder at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The obvious answer is some form of RFI but I have done everything I can to eliminate this. The motor driver and the Nano board that powers it are in a shielded enclosure, the cable to the motor is a shielded cable and I have 10uH chokes on each of the four motor leads. Finally, I have fitted a filter to the incoming power supply to the motor box to minimise any RFI going back down the power lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The use of the ULN2803A buffer was my latest attempt to make this work. Previously the signals went direct to the Nano pins. With the buffer, I have used 20k pull-ups on the input side and 10k pull-ups on the outputs. This was a direct copy of the Velleman board input circuit that I knew worked without problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have looked at the motor pulses at the input pin to the Nano on my scope and they are nice looking, sharp edged pulses of duration 70 uS and a frequency of 497 Hz. Not bad as I set the pulse rate using the Accelstepper library to 500Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I now suspect that this is a software problem. This wouldn't surprise me as I am very new to all this, just trying to learn enough at each stage to do what I need. I have attached the code - this is a stripped down version without a lot of I2C stuff that is not relevant to my problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, for information. I have tried using the &lt;code&gt;attachInterrupt()&lt;/code&gt; function and by directly setting the relevant registers - no difference!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I really really hope someone can help me sort this out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards, Hugh&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*          &#xA;ABoard3  &#xA;ROTATION MONITORING AND POSITION&#xA;Version AB3_stripped&#xA;*****************************PURPOSE*****************************************&#xA;This sketch is used on an Arduino Nano to count the motor pulses from ABoard1&#xA;and the Rotary Encoder ticks. The motor pulse count between encoder ticks is&#xA;used to detect dome jamming.&#xA;****************************INPUTS*******************************************&#xA;PIN CHANGE INTERRUPTS&#xA;**********ROTARY ENCODER INPUT*********&#xA;The rotary encoder is a Bourns ENA1J-B28 L00064L 1139M MEX 64 cycle per turn&#xA;optical encoder. This is connected to ABoard3 Pins D11 and D12. These pins&#xA;connect to Channel A and Channel B respectively. Pin change interrupts are used&#xA;to receive the rotary encoder output.&#xA;(The output pulses from the rotary encoder is also sent to the Velleman board&#xA;for use by LesveDomeNet for finding dome position)&#xA;*********HOME POSITION INPUT*********&#xA;The home position sensor is an Omron EESX671 Optical Sensor.&#xA;The sensor output is connected to ABoard3 Pin D7.&#xA;Pin change interrupt PCINT21 records activation/deactivation of the sensor.&#xA;EXTERNAL INTERRUPTS&#xA;*********MOTOR PULSE INPUT***********&#xA;The pulses sent to the G251X stepper driver are also sent to Aboard3 Pin D2.&#xA;This pin is the External Interrupt pin, vector INT0&#xA;*********MOTOR DIRECTION INPUT********&#xA;Motor direction is input to ABoard3 from ABoard2. ABoard2 pin, pnVmInRotMotor&#xA;(AB2:A0{54}) is connected to Velleman pins DI4 and DO2 and also to AB3:D3.&#xA;AB3:D3 is an External Interrupt pin, vector INT1.&#xA;*/&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;                       &#xA;#include &quot;streaming.h&quot;                        &#xA;#include &quot;I2C_AnythingHEG.h&quot;   &#xA;#include &amp;lt;EEPROMex.h&amp;gt;                    &#xA;&#xA;//CONSTANTS                       &#xA;//PIN ASSIGNMENTS For ABOARD3&#xA;const uint8_t pnMotorPulse = 2;      //Port PD2, INT0, ISR(INT0_vect){}&#xA;const uint8_t pnMotorDirection = 3;  //Port PD3, INT1, ISR(INT1_vect){}&#xA;const uint8_t pnDomeAtHome = 7;      //Port PD7, PCINT23,ISR(PCINT2_vect){}&#xA;const uint8_t pnREChanA = 11;        //Port PB3, PCINT3, ISR(PCINT0_vect){}&#xA;const uint8_t pnREChanB = 12;        //Port PB4, PCINT4, ISR(PCINT0_vect){}&#xA;&#xA;//*****************EXPERIMENTAL STUFF FOR PULSE COUNTING*******************************                  &#xA;uint16_t volatile myTest = 0;&#xA;int32_t volatile ratioCount = 0L;&#xA;int32_t volatile totalCount = 0L;&#xA;int32_t volatile tickCount = 0L;&#xA;uint8_t volatile halftickCount = 0;&#xA;int32_t volatile addPulse = 0L; &#xA;&#xA;void setup() {&#xA;  //**********************************SERIAL FOR DEBUG ONLY************************&#xA;  Serial.begin(115200);&#xA;  //*************************INPUT PIN MODE SETUP**********************************&#xA;  //NOTE Set all UNUSED PCINT0:5 pins (D8, D9, D10, D11) to OUTPUT.&#xA;  //and set the value to LOW&#xA;  //The actual pins used to receive interrupts have external 10k pull-ups.&#xA;  //This is to reduce susceptibility to interference causing false triggering.&#xA;  pinMode(pnMotorPulse, INPUT); //D2&#xA;  pinMode(pnMotorDirection, INPUT); //D3&#xA;  pinMode(pnDomeAtHome, INPUT); //D7&#xA;  pinMode(pnREChanA, INPUT); //D11&#xA;  pinMode(pnREChanB, INPUT); //D12&#xA;  pinMode(4, OUTPUT); //D4&#xA;  digitalWrite(4, LOW);&#xA;  pinMode(8, OUTPUT); //D8&#xA;  digitalWrite(8, LOW);&#xA;  pinMode(9, OUTPUT); //D9&#xA;  digitalWrite(9, LOW);&#xA;  pinMode(10, OUTPUT); //D10&#xA;  digitalWrite(10, LOW);&#xA;  //******************SET UP AddPulse According to Motor Direction******************&#xA;  //This is needed to make sure the pulse counting starts in the correct direction&#xA;  //as the direction is only checked in the ISR after a change has occurred.&#xA;  //If Motor Direction is AntiClockwise, change to Subtract a pulse&#xA;  if( digitalRead(pnMotorDirection)) {&#xA;    addPulse = 1L;&#xA;  } else {&#xA;    addPulse = -1L;&#xA;  }&#xA;  //**************************SET UP PIN CHANGE INTERRUPTS**************************&#xA;  //Set the Pin Change Interrupt Masks&#xA;  //Clear all bits to start with&#xA;  PCMSK0 &amp;amp;= 0b00000000; //Clear all bits&#xA;  PCMSK1 &amp;amp;= 0b00000000; //Clear all bits&#xA;  PCMSK2 &amp;amp;= 0b00000000; //Clear all bits&#xA;  //Mask for PCINTs 0 through 7 is PCMSK0 (Rotary Encoder Pulses)&#xA;  //Need to allow interrupts on PCINT3 and PCINT4, so set bits 3 and 4&#xA;  //PCINT3 is Nano  pin D11 and PCINT4 is Nano pin D12&#xA;  //Use a compound bitwise OR to set the bits&#xA;  PCMSK0 |= 0b00011000; //Enable PCINT3 ONLY (bit 3)&#xA;  //Interrupt on pins 11 and 12, RE Ticks&#xA;  //Mask for PCINTs 16through 23 is PCMSK2 (Home Position)&#xA;  //Need to allow interrupts on PCINT23 so set bit 7&#xA;  PCMSK2 |= 0b10000000; //Interrupt on pin 7, Home Position Sensor activated&#xA;  //Now enable the interrupts (TURN THEM ON) by setting bits in PCICR&#xA;  //PCICR is Pin Change Interupt Control Register.Set bit 0 (PCIE0)  &#xA;  //to enable interrupts PCINT0:7 This catches PCINT3 and 4 - RE Ticks&#xA;  //Set bit 2 (PCIE2) to enable interrupts PCINT16:23. Catches PCINT21 - Home Position Sensor&#xA;  PCICR &amp;amp;= 0b00000000; //Clear PCICR register &#xA;  PCICR |= 0b00000001; //Set bit 0 - Catches PCINT3 &amp;amp; PCINT4 - RE Ticks&#xA;  PCICR |= 0b00000100; //Set bit 2 - Catch PCINT21 - Home Position Sensor&#xA;  //**************************SET UP 'EXTERNAL INTERRUPTS'**************************&#xA;  //Interupts on External Interrupt Pins D2 (INT0) and D3 (INT1).&#xA;  //INT0 (Nano pin D2)occurs when a stepper motor driver pulse is received&#xA;  //INT1 (Nano pin D3)occurs when the ABoard2 pin, pnVmInRotMotor toggles &#xA;  //indicating a motor direction change.&#xA;  //To use the 'External Interrupts' the following registers need to be set-up:         &#xA;  //EICRA External Interrupt Control Register A       &#xA;  //Need to set Interrupt Sense Control bits ISC11 .. ISC00 (bits 3:0 in EICRA)&#xA;  //ISC01     ISC00 (INT0)    Interrupt&#xA;  //ISC11     ISC01 (INT1)    Generated by&#xA;  //  0         0             Low level on Pin&#xA;  //  0         1             Any Logical Change&#xA;  //  1         0             Falling Edge&#xA;  //  1         1             Rising Edge&#xA;  //First clear all bits, then set as follows:  &#xA;  //For INT1 - Motor Direction - Generate on ANY LOGICAL CHANGE     &#xA;  //bit 3 ISC11 0     &#xA;  //bit 2 ISC10 1 This combination = Any logical change causes interrupt &#xA;  //For INT0 - Stepper Motor Pulses  - Generate on RISING EDGE      &#xA;  //bit 1 ISC01 1     &#xA;  //bit 0 ISC00 1 This combination = Rising edge of pulse causes interrupt&#xA;  //NOTE: To provide some immunity to RFI, Aboard3:Pins 2 &amp;amp; 3 are pulled high&#xA;  //using 10k resistors. &#xA;  //So, code is&#xA;  EICRA &amp;amp;= 0b00000000; //Clear EICRA register&#xA;  EICRA |= 0b00000111; // Set bits 0,1 and 2 in EICRA register&#xA;  //EIMSK External Interrupt Mask Register        &#xA;  //Need to set External Interrupt Request Enables INT1 &amp;amp; INT0  (bits 1:0)          &#xA;  //First clear both bits, then set as follows: &#xA;  //bit 1  INT1  1 External interrupt pin (D3) enabled   &#xA;  //bit 0  INT0  1 External interrupt pin (D2) enabled   &#xA;  //So, code is&#xA;  EIMSK &amp;amp;= 0b00000000; //Clear EIMSK register&#xA;  EIMSK |= 0b00000011; // Set bits 0 and 1 in EIMSK register&#xA;  //NOTE: Setting EIMSK TURNS ON THE EXTERNAL INTERRUPTS&#xA;  //************VARIABLE INITIALISATION*********&#xA;  myCommand = 0;&#xA;  myTest = 0;&#xA;  tickCount = 0L;&#xA;  totalCount = 0L;&#xA;} //END of setup&#xA;&#xA;void loop() {&#xA;  //******************************COMMAND ACTIONS******************************&#xA;  if (myTest == 3) (&#xA;    //RE tick&#xA;    Serial &amp;lt;&amp;lt; &quot;Tick Count = &quot; &amp;lt;&amp;lt; tickCount &amp;lt;&amp;lt; &quot;  totalCount = &quot; &amp;lt;&amp;lt; totalCount &amp;lt;&amp;lt; &quot;\n&quot;;&#xA;    myTest = 0;&#xA;  }&#xA;}&#xA;//*************************FUNCTIONS / ISRs FROM HEREON*************************&#xA;ISR(INT0_vect) {&#xA;  //Triggered by stepper motor drive pulse from ABoard1&#xA;  totalCount = totalCount + addPulse;&#xA;}&#xA;ISR(INT1_vect) {&#xA;  //Triggered by a change in motor direction&#xA;  if(digitalRead(pnMotorDirection)) {&#xA;    addPulse = 1L;&#xA;  } else {&#xA;    addPulse = -1L;&#xA;  }&#xA;}&#xA;ISR(PCINT0_vect) {&#xA;  //Triggered by a ROTARY ENCODER TICK&#xA;  halftickCount++;&#xA;  if (halftickCount == 2) {&#xA;    //Make count same as Velleman&#xA;    tickCount++;&#xA;    halftickCount = 0;&#xA;    myTest = 3;&#xA;  }&#xA;}&#xA;ISR(PCINT2_vect) {&#xA;  //Triggered by activation of Home Position Sensor&#xA;  myTest = 4;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19267" LastEditorUserId="4628" LastEditDate="2017-01-09T07:41:25.357" LastActivityDate="2017-01-09T07:41:25.357" Title="Strange results trying to count pulses" Tags="|arduino-nano|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21808" PostTypeId="2" ParentId="21806" CreationDate="2016-03-14T19:18:58.863" Score="1" Body="&lt;p&gt;There is no need to use int32_t for some of the variables. The problem with using variables that are more than 8 bits on a 8-bit processor, is that the processor needs 4 reads to get the value. In the middle of those reads an interrupt might occur, resulting in a value that has some bits of the old value, and some bits of the new.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some variable only need 8 bits.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t volatile myTest = 0;&#xA;int32_t volatile totalCount = 0L;&#xA;int32_t volatile tickCount = 0L;&#xA;uint8_t volatile halftickCount = 0;&#xA;int8_t volatile addPulse = 0L; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The next thing is to make the reading of the value atomic.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()                                             &#xA;{                                               &#xA;//******************************COMMAND ACTIONS******************************  &#xA;&#xA;if (myTest == 3)   //RE tick&#xA;{&#xA;    noInterrupts();&#xA;    int32_t tickCountCopy = tickCount;&#xA;    int32_t totalCountCopy = totalCount;&#xA;    interrupts();&#xA;    Serial &amp;lt;&amp;lt; &quot;Tick Count = &quot; &amp;lt;&amp;lt; tickCountCopy &amp;lt;&amp;lt; &quot;  totalCount = &quot; &amp;lt;&amp;lt; totalCountCopy &amp;lt;&amp;lt; &quot;\n&quot;; &#xA;    myTest = 0; &#xA;}&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS. this is not necessarily an answer, but it didn't fit in the comments.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-14T19:18:58.863" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21809" PostTypeId="1" CreationDate="2016-03-14T17:36:48.933" Score="0" ViewCount="769" Body="&lt;p&gt;I am trying to get my Atmel SAMD11 XPLAINED PRO and arduino to talk to each other using SPI. I have set up the arduino as the master, with the SAMD11 as the slave. On the ATMEL, I have the following code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://asf.atmel.com/docs/latest/samd21/html/asfdoc_sam0_sercom_spi_slave_callback_use.html&quot; rel=&quot;nofollow&quot;&gt;http://asf.atmel.com/docs/latest/samd21/html/asfdoc_sam0_sercom_spi_slave_callback_use.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, it waits until the master sends data, compares the data with what it expects, and updates an LED accordingly. On the arduino side, I have the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define BUF_LENGTH 20&#xA;int slave_select = 10;&#xA;&#xA;void setup (void)&#xA;{&#xA;  // Initialize serial for DEBUG.&#xA;  Serial.begin(9600);&#xA;  pinMode (slave_select, OUTPUT);&#xA;  digitalWrite(slave_select, HIGH);  // ensure SS stays high for now&#xA;  // Put SCK, MOSI, SS pins into output mode&#xA;  // also put SCK, MOSI into LOW state, and SS into HIGH state.&#xA;  // Then put SPI hardware into Master mode and turn SPI on&#xA;  SPI.beginTransaction (SPISettings (4000000, MSBFIRST, SPI_MODE0));  // 4 MHz clock, MSB first, mode 0&#xA;  // Master initialized.&#xA;  Serial.println(&quot;Master Initialized&quot;);&#xA;}  // end of setup&#xA;&#xA;void loop (void)&#xA;{&#xA;  static uint8_t buffer_expect[BUF_LENGTH] = {&#xA;    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,&#xA;     0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13&#xA;  };&#xA;  // enable Slave Select&#xA;  digitalWrite(slave_select, LOW);    // SS is pin 10&#xA;&#xA;  //write the 20 bytes&#xA;  for (int I=0;I&amp;lt;20;I++)&#xA;  {&#xA;    SPI.transfer(buffer_expect[I]); //write data byte&#xA;    delay(20);&#xA;  }&#xA;&#xA;  // disable Slave Select&#xA;  digitalWrite(slave_select, HIGH);&#xA;&#xA;  delay (1000);  // 1 seconds delay &#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the code, the LED on the SAMD11 isn't updated, which means that it is waiting for data to be sent, and hasn't received any, despite what the arduino code writes. On the hardware side, I have GND connected on both boards, VCC on the SAM to 5V on the arduino, and SPI_SS_A, MOSI, MISO and SCK connected to pins 10,11,12 and 13 on the arduino respectively. &lt;/p&gt;&#xA;" OwnerUserId="19289" OwnerDisplayName="trset test" LastEditorUserId="19289" LastEditDate="2016-03-15T15:02:01.777" LastActivityDate="2019-03-19T19:28:47.420" Title="ATMEL SAMD11 SPI (Slave) With Arduino (Master)" Tags="|spi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21810" PostTypeId="2" ParentId="21809" CreationDate="2016-03-14T18:52:24.633" Score="1" Body="&lt;p&gt;You haven't set your SS pin as an output anywhere in your code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino page you linked to has a note near the bottom which reads:  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note about Slave Select (SS) pin on AVR based boards&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;All AVR based boards have an SS pin that is useful when they act as a&#xA;  slave controlled by an external master. Since this library supports&#xA;  only master mode, this pin should be set always as OUTPUT otherwise&#xA;  the SPI interface could be put automatically into slave mode by&#xA;  hardware, rendering the library inoperative. It is, however, possible&#xA;  to use any pin as the Slave Select (SS) for the devices. For example,&#xA;  the Arduino Ethernet shield uses pin 4 to control the SPI connection&#xA;  to the on-board SD card, and pin 10 to control the connection to the&#xA;  Ethernet controller.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Example code given for the teensy board on the other page you linked has:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode (slaveSelectPin, OUTPUT); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in its setup() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's what you're missing.&lt;br&gt;&#xA;Setting the pin high or low is not going to achieve anything if its not an output.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that SPI can access many diffrent devices using the same MOSI/MISO/SCK pins, but each slave device has its own Slave-Select pin which needs to be individually driven by the master.&lt;br&gt;&#xA;Your master can therefore have many different SS pins, all set as outputs - and there is no single standard pin for this.&lt;/p&gt;&#xA;" OwnerUserId="8166" OwnerDisplayName="brhans" LastActivityDate="2016-03-14T18:52:24.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21811" PostTypeId="2" ParentId="19526" CreationDate="2016-03-14T19:27:16.743" Score="2" Body="&lt;p&gt;According to Adafruit &lt;a href=&quot;https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview&lt;/a&gt; these led matrixes require active scanning. It means that the RGBMatrixPanel will set up some scanning interrupt to refresh the screen periodically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can very much interfere with serial receive, as according to Adafruit, the panels require a serious data transmission all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the followings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;have one byte serial commands, e.g. N for &quot;on&quot; and F for &quot;off&quot; (I know you will need more complex commands, but this is just to verify the theory)&lt;/li&gt;&#xA;&lt;li&gt;remove all debug Serial.printlns (those also consume some time)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    char incomingByte = Serial.read();&#xA;    if (incomingByte=='N') {&#xA;       matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));&#xA;    }&#xA;    if (incomingByte=='F') {&#xA;       matrix.drawPixel(0, 0, matrix.Color333(0, 0, 0));&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-14T19:27:16.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21812" PostTypeId="1" CreationDate="2016-03-14T20:09:55.963" Score="4" ViewCount="1185" Body="&lt;p&gt;Long story short, I'm trying to build some form of device that you can wear and it will detect when something moves behind you. I wanted to use PIR sensors for the motion detection, but I have no idea if they can detect objects if you're moving. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="19270" LastEditorUserId="26717" LastEditDate="2017-01-02T11:05:49.223" LastActivityDate="2017-08-21T15:40:37.403" Title="Moving motion sensor?" Tags="|arduino-uno|sensors|electronics|project|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21813" PostTypeId="1" CreationDate="2016-03-14T20:12:30.800" Score="0" ViewCount="1834" Body="&lt;p&gt;I am reading sound input every 60 seconds and I would like to calculate the average of sound during that period using non-blocking code; what should I do to change the way that I calculate it in separated function as I need to do something else with other sensors.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int calculateSoundValue(){&#xA;    int average = analogRead(0);&#xA;    // loop to calculate the average simple formula sum div nbr of calculated times&#xA;    return average;&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;&#xA;}&#xA;void loop() {&#xA;  // I donùt wanna calculate the average inside a loop but instead inside a function &#xA;  int value = calculateSoundValue();&#xA;  Serial.println(value);&#xA;&#xA;  delay(600);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this what you mean ? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousMillis = 0;&#xA;const long interval = 6000;  &#xA;int totalSamples = 0; &#xA;int count = 0&#xA;&#xA;    int calculateSoundValue(){&#xA;        int sound = analogRead(0);&#xA;        totalSamples+= sound;&#xA;        count += 1;&#xA;        return totalSamples/count;&#xA;    }&#xA;&#xA;void setup() {&#xA;  // set the digital pin as output:&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  unsigned long currentMillis = millis();&#xA;int totalSamples = 0; &#xA;int count = 0&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;    previousMillis = currentMillis;&#xA;&#xA;  }&#xA;      int value = calculateSoundValue();&#xA;      Serial.println(value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5134" LastEditorUserId="10794" LastEditDate="2016-03-14T22:10:31.927" LastActivityDate="2016-03-16T14:47:21.217" Title="Getting the average of sound in last minute" Tags="|arduino-uno|c++|analogread|sound|" AnswerCount="3" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="21814" PostTypeId="2" ParentId="21812" CreationDate="2016-03-14T20:24:49.417" Score="2" Body="&lt;p&gt;PIR sensors detect the movement of a warm body &lt;em&gt;relative&lt;/em&gt; to the location of the PIR sensor.  Therefore if the PIR sensor moves then the location of a static object &lt;em&gt;relative to&lt;/em&gt; that PIR sensor will change and motion will be detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, PIR is not really suitable for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TBH I can't, off the top of my head, think of a simple way of achieving what you want short of image processing with OpenCV on something considerably more powerful than an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-14T20:24:49.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21817" PostTypeId="2" ParentId="18903" CreationDate="2016-03-14T21:50:26.373" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/users/17192/aranganathan&quot;&gt;ArangaNathan&lt;/a&gt; has posted &lt;a href=&quot;https://arduino.stackexchange.com/questions/18903/connecting-esp8266-with-arduino-uno-wifi-shield-not-present/20502#20502&quot;&gt;another Fritzing diagram&lt;/a&gt; with the same errors as the opening diagram: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can't drive the ESP8266 from the Arduino 3.3V pin as it can only supply 50mA but the ESP requires &gt; 200mA to transmit properly.&lt;/li&gt;&#xA;&lt;li&gt;All I/O wires between Arduino and ESP must be level shifted from 5V to 3.3V otherwise you will damage the ESP. It may not happen straight away, but it will happen. &lt;/li&gt;&#xA;&lt;li&gt;If you wire Arduino Tx &amp;lt;-&gt; ESP Tx and Arduino RX &amp;lt;-&gt; ESP Rx you must remove the Arduino MCU chip completely before powering on, and use the Arduino IDE monitor to send commands to the ESP.&lt;/li&gt;&#xA;&lt;li&gt;If you don't remove the MCU then you have to wire Arduino TX-&gt;RX and Arduino Rx&amp;lt;-TX. &lt;/li&gt;&#xA;&lt;li&gt;If also you want to use the Arduino IDE in this mode (MCU installed) then you can't wire ESP TX/RX to D0/D1 and must use other pins instead (e.g. D2/D3) and SoftSerial to create another serial UART port.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19087" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-15T04:36:13.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21818" PostTypeId="2" ParentId="21706" CreationDate="2016-03-14T21:51:17.213" Score="1" Body="&lt;p&gt;Arduino accesories are generally large because they are meant to be easy to use. mpu-6050 is a good example and you can find many decent breakout boards for it. But if you really want it to be very small, you should consider a custom solution for your problem like designing a PCB that holds both the microcontroller and the accelerometer. &lt;/p&gt;&#xA;" OwnerUserId="19264" LastActivityDate="2016-03-14T21:51:17.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21819" PostTypeId="2" ParentId="21813" CreationDate="2016-03-14T21:58:05.237" Score="0" Body="&lt;p&gt;The short answer is use millis() to keep track of time. You can also put all the time related stuff inside a class to have a nicely organized code. You can get more info about time management on the Arduino here. &lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-1/ditch-the-delay&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/multi-tasking-the-arduino-part-1/ditch-the-delay&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19264" LastActivityDate="2016-03-14T21:58:05.237" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21820" PostTypeId="2" ParentId="21813" CreationDate="2016-03-14T22:10:58.770" Score="1" Body="&lt;p&gt;You want to find the average of doing an &lt;code&gt;analogRead&lt;/code&gt; over a minute, is that it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How about this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long total;&#xA;unsigned int count;&#xA;&#xA;unsigned long whenStarted;&#xA;&#xA;const unsigned long INTERVAL = 60000;  // one minute&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println (F(&quot;Starting ...&quot;));&#xA;  whenStarted = millis ();&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;  // one more sample&#xA;  total += analogRead (0);&#xA;  count++;&#xA;&#xA;  if (millis () - whenStarted &amp;gt;= INTERVAL) // is a minute up?&#xA;    {&#xA;    Serial.print (F(&quot;Average = &quot;));&#xA;    Serial.println (total / count);&#xA;    total = 0;&#xA;    count = 0;&#xA;    whenStarted = millis ();&#xA;    }&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-14T22:10:58.770" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21821" PostTypeId="1" AcceptedAnswerId="21822" CreationDate="2016-03-14T22:41:16.237" Score="0" ViewCount="1217" Body="&lt;p&gt;On &lt;a href=&quot;https://www.arduino.cc/en/Main/Donate&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; page on Arduino's website, it states &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;HUNDREDS OF COMPANIES AROUND THE WORLD ARE USING IT &lt;em&gt;[Arduino Software]&lt;/em&gt; TO PROGRAM THEIR&#xA;  DEVICES, INCLUDING COMPATIBLES, &lt;strong&gt;CLONES, AND EVEN COUNTERFEIT&lt;/strong&gt;.&quot;&#xA;  (Emphasis Added)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With open source electronics, what is the difference between a clone, and a counterfeit? &lt;/p&gt;&#xA;" OwnerUserId="11898" OwnerDisplayName="Eric Johnson" LastEditorUserId="11898" LastEditDate="2017-01-04T15:41:05.363" LastActivityDate="2017-01-04T15:41:05.363" Title="Clone vs Counterfeit (Arduino)" Tags="|clones|counterfeit|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21822" PostTypeId="2" ParentId="21821" CreationDate="2016-03-14T23:14:05.137" Score="7" Body="&lt;p&gt;This is not gospel, but here is what those terms are generally used to indicate (as I understand it):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;compatible: a dev board which is compatible with the Arduino IDE/toolchain. The Arduino UNO uses an ATmega328 MCU, while other platforms may use different MCUs i.e. there are multiple MCUs that are compatible with the Arduino IDE. It may or may not have the same form factor. Keep in mind that this term can also be used for shields, &quot;Arduino-compatible&quot; shields are add-on boards that are meant to mate with an Arduino. The &lt;a href=&quot;https://www.sparkfun.com/products/12757&quot; rel=&quot;nofollow&quot;&gt;Sparkfun RedBoard&lt;/a&gt; is an example.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;clone: a dev board which has the same (or very similar) circuitry as an Arduino and the same physical board/layout. They are branded differently, but are, for all intents and purposes, exactly the same as a real Arduino. These boards are permitted under the open-source licensing of the Arduino design. An &lt;a href=&quot;http://www.freeduino.org/freeduino_open_designs.html&quot; rel=&quot;nofollow&quot;&gt;Freeduino&lt;/a&gt; might be an example.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;counterfeit: a dev board which is identical to an original Arduino, and is branded and sold as an original Arduino. As I understand it, the open-source licensing &lt;em&gt;does not&lt;/em&gt; permit this, however, this does not deter the flood of shops churning out counterfeit Arduinos. A search on eBay or Aliexpress will turn up loads of examples; note the &lt;a href=&quot;https://www.arduino.cc/en/Products/Counterfeit&quot; rel=&quot;nofollow&quot;&gt;Arduino guide to spotting counterfeits&lt;/a&gt;, in general, the silkscreen is blue and the quality of assembly is not quite as good.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The difference between &quot;compatible&quot; and &quot;clone&quot; is a bit blurry, but it's not really important. The main difference between counterfeit and non-counterfeit is that counterfeit Arduinos are boards that are &lt;em&gt;not sold by Arduino but are branded as such&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16988" OwnerDisplayName="uint128_t" LastEditorUserId="16988" LastEditDate="2016-03-15T16:32:46.480" LastActivityDate="2016-03-15T16:32:46.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21823" PostTypeId="1" CreationDate="2016-03-15T00:13:40.943" Score="2" ViewCount="437" Body="&lt;p&gt;&lt;em&gt;Transferred from stackoverflow on the advice of @Gee_Bee:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I can get &lt;a href=&quot;https://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;Writing a Library for Arduino&lt;/a&gt; to work as well as&#xA;  &lt;a href=&quot;http://arduino.land/FAQ/content/7/43/en/breaking-a-sketch-into-multiple-files.html&quot; rel=&quot;nofollow&quot;&gt;Breaking a sketch into multiple files&lt;/a&gt; and &lt;a href=&quot;http://arduinoetcetera.blogspot.com/2011/01/classes-within-classes-initialiser.html&quot; rel=&quot;nofollow&quot;&gt;Classes within Classes&#xA;  - Initialiser Lists&lt;/a&gt;. I can even get extern references to variables to work but referencing the an instance of ESP8266WebServer in&#xA;  different files is still beyond me.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As my sketches get bigger, the code looks awful as one file and the number of global variables is too high. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the webconfig part of my sketch the device attempts to get online and if it fails it scans for available Wi-Fi networks, goes into Access Point Mode, starts a server, sends the list of SSID's and listens for a response of an SSID/password pair. The server is only for the configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally I'd like the cleaned up &lt;code&gt;main.ino&lt;/code&gt; file to look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &quot;config.h&quot;&#xA;    void setup(){&#xA;        Serial.begin(115200);&#xA;        Serial.println();&#xA;        Serial.println(&quot;--------------------------&quot;);&#xA;      Serial.println(&quot;ESP8266 multifile&quot;);&#xA;      Serial.println(&quot;--------------------------&quot;);&#xA;      getOnline();&#xA;    }&#xA;    void loop(){&#xA;        if(IN_CONFIG_MODE){&#xA;           server.handleClient();&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with a &lt;code&gt;config.h&lt;/code&gt; something like..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #ifndef config_h&#xA;    #define config_h&#xA;        #include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;        #include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;        ESP8266WebServer server;&#xA;        void getOnline();&#xA;    #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then a &lt;code&gt;config.cpp&lt;/code&gt; where it does all stuff described above yet gives the &lt;code&gt;main.ino&lt;/code&gt; program access to the &lt;code&gt;server&lt;/code&gt; instance so it can listen in the main loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;config.h&quot;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;&#xA;char *espssid = &quot;espAPsb&quot;;&#xA;char *ssid = &quot;street_no_vale2&quot;;&#xA;char *pwd = &quot;jjjjjjjjx&quot;;&#xA;char ssids[300];&#xA;&#xA;extern server(80);&#xA;&#xA;void handleRoot(){&#xA;    server.send(200, &quot;text/html&quot;, &quot;&amp;lt;h1&amp;gt;root of espAPsb AP server&amp;lt;/h1&amp;gt;&quot;);&#xA;    //send json of available ssids&#xA;}&#xA;&#xA;void scan(){&#xA;  WiFi.mode(WIFI_STA);&#xA;  WiFi.disconnect();&#xA;  delay(100);&#xA;  int n = WiFi.scanNetworks();&#xA;  Serial.println(&quot;scan done&quot;);  &#xA;  if (n == 0)&#xA;    Serial.println(&quot;no networks found&quot;);&#xA;  else&#xA;  {&#xA;    Serial.print(n);&#xA;    Serial.println(&quot; networks found&quot;);&#xA;    for (int i = 0; i &amp;lt; n; ++i)&#xA;    {&#xA;      // Print SSID and RSSI for each network found&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot;: &quot;);&#xA;      Serial.print(WiFi.SSID(i));&#xA;      Serial.print(&quot; (&quot;);&#xA;      Serial.print(WiFi.RSSI(i));&#xA;      Serial.print(&quot;)&quot;);&#xA;      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?&quot; &quot;:&quot;*&quot;);&#xA;      delay(10);&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;&quot;);   &#xA;}&#xA;&#xA;void setupAP(){&#xA;    WiFi.softAP(espssid);&#xA;    server.on(&quot;/&quot;, handleRoot);&#xA;    server.begin();&#xA;  Serial.println();&#xA;  Serial.print(&quot;connected as AP &quot;);&#xA;  Serial.println(espssid);&#xA;  Serial.print(&quot;IP address: &quot;);&#xA;  Serial.println(WiFi.softAPIP());  &#xA;}&#xA;&#xA;void getOnline(){&#xA;    WiFi.begin(ssid, pwd);&#xA;  int tries =0;&#xA;  int success=1;&#xA;  while (WiFi.status() != WL_CONNECTED ) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;    tries++;&#xA;    if (tries==15){&#xA;      success=0;&#xA;      Serial.println(&quot;WiFi not connected&quot;);&#xA;      scan();&#xA;      setupAP();&#xA;      break;&#xA;    }&#xA;  }&#xA;  if (success){&#xA;    Serial.println(&quot;&quot;);&#xA;    Serial.println(&quot;WiFi connected&quot;);&#xA;    Serial.print(&quot;IP address: &quot;);&#xA;    Serial.println(WiFi.localIP());    &#xA;  } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18628" LastEditorUserId="6936" LastEditDate="2016-03-16T07:34:00.790" LastActivityDate="2021-08-30T20:08:26.957" Title="Multi-file arduino esp8266 sketch sharing a reference to server" Tags="|c++|arduino-ide|esp8266|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21826" PostTypeId="1" CreationDate="2016-03-15T03:27:32.413" Score="4" ViewCount="410" Body="&lt;p&gt;When I call the tone function on a Uno, why do I not have to declare the pinmode in setup? Like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Simplest tone&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;    tone (8,500); //on pin 8 output 500 Hz&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19076" LastEditorUserId="46" LastEditDate="2016-03-15T19:08:14.597" LastActivityDate="2016-03-15T19:10:12.870" Title="When I call the tone function on a Uno, why do I not have to declare the pinmode in setup?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21827" PostTypeId="2" ParentId="21826" CreationDate="2016-03-15T03:56:05.550" Score="7" Body="&lt;p&gt;Because the &lt;code&gt;tone(hertz)&lt;/code&gt; code initializes the pinmode, along with the timer/counter control registers to produce the appropriate frequency.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)&#xA;{&#xA;  uint8_t prescalarbits = 0b001;&#xA;  long toggle_count = 0;&#xA;  uint32_t ocr = 0;&#xA;  int8_t _timer;&#xA;&#xA;  _timer = toneBegin(_pin);&#xA;&#xA;  if (_timer &amp;gt;= 0)&#xA;  {&#xA;    // Set the pinMode as OUTPUT&#xA;    pinMode(_pin, OUTPUT);&#xA;   ... &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Tone.cpp#L255&quot; rel=&quot;nofollow&quot;&gt;Tone.cpp - line 255&lt;/a&gt; for the source.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastEditorUserId="46" LastEditDate="2016-03-15T19:10:12.870" LastActivityDate="2016-03-15T19:10:12.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21828" PostTypeId="2" ParentId="21762" CreationDate="2016-03-15T04:20:43.920" Score="0" Body="&lt;p&gt;Your switch 2 code includes a myservo.detach() at the end which prevents any further server code from operating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the switch 1 code to execute only once, you could add a myservo.detach() to the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also seem to want to recycle for the appropriate number of times if you clear the switch.  For this, you may want to myservo.attach(9) when all the switches are open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately,  you could avoide the detach() and attach() by adding a one-shot flag to the conditionals, set it inside the conditional, and clear it when the switches are clear.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   if (!s1state &amp;amp; !s2state &amp;amp; !s3state &amp;amp; !s4state) armed = 1;&#xA;   ...&#xA;&#xA;   if (armed &amp;amp; s1state == LOW) {     // read the stored input pin value&#xA;       armed = 0;&#xA;       ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-15T04:20:43.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21829" PostTypeId="1" AcceptedAnswerId="21836" CreationDate="2016-03-15T07:05:25.463" Score="0" ViewCount="285" Body="&lt;p&gt;Originally I had an idea to develop an Arduino-compatible project using an &lt;strong&gt;ATmega328P&lt;/strong&gt;, some sensors and the &lt;strong&gt;nRF51822&lt;/strong&gt; as the BLE radio. As I progressed, I realized that if I relaxed the Arduino-compatible requirement, I could actually do away with the ATmega328P and write the application directly on the nRF51822 as it is a more capable MCU (32-bit, more memory, faster, has SPI, I2C and TTL serial, etc.) I'm not familiar with writing native applications for the nRF51822 but it seems much more complicated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For someone that has experience in both platforms, can you please list some of the tradeoffs of developing using an ATmega328P for application + nRF51822 for radio and using the nRF51822 for both application and radio?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="18795" LastEditDate="2016-03-15T07:17:59.790" LastActivityDate="2016-03-15T15:55:27.620" Title="Arduino development vs nRF51 development" Tags="|bluetooth|nrf51|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21831" PostTypeId="2" ParentId="1848" CreationDate="2016-03-15T09:27:59.217" Score="0" Body="&lt;p&gt;There are a number of ways to get more inputs and outputs, with different implications.  And it depends on the types of sensors, and on the libraries or code snippets you want to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first thing you need to do is list the sensors you want, along with the type of interface each uses; I use a spreadsheet.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a flame sensor could just use a single digital output (going to a digital input on the Arduino), with the threshold set with a pot on the module.  Or it could output an analog signal which goes to an analog input on the Arduino, allowing the code to detect intensity or set varying thresholds without needing to move the pot.  Each approach has different implications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are still other sensor and actuator interfaces besides these two (simple digital and analog).  Some give a variable value (like analog) but based on timing a pulse on a digital signal; this is how most inexpensive ultrasonic rangefinders work.  And of course there are sensors which use standard (I2C or SPI) or proprietary (one-wire protocol, or the DHT-xx temp &amp;amp; humidity sensors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likewise some outputs will need PWM or other signally, beyond simple on/off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra simple digital inputs, or outputs, can be had fairly easy with I2C extenders, or with shift registers.  For example, checking a digital output flame sensor, or turning on a light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Extra analog inputs can be done with analog multiplexing (like an electronic switch), or via external ADC modules using I2C or SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If timing is required, there are larger potential problems. Often you would use a library to handle such things.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Libraries.&lt;/strong&gt; Most sensor and actuator libraries will be written to use direct input and output pins on the Arduino.  You may be able to pass a pin number when initializing, but if you are using a shift register or extender there's no way to tell the library how to use your custom extension.  In this case you will have to roll our own code without using the library, or make a modified version of the library which does I/O through your hardware extension hardware.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Special Pin Functions.&lt;/strong&gt; A second problem is special pin functions; if the library or code snippet you want to use expects to use a special feature of a pin (like a pin interrupt, or a timer input capture), that may not be available from your extension hardware, or may be extra work to handle.  For example, some extenders may be able to signal an interrupt pin on the Arduino when one of their inputs changes - but you'll have to write your own interrupt handler to catch that, and replace the functionality of the direct pin interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Timing.&lt;/strong&gt;  And a third problem is that sometimes tight timing is hard to manage through extension hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of these can be resolved with appropriate effort, sometimes easy and sometimes not.  Look through your list of sensors and actuators; sort out which ones can most easily be attached to extension hardware (like a shift register), and which ones should be directly attached to the Arduino for simplicity or performance.  You could be lucky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Recommendations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) If you can handle any fancy sensors or actuators with direct pins, and cover any simple ones with shift registers or I2C extender chips, that's a viable option.  For example, if your code wants to check occasionally whether a flame has been sensed (digital version), or wants to turn on a motor, it's not that hard to go through a shift register instead of doing a direct pin access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) If you go beyond that, and run out of pins for things that are much easier to handle when directly connected, then I suggest going to a Mega or Mega2560.&#xA;It has more digital pins and more analog inputs and more PWM outputs.  Most (tho not all) libraries will adapt just by changing pin numbers.  It's much easier than rewriting libraries to use external digital and analog pins.&lt;/p&gt;&#xA;" OwnerUserId="1186" LastEditorUserId="1186" LastEditDate="2016-03-15T09:35:21.393" LastActivityDate="2016-03-15T09:35:21.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21833" PostTypeId="1" CreationDate="2016-03-15T12:30:02.903" Score="1" ViewCount="4200" Body="&lt;p&gt;I am looking for ideas on how to connect 12 sensors to an Arduino wirelessly.  The sensors will be about 10ft from the Arduino.  They need to send one byte of data every 100ms-250ms to the Arduino in an organized manner.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have investigated MQTT and pubsubclient, but have not found a way to make an Arduino a Broker, and have been told it is very inefficient for my application.&lt;/li&gt;&#xA;&lt;li&gt;I have looked at NRF24L01, but it appears to be limited to just 6 pipes to receive data in an organized fashion.&lt;/li&gt;&#xA;&lt;li&gt;I researched Xbee, but have been told that it cannot keep up with the data rate.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other suggestions are appreciated...  Thank you.&lt;/p&gt;&#xA;" OwnerDisplayName="user19216" LastActivityDate="2018-11-09T12:55:56.730" Title="Multiple Wireless Sensors to an Arduino" Tags="|arduino-uno|sensors|wireless|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21834" PostTypeId="2" ParentId="21833" CreationDate="2016-03-15T13:02:38.760" Score="1" Body="&lt;p&gt;It might be easiest to send a UDP packet over WiFi.  There is no extra packet overhead for this &quot;connectionless&quot; protocol: no OPEN, no ACK/NAK, no CLOSE, etc.  The incremental cost for additional bytes is very small, so if you decide you need to send 2 bytes, or even 100 bytes, it won't affect the throughput very much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can &quot;batch&quot; the bytes, that would be even better.  For example, could you send 8 bytes per node, once every 800ms-2000ms?  If not, WiFi speeds should allow the single-byte UDP packet to get through without much latency.  Do you know what latency the receiver can accommodate?  You might get lower &lt;em&gt;average&lt;/em&gt; latency with batched packets, depending on the network access time (i.e., how long it takes to hop on to the air).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A roll-your own approach would be to use a raw RF transmitter/receiver with something like VirtualWire.  With proper synchronization from the &quot;master&quot;, the slaves could each have their own time slot, avoiding collisions (which keeps the network access time low)&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-03-15T13:02:38.760" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21835" PostTypeId="2" ParentId="21736" CreationDate="2016-03-15T13:07:51.720" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to program Arduino in Pascal?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The answer is yes and no. The answer is yes because it is possible to port the &lt;a href=&quot;https://en.wikipedia.org/wiki/P-code_machine&quot; rel=&quot;nofollow&quot;&gt;p-code&lt;/a&gt; virtual machine to Arduino and compile for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer is no if extending the question with &quot;is there a supported open-source Arduino/AVR IDE for Pascal available?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few commercial AVR/Pascal products. You can easily web-search them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last, a possible short-cut is to use &lt;a href=&quot;https://schneider.ncifcrf.gov/p2c/&quot; rel=&quot;nofollow&quot;&gt;p2c&lt;/a&gt;, a Pascal to C translator, as a pre-processor in the Arduino IDE. There are hooks in the Arduino build for adding additional tools. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-15T13:07:51.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21836" PostTypeId="2" ParentId="21829" CreationDate="2016-03-15T13:36:44.153" Score="0" Body="&lt;p&gt;First, there are various ports of the Arduino environment to the NRF51822, but I'll leave that aside for the moment and address using Nordic's codebase or the mbed one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally speaking, one of these paths will put you more in the current &quot;real world&quot; of professional level embedded development, in which the ARM cortex parts play a leading role.  You will have conventional multiple source file projects tied together by more ordinary means such as a Makefile or explicit IDE configuration, rather than the rather oddball way the Arduino IDE has evolved to do things.  The basic lower level APIs you will be writing against will be much more conventional - ie, your code will start in &lt;code&gt;main()&lt;/code&gt; rather than &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt;, you will generate debug messages with &lt;code&gt;printf()&lt;/code&gt; or similarly styled member function on mbed, rather than Arduino type &lt;code&gt;print()&lt;/code&gt;/&lt;code&gt;println()&lt;/code&gt; (though of course you can use &lt;code&gt;printf()&lt;/code&gt; on an Arduino with some setup).  This tends to make it a lot easier to port or share code between this and other embedded systems, or even between an embedded system and a phone or desktop communicating with or simulating it.  Of course you can treat an Arduino as a plain ATmega and do this with that as well, up to the limits of the CPU and its memories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People tend to think of the mbed option as being an online &quot;toy&quot; for certain boards, but you can generally use others just by setting it for a board using the same MCU in a similar way.  And in most cases you can download a zipfile of a project with a Makefile in it that will drive arm-gcc or a few other compiler choices.  The NRF51822 does come in varieties with different onboard storage sizes, and this can sometimes require care and attention to the linker script - in a few cases a project that fits in the online build (apparently with the Keil compilation engine as its backed) will not build in the downloaded GCC configuration unless you adjust the linker script to reduce the stack size, or perhaps change compiler optimization levels. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Countering reasons you might end up keeping the ATmega would be if you need some of its I/O peripherals or its 5v I/O capability.  For example, the NRF51822 has limited hardware PWM capability compared to an ATmega so that must generally be done in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really at home with &quot;The Arduino Way&quot; switching to anything more traditional may take some adjustment of thinking and habits.  On the other had, if you look at the benefits of Arduino being the variety of works-out-of-the-box, easily modified examples you can use to explore the possibility of a project, but often find yourself annoyed by the legacy of its countless quirks and atypical approaches in the longer run, then you'll probably find the adaptation to using the NRF51822 directly to have been worthwhile.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-03-15T15:55:27.620" LastActivityDate="2016-03-15T15:55:27.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21837" PostTypeId="2" ParentId="21833" CreationDate="2016-03-15T13:41:28.100" Score="2" Body="&lt;p&gt;I would recommend the nRF24L01.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need one pipe per node - just one pipe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each pipe is effectively an address that a node responds to - having multiple pipes means you can have multiple addresses on one node (like aliases) - but of course you only need one address per node, and hence one pipe per node.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The range is more than adequate (with the antenna version I have managed to get hundreds of meters no problem) and the price is so low as to be negligible.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-15T13:41:28.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21838" PostTypeId="1" AcceptedAnswerId="21907" CreationDate="2016-03-15T12:40:08.073" Score="0" ViewCount="380" Body="&lt;p&gt;I just managed to get Dean Camera's LUFA AVRISP clone working on my Arduino Pro Micro, when to my dismay I found that to use PDI for my XMega, I need to have PD5 exposed for the clock source! The Pro Micro has PD5 connected to an LED, so I am not easily able to use it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If worst comes to worst, I can desolder the LED and wire a jumper, but that would be a pain in the butt. So I am wondering if any of you know if I can change the clock pin assignment from PD5 to PD6 or some other accesible pin. Thank you in advance for your help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--[[ EDITS ]]--&#xA;Sorry for my lack of clarity, I am using the Pro Micro as the programmer, and the AVRISP clone supports PDI to the XMEGA. The 32u4 is actually directly supported by the programmer firmware. Here is what I am doing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--[[ EDITS II ]]--&#xA;There is a schematic.. umm.. draw-o? I don't know but anyway the cathodes of D1 and D3 are NOT connected. That wire is an error.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/y1XxH.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fy1XxH.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--Cantos&lt;/p&gt;&#xA;" OwnerUserId="19039" OwnerDisplayName="KilowattLaser" LastEditorUserId="19039" LastEditDate="2016-03-17T13:15:40.010" LastActivityDate="2019-10-11T22:35:44.467" Title="How do I change pin assignments for the LUFA AVRISPMkII?" Tags="|usb|isp|arduino-pro-micro|programmer|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21839" PostTypeId="2" ParentId="21838" CreationDate="2016-03-15T13:12:46.043" Score="0" Body="&lt;p&gt;Can you give more details on your problem? Schematics or something like that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I see from &lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, the Arduino Pro Micro uses ATmega32u4 chip, which is not part of XMega family, so I'm not sure if their internals are mutually compatible. In any case, if you configure PD5 as an input for your clock, it will work as an input, since it's a GPIO pin &lt;code&gt;(DDRD &amp;amp;= ~(1&amp;lt;&amp;lt;PIN5))&lt;/code&gt;. You'll just additionally have the LED blinking :). You can also configure PD6 as an input in the same way &lt;code&gt;(DDRD  &amp;amp;= ~(1&amp;lt;&amp;lt;PIN6))&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18891" OwnerDisplayName="Roker Pivic" LastActivityDate="2016-03-15T13:12:46.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21840" PostTypeId="2" ParentId="21833" CreationDate="2016-03-15T14:09:10.877" Score="1" Body="&lt;p&gt;Use nRF24L01. To avoid collisions you can query the sensors (as Chris suggested in comment).&#xA;The setup would be:&#xA;Each sensor would have unique address. Central unit would transmit request and sensor node would respond to it. Central unit would have different address and all sensors would transmit to that address. You can also use data in ack to pack response.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Central node (Addr0) -&gt; Sensor 1 (Addr1): Request&lt;/li&gt;&#xA;&lt;li&gt;Sensor 1 (Addr1) -&gt; Central node (Addr0): Response, sensor data&lt;/li&gt;&#xA;&lt;li&gt;Central node (Addr0) -&gt; Sensor 2 (Addr2): Request&lt;/li&gt;&#xA;&lt;li&gt;Sensor 2 (Addr2) -&gt; Central node (Addr0): Response, sensor data&lt;/li&gt;&#xA;&lt;li&gt;Central node (Addr0) -&gt; Sensor 3 (Addr3): Request&lt;/li&gt;&#xA;&lt;li&gt;Sensor 3 (Addr3) -&gt; Central node (Addr0): Response, sensor data&lt;/li&gt;&#xA;&lt;li&gt;...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18600" LastActivityDate="2016-03-15T14:09:10.877" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21841" PostTypeId="2" ParentId="21821" CreationDate="2016-03-15T15:48:31.190" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;With open source electronics, what is the difference between a clone, and a counterfeit? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Counterfeit&lt;/strong&gt;: the vendor says/implies that the Arduino board is produced by Arduino/Genuino, an &quot;original&quot;, but it is not. The screen-print is the same, but looking closer at the components and PCB there are some differences. You think you can turn to Arduino/Genuino for product support but you cannot. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Clone&lt;/strong&gt;: the vendor states that the board is a &quot;compatible copy&quot;, uses all the open-source bill-of-material, schematics, etc, (or slightly changed for cheaper components) when produced, and it is obviously not produced by Arduino/Genuino. You know that you cannot turn to Arduino/Genuino for product support. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The punishment for selling and buying (!!) counterfeit fashion in Italy is very severe. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Counterfeiting is &lt;a href=&quot;http://www.inta.org/TrademarkBasics/FactSheets/Pages/Counterfeiting.aspx&quot; rel=&quot;nofollow&quot;&gt;a trademark violation issue&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-15T15:48:31.190" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21842" PostTypeId="2" ParentId="999" CreationDate="2016-03-15T16:41:29.050" Score="2" Body="&lt;p&gt;The presence of those pins is a requirement of the technique that had to be used to interface the LCD to the microprocessors that were available back when the HD44780U controller chip was developed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Single chip microcontrollers as we know them were still in the future and the LCD had to be interfaced to the 8-bit microprocessor chips of the times using the same techniques as any other 8-bit I/O or memory device which was an 8-bit bus. &lt;/p&gt;&#xA;" OwnerUserId="19291" LastActivityDate="2016-03-15T16:41:29.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21843" PostTypeId="1" CreationDate="2016-03-15T17:17:45.363" Score="14" ViewCount="375" Body="&lt;p&gt;Arduino IDE 1.6.8, Arduino Due, Mac OS 10.11.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am seeing eight mysterious pulses on the RX line when I connect to the serial port using multiple client libraries (Python, JavaScript as well as the built-in Serial Monitor in the IDE). About 78-79us apiece, sampled at 1MS/s with a Logic Pro 16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VUXZf.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VUXZf.png&quot; alt=&quot;Mystery pulses&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These eight pulses when interpreted at 57600 baud will jam the Firmata firmware. And they happen on every connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is using a new install of the Arduino 1.6.8 IDE and with multiple sketches (the normal &quot;Blink&quot; sketch will reproduce this also).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repro steps on my machine:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Install any sketch&lt;/li&gt;&#xA;&lt;li&gt;Start a logic analyzer if you want to catch it&lt;/li&gt;&#xA;&lt;li&gt;Go to Serial Monitor. I have mine configured for 57600 baud, Newline line ending, but it doesn't matter&lt;/li&gt;&#xA;&lt;li&gt;If you want, close and repeat step 3&lt;/li&gt;&#xA;&lt;li&gt;Note pulses each time you connect to the serial port&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestions for diagnosing this? It sounds like it's serial driver-level in some way.&lt;/p&gt;&#xA;" OwnerUserId="19292" LastEditorUserId="46" LastEditDate="2016-03-15T19:02:40.270" LastActivityDate="2017-10-31T07:24:25.257" Title="Mysterious RX pulses on UART connect on OS X Arduino Due" Tags="|arduino-due|uart|osx|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="21844" PostTypeId="2" ParentId="21736" CreationDate="2016-03-15T17:49:36.910" Score="1" Body="&lt;p&gt;A &lt;a href=&quot;http://www.gnu-pascal.de/gpc/h-index.html&quot; rel=&quot;nofollow&quot;&gt;Pascal front-end&lt;/a&gt; to the Gnu compiler collection (gcc, on which nearly all the of AVR programming is based) already exists. Therefore, a Pascal compiler for AVR exists in principle if not in fact (and I don't know that it doesn't). I'd start by getting in touch with the folks working on the GPC to find out what has already been done.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-21T11:43:28.790" LastActivityDate="2016-03-21T11:43:28.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21846" PostTypeId="1" AcceptedAnswerId="21849" CreationDate="2016-03-15T19:39:22.427" Score="0" ViewCount="33476" Body="&lt;p&gt;I have the code, it's purpose is to receive the string from a comport like:&#xA;&lt;code&gt;Set@1234567890123456@1234567890123456@1234567890123456@1234567890123456&lt;/code&gt;&#xA;and translate it into four byte arrays &lt;code&gt;byte user1[16], user2[16], pass1[16], pass2[16]&lt;/code&gt;. Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String inString = &quot;&quot;; // COM port incoming data buffer&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Start&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  // Receive data from com port&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    int inChar = Serial.read();&#xA;&#xA;&#xA;    if (inChar != '\n') {&#xA;      inString += (char)inChar;&#xA;    } else {&#xA;      // New line&#xA;      String Action = inString.substring(0, 3);&#xA;      if (Action == &quot;Set&quot;) {&#xA;        SetCard(inString);&#xA;      } else if (Action == &quot;Get&quot;) {&#xA;        Serial.println(&quot;1&quot;);&#xA;      } else {&#xA;        Serial.println(Action);&#xA;      }&#xA;      inString = &quot;&quot;;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void SetCard(String Data) {&#xA;  Serial.println(Data);&#xA;  // Data Set@user1@user2@pass1@pass2&#xA;  // Set@1234567890123456@1234567890123456@1234567890123456@1234567890123456&#xA;  byte user1[16], user2[16], pass1[16], pass2[16];&#xA;&#xA;  String user1str = inString.substring(4, 20);&#xA;  String user2str = inString.substring(21, 37);&#xA;  String pass1str = inString.substring(38, 54);&#xA;  String pass2str = inString.substring(55, 71);&#xA;&#xA;  Serial.println(&quot;Strings&quot;);&#xA;  Serial.println(user1str);&#xA;  Serial.println(user2str);&#xA;  Serial.println(pass1str);&#xA;  Serial.println(pass2str);&#xA;&#xA;  Serial.println(&quot;Arrays&quot;);&#xA;  user1str.getBytes(user1, 16);&#xA;  user2str.getBytes(user2, 16);&#xA;  pass1str.getBytes(pass1, 16);&#xA;  pass2str.getBytes(pass2, 16);&#xA;&#xA;&#xA;  writeByteArray(user1, 16);&#xA;  writeByteArray(user2, 16);&#xA;  writeByteArray(pass1, 16);&#xA;  writeByteArray(pass2, 16);&#xA;}&#xA;&#xA;void writeByteArray(byte array[], int arrlength)&#xA;{&#xA;  for (int j = 0 ; j &amp;lt; arrlength ; j++) //print the block contents&#xA;  {&#xA;    Serial.write (array[j]);//Serial.write() transmits the ASCII numbers as human readable characters to serial monitor&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this code and send my string through a com port I expect the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start&#xA;Set@1234567890123456@1234567890123456@1234567890123456@1234567890123456&#xA;Strings&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;Arrays&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yet, I receive&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Start&#xA;Set@1234567890123456@1234567890123456@1234567890123456@1234567890123456&#xA;Strings&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;1234567890123456&#xA;Arrays&#xA;123456789012345&#xA;123456789012345&#xA;123456789012345&#xA;123456789012345&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? And how do I receive desired output?&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/StringGetBytes&quot; rel=&quot;nofollow&quot;&gt;getBytes docs&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19294" LastActivityDate="2021-10-01T05:16:07.480" Title="How to convert String to byte array" Tags="|arduino-uno|string|convert|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21847" PostTypeId="2" ParentId="21793" CreationDate="2016-03-15T19:39:24.477" Score="0" Body="&lt;p&gt;Depending on the jumper settings, the MegaMoto shield will drive current sense voltages onto one or two of the Arduino analog inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your picture shows the shunt installed to drive A0, which is of course going to conflict with your attempt to use the same pin for the force sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are not using current feedback, it seems like you may be able to just remove that jumper, otherwise you will need to pick distinct pins for the current sense and your force sensor.  Consult the manual to be certain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The other placement of the other jumper in that block looks a bit suspicious too, almost seems it may be shorting the two current sense channels together, but not certain about that)&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-03-15T19:39:24.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21848" PostTypeId="1" CreationDate="2016-03-15T19:40:01.363" Score="0" ViewCount="1935" Body="&lt;p&gt;I have found a similar qustion to mine but there was no good response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've connected my ESP8266 to Arduino UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I got some trouble with software serial communication with Arduino and decided to change baud-rate to 9600 (previously it was 115200).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used AT+IPR=9600 command to change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that blue led of esp stays on and not taking AT commands any more, but output some gibberish to serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I connected the esp8266 through a voltage regulator and a power source and both gave the same problem. My firmware is supposed to be updated so I don't think that it is the issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anyone please help me?&lt;/p&gt;&#xA;" OwnerUserId="19295" LastActivityDate="2016-03-16T13:29:51.533" Title="ESP8266 blue led stays stays on" Tags="|arduino-uno|esp8266|baud-rate|" AnswerCount="1" CommentCount="1" ClosedDate="2016-03-20T05:08:02.463" ContentLicense="CC BY-SA 3.0" />
  <row Id="21849" PostTypeId="2" ParentId="21846" CreationDate="2016-03-15T20:02:48.140" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why? And how do I receive desired output? getBytes docs&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The String member function &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/WString.cpp#L547&quot; rel=&quot;nofollow&quot;&gt;getBytes&lt;/a&gt;() will null-terminate the string. You must add space for that. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  byte user1[17], user2[17], pass1[17], pass2[17];&#xA;  ...&#xA;  user1str.getBytes(user1, sizeof(user1));&#xA;  ...&#xA;  Serial.print((char*) user1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That should do the trick.&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-15T20:02:48.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21850" PostTypeId="1" AcceptedAnswerId="21851" CreationDate="2016-03-15T20:46:43.160" Score="10" ViewCount="21092" Body="&lt;p&gt;I am reading about I2C. On this site:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/WireLibraryDetailedReference#endTransmission&quot; rel=&quot;noreferrer&quot;&gt;http://playground.arduino.cc/Main/WireLibraryDetailedReference#endTransmission&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says that &lt;code&gt;endTransmission()&lt;/code&gt; can return one of the following status codes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0: Successful send.&lt;/li&gt;&#xA;&lt;li&gt;1: Send buffer too large for the twi buffer. This should not happen, as the TWI buffer length set in twi.h is equivalent to the send buffer length set in Wire.h.&lt;/li&gt;&#xA;&lt;li&gt;2: Address was sent and a NACK received. This is an issue, and the master should send a STOP condition.&lt;/li&gt;&#xA;&lt;li&gt;3: Data was sent and a NACK received. This means the slave has no more to send. The master can send a STOP condition, or a repeated START.&#xA;4: Another twi error took place (eg, the master lost bus arbitration). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I attach nothing to my Arduino (or with pull-up resistors to both SDA/SCL), I always get status 2. But how can a NACK (or anything) be received when there is nothing to communicate with? Does it mean something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my example code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;}&#xA;void loop()  {&#xA;  Wire.beginTransmission(42);&#xA;  Wire.write(0);&#xA;  byte status = Wire.endTransmission();&#xA;  Serial.println(status); // always prints 2&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3267" LastActivityDate="2020-05-25T01:56:44.570" Title="What does it mean in I2C, &quot;NACK received&quot;?" Tags="|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21851" PostTypeId="2" ParentId="21850" CreationDate="2016-03-15T21:03:41.343" Score="10" Body="&lt;p&gt;A &lt;code&gt;NACK&lt;/code&gt; is signaled by an acknowledgement slot in which &lt;code&gt;SDA&lt;/code&gt; remains high while &lt;code&gt;SCL&lt;/code&gt; cycles under control of the master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since high is the un-driven state of the pulled-up bus, in the absence of a peripheral at the selected address to positively acknowledge by pulling it down, a &lt;code&gt;NACK&lt;/code&gt; condition will &lt;em&gt;passively&lt;/em&gt; result.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-03-15T21:03:41.343" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21852" PostTypeId="1" AcceptedAnswerId="21863" CreationDate="2016-03-15T21:06:24.063" Score="0" ViewCount="148" Body="&lt;p&gt;Non-technical person here, so please be gentle. I moved into a place that has ceiling speakers in each room (I tried, but they don't come apart, aren't marked other than manufacturer, and that is a company that went out of business 15+ years ago). So, let's assume they are 8 ohm speakers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a media amplifier, and have successfully played music over all the speakers so I know that they work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My wife would like the ability to select which speakers are on or off, so I'm thinking a quick Arduino project and relay board with 8-12 relays... but I'm not sure how to estimate the load, so I don't know how to appropriately size the relays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on the best way to do this, or should I just get mains-rated relays and over-engineer the heck out of this?&lt;/p&gt;&#xA;" OwnerUserId="19298" LastEditorUserId="6936" LastEditDate="2016-03-16T00:30:40.227" LastActivityDate="2016-03-16T05:49:29.227" Title="Sizing relays for audio circuit?" Tags="|current|audio|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21853" PostTypeId="1" AcceptedAnswerId="21854" CreationDate="2016-03-15T21:34:21.307" Score="2" ViewCount="114" Body="&lt;p&gt;Simple question really, I just want to be sure that I understand it correctly. I understand this isn't necessarily Arduino specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With regards to the ATmega2560 I'm doing 3 back-to-back A/D conversions - one immediately after the previous finishes. I'm accomplishing this by calling a Single Conversion each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I stumbled across this useful code to wait for the conversion to finish:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(ADCSRA &amp;amp; (1&amp;lt;&amp;lt;ADSC))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I understand that it is waiting for the conversion to finish and that when this is done the ADSC will be set to 0. (Conversely, I could wait for ADIF to be set to 1.) I'm not as clear on how exactly this line is interpreted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally when I see something along the lines of &lt;code&gt;(1&amp;lt;&amp;lt;ADSC)&lt;/code&gt; it means write a 1 to the ADSC bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, in this instance, that isn't the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why not just write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(ADSC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7317" LastEditorUserId="4143" LastEditDate="2016-03-15T21:37:26.323" LastActivityDate="2016-03-15T21:42:21.893" Title="Comparison of a bit vs. setting a bit" Tags="|adc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21854" PostTypeId="2" ParentId="21853" CreationDate="2016-03-15T21:42:21.893" Score="4" Body="&lt;p&gt;You misunderstand the meaning of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1 &amp;lt;&amp;lt; ADSC&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That actually means &lt;em&gt;Bit-shift 1 left by the number of bits specified by the value ADSC&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ADSC&lt;/code&gt; in this case is 6:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADSC    6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you did:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(ADSC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you would actually be doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which of course will never end, since 6 is not 0, so is true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you shift 1 left 6 times, which in binary would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000001&#xA;    &amp;lt;&amp;lt; 6&#xA;01000000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That, of course, is 64, or 0x40 in hexadecimal.  That is then ANDed with the value of the ADCSRA register to return the value of one single bit within that register.  It's then the result of that AND that you control the &lt;code&gt;while&lt;/code&gt; with.  So it ends up as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(ADCSRA &amp;amp; 0x40);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which will either equate to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(0x40);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if the 7&lt;sup&gt;th&lt;/sup&gt; bit is set, or if it's not set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(0x00);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And since 0x00 is 0 it will equate to false when the bit isn't set and the &lt;code&gt;while&lt;/code&gt; will finish.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-15T21:42:21.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21857" PostTypeId="1" CreationDate="2016-03-16T03:49:34.790" Score="3" ViewCount="860" Body="&lt;p&gt;Why do I end up with the display&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Failed to read from DHT sensor!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;in the serial monitor in most cases when I run the code given below? When I reduce the delay to 1000ms the reading shows 0.00 for both temperature and humidity which, as well, is pretty much false. Any help would be highly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Example testing sketch for various DHT humidity/temperature sensors&#xA;// Written by ladyada, public domain&#xA;&#xA;#include &quot;DHT.h&quot;&#xA;&#xA;#define DHTPIN 2     // what pin we're connected to&#xA;&#xA;// Uncomment whatever type you're using!&#xA;//#define DHTTYPE DHT11   // DHT 11 &#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;//#define DHTTYPE DHT21   // DHT 21 (AM2301)&#xA;&#xA;&#xA;&#xA;// Initialize DHT sensor for normal 16mhz Arduino&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you&#xA;// might need to increase the threshold for cycle counts considered a 1 or 0.&#xA;// You can do this by passing a 3rd parameter for this threshold.  It's a bit&#xA;// of fiddling to find the right value, but in general the faster the CPU the&#xA;// higher the value.  The default for a 16mhz AVR is a value of 6.  For an&#xA;// Arduino Due that runs at 84mhz a value of 30 works.&#xA;// Example to initialize DHT sensor for Arduino Due:&#xA;//DHT dht(DHTPIN, DHTTYPE, 30);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600); &#xA;  Serial.println(&quot;DHTxx test!&quot;);&#xA;&#xA;  dht.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  // Wait a few seconds between measurements.&#xA;  delay(2000);&#xA;&#xA;  // Reading temperature or humidity takes about 250 milliseconds!&#xA;  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)&#xA;  float h = dht.readHumidity();&#xA;  // Read temperature as Celsius&#xA;  float t = dht.readTemperature();&#xA;  // Read temperature as Fahrenheit&#xA;  float f = dht.readTemperature(true);&#xA;&#xA;  // Check if any reads failed and exit early (to try again).&#xA;  if (isnan(h) || isnan(t) || isnan(f)) {&#xA;    Serial.println(&quot;Failed to read from DHT sensor!&quot;);&#xA;    return;&#xA;  }&#xA;&#xA;  // Compute heat index&#xA;  // Must send in temp in Fahrenheit!&#xA;  float hi = dht.computeHeatIndex(f, h);&#xA;&#xA;  Serial.print(&quot;Humidity: &quot;); &#xA;  Serial.print(h);&#xA;  Serial.print(&quot; %\t&quot;);&#xA;  Serial.print(&quot;Temperature: &quot;); &#xA;  Serial.print(t);&#xA;  Serial.print(&quot; *C &quot;);&#xA;  Serial.print(f);&#xA;  Serial.print(&quot; *F\t&quot;);&#xA;  Serial.print(&quot;Heat index: &quot;);&#xA;  Serial.print(hi);&#xA;  Serial.println(&quot; *F&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19305" LastEditorUserId="19721" LastEditDate="2016-03-30T13:26:09.900" LastActivityDate="2019-03-11T10:51:40.617" Title="Failed to read DHT22 sensor using Intel Galileo Gen2 board" Tags="|sensors|arduino-galileo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21860" PostTypeId="1" AcceptedAnswerId="21867" CreationDate="2016-03-16T05:07:22.713" Score="1" ViewCount="2766" Body="&lt;p&gt;I am new to the Arduino world. I have a question regarding current that the Arduino outputs over its 5V port. Why is the current in the Arduino too weak for current hungry circuit when the only thing that changes in this equation &lt;code&gt;V=IR&lt;/code&gt; is the current itself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the voltage in an Arduino is restricted to 5 volts. Assuming that the resistance of the current stays the same, shouldn't the current also increase (following Ohm's law) over its 5V port? More specifically, I am talking about powering ESP8266 with an Arduino.&lt;/p&gt;&#xA;" OwnerUserId="19306" LastEditorUserId="6936" LastEditDate="2016-03-31T13:38:32.963" LastActivityDate="2016-03-31T13:38:32.963" Title="How can there be not enough current?" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21861" PostTypeId="2" ParentId="19124" CreationDate="2016-03-16T05:43:48.167" Score="0" Body="&lt;p&gt;For my transition between colors I used arrays during the setup to collect the main transitions (bigger jumps between RGB values) then during the loop I used a series of &lt;code&gt;analogWrite()&lt;/code&gt; commands essentially splitting the jumps by a 16th, for example starting at &lt;code&gt;255, 0, 0&lt;/code&gt; the next array value was &lt;code&gt;223, 0, 0&lt;/code&gt; in the loop it went from &lt;code&gt;255, 0, 0&lt;/code&gt; to &lt;code&gt;253, 0, 0&lt;/code&gt; to &lt;code&gt;251, 0, 0&lt;/code&gt; finally landing the last loop value of &lt;code&gt;225, 0, 0&lt;/code&gt; before starting the loop over at the next array value of &lt;code&gt;223, 0, 0&lt;/code&gt;. It's important to realize what colors transition into others and what the corresponding RGB values are of that transition. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tomorrow I'll post my code, it's a bit messy as it was more proof of concept that starting with a distinct plan.&lt;/p&gt;&#xA;" OwnerUserId="19308" LastEditorUserId="6936" LastEditDate="2016-03-26T03:06:42.677" LastActivityDate="2016-03-26T03:06:42.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21863" PostTypeId="2" ParentId="21852" CreationDate="2016-03-16T05:49:29.227" Score="0" Body="&lt;p&gt;If you can estimate speaker power, it probably is reasonable to use the ordinary power formula P = I²R for estimating the current the relay needs to handle.  Typically, high-power speakers of a given kind are bigger than low-power speakers of the same kind.  But as you can see from pictures of &#xA;&lt;a href=&quot;https://www.google.com/search?site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;q=5w+speaker&quot; rel=&quot;nofollow&quot;&gt;5W&lt;/a&gt;,&#xA;&lt;a href=&quot;https://www.google.com/search?site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;q=10w+speaker&quot; rel=&quot;nofollow&quot;&gt;10W&lt;/a&gt;, and&#xA;&lt;a href=&quot;https://www.google.com/search?site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;q=40w+speaker&quot; rel=&quot;nofollow&quot;&gt;40W&lt;/a&gt; speakers, some 10W speakers are smaller than some 5W speakers, and some are bigger than 40W speakers, so power estimation based on speaker size can be difficult.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have access to the sound source (tuner or player or whatever, connected to an amplifier) you may find output power listed on the amplifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, due to the I² term in the power formula, the range of current to plan for is relatively small.  For example, if 5W is going to an 8Ω speaker, 5/8 = I², and I =  0.79 A.  If it's 40W, then I = 2.24 A.  This range is likely to be handled ok by relays sold for ordinary use with Arduino systems.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note 1:&lt;/em&gt; A relay's current rating ordinarily is derated significantly when the relay is used to switch DC or high-voltage AC.  Audio is low-voltage AC and relay derating probably isn't needed.  &lt;em&gt;Note 2:&lt;/em&gt; The current a relay can safely switch in a live circuit may be much less than the unswitched current that closed contacts can carry.  This might not be a problem with low-voltage audio.  &lt;em&gt;Note 3:&lt;/em&gt; Some commercial high-wattage audio distribution systems operate at higher voltages (see, eg, wikipedia's &lt;a href=&quot;https://en.wikipedia.org/wiki/Constant-voltage_speaker_system&quot; rel=&quot;nofollow&quot;&gt;high-voltage audio distribution systems&lt;/a&gt; article, re 70.7 V etc systems); if you have one of those – as amplifier labeling might reveal – the example calculations shown above would need adapting.  &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-16T05:49:29.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21865" PostTypeId="1" AcceptedAnswerId="21869" CreationDate="2016-03-16T08:56:04.877" Score="0" ViewCount="183" Body="&lt;p&gt;I am using digital pins (2,3,4,5) to play midi notes on and off with 3pdt switches with pull down 10k resistor between input pin and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I press button 2 randomly at different time interval it sometimes shows pin 3 high in the monitor. (after reading forums here I have realised that it might be due to big switches that I am using where the physical contact plates might be reason for this). I have even changed wires and isolated them from each other to rule out the noise from the wires.&#xA;I have checked all the connections and soldered the Arduino board pins with best possible skills that I have and tracks are all clear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same case occurs between other buttons as but its not always.&#xA;However after reading about Debounce I have made changes to the code as following, now I got the error only once after that I havent seen it. Can someone have look at the code and advice me if I have assigned Debounce function to multiple switches correctly and if not, what should it be as I am new with coding&#xA;Since I am using 3pdt switch I have added switch mode..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MIDI.h&amp;gt;&#xA;&#xA;int buttonPin[] = {2, 3, 4, 5};&#xA;byte mode[] = {0, 0 , 0 ,0};&#xA;boolean currentState = LOW;&#xA;boolean lastState = LOW;&#xA;int buttonPinM[] = {6, 7, 8, 9};&#xA;byte mode1[] = {0, 0, 0, 0};&#xA;&#xA;boolean currentState1 = LOW;&#xA;boolean lastState1 = LOW;&#xA;&#xA;long lastDebounceTime = 0;&#xA;long debounceDelay = 50;&#xA;&#xA;void setup (){&#xA;    MIDI.begin(MIDI_CHANNEL_OMNI);&#xA;&#xA;    int i;&#xA;    for (i = 0; i &amp;lt; 4; i++) {&#xA;        pinMode(buttonPin[i], INPUT);&#xA;    }&#xA;    int j;&#xA;    for (j = 0; j &amp;lt; 4; j++) {&#xA;        pinMode(buttonPinM[j], INPUT);&#xA;    }&#xA;&#xA;    {&#xA;        int i;&#xA;        for (i = 0; i &amp;lt; 4; i++);&#xA;    }&#xA;    {&#xA;        int j;&#xA;        for (j = 0; j &amp;lt; 4; j++);&#xA;    }&#xA;}&#xA;&#xA;// This will track which pin/mode we're using&#xA;&#xA;int j = 0;&#xA;int i = 0;&#xA;&#xA;void loop () {&#xA;    {  &#xA;        currentState = digitalRead(buttonPin[i]);&#xA;&#xA;        if ( (millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;            switch (mode[i]) {&#xA;                case 0:&#xA;                    if (currentState == HIGH) {&#xA;                        MIDI.sendNoteOff (i+55, 0, 1);&#xA;                        mode[i] = 1;&#xA;                        lastDebounceTime = millis();&#xA;                    }&#xA;                    break;&#xA;                case 1:&#xA;                    if (currentState == HIGH)&#xA;                        mode[i] = 2;&#xA;                    break;&#xA;                case 2:&#xA;                    if (currentState == LOW) {&#xA;                        MIDI.sendNoteOn (i+55, 127, 1);&#xA;                        mode[i] = 3;&#xA;                        lastDebounceTime = millis();&#xA;                    }&#xA;                    break;&#xA;                case 3:&#xA;                    if (currentState == LOW)&#xA;                        mode[i] = 0;&#xA;                    break;&#xA;            }&#xA;        }&#xA;        lastState = currentState;&#xA;        if (++i &amp;gt; 3)&#xA;            i = 0;  &#xA;    }&#xA;    {&#xA;        currentState1 = digitalRead(buttonPinM[j]);&#xA;        if ( (millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;            switch (mode1[j]) {&#xA;                case 0:&#xA;                    if (currentState1 == HIGH ) {&#xA;                        MIDI.sendNoteOn (j+61, 127, 1);&#xA;                        mode1[j] = 1;&#xA;                        lastDebounceTime = millis();&#xA;                    }&#xA;                    break;&#xA;                case 1:&#xA;                    if (currentState1 == HIGH)&#xA;                        mode1[j] = 2;&#xA;                    break;&#xA;                case 2:&#xA;                    if (currentState1 == LOW) {&#xA;                        MIDI.sendNoteOff (j+61, 0, 1);&#xA;                        mode1[j] = 3;&#xA;                        lastDebounceTime = millis();&#xA;                    }&#xA;                    break;&#xA;                case 3:&#xA;                    if (currentState1 == LOW)&#xA;                        mode1[j] = 0;&#xA;                break;&#xA;            }&#xA;        }&#xA;        lastState1 = currentState1;&#xA;        if (++j &amp;gt; 3)&#xA;            j = 0;   &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10547" LastEditorUserId="10214" LastEditDate="2016-03-16T10:59:56.173" LastActivityDate="2016-03-17T18:27:52.573" Title="Arduino digital input fluctuates with neighbouring pins" Tags="|arduino-uno|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21867" PostTypeId="2" ParentId="21860" CreationDate="2016-03-16T09:29:18.623" Score="4" Body="&lt;p&gt;The problem is not that &quot;there is not enough current&quot;, but that you can't dissipate enough power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's assume you are powering the board from an external 12V supply. Now, the 5V are obtained from 12V with a resistive regulator: this means that the regulator (see &lt;a href=&quot;http://3.bp.blogspot.com/-msRgadfnk34/UvaZ1EEyTXI/AAAAAAAAAuM/DvSoiyw2Mu8/s1600/Arduino+uno+w-circled+voltage+regulator.PNG&quot;&gt;this image&lt;/a&gt; if you are interested in knowing what component it is) simply behaves like a variable resistor, dissipating the power in excess. Now, let's assume you want to draw 4A from the 5V rail, since you want to turn on a lot of LEDs and other stuff. Since P=VI, the regulator (that very little component) has to dissipate (12V-5V)*4A = almost 30W. This means that it becomes a little heater and.. Puff! it breaks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, 4A is a really high current, but that regulator can withstand very little power dissipations. According to the datasheet, and estimating a 1cm x 2cm heatsing under it, we can estimate a 25 K/W thermal resistance, which means that each watt you dissipate raises the internal temperature by 25K (=25°C). You can't go beyond 150°C without damaging the component, which means that if your room is at 25°C you can dissipate AT MOST 5W. In practice, never go beyond 3W. Anyway even 5W mean that, at 12V, you can't get more than 5W/7V=0.7A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way, the regulator is rated 0.8A, so you should never go beyond that value in any case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, this was the external regulator. As for the usb, you can't get more than 500mA from that power supply. That's written in the specs. For this reason, a 500mA fuse is on that rail, so going beyond 500mA will blow that one, interrupting your power. Well, that's a self-healing fuse, so after some time (maybe hours?) it will operate again, but.. Don't try that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, the digital pin current. The atmega datasheet says that&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The absolute maximum current per I/O Pin is 40.0mA&lt;/li&gt;&#xA;&lt;li&gt;The absolute maximum current inside VCC and GND Pins is 200.0mA&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This means that from each single pin you can get at most 40mA (but I suggest you never go beyond 20mA), and the sum of all the currents (and the internal peripherals) should never exceed 200mA. So if you need to power 2 leds, you can give each of them 20mA, if you need to power 15 of them you can't (you are limited to, let's say, 10mA). If you need more, use transistors to separate the current paths.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-16T09:29:18.623" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21869" PostTypeId="2" ParentId="21865" CreationDate="2016-03-16T11:00:42.793" Score="0" Body="&lt;p&gt;Posting here since it is quite long, but it's not a complete answer, just a few thoughts and a possible improvement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, so there are a couple of things in your code I don't understand:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1: in the setup()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    int i;&#xA;    for (i = 0; i &amp;lt; 4; i++);&#xA;}&#xA;{&#xA;    int j;&#xA;    for (j = 0; j &amp;lt; 4; j++);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What are these for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2: debouncing&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are not implementing it correctly, at least not for me. You are reading the button every 50ms, without debouncing. Ok, you won't see &quot;bounces&quot;, but there are better solutions (see later).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3: modes 1 and 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are quite useless. What are they for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4: pins 6,7,8,9&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are they for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;5: variable laststate&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is it for? You never use it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;6: updating one button per loop&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it needed? I mean, you are just updating one button per loop instead of all of them for each loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In the end&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, now my suggestions, apart from learning to indent the code (otherwise it's impossible to read it): I always use the bounce2 class to debounce a button, since it contains everything inside and.. Well, it works well. It can also detect the rising and falling edges of the button, thing that you need if I interpreted correctly your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more thing: debounce delay can be lowered (even to just 5ms):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MIDI.h&amp;gt;&#xA;#include &amp;lt;Bounce2.h&amp;gt;&#xA;&#xA;int buttonPin[] = {2, 3, 4, 5};&#xA;int buttonPinM[] = {6, 7, 8, 9};&#xA;&#xA;Bounce debouncers[4];&#xA;Bounce debouncersM[4];&#xA;&#xA;int debounceDelay = 50; // Usually is lower - even 5ms is fine&#xA;uint8_t i = 0;&#xA;&#xA;void setup ()&#xA;{&#xA;    MIDI.begin(MIDI_CHANNEL_OMNI);&#xA;&#xA;    for (i = 0; i &amp;lt; 4; i++)&#xA;    {&#xA;        pinMode(buttonPin[i], INPUT);&#xA;        debouncers[i].attach(buttonPin[i]);&#xA;        debouncers[i].interval(debounceDelay);&#xA;&#xA;        pinMode(buttonPinM[i], INPUT);&#xA;        debouncersM[i].attach(buttonPinM[i]);&#xA;        debouncersM[i].interval(debounceDelay);&#xA;    }&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;    for (i = 0; i &amp;lt; 4; i++)&#xA;    {&#xA;        debouncers[i].update();&#xA;        debouncersM[i].update();&#xA;    }&#xA;&#xA;    for (i = 0; i &amp;lt; 4; i++)&#xA;    {&#xA;        if (debouncers[i].rose()) // button i switched from 0 to 1&#xA;            MIDI.sendNoteOff(i+55, 0, 1);&#xA;        if (debouncers[i].fell()) // button i switched from 1 to 0&#xA;            MIDI.sendNoteOn (i+55, 127, 1);&#xA;        if (debouncersM[i].rose()) // button i switched from 0 to 1&#xA;            MIDI.sendNoteOn (i+61, 127, 1);&#xA;        if (debouncersM[i].fell()) // button i switched from 1 to 0&#xA;            MIDI.sendNoteOff(i+61, 0, 1);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2016-03-17T18:27:52.573" LastActivityDate="2016-03-17T18:27:52.573" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21870" PostTypeId="1" AcceptedAnswerId="21872" CreationDate="2016-03-16T11:16:27.640" Score="0" ViewCount="178" Body="&lt;p&gt;My main objective with this project was to control these two DC motors with an Arduino Nano (it is not a UNO), powered by a 3-Cell 750mAh LiPO battery (both the motors as the Arduino itself). So, I came up with something like this (it is a simplified version):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IfEtJm.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IfEtJm.png&quot; alt=&quot;Simplified version of circuit.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the load on the two mottors rise, could the Arduino be damaged by this current increase? Is the voltage too high for the Arduino handle? Is there any more issues that this setup can have?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When searching, I found that it would be wise to get a fuse between the power supply and the arduino (before reaching Vin). Is that necessary?&lt;/p&gt;&#xA;" OwnerUserId="19315" LastActivityDate="2016-03-16T11:56:14.993" Title="Issues on Arduino, LiPO battery and two mottors setup" Tags="|motor|battery|current|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21871" PostTypeId="2" ParentId="21860" CreationDate="2016-03-16T11:29:15.683" Score="1" Body="&lt;p&gt;A very simple answer:  The Arduino is limited to an absolute 40mA per pin, because within the controller chip (ATMega328 usually) the path the current follows is very small.  More current can destroy the tiny transistors in the chip.  Best case, you burn out that pin.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a problem that requires more than 40mA (and really, as other posters point out, 20mA!) you should be using a transistor, mosfet or relay controlled by the Arduino, rather than directly power the end device.&lt;/p&gt;&#xA;" OwnerUserId="3058" LastActivityDate="2016-03-16T11:29:15.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21872" PostTypeId="2" ParentId="21870" CreationDate="2016-03-16T11:56:14.993" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If the load on the two motors rise, could the Arduino be damaged by this current increase?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, the motor current doesn't pass through the Arduino. It is completely separate.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the voltage too high for the Arduino handle?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Borderline. The regulator (a lowly 7805) may well get very hot at that voltage (depending on the Arduino's current draw) and go into thermal shutdown.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any more issues that this setup can have?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Maybe add a small buck regulator to the 5V pin instead of using the on-board linear regulator. That will not overheat and will be far more efficient making your batteries last longer. Often marketed as &quot;UBEC&quot; (Universal Battery Elimination Circuit) and used throughout the model vehicle industry these are very easy to get hold of and are ideal for powering things like Arduinos from batteries like this.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-16T11:56:14.993" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21873" PostTypeId="1" CreationDate="2016-03-16T12:47:13.153" Score="0" ViewCount="1102" Body="&lt;p&gt;I am trying to design a project that Arduino would have connected water and salinity sensor, would be packed in a special box be droped into ocean up to 500 meters. What sensors should I use and how should they be conencted. I assume that I would need professional equipment, not chineese stuff from ebay.&#xA;Hardware needs to be able to work under 50*C and up to 50bar&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Budget is about up to 400 pounds for sensors.&#xA;Resolution of pressure 0 to 100 bar&#xA;Resolution of salinity doesnt matter so much. Few percents of mistake, just to measure it somehow&lt;/p&gt;&#xA;" OwnerUserId="19320" LastEditorUserId="19320" LastEditDate="2016-03-16T15:12:37.453" LastActivityDate="2019-04-18T23:01:20.220" Title="Water pressure an salinity sensor connected to arduino" Tags="|sensors|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21875" PostTypeId="2" ParentId="21848" CreationDate="2016-03-16T13:29:51.533" Score="0" Body="&lt;p&gt;Did you change the firmware? I think Baud rate can be changed only if you flash it with newer version of the firmware. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-03-16T13:29:51.533" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21876" PostTypeId="2" ParentId="18172" CreationDate="2016-03-16T14:29:10.110" Score="1" Body="&lt;p&gt;You mentioned arduino uno clone, do you know what USB chip it's using and what chip you are uploading the sketches to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The clone I have is very fussy and hangs up continuously. I have had luck once or twice with uploading the sketches. Depending on the chips on the board downloading the proper driver will help and selecting the proper chip under the board setting i.e. Atmega328 or atmega8 depending on the chip. Hope this helps as it worked for me.&lt;/p&gt;&#xA;" OwnerUserId="19308" LastActivityDate="2016-03-16T14:29:10.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21877" PostTypeId="1" CreationDate="2016-03-16T14:34:12.370" Score="2" ViewCount="1119" Body="&lt;p&gt;I have an HC-06 Bluetooth module connected to an Arduino Uno board to allow for the data received by the Ultrasonic sensor to be transferred to my PC via Bluetooth and serial communication.&lt;/p&gt;&#xA;&lt;p&gt;I am using the PuTTY program to view the data. The thing is, my PC says that it has paired with the Bluetooth and I was able to see the COM number, but when I opened PuTTY and entered the COM number while choosing the option 'serial' an error box appeared saying: &amp;quot;Unable to open serial port.&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;The way I am currently connecting my b&#xA;Bluetooth to the arduino board is:&lt;/p&gt;&#xA;&lt;p&gt;RX-&amp;gt;pin 10&lt;br /&gt;&#xA;TX-&amp;gt;pin 11&lt;br /&gt;&#xA;GND-&amp;gt;GND pin&lt;br /&gt;&#xA;VCC-&amp;gt; 5V VCC&lt;/p&gt;&#xA;&lt;p&gt;I am sure that the sketch in the Arduino for serial communication via Bluetooth is right as I have tested the system yesterday and it worked.&lt;/p&gt;&#xA;&lt;p&gt;Only after a time (say like 5-10 min) the connection breaks and I can't seem to figure out the problem. The Arduino is being powered by USB, if that matters.&lt;/p&gt;&#xA;" OwnerUserId="8670" LastEditorUserId="61722" LastEditDate="2022-08-06T08:57:07.703" LastActivityDate="2023-01-03T12:01:30.257" Title="PC cannot access HC-06 Bluetooth COM port" Tags="|arduino-uno|serial|programming|bluetooth|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21879" PostTypeId="2" ParentId="21813" CreationDate="2016-03-16T14:47:21.217" Score="1" Body="&lt;p&gt;I assume what you actually want is to measure sound intensity. This is&#xA;significantly more involved than just averaging the samples you read. I&#xA;have written a few weeks ago a program that does exactly that: it&#xA;measures the sound intensity and sends those measurements through the&#xA;serial port. It is a pretty short program (43 lines of code) you may be&#xA;able to adapt to your needs, so I am now sharing it as a GitHub gist:&#xA;&lt;a href=&quot;https://gist.github.com/edgar-bonet/e693799f58a545ca89a2&quot; rel=&quot;nofollow&quot;&gt;sound-meter.ino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order for this not to be a link-only answer, I'll try to explain the&#xA;program's inner working, and go through the theory of measuring sound&#xA;intensity on an Arduino. But first let me put here a disclaimer: a&#xA;“real” sound level meter should have a frequency response that complies&#xA;with some standards, and it should be calibrated to absolute levels.&#xA;This program only provides uncalibrated readings with whatever frequency&#xA;response its analog hardware has.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Signal conditioning&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Four measuring sound on an Arduino, you obviously need a microphone,&#xA;but you also need some kind of interface circuit between the microphone&#xA;and the Arduino. The purpose of the interface is to “condition the&#xA;signal”, i.e. to make sure the Arduino gets a voltage in the proper&#xA;range for it's analog-to-digital converter (ADC). It's typically an&#xA;op-amp based circuit that provides some amplification and also adds a DC&#xA;bias to avoid clipping the negative side of each oscillation. Ideally,&#xA;the DC bias should be around Vcc/2, i.e. 2.5&amp;nbsp;V on an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See this &lt;a href=&quot;https://www.sparkfun.com/products/9964&quot; rel=&quot;nofollow&quot;&gt;SparkFun microphone&#xA;breakout&lt;/a&gt; for an example on how&#xA;such a circuit may be built (click on “Schematic”).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;ADC sampling&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once you have a properly conditioned analog signal, you have to sample&#xA;it fast enough to catch all its spectral content. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem&quot; rel=&quot;nofollow&quot;&gt;Nyquist–Shannon&#xA;sampling&#xA;theorem&lt;/a&gt;&#xA;tells us the sampling rate should be at least twice the highest&#xA;frequency in the signal. For audio signals, sampling rates of the order&#xA;of 8&amp;nbsp;kS/s (kilosamples per second) are typical of low quality,&#xA;telephone-like applications, whereas high quality audio would run at&#xA;44.1 to 48&amp;nbsp;kS/s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ADC of the Arduino Uno, in its default configuration, takes&#xA;104&amp;nbsp;µs to convert one sample. If you just call &lt;code&gt;analogRead()&lt;/code&gt; in a&#xA;tight loop, this gives a sampling rate of about 9.6&amp;nbsp;kS/s, which is&#xA;fine for this kind of application, unless we have to measure noise above&#xA;4.8&amp;nbsp;kHz. The problem with this approach is that &lt;code&gt;analogRead()&lt;/code&gt; is a&#xA;&lt;em&gt;blocking&lt;/em&gt; function. Calling it in a tight loop means the program will&#xA;spend most of its time just waiting for the ADC. If you do anything else&#xA;in the loop, not only will the sampling rate be lowered, it will also&#xA;become unsteady, which is generally not desirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to avoid blocking the CPU, we have to forgo &lt;code&gt;analogRead()&lt;/code&gt;, and&#xA;instead get our hands dirty with low-level configuration of the ADC. The&#xA;ADC of the Arduino Uno offers a so-called “free running mode”, which is&#xA;well suited for this kind of application. In this mode, the ADC starts a&#xA;new conversion as soon as the previous one is done, ensuring a very&#xA;consistent sampling rate of 9.6&amp;nbsp;kS/s. It can also trigger an&#xA;interrupt after each conversion, in order for the interrupt service&#xA;routine to retrieve and process the sample. See the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet of the&#xA;ATmega328P&lt;/a&gt;&#xA;for details on configuring the ADC.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Removal of the DC bias&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once we have the digitized samples, the first thing to do is to remove&#xA;the DC bias that was added by the interface circuit. If the bias is&#xA;stable and known (maybe determined by experiment), this only involves&#xA;subtracting a constant. If it is not known, it can be estimated by&#xA;running the samples through a digital low-pass filter with a cutoff&#xA;frequency below the range of interest. Subtracting the output of a&#xA;low-pass filter is essentially building a high-pass filter. As an&#xA;alternative, a numerical derivative (difference between consecutive&#xA;samples) can be used as a crude high-pass filter. This, however, will&#xA;bias the sensitivity of the detection towards the high end of the&#xA;spectrum. Depending on the noise you want to detect, and on the&#xA;background noise, this could be acceptable for your application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the program I am sharing, I assume the DC bias is known: it's the&#xA;&lt;code&gt;dc_offset&lt;/code&gt; constant at the beginning of the program.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Instantaneous intensity&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;With the DC bias removed, the signal we have is a digital image of the&#xA;sound picked by the microphone. It could be tempting to just average it&#xA;as is. This, however, would just give zero, as the positive fluctuations&#xA;of the signal would cancel the negative ones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The are several options to solve this problem. We could do a peak&#xA;detection instead of an average, or we could take the absolute value&#xA;before averaging. The most popular option is probably to compute the&#xA;squares of the samples. Since the square of a real number is always&#xA;positive, this avoids the averaging-out problem. But the square has also&#xA;a deeper physical meaning: it is proportional to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Sound_intensity&quot; rel=&quot;nofollow&quot;&gt;sound&#xA;intensity&lt;/a&gt;, i.e. the&#xA;energy carried by the sound wave.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Low-pass filter&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The intensity computed above is a very fast varying quantity. If the&#xA;signal is a simple tone of constant frequency and volume, the&#xA;instantaneous intensity fluctuates between zero and some maximum at&#xA;twice the tone frequency. In order to recover the “constant volume”&#xA;property of the sound, we need to perform some sort of averaging or, in&#xA;other words, we need a low-pass filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many ways to implement a digital low-pass filter. The most&#xA;intuitive may be to group the samples into batches, and then compute the&#xA;average of each batch. However, this is neither the best nor the most&#xA;efficient to implement. When I need a quick and simple low pass filter,&#xA;I generally use an &lt;a href=&quot;https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average&quot; rel=&quot;nofollow&quot;&gt;exponential moving&#xA;average&lt;/a&gt;.&#xA;This is the discrete-time equivalent of an analog RC filter, and it can&#xA;be implemented very efficiently by remembering the previous output and&#xA;updating it as&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;output += input - output / N;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where, for efficiency reasons, N should be a power of two. The filter's&#xA;time constant is N/f&lt;sub&gt;s&lt;/sub&gt;, where f&lt;sub&gt;s&lt;/sub&gt; is the sampling&#xA;frequency. In the program I use N&amp;nbsp;=&amp;nbsp;256, which makes the&#xA;division virtually free. This gives a time constant of 26.6&amp;nbsp;ms. You&#xA;can tune the time constant to your needs simply by changing N, but make&#xA;sure it is still a power of two.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Decimation&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you only want to trigger an event when the sound intensity exceeds a&#xA;defined level, you may not need this. But if you have other processing&#xA;to do with those measurements, it is probably not useful to process more&#xA;than one intensity reading per time constant of the previous filter.&#xA;That's why the program has a decimation step. This is simply the ISR&#xA;periodically signaling the main program that an intensity reading is&#xA;available. Notice that, since the sample count is an 8-bit variable, it&#xA;automatically counts modulo 256. If you want to increase the decimation&#xA;factor, you should make &lt;code&gt;sample_count&lt;/code&gt; wider and mask out the bits you&#xA;do not need.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-16T14:47:21.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21880" PostTypeId="1" CreationDate="2016-03-16T16:21:56.000" Score="0" ViewCount="264" Body="&lt;p&gt;I've this &lt;a href=&quot;http://m.aliexpress.com/item/32584436489.html&quot; rel=&quot;nofollow&quot;&gt;PWM Module - 6V-90V 15A Pulse Width PWM DC Motor Speed Controller Switch&lt;/a&gt; which I use to control a peristaltic pump (ordinary DC motor), now I want to replace the potentiometer with an Arduino in order to create a soft-start for the pump by pressing a button. &#xA;The control is a 0-5V input from the potentiometer, and the description says &quot;&lt;em&gt;you can external drive&lt;/em&gt;&quot; and &quot;&lt;em&gt;It could use of PLC controls speed of motor&lt;/em&gt;&quot;, unfortunately I cannot provide datasheets or schematics.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible? Or I need a digital pot?    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I wire it? The 3 cables from the board to the pot are: &lt;strong&gt;ground, 0-5V and 5V&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="19325" LastEditorUserId="6936" LastEditDate="2016-03-17T02:56:54.110" LastActivityDate="2016-03-17T06:39:50.687" Title="Arduino and DC Motor control board" Tags="|arduino-uno|motor|pwm|potentiometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21881" PostTypeId="1" AcceptedAnswerId="21882" CreationDate="2016-03-16T17:02:11.387" Score="0" ViewCount="190" Body="&lt;p&gt;I am using sdFat library the analog bin logger example, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/greiman/SdFat/tree/master/SdFat/examples/AnalogBinLogger&quot; rel=&quot;nofollow&quot;&gt;Github: SdFat/SdFat/examples/AnalogBinLogger/&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is working fine and every thing but the thing is, this high speed datalogger uses interrupts and timers to make the ADC work at a pre-determined sampling frequency and it DOES NOT use the normal &lt;code&gt;analogRead ()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want is, when the input of some analog pin is bellow a pre-determined value, I want to write HIGH or LOW to some digital pin, &#xA;my question is, how can I compare the new sample in the analog bin logger example as I simply want to compare the new sample as in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( analogRead() &amp;lt; 256 ) {// do something}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;knowing that there is no analogRead() in the program because it uses timers and interrupts.&lt;/p&gt;&#xA;" OwnerUserId="10270" LastEditorUserId="10794" LastEditDate="2016-03-16T21:56:11.077" LastActivityDate="2016-03-16T21:56:11.077" Title="Compare the new sample in a high sampling rate datalogger" Tags="|arduino-mega|interrupt|sd-card|timers|datalogging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21882" PostTypeId="2" ParentId="21881" CreationDate="2016-03-16T17:25:35.107" Score="2" Body="&lt;p&gt;In the function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(ADC_vect) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the variable &lt;code&gt;d&lt;/code&gt; contains the current sample:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  // Read ADC data.&#xA;#if RECORD_EIGHT_BITS&#xA;  uint8_t d = ADCH;&#xA;#else  // RECORD_EIGHT_BITS&#xA;  // This will access ADCL first.&#xA;  uint16_t d = ADC;&#xA;#endif  // RECORD_EIGHT_BITS&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can just &quot;do something&quot; depending on what is in &lt;code&gt;d&lt;/code&gt;.  Of course, since this is a timer interrupt you have limited time to do anything, so you need to make sure that whatever you do is fast and efficient - so really you want to be using direct port access instead of digitalWrite().&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-16T17:25:35.107" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21883" PostTypeId="2" ParentId="21880" CreationDate="2016-03-16T17:38:33.180" Score="0" Body="&lt;p&gt;Functionally you can replace the potmeter with a digital potmeter.&lt;br&gt;&#xA;If your arduino runs on 5 volt, you can simply connect the grounds and the wire connected to the middle of the pot to a pwm pin.&#xA;If the pwm pin does not work smoothly use a RC filter. That is a resis  tor and a capacitor.  As explained here &lt;a href=&quot;http://www.instructables.com/id/Analog-Output-Convert-PWM-to-Voltage/&quot; rel=&quot;nofollow&quot;&gt;instructables&lt;/a&gt;&lt;br&gt;&#xA;If your arduino runs on 3.3 you can still use the rc filter but you need to add a bridge.  &lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-16T17:38:33.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21884" PostTypeId="1" AcceptedAnswerId="21890" CreationDate="2016-03-16T18:01:38.843" Score="1" ViewCount="184" Body="&lt;p&gt;See: &lt;a href=&quot;https://github.com/adafruit/Adafruit_FRAM_SPI/blob/master/Adafruit_FRAM_SPI.cpp&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_FRAM_SPI/blob/master/Adafruit_FRAM_SPI.cpp&lt;/a&gt;&#xA;The following method reads and converts the input to 8 bit. I have several questions concerning its function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using addr = 0xFFFF as an example, the method converts the variable to 0xFF. I understand that bits are removed from the end, but surely 65535 != 255. Perhaps relatively, to their max size, but how is this a useful conversion? I might be missing something about bitwise here..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t Adafruit_FRAM_SPI::read8 (uint16_t addr)&#xA;{&#xA; digitalWrite(_cs, LOW);&#xA; SPItransfer(OPCODE_READ); //read memory from fram array (2-byte)&#xA; SPItransfer((uint8_t)(addr &amp;gt;&amp;gt; 8));&#xA; SPItransfer((uint8_t)(addr &amp;amp; 0xFF));&#xA; uint8_t x = SPItransfer(0);&#xA; digitalWrite(_cs, HIGH);&#xA; return x;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Correct me if I'm wrong, the casting is to keep sign extension from occurring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The masking I understand in theory, but do not at all understand its application here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, it always returns the same value x = 0, why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also see there's a write method but no read method. Only read8. Reasoning? &lt;/p&gt;&#xA;" OwnerUserId="19328" LastEditorUserId="19328" LastEditDate="2016-03-21T00:35:38.657" LastActivityDate="2016-03-21T00:35:38.657" Title="Why perform bitwise operations here? (SPI FRAM read method)" Tags="|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21885" PostTypeId="2" ParentId="8473" CreationDate="2016-03-16T18:31:58.430" Score="0" Body="&lt;p&gt;I tried this as well, for some reason it is NOT WORKING on pins 6 and 7, but it works perfectly using pins 10 and 11 instead. Of course, you still need to add the &lt;code&gt;mySerial.begin()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19330" LastEditorUserId="6936" LastEditDate="2016-03-19T01:02:02.297" LastActivityDate="2016-03-19T01:02:02.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21887" PostTypeId="2" ParentId="17485" CreationDate="2016-03-16T18:45:44.573" Score="1" Body="&lt;p&gt;I have edited your &lt;code&gt;serialEvent()&lt;/code&gt; method a little bit, so it could handle the data from the Arduino, when split by a tab.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent (Serial myPort) {&#xA;   String inString = myPort.readStringUntil('\n');&#xA;&#xA;   if (inString != null) {&#xA;     values=split(inString,&quot;\t&quot;);  //Splitting the output of the arduino into a String Array&#xA;     for(int i=0;i&amp;lt;values.length;i++){&#xA;       values[i]=trim(values[i]); //deleting the whitespaces as before&#xA;       float_values[i]=float(values[i]); //cast the string to a float as before&#xA;     }&#xA;       x = map(float_values[0], 0, 1023, 0, height); //map the value as before&#xA;       y = map(float_values[1], 0, 1023, 0, height);//map the value as before&#xA;       z = map(float_values[2], 0, 1023, 0, height);//map the value as before&#xA;       newVal = true;&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so your sending on the Arduino has to look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    x = ski.getXRaw();&#xA;    y = ski.getYRaw();&#xA;    z = ski.getZRaw();&#xA;    Serial.print(&quot;\n&quot;);&#xA;    Serial.print(x);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(y);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(z);&#xA;    delay(10);                                     //(make it readable)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You still have to make the drawing in the &lt;code&gt;draw()&lt;/code&gt; method of processing, but I think that this is not the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the 3d draw you should have a look on the &lt;a href=&quot;https://processing.org/reference/&quot; rel=&quot;nofollow&quot;&gt;Processing reference&lt;/a&gt; or at this special topic, &lt;a href=&quot;https://processing.org/tutorials/p3d/&quot; rel=&quot;nofollow&quot;&gt;P3D by Daniel Shiffman&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not tested the code, but I think that it should work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have questions, feel free to ask ;D&lt;/p&gt;&#xA;" OwnerUserId="19329" LastEditorUserId="6936" LastEditDate="2016-03-19T01:13:14.440" LastActivityDate="2016-03-19T01:13:14.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21889" PostTypeId="2" ParentId="17571" CreationDate="2016-03-16T20:33:02.460" Score="1" Body="&lt;p&gt;Following on from user1637451 the following sequence has always worked for me: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Before download, pull both GPIO0 and RST to ground.&lt;/li&gt;&#xA;&lt;li&gt;Release the pull down on RST, but keep GPIO0 low.&lt;/li&gt;&#xA;&lt;li&gt;When the IDE has finished downloading, release GPIO0 from low. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I usually have pull-up resistors (10K) on both RST and GPIO0. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the IDE problem. I used the tutorial from Sparkfun entitled &quot;ESP8266 Thing Hookup Guide&quot; and then the section &quot;Installing the ESP8266 Arduino Addon&quot;. Because I used a different ESP8266 board to them I set the IDE to use the &quot;generic ESP8266 board&quot;. This worked for me. &lt;/p&gt;&#xA;" OwnerUserId="19332" LastActivityDate="2016-03-16T20:33:02.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21890" PostTypeId="2" ParentId="21884" CreationDate="2016-03-16T20:43:04.680" Score="2" Body="&lt;p&gt;Let's assume &lt;code&gt;addr&lt;/code&gt; is &lt;code&gt;0xbeef&lt;/code&gt;. Then, if we break down each operation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;expression             │ value&#xA;───────────────────────┼───────&#xA;addr                   │ 0xbeef&#xA;addr &amp;gt;&amp;gt; 8              │ 0x00be&#xA;(uint8_t)(addr &amp;gt;&amp;gt; 8)   │   0xbe&#xA;addr &amp;amp; 0xFF            │ 0x00ef&#xA;(uint8_t)(addr &amp;amp; 0xFF) │   0xef&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So this is essentially breaking down the address into two 8-bit chunks,&#xA;and transmitting those chunks individually. It's done like this because&#xA;SPI only transmits bytes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the casting is to keep sign extension from occurring.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Non, sign extension cannot occur, since &lt;code&gt;addr&lt;/code&gt; is an unsigned number.&#xA;The casting really serves no useful purpose, other than documenting the&#xA;code. It would be done implicitly simply because &lt;code&gt;SPItransfer()&lt;/code&gt; takes&#xA;an &lt;code&gt;uint8_t&lt;/code&gt; argument. The casting &lt;em&gt;could&lt;/em&gt; be useful if &lt;code&gt;SPItransfer()&lt;/code&gt;&#xA;was overloaded with a 16-bit version.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Finally, it always returns the same value x = 0, why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it returns whatever the call to &lt;code&gt;SPItransfer(0);&lt;/code&gt; returns, i.e. the&#xA;data sent by the FRAM module.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-16T20:43:04.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21894" PostTypeId="2" ParentId="18958" CreationDate="2016-03-17T01:15:12.120" Score="1" Body="&lt;p&gt;I think something is wrong with this LCD board. This is because in my case the display works sometimes perfectly with the ILI9481 driver but sometimes something hangs and the display starts to flicker. It looks like a chip charging problem. Anyway I solved the flickering problem by tuning the ILI9488 registers. Simply you have to change the &lt;code&gt;initlcd.h&lt;/code&gt; for ILI9481 driver in UTFT library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enter code here&#xA;&#xA;case ILI9481:&#xA;&#xA;&#xA;LCD_Write_COM(0x11);&#xA;delay(70);&#xA;&#xA;LCD_Write_COM(0x38);//Idle Mode OFF&#xA;LCD_Write_COM(0x13);//Normal mode&#xA;&#xA;LCD_Write_COM(0x36); // Memory Access Control  crucial&#xA;LCD_Write_DATA(0x0A);&#xA;&#xA;&#xA;&#xA;LCD_Write_COM(0x55);&#xA;LCD_Write_DATA(0x22);//High enhancment of CE ratio&#xA;&#xA;&#xA;&#xA;LCD_Write_COM(0xB1);&#xA;LCD_Write_DATA(0x70);&#xA;LCD_Write_DATA(0x10);&#xA;&#xA;LCD_Write_COM(0xB4);&#xA;LCD_Write_DATA(0x10);&#xA;&#xA;LCD_Write_COM(0xB5);&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x12);&#xA;&#xA;LCD_Write_COM(0xB6);        // Display Function Control&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x21);       // 0x42 = Rotate display 180 deg.&#xA;LCD_Write_DATA(0x3B);&#xA;&#xA;&#xA;LCD_Write_COM(0xC0);&#xA;LCD_Write_DATA(0x1F);//0X1F&#xA;LCD_Write_DATA(0x01);//0X10&#xA;&#xA;LCD_Write_COM(0xC1);&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x10);&#xA;&#xA;LCD_Write_COM(0xC2);&#xA;LCD_Write_DATA(0x00);//0X44 lower better&#xA;LCD_Write_COM(0xC4);&#xA;LCD_Write_DATA(0x00);//0X10&#xA;&#xA;LCD_Write_COM(0xC5);&#xA;LCD_Write_DATA(0x00);//0X10&#xA;LCD_Write_DATA(0x80);//optimum&#xA;LCD_Write_DATA(0x80);//0X10&#xA;&#xA;&#xA;LCD_Write_COM(0x3A);//Interface Pixel Format&#xA;LCD_Write_DATA(0x55);&#xA;&#xA;LCD_Write_COM(0x2A);//Column Address Set&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x01);&#xA;LCD_Write_DATA(0xDF);//320&#xA;&#xA;LCD_Write_COM(0x2B);//Page Address Set&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x00);&#xA;LCD_Write_DATA(0x01);&#xA;LCD_Write_DATA(0x3F);//480&#xA;&#xA;&#xA;delay(60);&#xA;&#xA;LCD_Write_COM(0x29);//Display ON&#xA;delay(30);&#xA;&#xA;LCD_Write_COM(0x2C);//Memory Write&#xA;delay(30);&#xA;break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19338" LastEditorUserId="6936" LastEditDate="2016-03-19T01:00:54.593" LastActivityDate="2016-03-19T01:00:54.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21895" PostTypeId="1" AcceptedAnswerId="22041" CreationDate="2016-03-17T04:40:54.743" Score="2" ViewCount="2958" Body="&lt;p&gt;Problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an HDMI switch that is controllable via RS232&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Scenario 1:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setup: PC connected to HDMI switch using USB -&gt; serial adapter  &lt;/li&gt;&#xA;&lt;li&gt;Test: Opening PuTTY on COM port and sending command &quot;sw i01&quot; from my PC&lt;/li&gt;&#xA;&lt;li&gt;Results: HDMI switch input changes to port 1 [Good]&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Scenario 2:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setup: Arduino UART port connected to TTL-&gt;RS232 adapter connected to serial-&gt;USB adapter connected to PC with PuTTY program open on COM port&lt;/li&gt;&#xA;&lt;li&gt;Test: Sending command &quot;sw i01&quot; from Arduino to PC using code below&lt;/li&gt;&#xA;&lt;li&gt;Results: &quot;sw i01&quot; prints repeatedly on the Putty terminal [Good]&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Scenario 3:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Setup: Arduino UART port connected to TTL-&gt;RS232 adapter connected to HDMI switch serial port&lt;/li&gt;&#xA;&lt;li&gt;Test: Sending &quot;sw i01&quot; from Arduino repeatedly to HDMI switch using code below&lt;/li&gt;&#xA;&lt;li&gt;Results: HDMI port does not switch from port2 to port1 [Bad]&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Intel Galileo Gen 2&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/449&quot; rel=&quot;nofollow&quot;&gt;SparkFunRS232/TTL Shifter&lt;/a&gt; connected to Galileo UART&lt;/li&gt;&#xA;&lt;li&gt;HDMI switch is &lt;a href=&quot;http://iogear.custhelp.com/app/answers/detail/a_id/2492/~/ghsw8141-and-ghsw8181-quick-start-guide&quot; rel=&quot;nofollow&quot;&gt;IOGear GHSW8141&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Code: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Note: Galileo Gen 2 requires Serial1 for UART communication]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial1.begin(19200);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial1.print(&quot;sw i01&quot;);&#xA;    Serial1.write(13);    // CR&#xA;    Serial1.write(10);    // LF&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Question: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like Scenario 1 and 2 confirm that the Arduino-&gt;HDMI switch communication should work, but it doesn't. Am I missing something regarding physical connectivity? Does manually typing &quot;sw i01&quot; in PuTTY send different commands than I have in the Arduino code?&lt;/p&gt;&#xA;" OwnerUserId="19339" LastEditorUserId="6936" LastEditDate="2016-03-26T03:26:14.137" LastActivityDate="2016-03-26T03:26:14.137" Title="Controlling HDMI Switch via RS232/UART" Tags="|serial|uart|arduino-galileo|rs232|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21896" PostTypeId="2" ParentId="21880" CreationDate="2016-03-17T06:39:50.687" Score="1" Body="&lt;p&gt;Or you may exchange the whole controller with a power mosfet module connected to your arduino. And use pwm directly from your arduino.&#xA;&lt;a href=&quot;http://store.arduino.cc/product/T010020&quot; rel=&quot;nofollow&quot;&gt;http://store.arduino.cc/product/T010020&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-17T06:39:50.687" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21902" PostTypeId="2" ParentId="21895" CreationDate="2016-03-17T10:55:33.570" Score="1" Body="&lt;p&gt;Your HDMI switcher, and your USB to RS-232 converter speak RS-232.  The Arduino speaks TTL UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the concept behind them, and the overall format of the data, is the same there are major differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RS-232 uses a ±10V NRZ signalling method, TTL UART uses a 0-5V signalling method&lt;/li&gt;&#xA;&lt;li&gt;RS-232 uses inverse logic compared to TTL UART&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That means that you need to convert the Arduino's TTL UART to ±10V NRZ with inverse logic in order to communicate with the IOGear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately that's a simple enough task using a special interface chip. These are readily available and can be bought for tiny amounts as a breakout board or even a full shield if you like (such as &lt;a href=&quot;https://www.sparkfun.com/products/13029&quot; rel=&quot;nofollow&quot;&gt;this one from Sparkfun&lt;/a&gt;).  The chip is known as a &lt;strong&gt;MAX232&lt;/strong&gt; in its most common form, though other manufacturers may use different letters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you pop on eBay (or your favourite budget seller site) and search for &quot;Arduino MAX232 DB9&quot; (the DB9 is the type of plug on the board - the 9-pin D connector) you will get lots of hits to choose from.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-17T10:55:33.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21904" PostTypeId="2" ParentId="18015" CreationDate="2016-03-17T12:08:59.733" Score="2" Body="&lt;p&gt;I have had same problem, issued on v1.6.7 and v1.6.8. I solved it with the &lt;a href=&quot;https://github.com/marcoschwartz/LiquidCrystal_I2C&quot; rel=&quot;nofollow&quot;&gt;new 'marcoschwartz' library&lt;/a&gt; specified in other answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I had used the same DFRobot library, which worked fine on IDE 1.6.0, until I upgraded on v1.6.7.&lt;/p&gt;&#xA;" OwnerUserId="19352" LastEditorUserId="6936" LastEditDate="2016-03-19T01:06:05.877" LastActivityDate="2016-03-19T01:06:05.877" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21907" PostTypeId="2" ParentId="21838" CreationDate="2016-03-17T13:13:15.703" Score="1" Body="&lt;p&gt;I found the answer searching through the Doxygen files. I had to go to AppConfig.h under Config in the project root directory, and edit AUX_LINE_MASK to change the pin. Thanks to everyone who helped!&lt;/p&gt;&#xA;" OwnerUserId="19039" LastActivityDate="2016-03-17T13:13:15.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21910" PostTypeId="1" CreationDate="2016-03-17T17:22:51.243" Score="0" ViewCount="91" Body="&lt;p&gt;I'm doing a project which is automatic box carrier. It will hold a box from a location and move it next to it. Kind of cnc work. Locations are fixed it just has to run the orders. I want to send an array of integers and manage them in the switch under main loop. for example&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  orders[0]=2;&#xA;  orders[1]=2000;&#xA;&#xA;  orders[2]=3;&#xA;  orders[3]=60;&#xA;&#xA;  orders[4]=1;&#xA;  orders[5]=7000;&#xA;&#xA;  orders[6]=2;&#xA;  orders[7]=2000;&#xA;&#xA;  orders[8]=3;&#xA;  orders[9]=90;&#xA;&#xA;  orders[10]=1;&#xA;  orders[11]=2000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will be my orders array and here is the code i want to run. When I upload code to arduino steppers and servo doing fine until orders[8]. When came to that order; first servo goes to 30 degrees then goes to 0 and click sound starts. After that steppers are not doing remaining steps.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo;&#xA;&#xA;int distance=0;&#xA;int code =0;&#xA;int orders[10]={};&#xA;int thisStep=0;&#xA;int thisVal=1;&#xA;int pos = 0;&#xA;int currpos=90;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(115200);&#xA;&#xA;  pinMode(2,OUTPUT);&#xA;  pinMode(3,OUTPUT);&#xA;  pinMode(4,OUTPUT);&#xA;  pinMode(5,OUTPUT);&#xA;  digitalWrite(2,LOW);&#xA;  digitalWrite(3,LOW);&#xA;  digitalWrite(4,LOW);&#xA;  digitalWrite(5,LOW);&#xA;  myservo.attach(9);&#xA;&#xA;  orders[0]=2;&#xA;  orders[1]=7000;&#xA;&#xA;  orders[2]=3;&#xA;  orders[3]=60;&#xA;&#xA;  orders[4]=1;&#xA;  orders[5]=2000;&#xA;&#xA;  orders[6]=2;&#xA;  orders[7]=2000;&#xA;&#xA;  orders[8]=3;&#xA;  orders[9]=30;&#xA;&#xA;  orders[10]=1;&#xA;  orders[11]=2000;&#xA;&#xA; /* orders[12]=2;&#xA;  orders[13]=5000;*/&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  code = orders[thisStep];&#xA;  switch (code){&#xA;    case 1:&#xA;&#xA;    go(orders[thisVal]);&#xA;    thisStep = thisStep + 2;&#xA;  thisVal = thisVal + 2;&#xA;&#xA;    break;&#xA;    case 2:&#xA;     Serial.println(thisVal);&#xA;    goReverse(orders[thisVal]);&#xA;    thisStep = thisStep + 2;&#xA;    thisVal = thisVal + 2;&#xA;&#xA;    break;&#xA;&#xA;    case 3:&#xA;    goServo(orders[thisVal]);&#xA;    thisStep = thisStep + 2;&#xA;    thisVal = thisVal + 2;&#xA;    break;&#xA;  }&#xA;&#xA;}&#xA;void go(int dist){&#xA;  digitalWrite(2,LOW);&#xA;  digitalWrite(4,LOW);&#xA;  do{&#xA;  digitalWrite(3,HIGH);&#xA;  digitalWrite(5,HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(3,LOW);&#xA;  digitalWrite(5,LOW);&#xA;  delayMicroseconds(10);&#xA;  distance = distance+1;&#xA;  Serial.println(distance);&#xA;  }while (dist&amp;gt;distance);&#xA; distance=0;&#xA; delay(500);&#xA;}&#xA;void goReverse(int dist){&#xA;  digitalWrite(2,HIGH);&#xA;  digitalWrite(4,HIGH);&#xA;  do{&#xA;  digitalWrite(3,HIGH);&#xA;  digitalWrite(5,HIGH);&#xA;  delayMicroseconds(300);&#xA;  digitalWrite(3,LOW);&#xA;  digitalWrite(5,LOW);&#xA;  delayMicroseconds(300);&#xA;  distance = distance+1;&#xA;&#xA;  }while (dist&amp;gt;distance);&#xA;  distance=0;&#xA;  delay(500);&#xA;}&#xA;&#xA;void goServo (int degree){&#xA;  myservo.attach(9);&#xA;  myservo.write(degree);&#xA;&#xA;  delay(300);&#xA;   myservo.detach();&#xA;  /*if (currpos &amp;gt; degree)&#xA;  {&#xA;    for (pos = currpos; pos &amp;gt;= degree; pos -= 1) { // goes from 0 degrees to 180 degrees&#xA;      // in steps of 1 degree&#xA;       myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;       delay(15);  &#xA;       // waits 15ms for the servo to reach the position&#xA;      }&#xA;      delay(500); &#xA;  }&#xA;  else if (currpos &amp;lt; degree)&#xA;  {&#xA;    for (pos = currpos; pos &amp;lt;= degree; pos += 1) { // goes from 0 degrees to 180 degrees&#xA;      // in steps of 1 degree&#xA;       myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;       delay(15);  &#xA;       // waits 15ms for the servo to reach the position&#xA;      }&#xA;&#xA;  }&#xA;  currpos=degree;&#xA;&#xA;*/&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="19358" LastEditorUserId="4131" LastEditDate="2016-03-18T19:00:20.690" LastActivityDate="2016-08-16T05:32:01.573" Title="Running Steppers with servo" Tags="|arduino-mega|arduino-ide|servo|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21911" PostTypeId="1" CreationDate="2016-03-17T18:19:16.653" Score="1" ViewCount="148" Body="&lt;p&gt;I have been working on a project watch which would work best if it is entirely sealed (to waterproof it). The watch may need future updates, but I will be unable to send code to it using a usb connector or isp programmer without opening the case. What is the best way to connect my PC with this watch wirelessly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I gather that the serial ports are usually used to send code via the usb, and that most Bluetooth modules use serial coms to communicate with the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino that I am using is an Arduino Pro Mini clone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19359" LastActivityDate="2016-03-18T09:11:13.910" Title="Uploading code to Arduino wirelessly" Tags="|bluetooth|arduino-pro-mini|wireless|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21912" PostTypeId="1" AcceptedAnswerId="21919" CreationDate="2016-03-17T18:30:09.767" Score="1" ViewCount="3696" Body="&lt;p&gt;I am writing a program that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Reads string (one line) from com port &lt;/li&gt;&#xA;&lt;li&gt;Waits for an RFID card to be present&lt;/li&gt;&#xA;&lt;li&gt;Reads a block from the card&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's the code (it uses &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; MFRC522 library, also the code is based on makecourse.com  RFID tutorial):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt; //include the SPI bus library&#xA;#include &amp;lt;MFRC522.h&amp;gt; //include the RFID reader library&#xA;&#xA;#define SS_PIN 10  //slave select pin&#xA;#define RST_PIN 9  //reset pin&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);        // instatiate a MFRC522 reader object.&#xA;MFRC522::MIFARE_Key key; //create a MIFARE_Key struct named 'key', which will hold the card information&#xA;&#xA;byte readbackblock[18]; //This array is used for reading out a block. The MIFARE_Read method requires a buffer that is at least 18 bytes to hold the 16 bytes of a block.&#xA;&#xA;String inString = &quot;&quot;; // COM port incoming data buffer&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);        // Initialize serial communications with the PC&#xA;  SPI.begin();               // Init SPI bus&#xA;  mfrc522.PCD_Init();        // Init MFRC522 card (in case you wonder what PCD means: proximity coupling device)&#xA;  Serial.println(&quot;Scan a MIFARE Classic card&quot;);&#xA;&#xA;  // Prepare the security key for the read and write functions - all six key bytes are set to 0xFF at chip delivery from the factory.&#xA;  // Since the cards in the kit are new and the keys were never defined, they are 0xFF&#xA;  // if we had a card that was programmed by someone else, we would need to know the key to be able to access it. This key would then need to be stored in 'key' instead.&#xA;&#xA;  for (byte i = 0; i &amp;lt; 6; i++) {&#xA;    key.keyByte[i] = 0xFF;//keyByte is defined in the &quot;MIFARE_Key&quot; 'struct' definition in the .h file of the library&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    int inChar = Serial.read();&#xA;&#xA;    if (inChar != '\n') {&#xA;      inString += (char)inChar;&#xA;    } else {&#xA;      // New line&#xA;&#xA;      Serial.println(&quot;Start&quot;);&#xA;      while (!initcard()); // Detecting new card&#xA;      Serial.println(&quot;CardFound&quot;);&#xA;      readBlockToCom(2); // Reading a block&#xA;      Serial.println(&quot;Done&quot;);&#xA;      inString = &quot;&quot;;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;bool initcard()&#xA;{&#xA;  // Look for new cards (in case you wonder what PICC means: proximity integrated circuit card)&#xA;  if ( ! mfrc522.PICC_IsNewCardPresent()) {//if PICC_IsNewCardPresent returns 1, a new card has been found and we continue&#xA;    return false; //if it did not find a new card is returns a '0' and we return to the start of the loop&#xA;  }&#xA;&#xA;  // Select one of the cards&#xA;  if ( ! mfrc522.PICC_ReadCardSerial()) {//if PICC_ReadCardSerial returns 1, the &quot;uid&quot; struct (see MFRC522.h lines 238-45)) contains the ID of the read card.&#xA;    return false; //if it returns a '0' something went wrong and we return to the start of the loop&#xA;  }&#xA;  return true;&#xA;}    &#xA;&#xA;void readBlockToCom(int number)&#xA;{&#xA;  readBlock(number, readbackblock);//read the block back&#xA;  Serial.print(&quot;read block: &quot;);&#xA;  for (int j = 0 ; j &amp;lt; 16 ; j++) //print the block contents&#xA;  {&#xA;    Serial.write (readbackblock[j]);//Serial.write() transmits the ASCII numbers as human readable characters to serial monitor&#xA;  }&#xA;  Serial.println(&quot;&quot;);&#xA;}&#xA;&#xA;int readBlock(int blockNumber, byte arrayAddress[]) &#xA;{&#xA;  int largestModulo4Number=blockNumber/4*4;&#xA;  int trailerBlock=largestModulo4Number+3;//determine trailer block for the sector&#xA;&#xA;  /*****************************************authentication of the desired block for access***********************************************************/&#xA;  byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &amp;amp;key, &amp;amp;(mfrc522.uid));&#xA;  //byte PCD_Authenticate(byte command, byte blockAddr, MIFARE_Key *key, Uid *uid);&#xA;  //this method is used to authenticate a certain block for writing or reading&#xA;  //command: See enumerations above -&amp;gt; PICC_CMD_MF_AUTH_KEY_A   = 0x60 (=1100000),      // this command performs authentication with Key A&#xA;  //blockAddr is the number of the block from 0 to 15.&#xA;  //MIFARE_Key *key is a pointer to the MIFARE_Key struct defined above, this struct needs to be defined for each block. New cards have all A/B= FF FF FF FF FF FF&#xA;  //Uid *uid is a pointer to the UID struct that contains the user ID of the card.&#xA;  if (status != MFRC522::STATUS_OK) {&#xA;         Serial.print(&quot;PCD_Authenticate() failed (read): &quot;);&#xA;         Serial.println(mfrc522.GetStatusCodeName(status));&#xA;         return 3;//return &quot;3&quot; as error message&#xA;  }&#xA;  //it appears the authentication needs to be made before every block read/write within a specific sector.&#xA;  //If a different sector is being authenticated access to the previous one is lost.&#xA;&#xA;&#xA;  /*****************************************reading a block***********************************************************/&#xA;&#xA;  byte buffersize = 18;//we need to define a variable with the read buffer size, since the MIFARE_Read method below needs a pointer to the variable that contains the size... &#xA;  status = mfrc522.MIFARE_Read(blockNumber, arrayAddress, &amp;amp;buffersize);//&amp;amp;buffersize is a pointer to the buffersize variable; MIFARE_Read requires a pointer instead of just a number&#xA;  if (status != MFRC522::STATUS_OK) {&#xA;          Serial.print(&quot;MIFARE_read() failed: &quot;);&#xA;          Serial.println(mfrc522.GetStatusCodeName(status));&#xA;          return 4;//return &quot;4&quot; as error message&#xA;  }&#xA;  Serial.println(&quot;block was read&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having is that &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I send first line via com port &lt;/li&gt;&#xA;&lt;li&gt;Apply a card to RFID-RC522 &lt;/li&gt;&#xA;&lt;li&gt;The program reads the block alright &lt;/li&gt;&#xA;&lt;li&gt;But then I send the second line &lt;/li&gt;&#xA;&lt;li&gt;Arduino hangs on card detect&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here's the output I receive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Scan a MIFARE Classic card&#xA;Start&#xA;CardFound&#xA;block was read&#xA;read block: makecourse_____&#xA;Done&#xA;Start&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried removing card and applying it again or applying a different card, but it still freezes on card detect, sometimes after some time it works, though. &lt;/p&gt;&#xA;" OwnerUserId="19294" LastEditorUserId="4131" LastEditDate="2016-03-18T13:54:48.700" LastActivityDate="2016-03-18T13:54:48.700" Title="RFID detects the first card fine, but hangs on a second" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21913" PostTypeId="1" AcceptedAnswerId="21915" CreationDate="2016-03-17T19:52:51.207" Score="0" ViewCount="604" Body="&lt;p&gt;I am trying to get my head around how to instantiate objects from existing libaries inside a class object. Specifically I am trying to get the bounce2.h debouncer working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment my code compiles but i think the debounce function is not working as the button is filling my array with lots of random numbers (even from setup) whereas it works fine on a non-class based sketch, so I think that I am probably not instantiating the bounce object correctly. If anyone can help I would be very grateful!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef CandleRack_h&#xA;#define CandleRack_h&#xA;&#xA;class CandleRack&#xA;{&#xA;  public:&#xA;&#xA;    CandleRack(byte candleRackStatus);&#xA;    void begin();&#xA;    void pushButton();&#xA;    void selectRandomCandle();&#xA;    void turnOnCandle(byte candlePosition);&#xA;    void burnCandlesForMs();&#xA;    void fadeOutCandle(byte candlePosition);&#xA;&#xA;  private:&#xA;    Bounce _debouncePushButton;&#xA;    byte _pushButtonPin; &#xA;    byte _candleRackStatus;    &#xA;    byte _candlePosition;&#xA;    byte _candleStatus[];&#xA;    elapsedMillis _candleTimeElapsed;&#xA;    unsigned int _candleOnForMs;&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My cpp &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;FastLED.h&amp;gt;&#xA;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;#include &amp;lt;Bounce2.h&amp;gt;&#xA;#include &quot;CandleRack.h&quot;&#xA;&#xA;#define NUM_LEDS 50&#xA;&#xA;CandleRack::CandleRack(byte candleRackStatus)&#xA;{&#xA;  _candleRackStatus = candleRackStatus;&#xA;}&#xA;&#xA;void CandleRack::begin()&#xA;{&#xA;  randomSeed(analogRead(0));&#xA;&#xA;  _debouncePushButton = Bounce();&#xA;  _pushButtonPin = 3;&#xA;  _candleOnForMs = 20000;&#xA;  pinMode(_pushButtonPin, INPUT_PULLUP);&#xA;  _debouncePushButton.attach(_pushButtonPin);&#xA;  _debouncePushButton.interval(10);&#xA;&#xA;  for (byte b = 0; b &amp;lt; NUM_LEDS; b++)&#xA;  {&#xA;    _candleStatus[_candlePosition] = 0;&#xA;  }&#xA;&#xA;  Serial.println(&quot;Candle Array: &quot;);       // Debug ************************&#xA;  for (byte b = 0; b &amp;lt; NUM_LEDS; b++)     // Debug ************************&#xA;  {                                       // Debug ************************&#xA;    Serial.print(_candleStatus[b]);       // Debug ************************&#xA;    Serial.print(&quot;, &quot;);                   // Debug ************************&#xA;  }                                       // Debug ************************&#xA;  Serial.println(&quot;&quot;);                     // Debug ************************&#xA;  Serial.println(&quot;Begin Complete&quot;);       // Debug ************************&#xA;}&#xA;&#xA;&#xA;void CandleRack::pushButton()&#xA;{&#xA;  // Look for a button push&#xA;  if (_debouncePushButton.update())&#xA;  {&#xA;    if (_debouncePushButton.fell())&#xA;    {&#xA;      selectRandomCandle();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;void CandleRack::selectRandomCandle()&#xA;{&#xA;  byte randomCandlePosition;&#xA;  do&#xA;  {&#xA;    randomCandlePosition = random(0, NUM_LEDS);&#xA;  }&#xA;  while (_candleStatus[randomCandlePosition] != 0);&#xA;&#xA;  turnOnCandle(randomCandlePosition);&#xA;}&#xA;&#xA;&#xA;void CandleRack::turnOnCandle(byte _candlePosition)&#xA;{&#xA;  // leds[_candlePosition] = CRGB::Red;&#xA;  _candleStatus[_candlePosition] = 1;&#xA;&#xA;  Serial.println(&quot;Button Pushed: &quot;);      // Debug ************************&#xA;  Serial.println(_candlePosition);        // Debug ************************&#xA;  Serial.println(&quot;Candle Array: &quot;);       // Debug ************************&#xA;  for (byte b = 0; b &amp;lt; NUM_LEDS; b++)     // Debug ************************&#xA;  {                                       // Debug ************************&#xA;    Serial.print(_candleStatus[b]);       // Debug ************************&#xA;    Serial.print(&quot;, &quot;);                   // Debug ************************&#xA;  }                                       // Debug ************************&#xA;  Serial.println(&quot;&quot;);                     // Debug ************************&#xA;}&#xA;&#xA;&#xA;void CandleRack::burnCandlesForMs()&#xA;{&#xA;  // See if it is time to turn the candle off&#xA;  for (byte b = 0; b &amp;lt; NUM_LEDS; b++)&#xA;  {&#xA;    if (_candleTimeElapsed &amp;gt; _candleOnForMs &amp;amp;&amp;amp; _candleStatus[b] == 1)&#xA;    {&#xA;      CandleRack::fadeOutCandle(b);&#xA;      _candleTimeElapsed = 0;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;&#xA;void CandleRack::fadeOutCandle(byte _candlePosition)&#xA;{&#xA;  _candleStatus[_candlePosition] = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;FastLED.h&amp;gt;&#xA;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;#include &amp;lt;Bounce2.h&amp;gt;&#xA;#include &quot;CandleRack.h&quot;&#xA;&#xA;CandleRack MyCandleRack(0);&#xA;&#xA;void setup() {&#xA;  delay(3000); // sanity delay&#xA;&#xA;  Serial.begin(9600);&#xA;  while (!Serial); &#xA;&#xA;  Serial.println(&quot;Setup Starts&quot;);  // Debug ************************&#xA;&#xA;  MyCandleRack.begin();&#xA;&#xA;  Serial.println(&quot;Setup Complate&quot;);  // Debug ************************&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  MyCandleRack.pushButton();&#xA; // MyCandleRack.burnCandlesForMs();&#xA;&#xA;  FastLED.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;edit - added the code from the original debounce example for a single sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Detect the falling edge&#xA;&#xA;// Include the Bounce2 library found here :&#xA;// https://github.com/thomasfredericks/Bounce-Arduino-Wiring&#xA;#include &amp;lt;Bounce2.h&amp;gt;&#xA;&#xA;&#xA;#define BUTTON_PIN 2&#xA;#define LED_PIN 13&#xA;&#xA;int ledState = LOW;&#xA;&#xA;&#xA;// Instantiate a Bounce object :&#xA;Bounce debouncer = Bounce(); &#xA;&#xA;void setup() {&#xA;&#xA;  // Setup the button with an internal pull-up :&#xA;  pinMode(BUTTON_PIN,INPUT_PULLUP);&#xA;&#xA;  // After setting up the button, setup the Bounce instance :&#xA;  debouncer.attach(BUTTON_PIN);&#xA;  debouncer.interval(500);&#xA;&#xA;  // Setup the LED :&#xA;  pinMode(LED_PIN,OUTPUT);&#xA;  digitalWrite(LED_PIN,ledState);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Update the Bounce instance :&#xA;   debouncer.update();&#xA;&#xA;   // Call code if Bounce fell (transition from HIGH to LOW) :&#xA;   if ( debouncer.fell() ) {&#xA;&#xA;     // Toggle LED state :&#xA;     ledState = !ledState;&#xA;     digitalWrite(LED_PIN,ledState);&#xA;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19361" LastEditorUserId="19361" LastEditDate="2016-03-17T22:57:40.830" LastActivityDate="2016-03-18T11:15:59.587" Title="Instantiating bounce library inside a class" Tags="|library|class|debounce|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21914" PostTypeId="1" CreationDate="2016-03-17T20:22:41.397" Score="7" ViewCount="7179" Body="&lt;p&gt;I'm looking to communicate between ~5-10 Arduinos to send commands and data between them. By &quot;Arduino&quot; I mean the ATmega328 programmed using the Arduino programming framework.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each of the devices would be on the same PCB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know I2C and SPI can communicate to some degree, but that they're really meant for peripherals devices connected to a micro controller rather than connecting multiple micro controllers to each other, and that they usually only send a few bytes of data at a time. On the other hand I know LCD displays can be driven using them, and I'd imagine there's a lot of data being transferred in those cases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a something like I2C (multi-master, multi-slave, single-ended, serial computer bus) for communicating between micro controllers? Allowing each device to send data to each other device unsolicited. For example, if a switch was pressed on device A, it would tell device B, without having device B ask A all the time if a switch was pressed. and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I found some libraries that may do what I want with RS-485. Is this the only viable option for ~1k bps transmission between 5-10 devices? I would imagine TCP/IP over Ethernet would work as well, but that seems like too much. Are there any I2C libraries that allow sending that amount of data between only master devices?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MichaelJonker/HardwareSerialRS485&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/MichaelJonker/HardwareSerialRS485&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/MajenkoLibraries/ICSC&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7461" LastEditorUserId="7461" LastEditDate="2016-03-18T19:06:16.317" LastActivityDate="2016-04-15T04:34:52.617" Title="Options for communicating between Arduinos" Tags="|communication|" AnswerCount="4" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="21915" PostTypeId="2" ParentId="21913" CreationDate="2016-03-17T21:57:56.360" Score="1" Body="&lt;p&gt;Your main issue (the cause of your symptoms) is the fact that you have no size for your &lt;code&gt;_candleStatus&lt;/code&gt; array.  Without specifying a size you end up with no memory allocated to the array, and hence no valid content.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your class definition the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte _candleStatus[];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be modified to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte _candleStatus[NUM_LEDS];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;code&gt;NUM_LEDS&lt;/code&gt; should be defined in the header, not in the CPP file. (By specifying it in the header file, since the header file is included in the CPP file, the definition ends up in both files).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside from that this line doesn't do what you think it does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_debouncePushButton = Bounce();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are copying the content of an anonymous bounce object created just for the occasion into a pre-existing Bounce object.  You don't want that line to exist since the Bounce object has already been instantiated by the construction of your &lt;code&gt;CandleRack&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there is something you need to be aware of known as the &lt;em&gt;Static Initialization Order Fiasco&lt;/em&gt; which can bite you on the rear end if you are not aware of it.  This is basically when you use objects in other objects and those objects haven't yet been properly created since you cannot predict the order in which objects are initialized. This may or may not be an issue in your system - it all depends on how the other classes you use behave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One way around the issue, if you find it does become a problem (or if you just want to avoid the problem altogether) is to use pointers and what is known as &lt;em&gt;Construct On First Use&lt;/em&gt;.  This is where you don't instantiate any objects in your constructor or the class definition - instead you just have pointers to them and use the &lt;code&gt;new&lt;/code&gt; keyword to construct the object from within a member function (such as &lt;code&gt;begin()&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this you change your class definition object entries to be pointers, such as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bounce *_debouncePushButton = NULL;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Note that not all versions of the compiler will support that assignment in the class definition. It's a modern addition to C++ and depending on your version of the Arduino software may or may not work. If it doesn't you can move the assignment into the constructor by removing the &lt;code&gt;= NULL&lt;/code&gt; from the definition and adding &lt;code&gt;_debouncePushButton = NULL;&lt;/code&gt; into the constructor.)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then construct a new object in the &lt;code&gt;begin()&lt;/code&gt; function (if it hasn't already been created):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (_debouncePushButton == NULL) {&#xA;    _debouncePushButton = new Bounce();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have to access the &lt;code&gt;_debouncePushButton&lt;/code&gt; as a pointer to an object not an object, so change all your accesses to use the pointer dereference operator &lt;code&gt;-&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_debouncePushButton-&amp;gt;attach(_pushButtonPin);&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case the class should ever go &lt;em&gt;out of scope&lt;/em&gt; or be used in a &lt;em&gt;dynamic&lt;/em&gt; way you really should create a &lt;em&gt;destructor&lt;/em&gt; to delete any objects that have been created:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack::~CandleRack() {&#xA;    if (_debouncePushButton != NULL) {&#xA;        delete _debouncePushButton;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you should only ever try and delete objects that have actually been created - hence the test to see if it's not null.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excessive use of &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; though is discouraged, so it is best to use objects in a static context if possible. Too much &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt; or &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; can cause &lt;em&gt;heap fragmentation&lt;/em&gt; which can lead to you running out of memory and all the associated stability problems that come with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, all this is optional and chances are it won't be needed if the other classes behave well.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-18T11:15:59.587" LastActivityDate="2016-03-18T11:15:59.587" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="21916" PostTypeId="2" ParentId="16796" CreationDate="2016-03-17T21:59:44.213" Score="0" Body="&lt;p&gt;I had to connect my &lt;code&gt;SCL&lt;/code&gt; and &lt;code&gt;SDA&lt;/code&gt; pins to dedicated &lt;strong&gt;20th and 21st&lt;/strong&gt; pins on &lt;code&gt;Arduino MEGA 2560&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19364" LastActivityDate="2016-03-17T21:59:44.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21917" PostTypeId="2" ParentId="20157" CreationDate="2016-03-17T22:05:36.370" Score="2" Body="&lt;p&gt;Ok, one simple step which might help you to get going.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The no-brainer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an RS232 link between your Arduino and the PC. (Of course, it might not be a real RS232, it can be the USB, and over the USB the PC sees the arduino as a serial port what you can write from Arduino. So far so good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily extend the USB with passive expansion cords, as well as with active USB expansion cords, easily getting an extra 30m. Of course it is not an RS485, but comes at no further thinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The RS485&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RS485 is basically a clever variant of a serial port, which allows you sending your data over up to 1.5km twisted wire pair.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;get an USB-RS485 adapter for your PC or Raspberry side. These are widely available, e.g. &lt;a href=&quot;http://usb-rs485.eu/?cms=eu85xl&amp;amp;gclid=CjwKEAjwq6m3BRCP7IfMq6Oo9gESJACRc0bNkhzTSQU3wUW_5tebRZDD-zAqflcvcFOq9V8nmZIlRhoCvyPw_wcB&quot; rel=&quot;nofollow&quot;&gt;http://usb-rs485.eu/?cms=eu85xl&amp;amp;gclid=CjwKEAjwq6m3BRCP7IfMq6Oo9gESJACRc0bNkhzTSQU3wUW_5tebRZDD-zAqflcvcFOq9V8nmZIlRhoCvyPw_wcB&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;get an RS485 driver chip such as MAX485 (I prefer LTC485, that works straight from 5V, costs like 1 EUR) for your Arduino side.&lt;/li&gt;&#xA;&lt;li&gt;you'll need two ardino pins - serial read and write, therefore you may prefer an Arduio supporting also Serial1 - so a TxD and RxD wire from the board. When you write to this serial port instead of Serial, the data comes out from the TxD pin of the Ardino panel, instead of going to the PC via the USB.&lt;/li&gt;&#xA;&lt;li&gt;now, if you can have a simplex system - i.e. only Arduino talks to the PC or Raspberry - then it makes your life a lot easier. Then you only need the TxD from the Arduino, and connect it to the DI of the RS485 driver chip. Connect RE and DE and connect both of them to 5V. That's all.&lt;/li&gt;&#xA;&lt;li&gt;if you want a two direction communication between the Arduino and PC, that makes things a bit more complicated. RS485 is a half-duplex thing, so your Arduino needs to control when it wants to talk to the line or listen. For that you need a separate pin to be connected to RE and DE together. Put it to 1 to write, 0 to read from the RS485 lines. Note that Arduino is having write buffers, so it will be a little tricky to know exactly when to switch back to listening after writing. Solving this properly worths of a separate question :)&lt;/li&gt;&#xA;&lt;li&gt;connect A of the MAX485/LTC485 to the A of the USB RS485 interface. Connect B to B. Now you're almost there... Connect also GND of the Arduino to the GND of the RS485 interface. (Although you can see many examples on the net of using only two wires, A and B, in the real life you either need a common GND, or an additional overvoltage protection circuit made of four zener diodes to have it running well forever.)&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you're advised of using a twisted pair wire for A and B. This is not a requirement though, you can go well with any wires. One of my friend used a garden fence made of metal as A, and the soil as B, which worked well for 50 meters :) However for 1.5Mbit, 1km you definitely need a twisted pair&lt;/li&gt;&#xA;&lt;li&gt;Note that if you go with long wires (over 50 meter) and higher speed (over 9600 bps), you need to have line-terminator resistors. This means a simple 120 ohm resistor connected between A and B on the PC side. Another 120 ohm resistor to be connected at A and B on the MAX 485 side - so the two farthest end of the long communication wire.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now the software side:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The USB RS485 interface will look like just a regular serial port for the PC (e.g. COM9) or Raspberry. So you can read and write the RS485 bus just like a standard com port.&lt;/li&gt;&#xA;&lt;li&gt;On the Arduino side, you can use the Serial1 (or equal) to write data out to the MAX485, which drives the wires.&lt;/li&gt;&#xA;&lt;li&gt;I suggest again to start with a simplex system, i.e. Arduino only writes data, the PC just reads data.&lt;/li&gt;&#xA;&lt;li&gt;Note that you have to use exactly the same bit rate on Arduino as well as on the PC side. Watch out when you open up the terminal. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-17T22:05:36.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21918" PostTypeId="2" ParentId="21914" CreationDate="2016-03-17T23:01:36.193" Score="2" Body="&lt;p&gt;There are a number of concepts that can help you realize your dream. I can't, in the space of this answer, tell you exactly how to implement what you want, but I can show you the concepts that will help you to implement it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First off there's the concept of the &lt;em&gt;bus master&lt;/em&gt;.  This isn't necessarily the device that instantiates communication - instead this is the device that &lt;em&gt;owns&lt;/em&gt; and &lt;em&gt;controls&lt;/em&gt; the bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a device that isn't the bus master wants to communicate on the bus it first asks permission from the bus master.  The old Z80 (well, I say &quot;old&quot;, but they are still in use in many forms today) used this concept to allow other chips to use the data and address buses. It consists of two signals - BUSRQ and BUSACK.  A device first looks to see if either of BUSRQ or BUSACK are active, and if neither are it then activates BUSRQ. If the bus master is willing to give up the bus to the other device (it's not using it at that moment) it activates BUSACK and the other device then knows that it can use the bus.  Nothing else can use it until BUSRQ and BUSACK have both been released.  Nice and simple and elegant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But not perfect. If two devices both decide to ask for the bus at the very same instant you get a &lt;em&gt;collision&lt;/em&gt;.  This is a common problem amongst shared bus systems like this, and causes untold problems unless you know how to handle it properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Enter the concept of &lt;em&gt;listen-while-you-talk&lt;/em&gt;.  This involves the device that is sending on the bus also listening to what is being sent on the bus through a separate receiver.  It then can know if what it sent on the bus is what actually ended up on the bus.  For instance if two devices talk at the same time and one sends &lt;code&gt;10011001&lt;/code&gt; and the other sends &lt;code&gt;11001100&lt;/code&gt; the result that appears on the bus might actually end up as something else, such as &lt;code&gt;11011101&lt;/code&gt; or maybe &lt;code&gt;10001000&lt;/code&gt; depending on how the bus signals are created.  So if you know what you sent got corrupted you can now do something about it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next concept: &lt;em&gt;backing off&lt;/em&gt;.  This is where both the senders wait for a short period and try and send again. As long as they both delay for a different amount of time the first one to try will get the bus and be able to communicate. But how do you guarantee that they will both delay for different times?  You may think the answer is simple: use a random number, like &lt;code&gt;rand()&lt;/code&gt; or &lt;code&gt;random()&lt;/code&gt;.  But that is also problematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another concept: &lt;em&gt;The &lt;strong&gt;pseudo&lt;/strong&gt; random number generator&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino doesn't generate random numbers.  It just uses a complex mathematical formula to create a sequence of numbers that, to us, &lt;em&gt;look&lt;/em&gt; random.  They aren't though.  Write a small program to print 10 random numbers through serial and run it multiple times (press the reset button).  You will find the same &quot;random&quot; numbers in the same order every time.  Try it on another Arduino and you get the same numbers again. Always the same. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what to do?  The answer is called &lt;em&gt;seeding&lt;/em&gt; the random number generator.  The next number generated by &lt;code&gt;rand()&lt;/code&gt; et al depend on the number that had been generated last.  So change the &lt;em&gt;first&lt;/em&gt; number and all the rest of the numbers will change.  However, you have a catch-22 situation. You need a random number to seed the random number generator to make it random to be able to generate a random number to seed the random number generator... ad infinitum.  You see where that's going? You can't seed from &lt;code&gt;rand()&lt;/code&gt; since &lt;code&gt;rand()&lt;/code&gt; isn't random until you have seeded from a random source. So you need to find a random source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that's not an easy task.  The best source of &lt;em&gt;entropy&lt;/em&gt; as it's known is &lt;em&gt;white noise&lt;/em&gt;. This can be generated in a number of ways with a number of different circuits - from the breakdown of a diode junction to very high gain amplification of the thermal fluctuations in a resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All are quite complex for what you want really, but there is a simpler, if slightly less random, method - read an analog input that isn't connected to anything.  It won't have as much of a range as a proper entropy generator, but it should provide enough randomness to give a reasonable chance of each device getting a different seed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another useful concept is the interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is good in a situation where you don't want the complexity of a multi-master bus with all the collisions etc. You have a single master that does all the work on the bus, and when a slave device has something important to say it nudges the master with an interrupt. The master then goes &quot;Yes? What do you want?&quot; to which the slave replies &quot;Someone pressed my button&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way the master isn't constantly polling the slave to see if the button has been pressed.  It is often used in bus arrangements like SPI and there are many chips, such as IO expander chips, that can assert an interrupt when one of their input pins changes state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you have 20 devices does that mean you have 20 interrupt pins?  Not necessarily. New concept: &lt;em&gt;wired OR&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's perfectly possible to have multiple different slaves all using the same interrupt pin.  The pin is normally held HIGH with a resistor (it could be an internal pullup resistor) and each slave has an &lt;em&gt;open drain&lt;/em&gt; output connected to that pin.  An open drain output, when &quot;off&quot;, is not connected to anything - it's like the pin is in input mode (in fact it can be emulated on chips that don't have open drain by switching between input and output mode).  When the output is &quot;on&quot; it connects the pin to ground, pulling down the IO pin, just like a button would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's then up to the master to make its way round the slaves that it knows are attached to that interrupt to see who needs attention.  You can of course implement a number of different interrupt pins with different groups of slaves on each one - maybe a high priority one with just one device, and lower priority ones with multiple devices on each, for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same concept of &lt;em&gt;wired OR&lt;/em&gt; and &lt;em&gt;open drain&lt;/em&gt; can be used for allowing multiple devices to all share the same physical wires.  That is exactly how I2C works - the two bus lines are pulled up by resistors and the devices on it use open drain outputs to pull the line low to release it back to high to create the different logic levels. If two devices both pull it low together it will just be low.  Without the open drain method if you had one device outputting a 1 and another outputting a 0 you would basically get a short circuit between the two and you would end up damaging chips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then of course you have the concept of synchronous versus asynchronous communication, but that is an entirely different kettle of fish. Simply said though, protocols with a clock, like SPI and I2C, which have a master generating that clock, are synchronous. Protocols like the UART and RS-232, RS-485, etc are asynchronous - they rely on both ends agreeing on how fast data is being sent (baud rate) so they know how to interpret the signals as they arrive.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-17T23:01:36.193" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21919" PostTypeId="2" ParentId="21912" CreationDate="2016-03-17T23:48:08.160" Score="4" Body="&lt;p&gt;You should try adding this, at the end of &lt;code&gt;readBlock()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Halt PICC&#xA;mfrc522.PICC_HaltA();&#xA;// Stop encryption on PCD&#xA;mfrc522.PCD_StopCrypto1();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-17T23:48:08.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21920" PostTypeId="1" CreationDate="2016-03-18T00:26:16.560" Score="0" ViewCount="287" Body="&lt;p&gt;So this is my first arduino (or embedded for that matter) project. I am trying to power 4 leds with max7219. Max7219 seems easy to use, but for some reason after I upload the code, nothing happens. I've looked over my breadboard, and the connections seem right. My confusion arises from the fact that all the projects I have found on google use matrices for the leds. I am using 4 separate leds. Does this even matter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I use:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;LedControl.h&quot;&#xA;&#xA;LedControl ledControl = LedControl(12, 9, 10, 1);&#xA;&#xA;void setup()&#xA;{&#xA;    //should be waking ledcontrol&#xA;    ledControl.shutdown(0, false);&#xA;    ledControl.setIntensity(0, 8);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    ledControl.setLed(0, 0, 0, true);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19365" LastEditorUserId="4131" LastEditDate="2016-03-18T16:30:12.937" LastActivityDate="2016-03-18T16:30:12.937" Title="Power 4 leds with max7219 and LedControl.h" Tags="|led|max7219|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21921" PostTypeId="2" ParentId="3728" CreationDate="2016-03-18T01:18:32.003" Score="3" Body="&lt;p&gt;I'm pretty sure that, despite the schematic provided, you will find that the 5V Pro Micro actually has a 5V regulator onboard. So even if you open the jumper, it will still be powering the Atmega32u4 at 5V (technically 5V minus diode voltage drop and regulator dropout voltage).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could change the regulator for a 3.3V one using a hot air station and solder paste &lt;em&gt;and&lt;/em&gt; open the jumper, but as other posters have commented, you would still be running the Atmega beyond spec at 16MHz and 3.3V.&lt;/p&gt;&#xA;" OwnerUserId="10733" LastActivityDate="2016-03-18T01:18:32.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21922" PostTypeId="2" ParentId="21914" CreationDate="2016-03-18T03:37:34.823" Score="0" Body="&lt;p&gt;In addition to @Majenko's excellent answer, you need to have a think about what you are communicating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you want to communicate a single bit - perhaps you can get away with individual pins? If you have a master, and up to 13 slaves, you could have one pin on the master connected to one pin on each of the slaves (via a resistor). If slave A wanted to signal it's signal, it would raise the pin; the master would then be able to poll each pin in turn, to work out who said what.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-18T03:37:34.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21923" PostTypeId="2" ParentId="21914" CreationDate="2016-03-18T04:09:11.517" Score="0" Body="&lt;p&gt;Another option is SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SPI can be used with any number of devices, in a ring. It was explained to me as follows: any participant can toggle the clock line 8 times, to move the byte in it's own buffer, into the next device's buffer, in a ring; the device gets a byte from the previous device. If someone else toggles the clock 8 times, you get notified that the new byte is ready (this is done in hardware).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to think carefully about a protocol for this - an &quot;address&quot;, &quot;length&quot;, &quot;command&quot;, and then any number of parameters. The sender sends the &quot;address&quot; byte, sets the &quot;length&quot; byte in the buffer, and holds the rest ready. The next device has received the &quot;address&quot; byte, and sees if it is the intended recipient. If it is not, it notes this down, and pushes the chain round, notes the length, and waits until someone ELSE has pushed that many bytes around. If it IS yours, read the rest of the data, pushing the data around, and blanking it as you go (to stop it coming back). A blank address (e.g. 0) would be reserved, meaning &quot;don't do anything with this, wait for someone else to push it around, and read the next byte as the next address&quot;. All devices would need to initialize to 0 on startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to set addresses dynamically, set a special byte &quot;all stations&quot;, with a command which means &quot;your device number is X, and tell the next device it's device number is X+1&quot;. Someone would need to initiate this, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also run the risk of collisions, if two devices start sending at the same time, or if something doesn't relay what it's supposed to (e.g. a chip is powered down). You need to think about how you're going to detect/recover from this.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-18T04:09:11.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21924" PostTypeId="1" CreationDate="2016-03-18T04:23:43.203" Score="1" ViewCount="1056" Body="&lt;p&gt;Am working on a WiFi based irrigation system that utilises the RF24 lib for comms.&#xA;Have got prototype of remote sensor up and running which has a standby current of 0.036mA and transmits data every hour using around a peak of 12mA. &#xA;While running the prototype I see various retry attempts which seem to vary with every transmission – despite the setup being under the same conditions all the time. I have coded a retry loop to limit this to 10 tries connecting to the master – don’t want the sensor to continuously be sending without getting a confirmation from the master&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to find is the ideal delay required between various RF24 commands to limit transmit times as much as possible to conserve power usage.&#xA;Any ideas??&#xA;(code snippets attached)&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;   pinMode(mostureSensorVCC, OUTPUT);&#xA;   digitalWrite (mostureSensorVCC, HIGH); //VCC to sensor   &#xA;   pinMode(mostureSensor1, INPUT);      //moisture sensor on&#xA;   delay(10); &#xA;   int sensorValue1 = analogRead(mostureSensor1); // read the input on analog pin &#xA;   Serial.print(&quot;Current Value Sensor 1 is : &quot;); // debugging&#xA;   Serial.println(sensorValue1); // print out the value you read:  &#xA;   msg[0] = sensorValue1;&#xA;    digitalWrite(mostureSensor1, LOW);&#xA;    digitalWrite(mostureSensorVCC, LOW);    &#xA;      while (message != sensorValue1)&#xA;        { &#xA;&#xA;          Serial.print(&quot;sensorValue in while loop is &quot;); // debugging&#xA;          Serial.println(sensorValue1);                   // debugging&#xA;          Serial.print(&quot;Message One is &quot;);                // debugging&#xA;          Serial.println(message);                        // debugging  &#xA;          radio.powerUp();&#xA;          delay(70);&#xA;&#xA;          radio.stopListening();&#xA;          delay(50);&#xA;          radio.write(msg, 2);&#xA;          delay(40);&#xA;          radio.startListening();&#xA;          delay(50);&#xA;&#xA;         Serial.println(d);               // debugging&#xA;&#xA;&#xA;          if (radio.available())&#xA;            {   &#xA;             Serial.println(&quot;Radio available&quot;);     // debugging&#xA;              radio.read(msg, sizeof(msg));&#xA;              message = msg[0];&#xA;              Serial.print(&quot;Check Message received from master &quot;);// debugging&#xA;              Serial.println(message);&#xA;&#xA;            }&#xA;            if(d&amp;gt;=10)&#xA;            {&#xA;              Serial.println(&quot;Unable to send to master&quot;);&#xA;              break;&#xA;            }&#xA;       d++;   &#xA;  }&#xA;&#xA;delay(1000);       &#xA;radio.powerDown();&#xA;message = 0; &#xA;msg[0] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19369" LastEditorUserId="4131" LastEditDate="2016-03-27T19:56:07.367" LastActivityDate="2016-03-27T19:56:07.367" Title="What are ideal delay times between commands for RF24 lib" Tags="|sensors|nrf24l01+|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21927" PostTypeId="2" ParentId="21910" CreationDate="2016-03-18T08:34:41.860" Score="1" Body="&lt;p&gt;Your problem here is that you have an array of 10 bytes, which works fine, only that in your loop you don't stop or check that you are within that array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is supposed to run forever, you could add a line like this at the end of your loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (thisStep &amp;gt; sizeof(orders)-1) thisStep = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(-1 because you have an array of 10, which are from 0-9, sizeof will return 10)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this will make it start from the beginning again.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-18T08:34:41.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21929" PostTypeId="2" ParentId="21911" CreationDate="2016-03-18T09:11:13.910" Score="1" Body="&lt;p&gt;You could use ESP8266 and &lt;a href=&quot;https://github.com/jeelabs/esp-link&quot; rel=&quot;nofollow&quot;&gt;ESP-LINK&lt;/a&gt; firmware to update the arduino firmware over the wire. Its also enables you to debug it wirelessly. What it does is provide a serial link but over wifi. Just like connecting it via cable. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-03-18T09:11:13.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21930" PostTypeId="2" ParentId="9882" CreationDate="2016-03-18T09:30:11.857" Score="1" Body="&lt;p&gt;First you have to grant permission to the user!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Type the query in MySQL like:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GRANT ALL ON test_arduino.* TO root@'192.168.0.102' IDENTIFIED BY 'fifa2005';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19377" LastEditorUserId="2944" LastEditDate="2016-03-18T18:15:17.743" LastActivityDate="2016-03-18T18:15:17.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21931" PostTypeId="1" AcceptedAnswerId="21935" CreationDate="2016-03-18T12:03:42.997" Score="0" ViewCount="2171" Body="&lt;p&gt;I am using the FastLED library in my program and the basic usage is that the following lines go at the top of the main sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS 60&#xA;#define DATA_PIN 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see the documentation at &lt;a href=&quot;https://github.com/FastLED/FastLED/wiki/Basic-usage&quot; rel=&quot;nofollow&quot;&gt;https://github.com/FastLED/FastLED/wiki/Basic-usage&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I am using the FastLED library in several different objects in my program and I would like to be able to reference NUM_LEDS in different header files for each object so that the number of LEDS can be controlled just by changing the value in the main sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also intending that my own objects can be made into libraries for others to use, so they will then define the settings in their main sketch, that my libraries will then use.&lt;/p&gt;&#xA;" OwnerUserId="19361" LastEditorUserId="19361" LastEditDate="2016-03-18T12:37:00.447" LastActivityDate="2016-03-18T15:31:10.567" Title="Using #define and multiple classes" Tags="|library|class|rgb-led|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="21932" PostTypeId="1" CreationDate="2016-03-18T13:26:29.647" Score="1" ViewCount="878" Body="&lt;p&gt;As already mentioned in &lt;a href=&quot;https://arduino.stackexchange.com/questions/15834/how-to-interconnect-multiple-arduinos-with-a-rpi-to-control-home-lights-switches&quot;&gt;another question&lt;/a&gt;, I'm spending &lt;strong&gt;LOT&lt;/strong&gt; of time planning the home-automation system for my new house (currently still in the &quot;still building&quot; phase).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if started only as a &quot;lights/switch management project&quot;, things started getting bigger and bigger and, at the moment, in addition to original requirements, I &lt;strong&gt;already&lt;/strong&gt; have:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A &lt;a href=&quot;https://arduino.stackexchange.com/questions/20666/tamper-circuit-of-a-reed-switch-can-i-connect-the-two-wires-to-an-input-and-a&quot;&gt;reed switch including cut-detection wires&lt;/a&gt; (for a total of 4 wires)  installed on every single window (one switch for single-windows; two switches for dual-door windows);&lt;/li&gt;&#xA;&lt;li&gt;planned the location of a DHT22 sensor in each room.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In addition to the above, I'm currently evaluating the opportunity to add a single &lt;strong&gt;RGB led to have visual-feedback for each push-button&lt;/strong&gt; (something like: GREEN=&gt;LIGHT/OFF; RED=&gt;LIGHT/ON). More specifically, I'm evaluating the opportunity to replace common/simple pushbuttons with these:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hw62i.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hw62i.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, such a change will &lt;strong&gt;heavily&lt;/strong&gt; impact the cabling, as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;original simple/pushbutton required &lt;strong&gt;only two wires&lt;/strong&gt; for each pushbutton, with one wire potentially shareable among adiacent pushbuttons (I'll be using &quot;internal pullups&quot;, so one wire will be GND)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;RGB pushbuttons require &lt;strong&gt;six&lt;/strong&gt; wires (GND and SIGNAL for pushbutton; R, G and B plus COMMON for LED), with only two wires potentially shareable among adjacent pushbuttons (GND and COMMON).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Adding to this that it will be easy to have wall-boxes hosting two, three or even four pushbuttons, and you easily understand that &lt;strong&gt;LOTS&lt;/strong&gt; of cables are required!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here below I'm attaching a rough schema of what I'm planning to build, in terms of hardware:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UHzVq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UHzVq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;where you can see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;ROOM 1, with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 x reed switch (up to 8 wires);&lt;/li&gt;&#xA;&lt;li&gt;1 x DHT22 (3 wires);&lt;/li&gt;&#xA;&lt;li&gt;a wall box with two pushbuttons/wLED (up to 12 wires);&lt;/li&gt;&#xA;&lt;li&gt;a wall box with one pushbutton/wLED (up to 6 wires)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ROOM 2, with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 x reed switch (4 wires);&lt;/li&gt;&#xA;&lt;li&gt;1 x DHT22 (3 wires)&lt;/li&gt;&#xA;&lt;li&gt;a wall box with two pushbuttons/wLED (up to 12 wires)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, as for &quot;controlling&quot; the whole system:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;two POWER-BOXES, located externally to rooms, where I originally planned to host the &quot;controller&quot; (a MEGA2560) together with needed Relay-modules, and interconnected via an RS-485 bus.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(BTW: actually, I'll have three POWER-BOXES, and not only TWO. But this is a detail, as for the spirit of this question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that POWER-BOXES (PB1 and PB2) will be located (...as for the original plan) quite &lt;strong&gt;FAR&lt;/strong&gt; from some rooms: up to 10/15 meters, in the worst case scenario. Also, please note that each power-boxes are far up to 10/15 meters from each-others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before the real question, let me add another couple of important points:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Even tough I know that some kind of wireless system and/or wireless segment could simplify my overall architecture, I'm a strongly believer that a &quot;wired&quot; system is more reliable than a &quot;wireless&quot; one, expecially in the long-term. As such, as I'm lucky enough to put down &lt;strong&gt;lots&lt;/strong&gt; of &quot;pipes&quot; (to properly distribute cables all around the house), I really prefer a wholly wired system;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As for this question, I'm &lt;strong&gt;not&lt;/strong&gt; interested in the &quot;software&quot; side of the system. This is really an accessory (again, as for this very question). My &lt;strong&gt;really_big_problem&lt;/strong&gt; relates to the &quot;hardware&quot; infrastructure to put in place. That's why I'm posting this question here.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;After the all of this, here is the question: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your experience and knowledge:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;should I stick to original plan, having an RS-485 multidrop-bus interconnecting only the MEGAs, with &quot;signal&quot; cables going directly from room-hardware (pushbuttons, reeds, DHT22, etc.) to the MEGA PINs ....&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;should I add some other Arduinos (a Micro seems a really good candidates) in &lt;strong&gt;each room&lt;/strong&gt;, terminating all the signal-room-cables coming from room-hardware, and speaking with MEGAs via the same RS-485 bus?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In the first case, I'll have a real simple RS-485 bus with a mess of cables; In the second case I'll have a _longer_and_more_complex_ RS-485 bus, with a much manageable network cabling/infrastructure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I right? What are the PROs and the CONSs of above two scenarios? Should I investigate &lt;strong&gt;other&lt;/strong&gt; approaches?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there some documentation that can help me picking the right solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Thanks in advance to all of those who will spend some (precious) time helping me in this really difficult decision to take!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW: if you need further details, please don't hesitate to ask.&lt;/p&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-21T22:24:13.240" Title="Hardware network-infrastructure for a fully-arduino-based home-automation project" Tags="|arduino-micro|networking|arduino-pro-micro|rs485|home-automation|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21933" PostTypeId="2" ParentId="21920" CreationDate="2016-03-18T13:40:53.143" Score="1" Body="&lt;p&gt;No it shouldn't matter that you are using separate LEDs, but you will have to connect them in a way that is acceptable to the 7219, they will have to share either a common anode or cathode (can't remember which of the top of my head).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find its always best to check the basics (Based on personal experience)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Have you got the LEDs the correct way around?&lt;/li&gt;&#xA;&lt;li&gt;Are you using the correct voltage for everything?&lt;/li&gt;&#xA;&lt;li&gt;Do the LEDs work when controlled directly by the Arduino, try &quot;Blink&quot;?&lt;/li&gt;&#xA;&lt;li&gt;Have you tried changing the intensity?&lt;/li&gt;&#xA;&lt;li&gt;Have you got the required resistors in?&lt;/li&gt;&#xA;&lt;li&gt;Try inverting the index of the LEDs, i.e. led(x=0,y=0) might be wired (x=7,y=7)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You loop() is not pausing, so all it is going to be doing is calling that one statement repeatedly.  Now that might not be a problem or the second call may be blocking the first from completing.  So I suggest add a delay for a second or so and see if that changes anything.  Also to prove you are running you Loop() code flash the LED on the board (pin13?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-03-18T13:40:53.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21934" PostTypeId="1" AcceptedAnswerId="21945" CreationDate="2016-03-18T15:24:05.250" Score="2" ViewCount="40557" Body="&lt;p&gt;I am trying to set the status of an object from a private enum and I'm not sure how to get the private member to the public version in the constructor, and I'm pretty sure I should not be using &lt;code&gt;byte&lt;/code&gt; in the constructor when it's an enum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm not sure if I should even have the values of the enum inside the header at all. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CandleRack&#xA;{&#xA;  public:&#xA;&#xA;    CandleRack(byte candleRackStatus);&#xA;    ~CandleRack();&#xA;    void begin();&#xA;    void pushButton();&#xA;    void selectRandomCandle();&#xA;    void turnOnCandle(byte candlePosition);&#xA;    void burnCandlesForMs();&#xA;    void fadeOutCandle(byte candlePosition);&#xA;&#xA;&#xA;  private:&#xA;    Bounce *_debouncePushButton;&#xA;    byte _pushButtonPin; &#xA;    enum _candleRackStatus&#xA;    {&#xA;      inactive = 0,&#xA;      candlesOn = 1,&#xA;      rewardAnimation = 2,&#xA;      tweetArrived = 3,&#xA;      partyMode = 4,      &#xA;    };&#xA;    byte _candlePosition;&#xA;    byte _candleStatus[NUM_LEDS];&#xA;    elapsedMillis _candleTimeElapsed[NUM_LEDS];&#xA;    unsigned int _candleOnForMs;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack::CandleRack(byte candleRackStatus)&#xA;{&#xA;  _candleRackStatus = candleRackStatus;&#xA;  _debouncePushButton = NULL;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack MyCandleRack(0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: expected unqualified-id before '=' token&#xA;_candleRackStatus = candleRackStatus;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19361" LastActivityDate="2016-03-19T13:00:21.530" Title="How do I correctly use enum within a class?" Tags="|variables|class|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21935" PostTypeId="2" ParentId="21931" CreationDate="2016-03-18T15:31:10.567" Score="1" Body="&lt;p&gt;As the OP suggested, I'm posting a summing up of the comments under his question since the answer was found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to make a common define for those parameters in different source files, the easiest solution is to make a shared header. To do this, just create a new file called &lt;code&gt;FastLedInclude.h&lt;/code&gt; and, inside of that, write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FastLED.h&amp;gt;&#xA;#define NUM_LEDS 60&#xA;#define DATA_PIN 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in every source file you will just have to &lt;code&gt;#include &quot;FastLedInclude.h&quot;&lt;/code&gt; to be able to use that library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FastLED library also requires the programmer to create a struct. Now, placing the definition of the struct (i.e. &lt;code&gt;struct CRGB leds[NUM_LEDS];&lt;/code&gt;) into the header file leads to compilation errors, since the compiler writes the code to allocate it once for every object file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to share this among different object files is to declare it &lt;code&gt;extern&lt;/code&gt; in the header, then define it just once in one of the cpp or ino files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// into FastLedInclude.h&#xA;extern struct CRGB leds[];&#xA;&#xA;// into any cpp or ino file (but just once)&#xA;struct CRGB leds[NUM_LEDS];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can also be done in the main ino sketch file, but personally I prefer to define it into another one (it depends, however, on how you choose to divide the program).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to create a library, some other problems arise. The easiest solution is to ask the user to manually modify the header file which will be in the library folder. This solution is a bit uncomfortable, but it is the safest one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another solution is to force the user to create a header file into the sketch folder. Then the library should know the sketch folder path to back-include it. But.. This is a very discouraged option, since it will require the library to know the sketch location, thus violating the consistency principle at the base of a library-based approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third solution is to modify the approach, from a compile-time static definition to a dynamic one. In order to do this, instead of defining &lt;code&gt;NUM_LEDS&lt;/code&gt; and &lt;code&gt;DATA_PIN&lt;/code&gt; at compile time you save them as variables in the library class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, in your library class definition you have&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class yourclass&#xA;{&#xA;    public:&#xA;        yourclass(uint8_t data_pin, uint8_t num_leds);&#xA;        ~yourclass();&#xA;    private:&#xA;        uint8_t _data_pin;&#xA;        uint8_t _num_leds;&#xA;        struct CRGB *leds = NULL;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the implementation can be&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yourclass::yourclass(uint8_t data_pin, uint8_t num_leds)&#xA;{&#xA;    _data_pin = data_pin;&#xA;    _num_leds = num_leds;&#xA;&#xA;    // Dynamic allocation of the array&#xA;    leds = (struct CRGB *) malloc(num_leds * sizeof(struct CRGB));&#xA;}&#xA;&#xA;yourclass::~yourclass()&#xA;{&#xA;    // you should free the leds array when done&#xA;    free(leds);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the user can write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yourclass *obj = new yourclass(6, 60);&#xA;&#xA;// or, if he wants to define,&#xA;#define NUM_LEDS 60&#xA;#define DATA_PIN 6&#xA;...&#xA;yourclass *obj = new yourclass(DATA_PIN, NUM_LEDS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or, in the case of a statically allocated object, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;yourclass obj(6, 60);&#xA;&#xA;// or, if he wants to define,&#xA;#define NUM_LEDS 60&#xA;#define DATA_PIN 6&#xA;...&#xA;yourclass obj(DATA_PIN, NUM_LEDS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-18T15:31:10.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21936" PostTypeId="1" CreationDate="2016-03-18T16:21:16.087" Score="2" ViewCount="568" Body="&lt;p&gt;The Adafruit board connects fine over USB serial, and fine over Bluetooth to a mobile app, but it will not connect to a Mac serial monitor over Bluetooth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to use the Adafruit's Bluetooth chip as a pass-through, to allow serial communication over Bluetooth from the Mac to the board itself? &lt;/p&gt;&#xA;" OwnerUserId="19383" LastEditorUserId="6936" LastEditDate="2016-03-31T13:40:51.917" LastActivityDate="2016-03-31T13:40:51.917" Title="Connecting Mac to Adafruit Feather 32u4 Bluefruit LE over serial" Tags="|serial|bluetooth|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21937" PostTypeId="2" ParentId="21924" CreationDate="2016-03-18T16:28:56.173" Score="1" Body="&lt;p&gt;Remove all delays except the one after startListening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could replace it with a &quot;wait for radio.available to be true OR 50ms to have passed&quot; piece of code. There is no need to wait for 50ms if the message was already received after e.g. 10ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better would be to use the ACK-package feature of the NRF. With this feature the master already prepares a package for the slave. Then when the slave sends it's message (every hour), the prepared package is included in the ACK (acknowledgement) packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to optimizing it even further. It would be better to optimize the sleep code, then the send code. The sleep part will still use more power in an hour than the sending code, even if it takes 10 second to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the lost packages. Try using a different channel. You also might want to get an NRF module with an real antenna, and maybe even an amplifier, for the master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS You can remove the serial.print in the deployed version.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-18T16:28:56.173" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21939" PostTypeId="1" AcceptedAnswerId="21941" CreationDate="2016-03-18T16:50:20.997" Score="1" ViewCount="1259" Body="&lt;p&gt;I am thinking about buying Arduino or Raspberry Pi.  I generally know Arduino advantages (fast start-up, low consumption, ADC converters) and disadvantages (low memory, low connectivity, hard programming), but I simply cannot figure out maybe the most important issue: current output for controlling devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the common cited advantages of Arduino system compared to Raspberry Pi system is that power per I/O pin is much larger.  Arduino Uno allegedly has up to 20 mA @ 5 V per pin and 50 mA @ 3.3 V per pin making quite substantial power of 0.15 W, compared to say typical 10 mA @ 5 V per pin for Raspberry Pi (although there is no official number available).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;this power is far too low to control any motors and you still have to&#xA;provide shields,&lt;/li&gt;&#xA;&lt;li&gt;new version Arduino 101 reduced that current to 20 mA and even less for some other Arduino models.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, what is really the importance (if any) of these higher currents for home projects, compared between different Arduinos themselves and compared to Raspberry Pi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a question of total current for all pins together, which is also limited, but it is soooooo difficult to get official limits (for both Arduino and Raspberry Pi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please give me some insight into this issue, so I can decide.&lt;/p&gt;&#xA;" OwnerUserId="19384" LastEditorUserId="19384" LastEditDate="2016-03-20T08:48:43.187" LastActivityDate="2016-03-20T08:48:43.187" Title="The importance of I/O pin DC current" Tags="|current|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21940" PostTypeId="1" AcceptedAnswerId="21942" CreationDate="2016-03-18T17:05:07.300" Score="0" ViewCount="40" Body="&lt;p&gt;I've worked with a few different GPS modules. Most of them seem to just pump out data and not really interact with the micro controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a quadcopter (Cheerson CX 20 Big Sky) It has a gps break out board that looks similar to the one I've worked with before. Is it likely that I connect another micro controller to this board? I want to add a cellular module to my quad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the answer may be &quot;it depends&quot; but before I start testing and researching I just want to know if it's even likely to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the gps is just barfing out coordinates and not interacting with the main board I think it could work. I could just tap in and &quot;listen&quot; -- is this even a possibility?&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2016-03-18T17:15:39.107" Title="Can I hook up two micros to one GPS module?" Tags="|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21941" PostTypeId="2" ParentId="21939" CreationDate="2016-03-18T17:11:15.170" Score="3" Body="&lt;p&gt;The simple answer is: &lt;strong&gt;It doesn't matter.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both Arduino and the Raspberry Pi, and every other common microcontroller board, are designed to control things, not provide power to things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital IO pins aren't designed to drive heavy loads. Yes, some (like the Arduino) can provide slightly more current, but that is really unimportant for most projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, some boards have more powerful power supply circuits on them so you can draw more current from their power supplies, but again that is largely irrelevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one thing that you seem to be forgetting (or haven't realised) is that &lt;em&gt;the microcontroller board does not have to supply &lt;strong&gt;all&lt;/strong&gt; the power.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino, Pi, Teensy, chipKIT, whatever, is merely a controller. If your system needs more current it is up to you to provide that current. The Arduino etc merely controls the circuit or device that it is connected to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is very common to have multiple power supplies in a large project - each providing different voltages, or being used for different specific tasks within the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just one thing you need to remember: &lt;strong&gt;Connect the grounds.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-18T17:11:15.170" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="21942" PostTypeId="2" ParentId="21940" CreationDate="2016-03-18T17:15:39.107" Score="2" Body="&lt;p&gt;You are quite wrong. The answer is not &quot;it depends&quot;, but &quot;yes&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have any number of devices listening to (receiving) the transmitted data. You can only have one device sending anything back to whatever it is that is broadcasting the data if you need to configure it in any way. That shouldn't be a problem of course if you have one main controller that does that configuration and everything else is just a passive listener.  Just be sure that you don't connect the transmit pins of the passive listeners to anything (unless you want to use them for a completely unrelated purpose to transmit serial data to something else).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only caveat is that each device you add as a listener will increase the load on the GPS's transmit pin and eventually the &lt;em&gt;slew rate&lt;/em&gt; will become too slow and the signal will become distorted. If this ever becomes an issue reducing the baud rate can combat it to a certain extent. For serial though you would need quite a lot of devices for it to become an issue. Two devices certainly won't ever be an issue.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-18T17:15:39.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21943" PostTypeId="2" ParentId="21939" CreationDate="2016-03-18T17:17:42.017" Score="3" Body="&lt;p&gt;Bottom line is: the controllers are just not meant for supplying power. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They do have the ability to do so, within limits - fairly stringent limits for a controller chip itself, and &lt;em&gt;slightly&lt;/em&gt; more generous limits for the on-board power supply. If you really need an all-in-one, you might consider making building your own controller board with a more capable on-board power supply and a number of transistor switches to provide power for the hungrier devices, that can be switched by the MCU chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this will not improve the chip's ability to supply power - you can't, by any practical means - but the board can, through the switching transistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Figure out your project's power budget, or the budget you'd like to have for your future projects, and design an on-board power supply to exceed that by a healthy margin-of-safety. Likewise, for the individual switched circuits, in order to choose a sufficiently robust switching transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you prefer an off-the-shelf solution, one of the available motor-driver boards is probably a good choice but it will need to have an independent power supply if there isn't one on the driver board.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-18T17:17:42.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21944" PostTypeId="1" CreationDate="2016-03-18T18:04:39.410" Score="1" ViewCount="779" Body="&lt;p&gt;I've got an Arduino Uno, SIM900 GPRS, and the Adafruit Breakout GPS.&lt;/p&gt;&#xA;&lt;p&gt;Can this code be optimized?&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA; #include &amp;lt;TinyGPS++.h&amp;gt;&#xA; #include &amp;lt;Ubidots_Arduino_GPRS.h&amp;gt;&#xA; //Serial Relay - Arduino will patch a &#xA; //serial link between the computer and the GPRS Shield&#xA; //at 19200 bps 8-N-1&#xA; //Computer is connected to Hardware UART&#xA; //GPRS Shield is connected to the Software UART &#xA; #define APN &amp;quot;myapn&amp;quot; &#xA; #define USER &amp;quot;&amp;quot;  // If your apn doesnt have username just put &amp;quot;&amp;quot;&#xA; #define PASS &amp;quot;&amp;quot;  // If your apn doesnt have password just put &amp;quot;&amp;quot;&#xA; #define TOKEN &amp;quot;ubidotsToken&amp;quot;  // Replace it with your Ubidots token&#xA; #define ID &amp;quot;Your_id_here&amp;quot; // Replace it with your Ubidots' variable ID&#xA; // You can send 1 to 10 variable at the same time&#xA; #define ID1 &amp;quot;idHere&amp;quot; // Replace it with your variable ID&#xA; //#define ID2 &amp;quot;&amp;quot; // Replace it with your variable ID&#xA; //#define ID3 &amp;quot;Your_id_here&amp;quot; // Replace it with your variable ID&#xA; &#xA; TinyGPSPlus gps; // The TinyGPS++ object for interfacing with the GPS&#xA; //Declare indexes, and strings&#xA; char latitude[12];&#xA; char longitude[12];&#xA; float value_1 = 1;&#xA; char var[18] = &amp;quot;Lat: &amp;quot;;&#xA; char var2[18] = &amp;quot;Long: &amp;quot;;&#xA; Ubidots client(TOKEN);  &#xA; SoftwareSerial ss(2,3);&#xA; void setup() {&#xA;    &#xA; // the Serial port of Arduino baud rate.&#xA;   Serial.begin(9600);               &#xA;      &#xA;   client.powerUpOrDown();&#xA;   client.setApn(APN,USER,PASS);&#xA; //.endC is for _client.end() in Ubidots_GPRS.cpp&#xA;   client.endC();&#xA;   ss.begin(9600);&#xA; }&#xA;   &#xA; void loop() {&#xA;      &#xA;   //handling GPS data parsing&#xA;   while (ss.available() &amp;gt; 0) {&#xA;     gps.encode(ss.read());}&#xA;   //Once a valid location comes up it updates Lat/Long variables&#xA;    if (gps.location.isUpdated())&#xA; {&#xA;     strcpy(var, &amp;quot;Lat: &amp;quot;);&#xA;     strcpy(var2,&amp;quot;Long: &amp;quot;);&#xA;     &#xA;     dtostrf(gps.location.lat(),10,6,latitude);&#xA;     strcat(var, latitude);&#xA;        &#xA;     dtostrf(gps.location.lng(),10,6,longitude);&#xA;     strcat(var2, longitude);&#xA;   //Added ss.flush();&#xA;     ss.flush();&#xA;     ss.end();&#xA;     Serial.flush()&#xA;   //Added client.beginC() for _client.begin(9600) is Ubidots_GPRS.cpp&#xA;     client.beginC();&#xA;     client.add(ID1, value_1, var, var2);&#xA;     client.sendAll();&#xA;     client.endC();&#xA;     ss.begin(9600);&#xA;   }&#xA;  Serial.println(var);&#xA;  Serial.println(var2);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;From this &lt;a href=&quot;https://stackoverflow.com/questions/17985830/arduino-using-interrupts-freezes-processing-and-serial-output&quot;&gt;link&lt;/a&gt;, I moved the &lt;strong&gt;println&lt;/strong&gt; from inside &lt;strong&gt;.isUpdated()&lt;/strong&gt; to outside the if statement. I was able to get GPS data sent from the unit to my Ubidots account while driving around town. Afterwards I was able to input the data into Google Maps and the route produced was accurate. Do I need flush()?&lt;/p&gt;&#xA;" OwnerUserId="18800" LastEditorUserId="90731" LastEditDate="2024-01-12T18:00:53.710" LastActivityDate="2024-02-11T18:07:25.973" Title="Code problem w/ Uno+GPS+GPRS?" Tags="|gps|tinygps|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="21945" PostTypeId="2" ParentId="21934" CreationDate="2016-03-18T18:28:46.763" Score="4" Body="&lt;p&gt;I see two separate issues here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all your enum isn't available as a variable. &#xA;By declaring it as a private type within your class the enum can't be used outside of that class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This forces a user of that class to handle unintended calls like (attention, &lt;em&gt;bug&lt;/em&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack(255);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which can make code harder to read (and debugging more difficult, since it wouldn't be detected by the compiler).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second of all you try to directly assign a byte &lt;em&gt;value&lt;/em&gt; to an enum &lt;em&gt;type&lt;/em&gt;. This will be rejected by the compiler and/or cause runtime errors later (depending on compiler settings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend that you declare the enum type so that it is accessible directly via the header file:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum CandleRackStatus {&#xA;    inactive = 0,&#xA;    candlesOn = 1,&#xA;    rewardAnimation = 2,&#xA;    tweetArrived = 3,&#xA;    partyMode = 4,      &#xA;};&#xA;&#xA;class CandleRack&#xA;{&#xA;  public:&#xA;&#xA;    CandleRack(CandleRackStatus candleRackStatus);&#xA;    ~CandleRack();&#xA;    void begin();&#xA;    void pushButton();&#xA;    void selectRandomCandle();&#xA;    void turnOnCandle(byte candlePosition);&#xA;    void burnCandlesForMs();&#xA;    void fadeOutCandle(byte candlePosition);&#xA;&#xA;  private:&#xA;    Bounce *_debouncePushButton;&#xA;    CandleRackStatus _candleRackStatus;&#xA;    byte _pushButtonPin; &#xA;    byte _candlePosition;&#xA;    byte _candleStatus[NUM_LEDS];&#xA;    elapsedMillis _candleTimeElapsed[NUM_LEDS];&#xA;    unsigned int _candleOnForMs;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can instantiate your class while using the correct enum type as the parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack MyCandleRack(CandleRackStatus::inactive);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Within your implementation you can now directly store the constructor parameter in the private variable, the compiler will make sure it's always of the correct enum type:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack::CandleRack(CandleRackStatus candleRackStatus) {&#xA;    _candleRackStatus = candleRackStatus;&#xA;    // rest of your initialisiation goes here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As an added bonus, there's the possibility to use a couple of C++ language features that will make your implementation easier:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Default_argument#Default_arguments_in_C.2B.2B&quot; rel=&quot;nofollow&quot;&gt;a default parameter value&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Initialization_(programming)#Initializer_list&quot; rel=&quot;nofollow&quot;&gt;an initializer (list)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class &#xA;{&#xA;  public:&#xA;    CandleRack(CandleRackStatus candleRackStatus = CandleRackStatus::inactive);&#xA;    // [...]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack::CandleRack(CandleRackStatus candleRackStatus) : _candleRackStatus(candleRackStatus) {&#xA;    // rest of your initializiation goes here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-19T13:00:21.530" LastActivityDate="2016-03-19T13:00:21.530" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21946" PostTypeId="2" ParentId="21309" CreationDate="2016-03-18T18:54:42.573" Score="2" Body="&lt;p&gt;You have to rebuild &lt;code&gt;sys-libs/ncurses&lt;/code&gt; with &lt;code&gt;tinfo&lt;/code&gt; USE flag turned on. (You can also make a symlink: &lt;code&gt;libtinfo.so -&amp;gt; libncurses.so&lt;/code&gt;, but it's not elegant solution).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, check if you have a record for ncurses in any file in &lt;code&gt;/etc/portage/package.use&lt;/code&gt;. If not, create a file &lt;code&gt;/etc/portage/package.use/ncurses&lt;/code&gt; with such content:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sys-libs/ncurses tinfo&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then, rebuild ncurses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;emerge -av sys-libs/ncurses&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19386" LastActivityDate="2016-03-18T18:54:42.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21947" PostTypeId="2" ParentId="21934" CreationDate="2016-03-18T19:53:22.097" Score="0" Body="&lt;p&gt;How about this refactoring?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CandleRack&#xA;{&#xA;  public:&#xA;    enum status_t&#xA;    {&#xA;      inactive = 0,&#xA;      candlesOn = 1,&#xA;      rewardAnimation = 2,&#xA;      tweetArrived = 3,&#xA;      partyMode = 4,      &#xA;    };    &#xA;    CandleRack(status_t status = inactive);&#xA;    ~CandleRack();&#xA;    void begin();&#xA;    void pushButton();&#xA;    void selectRandomCandle();&#xA;    void turnOnCandle(byte candlePosition);&#xA;    void burnCandlesForMs();&#xA;    void fadeOutCandle(byte candlePosition);&#xA;&#xA;  private:&#xA;    Bounce *_debouncePushButton;&#xA;    byte _pushButtonPin;&#xA;    status_t _candleRackStatus;&#xA;    byte _candlePosition;&#xA;    byte _candleStatus[NUM_LEDS];&#xA;    elapsedMillis _candleTimeElapsed[NUM_LEDS];&#xA;    unsigned int _candleOnForMs;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in a sketch with either the default setting (inactive)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack MyCandleRack;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or explicit&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CandleRack MyCandleRack(CandleRack::candlesOn);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-03-19T10:46:41.503" LastActivityDate="2016-03-19T10:46:41.503" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="21948" PostTypeId="1" AcceptedAnswerId="22249" CreationDate="2016-03-18T20:05:29.873" Score="9" ViewCount="41380" Body="&lt;p&gt;In Fast.Led lib for arduino there is a code to turn off all leds&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FastLED.clear ();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there also a shortcut to turn all LEDs ON, and with a specific color&lt;/p&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="25788" LastEditDate="2016-09-18T14:10:47.693" LastActivityDate="2016-09-18T14:10:47.693" Title="Turning all LEDs on (FAST.LED)" Tags="|arduino-nano|adafruit|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21949" PostTypeId="1" AcceptedAnswerId="21950" CreationDate="2016-03-18T20:26:54.653" Score="0" ViewCount="4932" Body="&lt;p&gt;I have a &lt;code&gt;for&lt;/code&gt; loop inside my &lt;code&gt;void loop()&lt;/code&gt; that triggers a piezo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to happen is when I press a button, it breaks the loop of the piezo, but right now, it's as if it isn't detecting the button press inside my &lt;code&gt;for&lt;/code&gt; loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;#define PIN 6&#xA;#define TONE 8&#xA;const int buttonPin = 2;&#xA;&#xA;long fadeTime = 5 * 1000L; // X minutes&#xA;int colorStops = 256;&#xA;int delaySpeed = fadeTime / colorStops;&#xA;int notes[] = {262,294,330,349};&#xA;int switchState = 0;         // variable for reading the pushbutton status&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, PIN, NEO_RGB);&#xA;&#xA;void setup() {&#xA;  pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input&#xA;&#xA;  strip.begin();&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the pushbutton value:&#xA;  switchState = digitalRead(buttonPin);&#xA;&#xA;  // Fade in light&#xA;  for(int i = 1; i&amp;lt;colorStops; i++){&#xA;    for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;      strip.setPixelColor(np, strip.Color(i,i,0));&#xA;    }&#xA;    strip.show();&#xA;    delay(delaySpeed);&#xA;  }&#xA;&#xA;  // Play tone after light fully bright&#xA;  for(int i = 1; i&amp;lt;100; i++){&#xA;    // Turn off tone on button press&#xA;    if (switchState == HIGH) {&#xA;      noTone(TONE);&#xA;      break;&#xA;    }&#xA;    tone(TONE, notes[random(0,3)]);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does &lt;code&gt;switchState = digitalRead(buttonPin);&lt;/code&gt; only get called at the start of the &lt;code&gt;void loop&lt;/code&gt; and so it can't detect the button change until then? Something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, in case it's useful, here's my hardware set up...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OGZNe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OGZNe.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-03-18T20:31:11.183" LastActivityDate="2016-03-18T20:53:36.170" Title="How to get a button state change within a for loop?" Tags="|arduino-uno|button|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21950" PostTypeId="2" ParentId="21949" CreationDate="2016-03-18T20:53:36.170" Score="1" Body="&lt;p&gt;You aren't reading the state of the button within your loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only read it the once at the top of your &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // read the state of the pushbutton value:&#xA;  switchState = digitalRead(buttonPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to replicate that every time you want a new reading from the button - so in your loop you need to add that &lt;code&gt;digitalRead&lt;/code&gt; line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Play tone after light fully bright&#xA;for(int i = 1; i&amp;lt;100; i++){&#xA;  // Turn off tone on button press&#xA;  switchState = digitalRead(buttonPin);&#xA;  if (switchState == HIGH) {&#xA;    noTone(TONE);&#xA;    break;&#xA;  }&#xA;  tone(TONE, notes[random(0,3)]);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you can do away with the variable altogether and just test the return value of the &lt;code&gt;digitalRead&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Play tone after light fully bright&#xA;for(int i = 1; i&amp;lt;100; i++){&#xA;  // Turn off tone on button press&#xA;  if (digitalRead(buttonPin) == HIGH) {&#xA;    noTone(TONE);&#xA;    break;&#xA;  }&#xA;  tone(TONE, notes[random(0,3)]);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-18T20:53:36.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21951" PostTypeId="1" AcceptedAnswerId="21953" CreationDate="2016-03-18T22:05:29.390" Score="2" ViewCount="3086" Body="&lt;p&gt;I have 5 of &lt;a href=&quot;https://www.adafruit.com/products/1734&quot; rel=&quot;nofollow noreferrer&quot;&gt;these NeoPixel LED's&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For these particular LED's, they &lt;a href=&quot;https://learn.adafruit.com/adafruit-neopixel-uberguide/individual-neopixels#through-hole-neopixels&quot; rel=&quot;nofollow noreferrer&quot;&gt;recommend&lt;/a&gt; &quot;use of a 0.1 μF capacitor between + and ground&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I've got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FyNpT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FyNpT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blue's are 100 μF and the little brown ones are...I have no idea. Both were just in this starter kit. Maybe 100 pF?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, a few questions around this...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are these actually necessary and why?&lt;/li&gt;&#xA;&lt;li&gt;Is there any harm in using much higher capacitors than recommended?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-19T21:56:39.553" Title="Do I need capacitors for these LEDs?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21952" PostTypeId="2" ParentId="21857" CreationDate="2016-03-18T22:10:18.317" Score="1" Body="&lt;p&gt;The &lt;a href=&quot;https://communities.intel.com/thread/53869?tstart=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;article&lt;/a&gt; link by Nick is the same that I found, so it must be a well search problem.&lt;/p&gt;&#xA;&lt;p&gt;What is described on the Intel forum is that the Galileo is not capable of direct communication with the sensor as it is a computer and not a microcontroller, so therefore lacks the ability for accurate timing required by the sensor and also the DHT* is considered a peripheral and would thus require a way to interface with the &amp;quot;PC&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;What is described in the post is to use two pins to create the proper digital signal for the DHT.&lt;/p&gt;&#xA;&lt;p&gt;The circuit makes use of a diode to protect the output pin.&lt;/p&gt;&#xA;&lt;p&gt;The OP on the forum describes the connections like this:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Pin 2 of Galileo is connected to the data pin of the DHT11.&lt;/p&gt;&#xA;&lt;p&gt;Cathode of the diode is connected to pin 3 of the Galileo.&lt;/p&gt;&#xA;&lt;p&gt;Anode of the diode is connected to the DHT11 data pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The diode would be a standard diode, possibly a fast switching signal diode as the 1N4143. The resistor would be the standard pull up resistor of 10K Ohms.&lt;/p&gt;&#xA;&lt;p&gt;Here is the OPs schematic:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZvYzB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZvYzB.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;https://communities.intel.com/servlet/JiveServlet/downloadImage/2-245223-237707/DHTGal.PNG&quot; rel=&quot;nofollow noreferrer&quot;&gt;intel.com&lt;/a&gt;)&lt;/sub&gt;&lt;/p&gt;&#xA;&lt;p&gt;You will also need to make use of the code linked to by the OP in the linked post as it was modified to work with the workaround.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-03-11T10:51:40.617" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="21953" PostTypeId="2" ParentId="21951" CreationDate="2016-03-18T22:15:55.423" Score="7" Body="&lt;p&gt;The capacitors are called &lt;em&gt;decoupling capacitors&lt;/em&gt; and are used to provide current at very short notice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LEDs, when not fully on or fully off, switch rapidly on and off.  This switching needs current to be provided very rapidly at short notice, and batteries and power supplies aren't good at that - so you have the capacitors to act as a little reservoir of power that the LEDs can dip into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The size of the capacitor (capacitance) can have an effect on how effective they are.  Bigger capacitors respond slower than smaller ones, but store more energy. So you need the capacitor to be small enough for it to respond fast enough. But if you have it too small it won't store enough energy to give to the LEDs and they will be unable to do their job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;0.1µF (or 100nF), aka &quot;104&quot; capacitors are usually reckoned to be a good rule-of-thumb value to use since they are small enough to respond rapidly and yet large enough to store enough power for most small high speed fluctuations.  The exact value though doesn't matter that much, however I would be wary about going below that, and going too high can be troublesome for other reasons as well as their slow response (google: &quot;Inrush Current&quot;). So you don't want to go too high. Around the 0.1µF to 1µF area is where you want to be, with maybe a 10µF for every group of 5 or so LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would say 100µF is way too high to have on every LED, but maybe one of those on the breadboard where the power is fed in would be useful to provide a reservoir for larger low frequency demands from the rest of the board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-18T22:15:55.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21954" PostTypeId="1" CreationDate="2016-03-18T22:54:44.207" Score="1" ViewCount="1945" Body="&lt;p&gt;How can I make LEDs blink randomly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a piece of code, but it is not working for me. I probably need something other than &lt;code&gt;setPixel()&lt;/code&gt;, but I don't know what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/FastLED/FastLED&quot; rel=&quot;nofollow&quot;&gt;Fast.Led library&lt;/a&gt; with Arduino Nano and WS2812B LEDs&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    Twinkle(CRGB::Red, 10, 100, false);&#xA;}&#xA;&#xA;void Twinkle(uint32_t color, uint16_t Count, uint16_t SpeedDelay, boolean OnlyOne) &#xA;{&#xA;    FastLED.setBrightness(MAX_BRIGHTNESS);&#xA;    fill_solid(leds, random(NUM_LEDS), CRGB::White);&#xA;    FastLED.show(); &#xA;    for (int i=0; i &amp;lt; Count; i++) {&#xA;//        setPixel(random(NUM_LEDS),red,green,blue);  //!ORIGINAL LINE OF CODE!&#xA;        setPixel(random(NUM_LEDS), color);  //!MY LINE! &#xA;        FastLED.show();&#xA;        delay(SpeedDelay);&#xA;        if (OnlyOne) {&#xA;            fill_solid(leds, NUM_LEDS, CRGB::Black);&#xA;            FastLED.show();&#xA;        }&#xA;    }&#xA;&#xA;    delay(SpeedDelay);&#xA;    return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8162" LastEditorUserId="6936" LastEditDate="2016-03-19T01:45:16.530" LastActivityDate="2016-03-25T10:09:29.220" Title="Random Blink LEDs" Tags="|arduino-nano|rgb-led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21955" PostTypeId="2" ParentId="21944" CreationDate="2016-03-18T23:10:43.613" Score="0" Body="&lt;p&gt;It seems you're using the same hardware &lt;code&gt;Serial&lt;/code&gt; port for both your PC and the GPS module. This will result in the GPS module receiving everything you send to the PC with &lt;code&gt;Serial.print()&lt;/code&gt; and this may be the cause of your problem, as it could confuse the module and either make it send an endless stream of gibberish and/or making &lt;code&gt;isValid()&lt;/code&gt; to always be false. You should instead create a &lt;code&gt;SoftwareSerial&lt;/code&gt; instance attached to any 2 digital pins (maybe 2 and 3) like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial ss(2, 3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ss.begin(9600);  // use your module baud rate&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then at the top of &lt;code&gt;loop()&lt;/code&gt;, use this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (ss.available() &amp;gt; 0)&#xA;    gps.encode(ss.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get rid of the recursive call of &lt;code&gt;loop()&lt;/code&gt; within &lt;code&gt;loop()&lt;/code&gt; since it will cause your stack to rapidly overflow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want data to only be sent when the location values are &lt;em&gt;updated&lt;/em&gt; based on recent received data (but not necessarily &lt;em&gt;changed&lt;/em&gt;, since you may still be at the same location), you should use &lt;code&gt;if (gps.location.isUpdated())&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your call of &lt;code&gt;dtostrf()&lt;/code&gt; is also wrong. The second argument should be the length of the string to be created (including decimal point) and the 3rd argument should be the number of digits after the decimal point. Something like this should be okay:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;dtostrf(gps.location.lat(), 10, 6, latitude); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can also put this at the end of &lt;code&gt;loop()&lt;/code&gt; to check if data is actually being received from the module and processed by the library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (millis() &amp;gt; 5000 &amp;amp;&amp;amp; gps.charsProcessed() &amp;lt; 10)&#xA;  Serial.println(F(&quot;WARNING: No GPS data.  Check wiring.&quot;));&#xA;  while (1){ // infinite loop&#xA;    if (ss.available())&#xA;      Serial.print(ss.read());&#xA;  }&#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;This site&lt;/a&gt; may provide additional details.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-18T23:10:43.613" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="21958" PostTypeId="2" ParentId="4114" CreationDate="2016-03-19T01:10:34.147" Score="1" Body="&lt;p&gt;The most elegant approach would probably be to use shields controlled by the I2C bus. I've found LCD+keypad and &lt;a href=&quot;https://www.adafruit.com/products/1438&quot; rel=&quot;nofollow&quot;&gt;motor shield&lt;/a&gt; offered by Adafruit for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The I2C bus is shared by all slaves connected to it, and you should find microswitches on each shield to set its I2C address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regular shields should not interfere with I2C lines, so as last resort you can put one shield controlled &quot;traditional way&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19394" LastEditorUserId="19394" LastEditDate="2016-03-27T17:47:50.400" LastActivityDate="2016-03-27T17:47:50.400" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21962" PostTypeId="2" ParentId="12951" CreationDate="2016-03-19T05:58:56.730" Score="0" Body="&lt;p&gt;For the 1M pulldown solution, turning off the internal pullup at the end of the pin check routine MIGHT give enough time for the pin to discharge, and it might not if the code can conditionally do very little else between pin checks.  If you want to leave out the 100 us delay, take care to ensure that your code will always do something that takes sufficient cycles for the pin to discharge between checks.&lt;/p&gt;&#xA;" OwnerUserId="19457" LastActivityDate="2016-03-19T05:58:56.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21963" PostTypeId="2" ParentId="21951" CreationDate="2016-03-19T06:32:34.963" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Are these actually necessary and why?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the WS2812 says a &quot;typical application circuit&quot; should have them:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Fi0O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Fi0O.png&quot; alt=&quot;WS2812 circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the manufacturer recommends it, I would say it is necessary. I'm sure they would be happy to not have to recommend extra parts, but testing would have shown they are necessary. As Majenko replied, putting in 100 µF when you only need 0.1 µF seems way overkill (to say nothing of more expensive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And don't forget the 150R resistors, eh?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-19T06:32:34.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21964" PostTypeId="2" ParentId="21939" CreationDate="2016-03-19T06:48:19.587" Score="3" Body="&lt;p&gt;I bought a Pi a while back, and found it so tedious to use I put it in my parts drawer and haven't used it since. A Pi is like a small Unix PC - you have to install an operating system, boot it up (which takes time) and then install device drivers etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino (particularly the Uno) boots in under a second, and &quot;just works&quot;. It is much easier to use for small to medium projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the current, as others have replied, you aren't supposed to be powering things, like motors, from the output pins. 20 mA is a nice amount of current to flash an LED, or send data to another device. The output pins are for &lt;strong&gt;data&lt;/strong&gt; not for driving things like motors. If you need more than 20 mA you should be looking at driver circuits, like transistors or MOSFETs.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... hard programming ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I wouldn't say that. You program in C++. What are you going to program the Pi in? There are many libraries for the Arduino to simplify programming, but you can get down to the &quot;bare metal&quot; quite simply.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-19T06:48:19.587" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21965" PostTypeId="1" AcceptedAnswerId="21975" CreationDate="2016-03-19T06:52:53.537" Score="1" ViewCount="1765" Body="&lt;p&gt;I am getting a &quot;does not name a type&quot; error when trying to use &lt;code&gt;makeTime()&lt;/code&gt; from the Time.h library, code snippet as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;Time.h&amp;gt;&#xA;&#xA;tmElements_t tmet;&#xA;tmet.Year = 2013-1970;&#xA;tmet.Month = 8;&#xA;tmet.Day = 28;&#xA;tmet.Hour = 18;&#xA;tmet.Minute = 30;&#xA;tmet.Second = 0;&#xA;&#xA;time_t dateMet = makeTime(tmet);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Alternatively I've also tried &lt;code&gt;time_t dateMet = maketime(&amp;amp;tmet);&lt;/code&gt; with the same result. I am no expert so go easy on me but am I missing something small here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="2815" LastActivityDate="2016-03-19T09:29:23.280" Title="Does not name a type error when using makeTime" Tags="|arduino-uno|time|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21967" PostTypeId="1" CreationDate="2016-03-19T07:07:16.967" Score="0" ViewCount="1223" Body="&lt;p&gt;I want to control my Adruino through Internet without Ethernet or wifi shield. So what are the ways I can do?&lt;/p&gt;&#xA;" OwnerUserId="18794" LastActivityDate="2016-03-20T00:37:40.213" Title="How to control Adruino through Internet" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ClosedDate="2016-03-20T09:04:58.660" ContentLicense="CC BY-SA 3.0" />
  <row Id="21968" PostTypeId="2" ParentId="18884" CreationDate="2016-03-19T07:29:17.793" Score="3" Body="&lt;p&gt;The authors of the library are not fans of the &lt;code&gt;setBrightness()&lt;/code&gt; method and advise handling it yourself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code should do what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_DotStar.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;          &#xA;&#xA;#define NUMPIXELS 60 // This should be the total number of LEDs in your strip &#xA;&#xA;#define DATAPIN    4&#xA;#define CLOCKPIN   5&#xA;Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);  &#xA;&#xA;void setup() &#xA;{&#xA;  strip.begin();  &#xA;  strip.show();   &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  // loop through each pixel in the control array setting it to the colour mix you want.  &#xA;  for (int i=0; i &amp;lt;= NUMPIXELS; i=i+1) {&#xA;    strip.setPixelColor(i, 25, 25, 25); // Even 25 on my strip gives reasonably bright flash&#xA;  }&#xA;&#xA;  strip.show(); // Then push the control array to the strip &#xA;  delay(1000); // and leave it set for a while&#xA;&#xA;// Then do it again for the 2nd brightness in your scheme&#xA;&#xA;  // loop through each pixel in the control array setting it to off.  &#xA;  for (int i=0; i &amp;lt;= NUMPIXELS; i=i+1) {&#xA;    strip.setPixelColor(i, 0, 0, 0); &#xA;  }&#xA;&#xA;  strip.show(); // Then push the control array to the strip &#xA;  delay(1000); // and leave it set for a while&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19400" LastEditorUserId="6936" LastEditDate="2016-03-25T11:00:30.443" LastActivityDate="2016-03-25T11:00:30.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21970" PostTypeId="2" ParentId="21967" CreationDate="2016-03-19T08:08:45.803" Score="0" Body="&lt;p&gt;Guess you need to use a pc, and a program to receive commands and send them along to the arduino by serial.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-19T08:08:45.803" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="21975" PostTypeId="2" ParentId="21965" CreationDate="2016-03-19T09:16:43.217" Score="3" Body="&lt;p&gt;You're trying to access the '&lt;em&gt;properties&lt;/em&gt;' (i.e. the &lt;em&gt;members&lt;/em&gt;) of the &lt;code&gt;tmet&lt;/code&gt; variable in a scope where they aren't accessible (outside of a code block). In this global scope of the program the compiler expects a type name on the left side of a statement (i.e. a variable or type declaration), but &lt;code&gt;tmet&lt;/code&gt;'s members like &lt;code&gt;tmet.Year&lt;/code&gt; aren't types in and of themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two solutions. You can move the access to the members of &lt;code&gt;tmet&lt;/code&gt; into a code block like the &lt;code&gt;setup&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Time.h&amp;gt;&#xA;&#xA;tmElements_t tmet;&#xA;time_t dateMet;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;    tmet.Year = 2013-1970;&#xA;    tmet.Month = 8;&#xA;    tmet.Day = 28;&#xA;    tmet.Hour = 18;&#xA;    tmet.Minute = 30;&#xA;    tmet.Second = 0;&#xA;&#xA;    dateMet = makeTime(tmet);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you could declare and define &lt;code&gt;tmet&lt;/code&gt; in one statement, which has a different syntax (since you have to provide the content of a &lt;code&gt;tmElements_t&lt;/code&gt; in a single line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Time.h&amp;gt;&#xA;&#xA;tmElements_t tmet2 = { 2013-1970, 8, 28, 18, 30, 0 };&#xA;&#xA;time_t dateMet2 = makeTime(tmet2);&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both versions work right away from within the Arduino IDE (i.e. I tested them).&lt;/p&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="19016" LastEditDate="2016-03-19T09:29:23.280" LastActivityDate="2016-03-19T09:29:23.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21976" PostTypeId="1" AcceptedAnswerId="22119" CreationDate="2016-03-19T11:14:06.317" Score="0" ViewCount="2904" Body="&lt;p&gt;trying to make a system where one master Arduino makes moving 9 steppers 28BYJ-48 by 3 stepper on each slave arduino.&lt;/p&gt;&#xA;&lt;p&gt;While all the parts on their way to me, wonder to check with professionals.&lt;/p&gt;&#xA;&lt;p&gt;Maybe I've missed something?&lt;/p&gt;&#xA;&lt;p&gt;Any suggestions and tips are welcome.&#xA;Thank you.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ivEra.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ivEra.png&quot; alt=&quot;Sketch&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MmlFP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MmlFP.jpg&quot; alt=&quot;Scheme&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19406" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-22T11:55:52.757" Title="I2C Master-Slave Arduino system to control array of steppers" Tags="|arduino-mega|stepper|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21978" PostTypeId="2" ParentId="19909" CreationDate="2016-03-19T12:47:04.543" Score="1" Body="&lt;p&gt;The code you are using is the example provided with the SimpleModbusMaster library found on GitHub: &lt;a href=&quot;https://github.com/angeloc/simplemodbusng&quot; rel=&quot;nofollow&quot;&gt;https://github.com/angeloc/simplemodbusng&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears that the SimpleModbusMaster library isn't installed. This can happen if you install a new version of the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To install this library:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to the link above and download the zip of the code.&lt;/li&gt;&#xA;&lt;li&gt;Extract the contents and then copy the folder &quot;SimpleModbusMaster&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Paste the folder into the Arduino/libraries folder located on your computer.  (On my computer it is: &lt;code&gt;C:\Program Files (x86)\Arduino\libraries&lt;/code&gt;).&lt;/li&gt;&#xA;&lt;li&gt;Restart the  Arduino IDE. You can go straight to the example code by selecting: &lt;code&gt;File &amp;gt; Examples &amp;gt; SimpleModbusMaster &amp;gt; SimpleModbusMasterExample&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This procedure compiled for me with no errors. &lt;/p&gt;&#xA;" OwnerUserId="19409" LastActivityDate="2016-03-19T12:47:04.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21979" PostTypeId="2" ParentId="12951" CreationDate="2016-03-19T13:32:43.927" Score="0" Body="&lt;p&gt;Nick Gammon's answer seems the most straightforward solution to your&#xA;problem, given that you cannot spare an analog input. It has however the&#xA;drawback of needing a delay of ≈&amp;nbsp;100&amp;nbsp;µs. This may not be an&#xA;issue, but I just figured out a scheme that allows a faster read, and&#xA;may be of interest to some: instead of pull-ups or pull-downs, put just&#xA;a 10&amp;nbsp;kΩ resistor &lt;em&gt;in series&lt;/em&gt; between the MPC73831's output and you&#xA;Arduino input. When you want to read the state:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Take a first reading with the pin in INPUT mode:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if you read HIGH, then your MPC is either HIGH or HI_Z&lt;/li&gt;&#xA;&lt;li&gt;if you read LOW, then it's either LOW or HI_Z&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Now, switch the pin to OUTPUT, write the &lt;em&gt;opposite&lt;/em&gt; of what you just&#xA;read, switch back to input and take a second reading:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if you read what you just wrote, then your MPC is in the HI_Z state&lt;/li&gt;&#xA;&lt;li&gt;if you read the same as before, then it's either HIGH or LOW.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Here is the implementation of this scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define HI_Z 2&#xA;&#xA;/*&#xA; * Read a 3-state pin.&#xA; * Put a 10 kOhm resistor between the output and input pins.&#xA; */&#xA;int read3state(int pin)&#xA;{&#xA;    int reading1 = digitalRead(pin);&#xA;    pinMode(pin, OUTPUT);&#xA;    digitalWrite(pin, !reading1);&#xA;    pinMode(pin, INPUT);&#xA;    int reading2 = digitalRead(pin);&#xA;    if (reading1 == reading2)&#xA;        return reading1;&#xA;    else&#xA;        return HI_Z;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tested this a few 10&lt;sup&gt;4&lt;/sup&gt; times with an Arduino sending to&#xA;itself a pseudo-random sequence of LOW, HIGH and HI_Z. It works&#xA;reliably for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: This scheme relies on the pin being capacitively coupled to&#xA;GND or Vcc, and this coupling being stronger than couplings with other&#xA;signals in your circuit. If you fear this might not be the case, you can&#xA;put something like 100&amp;nbsp;pF from the pin to ground, but then you&#xA;should better wait a couple of microseconds before taking the second&#xA;reading.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-19T13:32:43.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21980" PostTypeId="1" CreationDate="2016-03-19T13:38:50.210" Score="0" ViewCount="7430" Body="&lt;p&gt;I like to use AS7 to make my programs. &#xA;I know c and some c++, but how things work from there I'm green.&#xA;I would like to know if there is a folder where I can store my own homemade c and h library files where they get to be available for all my projects.&#xA;Now I copy all the files into each of my projects and this works but I find it a bit tedious.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-04-18T16:44:47.167" Title="Atmel studio 7 - my own libraries" Tags="|arduino-uno|arduino-mega|arduino-ide|atmel-studio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21981" PostTypeId="2" ParentId="21976" CreationDate="2016-03-19T13:43:40.550" Score="2" Body="&lt;p&gt;I don't quite understand the problem. A&#xA; arduino mega would have no problem controlling 9 of these steppers alone. If you are asking about i2c protocol please be more specific about what you need help with. &lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-19T13:43:40.550" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="21982" PostTypeId="1" AcceptedAnswerId="22002" CreationDate="2016-03-19T13:57:32.820" Score="1" ViewCount="1839" Body="&lt;p&gt;Program reads rotary encoder correctly without bouncing in this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = 0;&#xA;byte clkPin = 3;&#xA;byte dtPin = 2;&#xA;bool lastClk;&#xA;bool lastDt;&#xA;void setup() {&#xA;  pinMode(clkPin,INPUT);&#xA;  pinMode(dtPin,INPUT);&#xA;  lastClk = digitalRead(3);&#xA;  lastDt = digitalRead(2);&#xA;  val = 0;&#xA;  attachInterrupt(digitalPinToInterrupt(clkPin), clkRise, RISING);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;void clkRise(){&#xA;      lastClk = HIGH;&#xA;      lastDt = digitalRead(dtPin);&#xA;      if(lastDt == LOW){&#xA;        val--;&#xA;        Serial.println(val);&#xA;        }  else{val++; Serial.println(val);}&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but when i use lcd to show the result, i get massive bounces (i think) in this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27,20,4);&#xA;int val = 0;&#xA;byte clkPin = 3;&#xA;byte dtPin = 2;&#xA;bool lastClk;&#xA;bool lastDt;&#xA;void setup() {&#xA;  lcd.begin();&#xA;  pinMode(clkPin,INPUT);&#xA;  pinMode(dtPin,INPUT);&#xA;  lastClk = digitalRead(3);&#xA;  lastDt = digitalRead(2);&#xA;  val = 0;&#xA;  attachInterrupt(digitalPinToInterrupt(clkPin), clkRise, RISING);&#xA;  Serial.begin(9600);&#xA;  lcd.home();&#xA;}&#xA;&#xA;void loop() {&#xA;  lcd.print(val);&#xA;}&#xA;&#xA;void clkRise(){&#xA;      lastClk = HIGH;&#xA;      lastDt = digitalRead(dtPin);&#xA;      if(lastDt == LOW){&#xA;        val--;&#xA;        Serial.println(val);&#xA;        }  else{val++;}&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it increases and decreases by random numbers between 0-5.I use KY-040 R.E. it has built-in 10k pull up resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what i use to debounce:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A or B pin of R.E--10k R----------------------------------Arduino INPUT PIN&#xA;                         |&#xA;                         |&#xA;                         =0.1uF C&#xA;                         |&#xA;                         ---------------------GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19192" LastActivityDate="2016-03-19T20:45:30.037" Title="Rotary Encoder problem with LCD Display" Tags="|lcd|rotary-encoder|debounce|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21983" PostTypeId="1" CreationDate="2016-03-19T14:36:54.663" Score="0" ViewCount="3790" Body="&lt;p&gt;I have a pair of IR transmitters and receivers, but I have found that the brightness of the transmitter is very low, so that I can't use it to detect an object in front of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="19413" LastEditorUserId="6936" LastEditDate="2016-03-26T03:08:10.460" LastActivityDate="2016-03-26T03:08:10.460" Title="How to increase the brightness of a IR transmitter LED?" Tags="|ir|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21985" PostTypeId="2" ParentId="21980" CreationDate="2016-03-19T15:51:20.927" Score="1" Body="&lt;p&gt;You should create your library as a separate project: File-&gt;New-&gt;Project and select C or C++ static library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xeDGB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xeDGB.png&quot; alt=&quot;creating c++ static library&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add your library modules in this project. When building, this will create &lt;strong&gt;lib{your_project_name}.a&lt;/strong&gt; file (in Debug or Release folder) - your library object file you can use in your other projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually I include in the same solution both the library project and target project (just library project file, sure the library and it's files resides in single place):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GnWfV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GnWfV.png&quot; alt=&quot;project solution&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;ORDO&lt;/strong&gt; is the library name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some check list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Include the library file in Libraries folder (shown above)&lt;/li&gt;&#xA;&lt;li&gt;Specify the path to the library *.a file for linker (Toolchain-&gt;AVR/GNU Linker-&gt;Libraries). Note that there should be different paths for Debug and Release configurations.&lt;/li&gt;&#xA;&lt;li&gt;Specify the path for library include files (Toolchain-&gt;AVR/GNU C or C++ Compiler-&gt;Directories)&lt;/li&gt;&#xA;&lt;li&gt;In some cases, F_CPU definition might be needed for library project too (same as in your project, under Symbols).&lt;/li&gt;&#xA;&lt;li&gt;When changes are made in your library files, use Build solution (F7) when building, if not - you can use Build project (which will be faster).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Setting project dependencies shall also lead to rebuilding the library automatically when needed (not tested, I usually just hit F7 :).&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="13594" LastEditDate="2016-03-19T16:00:27.177" LastActivityDate="2016-03-19T16:00:27.177" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="21986" PostTypeId="2" ParentId="21983" CreationDate="2016-03-19T16:09:04.867" Score="1" Body="&lt;p&gt;IR transmitter LEDs are literally just LEDs that emits Infrared Light which is not visible to the human eye.&#xA;That being said, IR LEDs behave very similarly to regular LEDs and therefore to increase the brightness you need to increase the Voltage it is receiving, just like you would do with a regular LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem with LEDs is that they drain current and that's why we use resistors,to protect our electronics(i.e. Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to recieve maximum voltage you can reduce the resistance of the resistor (let's say 220ohm or even 100ohm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forgot to mention that the correct wiring of LEDs to an arduino is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5V pin(or digital pin set to high) -&gt; Anode leg(longer) of LED -&gt; Resistor(connected to shorter leg :3) -&gt; ground pin&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-03-19T16:09:04.867" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="21987" PostTypeId="2" ParentId="11689" CreationDate="2016-03-19T16:17:54.497" Score="4" Body="&lt;p&gt;Also &lt;a href=&quot;http://www.procyonengineering.com/embedded/avr/avrlib/&quot; rel=&quot;nofollow&quot;&gt;Procyon AVR library&lt;/a&gt; worth be checking. It is a bit old now but very professional and kinda minimalistic. Not much dependencies, should be fine to use just I2C module only. There is hardly anything new in AVR I2C part since.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-03-19T16:17:54.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21988" PostTypeId="2" ParentId="21954" CreationDate="2016-03-19T16:33:25.590" Score="1" Body="&lt;p&gt;I can't tell exactly whats not working with your code,it would be really helpful if you elaborate more. &#xA;But here is some code that I wrote and I think it will get the job done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//declare our variables:&#xA;int myPins[] = {2, 4, 8, 3, 6}; //Enter the number of the pins being used&#xA;int RNum = 0;&#xA;&#xA;void loop()&#xA;{&#xA;    DigitalWrite(myPins[RNum],LOW);&#xA;    RNum = Random(0,MAX) // MAX being the number of LEDs connected minus one &#xA;    //the above generates a random number&#xA;    DigitalWrite(myPins[RNum],High);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will turn on one LED at a time.&lt;/p&gt;&#xA;" OwnerUserId="11982" LastEditorUserId="11982" LastEditDate="2016-03-25T10:09:29.220" LastActivityDate="2016-03-25T10:09:29.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21989" PostTypeId="2" ParentId="9882" CreationDate="2016-03-19T16:56:46.107" Score="1" Body="&lt;p&gt;Can't comment, so I put here. In your Arduino you shall use unique MAC address, that can't be same as in your laptop or any other node in network segment. And it can't be just any number because some bits have different meanings, so to be safe, use MAC from Ethernet shield samples (BTW in production units, MAC addresses have to be purchased, but unfortunately Ethernet shield comes without it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;127.0.0.1 is a &quot;virtual&quot; localhost address (alternative address used to access the services within same host), in your case you shall use MySQL server (your laptop?) host address, so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; server_addr(192,168,0,102);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is right.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-03-19T16:56:46.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21990" PostTypeId="1" AcceptedAnswerId="21991" CreationDate="2016-03-19T17:29:20.637" Score="1" ViewCount="199" Body="&lt;p&gt;I am working on a project with multiple arduinos. I want my folder structure to be as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/&#xA;  libs/&#xA;    someSharedFile.h&#xA;  arduino1/&#xA;    arduino1.ino&#xA;  arduino2/&#xA;    arduino2.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I include &lt;code&gt;someSharedFile.h&lt;/code&gt; in one of my .ino files like this &lt;code&gt;#include &quot;../libs/someSharedFile.h&quot;&lt;/code&gt;, I get this error &lt;code&gt;No such file or directory&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I move &lt;code&gt;libs/&lt;/code&gt; to &lt;code&gt;arduino1&lt;/code&gt; and include the shared file like this &lt;code&gt;#include &quot;libs/someSharedFile.h&quot;&lt;/code&gt; everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using IDE 1.6.7 on windows 10.&lt;/p&gt;&#xA;" OwnerUserId="17310" LastActivityDate="2016-03-19T17:46:04.273" Title="Cannot include .h files back one directory" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21991" PostTypeId="2" ParentId="21990" CreationDate="2016-03-19T17:46:04.273" Score="2" Body="&lt;p&gt;Arduino IDE copies the files to a temp folder. You can see that when you compile in verbose mode.&lt;br&gt;&#xA;As such the lib folder is not available.&lt;br&gt;&#xA;You should place you libraries in [your home folder]/arduino/libraries&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-19T17:46:04.273" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="21992" PostTypeId="2" ParentId="21983" CreationDate="2016-03-19T17:48:27.137" Score="0" Body="&lt;p&gt;If you aren't at the current limit of either the IO pin (40mA) or the LED (usually around 30mA) you can increase the current as far as the lower of those.  That can be done by reducing the value of the resistor you are using with the LED or using a higher current drive circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, just having an LED turned on all the time is not a good way of using it - you are constantly fighting against the background light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead the LED needs to be pulsed on and off using PWM at a very high frequency (typically 30-50kHz) and you need to detect that pulsed light with the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is usually achieved by using a high-pass (or band pass) filter and amplifier on the receiver.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-19T17:48:27.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="21993" PostTypeId="2" ParentId="5097" CreationDate="2016-03-19T18:05:27.530" Score="7" Body="&lt;p&gt;Note that there is also a version of &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPITransfer&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;SPI.transfer&lt;/code&gt;&lt;/a&gt; for multi-byte (buffer) transfers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.transfer(buffer, size)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used the buffer transfer in my &lt;a href=&quot;https://github.com/ulrichstern/Tlc59711/wiki&quot; rel=&quot;noreferrer&quot;&gt;library&lt;/a&gt; for the TLC59711 (see &lt;a href=&quot;https://github.com/ulrichstern/Tlc59711/blob/v1.0.1/Tlc59711.cpp#L91&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;) and found the buffer transfer faster than transferring bytes individually using &lt;code&gt;SPI.transfer(val)&lt;/code&gt;; the switch to buffer transfers is &lt;em&gt;one&lt;/em&gt; of the reasons my library is about 3.5 times faster than a previous library for the TLC59711.&lt;/p&gt;&#xA;" OwnerUserId="14765" LastEditorUserId="14765" LastEditDate="2016-06-15T20:54:35.843" LastActivityDate="2016-06-15T20:54:35.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="21999" PostTypeId="1" AcceptedAnswerId="22000" CreationDate="2016-03-19T20:15:50.767" Score="0" ViewCount="70" Body="&lt;p&gt;I just purchased &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_RTC&quot; rel=&quot;nofollow noreferrer&quot;&gt;this Grove RTC&lt;/a&gt;. It includes a cable presumably to connect it to a breadboard and/or Arduino, but the pin holes on this cable are much smaller than those on a breadboard or Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How/where would I connect this in the case of using an Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SQ2Mb.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SQ2Mb.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-19T20:26:44.247" Title="How do I connect this to my breadboard?" Tags="|arduino-uno|rtc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22000" PostTypeId="2" ParentId="21999" CreationDate="2016-03-19T20:26:44.247" Score="0" Body="&lt;p&gt;Either use jumper wire, or pull the connectors from the Housing and connect them with male connectors.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-19T20:26:44.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22001" PostTypeId="1" AcceptedAnswerId="22008" CreationDate="2016-03-19T20:38:28.083" Score="0" ViewCount="5388" Body="&lt;p&gt;I am currently having difficulties sending data from an Arduino using an ethernet shield to a PHP database in MySQL. My problem is that it appears that the server is receiving the data as there is a time stamp when I send it from the Arduino however, the other values it is receiving are incorrect (see images below). The server says the values of &quot;data&quot;, and &quot;serial_number&quot; are 0 but they are supposed to be 10 and 24. Along with that the Arduino is saying that the data has been sent successfully. My code for both the server and the Arduino is listed below. Any ideas on how to fix this or what is going on are much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oLP5K.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oLP5K.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;byte mac[] = { 0x00, 0xAB, 0xBA, 0xBC, 0xDD, 0x02 };&#xA;EthernetClient client;&#xA;String data;&#xA;int t;&#xA;int h;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;  }&#xA;&#xA;  Serial.println(&quot;still working here&quot;);&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;t = 10;&#xA;h = 24;&#xA;&#xA;data = &quot;temp1=&quot;;&#xA;&#xA;data.concat(t);&#xA;&#xA;data.concat(&quot;&amp;amp;hum1=&quot;);&#xA;&#xA;data.concat(h);&#xA;&#xA;&#xA;  if (client.connect(&quot;www.smartwater.x10host.com&quot;,80)) {&#xA;    Serial.println(data);&#xA;    client.print(&quot;POST /add.php HTTP/1.1\n&quot;);&#xA;    client.print(&quot;Host: www.smartwater.x10host.com\n&quot;);&#xA;    client.print(&quot;Connection: close\n&quot;);&#xA;    client.print(&quot;Content-Type: application/x-www-form-urlencoded\n&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.print(data.length());&#xA;    client.print(&quot;\n\n&quot;);&#xA;    client.print(data);&#xA;    Serial.println(&quot;Successfull&quot;);&#xA;&#xA;&#xA;  }&#xA;&#xA;  if (client.connected()) {&#xA;    client.stop();&#xA;  }&#xA;&#xA;  delay(20000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;add.php (Server Code)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;    include(&quot;connect.php&quot;);&#xA;&#xA;    $link=Connection();&#xA;&#xA;    $temp1=$_POST[&quot;data&quot;];&#xA;    $hum1=$_POST[&quot;serial_number&quot;];&#xA;&#xA;    $query = &quot;INSERT INTO `Main` (`data`, `serial_number`) &#xA;        VALUES ('&quot;.$temp1.&quot;','&quot;.$hum1.&quot;')&quot;; &#xA;&#xA;    mysql_query($query,$link);&#xA;    mysql_close($link);&#xA;&#xA;    header(&quot;Location: index.php&quot;);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;connect.php (Server Code)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;    function Connection(){&#xA;        $server=&quot;localhost&quot;;&#xA;        $user=&quot;smartwat_arduino&quot;;&#xA;        $pass=&quot;*****&quot;;&#xA;        $db=&quot;smartwat_Main&quot;;&#xA;&#xA;        $connection = mysql_connect($server, $user, $pass);&#xA;&#xA;        if (!$connection) {&#xA;            die('MySQL ERROR: ' . mysql_error());&#xA;        }&#xA;&#xA;        mysql_select_db($db) or die( 'MySQL ERROR: '. mysql_error() );&#xA;&#xA;        return $connection;&#xA;    }&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;index.php (Server Code)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;&#xA;    include(&quot;connect.php&quot;);     &#xA;&#xA;    $link=Connection();&#xA;&#xA;    $result=mysql_query(&quot;SELECT * FROM `Main` ORDER BY `timeStamp` DESC&quot;,$link);&#xA;?&amp;gt;&#xA;&#xA;&amp;lt;html&amp;gt;&#xA;   &amp;lt;head&amp;gt;&#xA;      &amp;lt;title&amp;gt;Data&amp;lt;/title&amp;gt;&#xA;   &amp;lt;/head&amp;gt;&#xA;&amp;lt;body&amp;gt;&#xA;   &amp;lt;h1&amp;gt;Stuff&amp;lt;/h1&amp;gt;&#xA;&#xA;   &amp;lt;table border=&quot;1&quot; cellspacing=&quot;1&quot; cellpadding=&quot;1&quot;&amp;gt;&#xA;        &amp;lt;tr&amp;gt;&#xA;            &amp;lt;td&amp;gt;&amp;amp;nbsp;Timestamp&amp;amp;nbsp;&amp;lt;/td&amp;gt;&#xA;            &amp;lt;td&amp;gt;&amp;amp;nbsp;Data&amp;amp;nbsp;&amp;lt;/td&amp;gt;&#xA;            &amp;lt;td&amp;gt;&amp;amp;nbsp;Serial Number&amp;amp;nbsp;&amp;lt;/td&amp;gt;&#xA;&#xA;        &amp;lt;/tr&amp;gt;&#xA;&#xA;      &amp;lt;?php &#xA;          if($result!==FALSE){&#xA;             while($row = mysql_fetch_array($result)) {&#xA;                printf(&quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;nbsp;%s &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; &amp;amp;nbsp;%s&amp;amp;nbsp; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; &amp;amp;nbsp;%s&amp;amp;nbsp; &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&quot;, &#xA;                   $row[&quot;timeStamp&quot;], $row[&quot;data&quot;], $row[&quot;serial_number&quot;]);&#xA;             }&#xA;             mysql_free_result($result);&#xA;             mysql_close();&#xA;          }&#xA;      ?&amp;gt;&#xA;&#xA;   &amp;lt;/table&amp;gt;&#xA;&amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19421" LastActivityDate="2019-08-29T02:37:37.953" Title="Posting Arduino data via ethernet to PHP server problems" Tags="|arduino-uno|ethernet|web-server|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22002" PostTypeId="2" ParentId="21982" CreationDate="2016-03-19T20:38:51.520" Score="0" Body="&lt;p&gt;I suspect the problem is that your hardware-debounce capacitive circuit isn't working well enough to accurately debounce the contacts, and that invalid transitions are occurring on the quadrature lines as read by the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that use of &lt;code&gt;Serial.println()&lt;/code&gt; within your &lt;code&gt;clkRise()&lt;/code&gt; interrupt handler is problematic, because &lt;code&gt;Serial.println()&lt;/code&gt; uses interrupts itself. As far as I know, &lt;code&gt;println()&lt;/code&gt; is not reentrant, ie cannot be used correctly from the multiple interrupts that may start before previous &lt;code&gt;println()&lt;/code&gt; calls finish their background processing.  The bits of extra delay introduced by LCD code may merely be exposing a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no need for either hardware or software debouncing on quadrature inputs.  A correctly-implemented state machine will reject invalid conditions that arise during bounce, or will immediately follow any extra up-tick by a corresponding down-tick, or vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some state machine code, see for example &lt;a href=&quot;https://arduino.stackexchange.com/a/16420/3917&quot;&gt;answer 16420/3917&lt;/a&gt; and also see &lt;a href=&quot;https://arduino.stackexchange.com/a/18221/3917&quot;&gt;answer 18221/3917&lt;/a&gt;.  Also see &lt;a href=&quot;https://arduino.stackexchange.com/a/19109/3917&quot;&gt;answer 19109/3917&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-19T20:45:30.037" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22003" PostTypeId="2" ParentId="22001" CreationDate="2016-03-19T20:44:01.420" Score="0" Body="&lt;p&gt;Data = 10 is not the characters making 1 and 0 but an ascii character with value &#xA;10, your php script doesn't understand that.&#xA;Try using itoa function to make character array 1 and 0 for your php to understand.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-19T20:44:01.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22004" PostTypeId="2" ParentId="22001" CreationDate="2016-03-19T21:47:48.410" Score="0" Body="&lt;p&gt;You get a timestamp from running the php file. That doest mean that there is a number in $data or $serialnmber.&#xA;What happens if you fill in a value in your php file instead of the variables $data and serialnumber. If the dbase gets filled, you know that than your variables were empty. If they arent filled something is wrong in your php coding&lt;/p&gt;&#xA;" OwnerUserId="8162" LastActivityDate="2016-03-19T21:47:48.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22007" PostTypeId="2" ParentId="21967" CreationDate="2016-03-20T00:37:40.213" Score="0" Body="&lt;p&gt;You need access to the Internet. Since you dont want to use an Ethernet or WiFi shield/module, then, for the most part, you are left with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Using a GSM module with the Arduino to receive data over the Internet&lt;/li&gt;&#xA;&lt;li&gt;Using a PC as a web server to receive data over the internet and forward it to the Arduino over a wired connection (UART) or a wireless connection (e.g. bluetooth)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The most direct would be the second method over UART. So it could be seen like this: &lt;code&gt;Client/Sending PC -&amp;gt; Over the Internet -&amp;gt; Server/Receiving PC -&amp;gt; Over UART -&amp;gt; Arduino&lt;/code&gt;. So you are now faced with 3 main interfaces: &lt;code&gt;Internet-&amp;gt;PC&lt;/code&gt; for the server and client as well as the &lt;code&gt;PC-&amp;gt;Arduino&lt;/code&gt; interface on the server/receiver side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To handle the &lt;code&gt;Internet -&amp;gt; PC&lt;/code&gt; interface for the client, the client PC would need to run a program that will connect to the server PC over the Internet (using the server's public IP) and send the Arduino control data. Similarly, the &lt;code&gt;Internet-PC&lt;/code&gt; interface for the server PC would require a constantly-running server program that will listen for incoming connections from the client PC and receive the data being sent. Assuming you know Python, with Python you can have both programs up and running within minutes. &lt;a href=&quot;http://www.bogotobogo.com/python/python_network_programming_server_client.php&quot; rel=&quot;nofollow&quot;&gt;This site&lt;/a&gt; should help with the programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that port forwarding will need to be implemented on the router on the server side so that packets from outside its local network can get to it, given that its behind a router. &lt;a href=&quot;http://upnp-portmapper.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;This software&lt;/a&gt; can help with setting port forwarding rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;PC-&amp;gt;Arduino&lt;/code&gt; interface will require the &lt;code&gt;pyserial&lt;/code&gt; package (if you're still using Python). Pyserial can be used to forward the control data received over the internet, to the Arduino over Serial UART. &lt;a href=&quot;https://pythonhosted.org/pyserial/&quot; rel=&quot;nofollow&quot;&gt;This site&lt;/a&gt; should help with using Pyserial for Python 3. Search for other tutorials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the Arduino itself must regularly check the Serial buffer for any received characters from the PC. It must then act on the received data, depending on rules you should have established. A simple example would be: 'a' = Write HIGH to pin 13. This means if ASCII char 'a' were received over Serial, the Arduino would interpret this to mean a command to &lt;code&gt;digitalWrite(13, HIGH)&lt;/code&gt;. You can make use of the built-in &lt;code&gt;serialEvent()&lt;/code&gt; to regularly poll the serial buffer. A simple sketch to illustrate this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){}&#xA;&#xA;void serialEvent(){&#xA;  if (Serial.read() == 'a') &#xA;    digitalwrite(13, HIGH);&#xA;  else  //any other character turns off the LED&#xA;    digitalWrite(13, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is, by no means, the only way to do this, only very straightforward IMO. For example, you could also upload your control data to some cheap server and have your PC regularly poll that server for any new commands. Of course, this would be greatly simplified if you decided to use a WiFi module, like the cheap ESP-01, directly with the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-20T00:37:40.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22008" PostTypeId="2" ParentId="22001" CreationDate="2016-03-20T00:55:45.253" Score="1" Body="&lt;p&gt;In your Arduino code, the function call that send the real data within the HTTP-POST call, is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;client.print(data);&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When executed, the content of the &lt;code&gt;data&lt;/code&gt; variable is sent to the server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supposing &lt;code&gt;data&lt;/code&gt; is a &lt;code&gt;String&lt;/code&gt; object then &lt;code&gt;data.concat()&lt;/code&gt; is &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringConcat&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; function, allowing &quot;&lt;em&gt;... String, string, char, byte, &lt;strong&gt;int&lt;/strong&gt;, unsigned int, long, unsigned long, float, double...&lt;/em&gt;&quot; as argument.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, after the execution, &lt;code&gt;data&lt;/code&gt; should contain:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;temp1=10&amp;amp;hum1=24&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and such content is exactly what is passed, via &lt;code&gt;POST&lt;/code&gt; to the &lt;code&gt;/add.php&lt;/code&gt; script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you're passing two variables, called &quot;&lt;strong&gt;temp1&lt;/strong&gt;&quot; and &quot;&lt;strong&gt;hum1&lt;/strong&gt;&quot;. &lt;strong&gt;Please keep note of those variable names&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now let's switch the the PHP script, where you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;$temp1=$_POST[&quot;data&quot;];&#xA;$hum1=$_POST[&quot;serial_number&quot;];&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Above two statements, asks PHP to retrieve, via the &lt;code&gt;$_POST&lt;/code&gt; function, the content of the two variables &lt;strong&gt;data&lt;/strong&gt; and &lt;strong&gt;serial_number&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such variables are &lt;strong&gt;undefined&lt;/strong&gt; (the variables you passed were &lt;code&gt;temp1&lt;/code&gt; and &lt;code&gt;hum1&lt;/code&gt;), PHP consider them like &lt;code&gt;0&lt;/code&gt; and, as such, assign 0 to &lt;code&gt;$temp1&lt;/code&gt; and &lt;code&gt;$hum1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bet that to solve your problem you only need to change above PHP with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[...]&#xA;$temp1=$_POST[&quot;temp1&quot;];&#xA;$hum1=$_POST[&quot;hum1&quot;];&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;BTW: please note that what is inside the $_POST call is totally unrelated with the names of the variables you have on the left of the &lt;code&gt;=&lt;/code&gt; sign: they are really different things!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="13193" LastActivityDate="2016-03-20T00:55:45.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22009" PostTypeId="2" ParentId="20482" CreationDate="2016-03-20T01:17:59.727" Score="-1" Body="&lt;p&gt;You can use a Raspberry Pi as your MQTT server and you can also connect a nRF24L01+ module.&lt;/p&gt;&#xA;" OwnerUserId="19424" LastEditorUserId="11529" LastEditDate="2016-03-21T00:27:16.140" LastActivityDate="2016-03-21T00:27:16.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22012" PostTypeId="2" ParentId="21932" CreationDate="2016-03-20T05:13:36.550" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;short wires are generally better than long ones&lt;/li&gt;&#xA;&lt;li&gt;I agree, that wired is better in your situation&lt;/li&gt;&#xA;&lt;li&gt;Maybe you distinguish between two different areas: sensor/actor to controller and controller to controller communication&lt;/li&gt;&#xA;&lt;li&gt;In many cases you can not chose the sensor/actor to controller communication, because it is given by the device (DHT-22, reed, led push button etc.). Therefore, keep these lines short&lt;/li&gt;&#xA;&lt;li&gt;RS-485 is good, but is it necessary? It adds drivers to each device. Maybe, I2C could do it,to. You can still use twisted pair cables.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19428" LastActivityDate="2016-03-20T05:13:36.550" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22015" PostTypeId="1" AcceptedAnswerId="22016" CreationDate="2016-03-20T10:45:29.167" Score="1" ViewCount="1711" Body="&lt;p&gt;I am currently busy with a project that requires me to use an Arduino and 3 potentiometers (to change background in RGB format) to write values through the serial port and read and separate them in processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is to be able to use my Arduino to write multiple values to a processing program. I am quite new to coding and its been a while since I worked with my Arduino. I know how to read and write one value, but not multiple values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also is there a way to write 20 values?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="19431" LastActivityDate="2016-03-20T11:18:19.043" Title="Writing and reading multiple values through serial" Tags="|serial|processing-lang|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22016" PostTypeId="2" ParentId="22015" CreationDate="2016-03-20T11:18:19.043" Score="0" Body="&lt;p&gt;The simplest way is to just print them as a single line and separate them with &quot;something&quot;. That &quot;something&quot; could be as simple as a space.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(val1);&#xA;Serial.print(&quot; &quot;);&#xA;Serial.print(val2);&#xA;...&#xA;Serial.print(&quot; &quot;);&#xA;Serial.println(val20);&#xA;&#xA;&#xA;743 234 34 599 2 ... 427 1013 48 2 409&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in processing you just read the entire line into a String and split it on the spaces into an array.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-20T11:18:19.043" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22017" PostTypeId="1" CreationDate="2016-03-20T11:22:02.310" Score="4" ViewCount="3095" Body="&lt;p&gt;I'm working on a project where I need to read the HID RFID cards. Behind the card it shows as HID 0008p and based on the documentation, it looks like it uses a 125&amp;nbsp;kHz frequency. I tried using different 125&amp;nbsp;kHz RFID readers, but I was unable to read the card. What reader should I use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used RC522, and also another 125&amp;nbsp;kHz reader with Wiegand output, both  without any success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Card Used : HID Proximity Card 0008p&#xA;&lt;strong&gt;Additional details about the card type : HID DuoProx II 1336&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code i used - This works fine with SWH 5100 &lt;a href=&quot;http://www.sourcesecurity.com/technical-details/access-control/readers-and-controllers/readers/software-house-swh-5100.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;reader&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But doesn't work with this reader &lt;a href=&quot;http://www.nskelectronics.in/index.php?route=product/product&amp;amp;product_id=299&amp;amp;search=RFID&quot; rel=&quot;nofollow noreferrer&quot;&gt;EDK-125 TTL&lt;/a&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;volatile unsigned long tagID = 0;&#xA;volatile unsigned long lastBitArrivalTime;&#xA;volatile int bitCount = 0;&#xA;&#xA;#define MAX_BITS 100                 // max number of bits &#xA;#define WEIGAND_WAIT_TIME  3000      // time to wait for another weigand pulse.  &#xA;&#xA;unsigned char databits[MAX_BITS];    // stores all of the data bits&#xA;&#xA;unsigned long facilityCode;        // decoded facility code&#xA;unsigned long cardCode;            // decoded card code&#xA;&#xA; unsigned char i;&#xA;&#xA;void ISRone(void)&#xA;{&#xA;  lastBitArrivalTime = millis();&#xA;  databits[bitCount] = 1;&#xA;  bitCount++;&#xA;  tagID &amp;lt;&amp;lt;= 1;&#xA;  tagID |= 1;&#xA;  Serial.println(bitCount);&#xA;}&#xA;&#xA;void ISRzero(void)&#xA;{&#xA;  lastBitArrivalTime = millis();&#xA;  databits[bitCount] = 0;&#xA;  bitCount++;&#xA;  tagID &amp;lt;&amp;lt;= 1;&#xA;  Serial.println(bitCount);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(2, INPUT);&#xA;  digitalWrite(2, HIGH);  // Enable pull-up resistor&#xA;  attachInterrupt(0, ISRzero, CHANGE);&#xA;&#xA;  pinMode(3, INPUT);&#xA;  digitalWrite(3, HIGH);  // Enable pull-up resistor&#xA;  attachInterrupt(1, ISRone,  CHANGE);&#xA;&#xA;  tagID = 0;&#xA;  bitCount = 0;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //  See if it has been more than 1/4 second since the last bit arrived&#xA;  if(bitCount &amp;gt; 0 &amp;amp;&amp;amp; millis() - lastBitArrivalTime &amp;gt;  250)&#xA;  {&#xA;    Serial.print(bitCount, DEC);&#xA;    Serial.print(&quot; bits: &quot;);&#xA;&#xA; // 35 bit HID Corporate 1000 format&#xA;      // facility code = bits 2 to 14&#xA;      for (i=2; i&amp;lt;14; i++)&#xA;      {&#xA;         facilityCode &amp;lt;&amp;lt;=1;&#xA;         facilityCode |= databits[i];&#xA;      }&#xA;&#xA;      // card code = bits 15 to 34&#xA;      for (i=14; i&amp;lt;34; i++)&#xA;      {&#xA;         cardCode &amp;lt;&amp;lt;=1;&#xA;         cardCode |= databits[i];&#xA;      }&#xA;&#xA; //   Serial.println(tagID);&#xA;    Serial.println(cardCode);&#xA; //   Serial.println(facilityCode);&#xA;&#xA;    cardCode = 0;&#xA;    facilityCode = 0;&#xA;    tagID = 0;&#xA;    bitCount = 0;&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18711" LastEditorUserId="37523" LastEditDate="2019-05-13T19:15:46.253" LastActivityDate="2019-05-13T19:15:46.253" Title="Can we use an alternate RFID reader to read HID cards?" Tags="|rfid|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22018" PostTypeId="1" CreationDate="2016-03-20T12:47:10.810" Score="2" ViewCount="6359" Body="&lt;p&gt;I have a problem with my Arduino Nano ATmega328 and my ESP8266 01 module. I have connected the ESP8266 on my Arduino board without FTDI. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made the following connection: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I an using a 5V Arduino Nano which of course is 5V. The ESP8266 is a 3.3V device and so I am using a voltage divider to bring the Arduino's 5V down to 3.3V. If you are using a 3.3V Arduino then you do not need the voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The wiring is very similar to the FTDI.&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 3 to voltage divider and then to ESP8266 RX&lt;/li&gt;&#xA;&lt;li&gt;Arduino pin 2 to ESP8266 TX&lt;/li&gt;&#xA;&lt;li&gt;Arduino GND to ESP8266 GND&lt;/li&gt;&#xA;&lt;li&gt;Pull CH_PD HIGH with a 10K resistor to +3.3V&lt;/li&gt;&#xA;&lt;li&gt;+3.3V to Vcc&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You only need the voltage divider on the Arduino TX pin. The 5V Arduino will read 3.3V as HIGH so you can connect the ESP8266 TX pin directly to the Arduino RX pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I had and I can't handle is that when I start up the Arduino Tx and Rx LEDs work continuously so I can't have access to my serial monitor of the Arduino IDE. So with that problem I can't send or receive any command to/from the IDE. Also when I try to upload my program to the Arduino board, I have to disconnect the ESP. If I don't I can't upload it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas guys? I would be grateful &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Indvi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Indvi.jpg&quot; alt=&quot;My circuit schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also try to implement code with &lt;code&gt;AltSoftSerial&lt;/code&gt; but I have library issues - my laptop does not recognize it (I downloaded it and I put it in the same folder with my code).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;    SoftwareSerial ESPserial(2, 3); // RX | TX&#xA;    void setup() &#xA;    {    Serial.begin(9600);     // communication with the host         computer&#xA;&#xA;     // Start the software serial for communication with the ESP8266&#xA;     ESPserial.begin(9600);  &#xA;&#xA;     Serial.println(&quot;&quot;);&#xA;     Serial.println(&quot;Remember to to set Both NL &amp;amp; CR in the serial monitor.&quot;);&#xA;     Serial.println(&quot;Ready&quot;);&#xA;     Serial.println(&quot;&quot;);}&#xA;&#xA;     void loop() &#xA;      {&#xA;      // listen for communication from the ESP8266 and then write it to the serial monitor&#xA;       if ( ESPserial.available() )   {  Serial.write( ESPserial.read();}  / / listen for user input and send it to the ESP8266&#xA;      if ( Serial.available() )       {  ESPserial.write( Serial.read()  );  }}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19434" LastEditorUserId="6936" LastEditDate="2016-04-19T04:40:06.087" LastActivityDate="2016-04-19T13:03:08.010" Title="Arduino Nano ESP8266 software serial problems" Tags="|arduino-nano|esp8266|softwareserial|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22019" PostTypeId="1" CreationDate="2016-03-20T14:46:52.377" Score="0" ViewCount="4766" Body="&lt;p&gt;I just purchased some HC-05 Bluetooth devices and I have followed the directions to put the devices in AT command mode by holding EN HIGH when the HC-05 powers up.  When I do this the HC-05 goes into the &quot;slow blink&quot; to indicate it is in command mode.  However, when I send it &quot;AT&quot; I get odd characters in the response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that when I type &quot;AT&quot; I get exactly 4 characters back.  They are just not the &quot;OK&quot; characters I expect.  I also verified that the Arduino IDE serial console is sending both NL and CR characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, here is the Mel Patrick HC-05 authored setup program I am running:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://raw.githubusercontent.com/dmccreary/coderdojo-robots/master/src/bluetooth-remote/hc-05-setup/hc-05-setup.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://raw.githubusercontent.com/dmccreary/coderdojo-robots/master/src/bluetooth-remote/hc-05-setup/hc-05-setup.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TbqJz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TbqJz.png&quot; alt=&quot;HC-05 serial problem&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has been suggested that the data from the HC-05 is only going up to 3.3v and that might be the cause of the problem, since the Arduino is looking for a 0-5 volt signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also note that when I remove the TDX line from the HC-05 that no responses come back.  So I suspect that it is getting the &quot;AT&quot; fine through the RTX from the Arduino to the HC-05.  It is just some problem in the return data format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple transistor circuit I can hookup to shift the levels back to 0 to 5 volts from the 0 to 3.3 volts?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also using an Arduino Nano if that makes any difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks - Dan&lt;/p&gt;&#xA;" OwnerUserId="4519" LastActivityDate="2020-01-01T02:03:05.460" Title="Problems with serial communication from Arduino to Bluetooth HC-05" Tags="|serial|bluetooth|arduino-nano|voltage-level|hc-05|" AnswerCount="6" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22020" PostTypeId="1" CreationDate="2016-03-20T15:33:34.423" Score="1" ViewCount="1067" Body="&lt;p&gt;I’m new to Arduino and am trying to build a plant watering system without much knowledge on the subject. But my water pump is not working as I expected it to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to keep it simple so I bought a Arduino Motor Shield for my Arduino Uno R3. I’m using a motor rated at 3-9V (motor is shown below), I’ve tried two different DC adaptors plugged into the power supply port on the arduino, 12V 1.5A and 12V 2A, even though the motor is rated at 9V, I’ve read that I need a 12V adapter to power the motor shield. &#xA;&lt;a href=&quot;http://www.mabuchi-motor.co.jp/cgi-bin/catalog/e_catalog.cgi?CAT_ID=rs_360sh&quot; rel=&quot;nofollow&quot;&gt;http://www.mabuchi-motor.co.jp/cgi-bin/catalog/e_catalog.cgi?CAT_ID=rs_360sh&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first problem is If I run the motor at full speed, &lt;code&gt;analogWrite(3, 255)&lt;/code&gt;, it sounds like its going to explode, so I’m trying to run it at a lower speed. But If use values anywhere below 170 the motor will not run and will only make a beeping sound. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, regardless of the PWM value I run the motor at, the chip gets very hot very quickly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, why can’t I run the pump at lower PWM values, and why is it getting so hot?&#xA;If I bought a 12V water pump and used the same setup, would I not have any of these problems? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;an update...&#xA;it seems to basically work now. i have a feeling it wasn't working great because I was previously using a powerbar&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will run on max power PWM(255) for about a minute, and then stop working, which is okay. It will stop and then the motor shield lights will start blinking. Does anybody have any guesses what is happening? The motorshield chip is a little hot, so overheating is a possibility. Or is there not enough current ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;video&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=xdxf3f_Svqs&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=xdxf3f_Svqs&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;//  //Setup Channel A&#xA;  pinMode(12, OUTPUT); //Initiates Motor Channel A pin&#xA;  pinMode(9, OUTPUT); //Initiates Brake Channel A pin&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  //forward @ full speed, A&#xA;  digitalWrite(12, HIGH); //Establishes forward direction of Channel A&#xA;  digitalWrite(9, LOW);   //Disengage the Brake for Channel A&#xA;  analogWrite(3, 170);   //Spins the motor on Channel A at a speed. approx 90 is min&#xA;&#xA;  delay(3000);&#xA;&#xA;  digitalWrite(9, HIGH); //Engage the Brake for Channel A&#xA;&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19437" LastEditorUserId="19437" LastEditDate="2016-03-23T00:10:27.550" LastActivityDate="2016-03-23T00:10:27.550" Title="Arduino water pump not working and beeping" Tags="|arduino-uno|motor|pwm|arduino-motor-shield|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22025" PostTypeId="1" AcceptedAnswerId="22033" CreationDate="2016-03-20T19:03:30.247" Score="0" ViewCount="6864" Body="&lt;p&gt;I want to write code for my Arduino in Lua. Where I can find the necessary (pins) I/O lib and examples for Arduino IDE?&lt;br&gt;&#xA;UPD: I've got arduino mega with many memory.&lt;/p&gt;&#xA;" OwnerUserId="15718" LastEditorUserId="15718" LastEditDate="2016-08-17T16:36:19.650" LastActivityDate="2016-08-17T16:36:19.650" Title="Using Lua in Arduino project" Tags="|lua|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22026" PostTypeId="1" CreationDate="2016-03-20T19:12:18.137" Score="0" ViewCount="9643" Body="&lt;p&gt;I got a SIM800L, same as the one under this link, &lt;a href=&quot;http://www.ayomaonline.com/programming/quickstart-sim800-sim800l-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;Quickstart SIM800 (SIM800L) With Arduino&lt;/a&gt;, and played around with an Arduino Nano and Uno. I had a few problems, at the start, not getting it work properly. It turned out that my Nano 5V pin wasn't enough for the SIM unit. It works fine with Uno though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is the code I tested the GSM (same link) and got it working somehow, I got simple AT commands and managed to send an SMS. But after I dismantled the connections and the next day I tried again... Nothing. I can see the SIM unit connects to network as the LED blinking slows down to once every 3 seconds but when I type commands in nothing happens in the serial monitor. It doesn't give errors or anything, just nothing happens on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did wire it incorrectly, once with the Tx/Rx, but that shouldn't damage the unit, should it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to upload different programs to my Arduino and they work fine so that shouldn't be the problem. Is there a way to reset the SIM800 unit? Or am I missing something here?&lt;/p&gt;&#xA;" OwnerUserId="19441" LastEditorUserId="6936" LastEditDate="2016-03-26T03:33:27.763" LastActivityDate="2016-05-25T09:03:36.283" Title="SIM800L project not working" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22027" PostTypeId="2" ParentId="22020" CreationDate="2016-03-20T20:05:49.047" Score="2" Body="&lt;p&gt;Regarding your motor just making high pitched noise (beeping) I would say that you are not supplying enough power to your motor for it to pull in the load and get rotating, you might try to first get it started by a higher power setting (PWM) and then when it's running see how far down you can set it before it stalls (stops). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't belive a 12V pump would work any different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the motor and L298 chip getting hot, this is sort of normal and in some cases would require som way of dissipating this heat. A heatsink might be an option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were to overheat the L298 it will shut down before being destroyed (it should).&lt;/p&gt;&#xA;" OwnerUserId="19322" LastEditorUserId="19322" LastEditDate="2016-03-21T12:37:38.790" LastActivityDate="2016-03-21T12:37:38.790" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22028" PostTypeId="2" ParentId="22026" CreationDate="2016-03-20T20:33:53.560" Score="2" Body="&lt;p&gt;The module needs a good 5v supplier as it might have a peak of 1A or 2A, when it registers to the network or connects to 3G.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to make sure that you share the ground between the power supplier and you use some 2 pins on your arduino to connect the GSM module.&#xA;Dont try to get a fast baudrate as software serial doesnt work, try with 9600 to start then see if it response to the AT command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SIM800 is a very simple module, try with an FTDI in case you want to make sure you didnt break your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more help, share your schematic how you have connected the arduino.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2016-03-20T20:33:53.560" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22031" PostTypeId="2" ParentId="22025" CreationDate="2016-03-20T21:44:15.130" Score="0" Body="&lt;p&gt;AFAIK, Arduino IDE supports C++ only. You can use other languages to communicate with Arduino from your PC. Take a look at Firmata.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-03-20T21:44:15.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22032" PostTypeId="2" ParentId="10152" CreationDate="2016-03-20T22:02:46.637" Score="2" Body="&lt;p&gt;FWIW, I had packet loss issues using these boards, until I introduced those 3.3 V piggy back boards to supply current. I use them on both RX and TX now, but experimentation showed that the RX was where it made the crucial difference. Omitting the filter cap also didn't make any difference. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why these 5 V to 3.3 V piggy back boards were so effective; they're just a regulator. Maybe they've got better quality specs, or their own on board filter caps have a better frequency range for driving the nRF. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;They only cost about a $, and save so much agro.&lt;/p&gt;&#xA;" OwnerUserId="11984" LastEditorUserId="6936" LastEditDate="2016-03-25T10:59:13.300" LastActivityDate="2016-03-25T10:59:13.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22033" PostTypeId="2" ParentId="22025" CreationDate="2016-03-20T22:12:23.233" Score="1" Body="&lt;p&gt;Lua is an interpreted language. That is, the compile phase turns Lua source code into intermediate &quot;pseudo-code&quot; which the Lua interpreter then runs. It doesn't compile into machine code, and therefore there is nothing that could be uploaded to your Uno as a &quot;hex&quot; file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, with only 2 KB of RAM, it wouldn't be very practical to attempt to run Lua on a Uno. I like Lua personally, but running it on the (AVR) Arduinos just isn't practical.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-20T22:12:23.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22034" PostTypeId="1" AcceptedAnswerId="22038" CreationDate="2016-03-20T23:06:49.077" Score="1" ViewCount="2855" Body="&lt;p&gt;I imagine that the proper way to implement an RS485 multidrop bus is the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iScLl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iScLl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What happens if, in order to save cables, I connect the same 5 nodes above using this other topology?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CmvEl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CmvEl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Will it works? &lt;/li&gt;&#xA;&lt;li&gt;If no, why? &lt;/li&gt;&#xA;&lt;li&gt;If &quot;maybe&quot;, under which circumstances will it work?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.S.: yes! I know that MEGA has three Serials and, as such, I could implement two different BUSses (1: Mega&amp;lt;-&gt;Mega&amp;lt;-&gt;Mega; 2: Mega&amp;lt;-&gt;Nano&amp;lt;-&gt;Nano), but this will increase the complexity of the software I'm running, as it needs some hacking in order to play nicely with two distinct RS-485 busses;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;P.P.S.: This is the bus discussed in &lt;a href=&quot;https://arduino.stackexchange.com/questions/21932/hardware-network-infrastructure-for-a-fully-arduino-based-home-automation-projec&quot;&gt;this other question&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="13193" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-20T23:41:13.870" Title="RS485: is &quot;Y&quot; multidrop allowed?" Tags="|rs485|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22037" PostTypeId="1" AcceptedAnswerId="22039" CreationDate="2016-03-20T23:38:22.903" Score="1" ViewCount="2327" Body="&lt;p&gt;Is it possible to have two rotary potentiometers read from a single analog input pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analog input is 10 bits (0-1023), so each pot would have 5 bit precision (0-15).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Least significant bits for pot 1 and most significant bits for pot 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A SPI/I2C ADC IC (eg. MCP3008) is an option if this is not possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The two pots do not need to be read at the same time.&#xA;It seems full 10 bit precision could be achieved if I use a digital pin to enable each pot before it is read.&lt;/p&gt;&#xA;" OwnerUserId="4558" LastEditorUserId="4558" LastEditDate="2016-03-20T23:53:27.300" LastActivityDate="2016-03-21T01:37:47.680" Title="Multiplexing potentiometers" Tags="|potentiometer|adc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22038" PostTypeId="2" ParentId="22034" CreationDate="2016-03-20T23:41:13.870" Score="2" Body="&lt;p&gt;At low speeds and short distances that won't be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At high speeds (megabits per second) and long distances (hundreds of meters) you may get reflections unless you get the termination just right.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-20T23:41:13.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22039" PostTypeId="2" ParentId="22037" CreationDate="2016-03-21T00:09:32.040" Score="4" Body="&lt;p&gt;There are a few ways of doing what you want.  One would be to use an analog multiplexer as in this answer: &lt;a href=&quot;https://arduino.stackexchange.com/questions/21536/expanding-analog-inputs-to-the-arduino/21538#21538&quot;&gt;Expanding analog inputs to the Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another would be to use digital I/O pins to control the power and ground to the potentiometers.  Note that both sides of the pot need to be controlled, not just one, since any connection of one will interfere with the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you will need four IO pins - one for the +5v and one for the GND of each potentiometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r0ICy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r0ICy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example set D3 to OUTPUT and HIGH, D4 to OUTPUT and LOW, and D5 and D6 both to INPUT.  You will now be reading from the top pot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then change D3 and D4 to both be INPUT, and D5 to be OUTPUT and HIGH and D6 to be OUTPUT and LOW.  You will then be reading from the bottom pot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bit wasteful of IO pins though.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-21T00:09:32.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22040" PostTypeId="1" CreationDate="2016-03-21T00:46:36.940" Score="2" ViewCount="12888" Body="&lt;p&gt;I have an analog sensor which I want to send data from my Arduino Certified Intel Edison to PC, without using a Serial Monitor and preferably putting the data into a text file. &lt;/p&gt;&#xA;" OwnerUserId="19455" LastEditorUserId="11529" LastEditDate="2016-03-21T11:38:15.200" LastActivityDate="2016-03-25T19:52:20.760" Title="How to send data from an Arduino to PC, without using the Serial Monitor?" Tags="|serial|programming|edison|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22041" PostTypeId="2" ParentId="21895" CreationDate="2016-03-21T01:29:29.163" Score="0" Body="&lt;p&gt;I found it is was related to the physical connection!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Scenario 3, I originally had the Sparkfun TTL/RS232 adapter that had a female DB9 connector wired to the HDMI switch female DB9 connector using a male/male serial cable. The serial cable I bought was a straight through cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I swapped it out with a null modem cable and it worked right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the wiring diagram, I thought swapping the Tx/Rx pins on the Sparkfun adapter would have achieved the same result as the null modem cable, but apparently not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anybody can point out why the null modem cable made the difference, that would be something good to know for the future.&lt;/p&gt;&#xA;" OwnerUserId="19339" LastActivityDate="2016-03-21T01:29:29.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22042" PostTypeId="2" ParentId="22037" CreationDate="2016-03-21T01:37:47.680" Score="2" Body="&lt;p&gt;Building on @Majenko's answer, I think you could do the same thing, using 1 analog pin (as shown in his answer) and one digital pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than using one digital pin for each side of the each pot, you could use one transistor for each side of each pot, and then use one digital pin to switch all 4 transistors on/off at the same time, in the right combination.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-21T01:37:47.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22043" PostTypeId="1" CreationDate="2016-03-21T01:39:20.653" Score="0" ViewCount="1966" Body="&lt;p&gt;I've attached the breadboard layout and schematic of a circuit I'm constructing, which is a simple Arduino radio control car, with a 9V powering the Arduino Uno, and the 6 volt battery pack feeding power to the motors via the L293D. My question is regarding the switch where I've connected the ground from both battery power supplies to one side, and connected the ground of the circuit to the other side. Is this OK and safe to do? Is there anything I should be concerned about with this setup? Is there a safer or better way to do this? What components added or removed (if any) would improve this circuit in terms of power safety and battery longevity?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case you are wondering why I have two switches, the reason is because I wanted to debug the radio receiver using the serial monitor when I wired this to USB, but I also wanted to prevent it from powering up the motors so my project doesn't try and roll away while it's still connected to the USB cable. The switch I'm asking about in my question is sort of a mains power switch, so when it's off USB I can just flip on both switches and set the robot car free...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FEQiD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FEQiD.png&quot; alt=&quot;Fritzing wiring diagram of circuit with 9 volt and 6 volt grounds wired to same switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MhmLF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MhmLF.png&quot; alt=&quot;This is the same circuit as the previous picture, but shown in schematic format. Created with Fritzing, this shows an Arduino board wired to an L293D and two battery packs, controlled with a common switch leading to ground.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19456" LastActivityDate="2016-03-21T11:21:16.093" Title="Safe to control multiple power sources through a switch through the ground?" Tags="|arduino-uno|power|motor|battery|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22045" PostTypeId="1" CreationDate="2016-03-21T06:12:47.510" Score="5" ViewCount="15674" Body="&lt;p&gt;I'd like to power my Arduino circuit like a smartphone. That is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When the device is unplugged, power by rechargeable battery&lt;/li&gt;&#xA;&lt;li&gt;When the device is plugged in, power by mains and charge battery at the same time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'd like to not go the expensive shield route and instead purchase some inexpensive breakout boards from Aliexpress or eBay if possible. I'm willing to put in the time to learn if someone will point the way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please provide some guidance?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2017-07-08T09:23:12.970" Title="How to power an Arduino using automated mains/rechargeable battery switching?" Tags="|power|battery|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22046" PostTypeId="2" ParentId="22045" CreationDate="2016-03-21T07:40:57.100" Score="3" Body="&lt;p&gt;There are many ways you can do this, as you mention there are ready made shields that do this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to take a few thing into consideration:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Power - how much power will your cirquit be drawing, as many of these boards will only be able to deliver 3-600mah is this enough, at the same time you will find out how long your cirquit will be able to stay on battery power. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Complexity - a ready made controller/charger is already made to work togheter, if you go for a separate charger and booster module you might end up with unwanted power loss, or you need ekstra buttons/sliders to control power.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You could in theory use 1 lipo cell directly to power your MCU, as the voltage spans from 3,6 to 4,7 Volts pr.cell and charge the lipo when NOT in use (you cannot charge a lipo directly while in use, thats why you need a controller). This would be the cheapest way.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-21T07:40:57.100" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22047" PostTypeId="2" ParentId="21583" CreationDate="2016-03-21T07:43:11.117" Score="0" Body="&lt;p&gt;The answer was simply that 6-pin are not designed for uploading sketches. Instead use the micro-USB port to upload sketches.&lt;/p&gt;&#xA;" OwnerUserId="19088" LastActivityDate="2016-03-21T07:43:11.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22048" PostTypeId="1" CreationDate="2016-03-21T10:21:05.263" Score="2" ViewCount="40" Body="&lt;p&gt;vrdude stk 500 not responding error inspeed control of dc motor using arduino uno board  .how to solve this issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oA2j0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oA2j0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PgcVq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PgcVq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19462" LastActivityDate="2016-03-21T10:21:05.263" Title="vrdude stk 500 not responding error inspeed control of dc motor using arduino uno board .how to solve this issue" Tags="|arduino-uno|interrupt|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22051" PostTypeId="1" CreationDate="2016-03-21T10:44:30.057" Score="2" ViewCount="511" Body="&lt;p&gt;I am using Arduino Pro Mini to get GPS info from a u-blox NEO-M8N chip and display it on a Adafruit OLED display. NEO-M8N has a PPS(pulse per second) output which is aligned to GPS's second. Because UART and deserialization is slow, I use PPS signal to make time displays more accurately. The PPS(time pulse) signal and UART message are coming like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PrmLU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PrmLU.png&quot; alt=&quot;TIMEPULSE and Serial Data&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On my Arduino, SoftwareSerial RX/TX is on pin 7/8 (but only use pin 7 because Arduino has no message to send to NEO-M8N), and the interrupt(PPS) is on pin 2. If I just connect pin 7, display update once per second as intended; if I just connect pin 2, time increased by one second per second as intended. BUT if connect them both, &lt;code&gt;((&lt;/code&gt;time will increased more than one second per second&lt;code&gt;)&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt; &lt;code&gt;processGPS()&lt;/code&gt; will lost sync with upcoming UBX(u-blox message format) message&lt;code&gt;))&lt;/code&gt; occasionally. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the entire code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Adafruit_SSD1306.h&amp;gt;&#xA;&#xA;#define OLED_RESET 9&#xA;Adafruit_SSD1306 display(OLED_RESET);&#xA;&#xA;#if (SSD1306_LCDHEIGHT != 64)&#xA;#error(&quot;Height incorrect, please fix Adafruit_SSD1306.h!&quot;);&#xA;#endif&#xA;&#xA;&#xA;// Connect the GPS RX/TX to arduino pins 7 and 8&#xA;SoftwareSerial S_Serial = SoftwareSerial(7,8);&#xA;int intpin = 2;&#xA;volatile int state = LOW;&#xA;&#xA;const unsigned char UBX_HEADER[] = { 0xB5, 0x62 };&#xA;&#xA;struct NAV_PVT {&#xA;  unsigned char cls;&#xA;  unsigned char id;&#xA;  unsigned short len;&#xA;  unsigned long iTOW;&#xA;  unsigned short year;&#xA;  byte month;&#xA;  byte day;&#xA;  byte hour;&#xA;  byte miniute;&#xA;  byte sec;&#xA;  unsigned char valid;&#xA;  unsigned long tAcc;&#xA;  long nano;&#xA;  byte fixType;&#xA;  unsigned char flag;&#xA;  unsigned char flag2;&#xA;  byte numSV;&#xA;  long lon;&#xA;  long lat;&#xA;  long height;&#xA;  long hMSL;&#xA;  unsigned long hAcc;&#xA;  unsigned long vAcc;&#xA;  long velN;&#xA;  long velE;&#xA;  long velD;&#xA;  long gSpeed;&#xA;  long headMot;&#xA;  unsigned long sAcc;&#xA;  unsigned long headAcc;&#xA;  unsigned short pDop;&#xA;  byte reserved1[6];&#xA;  long headVeh;&#xA;  byte reserved2[4];&#xA;};&#xA;&#xA;NAV_PVT pvt;&#xA;&#xA;void calcChecksum(unsigned char* CK) {&#xA;  memset(CK, 0, 2);&#xA;  for (int i = 0; i &amp;lt; (int)sizeof(NAV_PVT); i++) {&#xA;    CK[0] += ((unsigned char*)(&amp;amp;pvt))[i];&#xA;    CK[1] += CK[0];&#xA;  }&#xA;}&#xA;&#xA;bool processGPS() {&#xA;  static int fpos = 0;&#xA;  static unsigned char checksum[2];&#xA;  const int payloadSize = sizeof(NAV_PVT);&#xA;&#xA;  while ( S_Serial.available() ) {&#xA;    byte c = S_Serial.read();&#xA;    if ( fpos &amp;lt; 2 ) { //SYNC&#xA;      if ( c == UBX_HEADER[fpos] )&#xA;        fpos++;&#xA;      else&#xA;        fpos = 0;&#xA;    }&#xA;    else {&#xA;      if ( (fpos-2) &amp;lt; payloadSize )&#xA;        ((unsigned char*)(&amp;amp;pvt))[fpos-2] = c;&#xA;&#xA;      fpos++;&#xA;&#xA;      if ( fpos == (payloadSize+2) ) {&#xA;        calcChecksum(checksum);&#xA;      }&#xA;      else if ( fpos == (payloadSize+3) ) {&#xA;        if ( c != checksum[0] )&#xA;          fpos = 0;&#xA;      }&#xA;      else if ( fpos == (payloadSize+4) ) {&#xA;        fpos = 0;&#xA;        if ( c == checksum[1] ) {&#xA;          return true;&#xA;        }&#xA;      }&#xA;      else if ( fpos &amp;gt; (payloadSize+4) ) {&#xA;        fpos = 0;&#xA;      }&#xA;    }&#xA;  }&#xA;  return false;&#xA;}&#xA;&#xA;void pps()&#xA;{&#xA;  state=!state;&#xA;}&#xA;&#xA;void PrintScreen()&#xA;{&#xA;  display.clearDisplay();&#xA;&#xA;  //Size 2&#xA;  display.setTextSize(2);&#xA;  display.setTextColor(WHITE);&#xA;  display.setCursor(0,0);&#xA;  float sik = (pvt.gSpeed / 100) / 3.6f;&#xA;  if (sik&amp;lt;100)&#xA;    display.print(&quot; &quot;);&#xA;  if (sik&amp;lt;10)&#xA;    display.print(&quot; &quot;);&#xA;  display.print(sik,1);//SpeedInKph&#xA;  display.setCursor(84,0);&#xA;  if (pvt.numSV&amp;lt;10)&#xA;    display.print(&quot; &quot;);&#xA;  display.print(pvt.numSV);//SV&#xA;&#xA;  //Size 1&#xA;  display.setTextSize(1);&#xA;  display.setCursor(60,8);&#xA;  display.print(&quot;km/h&quot;);&#xA;  display.setCursor(63,0);&#xA;  display.print(&quot;CHL&quot;);&#xA;  display.setCursor(108,8);&#xA;  display.print(&quot;SVs&quot;);&#xA;  display.setCursor(108,0);&#xA;  switch (pvt.fixType){&#xA;    case 0:&#xA;      display.print(&quot;N.F&quot;);&#xA;      break;&#xA;    case 2:&#xA;      display.print(&quot;2D&quot;);&#xA;      break;&#xA;    case 3:&#xA;      display.print(&quot;3D&quot;);&#xA;      if ((byte)pvt.flag &amp;amp; 2)&#xA;        display.print(&quot;+&quot;);&#xA;      break;&#xA;    default:&#xA;      display.print(&quot;INV&quot;);&#xA;      break;&#xA;  }&#xA;&#xA;&#xA;&#xA;  long  temp;&#xA;  //Line 1&#xA;  display.setCursor(0,16);&#xA;  if (pvt.lat &amp;gt;= 0)&#xA;    temp = pvt.lat;&#xA;  else&#xA;    temp = -pvt.lat;&#xA;  if (temp &amp;gt;= 1000000000)&#xA;    display.print(&quot;lat:&quot;);&#xA;  else &#xA;    if (temp &amp;gt;= 100000000)&#xA;      display.print(&quot;lat: &quot;);&#xA;    else&#xA;      display.print(&quot;lat:  &quot;);&#xA;  display.print(temp / 10000000);display.print(&quot;.&quot;);&#xA;  long temp2 = 1000000;&#xA;  temp = temp % 10000000;&#xA;  while ((temp / temp2 == 0)&amp;amp;&amp;amp;(temp2&amp;gt;1))&#xA;  {&#xA;    display.print(&quot;0&quot;);&#xA;    temp2 /= 10;&#xA;  }&#xA;  display.print(temp);&#xA;  if (pvt.lat &amp;gt;= 0)&#xA;    display.print(&quot;N&quot;);&#xA;  else&#xA;    display.print(&quot;S&quot;);&#xA;  temp = 10000;&#xA;  while (((pvt.pDop / temp) == 0)&amp;amp;&amp;amp;(temp&amp;gt;1))&#xA;  {&#xA;    display.print(&quot; &quot;);&#xA;    temp /= 10;&#xA;  }&#xA;  display.println(pvt.pDop);&#xA;&#xA;  //Line2&#xA;  if (pvt.lon &amp;gt;= 0)&#xA;    temp = pvt.lon;&#xA;  else&#xA;    temp = -pvt.lon;&#xA;  if (temp &amp;gt;= 1000000000)&#xA;    display.print(&quot;lon:&quot;);&#xA;  else &#xA;    if (temp &amp;gt;= 100000000)&#xA;      display.print(&quot;lon: &quot;);&#xA;    else&#xA;      display.print(&quot;lon:  &quot;);&#xA;  display.print(temp / 10000000);display.print(&quot;.&quot;);&#xA;  temp2 = 1000000;&#xA;  temp = temp % 10000000;&#xA;  while ((temp / temp2 == 0)&amp;amp;&amp;amp;(temp2&amp;gt;1))&#xA;  {&#xA;    display.print(&quot;0&quot;);&#xA;    temp2 /= 10;&#xA;  }&#xA;  display.print(temp);&#xA;  if (pvt.lon &amp;gt;= 0)&#xA;    display.print(&quot;E&quot;);&#xA;  else&#xA;    display.print(&quot;W&quot;);&#xA;  display.println(&quot; HEAD&quot;);&#xA;&#xA;  //Line3&#xA;  display.print(&quot;hMSL:&quot;);&#xA;  if (pvt.hMSL &amp;lt; 0)&#xA;    pvt.hMSL = -pvt.hMSL;&#xA;  temp = 10000000;&#xA;  while (((pvt.hMSL / temp) == 0)&amp;amp;&amp;amp;(temp&amp;gt;1000))&#xA;  {&#xA;    display.print(&quot; &quot;);&#xA;    temp /= 10;&#xA;  }&#xA;  display.print((pvt.hMSL % 100000000) / 1000);display.print(&quot;.&quot;);&#xA;  if ((pvt.hMSL % 1000) &amp;lt; 100)&#xA;    display.print(&quot;0&quot;);&#xA;  if ((pvt.hMSL % 1000) &amp;lt; 10)&#xA;    display.print(&quot;0&quot;);&#xA;  display.print(pvt.hMSL % 1000);&#xA;  display.print(&quot;|&quot;);&#xA;  temp = pvt.headMot / 100000;&#xA;  if (temp &amp;lt; 100)&#xA;    display.print(&quot; &quot;);&#xA;  if (temp &amp;lt; 10)&#xA;    display.print(&quot; &quot;);&#xA;  display.print(temp);display.print(&quot;.&quot;);&#xA;  temp2 = (pvt.headMot%100000)/1000;&#xA;  if (temp2&amp;lt;0)&#xA;    temp2 = -temp2;&#xA;  if (temp2&amp;lt;10)&#xA;    display.print(&quot;0&quot;);&#xA;  display.println(temp2);&#xA;&#xA;  //Line4&#xA;  display.print(&quot;h,vAcc:&quot;);&#xA;  if (pvt.hAcc &amp;gt;= 100000)&#xA;    display.print(&quot;  &amp;gt;100&quot;);&#xA;  else&#xA;  {&#xA;    display.print(pvt.hAcc / 1000);display.print(&quot;.&quot;);&#xA;    if (pvt.hAcc % 1000 &amp;lt; 100)&#xA;      display.print(&quot;0&quot;);&#xA;    if (pvt.hAcc % 1000 &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.hAcc % 1000);&#xA;  }&#xA;  display.print(&quot;,&quot;);&#xA;  if (pvt.vAcc &amp;gt;= 100000)&#xA;    display.print(&quot; &amp;gt;100&quot;);&#xA;  else&#xA;  {&#xA;    display.print(pvt.vAcc / 1000);display.print(&quot;.&quot;);&#xA;    if (pvt.vAcc%1000 &amp;lt; 100)&#xA;      display.print(&quot;0&quot;);&#xA;    if (pvt.vAcc%1000 &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.vAcc%1000);&#xA;  }&#xA;  display.println(&quot;m&quot;);&#xA;&#xA;  //Line5&#xA;  display.print(&quot;V:&quot;);&#xA;  if (pvt.gSpeed &amp;lt; 1000000)&#xA;    display.print(&quot; &quot;);&#xA;  if (pvt.gSpeed &amp;lt; 100000)&#xA;    display.print(&quot; &quot;);&#xA;  if (pvt.gSpeed &amp;lt; 10000)&#xA;    display.print(&quot; &quot;);&#xA;  display.print((pvt.gSpeed % 10000000)/1000);display.print(&quot;.&quot;);&#xA;  if (pvt.gSpeed % 1000 &amp;lt; 100)&#xA;    display.print(&quot;0&quot;);&#xA;  if (pvt.gSpeed % 1000 &amp;lt; 10)&#xA;    display.print(&quot;0&quot;);&#xA;  display.print(pvt.gSpeed % 1000);&#xA;  display.print(&quot;m/s&quot;);&#xA;  if (pvt.sAcc &amp;lt; 1000000)&#xA;  {&#xA;    if (pvt.sAcc &amp;lt; 100000)&#xA;      display.print(&quot; &quot;);&#xA;    if (pvt.sAcc &amp;lt; 10000)&#xA;      display.print(&quot; &quot;);&#xA;    display.print(&quot;~&quot;);&#xA;    display.print(pvt.sAcc / 1000);display.print(&quot;.&quot;);&#xA;    if (pvt.sAcc % 1000 &amp;lt; 100)&#xA;      display.print(&quot;0&quot;);&#xA;    if (pvt.sAcc % 1000 &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.println(pvt.sAcc % 1000);&#xA;  }&#xA;  else&#xA;  display.println(&quot; ~&amp;gt;100&quot;);&#xA;&#xA;  //Line6&#xA;  if ((pvt.year&amp;lt;10000)&amp;amp;&amp;amp;(pvt.year&amp;gt;=1000))&#xA;    display.print(pvt.year);&#xA;  else&#xA;    display.print(&quot;????&quot;);&#xA;  display.print(&quot;/&quot;);&#xA;  if ((pvt.month&amp;lt;=12)&amp;amp;&amp;amp;(pvt.month&amp;gt;=1))&#xA;  {&#xA;    if (pvt.month &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.month);&#xA;  }&#xA;  else&#xA;    display.print(&quot;??&quot;);&#xA;  display.print(&quot;/&quot;);&#xA;  if ((pvt.day&amp;lt;=31)&amp;amp;&amp;amp;(pvt.day&amp;gt;=1))&#xA;  {&#xA;    if (pvt.day &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.day);&#xA;  }&#xA;  else&#xA;    display.print(&quot;??&quot;);&#xA;  if (pvt.valid &amp;amp; 0x04)&#xA;    display.print(&quot;UTC&quot;);&#xA;  else&#xA;    display.print(&quot;INV&quot;);&#xA;  if ((pvt.hour&amp;lt;=23)&amp;amp;&amp;amp;(pvt.hour&amp;gt;=0))&#xA;  {&#xA;    if (pvt.hour &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.hour);&#xA;  }&#xA;  else&#xA;    display.print(&quot;??&quot;);&#xA;  display.print(&quot;:&quot;);&#xA;  if ((pvt.miniute&amp;lt;=59)&amp;amp;&amp;amp;(pvt.miniute&amp;gt;=0))&#xA;  {&#xA;    if (pvt.miniute &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.miniute);&#xA;  }&#xA;  else&#xA;    display.print(&quot;??&quot;);&#xA;  display.print(&quot;:&quot;);&#xA;  if ((pvt.sec&amp;lt;=60)&amp;amp;&amp;amp;(pvt.sec&amp;gt;=0))&#xA;  {&#xA;    if (pvt.sec &amp;lt; 10)&#xA;      display.print(&quot;0&quot;);&#xA;    display.print(pvt.sec);&#xA;  }&#xA;  else&#xA;    display.print(&quot;??&quot;);&#xA;&#xA;  display.display();&#xA;}&#xA;&#xA;void PrintSec()&#xA;{&#xA;  pvt.sec = (pvt.sec + 1)%60;&#xA;  display.fillRect(114,56,12,8,BLACK);&#xA;  display.setCursor(114,56);&#xA;  if (pvt.sec&amp;lt;10)&#xA;    display.print(&quot;0&quot;);&#xA;  display.println(pvt.sec);&#xA;  display.display();&#xA;  state = LOW;&#xA;}&#xA;&#xA;void setup() &#xA;{&#xA;  S_Serial.begin(9600);&#xA;  pinMode(intpin, INPUT);&#xA;  attachInterrupt(digitalPinToInterrupt(intpin), pps, RISING);&#xA;  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)&#xA;  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  &#xA;  // init done&#xA;}&#xA;&#xA;void loop() {&#xA;  if (state == HIGH)&#xA;    PrintSec();&#xA;  if ( processGPS() ) &#xA;    PrintScreen();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found a similar issue &lt;a href=&quot;https://stackoverflow.com/questions/18343058/interrupt-service-routine-executes-twice-atmega88&quot;&gt;here&lt;/a&gt; (Interrupt Service Routine Executes Twice ATmega88), but since ISR only executes once if I connect pin 2 alone, I think the cause might be something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it a software issue or a hardware issue? How to fix it?&lt;/p&gt;&#xA;" OwnerUserId="19460" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2018-05-11T17:53:44.727" Title="ISR executes twice if data coming through SoftwareSerial" Tags="|interrupt|softwareserial|arduino-pro-mini|isr|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22052" PostTypeId="2" ParentId="22051" CreationDate="2016-03-21T11:21:06.707" Score="0" Body="&lt;p&gt;If i understand you correctly you have 2 ways that increase your seconds, &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;when software serial receives data &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When PPM pin goes high&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And when each of theese are run separately things work, but when you use them together seconds increase by 2 each time ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;wouldnt this suggest that your program only should use one of theese to increase your seconds.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-21T11:21:06.707" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22053" PostTypeId="2" ParentId="22043" CreationDate="2016-03-21T11:21:16.093" Score="1" Body="&lt;p&gt;You have the grounds of the batteries permanently connected together, so opening the switch won't remove them from the circuit altogether: it will leave a potential difference of 3v between the Arduino's power input at the L293's power input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That would be exactly equivalent to having a 3v battery with its +ve terminal connected to the Arduino power input, and its -ve connected to the L293's power input, with their grounds connected together - so they're sort of wired in series, with one of them backwards, with a far-too-small supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;suspect&lt;/em&gt; it won't kill anything but I would imagine it would drain the batteries and probably isn't what you want to do.&lt;/p&gt;&#xA;" OwnerUserId="16085" LastActivityDate="2016-03-21T11:21:16.093" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22054" PostTypeId="1" CreationDate="2016-03-21T11:35:08.137" Score="0" ViewCount="125" Body="&lt;p&gt;I recently purchased the &lt;a href=&quot;http://www.arduino.org/products/shields/5-arduino-shields/arduino-9-axes-motion-shield&quot; rel=&quot;nofollow&quot;&gt;Arduino 9-Axes Motion Shield&lt;/a&gt;. I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q1. The official Arduino page says that the shield doesn't have any external power source and can only be powered up by stacking on top of an Arduino board. How can I use this shield with a Raspberry Pi?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Q2. A page &lt;a href=&quot;http://www.mouser.in/new/arduino/arduino-9-axes/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; shows that it has support for the Ethernet Shield but doesn't mention WiFi shield anywhere. Does this mean that I cannot use my WiFi shield with it? I plan to stack the 9-axes shield on top of the WiFi shield which in turn is stacked over Arduino Uno.&lt;/p&gt;&#xA;" OwnerUserId="18846" LastActivityDate="2016-03-21T12:12:44.020" Title="Interfacing 9-Axes Motion Shield with RPi and WiFi Shield" Tags="|sensors|wifi|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22055" PostTypeId="2" ParentId="22040" CreationDate="2016-03-21T11:59:09.133" Score="0" Body="&lt;p&gt;There are a couple of ways you can communicate between a &quot;Arduino' and a &quot;PC&quot;*.    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1)Serial communication.&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A serial port on your system is created and a program that reads and writes to the serial port is used as communication.&lt;br&gt;&#xA;A program that does this is the &quot;serial monitor&quot; which comes in many flavours.&lt;br&gt;&#xA;In linux dumping serial monitor incoming data to a file is as easy as:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat /dev/ttyS0&amp;gt; myFile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2)Bluetooth (LE)&lt;/strong&gt;&lt;br&gt;&#xA;Bluetooth is a low energy consuming protocol that is commonly used for communication between a PC and a &quot;device&quot;. The LE uses even less energy.&#xA;I'm not aware of any &quot;official Arduino&quot; boards that contain the hardware for Bluetooth on board.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3) Network&lt;/strong&gt;&lt;br&gt;&#xA;Today network equals to WIFI of tcpip. These methods allow for huge distances between the pc and the device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of these methods the serial communication over USB is the best know because -in Arduino world- this method is most commonly used to upload the &quot;sketch&quot; to the  &quot;Arduino&quot;. As such all hardware is commonly available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*I put quotes around Arduino and PC because in perspective of this answer both arduino and PC are to be interpreted as a device containing a cpu.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-21T11:59:09.133" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22056" PostTypeId="2" ParentId="22054" CreationDate="2016-03-21T12:12:44.020" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Q1. The official Arduino page says that the shield doesn't have any external power source and can only be powered up by stacking on top of an Arduino board. How can I use this shield with a Raspberry Pi?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;By providing the right power to the right pins.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q2. A page here shows that it has support for the Ethernet Shield but doesn't mention WiFi shield anywhere. Does this mean that I cannot use my WiFi shield with it? I plan to stack the 9-axes shield on top of the WiFi shield which in turn is stacked over Arduino Uno.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it says it is compatible with the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;Arduino Ethernet&lt;/em&gt;&lt;/a&gt; which is not a shield, it is an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What other shields you can use it with depends on what pins those other shields use.  Look at the schematics. Read the manuals. Do some leg-work.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-21T12:12:44.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22057" PostTypeId="1" CreationDate="2016-03-21T12:47:24.657" Score="0" ViewCount="1439" Body="&lt;p&gt;When I plug the USB cable to my Arduino and try to upload a sketch I get thtis error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: ser_open(): can't open device &quot;/dev/cu.usbmodem1411&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when I go to Tools &gt; ports I can't find the USB port.&#xA;The Arduino still working and green ligh is on, so what is the problem exactly?&lt;/p&gt;&#xA;" OwnerUserId="19468" LastActivityDate="2018-03-18T12:18:14.810" Title="Not sure if my Arduino Uno is damaged" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22058" PostTypeId="2" ParentId="22057" CreationDate="2016-03-21T13:05:59.683" Score="2" Body="&lt;p&gt;Have heard of similar problems with Mac. Not a Mac user myself. Sometimes the Arduino can somehow trigger a current fault in the USB of Mac's and will need to be shut down and rebooted for it to work again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try rebooting your Mac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a cheap chinese Arduino you might need other drivers for it. Check what chip you have closest to the usb connector.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-21T13:05:59.683" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22059" PostTypeId="1" CreationDate="2016-03-21T13:11:55.730" Score="2" ViewCount="394" Body="&lt;p&gt;I am trying to communicate with a serial port trought matlab. This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete (instrfindall)&#xA;clear all&#xA;close all&#xA;clc; &#xA;&#xA;s=serial('COM4');&#xA;set(s,'BaudRate',4800);&#xA;set(s,'DataBits',8);&#xA;set(s, 'Parity','none');&#xA;set(s,'StopBits',1);&#xA;set(s, 'FlowControl','none');&#xA;set(s,'Terminator','CR');&#xA;set(s,'TimeOut',5000); &#xA;&#xA;fopen(s)&#xA;%Move the probe radial&#xA;fprintf(s,'%s','RADIAL=100');&#xA;&#xA;out=fgets(s);&#xA;&#xA;fclose (s)&#xA;delete (s)&#xA;clear (s)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But i cannot make the serial port to answer me. &#xA;Can you help me? Is this code right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards,&lt;/p&gt;&#xA;" OwnerUserId="19469" LastActivityDate="2016-03-21T13:11:55.730" Title="Communication serial port with matlab" Tags="|serial|communication|matlab|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22063" PostTypeId="1" AcceptedAnswerId="22064" CreationDate="2016-03-21T15:59:43.800" Score="0" ViewCount="162" Body="&lt;p&gt;I am trying to make a human detection robot using D6T omron thermal sensor. However, I am facing some problem here. My Arduino Uno didn't run the sketches until I open up my GUI in processing. The tx/rx pin did not light up when I remove my USB serial cable from my PC and put in an external power supply to my arduino uno board. The tx/rx pin will only light up when I open my GUI in processing and everything works just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to move my robot away from my PC. Therefore, it is a must for me to provide my board an external power supply but it just does not work. I am confused here. Fyi, it will be interfacing with my PC thru Xbee in the near future. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps: this is my final year project. Your effort will be much appreciated and credits will goes to you. Thanks guys!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code (Arduino sketch):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define E_right 10&#xA;#define E_left 11&#xA;&#xA;int RightMotorForward = 9; // Pin 10 has Left Motor connected on Arduino boards.&#xA;int RightMotorReverse = 8; // Pin 9 has Left Motor connected on Arduino boards.&#xA;&#xA;int LeftMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.&#xA;int LeftMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards.&#xA;&#xA;float top_sum, bottom_sum, left_sum, right_sum, center_row_sum;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;WireExt.h&amp;gt;&#xA;&#xA;#define D6T_addr 0x0A&#xA;#define D6T_cmd 0x4C&#xA;&#xA;int rbuf[35];&#xA;float tdata[16];&#xA;float t_PTAT;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.flush();&#xA;  pinMode(E_right, OUTPUT);&#xA;  pinMode(E_left, OUTPUT);&#xA;  pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.&#xA;  pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.&#xA;  pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.&#xA;  pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.&#xA;}&#xA;//-----------------------------------------------------------------------------  &#xA;&#xA;// The following Loop is to make the Robot move towards heat source.&#xA;void loop()&#xA;{&#xA;int i;&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {     &#xA;    int inByte = Serial.read();     &#xA;    if (inByte == 0x0001) {         &#xA;&#xA;      Wire.beginTransmission(D6T_addr);&#xA;      Wire.write(D6T_cmd);&#xA;      Wire.endTransmission();&#xA;&#xA;      if (WireExt.beginReception(D6T_addr) &amp;gt;= 0) {&#xA;        i = 0;&#xA;        for (i = 0; i &amp;lt; 35; i++) {&#xA;          rbuf[i] = WireExt.get_byte();&#xA;        }&#xA;        WireExt.endReception();&#xA;&#xA;        t_PTAT = (rbuf[0]+(rbuf[1]&amp;lt;&amp;lt;8))*0.1;&#xA;        for (i = 0; i &amp;lt; 16; i++) {&#xA;          tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]&amp;lt;&amp;lt;8))*0.1;&#xA;        }&#xA;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;&#xA;top_sum= tdata[0] + tdata[1] + tdata[2] + tdata[3];&#xA;bottom_sum= tdata[12] + tdata[13] + tdata[14] + tdata[15];&#xA;right_sum= tdata[0]+ tdata[4] + tdata[8] + tdata[12];&#xA;left_sum= tdata[3] + tdata[7] + tdata[11] + tdata[15];&#xA;center_row_sum= tdata[1] + tdata[2] + tdata[5] + tdata[6] + tdata[9] + tdata[10] + tdata[13] + tdata[14];&#xA;&#xA;&#xA;&#xA;if ((left_sum&amp;gt;center_sum)&amp;amp;&amp;amp; (center_sum&amp;gt;right_sum))&#xA;{&#xA;   analogWrite(E_right, 230); &#xA;   analogWrite(E_left, 205); &#xA;&#xA;   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON&#xA;   digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor OFF&#xA;                  // wait for  0.5 seconds&#xA;   delay(500);&#xA;   //turn left&#xA;}&#xA;&#xA;else if ((right_sum&amp;gt;center_sum)&amp;amp;&amp;amp;(center_sum&amp;gt;left_sum))&#xA;{&#xA;   analogWrite(E_right, 230); &#xA;   analogWrite(E_left, 205); &#xA;&#xA;   digitalWrite(RightMotorForward, LOW);   // turn the Right Motor OFF&#xA;   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON&#xA;   // wait for  0.5 seconds&#xA;   delay(500);&#xA;   //turn right&#xA;}&#xA;else if ((center_row_sum&amp;gt;right_sum)&amp;amp;&amp;amp;(center_row_sum&amp;gt;left_sum))&#xA;{&#xA;&#xA;   analogWrite(E_right, 230); &#xA;   analogWrite(E_left, 205); &#xA;&#xA;   digitalWrite(RightMotorForward, HIGH);   // turn the Right Motor ON&#xA;   digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ON&#xA;   delay(500); //forward&#xA;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code in processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;&#xA;float[] tdata = new float[17]; &#xA;float tptat; // PTAT&#xA;String portName; &#xA;//int serialport = 0; &#xA;&#xA;String buf; &#xA;float colourGreen; //change green in relation to temperature &#xA;&#xA;int lbTemp = 25; //lowest relative temperature&#xA;int hbTemp = 35; //highest relative temperature &#xA;Serial myPort;  // Create object from Serial class&#xA;&#xA;void setup() {&#xA;  size(640,640);&#xA;  //println(Serial.list());&#xA;  //portName = Serial.list()[serialport];&#xA;  myPort = new Serial(this, &quot;COM7&quot;, 9600);&#xA;  myPort.clear();&#xA;&#xA;}&#xA;void draw() {&#xA;  myPort.write(0x01); &#xA;  delay(100); &#xA;  while (myPort.available() &amp;gt; 0) { &#xA;    delay(300); &#xA;    buf = myPort.readString(); &#xA;    myPort.clear();  &#xA;    tdata = float(split(buf, ','));  &#xA;    for (int i = 0; i &amp;lt;16; i++) { &#xA;      colourGreen = map(tdata[i],lbTemp,hbTemp,255,0);&#xA;fill (255,colourGreen,0);&#xA;&#xA;      if (i == 0)&#xA;    { rect(480,0,160,160);}&#xA;      else if (i == 1)&#xA;    { rect(320,0,160,160);}&#xA;      else if (i == 2)&#xA;    { rect(160,0,160,160);}&#xA;      else if (i == 3)&#xA;    { rect(0,0,160,160);}&#xA;      else if (i == 4)&#xA;    { rect(480,160,160,160);}&#xA;      else if (i == 5)&#xA;    { rect(320,160,160,160);}&#xA;      else if (i == 6)&#xA;    { rect(160,160,160,160);}&#xA;      else if (i == 7)&#xA;    { rect(0,160,160,160);}&#xA;      else if (i == 8)&#xA;    { rect(480,320,160,160);}&#xA;      else if (i == 9)&#xA;    { rect(320,320,160,160);}&#xA;      else if (i == 10)&#xA;    { rect(160,320,160,160);}&#xA;      else if (i == 11)&#xA;    { rect(0,320,160,160);}&#xA;      else if (i == 12)&#xA;    { rect(480,480,160,160);}&#xA;      else if (i == 13)&#xA;    { rect(320,480,160,160);}&#xA;      else if (i == 14)&#xA;    { rect(160,480,160,160);}&#xA;      else&#xA;    { rect(0,480,160,160); }&#xA;&#xA;    if (tdata[i]&amp;lt;5) {fill(255);} else {fill(0);}&#xA;      if (i ==0)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),560, 80);}&#xA;      else if (i == 1)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),400, 80);&#xA;      }&#xA;      else if (i == 2)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 240, 80);&#xA;      }&#xA;      else if (i == 3)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),80, 80); &#xA;      }&#xA;      else if (i == 4)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 560, 240); &#xA;      }&#xA;      else if (i == 5)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 400, 240);  &#xA;      }&#xA;      else if (i == 6)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 240, 240);  &#xA;      }&#xA;      else if (i == 7)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 80, 240); &#xA;      }&#xA;      else if (i == 8)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 560, 400);&#xA;      }&#xA;      else if (i == 9)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 400, 400);  &#xA;      }&#xA;      else if (i == 10)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 240, 400);&#xA;      }&#xA;      else if (i == 11)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 80, 400);&#xA;      }&#xA;      else if (i == 12)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 560, 560);  &#xA;      }&#xA;      else if (i == 13)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 400, 560); &#xA;      }&#xA;      else if (i == 14)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 240, 560);&#xA;      }&#xA;      else&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 80, 560);  &#xA;      }&#xA;    }&#xA;    delay(800);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19475" LastEditorUserId="19515" LastEditDate="2016-03-22T20:03:43.573" LastActivityDate="2016-03-22T20:03:43.573" Title="Arduino sketch won't run until I open up GUI in processing" Tags="|arduino-uno|i2c|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22064" PostTypeId="2" ParentId="22063" CreationDate="2016-03-21T16:11:17.903" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My Arduino Uno didn't run the sketches until I open up my GUI in processing. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How do you know?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The tx/rx pin did not light up when I remove my USB serial cable from my PC and put in an external power supply to my arduino uno board. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is because the TX/RX LEDs are linked to the USB interface chip. With no USB connection there can be no lights.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The tx/rx pin will only light up when I open my GUI in processing and everything works just fine.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is because there is USB communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your sketch is running fine. However your sketch looks to be wrong.  Major portions of it (i.e., the portion that does any detection at all) relies on serial data coming in.  How can you have it working, in that case, if you disconnect the serial interface so that no data ever comes in?&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-21T16:11:17.903" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22066" PostTypeId="1" AcceptedAnswerId="22067" CreationDate="2016-03-21T17:02:29.617" Score="2" ViewCount="910" Body="&lt;p&gt;I am looking to power a Trinket Pro 5V microcontroller using a 9V voltage source. I have logic running on this controller to gather the data from an accelerometer (powered off of the 5V pin on the controller) and output it to three strands of 21 RGB LEDs (&lt;a href=&quot;https://www.adafruit.com/products/1655&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1655&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;RGB LEDs cannot exceed a power source of 5V and after passing through the Trinket voltage regulator the 5V pin on the Trinket just does not have enough power for all three strands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, advise on the appropriate hardware for this case. What is the maximum voltage that RGB LEDs can handle and how does the schematic look on the protoboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your expertise.&lt;/p&gt;&#xA;" OwnerUserId="15366" LastActivityDate="2016-03-21T20:18:59.463" Title="Two voltage sources on the same circuit" Tags="|arduino-uno|power|voltage-level|rgb-led|voltage-protection|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22067" PostTypeId="2" ParentId="22066" CreationDate="2016-03-21T17:22:48.190" Score="1" Body="&lt;p&gt;First of all: 9V means that you are using a 9V &quot;transistor&quot; battery (like &lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/8/8d/Duracell_9_Volt_0849.jpg&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;), right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so it won't last very long: I suggest you to use a different approach (e.g. four AA batteries in series).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your question, I couldn't find the power consumption for these leds. Try to measure it yourself, setting the max brightness and white color. I think that, anyway, the max current for each LED should be 60mA (20mA for each color). This means that each strand absorbs 1.2A (quite a lot!).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This power requires you to use at least a switching regulator. I always used some small modules I found on ebay (they have a LM2596 IC, so just search LM2596 on ebay to find them). They are rated for 3A, so you should put at least two of them (1.2 * 3 strands = 3.6A &gt; 3A).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The connections are quite straightforward: the board has four pins: IN+, IN-, OUT+ and OUT-. IN+ of all the modules go to the positive terminal of the battery, IN- and OUT- of all the modules go to the common ground node (negative terminal of trinket, battery and leds), OUT+ is the 5V regulated output. Oh, by the way, they are adjustable modules, so BEFORE ATTACHING THE LEDS use a multimeter to set the correct voltage (if you attach the leds without regulating the voltage you can destroy them).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you will have a lot of current left on the second module, you can power the trinket from there (so you will not waste a lot of power).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last thought: 9V batteries usually have a capacity of around 600mAh; if you use one of them with the switching modules and drain 4A from the 5V your battery will last 0.6Ah / 4A * 9/5 = 0.27h = 16 minutes; if you switch to 4 AA batteries (around 2000mAh) it will last 2Ah / 4A * 6/5 = 0.6h = 36 minutes. More than double (calculations made rounding up the power drained by 21 leds set at max brightness and white color)&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-21T17:22:48.190" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22068" PostTypeId="2" ParentId="22066" CreationDate="2016-03-21T17:32:02.483" Score="1" Body="&lt;p&gt;According to the link you supply you might either receive the WS2812 or the SK6812, datasheet on Ws2812 claims you can supply up to 7V , but this is still less than 9V , the SK6812 is lacking in max voltage but says 5v typical.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to use the 9V supply you will need a extra voltage regulator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A little math: each pixel can max draw 60mA, if you have 21 of them we multiply and get 1260mA, thats 1.26 Amps but thats max values we might divide by two and still be relative safe. Let's not.  So we need a 1.26A source from 9V to 5V then we can calculate the power we need to dissipate. (9-5) x 1.26 = 5.04W of heat. Ok you need a regulator that can dissipate that kind of heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 7805 regulator will not do,  you need a switching buck converter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to driving this on battery power I don't think alkaline will be able to deliver 1.3A (adding for the MCU) without loosing voltage to inner resistance, some rechargeable might. Lipo can deliver but at a different voltage that will need a new calculation of potential waste using linear regulation, or a buck regulator.  In my opinion the charging of lipos require special attention and are not my preference, but might be option here. &lt;/p&gt;&#xA;" OwnerUserId="19322" LastEditorUserId="19322" LastEditDate="2016-03-21T20:18:59.463" LastActivityDate="2016-03-21T20:18:59.463" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22070" PostTypeId="1" AcceptedAnswerId="22081" CreationDate="2016-03-21T18:58:33.100" Score="3" ViewCount="8505" Body="&lt;p&gt;I'm thinking of creating a &quot;small&quot; electronic dice.&#xA;(I will solder the button a little different though xD)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ffpEC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ffpEC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there are some concerns on my design:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Powering from a coin-cell&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a 5V arduino Pro mini, but it should be able to run (per datasheet) on 2.7V to 5.5V, can I just put the 3V of the coin-cell battery on VCC. (I'm aware I'll have to use the internal 8Mhz clock on this voltage though). I won't need the regulator, since the coin-cell will never exceed 5V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Can I use a I/O as (input/supply) GND?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can actually use outputs as positive voltage, and you can sink currents.&#xA;But does that mean I can connect the negative side of the coin-cell to an output, and sink it?&#xA;This way it should power my arduino's VCC pin through the &quot;digital GND&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Using the reset button&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use the reset button, but would it still give me &quot;random enough&quot; numbers? Since the seed is reset every time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I probably won't use it though, it's placed inconveniently for this project, but I am wondering.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A crude drawing below:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fun thing is, polarity of the LED's/segments doesn't matter, since I can change which side is high or low? :)&#xA;Also, I've only drawn half the LED's/segments. And I know it's better to use a resistor on every pin, but I don't want to make it any more bulky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(btw, battery GND pin should be pin 4, not pin 2)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3fqtU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3fqtU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-04-23T20:05:14.767" Title="Powering from 3V coin cell to VCC, using I/O pin as supply GND" Tags="|arduino-pro-mini|battery|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22072" PostTypeId="1" AcceptedAnswerId="22073" CreationDate="2016-03-21T19:34:58.210" Score="1" ViewCount="541" Body="&lt;p&gt;I have recently bought an Arduino Mega, and I am powering it with a USB charging port, 5V at 1A. I need to use the 1A with a transistor, since the Arduino itself can only supply a maximum of 20mA through one pin. &lt;br&gt;&#xA;So I was wondering, is there any way to access this unregulated power source? Would the VIN pin serve this purpose, or is there no way to access the 1A current without pulling apart the USB cable?&lt;/p&gt;&#xA;" OwnerUserId="19483" LastActivityDate="2016-03-21T19:47:58.263" Title="How to use unregulated VIN voltage?" Tags="|power|usb|current|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22073" PostTypeId="2" ParentId="22072" CreationDate="2016-03-21T19:38:16.557" Score="2" Body="&lt;p&gt;The VIN port is connected to the barrel jack. It must only be used if you are powering the board through that jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To access the USB power just use the 5V pin - it is directly connected to the USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the USB, although the socket it is plugged into can supply more, is limited to 500mA. This is because of a 500mA auto-resetting &lt;em&gt;polyfuse&lt;/em&gt; on the USB power input (the large gold and dark green rectangle next to the USB socket - mine has either XE05 or 503X on it depending on which way up you hold it).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-21T19:47:58.263" LastActivityDate="2016-03-21T19:47:58.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22074" PostTypeId="1" AcceptedAnswerId="22077" CreationDate="2016-03-21T17:23:32.487" Score="2" ViewCount="26089" Body="&lt;p&gt;How much current can I put through the pins of an Arduino Mega at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The situation: I am building a 7x7x7 LED cube, and my plan was to multiplex in 7 layers of 49 pins, lighting each layer, one at a time. This would mean each pin on the Arduino Mega would only have to supply max. 1 LED at a time.&lt;br&gt;&#xA;However, if all 49 LEDs in one layer were on, it would presumably draw 49*20mA (from the LED specs sheet), which is 980mA. This seems like quite a lot of current to put through an ATMega chip, so I was wondering if I could do it, either continuing like this, or using transistors to control the lighting of each layer, or what?&lt;br&gt;&#xA;Any help or advice is appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Using ATMega2560, not ATMega328 or alternate.&lt;/p&gt;&#xA;" OwnerUserId="19483" OwnerDisplayName="TheAbelo2" LastActivityDate="2016-03-21T19:51:52.617" Title="Max current through an Arduino Mega?" Tags="|current|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22075" PostTypeId="2" ParentId="22074" CreationDate="2016-03-21T17:48:58.980" Score="2" Body="&lt;p&gt;You're on the right track here. In the datasheet for the ATmega1280 I find this box:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FAovO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FAovO.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want to look at is &lt;code&gt;DC Current Vcc and GND Pins  ....  200.0 mA&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the total limit of &lt;em&gt;all the current&lt;/em&gt; going through the chip (because everything must come through Vcc), and it is the &lt;em&gt;absolute maximum&lt;/em&gt;. Don't go near it. You need to boost this with some transistors.&lt;/p&gt;&#xA;" OwnerUserId="26624" OwnerDisplayName="pipe" LastActivityDate="2016-03-21T17:56:49.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22076" PostTypeId="2" ParentId="22074" CreationDate="2016-03-21T17:55:55.237" Score="1" Body="&lt;p&gt;It's listed in the Electrical Characteristics of the specific MCU used in the Arduino you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Mega2560, its remarkably similar to the 328 in the Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Absolute Max, 40mA per pin, 200mA VCC or GND current. 20mA per pin recommended max. A huge note, various ports have individual limits:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;3: Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state&#xA;  conditions (non-transient), the following must be observed:&lt;/strong&gt;&lt;br&gt;&#xA;  ATmega1281/2561:&lt;br&gt;&#xA;  1.)The sum of all IOL, for ports A0-A7, G2, C4-C7 should not exceed 100mA.&lt;br&gt;&#xA;  2.)The sum of all IOL, for ports C0-C3, G0-G1, D0-D7 should not exceed 100mA.&lt;br&gt;&#xA;  3.)The sum of all IOL, for ports G3-G5, B0-B7, E0-E7 should not exceed 100mA.&lt;br&gt;&#xA;  4.)The sum of all IOL, for ports F0-F7 should not exceed 100mA.&lt;br&gt;&#xA;  ATmega640/1280/2560:&lt;br&gt;&#xA;  1.)The sum of all IOL, for ports J0-J7, A0-A7, G2 should not exceed 200mA.&lt;br&gt;&#xA;  2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.&lt;br&gt;&#xA;  3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200mA.&lt;br&gt;&#xA;  4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100mA.&lt;br&gt;&#xA;  5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100mA.&lt;br&gt;&#xA;  &lt;strong&gt;If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;4: Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:&lt;/strong&gt;&lt;br&gt;&#xA;  ATmega1281/2561:&lt;br&gt;&#xA;  1)The sum of all IOH, for ports A0-A7, G2, C4-C7 should not exceed 100mA.&lt;br&gt;&#xA;  2)The sum of all IOH, for ports C0-C3, G0-G1, D0-D7 should not exceed 100mA.&lt;br&gt;&#xA;  3)The sum of all IOH, for ports G3-G5, B0-B7, E0-E7 should not exceed 100mA.&lt;br&gt;&#xA;  4)The sum of all IOH, for ports F0-F7 should not exceed 100mA.   ATmega640/1280/2560:&lt;br&gt;&#xA;  1)The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed 200mA.&lt;br&gt;&#xA;  2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.&lt;br&gt;&#xA;  3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA.&lt;br&gt;&#xA;  4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.&lt;br&gt;&#xA;  5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastActivityDate="2016-03-21T17:55:55.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22077" PostTypeId="2" ParentId="22074" CreationDate="2016-03-21T18:28:08.283" Score="1" Body="&lt;p&gt;The ATmega 2560 (assuming that's the chip on your Arduino Mega) has an absolute limit of 40mA on each pin, and 200mA in total for all pins. So yes, you will not be able to drive that load directly from the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NobBL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NobBL.png&quot; alt=&quot;Absolute Maximum Ratings&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With external circuitry however, anything is possible. If it were me, I'd use some TPIC6B595 IC's to drain current and BC635 NPN's to source it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 595's can sink up to 150mA each (so up to 8 LEDs at 18.75mA each, use a 270Ω resistor in series with each LED if you're running everything from 5V.) You would need 7 595's for 49 LEDs (49 / 8 rounded up.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can daisy chain the serial in/outs on them so you just need to shift out 8 bytes from the Arduino (either using SPI or the software equivalent, shiftOut or whatever it's called, on any digital pin.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.farnell.com/datasheets/2008101.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TPIC6B595N Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To source current, BC635's are rated up to 1A with a typical current gain (hFE) of 100. Collector pin goes to 5V, Emitter pin goes to all the LED anodes on a layer, Base pin connects in series to a 510Ω or 470Ω resistor and an Arduino digital pin. You would need 7 635's, one for each layer. They turn 10mA from a digital pin into 1A from the power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.farnell.com/datasheets/1693081.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;BC635 Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaking of power supplies, you will not be able to power the whole thing from the Arduino 5V pin (especially if powered from USB.) You will need an additional 5V power supply. If you want simplicity you could use a L7805 voltage regulator and stick a heatsink on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.farnell.com/datasheets/1805459.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;L7805 Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of these are popular components which can be obtained from eBay for next to nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have more questions specific to Arduino, they might be better suited to the Arduino Stack Exchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino.stackexchange.com&quot;&gt;Arduino Stack Exchange Link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15295" OwnerDisplayName="Ashlyn Black" LastActivityDate="2016-03-21T18:28:08.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22079" PostTypeId="2" ParentId="22070" CreationDate="2016-03-21T19:59:02.173" Score="1" Body="&lt;p&gt;Yes you should be fine with the voltage from a coin cell - though don't expect it to last long!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No you can't use an I/O as ground - they are set to input by default, and even if they weren't, if wouldn't be guaranteed to work, and even if it did happen to work*, it would be horrible.  I don't quite understand why you want to do it this way - why not just connect the cell's -ve to the GND pin, right next to the VCC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you seed your random number generator suitably (e.g. from an unconnected analogue input) you ought to be OK since that will suitably random - you'll be reseeding it each time with a different seed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Stranger things have happend! The very fist ARM chip worked without power, running from parasitic currents from the inputs, as they discovered by mistake when they tested it with the power supply disconnected.&lt;/p&gt;&#xA;" OwnerUserId="16085" LastActivityDate="2016-03-21T19:59:02.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22080" PostTypeId="2" ParentId="22070" CreationDate="2016-03-21T20:01:56.930" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It's a 5V arduino Pro mini, but it should be able to run (per datasheet) on 2.7V to 5.5V, can I just put the 3V of the coin-cell battery on VCC. (I'm aware I'll have to use the internal 8Mhz clock on this voltage though). I won't need the regulator, since the coin-cell will never exceed 5V?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is correct.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can actually use outputs as positive voltage, and you can sink currents. But does that mean I can connect the negative side of the coin-cell to an output, and sink it? This way it should power my arduino's VCC pin through the &quot;digital GND&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Definitely not. That is a sure-fire way to kill the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you have a Catch-22 situation. To make the pin conduct to ground you have to set it to output and switch it LOW. How can you do that if the chip is powered off? You need to power the chip on in order to power the chip on. It just can't work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I could use the reset button, but would it still give me &quot;random enough&quot; numbers? Since the seed is reset every time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will only get random numbers if you seed the PRNG with a random number. If you can get a source of entropy (noise on an analog pin for instance) then yes, that could work.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And I know it's better to use a resistor on every pin, but I don't want to make it any more bulky.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's not &quot;better&quot; - it's &lt;strong&gt;REQUIRED&lt;/strong&gt;.  With just one resistor and one segment on that segment will get 8x the current compared to having all 8 segments on. You then either get very dim segments with lots on, or smoke from segments when not many are on.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-21T23:16:10.390" LastActivityDate="2016-03-21T23:16:10.390" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22081" PostTypeId="2" ParentId="22070" CreationDate="2016-03-21T20:06:02.097" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I use a I/O as (input/supply) GND?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use an I/O pin as a supply for &lt;em&gt;another (low power) device&lt;/em&gt;, but&#xA;you should power the Arduino itself from its Vcc and GND pins.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I could use the reset button, but would it still give me &quot;random&#xA;  enough&quot; numbers?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will likely see the very same sequence every time you reset it.&#xA;There are ways around this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can seed the random number generator (RNG) at startup with an&#xA;&lt;code&gt;analogRead()&lt;/code&gt; from an unconnected pin, but it's not clear how much&#xA;entropy you can expect from this.&lt;/li&gt;&#xA;&lt;li&gt;You can save the RNG's entropy into the .noinit memory section, this&#xA;way it will not be wiped up during the program startup.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would recommend, however, that you use a normal I/O pin to trigger the&#xA;dice, if only for one reason: the time when the user presses the button&#xA;(that you read with &lt;code&gt;micros()&lt;/code&gt;) is a very good entropy source for&#xA;seeding the RNG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, whenever the user presses the button you could:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;srandom(random() ^ ((uint32_t) analogRead(0) &amp;lt;&amp;lt; 22) ^ micros());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you combine the entropy from the button press with the entropy&#xA;from the analog pin (if any), with whatever entropy may already by in&#xA;the RNG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: More on entropy gathering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you seemingly already know, &lt;code&gt;random()&lt;/code&gt; is a pseudo-random number&#xA;generator intended to produce a sequence of numbers that &lt;em&gt;look&lt;/em&gt; random.&#xA;Unless you have some other source of randomness in your program, every&#xA;time you restart the Arduino you will get the &lt;em&gt;very same&lt;/em&gt; sequence of&#xA;numbers. Getting true randomness (also called “entropy”) on an Arduino&#xA;is not so easy. Here are some ideas you may want to explore.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Read from an unconnected analog input&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This trick seems to be pretty popular. It can even be found in the&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/RandomSeed&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino documentation on&#xA;randomSeed()&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;use randomSeed() to initialize the random number generator with a&#xA;  fairly random input, such as analogRead() on an unconnected pin.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In my experience, this seems to be a very poor entropy source. I wrote a&#xA;test program that prints out the output of &lt;code&gt;analogRead(0)&lt;/code&gt; and it seems&#xA;to cycle through the same few values in an almost predictable way. &#xA;I estimate this gives around one or two bits of entropy per call. On the&#xA;plus side, each call takes just over 100&amp;nbsp;µs.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Read from an analog noise source&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There is a lot of literature on building analog noise sources. Such&#xA;sources are used inside crypto-grade random number generators, but the&#xA;circuits are likely to be more complex than you would like. There seems,&#xA;however, to be a very simple alternative. In &lt;a href=&quot;https://arduino.stackexchange.com/a/12410&quot;&gt;a comment to this&#xA;post&lt;/a&gt;, CharlieHanson wrote:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Connecting the analogue input to the collector of a run-of-the-mill&#xA;  transistor, with the emitter grounded and base open helps to make a&#xA;  noisy input.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have not tested this idea, but it is certainly worth exploring.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Time user input&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If the user is required to press a button to throw the dice, the timing&#xA;of the button press is probably the best entropy source you can have.&#xA;With a 8&amp;nbsp;MHz clock, the &lt;code&gt;micros()&lt;/code&gt; function has a resolution of&#xA;8&amp;nbsp;µs (64 clock cycles). Assuming the user is unable to control his&#xA;timing better than 0.1&amp;nbsp;seconds, then you have more than&#xA;13&amp;nbsp;bits of entropy per button press.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, instead of &lt;code&gt;micros()&lt;/code&gt;, you use timer 1 running at the full CPU&#xA;speed, then you would have 16&amp;nbsp;bits of entropy per button press. And&#xA;you would not need &lt;code&gt;random()&lt;/code&gt; at all, as you could just output&#xA;&lt;code&gt;1+TCNT1%6&lt;/code&gt;. That would be like throwing a dart at a carnival wheel&#xA;spinning at 80&amp;nbsp;&lt;em&gt;million&lt;/em&gt;&amp;nbsp;RPM (8&amp;nbsp;MHz&amp;nbsp;/&amp;nbsp;6)!&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Measure clock drift&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The drift of a clock relative to another clock &lt;a href=&quot;https://en.wikipedia.org/wiki/Clock_drift#Random_number_generators&quot; rel=&quot;nofollow noreferrer&quot;&gt;can be used as an&#xA;entropy&#xA;source&lt;/a&gt;.&#xA;The ATmega chip in your Arduino has two independent clocks: the internal&#xA;“calibrated” 8&amp;nbsp;MHz RC oscillator, and the 128&amp;nbsp;kHz oscillator&#xA;used by the watchdog timer. Both are low-accuracy clocks subject to&#xA;somewhat unpredictable drift, which is a good thing for this&#xA;application. You can gather entropy from this by configuring the&#xA;watchdog timer as a periodic interrupt source, and using timer 1 at full&#xA;speed to time the interrupt arrival times:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include &amp;lt;util/atomic.h&amp;gt;&#xA;&#xA;// Configure Timer 1 for counting CPU cycles and the watchdog as an&#xA;// interrupt source firing (roughly) once a second. Call once in&#xA;// setup().&#xA;void configure_timers()&#xA;{&#xA;    // Timer 1.&#xA;    TCCR1A = 0;          // normal counting mode&#xA;    TCCR1B = _BV(CS10);  // prescaler = 1&#xA;&#xA;    // Watchdog. This is a timed sequence.&#xA;    ATOMIC_BLOCK(ATOMIC_FORCEON) {&#xA;        WDTCSR = _BV(WDCE)  // enable changing the prescaler&#xA;               | _BV(WDE);  // ditto&#xA;        WDTCSR = _BV(WDIF)  // clear interrupt flag&#xA;               | _BV(WDIE)  // enable interrupts&#xA;               | WDTO_1S;   // timeout ~ 1 second&#xA;    }&#xA;}&#xA;&#xA;volatile uint16_t wdt_time;&#xA;volatile bool wdt_fired;&#xA;&#xA;// Watchdog interrupt service routine.&#xA;ISR(WDT_vect)&#xA;{&#xA;    wdt_time = TCNT1;&#xA;    wdt_fired = true;&#xA;}&#xA;&#xA;// Add entropy to the RNG from the timing of the last WDT interrupt.&#xA;// Call periodically in loop().&#xA;void get_wdt_entropy()&#xA;{&#xA;    if (!wdt_fired) return;  // No WDT event since last time.&#xA;    uint16_t wdt_time_copy;&#xA;    ATOMIC_BLOCK(ATOMIC_FORCEON) {&#xA;        wdt_time_copy = wdt_time;&#xA;        wdt_fired = false;&#xA;    }&#xA;    srandom(random() ^ wdt_time_copy);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tested this idea by plotting the time &lt;em&gt;differences&lt;/em&gt; between&#xA;successive interrupts. On an Arduino Uno clocked at 16&amp;nbsp;MHz, I see&#xA;short-time fluctuations with an amplitude of about 300. That should&#xA;provide around 8 bits of entropy per second.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Save the entropy pool across reboots&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Once you have spent some effort to gather entropy from the environment,&#xA;it would be a pity to lose it all at power down. It is common practice&#xA;to save the entropy pool to disk when a computer shuts down, and restore&#xA;it at boot time. This avoids the problem of the RNG always starting in&#xA;the same predictable state. On the Arduino, you have no disk, but you&#xA;can use the EEPROM instead. The problem is you cannot know in advance&#xA;when the user is going to switch the device off. Then, ideally, you&#xA;would save the entropy every time the user requests a new dice value.&#xA;The new problem is that the EEPROM is only guaranteed to work reliably&#xA;for 100,000 write/erase cycles. This may not be a serious problem&#xA;(100,000 is plenty of throws), but it can nonetheless be mitigated by&#xA;using a wear-leveling scheme, where you distribute the writes across the&#xA;whole EEPROM instead of always overwriting the same bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wear-leveling can add significant complexity to your program, but it&#xA;turns out there is, in this particular case, a wear-leveling scheme that&#xA;is trivial to implement: just write at a random location! At startup,&#xA;you do not know what was the last location written to, but you do not&#xA;need to: you read and mix the whole contents of the EEPROM:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/eeprom.h&amp;gt;&#xA;&#xA;// Save the entropy to EEPROM. Call this every time the user requests a&#xA;// new value.&#xA;void save_entropy()&#xA;{&#xA;    uint32_t *address = (uint32_t *)(random() &amp;amp; E2END &amp;amp; ~3);&#xA;    eeprom_write_dword(address, random());&#xA;}&#xA;&#xA;// Restore the entropy from the EEPROM. Call once in setup().&#xA;void restore_entropy()&#xA;{&#xA;    uint32_t seed = 0;&#xA;    for (uint32_t *address = 0; address &amp;lt; (uint32_t *) E2END; address++)&#xA;        seed ^= eeprom_read_dword(address);&#xA;    srandom(seed);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Combine the entropy sources with the XOR operator&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As you probably already noticed, the bitwise xor operator (^) is used&#xA;every time one wants to combine entropy sources. The main reason is&#xA;that, if &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; are independent random variables, then &lt;code&gt;a^b&lt;/code&gt; is at&#xA;least as random as the most random of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;. Which means that&#xA;XORing a “good” random variable with a “bad” one is harmless. This is&#xA;somewhat formalized as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Piling-up_lemma&quot; rel=&quot;nofollow noreferrer&quot;&gt;piling-up&#xA;lemma&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, doing &lt;code&gt;randomSeed(analogRead(0))&lt;/code&gt; at program startup is&#xA;fine, but doing it repeatedly during program execution is a terrible&#xA;idea: most of the time this will put the RNG in one of a very few&#xA;states. If instead you&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;srandom(random() ^ analogRead(0));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then you are combining the current randomness of the RNG with the output&#xA;of &lt;code&gt;analogRead()&lt;/code&gt;, and putting this back into the RNG. And this is&#xA;harmless even if &lt;code&gt;analogRead()&lt;/code&gt; is quite predictable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;A side note on randomSeed()&lt;/strong&gt;: Arduino releases prior to 1.6.5 had a&#xA;bug that would truncate to 16 bits the entropy provided with&#xA;&lt;code&gt;randomSeed()&lt;/code&gt;. On those releases it is better to use the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga4fca27496ca29c0a723d197696641eff&quot; rel=&quot;nofollow noreferrer&quot;&gt;avr-libc&#xA;srandom()&#xA;function&lt;/a&gt;.&#xA;The bug has since &lt;a href=&quot;https://github.com/arduino/Arduino/commit/0051eadd2a5c7c81c24363b9dfa966c098c6a046&quot; rel=&quot;nofollow noreferrer&quot;&gt;been&#xA;fixed&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-22T15:32:01.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22082" PostTypeId="1" AcceptedAnswerId="22090" CreationDate="2016-03-21T20:38:42.203" Score="0" ViewCount="4433" Body="&lt;p&gt;I try to send pairs of numbers over the serial port from a linux pc to the arduino. By now I did so always by piecing together the ASCII chars from the serial line and using &lt;code&gt;Serial.read()&lt;/code&gt;. Now I need this same thing to run at 100-200Hz, and it turns out, that the Arduino does not receive all the data (even at 1Hz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As turned out, my problem was in another portion of the code and all below code works perfectly as is!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I make sure, that every char (or better even byte without ASCII encoding) is received? I am aware, that each connection has errors, but this is a systematical error! I guess, that the bytes are lost during the processing within the main loop, or because of other callbacks I use (got some ISR running). I am not looking for error detection, but rather a concise way of reading the serial line, without loosing 70% of the data validity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If important: the pairs i need to send are unsigned, 1 byte and another one with 2 bytes. The values are in the range of &lt;code&gt;[0;7]&lt;/code&gt; and &lt;code&gt;[1000;2000]&lt;/code&gt;. Thanks for any advice. Disclaimer, I read a lot, including &lt;a href=&quot;https://arduino.stackexchange.com/questions/4875/how-to-send-two-different-sets-of-int-numbers-over-serial&quot;&gt;this&lt;/a&gt;, but most questions go into detail about the packaging format, whereas I am concerned about the reading method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code I use at the moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// read numbers from the char representation!&#xA;// on the serial connection&#xA;// each DIGIT is sent separately&#xA;&#xA;String inputString = &quot;&quot;;         // a string to hold incoming data&#xA;boolean stringComplete = false;  // whether the string is complete&#xA;uint8_t channel; // holding the number of the channel to modify&#xA;uint16_t signal; // ppm signal length in us (1000-2000)&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  inputString.reserve(200);&#xA;&#xA;  pinMode(9,OUTPUT); // fixed pin 9 for PPM output&#xA;}&#xA;&#xA;void loop() {&#xA;  if (stringComplete) {&#xA;    channel = uint8_t(inputString[0])-48;&#xA;    signal = 0;&#xA;    for (uint8_t n=1; n&amp;lt;5; n++) {&#xA;      signal = (signal*10) + uint8_t(inputString[n])-48;&#xA;    }&#xA;    Serial.print(F(&quot;ch: &quot;)); Serial.print(channel);&#xA;    Serial.print(F(&quot; signal: &quot;)); Serial.print(signal);&#xA;    Serial.print(F(&quot;\n&quot;));&#xA;    //PROCESS Data&#xA;    inputString = &quot;&quot;;&#xA;    stringComplete = false;&#xA;  }&#xA;}&#xA;&#xA;void serialEvent() {&#xA;  while (Serial.available()) {&#xA;    char inChar = (char)Serial.read();&#xA;    inputString += inChar;&#xA;    // if the incoming character is a&#xA;    // newline (10) or carriage return (13)&#xA;    // set a flag for a complete transmission&#xA;    if (inChar == 10 | inChar == 13) {&#xA;      stringComplete = true;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another version I tried, without strings is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// channel and pulse-length&#xA;uint16_t numbers[2] = {0, 0}; // channel,value&#xA;uint8_t buf[5];&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (serial_input(numbers,buf)) {&#xA;    numbers[0] = buf[0]-48;&#xA;    numbers[1] = (buf[1]-48)*10+(buf[2]-48);&#xA;    Serial.print(F(&quot;channel: &quot;)); Serial.println(numbers[0]);&#xA;    Serial.print(F(&quot; signal: &quot;)); Serial.println(numbers[1]);&#xA;    // Do Stuff&#xA;  }&#xA;}&#xA;&#xA;uint8_t serial_input(uint16_t* num, uint8_t* buf) {&#xA;  uint8_t newData = 0;&#xA;  uint8_t k = 0;&#xA;  num[0] = 0; num[1] = 0;&#xA;  while(Serial.available()) {&#xA;    delayMicroseconds(2100);&#xA;    char ser = Serial.read();&#xA;    if (isDigit(ser)) {&#xA;      buf[k] = uint8_t(ser);&#xA;      k++;&#xA;      newData = 1;&#xA;    } else {break;}&#xA;  }&#xA;  return newData;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another try inspired by an answer here, where I send &quot;3 1500\n&quot; over the serial line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent() {&#xA;  if (!newdata) {&#xA;    channel = Serial.parseInt();&#xA;    signal = Serial.parseInt();&#xA;    newdata = true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Turns out all of those methods work (more or less elegantly), but having a &quot;delay&quot; within an ISR isn't such a good idea - even intermediately...&lt;/p&gt;&#xA;" OwnerUserId="2902" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-03-22T17:11:25.000" Title="Reading 2 numbers from serial" Tags="|serial|usb|linux|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22083" PostTypeId="1" CreationDate="2016-03-21T21:15:12.570" Score="2" ViewCount="423" Body="&lt;p&gt;I have seen similar issues posted here but none match my problem exactly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a starter kit and a 16x2 LCD screen that only shows black boxes in the top row using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  lcd.begin(16, 2);&#xA;  lcd.print(&quot;hello, world!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All tutorials use a potentiometer to change the contrast but I don't have one so I decided to use chain several resistors. When doing so, the contrast indeed changes, but it changes as a whole. The black boxes become less readable i.e. less in contrast (more vague) but stay completely black.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to make sure, I have a cable from the + tray (with 5v) to the VDD port and - tray (with GND) to the VSS port. The K port is on the - tray as well and the A is with a 220 ohm resistor on the + tray. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried no, 3k, 4k, 3220, 10k and 100k ohm on the v0 port to change the contrast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be wrong? Any help is appreciated. &lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Edit photo:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2WfN4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2WfN4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19487" LastEditorUserId="19487" LastEditDate="2016-03-22T09:29:01.260" LastActivityDate="2016-03-22T09:29:01.260" Title="Arduino LCD changing contrast only makes black boxes less readable i.e. less in contrast" Tags="|arduino-uno|lcd|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="22084" PostTypeId="1" AcceptedAnswerId="22086" CreationDate="2016-03-21T21:36:10.513" Score="4" ViewCount="14079" Body="&lt;p&gt;I have read some conflicting sources about what pins have internal pullup resistors available for the Attiny85 microcontroller. Can all I/O pins work with INPUT_PULLUP, or just some of them? And if so, which ones?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="15677" LastActivityDate="2016-03-21T21:48:51.747" Title="ATtiny85 and INPUT_PULLUP" Tags="|attiny|input|pull-up|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22086" PostTypeId="2" ParentId="22084" CreationDate="2016-03-21T21:48:51.747" Score="4" Body="&lt;p&gt;Check the datasheet, probably just search for &quot;internal&quot; or &quot;pullup&quot; &lt;img src=&quot;https://i.stack.imgur.com/KnmyK.jpg&quot; alt=&quot;enter image description here&quot;&gt; I believe there are little more pins/ports as portB, so they should all have internal pull ups.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-21T21:48:51.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22087" PostTypeId="1" AcceptedAnswerId="22092" CreationDate="2016-03-21T21:57:14.357" Score="0" ViewCount="143" Body="&lt;p&gt;I thought the idea of Amazon Prime air drone delivery was a pretty cool one when it first came out and I started to question whether something like that (an autonomous gps guided vehicle) could possibly be created with the Arduino microcontroller(s). Any thoughts?&lt;/p&gt;&#xA;" OwnerDisplayName="user19489" LastActivityDate="2016-03-21T23:41:55.503" Title="Has anybody seen/created a gps guided vehicle with arduino?" Tags="|arduino-uno|programming|sensors|c++|power|" AnswerCount="2" CommentCount="3" ClosedDate="2016-03-26T23:09:29.797" ContentLicense="CC BY-SA 3.0" />
  <row Id="22088" PostTypeId="2" ParentId="22087" CreationDate="2016-03-21T22:21:39.100" Score="2" Body="&lt;p&gt;Yes, someone (not me) has: &lt;a href=&quot;https://www.youtube.com/watch?v=3-r2Jk0uA6U&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=3-r2Jk0uA6U&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I doubt it would work very well with non-flying vehicles - in the air, a 3 meter margin of error is fine, on the ground it's the difference between the sidewalk and the middle of the road.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-21T22:21:39.100" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22089" PostTypeId="2" ParentId="21932" CreationDate="2016-03-21T22:24:13.240" Score="0" Body="&lt;p&gt;Here my additional thoughts in short:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;20 meters is, compared with the distance to the moon, quite short ;-). Maximum length of RS-485 is reported to be kilometers with small transmission rates (google: rs485 cable length).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Noise can either be avoided (hardware) or corrected by software (fault tolerant codes, checksums etc.) Generally, software is cheaper.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Short wires does not mean no wires at all. Short wires would e.g. result if you have a controller per room and connect the sensors to it. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are also small packages of Arduino compatible chips available (ATTiny84/85). And without RS485 you save the space of the controllers...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I2C bus length should work inside a house, if yous is not bigger than the one of Bill Gates...&#xA;&lt;a href=&quot;http://www.esacademy.com/en/library/technical-articles-and-documents/miscellaneous/i2c-bus/frequently-asked-questions/i2c-faq.html&quot; rel=&quot;nofollow&quot;&gt;http://www.esacademy.com/en/library/technical-articles-and-documents/miscellaneous/i2c-bus/frequently-asked-questions/i2c-faq.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would not use serial for communication. It is not extensible. Serial is ok for debugging.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19428" LastActivityDate="2016-03-21T22:24:13.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22090" PostTypeId="2" ParentId="22082" CreationDate="2016-03-21T22:28:33.343" Score="0" Body="&lt;p&gt;there is a great function:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Serial/ParseInt&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/ParseInt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested the following script up 2kHz incoming, but it should go even faster.&#xA;Do something like this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int number = 0;&#xA;int number2 = 0;&#xA;bool get_data = false;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  inputString.reserve(200);&#xA;&#xA;  pinMode(9,OUTPUT); // fixed pin 9 for PPM output&#xA;}&#xA;&#xA;void loop() {&#xA;    if(get_data == true){&#xA;      Serial.print(number);&#xA;      Serial.print(number2);&#xA;      get_data = false;&#xA;    }&#xA;}&#xA; void SerialEvent()&#xA;   if(!get_data){&#xA;     number = Serial.parseInt();&#xA;     number2 = Serial.parseInt();&#xA;     get_data = true;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19493" LastEditorUserId="2902" LastEditDate="2016-03-22T17:11:25.000" LastActivityDate="2016-03-22T17:11:25.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22091" PostTypeId="2" ParentId="22082" CreationDate="2016-03-21T22:33:33.553" Score="1" Body="&lt;p&gt;115200 baud at 200Hz means you should be able to transfer in excess of 50 characters between each &quot;trigger&quot;. That is more than enough time to send the data even as ASCII encoded text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;serialEvent()&lt;/code&gt; is no better than manually looking at things like &lt;code&gt;serialAvailable()&lt;/code&gt; in your loop since that is all it does anyway. It just runs after each iteration of your loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem that you have is that you're appending each character to a String object. This is very inefficient and should be avoided. Instead you should really use a character array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Input text in the form &quot;123 456\n&quot;&#xA;char instring[20]; // Room for 19 characters plus terminating null&#xA;int spos = 0; // Location in the array&#xA;int val1 = 0;&#xA;int val2 = 0;&#xA;&#xA;void loop() {&#xA;    if (Serial.available()) {&#xA;        char *bita, *bitb;&#xA;        int c = Serial.read();&#xA;        switch (c) {&#xA;            case '\r': break; // ignore&#xA;            case '\n': &#xA;                 spos = 0;&#xA;                 bita = strtok(instring, &quot; &quot;);&#xA;                 bitb = strtok(NULL, &quot; &quot;);&#xA;                 if (bita &amp;amp;&amp;amp; bitb) {&#xA;                     val1 = atoi(bita);&#xA;                     val2 = atoi(bitb);&#xA;                 }&#xA;                 // You now have two new values in val1 and val2&#xA;                 break;&#xA;            default:&#xA;                if (spos &amp;lt; 18) {&#xA;                    instring[spos++] = c;&#xA;                    instring[spos] = 0;&#xA;                }&#xA;        }&#xA;    }&#xA;}            &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-21T22:33:33.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22092" PostTypeId="2" ParentId="22087" CreationDate="2016-03-21T23:22:20.840" Score="1" Body="&lt;p&gt;GPS is not, by itself, enough to make an Amazon Prime-like delivery drone.  GPS only provides a very rough position (thanks to the US Military imposing a large margin of error on non-military users, or so the urban legend goes (it's actually a difference in transmission systems that makes the difference)). It's good enough for getting you to your destination and working out roughly where you are, but getting to a specific pinpoint location just can't be done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need other sensors as well. Things that can examine the environment and work out where you are in relation to other things. Especially people. Object avoidance is the critical component of any autonomous drone, and unless you can come up with a completely safe and foolproof system the FAA will be down on you like a ton of rectangular building blocks.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-21T23:41:55.503" LastActivityDate="2016-03-21T23:41:55.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22093" PostTypeId="1" CreationDate="2016-03-21T23:58:27.440" Score="1" ViewCount="47" Body="&lt;p&gt;Right now I have DHT11, PIR sensor, relay, and a photocell on the same board. I am planning to upload the data to a web server. But I want both DHT11 and photocell to be uploaded hourly; PIR and relay by every 3s. Is it possible for a single Arduino to perform such thing?&lt;/p&gt;&#xA;" OwnerUserId="19496" LastActivityDate="2016-03-22T00:16:05.290" Title="Arduino sensors with various periods" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22094" PostTypeId="2" ParentId="22093" CreationDate="2016-03-22T00:01:21.597" Score="2" Body="&lt;p&gt;Yes. Perfectly possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How accurate do you need the &quot;hourly&quot;? If you want any form of accuracy at all you will really want to use an RTC module to provide the real time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise that, and the higher speed 3s updates, can be timed using the &lt;code&gt;millis()&lt;/code&gt; function.  The BlinkWithoutDelay example in the IDE shows you the basic idea of working with timestamps to examine elapsed time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also there are simple libraries that could help you, such as &lt;a href=&quot;http://playground.arduino.cc/Code/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;SimpleTimer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-22T00:01:21.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22096" PostTypeId="1" AcceptedAnswerId="22099" CreationDate="2016-03-22T01:44:15.820" Score="2" ViewCount="575" Body="&lt;p&gt;I've prototyped a little light/sunrise alarm clock w/ an Arduino Uno and a breadboard. How do I go about figuring out what components I'd need to reduce this down in to a more semi-permanent prototype?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously I don't need everything the Uno has to offer and I'd like to slim this down into a custom box I build.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what sort of microcontroller(s) would I need to size this down? How else can I simplify it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, I'm not trying to turn this in to any sort of finished/super-polished product. Just wanting to get out of the breadboard and in to some soldering of something a bit more set in stone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AUmuv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AUmuv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EuMmv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EuMmv.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-23T10:28:53.203" Title="How do I reduce this down to a smaller, more permanent prototype?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="15" ContentLicense="CC BY-SA 3.0" />
  <row Id="22099" PostTypeId="2" ParentId="22096" CreationDate="2016-03-22T02:45:56.610" Score="4" Body="&lt;p&gt;At a bare minimum, you need a power supply, and an AtMega or AtTiny chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AtMega and AtTiny's have an internal clock, 1mhz. It's not terribly accurate for timekeeping purposes (1% error, I think, as opposed to 20ppm = 0.02% for the external clock), but I see you have an RTC, so a 1% drift is probably fine (I can't see your code, so I don't know if the internal time is used for anything). Remember that you will need to adjust your code for the different clock rate, anything that uses anything time-related will run at 1/16th speed (delay, serial comms, etc). You will need to set the fuses to use the internal clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your power source isn't 5v, then you need a transformer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What type of AtTiny or AtMega you use depends on your code, and how many pins you use. I see 5 pins, they are all used as digital I think? You might get away with one of the 14-pin AtTinys. I suspect your code is probably pretty small. You can probably get away with nearly any AtTiny. To select an AtTiny, go to &lt;a href=&quot;http://www.atmel.com/products/microcontrollers/avr/tinyavr.aspx&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/products/microcontrollers/avr/tinyavr.aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon (who will probably be providing his own answer as I type) has an excellent site on how to put the parts together, at &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/breadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This site mentions programming the bootloader. On a low-memory chip, you do not need a bootloader, you can upload your program using SPI (same way as you upload the bootloader in Nick's example). Alternatively, you can use a programmer like the USBASP, which makes the whole process a lot easier. When you build your final board, I strongly suggest putting a 6-pin ICSP header (same as the 2x3 pins on the end of your Arduino board) on, to make reprogramming easier. You plug the USBASP into the 6-pin header, and click File-&gt;Upload using programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ADDITIONAL:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your project &quot;really nice&quot;, you can design and etch your own PCB. If &quot;good enough is good enough&quot; (which for me it always is), I suggest you use stripboard (also known by it's brandname, veroboard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case, spend some time thinking about your exact layout. Use a computer layout tool, and spend some time working out the best layout. I generally spend at least 5 times as much time on the layout, as I do on building the board - if a project is twice as big, I will spend twice as much time soldering, but at least 4 times as long laying it out.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2016-03-22T20:30:03.677" LastActivityDate="2016-03-22T20:30:03.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22100" PostTypeId="1" AcceptedAnswerId="22102" CreationDate="2016-03-22T04:42:51.207" Score="-1" ViewCount="1635" Body="&lt;p&gt;I recently purcahsed an si4703, from sparkfun&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11083&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/11083&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got it soldered to some headers and now I am not getting anything to work on it, my wire diagram is as follows&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w7Fyk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w7Fyk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;( I know the FM module pictured is different but its ultimately wired up the same I think)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I am just trying to run the out of box example code modified to my Arduino Mega board&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SparkFunSi4703.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int resetPin = 35;&#xA;int SDIO = A15;&#xA;int SCLK = A14;&#xA;&#xA;Si4703_Breakout radio(resetPin, SDIO, SCLK);&#xA;int channel;&#xA;int volume;&#xA;char rdsBuffer[10];&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;\n\nSi4703_Breakout Test Sketch&quot;);&#xA;  Serial.println(&quot;===========================&quot;); &#xA;  Serial.println(&quot;a b     Favourite stations&quot;);&#xA;  Serial.println(&quot;+ -     Volume (max 15)&quot;);&#xA;  Serial.println(&quot;u d     Seek up / down&quot;);&#xA;  Serial.println(&quot;r       Listen for RDS Data (15 sec timeout)&quot;);&#xA;  Serial.println(&quot;Send me a command letter.&quot;);&#xA;&#xA;  radio.powerOn();&#xA;  radio.setVolume(0);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;looping&quot;);&#xA;  if (Serial.available())&#xA;  {&#xA;    char ch = Serial.read();&#xA;    if (ch == 'u')&#xA;    {&#xA;      channel = radio.seekUp();&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == 'd')&#xA;    {&#xA;      channel = radio.seekDown();&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == '+')&#xA;    {&#xA;      volume ++;&#xA;      if (volume == 16) volume = 15;&#xA;      radio.setVolume(volume);&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == '-')&#xA;    {&#xA;      volume --;&#xA;      if (volume &amp;lt; 0) volume = 0;&#xA;      radio.setVolume(volume);&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == 'a')&#xA;    {&#xA;      channel = 930; // Rock FM&#xA;      radio.setChannel(channel);&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == 'b')&#xA;    {&#xA;      channel = 1067; // BBC R4&#xA;      radio.setChannel(channel);&#xA;      displayInfo();&#xA;    }&#xA;    else if (ch == 'r')&#xA;    {&#xA;      Serial.println(&quot;RDS listening&quot;);&#xA;      radio.readRDS(rdsBuffer, 15000);&#xA;      Serial.print(&quot;RDS heard:&quot;);&#xA;      Serial.println(rdsBuffer);     &#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void displayInfo()&#xA;{&#xA;   Serial.print(&quot;Channel:&quot;); Serial.print(channel);&#xA;   Serial.print(&quot; Volume:&quot;); Serial.println(volume);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However I do not think it is ever getting to the actual loop, it seems to get stuck on the code &lt;code&gt;radio.powerOn()&lt;/code&gt; and then does nothing after that, what can I do to make this work?&lt;/p&gt;&#xA;" OwnerUserId="19501" LastActivityDate="2016-06-20T08:08:17.277" Title="Sparkfun Si4703 FM not getting to loop" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22101" PostTypeId="1" CreationDate="2016-03-22T06:06:07.243" Score="1" ViewCount="2157" Body="&lt;p&gt;I have an Arduino sketch that controls an LED through the Internet, and another through Bluetooth. The thing is I want to combine both sketches so that I can control my Arduino LED by Bluetooth as well as through the Internet. Is it possible to do that?&lt;/p&gt;&#xA;" OwnerUserId="18794" LastEditorUserId="4628" LastEditDate="2017-03-08T13:34:09.313" LastActivityDate="2017-03-08T16:52:46.707" Title="Controlling Arduino through Internet and Bluetooth" Tags="|bluetooth|web|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22102" PostTypeId="2" ParentId="22100" CreationDate="2016-03-22T06:15:19.113" Score="1" Body="&lt;p&gt;According to your hookup image, you have connected I2c pins to A14 and A15, I2c on Mega is on pins 20 and 21 , clearly marked SDA and SCL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that this module can ba powered by 5V but is only 3.3V tolerant on the input pins, you should use a level converter.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-22T06:15:19.113" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22104" PostTypeId="1" AcceptedAnswerId="22150" CreationDate="2016-03-22T07:14:35.803" Score="0" ViewCount="388" Body="&lt;p&gt;Is it possible to have an Arduino Uno + WiFi 101 recognize when the USB cable has been connected and prompt a user to enter a network name and password?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can this be stored on the Arduino itself or does it need to be something run locally on the user's PC?&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-03-23T01:19:49.387" Title="Open WiFi Configuration Automatically" Tags="|wifi|networking|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22106" PostTypeId="2" ParentId="22040" CreationDate="2016-03-22T09:25:15.433" Score="1" Body="&lt;p&gt;I believe you are looking for something like the &lt;a href=&quot;https://github.com/Overdrivr/Telemetry&quot; rel=&quot;nofollow noreferrer&quot;&gt;Telemetry&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Full disclaismer : I am the author&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It allows you to send string, numbers, arrays, sparse arrays through the serial port for instance. Each sent data has a label, called topic, that is used to identify it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/Overdrivr/pytelemetrycli&quot; rel=&quot;nofollow noreferrer&quot;&gt;Pytelemety command line interface&lt;/a&gt; then allows you to connect to the serial port, plot received data in real time, write parameters to reconfigure the arduino from the computer, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of arduino code thats send an incrementing counter&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Telemetry.h&amp;gt;&#xA;&#xA;Telemetry TM;&#xA;int8_t counter;&#xA;&#xA;void setup() {&#xA;  TM.begin(115200);&#xA;  counter = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;  TM.pub_i8(&quot;count&quot;,counter);&#xA;  counter++;&#xA;  delay(10); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Overview of the CLI (Command-Line Interface)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/mdnAs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mdnAs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Overview of a graph (not produced by the arduino program above)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/FifYF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FifYF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output to file is not implemented yet, although all received data is logged to a file (but this log also contains system information). However, this is an interesting feature, quite straightforward to implement, that I might add in coming days if you are interested.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Central documentation is available &lt;a href=&quot;https://github.com/Overdrivr/Telemetry/wiki&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="17188" LastActivityDate="2016-03-22T09:25:15.433" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22107" PostTypeId="2" ParentId="13721" CreationDate="2016-03-22T10:09:44.623" Score="1" Body="&lt;p&gt;I see several options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Change your code to achieve lower delays on the other functions&lt;/li&gt;&#xA;&lt;li&gt;Use interrupts at a set frequency to trigger the sending (and maybe the automatic transmission trigger pins, see MCP2515 datasheet, depending on pin use &amp;amp; schematic of your specific shield)&lt;/li&gt;&#xA;&lt;li&gt;Use a basic scheduler/rtos&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It is hard to tell what is going on without the rest of your code, if it is a good idea to try to achieve faster functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not 100% sure the CAN-lib would will work well in the context of an interrupt.&lt;/p&gt;&#xA;" OwnerUserId="19504" LastEditorUserId="6936" LastEditDate="2016-03-26T03:09:57.993" LastActivityDate="2016-03-26T03:09:57.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22108" PostTypeId="2" ParentId="22101" CreationDate="2016-03-22T10:16:22.167" Score="2" Body="&lt;p&gt;If I were you, I would separate the &quot;hardware&quot; from the &quot;software&quot;. This is quite an interesting &quot;pattern&quot;. It's used by almost every Operating System, to assure compatibility with devices all around the world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Layers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;OSI-model&quot; typically describes a few layers. But to me, the most interesting part is the difference between &quot;Host layer&quot; and &quot;Media layer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Media Layer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The media layer(s) typically handle the transportation of your bits, addressing and data collision. In &quot;the internet&quot; you can 'simply' change from copper to glasfiber without it being noticeable in your end application (apart from being faster).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Host layer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same for the host layers, whatever PC or network adapter you have, your program will run fine (if this abstraction/integration is done well).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Applying this&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do we apply this? In a basic, small application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5BOJH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5BOJH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We want our Host to not care too much about which Media(layer) it is using.&#xA;The Arduino has to be able to be configured or detect which media layer it is using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this is neccesary (this is not actual code, more pseudo code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String messageBuffer = &quot;&quot;;&#xA;&#xA;void Setup(){&#xA;   setupWifi(pin1,pin2);&#xA;   setupBluetooth(pin3,pin4);&#xA;}&#xA;&#xA;void Loop(){&#xA;   messageBuffer = getWifiMessage();&#xA;   handleMessage(messageBuffer);&#xA;   messageBuffer = getBluetoothMessage();&#xA;   handleMessage(messageBuffer);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you set up this correctly, you'll only have to write the buffer handling code once. Which is very useful!&#xA;Handling buffers along with all the logic/effects it will cause, should be solid. You (probably) don't want different behaviour when you use bluetooth as when you use WiFi. Imagine your web-browser only working when you use copper, but not when you use glasfiber :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Protocol&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your message should be exactly the same for WiFi and bluetooth. This way you won't have to deal with two different protocols and it will be easier to implement this at the other (control) side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good protocol/message can be this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;@12#13,255,255,0;&quot;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I use the @ as an start indication. This is very usefull for receiving, since you know where to start (obviously?).&lt;/li&gt;&#xA;&lt;li&gt;You'll have to make rules for what will follow (maybe a set amount of characters, in my example, between @ and # it will indicate an &quot;address&quot;. When you send it to multiple devices, you only want (in my example) device 12 to react. This often is handled by the bluetooth or wifi already, but it can be good to have some sort of unique header. So that random messages (which might look alike) won't be seen as one of your messages.&lt;/li&gt;&#xA;&lt;li&gt;An message ID is useful, you kinda want to have different types of messages, for either &quot;LED brightness&quot; or &quot;debug request&quot; or &quot;set output&quot;.&lt;/li&gt;&#xA;&lt;li&gt;Each message could have an x amount of parameters, it's often better to separate these. It's important that you specify the maximal amount of parameters and what behavior they will cause.&lt;/li&gt;&#xA;&lt;li&gt;Some protocols use a set length, but an end delimiter &quot;;&quot; is often the best way to let the other device know your message is completely received.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Some notes&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Try to aim for existing protocols, it will be cool if your device is compatible and creating yet another protocol isn't particularly useful.&lt;/li&gt;&#xA;&lt;li&gt;Mind that possible transmitted text does not include your start/end delimiters. You could use the message length or exclusions/inclusions in this case.&lt;/li&gt;&#xA;&lt;li&gt;Be wary that the protocol adds overhead. But usually being able to &quot;read&quot; a message will make it much more easier to program a handler or generally work with it.&lt;/li&gt;&#xA;&lt;li&gt;Check if the message is fully received and does not have errors. If you have an error, be sure your system can handle it and will respond with a message telling so. In no way your system should lock down on error or not provide a reaction (which makes debugging a pain).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The server&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From whatever device you're sending your stuff, it should have bluetooth and/or WiFi. Bluetooth is fairly easy and should get you started quite fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using WiFi, you should check if your device can make a TCP/IP connection. TCP/IP is basically a &quot;shell&quot; around your message, to shoot it over the internet ;D it comes with some neat addressing and error checking built in (but you can't be 100% sure there will be no error between your receiver and arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;But why?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only is it useful to learn how to do this, having to write the handler and protocol specification for both the Wifi and bluetooth (and possible usb, rf, ethernet etc). &#xA;Apart from that, in embedded systems, you want to be sure that something works, using different handlers for different physical layers will create vague specific errors and might rip up your program logic. Also, if your protocol/application is used/reviewed by more people, you'll be more certain that it works well.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-03-22T10:24:41.213" LastActivityDate="2016-03-22T10:24:41.213" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22109" PostTypeId="2" ParentId="20838" CreationDate="2016-03-22T10:20:42.297" Score="2" Body="&lt;p&gt;Beware, the industry standard pinout for CAN on DB9 connectors is different to what Sparkfun use on their shield:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pin 3/5 &lt;a href=&quot;https://www.sparkfun.com/datasheets/DevTools/Arduino/canbus_shield-v12.pdf&quot; rel=&quot;nofollow&quot;&gt;CAN bus shield schematic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;pin 2/7 (Vector tools for example).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Which software have you been using on the Arduino? Any additional info on the ECU you're using, and the wiring in your system?&lt;/p&gt;&#xA;" OwnerUserId="19504" LastEditorUserId="6936" LastEditDate="2016-03-25T10:24:08.760" LastActivityDate="2016-03-25T10:24:08.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22110" PostTypeId="1" CreationDate="2016-03-22T10:27:34.613" Score="0" ViewCount="139" Body="&lt;p&gt;How to remove the program from arduino board which is already there in it.?And I need that program in my arduino IDE how to take it please help me?&lt;/p&gt;&#xA;" OwnerUserId="19505" LastEditorUserId="31105" LastEditDate="2017-04-04T18:11:24.733" LastActivityDate="2017-04-04T18:11:24.733" Title="Take the program from the arduino board" Tags="|arduino-ide|" AnswerCount="3" CommentCount="2" ClosedDate="2016-03-26T23:17:31.223" ContentLicense="CC BY-SA 3.0" />
  <row Id="22111" PostTypeId="2" ParentId="19707" CreationDate="2016-03-22T10:29:49.363" Score="2" Body="&lt;p&gt;Technically, yes: If you hook up this shield to the car buses through OBD-II, and know which messages to send (e.g., ones that the car will accept and work with), then it will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is: There are some &quot;official&quot; messages, basically emission related stuff, that are mandatory on every cars. There are lists of these out there.&#xA;Unfortunately, most messages are OEM dependent (including those that may control the basic features you mentioned), and they don't want you to mess around this.&#xA;Said differently: The semantic of CAN frames/messages varies from one car to another.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being able to send receive CAN frames (which this shield is) is like being able to emit sounds &amp;amp; hear them: Mandatory, if you want to discuss with someone, but useless/not enough if you do not speak the same language.&lt;/p&gt;&#xA;" OwnerUserId="19504" LastEditorUserId="6936" LastEditDate="2016-03-25T10:40:09.457" LastActivityDate="2016-03-25T10:40:09.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22112" PostTypeId="2" ParentId="22110" CreationDate="2016-03-22T10:52:09.433" Score="1" Body="&lt;p&gt;You can't. The program in the Arduino IDE is compiled to machine code (bits and bytes basically) and that's what is uploaded to the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2016-03-22T10:52:09.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22113" PostTypeId="2" ParentId="18620" CreationDate="2016-03-22T10:59:19.497" Score="2" Body="&lt;p&gt;The main question is: Which features do you want to have on your board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can start off with the design files of the Arduino board you are using: update what you need (and don't need). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, for the manufacturing itself, several approaches will work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;veroboard &amp;amp; through hole components. Not very practical, not small, but easy;&lt;/li&gt;&#xA;&lt;li&gt;DIY manufacturing: toner transfer method, or if you have a CNC, isolation milling;&lt;/li&gt;&#xA;&lt;li&gt;Boardhouse (e.g. PCB manufacturer) to whom you send your finished design to have it manufactured.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to use a smaller board, like an Arduino nano: it all depends on what your constraints/goals are.&lt;/p&gt;&#xA;" OwnerUserId="19504" LastEditorUserId="6936" LastEditDate="2016-03-25T10:37:06.550" LastActivityDate="2016-03-25T10:37:06.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22114" PostTypeId="2" ParentId="22101" CreationDate="2016-03-22T11:05:31.130" Score="1" Body="&lt;p&gt;&lt;em&gt;Judging from your reaction, you don't want to use a WiFi/Bluetooth/Ethernet shield&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino has no built-in Bluetooth or Ethernet.&#xA;The question is shifting a little towards software, but okay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. Using your PC as Ethernet/Bluetooth receiver&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can (and I believe you want to) use your PC as the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Bma5F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Bma5F.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Talking in network terms, your phone has to become a &quot;client&quot; and your PC will become a &quot;server&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would advise using &lt;a href=&quot;https://processing.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Processing&lt;/a&gt; on your PC as a &quot;Server&quot;.&#xA;Within processing you can &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing&quot; rel=&quot;nofollow noreferrer&quot;&gt;easily set up a connection to your Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And even use your &lt;a href=&quot;http://www.extrapixel.ch/processing/bluetoothDesktop/&quot; rel=&quot;nofollow noreferrer&quot;&gt;PC's bluetooth&lt;/a&gt; or you might just set up a &lt;a href=&quot;http://windows.microsoft.com/nl-nl/windows/choose-com-port-bluetooth#1TC=windows-7&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;bluetooth COM port&quot;&lt;/a&gt; which makes your Bluetooth device look like a serial device like the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a little catch though. Processing can easily set up a TCP/IP connection. On your phone this might be a little less trivial. Your browser generally uses HTTP(s) to connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you should either &lt;a href=&quot;https://processing.org/discourse/beta/num_1231628867.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;implement HTTP in Processing&lt;/a&gt; or &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.sollae.eztcpclient&quot; rel=&quot;nofollow noreferrer&quot;&gt;make/use an app that supports TCP/IP message sending&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="4628" LastEditDate="2017-03-08T13:35:47.930" LastActivityDate="2017-03-08T13:35:47.930" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22115" PostTypeId="2" ParentId="22110" CreationDate="2016-03-22T11:07:06.840" Score="1" Body="&lt;p&gt;It's a bit like baking a cake. Or brewing cider. Once you have baked your cake can you get the eggs, flour and sugar back again? Can you make apples from cider? No. And it's the same with compiling. Once you have compiled your source code you can't turn it back into source code again.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-22T11:07:06.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22116" PostTypeId="1" AcceptedAnswerId="22117" CreationDate="2016-03-22T11:28:48.147" Score="0" ViewCount="9175" Body="&lt;p&gt;I have a rather newbie question but I can't figure it out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets say I have this char array: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char array[] = &quot;10,11,12,1,0,1,0&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I convert it to an array of int like this? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int arrayINT[] = {10,11,12,1,0,1,0};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19507" LastEditorUserId="15427" LastEditDate="2016-03-23T14:18:58.317" LastActivityDate="2016-03-23T14:18:58.317" Title="How to convert array of chars to array of ints?" Tags="|c++|c|string|array|convert|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22117" PostTypeId="2" ParentId="22116" CreationDate="2016-03-22T11:41:53.947" Score="7" Body="&lt;p&gt;If you have a C string containing ASCII numbers with a common delimiter (comma in this case) you can use the &lt;code&gt;strtok()&lt;/code&gt; function to split it into individual strings.  Then you can use &lt;code&gt;atoi()&lt;/code&gt; to convert those individual strings into integers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char array[] = &quot;10,11,12,1,0,1,0&quot;;&#xA;int intArray[7]; // or more if you want some extra room? &#xA;&#xA;int ipos = 0;&#xA;// Get the first token from the string&#xA;char *tok = strtok(array, &quot;,&quot;);&#xA;// Keep going until we run out of tokens&#xA;while (tok) {&#xA;    // Don't overflow your target array&#xA;    if (ipos &amp;lt; 7) {&#xA;        // Convert to integer and store it&#xA;        intArray[ipos++] = atoi(tok);&#xA;    }&#xA;    // Get the next token from the string - note the use of NULL&#xA;    // instead of the string in this case - that tells it to carry&#xA;    // on from where it left off.&#xA;    tok = strtok(NULL, &quot;,&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;strtok()&lt;/code&gt; is a &lt;em&gt;destructive&lt;/em&gt; function. It will decimate your existing string with NULL characters as it slices it up.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-22T11:41:53.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22119" PostTypeId="2" ParentId="21976" CreationDate="2016-03-22T11:55:52.757" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hb40X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hb40X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think your schematic might be wrong there. Only one MEGA is connected to a positive side of a battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MEGA can only run on 7V to 12V. &lt;em&gt;BUT PLEASE DO NOT apply the voltage to the &lt;code&gt;3V3&lt;/code&gt; or &lt;code&gt;5V&lt;/code&gt; pin.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Microcontroller ATmega1280&#xA;Operating Voltage   5V&#xA;Input Voltage (recommended) 7-12V&#xA;Input Voltage (limits)  6-20V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also, I would only put in another MEGA when you don't have enough I/O pins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Digital I/O Pins    54 (of which 15 provide PWM output)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In theory you could use 13 steppers on one MEGA. Try slowly scaling up.&#xA;You don't need PWM for steppers, maybe you're confused with servo's?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And why not use one of the stepper-driving MEGA's as the master? (In the first picture, slave 1 isn't even connected to the SDA/SCL lines of the I2C bus.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-22T11:55:52.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22120" PostTypeId="1" CreationDate="2016-03-22T12:43:00.993" Score="1" ViewCount="1259" Body="&lt;p&gt;I'm using an Arduino clone (&lt;a href=&quot;http://www.seeedstudio.com/wiki/Seeeduino_Lotus_v1.0&quot; rel=&quot;nofollow&quot;&gt;Seeeduino Lotus&lt;/a&gt;) together with a Shinyei PPD42NS sensor to measure air quality. The sensor reports its measurement as Low-Pulse occupancy. What would be the best way how to collect the value with Arduino? Currently I'm simply looping for some predefined duration using &lt;a href=&quot;https://www.arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;pulseIn&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;unsigned long starttime;&#xA;register unsigned long sample_time; // ms&#xA;register unsigned long lowpulseoccupancy = 0; // us&#xA;&#xA;// Wait for the signal to return to HIGH&#xA;pulseIn(DUSTPIN, LOW);&#xA;// Now start measuring&#xA;starttime = millis();&#xA;while ((sample_time = (millis() - starttime)) &amp;lt; DUST_SAMPLE_TIME_MS) {&#xA;    lowpulseoccupancy += pulseIn(DUSTPIN, LOW);&#xA;}&#xA;&#xA;ratio_pct = lowpulseoccupancy / (sample_time * 10.0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a better way? In particular, this tight loop prevents Arduino from doing anything else for 30s (or a similar period).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking about using &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;interrupts&lt;/a&gt;, either triggering on &lt;code&gt;CHANGE&lt;/code&gt;, or (if that's possible) having two functions, one triggering on &lt;code&gt;RISING&lt;/code&gt; and another on &lt;code&gt;FALLING&lt;/code&gt;. Are there any caveats when doing so?&lt;/p&gt;&#xA;" OwnerUserId="19445" LastActivityDate="2016-11-17T20:15:05.313" Title="Measuring LPO (Low-Pulse Occupancy)" Tags="|interrupt|digital|input|pulsein|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22121" PostTypeId="2" ParentId="12134" CreationDate="2016-03-22T13:05:41.823" Score="0" Body="&lt;p&gt;Have you tried this lib's documentation? It looks like just doing &lt;code&gt;init()&lt;/code&gt; and then checking the task state is not enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking &lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0/blob/master/Usb.cpp&quot; rel=&quot;nofollow&quot;&gt;at the source code&lt;/a&gt; makes me think you might want to add a call to the main task/state machine, e.g. add a call to &lt;code&gt;Usb.Task();&lt;/code&gt; to your loop, before your &lt;code&gt;if&lt;/code&gt; statement.&lt;/p&gt;&#xA;" OwnerUserId="19504" LastEditorUserId="6936" LastEditDate="2016-03-25T10:18:25.777" LastActivityDate="2016-03-25T10:18:25.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22123" PostTypeId="1" CreationDate="2016-03-22T14:23:51.273" Score="0" ViewCount="273" Body="&lt;p&gt;I am working on an Arduino project that replaces the computer mouse. I want to do this in combination with an ultrasonic sensor. I found some nice examples on youtube, but they didn't post the code. And an example on this website. But I don't get it completely. I don't have much Arduino skills, but do have some. How can you attach for example &lt;code&gt;echoPinScroll&lt;/code&gt; to a board?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope someone can give me advice on how to use this ultrasonic to control my mouse!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Mouse.h&amp;gt;&#xA;&#xA;int echoPinCursor=2;&#xA;int trigPinCursor=3;&#xA;&#xA;int echoPinBtn=4;&#xA;int trigPinBtn=5;&#xA;int echoPinScroll=6;&#xA;int trigPinScroll=7;&#xA;int x;&#xA;int y;&#xA;long duracionCursor, distanciaCursor;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA; pinMode(trigPinCursor, OUTPUT);&#xA; pinMode(echoPinCursor, INPUT);&#xA; pinMode(trigPinBtn, OUTPUT);&#xA; pinMode(echoPinBtn, INPUT);&#xA; pinMode(trigPinScroll, OUTPUT);&#xA; pinMode(echoPinScroll, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;//mover el cursor&#xA;int direccionx=moverx();&#xA;int direcciony=movery();&#xA;&#xA;Mouse.move(direccionx, direcciony,0);&#xA;delay(2);&#xA;&#xA;}&#xA;&#xA;int moverx(){&#xA;distanciaCursor=obtener_distanciaCursor();&#xA;if (distanciaCursor &amp;gt;= 1  || distanciaCursor &amp;lt;= 11){&#xA;   x--;&#xA; }&#xA;if (distanciaCursor &amp;gt;= 12 || distanciaCursor &amp;lt;= 24){&#xA;   x++;&#xA;  }&#xA; return x;&#xA;}&#xA;&#xA;int movery(){&#xA;distanciaCursor=obtener_distanciaCursor();&#xA;if (distanciaCursor &amp;gt;= 25 || distanciaCursor &amp;lt;= 37){&#xA;   y--;&#xA;   }&#xA;if (distanciaCursor &amp;gt;= 38 || distanciaCursor &amp;lt;= 50){&#xA;   y++;&#xA;  }&#xA;return y;&#xA;}&#xA;&#xA;long obtener_distanciaCursor(void)&#xA;{&#xA;digitalWrite(trigPinCursor, LOW);&#xA;delayMicroseconds(2);&#xA;&#xA;digitalWrite(trigPinCursor, HIGH);&#xA;delayMicroseconds(10);&#xA;&#xA;digitalWrite(trigPinCursor, LOW);&#xA;duracionCursor = pulseIn(echoPinCursor, HIGH);&#xA;&#xA;distanciaCursor = duracionCursor/58.2;&#xA;return(distanciaCursor);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19512" LastEditorUserId="6936" LastEditDate="2016-03-26T03:14:29.840" LastActivityDate="2016-03-26T03:14:29.840" Title="How to combine Leonardo with Ultrasonic sensor?" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22124" PostTypeId="2" ParentId="22096" CreationDate="2016-03-22T14:28:09.873" Score="1" Body="&lt;p&gt;I did an awful try at making a nice breadboard for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you're better off using some perfboard, small solderable wires and an Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w6noM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w6noM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This because the Arduino Nano has an FTDI chip, crystal and power regulator and is barely bigger than an 328 DIP package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could easily mount the pieces of perfboard inside/on your enclosure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aim to add the snooze button on top with the settings buttons on the sides.&#xA;The buzzer could be in the back or other side. The display (if any) should be in the front. Your &quot;Neopixels&quot; are no different than WS2812B &quot;led's&quot;.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-03-23T10:28:53.203" LastActivityDate="2016-03-23T10:28:53.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22125" PostTypeId="2" ParentId="22096" CreationDate="2016-03-22T15:26:56.027" Score="2" Body="&lt;p&gt;Several steps are required:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Define what you want&lt;/strong&gt; to achieve in a clear and explicit manner, eg start documenting your project by writing down your decisions and design goals, for example on a project wiki somewhere. This could be the time where you explore the internet to gather several inspirational sources &amp;amp; modules you want to reuse.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check that your schematic is correct&lt;/strong&gt;, eg that first prototype works reliably. Obviously, going from prototype to a &quot;more permanent prototype&quot; should include checking everything works as expected (getting validation from here would be an option).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prepare a hardware design&lt;/strong&gt;, eg routing on your prefered CAD software. Many options exist: Fritzing, Eagle, Kicad, ... You may need help/tutorials to do this properly&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Manufacture the pcb&lt;/strong&gt;, or get your board manufactured. Several options are available (see below)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Assemble &amp;amp; test&lt;/strong&gt;; depending on results, go back to step 1, 2, 3 ;)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;check that your schematic&lt;/strong&gt; is correct, well, you can post it somewhere. As a starter: your initial post has some errors.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;resistors required for LED&lt;/li&gt;&#xA;&lt;li&gt;red (+) seems to be on GND, not +5v (!!)&lt;/li&gt;&#xA;&lt;li&gt;using a pulldown for the button where an internal pullup is sufficient is a waste of ressource&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Answer above has errors, too (as stated). So make sure your schematic &amp;amp; prototype work before trying to get it more permanent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To &lt;strong&gt;manufacture the PCB&lt;/strong&gt;, several options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Veroboard &amp;amp; through hole components. Not small, but cheap, easy &amp;amp; reliable.&lt;/li&gt;&#xA;&lt;li&gt;DIY: toner transfer method (numerous examples &amp;amp; howto online) :&#xA;requires a bit more time/skills, but if you plan to do several&#xA;boards/experiments, can be worth it. Can be rather cheap. Cannot&#xA;yield high precision pcb.&#xA;Note: other DIY PCB manufacturing techniques exist.&lt;/li&gt;&#xA;&lt;li&gt;boardhouse contract manufacturing: yields perfect results (if your&#xA;design files are OK...), can't be quick &amp;amp; cheap (but can be either,&#xA;relatively)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19504" LastActivityDate="2016-03-22T15:26:56.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22126" PostTypeId="2" ParentId="22123" CreationDate="2016-03-22T16:18:53.027" Score="1" Body="&lt;p&gt;What is your hardware setup?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your code, it looks like you're not using the pins &lt;code&gt;trigPinBtn, echoPinBtn, trigPinScroll, echoPinScroll&lt;/code&gt;. Weird. I can't figure out:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;which ultrasound module you're using&lt;/li&gt;&#xA;&lt;li&gt;what do you expect, eg which movement(s) in front of which ultrasound sensor shall generate which mouse action(s)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I would recommand having an iterative approach:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Play with your ultrasound sensor(s), eg understand properly how to wire them to the arduino, how to interface them (software/lib), what kind of values you can get from them, etc... This will depend on the HW module you have chosen (if any yet).&lt;/li&gt;&#xA;&lt;li&gt;Read the documentation that comes with the mouse lib of the Leonardo and play with it independently/with existing, working examples.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;That is divide and conquer: understand each bit before trying to assemble them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;THEN, and only then, you will have a better understanding of the different part of your project. You will then be able to formulate an overview of your project goals, and how you can do it. That is, start documenting your project &lt;strong&gt;before&lt;/strong&gt; it is done: doing so will &lt;s&gt;force&lt;/s&gt; help you to have a clear idea of &lt;strong&gt;what&lt;/strong&gt; it is that you're trying to achieve... and thus how to achieve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But yeah, the overall project might look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Ultrasound distance sensor #1, hooked to the arduino with xxx and yyy; generates movement along the x axis&#xA;// Ultrasound distance sensor #2, hooked to the arduino with zzz and ttt ; generates movement along the y axis&#xA;// Something for the wheel? The buttons?&#xA;&#xA;//global values &amp;amp; objects&#xA;setup()&#xA;//initialize hardware&amp;amp; libs&#xA;&#xA;loop()&#xA;//get raw ultrasound distances&#xA;//translate these into x and y movements&#xA;//do something about buttons &amp;amp; wheel?&#xA;//update mouse values&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19504" LastActivityDate="2016-03-22T16:18:53.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22127" PostTypeId="2" ParentId="22120" CreationDate="2016-03-22T16:26:51.823" Score="1" Body="&lt;p&gt;You can trigger on &lt;code&gt;CHANGE&lt;/code&gt;, and check in your handler which case it is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   attachInterrupt(digitalPinToInterrupt(my_pin), my_handler, CHANGE);&#xA;    (...)&#xA;    void my_handler(void) {&#xA;      if(LOW==digitalRead(my_pin)) {&#xA;        //do_falling();&#xA;      }&#xA;      else {&#xA;        //do_rising();&#xA;      }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use a timer to poll your input, and implement a logic on top of this.&lt;/p&gt;&#xA;" OwnerUserId="19504" LastActivityDate="2016-03-22T16:26:51.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22128" PostTypeId="1" AcceptedAnswerId="37290" CreationDate="2016-03-22T16:39:34.640" Score="1" ViewCount="10726" Body="&lt;p&gt;Guys please help me out in verifying my program for my project -- led fading effect using a push button.&lt;/p&gt;&#xA;&lt;p&gt;My project is simple, I want to start the LED fading effect (i.e., glowing and dimming one after another) at one click on the push button that is pushing and then leaving the push button and on my another click I want the effect to get off.&lt;/p&gt;&#xA;&lt;p&gt;The main problem is coming in the programming part and rest all the circuit and components are fine.&lt;/p&gt;&#xA;&lt;p&gt;THIS IS MY SKETCH :-&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int ledpin = 9;&#xA;int buttonpin = 8;&#xA;boolean buttonpressed = false;   // to check whether the button was pressed //&#xA;int brightness = 0;&#xA;int fadeamount = 5;&#xA;&#xA;void setup ()&#xA;{ &#xA;pinMode (ledpin, OUTPUT);&#xA;pinMode (buttonpin,INPUT);&#xA;digitalWrite (ledpin,LOW);&#xA;}&#xA;&#xA;void loop ()&#xA;{      &#xA;if ( digitalRead (buttonpin) == HIGH)&#xA; { &#xA;  buttonpressed = true;&#xA; }&#xA;&#xA; else {&#xA;     if ( buttonpressed = true &amp;amp;&amp;amp; digitalRead(ledpin) == LOW)&#xA;       {&#xA;           brightness = brightness + fadeamount;&#xA;           if ( brightness == 0 || brightness == 255)&#xA;            { &#xA;             fadeamount = -fadeamount;}&#xA;             analogWrite(ledpin, brightness);&#xA;             delay (30);&#xA;             buttonpressed = false;&#xA;        }&#xA;      if (buttonpressed == true &amp;amp;&amp;amp; analogRead(ledpin) == brightness)&#xA;        {&#xA;          digitalWrite(ledpin,LOW); &#xA;          buttonpressed = false;&#xA;        }&#xA;   }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;THIS IS THE CIRCUIT DIAGRAM&lt;/strong&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/LYfci.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LYfci.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19511" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-05-24T10:16:10.577" Title="LED fading effect using a push button" Tags="|arduino-uno|electricity|" AnswerCount="5" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22129" PostTypeId="2" ParentId="22128" CreationDate="2016-03-22T16:48:27.240" Score="0" Body="&lt;p&gt;There are basically two parts to your program and it's best if you deal with them completely separately:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Reading a push button to turn fading on or off&lt;/li&gt;&#xA;&lt;li&gt;Fading if fading is turned on&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Start by making an LED fade all the time. The Fade example can help you with that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then as a separate sketch program the button to turn an LED on or off each time you press it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have those working change the LED in the second sketch to setting a flag, and make the code from the first sketch look at that flag.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-22T16:48:27.240" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22130" PostTypeId="2" ParentId="22110" CreationDate="2016-03-22T17:03:56.280" Score="3" Body="&lt;p&gt;You can retrieve the program currently in your Arduino with the&#xA;&lt;code&gt;avrdude&lt;/code&gt; tool. This tool comes with the Arduino installation. The way&#xA;to call it is somewhat OS-dependent. On Ubuntu, for an Arduino Uno, I&#xA;type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -p atmega328p -c arduino -P /dev/ttyACM0 -b 115200 -D -U flash:r:prog.hex:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates the file &lt;code&gt;prog.hex&lt;/code&gt; with your program in &lt;a href=&quot;https://en.wikipedia.org/wiki/Intel_HEX&quot; rel=&quot;nofollow&quot;&gt;Intel&#xA;HEX&lt;/a&gt; format. You can save this&#xA;file if you want to re-install it on the Arduino later. You can also&#xA;turn this file into an assembly listing with &lt;code&gt;avr-objdump&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -m avr -Dz prog.hex &amp;gt; prog.lst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may be able to make some sense of this listing if&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you are well versed in AVR assembly language&lt;/li&gt;&#xA;&lt;li&gt;you have lots of spare time&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As others have said, you cannot expect to get the original C++ source&#xA;back.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-22T17:03:56.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22131" PostTypeId="2" ParentId="22128" CreationDate="2016-03-22T17:04:28.043" Score="3" Body="&lt;p&gt;The 1k (pulldown-)resistor must be placed at the other side of the button (the pin8 side, not the 5v side).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The led needs a resistor, to limit the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no need for the &lt;code&gt;buttonstate&lt;/code&gt; variable, as you can just check the brightness to see if the PWM value must be changed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledpin = 9;&#xA;int pushbutton = 8;&#xA;&#xA;int brightness = 0;&#xA;int fadeamount = 1;&#xA;&#xA;void setup ()&#xA;{ &#xA;  pinMode (ledpin,OUTPUT);&#xA;  pinMode (pushbutton,INPUT);&#xA;}&#xA;&#xA;void loop ()&#xA;{ &#xA;  if( digitalRead(pushbutton)==HIGH &amp;amp;&amp;amp; brightness&amp;lt;255 )&#xA;  {&#xA;    // fade in led &#xA;    brightness = brightness + fadeamount;// increase brightness&#xA;    if( brightness&amp;gt;255 ) // check that brightness doesn't exceed 255&#xA;      brightness = 255;&#xA;    analogWrite(ledpin,brightness);&#xA;    delay (1);&#xA;  }&#xA;  else if( digitalRead(pushbutton)==LOW &amp;amp;&amp;amp; brightness&amp;gt;0 )&#xA;  {&#xA;    // fade out led&#xA;    brightness = brightness - fadeamount;// decrease brightness&#xA;    if( brightness&amp;lt;0 ) // check that brightness doesn't go below 0&#xA;      brightness = 0;&#xA;    analogWrite(ledpin,brightness);&#xA;    delay (1);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-03-22T17:04:28.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22132" PostTypeId="2" ParentId="22128" CreationDate="2016-03-22T17:06:55.820" Score="2" Body="&lt;p&gt;try this, its simple and easy to understand,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 9;&#xA;int btnPin = 8;&#xA;int brightness = 0;&#xA;int btnState = LOW;&#xA;bool trigger = LOW;&#xA;void setup ()&#xA;{&#xA;  pinMode (ledPin, OUTPUT);&#xA;  pinMode (btnPin, INPUT);&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  if ( digitalRead(btnState) &amp;amp;&amp;amp; !btnState)&#xA;  {&#xA;    if (trigger)&#xA;    {&#xA;      for (int i = 0; i &amp;lt; 256; i++)&#xA;      {&#xA;        analogWrite(ledPin, i);&#xA;        // wait for 30 milliseconds to see the dimming effect&#xA;        delay(30);&#xA;      }&#xA;    }&#xA;    else&#xA;    {&#xA;      for (int i = 255; i &amp;gt;= 0; i--)&#xA;      {&#xA;        analogWrite(ledPin, i);&#xA;        // wait for 30 milliseconds to see the dimming effect&#xA;        delay(30);&#xA;      }&#xA;    }&#xA;    trigger = !trigger;&#xA;  }&#xA;  btnState = digitalRead(btnState);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="19513" LastEditDate="2016-03-22T17:10:48.887" LastActivityDate="2016-03-22T17:10:48.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22133" PostTypeId="2" ParentId="2978" CreationDate="2016-03-22T19:24:48.030" Score="0" Body="&lt;p&gt;Try interchanging the Tx-Rx pins of your XBee-Arduino connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are getting correct values on the Arduino IDE, this means that both sensor and serial is working, but it sends values only when connected via USB which means that problem lies in your link between Arduino-Serial Device (in this case XBee)&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="6936" LastEditDate="2016-03-25T10:26:20.483" LastActivityDate="2016-03-25T10:26:20.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22135" PostTypeId="5" CreationDate="2016-03-22T21:48:05.117" Score="0" Body="&lt;p&gt;In computer programming, a callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. The invocation may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T13:08:20.153" LastActivityDate="2016-03-24T13:08:20.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22136" PostTypeId="4" CreationDate="2016-03-22T21:48:05.117" Score="0" Body="This refer to the call back procedure in computer programming." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:39:46.690" LastActivityDate="2016-04-12T07:39:46.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22137" PostTypeId="5" CreationDate="2016-03-22T21:51:15.357" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-22T21:51:15.357" LastActivityDate="2016-03-22T21:51:15.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22138" PostTypeId="4" CreationDate="2016-03-22T21:51:15.357" Score="0" Body="Refer to a software that simulate the behaviour of a particular device." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-23T14:19:20.517" LastActivityDate="2016-03-23T14:19:20.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22139" PostTypeId="5" CreationDate="2016-03-22T21:53:01.490" Score="0" Body="&lt;p&gt;The Raspberry Pi is a series of &lt;em&gt;credit card–sized&lt;/em&gt; single-board computers developed in England, United Kingdom by the Raspberry Pi Foundation with the intent to promote the teaching of basic computer science in schools and developing countries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a question about Raspberry Pi only, visit our sister site &lt;a href=&quot;https://raspberrypi.stackexchange.com/&quot;&gt;Raspberry Pi Stack Exchange&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="27346" LastEditDate="2017-10-27T12:14:28.027" LastActivityDate="2017-10-27T12:14:28.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22140" PostTypeId="4" CreationDate="2016-03-22T21:53:01.490" Score="0" Body="For questions about integrating the Arduino microcontroller with the single-board computer Raspberry Pi. Questions just about Raspberry Pi are off-topic but can be asked on Raspberry Pi Stack Exchange." OwnerUserId="19515" LastEditorUserId="27346" LastEditDate="2017-10-22T11:18:07.847" LastActivityDate="2017-10-22T11:18:07.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22141" PostTypeId="5" CreationDate="2016-03-22T22:00:02.783" Score="0" Body="&lt;p&gt;Java is a &lt;em&gt;high-level&lt;/em&gt;, &lt;em&gt;platform-independent&lt;/em&gt;, &lt;em&gt;object-oriented (OOP)&lt;/em&gt; programming language and run-time environment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Java language derives much of its syntax from C and C++, but its object model is simpler than that of C++ and it has fewer low-level facilities. Java applications are typically compiled to &lt;a href=&quot;https://en.wikipedia.org/wiki/Java_bytecode&quot; rel=&quot;nofollow&quot;&gt;bytecode&lt;/a&gt; (called &lt;a href=&quot;https://en.wikipedia.org/wiki/Java_class_file&quot; rel=&quot;nofollow&quot;&gt;class files&lt;/a&gt;) that can be executed by a JVM (Java Virtual Machine), independent of computer architecture. The JVM often further compiles code to native machine code to optimize performance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The JVM manages memory with the help of a &lt;strong&gt;garbage collector&lt;/strong&gt; in order to handle object removal from memory when not used any more. Java supports features such as reflection and interfacing with C and C++ via JNI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Java is designed to have as few implementation dependencies as possible, intended to allow application developers to &quot;&lt;strong&gt;write once, run anywhere&lt;/strong&gt;&quot; (WORA): code that executes on one platform does not need to be recompiled to run on another machine. Java was originally developed by [James Gosling] at Sun Microsystems (which merged with Oracle Corporation on April 20, 2009) and was released in 1995 as a core component of Sun Microsystems' Java platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The [Java platform] is the name given by Sun (now Oracle) to computing systems that have installed tools for developing and running Java programs. The platform features a wide variety of tools that can help developers work efficiently with the Java programming language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The platform consists of two essential software packages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;strong&gt;Java Runtime Environment (JRE)&lt;/strong&gt;, which is needed to &lt;em&gt;run&lt;/em&gt; Java applications and applets; and,&lt;/li&gt;&#xA;&lt;li&gt;the &lt;strong&gt;Java Development Kit (JDK)&lt;/strong&gt;, which is needed to &lt;em&gt;develop&lt;/em&gt; Java applications and applets. The JDK comes with a JRE.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In this section, we will explore in further detail what these two software components of the Java platform do.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:30.397" LastActivityDate="2016-03-29T18:31:30.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22142" PostTypeId="4" CreationDate="2016-03-22T22:00:02.783" Score="0" Body="Java (not to be confused with JavaScript) is a general-purpose object-oriented programming language designed to be used in conjunction with the Java Virtual Machine (JVM). &quot;Java platform&quot; is the name for a computing system that has installed tools for developing and running Java programs. Use this tag for questions referring to Java programming language or Java platform tools." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:30:41.343" LastActivityDate="2016-03-29T18:30:41.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22143" PostTypeId="5" CreationDate="2016-03-22T22:00:46.553" Score="0" Body="&lt;p&gt;An assembly (or assembler) language, often abbreviated asm, is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-23T14:18:29.533" LastActivityDate="2016-03-23T14:18:29.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22144" PostTypeId="4" CreationDate="2016-03-22T22:00:46.553" Score="0" Body="Refer to the assembly (or assembler) language." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-23T14:18:36.457" LastActivityDate="2016-03-23T14:18:36.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22145" PostTypeId="5" CreationDate="2016-03-22T22:04:17.780" Score="0" Body="&lt;p&gt;HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-23T14:18:45.237" LastActivityDate="2016-03-23T14:18:45.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22146" PostTypeId="4" CreationDate="2016-03-22T22:04:17.780" Score="0" Body="Refer to the HC-05 Bluetooth module." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:39:02.497" LastActivityDate="2016-04-12T07:39:02.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22147" PostTypeId="1" CreationDate="2016-03-22T22:24:59.590" Score="2" ViewCount="41" Body="&lt;p&gt;A friend of mine bought two of these Bluetooth shields &lt;a href=&quot;http://store.linksprite.com/bluetooth-4-0-ble-pro-shield-for-arduino-master-slave-and-ibeacon/&quot; rel=&quot;nofollow&quot; title=&quot;Bluetooth Shield&quot;&gt;here.&lt;/a&gt; I have been trying to get the two Arduinos connected to each other through Bluetooth. I could not get it working myself but I found some code online &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=Bluetooth_Shield_for_Arduino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; that I tried. The shields connect to each other (the lights on both turn red) but the I can't send data between them. Does anyone have any code that may works with these shields?&lt;/p&gt;&#xA;" OwnerUserId="16094" LastEditorUserId="2881" LastEditDate="2016-03-23T16:16:01.517" LastActivityDate="2016-03-23T16:16:01.517" Title="Arduino Bluetooth Shield" Tags="|arduino-uno|bluetooth|shields|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22148" PostTypeId="1" CreationDate="2016-03-22T23:01:10.083" Score="8" ViewCount="5747" Body="&lt;p&gt;I recently ran way to much voltage through my Arduino and back into my computer via the USB connection. I'm looking for a USB hub with a fuse or some sort of protection to protect my laptop from these types of mistakes.  Any suggestions as to products that would serve this function or other precautions I might take? &lt;/p&gt;&#xA;" OwnerUserId="19502" LastActivityDate="2021-08-29T14:16:07.517" Title="Protecting your computer from stupid (arduino) mistakes" Tags="|arduino-uno|usb|fuses|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22149" PostTypeId="1" CreationDate="2016-03-23T01:05:47.847" Score="1" ViewCount="4792" Body="&lt;p&gt;I'm trying to get GPS coordinates and send them to my API through the GPRS SIM900 and GPS NEO-6M shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt;, I first start the GPRS shield and call the function that connects to the internet. Then in &lt;code&gt;loop()&lt;/code&gt;, I start to capture GPS coordinates and finally I send to my API, but my code doesn't work with this logic. I'd like to connect once and get GPS coordinates and send them to the API many times making a tracking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The app stops if I run the code. &lt;code&gt;connectToInternet()&lt;/code&gt; in &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;getGpsPosition()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt;. The SIM900 shield connects but the NEO6-M shield does not display the coordinates. The GPS only captures the coordinates if I do not connect to the internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me? Following is my code and printout of the response to AT commands.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;inetGSM.h&amp;gt;&#xA;&#xA;static const int RXPin = 4, TXPin = 3;&#xA;InetGSM inet;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial serialGps(RXPin, TXPin);&#xA;char msg[50];&#xA;boolean started = false;&#xA;const char* dataCoord = &quot;&quot;;&#xA;&#xA;void setup() {&#xA;  // Serial connection.&#xA;  Serial.begin(19200);&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  Serial.println(F(&quot;Starting App Tracking Arduino&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  // Turn on GPRS&#xA;  powerUpGprs();&#xA;  // Start configuration of shield SIM900 with baudrate.&#xA;  if (gsm.begin(2400)) {&#xA;    Serial.println(F(&quot;\nstatus=READY&quot;));&#xA;    started = true;&#xA;  } else Serial.println(F(&quot;\nstatus=IDLE&quot;));&#xA;  if (started)&#xA;    connectToInternet();&#xA;  // Start configuration of shield GPS NEO-6M with baudrate.&#xA;  serialGps.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // This sketch displays information every time a new sentence is correctly encoded.&#xA;  while (serialGps.available() &amp;gt; 0)&#xA;    if (gps.encode(serialGps.read())) getGpsPosition();&#xA;}&#xA;&#xA;/**&#xA;  Power up&#xA;*/&#xA;void powerUpGprs() {&#xA;  pinMode(9, OUTPUT);&#xA;  delay(100);&#xA;  digitalWrite(9, HIGH);&#xA;  Serial.println(F(&quot;\nPower Up SIM900!&quot;));&#xA;}&#xA;&#xA;/**&#xA;  Connect to Internet via GSM&#xA;*/&#xA;void connectToInternet() {&#xA;  Serial.print(F(&quot;\r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  Serial.print(F(&quot; CONNECT TO INTERNET \r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  //GPRS attach, put in order APN, username and password.&#xA;  if (inet.attachGPRS(&quot;zap.vivo.com.br&quot;, &quot;vivo&quot;, &quot;vivo&quot;))&#xA;    Serial.println(F(&quot;status=ATTACHED&quot;));&#xA;  else&#xA;    Serial.println(F(&quot;status=ERROR&quot;));&#xA;  delay(1000);&#xA;  //Read IP address.&#xA;  gsm.SimpleWriteln(&quot;AT+CIFSR&quot;);&#xA;}&#xA;&#xA;&#xA;/**&#xA;  Get GPS position&#xA;*/&#xA;void getGpsPosition() {&#xA;  Serial.print(F(&quot;\r\n\r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  Serial.print(F(&quot; GET POSITON \r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  // geolocation&#xA;  TinyGPSDate &amp;amp;d = gps.date;&#xA;  TinyGPSTime &amp;amp;t = gps.time;&#xA;  char* timestamp;&#xA;  if (!d.isValid()) {&#xA;    timestamp = &quot;00/00/0000 00:00:00&quot;;&#xA;  } else {&#xA;    char sz[32];&#xA;    sprintf(sz, &quot;%02d/%02d/%02d %02d:%02d:%02d&quot;,&#xA;      d.day(), d.month(), d.year(),&#xA;      t.hour(), t.minute(), t.second());&#xA;    timestamp = sz;&#xA;  }&#xA;  String position = String(&quot;&quot;);&#xA;  position.concat(String(&quot;timestamp=&quot;) + String(timestamp));&#xA;  position.concat(String(&quot;&amp;amp;latitude=&quot;) + String(gps.location.lat(), 6));&#xA;  position.concat(String(&quot;&amp;amp;longitude=&quot;) + String(gps.location.lng(), 6));&#xA;  position.concat(String(&quot;&amp;amp;altitude=&quot;) + String(gps.altitude.meters()));&#xA;  position.concat(String(&quot;&amp;amp;speed=&quot;) + String(gps.speed.kmph()));&#xA;  Serial.println(dataCoord);&#xA;  send2Api();&#xA;}&#xA;&#xA;/**&#xA;  Send To API, The function inet.httpPOST(),&#xA;  this is submit method POST via http request&#xA;*/&#xA;void send2Api() {&#xA;  Serial.print(F(&quot;\r\n\r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  Serial.print(F(&quot; SEND TO API\r\n&quot;));&#xA;  Serial.print(F(&quot;------------------------------------------------- \r\n&quot;));&#xA;  // Read until serial buffer is emapty.&#xA;  gsm.WhileSimpleRead();&#xA;  // TCP Client HTTP, send a POST request to the server and save the reply.&#xA;  int numdata = inet.httpPOST(&quot;api.myapp.com.br&quot;, 80, &quot;/geolocations &quot;, dataCoord, msg, 100);&#xA;  // Print the results.&#xA;  Serial.print(F(&quot;\nNumber of data received: &quot;));&#xA;  Serial.println(numdata);&#xA;  Serial.print(F(&quot;\nData received: &quot;));&#xA;  Serial.println(msg);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I connect to internet the GPS does not display the coordinates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f6hZq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f6hZq.png&quot; alt=&quot;Run app with  connectToInternet() and getGpsPosition&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I don't connect to internet the GPS displays the coordinates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oboag.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oboag.png&quot; alt=&quot;connectToInternet() function omitted&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19165" LastEditorUserId="4628" LastEditDate="2017-06-09T04:50:42.510" LastActivityDate="2018-08-08T23:13:10.483" Title="GPRS SIM900 and GPS NEO-6M don't work together" Tags="|arduino-uno|gsm|communication|gps|command-line|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22150" PostTypeId="2" ParentId="22104" CreationDate="2016-03-23T01:19:49.387" Score="1" Body="&lt;p&gt;To render a UI, you need a PC program. It would handle presenting an interface as well as communicating the user's input to the Arduino over UART. I would recommend writing your own program as it would give you a lot of freedom in the UI design. Processing and Python are good options. To avoid using the IDE, you'll need a USB-TTL adapter cable. If you use the default USB connection, you need the drivers which only ship with the installer AFAIK. To detect the COM port, you can either have the user check the Device Manager or make your program auto-detect it, though this isnt very reliable. &lt;a href=&quot;https://stackoverflow.com/questions/24214643/python-to-automatically-select-serial-ports-for-arduino&quot;&gt;This link&lt;/a&gt; shows some Python code on detecting the Arduino's port or at least, displaying a list of open ports and allowing the user to choose. You can set the baud rate and other stuff permanently in your code; the COM port is the only variable. Also all handshaking b/w the Arduino and PC can be done without the knowledge of the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, there are already existing programs (for most common OSes) that can provide minimal functionality. If you dont need a fancy GUI, then &lt;strong&gt;putty&lt;/strong&gt; (on Windows) can serve to read input from a user and pass it on to the listening Arduino. You can use putty's default baud rate (9600) in your Arduino sketch so that the user doesnt have to set this. Again, the COM port must be known. Device Manager is the only real option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this second approach, you could make a user enter some string (or even a char) in putty to prompt the Arduino to ask for the SSID and password. Once the Arduino is powered, it does nothing but wait for that input string and once it receives it, it sends something like: &lt;code&gt;Enter SSID:&lt;/code&gt; , the user complies (and presses the Return key to terminate) and this is repeated for the password. The Arduino sketch would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_LEN 20  //max length of name or password&#xA;&#xA;char PROMPT[] = &quot;ready\r&quot;  //the initial string input from a user&#xA;char SSID[MAX_LEN];  // buffers for the ssid and pwd&#xA;char PWD[MAX_LEN];&#xA;&#xA;init_done = 0;  // this var is set when an ssid and pwd have been received&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  //anything else&#xA;}&#xA;&#xA;void loop(){&#xA;  if (!init_done)&#xA;    continue;&#xA;  //  your other code&#xA;}&#xA;&#xA;void get_data(){&#xA;  Serial.print(&quot;Enter Network SSID: \r\n&quot;);&#xA;  while (Serial.available() == 0);  // wait for input&#xA;&#xA;  // no timeouts used here; wait till user presses return key&#xA;  int i = 0;&#xA;  char c;&#xA;  while (i &amp;lt; MAX_LEN - 1){  // read chars till the buffer is almost full&#xA;    c = Serial.read();&#xA;    if (c == '\r') // means end of input&#xA;      break;&#xA;    SSID[i++] = c;&#xA;    while (Serial.available() == 0);  // wait for next char&#xA;  }&#xA;  SSID[i] = 0;  // null terminate&#xA;  while (Serial.read() != -1);  // flush serial buffer &#xA;&#xA;  Serial.print(&quot;Enter password: \r\n&quot;);  //same as before&#xA;  while (Serial.available() == 0); &#xA;&#xA;  i = 0;&#xA;  while (i &amp;lt; MAX_LEN - 1){&#xA;    c = Serial.read();&#xA;    if (c == '\r') // end of input&#xA;      break;&#xA;    PWD[i++] = c;&#xA;    while (Serial.available());&#xA;  }&#xA;  PWD[i] = 0;&#xA;  while (Serial.read() != -1); &#xA;&#xA;  //Serial.print(&quot;Done.&quot;);&#xA;  init_done = 1;&#xA;}&#xA;&#xA;&#xA;void serialEvent(){&#xA;  if (!init_done){&#xA;    while (Serial.peek() != PROMPT[0]) // read off any garbage&#xA;      Serial.read(); &#xA;    int i = 0;&#xA;    while (1){&#xA;      if (Serial.peek() == PROMPT[i++]) // compare received chars to PROMPT&#xA;        Serial.read();&#xA;      else&#xA;        return&#xA;&#xA;      if (i == sizeof(PROMPT)){ // read enough chars&#xA;        while (Serial.read() != -1);  // flush the buffer &#xA;        get_data();  // get ssid and so on&#xA;      }&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-23T01:19:49.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22151" PostTypeId="2" ParentId="16954" CreationDate="2016-03-23T01:24:53.427" Score="2" Body="&lt;p&gt;I am using a &quot;BIND&quot; between the PAIR and LINK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+PAIR=98D3,31,FC2D54,5&#xA;AT+BIND=98D3,31,FC2D54&#xA;AT+LINK=98D3,31,FC2D54&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That seems to work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the docs here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;ftp://imall.iteadstudio.com/Modules/IM120723009/DS_IM120723009.pdf&quot; rel=&quot;nofollow&quot;&gt;ftp://imall.iteadstudio.com/Modules/IM120723009/DS_IM120723009.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4519" LastActivityDate="2016-03-23T01:24:53.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22152" PostTypeId="2" ParentId="9030" CreationDate="2016-03-23T01:28:12.683" Score="7" Body="&lt;p&gt;I believe the OEM part is NS-Tech 1125S-4P: &lt;a href=&quot;http://www.nstech.com.cn/en/products/product_202201151603323190.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wire to Board connector &amp;gt; PITCH 2.00mm &amp;gt; 1125 Series&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Good luck finding a vendor!&lt;/p&gt;&#xA;" OwnerUserId="19523" LastEditorUserId="93229" LastEditDate="2023-11-08T08:30:44.240" LastActivityDate="2023-11-08T08:30:44.240" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22153" PostTypeId="2" ParentId="22148" CreationDate="2016-03-23T02:29:20.533" Score="1" Body="&lt;p&gt;You get used to what not to do fairly quickly :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps what you're after is a ruggeduino - &lt;a href=&quot;http://www.rugged-circuits.com/ruggeduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.rugged-circuits.com/ruggeduino/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get the feeling that this sort of thing encourages bad habits, but then it also encourages more exploration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to think carefully about what you're doing, if you put in any second source of power (e.g. USB + power plug, or USB + a signal from another device).&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-03-23T02:29:20.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22156" PostTypeId="2" ParentId="22149" CreationDate="2016-03-23T04:02:06.993" Score="2" Body="&lt;p&gt;You are using 2 SoftwareSerial instances and you're losing bytes when you aren't listening to the other port. Also your &lt;code&gt;inetGSM&lt;/code&gt; library uses pins 3 for RX with the SIM900 and in your Arduino sketch, pin 3 is also the Arduino TX pin to the GPS module. Therefore, anything sent by the Arduino over pin 3 is received by both modules. Confusion.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use the GPS module with another pair of pins, maybe, 7 for RX and 8 for TX. Connect the GPS TX to 7 and its RX to 8.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Try adding: &lt;code&gt;gsm._cell.listen();&lt;/code&gt; right before this line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;// Read until serial buffer is empty.&#xA;gsm.WhileSimpleRead();&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also add &lt;code&gt;serialGps.listen();&lt;/code&gt; right before this line:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;// Print the results.&#xA;Serial.print(F(&quot;\nNumber of data received: &quot;));&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Refer to this &lt;a href=&quot;https://arduino.stackexchange.com/questions/22633/solved-dbno-resp-using-inet-httppost-on-loop/22637#22637&quot;&gt;answer&lt;/a&gt; for more details.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-04-05T01:37:19.697" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22158" PostTypeId="2" ParentId="22148" CreationDate="2016-03-23T06:50:38.707" Score="5" Body="&lt;p&gt;Both the arduino and a USB port do have some protection against wrong connections and such. The arduino has a diode to prevent wrong polarity to reach your power supply, it also have a resetable fuse (the kinda big, often green SMD part close by your USB connection on your Arduino) that should protect your USB port pretty good from its side of the cable. Your USB port also have some good protections going on as far as i know, so basically it should be hard to break a USB port by accident.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That was the theoretical part, In real life things aren't always what they claim to be, so I use a cheap powered USB hub, that i always use as a first line of defense. &lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-23T06:50:38.707" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22159" PostTypeId="1" CreationDate="2016-03-23T08:30:04.500" Score="2" ViewCount="420" Body="&lt;p&gt;I want to collect GPS data with a cellular-enabled micro-controller to help me find my drone if it gets lost. My drone has GPS, so I tried to connect to it. Many GPS break-out boards have the following connections:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GND &lt;/li&gt;&#xA;&lt;li&gt;5V/3.3V &lt;/li&gt;&#xA;&lt;li&gt;TX &lt;/li&gt;&#xA;&lt;li&gt;RX&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Some of the time there are more, but these seem to be the essential ones. But, I'm studying a GPS module that uses only 3 wires. Take a look:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0xM1r.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0xM1r.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The red and black ones are power and ground. Must the remaining wire be TX?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying every way I can think of to tap into this GPS on my quad. I spliced into the 3 wires, but I only connected ground and what I suspect to be TX to my micro. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yOCKS.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yOCKS.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, at this point, I'm just curious.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've studied the GPS a bit more and I can now see it has a compass and some other motion device. So it's not just a GPS board.&#xA;It also had it's own micro controller managing all of these devices.  I think the serial data on the wires I've tapped has been reformatted for the flight controller. It's gibberish in the arduino app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point I'm ready give up and just put a second GPS on the thing!&#xA;But before I give up I wanted to ask if there are any other methods I can try to listen to the GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="8769" LastActivityDate="2016-03-23T08:30:04.500" Title="How would one make a 3-wire GPS?" Tags="|serial|gps|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22160" PostTypeId="2" ParentId="22148" CreationDate="2016-03-23T08:39:43.680" Score="3" Body="&lt;p&gt;There are a number of USB Isolator products available all around the world.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a list of just a few: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/2107&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit - USB Isolator&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.olimex.com/Products/USB-Modules/USB-ISO/&quot; rel=&quot;nofollow noreferrer&quot;&gt;OLIMEX - USB Isolator&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.bb-elec.com/Products/USB-Connectivity/USB-Isolators/USB-Isolators.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;Avantech - USB Isolators&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.cesys.com/products/usb-isolator/&quot; rel=&quot;nofollow noreferrer&quot;&gt;CESYS - USB Isolator&lt;/a&gt;   &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://usb-rs485.eu/default.asp&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hjelmslund Electronics - USBISO-AA&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T11:51:04.213" LastActivityDate="2018-12-13T11:51:04.213" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22161" PostTypeId="1" AcceptedAnswerId="22163" CreationDate="2016-03-23T09:22:35.107" Score="0" ViewCount="788" Body="&lt;p&gt;I am trying to read sensor data from a FIFO buffer embedded in the sensor (LSM9DS1), and store that data on a Teensy 3.2 board to later be put in a file. I can only read 6 bytes at a time from the FIFO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sensor's FIFO is read by the Teensy when an interrupt triggers an isr function. I want to store the data on the Teensy memory. Then, after the ISR store the memory, I plan to parse the data and do a few simple calculations in the loop() function before writing it to file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to accomplish this? I tried using a FIFO library for Arduino &lt;a href=&quot;https://github.com/rambo/SimpleFIFO&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, but it doesn't work with interrupts. I encountered errors with declaring it as a volatile memory type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could I used shared memory using the sys/shm.h library from C++? If so, how can I import this to my arduino code?&lt;/p&gt;&#xA;" OwnerUserId="16549" LastActivityDate="2016-03-23T10:20:57.223" Title="Shared Memory using SHM Library" Tags="|teensy|memory-usage|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22162" PostTypeId="2" ParentId="20678" CreationDate="2016-03-23T10:02:44.170" Score="0" Body="&lt;p&gt;Not tested but should work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int nums[] = {0, 0, 0, 0};&#xA;String inString = &quot;&quot;;&#xA;while (Serial.available() &amp;gt;= 16) {&#xA;  for (int k =0;k&amp;lt;4;k++) {&#xA;    for (int i =0;i&amp;lt;4;i++) {&#xA;      int inChar = Serial.read();&#xA;      if (isDigit(inChar)) {&#xA;        inString += (char)inChar;&#xA;      }&#xA;    }&#xA;    nums[k]=inString.toInt();&#xA;    inString = &quot;&quot;;&#xA;  }&#xA;  Serial.println(nums[0]);&#xA;  Serial.println(nums[1]);&#xA;  Serial.println(nums[2]);&#xA;  Serial.println(nums[3]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19536" LastActivityDate="2016-03-23T10:02:44.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22163" PostTypeId="2" ParentId="22161" CreationDate="2016-03-23T10:20:57.223" Score="2" Body="&lt;p&gt;&lt;em&gt;Shared memory&lt;/em&gt; only makes any sense in two combined situations:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have a kernel arbitrating processes, threads and memory allocation, with process isolation&lt;/li&gt;&#xA;&lt;li&gt;You have multiple threads or processes in your application&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You certainly don't have number 1 unless you can install an operating system on the Teensy 3.1 (some RTOS may provide a SHM analogue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for 2 yes, it could be said you have two threads. But you don't have any form of process isolation, so what one &quot;thread&quot; can access the other &quot;thread&quot; can access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both the ISR and the &lt;code&gt;loop()&lt;/code&gt; function have access to the exact same memory. Any global variables are accessible to both. You may need to inform the compiler that a variable is modified in one thread and read in another though. The simplest way of doing that is to make the variable &lt;em&gt;volatile&lt;/em&gt; by prepending the &lt;code&gt;volatile&lt;/code&gt; keyword to the definition.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-23T10:20:57.223" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="22165" PostTypeId="1" CreationDate="2016-03-23T13:15:05.780" Score="7" ViewCount="3096" Body="&lt;p&gt;Pin 13 fires relay when powering on... How to disable?&#xA;I'm using &lt;a href=&quot;http://www.miniinthebox.com/atmega328p-pro-mini-328-mini-atmega328-5v-16mhz-for-arduino_p4309665.html?currency=USD&amp;amp;litb_from=paid_adwords_shopping&amp;amp;utm_source=google_shopping&amp;amp;utm_medium=cpc&amp;amp;adword_mt=&amp;amp;adword_ct=94710053401&amp;amp;adword_kw=&amp;amp;adword_pos=1o5&amp;amp;adword_pl=&amp;amp;adword_net=g&amp;amp;adword_tar=&amp;amp;adw_src_id=1364803665_328601281_21739983481_pla-146299556698&amp;amp;gclid=CjwKEAjw_ci3BRDSvfjortr--DQSJADU8f2jz14aOXr1fw3OR7rMu4B3kx12ipYcuGdeNrVdQo7bzBoCU37w_wcB&quot;&gt;pro mini 5v 16MHz&lt;/a&gt; and a &lt;a href=&quot;http://www.ebay.com/itm/like/391359931507?lpid=82&amp;amp;chn=ps&amp;amp;ul_noapp=true&quot;&gt;DC 12V 2 Channel Relay Module Optocoupler&lt;/a&gt;. The relay Jd-VCC is powered by a 12V and it's VCC is 5V (the same as Arduino VCC). The relay is active low and I soldered pins 12 and 13 of the pro mini to IN1 and IN2 of the relay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I power the board up it cycles Pin 13(and the on-board LED) ON and then OFF before resuming to the code I uploaded. I believe that this can be fixed by disabling this blinking function in the startup process. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that I can use other pins. Why not learn how to remove this from startup, if I prefer to use this pin for circuit layout purposes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated. Most of my searches ended up with people using the pin as an input... My issue is when using D13 as an active low pin it has some funky behavior at startup but then works as programmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!!!&lt;/p&gt;&#xA;" OwnerUserId="19540" LastActivityDate="2016-03-23T19:44:09.370" Title="Pin 13 fires relay when powering on... How to disable?" Tags="|pins|bootloader|arduino-pro-mini|relay|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22166" PostTypeId="2" ParentId="22165" CreationDate="2016-03-23T13:19:36.090" Score="11" Body="&lt;p&gt;There are three things you can do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Remove the bootloader entirely and program the board with a hardware programmer (USB-ASP, Another Arduino, etc).&lt;/li&gt;&#xA;&lt;li&gt;Edit the bootloader source, recompile, and reinstall it to the board using a hardware programmer (as in option 1).&lt;/li&gt;&#xA;&lt;li&gt;Just don't use pin 13 for the relay.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Of the three options the third one is by far the simplest. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="3917" LastEditDate="2016-03-23T19:44:09.370" LastActivityDate="2016-03-23T19:44:09.370" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22167" PostTypeId="1" AcceptedAnswerId="22177" CreationDate="2016-03-23T13:27:02.067" Score="1" ViewCount="1025" Body="&lt;p&gt;RTC seems to be sporadically returning bogus date/times. Here are the logs from my serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2016/3/23 8:19:46&#xA;2017/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2165/165/165 15:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;2016/3/23 8:19:46&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That &lt;code&gt;2165/165/165 15:19:46&lt;/code&gt; appears throughout the logs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the relevant code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  if (! rtc.begin()) {&#xA;    Serial.println(&quot;Couldn't find RTC&quot;);&#xA;    while (1);&#xA;  }&#xA;  if (! rtc.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    rtc.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  DateTime now = rtc.now(); &#xA;&#xA;  Serial.print(now.year(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.month(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.day(), DEC);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(now.hour(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.minute(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.second(), DEC);&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_RTC&quot; rel=&quot;nofollow&quot;&gt;Grove RTC module&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-03-23T20:34:56.213" Title="My RTC is returning a sporadic date/time" Tags="|arduino-uno|time|rtc|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22168" PostTypeId="2" ParentId="20936" CreationDate="2016-03-23T13:47:17.023" Score="1" Body="&lt;p&gt;This is an &lt;strong&gt;analog servo&lt;/strong&gt;, so there is no endpoint calibration &lt;strong&gt;on the servo side&lt;/strong&gt;. This type of calibration is for digital servos (which can be tuned) and controllers.&#xA;On the servo description page, they talk about a stretcher. This is a translation tool to help with old controllers:  usually servos have a narrower band: 1000us to 2000us for 0° to 180°. Therefore old controllers can only do 1000us to 2000us, and would fail to achieve full range with this servo, which requires 600us to 2400us&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, note that &lt;a href=&quot;https://en.wikipedia.org/wiki/Servo_control#Pulse_duration&quot; rel=&quot;nofollow&quot;&gt;RC servo input signal isn't really a PWM&lt;/a&gt;: duty cycle doesn't matter, only lengh of the pulse does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your servo doc says: 600us to 2400us for -90° to +90°, which correspond to what the Servo lib does by default according to its documentation. You should be fine. What are the results of a super simple sweep-like code? eg:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop() {&#xA;  myServo.writeMicroseconds(600);&#xA;  delay(2000);&#xA;  myServo.writeMicroseconds(2400);&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19504" LastActivityDate="2016-03-23T13:47:17.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22170" PostTypeId="2" ParentId="19524" CreationDate="2016-03-23T14:31:59.697" Score="0" Body="&lt;p&gt;There seem to be a confusion on Serial &amp;amp; Serial3. You say that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Serial is used to send back debug data to the PC&lt;/li&gt;&#xA;&lt;li&gt;Serial3 is used to get data from the master&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But this is not clear/coherent to your code. Let's try to see your code with proper indentation. I added comments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if(Serial.available()) { //isnt Serial your debug port? did you mean Serial3?&#xA;    if (b == Serial.available()) { //same. Serial3? also, read() instead of available() ?&#xA;      while(Serial.available()) { //same. Serial3?&#xA;        buffer[count++] = Serial.read(); //Serial3?&#xA;        if(count == 12) {&#xA;          break; //will this work for several frames? how can count ever go back to 0?&#xA;        }&#xA;        Serial3.write(buffer, count); //isnt Serial your debug output?&#xA;      }&#xA;    }&#xA;//your indentation didnt show it, but we're still guarded by the first 'if' here.&#xA;//Also I guess you meant Serial here?&#xA;    if (Serial3.available()) { &#xA;//why check for a SoF? what do you do with data coming up fro the debug PC?&#xA;      if(b == Serial3.available()) {&#xA;//messing with data in your buffer, potentially outside of it? (count can be&amp;gt;11 here)&#xA;        buffer[count++] = Serial3.read();&#xA;        Serial.write(buffer, count);&#xA;      }&#xA;    }&#xA;    Serial.println(&quot;lyca&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What about this (code below still has several flaws, but should perform better than yours)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(void) {&#xA;  if(Serial3.available() &amp;gt; 0) { //available data from master?&#xA;    while(Serial3.available() &amp;gt; 0) { //if statement above for clarity, this while on its own would be enough&#xA;      inByte = Serial3.read();&#xA;      if(inByte  == SOF_BYTE) { //is this a start of frame?&#xA;        mybuff.ptr = 0; //let's say we dump everything in buff whenever we get a new SoF&#xA;        Serial.println(&quot;SoF received&quot;);     &#xA;      }&#xA;      else { //let's not keep SoF&#xA;        mybuff.append(inByte);&#xA;      }&#xA;    }&#xA;  }&#xA;  if(mybuff.size &amp;gt;= FULLFRAME_SIZE) { //we've got a full frame, output it&#xA;    Serial.print(&quot;Full frame received:&quot;);&#xA;    Serial.println(mybuff.string);&#xA;    mybuff.ptr = 0; //now that we've consumed the frame, kill it&#xA;  }&#xA;  else {&#xA;    Serial.print(&quot;.&quot;) // no frame, show progress/still alive&#xA;  }&#xA;  delay(refreshtime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19504" LastActivityDate="2016-03-23T14:31:59.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22171" PostTypeId="1" AcceptedAnswerId="22175" CreationDate="2016-03-23T16:36:36.600" Score="5" ViewCount="1690" Body="&lt;p&gt;I've written a Arduino sketch that converts an analogue voltage to a temperature using a lookup table - code below. I've recently changed my LUT to include more values but ever since that my Serial monitor won't print out my debugging statements etc. So I limited the number of elements in the array and it was back to normal. But when I enter more debugging statements using the serial monitor, there is garbage before my statements (still readable though when I parse through it myself) or at the start nothing is printed.&#xA;I've checked that the two baud rates are the same but I just find it peculiar that if I take some of my println() statements out it runs okay. Tested everything else with a &quot;Hello World&quot; example but in the simple exaples the monitor works fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;    #####PROJECT DESCRIPTION##### &#xA;    Measures temperature with an Arduino and NTC Thermistor (10Kohms @ 25^C)                                 in a voltage divider circuit&#xA;    Since the response is non-linear, a lookup table is used since there is a non linear response &#xA;    The values in the LUT are the predicted values of the ADC at  temperature between 6^C and 40^C&#xA;    LUT has been derived from the calibration tests&#xA;    */&#xA;    //#####CONSTANTS#####&#xA;    const int constDelay = 3000; //constant delay for program &#xA;    const int constNoOfAnaloguePins = 2; //number of analogue pins that are to be read&#xA;    const int errReturn = 998; //error value that is returned ***CHECK FOR CONSITENT VALUE ACROSS FUNCTIONS***&#xA;    //#####VARIABLE DECLARATIONS#####&#xA;    float avgTempC; //float var to store average of multiple temp readings&#xA;&#xA;    //#####SETUP PROCEDURE#####&#xA;    void setup()&#xA;    {&#xA;      //this is the Setup part of your project - this is for code that is run only ONCE at startup&#xA;      for (int analoguePinCounter = 0; analoguePinCounter &amp;lt; constNoOfAnaloguePins; analoguePinCounter++) //for loop to set up numerous analogue pins&#xA;      {&#xA;        pinMode(analoguePinCounter, INPUT);  //set pin mode of the analogue thermistor input&#xA;      }//end for&#xA;      analogReference(INTERNAL); //use the interval votlage of 1.1V for the ADC resolution&#xA;      Serial.begin(9600); //serial monitor baud rate&#xA;    }//end Setup function&#xA;&#xA;    //#####LOOP PROCEDURE#####&#xA;    void loop()&#xA;    {&#xA;      //this is the main part of your project - put all continuously running code here&#xA;      for (int analoguePinCounter = 0; analoguePinCounter &amp;lt; constNoOfAnaloguePins; analoguePinCounter++) //for loop to take temp readings from each analogue pin&#xA;      {&#xA;        //get LPF average reading over 25 samples&#xA;        avgTempC = LPF(analoguePinCounter, 25);&#xA;        //print out the readings&#xA;        if (avgTempC &amp;lt; float(errReturn)) //there hasn't been any temps outside the range ***CHECK THE VALUE RETURNED FROM LPF IF ERROR***&#xA;        {&#xA;          Serial.print(analoguePinCounter);&#xA;          Serial.print(&quot; | Average Temperature Readings = &quot;);&#xA;          Serial.print(avgTempC, 2);&#xA;          Serial.println(&quot; degC.&quot;);&#xA;          Serial.println(&quot;-------------------------&quot;);&#xA;        }&#xA;        else //avgTempC has returned X indicating an error&#xA;        {&#xA;          Serial.print(analoguePinCounter);&#xA;          Serial.println(&quot;**ERROR IN READING AVERAGE TEMP**&quot;);&#xA;          Serial.println(&quot;-------------------------&quot;);&#xA;          delay(10);&#xA;        }//end if&#xA;        delay(constDelay/2); //wait X/2 seconds until moving onto next sensor&#xA;      }//end for&#xA;      delay(constDelay); //wait X seconds until next loop&#xA;    }//end Loop function&#xA;&#xA;    /*&#xA;    #####LOW PASS FILTER DESCRIPTION#####&#xA;    This function is a LPF for smoothing out signals or averaging&#xA;    It uses a static buffer to store the last &quot;n&quot; readings, and each time it is called,&#xA;    the oldest reading is discarded, the new reading is added, and the stack average&#xA;    value is returned.&#xA;    The buffer size is user-adjustable, but is constrained between 2 and 50&#xA;    An initialization function fills the entire buffer with the input value. &#xA;    This is useful when the LPF function is called for the first time.&#xA;    Note: To meet the definition of a true LPF, this function must be called         at regular intervals.&#xA;    */&#xA;    //#####LOW PASS FILTER FUNCTION#####&#xA;    float LPF(int pinAnalogue, int bufferSize)&#xA;    {&#xA;      //##PRE PROCESSOR##&#xA;      #define bufferCap 75 //maximum buffer capacity&#xA;      //##CONSTANTS##&#xA;      const int constMAXERRORS = 5; //max number of error that can occur&#xA;      const int errReturn = 998; //value return if there is an error&#xA;      //##VARIABLES##&#xA;      float tempC; //var to store instantaneous temp&#xA;      static float buffer[bufferCap]; //array to act like a 'stack' of temp values ***DOES IT NEED TO BE STATIC NOW?***&#xA;      float tempSum; //to store the sum of the temperatures&#xA;      float output; //return value of LPF which is the average of the temp readings&#xA;      int errCounter = 0; //initialise error counter to 0&#xA;&#xA;      //make sure buffer size is between the range&#xA;      bufferSize = constrain(bufferSize, 2, bufferCap);&#xA;&#xA;      for (int i=0; i&amp;lt;bufferSize; i++) //for loop to store temps in buffer array &#xA;      {&#xA;        tempC = getTempFloat(pinAnalogue); //call function to get temperature from pin&#xA;        if ((tempC &amp;gt; -errReturn) &amp;amp;&amp;amp; (tempC &amp;lt; errReturn)) //no error &#xA;        {&#xA;          buffer[i] = tempC; //store temp value into array&#xA;        }&#xA;        else //error&#xA;        {&#xA;          errCounter++; //increment counter for number of erroneous readings&#xA;          i--; //decrement counter as to not skip a sample index&#xA;          if (errCounter &amp;gt; constMAXERRORS)&#xA;          {&#xA;            return(errReturn+1.0); //return the error value + 1&#xA;          }//end if&#xA;        }//end if&#xA;        delay(25); //allow the ADC to settle&#xA;      }//end for&#xA;&#xA;      //calculate current stack average&#xA;      tempSum = 0; //initialise sum total&#xA;      for (int i=0; i&amp;lt;bufferSize; i++) //go through stack array&#xA;      {&#xA;        tempSum = tempSum + buffer[i]; //total up readings&#xA;      }//end for&#xA;&#xA;      //average sum&#xA;      output = tempSum/bufferSize;&#xA;&#xA;      return(output);&#xA;    }//end LPF function&#xA;&#xA;    /*&#xA;    #####GET TEMP FLOAT DESCRIPTION#####  &#xA;    This function converts a thermistor reading into a corresponding temp in ^C&#xA;    The thermistor is incorporated into a Voltage Divider Circuit:&#xA;&#xA;       +Vref---[Thermistor]---+--[1.8K]---GND&#xA;                              |&#xA;                             ADC @ thermPin&#xA;&#xA;    ADC Values were externally calculated from the calibration table using:           ADC = 1023*10000/(Rtherm+10000)&#xA;    The LUT is an array of integer constants containing the predicted ADC         values for all temperatures between +6^C to +40.5^C.&#xA;    The array index starts at zero, which corresponds to a temperature of         +6^C.&#xA;    A linear interpolation between the two closest entries is performed to         give a finer output resolution.&#xA;    */&#xA;&#xA;    float getTempFloat (int thermPin)&#xA;    {&#xA;      //##CONSTANTS##&#xA;      /*1K8*/&#xA;      const int constLUTArraySize = 431;&#xA;      const int LUT_Therm[constLUTArraySize] = //LUT containing ADC values&#xA;      {&#xA;        223, 224, 225, 226, 227, 228, 229, 230, 231, 232,         //7^C to 7.9^C&#xA;        233, 234, 235, 236, 237, 238, 239, 240, 241, 242,&#xA;        244, 245, 246, 247, 248, 249, 250, 251, 252, 253,&#xA;        255, 256, 257, 258, 259, 260, 261, 263, 264, 265,&#xA;        266, 267, 268, 269, 271, 272, 273, 274, 275, 277,&#xA;        278, 279, 280, 281, 283, 284, 285, 286, 287, 289,&#xA;        290, 291, 292, 294, 295, 296, 297, 299, 300, 301,           //13^C to 13.9^C&#xA;        302, 304, 305, 306, 308, 309, 310, 312, 313, 314,&#xA;        315, 317, 318, 319, 321, 322, 323, 325, 326, 327,&#xA;        329, 330, 332, 333, 334, 336, 337, 338, 340, 341,&#xA;        343, 344, 345, 347, 348, 350, 351, 353, 354, 355,&#xA;        357, 358, 360, 361, 363, 364, 366, 367, 369, 370,&#xA;        371, 373, 374, 376, 377, 379, 380, 382, 383, 385,&#xA;        387, 388, 390, 391, 393, 394, 396, 397, 399, 400,&#xA;        402, 404, 405, 407, 408, 410, 411, 413, 415, 416,&#xA;        418, 419, 421, 423, 424, 426, 428, 429, 431, 433,&#xA;        434, 436, 438, 439, 441, 443, 444, 446, 448, 449,&#xA;        451, 453, 454, 456, 458, 460, 461, 463, 465, 466,&#xA;        468, 470, 472, 473, 475, 477, 479, 480, 482, 484,&#xA;        486, 488, 489, 491, 493, 495, 497, 498, 500, 502,&#xA;        504, 506, 507, 509, 511, 513, 515, 517, 519, 520,&#xA;        522, 524, 526, 528, 530, 532, 534, 535, 537, 539,&#xA;        541, 543, 545, 547, 549, 551, 553, 555, 557, 559,&#xA;        560, 562, 564, 566, 568, 570, 572, 574, 576, 578, &#xA;        580, 582, 584, 586, 588, 590, 592, 594, 596, 598,&#xA;        600, 602, 604, 606, 608, 611, 613, 615, 617, 619,&#xA;        621, 623, 625, 627, 629, 631, 633, 635, 638, 640,&#xA;        642, 644, 646, 648, 650, 652, 655, 657, 659, 661,&#xA;        663, 665, 667, 670, 672, 674, 676, 678, 680, 683,&#xA;        685, 687, 689, 691, 694, 696, 698, 700, 702, 705,&#xA;        707, 709, 711, 714, 716, 718, 720, 723, 725, 727,&#xA;        729, 732, 734, 736, 738, 741, 743, 745, 747, 750, &#xA;        752, 754, 757, 759, 761, 764, 766, 768, 771, 773,&#xA;        775, 778, 780, 782, 785, 787, 789, 792, 794, 796,&#xA;        799, 801, 803, 806, 808, 811, 813, 815, 818, 820,&#xA;        822, 825, 827, 830, 832, 834, 837, 839, 842, 844,&#xA;        847, 849, 851, 854, 856, 859, 861, 864, 866, 868,&#xA;        871, 873, 876, 878, 881, 883, 886, 888, 891, 893,&#xA;        896, 898, 901, 903, 906, 908, 911, 913, 916, 918, &#xA;        921, 923, 926, 928, 931, 933, 936, 938, 941, 943,&#xA;        946, 948, 951, 953, 956, 958, 961, 963, 966, 969,&#xA;        971, 974, 976, 979, 981, 984, 987, 989, 992, 994,&#xA;        997, 999, 1002, 1005, 1007, 1010, 1012, 1015, 1017, 1020, //40^C to 49.9^C&#xA;        1023                                                     //50^C&#xA;      };&#xA;      const int errReturn = 998; //error value that is returned&#xA;      //##VARIABLES##&#xA;      float _tempC; //intermediate results + final temperature return value&#xA;      int ADC_Lo; //the lower ADC matching value&#xA;      int ADC_Hi; //the higher ADC matching value&#xA;      float Temp_Lo; //the lower number matching temperature&#xA;      int mapTemp_Lo; //the lower number that will be entered into the map function&#xA;      float Temp_Hi; //the higher  number matching temperature&#xA;      int mapTemp_Hi; //the higher number that will be entered into the map function&#xA;&#xA;      //prep ADC onto that particular analogue pin to sort out multiplexing etc&#xA;      analogRead(thermPin); &#xA;      delay(10);&#xA;      //get raw ADC value from VDR&#xA;      int thermValue = analogRead(thermPin); &#xA;      //Serial.println(thermValue);&#xA;      /*Serial.print(&quot;PinNo : &quot;);&#xA;      Serial.println(thermPin);*/&#xA;      Serial.print(&quot;ADC : &quot;);&#xA;      Serial.println(thermValue);&#xA;      //return dummy value if the sensor reading falls outside of the LUT&#xA;      if (thermValue &amp;lt; LUT_Therm[0]) //less than the least ADC value&#xA;        _tempC = -errReturn-1; //under range dummy value&#xA;      else if (thermValue &amp;gt; LUT_Therm[constLUTArraySize-1]) //more than the greatest ADC value&#xA;        _tempC = errReturn+1; //over range dummy value&#xA;      else //value falls in LUT range&#xA;      {&#xA;        for (int i=0; i&amp;lt;constLUTArraySize; i++) //step through LUT and look for a match&#xA;        {    &#xA;          if (LUT_Therm[i] &amp;gt; thermValue) //LUT value is greater than the reading&#xA;          {  &#xA;            //find the closest higher ADC value&#xA;            ADC_Hi = LUT_Therm[i];&#xA;            //record the closest higher temperature        &#xA;            Temp_Hi = float(i/10) + 13.0; //convert to temp&#xA;            //get the closest lower temperature - taking the lower table boundary into account&#xA;            if (i != 0) //general case -&amp;gt; as long as it is not the first entry&#xA;            {&#xA;              ADC_Lo = LUT_Therm[i-1]; //store the previous array element as the low&#xA;              Temp_Lo = float(i/10) + 13.0 - 0.1; //convert to temp&#xA;            }&#xA;            else //special case -&amp;gt; counter = 0 ie first array entry&#xA;            {&#xA;              ADC_Lo = LUT_Therm[i]; //store the first array element&#xA;              Temp_Lo = i - float(i/10) + 13.0; //convert to temp&#xA;            }//end if&#xA;            //interpolate the temperature value for greater precision&#xA;            //NB the map function does not use floating-point math, so the int values of temp are multiplied by 100 and then result is subsequently divided by 100&#xA;            mapTemp_Lo = Temp_Lo*100;&#xA;            mapTemp_Hi = Temp_Hi*100;&#xA;            _tempC = float(map(thermValue,ADC_Lo,ADC_Hi,mapTemp_Lo,mapTemp_Hi))/100;&#xA;            break;  //exit for loop after the match is detected&#xA;          }//end if&#xA;        }//end for&#xA;      }//end if&#xA;      return(_tempC);&#xA;    }//end getTempFloat function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this particular sketch no output is seen on the serial monitor. Has anyone come across this before or have any ideas how I could fix this?&lt;/p&gt;&#xA;" OwnerUserId="19548" LastEditorUserId="10794" LastEditDate="2016-03-23T20:36:13.190" LastActivityDate="2018-12-13T11:52:50.737" Title="Array + Serial Monitor Problem" Tags="|arduino-uno|serial|c++|sram|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22172" PostTypeId="1" AcceptedAnswerId="22176" CreationDate="2016-03-23T16:41:23.190" Score="1" ViewCount="1943" Body="&lt;p&gt;I'm using an Ethernet shield with the built-in Ethernet library. I obtain an IP address using DHCP, and call &lt;code&gt;Ethernet.maintain()&lt;/code&gt; periodically to ensure that the DHCP lease is renewed as required. So far I've never seen this fail, but &lt;code&gt;maintain()&lt;/code&gt; can return error codes for renew fail and rebind fail and I assume that I should be handling them. What conditions would cause these errors to occur, and what's the best practise for recovering from them? Is it enough to call &lt;code&gt;Ethernet.maintain()&lt;/code&gt; repeatedly until it returns cleanly, should I call &lt;code&gt;Ethernet.begin()&lt;/code&gt; to reinitialise the Ethernet shield, or would it be best to reset both the Arduino and Ethernet shield using the watchdog timer?&lt;/p&gt;&#xA;" OwnerUserId="19551" LastActivityDate="2016-03-24T13:08:14.437" Title="How to recover from DHCP Renewal and Rebind failures?" Tags="|ethernet|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22173" PostTypeId="2" ParentId="22171" CreationDate="2016-03-23T17:36:17.653" Score="4" Body="&lt;p&gt;You have likely run out of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 431 integers in the look-up table alone. That equates to 862 bytes of SRAM. You also have a buffer of 75 floats, which equates to 300 bytes. This is in addition to all your other variables and function calls. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Uno only has 2KB of SRAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solutions:&lt;br&gt;&#xA; 1) Move your LUT to Flash (ie. program space) using the PROGMEM keyword (just before the equals sign):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LUT_Therm[constLUTArraySize] PROGMEM = //LUT containing ADC values&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Use an Arduino with a greater amount of SRAM. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Mega  - 8KB SRAM  &lt;/li&gt;&#xA;&lt;li&gt;Arduino ZERO  - 32KB SRAM  &lt;/li&gt;&#xA;&lt;li&gt;Arduino Due   - 96KB SRAM  &lt;/li&gt;&#xA;&lt;li&gt;Arduino MKR 1000/1010/1400/ZERO - 32KB SRAM&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T11:52:50.737" LastActivityDate="2018-12-13T11:52:50.737" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22174" PostTypeId="2" ParentId="20565" CreationDate="2016-03-23T17:44:42.760" Score="2" Body="&lt;p&gt;In SPI protocol you'll need to read the SPI buffer twice because the data you wrote will be read by the IC and the IC will respond to it in the next communication and that's when you know. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, by looking at the message, I see that your IC is working fine, but is your CAN bus initialised properly? I'm a FSAE team member and I've faced this issue with the CAN Bus termination resistances and the ODB-II configuration on the Sparkfun CAN Bus shield. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, have you tried any other libraries for the CAN Shield? For me the seeedstudio library of their CAN shield worked very well.&lt;/p&gt;&#xA;" OwnerUserId="18545" LastEditorUserId="6936" LastEditDate="2016-03-25T10:38:34.317" LastActivityDate="2016-03-25T10:38:34.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22175" PostTypeId="2" ParentId="22171" CreationDate="2016-03-23T17:57:54.420" Score="4" Body="&lt;p&gt;Use the &lt;code&gt;F()&lt;/code&gt; macro for all double-quoted strings you print.  Change lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot; degC.&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println( F(&quot; degC.&quot;) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will save about 100 bytes of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as BrettAM suggested, put that table into PROGMEM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  const int LUT_Therm[constLUTArraySize] PROGMEM = //LUT containing ADC values&#xA;  {&#xA;    223, 224, 225, 226, 227, 228, 229, 230, 231, 232,         //7^C to 7.9^C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This requires changing how you access the array, from this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (thermValue &amp;lt; LUT_Therm[0]) //less than the least ADC value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (thermValue &amp;lt; (int) pgm_read_word( &amp;amp;LUT_Therm[0] )) //less than the least ADC value&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the cast, the function call and the ampersand wrapped around the desired array element.  You must replace all uses of the array with this sequence.  You can also read it once into a local &lt;code&gt;int&lt;/code&gt; and then use it normally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      int lut_therm = (int) pgm_read_word(LUT_Therm[i]); // read it in&#xA;&#xA;      if (lut_therm &amp;gt; thermValue) //LUT value is greater than the reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This saves almost 1000 bytes of RAM!  The reported binary sketch size goes &lt;em&gt;up&lt;/em&gt; by the same amount&lt;sup&gt;[1]&lt;/sup&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to pull the table out from inside &lt;code&gt;getTempFloat&lt;/code&gt;, to the file scope.  Here's the complete sketch with those mods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;#####PROJECT DESCRIPTION##### &#xA;Measures temperature with an Arduino and NTC Thermistor (10Kohms @ 25^C)                                 in a voltage divider circuit&#xA;Since the response is non-linear, a lookup table is used since there is a non linear response &#xA;The values in the LUT are the predicted values of the ADC at  temperature between 6^C and 40^C&#xA;LUT has been derived from the calibration tests&#xA;*/&#xA;&#xA;//#####CONSTANTS#####&#xA;const int constDelay = 3000; //constant delay for program &#xA;const int constNoOfAnaloguePins = 2; //number of analogue pins that are to be read&#xA;const int errReturn = 998; //error value that is returned ***CHECK FOR CONSITENT VALUE ACROSS FUNCTIONS***&#xA;&#xA;//#####VARIABLE DECLARATIONS#####&#xA;float avgTempC; //float var to store average of multiple temp readings&#xA;&#xA;//#####SETUP PROCEDURE#####&#xA;void setup()&#xA;{&#xA;  //this is the Setup part of your project - this is for code that is run only ONCE at startup&#xA;  for (int analoguePinCounter = 0; analoguePinCounter &amp;lt; constNoOfAnaloguePins; analoguePinCounter++) //for loop to set up numerous analogue pins&#xA;  {&#xA;    pinMode(analoguePinCounter, INPUT);  //set pin mode of the analogue thermistor input&#xA;  }//end for&#xA;  analogReference(INTERNAL); //use the interval votlage of 1.1V for the ADC resolution&#xA;  Serial.begin(9600); //serial monitor baud rate&#xA;}//end Setup function&#xA;&#xA;//#####LOOP PROCEDURE#####&#xA;void loop()&#xA;{&#xA;  //this is the main part of your project - put all continuously running code here&#xA;  for (int analoguePinCounter = 0; analoguePinCounter &amp;lt; constNoOfAnaloguePins; analoguePinCounter++) //for loop to take temp readings from each analogue pin&#xA;  {&#xA;    //get LPF average reading over 25 samples&#xA;    avgTempC = LPF(analoguePinCounter, 25);&#xA;    //print out the readings&#xA;    if (avgTempC &amp;lt; float(errReturn)) //there hasn't been any temps outside the range ***CHECK THE VALUE RETURNED FROM LPF IF ERROR***&#xA;    {&#xA;      Serial.print(analoguePinCounter);&#xA;      Serial.print( F(&quot; | Average Temperature Readings = &quot;) );&#xA;      Serial.print(avgTempC, 2);&#xA;      Serial.println( F(&quot; degC.&quot;) );&#xA;      Serial.println( F(&quot;-------------------------&quot;) );&#xA;    }&#xA;    else //avgTempC has returned X indicating an error&#xA;    {&#xA;      Serial.print(analoguePinCounter);&#xA;      Serial.println( F(&quot;**ERROR IN READING AVERAGE TEMP**&quot;) );&#xA;      Serial.println( F(&quot;-------------------------&quot;) );&#xA;      delay(10);&#xA;    }//end if&#xA;    delay(constDelay/2); //wait X/2 seconds until moving onto next sensor&#xA;  }//end for&#xA;  delay(constDelay); //wait X seconds until next loop&#xA;}//end Loop function&#xA;&#xA;/*&#xA;#####LOW PASS FILTER DESCRIPTION#####&#xA;This function is a LPF for smoothing out signals or averaging&#xA;It uses a static buffer to store the last &quot;n&quot; readings, and each time it is called,&#xA;the oldest reading is discarded, the new reading is added, and the stack average&#xA;value is returned.&#xA;The buffer size is user-adjustable, but is constrained between 2 and 50&#xA;An initialization function fills the entire buffer with the input value. &#xA;This is useful when the LPF function is called for the first time.&#xA;Note: To meet the definition of a true LPF, this function must be called         at regular intervals.&#xA;*/&#xA;//#####LOW PASS FILTER FUNCTION#####&#xA;float LPF(int pinAnalogue, int bufferSize)&#xA;{&#xA;  //##PRE PROCESSOR##&#xA;  #define bufferCap 75 //maximum buffer capacity&#xA;  //##CONSTANTS##&#xA;  const int constMAXERRORS = 5; //max number of error that can occur&#xA;  //##VARIABLES##&#xA;  float tempC; //var to store instantaneous temp&#xA;  static float buffer[bufferCap]; //array to act like a 'stack' of temp values ***DOES IT NEED TO BE STATIC NOW?***&#xA;  float tempSum; //to store the sum of the temperatures&#xA;  float output; //return value of LPF which is the average of the temp readings&#xA;  int errCounter = 0; //initialise error counter to 0&#xA;&#xA;  //make sure buffer size is between the range&#xA;  bufferSize = constrain(bufferSize, 2, bufferCap);&#xA;&#xA;  for (int i=0; i&amp;lt;bufferSize; i++) //for loop to store temps in buffer array &#xA;  {&#xA;    tempC = getTempFloat(pinAnalogue); //call function to get temperature from pin&#xA;    if ((tempC &amp;gt; -errReturn) &amp;amp;&amp;amp; (tempC &amp;lt; errReturn)) //no error &#xA;    {&#xA;      buffer[i] = tempC; //store temp value into array&#xA;    }&#xA;    else //error&#xA;    {&#xA;      errCounter++; //increment counter for number of erroneous readings&#xA;      i--; //decrement counter as to not skip a sample index&#xA;      if (errCounter &amp;gt; constMAXERRORS)&#xA;      {&#xA;        return(errReturn+1.0); //return the error value + 1&#xA;      }//end if&#xA;    }//end if&#xA;    delay(25); //allow the ADC to settle&#xA;  }//end for&#xA;&#xA;  //calculate current stack average&#xA;  tempSum = 0; //initialise sum total&#xA;  for (int i=0; i&amp;lt;bufferSize; i++) //go through stack array&#xA;  {&#xA;    tempSum = tempSum + buffer[i]; //total up readings&#xA;  }//end for&#xA;&#xA;  //average sum&#xA;  output = tempSum/bufferSize;&#xA;&#xA;  return(output);&#xA;}//end LPF function&#xA;&#xA;/*&#xA;#####GET TEMP FLOAT DESCRIPTION#####  &#xA;This function converts a thermistor reading into a corresponding temp in ^C&#xA;The thermistor is incorporated into a Voltage Divider Circuit:&#xA;&#xA;   +Vref---[Thermistor]---+--[1.8K]---GND&#xA;                          |&#xA;                         ADC @ thermPin&#xA;&#xA;ADC Values were externally calculated from the calibration table using:           ADC = 1023*10000/(Rtherm+10000)&#xA;The LUT is an array of integer constants containing the predicted ADC         values for all temperatures between +6^C to +40.5^C.&#xA;The array index starts at zero, which corresponds to a temperature of         +6^C.&#xA;A linear interpolation between the two closest entries is performed to         give a finer output resolution.&#xA;*/&#xA;&#xA;//##CONSTANTS##&#xA;/*1K8*/&#xA;const int LUT_Therm[] PROGMEM = //LUT containing ADC values&#xA;{&#xA;  223, 224, 225, 226, 227, 228, 229, 230, 231, 232,         //7^C to 7.9^C&#xA;  233, 234, 235, 236, 237, 238, 239, 240, 241, 242,&#xA;  244, 245, 246, 247, 248, 249, 250, 251, 252, 253,&#xA;  255, 256, 257, 258, 259, 260, 261, 263, 264, 265,&#xA;  266, 267, 268, 269, 271, 272, 273, 274, 275, 277,&#xA;  278, 279, 280, 281, 283, 284, 285, 286, 287, 289,&#xA;  290, 291, 292, 294, 295, 296, 297, 299, 300, 301,           //13^C to 13.9^C&#xA;  302, 304, 305, 306, 308, 309, 310, 312, 313, 314,&#xA;  315, 317, 318, 319, 321, 322, 323, 325, 326, 327,&#xA;  329, 330, 332, 333, 334, 336, 337, 338, 340, 341,&#xA;  343, 344, 345, 347, 348, 350, 351, 353, 354, 355,&#xA;  357, 358, 360, 361, 363, 364, 366, 367, 369, 370,&#xA;  371, 373, 374, 376, 377, 379, 380, 382, 383, 385,&#xA;  387, 388, 390, 391, 393, 394, 396, 397, 399, 400,&#xA;  402, 404, 405, 407, 408, 410, 411, 413, 415, 416,&#xA;  418, 419, 421, 423, 424, 426, 428, 429, 431, 433,&#xA;  434, 436, 438, 439, 441, 443, 444, 446, 448, 449,&#xA;  451, 453, 454, 456, 458, 460, 461, 463, 465, 466,&#xA;  468, 470, 472, 473, 475, 477, 479, 480, 482, 484,&#xA;  486, 488, 489, 491, 493, 495, 497, 498, 500, 502,&#xA;  504, 506, 507, 509, 511, 513, 515, 517, 519, 520,&#xA;  522, 524, 526, 528, 530, 532, 534, 535, 537, 539,&#xA;  541, 543, 545, 547, 549, 551, 553, 555, 557, 559,&#xA;  560, 562, 564, 566, 568, 570, 572, 574, 576, 578, &#xA;  580, 582, 584, 586, 588, 590, 592, 594, 596, 598,&#xA;  600, 602, 604, 606, 608, 611, 613, 615, 617, 619,&#xA;  621, 623, 625, 627, 629, 631, 633, 635, 638, 640,&#xA;  642, 644, 646, 648, 650, 652, 655, 657, 659, 661,&#xA;  663, 665, 667, 670, 672, 674, 676, 678, 680, 683,&#xA;  685, 687, 689, 691, 694, 696, 698, 700, 702, 705,&#xA;  707, 709, 711, 714, 716, 718, 720, 723, 725, 727,&#xA;  729, 732, 734, 736, 738, 741, 743, 745, 747, 750, &#xA;  752, 754, 757, 759, 761, 764, 766, 768, 771, 773,&#xA;  775, 778, 780, 782, 785, 787, 789, 792, 794, 796,&#xA;  799, 801, 803, 806, 808, 811, 813, 815, 818, 820,&#xA;  822, 825, 827, 830, 832, 834, 837, 839, 842, 844,&#xA;  847, 849, 851, 854, 856, 859, 861, 864, 866, 868,&#xA;  871, 873, 876, 878, 881, 883, 886, 888, 891, 893,&#xA;  896, 898, 901, 903, 906, 908, 911, 913, 916, 918, &#xA;  921, 923, 926, 928, 931, 933, 936, 938, 941, 943,&#xA;  946, 948, 951, 953, 956, 958, 961, 963, 966, 969,&#xA;  971, 974, 976, 979, 981, 984, 987, 989, 992, 994,&#xA;  997, 999, 1002, 1005, 1007, 1010, 1012, 1015, 1017, 1020, //40^C to 49.9^C&#xA;  1023                                                     //50^C&#xA;};&#xA;const int constLUTArraySize = sizeof(LUT_Therm)/sizeof(LUT_Therm[0]);&#xA;&#xA;float getTempFloat (int thermPin)&#xA;{&#xA;  //##VARIABLES##&#xA;  float _tempC; //intermediate results + final temperature return value&#xA;  int ADC_Lo; //the lower ADC matching value&#xA;  int ADC_Hi; //the higher ADC matching value&#xA;  float Temp_Lo; //the lower number matching temperature&#xA;  int mapTemp_Lo; //the lower number that will be entered into the map function&#xA;  float Temp_Hi; //the higher  number matching temperature&#xA;  int mapTemp_Hi; //the higher number that will be entered into the map function&#xA;&#xA;  //prep ADC onto that particular analogue pin to sort out multiplexing etc&#xA;  analogRead(thermPin); &#xA;  delay(10);&#xA;  //get raw ADC value from VDR&#xA;  int thermValue = analogRead(thermPin); &#xA;  //Serial.println(thermValue);&#xA;  /*Serial.print( F(&quot;PinNo : &quot;) );&#xA;  Serial.println(thermPin);*/&#xA;  Serial.print( F(&quot;ADC : &quot;) );&#xA;  Serial.println(thermValue);&#xA;&#xA;  //return dummy value if the sensor reading falls outside of the LUT&#xA;  if (thermValue &amp;lt; (int) pgm_read_word( &amp;amp;LUT_Therm[0] )) //less than the least ADC value&#xA;    _tempC = -errReturn-1; //under range dummy value&#xA;&#xA;  else if (thermValue &amp;gt; (int) pgm_read_word(LUT_Therm[constLUTArraySize-1])) //more than the greatest ADC value&#xA;    _tempC = errReturn+1; //over range dummy value&#xA;&#xA;  else //value falls in LUT range&#xA;  {&#xA;    int prev_lut_therm = 0;&#xA;    for (int i=0; i&amp;lt;constLUTArraySize; i++) //step through LUT and look for a match&#xA;    {    &#xA;      int lut_therm = (int) pgm_read_word(LUT_Therm[i]);&#xA;      if (lut_therm &amp;gt; thermValue) //LUT value is greater than the reading&#xA;      {  &#xA;        //find the closest higher ADC value&#xA;        ADC_Hi = lut_therm;&#xA;        //record the closest higher temperature        &#xA;        Temp_Hi = float(i/10) + 13.0; //convert to temp&#xA;        //get the closest lower temperature - taking the lower table boundary into account&#xA;        if (i != 0) //general case -&amp;gt; as long as it is not the first entry&#xA;        {&#xA;          ADC_Lo = prev_lut_therm; //store the previous array element as the low&#xA;          Temp_Lo = float(i/10) + 13.0 - 0.1; //convert to temp&#xA;        }&#xA;        else //special case -&amp;gt; counter = 0 ie first array entry&#xA;        {&#xA;          ADC_Lo = lut_therm; //store the first array element&#xA;          Temp_Lo = i - float(i/10) + 13.0; //convert to temp&#xA;        }//end if&#xA;        //interpolate the temperature value for greater precision&#xA;        //NB the map function does not use floating-point math, so the int values of temp are multiplied by 100 and then result is subsequently divided by 100&#xA;        mapTemp_Lo = Temp_Lo*100;&#xA;        mapTemp_Hi = Temp_Hi*100;&#xA;        _tempC = float(map(thermValue,ADC_Lo,ADC_Hi,mapTemp_Lo,mapTemp_Hi))/100;&#xA;        break;  //exit for loop after the match is detected&#xA;      }//end if&#xA;      prev_lut_therm = lut_therm;&#xA;    }//end for&#xA;  }//end if&#xA;  return(_tempC);&#xA;}//end getTempFloat function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note the technique for declaring the &lt;code&gt;LUT_Therm&lt;/code&gt; array, using the empty &lt;code&gt;[]&lt;/code&gt; brackets (line 135).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's followed by the &lt;code&gt;const int&lt;/code&gt; array size (line 182) that is &quot;calculated&quot; from the array declaration: (Total array size) / (size of one array element).  If you ever change the lookup table, you don't have to count the elements by hand.  Let the compiler do it for you!  :)&#xA;&lt;hr&gt;&#xA;[1] Although the IDE reports an increased binary sketch size, the total uploaded size is unchanged:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;PROGMEM keyword   text    data     bss&#xA;No                5948     894     483&#xA;Yes               6810      32     483&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the 862 bytes for this table move from the &lt;code&gt;data&lt;/code&gt; section to the &lt;code&gt;text&lt;/code&gt; section.  The uploaded HEX files are identical at 93,737 bytes.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2016-03-24T14:35:39.900" LastActivityDate="2016-03-24T14:35:39.900" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22176" PostTypeId="2" ParentId="22172" CreationDate="2016-03-23T18:30:34.350" Score="0" Body="&lt;p&gt;Possible causes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The DHCP server might be down.&lt;/li&gt;&#xA;&lt;li&gt;Or it might have lost its state (but I think they try really hard to preserve the list of leases).&lt;/li&gt;&#xA;&lt;li&gt;Or some other cause which makes the server unavailable/unwilling to renew the lease.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Solutions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you can wait, you can retry, but otherwise I'd just say try to obtain a new lease, unless for some reason you &lt;em&gt;really&lt;/em&gt; want to stick to the IP from the previous lease.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you control the server and your network is kinda stable, you could assign a fixed IP to your device configure the server to associate it with the MAC address you gave to your device. In general, when the network setup is really stable, this might be preferable, since other entities on the network will probably cache the IP of your device and use it, should the DNS fail as well (ex: dnsmasquerade works both as dhcp server and dns). Similarly, your device doesn't have to worry anymore of the DHCP lease, because it's permanent.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="19515" LastEditDate="2016-03-24T13:08:14.437" LastActivityDate="2016-03-24T13:08:14.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22177" PostTypeId="2" ParentId="22167" CreationDate="2016-03-23T20:12:36.450" Score="1" Body="&lt;p&gt;Previous reports of this RTC problem (&lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=22&amp;amp;p=194535&quot; rel=&quot;nofollow&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=25&amp;amp;t=66041&quot; rel=&quot;nofollow&quot;&gt;2&lt;/a&gt;,&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=189283.0&quot; rel=&quot;nofollow&quot;&gt;3&lt;/a&gt;) attribute it to hardware issues, such as broken wires (to SCL or to battery) and overvoltage (&lt;code&gt;&amp;gt;&lt;/code&gt;3.6 V supply vs 3 to 3.3 V).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your setup uses breadboards or other temporary connections, you might try adding some redundant wires.  If your setup uses soldered connections, go over them carefully, looking for shorts and opens; or use a solder sucker / solder wick to remove old solder; then solder anew to make fresh, bright connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't locate a hardware problem (and perhaps even if you do) you could add error-testing to your sketch.  That code would see if all relevant fields have valid, in-range values.  If any fields are invalid, it would delay a few milliseconds and then reread the RTC.  &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-23T20:12:36.450" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22178" PostTypeId="2" ParentId="22167" CreationDate="2016-03-23T20:34:56.213" Score="4" Body="&lt;p&gt;The RTC library does not check for communications success. In particular, here:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;DateTime RTC_DS1307::now() {&#xA;  Wire.beginTransmission(DS1307_ADDRESS);&#xA;  Wire.send((byte) 0);&#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.requestFrom(DS1307_ADDRESS, 7);&#xA;  uint8_t ss = bcd2bin(Wire.read() &amp;amp; 0x7F);&#xA;  uint8_t mm = bcd2bin(Wire.read());&#xA;  uint8_t hh = bcd2bin(Wire.read());&#xA;  Wire.read();&#xA;  uint8_t d = bcd2bin(Wire.read());&#xA;  uint8_t m = bcd2bin(Wire.read());&#xA;  uint16_t y = bcd2bin(Wire.read()) + 2000;&#xA;&#xA;  return DateTime (y, m, d, hh, mm, ss);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There should be a check for a zero returned from &lt;code&gt;Wire.endTransmission()&lt;/code&gt;. It isn't otherwise possible to detect if the data is invalid (if we got the endTransmission OK) however generally speaking I2C will return 0xFF if the transmission has ceased.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in the library for &lt;code&gt;bcd2bin&lt;/code&gt; is this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;static uint8_t bcd2bin (uint8_t val) { return val - 6 * (val &amp;gt;&amp;gt; 4); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that if passed 0xFF (255) it will return:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;   255 - (6 * 15) = 165&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus if any of the minutes, hours, day or month (which are not further affected in the code above) are 165 (or if the year is 2165) you can assume the whole date/time is bad.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-23T20:34:56.213" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22179" PostTypeId="2" ParentId="22051" CreationDate="2016-03-23T21:32:56.883" Score="1" Body="&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; First, deferring &lt;code&gt;PrintSec&lt;/code&gt; to &lt;code&gt;loop&lt;/code&gt; through the volatile &lt;code&gt;state&lt;/code&gt;, which is set by the ISR, actually takes &lt;em&gt;more&lt;/em&gt; time to update the display.  You might as well just test the pin in &lt;code&gt;loop&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;  S_Serial.begin(9600);&#xA;  pinMode(intpin, INPUT);&#xA;&#xA;  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)&#xA;  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;         bool state    = digitalRead(intPin);&#xA;  static bool oldState = false;&#xA;&#xA;  // Watch for change&#xA;  if (oldState != state) {&#xA;    oldState = state;&#xA;&#xA;    // RISING edge?&#xA;    if (state)&#xA;      PrintSec();&#xA;  }&#xA;&#xA;  if ( processGPS() ) &#xA;    PrintScreen();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;&lt;strong&gt;2)&lt;/strong&gt; &quot;But I might miss a PPS!&quot; you exclaim.  The bad news is that if you can't finish &lt;code&gt;PrintScreen&lt;/code&gt; in time to get back to testing the pin, then you're Trying To Do Too Much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to consider incremental updates of the display.  If you have the previous pieces (i.e., an extra NAV_PVT struct), you could compare each piece to see if it has changed.  If it has, it's ok to spend time writing it.  Just add an extra test to each piece:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NAV_PVT pvt, prevPVT;&#xA;static bool firstTime = true;&#xA;  .&#xA;  .&#xA;  .&#xA;void PrintScreen()&#xA;{&#xA;  if (firstTime)&#xA;    display.clearDisplay();&#xA;&#xA;  //Size 2&#xA;  display.setTextSize(2);&#xA;  display.setTextColor(WHITE);&#xA;&#xA;  //  Update the Speed?&#xA;  if (firstTime || (pvt.gSpeed != prevPVT.gSpeed)) {&#xA;    display.setCursor(0,0);&#xA;    float sik = (pvt.gSpeed / 100) / 3.6f;&#xA;    if (sik&amp;lt;100)&#xA;      display.print(&quot; &quot;);&#xA;    if (sik&amp;lt;10)&#xA;      display.print(&quot; &quot;);&#xA;    display.print(sik,1);//SpeedInKph&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the end of &lt;code&gt;PrintScreen&lt;/code&gt;, do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  display.display();&#xA;&#xA;  prevPVT   = pvt;&#xA;  firstTime = false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For most updates, only the &lt;code&gt;seconds&lt;/code&gt; field would get written.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Clearing the screen and drawing the labels could probably happen just once in &lt;code&gt;setup&lt;/code&gt;.&#xA;&lt;hr&gt;&#xA;&lt;strong&gt;3)&lt;/strong&gt; I would suggest a more efficient and reliable software serial library.  &lt;code&gt;SoftwareSerial&lt;/code&gt; disables &lt;em&gt;all&lt;/em&gt; interrupts for the entire 10-bit character time, once the start bit is received.  This makes it both vulnerable and intrusive to other interrupts, like PinChange and SPI.  Ick.  If you can use pins 8 &amp;amp; 9, AltSoftSerial is the best choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't use those pins, and you're not using the USB port to connect to a host, could you use Serial input (pin 0) for the GPS?  The GPS would have to be disconnected to do USB programming, but it could stay connected if you're using an ISP.&#xA;&lt;hr&gt;&#xA;&lt;strong&gt;4)&lt;/strong&gt; You need a more robust way to restart UBX packet framing, even if chars are lost.  I would suggest something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  if (state == HIGH) {&#xA;    PrintSec();&#xA;    fpos = 0; // new packet coming soon, ditch old partial packet&#xA;  }&#xA;  if ( processGPS() ) &#xA;    PrintScreen();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At least that will keep you in sync.  Without it, packet completion might not happen until after a 2nd PPS occurs (and 2nd packet begins arriving).  Maybe this explains the symptoms you're seeing?&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-03-23T21:32:56.883" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22180" PostTypeId="2" ParentId="22045" CreationDate="2016-03-23T21:51:44.117" Score="6" Body="&lt;p&gt;Yes, charging a battery and supplying an Arduino at the same time is possible as long as we manage the caveats (see below) of in-circuit charging.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;This is what I use:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a 3.3V Arduino (a &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;noreferrer&quot;&gt;Pro Mini&lt;/a&gt; in my case),&lt;/li&gt;&#xA;&lt;li&gt;a regular &lt;a href=&quot;https://en.wikipedia.org/wiki/Lithium-ion_battery&quot; rel=&quot;noreferrer&quot;&gt;Li-Ion battery&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;a charging controller that supports &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_source&quot; rel=&quot;noreferrer&quot;&gt;constant voltage&lt;/a&gt; (CV) and &lt;a href=&quot;https://en.wikipedia.org/wiki/Constant_current&quot; rel=&quot;noreferrer&quot;&gt;constant current&lt;/a&gt; (CC) &lt;a href=&quot;https://en.wikipedia.org/wiki/Lithium-ion_battery#Procedure&quot; rel=&quot;noreferrer&quot;&gt;charging&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;optionally, a 6V solar panel.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;This is how it works:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;charger is fed via solar panel and/or USB supply,&lt;/li&gt;&#xA;&lt;li&gt;battery is continuously supervised and charged on demand&lt;/li&gt;&#xA;&lt;li&gt;Arduino is connected to the output side of the charger&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This works because the load that the Arduino presents is relatively small compared to what the charger can feed (and what the battery can take). &#xA;During recharging the charge current will predominantly flow through the battery. &#xA;And since the current through the battery drops once it gets full, the charger can still recognise this drop and finish the charge cycle – even though the Arduino is connected all the time.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example setup:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I took some quick snapshots, please excuse the image quality. Charger is in the center, Arduino to the upper left, &lt;a href=&quot;http://industrial.panasonic.com/cdbs/www-data/pdf2/ACI4000/ACI4000CE17.pdf&quot; rel=&quot;noreferrer&quot;&gt;battery&lt;/a&gt; in a holder to the lower left, solar panel to the upper right. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino has a voltage regulator, but I don't use it in this setup. An explanation why and when to use the regulator is beyond the scope of this question and a matter for another answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/D6GoK.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D6GoK.jpg&quot; alt=&quot;charger turned off&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the first photo the charger input is only connected to the solar panel, but the panel voltage is low. So the charger is actually &lt;em&gt;off&lt;/em&gt; and the Arduino is running off the battery.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bO1kR.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bO1kR.jpg&quot; alt=&quot;charger in charge mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second photo the charger is now connected to a USB power supply. The charger is on and in CC/CV charge mode (as indicated by the red LED of this charger model).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rsrqv.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rsrqv.jpg&quot; alt=&quot;charger in standby mode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the third photo the charge cycle is completed, the battery is full (as indicated by the blue LED of this charger model). Note that the charger could determine the charge completion even though the Arduino is connected and running (no power saving tricks involved here).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Background info:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The charger switches between CC and CV mode, depending on the level of discharge the battery is in. Particularly, my charger uses CC mode in case the voltage on the battery side is below 4V and CV mode in case the voltage on the battery side is above 4V. The current limit can be configured and the voltage limit is hard coded to around 4.2V, which makes the circuit save for a device like Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/40sok.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/40sok.png&quot; alt=&quot;The charger switches between CC and CV mode.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image source: &lt;a href=&quot;https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/TP4056.pdf&quot; rel=&quot;noreferrer&quot;&gt;Nanjing Top Power&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other chargers may have other thresholds, but that doesn't matter as long as it fits your battery type and uses constant current/voltage only.&#xA;I have no particular recommendation for a charger, but so far have a good impression of the one I used in this answer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Caveats:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;There are a couple of cases to consider, though:&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Deep discharge&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Should the battery voltage ever go below around 2.9V (e.g. deeply discharged battery), the charger will switch into trickle charge mode where only very small amounts of current are passed to the battery – too little current (i.e. too low a voltage) for the Arduino to run. Arduino will go into brown-out and try to restart until the battery has recovered. So this can become a state in which your Arduino won't respond for an unknown amount of time.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;High load&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;If the load connected to the battery draws a current that isn't small anymore – compared to the battery charge current – then the charger cannot recognise a full battery anymore, since the current as seen by the charger will never fall off at the end of any charge cycle. So watch out how many gadgets you connect to this kind of in-circuit charger.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Wrong charger type&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There are a multitude of ways to charge a battery. Things like &lt;a href=&quot;https://en.wikipedia.org/wiki/Trickle_charging&quot; rel=&quot;noreferrer&quot;&gt;trickle charge&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Battery_regenerator&quot; rel=&quot;noreferrer&quot;&gt;pulse charge&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Battery_charger#Timer-based.28HI.29_chargers&quot; rel=&quot;noreferrer&quot;&gt;timer based charging&lt;/a&gt;, and so on. &#xA;None of these would likely work, as the voltage those charger types generate could upset the Arduino and the load the Arduino presents could upset the charger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please also note that some chargers don't supervise the battery. With Li-Ion or Li-Poly (and other) batteries this would be a very bad idea. Always choose a charger appropriate for your battery.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Alternatives&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The charger I use employs a linear regulator. That's not very efficient, other topologies are possible. But they might require &lt;a href=&quot;https://en.wikipedia.org/wiki/Ripple_(electrical)&quot; rel=&quot;noreferrer&quot;&gt;supply filtering&lt;/a&gt; for the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Shameless plug&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I wrote a library for the purpose of supervising an Arduino's supply voltage (and chip temperature). This technique allows to check the battery level without any additional components. That library is called &lt;a href=&quot;https://github.com/sekdiy/CoreSensors&quot; rel=&quot;noreferrer&quot;&gt;CoreSensors&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Further links:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Qw4psECqpwI#t=22.19582&quot; rel=&quot;noreferrer&quot;&gt;New TP4056 Lithium Cell Charger Module with Battery Protection&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.mysensors.org/topic/1484/solar-pannel-and-lion-or-lipo/8&quot; rel=&quot;noreferrer&quot;&gt;Solar Pannel and LiOn or Lipo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://electronics.stackexchange.com/questions/152931/how-to-autoregulate-a-tp4056-for-maximum-solar-power-extraction&quot;&gt;How to autoregulate a TP4056 for maximum solar power extraction&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19016" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-03-23T22:02:59.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22181" PostTypeId="5" CreationDate="2016-03-23T22:23:55.820" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-23T22:23:55.820" LastActivityDate="2016-03-23T22:23:55.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22182" PostTypeId="4" CreationDate="2016-03-23T22:23:55.820" Score="0" Body="Wire is a conductor that used to connect electronic components each other" OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2017-01-26T18:53:26.290" LastActivityDate="2017-01-26T18:53:26.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22183" PostTypeId="5" CreationDate="2016-03-23T22:24:52.730" Score="0" Body="&lt;p&gt;Wireless technologies allow the transfer of data between two points that have no physical connection, i.e. through electromagnetic waves.&#xA;Traditionally, those physical connection are made in copper wires hence the term &quot;wire-less&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="84" LastEditDate="2016-08-25T18:21:38.207" LastActivityDate="2016-08-25T18:21:38.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22184" PostTypeId="4" CreationDate="2016-03-23T22:24:52.730" Score="0" Body="Wireless refers to the technology allowing the transfer of information between two points that are not physically connected. " OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-09-27T13:39:23.570" LastActivityDate="2016-09-27T13:39:23.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22185" PostTypeId="5" CreationDate="2016-03-23T22:25:25.220" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-23T22:25:25.220" LastActivityDate="2016-03-23T22:25:25.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22186" PostTypeId="4" CreationDate="2016-03-23T22:25:25.220" Score="0" Body="For question related to environment with networks." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T13:07:37.780" LastActivityDate="2016-03-24T13:07:37.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22187" PostTypeId="5" CreationDate="2016-03-23T22:27:58.873" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-23T22:27:58.873" LastActivityDate="2016-03-23T22:27:58.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22188" PostTypeId="4" CreationDate="2016-03-23T22:27:58.873" Score="0" Body="Refers to Mac operating systems." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T13:07:34.827" LastActivityDate="2016-03-24T13:07:34.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22189" PostTypeId="1" CreationDate="2016-03-23T23:16:20.377" Score="0" ViewCount="1470" Body="&lt;p&gt;I have an Arduino Uno connected to the Adafruit Motorshield v2. I have it hooked up to a stepper motor(27BYJ-48). I am trying to make the motor do one complete revolution. However, the number of steps I specify to the stepper motor(200 in the code) doesn't affect the motor steps. For example, the 2200 step in this code, is roughly one rotation and is completely unaffected by change the steps/revolution specified when instantiating the motor. How do I get the motor to do one exact revolution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code on the arduino: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_MS_PWMServoDriver.h&quot;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;  Serial.println(&quot;Stepper test!&quot;);&#xA;&#xA;  AFMS.begin();  // create with the default frequency 1.6KHz&#xA;&#xA;  myMotor-&amp;gt;setSpeed(2000);  // 10 rpm   &#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Single coil steps&quot;);&#xA;  myMotor-&amp;gt;step(2200, FORWARD, DOUBLE); &#xA;  myMotor-&amp;gt;step(2200, BACKWARD, DOUBLE); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;Wiring:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/U8Vo5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U8Vo5.png&quot; alt=&quot;Wiring from Motorshield to Stepper&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EnOvw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EnOvw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19561" LastEditorUserId="19561" LastEditDate="2016-03-23T23:38:28.533" LastActivityDate="2017-10-18T13:15:49.320" Title="Stepper Motor not Stepping Properly" Tags="|arduino-uno|motor|stepper|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22191" PostTypeId="1" AcceptedAnswerId="22199" CreationDate="2016-03-24T00:44:42.947" Score="2" ViewCount="24570" Body="&lt;p&gt;Arduino IDE is throwing this error when uploading sketches - &lt;strong&gt;avrdude: stk500_recv(): programmer is not responding&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem arose just after I uploaded a blink sketch to my Arduino Mini, which worked absolutely fine. After the successful upload I tried to upload a different sketch and got the error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I had destroyed the boot loader somehow and was about to get out the Bus Pirate for ICSP but I decided to try another Arduino Mini I had lying around (albeit from another manufacturer) and got the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm convinced it's a driver issue as I successfully uploaded a sketch (it still runs as we speak!) then just magically without changing &lt;strong&gt;ANYTHING&lt;/strong&gt; I can no longer upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a futile attempt to get back to work I've done the following:&#xA;Switched the RX-TX lines (clearly not the issue as the first upload worked)&#xA;Used a different FTDI cable&#xA;used a  different programmer&#xA;(FTDI 5V/3.3V USB to TTL Basic FT232 FIO Programmer)&#xA;(USB to TTL Serial UART RS232 Adaptor (PL2303HX)&#xA;I'm fairly certain these use different drivers - FTDI and Prolific&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me I'm about to murder something :'(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BBQoV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Screencaps of error and device manager - Imgur&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19566" LastActivityDate="2018-11-10T16:02:16.730" Title="avrdude: stk500_recv(): programmer is not responding" Tags="|ftdi|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22193" PostTypeId="2" ParentId="22189" CreationDate="2016-03-24T01:34:44.680" Score="1" Body="&lt;p&gt;Ok so I'm not familiar with the sheild or API (or motor lol) but going off the spec sheets etc &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Leave the red wire disconnected [see 1] and try this code and report back what happens:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;Wire.h&amp;gt;&#xA;  #include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;  #include &quot;utility/Adafruit_MS_PWMServoDriver.h&quot;&#xA;&#xA;  Adafruit_MotorShield AFMS = Adafruit_MotorShield(); &#xA;  Adafruit_StepperMotor *myMotor = AFMS.getStepper(64, 2); // 64 steps pr revolution&#xA;                                                           // Using M3 and M4 of shield&#xA;&#xA;  void setup() &#xA;  {&#xA;    AFMS.begin();  // create with the default frequency 1.6KHz&#xA;    myMotor-&amp;gt;setSpeed(30);  // 30 rpm, so 1 full turn every 2sec  &#xA;  }&#xA;&#xA;  void loop() &#xA;  {  &#xA;    // 64 steps per motor shaft revolution,&#xA;    // 64 revolutions of motor per output shaft revolution&#xA;    myMotor-&amp;gt;step(4096, FORWARD, DOUBLE);    // Should be 1 rev in one direction&#xA;    myMotor-&amp;gt;step(4096, BACKWARD, DOUBLE);   // and 1 rev in other direction&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;[1] : your motor is unipolar (&lt;a href=&quot;https://en.wikipedia.org/wiki/Stepper_motor#Unipolar_motors&quot; rel=&quot;nofollow&quot;&gt;wikipedia on unipolar and bipolar motors&lt;/a&gt;), according to its documentation. The red wire is the central tap, and useless in this context.&lt;/p&gt;&#xA;" OwnerUserId="16725" LastEditorUserId="19504" LastEditDate="2016-03-25T20:37:28.110" LastActivityDate="2016-03-25T20:37:28.110" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22194" PostTypeId="2" ParentId="22191" CreationDate="2016-03-24T02:31:48.790" Score="4" Body="&lt;p&gt;Is it this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;To upload a new sketch to the Arduino Mini, you need to press the reset button on the board immediately before pressing the upload button in the Arduino environment.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoMini&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/ArduinoMini&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19523" LastActivityDate="2016-03-24T02:31:48.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22195" PostTypeId="1" CreationDate="2016-03-24T04:14:57.713" Score="1" ViewCount="2767" Body="&lt;p&gt;I have seen some tutorials on ultrasonic range detector sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that, what is the meaning of the word &lt;code&gt;pulseIn&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19413" LastEditorUserId="19515" LastEditDate="2016-03-24T20:10:00.680" LastActivityDate="2016-03-24T22:31:28.530" Title="What is pulseIn in programming Arduino?" Tags="|arduino-uno|programming|pulsein|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22196" PostTypeId="2" ParentId="22195" CreationDate="2016-03-24T04:25:44.257" Score="3" Body="&lt;p&gt;&lt;code&gt;pulseIn()&lt;/code&gt; is used to Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, &lt;code&gt;pulseIn()&lt;/code&gt; waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or 0 if no complete pulse was received within the timeout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timing of this function has been determined empirically and will probably show errors in shorter pulses. Works on pulses from 10 microseconds to 3 minutes in length. Please also note that if the pin is already high when the function is called, it will wait for the pin to go LOW and then HIGH before it starts counting. This routine can be used only if interrupts are activated. Furthermore the highest resolution is obtained with short intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pulseIn(pin, value) &#xA;pulseIn(pin, value, timeout)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;pin:&lt;/em&gt; the number of the pin on which you want to read the pulse. (int)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;value:&lt;/em&gt; type of pulse to read: either HIGH or LOW. (int)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;timeout (optional):&lt;/em&gt; the number of microseconds to wait for the pulse to be completed: the function returns 0 if no complete pulse was received within the timeout. Default is one second (unsigned long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Returns&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The length of the pulse (in microseconds) or 0 if no pulse is completed before the timeout (unsigned long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For additional information and example code, visit: &lt;a href=&quot;https://www.arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/PulseIn&lt;/a&gt;, hope this help you to understand the meaning of &lt;code&gt;pulseIn()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T22:31:28.530" LastActivityDate="2016-03-24T22:31:28.530" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22197" PostTypeId="5" CreationDate="2016-03-24T04:27:38.070" Score="0" Body="&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or 0 if no complete pulse was received within the timeout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timing of this function has been determined empirically and will probably show errors in shorter pulses. Works on pulses from 10 microseconds to 3 minutes in length. Please also note that if the pin is already high when the function is called, it will wait for the pin to go LOW and then HIGH before it starts counting. This routine can be used only if interrupts are activated. Furthermore the highest resolution is obtained with short intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pulseIn(pin, value) &#xA;pulseIn(pin, value, timeout)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;pin:&lt;/em&gt; the number of the pin on which you want to read the pulse. (int)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;value:&lt;/em&gt; type of pulse to read: either HIGH or LOW. (int)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;timeout (optional):&lt;/em&gt; the number of microseconds to wait for the pulse to be completed: the function returns 0 if no complete pulse was received within the timeout. Default is one second (unsigned long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Returns&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the length of the pulse (in microseconds) or 0 if no pulse is completed before the timeout (unsigned long)&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T13:08:02.483" LastActivityDate="2016-03-24T13:08:02.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22198" PostTypeId="4" CreationDate="2016-03-24T04:27:38.070" Score="0" Body="refers to the function pulseIn()." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-24T13:08:07.607" LastActivityDate="2016-03-24T13:08:07.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22199" PostTypeId="2" ParentId="22191" CreationDate="2016-03-24T05:09:29.277" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it this?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;To upload a new sketch to the Arduino Mini, you need to press the reset button &gt;on the board immediately before pressing the upload button in the Arduino &gt;environment.&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoMini&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Guide/ArduinoMini&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You sir, are a hero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't even know how I accidentally did this sequence to upload the first sketch... Perhaps I plugged the USB to Serial UART in to the USB port and quickly pressed upload? Having got the first sketch on there really mixed me up :/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Click upload sketch - It will show 'Compiling Sketch'&lt;/li&gt;&#xA;&lt;li&gt;Immediately after clicking upload, hold the reset button down on the Arduino mini&lt;/li&gt;&#xA;&lt;li&gt;Release the reset button when 'Compiling Sketch' turns in to 'Uploading'&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19566" LastEditorUserId="19566" LastEditDate="2018-05-22T17:25:07.313" LastActivityDate="2018-05-22T17:25:07.313" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22200" PostTypeId="1" CreationDate="2016-03-24T05:16:12.293" Score="1" ViewCount="2808" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VoSVn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VoSVn.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;What to add on this code to check my pins state during run? And how can i trigger error using Visual basic when 1 of my pin is disconnected?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String input = &quot;&quot;;&#xA;&#xA;void setup(){&#xA;&#xA;Serial.begin(9600); // Sets up communication with the serial port&#xA;&#xA;pinMode(6,OUTPUT);&#xA;pinMode(7,OUTPUT);&#xA;pinMode(8,OUTPUT);&#xA;pinMode(9,OUTPUT);&#xA;pinMode(10,OUTPUT);&#xA;pinMode(11,OUTPUT); // for start of program operation&#xA;pinMode(12,OUTPUT); // for stop of program operation&#xA;&#xA;digitalWrite(6,LOW);&#xA;digitalWrite(7,LOW);&#xA;digitalWrite(8,LOW);&#xA;digitalWrite(9,LOW);&#xA;digitalWrite(10,LOW);&#xA;&#xA;digitalWrite(11,LOW);&#xA;digitalWrite(12,LOW);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;int recipe;&#xA;//Serial.print(&quot;Enter recipe number: &quot;);&#xA;&#xA;while(Serial.available()==0){    // Waits for data from serial port&#xA;}&#xA;&#xA;while(Serial.available() &amp;gt; 0){&#xA;int data = Serial.read();&#xA;  // convert the incoming byte to a char&#xA;  // and add it to the string&#xA;input += (char)data;&#xA;&#xA;recipe = input.toInt()+'0';    //recipe=0 if not a digit&#xA;if(recipe == '0')&#xA;  recipe = data;&#xA;&#xA;if(data == '\n'){&#xA;  //Serial.print(&quot;Recipe: &quot;);&#xA;  //Serial.println(recipe);&#xA;  //Serial.print(&quot;String: &quot;);&#xA;  //Serial.println(input);&#xA;  input = &quot;&quot;;&#xA;}&#xA;}&#xA;&#xA;if(recipe == 's'){     &#xA;digitalWrite(11,HIGH);&#xA;delay(1000);&#xA;digitalWrite(11,LOW);&#xA;&#xA;digitalWrite(6,LOW);&#xA;digitalWrite(7,LOW);&#xA;digitalWrite(8,LOW);&#xA;digitalWrite(9,LOW);&#xA;digitalWrite(10,LOW);    &#xA;}&#xA;&#xA;else if(recipe == 't'){&#xA;digitalWrite(12,HIGH);&#xA;delay(1000);&#xA;digitalWrite(12,LOW);&#xA;&#xA;digitalWrite(6,LOW);&#xA;digitalWrite(7,LOW);&#xA;digitalWrite(8,LOW);&#xA;digitalWrite(9,LOW);&#xA;digitalWrite(10,LOW); &#xA;} &#xA;&#xA;else if(recipe&amp;gt;'0' &amp;amp;&amp;amp; recipe&amp;lt;'32'){    &#xA;&#xA;recipe = recipe-'0';&#xA;char binary[7] = {0};   // This is where the binary representation will be stored&#xA;recipe += 32; // Adding 32 so that there will always be 6 digits in the string&#xA;itoa(recipe,binary,2);  // Convert recipe to a string of base 2 and save it in array 'binary'&#xA;char* signals = binary + 1; // Get rid of the most significant digit to get the 5 bits&#xA;&#xA;//Serial.print(signals);    // Print out the signals in binary&#xA;&#xA;int i;&#xA;for(i=0; i&amp;lt;5; i++){&#xA;  if(signals[i] == '0')&#xA;    signals[i] = '1';&#xA;  else&#xA;    signals[i] = '0';&#xA;  digitalWrite(i+6, signals[i]-'0');    // write to pin; converts the bit of the string to HIGH or LOW&#xA;  //Serial.print(signals[i]);&#xA;}&#xA;&#xA;}&#xA;else&#xA;loop();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19121" LastEditorUserId="19121" LastEditDate="2016-03-24T06:40:13.033" LastActivityDate="2016-03-24T08:07:42.257" Title="How to check if all pins are connected on my board to make sure Arduino sends the correct pattern number on my tool" Tags="|arduino-uno|electronics|arduino-micro|home-automation|automatization|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22202" PostTypeId="2" ParentId="22200" CreationDate="2016-03-24T08:07:42.257" Score="2" Body="&lt;p&gt;As mentioned in a comment, your code has some fundamental flaws. &lt;strong&gt;Do not&lt;/strong&gt; call &lt;code&gt;loop()&lt;/code&gt; from within &lt;code&gt;loop()&lt;/code&gt;! Aside from the code errors, your question has a legitimate element.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing the tri-state behaviour of an input pin will let you know if it is genuinely high, genuinely low, or floating (disconnected). The technique was given in &lt;a href=&quot;https://arduino.stackexchange.com/questions/12951/testing-tri-state-pin-erroneous-results-with-internal-pullup/12955#12955&quot;&gt;this answer&lt;/a&gt; to similar problem I was encountering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect a large (1MOhm) resistor to each input between the pin and ground, then for each pin:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Turn off internal pullup;&lt;/li&gt;&#xA;&lt;li&gt;Read value of input pin;&lt;/li&gt;&#xA;&lt;li&gt;Turn on internal pullup;&lt;/li&gt;&#xA;&lt;li&gt;Read value again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If the value changes from the first to the second &lt;code&gt;digitalRead()&lt;/code&gt;, the input was not connected to anything. If the value remains the same then it is a genuine value from a connected device.&lt;/p&gt;&#xA;" OwnerUserId="10003" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-24T08:07:42.257" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22204" PostTypeId="1" CreationDate="2016-03-24T10:17:30.443" Score="1" ViewCount="1122" Body="&lt;p&gt;I am working on updating a project and I have a thread over in the Arduino forum which helped me out, but I'm a bit stuck, and there isn't much activity going on there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code is for use with a one wire temperature sensor, however, each time it retrieves data for the sensor, it has a 750ms delay as seen here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ds.reset();&#xA;ds.select(addr);&#xA;ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;delay(750);     // maybe 750ms is enough, maybe not&#xA;// we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;present = ds.reset();&#xA;ds.select(addr);    &#xA;ds.write(0xBE);         // Read Scratchpad&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I'm going to be using a momentary button as a toggle, but for this I need to debounce it, using a delay. With the 750ms delay present for the temperature sensor, that just isn't feasible, it makes it too unpredictable and difficult to use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to replace this delay with a &lt;code&gt;millis&lt;/code&gt; counter, but I'm not sure if I can without hanging up the rest of the script. I gave it a try like so, but it completely screwed up the reading.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (owcurrentMillis - owpreviousMillis &amp;gt;= owinterval) {&#xA;owpreviousMillis = owcurrentMillis;&#xA;present = ds.reset();&#xA;ds.select(addr);    &#xA;ds.write(0xBE);         // Read Scratchpad&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I then tried it like so, and the readout does still work, however, I have an LED which lights up when the temperature has &quot;Stabilized&quot;, which it's supposed to check every one second, but that has stopped working, and it's basically instant making it useless. I don't know why that &lt;code&gt;millis&lt;/code&gt; loop does not work though, it was only working due to the 750ms delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (owcurrentMillis - owpreviousMillis &amp;gt;= owinterval) {&#xA;owpreviousMillis = owcurrentMillis;&#xA;ds.reset();&#xA;ds.select(addr);&#xA;ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the bit of code controlling the LED illumination.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;previousMillis = currentMillis;&#xA;if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {      //If temperature hasn't changed by +/- .05 turn led on.&#xA;  digitalWrite(A0, HIGH); &#xA;}&#xA;}&#xA;if (delta &amp;gt;= 00.06) {                             //If temperature has changed by more than .1 turn LED off&#xA;digitalWrite(A0, LOW);&#xA;}&#xA;if (delta &amp;lt;= -00.06) {&#xA;digitalWrite(A0, LOW);                         // If temperature has changed by more than -.1 turn LED off&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think if I can get that one to work properly, instead of messing up like it is now I should be good, then I just need the 50ms delay to debounce the button which will trigger what I need, I just can't figure out why it will not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see the version which works best &lt;a href=&quot;https://www.dropbox.com/s/0hcz09ba433h80j/Temp%20sensor%20device.txt?dl=0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (with the 750ms delay in place):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;const int chipSelect = 10;&#xA;&#xA;OneWire  ds(9);                               //Onewire + lcd setup&#xA;LiquidCrystal lcd(6, 7, 5, 4, 3, 2);&#xA;float lasttemp;                              //Variable for last temperature&#xA;float delta;                                 //Variable for temperaturechange&#xA;long previousMillis = 0;&#xA;const long interval = 1000;                       //Check once every 20 seconds&#xA;&#xA;const long sdinterval = 5000;&#xA;long sdpreviousMillis = 0;&#xA;&#xA;&#xA;File myFile;&#xA;&#xA;void setup(void) {&#xA;  pinMode(A0, OUTPUT);&#xA;  pinMode(A3, OUTPUT);&#xA;&#xA;  Serial.begin(115200);                       //Start serial + LCD/Light test&#xA;  lcd.begin(8, 2);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;STARTING&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;VER. 1.2&quot;);&#xA;  digitalWrite(A0, HIGH);&#xA;  digitalWrite(A3, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(A0, LOW);&#xA;  digitalWrite(A3, HIGH);&#xA;  lcd.clear();                                //End of LCD/Light test&#xA;&#xA;  if (!SD.begin(10)) {                       // Check for SD card&#xA;    digitalWrite(A3, LOW);&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;SD CHECK&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;  FAIL  &quot;);&#xA;    delay(1000);&#xA;    lcd.clear();&#xA;    digitalWrite(A3, HIGH);&#xA;  } else {&#xA;    delay(1000);&#xA;    digitalWrite(A3, LOW);&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;SD CHECK&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;  PASS  &quot;);&#xA;    delay(1000);&#xA;    lcd.clear();&#xA;    digitalWrite(A3, HIGH);&#xA;  }&#xA;}&#xA;&#xA;&#xA;&#xA;void loop(void) {&#xA;&#xA;  unsigned long sdcurrentMillis = millis();&#xA;  unsigned long currentMillis = millis();&#xA;{&#xA;  }&#xA;&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius, fahrenheit;&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    Serial.println(&quot;No more addresses.&quot;);&#xA;    Serial.println();&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.print(&quot;ROM =&quot;);&#xA;  for( i = 0; i &amp;lt; 8; i++) {&#xA;    Serial.write(' ');&#xA;    Serial.print(addr[i], HEX);&#xA;  }&#xA;&#xA;  if (OneWire::crc8(addr, 7) != addr[7]) {&#xA;    Serial.println(&quot;CRC is not valid!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println();&#xA;&#xA;  // the first ROM byte indicates which chip&#xA;  switch (addr[0]) {&#xA;  case 0x10:&#xA;    Serial.println(&quot;  Chip = DS18S20&quot;);  // or old DS1820&#xA;    type_s = 1;&#xA;    break;&#xA;  case 0x28:&#xA;    Serial.println(&quot;  Chip = DS18B20&quot;);&#xA;    type_s = 0;&#xA;    break;&#xA;  case 0x22:&#xA;    Serial.println(&quot;  Chip = DS1822&quot;);&#xA;    type_s = 0;&#xA;    break;&#xA;  default:&#xA;    Serial.println(&quot;Device is not a DS18x20 family device.&quot;);&#xA;    return;&#xA;  } &#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;  delay(1000);     // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  Serial.print(&quot;  Data = &quot;);&#xA;  Serial.print(present, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;    Serial.print(data[i], HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.print(&quot; CRC=&quot;);&#xA;  Serial.print(OneWire::crc8(data, 8), HEX);&#xA;  Serial.println();&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } &#xA;  else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;&#xA;  celsius = (float)raw / 16.0;&#xA;  fahrenheit = celsius * 1.8 + 32.0;&#xA;  Serial.print(&quot;  Temperature = &quot;);&#xA;  Serial.print(celsius);&#xA;  Serial.print(&quot; Celsius, &quot;);&#xA;  Serial.print(fahrenheit);&#xA;  Serial.println(&quot; Fahrenheit&quot;);&#xA;&#xA;  delta = celsius - lasttemp;                       //Create value to check how much temperature has changed&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;    previousMillis = currentMillis;&#xA;    if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {      //If temperature hasn't changed by +/- .05 turn led on.&#xA;      digitalWrite(A0, HIGH); &#xA;    }&#xA;  }&#xA;  if (delta &amp;gt;= 00.06) {                             //If temperature has changed by more than .1 turn LED off&#xA;    digitalWrite(A0, LOW);&#xA;  }&#xA;  if (delta &amp;lt;= -00.06) {&#xA;    digitalWrite(A0, LOW);                         // If temperature has changed by more than -.1 turn LED off&#xA;  }&#xA;&#xA;&#xA;    if (sdcurrentMillis - sdpreviousMillis &amp;gt;= sdinterval) {  //Write to SD card every 5 seconds.&#xA;    sdpreviousMillis = sdcurrentMillis;&#xA;    digitalWrite(A3, LOW);&#xA;    myFile = SD.open(&quot;Log.txt&quot;, FILE_WRITE);&#xA;    myFile.print(celsius);&#xA;    myFile.println(&quot; C &quot;);&#xA;    myFile.close();&#xA;    digitalWrite(A3, HIGH);&#xA;  }&#xA;&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(celsius);&#xA;  lcd.print(&quot; C &quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(fahrenheit);&#xA;  lcd.print(&quot; F &quot;);&#xA;  lasttemp = celsius;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;a href=&quot;https://www.dropbox.com/s/90a07yeegjvznjr/Temp%20sensor%20device%20new.txt?dl=0&quot; rel=&quot;nofollow&quot;&gt;this is the one&lt;/a&gt; I'm working on as I write this, with the illumination delay messing up:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;unsigned long owpreviousMillis = 0;&#xA;const long owinterval = 750;&#xA;//---------------------------------------------------------------------------------- One wire temperature sensor stuff&#xA;OneWire  ds(9);                 //Setting one wire bus pin&#xA;byte i;                  &#xA;byte present = 0;&#xA;byte type_s;&#xA;byte data[12];&#xA;byte addr[8];&#xA;float celsius, fahrenheit;      //Variables for celsius and farenheit conversions&#xA;long previousMillis = 0;&#xA;float lasttemp;                 //Variable for last temperature&#xA;float delta;                    //Variable for temperaturechange&#xA;const long interval = 1000;     //Check once every 1 second&#xA;&#xA;//---------------------------------------------------------------------------------- End of one wire temperature sensor stuff.&#xA;&#xA;LiquidCrystal lcd(6, 7, 5, 4, 3, 2); //Defining pins for the LCD&#xA;&#xA;//---------------------------------------------------------------------------------- SD card stuff&#xA;const int chipSelect = 10;              //Setting SD chip select pin (obviously)&#xA;File myFile;&#xA;long sdpreviousMillis = 0;&#xA;const long sdinterval = 5000;           //SD card write interval&#xA;&#xA;//-----------------------------------------------------------------------------------End of pre-setup&#xA;&#xA;&#xA;void setup(void) {&#xA;  pinMode(A2, INPUT);&#xA;  pinMode(A0, OUTPUT);    //Green LED for temperature stability indication&#xA;  pinMode(A3, OUTPUT);    //Red LED for sd card activity indication&#xA;  Serial.begin(115200);&#xA;//------------------------- Testing LCD and LED's, displaying version number and checking for SD card.&#xA;  lcd.begin(8, 2);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.print(&quot;STARTING&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;VER. 1.5&quot;);&#xA;  digitalWrite(A0, HIGH);&#xA;  digitalWrite(A3, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(A0, LOW);&#xA;  digitalWrite(A3, HIGH);&#xA;  lcd.clear();&#xA;&#xA;  if (!SD.begin(10)) {                    // Check for SD card&#xA;    digitalWrite(A3, LOW);&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;SD CHECK&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;  FAIL  &quot;);&#xA;    delay(1000);&#xA;    lcd.clear();&#xA;    digitalWrite(A3, HIGH);&#xA;  } else {&#xA;    delay(1000);&#xA;    digitalWrite(A3, LOW);&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;SD CHECK&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;  PASS  &quot;);&#xA;    delay(1000);&#xA;    lcd.clear();&#xA;    digitalWrite(A3, HIGH);&#xA;  }  &#xA;//----------------------------------- Setting up one wire temperature sensor.&#xA;  if ( !ds.search(addr)) {&#xA;    Serial.println(&quot;No more addresses.&quot;);&#xA;    Serial.println();&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;  Serial.print(&quot;ROM =&quot;);&#xA;  for( i = 0; i &amp;lt; 8; i++) {&#xA;    Serial.write(' ');&#xA;    Serial.print(addr[i], HEX);&#xA;  }&#xA;  if (OneWire::crc8(addr, 7) != addr[7]) {&#xA;    Serial.println(&quot;CRC is not valid!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println();&#xA;&#xA;  // the first ROM byte indicates which chip&#xA;  switch (addr[0]) {&#xA;  case 0x10:&#xA;    Serial.println(&quot;  Chip = DS18S20&quot;);  // or old DS1820&#xA;    type_s = 1;&#xA;    break;&#xA;  case 0x28:&#xA;    Serial.println(&quot;  Chip = DS18B20&quot;);&#xA;    type_s = 0;&#xA;    break;&#xA;  case 0x22:&#xA;    Serial.println(&quot;  Chip = DS1822&quot;);&#xA;    type_s = 0;&#xA;    break;&#xA;  default:&#xA;    Serial.println(&quot;Device is not a DS18x20 family device.&quot;);&#xA;    return;&#xA;  } &#xA;&#xA;}&#xA;//----------------------------------------------------------------------------- End of setup. &#xA;&#xA;void loop(void) {&#xA;&#xA;  unsigned long sdcurrentMillis = millis();&#xA;  unsigned long currentMillis = millis();&#xA;  unsigned long owcurrentMillis = millis();&#xA;&#xA;&#xA;  if (owcurrentMillis - owpreviousMillis &amp;gt;= owinterval) {&#xA;    owpreviousMillis = owcurrentMillis;&#xA;    ds.reset();&#xA;    ds.select(addr);&#xA;    ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;    }&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  Serial.print(&quot;  Data = &quot;);&#xA;  Serial.print(present, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;    Serial.print(data[i], HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.print(&quot; CRC=&quot;);&#xA;  Serial.print(OneWire::crc8(data, 8), HEX);&#xA;  Serial.println();&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } &#xA;  else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;&#xA;  celsius = (float)raw / 16.0;&#xA;  fahrenheit = celsius * 1.8 + 32.0;&#xA;  Serial.print(&quot;  Temperature = &quot;);&#xA;  Serial.print(celsius);&#xA;  Serial.print(&quot; Celsius, &quot;);&#xA;  Serial.print(fahrenheit);&#xA;  Serial.println(&quot; Fahrenheit&quot;);&#xA;&#xA;  delta = celsius - lasttemp;                       //Create value to check how much temperature has changed&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;    previousMillis = currentMillis;&#xA;    if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {      //If temperature hasn't changed by +/- .05 turn led on.&#xA;      digitalWrite(A0, HIGH); &#xA;    }&#xA;  }&#xA;  if (delta &amp;gt;= 00.06) {                             //If temperature has changed by more than .1 turn LED off&#xA;    digitalWrite(A0, LOW);&#xA;  }&#xA;  if (delta &amp;lt;= -00.06) {&#xA;    digitalWrite(A0, LOW);                         // If temperature has changed by more than -.1 turn LED off&#xA;  }&#xA;&#xA;&#xA;    if (sdcurrentMillis - sdpreviousMillis &amp;gt;= sdinterval) {  //Write to SD card every 5 seconds.&#xA;    sdpreviousMillis = sdcurrentMillis;&#xA;    digitalWrite(A3, LOW);&#xA;    myFile = SD.open(&quot;Log.txt&quot;, FILE_WRITE);&#xA;    myFile.print(celsius);&#xA;    myFile.println(&quot; C &quot;);&#xA;    myFile.close();&#xA;    digitalWrite(A3, HIGH);&#xA;  }&#xA;&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(celsius);&#xA;  lcd.print(&quot; C &quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(fahrenheit);&#xA;  lcd.print(&quot; F &quot;);&#xA;  lasttemp = celsius;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the post on the Arduino forum which sort of explains what I'm doing a bit better, if it does not make sense: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=388521.0&quot; rel=&quot;nofollow&quot;&gt;Best way to set up a button to toggle a second function? (millis issue now)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit/update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alright, so I think it has to do with how I structured that bit of the code, it seems like the arguments to turn the LED off weren't in the if statement which used the delay, so changed it to this, and unfortunately now it is on constantly, but I think I am on the right track. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;previousMillis = currentMillis;&#xA;if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {       //If temperature hasn't changed by +/- .05 turn led on.&#xA;  digitalWrite(A0, HIGH);&#xA;} else {&#xA;  if ((delta &amp;gt;= 00.06) &amp;amp;&amp;amp; (delta &amp;lt;= -00.06)) {&#xA;    digitalWrite(A0, LOW);&#xA;  }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like this should work but perhaps there's an issue with having two &lt;code&gt;if&lt;/code&gt; statements set up on top of each other like that. I also gave it a try like this, to no avail.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;previousMillis = currentMillis;&#xA;if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {       //If temperature hasn't changed by +/- .05 turn led on.&#xA;  digitalWrite(A0, HIGH);&#xA;} else {&#xA;  if (delta &amp;gt;= 00.06){&#xA;    digitalWrite(A0, LOW);&#xA;  } else {&#xA;  if (delta &amp;lt;= -00.06){&#xA;   digitalWrite(A0, LOW);&#xA;  }&#xA; }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit/update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quick clarification, I managed to get rid of the delay and use millis instead but it introduced an issue with the LED which indicates stable temperature not working (being lit most of the time, and then flashing off/on fairly quickly as the temperature changes, instead of remaining off until it stabilizes again). It seems to be ignoring the delay I have it waiting for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, after going through it a lot, it seems like this is how I need it set up. It checks if the interval has been reached, if so, it checks if the temperature has changed less than &lt;em&gt;x&lt;/em&gt; amount, if so it lights the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the temperature has changed more than that, it checks if it exceeds &lt;em&gt;y&lt;/em&gt; amount, and if so turns the light off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried reversing these and it has had no effect, it just seems like the boolean arguments aren't working and I don't know why, but at least the delay issue is solved.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentMillis - previousMillis &amp;gt;= interval) {  //If it has been 20 seconds, check to turn LED on&#xA;previousMillis = currentMillis;&#xA;if ((delta &amp;lt; 00.03) &amp;amp;&amp;amp; (delta &amp;gt; -00.03)) {       //If temperature hasn't changed by +/- .05 turn led on.&#xA;  digitalWrite(A0, HIGH);&#xA;} else if ((delta &amp;gt;= 00.06) || (delta &amp;lt;= -00.06)) {&#xA;    digitalWrite(A0, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19572" LastEditorUserId="6936" LastEditDate="2016-03-26T03:03:56.280" LastActivityDate="2016-03-26T03:03:56.280" Title="Is it possible to replace this delay with millis()? (And issue with other millis loop)" Tags="|millis|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22205" PostTypeId="2" ParentId="22171" CreationDate="2016-03-24T11:34:29.373" Score="2" Body="&lt;p&gt;I went through your program and found a few bugs you may want to fix. I&#xA;think only one of these (wastage of RAM) is really related to your&#xA;problem, but anyway, here it goes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fist, there are two issues with &lt;code&gt;LPF()&lt;/code&gt;. The description states that&#xA;this is a rolling average low-pass filter. This is erroneous: a rolling&#xA;average would take a &lt;em&gt;single reading&lt;/em&gt;, then report the average of the&#xA;last &lt;em&gt;n&lt;/em&gt; readings. This function, in contrast, takes &lt;em&gt;n&lt;/em&gt; readings and&#xA;reports their average. This makes a big difference: a rolling average&#xA;would need to store the last &lt;em&gt;n&lt;/em&gt; values in static memory, while your&#xA;function does this for no good reason. You are just wasting&#xA;300&amp;nbsp;bytes of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a reimplementation of &lt;code&gt;LPF()&lt;/code&gt; that does the same thing as yours&#xA;without wasting RAM. I changed its name to be more consistent with it's&#xA;real purpose:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Take 'count' temperature readings from 'pin' and return their average.&#xA; * Returns NaN (not a number) if too many readings where in error.&#xA; */&#xA;float getAvgTemp(int pin, int count)&#xA;{&#xA;  const int MAXERRORS = 5; // max number of errors that can occur&#xA;  float temp;              // current temperature reading&#xA;  float tempSum = 0;       // sum of temperatures&#xA;  int errCounter = 0;      // number of erroneous readings&#xA;&#xA;  for (int i = 0; i &amp;lt; count; i++) {&#xA;&#xA;    // Try to get a valid reading.&#xA;    do {&#xA;      temp = getTempFloat(pin);&#xA;      if (isnan(temp))&#xA;        errCounter++;&#xA;      delay(25); // allow the ADC to settle&#xA;    } while (isnan(temp) &amp;amp;&amp;amp; errCounter &amp;lt;= MAXERRORS);&#xA;&#xA;    // Too many errors: return an error.&#xA;    if (errCounter &amp;gt; MAXERRORS)&#xA;      return NAN;&#xA;&#xA;    tempSum += temp;&#xA;  }&#xA;&#xA;  return tempSum / count;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I use NaN (not a number) as an error indicator, as it is&#xA;semantically clearer than a random out-of-range value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are also a few errors in &lt;code&gt;getTempFloat()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;pgm_read_word(LUT_Therm[constLUTArraySize-1])&lt;/code&gt; and&#xA;&lt;code&gt;pgm_read_word(LUT_Therm[i])&lt;/code&gt; will not work: you have to pass&#xA;&lt;code&gt;pgm_read_word()&lt;/code&gt; the &lt;em&gt;address&lt;/em&gt; where to read.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;float(i/10)&lt;/code&gt; does not do what you want: it computes &lt;code&gt;i/10&lt;/code&gt; as an&#xA;integer division (i.e. discarding the fractional part), and &lt;em&gt;then&lt;/em&gt; it&#xA;converts the result to a float. If you want a floating point division,&#xA;you should make sure that at least one of the arguments is a float.&#xA;The usual idiom is &lt;code&gt;i/10.0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is a version of &lt;code&gt;getTempFloat()&lt;/code&gt; with these problems fixed, and&#xA;also somewhat simplified:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;float getTempFloat(int pin)&#xA;{&#xA;  int i, lutval, prev_lutval;&#xA;&#xA;  // Take an analog reading.&#xA;  analogRead(pin);  // dummy reading to settle the MUX&#xA;  delay(10);&#xA;  int adc = analogRead(pin);&#xA;  Serial.print(F(&quot;ADC: &quot;));&#xA;  Serial.println(adc);&#xA;&#xA;  // Find i such that adc lies between LUT[i-1] and LUT[i].&#xA;  for (i = 0; i &amp;lt; constLUTArraySize; i++) {&#xA;    prev_lutval = lutval;&#xA;    lutval = pgm_read_word(&amp;amp;LUT_Therm[i]);&#xA;    if (lutval &amp;gt;= adc) break;&#xA;  }&#xA;&#xA;  // Special case: adc == LUT[0].&#xA;  if (i == 0 &amp;amp;&amp;amp; adc == lutval)&#xA;    return 13.0;&#xA;&#xA;  // Report an error if out of range.&#xA;  if (i == 0 || i == constLUTArraySize)&#xA;    return NAN;&#xA;&#xA;  // Return interpolated temperature.&#xA;  float fraction = float(adc - prev_lutval) / (lutval - prev_lutval);&#xA;  return 13.0 + (i-1 + fraction) / 10.0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Addendum&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I have noticed a few more problems and inconsistencies with your&#xA;program.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Powering the thermistor from the internal reference&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt;, you write&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;analogReference(INTERNAL); //use the interval votlage of 1.1V for the&#xA;  ADC resolution&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and then, in a comment further down you have the schematic&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+Vref---[Thermistor]---+--[1.8K]---GND&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This suggests you are powering the voltage divider from the internal&#xA;voltage reference of the MCU. You should not do that, as the datasheet&#xA;states: “Note that V&lt;sub&gt;REF&lt;/sub&gt; is a high impedance source, and only&#xA;a capacitive load should be connected in a system.”&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Relationship between ADC reading and thermistor resistance&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In the same comment as above, you wrote:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ADC = 1023*10000/(Rtherm+10000)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Actually, the factor is 1024, not 1023. Again, see the datasheet. And&#xA;the number &lt;code&gt;10000&lt;/code&gt; should be &lt;code&gt;1800&lt;/code&gt;, i.e. the resistance you have put&#xA;between the ADC input and GND. I understand that you may have simply&#xA;changed the value and forgotten to update one of the comments. But you&#xA;should consider a misleading comment as a bug, especially if it's not&#xA;consistent with the actual code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this kind of measurement, you get the best precision if the pulldown&#xA;resistor has a value close to the resistance of the thermistor. The&#xA;comment at the beginning of the program says your thermistor has&#xA;10&amp;nbsp;kΩ @&amp;nbsp;25°C. This means that, if you are mostly interested in&#xA;the range around 25°C, a 10&amp;nbsp;kΩ pulldown is better than 1.8&amp;nbsp;kΩ.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Relationship between array index and temperature&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;The comment before the LUT says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The array index starts at zero, which corresponds to a temperature of&#xA;  +6^C&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then, the very first line of the LUT has the comment&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;//7^C to 7.9^C&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And later on, the implementation of &lt;code&gt;getTempFloat()&lt;/code&gt; assumes&#xA;index 0 means 13°C. You should sort this out and make everything&#xA;consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, your LUT values go all the way up to 1023. A reading of 1023 would&#xA;mean the ADC voltage is higher than 1022.5/1024×V&lt;sub&gt;REF&lt;/sub&gt;. Which&#xA;in turn would imply the thermistor has a resistance lower than&#xA;14.6&amp;nbsp;Ω (assuming a 10&amp;nbsp;kΩ pulldown). I find this dubious.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Removal of the LUT&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Since your program is meant to run very slowly (&lt;code&gt;constDelay = 3000&lt;/code&gt;),&#xA;you can afford doing complex computations in it. You can get the same&#xA;precision with a way smaller LUT if you use a higher order&#xA;interpolation. For a function sampled at constant steps, the&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Interpolation_on_the_unit_interval_without_exact_derivatives&quot; rel=&quot;nofollow&quot;&gt;Catmull–Rom&#xA;spline&lt;/a&gt;&#xA;is easy to implement and is way better than linear interpolation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can remove the LUT altogether and use an analytical expression&#xA;instead. If you derived the LUT from such an expression, why not use it&#xA;in the program? If the LUT derives from experimental data, you can try&#xA;to do an empirical fit, i.e. an arbitrary function that closely fits the&#xA;data. The most obvious (though maybe not the best) empirical function&#xA;would be a polynomial. Below is an example of such a function that&#xA;reproduces you LUT with good accuracy using a 6th degree polynomial. It&#xA;assumes the first LUT entry is for a temperature of 7°C:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;float getTempFloat(int pin)&#xA;{&#xA;    const float T0 = 7;   // temperature at beginning of range&#xA;    int adc = analogRead(pin);&#xA;    float x = (adc-223.) / (1023.-223.) * 2 - 1;  // scale to [-1:1]&#xA;    if (x &amp;lt; -1 || x &amp;gt; 1) return NAN;              // out of range&#xA;    float y = 1.474 - x*(0.533 - x*(0.732 - x*0.458));&#xA;    return T0 + 26.107 + x*(19.287 - x*(3.596 - x*y));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actually this may be even more accurate than your LUT-based function, as&#xA;that LUT is made of integer values whereas the calibration curve should&#xA;obviously be continuous.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-03-24T16:44:48.340" LastActivityDate="2016-03-24T16:44:48.340" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22206" PostTypeId="2" ParentId="22204" CreationDate="2016-03-24T12:11:54.003" Score="2" Body="&lt;p&gt;Currently, your algorithm for reading the temperature in &lt;code&gt;loop()&lt;/code&gt; looks&#xA;like:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;request_temperature_conversion();&#xA;delay(1000);&#xA;float temp = read_temperature();&#xA;report_temperature_to_user(temp);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you take care to send the first request in &lt;code&gt;setup()&lt;/code&gt;, then you can&#xA;roll these pieces around so that your &lt;code&gt;loop()&lt;/code&gt; code looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;delay(1000);&#xA;float temp = read_temperature();&#xA;report_temperature_to_user(temp);&#xA;request_temperature_conversion();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that's the trick: you send the new request in the same loop&#xA;iteration. Once you do that, it becomes quite simple to remove the delay&#xA;and use &lt;code&gt;millis()&lt;/code&gt; instead. Your compete loop code could then look like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  uint32_t now = millis();&#xA;&#xA;  if (now - last_temp_read &amp;gt;= temp_read_interval) {&#xA;    float temp = read_temperature();&#xA;    report_temperature_to_user(temp);&#xA;    request_temperature_conversion();  // make request now, will read next time&#xA;    last_temp_read = now;&#xA;  }&#xA;&#xA;  if (now - last_led_update &amp;gt;= led_update_interval) {&#xA;    update_led_display();&#xA;    last_led_update = now;&#xA;  }&#xA;&#xA;  if (now - last_SD_card_write &amp;gt;= SD_card_write_interval) {&#xA;    write_data_to_log_file();&#xA;    last_SD_card_write = now;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-24T12:11:54.003" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22210" PostTypeId="1" AcceptedAnswerId="22218" CreationDate="2016-03-24T17:13:58.773" Score="0" ViewCount="649" Body="&lt;p&gt;I am a little confused on how exactly VirtualWire's &quot;send&quot; function works. After looking at the code, the process I gathered is the following.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In the Arduino IDE, call &lt;code&gt;vw_send()&lt;/code&gt; with the right parameters.&lt;/li&gt;&#xA;&lt;li&gt;Inside this method, it will start to encode the message and create the packet.&lt;/li&gt;&#xA;&lt;li&gt;Then before the function returns, it calls &lt;code&gt;vw_tx_start()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Inside that function, it enables the transmitter hardware and sets the variable &quot;vw_tx_enabled&quot; equal to true. Then this function returns, followed by the immediate return of &lt;code&gt;vw_send()&lt;/code&gt;. So there is no where in this flow where the message is actually being sent. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;However, the actual transmission of the message happens inside &lt;code&gt;vw_Int_Handler()&lt;/code&gt;. But this function is never called in &lt;code&gt;vw_send()&lt;/code&gt; or &lt;code&gt;vw_tx_start()&lt;/code&gt;. So the only way this could be happening is if there was some sort of multi-threading correct? Because by setting vw_tx_enabled to true, the transmission process would begin inside vw_Int_Handler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain/clarify this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, this library uses digitalWrite to transmit the bits. Wouldn't it just be faster to toggle the bits at the registry level? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, in VirtualWire, they send a 36 bit preamble, I assume this is for synchorinzation purposes. So if I want to send 128 byte packet length, how much of a preamble should I use? I believe the reason for VirtualWire only transmitting 27 byte packet length is because the 36 bit preamble will only keep the data synchronized for that long. So is there a certain formula used to determine the preamble size?&lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2016-03-24T18:33:58.287" LastActivityDate="2023-05-13T18:46:42.127" Title="VirtualWire send function" Tags="|library|communication|softwareserial|virtualwire|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22211" PostTypeId="1" AcceptedAnswerId="22240" CreationDate="2016-03-24T18:36:40.800" Score="3" ViewCount="5194" Body="&lt;p&gt;I have a header file called Rhino.h with class Rhino. I want to pass RX and TX pin numbers to this object class, and with this, define a SoftwareSerial object to be used inside the Rhino class. The code in my header file looks like this (there are more number of functions like gotoPos() which I have omitted for brevity purpose):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;&#xA;class Rhino&#xA;{&#xA;public:&#xA;    Rhino(int rx,int tx):serial(rx,tx){}&#xA;&#xA;    void gotoPos(int pos)&#xA;    {&#xA;        serial.write(pos);&#xA;    }&#xA;private:&#xA;    SoftwareSerial serial;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my Arduino code looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Rhino.h&amp;gt;&#xA;Rhino motor1(9,10);&#xA;void setup()&#xA;{&#xA;    motor1.gotoPos(10);&#xA;}&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this as error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.0.6 (Windows NT (unknown)), Board: &quot;Arduino Uno&quot;&#xA;S:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IS:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino -IS:\Program Files (x86)\Arduino\hardware\arduino\variants\standard -IS:\Program Files (x86)\Arduino\libraries\Rhino C:\Users\Samvrit\AppData\Local\Temp\build2516495983752907071.tmp\Test2.cpp -o C:\Users\Samvrit\AppData\Local\Temp\build2516495983752907071.tmp\Test2.cpp.o &#xA;&#xA;In file included from Test2.ino:6:&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:740: error: 'SoftwareSerial' does not name a type&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In constructor 'Rhino::Rhino(int, int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:16: error: class 'Rhino' does not have any field named 'serial'&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::init()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:21: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::reset()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:30: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::autoCalibrate()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:37: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::sendCmd(String)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:46: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::sendCmd(char*)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:58: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::rotate(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:76: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::stopMotor()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:88: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoPos(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:103: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoAngleDeg(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:123: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoAngleRad(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:143: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoAngleDegC(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:164: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoAngleRadC(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:185: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoRel(long int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:218: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoRelDeg(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:253: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::gotoRelRad(float)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:289: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setSFGain(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:306: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setP(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:322: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setI(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:338: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setD(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:355: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setSpeed(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:372: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setI2CAddr(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:389: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'void Rhino::setPos(int)':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:406: warning: unused variable 'curr_pos'&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:415: warning: unused variable 'curr_pos'&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:426: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getPos()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:474: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'float Rhino::getAngleDeg()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:501: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'float Rhino::getAngleRad()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:528: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getSpeed()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:555: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getRotSpeed()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:582: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getI2CAddr()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:609: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getSFGain()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:636: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getP()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:663: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getI()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:690: error: 'serial' was not declared in this scope&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h: In member function 'int Rhino::getD()':&#xA;S:\Program Files (x86)\Arduino\libraries\Rhino/Rhino.h:717: error: 'serial' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19578" LastActivityDate="2016-03-25T00:52:36.367" Title="How to define a SoftwareSerial object inside a class?" Tags="|c++|motor|library|softwareserial|uart|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22212" PostTypeId="1" AcceptedAnswerId="22237" CreationDate="2016-03-24T18:47:56.367" Score="14" ViewCount="52618" Body="&lt;p&gt;The documentation for &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;attachInterrupt()&lt;/code&gt;&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... &lt;code&gt;millis()&lt;/code&gt; relies on interrupts to count, so it will never increment inside an ISR. Since &lt;code&gt;delay()&lt;/code&gt; requires interrupts to work, it will not work if called inside an ISR. &lt;code&gt;micros()&lt;/code&gt; works initially, but will start behaving erratically after 1-2 ms. ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How does &lt;code&gt;micros()&lt;/code&gt; differ from &lt;code&gt;millis()&lt;/code&gt; (except of course for their precision)? Does the above warning mean that using &lt;code&gt;micros()&lt;/code&gt; inside an interrupt routine is always a bad idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context - I want to &lt;a href=&quot;https://arduino.stackexchange.com/q/22120/19445&quot;&gt;measure low pulse occupancy&lt;/a&gt;, so I need to trigger my routine when my input signal changes and record the current time.&lt;/p&gt;&#xA;" OwnerUserId="19445" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2022-11-11T16:07:09.037" Title="Using millis() and micros() inside an interrupt routine" Tags="|interrupt|timers|millis|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22213" PostTypeId="2" ParentId="22211" CreationDate="2016-03-24T19:18:24.683" Score="0" Body="&lt;p&gt;You need to import the SoftwareSerial library into your Rhino.h file, since you are using that class in your header file. Perhaps you are also in need of a forward declaration. Inside your Rhino.h file, include SoftwareSerial library, and then above &lt;code&gt;class Rhino&lt;/code&gt;, type &lt;code&gt;class SoftwareSerial;&lt;/code&gt;. This effectively lets the compiler know that Software Serial is being used. More information on forward declarations can be found &lt;a href=&quot;https://stackoverflow.com/questions/4757565/c-forward-declaration&quot;&gt;here.&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modified Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;SoftwareSerial.h&quot;&#xA;&#xA;class SoftwareSerial; //this might be unnecessary, but doesn't hurt to have it.&#xA;class Rhino&#xA;{&#xA;public:&#xA;Rhino(int rx,int tx):serial(rx,tx){}&#xA;&#xA;void gotoPos(int pos)&#xA;{&#xA;    serial.write(pos);&#xA;}&#xA;private:&#xA;    SoftwareSerial serial;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-24T19:23:43.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22214" PostTypeId="2" ParentId="22212" CreationDate="2016-03-24T19:26:00.807" Score="6" Body="&lt;p&gt;The quoted phrase is &lt;em&gt;not&lt;/em&gt; a warning, it is merely a statement about how things work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's nothing intrinsically wrong with using &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; within a properly-written interrupt routine.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, doing anything at all within an improperly-written interrupt routine is by definition wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An interrupt routine that takes more than a few microseconds to do its job is, in all likelihood, improperly written.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short:  A properly-written interrupt routine will not cause or encounter issues with &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt;  Regarding “why micros() &quot;starts behaving erratically&quot;”, as explained in an “&lt;a href=&quot;https://ucexperiment.wordpress.com/2012/03/17/examination-of-the-arduino-micros-function/&quot; rel=&quot;noreferrer&quot;&gt;examination of the Arduino micros function &lt;/a&gt;” webpage,  &lt;code&gt;micros()&lt;/code&gt; code on an ordinary Uno is functionally equivalent to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long micros() {&#xA;  return((timer0_overflow_count &amp;lt;&amp;lt; 8) + TCNT0)*(64/16);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This returns a four-byte unsigned long comprised of the three lowest bytes from &lt;code&gt;timer0_overflow_count&lt;/code&gt; and one byte from the timer-0 count register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;timer0_overflow_count&lt;/code&gt; is incremented about once per millisecond by the &lt;code&gt;TIMER0_OVF_vect&lt;/code&gt; interrupt handler, as explained in an &lt;a href=&quot;https://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/&quot; rel=&quot;noreferrer&quot;&gt;examination of the arduino millis function &lt;/a&gt; webpage.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before an interrupt handler begins, AVR hardware disables interrupts.  If (for example) an interrupt handler were to run for five milliseconds with interrupts still disabled, at least four timer 0 overflows would be missed.  [Interrupts written in C code in the Arduino system are not reentrant (capable of correctly handling multiple overlapping executions within the same handler) but one could write a reentrant assembly language handler that reenables interrupts before it begins a time-consuming process.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, timer overflows don't “stack up”; whenever an overflow occurs before the interrupt from the previous overflow has been handled, the &lt;code&gt;millis()&lt;/code&gt; counter loses a millisecond, and the discrepancy in &lt;code&gt;timer0_overflow_count&lt;/code&gt; in turn makes &lt;code&gt;micros()&lt;/code&gt; wrong by a millisecond too.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding “shorter than 500 μs” as an upper time limit for interrupt processing,  “to prevent blocking the timer interrupt for too long”, you could go up to just under 1024 μs (eg 1020 μs) and &lt;code&gt;millis()&lt;/code&gt; still would work, most of the time.  However, I regard an interrupt handler that takes more than 5 μs as a sluggard, more than 10 μs as slothful, more than 20 μs as snail-like.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-03-24T20:13:33.440" LastActivityDate="2016-03-24T20:13:33.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22215" PostTypeId="2" ParentId="22211" CreationDate="2016-03-24T19:27:17.190" Score="6" Body="&lt;p&gt;Personally I wouldn't go down this route. Instead I would pass a &lt;code&gt;Stream&lt;/code&gt; object (as a pointer or a reference) to the constructor and use that. Then it is up to your sketch to define what that &lt;code&gt;Stream&lt;/code&gt; object is and initialize it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way if you want to use the same class on a hardware UART instead of a &lt;code&gt;SoftwareSerial&lt;/code&gt; you just change the sketch, not the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would initialize as something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(6, 7);&#xA;Rhino myRhino(mySerial);&#xA;&#xA;void setup() {&#xA;    mySerial.begin(9600);&#xA;    myRhino.gotoPos(34);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your Rhino class would look something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Rhino {&#xA;    private:&#xA;        Stream *_dev;&#xA;&#xA;    public:&#xA;        Rhino(Stream *dev) : _dev(dev) {}&#xA;        Rhino(Stream &amp;amp;dev) : _dev(&amp;amp;dev) {}&#xA;        void gotoPos(int pos);&#xA;};&#xA;&#xA;void Rhino::gotoPos(int pos) {&#xA;    _dev-&amp;gt;write(pos);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The double constructors, one with a pointer and one with a reference, allow the simplicity of passing an object as in the example, or as a pointer, which could be done with the &lt;code&gt;new&lt;/code&gt; operator all in one step. I like the way shown in the example though since it is nice and clean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, because you now have a &lt;em&gt;pointer&lt;/em&gt; to your stream object, you need to use the pointer dereference operator instead of the normal &lt;code&gt;.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_dev-&amp;gt;write(pos);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Changing to a hardware UART is then as simple as, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Rhino myRhino(Serial);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Heck, you could even send it through the internet since an Ethernet or WiFi &lt;code&gt;Client&lt;/code&gt; is also a &lt;code&gt;Stream&lt;/code&gt; object.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-24T19:27:17.190" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22216" PostTypeId="2" ParentId="22212" CreationDate="2016-03-24T19:40:18.320" Score="9" Body="&lt;p&gt;It is not &lt;em&gt;wrong&lt;/em&gt; to use &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; within an interrupt routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It &lt;em&gt;is&lt;/em&gt; wrong to use them incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main thing here is that while you are in an interrupt routine &quot;the clock isn't ticking&quot;.  &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt; won't change (well, &lt;code&gt;micros()&lt;/code&gt; will initially, but once it goes past that magic millisecond point where a millisecond tick is required it all falls apart.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can certainly call on &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; to find out the current time within your ISR, but don't expect that time to change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is that lack of change in the time that is being warned about in the quote you provide.  &lt;code&gt;delay()&lt;/code&gt; relies on &lt;code&gt;millis()&lt;/code&gt; changing to know how much time has passed. Since it doesn't change &lt;code&gt;delay()&lt;/code&gt; can never finish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So essentially &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt; will tell you the time &lt;em&gt;when your ISR was called&lt;/em&gt; no matter when in your ISR you use them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-24T19:40:18.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22218" PostTypeId="2" ParentId="22210" CreationDate="2016-03-24T20:10:14.897" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However, the actual transmission of the message happens inside vw_Int_Handler(). But this function is never called in vw_send() or vw_tx_start(). So the only way this could be happening is if there was some sort of multi-threading correct? Because by setting vw_tx_enabled to true, the transmission process would begin inside vw_Int_Handler.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;vw_Int_Handler&lt;/code&gt; function is called from the interrupt handler of one of the timer modules in the chip. Yes, you could say it was some form of multi-threading in that it happens interleaved with the main processing of your sketch.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Moreover, this library uses digitalWrite to transmit the bits. Wouldn't it just be faster to toggle the bits at the registry level?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes it would, but it would be less portable.  VirtualWire has been written to work on a wide range of chips, and doing low-level port access would make the code about 1000x more complex, having to include special code for each and every chip it runs on.  Easier (though less efficient) to just use &lt;code&gt;digitalWrite()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Lastly, in VirtualWire, they send a 36 bit preamble, I assume this is for synchorinzation purposes. So if I want to send 128 byte packet length, how much of a preamble should I use? I believe the reason for VirtualWire only transmitting 27 byte packet length is because the 36 bit preamble will only keep the data synchronized for that long. So is there a certain formula used to determine the preamble size?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;VirtualWire uses a coding system called 4b/6b (actually a sub-set of &lt;a href=&quot;https://en.wikipedia.org/wiki/8b/10b_encoding#5b.2F6b&quot; rel=&quot;nofollow&quot;&gt;5b/6b coding&lt;/a&gt;). In that system it takes 6 &lt;em&gt;symbols&lt;/em&gt; to transmit 4 &lt;em&gt;bits&lt;/em&gt;. It is a way of encoding the clock into the signal in a reasonably efficient manner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The encoding system means that there can never be 36 alternating 1/0 bits in a message. That unique stream is used as the synchronisation because it can't be confused with anything else.  From then on it's just data encoded as 4b/6b. The limit on how much data can be transmitted in one packet is a purely arbitrary value. Since this is a low-speed protocol to low-power devices it is expected that they will have limited RAM, and so limited space to receive data. So small packets are the default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The numbers in use, incidentally, have been chosen because they fit into the 4b/6b coding scheme quite nicely.  For instance 36 symbols of preamble is equivalent to 24 bits of data. The packet size is 30 bytes, three bytes of which are used for control information (checksum, byte count, etc), leaving 27 bytes of actual payload.  30 bytes is 240 bits, which is, in 4b/6b, 360 symbols. 360 symbols could be packed cleanly into 45 bytes for simple transmission (pre-encoding from binary to 4b/6b before transmission).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other values won't fit quite so neatly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-24T20:10:14.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22219" PostTypeId="1" CreationDate="2016-03-24T20:59:14.230" Score="1" ViewCount="9073" Body="&lt;p&gt;Using two boards of similar architecture I would like to send the contents of a struct from the sending board to the receiving board. I am using UART to transfer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan was to populate an array with the starting structs data. Transfer that, than un-package the array onto the receiving boards struct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure this is a possible option. Unpacking the array seems sort of rigid, as I would be assigning each struct variable to the array index. It might work but I'm not really convinced I should do it this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what my sending sketch looks like.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Send:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct NWK_DataReq_t&#xA;{&#xA; uint8_t      state;&#xA; uint8_t      options;&#xA;} NWK_DataReq_t;&#xA;&#xA;//Instance struct&#xA;NWK_DataReq_t dataRequest;&#xA;&#xA;void setup() &#xA;{&#xA;  //Give it some values&#xA;  dataRequest.state = 2;&#xA;  dataRequest.options = 4;&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{  &#xA;  //set variable array to struct length&#xA;  uint8_t payload[sizeof(dataRequest)];&#xA;&#xA;  //copy struct to variable array&#xA;  memcpy(payload,&amp;amp;dataRequest,sizeof(dataRequest));&#xA;&#xA;  //send each item of struct, now contained in payload array&#xA;  for(int i=0;i &amp;lt; sizeof(payload);i++)&#xA;  {&#xA;    //Serial.print(i);&#xA;    //Serial.print(&quot;:&quot;);&#xA;    Serial.println(payload[i]);&#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receive:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct NWK_DataReq_t&#xA;{&#xA; uint8_t      state;&#xA; uint8_t      options;&#xA;} NWK_DataReq_t;&#xA;&#xA;//Instance struct&#xA;NWK_DataReq_t dataRequest;&#xA;uint8_t incomingPayload[sizeof(dataRequest)];&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.print(&quot;Recieve started&quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;  if (Serial.available())&#xA;  {&#xA;    //add incoming data to array&#xA;    for(int i=0;i&amp;lt;sizeof(dataRequest);i++)&#xA;    {&#xA;      uint8_t incomingByte = Serial.read();&#xA;      incomingPayload[i] = incomingByte;&#xA;    }&#xA;  }&#xA;&#xA;  //set array values to structs&#xA;  for (int i= 0;i &amp;lt; sizeof(dataRequest);i++)&#xA;  {&#xA;    structIndexPosition = incomingPayload[i];&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;structIndexPosition is not attached as I wasn't sure how I might index the struct, or if this is an okay approach.&lt;/p&gt;&#xA;" OwnerUserId="19328" LastEditorUserId="19328" LastEditDate="2016-03-24T21:21:03.057" LastActivityDate="2020-12-05T11:40:56.363" Title="Transfer a struct's data to an external struct via serial?" Tags="|c++|uart|struct|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22220" PostTypeId="5" CreationDate="2016-03-24T21:05:31.977" Score="0" Body="&lt;p&gt;The Intel® Edison module is a SoC (System on Chip) that includes an Intel® Atom™ 500MHz dual-core, dual-threaded CPU and an Intel® Quark™ 100MHz microcontroller.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:49:19.283" LastActivityDate="2016-03-25T16:49:19.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22221" PostTypeId="4" CreationDate="2016-03-24T21:05:31.977" Score="0" Body="refers to the Edison Arduino module." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:36:23.247" LastActivityDate="2016-04-12T07:36:23.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22222" PostTypeId="5" CreationDate="2016-03-24T21:07:01.000" Score="0" Body="&lt;p&gt;Use this tag when asking a question related to the use of a piezoelectric component. &lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-08-25T02:14:18.123" LastActivityDate="2016-08-25T02:14:18.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22223" PostTypeId="4" CreationDate="2016-03-24T21:07:01.000" Score="0" Body="refers to the prefix of Piezoelectricity." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:49:01.363" LastActivityDate="2016-03-25T16:49:01.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22225" PostTypeId="5" CreationDate="2016-03-24T21:07:40.597" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-24T21:07:40.597" LastActivityDate="2016-03-24T21:07:40.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22226" PostTypeId="4" CreationDate="2016-03-24T21:07:40.597" Score="0" Body="commonly refers to the upload procedure." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:49:11.753" LastActivityDate="2016-03-25T16:49:11.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22227" PostTypeId="5" CreationDate="2016-03-24T21:08:54.090" Score="0" Body="&lt;p&gt;A terminal or command-line interface is a text-only interface for interacting with an operating system or a piece of software. A user typically types commands into the terminal to perform specific tasks.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:48:55.393" LastActivityDate="2016-03-25T16:48:55.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22228" PostTypeId="4" CreationDate="2016-03-24T21:08:54.090" Score="0" Body="A terminal or command-line interface is a text-only interface for interacting with an operating system or a piece of software." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:49:04.580" LastActivityDate="2016-03-25T16:49:04.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22229" PostTypeId="5" CreationDate="2016-03-24T21:10:31.580" Score="0" Body="&lt;p&gt;A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:49:15.440" LastActivityDate="2016-03-25T16:49:15.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22230" PostTypeId="4" CreationDate="2016-03-24T21:10:31.580" Score="0" Body="It refers to a seven-segment display (SSD) is a form of electronic display device for displaying decimal numerals." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T16:48:52.270" LastActivityDate="2016-03-25T16:48:52.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22231" PostTypeId="1" CreationDate="2016-03-24T21:17:01.877" Score="1" ViewCount="75" Body="&lt;p&gt;For a class assignment I have been tasked with zeroing a Vernier force probe by typing a command into the serial monitor. I am having trouble writing the code for this algorithim. I was hoping to give the monitor the command and have it save the analogread as a variable which I can later subtract from future reads. Does anyone know if I can save the analogread value without it being updated in a loop? If, so how? &lt;/p&gt;&#xA;" OwnerUserId="19582" LastActivityDate="2016-03-25T03:38:34.220" Title="Zeroing a Vernier force probe" Tags="|arduino-uno|documentation|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22232" PostTypeId="2" ParentId="22219" CreationDate="2016-03-24T21:20:34.230" Score="0" Body="&lt;p&gt;&lt;em&gt;Why go over the bridge for water?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to access the data in the struct as a character pointer. No need to transfer to a buffer etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  ...&#xA;  ...&#xA;  const char* dp = (const char*) &amp;amp;dataRequest;&#xA;  for (int i = 0; i &amp;lt; sizeof(dataRequest); i++) Serial.print(*dp++);&#xA;  Serial.println();&#xA;  delay(1000);&#xA;  ...&#xA;  ...&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might be hard to extrapolate how to receive this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  if (Serial.available() &amp;gt; sizeof(dataRequest)) {&#xA;     char* dp = (char*) &amp;amp;dataRequest;&#xA;     for (int i = 0; i &amp;lt; sizeof(dataRequest); i++) *dp++ = Serial.read(); &#xA;     Serial.read();&#xA;     ...&#xA;     ...&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Serial.println() and extra Serial.read() could be replaced by a &quot;frame marker&quot; and/or a check-sum. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-03-24T21:43:36.990" LastActivityDate="2016-03-24T21:43:36.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22233" PostTypeId="2" ParentId="21514" CreationDate="2016-03-24T21:30:08.483" Score="0" Body="&lt;p&gt;It seems the 101 only supports Bluetooth LE stack and not the full Bluetooth stack including RFCOMM, virtual com port. This means there is no proper supported way, but it seems people are working on workarounds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=370123.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=370123.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10513" LastActivityDate="2016-03-24T21:30:08.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22235" PostTypeId="2" ParentId="22219" CreationDate="2016-03-24T22:24:40.570" Score="1" Body="&lt;p&gt;I think you are over-complicating it to send two bytes. Just send them as straight ASCII with a newline after, and decode it on the receiving end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42,87&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However if the question was just an example of something much more complex, then you may need to do more work. You need to have the receiving end know when a packet of data starts, and ends, and preferably have some validation that it wasn't corrupted.  If you want to pursue that idea, see my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11428&quot; rel=&quot;nofollow&quot;&gt;thread about sending data via RS485&lt;/a&gt; which has a library that does that sort of thing.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-24T22:24:40.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22237" PostTypeId="2" ParentId="22212" CreationDate="2016-03-24T22:41:29.587" Score="20" Body="&lt;p&gt;The other answers are very good, but I want to elaborate on how &lt;code&gt;micros()&lt;/code&gt; works. It &lt;em&gt;always&lt;/em&gt; reads the current hardware timer (possibly &lt;code&gt;TCNT0&lt;/code&gt;) which is constantly being updated by the hardware (in fact, every 4 µs because of the prescaler of 64). It then adds in the Timer 0 overflow count, which is updated by a timer overflow interrupt (multiplied by 256).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus, even inside an ISR, you can rely on &lt;code&gt;micros()&lt;/code&gt; updating. However &lt;em&gt;if you wait too long&lt;/em&gt; then you miss the overflow update, and then the result returned will go down (i.e you will get 253, 254, 255, 0, 1, 2, 3 etc.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is &lt;code&gt;micros()&lt;/code&gt; - slightly simplified to remove defines for other processors:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long micros() {&#xA;    unsigned long m;&#xA;    uint8_t oldSREG = SREG, t;&#xA;    cli();&#xA;    m = timer0_overflow_count;&#xA;    t = TCNT0;&#xA;    if ((TIFR0 &amp;amp; _BV(TOV0)) &amp;amp;&amp;amp; (t &amp;lt; 255))&#xA;        m++;&#xA;    SREG = oldSREG;&#xA;    return ((m &amp;lt;&amp;lt; 8) + t) * (64 / clockCyclesPerMicrosecond());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code above allows for the overflow (it checks the TOV0 bit) so it can cope with the overflow while interrupts are off but only &lt;strong&gt;once&lt;/strong&gt; - there is no provision for handling two overflows.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TLDR;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Don't do delays inside an ISR&lt;/li&gt;&#xA;&lt;li&gt;If you must do them, you can time then with &lt;code&gt;micros()&lt;/code&gt; but not &lt;code&gt;millis()&lt;/code&gt;. Also &lt;code&gt;delayMicroseconds()&lt;/code&gt; is a possibility.&lt;/li&gt;&#xA;&lt;li&gt;Don't delay more than 500 µs or so, or you'll miss a timer overflow.&lt;/li&gt;&#xA;&lt;li&gt;Even short delays may cause you to you miss incoming serial data (at 115200 baud you will get a new character every 87 µs).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-24T22:41:29.587" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22238" PostTypeId="2" ParentId="22231" CreationDate="2016-03-24T22:59:01.260" Score="1" Body="&lt;p&gt;Not sure if this is what you mean, but:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int FP = 0;  // force probe analog pin&#xA;const int OFFSET = 10; // your deadband depending on your sensors consistency too&#xA;int init_read = 0;  // initial read&#xA;int curr_read = 0;  // this will be constantly updated till zeroing is done&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  //the rest of your setup()&#xA;}&#xA;&#xA;void loop(){&#xA;  if (Serial.available() &amp;amp;&amp;amp; (Serial.read() == 'z')){  // if you sent anything with the monitor and if 'z' is present   &#xA;    init_read = analogRead(FP); // initial read from sensor before 'zeroing' begins &#xA;    while (abs(curr_read - init_read) &amp;lt; OFFSET){ // here you indicate the condition that would mean the probe has been zeroed&#xA;      // make your adjustments or whatever&#xA;      curr_read = analogRead(FP);  // take a new reading and check in the next iteration&#xA;    }&#xA;    Serial.print(&quot;Zeroing is done.&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;z&lt;/code&gt; is the command you send from the serial monitor to begin zeroing.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-03-25T03:38:34.220" LastActivityDate="2016-03-25T03:38:34.220" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22239" PostTypeId="2" ParentId="22219" CreationDate="2016-03-25T00:36:27.183" Score="1" Body="&lt;p&gt;The simplest possible way of sending the struct's data is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write((const uint8_t *)&amp;amp;myData, sizeof(myData));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Get the address of myData, cast it to an unsigned int pointer, and starting at that address write the number of bytes specified by &lt;code&gt;sizeof(myData)&lt;/code&gt;. That will transfer the raw data of the struct through the serial with no messing with copying of data into other arrays, assigning pointers, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However: it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sending raw binary data over serial like that, where serial has no concept of anything other than bytes, it is just not possible to know where in the stream of data you are. Which of the myriad of bytes coming in is which within a struct?  Who can tell?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to write a protocol. A method whereby one end tells the other end &quot;This is the start of the data.  This is the data.  This is the end of the data.&quot;  But also you need to be able to say &quot;This bit, that looks the same as the 'start of the data' message is actually a bit of the data, not the start of the data&quot;.  You see, it's quite an involved task really.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T00:36:27.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22240" PostTypeId="2" ParentId="22211" CreationDate="2016-03-25T00:52:36.367" Score="2" Body="&lt;p&gt;In your header file, I dont see where you included &lt;code&gt;SoftwareSerial.h&lt;/code&gt;; this may be a part of why you got those errors. Also you need to end the class definition with a semi-colon, like you were advised in a comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you could just pass a pointer to a &lt;code&gt;SoftwareSerial&lt;/code&gt; object to your &lt;code&gt;Rhino&lt;/code&gt; constructor. In your library header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;class Rhino {&#xA;  private:&#xA;    SoftwareSerial * serial;&#xA;&#xA;  public:&#xA;    Rhino(SoftwareSerial * ss);&#xA;    // other prototypes&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your .cpp source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Rhino.h&quot;  // assuming thats what you named the header&#xA;&#xA;Rhino::Rhino(SoftwareSerial * ss){&#xA;  serial = ss;&#xA; }&#xA;&#xA;void Rhino::begin(uint32_t baud){&#xA;  serial-&amp;gt;begin(baud);&#xA;}&#xA;&#xA;void Rhino::gotoPos(int pos)&#xA;{&#xA;  serial-&amp;gt;write(pos);  // must use the structure pointer operator&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your Arduino sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Rhino.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial ss(2,3);&#xA;Rhino rhino(&amp;amp;ss);  // pass a pointer to ss&#xA;&#xA;void setup(){&#xA;  rhino.begin(9600);&#xA;  rhino.gotoPos(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-03-25T00:52:36.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22241" PostTypeId="1" AcceptedAnswerId="22246" CreationDate="2016-03-25T01:59:05.020" Score="1" ViewCount="2248" Body="&lt;p&gt;I am using &lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel&quot; rel=&quot;nofollow&quot;&gt;Adafruit Neopixel Library&lt;/a&gt; to work with a strand of 21 RGB LEDs.&#xA;AT this point only the first 16 light up. It is not a soldering problem, battery issue or a short.&#xA;&lt;a href=&quot;https://learn.adafruit.com/digital-led-strip/troubleshooting&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; troubleshooting page suggests to &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;confirm that the number of LEDs in the LPD8806() constructor match the&#xA;  number of LEDs in the strip (both will be 32 if using the strandtest&#xA;  example and a single meter of LEDs).&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But looking at the library code below, I am not certain where to modify. Adafruit_Neopixel master zip has 2 files, which contain source code. One is &lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp&quot; rel=&quot;nofollow&quot;&gt;Adafruit_Neopixel.cpp&lt;/a&gt; and the other &lt;a href=&quot;https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h&quot; rel=&quot;nofollow&quot;&gt;Adafruit_Neopixel.h&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you. &lt;/p&gt;&#xA;" OwnerUserId="15366" LastEditorUserId="15366" LastEditDate="2016-03-25T02:10:36.847" LastActivityDate="2016-03-26T12:28:03.633" Title="Adafruit Neopixel Library- only the first 16 LEDs respond" Tags="|arduino-uno|adafruit|rgb-led|neopixel|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22242" PostTypeId="2" ParentId="22241" CreationDate="2016-03-25T02:22:09.410" Score="3" Body="&lt;p&gt;You don't modify the library at all. The page refers to the &lt;em&gt;constructor&lt;/em&gt; which is the last line here:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;#define PIN 6&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that would send to 60 NeoPixels. Change the 60 to however-many you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To compare, try running my library &lt;a href=&quot;http://www.gammon.com.au/forum/?id=13357&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. That doesn't use the Adafruit library. Use the minimal demo code, and change PIXELS to be 21.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;NeoPixels_SPI.h&amp;gt;&#xA;&#xA;const unsigned int PIXELS = 8; // Number of pixels in the string&#xA;&#xA;void setup ()&#xA;  {&#xA;  ledsetup();&#xA;  showColor (PIXELS, 0xB2, 0x22, 0x22);  // firebrick&#xA;  } // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that you connect the NeoPixels data to pin D11 of your Uno in this case.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;@Paul 2000mAh at 3.7V Lipo battery&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;according to the comment in the main question he's powering 21 LED's off a &quot;2000mAh at 3.7V Lipo battery&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, well let's look at the specs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Ue3l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Ue3l.png&quot; alt=&quot;WS2812 specs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you lose 0.2V over the first 8 LEDs you are under spec for the voltage.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-25T10:43:34.720" LastActivityDate="2016-03-25T10:43:34.720" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22244" PostTypeId="1" AcceptedAnswerId="22250" CreationDate="2016-03-25T07:32:23.623" Score="0" ViewCount="927" Body="&lt;p&gt;Following is my code that i am trying to use it with Arduino Uno with ESP8266 module but my code stucked in setup function why is that. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ESP8266.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(12,13);&#xA;#define SSID        &quot;abcd&quot;&#xA;#define PASSWORD    &quot;87654321&quot;&#xA;#define HOST_NAME   &quot;www.baidu.com&quot;&#xA;#define HOST_PORT   (80)&#xA;&#xA;ESP8266 wifi(mySerial);&#xA;&#xA;void setup(void)&#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial.print(&quot;setup begin\r\n&quot;);&#xA;&#xA;    Serial.print(&quot;FW Version:&quot;);&#xA;    Serial.println(wifi.getVersion().c_str());&#xA;&#xA;    if (wifi.setOprToStationSoftAP()) {&#xA;        Serial.print(&quot;to station + softap ok\r\n&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;to station + softap err\r\n&quot;);&#xA;    }&#xA;&#xA;//    if (wifi.joinAP(SSID, PASSWORD)) {&#xA;//        Serial.print(&quot;Join AP success\r\n&quot;);&#xA;//&#xA;//        Serial.print(&quot;IP:&quot;);&#xA;//        Serial.println( wifi.getLocalIP().c_str());       &#xA;//    } else {&#xA;//        Serial.print(&quot;Join AP failure\r\n&quot;);&#xA;//    }&#xA;    delay(500);&#xA;    if (wifi.disableMUX()) {&#xA;        Serial.print(&quot;single ok\r\n&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;single err\r\n&quot;);&#xA;    }&#xA;&#xA;    Serial.print(&quot;setup end\r\n&quot;);&#xA;&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;    uint8_t buffer[1024] = {0};&#xA;&#xA;    if (wifi.createTCP(HOST_NAME, HOST_PORT)) {&#xA;        Serial.print(&quot;create tcp ok\r\n&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;create tcp err\r\n&quot;);&#xA;    }&#xA;&#xA;    char *hello = &quot;GET / HTTP/1.1\r\nHost: www.baidu.com\r\nConnection: close\r\n\r\n&quot;;&#xA;    wifi.send((const uint8_t*)hello, strlen(hello));&#xA;&#xA;    uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);&#xA;    if (len &amp;gt; 0) {&#xA;        Serial.print(&quot;Received:[&quot;);&#xA;        for(uint32_t i = 0; i &amp;lt; len; i++) {&#xA;            Serial.print((char)buffer[i]);&#xA;        }&#xA;        Serial.print(&quot;]\r\n&quot;);&#xA;    }&#xA;&#xA;    if (wifi.releaseTCP()) {&#xA;        Serial.print(&quot;release tcp ok\r\n&quot;);&#xA;    } else {&#xA;        Serial.print(&quot;release tcp err\r\n&quot;);&#xA;    }&#xA;&#xA;    while(1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;On Serial Monitor i get the following continuously&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setup begin&#xA;FW Version:0018000902&#xA;to station + softap ok&#xA;singl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;setup begin&#xA;    FW Version:0018000902&#xA;    to station + softap ok&#xA;    singl&lt;/p&gt;&#xA;" OwnerUserId="16299" LastActivityDate="2016-03-25T09:21:52.163" Title="Arduino UNO stuck in Setup function when interfacing UNO with ESP8266 module" Tags="|arduino-uno|programming|arduino-ide|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22246" PostTypeId="2" ParentId="22241" CreationDate="2016-03-25T08:03:47.307" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;When something works, but not completely, it's often due to power issues.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Embedded things, microcontrollers/Arduino are fairly robust and &quot;logical&quot;.&#xA;Hence, if your Arduino program works today, it'll work tomorrow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Analog devices, or electricity is (in my eyes) often a bit vague. A chip can get enough power to run, but not enough to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The NeoPixel&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit has an extremely elaborated &lt;a href=&quot;https://learn.adafruit.com/downloads/pdf/adafruit-neopixel-uberguide.pdf&quot; rel=&quot;noreferrer&quot;&gt;tutorial/userguide&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Powering the NeoPixels&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This also seems to fit your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rjnXI.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rjnXI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try powering the strip from the middle.&#xA;Since your voltage isn't stable, your amperage might not be as high and the resistance may be a little big. It's actually quite impressive that it works.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Each NeoPixel can draw up to 60 milliamps at full brightness.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;2000mAh does not mean it can (always) deliver 2000mA. It depends on the &quot;C&quot; or discharge rating of the battery. So if your battery is rated 0.5 C it'll only be able to supply 1000mA (for 2 hours).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;60*21 would be well over 1000mA, actually 60*16 is just below 1mA, so this would fit your problem.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The voltage of a battery depends on how much charge it has.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Check google for: &lt;a href=&quot;https://dlnmh9ip6v2uc.cloudfront.net/assets/6/7/4/7/9/5112a224ce395fb479000003.png&quot; rel=&quot;noreferrer&quot;&gt;&quot;LiPo voltage drop&quot;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If all else fails&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is a chance that that particular LED is broken. The signal will not continue to the other LED's and thus the light of the strip will end there.&#xA;Try to drive the LED's behind the LED that fails. (With the power supply closer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm also not sure if you can supply 3.7V and then use 5V logic. Things like that would often break a microcontroller (when running on 3.3V, you usually can't receive 5V?)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-25T08:03:47.307" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22247" PostTypeId="1" CreationDate="2016-03-25T08:53:05.893" Score="0" ViewCount="1250" Body="&lt;p&gt;This code is working, any ideas? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check the code - Bluetooth is connecting but the servo motors are not varying with respect to the app sliders. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo1, myservo2, myservo3;&#xA;&#xA;int bluetoothTx = 1;&#xA;int bluetoothRx = 0;&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup()&#xA;{&#xA;  myservo1.attach(9);&#xA;  myservo2.attach(10);&#xA;  myservo3.attach(11);&#xA;&#xA;  //Setup usb serial connection to computer&#xA;  Serial.begin(9600);&#xA;&#xA;  //Setup Bluetooth serial connection to android&#xA;  bluetooth.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Read from bluetooth and write to usb serial&#xA;  if (bluetooth.available() &amp;gt;= 2 )&#xA;  {&#xA;    unsigned int servopos = bluetooth.read();&#xA;    unsigned int servopos1 = bluetooth.read();&#xA;    unsigned int realservo = (servopos1 * 256) + servopos;&#xA;    Serial.println(realservo);&#xA;&#xA;    if (realservo &amp;gt;= 1000 &amp;amp;&amp;amp; realservo &amp;lt; 1360) {&#xA;      int servo1 = realservo;&#xA;      servo1 = map(servo1, 1000, 1360, 0, 360);&#xA;      myservo1.write(servo1);&#xA;      Serial.println(&quot;servo 1 ON&quot;);&#xA;      delay(10);&#xA;    }&#xA;&#xA;    if (realservo &amp;gt;= 1000 &amp;amp;&amp;amp; realservo &amp;lt; 1360) {&#xA;      int servo2 = realservo;&#xA;      servo2 = map(servo2, 1000, 1360, 0, 360);&#xA;      myservo2.write(servo2);&#xA;      Serial.println(&quot;servo 2 On&quot;);&#xA;      delay(10);&#xA;    }&#xA;&#xA;    if (realservo &amp;gt;= 1000 &amp;amp;&amp;amp; realservo &amp;lt; 1360) {&#xA;      int servo3 = realservo;&#xA;      servo3 = map(servo3, 1000, 1360, 0, 360);&#xA;      myservo3.write(servo3);&#xA;      Serial.println(&quot;servo 3 On&quot;);&#xA;      delay(10);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19589" LastEditorUserId="6936" LastEditDate="2016-03-25T09:57:28.797" LastActivityDate="2016-11-21T06:37:14.607" Title="Arduino code for continuous rotation for 3 servos with Bluetooth" Tags="|arduino-uno|bluetooth|servo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22248" PostTypeId="2" ParentId="22241" CreationDate="2016-03-25T08:54:38.890" Score="0" Body="&lt;p&gt;With most led strips you can supply power from both ends if you are experiencing voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can do this with two separate power supply units if you don't have one unit that is capable of powering the entire strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if power is your entire problem, but if it is you could try this solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's a problem with the Neopixel library You could also try the excellent FastLED library and see if that helps you sort out your issues.&lt;/p&gt;&#xA;" OwnerUserId="19361" LastEditorUserId="19361" LastEditDate="2016-03-26T12:28:03.633" LastActivityDate="2016-03-26T12:28:03.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22249" PostTypeId="2" ParentId="21948" CreationDate="2016-03-25T09:07:10.860" Score="10" Body="&lt;p&gt;You can use fill_solid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fill_solid( leds, NUM_LEDS, CRGB(50,0,200));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fill_solid( leds, NUM_LEDS, CRGB::Red);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19361" LastEditorUserId="19361" LastEditDate="2016-03-25T11:17:23.540" LastActivityDate="2016-03-25T11:17:23.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22250" PostTypeId="2" ParentId="22244" CreationDate="2016-03-25T09:21:52.163" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It's always a good idea to put a serial output in the setup of your code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It seems that your Arduino resets itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the problem would be with too little power for your ESP8266 and Arduino. When the ESP8266 wants to create a network connection, it takes a little more current, possibly leaving your Arduino without enough current to run on itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your Arduino would shut down since the ESP8266 takes up all the current. Creating some kind of bootloop on your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell us how you powered the devices and how you connected them.&#xA;You might try using a separate power supply or a big capacitor on the Arduino's 5V+GND.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-25T09:21:52.163" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22251" PostTypeId="1" CreationDate="2016-03-25T10:13:24.623" Score="2" ViewCount="952" Body="&lt;p&gt;I'm trying to build my own 3D printer with &lt;a href=&quot;http://www.instructables.com/id/Complete-newbie-step-by-step-3D-printer-with-all-p/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;a guide&lt;/a&gt; but I've got a problem with two of my CD/DVD motors: I don't know which settings to set in Marlin (&lt;code&gt;configuration.h&lt;/code&gt;) because I can't find any datasheet for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I tried to set some values by my own, but I'm a little lost. That's why I'm asking for some help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an &lt;strong&gt;Arduino Mega 2560&lt;/strong&gt; (with Marlin firmware), a &lt;strong&gt;RAMPS 1.4&lt;/strong&gt; and &lt;strong&gt;x4 A4988 modules&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The 1st motor has &quot;&lt;strong&gt;7810200082AC&lt;/strong&gt;&quot; engraved on front and &quot;&lt;strong&gt;D5X08VF1D&lt;/strong&gt;&quot; printed on the back.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The 2nd motor has &quot;&lt;strong&gt;05Z20P2B&lt;/strong&gt;&quot; and &quot;&lt;strong&gt;092KPL201ACP&lt;/strong&gt;&quot; printed on the back.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If I wasn't clear or some information is missing, please tell me!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/85RMP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/85RMP.jpg&quot; alt=&quot;Motors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19592" LastEditorUserId="6936" LastEditDate="2016-11-24T02:03:44.073" LastActivityDate="2017-07-23T22:02:15.820" Title="Motors settings" Tags="|arduino-mega|motor|stepper|" AnswerCount="1" CommentCount="2" ClosedDate="2017-07-24T11:45:35.700" ContentLicense="CC BY-SA 3.0" />
  <row Id="22252" PostTypeId="1" AcceptedAnswerId="22255" CreationDate="2016-03-25T10:20:59.690" Score="2" ViewCount="585" Body="&lt;p&gt;I flashed an Arduino Nano compatible with ftdi_eeprom and the following config:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;vendor_id=0x0403    # Vendor ID&#xA;product_id=0x6001   # Product ID&#xA;&#xA;max_power=0     # Max. power consumption: value * 2 mA. Use 0 if self_powered = true.&#xA;&#xA;###########&#xA;# Strings #&#xA;########### &#xA;manufacturer=&quot;FTDI&quot;     # Manufacturer&#xA;product=&quot;Arduino Nano&quot;  # Product&#xA;serial=&quot;arduino_1&quot;      # Serial&#xA;&#xA;###########&#xA;# Options #&#xA;###########&#xA;self_powered=false  # Turn this off for bus powered&#xA;remote_wakeup=false # Turn this on for remote wakeup feature&#xA;use_serial=true     # Use the serial number string&#xA;&#xA;# Normally out don't have to change one of these flags&#xA;BM_type_chip=true       # Newer chips are all BM type&#xA;in_is_isochronous=false     # In Endpoint is Isochronous&#xA;out_is_isochronous=false    # Out Endpoint is Isochronous&#xA;suspend_pull_downs=false    # Enable suspend pull downs for lower power&#xA;change_usb_version=false    # Change USB Version&#xA;usb_version=0x0200      # Only used when change_usb_version is enabled&#xA;&#xA;########&#xA;# Misc #&#xA;########&#xA;&#xA;filename=&quot;eeprom.new&quot;   # Filename, leave empty to skip file writing&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My corresponfing &lt;code&gt;udev&lt;/code&gt; rules work and I get &lt;code&gt;/dev/arduino_1&lt;/code&gt; after connecting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However. After the flash, everything seems to work, But: The TX-LED is constantly on. Even, when the device is not sending. Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update &amp;amp; solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, I removed this line, because it threw warning messages (outdated)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# BM_type_chip=true         # Newer chips are all BM type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then I studied the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;schematics&lt;/a&gt; of the Nano and figured out, that &lt;code&gt;RX&lt;/code&gt; and &lt;code&gt;TX&lt;/code&gt;  LEDs are indeed connected to &lt;code&gt;CBUS0&lt;/code&gt; and &lt;code&gt;CBUS1&lt;/code&gt;. So, I added two lines to my config&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  cbus0=RXLED&#xA;  cbus1=TXLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which had the effect, that now both &lt;code&gt;RX&lt;/code&gt; and &lt;code&gt;TX&lt;/code&gt; where constantly on. So, I finally read the &lt;a href=&quot;https://www.sparkfun.com/datasheets/IC/FT232R_v104.pdf&quot; rel=&quot;nofollow&quot;&gt;manual&lt;/a&gt; which says on page 11, that the commands in question need a trailing &lt;code&gt;#&lt;/code&gt;. I updated my config again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cbus0=RXLED#&#xA;cbus1=TXLED#&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Extra:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Indeed, I had to install &lt;code&gt;ftdi_eeprom&lt;/code&gt; to get the job done&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA; apt-get remove ftdi-eeprom&#xA; apt-get install swig libusb-1.0-0-dev libconfuse-dev doxygen&#xA; git clone https://github.com/legege/libftdi.git&#xA; cd libftdi.git&#xA; cmake .&#xA; make &#xA; make install&#xA; ftdi_eeprom/ftdi_eeprom --flash-eeprom myconfig.conf&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="19013" LastEditDate="2016-03-25T15:06:31.687" LastActivityDate="2016-03-25T15:06:31.687" Title="Risks of ftdi_eeprom? - TX always high after flashing" Tags="|arduino-nano|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22253" PostTypeId="2" ParentId="22251" CreationDate="2016-03-25T10:35:12.657" Score="0" Body="&lt;p&gt;I don't know your exact setup, but when it comes to steppers, you just need to know a few things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Meter the coils to get an impression, how much current you can induce. &lt;/li&gt;&#xA;&lt;li&gt;Limit the current on your driver as low as possible (&amp;lt;= 0.25 A possible?)&lt;/li&gt;&#xA;&lt;li&gt;Test&lt;/li&gt;&#xA;&lt;li&gt;Heighten the current, if the motor doesn't turn or stalls &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Your motors are quite small, so I would assume, they run with less than 0.25 A at 12 V or 0.125 A at 24 V and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you limit the current, nothing can go wrong at all. Check the heat from time to time and make sure, your drivers lowers the current, whenever the given axis stands still.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it comes to to resolution, I would not recommend to use more than 1/4 steps, which would result in 4*48/round steps on a standard stepper and provides very good resolution plus smooth motor action.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="6936" LastEditDate="2016-11-24T02:05:48.820" LastActivityDate="2016-11-24T02:05:48.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22254" PostTypeId="1" CreationDate="2016-03-25T10:50:28.560" Score="1" ViewCount="680" Body="&lt;p&gt;I have a device which transmits USART with inverted polarity, and I would like to read data from it with the help of an Arduino. I use an Arduino Due, which has a SAM3X processor, so it should be able to invert the polarity without any external hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The settings accessible from the Arduino SDK are minimalistic, &lt;code&gt;Serial.begin()&lt;/code&gt; only allows to set the baudrate and start/parity/stop, nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the SAM3X datasheet I found the &quot;USART Mode Register&quot;, &lt;code&gt;US_MR&lt;/code&gt;, which dedicates bit 23 (&lt;code&gt;INVDATA&lt;/code&gt;) to invert the polarity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wTr5I.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wTr5I.png&quot; alt=&quot;USART Mode Register&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although it seems not to be documented anywhere, I found in a forum that to access the &lt;code&gt;US_MR&lt;/code&gt; register, I have to use &lt;code&gt;UART-&amp;gt;UART_MR&lt;/code&gt;. I can read that register but cannot change it. The SAM3X datasheet mentions that this register might be write protected, and that the write protection can be cleared in the &lt;code&gt;US_WPMR&lt;/code&gt; register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the Arduino SDK doesn't seem to know about this register. I tried several possibilities,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;US_WPMR&#xA;UART_WPMR&#xA;WPMR&#xA;UART-&amp;gt;US_WPMR&#xA;UART-&amp;gt;UART_WPMR&#xA;UART-&amp;gt;WPMR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;None of which are known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The string &lt;code&gt;WPMR&lt;/code&gt; is nowhere to be found in any of the files in my Arduino installation folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, &lt;a href=&quot;https://android.googlesource.com/platform/external/arduino-ide/+/f876b2abdebd02acfa4ba21e607327be4f9668d4/hardware/arduino/sam/cores/arduino/UARTClass.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;the source code&lt;/a&gt; for the UART class doesn't contain any reference to the WPMR. It just sets the required configuration registers without bothering with it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void UARTClass::begin( const uint32_t dwBaudRate )&#xA;{&#xA;  // Configure PMC&#xA;  pmc_enable_periph_clk( _dwId ) ;&#xA;  // Disable PDC channel&#xA;  _pUart-&amp;gt;UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS ;&#xA;  // Reset and disable receiver and transmitter&#xA;  _pUart-&amp;gt;UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS ;&#xA;  // Configure mode&#xA;  _pUart-&amp;gt;UART_MR = UART_MR_PAR_NO | UART_MR_CHMODE_NORMAL ;&#xA;  // Configure baudrate (asynchronous, no oversampling)&#xA;  _pUart-&amp;gt;UART_BRGR = (SystemCoreClock / dwBaudRate) &amp;gt;&amp;gt; 4 ;&#xA;  // Configure interrupts&#xA;  _pUart-&amp;gt;UART_IDR = 0xFFFFFFFF;&#xA;  _pUart-&amp;gt;UART_IER = UART_IER_RXRDY | UART_IER_OVRE | UART_IER_FRAME;&#xA;  // Enable UART interrupt in NVIC&#xA;  NVIC_EnableIRQ(_dwIrq);&#xA;  // Enable receiver and transmitter&#xA;  _pUart-&amp;gt;UART_CR = UART_CR_RXEN | UART_CR_TXEN ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I try to change &lt;code&gt;UART_MR&lt;/code&gt;, it remains the same.&lt;/p&gt;&#xA;" OwnerUserId="11045" LastEditorUserId="11045" LastEditDate="2016-03-25T11:50:21.850" LastActivityDate="2016-10-13T02:58:26.970" Title="How to disable the write protection of the USART mode register?" Tags="|serial|arduino-due|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22255" PostTypeId="2" ParentId="22252" CreationDate="2016-03-25T11:10:46.120" Score="1" Body="&lt;p&gt;The &lt;code&gt;ftdi_eeprom&lt;/code&gt; utility re-writes the entire EEPROM, not just the selected bits you have chosen.  That includes the &quot;CBUS&quot; pin configurations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to check on the Nano's schematic which LED is connected to which &lt;code&gt;CBUSx&lt;/code&gt; pin on the FTDI and set it accordingly.  You do that in your config using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cbus0=TXLED&#xA;cbus1=RXLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible settings for the CBUS pins are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TXDEN&lt;/li&gt;&#xA;&lt;li&gt;PWREN&lt;/li&gt;&#xA;&lt;li&gt;RXLED&lt;/li&gt;&#xA;&lt;li&gt;TXLED&lt;/li&gt;&#xA;&lt;li&gt;TXRXLED&lt;/li&gt;&#xA;&lt;li&gt;SLEEP&lt;/li&gt;&#xA;&lt;li&gt;CLK48&lt;/li&gt;&#xA;&lt;li&gt;CLK24&lt;/li&gt;&#xA;&lt;li&gt;CLK12&lt;/li&gt;&#xA;&lt;li&gt;CLK6&lt;/li&gt;&#xA;&lt;li&gt;IO_MODE&lt;/li&gt;&#xA;&lt;li&gt;BITBANG_WR&lt;/li&gt;&#xA;&lt;li&gt;BITBANG_RD&lt;/li&gt;&#xA;&lt;li&gt;SPECIAL&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Except CBUS4 which only has the functions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TXDEN&lt;/li&gt;&#xA;&lt;li&gt;PWRON&lt;/li&gt;&#xA;&lt;li&gt;RXLED&lt;/li&gt;&#xA;&lt;li&gt;TXLED&lt;/li&gt;&#xA;&lt;li&gt;TX_RX_LED&lt;/li&gt;&#xA;&lt;li&gt;SLEEP&lt;/li&gt;&#xA;&lt;li&gt;CLK48&lt;/li&gt;&#xA;&lt;li&gt;CLK24&lt;/li&gt;&#xA;&lt;li&gt;CLK12&lt;/li&gt;&#xA;&lt;li&gt;CLK6&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is a chance that your pre-packages version of &lt;code&gt;ftdi_eeprom&lt;/code&gt; doesn't support those settings, so you will need to download and compile the latest version from source from here: &lt;a href=&quot;https://github.com/legege/libftdi&quot; rel=&quot;nofollow&quot;&gt;https://github.com/legege/libftdi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also during testing I accidentally changed the VID of one of my boards thus rendering it unresponsive.  I did that by omitting the &lt;code&gt;0x&lt;/code&gt; from the VID and PID numbers.  Extreme care should be exercised using thin utility.  I have submitted a patch to allow the specification of a default VID for recovery from such situations.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-25T11:17:04.057" LastActivityDate="2016-03-25T11:17:04.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22256" PostTypeId="1" CreationDate="2016-03-25T11:20:17.377" Score="0" ViewCount="355" Body="&lt;p&gt;I've been messing around with accelerometers for Arduino for a school project. I bought the SODIAL GY-521 accelerometer + gyroscope module for Arduino. It uses de Invensense MPU 6050. I managed to connect it onto my board and successfully detect it, but it returns values of -1 on all output ports. I was expecting there to be a port for every axis of acceleration and rotation but it seems that this isn't the case. How should I connect the module into my Arduino, and how should I program the Arduino to read my data?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to follow the Arduino Playground example but the result was as explained above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for all answers.&lt;/p&gt;&#xA;" OwnerUserId="18564" LastActivityDate="2016-12-21T22:19:55.757" Title="Using 6 axis accelerometers" Tags="|arduino-uno|sensors|accelerometer|gyroscope|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22257" PostTypeId="1" AcceptedAnswerId="22258" CreationDate="2016-03-25T12:03:25.963" Score="0" ViewCount="92" Body="&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.print(&quot;hi&quot;);&#xA;}&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The product is in &lt;a href=&quot;http://hobbycomponents.com/featured/98-arduino-compatible-nano-v30-with-free-usb-cable&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also installed the drivers.&lt;/p&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="19515" LastEditDate="2016-03-25T15:41:43.770" LastActivityDate="2016-03-25T15:41:43.770" Title="My Arduino Nano clone doesn't show in the serial this simple code. Why?" Tags="|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22258" PostTypeId="2" ParentId="22257" CreationDate="2016-03-25T12:05:12.843" Score="1" Body="&lt;p&gt;You haven't &quot;started&quot; the serial interface.  Before you use the serial you need to tell it to initialize the hardware and how fast you want to communicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to add, for instance,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your &lt;code&gt;setup()&lt;/code&gt; function before you do your &lt;code&gt;Serial.print()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T12:05:12.843" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22260" PostTypeId="1" AcceptedAnswerId="22264" CreationDate="2016-03-25T12:49:56.527" Score="0" ViewCount="1508" Body="&lt;pre&gt;&lt;code&gt;const int GSR=A0;&#xA;int threshold=0;&#xA;int sensorValue;&#xA;&#xA;void setup(){&#xA;  long sum=0;&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;&#xA;  for(int i=0;i&amp;lt;500;i++)&#xA;  {&#xA;  sensorValue=analogRead(GSR);&#xA;  sum += sensorValue;&#xA;  delay(5);&#xA;  }&#xA;  threshold = sum/500;&#xA;   Serial.print(&quot;threshold =&quot;);&#xA;   Serial.println(threshold);&#xA;  }&#xA;&#xA;void loop(){&#xA;  int temp;&#xA;  sensorValue=analogRead(GSR);&#xA;  Serial.print(&quot;sensorValue=&quot;);&#xA;  Serial.println(sensorValue);&#xA;  temp = threshold - sensorValue;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="2881" LastEditDate="2016-03-25T14:48:27.490" LastActivityDate="2018-02-26T06:57:45.390" Title="Why can't I see the serial plot with the following code for arduino?" Tags="|arduino-nano|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="22262" PostTypeId="1" AcceptedAnswerId="22263" CreationDate="2016-03-25T13:45:03.853" Score="2" ViewCount="1044" Body="&lt;p&gt;About 3 years ago Sparkfun had a sale on Arduino Minis, so I bought 6 of them (3 x 3.3 V @ 16 MHz and 3 x 5 V @16 MHz). I used two of them for separate projects (everything worked flawlessly) then stored the rest. Then last night I grabbed one of the 5 V and 3.3 V Minis and tried to upload the Blinking LED program to them. But I kept getting this error: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm getting similar results on all of these computers: Mac OS X 10.10, Mac OS X 10.7, and Windows 7. I tested with default drivers and I tried installing fresh drivers based on the HardwareID's of the devices. I used both the newest version of Arduino IDE and a few older versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried two different USB devices: &lt;a href=&quot;https://www.sparkfun.com/products/9873&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Basic FTDI&lt;/a&gt; and a &lt;a href=&quot;https://www.amazon.ca/Driver-USB-TTL-USB-STC-ISP-On-line-Program/dp/B00JN1BR9A&quot; rel=&quot;nofollow&quot;&gt;Generic USB to Serial PL2303 similar to this one&lt;/a&gt;. They both produce the same error, however the FTDI seems to be somewhat able to communicate since the RX &amp;amp; TX lights are flashing as well as the Arduino LED. With PL2303, the LED is lit constantly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While searching last night, I found a few forums where people suggested things like hitting the reset button and selecting different Arduino boards in the IDE.&lt;/p&gt;&#xA;" OwnerUserId="19597" LastEditorUserId="6936" LastEditDate="2016-03-26T07:21:15.223" LastActivityDate="2016-04-03T21:40:00.793" Title="I can't get code transferred to my Arduino Mini Pro" Tags="|serial|usb|ftdi|arduino-mini|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22263" PostTypeId="2" ParentId="22262" CreationDate="2016-03-25T14:30:59.623" Score="2" Body="&lt;p&gt;Things have changed in the three years since you last used your FTDI board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most importantly avrdude has changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will most likely find that you can program your boards perfectly fine using Arduino IDE 1.0.1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What has changed is that avrdude has been modified to counter a change in the FTDI drivers. It used to be that the FTDI drivers would pulse the DTR line when the port was opened, but that stopped happening with newer drivers. So AVRDude started asserting the DTR line instead. However it doesn't pulse it, it just holds it low. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with that is if the DTR is connected direct to the RESET pin the main chip is held in reset mode all the time instead of it just being reset briefly to reset the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;fix&quot; is to place a 100nF capacitor between DTR and RESET instead of directly connecting it. That converts the steady low into a short pulse which resets the board and enters the bootloader.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T14:30:59.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22264" PostTypeId="2" ParentId="22260" CreationDate="2016-03-25T14:36:22.277" Score="3" Body="&lt;p&gt;The serial plotter requires just numbers and nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can't understand the data in the format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sensorValue=49&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It just expects:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;49&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Remove the line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;sensorValue=&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will start working.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T14:36:22.277" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="22265" PostTypeId="1" AcceptedAnswerId="22280" CreationDate="2016-03-25T14:52:14.663" Score="3" ViewCount="1517" Body="&lt;p&gt;I am working with an LSM9DS1 IMU, and now specifically trying to program a wakeup feature into the system. My idea is to set the accelerometer at the lowest possible read rate, then when the accelerometer value exceeds a predefined level, to have the system wake up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When programming the sensor, there is a register called INT_GEN_CFG_XL that has a &quot;6-Direction detection for interrupt.&quot; I was wondering what this means. Does this perhaps calculate the magnitude of acceleration, and see if that goes above a predefined value? I can see the other interrupt generators are for 1-direction of each of the three axes, but I can't interrupt this one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to the &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/datasheet/DM00103319.pdf&quot; rel=&quot;nofollow&quot;&gt;device datasheet&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16549" LastActivityDate="2016-03-25T17:44:05.800" Title="Accelerometer Interrupt Meaning - Wakeup Function" Tags="|sensors|interrupt|accelerometer|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22266" PostTypeId="2" ParentId="22256" CreationDate="2016-03-25T15:17:22.900" Score="1" Body="&lt;p&gt;From &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;the Arduino playground&lt;/a&gt;:&lt;br&gt;&#xA;This sensor board has a voltage regulator. When using 3.3V to the VCC the resulting voltage (after the onboard voltage regulator) might be too low for a good working I2C bus. It is preferred to apply 5V to the VCC pin of the sensor board. The board has pull-up resistors on the I2C-bus. The value of those pull-up resistors are sometimes 10k and sometimes 2k2. The 2k2 is rather low. If it is combined with other sensor board which have also pull-up resistors, the total pull-up impedance might be too low.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="10794" LastEditDate="2016-04-24T20:37:45.760" LastActivityDate="2016-04-24T20:37:45.760" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22267" PostTypeId="1" AcceptedAnswerId="23549" CreationDate="2016-03-25T15:40:30.307" Score="1" ViewCount="4591" Body="&lt;p&gt;I want to know the basics of Arduino serial communications and connection with a Java application in Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody provide me with a sample Java program that upon running just makes an Arduino pin high as well as the corresponding Arduino sketch, and some explanation on how the Arduino communicates with the Java app?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am now starting with Arduino, and I have some experience with Java &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this code on the net - will this work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Java code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;package arduino;&#xA;&#xA;import jssc.SerialPort;&#xA;import jssc.SerialPortException;&#xA;&#xA;public class Arduino {&#xA;&#xA;public static void main(String[] args) throws InterruptedException {&#xA;&#xA;    SerialPort serialPort = new SerialPort(&quot;COM3&quot;);&#xA;    try {&#xA;        System.out.println(&quot;Port opened: &quot; + serialPort.openPort());&#xA;        System.out.println(&quot;Params setted: &quot; + serialPort.setParams(9600, 8, 1, 0));&#xA;        System.out.println(&quot;\&quot;Hello World!!!\&quot; successfully writen to port: &quot; + serialPort.writeBytes(&quot;o&quot;.getBytes()));&#xA;        Thread.sleep(1000);&#xA;        System.out.println(&quot;\&quot;Hello World!!!\&quot; successfully writen to port: &quot; + serialPort.writeBytes(&quot;f&quot;.getBytes()));&#xA;        System.out.println(&quot;Port closed: &quot; + serialPort.closePort());&#xA;    } catch (SerialPortException ex) {&#xA;        System.out.println(ex);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void setup()   {                &#xA;  Serial.begin(9600);&#xA;  pinMode(8, OUTPUT);&#xA;  digitalWrite(8,HIGH);&#xA;  delay(500);&#xA;  digitalWrite(8,LOW);&#xA;  }&#xA;&#xA;  int incomingByte = 0;&#xA;&#xA;  void loop()                     &#xA;  {&#xA; // send data only when you receive data:&#xA;    if (Serial.available() &amp;gt; 0) {&#xA;           int text = Serial.read();&#xA;           Serial.println(text);&#xA;           if (text == 'o') {&#xA;&#xA;            digitalWrite(8,HIGH);&#xA;&#xA;           }&#xA;&#xA;           if (text = 'f') {&#xA;&#xA;            digitalWrite(8,LOW);&#xA;&#xA;           }&#xA;     }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19599" LastEditorUserId="6936" LastEditDate="2016-03-26T09:04:40.190" LastActivityDate="2017-06-19T15:43:49.167" Title="Java + JSSC + Arduino + Windows" Tags="|serial|java|windows|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22268" PostTypeId="1" AcceptedAnswerId="22271" CreationDate="2016-03-25T14:51:31.997" Score="0" ViewCount="2245" Body="&lt;p&gt;I am trying to hook up my Neo-6M GPS module to my Arduino Uno but am having some trouble getting GPS data out of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code being used was taken from the TinyGPS library. I have set the SoftwareSerial ports in the constructor to 2 and 3 (check images at bottom for reference). I set to the boad rate of the software serial so that it matches that of the Neo-6M. The datasheet for the module can be found &lt;a href=&quot;https://www.u-blox.com/sites/default/files/products/documents/NEO-6_DataSheet_(GPS.G6-HW-09005).pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output that comes out of the Arduino serial monitor looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vgyg6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vgyg6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A new line is added to this every second, and when the line is added the TX light on the Arduino blinks. The 'Chars RX' 0 would indicate that the SoftwareSerial isn't reading any data at all from the module. I can't for the life of me figure out why this is happening! Any help would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;    &#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;/* This sample code demonstrates the normal use of a TinyGPS object.&#xA;   It requires the use of SoftwareSerial, and assumes that you have a&#xA;   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).&#xA;*/&#xA;&#xA;TinyGPS gps;&#xA;SoftwareSerial ss(2, 3);&#xA;&#xA;static void smartdelay(unsigned long ms);&#xA;static void print_float(float val, float invalid, int len, int prec);&#xA;static void print_int(unsigned long val, unsigned long invalid, int len);&#xA;static void print_date(TinyGPS &amp;amp;gps);&#xA;static void print_str(const char *str, int len);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;&#xA;  Serial.print(&quot;Testing TinyGPS library v. &quot;); Serial.println(TinyGPS::library_version());&#xA;  Serial.println(&quot;by Mikal Hart&quot;);&#xA;  Serial.println();&#xA;  Serial.println(&quot;Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum&quot;);&#xA;  Serial.println(&quot;          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail&quot;);&#xA;  Serial.println(&quot;-------------------------------------------------------------------------------------------------------------------------------------&quot;);&#xA;&#xA;  ss.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  float flat, flon;&#xA;  unsigned long age, date, time, chars = 0;&#xA;  unsigned short sentences = 0, failed = 0;&#xA;  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;&#xA;&#xA;  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);&#xA;  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);&#xA;  gps.f_get_position(&amp;amp;flat, &amp;amp;flon, &amp;amp;age);&#xA;  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);&#xA;  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);&#xA;  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;  print_date(gps);&#xA;  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);&#xA;  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);&#xA;  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(gps.f_course()), 6);&#xA;  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);&#xA;  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);&#xA;  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? &quot;*** &quot; : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);&#xA;&#xA;  gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed);&#xA;  print_int(chars, 0xFFFFFFFF, 6);&#xA;  print_int(sentences, 0xFFFFFFFF, 10);&#xA;  print_int(failed, 0xFFFFFFFF, 9);&#xA;  Serial.println();&#xA;&#xA;  smartdelay(1000);&#xA;}&#xA;&#xA;static void smartdelay(unsigned long ms)&#xA;{&#xA;  unsigned long start = millis();&#xA;  do &#xA;  {&#xA;    while (ss.available())&#xA;      gps.encode(ss.read());&#xA;  } while (millis() - start &amp;lt; ms);&#xA;}&#xA;&#xA;static void print_float(float val, float invalid, int len, int prec)&#xA;{&#xA;  if (val == invalid)&#xA;  {&#xA;    while (len-- &amp;gt; 1)&#xA;      Serial.print('*');&#xA;    Serial.print(' ');&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(val, prec);&#xA;    int vi = abs((int)val);&#xA;    int flen = prec + (val &amp;lt; 0.0 ? 2 : 1); // . and -&#xA;    flen += vi &amp;gt;= 1000 ? 4 : vi &amp;gt;= 100 ? 3 : vi &amp;gt;= 10 ? 2 : 1;&#xA;    for (int i=flen; i&amp;lt;len; ++i)&#xA;      Serial.print(' ');&#xA;  }&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;static void print_int(unsigned long val, unsigned long invalid, int len)&#xA;{&#xA;  char sz[32];&#xA;  if (val == invalid)&#xA;    strcpy(sz, &quot;*******&quot;);&#xA;  else&#xA;    sprintf(sz, &quot;%ld&quot;, val);&#xA;  sz[len] = 0;&#xA;  for (int i=strlen(sz); i&amp;lt;len; ++i)&#xA;    sz[i] = ' ';&#xA;  if (len &amp;gt; 0) &#xA;    sz[len-1] = ' ';&#xA;  Serial.print(sz);&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;static void print_date(TinyGPS &amp;amp;gps)&#xA;{&#xA;  int year;&#xA;  byte month, day, hour, minute, second, hundredths;&#xA;  unsigned long age;&#xA;  gps.crack_datetime(&amp;amp;year, &amp;amp;month, &amp;amp;day, &amp;amp;hour, &amp;amp;minute, &amp;amp;second, &amp;amp;hundredths, &amp;amp;age);&#xA;  if (age == TinyGPS::GPS_INVALID_AGE)&#xA;    Serial.print(&quot;********** ******** &quot;);&#xA;  else&#xA;  {&#xA;    char sz[32];&#xA;    sprintf(sz, &quot;%02d/%02d/%02d %02d:%02d:%02d &quot;,&#xA;        month, day, year, hour, minute, second);&#xA;    Serial.print(sz);&#xA;  }&#xA;  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);&#xA;  smartdelay(0);&#xA;}&#xA;&#xA;static void print_str(const char *str, int len)&#xA;{&#xA;  int slen = strlen(str);&#xA;  for (int i=0; i&amp;lt;len; ++i)&#xA;    Serial.print(i&amp;lt;slen ? str[i] : ' ');&#xA;  smartdelay(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZC2gm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZC2gm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/fKjKk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fKjKk.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19605" OwnerDisplayName="jskidd3" LastActivityDate="2016-03-25T16:45:14.050" Title="Arduino SoftwareSerial not receiving data from Neo-6M GPS module" Tags="|serial|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22269" PostTypeId="1" AcceptedAnswerId="22270" CreationDate="2016-03-25T16:19:16.053" Score="1" ViewCount="833" Body="&lt;p&gt;I would like to be able to exclude from the auto-including process of the current project (without renaming the extension or delete it) a sketch with &lt;code&gt;pde&lt;/code&gt; or &lt;code&gt;ino&lt;/code&gt; extension that is used in certain circumstances only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently use Visual Micro to manage projects on Arduino.&lt;/p&gt;&#xA;" OwnerUserId="19601" LastEditorUserId="6936" LastEditDate="2016-03-26T03:18:37.970" LastActivityDate="2016-03-26T03:18:37.970" Title="How to exclude a ino/pde file from Arduino projects" Tags="|arduino-uno|programming|sketch|visualstudio|ino|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22270" PostTypeId="2" ParentId="22269" CreationDate="2016-03-25T16:33:50.840" Score="1" Body="&lt;p&gt;One possible approach is to guard the body of that sketch with an &lt;code&gt;#ifdef ... #endif&lt;/code&gt; pair, and use Visual Micro's  “Project Properties” to define (or not) a preprocessor symbol.  [If the .ino or .pde in question is used as a &lt;code&gt;#include&lt;/code&gt; file, you would instead guard all the &lt;code&gt;#include&lt;/code&gt; instances.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Refer to the &lt;a href=&quot;http://www.visualmicro.com/page/User-Guide.aspx?doc=Project-Defines.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;“Project Defines”&lt;/a&gt; page at visualmicro.com for how to define a preprocessor symbol and its value. [Via: Tools &gt; Options &gt; Visual Micro &gt; Compiler &gt; Show Build Properties]  Also see  &lt;a href=&quot;https://arduino.stackexchange.com/q/13105&quot;&gt;How do I add additional compiler switches in Visual Studio&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If necessary, you can use other tests besides &lt;code&gt;#ifdef&lt;/code&gt; to control compilation.  The first link above shows the following example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if USBPORT &amp;gt; 3&#xA;....your code here....&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-25T16:33:50.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22271" PostTypeId="2" ParentId="22268" CreationDate="2016-03-25T16:45:14.050" Score="2" Body="&lt;p&gt;Gray wire should be plug on pin2. &lt;code&gt;SoftwareSerial ss(2, 3);&lt;/code&gt;  means pin2 for Receive(RX) and pin3 for Transmit(TX). The Transmit(TX) on Neo-6M should be connected to Receive(RX) on Arduino.&lt;/p&gt;&#xA;" OwnerUserId="19460" LastActivityDate="2016-03-25T16:45:14.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22272" PostTypeId="1" AcceptedAnswerId="22278" CreationDate="2016-03-25T17:01:02.500" Score="5" ViewCount="40072" Body="&lt;p&gt;I currently have a &lt;code&gt;for&lt;/code&gt; loop that loops 300 times and then moves on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, I'd like that loop to run for a specific number of minutes, instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the current loop, for reference.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;for(int i = 1; i&amp;lt;300; i++){&#xA;  if (kill() == true){ break; }&#xA;&#xA;  strip.setPixelColor(1, strip.Color(random(100,255),random(100,255),random(100,255)));&#xA;  strip.show();&#xA;&#xA;  tone(TONE, notes[random(0,3)]);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I have an RTC that's used elsewhere in the app, so real actual time is available for use if it makes sense to do that...though I'd love to know of a way to do it without an RTC module for future projects.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-03-25T17:05:15.350" LastActivityDate="2020-07-16T09:17:50.037" Title="How do I run a loop for a specific amount of time?" Tags="|arduino-uno|time|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22273" PostTypeId="2" ParentId="22272" CreationDate="2016-03-25T17:03:45.223" Score="2" Body="&lt;p&gt;You can use a variable that is incremented each time you perform the loop, then you need only to change the loop from using a &lt;code&gt;for&lt;/code&gt; to a &lt;code&gt;while&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   int incremented_variable = 0;&#xA;   int incremented_value = 100;&#xA;   int max_value = 1000;  &#xA;&#xA;   while(incremented_variable &amp;lt; max_value){&#xA;   if (kill() == true){ break; }&#xA;&#xA;   strip.setPixelColor(1, strip.Color(random(100,255),random(100,255),random(100,255)));&#xA;   strip.show();&#xA;&#xA;   tone(TONE, notes[random(0,3)]);&#xA;&#xA;   delay(100);&#xA;   incremented_variable = incremented_variable + incremented_value;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; I have just read your update on the question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then use a while with a boolean flag that help you to end the loop or if you prefer, you can keep track of the time by calling the method: &lt;code&gt;millis()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-25T23:39:08.373" LastActivityDate="2016-03-25T23:39:08.373" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22274" PostTypeId="1" CreationDate="2016-03-25T17:14:15.510" Score="2" ViewCount="161" Body="&lt;p&gt;In the VirtualWire library, it is possible to encode the clock signal as the library is doing with 4b/6b coding. This is possible because VirtualWire uses convolutinal coding, where the &lt;em&gt;information is spread along the sequence&lt;/em&gt;. But, is the same possible for linear &lt;em&gt;block&lt;/em&gt; coding, such as LDPC/Hamming?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, if it is not possible, then how would I best deal with the signal going out of sync with serial communication, given I want to use LDPC coding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, the reason I am using serial communication is because I will have numerous nodes in my wireless mesh network, so to my knowledge, for the sake of: speed, power efficiency, scalability, &lt;em&gt;ease of implementation&lt;/em&gt;, etc, serial communication works best. But has anyone had better luck with any other types of communication that can take care of the sync problem, while accounting for speed, power efficiency, scalability, etc?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; The way I am doing wireless communication is by using simple rf transceivers. There will by one transceiver per node and I am trying to create a stable channel between one node to another. The communication channel isn't very reliable without some error correction. And I don't want to use the existing VirtualWire's convolutional error correction. I want to use LDPC codes, developed by Radford Neal. My goal is to first create a stable channel from one Arduino to another. Then, I will implement the network.&lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="13674" LastEditDate="2016-03-31T17:34:10.523" LastActivityDate="2016-03-31T17:34:10.523" Title="Encoding clock signal into linear block codes" Tags="|serial|softwareserial|wireless|virtualwire|coding-standards|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22275" PostTypeId="2" ParentId="22272" CreationDate="2016-03-25T17:24:11.497" Score="3" Body="&lt;p&gt;Using this example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/ElapsedMillis&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/ElapsedMillis&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;&#xA;elapsedMillis timeElapsed;&#xA;unsigned int interval = 60000; //one minute in ms&#xA;&#xA;while(timeElapsed &amp;lt; interval){&#xA;    //do stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on how accurate you want to be, you might want to opt for a similar method using the RTC.&lt;/p&gt;&#xA;" OwnerUserId="19597" LastEditorUserId="19597" LastEditDate="2016-03-25T17:30:47.637" LastActivityDate="2016-03-25T17:30:47.637" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22276" PostTypeId="1" AcceptedAnswerId="22286" CreationDate="2016-03-25T17:29:51.443" Score="0" ViewCount="181" Body="&lt;p&gt;I'm searching for the fastest way to test if two integers are equal or differ by 4. The integers can be positive, negative and equal to zero. They are between -1000 and 1000 and are exclusively multiples of 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest approach to test this should be this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(x == y || x - y == 4 || x - y == -4)&#xA;{&#xA;     //do something...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But since I want to do this 4 times inside of a interrupt sub routine I wanted to know if there is a faster way to do this.&lt;/p&gt;&#xA;" OwnerUserId="19602" LastEditorUserId="6936" LastEditDate="2016-03-26T03:20:05.767" LastActivityDate="2016-03-26T08:57:23.553" Title="Fastest way to test if two integers differ by 4 or equal to each other" Tags="|arduino-uno|c|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22277" PostTypeId="1" AcceptedAnswerId="22279" CreationDate="2016-03-25T17:35:21.323" Score="1" ViewCount="221" Body="&lt;p&gt;I am building a laser tag system with an Arduino in each gun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the guns to be linked during game play for many different reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start/Stop game&lt;/li&gt;&#xA;&lt;li&gt;Nearby teammates&lt;/li&gt;&#xA;&lt;li&gt;When a flag is captured&lt;/li&gt;&#xA;&lt;li&gt;etc.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I don't know how to link the guns to one another during game play because the field may be large (e.g. a park). Wifi has too short of a range, cellular would cost, linking to a phone via bluetooth would drain the phone battery (and require each player have a smart phone to play). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you think of another way to link the guns? Radio transmitters? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19603" LastActivityDate="2016-03-25T17:42:05.160" Title="Link Arduinos over 5 acre laser tag field" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22278" PostTypeId="2" ParentId="22272" CreationDate="2016-03-25T17:38:49.240" Score="10" Body="&lt;p&gt;Here is an example that will run for 5 minutes. Note that the loop will begin executing anytime before the time limit is up, including 1 msec before; it can't cut-off something happening at the 5-minute mark, meaning the timing precision will be limited to the duration of the code in the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: My first suggestion had a bug related to the 50-some-odd days roll-over period of the millis() clock. This one is more robust:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t period = 5 * 60000L;       // 5 minutes&#xA;&#xA;for( uint32_t tStart = millis();  (millis()-tStart) &amp;lt; period;  ){&#xA;   doStuff();&#xA;   moreStuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-25T18:24:17.163" LastActivityDate="2016-03-25T18:24:17.163" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22279" PostTypeId="2" ParentId="22277" CreationDate="2016-03-25T17:42:05.160" Score="4" Body="&lt;p&gt;You can use nRF24L01+&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chips offer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Really high range with power amplifier (1km open field radius (776 acres if I'm right) , but fairly high power consumption 100-150mA @ 3.3V) &lt;/li&gt;&#xA;&lt;li&gt;High range with PCB antenna (50-80m open field, low power consumption 14mA peak)&lt;/li&gt;&#xA;&lt;li&gt;Low cost (0.8£-6£ a piece)&lt;/li&gt;&#xA;&lt;li&gt;Many easy to use libraries available, possible to create a mesh network&lt;/li&gt;&#xA;&lt;li&gt;High usable voltage range (direct Li-Po for example without step-up)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-03-25T17:42:05.160" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22280" PostTypeId="2" ParentId="22265" CreationDate="2016-03-25T17:44:05.800" Score="2" Body="&lt;p&gt;The INT_GEN_CFG_XL 6-Direction detection interrupt apparently is aimed at detecting change of direction of travel, rather than an axis-combined acceleration level.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://forum.pololu.com/t/design-qs-lsm303-sleep-to-wakeup-and-inertial-interrupts/4900/2&quot; rel=&quot;nofollow&quot;&gt;LSM303&lt;/a&gt; discussion at Polulu.com.  That page includes a link to &lt;a href=&quot;http://www.st.com/web/en/resource/technical/document/application_note/CD00290365.pdf&quot; rel=&quot;nofollow&quot;&gt;App Note CD00290365.pdf&lt;/a&gt; for the LIS3DH.  Here is what that app note says, on page 27:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;There are two possible configurations for the 6D direction function:  &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;• 6D movement recognition: In this configuration the interrupt is generated when the device moves from a direction (known or unknown) to a different known direction. ...&lt;br&gt;&#xA;    •  6D position recognition: In this configuration the interrupt is generated when the device is stable in a known direction. ...&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the LSM9DS1 that you are using, you can leave OR enabled, set separate X,Y,Z threshholds in INT_GEN_THS_X_XL, INT_GEN_THS_Y_XL, INT_GEN_THS_Z_XL, and set the “Enable interrupt generation on accelerometer's X axis high event” (sim. for Y and Z) bits in the INT_GEN_CFG_XL register.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-25T17:44:05.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22281" PostTypeId="1" AcceptedAnswerId="22282" CreationDate="2016-03-25T18:43:48.410" Score="0" ViewCount="73" Body="&lt;p&gt;When I connect a piezo (to pin 8), it causes the output of my RTC to go haywire and throw &lt;code&gt;165&lt;/code&gt; errors into the results.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 165:37:4 // Connected piezo&#xA;2016/3/25 13:36:4&#xA;2165/165/45 13:36:4&#xA;2165/165/165 25:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/45 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/45 13:36:4&#xA;2165/165/165 165:165:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 37:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/27 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 25:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 25:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 25:36:4&#xA;2165/165/165 25:36:4&#xA;2016/3/25 13:36:4&#xA;2016/3/25 13:36:4&#xA;2165/165/165 25:36:4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's my current layout...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QKGnn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QKGnn.jpg&quot; alt=&quot;Photo of breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Worth noting:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Disconnecting the piezo instantly solves the problem.&lt;/li&gt;&#xA;&lt;li&gt;Connecting to any other pins also caused the issue.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the Fritzing diagram&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vu7bA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vu7bA.png&quot; alt=&quot;Fritzing diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and schematic&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7fgN6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7fgN6.png&quot; alt=&quot;Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the full code...&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;#define PIN 6&#xA;#define TONE 8&#xA;const int buttonPin = 7;&#xA;&#xA;long fadeTime = 1 * 60000L; // X minutes&#xA;int colorStops = 256;&#xA;int delaySpeed = fadeTime / colorStops;&#xA;int notes[] = {262,294,330,349};&#xA;int switchState = 1;         // variable for reading the pushbutton status&#xA;int timeHour = 13;&#xA;int timeMinute = 20;&#xA;uint32_t alarmLength = 5 * 60000L; // 5 minutes&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_RGB);&#xA;&#xA;void setup() {&#xA;  Serial.begin(57600);&#xA;&#xA;  if (! rtc.begin()) {&#xA;    Serial.println(&quot;Couldn't find RTC&quot;);&#xA;    while (1);&#xA;  }&#xA;  if (! rtc.isrunning()) {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    rtc.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;&#xA;  pinMode(buttonPin, INPUT_PULLUP); // initialize the pushbutton pin as an input&#xA;&#xA;  strip.begin();&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop() {&#xA;  DateTime now = rtc.now(); &#xA;&#xA;  Serial.print(now.year(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.month(), DEC);&#xA;  Serial.print('/');&#xA;  Serial.print(now.day(), DEC);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(now.hour(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.minute(), DEC);&#xA;  Serial.print(':');&#xA;  Serial.print(now.second(), DEC);&#xA;  Serial.println();&#xA;&#xA;  if (now.hour() == timeHour &amp;amp;&amp;amp; now.minute() == timeMinute &amp;amp;&amp;amp; now.second() == 00){&#xA;    // Fade in light&#xA;    for(int i = 1; i&amp;lt;colorStops; i++){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;        strip.setPixelColor(np, strip.Color(i,i,0));&#xA;      }&#xA;      strip.show();&#xA;      delay(delaySpeed);&#xA;    }&#xA;&#xA;    // Play tone after light fully bright&#xA;    for( uint32_t tStart = millis();  (millis()-tStart) &amp;lt; alarmLength; ){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;        strip.setPixelColor(np, strip.Color(random(100,255),random(100,255),random(100,255)));&#xA;      }&#xA;      strip.show();&#xA;&#xA;      tone(TONE, notes[random(0,3)]);&#xA;      delay(100);&#xA;    }&#xA;&#xA;    noTone(TONE);&#xA;&#xA;    for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;      strip.setPixelColor(np, strip.Color(0,0,0));&#xA;    }&#xA;    strip.show();&#xA;  }&#xA;}&#xA;&#xA;bool kill() {&#xA;  if (digitalRead(buttonPin) == LOW) {&#xA;    noTone(TONE);&#xA;&#xA;    for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;      strip.setPixelColor(np, strip.Color(0,0,0));&#xA;    }&#xA;    strip.show();&#xA;    return true;&#xA;  }&#xA;  else {&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="6936" LastEditDate="2016-04-15T09:28:14.807" LastActivityDate="2016-04-15T09:28:14.807" Title="Piezo connection causing RTC to go haywire" Tags="|arduino-uno|rtc|piezo|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="22282" PostTypeId="2" ParentId="22281" CreationDate="2016-03-25T19:10:30.730" Score="2" Body="&lt;p&gt;Add &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;pinMode(TONE,OUTPUT); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;code&gt;setup()&lt;/code&gt; to fix the problem.&lt;/p&gt;&#xA;" OwnerUserId="11754" LastEditorUserId="6936" LastEditDate="2016-03-26T15:46:45.630" LastActivityDate="2016-03-26T15:46:45.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22283" PostTypeId="2" ParentId="22247" CreationDate="2016-03-25T19:36:38.497" Score="1" Body="&lt;p&gt;pins 0 and 1 are used by the arduino for serial communication. You cant use pins 0 &amp;amp; 1  and then use software serial as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do want to use softwareserial try this code &lt;a href=&quot;https://gist.github.com/emil01/afedff4c3ba4625ebc75&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/emil01/afedff4c3ba4625ebc75&lt;/a&gt; Here i am using pins 2 &amp;amp; 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not want to use software serial you can try this code &lt;a href=&quot;https://gist.github.com/emil01/9a89800e383ec7f95b3f&quot; rel=&quot;nofollow&quot;&gt;https://gist.github.com/emil01/9a89800e383ec7f95b3f&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (bluetooth.available() &amp;gt;= 2 )&#xA;  {&#xA;   unsigned int servopos = bluetooth.read();&#xA;   unsigned int servopos1 = bluetooth.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are performing 2 consecutive read functions, this is not ideal as there can be data loss. A more ideal solution would be send a string with known string terminators and then parsing this string to get your required data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For e.g. you could send &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;S1:90\nS2:180\n&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;from this string you can clearly figure out the start and end of the string and accordingly manipulate the data for your need&lt;/p&gt;&#xA;" OwnerUserId="11754" LastActivityDate="2016-03-25T19:36:38.497" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22284" PostTypeId="2" ParentId="19180" CreationDate="2016-03-25T19:41:15.433" Score="0" Body="&lt;p&gt;After two months I finally found a solution. The problem was with USB drivers for my hackintosh. Few days ago new &lt;a href=&quot;http://www.tonymacx86.com/downloads.php?do=file&amp;amp;id=313&quot; rel=&quot;nofollow&quot;&gt;Multibeast 8.1&lt;/a&gt; was released with new USB drivers. After installing El Capitan 10.11.4 update and then installing USB drivers from Multibeast my Arduinos magically starter working again!&lt;/p&gt;&#xA;" OwnerUserId="16016" LastActivityDate="2016-03-25T19:41:15.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22285" PostTypeId="2" ParentId="22040" CreationDate="2016-03-25T19:52:20.760" Score="0" Body="&lt;p&gt;I know, I'm late, but I recommend, using python, as I most always do. The &lt;code&gt;serial&lt;/code&gt; module is part of the basic python installation&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;import serial&#xA;&#xA;S = serial.Serial('/dev/tty/USB0', 115200, timeout=1)&#xA;&#xA;S.write(&quot;Hello&quot;)&#xA;print S.readline()&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should echo &lt;code&gt;Hello&lt;/code&gt;, if the arduino sketch replies all incoming data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Very handy in combination with &lt;code&gt;ipython&lt;/code&gt;, where one can interactively poke around with the serial connection object.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastActivityDate="2016-03-25T19:52:20.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22286" PostTypeId="2" ParentId="22276" CreationDate="2016-03-25T20:22:47.327" Score="3" Body="&lt;p&gt;If you need to do the same comparison 4 times you can just put the result into a boolean variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean b = (x == y || x - y == 4 || x - y == -4)&#xA;&#xA;if( b )&#xA;{&#xA;     //do something...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are talking about optimizing the actual code, I shouldn't worry about it. The compiler is already pretty good at this. Here is the assembler code for it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void test(int x, int y)&#xA;{&#xA;    if(x == y || x - y == 4 || x - y == -4)&#xA;  a8:   86 17           cp  r24, r22&#xA;  aa:   97 07           cpc r25, r23&#xA;  ac:   39 f0           breq    .+14        ; 0xbc &amp;lt;_Z4testii+0x14&amp;gt;&#xA;  ae:   86 1b           sub r24, r22&#xA;  b0:   97 0b           sbc r25, r23&#xA;  b2:   84 30           cpi r24, 0x04   ; 4&#xA;  b4:   91 05           cpc r25, r1&#xA;  b6:   11 f0           breq    .+4         ; 0xbc &amp;lt;_Z4testii+0x14&amp;gt;&#xA;  b8:   04 96           adiw    r24, 0x04   ; 4&#xA;  ba:   09 f4           brne    .+2         ; 0xbe &amp;lt;_Z4testii+0x16&amp;gt;&#xA;    {&#xA;        asm (&quot;wdr&quot;);&#xA;  bc:   a8 95           wdr&#xA;  be:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;first it compare the two values x and y. Then is subtract y from x and compares it with 4. After that it gets the subtracted value from the previous step; adds 4; and check if it is &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to Dave X's suggestion; using &lt;code&gt;if(abs(x-y)&amp;lt;=4)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void test(int x, int y)&#xA;{&#xA;    if(abs(x-y)&amp;lt;=4)&#xA;  a8:   86 1b           sub r24, r22&#xA;  aa:   97 0b           sbc r25, r23&#xA;  ac:   04 96           adiw    r24, 0x04   ; 4&#xA;  ae:   09 97           sbiw    r24, 0x09   ; 9&#xA;  b0:   08 f4           brcc    .+2         ; 0xb4 &amp;lt;_Z4testii+0xc&amp;gt;&#xA;    {&#xA;         asm(&quot;wdr&quot;);&#xA;  b2:   a8 95           wdr&#xA;  b4:   08 95           ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So half the number of instructions needed. But as Paul said, this might not the fastest. This code always takes 5 instructions, while the previous code will only take 3 instructions if &lt;code&gt;x==y&lt;/code&gt;. So if 90% of the time x==y, the previous code will be faster 90% of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the assembler code, you can see how clever the compiler is. It first subtracts y from x. Then it adds 4. If &lt;code&gt;-4 &amp;lt;= x-y &amp;lt; 0&lt;/code&gt; the carry bit is set. Then it subtracts 9 (so it's like &lt;code&gt;(x-y)-5&lt;/code&gt; because of the previous &lt;code&gt;+4&lt;/code&gt;). If &lt;code&gt;0&amp;lt;= x-y &amp;lt;= 4&lt;/code&gt; the carry bit is set. It then check if the carry bits is set by either of the last to instructions. Pretty clever.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-03-26T08:57:23.553" LastActivityDate="2016-03-26T08:57:23.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22287" PostTypeId="1" AcceptedAnswerId="22298" CreationDate="2016-03-25T21:04:09.970" Score="1" ViewCount="740" Body="&lt;p&gt;My program reads the input and plays the appropriate note for 500 milliseconds. If I type in 'a', tone(8, 440, 500) will be called. I now want to add different note lengths so that in the future, I can play songs by sending code to Arduino. I was thinking that if 'a' is typed in, the program checks the next character. If it's a 1, it's a whole note. If it's a 2, it's a half note. My code doesn't work. What is wrong with it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if(Serial.available()&amp;gt;0){&#xA;    char character=Serial.read();&#xA;    if(character=='a'){&#xA;    char leng=Serial.read();&#xA;    if(leng=='1'){&#xA;    tone(8, 440, 1000);&#xA;    delay(1000);&#xA;    }&#xA;    else if(leng=='2'){&#xA;    tone(8, 440, 500);&#xA;    delay(500);&#xA;    }&#xA;&#xA;    }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-03-25T21:45:27.030" Title="How to Serial read two consecutive chars sent by computer to Arduino?" Tags="|serial|sound|piezo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22288" PostTypeId="1" CreationDate="2016-03-25T21:18:49.550" Score="0" ViewCount="1218" Body="&lt;p&gt;I want to use two ultrasonic sensors for counting incoming cars to a garage. What I want is: When both sensors detect the object then the counter should increase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me and give me an example? &lt;/p&gt;&#xA;" OwnerUserId="19608" LastEditorUserId="6936" LastEditDate="2016-03-26T01:40:09.087" LastActivityDate="2016-03-26T20:22:54.957" Title="Using two ultrasonic sensors for counting cars when they enter to a garage" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22289" PostTypeId="1" AcceptedAnswerId="22299" CreationDate="2016-03-25T21:26:32.597" Score="5" ViewCount="1914" Body="&lt;p&gt;On Linux, if you have more than one USB TTY device, the USB port name (&lt;code&gt;/dev/ttyUSBx&lt;/code&gt;) changes every time one is plugged in, and there's no easy way to know the new name without going and looking through dmesg.  &lt;a href=&quot;http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/&quot; rel=&quot;noreferrer&quot;&gt;It's trivial to set up a udev rule that creates a custom symlink&lt;/a&gt; so that my Arduino's FTDI can always be accessed through e.g., &lt;code&gt;/dev/ttyArduino&lt;/code&gt;, and this is the standard procedure for persistent access to USB devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can't make the IDE accept anything other than the &lt;code&gt;/dev/ttyUSBx&lt;/code&gt; names.  Even directly editing &lt;code&gt;preferences.txt&lt;/code&gt; is ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to instruct the IDE to use custom port names in order to access the Arduino through a symlink or other persistent name?&lt;/p&gt;&#xA;" OwnerUserId="19370" LastEditorUserId="6936" LastEditDate="2016-03-26T01:38:43.447" LastActivityDate="2016-03-28T00:55:10.630" Title="Can I specify custom port names in the Arduino IDE on Linux?" Tags="|arduino-ide|linux|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22290" PostTypeId="2" ParentId="22276" CreationDate="2016-03-25T21:31:35.247" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;test if two integers are equal or differ by 4&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;are exclusively multiples of 4.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That would mean that when a=20, b should be 16, 20 or 24. (But can't be 17, 18, 19, 21, 22 or 23)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you should check the most unlikely statement first. If it's likely to be well above x+4, check that first, if it's false, it'll just stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately you only have to check if it's less than x=y+4 or higher as x=y-4, this automatically includes x=y.&#xA;So checking if it's the same (which might be unlikely, might be redundant. Unless there is a very high chance of that being true.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-25T21:31:35.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22291" PostTypeId="5" CreationDate="2016-03-25T21:32:36.550" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-25T21:32:36.550" LastActivityDate="2016-03-25T21:32:36.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22292" PostTypeId="4" CreationDate="2016-03-25T21:32:36.550" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-25T21:32:36.550" LastActivityDate="2016-03-25T21:32:36.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22293" PostTypeId="5" CreationDate="2016-03-25T21:33:59.213" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-25T21:33:59.213" LastActivityDate="2016-03-25T21:33:59.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22294" PostTypeId="4" CreationDate="2016-03-25T21:33:59.213" Score="0" Body="Refers to code that present variables in the form of an array. " OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-26T10:37:34.243" LastActivityDate="2016-03-26T10:37:34.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22295" PostTypeId="5" CreationDate="2016-03-25T21:35:23.503" Score="0" Body="&lt;p&gt;In telecommunications, RS-232 is a standard for serial communication transmission of data. It formally defines the signals connecting between a DTE (data terminal equipment) such as a computer terminal, and a DCE (data circuit-terminating equipment or data communication equipment), such as a modem. The RS-232 standard is commonly used in computer serial ports.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-26T10:37:42.933" LastActivityDate="2016-03-26T10:37:42.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22296" PostTypeId="4" CreationDate="2016-03-25T21:35:23.503" Score="0" Body="it refers to the standard for serial communication transmission of data." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-26T10:37:39.790" LastActivityDate="2016-03-26T10:37:39.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22297" PostTypeId="1" AcceptedAnswerId="22321" CreationDate="2016-03-25T21:42:50.340" Score="1" ViewCount="1409" Body="&lt;p&gt;I have an Arduino Uno R3, Wireless Proto Shield and a XBee XB24-AWI-001 all hooked together. I'm using X-CTU software to access the XBee and change the properties of it. I did a little research and found out that if I want to access the XBee, I have to connect the GND to the RST pin (on the Proto Shield) or hold the RESET button on the board. This method works and when I do that, I can find the XBee on X-CTU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is - why do I have to do that? I'm probably wrong, but as far as I understand, if I have my Arduino connected to the computer, I'm accessing the ATmega microprocessor and that's the reason I can't access the XBee, but when I do the reset, I'm constantly resetting the microcontroller and that's the reason why I can access the XBee? Hopefully someone can explain this...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The link where I found the information about resetting (or removing) the ATmega microproccesor, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=213239.0&quot; rel=&quot;nofollow&quot;&gt;Using Arduino to Connect Xbee Serial to Computer&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18850" LastEditorUserId="6936" LastEditDate="2016-03-26T07:49:39.150" LastActivityDate="2016-03-26T15:51:02.633" Title="Issues with connecting XBee to Arduino Uno R3" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22298" PostTypeId="2" ParentId="22287" CreationDate="2016-03-25T21:45:27.030" Score="3" Body="&lt;p&gt;Presuming that code is the interior of &lt;code&gt;loop()&lt;/code&gt;, your Arduino will spin until a character arrives, that is, until &lt;code&gt;Serial.available()&amp;gt;0&lt;/code&gt; becomes true.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It then reads the character with &lt;code&gt;Serial.read()&lt;/code&gt; and if it's an &lt;code&gt;'a'&lt;/code&gt; immediately does another &lt;code&gt;Serial.read()&lt;/code&gt;.  In general, some delay occurs between characters arriving via a serial interface.  Whenever the serial buffer is empty, an immediate &lt;code&gt;Serial.read()&lt;/code&gt; will return -1 instead of an ASCII character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this problem, test for availability of a character before doing the second read.  For example, you could add&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (!Serial.available()){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;before the read, to delay until a character is available.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-25T21:45:27.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22299" PostTypeId="2" ParentId="22289" CreationDate="2016-03-25T21:54:36.313" Score="2" Body="&lt;p&gt;Consider using a device name of form ttyUSBnn, where nn is fairly large.  For example, in /dev you could say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo ln -s ttyUSB1 ttyUSB77&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;code&gt;ttyUSB77&lt;/code&gt; shows up in the IDE's ports list and can be selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I don't know how to set up that link using the &lt;code&gt;udev&lt;/code&gt; system, but imagine it can be done.)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-25T21:54:36.313" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22300" PostTypeId="1" AcceptedAnswerId="22305" CreationDate="2016-03-25T22:01:39.493" Score="5" ViewCount="10502" Body="&lt;p&gt;In Arduino Eclipse (v3, nightly build) I have not been able to load 'foreign' libraries, those written by me or someone else, so they are not among the available choices in the include-library dialogs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried adding them to a project as well as adding them as an available library resource using the built-in dialogs for doing so, but I don't see a way to select a library that isn't already included in those dialogs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ideal case would be a way for the Arduino Eclipse plugin to use the same boards and libraries as I use in my Arduino IDE installation, so that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An upgrade to the Arduino IDE would simultaneously upgrade the core libraries in Eclipse;&lt;/li&gt;&#xA;&lt;li&gt;An optional library would need installing in only one place;&lt;/li&gt;&#xA;&lt;li&gt;Modifying an optional library would only need to be done once, in one place.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The goal, as in an earlier question of mine, is to seamlessly permit using either IDE to advance a project. However, I'd be grateful to be able to add to my Eclipse installation any library of my choosing.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="18478" LastEditDate="2018-04-23T15:03:11.620" LastActivityDate="2018-08-11T16:15:59.903" Title="Can the Arduino Eclipse plugin use the libraries installed by the Arduino IDE?" Tags="|arduino-ide|library|core-libraries|eclipse|sloeber|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22301" PostTypeId="1" CreationDate="2016-03-25T22:34:42.577" Score="1" ViewCount="292" Body="&lt;p&gt;I am making a game where four different colored LEDs are flashing randomly, and when the green LED lights up, the user presses a button. If the user pushes the button when the LED is green, I want my 16x2 LCD screen to record points. And when the user presses the button on the wrong LED, i want the LCD screen to start over at &quot;0 points.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you give me some place to start on a code that will feed &quot;data&quot; from  each time the button is pushed to the LCD screen?&lt;/p&gt;&#xA;" OwnerUserId="19387" LastActivityDate="2017-06-18T08:44:12.503" Title="LED and LCD game" Tags="|arduino-uno|programming|led|lcd|button|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22302" PostTypeId="1" CreationDate="2016-03-25T22:40:09.663" Score="0" ViewCount="1314" Body="&lt;p&gt;I'm trying to experiment with a &quot;return&quot; function. Yet each time I try to run my program, there happens to be an error, like &quot;expected declaration before '}' token.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain the basics of a return function, and look at my code below to possibly see what the problem could be?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;int index;&#xA;&#xA;pinMode(10, INPUT); //button input&#xA;&#xA;int checkInput();&#xA;&#xA;if (digitalRead(10) == 0) {&#xA;&#xA;return 1;&#xA;else{&#xA;&#xA;return 0;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19387" LastActivityDate="2016-03-25T23:42:46.683" Title="&quot;Return&quot; Code Not Working" Tags="|arduino-uno|programming|code-review|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22303" PostTypeId="1" CreationDate="2016-03-25T20:28:20.373" Score="1" ViewCount="170" Body="&lt;p&gt;I bought an arduino compatible board here: &lt;a href=&quot;http://unsigned.io/projects/micromodem/&quot; rel=&quot;nofollow&quot;&gt;http://unsigned.io/projects/micromodem/&lt;/a&gt;&#xA;and am trying to flash new supported firmware onto it. The only instructions given to flash the board is to use the command avrdude -p m328p -c arduino -P /dev/ttyUSB0 -b 115200 -F -U flash:w:YourFirmwareFile.hex . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to follow the tutorial here using an Uno as a programmer: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader#uploading-code---hard-way&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader#uploading-code---hard-way&lt;/a&gt; but I don't know what to use for the fuse settings. I've tried a few different fuse settings such as the one for the Uno, and default 328p ones using a fuse calculator but it seems like they all have unpredictable results. Some fuse settings make it so that I can't connect  to the COM port at all to monitor the traffic, and others let me connect, but send a message of . I'm expecting an introduction message from the firmware that is supposed to be built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help. &lt;/p&gt;&#xA;" OwnerUserId="19637" OwnerDisplayName="user3474264" LastActivityDate="2016-03-28T06:13:29.700" Title="How to Determine Fuse Settings" Tags="|firmware|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22304" PostTypeId="1" CreationDate="2016-03-25T22:55:39.420" Score="1" ViewCount="494" Body="&lt;p&gt;I have created an arduino prototype using the exact instructions found on this page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Standalone&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I plug in the micro USB power supply and try to upload a program, here's the error I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0&#xA;&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried the following solutions, to no avail:&#xA;1) press the restart button (in a variety of ways and lengths of time)&#xA;2) Enable verbose output &#xA;3) trying the different board types in the Arduino IDE&#xA;4) Checking the COM port&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what to do I've basically tried everything I could find, on this website and others. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you guys can help! Thanks very much :)&lt;/p&gt;&#xA;" OwnerUserId="19611" LastEditorUserId="11529" LastEditDate="2016-03-26T23:35:13.450" LastActivityDate="2017-08-20T12:52:55.567" Title="Arduino Prototype on Breadboard: &quot;avrdude: stk500_recv(): programmer is not responding&quot;" Tags="|serial|programming|sketch|prototype|" AnswerCount="2" CommentCount="6" ClosedDate="2017-08-20T14:43:06.137" ContentLicense="CC BY-SA 3.0" />
  <row Id="22305" PostTypeId="2" ParentId="22300" CreationDate="2016-03-25T23:01:17.753" Score="2" Body="&lt;p&gt;I fear that what you want is not 100% possible.&lt;br&gt;&#xA;For libraries I am 100% sure it will work but the problem is the platforms.&lt;br&gt;&#xA;&lt;em&gt;UPDATE arduino IDE (no longer)? decompresses libraries and as such the libraries are unusable in Sloeber.&lt;/em&gt;    &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Lets start with the Libraries&lt;/strong&gt;&#xA;What you do is:&#xA;In arduino eclipse ide remove all libraries from the library manager.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In windows-&gt;preferences-&gt;arduino-&gt;&quot;private libraries path&quot; add the libraries folder in the arduino IDE install and add the libraries folder in the arduino15 folder maintained by the library manager.&lt;br&gt;&#xA;It is important to point to the parent folder containing the libraries. All subfolders are assumed to be libraries.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Then the boards&lt;/strong&gt;&#xA;The problem here is that the boardsmanager adds environment variables to link boards to tools. You may have read remarks about A.RUNTIME.TOOLS.AVR-GCC.PATH and A.RUNTIME.TOOLS.AVRDUDE.PATH not being defined. Well it is the boardsmanager that maintains these based on json file content.&#xA;If you can limit yourself to 1 version of AVR, SAM, AVRDUDE, BSON,... tool chain you can &quot;make it work&quot; as follows:&lt;br&gt;&#xA;&lt;strong&gt;Step 1:&lt;/strong&gt; Keep as little boards as possible installed. &lt;strong&gt;You have to keep at least 1&lt;/strong&gt; or the plugin will reinstall the AVR boards of Arduino when started.&lt;br&gt;&#xA;&lt;strong&gt;Step 2:&lt;/strong&gt; In windows-&gt;preferences-&gt;arduino-&gt;&quot;private hardware path&quot; add the hardware folder in the arduino IDE install and add the packages folder in the arduino15 folder maintained by the Arduino IDE boards manager.&lt;br&gt;&#xA;&lt;strong&gt;Step 3:&lt;/strong&gt; Recreate the project in eclipse as described in your other question.&lt;br&gt;&#xA;&lt;strong&gt;Step 4:&lt;/strong&gt; If the build fails modify the [eclipse installation]/arduinoPlugin/post and pre processing files to try to get it to work.&lt;br&gt;&#xA;&lt;strong&gt;Step 5:&lt;/strong&gt; in project properties-&gt;Arduino select apply and OK (this will take your changes in step 4 into account)&lt;br&gt;&#xA;&lt;strong&gt;Step 6:&lt;/strong&gt; Goto Step 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck&#xA;Jantje&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2018-04-23T09:51:31.897" LastActivityDate="2018-04-23T09:51:31.897" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22306" PostTypeId="2" ParentId="10330" CreationDate="2016-03-25T23:05:00.767" Score="1" Body="&lt;p&gt;You can use photo cells. Just get some light sensors and direct lasers on to them. I got 100 lasers for £10 from eBay. You don't need to connect them to any controller, just connect them to a power supply to provide light for sensors. The sensors I got from eBay were, I think, 100 for about £5 or £10, then you can use an Arduino Mega and connect sensors to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you cross the sensor, light will trigger and send a signal to Excel (you can use parallax program) and use Arduino code for interrupts when the sensor is triggered, you will get data to Excel (time and triggered sensor). If you call sensors like: first one 1 millisecond, 2 milliseconds, and so on, so you know what distance and what speed. But I think would be tricky if you need to measure a few guys simultaneously. It should work for single one though.&lt;/p&gt;&#xA;" OwnerUserId="16282" LastEditorUserId="6936" LastEditDate="2016-03-26T02:44:30.247" LastActivityDate="2016-03-26T02:44:30.247" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22307" PostTypeId="2" ParentId="22302" CreationDate="2016-03-25T23:06:40.860" Score="3" Body="&lt;p&gt;It has nothing to do with the retun statements. You have to close each { with a }. you are missing one.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   {&#xA;int index;&#xA;&#xA;pinMode(10, INPUT); //button input&#xA;&#xA;int checkInput();&#xA;&#xA;if (digitalRead(10) == 0) {&#xA;&#xA;return 1;}&#xA;else{&#xA;&#xA;return 0;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-25T23:06:40.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22308" PostTypeId="1" AcceptedAnswerId="22309" CreationDate="2016-03-25T23:13:09.837" Score="1" ViewCount="712" Body="&lt;p&gt;I see some old library code that initializes SPI this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    SPI.begin();&#xA;    SPI.setClockDivider(2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It does not use &lt;code&gt;beginTransaction&lt;/code&gt;/&lt;code&gt;endTransaction&lt;/code&gt; blocks, and &lt;code&gt;setClockDivider&lt;/code&gt; is now deprecated. The current way to use SPI is to use transaction blocks where you pass the settings in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the equivalent to this code using transaction blocks? Also, since the other settings (max speed, data order, data mode) aren't specified in the above code, there must be defaults. What are these defaults?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="18795" LastEditDate="2016-03-25T23:19:38.450" LastActivityDate="2016-03-26T06:43:33.543" Title="What is the equivalent of this old SPI code using the current SPI library?" Tags="|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22309" PostTypeId="2" ParentId="22308" CreationDate="2016-03-25T23:23:10.673" Score="0" Body="&lt;p&gt;The default is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Mode 0&lt;/li&gt;&#xA;&lt;li&gt;MSBFIRST&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Not sure on the default speed. But:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setClockDivider()&lt;/code&gt; sets a speed relative to the system clock. So it's impossible to say what speed that will be since it'll be different on 8MHz boards compared to 16MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;setClockDivider(2)&lt;/code&gt; would be the same as using F_CPU/2 as a speed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T23:23:10.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22310" PostTypeId="2" ParentId="22302" CreationDate="2016-03-25T23:42:46.683" Score="3" Body="&lt;p&gt;That piece of &quot;code&quot; is, I am afraid to say, complete gibberish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Passed through Artistic Style to reformat it ends up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    int index;&#xA;&#xA;    pinMode(10, INPUT); //button input&#xA;&#xA;    int checkInput();&#xA;&#xA;    if (digitalRead(10) == 0) {&#xA;        return 1;&#xA;        else {&#xA;            return 0;&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting from the top of the program the errors are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You have a bracket hanging at the front of the snippet for some reason&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;int checkInput();&lt;/code&gt; is a function prototype (forward declaration) and doesn't do anything other than tell the compiler that you will define this function somewhere else in your sketch.&lt;/li&gt;&#xA;&lt;li&gt;You are lacking the balancing bracket for the first portion of your &lt;code&gt;if&lt;/code&gt; statement, so your &lt;code&gt;else { return 0; }&lt;/code&gt; never runs.&lt;/li&gt;&#xA;&lt;li&gt;There is no balancing bracket for the strange one by itself at the start of the snippet.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short, I have a feeling you need to learn the basics of C syntax.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-25T23:42:46.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22311" PostTypeId="1" AcceptedAnswerId="22312" CreationDate="2016-03-26T01:40:48.320" Score="1" ViewCount="796" Body="&lt;p&gt;I have a potentiometer with switch, that seems to be working a little wonky (Keep in mind I have tried this with a few different pots and they all behave the same way which leads me to believe I am wiring them wrong).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can easily hookup the potentiometer and it's three terminals on the side, 1 being ground, 2 being output, 3 being input power. I can monitor it's value on a serial port with Arduino.  However when I try and test the switch, which are two terminals on the bottom of the pot.  I get an on signal when the pot is on, but when it is clicked off I get a random on/off signal.  As in it reads that it is sort of on but never truly reads off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now I am simply giving it 5v from the Arduino to both the switch and the third terminal.  Should I be giving the switch power via a capacitor? Not sure, have not tried that yet but that may smooth out my readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="19501" LastActivityDate="2016-03-26T02:01:25.580" Title="Potentiometer with switch wiring question. Not reading correctly" Tags="|potentiometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22312" PostTypeId="2" ParentId="22311" CreationDate="2016-03-26T02:01:25.580" Score="3" Body="&lt;p&gt;From your description of switch wiring, it sounds like you have one of the switch leads attached to +5 V and the other switch lead to an input.&lt;/p&gt;&#xA;&lt;p&gt;As noted in comments and answers to  “&lt;a href=&quot;https://arduino.stackexchange.com/q/21082&quot;&gt;Why all unset pins of my Arduino Uno are outputting 2 volts?&lt;/a&gt;”, such an input will read high when the switch is closed, and will read randomly when it is open, because an input is a high-impedance device that can accumulate charge:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;... input impedance typically can be taken as 100 MΩ for design purposes. ... Each pin has a few pF (5-10?) of capacitance ... which in general is small compared to stray capacitances of attached wiring.&lt;/p&gt;&#xA;&lt;p&gt;When stray electromagnetic fields charge the pin and stray capacitances, a small voltage develops on the pin. You could connect a 1 to 10 MΩ resistor between the pin and ground, to avoid the [voltage] you are seeing.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The easy fix for the problem is to attach one switch-lead to ground, one to an input pin, and initialize the pin with &lt;code&gt;INPUT_PULLUP&lt;/code&gt; pinmode instead of just &lt;code&gt;INPUT&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-26T02:01:25.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22313" PostTypeId="1" CreationDate="2016-03-26T04:22:48.983" Score="5" ViewCount="2660" Body="&lt;p&gt;Are there any MQTT libraries that do not block while connecting?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently using PubSubClient, and the connection part contains this code:&#xA;&lt;a href=&quot;https://github.com/knolleary/pubsubclient/blob/master/src/PubSubClient.cpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/knolleary/pubsubclient/blob/master/src/PubSubClient.cpp&lt;/a&gt;&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        while (!_client-&amp;gt;available()) {&#xA;            unsigned long t = millis();&#xA;            if (t-lastInActivity &amp;gt;= ((int32_t) MQTT_SOCKET_TIMEOUT*1000UL)) {&#xA;                _state = MQTT_CONNECTION_TIMEOUT;&#xA;                _client-&amp;gt;stop();&#xA;                return false;&#xA;            }&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like my main loop to continue, or a callback to be called, while the MQTT connection is established, rather than waiting for ages if the MQTT server is unavailable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a modification to take a callback function, and called it in an else clause added to that if statement, and discovered that the blocking delay is not this while loop. I think it's in the _client-&gt;connect at the start of the method.&lt;/p&gt;&#xA;" OwnerUserId="18774" LastEditorUserId="37523" LastEditDate="2019-05-13T15:56:23.253" LastActivityDate="2022-05-31T20:35:42.357" Title="Non-blocking MQTT library" Tags="|esp8266|callbacks|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22315" PostTypeId="1" AcceptedAnswerId="22316" CreationDate="2016-03-26T05:27:09.880" Score="1" ViewCount="775" Body="&lt;p&gt;I recently found that standard servos only rotate 90deg total rotation for a pulse width range of 1-2 usec.  To rotate 180deg total rotation they need a .5-2.5 usec pulse range.  The arduino is programmed to only output the 1-2 usec range for 0-180 deg rotation.  Is there a way to make the arduino output the .5-2.5 usec pulse range to get full 180deg rotation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-03-26T05:43:31.503" Title="Can the servo pulse width range be changed?" Tags="|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22316" PostTypeId="2" ParentId="22315" CreationDate="2016-03-26T05:37:47.640" Score="2" Body="&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Reference/ServoAttach&quot; rel=&quot;nofollow noreferrer&quot;&gt;Servo Attach&lt;/a&gt; method has two forms,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servo.attach(pin) &#xA;servo.attach(pin, min, max)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the latter form, you can specify values for the min and max microseconds that &lt;code&gt;servo.write()&lt;/code&gt; will use to represent 0° and 180° respectively.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, default values are 544 μs and 2400 μs, which is not so different than the range you say you want, so perhaps some other problem is afflicting your setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, as explained in &lt;a href=&quot;https://arduino.stackexchange.com/a/20814/3917&quot;&gt;my answer&lt;/a&gt; to question  “&lt;a href=&quot;https://arduino.stackexchange.com/q/20810&quot;&gt;Change Servo Speed With RedBearLabs BLE Shield&lt;/a&gt;”, you can issue &lt;code&gt;servo.write(value)&lt;/code&gt; calls with value in microseconds instead of in degrees, which may allow more precise control.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-03-26T05:43:31.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22318" PostTypeId="2" ParentId="22308" CreationDate="2016-03-26T06:43:33.543" Score="0" Body="&lt;p&gt;I have example code &lt;a href=&quot;http://www.gammon.com.au/forum/?id=10892&amp;amp;reply=9#reply9&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#if SPI_HAS_TRANSACTION&#xA;  SPI.usingInterrupt (0);  // I am using external interrupt 0&#xA;  SPI.usingInterrupt (1);  // I am also using external interrupt 1&#xA;  SPI.beginTransaction (SPISettings (2000000, MSBFIRST, SPI_MODE0));  // 2 MHz clock&#xA;#else&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV8);&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  SPI.setDataMode(SPI_MODE0);&#xA;#endif // SPI_HAS_TRANSACTION&#xA;&#xA;digitalWrite (SS, LOW);        // assert Slave Select&#xA;byte foo = SPI.transfer (42);  // do a transfer&#xA;digitalWrite (SS, HIGH);       // de-assert Slave Select&#xA;&#xA;#if SPI_HAS_TRANSACTION&#xA;  SPI.endTransaction ();   // allow external interrupts to fire now&#xA;#endif // SPI_HAS_TRANSACTION&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The default setting for SPI is to use the system clock speed divided by four.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-26T06:43:33.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22319" PostTypeId="1" AcceptedAnswerId="22324" CreationDate="2016-03-26T07:41:05.700" Score="3" ViewCount="1178" Body="&lt;p&gt;I'm trying to understand if the following bit of code is subject to memory fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say I incrementally build a string within a function and I don't know how large the string should be. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String f() {&#xA;    String s = String(&quot;&quot;);&#xA;    s += &quot;a&quot;; // ...&#xA;    s += &quot;bc&quot;; // ...&#xA;    return s;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;String&lt;/code&gt; object does dynamic memory allocation internally, but &lt;code&gt;s&lt;/code&gt; is on the stack, so once the function returns, the &lt;code&gt;s&lt;/code&gt; object presumably deallocates and dynamically allocated memory is freed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before this happens, the &lt;code&gt;String&lt;/code&gt; object to be returned must be copied from &lt;code&gt;s&lt;/code&gt;. Since &lt;code&gt;String&lt;/code&gt; objects hold internal data in dynamically allocated buffers, this means that the &lt;code&gt;s&lt;/code&gt; internal buffer is allocated, then the return object internal buffer is allocated, then the &lt;code&gt;s&lt;/code&gt; internal buffer is deallocated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The return object internal buffer allocation is sandwiched between the &lt;code&gt;s&lt;/code&gt; object alloc and dealloc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To me, this implies that this will cause memory fragmentation. Am I reading this properly, or is this not the case? If so, does this also imply that functions like &lt;code&gt;Serial.readString&lt;/code&gt; are also subject to memory fragmentation? &lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="10794" LastEditDate="2016-03-26T22:14:57.573" LastActivityDate="2016-03-27T20:36:31.370" Title="Is this function subject to memory fragmentation?" Tags="|c++|memory-usage|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22320" PostTypeId="1" AcceptedAnswerId="22322" CreationDate="2016-03-26T07:42:22.083" Score="3" ViewCount="710" Body="&lt;p&gt;I came across the problem to handle two DHT22 devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the &lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;Adafruit DHT Sensor library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since my Arduino sketch works as a &quot;relay&quot; for Serial commands on a host, I tried to wire up and dynamically instantiate DHT22. With no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked the source and found, that the DHT object only gets constructed &lt;strong&gt;before&lt;/strong&gt; &lt;code&gt;setup()&lt;/code&gt; as a constant in the examples, because the library is written that way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a quick &lt;a href=&quot;https://github.com/SteffenKockel/DHT-sensor-library/commit/c0dff8755a94e587eac674cfc0e4f555f5a2b30e#diff-e3bd93bd1d2964ed65bbaf66e517e5a7&quot; rel=&quot;nofollow&quot;&gt;hack&lt;/a&gt;, which works, but seems ugly to me:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DHT.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {&#xA;-  _pin = pin;&#xA;-  _type = type;&#xA;-  #ifdef __AVR&#xA;-    _bit = digitalPinToBitMask(pin);&#xA;-    _port = digitalPinToPort(pin);&#xA;-  #endif&#xA;+  //_pin = pin;&#xA;+  //_type = type;&#xA;+  //#ifdef __AVR&#xA;+  //  _bit = digitalPinToBitMask(pin);&#xA;+  //  _port = digitalPinToPort(pin);&#xA;+  //#endif&#xA;&#xA;...&#xA;&#xA;-void DHT::begin(void) {&#xA;+void DHT::begin(uint8_t pin, uint8_t type, uint8_t count) {&#xA;+  _pin = pin;&#xA;+  _type = type;&#xA;+  #ifdef __AVR&#xA;+    _bit = digitalPinToBitMask(pin);&#xA;+    _port = digitalPinToPort(pin);&#xA;+  #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DHT.h*&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-   void begin(void);&#xA;+   void begin(uint8_t pin, uint8_t type, uint8_t count=6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I moved a few lines from the constructor to the &lt;code&gt;begin()&lt;/code&gt; method. The whole thing works. I can even rewire &amp;amp; change the data-pin dynamically while the Arduino runs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is the hacked away behavior a bug or feature?&lt;/li&gt;&#xA;&lt;li&gt;Would my solution be good enough for a pull request to Adafruit? I would clean it up beforehand.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="10794" LastEditDate="2016-03-26T20:50:43.260" LastActivityDate="2016-03-26T20:52:59.410" Title="Why does DHT-library (and others) only allow one object instance?" Tags="|programming|library|adafruit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22321" PostTypeId="2" ParentId="22297" CreationDate="2016-03-26T07:47:06.663" Score="0" Body="&lt;p&gt;I am slightly surprised that you can actually talk to the XBee from your PC over USB with the XBee in the shield. XBee shields are generally designed for the XBee to be used by the Arduino &lt;em&gt;only&lt;/em&gt;. The fact that you can actually talk to the XBee from the PC using X_CTU with the XBee in the Arduino shield, by holding down reset, seems to either be a quirk or a &lt;em&gt;feature&lt;/em&gt; of the shield&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Generally to use X-CTU to talk to the XBee, one would use an XBee explorer board or a Development board. One would configure the XBee completely in the Explorer dongle and then transfer the XBee to the shield for the Arduino to use it.&lt;/p&gt;&#xA;&lt;p&gt;See the thread on the Digi forums, &lt;a href=&quot;http://www.digi.com/support/forum/49165/xbee-s1-xctu-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;xbee s1 xctu arduino&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The shield is not design for writing and reading firmware to and from&#xA;the XBee module. It is only designed for basic two way communications.&#xA;If you want to read or write firmware to the module, you need to use a&#xA;board that is designed for it such as the XBIB boards from Digi.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;See also &lt;a href=&quot;https://electronics.stackexchange.com/questions/8882/can-an-xbee-be-programmed-with-an-xbee-shield&quot;&gt;Can an XBee be programmed with an XBee Shield&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, hopefully someone with more knowledge of the internals of an Uno and XBee shield than I, could explain the actual electrical reasoning behind this issue. I have attempted to explain it below in the footnote.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Having said all of that, looking at some of my XBee shields, a couple have a microswitch, that enables the XBee to talk to &lt;em&gt;either&lt;/em&gt; the Arduino &lt;em&gt;or&lt;/em&gt; the USB, but &lt;em&gt;not both&lt;/em&gt; at the same time. So, I guess that the need to hold the reset on your shield is because you do not have such a microswitch.&lt;/p&gt;&#xA;&lt;p&gt;So the reason being, is that the Arduino and the USB can not talk to the XBee at the same time, as there would be conflict on the Rx and Tx serial lines - see this thread, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=187950.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;UNO + Sparkfun's Xbee Shield Always Reset if Receiving Data From X-CTU Terminal&lt;/a&gt; which hints at the same thing. Two comments of note from that thread are:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It would be a lot simpler to debug the issue if you put the switch in the other position, and used SoftwareSerial to talk to the XBee and Serial to talk to the PC. Using one port to talk to two devices IS going to frustrate you no end.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Note that a communication application connected to an arduino that opens a com port, sends data, then closes may cause the arduino to reset.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As a (really wild) guess, I would imagine that the &lt;strong&gt;USB-to-TTL IC&lt;/strong&gt;'s DTR line, or equivalent (?), is [logically] tied to the Arduino's RST line, so that if the PC tries to communicate to the XBee, it ends up resetting it, rather than signalling to the XBee that it is ready to communicate.&lt;/p&gt;&#xA;&lt;p&gt;Note: The &lt;strong&gt;USB-to-TTL IC&lt;/strong&gt; could be a FTDI, ATmega 4U2/8U2/16U2 or an FTDI clone, depending on the variety of Uno that you possess.&lt;/p&gt;&#xA;&lt;h3&gt;Addendum&lt;/h3&gt;&#xA;&lt;p&gt;I do wonder why the switch is there, if it doesn't end up working correctly. Regardless, I would still get a $3 explorer board clone to use with X-CTU. Be careful which one you buy as not all of them work with OS X, if you use a Mac, see the end of &lt;a href=&quot;https://gr33nonline.wordpress.com/2015/12/13/usb-ttl-devices/&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB-TTL interface devices on OS X&lt;/a&gt;. That explorer,  &lt;a href=&quot;http://www.ebay.co.uk/itm/161894812598&quot; rel=&quot;nofollow noreferrer&quot;&gt;XBee USB Adapter Bluetooth Bee FT232RL USB to Serial Port Module for PC Arduino&lt;/a&gt;, is good value for money and compatible with WinTel, LinTel and OS X machines:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ELlYY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ELlYY.jpg&quot; alt=&quot;XBee explorer&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-26T15:51:02.633" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22322" PostTypeId="2" ParentId="22320" CreationDate="2016-03-26T09:18:58.163" Score="3" Body="&lt;p&gt;There is nothing wrong with the library. It does not allow just one object instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is wrong is your way of using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It, and many other libraries, specify the pin numbers and other (under normal usage) static data in the constructor. You want to have two objects then create two objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it seems you want to change that static data. So you need to construct differently.  Instead of statically declaring your objects you need to be dynamic. Use new and delete. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DHT *myDHT = NULL;&#xA;&#xA;myDHT = new DHT(4,5);&#xA;// do something&#xA;// change pins&#xA;delete myDHT;&#xA;myDHT = new DHT(6,7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-26T09:18:58.163" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22323" PostTypeId="2" ParentId="3680" CreationDate="2016-03-26T09:21:37.277" Score="4" Body="&lt;p&gt;This is quite easy! You have to customize the ftdi chips firmware and add an udev rule:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, get &lt;code&gt;ftdi_eeprom&lt;/code&gt; via &lt;code&gt;apt-get&lt;/code&gt; or from the sources. Identify your device via lsusb and get the id:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;lsusb&#xA;&#xA;Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC&#xA;....&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Prepare a config and make sure, that &lt;code&gt;vendor_id&lt;/code&gt; and &lt;code&gt;product_id&lt;/code&gt; match. Customize the strings in the &lt;code&gt;Strings&lt;/code&gt; section to get a unique id for your device. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;vendor_id=0x0403    # Vendor ID&#xA;product_id=0x6001   # Product ID&#xA;&#xA;max_power=50        # Max. power consumption: value * 2 mA. Use 0 if self_powered = true.&#xA;&#xA;###########&#xA;# Strings #&#xA;########### &#xA;manufacturer=&quot;FTDI&quot;     # Manufacturer&#xA;product=&quot;Arduino Nano&quot;      # Product&#xA;serial=&quot;arduino1&quot;       # Serial&#xA;&#xA;###########&#xA;# Options #&#xA;###########&#xA;self_powered=false  # Turn this off for bus powered&#xA;remote_wakeup=false # Turn this on for remote wakeup feature&#xA;use_serial=true     # Use the serial number string&#xA;&#xA;# Normally out don't have to change one of these flags&#xA;# BM_type_chip=true         # Newer chips are all BM type&#xA;in_is_isochronous=false     # In Endpoint is Isochronous&#xA;out_is_isochronous=false    # Out Endpoint is Isochronous&#xA;suspend_pull_downs=false    # Enable suspend pull downs for lower power&#xA;change_usb_version=false    # Change USB Version&#xA;usb_version=0x0200      # Only used when change_usb_version is enabled&#xA;&#xA;########&#xA;# Misc #&#xA;########&#xA;&#xA;filename=&quot;eeprom.old&quot;   # Filename, leave empty to skip file writing&#xA;cbus0=RXLED#&#xA;cbus1=TXLED#&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Dump the current ftdi-firmware:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ftdi_eeprom --read-eprom&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This command creates &lt;code&gt;${pwd}/eeprom.old&lt;/code&gt;, which contains the current firmware on the ftdi. &lt;strong&gt;Backup&lt;/strong&gt; this file &lt;strong&gt;before continuing&lt;/strong&gt;, because during &lt;code&gt;flash-eeprom&lt;/code&gt; the file gets rewritten. After the backup, flash the ftdi:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ftdi_eeprom --flash-eeprom myconfig.conf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, create an udev rule, like so&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEMS==&quot;usb&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, SYMLINK+=&quot;$attr{serial}&quot;, OWNER=&quot;bananapi&quot;, GROUP=&quot;pi&quot;, MODE=&quot;0777&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;/etc/udev/rules.d/90-arduino-usb.rules&lt;/code&gt; and restart udev. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;service udev restart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unplug and re-plug your device and try&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ls -lah /dev/arduino1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where &lt;code&gt;arduino1&lt;/code&gt; is the string defined under &lt;code&gt;serial&lt;/code&gt; in the above &lt;code&gt;.conf&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also: &lt;a href=&quot;https://arduino.stackexchange.com/questions/22252/risks-of-ftdi-eeprom-tx-always-high-after-flashing&quot;&gt;Risks of ftdi_eeprom? - TX always high after flashing&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-03-26T09:21:37.277" CommentCount="0" CommunityOwnedDate="2016-03-26T09:21:37.277" ContentLicense="CC BY-SA 3.0" />
  <row Id="22324" PostTypeId="2" ParentId="22319" CreationDate="2016-03-26T09:33:44.463" Score="3" Body="&lt;p&gt;Pretty much every use of the String object can lead to memory fragmentation. Especially concatenating and copying objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cover it here: &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/04/the-evils-of-arduino-strings/&quot; rel=&quot;nofollow&quot;&gt;https://hackingmajenkoblog.wordpress.com/2016/02/04/the-evils-of-arduino-strings/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are much better off never using the String class and instead sticking to basic C strings (char arrays).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-26T09:33:44.463" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22327" PostTypeId="1" AcceptedAnswerId="22337" CreationDate="2016-03-26T14:14:10.193" Score="-1" ViewCount="65" Body="&lt;p&gt;I'm new to Arduino and I was wondering how to add an SD card to Arduino so it can store more code and also store files such as text files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there such a shield, and if so, any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="19625" LastEditorUserId="4628" LastEditDate="2017-01-27T03:44:02.050" LastActivityDate="2017-01-27T03:44:02.050" Title="How to add SD card to store data" Tags="|shields|sd-card|" AnswerCount="2" CommentCount="4" ClosedDate="2017-02-02T21:10:34.940" ContentLicense="CC BY-SA 3.0" />
  <row Id="22328" PostTypeId="2" ParentId="22319" CreationDate="2016-03-26T14:29:01.513" Score="1" Body="&lt;p&gt;Memory fragmentation is hard to predict, as it depends on how your&#xA;different allocation patters interact. This single pattern, &lt;em&gt;per se&lt;/em&gt;,&#xA;looks safe. By safe I mean that &lt;em&gt;if&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;your heap is not fragmented when you enter this function, and&lt;/li&gt;&#xA;&lt;li&gt;you do no dynamic allocation inside the function other than growing the&#xA;string,&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;then the string will be allocated to the top of the heap and grow from&#xA;there without moving or making holes. You can check this is the case by&#xA;looking at the address of the string's internal buffer, which is given&#xA;by the &lt;code&gt;c_str()&lt;/code&gt; method. It should not change inside the function:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;String f() {&#xA;    String s = String(&quot;&quot;);&#xA;    const char * p = s.c_str();&#xA;    s += &quot;a&quot;; // ...&#xA;    s += &quot;bc&quot;; // ...&#xA;    if (p != s.c_str())&#xA;        Serial.println(F(&quot;Warning: memory fragmentation.&quot;));&#xA;    return s;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I wrote this small test program to show the behaviour of the&#xA;heap when you use string concatenation this way:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;extern uintptr_t __brkval;&#xA;&#xA;String f() {&#xA;    String s(&quot;&quot;);&#xA;    const char * p = s.c_str();&#xA;    Serial.print(F(&quot;  f(): string buffer @ 0x&quot;));&#xA;    Serial.println((uintptr_t) p, 16);&#xA;    for (int i = 0; i &amp;lt; random(8) + 1; i++)&#xA;        s += random(2) ? &quot;a&quot;: &quot;bc&quot;;&#xA;    if (p != s.c_str())&#xA;        Serial.println(F(&quot;Warning: memory fragmentation.&quot;));&#xA;    Serial.print(F(&quot;        top of heap at 0x&quot;));&#xA;    Serial.println(__brkval, 16);&#xA;    return s;&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.print(F(&quot;***     heap starts at 0x&quot;));&#xA;    Serial.println((uintptr_t) __malloc_heap_start, 16);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.print(F(&quot;loop(): top of heap at 0x&quot;));&#xA;    Serial.println(__brkval, 16);&#xA;    String s = f();&#xA;    Serial.print(F(&quot;  f() returned &quot;));&#xA;    Serial.println(s);&#xA;    Serial.print(F(&quot;        with buffer at 0x&quot;));&#xA;    Serial.println((uintptr_t) s.c_str(), 16);&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of the program is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;***     heap starts at 0x1D7&#xA;loop(): top of heap at 0x0&#xA;  f(): string buffer @ 0x1D9&#xA;        top of heap at 0x1DF&#xA;  f() returned abcbc&#xA;        with buffer at 0x1D9&#xA;loop(): top of heap at 0x1D7&#xA;  f(): string buffer @ 0x1D9&#xA;        top of heap at 0x1DF&#xA;  f() returned abcbc&#xA;        with buffer at 0x1D9&#xA;loop(): top of heap at 0x1D7&#xA;  f(): string buffer @ 0x1D9&#xA;        top of heap at 0x1DC&#xA;  f() returned aa&#xA;        with buffer at 0x1D9&#xA;loop(): top of heap at 0x1D7&#xA;  f(): string buffer @ 0x1D9&#xA;        top of heap at 0x1E2&#xA;  f() returned aabcabca&#xA;        with buffer at 0x1D9&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The very first “top of heap at” is bogus because at this point the&#xA;malloc library has not been initialized. Besides that, you can see here&#xA;that:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the heap is always empty (top = bottom) at the beginning of &lt;code&gt;loop()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;the string is always allocated at the same place&lt;/li&gt;&#xA;&lt;li&gt;the heap size inside &lt;code&gt;f()&lt;/code&gt; varies depending on the string's length&lt;/li&gt;&#xA;&lt;li&gt;the string is not copied when returned to the caller, as the internal&#xA;buffer is still at the same address.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However, if the statement &lt;code&gt;String s = f();&lt;/code&gt; is replaced by&#xA;&lt;code&gt;String s; s = f();&lt;/code&gt;, then the string is copied when returned to the&#xA;caller, which doubles the amount of RAM required to handle it. This is&#xA;presumably because only the first form allows &lt;a href=&quot;https://stackoverflow.com/questions/12953127&quot;&gt;copy elision&#xA;optimization&lt;/a&gt;. (This&#xA;paragraph was added after reading Nick Gammon's answer, which made me&#xA;realize the copy elision issue).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that this works so nicely only because there is nothing&#xA;else doing dynamic allocation in this small program. This usage pattern&#xA;is safe, but once you start doing dynamic allocation in different parts&#xA;of the program, it becomes difficult to ensure that the&#xA;allocation/deallocation pattern is still safe vs. memory fragmentation.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-03-27T20:36:31.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22329" PostTypeId="2" ParentId="22288" CreationDate="2016-03-26T14:36:08.100" Score="2" Body="&lt;p&gt;If you have two sensors, you use analogRead.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int sensor1 = A0;&#xA;int sensor2 = A1;&#xA;int distance = 50; // or whatever you want here&#xA;bool car_passing = false;&#xA;&#xA;void setup(){&#xA;    int counter = 0;&#xA;}&#xA;&#xA;void loop(){&#xA;    if(analogRead(sensor1) &amp;lt; distance &amp;amp;&amp;amp; &#xA;       analogRead(sensor2) &amp;lt; distance &amp;amp;&amp;amp; &#xA;       !car_passing)&#xA;    {&#xA;        car_passing = true;&#xA;        counter++; &#xA;    }&#xA;&#xA;    if(analogRead(sensor1) &amp;gt; distance){&#xA;        car_passing = false;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To prevent the counter keep counting while the car is passing by, we need to make a boolean, so the counter does not wait for count again, before the car has passed.&lt;/p&gt;&#xA;" OwnerUserId="15457" LastEditorUserId="4131" LastEditDate="2016-03-26T20:22:54.957" LastActivityDate="2016-03-26T20:22:54.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22330" PostTypeId="1" AcceptedAnswerId="22331" CreationDate="2016-03-26T14:53:16.343" Score="0" ViewCount="129" Body="&lt;p&gt;OK, I'm working on a remote controlled robot. Both the robot and the remote use Arduino with a Bluetooth shield. The Bluetooth is working and I need to send something similar to this over Bluetooth:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;X:1026,Y:1026,Button:1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be more buttons added and &lt;code&gt;X,Y&lt;/code&gt; can be between &lt;code&gt;1026&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;. How can I build that string from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;xPosition = 1026;&#xA; yPosition = 1026;&#xA; buttonState = 0;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also need to be able to separate that string back into variables on the 2nd Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have seen other questions similar to this but they involved Serial. I am using Bluetooth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT AGAIN: I am sending the data over Bluetooth with the &lt;code&gt;BlueToothSerial.print&lt;/code&gt; command from the &lt;code&gt;SoftwareSerial.h&lt;/code&gt; library. (&lt;code&gt;BlueToothSerial&lt;/code&gt; is &lt;code&gt;SoftwareSerial BlueToothSerial(RxD,TxD);&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="16094" LastEditorUserId="16094" LastEditDate="2016-03-26T16:05:41.730" LastActivityDate="2016-05-25T17:14:19.140" Title="Arduino join multiple strings and numbers and then seperate them" Tags="|arduino-uno|programming|string|variables|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22331" PostTypeId="2" ParentId="22330" CreationDate="2016-03-26T15:27:00.853" Score="0" Body="&lt;p&gt;To make the string you can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char outstring[30];&#xA;sprintf(outstring, &quot;X:%d,Y:%d,Button:%d&quot;, xPosition, yPosition, buttonState);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be sure to make the &lt;code&gt;outstring&lt;/code&gt; big enough to store it all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, of course, if you actually &lt;em&gt;need&lt;/em&gt; to have the whole thing in one string all the time.  You haven't said how you are sending it (yes, I know, bluetooth, but there is bluetooth and there is bluetooth, and there are different ways of it working.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Splitting a string like that can be done with &lt;code&gt;strtok()&lt;/code&gt; then looking for the location of the colon in each returned token. Or, depending on how the string data actually arrives, could be parsed on a character-by-character basis, which would be better. Again, because you haven't told us how the data is actually being transferred it's impossible to elaborate on that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-26T15:27:00.853" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22333" PostTypeId="1" AcceptedAnswerId="22335" CreationDate="2016-03-26T16:46:10.453" Score="1" ViewCount="1098" Body="&lt;p&gt;I have a quick question regarding this code below in Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;0&quot;);&#xA;Serial.print(5);&#xA;Serial.print(&quot;0&quot;);&#xA;Serial.print(1);&#xA;Serial.print(&quot;0&quot;);&#xA;Serial.print(5);&#xA;Serial.print(&quot;0&quot;);&#xA;Serial.print(1);&#xA;Serial.print(&quot;0&quot;);&#xA;Serial.println(5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In C code, currently I'm receiving the message using this method below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int serialport_read_until(int fd, char* buf, char until, int buf_max, int timeout)&#xA;{&#xA;    char b[1];  // read expects an array, so we give it a 1-byte array&#xA;    int i=0;&#xA;    do { &#xA;        int n = read(fd, b, 1);  // read a char at a time&#xA;        if( n==-1) return -1;    // couldn't read&#xA;        if( n==0 ) {&#xA;            usleep( 1 * 1000 );  // wait 1 msec try again&#xA;            timeout--;&#xA;            if( timeout==0 ) return -2;&#xA;            continue;&#xA;        }&#xA;        buf[i] = b[0]; &#xA;        i++;&#xA;    } while( b[0] != until &amp;amp;&amp;amp; i+1 &amp;lt; buf_max &amp;amp;&amp;amp; timeout&amp;gt;0 );&#xA;&#xA;    buf[i] = 0;  // null terminate the string&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In C i defined:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char message[13];&#xA;uint32_t num;&#xA;char until = '\n';&#xA;&#xA;serialport_read_until(fd, message, newLine, sizeof message, 20000);&#xA;// the 20000 is timeout in millisec&#xA;// this method stores the data in serial buffer into message array&#xA;&#xA;printf(&quot;message is %d\n&quot;, num);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am expecting a raw value of &lt;strong&gt;0501050105&lt;/strong&gt; first.&#xA;Then I convert this raw string into &lt;strong&gt;501050105&lt;/strong&gt; using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sscanf(message, &quot;%d&quot;, &amp;amp;num);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently it works fine, but I strongly believe it is not the correct way to do it (or rather not the optimized way to do it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition, when i use serialport_read_until() method above, even though i specify the char until as '\n', the method terminates after reading '\r' (leaving the \n in the serial buffer), and the '\n' is only captured in the next method call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q1:&lt;/strong&gt; Am i reading the \r\n wrongly from the println (I saw in Arduino documentation that println prints \r\n)? What resulted in C 'cutting off' the message when it detected a \r from Arduino even though I specifically set to kill it only when \n is received?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Q2:&lt;/strong&gt; Instead of printing a string to me and converting it back to integer in C, is there a way for Arduino to send me a long value directly instead? eg 501050105 or 51515. how should I rewrite the serial print or method? And how do i capture that integer correctly in C? If i'm not wrong if a raw integer is print out from Arduino, it converts it into ASCII code. I'm still very new to C and Arduino and hope some guidelines to be given so I can improve on the current coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much.&lt;/p&gt;&#xA;" OwnerUserId="18966" LastEditorUserId="10794" LastEditDate="2016-03-26T20:40:21.927" LastActivityDate="2016-03-26T20:40:21.927" Title="How to read long value sent by Arduino in C" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22334" PostTypeId="1" CreationDate="2016-03-26T14:08:21.907" Score="2" ViewCount="184" Body="&lt;p&gt;I'm using this &lt;a href=&quot;https://www.adafruit.com/products/81&quot; rel=&quot;nofollow noreferrer&quot;&gt;motor shield&lt;/a&gt; for arduino from adafruit. It says it can drive 4 DC motors with it. However, two terminals M3 &amp;amp; M4 (as marked in the image) seem to be supplying lesser voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mUB9G.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mUB9G.jpg&quot; alt=&quot;motor shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid this becoming an XY problem, some more details:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The entire setup consists of an arduino, shield, raspberry Pi 3 &amp;amp; the motors being  powered with a 2200 mAh 12v supply. The raspberry pi is powered from the 5v supply of this shield.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the problem as mentioned is that even though M1 &amp;amp; M2 get the 12v, M3 &amp;amp; M4 don't. When I measured they give varying degree of voltage (3v - 6v). I tried disconnecting &amp;amp; connecting various combinations, with &amp;amp; without motors connected, pi removed, etc. All are giving same result. When I supplied 5v as external power, these pins in question dropped to 2v-3v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/using-dc-motors&quot; rel=&quot;nofollow noreferrer&quot;&gt;this documentation&lt;/a&gt;, there seems to be a difference in M3, M4 in that they run at 1KHZ, to save power. But my knowledge to make of this info seems to be limited. Can anyone point me to the right direction here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The complete setup.&lt;a href=&quot;https://i.stack.imgur.com/YOB5m.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YOB5m.jpg&quot; alt=&quot;The complete setup of hardware&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19631" OwnerDisplayName="loxxy" LastEditorUserId="19631" LastEditDate="2016-03-27T06:56:03.827" LastActivityDate="2016-03-27T06:56:03.827" Title="Debugging arduino shield for varying voltage" Tags="|arduino-uno|adafruit|arduino-motor-shield|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22335" PostTypeId="2" ParentId="22333" CreationDate="2016-03-26T17:02:08.030" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;char b[1];  // read expects an array, so we give it a 1-byte array&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it expects a &lt;em&gt;pointer&lt;/em&gt; to a destination to store the data. You don't need a 1-entry array - you can simplify your code with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char b;&#xA;...&#xA;int n = read(fd, &amp;amp;b, 1);  // read a char at a time&#xA;...&#xA;buf[i] = b;&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Currently it works fine, but I strongly believe it is not the correct way to do it (or rather not the optimized way to do it).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;C has the function &lt;code&gt;strtoul()&lt;/code&gt; which is far more efficient that sscanf.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t val = strtoul(buf, NULL, 10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;10&lt;/code&gt; is the base to convert from, so you could convert hexadecimal (base 16), octal (base 8), etc using it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q1: Am i reading the \r\n wrongly from the println (I saw in Arduino documentation that println prints \r\n)? What resulted in C 'cutting off' the message when it detected a \r from Arduino even though I specifically set to kill it only when \n is received?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You're defining the variable &lt;code&gt;until&lt;/code&gt; to contain &lt;code&gt;\n&lt;/code&gt;, yet passing the variable &lt;code&gt;newLine&lt;/code&gt; to your function. Maybe that has something to do with it?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Q2: Instead of printing a string to me and converting it back to integer in C, is there a way for Arduino to send me a long value directly instead? eg 501050105 or 51515. how should I rewrite the serial print or method? And how do i capture that integer correctly in C? If i'm not wrong if a raw integer is print out from Arduino, it converts it into ASCII code. I'm still very new to C and Arduino and hope some guidelines to be given so I can improve on the current coding.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can send a 32-bit value using just 4 bytes. However it's not reliable without implementing a whole protocol around those 4 bytes which, for just 4 bytes, is a bit of a waste. Simplest just to stick to ASCII encoding your data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-26T17:02:08.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22336" PostTypeId="1" AcceptedAnswerId="22338" CreationDate="2016-03-26T17:40:33.207" Score="0" ViewCount="342" Body="&lt;p&gt;I am using Neopixel Library and a Trinket Pro 5V Microcontroller to chase first three LEDs on a strip and then burst the last 2 (could be modified based on the number of LEDs).&#xA;The LEDs chase only once. See the code below. I am not sure why, even though the logic is inside the loop function, it only executes once. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &quot;WS2812_Definitions.h&quot;&#xA;#ifdef __AVR__&#xA;  #include &amp;lt;avr/power.h&amp;gt;&#xA;#endif&#xA;&#xA;// Which pin on the Arduino is connected to the NeoPixels?&#xA;// On a Trinket or Gemma we suggest changing this to 1&#xA;#define PIN            6&#xA;&#xA;// How many NeoPixels are attached to the Arduino? How many Neopixels do you want to chase (starting from the first in address 0. How many do you want to burst at the end?&#xA;#define NUMPIXELS      5&#xA;#define NUMPIXELSCHASE 3&#xA;#define NUMPIXELSBURST 2&#xA;&#xA;// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.&#xA;// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest&#xA;// example for more information on possible values.&#xA;Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;void setup() {&#xA;  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket&#xA;#if defined (__AVR_ATtiny85__)&#xA;  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);&#xA;#endif&#xA;  // End of trinket special code&#xA;&#xA;  pixels.begin(); // This initializes the NeoPixel library.&#xA;  clearLEDs();&#xA;  pixels.show();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.&#xA;  for(int i=0;i&amp;lt;NUMPIXELSCHASE;i++){&#xA;&#xA;   pixels.setPixelColor(i, INDIGO);&#xA;   pixels.show(); // This sends the updated pixel color to the hardware.&#xA;   delay (200);&#xA;  }&#xA;&#xA;  for(int i=NUMPIXELS-NUMPIXELSBURST;i&amp;lt;NUMPIXELS;i++){&#xA;&#xA;   pixels.setPixelColor(i, AQUA);&#xA;   pixels.show(); // This sends the updated pixel color to the hardware.&#xA;   delay(0);&#xA;  }&#xA;}&#xA;&#xA;// Sets all LEDs to off, but DOES NOT update the display;&#xA;// call leds.show() to actually turn them off after this.&#xA;void clearLEDs()&#xA;{&#xA;  for (int i=0; i&amp;lt;NUMPIXELS; i++)&#xA;  {&#xA;    pixels.setPixelColor(i, 0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15366" LastEditorUserId="15366" LastEditDate="2016-03-26T17:47:59.807" LastActivityDate="2016-03-26T18:07:14.277" Title="LEDs instruction code does not loop" Tags="|arduino-uno|programming|adafruit|rgb-led|neopixel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22337" PostTypeId="2" ParentId="22327" CreationDate="2016-03-26T18:03:09.183" Score="0" Body="&lt;p&gt;Take a look at this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9530&quot; rel=&quot;nofollow&quot;&gt;Sparkfun OpenLog&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8015" LastActivityDate="2016-03-26T18:03:09.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22338" PostTypeId="2" ParentId="22336" CreationDate="2016-03-26T18:07:14.277" Score="1" Body="&lt;p&gt;Your 1st pixel should go indigo &amp;amp; stay there, &amp;amp; the other 2 very briefly show Aqua before going back to Indigo. Try a longer delay than 0 at the end, and then clear them down for the next loop.&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2016-03-26T18:07:14.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22340" PostTypeId="1" AcceptedAnswerId="22341" CreationDate="2016-03-26T19:46:25.263" Score="1" ViewCount="252" Body="&lt;p&gt;Is it possible to determine at runtime whether a pointer points to &lt;code&gt;PROGMEM&lt;/code&gt;'ed values or regular values? This would give some flexibility when writing code that handles both.&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="10794" LastEditDate="2016-03-26T20:37:29.553" LastActivityDate="2019-05-25T13:02:21.043" Title="Possible to determine at runtime whether a pointer is declared PROGMEM?" Tags="|c++|progmem|sram|memory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22341" PostTypeId="2" ParentId="22340" CreationDate="2016-03-26T20:37:09.207" Score="2" Body="&lt;p&gt;Not really, if you are asking whether you can determine (simply from its value) whether 0x100 is in RAM or PROGMEM. Both are possible candidates for a memory location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;F()&lt;/code&gt; macro works around this by changing the &lt;em&gt;type&lt;/em&gt; of a variable at compile-time, so that the compiler can select a suitable method of printing. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println (&quot;Hello, world&quot;);&#xA;Serial.println (F(&quot;Hello, world&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case the appropriate &lt;code&gt;println&lt;/code&gt; function is chosen at compile-time by the compiler, based on the type (one would be a &lt;code&gt;const char *&lt;/code&gt;, the other a &lt;code&gt;__FlashStringHelper&lt;/code&gt; type).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are best off designing a way (similar to the &lt;code&gt;F()&lt;/code&gt; macro) where you can make the decision at compile time.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-26T20:37:09.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22342" PostTypeId="2" ParentId="22319" CreationDate="2016-03-26T20:45:42.983" Score="1" Body="&lt;p&gt;The worst line in your example is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s += &quot;a&quot;; // ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any sort of loop that adds one byte to a String is potentially going to fragment memory. First the String class allocates zero bytes for the string, then when you add a byte, it has to allocate one byte, then when you add another byte it has to deallocate (free) that byte and allocate two bytes, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The allocator &lt;em&gt;tries&lt;/em&gt; to be efficient, so eventually when you get up to three bytes you will, with luck, actually get the memory previously allocated to the one-byte string followed by the two-byte string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if other allocations have occurred (eg. another use of String elsewhere in the program) this might not be possible. Eventually you have lots of small gaps of maybe one or two bytes, with other stuff inbetween. Unless they are adjacent they cannot be recombined into a bigger block. This is your &quot;fragmentation&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When you += &quot;a&quot;, it does not free the previously allocated space: it calls realloc() to grow the buffer, and realloc() tries to grow it in place.  This works fine, without fragmentation, as long as your buffer is at the top of the heap. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Good point, however if you have multiple String instances, this may not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edgar Bonet is right, however there is certainly the potential, with multiple String instances, for each of them to prevent the others from growing their buffer size neatly. In the example in the question, you will probably find that when &lt;code&gt;f()&lt;/code&gt; returns, it returns a &lt;em&gt;copy&lt;/em&gt; of the String allocated on the stack, thus we now have 2 x String instances.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;While Edgar was writing some test code, so was I. :)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;memdebug.h&amp;gt;&#xA;&#xA;String foo;&#xA;&#xA;String f() {&#xA;  String s = String(&quot;&quot;);&#xA;  s += &quot;a&quot;; // ...&#xA;  s += &quot;bc&quot;; // ...&#xA;  return s;&#xA;}  // end of f&#xA;&#xA;void showMemoryUsage ()&#xA;{&#xA;  Serial.println (F(&quot;---------------&quot;));&#xA;  Serial.print (F(&quot;Largest block in freelist: &quot;));&#xA;  Serial.println (getLargestBlockInFreeList ());&#xA;  Serial.print (F(&quot;Largest available memory: &quot;));&#xA;  Serial.println (getLargestAvailableMemoryBlock ());&#xA;  Serial.print (F(&quot;Free memory: &quot;));&#xA;  Serial.println (getFreeMemory ());&#xA;  Serial.print (F(&quot;address of foo data = &quot;));&#xA;  Serial.println ((int) foo.c_str ());&#xA;} // end of showMemoryUsage&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  showMemoryUsage ();&#xA;  Serial.println (F(&quot;Calling f() ...&quot;));&#xA;  foo = f ();&#xA;  showMemoryUsage ();&#xA;  Serial.println (F(&quot;Calling f() ...&quot;));&#xA;  foo = f ();&#xA;  showMemoryUsage ();&#xA;  Serial.print (F(&quot;foo = &quot;));&#xA;  Serial.println (foo);&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Memory debug library from &lt;a href=&quot;http://andybrown.me.uk/wk/2011/01/01/debugging-avr-dynamic-memory-allocation/&quot; rel=&quot;nofollow&quot;&gt;http://andybrown.me.uk/wk/2011/01/01/debugging-avr-dynamic-memory-allocation/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---------------&#xA;Largest block in freelist: 0&#xA;Largest available memory: 1675&#xA;Free memory: 1677&#xA;address of foo data = 478&#xA;Calling f() ...&#xA;---------------&#xA;Largest block in freelist: 2&#xA;Largest available memory: 1669&#xA;Free memory: 1675&#xA;address of foo data = 482&#xA;Calling f() ...&#xA;---------------&#xA;Largest block in freelist: 2&#xA;Largest available memory: 1669&#xA;Free memory: 1675&#xA;address of foo data = 482&#xA;foo = abc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The address of the data in &lt;code&gt;foo&lt;/code&gt; has changed from 478 to 482, so my prediction above was right. The function &lt;code&gt;f()&lt;/code&gt; made a String, but a second &lt;em&gt;copy&lt;/em&gt; was returned, hence we have now &quot;lost&quot; 4 bytes in the heap. Well, not lost, but there is a gap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Calling &lt;code&gt;f()&lt;/code&gt; a second time did not make the fragmentation worse.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;BTW, this is unnecessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String s = String(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String s;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are invoking a second String just to provide something to copy into the first String. Strings start off empty so this is just wasted time.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-26T22:19:33.970" LastActivityDate="2016-03-26T22:19:33.970" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22343" PostTypeId="1" CreationDate="2016-03-26T20:47:27.467" Score="1" ViewCount="538" Body="&lt;p&gt;I'm using the Adafruit SIM808 breakout board to text a GPS link to Google Maps when pinged. My program is mostly working, but the GPS data that I get has no &quot;N, S, E, W&quot; indicators. In addition, I know that the longitude where I live is negative but it's coming out as positive. This is the output that I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ouVpf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ouVpf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that triggers that output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t stat;&#xA;// check GPS fix&#xA;stat = fona.GPSstatus();&#xA;if (stat &amp;lt; 0)  {&#xA;  Serial.println(F(&quot;Failed to query&quot;));&#xA;}&#xA;if (stat == 0) {&#xA;  Serial.println(F(&quot;GPS off&quot;));&#xA;}&#xA;if (stat == 1) {&#xA;  Serial.println(F(&quot;No fix&quot;));&#xA;}&#xA;if (stat == 2) {&#xA;  Serial.println(F(&quot;2D fix&quot;));&#xA;}&#xA;if (stat == 3) {&#xA;  Serial.println(F(&quot;3D fix&quot;));&#xA;}&#xA;&#xA;// check for GPS location&#xA;char gpsdata[120];&#xA;fona.getGPS(0, gpsdata, 120);&#xA;Serial.println(gpsdata);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm already reading about how to fix the GPS data so that it can be used by Google Maps, but I don't know what to do about the issue of not having the directional information/sign.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the full code, just for reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_FONA.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define FONA_RX 2&#xA;#define FONA_TX 3&#xA;#define FONA_RST 4&#xA;#define FONA_KEY 7&#xA;#define FONA_PS 8&#xA;&#xA;// this is a large buffer for replies&#xA;char replybuffer[255];&#xA;&#xA;SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);&#xA;SoftwareSerial *fonaSerial = &amp;amp;fonaSS;&#xA;Adafruit_FONA fona = Adafruit_FONA(FONA_RST);&#xA;uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(FONA_KEY, OUTPUT);&#xA;  pinMode(FONA_PS, INPUT);&#xA;  analogReference(INTERNAL);&#xA;  delay(2000);&#xA;&#xA;  TurnOffFona();&#xA;&#xA;  Serial.println(F(&quot;FONA SMS caller ID test&quot;));&#xA;  Serial.println(F(&quot;Initializing....(May take 3 seconds)&quot;));&#xA;  delay(1000);&#xA;&#xA;  TurnOnFona();&#xA;&#xA;  fonaSerial-&amp;gt;begin(4800);&#xA;  if (! fona.begin(*fonaSerial)) {&#xA;    Serial.println(F(&quot;Couldn't find FONA&quot;));&#xA;    while (1);&#xA;  }&#xA;  Serial.println(F(&quot;FONA is OK&quot;));&#xA;&#xA;  // Print SIM card IMEI number.&#xA;  char imei[15] = {0}; // MUST use a 16 character buffer for IMEI!&#xA;  uint8_t imeiLen = fona.getIMEI(imei);&#xA;  if (imeiLen &amp;gt; 0) {&#xA;    Serial.print(&quot;SIM card IMEI: &quot;); Serial.println(imei);&#xA;  }&#xA;&#xA;  // turn GPS on&#xA;  if (!fona.enableGPS(true)) {&#xA;    Serial.println(F(&quot;GPS failed to turn on&quot;));&#xA;  }&#xA;&#xA;  Serial.println(&quot;FONA Ready&quot;);&#xA;}&#xA;&#xA;&#xA;char fonaInBuffer[64]; //for notifications from the FONA&#xA;&#xA;void loop() {&#xA;  char* bufPtr = fonaInBuffer; //handy buffer pointer&#xA;&#xA;  if (fona.available()) {&#xA;    //any data available from the FONA?&#xA;    int slot = 0; //this will be the slot number of the SMS&#xA;    int charCount = 0;&#xA;    //Read the notification into fonaInBuffer&#xA;    do  {&#xA;      *bufPtr = fona.read();&#xA;      Serial.write(*bufPtr);&#xA;      delay(1);&#xA;    } while ((*bufPtr++ != '\n') &amp;amp;&amp;amp; (fona.available()) &amp;amp;&amp;amp; (++charCount &amp;lt; (sizeof(fonaInBuffer) - 1)));&#xA;&#xA;    //Add a terminal NULL to the notification string&#xA;    *bufPtr = 0;&#xA;&#xA;    //Scan the notification string for an SMS received notification.&#xA;    //  If it's an SMS message, we'll get the slot number in 'slot'&#xA;    if (1 == sscanf(fonaInBuffer, &quot;+CMTI: \&quot;SM\&quot;,%d&quot;, &amp;amp;slot)) {&#xA;      Serial.print(&quot;slot: &quot;); Serial.println(slot);&#xA;      char callerIDbuffer[32];  //we'll store the SMS sender number in here&#xA;&#xA;      // Retrieve SMS sender address/phone number.&#xA;      if (! fona.getSMSSender(slot, callerIDbuffer, 31)) {&#xA;        Serial.println(&quot;Didn't find SMS message in slot!&quot;);&#xA;      }&#xA;      Serial.print(F(&quot;FROM: &quot;)); Serial.println(callerIDbuffer);&#xA;&#xA;      int8_t stat;&#xA;      // check GPS fix&#xA;      stat = fona.GPSstatus();&#xA;      if (stat &amp;lt; 0)  {&#xA;        Serial.println(F(&quot;Failed to query&quot;));&#xA;      }&#xA;      if (stat == 0) {&#xA;        Serial.println(F(&quot;GPS off&quot;));&#xA;      }&#xA;      if (stat == 1) {&#xA;        Serial.println(F(&quot;No fix&quot;));&#xA;      }&#xA;      if (stat == 2) {&#xA;        Serial.println(F(&quot;2D fix&quot;));&#xA;      }&#xA;      if (stat == 3) {&#xA;        Serial.println(F(&quot;3D fix&quot;));&#xA;      }&#xA;&#xA;      // check for GPS location&#xA;      char gpsdata[120];&#xA;      fona.getGPS(0, gpsdata, 120);&#xA;      Serial.println(gpsdata);&#xA;      String gpsString;&#xA;&#xA;      gpsString = (String) gpsdata; //re-cast chr array as string.&#xA;      Serial.println(gpsString);&#xA;      int commaIndex = gpsString.indexOf(',');&#xA;      int secondCommaIndex = gpsString.indexOf(',', commaIndex + 1);&#xA;      int thirdCommaIndex = gpsString.indexOf(',', secondCommaIndex + 1);&#xA;      int fourthCommaIndex = gpsString.indexOf(',', thirdCommaIndex + 1);&#xA;&#xA;      String firstValue = gpsString.substring(0, commaIndex);&#xA;      String rawLat = gpsString.substring(commaIndex + 1, secondCommaIndex);&#xA;      String rawLon = gpsString.substring(secondCommaIndex + 1, thirdCommaIndex);&#xA;      String rawAlt = gpsString.substring(thirdCommaIndex + 1, fourthCommaIndex);&#xA;&#xA;      int decimalIndex = rawLat.indexOf('.');&#xA;      String lat1 = rawLat.substring(0, decimalIndex);&#xA;      String lat2 = rawLat.substring(decimalIndex + 1, rawLat.length());&#xA;      Serial.println(lat1);&#xA;      Serial.println(lat2);&#xA;      rawLat = lat1.substring(0, 2) + &quot;.&quot; + lat1.substring(3, lat1.length()) + lat2;&#xA;      Serial.println(rawLat);&#xA;&#xA;      int decimal2Index = rawLon.indexOf('.');&#xA;      String lon1 = rawLon.substring(0, decimal2Index);&#xA;      String lon2 = rawLon.substring(decimal2Index + 1, rawLon.length());&#xA;      Serial.println(lon1);&#xA;      Serial.println(lon2);&#xA;      rawLon = lon1.substring(0, 2) + &quot;.&quot; + lon1.substring(3, lon1.length()) + lon2;&#xA;      Serial.println(rawLon);&#xA;&#xA;      char txtmsgArray[80];&#xA;      String txmsg = &quot;https://www.google.com/maps/@&quot; + rawLat + &quot;,&quot; +  rawLon + &quot;,15z&quot;;&#xA;      txmsg.toCharArray(txtmsgArray, 80);&#xA;      Serial.println(txtmsgArray);&#xA;&#xA;      Serial.println(&quot;Sending reponse...&quot;);&#xA;      if (!fona.sendSMS(callerIDbuffer, txtmsgArray)) {&#xA;        Serial.println(F(&quot;Failed&quot;));&#xA;      } else {&#xA;        Serial.println(F(&quot;Sent!&quot;));&#xA;      }&#xA;      delay(3000);&#xA;      // delete the original msg after it is processed&#xA;      //   otherwise, we will fill up all the slots&#xA;      //   and then we won't be able to receive SMS anymore&#xA;      if (fona.deleteSMS(slot)) {&#xA;        Serial.println(F(&quot;OK!&quot;));&#xA;      } else {&#xA;        Serial.println(F(&quot;Couldn't delete&quot;));&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void TurnOnFona() {&#xA;  Serial.println(&quot;Turning on Fona: &quot;);&#xA;  while (digitalRead(FONA_PS) == LOW) {&#xA;    digitalWrite(FONA_KEY, LOW);&#xA;  }&#xA;  digitalWrite(FONA_KEY, HIGH);&#xA;  delay(4000);&#xA;}&#xA;&#xA;void TurnOffFona() {&#xA;  Serial.println(&quot;Turning off Fona &quot;);&#xA;  while (digitalRead(FONA_PS) == HIGH) {&#xA;    digitalWrite(FONA_KEY, LOW);&#xA;  }&#xA;  digitalWrite(FONA_KEY, HIGH);&#xA;  delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8769" LastEditorUserId="4628" LastEditDate="2017-12-02T06:36:06.613" LastActivityDate="2017-12-02T06:36:06.613" Title="GPS North? South? East? West?" Tags="|gps|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22344" PostTypeId="2" ParentId="22320" CreationDate="2016-03-26T20:52:59.410" Score="1" Body="&lt;p&gt;Changing the pins sounds like a reasonable requirement, and you shouldn't have to delete/new to achieve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would leave the library alone (for backwards compatibility) except to add a &lt;code&gt;changePins&lt;/code&gt; function which you may choose whether or not to call, to assign new pins to the class structure. (Effectively it would be your rewritten &lt;code&gt;begin&lt;/code&gt; function with a different name).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-26T20:52:59.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22345" PostTypeId="1" AcceptedAnswerId="22346" CreationDate="2016-03-27T00:14:50.250" Score="2" ViewCount="320" Body="&lt;p&gt;I would like to have a shield permanently attached that use the VIN (not 5v) for it's power - the problem comes in when I want to program the arduino (via the USB port), do I need to also have the barrel connector plugged in, or can I just expect the shield to not work (no, it won't be damaged from not getting enough/any power), but have the arduino itself be fine - or am I somehow damaging the power regulator by attempting to use it in reverse? &lt;/p&gt;&#xA;" OwnerUserId="10606" LastActivityDate="2016-03-27T00:30:28.147" Title="What happens if I try to draw power from the VIN port while under USB power on an Uno?" Tags="|arduino-uno|power|shields|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22346" PostTypeId="2" ParentId="22345" CreationDate="2016-03-27T00:30:28.147" Score="3" Body="&lt;p&gt;You do run the risk of damaging the 5V regulator, yes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power will attempt to flow from the 5V rail (USB port) through the voltage regulator (backwards) and into the shield to power it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your shield doesn't mind being under-powered from 5V while you're programming the Arduino you can add a diode between 5V (anode) and Vin (cathode). This will bypass the regulator when the voltage of the 5V rail is higher than the Vin rail, and your shield will be supplied with about 4.3V (slightly higher for a schottky diode).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-27T00:30:28.147" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22348" PostTypeId="1" CreationDate="2016-03-27T02:05:38.317" Score="0" ViewCount="624" Body="&lt;p&gt;Recently I uploaded individual codes for relay's and Servo motor seperately, it all worked fine. But when I combined these two codes and dumped in to the loop there is a delay in functioning of the relay's but the Servo motor is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have to control these devices through Bluetooth HC-05 module.&#xA;Could you please help me with the code?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;simple LED test&#xA;*/&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;char val;         // variable to receive data from the serial port&#xA;int ledpin = 2; // LED connected to pin 2 (on-board LED)&#xA;Servo myservo;&#xA;int pos = 0;    // variable to store the servo position&#xA;int motor = 0;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT&#xA;  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT&#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object&#xA;  Serial.print(&quot;Arduino control Servo Motor Connected OK&quot;);&#xA;  Serial.print('\n');&#xA;  Serial.begin(9600);       // start serial communication at 115200bps&#xA;  digitalWrite(ledpin = 2 ,HIGH);&#xA;  digitalWrite(ledpin = 3 ,HIGH);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;      if( Serial.read() == 'a' )    // if 'a' was received led 2 is switched off&#xA;  {&#xA;    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2&#xA;&#xA;  }&#xA;&#xA;  if( Serial.read() == 'A' )               // if 'A' was received led 2 on&#xA;  {&#xA;    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2&#xA;&#xA;  }&#xA;&#xA;  if( Serial.read() == 'b' )        // if 'b' was received led 3 is switched off&#xA;  {&#xA;    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3&#xA;&#xA;  }&#xA;&#xA;  if( Serial.read() == 'B' )               // if 'B' was received led 3 on&#xA;  {&#xA;    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3&#xA;&#xA;  } &#xA;&#xA;&#xA;&#xA;  if (Serial.read() == '\n')&#xA;    {&#xA;&#xA;   motor = Serial.parseInt();&#xA;    pos = Serial.parseInt();&#xA;      myservo.write(pos);             &#xA;      delay(15);                     &#xA;      Serial.print(&quot;Data Response : &quot;);&#xA;      Serial.print(motor, DEC);&#xA;      Serial.print(pos, DEC);&#xA;&#xA;    }&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19636" LastEditorUserId="19515" LastEditDate="2016-03-28T04:01:10.457" LastActivityDate="2018-12-13T12:01:23.487" Title="How to merge two arduino sketches, one for relay's and one for Servo motor?" Tags="|arduino-uno|servo|relay|hc-05|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22349" PostTypeId="2" ParentId="22304" CreationDate="2016-03-27T02:10:30.113" Score="0" Body="&lt;p&gt;Remove the pins connected to Tx and Rx while uploading the code , it worrked for me.&#xA;also include all the libraries currently used in your program.&#xA;Good luck!!&lt;/p&gt;&#xA;" OwnerUserId="19636" LastActivityDate="2016-03-27T02:10:30.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22350" PostTypeId="1" AcceptedAnswerId="22357" CreationDate="2016-03-27T02:19:02.410" Score="0" ViewCount="2537" Body="&lt;p&gt;For a project i need to extract some data from an external eeprom and then store it somewhere. Suddenly after some manipulations (not necessarly with Arduino board) i need to put them in an external eeprom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would do is to convert the extracted data from the EEPROM in Intel Hex data and vice versa.&#xA;To do this I wanted to know if there is already a library for that purpose &quot;ready to use&quot; made for Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="19601" LastActivityDate="2017-03-17T17:27:55.847" Title="A library for manipulate Intel Hex data?" Tags="|arduino-uno|arduino-ide|eeprom|data-type|convert|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22351" PostTypeId="1" AcceptedAnswerId="22390" CreationDate="2016-03-27T03:38:04.527" Score="1" ViewCount="358" Body="&lt;p&gt;I'm using a MCP3008 8ch 10bit ADC to expand the Analog Inputs for the project I'm working on. The only library I can find for it is &lt;a href=&quot;https://github.com/nodesign/MCP3008&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; the library is ported from Adafruit's Raspberry Pi library &lt;a href=&quot;https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/script&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. From what I can tell the library uses bitbanging as opposed to hardware SPI in order to communicate. I would like to use hardware SPI, but don't have the skills to write a library to communicate with it myself. Are there any resources for how to write a library like that, or anything I can read about on how to convert a library from bitbanging to hardware SPI? &lt;/p&gt;&#xA;" OwnerUserId="18878" LastEditorUserId="18878" LastEditDate="2016-03-27T04:59:24.790" LastActivityDate="2016-03-28T03:31:48.543" Title="Convert library from using bitbanging to hardware SPI" Tags="|library|spi|prototype|pcb-design|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22352" PostTypeId="1" CreationDate="2016-03-27T04:29:11.167" Score="0" ViewCount="25066" Body="&lt;p&gt;I keep getting the error &quot;Expected initializer&quot; at different points in my code whenever I try to verify it. Currently, the error exists before &quot;void setup.&quot; How can I fix this error and not allow it to happen in the future?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPins[] = {9, 8, 7, 6};&#xA;int index;&#xA;int currentLED&#xA;&#xA;&#xA;void setup();&#xA;  {&#xA;  pinMode(Led1Pin, OUTPUT);&#xA;  pinMode(Led2Pin, OUTPUT);&#xA;  pinMode(Led3Pin, OUTPUT);&#xA;  pinMode(Led4Pin, OUTPUT);&#xA;  pinMode(Led5Pin, OUTPUT);&#xA;  pinMode(ButtonPin, INPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  //Start a new game.&#xA;&#xA;&#xA;&#xA;&#xA; for(index = 0; index &amp;lt;= 4; index++)&#xA;  {&#xA;    pinMode(ledPins[index],OUTPUT);&#xA;    // ledPins[index] is replaced by the value in the array.&#xA;    // For example, ledPins[0] is 2&#xA;  }&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  oneAfterAnotherNoLoop();  // Light up all the LEDs in turn&#xA;&#xA;&#xA;}&#xA;&#xA;void oneAfterAnotherNoLoop()&#xA;{&#xA;  int delayTime = 200; // time (milliseconds) to pause between LEDs&#xA;                   // make this smaller for faster switching&#xA;  // turn all the LEDs on:&#xA;  int Index;&#xA;&#xA;for (Index = 0; Index &amp;lt;=3; Index++) {&#xA;  digitalWrite(ledPins[Index], HIGH);&#xA;  delay(delayTime);&#xA;  digitalWrite(ledPins[Index], LOW);&#xA;}&#xA;for (Index = 3; Index &amp;gt;= 0; Index--) {&#xA;    digitalWrite(ledPins[Index], HIGH);&#xA;  delay(delayTime);&#xA;  digitalWrite(ledPins[Index], LOW);&#xA;}&#xA;}&#xA;&#xA;void loop();&#xA;{&#xA;    // Check if the button is pressed at the right moment&#xA;&#xA;   if (digitalRead(10) == 0) &#xA;   {&#xA;    if (currentLED == 8)&#xA;    {&#xA;      // Blink the orrect (green) LED&#xA;      digitalWrite(8, HIGH);&#xA;      delay(200);&#xA;      digitalWrite(14, LOW);&#xA;      delay(200);&#xA;      digitalWrite(8, HIGH);&#xA;      delay(200);&#xA;      digitalWrite(14, LOW);&#xA;    }&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19387" LastActivityDate="2018-06-14T03:25:59.317" Title="Expected Initializer?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="1" ClosedDate="2018-06-21T02:20:52.483" ContentLicense="CC BY-SA 3.0" />
  <row Id="22353" PostTypeId="1" AcceptedAnswerId="22389" CreationDate="2016-03-27T05:03:22.433" Score="3" ViewCount="7065" Body="&lt;p&gt;In trying to learn how to create a reasonably precise 3d model of my (very hilly) property, I stumbled across a product called Navspark, which appears to be a $22 arduino-compatible development board, with an RTK-capable (and RTKlib-compatible) GPS chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea with RTK is that a reference-position base-station transmits its positional error to a mobile unit, giving the mobile unit cm-level precision relative to the position of the base station. The error calculation is computationally intensive, but apparently within the capabilities of a Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it actually possible to build an RTK-capable mobile/base pair using low-priced equipment like this?  Can you link a howto or project example?&lt;/p&gt;&#xA;" OwnerUserId="19370" LastActivityDate="2016-03-28T03:05:13.963" Title="Getting RTK-precision GPS with arduino devices like NavSpark?" Tags="|gps|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22354" PostTypeId="2" ParentId="22351" CreationDate="2016-03-27T05:18:27.683" Score="4" Body="&lt;p&gt;The standard AVR library has SPI handling. See, for example: &lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/spi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't have to write a library if you don't want, just communicate directly using SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the MCP3008 has some tips for using an 8-bit SPI system to communicate with the device. In particular this chart:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Djtxp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Djtxp.png&quot; alt=&quot;MCP3008 timings&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see from that, that you will need 3 x SPI.transfer. I don't have one here to test with, but the code would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite (SS, LOW);  // select device&#xA;int result;&#xA;SPI.transfer (0x01);  // start bit&#xA;result = SPI.transfer (0b10000000);  // single, ch0&#xA;result = (result &amp;amp; 0b11) &amp;lt;&amp;lt; 8;  // move to high-order byte&#xA;result |= SPI.transfer (0);   // lower order byte&#xA;digitalWrite (SS, HIGH);  // deselect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Untested, but this should be roughly it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-27T05:18:27.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22355" PostTypeId="2" ParentId="22352" CreationDate="2016-03-27T05:21:55.347" Score="2" Body="&lt;pre&gt;&lt;code&gt;int currentLED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are missing a semicolon there.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There should &lt;em&gt;not&lt;/em&gt; be a semicolon here.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Do some tutorials on the C or C++ language. They will help you.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-27T05:21:55.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22357" PostTypeId="2" ParentId="22350" CreationDate="2016-03-27T05:30:21.927" Score="0" Body="&lt;p&gt;Why does it have to be in Intel Hex format? You could write out the EEPROM to the serial port one byte to a line, or something. Something like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  for (int addr = 0x0000; addr &amp;lt; 0x0010; addr++)&#xA;    {&#xA;    Serial.print (&quot;Address = &quot;);&#xA;    Serial.print (addr, HEX);&#xA;    Serial.print (&quot;, value = &quot;);&#xA;    Serial.println (EEPROM.read(addr), HEX);&#xA;    }&#xA;&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not personally aware of a library that happens to write out/read in, Intel Hex format from/to the EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I have &lt;a href=&quot;http://www.gammon.com.au/uploader&quot; rel=&quot;nofollow&quot;&gt;code that uploads and downloads files to the Arduino&lt;/a&gt;. Inside that is code to read/write Intel hex format. However it isn't a library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside File_Utils.ino are some comments that show the format:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;Line format:&#xA;&#xA;  :nnaaaatt(data)ss&#xA;&#xA;  Where:&#xA;  :      = a colon&#xA;&#xA;  (All of below in hex format)&#xA;&#xA;  nn     = length of data part&#xA;  aaaa   = address (eg. where to write data)&#xA;  tt     = transaction type&#xA;           00 = data&#xA;           01 = end of file&#xA;           02 = extended segment address (changes high-order byte of the address)&#xA;           03 = start segment address *&#xA;           04 = linear address *&#xA;           05 = start linear address *&#xA;  (data) = variable length data&#xA;  ss     = sumcheck&#xA;&#xA;            * We don't use these&#xA;&#xA;*/&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In that file is code to write Intel Hex format (reading from Flash, not EEPROM):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void readFlashContents ()&#xA;  {&#xA;  if (!haveSDcard)&#xA;    {&#xA;    Serial.println (F(&quot;*** No SD card detected.&quot;));&#xA;    return;&#xA;    }&#xA;&#xA;  progressBarCount = 0;&#xA;  pagesize = currentSignature.pageSize;&#xA;  pagemask = ~(pagesize - 1);&#xA;  oldPage = NO_PAGE;&#xA;  byte lastMSBwritten = 0;&#xA;&#xA;  while (true)&#xA;    {&#xA;&#xA;    Serial.println ();  &#xA;    Serial.println (F(&quot;Choose file to save as: &quot;));&#xA;&#xA;    getline (name, sizeof name);&#xA;    int len = strlen (name);&#xA;&#xA;    if (len &amp;lt; 5 || strcmp (&amp;amp;name [len - 4], &quot;.HEX&quot;) != 0)&#xA;      {&#xA;      Serial.println (F(&quot;File name must end in .HEX&quot;));  &#xA;      return;&#xA;      }&#xA;&#xA;    // if file doesn't exist, proceed&#xA;    if (!sd.vwd()-&amp;gt;exists (name))&#xA;      break;&#xA;&#xA;    Serial.print (F(&quot;File &quot;));&#xA;    Serial.print (name);    &#xA;    Serial.println (F(&quot; exists. Overwrite? Type 'YES' to confirm ...&quot;));  &#xA;&#xA;    if (getYesNo ())&#xA;      break;&#xA;&#xA;    }  // end of checking if file exists&#xA;&#xA;  // ensure back in programming mode  &#xA;  if (!startProgramming ())&#xA;    return;  &#xA;&#xA;  SdFile myFile;&#xA;&#xA;  // open the file for writing&#xA;  if (!myFile.open(name, O_WRITE | O_CREAT | O_TRUNC)) &#xA;    {&#xA;    Serial.print (F(&quot;Could not open file &quot;));&#xA;    Serial.print (name);&#xA;    Serial.println (F(&quot; for writing.&quot;));&#xA;    return;    &#xA;    }&#xA;&#xA;  byte memBuf [16];&#xA;  bool allFF;&#xA;  unsigned int i;&#xA;  char linebuf [50];&#xA;  byte sumCheck;&#xA;&#xA;  Serial.println (F(&quot;Copying flash memory to SD card (disk) ...&quot;));  &#xA;&#xA;  for (unsigned long address = 0; address &amp;lt; currentSignature.flashSize; address += sizeof memBuf)&#xA;    {&#xA;&#xA;    unsigned long thisPage = address &amp;amp; pagemask;&#xA;    // page changed? show progress&#xA;    if (thisPage != oldPage &amp;amp;&amp;amp; oldPage != NO_PAGE)&#xA;      showProgress ();&#xA;    // now this is the current page&#xA;    oldPage = thisPage;&#xA;&#xA;    // don't write lines that are all 0xFF&#xA;    allFF = true;&#xA;&#xA;    for (i = 0; i &amp;lt; sizeof memBuf; i++)&#xA;      {&#xA;      memBuf [i] = readFlash (address + i); &#xA;      if (memBuf [i] != 0xFF)&#xA;        allFF = false;&#xA;      }  // end of reading 16 bytes&#xA;    if (allFF)&#xA;      continue;&#xA;&#xA;    byte MSB = address &amp;gt;&amp;gt; 16;&#xA;    if (MSB != lastMSBwritten)&#xA;      {&#xA;      sumCheck = 2 + 2 + (MSB &amp;lt;&amp;lt; 4);&#xA;      sumCheck = ~sumCheck + 1;      &#xA;      // hexExtendedSegmentAddressRecord (02)&#xA;      sprintf (linebuf, &quot;:02000002%02X00%02X\r\n&quot;, MSB &amp;lt;&amp;lt; 4, sumCheck);    &#xA;      myFile.print (linebuf);   &#xA;      lastMSBwritten = MSB;&#xA;      }  // end if different MSB&#xA;&#xA;    sumCheck = 16 + lowByte (address) + highByte (address);&#xA;    sprintf (linebuf, &quot;:10%04X00&quot;, (unsigned int) address &amp;amp; 0xFFFF);&#xA;    for (i = 0; i &amp;lt; sizeof memBuf; i++)&#xA;      {&#xA;      sprintf (&amp;amp;linebuf [(i * 2) + 9] , &quot;%02X&quot;,  memBuf [i]);&#xA;      sumCheck += memBuf [i];&#xA;      }  // end of reading 16 bytes&#xA;&#xA;    // 2's complement&#xA;    sumCheck = ~sumCheck + 1;&#xA;    // append sumcheck&#xA;    sprintf (&amp;amp;linebuf [(sizeof memBuf * 2) + 9] , &quot;%02X\r\n&quot;,  sumCheck);&#xA;&#xA;    myFile.clearWriteError ();&#xA;    myFile.print (linebuf);   &#xA;    if (myFile.getWriteError ())&#xA;       {&#xA;       Serial.println ();  // finish off progress bar&#xA;       Serial.println (F(&quot;Error writing file.&quot;));&#xA;       myFile.close ();&#xA;       return; &#xA;       }   // end of an error&#xA;&#xA;    }  // end of reading flash &#xA;&#xA;  Serial.println ();  // finish off progress bar&#xA;  myFile.print (&quot;:00000001FF\r\n&quot;);    // end of file record&#xA;  myFile.close ();  &#xA;  // ensure written to disk&#xA;  sd.vwd()-&amp;gt;sync ();&#xA;  Serial.print (F(&quot;File &quot;));&#xA;  Serial.print (name);&#xA;  Serial.println (F(&quot; saved.&quot;));&#xA;  }  // end of readFlashContents&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That should give you some tips about how to write out the file. Look in my code to see the reading code as well. However as I said, you don't necessarily have to use that format if you just want to manipulate the data yourself.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-27T21:07:48.470" LastActivityDate="2016-03-27T21:07:48.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22360" PostTypeId="1" CreationDate="2016-03-27T07:44:32.090" Score="2" ViewCount="384" Body="&lt;p&gt;I want to send servo signal to ESC and Servo with my 3.3V Arduino Pro Mini.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the ESC/Servo read 3.3V signal from Arduino Pro Mini? Or do I need to make some level shifter to make 5V signal?&lt;/p&gt;&#xA;" OwnerUserId="19641" LastEditorUserId="19515" LastEditDate="2016-03-28T04:01:05.957" LastActivityDate="2016-03-28T09:17:33.977" Title="Arduino Pro Mini and Electronic Speed Controller (ESC)" Tags="|servo|arduino-pro-mini|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22362" PostTypeId="1" AcceptedAnswerId="22364" CreationDate="2016-03-27T11:09:35.300" Score="0" ViewCount="12508" Body="&lt;p&gt;Hey guys need your help in verifying out this program about toggling the LED ON and OFF using 2 push buttons.What i actually want is to let my LED stay ON when i press and even leave the push button-1 , and on pressing and leaving the push button-2 i want the led to turn off and no matter how many times i press the push button-1 i want it to turn ON the LED and the push button-2 should only turn off the LED.but with my program i am only able to see the LED to be at HIGH state,It is not shifting to LOW state on clicking push button-2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my sketch :-&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;    /* LED CONTROLLED WITH 2 PUSH BUTTON PROJECT&#xA;       BY ARSH BANSAL &#xA;&#xA; CIRCUIT :-&#xA; i) LEDPIN CONNECTED PIN 13.&#xA; ii) PUSHBUTTON1 CONNECTED TO PIN 8.&#xA; iii) PUSHBUTTON2 CONNECTED TO PIN 7.&#xA; iv) BOTH THE PUSH BUTTONS CONNECTED PARALLELY, EACH WITH A 1K PULLUP RESISTOR AND BOTH THE PUSH BUTTONS CONNECTED TO 5V SUPPLY.&#xA;   */&#xA;&#xA; int ledpin = 13;&#xA; int pushbutton1 = 8;&#xA; int pushbutton2 = 7;&#xA; boolean lastbuttonstate1 = LOW;&#xA; boolean lastbuttonstate2 = LOW;&#xA;&#xA; void setup() &#xA; { &#xA;   pinMode(ledpin,OUTPUT);&#xA;   pinMode(pushbutton1,INPUT);&#xA;   pinMode(pushbutton2,INPUT);&#xA; }&#xA;&#xA; void loop()&#xA; {&#xA;   if ( digitalRead(pushbutton1)== HIGH &amp;amp;&amp;amp; digitalRead(pushbutton2) == LOW &amp;amp;&amp;amp; lastbuttonstate1 == LOW )&#xA;    { digitalWrite (ledpin,HIGH) ;}&#xA;&#xA;   else ( digitalRead(pushbutton1) == LOW &amp;amp;&amp;amp; digitalRead(pushbutton2)== LOW &amp;amp;&amp;amp; lastbuttonstate1 == HIGH)&#xA;    ; { digitalWrite (ledpin,HIGH) ; }&#xA;&#xA;    if ( digitalRead(pushbutton1)== LOW &amp;amp;&amp;amp; digitalRead(pushbutton2) == HIGH  &amp;amp;&amp;amp; lastbuttonstate2 == LOW)&#xA;    { digitalWrite (ledpin,LOW) ;}&#xA;&#xA;   else ( digitalRead(pushbutton1) == LOW &amp;amp;&amp;amp; digitalRead(pushbutton2)== LOW  &amp;amp;&amp;amp; lastbuttonstate2 == HIGH)&#xA;    ; { digitalWrite (ledpin,LOW) ; }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19511" LastEditorUserId="4131" LastEditDate="2016-03-28T01:34:27.397" LastActivityDate="2018-10-27T04:24:18.500" Title="Integrating 2 push buttons to toggle the LED ON and OFF" Tags="|arduino-uno|led|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22363" PostTypeId="1" CreationDate="2016-03-27T11:30:36.373" Score="-1" ViewCount="23189" Body="&lt;p&gt;I am communicating with the esp8266 WiFi module using Arduino. The module returns GET requests from other clients. They will be of the form &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET /101011 HTTP/1.1\r\nHost...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wish to extract only the &lt;code&gt;101011&lt;/code&gt; from the received serial data and discard the rest. I came up with this small chunk of code to test it by sending data from my laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String s;&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if(Serial.available())&#xA;  {&#xA;    Serial.println(&quot;Inside&quot;);&#xA;    Serial.find(&quot;/&quot;);&#xA;    s = Serial.readStringUntil(' ');&#xA;    Serial.println(s);&#xA;    // Discard the rest of the data . Snippet from Jeremy Blum's Blog&#xA;&#xA;    while(Serial.available()&amp;gt;0) Serial.read(); &#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.jeremyblum.com/2011/02/07/arduino-tutorial-6-serial-communication-and-processing/&quot; rel=&quot;nofollow&quot;&gt;Jeremy's Blog&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I run this using the input &lt;code&gt;GET /101011 HTTP/1.1\r\n&lt;/code&gt; the output produced is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Inside&#xA;101011&#xA;Inside&#xA;1.1\r\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is &lt;code&gt;Serial.available()&lt;/code&gt; returning &lt;code&gt;true&lt;/code&gt; even after reading everything? How to discard the rest of data from the serial input buffer?&lt;/p&gt;&#xA;" OwnerUserId="6862" LastActivityDate="2021-10-06T07:00:02.487" Title="How to flush the input serial buffer in Arduino?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22364" PostTypeId="2" ParentId="22362" CreationDate="2016-03-27T11:47:51.807" Score="1" Body="&lt;p&gt;You are better off, in this case, remembering the state of the LED not the state of the buttons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the LED is OFF and BUTTON1 is PRESSED then turn the LED on.&lt;/li&gt;&#xA;&lt;li&gt;If the LED is ON and BUTTON2 is PRESSED then turn the LED off.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    static bool ledState = false; // LED is off by default&#xA;    if ((digitalRead(pushbutton1) == LOW) &amp;amp;&amp;amp; !ledState) { // 1 pressed &amp;amp; led is off&#xA;        digitalWrite(ledpin, HIGH);&#xA;        ledState = true;&#xA;    }&#xA;    if ((digitalRead(pushbutton2) == LOW) &amp;amp;&amp;amp; ledState) { // 2 pressed &amp;amp; led is on&#xA;        digitalWrite(ledpin, LOW);&#xA;        ledState = false;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-27T11:47:51.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22365" PostTypeId="2" ParentId="20503" CreationDate="2016-03-27T14:51:08.577" Score="4" Body="&lt;p&gt;It would be more accurate to say that it can be used as part of a microstepping system, though it's probably not a good choice for &lt;em&gt;any use&lt;/em&gt; today.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The L293D is merely an (effectively obsolete implementation of an) H-bridge, not a stepper motor &lt;em&gt;sequencer&lt;/em&gt;, hence it is no more capable of autonomously driving a motor in full or half step mode than it is of microstepping - it can only do any of these when it is controlled by a sequencer, such as an L297 chip, or software running on an Arduino's processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Microstepping requires partially actuating the coils to interpolate between the angular positions which would be achieved by activating each in turn fully.  It can be thought of as a proportional extension of how half-stepping uses actuating both coils at the same power to achieve a halfway in between position, only now the coils are actuated at different power levels to achieve finer gradations of position, though achieving accurate interpolation requires care as the relationship is not linear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modern power electronics no longer use variable analog drivers, as these convert the unused power to heat.  Instead, the goal is to use switches which come as close as possible to only ever being fully on or fully off.  Reduced driver power is achieved by pulse width modulating the switch, varying the average amount of power delivered to the load over a short period of time.  In a stepper motor setting, this on-off modulation can be done to achieve microstepping and or also to achieve current regulation when a many-times-rated-voltage supply is used to allow overcoming winding inductance at high step rates. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The L293D (and its larger cousin the L298) are quite inefficient bipolar transistor bridges (they aren't very good switches compared to MOSFETs), and should probably not be chosen for new designs today.  They are, however, capable of being used to microstep a motor when actuated by a sequencer which pulse width modulates the phase signals. &#xA;Adafruit, who appear to be the original creators of this shield design, have in fact published microstepping driver code for their L293D board on github. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit-Motor-Shield-library&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/adafruit/Adafruit-Motor-Shield-library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that the ebay seller you link to as the source of the board is using Adafruit's own schematic on their product page, it's a bit unclear why your software is differentiating between this board vs an Adafruit one, unless by the the Adafruit board you mean their V2 shield.  The V2 design uses a more efficient TB6612FNG FET bridge, but of more relevance to microstepping offloads the sequencing task from Arduino software to a PCA9685 chip which is apparently capable of microstepping (as well as simpler modes) by itself.  Depending on the computational load and/or your  level of determination, you may be able to get the ATmega microstepping the L293D in the context of your overall project.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-03-27T18:00:36.720" LastActivityDate="2016-03-27T18:00:36.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22366" PostTypeId="2" ParentId="22350" CreationDate="2016-03-27T15:08:42.370" Score="0" Body="&lt;p&gt;Nick's answer assumes you just want to read/process/write the data from one place to another.  If that's the case, there's no need to store the data into an Intel Hex Data formatted file – just keep it in a flat array, or a file that's formatted conveniently rather than in a form that requires parsing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, if you actually need the formatted file for some reason – such as an intermediate program only working with Hex files – you could edit the question and say so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note,  &lt;a href=&quot;https://pypi.python.org/pypi/IntelHex&quot; rel=&quot;nofollow&quot;&gt;Python Software Foundation's IntelHex&lt;/a&gt; page provides a&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Python library to read, write, create from scratch and manipulate data from HEX (also known as Intel HEX) file format. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To use it, you would write a Python program that (on your host computer) reads serial-port data with values to be stored, and uses the IntelHex library to write a Hex file.  After the intermediate program fiddles with the Hex file, another Python program on your host computer uses IntelHex to read the modified Hex file and writes it to EEPROM or to serial for an Arduino to write it to an EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-03-27T15:08:42.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22369" PostTypeId="1" CreationDate="2016-03-27T17:01:16.693" Score="0" ViewCount="263" Body="&lt;p&gt;I have a college assignment where I need to get serial output, the Ethernet shield and SPI communication with other boards to work. We are not allowed to use any existing libraries, though we can use them as strong inspiration, as long as we are able to explain every line we have in our final code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since there appears to be a lack of C resource I spent lots of time trying to reverse engineer the CPP libraries but I am hopelessly overwhelmed by anything beyond getting a pure C blinky to run.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any idea how I should approach this? Are there C resources about the Ethernet shield and Arduino SPI?&lt;/p&gt;&#xA;" OwnerUserId="19652" LastActivityDate="2016-04-26T23:18:24.607" Title="How to approach an complex Arduino Uno project (Serial, SPI, Ethernet) in pure C, without libraries?" Tags="|arduino-uno|ethernet|spi|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22370" PostTypeId="1" CreationDate="2016-03-27T06:15:48.133" Score="2" ViewCount="1301" Body="&lt;p&gt;I am trying to simulate an interrupt with an Arduino Uno in Proteus. This is the simple test code that I'm using:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void introutine()&#xA;{&#xA;  digitalWrite(13,HIGH);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(13,OUTPUT);&#xA;  attachInterrupt(2,introutine,LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's the circuit in Proteus:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Eniw0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Eniw0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I hit the button, the LED is supposed to turn on. Well, nothing happens. I have read something about Proteus being bad at simulating interrupts, but I'm not sure about it because Timer1 interrupts did work well. Basically, the problem lies within EXTERNAL interrupts only. I hope you people can help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerDisplayName="sebascarra" LastEditorUserId="37523" LastEditDate="2019-07-18T19:21:03.713" LastActivityDate="2019-07-18T19:21:03.713" Title="Does Proteus simulate external interrupts properly using Arduino? I can't get them to work" Tags="|arduino-uno|avr|isr|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22371" PostTypeId="2" ParentId="22348" CreationDate="2016-03-27T18:18:01.587" Score="1" Body="&lt;p&gt;A couple of things stand out in your code.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Whenever you perform a digital write you assign a value to ledpin:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(ledpin = 3, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is not necessary as you do not do anything with the ledpin variable. Instead, just have the digital I/O pin number:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(3, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or simply have 2 variables, one for pin 2 and another for pin 3. Eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;redledpin = 2;&#xA;greenledpin = 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also applies to the pinMode function calls in the setup function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Each one of your  &lt;code&gt;if( Serial.read() == xx)&lt;/code&gt; statements will read a serial character off of the serial buffer. Instead store the read character in a local variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readChar = Serial.read()&#xA;if( readchar == 'a')&#xA;...&#xA;if( readchar == 'A')&#xA;...&#xA;if( readchar == 'b')&#xA;...&#xA;if( readchar == 'B')&#xA;... &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I would encase all of the code inside &lt;code&gt;loop()&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( Serial.available() )&#xA;{&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The delay function is blocking and this will cause issues. I suggest deleting the delay altogether.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Due to the fact that you are sending commands to turn digital outputs on and off as well as sending an integer for motor and another for pos, I suggest that you define a packet structure and make your code follow that (with the necessary error handling). As the code currently stands you will miss information, depending on what character it sees first on the serial buffer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A, B, 142, 090&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Starting the packet off with a know character is a good idea. So is having a timeout period - in case only a portion of your packet is received.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:01:23.487" LastActivityDate="2018-12-13T12:01:23.487" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22372" PostTypeId="2" ParentId="22369" CreationDate="2016-03-27T21:24:19.797" Score="1" Body="&lt;p&gt;As Hans Neve wrote, you should really refer to the docs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how it works in real life, when you want to write a driver for a new piece of HW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to at least understand the block diagram, programming models and register sets of the device you want to control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Then&lt;/em&gt; read whatever existing code you might find. In the practical case you have the driver for the version N-1 of the HW. Or maybe for something close enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As generic programming advice goes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;avoid any dynamic memory allocation, you will thank yourself later on, when you do not have to debug unexplained memory issues&lt;/li&gt;&#xA;&lt;li&gt;if you want to write a driver, consider making it reentrant, should the same code be shared across multiple IP blocks&lt;/li&gt;&#xA;&lt;li&gt;if you want to use OOP, avoid anything that requires runtime lookup. The compiler should have enough information to resolve everything statically.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;WRT debugging: both device drivers might suffer from interference if you try to use the serial port. Consider using some ICD tools, like the AVR Dragon. Alternatively, you might find that debugging over I2C is less penalizing. But you have to define your debugging messages.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2016-04-26T23:18:24.607" LastActivityDate="2016-04-26T23:18:24.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22373" PostTypeId="2" ParentId="22369" CreationDate="2016-03-27T21:28:22.287" Score="0" Body="&lt;p&gt;SPI is pretty trivial (see the existing SPI library). Serial is easy enough. As for the Ethernet shield you would need to look at either the existing library or the manufacturer's datasheet. Some Ethernet chips are &lt;em&gt;much&lt;/em&gt; easier to work with than others. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you look at the datasheet for the Atmega328P (as used in the Uno) they have example code (in C) for SPI - along with comments. That should let you knock off the SPI part in an hour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They also have example code for serial. Add in a ring buffer and you should be able to get serial going in half a day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After all, the assignment doesn't tell you to not use the &lt;em&gt;datasheet&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the Ethernet chip, you should be able to dig up (possibly in the chip datasheet) example code for that as well.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could always use existing libraries (eg. Serial.print) for &lt;em&gt;debugging&lt;/em&gt;, and then pull that code out once you are happy your own code works.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-27T21:28:22.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22374" PostTypeId="2" ParentId="22289" CreationDate="2016-03-28T00:55:10.630" Score="2" Body="&lt;p&gt;Think the other way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your device has a port name, that is not supported by the IDE, you can create an additional (static) symlink &lt;code&gt;/dev/USBx&lt;/code&gt; that you can identify and select in the arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, it is quite easy to &lt;a href=&quot;https://arduino.stackexchange.com/questions/3680/in-linux-how-to-identify-multiple-arduinos-connected-over-usb/22323#22323&quot;&gt;make all of your arduinos unique&lt;/a&gt; to udev.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-28T00:55:10.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22375" PostTypeId="5" CreationDate="2016-03-28T01:23:31.697" Score="0" Body="&lt;p&gt;TCP/IP (Transmission Control Protocol/Internet Protocol) is the basic communication language or protocol of the Internet. It can also be used as a communications protocol in a private network (either an intranet or an extranet). Should be used when the question is about implementing or using TCP/IP.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="11529" LastEditDate="2016-03-28T20:21:19.413" LastActivityDate="2016-03-28T20:21:19.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22376" PostTypeId="4" CreationDate="2016-03-28T01:23:31.697" Score="0" Body="This should be used when referring to the transmission protocol TCP/IP." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:38.273" LastActivityDate="2016-03-28T20:18:38.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22377" PostTypeId="1" CreationDate="2016-03-28T01:23:46.243" Score="1" ViewCount="804" Body="&lt;p&gt;Last week I purchased a couple of &lt;a href=&quot;https://www.adafruit.com/product/1501&quot; rel=&quot;nofollow noreferrer&quot;&gt;Trinkets from Adafruit (5v micro-USB)&lt;/a&gt;. The first thing I did was solder the headers to one of them. I did the whole &lt;a href=&quot;https://learn.adafruit.com/introducing-trinket?view=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;setup process&lt;/a&gt; w/ the Arduino IDE and didn't have any issues, until I actually tried uploading the &quot;&lt;a href=&quot;https://learn.adafruit.com/introducing-trinket?view=all#blink&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blink&lt;/a&gt;&quot; example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug in the Trinket, I get the pulsing red light, but when I try to upload during that, I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: error: usbtiny_send: Input/output error (expected 64, got -5)&#xA;avrdude: verification error, first mismatch at byte 0x0004&#xA;         0x1d != 0x36&#xA;avrdude: verification error; content mismatch&#xA;&#xA;avrdude: error: usbtiny_transmit: Input/output error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, if I press the reset button, I can't get it to &quot;pulse&quot; again. The red light just dimly turns on and stays constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the other Trinket I ordered (that has &lt;em&gt;not&lt;/em&gt; been soldered yet) and it works perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, did I somehow screw up something when soldering the headers? Or do I have a faulty Trinket?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, here's the trinket in question...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2L6Ro.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2L6Ro.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-04-28T09:39:26.160" Title="Soldering headers screwed up Trinket?" Tags="|adafruit|electronics|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22378" PostTypeId="5" CreationDate="2016-03-28T01:25:22.107" Score="0" Body="&lt;p&gt;Secure Shell, or SSH, is a cryptographic (encrypted) network protocol operating at layer 7 of the OSI Model to allow remote login and other network services to operate securely over an unsecured network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SSH provides a secure channel over an unsecured network in a client-server architecture, connecting an SSH client application with an SSH server.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:44.773" LastActivityDate="2016-03-28T20:18:44.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22379" PostTypeId="4" CreationDate="2016-03-28T01:25:22.107" Score="0" Body="Acronym that stand for Secure Shell it refers to a cryptographic network protocol for shell." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:21.303" LastActivityDate="2016-03-28T20:18:21.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22380" PostTypeId="5" CreationDate="2016-03-28T01:29:14.357" Score="0" Body="&lt;p&gt;Additional information about the use of the library can be found in &lt;a href=&quot;https://github.com/olikraus/U8glib_Arduino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:19:07.040" LastActivityDate="2016-03-28T20:19:07.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22381" PostTypeId="4" CreationDate="2016-03-28T01:29:14.357" Score="0" Body="Refer to the graphics library U8glib with support for many different monochrome displays." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:59.697" LastActivityDate="2016-03-28T20:18:59.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22382" PostTypeId="5" CreationDate="2016-03-28T01:30:15.013" Score="0" Body="&lt;p&gt;A printed circuit board (PCB) mechanically supports and electrically connects electronic components using conductive tracks, pads and other features etched from copper sheets laminated onto a non-conductive substrate.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:19:13.307" LastActivityDate="2016-03-28T20:19:13.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22383" PostTypeId="4" CreationDate="2016-03-28T01:30:15.013" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-28T01:30:15.013" LastActivityDate="2016-03-28T01:30:15.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22384" PostTypeId="5" CreationDate="2016-03-28T01:33:24.670" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-28T01:33:24.670" LastActivityDate="2016-03-28T01:33:24.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22385" PostTypeId="4" CreationDate="2016-03-28T01:33:24.670" Score="0" Body="DS18B20 is a digital temperature sensor." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:34.617" LastActivityDate="2016-03-28T20:18:34.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22386" PostTypeId="5" CreationDate="2016-03-28T01:36:58.093" Score="0" Body="&lt;p&gt;ST7920 LCD controller/driver IC can display alphabets, numbers, Chinese fonts and self-defined characters. It supports 3 kinds of bus interface, namely 8 bit/ 4bit and serial. All functions, including display RAM, character generator ROM, LCD display drivers and control circuits are all in a one-chip solution. With a minimum system configuration, a Chinese character display system can easily achieved.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-28T20:18:26.913" LastActivityDate="2016-03-28T20:18:26.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22387" PostTypeId="4" CreationDate="2016-03-28T01:36:58.093" Score="0" Body="For questions about the ST7920 LCD controller/driver IC, capable of displaying alphabets, numbers, Chinese fonts and self-defined characters." OwnerUserId="27346" LastEditorUserId="27346" LastEditDate="2018-10-22T15:34:50.867" LastActivityDate="2018-10-22T15:34:50.867" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22388" PostTypeId="2" ParentId="22377" CreationDate="2016-03-28T02:29:39.153" Score="-1" Body="&lt;p&gt;On this side it doesn't seem like there's a solder bridge, although it's possible there is one on the other side if you were heavy handed on the solder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you did the verification with the other unit this can't be a software or usb cable issue. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So indeed it's coming from the trinket itself. I think your best bet is to desolder the pins and check the upload again. If it's failling, try flashing a new bootloader. And if it's still not working then I guess either it was faulty from the start or you did damaged a component during the soldering.&lt;/p&gt;&#xA;" OwnerUserId="19656" LastActivityDate="2016-03-28T02:29:39.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22389" PostTypeId="2" ParentId="22353" CreationDate="2016-03-28T03:05:13.963" Score="1" Body="&lt;p&gt;How about the &lt;a href=&quot;http://www.navspark.com.tw/tutorial-4&quot; rel=&quot;nofollow&quot;&gt;http://www.navspark.com.tw/tutorial-4&lt;/a&gt; tutorial?  It seems to indicate you need a couple of the more capable $80 NS-RAW units with carrier-phase info rather than the less capable $22 NAV-SPARC plain GPS units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RTK system doesn't transmit only its positional error, (which it knows from external information) but also communicates the phase information for the particular channels, and then the RTK software re-calculates the positions of both using common sets of satellites and the phase info.  With the same framework, it knows the relative positions accurately, and with assumptions about the location of the base station, it can correct mobile station&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't an arduino problem, unless you are asking about porting RTKlib to something arduino.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-03-28T03:05:13.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22390" PostTypeId="2" ParentId="22351" CreationDate="2016-03-28T03:31:48.543" Score="1" Body="&lt;p&gt;Turns out my google-fu needs work. I found &lt;a href=&quot;https://rheingoldheavy.com/mcp3008-tutorial-02-sampling-dc-voltage/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; that works great using hardware SPI! Thanks everyone! &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-28T03:31:48.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22391" PostTypeId="1" AcceptedAnswerId="22392" CreationDate="2016-03-28T04:04:51.913" Score="0" ViewCount="625" Body="&lt;p&gt;I have an Atmega328P that I have previously burned with a bootloader configured to use the 8MHz internal clock as described &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. I would like to now burn the normal Duemilanove bootloader configured to use an external 16MHz clock onto the chip. However, when I try following the normal procedure, it says &quot;Invalid device signature&quot;. I can still upload programs to the chip and they will run, but I would like it to use the 16MHz external clock. How do I do this?&lt;/p&gt;&#xA;" OwnerUserId="3029" LastActivityDate="2016-03-28T04:44:29.470" Title="Burn normal bootloader onto Atmega328P configured to use internal 8MHz clock" Tags="|atmega328|bootloader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22392" PostTypeId="2" ParentId="22391" CreationDate="2016-03-28T04:44:29.470" Score="1" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;sketch that will upload the Optiboot bootloader&lt;/a&gt; - that will work perfectly well on the Duemilanove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latest version will be available on &lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This particular sketch is in the &quot;Atmega_Board_Programmer&quot; subdirectory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to run this sketch on another Arduino (like a Uno) and connect it up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QWfFR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QWfFR.jpg&quot; alt=&quot;Programming bootloader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-28T04:44:29.470" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22393" PostTypeId="2" ParentId="22363" CreationDate="2016-03-28T04:47:49.690" Score="2" Body="&lt;p&gt;One possible approach is to read and discard everything for a fixed time, like a second. For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long now = millis ();&#xA;while (millis () - now &amp;lt; 1000)&#xA;  Serial.read ();  // read and discard any input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not a big fan of trying to &quot;flush the input buffer&quot;. How do you know if a second is long enough? Or maybe it is too long? You are better off reading to some known delimiter.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-28T04:47:49.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22396" PostTypeId="2" ParentId="22360" CreationDate="2016-03-28T06:00:24.610" Score="1" Body="&lt;p&gt;The ESC should have no problem with 3v3 signal.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-28T06:00:24.610" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22397" PostTypeId="2" ParentId="22303" CreationDate="2016-03-28T06:13:29.700" Score="1" Body="&lt;p&gt;Normally you don't need to change the fuse settings, this configuration should be fine with the default arduino setting of &lt;/p&gt;&#xA;&#xA;&lt;p&gt;lowfuse=0xff &lt;/p&gt;&#xA;&#xA;&lt;p&gt;highfuse=0xde &lt;/p&gt;&#xA;&#xA;&lt;p&gt;extendedfuse=0x05&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial should work fine.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-28T06:13:29.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22398" PostTypeId="1" AcceptedAnswerId="22399" CreationDate="2016-03-28T06:17:54.197" Score="2" ViewCount="564" Body="&lt;p&gt;I am intending to write a code where a user will send lines through serial to affect timer interrupts. I am noticing a problem with serial where as soon as I enable the timer interrupts, the serial communication becomes garbled. More specifically, as soon as I enable the timer interrupts and I open the serial monitor, the monitor gets flooded with garbage. I haven't written too much code and this is already happening. Am I making a silly mistake? I am using an Arduino Mega 2560. My code is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Hello World!&quot;);&#xA;  timer_setup();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;}&#xA;&#xA;void timer_setup() {&#xA;  // waveform generation = 0100 = CTC&#xA;  TCCR1B &amp;amp;= ~(1 &amp;lt;&amp;lt; WGM13);&#xA;  TCCR1B |=  (1 &amp;lt;&amp;lt; WGM12);&#xA;  TCCR1A &amp;amp;= ~(1 &amp;lt;&amp;lt; WGM11);&#xA;  TCCR1A &amp;amp;= ~(1 &amp;lt;&amp;lt; WGM10);&#xA;  // output mode = 00 (disconnected)&#xA;  TCCR1A &amp;amp;= ~(3 &amp;lt;&amp;lt; COM1A0);&#xA;  TCCR1A &amp;amp;= ~(3 &amp;lt;&amp;lt; COM1B0);&#xA;  // Set the timer pre-scaler&#xA;  TCCR1B = (TCCR1B &amp;amp; ~(0x07 &amp;lt;&amp;lt; CS10)) | (2 &amp;lt;&amp;lt; CS10);&#xA;  OCR1A = 0x4000;&#xA;  TCNT1 = 0;&#xA;  // Enable timer interrupt mask 1&#xA;  TIMSK1 |= (1&amp;lt;&amp;lt;OCIE1A);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I comment out the &lt;code&gt;TIMSK1 |= (1&amp;lt;&amp;lt;OCIE1A)&lt;/code&gt; line, serial doesn't mess up. &lt;/p&gt;&#xA;" OwnerUserId="12039" LastEditorUserId="12039" LastEditDate="2016-03-28T11:44:34.473" LastActivityDate="2016-03-28T11:44:34.473" Title="Why does enabling TIMSK1 mess up serial?" Tags="|serial|arduino-mega|c++|interrupt|timers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22399" PostTypeId="2" ParentId="22398" CreationDate="2016-03-28T07:22:16.010" Score="4" Body="&lt;p&gt;You've enabled interrupts for Timer 1 Compare A interrupt. Where is the interrupt handler?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;  // whatever&#xA;}  // end of TIMER1_COMPA_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without that, the processor is just restarting. No wonder serial output is messed up.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-28T07:22:16.010" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22401" PostTypeId="1" CreationDate="2016-03-28T07:36:46.630" Score="5" ViewCount="9140" Body="&lt;p&gt;Using a 'random' function in sketch gives same pattern of numbers every-time. But, I need to generate different numbers such that any number to repeat itself should have a very less probability. &lt;/p&gt;&#xA;" OwnerUserId="19663" LastEditorUserId="19721" LastEditDate="2016-03-30T13:25:51.553" LastActivityDate="2016-06-13T07:09:14.187" Title="How to generate true random numbers over Arduino Uno without any external hardware?" Tags="|arduino-uno|sketch|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22403" PostTypeId="2" ParentId="16954" CreationDate="2016-03-28T08:25:27.160" Score="1" Body="&lt;p&gt;It looks like I now have a slight understanding of what happens and how to get the HC-05 working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be sure to have the CMD-DAT-switch set to CMD before turning on the HC-05.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Command mode (configuration)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check general AT command set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reset to default values (sets, among others, ROLE=0 and CMODE=1):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ORGL&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Set master mode and check it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ROLE=1&#xA;&amp;gt; OK&#xA;AT+ROLE?&#xA;&amp;gt; +ROLE:1&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reset and initialize (reset aborts, e.g. the inquiring state - quickly flashing LED; without initializing you would get ERROR(16)):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RESET&#xA;&amp;gt; OK&#xA;AT+INIT&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the LED should slowly flash.&#xA;Optionally: set password of the target device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+PSWD=1234&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Show count of all authenticated devices in pair list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ADCN?&#xA;&amp;gt; +ADCN:7&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the value is larger than 0, delete all authenticated devices in pair list:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+RMAAD&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now pair with the desired device (the last 20 mean 20s):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+PAIR=12,34,567890,20&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The LED starts flashing one time with a longer pause.&#xA;Set the desired device:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+BIND=12,34,567890&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now link (e.g. when connecting to the ELM327; the PC will create another new port after having requested the password from the user):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+LINK=12,34,567890&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The LED starts flashing two times with a longer pause. After linking, it might be that either the HC-05 switches to data-mode or continues in command-mode (haven't found out when it does one or the other).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Command mode (auto connect)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now switch off the HC-05 and keep the CMD-DAT-switch to CMD. Switch it on again. It should automatically connect to the previously connected device. To switch to the data mode, first disconnect...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+DISC&#xA;&amp;gt; +DISC:SUCCESS&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and reconnect.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+LINK=12,34,567890&#xA;&amp;gt; OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the connection seems to have switched to data mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Data Mode&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now switch off the HC-05 and move the CMD-DAT-switch to DAT. Turn on the HC-05. It automatically will try to connect to the previously connected device - the LED should flash two times with longer pause - and you don't have to mess with HC-05-AT commands any more.&lt;/p&gt;&#xA;" OwnerUserId="3237" LastEditorUserId="3237" LastEditDate="2016-03-28T08:31:36.990" LastActivityDate="2016-03-28T08:31:36.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22404" PostTypeId="2" ParentId="22401" CreationDate="2016-03-28T08:34:46.927" Score="6" Body="&lt;p&gt;The standard (but not very good) solution is to seed the random number generator from an &lt;code&gt;analogRead()&lt;/code&gt; on an unconnected pin. For better options, see &lt;a href=&quot;https://arduino.stackexchange.com/a/22081&quot;&gt;this answer&lt;/a&gt; to a related question.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-28T08:34:46.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22405" PostTypeId="1" CreationDate="2016-03-28T09:08:35.337" Score="4" ViewCount="5985" Body="&lt;p&gt;I am using Arduino Uno, with &lt;strong&gt;PID&lt;/strong&gt; library and &lt;a href=&quot;http://www.i2cdevlib.com/devices/mpu6050#source&quot; rel=&quot;nofollow&quot;&gt;Jeff Rowberg library for MPU6050&lt;/a&gt; i.e &lt;code&gt;I2Cdev.h&lt;/code&gt;, &lt;code&gt;MPU6050_6Axis_MotionApps20.h&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is one PID for each axis i.e Pitch and Roll, I am getting output that wobbles and is unstable. I don't know whether my code is wrong or something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Errors which I feel are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I am using &lt;code&gt;Esc.write()&lt;/code&gt;, I know Microseconds should be used but it feels very light, even it doesn't wobble.&lt;/li&gt;&#xA;&lt;li&gt;Kalman Filter not used, but I am getting the pitch, roll, yaw.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow&quot;&gt;PID library (By Brett Beauregard)&lt;/a&gt; not suitable for Quadcopter.&lt;/li&gt;&#xA;&lt;li&gt;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;else if (mpuIntStatus &amp;amp; 0x02) // wait for correc available data length, should be a VERY short wait&#xA;         while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount(); &#xA;&lt;/code&gt;&lt;/pre&gt;This statement in loop making loop slow, it's written in its comment and maybe it making pid compute upset&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Please look at code.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;        // display Euler angles in degrees&#xA;        mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;        mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;        mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;        yaw = ypr[0] * 180/M_PI;&#xA;        pitch = ypr[1] * 180/M_PI;&#xA;        roll = ypr[2] * 180/M_PI;&#xA;&#xA;        Input = pitch;&#xA;        RInput = roll;&#xA;        myPID.SetTunings(Kp,Ki,Kd);&#xA;        myPIDR.SetTunings(RKp,RKi,RKd);&#xA;&#xA;        //Sample Time is 10 for both PID.&#xA;&#xA;             myPID.Compute();&#xA;              myPIDR.Compute();&#xA;&#xA;        if(armed == 1) {&#xA;          int m1 = throttle.toInt() + Output;&#xA;          int m2 = throttle.toInt() + ROutput;&#xA;          int m3 = throttle.toInt() - Output;&#xA;          int m4 = throttle.toInt() - ROutput;&#xA;&#xA;&#xA; int angle1 = map(m1, 0, 100, 0, 180);&#xA; ESC1.write(angle1); //FRONT PITCH+&#xA; int angle2 = map(m2, 0, 100, 0, 180);&#xA; ESC2.write(angle2); //LEFT ROLL+&#xA; int angle3 = map(m3, 0, 100, 0, 180); &#xA; ESC3.write(angle3); //BACK PITCH-&#xA; int angle4 = map(m4, 0, 100, 0, 180); &#xA; ESC4.write(angle4); //RIGHT ROLL-&#xA;        }&#xA;    #endif  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Kp = 0.25, Ki = 0.04, Kd = 0.05&lt;/em&gt; | &#xA;&lt;em&gt;RKp = 0.25, RKi = 0.04, RKd = 0.05&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;From testing: if I shake my Quadcopter fast by hand it behaves like PID is activated and works as wanted, but suddenly after a couple of seconds again feel loose, may be PID compute become upset&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="19664" LastEditorUserId="2944" LastEditDate="2016-03-31T13:23:11.410" LastActivityDate="2016-03-31T13:23:11.410" Title="QuadCopter PID using MPU6050" Tags="|arduino-uno|mpu6050|pid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22406" PostTypeId="2" ParentId="22360" CreationDate="2016-03-28T09:17:33.977" Score="0" Body="&lt;p&gt;Signal can be send easily from Arduino Pro mini to ESC, Simply either use .write() or .Microseconds() function.&lt;/p&gt;&#xA;" OwnerUserId="19664" LastActivityDate="2016-03-28T09:17:33.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22407" PostTypeId="1" CreationDate="2016-03-28T09:35:51.527" Score="2" ViewCount="475" Body="&lt;p&gt;I am using two XBee Series 2 modules (Zigbee), an Arduino Uno, and a HC-SR04 Ultrasonic sensor to send distance readings from the coordinator XBee on the Arduino to the XBee connected to my computer. I configured the ArduinoXBee as &quot;Zigbee coordinator AT&quot; and the ComputerXBee as &quot;Zigbee end device AT&quot; with the following networking settings:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Coordinator:&#xA;PanID: 1234&#xA;DH: 0&#xA;DL: FFFF &lt;/p&gt;&#xA;&#xA;&lt;p&gt;End Device:&#xA;PanID: 1234&#xA;DH: 0&#xA;DL: 0 (so it can only talk to the coordinator) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I am facing is that when I open the End Device terminal on X-CTU, the distance readings I get are accurate yet very unstable. Like it receives the correct readings but the transmission is unsynchronized as it sometimes receives 5 numbers in one transmission and lags for 10 seconds then receives the next bunch and lags for another 10 seconds and so on... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;const int trigPin = 13;&#xA;const int echoPin = 9;&#xA;&#xA;SoftwareSerial xbee(10, 11); // RX, TX&#xA;&#xA;void setup()  {&#xA;   xbee.begin( 9600 );&#xA;   pinMode(trigPin, OUTPUT);&#xA;   pinMode(echoPin, INPUT);&#xA;}&#xA;void loop()  {&#xA;long duration, distance;&#xA;  digitalWrite(trigPin, LOW);  &#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10); &#xA;  digitalWrite(trigPin, LOW);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;  distance = (duration/2) / 29.1;&#xA;  xbee.println( distance );&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="19668" LastActivityDate="2018-01-11T18:35:55.530" Title="XBee unstable sensor data transmission" Tags="|serial|sensors|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22408" PostTypeId="2" ParentId="17028" CreationDate="2016-03-28T09:39:43.883" Score="1" Body="&lt;p&gt;Try using the following code you need to use String and concatenate that&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    String rcev_data=&quot;&quot;;&#xA;bool chk=false;&#xA;\#define output 9&#xA;&#xA;\#define output2 10&#xA;&#xA;void setup() &#xA;{&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(output, OUTPUT);&#xA;  pinMode(output2, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  // put your main code here, to run repeatedly:&#xA;  while(Serial.available())&#xA;  {&#xA;    char rxx = Serial.read();&#xA;    recv.concat(rxx);&#xA;    delay(10);&#xA;    if (recv == &quot;QWER&quot;)&#xA;    {&#xA;       chk=1;&#xA;       break;&#xA;     }&#xA;    else&#xA;     chk=0;&#xA; }&#xA;&#xA;&#xA;&#xA;  if (chk)&#xA;  {&#xA;    digitalWrite(output,HIGH);&#xA;    Serial.println(&quot;ON&quot;);&#xA;    delay(3000);&#xA;    chk=0;&#xA;  }&#xA;&#xA;  else&#xA;  {&#xA;    digitalWrite(output,LOW);&#xA;  }&#xA;  recv=&quot;&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16299" LastEditorUserId="16299" LastEditDate="2016-03-28T09:46:53.790" LastActivityDate="2016-03-28T09:46:53.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22409" PostTypeId="1" AcceptedAnswerId="22412" CreationDate="2016-03-28T09:59:20.907" Score="3" ViewCount="247" Body="&lt;p&gt;So im just running a 328p at 8mhz with the internal oscillator. Datasheet says 1.8 to 5.5v is voltage range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will 3xAA in series (~4.5v) last longer than 2xAA in series (~3v), assuming all batteries have the same capacity, theoretically each option should have the same mAh but does the difference in voltage affect things ?&lt;/p&gt;&#xA;" OwnerUserId="4024" LastEditorUserId="4024" LastEditDate="2016-03-28T10:20:54.770" LastActivityDate="2016-03-29T01:46:18.490" Title="Barebones 328p, 2xAA vs 3xAA, which will last longer?" Tags="|atmega328|battery|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22411" PostTypeId="1" CreationDate="2016-03-28T11:02:08.290" Score="1" ViewCount="434" Body="&lt;p&gt;I'm using Arduino Uno R3 and the official Arduino WiFi Shield R3. I'm trying to update the Shield's firmware to 1.1.0 through &lt;a href=&quot;http://www.bustatech.com/upgrade-arduino-wifi-shield/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; guide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything goes fine until Step 9. When I execute the code in Step 10, I get an error (see attachment) as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;AtLibUsbDfu: 3EB 2FF8 no device present&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;FAIL Could not open USB device.&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;ISP done.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/93FSy.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/93FSy.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;EDIT:&lt;/em&gt;&lt;/strong&gt; I re-installed the firmware on my shield and now the problem's gone.&lt;/p&gt;&#xA;" OwnerUserId="18846" LastEditorUserId="18846" LastEditDate="2016-03-29T11:39:05.523" LastActivityDate="2016-03-29T15:12:12.997" Title="Problem updating Arduino WiFi Shield's Firmware" Tags="|wifi|firmware|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22412" PostTypeId="2" ParentId="22409" CreationDate="2016-03-28T11:11:38.080" Score="3" Body="&lt;p&gt;Yes, running at a higher voltage will consume more current.  In the datasheet you have this nice graph:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hFe5X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hFe5X.png&quot; alt=&quot;ATMega328P Voltage vs Current&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have highlighted the two voltages at 8MHz for you. At 4.5V you would typically be using about 4.7mA.  At 3V you would be using around 2.8mA.  That's not taking into account anything else in your circuit of course - just the ATMega itself. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-28T11:11:38.080" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22413" PostTypeId="2" ParentId="12634" CreationDate="2016-03-28T12:13:39.870" Score="0" Body="&lt;p&gt;Finally, here is how I did the job. In short, I separated the two topics of getting a trace of any user using &lt;code&gt;socket.io&lt;/code&gt; and giving a limitations of the number of users.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, my Arduino Yun is on a Ethernet network where a router, acting also as the internet gateway, is a dhcp server. My Arduino Yun have a static IP address in the subnet of this router (so it is not a dhclient). This can be set either by modifying the file &lt;code&gt;/etc/init.d/network&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Including the lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;config 'interface' 'wan'&#xA;        option 'proto' 'static'&#xA;        option 'ifname' 'your_interface_name'&#xA;        ipaddr xxx.xxx.xxx.xxx&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or by using the LuCi interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information about the way to properly configure the network in OpenWRT, see &lt;a href=&quot;https://wiki.openwrt.org/doc/uci/network&quot; rel=&quot;nofollow&quot;&gt;Network configuration&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the router is set to authorize only few IP addresses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The last step is to bridge the Wi-Fi and the Ethernet (WAN and LAN) keeping the configuration of the Ethernet interface. This can be done using the LuCi interface. Be careful of what interface configuration you keep. &lt;a href=&quot;http://root42.blogspot.fr/2014/01/how-to-setup-openwrt-router-as-wifi.html&quot; rel=&quot;nofollow&quot;&gt;How to setup an OpenWRT router as a Wi-Fi bridge to an Ethernet router&lt;/a&gt; gives the way to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that this can also be done using the Arduino Yun as a DHCP server if you don't want to be connected on a network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the end, any connections on the Arduino Wi-Fi will get its IP address in the authorized range (up to 16 users at the same time in my case) by the router/DHCP server through the bridge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;socket.io&lt;/code&gt;, I took the id that is given to any connected client and the IP address to ensure that I have a same user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About the NFC dynamic tag, I developed a NFC specific board with a dynamic tag in the Arduino Yun/Uno format and its library to push through the bridge between ATmega and Atheros any new Wi-Fi code or any webpage. I think it is outside of this scope so if you need anything about this I can give you in PM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I finally get at the end a device:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Connected to an existing network and accessing the internet,&lt;/li&gt;&#xA;&lt;li&gt;Serving the webpages I want using my node serve,&lt;/li&gt;&#xA;&lt;li&gt;Able to push any information on any other devices on the network through my nodeJS server,&lt;/li&gt;&#xA;&lt;li&gt;Enabling access to people to local or network content,&lt;/li&gt;&#xA;&lt;li&gt;Serving some specific local information through the NFC shield.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10646" LastEditorUserId="6936" LastEditDate="2016-03-28T18:14:45.343" LastActivityDate="2016-03-28T18:14:45.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22414" PostTypeId="1" CreationDate="2016-03-28T12:17:07.097" Score="2" ViewCount="901" Body="&lt;p&gt;I'm planning on making my own Bluetooth mechanical keyboard using the Adafruit Feather 32u4 Bluetooth LE. Something that I haven't really figured out is the programming side of things. I was wondering if there is an easy to use library for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know of the KeyPad library but I'm not sure how to handle modifier keys like Shift and CTRL with it. Any idea can help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Like said before the project I'm working on is a Bluetooth mechanical keyboard. So this means there will be 85 (at least for my design) switches in a matrix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an ideal world the library I'm looking for can do the following: I specify the keys and their position in a matrix and what the modifier keys are. It can generate the appropriate ASCII character when the matching key(s) are pressed and return it or something, so that I can send it over Bluetooth in another piece of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a less ideal world I use the KeyPad library but I don't really know how to take care of modifier keys like shift when doing that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a nice day!&lt;/p&gt;&#xA;" OwnerUserId="16572" LastEditorUserId="84" LastEditDate="2016-12-25T07:40:20.070" LastActivityDate="2017-03-25T10:35:48.863" Title="Library for DIY Keyboard" Tags="|programming|bluetooth|adafruit|keyboard|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22416" PostTypeId="1" CreationDate="2016-03-28T13:30:24.213" Score="1" ViewCount="182" Body="&lt;p&gt;I want to have a loop of 4 colours which runs constantly (i.e. red -&gt; green -&gt; blue -&gt; white) each of the colours having their own LED and pin on the Arduino board. There is a 7 second delay between switching the colour and this cycle should run continuously. When I press a button, I want the cycle to immediately switch back to green and continue the cycle (i.e. -&gt; blue -&gt; white -&gt; red) again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should I go about this? Can you have a listener for a button press going at the same time as a delay? How do you interrupt the timer and change the active LED?&lt;/p&gt;&#xA;" OwnerUserId="19675" LastActivityDate="2016-03-29T14:39:55.483" Title="How to interrupt a Timer to Change position along a Colour Cycle" Tags="|led|interrupt|timers|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22417" PostTypeId="1" CreationDate="2016-03-28T13:51:51.527" Score="3" ViewCount="4832" Body="&lt;p&gt;I'm reading a code that uses Arduino as a webclient and when he tries to catch the info from the site, he uses a callback with the following parameters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static void response_callback (byte status, word off, word len)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain me how does each one of this parameters work exactly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS.: The example I got it from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EtherCard.h&amp;gt;&#xA;&#xA;#define HTTP_HEADER_OFFSET 0&#xA;static byte mymac[] = {0x12,0x34,0x56,0x78,0x90,0xAB};&#xA;char website[] PROGMEM = &quot;www.yourwebsite.com&quot;;&#xA;&#xA;byte Ethernet::buffer[700];&#xA;static uint32_t timer = 0;&#xA;&#xA;static void response_callback (byte status, word off, word len) {&#xA;  Serial.print((const char*) Ethernet::buffer + off + HTTP_HEADER_OFFSET);&#xA;} &#xA;&#xA;void setup () {&#xA;  Serial.begin(57600);&#xA;&#xA;  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))&#xA;  {&#xA;    Serial.println(&quot;Failed to access Ethernet controller&quot;);&#xA;    while(1);&#xA;  }&#xA;  else&#xA;    Serial.println(&quot;Ethernet controller initialized&quot;);&#xA;  Serial.println();&#xA;&#xA;  if (!ether.dhcpSetup())&#xA;  {&#xA;    Serial.println(&quot;Failed to get configuration from DHCP&quot;);&#xA;    while(1);&#xA;  }&#xA;  else&#xA;    Serial.println(&quot;DHCP configuration done&quot;);&#xA;&#xA;  if (!ether.dnsLookup(website))&#xA;  {&#xA;    Serial.println(&quot;DNS failed&quot;);&#xA;    while(1);&#xA;  }&#xA;  else &#xA;    Serial.println(&quot;DNS resolution done&quot;); &#xA;&#xA;  ether.printIp(&quot;SRV IP:\t&quot;, ether.hisip);&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;  ether.packetLoop(ether.packetReceive());&#xA;&#xA;  if (millis() &amp;gt; timer) {&#xA;    timer = millis() + 5000;&#xA;    ether.browseUrl(&quot;/&quot;, &quot;yourpage.php&quot;, website, response_callback);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19678" LastEditorUserId="7508" LastEditDate="2016-04-27T16:11:51.703" LastActivityDate="2017-08-21T20:08:58.620" Title="What are the parameters of the browseUrl() callback in the Ethercard library?" Tags="|arduino-mega|ethernet|callbacks|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22418" PostTypeId="1" AcceptedAnswerId="22420" CreationDate="2016-03-28T15:12:20.887" Score="3" ViewCount="3771" Body="&lt;p&gt;Is it possible to create an IP-to-USB HID (keyboard) using Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to connect an Arduino to my network using Ethernet, and then send it commands using TCP/IP and have those commands translated to USB HID and sent as keystrokes to the connected PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a few articles discussing USB HID emulation using the Arduino Uno (see &lt;a href=&quot;http://mitchtech.net/arduino-usb-hid-keyboard&quot; rel=&quot;nofollow&quot;&gt;http://mitchtech.net/arduino-usb-hid-keyboard&lt;/a&gt;) but it refers to using GPIO pins as buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct that this might work if I use an Arduino Uno and then purchase an Arduino Shield Ethernet?  (seems a bit expensive, but is this the cheapest option?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="19680" LastActivityDate="2020-07-21T22:19:10.167" Title="Possible to create IP-to-USB HID (keyboard) device using Arduino?" Tags="|ethernet|usb|keyboard|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22419" PostTypeId="2" ParentId="22417" CreationDate="2016-03-28T15:20:34.470" Score="1" Body="&lt;p&gt;Apparently, the callback is executed on every packet which arrives by the browseUrl call. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;off&quot; and &quot;len&quot; are pointers to the Ethernet buffer holding the data. &quot;Off&quot; are the initial value (offset) and &quot;len&quot; (length) is the amount of data received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;byte status&quot;, I am not sure what it means, but it's very likely will be some kind of error code. It's not being used in any sample I am seeing, so I am really wondering what it means...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.rogerclark.net/aurduino-ethercard-multiple-browser-request-example/&quot; rel=&quot;nofollow&quot;&gt;Check this link for a fully working sample&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Callback here are called browseUrlCallback1 and browseUrlCallback2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can't figure out a link with the detailed documentation. If someone has it, please post it.&lt;/p&gt;&#xA;" OwnerUserId="14766" LastActivityDate="2016-03-28T15:20:34.470" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22420" PostTypeId="2" ParentId="22418" CreationDate="2016-03-28T15:45:11.267" Score="2" Body="&lt;p&gt;Yes, it is perfectly possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You ideally need an Arduino with a direct USB interface, such as the Leonardo. Then you can just access the &lt;code&gt;Keyboard&lt;/code&gt; object to send the keystrokes to the PC.  How your receive the data through Ethernet is entirely up to you. A simple TCP interface may be easiest - open the connection with whatever telnet-like client and whatever you type gets sent through.  The trick will be getting it into character-at-a-time mode.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-28T15:45:11.267" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22421" PostTypeId="2" ParentId="22411" CreationDate="2016-03-28T15:50:58.250" Score="1" Body="&lt;p&gt;I cant comment because of reputation... You've already upgraded the firmware. Just when you try upgrading again your wifi device is rebooting itself because of upgrading before.&lt;/p&gt;&#xA;" OwnerUserId="19559" LastActivityDate="2016-03-28T15:50:58.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22422" PostTypeId="1" AcceptedAnswerId="33021" CreationDate="2016-03-28T15:51:18.073" Score="2" ViewCount="748" Body="&lt;p&gt;I am working on a remote control car from an Arduino Esplora board and the Mega 2650 Board. My problem lies with the Esplora board as the nRF does not transmit like it is supposed to or does not even transmit at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the &lt;a href=&quot;https://github.com/maniacbug/RF24/blob/master/tests/pingpair_test/pingpair_test.pde&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;pingpair_test.ino&lt;/code&gt;&lt;/a&gt; from the &lt;a href=&quot;https://github.com/maniacbug/RF24&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;RF24&quot;&gt;RF24&lt;/a&gt; library to make sure the transceiver is working, and when I try to transmit on the serial monitor, I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Configuration = t&#xA;&#xA;STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0 &#xA;&#xA;RX_ADDR_P0-1 = 0x0000000000 0x0000000000&#xA;&#xA;RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00&#xA;&#xA;TX_ADDR = 0x0000000000&#xA;&#xA;RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00&#xA;&#xA;EN_AA = 0x00&#xA;&#xA;EN_RXADDR = 0x00&#xA;&#xA;RF_CH = 0x00&#xA;&#xA;RF_SETUP = 0x00&#xA;&#xA;CONFIG = 0x00&#xA;&#xA;DYNPD/FEATURE = 0x00 0x00&#xA;&#xA;Data Rate = 1MBPS&#xA;&#xA;Model = nRF24L01&#xA;&#xA;CRC Length = Disabled&#xA;&#xA;PA Power = PA_MIN&#xA;&#xA;Now sending length 4...No responses received. Are interrupts connected?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have no idea what any of this means besides the interrupts part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even using &lt;code&gt;interrupts();&lt;/code&gt; the Arduino Esplora still refuses to send data. I am sure my wiring is correct because the status light on the nRF is on and I triple checked all of the SPI pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the Esplora:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CE = 0&lt;/li&gt;&#xA;&lt;li&gt;CSN = 1&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the Mega:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CE = 51&lt;/li&gt;&#xA;&lt;li&gt;CSN = 50&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a fritzing sketch &lt;a href=&quot;https://onedrive.live.com/redir?resid=B54AEA44CB029F51!53123&amp;amp;authkey=!APUwJhmiNuUa6d8&amp;amp;ithint=file%2Czip&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;here&quot;&gt;here&lt;/a&gt; for those who want to see my wiring.&lt;/p&gt;&#xA;" OwnerUserId="12016" LastEditorUserId="4628" LastEditDate="2017-07-06T05:24:11.103" LastActivityDate="2017-07-06T05:24:11.103" Title="Why is the nRF24L01 not working with Arduino Esplora?" Tags="|spi|nrf24l01+|rf|arduino-esplora|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22423" PostTypeId="1" CreationDate="2016-03-28T15:55:34.993" Score="3" ViewCount="677" Body="&lt;p&gt;I'm trying to get consistent values from the LM335Z temperature sensor. But it behaves very strange.&lt;/p&gt;&#xA;&lt;p&gt;I'm using an arduino nano and it's powered via USB from a Raspberry Pi. The circuit also has two little reed relays (SIP-1A05), a button and a potentiometer.&#xA;It's connected like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bdpiA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bdpiA.png&quot; alt=&quot;Sketch of circuit&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Additionally I'm using &lt;code&gt;analogReference(EXTERNAL)&lt;/code&gt; in an attempt to get consistent values, so I've connected the Arduinos 5V output to the reference voltage pin.&#xA;Here's the code for reading the thermometer:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int getTemperature() {&#xA;  int rawvoltage = analogRead(0);&#xA;  float millivolts = (rawvoltage / 1024.0) * 5000;&#xA;  float kelvin = (millivolts / 10);&#xA;  float celsius = kelvin - 273.15;&#xA;  return round(celsius);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Then it just waits for me to say &amp;quot;get&amp;quot; in the serial monitor and it replies with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void sendData(){&#xA;  String data = (String)getTemperature();&#xA;  data += ',';&#xA;  data += (String)map(getTablePos(), 0, 1023, 0, 100); //Potentiometer&#xA;  data += ',';&#xA;  data += (String)getTableActive(); //1 or 0&#xA;  Serial.println(data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also read somewhere that the first couple of readings are unreliable, and that you should read a couple of times in startup, which I do:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for(int i = 0; i &amp;lt; 10; i++){&#xA;    analogRead(0);&#xA;    delay(1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Yesterday the termometer reported 37 degrees. Today it started by reporting 49 degrees. After asking for the temperature a couple of times it said 56. Then now, about an hour later it says 52. And if one of they relays is active it says 77 degrees.&#xA;My two other (non Arduino) thermometers have ben on a steady 25 all this time.&lt;/p&gt;&#xA;&lt;p&gt;What should I do to get reliable values from the LM335z?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h3&gt;Edit&lt;/h3&gt;&#xA;&lt;p&gt;Added dots to the intersections of the circuit diagram for better readability.&lt;/p&gt;&#xA;&lt;p&gt;I've also found a way to get the thermometer to work, kind of. I removed the external analog reference and only have one 1kOhm resistor for the LM335Z.&lt;br /&gt;&#xA;Then I have this code instead:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const float cal = 4.62; //Voltage between 5V and GND, measured with multimeter&#xA;    &#xA;float getTemperature() {&#xA;    float input = (float) analogRead(0);&#xA;    input = (input*cal)/1024.0;&#xA;    return (input/0.01)-273.15;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It worked perfectly standalone on an Arduino Uno powered via USB3.0. When I moved it over into my project with the Nano it gave a few degrees off, but that can be combated by just subtracting the difference I guess.&#xA;Then I tried switching to a USB2.0-port on my keyboard, and the values started jumping all over the place.&lt;br /&gt;&#xA;Here's a comparison using Arduinos rather spartan plotter:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/MpC1v.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MpC1v.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&#xA;Left: USB2.0 via keyboard hub. Right: Front panel USB3.0.&lt;/p&gt;&#xA;&lt;p&gt;Also, the temperature dubbels when a relay is on.&lt;/p&gt;&#xA;&lt;p&gt;How do I tackle this? I'd like keep powering it from my Raspberry pi 3, if possible.&lt;/p&gt;&#xA;" OwnerUserId="19677" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-29T19:42:27.423" Title="LM335Z temperature sensor gives very varying values" Tags="|arduino-nano|analogread|temperature-sensor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22424" PostTypeId="2" ParentId="22423" CreationDate="2016-03-28T16:33:58.030" Score="1" Body="&lt;p&gt;According to your schematic, one of the LM335Z's leads is floating. The pins are meant to be Vcc, Gnd, and output; the output should go to an Analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You wrote that Aref was tied to +5 but you've drawn it as going to one end of the pot with the other end of the pot grounded. The pot's wiper goes to A1 (assuming the pin hasn't been set to some other function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, check your circuit. Try wiring up the sensor to +5, Gnd, and your DVM. Then replace the DVM with A0. At that point you'll have confirmed the sensor circuit, leaving only the code and the external analog circuitry. While I only skimmed the code I don't see anything that would give flaky results. I think you're seeing analog noise, probably due to one or more of the floating sensor pin, an inconsistent or noisy Aref, and pickup in the analog input from the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;I based my connections description on this diagram&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/nJDBc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nJDBc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;, from this &lt;a href=&quot;http://www.futurlec.com/Linear/LM335Z.shtml&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;. In all of those diagrams, the Resistor-Zener connection is shown as the output and no pins are shown floating. But I did see that pin labeled as adj, for what reason I don't know. That's really why I recommended getting the sensor working by itself first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see your +5V to Aref connection now. The usual convention for indicating a connection at such a crossing is to put a dot on the intersection, just as the output pin's connection is shown in the above diagram.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-29T00:00:58.283" LastActivityDate="2016-03-29T00:00:58.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22425" PostTypeId="2" ParentId="22405" CreationDate="2016-03-28T17:13:21.970" Score="2" Body="&lt;p&gt;Quadcopters usually use 2-PID loops per axis, a rate loop and an angle loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your quadcopter needs to be very aggressive about its rate of rotation but relatively relaxed about how quickly it returns its angle to the center so it doesn't overshoot. With a single PID it will either be too slow to correct or overshoot and oscillate with no &quot;usable&quot; range of tunings in-between, because in order for its outputs to be strong enough to control the quad it will necessarily be too aggressive to smoothly align with the center position. There is a lot of math that explains why this cannot be achieved with a single loop more rigorously if you care to look into it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So try setting it up with a PitchAngle PID whose output is the setpoint of a PitchRate PID loop whose output goes to the motors, and similarly with the Roll.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is only one possible problem though, there is a huge number of things that could be wrong. Are your pitch and roll measurements angles to the horizon or euler angles? how fast is your loop running? Are oscillations induced by the motors causing your accelerometer reading/attitude filter combo to be unusable? Are the PID parameters correct? Is the accelerometer's bias calibrated? Is the gyro drift calibrated? Are all you ESC's calibrated the same way?&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-03-28T17:13:21.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22426" PostTypeId="1" AcceptedAnswerId="22473" CreationDate="2016-03-28T17:52:35.920" Score="2" ViewCount="2270" Body="&lt;h2&gt;Problem description&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a datalogger with an Arduino UNO. I have connected a SD card module to the Arduino. I have planned to catch the measurement data from the analog input pins. Everything works fine if connected to the usb port. But if I run the Arduino over an external power supply, the &lt;code&gt;SD.open&lt;/code&gt;-method fails (It simply returns false).&#xA;The problem occurs even, if I connect the external power supply additional to the USB connection. So the problem can't be a missing serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the problem only occurs, if &lt;code&gt;SD.open&lt;/code&gt; is in WRITE-mode.&#xA;(&lt;code&gt;File dataFile = SD.open(&quot;datalog.txt&quot;, FILE_WRITE);&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;What I've already tried:&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;running the SD-card example code, which is included in the SD card library.&lt;/li&gt;&#xA;&lt;li&gt;trying different types of file-system formattings (FAT, FAT32, with different cluster-sizes)&lt;/li&gt;&#xA;&lt;li&gt;powering the sd-card reader with 3.3V instead of 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h2&gt;Arduino wiring&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Look at the pictures to check if there are some mistakes with the wiring:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vubul.jpg&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Digital inputs on the arduino&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vubul.jpg&quot; alt=&quot;Digital inputs on the arduino&quot; title=&quot;Digital inputs on the arduino&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UK4cz.jpg&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Wiring on the SD-card module and power connection&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UK4cz.jpg&quot; alt=&quot;Wiring on the SD-card module and power connection&quot; title=&quot;Wiring on the SD-card module and power connection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Specifications of the power supply&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;And here are the specifications of the power supply:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Manufacturer:&lt;/strong&gt; MyVolts&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Model:&lt;/strong&gt; DD282MU&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Input:&lt;/strong&gt; 100-240V (AC) - 50-60 Hz&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Output:&lt;/strong&gt; 9V, 1A (DC)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I hope you can help me with my problem. And of course, I hope there is a solution for the problem at all. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="19681" LastActivityDate="2019-12-25T19:16:05.890" Title="SD-Card-Module doesnt work with external power supply" Tags="|arduino-uno|power|sd-card|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22428" PostTypeId="1" AcceptedAnswerId="22429" CreationDate="2016-03-28T19:44:45.153" Score="1" ViewCount="3314" Body="&lt;p&gt;Im simply trying to pass my payload to another device that has the same architecture and struct. I'm using UART to transfer, and modeling the protocol from EasyTransfer.&lt;/p&gt;&#xA;&lt;p&gt;When I call &lt;code&gt;Serial.print((char*)mydata.data);&lt;/code&gt; in Transfer it prints Hello World as expected.&lt;/p&gt;&#xA;&lt;p&gt;Calling that same line in Receive prints a '?' to console. This may be some background behavior with Arduino, or I'm just not casting/handling the pointers correctly. How can I get this print out to function properly?&lt;/p&gt;&#xA;&lt;p&gt;Transfer Sketch&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EasyTransfer.h&amp;gt;&#xA;&#xA;//create object&#xA;EasyTransfer TransferObject; &#xA;&#xA;//Struct contents must be idential to struct from other board&#xA;#define PAYLOAD_SIZE 255&#xA;struct SEND_DATA_STRUCTURE&#xA;{&#xA;  int blinks;&#xA;  int pause;&#xA;&#xA;  uint8_t data[PAYLOAD_SIZE];&#xA;};&#xA;&#xA;//give a name to the group of data&#xA;SEND_DATA_STRUCTURE mydata;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  //#define details(name) (byte*)&amp;amp;name,sizeof(name) &#xA;  TransferObject.begin(details(mydata), &amp;amp;Serial);&#xA;  &#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  //initalize not so random number generator&#xA;  randomSeed(analogRead(0));&#xA;  &#xA;}&#xA; &#xA;void loop()&#xA;{&#xA;  //mydata.blinks = random(5);&#xA;  //mydata.pause = random(5);&#xA;&#xA;  //Create payload to transfer&#xA;  char* payload = &amp;quot;Hello World!&amp;quot;;&#xA;&#xA;  //Fill array with data&#xA;  strncpy((char *)mydata.data, payload, PAYLOAD_SIZE);&#xA;&#xA;  //Print sample&#xA;  Serial.print((char*)mydata.data);&#xA;  &#xA;  //send the entire struct&#xA;  TransferObject.sendData();&#xA;  &#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Receive Sketch&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;EasyTransfer.h&amp;gt;&#xA;&#xA;//create object&#xA;EasyTransfer TransferObject; &#xA;&#xA;//Struct contents must be idential to struct from other board&#xA;#define PAYLOAD_SIZE 255&#xA;struct RECEIVE_DATA_STRUCTURE&#xA;{&#xA;  int blinks;&#xA;  int pause;&#xA;  &#xA;  uint8_t data[PAYLOAD_SIZE];&#xA;};&#xA;&#xA;//give a name to the group of data&#xA;RECEIVE_DATA_STRUCTURE mydata;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;&#xA;  //#define details(name) (byte*)&amp;amp;name,sizeof(name) &#xA;  TransferObject.begin(details(mydata), &amp;amp;Serial);&#xA;  &#xA;  pinMode(13, OUTPUT);&#xA;  &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //check and see if a data packet has come in. &#xA;  if(TransferObject.receiveData())&#xA;  {&#xA;    Serial.print(&amp;quot;active&amp;quot;);&#xA;    //print data payload&#xA;    Serial.print((char*)mydata.data);&#xA;    }&#xA;  &#xA;  //you should make this delay shorter then your transmit delay or else messages could be lost&#xA;  delay(250);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is &lt;a href=&quot;https://github.com/madsci1016/Arduino-EasyTransfer/tree/master/EasyTransfer&quot; rel=&quot;nofollow noreferrer&quot;&gt;an exerpt and variant from this library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19328" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-03-28T21:24:25.087" Title="Casting a struct member between uint8_t and char, with regard to serial transfer" Tags="|serial|c++|uart|pointer|struct|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22429" PostTypeId="2" ParentId="22428" CreationDate="2016-03-28T19:51:50.373" Score="1" Body="&lt;p&gt;You're actually falling into a common problem with pointers in structs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct SEND_DATA_STRUCTURE&#xA;{&#xA;  int blinks;&#xA;  int pause;&#xA;&#xA;  uint8_t *data;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;contains three values: blinks, pause and a pointer to the data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t *data;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That doesn't contain the data. That only contains the address that the data is stored at in memory.  When you transfer the struct it's that address that you are sending - then when the other end tries to print it all it can do is look at the address it's been told about and try and print whatever is in there - and that is complete garbage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of storing a pointer to the data you need to store the actual data itself. That means that you need to decide upon a maximum size for that data and pre-allocate the memory within the struct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DATA_SIZE 40&#xA;&#xA;struct SEND_DATA_STRUCTURE&#xA;{&#xA;  int blinks;&#xA;  int pause;&#xA;&#xA;  uint8_t data[DATA_SIZE];&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in order to get the data into that struct you need to fill that array with your payload. For strings the simplest way is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strncpy((char *)mydata.data, payload, DATA_SIZE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will copy &lt;em&gt;up to&lt;/em&gt; &lt;code&gt;DATA_SIZE&lt;/code&gt; characters from &lt;code&gt;payload&lt;/code&gt; into &lt;code&gt;mydata.data&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that if &lt;code&gt;payload&lt;/code&gt; contains more than &lt;code&gt;DATA_SIZE-1&lt;/code&gt; characters the data in &lt;code&gt;mydata.data&lt;/code&gt; will not be NULL terminated. You can get round that by forcing NULL termination:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mydata.data[DATA_SIZE-1] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;In your revised code your payload size is too big. The way the EasyTransfer library works is it has a single byte for the size of the payload. Your total payload size is PAYLOAD_SIZE + 2 ints - that is 255 + 2 + 2 = 259 bytes.  Placed into a single byte that gets truncated to 3. That means you are actually transferring one and a half integers and nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to ensure that your entire struct never exceeds 255 bytes. So you can have a maximum size of data, once you have taken your two integers into account (assuming 16-bit integers on an 8-bit Arduino), of 251 bytes.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-03-28T21:24:25.087" LastActivityDate="2016-03-28T21:24:25.087" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22430" PostTypeId="1" CreationDate="2016-03-28T20:33:00.307" Score="0" ViewCount="621" Body="&lt;p&gt;I want to apply a Kalman Filter to the humidity data which I retrieve of the DHT11. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;" OwnerUserId="19685" LastEditorUserId="2902" LastEditDate="2016-03-29T01:45:35.930" LastActivityDate="2016-03-29T01:45:35.930" Title="Can I apply a Kalman filter to DHT11 data?" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22431" PostTypeId="2" ParentId="22430" CreationDate="2016-03-28T20:44:14.327" Score="4" Body="&lt;p&gt;Learn about the kalman filter and what it does. It requires a certain understanding of what it is, what it is good for and why you would eventually use it. It seems to me, that at the moment this isn't your strongest topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thereafter, figure out which !multiple! sensor values you have, since only with a &quot;model&quot; and an &quot;observation&quot; a filter of this kind makes sense in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To specifically adress your question: you can apply any filter to any data. The hidden question, if it makes sense in this case is not trivial to answer, since you didn't exactly provide the vast information. My guess is, you only have this one sensor, and it would be (at this state of knowledge) a reasonable idea to use a bandpass filter of sorts instead.&lt;/p&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2016-03-28T20:44:14.327" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22432" PostTypeId="1" AcceptedAnswerId="22433" CreationDate="2016-03-28T21:00:45.193" Score="2" ViewCount="1325" Body="&lt;p&gt;I seek to call an ISR routine after a fixed time of 400us. This action needs to be done every now and then (in the range of 0.8-3.0ms). For that matter, I thought I'd set timer2 to CTC mode, use OCR2A to set some TOP value for 400us and let the timer call the ISR routine after 400us. Within the ISR I would then stop the timer from triggering interrupts, until I need to count to 400us again, where I would activate the timer interrupt again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works, as expected, except for the fact, that after activating the interrupt for OCR2A again, it instantly triggers. The code below, produces a 1ms alternating signal, instead of 1ms+400us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, am I on a good way with this, or should I use the overflow ISR and preload the timer? Or any other method? The problem is, that after the 1ms waiting time in the main loop, I'd expect the counter to count from 0 to 100, meaning 400us. However on an oscilloscope I see the pin toggle each 1ms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t timestamp;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(9, OUTPUT);&#xA;  cli();         // disable global interrupts&#xA;  // Timer2 for counting (to release the pin)&#xA;  TCCR2A |= (1 &amp;lt;&amp;lt; WGM21); // CTC mode, clear timer on compare match&#xA;  TCCR2B |= (1 &amp;lt;&amp;lt; CS22); // Prescalar 64&#xA;&#xA;  OCR2A = 99; // ticks, before ISR is called&#xA;  TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A); // enable timer compare interrupt&#xA;  TCNT2 = 0x00; // set the timer to 0&#xA;  // counting time[s] = (OCR+1)/(F_cpu/prescalar)&#xA;  // 99 = 400us | 124 = 500us&#xA;  sei(); // enable global interrups&#xA;  timestamp = micros();&#xA;}&#xA;&#xA;void loop() {&#xA;  uint32_t now = micros();&#xA;  if (now - timestamp &amp;gt; 1000) {&#xA;    timestamp = now;&#xA;    cli();&#xA;    TIMSK2 |= (1 &amp;lt;&amp;lt; OCIE2A); // enable timer compare interrupt&#xA;    sei();&#xA;    TCNT2 = 0x00;&#xA;  }&#xA;}&#xA;&#xA;ISR(TIMER2_COMPA_vect) {&#xA;  // Serial.print(F(&quot;Here\n&quot;));&#xA;  PORTB ^= 2; // set pin 9 high again&#xA;  // TCNT2 = 0x00; // reset timer for testing&#xA;  // deactivate the counter&#xA;   cli();&#xA;   TIMSK2 = 0x00; // unlink the ISR from timer&#xA;   sei();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2902" LastActivityDate="2016-03-29T20:45:13.883" Title="Irregularly triggering an ISR using timers" Tags="|interrupt|timers|isr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22433" PostTypeId="2" ParentId="22432" CreationDate="2016-03-29T00:41:09.790" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;However on an oscilloscope I see the pin toggle each 1ms.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's what you expect. You set up the timer to fire every 1 ms. Since the ISR is called some time after that (and that is what toggles the pin) you will see the pin toggle every 1 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've reworked your example a bit to make it clearer, and to toggle the pin when we start the timer, and again when the ISR fires:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;uint32_t timestamp;&#xA;&#xA;void setup() &#xA;  {&#xA;  pinMode(9, OUTPUT);&#xA;  // Timer2 for counting &#xA;  TCCR2A = bit (WGM21); // CTC mode, clear timer on compare match&#xA;  OCR2A = 99;           // ticks, before ISR is called&#xA;&#xA;  // counting time[s] = (OCR+1)/(F_cpu/prescalar)&#xA;  // 99 = 400us | 124 = 500us&#xA;  timestamp = micros();&#xA;  }  // end of seupt&#xA;&#xA;void loop() &#xA;{&#xA;  uint32_t now = micros();&#xA;  if (now - timestamp &amp;gt;= 1000) &#xA;    {&#xA;    timestamp = now;&#xA;    TIFR2 = bit (OCF2A);   // clear any pending interrupt&#xA;    TCNT2 = 0;             // make sure counter is zero&#xA;    TIMSK2 = bit (OCIE2A); // enable timer compare interrupt&#xA;    TCCR2B = bit (CS22);   // start timer: Prescalar 64&#xA;    PINB = bit (1);        // toggle pin 9&#xA;    }  // end of if&#xA;}  // end of loop&#xA;&#xA;ISR(TIMER2_COMPA_vect) &#xA;{&#xA;  PINB = bit (1); // toggle pin 9&#xA;  TCCR2B = 0;     // stop timer&#xA;}  // end of TIMER2_COMPA_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see from the scope output that the timer is started every 1 ms (as expected) because Cursor 1 is at -1 ms. The width of the pulse is 400 µs, as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ranlV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ranlV.png&quot; alt=&quot;Timer 2 scope output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In my example I do not have to set so many settings each time I want to start the timer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I took out the &lt;code&gt;cli&lt;/code&gt; and &lt;code&gt;sei&lt;/code&gt; so I saved you two lines. Don't forget to count them!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you leave the timer running, it may well have reached the counter again (even though not generating an interrupt). Thus this line is important (even more so for you):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;TIFR2 = bit (OCF2A);   // clear any pending interrupt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, if you leave the timer running, you may have a race condition. Say the timer is just about to tick over and generate the interrupt. You clear the flag (as shown above), but one machine cycle later the timer reaches the counter and sets it again, just before you get a chance to zero it. With the timer running, there could be combinations of when you enable interrupts, zero the flag, and clear the pending interrupt flag, that could occasionally work against you. Having the timer stopped is much safer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if you are worried about the number of lines you need to start it (I wouldn't be) then you can move this line into setup:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;TIMSK2 = bit (OCIE2A); // enable timer compare interrupt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you stop the timer in the ISR it doesn't matter if the interrupt is still enabled. Now you just have three lines to start the timer:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;TIFR2 = bit (OCF2A);  // clear any pending interrupt&#xA;TCNT2 = 0;            // make sure timer is zeroed&#xA;TCCR2B = bit (CS22);  // start timer: Prescalar 64&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think we've agreed that clearing the compare flag is important, so this isn't any lengthier.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;looking at your divisioning of the time axis, and from code, it is clear, that there is a 600us break, not 1ms!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, there's a 600 µs break, because you start the timer every 1 ms, and it runs for 400 µs, thus there will be a 600 µs break.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I seek to call an ISR routine after a fixed time of 400us. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's exactly what my posted code does. The pin goes high at the time you desire, in loop, and it goes low 400 µs later. That's what you wanted: a 400 µs interval.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-03-29T20:45:13.883" LastActivityDate="2016-03-29T20:45:13.883" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22435" PostTypeId="2" ParentId="22409" CreationDate="2016-03-29T01:46:18.490" Score="2" Body="&lt;p&gt;Majenko's answer is correct, however he (or both of you) are assuming that the processor clock is running. When it runs, a processor cycle at a higher voltage will use more current. However when in power-down sleep mode the clock stops, and consumption is much lower. If you don't need the watchdog timer (for example, a switch closure activates the processor) then the difference will be negligible. Indeed, the current consumption is around 100 nA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JdOHg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JdOHg.png&quot; alt=&quot;Current usage - no watchdog timer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need the watchdog to periodically wake you, then the difference will be about 2 µA (that's a lot less than 2.8 mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yC6Je.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yC6Je.png&quot; alt=&quot;Current usage - watchdog timer&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are quoted at room temperature - around 25°C.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would be concerned about 2 x AA batteries. Their nominal voltage might be 3V, but their actual voltage (say, if they are NiMh batteries) might be closer to 2.4V, and that is the minimal amount for running at 8 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With 3 x AA batteries you are much more safely in range for the voltage requirements, particularly if you have some peripherals that might drain power, and thus lower the voltage.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Other discussions about low-power considerations at &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/power&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-29T01:46:18.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22436" PostTypeId="1" CreationDate="2016-03-29T05:28:02.817" Score="1" ViewCount="1882" Body="&lt;p&gt;I want to monitor the vibration from a motor running at 9.5Hz at 565rpm. I am using Arduino Uno and the ADXL345 as my condition monitoring equipment. How do I set the sampling frequency? I want to sample at at least 5x more than the operating frequency which is 50Hz, which will give a interval of 0.02 sec. However, to collect 2500 readings, I would need to take around 300 sec which is 0.12sec per reading different from the preset value at 0.02 sec. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my code wrong somewhere? Or what can I do to speed up the process? &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#define DEVICE (0x53)    //ADXL345 device address&#xA;#define TO_READ (6)        //num of bytes we are going to read each time    (two bytes for each axis)&#xA;#define THRESH_ACT  (0x24)&#xA;#define THRESH_INACT  (0x25)&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;File myFile;&#xA;&#xA;// Declare Variable&#xA;byte runComplete; //setting the number of iteration&#xA;int i; //delare i for count&#xA;byte buff[TO_READ];//6 bytes buffer for saving data read from the device&#xA;float x, y, z; //Acceleration variable&#xA;float x1, y1, z1; //Acceleration variable&#xA;&#xA;void writeTo(int device, byte address, byte val) {&#xA;  Wire.beginTransmission(device); //start transmission to device&#xA;  Wire.write(address);        // send register address&#xA;  Wire.write(val);        // send value to write&#xA;  Wire.endTransmission(); //end transmission&#xA;}&#xA;&#xA;void readFrom(int device, byte address, int num, byte buff[]) { //reads num bytes starting from address register on device in to buff array&#xA;  Wire.beginTransmission(device); //start transmission to device&#xA;  Wire.write(address);        //sends address to read from&#xA;  Wire.endTransmission(); //end transmission&#xA;  int n = Wire.requestFrom(device, num);    // request 6 bytes from device&#xA;  if( n == num)&#xA;  {     &#xA;      Wire.readBytes(buff, n);&#xA;  }&#xA;    }&#xA;void regAddress()&#xA;{&#xA;    int regAddress = 0x32;    //first axis-acceleration-data register on the ADXL345&#xA;    readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345&#xA;&#xA;     //each axis reading comes in 10 bit resolution, ie 2 bytes.  Least Significat Byte first!!&#xA;     //thus we are converting both bytes in to one int&#xA;    x = (((int)buff[1]) &amp;lt;&amp;lt; 8) | buff[0];  &#xA;    y = (((int)buff[3])&amp;lt;&amp;lt; 8) | buff[2];&#xA;    z = (((int)buff[5]) &amp;lt;&amp;lt; 8) | buff[4];&#xA;&#xA;    x1 = (x/256);&#xA;    y1 = (y/256);&#xA;    z1 = (z/256);&#xA;&#xA; Serial.println(&quot; &quot;);&#xA;    Serial.print(&quot;X: &quot;);Serial.print(x1); Serial.println(&quot; mm/s2&quot;);&#xA;    Serial.print(&quot;Y: &quot;);Serial.print(y1); Serial.println(&quot; mm/s2&quot;);&#xA;    Serial.print(&quot;Z: &quot;);Serial.print(z1); Serial.println(&quot; mm/s2&quot;);&#xA;    Serial.println(&quot; &quot;);&#xA;&#xA;    myFile = SD.open(&quot;x30.txt&quot;, FILE_WRITE); // if the file opened okay, write to it:&#xA;    if (myFile) {&#xA;      Serial.print(&quot;Writing to X.txt...&quot;);&#xA;      myFile.println(x1);&#xA;      myFile.close();// close the file:&#xA;      Serial.println(&quot;done.&quot;);&#xA;    } else {&#xA;      Serial.println(F(&quot;error opening x.txt&quot;)) ;// if the file didn't open, print an error:&#xA;    }&#xA;&#xA;    myFile = SD.open(&quot;y30.txt&quot;, FILE_WRITE); // if the file opened okay, write to it:&#xA;    if (myFile) {&#xA;      Serial.print(&quot;Writing to Y.txt...&quot;);&#xA;      myFile.println(y1);&#xA;      myFile.close();// close the file:&#xA;      Serial.println(&quot;done.&quot;);&#xA;    } else {&#xA;      Serial.println(F(&quot;error opening Y.txt&quot;)) ; // if the file didn't open, print an error:&#xA;    }&#xA;      myFile = SD.open(&quot;z30.txt&quot;, FILE_WRITE);// if the file opened okay, write to it:&#xA;    if (myFile) {&#xA;      Serial.print(&quot;Writing to Z.txt...&quot;);&#xA;      myFile.println(z1);&#xA;      myFile.close();// close the file:&#xA;      Serial.println(&quot;done.&quot;);&#xA;      Serial.println(&quot;&quot;);&#xA;    } else {&#xA;      Serial.println(F(&quot;error opening Z.txt&quot;)); // if the file didn't open, print an error:&#xA;      Serial.println(&quot;&quot;);&#xA;    }   &#xA;       }&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();        // join i2c bus (address optional for master)&#xA;  Serial.begin(9600);  // start serial for output&#xA;  writeTo(DEVICE, 0x2D, 0);   //Turning on the ADXL345&#xA;  writeTo(DEVICE, 0x2D, 16);  //Turning on the ADXL345&#xA;  writeTo(DEVICE, 0x2D, 8);   //Turning on the ADXL345&#xA;  writeTo(DEVICE, 0x31, 8);&#xA;  Serial.println(&quot;Initializing Accelerometer...&quot;);&#xA;  Serial.print(&quot;Initializing SD card...&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    Serial.println(&quot;&quot;);&#xA;    return;&#xA;  }&#xA;  delay(2000);&#xA;}&#xA;&#xA; void loop() {&#xA;   if (runComplete == 0){&#xA;  for (i=0; i&amp;lt;2501; i=i+1){&#xA; Serial.print(&quot;Number of iteration(seconds) = &quot;); Serial.print(i);&#xA; Serial.println(&quot;&quot;);&#xA; regAddress();&#xA;     delay(200);&#xA;   }&#xA;  runComplete = 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19693" LastEditorUserId="2944" LastEditDate="2016-03-30T13:25:47.070" LastActivityDate="2018-06-05T15:14:38.127" Title="How do I set my sampling rate?" Tags="|arduino-uno|accelerometer|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22437" PostTypeId="1" CreationDate="2016-03-29T05:43:55.657" Score="2" ViewCount="27920" Body="&lt;p&gt;I have the following errors trying to use a TFT library function inside my library. My library uses the pointer to an instance of the TFT library in the constructor, as well described there:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/q/18974/19684&quot;&gt;Basic C++ programming, how to pass constructor argument into class?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The errors are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: invalid use of incomplete type 'class TFT'&#xA;_TFTscreen-&amp;gt;background(0, 0, 0);&#xA;&#xA;error: forward declaration of 'class TFT'&#xA;class TFT;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;MESmenu.h:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _MESMENU_H_&#xA;#define _MESMENU_H_&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;class TFT;&#xA;&#xA;class MESmenu{&#xA;public:&#xA;  MESmenu(TFT* pTFT) : _TFTscreen(pTFT) {};&#xA;  void start();&#xA;  void execute();&#xA;private:&#xA;  TFT* _TFTscreen;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;MESmenu.cpp:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;MESmenu.h&quot;&#xA;&#xA;void MESmenu::start(){&#xA;  _TFTscreen-&amp;gt;background(0, 0, 0);&#xA;  _TFTscreen-&amp;gt;text(&quot;starting menu...&quot;, 0, 0);&#xA;  //...&#xA;}&#xA;&#xA;void MESmenu::execute(){&#xA;   //some code...  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;Arduino sketch&lt;/em&gt; is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;TFT.h&amp;gt;  // Arduino LCD library&#xA;#include &amp;lt;MESmenu.h&amp;gt;  // my library&#xA;&#xA;// --------- TFT LCD ---------&#xA;// pin definition for the due&#xA;#define sd_cs  7&#xA;#define lcd_cs 10&#xA;#define dc     9&#xA;#define rst    8&#xA;TFT TFTscreen = TFT(lcd_cs, dc, rst);&#xA;&#xA;// MES menu class&#xA;MESmenu *mainMenu = new MESmenu(&amp;amp;TFTscreen);&#xA;&#xA;void setup() {&#xA;  // initialize TFT&#xA;  TFTscreen.begin();&#xA;  TFTscreen.background(0, 0, 0);&#xA;  // set the stroke color to white&#xA;  TFTscreen.stroke(255,255,255);&#xA;  TFTscreen.fill(255,255,255);&#xA;  TFTscreen.setTextSize(2);&#xA;  TFTscreen.text(&quot;TEST&quot;, 0, 0);&#xA;&#xA;  // Start menu&#xA;  mainMenu-&amp;gt;start();&#xA;}&#xA;&#xA;void loop () {&#xA;  mainMenu-&amp;gt;execute();      &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is related to the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_TFTscreen-&amp;gt;background(0, 0, 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;inside the MESmenu::start() in the .cpp file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As suggested by &lt;strong&gt;frarugi87&lt;/strong&gt; I've updated the question with the details of .h and .cpp files.&#xA;Those file are in the Arduino\libraries\MESmenu folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try to change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TFT;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TFT.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and removed the #include  from the main arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This leads to the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libraries\MESmenu\MESmenu.cpp.o: In function `Adafruit_GFX::image(PImage&amp;amp;, unsigned int, unsigned int)':&#xA;D:\Software\arduino-1.6.7\libraries\TFT\src/utility/Adafruit_GFX.h:231: multiple definition of `Adafruit_GFX::image(PImage&amp;amp;, unsigned int, unsigned int)'&#xA;sketch\test_MESmenu_lib.ino.cpp.o:D:\Software\arduino-1.6.7\libraries\TFT\src/utility/Adafruit_GFX.h:231: first defined here&#xA;&#xA;libraries\MESmenu\MESmenu.cpp.o: In function `Adafruit_GFX::image(PImage&amp;amp;, unsigned int, unsigned int)':&#xA;D:\Software\arduino-1.6.7\libraries\TFT\src/utility/Adafruit_GFX.h:231: multiple definition of `PImage::read16(SDLib::File)'&#xA;sketch\test_MESmenu_lib.ino.cpp.o:D:\Software\arduino-1.6.7\libraries\TFT\src/utility/PImage.h:17: first defined here&#xA;&#xA;libraries\MESmenu\MESmenu.cpp.o: In function `Adafruit_GFX::image(PImage&amp;amp;, unsigned int, unsigned int)':&#xA;D:\Software\arduino-1.6.7\libraries\TFT\src/utility/Adafruit_GFX.h:231: multiple definition of `PImage::read32(SDLib::File)'&#xA;sketch\test_MESmenu_lib.ino.cpp.o:D:\Software\arduino-1.6.7\libraries\TFT\src/utility/PImage.h:17: first defined here&#xA;&#xA;libraries\MESmenu\MESmenu.cpp.o: In function `Adafruit_GFX::image(PImage&amp;amp;, unsigned int, unsigned int)':&#xA;D:\Software\arduino-1.6.7\libraries\TFT\src/utility/Adafruit_GFX.h:231: multiple definition of `PImage::loadImage(char const*)'&#xA;sketch\test_MESmenu_lib.ino.cpp.o:D:\Software\arduino-1.6.7\libraries\TFT\src/utility/PImage.h:17: first defined here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19684" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-06-29T11:13:04.897" Title="Error: &quot;invalid use of incomplete type&quot; and &quot;forward declaration&quot;" Tags="|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22438" PostTypeId="2" ParentId="22437" CreationDate="2016-03-29T08:44:43.370" Score="1" Body="&lt;p&gt;Try to change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class TFT;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TFT.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can remove the &lt;code&gt;#include &amp;lt;TFT.h&amp;gt;&lt;/code&gt; from the main arduino sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover you should at least write a piece of code to make the compiler include your library just once; this is the usual way to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _MESMENU_H_&#xA;#define _MESMENU_H_&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;...&#xA;the rest of your library&#xA;...&#xA;&#xA;  TFT* _TFTscreen;&#xA;}&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;_MESMENU_H_&lt;/code&gt; is any unique string (usually the filename is used, remembering that you can't put spaces or other punctuation marks except the underscore). And you should put it only in the header file (*.h or &lt;em&gt;.hpp), not in the source (&lt;/em&gt;.c or *.cpp or *.ino)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The additional info lead me to analyze the library and.. there are problems with the library. Particularly the file &lt;code&gt;TFT/src/utility/Adafruit_GFX.h&lt;/code&gt; has a big problem: it has the code for the functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix it, you have to modify the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go into the folder &lt;code&gt;TFT/src/utility/&lt;/code&gt; and make a copy of &lt;code&gt;Adafruit_GFX.h&lt;/code&gt;, calling it &lt;code&gt;PImage.cpp&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open &lt;code&gt;Adafruit_GFX.h&lt;/code&gt; and delete everything between line 227 and line 370. This means that from&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool useFill;&#xA;};&#xA;&#xA;#if defined(__SD_H__)  // Arduino SD library&#xA;&#xA;#define BUFFPIXEL 20&#xA;&#xA;void Adafruit_GFX::image(PImage &amp;amp; img, uint16_t x, uint16_t y) {&#xA;&#xA;...&#xA;&#xA;  return PImage(bmpFile, bmpWidth, bmpHeight, bmpDepth, bmpImageoffset, rowSize, flip);&#xA;}&#xA;&#xA;#endif&#xA;&#xA;#endif // _ADAFRUIT_GFX_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it should become&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool useFill;&#xA;};&#xA;&#xA;#endif // _ADAFRUIT_GFX_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Having done this, open &lt;code&gt;PImage.cpp&lt;/code&gt; and delete everything above line 227, then delete the function &lt;code&gt;Adafruit_GFX::image&lt;/code&gt; and the last &lt;code&gt;endif&lt;/code&gt; and add, at the beginning, &lt;code&gt;#include Adafruit_GFX.h&lt;/code&gt;. This means that the file should look like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_GFX.h&quot;&#xA;&#xA;#if defined(__SD_H__)  // Arduino SD library&#xA;&#xA;#define BUFFPIXEL 20&#xA;&#xA;// These read 16- and 32-bit types from the SD card file.&#xA;// BMP data is stored little-endian, Arduino is little-endian too.&#xA;// May need to reverse subscript order if porting elsewhere.&#xA;&#xA;uint16_t PImage::read16(File f) {&#xA;&#xA;...  &#xA;&#xA;  return PImage(bmpFile, bmpWidth, bmpHeight, bmpDepth, bmpImageoffset, rowSize, flip);&#xA;}&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then try to compile again the program&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW: the source I looked at is at &lt;a href=&quot;http://bitsbytesnibble.com/indefero/p/builduinok5/source/tree/master/libraries/TFT/src/utility/Adafruit_GFX.h&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2016-03-31T10:19:17.090" LastActivityDate="2016-03-31T10:19:17.090" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22439" PostTypeId="2" ParentId="3625" CreationDate="2016-03-29T09:13:57.020" Score="8" Body="&lt;p&gt;Recently I also faced similar problem, with connection as:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1=GND, 2=+5v, 4=11, 6=12, 11=5, 12=4, 12=3, 14=2, 15=backlight positive, 16=backlight negative&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: I just &lt;strong&gt;connected VEE (pin 3) of LCD to Ground (GND)&lt;/strong&gt; without use of potentiometer as it worked.&lt;/p&gt;&#xA;" OwnerUserId="19695" LastActivityDate="2016-03-29T09:13:57.020" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22440" PostTypeId="1" CreationDate="2016-03-29T09:24:54.167" Score="6" ViewCount="286" Body="&lt;p&gt;I modified the serial code in this way and I don't think the gap is produced by my edit even because it made it even before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//////////&#xA;/////////  All Serial Handling Code, &#xA;/////////  It's Changeable with the 'serialVisual' variable&#xA;/////////  Set it to 'true' or 'false' when it's declared at start of code.  &#xA;/////////&#xA;&#xA;void serialOutput(){   // Decide How To Output Serial. &#xA; if (serialVisual == true){  &#xA;     arduinoSerialMonitorVisual('-', Signal);   // goes to function that makes Serial Monitor Visualizer&#xA; } else{&#xA;      sendDataToSerial('S', Signal);     // goes to sendDataToSerial function&#xA; }        &#xA;}&#xA;&#xA;&#xA;//  Decides How To OutPut BPM and IBI Data&#xA;void serialOutputWhenBeatHappens(){    &#xA; if (serialVisual == true){            //  Code to Make the Serial Monitor Visualizer Work&#xA;    //ASCII Art Madness&#xA;    Serial.print(BPM);&#xA;    Serial.println(&quot;&quot;);&#xA;&#xA; } else{&#xA;        sendDataToSerial('B',BPM);   // send heart rate with a 'B' prefix&#xA;        sendDataToSerial('Q',IBI);   // send time between beats with a 'Q' prefix&#xA; }   &#xA;}&#xA;&#xA;&#xA;&#xA;//  Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers. &#xA;void sendDataToSerial(char symbol, int data ){&#xA;    Serial.print(symbol);&#xA;&#xA;    Serial.println(data);                &#xA;  }&#xA;&#xA;&#xA;//  Code to Make the Serial Monitor Visualizer Work&#xA;void arduinoSerialMonitorVisual(char symbol, int data ){    &#xA;  const int sensorMin = 0;      // sensor minimum, discovered through experiment&#xA;const int sensorMax = 1024;    // sensor maximum, discovered through experiment&#xA;&#xA;  int sensorReading = data;&#xA;  // map the sensor range to a range of 12 options:&#xA;  int range = map(sensorReading, sensorMin, sensorMax, 0, 11);&#xA;&#xA;  // do something different depending on the &#xA;  // range value:&#xA;  switch (range) {&#xA;  case 0:     &#xA;    Serial.println(&quot;&quot;);&#xA;&#xA;  } &#xA;}&#xA;&#xA;&#xA;&#xA;63&#xA;&#xA;63&#xA;63&#xA;63&#xA;63&#xA;62&#xA;62&#xA;62&#xA;62&#xA;62&#xA;62&#xA;62&#xA;63&#xA;62&#xA;63&#xA;64&#xA;63&#xA;63&#xA;64&#xA;64&#xA;65&#xA;65&#xA;&#xA;&#xA;&#xA;65&#xA;68&#xA;74&#xA;78&#xA;86&#xA;95&#xA;105&#xA;112&#xA;123&#xA;141&#xA;167&#xA;154&#xA;136&#xA;128&#xA;123&#xA;125&#xA;123&#xA;127&#xA;132&#xA;104&#xA;93&#xA;92&#xA;92&#xA;89&#xA;83&#xA;77&#xA;73&#xA;69&#xA;65&#xA;70&#xA;70&#xA;71&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can find all the code here:&#xA;&lt;a href=&quot;https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino&quot;&gt;https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code I posted there is some code I don'f find useful but I can't delete it for reason linked to variables used for other functions I don't know I'm using.&#xA;You can also see huge changes in the heart rate that surely don't reflect the reality.&lt;/p&gt;&#xA;" OwnerUserId="15699" LastActivityDate="2016-11-10T03:47:54.177" Title="Why does pulse sensor shows gaps when I move it?" Tags="|arduino-uno|arduino-nano|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="22441" PostTypeId="1" CreationDate="2016-03-29T09:30:16.717" Score="2" ViewCount="10043" Body="&lt;p&gt;One sensor has a baud rate of 115200, the other 9600. I think this will create problems in the serial because I can only choose one baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you think?&#xA;The first sensor is the pulse sensor, while the other is the gsr sensor by grove.&#xA;Link: &lt;a href=&quot;http://pulsesensor.com/&quot; rel=&quot;nofollow&quot;&gt;http://pulsesensor.com/&lt;/a&gt;&#xA;Link 2: &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="15699" LastEditDate="2016-03-29T15:54:56.227" LastActivityDate="2016-03-29T16:09:33.737" Title="Can I use two sensors with different baud rate without problems on arduino?" Tags="|arduino-uno|sensors|arduino-nano|baud-rate|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22442" PostTypeId="2" ParentId="22441" CreationDate="2016-03-29T09:48:25.717" Score="1" Body="&lt;p&gt;You can only have one sensor on one serial port, and the baud rate is set on the serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as long as you have two serial ports, or SoftwareSerial ports (I wouldn't, it causes more problems that it solves - get a board with multiple UART interfaces) then yes you can have two baud rates.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-29T09:48:25.717" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22443" PostTypeId="1" AcceptedAnswerId="22561" CreationDate="2016-03-29T10:52:33.980" Score="1" ViewCount="377" Body="&lt;p&gt;I have a weird problem. I am currently building a BB-8. Therefore, I am using an Arduino Uno. On top, I have stacked an Adafruit Motor Shield v2.3 and, again, on top of this, I have stacked the Sparkfun USB Host Shield. The Arduino is powered by a 9V-Block battery, the motors are powered separately by two 18650 Li-Ion batteries. To control the two Pololu motors, which have a stall current of 1.6 amps each, I use a Xbox 360 wireless controller, where the receiver is connected to the USB Host Shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to my problem. Every seems to work fine, until i cover everything with a styrofoam hemisphere. Yes, you've read right. If that happens, the controller signals is lost and does not connect again, unless I restart the Arduino. I have uploaded a small video on &lt;a href=&quot;https://youtu.be/kabobDlFX2s&quot; rel=&quot;nofollow&quot;&gt;youtube&lt;/a&gt;, where you can see the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess, this is a power problem, since this issue does not occur, when I connect the Xbox receiver to my Mac. Has anyone an idea, how to solve this problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I already tried another power source. And the USB host shield should give enough power, since the specs are saying, that 500 mA is no problem, and hit is exactly the USB 2.0 spec. The combination of the shield shouldn't be a problem, too. I carefully chose this shields, because the motor shield is just using the pins A4 and A5, the USB host shield is using some of the digital pins, so I think there is no interference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I have tested it a bit more now and i think i can reduce the probable reasons. First, i tried some other power supplies, from AA batteries on the VIN pin to external power adaptors. Next, i tried other xbox receivers and controllers. I also tried a playstation 3 controller with a Bluetooth dongle. Nothing solved the problem. I also covered the Arduino with other things than styrofoam, like a garbage can, cardboard and some metal box. This worked, so the problem was only with styrofoam. Now i haven't covered the Arduino, but i slowly got closer. About 20 cm from the Arduino, it stopped working. My clue: static electricity. Do you think this can be a problem? And if yes, how can i solve this?&lt;/p&gt;&#xA;" OwnerDisplayName="user19698" LastEditorDisplayName="user19698" LastEditDate="2016-03-30T19:05:48.470" LastActivityDate="2016-04-01T09:44:19.930" Title="Power problems stacked Arduino shields" Tags="|arduino-uno|power|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22444" PostTypeId="2" ParentId="22443" CreationDate="2016-03-29T13:53:00.327" Score="1" Body="&lt;p&gt;Those 9v batteries are not known for their ability to supply current. Their best uses are long-term powering of low-current standby devices like smoke detectors. I'd first try replacing it with 4 double- or triple-A cells, whatever you can scrounge up for a quick test. My guess is when you cover the robot the Xbox receiver's current demand increases just enough to crash or reset something. A-cells may supply enough more current without the voltage sagging.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-03-29T14:31:14.027" LastActivityDate="2016-03-29T14:31:14.027" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22445" PostTypeId="5" CreationDate="2016-03-29T14:04:28.473" Score="0" Body="&lt;p&gt;A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a precise frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This frequency is commonly used to keep track of time, as in quartz wristwatches, to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. &lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:17.990" LastActivityDate="2016-03-29T18:31:17.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22446" PostTypeId="4" CreationDate="2016-03-29T14:04:28.473" Score="0" Body="Refers to a crystal oscillator." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:39:41.297" LastActivityDate="2016-04-12T07:39:41.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22447" PostTypeId="5" CreationDate="2016-03-29T14:05:55.160" Score="0" Body="&lt;p&gt;In computer science, a record (also called struct or compound data) is a basic data structure. A record is a collection of fields, possibly of different data types, typically in fixed number and sequence.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:13.723" LastActivityDate="2016-03-29T18:31:13.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22448" PostTypeId="4" CreationDate="2016-03-29T14:05:55.160" Score="0" Body="Refers to a basic data structure (also called record)." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:36:39.000" LastActivityDate="2016-04-12T07:36:39.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22449" PostTypeId="5" CreationDate="2016-03-29T14:06:48.567" Score="0" Body="&lt;p&gt;In electronics and electrical engineering, a fuse is a type of low resistance resistor that acts as a sacrificial device to provide overcurrent protection, of either the load or source circuit.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:00.267" LastActivityDate="2016-03-29T18:31:00.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22450" PostTypeId="4" CreationDate="2016-03-29T14:06:48.567" Score="0" Body="Refers to the component fuse that acts as a sacrificial device to provide overcorrect protection." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:36:17.577" LastActivityDate="2016-04-12T07:36:17.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22451" PostTypeId="5" CreationDate="2016-03-29T14:08:23.643" Score="0" Body="&lt;p&gt;An algorithm is a set of ordered instructions based on a formal language with the following conditions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Finite&lt;/strong&gt;. The number of instructions must be finite.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Executable&lt;/strong&gt;. All instructions must be executable in some language-dependent way, in a finite amount of time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An algorithm does not have to be deterministic - there are many random-based&#xA;algorithms, e.g. QuickSort with selecting the pivot element randomly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An algorithm can be expressed in many ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;As a sequence of instructions&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;As a block-scheme&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;As a code in an existing or new programming language&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;As a piece of text in a human language&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Or in other, similar ways&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;An algorithm can solve a class of problems. For example, both &lt;em&gt;&quot;sum 1 and 3&quot;&lt;/em&gt; and &lt;em&gt;&quot;sum 4 and 5&quot;&lt;/em&gt; are problems in the same class: &lt;em&gt;&quot;sum two integer numbers.&quot;&lt;/em&gt; Furthermore, a given class of problems can generally be solved by a variety of algorithms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One important aspect of algorithm design is performance. For large datasets a good algorithm may outperform a poor algorithm by several orders of magnitude. Algorithm performance is often rated with &lt;a href=&quot;http://en.wikipedia.org/wiki/Big_O_notation&quot; rel=&quot;nofollow&quot;&gt;Big O or Θ notation&lt;/a&gt;, but one should be cautious with asymptotic notation, since big constants may be involved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A key algorithm classification is known as &lt;a href=&quot;http://en.wikipedia.org/wiki/Computational_complexity_theory&quot; rel=&quot;nofollow&quot;&gt;Algorithm Complexity&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another important step of algorithm design is &lt;em&gt;proof of correctness&lt;/em&gt;. Algorithm should actually provide correct result for any instance of the problem. We should always take care all the conditions where proposed algorithm might &lt;em&gt;fail&lt;/em&gt;. This could be done using several techniques, For example Model Checking, Assertion, Loop Invariant.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Reference Links&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Additional resources on algorithms include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Algorithm&quot; rel=&quot;nofollow&quot;&gt;Algorithm on Wikipedia&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://computer.howstuffworks.com/question717.htm&quot; rel=&quot;nofollow&quot;&gt;Algorithm on Howstuffworks&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://xlinux.nist.gov/dads/&quot; rel=&quot;nofollow&quot;&gt;Dictionary of Algorithms and Data Structures&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/pedrovgs/Algorithms&quot; rel=&quot;nofollow&quot;&gt;Algorithms implementations 1 - Github&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/prakhar1989/Algorithms&quot; rel=&quot;nofollow&quot;&gt;Algorithms implementations 2 - Github&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:37.820" LastActivityDate="2016-03-29T18:31:37.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22452" PostTypeId="4" CreationDate="2016-03-29T14:08:23.643" Score="0" Body="An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:30:57.423" LastActivityDate="2016-03-29T18:30:57.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22453" PostTypeId="5" CreationDate="2016-03-29T14:09:46.567" Score="0" Body="&lt;p&gt;In digital communications, symbol rate, also known as baud rate and modulation rate, is the number of symbol changes, waveform changes, or signaling events, across the transmission medium per time unit using a digitally modulated signal or a line code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The symbol rate is measured in baud (Bd) or symbols per second. In the case of a line code, the symbol rate is the pulse rate in pulses per second. Each symbol can represent or convey one or several bits of data. The symbol rate is related to the gross bitrate expressed in bits per second.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:30:47.390" LastActivityDate="2016-03-29T18:30:47.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22454" PostTypeId="4" CreationDate="2016-03-29T14:09:46.567" Score="0" Body="Refers to the symbol rate and so the number of symbol that changes per time unit." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:36:04.167" LastActivityDate="2016-04-12T07:36:04.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22455" PostTypeId="2" ParentId="22416" CreationDate="2016-03-29T14:27:59.070" Score="1" Body="&lt;p&gt;You could start with the &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;attachInterrupt&lt;/a&gt; example sketch and work from there. Here is a possible solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum { GREEN = 0, BLUE = 1, WHITE = 2, RED = 3};&#xA;const int buttonPin = 2;&#xA;const int ledPin[] = { 4, 5, 6, 7 };&#xA;volatile bool reset = false;&#xA;int state = GREEN;&#xA;&#xA;void setup() {&#xA;  pinMode(buttonPin, INPUT_PULLUP);&#xA;  for (int i = 0; i &amp;lt; 4; i++) pinMode(ledPin[i], OUTPUT);&#xA;  attachInterrupt(digitalPinToInterrupt(buttonPin), doResetState, FALLING);&#xA;}&#xA;&#xA;void loop() {&#xA;   digitalWrite(ledPin[state], HIGH);&#xA;   delay(7000);&#xA;   digitalWrite(ledPin[state], LOW);&#xA;   if (state == RED || reset) {&#xA;     state = GREEN;&#xA;     reset = false;&#xA;   }&#xA;   else {&#xA;     state = state + 1;&#xA;   }&#xA;}&#xA;&#xA;void doResetState () {&#xA;    reset = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will not immediately cycle back to GREEN when pressing the button but you can fix that by modifying the doResetState().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-03-29T14:27:59.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22456" PostTypeId="2" ParentId="22416" CreationDate="2016-03-29T14:39:55.483" Score="0" Body="&lt;p&gt;The SimpleTimer library would be ideal for this. One timer callback function, the present contents of the loop() function, would advance the lighting state, called by a 7 second timer. Another, your present doResetState() with the modification noted by @MikaelPatel, would read (and debounce) the button on, say, a 100ms timer. The main loop would be reduced to &lt;code&gt;Timer.run();&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-03-29T14:39:55.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22457" PostTypeId="2" ParentId="22411" CreationDate="2016-03-29T15:12:12.997" Score="1" Body="&lt;p&gt;Many of the online instructions do not work. This one does - &lt;a href=&quot;http://arduinotronics.blogspot.com/2015/06/upgrading-arduino-wifi-shield-firmware.html&quot; rel=&quot;nofollow&quot;&gt;http://arduinotronics.blogspot.com/2015/06/upgrading-arduino-wifi-shield-firmware.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10200" LastActivityDate="2016-03-29T15:12:12.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22459" PostTypeId="5" CreationDate="2016-03-29T15:37:35.113" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Mathematics&quot; rel=&quot;nofollow&quot;&gt;Mathematics&lt;/a&gt; is the study of quantity, structure, space, and change. Mathematicians seek out patterns, formulate new conjectures, and establish truth by rigorous deduction from appropriately chosen axioms and definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Through the use of abstraction and logical reasoning, mathematics evolved from counting, calculation, measurement, and the systematic study of the shapes and motions of physical objects. Practical mathematics has been a human activity for as far back as written records exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mathematics is behind all programming at some level, but math questions here should be specifically related to a programmed implementation.  General math questions can be asked at &lt;a href=&quot;http://math.stackexchange.com/&quot;&gt;Mathematics&lt;/a&gt;. Research level mathematics questions can be asked at &lt;a href=&quot;http://mathoverflow.net/&quot;&gt;MathOverflow&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:39:37.640" LastActivityDate="2016-04-12T07:39:37.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22460" PostTypeId="4" CreationDate="2016-03-29T15:37:35.113" Score="0" Body="Mathematics is the study of quantity, structure, space, and change. Any math questions on this site should be programming related." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-03-29T18:31:08.223" LastActivityDate="2016-03-29T18:31:08.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22461" PostTypeId="5" CreationDate="2016-03-29T15:38:07.630" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-29T15:38:07.630" LastActivityDate="2016-03-29T15:38:07.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22462" PostTypeId="4" CreationDate="2016-03-29T15:38:07.630" Score="0" Body="Documentation is information on aspects of software or hardware, including its intended purpose, functionality, and maintenance. Documentation can exist in many different forms and formats, but its aim is always to educate." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-12T07:39:54.203" LastActivityDate="2016-04-12T07:39:54.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22463" PostTypeId="2" ParentId="22441" CreationDate="2016-03-29T16:09:33.737" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;One sensor has a baud rate of 115200, the other 9600. I think this&#xA;  will create problems in the serial because I can only choose one baud&#xA;  rate.&lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;Why do you think the sensor has a baudrate?&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Both the sensors seem to use the &quot;serial connection&quot; of the Arduino to log their information.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What do you think? The first sensor is the pulse sensor, while the&#xA;  other is the gsr sensor by grove. Link: &lt;a href=&quot;http://pulsesensor.com/&quot; rel=&quot;nofollow&quot;&gt;http://pulsesensor.com/&lt;/a&gt; Link&#xA;  2: &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;I think it'll work fine.&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looking at the facts of your sensors, the pulse sensor does have some kind of weird low-level timing/ADC access. But your Grove GSR sensor can basically be read out through an analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So what to choose?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could choose 9,6k or 115k2 (9600 or 115200). It wouldn't make all that much difference. 9600 or 115200 will work fine. 115200 is a lot faster, but for debugging purpose 9600 is used, since it's often default and (often) more reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wrapping up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think there is an issue with the two serials. You can easily log both messages to the same serial output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using 115200 since timing is essential in your case, you want your sensor to be response/fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They do both use the same analog to digital converter on your board. An Arduino can't check both sensors at the same time. But by switching between them very fast, you will get a resolution that's good enough.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-03-29T16:09:33.737" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22464" PostTypeId="1" AcceptedAnswerId="22476" CreationDate="2016-03-29T16:54:10.067" Score="0" ViewCount="360" Body="&lt;p&gt;I'm looking for some reference material to start on a project I'd like to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Open House at my school. My group project has been to create a little timesheet app using JavaEE. I just started looking for how to do this and if I can. But I would like to wow people a bit by setting this up using an Arduino Yun board. I know it has WiFi and I'm pretty sure I can run Linux on the little guy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated. &lt;/p&gt;&#xA;" OwnerUserId="19708" LastEditorUserId="26916" LastEditDate="2017-09-09T02:15:33.423" LastActivityDate="2017-09-09T02:15:33.423" Title="Setting Up a JavaEE app on an Arduino Yun Board" Tags="|arduino-yun|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22466" PostTypeId="1" AcceptedAnswerId="22467" CreationDate="2016-03-29T18:21:38.210" Score="1" ViewCount="826" Body="&lt;p&gt;Probably I'm asking a nonsense question but I'm new at interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to connect an USB barcode scanner to an Arduino (Uno or Mega). I've read that I need a USB host shield to achieve this. But I don't have any. I have a FTDI, so I suppose I could plug the USB output of the scanner into the FTDI and connect the FTDI to the UART port of Arduino. Then, I would be passing the USB output to Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it correct? Thanks and sorry if I said something stupid!&lt;/p&gt;&#xA;" OwnerUserId="11007" LastActivityDate="2016-03-29T18:24:08.507" Title="Connect a USB slave into Arduino using FTDI" Tags="|arduino-uno|usb|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22467" PostTypeId="2" ParentId="22466" CreationDate="2016-03-29T18:24:08.507" Score="2" Body="&lt;p&gt;No, that is completely wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In USB you have &lt;em&gt;hosts&lt;/em&gt; and &lt;em&gt;devices&lt;/em&gt;. A &lt;em&gt;device&lt;/em&gt; has to connect to a &lt;em&gt;host&lt;/em&gt;. Your FT232 is a &lt;em&gt;device&lt;/em&gt;. The barcode scanner is a &lt;em&gt;device&lt;/em&gt;. Both of them need to be connected to a &lt;em&gt;host&lt;/em&gt; for them to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need a USB &lt;em&gt;host&lt;/em&gt; shield to act as that host.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However - check the manual for your barcode scanner: it may well have a RS-232 mode that it can be switched into (may need a different cable attached).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-29T18:24:08.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22468" PostTypeId="1" CreationDate="2016-03-29T18:30:52.143" Score="0" ViewCount="94" Body="&lt;p&gt;I'm looking into working with an Arduino micro, and I'd like to be able to plug it into my computer directly(without a cable). I've been looking around, and the best thing that I found was &lt;a href=&quot;http://www.gearbest.com/usb-flash-drives/pp_241630.html?currency=USD&amp;amp;gclid=Cj0KEQjwz-i3BRDtn53Z5Z7t4PUBEiQA23q2ADLBLxSTh67ggFcvjZenuXTcFK6nriQfRnaFchLybM8aAuhx8P8HAQ&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. The reason I haven't bought the linked adapter is because I've seen a number of bad reviews of the seller with close to half of the reviews being 1-star. Anybody have an idea where I can find something similar?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I'm going to be using this for security testing, emulating a rubber ducky usb, so I need the computer to recognize the Arduino as an HID, not an arduino, but I also (obviously) need to be able to load my code onto it&lt;/p&gt;&#xA;" OwnerUserId="19713" LastEditorUserId="19713" LastEditDate="2016-03-29T20:38:00.953" LastActivityDate="2016-03-29T20:38:00.953" Title="Micro USB to USB adapter m/m" Tags="|usb|arduino-micro|" AnswerCount="1" CommentCount="4" ClosedDate="2016-04-01T17:59:05.863" ContentLicense="CC BY-SA 3.0" />
  <row Id="22469" PostTypeId="2" ParentId="646" CreationDate="2016-03-29T18:52:36.523" Score="2" Body="&lt;p&gt;A pretty detailed troubleshooting guide is available at &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting2#toc8&quot; rel=&quot;nofollow&quot;&gt;arduino.cc&lt;/a&gt;. Besides the checks already mentioned in the question and the answers, it is recommended to check that &lt;code&gt;serial.download_rate&lt;/code&gt; is set to &lt;code&gt;19200&lt;/code&gt; in &lt;code&gt;~/.arduino/preferences.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;19200&lt;/code&gt; is the default baud rate used by most &lt;a href=&quot;https://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader&quot; rel=&quot;nofollow&quot;&gt;bootloaders&lt;/a&gt;, so this doesn't apply if you don't use one, or use a modified version.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-03-29T18:52:36.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22470" PostTypeId="2" ParentId="22468" CreationDate="2016-03-29T18:52:49.823" Score="2" Body="&lt;p&gt;That adapter is not suitable. Not only is it the wrong gender on the large end, but it is designed for a completely different purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is an &quot;On The Go&quot; adapter which is designed for connecting things with a USB A plug (such as a memory stick, etc) to a mobile phone's USB socket.  It is not suitable for connecting things to an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have never heard of an adapter like you want, but I have heard of Arduino-like boards that plug direct into a computer like you want. One example is the &lt;a href=&quot;http://digistump.com/products/1&quot; rel=&quot;nofollow&quot;&gt;Digispark from Digistump&lt;/a&gt; which is an ATTiny85 on a USB plug.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-29T18:52:49.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22471" PostTypeId="2" ParentId="13998" CreationDate="2016-03-29T19:45:39.480" Score="4" Body="&lt;p&gt;There is a new signed driver for OS-X El Capitan and Yosemite. This is all you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://kig.re/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&quot; rel=&quot;nofollow&quot;&gt;http://kig.re/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19717" LastActivityDate="2016-03-29T19:45:39.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22473" PostTypeId="2" ParentId="22426" CreationDate="2016-03-29T21:42:33.600" Score="2" Body="&lt;p&gt;Okay, thank you all for your efforts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, after changing the PSU and connecting the Arduino to another usb-port without operating system, I found the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was the SD-Card itself:&#xA;I swapped the SD-card with a newer (maybe more expensive(?)) one and it just works now. No matter if you connect the Arduino with the PSU or over an usb connection.&#xA;My assumption is, that there could be a different clock speed of the sd-card module on different voltages, which causes the problem. The old sd-card can't handle the fast speed and runs into an error (or just rejects it) on a write attempt...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, thank you again for your efforts!&lt;/p&gt;&#xA;" OwnerUserId="19681" LastActivityDate="2016-03-29T21:42:33.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22474" PostTypeId="1" AcceptedAnswerId="22475" CreationDate="2016-03-29T23:03:15.197" Score="1" ViewCount="3907" Body="&lt;p&gt;I want to read strings from &lt;code&gt;Serial.read()&lt;/code&gt; to send them later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the data from the Serial monitor I'm doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;String stringOne  = &quot;&quot;;&#xA;int  incomingByte; &#xA;&#xA;if (Serial.available() &amp;gt; 0) {   &#xA;&#xA;  while(Serial.available() &amp;gt; 0)&#xA;  {&#xA;     incomingByte= Serial.read();&#xA;     stringOne = String(stringOne + String(incomingByte));&#xA;  }&#xA;&#xA;  Serial.println(stringOne);&#xA;  stringOne = &quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is that when I type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'a'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'97'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for &#xA;    'abc' &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'979899'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so on and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do in order to get the same string I type?&lt;/p&gt;&#xA;" OwnerUserId="18574" LastEditorUserId="6936" LastEditDate="2016-03-31T13:20:12.550" LastActivityDate="2016-03-31T13:20:12.550" Title="Get strings from Serial.read()" Tags="|serial|string|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22475" PostTypeId="2" ParentId="22474" CreationDate="2016-03-29T23:40:46.803" Score="6" Body="&lt;p&gt;You're adding the ASCII value of each char to your string, hence you get numbers. See the various String constructors at:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/StringConstructors&quot;&gt;https://www.arduino.cc/en/Tutorial/StringConstructors&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either cast the read byte to a char:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stringOne = String(stringOne + String((char)incomingByte));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or consider receiving characters as chars, instead of ints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char incomingByte; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a perfectly valid one-method call which does all of this hassle easier and more efficiently: &lt;a href=&quot;https://www.arduino.cc/en/Serial/ReadStringUntil&quot;&gt;https://www.arduino.cc/en/Serial/ReadStringUntil&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you'll sooner or later anyhow have to add a framing prototcol. For example, you're sending down text commands to Arduino, and each command is separated by a new line character. ReadStringUntil will handle that very nicely.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-29T23:40:46.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22476" PostTypeId="2" ParentId="22464" CreationDate="2016-03-30T00:22:02.150" Score="0" Body="&lt;p&gt;Sorry, forget it. 64Mb ram, 16Mb flash what the Yun has.&#xA;Java EE is magnitudes bigger (and bugger) than that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try with Java SE embedded, the smallest profile might fit to 11Mb:&#xA;&lt;a href=&quot;http://www.oracle.com/us/technologies/java/oracle-javase-embedded-ds-365290.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.oracle.com/us/technologies/java/oracle-javase-embedded-ds-365290.pdf&lt;/a&gt;&#xA;and then you can roll your own web server. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Personal comments: For little timesheets JavaEE is overkill, for anything modern JavaEE is obsolete - consider modern Java micro web frameworks, which offer magnitudes better performance than JavaEE).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can try is Raspberry PI, which works well with network, and Java (SE).&#xA;Not that well but also Java EE works: &lt;a href=&quot;https://blogs.oracle.com/theaquarium/entry/glassfish_4_on_the_raspberry&quot; rel=&quot;nofollow&quot;&gt;https://blogs.oracle.com/theaquarium/entry/glassfish_4_on_the_raspberry&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-30T00:22:02.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22477" PostTypeId="2" ParentId="22474" CreationDate="2016-03-30T05:35:50.363" Score="2" Body="&lt;p&gt;Instead of using: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available() &amp;gt; 0)&#xA;  {&#xA;     incomingByte= Serial.read();&#xA;     stringOne = String(stringOne + String(incomingByte));&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Use the following to cast them to character:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available() &amp;gt; 0)&#xA;  {&#xA;     char incomingByte= Serial.read();&#xA;     stringOne.concat(incomingByte));&#xA;  }&#xA;Serial.println(stringOne);&#xA;stringOne=&quot;&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16299" LastEditorUserId="6936" LastEditDate="2016-03-30T22:17:57.680" LastActivityDate="2016-03-30T22:17:57.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22478" PostTypeId="2" ParentId="18275" CreationDate="2016-03-30T05:43:52.013" Score="1" Body="&lt;p&gt;I belive what you want to do is program a Arduino by ISP and retain the bootloader, I have done this on occasion by first loading the bootloader onto a chip, then upload the Arduino &lt;em&gt;sketch&lt;/em&gt;, then i use the ISP programmer to read the whole flash back into hex file. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This hex file is then used to program the rest of the chips for production. (If you feel this takes too much time, it is possible to strip the hex file down, but that might be a bit complicated)&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-30T05:43:52.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22479" PostTypeId="2" ParentId="19329" CreationDate="2016-03-30T06:06:21.643" Score="1" Body="&lt;p&gt;There's actually a library for that as well! See &lt;a href=&quot;https://github.com/osbock/Baldwisdom/tree/master/BootDrive&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://baldwisdom.com/bootdrive/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-30T06:06:21.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22480" PostTypeId="2" ParentId="18755" CreationDate="2016-03-30T07:27:48.770" Score="3" Body="&lt;p&gt;The 433mhz modules can be sensible on the power lines, place a cap on the power input. Also a straight antenna works most of the times, but if you want some more distance, look into making a dipole antenna, there is a coil loaded diy antenna you can make that helps a little bit up from straight wire.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastActivityDate="2016-03-30T07:27:48.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22487" PostTypeId="1" CreationDate="2016-03-30T13:14:33.280" Score="4" ViewCount="17622" Body="&lt;p&gt;Connected servo motor (180°) to Arduino Uno R3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I am using a servo motor which have rotation angle specified as 180°, but I have a requirement to rotate to certain angles greater that 180°.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So do I need to go for a &lt;em&gt;continuous rotation servo motor (360°)&lt;/em&gt;, so that I can stop the motor at different angles greater than 180°, was my assumption true, will continuous rotation servo motor satisfy this requirement?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am referring to &lt;a href=&quot;https://www.sparkfun.com/products/9347&quot; rel=&quot;nofollow&quot;&gt;Servo - Generic High Torque Continuous Rotation (Standard Size)&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current code, which I am using 180° servo motor.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Servo myservo;&#xA;int pos = 0;   &#xA;void setup() {&#xA;  myservo.attach(9);  &#xA;}&#xA;&#xA;void loop() {&#xA;   { &#xA;    myservo.write(180);              &#xA;    delay(15);                       &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10894" LastEditorUserId="4131" LastEditDate="2016-03-31T15:21:52.667" LastActivityDate="2019-09-15T17:40:49.543" Title="How to make servo rotate for angle bigger than 180°" Tags="|arduino-uno|motor|servo|arduino-motor-shield|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22489" PostTypeId="1" AcceptedAnswerId="22491" CreationDate="2016-03-30T16:44:06.890" Score="0" ViewCount="423" Body="&lt;p&gt;EDIT: upon further investigation: I found out that if I wired it Thermistor &gt; resistor &gt; GND values go one direction. If I wired it Thermistor &gt; Resistor &gt; 5v, it goes the other direction. So my new question: Which way is correct? One sketch assumes it works one way, and one the other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have some Thermistors from &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0087YI1KW&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. I have an Arduino Nano and an Arduino Uno, both set up identically with pictures of the wiring below. On the sketch below, when I heat up the thermistor the value increases on the Uno and decreases on the Nano. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// which analog pin to connect&#xA;#define THERMISTORPIN A0&#xA;// resistance at 25 degrees C&#xA;#define THERMISTORNOMINAL 10000&#xA;// temp. for nominal resistance (almost always 25 C)&#xA;#define TEMPERATURENOMINAL 25&#xA;// how many samples to take and average, more takes longer&#xA;// but is more 'smooth'&#xA;#define NUMSAMPLES 5&#xA;// The beta coefficient of the thermistor (usually 3000-4000)&#xA;#define BCOEFFICIENT 3950&#xA;// the value of the 'other' resistor&#xA;#define SERIESRESISTOR 9800&#xA;&#xA;int samples[NUMSAMPLES];&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  uint8_t i;&#xA;  float average;&#xA;&#xA;  // take N samples in a row, with a slight delay&#xA;  for (i=0; i&amp;lt; NUMSAMPLES; i++) {&#xA;       samples[i] = analogRead(THERMISTORPIN);&#xA;   delay(10);&#xA;  }&#xA;&#xA;  // average all the samples out&#xA;  average = 0;&#xA;  for (i=0; i&amp;lt; NUMSAMPLES; i++) {&#xA;     average += samples[i];&#xA;  }&#xA;  average /= NUMSAMPLES;&#xA;&#xA;  Serial.print(&quot;Average analog reading &quot;);&#xA;  Serial.println(average);&#xA;&#xA;  // convert the value to resistance&#xA;  average = 1023 / average - 1;&#xA;  average = SERIESRESISTOR / average;&#xA;  Serial.print(&quot;Thermistor resistance &quot;);&#xA;  Serial.println(average);&#xA;&#xA;  float steinhart;&#xA;  steinhart = average / THERMISTORNOMINAL;     // (R/Ro)&#xA;  steinhart = log(steinhart);                  // ln(R/Ro)&#xA;  steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)&#xA;  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)&#xA;  steinhart = 1.0 / steinhart;                 // Invert&#xA;  steinhart -= 273.15;                         // convert to C&#xA;&#xA;  Serial.print(&quot;Temperature &quot;);&#xA;  Serial.print(steinhart);&#xA;  Serial.println(&quot; *C&quot;);&#xA;  Serial.println();&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the sketch below, the Uno is backwards and the Nano is correct. I'm sure there's something simple I'm missing, but I sure can't find it. Any suggestions? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;double Thermistor(int RawADC) {&#xA; double Temp;&#xA; Temp = log(10000.0*((1024.0/RawADC-1)));&#xA; Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );&#xA; Temp = Temp - 273.15;&#xA; Temp = (Temp * 9.0)/ 5.0 + 32.0;&#xA; return Temp;&#xA;}&#xA;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int val;&#xA;  double temp;&#xA;  val=analogRead(7);&#xA;  temp=Thermistor(val);&#xA;  Serial.print(&quot;Temperature = &quot;);&#xA;  Serial.print(temp);&#xA;  Serial.println(&quot; F&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QQ8Fs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nano Wiring&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kIM29.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uno Wiring&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-03-30T17:00:15.360" Title="Thermistor value correct on Uno backwards on Nano" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22490" PostTypeId="2" ParentId="3962" CreationDate="2016-03-30T16:51:24.970" Score="0" Body="&lt;p&gt;Answering the other part of the question:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you're getting CRs because your readString is just wrong. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The problem is that you don't wait for receiving a whole line of string. For example, if you press H on the serial monitor, then it is getting received and echoed back as if it would been the whole input, ending with a new line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might wish to check my answer at &lt;a href=&quot;https://arduino.stackexchange.com/questions/22474/get-strings-from-serial-read/22475#22475&quot;&gt;Get strings from Serial.read()&lt;/a&gt; that is use &lt;a href=&quot;https://www.arduino.cc/en/Serial/ReadStringUntil&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Serial/ReadStringUntil&lt;/a&gt; which reads you the whole string until a separator (for example the whole string until it ends with a CR when you press Enter on the serial monitor).&lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-30T16:51:24.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22491" PostTypeId="2" ParentId="22489" CreationDate="2016-03-30T17:00:15.360" Score="0" Body="&lt;p&gt;There is no &quot;correct&quot; way. The thermistor and the resistor combine to make a voltage divider. Whether the thermistor is connected to +5V (AKA R1) or to GND (AKA R2) determines the formula to use to calculate the resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The general form is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;          R2&#xA;Vout = ------- x Vin&#xA;       R1 + R2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To solve for R2 (thermistor connected to GND) you re-arrange to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                 1&#xA;R2 = R1 x --------------&#xA;          (Vin/Vout) - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To solve for R1 (thermistor connected to +5V) it's:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     R2 x Vin&#xA;R1 = -------- - R2&#xA;       Vout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Vin, of course, is 5V, and Vout is a voltage you calculate from the analog reading on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have the resistance you can then calculate the temperature. That part doesn't change regardless of the orientation of the thermistor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-30T17:00:15.360" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22492" PostTypeId="1" CreationDate="2016-03-30T17:35:00.503" Score="0" ViewCount="173" Body="&lt;p&gt;I'm using the grove GSR sensor: &lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&lt;/a&gt; with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int GSR=A0;&#xA;int threshold=0;&#xA;int sensorValue;&#xA;const long interval = 1000;  &#xA;void setup(){&#xA;  long sum=0;&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;&#xA;  for(int i=0;i&amp;lt;500;i++)&#xA;  {&#xA;  sensorValue=analogRead(GSR);&#xA;  sum += sensorValue;&#xA;  delay(5);&#xA;  }&#xA;  threshold = sum/500;&#xA;   Serial.print(&quot;threshold =&quot;);&#xA;   Serial.println(threshold);&#xA;  }&#xA;&#xA;void loop(){&#xA;  int temp;&#xA;  sensorValue=analogRead(GSR);&#xA;  Serial.println(sensorValue);&#xA;  temp = threshold - sensorValue;&#xA;  delay(250);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is the delay way to skip milliseconds or the &lt;code&gt;millis()&lt;/code&gt; function. Do you have ideas on how can I implement it? The delay has the problem that doesn't consider the time the sensor uses to read the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I am trying&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int GSR=A0;&#xA;int threshold=0;&#xA;int sensorValue;&#xA;const long interval = 1000; &#xA;unsigned long startTime=millis();&#xA;&#xA;&#xA;void setup(){&#xA;  long sum=0;&#xA;  Serial.begin(9600);&#xA;  delay(1000);&#xA;&#xA;  for(int i=0;i&amp;lt;500;i++)&#xA;  {&#xA;  sensorValue=analogRead(GSR);&#xA;  sum += sensorValue;&#xA;  delay(5);&#xA;  }&#xA;  threshold = sum/500;&#xA;   Serial.print(&quot;threshold =&quot;);&#xA;   Serial.println(threshold);&#xA;  }&#xA;&#xA;void loop(){&#xA;&#xA;&#xA;  if((millis() - startTime) % 250 == 0) {&#xA;   int temp;&#xA;  sensorValue=analogRead(GSR);&#xA;  Serial.println(sensorValue);&#xA;  temp = threshold - sensorValue;&#xA;&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="10794" LastEditDate="2016-03-30T20:47:41.597" LastActivityDate="2016-03-31T11:04:47.213" Title="How can I exactly put my sensor at 4 Hz readings?" Tags="|arduino-uno|c++|arduino-nano|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22493" PostTypeId="2" ParentId="22487" CreationDate="2016-03-30T17:50:23.227" Score="5" Body="&lt;p&gt;No. The continuous rotation servo rotates &lt;em&gt;continuously&lt;/em&gt; and you can not control where to stop. You can control the rotation direction and the speed at a little.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need is either a special 270 degree servo, or you can use some mechanic, e.g. gears to transform the 0..180 rotation to 0..whateverrotation you prefer, depending on the gearbox ratio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use stepper motors, where you can control steps in 1.8 degrees, and at the same time free to move as many turns as you prefer. Note though that steppers have two disadvantages compared to servos:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;steppers require electrical current to hold their current position - for servo, the gearbox works ok for this&lt;/li&gt;&#xA;&lt;li&gt;steppers don't know their initial position. So you need an optointerrupter or other means to learn the initial position first, then drive the steps to get to any position.&lt;/li&gt;&#xA;&lt;li&gt;steppers require a more serious driving circuit, as well as a good power supply. Not for DIY robot running on batteries.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In industrial solutions, the stepper motor + some gearbox + an absolute rotation encoder is used to compose an industrial servo drive. (Similarly as a DC motor + some gearbox + an inexpensive potentiometer works in a model servo.)&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-03-30T17:50:23.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22496" PostTypeId="2" ParentId="14680" CreationDate="2016-03-30T19:28:52.570" Score="1" Body="&lt;p&gt;I guess you're not using the designated PWM pins provided on the Arduino Board, anyhow I suggest you read this instructible: &lt;a href=&quot;http://www.instructables.com/id/Arduino-DC-motor-speed-and-direction-L293D/step2/L293D-Pin-Layout/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Arduino-DC-motor-speed-and-direction-L293D/step2/L293D-Pin-Layout/&lt;/a&gt; ,Perhaps this can help you in making proper connections and also help you with the code :)&lt;/p&gt;&#xA;" OwnerUserId="18545" LastActivityDate="2016-03-30T19:28:52.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22497" PostTypeId="5" CreationDate="2016-03-30T20:13:41.183" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-30T20:13:41.183" LastActivityDate="2016-03-30T20:13:41.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22498" PostTypeId="4" CreationDate="2016-03-30T20:13:41.183" Score="0" Body="A text input device. Utilize this tag to ask programming questions regarding reading input from it or blinking the lights, etc." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-01T17:51:04.893" LastActivityDate="2016-04-01T17:51:04.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22499" PostTypeId="5" CreationDate="2016-03-30T20:15:53.460" Score="0" Body="&lt;p&gt;&lt;strong&gt;sound&lt;/strong&gt; is a vibration that propagates as a typically audible mechanical wave of pressure and displacement, through a transmission medium such as air or water.&lt;/p&gt;&#xA;" OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2017-01-26T18:53:09.877" LastActivityDate="2017-01-26T18:53:09.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22500" PostTypeId="4" CreationDate="2016-03-30T20:15:53.460" Score="0" Body="sound is a vibration that propagates as a typically audible mechanical wave of pressure and displacement, through a transmission medium such as air or water." OwnerUserId="8552" LastEditorUserId="8552" LastEditDate="2017-01-26T18:52:43.863" LastActivityDate="2017-01-26T18:52:43.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22502" PostTypeId="5" CreationDate="2016-03-30T20:42:49.507" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-30T20:42:49.507" LastActivityDate="2016-03-30T20:42:49.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22503" PostTypeId="4" CreationDate="2016-03-30T20:42:49.507" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-30T20:42:49.507" LastActivityDate="2016-03-30T20:42:49.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22504" PostTypeId="5" CreationDate="2016-03-30T20:44:07.763" Score="0" Body="&lt;p&gt;In the field of computer software, the term software build refers either to the process of converting source code files into standalone software artifact(s) that can be run on a computer, or the result of doing so.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-01T17:51:33.430" LastActivityDate="2016-04-01T17:51:33.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22505" PostTypeId="4" CreationDate="2016-03-30T20:44:07.763" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-03-30T20:44:07.763" LastActivityDate="2016-03-30T20:44:07.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22506" PostTypeId="1" AcceptedAnswerId="22524" CreationDate="2016-03-30T20:45:57.757" Score="0" ViewCount="599" Body="&lt;p&gt;So I'm doing a project that involves getting sensor data from several sensors, and then sending them to an external server when a tragic occurs. But I've been having trouble figuring out how to send this data, and I am welcome to advice (I'm still relatively new to Arduino coding).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino mega, with a sim900 GSM shield and an SD card. The sensors are just analog reads and a GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've looked into FTP, a Xively account and http requests to a web server but couldn't figure it out.&lt;/p&gt;&#xA;" OwnerUserId="19740" LastEditorUserId="19515" LastEditDate="2016-03-30T21:13:33.383" LastActivityDate="2016-03-31T11:20:33.120" Title="How to perform a data transfer to an external server" Tags="|arduino-mega|sensors|gsm|sd-card|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22507" PostTypeId="2" ParentId="22492" CreationDate="2016-03-30T20:49:04.480" Score="0" Body="&lt;p&gt;Something like this should do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte LED = 13;&#xA;unsigned long lastReading;&#xA;const unsigned long INTERVAL = 250;&#xA;&#xA;void setup() &#xA;  {&#xA;  pinMode (LED, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop() &#xA;  {&#xA;  unsigned long now = millis ();&#xA;  if (now - lastReading &amp;gt;= INTERVAL)&#xA;    {&#xA;    lastReading = now;&#xA;    digitalWrite (LED, HIGH);&#xA;    delay (50);  // simulate reading delay&#xA;    digitalWrite (LED, LOW);&#xA;    }&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code saves when we are &lt;em&gt;about to&lt;/em&gt; do a reading, and uses that as the basis for when to do the next one. This eliminates the reading time from the equation. In my example code I throw in a 50 ms delay to prove the point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LED flashes exactly at 250 ms intervals.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-30T20:49:04.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22508" PostTypeId="2" ParentId="22492" CreationDate="2016-03-30T21:17:09.503" Score="2" Body="&lt;p&gt;The difference between your first code and the second one is that the first one is blocking execution when it reaches the &lt;code&gt;delay&lt;/code&gt; function, but the second code keeps running without being blocked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now your algorithm has a drawback, the loop may or may not reach the &lt;code&gt;if&lt;/code&gt; condition exactly when the modulo is strictly equal to 0. So you may prefer to use something like :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long T = millis();&#xA;&#xA;...&#xA;&#xA;if( millis() - T &amp;gt;= 250 ) {&#xA;    ... // sensor stuff&#xA;    T = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This idea is also presented in this article &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to use Timers and Interrupts, but this is far more complicated (&lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Timer1&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="13995" LastActivityDate="2016-03-30T21:17:09.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22509" PostTypeId="1" AcceptedAnswerId="22510" CreationDate="2016-03-30T21:28:27.733" Score="0" ViewCount="266" Body="&lt;p&gt;I'm making a device for the visually disabled that makes a sound when the water in a bowl reach certain levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already made the sensors for three levels of water and if statements to make the sound, but I need the sound to be played just once for every level change and it loops over and over. &#xA;How can I make it to sound just one time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PCM.h&amp;gt;&#xA;const unsigned char sample[] PROGMEM = { //Here goes the sample&#xA;};&#xA;int low = 0;&#xA;int mid = 0;&#xA;int high = 0;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  low = analogRead(A0);&#xA;  mid = analogRead(A1);&#xA;  high = analogRead(A2);&#xA;  Serial.print(&quot;nivel agua: &quot;);&#xA;&#xA;  if (high &amp;gt; 50){&#xA;    Serial.print(&quot;Alto&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;  }&#xA;  else if (mid &amp;gt;50){&#xA;    Serial.print(&quot;Medio&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;  }&#xA;  else if (low &amp;gt; 50){&#xA;    Serial.print(&quot;Bajo&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;  }&#xA;  delay(100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19741" LastEditorUserId="10794" LastEditDate="2016-03-31T08:35:36.080" LastActivityDate="2016-03-31T12:27:31.047" Title="Need to make an action just once when condition is reached" Tags="|c++|arduino-pro-mini|sound|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22510" PostTypeId="2" ParentId="22509" CreationDate="2016-03-30T21:41:25.970" Score="3" Body="&lt;p&gt;A possible solution to your problem can be the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PCM.h&amp;gt;&#xA;const unsigned char sample[] PROGMEM = { //Here goes the sample&#xA;};&#xA;int low = 0;&#xA;int mid = 0;&#xA;int high = 0;&#xA;bool first = true;&#xA;bool second = true;&#xA;bool third = true;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  low = analogRead(A0);&#xA;  mid = analogRead(A1);&#xA;  high = analogRead(A2);&#xA;  Serial.print(&quot;nivel agua: &quot;);&#xA;&#xA;  if (high &amp;gt; 50 &amp;amp;&amp;amp; first){&#xA;    Serial.print(&quot;Alto&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    first = false;&#xA;  }&#xA;  else if (mid &amp;gt;50 &amp;amp;&amp;amp; second){&#xA;    Serial.print(&quot;Medio&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    second = false;&#xA;  }&#xA;  else if (low &amp;gt; 50 &amp;amp;&amp;amp; third){&#xA;    Serial.print(&quot;Bajo&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    third = false;&#xA;  }&#xA;  delay(100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this way the sound for each level will be played only once. I hope this is what you were looking for.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastActivityDate="2016-03-30T21:41:25.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22511" PostTypeId="1" CreationDate="2016-03-30T22:31:27.990" Score="0" ViewCount="3896" Body="&lt;p&gt;I recently bought a brand new Arduino pro micro from &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B012FOV17O&quot; rel=&quot;nofollow&quot;&gt;Amazon&lt;/a&gt;, I set it up according to the instructions on &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#installing-windows&quot; rel=&quot;nofollow&quot;&gt;sparkfun&lt;/a&gt;, except that when I plug it in, Windows doesn't even show that it tried to install device driver software. I figured it might just be a windows 10 thing because the tutorial was written on windows 7, so I forged ahead, and updated the device driver for COM3 in device manager, and attempted to upload a simple test for HID emulation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Keyboard.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Keyboard.write('z');&#xA;}&#xA;&#xA;void loop() {&#xA;  Keyboard.write('a');&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It compiled just fine, and the IDE said it started uploading to the device, However, as it was uploading (or so I thought) I read a little farther and realized that the IDE wasn't set to use the right voltage (3.3V instead of 5V) I closed the IDE and reopened my sketch, changed the voltage to match up, and tried uploading it again. Here, it got stuck on the &lt;code&gt;Uploading...&lt;/code&gt; text and so again, I closed the IDE. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only the LED closest to the USB port is on, and it's solid green. I've connected to my computer using a Micro USB to USB adapter, and I initially plugged the board into a USB 3.0, but then switched to 2.0 to see if it made a difference. I have also tried it on Ubuntu 14.04 with no luck. I don't think it's bricked because if it was, my computer would still recognize it, but not know what it was (according to sparkfun), and as a result, I have yet to try the debricking method they suggest. Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="19713" LastActivityDate="2016-06-03T13:46:23.307" Title="Arduino Pro Micro troubles" Tags="|arduino-pro-micro|clones|windows|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22512" PostTypeId="2" ParentId="22511" CreationDate="2016-03-30T23:37:42.207" Score="1" Body="&lt;p&gt;The Pro Micro, like the Leonardo, cannot automatically reboot into the bootloader like boards such as the Uno and Mega.  Instead it relies on the sketch running on it listening for a special combination of events (open the serial port, set the baud rate to 1200 baud, close the serial port) to activate the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, for whatever reason, you don't have a working sketch installed on the board (such as you aborted the upload part way through) then there will be nothing there to listen for the &quot;reboot into bootloader&quot; instructions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to manually enter the bootloader. Fortunately it should be easy enough, but timing is all important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you first plug the board in, or when you press the reset button, you get a few seconds where the board is in the bootloader.  On the Leonardo that is signified by the LED glowing and pulsating - I don't know off hand what is shown on the Pro Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as you press the reset button just before you compile and upload your sketch, and as long as the upload portion doesn't take too long to start (tip: compile it before uploading, it makes it faster) it should then install the sketch into the board and from then on the auto-reboot should start working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: I haven't used a Pro Micro - this is all from my experience with the Leonardo which I believe uses the same bootloader.) &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-30T23:37:42.207" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22513" PostTypeId="1" CreationDate="2016-03-31T00:07:07.357" Score="2" ViewCount="317" Body="&lt;p&gt;So I have 7 different sensor I’d like to send to Processing, then use each of their values as variables inside different webcam filters. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I’m going off of &lt;a href=&quot;https://itp.nyu.edu/physcomp/labs/labs-serial-communication/two-way-duplex-serial-communication-using-an-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; which has been helpful, but it doesn’t give linear steps – more like different techniques depending on what you’re trying to use it for. &#xA;In that tutorial, it shows two ways to initialize connection between Serial and Arduino – the Punctuation method and the Call-and-response method. I used the Punctuation method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up the Punctuation method, you put the sensor values into one string, separated with commas. Once the values are sent over, you split the string and put all of the values into an array. Once in an array, you can individually take out each of the values and turn them into variables that are usable in the draw loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Processing sketch runs perfectly fine sometimes. Otherwise it will give either this error : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Error, disabling serialEvent() for /dev/cu.usbmodem1421&#xA;  null&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or this one :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WT6Eg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WT6Eg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone see anything fishy with the syntax or structure I’m setting up? &#xA;(I took out all filter functions except the temp -&gt; blur to make debugging easier.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// get the serial lib :&#xA;import processing.serial.*;&#xA;&#xA;// give port a variable :&#xA;Serial port;&#xA;&#xA;// get the webcam lib :&#xA;import processing.video.*;&#xA;&#xA;// give webcam a variable :&#xA;Capture webcam;&#xA;&#xA;// sensors&#xA;int cap1, cap2, piezo, temp, axisX, axisY, axisZ;&#xA;&#xA;void setup() {&#xA;  size(480, 360, P2D);&#xA;  smooth();&#xA;&#xA;  webcam = new Capture(this, width, height, 24);&#xA;  webcam.start();&#xA;&#xA;  String portName = &quot;/dev/cu.usbmodem1421&quot;;&#xA;  port = new Serial(this, portName, 9600);&#xA;  //port.bufferUntil('\n');&#xA;}&#xA;&#xA;void captureEvent(Capture webcam) {&#xA;  webcam.read();&#xA;}&#xA;&#xA;void serialEvent(Serial port) {&#xA;&#xA;  String reading = port.readStringUntil('\n');&#xA;  if (reading != null) {&#xA;    reading = trim(reading);&#xA;&#xA;    int values[] = int(split(reading, ','));&#xA;&#xA;    for (int valNum = 0; valNum &amp;lt; values.length; valNum++) {&#xA;      print(values[valNum] + &quot;|&quot;);&#xA;    }&#xA;    println();&#xA;&#xA;    if (values.length &amp;gt; 1) {&#xA;      cap1 = values[0];&#xA;      cap2 = values[1];&#xA;      piezo = values[2]; &#xA;      temp = values[3];&#xA;      axisX = values[4];&#xA;      axisY = values[5];&#xA;      axisZ = values[6];&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void draw() {&#xA;&#xA;  // temp  &#xA;  float t;&#xA;  if (temp &amp;gt;= 100) { //when analog pin unplugged &#xA;    t = 6;&#xA;  } else {&#xA;    t = 0;&#xA;  }&#xA;&#xA;  image(webcam, 0, 0);&#xA;  filter(BLUR, t);&#xA;}&#xA;&#xA;//if down key pressed, saveImage();&#xA;void saveImage()&#xA;{&#xA;  saveFrame(&quot;images/captured-####.jpg&quot;);&#xA;}&#xA;&#xA;void keyPressed() {&#xA;  if (key == CODED) {&#xA;    if (keyCode == DOWN) { &#xA;      saveImage();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I’m thinking it’s an issue with memory, or maybe the way I’m sending/receiving the data is shoddy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently one of the disadvantages to using Punctuation rather than Call-and-response is that it can slow down the program if it contains a lot of graphic work… but why would it work in perfect time sometimes and then not work at all?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insight would be amazing!!&lt;/p&gt;&#xA;" OwnerUserId="19747" LastActivityDate="2016-03-31T00:07:07.357" Title="Arduino Uno to Processing, using Serial" Tags="|serial|processing-lang|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22514" PostTypeId="1" CreationDate="2016-03-30T23:46:48.940" Score="3" ViewCount="5435" Body="&lt;p&gt;I just bought my first Arduino compatible device, and I am greatly enjoying it. I finally could not resist the urge after going to an Arduino meetup, where someone showed me their &lt;code&gt;Teensy&lt;/code&gt; connected to their laptop and reacting to MIDI signals over USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not knowing anything, I bought my clone and soon learned about the whole &lt;code&gt;CH340G&lt;/code&gt; limitation where it doesn't &quot;just work&quot; (I cannot simply use the USBMIDI Arduino library), and instead I need to run a software MIDI-serial converter command (&lt;code&gt;ttymidi&lt;/code&gt;) in order to send the signals to my Arduino clone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been reading up a bit (the amount of information out there is perhaps too vast and often outdated or simply doesn't exactly solve my problem) and have learned of &lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow&quot;&gt;V-USB&lt;/a&gt; and the project &lt;a href=&quot;http://cryptomys.de/horo/V-USB-MIDI/index.html&quot; rel=&quot;nofollow&quot;&gt;V-USB-MIDI&lt;/a&gt; but I am really out of my element here and do not know how to approach this to get it all working (since it is not just an Arduino sketch and &lt;code&gt;.h&lt;/code&gt; header). Or even if this is a solution to my problem. I've read about some solutions which require using an AVR via some of the pins (as opposed to over USB) since you have to reprogram the chip in such a way that it no longer is programmable over USB once the sketch is uploaded, but if I understood it correctly, you can't do even this on the &lt;code&gt;CH340G&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, are there any examples of getting this working? A sketch or something? I downloaded the latest V-USB release, but I really don't want to make a mistake that will brick or otherwise ruin my device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically: I want to just upload my MIDI sketch (with whatever necessary modifications or code) such that I do not need &lt;code&gt;ttymidi&lt;/code&gt; to have the device recognized as a MIDI device (over USB) that I can just &quot;plug 'n' play&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19157" OwnerDisplayName="insaner" LastEditorUserId="6936" LastEditDate="2016-03-31T13:59:45.720" LastActivityDate="2016-03-31T13:59:45.720" Title="Arduino clone CH340G (ATmega328P), MIDI over USB" Tags="|usb|midi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22515" PostTypeId="1" CreationDate="2016-03-31T03:34:28.860" Score="-1" ViewCount="489" Body="&lt;p&gt;I'm trying to connect a HC-05 to AB Shutter3 module. However, when I try to search AB Shutter3 address via AT commands (&lt;code&gt;AT+INQ&lt;/code&gt;) I could not find AB Shutter3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to integrate both, so that I can send commands from an AB Shutter button click to HC-05. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also want to know whether the HC-05 needs to be in master or in slave mode.&lt;/p&gt;&#xA;" OwnerUserId="19749" LastEditorUserId="6936" LastEditDate="2016-03-31T13:36:14.960" LastActivityDate="2023-02-17T06:06:35.720" Title="HC-05 to low cost AB shutter 3" Tags="|arduino-uno|bluetooth|hc-05|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22516" PostTypeId="2" ParentId="9666" CreationDate="2016-03-31T06:38:00.217" Score="3" Body="&lt;p&gt;Nick Gammon, a moderator on the official Arduino site and a very active member of the Arduino community on Stackoverflow, has done a very nice post on &lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;reading serial without blocking&lt;/a&gt;. I've posted the relevant code.&#xA;    /*&#xA;    Example of processing incoming serial data without blocking.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Author:   Nick Gammon&#xA;Date:     13 November 2011. &#xA;Modified: 31 August 2013.&#xA;&#xA;Released for public use.&#xA;*/&#xA;&#xA;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 50;&#xA;&#xA;void setup (){&#xA;Serial.begin (115200);&#xA;} // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data)&#xA; {&#xA; // for now just display it&#xA; // (but you could compare it to some value, convert to an integer, etc.)&#xA; Serial.println (data);&#xA; }  // end of process_data&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;{&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;switch (inByte)&#xA;  {&#xA;&#xA;  case '\n':   // end of text&#xA;    input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;    // terminator reached! process input_line here ...&#xA;    process_data (input_line);&#xA;&#xA;    // reset buffer for next time&#xA;    input_pos = 0;  &#xA;    break;&#xA;&#xA;  case '\r':   // discard carriage return&#xA;    break;&#xA;&#xA;  default:&#xA;    // keep adding if not full ... allow for terminating null byte&#xA;    if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;      input_line [input_pos++] = inByte;&#xA;    break;&#xA;&#xA;  }  // end of switch&#xA;&#xA;} // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;{&#xA;// if serial data available, process it&#xA;while (Serial.available () &amp;gt; 0)&#xA;  processIncomingByte (Serial.read ());&#xA;&#xA;// do other stuff here like testing digital input (button presses) ...&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13674" LastActivityDate="2016-03-31T06:38:00.217" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22517" PostTypeId="2" ParentId="22514" CreationDate="2016-03-31T07:14:05.433" Score="2" Body="&lt;p&gt;V-USB &lt;a href=&quot;https://en.wikipedia.org/wiki/Bit_banging&quot; rel=&quot;nofollow&quot;&gt;bit bangs&lt;/a&gt; some GPIO pins so that they speak the low-speed USB protocol.&#xA;This does not use the 'normal' USB connection through the CH340; you would have to solder a separate USB cable to those GPIO pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming would be no problem; the V-USB code is just normal code that runs on the MCU. (Programming through ISP pins would be required on hardware where USB communication and programming is handled with a &lt;em&gt;second&lt;/em&gt; AVR MCU; in that case, the USB/MIDI code would run on that second MCU.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Low-speed USB is not supposed to be used for MIDI, and as a software emulation, V-USB does not work very well, or efficiently.&#xA;If you want to create a USB device, you should use an MCU that actually supports USB in hardware, such as the ATmega32U4 or AT90USB646 used on some Teensies.&lt;/p&gt;&#xA;" OwnerUserId="6802" LastActivityDate="2016-03-31T07:14:05.433" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22521" PostTypeId="2" ParentId="22515" CreationDate="2016-03-31T09:56:40.953" Score="0" Body="&lt;p&gt;I rather suspect the AB Shutter 3 is a Bluetooth HID device (like a keyboard or a mouse). The HC-05 can only communicate with Bluetooth Serial devices, such as the HC-06 or systems that can emulate a serial device (such as a computer or a smartphone).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't get them to communicate no matter how hard you hit them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-31T09:56:40.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22522" PostTypeId="2" ParentId="17411" CreationDate="2016-03-31T11:00:08.450" Score="1" Body="&lt;p&gt;There are 3(or 4) places that you need to look at to know how to upload.&lt;br&gt;&#xA;There is the boards.txt file and the platform.txt file.&lt;br&gt;&#xA;You can consider a platform.txt file line &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tools.avrdude.path={runtime.tools.avrdude.path}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as (in linux in windows replace ${xx} by %xx%)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set tools.avrdude.path ${runtime.tools.avrdude.path}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the board.txt for the selected board like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.bootloader.tool=avrdude&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set bootloader.tool avrdude&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The arduino ide uses the following string to know the upload command environment variable&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tools.${bootloader.tool}.upload.pattern&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way it knows the command to upload is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;{cmd.path} is hardcoded as tools.${bootloader.tool}.cmd.path which equals {path}/bin/avrdude&lt;br&gt;&#xA;where {path} is to be understood as tools.${bootloader.tool}.path wich equals {runtime.tools.avrdude.path}.&lt;br&gt;&#xA;{runtime.tools.avrdude.path} is defined by the boardsmanager based n the json file and the location where the boardsmanager extracted the download.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that makes 3 files: boards.txt, platform.txt and json file and some hard coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 4th file comes into play when you use the &quot;other upload commands&quot;. These are located in the programmers.txt file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO Arduino IDE core team did not opt for the simplest solution to define these things. They also change the way they work from time to time.&lt;br&gt;&#xA;If you use a makefile know that a lot of people have done this already so it may be a good idea to &quot;reuse other peoples work&quot; instead of &quot;reinventing the wheel&quot;. It is not so easy or straightforward.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; I know all these things because I implemented the Arduino eclipse IDE. As far as I know none of this is documented.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-03-31T11:00:08.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22523" PostTypeId="2" ParentId="22492" CreationDate="2016-03-31T11:04:47.213" Score="2" Body="&lt;p&gt;Both other answers are correct, but my usual way of dealing with this is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long startTime = 0;&#xA;#define MEASURE_PERIOD 250&#xA;...&#xA;void loop()&#xA;{&#xA;    if((millis() - startTime) &amp;gt;= MEASURE_PERIOD)&#xA;    {&#xA;        startTime += MEASURE_PERIOD;&#xA;        // Do your job, such as&#xA;        int temp;&#xA;        sensorValue=analogRead(GSR);&#xA;        Serial.println(sensorValue);&#xA;        temp = threshold - sensorValue;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The difference between this way and the other ones (Nick's way, i.e. saving &lt;code&gt;millis&lt;/code&gt; and setting the &lt;code&gt;startTime&lt;/code&gt; variable to it, or nico's one - which is worse - , to set it again), is that this way if there is some error (e.g. 260ms between two calls) it gets recovered by the next cycle (which will be of 240ms), while in their way it is not.&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-03-31T11:04:47.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22524" PostTypeId="2" ParentId="22506" CreationDate="2016-03-31T11:20:33.120" Score="1" Body="&lt;p&gt;There is a good example of using the &lt;strong&gt;SubmitHttpRequest()&lt;/strong&gt; in this article:&#xA;&lt;a href=&quot;https://roysoala.wordpress.com/2012/11/20/gprs-shield-sim900-arduino-get-data-application/&quot; rel=&quot;nofollow&quot;&gt;GPRS Shield SIM900 Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could easily modify:&#xA;&lt;strong&gt;mySerial.println(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;www.yourwebsite.com/testing.php\&quot;&quot;);&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to include a string of the sensor value, and then using a PHP script to MySQL on your webserver. Maybe something like: &#xA;http://&lt;strong&gt;yourwebsite.com&lt;/strong&gt;/testing.php?&lt;strong&gt;sensor1&lt;/strong&gt;=5&amp;amp;&lt;strong&gt;sensor2&lt;/strong&gt;=10&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-03-31T11:20:33.120" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22525" PostTypeId="2" ParentId="22509" CreationDate="2016-03-31T12:14:29.307" Score="0" Body="&lt;p&gt;As an addition to the answer of Mattia.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect you have something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  low = analogRead(A0);&#xA;  mid = analogRead(A1);&#xA;  high = analogRead(A2);&#xA;  Serial.print(&quot;nivel agua: &quot;);&#xA;&#xA;  if (resetVariables){&#xA;     first = true;&#xA;     second = true;&#xA;     third = true;&#xA;     resetVariables = false;&#xA;  }&#xA;&#xA;  if (high &amp;gt; 50 &amp;amp;&amp;amp; first){&#xA;    Serial.print(&quot;Alto&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    first = false;&#xA;  }&#xA;  else if (mid &amp;gt;50 &amp;amp;&amp;amp; second){&#xA;    Serial.print(&quot;Medio&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    second = false;&#xA;  }&#xA;  else if (low &amp;gt; 50 &amp;amp;&amp;amp; third){&#xA;    Serial.print(&quot;Bajo&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    third = false;&#xA;  }&#xA;&#xA;  if(buttonPressed){&#xA;    resetVariables = true;&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A better practice would be to use another function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void resetFlags() {&#xA;  first = true;&#xA;  second = true;&#xA;  third = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the main code would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  low = analogRead(A0);&#xA;  mid = analogRead(A1);&#xA;  high = analogRead(A2);&#xA;  Serial.print(&quot;nivel agua: &quot;);&#xA;&#xA;  if (high &amp;gt; 50 &amp;amp;&amp;amp; first){&#xA;    Serial.print(&quot;Alto&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    first = false;&#xA;  }&#xA;  else if (mid &amp;gt;50 &amp;amp;&amp;amp; second){&#xA;    Serial.print(&quot;Medio&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    second = false;&#xA;  }&#xA;  else if (low &amp;gt; 50 &amp;amp;&amp;amp; third){&#xA;    Serial.print(&quot;Bajo&quot;);&#xA;    startPlayback(sample, sizeof(sample));&#xA;    third = false;&#xA;  }&#xA;&#xA;  if(buttonPressed){&#xA;    resetFlags();&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would this be faster?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It would at least make your loop code more readable, instead of juggling flags around.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;resetFlags()&lt;/code&gt;; would act immediately and independent from the flag checking etc.&lt;/li&gt;&#xA;&lt;li&gt;It saves checking unnecessary if's (which equals a very little speed increase).&lt;/li&gt;&#xA;&lt;li&gt;It saves 1 boolean (byte maximal in memory) which equals a very little memory/speed increase.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But why mind speed if you have a 100msec delay?&#xA;You could make it only output the water level when it changes. Then you can run the water checking extremely fast!&#xA;(It wouldn't spam your console, plus, writing to console takes considerable amount of time, compared to checking if's.)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="19515" LastEditDate="2016-03-31T12:27:31.047" LastActivityDate="2016-03-31T12:27:31.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22527" PostTypeId="1" AcceptedAnswerId="22577" CreationDate="2016-03-31T13:48:40.277" Score="1" ViewCount="99" Body="&lt;p&gt;EDIT :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have plenty of weird bugs. I will open another thread, and come back to this one when I have better understanding, rather than completely modify this one halway through. Sorry to every answerer for my electronic incompetence which led me to ask the wrong questions; I hope the other thread makes more sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have recently exhumed an arduino from a cupboard, and can't seem to make even a blinking LED circuit work correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the sketch :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(9, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(9, HIGH);&#xA;  delay(1000);            &#xA;  digitalWrite(9, LOW);   &#xA;  delay(1000);              &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has been tried without the circuit, on pin 13, using the onboard LED, and it worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, using the following circuit, it did not result in a blinking LED, using several pins (8, 9, 12, 13) and LEDS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;May I assume the arduino is fried?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a thumbnail of the circuit : &lt;a href=&quot;https://i.stack.imgur.com/plQLY.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/plQLY.jpg&quot; alt=&quot;circuit picture&quot;&gt;&lt;/a&gt;  &lt;/p&gt;&#xA;" OwnerUserId="19700" LastEditorUserId="19700" LastEditDate="2016-04-01T13:06:40.333" LastActivityDate="2016-04-01T14:46:47.173" Title="Arduino fried? Onboard blink ok; offboard blink not ok" Tags="|c++|pins|hardware|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22529" PostTypeId="2" ParentId="19305" CreationDate="2016-03-31T14:06:59.620" Score="1" Body="&lt;p&gt;I can see no problem with your pseudo-code. You should probably post a&#xA;complete testable code in order to get better feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, here are a few suggestions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You should &lt;em&gt;completely set&lt;/em&gt; the ADC registers to the values that suit&#xA;your application, instead of just changing a few bits here and there.&#xA;This is because you should not care about how the Arduino core&#xA;library initializes those registers, especially if this is a&#xA;prototype for a final product that will not use Arduino core. For&#xA;example, instead of&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;REG1 = REG1 | 0x01;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can write something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;REG1 = _BV(FOO)   // use foo mode...&#xA;     | _BV(BAR);  // ...in the bar setting&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;_BV(x)&lt;/code&gt; is a macro from avr-libc that expands to &lt;code&gt;(1&amp;lt;&amp;lt;(x))&lt;/code&gt;,&#xA;   and the bit names are those of the datasheet, for better readability.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;You may want to run the digital filter in the ADC interrupt service&#xA;routine. If you can split your processing into a fast filter&#xA;(processing every sample) and a slow filter (running on decimated&#xA;samples), then do only the fast one in the ISR and leave the slow one&#xA;to the main loop. I say this from experience: when I tried to do&#xA;all the processing in &lt;code&gt;loop()&lt;/code&gt; I always lost samples, which did not&#xA;happen when I moved the filter to the ISR.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But then, make sure your filter is optimized to be &lt;em&gt;fast&lt;/em&gt;. Avoid&#xA;floating point operations in the ISR if at all possible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I have written a program that looks very similar to what you are trying&#xA;to do: it samples an analog input at 9.6&amp;nbsp;kS/s and runs an&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Homodyne_detection&quot; rel=&quot;nofollow&quot;&gt;homodyne detection&lt;/a&gt;&#xA;filter in order to extract the signal power in a very narrow band around&#xA;1&amp;nbsp;kHz. The ADC is set to free running mode. In the ADC ISR, I&#xA;retrieve the sample, run it through the filter, and store the result&#xA;into volatile variables. In &lt;code&gt;loop()&lt;/code&gt;, I read these back from time to&#xA;time. Here is how I set the ADC:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;static void configure_adc()&#xA;{&#xA;    ADMUX  = _BV(REFS0)  // ref = AVCC&#xA;           | _BV(ADLAR)  // left adjust result&#xA;           | analog_in;  // input channel&#xA;    ADCSRB = 0;          // free running mode&#xA;    ADCSRA = _BV(ADEN)   // enable&#xA;           | _BV(ADSC)   // start conversion&#xA;           | _BV(ADATE)  // auto trigger enable&#xA;           | _BV(ADIF)   // clear interrupt flag&#xA;           | _BV(ADIE)   // interrupt enable&#xA;           | 7;          // prescaler = 128&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The complete program is available here:&#xA;&lt;a href=&quot;https://gist.github.com/edgar-bonet/0b03735d70366bc05fc6&quot; rel=&quot;nofollow&quot;&gt;homodyne.ino&lt;/a&gt;.&#xA;It was initially intended for an Arduino Uno, but it runs unmodified on&#xA;a Leonardo clone.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-03-31T14:06:59.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22530" PostTypeId="1" AcceptedAnswerId="22531" CreationDate="2016-03-31T14:37:15.217" Score="1" ViewCount="1703" Body="&lt;p&gt;I have bought a SIM900 shield for an ordinary Arduino Uno board. The problem is that it doesn't have long pins on the bottom side, making it impossible to click on mu Arduino Uno.&#xA;The shield I have is this: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZOqzp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZOqzp.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, there are identical pin spaces next to the red and yellow plastic female pin things. Can I just solder new pins in the free spaces and will it work like that?&#xA;I notice that the yellow and red plastic female pin holders on my board are on the free spaces in this picture. I supposed I can just use the adjacent foles to solder long pins so I can use it for my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="1100" LastActivityDate="2016-05-08T23:12:13.437" Title="Arduino GPRS (GSM) shield (SIM900) no long pins" Tags="|arduino-uno|shields|gsm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22531" PostTypeId="2" ParentId="22530" CreationDate="2016-03-31T14:55:32.450" Score="3" Body="&lt;p&gt;Yes, you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is two methods of making shields stackable:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use the quite hard to source extra long pinned headers to go right through and down (such as these &lt;a href=&quot;https://www.adafruit.com/products/85&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/85&lt;/a&gt;) , or&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use separate headers and pins and (if you are using through hole) offsetting them.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your shield uses the second method, but the descending pins haven't been populated.  By populating those pins you are just completing the build.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="20249" LastEditDate="2016-05-08T23:12:13.437" LastActivityDate="2016-05-08T23:12:13.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22532" PostTypeId="1" CreationDate="2016-03-31T16:28:31.320" Score="2" ViewCount="118" Body="&lt;p&gt;HI I am a newbie and need some suggestions &#xA;Is there a possibility to do this?? I am trying to send MIDI data through a button using Arduino and bluetooth module HM10. Can someone help me write the loop part or am going the right way. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MIDI.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial (2, 3);&#xA;char c = ' ';&#xA;int pushButton7 = 7;&#xA;int buttonState7 = 0;&#xA;int note7 = 0;&#xA;void setup() {&#xA;  MIDI.begin(4);&#xA;  // 115200 hairless MIDI&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;  pinMode(pushButton7, INPUT);&#xA;}&#xA;&#xA;  void loop() {&#xA;&#xA;   int buttonState7 = digitalRead(pushButton7);&#xA;&#xA;&#xA;&#xA; // Button 7&#xA;&#xA;  // when button pressed:&#xA;  if (buttonState7 == HIGH) {&#xA;    // if note not playing&#xA;    if (note7 == 0) {&#xA;      // play note (note number, velocity, channel)&#xA;      // more info: http://arduinomidilib.sourceforge.net/a00001.html&#xA;      // MIDI notes chart http://www.phys.unsw.edu.au/jw/notes.html&#xA;      // 55 = G3, 127 = trigger note with max volume&#xA;      MIDI.sendNoteOn(55,127,1);&#xA;      // note is playing&#xA;      note7 = 1;&#xA;    }&#xA;  // when button released&#xA;  } else {&#xA;    // if note playing&#xA;    if (note7 == 1) {&#xA;      // if playing - stop&#xA;      MIDI.sendNoteOff(55,0,1);&#xA;    }&#xA;    // if button released note is off&#xA;    note7 = 0;&#xA;  }&#xA;&#xA;  delay(1);&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19765" LastActivityDate="2016-03-31T16:28:31.320" Title="Arduino with Bluetooth" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22533" PostTypeId="2" ParentId="22527" CreationDate="2016-03-31T17:00:30.140" Score="0" Body="&lt;p&gt;Try lighting up the LED without using any resistance in the middle, if that doesn't work try with a LED which consumes less current even if that doesn't work put the pin to HIGH state in code and measure the voltage of the given pin using a multimeter it should read above 3.3V. If neither of these work then you can be sure that your arduino is fried&lt;/p&gt;&#xA;" OwnerUserId="18545" LastActivityDate="2016-03-31T17:00:30.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22535" PostTypeId="2" ParentId="13727" CreationDate="2016-03-31T17:18:34.963" Score="0" Body="&lt;p&gt;There are two AVR ICs present on the Arduino board, one is used for the USB to ICSP interface and the other one is the &amp;mu;C which you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I've noticed that you've tried to connect &lt;code&gt;Tx&lt;/code&gt; and &lt;code&gt;Rx&lt;/code&gt; pins including reset for programming the IC. Those pins are used for communication on serial protocol, where as the AVR in Arduino is programmed using SPI Protocol, so you should be using MISO, MOSI, SCK, SS (they're pins 13-10 respectively) and Reset pins on the Arduino, then the AVR which is used as USB-SPI bridge for programming can communicate with the &amp;mu;C and program it.&lt;/p&gt;&#xA;" OwnerUserId="18545" LastEditorUserId="6936" LastEditDate="2016-03-31T19:04:21.440" LastActivityDate="2016-03-31T19:04:21.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22536" PostTypeId="1" CreationDate="2016-03-31T17:56:13.520" Score="0" ViewCount="185" Body="&lt;p&gt;I have an Arduino Uno connected to a motor controller over I2C. The Arduino accepts commands from a Raspberry Pi via the USB serial line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to diagnose a problem where the Arduino will become completely unresponsive. It's programmed to respond to a &quot;ping&quot; request every N seconds, and for some reason I can't identify, it seems to crash and no longer respond to any commands. However, the motor controller continues powering the motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything is powered from a 12V Li-Po battery, but everything is located behind 5V regulators. When this problem happens, the battery is fully charged and the motors aren't sourcing much current, and neither the motor controller or Raspberry Pi are effected, so I've ruled out a brownout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My theory is there's some subtle programming error in my Arduino code that's causing an &quot;exception&quot;, but I don't know how to identify it. I've tried adding special code to allow me to trigger one of these, by indexing an array outside of its limits or calling a null function pointer, but the Arduino stubbornly refuses to crash when I try to explicitly make it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I diagnose an Arduino becoming unresponsive?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="6936" LastEditDate="2016-03-31T19:07:16.753" LastActivityDate="2016-03-31T23:54:17.193" Title="Diagnosing crashed Arduino Uno" Tags="|arduino-uno|raspberrypi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22537" PostTypeId="1" AcceptedAnswerId="22548" CreationDate="2016-03-31T18:30:28.623" Score="1" ViewCount="60" Body="&lt;p&gt;I am making a basic 2WD robot using Arduino Uno with motor shield.&#xA;I am getting no compile errors - but something in my logic flow is not working as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected Operation:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Ping sensor does distance check.&lt;/li&gt;&#xA;&lt;li&gt;If distance is less than 5cm.&lt;/li&gt;&#xA;&lt;li&gt;Turn both Channel A &amp;amp; B motors half-speed for 1 second.&lt;/li&gt;&#xA;&lt;li&gt;Stop motors.&lt;/li&gt;&#xA;&lt;li&gt;Take new distance reading ping, start again.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;What however is happening, is that channel A works as expected, but channel B motor keeps running??&#xA;Where is my code / logic mistake?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later date I will add to &lt;code&gt;else&lt;/code&gt; statement to turn one wheel to change direction.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; HC-SR04 Ping distance sensor:&#xA; VCC to arduino 5v &#xA; GND to arduino GND&#xA; Echo to Arduino pin 7 &#xA; Trig to Arduino pin 8&#xA; */&#xA;&#xA;#define echoPin 7 // Echo Pin&#xA;#define trigPin 8 // Trigger Pin&#xA;#define LEDPin 13 // Onboard LED&#xA;&#xA;int maximumRange = 1000; // Maximum range needed&#xA;int minimumRange = 1; // Minimum range needed&#xA;long duration, distance; // Duration used to calculate distance&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;Serial.begin (9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)&#xA;&#xA;&#xA;  pinMode(12, OUTPUT); /* Motor Channel A RIGHT SIDE*/&#xA;  pinMode(9, OUTPUT); /* Motor Channel A */&#xA;&#xA;  pinMode(13, OUTPUT); /* Motor Channel B LEFT SIDE */&#xA;  pinMode(8, OUTPUT);&#xA;&#xA;  }&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;  /* Distance check begins */&#xA;&#xA;  digitalWrite(trigPin, LOW); &#xA;  delayMicroseconds(2); &#xA;&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10); &#xA;&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;&#xA; //Calculate the distance (in cm) based on the speed of sound.&#xA; distance = duration/58.2;&#xA;&#xA; /* End distance check */&#xA;&#xA; if (distance &amp;gt;= 5){&#xA; /* Distance great enough to provide room to move */&#xA;  Serial.println(&quot;Move!&quot;);&#xA;&#xA;  digitalWrite(LEDPin, HIGH); /* LED show movement */&#xA;&#xA;  digitalWrite(12, LOW); /*move channel A motor half-speed */&#xA;  digitalWrite(9, LOW);&#xA;  analogWrite(3, 123);&#xA;&#xA;  digitalWrite(13, HIGH); /*move channel B motor half-speed */&#xA;  digitalWrite(8, LOW);&#xA;  analogWrite(11, 123); &#xA;&#xA;  delay(1000);&#xA;&#xA;  digitalWrite(9, HIGH); &#xA;  digitalWrite(8, HIGH);&#xA; }&#xA;&#xA; else {&#xA; /* Send the distance to the computer using Serial protocol, and&#xA; turn LED OFF to indicate successful reading. */&#xA; Serial.println(distance);&#xA; digitalWrite(LEDPin, LOW); &#xA; }&#xA;&#xA; //Delay 50ms before next reading.&#xA; delay(500); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19770" LastEditorUserId="19515" LastEditDate="2016-04-01T17:50:58.223" LastActivityDate="2016-04-01T17:50:58.223" Title="2WD robot - logic error" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22538" PostTypeId="1" AcceptedAnswerId="22546" CreationDate="2016-03-31T18:38:14.107" Score="0" ViewCount="326" Body="&lt;p&gt;I am trying to create a stable communication channel without any mis-synchronization. In the SoftwareSerial library, the write function transmits one byte at a time. The mis-synchronization occurs when the receiver misjudges which bit is the start bit. Why is this a problem? Because the internal delay between the start bit and the first message bit is different from the internal delay between each message bit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the really good suggestions I have heard is to use &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=63755.0&quot; rel=&quot;nofollow&quot;&gt;Manchester encoding&lt;/a&gt; on the Arduino. While I am testing out this option, I also wanted advice on altering the software serial library in the following way. If I modify the write function to transmit 128 bytes instead of 1, then this can avoid the problem I explained above, I &lt;em&gt;assume.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I have altered the write function of SoftwareSerial. I haven't thought of any issues with this approach, but does anyone else see any problems? &#xA;Here is the whole altered function. (I changed the parameter, and added 2 new loops - one to invert all the bytes if(inv) and another loop outside the loop that transmits each bit of a byte. I have attached the original function, further below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t SoftwareSerial::write(byte* b)&#xA;{&#xA;  if (_tx_delay == 0) {&#xA;    setWriteError();&#xA;    return 0;&#xA;  }&#xA;&#xA;// By declaring these as local variables, the compiler will put them&#xA;// in registers _before_ disabling interrupts and entering the&#xA;// critical timing sections below, which makes it a lot easier to&#xA;// verify the cycle timings&#xA;volatile uint8_t *reg = _transmitPortRegister;&#xA;uint8_t reg_mask = _transmitBitMask;&#xA;uint8_t inv_mask = ~_transmitBitMask;&#xA;uint8_t oldSREG = SREG;&#xA;bool inv = _inverse_logic;&#xA;uint16_t delay = _tx_delay;&#xA;&#xA;//Doubtful of this loop ------------------&#xA;for(int i = 0; i &amp;lt; 128; i++)&#xA;{&#xA;  if (inv)&#xA;    b[i] = ~(b[i]); &#xA;}&#xA;&#xA;cli();  // turn off interrupts for a clean txmit&#xA;&#xA;// Write the start bit&#xA;if (inv)&#xA;  *reg |= reg_mask;&#xA;else&#xA;  *reg &amp;amp;= inv_mask;&#xA;&#xA;tunedDelay(delay);&#xA;for(int j = 0; j &amp;lt; 128; j++)&#xA;{&#xA;  // Write each of the 8 bits&#xA;  for (long i = 8; i &amp;gt; 0; --i)&#xA;  {&#xA;    if (b[j] &amp;amp; 1) // choose bit&#xA;      *reg |= reg_mask; // send 1&#xA;    else&#xA;      *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;    tunedDelay(delay);&#xA;    b[j] &amp;gt;&amp;gt;= 1;&#xA;  }&#xA;}&#xA;// restore pin to natural state&#xA;if (inv)&#xA;  *reg &amp;amp;= inv_mask;&#xA;else&#xA;  *reg |= reg_mask;&#xA;&#xA;SREG = oldSREG; // turn interrupts back on&#xA;tunedDelay(_tx_delay);&#xA;&#xA;return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the original function. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t SoftwareSerial::write(uint8_t b)&#xA;{&#xA;if (_tx_delay == 0) {&#xA;  setWriteError();&#xA;  return 0;&#xA;}&#xA;&#xA;// By declaring these as local variables, the compiler will put them&#xA;// in registers _before_ disabling interrupts and entering the&#xA;// critical timing sections below, which makes it a lot easier to&#xA;// verify the cycle timings&#xA;volatile uint8_t *reg = _transmitPortRegister;&#xA;uint8_t reg_mask = _transmitBitMask;&#xA;uint8_t inv_mask = ~_transmitBitMask;&#xA;uint8_t oldSREG = SREG;&#xA;bool inv = _inverse_logic;&#xA;uint16_t delay = _tx_delay;&#xA;&#xA;if (inv)&#xA;  b = ~b;&#xA;&#xA;cli();  // turn off interrupts for a clean txmit&#xA;&#xA;// Write the start bit&#xA;if (inv)&#xA;  *reg |= reg_mask;&#xA;else&#xA;  *reg &amp;amp;= inv_mask;&#xA;&#xA;tunedDelay(delay);&#xA;&#xA;// Write each of the 8 bits&#xA;for (uint8_t i = 8; i &amp;gt; 0; --i)&#xA;{&#xA;  if (b &amp;amp; 1) // choose bit&#xA;    *reg |= reg_mask; // send 1&#xA;  else&#xA;    *reg &amp;amp;= inv_mask; // send 0&#xA;&#xA;  tunedDelay(delay);&#xA;  b &amp;gt;&amp;gt;= 1;&#xA;}&#xA;&#xA;// restore pin to natural state&#xA;if (inv)&#xA;  *reg &amp;amp;= inv_mask;&#xA;else&#xA;  *reg |= reg_mask;&#xA;&#xA;SREG = oldSREG; // turn interrupts back on&#xA;tunedDelay(_tx_delay);&#xA;&#xA;return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial buffer can only hold 64 bytes at a time, but I am using the following &lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;code&lt;/a&gt;, courtesy of Nick Gammon to read the data from serial buffer without blocking. So it shouldn't be a problem on the receiving end either, I hope.&lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="10794" LastEditDate="2016-03-31T23:14:21.590" LastActivityDate="2016-03-31T23:48:17.553" Title="Altering SoftwareSerial to transmit more than 1 byte at a time" Tags="|c++|softwareserial|wireless|coding-standards|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22539" PostTypeId="2" ParentId="22536" CreationDate="2016-03-31T19:09:24.777" Score="2" Body="&lt;p&gt;Assuming you don't have access to a debugger, the most common way is to add debug logging. The ususal algorithm to solve those problems is more or less like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do {&#xA;    add_logs_in_suspicious_places();&#xA;    wait_until_it_crashes();&#xA;    analyze_logs();&#xA;} while( ! i_know_why_it_crashes() );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you cannot add any debug logging because of a flawed system design (lack of I/O, etc) you've commited a captial engineering crime and this is your punishment. :)&lt;/p&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-03-31T19:24:16.250" LastActivityDate="2016-03-31T19:24:16.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22540" PostTypeId="2" ParentId="22536" CreationDate="2016-03-31T19:30:25.060" Score="1" Body="&lt;p&gt;There is an excellent &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board/13293#13293&quot;&gt;post&lt;/a&gt; by Nick Gammon that covers a wide array of possible problems. Look into this, as might be useful. &lt;/p&gt;&#xA;" OwnerUserId="13674" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-03-31T19:30:25.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22541" PostTypeId="2" ParentId="17" CreationDate="2016-03-31T19:46:44.737" Score="12" Body="&lt;p&gt;In my case I hadn't wired the RTS pin of the FTDI chip to a capacitor which went to the RST pin of the Arduino Pro Mini.  Once I installed this connection, I no longer got the error and I was able to upload code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon explains this &lt;a href=&quot;http://www.gammon.com.au/breadboard&quot;&gt;in his forum&lt;/a&gt;.&#xA;I've added a picture of where/how the capacitor should be placed.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hDu1t.jpg&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hDu1t.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19679" LastEditorUserId="8033" LastEditDate="2016-04-13T08:20:17.100" LastActivityDate="2016-04-13T08:20:17.100" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22542" PostTypeId="1" AcceptedAnswerId="22544" CreationDate="2016-03-31T19:59:39.143" Score="6" ViewCount="2014" Body="&lt;p&gt;Looks like I'm overshooting the storage of my Adafruit Trinket:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 5,600 bytes (105%) of program storage space. Maximum is 5,310 bytes.&#xA;Global variables use 109 bytes of dynamic memory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any tips for reducing the footprint of my code?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;&#xA;#define LEDPIN 1&#xA;#define TONE 4&#xA;#define BTNPIN 3&#xA;&#xA;RTC_DS1307 rtc;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, LEDPIN, NEO_RGB);&#xA;&#xA;long fadeTime = 1 * 10000L; // X minutes&#xA;int colorStops = 256;&#xA;int delaySpeed = fadeTime / colorStops;&#xA;int notes[] = {262,294,330,349};&#xA;int timeHour = 14;&#xA;int timeMinute = 43;&#xA;uint32_t alarmLength = 5 * 60000L; // 5 minutes&#xA;&#xA;void setup() {&#xA;  rtc.begin();&#xA;  if(!rtc.isrunning()) {&#xA;    rtc.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;&#xA;  pinMode(TONE,OUTPUT);&#xA;  pinMode(BTNPIN, INPUT);&#xA;  digitalWrite(BTNPIN, HIGH);&#xA;&#xA;  strip.begin();&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop() {&#xA;  DateTime now = rtc.now(); &#xA;&#xA;  if (now.hour() == timeHour &amp;amp;&amp;amp; now.minute() == timeMinute &amp;amp;&amp;amp; now.second() == 0){&#xA;    // Fade in light&#xA;    for(int i = 1; i&amp;lt;colorStops; i++){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;        strip.setPixelColor(np, strip.Color(i,i,0));&#xA;      }&#xA;      strip.show();&#xA;      delay(delaySpeed);&#xA;    }&#xA;&#xA;    // Play tone after light fully bright&#xA;    for( uint32_t tStart = millis();  (millis()-tStart) &amp;lt; alarmLength; ){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;        strip.setPixelColor(np, strip.Color(random(100,255),random(100,255),random(100,255)));&#xA;      }&#xA;      strip.show();&#xA;&#xA;      beep(TONE, notes[random(0,3)], 50);&#xA;      delay(100);&#xA;    }&#xA;&#xA;    for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;      strip.setPixelColor(np, strip.Color(0,0,0));&#xA;    }&#xA;    strip.show();&#xA;  }&#xA;}&#xA;&#xA;void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)&#xA;{   // http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html&#xA;  int x;   &#xA;  long delayAmount = (long)(1000000/frequencyInHertz);&#xA;  long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));&#xA;  for (x=0;x&amp;lt;loopTime;x++)   &#xA;  {  &#xA;    digitalWrite(speakerPin,HIGH);&#xA;    delayMicroseconds(delayAmount);&#xA;    digitalWrite(speakerPin,LOW);&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&#xA;bool kill() {&#xA;  if (! digitalRead(BTNPIN)) {&#xA;    for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;      strip.setPixelColor(np, strip.Color(0,0,0));&#xA;    }&#xA;    strip.show();&#xA;    return true;&#xA;  }&#xA;  else {&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-03-31T21:03:43.150" LastActivityDate="2021-04-01T13:27:48.820" Title="How can I reduce the size of my sketch?" Tags="|adafruit|sketch-size|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22543" PostTypeId="2" ParentId="22527" CreationDate="2016-03-31T20:25:26.977" Score="1" Body="&lt;p&gt;Here's a guide posted by Nick Gammon for checking if your Arduino is bricked &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board/13293#13293&quot;&gt;Is My Arduino Bricked ?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="521" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-31T20:25:26.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22544" PostTypeId="2" ParentId="22542" CreationDate="2016-03-31T20:26:45.013" Score="4" Body="&lt;p&gt;The AdaFruit Trinket just doesn't have a lot of memory - 8kb, of which 3kb is used by the bootloader.&lt;/p&gt;&#xA;&lt;p&gt;The order I look for things to reduce the footprint of an Arduino program are:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;data (e.g. large strings)&lt;/li&gt;&#xA;&lt;li&gt;libraries&lt;/li&gt;&#xA;&lt;li&gt;your code (especially doing the same things several times, which might be combined into loops or functions).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this case, you don't have much data. Most of your resulting program size is in the libraries you use.&lt;/p&gt;&#xA;&lt;p&gt;It seems like you use the clock solely to detect the year - that seems like a lot of overhead just to figure out what year it is. It then does nothing for subsequent years (or prior years), if I read your code correctly. Maybe you would consider dropping this code? Then you can skip the entire RTC library. At least try it to see how much you save. I suspect that the RTC library will use another library to do the underlying work.&lt;/p&gt;&#xA;&lt;p&gt;You use the &amp;lt;Wire.h&amp;gt; library, but don't reference it in your code. It should be optimized out (unless used elsewhere), but there's no reason to have it there.&lt;/p&gt;&#xA;&lt;p&gt;You may also save a little space by replacing initialized variables which don't change to constants. Storing &lt;code&gt;25&lt;/code&gt; in a variable takes 1 byte, plus 2 bytes every time you reference it; &lt;code&gt;25&lt;/code&gt; in a constant gets optimized away, and will take up 1 byte every time you reference it.&lt;/p&gt;&#xA;&lt;p&gt;As mentioned in the comments, you can also save a few bytes by specifying the size of your int's, especially initialized ones.&lt;/p&gt;&#xA;&lt;p&gt;Another option would be to use a larger chip - the AtMega328p used in (for example) the Arduino has 32kb of flash - 6 times the (available) size.&lt;/p&gt;&#xA;&lt;p&gt;You can also save some bytes by removing the clause &lt;code&gt; if(!rtc.isrunning()) {&lt;/code&gt;, once you have set it up once.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Additional&lt;/strong&gt;: I have had some success reducing footprints by reimplementing a subset of a library. Usually, libraries are very well implemented, but if your needs are substantially different/simpler than what the library was designed for, or you are willing to forgo parts of it (e.g. error checking), then SOMETIMES this can help. WARNING! There is a HIGH price to pay (coding, debugging, loss of error checking, undetected bugs etc), and it may &lt;em&gt;not&lt;/em&gt; save you anything in the end.&lt;/p&gt;&#xA;&lt;p&gt;You can also (sometimes) move data (e.g. large strings) to eeprom. The Trinket has 512 bytes of eeprom. You may need one sketch to load the data into eeprom, to run before loading your main sketch. eeprom has it's own overhead, so may not be worthwhile for 512 bytes, it is slower (which probably won't matter for this), and you have a limited number of writes.&lt;/p&gt;&#xA;&lt;p&gt;Another few bytes may be saved by doing all the maths for the tone frequency/time beforehand, and sacrificing something. For example, you beep for 50ms. If, instead of passing the frequency (between 262 and 349 hertz) and instead pre-calculate the delayAmount (for 262 hz, this would be 1,000,000/262 = 3817ms); your looptime for this is ((timeInMilliseconds&lt;em&gt;1000)/(delayAmount&lt;/em&gt;2)) = (50&lt;em&gt;1000)/(3817&lt;/em&gt;2) = 6.55 cycles. 7 cycles is probably &amp;quot;close enough&amp;quot; for all the tones you want to produce. So you can hardcode 7 cycles (using a constant of 7 for looptime), and get rid of that formula to calculate looptime.&lt;/p&gt;&#xA;&lt;p&gt;In a similar way, if you don't care too much about the exact frequency (which varies between 3817ms and 2865ms depending on your random number), you might specify the delayamount as 2865+random(0,3)*238 (make sure you store at least the random number, you don't want it to change during the loop!).&lt;/p&gt;&#xA;&lt;p&gt;You now have:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define random_beep_length 7&#xA;void random_beep (unsigned char speakerPin)&#xA;{   // http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html&#xA;    // Heavily modified!&#xA;  int x;&#xA;  unsigned char pitch = 2865+random(0,3)*238;&#xA;  for (x=0;x&amp;lt;random_beep_length;x++)   &#xA;  {  &#xA;    digitalWrite(speakerPin,HIGH);&#xA;    delayMicroseconds(delayAmount);&#xA;    digitalWrite(speakerPin,LOW);&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="68358" LastEditDate="2021-04-01T13:27:48.820" LastActivityDate="2021-04-01T13:27:48.820" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22545" PostTypeId="2" ParentId="22542" CreationDate="2016-03-31T21:19:32.410" Score="3" Body="&lt;p&gt;An option not already mentioned, but may be worth mentioning, would be to remove the bootloader and program the chip directly with a hardware programmer (or another Arduino). That will increase the available sketch memory from 5kiB to the full 8kiB on the chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-31T21:19:32.410" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22546" PostTypeId="2" ParentId="22538" CreationDate="2016-03-31T21:32:36.640" Score="0" Body="&lt;p&gt;Basically your code has changed the size of the RS-232 packet from 10 bits to 1026 bits. There is nothing &quot;wrong&quot; with that, but it doesn't really solve the problem of a missed start bit - if anything it makes it worse since instead of losing 8 bits you lose 1024 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Synchronisation is best done separately to the transmission of packets, and for that you need your packet to be nice and short.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A packet consists of 10 bits - the first is a LOW and the last is a HIGH; everything else in between is data.  The trick is to provide a forced idle period before sending of &lt;em&gt;at least&lt;/em&gt; the amount of time it takes to transfer one packet.  That way if the receiver is mistakenly in a receive loop for whatever reason the 10 (or more) bits worth of HIGH will effectively cause the receiver to finish whatever it is doing and get ready to receive your real byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a hugely long packet (1024 + 2 bits) flushing the receiver before transmitting will take a very long time - rather than just one byte's worth of time it will be your entire packet's transmit time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that you then have the problem of byte order and data integrity checking.  Just sending two bytes (or 128 bytes) is not reliable. You need to wrap those bytes in a protocol including a start-of-packet indicator (0x55 0xAA is common, as is the special ASCII character 0x01: SOH), packet or payload length, and checksums.  Options for things like sequence numbers, acknowledgements, packet retransmission, etc can also be built in to increase the reliability of the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than trying to reinvent the wheel by changing the underlying data layer transmission you should learn the OSI 7 layer model and implement your protocol at a higher level than the data layer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-03-31T21:32:36.640" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22547" PostTypeId="1" CreationDate="2016-03-31T22:13:10.790" Score="2" ViewCount="1504" Body="&lt;p&gt;I'm trying to get GPS data transmitted from one Arduino UNO to a second unit to eventually be displayed on an LCD and stored in an SD card.  I am using Xbees S2C's on Xbee Shield's to do this.  The GPS information is coming from an Adafruit ultimate GPS breakout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I wanted so send two NMEA sentences as strings, but have since found that the EasyTransfer library does not like that.  I was getting information but it was just random characters, sort of.  The pattern was repeated, so it was consistent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing some searching I thought the best way to do it was to convert my strings to character arrays and send those.  I managed to successfully convert them to character arrays, but I can't seem to get them over to the other Arduino.  I do get the FIX int as well as the Length int that I sent over just to make sure it is working.  Any ideas on what I am doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sender code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EasyTransfer.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GPS.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt; &#xA;&#xA;SoftwareSerial mySerial(3, 2); //Initialize SoftwareSerial, and tell it you will be connecting through pins 2 and 3&#xA;Adafruit_GPS GPS(&amp;amp;mySerial); //Create GPS object&#xA;&#xA;String NMEA1;  //We will use this variable to hold our first NMEA sentence&#xA;String NMEA2;  //We will use this variable to hold our second NMEA sentence&#xA;char c;       //Used to read the characters spewing from the GPS module&#xA;int fix = 0;&#xA;long GPStime = 0;&#xA;int val = 0;&#xA;&#xA;EasyTransfer ET;&#xA;&#xA;//Declare Data Structure for the EasyTransfer Library&#xA;//Note: Data Structure must be same on TX and RX...&#xA;&#xA;struct DATA_STRUCTURE{&#xA; int fixed;&#xA; int length1;&#xA; int length2;&#xA; char* nmea1;&#xA; char* nmea2;&#xA;};&#xA;&#xA;DATA_STRUCTURE myData;&#xA;&#xA;void setup()&#xA;{&#xA;  //Initalizing EasyTransfer Serial Ports&#xA;  Serial.begin(115200);&#xA;  ET.begin(details(myData), &amp;amp;Serial);&#xA;  GPS.begin(9600);       //Turn GPS on at baud rate of 9600&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, LOW);&#xA;  //Serial.println(&quot;Two GPS Sentences From GPS&quot;);&#xA;  GPS.sendCommand(&quot;$PGCMD,33,0*6D&quot;); // Turn Off GPS Antenna Update&#xA;  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //Tell GPS we want only $GPRMC and $GPGGA NMEA sentences&#xA;  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);   // 10 Hz update rate&#xA;  delay(1000);  //Pause&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  readGPS();  //This is a function we define below which reads two NMEA sentences from GPS&#xA;  //Sending Data&#xA;  ET.sendData();&#xA;}&#xA;&#xA;void readGPS()    //This function will read and remember two NMEA sentences from GPS&#xA;{  &#xA;  clearGPS();    //Serial port probably has old or corrupt data, so begin by clearing it all out&#xA;  while(!GPS.newNMEAreceived())   //Keep reading characters in this loop until a good NMEA sentence is received&#xA;  { &#xA;    c=GPS.read(); //read a character from the GPS&#xA;  }&#xA;  GPS.parse(GPS.lastNMEA());  //Once you get a good NMEA, parse it&#xA;  NMEA1=GPS.lastNMEA();      //Once parsed, save NMEA sentence into NMEA1&#xA;  while(!GPS.newNMEAreceived()) //Go out and get the second NMEA sentence, should be different type than the first one read above.&#xA;  { &#xA;    c=GPS.read();&#xA;  }&#xA;  GPS.parse(GPS.lastNMEA());&#xA;  NMEA2=GPS.lastNMEA();&#xA;&#xA;  fix = GPS.fix;&#xA;  if (fix == 1)&#xA;  {&#xA;    //Serial.print(&quot;FIXED&quot;);&#xA;    digitalWrite(13, HIGH);&#xA;    //Serial.print(NMEA1);&#xA;    myData.fixed = 1;&#xA;    int str_len1 = NMEA1.length();&#xA;    char char_array1[str_len1];&#xA;    NMEA1.toCharArray(char_array1, str_len1);&#xA;    myData.length1 = str_len1;&#xA;&#xA;    //Serial.print(char_array1);&#xA;    //Serial.println(&quot;&quot;);&#xA;    //Serial.println(&quot;&quot;);&#xA;    myData.nmea1 = char_array1;&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;    //Serial.println(&quot;No fix&quot;);&#xA;    digitalWrite(13, LOW);&#xA;    myData.fixed = 0;&#xA;&#xA;  }&#xA;}&#xA;&#xA;void clearGPS() //Since between GPS reads, we still have data streaming in, we need to clear the old data by reading a few sentences, and discarding these&#xA;{  &#xA;  while(!GPS.newNMEAreceived()) &#xA;  {&#xA;    c=GPS.read();&#xA;  }&#xA;  GPS.parse(GPS.lastNMEA());&#xA;  while(!GPS.newNMEAreceived()) &#xA;  {&#xA;    c=GPS.read();&#xA;  }&#xA;  GPS.parse(GPS.lastNMEA());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiver Code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EasyTransfer.h&amp;gt;&#xA;#include &quot;Wire.h&quot;&#xA;#include &quot;Adafruit_LiquidCrystal.h&quot;&#xA;&#xA;EasyTransfer ET;&#xA;&#xA;Adafruit_LiquidCrystal lcd(0);&#xA;&#xA;//Declare Data Structure for the EasyTransfer Library&#xA;//Note: Data Structure must be same on TX and RX...&#xA;&#xA;struct DATA_STRUCTURE{&#xA; int fixed;&#xA; int length1;&#xA; int length2;&#xA; char* nmea1;&#xA; char* nmea2;&#xA; //int pause;&#xA;};&#xA;&#xA;DATA_STRUCTURE myData;&#xA;&#xA;char* NMEA1[100] = {0};&#xA;&#xA;void setup()&#xA;{&#xA; //Initalizing EasyTransfer Serial Ports&#xA; Serial.begin(115200);&#xA; ET.begin(details(myData), &amp;amp;Serial);&#xA;&#xA; lcd.begin(20, 4);&#xA; lcd.clear();&#xA; lcd.setBacklight(HIGH);&#xA;&#xA; pinMode(13, OUTPUT);&#xA; digitalWrite(13, LOW);&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //check and see if a data packet has come in. &#xA;  if(ET.receiveData()){&#xA;    //this is how you access the variables. [name of the group].[variable name]&#xA;    int FIX = myData.fixed;&#xA;    int LENGTH1 = myData.length1;&#xA;    char* NMEA1 = myData.nmea1;&#xA;    Serial.println(FIX);&#xA;    Serial.println(LENGTH1);&#xA;    Serial.print(NMEA1);&#xA;    Serial.println(&quot;&quot;);&#xA;    if (myData.fixed == 1)&#xA;    {&#xA;      digitalWrite(13, HIGH);&#xA;      lcd.setCursor(10, 3);&#xA;      lcd.print(&quot; GPS Fixed&quot;);&#xA;    }&#xA;    else&#xA;    {&#xA;      digitalWrite(13, LOW);&#xA;      lcd.setCursor(10, 3);&#xA;      lcd.print(&quot;No GPS Fix&quot;);&#xA;    }&#xA;  }&#xA;&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&#xA;K-Bert&lt;/p&gt;&#xA;" OwnerUserId="19774" LastEditorUserId="37523" LastEditDate="2019-07-18T19:18:38.867" LastActivityDate="2019-07-18T19:18:38.867" Title="Sending GPS data between two Arduinos using Easy Transfer" Tags="|arduino-uno|lcd|softwareserial|communication|gps|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22548" PostTypeId="2" ParentId="22537" CreationDate="2016-03-31T22:20:59.843" Score="2" Body="&lt;p&gt;I believe that your error is in that you declare &lt;code&gt;LEDpin&lt;/code&gt; as pin 13 and then your motor B as pin 13 as well, that to me would result in errors when you write to the led in the else statement at the end of your code. I would recommend that you clean this up, don't use pins for different things. Try this first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your logic is ok in terms of functionality.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also why is there inconsistency at this part on your code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;digitalWrite(12, LOW); /*move channel A motor half-speed */&#xA;  digitalWrite(9, LOW);&#xA;  analogWrite(3, 123);&#xA;&#xA;  digitalWrite(13, HIGH); /*move channel B motor half-speed */&#xA; digitalWrite(8, LOW);&#xA;  analogWrite(11, 123);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why do you say pin &lt;code&gt;12&lt;/code&gt; must be&lt;code&gt;LOW&lt;/code&gt; and &lt;code&gt;13 HIGH&lt;/code&gt; when moving forward? Is this the way your un-mentioned circuit setup works, if possible could you add this info?&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-03-31T22:20:59.843" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22549" PostTypeId="1" CreationDate="2016-03-31T22:39:08.317" Score="4" ViewCount="2239" Body="&lt;p&gt;I have a servo motor on one end which can be turned ON and OFF with web service sending SOAP request. In the other end I have my Arduino UNO with ESP8266. Currently, I am able to send HIGH or LOW status from my Arduino to ESP8266. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My query is: After receiving the status &quot;HIGH&quot; from Arduino to ESP8266, I need to POST the status via SOAP request so that my motor would be &quot;turned ON&quot; . After turning ON the motor in the other end I would like to GET a simple SOAP response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure if the above explains to you clearly but I am tired of thinking &quot;how to do this&quot;. &lt;/p&gt;&#xA;" OwnerUserId="19777" LastEditorUserId="26916" LastEditDate="2017-11-04T08:15:06.817" LastActivityDate="2017-11-04T08:15:06.817" Title="Sending data from Arduino UNO as a SOAP request" Tags="|arduino-uno|esp8266|servo|web-server|web-service|" AnswerCount="0" CommentCount="8" ClosedDate="2021-07-30T09:07:45.093" ContentLicense="CC BY-SA 3.0" />
  <row Id="22550" PostTypeId="2" ParentId="22538" CreationDate="2016-03-31T23:48:17.553" Score="1" Body="&lt;p&gt;So far you have asked a &lt;em&gt;lot&lt;/em&gt; of questions about your project which uses SoftwareSerial to send a lot of bits:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17864/how-to-transmit-more-than-1-byte-continually&quot;&gt;How to transmit more than 1 byte continually?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/16390/basic-serial-transmission-protocol&quot;&gt;Basic Serial Transmission Protocol&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17326/synchronization-and-implementing-hamming-code-on-software-serial&quot;&gt;Synchronization and Implementing hamming code on Software Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/22274/encoding-clock-signal-into-linear-block-codes&quot;&gt;Encoding clock signal into linear block codes&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/16393/how-to-fix-baud-rate-when-hardware-capacity-has-a-low-limit&quot;&gt;How to fix baud rate when hardware capacity has a low limit?&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17021/unable-to-tell-if-error-is-from-receiving-or-transmitting-end&quot;&gt;Unable to tell if error is from receiving or transmitting end&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17309/read-function-in-software-serial&quot;&gt;Read function in Software Serial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And now we have another one (this question).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you are flogging a dead horse with this. For one thing, what are you trying to achieve, that can't be achieved by just sending the bytes &quot;normally&quot; as 8-bit bytes? The only thing I can think of is a slight speed increase. By trying to make a 1024-bit packet, you are saving some start and stop bits in the middle, that's all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In some of your other questions you mention 9600 baud, so let's run with that. At 9600 baud one bit is 1/9600 of a second, that is 104.17 µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To transmit 1024 bits &quot;normally&quot; you would need 128 bytes, each of which needs a start and stop bit, so the total is &lt;code&gt;128 * 10 * 104.17 µs = 133.338 ms.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use your system you need 1024 bits plus one start and stop bit, so that is &lt;code&gt;1026 * 104.17 µs = 106.878 ms.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far you have only saved 26.46 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could save a lot more by simply doubling the baud rate. Or quadrupling it. However SoftwareSerial is less reliable at higher baud rates. Why not use HardwareSerial?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your next problem is that SoftwareSerial turns interrupts off during reception of one byte, so that it gets the timing right. For an 8-bit byte this means they are off for &lt;code&gt;10 * 104.17 µs = 1.0417 ms&lt;/code&gt;. That's about the limit for turning interrupts off if you want the internal timer to work, the one which gives you &lt;code&gt;millis&lt;/code&gt; and &lt;code&gt;micros&lt;/code&gt;. If you turn them off for 128 times as long, you can say &quot;goodbye&quot; to knowing how much time has elapsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned in a comment, too, since serial comms relies on external clocks (that is, both ends have to get the clocking right) you can only afford around a ±2% error in the receiving clock to ensure that we are sampling at the correct place (see the datasheet) for an &lt;em&gt;8-bit byte&lt;/em&gt;. The error tolerance will drop to 1/128th of that if you try to send 128 bytes in a single stream. The crystal/resonator in the Arduino just won't be that good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, to avoid false detection of the start bit (which you have asked about elsewhere) you need a much longer gap between packets, to ensure that we get the correct start bit. Effectively you need a one-byte length (ie. the incoming data is continually HIGH) for 8-bit bytes. For 1024-bit packets you will need to introduce a gap of &lt;code&gt;1024 * 104.17 µs = 106.670 ms&lt;/code&gt; between packets. This required gap totally wipes out any saving by not sending those extra start and stop bits.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-03-31T23:48:17.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22551" PostTypeId="2" ParentId="22536" CreationDate="2016-03-31T23:54:17.193" Score="1" Body="&lt;p&gt;If you have spare pins, add debugging LEDs. For example, toggle one at the start of &lt;code&gt;loop&lt;/code&gt;, another at the start of another function, and so on. When the Arduino &quot;crashes&quot; the state of the LEDs should provide a hint as to where in the code it is.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but the Arduino stubbornly refuses to crash when I try to explicitly make it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Typically you are indexing outside an array or using uninitialized memory. Your debugging code has moved the problem around enough to stop it happening (or appearing to happen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you amend your question and post your code we might spot something.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-03-31T23:54:17.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22552" PostTypeId="2" ParentId="22527" CreationDate="2016-04-01T00:52:24.740" Score="0" Body="&lt;p&gt;It it possible the non-working LED got wired backward (it wouldn't be the first time!)? If the LED is clear enough, hold it up to the light and look inside the plastic bubble. There will be two bits of metal, one attached to each lead. One of them is significantly larger than the other; that's the cathode and it needs to be connected to the more negative side of the circuit. Here's a &lt;a href=&quot;http://www.instructables.com/id/IDENTIFY-THE-ANODECATHODE-of-LEDs/&quot; rel=&quot;nofollow&quot;&gt;picture&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-01T13:55:53.787" LastActivityDate="2016-04-01T13:55:53.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22553" PostTypeId="1" CreationDate="2016-04-01T02:57:22.047" Score="3" ViewCount="2462" Body="&lt;p&gt;&lt;strong&gt;I was wondering if it was possible to work, in the same Arduino board, both Transmitter and Receiver RF 433 MHz modules. Is it feasible?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the schematics I tried:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) a pushbutton toggles a state value (0 or 1) and triggers the RF transmitter to send it as a message to the receiver module&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) the RF receiver, whenever reading the message, turns on or off a LED according to the corresponding value (0 or 1)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zZx8k.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zZx8k.jpg&quot; alt=&quot;RF 433 Modules with the same Arduino board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the source code I wrote:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;#define BTN_PIN A0    // pushbutton que aciona a transmissao&#xA;#define LED_PIN 13    // LED aceso ao receber o sinal&#xA;#define TX_PIN   4    // ligado ao pino DATA do transmissor RF&#xA;#define RX_PIN   7    // ligado ao pino DATA do receptor RF&#xA;&#xA;#define SPEED  5000   // velocidade de comunicacao (bits por segundo)&#xA;&#xA;int estado = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(BTN_PIN, INPUT);&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;&#xA;  vw_set_tx_pin(TX_PIN);  // transmissor&#xA;  vw_set_rx_pin(RX_PIN);  // receptor&#xA;  vw_setup(SPEED);&#xA;  vw_rx_start();&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int pressionado = !digitalRead(BTN_PIN);&#xA;  char msg[4];&#xA;&#xA;  if (pressionado) {&#xA;    estado = !estado;&#xA;    itoa(estado, msg, 10);&#xA;&#xA;    vw_send((uint8_t *) msg, strlen(msg));&#xA;    vw_wait_tx();&#xA;&#xA;    Serial.print(&quot;Mensagem enviada: [&quot;);&#xA;    Serial.print(msg);&#xA;    Serial.println(&quot;]&quot;);&#xA;&#xA;    delay(500);&#xA;  }&#xA;&#xA;  uint8_t buf[VW_MAX_MESSAGE_LEN];&#xA;  uint8_t buflen = VW_MAX_MESSAGE_LEN;&#xA;  int recebido = 0;&#xA;&#xA;  memset(msg, 0, 4);&#xA;  if (vw_get_message(buf, &amp;amp;buflen)) {&#xA;&#xA;    for (int i = 0; i &amp;lt; buflen; i++)&#xA;      msg[i] = char(buf[i]);&#xA;    msg[buflen] = '\0';&#xA;&#xA;    Serial.print(&quot;Mensagem recebida: [&quot;);&#xA;    Serial.print(msg);&#xA;    Serial.println(&quot;]&quot;);&#xA;&#xA;    recebido = atoi(msg);&#xA;&#xA;    Serial.print(&quot;recebido = &quot;);&#xA;    Serial.println(recebido);&#xA;&#xA;    digitalWrite(LED_PIN, recebido);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run it, according to Serial Monitor it sends the message. The problem is no message comes to the RF receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Does anyone have an idea of what could be wrong?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="18758" LastActivityDate="2016-05-31T19:29:08.437" Title="RF 433 Module with VirtualWire: transmit and receive using the same Arduino board" Tags="|arduino-uno|rf|virtualwire|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22554" PostTypeId="2" ParentId="22527" CreationDate="2016-04-01T03:38:42.180" Score="0" Body="&lt;p&gt;You haven't exactly got the LED connected to pin 9, as in the code, have you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find it hard to believe that you can upload new sketches, but none of the pins work. Try pins 0 or 1, in the sketch, for example. Or the whole lot:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  for (int i = 0; i &amp;lt; 20; i++)&#xA;    pinMode (i, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  for (int i = 0; i &amp;lt; 20; i++)&#xA;  {&#xA;    digitalWrite(i, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(i, LOW);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now methodically test every pin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What happens if you plug the white jumper into 5V rather than the current digital pin 12&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The LED doesn't light. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Something's wrong with your testing. The processor cannot be powering up, and accepting new sketches, yet not have power to the +5V pin. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-01T03:38:42.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22557" PostTypeId="2" ParentId="22553" CreationDate="2016-04-01T08:49:58.650" Score="1" Body="&lt;p&gt;As said in the comment you definitely need an antenna on both modules. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible that you are not supplying enough power to the 433 Mhz modules. The Arduino is not capable of outputting much current and RF transmitters generally have large current spikes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would recommend that you use a seperate power supply to power the modules (do not forget to keep common ground between the Arduino and the Transmitter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also heard that it is preferred to not maintain common ground between the transmitter and the receiver. So if all else fails then use two separate power supplies. &lt;/p&gt;&#xA;" OwnerUserId="19784" LastActivityDate="2016-04-01T08:49:58.650" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22561" PostTypeId="2" ParentId="22443" CreationDate="2016-04-01T09:44:19.930" Score="1" Body="&lt;p&gt;So, I solved the problem. As is mentioned in my question, the problem was static electricity. I primed the styrofoam sphere with some special primer to make the styrofoam a little more stable and so on. That's it. Luckily I didn't touch the Arduino with the sphere. I think it would have damaged the Arduino.&lt;/p&gt;&#xA;" OwnerDisplayName="user19698" LastActivityDate="2016-04-01T09:44:19.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22563" PostTypeId="1" AcceptedAnswerId="22565" CreationDate="2016-04-01T09:51:56.740" Score="0" ViewCount="7827" Body="&lt;p&gt;The arduino IDE can't seem to find the wire.h file when i'm using the &lt;a href=&quot;https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home&quot; rel=&quot;nofollow&quot;&gt;new liquid crystal library&lt;/a&gt;. Does anyone know how to solve this? here is the code i'm using and the error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*-----( Import needed libraries )-----*/&#xA;#include &amp;lt;Wire.h&amp;gt;  // Comes with Arduino IDE &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;/*-----( Declare Constants )-----*/ /*-----( Declare objects )-----*/ // set the LCD address to 0x27 for a 16 chars 2 line display // A FEW use address 0x3F // Set the pins on the I2C chip used for LCD connections: //                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address&#xA;&#xA;/*-----( Declare Variables )-----*/ //NONE&#xA;&#xA;void setup()   /*----( SETUP: RUNS ONCE )----*/ {   Serial.begin(9600);  // Used to type in characters&#xA;&#xA;  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight&#xA;&#xA;// ------- Quick 3 blinks of backlight  -------------   for(int i = 0; i&amp;lt; 3; i++)   {&#xA;    lcd.backlight();&#xA;    delay(250);&#xA;    lcd.noBacklight();&#xA;    delay(250);   }   lcd.backlight(); // finish with backlight on  &#xA;&#xA;//-------- Write characters on the display ------------------ // NOTE: Cursor Position: (CHAR, LINE) start at 0     lcd.setCursor(0,0); //Start at character 4 on line 0   lcd.print(&quot;Hello, world!&quot;);   delay(1000);   lcd.setCursor(0,1);   lcd.print(&quot;HI!YourDuino.com&quot;);   delay(8000);  &#xA;&#xA;// Wait and then tell user they can start the Serial Monitor and type in characters to // Display. (Set Serial Monitor option to &quot;No Line Ending&quot;)   lcd.clear();   lcd.setCursor(0,0); //Start at character 0 on line 0   lcd.print(&quot;Use Serial Mon&quot;);   lcd.setCursor(0,1);   lcd.print(&quot;Type to display&quot;);  &#xA;&#xA;&#xA;}/*--(end setup )---*/&#xA;&#xA;&#xA;void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/ {   {&#xA;    // when characters arrive over the serial port...&#xA;    if (Serial.available()) {&#xA;      // wait a bit for the entire message to arrive&#xA;      delay(100);&#xA;      // clear the screen&#xA;      lcd.clear();&#xA;      // read all the available characters&#xA;      while (Serial.available() &amp;gt; 0) {&#xA;        // display each character to the LCD&#xA;        lcd.write(Serial.read());&#xA;      }&#xA;    }   }&#xA;&#xA;}/* --(end main loop )-- */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the compiler output&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino: 1.6.7 (Windows 10), Board: &quot;Arduino Nano, ATmega328&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;C:\Users\martin\Documents\Arduino\libraries\LiquidCrystal\I2CIO.cpp:35:26:&#xA;  fatal error: ../Wire/Wire.h: No such file or directory&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;#include &amp;lt;../Wire/Wire.h&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                      ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;  &#xA;  &lt;p&gt;compilation terminated.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;exit status 1 Error compiling.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;This report would have more information with   &quot;Show verbose output&#xA;  during compilation&quot;   enabled in File &gt; Preferences.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19788" LastActivityDate="2019-01-21T23:20:16.530" Title="Wire.h not found newliquidcrystal" Tags="|lcd|" AnswerCount="1" CommentCount="1" ClosedDate="2023-03-11T09:22:42.493" ContentLicense="CC BY-SA 3.0" />
  <row Id="22564" PostTypeId="2" ParentId="22542" CreationDate="2016-04-01T10:08:05.130" Score="3" Body="&lt;p&gt;As already mentioned by AMADANON Inc. in his answer, you should qualify&#xA;as &lt;code&gt;const&lt;/code&gt; all the constant variables at the beginning of the program.&#xA;This is probably the biggest space saver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can gain something like 100&amp;nbsp;bytes by using &lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;direct port&#xA;access&lt;/a&gt; instead of&#xA;pinMode/digitalRead/digitalWrite. In the case of the ATtiny85, you only&#xA;have port B, and the Arduino pin numbers are the same as the Atmel bit&#xA;numbers. So you would for example use &lt;code&gt;PINB &amp;amp; _BV(BTNPIN)&lt;/code&gt; instead of&#xA;&lt;code&gt;digitalRead(BTNPIN)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a few optimization opportunities in &lt;code&gt;beep()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pass only one parameter, as &lt;code&gt;speakerPin&lt;/code&gt; and &lt;code&gt;timeInMilliseconds&lt;/code&gt; are&#xA;constants in your program&lt;/li&gt;&#xA;&lt;li&gt;have this parameter be &lt;code&gt;delayAmount&lt;/code&gt; instead of &lt;code&gt;frequencyInHertz&lt;/code&gt;,&#xA;and store these delays, instead of the frequencies, in the &lt;code&gt;notes[]&lt;/code&gt;&#xA;constant array&lt;/li&gt;&#xA;&lt;li&gt;do not compute the number of iterations (the misnamed &lt;code&gt;loopTime&lt;/code&gt;)&#xA;beforehand, instead compute the elapsed time and loop until you reach&#xA;the required time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is my version of &lt;code&gt;beep()&lt;/code&gt; with these optimizations:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void beep(int delayAmount)&#xA;{&#xA;  for (uint16_t t = 0; t &amp;lt; BEEP_TIME*1000/2; t += delayAmount)&#xA;  {  &#xA;    PORTB |= _BV(TONE);  // digitalWrite(TONE,HIGH);&#xA;    delayMicroseconds(delayAmount);&#xA;    PORTB &amp;amp;= ~_BV(TONE);  // digitalWrite(TONE,LOW);&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the loop variable is actually &lt;em&gt;half&lt;/em&gt; the elapsed time. This&#xA;saves a few bytes. Making the number of iterations constant, as proposed&#xA;by AMADANON Inc., also saves a few bytes (6 bytes in my test).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also remove all the calls to &lt;code&gt;strip.Color()&lt;/code&gt;: replace every&#xA;instance of &lt;code&gt;strip.setPixelColor(np, strip.Color(r, g, b))&lt;/code&gt; by&#xA;&lt;code&gt;strip.setPixelColor(np, r, g, b)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With all these optimizations combined, I am quite confident you will&#xA;gain more than the 290 bytes you need to fit your program in the&#xA;Trinket.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-01T10:08:05.130" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22565" PostTypeId="2" ParentId="22563" CreationDate="2016-04-01T10:16:06.713" Score="2" Body="&lt;p&gt;The liquid crystal library has to be installed in the same folder as the wire library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libraries/Wire/Wire.h (etc)&#xA;libraries/LiquidCrystal/LiquidCrystal_I2C.h (etc)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a hard-coded path in the liquid crystal library pointing to the wire library that is relative to where the liquid crystal library is, which is done to get around the problem that the Arduino library doesn't recurse libraries. It's not actually needed since including the Wire library in the IDE is enough to tell it where to find it for the liquid crystal library, so I don't really know why they did it that way.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-01T10:16:06.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22567" PostTypeId="1" AcceptedAnswerId="25579" CreationDate="2016-04-01T12:04:55.273" Score="1" ViewCount="1401" Body="&lt;p&gt;I'm trying to use Analog Devices' isolated ADC &lt;a href=&quot;http://www.analog.com/en/products/analog-to-digital-converters/integrated-special-purpose-converters/energy-metering-ics/ade7912.html#product-overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;ADE7912&lt;/a&gt; to build a native product for voltage and current sensing, using an Arduino as a microcontroller. The IC communicates with the Arduino using SPI (and SCK frequencies of 8,4,2 and 1 MHz), and I have followed the datasheet and written down some basic code using SPI-transactions and all, which seems to be giving correct results when I apply a positive voltage to the inputs of the ADC. I have two problems here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I try to display the SCLK, MISO and MOSI signals on an oscilloscope, the clock seems to have trouble maintaining its value (it becomes erratic and hence the SPI communication also misses some values etc.) Why is this happening?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When I apply a negative voltage to the ADC inputs, the IC does not really show any response to that even though it clearly supports negative voltage inputs to the ADC, as mentioned in the datasheet. This might be an IC related problem, but I am not sure.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, is there anyone who has built a library for this IC? Would be greatly obliged if they could share it.&lt;/p&gt;&#xA;" OwnerUserId="16081" LastEditorUserId="28084" LastEditDate="2016-11-20T20:59:10.977" LastActivityDate="2016-12-20T21:12:32.357" Title="Using a SPI based ADC (ADE7912) with Arduino" Tags="|arduino-mega|spi|adc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22568" PostTypeId="1" AcceptedAnswerId="29274" CreationDate="2016-04-01T12:05:18.297" Score="1" ViewCount="4465" Body="&lt;p&gt;I'm trying to transmit using mode 5 with the rc switch library, but my reciever tells me that the data is using protocol 2. I'm using the RecieveDemo_simple example as a sniffer for 433 MHz and I'm recieving data with protocol 5 from a wireless electric plug that I want to replicate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to send the data, but it is using the wrong protocol most of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some output from the reciever:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Received 15766156 / 24bit Protocol: 2&#xA;Received 15766156 / 24bit Protocol: 5&#xA;Received 15885740 / 24bit Protocol: 2&#xA;Received 15885740 / 24bit Protocol: 2&#xA;Received 15766156 / 24bit Protocol: 2&#xA;Received 15766156 / 24bit Protocol: 2&#xA;Received 15766156 / 24bit Protocol: 5&#xA;Received 15885740 / 24bit Protocol: 2&#xA;Received 15885740 / 24bit Protocol: 2&#xA;Received 15885740 / 24bit Protocol: 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Example for different sending methods&#xA;&#xA;  https://github.com/sui77/rc-switch/&#xA;&#xA;*/&#xA;&#xA;#include &amp;lt;RCSwitch.h&amp;gt;&#xA;&#xA;RCSwitch mySwitch = RCSwitch();&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  // Transmitter is connected to Arduino Pin #10  &#xA;  mySwitch.enableTransmit(10);&#xA;&#xA;  // Optional set pulse length.&#xA;  // mySwitch.setPulseLength(320);&#xA;&#xA;  // Optional set protocol (default is 1, will work for most outlets)&#xA;  mySwitch.setProtocol(5);&#xA;&#xA;  // Optional set number of transmission repetitions.&#xA;  // mySwitch.setRepeatTransmit(15);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  /* Same switch as above, but using decimal code */&#xA;  mySwitch.send(15885740, 24);&#xA;  delay(1000);  &#xA;  mySwitch.send(15766156, 24);&#xA;  delay(1000);  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19788" LastEditorUserId="19788" LastEditDate="2016-04-01T21:00:21.090" LastActivityDate="2016-09-14T11:25:42.560" Title="Rc switch library transmit using protocol 5" Tags="|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22569" PostTypeId="1" AcceptedAnswerId="45047" CreationDate="2016-04-01T12:44:18.537" Score="3" ViewCount="2780" Body="&lt;p&gt;I'm dealing with an application in which I need to upload sketches remotely to an arduino UNO board. I successufully managed to upload sketches using an HC-06 bluetooth adapter. The only problem is that I am forced to manually press the reset button once the bluetooth link is established. Is there a way to automatically reset the arduino, in a software or hardware way,  so that it will be able to accept and install the incoming and sketch?&#xA;Would it be enough to activate a digital pin connected to the reset at the right timing prior the upload process starts?&lt;/p&gt;&#xA;" OwnerUserId="14571" LastEditorUserId="19515" LastEditDate="2016-04-01T13:36:30.577" LastActivityDate="2017-09-25T23:01:06.440" Title="Upload sketch via Bluetooth using HC-06 module" Tags="|bluetooth|sketch|uploading|bootloader|hc-06|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22570" PostTypeId="1" CreationDate="2016-04-01T13:24:46.537" Score="2" ViewCount="492" Body="&lt;p&gt;I am trying to communicate between HM-10 module (without any breadboard or soldering) and experience problem with reading data from serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define TO_HEX(i) (i &amp;lt;= 9 ? '0' + i : 'A' - 10 + i)&#xA;&#xA;void afterSetup() {&#xA;  Serial3.write(&quot;AT+NAME?&quot;);&#xA;  delay(500);&#xA;}&#xA;&#xA;void setup() {&#xA;  // initialize both serial ports:&#xA;  Serial.begin(9600);&#xA;&#xA;  /*Serial3.begin(115200);  // The Bluetooth Mate defaults to 115200bps&#xA;  delay(100);  // Short delay, wait for the Mate to send back CMD&#xA;  Serial3.println(&quot;U,9600,N&quot;);  // Temporarily Change the baudrate to 9600, no parity&#xA;  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably*/&#xA;  Serial3.begin(9600);  // Start bluetooth serial at 9600&#xA;&#xA;  Serial.write(&quot;\n\n\n==== START ====\n&quot;);&#xA;&#xA;  afterSetup();&#xA;}&#xA;&#xA;unsigned char mode = 2;&#xA;&#xA;void wr(HardwareSerial*, int);&#xA;&#xA;void wr(HardwareSerial *target, int bt, unsigned char mode) {&#xA;    //target-&amp;gt;write(TO_HEX(((bt &amp;amp; 0xF000) &amp;gt;&amp;gt; 12 )));&#xA;    //target-&amp;gt;write(TO_HEX(((bt &amp;amp; 0x0F00) &amp;gt;&amp;gt; 8 )));&#xA;    if(mode &amp;gt; 0) {&#xA;      target-&amp;gt;write(&quot;\t\t\t\t&quot;);&#xA;    }&#xA;    target-&amp;gt;write(TO_HEX(((bt &amp;amp; 0x00F0) &amp;gt;&amp;gt; 4 )));&#xA;    target-&amp;gt;write(TO_HEX((bt &amp;amp; 0x000F)));&#xA;    target-&amp;gt;write(&quot; (&quot;);&#xA;    target-&amp;gt;write(bt);&#xA;    target-&amp;gt;write(&quot;)\n&quot;);&#xA;    return;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // read from port 1, send to port 0:&#xA;  if (Serial3.available()) {&#xA;    int inByte = Serial3.read();&#xA;&#xA;    if(mode != 1) {&#xA;      mode = 1;&#xA;    }&#xA;&#xA;    wr(&amp;amp;Serial, inByte, 1);&#xA;  }&#xA;&#xA;  // read from port 0, send to port 1:&#xA;  if (Serial.available()) {&#xA;    int inByte = Serial.read();&#xA;    Serial3.print((char)inByte);&#xA;&#xA;    if(mode != 0) {&#xA;      mode = 0;&#xA;    }&#xA;&#xA;    wr(&amp;amp;Serial, inByte, 0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Wiring is simple:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;HM-10    | due&#xA;-------------------&#xA;RX       | TX3&#xA;TX       | RX3&#xA;VCC      | 3V3&#xA;GND      | GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Basically, I am able to get data from serial, but it &lt;strong&gt;corrupted&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Command: AT+NAME?&lt;/li&gt;&#xA;&lt;li&gt;Expected: HMSoft&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Response:         &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;        28 (()&#xA;        25 (%)&#xA;        2A (*)&#xA;        35 (5)&#xA;        15 ()&#xA;        FE (�)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And another, simpler:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Command:  AT&lt;/li&gt;&#xA;&lt;li&gt;Expected: OK&lt;/li&gt;&#xA;&lt;li&gt;Response: F5&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="16411" LastEditorUserId="37523" LastEditDate="2019-07-18T19:10:23.263" LastActivityDate="2019-07-18T19:10:23.263" Title="HM-10 and Arduino Due" Tags="|bluetooth|arduino-due|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="22571" PostTypeId="1" AcceptedAnswerId="22573" CreationDate="2016-04-01T13:25:59.463" Score="0" ViewCount="230" Body="&lt;p&gt;here is a very simple circuit, with a LED between pin 2 and ground, and a loose wire in pin 8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RGims.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RGims.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sketch that was intended for use with a small 4-contact switch like these in every arduino starter kit :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int yellowCIn = 8;&#xA;int yellowCOut = 2;&#xA;&#xA;void setup() {&#xA;  pinMode(yellowCIn, INPUT);&#xA;  pinMode(yellowCOut, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (digitalRead(yellowCIn) == HIGH) {&#xA;  digitalWrite(yellowCOut, HIGH);&#xA;  }&#xA;  else {&#xA;    digitalWrite(yellowCOut, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, simply moving my hand near the loose white wire is enough to light the LED, moving it away to put it off. As I am writing this, with the arduino connected by usb, rather than on the blue battery visible in the picture, I notice moving my hands away from the keyboard lights the led, moving them close to the keyboard powers it off...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So back to my title : are my hands magic, my electronics competency crap (well, it is, for sure) enough that I never heard of such a tremendous static electricity effect (and never fried one of the many computers I built from parts), or does this board have dire problems?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your attention :)&lt;/p&gt;&#xA;" OwnerUserId="19700" LastActivityDate="2016-04-01T13:40:19.403" Title="Proximity sensor without proximity sensor; is my hand magic, my competency crap, or my arduino fried?" Tags="|electricity|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22572" PostTypeId="2" ParentId="22571" CreationDate="2016-04-01T13:37:49.173" Score="1" Body="&lt;p&gt;Try configuring your input pin as INPUT_PULLUP instead. This connects an internal pullup resistor to stop the input value from drifting around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would only use the &quot;INPUT&quot; mode on its own if I have that pin wired to something on the board and the levels won't be erratic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your hands are magic - they pick up interference from various sources and the high impedance input of the chip pick this up...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There's a bit more on the modes here: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;nofollow&quot;&gt;Arduino DigitalPins page&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-04-01T13:37:49.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22573" PostTypeId="2" ParentId="22571" CreationDate="2016-04-01T13:40:19.403" Score="2" Body="&lt;p&gt;Nothing's broken; you have discovered  the nature of a floating pin.  Unfortunately, that means that strange things happen...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A very small charge from your hand is triggering the logic because the state of the pin (high or low) is not set.  To fix this, you need to add a &lt;a href=&quot;http://playground.arduino.cc/CommonTopics/PullUpDownResistor&quot; rel=&quot;nofollow&quot;&gt;pull-up or pull-down resistor&lt;/a&gt; (or activate the internal &lt;a href=&quot;https://www.arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow&quot;&gt;input-pullup resistor&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can read about how to accomplish this &lt;a href=&quot;https://learn.sparkfun.com/tutorials/pull-up-resistors&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19017" LastActivityDate="2016-04-01T13:40:19.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22574" PostTypeId="2" ParentId="22569" CreationDate="2016-04-01T13:42:24.820" Score="1" Body="&lt;p&gt;Here's a instructable on how to reset the arduino with software&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/two-ways-to-reset-arduino-in-software/&quot; rel=&quot;nofollow&quot;&gt;Instructables link&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19788" LastActivityDate="2016-04-01T13:42:24.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22575" PostTypeId="1" AcceptedAnswerId="22576" CreationDate="2016-04-01T14:17:24.497" Score="0" ViewCount="196" Body="&lt;p&gt;I have a GSM shield connected with my Intel Galileo board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I intend to connect the board with serial communication at a baud rate of 115200 instead of the GSM library. I want to print the results of &quot;at&quot; commands in my serial window, how should I do it?&lt;/p&gt;&#xA;" OwnerUserId="19279" LastEditorUserId="19515" LastEditDate="2016-04-01T17:51:37.587" LastActivityDate="2017-05-28T05:33:56.187" Title="Print the response from GSM shield" Tags="|gsm|arduino-galileo|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22576" PostTypeId="2" ParentId="22575" CreationDate="2016-04-01T14:44:48.593" Score="0" Body="&lt;p&gt;I have only worked with the SIMCOM series of GSM modules like the SIM900 and the SIM808. Here is a sample of the kind of code you should be looking at using.&#xA;It will send one &quot;AT&quot; to the GSM module and then it will spit out the result in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  int bytesSent = Serial.write(“AT\r\n”); //send &quot;AT&quot; and send the end of line characters to signify end of the command&#xA; }&#xA;&#xA; void loop()&#xA;{&#xA;   if (Serial.available() &amp;gt; 0) {&#xA;            // read the incoming byte:&#xA;            incomingByte = Serial.read();&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19784" LastEditorUserId="19784" LastEditDate="2016-06-01T07:50:01.803" LastActivityDate="2016-06-01T07:50:01.803" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22577" PostTypeId="2" ParentId="22527" CreationDate="2016-04-01T14:46:47.173" Score="0" Body="&lt;p&gt;My arduino is not bricked, I just don't know how many things I don't understand about electronics, and make every single mistake I can make, especially while cabling.&lt;/p&gt;&#xA;" OwnerUserId="19700" LastActivityDate="2016-04-01T14:46:47.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22578" PostTypeId="1" CreationDate="2016-04-01T12:58:26.380" Score="0" ViewCount="350" Body="&lt;p&gt;I have just programmed a new micro, loaded the basic blink code in it. After that neither my laptop, nor my desktop sees it anyway with the following usb error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Fri Apr  1 14:32:01 2016] usb 1-2: device descriptor read/64, error -62&#xA;[Fri Apr  1 14:32:01 2016] usb 1-2: device descriptor read/64, error -62&#xA;[Fri Apr  1 14:32:02 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd&#xA;[Fri Apr  1 14:32:02 2016] usb 1-2: device descriptor read/64, error -62&#xA;[Fri Apr  1 14:32:02 2016] usb 1-2: device descriptor read/64, error -62&#xA;[Fri Apr  1 14:32:02 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd&#xA;[Fri Apr  1 14:32:03 2016] usb 1-2: device not accepting address 8, error -62&#xA;[Fri Apr  1 14:32:03 2016] usb 1-2: reset full-speed USB device number 8 using ohci_hcd&#xA;[Fri Apr  1 14:32:03 2016] usb 1-2: device not accepting address 8, error -62&#xA;[Fri Apr  1 14:32:03 2016] usb 1-2: USB disconnect, device number 8&#xA;[Fri Apr  1 14:32:03 2016] usb 1-2: new full-speed USB device number 9 using ohci_hcd&#xA;[Fri Apr  1 14:32:04 2016] usb 1-2: device descriptor read/64, error -62&#xA;[Fri Apr  1 14:32:04 2016] usb 1-2: device descriptor read/64, error -62&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I push the reset button on it it comes back a bit then disappears again:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;22620.495256] usb 1-2: New USB device found, idVendor=2341, idProduct=0037&#xA;[22620.495263] usb 1-2: New USB device strings: Mfr=2, Product=1, SerialNumber=0&#xA;[22620.495268] usb 1-2: Product: Arduino Micro   &#xA;[22620.495272] usb 1-2: Manufacturer: Arduino LLC&#xA;[22620.497393] cdc_acm 1-2:1.0: ttyACM0: USB ACM device&#xA;[22627.966141] usb 1-2: USB disconnect, device number 32&#xA;[22628.432089] usb 1-2: new full-speed USB device number 33 using ohci_hcd&#xA;[22628.572111] usb 1-2: device descriptor read/64, error -62&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anybody experienced this? I have tried to reconnect it multiple times to both computers, even tried a new cable doesn't help.&lt;/p&gt;&#xA;" OwnerDisplayName="Defiler" LastEditorUserId="27346" LastEditDate="2018-11-08T14:21:21.887" LastActivityDate="2018-11-08T14:21:21.887" Title="Arduino micro lost connection after first programming" Tags="|usb|arduino-micro|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22579" PostTypeId="2" ParentId="22578" CreationDate="2016-04-01T13:33:20.493" Score="3" Body="&lt;p&gt;The USB part of the Atmega32U4 needs quite a bit of software to operate correctly, which is either not included in the basic blinky example or you got a binary for a different Arduino model.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The syslog looks like there is a bootloader present after Reset for a couple of seconds..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[22620.497393] cdc_acm 1-2:1.0: ttyACM0: USB ACM device&#xA;     ^&#xA;[22627.966141] usb 1-2: USB disconnect, device number 32&#xA;     ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;.. which shuts down and starts blinky. This is documented on the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;ArduinoBoardMicro&lt;/a&gt; page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Re-flashing the chip is a bit tricky in this state, as you must press the reset button at the &quot;right&quot; time just before the software wants to access the chip.&lt;/p&gt;&#xA;" OwnerUserId="19797" OwnerDisplayName="Turbo J" LastActivityDate="2016-04-01T13:33:20.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22580" PostTypeId="1" CreationDate="2016-04-01T09:47:39.667" Score="2" ViewCount="1845" Body="&lt;p&gt;I am trying to use map command which is used to power servo 180 degrees as the potentiometer moves...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in fact what i want to do is just when i adjust my potentiometer to zero; stop the dc motor then after turn the pot to 512 analog value turn the motor to the left (digitalWrite(I1, HIGH); digitalWrite(I2, LOW);)and then stop when it reach 512 then when adjust the pot back to zero turn the dc motor to the right (digitalWrite(I1, HIGH); digitalWrite(I2, LOW);) but the think is what i am trying to do is exactly what we can do with the servo motor in the knob &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/Knob&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/Knob&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a normal DC motor and l293D IC but I want to control the DC as knob method like the 200 degrees. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define E1 11    // Enable Pin for motor &#xA;#define I1 10    // Control pin a for motor &#xA;#define I2 9     // Control pin b for motor &#xA;const int analogPin = A0;  &#xA;int analogValue ;  &#xA;&#xA;void setup() {&#xA;  pinMode(E1, OUTPUT);&#xA;  pinMode(I1, OUTPUT);&#xA;  pinMode(I2, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int analogValue = analogRead(analogPin);&#xA;&#xA;  if(analogValue &amp;gt; 0 &amp;amp;&amp;amp; analogValue &amp;lt; 512)  {&#xA;&#xA;  analogWrite(E1, 255);   &#xA;  digitalWrite(I1, HIGH);&#xA;  digitalWrite(I2, LOW);&#xA;    delay(100); &#xA;} else &#xA;  analogWrite(E1, 255);  &#xA;  digitalWrite(I1, LOW);&#xA;  digitalWrite(I2, HIGH);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19831" OwnerDisplayName="mohammad" LastEditorUserId="19831" LastEditDate="2016-04-02T18:23:20.017" LastActivityDate="2019-02-08T19:56:36.533" Title="Using map for DC motor instead of servo" Tags="|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22581" PostTypeId="2" ParentId="22580" CreationDate="2016-04-01T11:49:10.333" Score="1" Body="&lt;p&gt;It looks like you want to use the &quot;analogValue&quot; to control the direction and speed of your DC motor.  If this is correct consider using this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      //This method assumes: The center position of the pot is the motor's 0 speed point,   &#xA;      //(because this is an ideal speed to actually reverse the motor's direction).&#xA;      //A PWM control range of 0-255, and the ADC input range of 0-1023.  &#xA;&#xA;      //First create a relative speed value from &quot;analogValue&quot;,   &#xA;      //with the pot mid point at 0 speed, and pot high/low points being full speed.  &#xA;&#xA;      int motorSpeed = 0;  &#xA;      if (analogValue &amp;lt; 512 )  &#xA;      {  &#xA;       motorSpeed = map(analogValue, 0, 511, 255, 0);  &#xA;      }  //Note that mapped range is reversed to give 0 speed at mid point.           &#xA;      else  &#xA;      {  &#xA;       motorSpeed = map(analogValue, 512, 1023, 0, 255);  &#xA;      }&#xA;&#xA;      //then replace each analogWrite(E1, 255) with:  &#xA;      analogWrite(E1, speedValue);  &#xA;&#xA;      //you should also change &quot;  if (analogValue &amp;gt; 2 &amp;amp;&amp;amp; analogValue &amp;lt; 500) {  &quot; to:  &#xA;      if (analogValue &amp;lt; 512) { &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Nedd" LastActivityDate="2016-04-01T12:33:40.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22582" PostTypeId="1" AcceptedAnswerId="22583" CreationDate="2016-04-01T18:34:54.293" Score="1" ViewCount="291" Body="&lt;p&gt;My &lt;a href=&quot;https://learn.adafruit.com/introducing-trinket?view=all&quot; rel=&quot;nofollow&quot;&gt;Adafruit 5V Trinket&lt;/a&gt; works fine when powered via USB connected to my computer (and the power going in to the Trinket is 5V), but if I use a 9V wall adapter with a microUSB adapter, it just powers on but doesn't seem to actually run the program on the Trinket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I &lt;em&gt;over&lt;/em&gt; powering the Trinket and sending too much voltage to everything? If that's the case, is there some way to decrease the voltage?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-01T19:54:22.310" Title="Trinket works with USB but not with wall adapter" Tags="|voltage-level|adafruit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22583" PostTypeId="2" ParentId="22582" CreationDate="2016-04-01T19:31:07.590" Score="0" Body="&lt;p&gt;Yes, you are probably over-powering the trinket. The trinket expects 5V on the USB connector. However, it has an voltage regulator on board that can take up to 16V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The BAT pin is connected to the voltage regulator and can take anywhere from 5.5V to 16V.&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2016-04-01T19:31:07.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22584" PostTypeId="1" AcceptedAnswerId="22590" CreationDate="2016-04-01T19:37:09.403" Score="1" ViewCount="73" Body="&lt;p&gt;This is the outline of my project:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;interpret environment data (sensor, motor, etc..).&lt;/li&gt;&#xA;&lt;li&gt;Modify this data into a more usable form,&lt;/li&gt;&#xA;&lt;li&gt;send it back to the same motor for further operation from modified data.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;As an example (this is not the project, but just an example to make sure I am being clear).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A motor moves a conveyor belt with various size flasks on it, some large other small. Depending on the reading of the position of the motor (from encoder) another process (filling the flasks) will take place.  If the first motor encoder data indicated the flask was small then the amount of liquid poured will be small. If large, the amount of liquid dispensed will be large.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More generally, read the location of an item based on motor encoder feedback.  Modify this data. Send this modified data back to a different motor so that it does something specifically as a function of the first motor encoder data.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to send the original encoder feedback to a file, manually massage it and paste it into an Arduino script, compile and have everything work great. I just want to remove the manual steps (cut &amp;amp; paste) and data massaging (I'm looking to an Arduino program to do that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To further complicate things, I want this process to be part of a distributable package that does not require further compiling. Reading from a sim card is fine.  Also, I am not too price sensitive as the Arduino is a small portion of the total cost of the final product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope someone can give me some insight or pathway to a solution.&#xA;All the very best, John.&lt;/p&gt;&#xA;" OwnerUserId="17015" LastEditorUserId="19515" LastEditDate="2016-04-01T21:08:51.347" LastActivityDate="2016-04-01T21:41:39.977" Title="Reading sensor data, massaging it and performing operation based on transformed data" Tags="|datalogging|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22585" PostTypeId="1" CreationDate="2016-04-01T20:13:00.133" Score="2" ViewCount="394" Body="&lt;p&gt;I own a UDOO Quad board which features two CPUs (SAM3X8E like Arduino Due and a ARM Cortex-A9) connected with an internal OTG USB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying literally for months to use the USB Host Shield Library (&lt;a href=&quot;https://github.com/felis/USB_Host_Shield_2.0/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/felis/USB_Host_Shield_2.0/&lt;/a&gt;) in order to make the Due act as a USB host to the other CPU (which runs Android). The Due runs well a piece of code collecting some data every X milliseconds within a built-in timer's ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to achieve is to send this data collected by the ISR to the other CPU via the USB connection of the two; but there seems to be an issue with the Usb.Task() call. This Usb.Task() needs to be executed from within the Loop() but it seems to need much more time than the timer's frequency. So eventually it is never executed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note that all of the above work when the interrupt is not involved; Usb.Task() works perfectly from the Loop() (data to/from the other CPU can be both sent and received). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bits from the code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void readPlantStatus() {&#xA;  if (analogRead(E2_STATUS)*(3.3/1023.0) &amp;gt; 2.0) e2_reached = true;&#xA;  else e2_reached = false;&#xA;  if (analogRead(F2_STATUS)*(3.3/1023.0) &amp;gt; 2.0) f2_reached = true;&#xA;  else f2_reached = false;&#xA;  if (analogRead(T2_STATUS)*(3.3/1023.0) &amp;gt; 2.0) t2_reached = true;   &#xA;  else t2_reached = false;&#xA;  if (analogRead(E3_STATUS)*(3.3/1023.0) &amp;gt; 2.0) e3_reached = true;&#xA;  else e3_reached = false;&#xA;  if (analogRead(F3_STATUS)*(3.3/1023.0) &amp;gt; 2.0) f3_reached = true;   &#xA;  else f3_reached = false;&#xA;}&#xA;&#xA;void TC3_Handler() {&#xA;  TC_GetStatus(TC1, 0);&#xA;  readPlantStatus();  &#xA;  writeToController();&#xA;  readFromController();    &#xA;  controlPlant();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Usb.Task();   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="19803" LastEditorUserId="37523" LastEditDate="2019-07-15T22:41:11.403" LastActivityDate="2019-07-15T22:41:11.403" Title="Due as USB Host timing issues" Tags="|arduino-due|usb|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22586" PostTypeId="1" AcceptedAnswerId="22588" CreationDate="2016-04-01T20:21:23.167" Score="0" ViewCount="1573" Body="&lt;p&gt;I have &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B007ZK4I10&quot; rel=&quot;nofollow noreferrer&quot;&gt;this 8x8 LED RGB matrix&lt;/a&gt;. How do I get it connected to an Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It came with no other wires/modules/connectors and has a veritable crap-ton of pins to connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/a0aRi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/a0aRi.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2019-03-07T01:00:09.587" Title="How do I connect an 8x8 LED RGB matrix to an Uno?" Tags="|arduino-uno|led|pins|rgb-led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22587" PostTypeId="1" CreationDate="2016-04-01T20:30:59.327" Score="0" ViewCount="476" Body="&lt;p&gt;I've programmed my Arduino Ethernet to receive data from a Skytraq Venus GPS receiver and separate it using TinyGPS, then store it on an SD card. With the SD card inserted, everything else except the time is totally wrong. Once I remove the SD card and reset, the longitude and latitude are still wrong but everything else is correct. I've tried supplying more power, replacing the receiver, antenna, the arduino itself, even switched the serial ports I use but I can't seem to find a solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;a href=&quot;https://github.com/mikalhart/TinyGPS&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; for the TinyGPS library and a &lt;a href=&quot;http://arduiniana.org/libraries/newsoftserial/&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; for the NewSoftSerial library. And for the schematics, I haven't drawn any yet but I'm using the Arduino Ethernet's SD port as my SD shield. My Skytraq GPS receiver's RX pin is connected to pin 2 on the arduino ethernet and the TX pin is connected to pin 3 on the ethernet. (Ethernet TX/RX has been set to pin 3 and 2 respectively.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the Sparkfun Venus GPS with SMA connector from sparkfun.com. I would post the link but it says I need at least 10 reputation to post more than two links. Serial signals at 3.3V and GPS module is a 3.3V module. I use the same sketch with and without the SD Card. SD.begin is called just once and Serial.begin is also called once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; //NewSoftwareSerial Library&#xA;#include &amp;lt;TinyGPS.h&amp;gt;        //TinyGPS Library&#xA;#include &amp;lt;SPI.h&amp;gt;            //This Library is used by the SD library.&#xA;                            //Must be defined before SD library to prevent errors.&#xA;#include &amp;lt;SD.h&amp;gt;             //SD Card Library&#xA;&#xA;//NB: To avoid SD Card Errors, use an SD Card whose size is at most 2GB&#xA;//and use FAT16 format. Arduino has problems with FAT32 and cards&amp;gt;2GB.&#xA;&#xA;#define RXPIN 2&#xA;#define TXPIN 3&#xA;&#xA;const int chipSelect = 4; //This selects the SD card port for read/write&#xA;&#xA;#define GPSBAUD 9600&#xA;&#xA;File logs; //Used to write to SD card later&#xA;&#xA;TinyGPS gps;&#xA;&#xA;//Initialize the Software Serial to recognize&#xA;//our UART pins (Read(RX) and Write(TX))&#xA;SoftwareSerial read_gps(RXPIN, TXPIN); &#xA;&#xA;void getdata(TinyGPS &amp;amp;gps);&#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);  //Start the serial port&#xA;  read_gps.begin(GPSBAUD);  //Start reading from the gps&#xA;  &#xA;  pinMode(chipSelect, OUTPUT); //Make pin 4 an output pin&#xA;  pinMode(10, OUTPUT);  //Pin 10 must always be set to output to avoid errors&#xA;  digitalWrite(10, HIGH); //Pin 10 must always be high to prevent errors.&#xA;  &#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;Awaiting Lock&quot;);&#xA;  Serial.println(&quot;&quot;);&#xA;  &#xA;  //Initialize the SD Card&#xA;  SD.begin();&#xA;  Serial.println(&quot;Initializing SD Card. Please Wait.&quot;);&#xA;  if(!SD.begin(4)){//If card not available or card not recognized&#xA;    Serial.println(&quot;Failed.&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;Card Initialized&quot;);&#xA;&#xA;}&#xA;&#xA;&#xA;//the loop function is used to read the data from the gps,&#xA;//check for valid data and then separate the data based on our specs.&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  while(read_gps.available()){//as data is received from the gps&#xA;    int c = read_gps.read();&#xA;    if(gps.encode(c)){//check if new valid data available&#xA;      getgps(gps); //read the valid gps data and process&#xA;    }&#xA;  }&#xA;  &#xA;  &#xA;  &#xA;}&#xA;&#xA;void getgps(TinyGPS &amp;amp;gps)&#xA;{&#xA;  float latitude, longitude;&#xA;  &#xA;  gps.f_get_position(&amp;amp;latitude, &amp;amp;longitude); //Feature of tinygps.&#xA;                                             //Gets the latitude and longitude&#xA;  &#xA;  Serial.print(&quot;Latitude: &quot;); Serial.print(latitude);&#xA;  Serial.print(&quot;\nLongitude: &quot;); Serial.print(longitude);&#xA;  &#xA;  int yr;&#xA;  byte mnth, dy, hr, minu, sec, hundredths;&#xA;  gps.crack_datetime(&amp;amp;yr, &amp;amp;mnth, &amp;amp;dy, &amp;amp;hr, &amp;amp;minu, &amp;amp;sec, &amp;amp;hundredths); //Gets the date and time and separates them&#xA;                                                                      //into individual components.&#xA;  &#xA;  Serial.print(&quot;\nDate: &quot;); Serial.print(mnth, DEC); Serial.print(&quot;/&quot;);&#xA;  Serial.print(dy, DEC); Serial.print(&quot;/&quot;); Serial.print(yr);&#xA;  Serial.print(&quot;   \nTime: &quot;); Serial.print(hr, DEC); Serial.print(&quot;:&quot;);&#xA;  Serial.print(minu, DEC); Serial.print(&quot;:&quot;); Serial.print(sec, DEC);&#xA;  Serial.print(&quot;.&quot;); Serial.println(hundredths, DEC);&#xA;  &#xA;  &#xA;  &#xA;  Serial.print(&quot;Altitude(metres): &quot;); Serial.println(gps.f_altitude());&#xA;  &#xA;  Serial.print(&quot;Speed(kmph): &quot;); Serial.println(gps.f_speed_kmph());&#xA;  Serial.println();&#xA;  &#xA;  logs = SD.open(&quot;datalogs.csv&quot;, FILE_WRITE);  //open the datalog file on the sd card. If it doesn't exist on the card, create it.&#xA;  &#xA;  if(logs){//Start writing data to SD Card&#xA;    Serial.print(&quot;Writing to datalogs...&quot;);&#xA;    logs.println(&quot;\nLatitude: &quot;); logs.print(latitude);&#xA;    logs.print(&quot;\nLongitude: &quot;); logs.print(longitude);&#xA;    logs.print(&quot;\nDate: &quot;); logs.print(mnth, DEC); logs.print(&quot;/&quot;);&#xA;    logs.print(dy, DEC); logs.print(&quot;/&quot;); logs.print(yr);&#xA;    logs.print(&quot;   \nTime: &quot;); logs.print(hr, DEC); logs.print(&quot;:&quot;);&#xA;    logs.print(minu, DEC); logs.print(&quot;:&quot;); logs.print(sec, DEC);&#xA;    logs.print(&quot;.&quot;); logs.println(hundredths, DEC);&#xA;    logs.print(&quot;Altitude(metres): &quot;); logs.println(gps.f_altitude());&#xA;  &#xA;    logs.print(&quot;Speed(kmph): &quot;); logs.println(gps.f_speed_kmph());&#xA;    logs.print(&quot;\n&quot;);&#xA;    logs.println();&#xA;    &#xA;    logs.close(); //close the file&#xA;    Serial.println(&quot;done.&quot;);&#xA;    Serial.println(&quot;\n&quot;);&#xA;  }&#xA;  else{&#xA;    Serial.println(&quot;Error opening file.&quot;);&#xA;  }&#xA;    &#xA;    &#xA;  &#xA;  unsigned long chars;&#xA;  unsigned short sentences, failed_checksum;&#xA;  gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed_checksum);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19806" LastEditorUserId="19806" LastEditDate="2016-04-03T19:39:27.563" LastActivityDate="2021-12-18T03:02:10.237" Title="GPS Transmits False Data with SD card in; True data with SD card out" Tags="|arduino-uno|gps|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22588" PostTypeId="2" ParentId="22586" CreationDate="2016-04-01T20:32:45.243" Score="1" Body="&lt;p&gt;Because you have, unfortunately, decided to buy a product without a datasheet (and the product description can't even decide if it's common anode or common cathode!), you'll have to find a product which is similar that &lt;em&gt;has&lt;/em&gt; a datasheet, and determine by experimentation if the pinout matches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, &lt;a href=&quot;https://www.sparkfun.com/products/retired/683&quot; rel=&quot;nofollow&quot;&gt;this Sparkfun LED matrix&lt;/a&gt; looks similar. Take a look at the datasheet for an internal schematic and manually verify the pinout. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you know the pinout, you can begin to figure out how to drive it. There are many ways to drive large numbers of LEDs, one of the simplest of which is a bunch of shift registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Getting yourself a couple of 595 SRs and playing with the matrix (hint: try and get a single colour working first, then add the others) would be a good place to start. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, the display description says that it is compatible with &quot;Arduino RGB LED Matrix Driver Shield&quot;. That may or may not be true, but looking at a schematic of that board would give you insight into how to drive the matrix. I believe that board uses a DM163 8x3 CC LED driver chip, which seems to be perfectly suited to drive the matrix, but buying and wiring that chip up may be non-trivial. &lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-04-01T20:32:45.243" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22589" PostTypeId="2" ParentId="8307" CreationDate="2016-04-01T20:59:52.087" Score="0" Body="&lt;p&gt;After dealing with the problem for several hours I unexpectedly solve the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The HC-06's LED keep blinking after I entered the &quot;1234&quot; code. In my case (I'm using Windows 10), the HC-06 status changed to &quot;connected&quot; for few seconds and then changed to &quot;Paired&quot;. Once I opened the correct COM port to receive data from the HC-06 to my PC computer, the LED changed to solid ON. Then I was able to catch data from my Arduino UNO. As soon as I closed the COM port in my PC (I used CoolTerm), the LED changed to blinking back again. The COM port I used to receive the data was the one indicated with direction &quot;Outgoing&quot; in the PC's Bluetooth settings. So, I was expecting the HC-06 to behave as my Bluetooth speakers or my Bluetooth headphones: Always connected. I was wrong and it cost me several hours of testing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my firsts tests I focused opening the COM port with direction &quot;Incoming&quot;. Nothing happened here and I lost a lot of time. I tested my wiring between the arduino and the HT-06 module by changing the device name from &quot;HC-06&quot; to &quot;ArduinoBT01&quot; and it worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the sketch I used to receive data form the Arduino via Bluetooth:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HKL3M.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HKL3M.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the CoolTerm's window capture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XOD8q.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XOD8q.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mysteriously, the CoolTerm speed setting is 14400bps but the speed in the device manager for COM34 is 9600bps. After triying opening many times the COM34 port with 9600bps I got this error in CoolTerm:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;An error occurred while attempting to open the port&quot;.&#xA;&quot;1168: Error 1168&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it only works with 14400 bps. Crazy!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry for bugs in my English.&lt;/p&gt;&#xA;" OwnerUserId="19807" LastEditorUserId="19807" LastEditDate="2016-04-01T21:47:29.060" LastActivityDate="2016-04-01T21:47:29.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22590" PostTypeId="2" ParentId="22584" CreationDate="2016-04-01T21:41:39.977" Score="1" Body="&lt;p&gt;Here's a back-of-envelope sketch, off the top of my head:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conveyor belt driven by stepper motor, controlled by the Arduino.  Each step is a known distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bottles are either of exactly two heights, at random.  Two &lt;a href=&quot;https://learn.adafruit.com/ir-breakbeam-sensors/overview&quot; rel=&quot;nofollow&quot;&gt;beam break sensors&lt;/a&gt;, one to determine where a bottle starts and one to determine whether it's tall or short.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some sort of valve to control the water flow - I presume you have some idea how this can be controlled.  I don't, but washing machines have electrically-controlled valves so something broadly along those lines.  Controllable on/off by the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Software on the Arduino steps the motor until it sees the start of a bottle (first beam broken).  Then uses second beam to determine whether the bottle is large or small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino switches on the water valve (outlet positioned exactly right to be above the bottle) for either 2s or 4s accoriding to bottle size, then off again.   (Water pressure and flow rate regulated independently, perhaps fed from a header tank).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino steps motor more until it sees another bottle.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;No string concatenation in there, nor sorting of lists or need for a Raspberry Pi.  It's not clear to me why you'd need those things for the application described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not aware that you can program the Arduino in Python unfortunately.  Someone may know better.  C isn't hard though - get an Arduino and some LEDs or whatever, go through some tutorials, you'll get the hang of it.&lt;/p&gt;&#xA;" OwnerUserId="16085" LastActivityDate="2016-04-01T21:41:39.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22591" PostTypeId="1" AcceptedAnswerId="22600" CreationDate="2016-04-01T22:05:14.690" Score="2" ViewCount="2039" Body="&lt;p&gt;I recently obtained a Controllino Mini to be used in a small industrial project. While checking it out I also wanted to test the built-in RTC capabilities. In doing so I toyed around with the available commands from the supplied &lt;a href=&quot;https://github.com/Controllino/ControllinoLibrary&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt;. After uploading another sketch it seems I have bricked the Controllino, since I cannot upload anything else : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding avrdude:&#xA;  stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and the reset LED is permanently lid. When looking at the &lt;a href=&quot;http://controllino.cc/wp-content/uploads/2015/10/CONTROLLINO-MINI-PINOUT-02-10-15.jpg&quot; rel=&quot;nofollow&quot;&gt;pinout&lt;/a&gt; diagram of the Controllino Mini I saw that there was a small remark  near the top stating &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not proper handling of the RTC/INT output can cause permanent&#xA;  controllino reset , so I guess I somehow reached that state.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since I am pretty new to the whole Arduino / Microcontroller scene I don't really know where to go from here. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it a viable idea to try and burn a new bootloader ? &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a simpler way to reset the state of the device?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What did I even do wrong ?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Christian&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the sketch that got me into this mess:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Controllino.h&amp;gt;&#xA;&#xA;&#xA;unsigned char day, weekday, month, year, hour, minute, sec;&#xA;#define analogInputPin A0&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;Serial.begin(9600);&#xA;pinMode(analogInputPin, INPUT);&#xA;Controllino_RTC_init(1);&#xA;Serial.print(&quot;Initalized RTC: &quot;);&#xA;Controllino_SetTimeDate(1,6,4,2016,15,14,10);&#xA;}&#xA;&#xA;void loop() {&#xA; Controllino_ReadTimeDate(&amp;amp;day,&amp;amp;weekday,&amp;amp;month,&amp;amp;year,&amp;amp;hour,&amp;amp;minute,&amp;amp;sec);&#xA;  float voltage = 15*(analogRead(analogInputPin)/1023.0);&#xA;  Serial.print(hour);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(minute);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(sec);&#xA;  Serial.print(&quot; : &quot;);&#xA;&#xA;  Serial.println(voltage);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19810" LastEditorUserId="19810" LastEditDate="2016-04-01T22:18:36.093" LastActivityDate="2016-04-02T09:36:14.453" Title="Did I Brick my Controllino?" Tags="|atmega328|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22592" PostTypeId="2" ParentId="22591" CreationDate="2016-04-01T23:03:40.137" Score="4" Body="&lt;p&gt;It certainly looks like the INT pin of the RTC can kill the whole unit. Bit of a FUBAR on their part I would say. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it a viable idea to try and burn a new bootloader ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the problem is that INT pin then you won't be able to replace the bootloader, and even if you did it wouldn't fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there a simpler way to reset the state of the device?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It looks like you will have to make a hardware modification - cut the connection between /INT and /RESET on the board - if you can identify which track that might be - or use a soldering iron to heat and lift the /INT pin of the RTC chip, which might be easier, depending on what the chip is (they are amazingly short on information).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What did I even do wrong ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably nothing serious - it's the design that is at fault. Anything that has the potential to completely cripple a system like that without even trying is just idiotic.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-01T23:03:40.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22593" PostTypeId="1" AcceptedAnswerId="22594" CreationDate="2016-04-02T02:22:13.693" Score="0" ViewCount="80" Body="&lt;p&gt;I want to detect if a button has been pressed, but what I don't want is for it to keep returning the &quot;pressed&quot; state more than once within a second or two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  passButtonState = digitalRead(passButton);&#xA;&#xA;  if (passButtonState == LOW) {&#xA;    Serial.println(&quot;PASSED!&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Would spit out something like this with a single quick press of the button:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;PASSED!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But what I want is for a single button press to just return &lt;code&gt;PASSED!&lt;/code&gt; once for that single button press.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="19515" LastEditDate="2016-04-02T02:28:54.243" LastActivityDate="2022-08-14T17:07:38.417" Title="Only return button state once in X amount of time?" Tags="|arduino-uno|c++|button|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22594" PostTypeId="2" ParentId="22593" CreationDate="2016-04-02T02:25:41.870" Score="0" Body="&lt;p&gt;To avoid this problem you can use a boolean variable as a flag that permit to enter inside the &lt;code&gt;if&lt;/code&gt; only once.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool flag = true;&#xA;&#xA;void loop() {&#xA;  passButtonState = digitalRead(passButton);&#xA;&#xA;  if (passButtonState == LOW &amp;amp;&amp;amp; flag) {&#xA;    Serial.println(&quot;PASSED!&quot;);&#xA;    flag = false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19515" LastActivityDate="2016-04-02T02:25:41.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22595" PostTypeId="2" ParentId="22593" CreationDate="2016-04-02T03:45:13.647" Score="-1" Body="&lt;p&gt;You can add a delay.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  passButtonState = digitalRead(passButton);&#xA;&#xA;  if (passButtonState == LOW) {&#xA;    Serial.println(&quot;PASSED!&quot;);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19692" LastActivityDate="2016-04-02T03:45:13.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22596" PostTypeId="1" CreationDate="2016-04-02T05:07:43.447" Score="2" ViewCount="659" Body="&lt;p&gt;Can anyone explain to me why my output ip is: 15.16.17.18? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I configured my addresses as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino :&#xA;gateway 192.168.1.1&#xA;ipaddress 192.168.1.8&#xA;subnet 255.255.255.0&#xA;&#xA;My local network:&#xA;gateway 192.168.1.1&#xA;&#xA;ipaddress 192.168.1.3&#xA;&#xA;subnet 255.255.255.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I print it, it shows&#xA;15.16.17.18&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// network configuration. dns server, gateway and subnet are optional.&#xA;&#xA;// the media access control (ethernet hardware) address for the shield:&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  &#xA;&#xA;// the dns server ip&#xA;IPAddress dnServer(192, 168, 1, 1);&#xA;// the router's gateway address:&#xA;IPAddress gateway(192, 168, 1, 1);&#xA;// the subnet:&#xA;IPAddress subnet(255, 255, 255, 0);&#xA;&#xA;//the IP address is dependent on your network&#xA;IPAddress ip(192, 168, 1, 8);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  // initialize the ethernet device&#xA;  Ethernet.begin(mac, ip, dnServer, gateway, subnet);&#xA;  //print out the IP address&#xA;  Serial.print(&quot;IP = &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My output is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IP = 15.16.17.18&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help, thank you.&lt;/p&gt;&#xA;" OwnerUserId="19813" LastEditorUserId="19515" LastEditDate="2016-04-04T03:00:31.190" LastActivityDate="2016-04-04T03:00:31.190" Title="Problem related to Arduino ip address" Tags="|arduino-uno|ethernet|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22597" PostTypeId="1" CreationDate="2016-04-02T06:13:23.627" Score="3" ViewCount="908" Body="&lt;p&gt;I have been working on a Security System project wherein I should get an email if the PIR sensor detects any human presence.&#xA;I have used an Arduino UNO, ESP8266-01 WiFi module and a PIR sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power supply:&#xA;Arduino is powered through the USB connection of desktop and ESP8266-01 is powered through the 3.3V pin of Arduino UNO and I have not faced any problem with that 3.3V connection of Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The connection between Arduino UNO and ESP8266-01 are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO-ESP8266-01&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rx  -   Rx&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tx  -   Tx&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3.3V - CH_PD &amp;amp; VCC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND - GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPIO0 and GPIO2 left open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After successfully uploading the 'BareMinimum' code as found in 'File&gt;Examples&gt;Basics' of Arduino IDE, the ESP8266 is able to communicate correctly i.e. connecting to a wifi network or serving as an access point via &lt;/p&gt;&#xA;&#xA;&lt;p&gt;SERIAL MONITOR.The ESP8266-01 displays '0018000902-AI03' as the firware version when I type AT+GMR in the serial monitor of Arduino IDE v1.6.8&#xA;Then I created an account on &lt;a href=&quot;https://temboo.com/&quot; rel=&quot;noreferrer&quot;&gt;https://temboo.com/&lt;/a&gt; and used the 'SendEmail' choreo as found under 'Google&gt;Gmail&gt;SendEmail'.&#xA;I selected the 'Arduino' option in one tab and 'Arduino Wifi' option in another tab.I then entered the required details including the 'App specific password' and I was able to successfully run the choreo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to successfully upload the code  to my Arduino UNO that was generated by Temboo.&#xA;But after uploading the code, when I'm opening my SERIAL MONITOR window from Arduino IDE a message &quot;Shield:FAIL&quot; is being displayed.&#xA;I'm not able to communicate with the ESP8266 any further.&#xA;But if I upload the BareMinimum code again, then ESP8266 works normally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After connecting Rx-Tx and Tx-Rx of Arduino UNO-ESP8266-01, the serial monitor still displays 'Shield:FAIL'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a newbie and dont know much about the programming of Arduino though some basics of C are clear.Please if anyone can help me with this, I would be very grateful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The code is as below:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;#include &amp;lt;Temboo.h&amp;gt;&#xA;#include &quot;TembooAccount.h&quot; // Contains Temboo account information&#xA;&#xA;WiFiClient client;&#xA;&#xA;// The number of times to trigger the action if the condition is met&#xA;// We limit this so you won't use all of your Temboo calls while testing&#xA;int maxCalls = 10;&#xA;&#xA;// The number of times this Choreo has been run so far in this sketch&#xA;int calls = 0;&#xA;&#xA;int inputPin = A0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  // For debugging, wait until the serial console is connected&#xA;  delay(4000);&#xA;  while(!Serial);&#xA;&#xA;  int wifiStatus = WL_IDLE_STATUS;&#xA;&#xA;  // Determine if the WiFi Shield is present&#xA;  Serial.print(&quot;\n\nShield:&quot;);&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(&quot;FAIL&quot;);&#xA;&#xA;    // If there's no WiFi shield, stop here&#xA;    while(true);&#xA;  }&#xA;&#xA;  Serial.println(&quot;OK&quot;);&#xA;&#xA;  // Try to connect to the local WiFi network&#xA;  while(wifiStatus != WL_CONNECTED) {&#xA;    Serial.print(&quot;WiFi:&quot;);&#xA;    wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);&#xA;&#xA;    if (wifiStatus == WL_CONNECTED) {&#xA;      Serial.println(&quot;OK&quot;);&#xA;    } else {&#xA;      Serial.println(&quot;FAIL&quot;);&#xA;    }&#xA;    delay(5000);&#xA;  }&#xA;&#xA;  // Initialize pins&#xA;  pinMode(inputPin, INPUT);&#xA;&#xA;  Serial.println(&quot;Setup complete.\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorValue = analogRead(inputPin);&#xA;  Serial.println(&quot;Sensor: &quot; + String(sensorValue));&#xA;&#xA;  if (sensorValue &amp;gt;= 2) {&#xA;    if (calls &amp;lt; maxCalls) {&#xA;      Serial.println(&quot;\nTriggered! Calling SendEmail Choreo...&quot;);&#xA;      runSendEmail(sensorValue);&#xA;      calls++;&#xA;    } else {&#xA;      Serial.println(&quot;\nTriggered! Skipping to save Temboo calls. Adjust      maxCalls as required.&quot;);&#xA;    }&#xA;  }&#xA;  delay(250);&#xA;}&#xA;&#xA;void runSendEmail(int sensorValue) {&#xA;  TembooChoreo SendEmailChoreo(client);&#xA;&#xA;  // Set Temboo account credentials&#xA;  SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);&#xA;  SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);&#xA;  SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);&#xA;&#xA;  // Set profile to use for execution&#xA;  SendEmailChoreo.setProfile(&quot;JigarFaria&quot;);&#xA;  // Identify the Choreo to run&#xA;  SendEmailChoreo.setChoreo(&quot;/Library/Google/Gmail/SendEmail&quot;);&#xA;&#xA;  // Run the Choreo&#xA;  unsigned int returnCode = SendEmailChoreo.run();&#xA;&#xA;  // Read and print the error message&#xA;  while (SendEmailChoreo.available()) {&#xA;    char c = SendEmailChoreo.read();&#xA;    Serial.print(c);&#xA;  }&#xA;Serial.println();&#xA;  SendEmailChoreo.close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19814" LastActivityDate="2018-04-15T23:19:37.977" Title="Shield:FAIL problem in ESP8266-01 with Arduino UNO" Tags="|arduino-uno|sensors|wifi|esp8266|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="22599" PostTypeId="1" CreationDate="2016-04-02T07:36:37.673" Score="2" ViewCount="151" Body="&lt;p&gt;Considering the GSR is the inverse of the Resistance, if I know the resistance and how much it increases for every celsius degree, the game would be done.&#xA;Here's how my code looks like at the moment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int GSR=A0;&#xA;int threshold=0;&#xA;int sensorValue;&#xA;const long interval = 1000; &#xA;unsigned long T = millis();&#xA;&#xA;&#xA;void setup(){&#xA;  long sum=0;&#xA;  Serial.begin(115200);&#xA;  delay(1000);&#xA;&#xA;  for(int i=0;i&amp;lt;500;i++)&#xA;  {&#xA;  sensorValue=analogRead(GSR);&#xA;  sum += sensorValue;&#xA;  delay(5);&#xA;  }&#xA;  threshold = sum/500;&#xA;   Serial.print(&quot;threshold =&quot;);&#xA;   Serial.println(threshold);&#xA;  }&#xA;&#xA;void loop(){&#xA;&#xA;&#xA;  if( millis() - T &amp;gt;= 250)  {&#xA;   int temp;&#xA;  sensorValue=analogRead(GSR);&#xA;  Serial.println(sensorValue);&#xA;  temp = threshold - sensorValue;&#xA;  T = millis();&#xA;&#xA;  }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The page of the sensor:&#xA;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15699" LastActivityDate="2016-04-02T16:29:28.857" Title="How can I read also the temperature with this GSR sensor?" Tags="|arduino-uno|arduino-nano|temperature-sensor|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22600" PostTypeId="2" ParentId="22591" CreationDate="2016-04-02T08:07:04.510" Score="1" Body="&lt;p&gt;I just received an answer from the official team which should work, I'll leave it here for further reference:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Open the device and disconnect (remove) connection board for approx. 30 seconds from the control board – RTC is disconnected from power (gold cap disconnected) and because of that there is reset of all RTC registers.&lt;/li&gt;&#xA;  &lt;li&gt;Plug the connection board back in to the control board. Now we need to rewrite the SW inside the Controllino which caused wrong RTC setting.&lt;/li&gt;&#xA;  &lt;li&gt;Open the Controllino example RTC sketch in Arduino IDE and prepare it to upload (function Controllino_RTC_init(0); shall reset all registers inside the RTC).&lt;/li&gt;&#xA;  &lt;li&gt;Pres and hold reset button on the Controllino device.&lt;/li&gt;&#xA;  &lt;li&gt;Connect the USB Cable (still hold the reset button, SW inside the Controllino doesn’t start)&lt;/li&gt;&#xA;  &lt;li&gt;Click for upload the sketch in Aruduino IDE and wait for „uploading“ message on debug line, than immediately release the reset button and uploading shall be finished (=&gt; hold the reset button during the compiling phase)&lt;/li&gt;&#xA;  &lt;li&gt;If not successful, repeat the procedure&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19810" LastEditorUserId="4143" LastEditDate="2016-04-02T09:36:14.453" LastActivityDate="2016-04-02T09:36:14.453" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22601" PostTypeId="1" AcceptedAnswerId="22621" CreationDate="2016-04-02T09:57:13.050" Score="0" ViewCount="84" Body="&lt;p&gt;According to &lt;a href=&quot;http://www.education.rec.ri.cmu.edu/products/teaching_robotc_vex/sensing/operator_assist/docs/quick_tap.pdf&quot; rel=&quot;nofollow&quot;&gt;Official documentation of the Vex Bumper&lt;/a&gt;, it states that the bumpers will cause:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the robot sometimes [counts] a press twice. This issue is also caused by the robot counting too fast and as the limit switch is released, a second press is registered by the robot.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The documentation suggests this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;task main() {&#xA;    while(true) {&#xA;         string presses = buttonPresses;&#xA;         if(presses != last) {&#xA;             writeDebugStreamLine(presses);&#xA;         }&#xA;         last = presses;&#xA;&#xA;         if(SensorValue(bump) == 1) {&#xA;             wait1Msec(5);&#xA;             while(SensorValue(bump) == 1){}&#xA;             buttonPresses++;&#xA;         }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However, if you are like me, this didn't work at all, multiple button presses were registered from holding down the button for a moment and releasing it.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="17309" LastEditorUserId="17309" LastEditDate="2016-04-20T00:30:42.573" LastActivityDate="2016-04-20T00:30:42.573" Title="Stop multiple presses in vex bumper (Unexpected bumper output)" Tags="|c|" AnswerCount="2" CommentCount="0" ClosedDate="2016-04-16T09:50:32.627" ContentLicense="CC BY-SA 3.0" />
  <row Id="22602" PostTypeId="2" ParentId="22601" CreationDate="2016-04-02T10:00:58.460" Score="0" Body="&lt;p&gt;Because this problem was so infuriating and strange, I managed to do a workaround which the program refused to take a sudden addition to button counts after taking a first one. This enabled me to use the button without multiple extra counts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string last;&#xA;float buttonPresses = 0;&#xA;float time = time1[T1];&#xA;bool isFirstTime = true;&#xA;&#xA;task main()&#xA;{&#xA;    ClearTimer(T1);&#xA;    clearDebugStream();&#xA;    while(SensorValue(go) != 1) {&#xA;&#xA;        string presses = buttonPresses;&#xA;        if(presses != last) {&#xA;            writeDebugStreamLine(presses);&#xA;        }&#xA;        last = presses;&#xA;&#xA;        if(SensorValue(bump) == 1 &amp;amp;&amp;amp; buttonPresses &amp;lt; 6) {&#xA;            if(isFirstTime || time1[T1] - time &amp;gt; 50) {&#xA;                isFirstTime = false;&#xA;                wait1Msec(15);&#xA;                while(SensorValue(bump) == 1){time = time1[T1];}&#xA;                buttonPresses++;&#xA;            }&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want extra probability against multiple extra &quot;presses&quot; you can widen the interval of tolerance (in this case the 50 value) to something larger, but it makes it less accurate at registering quick taps.&lt;/p&gt;&#xA;" OwnerUserId="17309" LastActivityDate="2016-04-02T10:00:58.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22603" PostTypeId="1" CreationDate="2016-04-02T10:26:38.147" Score="2" ViewCount="319" Body="&lt;p&gt;I'm following the tutorial in &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WebClientRepeating&quot; rel=&quot;nofollow noreferrer&quot;&gt;WebClientRepeating&lt;/a&gt; and it says that &quot;The content of the page is viewable through your Arduino's serial window.&quot; However the output in my Serial window is just saying &quot;Connecting...&quot; repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1c93O.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1c93O.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*&#xA;  Repeating Web client&#xA;&#xA; This sketch connects to a a web server and makes a request&#xA; using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or&#xA; the Adafruit Ethernet shield, either one will work, as long as it's got&#xA; a Wiznet Ethernet module on board.&#xA;&#xA; This example uses DNS, by assigning the Ethernet client with a MAC address,&#xA; IP address, and DNS address.&#xA;&#xA; Circuit:&#xA; * Ethernet shield attached to pins 10, 11, 12, 13&#xA;&#xA; created 19 Apr 2012&#xA; by Tom Igoe&#xA; modified 21 Jan 2014&#xA; by Federico Vanzati&#xA;&#xA; http://www.arduino.cc/en/Tutorial/WebClientRepeating&#xA; This code is in the public domain.&#xA;&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// assign a MAC address for the ethernet controller.&#xA;// fill in your address here:&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;// fill in an available IP address on your network here,&#xA;// for manual configuration:&#xA;IPAddress ip(10, 1, 1, 4);&#xA;&#xA;// fill in your Domain Name Server address here:&#xA;IPAddress myDns(10, 1, 1, 1);&#xA;&#xA;// initialize the library instance:&#xA;EthernetClient client;&#xA;&#xA;char server[] = &quot;www.arduino.cc&quot;;&#xA;//IPAddress server(64,131,82,241);&#xA;&#xA;unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds&#xA;const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds&#xA;// the &quot;L&quot; is needed to use long type numbers&#xA;&#xA;void setup() {&#xA;  // start serial port:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  // give the ethernet module time to boot up:&#xA;  delay(1000);&#xA;  // start the Ethernet connection using a fixed IP address and DNS server:&#xA;  Ethernet.begin(mac, ip, myDns);&#xA;  // print the Ethernet board/shield's IP address:&#xA;  Serial.print(&quot;My IP address: &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;void loop() {&#xA;  // if there's incoming data from the net connection.&#xA;  // send it out the serial port.  This is for debugging&#xA;  // purposes only:&#xA;  if (client.available()) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;&#xA;  // if ten seconds have passed since your last connection,&#xA;  // then connect again and send data:&#xA;  if (millis() - lastConnectionTime &amp;gt; postingInterval) {&#xA;    httpRequest();&#xA;  }&#xA;&#xA;}&#xA;&#xA;// this method makes a HTTP connection to the server:&#xA;void httpRequest() {&#xA;  // close any connection before send a new request.&#xA;  // This will free the socket on the WiFi shield&#xA;  client.stop();&#xA;&#xA;  // if there's a successful connection:&#xA;  if (client.connect(server, 80)) {&#xA;    Serial.println(&quot;connecting...&quot;);&#xA;    // send the HTTP GET request:&#xA;    client.println(&quot;GET /latest.txt HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: www.arduino.cc&quot;);&#xA;    client.println(&quot;User-Agent: arduino-ethernet&quot;);&#xA;    client.println(&quot;Connection: close&quot;);&#xA;    client.println();&#xA;&#xA;    // note the time that the connection was made:&#xA;    lastConnectionTime = millis();&#xA;  } else {&#xA;    // if you couldn't make a connection:&#xA;    Serial.println(&quot;connection failed&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are my Mac's network settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7i2ry.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7i2ry.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5Iy7G.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5Iy7G.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's my understanding that I can assign an IP address to my Ethernet shield by just changing the last number of my computers IP address. Hence I changed 10.1.1.5 to 10.1.1.4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone see any obvious errors? This is not really my area of expertise :) &lt;/p&gt;&#xA;" OwnerUserId="19821" LastActivityDate="2016-04-02T10:26:38.147" Title="WebClientRepeating not printing response to Serial" Tags="|arduino-uno|ethernet|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22605" PostTypeId="1" AcceptedAnswerId="22750" CreationDate="2016-04-02T10:57:22.517" Score="0" ViewCount="416" Body="&lt;p&gt;My goal is to run a vibrating motor for &lt;strong&gt;specific&lt;/strong&gt; time intervals. I am using the &lt;code&gt;millis()&lt;/code&gt; function to successfully turn the motor on and off, but only if the &lt;code&gt;intervalOn = intervalOff&lt;/code&gt;. The problem comes when I try to change the intervals to turn the motor on for e.g. 120 ms, then turn off for 200 ms etc. My code seems to cause AVR restart and my motor sometimes stays running. First I thought this is caused by insufficient decouple capacitor (I have 100 uF one) but when running the &lt;code&gt;millis()&lt;/code&gt; code with one no-changing interval, it all works flawlessly...&#xA;Is there any other way to change the intervals?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Vibrating()&lt;/code&gt; function gets called from the &lt;code&gt;loop()&lt;/code&gt; whenever &lt;code&gt;vibrEnabled = true&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;unsigned long interval = 0; &#xA;unsigned long previousMillis = 0;&#xA;int last = 120;&#xA;int pause = 200;&#xA;&#xA;void Vibrating()&#xA;{   &#xA;unsigned long currentMillis = millis();     &#xA;static byte cyclesPassed = 0;   &#xA;&#xA;if((unsigned long)(currentMillis - previousMillis) &amp;gt;= interval)  &#xA;{&#xA;    PORTC ^= (1&amp;lt;&amp;lt;PC1);//toggle motor&#xA;&#xA;    if(interval != last) //this part causes the problem&#xA;        interval = last; //&#xA;    else                 //&#xA;        interval = pause;//&#xA;&#xA;    cyclesPassed++;&#xA;    if(cyclesPassed == 8)//motor is on 4x&#xA;    {&#xA;    cyclesPassed = 0;           &#xA;    vibrEnabled = false;    &#xA;    }   &#xA;&#xA;    previousMillis = millis();  &#xA; }          &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19820" LastEditorUserId="4131" LastEditDate="2016-04-05T08:40:51.083" LastActivityDate="2016-04-05T13:56:39.570" Title="Changing timing intervals with millis()" Tags="|timers|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22606" PostTypeId="1" CreationDate="2016-04-02T11:31:26.067" Score="4" ViewCount="666" Body="&lt;p&gt;I would like to prototype an Ergodox-like keyboard. My take on this good design would be to affix each half of the keyboard to my chair's armrests, so that the arms are always in a natural relaxed position. In order to achieve this, bluetooth capabilities seem necessary in order to avoid cable mayhem each time I move the chair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that the Arduino Leonardo has USB-HID capabilities, but will that translate to the additional USB module that would be required? I saw that Adafruit has an EZ-key bluetooth module that seems to fit the bill, but even so, it would require more cabling and complexity, for a project that is already very near my threshold (or above it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be easy is if the Arduino 101 had HID capabilities. I would just need to solder the matrix of keys, and almost be done. Does it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your attention.&lt;/p&gt;&#xA;" OwnerUserId="19700" LastEditorUserId="4628" LastEditDate="2017-12-31T05:12:26.660" LastActivityDate="2017-12-31T05:13:12.947" Title="Does an Arduino 101 come with bluetooth HID capabilities?" Tags="|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22607" PostTypeId="1" CreationDate="2016-04-02T11:54:08.247" Score="0" ViewCount="1156" Body="&lt;p&gt;I want to communicate between an arduino and an Android phone that has an Android app blue term. I connected HC-05 with Arduino using software serial and I connected the hc05 as a device with the android app. I am able to send data ( data as in message) from Android to Arduino but I am unable to send message from arduino to Android though I have given &lt;code&gt;.write()&lt;/code&gt; command to Bluetooth connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it such that the Android app does not show the received message? Or there is some master-slave configuration issue? Do I need to configure HC-05 in master mode? It was configured in slave mode by default when I had connected it to Android app. &lt;/p&gt;&#xA;" OwnerUserId="19823" LastEditorUserId="19515" LastEditDate="2016-04-03T09:16:50.943" LastActivityDate="2024-02-12T11:03:00.390" Title="Arduino-Bluetooth HC-05 Android app blueterm connection for chatting" Tags="|android|hc-05|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22617" PostTypeId="2" ParentId="22593" CreationDate="2016-04-02T16:43:06.853" Score="1" Body="&lt;p&gt;If I understand the problem correctly, I think the answer might be a pretty common one. Your circuit may be suffering from &quot;bounce&quot; and the solution is called &quot;debounce.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out this link for a possible solution:&#xA;&lt;a href=&quot;http://playground.arduino.cc/Learning/SoftwareDebounce&quot; rel=&quot;nofollow&quot;&gt;Software Debounce&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-04-02T16:43:06.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22618" PostTypeId="1" CreationDate="2016-04-02T17:51:01.920" Score="1" ViewCount="3198" Body="&lt;p&gt;I used sevseg.h library to write numbers to my 4 digit seven segment. The display should update every second with the current time since program started running. This is my code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;&#xA;SevSeg sevseg;&#xA;&#xA;void setup() {&#xA;    byte numDigits = 4;&#xA;    byte digitPins[] = {5, 4, 3, 2};&#xA;    byte segmentPins[] = {13, 12, 11, 10, 9, 8, 7, 6};&#xA;    sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);&#xA;    sevseg.setBrightness(50);&#xA;    sevseg.setNumber(0000, -1);&#xA;}&#xA;&#xA;void loop() {&#xA;    unsigned long timer = millis();&#xA;    for (int i = 0; i &amp;lt; 500; i++) {&#xA;        sevseg.setNumber(timer/1000, -1);&#xA;        sevseg.refreshDisplay();&#xA;        delay(2);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the delay is 2, the for loop loops 500 times, resulting in 1000ms or 1 second. The current second is written to the display. For some reason, the display is updated every other 5 or 6 seconds. Why is this occurring? How can this be fixed so that my display turns into a stopwatch in a way?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="7508" LastEditDate="2017-04-28T08:35:04.877" LastActivityDate="2019-08-23T09:09:22.900" Title="Why doesn't my 7 segment update every second like in the program?" Tags="|display|millis|7-segment|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22619" PostTypeId="2" ParentId="22607" CreationDate="2016-04-02T17:59:00.850" Score="0" Body="&lt;p&gt;Its totally Normal. You must be doing something wrong. It has happen to my Arduino Code a lot of times. try following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try interchanging you Tx and Rx Pin Positions. (This happens all the time).&lt;/li&gt;&#xA;&lt;li&gt;Try connecting using default &lt;strong&gt;Serial&lt;/strong&gt; and using Pin 1 and Pin 0 as Tx/Rx. (In this case remember to unplug the Tx/Rx Pins while running code.)&lt;/li&gt;&#xA;&lt;li&gt;Try using just basic &lt;strong&gt;Serial.Write()&lt;/strong&gt; function in beginning. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-02T17:59:00.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22620" PostTypeId="1" AcceptedAnswerId="22627" CreationDate="2016-04-02T18:08:33.507" Score="0" ViewCount="1072" Body="&lt;p&gt;Bear with me as I'm fairly adept at C# but I am having a problem understanding how to get an array iterated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am writing a program to test relay boards, it will eventually have an input mechanism to select the number of relays on the board. For now, i just need to get an array iterated to move on with the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The biggest relay board I've seen has 16 relays, so....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Relay1  2  // Arduino Digital I/O pin numbers for UNO R3&#xA;#define Relay2  3&#xA;#define Relay3  4&#xA;#define Relay4  5&#xA;#define Relay5  7  &#xA;#define Relay6  8&#xA;#define Relay7  9&#xA;#define Relay8  10&#xA;#define Relay9  11  &#xA;#define Relay10  12&#xA;#define Relay11  13&#xA;#define Relay12  A0&#xA;#define Relay13  A1 &#xA;#define Relay14  A2&#xA;#define Relay15  A3&#xA;#define Relay16  A4&#xA;&#xA;int relays[]{ Relay1,Relay2,Relay3,Relay4,&#xA;    Relay5,Relay6,Relay7,Relay8 };&#xA;int maxRelayCount = 8;&#xA;char rx_byte = 0;&#xA;&#xA;void setup()   //Initializes all variables and settings&#xA;{&#xA;  Serial.begin(9600);&#xA; // create an input for the amount of relays on the board&#xA;//hardcoded for now&#xA;&#xA;//Set pins to OFF &amp;amp; declare pins as OUTPUTS&#xA; for(int i = 0; i &amp;lt; maxRelayCount; i++)&#xA; {&#xA;   digitalWrite(relays[i], RELAY_OFF);&#xA;   pinMode(relays[i], OUTPUT);&#xA;   //How to convert i to a string in c++?&#xA;   //Serial.print(&quot;Relay &quot; +[i] + &quot; set HIGH and as OUTPUTS&quot;);&#xA; }&#xA;&#xA; //Check that all relays are inactive at Reset&#xA; delay(4000); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So there are two issues. If I remove the loop and just hard code 8 times to set HIGH and OUTPUT it works fine, but the loop does not and won't upload to the Arduino, thus the reason I believe it is wrong. Secondary question is how to convert the counter i to a string to concatenate the message&lt;/p&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-02T19:07:57.087" Title="Iterating an array of relays" Tags="|arduino-uno|array|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22621" PostTypeId="2" ParentId="22601" CreationDate="2016-04-02T18:10:54.163" Score="0" Body="&lt;p&gt;When you are testing buttons within a loop that runs repeatedly, there's no need for lengthy monolithic delays like &lt;code&gt;wait1Msec(15)&lt;/code&gt;, and no need to store and test start times, like &lt;code&gt;time = time1[T1]&lt;/code&gt; and &lt;code&gt;time1[T1] - time &amp;gt; 50&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you can change your loop so it takes at least some small time (as via &lt;code&gt;wait1Msec(1)&lt;/code&gt; in following code sample), and add a holdoff counter that inhibits sensor testing during probable bounce periods.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;string last;&#xA;long bumpCount = 0;&#xA;byte holdoff=0, isbump=0;&#xA;&#xA;task main() {&#xA;  while (SensorValue(go) != 1) {&#xA;    string presses = bumpCount;&#xA;    if(presses != last) {&#xA;      writeDebugStreamLine(presses);&#xA;    }&#xA;    last = presses;&#xA;    wait1Msec(1);&#xA;    if (holdoff) {      // Ignore bump sensor during holdoff&#xA;      --holdoff;&#xA;    } else {&#xA;      if (SensorValue(bump)) {&#xA;        if (isbump==0) {&#xA;          ++bumpCount;  // Count a new closure&#xA;          holdoff = 40; // Start a holdoff period&#xA;        }&#xA;        isbump = 1;     // We detected bump is on&#xA;      } else {&#xA;        isbump = 0;     // We detected bump is off&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code shown above acts as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Initially, &lt;code&gt;bumpCount&lt;/code&gt;, &lt;code&gt;holdoff&lt;/code&gt;, and &lt;code&gt;isbump&lt;/code&gt; are zero, to indicate we haven't counted any bumps, are not inhibiting bump sensing, and think the bump sensor is off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Under initial conditions and while the bump sensor is off, we will pass through the outer while loop, each time waiting a millisecond, then taking the &lt;code&gt;else&lt;/code&gt; branch of &lt;code&gt;if (holdoff)&lt;/code&gt; and the &lt;code&gt;else&lt;/code&gt; branch of &lt;code&gt;if (SensorValue(bump))&lt;/code&gt;, so will repeatedly set &lt;code&gt;isbump = 0&lt;/code&gt;, thus maintaining initial conditions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• When the bump sensor goes on, we take the first branch of &lt;code&gt;if (SensorValue(bump))&lt;/code&gt;.  From initial conditions, &lt;code&gt;isbump==0&lt;/code&gt; so we increment &lt;code&gt;bumpCount&lt;/code&gt; and set &lt;code&gt;holdoff = 40&lt;/code&gt;.  Lastly, set &lt;code&gt;isbump = 1&lt;/code&gt; to reflect sensor state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• During the next 40 milliseconds or so (that is, during the holdoff period) we repeatedly decrement &lt;code&gt;holdoff&lt;/code&gt;, while ignoring the bump sensor, which may bounce a number of times or not, as it pleases, but we don't care.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• After the holdoff period, &lt;code&gt;SensorValue(bump)&lt;/code&gt; may still be true.  But since &lt;code&gt;isbump==0&lt;/code&gt; is false, we don't change &lt;code&gt;bumpCount&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• If the bump sensor opens after the holdoff, &lt;code&gt;isbump&lt;/code&gt; will go zero, restoring two of the initial conditions.  If it opens during the holdoff and stays open, the same thing happens at the end of the holdoff. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-02T18:10:54.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22622" PostTypeId="2" ParentId="22618" CreationDate="2016-04-02T18:14:37.430" Score="-1" Body="&lt;p&gt;On &lt;a href=&quot;http://playground.arduino.cc/Main/SevenSegmentLibrary&quot; rel=&quot;nofollow&quot;&gt;SevSeg.h Arduino Page&lt;/a&gt;, It says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Your program must run the refreshDisplay() function repeatedly to&#xA;  display the number.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think that's the Problem. You are calling it just once and then your &lt;strong&gt;the number&lt;/strong&gt; is changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus, you are saying it must get updated after One Second, but I think in your code, its being updated ever other &lt;strong&gt;2 milisecond&lt;/strong&gt; (WOW).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I suggest is that you add a &lt;strong&gt;delay()&lt;/strong&gt; for one second and then call &lt;strong&gt;sevseg.refreshDisplay();&lt;/strong&gt; several times in a &lt;strong&gt;for&lt;/strong&gt; loop. You also need to change the way you measure no. of seconds elapsed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e. try Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SevSeg.h&amp;gt;&#xA;SevSeg sevseg;&#xA;void setup() {&#xA;  byte numDigits = 4;&#xA;  byte digitPins[] = {5, 4, 3, 2};&#xA;  byte segmentPins[] = {13, 12, 11, 10, 9, 8, 7, 6};&#xA;  sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);&#xA;  sevseg.setBrightness(50);&#xA;  sevseg.setNumber(0000, -1);&#xA;}&#xA;unsigned long timerGlobal = millis();&#xA;void loop() {&#xA;  delay(1000);&#xA;  sevseg.setNumber( (timerGlobal - millis())/1000, -1)&#xA;  for (int i = 0; i &amp;lt; 50; i++) {&#xA;    sevseg.refreshDisplay();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-02T18:14:37.430" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22623" PostTypeId="2" ParentId="22620" CreationDate="2016-04-02T18:18:14.980" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;the loop does not and won't upload to the Arduino&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Most likely because &lt;code&gt;RELAY_OFF&lt;/code&gt; has never been defined anywhere. Change that to HIGH (if that is what your relays need to turn off), or define it somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also there is no &lt;code&gt;loop()&lt;/code&gt; function - is that just you being economical with the paste?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Secondary question is how to convert the counter i to a string to concatenate the message.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Simple: don't.  There's no need.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Relay &quot;);&#xA;Serial.print(i);&#xA;Serial.println(&quot; set HIGH and as OUTPUT&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-02T18:18:14.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22624" PostTypeId="1" AcceptedAnswerId="22630" CreationDate="2016-04-02T18:30:35.163" Score="0" ViewCount="334" Body="&lt;p&gt;I'd like to build a little voice recorder for my grandmother. She told me &quot;I get a lot of idea when I'm driving but then I forget them. I want a necklace where I can just press a button and it'll record my voice and I can press a button and it'll stop recording.&quot; She wants each recording to save as a separate file. I was thinking of concealing a mini Arduino board or Rasberry Pi or something in a necklace, with a removable micro sd card. Or something like that. I just don't know where to start, I don't have much experience with this. Does anyone have any tips on what kind of device I could use or where to start? I suggested that she just have Siri take notes for her on her iPhone but she wants something around her neck, and she wants me to make it.&lt;/p&gt;&#xA;" OwnerUserId="19834" LastActivityDate="2016-04-02T20:13:21.537" Title="Audio/Voice Recording Device" Tags="|sensors|audio|raspberrypi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22625" PostTypeId="2" ParentId="22618" CreationDate="2016-04-02T18:32:06.427" Score="2" Body="&lt;p&gt;This is the code that fixed the issue:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;SevSeg.h&amp;gt;&#xA;  SevSeg sevseg;&#xA;&#xA;  void setup() {&#xA;    byte numDigits = 4;&#xA;    byte digitPins[] = {5, 4, 3, 2};&#xA;    byte segmentPins[] = {13, 12, 11, 10, 9, 8, 7, 6};&#xA;    sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);&#xA;    sevseg.setBrightness(50);&#xA;    sevseg.setNumber(0000, -1);&#xA;  }&#xA;&#xA;  void loop() {&#xA;    unsigned long timerGlobal = millis();&#xA;    sevseg.setNumber(timerGlobal/1000, -1);&#xA;    sevseg.refreshDisplay();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this, no delays are needed. &lt;code&gt;millis&lt;/code&gt; is divided by 1000 and the integer second is drawn on the display. Proved to be much easier than I previously thought.&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="56216" LastEditDate="2019-08-23T09:09:22.900" LastActivityDate="2019-08-23T09:09:22.900" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22627" PostTypeId="2" ParentId="22620" CreationDate="2016-04-02T19:07:57.087" Score="1" Body="&lt;p&gt;As noted earlier, &lt;code&gt;RELAY_OFF&lt;/code&gt; needs a defined value.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, rather than using clumsy list of &lt;code&gt;#define&lt;/code&gt; statements to define a bunch of integer constants, you can use C's &lt;code&gt;enum&lt;/code&gt; declaration to define them, as shown in the following sketch, which produces the output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Relay 1 should be OFF&#xA;Relay 2 should be OFF&#xA;Relay 3 should be OFF&#xA;Relay 4 should be OFF&#xA;Relay 5 should be OFF&#xA;Relay 6 should be OFF&#xA;Relay 7 should be OFF&#xA;Relay 8 should be OFF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when it is run.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;&#xA;// Arduino Digital I/O pin numbers for UNO R3&#xA;enum { Relay1=2, Relay2=3, Relay3=4, Relay4=5, Relay5=7, Relay6=8,&#xA;       Relay7=9,   Relay8=10,  Relay9=11,  Relay10=12,  Relay11=13,&#xA;       Relay12=A0, Relay13=A1, Relay14=A2, Relay15=A3,  Relay16=A4};&#xA;&#xA;int relays[] = {Relay1,Relay2,Relay3,Relay4,Relay5,Relay6,Relay7,Relay8};&#xA;// Number of relays in the array&#xA;enum { maxRelayCount = sizeof relays / sizeof relays[0] };&#xA;enum { RELAY_OFF = HIGH };  // Set LOW or HIGH as appropriate&#xA;char rx_byte = 0;&#xA;&#xA;void setup() {          // Initialize variables and settings&#xA;  Serial.begin(9600);&#xA;  //Set pins to OFF &amp;amp; declare pins as OUTPUTS&#xA;  for(int i = 0; i &amp;lt; maxRelayCount; ++i) {&#xA;    digitalWrite(relays[i], RELAY_OFF);&#xA;    pinMode(relays[i], OUTPUT);&#xA;    // Serial.print(&quot;Relay &quot; +[i] + &quot; set HIGH and as OUTPUTS&quot;);&#xA;    Serial &amp;lt;&amp;lt; &quot;Relay &quot; &amp;lt;&amp;lt; i+1 &amp;lt;&amp;lt; &quot; should be OFF&quot; &amp;lt;&amp;lt; endl;&#xA;  }&#xA;&#xA; // Check that all relays are inactive at Reset&#xA; delay(4000);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note, the &lt;code&gt;Streaming.h&lt;/code&gt; library adds some “syntactic sugar” to Arduino C. At compile time it converts C++-like &amp;lt;&amp;lt; Serial stream operators to Serial.print statements, without increasing code size.  You can install it by unzipping &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduiniana.org&lt;/a&gt; in your &lt;code&gt;sketchbook/libraries&lt;/code&gt; directory&lt;a href=&quot;https://arduino.stackexchange.com/questions/18348/arduino-variable-data-type&quot;&gt;.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-04-02T19:07:57.087" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22628" PostTypeId="1" AcceptedAnswerId="24705" CreationDate="2016-04-02T19:21:31.013" Score="3" ViewCount="286" Body="&lt;p&gt;I'm using two Arduinos with the rf24 modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to control a process with those, but for now I'm just checking the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code of the master:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include  &amp;lt;SPI.h&amp;gt;&#xA;#include &quot;nRF24L01.h&quot;&#xA;#include &quot;RF24.h&quot;&#xA;unsigned char msg[4];&#xA;unsigned char serial_msg[1];&#xA;&#xA;String mensaje = &quot;ii&quot;;&#xA;&#xA;int CE = 9;&#xA;int CSN = 10;&#xA;&#xA;RF24 radio(9,10);&#xA;&#xA;//const uint64_t pipe = 0xE8E8F0F0E1LL;&#xA;const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };&#xA;&#xA;bool done;&#xA;int incomingByte = 0; &#xA;&#xA;String stringOne  = &quot;&quot;;&#xA;&#xA;void setup(void){&#xA;    Serial.begin(9600);&#xA;    radio.begin();&#xA;    radio.setRetries(15,15);   &#xA;    radio.openWritingPipe(pipes[1]);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    radio.stopListening();  &#xA;&#xA;    if (Serial.available() == 3) {&#xA;&#xA;        while(Serial.available() &amp;gt; 0)&#xA;        {&#xA;            incomingByte= Serial.read();&#xA;&#xA;            stringOne = String(stringOne + String((char)incomingByte));&#xA;&#xA;        }&#xA;        Serial.println(mensaje);&#xA;&#xA;        incomingByte = Serial.read();&#xA;        serial_msg[0] = incomingByte;&#xA;&#xA;        radio.write(stringOne.c_str() ,2);&#xA;&#xA;    }&#xA;&#xA;    stringOne  = &quot;&quot;;&#xA;&#xA;    radio.startListening();    // Volvemos a la escucha para recibir mas paquetes&#xA;    delay(10); // necesario para activar el modo de esucha&#xA;&#xA;    if (radio.available())&#xA;    done = false;&#xA;    {&#xA;        while (!done)&#xA;        {&#xA;            if (sizeof(msg)==4)&#xA;            {&#xA;                done = radio.read(msg,sizeof(msg) );&#xA;                Serial.print(&quot;Estado: &quot;);&#xA;                Serial.println(msg[0]); &#xA;                Serial.print(&quot;Voltaje: &quot;);&#xA;                Serial.print(msg[1]);&#xA;                Serial.print(msg[2]);&#xA;                Serial.println(msg[3]);&#xA;            }&#xA;&#xA;        }&#xA;&#xA;&#xA;    }&#xA;    mensaje = &quot;&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What t does is read data for the serial monitor, convert it to a string and them send the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code of the receiver is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include  &amp;lt;SPI.h&amp;gt;  &#xA;#include &quot;nRF24L01.h&quot;  &#xA;#include &quot;RF24.h&quot;  &#xA;&#xA;int CE = 6;    &#xA;int CSN = 7;&#xA;RF24 radio(CE,CSN);  /// ()&#xA;const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };&#xA;&#xA;bool done = false;&#xA;&#xA;int voltaje = 141;&#xA;String string_vol= &quot;789&quot;;&#xA;enum states { &#xA;    ESPERA,&#xA;    ENCENDIDO,&#xA;    PAUSA&#xA;};&#xA;enum states state = ESPERA;&#xA;&#xA;unsigned char msg[2];&#xA;char incomingByte = '_';&#xA;unsigned long previousMillis = 0;&#xA;unsigned long currentMillis = 0;&#xA;unsigned long interval = 1000;&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(9600);            &#xA;    radio.begin();         &#xA;    radio.startListening();             &#xA;    radio.openWritingPipe(pipes[1]);              &#xA;    radio.openReadingPipe(1,pipes[0]);  &#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    string_vol= &quot;789&quot;;&#xA;    currentMillis = millis();&#xA;    if ((currentMillis-previousMillis)&amp;gt;interval)&#xA;    {&#xA;        previousMillis = currentMillis;&#xA;        msg[0] = char(state);&#xA;        radio.stopListening(); // Dejamos d escuchar para poder hablar&#xA;        string_vol = String(String((char)state)  + string_vol );&#xA;        radio.write(string_vol.c_str() ,4);&#xA;        radio.startListening();    // Volvemos a la escucha para recibir mas paquetes&#xA;        delay(10);&#xA;    }&#xA;    if (radio.available())&#xA;    done = false;&#xA;    {&#xA;        while (!done)&#xA;        {&#xA;            done = radio.read(msg,sizeof(msg));&#xA;        }&#xA;    }&#xA;&#xA;    switch(state) {&#xA;    case ESPERA:&#xA;&#xA;        if (msg[0] == 'i')&#xA;        {&#xA;            state =  ENCENDIDO;&#xA;        }&#xA;&#xA;        break;&#xA;    case ENCENDIDO:&#xA;&#xA;        currentMillis = millis();&#xA;&#xA;        if (msg[0]=='r')&#xA;&#xA;        {&#xA;            state =  ESPERA;&#xA;        }&#xA;        else if  (msg[0]=='d')&#xA;        {&#xA;            state =  PAUSA;&#xA;        }&#xA;        break;&#xA;    case PAUSA:&#xA;        if (msg[0]=='r')&#xA;        {&#xA;            state =  ESPERA;&#xA;        }&#xA;        else if  (msg[0]=='c')&#xA;        {&#xA;            state =  ENCENDIDO;&#xA;        }&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This one acts as a state machine, and sends a string in this case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string_vol= &quot;789&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;plus the actual state of the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string_vol = String(String((char)state)  + string_vol );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When this Arduino is in state one:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the other side I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Estado: 1&lt;br&gt;&#xA;Voltaje: 555657                        &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When is in state II I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Estado: 2&lt;br&gt;&#xA;Voltaje: 555657                 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if it's in state zero, which is the initial one, I got:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Estado: 55&lt;br&gt;&#xA;Voltaje: 56570                &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It change the  position of the state for one of the chars of the string&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The  issue is when sending the '0' of the first state, I changed enum to: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum states { &#xA;    foo, //  revisar, solo usada para comenzar en 1&#xA;    ESPERA,&#xA;    ENCENDIDO,&#xA;    PAUSA&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now it works fine because the first state is '1', still don't now why it doesn't work if I use the '0'&lt;/p&gt;&#xA;" OwnerUserId="18574" LastEditorUserId="20645" LastEditDate="2016-05-30T22:21:03.340" LastActivityDate="2016-05-30T22:21:03.340" Title="rf24 change order of data" Tags="|serial|c++|nrf24l01+|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22630" PostTypeId="2" ParentId="22624" CreationDate="2016-04-02T20:13:21.537" Score="0" Body="&lt;p&gt;Try this amazing breakout board. Its all you need. &lt;a href=&quot;https://www.sparkfun.com/products/retired/10653&quot; rel=&quot;nofollow&quot;&gt;SparkFun Voice Recorder Breakout - ISD1932&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, If you thinking on letting that device talk back, try this: &lt;a href=&quot;http://www.spikenzielabs.com/SpikenzieLabs/VoiceShield.html&quot; rel=&quot;nofollow&quot;&gt;VoiceShield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, there is also an instructable for this, &lt;a href=&quot;http://www.instructables.com/id/Arduino-Mega-Audio-File-logging/&quot; rel=&quot;nofollow&quot;&gt;HERE&lt;/a&gt;. This Instructable will show you how audio input can be repeatedly added to a 512 byte buffer and then transferred to a SD card in real time. The audio file can be played back on a standard audio application or analysed byte by byte.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-02T20:13:21.537" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22633" PostTypeId="1" AcceptedAnswerId="22637" CreationDate="2016-04-02T22:11:42.667" Score="1" ViewCount="3859" Body="&lt;p&gt;I'm using SIM900 module + arduino uno + gsmlib.org library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to send a string to endpoint on my API , and it worked correctly for the first time when I using &lt;code&gt;inet.httpPOST&lt;/code&gt; function in &lt;code&gt;setup()&lt;/code&gt;, but... in &lt;code&gt;loop()&lt;/code&gt;, when I call that function again, it doesn't work. On serial monitor I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ATT: ERROR&#xA;RIC: &#xA;ERROR    &#xA;DB:STARTING NEW CONNECTION&#xA;ATT: SHUT OK&#xA;RIC: &#xA;SHUT OK    &#xA;DB:SHUTTED OK&#xA;ATT: OK&#xA;RIC: &#xA;OK    &#xA;DB:APN OK&#xA;ATT: OK&#xA;RIC: &#xA;OK    &#xA;DB:CONNECTION OK&#xA;ATT: ERROR&#xA;RIC: &#xA;xxx.xxx.xxx.xxx&#xA;&#xA;DB:ASSIGNED AN IP&#xA;status=ATTACHED&#xA;&#xA;http://api.com.br/mystring&#xA;&#xA;ATT: OK&#xA;RIC: &#xA;OK    &#xA;DB:RECVD CMD&#xA;ATT: CONNECT OK&#xA;RIC: &#xA;OK    &#xA;ATT: OK&#xA;RIC: &#xA;CONNECT OK    &#xA;DB:OK TCP&#xA;ATT: &amp;gt;&#xA;RIC: &#xA;&amp;gt; &#xA;DB:&amp;gt;&#xA;ATT: SEND OK&#xA;RIC: &#xA;SEND OK&#xA;&#xA;DB:SENT&#xA;&#xA;http://api.com.br/mystring&#xA;&#xA;ATT: OK&#xA;RIC: &#xA;xxx.xxx.xxx.xxx&#xA;ERROR    &#xA;ALREADY CONNECT    &#xA;DB:NOT CONN&#xA;ATT: OK&#xA;RIC: &#xA;ERROR&#xA;&#xA;ALREADY CONNECT    &#xA;DB:NOT CONN&#xA;ATT: OK&#xA;RIC: &#xA;ERROR&#xA;&#xA;ALREADY CONNECT    &#xA;DB:NOT CONN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I send data to my API continuously on loop() Could someone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following is my code (SOLVED): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;inetGSM.h&amp;gt;&#xA;&#xA;InetGSM inet;&#xA;TinyGPSPlus gps;&#xA;SoftwareSerial serialGps(11, 10);&#xA;&#xA;/**&#xA;    setup&#xA;*/&#xA;void setup() {&#xA;  // Serial connection.&#xA;  Serial.begin(19200);&#xA;  Serial.println(F(&quot;Starting App Arduino&quot;));&#xA;&#xA;  // Turn on GPRS&#xA;  powerUpGprs();&#xA;&#xA;  // Start configuration of shield SIM900 with baudrate and  connect to internet.&#xA;  if (gsm.begin(9600)) {&#xA;    Serial.println(F(&quot;\nstatus=READY&quot;));&#xA;&#xA;  // Start configuration of shield GPS NEO-6M with baudrate.&#xA;  serialGps.begin(9600);&#xA;&#xA;  // Mensure and show memory usage&#xA;  Serial.println(F(&quot;\nMemory usage&quot;));&#xA;  Serial.print(freeRam());&#xA;}&#xA;&#xA;/**&#xA;   loop&#xA;*/&#xA; void loop() {&#xA;  serialGps.listen();&#xA;  while (serialGps.available() &amp;gt; 0)  {&#xA;    if (gps.encode(serialGps.read())) {&#xA;      // Get GPS position and send To API &#xA;      gsm.listen();&#xA;      // if sim900 started, connect to internet&#xA;      Serial.print(F(&quot;\r\n&quot;));        &#xA;      Serial.print(F(&quot; CONNECT TO INTERNET \r\n&quot;));&#xA;&#xA;      // GPRS attach, put in order APN, username and password.&#xA;      if (inet.attachGPRS(&quot;zap.com.br&quot;, &quot;zap&quot;, &quot;zap&quot;))&#xA;        Serial.println(&quot;status=ATTACHED&quot;);&#xA;      else Serial.println(&quot;status=ERROR&quot;);&#xA;      delay(1000);&#xA;      // Read IP address.&#xA;      gsm.SimpleWriteln(&quot;AT+CIFSR&quot;);&#xA;&#xA;      Serial.print(F(&quot;\r\n\r\n&quot;));&#xA;      Serial.print(F(&quot; GET GEOLOCATION &amp;amp; SEND TO API \r\n&quot;));&#xA;      // get geolocation&#xA;      String geo;&#xA;      geo.concat(&quot;lat=&quot; + String(gps.location.lat(), 6));&#xA;      geo.concat(&quot;&amp;amp;lng=&quot; + String(gps.location.lng(), 6));&#xA;      geo.concat(&quot;&amp;amp;spd=&quot; + String(gps.speed.kmph()));&#xA;      geo.concat(&quot;&amp;amp;gps.uuid=1&quot;);&#xA;      // send2Api&#xA;      Serial.println(geo.c_str());&#xA;      Serial.print(F(&quot;\n&quot;));&#xA;      gsm.SimpleWriteln(&quot;AT+CIFSR&quot;);&#xA;      inet.httpPOST(&quot;api.com.br&quot;, 80, &quot;/geolocations&quot;, geo.c_str(), &quot;&quot;, 100);&#xA;    }&#xA;  }&#xA;}    &#xA;&#xA;/**&#xA;   mensure memory usage&#xA;*/&#xA;int freeRam() {&#xA;  extern int __heap_start, *__brkval;&#xA;  int v;&#xA;  return (int) &amp;amp;v - (__brkval == 0 ? (int) &amp;amp;__heap_start : (int) __brkval);&#xA;}&#xA;&#xA;/**&#xA;   Power up&#xA;*/&#xA;void powerUpGprs() {&#xA;  pinMode(9, OUTPUT);&#xA;  delay(100);&#xA;  digitalWrite(9, HIGH);&#xA;  Serial.println(F(&quot;\nPower Up SIM900!&quot;));&#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank You!!!&lt;/p&gt;&#xA;" OwnerUserId="19165" LastEditorUserId="19165" LastEditDate="2017-03-02T19:28:01.347" LastActivityDate="2017-03-02T19:28:01.347" Title="DB:NO RESP Using inet.httpPOST on loop()" Tags="|arduino-uno|gsm|softwareserial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22634" PostTypeId="1" AcceptedAnswerId="22635" CreationDate="2016-04-02T22:20:04.887" Score="0" ViewCount="44" Body="&lt;p&gt;I am writing a utility program to test relay boards. I'd like to be able to accept a user input of the number of relays on the board. Is this doable via the serial monitor since when I'm testing boards I'm generally doing it at my desk with my testing Arduino attached to my laptop? I'd prefer not to go the LCD and keypad route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an accepted practice for doing this?&lt;/p&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-02T22:39:01.683" Title="User input for utility program" Tags="|arduino-uno|input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22635" PostTypeId="2" ParentId="22634" CreationDate="2016-04-02T22:39:01.683" Score="3" Body="&lt;p&gt;Yes, it is perfectly do-able through the serial monitor.  However the serial monitor is very very basic and you will be able to create a much better user experience using a proper serial terminal emulator (such as TeraTerm, Putty, etc) and using ANSI control codes to lay the screen out as a proper text-based application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A useful resource is on Wikipedia: &lt;a href=&quot;https://en.wikipedia.org/wiki/ANSI_escape_code&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/ANSI_escape_code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a little library that I started a while back and never finished that performs two basic ANSI control sequences - clear screen and set cursor. You can look at it to see how to perform ANSI control codes: &lt;a href=&quot;https://github.com/MajenkoLibraries/ANSI&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/ANSI&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-02T22:39:01.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22636" PostTypeId="2" ParentId="22343" CreationDate="2016-04-02T23:21:23.267" Score="1" Body="&lt;p&gt;GPS is a positioning system: it doesn't do direction.  If your software has serial information coming in,  it can take the difference in readings and &lt;em&gt;generate&lt;/em&gt; that data but GPS doesn't do it for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some devices may add it to the standard,  but that's a per-device feature. .&lt;/p&gt;&#xA;" OwnerUserId="5168" LastActivityDate="2016-04-02T23:21:23.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22637" PostTypeId="2" ParentId="22633" CreationDate="2016-04-02T23:44:12.987" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/22149/gprs-sim900-and-gps-neo-6m-dont-work-together/&quot;&gt;Like I told you before&lt;/a&gt;, you have 2 instances of &lt;code&gt;SoftwareSerial&lt;/code&gt; active, but you're allowed to listen to only one at a time (implementation rules). So you have to alternate between calling &lt;code&gt;listen()&lt;/code&gt; on each instance; any data arriving at any port while its not the active port will be discarded. &lt;code&gt;inet.httpPOST()&lt;/code&gt; worked in &lt;code&gt;setup()&lt;/code&gt; because you called the function before &lt;code&gt;begin()&lt;/code&gt;ing &lt;code&gt;serialGps&lt;/code&gt;. Calling &lt;code&gt;serialGps.begin()&lt;/code&gt; immediately made &lt;code&gt;serialGps&lt;/code&gt; the active port, severing communication with the modem. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Add this line to &lt;code&gt;SIM900.h&lt;/code&gt; in the library, under the public methods:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void listen();&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add this method to &lt;code&gt;SIM900.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SIMCOM900::listen(){&#xA;   _cell.listen();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Save the files and add &lt;code&gt;gsm.listen()&lt;/code&gt; right before &lt;code&gt;gsm.SimpleWriteln(&quot;AT+CIFSR&quot;);&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Re-initialize GPRS, like you did in setup() with attachGprs(), right after gsm.listen() in loop().&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Make &lt;code&gt;serialGps.listen()&lt;/code&gt; the last  statement in loop() immediately after the &lt;code&gt;inet.httpPOST()&lt;/code&gt; call. Use braces to enclose the body of the while loop.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hopefully this should solve your problem.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-04-03T18:31:25.677" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="22638" PostTypeId="1" CreationDate="2016-04-03T01:58:05.447" Score="2" ViewCount="488" Body="&lt;p&gt;When this 3 wire LCD code is compiled the following message results:&#xA;NewLiquidCrystal-master\I2CIO.cpp:35:26: fatal error: ../Wire/Wire.h: No such file or directory&lt;/p&gt;&#xA;&#xA;&lt;p&gt;#include &amp;lt;../Wire/Wire.h&gt;                         ^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;compilation terminated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;exit status 1&#xA;Error compiling for board Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help. &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; // Original LiquidCrystal library that can be inherited from to support other &#xA; // connectivity: &#xA; // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home &#xA;&#xA;&#xA; #include &amp;lt;LiquidCrystal_SR_LCD3.h&amp;gt; &#xA;&#xA;&#xA; // Standard HD44780 20x4 LCD display driven via 3 output pins to a 4094 8-bit &#xA; // shift register like 74HC4094 pebblev2's MC14094 &#xA;&#xA;  // This demo was written for the PebbleV2 to test LiquidCrystal_SR_LCD3, but it &#xA; // should work with other LiquidCrystal Displays that are 20x4. &#xA; // http://www.freetronics.com/pages/pebble-v2 &#xA; // https://github.com/lukeweston/pebble20 &#xA;&#xA;&#xA; // Data are the input bits &#xA; // Clock tells the SR that the data pin holds the next valid bit &#xA; // Strobe gets data input to be made visible on the parallel output pins. &#xA;&#xA;&#xA; const int PIN_LCD_STROBE         =  2;  // Out: LCD IC4094 shift-register strobe &#xA; const int PIN_LCD_DATA           =  3;  // Out: LCD IC4094 shift-register data &#xA; const int PIN_LCD_CLOCK          =  4;  // Out: LCD IC4094 shift-register clock &#xA; const int PIN_LCD_BACKLIGHT      =  5;  // Out: LCD backlight (PWM) &#xA;&#xA;&#xA; // srdata / srclock / strobe &#xA; LiquidCrystal_SR_LCD3 lcd(PIN_LCD_DATA, PIN_LCD_CLOCK, PIN_LCD_STROBE); &#xA;&#xA;&#xA; // Creat a set of new characters &#xA; byte heart[8] = { &#xA;   0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000 &#xA; }; &#xA;&#xA;&#xA; byte smiley[8] = { &#xA;   0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000 &#xA; }; &#xA;&#xA;&#xA; byte frownie[8] = { &#xA;   0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b00000, 0b01110, 0b10001 &#xA; }; &#xA;&#xA;&#xA;byte armsDown[8] = { &#xA;   0b00100, 0b01010, 0b00100, 0b00100, 0b01110, 0b10101, 0b00100, 0b01010 &#xA; }; &#xA;&#xA;&#xA; byte armsUp[8] = { &#xA;   0b00100, 0b01010, 0b00100, 0b10101, 0b01110, 0b00100, 0b00100, 0b01010 &#xA; }; &#xA;&#xA;&#xA; void setup(){ &#xA;     pinMode(PIN_LCD_BACKLIGHT, OUTPUT); &#xA;     analogWrite(PIN_LCD_BACKLIGHT, 80); &#xA;&#xA;&#xA;     lcd.begin(20, 4);               // initialize the lcd  &#xA;&#xA;&#xA;     // load characters to the LCD &#xA;     lcd.createChar(0, smiley); &#xA;     lcd.createChar(1, frownie); &#xA;     lcd.createChar(2, armsDown);   &#xA;     lcd.createChar(3, armsUp);   &#xA;     lcd.createChar(4, heart); &#xA;&#xA;&#xA;     lcd.home ();                   // go home &#xA;     lcd.setCursor (0, 0); &#xA;     lcd.print(F(&quot;LiquidCrystal_SRLCD3&quot;));   &#xA;     lcd.setCursor (0, 1); &#xA;     lcd.print(F(&quot;he..&quot;)); &#xA;     lcd.setCursor (0, 2); &#xA;     lcd.print(F(&quot;..lo&quot;)); &#xA;     lcd.setCursor (0, 3); &#xA;     lcd.print(F(&quot;World &quot;)); &#xA;     lcd.print(char(4)); &#xA;     lcd.print(char(2)); &#xA;     lcd.print(char(3)); &#xA;     delay(2000); &#xA; } &#xA;&#xA;&#xA;void loop() &#xA; { &#xA;     for (int i = 5; i &amp;lt;= 15; i++){ &#xA;       lcd.setCursor ( i, 1 ); &#xA;       lcd.print(char(random(0,2))); &#xA;       delay(100); &#xA;       lcd.setCursor ( i, 1 ); &#xA;       lcd.print(F(&quot; &quot;)); &#xA;     } &#xA;&#xA;     for (int i = 15; i &amp;gt;= 5; i--){ &#xA;       lcd.setCursor ( i, 1 ); &#xA;       lcd.print(char(random(0,2))); &#xA;       delay(100); &#xA;       lcd.setCursor ( i, 1 ); &#xA;  lcd.print(F(&quot; &quot;)); &#xA;     } &#xA;&#xA;&#xA;     // Turn the display on/off &#xA;     lcd.setCursor ( 5, 2 ); &#xA;     lcd.print(F(&quot;Turn screen off&quot;)); &#xA;     delay(1000); &#xA;     lcd.noDisplay(); &#xA;     delay(1000); &#xA;     lcd.display();    &#xA;&#xA;&#xA;     lcd.setCursor ( 5, 2 ); &#xA;     lcd.print(F(&quot;Toggle Cursor  &quot;)); &#xA;     delay(1000); &#xA;     lcd.setCursor ( 19, 2 ); &#xA;     lcd.cursor(); &#xA;     delay(2000); &#xA;     lcd.noCursor(); &#xA;&#xA;&#xA;     lcd.setCursor ( 5, 2 ); &#xA;     lcd.print(F(&quot;Toggle Blink   &quot;)); &#xA;     lcd.setCursor ( 19, 2 ); &#xA;     lcd.blink(); &#xA;     delay(2000); &#xA;     lcd.noBlink(); &#xA;&#xA;&#xA;     lcd.setCursor ( 5, 2 ); &#xA;     lcd.print(F(&quot;Scroll screen  &quot;)); &#xA;     delay(1000); &#xA; // This is an autoscroll demo, not super useful but here just in case. &#xA; //    lcd.setCursor(16,0); &#xA; //     lcd.autoscroll(); &#xA; //     // print from 0 to 9: &#xA; //     for (uint8_t thisChar = 0; thisChar &amp;lt; 10; thisChar++) { &#xA; //   lcd.print(char(2)); &#xA; //  delay(250); &#xA; //  lcd.print(char(3)); &#xA; //  delay(250); &#xA; //     } &#xA; //     // turn off automatic scro &#xA; //     lcd.noAutoscroll(); &#xA;&#xA;&#xA;     for (uint8_t positionCounter = 0; positionCounter &amp;lt; 10; positionCounter++) { &#xA;       // scroll one position left: &#xA;       lcd.scrollDisplayLeft();  &#xA;       // wait a bit: &#xA;       delay(50); &#xA;     } &#xA;&#xA;&#xA;     // scroll 29 positions (string length + display length) to the right &#xA;     // to move it offscreen right: &#xA;     for (uint8_t positionCounter = 0; positionCounter &amp;lt; 20; positionCounter++) { &#xA;       // scroll one position right: &#xA;       lcd.scrollDisplayRight();  &#xA;       // wait a bit: &#xA;       delay(50); &#xA;    } &#xA;&#xA;&#xA;       // scroll 16 positions (display length + string length) to the left &#xA;       // to move it back to center: &#xA;     for (uint8_t positionCounter = 0; positionCounter &amp;lt; 10; positionCounter++) { &#xA;       // scroll one position left: &#xA;       lcd.scrollDisplayLeft();  &#xA;       // wait a bit: &#xA;       delay(50); &#xA;     } &#xA;     lcd.setCursor ( 5, 2 ); &#xA;     lcd.print(F(&quot;               &quot;)); &#xA; } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="37523" LastEditDate="2019-07-15T21:25:22.960" LastActivityDate="2019-07-15T21:25:22.960" Title="Compiling Error 3 Wire LCD" Tags="|lcd|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="22639" PostTypeId="1" CreationDate="2016-04-03T02:03:58.460" Score="-1" ViewCount="8873" Body="&lt;p&gt;I'm trying to build a circuit that buzzes until a button is pressed, or it buzzes 5 times:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void alarm()&#xA;{&#xA;  int AlarmState = 0; //Just to get while loop going&#xA;  int count = 1;&#xA;  while(AlarmState==0)&#xA;  {&#xA;    int count = 1;&#xA;    AlarmState = digitalRead(alarmStop);                   &#xA;    digitalWrite(buzz,HIGH);&#xA;    AlarmState = digitalRead(alarmStop);&#xA;    delay(500);&#xA;    AlarmState = digitalRead(alarmStop);&#xA;    digitalWrite(buzz,LOW);&#xA;    AlarmState = digitalRead(alarmStop);&#xA;    delay(500);&#xA;    count++;&#xA;    if(count&amp;gt;=5){&#xA;       break;&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I put a bunch of digitalRead's  so it has a better chance of catching the button press while the loop is going, there's a better way to do that I'm sure but it's not my main concern right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is part of a larger project, but I hope I've posted only the necessary code. The function runs, but does not break after &lt;code&gt;count&lt;/code&gt; equals 5. Why? &lt;/p&gt;&#xA;" OwnerUserId="17202" LastEditorUserId="4215" LastEditDate="2016-07-03T17:56:45.147" LastActivityDate="2022-01-17T05:05:05.563" Title="While loop not breaking" Tags="|programming|c++|sketch|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22640" PostTypeId="1" CreationDate="2016-04-03T03:40:18.900" Score="-1" ViewCount="666" Body="&lt;p&gt;How can I get AD8232 chip in Arduino simulator?&#xA;It is because I have my ciruit comprising AD8232 analogue chip but I dont get this chip? I want to make simulatoin of my ciruit.&#xA;If it is can not be found in Arduino please direct me in which circuit simulating software can I get it! &lt;/p&gt;&#xA;" OwnerUserId="19844" LastActivityDate="2017-08-27T13:38:18.683" Title="Simulator for AD8232 Chip" Tags="|simulator|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22641" PostTypeId="2" ParentId="22639" CreationDate="2016-04-03T04:08:34.977" Score="0" Body="&lt;p&gt;Try This One its Simple:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void alarm()&#xA;{&#xA;  int count = 0;&#xA;  while ( digitalRead(alarmStop) &amp;amp;&amp;amp; (count++ &amp;lt;5))&#xA;  {&#xA;    //A&#xA;    digitalWrite(buzz, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(buzz, LOW);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, There is a logical problem with this Code. Lets say that your code is at point A (metioned in comment) and at same time button is pressed. Now This code above will, still buzz and then stop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid This try using interrupts. To use interrupts on Arduino I prefer &lt;a href=&quot;http://playground.arduino.cc/Main/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;This Library&lt;/a&gt;. &lt;a href=&quot;https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/arduino-pinchangeint/pinchangeint-v2.19beta.zip&quot; rel=&quot;nofollow&quot;&gt;Download Here&lt;/a&gt;. Extract this and inside you will find a folder Named &lt;strong&gt;PinChangeInt&lt;/strong&gt;. Copy This whole folder to your &lt;strong&gt;Documents\Arduino\libraries&lt;/strong&gt; folder. Now, restart Arduino IDE and copy paste this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PinChangeInt.h&amp;gt;&#xA;&#xA;int buzz = 3;&#xA;&#xA;bool alarmStatus = false;&#xA;#define PIN3 4&#xA;void pin3func() {&#xA;  digitalWrite(buzz, LOW);&#xA;  alarmStatus = true;&#xA;}&#xA;&#xA;void setup() {&#xA;  pinMode(PIN3, INPUT); digitalWrite(PIN3, HIGH);&#xA;  PCintPort::attachInterrupt(PIN3, &amp;amp;pin3func, CHANGE);&#xA;}&#xA;&#xA;int count = 0;&#xA;void loop() {&#xA;  if (count &amp;lt; 5)&#xA;  {&#xA;    if (!alarmStatus)&#xA;    {&#xA;      digitalWrite(buzz, HIGH);&#xA;    }&#xA;    delay(500);&#xA;    digitalWrite(buzz, LOW);&#xA;    delay(500);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because, of unavailability of hardware, I haven't tested this code. But, I hope It will work.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-03T04:08:34.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22642" PostTypeId="1" AcceptedAnswerId="22668" CreationDate="2016-04-03T04:41:58.687" Score="1" ViewCount="1558" Body="&lt;p&gt;I am a programming amateur, arduino noob, trying to decide which board will be better for my project. I need a small board. I am trying to decide between the Teensy 3.2 and the RFduino. I want to have blue-tooth capability for over air routine changes to a WS2812B LED strip, which makes the RFduino attractive because of its integrated BLE4.0 antenna. However, I want to be able to have enough speed for imperceptible LED modulation, which makes the 72MHz speed of the Teensy attractive. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the objective difference between the 16MHz processor on the RFduino versus the 72MHz on the Teensy3.2? Is this something I should be concerned with?&lt;/p&gt;&#xA;" OwnerUserId="19845" LastEditorUserId="19845" LastEditDate="2016-04-03T07:29:20.430" LastActivityDate="2017-04-18T23:30:05.657" Title="What are the consequences of different clock speeds on different boards?" Tags="|led|teensy|oscillator-clock|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22643" PostTypeId="1" AcceptedAnswerId="22952" CreationDate="2016-04-03T05:12:25.447" Score="0" ViewCount="290" Body="&lt;p&gt;I am attempting to use an Arduino Uno+WiFly setup to send data to Thingspeak. &#xA;I have tried a few libraries by now. But nearly all of them don't have a working WebClient example (WebServer works fine).&#xA;I am using &lt;strong&gt;Arduino 1.6.3 IDE&lt;/strong&gt; for Arduino UNO R3 + &lt;strong&gt;Wifly-RN171 with Firmware 4.0&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The libraries I have tried (found through Google and forums):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/sparkfun/WiFly-Shield/tree/master/Libraries/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sparkfun/WiFly-Shield/tree/master/Libraries/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A ThingSpeak example is given but the execution stops when WiFly.begin() is called. &lt;br&gt;I tried WebClient and WebClient(Faster) examples from the same library and they are both stuck at the same line: WiFly.begin().&lt;br&gt; &lt;br&gt;&#xA;I believe this could be compatibility issue (WiFly firmware version/Arduino) but am unsure how to fix it.&#xA;&lt;br&gt;&lt;br&gt;&#xA;&lt;strong&gt;Note:&lt;/strong&gt; There seems to be a few versions for the SparkFun WiFly library from my search results. I tried whatever I found but only listed the latest one since if it is indeed a compatibility issue a newer version should be more likely to work.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/Seeed-Studio/WiFi_Shield&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Seeed-Studio/WiFi_Shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This one has a http example which I am attempting to use to send data to Thingspeak through http get/post. I am getting 'Bad Request' from their nginx server. Any help in the right direction will be much appreciated.&#xA;&lt;br&gt;I hosted the sketch I tried here: codebender.cc/sketch:276925 &lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;p.s. I am not allowed to post &gt;2 links due to reputation so the last one is plain text.&lt;br&gt;&#xA;p.s.s Can someone with higher reputation help me add the new tags {thingspeak, wifly, rn171}&lt;/p&gt;&#xA;" OwnerUserId="13736" LastActivityDate="2016-04-10T14:13:07.033" Title="Arduino to Thingspeak using WiFly-RN171 (Firmware 4.0)" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22644" PostTypeId="2" ParentId="22640" CreationDate="2016-04-03T05:26:36.337" Score="1" Body="&lt;p&gt;I don't think there would be an actual simulator for this chip. Its hard. But there is a way around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are doing eventually is &lt;strong&gt;ECG&lt;/strong&gt; and the output given by this chip is just analog signal i.e. &lt;strong&gt;a single float value&lt;/strong&gt;. So, lets say for now, all you are concerned with is obtaining those float &lt;strong&gt;values&lt;/strong&gt; irrespective of source. And of course you need a lot of them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is to use a &lt;strong&gt;dataset&lt;/strong&gt;. As indicated by its name, a &lt;strong&gt;dataset&lt;/strong&gt; contains a large number of (recorded) value of something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can use a &lt;strong&gt;dataset for heart reate&lt;/strong&gt; to &lt;strong&gt;simulate&lt;/strong&gt; this chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are many related &lt;strong&gt;datasets&lt;/strong&gt; available online for free. just &lt;a href=&quot;https://www.google.com.pk/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=dataset%20heart%20rate&quot; rel=&quot;nofollow&quot;&gt;Google it&lt;/a&gt;. and find one that suits you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it help. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-03T05:26:36.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22645" PostTypeId="1" CreationDate="2016-04-03T06:00:43.377" Score="0" ViewCount="2049" Body="&lt;p&gt;One can connect an FSR sensor (a &lt;a href=&quot;https://learn.adafruit.com/force-sensitive-resistor-fsr/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;force-sensitive resistor&lt;/a&gt;) to an Arduino via 5V, Gnd,  and A0 port (as below, according to &lt;a href=&quot;https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr&quot; rel=&quot;nofollow noreferrer&quot;&gt;an adafruit.com page&lt;/a&gt;), but how will it work for two of them instead of one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aDNj4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aDNj4.png&quot; alt=&quot;FSR circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19846" LastEditorUserId="3917" LastEditDate="2016-04-03T06:21:34.633" LastActivityDate="2021-02-27T04:04:55.430" Title="How do we connect 2 FSR sensors to an Arduino Mega?" Tags="|arduino-mega|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22647" PostTypeId="1" CreationDate="2016-04-03T06:08:09.730" Score="3" ViewCount="2163" Body="&lt;p&gt;For my project I need to control relays through SMS and now I can send SMS from my SIM800 module which is connected to Arduino Mega R3. But I tried several shapes for AT commands to receive SMS and parse it to check sender number and SMS text but every time I received a 2 digits number in serial monitor of Arduino,&lt;/p&gt;&#xA;" OwnerUserId="19839" LastEditorUserId="19721" LastEditDate="2016-04-04T13:22:26.180" LastActivityDate="2016-04-04T13:22:26.180" Title="How to control relay using SIM800 and Arduino Mega through SMS?" Tags="|arduino-mega|gsm|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="22648" PostTypeId="2" ParentId="22645" CreationDate="2016-04-03T06:28:48.623" Score="1" Body="&lt;p&gt;Attach the second FSR mostly the same as the first, but connect the second analog voltage to A1 instead of to A0.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use several copies of  the circuit (below left) with each circuit's analog voltage going to a different analog-converter input (A0, A1, A2, ...). &#xA;&lt;a href=&quot;https://i.stack.imgur.com/CwN5b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CwN5b.png&quot; alt=&quot;circuit + breadboard + avrisp pinout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To connect up multiple 5V and ground connections, you can:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;•  use almost any popular shield&lt;br&gt;&#xA;•  use breadboards like those illustrated above&lt;br&gt;&#xA;•  cut and solder Dupont cables to add extra pins or sockets in or out (for example, cut two M-F Duponts in half, and connect both F halves to one M half)&lt;br&gt;&#xA;•  connect to the extra 5V and Gnd pins on Uno or Mega boards.  (On a Mega, besides 5V and Gnd pins on programming headers, there are two 5V sockets next to 22 and 23, and two Gnds next to 52 and 53.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The diagrams above right show the location of the 5V pins on the programming headers found on the Uno.  Most Arduino boards have at least one AVRISP header like that.  &lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-04-03T19:01:04.080" LastActivityDate="2016-04-03T19:01:04.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22649" PostTypeId="2" ParentId="22642" CreationDate="2016-04-03T06:41:11.417" Score="0" Body="&lt;p&gt;You would think on the face of it that a faster processor will give you &quot;more speed&quot; however that does not necessarily work in a linear way. The faster processors tend to have more sophisticated chips. And &quot;more sophisticated&quot; can be code for &quot;it takes more clock cycles to achieve the same thing&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have code that drives 300 NeoPixels in a seamless manner, on a 16 MHz Arduino Uno, however during the driving it is pretty processor-intensive (and interrupts have to be off). So certainly you can have some smooth effects at 16 MHz. However controlling them in real time, via Bluetooth, may be a different thing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NeoPixels will &quot;remember&quot; the last thing that was sent to them, so (when interrupts are active) you could be accepting new instructions, and the pixels will just display what they were last sent. This may be acceptable for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.adafruit.com/products/1138&quot; rel=&quot;nofollow&quot;&gt;Adafruit page&lt;/a&gt; for RGB LED Strip mentions that their library is only for the AVR processors. So that may be a consideration for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even with other display strips, you may find that, during reception of radio signals, the strips cannot alter their patterns at high speed. The 72 MHz you quoted is only 4.5 times as fast as 16 MHz. The NeoPixel timings are in the order of nanoseconds (350 ns for a zero-bit) so timing is tight. Having 4.5 x the clock speed isn't necessarily going to give you enough leeway to do radio communications.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I just want to be able to select and change the program remotely via BLE, rather than send sequential commands over air. Does this change your answer at all? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your design seems to me to consist of two components:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Showing some pattern&lt;/li&gt;&#xA;&lt;li&gt;Receiving a new pattern (or code for a new pattern)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can't be doing both at precisely the same time. (Maybe with two processors you might - one doing the radio, and one displaying the pixel pattern). I found I could refresh 1000 pixels in 63 ms, which is roughly 16 FPS. If you have less pixels it will be faster. I don't know exactly how long it takes to determine if a Bluetooth message has arrived, I assume not particularly long.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Planning on 3M of 60LED/M WS2812B strip as of now&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, 180 pixels. At 63 µs per pixel that would be 11.3 ms to refresh the strip. You can see that this gives you quite a bit of time over in one second to receive new instructions.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-03T10:54:23.503" LastActivityDate="2016-04-03T10:54:23.503" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22650" PostTypeId="2" ParentId="21374" CreationDate="2016-04-03T06:56:15.020" Score="0" Body="&lt;p&gt;There is no Proteus Library for HC05. (Not one I know of.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, your HC05 is a serial device i.e. it acts as a &lt;strong&gt;Serial monitor&lt;/strong&gt;. and fortunately there is &lt;strong&gt;Serial Monitor&lt;/strong&gt; in Proteus. You can use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=bwViKGjCO2Y&quot; rel=&quot;nofollow&quot;&gt;Here, Have a look.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. if you are using ISIS 7.x. there is a thing to be noted. You have placed a &lt;strong&gt;serial monitor&lt;/strong&gt; and connected to arduino and you started execution and its working fine. Now, what happens sometimes is that when you stop execution and start again, serial monitor might not work. No need to worry about. Stop execution, delete that serial monitor and place a new.That will work.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-03T06:56:15.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22651" PostTypeId="1" CreationDate="2016-04-03T07:04:30.003" Score="-2" ViewCount="6706" Body="&lt;p&gt;I am using an LCD (16x2) with an Arduino Uno R3, in for that I need a 10 k&amp;Omega; potentiometer, but I don't have it now. How can I replace that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have resistors of many kinds and a 1 k&amp;Omega; potentiometer.&lt;/p&gt;&#xA;" OwnerUserId="19413" LastEditorUserId="6936" LastEditDate="2016-04-17T04:17:09.910" LastActivityDate="2017-01-03T07:20:49.567" Title="How can we replace a 10k potentiometer with resistors?" Tags="|arduino-uno|lcd|potentiometer|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22652" PostTypeId="2" ParentId="22651" CreationDate="2016-04-03T07:08:00.737" Score="0" Body="&lt;p&gt;Try using 9k~1k. (It worked for my 16*2 LCD)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or place 9k in series with 1K and vary that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect 10 of your 1K resistors in series. Connect one end to GND and other end to VCC. Now, you will have 10 different nodes (including VCC and GND) each having a different voltage. Connect your desired input pin to any of those nodes.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="6936" LastEditDate="2016-04-17T04:18:33.083" LastActivityDate="2016-04-17T04:18:33.083" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22656" PostTypeId="2" ParentId="22651" CreationDate="2016-04-03T08:42:18.847" Score="2" Body="&lt;p&gt;Just use your 1k pot in place of the 10k pot. The resistance doesn't matter that much (though you don't want to go loo low or you could draw too much current) since it is just being used as a voltage divider to set an offset point for the LCD.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-03T09:46:20.730" LastActivityDate="2016-04-03T09:46:20.730" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22657" PostTypeId="1" AcceptedAnswerId="22658" CreationDate="2016-04-03T08:43:15.117" Score="1" ViewCount="1299" Body="&lt;p&gt;I have recently decided to buy an arduino over a raspberri pi and have been shopping for a good deal and learning about which model I need and where to buy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have come across a few very cheap arduino uno boards that are identical to every other board. These range from an unbelievable $4-$15. Are they officially branded and/or are they trustworthy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to a few links to some I've found:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://m.ebay.com/itm/New-UNO-R3-ATmega328P-Development-Board-For-Arduino-Compatible-USB-Cable-DIY-/311418263595?nav=SEARCH&quot; rel=&quot;nofollow&quot;&gt;http://m.ebay.com/itm/New-UNO-R3-ATmega328P-Development-Board-For-Arduino-Compatible-USB-Cable-DIY-/311418263595?nav=SEARCH&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://m.ebay.com/itm/NEW-UNO-R3-ATmega328P-CH340-Mini-USB-Board-for-Compatible-Arduino-WL-/161883302204?nav=SEARCH&quot; rel=&quot;nofollow&quot;&gt;http://m.ebay.com/itm/NEW-UNO-R3-ATmega328P-CH340-Mini-USB-Board-for-Compatible-Arduino-WL-/161883302204?nav=SEARCH&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18907" LastActivityDate="2016-04-04T05:08:37.520" Title="Is cheap away arduino trustworthy" Tags="|arduino-uno|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22658" PostTypeId="2" ParentId="22657" CreationDate="2016-04-03T09:41:16.653" Score="1" Body="&lt;p&gt;Caveat Emptor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it's not genuine you can never be sure quite what you are getting. You have to ask with some of then just how they can make them so cheap. Poor quality components is one way. Either counterfeit or reject components which may fail after a short time, or under certain conditions is a big risk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are different grades of board each with their own risks...&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Genuine. High price, good reliability and quality. Good after sales support. Supports the Arduino cause.&lt;/li&gt;&#xA;&lt;li&gt;Arduino clone. Genuine Arduino design made by a reputable third party. Almost as good as option 1 but doesn't support Arduino financially.&lt;/li&gt;&#xA;&lt;li&gt;Arduino Based. A board created for a specific job that is based around genuine Arduino design. Support really only from the (often smaller) manufacturer. Quality varies.&lt;/li&gt;&#xA;&lt;li&gt;Chinese clone. Low grade components made to original Arduino designs. Little or no support. Poor quality. Often with different USB interface that is unstable and low quality.&lt;/li&gt;&#xA;&lt;li&gt;Counterfeit. Low quality components. Claims to be a genuine Arduino. Bad build quality.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Options 1-3 are ones I would consider buying. 4 and 5 I would stay well away from.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-03T09:41:16.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22659" PostTypeId="1" CreationDate="2016-04-03T10:17:55.063" Score="1" ViewCount="640" Body="&lt;p&gt;have a program that checks to see if an RFID tag has been read, if it has, it runs some code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a count down timer function (timer) that I'd like to run in the background. It displays the clock on the bottom of the LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having is that when I put timer(); in the main loop, the rest of the program is delayed for the duration of the count down which means that no RFID cards are read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timer works, but nothing below timer(); is running. I assume this is because of the use of delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know how I can prevent this? Thank you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;      &#xA;#include &amp;lt;MFRC522.h&amp;gt;  &#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;&#xA;int readflag;&#xA;int initstate = 1;&#xA;&#xA;int nextred = 4;&#xA;int nextblue = 8;&#xA;&#xA;uint8_t readCard[4];           &#xA;&#xA;int minutes = 1; //start min&#xA;int seconds = 0; //start seconds&#xA;&#xA;&#xA;MFRC522 mfrc522(10, 9);&#xA;LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;&#xA;&#xA;///////////////////////////////////////// Setup ///////////////////////////////////&#xA;void setup() {&#xA;&#xA;    //Protocol Configuration&#xA;  Serial.begin(9600);  &#xA;  SPI.begin();           &#xA;  mfrc522.PCD_Init();    &#xA;  mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);&#xA;&#xA;  lcd.begin(20, 4);&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;  // Main loop&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;void loop () {&#xA;&#xA; do {                                                             &#xA;   readflag = checkread(); &#xA;if (initstate == 0) {&#xA;  timer(); //start timer - timer works but nothing below timer(); is running.&#xA;   lcd.setCursor(0,0);&#xA;   lcd.print(&quot;Red team next: &quot;);&#xA;   lcd.print(nextred);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;Blue team next: &quot;);&#xA;    lcd.print(nextblue);&#xA;&#xA;}&#xA;  }&#xA;  while (!readflag); &#xA;  tone(8, 850, 15);&#xA;  recordid();&#xA;  updatenextteamnumbers();&#xA;}&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;  // Function to update team next numbers&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;void updatenextteamnumbers() {&#xA;//If Blue Tag scanned show team info&#xA;  if (*((uint32_t *)readCard) == 0xACB7D573) {&#xA;&#xA;    Serial.println(&quot;Blue Tag detected, showing team info&quot;);&#xA;    initstate=0;&#xA;&#xA;   }&#xA;&#xA;&#xA;//Red Team (sequence 4, 5, 2, 1, 9)&#xA;else if (*((uint32_t *)readCard) == 0x29FDC9F5 &amp;amp;&amp;amp; initstate == 0) {&#xA;    Serial.println(&quot;CARD 4 detected&quot;);&#xA;    nextred = 5;&#xA;&#xA;      }&#xA;&#xA;else if (*((uint32_t *)readCard) == 0x3FCE7832 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 5 detected&quot;);&#xA;    nextred = 2;&#xA;&#xA;}&#xA;&#xA;else if (*((uint32_t *)readCard) == 0x3FCCECE2 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 2 detected&quot;);&#xA;    nextred = 1;&#xA;&#xA;      }&#xA;&#xA;&#xA;  else if (*((uint32_t *)readCard) == 0x3F7AB752 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 1 detected&quot;);&#xA;    nextred = 9;&#xA;&#xA;    //activateredrelay&#xA;&#xA;      }&#xA;&#xA;&#xA;  else if (*((uint32_t *)readCard) == 0x00000000 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 9 detected&quot;);&#xA;    redwins();    &#xA;&#xA;      }&#xA;&#xA;&#xA;&#xA;//Blue Team (sequence 8, 6, 3, 7, 10)&#xA;&#xA;else if (*((uint32_t *)readCard) == 0x00000000 &amp;amp;&amp;amp; initstate == 0) {&#xA;    Serial.println(&quot;CARD 8 detected&quot;);&#xA;    nextblue = 6;&#xA;&#xA;      }&#xA;&#xA;else if (*((uint32_t *)readCard) == 0x00000000 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 6 detected&quot;);&#xA;    nextblue = 3;&#xA;&#xA;}&#xA;&#xA;else if (*((uint32_t *)readCard) == 0x3F7ABA82 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 3 detected&quot;);&#xA;    nextblue = 7;&#xA;&#xA;      }&#xA;&#xA;&#xA;  else if (*((uint32_t *)readCard) == 0x00000000 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 7 detected&quot;);&#xA;    nextblue = 10;&#xA;&#xA;    //activatebluerelay&#xA;&#xA;      }&#xA;&#xA;&#xA;  else if (*((uint32_t *)readCard) == 0x00000000 &amp;amp;&amp;amp; initstate == 0) {&#xA;&#xA;    Serial.println(&quot;CARD 10 detected&quot;);&#xA;    bluewins();    &#xA;&#xA;      }&#xA;&#xA; }&#xA;&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;  // Stores the ID of the card that's been detected in readCard byte array&#xA;///////////////////////////////////////////////////////////////////////////////&#xA;void recordid() {&#xA;    mfrc522.PICC_IsNewCardPresent();&#xA;    mfrc522.PICC_ReadCardSerial();&#xA;&#xA;    for (int i = 0; i &amp;lt; mfrc522.uid.size; i++) { &#xA;        readCard[i] = mfrc522.uid.uidByte[i];  &#xA;        Serial.print(mfrc522.uid.uidByte[i], HEX);&#xA;        }&#xA;Serial.println(&quot;&quot;);&#xA;    mfrc522.PICC_HaltA();&#xA;  }&#xA;&#xA;&#xA;/////////////////////////////////////////////&#xA;  // Returns 1 if a card has been detected&#xA;/////////////////////////////////////////////&#xA;int checkread() {&#xA;   if ( ! mfrc522.PICC_IsNewCardPresent()) { &#xA;    return 0; }                                        //no card detected&#xA;&#xA;    mfrc522.PICC_HaltA(); &#xA;    return 1; }                                       //card detected&#xA;&#xA;&#xA;/////////////////////////////////////////////&#xA;  // Runs if red team wins&#xA;/////////////////////////////////////////////&#xA;void redwins() {&#xA;      lcd.clear();&#xA;      lcd.setCursor(0,0); &#xA;      lcd.print(&quot;Red team wins!&quot;);&#xA;      lcd.display();&#xA;      Serial.println(&quot;Red team wins!&quot;);&#xA;      delay(36000);&#xA;}&#xA;&#xA; /////////////////////////////////////////////&#xA;  // Runs if blue team wins&#xA;/////////////////////////////////////////////&#xA;void bluewins() {&#xA;      lcd.clear();&#xA;      lcd.setCursor(0,0); &#xA;      lcd.print(&quot;Blue team wins!&quot;);&#xA;      lcd.display();&#xA;      Serial.println(&quot;Blue team wins!&quot;);&#xA;      delay(36000);&#xA;}&#xA;&#xA;&#xA; /////////////////////////////////////////////&#xA;  // Count down timer&#xA;/////////////////////////////////////////////&#xA;void timer() {&#xA;lcd.setCursor(0,3);&#xA;  lcd.print(&quot;Time left:&quot;);&#xA; while (minutes &amp;gt; 0 || seconds &amp;gt;= 0) {&#xA;  lcd.setCursor(15, 3);&#xA; (minutes &amp;lt; 10) ? lcd.print(&quot;0&quot;) : NULL;&#xA; lcd.print(minutes);&#xA; lcd.print(&quot;:&quot;);&#xA; (seconds &amp;lt; 10) ? lcd.print(&quot;0&quot;) : NULL;&#xA; lcd.print(seconds);&#xA; lcd.display();&#xA; decrement();&#xA; delay(1000);&#xA; }&#xA;}&#xA;&#xA; /////////////////////////////////////////////&#xA;  // Decrement timer&#xA;/////////////////////////////////////////////&#xA;void decrement() {&#xA;      if (seconds &amp;gt; 0) {&#xA;          seconds -= 1;&#xA;      } &#xA;      else      {&#xA;         if (minutes &amp;gt; 0) {&#xA;           seconds = 59;&#xA;           minutes -= 1;&#xA;          } &#xA;          else  {&#xA;            timeup();&#xA;          }&#xA;       }&#xA;}&#xA;&#xA; /////////////////////////////////////////////&#xA;  // Called when time expires&#xA;/////////////////////////////////////////////&#xA;void timeup() {&#xA;      lcd.clear();&#xA;      lcd.setCursor(0,0); &#xA;      lcd.print(&quot;Time up!&quot;);&#xA;      lcd.display();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19851" LastActivityDate="2018-01-05T23:56:01.490" Title="Arduino countdown timer preventing rest of program running" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22661" PostTypeId="2" ParentId="22651" CreationDate="2016-04-03T10:59:38.583" Score="1" Body="&lt;p&gt;Derived from Ohm's Law:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;R = R1 + R2 + ... + Rn (For resistors in Series)&lt;/li&gt;&#xA;&lt;li&gt;(1/R) = (1/R&lt;sub&gt;1&lt;/sub&gt;) + (1/R&lt;sub&gt;2&lt;/sub&gt;) + ... + (1/R&lt;sub&gt;n&lt;/sub&gt;) (For resistors in Parallel)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can use any resistance from 1k to 10k with your LCD but the actual value depends on your choice and preferences. You may start with 5k and if you have one then its allright. But if you do not have a resistor of that value you can join resistors of lower values in &lt;strong&gt;series&lt;/strong&gt; with your 1k POT to get resistance of 5k ~ 6k.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In such a way you may get a variable resistance (1k pot) with a suitably high value (other resistors in series). If you wish, you may add more resistors to get higher values like 8k ~ 9k and so on.&lt;/p&gt;&#xA;" OwnerUserId="19853" LastEditorUserId="19853" LastEditDate="2017-01-03T07:20:49.567" LastActivityDate="2017-01-03T07:20:49.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22662" PostTypeId="1" AcceptedAnswerId="22663" CreationDate="2016-04-03T12:46:15.803" Score="1" ViewCount="2773" Body="&lt;p&gt;&lt;em&gt;Please mind that this is an &quot;example&quot; question.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to make a &quot;tiny arduino&quot;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've ordered a bunch of ATtiny85's off E-bay, they're like tiny Arduino's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've set up the &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;latest Arduino IDE&lt;/a&gt; and would like to run the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow noreferrer&quot;&gt;blink example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My process so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wiring&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X5RjA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X5RjA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The blink example)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);              // wait for a second&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-04-03T19:17:53.387" Title="How do I use an AtTiny85 (or other AtTiny) with Arduino?" Tags="|arduino-ide|attiny|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22663" PostTypeId="2" ParentId="22662" CreationDate="2016-04-03T12:46:15.803" Score="1" Body="&lt;p&gt;&lt;strong&gt;1. The Tiny&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATtiny differs a little from the Arduino, don't expect it to be &quot;fully compatible&quot;. It's a microcontroller which is just a part of an Arduino and not a full Arduino itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's more of a device for &quot;advanced users&quot; and gives some more flexibility (at cost of usability). You can easily add this microcontroller on a breadboard, since putting a full Arduino on a breadboard makes little sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;1.1 USB?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ATtiny is a microcontroller (like the ATmega on an Arduino) and not a development board (as an Arduino), it does not have an USB connector.&#xA;The ATtiny series also does not have hardwareUART (Rx/Tx). The &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to take care for a steady power-supply to your Microcontroller and the programming will be a little more tricky (details further below).&#xA;It is however possible to use &lt;code&gt;SoftwareSerial&lt;/code&gt; and a customized bootloader. My ATtiny85 runs software serial with 115200 fine, though I have found a post which states that the internal oscillator &lt;a href=&quot;http://www.ernstc.dk/arduino/tinycom.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;should be tuned&lt;/a&gt; for a reliable connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;1.2 RAM/program memory&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATtiny has less RAM and program memory. This essentially means your program can't be as 'big' as on a normal Arduino. It also means that you can't use as much variables. A program for the tiny should be &quot;small&quot; or very efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;1.3 &quot;Speed&quot;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ATtiny came with 1Mhz internal clock set, but if you change the fuse bits you can make it run at 8Mhz. An standard Arduino has a 16Mhz clock on the board. So your code would run 16x slower on default and 2x slower on &quot;max&quot;. You could use an external clock for the ATtiny, but that eats up 2 pins.&#xA;The cool thing is, when you set it to 1Mhz it can run on about 2.7V (check datasheet first).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino                   16Mhz&#xA;ATtiny (standard)         1Mhz&#xA;ATtiny (set fuses)        8Mhz&#xA;ATtiny (external crystal) up to 20Mhz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Higher Mhz is faster. Keep in mind that 1Mhz is roughly 1000000 instructions per second, which is still blazingly fast and good enough for most occasions, especially on such a tiny device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. Programming the Tiny&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the ATtiny's don't come with a customized (software serial) Arduino bootloader. This essentially means that you have to burn a custom bootloader by yourself or use another type of programmer. You should really watch &lt;a href=&quot;https://youtu.be/ncobWc61wL4&quot; rel=&quot;nofollow noreferrer&quot;&gt;the video&lt;/a&gt; from Ben Heck. He explains that Arduino boards have an USB converter on board and have custom code that is able to &quot;bootload&quot; your Arduino. But that ICSP/ISP programmers are used to upload programs without a bootloader/uart connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;2.1 The programmer&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've got a load of options, check the &quot;Programmer&quot; item in the &quot;tools&quot; tab in your Arduino IDE. I'm using an USBasp which can be bought on &lt;a href=&quot;http://www.ebay.nl/itm/USBASP-USBISP-3-3V-5V-AVR-Programmer-USB-ATMEGA8-/261021924011&quot; rel=&quot;nofollow noreferrer&quot;&gt;ebay for as little as 3€&lt;/a&gt;. You should get one that has a selectable voltage (3.3V and 5V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(If your ATtiny85 already has the bootloader, which is unlikely, you can use the software rx/tx pins for uploading)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;2.2 Preparation&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check your microcontroller if it really is a ATtiny85 my E-bay reseller actually had one ATtiny45 included, which lead to an &quot;error&quot; when trying to upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE does not know the &quot;ATtiny board&quot; so you can't select it easily. You'll have to let the IDE know that the ATtiny can also be programmed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a very &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow noreferrer&quot;&gt;nice tutorial&lt;/a&gt; that describes how to do this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Open the preferences dialog in the Arduino software. Find the&#xA;  “Additional Boards Manager URLs” field near the bottom of the dialog.&lt;/li&gt;&#xA;  &lt;li&gt;Paste the following URL into the field (use a comma to separate it from any URLs you’ve already added):&#xA;  &lt;a href=&quot;https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;Click the OK button to save your updated preferences.&lt;/li&gt;&#xA;  &lt;li&gt;Open the boards manager in the “Tools &gt; Board” menu.&lt;/li&gt;&#xA;  &lt;li&gt;Scroll to the bottom of the list; you should see an entry for “ATtiny”.&lt;/li&gt;&#xA;  &lt;li&gt;Click on the ATtiny entry. An install button should appear. &lt;/li&gt;&#xA;  &lt;li&gt;Click the install button. The word “installed” should now appear next to the title of the ATtiny entry.&lt;/li&gt;&#xA;  &lt;li&gt;Close the boards manager. You should now see an entry for ATtiny in the “Tools &gt; Board” menu.&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;2.3 Changing the internal clock&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=85033.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;interesting post I found&lt;/a&gt; told me that you can change the internal clock/oscillator to 8Mhz by selecting 8Mhz (internal) as the clock and pressing the &quot;Burn bootloader&quot; button. This won't flash a bootloader (since that makes little sense on a Tiny85) but does change the fuse-bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;2.4 Code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll not get away with the standard blink tutorial. It uses digital pin 13 (the tiny only has 8 pins).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind that you might have to upload using Ctrl+Shift+U (or sketch-&gt;Upload with programmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the diagram below to check the pins (from highlowtech.org)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kIjxX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kIjxX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/GT4rK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GT4rK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3. Hardware&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your &quot;schematic&quot; isn't complete, I don't see a way to program or power the microcontroller. And you might want to take some precautions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally think a well-drawn schematic looks better as a &quot;breadboard view&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4uKJR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4uKJR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 10Kohm pull-up resistor on the reset pin is not 100% neccesary according to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=20219.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;the datasheet&lt;/a&gt;. But the Uno has one in it's reference design (which I use as a reference).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two capacitors, one &quot;big&quot; capacitor as a reservoir. If one device suddenly pulls a lot of current, this capacitor will handle that. The smaller decoupling capacitor will damp the noise of other IC's or switching supplies. It may work withouth these, but your circuit will be more reliable with them.&#xA;Mind that the decoupling capacitor should be (physically) close to the IC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can power the board through the programming header, but mind that you'll need a smooth voltage between (most likely) 3.3V and 5V. If you want to power it with a bigger voltage (9V battery) then you'll need a voltage regulator.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-03T19:17:53.387" LastActivityDate="2016-04-03T19:17:53.387" CommentCount="3" CommunityOwnedDate="2016-04-03T19:23:52.143" ContentLicense="CC BY-SA 3.0" />
  <row Id="22668" PostTypeId="2" ParentId="22642" CreationDate="2016-04-03T13:40:21.183" Score="0" Body="&lt;p&gt;You have to set your requirements, or atleast elaborate what you want to achieve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best would be to program in a set amount of effects on the microcontroller and only send which effect you want to &quot;start&quot; with maybe even a color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you have to specify stuff, you should make a list like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Length of messages&#xA;(Max) baudrate of bluetooth device &amp;amp; microcontroller&#xA;&#xA;amount of bits in the total LED strip&#xA;speed of sending bits into the LED strip&#xA;&#xA;Maximal time from sending to effect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sample calculation for NeoPixel (WS2182)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can make a good approximation (or find actual values) you can determine which speed you are going to need. This might even be 1Mhz, try to avoid &lt;a href=&quot;http://c2.com/cgi/wiki?PrematureOptimization&quot; rel=&quot;nofollow&quot;&gt;premature optimization&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;60 leds/m for 3M = 180 leds.&#xA;24bit data per LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;180*24 = 4320 bits of data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One bit takes around 1,3uS, so 4320*1,3 = 5616 uS&#xA;Which is 5,616 milliseconds to update the LED strip. (Processor Mhz won't help you here)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sample calculation for DotStar (APA102)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;180 leds, 32bit per LED = 5.760 bits total.&#xA;+64 bits (32bit start frame, 32bit end frame).&#xA;5824 total bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can set the SPI clock divider to 2.&#xA;So if your board runs at 16Mhz, divided by 2, you get 8Mhz SPI output.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;8 megahertz = 8 000 000 hertz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(EDIT)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The fastest rate is &quot;divide by 2&quot; or one SPI clock pulse every 125 nS. - Nick Gammon (&lt;a href=&quot;http://www.gammon.com.au/spi&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/spi&lt;/a&gt;)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Neopixels take 0.85us + 0.4us = 1,25 us (1250ns).&#xA;So they would be 10x slower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(never mind this calculation, it was from before using Nicks' facts)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;8.000.000  |  5824&#xA; 1 sec     |   x&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Your x value will be the time in seconds to update the DotStar strip with SPI@8Mhz)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What was your point?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this you can check your baudrate + message length to see how long sending/receiving your message will take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then reliably tell if you need 1, 8, 16 or 72Mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe the DotStar led strips should be faster, but I haven't completely calculated it out. You could ask yourself if it's worth trying to omptimize that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT, note that the DotStar/SPI led strip allows you to have &quot;interrupts&quot;. Which means you can receive characters over the bluetooth while you're writing to the LED strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, we're probably overthinking the situation. But it's better to overthink it using hard values :)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-03T13:57:42.300" LastActivityDate="2016-04-03T13:57:42.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22669" PostTypeId="2" ParentId="22659" CreationDate="2016-04-03T15:24:38.780" Score="1" Body="&lt;p&gt;Of course not - your timer() function is &lt;strong&gt;blocking&lt;/strong&gt; meaning that it does not return, and so does not permit anything else to execute, until its timing is completely done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to re-design your program.  Some options include:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Capturing an initial timestamp from millis() and comparing to it on each iteration through loop() to decide when your time has approximately elapsed, and to update the display with an appropriate value if that point is not yet reached. This is probably the best choice for your application, but be aware that after about 50 days of uptime, the difference calculation can be briefly incorrect, unless you account for overflow.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Place a short delay in the main loop (maybe 100 ms), and count iterations of the main loop until you have reached your desired time.  Beware though that your effective time will become longer if other parts of the loop take time (especially variable amounts of it) to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Set up an event timer in the background with interrupts.  This is a lot more complex and probably not advisable in your application.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-03T15:24:38.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22670" PostTypeId="2" ParentId="22587" CreationDate="2016-04-03T16:09:23.353" Score="1" Body="&lt;p&gt;You're trying to do too much (SD and Serial print operations) at the wrong time (GPS character receiving).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most GPS devices will send several &quot;sentences&quot; per second, in a batch.  &lt;code&gt;TinyGPS.encode&lt;/code&gt; returns &lt;code&gt;true&lt;/code&gt; after &lt;em&gt;each&lt;/em&gt; sentence, so your code will try to write multiple sentences per second to the SD card.  But it takes so long to open/write/close the SD card (and print to &lt;code&gt;Serial&lt;/code&gt;) that the input buffer fills up and overflows.  &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Troubleshooting.md#quiet-time-interval&quot; rel=&quot;nofollow&quot;&gt;Here's&lt;/a&gt; a detailed description of what is happening.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must wait until the GPS &quot;quiet time&quot; begins.  Even then, you could have trouble, depending on how much data you need to save and print.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It may be possible to make it work with TinyGPS, but I eventually gave up in frustration and wrote the &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt; library to help address these problems.  It can be configured to save just the data you need (via the &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Configurations.md&quot; rel=&quot;nofollow&quot;&gt;configuration files&lt;/a&gt;), and it can be used to detect when the quiet time begins (see NMEAorder.ino and NMEAfused.ino).  It &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/RAM.md&quot; rel=&quot;nofollow&quot;&gt;uses much less RAM&lt;/a&gt; and &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Performance.md&quot; rel=&quot;nofollow&quot;&gt;takes much less time&lt;/a&gt; to parse the GPS characters.  This will be important if you try to add the Ethernet libraries to the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still have trouble getting all the information written during the quiet time, you can use a companion library (e.g., &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoSWSerial&lt;/a&gt;) to handle the GPS characters &lt;em&gt;during&lt;/em&gt; the RX interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, I would suggest replacing &lt;code&gt;SoftwareSerial&lt;/code&gt; with &lt;code&gt;NeoSWSerial&lt;/code&gt;.  It, too, is much more efficient than the CPU-killer &lt;code&gt;SoftwareSerial&lt;/code&gt;.  It won't fix the main problem, but it will pay off later.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-04-03T16:09:23.353" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="22671" PostTypeId="1" CreationDate="2016-04-03T16:24:59.670" Score="0" ViewCount="967" Body="&lt;p&gt;So, I'd like to put a button between input and output pins to read when button is pressed. What minimal resistance should I add to the scheme not to burn Arduino when the button is pressed? Does this value depend on Arduino model?&lt;/p&gt;&#xA;" OwnerUserId="16944" LastActivityDate="2016-04-04T04:12:06.187" Title="What minimal resistance should be between an input and output pin not to burn Arduino?" Tags="|voltage-level|current|voltage-protection|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22672" PostTypeId="1" AcceptedAnswerId="22673" CreationDate="2016-04-03T16:53:16.590" Score="-1" ViewCount="208" Body="&lt;p&gt;Are input and output pins not supposed to have current through them and only either apply voltage or &quot;measure&quot; it?&lt;/p&gt;&#xA;" OwnerUserId="16944" LastEditorUserId="16944" LastEditDate="2016-04-03T22:19:25.190" LastActivityDate="2016-04-04T04:02:42.450" Title="Is that correct that input and output pins are not supposed to have current through them?" Tags="|voltage-level|current|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22673" PostTypeId="2" ParentId="22672" CreationDate="2016-04-03T17:06:20.077" Score="3" Body="&lt;p&gt;An output pin (on an AVR 8-bit board like an Arduino Uno) can pass up to 40mA (&lt;em&gt;absolute maximum&lt;/em&gt;). It is recommended not to exceed 25mA.  This is called &lt;em&gt;sinking current&lt;/em&gt; when the output pin is set to LOW, and &lt;em&gt;sourcing current&lt;/em&gt; when it is set to HIGH.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An input pin is what is known as &lt;em&gt;high impedance&lt;/em&gt;. I.e., it looks, to the circuit connected to the pin, like an incredibly high value resistor connected between the input and ground. Because of that only very tiny currents will ever flow through it (unless you do something silly like plug it direct into the mains).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-03T18:09:46.547" LastActivityDate="2016-04-03T18:09:46.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22674" PostTypeId="2" ParentId="22672" CreationDate="2016-04-03T17:16:24.903" Score="3" Body="&lt;p&gt;First, you can not apply a voltage to or with an I/O pin connected to a circuit, and have no current flow as a result. There is a limit to the current a given pin on a given device can pass without damage and that is specified in the device's datasheet. How much current a given pin and circuit will pass or try to pass depends on the external circuit and the circuit internal to the device. Majenko's answer (except possibly for the specific limits, depending on the device) is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't specified what device. Is this a generic question or is it specific to the AVR micro-controllers used in most Arduino boards? If the latter, the limits in @Majenko's answer are also correct.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-03T17:16:24.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22675" PostTypeId="2" ParentId="22671" CreationDate="2016-04-03T18:19:46.420" Score="1" Body="&lt;p&gt;Looking towards the high end of recommended (vs absolute maximum) current and considering Ohm's law at a 5v difference if two outputs are trying to drive each other to opposite values, you would probably get away with as little as 250 ohms.  But in most cases that would needlessly waste power, and in the case of multiple instance you could start totaling towards the limit of power supply current for the chip overall.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical values for external pull up resistors are more in the range of 1K-10K though higher is not uncommon - the internal pullup which you can optionally activate by setting the output state of an &lt;em&gt;input&lt;/em&gt; pin high has a value of several tens of kilo ohms.  Lower values will consume more power, higher values may be less reliable in a noisy situation.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-03T18:19:46.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22677" PostTypeId="1" CreationDate="2016-04-03T20:19:43.693" Score="0" ViewCount="1103" Body="&lt;p&gt;I bought a 3 pin buzzer. It has positive, negative and signal pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand how this signal pin should be connected with the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.techshopbd.com/product-categories/modules-98775/1690/digital-buzzer-module-techshop-bangladesh&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is reported the description page of the buzzer.&lt;/p&gt;&#xA;" OwnerUserId="19864" LastEditorUserId="19515" LastEditDate="2016-04-04T13:22:34.210" LastActivityDate="2016-04-04T13:22:34.210" Title="Signal pin of buzzer is connected with which Arduino uno pin" Tags="|arduino-uno|buzzer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22678" PostTypeId="2" ParentId="22677" CreationDate="2016-04-03T20:32:05.743" Score="1" Body="&lt;p&gt;As I have read in the page you have linked, I think you should program the Arduino to provide an impulse to the signal (&lt;code&gt;s&lt;/code&gt;) pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, to answer your question you can use any digital pin of the Arduino. And I guess that as long as the impulse last as long as the buzzer will produce a sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here an example of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buzzPin =  2;    //Connect Buzzer on Digital Pin3 &#xA;void setup()   &#xA;{         &#xA; pinMode(buzzPin, OUTPUT);      &#xA;} &#xA; void loop()                      &#xA;{ &#xA; digitalWrite(buzzPin, HIGH); &#xA; delayMicroseconds(50); &#xA; digitalWrite(buzzPin, LOW);  &#xA; delayMicroseconds(50);    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19515" LastActivityDate="2016-04-03T20:32:05.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22679" PostTypeId="2" ParentId="5008" CreationDate="2016-04-03T20:39:07.920" Score="1" Body="&lt;p&gt;I Have The Same Problem.&#xA;But First Of All you have to set your modem Network Band according to your cellular Network Band.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GSMBand band;&#xA;String newBand= &quot;GSM_MODE_EGSM_DCS&quot;;// Your Band In My case That was &#xA;  band.begin();&#xA;  Serial.println(&quot;Modem restarted.&quot;);&#xA;  String bandName = band.getBand(); // Get and print band name&#xA;  Serial.print(&quot;Current band:&quot;);&#xA;  Serial.println(bandName);&#xA;&#xA;band.setBand(newBand);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Band Help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  GSM_MODE_EGSM                ---- E-GSM(900)&#xA;  GSM_MODE_DCS                 ---- DCS(1800)&#xA;  GSM_MODE_PCS                 ---- PCS(1900)&#xA;  GSM_MODE_EGSM_DCS            ---- E-GSM(900)+DCS(1800) ex: Europe&#xA;  GSM_MODE_GSM850_PCS          ---- GSM(850)+PCS(1900) Ex: USA, South Am.&#xA;  GSM_MODE_GSM850_EGSM_DCS_PCS ---- GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then You Have To use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gsm.access.begin();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19865" LastEditorUserId="19515" LastEditDate="2016-04-04T13:21:59.957" LastActivityDate="2016-04-04T13:21:59.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22680" PostTypeId="1" CreationDate="2016-04-03T21:00:23.090" Score="2" ViewCount="556" Body="&lt;p&gt;I have the following problem: for some *** reason, my LCD is flashing when my fingerprint scanner turns on. Here is a video of the behavior: &lt;a href=&quot;https://www.dropbox.com/s/mqk4u0vu8yvhiwz/IMG_3171.m4v?dl=0&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/mqk4u0vu8yvhiwz/IMG_3171.m4v?dl=0&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details: I have a membrane keypad. When I start typing on it, the LCD turns on, and when I type the correct code, the fingerprint scanner turns on, and the LCD prompts the user to press a finger upon the scanner. However, then the LCD backlight starts flashing badly. Interestingly, if I just plug the wall adapter into the arduino and try the scenario, the LCD does not flash. However, if let's say 10-15 have passed since the adapter is plugged in, the LCD flickering becomes visible and irritating (again, when the fingerprint scanner is turned on). So, what could be the reason and how to fix it? Why if I just plug the adapter and execute the scenario, the LCD does not flash, and if I wait some time with the adapter plugged in, and then execute the scenario, the LCD flickers?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to add: My fingerprint scanner is GT511C1R (&lt;a href=&quot;https://www.sparkfun.com/products/13007&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/13007&lt;/a&gt;) and I am using the standard scheme for wiring it (560/1000 ohm for the RX). I am not using lcd.clear() command as I know it's heavy, and even if I don't write any text, the still LCD flickers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best regards,&#xA;Nike&lt;/p&gt;&#xA;" OwnerUserId="19868" LastActivityDate="2016-04-26T09:18:43.693" Title="Flickering LCD backlight with fingerprint scanner" Tags="|lcd|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22681" PostTypeId="2" ParentId="22677" CreationDate="2016-04-03T21:11:20.697" Score="1" Body="&lt;p&gt;Usually a buzzer only has two wires, positive and negative. The module you have bought though uses a transistor to drive the buzzer, which is a nice thing for very low power boards, which is not your case I believe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, the module will take power from the positive and negative connections, allowing you to control it via the signal, from which very little power is drained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does a buzzer work? Actually to emit a sound via a buzzer you have to send a series of electrical pulses to the signal pin. The number of pulses per second (frequency, expressed in hertz, Hz) will determine the tone of the sound. higher the frequency, higher the pitch of the sound emitted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Human ear is capable to detect frequencies between 20 and 20000Hz, but not everybody has such a broad perception, it decreases with age and not everybody is born with full range, so I advice to stay in the 2000-15000Hz range.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a nice library called &lt;a href=&quot;https://www.arduino.cc/en/Reference/Tone&quot; rel=&quot;nofollow&quot;&gt;Tone&lt;/a&gt; which helps you generate the correct signal for specific notes, allowing to even play some music via the buzzer (don't expect polyphony though!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, to play a note on your buzzer, assuming you have the buzzer signal pin tied to digital pin 6, you can just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { /* empty */ }&#xA;&#xA;void loop() {&#xA;    noTone(6);&#xA;    // play a note on pin 6 for 200 ms:&#xA;    tone(6, 440, 200);&#xA;    delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also have a look at &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ToneMelody&quot; rel=&quot;nofollow&quot;&gt;ToneMelody&lt;/a&gt; if you wish to emit specific notes (each note has its own particular frequency)&lt;/p&gt;&#xA;" OwnerUserId="19867" LastActivityDate="2016-04-03T21:11:20.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22682" PostTypeId="2" ParentId="20773" CreationDate="2016-04-03T21:20:58.330" Score="1" Body="&lt;p&gt;More than probably your level shifter is not fast enough.&#xA;A level shifter uses a mosfet to copy signals from one voltage level to the other, but each mosfet has a latency or, if you prefer, a rise time.&#xA;Your board probably doesn't use a fast switching mosfet and so the SPI protocol (which is a quite fast one) is not &lt;em&gt;copied&lt;/em&gt; correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that you &lt;strong&gt;actually don't need a level switcher&lt;/strong&gt; for the nRF24 modules: the power pin must be limited to 3.3V, but the signal pins are 5V tolerant. &#xA;This means you only need a 3.3V voltage source and all the remaining connections can go directly (and safely) into your Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;: the speed concept still applies, it doesn't matter which side of the connection you are using. A mosfet has a little capacitance which &lt;em&gt;slows&lt;/em&gt; down the signal transmission: higher the capacitance, slower the maximum data rate.&#xA;The cheap chinese level shifter is not designed for high speed communication, while the Texas Instrument device is clearly designed for high speed.&#xA;If you look at the SN74HCT245 datasheet you'll notice the switching speed is reported for 50pF capacitance and ranges from 8ns to 16ns: that's the time needed to build enough charge in the switching circuit.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/3Um6i.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3Um6i.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19867" LastEditorUserId="19867" LastEditDate="2016-04-04T23:57:10.510" LastActivityDate="2016-04-04T23:57:10.510" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22683" PostTypeId="2" ParentId="22262" CreationDate="2016-04-03T21:40:00.793" Score="0" Body="&lt;p&gt;For programming a Pro Mini, I find the CP2104 adaptor works better than the FTDI or PL2303 based units, on both Mac and PC. You can find the CP2104 adaptor from many sources, such as TxHang Electronic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/USB-2-0-TTL-UART-6PIN-Module-Serial-Converter-CP2104-STC-PRGMR-Replace-CP2102-/200958955841?hash=item2eca165141&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/USB-2-0-TTL-UART-6PIN-Module-Serial-Converter-CP2104-STC-PRGMR-Replace-CP2102-/200958955841?hash=item2eca165141&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You may need to install CP2104 software drivers on some platforms)&#xA;This is how I wire them together:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;CP2104_________PRO MINI&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;DTR------------DTR&lt;/li&gt;&#xA;&lt;li&gt;3.3V--------- - * NOT USED (VCC)&lt;/li&gt;&#xA;&lt;li&gt;5V --------- - -* NOT USED  (VCC)&lt;/li&gt;&#xA;&lt;li&gt;TXD------------RXD&lt;/li&gt;&#xA;&lt;li&gt;RXD------------TXD&lt;/li&gt;&#xA;&lt;li&gt;GND-----------GND&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: * While you may be able to power your (unloaded) Pro Mini from your CP2104 adaptor, it's better to use a separate supply that is appropriate for the version of the Pro Mini you use. Good luck. /DerrickA&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19870" LastActivityDate="2016-04-03T21:40:00.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22684" PostTypeId="1" AcceptedAnswerId="22699" CreationDate="2016-04-03T21:46:19.823" Score="1" ViewCount="755" Body="&lt;p&gt;I would like to micromize my Arduino project and move it to ATTiny85. The first step was using sleep functions because I just want it to run once a day. Now I need to connect the 433Mhz stuff but I'm getting into a fight with cores vs. libraries vs. missing functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No matter what core and library combination I pick, there always seems to be something missing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/thijs/Documents/Arduino/libraries/VirtualWire/VirtualWire.cpp:260:18: error: 'WGM12' was not declared in this scope&#xA;     TCCR1B = _BV(WGM12) | _BV(CS10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried &lt;code&gt;Tiny&lt;/code&gt; cores, &lt;code&gt;high lowtech&lt;/code&gt; cores and Manchester and VirtualWire libraries. I don't want to dive into the libraries and make them 'suitable' for ATTiny because I have more than one project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I approach this dependency problem? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;[&lt;strong&gt;edit&lt;/strong&gt;]&lt;br&gt;&#xA;Found a better core here:&#xA;&lt;a href=&quot;https://github.com/SpenceKonde/ATTinyCore&quot; rel=&quot;nofollow&quot;&gt;https://github.com/SpenceKonde/ATTinyCore&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14790" LastEditorUserId="14790" LastEditDate="2016-04-03T22:09:16.413" LastActivityDate="2016-04-04T07:14:23.300" Title="ATTiny85 433Mhz with sleep" Tags="|attiny|sleep|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22685" PostTypeId="2" ParentId="22422" CreationDate="2016-04-03T22:34:37.123" Score="0" Body="&lt;p&gt;Looking at your output either you have a wrong wiring or, more probably, you need a capacitor between the nRF24 positive and negative pins: anything between 10uF and 100uF will do.&lt;/p&gt;&#xA;" OwnerUserId="19867" LastActivityDate="2016-04-03T22:34:37.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22686" PostTypeId="2" ParentId="5058" CreationDate="2016-04-03T22:43:54.380" Score="0" Body="&lt;p&gt;If you set pipe 1 to a common address (let's call it the broadcast address) anytime you send a packet to that address all the modules will receive it on that pipe! &#xA;It's as simple as that, but you will not be able to use auto-ack (you will receive multiple acks, one per each receiver) and you can't also use ack payloads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a series of &lt;a href=&quot;https://rlogiacco.wordpress.com/2015/09/21/nrf24-walk-through-introduction/&quot; rel=&quot;nofollow&quot;&gt;blog posts&lt;/a&gt; on this modules and I'm going to keep writing on the topic.&lt;/p&gt;&#xA;" OwnerUserId="19867" LastActivityDate="2016-04-03T22:43:54.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22687" PostTypeId="1" AcceptedAnswerId="22689" CreationDate="2016-04-04T01:54:29.843" Score="4" ViewCount="10834" Body="&lt;p&gt;I'm making touch-sensitive, light up tic-tac-toe board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means 9 LEDs + 9 capacitive sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each LED needs 1 pin and each sensor needs 2...meaning I'd need 27 pins to properly control each touch-and-illuminate sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There aren't enough inputs on the Uno for this, so what sort of workarounds should I explore to pull this off?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-04-06T13:32:12.550" Title="Not enough pins on Uno?" Tags="|arduino-uno|sensors|led|pins|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22688" PostTypeId="1" CreationDate="2016-04-04T02:14:59.803" Score="0" ViewCount="42" Body="&lt;p&gt;I assembled the following sparkfun redboard: &lt;strong&gt;&lt;a href=&quot;https://www.sparkfun.com/products/retired/10776&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/retired/10776&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug the board in it start to blink but increasingly fast until the LED stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm very new to this and not sure what could be the issue or what to look. Any tips on how to debut this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are images of the assembled board:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UDcfG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UDcfG.jpg&quot; alt=&quot;Front&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/M1gpc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M1gpc.jpg&quot; alt=&quot;Back&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19871" LastEditorUserId="19871" LastEditDate="2016-04-05T03:32:13.020" LastActivityDate="2016-06-05T02:52:35.163" Title="Assembled redboard PTH kit, when I turn it on the led flashes increasingly fast and stops" Tags="|hardware|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22689" PostTypeId="2" ParentId="22687" CreationDate="2016-04-04T02:46:12.087" Score="5" Body="&lt;p&gt;There are a number of common solutions to &quot;not enough pins&quot;.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Reduce the number of pins you need. This option is often discarded out of hand, but may be the best. For example, you may be able to reduce the 18 individual pins for the on/off capacitive sensor, with a different part, which may be able to give you an X,Y co-ordinate of where it is touched, with fewer pins. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Multiplex the pins. This seems to be the most likely to work in this case - you will use (for example) 9 Uno pins to power the LED and capacitive sensor on each cell, one at a time. So, for example, you might attach D1 to the top left cell, D2 to the top-center, and so forth. Then you use another pin (e.g. D10) to connect to ALL the cathodes of the LEDs (via a single transistor, to protect the Uno from too much current), D11 and D12 to connect to one of the data pins of ALL of the capacitive sensors. So, you &quot;select&quot; cell one, by switching D1 from LOW to HIGH. Then, you put D10 to LOW, so current will from across the LEDs. Read the capacitive sensor, which is now also powered on. Although all of the censors are connected to D11 &amp;amp; D12, only one will be powered on, so you will only be reading that one. Once read, you probably want to delay a few milliseconds, to make sure the light shows up. Then move on to the next cell. Go round and round all cells. The LEDs will be off 8/9ths of the time, but it will still be visible. NOTE: reading more about capacitive sensors, I see that one is input, the other output. You would need a transistor for each of the &quot;select&quot; pins, used as a switch to connect D11 to the correct sensor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Do the same thing, but using a decade counter. Connect 2 pins from the Arduino to the decade counter - one to &quot;count&quot;, and one to reset. First, strobe the reset - this will set the first output of the decade counter high - connected to cell 1. Then, when you want to move to the next cell, drop the &quot;count&quot; low, then high again. You are now on the next cell. Repeat until you get to cell 9, then send the &quot;reset&quot; (which guarantees you know where you are up to) to get back to cell 1.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Charlieplexing (mostly suitable for output only). This is a somewhat complicated, but very efficient (pin-count wise) way of running lots of LEDs off only a few Arduino pins, by using them in combination. For example, 3 pins could run 6 LEDs - if you have pins A, B and C, run one LED from A to B, one from B to C, and one from C to A; then, run 3 more LEDs in the OPPOSITE direction (don't forget your resistors!). Depending on which LED you want lit, you might want pin A high, B low, and C high impedance (INPUT). 4 pins will get you 12 LEDs, 10 will get you 90 LEDs. If you think this might be useful, check out the Wikipedia &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use chips that are designed specifically for the application you need. For example, TLC5940 chips will run up to 16 LEDs each, controlling the brightness of each LED independently. You set the brightness of each LED, then let the TLC5940 take care of the work. SIPO chips such as the 74HC595 (8 outputs) are similar, but only allow &quot;on&quot; or &quot;off&quot; for each pin. Both of these can be &quot;daisy chained&quot; - with the same number of Arduino pins, you can connect the output of one to the input of the next, to control more outputs. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use multiple Arduinos. Yes, this might sound expensive, but you can use an AtMega (e.g. AtMega328, which is the same chip used in the Arduino) for a fraction of the cost. You might even use an AtTiny - even cheaper (but less memory). All of these can run the same code. This is the most flexible, but is also the most work - you would need to think about which chip does what, how they interact, and how they talk to each other. This also has the advantage that, rather than a chip that runs at 16mhz, you can now have multiple chips that each run at that speed, and have more memory each. Some applications work well with one &quot;master&quot; chip controlling one (or more) &quot;slaves&quot;, whereas other applications work really well as peer-to-peer, either with each node running the same code, or each doing their own thing, and passing information to other nodes. For this example, you might use one AtTiny85 for each of the 9 cells, with an Arduino to be the master. Or, use an AtTiny84, for each row of 3 cells, with one Arduino to rule them all. The AtTiny84 has 14 pins: power, ground, reset, and 11 data pins - 2 is enough for a shared data bus, such as i2c, leaving 3 pins for each of 3 cells.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;(not relevant for this example) For multiple on/off sensors (e.g. pushbuttons, switches), you can attach them through different values of resistors, and connect them to an ADC pin as a voltage divider. For example, connect ground via R0 to an analog pin; then connect to the same pin: pin -&gt; resistor 1 -&gt; pushbutton 1 -&gt; +5v; pin -&gt; resistor 2 -&gt; pushbutton 2 -&gt; +5v, and so forth. Build the circuit, and test each combination of switches/pushbuttons on/off, what the output will be. Then, in your code, figure out which combination it is closest to. Each resistor will need to be different resistance. If you only expect one switch to be on at once, it's a lot easier. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2016-04-05T02:48:30.660" LastActivityDate="2016-04-05T02:48:30.660" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22690" PostTypeId="2" ParentId="22687" CreationDate="2016-04-04T03:40:17.777" Score="2" Body="&lt;ol start=&quot;7&quot;&gt;&#xA;&lt;li&gt;Shift registers. A single shift register is typically 8 bits, so for nine cells you will need two parallel-in/serial-out (for the sensors) and two serial-in/parallel-out (for the leds). You can chain shift registers together to manage any number of bits, at the price of speed. Each chain of registers needs two pins - data and clock, and the parallel input needs a third pin to latch the data. 5 pins all up, for any number of inputs and outputs. You could even combine the clocks by combining 'read the sensors' and 'refresh the display' as a single operation.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-04T03:40:17.777" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22691" PostTypeId="2" ParentId="22672" CreationDate="2016-04-04T04:02:42.450" Score="2" Body="&lt;p&gt;What everyone else said.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's difficult to measure voltage without taking at least a tiny trickle of current, and that's what input pins do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anything that is driven needs current to drive it (power = current * voltage). However, an arduino pin - as someone mentioned - should only ever be used to supply about 25mA. Drawing a heavier current than that can fry the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;V=IR, so, the resistance on an output pin should be no less than 200 ohms, hence the 330 ohm current-limiting resistor you put on an LED. Power is IV, so the maximum power you can safely get get is 125mW (oh, you can get more - but you may fry your chip). This translates directly into the maximum safe brightness of a LED, the strength*speed of a motor, the loudness of a buzzer powered by an output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another big thing when trying to drive coils (motors, solenoids, relays) is that when you switch off the power to a coil, it generates a spike of voltage going the other way. This spike also can fry the chip. This is why relay shields are a thing - they contain electronics to deal with this back-emf. If you want to drive a motor and don't want to buy a shield, look into darlington array chips. I used one to run a stepper - worked perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Inputs in theory need almost no current - but they do need that tiny trickle.&lt;/li&gt;&#xA;&lt;li&gt;Outputs must have current to do any work. The amount you can get off the board without frying it is limited.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-04T04:02:42.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22692" PostTypeId="2" ParentId="22671" CreationDate="2016-04-04T04:12:06.187" Score="0" Body="&lt;p&gt;To read a button, normally you hook one end of the button to ground and one end to a pin in INPUT_PULLUP mode. Normally the pin reads 'high' because it is connected to +5v with a biggish resistor inside the arduino. When you press the button, it shorts out to ground and the input reads 'low'. The chip already has suitable resistors in it to handle this, and you don't need to worry about it. Just connect one end of your button the the pin, the other to the chassis, INPUT_PULLUP and away you go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output pins should have no less than 250Ω on them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Beats me why you are thinking of connecting an output pin and an input pin together.&lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-04T04:12:06.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22693" PostTypeId="2" ParentId="22605" CreationDate="2016-04-04T04:19:50.393" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Maybe your vibrating motor is actually shaking something loose. A dodgy batter clip or something.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maybe your vibrating motor is drawing too much current and power-cycling the board.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Maybe your vibrating motor is doing weird, bad things like generating back-EMF spikes that it's sending back into the arduino.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It's probably number 3. Generally speaking, you &lt;em&gt;never&lt;/em&gt; power motors off an output pin. Run the output into a mosfet or something with a flyback diode across it. Google &quot;circuit to power motor from digital out&quot;.&lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-04T04:19:50.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22694" PostTypeId="1" AcceptedAnswerId="22704" CreationDate="2016-04-04T04:40:34.473" Score="1" ViewCount="1865" Body="&lt;p&gt;I know this is ridiculously simple task but I spent the last two hours trying to get this to work and it is not working.  I don't have an Arduino but I have an ESP8266 Huzzah Feather which is programmable via the Arduino IDE.  So, I don't think I can provide a Fritz diagram but in any case, I'm just trying to hook up a pushbutton and be able to read a HIGH or LOW (via my Serial monitor).  Currently, everything is 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As best I can describe it is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5V from Feather into resistor into one terminal of the pushbutton.  Out the other terminal of the pushbutton is a wire connecting to pin 12 of the Feather, and also a wire leading to ground.  Feather is also grounded.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(12, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int button_val = digitalRead(12);&#xA;  Serial.println(button_val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It shouldn't be this hard for me.  Whenever I open and run the serial monitor, it reads 0s.  What am I missing?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, an issue that I faced is determining which 2 out of the 4 terminals of the pushbutton to use.  Some resources I find say that it is the same side as the terminal the voltage is flowing into; other resources say it is the terminal opposite to the side the voltage is flowing into.  I currently have it opposite.  &lt;/p&gt;&#xA;" OwnerUserId="19872" LastEditorUserId="4131" LastEditDate="2016-04-04T17:36:54.903" LastActivityDate="2016-04-04T17:36:54.903" Title="Why is my pushbutton always reading LOW?" Tags="|arduino-ide|button|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22695" PostTypeId="2" ParentId="22657" CreationDate="2016-04-04T04:47:40.440" Score="0" Body="&lt;p&gt;How many Arduinos do you need? If you are just getting one to learn on, for heaven's sake pay the extra fifteen bucks and support the cause.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are manufacturing something and need a few dozen boards, buy 50 Chinese ones and chuck the ones that don't work.&lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-04T04:47:40.440" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22696" PostTypeId="2" ParentId="22657" CreationDate="2016-04-04T05:08:37.520" Score="0" Body="&lt;p&gt;While, yes, caveat emptor, I have purchased a number of devices which are based on the Arduino open design. I have not yet had a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember that, if you buy more expensive, prominently &quot;Arduino&quot; branded parts, from a third party, you also have no guarantee that they are quality controlled by Arduino. Even &quot;genuine&quot; electronics parts are usually manufactured in China, often in the same factories.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your question, there are a number of ways the costs can be kept down:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lack of unions, lack of labor laws, economies of scale, markup by the &quot;official&quot; companies, lack of development costs (remember, Arduino is open hardware, copying is allowed), cheap labor, tax, transport costs (there is some trickery in some countries, including Hong Kong, which makes shipping essentially free), shorter supply chain, cheaper components, smaller marketing budget.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-04-04T05:08:37.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22697" PostTypeId="2" ParentId="22694" CreationDate="2016-04-04T06:24:09.813" Score="4" Body="&lt;p&gt;The pins on each side of the button are shorted, the &quot;button&quot; is between the &lt;em&gt;sides&lt;/em&gt; of the button. Else your code looks alright.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here's an image which shows how a push button is connected internally, make sure you're using the correct pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vJ3ZH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vJ3ZH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19322" LastEditorUserId="19785" LastEditDate="2016-04-04T07:51:51.677" LastActivityDate="2016-04-04T07:51:51.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22698" PostTypeId="2" ParentId="18034" CreationDate="2016-04-04T06:46:26.307" Score="1" Body="&lt;p&gt;Piezoelectric speakers, the kind commonly found in ultrasonic transducers generally operate in a narrow frequency range when operating at ultrasonic range (a resonate frequency of the metallic diaphragm). This is very true once you get above about ~60 kHz. However if the ultrasonic &quot;chirp&quot; you are looking for can be in the range of say 20-60 kHz you could be in luck, i.e., &lt;a href=&quot;http://www.conrad-electronic.co.uk/ce/en/product/710991/KEPO-piezo-element-25-60-kHz-515-mm&quot; rel=&quot;nofollow&quot;&gt;http://www.conrad-electronic.co.uk/ce/en/product/710991/KEPO-piezo-element-25-60-kHz-515-mm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the Tone function (which goes up to 65535 Hz) to produce the frequency sweep you desire. However if you want to go up to frequencies in the 100+ kHz range you will be delving into research territory and hence extremely expensive equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, technologies change very quickly and I my knowledge may already be out of date. Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="19874" LastActivityDate="2016-04-04T06:46:26.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22699" PostTypeId="2" ParentId="22684" CreationDate="2016-04-04T07:14:23.300" Score="2" Body="&lt;p&gt;The error you posted has nothing to do with an Arduino core. This is just plain avr-libc stuff. In order to use this kind of functionality, you need to&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the Arduino core, it is common to have this done by default. But if this is not the case with your chosen core, just add the &lt;code&gt;#include&lt;/code&gt; yourself in the program.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-04T07:14:23.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22700" PostTypeId="1" CreationDate="2016-04-04T07:29:03.427" Score="2" ViewCount="12686" Body="&lt;p&gt;What configuration settings do I need to change on my computer to use the ethernet shield mounted on my Arduino UNO as I don't want to connect the ethernet shield to the router?&lt;/p&gt;&#xA;" OwnerUserId="19876" LastEditorUserId="19515" LastEditDate="2016-04-05T13:23:41.737" LastActivityDate="2016-12-29T10:56:13.150" Title="Connecting ethernet shield to computer" Tags="|arduino-uno|ethernet|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22702" PostTypeId="2" ParentId="22639" CreationDate="2016-04-04T08:54:05.970" Score="0" Body="&lt;p&gt;The problem with your code is your using &lt;code&gt;delay()&lt;/code&gt;. This is a function&#xA;that should most of the time be avoided for one simple reason: when the&#xA;Arduino is executing the &lt;code&gt;delay()&lt;/code&gt; instruction, it does &lt;em&gt;nothing&lt;/em&gt; but&#xA;wait. This means, among other things, that it cannot be reactive to user&#xA;input. As outlined by ARK in his answer, interrupts could be used to&#xA;overcome this problem. But you actually do not need them: the standard&#xA;way to avoid delays is to use instead the &lt;code&gt;millis()&lt;/code&gt; function to control&#xA;timings. This approach is well described in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;Blink without&#xA;delay&lt;/a&gt; Arduino&#xA;tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how you can apply this technique to your &lt;code&gt;alarm()&lt;/code&gt; function: In&#xA;a nutshell, you can think of &lt;code&gt;delay()&lt;/code&gt; to be roughly equivalent to this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void naiveDelay(uint32_t ms)&#xA;{&#xA;    uint32_t start = millis();&#xA;    while (millis() - start &amp;lt; ms) {&#xA;        // do nothing&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem here is the “do nothing” part. You do not want your program&#xA;to do nothing, you want it to monitor the “alarm stop” button. So the&#xA;simple solution to your problem is to replace &lt;code&gt;delay()&lt;/code&gt; by the code&#xA;above, and then change it so that it monitors the button instead of&#xA;doing nothing. Then you get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void alarm()&#xA;{&#xA;    for (int count = 0; count &amp;lt; 5; count++) {&#xA;&#xA;        // start the buzzer&#xA;        digitalWrite(buzz, HIGH);&#xA;&#xA;        // first delay&#xA;        uint32_t start = millis();&#xA;        while (millis() - start &amp;lt; 500) {&#xA;            if (digitalRead(alarmStop) == HIGH) {&#xA;                digitalWrite(buzz, LOW);  // stop the buzzer&#xA;                return;&#xA;            }&#xA;        }&#xA;&#xA;        // stop the buzzer&#xA;        digitalWrite(buzz, LOW);&#xA;&#xA;        // second delay&#xA;        start = millis();&#xA;        while (millis() - start &amp;lt; 500) {&#xA;            if (digitalRead(alarmStop) == HIGH) {&#xA;                return;  // buzzer already off&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-04T08:54:05.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22703" PostTypeId="2" ParentId="22700" CreationDate="2016-04-04T10:14:35.320" Score="1" Body="&lt;p&gt;First off you need a basic understanding of TCP/IP networking. One you have that you need to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Allocate yourself a new subnet - one that's not your normal local network (say 192.168.1.0/24)&lt;/li&gt;&#xA;&lt;li&gt;Assign an IP in that subnet to your Arduino (say 192.168.1.1)&lt;/li&gt;&#xA;&lt;li&gt;Assign a different IP in that subnet to your PC (say 192.168.1.2)&lt;/li&gt;&#xA;&lt;li&gt;Configure your Arduino's sketch with it's IP address and netmask&lt;/li&gt;&#xA;&lt;li&gt;Configure the PC's Ethernet interface with it's IP address and netmask&lt;/li&gt;&#xA;&lt;li&gt;Connect the two together with a suitable cable.  If the PC's Ethernet port doesn't have auto-direction sensing you will require a special cross-over cable where TX+/TX- and RX+/RX- are swapped over.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-04T10:14:35.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22704" PostTypeId="2" ParentId="22694" CreationDate="2016-04-04T10:16:55.050" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Out the other terminal of the pushbutton is a wire connecting to pin 12 of the Feather, and also a wire leading to ground.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That sounds to me like you have connected the IO pin direct to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IO pin should connect to the same pin as the resistor that connects to +5v. The other side of the button should connect to ground only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance using @HansNeve's button picture you could connect pin A to the IO pin and via a resistor to +5V, and pin B to ground.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-04T10:16:55.050" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22705" PostTypeId="1" CreationDate="2016-04-04T10:23:09.307" Score="3" ViewCount="1592" Body="&lt;p&gt;I'm doing a project that includes an Arduino Uno and custom hardware made by me. Everything is working perfectly independently, and I'm trying to implement a way for them (the Arduino and my hardware) to work together. In order to achieve that, I am using the Wire protocol (Arduino side) and I2C (custom hardware side). From now I can send data from &lt;strong&gt;my hardware&lt;/strong&gt; to &lt;strong&gt;my Arduino&lt;/strong&gt; in a &lt;strong&gt;master-slave&lt;/strong&gt; relation, and I have no problem with that. Please take a look at my Arduino code for better understanding:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup(void) {&#xA;  Wire.begin(7);&#xA;  Wire.onReceive(receiveEvent);&#xA;}&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  int x = Wire.read(); // receive byte as an integer&#xA;  Serial.print(x);&#xA;  if (x==0) &#xA;    state = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So far so good. Now I want to send data from the &lt;strong&gt;Arduino&lt;/strong&gt; to my &lt;strong&gt;custom hardware&lt;/strong&gt; full duple, and for that I am adding this code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void frame(void){&#xA;  Wire.write('x');&#xA;  Wire.write('\r');&#xA;}&#xA;&#xA;void loop() {&#xA;  if (state == 0){&#xA;    frame();&#xA;    state = 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In order to receive the 'x' char in my custom hardware I have switched the I2C protocol bit from Write to Read using &lt;code&gt;I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_WRITE);&lt;/code&gt; to &lt;code&gt;I2C_FORMAT_7_BIT_ADDRESS(SlaveAddress, _address, I2C_READ);&lt;/code&gt; in my custom hardware code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why, I am not receiving the data from the Arduino. Am I missing any configuration on the Arduino side?&lt;/p&gt;&#xA;" OwnerUserId="19878" LastEditorUserId="4628" LastEditDate="2016-12-31T21:40:20.977" LastActivityDate="2017-01-02T01:52:29.333" Title="Wire Library send/receive" Tags="|arduino-uno|i2c|wire-library|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22706" PostTypeId="2" ParentId="19930" CreationDate="2016-04-04T11:26:56.703" Score="0" Body="&lt;p&gt;I would recommend you the &lt;a href=&quot;http://www.vlsi.fi/fileadmin/datasheets/vs1003.pdf&quot; rel=&quot;nofollow&quot;&gt;VS1003&lt;/a&gt; chip ($2.30 on ebay) or module ($7 on ebay). It can play MP3, WMA, MIDI, WAV and can record and encode ADPCM. It's even programmable (own filters etc). See &lt;a href=&quot;http://arduino-cool.blogspot.com/2012/10/arduino-mp3-player-i.html&quot; rel=&quot;nofollow&quot;&gt;this project&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-04-04T11:26:56.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22708" PostTypeId="1" CreationDate="2016-04-04T12:41:56.530" Score="1" ViewCount="1463" Body="&lt;p&gt;I tried using a MCP4725 DAC with an Arduino (M0 Pro, Duemilanove and Diecimila) and it is not outputing any voltage (just random noise).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been using the 2 tutorial codes fount here : &lt;a href=&quot;https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/using-with-arduino&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/using-with-arduino&lt;/a&gt; which are supposed to generate a sinus wave and a triangle wave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pretty sure it doesn't come from the Arduino because basic examples have been working so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anybody had the same issue or can help on this ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MCP4725.h&amp;gt;&#xA;&#xA;Adafruit_MCP4725 dac;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Hello!&quot;);&#xA;&#xA;// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)&#xA;  // For MCP4725A0 the address is 0x60 or 0x61&#xA;  // For MCP4725A2 the address is 0x64 or 0x65&#xA;  dac.begin(0x62);&#xA;&#xA;  Serial.println(&quot;Generating a triangle wave&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;    uint32_t counter;&#xA;    // Run through the full 12-bit scale for a triangle wave&#xA;    for (counter = 0; counter &amp;lt; 4095; counter++)&#xA;    {&#xA;      dac.setVoltage(counter, false);&#xA;    }&#xA;    for (counter = 4095; counter &amp;gt; 0; counter--)&#xA;    {&#xA;      dac.setVoltage(counter, false);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19881" LastEditorUserId="19881" LastEditDate="2016-04-04T12:47:38.873" LastActivityDate="2018-04-02T22:56:56.920" Title="MCP4725 not working" Tags="|arduino-mega|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22709" PostTypeId="2" ParentId="22705" CreationDate="2016-04-04T12:49:51.300" Score="1" Body="&lt;p&gt;I've not done events on an Arduino so this could be a bum steer, but shouldn't the state variable be volatile and protected with a semaphore?&#xA;You are accessing it in the main program and in your event/ISR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly, no offence intended, could you replace your hardware with a bit of tried and trusted hardware to eliminate the remote possibility that your hardware is at fault.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-04T12:49:51.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22712" PostTypeId="1" AcceptedAnswerId="22713" CreationDate="2016-04-04T19:39:23.320" Score="0" ViewCount="1124" Body="&lt;p&gt;I am from programming background and newbie to this field. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Couple of days ago I brought &lt;strong&gt;Arduino Uno (5V)&lt;/strong&gt;. I want to control light bulb and fan from my &lt;strong&gt;Android&lt;/strong&gt;. So I thought, I will buy &lt;strong&gt;relays&lt;/strong&gt; and &lt;strong&gt;ESP8266&lt;/strong&gt; module and its done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now read somewhere that ESP8266 works with &lt;strong&gt;3.3v&lt;/strong&gt; and my Arduino supplies &lt;strong&gt;5v&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should I go for different Arduino board (like Arduino pro or Arduino mini) or is there any &lt;strong&gt;reliable &amp;amp; cheap&lt;/strong&gt; solution that will work my &lt;strong&gt;Arduino Uno (5V)&lt;/strong&gt; ?&lt;/p&gt;&#xA;" OwnerUserId="19781" LastActivityDate="2016-04-05T13:23:49.423" Title="Cheapest Arduino wireless solution for home automation" Tags="|arduino-uno|power|wifi|wireless|" AnswerCount="1" CommentCount="3" ClosedDate="2016-04-05T00:03:09.060" ContentLicense="CC BY-SA 3.0" />
  <row Id="22713" PostTypeId="2" ParentId="22712" CreationDate="2016-04-04T19:43:32.900" Score="2" Body="&lt;p&gt;If you want to go for cheap just use a ESP8266 no arduino needed.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-04-04T19:43:32.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22715" PostTypeId="2" ParentId="22578" CreationDate="2016-04-04T21:34:24.490" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;If I push the reset button on it it comes back a bit then disappears again:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's exactly how it works. The Micro enumerates as a Serial interface for a couple of seconds after reset, enough time for you to upload a new sketch. If you don't upload in time, and unless your code specifies a serial port, the serial interface goes away. Blink doesn't use a serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to quickly press and release Reset at the exact moment that the IDE says it is uploading, and the board should then detect the new sketch.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-04T21:34:24.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22716" PostTypeId="1" AcceptedAnswerId="47219" CreationDate="2016-04-04T21:51:33.563" Score="2" ViewCount="2622" Body="&lt;p&gt;I tried Google, I tried a bunch of forums and I searched here. This question needs a final answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Which GSM-shield is most efficient for GPRS communication?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Arduino is the amateurs best friend for home automation and IoT, an &quot;efficient&quot; shield has a very low power consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently developing a system that collects some data from different sensors at a place far, far away, with limited access to power (e.g. it has a very small solar panel and a battery). It is also in pocket-size which makes a car battery a bad option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, this specific device reads these sensors every 20 minutes, and if there's a deviation since the previous reading it starts the GSM module to send the new data to my API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SMS and call features are of absolutely no interest at all.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since these GSM-power-absorbing-current-eating-devils really like power I must think outside the box and compare different alternatives. So besides the primary question in this post, is there any way you can limit the power consumed, for example by limit the connection speed or anything like that? I'm using a M590 module at the moment, and that beast can eat around 2A if it's hungry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance :)&lt;/p&gt;&#xA;" OwnerUserId="19898" LastActivityDate="2017-12-01T14:14:20.297" Title="Which GSM-shield is most efficient for GPRS communication?" Tags="|power|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22718" PostTypeId="2" ParentId="22716" CreationDate="2016-04-04T21:58:19.903" Score="1" Body="&lt;p&gt;GSM, by its very nature, is power hungry.  Even the most &quot;efficient&quot; one will blow your power budget many times over.  Since everything on GSM goes down the same digital transmission channel there would be no real difference between one with call and SMS and one without. It's all just data at the end of the day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, the most efficient GSM module is one that consumes absolutely now power. And that is, at least for most of the time, perfectly possible.  By making the Arduino control the power supply to the GSM modem it can be literally turned off until an update is needed to be sent. Worst case that is on for maybe a minute (give it time to register on the network and what have you) and then off for 19 minutes. That's only on for 5% of the time - less if there isn't a change since the last time, of course.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-04T21:58:19.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22720" PostTypeId="1" CreationDate="2016-04-04T22:38:04.160" Score="1" ViewCount="57" Body="&lt;p&gt;I want it to display the current temperature in the middle of the screen, fade out for two seconds, display new temperature, rinse repeat.  This is current (see images)&lt;a href=&quot;https://i.stack.imgur.com/aH2Gn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aH2Gn.jpg&quot; alt=&quot;all over the place![![][1]&quot;&gt;&lt;/a&gt;]&lt;a href=&quot;https://i.stack.imgur.com/xNoG4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;2&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * File:    readTemperature.ino&#xA; * Author:  Andy Gelme (@geekscape) &amp;amp; Angus Gratton (angus at freetronics. com)&#xA; * License: GPLv3&#xA; *&#xA; * For more information see www.freetronics.com/irtemp&#xA; *THIS NOW WORKS!!! Except for reading to LCD.&#xA; */&#xA;&#xA;#include &quot;IRTemp.h&quot;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 9, 8, 7, 6);&#xA;&#xA;static const byte PIN_DATA    = 2; // Choose any pins you like for these&#xA;static const byte PIN_CLOCK   = 3;&#xA;static const byte PIN_ACQUIRE = 4;&#xA;&#xA;static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT&#xA;&#xA;IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);&#xA;&#xA;void setup(void) {&#xA; // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // initialize the serial communications:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;  float irTemperature = irTemp.getIRTemperature(SCALE);&#xA;  printTemperature(&quot;&quot;,irTemperature);&#xA; delay(1000);&#xA;   // when characters arrive over the serial port...&#xA;  if (Serial.available()) {&#xA;    // wait a bit for the entire message to arrive&#xA;    delay(100);&#xA;    // clear the screen&#xA;    lcd.clear();&#xA;    // read all the available characters&#xA;    while (Serial.available() &amp;gt; 0) {&#xA;      // display each character to the LCD&#xA;      lcd.write(Serial.read());&#xA;&#xA;  // delay at the end of the full loop:&#xA;  delay(1000);&#xA;&#xA;}&#xA;  }&#xA;}&#xA;&#xA;void printTemperature(&#xA;  char  *type,&#xA;  float  temperature) {&#xA;&#xA;  lcd.print(type);&#xA;  lcd.print(&quot; temp: &quot;);&#xA;&#xA;  if (isnan(temperature)) {&#xA;    lcd.println(&quot;Failed&quot;);&#xA;  }&#xA;  else {&#xA;    lcd.print(temperature);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19901" LastEditorUserId="10794" LastEditDate="2016-04-05T00:59:42.403" LastActivityDate="2016-04-05T15:03:13.310" Title="LCD readout is odd" Tags="|c++|lcd|display|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22721" PostTypeId="2" ParentId="22720" CreationDate="2016-04-04T22:56:40.477" Score="1" Body="&lt;p&gt;Before you write the first character of your temperature text, set the cursor to where you want that first character to display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, use &lt;code&gt;lcd.setCursor(col, row);&lt;/code&gt; to set the cursor at a specified column in a specified row.  Row and column numbering starts from zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also use &lt;code&gt;lcd.home();&lt;/code&gt; to set the cursor at (0,0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output cursor advances a column each time you write a character.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-04T22:56:40.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22722" PostTypeId="2" ParentId="22705" CreationDate="2016-04-04T23:11:52.793" Score="1" Body="&lt;p&gt;You use the &lt;code&gt;onReceive()&lt;/code&gt; and &lt;code&gt;onRequest()&lt;/code&gt; methods of the Wire library to implement an Arduino slave. In your case, something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(void){&#xA;  Wire.begin(18);&#xA;  Wire.onReceive(receiveEvent);  # register receive handler&#xA;  Wire.onRequest(requestEvent);  #register request handler&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void receiveEvent(int howMany){&#xA;  int x = Wire.read();    // receive byte as an integer&#xA;  Serial.print(x);&#xA;  if (x == 0) &#xA;    state = 0;&#xA;}&#xA;&#xA;void requestEvent(){&#xA;  Wire.write(&quot;x\r&quot;);&#xA;  state = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterWriter&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slave Receiver&lt;/a&gt; and &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterReader&quot; rel=&quot;nofollow noreferrer&quot;&gt;Slave Sender&lt;/a&gt; examples for more details.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2017-01-02T01:52:29.333" LastActivityDate="2017-01-02T01:52:29.333" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22723" PostTypeId="5" CreationDate="2016-04-04T23:18:14.063" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-04-04T23:18:14.063" LastActivityDate="2016-04-04T23:18:14.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22724" PostTypeId="4" CreationDate="2016-04-04T23:18:14.063" Score="0" Body="Use this tag when referring to circuit or component for voltage protection." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-10T20:40:02.680" LastActivityDate="2016-04-10T20:40:02.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22725" PostTypeId="2" ParentId="21316" CreationDate="2016-04-05T00:20:09.210" Score="0" Body="&lt;p&gt;Have you also pulled up the ESP8266's reset pin? I don't know what effect not doing so might have, but the recommended connections I have read and followed include that. The RST and CH_PD pins are adjacent; they're easy to jumper together.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-05T00:20:09.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22726" PostTypeId="1" AcceptedAnswerId="22734" CreationDate="2016-04-04T19:12:40.900" Score="0" ViewCount="720" Body="&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a reason for unstable button numbers of an IR remote?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Desciption&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a remote class where I identify the pressed number of the remote to set states. But however I get never the same number of the pressed key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example I press the number '1' and on the serial interface shows this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3588650484&#xA;2740290906&#xA;3148594742&#xA;689746115&#xA;2396927248&#xA;2934053595&#xA;4294967295&#xA;3876827360&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it should look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;16724175 // Button 1&#xA;4294967295&#xA;16724175 // Button 1&#xA;16724175 // Button 1&#xA;16724175 // Button 1&#xA;16724175 // Button 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an arduino UNO board and the standart remote of the starter kit. There is no name just 'SPECIAL FOR MP3'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some more infos&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, in my first project I used the code from Noreddine Kessa(&lt;a href=&quot;http://www.instructables.com/id/Controlling-an-Arduino-Board-Using-an-Infrared-Rem/&quot; rel=&quot;nofollow&quot;&gt;Example Project&lt;/a&gt;) which works fine. Next I copied some code in my new class 'IRControl.cpp' ( you can see below). Then I created an object IRControl in the main.cpp and run the menu() in the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;h-File:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * IRControl.h&#xA; *&#xA; *  Created on: 04.04.2016&#xA; *      Author: David&#xA; */&#xA;&#xA;#ifndef IRCONTROL_H_&#xA;#define IRCONTROL_H_&#xA;&#xA;//Remote Defines&#xA;#define buttonON 16753245&#xA;#define buttonMode 16736925&#xA;#define buttonSoundOff 16769565&#xA;#define buttonPlayStop 16743045&#xA;#define buttonTrackBack 16712445&#xA;#define buttonTrackForward 16761405&#xA;#define buttonEQ 16769055&#xA;#define buttonMinus 16754775&#xA;#define buttonPlus 16748655&#xA;#define button0 16738455&#xA;#define buttonRepeat 16750695&#xA;#define buttonJSD 16756815&#xA;#define button1 16724175&#xA;#define button2 16718055&#xA;#define button3 16743045&#xA;#define button4 16716015&#xA;#define button5 16726215&#xA;#define button6 16734885&#xA;#define button7 16728765&#xA;#define button8 16730805&#xA;&#xA;#include &quot;IRremote.h&quot;&#xA;#include &quot;wiring_private.h&quot;&#xA;&#xA;enum zustaende{Motor1, Motor2, Motor3, Sleep};&#xA;extern int zustand;&#xA;&#xA;class IRControl {&#xA;private:&#xA;    IRrecv *irrecv;&#xA;    decode_results remoteValue;&#xA;public:&#xA;    IRControl(int RECV_PIN);&#xA;    virtual ~IRControl();&#xA;    void menu();&#xA;};&#xA;&#xA;#endif /* IRCONTROL_H_ */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;cpp-File:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* IRControl.cpp&#xA; *&#xA; *  Created on: 04.04.2016&#xA; *      Author: David&#xA; */&#xA;&#xA;#include &quot;IRControl.h&quot;&#xA;&#xA;IRControl::IRControl(int RECV_PIN) {&#xA;    // TODO Auto-generated constructor stub&#xA;    irrecv = new IRrecv(RECV_PIN);&#xA;    pinMode(RECV_PIN , INPUT);&#xA;    irrecv-&amp;gt;enableIRIn();&#xA;}&#xA;&#xA;IRControl::~IRControl() {&#xA;    // TODO Auto-generated destructor stub&#xA;    delete irrecv;&#xA;}&#xA;&#xA;void IRControl::menu() {&#xA;    if (irrecv-&amp;gt;decode(&amp;amp;remoteValue)) {&#xA;        //lReceived = remoteValue.value ;&#xA;        Serial.println(remoteValue.value);&#xA;        /*&#xA;        switch(remoteValue.value)&#xA;                {&#xA;                case button1:&#xA;                    zustand = Motor1;&#xA;                    //digitalWrite (LED1, HIGH); // for control&#xA;                    break;&#xA;&#xA;                case button2:&#xA;                    zustand = Motor2;&#xA;                    //digitalWrite (LED2, HIGH);&#xA;                    break;&#xA;                case button3:&#xA;                    zustand = Motor3;&#xA;                    //digitalWrite (LED3, HIGH);&#xA;                    break;&#xA;&#xA;                case button0:&#xA;                    zustand = Sleep;&#xA;                    break;&#xA;&#xA;                default: break;&#xA;                }&#xA;                */&#xA;        irrecv-&amp;gt;resume(); // Receive the next value&#xA;      }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Where the problem could be&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think there could be a problem with the &lt;code&gt;IRrecv *irrecv;&lt;/code&gt;. But i'm not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="19890" OwnerDisplayName="Deweird" LastEditorUserId="10794" LastEditDate="2016-04-05T05:18:19.533" LastActivityDate="2016-04-05T05:18:19.533" Title="IR remote unstable button numbers" Tags="|c++|button|remote-control|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22727" PostTypeId="2" ParentId="22720" CreationDate="2016-04-05T01:39:06.200" Score="0" Body="&lt;pre&gt;&lt;code&gt;/*&#xA; * File:    readTemperature.ino&#xA; * Author:  Andy Gelme (@geekscape) &amp;amp; Angus Gratton (angus at freetronics. com)&#xA; * License: GPLv3&#xA; *&#xA; * For more information see www.freetronics.com/irtemp&#xA; *THIS NOW WORKS!!! Except for reading to LCD.&#xA; */&#xA;&#xA;#include &quot;IRTemp.h&quot;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 9, 8, 7, 6);&#xA;&#xA;static const byte PIN_DATA    = 2; // Choose any pins you like for these&#xA;static const byte PIN_CLOCK   = 3;&#xA;static const byte PIN_ACQUIRE = 4;&#xA;&#xA;static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT&#xA;&#xA;IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);&#xA;&#xA;void setup(void) {&#xA; // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 1);&#xA;  // initialize the serial communications:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;  float irTemperature = irTemp.getIRTemperature(SCALE);&#xA;  printTemperature(&quot;&quot;,irTemperature);&#xA; delay(1000);&#xA;&#xA;  }&#xA;&#xA;void printTemperature(&#xA;  char  *type,&#xA;  float  temperature) {&#xA;&#xA;  lcd.print(type);&#xA;  lcd.setCursor(1,1);&#xA;  lcd.print(temperature);&#xA;  lcd.setCursor(7,1);&#xA;  lcd.print(&quot;celcius&quot;);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19901" LastEditorUserId="2881" LastEditDate="2016-04-05T15:03:13.310" LastActivityDate="2016-04-05T15:03:13.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22728" PostTypeId="2" ParentId="22720" CreationDate="2016-04-05T01:41:12.320" Score="0" Body="&lt;pre&gt;&lt;code&gt;/*&#xA; * File:    readTemperature.ino&#xA; * Author:  Andy Gelme (@geekscape) &amp;amp; Angus Gratton (angus at freetronics. com)&#xA; * License: GPLv3&#xA; *&#xA; * For more information see www.freetronics.com/irtemp&#xA; *After much playing around this is the finaL result.&#xA; */&#xA;&#xA;#include &quot;IRTemp.h&quot;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 9, 8, 7, 6);&#xA;&#xA;static const byte PIN_DATA    = 2; // Choose any pins you like for these&#xA;static const byte PIN_CLOCK   = 3;&#xA;static const byte PIN_ACQUIRE = 4;&#xA;&#xA;static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT&#xA;&#xA;IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);&#xA;&#xA;void setup(void) {&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 1);&#xA;  // initialize the serial communications:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;  float irTemperature = irTemp.getIRTemperature(SCALE);&#xA;  printTemperature(&quot;&quot;,irTemperature);&#xA; delay(1000);&#xA;&#xA;  }&#xA;&#xA;void printTemperature(&#xA;  char  *type,&#xA;  float  temperature) {&#xA;&#xA;  lcd.print(type);&#xA;  lcd.setCursor(1,1);&#xA;  lcd.print(temperature);&#xA;  lcd.setCursor(7,1);&#xA;  lcd.print(&quot;celcius&quot;);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19901" LastEditorUserId="19912" LastEditDate="2016-04-05T13:23:34.080" LastActivityDate="2016-04-05T13:23:34.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22730" PostTypeId="1" CreationDate="2016-04-05T03:12:09.143" Score="2" ViewCount="282" Body="&lt;p&gt;I am trying to make a heart rate sensor watch. I am trying to do this using a Simblee (www.simblee.com) and a Pulse Sensor (www.pulsesensor.com) however they will not work! The original code from pulsesensor uses Timer2, which I commented out in favor of delay(2) (i'm new to Arduino and it seemed to work). I am getting readings over serial they just seem to be in a wave instead of a pulse. I need to get this working as I am out of time and money ;) Would anyone have any ideas on how I could get them working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ALL CODE ON GITHUB (&lt;a href=&quot;https://github.com/shadow85926/SimbleeArduinoCode&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/shadow85926/SimbleeArduinoCode&lt;/a&gt;)&#xA;Thank you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wave pattern:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zw7tP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/zw7tP.jpg&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19908" LastEditorUserId="19515" LastEditDate="2016-04-05T16:31:33.463" LastActivityDate="2016-04-05T16:31:33.463" Title="Connecting Pulse Sensor to RFDuino Simblee" Tags="|arduino-ide|rf|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22731" PostTypeId="1" CreationDate="2016-04-05T03:12:32.153" Score="3" ViewCount="129" Body="&lt;p&gt;What I am trying to accomplish is to include information about the state of my environment at build time in my code. For example, I may want the &lt;code&gt;setup()&lt;/code&gt; code to print the git sha it was built against, and the time of build. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two related issues here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to include that information in the code&lt;/li&gt;&#xA;&lt;li&gt;How to specify to the build environment what to generate in the first place.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first can be addressed in a number of ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-D options can be generated at build time, and the corresponding defined macros expanded in the code. For example, the compiler could be invoked as &lt;code&gt;g++ -DGIT_SHA=$(git rev-parse HEAD) -DDATE=$(date '+%Y%m%d-%H:%M:%S')&lt;/code&gt;, and my code could have something like &lt;code&gt;#define strfy(_x) #_x&lt;/code&gt; followed by &lt;code&gt;Serial.println(strfy(GIT_SHA));&lt;/code&gt;. Or the build tool could generate a header file that would define these as external string variables, which the main sketch could then include and print. Or any other number of tricks.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The question I am really asking is: &lt;strong&gt;how should I specify this sort of stuff for &lt;code&gt;arduino-builder&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally, it would be a custom recipe in &lt;code&gt;platform.txt&lt;/code&gt;, but if there is a way to invoke shell commands in recipes and use the results to modify other variables (such as &lt;code&gt;preproc.macro.flags&lt;/code&gt;), I haven't been able to find it (if there is documentation, it's really well hidden). Ideally I would want to be able to say &lt;code&gt;preproc.macros.flags=-w -x c++ -E -CC -DGIT_SHA=$(git rev-parse HEAD)&lt;/code&gt; and have the shell command be executed at the point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, before I set out to hack arduino-builder, do people have any opinion on this? My main criterion is something that would be of general value and has a chance of being incorporated in the code, rather than a kludge that only works for me and which I have to patch every time I upgrade. Please do not suggest workarounds. I can think of several myself!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;did&lt;/em&gt; try to search, and this sort of issue has come up before, but I didn't see any satisfactory answers from people who knew what they were talking about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/ji &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-05T13:37:57.363" Title="What would be the architecturally-right place to put custom -D defines?" Tags="|arduino-ide|build|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22732" PostTypeId="1" CreationDate="2016-04-05T03:42:44.577" Score="2" ViewCount="7308" Body="&lt;p&gt;I'm trying to figure out how to connect a vibration motor to my Arduino.  I've come across &lt;a href=&quot;http://learningaboutelectronics.com/Articles/Vibration-motor-circuit.php&quot; rel=&quot;nofollow&quot;&gt;this resource&lt;/a&gt; and it seems pretty straightforward though for a while my eye glazed over at how complicated the circuit was (do I really need all of that to run my vibration motor?).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My real question is that I have a vibration motor similar to the picture in the link and I'm trying to figure out how to actually connect it to my breadboard.  Do I have to solder wires onto those flimsy ends or is that a better way to get this to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19872" LastActivityDate="2018-01-04T22:03:41.207" Title="How do I connect a vibration motor to Arduino?" Tags="|motor|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22734" PostTypeId="2" ParentId="22726" CreationDate="2016-04-05T05:18:05.267" Score="1" Body="&lt;p&gt;Please post the code where you call the library. In particular where do you make an instance of IRControl?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am guessing you are doing it at global scope which means you are probably running into the &lt;em&gt;C++ static initialization order fiasco&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What it is: &lt;a href=&quot;http://www.parashift.com/c++-faq/static-init-order.html&quot; rel=&quot;nofollow&quot;&gt;http://www.parashift.com/c++-faq/static-init-order.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to prevent it: &lt;a href=&quot;http://www.parashift.com/c++-faq/static-init-order-on-first-use.html&quot; rel=&quot;nofollow&quot;&gt;http://www.parashift.com/c++-faq/static-init-order-on-first-use.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent this, you should &lt;strong&gt;not&lt;/strong&gt; be doing this in the class constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;irrecv = new IRrecv(RECV_PIN);&#xA;pinMode(RECV_PIN , INPUT);&#xA;irrecv-&amp;gt;enableIRIn();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead, make a &lt;code&gt;begin&lt;/code&gt; function (like most Arduino classes do) and call that from &lt;code&gt;setup&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-05T05:18:05.267" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22736" PostTypeId="1" CreationDate="2016-04-05T07:05:44.480" Score="2" ViewCount="604" Body="&lt;p&gt;I have connected a CIM motor to a Jaguar speed controller, powered by a 12V battery. The Jaguar is connected to an Arduino Uno via the signal and ground. Also, I have two switches connected to the Arduino, for forward and reverse of the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code, for speed of the motor, I have set 90 as the mid point and 100 for forward and 80 for reverse. When I push the reverse button, the motor runs smoothly in the reverse direction at the set speed. However, the problem is, when I press the forward button, the motor runs seemingly &lt;strong&gt;slower&lt;/strong&gt; in the forward direction than the set speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My logic here was, if I have set speeds in forward and reverse at +/- 10 from the mid-point, the motor should run at the same speed in the forward and reverse direction, but this is not happening. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pasting my code below. Any help would be much appreciated. Thank you!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;int forwardPin = 2;&#xA;int reversePin = 4;&#xA;int motorPin = 10;&#xA;int fwdReading = 0;&#xA;int revReading = 0;&#xA;&#xA;Servo myservo;&#xA;&#xA;void setup() {&#xA;  TCCR1B = TCCR1B &amp;amp; 0b11111000 | 0x04; // PWM Freq. at 122Hz&#xA;  pinMode (forwardPin, INPUT);&#xA;  pinMode (reversePin, INPUT);&#xA;  myservo.attach(motorPin);&#xA;  myservo.write(90);  // set servo to mid-point&#xA;}&#xA;&#xA;void loop() {&#xA;  fwdReading = digitalRead(forwardPin);&#xA;  revReading = digitalRead(reversePin);&#xA;  if (fwdReading == HIGH) {&#xA;    myservo.write(100); // forward&#xA;  } else if (revReading == HIGH) {&#xA;    myservo.write(80); // reverse&#xA;  } else&#xA;    myservo.write(90); // neutral&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19913" LastEditorUserId="4628" LastEditDate="2017-05-03T09:58:23.097" LastActivityDate="2019-12-22T05:03:00.417" Title="Arduino Uno + Jaguar Speed Controller + CIM Motor (12V DC)" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22738" PostTypeId="2" ParentId="22732" CreationDate="2016-04-05T08:29:24.587" Score="1" Body="&lt;p&gt;I've never used a vibration motor, but I think you do need all of the circuit.  Its says in the text, but the transistor is needed because the Arduino 'doesn't supply enough current through the output port' and the diode and cap are required to prevent spikes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the flimsy wires you could solder them onto a bit of strip board and then solder &quot;proper&quot; wires of connectors onto the board too.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-05T08:29:24.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22739" PostTypeId="2" ParentId="22687" CreationDate="2016-04-05T09:07:50.870" Score="0" Body="&lt;p&gt;As noted in Paul's comment, you could use NeoPixels instead of ordinary LEDs for the display.  Each NeoPixel contains RGB LEDs and a microcontroller that accepts a serial stream of bits in, cleans up the waveform, and passes what it doesn't need on through, to the next NeoPixel.  This would reduce the necessary number of pins by 8, since a string of NeoPixels uses one signal pin, independent of the number of NeoPixels in the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the touch-sensitive (capacitive) buttons, rather than two wires per button, you can use one sense wire per button, and one drive wire per set of buttons, thus 10 pins to sense nine buttons, rather than the 18 pins mentioned in the question.  A sketch is shown below that samples nine capacitive buttons about 1300 times per second.  Here is some sample output from the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;At t=2354 button 0 on at level 274  xoooooooo  nr= 3121&#xA;At t=2975 button 1 on at level 283  xxooooooo  nr= 3943&#xA;At t=3056 button 2 on at level 271  oxxoooooo  nr= 4048&#xA;At t=3235 button 3 on at level 280  oooxooooo  nr= 4283&#xA;At t=3272 button 4 on at level 278  oooxxoooo  nr= 4331&#xA;At t=3418 button 5 on at level 284  ooooxxooo  nr= 4521&#xA;At t=3460 button 6 on at level 275  ooooooxoo  nr= 4575&#xA;At t=3507 button 7 on at level 278  oooooooxo  nr= 4636&#xA;At t=3632 button 8 on at level 290  oooooooxx  nr= 4799    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each entry like “level 278” shows the value of a running average of counts for a button; since the program is using 270 as a threshhold value for a button being on, it's reasonable for the numbers to be slightly above 270.  (Note, if the call to &lt;code&gt;secondlyReport()&lt;/code&gt; were uncommented, one would see that the running averages go on up into the 300 to 500 count range when a button is pressed.)  The strings of o's and x's show which buttons are on and which are off.  The numbers after &lt;code&gt;nr=&lt;/code&gt; are the number of button readings taken so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program implements smoothing (via a running average with exponential decay), debounce (via “holdoff” counts, as explained in detail in a &lt;a href=&quot;https://arduino.stackexchange.com/a/22621/3917&quot;&gt;previous answer&lt;/a&gt;), and hysteresis (going from off to on at a high count (270) and from on to off at a lower count (170)).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program may need tuning to work with a given set of capacitive buttons.  The tuning variables used here (such as &lt;code&gt;ButtonIsOn = 270&lt;/code&gt;, &lt;code&gt;ButtonIsOff = 170&lt;/code&gt;, &lt;code&gt;usSettle=60&lt;/code&gt;, &lt;code&gt;usPreWait=5&lt;/code&gt;, and &lt;code&gt;nsamp = 40&lt;/code&gt;) work ok with my nine-button setup where each capacitive button is attached to an input pin (like 4,5,...12) and to a 619K resistor (a size I have a number of).  The other end of each of those resistors attaches to Uno pin 13.  By changing &lt;code&gt;ButtonIsOn&lt;/code&gt; and &lt;code&gt;ButtonIsOff&lt;/code&gt;, one should be able to accomodate resistor sizes from a megohm on up to perhaps 4 or 5 megohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, to install &lt;code&gt;Streaming.h&lt;/code&gt; (which doesn't increase code size) unzip &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduiniana.org&lt;/a&gt; in your &lt;code&gt;sketchbook/libraries&lt;/code&gt; directory.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/* Via serial port, tell the current time when capacitive readings on&#xA;  various digital pins show a button has been &quot;pressed&quot; or &quot;released&quot;.&#xA;  This version reads buttons using 13 as a drive pin, and two groups&#xA;  of pins as capacitive switches: group D = pins 4,5,6,7, group B =&#xA;  8,9,10,11,12.  Each of those pins should be connected to the drive&#xA;  pin via (eg) a 1M ohm resistor.   JW - April 2016&#xA;&#xA; See eg refs at http://playground.arduino.cc/Code/CapacitiveSensor and&#xA; http://www.arduino.cc/en/Reference/PortManipulation and&#xA; http://garretlab.web.fc2.com/en/arduino/inside/arduino/Arduino.h/digitalPinToPort.html&#xA; */&#xA;#include &amp;lt;Streaming.h&amp;gt;       // provides nicer syntax for printing&#xA;enum { pinsMax = 9 };        // upper size on pins count per sample;&#xA;enum { nPortReads = 40 };    // # bit samples saved per reading;&#xA;enum { bundleSize = 16 };    // 2^j samples carried in running average&#xA;enum { drivePin = 13 };      // # of pin to drive capacitors&#xA;enum { ButtonIsOn = 270 };   // button-on level, with hysteresis&#xA;enum { ButtonIsOff= 170 };   // button-off level &quot;    &quot;&#xA;enum { usSettle = 60 };      // Hold sense pins low this long.&#xA;enum { usPreWait = 5 };      // Ignore probably crosstalk this long.&#xA;enum { nKeys=9 };        // # of keys in PinSet. Cannot be &amp;gt; pinsMax&#xA;#define PinSet &quot;4,5,6,7,8,9,10,11,12&quot;&#xA;unsigned int AvCount[nKeys]={0};&#xA;unsigned long int nSamples; // # of samples taken&#xA;//-----------------------------------------------------------&#xA;// Use delta=0 for startup, vs delta=1 for exponential averaging&#xA;void makeSample(int delta) {  // Take a sample, add it to AvCount&#xA;  byte counts[nKeys], j, nc;&#xA;  unsigned int bundle;&#xA;  nc = countPins7(drivePin, PinSet, counts);&#xA;  for (j=0; j&amp;lt;nc; ++j) {&#xA;    bundle = AvCount[j] * (bundleSize-delta);&#xA;    AvCount[j] = bundle/bundleSize + counts[j];&#xA;  }&#xA;  ++nSamples;&#xA;}&#xA;//-----------------------------------------------------------&#xA;void setup() {&#xA;  Serial.begin(115200);     // initialize serial port&#xA;  nSamples = 0;&#xA;  // Initialize AvCount[] with a bundle of samplecounts&#xA;  for (byte j=0; j&amp;lt;bundleSize; ++j)&#xA;    makeSample(0);      // Add sample directly to total&#xA;}&#xA;//-----------------------------------------------------------&#xA;// portSampler7(): countPins7() calls this routine, which holds&#xA;// drivePin and involved pins on current port low for usSettle &#xA;// us, then makes them inputs and turns on drivePin.  It waits&#xA;// usPreWait us (to weed out crosstalk), then reads the port &#xA;// nPortReads times as the pins recharge.&#xA;// The set of nPortReads port readings is returned in portReadings.&#xA;//  &#xA;// Inputs:  drivePin, portCode, pinsMask.  Constant nPortReads.&#xA;// Output:  array of nPortReads portReadings. &#xA;//&#xA;// This version takes 8 cycles per reading.  Inputs switch &#xA;// on after about one RC time constant.  On a 16MHz Arduino an&#xA;// m-count result (that is, a zero bit in m of the nPortReads reads)&#xA;// suggests RC is about m/2 us + usPreWait us.&#xA;&#xA;void portSampler7(byte drivePin, byte portCode,&#xA;          byte pinsMask, byte *portReadings) {&#xA;  volatile byte *pin, *port, *ddr;&#xA;  // pin, port, and ddr are pointers to registers with volatile&#xA;  // contents: input port, output port, direction register.&#xA;  pinMode(drivePin, OUTPUT);&#xA;  digitalWrite(drivePin,LOW);&#xA;  pin =  portInputRegister (portCode); // eg points to PIND&#xA;  port = portOutputRegister(portCode); // eg points to PORTD&#xA;  ddr =  portModeRegister  (portCode); // eg points to DDRD&#xA;  *port &amp;amp;= ~pinsMask;        // Turn off our pins&#xA;  *ddr  |= pinsMask;         // Make our pins be outputs, briefly&#xA;  delayMicroseconds(usSettle); // Delay to let pins settle low&#xA;  *ddr &amp;amp;= ~pinsMask;         // Make our pins be high-impedance inputs&#xA;  digitalWrite(drivePin,HIGH); // Turn on driver pin&#xA;  delayMicroseconds(usPreWait);&#xA;  for (byte i=0; i&amp;lt;nPortReads; ++i) // Take and store nPortReads readings&#xA;    portReadings[i] = *pin;&#xA;}&#xA;//-----------------------------------------------------------&#xA;/* Decode a pins-list into one list per involved port.&#xA;   Use portSampler7() to get rise-time counts for each port.&#xA;&#xA;   If pins are spread across k ports, countPins7()  will make&#xA;   k calls to portSampler7().  Results are in counts array.&#xA;   Note, make pinsMax larger if pinsMax &amp;lt; #(pins in list).&#xA;&#xA;   pinsList can look like &quot;2,3,4,5,6&quot; or &quot;2,4,5,12,9,23,17,7&quot;&#xA;   etc.  A list may contain digits and commas only.  Pins may be&#xA;   listed in any desired order.  Elements of counts[] will be in&#xA;   list-order.  Eg, in the &quot;2,3,4,5,6&quot; example, counts[0] is the&#xA;   count for pin 2, counts[1] is the count for pin 3, etc.  A&#xA;   larger count implies longer rise time and larger capacitance.&#xA; */&#xA;byte countPins7(byte drivePin, char *pinsList, byte *counts) {&#xA;  byte pnum, pomask, pocode, potem, i, j, mul;&#xA;  byte sampl[nPortReads], pim[pinsMax], pat[pinsMax], bout=0, nat=0, pcon;&#xA;  char *c, cc;&#xA;  int usedPorts=0;  // To track which ports are done&#xA;  for (c=pinsList, counts[0]=pcon=0; *c; ++c) // Zero the counts array&#xA;    if (*c &amp;lt; '0' || *c &amp;gt; '9') counts[++pcon] = 0;&#xA;  // In each pass, group bit numbers by port and sample the port&#xA;  while (nat&amp;lt;pcon) { // Each loop pass sets one bit in usedPorts&#xA;    pnum = pocode = pomask = bout = pcon = 0;&#xA;    c = pinsList;&#xA;    while ((cc=*c++)) {  // Loop until c is at end of string&#xA;      if ('0' &amp;lt;= cc &amp;amp;&amp;amp; '9' &amp;gt;= cc) {&#xA;        pnum = 10*pnum + cc - '0';&#xA;        if ( *c &amp;lt; '0' || *c &amp;gt; '9') { // See if pin # is complete&#xA;          potem = digitalPinToPort(pnum);  // Get port #, in range 1 to 12&#xA;          if (!(usedPorts &amp;amp; (1&amp;lt;&amp;lt;potem))) { // Is potem's port already done?&#xA;            if (!pocode)           // If pocode not set, set it&#xA;              pocode = digitalPinToPort(pnum);&#xA;            if (pocode == potem) {  // Process pin if it's in current port&#xA;              pomask |= (pim[bout] = digitalPinToBitMask(pnum));&#xA;              pat[bout++] = pcon; // Save location of pin's bit in results&#xA;            }&#xA;          }&#xA;          pnum = 0; // Clear # accumulator&#xA;          ++pcon;   // Count pin numbers&#xA;        }&#xA;      }&#xA;    }&#xA;    // Now pomask is a mask for all bits to be read from port pocode&#xA;    // and we are ready to sample current port.&#xA;&#xA;    // Get nPortReads port readings into sampl array.&#xA;    portSampler7(drivePin, pocode, pomask, sampl);&#xA;    usedPorts |= 1&amp;lt;&amp;lt;pocode;       // Mark the port finished&#xA;    // Count up # of zeroes (ie rise times) in sampled bits&#xA;    for (j=0; j&amp;lt;bout; ++j) {&#xA;      int count;&#xA;      byte m=pim[j];&#xA;      for (count=i=0; i&amp;lt;nPortReads; ++i)&#xA;        count += sampl[i] &amp;amp; m;&#xA;      counts[pat[j]] += nPortReads - count/m; // Return the number of Zeroes&#xA;    }&#xA;    nat += bout;        // Count number of pins done so far&#xA;  }&#xA;  return pcon;          // Return # of pins processed&#xA;}&#xA;//-----------------------------------------------------------&#xA;// Measure rise times at designated pins and report&#xA;// current running averages of rise times, once per second&#xA;void secondlyReport() {&#xA;  unsigned int seconds=0, now;&#xA;  while (1) {&#xA;    now = millis()/1000;&#xA;    makeSample(1);      // Add a sample to running average&#xA;    if (now &amp;gt; seconds) {    // See if next second started&#xA;      Serial &amp;lt;&amp;lt; &quot;Counts: &quot;;&#xA;      for (byte j=0; j&amp;lt;nKeys; ++j) // Show output&#xA;        //for (byte j=1; j&amp;lt;nKeys; j+=2) // Show output&#xA;        Serial &amp;lt;&amp;lt; AvCount[j] &amp;lt;&amp;lt; &quot; &quot;;&#xA;      Serial &amp;lt;&amp;lt; &quot; t=&quot; &amp;lt;&amp;lt; now &amp;lt;&amp;lt; &quot; sec.&quot; &amp;lt;&amp;lt; endl;&#xA;    }&#xA;    seconds = now;&#xA;  }&#xA;}&#xA;//-----------------------------------------------------------&#xA;// Frequently sample rise times on designated pins, to&#xA;// find and report capacitive key press times &amp;amp; levels.&#xA;void keypressReport() {&#xA;  // Old-state and holdoff-count vars&#xA;  byte ostate[nKeys] = {0}, holdo[nKeys] = {0}, j, k;&#xA;  while (1) {&#xA;    makeSample(1);      // Add a sample to running average&#xA;    for (k=0; k&amp;lt;nKeys; ++k) {&#xA;      if (holdo[k]) {       // Ignore an on button during holdoff&#xA;      --holdo[k];&#xA;      } else {&#xA;    if (AvCount[k] &amp;gt; ButtonIsOn ||&#xA;       (AvCount[k] &amp;gt; ButtonIsOff &amp;amp;&amp;amp; ostate[k])) {&#xA;      if (!ostate[k]) { // Were we off?&#xA;            ostate[k] = 1;  // New button press&#xA;            holdo[k] = 40; // Start a holdoff period&#xA;            Serial &amp;lt;&amp;lt; &quot;At t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; &quot; button &quot; &amp;lt;&amp;lt; k;&#xA;            Serial &amp;lt;&amp;lt; &quot; on at level &quot; &amp;lt;&amp;lt; AvCount[k] &amp;lt;&amp;lt; &quot;  &quot;;&#xA;            for (j=0; j&amp;lt;nKeys; ++j)&#xA;              Serial &amp;lt;&amp;lt; (ostate[j]? 'x' : 'o');&#xA;            Serial &amp;lt;&amp;lt; &quot;  nr= &quot; &amp;lt;&amp;lt; nSamples &amp;lt;&amp;lt; endl;&#xA;          }&#xA;          ostate[k] = 1;     // We detected button is on&#xA;        } else {&#xA;          ostate[k] = 0;     // We detected button is off&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;//-----------------------------------------------------------&#xA;void loop() {&#xA;  if (0) secondlyReport();&#xA;  keypressReport();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-06T06:34:48.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22740" PostTypeId="2" ParentId="22732" CreationDate="2016-04-05T10:43:26.307" Score="1" Body="&lt;p&gt;You could make a simpler circuit by removing the diode, capacitor.  BUT this comes at the cost of having a circuit that could kill your arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stick with it and build the entire thing.  This isn't a shortcut worth taking.&lt;/p&gt;&#xA;" OwnerUserId="3058" LastActivityDate="2016-04-05T10:43:26.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22741" PostTypeId="1" CreationDate="2016-04-05T10:47:33.750" Score="2" ViewCount="498" Body="&lt;p&gt;I have made a custom board based on the Arduino Due but have some problems with the Serial communication with the 16u2 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have usb connection with the 16u2 chip and was able to load the arduino-due usb serial hex over the usb port. the usb now shows up as arduino com port. now when i try to load a sketch it says No device found on COM12. the SAM chip is erased but it can't load the new sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;now when i load a sketch with a simple serial print at 115200 over the native port. the SAM chip is programmed correctly. when i open the serial monitor i receive data but it is garbage! the garbage is always different. the sketch is at 115200 and the monitor also at 115200.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this would explain why it can't upload a sketch with the 16u2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the same sketch on a original arduino due works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the transmit an receive led are blinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would cause this garbage in the connection where do i start looking?&lt;/p&gt;&#xA;" OwnerUserId="19917" LastActivityDate="2016-04-05T10:47:33.750" Title="Arduino Due Serial garbage" Tags="|arduino-due|" AnswerCount="0" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="22742" PostTypeId="2" ParentId="22731" CreationDate="2016-04-05T10:55:10.997" Score="1" Body="&lt;p&gt;That is a tough one...  Because arduino-builder is basically a custom go script you don't get the facilities you get in a Makefile, like shell execution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be inclined to do this kind of thing outside that environment - use some external program or tool to generate a config.h file (maybe use something like GNU Autotools) that contains your custom defines. That can then be #included in your sketch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T10:55:10.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22743" PostTypeId="2" ParentId="22732" CreationDate="2016-04-05T11:23:48.133" Score="3" Body="&lt;p&gt;Lets break down the circuit and have a look why everything in that circuit is there and what it does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we have the 33R resistor before the motor which limits the current to the motor. This particular motor is rated at 75mA and has a starting of 85mA. The 33R resistor limits the current to 130mA maximum through the motor. If the risk of the motor pulling too much current is an issue then stick a fuse in-line&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there's the motor, not much to say here really. It's whatever motor you're using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We then have both a diode and a capacitor across the motor. I find this a bit strange, I've seen the use of flyback diodes, I've seen the use of snubbers, but both? The purpose of the diode is to allow a return path for any spikes caused by switching off power to the inductive load (the motor) which stops them from damaging the transistor. For the capacitor, just remove it, it's not got any use here really.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then comes the transistor, it might be easier to think of a transistor as a switch (especially in this example). When you put a little bit of current on the base, the transistor 'opens' allowing the motor to connect to ground. The reason we have to use a transistor is because the outputs of an arduino are only able to supply a maximum of 40mA, we need more than that to run our motor. Fortunately, the transistor is not going to need any more than 5mA on it's base which is why we use it to 'switch in' components that require more voltage/current. The 1K resistor on the base is to limit the current coming from the arduino and preventing it from killing our poor transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tl;dr - You need everything except the capacitor&lt;/p&gt;&#xA;" OwnerUserId="19785" LastEditorUserId="19785" LastEditDate="2016-04-05T12:41:59.660" LastActivityDate="2016-04-05T12:41:59.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22744" PostTypeId="2" ParentId="22732" CreationDate="2016-04-05T11:52:46.527" Score="2" Body="&lt;p&gt;There are actually a number of things wrong with that circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First the motor runs from 2.5 to 3.8V, yet they show it running off the 5V supply pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly they include a 33Ω resistor to &quot;limit the current&quot;. It doesn't! It drops a voltage depending on the current flowing through it, and the current flowing through it depends on the speed and load of the motor at the time.  So the motor itself will be getting a fairly random voltage applied to it, which at times will be below the specifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g.:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The start current is 85mA.  V=RI, 33*0.085 = 2.805V. 5 - 2.805 = 2.195V: way below the 2.5V required minimum.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The run current of 75mA calculates as: 33*0.075 = 2.475. 5 - 2.475 = 2.525V: only just enough for it to run.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So it should be powered from a 3.3V supply that has enough current capacity to drive it (85mA) and the 33Ω resistor should be removed entirely.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-05T12:12:21.780" LastActivityDate="2016-04-05T12:12:21.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22745" PostTypeId="1" CreationDate="2016-04-05T13:22:55.813" Score="0" ViewCount="70" Body="&lt;p&gt;I uploaded a bluetooth sketch from IDE (File-&gt;Examples-&gt;Firmata-&gt;Standard Firmata) to Arduino Duo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now if I have a sensor attached to this Arduino, I can use bluetooth from another device (Raspberry pi or mobilephone) to read the sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what if I want to do something in the arduino itself? I see only one option&#xA;which is to edit the standardfirmata to read the sensor and do something. So multiple sketches running in one sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I correct?&lt;/p&gt;&#xA;" OwnerUserId="19920" LastActivityDate="2023-04-01T23:04:40.583" Title="Bluetooth and another sketch" Tags="|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22748" PostTypeId="2" ParentId="22731" CreationDate="2016-04-05T13:37:57.363" Score="0" Body="&lt;p&gt;For the date and time of compilation there are predefined preprocessor symbols: &lt;code&gt;__DATE__&lt;/code&gt; and &lt;code&gt;__TIME__&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-05T13:37:57.363" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22750" PostTypeId="2" ParentId="22605" CreationDate="2016-04-05T13:56:39.570" Score="-1" Body="&lt;p&gt;The problems were caused by the vibrating motor. It's shaking caused the rotating part touched the surface and the motor stopped for a while.&lt;br&gt;&#xA;Thank you for you help.&lt;/p&gt;&#xA;" OwnerUserId="19820" LastActivityDate="2016-04-05T13:56:39.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22751" PostTypeId="1" AcceptedAnswerId="22752" CreationDate="2016-04-05T14:01:54.643" Score="0" ViewCount="1034" Body="&lt;p&gt;I'm looking for a portable power source for an MQ-7 gas sensor. According to my research - it needs 5V D.C power with at least 0.3A of current. I'm not really good with electronics so I need to know if I can use a 9V battery instead which produces 0.5A. Will the cell damage my sensor and if it does may you please recommend me something else.&lt;/p&gt;&#xA;" OwnerUserId="19922" LastActivityDate="2016-04-05T14:27:52.397" Title="Is it safe to power an MQ-7 gas sensor with a 9V D.C supply?" Tags="|arduino-uno|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22752" PostTypeId="2" ParentId="22751" CreationDate="2016-04-05T14:27:52.397" Score="0" Body="&lt;p&gt;You can, but you will have to reduce the voltage to the 5V the sensor needs, otherwise you will blow up the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To that end you require a voltage regulator. You can use a linear regulator like the Arduino has on-board, but they are very wasteful of power and will dissipate the excess 4V of electricity as heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Better would be to use a switching regulator (commonly and cheaply available on eBay and other sites) to step the voltage down to 5V more efficiently.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T14:27:52.397" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22753" PostTypeId="1" AcceptedAnswerId="22754" CreationDate="2016-04-05T14:38:51.003" Score="1" ViewCount="262" Body="&lt;p&gt;&lt;a href=&quot;http://www.hth.com/filelibrary/pdffiles/snap.pdf&quot; rel=&quot;nofollow&quot;&gt;I've reviewed the documentation&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm still a little lost when it comes to applying the functions. Each of the redundancy check methods take in an unsigned char and return an unsigned char.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Shouldn't there be some sort of boolean return somewhere confirming that the data is accurate?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been trying to debug &lt;code&gt;unsigned char* tempData = &quot;snap&quot;&lt;/code&gt; to the terminal, writing it directly to the register, according to the doc it should return &lt;code&gt;h17&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  UDR0 = crc8(tempData,sizeof(tempData));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The terminal outputs '?' - as if it cannot be read.&lt;/p&gt;&#xA;" OwnerUserId="19328" LastEditorUserId="19328" LastEditDate="2016-04-05T14:42:51.190" LastActivityDate="2016-04-05T14:50:31.130" Title="How do I use SNAP protocol, correctly?" Tags="|c|avr|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22754" PostTypeId="2" ParentId="22753" CreationDate="2016-04-05T14:50:31.130" Score="2" Body="&lt;p&gt;The &lt;code&gt;crc8&lt;/code&gt; function calculates the Cyclic Redundancy Check (8-bit) value for the data you provide. It is then up to you to compare that calculated value with the CRC you have received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;?&lt;/code&gt; you are seeing in the serial terminal is an &lt;em&gt;unprintable&lt;/em&gt; character. It is representing an 8-bit value that doesn't lie within the 32-127 range of normal ASCII characters, or 32-255 of the extended ASCII character set.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T14:50:31.130" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22757" PostTypeId="1" CreationDate="2016-04-05T17:20:53.377" Score="1" ViewCount="8050" Body="&lt;p&gt;I am trying to extract a substring out of another string, but it doesn't seem to be working. I am new to programming in arduino and c++ in general. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;char rfid;&#xA;&#xA;void loop()&#xA;{&#xA;  while (Serial.available() &amp;gt; 0)&#xA;  {&#xA;    rfid = Serial.read();&#xA;    String cardnum(rfid);&#xA;    cardnum.replace(&quot;&quot;, &quot;&quot;);&#xA;    cardnum.replace(&quot;&quot;, &quot;&quot;);&#xA;    String id = cardnum.substring(0,2);&#xA;    Serial.print(id);&#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first argument in &lt;code&gt;cardnum.replace(&quot;&quot;, &quot;&quot;);&lt;/code&gt; and &lt;code&gt;cardnum.replace(&quot;&quot;, &quot;&quot;);&lt;/code&gt; replaces the start and end bit with nothing, but it somehow doesn't display it correctly here.&lt;br&gt;&#xA;Now on to the problem at hand. The output for &lt;code&gt;cardnum&lt;/code&gt; is &lt;i&gt;1F006B471F2C&lt;/i&gt; which it should be, but the ouput for &lt;code&gt;id&lt;/code&gt; is the same, when i want it to be only the first two characters of &lt;code&gt;cardnum&lt;/code&gt;. How would i go about achieving that.&lt;br&gt;&#xA;Thanks in advance for any answers you can provide.&lt;/p&gt;&#xA;" OwnerUserId="19929" LastActivityDate="2016-04-05T17:43:31.783" Title="Extracting a substring from original string" Tags="|string|rfid|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22758" PostTypeId="2" ParentId="22757" CreationDate="2016-04-05T17:43:31.783" Score="2" Body="&lt;p&gt;Let's dissect your program a moment and see why it's not doing what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (Serial.available() &amp;gt; 0)&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So while there are characters available to read in the serial buffer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  rfid = Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;read one character into the &lt;code&gt;rfid&lt;/code&gt; variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String cardnum(rfid);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Convert that character into a string.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  cardnum.replace(&quot;&quot;, &quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Replace nothing (&lt;code&gt;&quot;&quot;&lt;/code&gt;) with nothing (&lt;code&gt;&quot;&quot;&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  cardnum.replace(&quot;&quot;, &quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do the same again,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String id = cardnum.substring(0,2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Take the first two characters of the string that contains the single character that you have read.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.print(id);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Print it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically you have read one character, made it into a string, done nothing to it, copied it to another string, then printed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of this method, which does nothing useful, you should read the whole ID into a string (I'd use a C string [i.e., char array] rather than an Arduino String object) then perform operations on that string once you have read the whole ID code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's many methods of doing that, but how you do it is heavily influenced by exactly how the data is presented to you. Does it have a terminating CR or LF to indicate the end of the string? If not you will have to use some form of timeout to determine when the string has been completer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T17:43:31.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22759" PostTypeId="1" CreationDate="2016-04-05T17:47:02.493" Score="1" ViewCount="55" Body="&lt;p&gt;I am Looking for a Mega 2650 drawing or picture that shows the components labeled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen the schematics but didn't find a labeled assembly drawing yet.  Should this exist?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-04-05T17:58:20.627" Title="Looking for a Mega 2650 drawing or picture that shows the components labeled" Tags="|arduino-mega|components|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22760" PostTypeId="2" ParentId="22759" CreationDate="2016-04-05T17:58:20.627" Score="2" Body="&lt;p&gt;Yes, it exists, but not (commonly) as an &quot;image&quot; in the traditional sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to install Eagle PCB design software and open the PCB file downloadable from the Arduino site from where you can see exactly which component is where.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T17:58:20.627" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22761" PostTypeId="1" CreationDate="2016-04-05T19:07:50.867" Score="0" ViewCount="235" Body="&lt;p&gt;I am trying to setup a series of lights (traffic lights) that change based on a timer that begins when a button is pressed.  The goal is to use the lights to track how long its been since you pressed the button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I am running into is trying to use the &quot;TimeAlarms&quot; library.  I am getting an error&#xA;'Timer' was not declared in this scope&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it may be an issue with the version of Arduino I am using (1.6.8) but I am not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Board: Arduino Leonardo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here the code&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimeAlarms.h&amp;gt;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;TimeLib.h&amp;gt;&#xA;&#xA;int redPin = 2;&#xA;int yellowPin = 3;&#xA;int greenPin = 4;&#xA;int buttonPin = 5;&#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) ;&#xA;  pinMode(redPin, OUTPUT);&#xA;  pinMode(yellowPin, OUTPUT);&#xA;  pinMode(greenPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  // set timers in seconds, yellow = 24 hours, red = 48 hours)&#xA;  // http://www.pjrc.com/teensy/td_libs_TimeAlarms.html&#xA;  Alarm.timerOnce(86400, YellowTimer);&#xA;  Alarm.timerOnce(172800, RedTimer);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if (digitalRead(buttonPin))&#xA;  {&#xA;      setLights(LOW, LOW, HIGH)&#xA;      void YellowTimer(){&#xA;         setLights(LOW, HIGH, LOW)&#xA;         }&#xA;      void RedTimer(){&#xA;         setLights(HIGH, LOW, LOW)&#xA;         }&#xA;  }&#xA;  delay (1000);&#xA;  }&#xA;&#xA;void setLights(int red, int yellow, int green)&#xA;{&#xA;  digitalWrite(redPin, red);&#xA;  digitalWrite(yellowPin, yellow);&#xA;  digitalWrite(greenPin, green);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19931" LastEditorUserId="19515" LastEditDate="2016-04-05T19:54:21.000" LastActivityDate="2016-04-06T00:05:54.070" Title="Trying to start a timer to change lights when a button is pressed" Tags="|programming|arduino-leonardo|button|time|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22762" PostTypeId="1" AcceptedAnswerId="22763" CreationDate="2016-04-05T20:21:05.793" Score="3" ViewCount="7477" Body="&lt;p&gt;I have this really simple sketch where I blink a led light.&#xA;If I send another value threw the serial monitor then first there is always a brief second where the light doesn't blink anymore. Why is that, and how can I get rid of that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int the_delay = 300;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  pinMode(12, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(12, HIGH);   &#xA;  delay(the_delay);            &#xA;  digitalWrite(12, LOW);    &#xA;  delay(the_delay);            &#xA;}&#xA;&#xA;&#xA;void serialEvent() {&#xA;&#xA;  if (Serial.available()) {   &#xA;    the_delay = Serial.parseInt();&#xA;    Serial.println(the_delay);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case it helps, eventually I would like to send values with 60fps.&lt;/p&gt;&#xA;" OwnerUserId="19933" LastActivityDate="2021-10-15T09:01:11.263" Title="Why does the arduino respond so slow to serial input" Tags="|arduino-uno|serial|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22763" PostTypeId="2" ParentId="22762" CreationDate="2016-04-05T20:33:54.217" Score="3" Body="&lt;p&gt;It's because you're using &lt;code&gt;Serial.parseInt()&lt;/code&gt;.  It uses a timeout to find the end of the data on the serial port, and while it's waiting for that timeout it can do nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would be better off manually reading the serial data a character at a time to build up an input string (C-string, not Arduino String) with a proper line terminator (line-feed, &lt;code&gt;\n&lt;/code&gt;) and then convert that into an integer with &lt;code&gt;atoi()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-05T20:33:54.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22765" PostTypeId="1" CreationDate="2016-04-05T21:07:44.320" Score="0" ViewCount="1511" Body="&lt;p&gt;I'm new to Arduino; and I'm trying to upload a simple sketch to a new Arduino Nano&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried a few sketches (blink / helloworld / empty one); and changing the USB PORT.&#xA;Windows find the correct serial port (but it's a CH340 USB-Serial; I think that's some Chinese clone).&#xA;I tried a few USB ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I upload the sketch, it seems to upload. But a verification error appears:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x00ea&#xA;         0x8c != 0x8d&#xA;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the command line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;D:\Arduino\hardware\tools\avr/bin/avrdude -CD:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b57600 -D -Uflash:w:C:\Users\corti\AppData\Local\Temp\build462236accad2415310c5b24cce7ccca0.tmp/Blink.ino.hex:i &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the full verbose log of the flashing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;D:\Arduino\hardware\tools\avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM6&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;         Hardware Version: 2&#xA;         Firmware Version: 1.16&#xA;         Vtarget         : 0.0 V&#xA;         Varef           : 0.0 V&#xA;         Oscillator      : Off&#xA;         SCK period      : 0.1 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: reading input file &quot;C:\Users\corti\AppData\Local\Temp\build462236accad2415310c5b24cce7ccca0.tmp/Blink.ino.hex&quot;&#xA;avrdude: writing flash (1066 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.32s&#xA;&#xA;avrdude: 1066 bytes of flash written&#xA;avrdude: verifying flash memory against C:\Users\corti\AppData\Local\Temp\build462236accad2415310c5b24cce7ccca0.tmp/Blink.ino.hex:&#xA;avrdude: load data flash data from input file C:\Users\corti\AppData\Local\Temp\build462236accad2415310c5b24cce7ccca0.tmp/Blink.ino.hex:&#xA;avrdude: input file C:\Users\corti\AppData\Local\Temp\build462236accad2415310c5b24cce7ccca0.tmp/Blink.ino.hex contains 1066 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 0.24s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x00ea&#xA;         0x8c != 0x8d&#xA;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19934" LastEditorUserId="8033" LastEditDate="2016-04-07T15:08:54.263" LastActivityDate="2018-12-13T12:12:18.747" Title="Arduino Nano - Upload verification error" Tags="|arduino-nano|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22766" PostTypeId="2" ParentId="22762" CreationDate="2016-04-05T21:58:39.880" Score="2" Body="&lt;p&gt;Try typing a non-digit character after the delay value; even &lt;code&gt;Enter&lt;/code&gt; should work if your terminal is configured to send any kind of end-of-line. &lt;code&gt;Serial.parseInt()&lt;/code&gt; waits the full timeout (default: 1000 ms) after each digit, for the next one. A non-digit will end the input value immediately.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorDisplayName="user24204" LastEditDate="2016-09-30T13:36:15.090" LastActivityDate="2016-09-30T13:36:15.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22767" PostTypeId="5" CreationDate="2016-04-05T22:01:31.180" Score="0" Body="&lt;p&gt;An opamp is a high gain amplifier, which amplifies the voltage difference between its two inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ideal opamp has the following properties:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;infinite open-loop gain&lt;/li&gt;&#xA;&lt;li&gt;infinite bandwidth&lt;/li&gt;&#xA;&lt;li&gt;zero input current&lt;/li&gt;&#xA;&lt;li&gt;zero output impedance&lt;/li&gt;&#xA;&lt;li&gt;zero offset voltage&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Real op-amps often have gains of minimum 100 dB, which makes them of little use without feedback. Negative feedback is most often used, and allows the design of inverting amplifiers, non-inverting amplifiers, integrators, differentiators and filters. Positive feedback is used to construct Schmitt-triggers.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-10T20:39:14.127" LastActivityDate="2016-04-10T20:39:14.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22768" PostTypeId="4" CreationDate="2016-04-05T22:01:31.180" Score="0" Body="An op-amp (operational amplifier) is a high gain analog voltage amplifier with differential high impedance inputs, and a low impedance output. A basic building block in signal processing, like as amplifier or active filter." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-10T20:39:20.583" LastActivityDate="2016-04-10T20:39:20.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22769" PostTypeId="5" CreationDate="2016-04-05T22:03:03.807" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-04-05T22:03:03.807" LastActivityDate="2016-04-05T22:03:03.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22770" PostTypeId="4" CreationDate="2016-04-05T22:03:03.807" Score="0" Body="It refers to the Arduino HC-06 bluetooth module." OwnerUserId="19515" LastEditorUserId="11529" LastEditDate="2016-04-10T20:39:42.613" LastActivityDate="2016-04-10T20:39:42.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22771" PostTypeId="2" ParentId="22761" CreationDate="2016-04-05T23:26:03.303" Score="1" Body="&lt;p&gt;You must first declare your timer functions. I have placed them above so they are visible when you call the timer. Also in the loop() you want probably to call timer.&#xA;I have changed the code to reflect what I told above. I do not have ability to test this, so please try. There may be some syntax errors, but I think you can handle it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimeAlarms.h&amp;gt;&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;TimeLib.h&amp;gt;&#xA;&#xA;int redPin = 2;&#xA;int yellowPin = 3;&#xA;int greenPin = 4;&#xA;int buttonPin = 5;&#xA;&#xA;void YellowTimer()&#xA;{&#xA;    setLights(LOW, HIGH, LOW)&#xA;}&#xA;&#xA;void RedTimer()&#xA;{&#xA;    setLights(HIGH, LOW, LOW)&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) ;&#xA;  pinMode(redPin, OUTPUT);&#xA;  pinMode(yellowPin, OUTPUT);&#xA;  pinMode(greenPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  // set timers in seconds, yellow = 24 hours, red = 48 hours)&#xA;  // http://www.pjrc.com/teensy/td_libs_TimeAlarms.html&#xA;  Alarm.timerOnce(86400, YellowTimer);&#xA;  Alarm.timerOnce(172800, RedTimer);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if (digitalRead(buttonPin))&#xA;  {&#xA;      setLights(LOW, LOW, HIGH)&#xA;      Alarm.timerOnce(86400, YellowTimer);&#xA;      Alarm.timerOnce(172800, RedTimer);&#xA;  }&#xA;  delay (1000);&#xA;  }&#xA;&#xA;void setLights(int red, int yellow, int green)&#xA;{&#xA;  digitalWrite(redPin, red);&#xA;  digitalWrite(yellowPin, yellow);&#xA;  digitalWrite(greenPin, green);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-04-06T00:05:54.070" LastActivityDate="2016-04-06T00:05:54.070" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22772" PostTypeId="2" ParentId="22688" CreationDate="2016-04-06T01:42:59.410" Score="1" Body="&lt;p&gt;The board seems to be working. After I plugged in an ftdi connector (adafruit FTDI friend) and uploaded blink to it, it started blinking every second instead of really fast. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation was a bit confusing as it implied that blink was pre-loaded on the device but instead it would just blink extremely fast until it went all the way on and then turn off the green led. &lt;/p&gt;&#xA;" OwnerUserId="19871" LastActivityDate="2016-04-06T01:42:59.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22773" PostTypeId="1" CreationDate="2016-04-06T03:16:03.033" Score="4" ViewCount="231" Body="&lt;p&gt;Something happened to my mega2650 as I was experimenting the other day.  It no longer turned on when powering from the 2.1mm jack or from Vin, regardless of the voltage applied.  A plastic bubble had formed on the 5V regulator, I assumed I had shorted something and fried it.  If I applied 5V to the 5V pin everything worked fine.  It also works fine when powered from USB.  So I replaced the 5V regulator with a NCP1117 version.  But I have the same situation.  If I apply voltage directly to the 5V regulator input pin I get 5V on the output pin and everything is fine.  I tested up to 12V and it is dead on at 5V.  I also checked the PNP switching transistor, and found it was working correctly.  As far as I can tell, the only thing remaining is that the trace is severed somewhere between just after the Vin pin and the 5V regulator, maybe the regulator input is not soldered well to the trace?  But this was one of the better solder joints I made, so I thought.  Any other ideas as to the root cause?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastEditorUserId="15341" LastEditDate="2016-04-06T03:30:23.050" LastActivityDate="2016-04-07T23:59:27.500" Title="a mega 2650 power supply mystery" Tags="|arduino-mega|power|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22774" PostTypeId="1" CreationDate="2016-04-06T04:51:41.863" Score="1" ViewCount="858" Body="&lt;p&gt;Pardon the double post, but I'm not getting much traction with this question over at arduino.cc so I'm looking for answers here now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Original post: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=391698.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=391698.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I get the idea of uploading a &quot;stop&quot; sketch for the purpose of&#xA;  overriding a previously uploaded program in Flash memory space.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Then of course we have EEPROM for &quot;long-term&quot; storage.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;However, let's say an Arduino: Read user input as secret key and store&#xA;  in memory (SRAM) Performed a signing operation with secret key&#xA;  Subsequently powered off&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We know that computers introduce a wide range of complications to&#xA;  security because data can still be recovered, even after being erased&#xA;  or overwritten in some cases, variables stored in memory float around&#xA;  (unless pinned for decryption in SecureString contexts, etc.), etc.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;To establish context for the following questions, let's [overly]&#xA;  simplify the attack vector in saying this would be a scenario where an&#xA;  Arduino used in a security application is physically disconnected,&#xA;  stolen, and then powered on sometime later.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Question 1: Obviously we're not talking about storing keys on disk&#xA;  necessarily (i.e. EEPROM). How likely (or difficult) would it be to&#xA;  analyze SRAM with the intent to recover keys that may have been&#xA;  previously stored in memory?&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Question 2: Similarly, let's say sensitive information was in fact&#xA;  stored in EEPROM.  Does the same hold true of data previously stored&#xA;  in EEPROM that has since been overwritten with new (i.e. zero) data?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19939" LastActivityDate="2016-04-06T16:03:45.990" Title="Forensic security of Arduino (SRAM)" Tags="|arduino-uno|memory-usage|sram|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22776" PostTypeId="2" ParentId="22774" CreationDate="2016-04-06T06:07:32.223" Score="1" Body="&lt;p&gt;Uploading a new sketch using the IDE does &quot;page erases&quot; which means that a small sketch will not completely replace a larger one. However using a ICSP programmer starts with a complete flash erase, so that would be more secure. Or you could probably (and it would be better to) upload a new sketch containing mostly random data (eg. a large array in PROGMEM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rewriting EEPROM should be pretty secure, especially if you replace the EEPROM with random data, and preferably do it a number of times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for SRAM, I would be surprised if you could recover much after a power-off. If the attacker manages to keep the power on that would be different. If possible, write over sensitive data with random bytes as soon as you don't need it any more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the data has to stay in RAM, I could envisage a scenario where if I got access to the processor (still powered on) I would upload a small sketch which would simply dump RAM to (say) the serial port a byte at a time, to avoid needing much RAM to do the dumping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the AVR processors at least would be comparatively safe. After all they don't have disks, virtual memory, or fancy remapping of sectors like a USB stick might.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Read user input as secret key and store in memory (SRAM) Performed a signing operation with secret key. Subsequently powered off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sounds pretty safe once you specify &quot;powered off&quot;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://xkcd.com/538/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://xkcd.com/538/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k8s9l.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k8s9l.png&quot; alt=&quot;Scurity&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-06T09:50:54.553" LastActivityDate="2016-04-06T09:50:54.553" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22777" PostTypeId="2" ParentId="22762" CreationDate="2016-04-06T06:11:58.760" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/serial&quot; rel=&quot;nofollow&quot;&gt;How to process incoming serial data without blocking&lt;/a&gt;. An interim solution is to get the Serial Monitor to send a newline automatically when you press Send.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is example code that processes input without blocking:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;// Example of processing incoming serial data without blocking.&#xA;&#xA;// how much serial data we expect before a newline&#xA;const unsigned int MAX_INPUT = 50;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  } // end of setup&#xA;&#xA;// here to process incoming serial data after a terminator received&#xA;void process_data (const char * data)&#xA;  {&#xA;  // for now just display it&#xA;  // (but you could compare it to some value, convert to an integer, etc.)&#xA;  Serial.println (data);&#xA;  }  // end of process_data&#xA;&#xA;void processIncomingByte (const byte inByte)&#xA;  {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte)&#xA;    {&#xA;&#xA;    case '\n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;&#xA;      // terminator reached! process input_line here ...&#xA;      process_data (input_line);&#xA;&#xA;      // reset buffer for next time&#xA;      input_pos = 0;  &#xA;      break;&#xA;&#xA;    case '\r':   // discard carriage return&#xA;      break;&#xA;&#xA;    default:&#xA;      // keep adding if not full ... allow for terminating null byte&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;    }  // end of switch&#xA;&#xA;  } // end of processIncomingByte  &#xA;&#xA;void loop()&#xA;  {&#xA;  // if serial data available, process it&#xA;  while (Serial.available () &amp;gt; 0)&#xA;    processIncomingByte (Serial.read ());&#xA;&#xA;  // do other stuff here like testing digital input (button presses) ...&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-06T21:49:35.033" LastActivityDate="2016-04-06T21:49:35.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22779" PostTypeId="1" AcceptedAnswerId="22784" CreationDate="2016-04-06T07:51:40.653" Score="1" ViewCount="23907" Body="&lt;p&gt;My intention is to control an LED according to the content of the SMS received. For example, if the SMS is &quot;ON&quot;, turn on the LED and if it is &quot;OFF&quot;, turn it off. I referred many sites and got the below code. &#xA;The digital pins 9 and 10 are used instead of Rx and Tx to avoid the code uploading problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I have kept the different versions of AT commands commented in the code because I'm not sure which one is correct. With the current one, I'm able to get some kind of output which I've mentioned after the code.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(9, 10);&#xA;&#xA;char msg;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);   // Setting the baud rate of GSM Module  &#xA;  delay(1000);&#xA;  //mySerial.print(&quot;AT+CMGF=1r&quot;); // set SMS mode to text&#xA;  mySerial.print(&quot;AT+CMGF=1\r&quot;);  // set SMS mode to text&#xA;&#xA;  delay(100);&#xA;  //mySerial.println(&quot;AT+CNMI=2,2,0,0,0&quot;); // AT Command to receive a live SMS&#xA;  //mySerial.print(&quot;AT+CNMI=2,2,0,0,0r&quot;);&#xA;&#xA;  mySerial.print(&quot;AT+CNMI=1,2,0,0,0\r&quot;); // AT Command to receive a live SMS&#xA;  delay(100);&#xA;  Serial.println(&quot;Ready&quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  if (mySerial.available()&amp;gt;0)&#xA;  {&#xA;    msg=mySerial.read();&#xA;    Serial.print(msg);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output I'm getting..&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ready&#xA;AT+CMGF=1&#xA;AT+CNMI=1,2,0,0,0&#xA;&#xA;OK&#xA;&#xA;+CMTI: &quot;SM&quot;,31&#xA;&#xA;+CMTI: &quot;SM&quot;,32&#xA;&#xA;+CMTI: &quot;SM&quot;,33&#xA;&#xA;+CMTI: &quot;SM&quot;,34&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The issue is, I'm not able to retrieve the message content. What I'm getting is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;+CMTI: &quot;SM&quot;,31&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;+CMTI: &quot;SM&quot;,32&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the number keeps on incrementing. (33, 34 and so on). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do understand that I have to parse the message to get the exact content, but here I'm not getting the content at all. What exactly should I do to get the SMS content? Could anybody help me to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more thing, the GSM module I'm using is a SIM900A type (from elementzonline.com). It's not a shield type, so I've made connections using wires; the Rx, Tx connections and the ground one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Sorry for the bad explanation, I'm a complete noob in Arduino, a hobbyist.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance. &lt;/p&gt;&#xA;" OwnerUserId="19944" LastActivityDate="2019-05-22T04:42:44.737" Title="SMS Receiving problem - Arduino Uno and SIM900A GSM Module" Tags="|arduino-uno|gsm|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22780" PostTypeId="2" ParentId="22779" CreationDate="2016-04-06T08:49:28.183" Score="1" Body="&lt;p&gt;Instead of using At commands use the GSM library of Arduino it easier to understand and implement.&#xA;the code to recieve SMS&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;GSM.h&amp;gt;&#xA;&#xA;    // PIN Number for the SIM&#xA;    #define PINNUMBER &quot;&quot; //sim pin incase the sim is kept locked &#xA;&#xA;    // initialize the library instances&#xA;    GSM gsmAccess;&#xA;    GSM_SMS sms;&#xA;&#xA;    // Array to hold the number a SMS is retreived from&#xA;    char senderNumber[20];&#xA;&#xA;    void setup() {&#xA;      // initialize serial communications and wait for port to open:&#xA;      Serial.begin(9600);&#xA;      while (!Serial) {&#xA;        ; // wait for serial port to connect. Needed for native USB port only&#xA;      }&#xA;&#xA;      Serial.println(&quot;SMS Messages Receiver&quot;);&#xA;&#xA;      // connection state&#xA;      boolean notConnected = true;&#xA;&#xA;      // Start GSM connection&#xA;      while (notConnected) {&#xA;        if (gsmAccess.begin(PINNUMBER) == GSM_READY) {&#xA;          notConnected = false;&#xA;        } else {&#xA;          Serial.println(&quot;Not connected&quot;);&#xA;          delay(1000);&#xA;        }&#xA;      }&#xA;&#xA;      Serial.println(&quot;GSM initialized&quot;);&#xA;      Serial.println(&quot;Waiting for messages&quot;);&#xA;    }&#xA;&#xA;    void loop() {&#xA;      char c;&#xA;&#xA;      // If there are any SMSs available()&#xA;      if (sms.available()) {&#xA;        Serial.println(&quot;Message received from:&quot;);&#xA;&#xA;        // Get remote number&#xA;        sms.remoteNumber(senderNumber, 20);&#xA;        Serial.println(senderNumber);&#xA;&#xA;        // An example of message disposal&#xA;        // Any messages starting with # should be discarded&#xA;        if (sms.peek() == '#') {&#xA;          Serial.println(&quot;Discarded SMS&quot;);&#xA;          sms.flush();&#xA;        }&#xA;&#xA;        // Read message bytes and print them&#xA;        while (c = sms.read()) {&#xA;          Serial.print(c);&#xA;        }&#xA;&#xA;        Serial.println(&quot;\nEND OF MESSAGE&quot;);&#xA;&#xA;        // Delete message from modem memory&#xA;        sms.flush();&#xA;        Serial.println(&quot;MESSAGE DELETED&quot;);&#xA;      }&#xA;&#xA;      delay(1000);&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19947" LastActivityDate="2016-04-06T08:49:28.183" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22782" PostTypeId="2" ParentId="22774" CreationDate="2016-04-06T09:09:01.070" Score="3" Body="&lt;p&gt;RAM memory looses its contents when it's powered off. However, this&#xA;natural erasure process is not instantaneous: it can take several&#xA;seconds, or even minutes. It has been demonstrated that cooling down a&#xA;memory chip can extend its data retention time to &lt;em&gt;hours&lt;/em&gt;, which enables&#xA;a type of attack known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Cold_boot_attack&quot; rel=&quot;nofollow&quot;&gt;cold boot&#xA;attack&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This type of attack has been studied mostly on DRAM computer modules.&#xA;The Arduino memory, however, is based on SRAM, which is physically very&#xA;different from DRAM (a transistor feedback loop vs. a capacitor). There&#xA;seems to be very little research on cold boot attacks against SRAM. I&#xA;found nonetheless a technical report from the computer laboratory of the&#xA;University of Cambridge: &lt;a href=&quot;http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-536.pdf&quot; rel=&quot;nofollow&quot;&gt;Low temperature data remanence in static&#xA;RAM&lt;/a&gt;, by Sergei&#xA;Skorobogatov. Quoting from the conclusion:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Contrary to the established wisdom, there are several chips that&#xA;  retain data for dangerous periods of time at temperatures above −20°C.&#xA;  The temperature at which 80% of the data are retained for one minute&#xA;  varies widely between devices. Some require cooling to at least −50°C,&#xA;  while others retain data for this period at room temperature.&#xA;  Retention times can be significantly reduced by shorting VCC to ground&#xA;  rather than by leaving it floating.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From this perspective I would say that, although the attack seems non&#xA;obvious, your secret key is not completely safe even in SRAM. Since the&#xA;data retention time varies widely between devices, it could be worth&#xA;testing on your Arduino. If possible, I would suggest you overwrite the&#xA;key after the signing operation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I did a quick test on my Arduino Uno, at room temperature,&#xA;by just unplugging and plugging back the board. Here is my test code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// This memory buffer will not be zeroed at startup by the C runtime.&#xA;uint8_t __attribute__((section(&quot;.noinit&quot;))) buffer[1024];&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial.println(F(&quot;Program started.&quot;));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    switch (Serial.read()) {&#xA;        case 'i':  // Initialize the buffer with pseudo-random bits.&#xA;            srand(42);&#xA;            for (size_t i = 0; i &amp;lt; sizeof buffer; i++)&#xA;                buffer[i] = rand();&#xA;            Serial.println(F(&quot;Buffer initialized.&quot;));&#xA;            break;&#xA;        case 'f':  // Report number of flipped bits.&#xA;            int count = 0;&#xA;            srand(42);&#xA;            for (size_t i = 0; i &amp;lt; sizeof buffer; i++) {&#xA;                uint8_t mask = buffer[i] ^ rand();&#xA;                while (mask) {&#xA;                    count += mask &amp;amp; 1;&#xA;                    mask &amp;gt;&amp;gt;= 1;&#xA;                }&#xA;            }&#xA;            Serial.print(F(&quot;Flipped bits: &quot;));&#xA;            Serial.print(count);&#xA;            Serial.print(F(&quot; / &quot;));&#xA;            Serial.println(8 * sizeof buffer);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the output, with my comments on the right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Program started.            ← fresh boot&#xA;Buffer initialized.         ← pressed 'i'&#xA;Program started.            ← pressed the reset button&#xA;Flipped bits: 0 / 8192      ← pressed 'f'&#xA;Program started.            ← unplugged and plugged back&#xA;Flipped bits: 4166 / 8192   ← pressed 'f'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It appears the RAM is preserved across a warm reboot (pressing the reset&#xA;button), but it is completely lost after a power cycle: half the bits&#xA;flipped is a total loss of information. I tried to do this as fast as I&#xA;could, which is slightly less than one second. It would seem the SRAM in&#xA;the ATmega chips decays pretty fast, at least at room temperature.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;: I found an enlightening story about an unpowered AVR&#xA;keeping data in RAM for more than 10 minutes, but only on mornings:&#xA;&lt;a href=&quot;http://wp.josh.com/2014/03/03/the-mystery-of-the-zombie-ram/&quot; rel=&quot;nofollow&quot;&gt;The mystery of the Zombie&#xA;RAM&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-06T16:03:45.990" LastActivityDate="2016-04-06T16:03:45.990" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22783" PostTypeId="2" ParentId="9856" CreationDate="2016-04-06T10:09:46.147" Score="1" Body="&lt;p&gt;I ran into the same problem lately. I have a work-around but don't have a clear explanation of this problem. As you initialize the different modules in your &lt;code&gt;setup()&lt;/code&gt;, make sure to perform the SD card initialization first, then followed by the RTC's. Doing this completely sorted me out. However, I am yet to explain these results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though it is late, just in case anyone else runs into the same problem.&lt;/p&gt;&#xA;" OwnerUserId="19949" LastEditorUserId="11763" LastEditDate="2016-04-06T22:37:13.560" LastActivityDate="2016-04-06T22:37:13.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22784" PostTypeId="2" ParentId="22779" CreationDate="2016-04-06T10:33:05.037" Score="0" Body="&lt;p&gt;You should download the SIM900 command set (Google away) and read it. According to your CNMI settings, sms notifications are pushed to the Arduino not the sms content, thus the +CMTI data you're receiving. &lt;code&gt;SM&lt;/code&gt; tells you the sms is stored on the SIM and the number that follows tells you the index of the sms in the SIM memory. With that index, you use the command &lt;code&gt;AT+CMGR=&amp;lt;index&amp;gt;&lt;/code&gt; to get the sms content (as well as the sender number and timestamp) from the modem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, you must parse the CMTI notification, get the number at the end, and use that number to retrieve the SMS content from the modem with the CMGR command. You could also change your CNMI settings to (2,2,0,0,0) i think, if you want the content of the messages to be sent by the modem, and not the notifications alone. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In either case, the SoftwareSerial Receive buffer will most likely overflow when receiving the sms content from the modem; because you cant read() fast enough. This will make the message appear truncated. You have to increase the size of the SoftwareSerial RX buffer to prevent this. &lt;a href=&quot;https://arduino.stackexchange.com/questions/21210/how-to-set-delay-on-gsm-shield&quot;&gt;Here's&lt;/a&gt; a link to an answer where this is explained. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-06T15:57:52.640" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="22785" PostTypeId="1" CreationDate="2016-04-06T10:34:31.980" Score="-1" ViewCount="75" Body="&lt;p&gt;Can we configure two digital pins as serial pins using software serial library?&lt;/p&gt;&#xA;" OwnerUserId="19950" LastActivityDate="2016-04-06T10:41:27.117" Title="Regarding use of software serial two times" Tags="|bluetooth|lcd|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22786" PostTypeId="2" ParentId="22785" CreationDate="2016-04-06T10:41:27.117" Score="1" Body="&lt;p&gt;Kind of, yes - however you can't use them both at once. SoftwareSerial is blocking. That is, while one port is receiving or sending data the other port will be completely locked out so won't be able to receive anything. So it kind of breaks it in a nasty way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I never advocate the use of software serial unless there is absolutely no choice whatsoever, and that is something I have never found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need more than one UART then pick a chip with more than one UART.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-06T10:41:27.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22787" PostTypeId="2" ParentId="22773" CreationDate="2016-04-06T12:27:12.707" Score="1" Body="&lt;p&gt;You obviously have some form of DMM or volt meter at your disposal, since you know the voltages around the regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some places you should, therefore, probe for voltages, and what voltages you should expect.  With the barrel jack connected and powered up, and assuming a 12V supply, you should expect:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;At the rear of the socket: 12V&lt;/li&gt;&#xA;&lt;li&gt;At the socket side of the M7 diode: 12V&lt;/li&gt;&#xA;&lt;li&gt;At the header side of the M7 diode: 11.4V&lt;/li&gt;&#xA;&lt;li&gt;At the right-hand (VIN) pin of the regulator: 11.4V&lt;/li&gt;&#xA;&lt;li&gt;On the tab of the regulator: 5V&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you find any of those are wrong then the component that comes before it may well be faulty.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-06T12:27:12.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22788" PostTypeId="1" CreationDate="2016-04-06T12:31:06.410" Score="2" ViewCount="4087" Body="&lt;p&gt;I would like to measure water turbidity in the sea. The sensor does not need to measure it in an accurate way, I just need to know if water is clear or very turbided. I know that there could be used a light scatter but I do not know what kind of sensor should I use. Could anyone help how to measure turbidity?&lt;/p&gt;&#xA;" OwnerUserId="19320" LastActivityDate="2018-03-08T20:24:22.660" Title="How to measure water turbidity with arduino" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22789" PostTypeId="2" ParentId="22745" CreationDate="2016-04-06T12:41:52.153" Score="-1" Body="&lt;p&gt;If you programmed the Arduino to read the sensor and the do something else, what would you do if a second request to read the sensor came in before you had stopped doing something else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know anything about Firmata.  Could you add two sensor's, so the Pi could select to read from sensor 1 or sensor 2?  If you could do that then you alter the 'readSensor2()' function so it did 'Something else'.  This way you are exploiting any control/synchronisation logic within Firmata.  If you need 'readSensor1()' to automatically 'do something else' ever time it was called then couldn't you just tag it onto the end of 'readSensor1()'.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-06T12:41:52.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22790" PostTypeId="2" ParentId="22788" CreationDate="2016-04-06T12:48:44.627" Score="2" Body="&lt;p&gt;&lt;a href=&quot;http://uk.farnell.com/ams/tsl257-lf/sensor-light-voltage-converter/dp/1226886&quot; rel=&quot;nofollow&quot;&gt;http://uk.farnell.com/ams/tsl257-lf/sensor-light-voltage-converter/dp/1226886&lt;/a&gt;&#xA;is a good one according to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=299993.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=299993.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it might be easier to buy a COTS sensor, its a bit more expensive but much easier.  &lt;a href=&quot;http://www.aliexpress.com/item/Turbidity-Testing-Sensor-Module-Suite/1903197650.html?spm=2114.01010208.3.17.OSVwdj&amp;amp;ws_ab_test=searchweb201556_9,searchweb201602_2_10017_9868_10005_10006_10034_10021_507_10022_10020_1000020_10018_10019,searchweb201603_8&amp;amp;btsid=6dbcca61-3e0a-4e34-9359-a6c26b268509&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/Turbidity-Testing-Sensor-Module-Suite/1903197650.html?spm=2114.01010208.3.17.OSVwdj&amp;amp;ws_ab_test=searchweb201556_9,searchweb201602_2_10017_9868_10005_10006_10034_10021_507_10022_10020_1000020_10018_10019,searchweb201603_8&amp;amp;btsid=6dbcca61-3e0a-4e34-9359-a6c26b268509&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW for everyone else Turbidity is the amount of muck in the water, so it would be no good looking at the crystal clear waters off the UK coast :)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-06T12:48:44.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22791" PostTypeId="2" ParentId="22687" CreationDate="2016-04-06T13:32:12.550" Score="0" Body="&lt;p&gt;Oh - capacitative sensors. I was fooling about with transistors (BD149s, I think) hooked up into darlington pairs, and I found that just touching the resistor on the base was enough to make them switch. No extra capacitor timing whatsamajig required.  &lt;/p&gt;&#xA;" OwnerUserId="18463" LastActivityDate="2016-04-06T13:32:12.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22793" PostTypeId="1" CreationDate="2016-04-06T14:03:28.027" Score="5" ViewCount="28194" Body="&lt;p&gt;I am a newbie to Arduino, so please bear with me. I am trying to figure out how to power an Arduino Nano with a LiPo battery. I want to use a 3.7v if possible, as my project needs to be lightweight. There are two possibilities I know &lt;em&gt;could&lt;/em&gt; work:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Taking a USB to Mini-B USB, cutting off the normal USB end, and soldering a connector (based on the battery I use) to that end. I would then plug the Mini-B USB into the Nano, giving it power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Using the 5v and Ground pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would prefer to use the USB cable solution, however the 5v/Ground or any other solution is perfectly usable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, would 3.7v be enough to power the Nano, two Infrared LEDS (Launch and Receiver), and a 7-segment LED display. I also have a button.&#xA;                                                             Thanks, saddlepiggy!&lt;/p&gt;&#xA;" OwnerUserId="19953" LastActivityDate="2020-02-09T05:06:14.383" Title="How can I power an Arduino Nano with a LiPo battery, preferably 3.7v" Tags="|power|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22794" PostTypeId="1" AcceptedAnswerId="22795" CreationDate="2016-04-06T14:13:40.463" Score="1" ViewCount="69" Body="&lt;p&gt;&lt;a href=&quot;http://www.hth.com/filelibrary/pdffiles/snap.pdf&quot; rel=&quot;nofollow&quot;&gt;Page 14&lt;/a&gt; says that the method should return the value 'h17'&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct  {&#xA;  uint8_t data;&#xA;  uint8_t timestamp;&#xA;  unsigned char crc;&#xA;} tData;&#xA;&#xA;&#xA;int main(void)&#xA;{&#xA;  unsigned char* tempData = &quot;snap&quot;;&#xA;&#xA;    for(;;)&#xA;    {&#xA;      tData payload;&#xA;      payload.crc = crc8(tempData,sizeof(tempData));&#xA;      UDR0 = payload.crc;&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19328" LastActivityDate="2016-04-06T15:51:24.990" Title="Why does this method return an unprintable character, how do I convert it to display correctly?" Tags="|c|terminal|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22795" PostTypeId="2" ParentId="22794" CreationDate="2016-04-06T14:19:13.213" Score="1" Body="&lt;p&gt;Because “h17” is an unprintable character, namely ASCII ETB. The 'h' in “h17” stands for “hexadecimal”, like the &lt;code&gt;0x&lt;/code&gt; usually used in C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should convert the value to an ASCII number if you want to print it, using for example &lt;code&gt;Serial.print(payload.crc, 16);&lt;/code&gt; or – if you are not using Arduino core – &lt;code&gt;(s)printf()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: here is an implementation of my comment “&lt;em&gt;sprintf() into a&#xA;buffer and dump the buffer to UDR0 one byte at a time&lt;/em&gt;”:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;void print_byte_in_hex(uint8_t byte)&#xA;{&#xA;    // Print the byte in ASCII into an internal buffer.&#xA;    char buffer[8];&#xA;    sprintf(buffer, &quot;%02x\r\n&quot;, byte);&#xA;&#xA;    // Send it one byte at a time through the USART.&#xA;    for (char * p = buffer; *p; p++) {&#xA;        loop_until_bit_is_set(UCSR0A, UDRE0);&#xA;        UDR0 = *p;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-06T15:51:24.990" LastActivityDate="2016-04-06T15:51:24.990" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22796" PostTypeId="1" AcceptedAnswerId="32058" CreationDate="2016-04-06T14:27:40.253" Score="4" ViewCount="7603" Body="&lt;p&gt;So after burning up a couple Arduinos, I'm running out of ideas...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to power both a Solenoid valve and the Arduino(nano) with the same 12V-2amp power supply. I've tried it with both a relay breakout board, and via transistor switching, and both are giving me sporadic behavior for the Solenoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Early failures came from realizing that the solenoid water value was actually a coil (duh), and thus needed some kind of diode placed over its connections, so I'm assuming the back voltage spike is what fried the first two boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first I added a small diode that helped but wasn't enough, so I beefed it up to a 3 amp &quot;rectifier diode&quot; 200PIV, which stopped the board frying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a link to the &lt;a href=&quot;http://www.ebay.com/itm/281784710402?_trksid=p2060353.m2749.l2648&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow noreferrer&quot;&gt;solenoid water valve&lt;/a&gt;. Not much to go on I'm afraid. 12V 0.02-0.8Mpa.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The behavior that I'm seeing now, is that the solenoid will engage, but it won't disengage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need to add a Capacitor for the solenoid?  If so, any recommendations on sizing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/arA8E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/arA8E.png&quot; alt=&quot;Fritzing Schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int relayPin = 2;&#xA;&#xA;void setup() &#xA;{ &#xA;  pinMode(relayPin, OUTPUT);&#xA;  Serial.begin(115200);&#xA;} &#xA;&#xA;&#xA;void loop() &#xA;{ &#xA;  Serial.println(&quot;starting&quot;);&#xA;  digitalWrite(relayPin, HIGH);&#xA;  delay(2000);&#xA;  digitalWrite(relayPin, LOW);&#xA;  delay(2000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2019-01-31T13:01:40.280" Title="Arduino controlling a heavy solenoid water valve" Tags="|arduino-nano|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22797" PostTypeId="1" CreationDate="2016-04-06T15:02:39.337" Score="3" ViewCount="367" Body="&lt;p&gt;I have a Lolin NodeMCU V3 with a broken USB port: no power, no data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does show up on WIFI as &lt;code&gt;AI-thinker_xxx&lt;/code&gt;, I can connect, but what can I do next?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to program the NodeMCU Over the Air (OTA), or through some pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://frightanic.com/iot/comparison-of-esp8266-nodemcu-development-boards/&quot; rel=&quot;nofollow&quot;&gt;Description found here&lt;/a&gt; under V3&lt;/p&gt;&#xA;" OwnerUserId="19958" LastEditorUserId="19958" LastEditDate="2016-04-08T12:40:37.913" LastActivityDate="2021-09-05T13:02:45.507" Title="Program nodeMCU Over the Air (OTA)" Tags="|serial|uploading|nodemcu|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22798" PostTypeId="1" AcceptedAnswerId="22831" CreationDate="2016-04-06T15:14:43.420" Score="8" ViewCount="53808" Body="&lt;p&gt;I've bought this module&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B008BOPN40&quot; rel=&quot;noreferrer&quot;&gt;Kootek GY-521 MPU-6050 MPU6050 Module 3 Axis analog gyro sensors+ 3 Axis Accelerometer Module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project will involve affixing this to a moving object, moving at velocities varying from 0.1 to 1.0 meters per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understand, this module will allow me to infer rotation and acceleration, will I be able to derive velocity? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much accuracy can I expect?&lt;/p&gt;&#xA;" OwnerUserId="13605" LastActivityDate="2018-10-23T17:17:10.473" Title="Can I measure velocity from an accelerometer? How accurately?" Tags="|arduino-uno|bluetooth|accelerometer|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22799" PostTypeId="2" ParentId="9374" CreationDate="2016-04-06T15:23:59.437" Score="2" Body="&lt;p&gt;You should download this &lt;a href=&quot;http://www.theengineeringprojects.com/2016/03/gsm-library-proteus.html&quot; rel=&quot;nofollow&quot;&gt;GSM Library for Proteus&lt;/a&gt; . You can use this library to simulate your GSM module in Proteus software. You should also check this example where they have discussed Hoe to &lt;a href=&quot;http://www.theengineeringprojects.com/2016/04/send-sms-sim900d-proteus-isis.html&quot; rel=&quot;nofollow&quot;&gt;Send SMS with GSM module in Proteus ISIS&lt;/a&gt;. I hope it will help you out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-04-06T15:23:59.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22800" PostTypeId="2" ParentId="21374" CreationDate="2016-04-06T15:26:20.297" Score="0" Body="&lt;p&gt;I have found this &lt;a href=&quot;http://www.theengineeringprojects.com/2016/03/bluetooth-library-for-proteus.html&quot; rel=&quot;nofollow&quot;&gt;Bluetooth Library for Proteus&lt;/a&gt;. Thanks for helping me out guys. I am posting it here so that others can also get benefit out of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-04-06T15:26:20.297" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22802" PostTypeId="1" AcceptedAnswerId="22818" CreationDate="2016-04-06T15:46:18.513" Score="0" ViewCount="5012" Body="&lt;p&gt;I'm building a wireless mechanical keyboard. There is an array of 6 elements that stores the keys pressed by the user (since 6 is the max number of keys you can send at once over Bluetooth). An example would be &lt;code&gt;02-05-03-00-00-00&lt;/code&gt;. Notice the &quot;00&quot; at the end, these are just &quot;placeholders&quot; and don't have a meaning other than to indicate that there are no more keys pressed. When the user releases key 05 for example, the array should become this &lt;code&gt;02-03-00-00-00-00&lt;/code&gt;. I don't know how to do this however, since you can't just remove and item from an array and there doesn't seem to be a polished option for lists in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea for an algorithm that finds the 0's in an array, places them at the end of the array and keeps the order of the other elements?&lt;/p&gt;&#xA;" OwnerUserId="16572" LastActivityDate="2016-04-07T00:04:03.353" Title="Removing Element From Array While Keeping Order" Tags="|arduino-ide|c|array|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22804" PostTypeId="1" AcceptedAnswerId="22805" CreationDate="2016-04-06T16:48:06.120" Score="0" ViewCount="4963" Body="&lt;p&gt;I know I can send a newline using the option in the bottom right:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kde31.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kde31.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But why doesnt it work to use the option 'No line ending', and send a '\n' or '\r\n' after the text using the arduino serial monitor?&lt;/p&gt;&#xA;" OwnerUserId="19933" LastEditorUserId="612" LastEditDate="2016-04-06T17:15:30.323" LastActivityDate="2016-04-06T17:15:30.323" Title="Send newline through serial monitor" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22805" PostTypeId="2" ParentId="22804" CreationDate="2016-04-06T16:53:09.057" Score="2" Body="&lt;p&gt;The backslash escape encoding for special characters is a feature of double quotes in some programming languages, shells, and other parsers.  It is not normally a feature of live text input - an &quot;end user&quot; human typing a backslash is assumed to mean it literally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Live&quot; input of a carriage return or newline is more traditionally done with the return/enter key, or with the corresponding control codes - CTRL-J for newline and/or CTRL-M for return.  I don't know that the Arduino IDE's Serial Monitor supports either of these, at least once you select &quot;no line ending&quot;&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-06T16:53:09.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22806" PostTypeId="2" ParentId="22680" CreationDate="2016-04-06T16:56:57.617" Score="2" Body="&lt;p&gt;The backlights on these LCDs are just an LED array with a series resistor so the intensity will be directly proportional to the input voltage; flickering voltage = flickering backlight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check these things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Measure the output of the 5V regulator with an AC volt meter to see if the regulator is oscillating when the backlight flickers, i.e. AC voltage &gt;&gt; 0V.  If it is, then you probably need to increase the size of the output and possibly the input capacitors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Measure the Input-to-Output voltage differential of the regulator and multiply it by the output current.  If you dissipate more power than the thermal design allows this will heat the regulator making (1) more likely as well as driving the regulator into thermal shutdown.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the regulator is linear, i.e. 7805 etc, you can solve both (1) and (2) by changing the regulator to a drop in switching type.  These will dissipate heat as a percentage of the output power instead of as a function of the input voltage and can be made self contained with regard to input/output capacitors which would be on-board instead of off-board.  A switcher can also do something a linear can't do:  Supply more current than the source.  A 12V 0.5A power supply into a 5V regulator can supply 5V at 0.5A with 3.5 watts of waste heat.  That same 12V supply into a decent switcher can deliver 1.14A at 5V with only 300mW of waste heat!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ppl.ug/5iRK2MJOIPk/&quot; rel=&quot;nofollow&quot;&gt;This PDF&lt;/a&gt; is an example circuit that runs about 95% efficient and fits on a 7805 footprint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ppl.ug/tia-wJs1_Gg/&quot; rel=&quot;nofollow&quot;&gt;This PDF&lt;/a&gt; is the circuit of the 1516 switcher linked above configured to replace the NCP1117 linear regulator use on the Uno Rev3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://ppl.ug/EvIVf5q4K3Y/&quot; rel=&quot;nofollow&quot;&gt;This PDF&lt;/a&gt; is a full thermal analysis of the Arduino Uno NCP1117 regulator running under the conditions stated in your question.  As you can see, you were right on the edge of what the NCP1117 could handle at 200mA (LCD plus scanner).  I have included a thermograph showing the same unit supplying 1.85A at 5V using a drop in switching regulator with no issues.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastEditorUserId="6936" LastEditDate="2016-04-26T09:18:43.693" LastActivityDate="2016-04-26T09:18:43.693" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22807" PostTypeId="2" ParentId="22798" CreationDate="2016-04-06T19:50:16.310" Score="1" Body="&lt;p&gt;I don't think that will be possible. If my understanding of accelerometers is correct, they measure acceleration. Then you have a situation when the speed is constant. Acceleration = 0, according to Newton's laws. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to keep track of changes in acceleration then perform math to maintain the state. As @Chris Stratton suggest, that will lead to keep integrating the error to the very likely situation of getting a meaningless value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have never worked with an accelerometer before, so it can be possible at a certain extent. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be great to hear from someone who actually tried this.&lt;/p&gt;&#xA;" OwnerUserId="14766" LastActivityDate="2016-04-06T19:50:16.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22808" PostTypeId="1" AcceptedAnswerId="22810" CreationDate="2016-04-06T20:17:01.007" Score="0" ViewCount="595" Body="&lt;p&gt;I have the following vibration sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/MeJ33.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/MeJ33.png&quot; alt=&quot;Vibration Sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It has one short/firm-er terminal and one long/flimsy terminal.  Now the shorter terminal slides easily into my breadboard but the flimsy one clearly does not.  A few related questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How do I go about connecting this to my breadboard (simply plugging it in doesn't work)?  Do I have to solder a wire onto the flimsy end?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Why is this switch manufactured this way (with a flimsy end)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) Is it right to assume that the longer end is positive (+) and the shorter end is negative (-)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19872" LastEditorUserId="19872" LastEditDate="2016-04-06T21:18:06.610" LastActivityDate="2016-04-06T21:18:06.610" Title="How do I connect a vibration sensor/switch to a breadboard?" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22809" PostTypeId="1" AcceptedAnswerId="22833" CreationDate="2016-04-06T20:17:24.997" Score="2" ViewCount="184" Body="&lt;p&gt;I want to produce quick square waveform for testing purposes. If I will use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA; pinMode(2, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA; bitSet(PORTD, 2);&#xA; bitClear(PORTD, 2);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will get expected pulses but I also will get these 6.25 us dips in waveform roughly every 1 ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use latest Arduino 1.6.9 environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whole loop cycle take 1 us which mean 16 instructions (62.5 ns per instruction). So I will get 125 ns high and rest of the time low signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea what I'm doing wrong? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same results if I use asm sbi and sci instead of macros bitSet/bitClear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VFrm0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VFrm0.png&quot; alt=&quot;Oscilloscope waveform - 62.5 us detail&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/*&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So after yours advices and little bit further searching I came up with solution to produce clean square waveform. It make 2.66 Mhz and it's probably fastest what you can get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA; pinMode(2, OUTPUT);&#xA; noInterrupts();   &#xA;}&#xA;&#xA;void loop() &#xA;{&#xA; while(true)&#xA; {&#xA; bitSet(PORTD, 2);&#xA; bitClear(PORTD, 2);&#xA; }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19961" LastEditorUserId="19961" LastEditDate="2016-04-07T19:33:09.960" LastActivityDate="2020-06-04T18:10:49.513" Title="Arduino UNO doesn't produce expected square waveform" Tags="|arduino-uno|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22810" PostTypeId="2" ParentId="22808" CreationDate="2016-04-06T20:26:29.900" Score="1" Body="&lt;p&gt;It appears from this information source:&#xA;&lt;a href=&quot;http://www.electrodragon.com/product/vibration-switch-sensor-sw-18020p/&quot; rel=&quot;nofollow&quot;&gt;http://www.electrodragon.com/product/vibration-switch-sensor-sw-18020p/&lt;/a&gt;&#xA;that the sensor is an electrical contact on the firmer side surrounded by a very sensitive spring within the enclosure. The coil spring is by design made of a smaller diameter wire to provide sensitivity to movement. Rather than manufacture a translation to a heavier piece of material, the thinner lead is brought out of the enclosure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that it will not work on your breadboard, due to the flimsy end being too small to make solid contact within the breadboard. You could resolve that aspect by soldering on a heavier segment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it is designed as a simple switch, there is no plus or minus.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-04-06T20:26:29.900" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22811" PostTypeId="1" AcceptedAnswerId="22856" CreationDate="2016-04-06T20:33:51.367" Score="0" ViewCount="52" Body="&lt;p&gt;I'm about to order parts for my project and I'd like to avoid some rookie mistake I might've missed. I'll be using Arduino chip and a wifi module to host a very simple webpage and a battery to make this all portable. I've decided to use Arduino Mini Pro 8MHz because of 3.3V input voltage, same as ESP8266, also FT232RL to program the board and TPS73601 for my battery. This is where I have some doubts, the battery I've picked is Li-Ion from my old Samsung Galaxy S AFAIK when charged it supplies ~4.2V and nearly discharged ~2.7V so the regulator should work (?). Is using Li-Ion in any way different from regular AA or just +/- because I see 3 pins on the back of it? Except for charging of course I'll be using the phone for that. Thanks in advance for any suggestions. &lt;/p&gt;&#xA;" OwnerUserId="5043" LastActivityDate="2016-04-07T18:14:08.420" Title="Arduino project - will this fit together?" Tags="|project|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22812" PostTypeId="1" CreationDate="2016-04-06T20:59:24.633" Score="0" ViewCount="36" Body="&lt;p&gt;I have two Arduinos connected through Bluetooth. One sends a string of data similar to &lt;code&gt;506:507:1\r\n&lt;/code&gt;. The data can vary similar to &lt;code&gt;0:1000:0\r\n&lt;/code&gt;. I already have functions to break that string down into three variables. I send it from one Arduino over Bluetooth and the second Arduino receives it through &lt;code&gt;Serial&lt;/code&gt;. The only problem is that the second Arduino receives this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5&#xA;0&#xA;6&#xA;:&#xA;5&#xA;0&#xA;7&#xA;:&#xA;1&#xA;&quot;\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the end it adds a space at the end (&lt;code&gt;&quot;\n&quot;&lt;/code&gt;) How can I parse this data back into a string similar to &lt;code&gt;506:507:1\r\n&lt;/code&gt; that can still vary in length?&lt;/p&gt;&#xA;" OwnerUserId="16094" LastActivityDate="2022-01-21T03:05:25.740" Title="Join Serial Data Seperated by Newlines?" Tags="|arduino-uno|serial|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22813" PostTypeId="1" CreationDate="2016-04-06T21:11:08.660" Score="1" ViewCount="379" Body="&lt;p&gt;I'm using an Arduino Uno board with an HP computer running Windows 10 and IDE version 1.6.8. Arduino was working fine for me until a few days ago, when (and I suspect this is the root of the problem) I accidentally tried to upload software with something connected to the RX and TX pins on the board. Now I continually get the error message below:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;\.\COM2&quot;: Access is denied.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The only other thing that changed is I disconnected a bluetooth dongle (Kinivo BTD-400 Bluetooth 4.0 USB Adapter for Windows) without uninstalling any software, so I suspect that software may be searching for open COM ports and disrupting the Arduino upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried everything I could find about troubleshooting online, including that &quot;did I brick my arduino&quot; post elsewhere on this forum, and nothing has worked or even changed the problem - please help! I believe I've narrowed down the problem to my computer scanning open COM ports, but I can't find any reliable way to make sure that doesn't happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="19966" LastActivityDate="2016-04-06T21:47:50.097" Title="No sketches will upload to Arduino Uno board; says &quot;access denied&quot;" Tags="|arduino-uno|port-mapping|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22814" PostTypeId="1" CreationDate="2016-04-06T21:16:57.887" Score="2" ViewCount="15656" Body="&lt;p&gt;With the Serial Monitor I have the Newline option:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wVGpR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wVGpR.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;How can I send the same using python?&lt;/p&gt;&#xA;&lt;p&gt;I tried:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;30\r\n&lt;/p&gt;&#xA;&lt;p&gt;30\r&lt;/p&gt;&#xA;&lt;p&gt;30\n&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;&#xA;ser = serial.Serial('COM3', 115200)&#xA;&#xA;while True:&#xA;    numIn = input(&amp;quot;enter delay value: &amp;quot;)&#xA;    ser.write(numIn.encode('ascii'))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19933" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-04-06T21:16:57.887" Title="Send Newline / Carriage return with python" Tags="|python|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22816" PostTypeId="1" AcceptedAnswerId="22851" CreationDate="2016-04-06T21:45:20.240" Score="0" ViewCount="4541" Body="&lt;p&gt;I'm workin on a node for blender to control an arduino. I notice it goes really slow after a while so I isolated the problem.&#xA;It is good in maintaining 60 frames a second, then after around 40 seconds (pretty exact), it drops to a pretty exact 1 fps for some reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be going on?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;import time&#xA;&#xA;ser = serial.Serial('COM3', 115200)&#xA;&#xA;c = 0&#xA;&#xA;while True:&#xA;    c+=1&#xA;    print(&quot;ok &quot;, c)&#xA;    numIn = &quot;100n&quot;&#xA;    ser.write(numIn.encode('ascii'))&#xA;    time.sleep(1./60)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;arduino code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;// special thx to  Nick Gammon&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const unsigned int MAX_INPUT = 50;&#xA;&#xA;&#xA;unsigned long delay_time = 300;&#xA;unsigned long last_toggle_time = 0;&#xA;int current_state = LOW;&#xA;&#xA;void setup () {&#xA;  Serial.begin (115200);&#xA;  pinMode(12, OUTPUT);&#xA;&#xA;} &#xA;&#xA;&#xA;void process_data (const char * data) {&#xA;  Serial.println (data);&#xA;  delay_time = atoi(data);&#xA;} &#xA;&#xA;void processIncomingByte (const byte inByte) {&#xA;  static char input_line [MAX_INPUT];&#xA;  static unsigned int input_pos = 0;&#xA;&#xA;  switch (inByte) {&#xA;&#xA;    case 'n':   // end of text&#xA;      input_line [input_pos] = 0;  // terminating null byte&#xA;      process_data (input_line);&#xA;      input_pos = 0;&#xA;      break;&#xA;&#xA;    case 'r':   &#xA;      break;&#xA;&#xA;    default:&#xA;      if (input_pos &amp;lt; (MAX_INPUT - 1))&#xA;        input_line [input_pos++] = inByte;&#xA;      break;&#xA;&#xA;  } &#xA;} &#xA;&#xA;void loop() {&#xA;&#xA;  while (Serial.available () &amp;gt; 0) {&#xA;    processIncomingByte (Serial.read ());&#xA;  }&#xA;&#xA;  unsigned long m  = millis();&#xA;&#xA;  if (m &amp;gt; last_toggle_time + delay_time) {&#xA;      current_state = current_state == HIGH ? LOW : HIGH;&#xA;      digitalWrite(12, current_state);         &#xA;      last_toggle_time = m;&#xA;  }&#xA;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19933" LastEditorUserId="19933" LastEditDate="2016-04-06T22:24:40.810" LastActivityDate="2019-06-15T22:53:41.367" Title="serial communication dead slow after a while" Tags="|python|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="22817" PostTypeId="2" ParentId="22813" CreationDate="2016-04-06T21:47:50.097" Score="1" Body="&lt;p&gt;It sounds like Windows thinks that port is in use and isn't letting the ArduinoIDE access it. If it's the same port your dongle had been using, try plugging the dongle back in, then dismounting it before you remove it. Hopefully that will clear the port for other uses.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-06T21:47:50.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22818" PostTypeId="2" ParentId="22802" CreationDate="2016-04-06T22:25:33.377" Score="0" Body="&lt;p&gt;You need to compact the vector: First search for the first non-zero element and then move all non-zero elements. It could look something like below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  while (!Serial);&#xA;&#xA;  char vec[] = { 2, 5, 3, 0, 0, 1 };&#xA;  print(vec, sizeof(vec));&#xA;&#xA;  compact(vec, sizeof(vec));&#xA;  print(vec, sizeof(vec));&#xA;&#xA;  vec[1] = 0;&#xA;  print(vec, sizeof(vec));&#xA;&#xA;  compact(vec, sizeof(vec));&#xA;  print(vec, sizeof(vec));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&#xA;void compact(char* vec, size_t len)&#xA;{&#xA;  int i = 0;&#xA;  for (; i &amp;lt; len &amp;amp;&amp;amp; vec[i] != 0; i++);&#xA;  if (i == len) return;&#xA;  int j = i;&#xA;  for (; i &amp;lt; len; i++) {&#xA;    char c = vec[i];&#xA;    if (c != 0) {&#xA;      vec[j++] = c;&#xA;      vec[i] = 0;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void print(char* vec, size_t len)&#xA;{&#xA;  for (int i = 0; i &amp;lt; len; i++) {&#xA;    unsigned c = vec[i];&#xA;    if (c &amp;lt; 16) Serial.print(0);&#xA;    Serial.print(c, HEX);&#xA;    if (i + 1 &amp;lt; len) Serial.print('-');&#xA;  }&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This give the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;02-05-03-00-00-01&#xA;02-05-03-01-00-00&#xA;02-00-03-01-00-00&#xA;02-03-01-00-00-00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-04-06T22:25:33.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22819" PostTypeId="2" ParentId="22802" CreationDate="2016-04-06T23:20:46.343" Score="0" Body="&lt;p&gt;&lt;strong&gt;Remove Zeros&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void removeZeros(uint8_t array[], size_t length) {&#xA;// Sanity check.&#xA;if(array != nullptr &amp;amp;&amp;amp; length &amp;gt; 0) {&#xA;    for(size_t i = 0; i &amp;lt; length; i++) {&#xA;      if(array[i] == 0) {&#xA;        for(size_t j = i + 1; j &amp;lt; length; j++){&#xA;          if(array[j] != 0) {&#xA;            array[i] = array[j];&#xA;            array[j] = 0;&#xA;            break;&#xA;          }&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t keyBuffer[] = { 2, 0, 3, 0, 4, 0 };&#xA;removeZeros(keyBuffer, sizeof(keyBuffer)/sizeof(keyBuffer[0]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;New value of keyBuffer: { 2, 3, 4, 0, 0, 0 }&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br /&gt;&#xA;&lt;strong&gt;Remove a single indexed value&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void removeIndex(uint8_t array[], size_t length, size_t index){&#xA;  // Sanity check.&#xA;  if(array != nullptr &amp;amp;&amp;amp; length &amp;gt; 0) {&#xA;    for(size_t i = index; i &amp;lt; (length - 1); i++){&#xA;      array[i] = array[i + 1];&#xA;    }&#xA;    array[length-1] = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t keyBuffer[] = { 2, 5, 3, 0, 0, 0 };&#xA;removeZeros(keyBuffer, sizeof(keyBuffer)/sizeof(keyBuffer[0], 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;New value of keyBuffer: { 2, 3, 0, 0, 0, 0 }&lt;/p&gt;&#xA;" OwnerUserId="19963" LastEditorUserId="19963" LastEditDate="2016-04-07T00:04:03.353" LastActivityDate="2016-04-07T00:04:03.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22821" PostTypeId="1" AcceptedAnswerId="22829" CreationDate="2016-04-07T00:07:02.817" Score="0" ViewCount="474" Body="&lt;p&gt;I'm trying to connect an Arduino Nano with a Raspberry Pi 3 via I²C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the small test-program I found and used for I²C.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Wire.begin(4);                // join i2c bus with address #8&#xA;  Wire.onReceive(receiveEvent); // register event&#xA;  Serial.begin(9600);           // start serial for output&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(100);&#xA;}&#xA;&#xA;// function that executes whenever data is received from master&#xA;// this function is registered as an event, see setup()&#xA;void receiveEvent(int howMany) {&#xA;  while (1 &amp;lt; Wire.available()) { // loop through all but the last&#xA;    char c = Wire.read(); // receive byte as a character&#xA;    Serial.print(c);         // print the character&#xA;  }&#xA;  int x = Wire.read();    // receive byte as an integer&#xA;  Serial.println(x);         // print the integer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After compiling and uploading, I ssh-ed into my Pi and executed &lt;code&gt;sudo i2cdetect -y 1&lt;/code&gt; which prints an empty I²C table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are images of how I connected the two devices, as far as I know the connection itself is okay. I also tested the cables with a multimeter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KY21z.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KY21z.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lorWc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lorWc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xOVF6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xOVF6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the strange thing is, when I short-circuit my Arduino for a brief moment between GND and VIN I²C works, but Serial via USB with my PC stops working. Also the chip gets very hot and stays hot even though it isn't short-circuited anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas what I'm doing wrong? I don't think the Arduinos are broken, since I tested it with 2 different ones. (while testing I accidentally short-circuited one and it worked)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I tested I²C between the two Arduinos and it works flawlessly, but still doesn't want to work with my Pi. :(&lt;/p&gt;&#xA;" OwnerUserId="19971" LastEditorUserId="19971" LastEditDate="2016-04-07T02:14:03.610" LastActivityDate="2016-04-08T02:18:05.967" Title="I²C only works when I short-circuit my Arduino" Tags="|serial|i2c|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22822" PostTypeId="2" ParentId="22821" CreationDate="2016-04-07T00:13:47.590" Score="0" Body="&lt;p&gt;There is not enough information in your question to know for sure, but remember that the rpi is three volt and the arduino is five volt. Given the heat you are seeing you have something miswired.&lt;/p&gt;&#xA;" OwnerUserId="445" LastActivityDate="2016-04-07T00:13:47.590" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22823" PostTypeId="2" ParentId="22812" CreationDate="2016-04-07T00:41:17.533" Score="1" Body="&lt;p&gt;Simply reverse the steps you took on the sending side.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create a &lt;code&gt;char&lt;/code&gt; array of sufficient size as well as an index variable to keep track of your position within the array. An Arduino String may be more convenient, though they can cause &lt;strong&gt;a lot&lt;/strong&gt; of problems.&lt;/li&gt;&#xA;&lt;li&gt;In a loop, use &lt;code&gt;available()&lt;/code&gt; to wait for incoming chars and add them to the array you've created, using your index variable. &lt;/li&gt;&#xA;&lt;li&gt;Keep going in the loop, while checking for that unique character (\n, perhaps) that signals the end of a packet. Add this last byte to the array and then terminate the string with null or &lt;code&gt;\0&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you want to re-use the array for another packet, simply set the index variable to 0 and continue.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-07T00:41:17.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22824" PostTypeId="1" CreationDate="2016-04-07T02:14:57.810" Score="0" ViewCount="4857" Body="&lt;p&gt;I need to load the Atmega328p 8kHz board definition using the board manager and can not find a way.  Any help will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19972" LastActivityDate="2018-12-13T12:05:24.273" Title="How to load Atmega328p 8mhz board using board manager" Tags="|atmega328|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22826" PostTypeId="1" CreationDate="2016-04-07T05:32:29.853" Score="-1" ViewCount="1348" Body="&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte ANTENNA = 9;&#xA;&#xA;void setup() &#xA;  {&#xA;  // set up Timer 1&#xA;  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match&#xA;  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaler&#xA;  OCR1A =  9;       // compare A register value to 10 (zero relative)&#xA;  }  // end of setup&#xA;&#xA;void loop() &#xA;  {&#xA;  pinMode (ANTENNA, OUTPUT);&#xA;  delay (500);&#xA;  pinMode (ANTENNA, INPUT);&#xA;  delay (300);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is just toggling the mode of the pin, so how it is related to radio wave generation? &lt;/p&gt;&#xA;" OwnerUserId="19977" LastEditorUserId="10794" LastEditDate="2016-04-07T05:44:47.240" LastActivityDate="2016-05-07T06:07:05.467" Title="radio wave generation using arduino" Tags="|arduino-uno|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22827" PostTypeId="2" ParentId="22798" CreationDate="2016-04-07T05:41:21.550" Score="4" Body="&lt;p&gt;I work with Arduino-based autopilot modules, which usually use similar sensors in addition to GPS data to maintain a reasonable estimate of its position/velocity/acceleration.  If you were to add other sensors (i.e. a GPS) to your project, it might be worth looking into Extended Kalman Filters (&lt;a href=&quot;https://github.com/simondlevy/TinyEKF&quot; rel=&quot;nofollow&quot;&gt;https://github.com/simondlevy/TinyEKF&lt;/a&gt;), which are usually able to provide fairly accurate results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're only using an accelerometer, EKF would probably be overkill, so you could look into other noise-reduction techniques.  For example, using a weighted average of the last two readings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// alpha is value between 0 and 1&#xA;acceleration = alpha * readAccelerationSensor() + (1 - alpha) * lastSensorReading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another strategy to filter out noise would be to take multiple sensor readings at each time step and use the median value to integrate for velocity.&lt;/p&gt;&#xA;" OwnerUserId="19900" LastActivityDate="2016-04-07T05:41:21.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22828" PostTypeId="2" ParentId="22826" CreationDate="2016-04-07T05:47:49.037" Score="0" Body="&lt;p&gt;This looks incredibly like the post on my page: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11508&quot; rel=&quot;nofollow&quot;&gt;Turn your Arduino into an AM radio transmitter!&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the page mentions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The 16 MHz clock is divided by 10 (that is, 1.6 MHz) and that is used to toggle pin 9 at that rate, giving a frequency of 800 KHz, since one toggle turns the output on, and second toggle turns it off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These are the important lines:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  // set up Timer 1&#xA;  TCCR1A = bit (COM1A0);  // toggle OC1A on Compare Match&#xA;  TCCR1B = bit (WGM12) | bit (CS10);   // CTC, no prescaler&#xA;  OCR1A =  9;       // compare A register value to 10 (zero relative)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Timer 1 is set up to run at 800 kHz. That is a radio frequency. The toggling code just turns the output on or off as a simple form of &quot;keying&quot;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-07T05:47:49.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22829" PostTypeId="2" ParentId="22821" CreationDate="2016-04-07T05:59:42.927" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Any ideas what I'm doing wrong?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Apart from &lt;em&gt;deliberately shorting +5V to ground&lt;/em&gt;? Sheesh!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Get, or make, a level-shifter. You can't pump 5V from the Nano to the Pi and expect things to work. Example schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IgYlD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IgYlD.png&quot; alt=&quot;Level converter&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this example the low voltage (3.3V) side is marked LV, and the high voltage (5V) side is marked HV.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can use a level shifter with I²C but you don't need one. The Pi has pullup to 3.3V. Provided there are no other pullup it works. I routinely do this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The important phrase there is &quot;Provided there are no other pullup&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Wire.begin()&lt;/code&gt; enables the pull-ups. So make sure that &lt;em&gt;on the Nano side&lt;/em&gt; you disable them again:&lt;/p&gt;&#xA;&#xA; &#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;  Wire.begin (4);&#xA;  // disable internal pullups for twi.&#xA;  digitalWrite(SDA, LOW);&#xA;  digitalWrite(SCL, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-08T02:18:05.967" LastActivityDate="2016-04-08T02:18:05.967" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22830" PostTypeId="2" ParentId="4218" CreationDate="2016-04-07T06:00:46.443" Score="1" Body="&lt;p&gt;I don't have enough reputation to add a comment, but the datasheet link in @jfpoilpret is dead. &lt;a href=&quot;https://www.play-zone.ch/en/fileuploader/download/download/?d=1&amp;amp;file=custom%2Fupload%2FFile-1356269320.pdf&quot; rel=&quot;nofollow&quot;&gt;This link&lt;/a&gt; has the datasheet from the same website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="19815" LastActivityDate="2016-04-07T06:00:46.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22831" PostTypeId="2" ParentId="22798" CreationDate="2016-04-07T06:15:05.690" Score="6" Body="&lt;p&gt;The sensor in itself can't provide you the velocity. I have used it accelerometers in a couple of projects the easiest way to get the velocity is to constantly monitor acceleration changes and calculate velocity instantaneaously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to do so follow these instruction. Pleas note that this is only 1 axis reading in actual case you will have to perform this for all three axis i.e. x,y and z.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you are aware of the equation of motion (V = Vo + at)... The sensor will provide you value of acceleration at any given time. But acceleration can vary quite significantly during a huge time intervals so keep the time intervals 't' small. Lets say t = 10ms (depends on you). So calculate V after every 10ms intervale and this will give you current velocity at any given time. But what about Vo? As you know it is refered to as initial velocity so in the beginning it will be 0. Immediately after first reading when you are about to take second reading the Vo will change to the previous V calculated and hence forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means Vo at any given interval is actually the V calculated in the previous interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried this method in my project when using accelerometer. hope it helps you as well.&lt;/p&gt;&#xA;" OwnerUserId="18473" LastActivityDate="2016-04-07T06:15:05.690" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22832" PostTypeId="2" ParentId="22793" CreationDate="2016-04-07T06:24:20.373" Score="5" Body="&lt;p&gt;In short: not reliably.  The Arduino Nano expects either a 5V regulated supply or a 6-20V unregulated supply (&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardNano&lt;/a&gt;).  Even if you plugged it in and it worked initially, the battery voltage will decrease gradually as it discharges (LiPo cells can drop as low as ~3.2V), making it more and more unreliable.  You'd technically be overclocking the processor, since the Nano runs at 16 MHz and the &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet for the microcontroller&lt;/a&gt; requires at least a 4.5V supply to run above 10 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A safer solution would be to use a 2S LiPo battery (~7.4V), which would be plenty to supply the regulated input pin (VIN).  On the other hand, if you're set on using a 3.7V LiPo, other Arduino boards (like certain versions of the Pro Mini) run at 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your second question, 3.7V is plenty to power a few LEDs so long as they are connected in parallel (or to separate pins).  The only thing you need to be aware of is current draw--more current means shorter battery life.  For example, if your circuit draws 100 mA total from the battery, and your battery is specified at 500 mAh, you will get approximately (500 / 100) = 5 hours of battery life.&lt;/p&gt;&#xA;" OwnerUserId="19900" LastEditorUserId="26916" LastEditDate="2018-12-24T08:46:23.997" LastActivityDate="2018-12-24T08:46:23.997" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22833" PostTypeId="2" ParentId="22809" CreationDate="2016-04-07T09:12:13.210" Score="3" Body="&lt;p&gt;As I explained in my comment, the reason for this glitch is the Timer 0&#xA;overflow interrupt kicking in every 1024&amp;nbsp;µs. This interrupt is used&#xA;by the Arduino core library for timekeeping. It is the basis of&#xA;&lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;micros()&lt;/code&gt; and &lt;code&gt;delay()&lt;/code&gt;. The interrupt is &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring.c#L279&quot; rel=&quot;nofollow&quot;&gt;enabled by the&#xA;&lt;code&gt;init()&lt;/code&gt; function in&#xA;wiring.c&lt;/a&gt;.&#xA;There are several approaches to avoid that:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Avoid the Arduino core initialization&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This may be overkill, but since it seems you are already familiar with&#xA;directly accessing the IO ports of the ATmega chip, it may well suit&#xA;you. You can use the Arduino IDE without the Arduino core initialization&#xA;simply by defining your own &lt;code&gt;main()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA;    DDRD |= _BV(PD2);        // PD2 as output&#xA;    for (;;) {&#xA;        PORTD |= _BV(PD2);   // PD2 high&#xA;        PORTD &amp;amp;= ~_BV(PD2);  // PD2 low&#xA;        _delay_us(0.625);    // 10 CPU cycles, loop time = 16 cycles&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the extra delay: without it, the loop would complete in 6 CPU&#xA;cycles (2 per port access, 2 more to loop back). Not doing the Arduino&#xA;core initialization means you have no timekeeping and no &lt;code&gt;analogRead()&lt;/code&gt;&#xA;or &lt;code&gt;analogWrite()&lt;/code&gt;. Other Arduino functions should work normally but&#xA;some, like &lt;code&gt;Serial.begin()&lt;/code&gt; will bring their own interrupts.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Disable interrupts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;As suggested by Majenko, this may be the simplest way to have a steady&#xA;waveform:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    pinMode(2, OUTPUT);&#xA;    noInterrupts();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    PORTD |= _BV(PD2);   // PD2 high&#xA;    PORTD &amp;amp;= ~_BV(PD2);  // PD2 low&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Without interrupts, you have no timekeeping, no serial communications&#xA;and, obviously, no &lt;code&gt;attachInterrupt()&lt;/code&gt;. Most other Arduino functions&#xA;should work.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Use a hardware timer&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This allows you to generate the signal without relying on the CPU. You&#xA;can keep interrupts enabled and do other work in the program while the&#xA;waveform goes undisturbed. The simplest way to generate such a waveform&#xA;is with &lt;code&gt;analogWrite()&lt;/code&gt;. The resulting frequency is quite low though,&#xA;like 0.5 to 1&amp;nbsp;kHz. If you want 1&amp;nbsp;MHz, you will have to&#xA;configure the timer the hard way. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    DDRD |= _BV(PD3);     // OC2B = PD3 as output&#xA;    OCR2A = 15;           // period = 16 clock cycles&#xA;    OCR2B = 1;            // high during 2 clock cycles&#xA;    TCCR2A = _BV(COM2B1)  // non-inverting PWM&#xA;           | _BV(WGM20)   // fast PWM, TOP = OCR2A&#xA;           | _BV(WGM21);  // ditto&#xA;    TCCR2B = _BV(WGM22)   // ditto&#xA;           | _BV(CS20);   // clock at f_CPU&#xA;}&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is on pin PD3 = digital 3. This configuration will disable&#xA;&lt;code&gt;analogWrite()&lt;/code&gt; on pins 3 (PD3) and 11 (PB3).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-07T09:12:13.210" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22835" PostTypeId="2" ParentId="22809" CreationDate="2016-04-07T09:33:18.753" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to produce quick square waveform for testing purposes.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Whole loop cycle take 1 us which mean 16 instructions (62.5 ns per instruction). So I will get 125 ns high and rest of the time low signal.&#xA;  Any idea what I'm doing wrong? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are assuming that what goes on outside loop() and the call to loop() takes no time at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what the Arduino core &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp#L33&quot; rel=&quot;nofollow noreferrer&quot;&gt;main()&lt;/a&gt; looks like. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(void)&#xA;{&#xA;    init();&#xA;&#xA;    initVariant();&#xA;&#xA;#if defined(USBCON)&#xA;    USBDevice.attach();&#xA;#endif&#xA;&#xA;    setup();&#xA;&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is both the call to loop(), if-branch, and for-branch. This all adds up. On top of this there are a number of Interrupt Service Routines (ISR) such as for the Timer which is used for the micros() and millis() count. These will interleave periodically (as you have observed). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the question is how to fix this and I think @Edgar Bonet has done an excellent job with that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditorDisplayName="user24204" LastEditDate="2020-06-04T18:10:49.513" LastActivityDate="2020-06-04T18:10:49.513" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22837" PostTypeId="1" AcceptedAnswerId="22838" CreationDate="2016-04-07T10:22:25.433" Score="0" ViewCount="206" Body="&lt;p&gt;Each new circuit I build, I seem to make every possible mistake, including inverting 5V and ground. &#xA;I did that precise mistake on this 2x16 Sainsmart LCD. The backlight definitely works, but is the only thing I seem to be able to make work. Do you believe I fried the screen, or do they maybe have a diode to protect from erroneous cabling, and my mistake is another one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this somewhere, on a board that might be the one driving this LCD screen or not :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Operating Voltage VDD -0.3 to +7.0 V&#xA;Driver Supply Voltage VLCD VDD - 10 to VDD + 0.3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I mistakenly put 5V in VLCD, and 0V in VDD, which makes VLCD 5V and not 0.3V above VDD, would you suppose I fried it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your input :)&lt;/p&gt;&#xA;" OwnerUserId="19700" LastEditorUserId="19700" LastEditDate="2016-04-07T11:09:00.313" LastActivityDate="2016-04-07T11:09:00.313" Title="Did I fry a Sainsmart 1602LCD (not shield, just LCD), HD44780 compatible" Tags="|lcd|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22838" PostTypeId="2" ParentId="22837" CreationDate="2016-04-07T11:08:31.730" Score="1" Body="&lt;p&gt;For me, it's extremely hard to tell if you did or did not fry a device.&#xA;Even if you have the device right in front of you, it's often hard to tell.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've got two options:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Attempt to diagnose it&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you should try to run example code and follow the &quot;instructions&quot;. I believe this product is relatively well documented (/libraried?) and shouldn't be all too hard to set up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this isn't working, it's likely the device is dead (given the situation). You could go on and fiddle around with it for hours, which might not be worth the effort.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Buy a new one&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will cost you some money. But if you get the new one working, you can test the same code on your old one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Tips&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First connect the wires, check the wiring and AFTER THAT connect the power. (Especially take care on GND/VCC wiring.)&lt;/li&gt;&#xA;&lt;li&gt;Use black wires for GND/ground and red wires for VCC/5V.(It'll be easier to manage/spot)&lt;/li&gt;&#xA;&lt;li&gt;Check the devices datasheets (which pins, what maximal voltage)&lt;/li&gt;&#xA;&lt;li&gt;Try to use female connectors as power-output. (They don't short everything they touch)&lt;/li&gt;&#xA;&lt;li&gt;Try to use irreversible connectors.&lt;/li&gt;&#xA;&lt;li&gt;Don't have loose leads dangling around.&lt;/li&gt;&#xA;&lt;li&gt;Put a casing/backplate on your Arduino (and/or avoid placing it on metal)&lt;/li&gt;&#xA;&lt;li&gt;Keep your desk clean, bits of solder, wire, leads or screws may cause shorts between pins.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-04-07T11:08:31.730" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22839" PostTypeId="1" AcceptedAnswerId="22840" CreationDate="2016-04-07T11:17:38.300" Score="0" ViewCount="2019" Body="&lt;p&gt;I've recently got back to my Uno. I tried compiling my program and got the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.6 (Windows 8.1), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;avr-g++: error: missing filename after '-o'&#xA;&#xA;exit status 1&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This happens on any of the programs I've tried to compile/upload.&#xA;I've searched around on Google but I have gotten no definite answers and how to fix this or what has caused this? Does anyone have an idea on what I could do?&lt;/p&gt;&#xA;" OwnerUserId="19548" LastEditorUserId="15168" LastEditDate="2016-04-07T13:21:38.543" LastActivityDate="2016-04-07T13:21:38.543" Title="&quot;missing filename&quot; compilation Error" Tags="|arduino-ide|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22840" PostTypeId="2" ParentId="22839" CreationDate="2016-04-07T11:55:27.663" Score="1" Body="&lt;p&gt;I had same problem. You should download Arduino IDE 1.6.8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Software&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19983" LastActivityDate="2016-04-07T11:55:27.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22841" PostTypeId="2" ParentId="22824" CreationDate="2016-04-07T11:58:54.617" Score="1" Body="&lt;p&gt;&lt;strong&gt;Assuming that you have a 3.3V Atmega328P and are using an external 8MHz occilator:&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE click on &lt;code&gt;Tools&lt;/code&gt;.&lt;br&gt;&#xA;Scroll down until you see an option starting with the word &lt;code&gt;Board:&lt;/code&gt;&lt;br&gt;&#xA;Select the option called &lt;code&gt;Arduino Pro or Pro Mini&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Click the &lt;code&gt;Tools&lt;/code&gt; menu once again.&lt;br&gt;&#xA;This time select the option starting with &lt;code&gt;Processor:&lt;/code&gt;&lt;br&gt;&#xA;Select the &lt;code&gt;Atmega328P (3.3V, 8MHz)&lt;/code&gt;&lt;br&gt;&#xA;Done!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can edit the &lt;code&gt;boards.txt&lt;/code&gt; file located somewhere similar to &lt;code&gt;C:\Program Files (x86)\Arduino\hardware\arduino\avr&lt;/code&gt;&lt;br&gt;&#xA;Fuse bits can be calculated using one of these online tools:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.engbedded.com/fusecalc/&lt;/a&gt;  &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://eleccelerator.com/fusecalc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://eleccelerator.com/fusecalc/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:05:24.273" LastActivityDate="2018-12-13T12:05:24.273" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22843" PostTypeId="2" ParentId="22809" CreationDate="2016-04-07T12:13:50.490" Score="1" Body="&lt;p&gt;If you just want a rough square wave to test and you don't care about the frequency then try this:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;   pinMode(2, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;   digitalWrite(2, true);&#xA;   delay(2);&#xA;   digitalWrite(2, false);&#xA;   delay(2);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19409" LastActivityDate="2016-04-07T12:13:50.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22844" PostTypeId="2" ParentId="13292" CreationDate="2016-04-07T12:27:50.480" Score="3" Body="&lt;p&gt;I have bricked 2x ATMega328P on my Arduino Uno board due to static (I think).&lt;/p&gt;&#xA;&lt;p&gt;The static seems to have killed the TX pin and hence the program can't be downloaded using the USB cable.&lt;/p&gt;&#xA;&lt;p&gt;The easiest solution is to replace the microcontroller. You can buy a new ATMega328P DIP programmed with the Arduino bootloader (&lt;a href=&quot;https://www.adafruit.com/product/123&quot; rel=&quot;nofollow noreferrer&quot;&gt;such as this one from Adafruit&lt;/a&gt;) and you are ready to go again.&lt;/p&gt;&#xA;&lt;p&gt;Alternatively, you can still program the ATMega328P's by using the Atmel Ice or AVRISPmkII programmer or by using another Arduino as an ICSP programmer. When you do, all but the Tx pin work fine.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2021-02-18T10:09:26.493" LastActivityDate="2021-02-18T10:09:26.493" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22845" PostTypeId="1" CreationDate="2016-04-07T12:33:40.890" Score="1" ViewCount="196" Body="&lt;p&gt;I am currently working with an Arduino Micro / Linduino and making a program based on a lot of switch statements to execute certain functions that will be passed to a microprocessor (&lt;code&gt;LT2974&lt;/code&gt;) on a board serially. For the most part, all of the functions I have work, except there is one that I am trying to determine if it is my program that is causing issues, or the Linear Tech libraries that are provided. Upon research, I did discover something strange in my code that I cannot explain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a quick snippet of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long serialdata;&#xA;int inbyte;&#xA;&#xA;long getSerial()&#xA;{&#xA;  serialdata = 0;&#xA;  while (inbyte != '/')&#xA;  {&#xA;    inbyte = Serial.read();     &#xA;    if (inbyte &amp;gt; 0 &amp;amp;&amp;amp; inbyte != '/')&#xA;    {&#xA;      serialdata = serialdata * 10 + inbyte - '0';&#xA;      Serial.print(serialdata);&#xA;      Serial.print(&quot;test \n&quot;);&#xA;    }&#xA;  }&#xA;  inbyte = 0;&#xA;  return serialdata;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  getSerial();&#xA;  // Switch statement represents Slot choices&#xA;  switch (serialdata)&#xA;  {&#xA;&#xA;    case 1:&#xA;      {&#xA;        commands(Slot1);&#xA;        break;&#xA;      }&#xA;    case 2:&#xA;      {&#xA;        commands(Slot2);&#xA;        break;&#xA;      }&#xA;    case 3:&#xA;      {&#xA;        commands(Slot3);&#xA;        break;&#xA;      }&#xA;    case 4:&#xA;      {&#xA;        commands(Slot4);&#xA;        break;&#xA;      }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have left out the following switch statements that are found in the commands function as they are not where the issue lies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, when I pass data through to the Arduino, and then go to reprint it out with my &lt;code&gt;Serial.print&lt;/code&gt; command in &lt;code&gt;getSerial()&lt;/code&gt;, there is an additional number printing, and I believe the issue to lie here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for example, if I type &lt;code&gt;&quot;/1/&quot;&lt;/code&gt; (the slashes were used to pass multiple variables as shown in the function, but I'm only passing one for now), the Arduino reponds with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1test &#xA;4294967268test &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is &lt;code&gt;&quot;/2/&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2test &#xA;4294967258test &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is passing multiple variables with &lt;code&gt;&quot;/2/9/&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2test &#xA;9test &#xA;4294967258test &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of the values I just showed you do not correspond to any of my switch statements implemented, and so no actual data is being returned besides the print command from &lt;code&gt;getSerial()&lt;/code&gt;. So can anyone explain what is going on here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I added the data types of &lt;code&gt;serialdata&lt;/code&gt; and &lt;code&gt;inbyte&lt;/code&gt; to the top of the post. &lt;/p&gt;&#xA;" OwnerUserId="19985" LastEditorDisplayName="user24204" LastEditDate="2016-09-30T14:27:20.650" LastActivityDate="2016-09-30T14:27:20.650" Title="Random numbers being printed back after entering data" Tags="|serial|arduino-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22846" PostTypeId="2" ParentId="22845" CreationDate="2016-04-07T12:44:31.157" Score="1" Body="&lt;p&gt;The problem is that you are blindly reading serial data without first looking to see if there is actually any serial data available to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no data there &lt;code&gt;Serial.read()&lt;/code&gt; will return -1.  Since you have only provided a snippet of your program I can't say what data type &lt;code&gt;inbyte&lt;/code&gt; is, but my guess is it's some form of unsigned 32-bit value, since -1 mapped into an unsigned 32-bit value is 4294967295.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to be checking the presence of data, and only reading when you should read, and also looking for the end of your data sequence (add some terminating character, like a line feed) to know when to stop looking for and reading characters.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-07T12:44:31.157" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22847" PostTypeId="2" ParentId="22765" CreationDate="2016-04-07T13:05:24.817" Score="-1" Body="&lt;p&gt;I have seen this once before when one of my mates was having troubles programming a ATMega328P on a custom board. It turned out to be his physical serial port. We later confirmed it with a scope - indeed the first packet wasn't what it was meant to be sending. So we switched to a USB-to-Serial dongle that I had and the problem was resolved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, I highly suspect that it is the CH340 to blame here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try programming the Adruino with the AVRISPmkII or another USB-to-TTL converter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Alternatively you could program your microcontroller using a genuine Arduino Uno board (such as a friends) and then place it back onto your board.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:12:18.747" LastActivityDate="2018-12-13T12:12:18.747" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22848" PostTypeId="1" CreationDate="2016-04-07T13:45:14.630" Score="5" ViewCount="2144" Body="&lt;p&gt;Ideally I'd like a 2.8 inch and it to be touch screen. &#xA;But most of all I'd rather it work on both boards without much hassle.&lt;/p&gt;&#xA;" OwnerUserId="19986" LastActivityDate="2017-08-21T01:06:32.867" Title="Which tft works on both Arduino Uno and Raspberry pi" Tags="|arduino-uno|raspberrypi|tft|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22849" PostTypeId="1" CreationDate="2016-04-07T14:39:48.303" Score="1" ViewCount="74" Body="&lt;p&gt;I want to make a 4hz reading of GSR and temperature, in the following format for every second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;697,20.8744&#xA;696,20.86521&#xA;695,20.8653&#xA;699,20.8777&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The print, in python, would be print(GSR+&quot;,&quot;+Temp)&#xA;The tries in C are giving problem, here's my actual code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;const int GSR=A0;&#xA;int threshold=0;&#xA;int sensorValue;&#xA;unsigned long startTime = 0;&#xA;#define MEASURE_PERIOD 250&#xA;OneWire  ds(3);&#xA;&#xA;void setup(){&#xA;  long sum=0;&#xA;  Serial.begin(115200);&#xA;&#xA;  for(int i=0;i&amp;lt;500;i++)&#xA;  {&#xA;  sensorValue=analogRead(GSR);&#xA;  sum += sensorValue;&#xA;  delay(5);&#xA;  }&#xA;  threshold = sum/500;&#xA;  }&#xA;&#xA;void loop()&#xA;{&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius;&#xA;    if((millis() - startTime) &amp;gt;= MEASURE_PERIOD)&#xA;    {&#xA;        startTime += MEASURE_PERIOD;&#xA;        // Do your job, such as&#xA;        sensorValue=analogRead(GSR);&#xA;        Serial.print(sensorValue);&#xA;        Serial.print(&quot;,&quot;);&#xA;        if ( !ds.search(addr)) {&#xA;    ds.reset_search();&#xA;    return;&#xA;  }&#xA;&#xA;&#xA;&#xA;  if (OneWire::crc8(addr, 7) != addr[7]) {&#xA;      return;&#xA;  }&#xA;  // the first ROM byte indicates which chip&#xA;&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;   // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;  }&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;  celsius = (float)raw / 16.0;&#xA;  Serial.print(celsius);&#xA;&#xA;    }&#xA;    Serial.println(&quot;\n&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I reach the upper format?&lt;/p&gt;&#xA;" OwnerUserId="15699" LastActivityDate="2016-04-07T19:35:37.807" Title="Why does this code show me a lot of space?" Tags="|arduino-uno|arduino-nano|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22850" PostTypeId="2" ParentId="22849" CreationDate="2016-04-07T15:07:01.393" Score="1" Body="&lt;p&gt;From the point of view of what you print, your loop boils down to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (millis() - startTime &amp;gt;= MEASURE_PERIOD) {&#xA;    startTime += MEASURE_PERIOD;&#xA;    sensorValue = ...;&#xA;    celcius = ...;&#xA;    Serial.print(sensorValue);&#xA;    Serial.print(&quot;,&quot;);&#xA;    Serial.print(celsius);&#xA;}&#xA;Serial.println(&quot;\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are printing &lt;em&gt;two&lt;/em&gt; newlines on every loop iteration. One is written&#xA;as &lt;code&gt;&quot;\n&quot;&lt;/code&gt;, the other is the “ln” of &lt;code&gt;Serial.println&lt;/code&gt; (“println” means&#xA;“print some stuff followed by a new line character sequence”). Instead,&#xA;you probably want to print a &lt;em&gt;single&lt;/em&gt; newline, and only when there is&#xA;actual data being printed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (millis() - startTime &amp;gt;= MEASURE_PERIOD) {&#xA;    startTime += MEASURE_PERIOD;&#xA;    sensorValue = ...;&#xA;    celcius = ...;&#xA;    Serial.print(sensorValue);&#xA;    Serial.print(&quot;,&quot;);&#xA;    Serial.println(celsius);  // notice the ln in println&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But since you are doing nothing else in &lt;code&gt;loop()&lt;/code&gt;, you could simplify a&#xA;bit and avoid having everything inside a big &lt;code&gt;if&lt;/code&gt; statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (millis() - startTime &amp;lt; MEASURE_PERIOD)&#xA;    return;&#xA;&#xA;startTime += MEASURE_PERIOD;&#xA;sensorValue = ...;&#xA;celcius = ...;&#xA;Serial.print(sensorValue);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.println(celsius);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Here is a simple test demonstrating this logic. In both the&#xA;second and the third case, it generates an output in the requested&#xA;format.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint32_t MEASURE_PERIOD = 250;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    static uint32_t startTime;&#xA;#ifdef SECOND_CASE&#xA;    if (millis() - startTime &amp;gt;= MEASURE_PERIOD) {&#xA;        startTime += MEASURE_PERIOD;&#xA;        int sensorValue = random(695, 699);&#xA;        float celsius = map(sensorValue, 695, 699, 208653, 208777) / 1e4;&#xA;        Serial.print(sensorValue);&#xA;        Serial.print(&quot;,&quot;);&#xA;        Serial.println(celsius, 3);  // notice the ln in println&#xA;    }&#xA;#else  // third case&#xA;    if (millis() - startTime &amp;lt; MEASURE_PERIOD)&#xA;        return;&#xA;&#xA;    startTime += MEASURE_PERIOD;&#xA;    int sensorValue = random(695, 699);&#xA;    float celsius = map(sensorValue, 695, 699, 208653, 208777) / 1e4;&#xA;    Serial.print(sensorValue);&#xA;    Serial.print(&quot;,&quot;);&#xA;    Serial.println(celsius, 3);  // notice the ln in println&#xA;#endif&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-07T19:35:37.807" LastActivityDate="2016-04-07T19:35:37.807" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="22851" PostTypeId="2" ParentId="22816" CreationDate="2016-04-07T16:00:11.300" Score="0" Body="&lt;p&gt;If you print from arduino to serial and you don't read it then the buffer gets full. Causing it to go in a second delay. So make sure you read as well when you send data over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A short sleep is required between the sleep and the read for some reason. Else it hangs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;from time import sleep&#xA;&#xA;ser = serial.Serial('COM3', 115200)&#xA;sleep(1)&#xA;&#xA;c = 0&#xA;&#xA;while True:&#xA;    c+=1&#xA;    print(&quot;ok &quot;, c)&#xA;    numIn = &quot;100&quot;&#xA;    ser.write((numIn + '\r\n').encode())&#xA;    sleep(1./120)&#xA;&#xA;    inp = ser.readline()&#xA;    print(inp.decode(&quot;utf-8&quot;))&#xA;    sleep(1./120)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19933" LastActivityDate="2016-04-07T16:00:11.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22852" PostTypeId="1" AcceptedAnswerId="22853" CreationDate="2016-04-07T16:11:12.230" Score="5" ViewCount="22018" Body="&lt;p&gt;There is something I don't understand about serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know the &lt;code&gt;Newline&lt;/code&gt; option is &lt;code&gt;\n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;Carriage return&lt;/code&gt; option is &lt;code&gt;\r\n&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But does that make the &lt;code&gt;Both NL &amp;amp; CR&lt;/code&gt; option &lt;code&gt;\n\r\n&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19933" LastActivityDate="2016-04-07T17:14:04.380" Title="What does serial monitor send with 'Both NL &amp; CR'" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22853" PostTypeId="2" ParentId="22852" CreationDate="2016-04-07T16:31:37.967" Score="8" Body="&lt;p&gt;Newline is &lt;code&gt;\n&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Carriage Return is &lt;code&gt;\r&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both NL &amp;amp; CR is &lt;code&gt;\r\n&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="337" LastActivityDate="2016-04-07T16:31:37.967" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22854" PostTypeId="2" ParentId="22852" CreationDate="2016-04-07T17:14:04.380" Score="3" Body="&lt;p&gt;&quot;Both&quot; means 1 Carriage Return and 1 Newline (formerly known as &quot;Line Feed&quot;). Our present day &quot;standards&quot; are descended from mechanical teletypes that used those separate codes for the two separate mechanical functions: Returning the print carriage to the left side of the page, and scrolling the paper up one line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DOS/Windows world adopted the teletype standard (both) as is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The unix world dropped the carriage return as unnecessary, letting a single character stand for the end of a line, and more modern hardware (or its software drivers) could figure out what to do for the particular device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Apple world chose Carriage Return for its standard back in the mists of time, dropping it in later years for a selectable end-of-line sequence where appropriate, but more usually using the unix standard once it's OSes became hosted on unix.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-07T17:14:04.380" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22855" PostTypeId="2" ParentId="16493" CreationDate="2016-04-07T17:56:52.473" Score="1" Body="&lt;p&gt;I had a similar project a few months back and spotted this Arduino Library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/z3t0/Arduino-IRremote&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and it is invaluable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your instance, you want the RAW Data which you can achieve using an Example included in the Library named: IRrecvDemo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring is easy and straight forward&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An IR detector/demodulator must be connected to the input RECV_PIN.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which is 11 by default but you can definitely change it :3&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and the other two Legs of the IR detector/demodulator go to the power source.&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-04-07T17:56:52.473" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22856" PostTypeId="2" ParentId="22811" CreationDate="2016-04-07T18:14:08.420" Score="0" Body="&lt;p&gt;From what you've provided everything seems to be compatible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the battery, a quick look at the Arduino website shows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Input Voltage 3.35 -12 V (3.3V model)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Meaning the regulator will work as long as the battery provides voltage above 3.35 but since your battery's voltage drops as it gets depleted you might not get the battery life you'd expect :/. In other words: it'll work initially  until the voltage drops below 3.35V and then you would have to recharge it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is using Li-Ion in any way different from regular AA&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes and No.&#xA;No : both provide a stable DC source and both can be used in similar applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes: Li-Ion batteries can be recharged and have a longer life-span, and most importantly, Li-Ion batteries don't have a sharp voltage drop as they get depleted, unlike regular AA batteries. Which is a bonus for this project ( i guess :p )&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I see 3 pins on the back of it&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are only 2 pins that actually provide the power from the battery while the third is usually used to monitor temperature or battery life remaining.So you can use this battery by only connecting the power providing pins (usually indicated by + and - ) and safely ignore the third.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gd Luck!&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-04-07T18:14:08.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22857" PostTypeId="2" ParentId="22736" CreationDate="2016-04-07T18:28:17.240" Score="1" Body="&lt;p&gt;I searched for the library you're using and the arduino website mentions : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;0 being full-speed in one direction, 180 being full speed in the other, and &lt;strong&gt;a value near 90 being no movement&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From this we can take that the value 90 is not perfectly in the middle of the speed range therefore 10 points under 90 won't necessarily be equivalent to 10 points above 90.&#xA;My only advice is to try and find the equivalence point yourself by trail and error.&#xA;Even though 90 seems to cause no movement, try 89 or 91 see if they also have the result and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or simply try different values to get same speeds in different directions, it's ok if you use different values (away from 90) for the two different directions :P.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gd Luck&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-04-07T18:28:17.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22858" PostTypeId="1" CreationDate="2016-04-07T18:37:22.807" Score="2" ViewCount="1024" Body="&lt;p&gt;I want to take a picture with the OV0706 and save it to an SD card. I'm using an Arduino Mega2560, Ethernet Shield (with SD slot) and &lt;a href=&quot;http://www.aliexpress.com/item/NEW-RS232-TTL-JPEG-Digital-Serial-Camera-Module-SCB-1-with-video-out-Support-VIMICRO-VC0706/1975852463.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;an OV0706&lt;/a&gt;. I tried the tutorial for this camera from Adafruit, but I'm still getting a 'No camera found?' error.&lt;/p&gt;&#xA;&lt;p&gt;I thought it had something to do with assigning the pins, but if I connect the RX from the OV0706 with A15 on the Mega (see picture), it still gives the same error.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:&#xA;SoftwareSerial cameraconnection = SoftwareSerial(69, 3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code (important part):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// This is a basic snapshot sketch using the VC0706 library.&#xA;// On start, the Arduino will find the camera and SD card and&#xA;// then snap a photo, saving it to the SD card.&#xA;// Public domain.&#xA;&#xA;// If using an Arduino Mega (1280, 2560 or ADK) in conjunction&#xA;// with an SD card shield designed for conventional Arduinos&#xA;// (Uno, etc.), it's necessary to edit the library file:&#xA;//   libraries/SD/utility/Sd2Card.h&#xA;// Look for this line:&#xA;//   #define MEGA_SOFT_SPI 0&#xA;// change to:&#xA;//   #define MEGA_SOFT_SPI 1&#xA;// This is NOT required if using an SD card breakout interfaced&#xA;// directly to the SPI bus of the Mega (pins 50-53), or if using&#xA;// a non-Mega, Uno-style board.&#xA;&#xA;#include &amp;lt;Adafruit_VC0706.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;// comment out this line if using Arduino V23 or earlier&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;         &#xA;&#xA;// uncomment this line if using Arduino V23 or earlier&#xA;// #include &amp;lt;NewSoftSerial.h&amp;gt;       &#xA;&#xA;// SD card chip select line varies among boards/shields:&#xA;// Adafruit SD shields and modules: pin 10&#xA;// Arduino Ethernet shield: pin 4&#xA;// Sparkfun SD shield: pin 8&#xA;// Arduino Mega w/hardware SPI: pin 53&#xA;// Teensy 2.0: pin 0&#xA;// Teensy++ 2.0: pin 20&#xA;#define chipSelect 4&#xA;&#xA;// Pins for camera connection are configurable.&#xA;// With the Arduino Uno, etc., most pins can be used, except for&#xA;// those already in use for the SD card (10 through 13 plus&#xA;// chipSelect, if other than pin 10).&#xA;// With the Arduino Mega, the choices are a bit more involved:&#xA;// 1) You can still use SoftwareSerial and connect the camera to&#xA;//    a variety of pins...BUT the selection is limited.  The TX&#xA;//    pin from the camera (RX on the Arduino, and the first&#xA;//    argument to SoftwareSerial()) MUST be one of: 62, 63, 64,&#xA;//    65, 66, 67, 68, or 69.  If MEGA_SOFT_SPI is set (and using&#xA;//    a conventional Arduino SD shield), pins 50, 51, 52 and 53&#xA;//    are also available.  The RX pin from the camera (TX on&#xA;//    Arduino, second argument to SoftwareSerial()) can be any&#xA;//    pin, again excepting those used by the SD card.&#xA;// 2) You can use any of the additional three hardware UARTs on&#xA;//    the Mega board (labeled as RX1/TX1, RX2/TX2, RX3,TX3),&#xA;//    but must specifically use the two pins defined by that&#xA;//    UART; they are not configurable.  In this case, pass the&#xA;//    desired Serial object (rather than a SoftwareSerial&#xA;//    object) to the VC0706 constructor.&#xA;&#xA;// Using SoftwareSerial (Arduino 1.0+) or NewSoftSerial (Arduino 0023 &amp;amp; prior):&#xA;#if ARDUINO &amp;gt;= 100&#xA;// On Uno: camera TX connected to pin 2, camera RX to pin 3:&#xA;//SoftwareSerial cameraconnection = SoftwareSerial(2, 3);&#xA;// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:&#xA;SoftwareSerial cameraconnection = SoftwareSerial(69, 3);&#xA;#else&#xA;NewSoftSerial cameraconnection = NewSoftSerial(2, 3);&#xA;#endif&#xA;&#xA;Adafruit_VC0706 cam = Adafruit_VC0706(&amp;amp;cameraconnection);&#xA;&#xA;// Using hardware serial on Mega: camera TX conn. to RX1,&#xA;// camera RX to TX1, no SoftwareSerial object is required:&#xA;//Adafruit_VC0706 cam = Adafruit_VC0706(&amp;amp;Serial1);&#xA;&#xA;void setup() {&#xA;&#xA;  // When using hardware SPI, the SS pin MUST be set to an&#xA;  // output (even if not connected or used).  If left as a&#xA;  // floating input w/SPI on, this can cause lockuppage.&#xA;#if !defined(SOFTWARE_SPI)&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega&#xA;#else&#xA;  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.&#xA;#endif&#xA;#endif&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&amp;quot;VC0706 Camera snapshot test&amp;quot;);&#xA;  &#xA;  // see if the card is present and can be initialized:&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&amp;quot;Card failed, or not present&amp;quot;);&#xA;    // don't do anything more:&#xA;    return;&#xA;  }  &#xA;  &#xA;  // Try to locate the camera&#xA;  if (cam.begin()) {&#xA;    Serial.println(&amp;quot;Camera Found:&amp;quot;);&#xA;  } else {&#xA;    Serial.println(&amp;quot;No camera found?&amp;quot;);&#xA;    return;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&lt;p&gt;(Pictures: &lt;a href=&quot;http://prntscr.com/apdvi9&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://prntscr.com/apdvi9&lt;/a&gt; )&lt;/p&gt;&#xA;" OwnerUserId="19990" LastEditorUserId="4628" LastEditDate="2023-12-24T13:39:47.693" LastActivityDate="2024-01-23T14:01:55.263" Title="Arduino Mega2560, Ethernet Shield &amp; OV0706: &quot;Camera not found&quot;" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22859" PostTypeId="1" AcceptedAnswerId="22879" CreationDate="2016-04-07T19:18:08.620" Score="4" ViewCount="711" Body="&lt;p&gt;I have 2 Arduino Unos, 2 XBees and 2 Wireless Proto Shields. The first setup has a humidity/temperature sensor (SHT21P) and it writes data to serial and it works (I've tested it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the other Arduino with shield and XBee is plugged in my PC to get data from the sensor. So here's the problem: as far as I understand, I can't use XBee and Arduino at the same time, because USB and Arduino both use TX/RX pins to communicate to PC/XBee. I've tested both of the XBees when they are powered with DC jack and they both work. So can anyone confirm that it's true that they're not made for being used by PC and Arduino at the same time? If so, how can I get the data to my computer?&lt;/p&gt;&#xA;" OwnerUserId="18850" LastEditorUserId="4628" LastEditDate="2017-02-03T04:01:07.367" LastActivityDate="2018-11-27T01:03:05.690" Title="Using Arduino and XBee at the same time" Tags="|arduino-uno|communication|xbee|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22860" PostTypeId="1" CreationDate="2016-04-07T19:18:21.713" Score="2" ViewCount="577" Body="&lt;p&gt;I've been trying to upload data to data. Sparkfun's servers using HTTP commands, but I've hit errors every time I try. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;String.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial1.begin(9600);               // the GPRS baud rate   &#xA;  Serial.begin(9600);    // the GPRS baud rate &#xA;  delay(500);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (Serial.available())&#xA;    switch(Serial.read())&#xA;   {&#xA;     case 'h':&#xA;       SubmitHttpRequest();&#xA;       break;&#xA;       case 'j':&#xA;       http();&#xA;       break;&#xA;        } &#xA;  if (Serial1.available())&#xA;    Serial.write(Serial1.read());&#xA;}&#xA;&#xA;///SubmitHttpRequest()&#xA;///this function is submit a http request&#xA;///attention:the time of delay is very important, it must be set enough &#xA;void SubmitHttpRequest()&#xA;{&#xA;  Serial1.println(&quot;AT+CSQ&quot;);&#xA;  delay(100);&#xA;&#xA;  ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.&#xA;&#xA;  Serial1.println(&quot;AT+CGATT?&quot;);&#xA;  delay(100);&#xA;&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+SAPBR=3,1,\&quot;CONTYPE\&quot;,\&quot;GPRS\&quot;&quot;);//setting the SAPBR, the connection type is using gprs&#xA;  delay(1000);&#xA;&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;airtelgprs.com\&quot;&quot;);//setting the APN, the second need you fill in your local apn server&#xA;  delay(4000);&#xA;&#xA;  ShowSerialData();&#xA;&#xA; // Serial1.println(&quot;AT+SAPBR=1,1&quot;);//setting the SAPBR, for detail you can refer to the AT command mamual&#xA;  //delay(2000);&#xA;&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPINIT&quot;); //init the HTTP request&#xA;&#xA;  delay(4000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;http://data.sparkfun.com/input/[public key]?private_key=[private key]&amp;amp;gas=24\&quot;&quot;);// setting the httppara, the second parameter is the website you want to access&#xA;  delay(10);&#xA;&#xA;  ShowSerialData();&#xA;  Serial1.print(&quot; HTTP/1.1\r\n&quot;);&#xA;  delay(500);&#xA;  ShowSerialData();&#xA;&#xA;  delay(1000);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPACTION=1&quot;);//submit the request &#xA;  delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.&#xA;&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPREAD&quot;);// read the data from the website you access&#xA;  delay(300);&#xA;&#xA;  ShowSerialData();&#xA;&#xA;&#xA;  Serial1.println(&quot;&quot;);&#xA;  delay(100);&#xA;}&#xA;void http()&#xA;{&#xA;  Serial1.println(&quot;AT+CGATT?&quot;);&#xA;  delay(300);&#xA;  ShowSerialData();&#xA;Serial1.println(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;airtelgprs.com\&quot;&quot;);//setting the APN, the second need you fill in your local apn server&#xA;  delay(1000); &#xA;  ShowSerialData();&#xA;&#xA; Serial1.println(&quot;AT+CIFSR&quot;);//get local IP adress&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSPRT=0&quot;);&#xA;  delay(3000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;http://data.sparkfun.com\&quot;,\&quot;80\&quot;&quot;);//start up the connection&#xA;&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;  Serial.println();&#xA;  Serial1.println(&quot;AT+CIPSEND&quot;);//begin send data to remote server&#xA;  delay(4500);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.print(&quot;PUT /input/[public key]?private_key=[private key]&amp;amp;gas=4&quot;);&#xA;  delay(10);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.print(&quot; HTTP/1.1\r\n&quot;);&#xA;  delay(500);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;Host: http://data.sparkfun.com\r\n&quot;);&#xA;  delay(500);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.print(&quot;Connection: keep-alive&quot;);  //working&#xA;  Serial1.print(&quot;\r\n&quot;);&#xA;  Serial1.print(&quot;\r\n&quot;);&#xA;  Serial1.println();&#xA;  delay(500);&#xA;  ShowSerialData();&#xA;&#xA;Serial1.println((char)26);&#xA;  Serial1.write(0x1A);&#xA;  delay(500);//waitting for reply, important! the time is base on the condition of internet &#xA;  Serial1.println(); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPCLOSE&quot;);//close the connection&#xA;  delay(100);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSHUT=0&quot;);&#xA;  delay(100); &#xA;  ShowSerialData();&#xA;&#xA;} &#xA;&#xA;void ShowSerialData()&#xA;{&#xA;  while(Serial1.available()!=0)&#xA;    Serial.write(Serial1.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the first function (&lt;code&gt;httprequest&lt;/code&gt;) I don't get a response on the server, even though the at commands all work. The second function(&lt;code&gt;http&lt;/code&gt;) At At+CIPSEND, I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;ERROR&#xA;&#xA;STATE: IP STATUS&#xA;&#xA;CONNECT FAIL&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I've changed the URL but no luck. I still get the same response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Mega and a GSM SIM900&lt;/p&gt;&#xA;" OwnerUserId="19740" LastEditorUserId="37523" LastEditDate="2019-07-06T19:54:59.983" LastActivityDate="2019-07-06T19:54:59.983" Title="Sim900 data logging through Sparkfun" Tags="|serial|gsm|http|simulator|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="22861" PostTypeId="1" CreationDate="2016-04-07T19:25:22.237" Score="2" ViewCount="907" Body="&lt;p&gt;I followed this guide: &lt;a href=&quot;http://arduinodev.com/guide-to-arduino-development-environment-codeblocks/&quot; rel=&quot;nofollow&quot;&gt;http://arduinodev.com/guide-to-arduino-development-environment-codeblocks/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seemed to work until I compiled the example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;/*&#xA;  Turns on an LED on for one second, then off for one second, repeatedly.&#xA;&#xA;  This example code is in the public domain.&#xA;*/&#xA;&#xA;void setup()&#xA;{&#xA;    // initialize the digital pin as an output.&#xA;    // Pin 13 has an LED connected on most Arduino boards:&#xA;    pinMode(13, OUTPUT);     &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(13, HIGH);   // set the LED on&#xA;    delay(1000);              // wait for a second&#xA;    digitalWrite(13, LOW);    // set the LED off&#xA;    delay(1000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it gave me this errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;||=== Build: Simulator - Debug in test (compiler: GNU GCC Compiler) ===|&#xA;/home/meneses/.codeblocks/ardusim/include/util/delay.h|90|warning: #warning &quot;Compiler optimizations disabled; functions from &amp;lt;util/delay.h&amp;gt; won't work as designed&quot; [-Wcpp]|&#xA;/usr/include/x86_64-linux-gnu/sys/types.h|197|error: conflicting declaration ‘typedef long int int64_t’|&#xA;/home/meneses/.codeblocks/ardusim/arduino/cores/stdint.h|33|error: ‘int64_t’ has a previous declaration as ‘typedef long long int int64_t’|&#xA;/usr/include/unistd.h|267|error: conflicting declaration ‘typedef __intptr_t intptr_t’|&#xA;/home/meneses/.codeblocks/ardusim/arduino/cores/stdint.h|66|error: ‘intptr_t’ has a previous declaration as ‘typedef int intptr_t’|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I click on those errors I go to this following libraries:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first error - type.h, on line 197:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;__intN_t (64, __DI__);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;second error: stdint.h, on line 33:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef long long  int64_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;third error: unistd.h, on line 267:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef __intptr_t intptr_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;forth error: stdint.h, on line 66:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef int intptr_t;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And there's also the warning, on the delay.h library, line 90:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# warning &quot;Compiler optimizations disabled; functions from &amp;lt;util/delay.h&amp;gt; won't work as designed&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I've also found this error if instead of running the simulation debugger I run arduino UNO for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;library features.h, line 374, error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fatal error: sys/cdef.h: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But none of the other errors above..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line is: &lt;code&gt;#  include &amp;lt;sys/cdefs.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: solved the previous error by running this command:&#xA;sudo apt-get install libc6-dev-i386&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but now I'm running into 'uint_farptr_t' was not declared in this scope, I'll try to solve them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit3: fixed the previous item by going into code::block's settings -&gt; compiler -&gt; selected compiler -&gt; GNU GCC compiler for AVR -&gt; Search directories -&gt; Compiler -&gt; remove /usr/include&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know the consequences of this, but it fixed that error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm getting 5 errors of this type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/home/meneses/.codeblocks/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp|91|error: attempt to use poisoned &quot;SIG_USART0_RECV&quot;|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;edit4: I feel like cryinggg&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit5: I'm now willing to install other IDE, all I want is to be able to run simulations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using Linux Mint 17.3.&lt;/p&gt;&#xA;" OwnerUserId="19993" OwnerDisplayName="Diogo Meneses" LastEditorUserId="37523" LastEditDate="2019-12-04T07:53:12.713" LastActivityDate="2019-12-04T07:53:12.713" Title="Error with libraries after setting up Code::blocks to work as an arduino IDE" Tags="|c|ide|gcc|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22862" PostTypeId="2" ParentId="22859" CreationDate="2016-04-07T20:17:51.427" Score="0" Body="&lt;p&gt;If I understand correctly your goal is to receive data on your computer from an arduino connected with xbee? You could use a USB &gt; Xbee board similar to Sparkfun's Xbee USB explorer board. I am not familiar with the shield that you are using, but some xbee shields allow you to select the pins that the xbee is connected to. It sounds like yours is defaulting to Pin 0 and Pin 1, hardware serial on the Uno. If you can switch it to Pin 2 and Pin 3 (or any two digital pins) you could use software serial with the xbee, leaving hardware serial free for your USB connection. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-04-07T20:17:51.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22863" PostTypeId="2" ParentId="22680" CreationDate="2016-04-07T21:38:23.850" Score="0" Body="&lt;p&gt;A huge thanks for your detailed replies! They lead me into the very right direction. So here is what was it: As I mentioned, the situation gets worse as more time passes with the 12v jack plugged in. At the same time, the regulator was getting damn hot, I could not stick my fingers to it for more than half a second. So, I kind of did what you recommended - got a regulator and put down the voltage to 7V (with 5V the display did not want to show any text). With 7V the regulator is still getting warm, but even if I left it for 10 minutes running it's not getting hot any further further. The display - it's flickering very little and only if you look at it at a specific angle, but it's not flickering overall if you look straight at it. Interestingly, I also took a look at the schemes of the display and the fingerprint scanner and it sounds like it would not be possible for the arduino to feed these two. But, the whole project is running flawlessly (at least looks so). I just hope that math equations in regards to the mA would not cause harm to the fingerprint scanner or the arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, thanks again, for your kind and detailed replies, much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the best,&#xA;Nike&lt;/p&gt;&#xA;" OwnerUserId="19868" LastActivityDate="2016-04-07T21:38:23.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22864" PostTypeId="1" AcceptedAnswerId="22866" CreationDate="2016-04-07T21:45:31.417" Score="1" ViewCount="156" Body="&lt;p&gt;I am writing two Arduino Uno programs. One is a remote with a joystick and the other has five LED's indicating which direction the joystick is pointing. They are Bluetooth, so everything is sent and received through &lt;code&gt;Serial&lt;/code&gt;. I am sending three variables by joining them into one string, separated by colons. Then I separate them back into three variables on the other arduino The joystick, Bluetooth, and LED's part of the programs work, I'm having trouble receiving the data and separating it. I have included both programs below. As it is now, it doesn't work. In the slave code, you can change the &lt;code&gt;int xPosition = getValue(input, ':', 0).toInt();&lt;/code&gt; to &lt;code&gt;int xPosition = getValue(input2, ':', 0).toInt();&lt;/code&gt;( also change &lt;code&gt;yPosition&lt;/code&gt; and &lt;code&gt;buttonState&lt;/code&gt;) and everything works. What is the difference between that string and what I'm receiving?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Slave code:&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;#define RxD 7&#xA;#define TxD 6&#xA;SoftwareSerial BlueToothSerial(RxD,TxD);&#xA;char flag=1;&#xA;String input;&#xA;int xPosition;&#xA;int yPosition;&#xA;int buttonState;&#xA;char outstring[30];&#xA;char *input2 = &quot;510:609:1\r\n&quot;;&#xA;&#xA;void sendBlueToothCommand(char *Command)&#xA;{&#xA;  BlueToothSerial.print(Command);&#xA;  Serial.print(Command); &#xA;  delay(100);&#xA;  while(BlueToothSerial.available())&#xA;  {    &#xA;     Serial.print(char(BlueToothSerial.read())); &#xA;  }&#xA;}&#xA;&#xA;String getValue(String data, char separator, int index)&#xA;{&#xA; int found = 0;&#xA;  int strIndex[] = {0, -1  };&#xA;  int maxIndex = data.length()-1;&#xA;  for(int i=0; i&amp;lt;=maxIndex &amp;amp;&amp;amp; found&amp;lt;=index; i++){&#xA;  if(data.charAt(i)==separator || i==maxIndex){&#xA;  found++;&#xA;  strIndex[0] = strIndex[1]+1;&#xA;  strIndex[1] = (i == maxIndex) ? i+1 : i;&#xA;  }&#xA; }&#xA;  return found&amp;gt;index ? data.substring(strIndex[0], strIndex[1]) : &quot;&quot;;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;   pinMode(12, OUTPUT);&#xA;   pinMode(11, OUTPUT);&#xA;   pinMode(10, OUTPUT);&#xA;   pinMode(9, OUTPUT);&#xA;   pinMode(8, OUTPUT);&#xA;   Serial.begin(38400);     &#xA;   BlueToothSerial.begin(38400); &#xA;   delay(500);&#xA;   Serial.println(&quot;Starting...&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if(BlueToothSerial.available())&#xA;    {&#xA;      input = char(BlueToothSerial.read());&#xA;      int xPosition = getValue(input, ':', 0).toInt();&#xA;      int yPosition = getValue(input, ':', 1).toInt();&#xA;      int buttonState = getValue(input, ':', 2).toInt();&#xA;      Serial.println(&quot;xPosition&quot;);&#xA;      Serial.println(xPosition);&#xA;      Serial.println(&quot;yPosition&quot;);&#xA;      Serial.println(yPosition);&#xA;      Serial.println(&quot;buttonState&quot;);&#xA;      Serial.println(buttonState);&#xA;      if ((xPosition == 507)&amp;amp;&amp;amp;(yPosition == 506)){&#xA;        clear();&#xA;        digitalWrite(8, HIGH);&#xA;      } else if ((xPosition == 507)&amp;amp;&amp;amp;(yPosition == 0)){&#xA;        clear();&#xA;        digitalWrite(12, HIGH);&#xA;      } else if ((xPosition == 507)&amp;amp;&amp;amp;(yPosition == 1023)){&#xA;        clear();&#xA;        digitalWrite(10, HIGH);&#xA;      } else if ((xPosition == 1023)&amp;amp;&amp;amp;(yPosition == 507)){&#xA;        clear();&#xA;        digitalWrite(11, HIGH);&#xA;      } else if ((xPosition == 0)&amp;amp;&amp;amp;(yPosition == 1023)){&#xA;        clear();&#xA;        digitalWrite(9, HIGH);&#xA;      }&#xA;    }      &#xA;}&#xA;&#xA;void clear() {&#xA;  digitalWrite(12, LOW);&#xA;  digitalWrite(11, LOW);&#xA;  digitalWrite(10, LOW);&#xA;  digitalWrite(9, LOW);&#xA;  digitalWrite(8, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Master code:&lt;/h1&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;#define RxD 7&#xA;#define TxD 6&#xA;SoftwareSerial BlueToothSerial(RxD,TxD);&#xA;int xPin = A1;&#xA;int yPin = A0;&#xA;int buttonPin = 2;&#xA;char outstring[30];&#xA;int xPosition = 0;&#xA;int yPosition = 0;&#xA;int buttonState = 0;&#xA;&#xA;void sendBlueToothCommand(char *Command)&#xA;{&#xA;  BlueToothSerial.print(Command);&#xA;  Serial.print(Command); &#xA;  delay(100);&#xA;  while(BlueToothSerial.available())&#xA;  {    &#xA;     Serial.print(char(BlueToothSerial.read())); &#xA;  }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(38400);     &#xA;   BlueToothSerial.begin(38400); &#xA;   delay(500);&#xA;   pinMode(xPin, INPUT);&#xA;   pinMode(yPin, INPUT);&#xA;   pinMode(buttonPin, INPUT_PULLUP); &#xA;   BlueToothSerial.println(&quot;Hello&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  joy();&#xA;  sprintf(outstring, &quot;%d:%d:%d\r\n&quot;, xPosition, yPosition, buttonState);&#xA;  BlueToothSerial.println(outstring);&#xA;  Serial.println(outstring);&#xA;}&#xA;&#xA;void joy() {&#xA;  xPosition = analogRead(xPin);&#xA;  yPosition = analogRead(yPin);&#xA;  buttonState = digitalRead(buttonPin);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16094" LastEditorUserId="16094" LastEditDate="2016-04-07T21:56:49.383" LastActivityDate="2016-04-07T23:49:30.757" Title="Serial Data Formatting not Correct?" Tags="|serial|programming|string|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22865" PostTypeId="2" ParentId="22864" CreationDate="2016-04-07T23:06:28.080" Score="0" Body="&lt;p&gt;In the slave's &lt;code&gt;loop()&lt;/code&gt;, when you say&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;input = char(BlueToothSerial.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd expect just the first character of the serial stream to be read and stored.  Without further investigation, I don't know just what a &lt;code&gt;String&lt;/code&gt; class does when you assign a character to it, but I doubt that any of the following code ever has more than one character at a time to work on.  This will keep your &lt;code&gt;getValue()&lt;/code&gt; calls from working like you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using &lt;code&gt;String&lt;/code&gt; objects and your &lt;code&gt;getValue()&lt;/code&gt; code, consider using code like the following to handle the serial input.  The data format that this code expects is &lt;code&gt;nnnxnnnynnnb&lt;/code&gt;, where each &lt;code&gt;nnn&lt;/code&gt; is a series of digits, and x, y, b are literal characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code shortens two of the overly-verbose parts of your code by:&lt;br&gt;&#xA;• Use of an array and subscripting to replace the long list of &lt;code&gt;if&lt;/code&gt; statements that sort out the combinations of low/medium/high x and y values.&lt;br&gt;&#xA;• Use of &lt;code&gt;Streaming.h&lt;/code&gt; (which you can install by unzipping Streaming5.zip from arduiniana.org into your sketchbook/libraries directory) to clean up long lists of &lt;code&gt;Serial.println()&lt;/code&gt; statements, without increasing code size.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Streaming.h&amp;gt;&#xA;int numVal = 0;&#xA;&#xA;void doAction() {&#xA;  byte pins[] = { 9,0,0, 12,8,10, 0,11,0 };&#xA;  byte xy = 3*(x/500)+y/500;&#xA;  byte pin = pins[xy];&#xA;  if (pin) {&#xA;    clear();&#xA;    digitalWrite(pin, HIGH);&#xA;  }&#xA;  Serial &amp;lt;&amp;lt; &quot;xPosition =  &quot; &amp;lt;&amp;lt; xPosition &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;yPosition =  &quot; &amp;lt;&amp;lt; yPosition &amp;lt;&amp;lt; endl;&#xA;  Serial &amp;lt;&amp;lt; &quot;buttonState = &quot; &amp;lt;&amp;lt; buttonState &amp;lt;&amp;lt; endl;&#xA;  numVal = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;  while (BlueToothSerial.available()) {&#xA;    byte c = BlueToothSerial.read();&#xA;    if ('0' &amp;lt;= c &amp;amp;&amp;amp; '9' &amp;gt;= c) {&#xA;        numVal = 10*numVal + c - '0';&#xA;    } else {&#xA;      switch (c) {&#xA;      case 'x':  xPosition = numVal;   break;&#xA;      case 'y':  yPosition = numVal;   break;&#xA;      case 'b':  buttonState = numVal; doAction(); break;&#xA;      }&#xA;      numVal = 0;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-04-07T23:49:30.757" LastActivityDate="2016-04-07T23:49:30.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22866" PostTypeId="2" ParentId="22864" CreationDate="2016-04-07T23:10:05.093" Score="0" Body="&lt;p&gt;The problem is you are only reading one character and trying to split that single character into other smaller units. It just isn't going to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to append each character to the end of a string until you receive the end-of-line characters (&lt;code&gt;\r\n&lt;/code&gt;). Then you can split that entire string into parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can read numbers until you hit a &lt;code&gt;:&lt;/code&gt; or a &lt;code&gt;\r\n&lt;/code&gt; and build up the numbers directly without having to store anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My preferred method is the first, but I know Nick Gammon prefers the second, so I shall leave it to him to describe his favourite Finite State Machine for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To store all the data in a string I use a C string, not one of Arduino's dodgy String objects.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char input[15];&#xA;int ipos = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you read the data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (BlueToothSerial.available()) {&#xA;    char c = BlueToothSerial.read();&#xA;    if (c == '\r') continue; // Skip the carriage return&#xA;    if (c == '\n') { // We have the line ending&#xA;        // Split the data on :&#xA;        char *xtxt = strtok(input, &quot;:&quot;);&#xA;        char *ytxt = strtok(NULL, &quot;:&quot;);&#xA;        char *btxt = strtok(NULL, &quot;:&quot;);&#xA;        // Convert the text to integers&#xA;        if (xtxt) xPosition = atoi(xtxt);            &#xA;        if (ytxt) yPosition = atoi(ytxt);            &#xA;        if (btxt) buttonState = atoi(btxt);            &#xA;        ipos = 0; // Reset the string to the start&#xA;    } else {&#xA;        // If there is still room in the array&#xA;        if (ipos &amp;lt; 14) {&#xA;            // Add the incoming character&#xA;            input[ipos++] = c;&#xA;            // and terminate the string.&#xA;            input[ipos] = 0;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-07T23:10:05.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22867" PostTypeId="2" ParentId="22773" CreationDate="2016-04-07T23:59:27.500" Score="1" Body="&lt;p&gt;Well the answer is ... I fried the rest of the board when I was trying to troubleshoot it further :(  I think 12V went to the 328p, it got hot.  Oh well, thanks everyone!&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-04-07T23:59:27.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22869" PostTypeId="1" CreationDate="2016-04-08T01:34:20.317" Score="0" ViewCount="76" Body="&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/**************************************/&#xA;const int lowestPin = 1;//the lowest one attach to&#xA;const int speaker = 13;&#xA;int ts = 4;//how many beats you want&#xA;int count = 1;&#xA;const int keyPin = 11;&#xA;const int keyPinR = 10;&#xA;int buttonState = LOW;&#xA;int buttonState2 = LOW;&#xA;int bpm = 120;&#xA;int rthm = 1;&#xA;/**************************************/&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;   for(int thisPin = 1;thisPin &amp;lt;= ts;thisPin++)&#xA;   {&#xA; pinMode(thisPin,OUTPUT); //initialize thisPin as an output&#xA; pinMode(8, INPUT); &#xA;&#xA; pinMode(keyPin, INPUT);&#xA; pinMode(keyPinR, INPUT);&#xA; digitalWrite(keyPin, HIGH);&#xA; digitalWrite(keyPinR, HIGH); &#xA; }&#xA;&#xA;}&#xA;&#xA;/****************************************/&#xA;void loop()&#xA;{&#xA; buttonState = digitalRead(keyPin);&#xA; buttonState2 = digitalRead(keyPinR);&#xA; if(buttonState==LOW){&#xA; ts++; &#xA;  if(ts==6)&#xA;   {&#xA;    ts = 2;&#xA;   }&#xA;  }&#xA; if(buttonState2==LOW){&#xA;  rthm++;&#xA;    Serial.println(rthm);&#xA;  if(rthm==5)&#xA;  rthm = 1;&#xA;&#xA;  }&#xA;  for(int thisPin = 1;thisPin &amp;lt;= ts;thisPin++)&#xA;  { &#xA;&#xA;  for(int r = 1; r&amp;lt;=rthm; r++){&#xA;   bpm = pulseIn(6, HIGH);&#xA;    digitalWrite(thisPin,HIGH);&#xA;&#xA;    pinMode(13,OUTPUT); &#xA;&#xA;    if(count == 1&amp;amp;&amp;amp;r==1)&#xA;    tone(13,1500,40);&#xA;    else if(r==1)&#xA;    tone(13,1000,40);&#xA;    else&#xA;    tone(13,500,40);&#xA;    delay((bpm-52)/rthm);&#xA;&#xA;    digitalWrite(thisPin,LOW);&#xA;    pinMode(13,INPUT);&#xA;&#xA;   }&#xA;    count++;&#xA;    if(count &amp;gt;ts)&#xA;    count = 1;&#xA;    }  &#xA;&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is a metronome project. Each LED represents a beat. However, The LED for beat 1 is always on. It should turn off when it's on a different beat other than one. Is there anything wrong with the code?&lt;/p&gt;&#xA;" OwnerUserId="19210" LastEditorUserId="4131" LastEditDate="2016-04-08T08:58:25.913" LastActivityDate="2021-10-22T21:07:05.650" Title="Beat 1 LED light is always on - should turn off" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22870" PostTypeId="1" AcceptedAnswerId="22878" CreationDate="2016-04-08T03:26:44.790" Score="0" ViewCount="1236" Body="&lt;p&gt;The circuit diagram attached shows that the switch is open. Yet, the LED connected to pin 3 of the arduino board lights up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/m5HxL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/m5HxL.jpg&quot; alt=&quot;Arudino spaceship interface circuit diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand this - the circuit is open, so why should pin 3 light up?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I discussed this with one of my friends - he said that each pin on the board receives voltage after the battery is connected. If this is true, then that would answer my question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int switchState = 0;&#xA;//configures the digital pins&#xA;void setup() {&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;  pinMode(2, INPUT);&#xA;}&#xA;&#xA;//Checks the voltageo of the digital input and chooses the pin for voltage ( pin 2 )&#xA;void loop() {&#xA;  switchState = digitalRead(2);&#xA;&#xA;  if (switchState == LOW) {&#xA;    //Button is not pressed&#xA;&#xA;    digitalWrite(3, HIGH); //Green LED&#xA;    digitalWrite(4, LOW); //Red LED&#xA;    digitalWrite(5, LOW); //red LED&#xA;  }&#xA;&#xA;  else { //the button is pressed&#xA;    digitalWrite(3, LOW);&#xA;    digitalWrite(4, LOW);&#xA;    digitalWrite(5, HIGH);&#xA;&#xA;    delay(250); //wait for a quarter second&#xA;    //toggle the LEDs&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(5, LOW);&#xA;    delay(250); //wait for a quarter second&#xA;  }&#xA;} //go back to the beginning of the loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19999" LastEditorUserId="10794" LastEditDate="2016-04-09T04:24:53.717" LastActivityDate="2016-04-09T16:15:02.123" Title="Project 2: Arduino controlled spaceship interface" Tags="|arduino-uno|c++|led|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="22873" PostTypeId="1" CreationDate="2016-04-08T07:27:27.850" Score="3" ViewCount="12254" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L20SD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L20SD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am doing a project using a NEO 6M GPS with my Arduino LilyPad. I programmed it already, and it's working well except of the speed. I get stuck on fixing this. I wonder why the value is never getting zero although I am not moving to my place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need any suggestions/help that would make the speed working accurately.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA; #include &amp;lt;TinyGPS.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(4, 3); // RX, TX&#xA;TinyGPS gps;&#xA;&#xA;void gpsdump(TinyGPS &amp;amp;gps);&#xA;void printFloat(double f, int digits = 2);&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;  delay(1000);&#xA;  Serial.print(&quot;Sizeof(gpsobject) = &quot;);&#xA;  Serial.println(sizeof(TinyGPS));&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() {&#xA;  bool newdata = false;&#xA;  unsigned long start = millis();&#xA;  // Every 5 seconds we print an update&#xA;  while (millis() - start &amp;lt; 5000) {&#xA;    if (mySerial.available()) {&#xA;      char c = mySerial.read();&#xA;      if (gps.encode(c)) {&#xA;        newdata = true;&#xA;      }&#xA;    }&#xA;  }&#xA;  if (newdata) {&#xA;    Serial.println(&quot;Acquired Data&quot;);&#xA;    Serial.println(&quot;-------------&quot;);&#xA;    gpsdump(gps);&#xA;    Serial.println(&quot;-------------&quot;);&#xA;    Serial.println();&#xA;  }&#xA;}&#xA;&#xA;void gpsdump(TinyGPS &amp;amp;gps) {&#xA;  long lat, lon;&#xA;  float flat, flon;&#xA;  unsigned long age, date, time, chars;&#xA;  int year;&#xA;  byte month, day, hour, minute, second, hundredths;&#xA;  unsigned short sentences, failed;&#xA;  gps.get_position(&amp;amp;lat, &amp;amp;lon, &amp;amp;age);&#xA;  Serial.print(&quot;Lat/Long(10^-5 deg): &quot;);&#xA;  Serial.print(lat); &#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(lon); &#xA;  Serial.print(&quot; Fix age: &quot;);&#xA;  Serial.print(age);&#xA;  Serial.println(&quot;ms.&quot;);&#xA;  // On Arduino, GPS characters may be lost during lengthy Serial.print()&#xA;  // On Teensy, Serial prints to USB, which has large output buffering and&#xA;  // runs very fast, so it's not necessary to worry about missing 4800 baud GPS characters.&#xA;  gps.f_get_position(&amp;amp;flat, &amp;amp;flon, &amp;amp;age);&#xA;  Serial.print(&quot;Lat/Long(float): &quot;);&#xA;  printFloat(flat, 5); &#xA;  Serial.print(&quot;, &quot;); &#xA;  printFloat(flon, 5);&#xA;  Serial.print(&quot; Fix age: &quot;);&#xA;  Serial.print(age);&#xA;  Serial.println(&quot;ms.&quot;);&#xA;  gps.get_datetime(&amp;amp;date, &amp;amp;time, &amp;amp;age);&#xA;  Serial.print(&quot;Date(ddmmyy): &quot;); &#xA;  Serial.print(date);&#xA;  Serial.print(&quot; Time(hhmmsscc): &quot;);&#xA;  Serial.print(time);&#xA;  Serial.print(&quot; Fix age: &quot;); &#xA;  Serial.print(age); &#xA;  Serial.println(&quot;ms.&quot;);&#xA;  Serial.print(&quot;Alt(cm): &quot;); &#xA;  Serial.print(gps.altitude());&#xA;  Serial.print(&quot; Course(10^-2 deg): &quot;);&#xA;  Serial.print(gps.course()); &#xA;  Serial.print(&quot; Speed(10^-2 knots): &quot;);&#xA;  Serial.println(gps.speed());&#xA;  Serial.print(&quot;Alt(float): &quot;);&#xA;  printFloat(gps.f_altitude()); &#xA;  Serial.print(&quot; Course(float): &quot;);&#xA;  printFloat(gps.f_course()); &#xA;  Serial.println();&#xA;  Serial.print(&quot;Speed(knots): &quot;);&#xA;  printFloat(gps.f_speed_knots()); &#xA;  Serial.print(&quot; (mph): &quot;);&#xA;  printFloat(gps.f_speed_mph());&#xA;  Serial.print(&quot; (mps): &quot;); &#xA;  printFloat(gps.f_speed_mps());&#xA;  Serial.print(&quot; (kmph): &quot;);&#xA;  printFloat(gps.f_speed_kmph());&#xA;  Serial.println();&#xA;  gps.stats(&amp;amp;chars, &amp;amp;sentences, &amp;amp;failed);&#xA;  Serial.print(&quot;Stats: characters: &quot;); &#xA;  Serial.print(chars);&#xA;  Serial.print(&quot; sentences: &quot;);&#xA;  Serial.print(sentences);&#xA;  Serial.print(&quot; failed checksum: &quot;); &#xA;  Serial.println(failed);&#xA;}&#xA;&#xA;void printFloat(double number, int digits) {&#xA;  // Handle negative numbers&#xA;  if (number &amp;lt; 0.0) {&#xA;    Serial.print('-');&#xA;    number = -number;&#xA;  }&#xA;  // Round correctly so that print(1.999, 2) prints as &quot;2.00&quot;&#xA;  double rounding = 0.5;&#xA;  for (uint8_t i=0; i&amp;lt;digits; ++i)&#xA;    rounding /= 10.0;&#xA;  number += rounding;&#xA;  // Extract the integer part of the number and print it&#xA;  unsigned long int_part = (unsigned long)number;&#xA;  double remainder = number - (double)int_part;&#xA;  Serial.print(int_part);&#xA;  // Print the decimal point, but only if there are digits beyond&#xA;  if (digits &amp;gt; 0)&#xA;    Serial.print(&quot;.&quot;);&#xA;  // Extract digits from the remainder one at a time&#xA;  while (digits-- &amp;gt; 0) {&#xA;    remainder *= 10.0;&#xA;    int toPrint = int(remainder);&#xA;    Serial.print(toPrint);&#xA;    remainder -= toPrint;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE:  The altitude and longitude were already working. It's the speed that I want to fix. I want to see it as &quot;ZERO SPEED&quot; when at a steady state. How can I fix this? Please help me. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="18813" LastEditorUserId="4628" LastEditDate="2018-04-11T04:53:45.370" LastActivityDate="2018-04-11T04:53:45.370" Title="NEO 6M GPS speed" Tags="|arduino-uno|arduino-mega|gps|tinygps|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22875" PostTypeId="1" CreationDate="2016-04-08T08:17:22.293" Score="1" ViewCount="1958" Body="&lt;p&gt;I know this is probably a little bit basic but I need SERIOUS help with using my new led strip. You can see here the type of strip I have, and the packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DwCYX.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DwCYX.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/8LQdD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8LQdD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ksGON.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ksGON.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's difficult because it looks slightly different to all the other ones I've seen in tutorials so I don't really know where to start now...All I've done is cut off the ends of the wires already on there and replace them with the regular pins that I can use on the Arduino and breadboards too. Where do I have to go from here? Are there any code libraries I need to use?&lt;/p&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="18429" LastEditDate="2016-04-08T09:55:31.597" LastActivityDate="2018-06-19T11:24:29.753" Title="How to use a digital RGB LED Strip?" Tags="|led|digital|rgb-led|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22877" PostTypeId="2" ParentId="22869" CreationDate="2016-04-08T08:23:20.500" Score="1" Body="&lt;p&gt;You are using PIN1 as an output pin and you are writing data to the Serial interface.  The serial interface uses pin 1 and 0.&#xA;Change lowestPin to 2 and ts to 5 and it will work.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-08T08:23:20.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22878" PostTypeId="2" ParentId="22870" CreationDate="2016-04-08T08:31:33.810" Score="1" Body="&lt;p&gt;So everyone else knows where this is from &lt;a href=&quot;https://i.stack.imgur.com/FyQtP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;enter image description here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have edited the image you gave to attempt to answer your question on 'wiring' :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/FyQtP.jpg&quot; alt=&quot;wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/kNRw2.jpg&quot; alt=&quot;current&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first image shows simply and crudely how the parts are basically connected or there relationship. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second one shows how the current flows on the circuit, there is a key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do is take the information from the link you give in the comment and apply logic to it, like if you used a logic probe and stuck it one end of the switch, the right side in that image, it would be &lt;code&gt;high&lt;/code&gt;, if though you do so on the left it would be &lt;code&gt;low&lt;/code&gt;. Hence no current flows in that circuit but there is current flow in the circuit looking at it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What you have not examined is the code related to your project or the description of the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Create a global variable to hold the&#xA;// state of the switch. This variable is persistent&#xA;// throughout the program. Whenever you refer to&#xA;// switchState, you’re talking about the number it holds&#xA;int switchstate = 0;&#xA;&#xA;void setup() {&#xA;  // declare the LED pins as outputs&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;&#xA;  // declare the switch pin as an input&#xA;  pinMode(2, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // read the value of the switch&#xA;  // digitalRead() checks to see if there is voltage&#xA;  // on the pin or not&#xA;  switchstate = digitalRead(2);&#xA;&#xA;  // if the button is not pressed&#xA;  // turn on the green LED and off the red LEDs&#xA;  if (switchstate == LOW) {&#xA;    digitalWrite(3, HIGH); // turn the green LED on pin 3 on&#xA;    digitalWrite(4, LOW);  // turn the red LED on pin 4 off&#xA;    digitalWrite(5, LOW);  // turn the red LED on pin 5 off&#xA;  }&#xA;  // this else is part of the above if() statement.&#xA;  // if the switch is not LOW (the button is pressed)&#xA;  // turn off the green LED and blink alternatively the red LEDs&#xA;  else {&#xA;    digitalWrite(3, LOW);  // turn the green LED on pin 3 off&#xA;    digitalWrite(4, LOW);  // turn the red LED on pin 4 off&#xA;    digitalWrite(5, HIGH); // turn the red LED on pin 5 on&#xA;    // wait for a quarter second before changing the light&#xA;    delay(250);&#xA;    digitalWrite(4, HIGH); // turn the red LED on pin 4 on&#xA;    digitalWrite(5, LOW);  // turn the red LED on pin 5 off&#xA;    // wait for a quarter second before changing the light&#xA;    delay(250);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this we see that the default state of this code in the first &lt;code&gt;if()&lt;/code&gt; statement is to turn on PIN3 and leave the rest off when the button is not pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From Arduino:&lt;/p&gt;&#xA;&#xA;&lt;blockquote class=&quot;spoiler&quot;&gt;&#xA;  &lt;p&gt; A green LED will be ON, until you press a button. When the Arduino&#xA; gets a signal from the button, the green light will turn off and 2&#xA; other lights will start blinking.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2016-04-09T16:15:02.123" LastActivityDate="2016-04-09T16:15:02.123" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22879" PostTypeId="2" ParentId="22859" CreationDate="2016-04-08T08:42:43.070" Score="0" Body="&lt;p&gt;Okay, I guess I figured it all out. So right now I have the following setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 Arduino Board with Wireless Proto Shield (switch in Micro position) and XBee hooked up via DC jack pin, sends data to serial with &lt;code&gt;Serial.print(variable)&lt;/code&gt; where &lt;code&gt;variable&lt;/code&gt; is a predefined char array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 Arduino with Wireless Proto Shield (switch in Micro position) and XBee is hooked to the PC via USB and with &lt;code&gt;Serial.read()&lt;/code&gt; I'm able to read data via the Serial Monitor. No configuration required whatsoever, the only thing you need to do this is to declare &lt;code&gt;Serial.begin(9600)&lt;/code&gt; to both boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it's true that I can't use Arduino and XBee at the same time, but this still works for me to solve the problem I had.&lt;/p&gt;&#xA;" OwnerUserId="18850" LastEditorUserId="4628" LastEditDate="2017-02-03T04:02:33.140" LastActivityDate="2017-02-03T04:02:33.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22880" PostTypeId="2" ParentId="22875" CreationDate="2016-04-08T09:12:09.207" Score="1" Body="&lt;p&gt;As far as I understand the DAT (Green wire) is a digital data wire. Try the following:&#xA;1. VCC to +5V pin&#xA;2. GND to GND pin&#xA;3. DAT to 2 Digital pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then try to change the state of the 2 digital pin from high to low and see if anything happens... That's what I would start out with.&lt;/p&gt;&#xA;" OwnerUserId="18850" LastActivityDate="2016-04-08T09:12:09.207" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="22881" PostTypeId="2" ParentId="21545" CreationDate="2016-04-08T09:12:52.457" Score="1" Body="&lt;p&gt;(not enough point to comment, so here's a potential answer)&#xA;I had enormous troubles getting these things to work reliably.  I tried all kinds of caps over the power supply. In the end I went for a 1$ piggy back board that takes 5v input and regulates to 3.3V. It also has the right pin female header to fit the nfr nicely. Since then I've had no issues. I also did a bit of experimentation and found that the RX side was the side giving problems.&lt;/p&gt;&#xA;" OwnerUserId="11984" LastActivityDate="2016-04-08T09:12:52.457" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22882" PostTypeId="1" CreationDate="2016-04-08T10:14:39.053" Score="1" ViewCount="37" Body="&lt;p&gt;I just want to learn arduino and make some small projects.But in beginner starter kit there's a part named Prototyping Shield .Is it necessary or will it help me?&lt;/p&gt;&#xA;" OwnerUserId="20006" LastActivityDate="2016-04-08T10:20:37.477" Title="What is the necessity of “Prototyping Shield” for an arduino UNO R3?" Tags="|arduino-uno|shields|" AnswerCount="1" CommentCount="0" ClosedDate="2016-04-10T20:42:23.473" ContentLicense="CC BY-SA 3.0" />
  <row Id="22883" PostTypeId="1" CreationDate="2016-04-08T10:20:01.053" Score="0" ViewCount="256" Body="&lt;p&gt;I am starting to learn Arduino and wanna make some projects.which components will  I have to buy?please help me.&lt;/p&gt;&#xA;" OwnerUserId="20006" LastActivityDate="2016-04-08T11:56:07.670" Title="What are some &quot;must-have&quot; sensors or shields for an Arduino robot or motor?" Tags="|arduino-uno|sensors|motor|components|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22884" PostTypeId="2" ParentId="22882" CreationDate="2016-04-08T10:20:37.477" Score="1" Body="&lt;p&gt;The prototyping shield can be used to build your own circuits up in a more permanent form which can be plugged direct into the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can think of it as a blank canvass on which you can paint your own shield design.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-08T10:20:37.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22885" PostTypeId="1" AcceptedAnswerId="22886" CreationDate="2016-04-08T10:27:45.957" Score="2" ViewCount="2114" Body="&lt;p&gt;I am trying to figure if SDA and SCL pins from Arduino Uno is a TTL or a CMOS technology. I am not able to find this info anywhere but regarding it is a I2C protocol it does make sense to be a TTL technology. Can someone kindly confirm this info, please?&lt;/p&gt;&#xA;" OwnerUserId="19878" LastActivityDate="2016-04-08T11:46:58.463" Title="SDA/SCL pins Arduino Uno" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22886" PostTypeId="2" ParentId="22885" CreationDate="2016-04-08T10:32:00.617" Score="2" Body="&lt;p&gt;It is CMOS in that the IO pins of the MCU use MOSFETs not BJTs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I2C is slightly different in that it is open-drain not push-pull, so it's not really either TTL or CMOS since it doesn't conform to either logic level standard (since there is no &quot;high&quot; voltage, only what is pulled up by the external resistor). That said, since the ATMega is normally CMOS when in input or push-pull mode the logic levels of the I2C should conform to CMOS not TTL in order for the Arduino to read them properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's closer to RTL than TTL or CMOS.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-08T10:32:00.617" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22887" PostTypeId="2" ParentId="22885" CreationDate="2016-04-08T11:46:58.463" Score="1" Body="&lt;p&gt;Your question makes no sense. I²C uses open-drain/open-collector drivers which can even be discrete transistors or FETs although the inputs correspond to CMOS/TTL. These can be mixed - the Arduino uses MOS technology.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of more significance is the supply voltage and the high/low trigger points (and of course the value of the mandatory pullup resistors which determine speed and/or range).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible to use mixed 3.3V/5V levels. I use a Pi (3.3V) to communicate to Arduino (5V) which works (provided pullup is to 3.3V) although technically the Arduino input high levels are marginal.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-04-08T11:46:58.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22888" PostTypeId="2" ParentId="22883" CreationDate="2016-04-08T11:56:07.670" Score="2" Body="&lt;p&gt;It largely depends on your interests but since you've mentioned robotics, a motor shield, motor power supply, and one or a couple of hobby servos or DC motors will get you started on learning about controlling mechanical motion. You may be able salvage a DC motor from something else, like the vibrator motor from a dead cell phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to start inexpensively, a few LEDs and a ~200 Ohm resistor for each one, and a couple of light or temperature sensors will give you plenty to play with. It's amazing how much real-world data you can collect and infer from a couple of well placed temperature sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LM34 and LM35 are inexpensive and easy to use analog thermo-sensors that read directly in 0.01 Volts / degree (Fahrenheit and Celsius respectively), so only minimal arithmetic conversion is required (because along the way, you'll learn about Analog to Digital conversion, too).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get some experience with those simple parts, and the coding to make them useful, and you'll have a much better idea of what you want to do next and what you'll need to acquire to do it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-08T11:56:07.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22889" PostTypeId="1" CreationDate="2016-04-08T11:59:00.340" Score="2" ViewCount="263" Body="&lt;p&gt;I am making a smart bin which automatically sense (with the help of IR sensor ) and dispose the trash by moving with help of DC geared motor 12V 60 RPM and it also detects for obstacles with the help of ultrasonic sensor which is placed at the front of the bin. Once the bin is empty the motor has to spin in the reverse direction. My questions is that there is something wrong in my code and am not able to solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue that I am having is that when I run the code the bin was perfectly working as checking whether the bin is empty or not at the start and check for obstacles. If both are clear it will start move and whenever it detects any obstacles, the bin will stop the motor and checks again if any obstacles present, else it will start move and dispose the trash from the bin. The problem is when I code to reverse the motor direction to bring back the bin to original state the relay in relay board making a &lt;em&gt;trrrrr&lt;/em&gt; sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Project technical specifications:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno   &lt;/li&gt;&#xA;&lt;li&gt;60 RPM 12V DC geared motor  &lt;/li&gt;&#xA;&lt;li&gt;4 channel relay board with 2 relay active for two motors  &lt;/li&gt;&#xA;&lt;li&gt;Ultrasonic sensor  &lt;/li&gt;&#xA;&lt;li&gt;Infrared module  &lt;/li&gt;&#xA;&lt;li&gt;Plunger to open the door placed inside &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;&#xA;LiquidCrystal lcd(10, 11, 5, 4, 3, 2);&#xA;int motor_fwd = 7;&#xA;int motor_rev = 8;&#xA;int plung_rly = 6;&#xA;int irsensor = 9;&#xA;const int trigPin = 13;&#xA;const int echoPin = 12;&#xA;int mtr_time = 10;&#xA;int mtr_time_rev = 1;&#xA;&#xA;void setup()&#xA;{&#xA;    digitalWrite(motor_fwd, LOW);&#xA;    digitalWrite(motor_rev, LOW);&#xA;    digitalWrite(plung_rly, LOW);&#xA;    digitalWrite(irsensor, LOW);&#xA;&#xA;    // initialize the relay1 pin as an output;&#xA;    pinMode(motor_fwd, OUTPUT); // initialize the relay2 pin as an output;&#xA;    pinMode(motor_rev, OUTPUT); // pinMode(irsensor, INPUT);&#xA;    pinMode(plung_rly, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    irsen_chk_low();&#xA;    delay(500);&#xA;    irsen_chk_high();&#xA;    delay(500);&#xA;}&#xA;&#xA;void irsen_chk_low()&#xA;{&#xA;    if (digitalRead(irsensor) == LOW) {&#xA;        lcd.begin(16, 2);   // Print a message to the LCD.&#xA;        lcd.print(&quot;bin Empty&quot;);&#xA;        delay(500);&#xA;        digitalWrite(motor_fwd, LOW);&#xA;        if (mtr_time_rev &amp;gt;= 1) {&#xA;            mtr_time_rev = mtr_time_rev - 1;&#xA;            {&#xA;                digitalWrite(motor_rev, HIGH);&#xA;                delay(5000);&#xA;                digitalWrite(motor_rev, LOW);&#xA;                delay(5000);&#xA;                int mtr_time = 10;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;void irsen_chk_high()&#xA;{&#xA;    if (digitalRead(irsensor) == HIGH) {&#xA;        lcd.begin(16, 2);   // Print a message to the LCD;&#xA;        lcd.print(&quot;Bin is full&quot;);&#xA;        obs_detection();&#xA;        delay(500);&#xA;        digitalWrite(motor_fwd, HIGH);&#xA;    }&#xA;}&#xA;&#xA;void obs_detection()&#xA;{&#xA;    long duration, inches;&#xA;    pinMode(trigPin, OUTPUT);&#xA;    digitalWrite(trigPin, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(trigPin, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(trigPin, LOW);&#xA;&#xA;    pinMode(echoPin, INPUT);&#xA;    duration = pulseIn(echoPin, HIGH);&#xA;    inches = microsecondsToInches(duration);&#xA;    cm = microsecondsToCentimeters(duration);&#xA;    lcd.begin(16, 2);&#xA;    lcd.print(inches);&#xA;    delay(100);&#xA;    if (inches &amp;lt;= 10) {&#xA;        digitalWrite(motor_fwd, LOW);&#xA;        delay(200);&#xA;    } else {&#xA;        if (mtr_time &amp;gt;= 1) {&#xA;            mtr_time = mtr_time - 1;&#xA;            digitalWrite(motor_fwd, HIGH);&#xA;            delay(200);&#xA;        } else {&#xA;            int mtr_time = 10;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;long microsecondsToInches(long microseconds)&#xA;{&#xA;    return microseconds / 74 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19107" LastEditorUserId="6936" LastEditDate="2016-04-17T10:31:42.987" LastActivityDate="2017-05-24T06:29:36.653" Title="Problem with my Arduino project" Tags="|programming|sensors|arduino-motor-shield|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="22890" PostTypeId="1" CreationDate="2016-04-08T13:03:20.537" Score="0" ViewCount="529" Body="&lt;p&gt;I am trying to build an Arduino Flight controller. I have an MPU6050 (Gyroscope/Accelerometer) on board that is helping me configure my stabilization software. I also have my ESC's, and receiver plugged in to my Arduino. At some point during the code running, receiving and processing data from the Gyroscope and Receiver, the Arduino Uno freezes and I am not sure what is causing this problem. Any advice on how to fix this is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also getting FIFO overflows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;Servo esc1;&#xA;Servo esc2;&#xA;Servo esc3;&#xA;Servo esc4;&#xA;byte last_channel_1, last_channel_2, last_channel_3, last_channel_4, last_channel_5;&#xA;int receiver_input_channel_1, receiver_input_channel_2, receiver_input_channel_3;&#xA;int receiver_input_channel_4, receiver_input_channel_5;&#xA;unsigned long timer_1, timer_2, timer_3, timer_4, timer_5;&#xA;int reciever1, reciever2, reciever3, reciever4, reciever5;&#xA;int pastreciever1, pastreciever2, pastreciever3, pastreciever4, pastreciever5;&#xA;bool keycode;&#xA;int avg1, avg2, avg3, avg4;&#xA;int i;&#xA;const int avglen = 8;&#xA;int reciever1avg[avglen], reciever2avg[avglen], reciever3avg[avglen], reciever4avg[avglen];&#xA;int landingspeed = 1140;&#xA;int requestedspeed = 1400;&#xA;int autothrottle;&#xA;int motor1change, motor2change, motor3change, motor4change;&#xA;int yawchange, rollchange, nickchange;&#xA;int wait;&#xA;int set;&#xA;unsigned long interval=5000; // the time we need to wait&#xA;unsigned long previousMillis=0; // millis() returns an unsigned long.&#xA;unsigned long timer = 0;&#xA;&#xA;//#define printdata&#xA;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &quot;Wire.h&quot;&#xA;#endif&#xA;MPU6050 mpu;&#xA;#define OUTPUT_READABLE_YAWPITCHROLL&#xA;#define LED_PIN 13&#xA;bool blinkState = false;&#xA;bool dmpReady = false;  &#xA;uint8_t mpuIntStatus;   &#xA;uint8_t devStatus;      &#xA;uint16_t packetSize;    &#xA;uint16_t fifoCount;     &#xA;uint8_t fifoBuffer[64];&#xA;Quaternion q;         &#xA;VectorInt16 aa;       &#xA;VectorInt16 aaReal;  &#xA;VectorInt16 aaWorld;   &#xA;VectorFloat gravity;   &#xA;float euler[3];        &#xA;float ypr[3];           &#xA;uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };&#xA;volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high&#xA;void dmpDataReady() {&#xA;    mpuInterrupt = true;&#xA;}&#xA;&#xA;float initialGyroX;&#xA;float initialGyroY;&#xA;float initialGyroZ;&#xA;const int autopilotkey = 1150;&#xA;int deg_x;&#xA;int deg_y;&#xA;int deg_z;&#xA;int requiredspeed;&#xA;&#xA;void setup() &#xA;{ &#xA;  //Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs&#xA;  PCICR |=  (1 &amp;lt;&amp;lt; PCIE0);    // set PCIE0 to enable PCMSK0 scan&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT0);  // set PCINT0 (digital input 8) to trigger an interrupt on state change&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT1);  // set PCINT1 (digital input 9)to trigger an interrupt on state change&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT2);  // set PCINT2 (digital input 10)to trigger an interrupt on state change&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT3);  // set PCINT3 (digital input 11)to trigger an interrupt on state change&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT4);  // set PCINT4 (digital input 12)&#xA;&#xA;  pastreciever1 = 1058;&#xA;  pastreciever2 = 1058;&#xA;  pastreciever3 = 1058;&#xA;  pastreciever4 = 1058;&#xA;  wait=0;&#xA;  set=0;&#xA;  keycode = false;&#xA;&#xA;   esc1.writeMicroseconds(1000);&#xA;   esc2.writeMicroseconds(1000);&#xA;   esc3.writeMicroseconds(1000);&#xA;   esc4.writeMicroseconds(1000);&#xA;&#xA;   esc1.attach(9);&#xA;   esc2.attach(6);&#xA;   esc3.attach(5);&#xA;   esc4.attach(3);&#xA;&#xA;  #ifdef printdata   &#xA;  Serial.begin(115200);&#xA;  #endif&#xA;&#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;        Wire.begin();&#xA;        TWBR = 24; &#xA;    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;        Fastwire::setup(400, true);&#xA;    #endif&#xA;    mpu.initialize();&#xA;&#xA;    #ifdef printdata&#xA;    Serial.println(mpu.testConnection() ? F(&quot;MPU6050 connection successful&quot;) : F(&quot;MPU6050 connection failed&quot;));&#xA;    #endif&#xA;    devStatus = mpu.dmpInitialize();&#xA;    mpu.setXGyroOffset(220);&#xA;    mpu.setYGyroOffset(76);&#xA;    mpu.setZGyroOffset(-85);&#xA;    mpu.setXAccelOffset(-2580); &#xA;    mpu.setYAccelOffset(2567);&#xA;    mpu.setZAccelOffset(1920); &#xA;    //Serial.println(&quot;The timer has begun.&quot;);&#xA;   if (devStatus == 0) &#xA;   {&#xA;    #ifdef printdata&#xA;        Serial.println(F(&quot;Enabling DMP...&quot;));&#xA;        #endif&#xA;        mpu.setDMPEnabled(true);&#xA;        //Serial.println(F(&quot;Enabling interrupt detection (Arduino external interrupt 0)...&quot;));&#xA;        attachInterrupt(0, dmpDataReady, RISING);&#xA;        mpuIntStatus = mpu.getIntStatus();&#xA;        #ifdef printdata&#xA;        Serial.println(F(&quot;DMP ready! Waiting for first interrupt...&quot;));&#xA;        #endif&#xA;        dmpReady = true;&#xA;        packetSize = mpu.dmpGetFIFOPacketSize();&#xA;    } else {&#xA;        // ERROR!&#xA;        // 1 = initial memory load failed&#xA;        // 2 = DMP configuration updates failed&#xA;        // (if it's going to break, usually the code will be 1)&#xA;        #ifdef printdata&#xA;        Serial.print(F(&quot;DMP Initialization failed (code &quot;));&#xA;        #endif&#xA;        //Serial.print(devStatus);&#xA;        //Serial.println(F(&quot;)&quot;));&#xA;    }&#xA;}&#xA;&#xA;/*void ascend()&#xA;{&#xA;  Serial.println(&quot;Ascending.&quot;);&#xA;  for (autothrottle = landingspeed; autothrottle&amp;lt;requestedspeed; autothrottle++)&#xA;  {&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    delay(100);&#xA;    //gyro auto-level code??&#xA;    if ((avg3 != autothrottle)&amp;amp;&amp;amp;(avg3 &amp;lt; autothrottle));&#xA;    { }&#xA;    if ((avg3==requestedspeed)||(avg3&amp;gt;requestedspeed)||(avg1&amp;gt;1532)||(avg1&amp;lt;1472))&#xA;    {&#xA;      break; //go back to reciever input&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void descend()&#xA;{&#xA;  Serial.println (&quot;Descending.&quot;);&#xA;  for (autothrottle = avg3; autothrottle&amp;gt;landingspeed; autothrottle--)&#xA;  {&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    esc1.writeMicroseconds(autothrottle);&#xA;    delay(100);&#xA;    //Gyro autolevel code??&#xA;    do&#xA;    { } while ((avg3 != autothrottle)||(avg3&amp;gt;autothrottle));&#xA;    if ((avg3 == autothrottle)||(avg3&amp;lt;autothrottle)||(avg1&amp;gt;1532)||(avg1&amp;lt;1472))&#xA;    {&#xA;      break; //go back to reciever input&#xA;    }&#xA;  }&#xA;}*/&#xA;&#xA;void loop() &#xA;{  &#xA;   print_signals();&#xA;   motor1change=0;&#xA;   motor2change=0;&#xA;   motor3change=0;&#xA;   motor4change=0;&#xA;&#xA;   if (wait==0)&#xA;   {&#xA;    delay(20000);&#xA;    //XBee.write the weather&#xA;   }&#xA;   wait=1;&#xA;   if (set==6)&#xA;   {&#xA;    initialGyroX = (ypr[1] * 180/M_PI)-0.34;//X&#xA;    initialGyroY = (ypr[2] * 180/M_PI)-0.5;//Y&#xA;    initialGyroZ = ypr[0] * 180/M_PI;//Z&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;STORED:&quot;);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print (initialGyroX);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print (initialGyroY);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.println (initialGyroZ);&#xA;    #endif&#xA;    }&#xA;&#xA;    //Automatic Take-off&#xA;    /*if ((set&amp;gt;=6)&amp;amp;&amp;amp;(average3&amp;lt;1300)&amp;amp;&amp;amp;(average4&amp;lt;1300)&amp;amp;&amp;amp;(average2&amp;lt;1300)&amp;amp;&amp;amp;(average1&amp;gt;1700))&#xA;    {&#xA;      Serial.println(&quot;Ascending..&quot;);&#xA;      ascend();&#xA;    }*/&#xA;&#xA;   //Nick (Go forward/backward)------------------------------------------&#xA;   if(avg2 &amp;gt; 1532)&#xA;   {&#xA;    nickchange = (avg2 - 1532)/2;&#xA;    motor1change=motor1change+nickchange;&#xA;    motor2change=motor2change-nickchange;&#xA;    motor3change=motor3change-nickchange;&#xA;    motor4change=motor4change+nickchange;&#xA;   }&#xA;   if (avg2 &amp;lt; 1494)&#xA;   {&#xA;    nickchange = (1494-avg2)/2;&#xA;    motor1change=motor1change-nickchange;&#xA;    motor2change=motor2change+nickchange;&#xA;    motor3change=motor3change+nickchange;&#xA;    motor4change=motor4change-nickchange;&#xA;   }&#xA;   //Yaw-------------------------------------------------------------------&#xA;   if (avg1 &amp;gt; 1510)&#xA;   {&#xA;    yawchange = (avg1 - 1510)/2;&#xA;    motor1change=motor1change+yawchange;&#xA;    motor2change=motor2change-yawchange;&#xA;    motor3change=motor3change+yawchange;&#xA;    motor4change=motor4change-yawchange;&#xA;   }&#xA;   if (avg1 &amp;lt; 1470)&#xA;   {&#xA;    yawchange = (1470 - avg1)/2;&#xA;    motor1change=motor1change-yawchange;&#xA;    motor2change=motor2change+yawchange;&#xA;    motor3change=motor3change-yawchange;&#xA;    motor4change=motor4change+yawchange;&#xA;   }&#xA;   //Roll------------------------------------------------------------------&#xA;   if (avg4 &amp;gt; 1532)&#xA;   {&#xA;    rollchange = (avg4 - 1532)/2;&#xA;    motor1change=motor1change+rollchange;&#xA;    motor2change=motor2change+rollchange;&#xA;    motor3change=motor3change-rollchange;&#xA;    motor4change=motor4change-rollchange;&#xA;   }&#xA;   if (avg4 &amp;lt; 1472)&#xA;   {&#xA;    rollchange = (1472 - avg4)/2;&#xA;    motor1change=motor1change-rollchange;&#xA;    motor2change=motor2change-rollchange;&#xA;    motor3change=motor3change+rollchange;&#xA;    motor4change=motor4change+rollchange;&#xA;   }&#xA;&#xA;    if (!dmpReady) return;&#xA;    while (!mpuInterrupt &amp;amp;&amp;amp; fifoCount &amp;lt; packetSize) {&#xA;       }&#xA;    mpuInterrupt = false;&#xA;    mpuIntStatus = mpu.getIntStatus();&#xA;    fifoCount = mpu.getFIFOCount();&#xA;    if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;        mpu.resetFIFO();&#xA;        #ifdef printdata&#xA;        Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;        #endif&#xA;    } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;        while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;        mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;        fifoCount -= packetSize;&#xA;            //Print Data&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;            /*Serial.print(&quot;XYZ:\t&quot;);&#xA;            Serial.print(ypr[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(ypr[2] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(ypr[0] * 180/M_PI);*/&#xA;        //#endif&#xA;&#xA;//Stabilization----------------------------------------------------------------------------&#xA;if ((keycode==true)&amp;amp;&amp;amp;(avg3&amp;gt;autopilotkey))&#xA;{ &#xA;   //X Axis----------------------------------------------------------&#xA;  if ((ypr[1]* 180/M_PI)&amp;gt;(initialGyroX + 2))&#xA;  {&#xA;    deg_x = initialGyroX - (ypr[1] * 180/M_PI);&#xA;    requiredspeed = (-4.5*deg_x);&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;GyroX++: &quot;);&#xA;    #endif&#xA;    //Serial.println(requiredspeed);&#xA;    motor1change=motor1change+requiredspeed;&#xA;    motor2change=motor2change+requiredspeed;&#xA;    motor3change=motor3change-requiredspeed;&#xA;    motor4change=motor4change-requiredspeed;&#xA;  }&#xA;  if ((ypr[1]* 180/M_PI)&amp;lt;(initialGyroX - 2))&#xA;  {&#xA;    deg_x = initialGyroX - (ypr[1] * 180/M_PI);&#xA;    requiredspeed = (4.5*deg_x);&#xA;    #ifdef printdata&#xA;    Serial.print(&quot;GyroX--: &quot;);&#xA;    #endif&#xA;    //Serial.println (requiredspeed);&#xA;    motor1change=motor1change-requiredspeed;&#xA;    motor2change=motor2change-requiredspeed;&#xA;    motor3change=motor3change+requiredspeed;&#xA;    motor4change=motor4change+requiredspeed;&#xA;  }&#xA;  //Y Axis------------------------------------------------------------&#xA;  if ((ypr[2] * 180/M_PI)&amp;gt;(initialGyroY + 2))&#xA;  {&#xA;    deg_y = initialGyroY - (ypr[2] * 180/M_PI);&#xA;    requiredspeed = (-4.5*deg_y);&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;GyroY++: &quot;);&#xA;    #endif&#xA;    //Serial.println (requiredspeed);&#xA;    motor1change=motor1change+requiredspeed;&#xA;    motor2change=motor2change-requiredspeed;&#xA;    motor3change=motor3change-requiredspeed;&#xA;    motor4change=motor4change+requiredspeed;&#xA;  }&#xA;   if ((ypr[2] * 180/M_PI)&amp;lt;(initialGyroY - 2))&#xA;  {&#xA;    deg_y = initialGyroY - (ypr[2] * 180/M_PI);&#xA;    requiredspeed = (4.5*deg_y);&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;GyroY--: &quot;);&#xA;    #endif&#xA;    //Serial.println (requiredspeed);&#xA;    motor1change=motor1change-requiredspeed;&#xA;    motor2change=motor2change+requiredspeed;&#xA;    motor3change=motor3change+requiredspeed;&#xA;    motor4change=motor4change-requiredspeed;&#xA;  }&#xA;  //Z Axis--------------------------------------------------------------&#xA;  if ((ypr[0]* 180/M_PI)&amp;gt;(initialGyroZ + 4))//decrease&#xA;  {&#xA;    deg_z = initialGyroZ - (ypr[0] * 180/M_PI);&#xA;    requiredspeed = (-1*deg_z);&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;GyroZ++: &quot;);&#xA;    #endif&#xA;    //Serial.println (requiredspeed);&#xA;    motor1change=motor1change-requiredspeed;&#xA;    motor2change=motor2change+requiredspeed;&#xA;    motor3change=motor3change-requiredspeed;&#xA;    motor4change=motor4change+requiredspeed;&#xA;  }&#xA;  if ((ypr[0]* 180/M_PI)&amp;lt;(initialGyroZ - 4))//increase&#xA;  {&#xA;    deg_z = initialGyroZ - (ypr[0] * 180/M_PI);&#xA;    requiredspeed = (1*deg_z);&#xA;    #ifdef printdata&#xA;    Serial.print (&quot;GyroZ--: &quot;);&#xA;    #endif&#xA;    //Serial.println (requiredspeed);&#xA;    motor1change=motor1change+requiredspeed;&#xA;    motor2change=motor2change-requiredspeed;&#xA;    motor3change=motor3change+requiredspeed;&#xA;    motor4change=motor4change-requiredspeed;&#xA;  }&#xA; } &#xA;}&#xA;  motor1change=constrain(motor1change, -100, 100);&#xA;  motor2change=constrain(motor2change, -100, 100);&#xA;  motor3change=constrain(motor3change, -100, 100);&#xA;  motor4change=constrain(motor4change, -100, 100);&#xA;  #ifdef printdata&#xA;   //Elevation------------------------------------------------------------&#xA;   Serial.print (&quot;Motor Changes (1-4): &quot;);&#xA;   Serial.print (motor1change); &#xA;   Serial.print (&quot; &quot;);&#xA;   Serial.print (motor2change);&#xA;   Serial.print (&quot; &quot;);&#xA;   Serial.print (motor3change);&#xA;   Serial.print (&quot; &quot;);&#xA;   Serial.println (motor4change);&#xA;  #endif&#xA;   if (avg3&amp;gt;1150)&#xA;   {&#xA;   esc1.writeMicroseconds((avg3+7)+motor1change);&#xA;   esc2.writeMicroseconds((avg3+7)+motor2change);&#xA;   esc3.writeMicroseconds(avg3+motor3change);&#xA;   esc4.writeMicroseconds(avg3+motor4change);&#xA;   }&#xA;}&#xA;&#xA;//This routine is called every time input 8, 9, 10 or 11 changed state&#xA;ISR(PCINT0_vect){&#xA;  //Channel 1=========================================&#xA;  if(last_channel_1 == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00000001 ){         //Input 8 changed from 0 to 1&#xA;    last_channel_1 = 1;                                 //Remember current input state&#xA;    timer_1 = micros();                                 //Set timer_1 to micros()&#xA;  }&#xA;  else if(last_channel_1 == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00000001)){  //Input 8 changed from 1 to 0&#xA;    last_channel_1 = 0;                                 //Remember current input state&#xA;    receiver_input_channel_1 = micros() - timer_1;      //Channel 1 is micros() - timer_1&#xA;  }&#xA;  //Channel 2=========================================&#xA;  if(last_channel_2 == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00000100 ){         //Input 10 changed from 0 to 1&#xA;    last_channel_2 = 1;                                 //Remember current input state&#xA;    timer_2 = micros();                                 //Set timer_3 to micros()&#xA;  }&#xA;  else if(last_channel_2 == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00000100)){  //Input 10 changed from 1 to 0&#xA;    last_channel_2 = 0;                                 //Remember current input state&#xA;    receiver_input_channel_2 = micros() - timer_2;      //Channel 3 is micros() - timer_3&#xA;  }&#xA; //Channel 3=========================================&#xA;  if(last_channel_3 == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00001000 ){         //Input 11 changed from 0 to 1&#xA;    last_channel_3 = 1;                                 //Remember current input state&#xA;    timer_3 = micros();                                 //Set timer_4 to micros()&#xA;  }&#xA;  else if(last_channel_3 == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00001000)){  //Input 11 changed from 1 to 0&#xA;    last_channel_3 = 0;                                 //Remember current input state&#xA;    receiver_input_channel_3 = micros() - timer_3;      //Channel 4 is micros() - timer_4&#xA;  }&#xA;  //Channel 4=========================================&#xA;  if(last_channel_4 == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00010000 ){         //Input 12 changed from 0 to 1&#xA;    last_channel_4 = 1;                                 //Remember current input state&#xA;    timer_4 = micros();                                 //Set timer_5 to micros()&#xA;  }&#xA;  else if(last_channel_4 == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00010000)){  //Input 12 changed from 1 to 0&#xA;    last_channel_4 = 0;                                 //Remember current input state&#xA;    receiver_input_channel_4 = micros() - timer_4;      //Channel 5 is micros() - timer_5&#xA;  }&#xA;}&#xA;&#xA;//Subroutine for displaying the receiver signals&#xA;void print_signals()&#xA;{ &#xA;  //Constrain&#xA;  reciever1 = constrain(receiver_input_channel_1, 1000, 2100);&#xA;  reciever2 = constrain(receiver_input_channel_2, 1000, 2100);&#xA;  reciever3 = constrain(receiver_input_channel_3, 1000, 2100);&#xA;  reciever4 = constrain(receiver_input_channel_4, 1000, 2100);&#xA;  reciever5 = constrain(receiver_input_channel_5, 1000, 2100);  &#xA;&#xA;  set=set+1;&#xA;&#xA;  //AVG 1-4-----------------------------------------------------&#xA;  for (i=0; i&amp;lt;avglen-1; i++)&#xA;  {&#xA;    reciever1avg[i]=reciever1avg[i+1];&#xA;  }&#xA;  reciever1avg[avglen-1]=reciever1;&#xA;  avg1=0;&#xA;  for (i=0; i&amp;lt;avglen; i++)&#xA;  {&#xA;    avg1+= reciever1avg[i];&#xA;  } avg1/=avglen;&#xA;&#xA;  for (i=0; i&amp;lt;avglen-1; i++)&#xA;  {&#xA;    reciever2avg[i]=reciever2avg[i+1];&#xA;  }&#xA;  reciever2avg[avglen-1]=reciever2;&#xA;  avg2=0;&#xA;  for (i=0; i&amp;lt;avglen; i++)&#xA;  {&#xA;    avg2+= reciever2avg[i];&#xA;  } avg2/=avglen;&#xA;&#xA;  for (i=0; i&amp;lt;avglen-1; i++)&#xA;  {&#xA;    reciever3avg[i]=reciever3avg[i+1];&#xA;  }&#xA;  reciever3avg[avglen-1]=reciever3;&#xA;  avg3=0;&#xA;  for (i=0; i&amp;lt;avglen; i++)&#xA;  {&#xA;    avg3+= reciever3avg[i];&#xA;  } avg3/=avglen;&#xA;&#xA;  for (i=0; i&amp;lt;avglen-1; i++)&#xA;  {&#xA;    reciever4avg[i]=reciever4avg[i+1];&#xA;  }&#xA;  reciever4avg[avglen-1]=reciever4;&#xA;  avg4=0;&#xA;  for (i=0; i&amp;lt;avglen; i++)&#xA;  {&#xA;    avg4+= reciever4avg[i];&#xA;  } avg4/=avglen;&#xA;&#xA;  //Activate Autopilot&#xA;  if ((avg1==pastreciever1)&amp;amp;&amp;amp;(avg2==pastreciever2)&#xA;    &amp;amp;&amp;amp;(avg3==pastreciever3)&amp;amp;&amp;amp;(avg4==pastreciever4)&amp;amp;&amp;amp;(avg3&amp;gt;autopilotkey))&#xA;  {&#xA;    keycode=true;&#xA;&#xA;  } else {keycode=false;}&#xA;&#xA;  pastreciever1 = avg1;&#xA;  pastreciever2 = avg2;&#xA;  pastreciever3 = avg3;&#xA;  pastreciever4 = avg4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20011" LastEditorUserId="20011" LastEditDate="2016-04-08T14:48:35.773" LastActivityDate="2016-05-10T09:11:13.660" Title="arduino quadcopter freezing while reading MPU6050/RC Receiver" Tags="|arduino-uno|mpu6050|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22891" PostTypeId="1" CreationDate="2016-04-08T13:22:44.607" Score="-1" ViewCount="1273" Body="&lt;p&gt;The pins are so small I dont know which pin needs to go to the which pin socket and if t's compatible or not. I have the selfie camera of Xperia Z phone and a Arduino Uno r3.&lt;/p&gt;&#xA;" OwnerUserId="20012" LastEditorUserId="19515" LastEditDate="2016-04-08T17:46:01.437" LastActivityDate="2016-05-08T18:36:31.257" Title="How can I use my old cellphones camera on my arduino robot?" Tags="|sensors|pins|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22892" PostTypeId="2" ParentId="22891" CreationDate="2016-04-08T13:51:11.917" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can i use my old cellphones camera on my arduino robot?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No! Even if you got all the details on the camera there are too many limitations with the Arduino for any serious application. You will need more memory and processing power. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-04-08T13:51:11.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22893" PostTypeId="5" CreationDate="2016-04-08T13:58:18.057" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Http&quot; rel=&quot;nofollow&quot;&gt;Hypertext Transfer Protocol (HTTP)&lt;/a&gt; uses a client-request/server-response model. HTTP is a stateless protocol, which means it does not require the server to retain information or status about each user for the duration of multiple requests.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-10T20:39:52.663" LastActivityDate="2016-04-10T20:39:52.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22894" PostTypeId="4" CreationDate="2016-04-08T13:58:18.057" Score="0" Body="Hypertext Transfer Protocol (HTTP) is an application level network protocol that is used for the transfer of content on the World Wide Web." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-18T18:53:22.743" LastActivityDate="2016-04-18T18:53:22.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22895" PostTypeId="2" ParentId="22891" CreationDate="2016-04-08T14:04:40.990" Score="2" Body="&lt;p&gt;Camera modules usually talk a protocol called CSI-2 or CSI-3. That's the Camera Serial Interface protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It transfers very large amounts of data very fast. More data than a little Arduino can cope with.  For instance, a current typical mobile phone camera is measured in multiples of megapixels. Each pixel takes 3 bytes to represent at 24-bit, so say you have a 2 megapixel camera that would be in excess of 6 megabytes of data per image.  To put that into perspective the Arduino Uno has 2kB of RAM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no there is no way you will be able to directly interface a mobile phone camera to any of the microcontroller based Arduinos. That's not to say that something might not be able to be hacked on to one of the new-fangled things they try and pass off as Arduinos these days but are actually some strange SoC made by Intel. You're very much on your own with those though...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are camera modules available aimed at the Arduino, but they are not directly readable by the Arduino due to lack of memory. They do, though, generally have a UART interface for controlling the camera, and then a separate streaming interface (often with a FIFO buffer to access the data slowly) for grabbing a snapped picture. The Arduino can't really do much with that data other than save it to an SD card or pass it on to a computer through USB, so they're pretty pointless really.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-08T14:04:40.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22896" PostTypeId="1" CreationDate="2016-04-08T06:51:26.483" Score="0" ViewCount="140" Body="&lt;p&gt;I just want to learn Arduino and make some  small projects. But in  the beginner starter kit there's  a part named Prototyping Shield. Is it necessary or will it help me?&lt;/p&gt;&#xA;" OwnerUserId="20006" OwnerDisplayName="Fazla Rabbi Mashrur" LastEditorUserId="27346" LastEditDate="2018-11-08T14:21:34.107" LastActivityDate="2018-11-08T19:39:16.193" Title="What is the necessity of &quot;Prototyping Shield&quot; for an arduino UNO R3?" Tags="|arduino-uno|shields|prototype|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="22897" PostTypeId="2" ParentId="22896" CreationDate="2016-04-08T08:30:45.893" Score="1" Body="&lt;p&gt;A prototyping shield allows you to create your own circuit that can sit neatly on top of an Arduino.  Its main advantage is the pins/holes to connect to the Arduino, as these aren't evenly spaced so they are difficult to replicate with strip-board.&#xA;Do you need one? I doubt it very much, stick to the bread board and leave the soldering iron alone until you know what you are doing. &lt;/p&gt;&#xA;" OwnerUserId="10394" OwnerDisplayName="Matt" LastEditorUserId="10394" LastEditDate="2016-04-08T18:20:12.480" LastActivityDate="2016-04-08T18:20:12.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22898" PostTypeId="1" CreationDate="2016-04-08T15:13:04.147" Score="10" ViewCount="3444" Body="&lt;p&gt;How to proceed, when in need of a custom I2C master-slave system?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the design criteria to apply?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the debugging tools one can use to troubleshoot problems?&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-21T20:30:40.893" Title="How to design and debug a custom I2C master-slave system?" Tags="|motor|i2c|rotary-encoder|drone|debug|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22899" PostTypeId="2" ParentId="22898" CreationDate="2016-04-08T15:13:04.147" Score="11" Body="&lt;p&gt;This tutorial I gave at the Embedded Linux Conference tries to answer the questions, providing links to more detailed description of the topics addressed and using the practical example of driving a 4WD drone, where an Arduino Mini Pro acts as slave and controls the 4 independent wheels.&#xA;The original document can be found &lt;a href=&quot;http://events.linuxfoundation.org/sites/events/files/slides/ELC%202016%20-%20I2C%20hacking%20demystified.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This answer is currently work in progress, as I adapt the highlights from the link.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Typical Applications of the I2C bus&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Interfacing with relatively slow peripherals. Ex: sensors, mechanical actuators.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Controlling “fast” peripherals, that use other channels for exchanging data. Ex: codecs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a PC, the Operating System usually interacts over I2C with:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;temperature and battery voltage meters;&lt;/li&gt;&#xA;&lt;li&gt;fan speed controllers;&lt;/li&gt;&#xA;&lt;li&gt;audio codecs.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In case multiple bus controllers are available, peripherals are grouped by speed, so that fast ones are not penalized by slower ones.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;A quick introduction to the I2C bus - key features&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Serial bus.  &lt;/li&gt;&#xA;&lt;li&gt;Only 2 lines: Serial CLock and Serial DAta (plus ground).&lt;/li&gt;&#xA;&lt;li&gt;4 speeds: 100kHz, 400kHz, 1MHz, 3.2MHz.&lt;/li&gt;&#xA;&lt;li&gt;Typically, 1 master device and 1 or more slaves.&lt;/li&gt;&#xA;&lt;li&gt;Communications are always initiated by a master device.&lt;/li&gt;&#xA;&lt;li&gt;Multiple masters can co-exist on the same bus (multi-master).&lt;/li&gt;&#xA;&lt;li&gt;Open-Drain: both SDA and SCL need pull-up resistors.&lt;/li&gt;&#xA;&lt;li&gt;“Clock Stretching”&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The master controls SCL, but a slave can hold it down (because open drain), if it needs to adjust the speed.&lt;/li&gt;&#xA;&lt;li&gt;The master must check for this scenario.&lt;/li&gt;&#xA;&lt;li&gt;A slave can get stuck and jam the bus: need for reset lines from the master to the slave.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Typically 7-bit addressing, but also 10 bit is supported.&lt;/li&gt;&#xA;&lt;li&gt;Logical protocol: actual voltage levels are not specified and depend on individual implementations. Ex: 1.8V / 3.3V / 5.0V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Reference URLs: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.i2c-bus.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.i2c-bus.org&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.robot-electronics.co.uk/i2c-tutorial&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.robot-electronics.co.uk/i2c-tutorial&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Example of Bus Configuration&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DGm1u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DGm1u.png&quot; alt=&quot;Example of Bus Configuration&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Characteristics of the Protocol (simplified)&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;2 message types: &lt;em&gt;read&lt;/em&gt; and &lt;em&gt;write&lt;/em&gt;&lt;/li&gt;&#xA;&lt;li&gt;Start / Stop bit - represented as “[“ and “]” in the rest of the answer&lt;/li&gt;&#xA;&lt;li&gt;Address: 7 or 10 bits&lt;/li&gt;&#xA;&lt;li&gt;R/W bit: R = 1 / W = 0 Used to discriminate the type of message sent.&lt;/li&gt;&#xA;&lt;li&gt;Data on the bus: (Address &amp;lt;&amp;lt; 1 | R/W)&lt;/li&gt;&#xA;&lt;li&gt;Registers as information handlers, within the selected device.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h1&gt;Example of Bus traffic&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/X10rA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/X10rA.png&quot; alt=&quot;Example of Bus Traffic&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/U16Rg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U16Rg.png&quot; alt=&quot;Example of Bus Write Cycle&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/90Myv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/90Myv.png&quot; alt=&quot;Example of Bus Read Cycle Part1&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QZiUT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QZiUT.png&quot; alt=&quot;Example of Bus Read Cycle Part2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Custom Slaves&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Why create a custom I2C slave?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Desired sensor/actuator unavailable with I2C interface.&lt;/li&gt;&#xA;&lt;li&gt;Less unique addresses available than slaves needed.&lt;/li&gt;&#xA;&lt;li&gt;Desired custom functionality on the slave:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Semi-autonomous reactions to stimuli.&lt;/li&gt;&#xA;&lt;li&gt;Filtering/preprocessing input data.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Power optimization: custom “sensor hub” does the housekeeping while the main processor is idle.&lt;/li&gt;&#xA;&lt;li&gt;Realtime response to inputs.&lt;/li&gt;&#xA;&lt;li&gt;[your imagination here]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;How to design a custom I2C slave?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define requirements (see previous slide).&lt;/li&gt;&#xA;&lt;li&gt;Choose microcontroller or microprocessor.&lt;/li&gt;&#xA;&lt;li&gt;Choose Scheduler or Operating System (if any).&lt;/li&gt;&#xA;&lt;li&gt;Define communication sub-protocol:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Define parameters and commands to be exchanged.&lt;/li&gt;&#xA;&lt;li&gt;Organize them into “registers” and choose a free address.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Design of the I2C Master&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Key design criteria:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Weight/Dimensions.&lt;/li&gt;&#xA;&lt;li&gt;Required computational power and average latency.&lt;/li&gt;&#xA;&lt;li&gt;PC-like device&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Embedded device, typically headless.&lt;/li&gt;&#xA;&lt;li&gt;Preferred programming language: interpreted vs compiled.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Availability of busses/gpios for driving the slave(s):&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GPIOs only: bitbang the protocol&lt;/li&gt;&#xA;&lt;li&gt;I2C: user-space application vs kernel driver.&lt;/li&gt;&#xA;&lt;li&gt;No GPIOs/I2C interfaces available: USB to I2C adapter.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Debugging: Divide and Conquer&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Take direct control of the bus with an ad-hoc device. &#xA;Examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bus Pirate (useful also for other busses)&lt;/li&gt;&#xA;&lt;li&gt;USB to I2C Master adapter, also based on the FTDI FT232R chip.&lt;/li&gt;&#xA;&lt;li&gt;Custom device (could be a separate project).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Snoop the bus with a logic analyzer or a scope/advanced meter.&#xA;Examples:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;sigrok/pulseview with compatible logic analyzer&lt;/li&gt;&#xA;&lt;li&gt;2-channels standalone scope/meter&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use slave-specific In Circuit Debugger/In Circuit Emulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;AVR Dragon for AVR chips (Arduino UNO, Nano, Mini, MiniPro)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;BUS Pirate&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lcwyU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lcwyU.jpg&quot; alt=&quot;Bus Pirate&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Primarily for development purposes.&lt;/li&gt;&#xA;&lt;li&gt;Can both sniff the bus and drive it.&lt;/li&gt;&#xA;&lt;li&gt;Console interface over serial (ttyACM) port, including macros, or programmatic access for several programming languages.&lt;/li&gt;&#xA;&lt;li&gt;Built-in pullup resistors and voltage sources (5V / 3.3V)&lt;/li&gt;&#xA;&lt;li&gt;Supports many other protocols.&lt;/li&gt;&#xA;&lt;li&gt;References: &lt;a href=&quot;https://en.wikipedia.org/wiki/Bus_Pirate&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;, &lt;a href=&quot;http://dangerousprototypes.com/docs/Bus_Pirate&quot; rel=&quot;nofollow noreferrer&quot;&gt;main page&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;USB to I2C Adapter&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BpCww.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BpCww.jpg&quot; alt=&quot;usbtoi2c&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Small footprint.&lt;/li&gt;&#xA;&lt;li&gt;Suitable for permanent installations.&lt;/li&gt;&#xA;&lt;li&gt;No need for special connections on the host: it can be used to interface with a typical PC.&lt;/li&gt;&#xA;&lt;li&gt;Variant available that is also SPI-capable.&lt;/li&gt;&#xA;&lt;li&gt;No console interface, only serial binary protocol.&lt;/li&gt;&#xA;&lt;li&gt;Requires &lt;a href=&quot;https://arduino.stackexchange.com/questions/22069/how-to-operate-under-linux-an-usb-to-i2c-adapter-based-on-the-ftdi-ft232r&quot;&gt;protocol wrapper&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Reference: &lt;a href=&quot;http://www.robot-electronics.co.uk/htm/usb_i2c_tech.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;protocol&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;sigrok and pulseview&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;sigrok(bakend component) logo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TaJQVm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TaJQVm.jpg&quot; alt=&quot;sigrok&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;pulseview (visualizer) example&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LpBQ0m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LpBQ0m.png&quot; alt=&quot;pulseview&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of low end logic Analyzer&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Hged9m.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Hged9m.jpg&quot; alt=&quot;saleae&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;De-facto standard for PC-driven measurements on linux (but available on other OSes too).&lt;/li&gt;&#xA;&lt;li&gt;Support for vast range of logic analyzers, scopes and meters.&lt;/li&gt;&#xA;&lt;li&gt;Various protocol decoders, including I2C.&lt;/li&gt;&#xA;&lt;li&gt;Useful for visualizing the logical signals and debugging protocol errors.&lt;/li&gt;&#xA;&lt;li&gt;Even very low end, inexpensive HW can provide a whole new dimension to debugging.&lt;/li&gt;&#xA;&lt;li&gt;References: &lt;a href=&quot;https://sigrok.org&quot; rel=&quot;nofollow noreferrer&quot;&gt;sigrok&lt;/a&gt;, &lt;a href=&quot;https://sigrok.org/wiki/PulseView&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulseview&lt;/a&gt;, &lt;a href=&quot;https://sigrok.org/wiki/Supported_hardware&quot; rel=&quot;nofollow noreferrer&quot;&gt;supported hardware&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Example: steering a 4WD drone&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Prototype built using 2 Arduino Mini Pro.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ptWAZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ptWAZ.jpg&quot; alt=&quot;Drone&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;What does the slave do in the example?&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The I2C slave:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Controls the amount of torque applied to each wheel.&lt;/li&gt;&#xA;&lt;li&gt;Controls the direction each wheel spins.&lt;/li&gt;&#xA;&lt;li&gt;Measures  the rotation speed of each wheel through an optical encoder (Odometer).&lt;/li&gt;&#xA;&lt;li&gt;Exposes the parameters above to the I2C Master.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3HfLd.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3HfLd.jpg&quot; alt=&quot;Slave Role&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;High level block diagram of the I2C Slave.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Selecting the Slave: &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardProMini&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Mini Pro&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7bSx8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7bSx8.jpg&quot; alt=&quot;MiniPro&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Enough pins/functions to provide for each wheel:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 PWM output with independent configuration of the duty-cycle.&lt;/li&gt;&#xA;&lt;li&gt;1 GPIO for registering odometer input as IRQ.&lt;/li&gt;&#xA;&lt;li&gt;2 GPIOs for selecting:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Forward&lt;/li&gt;&#xA;&lt;li&gt;Reverse&lt;/li&gt;&#xA;&lt;li&gt;Idle&lt;/li&gt;&#xA;&lt;li&gt;Lock&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;I2C HW block for interrupt-driven i2c exchanges.&lt;/li&gt;&#xA;&lt;li&gt;Dedicated pins for SPI-based programming.&lt;/li&gt;&#xA;&lt;li&gt;Small footprint.&lt;/li&gt;&#xA;&lt;li&gt;Low Cost.&lt;/li&gt;&#xA;&lt;li&gt;The board layout of the clone represented in the picture is optimized for mounting on a DIL socket.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Slave-specific ICD: &lt;a href=&quot;http://www.atmel.com/webdoc/avrdragon/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR Dragon&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WxABh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WxABh.jpg&quot; alt=&quot;AVR Dragon&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Supports various programming modes, included SPI programming, through &lt;a href=&quot;http://www.nongnu.org/avrdude/&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVRDude&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Doesn’t interfere with normal AVR operations, so it can be left plugged into the system.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.larsen-b.com/Article/315.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;After enabling debugWire interface, it allows configuring HW/SW breakpoints, by a dedicated backend for gdb/ddd.&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Selecting the OS: &lt;a href=&quot;http://www.chibios.org/dokuwiki/doku.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;ChibiOS&lt;/a&gt;&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kzbau.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kzbau.jpg&quot; alt=&quot;ChibiOS&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RTOS: preemption, tasks, semaphores, dynamic system tic, etc.&lt;/li&gt;&#xA;&lt;li&gt;Small footprint: link only used code/data.&lt;/li&gt;&#xA;&lt;li&gt;Distinction between RTOS and BSP through HAL.&lt;/li&gt;&#xA;&lt;li&gt;GPLv3 for non-commercial use.&lt;/li&gt;&#xA;&lt;li&gt;Actively developed, but already mature.&lt;/li&gt;&#xA;&lt;li&gt;Supports 8bit AVR.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;However it had limited BSP support for AVR, lack of:&#xA; - interrupts driver for AVR GPIOs (added).&#xA; - I2C support for AVR slave mode (custom).&#xA;Which had to be developed separately as part of the &lt;a href=&quot;https://github.com/igor-stoppa/ChibiOS/tree/car/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Drone SW for the AVR&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Defining the Communication Parameters&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;For each wheel:&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Duty Cycle&lt;/strong&gt; of the PWM signal used to drive it - 1 byte.&#xA;0xFF = max torque / 0x00 = no torque.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Direction&lt;/strong&gt; of rotation - 1 byte.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0x00 = idle&lt;/li&gt;&#xA;&lt;li&gt;0x01 = reverse&lt;/li&gt;&#xA;&lt;li&gt;0x02 = forward&lt;/li&gt;&#xA;&lt;li&gt;0x03 = locked&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Average period&lt;/strong&gt; in between slots of the optical encoder - 2 bytes.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Writing anything resets the measurement.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Parameter Index&lt;/strong&gt; - 1 nibble:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0 = Duty Cycle&lt;/li&gt;&#xA;&lt;li&gt;1 = Direction&lt;/li&gt;&#xA;&lt;li&gt;2 = Average Period&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Wheel indexes&lt;/strong&gt; - 1 nibble:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;0 = Left Rear&lt;/li&gt;&#xA;&lt;li&gt;1 = Right Rear&lt;/li&gt;&#xA;&lt;li&gt;2 = Right Front&lt;/li&gt;&#xA;&lt;li&gt;3 = Left Front&lt;/li&gt;&#xA;&lt;li&gt;4 = All&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Sub Protocol: Defining the Registers&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Register format:   0xαβ&lt;/strong&gt;&#xA; - α = Parameter Index&#xA; - β = Wheel Index&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Address&lt;/strong&gt; (chosen arbitrarily): 0x10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Bus Pirate format:&lt;/strong&gt;&#xA; - [ = start bit&#xA; - ] = end bit&#xA; - r = read byte&#xA; - address times 2 (left shift 1), for R/W bit&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Example - in Bus Pirate Format&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;[   i2c_addr   reg_addr=(parm,wheel)   reg_value  ]&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[0x20 0x20 0x02]  Left Rear Forward&#xA;[0x20 0x21 0x01]  Right Rear Backward&#xA;[0x20 0x22 0x01]  Right Front Backward&#xA;[0x20 0x23 0x02]  Left Front Forward&#xA;[0x20 0x14 0xFF]  Wheels set to max torque&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The car spins clockwise.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-04-21T20:30:40.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22900" PostTypeId="1" AcceptedAnswerId="22902" CreationDate="2016-04-08T19:12:31.257" Score="2" ViewCount="247" Body="&lt;p&gt;I'm working on an Arduino program but am getting bogged down on what is the 'correct' implementation. I understand that multiple versions may work, so for my needs the 'correct' version will be the fastest (i.e. executing in the fewest clock cycles)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to set three analog input pins on my Mega 2560 - let's call them PF2-0.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I could use pinMode() - but that performs some extra checks that I want to leave out.&lt;/li&gt;&#xA;&lt;li&gt;I could use _BV() in the process, but that's another function call I wish to avoid.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So, using port manipulation, I can write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRF = 0x07; //PF2, PF1, PF0 as input&#xA;PORTF = 0x07; // Disable pullups&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should configure my three pins as inputs - and reduce any extraneous function calls. This should even be faster than writing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRF = (1 &amp;lt;&amp;lt; PF2) | (1 &amp;lt;&amp;lt; PF1) | (1 &amp;lt;&amp;lt; PF0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this the fastest implementation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*To be honest, I'm not sure how to profile this to know for sure.&lt;/p&gt;&#xA;" OwnerUserId="7317" LastActivityDate="2016-04-08T19:52:22.083" Title="Port Manipulation - fastest implementation" Tags="|code-optimization|input|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22901" PostTypeId="2" ParentId="22900" CreationDate="2016-04-08T19:19:34.350" Score="0" Body="&lt;p&gt;AFAIK the compiler should be smart enough to use bit manipulation instructions when in presence of _BV().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When unsure, you can always add -save-temps to the gcc options, to see what the compiler actually does. It will not give you profiling information, but you can see in detail how your C gets turned into assembly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remember to pay attention to what level of optimization you use. You should use the same that will be employed in the final version of your code (probably O2).&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-08T19:19:34.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22902" PostTypeId="2" ParentId="22900" CreationDate="2016-04-08T19:34:16.403" Score="3" Body="&lt;p&gt;The standard Arduino way of doing this is to use &lt;code&gt;pinMode()&lt;/code&gt;. It's not&#xA;fast, but it's easy to understand, especially for beginners. And it's&#xA;portable across architectures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to go fast, then you should skip the Arduino functions and&#xA;use port manipulation, and avr-libc. The standard avr-libc way of doing&#xA;what you want is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;DDRF = _BV(PF2)   // set PF2 as output&#xA;     | _BV(PF1)   // also PF1&#xA;     | _BV(PF0);  // and PF0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This compiles to two assembly instructions: one for loading a CPU&#xA;register with the constant, and the other to copy the register to the&#xA;DDRF IO port. Notice that you set the bits for the pins you want to set&#xA;as &lt;em&gt;outputs&lt;/em&gt;, and you clear the bits for the inputs. By default, all the&#xA;pins start as inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;_BV()&lt;/code&gt; here is not a function call: it's a macro that expands to&#xA;&lt;code&gt;(1 &amp;lt;&amp;lt; (x))&lt;/code&gt;. The way you write the expression to the right of the &lt;code&gt;=&lt;/code&gt;&#xA;sign is irrelevant as long as it is recognised to be a compile-time&#xA;constant. If you want to see for yourself, you can disassemble the&#xA;generated binary with the command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-objdump -S -C my_prog.elf &amp;gt; my_prog.lst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You get an assembly listing interspersed with your source. Doing this on&#xA;the example above yields:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    DDRF = _BV(PF2)   // set PF2 as output&#xA;         | _BV(PF1)   // also PF1&#xA;         | _BV(PF0);  // and PF0&#xA;100:    87 e0           ldi r24, 0x07   ; 7&#xA;102:    80 bb           out 0x10, r24   ; 16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the &lt;code&gt;ldi&lt;/code&gt; instruction means “load immediate”, i.e. load a register&#xA;(r24) with a constant value (0x07). The “out” instruction copies that&#xA;register into port 0x10 (namely DDRF). Both are single cycle&#xA;instructions, so the whole sequence takes two CPU cycles.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-08T19:52:22.083" LastActivityDate="2016-04-08T19:52:22.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22903" PostTypeId="1" AcceptedAnswerId="22938" CreationDate="2016-04-08T20:55:48.203" Score="0" ViewCount="531" Body="&lt;p&gt;It might be a stupid question but, I am currently using Arduino Uno with the 16MHz processor, what is maximum sampling rate of data available to me if I want to read data of a sensors such as accelerometer?&lt;/p&gt;&#xA;" OwnerUserId="20023" LastEditorUserId="19515" LastEditDate="2016-04-08T23:28:09.147" LastActivityDate="2016-04-09T22:54:56.547" Title="Sampling Rate of Arduino Uno" Tags="|arduino-uno|analog-sampling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22904" PostTypeId="1" CreationDate="2016-04-08T21:06:44.847" Score="0" ViewCount="6143" Body="&lt;p&gt;I just bought an Arduino Nano v3.0 (compatible? +- 5$) and I cannot connect it to my computer (Windows 8.1 64bit, Arduino IDE 1.6.8 installed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino was bought as a clone but shows GRAVITECH.US on the front.&#xA;It has a FTDI FT232RL chip (1412-G B8908572) on the back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When connecting the Arduino the power leds burns the TX and RX led flash a few times (really shortly) and then die. Then the yellow L leds blinks once per second continiously.(power to the Arduino comes from the USB cable, not from external power)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the system tray I get a message saying &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;The last USB device you connected to this computer malfunctioned, &#xA;and Windows does not recognize it.&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the device manager I get a node under Universal Serial Bus Controllers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Unknown USB Device (Device Descriptor Request Failed).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When examining the properties of the device, the device-status is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Windows has stopped this device because it has reported problems. (Code 43)&#xA;A request for the USB device descriptor failed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I tried to reset the device &lt;/li&gt;&#xA;&lt;li&gt;I tried different USB cables&lt;/li&gt;&#xA;&lt;li&gt;I used another Windows 8.1 PC without Arduino IDE installed&lt;/li&gt;&#xA;&lt;li&gt;I used an old XP computer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All give same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about the bricking of clones by the recent FTDI drivers...&#xA;I downloaded the FT_Prog tool V3.0.60 to check the PID, but the tool simply does not find the Arduino...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm out of ideas... does anyone have some left?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Michiel&lt;/p&gt;&#xA;" OwnerUserId="19910" LastActivityDate="2016-05-10T14:07:29.933" Title="Arduino Nano - Unknown USB device" Tags="|arduino-nano|usb|windows|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22906" PostTypeId="2" ParentId="22904" CreationDate="2016-04-08T21:40:25.017" Score="2" Body="&lt;p&gt;I found the issue!&#xA;There is a bug in the Arduino hardware:&#xA;&lt;a href=&quot;https://ketturi.kapsi.fi/2014/04/how-to-fix-moody-arduino-nano/&quot; rel=&quot;nofollow&quot;&gt;https://ketturi.kapsi.fi/2014/04/how-to-fix-moody-arduino-nano/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to bridge pins 25 and 26 of the FTDI chip (located at the back of the Arduino) to ground the pin 26 TEST signal.&#xA;If I connect these pins then it works just fine!&lt;/p&gt;&#xA;" OwnerUserId="19910" LastEditorUserId="19910" LastEditDate="2016-05-09T06:07:43.060" LastActivityDate="2016-05-09T06:07:43.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22907" PostTypeId="1" CreationDate="2016-04-08T21:58:20.537" Score="0" ViewCount="399" Body="&lt;p&gt;I am very new to this site and this question may not be strictly related to Arduino, but I do small Arduino project which needs to measure the temperature of the copper coil using TMP36GZ sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to glue it to the coil for best measurements?&#xA;Shoul I use silikone or epoxy? &#xA;Should I take extra steps to ensure proper readings from the coil surface (f.ex.: using thermal paste)?&lt;/p&gt;&#xA;" OwnerUserId="20025" LastActivityDate="2016-04-11T17:55:21.353" Title="What is the best way to attach TMP36 sensor to the copper coil?" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22908" PostTypeId="2" ParentId="22907" CreationDate="2016-04-08T22:41:51.733" Score="1" Body="&lt;p&gt;If you don't have to worry about conductivity from the electrical standpoint, you could use a thermal epoxy such as &lt;a href=&quot;http://www.arcticsilver.com/arctic_silver_thermal_adhesive.htm&quot; rel=&quot;nofollow&quot;&gt;Arctic Silver&lt;/a&gt; which uses &quot;microfine&quot; particles of silver to conduct heat. It's a two part (redundant when using the term epoxy, I think) adhesive that is engineered to transfer heat, but may also short conductors. I've used the stuff and unless subject to intentional separating force, it holds well.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-04-08T22:41:51.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22909" PostTypeId="2" ParentId="22873" CreationDate="2016-04-08T23:01:46.483" Score="1" Body="&lt;p&gt;Usually, this should be solved by just going outside to get the first fix point. If you still don't manage it, try the U-center software to make sure your GPS is properly working.&lt;/p&gt;&#xA;" OwnerUserId="11102" LastActivityDate="2016-04-08T23:01:46.483" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22910" PostTypeId="2" ParentId="22907" CreationDate="2016-04-09T00:22:55.827" Score="0" Body="&lt;p&gt;The datasheet devotes a whole page to mounting and thermal conductivity (though not to specific adhesives), particularly with respect to the plastic, through-hole devices, as the leads provide more a direct conductivity path to the sensing junction than the plastic bead does. If the surrounding air is at a different temperature from the coil surface you'll either need to insulate the leads from the air, or better, epoxy them to the coil with a thermally conductive but electrically insulating epoxy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an excerpt:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Caution should be exercised, especially with T-3 packages, because the &gt; leads and any wiring to the device can act as heat pipes, introducing errors if the surrounding air-surface interface is not isothermal. Avoiding this condition is easily achieved by dabbing the leads of the temper-ature sensor and the hookup wires with a bead of thermally conductive epoxy. This ensures that the TMP35/TMP36/ TMP37 die temperature is not affected by the surrounding air temperature. Because plastic IC packaging technology is used, excessive mechanical stress should be avoided when fastening the device with a clamp or a screw-on heat tab. Thermally conductive epoxy or glue, which must be electrically nonconductive, is recommended under typical mounting conditions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;I also noticed they didn't specify an epoxy, which I take to mean the feel it isn't critical. You'll need one compatible with &quot;most&quot; plastics and with copper. I'd probably use a big &quot;wad&quot; (that's a technical term :) of any off-the-shelf non-electrically conductive epoxy over the whole sensor and its leads, getting the sensor face as close to the copper as possible. I might even wrap some thermal insulation around the connecting wires for a foot or so, or even wrap that much of them around the coil and tape them to it, just to keep the sensor and the wires at as close to the coil temperature as possible. My guess is that will be more than sufficient to get temperature readings of the coil to within the sensor's limits of accuracy.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-11T17:55:21.353" LastActivityDate="2016-04-11T17:55:21.353" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22911" PostTypeId="2" ParentId="22870" CreationDate="2016-04-09T04:30:54.370" Score="0" Body="&lt;p&gt;Where is all this confusion coming from?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (switchState == LOW) {&#xA;    //Button is not pressed&#xA;&#xA;    digitalWrite(3, HIGH); //Green LED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your code says, if the switch is &lt;strong&gt;not&lt;/strong&gt; pressed, light LED on pin 3.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't understand this - the circuit is open, so why should pin 3 light up?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Because that is what the code tells it to do.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does that mean that there is some internal wiring between ground and pin 3 that supplies current to the green LED?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Get the idea out of your head that this is some wiring issue. Your device is doing exactly what you are telling it to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you &lt;code&gt;digitalWrite&lt;/code&gt; HIGH to some pin, the processor activates the output driver MOSFET that attempts to drive the pin to +5V. Therefore current flows through the resistor to the LED which lights up.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-09T04:30:54.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22912" PostTypeId="1" AcceptedAnswerId="22915" CreationDate="2016-04-09T04:49:51.437" Score="2" ViewCount="3278" Body="&lt;p&gt;I want to hook up a potentiometer to my arduino (Leonardo) as a voltage divider with the middle pin to an analog pin. I want to use the highest resistance to save power. I looked on the datasheet and it said the maximum output impedance is 10kOhm (§24.7.1 on Atmega32u4 datasheet). I also found another question that said I should use a 10kOhm potentiometer. What doesn't make sense is if the knob was turned towards the middle so that there is 5k on both sides, it's not the maximum capable resistance. So should I use a 20kOhm potentiometer?&lt;/p&gt;&#xA;" OwnerUserId="19520" LastEditorUserId="19520" LastEditDate="2016-04-09T04:58:32.577" LastActivityDate="2016-04-10T03:09:57.047" Title="Maximum potentiometer resistance" Tags="|analogread|potentiometer|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22914" PostTypeId="1" AcceptedAnswerId="22918" CreationDate="2016-04-09T05:46:39.843" Score="1" ViewCount="1151" Body="&lt;p&gt;I just got my first arduino boards and have been learning the basics (so I know very little). I got the 2.4GHz NRF24L01+ (this one: &lt;a href=&quot;http://www.ebay.ca/itm/2pcs-2-4GHz-NRF24L01-Antenna-Wireless-Transceiver-Module-For-Microcontrol-/181847271521?hash=item2a56f12861:g:yn4AAMXQUmFSoxhZ&quot; rel=&quot;nofollow&quot;&gt;NRF24L01+&lt;/a&gt;) and along with it a breakout board (this one: &lt;a href=&quot;http://www.ebay.ca/itm/191674251825?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow&quot;&gt;NRF24L01+ board&lt;/a&gt;) which I didn't realize was 10pin (nor that there is an 8pin version) vs the wireless board's 8pin. So my question is, is it safe to connect the module to this adapter board in some way? From the pinout of both I would assume not, since for example the bottom two pins on the board are ground (and therefore connected together) and the ground pin on the NRF24L01+ is next to the VCC (&lt;a href=&quot;http://yourduino.com/docs/nRF24L01-Modules-connection-diagram.pdf&quot; rel=&quot;nofollow&quot;&gt;NRF24L01+ pinout&lt;/a&gt;) and the top two on the board are both VCC 3.3 and from what I can tell by looking at the etched lines, it seems it leads to the resistors (not sure if they are resistors or what, like I said, I know very little still). There seems to be an LED on this board as well, connected to the AMS1117 chip (that's a voltage regulator, correct?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I am guessing I cannot just connect the NRF24L01+ to the adapter board straight in, right? But, can it with some wires? Would that even make sense? Also, is this board even necessary for anything? I bought it having read something somewhere (been reading too much to keep track of where exactly) that recommended it, but a tutorial I saw today didn't make use of it, instead just soldering a capacitor to two of the pins saying some other place recommended it to reduce noise. &lt;/p&gt;&#xA;" OwnerUserId="19157" LastActivityDate="2016-04-09T08:50:13.037" Title="nrf24l01 (8pin) + adapter board (10pin) oops?" Tags="|nrf24l01+|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22915" PostTypeId="2" ParentId="22912" CreationDate="2016-04-09T06:05:46.310" Score="4" Body="&lt;p&gt;There is a lengthy discussion about this on &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=169000.10&quot; rel=&quot;nofollow&quot;&gt;the Arduino Forum&lt;/a&gt;. As I understand it, the input impedance is only important if you are sampling a rapidly varying signal, as it takes a finite time to charge the sample/hold capacitor. However your potentiometer would not vary rapidly (certainly not in the order of thousands of herz). Thus I don't think the potentiometer resistance will be particularly important, particularly if you are not changing the analog inputs (eg. from one channel to another). The continuous current through the 10k pot would be 0.5 mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are worried about power, then rather than connecting the +5V side directly to 5V, connect it to an output pin, which you can bring high when you want to take a measurement, and make low at other times. That reduces the power through the pot, since there won't be a voltage potential. You might allow a few microseconds for the reading to stabilize when you need to take one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So the lower the pot resistance, the faster response time? Also I will constantly always be taking a measurement &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, I don't think this is an issue. The &quot;response time&quot; is really the time taken to do the ADC calculation (nominally 104 µs if you don't fiddle with the registers). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;ADC conversion on the Arduino (analogRead)&lt;/a&gt;. As mentioned on that page you can speed up the measurement by changing the ADC prescaler. However even with a prescaler of 128 you get 9615 conversions per second. I doubt you can turn the pot fast enough for this to be a meaningful issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless of the response time, the issue here is &lt;em&gt;accuracy&lt;/em&gt;. Will a lower pot value give more accurate results? Well, I doubt it. The ADC effectively copies the analog input into a 14 pF capacitor (the &quot;sample and hold&quot; capacitor) which it then tests against the reference voltage divided up in various ways. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input impedance would be relevant if you were sampling a &lt;em&gt;high-frequency input&lt;/em&gt;. On the page I linked I sampled a 4 kHz sine wave and got good results. You just won't be turning the pot that fast (4000 times a second).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm still unsure with how potentiometer resistance affects the data ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you keep sampling the same ADC input (eg. A0) then I think the sample and hold capacitor can be charging in the background (while your code is doing other things).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even if that were not the case, the datasheet says the sample and hold operation takes place 1.5 ADC cycles after the conversion starts. So at 16 MHz clock rate, and a prescaler of 128 for the ADC clock, this means we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;128 * 62.5 ns * 1.5 = 12 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now since the datasheet says the sample-and-hold capacitor is 14 pF, and the time taken to (almost fully) charge a capacitor is reckoned to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 * R * C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given R = 110k and C = 14e-12 (14 pF) then it will take:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 * 110000 * 14e-12 = 7.7 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I quoted 110k because the datasheet mentions a resistance of 1 to 100k in series with the capacitor, plus the 10k impedance they recommend.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means the capacitor will charge within the 12 µs it has available. Bump R up to 1e6 (1 megohm) and the calculation now gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 * (100e3 + 1e6) * 14e-12 = 77 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This exceeds the 12 µs quoted for the sample-and-hold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is why, I suggest, that for fast-changing signals they recommend a lower input impedance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if I am correct that the sample-and-hold capacitor is normally connected to the ADC input, then that 77 µs can be spread over the time you deal with the calculation. Still, that is quite a few clock cycles. :)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My recommendation is to stick with 10k or so potentiometer (as recommended by the datasheet) and use my earlier suggestion of connecting the 5V side of the pot to an output pin instead of continually having it connected to the +5V signal. That way you only need to &quot;power&quot; the pot when you actually need to take a reading. However you can see that a 20k pot (or even 50k) will probably still be in an acceptable range for an accurate conversion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, a 50k pot could charge the capacitor in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;5 * 150000 * 14e-12 = 10.5 µs&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I would also be cautious about a 1 megohm pot because then slight variances in other things (eg. heat on the wire, nearby noise) could swamp the reading from it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Wait, sorry do I need to half my potentiometers' resistance if I'm using two analog inputs?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, because the multiplexer chooses one input at a time (the others are effectively out of circuit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you are choosing between two pots (to measure two) then the resistance becomes more relevant. As I showed, with a high value pot it takes longer to charge the capacitor, so if you read A0 and then immediately afterwards A1, you don't want a lengthy charging time for the capacitor, because that would give erroneous readings.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-10T03:09:57.047" LastActivityDate="2016-04-10T03:09:57.047" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="22918" PostTypeId="2" ParentId="22914" CreationDate="2016-04-09T08:22:43.983" Score="2" Body="&lt;p&gt;To be honest, I don't see much added value for this breakout board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, as you mentioned, you won't be able to plug your NRF24 directly into it because the pinout is not compatible; hence, &lt;strong&gt;you will have to use wires for that&lt;/strong&gt;. But you could as well use wires directly from your Arduino to the NRF24 module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, regarding power (you are right, AMS1117 is a voltage regulator), the &lt;strong&gt;Arduino 3.3V pin is enough&lt;/strong&gt; (&lt;strong&gt;50mA&lt;/strong&gt; for UNO) to power your NRF24 as its current consumption is low (max &lt;strong&gt;13.5mA&lt;/strong&gt; as per the &lt;a href=&quot;http://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qg7Mn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qg7Mn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please note these are specifications for the chip itself not for the board, which may need a bit more current, but not much more according to my own experiments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note, I have created my own very simple breakout for the NRF24 board, with just a tiny piece of stripboard, that's something you can easily do by yourself if you have the right tools (saw, cutter, soldering iron), a few pin headers and some stripboard scrap:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9QxLM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9QxLM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last, the only utility I see with your breakout board is to be used as 3.3V supply for higher currents in future experiments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;as commented by @Hans-Neve, a capacitor would be useful between 3.3V and GND pins, as near the NRF24L01 board as possible, so that short consumption peaks do not impact correct function of the board. The breakout board has one (or more exactly 2: 100nF and 10uF) It is advised you add those two (at least the large 10uF cap) in your circuit. I saw some people directly soldering one cap on the pins of the NRF24 board, but if you use short enough wires to connect it, you can perfectly put this cap on a breadboard during your experiments.&lt;/p&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2016-04-09T08:50:13.037" LastActivityDate="2016-04-09T08:50:13.037" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="22919" PostTypeId="2" ParentId="21444" CreationDate="2016-04-09T08:46:02.333" Score="0" Body="&lt;p&gt;Want to make a ball move? Maybe look at how sphero does it by looking at a tear down video. You have to use motors. The motor end has to be connected to a wheel which turns the outer shell. The centre which is not at all connected to the shell should be heavier than the shell.&lt;/p&gt;&#xA;" OwnerUserId="19520" LastEditorUserId="19520" LastEditDate="2016-04-09T08:52:17.793" LastActivityDate="2016-04-09T08:52:17.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22920" PostTypeId="1" CreationDate="2016-04-09T09:12:04.613" Score="1" ViewCount="503" Body="&lt;p&gt;I have an Arduino clone of a Leonardo and I was just wondering how many keyboard commands I can send to the computer per second via USB. I'm not talking about the delay between send and receive (because that could vary between computer), I'm talking about the minimum possible time between something like stimulating a key press down and key press up as fast as possible.&lt;/p&gt;&#xA;" OwnerUserId="19520" LastEditorUserId="19520" LastEditDate="2016-04-09T10:44:35.427" LastActivityDate="2016-06-09T18:42:35.143" Title="Keyboard input arduino speed" Tags="|arduino-leonardo|time|keyboard|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22921" PostTypeId="1" CreationDate="2016-04-09T09:21:11.090" Score="1" ViewCount="363" Body="&lt;p&gt;Can I use a &quot;Funduino Uno&quot; arduino with power from a power bank with DC 5V 1A output?&lt;/p&gt;&#xA;" OwnerUserId="20034" LastEditorUserId="20036" LastEditDate="2016-04-09T22:44:42.307" LastActivityDate="2016-04-09T22:44:42.307" Title="Funduino Uno with 5V 1A power supply?" Tags="|arduino-uno|power|voltage-level|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22922" PostTypeId="2" ParentId="22921" CreationDate="2016-04-09T09:34:44.173" Score="1" Body="&lt;p&gt;Yes. As long as it connects the the arduino clone via USB and can maintain a stable power output then it's suitable.&lt;/p&gt;&#xA;" OwnerUserId="19520" LastActivityDate="2016-04-09T09:34:44.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22923" PostTypeId="1" CreationDate="2016-04-09T10:26:54.173" Score="0" ViewCount="132" Body="&lt;p&gt;My current code that doesn't convince me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt; &#xA;&#xA;int DS18S20_Pin = 3; //DS18S20 Signal pin on digital 3&#xA;unsigned long startTime = 0;&#xA;#define MEASURE_PERIOD 250&#xA;//Temperature chip i/o&#xA;OneWire ds(DS18S20_Pin);  // on digital pin 3&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  if((millis() - startTime) &amp;gt;= MEASURE_PERIOD)&#xA;    {&#xA;        startTime += MEASURE_PERIOD;&#xA;        float temperature = getTemp();&#xA;        Serial.println(temperature);&#xA;    } //just here to slow down the output so it is easier to read&#xA;&#xA;}&#xA;&#xA;&#xA;float getTemp(){&#xA;  //returns the temperature from one DS18S20 in DEG Celsius&#xA;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;      //no more sensors on chain, reset search&#xA;      ds.reset_search();&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( OneWire::crc8( addr, 7) != addr[7]) {&#xA;      Serial.println(&quot;CRC is not valid!&quot;);&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( addr[0] != 0x10 &amp;amp;&amp;amp; addr[0] != 0x28) {&#xA;      Serial.print(&quot;Device is not recognized&quot;);&#xA;      return -1000;&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44,1); // start conversion, with parasite power on at the end&#xA;&#xA;  byte present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE); // Read Scratchpad&#xA;&#xA;&#xA;  for (int i = 0; i &amp;lt; 9; i++) { // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;  }&#xA;&#xA;  ds.reset_search();&#xA;&#xA;  byte MSB = data[1];&#xA;  byte LSB = data[0];&#xA;&#xA;  float tempRead = ((MSB &amp;lt;&amp;lt; 8) | LSB); //using two's compliment&#xA;  float TemperatureSum = tempRead / 16;&#xA;&#xA;  return TemperatureSum;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the outcome of few seconds of recording:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;22.31&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: I inserted the suggestion of @frarugi87 and I inserted the sensor in my pants to test it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;22.50&#xA;22.50&#xA;22.50&#xA;23.69&#xA;23.69&#xA;23.69&#xA;23.75&#xA;23.75&#xA;23.75&#xA;23.75&#xA;23.75&#xA;23.75&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.81&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.87&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;23.94&#xA;24.00&#xA;24.00&#xA;24.00&#xA;24.06&#xA;24.06&#xA;24.06&#xA;24.19&#xA;24.19&#xA;24.19&#xA;24.25&#xA;24.25&#xA;24.25&#xA;24.31&#xA;24.31&#xA;24.31&#xA;24.44&#xA;24.44&#xA;24.44&#xA;24.50&#xA;24.50&#xA;24.50&#xA;24.56&#xA;24.56&#xA;24.56&#xA;24.56&#xA;24.56&#xA;24.56&#xA;24.62&#xA;24.62&#xA;24.62&#xA;24.69&#xA;24.69&#xA;24.69&#xA;24.75&#xA;24.75&#xA;24.75&#xA;24.81&#xA;24.81&#xA;24.81&#xA;24.87&#xA;24.87&#xA;24.87&#xA;24.87&#xA;24.87&#xA;24.87&#xA;24.94&#xA;24.94&#xA;24.94&#xA;25.00&#xA;25.00&#xA;25.00&#xA;25.00&#xA;25.00&#xA;25.00&#xA;25.06&#xA;25.06&#xA;25.06&#xA;25.12&#xA;25.12&#xA;25.12&#xA;25.12&#xA;25.12&#xA;25.12&#xA;25.19&#xA;25.19&#xA;25.19&#xA;25.25&#xA;25.25&#xA;25.25&#xA;25.25&#xA;25.25&#xA;25.25&#xA;25.31&#xA;25.31&#xA;25.31&#xA;25.37&#xA;25.37&#xA;25.37&#xA;25.44&#xA;25.44&#xA;25.44&#xA;25.44&#xA;25.44&#xA;25.44&#xA;25.50&#xA;25.50&#xA;25.50&#xA;25.50&#xA;25.50&#xA;25.50&#xA;25.56&#xA;25.56&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I still find the change of temperature slow&lt;/p&gt;&#xA;" OwnerUserId="15699" LastEditorUserId="15699" LastEditDate="2016-04-09T12:30:43.800" LastActivityDate="2016-06-08T19:22:14.300" Title="Is it possible to make 4hz readings with the DS18S20 temperature sensor?" Tags="|electronics|temperature-sensor|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22924" PostTypeId="1" CreationDate="2016-04-09T11:07:57.103" Score="2" ViewCount="151" Body="&lt;p&gt;I am trying to get data from D6T Omron thermal sensor. It works fine with both Arduino and Processing when I connect it to pc directly. However, it seems to always cannot read my last data in my data array when i use Xbee on them. It results in a NaN for my last data in my array in processing display [Fig 1]. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone having any thoughts on this? Any help will be much appreciated! =D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another problem i having here is that i was trying to make a popup window when my sensor senses a sum of 34*4 in the center pixels with no success currently. The last data in the array returns in NaN error again and the program is not responding after that. [Similar with Figure 1.] D: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It actually works fine until we reach this stage &quot;Serial.write(0x03)&quot; from Arduino to processing when it senses a sum of 34*4 in the center. I am confused. Any idea on how to improve that? =) Thanks a lot in advance!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code (Arduino sketch):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;WireExt.h&amp;gt;&#xA;&#xA;#define D6T_addr 0x0A&#xA;#define D6T_cmd 0x4C&#xA;&#xA;int rbuf[35];&#xA;float tdata[16];&#xA;float t_PTAT;&#xA;float top_sum, bottom_sum, left_sum, right_sum, center_sum, center_row_sum;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.flush();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int i;&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {     &#xA;    int inByte = Serial.read();     &#xA;    if (inByte == 0x0001) {         &#xA;&#xA;      Wire.beginTransmission(D6T_addr);&#xA;      Wire.write(D6T_cmd);&#xA;      Wire.endTransmission();&#xA;&#xA;      if (WireExt.beginReception(D6T_addr) &amp;gt;= 0) {&#xA;        i = 0;&#xA;        for (i = 0; i &amp;lt; 35; i++) {&#xA;          rbuf[i] = WireExt.get_byte();&#xA;        }&#xA;        WireExt.endReception();&#xA;&#xA;        t_PTAT = (rbuf[0]+(rbuf[1]&amp;lt;&amp;lt;8))*0.1;&#xA;        for (i = 0; i &amp;lt; 16; i++) {&#xA;          tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]&amp;lt;&amp;lt;8))*0.1;&#xA;        }&#xA;&#xA;        output_csv();  &#xA;        delay(250);&#xA;      }&#xA;      top_sum= tdata[0] + tdata[1] + tdata[2] + tdata[3];&#xA;      bottom_sum= tdata[12] + tdata[13] + tdata[14] + tdata[15];&#xA;      right_sum= tdata[0]+ tdata[4] + tdata[8] + tdata[12];&#xA;      left_sum= tdata[3] + tdata[7] + tdata[11] + tdata[15];&#xA;      center_sum= tdata[5] + tdata[6] + tdata[9] + tdata[10];&#xA;      center_row_sum= tdata[1] + tdata[2] + tdata[5] + tdata[6] + tdata[9] + tdata[10] + tdata[13] + tdata[14];&#xA;&#xA;     if (center_sum&amp;gt;34*4)&#xA;    {&#xA;      //Serial.flush();&#xA;      Serial.write(0x0003);&#xA;      delay(100);&#xA;&#xA;    }     &#xA;}&#xA;  }&#xA;}&#xA;&#xA;&#xA;void output_csv() {&#xA;  for (int i = 0; i &amp;lt; 16; i++) {&#xA;    Serial.print(tdata[i]);&#xA;    if (i &amp;lt; 15) {&#xA;      Serial.print(&quot;,&quot;);&#xA;    } &#xA;    else {&#xA;      Serial.println();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code in Processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;import controlP5.*;&#xA;import javax.swing.JOptionPane.*;&#xA;ControlP5 cp5;&#xA;javax.swing.JOptionPane JOptionPane;&#xA;&#xA;Textlabel myTextlabelA;&#xA;boolean canStart = true;&#xA;boolean canInput = false;&#xA;boolean Start = false;&#xA;String typedText = &quot;Comments: &quot;;&#xA;PFont font;&#xA;int confirm;&#xA;&#xA;&#xA;float[] tdata = new float[17]; &#xA;float tptat; // PTAT&#xA;String portName; &#xA;//int serialport = 0; &#xA;&#xA;String buf; &#xA;float colourGreen; //change green in relation to temperature &#xA;&#xA;int lbTemp = 25; //lowest relative temperature&#xA;int hbTemp = 40; //highest relative temperature &#xA;Serial myPort;  // Create object from Serial class&#xA;&#xA;&#xA;void setup() {&#xA;  size(600,768);&#xA;  background(ControlP5.BLACK);&#xA;  myPort = new Serial(this, &quot;COM15&quot;, 9600);&#xA;  myPort.clear();&#xA;  cp5 = new ControlP5(this);&#xA;&#xA;  myTextlabelA = cp5.addTextlabel(&quot;label&quot;)&#xA;                    .setText(&quot;GUI of Alive Human Detection System.&quot;)&#xA;                    .setPosition(120,10)&#xA;                    .setColorValue(#FFFAF0)&#xA;                    .setFont(createFont(&quot;Georgia&quot;,20))&#xA;                    ;&#xA;&#xA;  cp5.addButton(&quot;Start&quot;)&#xA;     .setPosition(115, 670)&#xA;     .setSize(100,30)&#xA;     ;&#xA;&#xA;  cp5.addButton(&quot;Stop&quot;)&#xA;     .setPosition(375, 670)&#xA;     .setSize(100,30)&#xA;     ;&#xA;}&#xA;&#xA;public void Start(int theValue) {&#xA;  println(&quot;Initialising...&quot;);&#xA;  println(&quot;Connected.&quot;);&#xA;  Start = !Start;&#xA;}&#xA;&#xA;public void Stop(int theValue) {&#xA;  println(&quot;Shuting Down...&quot;);&#xA;  myPort.write(0x02);&#xA;  Start = !Start;&#xA;&#xA;}&#xA;&#xA;void draw() {&#xA;    if (Start){&#xA;&#xA;    myPort.write(0x01); &#xA;    delay(100); &#xA;    while (myPort.available() &amp;gt; 0) { &#xA;    delay(500);  &#xA;    buf = myPort.readString(); &#xA;    myPort.clear();  &#xA;    tdata = float(split(buf, ','));  &#xA;    for (int i = 0; i &amp;lt;16; i++) { &#xA;    colourGreen = map(tdata[i],lbTemp,hbTemp,255,0);&#xA;    fill (255,colourGreen,0);&#xA;&#xA;      if (i == 0)&#xA;    { rect(450,64,150,150);}&#xA;      else if (i == 1)&#xA;    { rect(300,64,150,150);}&#xA;      else if (i == 2)&#xA;    { rect(150,64,150,150);}&#xA;      else if (i == 3)&#xA;    { rect(0,64,150,150);}&#xA;      else if (i == 4)&#xA;    { rect(450,214,150,150);}&#xA;      else if (i == 5)&#xA;    { rect(300,214,150,150);}&#xA;      else if (i == 6)&#xA;    { rect(150,214,150,150);}&#xA;      else if (i == 7)&#xA;    { rect(0,214,150,150);}&#xA;      else if (i == 8)&#xA;    { rect(450,364,150,150);}&#xA;      else if (i == 9)&#xA;    { rect(300,364,150,150);}&#xA;      else if (i == 10)&#xA;    { rect(150,364,150,150);}&#xA;      else if (i == 11)&#xA;    { rect(0,364,150,150);}&#xA;      else if (i == 12)&#xA;    { rect(450,514,150,150);}&#xA;      else if (i == 13)&#xA;    { rect(300,514,150,150);}&#xA;      else if (i == 14)&#xA;    { rect(150,514,150,150);}&#xA;      else if (i == 15)&#xA;    { rect(0,514,150,150); }&#xA;&#xA;    if (tdata[i]&amp;lt;5) {fill(255);} else {fill(0);}&#xA;      if (i ==0)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),525, 139);}&#xA;      else if (i == 1)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),375, 139);&#xA;      }&#xA;      else if (i == 2)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 139);&#xA;      }&#xA;      else if (i == 3)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),75, 139); &#xA;      }&#xA;      else if (i == 4)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 289); &#xA;      }&#xA;      else if (i == 5)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 289);  &#xA;      }&#xA;      else if (i == 6)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 289);  &#xA;      }&#xA;      else if (i == 7)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 289); &#xA;      }&#xA;      else if (i == 8)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 439);&#xA;      }&#xA;      else if (i == 9)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 439);  &#xA;      }&#xA;      else if (i == 10)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 439);&#xA;      }&#xA;      else if (i == 11)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 439);&#xA;      }&#xA;      else if (i == 12)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 592);  &#xA;      }&#xA;      else if (i == 13)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 592); &#xA;      }&#xA;      else if (i == 14)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 592);&#xA;      }&#xA;      else if (i == 15)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 592);  &#xA;      }&#xA;    }&#xA;    delay(250);&#xA;    CheckSerial();  &#xA;  }&#xA;&#xA;    }&#xA;&#xA;}&#xA;&#xA;void CheckSerial()&#xA;{  &#xA;    confirm = myPort.read(); &#xA;    if (confirm == 0x03)&#xA;  {&#xA;  int dialogResult = JOptionPane.showConfirmDialog (null, &quot;Human found? Please Confirm!!&quot;, &quot;Alert!&quot;, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);&#xA;  if(dialogResult == JOptionPane.YES_OPTION)&#xA;  {&#xA;  //futher action&#xA;  }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P0CrC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P0CrC.png&quot; alt=&quot;Figure 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19475" LastActivityDate="2016-04-09T11:07:57.103" Title="Getting NaN error in Processing when Xbee is used and trying to create a popup window." Tags="|arduino-uno|xbee|processing-lang|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22925" PostTypeId="2" ParentId="22923" CreationDate="2016-04-09T11:15:02.523" Score="1" Body="&lt;p&gt;I would expect some variations in temperature, but I would not say that is a problem caused by the 4Hz readings. You can test my assumption by reading every 3 seconds, does the temperature value change or is it still the same?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see two potential problems: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;your DS1820 is defect. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;from your code I assume that you use parasitic power. In that case the chip consumes power from the data wire ( one wire ;-) ) through a pull up resitor (~4.7 kOhms). If you do not provide a special handling, to drive more current while the DS1820 is converting or copying data to EE or from EE memory to the scratchpad, then there will be (most likely) voltage drops.&#xA;Then the Temperature conversion will not happen and you read the old value from the scratchpad in your read cycle.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You can test point 2 by adding VCC to the DS1820, and do not use parasitic power.&#xA;If that is your problem, you can fix it with a switching FET Transistor, that provide more current (see DS1820 Datasheet from Maxim) or by using an additional VCC wire. &lt;/p&gt;&#xA;" OwnerUserId="10285" LastActivityDate="2016-04-09T11:15:02.523" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22926" PostTypeId="2" ParentId="22923" CreationDate="2016-04-09T11:32:26.720" Score="0" Body="&lt;p&gt;Not sure if this is the only problem, but when shifting bytes you will lose the msb. This can be solved by casting the variable to an int.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And moreover you don't need the two variables &lt;code&gt;MSB&lt;/code&gt; and &lt;code&gt;LSB&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to correct it with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float tempRead = ((((int)data[1]) &amp;lt;&amp;lt; 8) | data[0]); //using two's compliment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-04-09T11:32:26.720" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="22927" PostTypeId="2" ParentId="22923" CreationDate="2016-04-09T12:07:25.710" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to make 4hz readings with the DS18S20 temperature sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but only at 9-10 bits resolution. See &lt;a href=&quot;https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf&quot; rel=&quot;nofollow&quot;&gt;Table 2. Thermometer Resolution Configuration&lt;/a&gt;. At full resolution, 12 bits, the conversion time is 750 ms. With the commands, reset, etc, this gives just over 1hz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this also gives you a hint on what to fix in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-04-09T12:07:25.710" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22928" PostTypeId="1" CreationDate="2016-04-09T13:16:19.110" Score="0" ViewCount="84" Body="&lt;p&gt;Can you use an Arduino EtherMega's 3.3v and 5v pins with two sensors, one requiring 3.3v and the other 5v and a sketch that combines both?&lt;/p&gt;&#xA;" OwnerUserId="19901" LastActivityDate="2016-04-09T13:17:55.023" Title="Can you use both 3.3v and 5v" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22929" PostTypeId="2" ParentId="22928" CreationDate="2016-04-09T13:17:55.023" Score="1" Body="&lt;p&gt;Yes. As long as you take into account that the outputs of the Arduino will be 5V so you may need to reduce that to 3.3V for the 3.3V sensor (if it has any connection to an output).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-09T13:17:55.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22930" PostTypeId="2" ParentId="19296" CreationDate="2016-04-09T16:14:41.960" Score="0" Body="&lt;p&gt;Dragino is just the password for the first initial setup. You probably set a new password. Even if you reset the shield, it keeps your password. This happened to me to and then I put in my password and it worked.&lt;/p&gt;&#xA;" OwnerUserId="20041" LastActivityDate="2016-04-09T16:14:41.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22932" PostTypeId="1" CreationDate="2016-04-09T20:24:33.540" Score="4" ViewCount="1596" Body="&lt;h1&gt;Summary&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;I'm having problems with my RTC draining its coin cells quickly - fresh batteries are drained in a few months. The RTC is set to signal an interrupt every 5 minutes, and I wonder - if there is no other power attached to the circuit, is that enough to drain the coin cell?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Details and my troubleshooting:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Problems with my RTC - if I leave the circuit unpowered for a few days (so that the only power to the RTC is from the coin cell backup), the time resets to 00:00 January 1, 2000. This doesn't happen immediately when I unplug it. If I disconnect it from the computer, plug it back in the next day, the time is ok. If I leave it unplugged for a few days, then plug it in, the date is reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This suggests the battery is bad. So I tested it with my meter (and an 100 ohm load, as described here: &lt;a href=&quot;https://www.youtube.com/watch?v=HcikzMG7mMU&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=HcikzMG7mMU&lt;/a&gt;). And sure enough, the batter has dropped quite a bit from its 3V start value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's all good, except that this battery is only a few months old, and it should last for years in an RTC. I've got two batteries purchased in the last year and used in RTC modules, and both are now drained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current hypothesis is that, after I unplug my circuit from the computer, the RTC continues to run on the coin cell, firing interrupts every 5 minutes, and it is these interrupts that are causing the drain. Does this make sense? If not, what else could I check?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Setup&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Breadboard arduino, DS3231 RTC on a breakout, connected &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RTC SDA -&gt; Arduino A4&lt;/li&gt;&#xA;&lt;li&gt;RTC SCL -&gt; Arduino A5&lt;/li&gt;&#xA;&lt;li&gt;RTC GND -&gt; Common GND&lt;/li&gt;&#xA;&lt;li&gt;RTC VCC -&gt; Common 5V (from ftdi/USB cable, when plugged in)&lt;/li&gt;&#xA;&lt;li&gt;RTC SQW -&gt; Arduino D2 &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The RTC is 'active-low', and the SQW pin is held at 5V between interrupts. With my multimeter, the brief drop to 'LOW' is undetectable. I also can't detect any current flow from the SQW pin with my multimeter.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Sketch&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Including only the code related to the RTC (SD card and temperature bits removed).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*-(Import required libraries)-*/&#xA;#include &amp;lt;Time.h&amp;gt;&#xA;#include &amp;lt;DS3232RTC.h&amp;gt; //source: https://github.com/JChristensen/DS3232RTC &#xA;&#xA;/*-( Declare Constants )-*/&#xA;const int wakeUpPin = 2;&#xA;#define resolution 5 // frequency in minutes to wake from sleep&#xA;&#xA;/*-(Declare Variables)-*/&#xA;time_t t;&#xA;int nextLoop;&#xA;&#xA;/****** SETUP: RUNS ONCE ******/&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  Serial.println();&#xA;  pinMode(wakeUpPin, INPUT);&#xA;&#xA;  t = RTC.get();&#xA;&#xA;  nextLoop = ((minute(RTC.get()) / resolution) + 1) * resolution;&#xA;  if (nextLoop &amp;gt;= 60) {&#xA;    nextLoop -= 60;&#xA;  }&#xA;  Serial.print(RTC.temperature());&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(RTC.oscStopped());&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.println(nextLoop); // the minutes when the next reading will be taken&#xA;&#xA;}&#xA;&#xA;/****** LOOP: RUNS CONSTANTLY ******/&#xA;void loop()&#xA;{&#xA;  t = RTC.get();&#xA;&#xA;  Serial.print(year(t), DEC);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(month(t), DEC);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(day(t), DEC);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(hour(t), DEC);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(minute(t), DEC);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(second(t), DEC);&#xA;  Serial.print(&quot;,&quot;);&#xA;&#xA;  goToSleep();&#xA;}&#xA;&#xA;&#xA;void goToSleep(void) {&#xA;    Serial.print(&quot;Sleeping until: &quot;);&#xA;    Serial.println(nextLoop);&#xA;    Serial.flush();&#xA;    RTC.setAlarm(ALM2_MATCH_MINUTES, nextLoop, 1, 1);&#xA;    RTC.alarmInterrupt(ALARM_2, true);&#xA;    attachInterrupt(0, wakeUp, LOW);&#xA;&#xA;    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);&#xA;    detachInterrupt(0);&#xA;    RTC.alarm(ALARM_2);&#xA;    nextLoop += resolution;&#xA;    if (nextLoop &amp;gt;= 60) {&#xA;         nextLoop -= 60;&#xA;    }&#xA;}&#xA;&#xA;void wakeUp(){&#xA;  // Handler for the pin interrupt.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3956" LastActivityDate="2020-09-16T04:07:15.740" Title="RTC interrupts and coin batteries" Tags="|battery|rtc|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22933" PostTypeId="1" CreationDate="2016-04-09T20:32:48.447" Score="0" ViewCount="992" Body="&lt;p&gt;It looks like I broke my Arduino (Compatible) Pro Mini board using AtmelStudio to change the fuses. I was having trouble with speed and using some basic sketches. For example, the LED blink was on for 2 seconds and off for 2 seconds instead of 1 second. I tried to change the fuses to Ext Clock + 65 ms, and now I can't use the thing at all. Cannot enter programming mode. Any ideas? &lt;/p&gt;&#xA;" OwnerUserId="20045" LastActivityDate="2016-05-09T22:03:54.207" Title="Pro Mini Fuse Repair" Tags="|arduino-pro-mini|fuses|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22934" PostTypeId="1" CreationDate="2016-04-09T20:33:09.853" Score="5" ViewCount="1059" Body="&lt;p&gt;So I'm looking to create an arduino clone to mount on one of my robots. I started off making the arduino on a breadboard, using the instructions found on Arduino's own website and I succeeded. It works as well, I've checked it with the &quot;blink&quot; project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then drew the schematic in Eagle:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/wdnvm.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I created a board and routed it, giving the following result:&#xA;&lt;img src=&quot;https://i.stack.imgur.com/aU1Xy.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I transferred it onto a copper clad, soldered it, but it doesn't work. Tried pretty much everything I could think of but there seems to be something wrong and I cant work out what it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hassan&lt;/p&gt;&#xA;" OwnerUserId="19611" LastEditorUserId="2944" LastEditDate="2016-04-10T12:52:09.787" LastActivityDate="2016-04-10T12:52:09.787" Title="Arduino on breadboard, and then soldered using a board made on Eagle but won't work" Tags="|arduino-uno|pcb-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22935" PostTypeId="2" ParentId="22934" CreationDate="2016-04-09T21:24:20.857" Score="8" Body="&lt;p&gt;I haven't worked out why it's &quot;not working&quot;, but some comments on your PCB:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your crystal is too far from the clock pins&lt;/li&gt;&#xA;&lt;li&gt;Your crystal capacitors are most definitely too far from the crystal&lt;/li&gt;&#xA;&lt;li&gt;There are no decoupling capacitors on your Vcc / AVcc pins&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your crystal should be right next to the pins on the chip that it is connected to, and the capacitors for it should be immediately next to that. The layout you have at the moment, if it actually works, will be radiating huge amounts of EMI and would immediately fail any emissions test you'd care to perform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without decoupling capacitors on the power pins the chip may not function properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit: I have just found your main mistake&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't linked the output of your regulator sub-circuit to Vcc. Power gets regulated but goes nowhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gob1d.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gob1d.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-09T21:24:20.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22936" PostTypeId="1" AcceptedAnswerId="22942" CreationDate="2016-04-09T21:27:22.310" Score="0" ViewCount="378" Body="&lt;p&gt;I hooked up two Arduino Nanos with I²C, using 3 wires between GND &amp;lt;-&gt; GND, A4 &amp;lt;-&gt; A4, A5 &amp;lt;-&gt; A5Ω and 1kΩ pull-up resistors on A4 &amp;amp; A5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the following code to communicate between them I get a weird empty receive event.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;master.cpp&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SERIAL_BAUD 9600&#xA;&#xA;#define I2C_SLAVE_ADDRESS 8&#xA;&#xA;void setup () {&#xA;    Wire.begin();&#xA;    Serial.begin(SERIAL_BAUD);&#xA;}&#xA;&#xA;void getFromState (unsigned char state) {&#xA;    Wire.beginTransmission(I2C_SLAVE_ADDRESS);&#xA;    Serial.print(&quot;s&quot;);&#xA;    Serial.print(Wire.write(state));&#xA;    Serial.print(&quot;e&quot;);&#xA;    Serial.print(Wire.endTransmission());&#xA;    delay(5000);&#xA;    Wire.requestFrom(I2C_SLAVE_ADDRESS, 2);&#xA;    int c = (unsigned char) Wire.read();&#xA;    Wire.flush();&#xA;    Serial.print(&quot;r&quot;);&#xA;    Serial.println(c);&#xA;    Wire.endTransmission();&#xA;}&#xA;&#xA;void loop () {&#xA;    Serial.println(&quot;loop&quot;);&#xA;    getFromState(0);&#xA;    delay(10000);&#xA;    getFromState(1);&#xA;    delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;slave.cpp&lt;/h3&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define SERIAL_BAUD 9600&#xA;&#xA;#define I2C_ADDRESS 8&#xA;&#xA;unsigned char state = 0;&#xA;&#xA;void requestEvent () {&#xA;    Serial.print(&quot;Request &quot;);&#xA;    Serial.println(state);&#xA;    Wire.write(state);&#xA;}&#xA;&#xA;void receiveEvent (int amount) {&#xA;    Serial.print(&quot;a&quot;);&#xA;    Serial.print(amount);&#xA;    Serial.print(&quot;r&quot;);&#xA;    state = (unsigned char) Wire.read();&#xA;    Serial.println(state);&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(SERIAL_BAUD);&#xA;    Wire.begin(I2C_ADDRESS);&#xA;    Wire.onRequest(requestEvent);&#xA;    Wire.onReceive(receiveEvent);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Serial Output Master After 1.5 Loops&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop&#xA;s1e0r0&#xA;s1e0r1&#xA;loop&#xA;s1e0r0&#xA;s1e0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Serial Output Slave After 1.5 Loops&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a1r0&#xA;Request 0&#xA;a0r255&#xA;a1r1&#xA;Request 0&#xA;a0r255&#xA;a1r0&#xA;Request 0&#xA;a0r255&#xA;a1r1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Question&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Why is there an empty receive event &lt;code&gt;a0r255&lt;/code&gt; after every request? Is that normal? Am I doing something wrong? Is this some sort of hardware issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I opensourced this project &lt;a href=&quot;https://github.com/dodekeract/arduino-examples/tree/master/custom-i2c-device&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, take a look if you want to!&lt;/p&gt;&#xA;" OwnerUserId="19971" LastEditorUserId="19971" LastEditDate="2016-04-10T08:47:40.773" LastActivityDate="2016-04-10T08:47:40.773" Title="I²C between 2 Arduinos sends additional receive event" Tags="|i2c|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22937" PostTypeId="2" ParentId="22933" CreationDate="2016-04-09T21:34:06.397" Score="1" Body="&lt;p&gt;Sounds like you broke your fuses. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to enter programming mode by applying an external clock signal to the clock in pin (use another Arduino to generate it).  If that doesn't work then the only way to fix it is with a &quot;High Voltage Programmer&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nick Gammon has a very good tutorial here: &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12898&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=12898&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-09T21:34:06.397" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22938" PostTypeId="2" ParentId="22903" CreationDate="2016-04-09T22:54:56.547" Score="0" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow&quot;&gt;page about I2C&lt;/a&gt;. The speed of I2C depends on a number of things, such as the I2C clock (which you can change) and also how many data bytes are in a &quot;packet&quot;. There is a fixed overhead of the device address in each packet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A broad rule-of-thumb would be around 4700 bytes per second for a single-byte payload at the default clock rate. You may also need to spend time asking for a reading. I haven't read the datasheet (which you didn't link). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for the MPU6050 may give you more information about how fast it can respond.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-09T22:54:56.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22939" PostTypeId="1" AcceptedAnswerId="22940" CreationDate="2016-04-09T23:14:50.660" Score="1" ViewCount="935" Body="&lt;p&gt;I have tried a software. It work flawless on the first laptop in a fresh install arduino IDE environment with the libraries I imported.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However when I copy the exact same program over. I get lot of errors and tried to clean up some of the old libraries from earlier programs. Then rerun the compiler; got even more errors and I am not sure what to do except completely clean everything including older libraries that I may need to keep around for older programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My includes are as following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &quot;utility/Adafruit_MS_PWMServoDriver.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error from the Arduino IDE from the second laptop is as following:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;Invalid library found in C:\Users\B Family\Documents\Arduino\libraries\examples: C:\Users\B Family\Documents\Arduino\libraries\examples&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\libraries\Adafruit_Motor_Shield_V2_Library-master\utility/Adafruit_MS_PWMServoDriver.cpp:28: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::setPWM(unsigned char, unsigned int, unsigned int)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::write8(unsigned char, unsigned char)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::reset()'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::begin()'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::read8(unsigned char)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;libraries\utility\Adafruit_MS_PWMServoDriver.cpp.o: In function `Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(unsigned char)':&#xA;&#xA;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: multiple definition of `Adafruit_MS_PWMServoDriver::setPWMFreq(float)'&#xA;&#xA;libraries\Adafruit_Motor_Shield_V2_Library-master\utility\Adafruit_MS_PWMServoDriver.cpp.o:C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:77: first defined here&#xA;&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&#xA;exit status 1&#xA;Error compiling.&#xA;&#xA;This report would have more information with&#xA;&quot;Show verbose output during compilation&quot;&#xA;enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20049" LastEditorUserId="19409" LastEditDate="2016-04-10T14:34:15.673" LastActivityDate="2016-04-10T14:34:15.673" Title="Troubleshooting duplicate libaries (Arduino motor shield and stepper motor)" Tags="|arduino-ide|library|arduino-motor-shield|stepper|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22940" PostTypeId="2" ParentId="22939" CreationDate="2016-04-09T23:57:36.090" Score="0" Body="&lt;p&gt;The diagnostics tell you &lt;em&gt;exactly&lt;/em&gt; what is wrong! You have multiple copies of the same library, probably because you installed it at different times from different places. The diagnostics even tell you which libraries are duplicates. Remove them and everything will work fine!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While we are at it: another source of duplicate definitions is badly written .h files that &lt;em&gt;define&lt;/em&gt; (as opposed to only &lt;em&gt;declaring&lt;/em&gt;) external symbols. Those you have to deal with as they happen, there is no global solution.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-09T23:57:36.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22941" PostTypeId="2" ParentId="22936" CreationDate="2016-04-10T00:02:19.930" Score="2" Body="&lt;p&gt;Your code has several issues:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the master:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your I2C transactions should be quick and not delayed with &lt;code&gt;Serial.print()&lt;/code&gt;s like in &lt;code&gt;getFromState()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;You requested 2 bytes from the slave but you are reading only one from the buffer. &lt;code&gt;Wire.flush()&lt;/code&gt; flushes the &lt;em&gt;outgoing&lt;/em&gt; buffer, not the receive buffer. Use &lt;code&gt;while (Wire.read() != -1);&lt;/code&gt; instead.&lt;/li&gt;&#xA;&lt;li&gt;Its also advised that you use &lt;code&gt;Wire.available()&lt;/code&gt; to iterate through the receive buffer when &lt;code&gt;read()&lt;/code&gt;ing; its how you check if anything was received at all and how many bytes were received. &lt;/li&gt;&#xA;&lt;li&gt;After using &lt;code&gt;requestFrom()&lt;/code&gt;, you shouldn't call &lt;code&gt;endTransmission()&lt;/code&gt;. Its self-contained.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For the slave:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should never call &lt;code&gt;Serial.print()&lt;/code&gt; or &lt;code&gt;delay()&lt;/code&gt; in &lt;code&gt;requestEvent()&lt;/code&gt; or &lt;code&gt;receiveEvent()&lt;/code&gt;; both functions are called from within ISRs and ISRs are meant to execute quickly and return. &lt;/li&gt;&#xA;&lt;li&gt;You are requesting 2 bytes from the slave in your master code, whereas your slave's &lt;code&gt;requestEvent()&lt;/code&gt; writes only one byte.&lt;/li&gt;&#xA;&lt;li&gt;In &lt;code&gt;receiveEvent()&lt;/code&gt;, again its best to use either &lt;code&gt;Wire.available()&lt;/code&gt; to iterate through the RX buffer or you use the variable &lt;code&gt;amount&lt;/code&gt;. This way, you read everything in the buffer; you can also flush the RX buffer like I showed you before.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Finally those delays are rather long; 10ms would do, if they are even needed at all.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-10T00:26:52.790" LastActivityDate="2016-04-10T00:26:52.790" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22942" PostTypeId="2" ParentId="22936" CreationDate="2016-04-10T00:05:05.383" Score="1" Body="&lt;p&gt;The main culprit that is causing your problem is the second &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.endTransmission();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after your &lt;code&gt;requestFrom&lt;/code&gt;.  That causes the previous &lt;code&gt;startTransmission()&lt;/code&gt; to be repeated with no data in it - thus giving you a second &lt;code&gt;receiveEvent&lt;/code&gt; call with no data. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-10T00:05:05.383" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22944" PostTypeId="1" CreationDate="2016-04-10T01:06:06.260" Score="0" ViewCount="145" Body="&lt;p&gt;I am using an Arduino Uno with a 4 relay module (found here: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00KTEN3TM&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/JBtek-Channel-Module-Arduino-Raspberry/dp/B00KTEN3TM?ie=UTF8&amp;amp;psc=1&amp;amp;redirect=true&amp;amp;ref_=oh_aui_detailpage_o04_s00&lt;/a&gt;) and an Adafruit CC3000 WiFi breakout board.  However, once I connect the power source, the board just constantly cycles on and off, e.g. about 1 second per cycle.  Could this have to do with too much current being drawn? Or that the current output of the digital pins isn't enough for all of the relay inputs? I'm new with this, but I am sure all of the pins are appropriately connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If I use the USB connector (5V 1A) instead of the external power supply, I can connect 1 or 2 of the relays without problem, but must do so AFTER the wifi has already connected to the network, otherwise the wifi chip will never connect.  Also, if I toggle the relays a few times, the wifi becomes unresponsive.  I suspect a current issue maybe?. Any ideas? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20053" LastEditorUserId="20053" LastEditDate="2016-04-10T02:12:38.280" LastActivityDate="2016-05-10T07:10:48.910" Title="Arduino Uno Constantly Resets with WiFi and 4 Relay Module" Tags="|arduino-uno|wifi|relay|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22945" PostTypeId="1" AcceptedAnswerId="22951" CreationDate="2016-04-10T02:48:42.630" Score="0" ViewCount="554" Body="&lt;p&gt;I'm working on a modular CANBUS system for offroad racing. The idea right now is that the main Arduino (1284p at the moment) will be the only one connected to CANBUS, and other modules will have their own atmega's that will communicate with the master over I2C. They will not be physically on the same PCB, but will be physically within inches of each other. One module will have 8 &lt;a href=&quot;https://datasheets.maximintegrated.com/en/ds/MAX31865.pdf&quot; rel=&quot;nofollow&quot;&gt;MAX31865&lt;/a&gt; IC's for interfacing with RTD's. The 31865 is not compatible with 5V microcontrollers, which right now we planned on running the Atmega's at 5V. Since the IC's are SPI, they can all share a MOSI, MISO, and CLK bus, so only two channels of a hex converter. For the Chip Select pin, would it be acceptable to use a resistor to decrease the voltage instead of using an additional 8 channels of hex converting? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would the upsides/downsides be of using an atmega running at 3.3v for the module with the MAX31865's and just using a hex converter on SDA/SCL for the I2C communication to the master? What atmega I use for this is flexible. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-04-10T09:58:57.750" Title="Resistor on SPI Chip Select Pin" Tags="|sensors|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22946" PostTypeId="2" ParentId="22944" CreationDate="2016-04-10T06:22:25.657" Score="1" Body="&lt;p&gt;It Will be a power issue you need to supply power direct to the relay modules VCC independent of the arduino, ensure the earths are connected and just use the digital outputs from the arduino to control the relays. Digital low normally switches the corresponding relay on.&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2016-04-10T06:22:25.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22947" PostTypeId="2" ParentId="22945" CreationDate="2016-04-10T06:50:07.303" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;would it be acceptable to use a resistor to decrease the voltage&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't see any big problem with using a voltage divider for chip select.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What would the upsides/downsides be of using an atmega running at 3.3v for the module with the MAX31865's &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;At 3.3V you can only run at 13 MHz or less (so in practice, 8 MHz, unless you want to do a lot of fiddling around). This may or may not matter to you. At a lower voltage it uses less power which can be a plus, and you don't need to worry about level converters.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and just using a hex converter on SDA/SCL for the I2C communication to the master?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Do you mean a level converter?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-10T06:50:07.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22948" PostTypeId="1" CreationDate="2016-04-10T08:35:24.430" Score="0" ViewCount="2678" Body="&lt;p&gt;research would show that there are numerous ways for two arduinos to talk to one another. But i was looking for a 'basic robust protocol' (..it doesn't sound basic ....I know!), to allow for two arduinos to talk to one another. The idea is , Arduino One(slave), is linked to a sensor and it reads data from the sensor and sends the data  to Arduino Two on 'request' of the data by Arduino Two(master). Arduino Two would have to 'request' for the data from Arduino One, before it can read the data, if its available. A popular method on most sites (e.g &lt;a href=&quot;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/shaking-hands-part-1&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/shaking-hands-part-1&lt;/a&gt;) is the use of the method below. I added a comment in search of clarity.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              void establishContact()&#xA;                     {  //This while loop does baffle me as it suggests that&#xA;                        //while there is nothing in serial, send A???&#xA;                        while (Serial.available() &amp;lt;= 0)&#xA;                       {&#xA;                         Serial.println(&quot;A&quot;);   // send a capital A&#xA;                         delay(300);&#xA;                       }&#xA;                     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this method was used in handshaking between Arduino and processing. This method was called on the Arduino sketch. On the processing sketch, a method there just checks to see if 'A' was received. If it is, it reads in the data from serial, clears the serial buffer and  writes 'A' back to Serial. I tried using this method on both of my arduinos as i felt it was 'basic' enough, but it didn't work at all. Does anyone has a better idea on how my arduinos could handshake?. &lt;/p&gt;&#xA;" OwnerUserId="14350" LastActivityDate="2016-04-10T09:52:59.610" Title="Two or More Arduinos Handshaking" Tags="|arduino-uno|serial|arduino-due|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22949" PostTypeId="2" ParentId="22890" CreationDate="2016-04-10T08:51:00.337" Score="1" Body="&lt;p&gt;This can happen in I2C sometimes. Basically the controller asks the sensors for data but there may be a bit error in the address. If so the sensor thinks you are talking to another chip, meanwhile your I2C master code waits for a reply, forever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this problem I would recommend the use of a watchdog timer. You can find the many examples online of how to set this up.&lt;/p&gt;&#xA;" OwnerUserId="20059" LastActivityDate="2016-04-10T08:51:00.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22950" PostTypeId="2" ParentId="22948" CreationDate="2016-04-10T09:52:59.610" Score="2" Body="&lt;p&gt;That while loop makes perfect sense.  It' basically nudging the other end repeatedly until it replies with something - anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like sitting next to someone and poking them in the ribs every 300ms until they respond to you. Once they have responded you can then react to that response - be that to run very fast or tell them your important news.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea of handshaking like that is all to do with synchronisation. It ensures that both ends are ready for communication at the same time.  Once synchronised you know, to a high probability, that what you are sending will be interpreted properly, and any replies you get back will be correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For basic communication between two Arduinos it's really not necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest call-and-response protocol involves Arduino A sending a single byte as a request and Arduino B replying with a single byte. It is up to you what those bytes represent, but ASCII letters for requests are ideal since they are understandable by a human, and numbers between 0 and 255 or -128 and +127 fit in to one byte (unsigned or signed respectively). Should you want bigger numbers being sent back then the reply will have to be delimited in some way. The simplest way of doing that is to format the response as ASCII data and send it with a CR and/or LF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.available()) {&#xA;    char command = Serial.read();&#xA;    switch (command) {&#xA;        case 'T':&#xA;            Serial.println(temperature);&#xA;            break;&#xA;        case 'P':&#xA;            Serial.println(pressure);&#xA;            break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The master end then sends either 'T' or 'P' to request temperature or pressure. It then reads characters up to a line feed and stores them in a string which it can then convert into the desired numeric data type depending on what temperature and pressure are (integer or floating point).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-10T09:52:59.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22951" PostTypeId="2" ParentId="22945" CreationDate="2016-04-10T09:58:57.750" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;using a hex converter on SDA/SCL for the I2C communication to the master&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I2C is not straight forward for level shifting.  The I/O pins operate in &lt;em&gt;open drain&lt;/em&gt; mode. That is, they don't send out any voltage of their own, they just pull down (like a button) the signals pulled up by resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To level shift you have to read the state of those lines and then replicate that open drain connection to the signals of a different voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that is not all of course. I2C is a bidirectional protocol on a single data line. That means that data goes in both directions on the data line, so your level shifter has to be able to work in both ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are special I2C level shifter chips available that do that exact thing. Some people sell them on breakout boards if you google around.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But with all that said, if you run your I2C bus purely at 3.3V it should work quite happily with both 3.3V and 5V devices.  To do so you need to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use external pullup resistors (~3.3KΩ) to 3.3V&lt;/li&gt;&#xA;&lt;li&gt;Disable the Arduino's idiotic use of the internal pullup resistors on the I2C pins (will need modification of the Wire library)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In short: It is possible to mix 3.3V and 5V I2C devices on a 3.3V I2C bus, but not on a 5V I2C bus.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-10T09:58:57.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22952" PostTypeId="2" ParentId="22643" CreationDate="2016-04-10T14:13:07.033" Score="0" Body="&lt;p&gt;I solved my problem by sending a GET request to a hosted PHP script which in turn updates Carriots by means of a Curl request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My PHP Script&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;$humidity=$_GET['humidity'];&#xA;$data = array(&quot;protocol&quot;=&amp;gt;&quot;v2&quot;, //Compose JSON stream&#xA;              &quot;at&quot;=&amp;gt; &quot;now&quot;,&#xA;              &quot;device&quot;=&amp;gt;&quot;DEVICE_NAME&quot;,&#xA;              &quot;data&quot; =&amp;gt; array (&quot;humidity&quot; =&amp;gt; trim($humidity)),&#xA;              &quot;checksum&quot; =&amp;gt; &quot;&quot;);&#xA;$data_string = json_encode($data);&#xA;&#xA;$ch = curl_init('https://api.carriots.com/status'); //Compose the HTTP request                                                                  &#xA;curl_setopt($ch, CURLOPT_CUSTOMREQUEST, &quot;POST&quot;);&#xA;curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);&#xA;curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&#xA;curl_setopt($ch, CURLOPT_HTTPHEADER, array(&#xA;    'Content-Type: application/json',&#xA;    'carriots.apikey: YOUR_API_KEY',&#xA;    'Content-Length: ' . strlen($data_string))&#xA;);       &#xA;&#xA;$result = curl_exec($ch); //Send the stream&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I switched to Carriots from ThingSpeak due to personal preference.&lt;/li&gt;&#xA;&lt;li&gt;This is by no means a standard way to send stream to Carriots.This&#xA;involves additional effort which slows down transmission of data but&#xA;I decided that this setup will be enough for a hobby project.&lt;/li&gt;&#xA;&lt;li&gt;A good understanding of how POST requests are built should allow me&#xA;to skip the extra PHP script completely.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="13736" LastActivityDate="2016-04-10T14:13:07.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22953" PostTypeId="1" AcceptedAnswerId="22959" CreationDate="2016-04-10T14:43:40.710" Score="1" ViewCount="555" Body="&lt;p&gt;I have this simple push button schematic:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sG0M7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sG0M7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The idea is that the LED is on as long as the button stays pushed, with the switch closed.&lt;/p&gt;&#xA;&lt;p&gt;The code is below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin=10;&#xA;int switchPin=5;&#xA;&#xA;void setup()&#xA;&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(switchPin, INPUT);&#xA;  pinMode(ledPin,OUTPUT);&#xA;&#xA;}&#xA;void loop()&#xA;&#xA;{&#xA;  digitalWrite(ledPin,LOW);//DBG&#xA;  if (digitalRead(switchPin)==HIGH)&#xA;{&#xA; digitalWrite(ledPin,HIGH);//DBG&#xA; delay(500);&#xA;}&#xA; if (digitalRead(switchPin)==LOW);&#xA;{&#xA;digitalWrite(ledPin,LOW);//DBG &#xA;delay(200);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As I keep the button pressed, &lt;strong&gt;the LED blinks regularly&lt;/strong&gt;, instead of &lt;strong&gt;staying on&lt;/strong&gt;. Why?&#xA;I have tried using a capacitor between the switch and switchPin, with no change.&lt;/p&gt;&#xA;" OwnerUserId="20062" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-04-10T15:39:16.457" Title="Why is my LED blinking?" Tags="|arduino-uno|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22954" PostTypeId="1" CreationDate="2016-04-10T14:46:49.757" Score="2" ViewCount="35" Body="&lt;p&gt;The title pretty much explains my question. If I'm using a library for example one for an accelerometer does the arduino need to be connected to my computer because it's using a library? Or is the library uploaded to the arduino and there for can run with out a computer connected?&lt;/p&gt;&#xA;" OwnerUserId="20064" LastActivityDate="2016-04-10T15:36:19.987" Title="Do arduino librarys require the arduino to be connected to a computer?" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22955" PostTypeId="1" AcceptedAnswerId="23563" CreationDate="2016-04-10T14:56:42.680" Score="2" ViewCount="307" Body="&lt;p&gt;I'm writing a &lt;a href=&quot;https://github.com/turn-a-round/Arduino-Charlieplexing&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; for Charlieplexed LED display (trying to write a common one actually). The library is working quite fine. In my arduino sketch, I'm using an integer to keep track of the LED, currently on. The integer value increases with time and the LED(s) glow one by one. The problem is, after couple of iterations, this integer value just goes out of chart (in Serial monitor, it has garbage values).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MatrixCharlieplex mch(Pins, 5, MXCHARLIE_CA); // instance of Class&#xA;int i = 0, j = 0;&#xA;boolean busy = false;&#xA;unsigned long time;&#xA;void setup() {&#xA;  //Serial.begin(9600);&#xA;  time=millis();&#xA;}&#xA;void loop() {&#xA;  if(millis() - time &amp;gt; 100){ // runs every 100 ms interval // corrected from (millis() &amp;gt; (time + 100))&#xA;    time=millis();&#xA;    blink();&#xA;  }&#xA;}&#xA;void blink(){&#xA;  if(!busy){&#xA;    busy = true;&#xA;    //Serial.print(&quot;i:\t&quot;);&#xA;    //Serial.println(i);&#xA;    //Serial.print(&quot;Node:\t&quot;);&#xA;    //Serial.println(i+1);&#xA;    mch.TurnOn(i+1);&#xA;    increase();&#xA;    busy = false;&#xA;  }&#xA;}&#xA;void increase(){&#xA;  i = (++i % 20); // resets after every 20 intervals&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i:  16&#xA;Node:   17&#xA;i:  17&#xA;Node:   18&#xA;i:  18&#xA;Node:   19&#xA;i:  19&#xA;Node:   20&#xA;i:16 &amp;lt;-- Stopped working here. it should be &quot;i:    0&quot; &amp;amp; &quot;Node:    1&quot;&#xA;    16&#xA;Node:   17&#xA;    17&#xA;Node:   18&#xA;    18&#xA;Node:   19&#xA;    19&#xA;Node:   20&#xA;16&#xA;    16&#xA;Node:   17&#xA;    17&#xA;Node:   18&#xA;    18&#xA;Node:   19&#xA;    19&#xA;Node:   20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch can also be found &lt;a href=&quot;https://github.com/turn-a-round/Arduino-Charlieplexing/tree/master/libraries/Arduino-Charlieplexing/examples/ArduinoMatrixCharlieplex&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update:&lt;/em&gt;&lt;/strong&gt; &#xA;There were no hardware-fault. The problem lies in the struct variable declaration as pointers.updated the question &amp;amp; posted answer. The files in the github links have also been updated.&lt;/p&gt;&#xA;" OwnerUserId="20065" LastEditorUserId="20065" LastEditDate="2016-04-25T19:23:17.643" LastActivityDate="2016-04-25T19:23:17.643" Title="Integer goes garbage after iteration. struct pointer manipulation messed up other variables in memory" Tags="|arduino-uno|pointer|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="22956" PostTypeId="2" ParentId="22954" CreationDate="2016-04-10T15:14:24.003" Score="1" Body="&lt;p&gt;No.  Arduino libraries (strictly speaking only the utilized parts) are permanently built-in parts of your compiled sketch.  Effectively they are &quot;statically linked&quot; unlike the situation with modern RAM-based computer operating systems where compiled dynamic link library code may be separately loaded into memory for a program to call at runtime.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This isn't even really a design choice, as the basic AVR Arduino's cannot load new program code into executable memory at runtime anyway - except by reflashing themselves like the bootloader does, which would be a bit slow compared to normal dynamic linking)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course if you have a library which is intended to perform &lt;em&gt;communication&lt;/em&gt; with a computer, then that connection would probably be required for it to fully operate.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-10T15:36:19.987" LastActivityDate="2016-04-10T15:36:19.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22958" PostTypeId="1" AcceptedAnswerId="22990" CreationDate="2016-04-10T15:29:10.210" Score="2" ViewCount="1787" Body="&lt;p&gt;I am trying to detect LPG leakage by using MQ4 gas sensor.&#xA;I have made this circuit&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f2jPw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f2jPw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino code is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);      // sets the serial port to 9600&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  sensorValue = analogRead(0);       &#xA;  Serial.println(sensorValue, DEC);  &#xA;  delay(100);                        &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my serial monitor, I am getting values like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;307&#xA;277&#xA;289&#xA;282&#xA;283&#xA;283&#xA;260&#xA;248&#xA;265&#xA;285&#xA;308&#xA;278&#xA;278&#xA;315&#xA;321&#xA;316&#xA;327&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These values are not getting change even after putting sensor near gas lighter. Did I made any mistake in circuit or this sensor could be faulty ? Any help is appriciated.&lt;/p&gt;&#xA;" OwnerUserId="19781" LastEditorUserId="19781" LastEditDate="2016-04-10T17:53:38.633" LastActivityDate="2016-04-11T12:33:48.027" Title="MQ4 gas sensor is not working with Arduino UNO" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22959" PostTypeId="2" ParentId="22953" CreationDate="2016-04-10T15:33:25.907" Score="1" Body="&lt;p&gt;The beginning of your code in the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop()  {&#xA;  digitalWrite(ledPin,LOW); //remove this line here&#xA;  if (digitalRead(switchPin)==HIGH)&#xA;{&#xA;     digitalWrite(ledPin,HIGH);//DBG&#xA;     delay(500);&#xA;}&#xA; if (digitalRead(switchPin)==LOW);&#xA; {&#xA;      digitalWrite(ledPin,LOW);//DBG &#xA;       delay(200);&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before your first &lt;code&gt;if(digital read(switch pin) == HIGH)&lt;/code&gt;  you turn the LED off, and then you have a delay, which gives the blinking effect, remove that and it will not blink.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2016-04-10T15:39:16.457" LastActivityDate="2016-04-10T15:39:16.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22960" PostTypeId="1" CreationDate="2016-04-10T16:47:04.717" Score="2" ViewCount="70" Body="&lt;p&gt;I am currently trying to make a simple game system with my Arduino Esplora, however I have noticed something. The Arduino Esplora has no pins for a 2-pin speaker that I get from a RadioShack store &lt;a href=&quot;https://www.radioshack.com/collections/maker-parts-kits/products/radioshack-8-ohm-mini-speaker?variant=5717358533&quot; rel=&quot;nofollow&quot;&gt;(Click here for item description)&lt;/a&gt;. How would I go about connecting the speaker because I am also using the TFT LCD screen, or is there a workaround with the output TinkerKit pins on the top?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20068" LastEditorUserId="4143" LastEditDate="2016-04-10T18:13:09.877" LastActivityDate="2016-04-10T18:13:09.877" Title="Esplora: Connecting a 2-Wire Speaker to Arduino Esplora" Tags="|tft|speaker|arduino-esplora|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22961" PostTypeId="1" AcceptedAnswerId="22962" CreationDate="2016-04-10T16:47:57.573" Score="3" ViewCount="206" Body="&lt;p&gt;I recently bought a 0.96&quot; Serial OLED Screen. I am not very experienced with this. I'm trying to display some text with the Arduino Uno. I installed the adafruit SSD1306 and GFX libraries but no luck. I've looked for tutorials for similar screens, but my screen has extra pins that others don't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mine has:&#xA;&lt;code&gt;CS&lt;/code&gt; &lt;code&gt;DC&lt;/code&gt; &lt;code&gt;RST&lt;/code&gt; &lt;code&gt;D1&lt;/code&gt; &lt;code&gt;D0&lt;/code&gt; &lt;code&gt;VCC&lt;/code&gt; &lt;code&gt;GND&lt;/code&gt;,&#xA;others only have 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what each pin should be connected to. Does any one know how to get this to work? Is there a different library that I could use with this screen?&lt;/p&gt;&#xA;" OwnerUserId="20069" LastEditorUserId="2881" LastEditDate="2016-04-10T18:11:40.510" LastActivityDate="2016-04-10T18:11:40.510" Title="OLED with arduino?" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22962" PostTypeId="2" ParentId="22961" CreationDate="2016-04-10T16:58:31.953" Score="2" Body="&lt;p&gt;Yes, certain OLED screens do have different pinouts. For yours, the following would be your OLED's pinouts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OLED ---- Arduino&#xA;&#xA;D0-----------10&#xA;&#xA;D1-----------9&#xA;&#xA;RST----------13&#xA;&#xA;DC-----------11&#xA;&#xA;VCC----------5V&#xA;&#xA;GND----------GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;CS&lt;/code&gt; pin does not need to be plugged in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the code, you can use &lt;a href=&quot;http://smart-prototyping.com/image/data/2_components/Arduino/100952%20OLED%200.96inch%2012864%20display%20module%20blue/OELD.txt&quot; rel=&quot;nofollow&quot;&gt;this include&lt;/a&gt; from Smart Prototyping as an extra file, then have some simple code in your &lt;code&gt;loop&lt;/code&gt; portion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;&#xA;LED_P8x16Str(23,0,&quot;here is&quot;);&#xA;&#xA;LED_P8x16Str(40,2,&quot;example&quot;);&#xA;&#xA;LED_P8x16Str(20,4,&quot;text&quot;);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20068" LastActivityDate="2016-04-10T16:58:31.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22963" PostTypeId="2" ParentId="22920" CreationDate="2016-04-10T17:45:17.677" Score="1" Body="&lt;p&gt;From my tests, it has been at least 1 millisecond, however, it can depend on what is running simultaneously on the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="20068" LastActivityDate="2016-04-10T17:45:17.677" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22964" PostTypeId="1" CreationDate="2016-04-10T18:26:43.690" Score="1" ViewCount="1193" Body="&lt;pre&gt;&lt;code&gt;/*&#xA;&#xA; This example code uses bogde's excellent library: https://github.com/bogde/HX711&#xA; bogde's library is released under a GNU GENERAL PUBLIC LICENSE&#xA;&#xA; The HX711 does one thing well: read load cells. The breakout board is compatible with any wheat-stone bridge&#xA; based load cell which should allow a user to measure everything from a few grams to tens of tons.&#xA; Arduino pin 2 -&amp;gt; HX711 CLK&#xA; 3 -&amp;gt; DAT&#xA; 5V -&amp;gt; VCC&#xA; GND -&amp;gt; GND&#xA;&#xA; The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.&#xA;&#xA;*/&#xA;&#xA;#include &quot;HX711.h&quot;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;float calibration_factor = -4050.0;&#xA;&#xA;#define DOUT  3&#xA;#define CLK  2&#xA;Servo myServo;&#xA;&#xA;HX711 scale(DOUT, CLK);&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Food Test&quot;);&#xA;    scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0&#xA;    Serial.println(&quot;Readings:&quot;);&#xA;    myServo.attach(9);&#xA;    long zero_factor = scale.read_average(); //Get a baseline reading&#xA;    Serial.print(&quot;Zero factor: &quot;); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.&#xA;    Serial.println(zero_factor);&#xA;}&#xA;&#xA;void loop() {&#xA;    scale.set_scale(calibration_factor); //Adjust to this calibration factor&#xA;&#xA;    if ((scale.get_units(), 1) &amp;lt;= 5) {&#xA;        Serial.print(&quot;whoa that is light, more food needed&quot;);&#xA;        myServo.write(90); // Open food hatch&#xA;        delay(2000);&#xA;        myServo.write(0);&#xA;&#xA;        do {&#xA;            // Do nothing&#xA;            Serial.println(&quot;It is working somewhat&quot;);&#xA;            Serial.println(scale.get_units(), 1);&#xA;            delay(1000);&#xA;            // When weight exceeds 5 it should break out of this loop and go below&#xA;        } while ((scale.get_units(), 1) &amp;lt; 10);&#xA;&#xA;        Serial.print(&quot;Closing the Hatch&quot;);&#xA;        myServo.write(0); // close food hatch&#xA;    } else {&#xA;        Serial.print(&quot;Something Went Wrong&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;It is working somewhat  &#xA;10.6&#xA;It is working somewhat&#xA;10.9&#xA;It is working somewhat&#xA;10.5&#xA;It is working somewhat&#xA;6.9&#xA;It is working somewhat&#xA;-0.8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will try to explain the problem as best as I can. I am using a scale library and the &lt;code&gt;scale.get_units()&lt;/code&gt;,x returns a value as a float. The whole point is that a servo will open and stay open until a specified weight of 10lbs is reached. As seen in the do, while loop that's what I specify. It jumps into the if loop and then into the do while loop, and it continually prints out values of readings which is what I want. BUT, even when I reach over 10lbs it will not break out of the Do/while loop, essentially it never satisfies the while condition and I have no clue why. It prints out values over 10 but keeps reading values. I know the format isn't the best but any help would be greatly appreciated!!&lt;/p&gt;&#xA;" OwnerUserId="20070" LastEditorUserId="4143" LastEditDate="2016-04-10T19:49:06.643" LastActivityDate="2021-08-09T02:07:55.710" Title="Using an Arduino Weight Sensor, it fails to satisfy a while loop and I can't firgure out why" Tags="|serial|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22965" PostTypeId="5" CreationDate="2016-04-10T18:36:24.320" Score="0" Body="&lt;p&gt;Arduino Esplora is a game-controller shaped Arduino with the Arduino Leonardo built-in that can be used as a standalone game or computer mouse to a game console controller, with the capability to have a TFT LCD screen built-in with TinkerKit Input and Output pins. The Arduino Esplora also comes with 4 preset buttons and a joystick to simulate the game controller feel, as well as an accelerometer, temperature sensor, linear potentiometer, light sensor, and buzzer.&lt;/p&gt;&#xA;" OwnerUserId="20068" LastEditorUserId="20068" LastEditDate="2016-04-10T20:39:47.757" LastActivityDate="2016-04-10T20:39:47.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22966" PostTypeId="4" CreationDate="2016-04-10T18:36:24.320" Score="0" Body="The Arduino Esplora is a microcontroller board derived from the Arduino Leonardo. The Esplora differs from all preceding Arduino boards in that it provides a number of built-in, ready-to-use set of onboard sensors for interaction. It's designed for people who want to get up and running with Arduino without having to learn about the electronics first." OwnerUserId="-1" LastEditorUserId="37523" LastEditDate="2019-11-16T17:18:29.330" LastActivityDate="2019-11-16T17:18:29.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22968" PostTypeId="2" ParentId="22964" CreationDate="2016-04-10T19:04:36.427" Score="1" Body="&lt;p&gt;It looks to me like you have an extra bracket in there that you don't want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment your structure is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if {&#xA;    do {&#xA;    }&#xA;} while...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As it stands your sketch won't compile. The unbalanced brackets prevent it.  Remove the excess one so that the &lt;code&gt;while&lt;/code&gt; is associated with the &lt;code&gt;do&lt;/code&gt; not the &lt;code&gt;if&lt;/code&gt; and report back.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Part II&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The main cause of your problem is the strange bit of code you have in your &lt;code&gt;if&lt;/code&gt;s and &lt;code&gt;while&lt;/code&gt;s.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((scale.get_units(), 1) &amp;lt;= 5) {&#xA;&#xA;....&#xA;&#xA;} while ((scale.get_units(), 1) &amp;lt; 10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both of those you have the bit &lt;code&gt;(scale.get_units(), 1)&lt;/code&gt; which is completely meaningless.  The comma operator in C calls (or evaluates) both sides, and then returns the right hand side.  So that calls &lt;code&gt;scale.get_units()&lt;/code&gt; and then returns 1.  1 has always been, and will always be, less than 10, so the &lt;code&gt;while&lt;/code&gt; never ends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know what you were hoping to achieve by having the &lt;code&gt;, 1&lt;/code&gt; in there, but you should delete it from every place you have it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-10T20:20:18.523" LastActivityDate="2016-04-10T20:20:18.523" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22969" PostTypeId="1" CreationDate="2016-04-10T19:16:35.947" Score="1" ViewCount="75" Body="&lt;p&gt;I'm running this on a Particle Photon, but I think the issue is just me failing at C++. I'm trying to retrieve some JSON data from a HTTP API, convert it to JSON, and then extract a few values for display on the screen. I convert the String to a char array for the JSON parser, but it seems to only grab the first 10 characters of the String (unless I manually set length to a number shorter than 10), and then of course, the JSON parser fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the relevant bit of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int str_len = response.body.length() + 1; &#xA;tft.print(&quot;Length: &quot;); tft.println(str_len);&#xA;char char_array[str_len];&#xA;response.body.toCharArray(char_array, str_len);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;response.body&lt;/code&gt; is a big JSON string, but &lt;code&gt;char_array&lt;/code&gt; is always just the first 10 characters of it: &lt;code&gt;{&quot;metadata&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing I noticed just now that might be related, &lt;code&gt;str_len&lt;/code&gt; is usually reported to be ~500 characters, but when I hit the same URL in a browser it ends up more like ~1500 characters. Neither are pretty-printed, so I'm not sure what the discrepancy is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my complete code, except I removed the base64'd username and password from the Authorization header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;HttpClient/HttpClient.h&quot;&#xA;#include &quot;SparkJson/SparkJson.h&quot;&#xA;#include &quot;Adafruit_mfGFX/Adafruit_mfGFX.h&quot;&#xA;#include &quot;Adafruit_SSD1351_Photon/Adafruit_SSD1351_Photon.h&quot;&#xA;&#xA;// OLED - You can use any (4 or) 5 pins&#xA;#define sclk A3&#xA;#define mosi A5&#xA;#define dc   D7&#xA;#define cs   A2&#xA;#define rst  D5&#xA;&#xA;// Color definitions&#xA;#define BLACK           0x0000&#xA;#define BLUE            0x001F&#xA;#define RED             0xF800&#xA;#define GREEN           0x07E0&#xA;#define CYAN            0x07FF&#xA;#define MAGENTA         0xF81F&#xA;#define YELLOW          0xFFE0  &#xA;#define WHITE           0xFFFF&#xA;&#xA;&#xA;// Option 1: Hardware SPI - uses some analog pins, but much faster&#xA;Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);&#xA;&#xA;// Option 2: Software SPI - use any pins but a little slower&#xA;//Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, mosi, sclk, rst);  &#xA;&#xA;&#xA;HttpClient http;&#xA;&#xA;// Headers currently need to be set at init, useful for API keys etc.&#xA;http_header_t headers[] = {&#xA;    //  { &quot;Content-Type&quot;, &quot;application/json&quot; },&#xA;    { &quot;Authorization&quot;, &quot;Basic &amp;lt;snip&amp;gt;&quot; }, // base64encode(username:password)&#xA;    { &quot;Accept&quot; , &quot;application/json&quot; },&#xA;    { NULL, NULL } // NOTE: Always terminate headers will NULL&#xA;};&#xA;&#xA;http_request_t request;&#xA;http_response_t response;&#xA;&#xA;&#xA;void setup(void) {&#xA;&#xA;    tft.begin();&#xA;&#xA;    tft.fillScreen(BLACK);&#xA;    tft.setCursor(0,0);&#xA;    tft.setTextSize(0);&#xA;    tft.setTextColor(WHITE);&#xA;&#xA;    // http://twcservice.mybluemix.net/api/weather/v2/observations/current?units=e&amp;amp;geocode=40.0388067%2C-84.3428471&amp;amp;language=en-US&#xA;    request.hostname = &quot;twcservice.mybluemix.net&quot;;&#xA;    request.port = 80;&#xA;    request.path = &quot;/api/weather/v2/observations/current?units=e&amp;amp;geocode=40.0388067%2C-84.3428471&amp;amp;language=en-US&quot;;&#xA;    //request.body = &quot;{\&quot;key\&quot;:\&quot;value\&quot;}&quot;;&#xA;    http.get(request, response, headers);&#xA;&#xA;    tft.print(&quot;Status: &quot;);&#xA;    tft.println(response.status);&#xA;&#xA;    //tft.println(&quot;Response Body: &quot;);&#xA;    //tft.println(response.body);&#xA;&#xA;    int str_len = response.body.length() + 1; &#xA;    tft.print(&quot;Length: &quot;); tft.println(str_len);&#xA;    char char_array[str_len];&#xA;    response.body.toCharArray(char_array, str_len);&#xA;&#xA;    DynamicJsonBuffer jsonBuffer;&#xA;    JsonObject&amp;amp; root = jsonBuffer.parseObject(char_array);&#xA;&#xA;    if (root.success()) {&#xA;        tft.print(&quot;Current Temperature: &quot;); &#xA;        const char* temp = root[&quot;observation&quot;][&quot;imperial&quot;][&quot;temp&quot;];&#xA;        tft.println(temp);&#xA;    } else {&#xA;        tft.setTextColor(RED);&#xA;        tft.println(&quot;parseObject() failed&quot;);&#xA;&#xA;        tft.setTextColor(GREEN);&#xA;        uint32_t freemem = System.freeMemory();&#xA;        tft.print(&quot;Free memory: &quot;); &#xA;        tft.print(freemem/1024); &#xA;        tft.println(&quot;k&quot;);&#xA;&#xA;        tft.setTextColor(WHITE);&#xA;        tft.println(char_array);&#xA;&#xA;        tft.setTextColor(CYAN);&#xA;        tft.println(response.body);&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual printout on the screen is smething like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Status: 200&#xA;Length: 501&#xA;parseObject() failed&#xA;Free memory: 59k&#xA;{&quot;metadata&#xA;{&quot;metadata&quot;:{&quot;language&quot;:&quot;en-US&quot;,&quot;transaction_id&quot;:&quot;1460309558940:-660053703&quot;,&quot;version&quot;:&quot;1&quot;,&quot;latitude&quot;:40.04,&quot;longitude&quot;:-84.34,&quot;units&quot;:&quot;e&quot;,&quot;expire_time_gmt&quot;:1460310025,&quot;status_code&quot;:200},&quot;observation&quot;:{&quot;class&quot;:&quot;observation&quot;,&quot;expire_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, here's an example of the JSON response I'm trying to parse:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&quot;metadata&quot;:{&quot;language&quot;:&quot;en-US&quot;,&quot;transaction_id&quot;:&quot;1460309558940:-660053703&quot;,&quot;version&quot;:&quot;1&quot;,&quot;latitude&quot;:40.04,&quot;longitude&quot;:-84.34,&quot;units&quot;:&quot;e&quot;,&quot;expire_time_gmt&quot;:1460310025,&quot;status_code&quot;:200},&quot;observation&quot;:{&quot;class&quot;:&quot;observation&quot;,&quot;expire_time_gmt&quot;:1460310025,&quot;obs_time&quot;:1460307900,&quot;obs_time_local&quot;:&quot;2016-04-10T13:05:00-0400&quot;,&quot;wdir&quot;:160,&quot;icon_code&quot;:26,&quot;icon_extd&quot;:2690,&quot;sunrise&quot;:&quot;2016-04-10T07:06:23-0400&quot;,&quot;sunset&quot;:&quot;2016-04-10T20:11:13-0400&quot;,&quot;day_ind&quot;:&quot;D&quot;,&quot;uv_index&quot;:3,&quot;uv_warning&quot;:0,&quot;wxman&quot;:&quot;wx4400&quot;,&quot;obs_qualifier_code&quot;:null,&quot;ptend_code&quot;:2,&quot;dow&quot;:&quot;Sunday&quot;,&quot;wdir_cardinal&quot;:&quot;SSE&quot;,&quot;uv_desc&quot;:&quot;Moderate&quot;,&quot;phrase_12char&quot;:&quot;Cloudy/Wind&quot;,&quot;phrase_22char&quot;:&quot;Cloudy/Wind&quot;,&quot;phrase_32char&quot;:&quot;Cloudy/Wind&quot;,&quot;ptend_desc&quot;:&quot;Falling&quot;,&quot;sky_cover&quot;:&quot;Cloudy&quot;,&quot;clds&quot;:&quot;OVC&quot;,&quot;obs_qualifier_severity&quot;:null,&quot;vocal_key&quot;:&quot;OT48:OX2690&quot;,&quot;imperial&quot;:{&quot;wspd&quot;:20,&quot;gust&quot;:24,&quot;vis&quot;:10.000,&quot;mslp&quot;:1018.7,&quot;altimeter&quot;:30.09,&quot;temp&quot;:48,&quot;dewpt&quot;:27,&quot;rh&quot;:43,&quot;wc&quot;:41,&quot;hi&quot;:48,&quot;temp_change_24hour&quot;:11,&quot;temp_max_24hour&quot;:44,&quot;temp_min_24hour&quot;:27,&quot;pchange&quot;:-0.10,&quot;feels_like&quot;:41,&quot;snow_1hour&quot;:0.0,&quot;snow_6hour&quot;:0.0,&quot;snow_24hour&quot;:0.0,&quot;snow_mtd&quot;:1.2,&quot;snow_season&quot;:21.3,&quot;snow_ytd&quot;:21.3,&quot;snow_2day&quot;:0.7,&quot;snow_3day&quot;:0.8,&quot;snow_7day&quot;:0.9,&quot;ceiling&quot;:7400,&quot;precip_1hour&quot;:0.00,&quot;precip_6hour&quot;:0.00,&quot;precip_24hour&quot;:0.00,&quot;precip_mtd&quot;:1.10,&quot;precip_ytd&quot;:11.76,&quot;precip_2day&quot;:0.29,&quot;precip_3day&quot;:0.30,&quot;precip_7day&quot;:0.96,&quot;obs_qualifier_100char&quot;:null,&quot;obs_qualifier_50char&quot;:null,&quot;obs_qualifier_32char&quot;:null}}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea what's going on?&lt;/p&gt;&#xA;" OwnerUserId="20072" LastEditorUserId="20072" LastEditDate="2016-04-10T19:58:08.307" LastActivityDate="2016-04-10T21:56:08.893" Title="Why is the result shorter than expected when I do longString.toCharArray(bigCharArr, longLength)?" Tags="|string|array|http|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22970" PostTypeId="2" ParentId="22969" CreationDate="2016-04-10T21:56:08.893" Score="1" Body="&lt;p&gt;It turns out that the HttpClient library has a fixed response length limit of 1024 bytes and whatever it was doing after it hit that limit is what caused all of the trouble. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Forking the library and increasing the limit as recommended at &lt;a href=&quot;https://community.particle.io/t/issues-with-string-char-array-length-json-parsing/21980&quot; rel=&quot;nofollow&quot;&gt;https://community.particle.io/t/issues-with-string-char-array-length-json-parsing/21980&lt;/a&gt; solved the issue.&lt;/p&gt;&#xA;" OwnerUserId="20072" LastActivityDate="2016-04-10T21:56:08.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22971" PostTypeId="2" ParentId="22955" CreationDate="2016-04-10T22:04:41.423" Score="1" Body="&lt;p&gt;If you have a Charliplexing board like mine (or even if you made your own) the problem could be electrical. If you turn on a lot of LEDs you may exceed the current consumption allowed and then the processor hangs or resets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest current-limiting resistors like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xJb0E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xJb0E.png&quot; alt=&quot;Charliplexing&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-10T22:04:41.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22973" PostTypeId="1" CreationDate="2016-04-11T00:09:59.423" Score="0" ViewCount="271" Body="&lt;p&gt;I am trying to convert the signal from digital pin 2 on my Uno to 3.3V.  I set up a voltage divider with 3 x 1000 ohm resistors.  When connected to ground and 5V the divider circuit generates 3.3V correctly, with a calculated input current of 1.7mA.  However I connect it to a digital pin, the digital pin voltage drops from 4.8V to .37V.  I thought the digital pins were to support 40mA, I was assuming 40mA at the 5V supply voltage.  Is my Uno malfunctioning?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-08-09T03:49:15.047" Title="voltage output at digital pins vs. load" Tags="|arduino-uno|pins|voltage-level|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22974" PostTypeId="2" ParentId="22973" CreationDate="2016-04-11T00:42:09.400" Score="1" Body="&lt;p&gt;Just figured out I didn't have the pin mode set, it works fine now, thanks.&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-04-11T00:42:09.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22976" PostTypeId="1" AcceptedAnswerId="22987" CreationDate="2016-04-11T03:50:36.533" Score="0" ViewCount="2148" Body="&lt;p&gt;Lets say I have a sketch called &lt;strong&gt;mysketch.ino&lt;/strong&gt; with these contents:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String globalString = &quot;ThisisGlobal&quot;;&#xA;void setup(){}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I pass &lt;strong&gt;THIS&lt;/strong&gt; sketch &lt;code&gt;mysketch.ino&lt;/code&gt; as an object or its reference to a &lt;code&gt;.h&lt;/code&gt; file named&#xA;&lt;code&gt;StringChanger.h&lt;/code&gt; with the following contents, so that &lt;code&gt;StringChanger.h&lt;/code&gt; can change somevariables belonging to &lt;code&gt;mysketch.ino&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class StringChanger{&#xA;   template &amp;lt;typename T&amp;gt; // or type of mySketch.ino i don't know what i'm doing &#xA;   void changeString(T t) {  //a Reference Or Object Or Whatever&#xA;      t.globalString = &quot;GotYouAndChangedYou&quot;;&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wan't to have simple usage in the &lt;code&gt;mySketch.ino&lt;/code&gt;.&#xA;For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;StringChanger.h&quot;&#xA;&#xA;StringChanger change(**this**);  // perhaps default empty constructor here&#xA;&#xA;String globalString = &quot;ThisisGlobal&quot;;&#xA;&#xA;void setup(){&#xA;    change.changeString(); // perhaps pass reference to **this** here&#xA;}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish this (give a class an object so that it can change some value of that object) in general and not neccesarily in this context.&#xA;Errors I currently get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;invalid use of 'this' in non-member function&#xA;invalid use of 'this' at top level.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14904" LastEditorUserId="19515" LastEditDate="2016-04-11T18:15:29.927" LastActivityDate="2016-04-11T18:15:29.927" Title="Arduino OOP and [this] keyword" Tags="|c++|arduino-ide|library|sketch|safety|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="22977" PostTypeId="1" CreationDate="2016-04-11T04:42:36.427" Score="1" ViewCount="122" Body="&lt;p&gt;If one were to want to keep track of data from 80 - 90 accelerometers using arduino, what would be the best way to go about this challenge?&lt;/p&gt;&#xA;" OwnerUserId="20079" LastActivityDate="2016-04-11T06:08:28.940" Title="Managing 80 ~ 90 accelerometers with Arduino" Tags="|accelerometer|multiplexer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22979" PostTypeId="2" ParentId="22977" CreationDate="2016-04-11T05:51:00.457" Score="1" Body="&lt;p&gt;1) Use the I2C address select inputs as an &quot;enable&quot;.  If you run out of I/Os before running out of bus time, drive the enables from an I/O expandander. If your accelerometers are SPI, drive or use the expander to drive the chip selects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Use a tree of slave MCUs (Arduino or otherwise) reading a number of accelerometers, extracting and batching the useful data, and reporting only that upstream to a master.  Probably use whichever of I2C or SPI your accelerometers are not using (SPI can be much faster, so hopefully that).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some accelerometer / gyro parts have an on-board processor which you may be able to program to do some of the data extraction for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider using an FPGA to collect the data.  A commonly available one with enough I/O pins to have a dedicated connection to each accelerometer (and so read them all in parallel) would probably also have the internal resources to implement an Arduino-class soft core processor, if not better.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-11T06:08:28.940" LastActivityDate="2016-04-11T06:08:28.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22982" PostTypeId="1" CreationDate="2016-04-11T06:04:52.153" Score="0" ViewCount="1087" Body="&lt;p&gt;Hi I am making a sketch and circuit with a HC-05 BT receiver to upload sketches via Bluetooth to my Uno.  This requires giving AT commands from the sketch.  I would like to see the response from the HC-05 but so far I haven't got it to work.  I want to view the response via the standard serial connection and serial monitor.  The commands from the sketch are not being recognized by the HC-05 and I would like to see the HC-05 response to troubleshoot it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a minute would you mind giving me a tip?  I would greatly appreciate it.  See the ArdProgramModeOn() and Off functions at the end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;int ATModePin = 2; &amp;nbsp;// pin for HC-05 AT comand mode&#xA;int HC05powerPin = 3; &amp;nbsp;// pin for powering HC-05 when high&#xA;char btserialrx; &amp;nbsp;// data through from bt connection&#xA;char myChar; // data through serial port connection&#xA;#define rxPin 8 // HC-05 bt serial pin&#xA;#define txPin 9 // HC-05 bt serial pin&#xA;&#xA;#include &amp;lt;&lt;b&gt;SoftwareSerial&lt;/b&gt;.h&amp;gt;&#xA;&lt;b&gt;SoftwareSerial&lt;/b&gt; btSerial(rxPin, txPin); // RX, TX&#xA;&#xA;void setup() {&#xA; &amp;nbsp;pinMode(ATModePin, OUTPUT);&#xA; &amp;nbsp;pinMode(HC05powerPin, OUTPUT);&#xA; &amp;nbsp;pinMode(5, OUTPUT);&#xA; &amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.begin(9600); &amp;nbsp;&amp;nbsp;&#xA; &amp;nbsp;btSerial.begin(115200); &#xA; &amp;nbsp;&#xA; &amp;nbsp;digitalWrite(HC05powerPin, HIGH);&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;}&#xA;&#xA;void loop() {&#xA;&#xA; &amp;nbsp;while (btSerial.available()) {&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;btserialrx = btSerial.read();&#xA; &amp;nbsp;}&#xA;&#xA; &amp;nbsp;if(btserialrx == '1'){ &amp;nbsp;// change to upload / reset mode&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.println(&quot;switching to upload mode&quot;);&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ATModeOn();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ArdProgramModeOn();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ATModeOff();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;btserialrx = '0';&#xA; &amp;nbsp;}&#xA; &amp;nbsp;else if (btserialrx == '2'){ &amp;nbsp;// change to normal mode&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.println(&quot;switching to normal mode&quot;);&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ATModeOn();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ArdProgramModeOn();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;ATModeOff();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;btserialrx = '0';&#xA; &amp;nbsp;}&#xA;}&#xA;&#xA;&#xA;void ATModeOn(){ &amp;nbsp;// reset HC-05 and change HC-05 to AT Command Mode&#xA; &amp;nbsp;digitalWrite(5, HIGH);&#xA; &amp;nbsp;digitalWrite(ATModePin, HIGH); // AT command mode on upon reset&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;digitalWrite(HC05powerPin, LOW); // hc-05 off&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;digitalWrite(HC05powerPin, HIGH); // hc-05 on&#xA; &amp;nbsp;delay(2000);&#xA;} &#xA;&#xA;void ATModeOff(){ &amp;nbsp;// reset HC-05 and return HC-05 to std. operation &#xA; &amp;nbsp;digitalWrite(5, LOW);&#xA; &amp;nbsp;digitalWrite(ATModePin, LOW); // AT command mode off upon reset&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;digitalWrite(HC05powerPin, LOW); // hc-05 off&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;digitalWrite(HC05powerPin, HIGH); // hc-05 on&#xA; &amp;nbsp;delay(2000);&#xA;}&#xA;&#xA;void ArdProgramModeOn(){&#xA; &amp;nbsp;btSerial.println(&quot;AT&quot;);&#xA; &amp;nbsp;delay(1000);&#xA; &amp;nbsp;btSerial.println(&quot;AT+POLAR=1,0&quot;); &amp;nbsp;// Arduino reset mode upon HC-05 connection for programming&#xA; &amp;nbsp;delay(1000);&#xA; &amp;nbsp;btSerial.println(&quot;AT+POLAR?&quot;); &amp;nbsp;// Arduino reset mode upon HC-05 connection for programming&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;while (btSerial.available()) { &amp;nbsp;// Show responses from HC-05&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;myChar = btSerial.read();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.print(myChar);&#xA; &amp;nbsp;}&#xA; &amp;nbsp;delay(4000);&#xA;}&#xA;&#xA;void ArdProgramModeOff(){&#xA; &amp;nbsp;btSerial.println(&quot;AT&quot;);&#xA; &amp;nbsp;delay(1000);&#xA; &amp;nbsp;btSerial.println(&quot;AT+POLAR=1,1&quot;); &amp;nbsp;// Arduino normal mode no reset upon HC-05 conection&#xA; &amp;nbsp;delay(1000);&#xA; &amp;nbsp;btSerial.println(&quot;AT+POLAR?&quot;); &amp;nbsp;// Arduino reset mode upon HC-05 connection for programming&#xA; &amp;nbsp;delay(2000);&#xA; &amp;nbsp;while (btSerial.available()) { &amp;nbsp;// Show responses from HC-05&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;myChar = btSerial.read();&#xA; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;Serial&lt;/b&gt;.print(myChar);&#xA; &amp;nbsp;}&#xA; &amp;nbsp;delay(4000);&#xA;}&#xA;&#xA;&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-04-11T07:40:34.587" Title="Controlling HC-05 from a sketch" Tags="|sketch|hc-05|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22983" PostTypeId="2" ParentId="22982" CreationDate="2016-04-11T07:40:34.587" Score="2" Body="&lt;p&gt;Unless you've manually set the btSerial speed, you need to be at the default for AT commands which is 38400 -&gt; btSerial.begin(38400);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to read regular Serial communication, you'll need to monitor 9600 -&gt; btSerial.begin(9600);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are unable to to send commands, I feel as if you wouldn't have changed the default speeds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used this link as a reference with my project: &lt;a href=&quot;http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;Modify The HC-05 Bluetooth Module Defaults Using AT Commands&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, you didn't mention whether or not you soldered a jumper wire to PIN 32 for your ArdProgramOff/On. Another reference for you as well: &lt;a href=&quot;http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/&quot; rel=&quot;nofollow&quot;&gt;DIY Arduino Bluetooth Programming Shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope my answer helps! Good luck!&lt;/p&gt;&#xA;" OwnerUserId="19034" LastActivityDate="2016-04-11T07:40:34.587" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22984" PostTypeId="1" CreationDate="2016-04-11T08:17:57.723" Score="3" ViewCount="1632" Body="&lt;p&gt;Where can I find a hardware manual (documentation or a book) for Arduino board? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know, all hardware details are dispersed (or scatter) in different tutorials.&lt;/p&gt;&#xA;" OwnerUserId="18431" LastEditorUserId="6628" LastEditDate="2022-01-06T18:41:55.550" LastActivityDate="2022-01-06T19:12:09.193" Title="Where can I find a hardware manual (or documentation) for Arduino Uno &amp; ATMega328P?" Tags="|arduino-uno|documentation|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="22985" PostTypeId="2" ParentId="22984" CreationDate="2016-04-11T08:31:46.683" Score="6" Body="&lt;p&gt;The Arduino Uno is little more than an ATmega328P microcontroller. In&#xA;most cases you will be interested by the documentation of the&#xA;microcontroller itself. Anyway, here are both:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno product page&lt;/a&gt; contains the most basic specs, as well as links to&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;board schematic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;http://www.arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow noreferrer&quot;&gt;pin mapping&lt;/a&gt;, but see below for a nicer alternative&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://www.microchip.com/en-us/product/ATmega328P&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328P product page&lt;/a&gt; links to&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061B.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328P family datasheet&lt;/a&gt;, a 650 page authoritative document&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATmega328P Automotive - Complete Datasheet&lt;/a&gt;, specific to the Uno's chip.&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://ww1.microchip.com/downloads/en/DeviceDoc/AVR-InstructionSet-Manual-DS40002198.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR instruction set manual&lt;/a&gt;, for those who want to play with assembly&lt;/li&gt;&#xA;&lt;li&gt;many application notes discussing specific uses of some peripherals&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Alberto (aka PighiXXX) has published nicer versions of the &lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/c/c9/Pinout_of_ARDUINO_Board_and_ATMega328PU.svg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Uno&#xA;pinout&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Um1kq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Um1kq.jpg&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="6628" LastEditDate="2022-01-06T19:12:09.193" LastActivityDate="2022-01-06T19:12:09.193" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="22986" PostTypeId="2" ParentId="22984" CreationDate="2016-04-11T08:43:04.440" Score="3" Body="&lt;p&gt;For the hardware part, you can refer to the schematic. It shows all the components so you can find their datasheets for detailed study.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;UNO schematic&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But to me, if you're just using the board but not designing your own board or writing libraries for the board, I don't think this is necessary. Stick to application level or IO-level and only really dig into the hardware when you're blocked when doing things like using all timers, low-power mode, interrupt with Serial...&lt;/p&gt;&#xA;" OwnerUserId="13176" LastActivityDate="2016-04-11T08:43:04.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22987" PostTypeId="2" ParentId="22976" CreationDate="2016-04-11T09:46:05.210" Score="1" Body="&lt;p&gt;A sketch isn't an object. It is merely a collection of variables, functions and, of course, classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example seems to be trying to make things incredibly complex when they don't need to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of ways of referencing things in one file from another - whether or not they are in a class.  The simplest is to use the &lt;code&gt;extern&lt;/code&gt; keyword.  This is used in a file where you want to reference a variable or function that is defined in the global scope of another file. It says &quot;This variable is global, but it's defined somewhere else.&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sketch&#xA;String myString = &quot;foo&quot;;&#xA;&#xA;// Library&#xA;extern String myString;&#xA;// ... later on ...&#xA;myString = &quot;bar&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, that means that the name of the variable is fixed and cannot change.  So you can pass the variable to whatever it is you want to use that variable in.  That could be as simple as passing it to your &quot;changer&quot; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sketch&#xA;String myString = &quot;foo&quot;;&#xA;StringChanger change;&#xA;// ... later ...&#xA;change.changeString(myString);&#xA;&#xA;// Library&#xA;class StringChanger {&#xA;    public:&#xA;        void changeString(String &amp;amp;stringToChange) {&#xA;            stringToChange = &quot;bar&quot;;&#xA;        }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to &quot;tie&quot; the variable to the class so you don't have to pass it each time you could pass it to the constructor and have the class remember it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Sketch&#xA;String myString = &quot;foo&quot;;&#xA;StringChanger change(myString);&#xA;// ... later ...&#xA;change.changeString();&#xA;&#xA;// Library&#xA;class StringChanger {&#xA;    private:&#xA;        String *_string;&#xA;    public:&#xA;        StringChanger(String &amp;amp;string) {&#xA;            _string = &amp;amp;string;&#xA;        }&#xA;        void changeString() {&#xA;            *_string = &quot;bar&quot;;&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And there's a myriad of other ways of doing it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-11T09:46:05.210" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="22988" PostTypeId="2" ParentId="22955" CreationDate="2016-04-11T10:52:09.677" Score="0" Body="&lt;p&gt;First thing to do is find out whether your problem is electrical or not.&lt;br&gt;&#xA;This can be done by removing the electrical parts not crucial to run the code.&lt;br&gt;&#xA;If the problem is code related try using another board to eliminate some hardware malfunction on your board.&lt;br&gt;&#xA;Doing these steps will give you some insight on the root cause of the problem.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-04-11T10:52:09.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22990" PostTypeId="2" ParentId="22958" CreationDate="2016-04-11T12:33:48.027" Score="1" Body="&lt;p&gt;That is what I would expect to see with one of these sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure on the wiring, I think you &lt;em&gt;may&lt;/em&gt; be wrong.  Have a read of &lt;a href=&quot;http://playground.arduino.cc/Main/MQGasSensors#readdatasheet&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/MQGasSensors#readdatasheet&lt;/a&gt; and see if you agree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Did you leave the sensor to warm up?  It takes a few minutes (from memory) and until its warm it won't give you a proper reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An MQ4 should be able to detect Methane, butane and propane, so was your lighter using on of these gasses?  When it does detect the target gas, the number will go up, and stay up for a while.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing you can try is blowing on the sensor, the results will vary depending on what you have been eating, but it should shift one way or another.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it still doesn't work then buzz out your connections, just to triple check, and re-read the manual.  &lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-11T12:33:48.027" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="22991" PostTypeId="1" CreationDate="2016-04-11T14:48:06.570" Score="0" ViewCount="1023" Body="&lt;p&gt;I have an Arduino Uno and I have a remote sensing project for which I need Wifi connectivity. After doing research, I've found that I have 2 options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Buy a WiFi shield for my existing Uno&lt;/li&gt;&#xA;&lt;li&gt;Buy an Arduino Yun with built-in WiFi&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Looking at costs, I found that a WiFi shield costs more than double what it costs to buy a Yun, so it would seem to me that the best option is the Yun as I'd save some cash and get a more capable board. However, I can't help but think I'm missing something. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the advantages of an Uno plus Wifi shield as opposed to a Yun?&lt;/p&gt;&#xA;" OwnerUserId="7951" LastEditorUserId="25757" LastEditDate="2017-05-19T14:32:31.920" LastActivityDate="2017-05-19T14:32:31.920" Title="Are there any advantages to Wifi shields as opposed to a Yun?" Tags="|arduino-uno|shields|wifi|arduino-yun|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22993" PostTypeId="2" ParentId="22991" CreationDate="2016-04-11T16:26:54.703" Score="4" Body="&lt;p&gt;There's a number of things to consider that could sway your choice one way or another:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Power consumption&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The Uno is a small low-power chip to which you add WiFi. The Yun is an Arduino Leonardo with a WiFi router (like you have on your desk) strapped to the back of it.  The Yun will therefore consume considerably more power than the Uno.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Boot time&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The Uno takes about 1 second to boot up - faster (instant) if you remove the bootloader and program it direct with a programmer.  The Yun takes minutes to boot.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Stability&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The Uno is a solid state single item. The Yun has an entire operating system with filesystems and things.  It's far more likely that the Yun will corrupt itself through power loss than an Uno will get struck by a stray neutrino.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Cost&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Yes, the Yun is cheaper. But is cheap always good?&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Remote-ability&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The Yun can be completely reprogrammed remotely. A new sketch can be uploaded to the Leonardo portion of it without you even having to be in the same country. The same can't be said for the Uno.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Power&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The Linux portion of the Yun is considerably more powerful than any normal Arduino. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-11T20:11:42.700" LastActivityDate="2016-04-11T20:11:42.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="22994" PostTypeId="1" CreationDate="2016-04-11T16:42:21.030" Score="3" ViewCount="32915" Body="&lt;p&gt;I want to know how much time has elapsed since a certain event, and I do not want to use any external timers. It seems logical to reset an internal timer whenever the event occurs (using an interrupt). Unfortunately, as far as I can tell, &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt; cannot be manually reset. Obviously, I could save a time stamp whenever the event occurs; however, I want to avoid overflow problems (&lt;code&gt;micros()&lt;/code&gt; will overflow every ~71 minutes, and &lt;code&gt;millis()&lt;/code&gt; will overflow every ~50 days).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to manually reset these built-in counters? If not, how can I manage the overflow?&lt;/p&gt;&#xA;" OwnerUserId="19617" LastEditorUserId="19515" LastEditDate="2016-04-11T16:51:45.073" LastActivityDate="2016-04-11T22:04:13.153" Title="Resetting millis() and micros()" Tags="|programming|time|millis|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22995" PostTypeId="1" AcceptedAnswerId="23104" CreationDate="2016-04-11T16:59:02.280" Score="1" ViewCount="2133" Body="&lt;p&gt;I have an Arduino connected to a stepper motor with an Easy Driver as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bjU3t.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bjU3t.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am controlling the position of the stepper motor using the Serial. This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;AccelStepper stepper(1, 9, 8);&#xA;&#xA;void setup()&#xA;{  &#xA;  Serial.begin(9600);&#xA;  stepper.setMaxSpeed(10000);&#xA;  stepper.setAcceleration(5000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  char c;&#xA;  if(Serial.available())  &#xA;  {  &#xA;   int steps = Serial.parseInt();&#xA;   Serial.print(steps);&#xA;   stepper.moveTo(steps);&#xA;&#xA;  }&#xA;  stepper.run();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code works well but I'm facing a problem, when I set a high position value, it starts turning in the opposite direction, like if there was a limit on the steps. Does anyone know why it starts turning to the opposite direction? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to solve this problem by using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (stepper1.distanceToGo() == 0)        &#xA;         { &#xA;            stepper1.setCurrentPosition(0);&#xA;         }  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I can set lower values to the serial. But the problem goes back again when the value goes up to the power of 6 (like 1000000).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="13316" LastEditorUserId="19515" LastEditDate="2016-04-11T18:18:45.810" LastActivityDate="2016-05-14T03:12:13.707" Title="Problem controlling a Stepper motor with AccelStepper" Tags="|motor|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22996" PostTypeId="2" ParentId="22994" CreationDate="2016-04-11T17:28:57.387" Score="6" Body="&lt;p&gt;&lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt; overflow periodically. However, this is not a&#xA;problem: as long as you &lt;a href=&quot;https://arduino.stackexchange.com/questions/12587&quot;&gt;compare durations instead of&#xA;timestamps&lt;/a&gt; you can&#xA;forget about the overflows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The liked answer also gives the trick for resetting &lt;code&gt;millis()&lt;/code&gt;. Can be&#xA;handy for testing purposes, but &lt;em&gt;you do not need this&lt;/em&gt; to handle the&#xA;millis() rollover problem. Notice that there is no clean way to reset&#xA;&lt;code&gt;micros()&lt;/code&gt;: it relies on a &lt;code&gt;static&lt;/code&gt; variable, i.e. a variable private to&#xA;the file defining it.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-04-11T17:48:01.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22997" PostTypeId="2" ParentId="22994" CreationDate="2016-04-11T17:29:08.963" Score="5" Body="&lt;p&gt;Overflow is never really an issue if you always calculate time difference. (Unless the time difference is more that 50 days.)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousTime = millis();&#xA;... wait for some event to happen ...&#xA;unsigned long elapsedTime =  millis() - previousTime;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even if &lt;code&gt;previousTime&lt;/code&gt; was before the overflow, and &lt;code&gt;millis()&lt;/code&gt; is after the overflow (so essentially &lt;code&gt;millis()&lt;/code&gt;&amp;lt;&lt;code&gt;previousTime&lt;/code&gt;), &lt;code&gt;elapsedTime&lt;/code&gt; will still be the correct value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because the calculation itself will also overflow. Since &lt;code&gt;millis()&lt;/code&gt;&amp;lt;&lt;code&gt;previousTime&lt;/code&gt;, the result would be negative, but the type of the variable is &lt;code&gt;unsigned&lt;/code&gt;, so it wraps around. I hope that makes sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just don't ever do something like &lt;code&gt;if( millis() &amp;gt; (previousTime+1000) )&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you still want to reset millis, you can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;extern volatile unsigned long timer0_millis;&#xA;unsigned long new_value = 0;&#xA;&#xA;void setup(){&#xA;  //Setup stuff&#xA;}&#xA;&#xA;void loop(){&#xA;  //Do stuff&#xA;  //--------&#xA;&#xA;  //Change Millis&#xA;  setMillis(new_value);&#xA;}&#xA;&#xA;void setMillis(unsigned long new_millis){&#xA;  uint8_t oldSREG = SREG;&#xA;  cli();&#xA;  timer0_millis = new_millis;&#xA;  SREG = oldSREG;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-11T17:29:08.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="22998" PostTypeId="1" AcceptedAnswerId="23001" CreationDate="2016-04-11T18:16:45.043" Score="0" ViewCount="785" Body="&lt;p&gt;I am quite new to C++ and hope that I don't bore you too much with my question. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use an object of LiquidCrystal Class in another class called &quot;Display_ManagerClass&quot;. I followed the instructions of the 2nd alternative in the following link:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/9296/use-object-of-other-class-within-class?newreg=5dd627937c1c4f94a0a47480f249445b&quot;&gt;Use object of other class within class&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, I receive a linker error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;.ino-file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Licht_Manager.h&quot;&#xA;#include &quot;Display_Manager.h&quot;&#xA;#include &quot;Zeit_Manager.h&quot;&#xA;&#xA;LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;    Licht_Manager.init();&#xA;    Display_Manager.init(&amp;amp;lcd);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;    Display_Manager.showText(&quot;Hello&quot;, &quot;World&quot;);&#xA;    while (1)&#xA;    {&#xA;        Licht_Manager.blink(1); &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Display_Manager.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _DISPLAY_MANAGER_h&#xA;#define _DISPLAY_MANAGER_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;    #include &quot;arduino.h&quot;    &#xA;#else&#xA;    #include &quot;WProgram.h&quot;&#xA;#endif&#xA;&#xA;#include &amp;lt;LiquidCrystal/src/LiquidCrystal.h&amp;gt;&#xA;&#xA;class Display_ManagerClass&#xA;{&#xA;    protected:&#xA;&#xA;    public:&#xA;        //void init();&#xA;        void init(LiquidCrystal* _p_lcd);&#xA;        void showText(String DisplayText1, String DisplayText2);&#xA;    private:&#xA;        LiquidCrystal* p_lcd;&#xA;&#xA;};&#xA;&#xA;extern Display_ManagerClass Display_Manager;&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Display_Manager.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Display_Manager.h&quot;&#xA;&#xA;void Display_ManagerClass::init(LiquidCrystal* _p_lcd)&#xA;{&#xA;    p_lcd = _p_lcd;&#xA;    p_lcd-&amp;gt;clear();&#xA;}&#xA;&#xA;void Display_ManagerClass::showText(String DisplayText1, String DisplayText2)&#xA;{&#xA;    p_lcd-&amp;gt;clear();&#xA;    p_lcd-&amp;gt;setCursor(0,0);&#xA;    p_lcd-&amp;gt;print(DisplayText1);&#xA;    p_lcd-&amp;gt;setCursor(0,1);&#xA;    p_lcd-&amp;gt;print(DisplayText2);&#xA;}&#xA;&#xA;Display_ManagerClass Display_Manager;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I receive the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Display_Manager.cpp.o:In function `Display_ManagerClass::init(LiquidCrystal*)&#xA;Display_Manager.cpp:clear()&#xA;Display_Manager.cpp.o:In function `Display_ManagerClass::showText(String, String)&#xA;Display_Manager.cpp:clear()&#xA;Display_Manager.cpp:setCursor(unsigned char, unsigned char)&#xA;Display_Manager.cpp:setCursor(unsigned char, unsigned char)&#xA;collect2.exe*:error: ld returned 1 exit status&#xA;Error creating .elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made sure that the correct directory of the library is set up in the project properties. The library also works in the normal way, but in combination with the class it doesn't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I work with Atmel Studio 7 in combination with VisualMicro, Arduino IDE 1.6 and Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="20094" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-11T21:10:07.843" Title="Use object of LiquidCrystal class within another class" Tags="|arduino-uno|lcd|class|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="22999" PostTypeId="1" CreationDate="2016-04-11T19:02:18.823" Score="1" ViewCount="361" Body="&lt;p&gt;I found this &lt;a href=&quot;https://arduino.stackexchange.com/questions/3079/how-to-retrieve-the-data-type-of-a-variable&quot;&gt;post&lt;/a&gt; and implemented the code in a separate classed and then passed different variables to it in an attempt to get the type name printed to serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code compiled and worked fine but i get the following strange output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;For type int I get Fn on the serial monitor&#xA;For String I get ;y on the serial monitor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I don't make a type using &lt;code&gt;MAKE_TYPE_INFO(type)&lt;/code&gt; then try &lt;code&gt;TYPE_NAME()&lt;/code&gt; I don't get &lt;code&gt;unknown&lt;/code&gt; printed on the serial monitor. I get &lt;code&gt;fÝ&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this weirdness is consistent and I could use it to make decisions based on type but why do that if their is a solution.&lt;/p&gt;&#xA;" OwnerUserId="14904" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-04-11T19:44:25.540" Title="How to get Type name of a variable on Arduino" Tags="|serial|variables|data-type|" AnswerCount="0" CommentCount="3" ClosedDate="2017-11-17T03:11:00.537" ContentLicense="CC BY-SA 3.0" />
  <row Id="23000" PostTypeId="2" ParentId="22991" CreationDate="2016-04-11T20:31:19.523" Score="1" Body="&lt;p&gt;First of all yun is not the same as uno + wifi shield. yun is more like a linux pcc with wifi and a lenoardo.&lt;br&gt;&#xA;If you are asking for your options there are more options. For what you want I would go for a ESP8266. Again there are 2 options here:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;uno + ESP8266 (as a wifi shield)&lt;/li&gt;&#xA;&lt;li&gt;ESP8266 (as a dev board)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I think it is pretty obvious that the ESP8266 (as a dev board) is the most cost effective.&lt;br&gt;&#xA;You can program the ESP8266 just like a uno in the arduino IDE.&lt;br&gt;&#xA;So I would advice to take that board.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-04-11T20:31:19.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23001" PostTypeId="2" ParentId="22998" CreationDate="2016-04-11T21:10:07.843" Score="1" Body="&lt;p&gt;You must also include &lt;code&gt;LiquidCrystal.h&lt;/code&gt; in your sketch. That way the IDE will know to include it in the list of files to compile and link with your sketch.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-11T21:10:07.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23004" PostTypeId="1" AcceptedAnswerId="23016" CreationDate="2016-04-11T22:03:17.210" Score="0" ViewCount="319" Body="&lt;p&gt;I'm trying to post data from my Arduino due to my web server (php) through POST using the CC3000 breakout board and for some reason, data with content length more than 104 is not being sent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried posting directly with postmaster with content length value greater than 104 to verify that it wasn't my server denying the request and it wasn't. So something with the Arduino or cc3000? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now, my post request looks like this which works:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POST /new/path/post.php HTTP/1.1&#xA;Host:  www.mywebsite.com&#xA;User-Agent: Arduino/1.0&#xA;Connection: close&#xA;Content-Type: application/x-www-form-urlencoded; charset=UTF-8&#xA;Content-Length: 104&#xA;&#xA;userId=32&amp;amp;sscId=43&amp;amp;raVal=52&amp;amp;cvVal=62&amp;amp;bbvfgTempInF=723&amp;amp;bbvfgLevel=82345&amp;amp;humidity=92&amp;amp;lmassLevel=0283838383&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the one that doesn't (notice only one character difference in userId): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POST /new/path/post.php HTTP/1.1&#xA;Host:  www.mywebsite.com&#xA;User-Agent: Arduino/1.0&#xA;Connection: close&#xA;Content-Type: application/x-www-form-urlencoded; charset=UTF-8&#xA;Content-Length: 105&#xA;&#xA;userId=322&amp;amp;sscId=43&amp;amp;raVal=52&amp;amp;cvVal=62&amp;amp;bbvfgTempInF=723&amp;amp;bbvfgLevel=82345&amp;amp;humidity=92&amp;amp;lmassLevel=0283838383&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is my full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &quot;utility/debug.h&quot;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   28  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  26&#xA;#define ADAFRUIT_CC3000_CS    22&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;                                         SPI_CLOCK_DIVIDER); // you can change this clock speed&#xA;&#xA;#define WLAN_SSID       &quot;mynetwork&quot;   // cannot be longer than 32 characters!&#xA;#define WLAN_PASS       &quot;mypassword&quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;#define IDLE_TIMEOUT_MS  10000      // Amount of time to wait (in milliseconds) with no data &#xA;                                   // received before closing the connection.  If you know the server&#xA;                                   // you're accessing is quick to respond, you can reduce this value.&#xA;&#xA;&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Sets up the HW and the CC3000 module (called automatically&#xA;            on startup)&#xA;*/&#xA;/**************************************************************************/&#xA;&#xA;uint32_t ip;&#xA;&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); &#xA;&#xA;  Serial.print(&quot;Free RAM: &quot;); Serial.println(getFreeRam(), DEC);&#xA;&#xA;  /* Initialise the module */&#xA;  Serial.println(F(&quot;\nInitializing...&quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  // Optional SSID scan&#xA;  // listSSIDResults();&#xA;&#xA;  Serial.print(F(&quot;\nAttempting to connect to &quot;)); Serial.println(WLAN_SSID);&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Failed!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Connected!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Request DHCP&quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;&#xA;  /* Display the IP address DNS, Gateway, etc. */  &#xA;  while (! displayConnectionDetails()) {&#xA;    delay(1000);&#xA;  }&#xA;&#xA;  ip = 0;&#xA;  // Try looking up the website's IP address&#xA;  Serial.print(WEBSITE); Serial.print(F(&quot; -&amp;gt; &quot;));&#xA;  while (ip == 0) {&#xA;    if (! cc3000.getHostByName(WEBSITE, &amp;amp;ip)) {&#xA;      Serial.println(F(&quot;Couldn't resolve!&quot;));&#xA;    }&#xA;    delay(500);&#xA;  }&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;&#xA;  // Optional: Do a ping test on the website&#xA;  /*&#xA;  Serial.print(F(&quot;\n\rPinging &quot;)); cc3000.printIPdotsRev(ip); Serial.print(&quot;...&quot;);  &#xA;  replies = cc3000.ping(ip, 5);&#xA;  Serial.print(replies); Serial.println(F(&quot; replies&quot;));&#xA;  */  &#xA;&#xA;  /* Try connecting to the website.&#xA;     Note: HTTP/1.1 protocol is used to keep the server from closing the connection before all data is read.&#xA;  */&#xA;  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);&#xA;  if (www.connected()) {&#xA;    Serial.println(&quot;Connected&quot;);    &#xA;    String PostDatat = &quot;userId=32&amp;amp;sscId=43&amp;amp;raVal=52&amp;amp;cvVal=62&amp;amp;bbvfgTempInF=723&amp;amp;bbvfgLevel=82345&amp;amp;humidity=92&amp;amp;lmassLevel=0283838383&quot;;&#xA;&#xA;&#xA;    Serial.println();&#xA;    Serial.println(&quot;POST /new/path/post.php HTTP/1.1&quot;);&#xA;    Serial.println(&quot;Host: www.mywebsite.com&quot;);&#xA;    Serial.println(&quot;User-Agent: Arduino/1.0&quot;);&#xA;    Serial.println(&quot;Connection: close&quot;);&#xA;    Serial.println(&quot;Content-Type: application/x-www-form-urlencoded; charset=UTF-8&quot;);&#xA;    Serial.print(&quot;Content-Length: &quot;);&#xA;    Serial.println(PostDatat.length());&#xA;    Serial.println();&#xA;    Serial.println(PostDatat);&#xA;&#xA;    //HANGS HERE IF CONTENT LENGTH &amp;gt; 104&#xA;&#xA;    www.println(&quot;POST /new/path/post.php HTTP/1.1&quot;);&#xA;    www.println(&quot;Host: www.mywebsite.com&quot;);&#xA;    www.println(&quot;User-Agent: Arduino/1.0&quot;);&#xA;    www.println(&quot;Connection: close&quot;);&#xA;    www.println(&quot;Content-Type: application/x-www-form-urlencoded; charset=UTF-8&quot;);&#xA;    www.print(&quot;Content-Length: &quot;);&#xA;    www.println(PostDatat.length());&#xA;    www.println();&#xA;    www.println(PostDatat);&#xA;&#xA;    Serial.println();&#xA;    Serial.println(&quot;POST /new/path/post.php HTTP/1.1&quot;);&#xA;    Serial.println(&quot;Host:  www.mywebsite.com&quot;);&#xA;    Serial.println(&quot;User-Agent: Arduino/1.0&quot;);&#xA;    Serial.println(&quot;Connection: close&quot;);&#xA;    Serial.println(&quot;Content-Type: application/x-www-form-urlencoded; charset=UTF-8&quot;);&#xA;    Serial.print(&quot;Content-Length: &quot;);&#xA;    Serial.println(PostDatat.length());&#xA;    Serial.println();&#xA;    Serial.println(PostDatat);&#xA;&#xA;    Serial.println(&quot;SENT&quot;);&#xA;  } else {&#xA;    Serial.println(F(&quot;Connection failed&quot;));    &#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;-------------------------------------&quot;));&#xA;&#xA;  /* Read data until either the connection is closed, or the idle timeout is reached. */ &#xA;  unsigned long lastRead = millis();&#xA;  while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    while (www.available()) {&#xA;      char c = www.read();&#xA;      Serial.print(c);&#xA;      lastRead = millis();&#xA;    }&#xA;  }&#xA;  www.close();&#xA;  Serial.println(F(&quot;-------------------------------------&quot;));&#xA;&#xA;  /* You need to make sure to clean up after yourself or the CC3000 can freak out */&#xA;  /* the next time your try to connect ... */&#xA;  Serial.println(F(&quot;\n\nDisconnecting&quot;));&#xA;  cc3000.disconnect();&#xA;&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA; delay(1000);&#xA;}&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Begins an SSID scan and prints out all the visible networks&#xA;*/&#xA;/**************************************************************************/&#xA;&#xA;void listSSIDResults(void)&#xA;{&#xA;  uint32_t index;&#xA;  uint8_t valid, rssi, sec;&#xA;  char ssidname[33]; &#xA;&#xA;  if (!cc3000.startSSIDscan(&amp;amp;index)) {&#xA;    Serial.println(F(&quot;SSID scan failed!&quot;));&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;Networks found: &quot;)); Serial.println(index);&#xA;  Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;  while (index) {&#xA;    index--;&#xA;&#xA;    valid = cc3000.getNextSSID(&amp;amp;rssi, &amp;amp;sec, ssidname);&#xA;&#xA;    Serial.print(F(&quot;SSID Name    : &quot;)); Serial.print(ssidname);&#xA;    Serial.println();&#xA;    Serial.print(F(&quot;RSSI         : &quot;));&#xA;    Serial.println(rssi);&#xA;    Serial.print(F(&quot;Security Mode: &quot;));&#xA;    Serial.println(sec);&#xA;    Serial.println();&#xA;  }&#xA;  Serial.println(F(&quot;================================================&quot;));&#xA;&#xA;  cc3000.stopSSIDscan();&#xA;}&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Tries to read the IP address and other connection details&#xA;*/&#xA;/**************************************************************************/&#xA;bool displayConnectionDetails(void)&#xA;{&#xA;  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;  if(!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv, &amp;amp;dnsserv))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;    return false;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;    Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;    Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;    Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;    Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;    Serial.println();&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So after running this code and changing the PostDatat variable to the two data being 104 char long and 105 char long, the 104 char long goes all the way through and prints the message &lt;code&gt;SENT&lt;/code&gt; to the Serial monitor. But the 105 char long just hangs after the first &lt;code&gt;Serial.println()&lt;/code&gt; blocks and before the &quot;www.println(...&quot; Has anyone had or encountered this problem or can suggest a solution to this? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20098" LastEditorUserId="19515" LastEditDate="2016-04-12T03:00:03.650" LastActivityDate="2016-04-15T00:35:05.797" Title="CC3000 cannot sending post data with content length more than 104" Tags="|arduino-due|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23005" PostTypeId="2" ParentId="22994" CreationDate="2016-04-11T22:04:13.153" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems logical to reset an internal timer whenever the event occurs (using an interrupt). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No it doesn't. You don't reset your clock to 00:00 when you put a cake in the oven do you?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you do is note the time. Then periodically you subtract the start time from the current time, giving you the elapsed time. When time is up, you remove the cake from the oven.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Think about it for a minute. What if you wanted to time &lt;strong&gt;two&lt;/strong&gt; events? Setting millis back to zero would hardly work then, would it? Setting it to zero for the second event would corrupt your timing for the first event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However &lt;em&gt;noting the time&lt;/em&gt; each one starts, and comparing the time &lt;em&gt;now&lt;/em&gt; to the start time, will work for any number of events.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For more details see my post about &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12127&quot; rel=&quot;nofollow&quot;&gt;millis() overflow ... a bad thing?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-11T22:04:13.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23006" PostTypeId="1" CreationDate="2016-04-11T09:54:47.643" Score="2" ViewCount="14929" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bWNb9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bWNb9.jpg&quot; alt=&quot;raindrop&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am working on a protection circuit with 2 raindrop sensors which would be hooked onto the arduinos 2 interrupt pins and as soon as they detect water they shut some relays off, turn a red led on and exit() the main program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These sensors I have order are working fine as regular input pins with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// lowest and highest sensor readings:&#xA;const int sensorMin = 0;     // sensor minimum&#xA;const int sensorMax = 1024;  // sensor maximum&#xA;&#xA;void setup() {&#xA;  // initialize serial communication @ 9600 baud:&#xA;  Serial.begin(9600);  &#xA;}&#xA;void loop() {&#xA;  // read the sensor on analog A0:&#xA;    int sensorReading = analogRead(A0);&#xA;  // map the sensor range (four options):&#xA;  // ex: 'long int map(long int, long int, long int, long int, long int)'&#xA;    int range = map(sensorReading, sensorMin, sensorMax, 0, 3);&#xA;&#xA;  // range value:&#xA;  switch (range) {&#xA; case 0:    // Sensor getting wet&#xA;    Serial.println(&quot;Flood&quot;);&#xA;    break;&#xA; case 1:    // Sensor getting wet&#xA;    Serial.println(&quot;Rain Warning&quot;);&#xA;    break;&#xA; case 2:    // Sensor dry - To shut this up delete the &quot; Serial.println(&quot;Not Raining&quot;); &quot; below.&#xA;    Serial.println(&quot;Not Raining&quot;);&#xA;    break;&#xA;  }&#xA;  delay(1);  // delay between reads&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I will use the digital output not the analog but this doesn't change much. For the digital the pin is up at 5V at start and will be put to LOW once water is detected by the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I using the mega right now for breadbording but micro will be the final board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both the mega+micro should have 2,3 as interrupt pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mega, Mega2560, MegaADK 2, 3, 18, 19, 20, 21&#xA;Micro, Leonardo, other 32u4-based   0, 1, 2, 3, 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have modified the following code and tried all conditions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LOW to trigger the interrupt whenever the pin is low,&#xA;CHANGE to trigger the interrupt whenever the pin changes value&#xA;RISING to trigger when the pin goes from low to high,&#xA;FALLING for when the pin goes from high to low. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't respond to any (the same time as I said the pin works fine as regular input).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here in the setup I know that I am not using&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(interruptPin, myISR, FALLING); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;that is because the IDE doesn't recognize this function. Is there any problem with the code? If I understand interrupts correctly I don't even need to check for that if ( ISRRan ) to break off the while loop, once the interrupt comes in the ardu SHOULD be running my interrupt function and immediately run the protection code then abort.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte interruptPin = 0;  // your interrupt pin&#xA;volatile boolean ISRRan = 0;  // this variable is set in your ISR to trigger a break in the while loop&#xA;byte C = 0;  // this is just the counter var for the while loop&#xA;&#xA;void setup() {&#xA; attachInterrupt(interruptPin, myISR, FALLING); &#xA;}&#xA;&#xA;void myISR() {&#xA; ISRRan = 1;&#xA; // do other things in the ISR&#xA;}&#xA;&#xA;void loop() {&#xA; while ( C &amp;lt; 10 ) {&#xA;   if ( ISRRan ) {&#xA;     break;&#xA;   }&#xA;   //doing something inside the while loop&#xA; C++;&#xA; }&#xA; // do other things outside of the while loop&#xA; ISRRan = 0;  // Reset for whatever reason&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="reaverx" LastEditorUserId="6628" LastEditDate="2016-04-13T17:37:21.850" LastActivityDate="2016-10-11T00:02:32.960" Title="digitalPinToInterrupt() doesn't work" Tags="|interrupt|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23007" PostTypeId="2" ParentId="23006" CreationDate="2016-04-11T14:46:04.377" Score="2" Body="&lt;p&gt;I have solved this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was with the pinout indeed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, myISR, FALLING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will use the DIGITAL PIN 2&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was using attachInterrupt 2, that's all.&lt;/p&gt;&#xA;" OwnerDisplayName="reaverx" LastActivityDate="2016-04-11T15:07:03.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23008" PostTypeId="1" CreationDate="2016-04-11T22:53:50.617" Score="1" ViewCount="292" Body="&lt;p&gt;I have a AC to DC converter that was originally used for recharging the PSP, I stripped the 2 wires of the output and was wanting to use it for my arduino instead of using a 9V battery, it's output is 5V 2000MA, is there a way to reduce the current in order to use it for the arduino and im guessing the 5V is enough to power it...right? Im kinda new to electronics and the arduino so any help is much appreciated :D.&#xA;Thanks,&#xA;Liam.&lt;/p&gt;&#xA;" OwnerUserId="20099" LastActivityDate="2016-04-12T01:09:52.200" Title="How to reduce current from a AC TO DC power supply for arduino use" Tags="|arduino-uno|power|voltage-level|current|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23010" PostTypeId="1" CreationDate="2016-04-11T23:37:23.027" Score="0" ViewCount="4105" Body="&lt;p&gt;I'm relatively new to arduino thus need your help to figure out why my stepper motor doesn't rotate clockwise and counterclockwise. All I could do was to make it rotate only in one direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;int pos=16000;&#xA;AccelStepper stepper(1,4,5);&#xA;&#xA;void setup() {&#xA;stepper.moveTo(pos);&#xA;stepper.setMaxSpeed(6400);&#xA;stepper.setSpeed(6400);&#xA;}&#xA;&#xA;void loop() {&#xA;if (stepper.distanceToGo() == 0)&#xA;{   &#xA;  stepper.setCurrentPosition(0);  &#xA;  pos = -pos;  &#xA;  stepper.moveTo(pos);  &#xA;  stepper.setSpeed(6400);&#xA;}&#xA;   stepper.runSpeed();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will appreciate any help you can give me :)&lt;/p&gt;&#xA;" OwnerUserId="20100" LastActivityDate="2016-04-14T01:08:38.677" Title="Can't make my stepper motor run clockwise and counterclockwise with AccelStepper Library" Tags="|arduino-uno|motor|stepper|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23012" PostTypeId="2" ParentId="23008" CreationDate="2016-04-12T01:09:52.200" Score="4" Body="&lt;p&gt;You don't need to reduce the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2000MA (2 amps) means the power supply is CAPABLE of supplying this (without overheating). Anything less than this, and your device will work perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your Arduino will DRAW a certain number of milliamps (amps), this is the amount of current that will ACTUALLY run through your circuit. &lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-04-12T01:09:52.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23013" PostTypeId="1" CreationDate="2016-04-12T02:01:08.047" Score="0" ViewCount="129" Body="&lt;p&gt;Unless my multimeter is on the fritz, it would seem my &lt;a href=&quot;https://learn.adafruit.com/introducing-trinket?view=all&quot; rel=&quot;nofollow noreferrer&quot;&gt;5V Adafruit Trinket&lt;/a&gt; is only outputting 3.3V when connected w/ DC power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When connected via USB, totally fun. Full 5V. But if I disconnect that and connect a 9V wall adapter, the output of the 5V pinout is just giving me 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is that even possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I noticed the issue b/c my program wasn't running properly when connected via the DC adapter (but ran just fine via USB). So I tested the voltage and sure enough, 3.3V all around at basically every +/- connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IonR3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IonR3.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tPVBp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tPVBp.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-04-12T03:42:13.237" Title="5V Trinket only outputting 3.3V?" Tags="|voltage-level|adafruit|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23014" PostTypeId="1" CreationDate="2016-04-12T01:00:13.463" Score="2" ViewCount="186" Body="&lt;p&gt;Hi there I just need to ask you how I can send command from master robot to slave to follow using XBee. I have configured both the XBee in AT mode, but I totally don't have the clue how the program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following kit components (from DF ROBOT) to build this project,&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Romeo V2-All in one Controller (Arduino based controller).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Differential drive chasis with caster ball.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Wheel Encoders.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;XBee 2mW PCB Antenna - Series 2 (ZigBee Mesh)  Transceiver module for the communication between two robots.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;IR sensors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;6.Micro DC Geared Motor w/ Back Shaft (180rpm 6V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have done the programming for obstacle detection, positioning of robot, but I have no idea how to do the master slave programming logic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me on this. Here attached the code I have done till now:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const int InfraredSensorPin1 = 6;//Connect the signal pin to the digital pin 6&#xA;int detected2;&#xA;int detected1;&#xA;const int InfraredSensorPin2 = 9 ; &#xA;&#xA;int E1 = 5;     //M1 Speed Control&#xA;int E2 = 6;     //M2 Speed Control&#xA;int M1 = 4;    //M1 Direction Control&#xA;int M2 = 7;    //M1 Direction Control&#xA;&#xA;#define LEFT 0&#xA;#define RIGHT 1&#xA;int value;&#xA;long coder[2] = {&#xA;  0, 0&#xA;};&#xA;int lastSpeed[2] = {&#xA;  0, 0&#xA;};&#xA;&#xA;void stop(void)                    //Stop&#xA;{&#xA;  digitalWrite(E1, 0);&#xA;  digitalWrite(M1, LOW);&#xA;  digitalWrite(E2, 0);&#xA;  digitalWrite(M2, LOW);&#xA;}&#xA;void advance(char a, char b)         //Move forward&#xA;{&#xA;  analogWrite (E1, a);&#xA;  digitalWrite(M1, HIGH);&#xA;  analogWrite (E2, b);&#xA;  digitalWrite(M2, HIGH);&#xA;}&#xA;void back_off (char a, char b)         //Move backward&#xA;{&#xA;  analogWrite (E1, a);&#xA;  digitalWrite(M1, LOW);&#xA;  analogWrite (E2, b);&#xA;  digitalWrite(M2, LOW);&#xA;}&#xA;void turn_L (char a, char b)            //Turn Left&#xA;{&#xA;  analogWrite (E1, a);&#xA;  digitalWrite(M1, LOW);&#xA;  analogWrite (E2, b);&#xA;  digitalWrite(M2, HIGH);&#xA;}&#xA;void turn_R (char a, char b)            //Turn Right&#xA;{&#xA;  analogWrite (E1, a);&#xA;  digitalWrite(M1, HIGH);&#xA;  analogWrite (E2, b);&#xA;  digitalWrite(M2, LOW);&#xA;}&#xA;&#xA;void setup(void)&#xA;{ Serial.println(&quot;Start!&quot;);&#xA;&#xA; pinMode(InfraredSensorPin1, INPUT);&#xA; pinMode(InfraredSensorPin2, INPUT);&#xA;&#xA;advance(200,200);&#xA;  Serial.begin(19200);      //Set Baud Rate//&#xA;  attachInterrupt(LEFT, LwheelSpeed, CHANGE);    //init the interrupt mode for the digital pin 2&#xA;  attachInterrupt(RIGHT, RwheelSpeed, CHANGE);   //init the interrupt mode for the digital pin 3&#xA;}&#xA;void loop(void)&#xA;{&#xA;  if((InfraredSensorPin1==LOW&amp;amp;&amp;amp;!InfraredSensorPin2==LOW)||(InfraredSensorPin1==LOW&amp;amp;&amp;amp;InfraredSensorPin2==LOW))&#xA;  turn_L (100,100);&#xA;&#xA;  else if ((InfraredSensorPin2==LOW&amp;amp;&amp;amp;!InfraredSensorPin1==LOW)||(InfraredSensorPin2==LOW&amp;amp;&amp;amp;InfraredSensorPin1==LOW))&#xA;  turn_R (100,100);&#xA;&#xA;  else  &#xA;  advance (80,80);&#xA;  static unsigned long timer = 0;                //print manager timer&#xA;  if (millis() - timer &amp;gt; 5) {&#xA;    Serial.print(&quot;Coder value: &quot;);&#xA;    Serial.print(coder[LEFT]);&#xA;    Serial.print(&quot;[Left Wheel] &quot;);&#xA;    Serial.print(coder[RIGHT]);&#xA;    Serial.println(&quot;[Right Wheel]&quot;);&#xA;&#xA;    lastSpeed[LEFT] = coder[LEFT];   //record the latest speed value&#xA;    lastSpeed[RIGHT] = coder[RIGHT];&#xA;    coder[LEFT] = 0;                 //clear the data buffer&#xA;    coder[RIGHT] = 0;&#xA;    timer = millis();&#xA;  }&#xA;}&#xA;void LwheelSpeed()&#xA;{&#xA;  coder[LEFT] ++;  //count the left wheel encoder interrupts&#xA;}&#xA;void RwheelSpeed()&#xA;{&#xA;  coder[RIGHT] ++; //count the right wheel encoder interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20311" OwnerDisplayName="Pranay Sable" LastEditorUserId="37523" LastEditDate="2019-07-06T19:49:46.967" LastActivityDate="2019-07-06T19:49:46.967" Title="master slave control of 2wd robots using xbee" Tags="|arduino-leonardo|communication|xbee|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23015" PostTypeId="2" ParentId="23013" CreationDate="2016-04-12T03:42:13.237" Score="3" Body="&lt;p&gt;Unfortunately I do not have the ability to comment. What I can suggest is to look at the small 5 pin regulator and look at its markings. If the IC is marked with &quot;QT33&quot; then adafruit has stupidly soldered the wrong chip onto your trinket board. If it says &quot;QT50&quot; then the regulator is not at fault.&lt;/p&gt;&#xA;" OwnerUserId="19520" LastActivityDate="2016-04-12T03:42:13.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23016" PostTypeId="2" ParentId="23004" CreationDate="2016-04-12T04:27:04.673" Score="0" Body="&lt;p&gt;I've gone through the library to locate the buffer where data is stored before being transmitted and I noticed that the minimum TX buffer size is set to 130 bytes. Certain control information in the form of headers are sent along with your data to the CC3000. The CC3000 interprets these headers, strips them away and re-formats your data for transmission to your gateway. So when your 105-byte content was added to these headers, the whole packet exceeded the 130-byte buffer and so caused it to overflow, overwrite a 'magic number' at its end, that is meant to detect this condition, and cause the program to stall indefinitely; this is all by design. From &lt;code&gt;ccspi.h&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)&#xA;// for the purpose of detection of the overrun. The location of the memory where the magic number&#xA;// resides shall never be written. In case it is written - the overrun occured and either recevie function&#xA;// or send function will stuck forever.&#xA;#define CC3000_BUFFER_MAGIC_NUMBER (0xDE)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The value of the number itself doesnt matter; its presence/absence is what is important. So this is where your code most likely got stuck:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)&#xA;   * for the purpose of overrun detection. If the magic number is overwritten - buffer overrun&#xA;   * occurred - and we will be stuck here forever! */&#xA;  if (wlan_tx_buffer[CC3000_TX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)&#xA;  {&#xA;    DEBUGPRINT_F(&quot;\tCC3000: Error - No magic number found in SpiWrite\n\r&quot;);&#xA;    while (1);  //Infinite loop; end of the road&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the reason you didnt get this error message is because debug mode is disabled by default in the library. You can enable it by changing &lt;code&gt;#define DEBUG_MODE (0)&lt;/code&gt; to &lt;code&gt;#define DEBUG_MODE  (1)&lt;/code&gt; in &lt;code&gt;debug.h&lt;/code&gt; in the &lt;code&gt;utility&lt;/code&gt; folder in the library.&#xA;Note that this buffer limitation applies to incoming data, as well as outgoing data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you can increase the buffer size by changing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CC3000_MINIMAL_TX_SIZE      (130 + 1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CC3000_MINIMAL_TX_SIZE      (150 + 1) // buffer size is now 150 bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;cc3000_common.h&lt;/code&gt; in the &lt;code&gt;utility&lt;/code&gt; folder in your library folder, save the file and try again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if this works though, I suggest you choose a fixed chunk size for sending data, one that is reasonably below 130 bytes. What happens next time when you want to send a 200-byte string? You increase the buffer again and you deprive the rest of your sketch of valuable SRAM. What you do is pass your POST content to some function that splits the string into chunks and sends them one at a time.&#xA;Assuming you send only ASCII strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CHUNK_SZ  80  // your chunk size&#xA;&#xA;void send_all(Adafruit_CC3000_Client * conn, const uint8_t * data, uint16_t len){&#xA;  while (len &amp;gt;= CHUNK_SZ){   // while the length is greater than your chunk size&#xA;    conn-&amp;gt;write(data, CHUNK_SZ);  // write a chunk to the socket&#xA;    data += CHUNK_SZ;  // advance the pointer to the start of the next chunk&#xA;    len -= CHUNK_SZ;  // get how many bytes are left &#xA;  }&#xA;  if (len)  // send whatever remains if anything remains&#xA;    conn-&amp;gt;write(data, len);&#xA;}&#xA;&#xA;void loop(){&#xA;  ...&#xA;&#xA;  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);&#xA;  const uint8_t[] PostDatat = &quot;userId=32&amp;amp;sscId=43&amp;amp;raVal=52\r\n&quot;;&#xA;  send_all(&amp;amp;www, PostDatat, sizeof(PostDatat) - 1); // -1 is to ignore the null byte&#xA;&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function takes a pointer to your CC3000 socket object, a pointer to your data and the size of the data (array or not) in bytes. It should work for C strings. Note that I explicitly added &lt;code&gt;\r\n&lt;/code&gt; at the end of the POST content, since &lt;code&gt;println()&lt;/code&gt; isnt used here. I used the &lt;code&gt;uint8_t&lt;/code&gt; type so that you can also use the function to send an arrays of &lt;code&gt;int&lt;/code&gt;s or other numeric types, as long as you cast the array to &lt;code&gt;uint8_t *&lt;/code&gt; and specify the length of the array in &lt;em&gt;bytes&lt;/em&gt; with &lt;code&gt;sizeof()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, try to make your chunk size as large as you can without getting too close to the limit. A large chunk size means fewer chunks, which means less overhead (remember those pesky headers) and time taken to transmit your whole request.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-15T00:35:05.797" LastActivityDate="2016-04-15T00:35:05.797" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23017" PostTypeId="1" AcceptedAnswerId="23025" CreationDate="2016-04-12T04:46:41.200" Score="0" ViewCount="125" Body="&lt;p&gt;I am trying to do this tutorial &lt;a href=&quot;http://www.instructables.com/id/Chappie-Self-Balancing-Robot/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Chappie-Self-Balancing-Robot/&lt;/a&gt;  on building a self-balancing robot with uno. However, I bothered by the Bluetooth wiring. I've done Arduino projects with Bluetooth before and all the Hc-05 wirings I've seen have it connected to the Tx and Rx pins.Currently, I have my Bluetooth module wiring like this :   with &lt;a href=&quot;http://cdn.instructables.com/FSK/AI30/HMMFE6UO/FSKAI30HMMFE6UO.MEDIUM.jpg&quot; rel=&quot;nofollow&quot;&gt;http://cdn.instructables.com/FSK/AI30/HMMFE6UO/FSKAI30HMMFE6UO.MEDIUM.jpg&lt;/a&gt;.&#xA;Will the different wiring need a different implementation, the code I see on the chappie instructable link does not have any pin mentions but I'm not sure. Is the chappie wiring fine? should I change my wiring? should I change my code?&#xA;I'm confused.&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2016-04-12T10:13:31.930" Title="Is this bluetooth setup good?" Tags="|arduino-uno|programming|bluetooth|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23020" PostTypeId="1" CreationDate="2016-04-12T06:30:42.160" Score="0" ViewCount="95" Body="&lt;p&gt;in my embedded system I used patch antenna and Atmega 328 microcontroller,but somehow it causes the abrupt function of a microcontroller or reset. how can it be solved?&lt;/p&gt;&#xA;" OwnerUserId="8484" LastActivityDate="2016-04-12T09:52:29.013" Title="Is Gsm antenna effect on microcontroller working?" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23021" PostTypeId="2" ParentId="23010" CreationDate="2016-04-12T06:39:57.773" Score="1" Body="&lt;p&gt;The  “Performance” paragraph of the “Detailed Description” section of &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html&quot; rel=&quot;nofollow&quot;&gt;AccelStepper documentation&lt;/a&gt; says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The fastest motor speed that can be reliably supported is about 4000 steps per second at a clock frequency of 16 MHz on Arduino such as Uno etc. ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and the &lt;a href=&quot;http://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html#ae79c49ad69d5ccc9da0ee691fa4ca235&quot; rel=&quot;nofollow&quot;&gt;AccelStepper::setSpeed ()&lt;/a&gt; documentation says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... Speeds of more than 1000 steps per second are unreliable&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Try changing your 6400-steps-per-second setting to a some plausible number, eg 500 or 1000.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Actually, it would make sense to start out with moderate destination settings and speeds, like a target position of 200 instead of 16000, and steps-per-second of 100, or whatever count it takes for say exactly two shaft revolutions.  Once you have that working right, then start doubling numbers until it no longer works, after which you can back off by a factor of say four (to allow for variations in load, etc).&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-12T06:39:57.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23022" PostTypeId="2" ParentId="23020" CreationDate="2016-04-12T06:55:05.750" Score="3" Body="&lt;p&gt;There are 3 possible causes that I can think of (it's difficult to say more without further details):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;SW bug: this is hard to confirm without actually finding the bug, but it might cause a lock-up and trigger a watchdog reset (do you have a watchdog running?) or a pointer error cause a jump to some memory location along the boot path (not so likely, I suspect)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Too tight power envelope: when your system tries to transmit, it draws more power than the power supply/battery can provide. This cause a temporary voltage drop, to the point that the system kinda power cycles. You can try to use a power supply with higher maximum current.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Electromagnetic interference: somehow the transmission interferes with the AVR. You can try to direct the antenna further away from the AVR and to increase the distance in between.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But you should really add more information to your question.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="4143" LastEditDate="2016-04-12T09:52:29.013" LastActivityDate="2016-04-12T09:52:29.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23023" PostTypeId="1" CreationDate="2016-04-12T07:21:26.317" Score="0" ViewCount="536" Body="&lt;p&gt;I did the research for similar issues and found that I had to enable debug. I did the following attempts:&lt;/p&gt;&#xA;&lt;p&gt;Changes to settings.h - enabled debugging by change from 0 to 1&lt;/p&gt;&#xA;&lt;p&gt;Getting the following compiling error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/Users/BAGHEL/Documents/Arduino/libraries/USB_Host_Shield_2.0-master/usbh_midi.cpp: In member function 'void USBH_MIDI::parseConfigDescr(byte, byte)':&#xA;/Users/BAGHEL/Documents/Arduino/libraries/USB_Host_Shield_2.0-master/usbh_midi.cpp:298:63: error: 'PrintEndpointDescriptor' was not declared in this scope&#xA;                                 PrintEndpointDescriptor(epDesc);&#xA;                                                               ^&#xA;/Users/BAGHEL/Documents/Arduino/libraries/USB_Host_Shield_2.0-master/usbh_midi.cpp: At global scope:&#xA;/Users/BAGHEL/Documents/Arduino/libraries/USB_Host_Shield_2.0-master/usbh_midi.cpp:421:80: error: no 'void USBH_MIDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR*)' member function declared in class 'USBH_MIDI'&#xA; void USBH_MIDI::PrintEndpointDescriptor( const USB_ENDPOINT_DESCRIPTOR* ep_ptr )&#xA;                                                                                ^&#xA;exit status 1&#xA;Error compiling for board Arduino/Genuino Uno.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20110" LastEditorUserId="61722" LastEditDate="2022-08-06T08:51:43.903" LastActivityDate="2023-01-03T13:01:00.127" Title="I am trying to connect the PS3 controller with the Arduino Uno using a USB Host Shield. Getting stuck at 'PS3 Bluetooth Library Started'" Tags="|bluetooth|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23024" PostTypeId="2" ParentId="23023" CreationDate="2016-04-12T09:58:32.777" Score="-1" Body="&lt;p&gt;At the risk of stating the bleeding obvious you need to define &quot;PrintEndpointDescriptor()&quot;.  I'm sorry but I can't give you a definitive answer to your problem, only generic steps that should solve it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This almost certainly means you have either missed a include file out or there is a pre-processor flag that is disabling or maybe not enabling that bit of code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search through the files in the library and see if there are any pre-processor flags that affect compilation and if so this function.  Have a search on Google for the filename and function name, see that others say.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possible solution is look for a readme in the library, or comments in the files that say you need another library including first.  In fact if you are including multiple libraries try changing the order of inclusion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last cause could be that the function is within a namespace.  This means you either need to fully qualify the function call (namespace::class::function), or use the horrible using command.  &lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-12T09:58:32.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23025" PostTypeId="2" ParentId="23017" CreationDate="2016-04-12T10:13:31.930" Score="0" Body="&lt;p&gt;Which code are you reading? At step 5 he wrote&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Complete code can be found on the &lt;a href=&quot;https://github.com/ManpreetSingh80/CHAPPIE&quot; rel=&quot;nofollow&quot;&gt;GITHUB&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The sketch file (&lt;a href=&quot;https://github.com/ManpreetSingh80/CHAPPIE/blob/master/SelfBalance_robot0_67/SelfBalance_robot0_67.ino&quot; rel=&quot;nofollow&quot;&gt;here is the direct link&lt;/a&gt;) has the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int rxpin = 11; // pin used to receive (not used in this version) &#xA;const int txpin = 4; // pin used to send to LCD&#xA;&#xA;SoftwareSerial blue(rxpin, txpin); // new serial port on pins 2 and 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means that the bluetooth is using a software serial on pins 11 and 4. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know where you got the image you posted, but anyway that wiring is not the same as the one in the instructable. With your wiring, you can either use the software serial on pins 0 and 1, or (better) use the hardware serial. To do so, remove or comment the lines I highlighted and then replace every call to &lt;code&gt;blue&lt;/code&gt; with &lt;code&gt;Serial&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-04-12T10:13:31.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23026" PostTypeId="1" AcceptedAnswerId="23029" CreationDate="2016-04-12T11:50:53.947" Score="1" ViewCount="1654" Body="&lt;p&gt;I'm just getting started with Arduino, and it has a LOT of uses, however, I would like to know how reliable is it? Can it be used for medical purposes (Measure vital signs, or to help surgeons perform surgeries), if it depends on the board, which one is the most accurate and reliable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know most robotic tasks will rely on the quality of the servo to interpret the Arduino commands, and sensors, and even the coding/logic, but we can replace/recode all of those things, but when it comes to the main board it gets more complicated&lt;/p&gt;&#xA;" OwnerUserId="12111" LastEditorUserId="12111" LastEditDate="2016-04-12T11:57:39.827" LastActivityDate="2016-04-12T12:52:08.837" Title="Is Arduino reliable for serious tasks, such as medical machines?" Tags="|sensors|robotics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23028" PostTypeId="1" AcceptedAnswerId="23031" CreationDate="2016-04-12T12:48:20.347" Score="1" ViewCount="49" Body="&lt;p&gt;I am getting this error from the Visual Studio compiler (I use the Visual Studio add-in Visual Micro for Arduino).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ModelRailroadCrossingSignalController.ino:In function 'void loop()&#xA;  ModelRailroadCrossingSignalController.ino:210:15: error: too few arguments to function 'Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer, const char*)&#xA;  :onSignalSound()&#xA;  ModelRailroadCrossingSignalController.ino:note  declared here&#xA;  :Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {&#xA;  Error compiling project sources&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here is the function and loop (all the defines and instances left out for brevity, they aren't the issue&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;// put your main code here, to run repeatedly&#xA;&#xA;signalEntrySensor = checkEntrySensor();&#xA;if (signalEntrySensor == true) {&#xA;    if (crossingSignalInOperation == false)&#xA;    {&#xA;        Adafruit_VS1053_FilePlayer mp = onSignalSound(musicPlayer,&quot;Trainxng.mp3&quot;);  //all other functions are called in the sound routine?&#xA;        if (debugMode)&#xA;        {&#xA;            Serial.println(&quot;Sound byte called&quot;);&#xA;        }&#xA;        while (mp.playingMusic) {&#xA;            // file is now playing in the 'background' so now's a good time&#xA;            // to do something else &#xA;            offRoadPower();&#xA;            lowerSignalArms();&#xA;            onSignalSound();&#xA;            startSignalFlashers();&#xA;            crossingSignalInOperation = true;&#xA;        }                   &#xA;    }&#xA;}&#xA;&#xA;Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {&#xA;// Play the train crossing sound file&#xA;if (debugMode)&#xA;{&#xA;    Serial.println(F(&quot;Playing track - &quot;));&#xA;    Serial.print(fileName);&#xA;}&#xA;//all sound files are on the micro sd card on the music player shield&#xA;if (!mp.startPlayingFile(fileName)) {&#xA;    Serial.println(F(&quot;Could not open file &quot;));&#xA;    Serial.print(fileName);&#xA;    while (1);&#xA;}&#xA;return mp;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm a C# guy, not ever using C++ until now, but this code should certainly work, not sure why the function is not compiling.&lt;/p&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-12T13:25:49.667" Title="Compiler doesn't like function code" Tags="|programming|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23029" PostTypeId="2" ParentId="23026" CreationDate="2016-04-12T12:52:08.837" Score="3" Body="&lt;p&gt;You should NOT trust using an Arduino for life safety measures (medical purposes). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This discusses the reliability of an Arduino pretty well- &lt;a href=&quot;https://electronics.stackexchange.com/questions/15535/reliability-of-the-arduino-platform-for-industrial-use&quot;&gt;https://electronics.stackexchange.com/questions/15535/reliability-of-the-arduino-platform-for-industrial-use&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20089" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-04-12T12:52:08.837" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23030" PostTypeId="1" CreationDate="2016-04-12T13:09:37.823" Score="0" ViewCount="1618" Body="&lt;p&gt;I am trying to strengthen the signal from my MQ135 air quality sensor so it can detect aerosols from 3 feet away, as, currently as it stands the resolution is pathetic, it only blips from 0.21 to 0.58 when you practically insert the sensor into the nozzle of a bottle full of vinegar/rubbing alcohol. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be ideal if you could guide me as to what sort of signal amplifier to buy to strengthen the signal coming from this board? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively: Could I increase the sensitivity of this sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to plot this to a graph at some point, so I will be working on an ASP.NET app that tells me if there are any aerosols in my room or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zMxNk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zMxNk.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Graph&#xA;&#xA; A simple example of communication from the Arduino board to the computer:&#xA; the value of analog input 0 is sent out the serial port.  We call this &quot;serial&quot;&#xA; communication because the connection appears to both the Arduino and the&#xA; computer as a serial port, even though it may actually use&#xA; a USB cable. Bytes are sent one after another (serially) from the Arduino&#xA; to the computer.&#xA;&#xA; You can use the Arduino serial monitor to view the sent data, or it can&#xA; be read by Processing, PD, Max/MSP, or any other program capable of reading&#xA; data from a serial port.  The Processing code below graphs the data received&#xA; so you can see the value of the analog input changing over time.&#xA;&#xA; The circuit:&#xA; Any analog input sensor is attached to analog in pin 0.&#xA;&#xA; created 2006&#xA; by David A. Mellis&#xA; modified 9 Apr 2012&#xA; by Tom Igoe and Scott Fitzgerald&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; http://www.arduino.cc/en/Tutorial/Graph&#xA; */&#xA;&#xA;void setup() {&#xA;  // initialize the serial communication:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // send the value of analog input 0:&#xA;  Serial.println(analogRead(A0));&#xA;  // wait a bit for the analog-to-digital converter&#xA;  // to stabilize after the last reading:&#xA;  delay(20);&#xA;}&#xA;&#xA;/* Processing code for this example&#xA;&#xA; // Graphing sketch&#xA;&#xA;&#xA;// This program takes ASCII-encoded strings&#xA;// from the serial port at 9600 baud and graphs them. It expects values in the&#xA;// range 0 to 1023, followed by a newline, or newline and carriage return&#xA;&#xA;// Created 20 Apr 2005&#xA;// Updated 24 Nov 2015&#xA;// by Tom Igoe&#xA;// This example code is in the public domain.&#xA;&#xA;import processing.serial.*;&#xA;&#xA;Serial myPort;        // The serial port&#xA;int xPos = 1;         // horizontal position of the graph&#xA;float inByte = 0;&#xA;&#xA;void setup () {&#xA;  // set the window size:&#xA;  size(400, 300);&#xA;&#xA;  // List all the available serial ports&#xA;  // if using Processing 2.1 or later, use Serial.printArray()&#xA;  println(Serial.list());&#xA;&#xA;  // I know that the first port in the serial list on my mac&#xA;  // is always my  Arduino, so I open Serial.list()[0].&#xA;  // Open whatever port is the one you're using.&#xA;  myPort = new Serial(this, Serial.list()[0], 9600);&#xA;&#xA;  // don't generate a serialEvent() unless you get a newline character:&#xA;  myPort.bufferUntil('\n');&#xA;&#xA;  // set inital background:&#xA;  background(0);&#xA;}&#xA;void draw () {&#xA;  // draw the line:&#xA;  stroke(127, 34, 255);&#xA;  line(xPos, height, xPos, height - inByte);&#xA;&#xA;  // at the edge of the screen, go back to the beginning:&#xA;  if (xPos &amp;gt;= width) {&#xA;    xPos = 0;&#xA;    background(0);&#xA;  } else {&#xA;    // increment the horizontal position:&#xA;    xPos++;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void serialEvent (Serial myPort) {&#xA;  // get the ASCII string:&#xA;  String inString = myPort.readStringUntil('\n');&#xA;&#xA;  if (inString != null) {&#xA;    // trim off any whitespace:&#xA;    inString = trim(inString);&#xA;    // convert to an int and map to the screen height:&#xA;    inByte = float(inString);&#xA;    println(inByte);&#xA;    inByte = map(inByte, 0, 1023, 0, height);&#xA;  }&#xA;}&#xA;&#xA;*/&#xA;&#xA;/* Max/MSP v5 patch for this example&#xA; ----------begin_max5_patcher----------&#xA;1591.3oc0YszbaaCD9r7uBL5RalQUAO3CvdyS5zVenWZxs5NcfHgjPCIfJIT&#xA;RTxj+6AOHkoTDooroUs0AQPR73a+1cwtK3WtZxzEpOwqlB9YveAlL4KWMYh6&#xA;Q1GLo99ISKXeJMmU451zTUQAWpmNy+NM+SZ2y+sR1l02JuU9t0hJvFlNcMPy&#xA;dOuBv.U5Rgb0LPpRpYBooM3529latArTUVvzZdFPtsXAuDrrTU.f.sBffXxL&#xA;vGE50lIHkUVJXq3fRtdaoDvjYfbgjujaFJSCzq4.tLaN.bi1tJefWpqbO0uz&#xA;1IjIABoluxrJ1guxh2JfPO2B5zRNyBCLDFcqbwNvuv9fHCb8bvevyyEU2JKT&#xA;YhkBSWPAfq2TZ6YhqmuMUo0feUn+rYpY4YtY+cFw3lUJdCMYAapZqzwUHX8S&#xA;crjAd+SIOU6UBAwIygy.Q1+HAA1KH6EveWOFQlitUK92ehfal9kFhUxJ3tWc&#xA;sgpxadigWExbt1o7Ps5dk3yttivyg20W0VcSmg1G90qtx92rAZbH4ez.ruy1&#xA;nhmaDPidE07J+5n2sg6E6oKXxUSmc20o6E3SPRDbrkXnPGUYE.i5nCNB9TxQ&#xA;jG.G0kCTZtH88f07Rt0ZMMWUw8VvbKVAaTk6GyoraPdZff7rQTejBN54lgyv&#xA;HE0Ft7AvIvvgvIwO23jBdUkYOuSvIFSiNcjFhiSsUBwsUCh1AgfNSBAeNDBZ&#xA;DIDqY.f8.YjfjV1HAn9XDTxyNFYatVTkKx3kcK9GraZpI5jv7GOx+Z37Xh82&#xA;LSKHIDmDXaESoXRngIZQDKVkpxUkMCyXCQhcCK1z.G457gi3TzMz4RFD515F&#xA;G3bIQQwcP3SOF0zlkGhiCBQ1kOHHFFlXaEBQIQnCwv9QF1LxPZ.A4jR5cyQs&#xA;vbvHMJsLll01We+rE2LazX6zYmCraRrsPFwKg1ANBZFY.IAihr8Ox.aH0oAL&#xA;hB8nQVw0FSJiZeunOykbT6t3r.NP8.iL+bnwNiXuVMNJH9H9YCm89CFXPBER&#xA;bz422p8.O4dg6kRxdyjDqRwMIHTbT3QFLskxJ8tbmQK4tm0XGeZWF7wKKtYY&#xA;aTAF.XPNFaaQBinQMJ4QLF0aNHF0JtYuHSxoUZfZY6.UU2ejJTb8lQw8Fo5k&#xA;Rv6e2PI+fOM71o2ecY1VgTYdCSxxUqLokuYq9jYJi6lxPgD2NIPePLB0mwbG&#xA;YA9Rgxdiu1k5xiLlSU6JVnx6wzg3sYHwTesB8Z5D7RiGZpXyvDNJY.DQX3.H&#xA;hvmcUN4bP1yCkhpTle2P37jtBsKrLWcMScEmltOPv22ZfAqQAdKr9HzATQwZ&#xA;q18PrUGt6Tst2XMCRUfGuhXs6ccn23YloomMqcTiC5iMGPsHsHRWhWFlaenV&#xA;XcqwgCQiGGJzptyS2ZMODBz6fGza0bzmXBj7+DA94bvpR01MffAlueO7HwcI&#xA;pWCwmzJdvi9ILgflLAFmyXB6O7ML0YbD26lenmcGxjVsZUN+A6pUK7AtTrPg&#xA;M+eRYG0qD9j4I7eEbco8Xh6WcO.or9XDC6UCiewbXHkh6xm5LiPEkzpJDRTu&#xA;mEB44Fgz4NCtJvX.SM1vo2SlTCZGAe7GZu6ahdRyzFOhYZ+mbVVSYptBw.K1&#xA;tboIkatIA7c1cTKD1u.honLYV04VkluHsXe0szv9pQCE9Ro3jaVB1o15pz2X&#xA;zYoBvO5KXCAe0LCYJybE8ZODf4fV8t9qW0zYxq.YJfTosj1bv0xc.SaC0+AV&#xA;9V9L.KKyV3SyTcRtmzi6rO.O16USvts4B5xe9EymDvebK0eMfW6+NIsNlE2m&#xA;eqRyJ0utRq13+RjmqYKN1e.4d61jjdsauXe3.2p6jgi9hsNIv97CoyJ01xzl&#xA;c3ZhUCtSHx3UZgjoEJYqNY+hYs5zZQVFW19L3JDYaTlMLqAAt1G2yXlnFg9a&#xA;53L1FJVcv.cOX0dh7mCVGCLce7GFcQwDdH5Ta3nyAS0pQbHxegr+tGIZORgM&#xA;RnMj5vGl1Fs16drnk7Tf1XOLgv1n0d2iEsCxR.eQsNOZ4FGF7whofgfI3kES&#xA;1kCeOX5L2rifbdu0A9ae2X.V33B1Z+.Bj1FrP5iFrCYCG5EUWSG.hhunHJd.&#xA;HJ5hhnng3h9HPj4lud02.1bxGw.&#xA;-----------end_max5_patcher-----------&#xA;&#xA; */&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20114" LastEditorUserId="19515" LastEditDate="2016-04-12T15:47:02.520" LastActivityDate="2019-12-28T11:00:33.193" Title="MQ135 Air Quality Sensor Signal Amplifier needed? Higher Quality Sensor?" Tags="|arduino-uno|sensors|temperature-sensor|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23031" PostTypeId="2" ParentId="23028" CreationDate="2016-04-12T13:25:49.667" Score="0" Body="&lt;p&gt;The clue is in the error...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;too few arguments to function 'Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer, const char*) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You have defined the function as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And yet you then try and call it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;onSignalSound();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Spot the mismatch?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect you don't want to be calling that function there since it seems to be in a bit where the sound has already been started.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-12T13:25:49.667" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23033" PostTypeId="1" AcceptedAnswerId="23034" CreationDate="2016-04-12T14:19:05.037" Score="0" ViewCount="443" Body="&lt;p&gt;I want to create arduino sketch that start program on my computer (i.e., browser) when I push button on Arduino itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to make it using Arduino uno? I already know how to make a serial connection between PC and Arduino and use Processing software, but as I know, Processing cannot interact with another programs.&lt;/p&gt;&#xA;" OwnerUserId="20091" LastEditorUserId="19515" LastEditDate="2016-04-12T16:00:46.900" LastActivityDate="2016-04-12T16:00:46.900" Title="Start program on PC using Arduino" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23034" PostTypeId="2" ParentId="23033" CreationDate="2016-04-12T14:23:58.277" Score="2" Body="&lt;p&gt;Processing is just Java.  If Java can do it Processing can do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And Java can do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just ask Google about the Java &lt;code&gt;ProcessBuilder&lt;/code&gt; class.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-12T14:23:58.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23035" PostTypeId="1" AcceptedAnswerId="23050" CreationDate="2016-04-12T14:50:42.160" Score="5" ViewCount="3823" Body="&lt;p&gt;I have Googled quite a lot regarding using a C++ program for uploading to Arduino and related, however I am confused now. Right, my problem is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have written a C++ program which imports RGB data of a 24 bit bitmap (which was generated using Matlab) and now I would like to use this array (3 arrays - R,G,B) for an Arduino sketch to be used for a LED matrix project that I am working on. I am not exactly a programmer and hence had to resort to this path -- MATLAB to c++ and then Arduino, although this could be entirely done in C++ too (importing a bitmap and extracting pixel info). So, my C++ code spits out the 3 arrays and I am not sure how to get those into an Arduino sketch. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read a lot about this and I understood this - As the Arduino &quot;language&quot; is C and C++ therefore it is possible to program an Arduino in C++/c. I need a maker file and a compiler. However my question is that isn't there a more non-programmer friendly way to get this done, some software or an IDE which supports Arduino programming in C++? I cannot understand much of this method, hence trying to bypass this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anybody's got any better method, I would be really glad if you could share it. I am also looking to use the Arduino package for MATLAB to send the array directly from there using serial communication. But I just wanted to make sure I at least tried this path.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would really appreciate if somebody could offer some help. I am quite stuck here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can share any other info if required. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot!&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify as Nick Gammon pointed out in the comments below. In brief steps, this is what I have done till now:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Got a 24 bit bitmap (some random image)&lt;/li&gt;&#xA;&lt;li&gt;Extracted the RGB data for each pixel using Matlab&lt;/li&gt;&#xA;&lt;li&gt;Have 3 arrays of (for eg.) 122X300 dimensions whose every element has values between 0-255 (8 bit) and for R,G and B colors&lt;/li&gt;&#xA;&lt;li&gt;Want to get these 3 arrays for use in Arduino sketch for further working&lt;/li&gt;&#xA;&lt;li&gt;Stuck here - how to do that .....&lt;/li&gt;&#xA;&lt;li&gt;So I did this - I imported that the RGB data into 3 separate text files and made a c++ program to read those arrays assuming that I should be able to then somehow use this program in Arduino sketch.&lt;/li&gt;&#xA;&lt;li&gt;Now I am not sure what to do....my goal would be to have these 3 arrays (CRGB arrays, FastLED) in my arduino sketch which I can control and then upload to my Due.&lt;/li&gt;&#xA;&lt;li&gt;On googling I found that to use c++ for arduino , you need the avr compiler and make file, which I want to avoid. Tried other IDEs too, Eclipse, PlatformIO too .. ummmm ... not that successful to be honest.&lt;/li&gt;&#xA;&lt;li&gt;as per Paul's ans- Matlab to Arduino method I have to try. &#xA;Hope I have clarified my process till now :)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/euhgC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/euhgC.png&quot; alt=&quot;Snapshot of Red color data (122X300) in Text format (imported from Matlab)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;C++ code for reading the above array (thought I could use the output in Arduino)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;#include &amp;lt;fstream&amp;gt;&#xA;#include &amp;lt;string&amp;gt;&#xA;#include &amp;lt;conio.h&amp;gt;&#xA;#include &amp;lt;sstream&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;&#xA;&#xA;const int HEIGHT = 4;&#xA;&#xA;const int WIDTH = 5;&#xA;&#xA;using namespace std;&#xA;&#xA;int main(){&#xA;&#xA;  int array_req [HEIGHT][WIDTH];&#xA;&#xA;string userinputprompt, filename;&#xA;&#xA;userinputprompt = &quot;COLORDATA FILENAME: &quot;;&#xA;&#xA;cout&amp;lt;&amp;lt;userinputprompt&amp;lt;&amp;lt;endl;&#xA;&#xA;getline(cin,filename);&#xA;&#xA;ifstream inputfile;&#xA;&#xA;inputfile.open(filename.c_str());&#xA;&#xA; for (int i = 0; i &amp;lt; HEIGHT; ++i)&#xA;{&#xA;  std::string tmpString;&#xA;  std::getline(inputfile, tmpString);&#xA;&#xA; std::stringstream ss(tmpString);&#xA;&#xA; for(int j=0;j &amp;lt; WIDTH; ++j)&#xA;  {&#xA;    ss &amp;gt;&amp;gt; array_req[i][j];&#xA;  }&#xA; }&#xA;&#xA;    for(int p=0; p&amp;lt;HEIGHT; p++)&#xA;    {&#xA;      for(int q=0; q&amp;lt;WIDTH; q++)&#xA;    {&#xA;        cout&amp;lt;&amp;lt;array_req[p][q]&amp;lt;&amp;lt;&quot; &quot;;&#xA;    }&#xA;    cout&amp;lt;&amp;lt;&quot;\n&quot;;&#xA;}&#xA;&#xA;inputfile.close();&#xA;getchar();&#xA;return 0;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20119" LastEditorUserId="10794" LastEditDate="2016-04-13T02:18:10.027" LastActivityDate="2016-04-23T10:24:08.833" Title="Employing C++ code for Arduino" Tags="|programming|c++|arduino-due|matlab|array|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23036" PostTypeId="5" CreationDate="2016-04-12T14:50:43.527" Score="0" Body="" OwnerUserId="-1" LastEditorUserId="-1" LastEditDate="2016-04-12T14:50:43.527" LastActivityDate="2016-04-12T14:50:43.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23037" PostTypeId="4" CreationDate="2016-04-12T14:50:43.527" Score="0" Body="A command line is a string given to a command interpreter that tells it actions to take, such as running programs or copying files. The interpreter processes command lines with escapes and substitutions." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-18T18:53:16.447" LastActivityDate="2016-04-18T18:53:16.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23038" PostTypeId="1" AcceptedAnswerId="23041" CreationDate="2016-04-12T14:50:56.117" Score="0" ViewCount="64" Body="&lt;p&gt;I have succesfully (or so the ide says) burned a bootloader on an ATMega328P-PU chipset, and uploaded my sketch on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears a voltage regulation is absolutely needed, if I want to solder a pcb with the standalone chip, rather than an arduino. Is that correct? Can I build one out of my starter kits parts (assortment of transistors, diodes, zeners, resistors and capacitors)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the meantime, I would like to make sure the chispet is functional. Can I power it from GND/5V of an arduino? Will it take care of that power regulation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I can, what is the correspondance between the arduino pins, and the ATMega328P-PU pins? I have this page here : &lt;a href=&quot;http://www.learningaboutelectronics.com/Articles/Atmega328-pinout.php&quot; rel=&quot;nofollow&quot;&gt;http://www.learningaboutelectronics.com/Articles/Atmega328-pinout.php&lt;/a&gt;&#xA;referencing the chipset pinout. Am I correct in assuming there is a correspondance with the arduino pinout in the reading order of this chart, ie. :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PD0 to PD7 are Rx, Tx, digital pins 2 to 7 on the arduino, PB0 to PB5 are digital pins 8 to 13, and PC0 to PC5 are A0 to A5 on the arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for reading.&lt;/p&gt;&#xA;" OwnerUserId="19700" LastActivityDate="2016-04-12T15:42:50.480" Title="Standalone chipset, power regulation &amp; pinout" Tags="|power|pins|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23039" PostTypeId="5" CreationDate="2016-04-12T14:52:45.933" Score="0" Body="&lt;p&gt;Simple Network Management Protocol (SNMP) is an Internet-standard protocol for managing devices on IP networks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SNMP is defined by a series of IETF Requests for Comment (RFCs). There are three versions of the protocol: SNMPv1, SNMPv2, and SNMPv3. &lt;a href=&quot;http://tools.ietf.org/html/rfc3584&quot; rel=&quot;nofollow&quot;&gt;RFC 3584&lt;/a&gt; is the &quot;Best Current Practice&quot; for handling coexistence of the three protocol versions, and provides a view of interoperability issues between the versions as well as a list of references to the various RFCs that define the different versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SNMP generally operates over UDP on either IPv4 or IPv6, but several transport mappings are defined in &lt;a href=&quot;http://tools.ietf.org/html/rfc3417&quot; rel=&quot;nofollow&quot;&gt;RFC 3417&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-18T18:53:29.540" LastActivityDate="2016-04-18T18:53:29.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23040" PostTypeId="4" CreationDate="2016-04-12T14:52:45.933" Score="0" Body="Simple Network Management Protocol (SNMP) is an Internet-standard protocol for managing devices on IP networks and consists of operations for data retrieval, modification and notification. SNMP generally operates over UDP." OwnerUserId="19515" LastEditorUserId="19515" LastEditDate="2016-04-18T18:53:08.397" LastActivityDate="2016-04-18T18:53:08.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23041" PostTypeId="2" ParentId="23038" CreationDate="2016-04-12T14:57:55.137" Score="1" Body="&lt;p&gt;Voltage regulation is needed if the voltage you are providing to the chip is outside (or can drift outside) the allowed range for the chip to operate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the upper limit that is 5.5V. The lower limit is 1.8V. Note that at lower voltages you can only reliably run at lower clock speeds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your power source is between those two voltages (say a 3.4V LiPo battery) then you don't need a regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your power source is above 5.5V (say a 9V PP3 battery [urgh]) then you definitely need a regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A proper regulator is quite a complex device, and it is highly unlikely that you have the components to make one.  A simple, very inefficient one, though, can be made using a resistor and a 5V Zener diode if you have one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oq9P6.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oq9P6.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until you have your own regulator of whatever form, yes, you can power the chip from the 5V pin of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin mapping for the chip -&gt; Arduino IO numbers is in the file &lt;code&gt;pins_arduino.h&lt;/code&gt; for the Uno variant in the IDE.  In the top of that file is this handy drawing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ATMEL ATMEGA8 &amp;amp; 168 / ARDUINO&#xA;//&#xA;//                  +-\/-+&#xA;//            PC6  1|    |28  PC5 (AI 5)&#xA;//      (D 0) PD0  2|    |27  PC4 (AI 4)&#xA;//      (D 1) PD1  3|    |26  PC3 (AI 3)&#xA;//      (D 2) PD2  4|    |25  PC2 (AI 2)&#xA;// PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)&#xA;//      (D 4) PD4  6|    |23  PC0 (AI 0)&#xA;//            VCC  7|    |22  GND&#xA;//            GND  8|    |21  AREF&#xA;//            PB6  9|    |20  AVCC&#xA;//            PB7 10|    |19  PB5 (D 13)&#xA;// PWM+ (D 5) PD5 11|    |18  PB4 (D 12)&#xA;// PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM&#xA;//      (D 7) PD7 13|    |16  PB2 (D 10) PWM&#xA;//      (D 8) PB0 14|    |15  PB1 (D 9) PWM&#xA;//                  +----+&#xA;//&#xA;// (PWM+ indicates the additional PWM pins on the ATmega168.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-12T15:42:50.480" LastActivityDate="2016-04-12T15:42:50.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23042" PostTypeId="1" AcceptedAnswerId="23044" CreationDate="2016-04-12T15:13:47.230" Score="0" ViewCount="121" Body="&lt;p&gt;I am trying to get a simple button (GPIO shortcircuit) to work. I have chosen Pin D0 as input and Pin D7 as output. It works fine in an Arduino sketch but I can't get it to run in pure C. What am I doing wrong? I bet I got the bits all wrong...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DDRD = 0b11111110; // set all port D pins to Output besides pin 0, which is set to input&#xA;PORTD = 0b11111111; // set all D pins to WRITE / PULL-UP&#xA;int a = PIND &amp;amp; 1; // a is 0 or 1, depending on whether pins D0 and D7 are physically connected&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It doesn't work though, &lt;code&gt;a&lt;/code&gt; is never zero, whether the pins are connected or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my complete code sample, where the on board LED depends on my pins connection state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;int main(void)&#xA;{&#xA; DDRB |= _BV(DDB5);&#xA; DDRD = 0b11111110;&#xA; PORTD = 0b11111111;&#xA;&#xA;     while(1) {&#xA;        int a =  PIND &amp;amp; 1;&#xA;        if(a != 0)&#xA;             PORTB |= _BV(PORTB5); // blink on&#xA;         else&#xA;             PORTB &amp;amp;= ~_BV(PORTB5); // blink off&#xA;         _delay_ms(1000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20120" LastEditorUserId="6936" LastEditDate="2016-04-19T04:31:59.647" LastActivityDate="2016-04-19T04:31:59.647" Title="ATmega328p simple shortcircuit button" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23043" PostTypeId="2" ParentId="23033" CreationDate="2016-04-12T15:50:59.960" Score="1" Body="&lt;p&gt;You can also make the Arduino look like a keyboard/mouse to the PC and then reproduce some key combo that will perform the action you want.&#xA;See reference &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-12T15:50:59.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23044" PostTypeId="2" ParentId="23042" CreationDate="2016-04-12T16:15:45.050" Score="4" Body="&lt;p&gt;The problem here is you set pull-up on D0. So even if button is not pressed it will be at high state because of pull-up. You would need pull-down for this to work (Arduino does not have it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pullups are useful if you want to connect pin to GND when button is pressed. When button is not pressed it will have defined state (HIGH because of pull-up) and when pressed it will be pulled LOW by button. You can imagine pull-up as a resistor to Vcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for this to work I would put the other end of button to GND and it will work (One end to D0, second on GND). Condition in code should be altered (a == 0) but otherwise all can be the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other option is to connect external resistor in range 1K-100K Ohm between pin D7 and GND and turn off pull-up in code. That resistor would serve as pull down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just one more note. If you are not using other pins it is the best to leave them as inputs. Setting an &quot;unused&quot; pin as output and setting it to HIGH can damage the pin if you accidentally connected it to GND (because in previous sketch you experimented something).&lt;/p&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-04-12T16:26:28.083" LastActivityDate="2016-04-12T16:26:28.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23045" PostTypeId="1" AcceptedAnswerId="23046" CreationDate="2016-04-12T16:22:02.780" Score="1" ViewCount="529" Body="&lt;p&gt;I have a relay (&lt;a href=&quot;https://www.fabtolab.com/Relay%20-5V-%20VRS4H-S&quot; rel=&quot;nofollow&quot;&gt;VRS4H-S-DC5V-C&lt;/a&gt;), for which the triggering voltage required is 5V Min.  If I directly use the 5V voltage of Arduino  I'm able to trigger it, but if I use any digital pin in OUTPUT mode in digitalWrite I'm not able to trigger the relay. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Earlier I thought that it must be that because it's a small board its digital pins would be giving HIGH state as 3.3.V, but the fact is when I checked both the voltage of 5V (which is obviously shown 5V on multi meter) and that digital pin one, both show 5V. So the question is why the hell is digital pin not able to trigger the relay, since trigger the relay by 5V is of no use for me since I can't control it, i.e., when it should trigger and when not?&lt;/p&gt;&#xA;" OwnerUserId="20123" LastEditorUserId="6628" LastEditDate="2016-04-18T17:26:03.417" LastActivityDate="2016-04-18T17:26:03.417" Title="Digital pin output voltage, not triggering 71mA relay coil" Tags="|arduino-nano|relay|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23046" PostTypeId="2" ParentId="23045" CreationDate="2016-04-12T16:40:39.203" Score="5" Body="&lt;p&gt;The digital output pin cannot output sufficient current to drive the relay directly. Iirc this question was already asked. You need to add between the Arduino and the relay a driving stage, for example with a FET. Or you can use a shield that already has this additional circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just google for &quot;Arduino relay driver circuit&quot; and you will get various options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/Connecting-a-12V-Relay-to-Arduino/&quot;&gt;This&lt;/a&gt; is pretty close to your setup.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-12T16:40:39.203" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23047" PostTypeId="1" CreationDate="2016-04-12T16:52:02.283" Score="1" ViewCount="1264" Body="&lt;p&gt;I'm trying to make a self balancing robot with MPU-6050. When I try the DMP6 example it works good and the Serial Monitor gives me the yaw pitch roll angles but whenever I try to output PWM on pin 6 nothing happens and I don't know why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class using DMP (MotionApps v2.0)&#xA;// 6/21/2012 by Jeff Rowberg &amp;lt;jeff@rowberg.net&amp;gt;&#xA;// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib&#xA;//&#xA;// Changelog:&#xA;//      2013-05-08 - added seamless Fastwire support&#xA;//                 - added note about gyro calibration&#xA;//      2012-06-21 - added note about Arduino 1.0.1 + Leonardo compatibility error&#xA;//      2012-06-20 - improved FIFO overflow handling and simplified read process&#xA;//      2012-06-19 - completely rearranged DMP initialization code and simplification&#xA;//      2012-06-13 - pull gyro and accel data from FIFO packet instead of reading directly&#xA;//      2012-06-09 - fix broken FIFO read sequence and change interrupt detection to RISING&#xA;//      2012-06-05 - add gravity-compensated initial reference frame acceleration output&#xA;//                 - add 3D math helper file to DMP6 example sketch&#xA;//                 - add Euler output and Yaw/Pitch/Roll output formats&#xA;//      2012-06-04 - remove accel offset clearing for better results (thanks Sungon Lee)&#xA;//      2012-06-01 - fixed gyro sensitivity to be 2000 deg/sec instead of 250&#xA;//      2012-05-30 - basic DMP initialization working&#xA;&#xA;/* ============================================&#xA;I2Cdev device library code is placed under the MIT license&#xA;Copyright (c) 2012 Jeff Rowberg&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a copy&#xA;of this software and associated documentation files (the &quot;Software&quot;), to deal&#xA;in the Software without restriction, including without limitation the rights&#xA;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;copies of the Software, and to permit persons to whom the Software is&#xA;furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included in&#xA;all copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#xA;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&#xA;THE SOFTWARE.&#xA;===============================================&#xA;*/&#xA;&#xA;// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files&#xA;// for both classes must be in the include path of your project&#xA;#include &quot;I2Cdev.h&quot;&#xA;&#xA;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;//#include &quot;MPU6050.h&quot; // not necessary if using MotionApps include file&#xA;&#xA;// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation&#xA;// is used in I2Cdev.h&#xA;#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;    #include &quot;Wire.h&quot;&#xA;#endif&#xA;&#xA;// class default I2C address is 0x68&#xA;// specific I2C addresses may be passed as a parameter here&#xA;// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)&#xA;// AD0 high = 0x69&#xA;MPU6050 mpu;&#xA;//MPU6050 mpu(0x69); // &amp;lt;-- use for AD0 high&#xA;&#xA;/* =========================================================================&#xA;   NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch&#xA;   depends on the MPU-6050's INT pin being connected to the Arduino's&#xA;   external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is&#xA;   digital I/O pin 2.&#xA; * ========================================================================= */&#xA;&#xA;/* =========================================================================&#xA;   NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error&#xA;   when using Serial.write(buf, len). The Teapot output uses this method.&#xA;   The solution requires a modification to the Arduino USBAPI.h file, which&#xA;   is fortunately simple, but annoying. This will be fixed in the next IDE&#xA;   release. For more info, see these links:&#xA;&#xA;   http://arduino.cc/forum/index.php/topic,109987.0.html&#xA;   http://code.google.com/p/arduino/issues/detail?id=958&#xA; * ========================================================================= */&#xA;&#xA;&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_QUATERNION&quot; if you want to see the actual&#xA;// quaternion components in a [w, x, y, z] format (not best for parsing&#xA;// on a remote host such as Processing or something though)&#xA;//#define OUTPUT_READABLE_QUATERNION&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_EULER&quot; if you want to see Euler angles&#xA;// (in degrees) calculated from the quaternions coming from the FIFO.&#xA;// Note that Euler angles suffer from gimbal lock (for more info, see&#xA;// http://en.wikipedia.org/wiki/Gimbal_lock)&#xA;//#define OUTPUT_READABLE_EULER&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_YAWPITCHROLL&quot; if you want to see the yaw/&#xA;// pitch/roll angles (in degrees) calculated from the quaternions coming&#xA;// from the FIFO. Note this also requires gravity vector calculations.&#xA;// Also note that yaw/pitch/roll angles suffer from gimbal lock (for&#xA;// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)&#xA;#define OUTPUT_READABLE_YAWPITCHROLL&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_REALACCEL&quot; if you want to see acceleration&#xA;// components with gravity removed. This acceleration reference frame is&#xA;// not compensated for orientation, so +X is always +X according to the&#xA;// sensor, just without the effects of gravity. If you want acceleration&#xA;// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.&#xA;//#define OUTPUT_READABLE_REALACCEL&#xA;&#xA;// uncomment &quot;OUTPUT_READABLE_WORLDACCEL&quot; if you want to see acceleration&#xA;// components with gravity removed and adjusted for the world frame of&#xA;// reference (yaw is relative to initial orientation, since no magnetometer&#xA;// is present in this case). Could be quite handy in some cases.&#xA;//#define OUTPUT_READABLE_WORLDACCEL&#xA;&#xA;// uncomment &quot;OUTPUT_TEAPOT&quot; if you want output that matches the&#xA;// format used for the InvenSense teapot demo&#xA;//#define OUTPUT_TEAPOT&#xA;&#xA;&#xA;&#xA;#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)&#xA;bool blinkState = false;&#xA;&#xA;// MPU control/status vars&#xA;bool dmpReady = false;  // set true if DMP init was successful&#xA;uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU&#xA;uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)&#xA;uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)&#xA;uint16_t fifoCount;     // count of all bytes currently in FIFO&#xA;uint8_t fifoBuffer[64]; // FIFO storage buffer&#xA;&#xA;// orientation/motion vars&#xA;Quaternion q;           // [w, x, y, z]         quaternion container&#xA;VectorInt16 aa;         // [x, y, z]            accel sensor measurements&#xA;VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements&#xA;VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements&#xA;VectorFloat gravity;    // [x, y, z]            gravity vector&#xA;float euler[3];         // [psi, theta, phi]    Euler angle container&#xA;float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector&#xA;&#xA;// packet structure for InvenSense teapot demo&#xA;uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===               INTERRUPT DETECTION ROUTINE                ===&#xA;// ================================================================&#xA;&#xA;volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high&#xA;void dmpDataReady() {&#xA;    mpuInterrupt = true;&#xA;}&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===                      INITIAL SETUP                       ===&#xA;// ================================================================&#xA;&#xA;void setup() {&#xA;  pinMode(6,OUTPUT);&#xA;    // join I2C bus (I2Cdev library doesn't do this automatically)&#xA;    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE&#xA;        Wire.begin();&#xA;        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz). Comment this line if having compilation difficulties with TWBR.&#xA;    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE&#xA;        Fastwire::setup(400, true);&#xA;    #endif&#xA;&#xA;    // initialize serial communication&#xA;    // (115200 chosen because it is required for Teapot Demo output, but it's&#xA;    // really up to you depending on your project)&#xA;    Serial.begin(115200);&#xA;    while (!Serial); // wait for Leonardo enumeration, others continue immediately&#xA;&#xA;    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Arduino&#xA;    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to&#xA;    // the baud timing being too misaligned with processor ticks. You must use&#xA;    // 38400 or slower in these cases, or use some kind of external separate&#xA;    // crystal solution for the UART timer.&#xA;&#xA;    // initialize device&#xA;    Serial.println(F(&quot;Initializing I2C devices...&quot;));&#xA;    mpu.initialize();&#xA;&#xA;    // verify connection&#xA;    Serial.println(F(&quot;Testing device connections...&quot;));&#xA;    Serial.println(mpu.testConnection() ? F(&quot;MPU6050 connection successful&quot;) : F(&quot;MPU6050 connection failed&quot;));&#xA;&#xA;    // wait for ready&#xA;    Serial.println(F(&quot;\nSend any character to begin DMP programming and demo: &quot;));&#xA;    while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer&#xA;    while (!Serial.available());                 // wait for data&#xA;    while (Serial.available() &amp;amp;&amp;amp; Serial.read()); // empty buffer again&#xA;&#xA;    // load and configure the DMP&#xA;    Serial.println(F(&quot;Initializing DMP...&quot;));&#xA;    devStatus = mpu.dmpInitialize();&#xA;&#xA;    // supply your own gyro offsets here, scaled for min sensitivity&#xA;    mpu.setXGyroOffset(29);&#xA;    mpu.setYGyroOffset(44);&#xA;    mpu.setZGyroOffset(21);&#xA;    mpu.setZAccelOffset(1407); // 1688 factory default for my test chip&#xA;&#xA;    // make sure it worked (returns 0 if so)&#xA;    if (devStatus == 0) {&#xA;        // turn on the DMP, now that it's ready&#xA;        Serial.println(F(&quot;Enabling DMP...&quot;));&#xA;        mpu.setDMPEnabled(true);&#xA;&#xA;        // enable Arduino interrupt detection&#xA;        Serial.println(F(&quot;Enabling interrupt detection (Arduino external interrupt 0)...&quot;));&#xA;        attachInterrupt(0, dmpDataReady, RISING);&#xA;        mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;        // set our DMP Ready flag so the main loop() function knows it's okay to use it&#xA;        Serial.println(F(&quot;DMP ready! Waiting for first interrupt...&quot;));&#xA;        dmpReady = true;&#xA;&#xA;        // get expected DMP packet size for later comparison&#xA;        packetSize = mpu.dmpGetFIFOPacketSize();&#xA;    } else {&#xA;        // ERROR!&#xA;        // 1 = initial memory load failed&#xA;        // 2 = DMP configuration updates failed&#xA;        // (if it's going to break, usually the code will be 1)&#xA;        Serial.print(F(&quot;DMP Initialization failed (code &quot;));&#xA;        Serial.print(devStatus);&#xA;        Serial.println(F(&quot;)&quot;));&#xA;    }&#xA;&#xA;    // configure LED for output&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;&#xA;&#xA;// ================================================================&#xA;// ===                    MAIN PROGRAM LOOP                     ===&#xA;// ================================================================&#xA;&#xA;void loop() {&#xA;  analogWrite(6,255);&#xA;    // if programming failed, don't try to do anything&#xA;    if (!dmpReady) return;&#xA;&#xA;    // wait for MPU interrupt or extra packet(s) available&#xA;    while (!mpuInterrupt &amp;amp;&amp;amp; fifoCount &amp;lt; packetSize) {&#xA;        // other program behavior stuff here&#xA;        // .&#xA;        // .&#xA;        // .&#xA;        // if you are really paranoid you can frequently test in between other&#xA;        // stuff to see if mpuInterrupt is true, and if so, &quot;break;&quot; from the&#xA;        // while() loop to immediately process the MPU data&#xA;        // .&#xA;        // .&#xA;        // .&#xA;    }&#xA;&#xA;    // reset interrupt flag and get INT_STATUS byte&#xA;    mpuInterrupt = false;&#xA;    mpuIntStatus = mpu.getIntStatus();&#xA;&#xA;    // get current FIFO count&#xA;    fifoCount = mpu.getFIFOCount();&#xA;&#xA;    // check for overflow (this should never happen unless our code is too inefficient)&#xA;    if ((mpuIntStatus &amp;amp; 0x10) || fifoCount == 1024) {&#xA;        // reset so we can continue cleanly&#xA;        mpu.resetFIFO();&#xA;        Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;&#xA;    // otherwise, check for DMP data ready interrupt (this should happen frequently)&#xA;    } else if (mpuIntStatus &amp;amp; 0x02) {&#xA;        // wait for correct available data length, should be a VERY short wait&#xA;        while (fifoCount &amp;lt; packetSize) fifoCount = mpu.getFIFOCount();&#xA;&#xA;        // read a packet from FIFO&#xA;        mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;&#xA;        // track FIFO count here in case there is &amp;gt; 1 packet available&#xA;        // (this lets us immediately read more without waiting for an interrupt)&#xA;        fifoCount -= packetSize;&#xA;&#xA;        #ifdef OUTPUT_READABLE_QUATERNION&#xA;            // display quaternion values in easy matrix form: w x y z&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            Serial.print(&quot;quat\t&quot;);&#xA;            Serial.print(q.w);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(q.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(q.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(q.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_EULER&#xA;            // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetEuler(euler, &amp;amp;q);&#xA;            Serial.print(&quot;euler\t&quot;);&#xA;            Serial.print(euler[0] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(euler[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(euler[2] * 180/M_PI);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;            // display Euler angles in degrees&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;            Serial.print(&quot;ypr\t&quot;);&#xA;            Serial.print(ypr[0] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(ypr[1] * 180/M_PI);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(ypr[2] * 180/M_PI);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_REALACCEL&#xA;            // display real acceleration, adjusted to remove gravity&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetAccel(&amp;amp;aa, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetLinearAccel(&amp;amp;aaReal, &amp;amp;aa, &amp;amp;gravity);&#xA;            Serial.print(&quot;areal\t&quot;);&#xA;            Serial.print(aaReal.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(aaReal.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(aaReal.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_READABLE_WORLDACCEL&#xA;            // display initial world-frame acceleration, adjusted to remove gravity&#xA;            // and rotated based on known orientation from quaternion&#xA;            mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;            mpu.dmpGetAccel(&amp;amp;aa, fifoBuffer);&#xA;            mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;            mpu.dmpGetLinearAccel(&amp;amp;aaReal, &amp;amp;aa, &amp;amp;gravity);&#xA;            mpu.dmpGetLinearAccelInWorld(&amp;amp;aaWorld, &amp;amp;aaReal, &amp;amp;q);&#xA;            Serial.print(&quot;aworld\t&quot;);&#xA;            Serial.print(aaWorld.x);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print(aaWorld.y);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.println(aaWorld.z);&#xA;        #endif&#xA;&#xA;        #ifdef OUTPUT_TEAPOT&#xA;            // display quaternion values in InvenSense Teapot demo format:&#xA;            teapotPacket[2] = fifoBuffer[0];&#xA;            teapotPacket[3] = fifoBuffer[1];&#xA;            teapotPacket[4] = fifoBuffer[4];&#xA;            teapotPacket[5] = fifoBuffer[5];&#xA;            teapotPacket[6] = fifoBuffer[8];&#xA;            teapotPacket[7] = fifoBuffer[9];&#xA;            teapotPacket[8] = fifoBuffer[12];&#xA;            teapotPacket[9] = fifoBuffer[13];&#xA;            Serial.write(teapotPacket, 14);&#xA;            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose&#xA;        #endif&#xA;&#xA;        // blink LED to indicate activity&#xA;        blinkState = !blinkState;&#xA;        digitalWrite(LED_PIN, blinkState);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20124" LastEditorUserId="26916" LastEditDate="2017-11-04T18:49:51.077" LastActivityDate="2017-11-04T18:49:51.077" Title="Translating accelerometer angle to PWM output (was MPU-6050 DMP6 example)" Tags="|mpu6050|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23048" PostTypeId="2" ParentId="23035" CreationDate="2016-04-12T18:02:34.963" Score="2" Body="&lt;p&gt;Here's a sample program you could use as reference, just replace the values in the array and adjust VALUES_NUMBER accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disclaimer: I didn't try to compile/run it, but it should give you an idea of how to use the values you already have.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// These are Arduino Pins that support &quot;analog&quot; output.&#xA;const unsigned short ANALOG_RED_PIN = 3;&#xA;const unsigned short ANALOG_GREEN_PIN = 5;&#xA;const unsigned short ANALOG_BLUE_PIN = 6;&#xA;&#xA;const unsigned int VALUES_NUMBER = 12;&#xA;&#xA;const unsigned short REDS[VALUES_NUMBER] = {&#xA;  0x00, 0x01, 0x02, 0x03, 0x04, 0x05,&#xA;  0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B&#xA;};&#xA;&#xA;const unsigned short GREENS[VALUES_NUMBER] = {&#xA;  0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,&#xA;  0x00, 0x01, 0x02, 0x03, 0x04, 0x05&#xA;};&#xA;&#xA;const unsigned short BLUES[VALUES_NUMBER] = {&#xA;  0x09, 0x0A, 0x0B, 0x03, 0x04, 0x05,&#xA;  0x00, 0x01, 0x02, 0x06, 0x07, 0x08&#xA;};&#xA;&#xA;void setup() {&#xA;  pinMode(analogRed, OUTPUT);&#xA;  pinMode(analogGreen, OUTPUT);&#xA;  pinMode(analogBlue, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned int counter;&#xA;  for (counter = 0; counter &amp;lt; VALUES_NUMBER; counter++) {&#xA;    analogWrite(ANALOG_RED_PIN, REDS[counter]);&#xA;    analogWrite(ANALOG_GREEN_PIN, GREENS[counter]);&#xA;    analogWrite(ANALOG_BLUE_PIN, BLUES[counter]);&#xA;    delay(1000); //sleep 1 second&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2016-04-12T18:17:09.363" LastActivityDate="2016-04-12T18:17:09.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23050" PostTypeId="2" ParentId="23035" CreationDate="2016-04-12T18:39:57.583" Score="3" Body="&lt;p&gt;You've got quite an interesting project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Programming an Arduino (C++)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino is C++ (or atleast a subset).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE uses the GNU AVR-GCC compiler. And it takes care of all &quot;make&quot; files and stuff. You shouldn't really bother too much. Just paste the code right in, and fix whatever is broken ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE&lt;/a&gt; is basically click&amp;amp;install, click&amp;amp;compile/upload, I'm not sure why you're even trying all the other options.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;For the sake of clarity/simplicity I'll give you an example of sending a single R/G/B pixel to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Matlab&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should set up your Matlab code something like this.&#xA;I'm not a &quot;Matlab guru&quot; nor do I know whatever code you have.&#xA;You should open a COM port and write to it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s = serial('COM1','BAUD',115200);&#xA;fopen(s);&#xA;Pixel pix = getPixelFromBMP(&quot;image.bmp&quot;,0);&#xA;fprintf(s,'%s',pix.r.to_String()+pix.g.to_String()+pix.b.to_String());&#xA;fclose(s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE (withouth worrying about makefiles and toolchains).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do the reverse of what you've done in your Matlab code.&#xA;Read the serial input and write it to the LED strip.&#xA;I'm quite sure this code won't compile, and there are a lot of fancier ways to read the serial buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ledstrip.h&amp;gt;&#xA;&#xA;LedStrip ledStrip;&#xA;&#xA;int incomingByteR = 0;   // for incoming serial data&#xA;int incomingByteG = 0;   // for incoming serial data&#xA;int incomingByteB = 0;   // for incoming serial data&#xA;&#xA;void setup() {&#xA;        Serial.begin(115200);     // opens serial port, sets data rate to 115200 bps&#xA;        ledStrip.begin(1,RGB);    // initializes the ledstrip (RGB).&#xA;}&#xA;&#xA;void loop() {&#xA;        // send data only when you receive data:&#xA;        if (Serial.available() &amp;gt; 3) {&#xA;                // read the incoming byte:&#xA;                incomingByteR = Serial.read();&#xA;                incomingByteG = Serial.read();&#xA;                incomingByteB = Serial.read();&#xA;                // say what you got:&#xA;                Serial.print(&quot;I received: &quot;);&#xA;                Serial.println(incomingByteR, DEC);&#xA;                Serial.println(incomingByteG, DEC);&#xA;                Serial.println(incomingByteB, DEC);&#xA;                ledStrip.pixel[0].r = incomingByteR;&#xA;                ledStrip.pixel[0].g = incomingByteG;&#xA;                ledStrip.pixel[0].b = incomingByteB;&#xA;                ledStrip.show();&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;C++&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you don't really need C++ (other than to program the Arduino). You could interchange Matlab for C++ or Arduino for pure AVR C++, but I wouldn't recommend it.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-12T20:52:58.723" LastActivityDate="2016-04-12T20:52:58.723" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23051" PostTypeId="1" AcceptedAnswerId="23052" CreationDate="2016-04-12T21:09:32.863" Score="1" ViewCount="57" Body="&lt;p&gt;I've been trying to detect a push button based on this &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Button&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt;, but due to my lack of skills/knowledge I haven't been able to make it work, could you guys point out what I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;My &lt;a href=&quot;https://123d.circuits.io/circuits/1945937&quot; rel=&quot;nofollow&quot;&gt;project&lt;/a&gt; on 123d circuits&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;My code:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(2, INPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  digitalWrite(3, HIGH);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  trigger();&#xA;}&#xA;&#xA;void trigger(){&#xA;  if (digitalRead(2) == HIGH) {&#xA;    Serial.println(&quot;Hey&quot;);&#xA;    //turn(); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12111" LastActivityDate="2016-04-12T21:21:36.203" Title="Not being able to use pushbutton" Tags="|button|digital|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23052" PostTypeId="2" ParentId="23051" CreationDate="2016-04-12T21:21:36.203" Score="3" Body="&lt;p&gt;You seem to be suffering from three problems here:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A lack of understanding how the button's pins are configured&lt;/li&gt;&#xA;&lt;li&gt;A lack of understanding of how breadboard works&lt;/li&gt;&#xA;&lt;li&gt;A strange notion (that I have seen around a lot recently for some reason) that a button needs to be driven from an output.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For the button's pins you should know that the pins are paired on the long sides. That is, if you hold the button so it is in &quot;landscape&quot; orientation (wider than it is high) the two upper pins are joined together, and the two lower pins are joined together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7P6Qf.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7P6Qf.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Breadboard consists of strips of connections which, in your diagram, would be running horizontal. Pins plugged into holes horizontally in line with each other on the same side of the board (the gap in the middle is a gap in the connections too) will be connected together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZlNHZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZlNHZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally for the wiring of the button. Nowhere in the tutorial you link to does it ever mention connecting the button to two IO pins. The button should only be connected to one IO pin. It also connects to +5V and, through the resistor, to ground.  Wire it up exactly as it shows you in the tutorial and make it work like that before you try fiddling with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aIqtZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aIqtZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-12T21:21:36.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23053" PostTypeId="2" ParentId="23035" CreationDate="2016-04-12T21:29:23.283" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;As the arduino &quot;language&quot; is C and C++ therefore it is possible to program an Arduino in C++/c. I need a maker file and a compiler. However my question is that isn't there a more non-programmer friendly way to get this done, some software or an IDE which supports Arduino programming in C++?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, it's called the &lt;strong&gt;Arduino IDE&lt;/strong&gt;. You plug your board into the USB port, write your program, or use an existing example, and then hit the Upload button.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-12T21:29:23.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23054" PostTypeId="1" CreationDate="2016-04-12T21:42:39.537" Score="3" ViewCount="77" Body="&lt;p&gt;Expecting the slave to ACKnowledge and return data, but it does not. &lt;a href=&quot;https://gist.github.com/SensationSama/c60253c8553caf29f7353a725ee42fc4&quot; rel=&quot;nofollow&quot;&gt;This is my protocol&lt;/a&gt;. &lt;a href=&quot;https://ams.com/eng/content/download/686523/1787697/file/iAQ-core_Datasheet_EN_v1.pdf&quot; rel=&quot;nofollow&quot;&gt;This is my Datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also FYI I'm on an Arduino Fio but I am not inheriting the Arduino library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;uart.h&amp;gt;&#xA;#include &amp;lt;i2c_master.h&amp;gt;&#xA;&#xA;#define LED PB5&#xA;&#xA;#define I2C_READ 0x5A&#xA;&#xA;char buffer[1];&#xA;&#xA;//char data[9];&#xA;uint16_t val = 0;&#xA;uint8_t status = 0;&#xA;&#xA;&#xA;void getVal()&#xA;{&#xA;  if(i2c_start(I2C_READ))&#xA;    {&#xA;        uart_puts(&quot;Start &quot;);&#xA;&#xA;        val = ((uint8_t)i2c_read_ack())&amp;lt;&amp;lt;8; &#xA;        val |= i2c_read_ack();&#xA;&#xA;    status = ((uint8_t)i2c_read_nack());&#xA;&#xA;      i2c_stop();&#xA;&#xA;    } else&#xA;  {&#xA;        uart_puts(&quot;Error&quot;);&#xA;&#xA;        i2c_stop();&#xA;    }&#xA;}&#xA;&#xA;int main(void)&#xA;{&#xA;  init_uart(57600);&#xA;  i2c_init();&#xA;&#xA;  DDRB = _BV(5);&#xA;&#xA;    for(;;)&#xA;    {&#xA;&#xA;      getVal();&#xA;&#xA;            itoa(status, buffer, 10); //convert decimal to string base 10&#xA;            uart_puts(buffer);&#xA;&#xA;      PORTB = 0xFF;&#xA;      _delay_ms(500);&#xA;      PORTB = 0x00;&#xA;      _delay_ms(500);&#xA;    }&#xA;    return 0;   /* never reached */&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19328" LastEditorUserId="19328" LastEditDate="2016-04-13T01:04:14.497" LastActivityDate="2022-02-19T05:06:20.563" Title="Why am I only receiving the first address byte? (I2C Protocol)" Tags="|i2c|c|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23055" PostTypeId="1" AcceptedAnswerId="23057" CreationDate="2016-04-12T22:14:27.537" Score="1" ViewCount="1749" Body="&lt;p&gt;I'm using the red Ultrasonic Range Sensor with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sig -&gt; Digital Pin 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VCC -&gt; 5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND -&gt; GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code uploads fine and i can hear the sensor clicking away, but for some reason it won't print the distance into the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Settings&#xA;int echoPin= 4;&#xA;int trigPin= 4;&#xA;unsigned long pulsetime = 0;&#xA;unsigned distance = 0;&#xA;unsigned OldDistance = 0;&#xA;&#xA;void setup (){&#xA;  pinMode (echoPin, INPUT);&#xA;  pinMode (trigPin, OUTPUT);&#xA;  Serial.begin(9600);  &#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  //Work out the distance&#xA;  digitalWrite(trigPin, LOW);&#xA;  delayMicroseconds(100);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(100);&#xA;  digitalWrite(trigPin, LOW);&#xA;  pulsetime = pulseIn(echoPin, HIGH);&#xA;  distance = pulsetime / 58;&#xA;  delay(10);&#xA;&#xA;&#xA;  //Send value if it's changed&#xA;  if (OldDistance != distance) {&#xA;&#xA;  Serial.print(distance); &#xA;&#xA;  OldDistance = distance;&#xA;  }&#xA;&#xA;  delay(50);  // Wait .1 Seconds&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20139" LastActivityDate="2016-04-12T23:16:49.417" Title="Ultrasonic Range Sensor won't print distance in Serial Monitor" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23056" PostTypeId="2" ParentId="21769" CreationDate="2016-04-12T22:23:40.717" Score="3" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Open the &quot;Preferences&quot; dialog in the Arduino IDE.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Click on the symbol next to &quot;Additional Board Manager URLs&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dKgF0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dKgF0.png&quot; alt=&quot;Additional Board Manager URLs&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Paste the following into the box (possibly on a new line under any existing URLs), then click OK.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LHX4Q.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LHX4Q.png&quot; alt=&quot;Add board URL&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you can click on the circled link for a list of boards. This will open in your web browser. You may have to switch to your browser to notice it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JIh4H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JIh4H.png&quot; alt=&quot;List of unofficial boards&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Click OK to close the Preferences dialog box.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the Tools menu / Board select the Boards Manager:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VuJqY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VuJqY.png&quot; alt=&quot;Boards Manager&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Scroll down until you see the Attiny entry (or the one for the board you want), click on it to select it, and then click &quot;Install&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qIRzw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qIRzw.png&quot; alt=&quot;Install Attiny&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once done, close the Board Manager dialog box.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You should now be able to select Attiny from the Boards menu:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7GlZv.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7GlZv.png&quot; alt=&quot;Select Attiny&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now in the Tools menu you can select which Attiny you want to use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u64TK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u64TK.png&quot; alt=&quot;Which Attiny&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Notice you can also select the appropriate clock speed in an adjacent menu item.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To program the Attiny you will need a suitable ISP (In System Programmer) such as the AVRISP programmer, or the USBtinyISP programmer.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-12T22:23:40.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23057" PostTypeId="2" ParentId="23055" CreationDate="2016-04-12T22:40:34.790" Score="1" Body="&lt;p&gt;You have to manually switch from OUTPUT (for sending the trigger pulse) and INPUT (for reading the distance) mode on the shared IO pin.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Work out the distance&#xA;pinMode(trigPin, OUTPUT);    // &amp;lt;&amp;lt; ADD THIS&#xA;digitalWrite(trigPin, LOW);&#xA;delayMicroseconds(100);&#xA;digitalWrite(trigPin, HIGH);&#xA;delayMicroseconds(100);&#xA;digitalWrite(trigPin, LOW);&#xA;pinMode(echoPin, INPUT);     // &amp;lt;&amp;lt; ADD THIS&#xA;pulsetime = pulseIn(echoPin, HIGH);&#xA;distance = pulsetime / 58;&#xA;delay(10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To save some confusion you might like to change your code to just use &lt;code&gt;sigPin&lt;/code&gt; instead of a pair of pins that are both the same pin.  That way you would avoid confusing bits like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode (echoPin, INPUT);&#xA;pinMode (trigPin, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which of course is the equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode (4, INPUT);&#xA;pinMode (4, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-12T22:40:34.790" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23058" PostTypeId="2" ParentId="23055" CreationDate="2016-04-12T23:16:49.417" Score="0" Body="&lt;p&gt;Two suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;setup()&lt;/code&gt; after you open the serial port, execute something like &lt;code&gt;Serial.println(&quot;Sensor Test Program&quot;);&lt;/code&gt;, and in loop, print the distance value with something like &lt;code&gt;Serial.print(&quot;dist: &quot;); Serial.println(distance);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will tell you two things: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;whether your port is open and working at all; and&lt;/li&gt;&#xA;&lt;li&gt;whether control reached your output statement (in loop) and that it tried to print something.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this case, it seems unlikely that control didn't reach &lt;code&gt;Serial.print(distance);&lt;/code&gt; but more information, at least in the early stages, helps when things don't work as you'd expected them to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should have seen &lt;em&gt;some&lt;/em&gt; output from your output statement, even if it was wrong. No output suggests:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;control didn't get there (perhaps due to a program crash, especially if this is a fragment of a large program);&lt;/li&gt;&#xA;&lt;li&gt;the terminal program and the Arduino's baud rates don't match;&lt;/li&gt;&#xA;&lt;li&gt;the terminal program was opened to the wrong port; &lt;/li&gt;&#xA;&lt;li&gt;the terminal program wasn't opened at all;&lt;/li&gt;&#xA;&lt;li&gt;the calculation (or operation of the device, perhaps in the manner @majenko suggested) failed such that the distance calculation always yielded zero, and the 'if' statement was therefore never satisfied (my guess), i.e., back to my first point, control didn't get there.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-12T23:16:49.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23059" PostTypeId="1" AcceptedAnswerId="23083" CreationDate="2016-04-12T23:55:58.233" Score="2" ViewCount="2327" Body="&lt;p&gt;I am having a problem getting my functions to run properly from the loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am building a model railroad crossing gate and need to run the 4 processes once the sensor signals the train entering the crossing zone. For right now I need to learn how to &quot;function&quot; in C++ running in loop, as I'm a C# ASP.Net guy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought process was in loop to &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Check entry sensor, this is all the loop should ever do UNTIL its tripped&lt;/li&gt;&#xA;&lt;li&gt;Once tripped, run the 4 processes functions (close the gates, turn on the sound, turn on the flashers, power down the road that crosses the tracks)&lt;/li&gt;&#xA;&lt;li&gt;After the entry sensor is tripped and the processes run (the sound and flashers should operate continuously until the exit sensor is cleared) the exit sensor must be monitored, and once its tripped, its monitored until it goes static again indicating the train has cleared. Then the 4 process are run to shut down the flashers, shut the sound, power up the road and raise the gates.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Right now I'm just trying to get the sound functioning properly. Right now, as the code stands, it plays for a split second then stops. I need that file playing until I call the function to stop it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code so far. I've removed the includes and defines for brevity.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// These are the pins used for the music maker shield&#xA;#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)&#xA;#define SHIELD_CS     7      // VS1053 chip select pin (output)&#xA;#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)&#xA;&#xA;// These are common pins between breakout and shield&#xA;#define CARDCS 4     // Card chip select pin&#xA;// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt&#xA;#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin&#xA;&#xA;// create shield-example object&#xA;Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&#xA;//global variables required&#xA;boolean crossingSignalInOperation = false;&#xA;boolean signalEntrySensor = false;&#xA;boolean signalExitSensor = false;&#xA;boolean debugMode = false;&#xA;&#xA;boolean checkEntrySensor() {&#xA;    //check entry sensor, if tripped return true otherwise false&#xA;    /*if () return true;&#xA;    return false;*/&#xA;    return true;  //hardcoded for testing&#xA;}&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;    debugMode = true;   //set this to false once code is fully operational&#xA;    //initialise music maker shield&#xA;        if (!musicPlayer.begin()) { &#xA;            if (debugMode)&#xA;            {&#xA;                Serial.println(F(&quot;Couldn't find VS1053, do you have the right pins defined?&quot;));&#xA;            }&#xA;&#xA;        while (1);&#xA;    }&#xA;    // 1st parameter is left, second parameter is right             &#xA;    musicPlayer.setVolume(20, 20);&#xA;    if (debugMode)&#xA;    {&#xA;        Serial.println(F(&quot;VS1053 found&quot;));&#xA;    }&#xA;&#xA;    // initialise the SD card&#xA;    SD.begin(CARDCS);    &#xA;&#xA;    //ensure our global booleans all start false&#xA;    crossingSignalInOperation = false;  &#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    // put your main code here, to run repeatedly&#xA;&#xA;    signalEntrySensor = checkEntrySensor();&#xA;    if (signalEntrySensor == true) {  //only want to catch the FIRST time it senses&#xA;        if (crossingSignalInOperation == false)&#xA;        {&#xA;            //crossing signal is inactive, activate it&#xA;            // turn the sound on and return the music player object&#xA;            Adafruit_VS1053_FilePlayer mp = onSignalSound(musicPlayer,&quot;trainxng.mp3&quot;);  &#xA;&#xA;            while (mp.playingMusic) {&#xA;                // file is now playing in the 'background' so now's a good time&#xA;                // to do something else &#xA;                if (!crossingSignalInOperation)&#xA;                {                   &#xA;                    crossingSignalInOperation = true;&#xA;                    //run the other three processes&#xA;                    //offRoadPower();&#xA;                    //lowerSignalArms();&#xA;                    //startSignalFlashers();&#xA;&#xA;                }               &#xA;            }                   &#xA;        }&#xA;    }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here are the functions;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {&#xA;    // Play the train crossing sound file&#xA;    if (debugMode)&#xA;    {&#xA;        Serial.println(F(&quot;Playing track - &quot;));&#xA;        Serial.print(fileName);&#xA;    }&#xA;    //all sound files are on the micro sd card on the music player shield&#xA;    if (!mp.startPlayingFile(fileName)) {&#xA;        Serial.println(F(&quot;Could not open file &quot;));&#xA;        Serial.print(fileName);&#xA;        while (1);&#xA;    }&#xA;    return mp;&#xA;}&#xA;boolean offSignalSound(Adafruit_VS1053_FilePlayer mp) {&#xA;    if (mp.playingMusic)&#xA;    {&#xA;        mp.stopPlaying();&#xA;        return true;&#xA;    }&#xA;    return true;    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any assistance would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;New version using the state machine methodology suggested by JRobert and Edgar&#xA;Any comments on structure?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include SPI, MP3 and SD libraries&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_VS1053.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;// include AccelStepper libraries&#xA;#include &amp;lt;MultiStepper.h&amp;gt;&#xA;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;using namespace std;&#xA;/*-----( Declare Enums &amp;amp; Constants )-----*/&#xA;// Arduino Digital I/O pin numbers for MEGA&#xA;//note: digital pins 30-45 &#xA;//MEGA is a MUST for this project&#xA;enum {&#xA;    Relay1 = 30, Relay2 = 31, Relay3 = 32, Relay4 = 33, Relay5 = 34, Relay6 = 35,&#xA;    Relay7 = 36, Relay8 = 37, Relay9 = 38, Relay10 = 39, Relay11 = 40,&#xA;    Relay12 = 41, Relay13 = 42, Relay14 = 43, Relay15 = 44, Relay16 = 45&#xA;};&#xA;&#xA;enum { RELAY_OFF = HIGH, RELAY_ON = LOW };&#xA;&#xA;enum {&#xA;    CROSSINGZONE_CLEAR, // no train in crossing area, also initialized state&#xA;    CROSSINGZONE_OCCUPIED, // train detected by the entry sensor&#xA;    CROSSINGZONE_EXITING  // train detected by the exit sensor, when sensor clears state = CLEAR&#xA;};&#xA;&#xA; enum {&#xA;     EXITSENSOR_CLEAR, // no train has passed the crossing gate exit sensor&#xA;     EXITSENSOR_ENTERED, // train detected by the exit sensor&#xA;     EXITSENSOR_WAITINGTOCLEAR // train passed by the exit sensor, when sensor clears state = CLEAR&#xA;&#xA; };&#xA;&#xA;byte state = CROSSINGZONE_CLEAR;&#xA; //*-----( Declare Variables )-----*/&#xA;// hardware is an optocoupler 16 channel 12V relay&#xA;const byte relays[] = { Relay1,Relay2,Relay3,Relay4,&#xA;Relay5,Relay6,Relay7,Relay8,&#xA;Relay9,Relay10,Relay11,Relay12,&#xA;Relay13,Relay14,Relay15,Relay16 };&#xA;enum { maxRelayCount = sizeof relays / sizeof relays[0] };&#xA;&#xA;byte entrySensorPin = 26;&#xA;byte exitSensorPin = 28;&#xA;const char* soundFile = &quot;trainxng.mp3&quot;;&#xA;boolean debugMode = true;&#xA;boolean exitSensorTripped = false;&#xA;&#xA;// These are the pins used for the music maker shield&#xA;#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)&#xA;#define SHIELD_CS     7      // VS1053 chip select pin (output)&#xA;#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)&#xA;// These are common pins between breakout and shield&#xA;#define CARDCS 4     // Card chip select pin&#xA;// DREQ should be an Int pin, see  http://arduino.cc/en/Reference/attachInterrupt&#xA;#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin&#xA;&#xA;AccelStepper gateMotor1Left(AccelStepper::DRIVER, 4, 3);  // 1=Stepper driver option, 4=Step pulse pin, 3=Direction&#xA;AccelStepper gateMotor1Right(AccelStepper::DRIVER, 6, 5);  // 1=Stepper driver option, 6=Step pulse pin, 5=Direction&#xA;AccelStepper gateMotor2Left(AccelStepper::DRIVER, 8, 7);  // 1=Stepper driver option, 8=Step pulse pin, 7=Direction&#xA;AccelStepper gateMotor2Right(AccelStepper::DRIVER, 10, 9);  // 1=Stepper driver option, 10=Step pulse pin, 9=Direction&#xA;Adafruit_VS1053_FilePlayer musicPlayer =&#xA;    Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&#xA;&#xA;class CrossingGate {&#xA;  public:&#xA;    // hmm voids or booleans? &#xA;    boolean GateFlashersOn(byte relayNumber) {&#xA;        digitalWrite(relayNumber, RELAY_ON);&#xA;        //need a check here to ensure its set LOW which is inactive for these relays&#xA;        return true;&#xA;    }&#xA;    boolean GateFlashersOff(byte relayNumber) {&#xA;        digitalWrite(relayNumber, RELAY_OFF);&#xA;        //need a check here to ensure its set HIGH which is inactive for these relays&#xA;        return true;&#xA;    }&#xA;    boolean GateArmFlashersOn(byte relayNumber) {&#xA;        digitalWrite(relayNumber, RELAY_ON);&#xA;        //need a check here to ensure its set LOW which is inactive for these relays&#xA;        return true;&#xA;     }&#xA;     boolean GateArmFlashersOff(byte relayNumber) {&#xA;         digitalWrite(relayNumber, RELAY_OFF);&#xA;        //need a check here to ensure its set HIGH which is inactive for these relays&#xA;        return true;&#xA;    }&#xA;    boolean GatesUp(byte relayNumber) {&#xA;        digitalWrite(relayNumber, RELAY_ON);&#xA;        //need a check here to ensure its set LOW which is inactive for these relays&#xA;        return true;&#xA;    }&#xA;    boolean GatesDown(byte relayNumber) {&#xA;        digitalWrite(relayNumber, RELAY_OFF);&#xA;        //need a check here to ensure its set HIGH which is inactive for these relays&#xA;        return true;&#xA;    }&#xA;&#xA;};&#xA;&#xA; class CrossingGateRoad {&#xA;   public:&#xA;       void PowerOn(byte relayNumber) {&#xA;           digitalWrite(relayNumber, RELAY_ON);&#xA;&#xA;       }&#xA;       void PowerOff(byte relayNumber) {&#xA;           digitalWrite(relayNumber, RELAY_OFF);&#xA;&#xA;       }&#xA;};&#xA;//  Sensor methods&#xA;int CheckEntrySensor(byte esp) {&#xA;    if (digitalRead(esp) == HIGH)&#xA;    {&#xA;         state = CROSSINGZONE_CLEAR;&#xA;         return CROSSINGZONE_CLEAR;&#xA;    }&#xA;    else {&#xA;        state = CROSSINGZONE_OCCUPIED;&#xA;        return CROSSINGZONE_OCCUPIED;&#xA;    }&#xA;     return -1;&#xA;}&#xA;int CheckExitSensor(byte xsp) {&#xA;    if (digitalRead(xsp) == HIGH &amp;amp;&amp;amp; state == CROSSINGZONE_OCCUPIED)&#xA;    {&#xA;        state = CROSSINGZONE_OCCUPIED;&#xA;        return CROSSINGZONE_OCCUPIED;&#xA;    }&#xA;    else if(digitalRead(xsp) == LOW &amp;amp;&amp;amp; state == CROSSINGZONE_OCCUPIED)&#xA;    {&#xA;        state = CROSSINGZONE_CLEAR;&#xA;        return CROSSINGZONE_OCCUPIED;&#xA;    }&#xA;    return -1;&#xA;}&#xA;&#xA;boolean CrossingBellsOn(Adafruit_VS1053_FilePlayer &amp;amp; mp, const char* soundFile) {&#xA;    if (!mp.startPlayingFile(soundFile)) {&#xA;        Serial.println(&quot;Could not open file trainxng.mp3 using the passed in object&quot;);&#xA;        while (1);&#xA;    }&#xA;    return true;&#xA;}&#xA;boolean CrossingBellsOff(Adafruit_VS1053_FilePlayer &amp;amp; mp) {&#xA;    if (mp.playingMusic) {&#xA;        mp.stopPlaying();&#xA;         return true;&#xA;    }&#xA;    if (mp.stopped())&#xA;    {&#xA;        return true;&#xA;    }&#xA;    return false;&#xA;}&#xA;&#xA;CrossingGate xGate1Left;&#xA;CrossingGate xGate1Right;&#xA;CrossingGate xGate2Left;&#xA;CrossingGate xGate2Right;&#xA;&#xA;CrossingGateRoad xGateRoad;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    // Set max speed. Steps per second&#xA;    gateMotor1Left.setMaxSpeed(500); &#xA;    gateMotor2Left.setMaxSpeed(500); &#xA;    gateMotor1Right.setMaxSpeed(500); &#xA;    gateMotor2Right.setMaxSpeed(500); &#xA;    // set motor acceleration&#xA;    gateMotor1Left.setAcceleration(35);  &#xA;    gateMotor2Left.setAcceleration(35);  &#xA;    gateMotor1Right.setAcceleration(35); &#xA;    gateMotor2Right.setAcceleration(35);  &#xA;    // set motor speeds&#xA;    gateMotor1Left.setSpeed(20);&#xA;    gateMotor2Left.setSpeed(20);&#xA;    gateMotor1Right.setSpeed(20);&#xA;    gateMotor2Right.setSpeed(20);&#xA;&#xA;    Serial.println(&quot;Adafruit VS1053 Library Test&quot;);&#xA;    // initialise the music player&#xA;    if (!musicPlayer.begin()) { // initialise the music player&#xA;         Serial.println(F(&quot;Couldn't find VS1053, do you have the right pins defined?&quot;));&#xA;        while (1);&#xA;    }&#xA;    Serial.println(F(&quot;VS1053 found&quot;));&#xA;    //musicPlayer.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working&#xA;    // check the card reader&#xA;    if (!SD.begin(CARDCS)) {&#xA;        Serial.println(F(&quot;SD failed, or not present&quot;));&#xA;        while (1);  &#xA;    }&#xA;    Serial.println(&quot;SD OK!&quot;);&#xA;    // Set volume for left, right channels. lower numbers == louder volume!&#xA;    musicPlayer.setVolume(20, 20);&#xA;&#xA;    // This option uses a pin interrupt. But DREQ must be on an&#xA;    //  interrupt pin. For Uno/Duemilanove/Diecimilla that's Digital #2 or #3 &#xA;    // See http://arduino.cc/en/Reference/attachInterrupt for other pins&#xA;    // * This is the preferred method&#xA;    if (!musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))&#xA;        Serial.println(F(&quot;DREQ pin is not an interrupt pin&quot;));&#xA;&#xA;}&#xA;void loop() {&#xA;&#xA;    switch (state) {&#xA;        case CROSSINGZONE_CLEAR:&#xA;          // Check entry sensor. If tripped, turn on the sound.&#xA;         if (CheckEntrySensor(entrySensorPin) == 1) {&#xA;            // first go around i'll try to tun all these here otherwise&#xA;            // I will break out to more states&#xA;            //these happen instantly&#xA;            xGateRoad.PowerOff(relays[0]);&#xA;            xGate1Left.GateArmFlashersOn(relays[1]);&#xA;            xGate1Right.GateArmFlashersOn(relays[2]);&#xA;            xGate2Left.GateArmFlashersOn(relays[3]);&#xA;            xGate2Right.GateArmFlashersOn(relays[4]);&#xA;            xGate1Left.GateFlashersOn(relays[5]);&#xA;            xGate1Right.GateFlashersOn(relays[6]);&#xA;            xGate2Left.GateFlashersOn(relays[7]);&#xA;            xGate2Right.GateFlashersOn(relays[8]);&#xA;            //these take some time&#xA;            xGate1Left.GatesDown(relays[9]);&#xA;            xGate1Right.GatesDown(relays[10]);&#xA;            xGate2Left.GatesDown(relays[11]);&#xA;            xGate2Right.GatesDown(relays[12]);&#xA;            //this is the last process, if it completes change state&#xA;            if (CrossingBellsOn(musicPlayer, soundFile)) {&#xA;                state = CROSSINGZONE_OCCUPIED;&#xA;            }           &#xA;        }&#xA;        else {&#xA;            state = CROSSINGZONE_CLEAR;&#xA;        }&#xA;        break;&#xA;    case CROSSINGZONE_OCCUPIED:     &#xA;        // Once zone is occupied, monitor the exit sensor&#xA;        if (CheckExitSensor(exitSensorPin) == 0) { // Exit sensor not tripped yet&#xA;            state = CROSSINGZONE_OCCUPIED;&#xA;        }&#xA;        else {&#xA;            exitSensorTripped = true;&#xA;        }&#xA;        if (exitSensorTripped)&#xA;        {&#xA;             // need to code here to wait until Exit Sensor has 1500 milliseconds where its clear&#xA;            // to indicate that the last car of train has passed it&#xA;            // if above set exitSensorTripped back to false and state to EXITING&#xA;            state = CROSSINGZONE_EXITING;&#xA;        }&#xA;        break;&#xA;    case CROSSINGZONE_EXITING:&#xA;        // Check if the train has cleared, then shut the sound.&#xA;        if (CheckExitSensor(exitSensorPin) == 1) {&#xA;            // first go around i'll try to tun all these here otherwise&#xA;            // I will break out to more states&#xA;            //these happen instantly&#xA;            xGateRoad.PowerOn(relays[0]);&#xA;            xGate1Left.GateArmFlashersOff(relays[1]);&#xA;            xGate1Right.GateArmFlashersOff(relays[2]);&#xA;            xGate2Left.GateArmFlashersOff(relays[3]);&#xA;            xGate2Right.GateArmFlashersOff(relays[4]);&#xA;            xGate1Left.GateArmFlashersOff(relays[5]);&#xA;            xGate1Right.GateArmFlashersOff(relays[6]);&#xA;            xGate2Left.GateArmFlashersOff(relays[7]);&#xA;            xGate2Right.GateArmFlashersOff(relays[8]);&#xA;            //these take some time&#xA;            xGate1Left.GatesUp(relays[9]);&#xA;            xGate1Right.GatesUp(relays[10]);&#xA;            xGate2Left.GatesUp(relays[11]);&#xA;            xGate2Right.GatesUp(relays[12]);&#xA;            //this is the last process, if it completes change state&#xA;            if (CrossingBellsOff(musicPlayer)) {&#xA;                state = CROSSINGZONE_CLEAR;&#xA;            }&#xA;        }&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-04-15T21:10:23.957" LastActivityDate="2016-04-15T21:10:23.957" Title="Proper way to run functions in loop" Tags="|arduino-uno|programming|sound|" AnswerCount="3" CommentCount="5" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23060" PostTypeId="2" ParentId="23035" CreationDate="2016-04-13T00:15:13.940" Score="-1" Body="&lt;p&gt;Use the Visual Studio free community edition (or the paid versions if you already have them) with the Visual Micro extension for Arduino. Makes life a lot easier since you have indicated your desire to write in C++, and you get true debugging and intellisense as well, which you DO NOT get with the aforementioned IDE's.&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-04-23T10:24:08.833" LastActivityDate="2016-04-23T10:24:08.833" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23061" PostTypeId="2" ParentId="23059" CreationDate="2016-04-13T00:21:28.453" Score="1" Body="&lt;p&gt;This is a classic state-machine problem. That isn't the only way to do it but it's just made for this kind of problem, one in which only certain external events are interesting at a given time; and when such an event occurs, the controller must tweak the outside world in some way, and then start paying attention to a different set of interesting events. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does playing a sound file totally occupy the Arduino until the sound is done? And if so, can your process tolerate the controller being unresponsive for the duration of the sound track? Because otherwise you'll need something more capable than an Arduino, or you'll need to be able to program the Arduino to feed the sound in small pieces to a buffered sound card, so it (the Arduino) can continue monitoring the interesting set of possible events while the sound is playing. That probably means some clever programming with the SimpleTimer library or similar, or using interrupt service routines to inform some part of your code when an event occurs. Probably the ideal cases would be to have a &quot;sound machine&quot; that can play 'n' different tracks, and would do so autonomously when told to start playing track 'j'. Begins to sound like another MCU just handling sound, doesn't it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look up state machine diagrams - basically circles representing states and arrows representing transitions to a new state in response to an events. There are several ways to put the state machine's control of the external equipment; my choice is that each state &quot;does something&quot; then &quot;waits for something to happen&quot;, where something to happen may include a clock signal indicating the event(s) it was waiting for didn't happen (i.e. a timeout). Look at some state diagrams to get an idea how they are used, then start diagramming your own project. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I draw the &quot;happy path&quot; straight down the page - that path that represents the normal or expected operation - with less usual or error paths drawn to either side. At that point you should be pretty confident in your algorithm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to code state machines - that'll be a further discussion.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-14T17:43:52.920" LastActivityDate="2016-04-14T17:43:52.920" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23062" PostTypeId="2" ParentId="23059" CreationDate="2016-04-13T00:24:32.247" Score="0" Body="&lt;p&gt;I think your problem here is that you are using multiple instances of Adafruit_VS1053_FilePlayer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Namely:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's two already.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you pass a copy here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_VS1053_FilePlayer onSignalSound(Adafruit_VS1053_FilePlayer mp, const char* fileName) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And return another copy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;return mp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All this creating/destroying copies is probably stopping the playback of the current copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've reworked your code to avoid all that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_VS1053.h&amp;gt;&#xA;&#xA;// These are the pins used for the music maker shield&#xA;#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)&#xA;#define SHIELD_CS     7      // VS1053 chip select pin (output)&#xA;#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)&#xA;&#xA;// These are common pins between breakout and shield&#xA;#define CARDCS 4     // Card chip select pin&#xA;// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt&#xA;#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin&#xA;&#xA;// create shield-example object&#xA;Adafruit_VS1053_FilePlayer musicPlayer (SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&#xA;//global variables required&#xA;boolean crossingSignalInOperation = false;&#xA;boolean signalEntrySensor = false;&#xA;boolean signalExitSensor = false;&#xA;boolean debugMode = false;&#xA;&#xA;boolean checkEntrySensor() {&#xA;    //check entry sensor, if tripped return true otherwise false&#xA;    /*if () return true;&#xA;    return false;*/&#xA;    return true;  //hardcoded for testing&#xA;}&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;    debugMode = true;   //set this to false once code is fully operational&#xA;    //initialise music maker shield&#xA;        if (!musicPlayer.begin()) { &#xA;            if (debugMode)&#xA;            {&#xA;                Serial.println(F(&quot;Couldn't find VS1053, do you have the right pins defined?&quot;));&#xA;            }&#xA;&#xA;        while (1);&#xA;    }&#xA;    // 1st parameter is left, second parameter is right             &#xA;    musicPlayer.setVolume(20, 20);&#xA;    if (debugMode)&#xA;    {&#xA;        Serial.println(F(&quot;VS1053 found&quot;));&#xA;    }&#xA;&#xA;    // initialise the SD card&#xA;    SD.begin(CARDCS);    &#xA;&#xA;    //ensure our global booleans all start false&#xA;    crossingSignalInOperation = false;  &#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    // put your main code here, to run repeatedly&#xA;&#xA;    signalEntrySensor = checkEntrySensor();&#xA;    if (signalEntrySensor == true) {  //only want to catch the FIRST time it senses&#xA;        if (crossingSignalInOperation == false)&#xA;        {&#xA;            //crossing signal is inactive, activate it&#xA;            // turn the sound on and return the music player object&#xA;            onSignalSound(musicPlayer,&quot;trainxng.mp3&quot;);  &#xA;&#xA;            while (musicPlayer.playingMusic) {&#xA;                // file is now playing in the 'background' so now's a good time&#xA;                // to do something else &#xA;                if (!crossingSignalInOperation)&#xA;                {                   &#xA;                    crossingSignalInOperation = true;&#xA;                    //run the other three processes&#xA;                    //offRoadPower();&#xA;                    //lowerSignalArms();&#xA;                    //startSignalFlashers();&#xA;&#xA;                }               &#xA;            }                   &#xA;        }&#xA;    }&#xA; }&#xA;&#xA;void onSignalSound(Adafruit_VS1053_FilePlayer &amp;amp; mp, const char* fileName) {&#xA;    // Play the train crossing sound file&#xA;    if (debugMode)&#xA;    {&#xA;        Serial.println(F(&quot;Playing track - &quot;));&#xA;        Serial.print(fileName);&#xA;    }&#xA;    //all sound files are on the micro sd card on the music player shield&#xA;    if (!mp.startPlayingFile(fileName)) {&#xA;        Serial.println(F(&quot;Could not open file &quot;));&#xA;        Serial.print(fileName);&#xA;        while (1);&#xA;    }&#xA;}&#xA;boolean offSignalSound(Adafruit_VS1053_FilePlayer &amp;amp; mp) {&#xA;    if (mp.playingMusic)&#xA;    {&#xA;        mp.stopPlaying();&#xA;        return true;&#xA;    }&#xA;    return true;    &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Untested, because I don't have the hardware, but that should work better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Adafruit_VS1053_FilePlayer object is passed &lt;strong&gt;by reference&lt;/strong&gt; to the function, which avoids another copy being made. We are using the original one at global scope, so we don't keep creating and discarding copies. In fact, since we are using the global one you could avoid passing it to the function at all.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-13T00:24:32.247" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23063" PostTypeId="1" AcceptedAnswerId="23079" CreationDate="2016-04-13T00:24:38.793" Score="6" ViewCount="11565" Body="&lt;p&gt;I want to write a class that allows the user to attach his own function to a member function that listens for messages coming from a wireless module, so that the user's function can be called depending on the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking about using function pointers but I don't know how it will work since I don't know the user's function parameters, return type and number of functions that will be added.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//sketch.ino&#xA;&#xA;&amp;lt;unknown&amp;gt; (*funcPtr)(&amp;lt;unknown&amp;gt;)[&amp;lt;unknown&amp;gt;];&#xA;&#xA;void receive() {&#xA;  message.type = 'o';&#xA;  if (message.available()) {&#xA;    message.receive();&#xA;  }&#xA;  switch (message.type) {&#xA;    case 'p': {&#xA;      Serial.println(p);&#xA;      break;&#xA;    }&#xA;    case 'f': {&#xA;      funcPtr[message.funcID](message.parameter1, message.parameter2);&#xA;      break;&#xA;    }&#xA;    default: break;&#xA;}&#xA;&#xA;void userFunction1() {&#xA;  Serial.println(&quot;User function 1&quot;);&#xA;}&#xA;&#xA;int userFunction2(int x) {&#xA;  return x * 2;&#xA;}&#xA;&#xA;funcPtr[0] = &amp;amp;userFunction1;&#xA;funcPtr[1] = &amp;amp;userFunction2;&#xA;&#xA;void setup() {}&#xA;&#xA;void loop() {&#xA;  receive();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this kind of thing possible?&lt;/p&gt;&#xA;" OwnerUserId="7123" LastActivityDate="2016-04-13T08:52:05.563" Title="User callback functions" Tags="|c++|pointer|callbacks|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23064" PostTypeId="1" CreationDate="2016-04-13T01:29:17.317" Score="2" ViewCount="104" Body="&lt;p&gt;Does anyone know how to simultaneously power a Nexus 7 tablet while simultaneously reading serial data from an arduino over USB? I have had quite some trouble with this and have attempted multiple combinations of usb splitters but no luck. I have also tried to use the nexus's inductive charging while using the arduino usb power. While this does work I need to use the Nexus NFC chip at the same time. What I really need is a solution that allows me USB Data, NFC, and power all at the same time. &lt;/p&gt;&#xA;" OwnerUserId="20143" LastActivityDate="2016-04-13T01:29:17.317" Title="How to get power for a nexus 7 while reading serial data from an arduino over usb?" Tags="|arduino-uno|power|usb|voltage-level|android|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23065" PostTypeId="2" ParentId="23047" CreationDate="2016-04-13T01:45:29.917" Score="1" Body="&lt;p&gt;It looks like the only &lt;code&gt;analogWrite(6...)&lt;/code&gt; is the &lt;code&gt;analogWrite(6,255)&lt;/code&gt; at the top of &lt;code&gt;loop(){}&lt;/code&gt; which makes the output on pin 6 insensitive to any changes.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-04-13T01:45:29.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23066" PostTypeId="1" AcceptedAnswerId="23103" CreationDate="2016-04-13T02:35:36.907" Score="1" ViewCount="11460" Body="&lt;p&gt;Sending data to the server(thingspeak.com/184.106.153.14) with AT commands on serial monitor works fine but whenever i upload the sketch ,the following always return false &lt;code&gt;if(Serial.find( &quot;&amp;gt;&quot; ) )&lt;/code&gt;. I am not sure if &lt;code&gt;AT+CIPSEND&lt;/code&gt; is not working correctly or what. I am using Arduino with ESP8266. Any help will be appreciated.Thanks you in advance. Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;  SoftwareSerial softSerial(2, 3); // RX, TX&#xA;&#xA;  #define SSID &quot;myssid&quot;&#xA;  #define PASS &quot;Mypass&quot;&#xA;  #define IP &quot;184.106.153.149&quot; // ThingSpeak &#xA;&#xA;  void setup() &#xA;  {&#xA;   uint32_t baud = 9600;&#xA;   Serial.begin(baud);&#xA;   softSerial.begin(baud);&#xA;&#xA;   connectWiFi();&#xA;   }&#xA;&#xA;   void loop() &#xA;   {&#xA;    updateTS();&#xA;    }&#xA;&#xA;    void updateTS()&#xA;    {&#xA;    String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;// Setup TCP connection&#xA;    cmd += IP;&#xA;    cmd += &quot;\&quot;,80&quot;;&#xA;    sendDebug(cmd);&#xA;    delay(2000);&#xA;&#xA;    String url = &quot;GET /update?key=P55Z0BDASNQBFQKT&amp;amp;field1=15&amp;amp;field2=25\r\n\r\n&quot;; //hard code value 15 and 25&#xA;    String stringLength=&quot;AT+CIPSEND=&quot;;&#xA;    stringLength +=String(url.length( ));&#xA;    Serial.println(stringLength);&#xA;    //delay(10000); I even tried to delay for few seconds&#xA;&#xA;   //Here is where it fails,it jumps to closing the connection&#xA;   if(Serial.find( &quot;&amp;gt;&quot; ) )&#xA;    {&#xA;     softSerial.print(&quot;&amp;gt;&quot;);&#xA;     softSerial.print(cmds);&#xA;     Serial.print(cmds);&#xA;    }&#xA;    else&#xA;    {&#xA;     sendDebug( &quot;AT+CIPCLOSE&quot; );//close TCP connection&#xA;    }&#xA;&#xA;    }&#xA;&#xA;&#xA;   void sendDebug(String cmd)&#xA;    {&#xA;      softSerial.print(&quot;SEND: &quot;);&#xA;      softSerial.println(cmd);&#xA;      Serial.println(cmd);&#xA;     }&#xA;&#xA;     boolean connectWiFi()&#xA;    {&#xA;      Serial.println(&quot;AT+CWMODE=1&quot;);&#xA;      delay(2000);&#xA;      String cmd=&quot;AT+CWJAP=\&quot;&quot;; // Join accespoint&#xA;      cmd+=SSID;&#xA;      cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;      cmd+=PASS;&#xA;      cmd+=&quot;\&quot;&quot;;&#xA;      sendDebug(cmd);&#xA;      delay(5000);&#xA;      if(Serial.find(&quot;OK&quot;))&#xA;      {&#xA;       softSerial.println(&quot;RECEIVED: OK&quot;);&#xA;       return true;&#xA;      }&#xA;      else&#xA;      {&#xA;       softSerial.println(&quot;RECEIVED: Error&quot;);&#xA;       return false;&#xA;       }&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19181" LastActivityDate="2018-10-27T13:47:26.470" Title="Trying to send data to the server and AT+CIPSEND not working correctly" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23067" PostTypeId="2" ParentId="23063" CreationDate="2016-04-13T02:42:19.213" Score="3" Body="&lt;p&gt;You can't call &lt;strong&gt;arbitrary&lt;/strong&gt; functions (with random return types, and any number of arguments) but you can specify a callback function that takes a certain number of specific arguments, and returns a certain thing (or nothing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/callbacks&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/callbacks&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef void (*GeneralMessageFunction) ();&#xA;&#xA;void sayHello ()&#xA;  {&#xA;  Serial.println (&quot;Hello!&quot;);  &#xA;  }  // end of sayHello&#xA;&#xA;void sayGoodbye ()&#xA;  {&#xA;  Serial.println (&quot;Goodbye!&quot;);  &#xA;  }  // end of sayGoodbye&#xA;&#xA;void checkPin (const int pin, GeneralMessageFunction response); // prototype&#xA;&#xA;void checkPin (const int pin, GeneralMessageFunction response)&#xA;  {&#xA;  if (digitalRead (pin) == LOW)&#xA;     {&#xA;     response ();  // call the callback function&#xA;     delay (500);  // debounce&#xA;     }&#xA;  }  // end of checkPin&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;  pinMode (8, INPUT_PULLUP);&#xA;  pinMode (9, INPUT_PULLUP);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  checkPin (8, sayHello);    &#xA;  checkPin (9, sayGoodbye);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know how it will work since I don't know the user's function parameters, return type and number of functions that will be added.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will need to tell the user what sort of function to write. For example, a function that takes a string (ie. the message) and returns a boolean (whether it was handled or not).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-13T02:42:19.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23068" PostTypeId="1" AcceptedAnswerId="23070" CreationDate="2016-04-13T02:53:09.913" Score="1" ViewCount="107" Body="&lt;p&gt;I had a problem with a memory leak in my sketch and cornered it with &lt;code&gt;MemoryFree.h&lt;/code&gt;. This works great and I was able to fix my leak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My sketch is not really static, but My var sizes are. I observed, that the free memory on the arduino reaches a different values and stays there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Example&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Run 1: 1655 Bytes Free&lt;/li&gt;&#xA;&lt;li&gt;Run 2: 1659 Bytes Free&lt;/li&gt;&#xA;&lt;li&gt;Run 3: 1654 Bytes Free&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For every run, I get a different, but over a short time, fixed memory usage. Is this normal? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: The serial input to the script just repeats forever with the exact same data. &lt;/p&gt;&#xA;" OwnerUserId="19013" LastActivityDate="2016-04-13T03:50:03.790" Title="'Non-Deterministic' memory usage on Arduino" Tags="|programming|memory-usage|debugging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23069" PostTypeId="1" CreationDate="2016-04-13T03:05:06.467" Score="0" ViewCount="276" Body="&lt;p&gt;I bought a few PFC8574 and 4x4 keypads for a small project. I'm unclear on the correct wiring of the keypad to the PFC8574.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the &lt;a href=&quot;http://playground.arduino.cc/Main/I2CPortExpanderAndKeypads&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Playground's site&lt;/a&gt;, there are pull-up resistors for each column, but on a few other sites (like &lt;a href=&quot;http://majsterkowo.pl/klawiatura-numeryczna-pod-i2c/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; that I can't read, but I understand a schematic and there's a third example too, but I don't have the reputation to post it), the wiring does straight into the IC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it depend on the library that's being used?  Or what am I missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="11367" LastEditorUserId="4628" LastEditDate="2017-02-07T19:27:38.127" LastActivityDate="2017-02-07T19:27:38.127" Title="PFC8574 4x4 keypad: correct wiring?" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23070" PostTypeId="2" ParentId="23068" CreationDate="2016-04-13T03:50:03.790" Score="2" Body="&lt;p&gt;You haven't posted any code, so any answer is guesswork. However ... if your code makes decisions based on external events (eg. readings from sensors) then it may allocate memory differently, and in a different order, each time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes memory allocation leaves gaps (known as &quot;heap fragmentation&quot;). Small differences in your results probably show slightly different sized gaps, due to the allocation order.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-13T03:50:03.790" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23071" PostTypeId="1" AcceptedAnswerId="23075" CreationDate="2016-04-13T04:25:54.400" Score="0" ViewCount="1925" Body="&lt;p&gt;To control some LEDs through internet using Arduino UNO, which type of connection  is better ? Ethernet or Wifi? (Later, I may connect some relays instead of LEDs, and control (turn on and off) some devices using this setup). &#xA;The only difference I know is the wired and wireless connectivity. &#xA;Is there any other difference? &lt;/p&gt;&#xA;" OwnerUserId="19944" LastActivityDate="2016-04-13T14:14:21.063" Title="Ethernet shield or Wifi sheild - Arduino?" Tags="|arduino-uno|wifi|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23072" PostTypeId="1" AcceptedAnswerId="23089" CreationDate="2016-04-13T05:35:48.563" Score="-1" ViewCount="1427" Body="&lt;pre&gt;&lt;code&gt;  import processing.serial.*; &#xA;import java.io.*; &#xA;Serial myPort; &#xA;int mySwitch; &#xA;String transmitter[] = new String[1280000]; //initialize array &#xA;&#xA;void setup(){ &#xA;         mySwitch=1; &#xA;         //Open the serial port for communication with the Arduino &#xA;         //Make sure the COM port is correct &#xA;         myPort = new Serial(this, &quot;COM6&quot;, 9600); &#xA;         myPort.bufferUntil('\n'); &#xA;} &#xA;&#xA;void draw() { &#xA;        if(mySwitch == 1)&#xA;        {       &#xA;           readData(&quot;input.txt&quot;);  &#xA;           int index = 0; &#xA;           while(index &amp;lt; 128000) &#xA;           {&#xA;             myPort.write(transmitter[index++]);&#xA;             if(index%128 == 0)&#xA;               delay(100);&#xA;           }&#xA;        }  &#xA;&#xA;         mySwitch = 0; &#xA;} &#xA;&#xA;&#xA;void readData(String myFileName){ &#xA;&#xA;         File file=new File(myFileName); &#xA;         BufferedReader br=null; &#xA;&#xA;         try{ &#xA;           br=new BufferedReader(new FileReader(file)); &#xA;&#xA;           String transmit=null; &#xA;           int i = 0; &#xA;           /* keep reading each line until you get to the end of the file */ &#xA;                while((transmit = br.readLine()) != null) &#xA;                   transmitter[i++] = transmit; &#xA;&#xA;         }catch(FileNotFoundException e){ e.printStackTrace(); } &#xA;&#xA;         catch(IOException e){ e.printStackTrace(); } &#xA;&#xA;         finally{ &#xA;                 try { &#xA;                   if (br != null) br.close();  &#xA;                 } &#xA;                 catch (IOException e) { e.printStackTrace(); } &#xA;         } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above code, I have an String array and I'm reading lines from a file and saving them as strings. How would I save them as byte/char inside an array of byte/char?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I have a file of integers on each line, each integer in the range [0, 255]. And I want to read this integer and send it to the Arduino. The Arduino serial.read() function reads a byte at a time. This is the issue I am trying to solve.&lt;/p&gt;&#xA;" OwnerUserId="13674" LastActivityDate="2016-06-12T19:45:50.210" Title="Using Processing to send data to Arduino" Tags="|processing-lang|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23075" PostTypeId="2" ParentId="23071" CreationDate="2016-04-13T07:29:30.567" Score="1" Body="&lt;p&gt;If you are beginner with Arduino its better to start with &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoEthernetShield&quot; rel=&quot;nofollow&quot;&gt;Ethernet Shield&lt;/a&gt;. Its much more easy to connect with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFi Module - &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;ESP8266&lt;/a&gt; required some more knowledge, that you will learn in future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bought products are cheap, so you can start with Ethernet and after that to switch to ESP.&lt;/p&gt;&#xA;" OwnerUserId="18916" LastActivityDate="2016-04-13T07:29:30.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23079" PostTypeId="2" ParentId="23063" CreationDate="2016-04-13T08:52:05.563" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know the user's function parameters,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;A common way for dealing with this issue is to pass a generic pointer to&#xA;arbitrary data. See below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;return type&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It makes little sense to allow for arbitrary return types, as your&#xA;library would have no way of knowing what to do with the returned value.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and number of functions that will be added.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Either you allocate the callback array statically with a fixed size, or&#xA;you use dynamic allocation. In the first case, the array size could be&#xA;decided by the user if it is a template parameter. In the second case,&#xA;you risk memory fragmentation unless all the callbacks are registered&#xA;once and for all at program startup, which is a common scenario anyway.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;About the generic pointer technique&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;This is a very common way of defining callbacks in C: a callback&#xA;contains both a function and a &lt;code&gt;void *&lt;/code&gt; pointer to arbitrary data, which&#xA;will be given as a parameter to the function. It is up to the user to&#xA;decide if and how he will use this pointer: he could completely ignore&#xA;it, like he could make it point to the root of a complex data tree.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// A callback contains both a function and a pointer to arbitrary data&#xA;// that will be passed as argument to the function.&#xA;struct Callback {&#xA;    Callback(void (*f)(void *) = 0, void *d = 0)&#xA;        : function(f), data(d) {}&#xA;    void (*function)(void *);&#xA;    void *data;&#xA;};&#xA;&#xA;Callback callbacks[3];&#xA;&#xA;// This callback expects an int.&#xA;void print_int(void *data)&#xA;{&#xA;    int parameter = * (int *) data;&#xA;    Serial.println(parameter);&#xA;}&#xA;&#xA;// This one expects a C string.&#xA;void print_string(void *data)&#xA;{&#xA;    char * parameter = (char *) data;&#xA;    Serial.println(parameter);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;&#xA;    // Register callbacks.&#xA;    static int seventeen = 17;&#xA;    static int forty_two = 42;&#xA;    static char hello[] = &quot;Hello, World!&quot;;&#xA;    callbacks[0] = Callback(print_int, &amp;amp;seventeen);&#xA;    callbacks[1] = Callback(print_int, &amp;amp;forty_two);&#xA;    callbacks[2] = Callback(print_string, hello);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Test all the callbacks.&#xA;    for (size_t i = 0; i &amp;lt; 3; i++)&#xA;        callbacks[i].function(callbacks[i].data);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the two callback functions take different types of&#xA;parameters, only disguised into the same generic pointer. Notice also&#xA;that &lt;code&gt;print_int&lt;/code&gt; is used in two different callbacks with different data.&#xA;In this example, the data does not change, but this need not be the&#xA;case: both the callbacks and the rest of the user code could change the&#xA;data pointed to by the generic pointers. Again, it is up to the user to&#xA;decide how he will use this facility to communicate between his&#xA;callbacks and the rest of his code.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-13T08:52:05.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23080" PostTypeId="1" CreationDate="2016-04-13T09:22:29.350" Score="0" ViewCount="80" Body="&lt;p&gt;This is basically an off-shoot from &lt;a href=&quot;https://arduino.stackexchange.com/questions/20569/unexpected-output-pin-behavior-was-relay-on-off-doesnt-loop&quot;&gt;https://arduino.stackexchange.com/questions/20569/unexpected-output-pin-behavior-was-relay-on-off-doesnt-loop&lt;/a&gt;. It's the same schematics and so on, however, I'm now wondering what the output voltage and current is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've a 9V battery and the MOSFET transistor from the arduino starterpack (doesn't say the specs) connected to the 5V pin on the board. I need the following output current/voltage for it to activate a solenoid:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;6V: 160 mA &lt;/li&gt;&#xA;&lt;li&gt;7V: 190 mA &lt;/li&gt;&#xA;&lt;li&gt;8V: 220 mA &lt;/li&gt;&#xA;&lt;li&gt;9V 240 mA &lt;/li&gt;&#xA;&lt;li&gt;10V :270 mA &lt;/li&gt;&#xA;&lt;li&gt;11V :300 mA&lt;/li&gt;&#xA;&lt;li&gt;12V :320 mA&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and I'm just not sure how to calculate it since I'm not sure about the output from the transistor and all the way to the solenoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solenoid: &lt;a href=&quot;http://www.electrokit.com/en/plastic-water-solenoid-valve-1-2-12v.51108&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.electrokit.com/en/plastic-water-solenoid-valve-1-2-12v.51108&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ElqV9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ElqV9.png&quot; alt=&quot;It should be solenoid instead of relay in the schematics&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17255" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-13T09:40:03.173" Title="Regarding the output voltage and current in arduino" Tags="|arduino-uno|relay|transistor|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23081" PostTypeId="2" ParentId="23080" CreationDate="2016-04-13T09:40:03.173" Score="2" Body="&lt;p&gt;You don't need to &quot;calculate&quot; anything with a MOSFET.  You will be using it in the &lt;em&gt;saturation&lt;/em&gt; zone. That means it is fully turned on and will allow through the current you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the gate of a MOSFET looks, to all intents and purposes, like a small capacitor. That means there will be a certain amount of &lt;em&gt;inrush&lt;/em&gt; current to the gate when you turn it on. To limit that inrush current you need a small resistor (say 100-220Ω) on the gate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using a BJT, though, you need to ensure that you allow enough current through the base to allow enough current through the collector.  Divide the current you need through the collector by the &lt;em&gt;Hfe&lt;/em&gt; (typically 100 for a small signal transistor) and that is the &lt;em&gt;minimum&lt;/em&gt; current you need to allow through the base. Subtract a silicon junction voltage (0.6V) from the voltage of the IO pin (5V). Divide it by your base current calculated above, and that is the &lt;em&gt;maximum&lt;/em&gt; resistor you can use on the base. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also your transistor symbol in your schematic is backwards.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-13T09:40:03.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23082" PostTypeId="2" ParentId="23069" CreationDate="2016-04-13T10:16:47.157" Score="1" Body="&lt;p&gt;Ok look at this image:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BjyAG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BjyAG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how your keypad is layed out but if you use a probe pin to test your connections via a multimeter, you can mark which ones correspond to the image.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am ASSUMING you are going to use the code from arduino playground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the format:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins of keypad (&lt;strong&gt;IN THE IMAGE&lt;/strong&gt;) - Pins of PFC8547&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the pin connections:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 - nothing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 - 9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 - 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4 - 6&lt;/p&gt;&#xA;&#xA;&lt;p&gt;5 - 7&lt;/p&gt;&#xA;&#xA;&lt;p&gt;6 - 10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;7 - 11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;8 - 5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also include the pull-up resistors.&#xA;Your ABCD keys will be ignored&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is like wiring a bomb...)&lt;/p&gt;&#xA;" OwnerUserId="19520" LastActivityDate="2016-04-13T10:16:47.157" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23083" PostTypeId="2" ParentId="23059" CreationDate="2016-04-13T10:17:01.083" Score="2" Body="&lt;p&gt;Elaborating on JRobert's answer, which I think is definitively the way&#xA;to go. Here is a typical way of writing a state machine with only three&#xA;states:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;No train in the area. You are monitoring the entry sensor.&lt;/li&gt;&#xA;&lt;li&gt;You have detected the train on the entry sensor. You started playing&#xA;the sound. You are monitoring the exit sensor.&lt;/li&gt;&#xA;&lt;li&gt;You have detected the train on the exit sensor. You are still&#xA;monitoring the same sensor in order to know when the train clears the&#xA;area.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Notice that the &lt;em&gt;actions&lt;/em&gt; you perform (starting and stopping the sound&#xA;for instance) are not associated with a particular state but with a&#xA;&lt;em&gt;transition&lt;/em&gt; between states: you start the sound on the 1&amp;nbsp;→&amp;nbsp;2&#xA;transition and stop it on 3&amp;nbsp;→&amp;nbsp;1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code for &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static enum {&#xA;        NO_TRAIN,        // no train in the area&#xA;        TRAIN_ENTERED,   // train seen by the entry sensor&#xA;        TRAIN_EXITING    // train seen by the exit sensor&#xA;    } state = NO_TRAIN;  // initial state&#xA;&#xA;    switch (state) {&#xA;        case NO_TRAIN:&#xA;            // Check entry sensor. If tripped, turn on the sound.&#xA;            if (checkEntrySensor()) {&#xA;                musicPlayer.startPlayingFile(&quot;trainxng.mp3&quot;);&#xA;                flashers.turnOn();&#xA;                gates.close();&#xA;                road.powerDown();&#xA;                state = TRAIN_ENTERED;&#xA;            }&#xA;            break;&#xA;        case TRAIN_ENTERED:&#xA;            // The exit sensor must be monitored.&#xA;            if (checkExitSensor()) {&#xA;                state = TRAIN_EXITING;&#xA;            }&#xA;            break;&#xA;        case TRAIN_EXITING:&#xA;            // Check if the train has cleared, then shut the sound.&#xA;            if (!checkExitSensor()) {&#xA;                musicPlayer.stopPlaying();&#xA;                flashers.turnOff();&#xA;                gates.open();&#xA;                road.powerUp();&#xA;                state = NO_TRAIN;&#xA;            }&#xA;            break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may be a bit oversimplified: if an action need some time, you may&#xA;have to create an extra state for it. For example, in order to avoid&#xA;blocking the program while the barrier goes down, you can split the&#xA;transition &lt;code&gt;NO_TRAIN → TRAIN_ENTERED&lt;/code&gt; in two:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;NO_TRAIN → LOWERING_BARRIER → TRAIN_ENTERED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the action “lower the barrier” is itself split into “start lowering&#xA;the barrier” (on the first transition) and “stop lowering the barrier”&#xA;(on the second transition).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-14T08:12:41.177" LastActivityDate="2016-04-14T08:12:41.177" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23084" PostTypeId="1" CreationDate="2016-04-13T12:52:04.873" Score="1" ViewCount="25399" Body="&lt;p&gt;The Arduino SW, under Tools, identifies my Uno as COM Port 3. However, COM Port 3 on my computer is in use by a chip set. My computer assigned COM Port 4 to my Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I reassign my Uno to COM Port 4?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: This question also applies to people who don't have administrative privileges. They do not have privileges to change the port via Windows Device Manager.&lt;/p&gt;&#xA;" OwnerUserId="20159" LastEditorUserId="19409" LastEditDate="2017-12-28T11:05:17.933" LastActivityDate="2017-12-28T11:05:17.933" Title="Can I reassign my Arduino Uno COM Port?" Tags="|usb|uploading|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23085" PostTypeId="2" ParentId="23084" CreationDate="2016-04-13T13:41:57.200" Score="1" Body="&lt;p&gt;If the Arduino IDE identified your Uno as COM Port 3, your computer most likely has already assigned COM Port 3 to your Uno. You can double check the port assignment in Device manager &gt; Ports.&lt;/p&gt;&#xA;" OwnerUserId="20158" LastActivityDate="2016-04-13T13:41:57.200" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23086" PostTypeId="2" ParentId="23084" CreationDate="2016-04-13T13:56:00.520" Score="0" Body="&lt;p&gt;You can change your COM Port number for a device by following these instructions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://plugable.com/2011/07/04/how-to-change-the-com-port-for-a-usb-serial-adapter-on-windows-7&quot; rel=&quot;nofollow&quot;&gt;http://plugable.com/2011/07/04/how-to-change-the-com-port-for-a-usb-serial-adapter-on-windows-7&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20089" LastActivityDate="2016-04-13T13:56:00.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23088" PostTypeId="1" CreationDate="2016-04-13T16:14:57.963" Score="0" ViewCount="792" Body="&lt;p&gt;I want to use a string of Neopixels attached to a Digispark hanging off of a RasPi3 as indicators for various situations.  For example: a motor (connected to a driver hat on the I2C bus of the RasPi) turns on or reverses direction.  Can I use Firmata, or is there something like it for the Digispark that I can use with Python?&lt;/p&gt;&#xA;" OwnerUserId="10225" LastActivityDate="2021-12-19T22:18:27.963" Title="How can I control neopixels attached to a Digispark?" Tags="|serial|python|neopixel|raspberrypi|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23089" PostTypeId="2" ParentId="23072" CreationDate="2016-04-13T16:42:00.370" Score="0" Body="&lt;p&gt;I believe I have actually found a very efficient solution to this problem by re-writing the code the following way by using the &quot;Scanner&quot; class and not the &quot;BufferedReader&quot; class. Any input on making this more efficient is welcome! &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*; &#xA;import java.io.*; &#xA;import java.util.*;&#xA;Serial myPort; &#xA;int mySwitch; &#xA;Scanner file;&#xA;byte transmitter[] = new byte[1280000]; //initialize array &#xA;&#xA;void setup(){ &#xA;    mySwitch=1; &#xA;    //Open the serial port for communication with the Arduino &#xA;    //Make sure the COM port is correct &#xA;    myPort = new Serial(this, &quot;COM6&quot;, 9600); &#xA;    myPort.bufferUntil('\n'); &#xA;} &#xA;&#xA;void draw() { &#xA;    if(mySwitch == 1)&#xA;    {       &#xA;        readData(&quot;input.txt&quot;);  &#xA;        int index = 0; &#xA;        while(index &amp;lt; 128000) &#xA;        {&#xA;            myPort.write(transmitter[index++]);&#xA;            if(index%128 == 0)&#xA;                delay(100);&#xA;        }&#xA;    }  &#xA;&#xA;    mySwitch = 0; &#xA;} &#xA;&#xA;&#xA;void readData(String myFileName){ &#xA;    try{&#xA;      file = new Scanner(new File(myFileName));&#xA;    }&#xA;    catch(Exception e){System.out.println(&quot;NOT FOUND!&quot;);}&#xA;&#xA;    int i = 0;&#xA;    while(file.hasNextByte())&#xA;      transmitter[i++] = file.nextByte();&#xA;&#xA;    file.close();&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13674" LastActivityDate="2016-04-13T16:42:00.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23090" PostTypeId="1" AcceptedAnswerId="23092" CreationDate="2016-04-13T17:18:37.493" Score="1" ViewCount="606" Body="&lt;p&gt;I have an Arduino Uno and A Raspberry Pi B+. I was wandering how I could use either as a Programbel HID Device (EX: &lt;a href=&quot;https://srlabs.de/badusb/&quot; rel=&quot;nofollow&quot;&gt;https://srlabs.de/badusb/&lt;/a&gt;). The Reason I ask under the arduino section is I want to preferably use it. If not I can use either. &lt;/p&gt;&#xA;" OwnerUserId="18665" LastActivityDate="2016-04-13T19:21:03.280" Title="Arduino (Or Raspberry Pi) As HID Device" Tags="|arduino-uno|raspberrypi|" AnswerCount="1" CommentCount="1" ClosedDate="2016-04-16T09:39:03.133" ContentLicense="CC BY-SA 3.0" />
  <row Id="23091" PostTypeId="1" AcceptedAnswerId="23093" CreationDate="2016-04-13T17:28:26.003" Score="6" ViewCount="14772" Body="&lt;p&gt;Say I wanted to, &lt;em&gt;purely hypothetically&lt;/em&gt;, set up a pirate radio station by connecting an Arduino to a WiFi network away from home, streaming music to the Arduino, decoding it, and broadcasting it with an FM transmitter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given an &lt;strong&gt;Arduino (Genuino) Uno&lt;/strong&gt;, a &lt;strong&gt;Sparkfun ESP8266 Thing Dev&lt;/strong&gt; breakout board for WiFi connectivity, and an &lt;strong&gt;Adafruit Si4713 Stereo FM Transmitter&lt;/strong&gt; breakout board, how would I go about the actual streaming of music (in MP3 or WAV format) from a (Windows) computer to the Arduino over WiFi? Would an Arduino Uno be powerful enough for this? Which components would I need to decode the audio?&lt;/p&gt;&#xA;" OwnerUserId="20166" LastActivityDate="2016-06-19T15:39:03.737" Title="Streaming audio from PC to Arduino over WiFi" Tags="|arduino-uno|esp8266|adafruit|audio|system-design|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23092" PostTypeId="2" ParentId="23090" CreationDate="2016-04-13T17:43:26.790" Score="-1" Body="&lt;p&gt;The Uno cannot be used as a HID device through the on board USB. You might be able to use the &lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;V-USB Library&lt;/a&gt; to be a HID device using the digital IO pins. See &lt;a href=&quot;http://blog.petrockblock.com/2012/05/19/usb-keyboard-with-arduino-and-v-usb-library-an-example/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several arduino compatible boards that do can act as a HID device natively. Most boards built around the ATMega32u4 can be a HID device.  For example the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMicro&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino Micro&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://raspberrypi.stackexchange.com/questions/32197/can-the-pi-emulate-an-hid-device-with-via-usb&quot;&gt;this question&lt;/a&gt; about the Raspberry Pi.&lt;/p&gt;&#xA;" OwnerUserId="337" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2016-04-13T19:21:03.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23093" PostTypeId="2" ParentId="23091" CreationDate="2016-04-13T18:50:02.580" Score="4" Body="&lt;p&gt;Well, a sort of... You can stream 64kbps MP3, get it via wifi from esp8266. Then for all the rest, forget the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need a dedicated MP3 decoder chip (many out there, sta013 was one of the oldest beasts) which can take the digital mp3 stream and convert it to analog output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can feed the line level analog output to the FM Transmitter, and then you're golden.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that you shall develop some application on the PC to actually stream out the MP3 - an off the shelf solution such as a Shoutcast server may not work, as the usual web-radio stations inject station data and currently played track metadata into the mp3 stream what you have to remove from the MP3 decoder chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the actual wifi bandwidth with ESP is limited (as well as the processing power of the Arduino), you may switch to a more efficient compression format. For example, a 64kbps WMA sounds far better than a 64kbps MP3, and at 64kbps AAC is superior to any of the other formats. Ensure that your decoder chip can work well with a modern codec comperssion format.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-13T18:50:02.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23094" PostTypeId="2" ParentId="23088" CreationDate="2016-04-13T18:55:11.350" Score="1" Body="&lt;p&gt;You need a dedicated microcontroller since you need very precise timing for controlling the neopixels. It works well on an ATTiny85, we are using Adafruit Trinket boards to control Neopixels and work well. So far up to 12 pixels :) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can download a Trinket Neopixel library, which is modded for an internal osc ATTiny85 from Adafruit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then your Raspi can talk to the microcontroller. It is a little problematic, though, since the software serial port handling consumes too much memory on ATTiny, and the ATTiny will ignore all serial input while refreshing the neopixels. Therefore you may get it easier by using an Arduino UNO, or Leonardo or Micro which is powerful enough for many pixels, and have a built-in hardware serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a matter of fact, you can talk to these Arduino boards as if it would be a serial port, so just plug in a Leonardo over USB and you'll get a new serial port in Rpi to talk to.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-13T18:55:11.350" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23095" PostTypeId="1" AcceptedAnswerId="23118" CreationDate="2016-04-13T22:23:27.533" Score="2" ViewCount="8068" Body="&lt;p&gt;We all &lt;em&gt;know&lt;/em&gt; the interrupts, but how do they really work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my sketch an interrupt method (invoked when pin goes high) is consuming data from a buffer and the main &lt;code&gt;loop()&lt;/code&gt; is filling the buffer at random speeds (from Internet - I'm using ESP8266, not the Arduino). Although I think there shouldn't be any &lt;em&gt;threading&lt;/em&gt; problems with this buffer - I might be wrong - the program hangs up after random number of seconds (about half a minute average - and then the built-in watchdog resets it after few seconds). When I detached the interrupt method and merged it into the main &lt;code&gt;loop()&lt;/code&gt; code, the problem disappeared (but I can't leave it like that). So it's probably either that I'm doing something illegal in the interrupt method (maybe it's just taking too long - how much time can an interrupt method take?) - or the second possibility - it &lt;strong&gt;is&lt;/strong&gt; a threading problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The questions:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main question is: how to correctly synchronize the interrupt method? How to create a critical section if the interrupt method cannot wait (for a semaphore) and if I leave it, it won't be invoked again because the pin is already high? And the detailed questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How to create a &lt;em&gt;thread-safe&lt;/em&gt; variable (a bool flag), so that interrupt method can skip the critical section if the main loop has entered it? (I understand the interrupt method is &quot;safe&quot; - it won't be interrupted - but how to secure the regular code?)&lt;/li&gt;&#xA;&lt;li&gt;If I detach an interrupt method that is triggered when a pin goes high when it is low (for just a few fast instructions), the pin gets high in that time, and then I'll re-attach the method to this pin again, will it be invoked? The same question for &lt;code&gt;noInterrupts();&lt;/code&gt; How to make sure it &lt;strong&gt;will&lt;/strong&gt; be invoked, if I can't check the pin and invoke (or not) the method manually in an atomic transaction with re-attaching the method?&lt;/li&gt;&#xA;&lt;li&gt;If I detach this method (in main loop), is it possible that it will be invoked before the control is back from the &lt;code&gt;detachInterrupt()&lt;/code&gt; method? (because the pin got high from external device in this very moment) And the same question for &lt;code&gt;noInterrupts();&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;I've read that &lt;code&gt;noInterrupts();&lt;/code&gt; causes some things, like reading incoming serial data, to be skipped. Can this method be even used if I don't want that? Or can I have guaranteed that it won't happen if the method is fast enough? (if so, please define the &quot;fast enough&quot;!)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So, is there a common template for creating a critical section between an interrupt method and the regular code? Or at least synchronizing a variable access? And if not, how to make sure the detached/blocked pin method will be invoked after re-attaching/re-enabling it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The common buffer code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(if you want to check whether this can cause any &quot;threading&quot; problems)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Buffer&#xA;{&#xA;  protected:&#xA;    byte *buf;&#xA;    int len, readpos, writepos;&#xA;    bool wasFull, wasEmpty;&#xA;    long ratioSum, ratioCount;&#xA;&#xA;  public:&#xA;    Buffer(int length)&#xA;    {&#xA;      len = length;&#xA;      buf = new byte[len];&#xA;      readpos = writepos = 0;&#xA;    }&#xA;&#xA;    bool isFull()&#xA;    {&#xA;      bool full = writepos - readpos &amp;gt;= len;&#xA;      wasFull &amp;amp;= full;&#xA;      return full;&#xA;    }&#xA;&#xA;    bool isEmpty()&#xA;    {&#xA;      bool empty = readpos &amp;gt;= writepos;&#xA;      wasEmpty &amp;amp;= empty;&#xA;      return empty;&#xA;    }&#xA;&#xA;    void write(byte b)&#xA;    {&#xA;      if (isFull()) { if (!wasFull) { wasFull = true; Serial.println(&quot;Error: Buffer overflow!&quot;); } return; }&#xA;      int pos = (writepos++) % len;&#xA;      buf[pos] = b;&#xA;      if (readpos &amp;gt;= len &amp;amp;&amp;amp; writepos &amp;gt;= len) { readpos -= len; writepos -= len; }&#xA;    }&#xA;&#xA;    byte read()&#xA;    {&#xA;      if (isEmpty()) { if (!wasEmpty) { wasEmpty = true; Serial.println(&quot;Error: Buffer underflow!&quot;); } return 0; }&#xA;      int pos = (readpos++) % len;&#xA;      if (readpos &amp;gt;= len &amp;amp;&amp;amp; writepos &amp;gt;= len) { readpos -= len; writepos -= len; }&#xA;      return buf[pos];&#xA;    }&#xA;&#xA;    int available()&#xA;    {&#xA;      return writepos - readpos;&#xA;    }&#xA;&#xA;    void measureRatio()&#xA;    {&#xA;      ratioSum += available();&#xA;      ratioCount++;&#xA;    }&#xA;&#xA;    int getRatio()&#xA;    {&#xA;      int ratio;&#xA;      if (ratioCount &amp;gt; 0) &#xA;        ratio = 100 * ((float)(ratioSum / ratioCount) / (float)len);&#xA;      else&#xA;        ratio = 100 * ((float)available() / (float)len);&#xA;      ratioSum = 0;&#xA;      ratioCount = 0;&#xA;      return ratio;&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have discovered that printing to Serial in the interrupt method (even without a &lt;code&gt;flush()&lt;/code&gt; is causing my program to crash after max half a second. Is it just a duration of printing or is it something else? Also if you're thinking that the warning printing in my Buffer code can cause the crashes, then I assure you that they're not because I always check isEmpty() and isFull() before each read and write operation, so they just can't occur.&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-04-15T21:48:16.630" Title="Critical sections in Arduino, interrupt consuming data" Tags="|esp8266|interrupt|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23097" PostTypeId="2" ParentId="23004" CreationDate="2016-04-13T23:31:16.490" Score="0" Body="&lt;p&gt;Does it print out the part &quot;Free Ram: &quot; If not, then I doubt its a memory problem. Not too familiar with the CC3000, but possibly related to a UART Break Condition.&lt;/p&gt;&#xA;" OwnerUserId="20174" LastActivityDate="2016-04-13T23:31:16.490" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23098" PostTypeId="2" ParentId="23095" CreationDate="2016-04-14T00:00:09.240" Score="3" Body="&lt;p&gt;The trick here is not to make your interrupt routine, or your main routine &quot;thread safe&quot; - instead you need to make the single item that is shared by the two &quot;thread safe&quot;. That means your Buffer class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to go through that with a fine toothed comb and work out which bits could possibly be accessed by the two contexts at once and protect them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The bits that jump out at me immediately are the calculations and manipulations of writepos and readpos. Accesses to those variables need to be made as atomic as possible.  One of the best ways of doing that is to massively restrict the actual access to those variables and wrap those accesses in critical sections (disable / enable interrupts). That keeps the critical sections as short as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, instead of directly manipulating the variables, as you enter the function you first create &quot;cached&quot; copies of the variables you will modify that could be modified at the same time (such as writepos being written to in the ISR):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cli();&#xA;int cachedWritePos = writepos;&#xA;sei();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you do your manipulations and calculations on those cached variables. Finally, just before you exit the function, you write your now safely changed cached variable values back to the member variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cli();&#xA;writepos = cachedWritePos;&#xA;sei();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The critical sections are then as brief as possible, and any heavy calculations (I count the modulus operator &lt;code&gt;%&lt;/code&gt; as a heavy calculation) don't block the interrupt from firing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course that is not a foolproof method and doesn't protect against two contexts changing the same variable and it getting out of step. To counter that you will have to use a mutex. There's no getting around that, other than ensuring that your program never changes the same variables from two different contexts. The only mutex you really have access to is a manually implemented &lt;a href=&quot;https://en.wikipedia.org/wiki/Spinlock&quot; rel=&quot;nofollow&quot;&gt;spinlock&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On that note, I am having some trouble following the logical flow of how your buffer works. There are bits that don't look quite right to me, such as this bit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (readpos &amp;gt;= len &amp;amp;&amp;amp; writepos &amp;gt;= len) { readpos -= len; writepos -= len; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;According to my way of thinking both readpos and writepos have to have reached (or exceeded) the end of the buffer for them to wrap around to the start again.  That can't really happen properly in a function that is only writing, or a function that is only reading. I think you want to only be checking writepos and wrapping that in the write function, and only checking readpos and wrapping that around in the read function, not both in both functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as using Serial in an interrupt goes, the general rule is: don't do it.  I don't know about the ESP8266's serial code, but certainly on the Arduino it relies on interrupts being used to take each character from the TX buffer and transmitting it through the UART interface. If you are in an interrupt routine and your (64 byte) serial TX buffer fills up any attempts to write to that buffer (Serial.print) will block until the interrupt that sends the characters has made some room for you - and of course that interrupt will never happen while you're blocking because you are in an interrupt at the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On systems with multiple priority levels of interrupt (such as a PIC32) the same holds true if you are in an interrupt routine that is at a higher priority than the Serial interrupt. If you are in a lower priority one the serial interrupt can still interrupt your current interrupt routine and function correctly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-14T00:00:09.240" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="23099" PostTypeId="1" CreationDate="2016-04-14T00:05:25.430" Score="2" ViewCount="129" Body="&lt;p&gt;I have an Arduino with an Ethernet shield and I want to capture all Ethernet data traffic that connects to the Arduino via [as?] a router. This is because I want to use the Arduino like a &lt;em&gt;honeypot&lt;/em&gt; and at the same time resend the Ethernet traffic to the Raspberry, &lt;em&gt;but only specific TCP traffic instead of UDP&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I want to resend all of the traffic data from an Arduino to a Raspberry Pi, but I need to &lt;em&gt;only&lt;/em&gt; resend all of the TCP traffic because the Raspberry reads and parses this. However, I only see examples of UDP traffic but nothing related to TCP. It doesn't matter what kind of port the Arduino listens on, I just need the data out of the other side, can you help me? &lt;/p&gt;&#xA;" OwnerUserId="20175" LastEditorUserId="6936" LastEditDate="2016-04-17T14:55:38.300" LastActivityDate="2016-04-17T14:55:38.300" Title="Resend data traffic from an Arduino" Tags="|ethernet|tcpip|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23100" PostTypeId="2" ParentId="23010" CreationDate="2016-04-14T01:08:38.677" Score="1" Body="&lt;p&gt;Actually after trying different options, I could finally find a solution that seems to work for me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (stepper.distanceToGo() == 0 &amp;amp;&amp;amp; stepper.currentPosition()==50000) {&#xA;    delay(1000);&#xA;    stepper.setCurrentPosition(0);&#xA;    stepper.moveTo(-50000);&#xA;    stepper.setSpeed(10000);&#xA;    stepper.runSpeedToPosition();&#xA;  }&#xA;  else if (stepper.distanceToGo() == 0 &amp;amp;&amp;amp; stepper.currentPosition()==-50000) {&#xA;    delay(1000);&#xA;    stepper.setCurrentPosition(0);&#xA;    stepper.moveTo(50000);&#xA;    stepper.setSpeed(10000);&#xA;    stepper.runSpeedToPosition();&#xA;  }&#xA;  stepper.runSpeed();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20100" LastActivityDate="2016-04-14T01:08:38.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23101" PostTypeId="1" CreationDate="2016-04-14T01:20:06.790" Score="0" ViewCount="607" Body="&lt;p&gt;I'm making a project with three buttons. What I'm trying to do is to disable other buttons (make them not respond to a click event) when one of three buttons is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For now I have this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    const int button1=3;&#xA;    const int button2=4;&#xA;    const int button3=5;&#xA;&#xA;    int button1State=0;&#xA;    int button2State=0;&#xA;    int button3State=0;&#xA;&#xA;    void setup() {&#xA;    pinMode(button1, INPUT);&#xA;    pinMode(button2, INPUT);&#xA;    pinMode(button3, INPUT);&#xA;    }&#xA;&#xA;   void loop() {&#xA;   button1State=digitalRead(button1);&#xA;   button2State=digitalRead(button2);&#xA;   button3State=digitalRead(button3);&#xA;&#xA;   if( button1State == HIGH){&#xA;   // do some stuff&#xA;   }   &#xA;&#xA;    if( button2State == HIGH){&#xA;    // do some stuff&#xA;    }    &#xA;&#xA;    if( button3State == HIGH){&#xA;    // do some stuff&#xA;    } &#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have any ideas how I could do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks is advance for any suggestions!&lt;/p&gt;&#xA;" OwnerUserId="20100" LastEditorUserId="20100" LastEditDate="2016-04-18T23:02:29.147" LastActivityDate="2016-04-18T23:02:29.147" Title="Disable other buttons while one of buttons is pressed" Tags="|arduino-nano|button|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23102" PostTypeId="2" ParentId="23101" CreationDate="2016-04-14T01:37:23.193" Score="2" Body="&lt;p&gt;The best solution for this is a finite state machine. There are lots of tutorials on state machines, just google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finite state machines are a very important concept in coding. You will find the need for them everywhere. Do yourself a favour, and read up about them, practice them, understand them, love them. Understand when they will be useful, and when they are not. If you do not, you will be back here shortly, with another question, which could also be solved by a finite state machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I strongly recommend you use this task as a practice task for learning about finite state machines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note also that, in electrical circuits, you frequently get bounce - when you push a button, your arduino will see many &quot;button presses&quot; (from off, to on, back to off), until it settles down. See &lt;a href=&quot;http://blog.kennyrasschaert.be/images/20140401/Bouncy_Switch.png&quot; rel=&quot;nofollow&quot;&gt;http://blog.kennyrasschaert.be/images/20140401/Bouncy_Switch.png&lt;/a&gt; for example. A state machine can also help you with this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to learn about FSMs, read on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;initialise last_button_pressed to 0 (meaning no button pressed)&#xA;if last_button_pressed&amp;gt;0&#xA;   if not(is_button_pressed(last_button_pressed) then&#xA;      last_button_pressed=0&#xA;else (no button is pressed)&#xA;   for each button_to_check (1,2,3)&#xA;      if last_button_pressed=0 and is_button_pressed(button_to_check) then&#xA;         last_button_pressed=button_to_check&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2016-04-14T01:51:40.323" LastActivityDate="2016-04-14T01:51:40.323" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23103" PostTypeId="2" ParentId="23066" CreationDate="2016-04-14T02:04:10.587" Score="1" Body="&lt;p&gt;Your code looks like you connected the ESP to the hardware serial port, but your comment says otherwise so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your sketch isnt working because you're writing to the wrong serial port half the time, and even when you do use the right serial port (&lt;code&gt;softSerial&lt;/code&gt;) you're sending garbage along with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.println(stringLength);&lt;/code&gt; and &lt;code&gt;Serial.find(&quot;OK&quot;)&lt;/code&gt; should be &lt;code&gt;softSerial.println(stringLength);&lt;/code&gt; and &lt;code&gt;softSerial.find(&quot;OK&quot;)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.find( &quot;&amp;gt;&quot; )&lt;/code&gt; should be &lt;code&gt;softSerial.find( &quot;&amp;gt;&quot; )&lt;/code&gt;. You should look for '&gt;' in the buffer between the &lt;strong&gt;Arduino and the ESP8266&lt;/strong&gt; and not the one between the Arduino and the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;softSerial.print(&quot;&amp;gt;&quot;);&lt;/code&gt;, &lt;code&gt;softSerial.println(&quot;RECEIVED: OK&quot;);&lt;/code&gt; and similar statements should not be there at all. They are not commands or arguments to a command so why are you printing them to the ESP? Whenever you write to &lt;code&gt;softSerial&lt;/code&gt;, make sure its a &lt;strong&gt;command&lt;/strong&gt;. Dont send your debug messages to &lt;code&gt;softSerial&lt;/code&gt;; use &lt;code&gt;Serial&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's no variable called &lt;code&gt;cmds&lt;/code&gt; and yet you're printing it to the serial port. Assuming this code compiled, its probably a typo in your question?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, your code structure is unreliable at best, what with all the delays in it and not a single &lt;code&gt;Serial.available()&lt;/code&gt; or &lt;code&gt;softSerial.available()&lt;/code&gt;, not to mention the abundant usage of Arduino Strings. I suggest you first learn how to read from a serial port and build C strings from the results and &lt;strong&gt;then&lt;/strong&gt; re-design your code again. &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Majenko's blog&lt;/a&gt; is as good a tutorial as any. Or you could download a library like &lt;a href=&quot;https://github.com/itead/ITEADLIB_Arduino_WeeESP8266&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt; that provides an easy API to the ESP8266, shielding you from the mess of AT commands, while providing you with example sketches that already do what you want. Of course, you could choose to go through their library (.cpp and .h files are the place to be) and figure out how &lt;em&gt;they&lt;/em&gt; used AT commands with the ESP and &lt;em&gt;then&lt;/em&gt; write your own sketch, library or whatever. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2018-01-09T13:59:09.153" LastActivityDate="2018-01-09T13:59:09.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23104" PostTypeId="2" ParentId="22995" CreationDate="2016-04-14T02:31:43.623" Score="0" Body="&lt;p&gt;Ints on vanilla Arduinos are 16 bits, and signed, which means they hold values from -2^15 to +2^15-1, so of course you cannot assign 10^6 to one of them. Use unsigned long (4 bytes), or, better yet, specify the length explicitly by using uint32_t. &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-14T02:31:43.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23106" PostTypeId="1" CreationDate="2016-04-14T02:42:35.157" Score="2" ViewCount="2758" Body="&lt;p&gt;I am using Sparkfun Arduino Pro Micro with an ATmega32u4(3.3v, 8MHz) on it (&lt;a href=&quot;https://www.sparkfun.com/products/12587&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/12587&lt;/a&gt;) and a HC-05 Bluetooth Module. I also running this on Windows 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've made these connections: (same as this tutorial) with some additional for leds&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Pro Micro TxD (Pin 0) -&gt; HC-05 RxD&#xA;HC-05 TxD -&gt; Arduino Pro Micro RxD (Pin 1)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am following this tutorial: &lt;a href=&quot;http://playground.arduino.cc/Learning/Tutorial01&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/Tutorial01&lt;/a&gt;&#xA;I have two Serial ports available for the HC-05 COM30(incoming) and COM31(Outgoing). When I try to send letter 'H' in Serial monitor on COM31 the arduino ide freezes and the HC-05 flashes rapidly. When I try to send letter 'H' in Serial monitor on COM30 it sends but nothing happens as H should ideally turn on the led. The arduino pro works with a button but I would like to send the command externally as in the tutorial. I also try in processing but the same thing happens as when using the arduino serial monitor. I have been trying for a couple of days now with no idea why it is not working, I have tried adjusting baud rates and changing to Serial1 with no change. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded this to the Arduino to test the Bluetooth module: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;char val; // variable to receive data from the serial port&#xA;int ledpin = 6; // LED connected to pin 48 (on-board LED)&#xA;int ledpin2 = 5;&#xA;void setup() {&#xA;  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT&#xA;  pinMode(ledpin2, OUTPUT);  // pin 48 (on-board LED) as OUTPUT&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);       // start serial communication at 9600bps&#xA;}&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;  if( Serial1.available() )       // if data is available to read&#xA;  {&#xA;    digitalWrite(ledpin2, LOW);&#xA;    val = Serial1.read();         // read it and store it in 'val'&#xA;  } else {&#xA;    digitalWrite(ledpin2, HIGH);&#xA;  }&#xA;  if( val == 'H' )               // if 'H' was received&#xA;  {&#xA;    digitalWrite(ledpin, HIGH);  // turn ON the LED&#xA;  } else { &#xA;    digitalWrite(ledpin, LOW);   // otherwise turn it OFF&#xA;  } &#xA;&#xA;  delay(100);                    // wait 100ms for next reading&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Processing code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//import class to set up serial connection with wiring board&#xA;import processing.serial.*;&#xA;Serial port;&#xA;//button setup&#xA;color currentcolor;&#xA;RectButton rect1, rect2;&#xA;boolean locked = false;&#xA;void setup() {&#xA;  //set up window&#xA;  size(200, 200);&#xA;  color baseColor = color(102, 102, 102);&#xA;  currentcolor = baseColor;&#xA;  // List all the available serial ports in the output pane. &#xA;  // You will need to choose the port that the Wiring board is &#xA;  // connected to from this list. The first port in the list is &#xA;  // port #0 and the third port in the list is port #2. &#xA;  println(Serial.list()); &#xA;  // Open the port that the Wiring board is connected to (in this case 1&#xA;  // which is the second open port in the array) &#xA;  // Make sure to open the port at the same speed Wiring is using (9600bps) &#xA;  port = new Serial(this, Serial.list()[2], 9600);&#xA;  // Define and create rectangle button #1&#xA;  int x = 30;&#xA;  int y = 100;&#xA;  int size = 50;&#xA;  color buttoncolor = color(153, 102, 102);&#xA;  color highlight = color(102, 51, 51); &#xA;  rect1 = new RectButton(x, y, size, buttoncolor, highlight);&#xA;  // Define and create rectangle button #2&#xA;  x = 90;&#xA;  y = 100; &#xA;  size = 50;&#xA;  buttoncolor = color(153, 153, 153);&#xA;  highlight = color(102, 102, 102); &#xA;  rect2 = new RectButton(x, y, size, buttoncolor, highlight);&#xA;}&#xA;void draw() {&#xA;  background(currentcolor);&#xA;  stroke(255);&#xA;  update(mouseX, mouseY);&#xA;  rect1.display();&#xA;  rect2.display();&#xA;}&#xA;void update(int x, int y) {&#xA;  if(locked == false) {&#xA;    rect1.update();&#xA;    rect2.update();&#xA;  } else {&#xA;    locked = false;&#xA;  }&#xA;  //Turn LED on and off if buttons pressed where&#xA;  //H = on (high) and L = off (low)&#xA;  if(mousePressed) {&#xA;    if(rect1.pressed()) {            //ON button&#xA;      currentcolor = rect1.basecolor;&#xA;      port.write('H');&#xA;    } else if(rect2.pressed()) {    //OFF button&#xA;      currentcolor = rect2.basecolor;&#xA;      port.write('L');&#xA;    }&#xA;  }&#xA;}&#xA;class Button {&#xA;  int x, y;&#xA;  int size;&#xA;  color basecolor, highlightcolor;&#xA;  color currentcolor;&#xA;  boolean over = false;&#xA;  boolean pressed = false;   &#xA;  void update() &#xA;  {&#xA;    if(over()) {&#xA;      currentcolor = highlightcolor;&#xA;    } else {&#xA;      currentcolor = basecolor;&#xA;    }&#xA;  }&#xA;  boolean pressed() &#xA;  {&#xA;    if(over) {&#xA;      locked = true;&#xA;      return true;&#xA;    } else {&#xA;      locked = false;&#xA;      return false;&#xA;    }    &#xA;  }&#xA;  boolean over() &#xA;  { &#xA;    return true; &#xA;  }&#xA;  void display() &#xA;  { &#xA;  }&#xA;}&#xA;class RectButton extends Button {&#xA;  RectButton(int ix, int iy, int isize, color icolor, color ihighlight) &#xA;  {&#xA;    x = ix;&#xA;    y = iy;&#xA;    size = isize;&#xA;    basecolor = icolor;&#xA;    highlightcolor = ihighlight;&#xA;    currentcolor = basecolor;&#xA;  }&#xA;  boolean over() &#xA;  {&#xA;    if( overRect(x, y, size, size) ) {&#xA;      over = true;&#xA;      return true;&#xA;    } else {&#xA;      over = false;&#xA;      return false;&#xA;    }&#xA;  }&#xA;  void display() &#xA;  {&#xA;    stroke(255);&#xA;    fill(currentcolor);&#xA;    rect(x, y, size, size);&#xA;  }&#xA;}&#xA;boolean overRect(int x, int y, int width, int height) {&#xA;  if (mouseX &amp;gt;= x &amp;amp;&amp;amp; mouseX &amp;lt;= x+width &amp;amp;&amp;amp; &#xA;      mouseY &amp;gt;= y &amp;amp;&amp;amp; mouseY &amp;lt;= y+height) {&#xA;    return true;&#xA;  } else {&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20180" LastActivityDate="2016-04-14T02:42:35.157" Title="Arduino Pro Micro and HC-05 Bluetooth module" Tags="|bluetooth|arduino-pro-micro|hc-05|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23107" PostTypeId="1" CreationDate="2016-04-14T03:56:43.997" Score="2" ViewCount="671" Body="&lt;p&gt;So I am new to the board and looking for a source to answer an Arduino servo project's rough power up.  The project uses a pair of servos operating together to swing a small door.  I have been working with intro level sketches over the last few weeks. I have powered and re-powered my Arduino Uno several times with different codes and each time the unit is powered the two servo motors move to their last position at what appears to be full speed resulting in a rather jerky and jumpy power up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can you suggest in the code that would force the servo motors to gently move toward their new code starting position?  Like a 'warm up cycle'.&lt;/p&gt;&#xA;" OwnerUserId="20181" LastActivityDate="2016-04-14T07:43:41.720" Title="code to force a gentle servo power up" Tags="|arduino-uno|programming|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23108" PostTypeId="2" ParentId="23107" CreationDate="2016-04-14T04:23:25.970" Score="0" Body="&lt;p&gt;I would recommend an &lt;a href=&quot;https://en.wikipedia.org/wiki/Sigmoid_function&quot; rel=&quot;nofollow&quot;&gt;S curve&lt;/a&gt; for the angular positioning of the door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should guarantee a smooth start and stop.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-14T04:23:25.970" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23109" PostTypeId="2" ParentId="12726" CreationDate="2016-04-14T05:56:31.333" Score="0" Body="&lt;p&gt;For those coming here from Google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The short answer is:&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes you technically can, but it wont be dirt cheap or very pretty depending on your wallet and tastes/requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Longer answer:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was researching the same thing. The problem is that Lightning connector is fairly complicated, and before it will start giving you power it requires software authentication by a chip that is built into the cable. That said you can use the USB camera connection kit or you can buy one of the IK Multimedia mini usb cables:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ikmultimedia.com/products/cat-view.php?C=spareparts&quot; rel=&quot;nofollow&quot;&gt;http://www.ikmultimedia.com/products/cat-view.php?C=spareparts&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have had success trying to tap into their cable for iRig Pro cause I happen to have one, and it gives out solid 3.3V on one of the pins which is good enough for my Arduino Mini Pro. But I would vouch that their full blown mini usb cable should be supplying regular 5V.&lt;/p&gt;&#xA;" OwnerUserId="20182" LastEditorUserId="20182" LastEditDate="2016-05-20T08:06:55.847" LastActivityDate="2016-05-20T08:06:55.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23110" PostTypeId="1" CreationDate="2016-04-14T06:11:48.473" Score="1" ViewCount="3222" Body="&lt;p&gt;I am attempting to send some information from MatLab to an Arduino Uno via Bluetooth with the following &lt;/p&gt;&#xA;&#xA;&lt;p&gt;MatLab program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;b=Bluetooth('HC-06',1);&#xA;fopen(b);&#xA;for i=1:1:15                                &#xA;  fprintf(b,i); &#xA;  out(i) = fscanf(b,'%d');&#xA;end&#xA;fclose(b)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and Arduino program&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int matlabval=0;&#xA;&#xA;void setup()  {&#xA;    Serial.begin(9600);  &#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    matlabval = Serial.read();&#xA;    Serial.println(matlabval); &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the output  of arduino is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1&#xA;10&#xA;2&#xA;10&#xA;3&#xA;10&#xA;4&#xA;10&#xA;5&#xA;10&#xA;6&#xA;10&#xA;7&#xA;10&#xA;8&#xA;10&#xA;9&#xA;10&#xA;10&#xA;10&#xA;11&#xA;10&#xA;12&#xA;10&#xA;13&#xA;10&#xA;14&#xA;10&#xA;15&#xA;10&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number 10 appears after each number. Why is that so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="20183" LastEditorUserId="28084" LastEditDate="2016-11-13T21:59:03.537" LastActivityDate="2017-07-14T15:12:26.217" Title="MatLab connection to Arduino using Bluetooth" Tags="|bluetooth|matlab|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23111" PostTypeId="2" ParentId="23107" CreationDate="2016-04-14T07:43:41.720" Score="2" Body="&lt;p&gt;You cannot do that with ordinary servos. This is because of the way the&#xA;communication protocol is built: the only thing a servo understands is a&#xA;command which in effect means “go to that position as fast as you can”.&#xA;You can achieve smooth movements by updating the requested position (the&#xA;so called “set point”) many times by tiny steps, but you still have the&#xA;problem at startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see two possible solutions to your problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you know the position at which the servo was left when you&#xA;powered down your Arduino. You can either arrange to leave it always&#xA;at the same position, or you can store the last position in EEPROM&#xA;before powering down. Then, at startup, you initialize the servo with&#xA;that last known set point.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Use a special type of servo known as a &lt;a href=&quot;https://learn.adafruit.com/analog-feedback-servos/about-servos-and-feedback&quot; rel=&quot;nofollow&quot;&gt;feedback&#xA;servo&lt;/a&gt;,&#xA;or &lt;a href=&quot;http://www.instructables.com/id/Servo-Feedback-Hack-free/&quot; rel=&quot;nofollow&quot;&gt;convert a regular&#xA;servo&lt;/a&gt; to&#xA;get a feedback. A feedback servo is a type of servo that tells you&#xA;its actual position, so you can arrange for the initial set point to&#xA;match that position.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-14T07:43:41.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23112" PostTypeId="1" CreationDate="2016-04-14T07:55:41.367" Score="2" ViewCount="2658" Body="&lt;p&gt;I'm writing an Arduino program to communicate with another module using RS485, so I need to control data flow with one pin. But when I set the pin to HIGH (line 88) it almost instantly falls (as you can see in the image, line 70). So my guess is that Arduino Serial.write() function is non-blocking, but I need it to be blocking &lt;a href=&quot;https://i.stack.imgur.com/36NbZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/36NbZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;so the flow control pin stays high during whole packet transmit. Please help. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="20187" LastActivityDate="2016-04-14T08:04:06.207" Title="Arduino serial non-blocking" Tags="|c|rs485|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23113" PostTypeId="1" AcceptedAnswerId="23116" CreationDate="2016-04-14T08:02:17.020" Score="0" ViewCount="496" Body="&lt;p&gt;My Arduino UNO is connected directly to the ESP8266 (01) WiFi module. The Red and Blue LED flashes and it seems to work properly. But when I connect the UNO to my computer, the module refreshes at irregular intervals and the PC produces sounds as that of ejecting and inserting a USB. I don't know whether this is caused due to low voltage supplied from the USB or some other reason. Please help me out...&lt;/p&gt;&#xA;" OwnerUserId="20186" LastActivityDate="2016-04-14T09:47:12.067" Title="ESP8266 module cutting connection with PC via USB" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23114" PostTypeId="2" ParentId="23112" CreationDate="2016-04-14T08:04:06.207" Score="3" Body="&lt;p&gt;You are right: &lt;code&gt;Serial.write()&lt;/code&gt; is non blocking: it puts the data in a&#xA;buffer and waits for an interrupt routine to send it through the UART.&#xA;If you want to wait for the transmission to complete, you can call&#xA;&lt;code&gt;Serial.flush()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-14T08:04:06.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23115" PostTypeId="1" CreationDate="2016-04-14T08:40:14.343" Score="0" ViewCount="10396" Body="&lt;p&gt;Who among here have tried measuring the before and after distance traveled using gps? I'm going to use the code from TinyGPS library's distance_between command without constant value of latitude and longitude, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to see that the first GPS latitude and longitude results is used as reference point. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How will I apply it on my code so that I could be able to get the distance I traveled? Please help me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA; /*&#xA;   This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.&#xA;   It requires the use of SoftwareSerial, and assumes that you have a&#xA;   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).&#xA; */&#xA; static const int RXPin = 4, TXPin = 3;&#xA; static const uint32_t GPSBaud = 4800;&#xA;&#xA;  // The TinyGPS++ object&#xA;TinyGPSPlus gps;&#xA;&#xA; // The serial connection to the GPS device&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(115200);&#xA; ss.begin(GPSBaud);&#xA;&#xA;     Serial.println(F(&quot;FullExample.ino&quot;));&#xA;     Serial.println(F(&quot;An extensive example of many interesting     TinyGPS++ features&quot;));&#xA;  Serial.print(F(&quot;Testing TinyGPS++ library v. &quot;));                    Serial.println(TinyGPSPlus::libraryVersion());&#xA;  Serial.println(F(&quot;by Mikal Hart&quot;));&#xA;  Serial.println();&#xA;  Serial.println(F(&quot;Sats HDOP Latitude   Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars     Sentences Checksum&quot;));&#xA;     Serial.println(F(&quot;          (deg)      (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail&quot;));&#xA;           Serial.println(F(&quot;---------------------------------------------------------------------------------------------------------------------------------------&quot;));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;&#xA;&#xA;  printInt(gps.satellites.value(), gps.satellites.isValid(), 5);&#xA;  printInt(gps.hdop.value(), gps.hdop.isValid(), 5);&#xA;  printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);&#xA;  printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);&#xA;  printInt(gps.location.age(), gps.location.isValid(), 5);&#xA;  printDateTime(gps.date, gps.time);&#xA;  printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);&#xA;  printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);&#xA;  printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);&#xA;  printStr(gps.course.isValid() ?        TinyGPSPlus::cardinal(gps.course.value()) : &quot;*** &quot;, 6);&#xA;&#xA;  unsigned long distanceKmToLondon =&#xA;   (unsigned long)TinyGPSPlus::distanceBetween(&#xA;     gps.location.lat(),&#xA;     gps.location.lng(),&#xA;     LONDON_LAT, &#xA;     LONDON_LON) / 1000;&#xA;     printInt(distanceKmToLondon, gps.location.isValid(), 9);&#xA;&#xA;     double courseToLondon =&#xA;    TinyGPSPlus::courseTo(&#xA;     gps.location.lat(),&#xA;     gps.location.lng(),&#xA;     LONDON_LAT, &#xA;     LONDON_LON);&#xA;&#xA;   printFloat(courseToLondon, gps.location.isValid(), 7, 2);&#xA;&#xA;   const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);&#xA;&#xA;   printStr(gps.location.isValid() ? cardinalToLondon : &quot;*** &quot;, 6);&#xA;&#xA;   printInt(gps.charsProcessed(), true, 6);&#xA;   printInt(gps.sentencesWithFix(), true, 10);&#xA;   printInt(gps.failedChecksum(), true, 9);&#xA;   Serial.println();&#xA;&#xA;   smartDelay(1000);&#xA;&#xA;   if (millis() &amp;gt; 5000 &amp;amp;&amp;amp; gps.charsProcessed() &amp;lt; 10)&#xA;    Serial.println(F(&quot;No GPS data received: check wiring&quot;));&#xA;   }&#xA;&#xA;  // This custom version of delay() ensures that the gps object&#xA;  // is being &quot;fed&quot;.&#xA;  static void smartDelay(unsigned long ms)&#xA;  {&#xA;  unsigned long start = millis();&#xA;  do &#xA;  {&#xA;   while (ss.available())&#xA;    gps.encode(ss.read());&#xA;    } while (millis() - start &amp;lt; ms);&#xA;    }&#xA;&#xA;    static void printFloat(float val, bool valid, int len, int prec)&#xA;     {&#xA;   if (!valid)&#xA;   {&#xA;    while (len-- &amp;gt; 1)&#xA;    Serial.print('*');&#xA;    Serial.print(' ');&#xA;    }&#xA;    else&#xA;    {&#xA;   Serial.print(val, prec);&#xA;   int vi = abs((int)val);&#xA;   int flen = prec + (val &amp;lt; 0.0 ? 2 : 1); // . and -&#xA;   flen += vi &amp;gt;= 1000 ? 4 : vi &amp;gt;= 100 ? 3 : vi &amp;gt;= 10 ? 2 : 1;&#xA;   for (int i=flen; i&amp;lt;len; ++i)&#xA;   Serial.print(' ');&#xA;   }&#xA;   smartDelay(0);&#xA;  }&#xA;&#xA; static void printInt(unsigned long val, bool valid, int len)&#xA; {&#xA;  char sz[32] = &quot;*****************&quot;;&#xA;  if (valid)&#xA;  sprintf(sz, &quot;%ld&quot;, val);&#xA;  sz[len] = 0;&#xA;  for (int i=strlen(sz); i&amp;lt;len; ++i)&#xA;   sz[i] = ' ';&#xA;  if (len &amp;gt; 0) &#xA;    sz[len-1] = ' ';&#xA;  Serial.print(sz);&#xA;  smartDelay(0);&#xA;  }&#xA;&#xA;  static void printDateTime(TinyGPSDate &amp;amp;d, TinyGPSTime &amp;amp;t)&#xA;  {&#xA;  if (!d.isValid())&#xA;   {&#xA;   Serial.print(F(&quot;********** &quot;));&#xA;   }&#xA;   else&#xA;   {&#xA;   char sz[32];&#xA;   sprintf(sz, &quot;%02d/%02d/%02d &quot;, d.month(), d.day(), d.year());&#xA;   Serial.print(sz);&#xA;    }&#xA;&#xA;    if (!t.isValid())&#xA;    {&#xA;    Serial.print(F(&quot;******** &quot;));&#xA;    }&#xA;    else&#xA;    {&#xA;    char sz[32];&#xA;    sprintf(sz, &quot;%02d:%02d:%02d &quot;, t.hour(), t.minute(), t.second());&#xA;    Serial.print(sz);&#xA;    }&#xA;&#xA;    printInt(d.age(), d.isValid(), 5);&#xA;    smartDelay(0);&#xA;    }&#xA;&#xA;    static void printStr(const char *str, int len)&#xA;    {&#xA;    int slen = strlen(str);&#xA;    for (int i=0; i&amp;lt;len; ++i)&#xA;    Serial.print(i&amp;lt;slen ? str[i] : ' ');&#xA;    smartDelay(0);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18813" LastActivityDate="2020-02-06T20:37:35.497" Title="Measuring The Distance Using GPS programmed with Arduino" Tags="|arduino-uno|tinygps|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23116" PostTypeId="2" ParentId="23113" CreationDate="2016-04-14T09:47:12.067" Score="1" Body="&lt;p&gt;At which pins you connected the ESP8266?&#xA;The pins pin 0 (RX) an 1 (TX) are connectet internaly to the FTDI USB-to-TTL Serial chip.&#xA;If you using Serial.begin() to communicate with the ESP8266, you can't communicate with the pc at the same time.&#xA;Use SoftwareSerial to communicate with the ESP8266 an Serial to PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also recommed to feed the ESP8266 with an external 3.3V power supply and stabilize with an capacitor. This could  produces the sounds of ejecting and inserting a USB.&lt;/p&gt;&#xA;" OwnerUserId="20188" LastActivityDate="2016-04-14T09:47:12.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23117" PostTypeId="2" ParentId="23115" CreationDate="2016-04-14T10:09:17.823" Score="1" Body="&lt;p&gt;This is where those dreaded maths classes come in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You know - the ones where no one paid attention because you thought &quot;Where in the real world would I ever want to know this stuff?&quot; Well, right here is were you would want to know this stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The distance between two points on a 2D plane (i.e., a map) can be looked at as two vertices of a right-angled triangle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SodLK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SodLK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going from Start to Finish you travel X degrees across the globe and Y degrees up or down it.  So you can calculate the number of degrees between the two points with simple pythagoras' theorem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jd1QN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jd1QN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C it's quite easy to do those calculations.  You can find X and Y by subtracting the two longitudes and scaling it for the logitudinal circumference of the Earth where you are. You can do the latitudes in a similar way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float X = ((long2 - long1) * 24901 * cos(lat1)) / 360.0&#xA;float Y = ((lat2 - lat1) * 24860) / 360.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;24901 is the circumference of the Earth at the equator, and 24860 is the circumference of the Earth going through both poles. Both are in miles, so the result will also be in miles. The numbers are different for the two directions because the Earth is not a perfect sphere. It is somewhat flattened at the poles, and is called an &lt;em&gt;oblate sphere&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It doesn't matter which one you subtract from which since, when you square them, they will become positive anyway:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float X2 = X * X;&#xA;float Y2 = Y * Y;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can get the square root:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float Distance = sqrt(X2 + Y2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So now you know how to calculate it without relying on some function in some library. It only takes a couple of lines of C code and you don't have to then know just how to use this unknown function provided by a library, and the theory will stand you in good stead for future similar projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and the code in full, in case you want it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float X = ((long2 - long1) * 24901 * cos(lat1)) / 360.0&#xA;float Y = ((lat2 - lat1) * 24860) / 360.0&#xA;float X2 = X * X;&#xA;float Y2 = Y * Y;&#xA;float Distance = sqrt(X2 + Y2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-15T09:57:51.627" LastActivityDate="2016-04-15T09:57:51.627" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23118" PostTypeId="2" ParentId="23095" CreationDate="2016-04-14T10:41:25.430" Score="6" Body="&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: I am not familiar with the ESP8266 hardware, and some of my&#xA;answers below may be only valid on the AVR architecture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest way to synchronize your main code with your interrupt&#xA;service routine is to define a &lt;em&gt;critical section&lt;/em&gt; in your &lt;code&gt;loop()&lt;/code&gt; that&#xA;wraps access to the shared data, and to make sure this critical section&#xA;cannot be interrupted:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;noInterrupts();&#xA;buffer.write(data);&#xA;interrupts();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should be fine as long as you make the critical section as short as&#xA;possible. Majenko's recommendation, to inspect the &lt;code&gt;write()&lt;/code&gt; method with&#xA;“a fine toothed comb” in order to minimize the critical section, is&#xA;definitively good advice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To understand the relevance of the “as short as possible” requirement,&#xA;think about what could happen if the interrupt triggering event (the pin&#xA;going high) happens while interrupts are disabled. If this happens&#xA;&lt;em&gt;once&lt;/em&gt;, it's not a problem: the interrupt is put on hold (technically,&#xA;an &lt;em&gt;interrupt flag&lt;/em&gt; is raised), and then it's serviced as soon as&#xA;interrupts are enabled again. However, if the pin goes high &lt;em&gt;twice&lt;/em&gt;&#xA;while interrupts are blocked, then, when you enable interrupts again,&#xA;the interrupt handler will be called only once. Whether this is a&#xA;problem or not I cannot say, it all depends on what job the handler is&#xA;supposed to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, to the specific sub-questions:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to create a thread-safe variable (a bool flag)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Chances are the boolean can be read and set atomically, so it's&#xA;inherently thread-safe. On an 8-bit CPU, like the AVR, access to a&#xA;multi-byte variable has to be protected inside a critical section. But&#xA;since you have a 32-bit CPU, I bet you have atomic access to variables&#xA;up to 32-bit wide.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I detach an interrupt method that is triggered when a pin goes high&#xA;  when it is low (for just a few fast instructions), the pin gets high&#xA;  in that time, and then I'll re-attach the method to this pin again,&#xA;  will it be invoked?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Hard to say without reading both the datasheet of the hardware and the&#xA;source code of &lt;code&gt;attachInterrupt()&lt;/code&gt;. It may be safer to keep the handler&#xA;attached and start its code with something like&#xA;&lt;code&gt;if (doNotRunInterruptHandler) return;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The same question for noInterrupts();&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, it will be invoked, but at most once.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I detach this method (in main loop), is it possible that it will be&#xA;  invoked before the control is back from the detachInterrupt() method?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, the interrupt can fire while &lt;code&gt;detachInterrupt()&lt;/code&gt; is checking to see&#xA;whether you gave it valid parameters.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;same question for noInterrupts();&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Check the implementation. On the AVR, &lt;code&gt;noInterrupts()&lt;/code&gt; is atomic.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I've read that noInterrupts(); causes some things, like reading&#xA;  incoming serial data, to be skipped.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Nothing like this will happen if your critical section is fast enough.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;please define the &quot;fast enough&quot;!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It depends on how long you can afford to delay the interrupt service&#xA;routine. For example, if you are reading serial data at 115200&amp;nbsp;bps&#xA;and the UART has only a one-byte buffer, then a 86&amp;nbsp;µs critical&#xA;section can make you loose one byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, there is the risk that several interrupts of the same kind fire&#xA;during the same same critical section. As said before, the interrupt&#xA;will only be serviced once. If this is a problem, then you should not&#xA;block interrupts for longer than the minimum possible period of the&#xA;triggering event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there is always the risk that several, &lt;em&gt;unrelated&lt;/em&gt; interrupts fire&#xA;during the same critical section. Then, the one with the lowest priority&#xA;will have to wait for the critical section to finish &lt;em&gt;and then&lt;/em&gt; for the&#xA;higher priority interrupt to be serviced.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-14T10:41:25.430" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23121" PostTypeId="1" AcceptedAnswerId="23123" CreationDate="2016-04-14T12:06:25.190" Score="1" ViewCount="229" Body="&lt;p&gt;I receive strings over the serial port like so:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;VLT=53.0, AMP=-30.2, AHR=-10, SOC=98, TMP=136, STS=192&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to reduce the use of string functions with the idea of dropping all non-digits, keeping numbers dot and comma, to get this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;53.0,-30.2,-10,98,136,192&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in an array and simple read [0], [1], etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regular expressions would be idea, but do not exist like in PERL.&#xA;Any hint would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relevant code used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char inByte = SerialPortOne.read(); // read byte&#xA;    strRecordIn.concat(inByte);         // add byte to receive buffer&#xA;    for (int i = 0; i &amp;lt;= 3; i++) {    // VLT, AMP, AHR, SOC&#xA;    strWord = getValue(strRecordIn, ',', i);  // get data item from RecordIn array&#xA;      strWord.remove(0, 4);           // remove field identifier (1st 3 char plus =)&#xA;      strRecordOut += ',';            // add delimiter&#xA;      strRecordOut += strWord;        // add value&#xA;      strWord = &quot;&quot;;                   // reset strWord&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideally:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char inByte = SerialPortOne.read(); // read byte&#xA;    if (inByte = [%d.,]+) {&#xA;      strRecordIn.concat(inByte);       // add byte to receive buffer&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20190" LastActivityDate="2016-04-14T12:18:37.407" Title="Drop alpha character from serial input" Tags="|arduino-uno|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23123" PostTypeId="2" ParentId="23121" CreationDate="2016-04-14T12:18:37.407" Score="0" Body="&lt;p&gt;If you just want to remove the letters:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;ctype.h&amp;gt;&#xA;&#xA;char inByte = SerialPortOne.read();  // read byte&#xA;if (!isalpha(inByte)) {              // not letter&#xA;    strRecordIn.concat(inByte);      // add byte to receive buffer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or you may test it for &lt;code&gt;isdigit()&lt;/code&gt; and explicitly compare to &lt;code&gt;','&lt;/code&gt; and&#xA;&lt;code&gt;'.'&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (isdigit(inByte) || inByte == '.' || inByte == ',') {&#xA;    strRecordIn.concat(inByte);      // add byte to receive buffer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C.f. the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__ctype.html&quot; rel=&quot;nofollow&quot;&gt;documentation of&#xA;&amp;lt;ctype.h&amp;gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-14T12:18:37.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23126" PostTypeId="1" AcceptedAnswerId="23129" CreationDate="2016-04-14T14:13:39.430" Score="3" ViewCount="4206" Body="&lt;p&gt;I'm struggling with something. My CPU sits in a switch case state machine like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch(expression) {&#xA;&#xA;   case constant-expression_1  :&#xA;      statement(s);&#xA;      break; /* optional */&#xA;&#xA;   case constant-expression_2  :&#xA;      statement(s);&#xA;      break; /* optional */&#xA;&#xA;   /* you can have any number of case statements */&#xA;   default : /* Optional */&#xA;   statement(s);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have an interrupt that occurs on a button press. In the interrupt, I change the switch expression to the case I want to go next, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ISR(void){&#xA;   expression = constant-expression_2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After the interrupt has been handled, I want the CPU to return directly to the case being switched to, and to not continue where it left off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any good ideas on how to implement this, if it's possible? I'd prefer to not have to wait for the code to finish what was happening in the previous case before going to the one being switched to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="20191" LastActivityDate="2016-04-15T10:13:34.773" Title="Breaking a switch case from an ISR" Tags="|interrupt|button|isr|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23127" PostTypeId="1" CreationDate="2016-04-14T14:30:26.333" Score="3" ViewCount="765" Body="&lt;p&gt;I have a Nano clone here, that sporadically fails to get detected by my banana pi. This is annoying, because it works for days and hours, but fails to work randomly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nano gets it's own power via &lt;code&gt;VIN&lt;/code&gt; and thus should have enough power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought of bypassing the FTDI and make a Serial connection via 2 Wires. Alternatively: Is there a way to force the arduino to use external Power over USB. I have the feeling, the the arduino wrongly decides, that USB is the better power source and uses it, causing the errors ( &lt;code&gt;device not accepting address 21, error -62&lt;/code&gt; )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: There is also a touch-screen connected to the banana pi via USB. Whatever port I use, It works and never failed. Just the Nano fails from time to time.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="19013" LastEditDate="2016-04-14T14:36:57.490" LastActivityDate="2022-12-03T04:06:20.837" Title="Arduino Nano USB Serial Bypass" Tags="|serial|arduino-nano|" AnswerCount="1" CommentCount="11" ClosedDate="2022-12-03T06:18:36.623" ContentLicense="CC BY-SA 3.0" />
  <row Id="23128" PostTypeId="2" ParentId="23126" CreationDate="2016-04-14T14:42:17.233" Score="1" Body="&lt;p&gt;Most of the time this isn't a problem, because code normally runs pretty fast. The problem, most of the time, is the use of &lt;code&gt;delay&lt;/code&gt;s. What I did was use my own delay function that checks if the expression has changed, and if so, immediately returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code. I had to modify it a bit, so it might not work out of the box, but will give you the idea as to how.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile byte expression;&#xA;volatile boolean expressionChanged = false;&#xA;&#xA;switch(expression) {&#xA;&#xA;   case constant-expression_1  :&#xA;      statement(s);&#xA;      myDelay(1000);&#xA;      statement(s);&#xA;      break; /* optional */&#xA;&#xA;   case constant-expression_2  :&#xA;      statement(s);&#xA;      myDelay(500);&#xA;      statement(s);&#xA;      break; /* optional */&#xA;&#xA;   /* you can have any number of case statements */&#xA;   default : /* Optional */&#xA;      statement(s);&#xA;}&#xA;&#xA;void myDelay(int ms)&#xA;{&#xA;    uint32_t start = micros();&#xA;    while (ms &amp;gt; 0 &amp;amp;&amp;amp; !expressionChanged)&#xA;    {&#xA;        //yield();not implemented in arduino&#xA;        if ( (micros() - start) &amp;gt;= 1000)&#xA;        {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }   &#xA;}&#xA;&#xA;void ISR(void){&#xA;   expression = constant-expression_2;&#xA;   expressionChanged = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-14T14:42:17.233" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23129" PostTypeId="2" ParentId="23126" CreationDate="2016-04-14T16:01:01.440" Score="0" Body="&lt;p&gt;It is certainly possible, although I do not think there is any &lt;em&gt;clean&lt;/em&gt;&#xA;way of doing it...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an idea that &lt;strong&gt;may&lt;/strong&gt; work: right before the switch statement,&#xA;you save the current context with &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__setjmp.html&quot; rel=&quot;nofollow&quot;&gt;the &lt;code&gt;setjmp()&lt;/code&gt;&#xA;function&lt;/a&gt;.&#xA;Then, in the ISR, you restore that context with &lt;code&gt;longjmp()&lt;/code&gt;. This is&#xA;kind of like a goto statement that works across functions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;setjmp.h&amp;gt;&#xA;&#xA;jmp_buf env;&#xA;&#xA;ISR(FOO_vect) {&#xA;    expression = ...;&#xA;    longjmp(env, 1);  // go to start of loop&#xA;}&#xA;&#xA;void loop() {&#xA;    setjmp(env);  // landing point from ISR exit&#xA;    switch (expression) {&#xA;        ...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the normal exit sequence of an ISR (the &lt;code&gt;reti&lt;/code&gt; instruction)&#xA;re-enables the interrupts. Since we are skipping this exit sequence, &lt;s&gt;we&#xA;have to enable them explicitly upon return from &lt;code&gt;setjmp()&lt;/code&gt;&lt;/s&gt;&#xA;interrupts are re-enabled not by the &lt;code&gt;reti&lt;/code&gt; instruction but by &lt;code&gt;longjmp()&lt;/code&gt;&#xA;restoring the CPU's status register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: This is a (very dirty) hack that I have &lt;em&gt;not tested&lt;/em&gt;. If I&#xA;were to use this trick, I would first:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Carefully examine the generated assembly to convince myself it does&#xA;the right thing.&lt;/li&gt;&#xA;&lt;li&gt;Test, test, test...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In case of problems, debugging this may be harder than just testing the&#xA;expression inside every slow function you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: Although I am saying that there is no clean way of doing&#xA;what you intend, there certainly is a clean way of achieving the same&#xA;end result: just make sure your switch statements return fast. My&#xA;preferred way of doing this would be to make sure no function ever&#xA;waits. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A routine reading sensors would not wait for them to respond. Instead,&#xA;it would return immediately if no reading is available. If a reading&#xA;&lt;em&gt;is&lt;/em&gt; available, it would retrieve it, send a query to the next sensor&#xA;in the list, then return.&lt;/li&gt;&#xA;&lt;li&gt;A communication routine would not wait for complete messages. Instead,&#xA;it would return immediately if no byte is available. If a byte is&#xA;available, it would buffer it and return. Unless it's the last byte of&#xA;a complete message, in which case it would process the message.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Obviously this could require a heavy refactoring of your code, probably&#xA;using finite state machines (see for example the tutorials&#xA;&lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&#xA;and &lt;a href=&quot;https://www.sparkfun.com/news/1801&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). It may be easier to&#xA;just test whether the expression has changed inside every busy-wait loop&#xA;you have, as recommended by Gerben's and Nick's answers.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-15T10:13:34.773" LastActivityDate="2016-04-15T10:13:34.773" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23130" PostTypeId="1" CreationDate="2016-04-14T18:01:10.920" Score="2" ViewCount="63" Body="&lt;p&gt;While making a Arduino programmed maze runner Will bipolar motor shield be more beneficial than using tb6612fng motor shield???? Also which type of sensors will be better??&lt;/p&gt;&#xA;" OwnerUserId="20104" LastActivityDate="2016-04-14T18:01:10.920" Title="Motor shield and sensors" Tags="|arduino-uno|arduino-mega|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23131" PostTypeId="1" AcceptedAnswerId="23132" CreationDate="2016-04-14T18:16:35.083" Score="0" ViewCount="1773" Body="&lt;p&gt;I bought a bunch of blank Mifare Classic NFC cards and I'd like to write NDEF records to them using my Arduino Uno. When I read them using my Uno and a PN532 NFC module using &lt;a href=&quot;https://github.com/don/NDEF/blob/master/examples/ReadTagExtended/ReadTagExtended.ino&quot; rel=&quot;nofollow&quot;&gt;Don's NDEF library&lt;/a&gt; however, it tells me they're not NDEF formatted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to define my NFC tags as NDEF using just the PN532 module and an Arduino Uno? (My Android phone doesn't support NFC.)&lt;/p&gt;&#xA;" OwnerUserId="20166" LastActivityDate="2016-04-14T18:21:35.750" Title="Defining an NFC tag as NDEF using the Arduino Uno and the PN532 NFC module" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23132" PostTypeId="2" ParentId="23131" CreationDate="2016-04-14T18:21:35.750" Score="0" Body="&lt;p&gt;I found the answer to my own question right after posting it, while going through the examples included in the library above:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library contains an example named &quot;FormatTag&quot; which does exactly what I was looking for.&lt;/p&gt;&#xA;" OwnerUserId="20166" LastActivityDate="2016-04-14T18:21:35.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23133" PostTypeId="1" AcceptedAnswerId="23135" CreationDate="2016-04-14T18:40:03.433" Score="0" ViewCount="3657" Body="&lt;p&gt;I'm having trouble using the ENABLE pin on my microstepper driver, I'm not sure of the exact model but it looks exactly like the one pictured here&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.driver-motor.com/UploadFile/ProductImage/1/5/20090328230757_%E7%85%A7%E7%89%87-005.jpg&quot; rel=&quot;nofollow&quot;&gt;Microstepper Driver&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_LEN 8&#xA;#define MIN_INCREMENT 0.5&#xA;#define LIMIT_SWITCH 3&#xA;#define ENABLE 10&#xA;float buoyancymass = 4401.425;&#xA;float centrebuoyancy = 14.164;&#xA;float mainarm = 14.3;&#xA;float nosearm = 1.8;&#xA;float adc = 11.4;&#xA;float meanadc = 22.65; &#xA;volatile byte enable_state = LOW;&#xA;&#xA;&#xA;#include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;const int stepsPerRevolution = 1600;  // change this to fit the number of steps per revolution&#xA;// for your motor&#xA;&#xA;// initialize the stepper library on pins 8 through 11:&#xA;Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);&#xA;&#xA;int stepCount = 0;         // number of steps the motor has taken&#xA;float stepinch = 0.00524; // 1 step = x&quot;&#xA;&#xA;void setup() {&#xA;  // initialize the serial port:&#xA;  Serial.begin(9600);&#xA;  pinMode(LIMIT_SWITCH, INPUT_PULLUP);&#xA;  pinMode(ENABLE, OUTPUT);&#xA;  //enable motor&#xA;  digitalWrite(ENABLE, enable_state);&#xA;  //interrupt&#xA;  attachInterrupt(digitalPinToInterrupt(LIMIT_SWITCH), limitbrake, FALLING);&#xA;  // set the speed&#xA;  myStepper.setSpeed(30);&#xA;}&#xA;&#xA;void limitbrake() {&#xA;  digitalWrite(ENABLE, !enable_state);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem I'm noticing is that when I set the &lt;code&gt;pinMode(ENABLE,OUTPUT);&lt;/code&gt; my stepper doesn't draw current and therefor, doesn't drive. This occurs regardless of whether I set my &lt;code&gt;enable_state&lt;/code&gt; to HIGH or LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Funny enough, when I set it to &lt;code&gt;pinMode(ENABLE,INPUT);&lt;/code&gt; it does draw current and drive the motor, but unfortunately my limit switch which I've attached an interrupt to doesn't disable the motor when its pressed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before you ask, I've tested the enable pin on my driver and my limit switch circuitry in other programs and they both work. I'm just having trouble with putting it together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the rest of my code if you were wondering. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float calc_margin(float pos, float mass) {&#xA;  // calculate margin&#xA;  Serial.print(&quot;Distance: &quot;);Serial.println(pos);&#xA;  float batterymoment = mass*pos;&#xA;  Serial.println(batterymoment);&#xA;  float totalmass = mass + 12404;&#xA;  Serial.println(totalmass);&#xA;  float totalmoment = 149650+batterymoment;&#xA;  Serial.println(totalmoment);&#xA;  float buoyancymoment = buoyancymass*centrebuoyancy;&#xA;  Serial.println(buoyancymoment);&#xA;  float wheelmoment = totalmoment - buoyancymoment;&#xA;  Serial.println(wheelmoment);&#xA;  float wheelweight = totalmass - buoyancymass;&#xA;  Serial.println(wheelweight);&#xA;  float cgwheels = wheelmoment/wheelweight;&#xA;  Serial.println(cgwheels);&#xA;  float maindistance = mainarm - cgwheels;&#xA;  Serial.println(maindistance);&#xA;  float nosedistance = cgwheels - nosearm;&#xA;  Serial.println(nosedistance);&#xA;  float mainmass = (((wheelweight)*(1-((maindistance)/(maindistance+nosedistance))))/2);&#xA;  Serial.println(mainmass);&#xA;  float nosemass = (((wheelweight)*(1-((nosedistance)/(nosedistance+maindistance))))/2);&#xA;  Serial.println(nosemass);&#xA;  float mainmoment = mainmass*mainarm;&#xA;  Serial.println(mainmoment);&#xA;  float nosemoment = nosemass*nosearm;&#xA;  Serial.println(nosemoment);&#xA;  float netmoment = buoyancymoment+(mainmoment*2)+(nosemoment*2);&#xA;  Serial.println(netmoment);&#xA;  float netcg = netmoment/totalmass;&#xA;  Serial.println(netcg);&#xA;  float staticmargin = adc - netcg;&#xA;  Serial.println(staticmargin);&#xA;  float answer = staticmargin/meanadc;&#xA;  Serial.println(answer);&#xA;  float percentage = answer*100;&#xA;  Serial.print(percentage); Serial.println(&quot;%&quot;);&#xA;  float result = answer;&#xA;  return result;&#xA;}&#xA;&#xA;boolean check_margin(float test_margin) {&#xA;  if (test_margin &amp;gt; -0.04 &amp;amp;&amp;amp; test_margin &amp;lt; -0.02)&#xA;    return true;&#xA;  return false;&#xA;}&#xA;&#xA;float armcalc(float mass) {&#xA;  for(float x=0;x&amp;lt;MAX_LEN;x+=MIN_INCREMENT) {&#xA;    // calculate margin&#xA;    float margin = calc_margin(x,mass);&#xA;    if (check_margin(margin)) {&#xA;      return x;&#xA;    }&#xA;  }&#xA;  return -1;&#xA;}&#xA;&#xA;float stepcalc(float arm){&#xA;  int arminch = arm*12;&#xA;  float numberofsteps = arminch/stepinch;&#xA;  int result = numberofsteps;&#xA;  Serial.print(&quot;Calculated steps: &quot;); Serial.println(result);&#xA;  return result;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // read input&#xA;  Serial.println(&quot;Enter mass: &quot;);&#xA;  while (!Serial.available());&#xA;  float mass = Serial.parseFloat();&#xA;  float arm = armcalc(mass);&#xA;  if (arm &amp;lt; 0) {&#xA;    // Error message&#xA;    Serial.println(&quot;Error!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.print(&quot;Arm distance is &quot;); Serial.println(arm);&#xA;  // step&#xA;  const int steplength = (int) stepcalc(arm);&#xA;  Serial.print(&quot;Number of steps is &quot;); Serial.println(steplength);&#xA;  myStepper.step(-steplength);&#xA;&#xA;  while(1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19111" LastActivityDate="2021-09-25T05:04:37.790" Title="Controlling Enable Function on MicroStepper Driver" Tags="|arduino-uno|interrupt|stepper|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23135" PostTypeId="2" ParentId="23133" CreationDate="2016-04-14T20:08:16.740" Score="1" Body="&lt;p&gt;These drivers differ from the H-Bridge-design &lt;a href=&quot;http://www.arduino.cc/en/Reference/StepperBipolarCircuit&quot; rel=&quot;nofollow noreferrer&quot;&gt;described here&lt;/a&gt;. You don't need to generate pulses for the coils, as you would do with a classic H-Bridge.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect your motor to &lt;code&gt;A+&lt;/code&gt;, &lt;code&gt;A-&lt;/code&gt;, &lt;code&gt;B+&lt;/code&gt;, &lt;code&gt;B-&lt;/code&gt; (a is one coil, b the other)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect Power (guess 12+ volts, mine take up to 48V) to &lt;code&gt;GND&lt;/code&gt; and &lt;code&gt;V+&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Either connect 5V to &lt;code&gt;ENA+(+5V)&lt;/code&gt; or a free arduino Pin and &lt;code&gt;ENA-(ENA)&lt;/code&gt; to GND. This pin enables/disables the driver. If no input is present at this pin, the driver will not work.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect &lt;code&gt;DIR+(+5V)&lt;/code&gt; to a free arduino pin and &lt;code&gt;DIR-(DIR)&lt;/code&gt; to &lt;code&gt;GND&lt;/code&gt;. This pin controls the direction. &lt;code&gt;HIGH&lt;/code&gt; makes the motor turn right, while &lt;code&gt;LOW&lt;/code&gt; on this pin makes the motor turn left.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect &lt;code&gt;PUL+(+5V)&lt;/code&gt; to a free arduino pin and &lt;code&gt;PUL-(PUL)&lt;/code&gt; to &lt;code&gt;GND&lt;/code&gt;. This pin controls the speed. The more pulses/second one applies, the faster the motor turns. (Up to a limit, of course).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Sketch should be easy.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Plus&lt;/strong&gt;: You could turn around the control connections, by hardwiring all &lt;code&gt;+5V&lt;/code&gt; pins to 5V and use &lt;code&gt;INPUT_PULLUP&lt;/code&gt; to switch the current flow on the negative lines. I know that these drivers are optical isolated and draw as little as 10 mA from a pin, if at all. So you should be safe.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="72996" LastEditDate="2021-09-25T05:04:37.790" LastActivityDate="2021-09-25T05:04:37.790" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23136" PostTypeId="1" AcceptedAnswerId="23161" CreationDate="2016-04-14T20:34:38.890" Score="0" ViewCount="685" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.firgelli.com/Firgelli_Technologies_PQ12_R_p/pq12-r.htm&quot; rel=&quot;nofollow&quot;&gt;linear actuator&lt;/a&gt; that I want to be able to slow down. Right now, the shaft moves too quickly. I'm not sure how to do this. I was looking into &lt;code&gt;varSpeedServo.h&lt;/code&gt; library but couldn't implement it.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;//Includes&#xA;#include &amp;lt;Servo.h&amp;gt; &#xA;&#xA;//Defines&#xA;#define LINEARACTUATORPIN 9        //Linear Actuator Digital Pin&#xA;&#xA;&#xA;&#xA;const int button1Pin = 4;     // the number of the pushbutton pin&#xA;&#xA;&#xA;// variables will change:&#xA;int button1State = 0;         // variable for reading the pushbutton status&#xA;&#xA;&#xA;Servo LINEARACTUATOR;  // create servo objects to control the linear actuator&#xA;&#xA;int linearValue = 10000;   //current positional value being sent to the linear actuator. &#xA;&#xA;void setup() &#xA;{ &#xA;  //initialize servo/linear actuator objects&#xA;  LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000);      // attaches/activates the linear actuator as a servo object &#xA;&#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(button1Pin, INPUT);   &#xA;&#xA;&#xA;  //use the writeMicroseconds to set the linear actuators to their default positions&#xA;  LINEARACTUATOR.writeMicroseconds(linearValue); &#xA;&#xA;} &#xA;&#xA;void loop() &#xA;{ &#xA;&#xA;  // if the pushbutton is pressed set the linear value&#xA;  button1State = digitalRead(button1Pin);&#xA;  if (button1State == HIGH) {    &#xA;    // set the position value  &#xA;    delay(2000);  &#xA;    linearValue = 1050; &#xA;&#xA;  } &#xA;&#xA;    if (button1State == LOW) {    &#xA;    // set the position value  &#xA;    linearValue = 2000;  &#xA;  } &#xA;&#xA;  //use the writeMicroseconds to set the actuator to the new position&#xA;  LINEARACTUATOR.writeMicroseconds(linearValue); &#xA;delay(3000);  &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18898" LastEditorUserId="6936" LastEditDate="2016-04-15T09:25:52.697" LastActivityDate="2016-04-15T15:19:25.540" Title="Control speed of linear actuator servo" Tags="|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23137" PostTypeId="1" CreationDate="2016-04-14T20:51:57.960" Score="1" ViewCount="1526" Body="&lt;p&gt;Sorry if this has been asked before, but I've read tons of threads and it seems the answer is only implied on a couple of occasions. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm an electrical noob, but I understand that a 9v battery plugged into a wall wort with a diode would serve as a battery backup if the power was cut from the wall wort.  I also understand that Vin on an arduino already has a diode to do this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm currently powering a temp/humidity that is dumping data into MySQL using a standard A-B USB cable and 5V DC USB power supply.  I'd like to incorporate a 9V battery plugged into Vin and ground, so that if DC power turns off, I can dump the data onto the SD card instead (since my MySQL server may or not be running during an outage).&lt;/p&gt;&#xA;" OwnerUserId="20197" LastActivityDate="2016-04-15T10:14:38.673" Title="Can a 9V battery be used as a backup power supply (to Arduino Uno) while plugged directly into Vin and ground?" Tags="|power|ethernet|sd-card|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23138" PostTypeId="2" ParentId="23126" CreationDate="2016-04-14T21:00:18.343" Score="1" Body="&#xA;&#xA;&lt;p&gt;First, put your major processing into functions. That looks better anyway. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;switch(expression) {&#xA;&#xA;   case constant-expression_1  :&#xA;      function1 ();&#xA;      break; /* optional */&#xA;&#xA;   case constant-expression_2  :&#xA;      function2 ();&#xA;      break; /* optional */&#xA;&#xA;   /* you can have any number of case statements */&#xA;   default : /* Optional */&#xA;      function_default ();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now inside your functions do a &lt;code&gt;return&lt;/code&gt; if you notice the expression has changed. This will get you out of any number of nested loops. For your 30 sensors, for example, you can now have a loop.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void function1 ()&#xA;  {&#xA;  for (int i = 0; i &amp;lt; 30; i++)&#xA;    {&#xA;    if (expression_changed)&#xA;       return;&#xA;    // take sensor reading&#xA;    }&#xA;  }  // end of function1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, as Gerben suggested, replace any &lt;code&gt;delay&lt;/code&gt; calls with a function that does the delay, however which ends early if the expression changes. It can return a boolean to let you know this happened. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;boolean myDelay(int ms)&#xA;  {&#xA;    uint32_t start = micros();&#xA;    while (ms &amp;gt; 0)&#xA;    {&#xA;        if (expression_changed)&#xA;           return true;   // early return&#xA;        if ( (micros() - start) &amp;gt;= 1000)&#xA;        {&#xA;            ms--;&#xA;            start += 1000;&#xA;        }&#xA;    }   &#xA;  return false;   // normal return&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now any function that needs delays can use that, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;void function2 ()&#xA;  {&#xA;  do_something ();&#xA;  if (myDelay (1000))  &#xA;     return;   // bail out&#xA;  do_something_else ();&#xA;  }  // end of function1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;My problem is, one of my cases includes a communication transceiver method, which can take a lot of time to get through&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There must be logical spots where you can just test the expression and do a &lt;code&gt;return&lt;/code&gt; (preferably cleaning up anything that needs it) when required.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-14T21:00:18.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23140" PostTypeId="2" ParentId="23137" CreationDate="2016-04-14T21:13:13.727" Score="3" Body="&lt;p&gt;My problem with that is that the other side of the diode on the Arduino is normally powered up. So for example if you have a 12V supply in the power jack you'll have 11.3V at Vin (because of the diode drop). Thus you are pumping 11.3V into your 9V battery which won't be designed to handle it. It will probably get hot and explode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need &lt;em&gt;another&lt;/em&gt; diode specifically between the battery and Vin. And make sure that Vin is at least 10V so that the normal mains power does not charge the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind a 9V battery doesn't have much capacity. With the power LED on,  taking sensor readings, and sending data via Ethernet (if that is what you are doing) you may have only bought yourself 15 minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a post about a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;temperature and humidity sensor&lt;/a&gt; which runs all the time from 3 x AA batteries. I think the batteries need replacing about every two years. The data is written to an SD card which you remove and plug into your computer when you want to.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;when you have 9V hooked up to Vin and 5V coming in from the USB, it will use power from the 9V battery&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looks like I misread the question. @mwwalk is quite right. If you supply more than 6.6V through Vin then the circuitry switches the USB off. See here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KyoOl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KyoOl.png&quot; alt=&quot;Uno power switching&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin is provided by the power jack (after a diode which drops it by 0.7V) - see blue ellipse. In any case (power jack or not) Vin goes through a voltage divider (two 10k resistors to the left of the red circle). This is compared to the output of the 3.3V voltage regulator. Therefore &lt;code&gt;GATE_CMD&lt;/code&gt; is HIGH if Vin exceeds 6.6V. This turns &lt;strong&gt;off&lt;/strong&gt; the MOSFET (green circle) and disconnects the USB power.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-15T10:14:38.673" LastActivityDate="2016-04-15T10:14:38.673" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23141" PostTypeId="1" CreationDate="2016-04-14T23:06:40.067" Score="2" ViewCount="64" Body="&lt;p&gt;I'd like to connect Arduino with bluetooth shield to multiple bluetooth devices (TV &amp;amp; baby monitor), plug a corded headset into the contraption, sprinkle LEDs on top, and do the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a signal above certain threshold coming from the baby monitor listen to a mix of TV and baby monitor audio with LEDs blinking; otherwise listen only to TV audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus the questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can bluetooth connect with multiple devices simultaneously?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do I need to implement that?&lt;/p&gt;&#xA;" OwnerUserId="16313" LastActivityDate="2016-04-14T23:06:40.067" Title="Can I turn a headset with a cord into a bluetooth headset with multiple connections?" Tags="|bluetooth|audio|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23142" PostTypeId="1" AcceptedAnswerId="23162" CreationDate="2016-04-15T01:24:27.523" Score="0" ViewCount="82" Body="&lt;p&gt;I bought a light sensor (&lt;strong&gt;LDR&lt;/strong&gt;), but he got &lt;strong&gt;stained&lt;/strong&gt;, what it means? It is used? Or is &lt;strong&gt;residuum&lt;/strong&gt; of time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must give back? I have to clean up or something?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought as new, so I tested one of the LEDs will not turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought the (Mercado Livre in BRAZIL).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The product is:&#xA;&lt;a href=&quot;http://www.gbkrobotics.com.br/exemplo-produto/p7-sensor-de-luz-com-leds.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gbkrobotics.com.br/exemplo-produto/p7-sensor-de-luz-com-leds.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pay R$8 BRL (equivalent aprox. $2 dollars) but, i just wanted to know if he had something I could do, because only shipping was R$ 13 BRL ($4 dollars)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm starting with Arduino, thx&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cgS8u.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cgS8u.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20125" LastEditorUserId="20125" LastEditDate="2016-04-15T12:47:05.693" LastActivityDate="2016-04-15T16:22:07.577" Title="Arduino LDR sensor stained" Tags="|sensors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23144" PostTypeId="1" AcceptedAnswerId="23151" CreationDate="2016-04-15T03:42:02.147" Score="0" ViewCount="12670" Body="&lt;p&gt;I have a Teensy set up as a keyboard, joystick, and I'm giving keyboard commands. Letter and number keys are going fine. But when I try sending ENTER, I get some extra code in my Linux terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;$ 16424&#xA;16424: command not found&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the code I have to give the ENTER key goes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  pinMode(0, INPUT_PULLUP);&#xA;  pinMode(1, INPUT_PULLUP);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the digital inputs and set the buttons&#xA;  Joystick.button(1, digitalRead(0));&#xA;  Serial.println(digitalRead(0));&#xA;  if(digitalRead(0)==0){&#xA;    Keyboard.println(KEY_ENTER);&#xA;  }&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where is this  &quot;16424&quot; coming from, and how do I send an ENTER keypress?&#xA;I am using a Teensy 2.0, on Linux, with Arduino IDE 1.6.7.&lt;/p&gt;&#xA;" OwnerUserId="4527" LastEditorUserId="26916" LastEditDate="2017-11-04T06:50:12.333" LastActivityDate="2017-11-04T06:50:12.333" Title="How do I give the ENTER keypress?" Tags="|teensy|keyboard|terminal|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23145" PostTypeId="2" ParentId="21914" CreationDate="2016-04-15T04:34:52.617" Score="2" Body="&lt;p&gt;Check out PJON - &lt;a href=&quot;https://github.com/gioblu/PJON&quot; rel=&quot;nofollow&quot;&gt;https://github.com/gioblu/PJON&lt;/a&gt;. It's a one-wire alternative.&lt;/p&gt;&#xA;" OwnerUserId="20201" LastActivityDate="2016-04-15T04:34:52.617" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23146" PostTypeId="1" AcceptedAnswerId="23160" CreationDate="2016-04-15T05:18:16.123" Score="1" ViewCount="13321" Body="&lt;p&gt;I have an ATmega328P Arduino and am trying to make the LED blink using assembly without any additional includes. The goal is to have it blink for 1 second on, then 1 second off, however, it blinks incredibly quickly and is barely perceptible. Am I doing something incorrectly?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;; DDRB       = 0x04&#xA;; PORTB      = 0x05&#xA;; TCCROB     = 0x25&#xA;; TCNT0      = 0x26&#xA;; 0b00000000 = OFF&#xA;; 0b00100000 = ON&#xA;&#xA;setup:&#xA;    ldi r16, 0b00100000     ; Set r16 to LED ON value&#xA;    out 0x04, r16           ; Set DDRB to output&#xA;    out 0x05, r16           ; Set PORTB to ON&#xA;    ldi r16, 0b00000101     ; Set r16 with prescaler 1024 value&#xA;    out 0x25, r16           ; Set the TCCROB to 1024&#xA;    ldi r20, 0              ; Reset r20&#xA;    ldi r21, 1              ; Hold value 1 to increment r20&#xA;loop:&#xA;    in r17, 0x26            ; Read the timer &#xA;    cpi r17, 128            ; Check to see if the timer is halfway done (1/2 second, max 255 value)&#xA;    brbc 0, increment       ; If r17 &amp;lt;= 128 (max 255 val before resets to 0), invert current LED state&#xA;    rjmp loop&#xA;increment:&#xA;    adc r20, r21            ; Add r21 (1) to r20 (with carry)&#xA;    brbs 0, reset           ; If the carry branch is set, reset the register&#xA;    rjmp loop               ; Otherwise, run the clock&#xA;reset:&#xA;    ldi r20, 0              ; Reset the delay register&#xA;    cpi r16, 0b00000000     ; Check if r16 is set to LED OFF&#xA;    brbs 1, switchon        ; If it is, change it to ON&#xA;    ldi r16, 0b00000000     ; Otherwise, change it to OFF&#xA;    out 0x05, r16           ; Set the LED to the new state&#xA;    rjmp loop               ; Run the clock&#xA;switchon:&#xA;    ldi r16, 0b00100000     ; Set r16 to LED ON value&#xA;    out 0x05, r16           ; Set the LED to the new state&#xA;    rjmp loop               ; Run the clock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20202" LastEditorUserId="20202" LastEditDate="2016-04-15T06:29:30.450" LastActivityDate="2016-04-15T15:14:14.943" Title="Make LED blink using AVR assembly" Tags="|arduino-uno|led|pins|assembly|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23147" PostTypeId="2" ParentId="23137" CreationDate="2016-04-15T06:35:55.757" Score="3" Body="&lt;p&gt;No, when you have 9V hooked up to Vin and 5V coming in from the USB, it will use power from the 9V battery, not usb and the battery will quickly be depleted.  &lt;/p&gt;&#xA;" OwnerUserId="3152" LastActivityDate="2016-04-15T06:35:55.757" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23148" PostTypeId="2" ParentId="23146" CreationDate="2016-04-15T07:25:02.593" Score="3" Body="&lt;p&gt;It appears that your intent is to set TCCROB up with a 1024x prescale, and each time it counts up to 128, increment r20, and toggle the LED each time r20 overflows to zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That sequence ought to take 1024/16M · 128 · 256 seconds, or about 2.1 seconds, a fairly leisurely toggle rate.  If instead it's flashing a hundred or more times too fast, probably one of the comparisons is backwards.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the following items might make it easier to debug the problem:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Instead of &lt;code&gt;brbc 0,...&lt;/code&gt;, say &lt;code&gt;brcc ...&lt;/code&gt;&lt;br&gt;&#xA;• Instead of &lt;code&gt;brbs 0,...&lt;/code&gt;, say &lt;code&gt;brcs ...&lt;/code&gt;&lt;br&gt;&#xA;• Instead of &lt;code&gt;brbs 1,...&lt;/code&gt;, say &lt;code&gt;breq ...&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is, use proper mnemonic branch instruction names, rather than referencing SREG bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• If my arithmetic was correct and your branch tests were fixed, your rate would be off by a factor of two.  To fix this problem, you could replace one of the more problematic tests (testing for carry clear after &lt;code&gt;cpi r17, 128&lt;/code&gt;) with &lt;code&gt;cpi r17, 0&lt;/code&gt; followed by a &lt;code&gt;breq&lt;/code&gt;, and change the prescale factor to 256 instead of 1024, which gives 256/16M · 256 · 256 seconds, or about 1.05 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Use named constants for register names instead of 0x04, 0x05, 0x25, and 0x26.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;• Instead of your lengthy toggle sequence use EOR to toggle the value.  That is, replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    cpi r16, 0b00000000     ; Check if r16 is set to LED OFF&#xA;    brbs 1, switchon        ; If it is, change it to ON&#xA;    ldi r16, 0b00000000     ; Otherwise, change it to OFF&#xA;    out 0x05, r16           ; Set the LED to the new state&#xA;    rjmp loop               ; Run the clock&#xA;switchon:&#xA;    ldi r16, 0b00100000     ; Set r16 to LED ON value&#xA;    out 0x05, r16           ; Set the LED to the new state&#xA;    rjmp loop               ; Run the clock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    eor   r18, r16          ; Toggle LED bit&#xA;    out   PORTB, r18        ; Set the LED to the new state&#xA;    rjmp  loop              ; Go run the clock&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where r16 and r18 are initialized as follows in setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ldi r16, 0b00100000     ; bit mask for LED pin&#xA;    mov r18, r16&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-15T07:25:02.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23150" PostTypeId="2" ParentId="23030" CreationDate="2016-04-15T09:33:12.877" Score="1" Body="&lt;pre&gt;&lt;code&gt;int sensorValue;&#xA;int pin8 = 8;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(pin8, OUTPUT);&#xA;&#xA;  }&#xA;&#xA;  void loop()&#xA;  {&#xA;    sensorValue = analogRead(0); // read analog input pin 0&#xA;    Serial.print(sensorValue, DEC); //prints the value read&#xA;    Serial.println(&quot;ppm&quot;);&#xA;    if (sensorValue &amp;gt; 500) {&#xA;      //Activate digital output pin 8 - the LED will light up&#xA;      digitalWrite(pin8, HIGH);&#xA;    }&#xA;    else&#xA;    {&#xA;      // Deactivate digital output pin 8 - the LED will not light up &#xA;      digitalWrite(pin8, LOW);&#xA;&#xA;    }&#xA;    delay(50);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20114" LastEditorUserId="10394" LastEditDate="2016-06-14T16:09:13.947" LastActivityDate="2016-06-14T16:09:13.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23151" PostTypeId="2" ParentId="23144" CreationDate="2016-04-15T09:57:28.347" Score="4" Body="&lt;p&gt;You can't just &quot;print&quot; a key like that. You use &lt;code&gt;print&lt;/code&gt; for sending text.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use &lt;code&gt;println&lt;/code&gt; it sends an enter key along with your text, so you can do :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.println(&quot;ls -al&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it will send the text &lt;code&gt;ls -al&lt;/code&gt; and press enter for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do it in the 'raw' way you will need to press and then release the key:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.press(KEY_ENTER);&#xA;Keyboard.release(KEY_ENTER);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-15T09:57:28.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23152" PostTypeId="1" CreationDate="2016-04-15T10:22:13.183" Score="-2" ViewCount="8540" Body="&lt;p&gt;I made simple sketch that generates three random numbers and then calculates the average of these three random numbers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It divides the total by 3 and then displays that average number with &lt;code&gt;serial.println&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes the generated average number can be decimal (for example 261,333333 or 124,33333).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly, the serial print doesn't print in decimal format &lt;strong&gt;124,33333&lt;/strong&gt;&#xA;it prints just integer &lt;strong&gt;124&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I print the value in decimal?&lt;/p&gt;&#xA;" OwnerUserId="20207" LastEditorUserId="6936" LastEditDate="2016-04-22T06:16:23.727" LastActivityDate="2016-04-26T20:27:35.207" Title="Printing decimal numbers" Tags="|arduino-uno|serial|mathematics|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23153" PostTypeId="1" AcceptedAnswerId="23197" CreationDate="2016-04-15T10:34:48.603" Score="1" ViewCount="746" Body="&lt;p&gt;So I have been messing around with the Arduino Capsense library with the immensely helpful guide; &lt;a href=&quot;http://www.instructables.com/id/How-To-Use-Touch-Sensors-With-Arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-To-Use-Touch-Sensors-With-Arduino/&lt;/a&gt;  (many thanks to DangerousTim!)   using the code provided, i managed to get a relay to operate with a sensor.  It worked great and I was able to adjust the distance and sensitivity.  But when i tried adding another sensor and relay, it stopped working.  I've been trying to isolate the problem for a while now and have gotten nowhere.  I'm hoping someone can help me, here's the original code for the single sensor and relay;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;#include &amp;lt;CapacitiveSensor.h&amp;gt; //change '42' to any desired pin...&#xA;&#xA;long time = 0;&#xA;int state = HIGH;&#xA;boolean yes;&#xA;boolean previous = false;&#xA;int debounce = 200;&#xA;CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);&#xA;// To add more sensors...&#xA;//CapacitiveSensor   cs_4_6 = CapacitiveSensor(4,6);        // 10M resistor       between pins 4 &amp;amp; 6, pin 6 is sensor pin, add a wire and or foil&#xA;//CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10M resistor  between pins 4 &amp;amp; 8, pin 8 is sensor pin, add a wire and or foil&#xA;&#xA;void setup()&#xA;{&#xA;    cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    long total1 =  cs_4_2.capacitiveSensor(30);&#xA;&#xA;    if (total1 &amp;gt; 60){yes = true;}&#xA;    else {yes = false;}&#xA;&#xA;    // to toggle the state of state&#xA;    if(yes == true &amp;amp;&amp;amp; previous  == false &amp;amp;&amp;amp; millis() - time&amp;gt;debounce){&#xA;        if(state == LOW){&#xA;            state = HIGH; }&#xA;        else state = LOW;&#xA;        time = millis();&#xA;    }&#xA;&#xA;    digitalWrite(13, state);&#xA;    previous = yes;&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here's the code for the two sensors and relays&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;&#xA;int led = 13;&#xA;int led2 = 12;&#xA;long time = 0;&#xA;int state = HIGH;&#xA;long time2 = 0;&#xA;int state2 = HIGH;&#xA;boolean yes;&#xA;boolean previous = false;&#xA;boolean yes2;&#xA;boolean previous2 = false;&#xA;int debounce = 200;&#xA;&#xA;CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor  between pins 4 &amp;amp; 2, pin 2 is sensor pin, add a wire and or foil if desired&#xA;CapacitiveSensor   cs_5_7 = CapacitiveSensor(4,6);&#xA;&#xA;void setup()&#xA;{&#xA;    cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);&#xA;    cs_5_7.set_CS_AutocaL_Millis(0xFFFFFFFF);  //Calibrate the sensor...&#xA;    pinMode(led, OUTPUT);&#xA;    pinMode(led2, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int total1 =  cs_4_2.capacitiveSensor(30);&#xA;    Serial.println(total1);&#xA;    int total2 =  cs_5_7.capacitiveSensor(30);&#xA;&#xA;    if (total1 &amp;gt; 60){yes = true;}&#xA;    else {yes = false;}&#xA;    if (total2 &amp;gt; 60){yes2 = true;}&#xA;    else {yes2 = false;}&#xA;&#xA;    // to toggle the state of state&#xA;    if(yes == true &amp;amp;&amp;amp; previous  == false &amp;amp;&amp;amp; millis() - time&amp;gt;debounce){&#xA;        if(state == LOW){&#xA;            state = HIGH;&#xA;        }&#xA;        else&#xA;            state = LOW;&#xA;        time = millis();&#xA;    }&#xA;&#xA;    if(yes2 == true &amp;amp;&amp;amp; previous2  == false &amp;amp;&amp;amp; millis() - time2&amp;gt;debounce){&#xA;        if(state2 == LOW){&#xA;            state2 = HIGH;&#xA;        }&#xA;        else&#xA;            state2 = LOW;&#xA;        time2 = millis();&#xA;    }&#xA;&#xA;    digitalWrite(led, state);&#xA;    previous = yes;&#xA;    digitalWrite(led2, state2);&#xA;    previous2 = yes2;&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19779" LastEditorUserId="7508" LastEditDate="2016-04-15T12:47:03.693" LastActivityDate="2016-04-16T13:53:56.753" Title="Arduino capacitive touch sensor help" Tags="|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23157" PostTypeId="2" ParentId="23152" CreationDate="2016-04-15T12:30:59.250" Score="2" Body="&lt;p&gt;In the C family of languages, if you divide an integer by another&#xA;integer, the compiler interprets the division operator (&lt;code&gt;/&lt;/code&gt;) as an&#xA;&lt;em&gt;integer division&lt;/em&gt;, i.e. you get the integer part of the quotient. Thus,&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;(first_int + second_int + third_int) / 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is an integer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If either operand is a floating point number, then the other one is&#xA;implicitly converted to floating point, and you get a floating point&#xA;division. Thus&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(first_int + second_int + third_int) / 3.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a floating point number, and the result you expect.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-04-22T13:17:42.097" LastActivityDate="2016-04-22T13:17:42.097" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23159" PostTypeId="1" CreationDate="2016-04-15T14:44:53.920" Score="6" ViewCount="12418" Body="&lt;p&gt;Does there exist (any user developed etc.) version of the Hardware UART serial library that has support for RTS/CTS based flow control? &#xA;More interested in the Tx side (Arduino sends data, while the peripheral can back-pressure). The library should enable the Arduino to stop transmitting within 1 character of seeing a 'not ready' indication from the peripheral.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="6930" LastActivityDate="2018-10-12T09:22:10.600" Title="Arduino Hardware serial library with rts/cts flow control support" Tags="|arduino-mega|uart|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23160" PostTypeId="2" ParentId="23146" CreationDate="2016-04-15T15:14:14.943" Score="2" Body="&lt;p&gt;There is a bug with the logic of your program: once TCNT0 gets larger&#xA;than 128, it will continue to be larger than 128 for quite some time...&#xA;during which time you are continuously incrementing your r20 counter.&#xA;The simplest fix would be to reset TCNT0 right after the &lt;code&gt;increment&lt;/code&gt;&#xA;label, with something like &lt;code&gt;out TCNT0, zero_reg&lt;/code&gt;. Then you may want to&#xA;compare TCNT0 with 61 instead of 128, in order to get closer to the&#xA;desired blink frequency of 0.5&amp;nbsp;Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other than that, there are quite a few problems in the way you write&#xA;your code. jwpat7 has already pointed out some of them, and here are&#xA;more:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You should not increment a register with &lt;code&gt;adc&lt;/code&gt;, but with plain &lt;code&gt;add&lt;/code&gt;.&#xA;Both instructions update the carry bit, but &lt;code&gt;adc&lt;/code&gt; also adds the&#xA;previous value of the carry bit to the target register.&lt;/li&gt;&#xA;&lt;li&gt;Better yet, increment with &lt;code&gt;inc&lt;/code&gt;, as it's purpose is more obvious. But&#xA;then you should test the zero bit, as &lt;code&gt;inc&lt;/code&gt; does not update the carry&#xA;bit.&lt;/li&gt;&#xA;&lt;li&gt;There is little point in resetting r20 once it has overflowed, as it&#xA;is zero at this point.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are also quite a few ways the program could me made simpler. The&#xA;simplest would probably be to configure timer 1 to deliver an interrupt&#xA;every second, and toggle the LED in the ISR. If you do not want&#xA;interrupts, you can configure counter 1 in much the same way, only&#xA;without the “interrupt enable” bit, and check the interrupt flag in a&#xA;busy loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a slightly simplified version of your program. I tried to keep&#xA;it as close as possible to yours, without using timer 1, nor interrupts,&#xA;and not even the interrupt flag. The code checks for timer 0 overflowing&#xA;by comparing its current value with the previous one.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.set PINB,     0x03&#xA;.set DDRB,     0x04&#xA;.set TCCR0B,   0x25&#xA;.set TCNT0,    0x26&#xA;.set LED_MASK, 0b00100000&#xA;.set PS_1024,  0b00000101&#xA;&#xA;setup:&#xA;    ldi r16, PS_1024    ; Set r16 with prescaler 1024 value&#xA;    out TCCR0B, r16     ; Set the TCCROB to 1024&#xA;    ldi r16, LED_MASK   ; Set r16 to the LED bit&#xA;    out DDRB, r16       ; Set LED pin to output&#xA;    clr r18             ; Clear the saved timer&#xA;loop:&#xA;    ldi r20, 61         ; Initialize our software counter&#xA;check_timer:&#xA;    in r17, TCNT0       ; Read the timer&#xA;    cp r17, r18         ; Compare with previous value&#xA;    mov r18, r17        ; Save current value&#xA;    brsh check_timer    ; unless the timer has decreased, repeat&#xA;decrement:&#xA;    dec r20             ; decrement the software counter&#xA;    brne check_timer    ; if not zero, go back to checking the timer&#xA;toggle:&#xA;    out PINB, r16       ; toggle the LED&#xA;    rjmp loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If we can use the timer overflow interrupt flag, then the test is&#xA;simpler, and we do not need to store the previous and current values of&#xA;the timer in registers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;check_timer:&#xA;    sbis TIFR0, TOV0    ; unless the timer has overflowed&#xA;    rjmp check_timer    ; check again for overflow&#xA;    sbi TIFR0, TOV0     ; otherwise clear the overflow flag&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-15T15:14:14.943" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23161" PostTypeId="2" ParentId="23136" CreationDate="2016-04-15T15:19:25.540" Score="0" Body="&lt;p&gt;Have you tried something like the following?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define STEP 50&#xA;&#xA;void loop() &#xA;{ &#xA;&#xA;  // if the pushbutton is pressed set the linear value&#xA;  button1State = digitalRead(button1Pin);&#xA;  if (button1State == HIGH) {    &#xA;    // set the position value  &#xA;    if (linearValue &amp;gt; 1050)&#xA;       linearValue = max(linearValue-STEP,1050) ; &#xA;&#xA;  } &#xA;&#xA;    if (button1State == LOW) {    &#xA;    // set the position value  &#xA;    if (linearValue &amp;lt; 2000) &#xA;       linearValue = min(linearValue+50,2000) ;  &#xA;  } &#xA;&#xA;  //use the writeMicroseconds to set the actuator to the new position&#xA;  LINEARACTUATOR.writeMicroseconds(linearValue); &#xA;  delay(100);  &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By changing the STEP value (or the delay in the next-to-last line) you can change the speed of the servo.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-04-15T15:19:25.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23162" PostTypeId="2" ParentId="23142" CreationDate="2016-04-15T16:22:07.577" Score="0" Body="&lt;p&gt;I've read you post a couple of times and I get the impression you would like this board to work, so here are some quick check to try and find the fault.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You need a bread board&lt;/li&gt;&#xA;&lt;li&gt;An arduino&lt;/li&gt;&#xA;&lt;li&gt;A 200-300 ohm resistor.&lt;/li&gt;&#xA;&lt;li&gt;Some wires. About 6 hands :)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Connect the board ground to the breadboard.  Then connect the to the resistor.  Then connect that to the power supply ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take the positive off the power supply and touch it to the LED1 pin and check LED1 lights up.  Repeat with 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switch every thing off&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the Positive to the Vcc connection of the board.&#xA;Connect a wire between Arduino A0 and &quot;Sinal Analog&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Load this sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   void setup() {&#xA;       Serial.begin(9600);&#xA;    }&#xA;   void loop() {&#xA;       Serial.println(analogRead(A0));&#xA;       delay(250);&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you cover the LDR it should read a lower number when you shine a light on it should read a higher number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turn everything off again, and if you have a multi meter test the resistance of the resistor on the board it should be 300 ohms, but I can't remember which way to read the bands and it might be 10K ohms, which would be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anything doesn't work then they can all be fixed for a few cents and you don't need to worry about the discolouration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps you.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-15T16:22:07.577" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23163" PostTypeId="1" AcceptedAnswerId="23218" CreationDate="2016-04-15T17:30:05.913" Score="1" ViewCount="4006" Body="&lt;p&gt;I want to do a project with fingerprint access control. But my client wants one on both sides of the door (inside and outside). Now I am using this product &lt;a href=&quot;https://www.adafruit.com/products/751&quot; rel=&quot;nofollow&quot;&gt;Adafruit Fingerprint module&lt;/a&gt; but I don't want to enroll each person on each fingerprint module. I want to look at enrolling each employee on 1 of these modules and then via arduino &quot;SYNC&quot; the fingerprint models between each other. Is this possible? Can someone maybe point me in the right direction or am I just insane HAHAHA. Look I can do the route of programming/enrolling each person on each module. But we life in a real world and at some point the fingerprint model/id's are not going to match up. And then there is going to come a problem with my online software. As well sorry for my bad lanuage  :)&lt;/p&gt;&#xA;" OwnerUserId="19724" LastActivityDate="2020-08-28T06:42:19.640" Title="Arduino and 2 Adafruit Fingerprint modules working together" Tags="|arduino-mega|adafruit|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23164" PostTypeId="1" AcceptedAnswerId="23186" CreationDate="2016-04-15T17:44:11.373" Score="1" ViewCount="2774" Body="&lt;p&gt;So, I have an Arduino Yun, and I'm trying to send an email with python. I have this code that I got from &lt;a href=&quot;https://github.com/amicojeko/YouCantTouchThis&quot; rel=&quot;nofollow&quot;&gt;https://github.com/amicojeko/YouCantTouchThis&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;But when I try to call the file with &lt;code&gt;$python sendemail.py test.png&lt;/code&gt;, it returns me an error:&#xA;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ImportError: No module named mime.multipart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I already tried to change to lowercase the imports, but it keeps showing the same error. The python version in the Arduino is 2.7. I've read something about module reorganization but even with the changes the error keep showing. &lt;br&gt;Here is the code: &#xA;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# coding=utf-8&#xA;# Copyright (C) 2014  Stefano Guglielmetti&#xA;&#xA;# This program is free software: you can redistribute it and/or modify&#xA;# it under the terms of the GNU General Public License as published by&#xA;# the Free Software Foundation, either version 3 of the License, or&#xA;# (at your option) any later version.&#xA;# This program is distributed in the hope that it will be useful,&#xA;# but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#xA;# GNU General Public License for more details.&#xA;&#xA;# You should have received a copy of the GNU General Public License&#xA;# along with this program. If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&#xA;&#xA;import smtplib, os, sys&#xA;from email.MIMEMultipart import MIMEMultipart&#xA;from email.MIMEBase import MIMEBase&#xA;from email.MIMEText import MIMEText&#xA;from email.Utils import COMMASPACE, formatdate&#xA;from email import Encoders&#xA;&#xA;#From address, to address, subject and message body&#xA;from_address    = 'FROM_ADDRESS@EMAIL.COM'&#xA;to_address      = ['YOUR_ADDRESS@EMAIL.COM']&#xA;email_subject   = 'Alert!!! Zombies!!! Ahead!!!'&#xA;email_body      = 'A non dead intruder has been detected and needs to be eliminated!'&#xA;&#xA;# Credentials (if needed)&#xA;username = 'EMAIL_LOGIN'&#xA;password = 'EMAIL_PASSWORD'&#xA;&#xA;# The actual mail send&#xA;server = 'smtp.gmail.com:587'&#xA;&#xA;def send_mail(send_from, send_to, subject, text, files=[], server=&quot;localhost&quot;):&#xA;    assert type(send_to)==list&#xA;    assert type(files)==list&#xA;&#xA;    msg = MIMEMultipart()&#xA;    msg['From'] = send_from&#xA;    msg['To'] = COMMASPACE.join(send_to)&#xA;    msg['Date'] = formatdate(localtime=True)&#xA;    msg['Subject'] = subject&#xA;&#xA;    msg.attach( MIMEText(text) )&#xA;&#xA;    for f in files:&#xA;        part = MIMEBase('application', &quot;octet-stream&quot;)&#xA;        part.set_payload( open(f,&quot;rb&quot;).read() )&#xA;        Encoders.encode_base64(part)&#xA;        part.add_header('Content-Disposition', 'attachment; filename=&quot;%s&quot;' % os.path.basename(f))&#xA;        msg.attach(part)&#xA;&#xA;    smtp = smtplib.SMTP(server)&#xA;    smtp.starttls()&#xA;    smtp.login(username,password)&#xA;    smtp.sendmail(send_from, send_to, msg.as_string())&#xA;    smtp.close()&#xA;&#xA;send_mail(from_address, to_address, email_subject, email_body, [sys.argv[1]], server) #the first command line argument will be used as the image file name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt; &#xA;&lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="20216" LastActivityDate="2016-04-16T05:31:32.533" Title="Arduino Yun Python ImportError: No Module named mime.multipart" Tags="|arduino-yun|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23165" PostTypeId="1" CreationDate="2016-04-15T18:41:35.000" Score="0" ViewCount="1541" Body="&lt;p&gt;I'm writing an Arduino sketch to control a display with my Arduino Nano. I have wired it up as explained &lt;a href=&quot;http://engineeringlearning.blogspot.de/2013/10/interfacing-lcd-without-potentiometer.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, but used pin 3-7 instead of pin 2-6 listed in the example. The reason I did so is that I also added a push-button on interrupt 0 (= digital pin 2). I'm calling the sleep mode with a method, as explained in the section &quot;Example&quot; &lt;a href=&quot;http://playground.arduino.cc/Learning/arduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. The Arduino seems to sleep, turning off all LEDs but the on/off one. The problem I have now is that the LCD display is sometimes still enabled (but only sometimes, not always). Why is it behaving like this? And how can I switch off everything possible to save as much energy as possible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code piece:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buttonPin = 2;&#xA;&#xA;void setup() &#xA;{&#xA;  pinMode(buttonPin , INPUT);&#xA;  digitalWrite(buttonPin , HIGH);&#xA;  ...&#xA;}&#xA;&#xA;void loop() {&#xA;  ...&#xA;  if(counter == 100) {&#xA;    enterSleep();            // Enter sleep method!&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&#xA;void enterSleep()&#xA;{&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;  sleep_enable();&#xA;  attachInterrupt(digitalPinToInterrupt(2), wakeUpNow, LOW);&#xA;  sleep_mode();&#xA;&#xA;  /* The program will continue from here. */&#xA;  /* First thing to do is disable sleep. */&#xA;  sleep_disable(); &#xA;  detachInterrupt(digitalPinToInterrupt(2));&#xA;}&#xA;&#xA;void wakeUpNow() {&#xA;  // execute code here after wake-up before returning to the loop() function&#xA;  // timers and code using timers (serial.print and more...) will not work here.&#xA;  // we don't really need to execute any special functions here, since we&#xA;  // just want the thing to wake up&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20218" LastEditorUserId="6628" LastEditDate="2016-04-15T20:05:53.383" LastActivityDate="2016-04-15T20:05:53.383" Title="Arduino: pins still active after entering sleep mode" Tags="|arduino-nano|lcd|sleep|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23166" PostTypeId="2" ParentId="23165" CreationDate="2016-04-15T19:00:02.797" Score="1" Body="&lt;p&gt;The problem is that you are not specifically doing anything to &quot;turn off&quot; the LCD (that is, switch off the back light - note that the LCD module will still be consuming power while you sleep).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you sleep the MCU it does just that - it goes to sleep. Its clock stops ticking. Not a lot more than that really.  So if you are using PWM to control the backlight of the LCD, when the clock stops ticking the PWM will stop happening, and the I/O pin will remain stuck in whatever state it happened to be in at that moment - leaving you with random on or off at sleep time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution? Manually turn off the backlight just before you sleep.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(9, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To save more power you might want to consider adding a high-side switch to the power of the LCD module. With that you can physically disconnect the power to the LCD to stop it consuming any power at all during sleep mode. Of course, after re-enabling it you will need to fully reinitialize the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same goes for any other external hardware that takes a power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A high side switch can be built from a P-channel MOSFET being controlled by an N-channel MOSFET. There's plenty of examples on the web.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-15T19:00:02.797" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23167" PostTypeId="1" AcceptedAnswerId="23200" CreationDate="2016-04-15T19:42:00.387" Score="0" ViewCount="1233" Body="&lt;p&gt;I am a software developer and I don't know much about circuits so I need help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an ESP8266 (esp-12) 3.3V and I'm planning to use it with an &lt;a href=&quot;https://www.sparkfun.com/products/242&quot; rel=&quot;nofollow&quot;&gt;IR proximity sensor&lt;/a&gt; (runs between 4.5-5V). I have 2 AA batteries (3V total) and 4 AA (6V total) power supplies. Also, I have a bunch of 10K Ohm and 330 Ohm resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I use a voltage divider to supply sufficient voltage to these components, based on what I have? If it would help, I have a 100uF capacitor and I use a &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B009T2ZR6W&quot; rel=&quot;nofollow&quot;&gt;CP2102 to TTL Serial Converter to program&lt;/a&gt;. Any help will be appreciated. Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="19181" LastEditorUserId="4628" LastEditDate="2016-04-16T23:38:59.167" LastActivityDate="2016-04-16T23:38:59.167" Title="How to use voltage divider between ESP8266 (3.3v) and IR proximity sensor (5V)?" Tags="|arduino-uno|esp8266|voltage-level|voltage-protection|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23168" PostTypeId="1" AcceptedAnswerId="23240" CreationDate="2016-04-15T19:56:03.080" Score="5" ViewCount="2043" Body="&lt;p&gt;Good afternoon, I'm trying to use a class to streamline the writing on the LCD. In this class I have an private attribute (it's a pointer, do not know how I call him) called  &lt;code&gt;LiquidCrystal_I2C* _lcd&lt;/code&gt;, I instantiate it in the constructor, so far so good, but when I call the &lt;code&gt;_lcd-&amp;gt; begin (20, 4)&lt;/code&gt; the code below is not executed, but no error is displayed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Display.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Display{&#xA;    public:&#xA;        Display();&#xA;        ...&#xA;    private:&#xA;        LiquidCrystal_I2C* _lcd;&#xA;        ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Display.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;Display::Display() {&#xA;    _lcd = new LiquidCrystal_I2C(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);&#xA;    _lcd-&amp;gt;begin (20, 4);&#xA;}&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Program.ino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Display.h&quot;&#xA;&#xA;Display lcd;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;test&quot;);&#xA;    delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just I noticed the error when I saw that &lt;code&gt;Serial.println (&quot;test&quot;);&lt;/code&gt; was not running. If I comment the &lt;code&gt;_lcd-&amp;gt;begin (20, 4);&lt;/code&gt; everything works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested writing everything in Program.ino and worked, has nothing to do with connections or something, just do not apply the concept of composition with this class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help me? And sorry for the English, i'm from Brazil. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="20219" LastEditorUserId="20219" LastEditDate="2016-04-15T20:16:38.700" LastActivityDate="2016-04-17T21:16:58.150" Title="Library LiquidCrystal_I2C don't work in other class (Composition)" Tags="|lcd|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23169" PostTypeId="1" CreationDate="2016-04-15T20:32:25.157" Score="0" ViewCount="87" Body="&lt;p&gt;When installing the IDE there are many &quot;Unable to open *.DLL&quot;, errors. I check &quot;ignore errors&quot; and the IDE installed. Now when selecting the correct port and  board the blink sketch is uploaded and several ATK 500 errors result. I have uninstalled and reinstalled the IDE several time, with repeated results.&lt;/p&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="10794" LastEditDate="2016-10-13T05:01:30.620" LastActivityDate="2016-10-13T05:01:30.620" Title="Arduino IDE installation Problems" Tags="|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23170" PostTypeId="2" ParentId="23169" CreationDate="2016-04-15T20:57:54.413" Score="1" Body="&lt;p&gt;You should check to make sure that your Java installation is up to date. It would also be best to make sure that you're bit types between the Java environment and the Arduino IDE are the same(32bit with 32bit, 64bit with 64bit). If this does not work, you should post your actual errors so we can help more :)&lt;/p&gt;&#xA;" OwnerUserId="19937" LastActivityDate="2016-04-15T20:57:54.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23171" PostTypeId="2" ParentId="23095" CreationDate="2016-04-15T21:48:16.630" Score="3" Body="&lt;p&gt;&lt;strong&gt;My problem with crashing is fixed! :)&lt;/strong&gt; I will share here what was wrong - maybe someone will have similar problem in the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But first...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have marked Edgar Bonet's answer because he answered most of the difficult questions that were bothering me and for pointing me out that reading a 16-bit variable on 8-bit processor is &lt;strong&gt;not atomic&lt;/strong&gt; (it was the most significant clue) and for helping me to understand that &lt;code&gt;noInterrupts()&lt;/code&gt; is the safe and only way to synchronize with the interrupt method in my case. Thanks Edgar! But credits also go to Majenko because I wouldn't have guessed it without him. He pushed me into the right direction in our chat discussion - that I have to secure &lt;strong&gt;all&lt;/strong&gt; the methods accessing &lt;code&gt;readpos&lt;/code&gt; and &lt;code&gt;writepos&lt;/code&gt;. Thanks Majenko. I agree with him that my Buffer code is ugly and it's not a good way to implement a circular buffer, but it was still logically OK - it just needed one more thing...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You probably know it already. The key is the non-atomic &lt;strong&gt;reading&lt;/strong&gt; of &lt;code&gt;readpos&lt;/code&gt; and &lt;code&gt;writepos&lt;/code&gt;. For example: the code from &lt;code&gt;loop()&lt;/code&gt; starts to read &lt;code&gt;readpos&lt;/code&gt;, reads the first byte of it, then the interrupt happens, &lt;code&gt;readpos&lt;/code&gt; changes there and the &lt;code&gt;loop()&lt;/code&gt; continues reading the other (changed) half, which is then glued with the old (out of date) half - so - a random value. Or another one: the loop writes first byte of &lt;code&gt;writepos&lt;/code&gt; (as it fills the buffer) and then interrupt fires and reads the first (changed) byte with the old (out of date) second byte. So the solution is to just wrap all access to those variables with &lt;code&gt;noInterrupts()&lt;/code&gt; - and the whole code works perfect! :) Thank you guys! Not only for helping me to fix it, but for helping me to understand it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how it looks like now (non-crashing version):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Buffer&#xA;{&#xA;  protected:&#xA;    byte *buf;&#xA;    const int len;&#xA;    int readpos, writepos;&#xA;    bool wasFull, wasEmpty;&#xA;    long ratioSum, ratioCount;&#xA;&#xA;  public:&#xA;    Buffer(const int length)&#xA;      : len(length)&#xA;    {&#xA;      buf = new byte[len];&#xA;      readpos = writepos = 0;&#xA;    }&#xA;&#xA;    bool isFull()&#xA;    {&#xA;      noInterrupts();&#xA;      bool full = writepos - readpos &amp;gt;= len;&#xA;      wasFull &amp;amp;= full;&#xA;      interrupts();&#xA;      return full;&#xA;    }&#xA;&#xA;    bool isEmpty()&#xA;    {&#xA;      noInterrupts();&#xA;      bool empty = readpos &amp;gt;= writepos;&#xA;      wasEmpty &amp;amp;= empty;&#xA;      interrupts();&#xA;      return empty;&#xA;    }&#xA;&#xA;    void write(byte b)&#xA;    {&#xA;      if (isFull()) return;//{ if (!wasFull) { wasFull = true; Serial.println(&quot;Error: Buffer overflow!&quot;); } return; }&#xA;      int pos = (writepos++) % len;&#xA;      buf[pos] = b;&#xA;      if (readpos &amp;gt;= len &amp;amp;&amp;amp; writepos &amp;gt;= len) { readpos -= len; writepos -= len; }&#xA;    }&#xA;&#xA;    byte read()&#xA;    {&#xA;      if (isEmpty()) return 0;// { if (!wasEmpty) { wasEmpty = true; Serial.println(&quot;Error: Buffer underflow!&quot;); } return 0; }&#xA;      int pos = (readpos++) % len;&#xA;      //if (readpos &amp;gt;= len &amp;amp;&amp;amp; writepos &amp;gt;= len) { readpos -= len; writepos -= len; }&#xA;      return buf[pos];&#xA;    }&#xA;&#xA;    int available()&#xA;    {&#xA;      noInterrupts();&#xA;      int result = writepos - readpos;&#xA;      interrupts();&#xA;      return result;&#xA;    }&#xA;&#xA;    int free()&#xA;    {&#xA;      noInterrupts();&#xA;      int result = len - available();&#xA;      interrupts();&#xA;      return result;&#xA;    }&#xA;&#xA;    void MeasureRatio()&#xA;    {&#xA;      ratioSum += available();&#xA;      ratioCount++;&#xA;    }&#xA;&#xA;    int getRatio()&#xA;    {&#xA;      int ratio;&#xA;      if (ratioCount &amp;gt; 0) &#xA;        ratio = 100 * ((float)(ratioSum / ratioCount) / (float)len);&#xA;      else&#xA;        ratio = 100 * ((float)available() / (float)len);&#xA;      ratioSum = 0;&#xA;      ratioCount = 0;&#xA;      return ratio;&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-04-15T21:48:16.630" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23172" PostTypeId="1" AcceptedAnswerId="23173" CreationDate="2016-04-15T21:55:36.713" Score="0" ViewCount="118" Body="&lt;p&gt;for the purpose of learning, I'm trying to have a kind of digital/binary input where I'm using 3 buttons but only 2 input pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;01 = Button 1&#xA;10 = Button 2&#xA;11 = Button 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My &lt;strong&gt;first attempt&lt;/strong&gt; was like this:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Z9bpj.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Z9bpj.png&quot; alt=&quot;first attempt&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;I left the resistors out right now. The problem here is of course, that it doesn't matter what button I press, both LEDs are lighting up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used 2 Diodes in my &lt;strong&gt;second attempt&lt;/strong&gt;:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Eu42f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Eu42f.png&quot; alt=&quot;second attempt&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;This time, S1 and S2 work as expected, but S3 brings only one LED up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I was wondering how I can wire things up correctly, using as little components as possible and having in mind, that I'm going to use an Arduino instead of the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for any help!&lt;/p&gt;&#xA;" OwnerUserId="20169" LastEditorUserId="20169" LastEditDate="2016-04-15T22:00:41.863" LastActivityDate="2016-04-15T22:29:35.157" Title="Having 3 buttons with only 2 input pins" Tags="|digital-in|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23173" PostTypeId="2" ParentId="23172" CreationDate="2016-04-15T22:29:35.157" Score="2" Body="&lt;p&gt;The logic of your second attempt is perfectly correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you put resistors in series with the LEDs you may get more joy out of it. Having two LEDs in parallel without resistors often results in one LED lighting and the other not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eNI7M.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eNI7M.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-15T22:29:35.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23174" PostTypeId="1" CreationDate="2016-04-15T22:47:29.043" Score="3" ViewCount="12509" Body="&lt;p&gt;I'm trying to get a fade to happen when an LED turns on/off during the color wipe rather than just abruptly turning on/off. I'm not quite sure how to do this though.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 3, NEO_RGBW + NEO_KHZ800);&#xA;void setup() {&#xA;  strip.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  colorWipe(strip.Color(255, 255, 255), 150); // Red&#xA; colorWipe(strip.Color(0, 0, 0), 150); // Red&#xA; delay(5000);&#xA;}&#xA;&#xA;void colorWipe(uint32_t color, uint8_t wait) {&#xA;  for(uint16_t i=0; i&amp;lt;strip.numPixels(); i++) {&#xA;      strip.setPixelColor(i, color);&#xA;      strip.show();&#xA;      delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18898" LastActivityDate="2018-10-31T15:46:56.503" Title="How to get neopixel to fade colorwipe?" Tags="|led|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23176" PostTypeId="1" AcceptedAnswerId="23178" CreationDate="2016-04-15T23:38:57.683" Score="0" ViewCount="136" Body="&lt;p&gt;I am totally beginner in Arduino, and i want to ask some questions : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    TCCR1B = (TCCR1B &amp;amp; ~(0x07&amp;lt;&amp;lt;CS10)) | (2&amp;lt;&amp;lt;CS10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does the previous line mean? with good explaination please . &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    TCCR1A &amp;amp;= ~(3&amp;lt;&amp;lt;COM1A0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;for the previous line , is there difference if i wrote '1' instead of '3' ? why ? &lt;/p&gt;&#xA;" OwnerUserId="20222" LastActivityDate="2016-04-16T02:31:50.297" Title="Dealing with TCCRx" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23177" PostTypeId="1" AcceptedAnswerId="23181" CreationDate="2016-04-16T00:28:37.750" Score="2" ViewCount="1348" Body="&lt;p&gt;I'm working with an SDS011 particular sensor through its serial interface. The spec sheet (&lt;a href=&quot;http://inovafitness.com/upload/file/20150311/14261262164716.pdf&quot; rel=&quot;nofollow&quot;&gt;http://inovafitness.com/upload/file/20150311/14261262164716.pdf&lt;/a&gt;) indicates that the second to last byte of a serial packet is a checksum equal to sum of all the data bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using pyserial to read and interpret the serial data. Here's a snippet of the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;&#xA;def read_sensor(port):&#xA;    while True:&#xA;        header = port.read(2)&#xA;        if header == b'\xAA\xC0':&#xA;            data = port.read(6)&#xA;            checksum = port.read()&#xA;            tail = port.read()&#xA;            if tail == b'\xAB':&#xA;                return header + data + checksum + tail&#xA;&#xA;port = serial.Serial(port=MY_PORT)&#xA;packet = read_sensor(port)&#xA;data_sum = sum(packet[2:8])&#xA;checksum = packet[8]&#xA;&#xA;if data_sum == checksum:&#xA;  print('Ok')&#xA;else:&#xA;   print('Error')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, I haven't got a single packet whose checksum hasn't been an error. Is there anything I could be potentially doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="18992" LastEditorUserId="18992" LastEditDate="2016-04-16T03:31:57.030" LastActivityDate="2016-04-16T03:31:57.030" Title="SDS011 Dust Sensor Checksum Error" Tags="|serial|sensors|python|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23178" PostTypeId="2" ParentId="23176" CreationDate="2016-04-16T01:00:11.070" Score="2" Body="&lt;p&gt;On the first line, you clear some bits, then set some bits in the same “region” of the byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From inside out, get 7 (which is 3 bits of ones: 00000111), shift it upwards (the &amp;lt;&amp;lt; operation) by CS10 amount (we don’t know how much, but the compiler does), complement all that (the tilde ~ character) and bitwise ‘and’ it with the value of the TCCR1A register (the &amp;amp; operation). Next, take a 2 (binary 00000010), shift it up by CS10 bits again (&amp;lt;&amp;lt; CS10), and bitwise ‘or’ that bit pattern with the earlier result (the | operator). Finally, assign all that to TCCR1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the second line, yes, changing 3 to 1 will certainly change what happens to TCCR1A. It makes a different bit pattern, and I'm sure you can reason it out after reading the previous explanation.&lt;/p&gt;&#xA;" OwnerUserId="20223" LastEditorUserId="3917" LastEditDate="2016-04-16T02:31:50.297" LastActivityDate="2016-04-16T02:31:50.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23179" PostTypeId="2" ParentId="23174" CreationDate="2016-04-16T01:26:05.763" Score="3" Body="&lt;p&gt;You could change the intensity of each colour in steps till you get to your target colour. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void colorFade(uint8_t r, uint8_t g, uint8_t b, uint8_t wait) {&#xA;  for(uint16_t i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;      uint8_t curr_r, curr_g, curr_b;&#xA;      uint32_t curr_col = strip.getPixelColor(i); // get the current colour&#xA;      curr_b = curr_col &amp;amp; 0xFF; curr_g = (curr_col &amp;gt;&amp;gt; 8) &amp;amp; 0xFF; curr_r = (curr_col &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;  // separate into RGB components&#xA;&#xA;      while ((curr_r != r) || (curr_g != g) || (curr_b != b)){  // while the curr color is not yet the target color&#xA;        if (curr_r &amp;lt; r) curr_r++; else if (curr_r &amp;gt; r) curr_r--;  // increment or decrement the old color values&#xA;        if (curr_g &amp;lt; g) curr_g++; else if (curr_g &amp;gt; g) curr_g--;&#xA;        if (curr_b &amp;lt; b) curr_b++; else if (curr_b &amp;gt; b) curr_b--;&#xA;        strip.setPixelColor(i, curr_r, curr_g, curr_b);  // set the color&#xA;        strip.show();&#xA;        // delay(wait);  // add a delay if its too fast&#xA;      }&#xA;      delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To use it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  colorFade(255, 0, 0, 150); // fade into red&#xA;  colorFade(255, 255, 255, 150); // and then into white&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is untested, so I dont know if it will be too fast or too slow. You'll have to tweak it to your needs.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="43113" LastEditDate="2018-02-23T09:36:41.190" LastActivityDate="2018-02-23T09:36:41.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23180" PostTypeId="1" CreationDate="2016-04-16T01:28:26.777" Score="1" ViewCount="1144" Body="&lt;p&gt;So I've got a FlySky TH9X and I'm trying to read some pulses using an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just starting out so I want to get the hang of using the pulseIn function before moving onto interrupts. My problem is that, when I wire everything up, I don't get sensible values. Furthermore, they don't change even though I move around the sticks on the actual remote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to start off simple by wiring just the channel 1 of the receiver to pin 3 of the Uno. Then I used this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ch1;&#xA;&#xA;void setup() {&#xA;  pinMode(3, INPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  ch1 = pulseIn(3, HIGH, 25000);&#xA;  Serial.print(&quot;Channel 1: &quot;);&#xA;  Serial.println(ch1);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serial monitor then spits out numbers ranging from 0 up to 10000+ in a very erratic and apparently not periodic nature. I'll copy a few lines here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Channel 1: 9989&#xA;Channel 1: 10063&#xA;Channel 1: 10068&#xA;Channel 1: 274&#xA;Channel 1: 0&#xA;Channel 1: 10085&#xA;Channel 1: 10039&#xA;Channel 1: 10336&#xA;Channel 1: 9629&#xA;Channel 1: 9959&#xA;Channel 1: 10064&#xA;Channel 1: 10088&#xA;Channel 1: 378&#xA;Channel 1: 0&#xA;Channel 1: 10044&#xA;Channel 1: 10059&#xA;Channel 1: 10424&#xA;Channel 1: 9632&#xA;Channel 1: 9867&#xA;Channel 1: 10069&#xA;Channel 1: 10067&#xA;Channel 1: 10473&#xA;Channel 1: 10037&#xA;Channel 1: 10063&#xA;Channel 1: 10063&#xA;Channel 1: 10253&#xA;Channel 1: 9677&#xA;Channel 1: 10013&#xA;Channel 1: 10064&#xA;Channel 1: 10062&#xA;Channel 1: 13&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see: not only are the higher-end values a whole order of magnitude too big (i thought pulses are normally between 1000 - 2000us?), but the actual range that these numbers span is far, far too wide for me to do anything with. Also, the sticks on my remote seem to have no influence on the numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me? thank you :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hassan&lt;/p&gt;&#xA;" OwnerUserId="19611" LastActivityDate="2018-10-26T13:29:55.060" Title="FlySky TH9X with Arduino: cant get pulseIn() function to return sensible values for any channel" Tags="|arduino-uno|serial|sensors|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23181" PostTypeId="2" ParentId="23177" CreationDate="2016-04-16T01:47:56.180" Score="1" Body="&lt;p&gt;Generally, a checksum byte is computed using 8-bit arithmetic, with overflow ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Python sum function uses arithmetic of indefinite precision (eg, 32- or 64-bit words for small values, with additional words for larger numbers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try comparing &lt;code&gt;checksum&lt;/code&gt; to &lt;code&gt;data_sum % 256&lt;/code&gt;.  If that doesn't fix the problem, print out some of the data packets and checksum values so that you can use a calculator to test different combinations.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-16T01:47:56.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23182" PostTypeId="2" ParentId="23177" CreationDate="2016-04-16T01:57:36.353" Score="0" Body="&lt;p&gt;I assume &lt;code&gt;MY_PORT&lt;/code&gt; stands for &lt;code&gt;COMxx&lt;/code&gt;. Since you set no timeout, it means &lt;code&gt;port.read()&lt;/code&gt; will block till it gets the number of bytes requested. I suggest you add a &lt;code&gt;print()&lt;/code&gt; to display the bytes returned, if any. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the sum, use &lt;code&gt;data_sum = sum(packet[2:8]) &amp;amp; 0xff&lt;/code&gt; to ensure you only get a byte. Also add &lt;code&gt;port.reset_input_buffer()&lt;/code&gt; right before you call &lt;code&gt;read_sensor()&lt;/code&gt;, to flush the input buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would also be a good idea to take at least 3 consecutive readings from the sensor in case of any errors in the first reading right after opening the port. Dont forget to add a &lt;code&gt;port.close()&lt;/code&gt; at the end of your code.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-16T01:57:36.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23183" PostTypeId="1" AcceptedAnswerId="23188" CreationDate="2016-04-16T02:23:01.400" Score="3" ViewCount="648" Body="&lt;p&gt;If I compile a sketch then upload using &lt;code&gt;ICSP&lt;/code&gt; does it overwrite the bootloader?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino program and &lt;code&gt;Arduino Uno&lt;/code&gt; as &lt;code&gt;ICSP&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2019-06-05T10:37:18.133" Title="Does upload using `ICSP`overwrite the bootloader?" Tags="|icsp|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23184" PostTypeId="2" ParentId="11734" CreationDate="2016-04-16T03:23:50.627" Score="0" Body="&lt;p&gt;I am fairly new to Arduino but have had a basic experience with python on RPi (Model 2). I am trying to connect ultrasonic sensors (for distance measuring) on Arduino  and then send (RF transmission) the value to Raspberry Pi. I am not able to figure out how to write a code for receiving the transmitted code. I have to receive the code, decode it and then update it in my SQLITE database (on the same RPi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have already tried RFSniffer but I am unable to receive value other than &quot;INT&quot;. RPi shows nothing if I send any &quot;CHAR&quot; or &quot;STRING&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please do suggest me how should I proceed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pradeep Verma&lt;/p&gt;&#xA;" OwnerUserId="20226" LastActivityDate="2016-04-16T03:23:50.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23185" PostTypeId="2" ParentId="23180" CreationDate="2016-04-16T03:54:07.867" Score="1" Body="&lt;p&gt;I would not recommend using &lt;code&gt;pulseIn&lt;/code&gt; for reading values from the receiver.  &lt;code&gt;pulseIn&lt;/code&gt; blocks the program until a signal is received, which is almost always undesirable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative approach would be to use CHANGE interrupts.  You get an interrupt when the signal goes high and low.  You take note of the time that each change occurs with &lt;code&gt;millis&lt;/code&gt; and compare the times to get the duration of the signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an example - you can add more channels if you'd like.  Note, this is using the &lt;a href=&quot;https://github.com/GreyGnome/EnableInterrupt&quot; rel=&quot;nofollow&quot;&gt;EnableInterrupt&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EnableInterrupt.h&amp;gt;&#xA;&#xA;#define SERIAL_PORT_SPEED 57600&#xA;#define RC_NUM_CHANNELS  2&#xA;&#xA;#define RC_CH1  0&#xA;#define RC_CH2  1&#xA;#define RC_CH1_INPUT  A0&#xA;#define RC_CH2_INPUT  A1   &#xA;&#xA;uint32_t last_update_time = 0;&#xA;uint16_t rc_values[RC_NUM_CHANNELS];&#xA;uint32_t rc_start[RC_NUM_CHANNELS];&#xA;volatile uint16_t rc_shared[RC_NUM_CHANNELS];&#xA;&#xA;void rc_read_values() {&#xA;  // read the values out of the shared, volatile array (which can change at any time)&#xA;  // and into an array that we only will only change when we call this function&#xA;&#xA;  noInterrupts();&#xA;  memcpy(rc_values, (const void *)rc_shared, sizeof(rc_shared));&#xA;  interrupts();&#xA;}&#xA;&#xA;void calc_input(uint8_t channel, uint8_t input_pin) {&#xA;  // This is the interrupt.  If the pin is high, we record the start&#xA;  // time of the pulse.  If the pin is low, we compare the start time&#xA;  // to the current time in order to get the length of the pulse.&#xA;&#xA;  if (digitalRead(input_pin) == HIGH) {&#xA;    rc_start[channel] = micros();&#xA;  } else {&#xA;    uint16_t rc_compare = (uint16_t)(micros() - rc_start[channel]);&#xA;    rc_shared[channel] = rc_compare;&#xA;  }&#xA;}&#xA;&#xA;void calc_ch1() { calc_input(RC_CH1, RC_CH1_INPUT); }&#xA;void calc_ch2() { calc_input(RC_CH2, RC_CH2_INPUT); }  &#xA;&#xA;void setup() {&#xA;  Serial.begin(SERIAL_PORT_SPEED);&#xA;&#xA;  pinMode(RC_CH1_INPUT, INPUT);&#xA;  pinMode(RC_CH2_INPUT, INPUT);&#xA;&#xA;  // set up CHANGE interrupts, so that we get notified when&#xA;  // each signal goes high or low.&#xA;  enableInterrupt(RC_CH1_INPUT, calc_ch1, CHANGE);&#xA;  enableInterrupt(RC_CH2_INPUT, calc_ch2, CHANGE);&#xA;}&#xA;&#xA;void loop() {&#xA;  rc_read_values();&#xA;&#xA;  Serial.print(&quot;CH1:&quot;); Serial.println(rc_values[RC_CH1]);&#xA;  Serial.print(&quot;CH2:&quot;); Serial.println(rc_values[RC_CH2]);&#xA;&#xA;  delay(200);  // just so serial log doesn't flood&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a more detailed explanation, take a look here:  &lt;a href=&quot;http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20227" LastActivityDate="2016-04-16T03:54:07.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23186" PostTypeId="2" ParentId="23164" CreationDate="2016-04-16T05:31:32.533" Score="0" Body="&lt;p&gt;&lt;code&gt;mime.multipart&lt;/code&gt; isnt used in your code at all so you shouldn't be getting that error. The correct import statements for Python 2.7 are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from email.mime.multipart import MIMEMultipart&#xA;from email.mime.base import MIMEBase&#xA;from email.mime.text import MIMEText&#xA;from email.utils import COMMASPACE, formatdate&#xA;from email.encoders import Encoders&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Study &lt;a href=&quot;https://docs.python.org/2/library/email-examples.html&quot; rel=&quot;nofollow&quot;&gt;these examples&lt;/a&gt; in the Python 2.7 documentation.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-16T05:31:32.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23188" PostTypeId="2" ParentId="23183" CreationDate="2016-04-16T05:49:30.303" Score="4" Body="&lt;p&gt;Yes.&lt;br&gt;&#xA;When you program using ISP you overwrite everything in the chips flash, even the bootloader. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has some pro's and con's:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pro: The program starts immediately, meaning it doesn't wait to check if there's any programming coming in before starting your sketch. &lt;/li&gt;&#xA;&lt;li&gt;Con: You need to use ISP to program your Arduino again or to upload the bootloader again.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Normally there is not really any reason for not having the bootloader present but if you are programming bare Atmel chips without a serial interface this way might be preferable.&lt;/p&gt;&#xA;" OwnerUserId="19322" LastEditorUserId="19409" LastEditDate="2019-06-05T10:37:18.133" LastActivityDate="2019-06-05T10:37:18.133" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23189" PostTypeId="1" AcceptedAnswerId="23195" CreationDate="2016-04-16T06:15:56.787" Score="2" ViewCount="1231" Body="&lt;p&gt;I have an Arduino Uno and I want to connect;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;RFID Reader (&lt;em&gt;RC522&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;WiFi Module (&lt;em&gt;ESP8266 ESP-01&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;li&gt;SD Card Module&lt;/li&gt;&#xA;&lt;li&gt;RTC (&lt;em&gt;Real Time Clock - DS1307&lt;/em&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Same time but pinouts are not enough. Is there a way to doing this with Uno or I have to buy an Arduino Mega ? I saw &quot;&lt;em&gt;Expansion Sensor Shield&lt;/em&gt;&quot;s but I do not know what is the logic of using this ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards &lt;/p&gt;&#xA;" OwnerUserId="19559" LastActivityDate="2017-08-11T01:24:52.730" Title="Arduino Uno Multiple Modules" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23192" PostTypeId="1" CreationDate="2016-04-16T11:51:59.753" Score="0" ViewCount="651" Body="&lt;p&gt;I am working on a wireless sensor network project, in which data is collected at a central node using nRF24 modules and the &lt;code&gt;RFNetwork.h&lt;/code&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to post that to the internet using the famous ESP8266 module, which works fine when used as standalone and programmed with Arduino IDE. But the problem is how to transfer my data from Arduino to the ESP8266 as it only has one serial that is already used to program it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried to use a nRF24 module that uses SPI with an ESP-12 as it has an SPI header, but it didn't work out and I can't figure out the problem. Is there a way to use ESP core libraries like &lt;code&gt;esp8266wifi.h&lt;/code&gt;, &lt;code&gt;wifiClient.h&lt;/code&gt;, &lt;code&gt;webserver.h&lt;/code&gt; etc., just like we can use the &lt;code&gt;esp8266.h&lt;/code&gt; library that uses AT commands to communicate to ESP from an Arduino like in a master-slave manner?&lt;/p&gt;&#xA;" OwnerUserId="20236" LastEditorUserId="4628" LastEditDate="2016-12-14T08:28:15.583" LastActivityDate="2017-10-11T05:36:22.770" Title="Using ESP8266 core for Arduino" Tags="|arduino-ide|esp8266|nrf24l01+|web-server|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23193" PostTypeId="2" ParentId="23192" CreationDate="2016-04-16T13:02:38.107" Score="1" Body="&lt;p&gt;Several solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Are your SPI components 5V or 3.3V parts? The ESP8266 is 3.3V only, and is NOT 5V-tolerant; you may have already fried it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In most cases that I've had problems with SPI with the ESP8266 (in particular, the Adafruit 8266-12E HUZZAH board), they went away when I drastically lowered the SPI speed to 8000000.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Once you've programmed the 8266, and assuming you don't use &lt;code&gt;Serial&lt;/code&gt; for debugging output, it's free to use to communicate with the world. Again, be careful about signal levels -- the 8266 is NOT 5V-tolerant, and most arduinos have 5V signals. So either use a 3.3V arduino-like part (my favorite is the Teensy 3.2 for larger projects, and the Adafruit Trinket for smaller ones), or use a level converter. If you need debugging output, you can still use &lt;code&gt;Serial1&lt;/code&gt; for output only (and don't forget to change its bit rate -- by default it's something crazy like 74380bps).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Run the 8266 as another SPI slave and have the Arduino write to it. Or come up with your own serial protocol! Again, careful about signal levels.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use a different version of the 8266 (or another wifi chip), one that's already meant to be used with the Arduino. Sparkfun and Adafruit have several, as do a lot of other vendors.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd still suggest that you try to work out the SPI problems and stick to the 8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, don't forget that neither serial nor SPI guarantees data integrity. Always use a CRC to make sure your data were transferred correctly, and have some provision for retransmissions if you can't afford to just ignore corrupted data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/ji&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-16T13:02:38.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23195" PostTypeId="2" ParentId="23189" CreationDate="2016-04-16T13:30:17.327" Score="4" Body="&lt;p&gt;Let's see which device uses which communication protocol:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;WiFi Module (ESP8266 ESP-01)&lt;/strong&gt; uses Serial communication.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;RTC (Real Time Clock - DS1307)&lt;/strong&gt; uses I²C communication.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;RFID Reader (RC522)&lt;/strong&gt; uses SPI communication.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;SD Card Module&lt;/strong&gt; also uses SPI communication.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now, the Arduino UNO supports &lt;strong&gt;One I²C&lt;/strong&gt;, &lt;strong&gt;One SPI&lt;/strong&gt; and &lt;strong&gt;One Serial&lt;/strong&gt; (by default) communication port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you can easily connect your &lt;strong&gt;Wifi&lt;/strong&gt; and &lt;strong&gt;RTC&lt;/strong&gt; modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, actual problem is: &quot;&lt;a href=&quot;https://arduino.stackexchange.com/questions/8425/how-to-access-multiple-spi-interfaces-on-arduino&quot;&gt;How to access multiple SPI interfaces on Arduino&lt;/a&gt;&quot; (and that is a solved problem).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps and you don't have to buy an &lt;strong&gt;Arduino MEGA&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="3134" LastEditDate="2017-08-11T01:24:52.730" LastActivityDate="2017-08-11T01:24:52.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23196" PostTypeId="2" ParentId="23163" CreationDate="2016-04-16T13:48:12.457" Score="1" Body="&lt;p&gt;&lt;strong&gt;Yes, you can easily do that&lt;/strong&gt;. This finger Print sensor works over Serial communication. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have multiple Serial devices connected to your Arduino UNO using &lt;a href=&quot;https://www.arduino.cc/en/Reference/softwareSerial&quot; rel=&quot;nofollow&quot;&gt;SoftwareSerial&lt;/a&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you have to do is to create multiple instances of Adafruit_Fingerprint initialized with different SoftwareSerial objects. i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// pin #2 is IN from sensor1 (GREEN wire)&#xA;// pin #3 is OUT from arduino to sensor1  (WHITE wire)&#xA;// pin #8 is IN from sensor2 (GREEN wire)&#xA;// pin #9 is OUT from arduino to sensor2  (WHITE wire)&#xA;SoftwareSerial mySerial1(2, 3);&#xA;Adafruit_Fingerprint finger1 = Adafruit_Fingerprint(&amp;amp;mySerial1);&#xA;SoftwareSerial mySerial2(8, 9);&#xA;Adafruit_Fingerprint finger2 = Adafruit_Fingerprint(&amp;amp;mySerial2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you can use &lt;strong&gt;finger1&lt;/strong&gt; and &lt;strong&gt;finger2&lt;/strong&gt; for your finger print operations. (previously referenced as only &lt;strong&gt;finger&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to understand Serial Communication with multiple serial devices, have a look at this &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/TwoPortReceive&quot; rel=&quot;nofollow&quot;&gt;Arduino.cc Offical tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-16T13:48:12.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23197" PostTypeId="2" ParentId="23153" CreationDate="2016-04-16T13:53:56.753" Score="1" Body="&lt;p&gt;I think you are making a mistake initializing &lt;strong&gt;cs_5_7&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);&#xA;CapacitiveSensor   cs_5_7 = CapacitiveSensor(4,6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are using same pin 4 for both Capacitive sensors. Try using different pins. I am quite sure that, this would help.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-16T13:53:56.753" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23198" PostTypeId="1" CreationDate="2016-04-16T14:06:40.777" Score="1" ViewCount="273" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NLZ7I.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NLZ7I.png&quot; alt=&quot;About 30 minutes of data&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt; &#xA;&#xA;int DS18S20_Pin = 3; //DS18S20 Signal pin on digital 3&#xA;unsigned long startTime = 0;&#xA;#define MEASURE_PERIOD 250&#xA;//Temperature chip i/o&#xA;OneWire ds(DS18S20_Pin);  // on digital pin 3&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  if((millis() - startTime) &amp;gt;= MEASURE_PERIOD)&#xA;    {&#xA;        startTime += MEASURE_PERIOD;&#xA;        float temperature = getTemp();&#xA;        Serial.println(temperature);&#xA;    } //just here to slow down the output so it is easier to read&#xA;&#xA;}&#xA;&#xA;&#xA;float getTemp(){&#xA;  //returns the temperature from one DS18S20 in DEG Celsius&#xA;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;      //no more sensors on chain, reset search&#xA;      ds.reset_search();&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( OneWire::crc8( addr, 7) != addr[7]) {&#xA;      Serial.println(&quot;CRC is not valid!&quot;);&#xA;      return -1000;&#xA;  }&#xA;&#xA;  if ( addr[0] != 0x10 &amp;amp;&amp;amp; addr[0] != 0x28) {&#xA;      Serial.print(&quot;Device is not recognized&quot;);&#xA;      return -1000;&#xA;  }&#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44,1); // start conversion, with parasite power on at the end&#xA;&#xA;  byte present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE); // Read Scratchpad&#xA;&#xA;&#xA;  for (int i = 0; i &amp;lt; 9; i++) { // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;  }&#xA;&#xA;  ds.reset_search();&#xA;&#xA;  //byte MSB = data[1];&#xA; // byte LSB = data[0];&#xA;&#xA;  float tempRead = ((((int)data[1]) &amp;lt;&amp;lt; 8) | data[0]); //using two's compliment&#xA;  float TemperatureSum = tempRead / 16;&#xA;&#xA;  return TemperatureSum;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15699" LastActivityDate="2016-10-15T02:18:16.317" Title="How is it possible that my skin temperature is so constant?" Tags="|arduino-uno|temperature-sensor|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23199" PostTypeId="2" ParentId="23198" CreationDate="2016-04-16T14:24:05.867" Score="0" Body="&lt;p&gt;Try using &lt;a href=&quot;https://github.com/milesburton/Arduino-Temperature-Control-Library&quot; rel=&quot;nofollow&quot;&gt;Dallas Temperature Control Library for DS18S20&lt;/a&gt;. (&lt;a href=&quot;https://github.com/milesburton/Arduino-Temperature-Control-Library/archive/master.zip&quot; rel=&quot;nofollow&quot;&gt;Click Here&lt;/a&gt;, Download Library). Its simple and easy to use, and it comes with examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.milesburton.com/?title=Dallas_Temperature_Control_Library&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-16T14:24:05.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23200" PostTypeId="2" ParentId="23167" CreationDate="2016-04-16T14:43:14.810" Score="0" Body="&lt;p&gt;My experience with esp8266 tells me that if you power esp8266 with a 3.3V supply and you provide 5V/0V signal to its pins (either Tx/Rx or pin0,1) nothing's gonna happen. It will work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on this experience, i would like to suggest you to &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;power your esp8266 with 3.3V pin of your TTL converter&lt;/li&gt;&#xA;&lt;li&gt;power your IR sensor using 5V output pin of your TTL converter&lt;/li&gt;&#xA;&lt;li&gt;connect signal pin of IR sensor to your esp8266 digital pin. (just&#xA;in case esp8266 heats up, disconnect circuit and try using voltage&#xA;divided only for this particular connection.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If using those external power supplies don't forget to common GND (or -ive terminal) of those power supplies. &lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-16T14:43:14.810" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23201" PostTypeId="2" ParentId="20322" CreationDate="2016-04-16T16:05:32.843" Score="0" Body="&lt;p&gt;Try to pull the I2C sensor at the back of the LCD board, you can see that it is shorted to the SMD mounted on the back,  just pull it a little so that it won't touch and short the conductors. This has happened to me, try it if this works.&lt;/p&gt;&#xA;" OwnerUserId="20239" LastActivityDate="2016-04-16T16:05:32.843" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23202" PostTypeId="1" CreationDate="2016-04-16T16:20:13.973" Score="3" ViewCount="260" Body="&lt;p&gt;I am new to Arduino and have a small query. I am building a simple system that switches on a motor and switches it off after some time and repeats this in a loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino that I am using is a “&lt;a href=&quot;http://www.ebay.in/itm/DIY-UNO-Play-Breadboard-ATMEGA328P-with-FT232-Breakout-Board-/301262281895?hash=item4624a19ca7:g:ox0AAOSwnDZT2Lox%27&quot; rel=&quot;nofollow noreferrer&quot;&gt;DIY UNO Play Breadboard -ATMEGA328P with FT232 Breakout Board&lt;/a&gt;” (Rs. 825, or $12.38USD, from Mangalore).  The Arduino board is similar in size to a Nano but without USB.  The FT232 board has a USB B port on one end and serial pins on the other.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hCq4Z.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hCq4Z.jpg&quot; alt=&quot;picture of boards and cable&quot;&gt;&lt;/a&gt;&#xA;My query is whether I should connect the positive end of battery supply to the motor and then connect in series using a motor controller circuit to port 7 and connect the negative terminal to the gnd port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do I need a separate voltage source for my Arduino, because this Arduino has no built in USB ports. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code to switch on and switch off the motor: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;int motorPin = 7;&#xA;   pinmode(motorPin,OUTPUT);&#xA;   digitalWrite(motorPin,HIGH); //turn motor on&#xA;   delay(500); //wait&#xA;   digitalWrite(motorPin,LOW); //turn motor off&#xA;   delay(500); //wait&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="20241" LastEditorUserId="20241" LastEditDate="2016-04-17T00:46:26.220" LastActivityDate="2016-04-17T17:40:02.177" Title="Connecting a motor to Arduino UNO Play breadboard" Tags="|arduino-uno|motor|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23203" PostTypeId="1" CreationDate="2016-04-16T16:21:27.793" Score="2" ViewCount="120" Body="&lt;p&gt;I'm using Matlab to communicate with a custom AD7746 board through an Arduino UNO. The data sheet mentions that &#xA;&lt;strong&gt;&lt;em&gt;&quot;In continuous conversion mode, the address pointers’ autoincrementer should be used for reading a conversion result. &#xA;That means, the three data bytes should be read using one &#xA;multibyte read transaction rather than three separate single byte &#xA;transactions&quot;&lt;/em&gt;&lt;/strong&gt;&#xA;I'm not sure how I can go about implementing this using MATLAB's Arduino support package.&#xA;Would anyone have an Idea about this?&lt;/p&gt;&#xA;" OwnerUserId="20240" LastActivityDate="2016-04-16T16:21:27.793" Title="Matlab Arduino Multi Byte Read" Tags="|arduino-uno|matlab|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23204" PostTypeId="1" AcceptedAnswerId="23210" CreationDate="2016-04-16T16:19:53.290" Score="0" ViewCount="232" Body="&lt;p&gt;I am currently making a robot with Arduino Uno, D6T omron thermal sensor (i2c sensor) and some other sensors. My thermal sensor will always update the data in array form. It will display 4 data arrays every 1 second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wish to have my Arduino send out a string &quot;found&quot; over serial when it meet a condition, and thermal sensor will stop updating my data. Thermal sensor and Arduino will just have to wait until the user sends a selection, jump to the selected function, and thermal sensor will start updating data again after that. I am new to coding, any suggestion on how to make my arduino and sensor to wait? Thank you guys! =) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code. (Arduino Sketch):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;WireExt.h&amp;gt;&#xA;&#xA;#define D6T_addr 0x0A&#xA;#define D6T_cmd 0x4C&#xA;&#xA;int rbuf[35];&#xA;float tdata[16];&#xA;float t_PTAT;&#xA;&#xA;const int S_DATATRANSFER = 0;&#xA;const int S_WAIT = 1;&#xA;const int S_STOPTRANSFER = 2;&#xA;const int S_CONFIRMATION = 3;&#xA;const int S_ALLSTOP = 4;&#xA;&#xA;float left_sum, right_sum, center_sum;&#xA;&#xA;//-----------------------------------------------------------------------------&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.flush();&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;static int state = S_DATATRANSFER;&#xA;&#xA;&#xA;    switch(state)&#xA;    {&#xA;&#xA;    case S_DATATRANSFER:&#xA;        //Calculate temp&#xA;        //serialprint temp&#xA;        int i;&#xA;&#xA;        if (Serial.available() &amp;gt; 0) &#xA;        {     &#xA;                      char inByte = Serial.read();     &#xA;                      if (inByte == '1') &#xA;            {  //processing will send one byte to arduino if ready     &#xA;&#xA;                Wire.beginTransmission(D6T_addr);&#xA;                Wire.write(D6T_cmd);&#xA;                Wire.endTransmission();&#xA;&#xA;            if (WireExt.beginReception(D6T_addr) &amp;gt;= 0) &#xA;                {&#xA;                    i = 0;&#xA;                    for (i = 0; i &amp;lt; 35; i++) &#xA;                    {&#xA;                        rbuf[i] = WireExt.get_byte();&#xA;                    }&#xA;                    WireExt.endReception();&#xA;&#xA;                    t_PTAT = (rbuf[0]+(rbuf[1]&amp;lt;&amp;lt;8))*0.1;&#xA;                    for (i = 0; i &amp;lt; 16; i++) &#xA;                    {&#xA;                        tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]&amp;lt;&amp;lt;8))*0.1;&#xA;                    }&#xA;                }&#xA;&#xA;                right_sum= tdata[0]+ tdata[4] + tdata[8] + tdata[12];&#xA;                left_sum= tdata[3] + tdata[7] + tdata[11] + tdata[15];&#xA;                center_sum= tdata[5] + tdata[6] + tdata[9] + tdata[10];            &#xA;                output_csv();  &#xA;&#xA;               }&#xA;                      }&#xA;        state = S_WAIT;&#xA;        break;&#xA;&#xA;    case S_WAIT:&#xA;        if (center_sum &amp;gt; 35*4)&#xA;        {&#xA;        state = S_STOPTRANSFER;&#xA;        }&#xA;        else&#xA;        {&#xA;        state = S_DATATRANSFER;&#xA;        }&#xA;        break;&#xA;&#xA;    case S_STOPTRANSFER:&#xA;&#xA;        Serial.println(&quot;F&quot;);&#xA;                delay(300);&#xA;&#xA;        state = S_CONFIRMATION;&#xA;&#xA;        break;&#xA;&#xA;    case S_CONFIRMATION:&#xA;        while (Serial.available())&#xA;        {&#xA;         char val = Serial.read();&#xA;            if (val == '2')&#xA;            {&#xA;                state = S_ALLSTOP;&#xA;            }&#xA;            else if (val == '3')&#xA;            {&#xA;                state = S_DATATRANSFER; &#xA;                }  &#xA;                        else if (val == '1')&#xA;                        {&#xA;                                state = S_DATATRANSFER;&#xA;                        }&#xA;                }   &#xA;&#xA;        break;&#xA;&#xA;        case S_ALLSTOP:&#xA;&#xA;        break;&#xA;&#xA;&#xA;    }&#xA;}&#xA;&#xA;void output_csv() &#xA;{&#xA;  for (int i = 0; i &amp;lt; 16; i++) &#xA;  {&#xA;    Serial.print(tdata[i]);&#xA;    if (i &amp;lt; 15) &#xA;    {&#xA;      Serial.print(&quot;,&quot;);&#xA;    } &#xA;    else &#xA;    {&#xA;      Serial.println();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Attached below is my code in processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;import controlP5.*;&#xA;import javax.swing.JOptionPane.*;&#xA;import com.onlylemi.processing.android.capture.*;&#xA;ControlP5 cp5;&#xA;javax.swing.JOptionPane JOptionPane;&#xA;&#xA;AndroidCamera ac;&#xA;PImage img;&#xA;Textlabel myTextlabelA, myTextlabelB;&#xA;boolean canStart = true;&#xA;boolean canInput = false;&#xA;boolean Start = false;&#xA;boolean Start_camera = false;&#xA;String typedText = &quot;Comments: &quot;;&#xA;PFont font;&#xA;String command = &quot;&quot;;&#xA;String confirm;&#xA;String found;&#xA;&#xA;PImage carImage;&#xA;float[] tdata = new float[17]; &#xA;float tptat; // PTAT&#xA;String portName; &#xA;//int serialport = 0; &#xA;&#xA;String buf; &#xA;float colourGreen; //change green in relation to temperature &#xA;&#xA;int lbTemp = 25; //lowest relative temperature&#xA;int hbTemp = 35; //highest relative temperature &#xA;Serial myPort;  // Create object from Serial class&#xA;&#xA;&#xA;void setup() {&#xA;  size(1366,768);&#xA;  //background(#FFFFFF);&#xA;  background(ControlP5.BLACK);&#xA;  //println(Serial.list());&#xA;  //portName = Serial.list()[serialport];&#xA;  myPort = new Serial(this, &quot;COM15&quot;, 9600);&#xA;  myPort.clear();&#xA;  cp5 = new ControlP5(this);&#xA;  ac = new AndroidCamera(720, 480, 30);&#xA;  ac.start();&#xA;&#xA;  myTextlabelA = cp5.addTextlabel(&quot;label&quot;)&#xA;                    .setText(&quot;GUI of Alive Human Detection System.&quot;)&#xA;                    .setPosition(120,10)&#xA;                    .setColorValue(#FFFAF0)&#xA;                    .setFont(createFont(&quot;Georgia&quot;,20))&#xA;                    ;&#xA;&#xA;  cp5.addButton(&quot;Start&quot;)&#xA;     .setPosition(115, 670)&#xA;     .setSize(100,30)&#xA;     ;&#xA;&#xA;  cp5.addButton(&quot;Stop&quot;)&#xA;     .setPosition(375, 670)&#xA;     .setSize(100,30)&#xA;     ;&#xA;  cp5.addButton(&quot;Start Camera&quot;)&#xA;     .setPosition(799, 670)&#xA;     .setSize(100,30)&#xA;     ;&#xA;}&#xA;&#xA;public void Start(int theValue) {&#xA;  println(&quot;Initialising...&quot;);&#xA;  println(&quot;Connected.&quot;);&#xA;  //start displaying&#xA; // carImage = loadImage(&quot;.png&quot;);&#xA;  Start = !Start;&#xA;}&#xA;&#xA;public void Stop(int theValue) {&#xA;  println(&quot;Shuting Down...&quot;);&#xA;  //finish = loadImage(&quot;robot.png&quot;);&#xA;  //image(finish,30,64);&#xA;  myPort.write(0x02);&#xA;  Start = !Start;&#xA;  //strokeWeight(0);&#xA;}&#xA;&#xA;public void Start_camera(int theValue) {&#xA;  println(&quot;Initialising...&quot;);&#xA;  println(&quot;Connected.&quot;);&#xA;  //start displaying&#xA; // carImage = loadImage(&quot;.png&quot;);&#xA;  Start_camera = !Start_camera;&#xA;}&#xA;&#xA;void draw() &#xA;{&#xA;  //if (Start_camera){&#xA;  //img = ac.getCameraImage();&#xA;  //image(img, 610, 0);&#xA;  //}&#xA;  if (Start){&#xA;&#xA;    myPort.write('1'); &#xA;    delay(100);&#xA;    while (myPort.available() &amp;gt; 0) { &#xA;    delay(300);  &#xA;    buf = myPort.readStringUntil('\n');&#xA;    if (buf.equals(&quot;F&quot;)){&#xA;    int dialogResult = JOptionPane.showConfirmDialog (null, &quot;Human found? Please Confirm!!&quot;, &quot;Alert!&quot;, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);&#xA;    if(dialogResult == JOptionPane.YES_OPTION)&#xA;    {&#xA;    fill(255,0,0);&#xA;    rect(100,670,50,30);&#xA;    myPort.write('2');&#xA;    }&#xA;    else if(dialogResult == JOptionPane.NO_OPTION)&#xA;    {&#xA;    fill(0,255,0);&#xA;    rect(100,670,50,30);&#xA;    myPort.write('3');&#xA;    }&#xA;    }&#xA;    else{&#xA;    myPort.clear();&#xA;    tdata = float(split(buf, ','));  &#xA;    for (int i = 0; i &amp;lt;16; i++) { &#xA;    colourGreen = map(tdata[i],lbTemp,hbTemp,255,0);&#xA;    fill (255,colourGreen,0);&#xA;&#xA;      if (i == 0)&#xA;    { rect(450,64,150,150);}&#xA;      else if (i == 1)&#xA;    { rect(300,64,150,150);}&#xA;      else if (i == 2)&#xA;    { rect(150,64,150,150);}&#xA;      else if (i == 3)&#xA;    { rect(0,64,150,150);}&#xA;      else if (i == 4)&#xA;    { rect(450,214,150,150);}&#xA;      else if (i == 5)&#xA;    { rect(300,214,150,150);}&#xA;      else if (i == 6)&#xA;    { rect(150,214,150,150);}&#xA;      else if (i == 7)&#xA;    { rect(0,214,150,150);}&#xA;      else if (i == 8)&#xA;    { rect(450,364,150,150);}&#xA;      else if (i == 9)&#xA;    { rect(300,364,150,150);}&#xA;      else if (i == 10)&#xA;    { rect(150,364,150,150);}&#xA;      else if (i == 11)&#xA;    { rect(0,364,150,150);}&#xA;      else if (i == 12)&#xA;    { rect(450,514,150,150);}&#xA;      else if (i == 13)&#xA;    { rect(300,514,150,150);}&#xA;      else if (i == 14)&#xA;    { rect(150,514,150,150);}&#xA;      else if (i == 15)&#xA;    { rect(0,514,150,150); }&#xA;&#xA;    if (tdata[i]&amp;lt;5) {fill(255);} else {fill(0);}&#xA;      if (i ==0)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),525, 139);}&#xA;      else if (i == 1)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),375, 139);&#xA;      }&#xA;      else if (i == 2)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 139);&#xA;      }&#xA;      else if (i == 3)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]),75, 139); &#xA;      }&#xA;      else if (i == 4)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 289); &#xA;      }&#xA;      else if (i == 5)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 289);  &#xA;      }&#xA;      else if (i == 6)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 289);  &#xA;      }&#xA;      else if (i == 7)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 289); &#xA;      }&#xA;      else if (i == 8)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 439);&#xA;      }&#xA;      else if (i == 9)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 439);  &#xA;      }&#xA;      else if (i == 10)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 439);&#xA;      }&#xA;      else if (i == 11)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 439);&#xA;      }&#xA;      else if (i == 12)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 525, 592);  &#xA;      }&#xA;      else if (i == 13)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 375, 592); &#xA;      }&#xA;      else if (i == 14)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 225, 592);&#xA;      }&#xA;      else if (i == 15)&#xA;      {&#xA;      textAlign(CENTER, CENTER);&#xA;      textSize(20);&#xA;      text(str(tdata[i]), 75, 592);  &#xA;      }&#xA;    }&#xA;    delay(350);  &#xA;  }&#xA;    }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19475" OwnerDisplayName="lim lagoon" LastEditorUserId="19475" LastEditDate="2016-04-19T10:43:03.517" LastActivityDate="2016-04-19T10:43:03.517" Title="How to make Arduino to stop updating i2c data when meet a condition and wait until it receives another serial input from processing?" Tags="|serial|i2c|processing-lang|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23205" PostTypeId="1" CreationDate="2016-04-16T17:17:51.050" Score="0" ViewCount="527" Body="&lt;p&gt;How can I connect this little ship to my Arduino? I can find alot of tutorials how to do it so, but all I find is 8 pins, mine includes 10 pins, and from what I could of understand from searching me myself, that there is 2 pins of VCC and 2 GRN pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I would like to know how to connect this? Not necesserly Arduino, but can someone help me with the pins names at least so I can identify them.&#xA;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cpCxP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cpCxP.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20243" LastEditorUserId="19515" LastEditDate="2016-04-16T18:05:01.787" LastActivityDate="2020-02-03T14:50:37.343" Title="RF24L01+ VER01 with 10 pins" Tags="|arduino-uno|nrf24l01+|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23206" PostTypeId="2" ParentId="23205" CreationDate="2016-04-16T17:54:37.517" Score="1" Body="&lt;p&gt;There are some 10pin adapter boards floating around. See e.g. &#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/22914/nrf24l01-8pin-adapter-board-10pin-oops&quot;&gt;nrf24l01 (8pin) + adapter board (10pin) oops?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their pinout looks to be the following.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5epm9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5epm9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-16T17:54:37.517" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23207" PostTypeId="1" CreationDate="2016-04-16T18:31:10.287" Score="5" ViewCount="166" Body="&lt;p&gt;Is it practical to record speech with the &lt;a href=&quot;http://www.arduino.cc/en/Main/arduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Leonardo&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to record speech via a MEMS microphone and stream it over a serial connection to a Raspberry Pi for speech-to-text processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.richardfarrar.com/choosing-bit-rates-for-podcasts/&quot; rel=&quot;nofollow&quot;&gt;This article&lt;/a&gt; states that the typical bitrate for recording voice podcasts is 64 kbps. The Arduino's &lt;code&gt;analogRead()&lt;/code&gt; function has a maximum sample rate of typically 8,600 times/sec for a maximum bitrate of 8,600 samples/sec * 10 bits/sample = 86 kbps, so theoretically, it should be fast enough to record decent voice audio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, will the serial connection be fast enough to stream this much data? Theoretically, the Leonardo's serial connection can go up to 115,200 bps, but I've never reliably gotten it to go faster than 57,600 bps, which would mean the serial connection would a bottleneck that would prevent it from sending a continuous stream of 64 kbps, and therefore it would be impractical to record speech with the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I wrong? Has anyone had success with voice recording while streaming it over serial?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="4478" LastEditDate="2016-04-17T18:46:36.997" LastActivityDate="2016-04-18T11:01:20.573" Title="Practicality of recording speech" Tags="|serial|arduino-leonardo|analogread|audio|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23208" PostTypeId="1" CreationDate="2016-04-16T19:31:34.137" Score="-2" ViewCount="3076" Body="&lt;p&gt;When I wanted to test my Nrf24L01 I wanted to be sure of it working fine, so I used this code for an Arduino Uno: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &quot;printf.h&quot;&#xA;#define RF_CS 9&#xA;#define RF_CSN 7&#xA;RF24 radio(RF_CS, RF_CSN);&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  printf_begin();&#xA;  radio.begin();&#xA;  radio.printDetails();&#xA;}&#xA;void loop() {&#xA;  radio.printDetails();&#xA;  delay(5000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The thing is when I opened my Serial, I got this each 5 second: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;STATUS       = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1&#xA;RX_ADDR_P0-1     = 0x0000000000 0x0000000000&#xA;RX_ADDR_P2-5     = 0xff 0xff 0x00 0x00&#xA;TX_ADDR      = 0x0000000000&#xA;RX_PW_P0-6   = 0xff 0x00 0x00 0xff 0xff 0x00&#xA;EN_AA        = 0xff&#xA;EN_RXADDR    = 0xff&#xA;RF_CH        = 0xff&#xA;RF_SETUP     = 0xff&#xA;CONFIG       = 0xff&#xA;DYNPD/FEATURE    = 0xff 0x00&#xA;Data Rate    = 1MBPS&#xA;Model        = nRF24L01&#xA;CRC Length   = 16 bits&#xA;PA Power     = PA_MAX&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which apparently means that there must be something wrong with the connection, as far as I know .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;noting that i have this Nrf24L01 with 10 pins, so i tried to attach it just like the following picture shows : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5epm9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5epm9.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I tried to plug it in with the Arduino just like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/PHuWb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PHuWb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What was the mistake?&lt;/p&gt;&#xA;" OwnerUserId="20243" LastEditorUserId="19515" LastEditDate="2016-04-17T20:14:03.260" LastActivityDate="2016-10-15T10:21:13.477" Title="Nrf24L01 with Arduino" Tags="|arduino-uno|nrf24l01+|" AnswerCount="1" CommentCount="2" ClosedDate="2019-06-21T20:51:13.347" ContentLicense="CC BY-SA 3.0" />
  <row Id="23209" PostTypeId="1" CreationDate="2016-04-16T19:33:12.887" Score="0" ViewCount="2714" Body="&lt;p&gt;I build &lt;code&gt;.hex&lt;/code&gt; files for Arduino. How can I do this in Linux? I use the Linux distro  Mint 17.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need a program to make [&lt;code&gt;.hex&lt;/code&gt; files] (in Linux). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help me?&lt;/p&gt;&#xA;" OwnerUserId="20244" LastEditorUserId="6936" LastEditDate="2016-04-18T11:14:00.473" LastActivityDate="2016-04-18T11:14:00.473" Title="Compile `.hex` files on Linux" Tags="|linux|" AnswerCount="2" CommentCount="5" ClosedDate="2016-04-18T10:16:43.693" ContentLicense="CC BY-SA 3.0" />
  <row Id="23210" PostTypeId="2" ParentId="23204" CreationDate="2016-04-16T19:55:14.237" Score="2" Body="&lt;p&gt;Implement a state machine first in your code for each state:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Sending i2c data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Not sending i2c data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And identify the conditions necessary to switch states:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 to 2 when condition meet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2 to 1 when command received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then drop your code into the state machine's code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read about state machines &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://teachmetomake.com/wordpress/arduino-tutorial-state-machine&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-16T19:55:14.237" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23211" PostTypeId="2" ParentId="13299" CreationDate="2016-04-16T19:57:27.637" Score="0" Body="&lt;p&gt;I got this error on my Macintosh system and the problem was that I needed to choose the correct port on the USB. Somehow it had auto-connected to a Bluetooth port which was listed under &lt;strong&gt;Tools-&gt;Port&lt;/strong&gt; as &lt;code&gt;/dev/cu.Bluetooth-modem&lt;/code&gt; and was my daughter's cell phone. I chose a port labeled &lt;code&gt;/dev/cu/wchusbserialfd&lt;/code&gt;... and it worked fine.&lt;/p&gt;&#xA;" OwnerUserId="20246" LastEditorUserId="6936" LastEditDate="2016-04-17T04:08:01.890" LastActivityDate="2016-04-17T04:08:01.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23213" PostTypeId="2" ParentId="23209" CreationDate="2016-04-16T20:12:58.580" Score="2" Body="&lt;p&gt;You can download the Arduino IDE for Linux from &lt;a href=&quot;https://www.arduino.cc/en/Main/Software&quot; rel=&quot;nofollow noreferrer&quot;&gt;the Arduino site&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in &lt;a href=&quot;https://stackoverflow.com/questions/11607834/where-are-the-hex-files-compiled-by-arduino&quot;&gt;Where are the hex files compiled by Arduino?&lt;/a&gt;, in the Arduino program: go to &lt;strong&gt;Arduino -&gt; Preferences&lt;/strong&gt; and then select &lt;strong&gt;Show verbose output during -&gt; compilation&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Finally, when you are compiling, the program will show you lots of&#xA;  data. At the last lines, you will find the path to the .hex file&#xA;  (Every time the path changes!).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you want to upload this &lt;code&gt;.hex&lt;/code&gt; file to your &lt;strong&gt;ATmega328P&lt;/strong&gt; (the micro controller inside Arduino Uno), &lt;code&gt;avrdude&lt;/code&gt; can do that for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, are few useful links:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ladyada.net/learn/avr/setup-unix.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Setup Avrdude on Linux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ladyada.net/learn/avr/programming.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programming your chip&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ladyada.net/learn/avr/programmers.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Choosing a Programmer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ladyada.net/learn/avr/avrdude.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Uploading your .hex file&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-04-17T16:39:47.357" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23214" PostTypeId="2" ParentId="23208" CreationDate="2016-04-16T20:22:10.397" Score="2" Body="&lt;p&gt;I think problem lies in your Arduino sketch, specifically in this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RF_CSN 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you have set RF_CSN pin to pin#7 while actually, its connected to pin#9&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get this to working you, try changing above lines of code to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define RF_CSN 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-16T20:22:10.397" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23217" PostTypeId="1" AcceptedAnswerId="23233" CreationDate="2016-04-17T01:01:35.163" Score="1" ViewCount="4456" Body="&lt;p&gt;I'm using the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Stepper&quot; rel=&quot;nofollow&quot;&gt;Stepper&lt;/a&gt; library to control a single stepper motor. When the Arduino is not running the motor it is holding the motor shaft in place. For my application, this is very wasteful and puts unnecessary strain on the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the Stepper library supposed to do this or is something else up with my circuit? Can this behavior be overridden?&lt;/p&gt;&#xA;" OwnerUserId="20248" LastActivityDate="2019-06-30T17:38:18.400" Title="Can I prevent the Stepper library from holding the motor?" Tags="|arduino-uno|library|stepper|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23218" PostTypeId="2" ParentId="23163" CreationDate="2016-04-17T01:49:04.167" Score="0" Body="&lt;p&gt;You should get an Arduino Mega, if you arent using one already. You'll need the SRAM and Serial ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I used this module, I didnt have enough time to experiment with it but here goes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;strong&gt;enroll&lt;/strong&gt; command for the FPM10 sensor takes an image of a fingerprint, processes it and finally creates a 512-byte model/template that is stored in flash memory with a unique ID (&lt;strong&gt;PageID&lt;/strong&gt;) and used for future comparisons. However, it is also possible to read those templates from the flash memory with a few commands.&#xA;You have not said much about the role your web server plays here, so I'll assume its possible for you to store data easily and that its responsible for authorizing fingerprint enrollment and deletion. Since you have more than one sensor, a general solution to your problem would be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The server must keep a record of available fingerprint IDs&lt;/li&gt;&#xA;&lt;li&gt;When instructing the Arduino to begin enrollment, the server must also send along a fingerprint ID, based on its records of what ID is free. IDs may be assigned sequentially at first but templates may be deleted, leaving holes, hence the need for the server.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino &lt;code&gt;begin()&lt;/code&gt;s the current sensor where the user is located and performs the normal enrollment. As soon as enrollment is done, the template that was just stored, should be loaded by the Arduino from the module's flash library and into one of its character file buffers using the &lt;strong&gt;LoadChar&lt;/strong&gt; command. The only parameters for this command are the BufferID and the PageID.&lt;/li&gt;&#xA;&lt;li&gt;Then the Arduino should download the template from the character file buffer into a 512-byte buffer that you will create in the Arduino SRAM. The command needed here is the &lt;strong&gt;UpChar&lt;/strong&gt; command and its sole argument is the BufferID of the buffer to be read from. As soon as confirmation is received from the module, the sensor begins sending the 512-byte template in packets of 32 bytes (by default), each with a packet identifier of 0x02 until the last packet which has a package identifier of 0x08.&lt;/li&gt;&#xA;&lt;li&gt;Then the Arduino &lt;code&gt;begin()&lt;/code&gt;s the other sensor and sends the &lt;strong&gt;DownChar&lt;/strong&gt; command to the module, which tells the sensor to expect a template to be stored in one of its character buffers (must be specified in the command). Once the Arduino receives confirmation, it should start sending the template to this sensor, using the same packet size and format that has been set for that sensor 9or the default I mentioned before if it hasnt been changed).&lt;/li&gt;&#xA;&lt;li&gt;Finally, the Arduino sends the &lt;strong&gt;Store&lt;/strong&gt; command to the sensor, to store the template in the buffer you just wrote to, into its flash library using the same fingerprint ID it was stored with in the first sensor.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino may then send confirmation to the Linux server, which then adds the fingerprint ID to the list of used IDs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now both sensors have identical fingerprint libraries and may be used to match fingerprints and get the same results. Deletion of fingerprints may also follow the same process: the server commands the Arduino to delete a print with a given ID and the Arduino sends the &lt;strong&gt;DeleteChar&lt;/strong&gt; command to both sensors. All the commands I mentioned here are in the sensor's datasheet, which you must have downloaded along with the Adafruit library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use 57600 baud to communicate with the sensors, for reliable results. This is my &lt;a href=&quot;https://github.com/brianrho/FPM&quot; rel=&quot;nofollow noreferrer&quot;&gt;fork&lt;/a&gt; of the Adafruit library with more functions available and without the buffer overflow issues. It should make the interfacing tasks a lot easier.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2017-02-11T15:18:08.457" LastActivityDate="2017-02-11T15:18:08.457" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23219" PostTypeId="2" ParentId="23202" CreationDate="2016-04-17T06:11:25.933" Score="1" Body="&lt;p&gt;Using same Voltage supply to power Arduino Board and motor simultaneously is usually not a good practice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what you can do is use separate batteries to power Arduino and motor as shown in image below&#xA;&lt;a href=&quot;https://i.stack.imgur.com/o3rDU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/o3rDU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;However you can also power arduino and motor from single power supply, but in this case you should first think of current ratting of your battery and current consumption of your Arduino (normally 500mA) and motor. As shown below,&#xA;&lt;a href=&quot;https://i.stack.imgur.com/EKHSg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EKHSg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Hope it help. Any question Comment below.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="19513" LastEditDate="2016-04-17T16:24:54.230" LastActivityDate="2016-04-17T16:24:54.230" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23220" PostTypeId="2" ParentId="23217" CreationDate="2016-04-17T06:19:43.837" Score="0" Body="&lt;p&gt;Stepper library has nothing to do with this. What &lt;strong&gt;holds&lt;/strong&gt; your motor are those &lt;strong&gt;GND&lt;/strong&gt;s or &lt;strong&gt;0 Volt&lt;/strong&gt;s applied to control pins of your Stepper motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are looking for is &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/uln2003a.pdf&quot; rel=&quot;nofollow&quot;&gt;UL2003A&lt;/a&gt;. The way ULN2003A works is solution to your problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming your stepper is unipolar, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/StepperUnipolar&quot; rel=&quot;nofollow&quot;&gt;Here is a complete tutorial&lt;/a&gt; on how to use Stepper motor with UNL2003A.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-17T06:19:43.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23221" PostTypeId="2" ParentId="23207" CreationDate="2016-04-17T06:33:16.800" Score="1" Body="&lt;p&gt;You don't actually have to initialize your connection to 115,200 bps or 57,600 bps. You can use a custom baud rate of 65,000 bps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to keep in mind that, you can use &lt;strong&gt;any&lt;/strong&gt; custom baud rate you want, as long as it's supported by the hardware. The Arduino IDE however only supports standard baud rates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One more thing, as you are streaming data (kind of), you might also want to look into Arduino serial buffer sizes.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="6936" LastEditDate="2016-04-17T10:13:29.823" LastActivityDate="2016-04-17T10:13:29.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23222" PostTypeId="2" ParentId="23207" CreationDate="2016-04-17T07:09:55.010" Score="3" Body="&lt;p&gt;On &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about the ADC converter&lt;/a&gt; I attempted to record a 4 kHz sine wave on the ATmega328P with the following code:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-C++ prettyprint-override&quot;&gt;&lt;code&gt;const byte adcPin = 0;  // A0&#xA;&#xA;const int MAX_RESULTS = 256;&#xA;&#xA;volatile int results [MAX_RESULTS];&#xA;volatile int resultNumber;&#xA;&#xA;// ADC complete ISR&#xA;ISR (ADC_vect)&#xA;  {&#xA;  if (resultNumber &amp;gt;= MAX_RESULTS)&#xA;    ADCSRA = 0;  // turn off ADC&#xA;  else&#xA;    results [resultNumber++] = ADC;&#xA;  }  // end of ADC_vect&#xA;&#xA;EMPTY_INTERRUPT (TIMER1_COMPB_vect);&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  // reset Timer 1&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;  TCNT1 = 0;&#xA;  TCCR1B = bit (CS11) | bit (WGM12);  // CTC, prescaler of 8&#xA;  TIMSK1 = bit (OCIE1B);  // WTF?&#xA;  OCR1A = 39;    &#xA;  OCR1B = 39;   // 20 uS - sampling frequency 50 kHz&#xA;&#xA;  ADCSRA =  bit (ADEN) | bit (ADIE) | bit (ADIF);   // turn ADC on, want interrupt on completion&#xA;  ADCSRA |= bit (ADPS2);  // Prescaler of 16&#xA;  ADMUX = bit (REFS0) | (adcPin &amp;amp; 7);&#xA;  ADCSRB = bit (ADTS0) | bit (ADTS2);  // Timer/Counter1 Compare Match B&#xA;  ADCSRA |= bit (ADATE);   // turn on automatic triggering&#xA;&#xA;  // wait for buffer to fill&#xA;  while (resultNumber &amp;lt; MAX_RESULTS)&#xA;    { }&#xA;&#xA;  for (int i = 0; i &amp;lt; MAX_RESULTS; i++)&#xA;    Serial.println (results [i]);&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code (rather inefficiently) sends the results in ASCII, like this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;378&#xA;710&#xA;899&#xA;992&#xA;966&#xA;827&#xA;609&#xA;367&#xA;159&#xA;38&#xA;35&#xA;147&#xA;350&#xA;593&#xA;817&#xA;965&#xA;1001&#xA;917&#xA;733&#xA;494&#xA;259&#xA;88&#xA;21&#xA;76&#xA;239&#xA;471&#xA;711&#xA;905&#xA;1001&#xA;977&#xA;839&#xA;620&#xA;376&#xA;164&#xA;39&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gave reasonable results:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tav19.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tav19.png&quot; alt=&quot;Sine wave with ADC&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the Leonardo is, of course, a different processor. However it is similar. The ADC on it should be capable of similar performance.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I should point out that this code records first, then sends the data. This is so the recording can keep up. A normal ADC conversion (if you don't change the ADC prescaler) takes 104 µs. To send 10 bits via serial at 115200 baud rate would take 173.6 µs because it would require two bytes per sample (unless you somehow compress each reading). If you could put up with 8-bit resolution (per sample) then you halve that, and can probably just stream the data out fast enough. &lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="6936" LastEditDate="2016-04-18T11:01:20.573" LastActivityDate="2016-04-18T11:01:20.573" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23224" PostTypeId="2" ParentId="23209" CreationDate="2016-04-17T11:24:45.350" Score="2" Body="&lt;p&gt;How are you creating your &lt;code&gt;.hex&lt;/code&gt; files? Where are they coming from? Are you cross compiling the &lt;code&gt;.hex&lt;/code&gt; files on some other machine and then transferring them to the Linux box? What is your Arduino connected to, the Linux box, or some other machine? Why are you even bothering with the .hex files? Your question is a little unclear. As Mikael states in &lt;a href=&quot;https://arduino.stackexchange.com/questions/23209/compile-hex-files-on-linux#comment-44093&quot;&gt;his comment&lt;/a&gt;, you do not need to &lt;em&gt;compile&lt;/em&gt; the &lt;code&gt;.hex&lt;/code&gt; files, they are already compiled, you merely need to &lt;em&gt;upload&lt;/em&gt; them, which the Arduino IDE would do for you anyway...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As ARK points out in &lt;a href=&quot;https://arduino.stackexchange.com/questions/23209/compile-hex-files-on-linux#answer-23213&quot;&gt;his answer&lt;/a&gt;, you may find the answers to the question &lt;a href=&quot;https://stackoverflow.com/questions/11607834/where-are-the-hex-files-compiled-by-arduino&quot;&gt;Where are the hex files compiled by Arduino?&lt;/a&gt; useful, although it seems like you know where they are but you don't know how to upload them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can you not just use the Arduino IDE, to write your sketch, and then allow it to &lt;em&gt;automatically&lt;/em&gt; compile the sketch and upload the &lt;code&gt;.hex&lt;/code&gt; file for you? That way you do not need to manually play with the &lt;code&gt;.hex&lt;/code&gt; file. Maybe I am missing something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the Arduino IDE bombing out and not uploading the sketch on to the Arduino board?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However, if you are merely asking, how can I upload a &lt;code&gt;.hex&lt;/code&gt; file to an Arduino, in Linux without using the Arduino IDE, then you would use &lt;code&gt;avrdude&lt;/code&gt;. Taking the answer from &lt;a href=&quot;https://electronics.stackexchange.com/questions/67121/how-do-i-upload-a-hex-file-firmware-to-a-target-board-without-using-the-arduino&quot;&gt;How do I upload a hex file firmware to a target board without using the arduino IDE?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/build8135728863211847829.tmp/sketch_may21b.cpp.hex:i &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or alternatively, taking the answer from &lt;a href=&quot;https://stackoverflow.com/questions/23780125/uploading-arduino-hex-file-using-avrdude&quot;&gt;Uploading Arduino hex file using avrdude&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -U flash:w:[put-hex-file-path-here]:i -C avrdude.conf -v -p atmega328 -b 115200 -c stk500v2 -P [put-device-path-here]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-04-17T11:35:20.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23225" PostTypeId="2" ParentId="23192" CreationDate="2016-04-17T12:31:20.230" Score="0" Body="&lt;p&gt;(It sounds like you have already used the esp8266 so I hope this background isn't too simple, but I'm not sure from your question where you're stuck.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 modules are programmable. They are (usually) delivered with an application program installed that uses the manufacturer-defined set of &quot;AT&amp;lt;something&amp;gt;&quot; commands to operate it as a WiFi station or access point. There are code libraries for Arduinos or other computers to set it up and use it that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use its one serial port for either job - communicating to its current application program (interpreter, or your own custom program), much as you do an Arduino's port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can program your entire application on the chip and operate its WiFi radios directly, just as the AT-command interpreter does. You'll need the specs for programming the radios though; the AT-interpreter does that for you. Once you've loaded an application program of your own, it replaces the interpreter. To put it back to as-delivered, with the AT-command interpreter running in it, you'll need to re-upload the interpreter (which of course will replace anything else you've loaded).&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-04-17T12:31:20.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23226" PostTypeId="2" ParentId="23202" CreationDate="2016-04-17T12:36:26.343" Score="0" Body="&lt;p&gt;You can use the same power supply for both if it can source enough current for both; USB ports usually can not. But what you must not do is try to supply motor current through the Arduino, from any power supply. You need the Arduino to control a transistor switch which manages the motor current.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-17T17:40:02.177" LastActivityDate="2016-04-17T17:40:02.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23228" PostTypeId="2" ParentId="23217" CreationDate="2016-04-17T13:32:15.990" Score="0" Body="&lt;p&gt;The ability to release all the stepping motor coils depend on the hardware and software used. For example, the Adafruit.com hardware and software has &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/library-reference#void-release-void&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; function to release all the stepping motor coils.  Investigate their approach and determine if you can contribute to the library you are using by porting this feature.  Also investigate if this feature is not (serendipitously) already part of the library you are using.  For instance, it is not unreasonable to expect the library you are using to return Atmel pins to a passive input state (which, depending on the hardware, may release the stepper) when you destroy the instance of the stepper library class.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-17T13:32:15.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23229" PostTypeId="2" ParentId="21707" CreationDate="2016-04-17T13:56:39.867" Score="1" Body="&lt;p&gt;Your temp sensor is obviously working if it displays the temp on the serial monitor. I would now write a new sketch, forgetting the temp sensor for the moment, and get numerical data on to the seven segment display correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many digits does the seven segment display have? What interface are you using, if any? How is the display connected to the Arduino? You need to provide the information in your question, to allow us to give you an accurate answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may want to take a look at my answer to &lt;a href=&quot;https://robotics.stackexchange.com/questions/9218/programming-4-digit-seven-segment-display-using-interrupts-only#answer-9221&quot;&gt;Programming 4-digit seven segment display using interrupts only&lt;/a&gt; on SE Robotics. I had the same issues, about a year ago, when I was trying to display data on a cheap seven segment display that I purchased in BKK, and I ended up writing an Arduino library in order to get it to work, see &lt;a href=&quot;https://gr33nonline.wordpress.com/2015/08/04/dual-seven-segment-display-madness/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Dual Seven Segment Display Madness&lt;/a&gt;. However, I don't recommend that you write your own library, and instead use a pre-built one. Take a look at the &lt;a href=&quot;http://playground.arduino.cc/Main/SevenSeg&quot; rel=&quot;nofollow noreferrer&quot;&gt;SevenSeg library&lt;/a&gt;. That is what I used eventually. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see that you are using some code from the &lt;a href=&quot;http://playground.arduino.cc/Main/SevenSegmentLibrary&quot; rel=&quot;nofollow noreferrer&quot;&gt;SevSeg library&lt;/a&gt;, but you do not appear to include the header &lt;code&gt;SevSeg.h&lt;/code&gt; in your sketch. If you are happy using the SevSeg library, then first write a sketch using the examples and the tutorials, so that you can get data displayed. Then integrate that software with your temperature sensor software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You really do need to divide your project into two parts, the sensor and the display. Once you are happy with displaying data on the Seven Segment display, &lt;em&gt;then&lt;/em&gt;, and only &lt;em&gt;then&lt;/em&gt; can you think about getting the temperature sensor data displayed on it.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:49:17.743" LastActivityDate="2016-04-17T14:08:06.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23231" PostTypeId="2" ParentId="23110" CreationDate="2016-04-17T14:52:31.507" Score="1" Body="&lt;p&gt;As discussed in the comments, the &quot;problem&quot; seemed to be Matlab adding a &quot;New Line&quot; which is a decimal 10 in ASCII.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;asciitable.com Decimal 10 is the ASCII code for a &quot;New Line&quot; so it appears your Matlab send code will add a &quot;New-line&quot; after each sent value. – Paul Apr 14 at 8:15       &lt;/p&gt;&#xA;  &#xA;  &lt;blockquote&gt;&#xA;    &lt;p&gt;thank you very match the problem is solved – abbas hussien 5 hours ago&lt;/p&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You might want to accept this answer so that this question gets &quot;closed&quot; and the site's statistics will be more accurate.&#xA;It will also avoid this question being bumped up by the system and people reading into something that has already been solved.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-04-17T14:52:31.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23232" PostTypeId="2" ParentId="23198" CreationDate="2016-04-17T15:01:29.100" Score="1" Body="&lt;p&gt;Examine your code closely.  It appears that you are partially implementing extended resolution calculations in this line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  float TemperatureSum = tempRead / 16;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;https://datasheets.maximintegrated.com/en/ds/DS18S20.pdf&quot; rel=&quot;nofollow&quot;&gt;DS18S20 specifications&lt;/a&gt; the extended resolution equation used is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; TEMPERATURE = TEMP_READ * 0.25 - ((COUNT_PER_C - COUNT_REMAIN) / (COUNT_PER_C))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where COUNT_PER_C is a DS18S20 register containing a value of up to 16.  Maybe that is where 16 originated?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe what you want to do is divide the recovered value by 2.0 base on table 1 from the DS18S20 specifications:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  float TemperatureSum = tempRead / 2.0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Don't forget the &quot;.&quot; in case the compiler you are using decides to do integer math dripping the &quot;float&quot; part before assigning it to TemperatureSum.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-17T15:01:29.100" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23233" PostTypeId="2" ParentId="23217" CreationDate="2016-04-17T15:32:51.943" Score="4" Body="&lt;p&gt;use disable output class in  accelstepper library.&#xA;&lt;a href=&quot;http://www.airspayce.com/mikem/arduino/AccelStepper/&quot; rel=&quot;nofollow&quot;&gt;http://www.airspayce.com/mikem/arduino/AccelStepper/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20263" LastActivityDate="2016-04-17T15:32:51.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23237" PostTypeId="1" CreationDate="2016-04-17T18:36:33.657" Score="3" ViewCount="505" Body="&lt;p&gt;I'm trying to connect arduino uno and ev3 by using this guide (&lt;a href=&quot;http://www.dexterindustries.com/howto/connecting-ev3-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.dexterindustries.com/howto/connecting-ev3-arduino/&lt;/a&gt;), &#xA;everything works perfectly but when i tried to use analogRead block to display data from arduino it just displays  i2c address of my arduino.&lt;/p&gt;&#xA;" OwnerUserId="20091" LastActivityDate="2016-04-17T18:36:33.657" Title="Connecting arduino and EV3 using I2C" Tags="|arduino-uno|i2c|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23238" PostTypeId="1" AcceptedAnswerId="23258" CreationDate="2016-04-17T20:19:03.190" Score="3" ViewCount="5007" Body="&lt;p&gt;I read and heard that the floating point math is much slower than int math.&lt;/p&gt;&#xA;&lt;p&gt;And I saw a converting process in here &lt;a href=&quot;https://web.archive.org/web/20200212200649/https://www.engblaze.com/faster-code-fridays-avoid-floating-point-math/&quot; rel=&quot;nofollow noreferrer&quot;&gt;floath math to integer math&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I want to to convert my floating math calculations to integer math.&lt;/p&gt;&#xA;&lt;p&gt;Here is the code that include floating math:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;float sensval, lpf, lps;&#xA;float sensinitial; // used to store the initial sensor data&#xA;float x, y, z;&#xA;int heigh;&#xA;int dA;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  runSensor();&#xA;  sensval = readSensorData();&#xA;  sensinitial = sensval; // Setting the initial data&#xA;  lpf = lps = sensval;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  sensval =  readSensorData();&#xA;  heigh = (float)44330 * (1 - pow(((float) sensval/sensinitial), 0.190295));&#xA;  lpf = lpf + (sensval - lpf) * 0.1;&#xA;  lps = lps+ (sensval - lps) * 0.05;&#xA;  x = (lps - lpf) * 50;&#xA;  y = x+ (z - y) * 0.1;&#xA;  z = constrain(y, -500, 500);&#xA;  dA += z * 100 + 2000;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;readSensorData(); returns 7 decimals maximum(752.4543 for example)&lt;/p&gt;&#xA;&lt;p&gt;There is pow calculation too.&lt;/p&gt;&#xA;&lt;p&gt;So how can I convert floath math to int math?&lt;/p&gt;&#xA;&lt;p&gt;Any optimization code are welcome.&lt;/p&gt;&#xA;" OwnerUserId="20208" LastEditorUserId="77085" LastEditDate="2023-12-05T14:23:38.330" LastActivityDate="2023-12-05T14:23:38.330" Title="Avoiding float math to speed up arduino" Tags="|arduino-uno|c++|float|mathematics|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23240" PostTypeId="2" ParentId="23168" CreationDate="2016-04-17T21:16:58.150" Score="4" Body="&lt;h1&gt;Most likely cause&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You are hitting an insidious problem that even experienced C++ programmers frequently miss: order of initialization of global variables. In your case, &lt;code&gt;Display lcd&lt;/code&gt; is initialized (&lt;em&gt;i.e.,&lt;/em&gt; its constructor is called) before &lt;code&gt;main()&lt;/code&gt; and subsequently &lt;code&gt;setup()&lt;/code&gt; are executed. However, you almost certainly are &lt;code&gt;#include&lt;/code&gt;ing whatever library is declaring the &lt;code&gt;LiquidCrystal_I2C&lt;/code&gt; class, probably &lt;code&gt;Wire.h&lt;/code&gt;, and so on. In many of these classes, a global variable of that type is also defined to make it easier to access stuff. For example, &lt;code&gt;Serial&lt;/code&gt; (as in &lt;code&gt;Serial.println(&quot;foo&quot;)&lt;/code&gt;) is really a global variable of the appropriate type of whatever serial implementation your particular core is using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem you are hitting is that the C++ standard does &lt;strong&gt;not&lt;/strong&gt; guarantee the execution order of the constructors of global variables. The order is an artifact of the compiler, the order in which object files were linked, and probably the phase of the moon :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is (almost certainly) happening is that the constructor for your &lt;code&gt;class Display&lt;/code&gt; is being called, which initializes the LCD and the i2c bus, and then something else calls either the LCD constructor or the i2c constructor and messes things up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, &quot;how do I fix this?&quot; I hear you ask. Simple: make the global lcd variable a &lt;em&gt;pointer&lt;/em&gt;, and allocate the instance in &lt;code&gt;begin()&lt;/code&gt;, like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Display.h&quot;&#xA;&#xA;Display *lcd;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  lcd = new Display();&#xA;  // stuff&#xA;}&#xA;&#xA;void loop() {&#xA;  // more stuff&#xA;  lcd-&amp;gt;some_method(some_argument);&#xA;  // even more stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you are guaranteed that your code will be the last to touch any initialization code that might affect the display or the bus. Just keep accessing the &lt;code&gt;class Display&lt;/code&gt; methods through the pointer.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;A less likely cause&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;It is still possible that your constructors are getting executed in the right order, but your hardware does not like being initialized twice (but test that anyway!), so you may have to figure out how to reset the hardware so you can initialize it again. If I understand your posting correctly, the loop never runs, which means that a second initialization probably either causes a exception (which you would not see unless you had some kind of additional debugging channel; in the case of the ESP8266, for example, that would be the output-only &lt;code&gt;Serial1&lt;/code&gt; port, and even then, you'd have to explicitly turn on debugging. Each core has its own debugging stuff, I forget what the real Arduino does.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/ji&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-17T21:16:58.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23241" PostTypeId="1" CreationDate="2016-04-17T21:53:10.360" Score="3" ViewCount="364" Body="&lt;p&gt;I have a genuine (purchased from Adafruit) Arduino Leonardo that I have had for 2 years and I have not had any issues with. However, I have always noticed that it seems to be running suspiciously hot for a low power microcontroller, sometimes even too hot to comfortably touch. I measured the temperature today with an infrared thermometer at 121 degrees Fahrenheit (~49C). Based on observations by feeling the board, the 32U4 seems to be what is getting hot and everything else is cool to the touch. This happens when it is powered over USB as well as through the power jack. The chip gets hot even when nothing is connected to the I/O or power pins. The board is entirely working and does not appear visibly damaged. I am a bit worried about this as I may use this board in a project where it will be inside in enclosure and running for long periods of time. Any ideas why this is happening and if this normal?&lt;/p&gt;&#xA;" OwnerUserId="3029" LastActivityDate="2016-04-17T22:09:51.393" Title="Arduino Leonardo runs unusually hot" Tags="|arduino-leonardo|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23242" PostTypeId="2" ParentId="23241" CreationDate="2016-04-17T22:09:51.393" Score="1" Body="&lt;p&gt;My Leonardo, which I leave on all the time, is not hot. The CPU chip feels at room temperature as far as I can tell. If you were powering something from it, maybe you are drawing too much current. If it gets hot just sitting there doing nothing, and with nothing connected, something is wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe you damaged it in the past? Maybe hooked up some LEDs without current-limiting resistors? If not, it sounds like a faulty device to me.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-17T22:09:51.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23243" PostTypeId="2" ParentId="23204" CreationDate="2016-04-17T23:59:28.413" Score="0" Body="&lt;p&gt;Create a flow chart of the entire process you want to happen. Once you proof your flow chart to cover all possible functions, you can create the logic, control, and subroutines that are needed. If you have a good book on Arduino programming, and how I2C works, you will know that the I2c display will hold whatever data you wish until you change it. Also, you probably know that you can chain a whole bunch of I2c devices, no matter if they are displays, or anything else, so each device will hold its own data independent of the others. Any updating is under your control in programming. You might also look into using interrupts for some of your program control. Sensors don't push data, the processor reads the data, and your program is in control of how often and when the data is read, and what it does with the data.  The exception to your program being in control, is when you use interrupts. You should be storing the data so you will always have access to it for program examination and possible decision making. Lastly, to increase the abilities of your system, consider using one master Arduino, and several slave Arduino's. Some of the slaves, depending on what you want them to do, can be very small. Look at the tiny85. Some of the boards with the Tiny85 are the size of a postage stamp. I hope some of these suggestions are helpful to you.&lt;/p&gt;&#xA;" OwnerUserId="20269" LastActivityDate="2016-04-17T23:59:28.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23245" PostTypeId="1" AcceptedAnswerId="23286" CreationDate="2016-04-18T00:08:51.437" Score="6" ViewCount="6683" Body="&lt;p&gt;Firstly, I have tried to set the bootloader to be 8MHz internal oscillator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried the board setup from here - &lt;a href=&quot;https://github.com/oshlab/Breadboard-Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/oshlab/Breadboard-Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also the &lt;code&gt;breadboard-1-6-x.zip&lt;/code&gt; setup from here - &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Burning the bootloader in both cases seems to work, with fuse settings of &lt;code&gt;-Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m&lt;/code&gt; (using Arduino IDE 1.6.7):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: 1 bytes of efuse written&#xA;avrdude: verifying efuse memory against 0x05:&#xA;avrdude: load data efuse data from input file 0x05:&#xA;avrdude: 1 bytes of efuse verified&#xA;...&#xA;avrdude: 1 bytes of hfuse written&#xA;avrdude: verifying hfuse memory against 0xDA:&#xA;avrdude: load data hfuse data from input file 0xDA:&#xA;avrdude: 1 bytes of hfuse verified&#xA;...&#xA;avrdude: 1 bytes of lfuse written&#xA;avrdude: verifying lfuse memory against 0xE2:&#xA;avrdude: load data lfuse data from input file 0xE2:&#xA;avrdude: 1 bytes of lfuse verified&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try and run the test sketch (below) at these voltages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3.3V it fails (tried multiple 3.3V sources, all fail).&lt;/li&gt;&#xA;&lt;li&gt;4.23V (3xAA rechargeable batteries) it works.&lt;/li&gt;&#xA;&lt;li&gt;4.8V (3xAA alkaline batteries) it works.&lt;/li&gt;&#xA;&lt;li&gt;5V it works.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To try and determine if it was my power sources or the bootloader that was the problem I uploaded this test sketch on my ATmega328P, an Arduino Nano (all Nanos are 16MHz?) and a 16MHz Arduino Pro to see if the red LED (with 100 Ohm resistor for ATmega328P) lights up in about the same time. This test sketch also does not work at 3.3V, and must be run at 5V to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;edit&lt;/em&gt;) When running this test sketch at 3.3V I see &lt;strong&gt;no&lt;/strong&gt; 3.3V logic level on &lt;strong&gt;any&lt;/strong&gt; output pin with my multimeter.  When running at 4.23, 4.28, 5V I see this logic level on all output pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;update&lt;/strong&gt;) When connecting the +ve of the LED directly to 3.3V, the LED lights up.  So the 3.3V source has enough power to light the LED directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I assumed that because my ATmega328P circuit has no crystal in it (and the Nano and Pro Mini are 16MHz), these loops would execute in different amounts of time?  But no, the loops &lt;em&gt;do&lt;/em&gt; execute at the same speed (3 and a bit seconds) - so is my Nano/Pro Mini underclocked, or my ATmega still running at 16MHz but without a crystal??  Rather confused.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;strong&gt;update&lt;/strong&gt;) I tried a second ATmega328P, same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;code edited to use 14 output pins&lt;/em&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  for (int p=0; p&amp;lt;14; p++) pinMode(p, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // waste some time.&#xA;  int y = 0;&#xA;  for (int i = 0; i &amp;lt; 11; i++) {&#xA;    for (int j = 0; j &amp;lt; 11; j++) {&#xA;      for (int k = 0; k &amp;lt; 101; k++) {&#xA;        y+=analogRead(A0);&#xA;      }&#xA;    }&#xA;  }&#xA;  for (int p=0; p&amp;lt;14; p++) digitalWrite(p, y % 2);&#xA;  for (int p=0; p&amp;lt;14; p++) digitalWrite(p, HIGH);&#xA;  delay(1000);&#xA;  for (int p=0; p&amp;lt;14; p++) digitalWrite(p, !(y % 2));&#xA;  for (int p=0; p&amp;lt;14; p++) digitalWrite(p, LOW);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19579" LastEditorUserId="19579" LastEditDate="2016-04-18T20:46:37.443" LastActivityDate="2019-09-02T08:08:05.230" Title="Confusion with ATmega328P and 3.3V/8MHz" Tags="|atmega328|voltage-level|bootloader|oscillator-clock|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23246" PostTypeId="1" AcceptedAnswerId="26528" CreationDate="2016-04-18T01:00:12.320" Score="3" ViewCount="6685" Body="&lt;p&gt;Recently, I bought two &lt;a href=&quot;https://www.silabs.com/Support%20Documents/TechnicalDocs/Si4464-63-61-60.pdf&quot; rel=&quot;nofollow&quot;&gt;Si4463&lt;/a&gt; chips, but I don't know how to use them. It seems complex. I'd like to know if there are any examples of an Si4463 used with an Arduino?&lt;/p&gt;&#xA;" OwnerUserId="15630" LastEditorUserId="11763" LastEditDate="2016-08-21T15:08:12.613" LastActivityDate="2023-01-29T13:09:23.800" Title="Are there any detail examples of Si4463" Tags="|library|spi|wireless|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23247" PostTypeId="2" ParentId="23245" CreationDate="2016-04-18T02:03:18.407" Score="4" Body="&lt;p&gt;If you are using an LED to indicate that your sketch is running, then that may be the problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you have a fairly average red LED, it might have a forward voltage of 2.0v @ 20ma (refer to your spec sheet for your particular LED). Putting these values into the &lt;a href=&quot;http://led.linear1.org/1led.wiz&quot; rel=&quot;nofollow&quot;&gt;LED calculator&lt;/a&gt;, it would tell you that you need a 150 ohm resistor. You might have tested this, and seen the LED light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, if you drop the voltage to 3.3v, your LED might be either very dim, or (more likely!) not light up at all. Putting 3.3v into the same web page, it shows you need a smaller resistor, 68 ohm, for the same LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. - I just noticed your paragraph about the green LED - a &quot;true green&quot; LED might have a voltage drop of 3.3v, which means for 5v you would need a 100 ohm resistor (as described in your paragraph); for a 3.3v supply you would need a 1 ohm resistor instead. This is pretty certainly your problem&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2016-04-18T02:16:06.030" LastActivityDate="2016-04-18T02:16:06.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23248" PostTypeId="2" ParentId="23245" CreationDate="2016-04-18T02:12:46.077" Score="2" Body="&lt;p&gt;If you are powering your circuit off a cell battery, you might find that your battery cannot supply enough current. To test this, use a multimeter to measure the voltage of the battery, while your circuit is connected (and possibly, or possibly not, running). If the voltage drops below 2.7v (as defined by your fuses - use the &lt;a href=&quot;http://www.engbedded.com/fusecalc/&quot; rel=&quot;nofollow&quot;&gt;AtMel Fuse Calculator&lt;/a&gt; page to see what your fuses mean), your chip will shut down, causing the voltage to rise back, turning the chip back on, and round it goes.The battery may even take a while to recover (I think last time this happened to me, it took about 10 seconds -I thought I'd destroyed the battery).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is fairly common issue with motors (which draw a lot of power), but depends on your exact battery, and the exact load. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this happens, you might get away with using multiple batteries in parallel (connect all the + sides together, to the + side of your circuit; all the - sides together to the - side of your circuit). Most battery holders are in series, which means they boost the voltage instead; you will have to do your own wiring for this.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastActivityDate="2016-04-18T02:12:46.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23249" PostTypeId="2" ParentId="23238" CreationDate="2016-04-18T03:09:23.837" Score="1" Body="&lt;p&gt;Since you are dealing with fractions, you can use fixed point arithmetic. For example, you can use &lt;code&gt;unsigned short _Accum&lt;/code&gt; for &lt;code&gt;readSensorData()&lt;/code&gt; if you only need 8 bits for the fraction part. &lt;a href=&quot;http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf&lt;/a&gt; tells you about fixed point types in c.&lt;/p&gt;&#xA;" OwnerUserId="19692" LastActivityDate="2016-04-18T03:09:23.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23250" PostTypeId="1" CreationDate="2016-04-18T03:44:09.963" Score="2" ViewCount="61" Body="&lt;p&gt;I'm currently attempting to use an Arduino Micro as a ducky USB for penetration testing, and currently when I attempt to open a command prompt (or any other window) the window loses focus which prevents me from typing anything in it. Here's my sample code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Keyboard.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  delay(5000); //Delay for testing&#xA;  Keyboard.begin();&#xA;&#xA;  Keyboard.write(KEY_LEFT_GUI);&#xA;  delay(400);&#xA;  print(F(&quot;notepad&quot;));&#xA;  enter();&#xA;&#xA;  Keyboard.print(&quot;This is a test&quot;);&#xA;  enter();&#xA;&#xA;  clear();&#xA;  Keyboard.end();&#xA;}&#xA;&#xA;void print(const __FlashStringHelper *value) {&#xA;  Keyboard.print(value);&#xA;}&#xA;&#xA;void clear() {&#xA;  Keyboard.releaseAll();&#xA;}&#xA;&#xA;void enter() {&#xA;  Keyboard.write(KEY_RETURN);&#xA;  Keyboard.releaseAll();&#xA;}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any thoughts on what might be causing this? I'm testing it on windows 10 home (not sure if that matters).&lt;/p&gt;&#xA;" OwnerUserId="19713" LastEditorUserId="37523" LastEditDate="2019-07-06T19:47:01.780" LastActivityDate="2019-07-06T19:47:01.780" Title="Arduino micro window focus troubles" Tags="|usb|arduino-micro|keyboard|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23252" PostTypeId="1" CreationDate="2016-04-18T04:06:51.880" Score="2" ViewCount="498" Body="&lt;p&gt;I built a keypad that can adjust volume, play, pause, skip tracks, and control the arrow and num keys. It has some backlighting under the keys. I'd like to turn this off when the computer is off. Additionally, whenever the computer is restarted the device must be unplugged and plugged back in or the operating system will not register keypresses. Is there a way I can tell if the computer is on or if the device is connected?&lt;a href=&quot;https://i.stack.imgur.com/aY1tw.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aY1tw.jpg&quot; alt=&quot;The keypad&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20273" LastActivityDate="2016-04-18T04:06:51.880" Title="How to detect whether connected to computer" Tags="|usb|arduino-micro|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="23257" PostTypeId="1" AcceptedAnswerId="23259" CreationDate="2016-04-18T08:43:57.057" Score="0" ViewCount="881" Body="&lt;p&gt;I'm new to Arduino and haven't done any education in electrical engineering before, so this might be a very dumb question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm busy with a project to control two servo motors with Arduino. Now yesterday I connected the wires incorrectly to the breadboard, so the wires started smoldering. I didn't connect the resistor correctly, so I guess that might have been the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I replaced the wiring, but it's not working and I don't know if the software might be the problem or the breadboard need to be replaced as well. I cannot see anything wrong with the breadboard, but it was warm so I don't know if it might be burned from the inside? The wiring of the servomotors seems to be okay, so I guess that I don't need to replace those I hope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any tips about how to check everything is still working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or might it be a good idea to buy an LED and add it to the breadboard to ensure it's okay?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I guess I found some code to check that the servomotors are still okay. Just add them directly to the Arduino and run some code: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Sweep&quot; rel=&quot;nofollow&quot;&gt;Sweep&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One other question: one of the servomotors doesn't have a black, red and yellow cable but a red, brown and orange. How can I know which ones the same as yellow, red and black?&lt;/p&gt;&#xA;" OwnerUserId="20279" LastEditorUserId="6936" LastEditDate="2016-04-18T12:14:31.693" LastActivityDate="2016-04-18T18:15:10.590" Title="Need to buy a new breadboard?" Tags="|arduino-uno|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23258" PostTypeId="2" ParentId="23238" CreationDate="2016-04-18T09:22:47.377" Score="4" Body="&lt;p&gt;What you are asking for is not simple, especially since you have this&#xA;power function that can be hard to approximate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, you have to figure out the range and the required precision of&#xA;each of the floating point numbers you are manipulating. You wrote that&#xA;&lt;code&gt;readSensorData()&lt;/code&gt; returns 7 decimals. If by that you mean that you&#xA;require a relative accuracy of 10&lt;sup&gt;−7&lt;/sup&gt;, then I predict it will&#xA;be &lt;em&gt;extremely&lt;/em&gt; hard to optimize this as a fixed point calculation. If&#xA;you can live with a much lower relative accuracy (say, around&#xA;10&lt;sup&gt;−3&lt;/sup&gt; or 10&lt;sup&gt;−4&lt;/sup&gt;), then it may be worth trying&#xA;something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would start by writing the expression of &lt;code&gt;height&lt;/code&gt; as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;height = f(sensval/sensinitial-1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(x) = 44330 * (1 - pow(1+x, 0.190295))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would expect &lt;code&gt;sensval&lt;/code&gt; and &lt;code&gt;sensinitial&lt;/code&gt; to be close to one another,&#xA;which would imply that &lt;em&gt;x&lt;/em&gt; is small. At this point you should try to&#xA;estimate the likely range for &lt;em&gt;x&lt;/em&gt;, because the feasibility of what&#xA;follows strongly depends on it. Next step is to approximate f() by a&#xA;polynomial. A simple &lt;a href=&quot;https://en.wikipedia.org/wiki/Taylor_series&quot; rel=&quot;nofollow&quot;&gt;Taylor&#xA;expansion&lt;/a&gt; gives:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;f(x) ≈ -x*(8435.78-x*(3415.25-x*2060.2))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You may start by trying this, just to see if it looks kind of OK or&#xA;completely hopeless. You will notice that the above approximation is&#xA;great when |&lt;em&gt;x&lt;/em&gt;| is tiny, but it very quickly degrades as |&lt;em&gt;x&lt;/em&gt;|&#xA;increases. This is why you don't use Taylor expansions in real&#xA;approximations, I showed it to you only to give you an idea of the&#xA;feasibility of a polynomial approximation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do better than Taylor, you &lt;em&gt;must&lt;/em&gt; specify the range of &lt;em&gt;x&lt;/em&gt;, then you&#xA;can scale that range to [−1,&amp;nbsp;1] and expand on the basis of the&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Chebyshev_polynomials&quot; rel=&quot;nofollow&quot;&gt;Chebyshev&#xA;polynomials&lt;/a&gt;. And&#xA;then you could fine-tune to get the &lt;a href=&quot;https://en.wikipedia.org/wiki/Approximation_theory&quot; rel=&quot;nofollow&quot;&gt;optimal&#xA;polynomial&lt;/a&gt;, but&#xA;it's likely to be only marginally better than the Chebyshev expansion.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all this works with a reasonable polynomial degree (say, no more than&#xA;5), then you can start converting to integer math. If it doesn't, you&#xA;may try a different type of approximation, like interpolating over&#xA;tabulated values. If the problem is the range of &lt;em&gt;x&lt;/em&gt; being too large,&#xA;you may instead write the power function as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a&lt;sup&gt;b&lt;/sup&gt; = 2&lt;sup&gt;b × log&lt;sub&gt;2&lt;/sub&gt;a&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and write polynomial approximations to the base-2 exponential and&#xA;logarithm (the polynomials only needs to cover one octave). If you try a&#xA;rational fraction approximation, beware that divisions are slow on the&#xA;AVR platform.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all the above looks like too complex, or too much work, then just get&#xA;a faster CPU, or try to live with your program being slow.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-18T09:22:47.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23259" PostTypeId="2" ParentId="23257" CreationDate="2016-04-18T09:29:38.787" Score="1" Body="&lt;p&gt;To answer your last question (for 99%): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;red = +&#xA;brown = gnd&#xA;orange = pwm (speed)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To test: try measure resistance with multimeter, gnd and + should have the lowest resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And to be save: buy a new breadboard, a bad partly melted breadboard, or pieces of solder spoiled, is a nightmare.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you can test with a multimeter the resistance of your breadboard for columns (close to 0) and rows 1.&lt;/p&gt;&#xA;" OwnerUserId="19958" LastActivityDate="2016-04-18T09:29:38.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23261" PostTypeId="1" CreationDate="2016-04-18T09:50:26.120" Score="1" ViewCount="4551" Body="&lt;p&gt;I just bought a DS18B20 temperature sensor. I can't detect the device when i run this code :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;&#xA;// Data wire is plugged into pin 10 on the Arduino&#xA;#define ONE_WIRE_BUS 10&#xA;&#xA;// Setup a oneWire instance to communicate with any OneWire devices &#xA;// (not just Maxim/Dallas temperature ICs)&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;&#xA;// Pass our oneWire reference to Dallas Temperature.&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;void setup(void)&#xA;{&#xA;  // start serial port&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Dallas Temperature IC Control Library Demo&quot;);&#xA;&#xA;  // Start up the library&#xA;  sensors.begin();&#xA; }&#xA;&#xA;&#xA; void loop(void)&#xA;{&#xA;  // call sensors.requestTemperatures() to issue a global temperature&#xA; // request to all devices on the bus&#xA;  Serial.print(&quot; Requesting temperatures...&quot;);&#xA;  sensors.requestTemperatures(); // Send the command to get temperatures&#xA;  Serial.println(&quot;DONE&quot;);&#xA;&#xA;  Serial.print(&quot;Temperature for Device 1 is: &quot;);&#xA;  Serial.print(sensors.getTempCByIndex(0)); // Why &quot;byIndex&quot;? &#xA;    // You can have more than one IC on the same bus. &#xA;    // 0 refers to the first IC on the wire&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are my connections:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5pb6H.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5pb6H.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;and output on Serial Terminal is: &lt;br&gt;&#xA;&lt;br&gt;&#xA;      &quot;Temperature for Device 1 is: -127.00 Requesting temperatures...DONE&quot;&lt;br&gt;&#xA;&lt;br&gt;&#xA;I also tried to detect the address of my device but with no success.&lt;br&gt;&#xA;I am using an arduino Mega 2560, i have read in some forms that maybe it has something to do with Clock speed or something like that.&lt;br&gt;&#xA;&lt;br&gt;&#xA;I appreciate your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mainly followed this tutorial : &lt;a href=&quot;http://www.hobbytronics.co.uk/ds18b20-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.hobbytronics.co.uk/ds18b20-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="11897" LastEditorUserId="19513" LastEditDate="2016-04-18T10:36:58.160" LastActivityDate="2017-10-25T11:05:46.893" Title="Detection of DS18B20, arduino Mega" Tags="|arduino-mega|temperature-sensor|1-wire|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23262" PostTypeId="2" ParentId="23261" CreationDate="2016-04-18T10:11:50.857" Score="1" Body="&lt;p&gt;In the &lt;a href=&quot;http://www.hobbytronics.co.uk/ds18b20-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Tutorial&lt;/a&gt;, which you are following, it says,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So we will use the 2 wire method. Simply connect both the GND and VDD&#xA;  pins to 0V (yes both)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and it shows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/b9Tc4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b9Tc4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but I think you are missing this step, because i can't see any connection like that here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/M0C5H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/M0C5H.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-18T10:11:50.857" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23267" PostTypeId="2" ParentId="23257" CreationDate="2016-04-18T10:34:56.540" Score="0" Body="&lt;p&gt;Not all servo motors have the same color cables, that's the manufacturers choice, although they should be standardized. You can test them with a multi-meter, low resistance is usually ground, slightly higher one is usually is usually the power, the other will be the signal. Breadboards are generally cheap and if you suspect yours is not functioning properly, buy a new one. I have two of these and they work very well for $10. &lt;a href=&quot;http://www.mpja.com/Powered-830-Point-Breadboard/productinfo/30176+TE/&quot; rel=&quot;nofollow&quot;&gt;MPJA powered breadboard&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, if you have a motor driver shield, they usually have a three pronged port for your servo cable to connect to. Try that as well.&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-04-18T10:41:57.387" LastActivityDate="2016-04-18T10:41:57.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23268" PostTypeId="2" ParentId="23257" CreationDate="2016-04-18T12:27:24.697" Score="2" Body="&lt;p&gt;You could check the connections of the breadboard, using a multimeter (set to continuity check) and wires in the breadboard holes, with the + and - leads, from the meter, at either end of each row/column of connections, following the diagram below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mgQVL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mgQVL.png&quot; alt=&quot;Breadboard connections&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be a bit tedious, but it should only take thirty minutes maximum, and would give you peace of mind as well as saving you four Euros...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you say that it was working before and now is not, then maybe the breadboard is damaged. However, it is unlikely that the whole breadboard is... try moving your components to a different part of the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The breadboard could possibly get warm, as servos &lt;em&gt;can&lt;/em&gt; use a fair bit of current, and breadboards aren't really designed for power circuitry. You &lt;em&gt;may&lt;/em&gt; be better off using an &lt;strong&gt;Arduino Servo shield&lt;/strong&gt; and connecting the servos directly to that, rather than using the breadboard. Why are you using a breadboard - can you, as &lt;a href=&quot;https://arduino.stackexchange.com/questions/23257/need-to-buy-a-new-breadboard#comment-44152&quot;&gt;Majenko states&lt;/a&gt;, provide a schematic diagram?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answering the last part of your question - Taking the graphics from &lt;a href=&quot;https://arduino.stackexchange.com/questions/20931/code-to-control-servo-with-shield/20942#20942&quot;&gt;my answer&lt;/a&gt; to &lt;a href=&quot;https://arduino.stackexchange.com/questions/20931/code-to-control-servo-with-shield&quot;&gt;Code to control servo with shield&lt;/a&gt;, to show the different colours for the four different connector types:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Futaba and Airtronics connectors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Sy2RH.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Sy2RH.gif&quot; alt=&quot;Futaba and Airtronics connectors&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hitec and JR Radio connectors have the same pin out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kjs4s.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kjs4s.gif&quot; alt=&quot;JR Radio and HiTec connectors&quot;&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the red, brown and orange leads go to a &lt;em&gt;JR Radios connector&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="6936" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-18T18:15:10.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23272" PostTypeId="1" AcceptedAnswerId="23316" CreationDate="2016-04-18T16:58:45.473" Score="4" ViewCount="22101" Body="&lt;p&gt;Given the following enums&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };&#xA;enum class CrossingZoneState: uint8_t {&#xA;    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state&#xA;    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor&#xA;    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where RELAY_OFF = HIGH, HIGH is #define HIGH 0x1 which I assume is a C++/Arduino constant? because I didn't define it. And RELAY_ON = LOW, LOW is 0x0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;in the following function I get the error that follows. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CrossingZoneState CheckEntrySensor(uint8_t esp) {&#xA;    //esp, short for entry sensor pin&#xA;    if (digitalRead(esp) == HIGH)&#xA;    {&#xA;        state = CrossingZoneState::CROSSINGZONE_CLEAR;&#xA;        return state;&#xA;    }&#xA;    else if (digitalRead(esp) == LOW)&#xA;    {&#xA;        state = CrossingZoneState::CROSSINGZONE_OCCUPIED;&#xA;        return state;&#xA;    }&#xA;    // if the digital read errs, return the current state so it re-runs&#xA;    return state;&#xA;};&#xA;&#xA;boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState relayState)    {&#xA;&#xA;    int testInt = 0;&#xA;    if (relayState == RelayState::RELAY_OFF)&#xA;    {&#xA;        testInt = 1;&#xA;    }&#xA;    digitalWrite(relayNumber, relayState);&#xA;    if (digitalRead(relayNumber) == testInt) {&#xA;        return true;&#xA;    };&#xA;    return false;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried having RelayState be an enum class as well but was getting similar type errors. Here is the error from VS2015 with the code shown above.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Compiling debug version of 'ModelRRXingStateMachine' for 'Arduino/Genuino Uno'&#xA;  ModelRRXingStateMachine.ino:11:55: error: 'RelayState' has not been declared&#xA;  :boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState relayState)&#xA;  ModelRRXingStateMachine.ino:2:1: error: 'CrossingZoneState' does not name a type&#xA;  :CrossingZoneState CheckEntrySensor(byte esp)&#xA;  Error compiling project sources&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not a professional programmer and am new to C++, usually writing in C# or VB.Net so I'm not sure what the compiler is looking for here, both enums are declared and one is declared with a type. Also, the VS code editor is showing no errors, the errors shown above show up in the error window when I try to build.&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-04-18T18:05:15.537" LastActivityDate="2016-04-19T13:16:50.197" Title="using enums in functions" Tags="|programming|arduino-mega|class|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23273" PostTypeId="1" AcceptedAnswerId="23276" CreationDate="2016-04-18T17:54:42.373" Score="0" ViewCount="246" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo myservo1, myservo2, myservo3;&#xA;&#xA;int bluetoothTx = 14;&#xA;int bluetoothRx = 15;&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup()&#xA;{&#xA;myservo1.attach(9);&#xA;&#xA;//Setup usb serial connection to computer&#xA;Serial.begin(9600);&#xA;&#xA;//Setup Bluetooth serial connection to android&#xA;bluetooth.begin(9600);&#xA; }&#xA;&#xA;void loop()&#xA;  {&#xA;    if(bluetooth.available()&amp;gt;0)&#xA;     { &#xA;      if(bluetooth.available()&amp;gt;=4)&#xA;       {  &#xA;        char buffer[4];&#xA;          for(int i=0;i&amp;lt;4;i++)&#xA;         {    &#xA;          buffer[i]=bluetooth.read();&#xA;         }&#xA;       int incomingValue = atoi(buffer);   &#xA;&#xA;      if(incomingValue&amp;gt;=1000 &amp;amp;&amp;amp; incomingValue&amp;lt;=1360)&#xA;        {&#xA;           unsigned int servopos = bluetooth.read();&#xA;           unsigned int servopos1 = bluetooth.read();&#xA;           unsigned int realservo = (servopos1 * 256) + servopos;&#xA;&#xA;         if (realservo &amp;gt;= 1000 &amp;amp;&amp;amp; realservo &amp;lt; 1360) &#xA;          {&#xA;              int servo1 = realservo;&#xA;              servo1 = map(servo1, 1000, 1360, 0, 360);&#xA;              myservo1.write(servo1);&#xA;              Serial.println(&quot;servo 1 ON&quot;);&#xA;           delay(10);    &#xA;            }&#xA;           }&#xA;          }&#xA;         if(bluetooth.available()==2)&#xA;          {&#xA;            char inbit=bluetooth.read();  &#xA;            if(inbit=='A'||inbit=='D');&#xA;           {&#xA;            char myval= bluetooth.read();&#xA;            if(myval== 'A')&#xA;            {&#xA;              myservo1.attach(9);&#xA;            }&#xA;&#xA;&#xA;             if(myval== 'D')&#xA;              {&#xA;               myservo1.detach();&#xA;              }&#xA;             }     &#xA;            }&#xA;           }&#xA;          }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19589" LastEditorUserId="19589" LastEditDate="2016-04-18T21:17:28.710" LastActivityDate="2016-04-18T21:17:28.710" Title="Programming problem I need both if else cases to work but only else loop is running" Tags="|programming|bluetooth|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23274" PostTypeId="1" AcceptedAnswerId="23275" CreationDate="2016-04-18T18:26:55.813" Score="0" ViewCount="2308" Body="&lt;p&gt;I'm working on a seemingly simple Arduino project which plays a sound and flashes an LED when provoked by some trigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When powered by an external power supply, the Arduino continually resets after playing ~1/4 seconds of audio. When powered from USB, it works fine (however the LED, being powered from the external power supply, of course does not work here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Wiring diagram&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FlIO5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FlIO5.png&quot; alt=&quot;wiring diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Parts list&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Pro Mini 5V&lt;/li&gt;&#xA;&lt;li&gt;Adafruit MAX98306 3.7W amplifier&lt;/li&gt;&#xA;&lt;li&gt;Sparkfun FemtoBuck LED Driver&lt;/li&gt;&#xA;&lt;li&gt;4 Ohm 3W speakers&lt;/li&gt;&#xA;&lt;li&gt;3W LED&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am using a 9V 1A power supply. Again, when no speakers are connected, the Arduino and LED work as intended. It's only when a speaker is connected that the board resets over and over again. Playing roughly 1/4 of a second of audio and then resetting implies to me that there's insufficient current, however, the problem persists even after using a 2.5A power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Things I have tried:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Increasing the power supply to 12V 2.5A&lt;/li&gt;&#xA;&lt;li&gt;Desoldering the LED driver (even with the LED driver removed, the board still resets)&lt;/li&gt;&#xA;&lt;li&gt;Checking continuity and staring at the wiring for long periods of time while scratching my head&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Overall, I'm at a loss as to why it would work when powered via USB instead of through my external power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong? Any insights are greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="20291" OwnerDisplayName="shanet" LastActivityDate="2016-05-02T20:57:42.273" Title="Arduino continually resets when connected to external power supply, but not USB" Tags="|led|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23275" PostTypeId="2" ParentId="23274" CreationDate="2016-04-18T18:35:04.923" Score="3" Body="&lt;p&gt;Most likely lack of current - lack of current able to be provided by the Mini. The audio is powered from the onboard regulator on the Mini, which has limited current capacity. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If too much current is drawn it will either get too hot and go into thermal shutdown until it cools down enough, or it will drop the output voltage, making things reset and crash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Power the audio system from an external 5V regulator.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-18T18:35:04.923" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23276" PostTypeId="2" ParentId="23273" CreationDate="2016-04-18T18:40:42.847" Score="1" Body="&lt;p&gt;There are so many things wrong with that program I can't begin to sort it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some of the most glaringly obvious errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(bluetooth.read() &amp;gt;=0 &amp;amp;&amp;amp; bluetooth.read() &amp;lt;=360)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read a character. Check it's at least 0. Read a second character. Check it's less than 360.  Since characters are between 0 and 255 that will always succeed if there is one character of any form to read (if there is no characters to read you get -1).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;else if(bluetooth.read()=='A'||'B'||'C'||'D'||'E'||'F');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read another character and compare it to 'A'. This if is true if the character read is A. It also succeeds if B, or if C or if D, etc. That's not &quot;if it's equal to C&quot;, just &quot;if C&quot;. C is a character literal, so it's equivalent to a number. Any number that is not 0 is TRUE, therefore it's equivalent to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if character is A or TRUE or TRUE or TRUE...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which of course is just true, so it will always succeed regardless.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char myval= bluetooth.read();&#xA;if(myval== 'A')&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read yet another character from bluetooth (I sure hope there are enough there...) then compare it to a list of characters that are the same as you looked at above. You're comparing a &lt;em&gt;new&lt;/em&gt; character this time, not the one you compared with the list a few lines beforehand.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-18T18:40:42.847" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23277" PostTypeId="1" AcceptedAnswerId="23328" CreationDate="2016-04-18T19:30:13.700" Score="0" ViewCount="305" Body="&lt;p&gt;I am starting some Arduino's projects with different sizes (very small based on Arduino Nano and bigger using Arduino Mega). These projects will be manipulated by students and they will connect and disconnect many times the wires. I will try to not use breadboard if I can. In order to develop very versatile projects, the idea will be to use very useful plug sockets. Currently I have no idea of which kinds of plug sockets I can use. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you have any idea about the existing plug sockets (from 2 to 6/8 wires) and which one it is preferable to use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Complements:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some shields and components I already have and want to use have sometimes some plugs sockets (similar to &lt;a href=&quot;http://boutique.semageek.com/fr/280-grove-base-shield-v2.html?adw=1&amp;amp;gclid=Cj0KEQjwrte4BRD-oYi3y5_AhZ4BEiQAzIFxn5xRoul9Pb_uKKQ_Tahm-_D9FlSqx8guNvUjOANcEHgaAlzR8P8HAQ&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;) but sometimes only some classical pins &lt;/li&gt;&#xA;&lt;li&gt;I want also to build my own shields by integrating plug sockets to the arduino or to another shield&lt;/li&gt;&#xA;&lt;li&gt;Some parts will be also composed by small electrical circuit on which I want to integrate plug sockets aswell&lt;/li&gt;&#xA;&lt;li&gt;I will also use LiPo batteries (for example &lt;a href=&quot;http://eud.dx.com/product/hubsan-h107-a05-3-7v-240mah-li-ion-polymer-battery-black-844217433&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt; which have a connector I can't buy currently because I don't know the reference) &lt;/li&gt;&#xA;&lt;li&gt;Communications will be also achieved using SPI and I2C&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="17063" LastEditorUserId="17063" LastEditDate="2016-04-19T14:34:29.347" LastActivityDate="2016-04-19T17:04:04.047" Title="The most practical plug socket" Tags="|wires|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23278" PostTypeId="1" AcceptedAnswerId="23285" CreationDate="2016-04-18T20:01:54.030" Score="1" ViewCount="775" Body="&lt;p&gt;I want to build a small circuit that will switch a LED on (for arguments sakes) when the cars ignition gets switched on. But I want to make it versatile so I can work with between 12V - 36V (Cars, Trucks, etc). What would be the best to read the Ignition status via the arduino. Know I have thought of an idea by working with voltage divider. Basically taking the principal of reading voltage &lt;a href=&quot;http://www.instructables.com/id/Arduino-Reading-Analog-Voltage/&quot; rel=&quot;nofollow&quot;&gt;Instructable Example&lt;/a&gt; and working from there. Any thoughts?&lt;/p&gt;&#xA;" OwnerUserId="19724" LastActivityDate="2016-04-18T22:02:24.130" Title="Arduino Digital Input. Trigger HIGH by 12V to 36V" Tags="|arduino-uno|digital|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23279" PostTypeId="2" ParentId="23272" CreationDate="2016-04-18T20:21:28.173" Score="0" Body="&lt;p&gt;For one thing, you are using the variable state without defining it. Moreover, you have not declared the functions CheckEntrySensor() and throwRelayAndCheckStatus() . When you define a function without first declaring it, the arduino preprocessor builds its own declarations, but often does so in a defective way. This is one of the idiosyncracies of the arduino environment versus a plain C++ compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following compiles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };&#xA;typedef enum RelayState RelayState_t ;&#xA;&#xA;&#xA;enum CrossingZoneState {&#xA;    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state&#xA;    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor&#xA;    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear&#xA;};&#xA;typedef enum CrossingZoneState CrossingZoneState_t ;&#xA;&#xA;CrossingZoneState_t CheckEntrySensor(uint8_t esp) ;&#xA;boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState_t relayState) ;&#xA;&#xA;CrossingZoneState_t CheckEntrySensor(uint8_t esp)&#xA;{&#xA;  CrossingZoneState_t state ;&#xA;    //esp, short for entry sensor pin&#xA;    if (digitalRead(esp) == HIGH)&#xA;    {&#xA;        state = /*CrossingZoneState_t::*/CROSSINGZONE_CLEAR;&#xA;        return state;&#xA;    }&#xA;    else if (digitalRead(esp) == LOW)&#xA;    {&#xA;        state = /*CrossingZoneState::*/CROSSINGZONE_OCCUPIED;&#xA;        return state;&#xA;    }&#xA;    // if the digital read errs, return the current state so it re-runs&#xA;    return state;&#xA;}&#xA;&#xA;boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState_t relayState)    {&#xA;&#xA;    int testInt = 0;&#xA;    if (relayState == /*RelayState::*/RELAY_OFF)&#xA;    {&#xA;        testInt = 1;&#xA;    }&#xA;    digitalWrite(relayNumber, relayState);&#xA;    if (digitalRead(relayNumber) == testInt) {&#xA;        return true;&#xA;    };&#xA;    return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, if you want to avoid the use of typedef, you can use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };&#xA;enum CrossingZoneState: uint8_t {&#xA;    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state&#xA;    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor&#xA;    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear&#xA;};&#xA;&#xA;enum CrossingZoneState CheckEntrySensor(uint8_t esp) ;&#xA;boolean throwRelayAndCheckStatus(uint8_t relayNumber, enum RelayState relayState) ;&#xA;&#xA;&#xA;enum CrossingZoneState CheckEntrySensor(uint8_t esp) {&#xA;    enum CrossingZoneState state ;&#xA;    //esp, short for entry sensor pin&#xA;    if (digitalRead(esp) == HIGH)&#xA;    {&#xA;        state = CROSSINGZONE_CLEAR;&#xA;        return state;&#xA;    }&#xA;    else if (digitalRead(esp) == LOW)&#xA;    {&#xA;        state = CROSSINGZONE_OCCUPIED;&#xA;        return state;&#xA;    }&#xA;    // if the digital read errs, return the current state so it re-runs&#xA;    return state;&#xA;}&#xA;&#xA;boolean throwRelayAndCheckStatus(uint8_t relayNumber, enum RelayState relayState)    {&#xA;&#xA;    int testInt = 0;&#xA;    if (relayState == RELAY_OFF)&#xA;    {&#xA;        testInt = 1;&#xA;    }&#xA;    digitalWrite(relayNumber, relayState);&#xA;    if (digitalRead(relayNumber) == testInt) {&#xA;        return true;&#xA;    };&#xA;    return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19886" LastEditorUserId="19886" LastEditDate="2016-04-19T10:08:07.350" LastActivityDate="2016-04-19T10:08:07.350" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23280" PostTypeId="2" ParentId="23274" CreationDate="2016-04-18T20:51:41.790" Score="0" Body="&lt;p&gt;your power supply may be faulty. try a another power supply which can supply more current and common the GND of arduino and power suply..it may have internal short circuit or lack of current. &lt;/p&gt;&#xA;" OwnerUserId="20296" LastActivityDate="2016-04-18T20:51:41.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23281" PostTypeId="1" CreationDate="2016-04-18T20:57:30.633" Score="-1" ViewCount="3428" Body="&lt;p&gt;Could anyone help me for a good free arduino uno simulation software for windows.Hope I get an answer.&lt;/p&gt;&#xA;" OwnerUserId="20270" LastActivityDate="2016-04-20T21:19:32.457" Title="Arduino uno simulation software for windows" Tags="|simulator|" AnswerCount="1" CommentCount="1" ClosedDate="2016-04-19T05:24:16.973" ContentLicense="CC BY-SA 3.0" />
  <row Id="23282" PostTypeId="2" ParentId="23278" CreationDate="2016-04-18T20:57:41.213" Score="0" Body="&lt;p&gt;you can use transistor bias circuit, opto-couples circuits, op amp circuit or a simple relay circuit, to get 5V output signal when 12V-36V signal is triggered. &lt;/p&gt;&#xA;" OwnerUserId="20296" LastActivityDate="2016-04-18T20:57:41.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23284" PostTypeId="2" ParentId="23281" CreationDate="2016-04-18T21:08:40.897" Score="-1" Body="&lt;p&gt;Autodesk offers a service called 123D Circuits which works in a web browser provided you have an Autodesk account. It allows you to construct (simple) virtual circuits and run code on a virtual Arduino Uno. Regrettably, it doesn't offer very much in the way of diagnostics tools, isn't open source, and won't work offline. The advantage of a service like this is that it requires no installation and is functional for simple setups with a few components. It can be found at &lt;a href=&quot;http://123d.circuits.io&quot; rel=&quot;nofollow&quot;&gt;123d.circuits.io&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20273" LastEditorUserId="20273" LastEditDate="2016-04-20T21:19:32.457" LastActivityDate="2016-04-20T21:19:32.457" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23285" PostTypeId="2" ParentId="23278" CreationDate="2016-04-18T22:02:24.130" Score="1" Body="&lt;p&gt;Even easier: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;input - series 220 ohm resistor, and a 78L05 voltage regulator (check for maximum voltage). This allows you handling like 4..30V and get a solid &quot;1&quot; on digitalRead. (4V input makes like 3V output which is still logic high).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-18T22:02:24.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23286" PostTypeId="2" ParentId="23245" CreationDate="2016-04-18T22:12:21.030" Score="4" Body="&lt;p&gt;It was a brownout fuse problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing &lt;code&gt;boards.txt&lt;/code&gt; from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;atmega328bb.bootloader.extended_fuses=0x05&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;atmega328bb.bootloader.extended_fuses=0x02&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;solved it for me (*).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chip and red LED now work at 3.01V  (1xAA alkaline and 1xAA rechargeable) and 3.19V (2xAA alkaline).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) not sure why I had to invert the bits (&lt;code&gt;0000 0010&lt;/code&gt;=0x02 versus &lt;code&gt;0000 0101&lt;/code&gt;=0x05) when compared to the tables below.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TZjQh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TZjQh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kedG0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kedG0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19579" LastActivityDate="2016-04-18T22:12:21.030" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23287" PostTypeId="1" AcceptedAnswerId="23292" CreationDate="2016-04-18T23:34:41.587" Score="0" ViewCount="395" Body="&lt;p&gt;Hello I want to know how to split an incoming serial message that comes in this format CxxxLxxx, x=number, so i can take the 3 numbers after the C and save them and then take the 3 numbers after the L and also save it, i have a code for this but it doesn't always work, can anyone tell me where I´m wrong or is the approach I´m taking is not the right one. Thanks.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int value = 0;&#xA;int channel;&#xA;int x;&#xA;String str;&#xA;int y;&#xA;String str1;&#xA;int le;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;if (Serial.read() == le)&#xA;{ }&#xA;  else&#xA;       {&#xA;        str = Serial.readStringUntil('C');&#xA;        str1 = Serial.readStringUntil('L');&#xA;        channel = Serial.parseInt();&#xA;        value = Serial.parseInt();&#xA;      DmxSimple.write(channel, value);&#xA;      le = Serial.read();&#xA;      Serial.println();&#xA;&#xA;       }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20299" LastActivityDate="2016-04-20T12:21:41.207" Title="Receiving serial data in acsii, how to split it." Tags="|arduino-uno|serial|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23288" PostTypeId="1" CreationDate="2016-04-18T23:43:40.427" Score="0" ViewCount="2144" Body="&lt;p&gt;I am using Arduino Uno board with Windows 10. From the tutorials on Arduino website, I am trying to upload the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  int sensorValue = analogRead(A0);&#xA;  Serial.println(sensorValue);&#xA;  delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It had undergone a series of issues:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First,&#xA;&lt;code&gt;avrdude: ser_open(): can't open device &quot;\\.\com3&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched for his issue, and found that most common solution id to go to device manager and change the name of the port, then unplug and plug again the arduino board. I did that&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Program Files (x86)\Arduino\hardware\tools\axr\bin\avr-ar:&#xA;unable to rename 'core.a'; reason: file exists\\&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I thiught it could be a memory problem. I used the reset button on the board, and repeated steps from the solution to the first problem. I tried to upload the code again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But now, I am not getting any error message. But the problem is that it is taking forever to upload the code. I see &lt;code&gt;Uploading...&lt;/code&gt; status since a long while. The green progress bar is also complete, but no uploading completed till now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help to understand and solve this will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="20300" LastActivityDate="2016-07-18T04:58:18.943" Title="Arduino sketch taking forever to upload, followed by multiple issues" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23289" PostTypeId="1" AcceptedAnswerId="23290" CreationDate="2016-04-19T00:00:29.020" Score="1" ViewCount="594" Body="&lt;p&gt;I'm a software engineer, but I'm not too skilled at understanding hardware design yet. I'm trying to learn how to use an Arduino Pro Mini board without the programmer connected, so I can actually make fun toys, etc. Currently, the software will only run when connected to the programmer (or at a minimum with the SCK pins connected to each other). I have been searching online for days, and I think I need a crystal or resonator hooked up somehow, but I can't figure out how to hook them up (which pins). I bought 5 16 MHz ceramic resonators, and I have them right here with me, but I can't find the answers online how to hook it up and have the board run stand alone. Any ideas? Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="20046" LastActivityDate="2016-04-19T00:19:47.293" Title="How to use Arduino Pro Mini without Programmer" Tags="|arduino-pro-mini|wires|programmer|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23290" PostTypeId="2" ParentId="23289" CreationDate="2016-04-19T00:19:47.293" Score="3" Body="&lt;p&gt;You might be on the wrong track.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do need a crystal (or not, it depends on), and an Atmel programmer if you want to program an empty chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, all Arduino boards come with a chip pre-programmed with a bootloader.&#xA;Then it is rather easy: you need an FTDI cable to connect the board to a PC. Then run Arduino IDE on the PC. (The FTDI cable is actually an USB-to-serial converter.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE lets you edit a C like code, complile it to binary, and send it out via the FTDI cable to the serial port (Rx, Tx) of the board. The microcontroller on the board comes with a bootloader. Bootloader is a small program which runs at power up, and will receive the data from the computer and put your program to the microcontroller. Then your program will run on the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you don't need an external programmer.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the other hand, you may consider picking a different Arduino board. Arduino Micro, or Pololu A-star Micro (for half of the price of the Arduino Micro) offers a board with a direct USB connection. All you need is one USB cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These boards come with a much better microcontroller (32u4) which has a hardware USB connection (allowing you to make a mouse or a keyboard, and control PC (such as buttonbass.com) from your gadget).&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-19T00:19:47.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23291" PostTypeId="2" ParentId="16572" CreationDate="2016-04-19T00:36:38.407" Score="1" Body="&lt;p&gt;Yes it is possible, of course everything is possible!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These drivers need two IO lines at very minimum: DIR and STEP. Pulsing STEP makes one step movement forward or backwards (depending on DIR). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 6 steppers you need therefore 12 outputs from Arduino. (Which Arduino please? pick one which has enough IO, or otherwise use an I2C output extender).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;M0 and M1 controls microstepping mode - configure at your wish. CFG is high on this Pololu board, allowing the board to use as a stepper driver out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steppers (if you want to get them working at full torque) require a constant-current drive. (Inexpensive solutions use a constant voltage drive, such as using an ULN2803 - however those can not get too much torque). Happily this driver can do this well, the potentiometer sets the maximum current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Steppers need considerable current when starting movement to a next step. However, unlike DC motors, even a still position will consume current, which eventually makes the motor hot. Therefore you are supposed to limit the current when the motor is &lt;em&gt;not&lt;/em&gt; moving. This is usually done from software (the driver does not known when it is time for a long period at stop).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way for limiting motor current at stop can be either an analog limiter, or a PWM. This driver has no dedicated input for this purpose. You can do two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use smaller drive current (use the potentiometer) - this can work well if you're satisfied with the torque&lt;/li&gt;&#xA;&lt;li&gt;use the sleep mode of the driver with a PWM from the Arduino side.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This latter solution needs you to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connect all EN pins of all 6 drivers, and connect it to one Arduino pin which has PWM (i.e. &lt;code&gt;analogWrite()&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;drive this to 0, then start movements&lt;/li&gt;&#xA;&lt;li&gt;once movements are finished, use &lt;code&gt;analogWrite()&lt;/code&gt; and set to say, 128 (usually half of the move current is a good guess for holding current)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This way when the motors are stopped, the holding current will be less, hence the motors don't get hot.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="26916" LastEditDate="2017-09-09T07:55:55.117" LastActivityDate="2017-09-09T07:55:55.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23292" PostTypeId="2" ParentId="23287" CreationDate="2016-04-19T00:47:28.223" Score="0" Body="&lt;p&gt;This:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (Serial.read() == le)&#xA;{ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;looks very suspicious - sometimes it can read the C or L and therefore render the rest of your code useless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also Serial.parseInt shall be avoided - it returns the first thing which looks like a number, and will not wait for all three numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, your problem is likely the DMX write speed. While the DmxSimple.write is getting executed, no new incoming message can be processed. Depending on your actual Arduino board and chip, there is some buffer, but the solution is not rocket-proof at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make a solid protocol between the PC and the Arduino, i.e. the PC sends one command, arduino sends it out over the DMX, and Arduino answers an OK to the PC. The PC will not send out any new command unless it has received an OK first.&lt;/li&gt;&#xA;&lt;li&gt;avoid these ad-hoc mess, i.e. serial-reads and serial.printlns here-and there.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, if you change the protocol so: CxxxLxxxE (E stands for end) you can utilize readStringUntil to read the input until a separator, and then use the toInt method to actually convert the read data to integer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    strDummy = Serial.readStringUntil('C');&#xA;    strC = Serial.readStringUntil('L'); // xxx from CxxxL&#xA;    strL = Serial.readStringUntil('E'); // xxx from LxxxE&#xA;    channel = strC.toInt();&#xA;    value = strL.toInt();&#xA;    DmxSimple.write(channel, value);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;After learning that it is not possible to change the protocol, here is a new plan&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int channel;&#xA;int value;&#xA;void loop() {&#xA;    if (Serial.read()=='C') { // wait for a C&#xA;        channel=Serial.parseInt(); // parse till first non-number&#xA;        value=Serial.parseInt(); // parse till first non-number&#xA;        DmxSimple.write(channel, value);&#xA;    }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ReadASCIIString&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ReadASCIIString&lt;/a&gt; for a tutorial. Note that Arduino Serial commands are pretty confusing sometimes :) for example, parseInt will actually consume one non-number character implicitly after parsing a number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that this solution works well if the command is sent as one batch. If you are trying to send the command manually, e.g. from a terminal window, character by character, parseInt may time out. Consider increasing the timeout to 10 seconds or more by &lt;a href=&quot;https://www.arduino.cc/en/Serial/SetTimeout&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/SetTimeout&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="19152" LastEditDate="2016-04-20T12:21:41.207" LastActivityDate="2016-04-20T12:21:41.207" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23293" PostTypeId="1" CreationDate="2016-04-19T01:15:09.783" Score="3" ViewCount="1014" Body="&lt;p&gt;I am an undergraduate student at a public university in Maryland. I am currently doing a project with an arduino and I came across a problem that I could not figure out after several days of researching. Regarding my project, I am trying to collect 6 data (acceleration and gyration in x,y,z) from an accelerometer/gyroscope sensor at a desired constant rate (trying to make it 1000 Hz, so about 1000 sets of the 6 data per second) into a SD card. However, I could not make the arduino do this; I am able to collect the data, but not at a constant sampling frequency of 1000 Hz. Could someone help me set the sampling frequency at 1000 Hz please. Here are some of the information of the sensors and arduino I am using:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino nano &lt;/li&gt;&#xA;&lt;li&gt;MPU-6050 gy-521 accelerometer/gyroscope - &lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/MPU-6050&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;SD card reader - &lt;a href=&quot;http://www.aliexpress.com/item/SD-Card-Reader-Module-for-Arduino-ARM-Read-and-Write-Free-shipping/526750081.html?spm=2114.12010108.1000023.4.JkncUu&amp;amp;spm=2114.12010108.1000023.4.JkncUu&quot; rel=&quot;nofollow&quot;&gt;http://www.aliexpress.com/item/SD-Card-Reader-Module-for-Arduino-ARM-Read-and-Write-Free-shipping/526750081.html?spm=2114.12010108.1000023.4.JkncUu&amp;amp;spm=2114.12010108.1000023.4.JkncUu&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Also, I have posted my code. Thank you in advance for the help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;unsigned long time;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;MPU6050.h&quot;&#xA;MPU6050 accelgyro;&#xA;#define OUTPUT_READABLE_ACCELGYRO&#xA;&#xA;const int sdcard = 7;&#xA;int num;&#xA;int16_t ax,ay,az,gx,gy,gz;&#xA;LiquidCrystal lcd(10, 9, 5, 4, 3, 2); //12 is 10 and 11 is 9&#xA;&#xA;void setup() &#xA;{&#xA;    Serial.begin(115200);&#xA;    lcd.begin(16, 2);&#xA;    pinMode(8, INPUT_PULLUP);&#xA;    Serial.print(&quot;Initializing SD card...&quot;);&#xA;    if (!SD.begin(sdcard)) &#xA;    {&#xA;        Serial.println(&quot;initialization failed!&quot;);&#xA;        return;&#xA;    }&#xA;    Serial.println(&quot;initialization done.&quot;);&#xA;    accelgyro.initialize();&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;Push button&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;to start&quot;);&#xA;    int sensorVal = digitalRead(8);&#xA;    if (sensorVal == 0)&#xA;    {&#xA;        delay(500);&#xA;        num = 1;&#xA;        collect();&#xA;    }&#xA;}&#xA;&#xA;void collect()&#xA;{             &#xA;    File myFile = SD.open(&quot;test.txt&quot;,FILE_WRITE);&#xA;    myFile.println(&quot;Begin:&quot;);&#xA;    myFile.print(&quot;x-axis  &quot;);&#xA;    myFile.print(&quot;y-axis  &quot;);&#xA;    myFile.print(&quot;z-axis &quot;);&#xA;    myFile.print(&quot;\n&quot;);&#xA;&#xA;    Serial.println(&quot;Begin:&quot;);&#xA;    Serial.print(&quot;x-axis: &quot;);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(&quot;y-axis: &quot;);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(&quot;z-axis: &quot;);&#xA;    Serial.print(&quot;\n&quot;);&#xA;&#xA;    if(myFile)&#xA;    {&#xA;        while (num == 1)&#xA;        {&#xA;            accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;            lcd.setCursor(0,0);&#xA;            lcd.print((double) ax/16384*9.81);&#xA;            lcd.setCursor(7,0);&#xA;            lcd.print((double) ay/16384*9.81);&#xA;            lcd.setCursor(0,1);&#xA;            lcd.print((double) az/16384*9.81);&#xA;            lcd.setCursor(7,1);&#xA;            lcd.print(time);&#xA;&#xA;            time = millis();&#xA;&#xA;            Serial.print(&quot;Time: &quot;);&#xA;            Serial.println(time);&#xA;            Serial.print(ax);&#xA;            Serial.print(&quot;\t&quot;);&#xA;            Serial.print((double) ax/16384*9.81);&#xA;            Serial.print(&quot;\t&quot;); &#xA;            Serial.print(ay);&#xA;            Serial.print(&quot;\t&quot;); &#xA;            Serial.print((double) ay/16384*9.81);  &#xA;            Serial.print(&quot;\t&quot;);   &#xA;            Serial.print(az); &#xA;            Serial.print(&quot;\t&quot;); &#xA;            Serial.print((double) az/16384*9.81);&#xA;            Serial.print(&quot;\n&quot;);&#xA;&#xA;            myFile.print(&quot;Time: &quot;);&#xA;            myFile.println(time);&#xA;            myFile.print(ax);&#xA;            myFile.print(&quot;\t&quot;);&#xA;            myFile.print(ay);&#xA;            myFile.print(&quot;\t&quot;);   &#xA;            myFile.println(az); &#xA;&#xA;            int sensorVal = digitalRead(8);&#xA;            if(sensorVal == 0)&#xA;            {&#xA;                delay(500);&#xA;                num = 0;&#xA;                Serial.println(&quot;STOPPED&quot;);&#xA;                myFile.println(&quot;STOPPED&quot;);&#xA;                Serial.print(&quot;\n&quot;);&#xA;                myFile.print(&quot;\n&quot;);&#xA;                myFile.close();&#xA;                lcd.clear();&#xA;                lcd.setCursor(0,0);&#xA;                lcd.print(&quot;Stopped&quot;);&#xA;                delay(2000);&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20302" LastEditorUserId="20645" LastEditDate="2016-05-16T16:51:46.480" LastActivityDate="2016-05-16T17:16:08.953" Title="Sampling frequency" Tags="|sensors|c++|arduino-nano|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23294" PostTypeId="2" ParentId="19655" CreationDate="2016-04-19T01:48:10.073" Score="0" Body="&lt;p&gt;you can try this website for more information&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://wiki.micropython.org/official-accessories/Bluetooth-module-HC05&quot; rel=&quot;nofollow&quot;&gt;http://wiki.micropython.org/official-accessories/Bluetooth-module-HC05&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20304" LastActivityDate="2016-04-19T01:48:10.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23295" PostTypeId="1" CreationDate="2016-04-19T01:57:29.233" Score="4" ViewCount="6510" Body="&lt;p&gt;I am using an Arduino Mega board with a SIM900 GSM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to be able to text the GSM with a value of two digits (ex: 79) and then store that value as a variable in the code. I know how to set up the Mega and the GSM in terms of wiring and initialization of ports, but how would I write a short function to test the incoming values and save them to a variable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought about testing each bit individually, storing each one as a separate variable, and then adding them for the total. For example, if the GSM received &quot;#79&quot; as a text I stored the value 7 as an integer variable named &lt;code&gt;One&lt;/code&gt; and the value 9 as an integer variable named &lt;code&gt;Two&lt;/code&gt;. Then I did &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Total = (One*10)+Two. &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am posting my code below that used this method, although it has not proved to be useful. If anyone has any suggestions I would greatly appreciate it.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;   //GSM Library &#xA;&#xA;int Max_temp;                  &#xA;float threshold;                   &#xA;&#xA;SoftwareSerial SIM900(18, 19);                &#xA;String destinationNumber = &quot;+17186578989&quot;;  &#xA;String outMessage1 = &quot;Please enter the maximum desired room temp&quot;;  &#xA;char inchar; // Will hold the incoming character from the GSM shield when user texts it &#xA;int M_one;&#xA;int M_zero;&#xA;void GSM_SEND_MAX();            &#xA;void GSM_RECEIVE_MAX();       &#xA;&#xA;void setup() &#xA;{&#xA;   Serial.begin(9600); &#xA;&#xA;//GSM setup:                       &#xA;  Serial1.begin(19200);  // wake up the GSM shield&#xA;  delay(20000); // give time to log on to network.&#xA;  Serial1.print(&quot;AT+CMGF=1\r&quot;); // set SMS mode to text&#xA;  delay(100);&#xA;  Serial1.print(&quot;AT+CNMI=2,2,0,0,0\r&quot;); // blurt out contents of new SMS upon receipt to the GSM shield's serial out&#xA;  delay(100);&#xA;}// end void set up() &#xA;&#xA;&#xA;&#xA;&#xA;void loop() &#xA;{&#xA;  GSM_SEND_MAX();&#xA;  GSM_RECEIVE_MAX();&#xA;}// end void loop ()&#xA;&#xA;/////Functions &#xA;void GSM_SEND_MAX()       &#xA;{&#xA;  Serial.println(&quot;sending text&quot;);    &#xA;  Serial1.begin(19200); &#xA;  delay(20000); // give time to log on to network.&#xA;  Serial1.print(&quot;AT+CMGF=1\r&quot;);&#xA;  delay(1000);&#xA;  Serial1.println(&quot;AT + CMGS = \&quot;&quot; + destinationNumber +&quot;\&quot;&quot;);&#xA;  delay(1000);&#xA;  Serial1.print(outMessage1);&#xA;  delay(1000);&#xA;  Serial1.write((char)26); //ctrl+z&#xA;  delay(1000);&#xA;  Serial.println(&quot;send text&quot;);&#xA;}//end GSM_SEND_MAX funtion &#xA;&#xA;void GSM_RECEIVE_MAX()        &#xA;{&#xA;  //If a character comes in from the cellular module...&#xA; while (Serial1.peek() != '#' )   &#xA;   {&#xA;    inchar=Serial1.read();      &#xA;    Serial.print(&quot;bad char &quot;);   &#xA;    Serial.println(inchar);     &#xA;    delay(500);&#xA;   }// end while #1 &#xA;&#xA; inchar=Serial1.peek();            &#xA; Serial.println(&quot;out of loop 1&quot;);   &#xA; Serial.println(inchar);           &#xA;&#xA; while (Serial1.available() != 0) //While #2 reads incoming char &#xA; {&#xA;    Serial.println(&quot;in loop 2&quot;);  &#xA;    inchar=Serial1.read();       &#xA;&#xA;if (inchar=='#')             &#xA;  {&#xA;  delay(10);&#xA;  Serial.print(&quot;got #&quot;);    &#xA;  M_one=Serial1.read();    &#xA;&#xA;  if (M_one &amp;gt;= 0 )&#xA;  {&#xA;  delay(10);&#xA;  Serial.println();&#xA;  Serial.print(&quot;got M_one&quot;);   &#xA;  Serial.print(M_one);&#xA;  M_zero=Serial1.read();   &#xA;&#xA;      if (M_zero &amp;gt;= 0)&#xA;      {&#xA;          Serial.println();&#xA;          Serial.print(&quot;got M_zero&quot;);  &#xA;          Serial.print(M_zero); &#xA;&#xA;       }//end m_zero &#xA;&#xA;  }//end m_one &#xA;  Max_temp = (M_one *10) + M_zero; &#xA;&#xA;  Serial.println();&#xA;  Serial.print(&quot;Max_temp=&quot;);&#xA;  Serial.print(Max_temp); &#xA;&#xA;  } //end if (inchar==#)&#xA;&#xA; }// end while #2 loop  &#xA;}//end GSM_RECEIVE_MAX function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20305" LastEditorUserId="6936" LastEditDate="2016-04-19T08:21:55.400" LastActivityDate="2018-02-17T06:04:23.097" Title="Arduino GSM receiving text and then storing value as a variable in code" Tags="|arduino-mega|gsm|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23297" PostTypeId="2" ParentId="23288" CreationDate="2016-04-19T03:19:08.560" Score="1" Body="&lt;p&gt;When the Arduino IDE says its uploading but never uploads, it is most likely a COM port issue. Try plugging the Arduino in a different port and make sure you change the port in the IDE. The problem seems to be you have changed the Arduino port, but not in the IDE. The Arduino IDE registers the previous port as open and tries to upload the program to that port. Go to &lt;code&gt;Tools &amp;gt; Serial Port&lt;/code&gt; and it should list the ports(example):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;COM 2&#xA;COM 3&#xA;Arduino Uno at COM 4&#xA;•COM 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Every time you unplug and replug the Arduino you should check your ports and select the appropriate one ( It usually says &lt;code&gt;Arduino *type* at COM *port number*&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;COM 2&#xA;COM 3&#xA;•Arduino Uno at COM 4&#xA;COM 5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16094" LastActivityDate="2016-04-19T03:19:08.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23301" PostTypeId="1" CreationDate="2016-04-19T05:49:59.603" Score="0" ViewCount="137" Body="&lt;p&gt;I am a beginner in Arduino. Below is my code to propel the fans of my motor. This happens in a clockwise direction but I wish to change the direction of rotation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I modify it? &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;// Declare the pin for the motor&#xA;int motorPin = 9;&#xA;&#xA;void setup() {&#xA;  // Define pin #9 as output&#xA;  pinMode(motorPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // Turn motor on&#xA;  digitalWrite(motorPin, HIGH);&#xA;  // Wait 250 ms&#xA;  delay(250);&#xA;  // Reanimate motor&#xA;  digitalWrite(motorPin, HIGH);&#xA;  // Wait 250 ms&#xA;  delay(250);&#xA;  // Turn motor off.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20314" LastEditorUserId="6936" LastEditDate="2016-04-19T08:17:56.320" LastActivityDate="2016-04-19T12:56:52.230" Title="Arduino motor rotation" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23303" PostTypeId="1" CreationDate="2016-04-19T08:21:10.053" Score="0" ViewCount="3656" Body="&lt;p&gt;Iam working with gyroscope and Iam trying to send its values from one bluetooth(HC-05) module to another bluetooth module but the data exchange is not happening and I have used 2 arduino boards to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a simple way to do it? &lt;/p&gt;&#xA;" OwnerUserId="20317" LastActivityDate="2016-04-20T13:19:41.673" Title="exchanging data between two hc05 bluetooth modules" Tags="|arduino-uno|bluetooth|gyroscope|hc-05|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23304" PostTypeId="1" CreationDate="2016-04-19T08:50:32.077" Score="2" ViewCount="1922" Body="&lt;p&gt;I want to be able to display what I am seeing on the serial monitor onto the LCD keypad shield I have connected to my Arduino UNO. Can someone possibly write the the code ontop of this for me?&#xA;I'm very new to coding so I apologies if it's hard for anyone to understand what i'm asking for.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13; // LED is attached to digital pin 13&#xA;int x = 0; // variable to be updated by the interrupt&#xA;&#xA;//variables to keep track of the timing of recent interrupts&#xA;unsigned long button_time = 0;  &#xA;unsigned long last_button_time = 0; &#xA;&#xA;void setup() {                &#xA;  //enable interrupt 0 which uses pin 2&#xA;  //jump to the increment function on falling edge&#xA;  attachInterrupt(0, increment, FALLING);&#xA;  Serial.begin(9600);  //turn on serial communication&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(ledPin, LOW);&#xA;  delay(500); //pretend to be doing something useful&#xA;  Serial.println(x, DEC); //print x to serial monitor&#xA;}&#xA;&#xA;// Interrupt service routine for interrupt 0&#xA;void increment() {&#xA;  button_time = millis();&#xA;  //check to see if increment() was called in the last 250 milliseconds&#xA;  if (button_time - last_button_time &amp;gt; 250)&#xA;  {&#xA;    x++;&#xA;    digitalWrite(ledPin, HIGH);&#xA;    last_button_time = button_time;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20306" LastEditorUserId="19513" LastEditDate="2016-04-19T12:39:19.127" LastActivityDate="2016-04-19T12:39:19.127" Title="How do I display serial monitor on LCD keypad shield?" Tags="|arduino-uno|lcd|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23305" PostTypeId="1" CreationDate="2016-04-19T08:52:48.603" Score="3" ViewCount="1033" Body="&lt;p&gt;I have a few questions related to GPRS/GSM SIM900 Shield not working with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To keep it short I have a list of concrete questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is the Arduino GSM library compatible with the &lt;a href=&quot;http://eud.dx.com/product/geeetech-gprs-gsm-sim900-shield-board-for-arduino-green-844377853#.VxXuxTCF6hd&quot; rel=&quot;nofollow&quot;&gt;Geeetech GPRS/GSM SIM900 Shield&lt;/a&gt;?&lt;/li&gt;&#xA;&lt;li&gt;On the board the green LED blinks every 3 seconds which I have read&#xA;means that it is connected. However, when I try to use any of the&#xA;GSM examples, in regard to internet, I either get error messages or&#xA;simply no progress in the program. For instance, in the &lt;code&gt;testGPRS&lt;/code&gt;&#xA;sketch it sits stuck at the port where it says &quot;Connecting GSM&#xA;network...&quot;. And in the &lt;code&gt;bandManagement&lt;/code&gt; example sketch it can't find&#xA;the current band,as well as the modem not responding, well basically nothing works, except that the&#xA;shield itself indicates it is connected to a network.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The SIM card I'm using is data exclusively and can't be used for voice calls or SMS. It has no pin code and works as my secondary SIM card (it shares the same subscription as my primary card).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;I have now tested the SMS capabillities of the board with another simcard, that works with no problems, seems only the internet won't work.&lt;/p&gt;&#xA;" OwnerUserId="20318" LastEditorUserId="20318" LastEditDate="2016-04-19T18:19:57.183" LastActivityDate="2016-04-19T18:19:57.183" Title="GPRS/GSM SIM900 Shield not working with Arduino" Tags="|gsm|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23307" PostTypeId="1" CreationDate="2016-04-19T09:18:19.250" Score="0" ViewCount="6576" Body="&lt;p&gt;I am trying to send packets of via bluetooth data that include 6 bytes read from a sensor and stored in a uint8_t array. Instead of sending over the data as numerical digital, I would like to send the ASCII character of each of the bytes. I am doing this to reduce the size of my data packets and make it easier to interpret the incoming data. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t* temp = readBufferData(FIFO);&#xA;&#xA;for (int i = 0; i &amp;lt; 6; i++)&#xA;{&#xA;    Serial.write(temp[i]);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Read buffer data returns a pointer to a uint8_t array read from a FIFO buffer.&#xA;When I use Serial.print, I get the following output, which makes sense.&#xA;22163226094255&#xA;One question is, when I use Serial.print on a single character, is it transmitted a single byte, or is it actually sending the decimal digital of the number, anywhere from 1-3 bytes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use the Serial.write, however, I get something like the following&#xA;DÿÂ?ÁÏ?ÌÆ?Ûµ?Ë½?ÔÀ?Ð¿?ÃÕÓÑËÐTÿÀ?Ï3ÿÉ?¹4ÿÐ?Ê&amp;lt;ÿ½?µfÿ¼?ìNÿÐ?×Â?ÊÚ?×¿?Å&#xA;Also, these data display much more slowly on the screen, than normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I send each uint8_t value by sending over the corresponding ASCII character for serial transmission?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="16549" LastEditorUserId="16549" LastEditDate="2016-04-19T09:45:49.590" LastActivityDate="2017-02-13T16:58:21.320" Title="Convert uint8_t array to ascii character for serial transmission" Tags="|bluetooth|code-optimization|data-type|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23308" PostTypeId="2" ParentId="23307" CreationDate="2016-04-19T09:26:43.690" Score="2" Body="&lt;p&gt;You don't &quot;convert&quot; anything. A character is just a human representation of an 8-bit value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you just need to change what the compiler thinks the data represents (from a human perspective).  The simplest way of doing that is to either cast the uint8_t values to be char values, or to write each one individually as a raw value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The latter way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myBluetoothSerial.write(myData[0]);&#xA;myBluetoothSerial.write(myData[1]);&#xA;myBluetoothSerial.write(myData[2]);&#xA;myBluetoothSerial.write(myData[3]);&#xA;myBluetoothSerial.write(myData[4]);&#xA;myBluetoothSerial.write(myData[5]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, with a loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 6; i++) {&#xA;    myBluetoothSerial.write(myData[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or using a built-in variant of write that does the loop for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myBluetoothSerial.write(myData, 6);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-19T09:26:43.690" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23309" PostTypeId="2" ParentId="23307" CreationDate="2016-04-19T09:59:53.860" Score="-1" Body="&lt;p&gt;Try changing Baud Rate. Most of the time garbage like this happens because of difference in baud rates of transmitter serial device and receiver serial device.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-19T09:59:53.860" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23311" PostTypeId="1" AcceptedAnswerId="23312" CreationDate="2016-04-19T11:33:04.403" Score="1" ViewCount="3705" Body="&lt;p&gt;For some reason my servos keep burning out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is simple, if condition, rotate to 0 degrees, else rotate to 180.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, what that does to the motor is keep it in a constant struggle to stay in rotation 0 or 180, when there is no movement in between. Sure enough, leave it running for 1 hour, the motor burns out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!strcmp(&quot;1&quot;,output)){&#xA;    myservo.write(0);&#xA;}&#xA;else {&#xA;    myservo.write(180);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there something like myservo.release or something? I presuming i need to get the servo in to position, then release it so it doesnt try to stay in position. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help, i've burned through 4-5 of them so far, it's not fun :(&lt;/p&gt;&#xA;" OwnerUserId="16593" LastActivityDate="2021-02-01T05:35:33.377" Title="Burning servos like crazy, what am I doing wrong?" Tags="|servo|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23312" PostTypeId="2" ParentId="23311" CreationDate="2016-04-19T12:50:33.810" Score="5" Body="&lt;p&gt;Some servos are actually not able to do full 0..180 rotation - or to rephrase it better, the standard 0.5ms and 1.5ms pulse will force them to a position which can not be reached. Therefore the motor keeps on rotating in a constant struggle.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;change 0 to something like 20, and 180 to something like 150&lt;/li&gt;&#xA;&lt;li&gt;check that the motor has stopped once reaching 20 or 150. I.e. it does not produce any sound, and if you touch the motor body it is not producing any vibration (so no constant stuggle)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-19T12:50:33.810" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23313" PostTypeId="2" ParentId="23301" CreationDate="2016-04-19T12:56:52.230" Score="1" Body="&lt;p&gt;I guess you have a DC motor in use. Likely a FET drives it on port 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This arrangement is enough to start or stop the motor, however to change direction, you need to swap the two wires on the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess you may perfer to do this in software - and for that you need to replace the simple FET driver with a H-Bridge. H-Bridge is an arrangement of electric switches which allows you swapping motor polarity, and it usually comes pre-assembled to a chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a vast amount of h-bridge motor driver chips to choose from. Google for &quot;pololu motor driver&quot;, or &quot;adafruit motor driver&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find all the further details in the Arduino examples on the web, e.g.:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/overview&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/overview&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-19T12:56:52.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23314" PostTypeId="2" ParentId="22018" CreationDate="2016-04-19T13:03:08.010" Score="1" Body="&lt;p&gt;Arduino Nano has its tx-rx serial port shared with the FTDI chip used by downloading and serial console. See &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&lt;/a&gt;&#xA;This means that if you drive these pins from ESP, it will flash leds, and all communication on these pins will interfere with serial monitor and board programming as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;disconnect ESP during program downloading&lt;/li&gt;&#xA;&lt;li&gt;pick a different board, which has a separate hardware serial port, such as Arduino Micro, Leonardo, or any Pololu A-star 32u4 boards, this way you have a dedicated serial port to control your ESP&lt;/li&gt;&#xA;&lt;li&gt;wire the tx-rx of ESP to two &lt;em&gt;other&lt;/em&gt; pins of your Arduino micro, and use a software serial library to bit-bang serial communication. (Note that serial receiving in software mode may require clever programming - since while your code does something &lt;em&gt;else&lt;/em&gt; it can not receive &lt;em&gt;anything&lt;/em&gt;).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-19T13:03:08.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23316" PostTypeId="2" ParentId="23272" CreationDate="2016-04-19T13:16:50.197" Score="2" Body="&lt;p&gt;The solution was to move the enum declarations to a header file, due to the fact this was a VM add-in issue which will be resolved once they've implemented arduino version 1.6.8. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding this code to a header file and removing it from the main file resolved the issues and the code builds and runs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ModelRRCrossing.h&#xA;&#xA;#ifndef _MODELRRCROSSING_h&#xA;#define _MODELRRCROSSING_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;    #include &quot;arduino.h&quot;&#xA;#else&#xA;    #include &quot;WProgram.h&quot;&#xA;#endif&#xA;#pragma once&#xA;// Arduino Digital I/O pin numbers for MEGA&#xA;//note: digital pins 30-45&#xA;//MEGA is a MUST for this project&#xA;enum {&#xA;    Relay1 = 30, Relay2 = 31, Relay3 = 32, Relay4 = 33, Relay5 = 34, Relay6 = 35,&#xA;    Relay7 = 36, Relay8 = 37, Relay9 = 38, Relay10 = 39, Relay11 = 40,&#xA;    Relay12 = 41, Relay13 = 42, Relay14 = 43, Relay15 = 44, Relay16 = 45&#xA;};&#xA;&#xA;enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };&#xA;enum class CrossingZoneState : uint8_t {&#xA;    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state&#xA;    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor&#xA;    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-19T13:16:50.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23317" PostTypeId="1" AcceptedAnswerId="23321" CreationDate="2016-04-19T13:36:45.033" Score="1" ViewCount="535" Body="&lt;p&gt;I was wondering if I could use a IR sensor with my Arduino to detect if someone is present in front of it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like, the emitter should emit continuously and if the receiver drop connection it should do something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will this work fine? or the emitter wide angle and a human body in front of it wont drop the signal? &lt;/p&gt;&#xA;" OwnerUserId="20324" LastEditorUserId="19513" LastEditDate="2016-04-19T18:48:40.673" LastActivityDate="2016-04-19T18:48:40.673" Title="Using IR Sensor to sense movement?" Tags="|arduino-uno|ir|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23318" PostTypeId="2" ParentId="23311" CreationDate="2016-04-19T13:41:10.633" Score="2" Body="&lt;p&gt;Ensure your voltage source matches the motors specs and that your wiring to the arduino or driver shield is correct and try the code I've posted which has worked for me to test servos.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;  // servo library&#xA;// You can control a maximum of twelve servos on the Uno &#xA;// using this library. (Other servo libraries may let you&#xA;// control more). Note that this library disables PWM on&#xA;// pins 9 and 10!&#xA;&#xA;Servo servo1;  // servo control object&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  //  Attach the servo1 object to digital pin 4.&#xA;  servo1.attach(4);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  int position;&#xA;  // Change position at full speed:&#xA;&#xA;  servo1.write(90);    // Tell servo to go to 90 degrees&#xA;  delay(1000);         // Pause to get it time to move&#xA;  servo1.write(180);   // Tell servo to go to 180 degrees&#xA;  delay(1000);         // Pause to get it time to move&#xA;  servo1.write(0);     // Tell servo to go to 0 degrees&#xA;  delay(1000);         // Pause to get it time to move&#xA;&#xA;  // Change position at a slower speed:&#xA;  // Tell servo to go to 180 degrees, stepping by two degrees&#xA;&#xA;  for(position = 0; position &amp;lt; 180; position += 2)&#xA;  {&#xA;    servo1.write(position);  // Move to next position&#xA;    delay(20);               // Short pause to allow it to move&#xA;  }&#xA;&#xA;  // Tell servo to go to 0 degrees, stepping by one degree&#xA;&#xA;  for(position = 180; position &amp;gt;= 0; position -= 1)&#xA;  {                                &#xA;    servo1.write(position);  // Move to next position&#xA;    delay(20);               // Short pause to allow it to move&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-19T13:41:10.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23319" PostTypeId="1" AcceptedAnswerId="23342" CreationDate="2016-04-19T13:46:58.657" Score="1" ViewCount="1808" Body="&lt;p&gt;I am using esp8266 to send a &lt;strong&gt;GET&lt;/strong&gt; Request but I am getting 408 Timeout error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of my output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6RY49.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6RY49.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20326" LastEditorUserId="19513" LastEditDate="2016-04-19T15:52:19.500" LastActivityDate="2016-04-20T01:21:10.463" Title="ESP8266 sending GET Request and getting 408 Timeout error" Tags="|arduino-uno|arduino-ide|esp8266|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23320" PostTypeId="2" ParentId="23317" CreationDate="2016-04-19T13:48:49.357" Score="0" Body="&lt;p&gt;This works quite fine !&#xA;The &quot;hardest&quot; part is isolating the IR beam and especially the receiver with anti-reflective paint or paper (ie : a small hole in a cardboard)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can make this by two (at least) ways :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;[IRled]         [human]          [IRreceiver]&lt;/li&gt;&#xA;&lt;li&gt;[IRled and receiver pointing the same way]       [human]        [mirror]&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The second way is what you find in auto-flushing toilet rooms. But if the human is wearing quite reflective clothes, this will fool the receiver.&#xA;This is great for long-range detection, but if you need a smaller range, go for the 1/.&lt;/p&gt;&#xA;" OwnerUserId="20325" LastActivityDate="2016-04-19T13:48:49.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23321" PostTypeId="2" ParentId="23317" CreationDate="2016-04-19T14:15:48.267" Score="1" Body="&lt;p&gt;This will work fine. The easiest way to do this is using &lt;strong&gt;IR Sensor Module&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/roE8n.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/roE8n.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will give you a digital output of whether there is someone in front of sensor or not. Use can use it as an Edge Trigger to detect Humans passing by.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can buy one. They are both cheap and easily available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can &lt;a href=&quot;http://www.instructables.com/id/DIY-Infrared-Sensor-Module/&quot; rel=&quot;nofollow noreferrer&quot;&gt;create your own&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastEditorUserId="19667" LastEditDate="2016-04-19T17:17:15.423" LastActivityDate="2016-04-19T17:17:15.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23324" PostTypeId="1" AcceptedAnswerId="23365" CreationDate="2016-04-19T15:36:13.570" Score="1" ViewCount="1000" Body="&lt;p&gt;I want to send a file from my Laptop using its own Bluetooth transmitter to Arduino. Arduino has HC-06 module as receiver.Arduino has SD Card fore store the file.&#xA;I was able to send bytes using Python application.&#xA;How to send a file using a Python application to Arduino?&lt;/p&gt;&#xA;" OwnerUserId="13536" LastActivityDate="2016-04-20T14:49:56.667" Title="Send a file from PC to Arduino using HC-06 module" Tags="|arduino-uno|python|hc-06|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23326" PostTypeId="1" CreationDate="2016-04-19T15:42:53.653" Score="2" ViewCount="4636" Body="&lt;p&gt;There are two problems to control digital servo(HD-1810MG) and HC-06 bluetooth module connection.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;When I put a specific number to servo(in the &lt;a href=&quot;https://youtu.be/L5o_dVs9VUc&quot; rel=&quot;nofollow noreferrer&quot;&gt;video&lt;/a&gt;, I put 45), it shakes too much and shows useless movements before get to the right angle. I have no clue why this happens. Should I add more code to control it correctly?&lt;br&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include SoftwareSerial.h&#xA;#include Servo.h&#xA;&#xA;Servo myServo;&#xA;int TxD = 10;&#xA;int RxD = 11;&#xA;SoftwareSerial bluetooth(TxD, RxD);&#xA;&#xA;void setup() {&#xA;  myServo.attach(9);&#xA;  Serial.begin(9600);       // start serial communication at 9600bps&#xA;  bluetooth.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (bluetooth.available()&amp;gt;0)&#xA;  {&#xA;    int servopos = bluetooth.read();&#xA;    Serial.println(servopos);&#xA;    myServo.write(servopos);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;I used Nexus 5X and apk app to pair with HC-06. It pairs well at the first time of connection, but it loose connection after servo moved once. Application said it is connected with bluetooth, but HC-06's LED is blinking(which means disconnected). How can I maintain connection with HC-06?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is my board.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/T2Wt4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/T2Wt4.png&quot; alt=&quot;arduino board image&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I made apk app using MIT App Inventor 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm so new to arduino and I'm not in major of engineering. Please give me an advice!&lt;/p&gt;&#xA;" OwnerUserId="20320" LastActivityDate="2016-10-17T16:00:32.607" Title="Having a problem to control digital servo with HC-06 bluetooth module" Tags="|bluetooth|servo|hc-06|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23327" PostTypeId="2" ParentId="23303" CreationDate="2016-04-19T15:45:04.610" Score="1" Body="&lt;p&gt;I think there is no simple answer for that. First you have to pair 2 HC-05 modules. To do so, you have to configure one HC-05 as slave, and other HC-05 as master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Steps for SLAVE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.&lt;/li&gt;&#xA;&lt;li&gt;Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)&lt;/li&gt;&#xA;&lt;li&gt;Note the values of &lt;code&gt;AT+PSWD?&lt;/code&gt;, &lt;code&gt;AT+NAME?&lt;/code&gt; and &lt;code&gt;AT+ADDR?&lt;/code&gt;(let's say 1111:22:123456) commands. You might set the password to 1234 for easy remembering. Issue &lt;code&gt;AT+PSWD=0000&lt;/code&gt;...&lt;/li&gt;&#xA;&lt;li&gt;Be sure to set the module to slave mode by issuing &lt;code&gt;AT+ROLE=0&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Steps for MASTER:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.&lt;/li&gt;&#xA;&lt;li&gt;Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)&lt;/li&gt;&#xA;&lt;li&gt;Reset the module to its original state by issuing &lt;code&gt;AT+ORGL&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;Remove the previous parings(if any) by issuing &lt;code&gt;AT+RMAAD&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;Set same password as slave by issuing &lt;code&gt;AT+PASSWD=0000&lt;/code&gt; command.&lt;/li&gt;&#xA;&lt;li&gt;Change the role to master; &lt;code&gt;AT+ROLE=1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Set connecting mode to any address it sees; &lt;code&gt;AT+CMODE=1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Initialize the SPP profile lib ; &lt;code&gt;AT+INIT&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Be sure that you see the slave HC-05 module, &lt;code&gt;AT+INQ&lt;/code&gt; command will list the modules you see.&lt;/li&gt;&#xA;&lt;li&gt;Be sure that you see address of the slave module(1111:22:123456).&lt;/li&gt;&#xA;&lt;li&gt;Last of all enter &lt;code&gt;AT+LINK=1111,22,123456&lt;/code&gt;(note the commas).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With these steps you should exchange data...&lt;/p&gt;&#xA;" OwnerUserId="20330" LastActivityDate="2016-04-19T15:45:04.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23328" PostTypeId="2" ParentId="23277" CreationDate="2016-04-19T16:52:12.073" Score="1" Body="&lt;p&gt;Ok, so more info from the OP:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;non-electrical engineering students needs a prototyping platform&lt;/li&gt;&#xA;&lt;li&gt;minimize possible damages, support hot plug-and-play&lt;/li&gt;&#xA;&lt;li&gt;not too expensive&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Dedicated connector&lt;/h2&gt;&#xA;&lt;p&gt;I suggest using standard subD9 connectors. Sensors shall have male pins, while the control board female socket (this makes very hard to do accidental short circuits on the control board). We were using these connectors in a daily basis in a lasershow system, and I was very statisfied. Inexpensive, easy to solder, works with a wide range of cables or separate wires.&lt;/p&gt;&#xA;&lt;p&gt;In many cases, you can integrate the sensor into the housing of the connector. For example, an IR receiver, an accelerometer, etc. fits well.&lt;/p&gt;&#xA;&lt;p&gt;You can use off-the-shelf serial cable extenders which makes it very versatile.&lt;/p&gt;&#xA;&lt;p&gt;Since it is a D shaped connector, there is only one possible way to connect a sensor to the mainboard, and we're golden.&lt;/p&gt;&#xA;&lt;h2&gt;Dedicated connector light&lt;/h2&gt;&#xA;&lt;p&gt;NSL25 and NSG25 are my favorites:&#xA;&lt;a href=&quot;http://www.soselectronic.hu/?str=371&amp;amp;artnum=4927&amp;amp;name=nsl-25-2-g&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.soselectronic.hu/?str=371&amp;amp;artnum=4927&amp;amp;name=nsl-25-2-g&lt;/a&gt;&lt;br /&gt;&#xA;&lt;a href=&quot;http://www.soselectronic.hu/?str=371&amp;amp;artnum=4934&amp;amp;name=-nsg-25-2&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.soselectronic.hu/?str=371&amp;amp;artnum=4934&amp;amp;name=-nsg-25-2&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Although these are inexpensive wire to board connectors, it is very hard to misconnect them. Criping is a PITA, but you can purchase pre-crimped connectors with wires such as &lt;a href=&quot;http://www.soselectronic.hu/?str=371&amp;amp;artnum=6175&amp;amp;name=-p-35003&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.soselectronic.hu/?str=371&amp;amp;artnum=6175&amp;amp;name=-p-35003&lt;/a&gt;&#xA;One 3 wire female connector with wires costs about 50 USD cent.&lt;/p&gt;&#xA;&lt;p&gt;Note though that in this case, the control board has the male connectors. By accidentally dropping a coin to the connector, or using a screwdriver, it is easy to run into short circuits. This leads us to the next plan...&lt;/p&gt;&#xA;&lt;h2&gt;Any inexpensive connector with proper electric protection&lt;/h2&gt;&#xA;&lt;p&gt;Probably the most inexpensive solution is to use standard headers and pins. Here you may also wish to buy ready made cables, than start crimping yourself:&#xA;&lt;a href=&quot;http://www.soselectronic.hu/?str=371&amp;amp;artnum=6171&amp;amp;name=-p-2543&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.soselectronic.hu/?str=371&amp;amp;artnum=6171&amp;amp;name=-p-2543&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This however opens up a can of worms of misconnection:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connection by one or multiple pin off&lt;/li&gt;&#xA;&lt;li&gt;connection in reverse direction&lt;/li&gt;&#xA;&lt;li&gt;shorting the pins on the board&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Against sorting, you shall have a multifuse on the power pins, say, 250mA. On each IO pin, you shall have a series resistor of 470 ohm, this ensures that no miswiring can destroy the Arduino.&lt;/p&gt;&#xA;&lt;p&gt;On the sensor-side, things are a little more tricky. You need a shottky (or an equivalent P fet diode) to ensure that reverse polarity connection will not destroy your sensor. If the sensor has output pins, also use a series 470 ohm resistor.&lt;/p&gt;&#xA;&lt;p&gt;Considering all the hassle, using a standard subD9 connector is a way easier:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it has enough dedicated pins for I2C, SPI, and a generic IO for dumb sensors&lt;/li&gt;&#xA;&lt;li&gt;the pins can handle more current, and there are more pins you can connect in parallel to have enough power for small motors&lt;/li&gt;&#xA;&lt;li&gt;it is impossible to misconnect (once all sensor sockets use identical wiring)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2&gt;Don't forget ESD protection&lt;/h2&gt;&#xA;&lt;p&gt;In any case, it is a good idea to have some sort of ESD protection whenever you have connectors, and wires, and rough external world.&lt;/p&gt;&#xA;&lt;p&gt;Have at least a TVS diode on the power pins (say, an 5.8V or 6V unidir TVS will do). On IO pins you can use a simple series resistor, or you can opt for a TVS.&lt;/p&gt;&#xA;&lt;p&gt;During hot plug and play, it may happen that sensitive sensors get powered in a strange way. E.g. first 5V then the sensor output is getting connected, but no GND for a short moment. Some sensor may get damaged in this case. Use diodes to fix this.&lt;/p&gt;&#xA;&lt;p&gt;For sensors requiring sudden current peaks (e.g. WIFI, or a motor), add at least 470uF/16V electrolyte capacitor right to the sensor end of the connector. This way once the sensor is connected to a long extension wire, you still have acceptable power to use in sudden current peaks.&lt;/p&gt;&#xA;&lt;p&gt;Some sensors (e.g. IR receivers) are sensitive to power glitches. Consult their datasheet, use the suggested RC filtering network on the power pins.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-04-19T17:04:04.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23329" PostTypeId="2" ParentId="23326" CreationDate="2016-04-19T17:45:45.373" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;let have a look at following line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int servopos = bluetooth.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think that you are thinking that if you type in &lt;strong&gt;1&lt;/strong&gt; in your&#xA;Bluetooth application. &lt;strong&gt;bluetooth.read()&lt;/strong&gt; will pass that &lt;strong&gt;1&lt;/strong&gt; to&#xA;&lt;strong&gt;sevopos&lt;/strong&gt;. But, that's what not happens. What actually happens is that it will pass the &lt;strong&gt;ASCII&lt;/strong&gt; value of whatever you type in you&#xA;app, to integer. So, if you have typed in &lt;strong&gt;1&lt;/strong&gt;, it will pass &lt;strong&gt;49&lt;/strong&gt;&#xA;to &lt;strong&gt;servopos&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I put 45&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now, think about it. when you type in &lt;strong&gt;4&lt;/strong&gt; of this &lt;strong&gt;45&lt;/strong&gt;,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bluetooth.available()&amp;gt;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;becomes &lt;strong&gt;true&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int servopos = bluetooth.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;bluetooth.read()&lt;/strong&gt; will pass &lt;strong&gt;52&lt;/strong&gt; (ASCII of &lt;strong&gt;4&lt;/strong&gt;) to &lt;strong&gt;servopos&lt;/strong&gt;. Next,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myServo.write(servopos);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;myservo&lt;/strong&gt; will move your servo to lets say &lt;strong&gt;52&lt;/strong&gt; degrees. and then there will be a &lt;strong&gt;delay&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, when you type in &lt;strong&gt;5&lt;/strong&gt; of this &lt;strong&gt;45&lt;/strong&gt;, the procedure will be&#xA;repeated and your servo will be moved again by &lt;strong&gt;53&lt;/strong&gt; degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you might be wondering that why &lt;strong&gt;4&lt;/strong&gt; and &lt;strong&gt;5&lt;/strong&gt; sepratly? Well,&#xA;all these intructution are being executed in &lt;strong&gt;MHz&lt;/strong&gt;s. and secondly,&#xA;you, yourself has programmed that &lt;strong&gt;if&lt;/strong&gt; loop you read just &lt;strong&gt;once&#xA;character&lt;/strong&gt;. Yes, it will read &lt;strong&gt;character by character&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;blockquote&gt;&#xA;  &lt;p&gt;but it loose connection after servo moved once&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think your servo is drawing too much current from Arduino Board&#xA;which results in a drop in net voltage. And hence your HC-05 (kind&#xA;of) tuns off. This is what happens most of the time.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-19T17:45:45.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23330" PostTypeId="1" AcceptedAnswerId="23331" CreationDate="2016-04-19T17:52:05.850" Score="3" ViewCount="212" Body="&lt;p&gt;I am not sure if I am in the right place. I would like to build a device (as small as possible) that has an accelerometer and can talk to my phone via bluetooth. Im not asking anyone to build this for me. I would just like some starting help. Can you tell me the parts that I would need to accomplish this?&lt;/p&gt;&#xA;" OwnerUserId="20340" LastActivityDate="2018-12-14T04:07:32.207" Title="Accelerometer IoT" Tags="|arduino-uno|bluetooth|accelerometer|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23331" PostTypeId="2" ParentId="23330" CreationDate="2016-04-19T17:58:08.037" Score="0" Body="&lt;p&gt;you will need:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Arduino Mini&lt;/strong&gt; (can also use &lt;strong&gt;Uno&lt;/strong&gt;/&lt;strong&gt;Mega&lt;/strong&gt;/&lt;strong&gt;Pro&lt;/strong&gt;....)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Bluetooth Module&lt;/strong&gt; (mostly used: &lt;strong&gt;HC-06&lt;/strong&gt;/&lt;strong&gt;HC-05&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Accelerometer&lt;/strong&gt; (mostly &lt;strong&gt;MPU-6050&lt;/strong&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Few &lt;strong&gt;wires&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you want to carry this device around, you will need a &lt;strong&gt;battery&lt;/strong&gt; to power this circuit.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-19T17:58:08.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23332" PostTypeId="1" AcceptedAnswerId="23333" CreationDate="2016-04-19T18:13:25.450" Score="-2" ViewCount="969" Body="&lt;p&gt;I am somewhat new to the Arduino world and so far having fun. I am making a gardening watering system for my first project. I am at the final stages of completion and want to add a Wi-Fi module on the Arduino to send to my computer and display via serial COM the soil moisture and other relevant measurements I have going. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my question is, is it possible the simple analog information from my Arduino to my computer's serial COM with the Wi-Fi module ?&lt;/p&gt;&#xA;" OwnerUserId="20328" LastEditorUserId="6936" LastEditDate="2016-04-20T05:16:55.557" LastActivityDate="2016-04-24T20:20:02.223" Title="Wi-Fi from Arduino to computer serial COM" Tags="|wifi|analogwrite|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23333" PostTypeId="2" ParentId="23332" CreationDate="2016-04-19T18:28:11.290" Score="1" Body="&lt;p&gt;I would recommend using Bluetooth, as Bluetooth communication is&#xA;mostly done by using &lt;strong&gt;COM&lt;/strong&gt; Ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;strong&gt;HC05&lt;/strong&gt;/&lt;strong&gt;HC06&lt;/strong&gt; &lt;strong&gt;Bluetooth&lt;/strong&gt; Modules with Arduino.&#xA;You can easily pair your PC with these Bluetooth Modules. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you write an application in any programming language to get &amp;amp;&#xA;send data to your Arduino via Bluetooth COM ports.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-19T18:28:11.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23335" PostTypeId="2" ParentId="23330" CreationDate="2016-04-19T19:15:40.520" Score="1" Body="&lt;p&gt;Your smallest solution would not involve a conventional &quot;Arduino&quot; at all, but rather something like an nRF51822 Bluetooth Low Energy chip/module, which in addition to being a radio is a processor in its own right capable of running custom software built in a variety of ways, including one that extends the Arduino IDE to support it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you need the nRF51822 or similar chip, an accelerometer, and whatever solution for powering the two you decide upon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of conventional bluetooth vs. BLE the choice depends not only on technical merits, but also on which phone you want to connect to.  If you want to connect to an iphone, you are basically locked into BLE as the bluetooth stack there is restricted to approved devices.  On the other hand older/cheaper Android devices may not support BLE, or support it poorly, while their conventional bluetooth does not have the approval restrictions of iOS.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-19T19:21:13.837" LastActivityDate="2016-04-19T19:21:13.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23336" PostTypeId="1" AcceptedAnswerId="23340" CreationDate="2016-04-19T20:09:20.280" Score="3" ViewCount="900" Body="&lt;p&gt;So I bought this nucleo expansion board, the X-NUCLEO-IKS01A1, and on the package it says it is compatible with Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal here is to read data from any sensor on this board. (When I can read one, I can probably read the others too using the same structure)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;#define ADDRESS 0x1E&#xA;#define REGISTER 0x16&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly&#xA;  Serial.println(I2CreadByte(ADDRESS, REGISTER));&#xA;  delay(5000);&#xA;}&#xA;&#xA;uint8_t I2CreadByte(uint8_t address, uint8_t subAddress)&#xA;{&#xA;  uint8_t data; // `data` will store the register data  &#xA;&#xA;  Wire.beginTransmission(address);      &#xA;  Wire.write(subAddress);                  &#xA;  Wire.endTransmission(true);         &#xA;  Wire.requestFrom(address, (uint8_t) 1); &#xA;&#xA;  data = Wire.read();                    &#xA;  return data;                   &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should return the temperature in 2's complement. But all it returns is a 1 (I can guarantee you it's not that cold in my room).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the board plugged on my Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what I'm doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the datasheet for the sensor I'm trying to communicate with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www2.st.com/content/ccc/resource/technical/document/datasheet/6e/09/28/0b/01/06/42/24/DM00101533.pdf/files/DM00101533.pdf/jcr:content/translations/en.DM00101533.pdf&quot; rel=&quot;nofollow&quot;&gt;Datasheet&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sub addresses are on page 33 and the I2C explantation on 27. It's called the LSM6DS0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks sooo much in advance.&lt;/p&gt;&#xA;" OwnerUserId="20345" LastActivityDate="2017-06-22T16:47:36.833" Title="Can't retrieve data from X-NUCLEO-IKS01A1 using I2C protocol" Tags="|arduino-uno|sensors|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23337" PostTypeId="2" ParentId="20852" CreationDate="2016-04-19T20:53:44.713" Score="1" Body="&lt;p&gt;You can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;use a driver chip, e.g. ULN2803 which gives you 8 outputs of up to somewhat 500mA from 8 digital pins &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;use a serially addressible power+logic chip, such as TPIC6A595NE which gives you 8 outputs, each can drive 350mA, and has a built-in &lt;em&gt;short circuit protection&lt;/em&gt;. You can cascade these, 3 chips give 24 outputs, and need only three pins to drive all 24 (or more if you use more chips) outputs.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are 24 output devices, however not in this current range. 24 output devices are usually i2c or spi based led controllers - some of them gives you goodies like rock solid hardware PWM on all 24 ports - but none of them gives you 100mA output.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-19T20:53:44.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23338" PostTypeId="2" ParentId="23332" CreationDate="2016-04-19T21:23:28.517" Score="0" Body="&lt;p&gt;you can use ESP8266 with ESP-LINK firmware. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is nothing to it.Check out &lt;a href=&quot;http://github.com/jeelabs/esp-link&quot; rel=&quot;nofollow&quot;&gt;github.com/jeelabs/esp-link&lt;/a&gt; for documentation, examples and such. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect ESP8266 to Arduino URXD: &#xA;connect to TX of microcontroller UTXD: &#xA;connect to RX of microcontroller GPIO0: &#xA;connect to RESET of microcontroller GPIO2: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;optionally connect green LED to 3.3V (indicates wifi status) And that about it. Everything else is done over WiFi &lt;/p&gt;&#xA;" OwnerUserId="17211" LastEditorUserId="17211" LastEditDate="2016-04-24T20:20:02.223" LastActivityDate="2016-04-24T20:20:02.223" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23339" PostTypeId="1" CreationDate="2016-04-19T17:59:11.310" Score="2" ViewCount="35" Body="&lt;p&gt;I use an atmega328 with fdti cable wired at rx/tx and i want to connect a zigbee s2 at diferrent pins. I have tried to use  SoftwareSerial library but i would like to use the xbee library too. Is there a way to use both libraries? If there is no way doing this, is it a problem to connect both fdti cable and zigbee at the same rx/tx? In the future, in opposition to fdti cable i will use a micro usb avr.&lt;/p&gt;&#xA;" OwnerUserId="20361" OwnerDisplayName="G-V" LastEditorUserId="37523" LastEditDate="2018-07-27T17:29:39.357" LastActivityDate="2018-07-27T17:29:39.357" Title="Atmega328 xbee and softaware serial libraries" Tags="|atmega328|xbee|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23340" PostTypeId="2" ParentId="23336" CreationDate="2016-04-20T00:25:33.987" Score="1" Body="&lt;p&gt;You're using a wrong slave address. From the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Slave ADdress (SAD) associated to the LSM6DS0 is 110101xb. The SDO/SA0 pin can be used to modify the less significant bit of the device address. If the SDO/SA0 pin is connected to a voltage supply, LSb is ‘1’ (address 1101011b), else if the SDO/SA0 pin is connected to ground, the LSb value is ‘0’ (address 1101010b). This solution permits to connect and address two different inertial modules to the same I2C bus.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This means your sketch should contain:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADDRESS 0x6A  // if SDO pin is pulled down&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ADDRESS 0x6B  // if SDO pin is pulled up&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's also a good idea to check if there's actually anything in the Wire buffer (with &lt;code&gt;Wire.available()&lt;/code&gt;) before you attempt reading. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I suggest you read both &lt;code&gt;OUT_TEMP_H&lt;/code&gt; and &lt;code&gt;OUT_TEMP_L&lt;/code&gt; registers, in order to calculate the temperature correctly. The datasheet says the temperature output is zero at 25 degrees Celsius and that the sensitivity is 16 LSB/C. This means you have to read both registers, combine their results to get a 16-bit signed integer (&lt;code&gt;OUT_TEMP_H&lt;/code&gt; is the MSB), divide it by 16 to get the temperature offset, and add the result to 25 degrees Celsius to get absolute temperature.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-20T00:25:33.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23342" PostTypeId="2" ParentId="23319" CreationDate="2016-04-20T01:21:10.463" Score="0" Body="&lt;p&gt;I assume you're doing all this from the serial monitor. You can't use escape sequences like &lt;code&gt;\r&lt;/code&gt; in the serial monitor entry box. Everything you enter is evaluated as a string of separate ASCII characters; &lt;code&gt;\r&lt;/code&gt; is just a backslash character followed by lowercase r. To send a HTTP request, you make the serial monitor send the &lt;code&gt;\r\n&lt;/code&gt; for you. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First set the serial monitor to &lt;code&gt;BOTH NL &amp;amp; CR&lt;/code&gt; permanently; it will serve you well for commands and HTTP requests as it appends &lt;code&gt;\r\n&lt;/code&gt; to everything you send.&lt;/li&gt;&#xA;&lt;li&gt;Count the number of bytes in the your HTTP request, including the carriage return and newline characters. I count 61 characters in your request.&lt;/li&gt;&#xA;&lt;li&gt;Use this count in &lt;code&gt;AT+CIPSEND&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Type the first line of your request, and stop right before the first &lt;code&gt;\r\n&lt;/code&gt;, and click Send. Because of your setting, the monitor will now send what you typed &lt;em&gt;with&lt;/em&gt; &lt;code&gt;\r\n&lt;/code&gt; suffixed to it. &lt;/li&gt;&#xA;&lt;li&gt;Type and send each line of the request, just like you sent the first line, until you've sent the last line.&lt;/li&gt;&#xA;&lt;li&gt;Since there is an additional &lt;code&gt;\r\n&lt;/code&gt; after the last line, you click Send again, without typing anything. And since the module requires &lt;code&gt;\r&lt;/code&gt; to indicate the end of the data packet, you click Send one last time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hopefully, this should give you the right results.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-20T01:21:10.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23344" PostTypeId="1" CreationDate="2016-04-20T02:08:57.847" Score="-3" ViewCount="765" Body="&lt;p&gt;I'm putting together a simple sketch to read a few sensors and have come across some odd behaviour associated with &lt;code&gt;#define&lt;/code&gt; and &lt;code&gt;#ifdef&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some snippets from my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Defines&#xA;//#define DEBUG 1&#xA;#define ACCELEROMETER 1&#xA;#define GYROSCOPE 1&#xA;#define GPSSYSTEM 1&#xA;#ifdef GPSSYSTEM&#xA;  unsigned int Mth=0;&#xA;  unsigned int Day=0;&#xA;  char TMZ[2];&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this snippet the rest of the sketch compiles, but with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Defines&#xA;//#define DEBUG 1&#xA;#define ACCELEROMETER 1&#xA;#define GYROSCOPE 1&#xA;//#define GPSSYSTEM 1&#xA;#ifdef GPSSYSTEM&#xA;  unsigned int Mth=0;&#xA;  unsigned int Day=0;&#xA;  char TMZ[2];&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The compile fails, claiming that the error is in some functions further down. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, &lt;code&gt;Mth&lt;/code&gt;, &lt;code&gt;Day&lt;/code&gt; and &lt;code&gt;TMZ&lt;/code&gt; are not used anywhere yet, not are they defined anywhere else.  What is even more odd is that the error messages are announcing the erroneous line numbers to be about 12 lines removed from where they really exist in the sketch, and have no association with the declarations here.&#xA;Now, this gives a clean compile:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Defines&#xA;//#define DEBUG 1&#xA;#define ACCELEROMETER 1&#xA;#define GYROSCOPE 1&#xA;#define GPSSYSTEM 1&#xA;//#ifdef GPSSYSTEM&#xA;  unsigned int Mth=0;&#xA;  unsigned int Day=0;&#xA;  char TMZ[2];&#xA;//#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;as does this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Defines&#xA;//#define DEBUG 1&#xA;#define ACCELEROMETER 1&#xA;#define GYROSCOPE 1&#xA;//#define GPSSYSTEM 1&#xA;//#ifdef GPSSYSTEM&#xA;  unsigned int Mth=0;&#xA;  unsigned int Day=0;&#xA;  char TMZ[2];&#xA;//#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've been chasing this weirdness for a day now and am getting nowhere.&lt;/p&gt;&#xA;" OwnerUserId="20350" LastEditorUserId="6936" LastEditDate="2016-04-20T05:07:09.990" LastActivityDate="2016-04-20T05:07:09.990" Title="Oddness with #define and #ifdef in a sketch" Tags="|programming|c++|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23345" PostTypeId="1" CreationDate="2016-04-20T02:39:37.630" Score="2" ViewCount="1549" Body="&lt;p&gt;I'm using SimpleSDaudio (&lt;a href=&quot;http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio&quot; rel=&quot;nofollow&quot;&gt;http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio&lt;/a&gt;) to play wav files. The connections are as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MISO pin 12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SCK pin 13&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SS pin 4&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MOSI pin 11&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaker pin 9&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Simple SD Audio bare minimum example, plays file EXAMPLE.AFM from root folder of SD card.&#xA;&#xA; This example shows how to use the SimpleSDAudio library for audio playback.&#xA; You need: &#xA; - An Arduino with ATmega368 or better&#xA; - An SD-Card connected to Arduinos SPI port (many shields will do)&#xA;   -&amp;gt; copy EXAMPLE.AFM on freshly formated SD card into root folder&#xA; - A passive loudspeaker and resistor or better: active speakers (then stereo output will be possible)&#xA;&#xA; Audio signal output is at the following pin:&#xA; - Arduino with ATmega328       (many non-mega Arduinos): Pin 9&#xA; - Arduino with ATmega1280/2560 (many mega Arduinos)    : Pin 44&#xA;&#xA; Using passive speaker: &#xA;    Audio-Pin --- -[100 Ohm resistor]- ---- Speaker ---- GND&#xA;&#xA; Using amplifier / active speaker / line-in etc.:&#xA;    Audio-Pin --||--------------[10k resistor]----+----[1k resistor]---- GND&#xA;              100nF capacitor                   to amp&#xA;&#xA; See SimpleSDAudio.h or our website for more information:&#xA; http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio&#xA;&#xA; created  20 Jan 2013 by Lutz Lisseck&#xA; */&#xA;#include &amp;lt;SimpleSDAudio.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA; // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;   while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;&#xA;  // Using F(&quot;...&quot;) to avoid wasting RAM  &#xA;  Serial.print(F(&quot;\nInitializing SD card...&quot;));  &#xA;&#xA;  // If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:&#xA;  // SdPlay.setSDCSPin(10);&#xA;&#xA;  if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)) {&#xA;    Serial.println(F(&quot;initialization failed. Things to check:&quot;));&#xA;    Serial.println(F(&quot;* is a card is inserted?&quot;));&#xA;    Serial.println(F(&quot;* Is your wiring correct?&quot;));&#xA;    Serial.println(F(&quot;* maybe you need to change the chipSelect pin to match your shield or module?&quot;));&#xA;    Serial.print(F(&quot;Error code: &quot;));&#xA;    Serial.println(SdPlay.getLastError());&#xA;    while(1);&#xA;  } else {&#xA;   Serial.println(F(&quot;Wiring is correct and a card is present.&quot;)); &#xA;  }&#xA;&#xA;  Serial.print(F(&quot;Looking for on.wav... &quot;));&#xA;  if(!SdPlay.setFile(&quot;hi.wav&quot;)) {&#xA;    Serial.println(F(&quot; not found on card! Error code: &quot;));&#xA;    Serial.println(SdPlay.getLastError());&#xA;    while(1);&#xA;  } else {&#xA;   Serial.println(F(&quot;found.&quot;)); &#xA;  }    &#xA;&#xA;  Serial.print(F(&quot;Playing... &quot;)); &#xA;  SdPlay.play();&#xA;  while(!SdPlay.isStopped()) {&#xA;    ;   // no worker needed anymore :-)&#xA;  }&#xA;  Serial.println(F(&quot;done.&quot;));&#xA;  SdPlay.deInit();&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is when playing the wav files. It plays with a lot of static. I've tried adding a 1k resistor between the speaker and gnd but that just lowered the overall volume. I resampled the wav files in itunes to 32khz, 8bit, mono. If I lower to 16khz then the audio volume becomes very low and the song just plays extremely fast. Here is a google drive link to one of the sounds:&#xA;&lt;a href=&quot;https://drive.google.com/file/d/0B3yAl4G-mcC4dlppN3dtczJvT1k/view?usp=sharing&quot; rel=&quot;nofollow&quot;&gt;https://drive.google.com/file/d/0B3yAl4G-mcC4dlppN3dtczJvT1k/view?usp=sharing&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really need help. I'm not sure what to do!&lt;/p&gt;&#xA;" OwnerUserId="18898" LastActivityDate="2017-10-15T14:00:15.293" Title="SimpleSDaudio giving a lot of static from speaker" Tags="|arduino-uno|sound|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23346" PostTypeId="2" ParentId="23344" CreationDate="2016-04-20T03:28:35.753" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The &lt;strong&gt;#ifdef&lt;/strong&gt; Directive you are using is one of Conditional&#xA;  Directive.&#xA;  This directive checks whether the identifier is currently defined.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In general, it has following syntax:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef identifier newline&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For Arduino, you can modify your &lt;strong&gt;#ifdef&lt;/strong&gt;s to following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(GPSSYSTEM)&#xA;    //Code here&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Explaining your code snippets behaviors:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In your first code snippets, &lt;strong&gt;GPSSYSTEM&lt;/strong&gt; has been defined by following line of code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define GPSSYSTEM 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, For this code snippets, &lt;strong&gt;#ifdef GPSSYSTEM&lt;/strong&gt; is &lt;strong&gt;true&lt;/strong&gt;, and following variables are defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, when you comment this &lt;strong&gt;#define GPSSYSTEM 1&lt;/strong&gt; line in your 2nd code snippets, &lt;strong&gt;GPSSYSTEM&lt;/strong&gt; is no more defined and so &lt;strong&gt;#ifdef GPSSYSTEM&lt;/strong&gt; is &lt;strong&gt;false&lt;/strong&gt;, and thus following variables are not defined which result in compilation errors in your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following same logic, behavior of your 3rd and 4th code snippets can be explained easily.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-20T03:28:35.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23347" PostTypeId="1" AcceptedAnswerId="23357" CreationDate="2016-04-20T04:13:30.957" Score="2" ViewCount="491" Body="&lt;p&gt;I am new to electronics. I have a good amount of programming under my belt however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to know if I am multiplexing correctly or not. My intended output is how I want it, but I am not sure if I implemented it how it's supposed to be, i.e. am I potentially damaging my equipment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 6 RGB LEDs hooked up to my arduino, let's called them L1 - L6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have each R, G, and B pin on L1 - L3 connected in parallel, and the same for L4 - L6. Then I have ground on L1 and L4 connected in parallel, and the same for L2 to L5, and L3 to L6. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So this gives me 6 pins to supply voltage to, to which I put a 220 ohm resistor in each one. Then it gives me 3 different spots for ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is about the ground. How should I control the different 'pins' for ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have right now, and it works, but I don't know if this is dangerous to my equipment for some reason. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the 3 ground pins connected to the Arduino in 3 different pins, 7, 4, and 2. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;Setup()&lt;/code&gt; I configure these 3 pins as outputs, and I later found out in order to keep them all 'off' I need to set them all to high. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then in order to turn L1 on to red, I need to turn its red pin to high, but turn its ground pin to low, then L1 turns on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using this same technique, I am able to get every LED to every desired color. So I mean it works. But why is this? Is this how I should be doing it? I understand LEDs polarity matters, but why would supplying its cathode with voltage make it turn off? That's the part I'm worried about, am I destroying my LEDs by doing this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any and all help much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I have it all wired up for clarity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NWd0Z.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NWd0Z.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20351" LastEditorUserId="20351" LastEditDate="2016-04-20T04:33:03.513" LastActivityDate="2016-04-20T09:37:35.277" Title="Am I multiplexing my LEDs correctly?" Tags="|led|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23348" PostTypeId="1" CreationDate="2016-04-20T04:14:11.380" Score="2" ViewCount="10089" Body="&lt;p&gt;I just started learning ESP8266 and in my first project I am successfully able to send data to ThingSpeak.com using ESP8266 with following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uploadData() {&#xA;  String apiKey = &quot;ESDS8678890SDDS&quot;;&#xA;  String myData = &quot;45.5&quot;; // example of data to send&#xA;  if (espClient.connect(server,80)) {&#xA;    String postStr = apiKey;&#xA;    postStr +=&quot;&amp;amp;field1=&quot;;&#xA;    postStr += String(myData);&#xA;    postStr += &quot;\r\n\r\n&quot;;&#xA;    espClient.print(&quot;POST /update HTTP/1.1\n&quot;);&#xA;    espClient.print(&quot;Host: api.thingspeak.com\n&quot;);&#xA;    espClient.print(&quot;Connection: close\n&quot;);&#xA;    espClient.print(&quot;X-THINGSPEAKAPIKEY: &quot;+apiKey+&quot;\n&quot;);&#xA;    espClient.print(&quot;Content-Type: application/x-www-form-urlencoded\n&quot;);&#xA;    espClient.print(&quot;Content-Length: &quot;);&#xA;    espClient.print(postStr.length());&#xA;    espClient.print(&quot;\n\n&quot;);&#xA;    espClient.print(postStr);&#xA;    Serial.print(postStr);&#xA;    Serial.print(&quot;My Data: &quot;);&#xA;    Serial.print(myData);&#xA;    Serial.print(&quot;\n&quot;);&#xA;  }&#xA;  espClient.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I have no idea how to retrieve data from ThingSpeak using ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Using XXXXX here as my channel is private&#xA;GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Help would be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="20354" OwnerDisplayName="Vicky Arora" LastEditorUserId="4628" LastEditDate="2017-01-03T15:18:41.757" LastActivityDate="2017-05-23T01:45:55.160" Title="Retrieve value from ThingSpeak using ESP8266 with Arduino setup" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23351" PostTypeId="1" CreationDate="2016-04-20T06:35:48.190" Score="1" ViewCount="10831" Body="&lt;p&gt;I recently prototyped and programmed a system that used some SPI sensors on an Arduino Uno. I wanted to get the size down a bit, so I was thinking I might buy an Arduino Nano and re-wire my system around that. The problem is that I have seen mention of SPI not working on the Nano. From the &lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow noreferrer&quot;&gt;Nano product page&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yet I have also seen mention of SPI working on this board, or at least people saying that it should. Someone asked a &lt;a href=&quot;https://stackoverflow.com/questions/16055842/arduino-nano-is-spi-supported&quot;&gt;similar question&lt;/a&gt; on Stack Overflow and was told that it should work with the same level of support as I&lt;sup&gt;2&lt;/sup&gt;C, even if it isn't built in to the core framework. But that answer does not definitively answer the question of whether SPI &lt;em&gt;does&lt;/em&gt; work, and it doesn't explain any caveats that one may come across. In &lt;a href=&quot;https://arduino.stackexchange.com/questions/13946/nrf24l01-pa-not-working-with-arduino-mega-works-with-nano&quot;&gt;this question&lt;/a&gt;, the OP's premise is that their SPI device works on the Nano but not on other boards; this seems to be a strong indication that SPI &lt;em&gt;does&lt;/em&gt; work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figured it would be worth it to buy a Nano 3 and see if it worked. SPI devices did not work on that board, including the same radio module mentioned in the question linked to above. So, I am inclined to believe the Arduino product page when they say it isn't supported. But that still isn't satisfactory, and it is the opposite conclusion from that of the other questions: &lt;strong&gt;The hardware is all there and the software framework is in place, so what does one need to do to make SPI work on the Arduino Nano?&lt;/strong&gt; Why is it that some sources say it works while others say it doesn't?&lt;/p&gt;&#xA;" OwnerUserId="20357" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2017-12-01T09:03:34.380" Title="How can one use the SPI hardware on the Arduino Nano?" Tags="|arduino-nano|communication|spi|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23353" PostTypeId="2" ParentId="23347" CreationDate="2016-04-20T09:13:03.867" Score="1" Body="&lt;p&gt;LEDs are not powered by a particular voltage level, but by the &lt;strong&gt;voltage difference&lt;/strong&gt; between anode and cathode. That's why you need to drive cathode pins (7, 4, and 2) LOW to switch the LEDs ON and HIGH to switch them off. A truth table could help:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;╔═══════╦═════════╦══════════════════════════╦═══════════╗&#xA;║ anode ║ cathode ║ voltage anode to cathode ║ led state ║&#xA;╠═══════╬═════════╬══════════════════════════╬═══════════╣&#xA;║ LOW   ║ LOW     ║ 0V                       ║ OFF       ║&#xA;╠═══════╬═════════╬══════════════════════════╬═══════════╣&#xA;║ LOW   ║ HIGH    ║ - 3.3V                   ║ OFF       ║&#xA;╠═══════╬═════════╬══════════════════════════╬═══════════╣&#xA;║ HIGH  ║ LOW     ║ + 3.3V                   ║ ON        ║&#xA;╠═══════╬═════════╬══════════════════════════╬═══════════╣&#xA;║ HIGH  ║ HIGH    ║ 0V                       ║ OFF       ║&#xA;╚═══════╩═════════╩══════════════════════════╩═══════════╝&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your schematic looks safe to me, but be aware that if you decide to illuminate L1, L2 and L3 to the same color simultaneously (e.g drive red line HIGH and pins 7, 4, and 2 LOW), your LEDs will not have uniform brightness. Only one of the cathode pins should be LOW at a time, otherwise you will end up in the situation described &lt;a href=&quot;https://electronics.stackexchange.com/q/22291/72179&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-04-20T09:20:25.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23354" PostTypeId="1" CreationDate="2016-04-20T09:15:10.033" Score="1" ViewCount="4384" Body="&lt;p&gt;I was wondering if I could create my own apache web server on my Arduino Uno, just like I did on my raspberry pi - &lt;a href=&quot;https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md&quot; rel=&quot;nofollow&quot;&gt;https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone have any idea about this? From my research it seems like I cant achieve the same results on an arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="20089" LastActivityDate="2016-04-21T19:27:05.200" Title="Create own apache web server on Arduino Uno... just like you can on a raspberry pi?" Tags="|arduino-uno|web-server|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23356" PostTypeId="2" ParentId="23354" CreationDate="2016-04-20T09:28:47.197" Score="1" Body="&lt;p&gt;You can only make a very, very, very basic webserver, that won't be able to handle more than a few requests per second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to add something like an ethernet shield, and probably an SD card reader. Which would make it about the same price as a Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible, but very limited, not practical in most cases, and not that much cheaper.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-20T09:28:47.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23357" PostTypeId="2" ParentId="23347" CreationDate="2016-04-20T09:37:35.277" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So I mean it works. But why is this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It works because the LED inside the RGB LED, all three of the LEDs inside have the characteristic of a diode, this means it will allow current flow in one direction, but will stop, or restrict it in the opposite direction. &lt;em&gt;Also are you asking why it works because of your specific wiring?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is this how I should be doing it? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, how you are doing it is fine. Although I would suggest you use NPN transistors to drive your cathodes of the LEDs. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This will at least remove any worry of applying 5v to the cathode.&lt;/li&gt;&#xA;&lt;li&gt;It will also reduce the amount of current your I/O pins have to handle.&lt;/li&gt;&#xA;&lt;li&gt;You should also move the resistors from the cathodes to the anodes as this is more reliable and pretty much the norm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I understand LEDs polarity matters, but why would supplying its cathode with voltage make it turn off? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This works because of the theory of the p-n junction, (inside construction of a diode), this means that because of the construction of the diode it requires the voltage on the Cathode to be at a lower potential. So that means when you set the output &lt;code&gt;HIGH&lt;/code&gt; the 5v on the anode and the 5v on the cathode &quot;stop&quot; current flow because it stops the breakdown within the p-n junction.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;That's the part I'm worried about, am I destroying my LEDs by doing this? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No you are not, the LED acts as a diode and when the potentials are the same, current doesn't really flow and thus doesn't do anything to the LED.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-04-20T09:37:35.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23358" PostTypeId="2" ParentId="23354" CreationDate="2016-04-20T09:40:09.400" Score="0" Body="&lt;p&gt;No you can't. Apache (or any web server of similar functionality) will require:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;tens to hundreds of megabytes of RAM&lt;/li&gt;&#xA;&lt;li&gt;about 50 megabytes of storage&lt;/li&gt;&#xA;&lt;li&gt;an actual operating system&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Perhaps you can get the required storage with the SD shield, but it's practically impossible to get enough RAM or run a suitable OS on arduino.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-04-20T09:40:09.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23361" PostTypeId="2" ParentId="23354" CreationDate="2016-04-20T10:21:07.087" Score="1" Body="&lt;p&gt;I do recall someone actually managing to run Linux on an Arduino. It was quite impressive, involving a very large amount of external DDR RAM and bit-banging the interface to it. Basically emulating a virtual computer within the Arduino.  I can't find the original post though - it's been lost in time...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, technically it is possible to run Linux, and thus Apache, on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it recommended to even think about trying to do something like this though?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Certainly not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino is a microcontroller, not a computer. It is designed for controlling things (hence its name) not for general computing tasks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It can, though, run its own web server software - that is, you can connect some form of network interface (Ethernet, WiFI, etc) and implement a very very basic web server. It can't really do much, and all interactivity has to be hard coded into it in C++. There doesn't (yet) exist any simple scripting engine or anything like that (PHP, etc) and you are very limited on how much you can implement (lack of memory) as regards anything fancy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general a web server running on an Arduino is used as a back-end to a proper web server and interacted with using Ajax calls or other similar methods.  More commonly though a web interface is shunned in favour of much lighter weight protocols or &lt;em&gt;push&lt;/em&gt; technologies like MQTT.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-20T10:21:07.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23362" PostTypeId="1" CreationDate="2016-04-20T11:55:26.140" Score="0" ViewCount="2200" Body="&lt;p&gt;I have the following issues:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) When i press for example number 7 on the keypad it shows a different number on the serial monitor &#xA;2) The servo motor works for any combination of 4 numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&#xA;/*&lt;a href=&quot;http://openhwdesign.comLock&quot; rel=&quot;nofollow&quot;&gt;http://openhwdesign.comLock&lt;/a&gt; system using a Keypad&#xA;*/&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Password.h&amp;gt;&#xA;#include &amp;lt;Keypad.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#pragma GCC diagnostic ignored &quot;-Wwrite-strings&quot;&#xA;Servo myservo; //declare servo&#xA;Password password = Password( &quot;5523&quot; ); &#xA;&#xA;const byte ROWS = 4; // declare the rows of the keypad&#xA;const byte COLS = 3; // declare the columns of the keypad&#xA;&#xA;// Define the Keymap&#xA;&#xA;char keys[ROWS][COLS] = {&#xA;{'1','2','3'},&#xA;{'4','5','6'},&#xA;{'7','8','9'},&#xA;{'*','0','#'}&#xA;};&#xA;&#xA;byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.&#xA;byte colPins[COLS] = {6,7,8}; // Connect keypad’s pins to these Arduino pins.&#xA;&#xA;// Create the KeyPad&#xA;Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );&#xA;&#xA;void setup(){&#xA;Serial.begin(9600);&#xA;myservo.write(0);&#xA;pinMode(11, OUTPUT); //The green led is set as an output.&#xA;pinMode(12, OUTPUT); //The red led is set as an output.&#xA;myservo.attach(13); //The servo is connected to the digital pin 13.&#xA;keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;keypad.getKey();&#xA;myservo.write(180); //why? what happens if you comment it? ###########################&#xA;//delay(5);&#xA;}&#xA;&#xA;void keypadEvent(KeypadEvent eKey){&#xA;// When the KeyPad will be pressed, the results will appear on the serial monitor.&#xA;switch (keypad.getState()){&#xA;case PRESSED:&#xA;Serial.print(&quot;Enter: &quot;);&#xA;Serial.println(eKey);&#xA;delay(10);&#xA;&#xA;switch (eKey){&#xA;case '*':&#xA;checkPassword(); // Will check the password.&#xA;delay(1); // Delay used for stability.&#xA;break;&#xA;&#xA;case '#':&#xA;password.reset(); //Will reset the password&#xA;delay(1); // Delay used for stability.&#xA;break;&#xA;&#xA;default:&#xA;password.append(eKey); //Append any keypress that is not a ‘#’ nor a ‘*’.&#xA;delay(1);&#xA;}&#xA;}&#xA;}&#xA;void checkPassword(){&#xA;&#xA;if (password.evaluate()){ //If the combination inserted is equal to the combination saved, the servo’ll rotate.&#xA;Serial.println(&quot;Accepted&quot;);&#xA;//delay(5000);&#xA;delay(10);&#xA;myservo.write(50); //was 140&#xA;delay(5000);&#xA;&#xA;digitalWrite(11, HIGH); //Turn the green led on.&#xA;delay(500); //Wait 5 seconds.&#xA;digitalWrite(11, LOW); //Turn the green led off.&#xA;&#xA;//break; // remove if trial did not work #####################try#####################&#xA;}&#xA;//break; // remove if trial did not work ##########################################&#xA;else{ //If the combination inserted isn’t equal to the combination saved, the servo will not rotate.&#xA;//delay(5000); delays response&#xA;Serial.println(&quot;denied&quot;);&#xA;delay(10);&#xA;//delay(5000);&#xA;myservo.write(20); // was 50&#xA;digitalWrite(12, HIGH); //Turn the green led on.&#xA;delay(5000); //Wait 5 seconds. was 500 /// &#xA;digitalWrite(12, LOW); //Turn the green led off.&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="20367" LastActivityDate="2016-04-20T13:10:32.240" Title="keypad code is not working and produces wrong numbers" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23363" PostTypeId="2" ParentId="23354" CreationDate="2016-04-20T12:06:20.670" Score="0" Body="&lt;p&gt;Yes, you can make a web server.  &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is the tutorial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not need Apache to create a web server.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-20T12:28:36.767" LastActivityDate="2016-04-20T12:28:36.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23364" PostTypeId="2" ParentId="23351" CreationDate="2016-04-20T12:44:02.770" Score="0" Body="&lt;p&gt;In &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; Nano schematic, I see MOSI, MISO &amp;amp; SCLK on pins J1-14, J1-15 &amp;amp; J2-15.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;https://www.arduino.cc/en/reference/SPI&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; page I see a SPI library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Nano is not specifically listed in the latter link.  However the Nano and other Arduino boards are similar.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-20T12:44:02.770" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23365" PostTypeId="2" ParentId="23324" CreationDate="2016-04-20T12:58:02.673" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Open the file in &lt;code&gt;rb&lt;/code&gt; mode in your Python code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Since the Arduino SoftSerial RX buffer is 64 bytes in size, sending 60 bytes per packet to the Arduino is okay. You basically call &lt;code&gt;out = file.read(60)&lt;/code&gt; in python to read 60 bytes from the file and then write these bytes to the Arduino with &lt;code&gt;ser.write(out)&lt;/code&gt;. You can have the python program wait for acknowledgement from the Arduino, perhaps indicating how many bytes it actually received (after a given timeout period) or what byte was last received. This is just very minor error detection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Arduino saves the 60-byte packet to an array and writes everything at once to a file on the SD card, that you've already opened.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After receiving acknowledgement from the Arduino, the Python program reads the next 60 bytes and forwards to the Arduino like before. Continue till the file is exhausted. You could send some sort of signature byte to inform the Arduino that no more bytes are coming and to close the file. Alternatively, a timeout period can be used.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Note: It'll be more efficient if you wrote to the SD card in chunks, where the chunk size is a factor of the card's sector size. 64 bytes is the highest you can do with the default RX buffer size, but thats living dangerously as you risk buffer overflow if anything goes bump.&#xA;This can be avoided though, by reading bytes from the RX buffer and into your own array, as soon as they arrive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Chunks of 32 bytes is safer but it will naturally take longer to send the whole file. Test and judge for yourself.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-20T14:49:56.667" LastActivityDate="2016-04-20T14:49:56.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23366" PostTypeId="1" CreationDate="2016-04-20T13:05:13.397" Score="1" ViewCount="8411" Body="&lt;p&gt;I'm running into a bizarre problem. I've got a custom board using an Atmega328P, running off the internal oscillator. From Atmel studio, I've successfully uploaded the standard optiboot bootloader (&lt;code&gt;optiboot_atmega328.hex&lt;/code&gt;) and burned the appropriate fuses (&lt;code&gt;hfuse = 0xDE&lt;/code&gt;, &lt;code&gt;lfuse = 0xE2&lt;/code&gt;, &lt;code&gt;extended_fuse = 0x05&lt;/code&gt;). As per an arduino forum post, I added the following entry to &lt;code&gt;boards.txt&lt;/code&gt;:&#xA;&#xA;    atmega328_384_8.name=ATmega328 Optiboot @ 38,400baud w/ 8MHz Int. RC Osc.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;atmega328_384_8.upload.protocol=arduino&#xA;atmega328_384_8.upload.maximum_size=30720&#xA;atmega328_384_8.upload.speed=57600 &#xA;atmega328_384_8.upload.tool=avrdude &#xA;&#xA;atmega328_384_8.bootloader.low_fuses=0xE2&#xA;atmega328_384_8.bootloader.high_fuses=0xDE&#xA;atmega328_384_8.bootloader.extended_fuses=0x05&#xA;atmega328_384_8.bootloader.path=optiboot&#xA;atmega328_384_8.bootloader.file=optiboot_atmega328.hex&#xA;atmega328_384_8.bootloader.unlock_bits=0x3F&#xA;atmega328_384_8.bootloader.lock_bits=0x0F&#xA;&#xA;atmega328_384_8.build.mcu=atmega328p&#xA;atmega328_384_8.build.f_cpu=8000000L&#xA;atmega328_384_8.build.core=arduino&#xA;atmega328_384_8.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note here, I've modified the upload speed to 57600 baud to &quot;fool&quot; it into the right upload speed given an 8MHz oscillator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can now successfully upload sketches from the Arduino IDE (1.6.3) on the lab windows machine, but when I try from my Mac (various IDE versions have been tried), I get the following protocol error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the full trace:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbserial-AH02F0KI -b57600 -D -Uflash:w:/var/folders/db/hw2v9r6j7qj_w9gh3qkhh_580000gr/T/build53eb1895270295360d41549eaf6e0624.tmp/sketch_apr19a.ino.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Users/npisenti/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/cu.usbserial-AH02F0KI&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00&#xA;         Hardware Version: -1538883332&#xA;         Firmware Version: 6291456.-1538883332&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;         Vtarget         : 322122165.6 V&#xA;         Varef           : 275608114.4 V&#xA;         Oscillator      : 0.001 Hz&#xA;         SCK period      : 368336.6 us&#xA;&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00&#xA;avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0xe0&#xA;avrdude: initialization failed, rc=-1&#xA;         Double check connections and try again, or use -F to override&#xA;         this check.&#xA;&#xA;avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xe0&#xA;&#xA;avrdude done.  Thank you.&#xA;&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Windows, the &quot;successful&quot; full trace from avrdude is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Sketch uses 1,974 bytes (6%) of program storage space. Maximum is 30,720 bytes.&#xA;Global variables use 192 bytes of dynamic memory.&#xA;C:\arduino-1.6.3\hardware\tools\avr/bin/avrdude -CC:\arduino-1.6.3\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:i &#xA;&#xA;avrdude: Version 6.0.1, compiled on Mar 30 2015 at 14:56:06&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\arduino-1.6.3\hardware\tools\avr/etc/avrdude.conf&quot;&#xA;&#xA;         Using Port                    : COM10&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;         Hardware Version: 3&#xA;         Firmware Version: 4.4&#xA;         Vtarget         : 0.3 V&#xA;         Varef           : 0.3 V&#xA;         Oscillator      : 28.800 kHz&#xA;         SCK period      : 3.3 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.01s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: reading input file &quot;C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex&quot;&#xA;avrdude: writing flash (1974 bytes):&#xA;&#xA;Writing | ################################################## | 100% 0.77s&#xA;&#xA;avrdude: 1974 bytes of flash written&#xA;avrdude: verifying flash memory against C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:&#xA;avrdude: load data flash data from input file C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:&#xA;avrdude: input file C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex contains 1974 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 0.86s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: 1974 bytes of flash verified&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In both cases, I'm using the FTDI friend from Adafruit; at first I figured it must be a driver issue, but I've installed the latest FTDI drivers and doesn't seem to help. Besides, I can successfully get text dumped from the ucontroller onto the serial port from a sketch previously uploaded on the windows machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated!&lt;/p&gt;&#xA;" OwnerUserId="20373" LastEditorUserId="37523" LastEditDate="2019-05-13T09:34:09.643" LastActivityDate="2019-09-17T01:02:50.350" Title="avrdude/stk500 protocol error" Tags="|bootloader|avrdude|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23367" PostTypeId="2" ParentId="23362" CreationDate="2016-04-20T13:10:32.240" Score="1" Body="&lt;p&gt;The first thing you need to do is just look at what the problem is.  Create a new sketch and paste this code into it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Keypad.h&amp;gt;&#xA;&#xA;const byte ROWS = 4; // declare the rows of the keypad&#xA;const byte COLS = 3; // declare the columns of the keypad&#xA;&#xA;// Define the Keymap&#xA;char keys[ROWS][COLS] = &#xA;{&#xA;    {'1','2','3'},&#xA;    {'4','5','6'},&#xA;    {'7','8','9'},&#xA;    {'*','0','#'}&#xA;};&#xA;&#xA;byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.&#xA;byte colPins[COLS] = {6,7,8};   // Connect keypad’s pins to these Arduino pins.&#xA;&#xA;// Create the KeyPad&#xA;Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );&#xA;&#xA;void keypadEvent(KeypadEvent eKey)&#xA;{&#xA;    // When the KeyPad will be pressed, the results will appear on the serial monitor.&#xA;    switch (keypad.getState())&#xA;    {&#xA;    case PRESSED:&#xA;        Serial.print(&quot;Enter: &quot;);&#xA;        Serial.println(eKey);&#xA;        delay(10);&#xA;        break;&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    keypad.getKey();&#xA;    delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should recognise it, its a reformatted version of your code (pretty code is easier to debug), but with only the keypad bits in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now load that onto your hardware and write down what number is shown when you press 1 three times.  Do it three times just to make sure its the same number and you haven't got something totally obscure happening. Repeat for the other 11 buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 7 and 3 always give you 3 and 6 then you have got your row and column wires crossed.&#xA;If 7 always gives you 1 and 9 always gives you 3 then the wires for row 4 and 2 are crossed over. etc&#xA;If you can't work out the patter post your findings and I'm sure someone will solve the puzzle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for problem 2, don't even go there until you know what you are typing. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-20T13:10:32.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23368" PostTypeId="1" AcceptedAnswerId="23373" CreationDate="2016-04-20T13:31:31.627" Score="0" ViewCount="3487" Body="&lt;p&gt;I need a motor controller for a 24v motor and I want to control it using än Arduino Uno. Suggestions?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor needs to run both directions and is going to draw about 5A&lt;/p&gt;&#xA;" OwnerUserId="18805" LastEditorUserId="18805" LastEditDate="2016-04-20T14:28:55.737" LastActivityDate="2019-01-17T08:45:00.807" Title="Motor controller for 24v motor, Arduino Uno" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23369" PostTypeId="2" ParentId="23368" CreationDate="2016-04-20T14:22:49.893" Score="0" Body="&lt;p&gt;I'm doing my own driver dude using Tip122 but you can use TIP120 too &lt;a href=&quot;https://www.fairchildsemi.com/datasheets/TI/TIP120.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TIP&lt;/a&gt;and other components&#xA;&lt;a href=&quot;https://i.stack.imgur.com/WD5Bx.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WD5Bx.gif&quot; alt=&quot;TIP122 driver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20375" LastActivityDate="2016-04-20T14:22:49.893" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23371" PostTypeId="1" AcceptedAnswerId="28858" CreationDate="2016-04-20T14:38:16.090" Score="5" ViewCount="4970" Body="&lt;p&gt;I've noticed that on the back of an Arduino PRO mini are two Jumpers next to the &lt;code&gt;A4&lt;/code&gt; and &lt;code&gt;A5&lt;/code&gt; pins, marked with red in the following :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/358z0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/358z0.png&quot; alt=&quot;Pro mini Back view with jumpers selection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the leads one seems to be a bypass for the POWER Led and the other a bypass for the regulator, but not sure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, the schematic reveals just one Jumper &lt;code&gt;SJ1&lt;/code&gt; : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GCJcp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GCJcp.png&quot; alt=&quot;Arduino Pro mini - Power schematic with jumper selection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions are :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why are there two physical Jumpers on the board ? &lt;/li&gt;&#xA;&lt;li&gt;Are these two jumpers actually just one : &lt;code&gt;SJ1&lt;/code&gt; ?&lt;/li&gt;&#xA;&lt;li&gt;And if so how to connect them in order to enable &lt;code&gt;Power isolation&lt;/code&gt; ?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="8240" LastEditorUserId="7856" LastEditDate="2016-04-21T07:50:15.493" LastActivityDate="2022-07-20T11:17:14.210" Title="Arduino PRO Mini - The pads [was &quot;jumpers&quot;] on the back and Low Power Consumption" Tags="|power|arduino-pro-mini|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23373" PostTypeId="2" ParentId="23368" CreationDate="2016-04-20T14:48:23.723" Score="2" Body="&lt;p&gt;try this &lt;a href=&quot;http://www.robotshop.com/en/arduino-compatible-mega-motor-shield-1a-5-28v.html&quot; rel=&quot;nofollow&quot;&gt;Arduino Compatible Mega Motor Shield&lt;/a&gt;. Specs:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Low-cost robust H-bridge ''shield'' for Arduino&lt;/li&gt;&#xA;&lt;li&gt;Provides the ability to control up to 30A of current at up to 28V&lt;/li&gt;&#xA;&lt;li&gt;Supply voltage: 5V to 28V (24V max battery rating)&lt;/li&gt;&#xA;&lt;li&gt;Continuous output current: 13A&#xA;Have, a look:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-20T14:48:23.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23377" PostTypeId="2" ParentId="12564" CreationDate="2016-04-20T15:40:44.183" Score="1" Body="&lt;p&gt;Some of the capacitive sensors need a seperate regulated power supply.You can look into the data sheet of the capacitive sensor.Maybe you can try with the same.&#xA;I just read the datasheet of At42qt2120 cap sensor.&lt;/p&gt;&#xA;" OwnerUserId="20379" LastActivityDate="2016-04-20T15:40:44.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23378" PostTypeId="1" AcceptedAnswerId="23379" CreationDate="2016-04-19T23:55:59.183" Score="1" ViewCount="2646" Body="&lt;p&gt;The &lt;strong&gt;LED_UPDATE()&lt;/strong&gt; is called in my &lt;strong&gt;loop()&lt;/strong&gt; function, I implemented it (tried anyways),&#xA;to send sms as shown in the code such that  only one sms is sent , because as the &lt;strong&gt;loop()&lt;/strong&gt; keeps calling &lt;strong&gt;LED_UPDATE()&lt;/strong&gt;, it's going to keep sending an sms every time (yep you guessed it, very bad for credit :o ) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;any tips on how I can get around this or what i'm doing wrong in my code would be much appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;p.s.&lt;/strong&gt; nearly left my mobile phone in the code lol &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void LED_UPDATE(int state) &#xA;{&#xA;&#xA;int count; // initialized to zero, once program runs it automatically enter state ==1 &#xA;if (state == 1)&#xA;{&#xA;&#xA;    digitalWrite(RED_PIN, LOW);&#xA;    digitalWrite(GREEN_PIN, HIGH);&#xA;    count=0; &#xA;}&#xA;else if (state == 2)&#xA;{&#xA;  count+=1;&#xA;  Red_Blink();&#xA;&#xA;  if(count == 1 )&#xA;  {&#xA;    sms.SendSMS(&quot;086XXXXXXX&quot;, &quot;PANIC BUTTON PRESSED, Subject needs help!!!&quot;);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15192" OwnerDisplayName="HummingDev" LastEditorUserId="15192" LastEditDate="2019-06-18T15:55:49.950" LastActivityDate="2019-06-18T15:55:49.950" Title="Arduino to send sms one time only when a button is pressed" Tags="|wires|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23379" PostTypeId="2" ParentId="23378" CreationDate="2016-04-20T00:08:56.417" Score="0" Body="&lt;p&gt;You are resetting &lt;code&gt;count&lt;/code&gt; every time you enter the function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static int count; // initialized to zero, once.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding the static statement should initialise the variable once and preserve its value between calls.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="transistor" LastActivityDate="2016-04-20T00:08:56.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23380" PostTypeId="1" CreationDate="2016-04-20T16:54:49.337" Score="0" ViewCount="1113" Body="&lt;p&gt;I'm looking to minimise the parts count and the power consumption as much as possible and I was wondering if is it possible to store a variable or execute a method when the 'reset' button is pressed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;I didn't find any docs or hints regarding this.&lt;/strike&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In theory, can it be done with an interrupt?&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Edit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;In a further research Atmel shows, that if you burn the 'RSTDISBL' fuse (still in theory for me) you can get hold of the reset button by transforming it in a I/O pin with &quot;special&quot; electric characteristics:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RFOm8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RFOm8.jpg&quot; alt=&quot;Atmega 382 reset short description focus &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you look at the schematic the reset pin shows that it has what it needs to be an I/O pin:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/O0qOz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/O0qOz.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I say in theory because I really don't know if arduino has the required constellation for this capability and if it comes whit the fuses already burned. &lt;/p&gt;&#xA;" OwnerUserId="8240" LastEditorUserId="8240" LastEditDate="2016-04-20T21:54:37.193" LastActivityDate="2016-04-21T02:37:59.550" Title="Reset as I/O pin" Tags="|arduino-ide|interrupt|reset|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23381" PostTypeId="2" ParentId="23371" CreationDate="2016-04-20T17:47:11.850" Score="1" Body="&lt;p&gt;I think those aren't jumpers, but pads to place two pull-up resistors for I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems the eagle files Sparkfun shares aren't the same as the board in the picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you don't need to worry about this. If the RAW pin is not connected the MIC5205 regulator uses only 0.01μA according to the datasheet.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-20T17:47:11.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23382" PostTypeId="1" CreationDate="2016-04-20T18:01:05.703" Score="2" ViewCount="245" Body="&lt;p&gt;My kids got many fluffy toys, and I would like to make them move and talk. Something like a small platform with wheels and a speaker and some sensors that I would be able to mount any of the toys on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to build something like 2 platforms with motors and sensors that move around, and when encountering obstacles &quot;bark&quot; at them through the speakers, wait random number of seconds, and move in different directions. Then the kids would mount their favorite fluffy dogs/cats/bears/rabbits on top of these platforms and unleash them on each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am very new to DIY; what do I need to buy for such a project?&lt;/p&gt;&#xA;" OwnerUserId="16313" LastActivityDate="2016-04-22T06:14:32.943" Title="What do I need to make fluffy toys move and talk?" Tags="|motor|sound|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23383" PostTypeId="1" AcceptedAnswerId="23389" CreationDate="2016-04-20T18:38:18.813" Score="0" ViewCount="784" Body="&lt;p&gt;I have been trying to use my newly bought L293d Motor Driver Module to run motors(a single motor in this test case, simple 5V toy motor) from my Arduino UNO. Thing is, this is an entire module, not just the IC (in which case there are many tutorials available). So I was following this tutorial to try and get my motor running.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the tutorial - &lt;a href=&quot;http://www.instructables.com/id/Arduino-and-L293D-Robot-Part-1-/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Arduino-and-L293D-Robot-Part-1-/?ALLSTEPS&lt;/a&gt;&lt;br&gt;&#xA;Here's what the module looks like - &lt;a href=&quot;https://i.stack.imgur.com/DoTMM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DoTMM.jpg&quot; alt=&quot;The module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 6 Pins on the module, which bring out the 6 inputs, EN1, EN2, IN1, IN2, IN3, IN4. Now since I am using only one motor, I connected my motor to the OUTPUT 1 &amp;amp; 2 header given on the module. I then take the 5V and GND from Arduino and connect them to my Module's 5V and GND header, (leaving the 12V one empty), I thought that this would be enough as my motor is also of 5V.&lt;br&gt;&#xA;I then connected the IN1 and IN2 to the pins 7 &amp;amp; 8 on my Arduino and used the following code-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Simple code to make the motor turn&#xA;int RightMotorForward = 7;&#xA;int RightMotorReverse = 8;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(RightMotorForward, OUTPUT);&#xA;  pinMode(RightMotorReverse, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;   digitalWrite(RightMotorForward, HIGH);&#xA;   delay(10000);&#xA;&#xA;   digitalWrite(RightMotorForward,LOW);&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nothing happened. The motor didn't work and I have no idea why. I've gone through the entire datasheet for L293D but I found nothing that could help me. I suspect that it has something to do with the EN1 pin, but I don't really know how to use it, the tutorial said to connect it to 5V, which I tried but no results. So where am I making the mistake? How do I get this to work?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-04-21T05:23:03.063" LastActivityDate="2016-04-21T05:23:03.063" Title="Using a L2938D Motor Driver Module. (Not IC, Module)" Tags="|arduino-uno|motor|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23384" PostTypeId="2" ParentId="23383" CreationDate="2016-04-20T18:49:21.257" Score="0" Body="&lt;p&gt;While no one can tell you exactly how to connect that board without having its documentation or the board in hand to examine visually or with an ohm-meter, it is quite likely that by leaving the &quot;12v&quot; terminal unconnected, no power is being provided to the motor side of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It kind of looks like there is a voltage regulator on board, so it may be that it will even provide 5v on that terminal when given something 7 volts (or so) or higher on the &quot;12v&quot; terminal - again, we cannot know without details of your exact board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The L293 is an old and low-performing chip, with internal losses that mean  that to achieve 5 volts across a motor, you will need to supply very nearly 7 volts to the chip.  The difference gets wasted as heat.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-20T18:49:21.257" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23385" PostTypeId="2" ParentId="23382" CreationDate="2016-04-20T19:01:08.527" Score="2" Body="&lt;p&gt;You will need a processor board, motor driver, sensors, and audio amplifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you are asking on the Arduino forum, it would be natural to consider one of the Arduino boards or derivates - but beware they tend to be rather antiquated compared to alternatives now available.  The plus side of the classic ATmega boards is the wide variety of read-to-go example code available right within the IDE, and the wide supply voltage range (of the bare chips if not the boards) which is more compatible with AA-cell battery packs than competing device's narrower voltage range tends to be.  The one part of the functionality you describe that is a bit of an issue is the audio output - you can get it from an ATmega but it will be poor in quality and you will need to add storage for the &quot;bark&quot; data.  You might almost consider a separate module with an ATtiny and a small SD card for that (ironically the ATtiny while generally less capable has fast PWM better suited to audio).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For motor drivers, especially when using batteries steer clear of the older bipolar L293/L298 type of solutions, as these have very high internal loss which basically means that one cell in your battery pack exists just to generate heat in the driver IC.  A modern FET based driver (the TB6612FNG is quite popular) will be better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For sensors you probably want one or more of microswitches extended with &quot;whiskers&quot;, ultrasonic rangefinders, or short range IR reflectance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some dual wheel drive (or &quot;tank steering&quot;) RC toys can be worth considering as platforms, but their gearing may be too fast for your purposes, particularly those designed to spin and tumble.  Continuous rotation servos are sometimes mentioned, but it can be hard to get them tuned to not rotate when commanded to stop, and mounting wheels can be tricky.  The small plastic gearboxes work well if you can get matching wheels but are hard themselves to mount.  Access to a 3d printer can be quite useful for creating missing physical components, though a block of wood and a router can make a nice chassis, too.  You can also buy ready made Arduino robot base kits with chassis, gearboxes, and wheels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For audio output, you can accomplish something with an NPN transistor and base resistor driving a speaker, but best results would be with a small class D driver board as are now widely sold for a few dollars.  They tend to be stereo, but you can feed both sides with the same signal.  If you only wanted &quot;robot beeps&quot; you can drive a piezo disk directly from a processor pin with reasonable loudness at higher frequencies, but the low frequency response is quite poor.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-20T19:12:11.260" LastActivityDate="2016-04-20T19:12:11.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23386" PostTypeId="1" CreationDate="2016-04-20T19:04:01.217" Score="2" ViewCount="326" Body="&lt;p&gt;I am working on wearable project using an Adafruit Flora V2, and for this project I need to use the onboard NeoPixel. I also need to use Neopixels that are attached to the D6 pin (is it a pin?). I have a line at the beginning of my program that says &lt;code&gt;#define PIN 6&lt;/code&gt;. I found that I can use the onboard NeoPixel by changing this to &lt;code&gt;#define PIN 8&lt;/code&gt;. Is there a way to use the onboard NeoPixel &lt;b&gt;and&lt;/b&gt; the ones attached to D6. I already have everything wired up, and the rest of my program is written, I just need to use both pins. Thanks for any possible help.&lt;/p&gt;&#xA;" OwnerUserId="20383" LastEditorUserId="20383" LastEditDate="2016-04-20T19:25:43.110" LastActivityDate="2016-07-19T23:38:59.133" Title="Adafruit Flora V2 use onboard and external NeoPixels" Tags="|programming|pins|adafruit|neopixel|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23387" PostTypeId="2" ParentId="23382" CreationDate="2016-04-20T19:26:39.083" Score="2" Body="&lt;h2&gt;&lt;strong&gt;Don't do it.&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;When you say to us:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am very new to DIY; what do I need to buy for such a project?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Then you really aren't ready yet.  Sometimes a virtuoso or savant exists, and they can make incredible DIY projects, but for most people, jumping into such an aggressive project as your first DIY is a recipe for disaster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not trying to be a smart-ass or negative, but you should get an Arduino and try some PROTOTYPING first.  Again, not trying to be a smart-ass, but if you even have to ask this question, then you really aren't ready yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I work with people on their first project, you should see how excited they get when they can get a light to blink (I still get excited each time too)!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should go for more of a &quot;karate kid&quot; approach: Wax the car, paint the fence, sand the floor.  Once you know the fundamentals, you'll be a ninja before you know it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could list a pile of &quot;fundamentals&quot; here, but any other guide would be more comprehensive than my Arduino karate kid list.&lt;/p&gt;&#xA;" OwnerUserId="19745" LastEditorUserId="6936" LastEditDate="2016-04-22T06:14:32.943" LastActivityDate="2016-04-22T06:14:32.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23389" PostTypeId="2" ParentId="23383" CreationDate="2016-04-20T19:35:10.697" Score="0" Body="&lt;p&gt;ooops. That &lt;strong&gt;5V&lt;/strong&gt; you are applying to &lt;strong&gt;5V pin&lt;/strong&gt; is actually an output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must apply some input voltage at the &lt;strong&gt;12V&lt;/strong&gt; &amp;amp; &lt;strong&gt;GND&lt;/strong&gt; inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't forget to remove that &lt;strong&gt;5V&lt;/strong&gt; connection to &lt;strong&gt;5V pin&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-20T19:35:10.697" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23390" PostTypeId="1" CreationDate="2016-04-20T20:35:42.740" Score="0" ViewCount="1339" Body="&lt;p&gt;I am hoping I could get some help developing a an idea I have for archaeologists/soil scientists using an arduino and the TCS3200 colour sensor. The idea I have is a simple device which can determine munsell colours with more accuracy and speed. The current conventional method is to use colour chips/swatches found in the Munsell system booklet and match them as close to examples of sediment/soil found at archaeological sites. The problem with doing this method is that it is highly subjective, and time consuming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to use the Adafruit TCS34725 to read and detect the RGB colour of the sediment (in the RBG colour space) and convert the data into the Munsell System. I have all the data of what RGB ratio corresponds to each Munsell colour -- which I have downloaded from this site: &lt;a href=&quot;http://www.cis.rit.edu/research/mcsl2/online/real_sRGB.xls&quot; rel=&quot;nofollow&quot;&gt;www.cis.rit.edu/research/mcsl2/online/real_sRGB.xls&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I use the sketch provided, I can not figure out how to use the &quot;if&quot; statement to &quot;Serial.print&quot; what the munsell colour corresponds to the RGB colour detected by the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My ultimate goal is to modify the colour view sketch here &lt;a href=&quot;https://github.com/adafruit/Adafruit_TCS34725/tree/master/examples&quot; rel=&quot;nofollow&quot;&gt;see: colorview&lt;/a&gt;&#xA;I would like to keep the everything provided but change two things, I would like to convert RGB into Munsell using the data provided by the RIT link and also add a screen and button to start the read process and display the colour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If some one would be willing to help me that would be great!, &lt;/p&gt;&#xA;" OwnerUserId="20389" LastActivityDate="2016-04-22T14:53:08.133" Title="Converting RGB from color sensor into the Munsell Color System" Tags="|sensors|rgb-led|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23391" PostTypeId="2" ParentId="23386" CreationDate="2016-04-20T21:51:03.753" Score="2" Body="&lt;p&gt;The #define is just letting you use a nice name for the numeric value of the pin.  If you want to use two different pins, you use two different names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you might define them at the beginning something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BOARDLED 8&#xA;#define STRIPLED 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you create a NeoPixel object that uses that pin.  In your case, you'll do this twice.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_NeoPixel flora_led = Adafruit_NeoPixel(60, BOARDLED, NEO_GRB + NEO_KHZ800);&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, STRIPLED, NEO_GRB + NEO_KHZ800);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then you call the one you want to set/modify/show/etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strip.show();&#xA;flora_led.show();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3500" LastActivityDate="2016-04-20T21:51:03.753" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23392" PostTypeId="1" AcceptedAnswerId="23397" CreationDate="2016-04-20T22:59:55.560" Score="0" ViewCount="421" Body="&lt;p&gt;Ok, so i'm trying to make &lt;a href=&quot;http://www.instructables.com/id/AbHhGD-the-Arduino-Based-Hand-held-Gaming-Device/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;This Project&lt;/a&gt; and the code comes all in different .ino files but in the video its all in one program. So how do I compile all of the code onto the arduino? (By the way the code is on step 5 in a .zip file) Thank you!&lt;/p&gt;&#xA;" OwnerUserId="20393" LastEditorUserId="6628" LastEditDate="2016-04-21T02:06:21.153" LastActivityDate="2016-04-21T02:09:45.460" Title="Help compiling multiple .ino file code with code! (I'm not sure what to name this)" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23393" PostTypeId="1" CreationDate="2016-04-20T23:36:03.553" Score="0" ViewCount="1416" Body="&lt;p&gt;I have a problem collecting data from my accelerometer/gyroscope sensor with a constant sampling rate. Is there a way to program the arduino to collect data from the sensor and store these values in a SD card with a constant frequency of 1kHz without using delay? The sensor that I am using is a MPU6050 gy-521 sensor that uses I2C with arduino. I will be reading 6 different datas from my sensor: acceleration in x,y,z directions and gyration in x,y,z directions. Thank you all in advance for the advice/help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so my project will be making a device that collects the values from the sensors and saves them to study the data later. First, a LCD display will print out a message without having any data collection to occur. The data collection will start when a button is pushed. After the button is pushed, the display will print out another message saying that the arduino is collecting data and the Arduino will save the 6 values (x,y,z acceleration and gyration) from the accelerometer/gyroscope sensor to the SD card. The data collection will stop after the button is clicked again and the display will print out another message saying that it has stopped collecting data. Then, this process can start again if the button is clicked once again. Thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="20302" LastEditorUserId="20302" LastEditDate="2016-04-25T15:38:45.173" LastActivityDate="2016-04-25T15:38:45.173" Title="sensor sampling frequency" Tags="|frequency|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23394" PostTypeId="1" CreationDate="2016-04-21T00:21:48.510" Score="2" ViewCount="469" Body="&lt;p&gt;I'm using a MAX7219 and 6 (six) seven segment displays&#xA;I used my own board and two purchased on ebay - no difference in operation.&#xA;MOSI, and CLK are correct and verified with my scope (Tektronics)&#xA;CS (chip select) is pin 22 (for no particular reason) SPI is set to Mode0&#xA;Yes, I have tried other pins as CS - all work the same.&#xA;My MEGA board can be powered by USB or 9.9 VDC wall-wart - no difference&#xA;Trial code is shown below, and works properly.&#xA;Placed 47 uF 50V cap on display board between +5 and GND - no effect&#xA;Placed 220 uF 35V cap on display board between +5 and GND - no effect&#xA;MOSI, SCK and CS are verified with scope to be 5 VDC. Compiler and D/L applications are set to MEGA and seem to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PROBLEM IS THIS:&lt;/strong&gt;&#xA;Code compiles and D/L properly into Mega. Mega resets, and about 50% of the time all digits illuminate (not executing code properly?) Digit 0 (most right hand digit is enabled) never works. I can press the reset on the Mega as many times as I want - no effect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HOWEVER&lt;/strong&gt; if I pull either +5 or GND to the MAX7219 module, and reset my Mega, it works perfectly. Yes, this is obviously a reset problem, but I've never seen a reset problem before with the MAX7219. I put delays at the beginning at short delays in the SPI communications to no effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone ever seen anything like this before? I have no hair left to pull. I'm thinking maybe to use a MOSFET to turn the MAX7219 on after the MEGA is up and running. Any suggestions are appreciated.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; //version 0.1&#xA; #include &amp;lt;SPI.h&amp;gt;&#xA; #define LOAD_PIN 22&#xA;&#xA; void maxTransfer(uint8_t address, uint8_t value) {&#xA;&#xA; digitalWrite(LOAD_PIN, LOW);      // Ensure LOAD/CS is enabled (LOW)&#xA; SPI.transfer(address);            // Send the register address&#xA; SPI.transfer(value);              // Send the value&#xA; digitalWrite(LOAD_PIN, HIGH);     // Tell chip to toggle in data&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA; pinMode(LOAD_PIN, OUTPUT);          // Set port pin to output&#xA;&#xA;                 // Reverse the SPI transfer to send the MSB first  &#xA; SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0)); &#xA;&#xA;                 // Start SPI with attributes in &quot;SPI.beginTransaction&quot;&#xA;delay(250); &#xA;SPI.begin();&#xA; maxTransfer(0x09, 0xFF);           // Enable mode B&#xA; maxTransfer(0x0A, 0x0F);            // Use highest intensity&#xA; maxTransfer(0x0B, 0x00);           // Only scan digit 0&#xA; maxTransfer(0x0C, 0x01);            // Turn on chip&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Loop through each code&#xA;  for (uint8_t i = 0; i &amp;lt; 0x10; ++i)&#xA;  {&#xA;    maxTransfer(0x01, i);&#xA;    delay(50);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20397" LastEditorUserId="37523" LastEditDate="2019-07-06T04:15:58.393" LastActivityDate="2019-07-06T04:15:58.393" Title="Arduinino &amp; Max7219" Tags="|arduino-mega|spi|reset|7-segment|max7219|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23395" PostTypeId="2" ParentId="23348" CreationDate="2016-04-21T00:23:45.840" Score="1" Body="&lt;p&gt;Connect to the server as usual with &lt;code&gt;espClient.connect()&lt;/code&gt;. The following request should return a JSON object containing your channel description and the first 2 entries in your feed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;espClient.println(&quot;GET /channels/CHANNEL_ID/feeds.json?results=2 HTTP/1.1&quot;);&#xA;espClient.println(&quot;Host: api.thingspeak.com&quot;);&#xA;espClient.println(&quot;Connection: close&quot;);&#xA;espClient.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it's a private channel, then you must supply your Read API key like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;espClient.println(&quot;GET /channels/CHANNEL_ID/feeds.json?api_key=&amp;lt;your API key&amp;gt;&amp;amp;results=2 HTTP/1.1&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that I use &lt;code&gt;println()&lt;/code&gt; and not &lt;code&gt;print()&lt;/code&gt; in order to implicitly terminate each request line properly. You should end each line not with &lt;code&gt;\n&lt;/code&gt; but with &lt;strong&gt;&lt;code&gt;\r\n&lt;/code&gt;&lt;/strong&gt;. You only need to type this yourself if you use &lt;code&gt;print()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To read the returned JSON data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (espClient.available() == 0);  // wait till something comes in; you may want to add a timeout here&#xA;&#xA;unsigned long lastRead = millis();  // keeps track of last time a byte was read&#xA;while (millis() - lastRead &amp;lt; 2000) {  // while 2 secs havent passed since a byte was read&#xA;  while (espClient.available()) {&#xA;    Serial.print(espClient.read());&#xA;    lastRead = millis();   // update last time something was read&#xA;  }&#xA;}&#xA;client.stop();  // close socket&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To parse the JSON string, you either get a library from GitHub or you parse the string yourself.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-04-21T00:23:45.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23396" PostTypeId="1" AcceptedAnswerId="23409" CreationDate="2016-04-21T01:53:08.643" Score="1" ViewCount="888" Body="&lt;p&gt;I was trying to use my L293D motor driver module. But when I upload the following sketch to try and run my motor, but it would get stuck on &quot;Uploading&quot;. This happens with this sketch only, and happens randomly, with odds of happening being 3 in 5 times. After a bit fiddling around I found an error  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Programmer is not responding.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I try to reset the board or just reconnect it to my PC it might work.&lt;br&gt;&#xA;Here's the sketch- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int RightMotorForward = 12;&#xA;int RightMotorReverse = 13;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(RightMotorForward, OUTPUT);&#xA;  pinMode(RightMotorReverse, OUTPUT); &#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;   digitalWrite(RightMotorForward, HIGH);&#xA;   delay(10000);&#xA;&#xA;   digitalWrite(RightMotorForward,LOW);&#xA;   delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anybody point out where I am going wrong? I am using Arduino UNO. Is this just some problem in my code?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-04-21T05:10:29.727" LastActivityDate="2016-05-21T09:45:31.790" Title="Arduino IDE get stuck while uploading sketch" Tags="|arduino-uno|arduino-ide|motor|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23397" PostTypeId="2" ParentId="23392" CreationDate="2016-04-21T02:09:45.460" Score="0" Body="&lt;p&gt;One of the .ino files is likely the main code file.  Name the enclosing folder with the name of the .ino file, then compile it as normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, AbHhGD.ino is the main file, and its folder should be named 'AbHhGD'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The comments indicate there are missing libraries you likely need to install.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-04-21T02:09:45.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23398" PostTypeId="2" ParentId="23380" CreationDate="2016-04-21T02:31:22.057" Score="1" Body="&lt;p&gt;Yes, there are several possibilities here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is detecting state after reset and acting on it.  One of the reasons you might do that would be to shut the processor down all but completely, and let the reset wake it back up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another would be to program the reset disable fuse and repurpose it as an I/O pin - of course if you do that, you can only then reprogram the chip if you have implement working functionality to get back to the bootloader (or similar), or if you use a high voltage programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are in the category of things which make development a lot more difficult, but are sometimes worthwhile as they let you squeeze a little more capability out of the hardware.  If you are just starting a design, you might consider a different chip instead - but if you have existing boards or design investment, and this lets you get the last little bit of needed capability from it, it is possible.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-21T02:37:59.550" LastActivityDate="2016-04-21T02:37:59.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23399" PostTypeId="2" ParentId="23371" CreationDate="2016-04-21T03:27:27.897" Score="1" Body="&lt;p&gt;These pads are not jumper SJ1. On the front of the board just beneath the GND pad there is a blob of solder. This is SJ1 (I believe - I am writing from memory, I do not have a Pro Mini sitting on my desk at the minute) and removing the solder blob will disconnect the LED and output of the regulator from Vcc.&lt;/p&gt;&#xA;" OwnerUserId="20400" LastActivityDate="2016-04-21T03:27:27.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23400" PostTypeId="1" CreationDate="2016-04-21T03:54:02.397" Score="1" ViewCount="590" Body="&lt;p&gt;I'm looking to connect an 8-relay board to an Arduino Uno. A board &lt;a href=&quot;http://www.ebay.com/itm/221389425632&quot; rel=&quot;nofollow&quot;&gt;like this one&lt;/a&gt;. However, I don't really want to use up 8 digital outputs if I don't have to. Is there some intermediate circuitry I can either buy or build that would do this? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, can I connect something to the serial so that sending '3' would result in binary 00000011 and thus turn on relay's 1 and 2?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternately, and probably more lazy, is there an extension board that would just give me a pile more digital pins?&lt;/p&gt;&#xA;" OwnerUserId="4843" LastActivityDate="2016-04-21T09:55:12.547" Title="How can I connect an 8-relay board without using 8 digital pins?" Tags="|relay|" AnswerCount="3" CommentCount="3" ClosedDate="2016-04-26T04:24:46.570" ContentLicense="CC BY-SA 3.0" />
  <row Id="23401" PostTypeId="2" ParentId="23400" CreationDate="2016-04-21T04:13:26.057" Score="1" Body="&lt;p&gt;A likely solution is to use the Arduino SPI interface and the Arduino SPI &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;library&lt;/a&gt; to control a SPI relay board.  &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=8209.0&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a 6 year old thread talking about such a board. And &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=293858.0&quot; rel=&quot;nofollow&quot;&gt;another&lt;/a&gt; more recent relay thread where SPI is brought up.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-21T04:13:26.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23402" PostTypeId="2" ParentId="23396" CreationDate="2016-04-21T04:26:41.923" Score="0" Body="&lt;p&gt;Is the motor driver connected to the Arduino while you program it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the Arduino is reset, the output pins on the Arduino are driven high. If too much current is drawn though any of these pins, then the voltage supply to the ATMega328 may drop, and the ATMega328 gets stuck in a brownout. &lt;/p&gt;&#xA;" OwnerUserId="20400" LastActivityDate="2016-04-21T04:26:41.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23403" PostTypeId="2" ParentId="23393" CreationDate="2016-04-21T04:27:38.973" Score="1" Body="&lt;p&gt;You have discovered delay() does not guarantee the period of your code.  This is because the period of your code is the delay() plus the time for your code to execute.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need is a hardware clock to give your code an indication that a fixed period has expired.  &lt;a href=&quot;http://playground.arduino.cc/Code/Timer&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; is one of several Arduino timer libraries. The timer library web page describes your problem in more detail with example code using delays and using the timer library features.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-21T04:27:38.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23406" PostTypeId="2" ParentId="23390" CreationDate="2016-04-21T07:54:08.160" Score="1" Body="&lt;p&gt;I have some thoughts on your task. First of all colorimetry is a science on its own. I know people working in this field for decades with equipment costing many millions of €. They all share some basic wise words. One is: &quot;Because we all see colours we think measuring colous is an easy task. The opposite is true. Many of the best colorimetrists are colour blind.&quot; One second is: &quot;Without light there is no colour&quot;. I will write on this later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Colorimetry in fact is a complex matter. Between a colored piece of stone and a numerical value normally lie a lot of transformations and convolutions. And inbetween there are also lurking many error sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This said, I'm sure it will be possible to produce somewhat acceptable results with your sensor. Provided you do a proper calibration and add a calibratable light source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaking of light source. A piece of stone can only reflect incident light (except some uranium/radium salts, you don't want to deal with). Pigments are basically LTI-systems (aka passive filters). This means they can only reflect wavelengths which are present in the incident light. And the will reflect a well defined and individual proportion of each wavelength regardless the luminous flux of the incident light. This means, if your incident light contains nearly no blue light then the stone or whatever you want to examine will reflect only the fraction of &quot;nearly no light&quot; it typically does reflect of any amount of blue light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the remission spectra of all pigments get shaped (multiplied) by the spectrum of the incident light. Your sensor sees only the reflected light and therefore will give totally different results for one and the same object depending on the incident light. Look up the spectra for daylight and incandescent light and think about the results of your sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make a long story short, you can only yield reproducable measurements if you supply your own light source along with the sensor. This is in fact the way all colour meters work.&#xA;The only other way was to measure the full spectrum of the incident light. Reasonable portable spectroradiometers for this purpose cost 5000 €. So it's better to go for a light source :).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As they are rather affordable I recommend using LEDs to make up a light source for examination. But LEDs suffer from several drawbacks. They tend to change their output spectrum with their chip temperature and ageing processes. So you have to supply a proper calibration procedure for your measuring equipment. And you better do the calibration sequence before every measurement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You then have to design an apparatus which allows the light from your LED fall onto your samples (stones, sediments or so) but prevents other scattered or direct light to enter your sensor. Otherwise all measurements will be crap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this is not a direct answer to your question, I think the topic is important enough to write an elaborate pamphlet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now some more words more closely related to your problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general loading a huge excel table into your arduino is not necessarily a good idea, even if a big &quot;if&quot;-code array was possible. Storage is scarce on this platform. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you combine a lookup table with interpolation, you can save much space. You would have to omit 90% of all datapoints and estimate all in between when measuring. Still the table will be rather big, because you have three degrees of freedom.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another drawback of big tables and LUT with interpolation is, that it makes calibration difficult. Normally, when you calibrate your sensor, you have to adjust the parameters along the calculation. If you rely on a table, you have to exchange the whole table, regardless if it is something like that excel thingy or a condensed lookup table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you go for an analytical solution, as suggested in one comment, the number of parameters you have to update after calibration reduces drastically. Effectively you have to adjust some factors and offsets in the equations for this problem. Of course you will have to learn the ropes of the photometric equations, but you will  have to do that anyway, I think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some more words on the design of your appartus. Your idea of a cylinder in front of your probe is good. I recommend to fit it with a rim of black foam rubber, so you can seal light coming from outside. And you have to paint the inside of your cylinder as black as you can. See the interiour of a camera objective for reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is white you will have multiple reflections and multiple filtering which deteriorates your measurement results vastly.&lt;/p&gt;&#xA;" OwnerUserId="4358" LastEditorUserId="4358" LastEditDate="2016-04-22T14:53:08.133" LastActivityDate="2016-04-22T14:53:08.133" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23407" PostTypeId="2" ParentId="23400" CreationDate="2016-04-21T08:29:32.030" Score="-1" Body="&lt;p&gt;You can use a MUX/DEMUX. Check out the link. Basically, you can select the output pin by a series of commands that you can do with the Arduino. The relay inputs will be hooked up to the IC's outputs&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.sparkfun.com/datasheets/IC/cd74hc4067.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/IC/cd74hc4067.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13376" LastActivityDate="2016-04-21T08:29:32.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23408" PostTypeId="2" ParentId="12133" CreationDate="2016-04-21T08:39:51.353" Score="0" Body="&lt;p&gt;First, check the USB cable - I had the same problem. If you have checked it, try the &lt;a href=&quot;https://github.com/NicoHood/Hoodloader2&quot; rel=&quot;nofollow&quot;&gt;HoodLoader2&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using it and it works with Arduino Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="20403" LastEditorUserId="20403" LastEditDate="2016-04-25T19:19:44.303" LastActivityDate="2016-04-25T19:19:44.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23409" PostTypeId="2" ParentId="23396" CreationDate="2016-04-21T08:47:24.430" Score="0" Body="&lt;p&gt;Found the solution... Just connect the 5v from arduino to the 5v on the Module. Then another battery (12-36 V, I tried a 9v one... it worked but only for about 40 seconds), to the 12 V input, keeping the ground common... That's gonna make the motors run!&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-04-21T08:47:24.430" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23411" PostTypeId="2" ParentId="23400" CreationDate="2016-04-21T09:55:12.547" Score="0" Body="&lt;p&gt;There are ICs that provide additional I/O ports through either the SPI or I2C busses, such as  &lt;a href=&quot;http://www.microchip.com/wwwproducts/en/en023499&quot; rel=&quot;nofollow&quot;&gt;MCP23017&lt;/a&gt; or &lt;a href=&quot;http://www.microchip.com/wwwproducts/en/en537375&quot; rel=&quot;nofollow&quot;&gt;MCP23018&lt;/a&gt; or their 8 port equivalents.&#xA;There are many different makes, search Google for &quot;Arduino addition IO Pins&quot;&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-21T09:55:12.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23412" PostTypeId="1" CreationDate="2016-04-21T10:50:45.840" Score="3" ViewCount="143" Body="&lt;p&gt;I would like to use Arduino to control locks around a building which is 5 storeys high and on every floor there is 2 door. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm concerned whether the wires is able to travel all the way from the ground floor to the 5th floor to provide enough power to the relay located at the door. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lock will be a 12V magnetic lock and it will be unlocked thru a SSR relay which will be controlled by the arduino&lt;/p&gt;&#xA;" OwnerUserId="20410" LastEditorUserId="20410" LastEditDate="2016-04-21T11:07:46.210" LastActivityDate="2016-04-22T13:28:36.380" Title="Arduino IO long distance travel" Tags="|power|pins|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23413" PostTypeId="2" ParentId="23412" CreationDate="2016-04-21T11:13:00.687" Score="2" Body="&lt;p&gt;Yes, losses in wires are proportional to the length, so an excessively long wire may not be able to deliver enough power. Many factors come into play here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;higher current consumed by the relay increases the losses&lt;/li&gt;&#xA;&lt;li&gt;smaller wire diameter increses the losses&lt;/li&gt;&#xA;&lt;li&gt;the voltage required by your relay defines how much you can afford to lose&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For example, a pair of &lt;a href=&quot;https://en.wikipedia.org/wiki/American_wire_gauge&quot; rel=&quot;nofollow&quot;&gt;AWG23&lt;/a&gt; wires 30m long will have a total resistance of 4 Ohm. If your relay consumes 100 mA, you will lose 0.4V in the wires. If Arduino delivers 5V, and the relay requires a mininum of 4.5V to work, you're just good enough: you're delivering 4.6V to the relay after the losses.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-04-21T11:13:00.687" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23414" PostTypeId="1" CreationDate="2016-04-21T12:02:58.197" Score="4" ViewCount="1439" Body="&lt;p&gt;I'm doing an rfid project that requires a read range of at least 5 inches or about 13cm.  I'm using a nano with a usb port, a rfid reader from priority 1 design and a large antenna. The problem I'm running in to is that when I power the project from the usb port I get a pretty decent read range of 11-13cm. But when I power the project from a DC power supply the read range drops considerably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a lot of testing with various power supplies I believe that all my power adaptors are dirty enough to cause rf interference and reduce the range.  Powering the project with a 9v battery and a 5v power regulator gives me really good range: 18cm with the largest antenna.  But I need plug in power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can I power this project in a way that gives me ultra clean power?&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I tried that same 5v regulator with a 5v adaptor and still had short read range.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Someone suggested adding a smoothing capacitor between V+ and Gnd but I wouldn't know what size.  I'm not an EE - I'm just a coder with a soldering iron.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a better power supply I can get?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;[EDIT] Also just FYI, when I connect even only the ground wire the the computers USB port I get a much farther read range. So..&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;Could it be a case of needing to ground the circut better as the switching power supplies only have 2 prongs and probably no real &quot;ground&quot;. (Or am I making stuff up?)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;[EDIT 2] What about a rechargable situation where my wall adaptor keeps a litium charged and the litium supplies clean power to the circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I now know that I can charge my whole circuit with anything from 5 to 12 volts. In fact it would be better to have more in the 7 to 12 range than strictly 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[UPDATE 3] Since this project is in my wall I was able to ground essentially to &quot;earth&quot; and that cleared up the noise. See this question as well: &lt;a href=&quot;https://electronics.stackexchange.com/questions/230024/grounding-dc-project-to-clean-rf-noise&quot;&gt;https://electronics.stackexchange.com/questions/230024/grounding-dc-project-to-clean-rf-noise&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20413" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2017-02-05T11:05:42.887" Title="How can I get ultra clean dc wall power for my arduino project?" Tags="|power|rfid|rf|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23415" PostTypeId="1" AcceptedAnswerId="23420" CreationDate="2016-04-21T12:12:47.513" Score="1" ViewCount="2426" Body="&lt;p&gt;Coming from a C# background where I do logs for every application, and given that I will be using the Mega for most projects and therefore have the memory available to do so, I want to incorporate error logging in my projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way to do so? Writing to an SD card? Writing via Wi-Fi or Ethernet to a networked storage or PC? Writing to a USB thumb drive?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current project I am working on uses the Adafruit Music Maker shield so has the SD card reader incorporated into it, so the easy choice there would be to use that but I like creating solutions that are portable to multiple projects so writing via Wi-Fi or Ethernet seems to be the preferred method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I am not fully up to speed with C++, and I see there are various ways to write to text files in C++, are there any preferred ways to do so depending on which storage route I take?&lt;/p&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-22T12:16:13.207" Title="Proper error logging using Arduino" Tags="|programming|arduino-mega|datalogging|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23416" PostTypeId="1" AcceptedAnswerId="23476" CreationDate="2016-04-21T12:17:05.357" Score="-2" ViewCount="96" Body="&lt;p&gt;I have no UARTs left on the ATmega and need to deliver 1 Byte of information from the pi using 1 analog input. I2C is no option either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I planned using the digital output to request an analog signal from the Pi, but it does not seem to have a DAC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to properly translate/read a PWM signal with the atmegas ADC?&#xA;Analyzing the PWM the 'usual' way would probably be too slow as I don't trust the pi to keep up with a high PWM frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PINS left: PA0(ADC0|PCINT0), PD7(OC2A|PCINT31)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should add that this is a rather large robotics project involving communication between 8 MCUs in it's current state and needs to be extended by a computer vision module(=pi), which is not compatible with the existing custom bus&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: This also is a real time system which has approximately ~1-2ms left in it's main loop(10ms period). The required data has to be present in time as it alters the robot's behaviour for this loop.&lt;/p&gt;&#xA;" OwnerUserId="11885" LastEditorUserId="11885" LastEditDate="2016-04-21T15:46:57.617" LastActivityDate="2016-04-23T15:30:29.260" Title="Pi3 + ATmega644P: How do I establish a data connection with 1 analog input and 1 digital output left on the AT?" Tags="|serial|communication|adc|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23418" PostTypeId="2" ParentId="23412" CreationDate="2016-04-21T12:22:43.590" Score="0" Body="&lt;p&gt;You are addressing a device control problem that auto, home and building automation has concerned itself with for years. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As such there are many solutions.  Most require a transmitter and one or more receiver(s). &lt;a href=&quot;https://en.wikipedia.org/wiki/C-Bus_%28protocol%29&quot; rel=&quot;nofollow&quot;&gt;C-BUS&lt;/a&gt; is one such solution.  Another is &lt;a href=&quot;https://en.wikipedia.org/wiki/CAN_bus&quot; rel=&quot;nofollow&quot;&gt;CAN-BUS&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="19667" LastEditDate="2016-04-22T00:11:06.903" LastActivityDate="2016-04-22T00:11:06.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23419" PostTypeId="2" ParentId="23415" CreationDate="2016-04-21T12:38:54.033" Score="0" Body="&lt;p&gt;Normally, because Arduino is meant to be easy to understand and use, C++ is only used (extensively) in the libraries.  Perhaps someone knows more about the Mega, but, in general, the Arduino platform does not contain many complex built in features.  For instance, before even thinking about how best to write to an SDCard, you need to do some research into how to load and use the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;Arduino SDCard library&lt;/a&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.allaboutcircuits.com/projects/reading-and-writing-files-from-an-sd-card-with-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; appears to be what you eventually want to do.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-21T12:38:54.033" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23420" PostTypeId="2" ParentId="23415" CreationDate="2016-04-21T12:40:09.460" Score="0" Body="&lt;p&gt;What you ask is difficult to answer in generic way, because not all the Arduino boards have the same HW options and even if you were to require a certain interface (ex: WiFi), that will introduce other side effects:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it will use certain pins/buses (SPI) that one might want to reserve for other purposes (yes you can have multiple peripherals on the SPI bus, but it will require additional code)&lt;/li&gt;&#xA;&lt;li&gt;it might significantly alter the execution timing in certain cases&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What most people use - and seem to be happy with - is the serial port:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it is not too difficult to setup&lt;/li&gt;&#xA;&lt;li&gt;the ide already has a serial port monitor&lt;/li&gt;&#xA;&lt;li&gt;it can produce information that is immediately human-parsable&lt;/li&gt;&#xA;&lt;li&gt;there is no need to retrieve it afterwards (an SD card has to be extracted, mounted, etc.)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would advise you to consider this at least as option, if not the only option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course each option has drawbacks: the serial port can also cause delays in the execution, might not be too good if you have lots of stuff to log, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serial port could be seen as a intermediate step toward wireless logging: modules like the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon&quot; rel=&quot;nofollow&quot;&gt;esp8266&lt;/a&gt; do rely on serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which means you could have wired logging while in the early phase and wireless logging later on, assuming you can afford to have something constantly listening to your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would consider the SD card only for cases where the device will run unattended for long periods of time and there might be some hard to reproduce event that you want to track.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also consider the onboard flash, if you have to log events that happen seldom.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2016-04-21T13:00:52.507" LastActivityDate="2016-04-21T13:00:52.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23421" PostTypeId="2" ParentId="23416" CreationDate="2016-04-21T12:47:04.120" Score="1" Body="&lt;p&gt;You can start researching about one wire protocol &lt;a href=&quot;https://en.wikipedia.org/wiki/1-Wire&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; to see if can implement it given your situation.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-21T12:47:04.120" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23422" PostTypeId="2" ParentId="23415" CreationDate="2016-04-21T13:28:09.830" Score="0" Body="&lt;p&gt;Embedded systems typically use UART for logging, and Arduino is no exception. Logging to UART is as easy as calling &lt;code&gt;Serial.begin()&lt;/code&gt; in the &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;Serial.println()&lt;/code&gt; in the &lt;code&gt;loop()&lt;/code&gt;, it works on all Arduinos, doesn't require any additional hardware and consumes much less resources than the SD card or networking library. Of course, you're limited in bandwidth (115200 kbit/s, sometimes more), so you won't be able to log in the fast-running cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't like the Serial Monitor feature of Arduino IDE, you can install &lt;a href=&quot;https://electronics.stackexchange.com/questions/52659/hyper-terminal-equivalent-in-windows-8&quot;&gt;one of the many terminal programs&lt;/a&gt; which will happily write the data from serial port to a log file. Some of these tools also have nice analysis features, including plotting of logged signals, formatting, data conversions etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're good with command line, creating a log file is as simple as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cat /dev/ttyUSB0 &amp;gt; log.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in Linux or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;type COM1 &amp;gt; log.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in Windows.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-04-21T15:10:21.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23423" PostTypeId="2" ParentId="23414" CreationDate="2016-04-21T14:38:26.857" Score="2" Body="&lt;p&gt;This is what I use, although admittedly not in your application. I run it from a 12V wall adaptor and adjust the output voltage to suit my requirements. The input should ideally be at least a couple of volts above the output(depends on current and temperature at 25degC and 20mA it's &gt; 1.6V and 1.5A at the same temp it's &gt; 2.7V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qfyen.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qfyen.jpg&quot; alt=&quot;Circuit Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative if you want to really go to town would be to repurpose an old computer ATX or similar PSU. There are plenty of guides out there and it's a straightforward job.&lt;/p&gt;&#xA;" OwnerUserId="521" LastEditorUserId="521" LastEditDate="2016-04-23T20:06:58.983" LastActivityDate="2016-04-23T20:06:58.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23424" PostTypeId="1" CreationDate="2016-04-21T14:39:48.447" Score="1" ViewCount="446" Body="&lt;p&gt;I'd like to create a process to programmatically turn-on/activate a separate USB device connected to my computer...Thinking another way to state the problem, I want the Arduino to complete the USB power circuit and then &quot;turn off&quot; on a schedule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In an essence, I'd like to have my Arduino facilitate the manual process of un-plugging a USB into my computer (lets say for 5 seconds) and then re-plugging it in (let's say for 5 mins)-- rinse and repeat on a schedule....I'd like to have this coded/programmed though (I'm ok in the Arduino IDE -- sample code would really help me out a ton though) -- I'm not going to setup an actual servo to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought getting a Arduino Shield would be the right place to start but I'm really lost.  I also thought getting a USB cable with a flip power switch might be another way to tackle the problem too-- but I haven't started to mess with it yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas or resources to point me in the right direction are greatly appreciated.  Thanks so much.&lt;/p&gt;&#xA;" OwnerUserId="20417" LastActivityDate="2017-01-15T13:43:01.167" Title="Arduino Uno (or Teensy 3.2) programmatically powering an external USB connection" Tags="|arduino-uno|power|shields|usb|teensy|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23426" PostTypeId="1" CreationDate="2016-04-21T14:48:56.830" Score="-1" ViewCount="627" Body="&lt;p&gt;I have an Arduino Mega and a 4-channel relay module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B0057OC5O8&quot; rel=&quot;nofollow&quot;&gt;relay&lt;/a&gt; module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the Arduino digital output is LOW, the relay is energized.  When the Arduino output is HIGH, the relay coil is de-energized. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="8761" LastEditorUserId="11763" LastEditDate="2016-04-21T22:22:22.520" LastActivityDate="2023-02-19T21:57:55.017" Title="Arduino relay module working in a wrong way" Tags="|relay|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23427" PostTypeId="2" ParentId="23426" CreationDate="2016-04-21T15:14:08.310" Score="2" Body="&lt;p&gt;That's how they're designed to work energized is LOW de-energized is HIGH you just need to take this into account when writing your Arduino code&lt;/p&gt;&#xA;" OwnerUserId="521" LastActivityDate="2016-04-21T15:14:08.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23428" PostTypeId="2" ParentId="23424" CreationDate="2016-04-21T15:15:06.750" Score="1" Body="&lt;p&gt;I'm not aware of any off the shelf &quot;shields&quot; which would accomplish this goal.  Since you do not seem to want your Arduino device to play either the USB host or client role, but rather to interrupt power to a difference device, a traditional USB shield is probably not going to help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather it would be useful to look at how the small minority of USB hubs that implement software control of downstream power on a port-by-port basis do it - USB allows for this, but doesn't require it, and most hub ICs have output pins to drive power switches, but don't include them.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switching the 5v USB VBUS needs to be a done with a &quot;high side switch&quot; - a P-channel MOSFET would be an obvious candidate, but it has been historically harder to find good ones.  Some time ago I ordered a few Richtek RT9701GB USB power switch ICs - apparently they are actually more effective N-channel FET's packaged with surrounding circuitry to make them usable on the high side - but that project was shelved so they remain untried.  If you are up for creating an extremely simple surface mount board to hold them (or can find one already made) they might be worth a try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the crude end you could probably use a relay board. There are hubs sold with mechanical power buttons that can be very useful when debugging USB-based embedded systems as you can power cycle them without constant unplugging, and this would be a sort of automated version of that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's an interesting question however, if removing the power to a USB peripheral while the data lines remain connected is proper.  This is problematic in the simplest design of an ESD protected input, as the built in protection diode means that the data signal ends up trying to power the unpowered IC, something it isn't usually rated to do, but actually USB circuitry may be more complicated.  An original USB &quot;A&quot; connector is made with the power and ground pins longer than the data ones, in the intent that they connect first.   Pragmatically, I've seen numerous USB devices survive data connection without power - but it could be interesting to read the specs (both USB and of the data sheets of particular devices implementing it) and see what they say about this.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another tactic could be to get one of the hubs with buttons, take it apart, and wire a relay across one of the buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, if you did get one of the rare USB hubs that actually includes controllable downstream power switches, an investigatory dive into the depths of your computer's USB stack should theoretically yield a way to control them from software there, potentially eliminating the need for the Arduino/Teensy.    &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-21T15:15:06.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23429" PostTypeId="1" CreationDate="2016-04-21T15:51:06.787" Score="-1" ViewCount="384" Body="&lt;p&gt;I am using my uno with gshield for my cnc. I would like to put laser on it. Laser have 3 wires. Red wire to power supply +, Black wire to power supply -, White wire to Arduino digital pin. I need to Connect the Arduino board ground to power supply -, but don't know how... Simple diagram (like child is using painter) would be great. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for help,&#xA;Urban&lt;/p&gt;&#xA;" OwnerUserId="20421" LastActivityDate="2016-04-21T16:39:21.937" Title="Arduino uno and ttl laser" Tags="|arduino-uno|power|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23431" PostTypeId="2" ParentId="23429" CreationDate="2016-04-21T16:39:21.937" Score="1" Body="&lt;p&gt;You take a wire, connect one end to the ground on the Arduino board and the other end to the ground on your power supply. Don't forget to strip the insulation. It doesn't get simpler than that.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-21T16:39:21.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23432" PostTypeId="1" CreationDate="2016-04-21T16:52:09.590" Score="1" ViewCount="94" Body="&lt;p&gt;I heard that using digital io pins in INPUT_PULLUP mode is much reliable and stable than in the case of using them in INPUT MODE.Then why is INPUT MODE still used...I mean &lt;strong&gt;Why isn't INPUT_PULLUP mode put as default&lt;/strong&gt; ??&lt;/p&gt;&#xA;" OwnerUserId="20270" LastActivityDate="2016-04-21T17:41:03.703" Title="Arduino digital I/O pins" Tags="|pins|input|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23433" PostTypeId="2" ParentId="23432" CreationDate="2016-04-21T17:00:39.403" Score="2" Body="&lt;p&gt;When the internal pullups are activated, a small amount of current is &lt;em&gt;sourced&lt;/em&gt; by the pin's circuitry whenever the input is low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that to drive the signal low, an external driver must not only sink current to discharge the capacitance of the internal and external circuitry, but it must continue doing so to dominate the attempt of the internal pullup to make the line high so that the voltage of the resistive voltage divider formed by the internal and external resistors is low enough to be an unambiguous low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that the external circuit must be stronger - not normally a problem for an active device, but potentially an issue for monitoring some very high impedance external circuit.  So for example, if you wanted an external pull-down resistor, it would have to be substantially lower in value than the internal pull-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also makes low power design (long life on batteries) difficult, as a system cannot take advantage of the best micropower suspend modes when any signal is being asserted &lt;em&gt;against&lt;/em&gt; the direction of a pulling resistor.  With just one or two such cases you might still get reasonable life when using flashlight batteries, but not with a coin cell, something a well designed ATmega circuit can presently do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After seeing Igor's comment, and re-reading your post, it seems maybe you are asking why the default is to have them disabled, rather than why you have the ability enable/disable them at all.  Most likely, the reason the Arduino core software has them disabled by default is because the ATmega resets that way.  As to why the ATmega resets that way, you might have to ask the design engineers, but generally it has been the norm to have an MCU reset to a state where it has the least influence on the external circuitry.  However, that is not necessarily the best - floating (undriven) inputs can potentially cause a typical CMOS input structure to consume more power than ones weakly driven to a known value.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-04-21T17:41:03.703" LastActivityDate="2016-04-21T17:41:03.703" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23434" PostTypeId="2" ParentId="23426" CreationDate="2016-04-21T17:58:53.743" Score="1" Body="&lt;p&gt;If you read the documentation or watch/read any tutorials on the mechanical relay you are using you will learn that LOW is active and HIGH is inactive for these devices. There is no way to change that behavior, that is how they are built. (Well, you can, but it's not worth the effort)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This design is intentional to prevent relay activation on power-up or system reset. And be sure to put this code in your setup routine to ensure proper system initialization.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(Relay, HIGH);&#xA;pinMode(Relay, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where Relay is the pin variable you defined for your relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just code your routine using LOW to activate the relay when necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try this tutorial &lt;a href=&quot;http://arduinobasics.blogspot.com/2014/09/relay-module.html&quot; rel=&quot;nofollow&quot;&gt;4 channel relay tutorial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-04-21T20:27:47.880" LastActivityDate="2016-04-21T20:27:47.880" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23435" PostTypeId="1" CreationDate="2016-04-21T17:59:23.650" Score="2" ViewCount="102" Body="&lt;p&gt;It seems that the last several times I've tried to open Arduino IDE I've encountered an error that says Launch4j, &quot;an error occurred while starting the application&quot;.  It takes some time before that happens.  I think I've seen some stuff online about this, however I've seen some mixed answers and results for how to solve that problem.  I'm using it on a Windows 7, 64 bit system.  I've tried opening it up while my Arduino was connected and it didn't work.&lt;/p&gt;&#xA;" OwnerUserId="19055" LastActivityDate="2016-04-21T17:59:23.650" Title="How to deal with launch4j error" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23436" PostTypeId="2" ParentId="23354" CreationDate="2016-04-21T19:27:05.200" Score="0" Body="&lt;p&gt;While you can't make an apache web server with an Arduino Uno, you can if you access the linux module of the Arduino Yun board. I in fact did this and with some testing realized that it can't handle more than a few packet requests per second.&#xA;Although a raspberry pi is much cheaper and more capable than a re-programmed Yun if you want a &quot;Mainstream&quot; server&#xA;(Namely one Arduino Yun is $75.00 while a Raspberry Pi model 3 B is $35.00 at the time of this writing.)&lt;/p&gt;&#xA;" OwnerUserId="20425" LastActivityDate="2016-04-21T19:27:05.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23437" PostTypeId="1" CreationDate="2016-04-21T21:02:14.053" Score="2" ViewCount="82" Body="&lt;p&gt;I have a custom board designed to be essentially identical to the Arduino Micro (Atmega32u4). I can burn the bootloader (Caterina) and it burns just fine, including the fade-then-slow LED signal that indicates a successful bootloader burn. However, it does not turn up under USB. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="15442" LastActivityDate="2016-04-21T21:02:14.053" Title="Can burn bootloader but not sketches... thoroughly mystified!" Tags="|bootloader|arduino-micro|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23438" PostTypeId="1" CreationDate="2016-04-21T21:15:56.680" Score="2" ViewCount="69" Body="&lt;p&gt;&lt;strong&gt;Sanguino&lt;/strong&gt; and &lt;strong&gt;Microduino&lt;/strong&gt; core+ both uses &lt;strong&gt;&lt;code&gt;ATMEGA644PA&lt;/code&gt;&lt;/strong&gt;. I need to write a piece of code in my library where I need to check what board has been selected.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;#   define TIMER_PWM_PIN  11             // Arduino Mega&#xA;#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)// Sanguino or microduino&#xA;#    define TIMER_PWM_PIN  13        //Sanguino PD5&#xA;#elif defined(__AVR_ATtiny84__)&#xA;# define TIMER_PWM_PIN  6&#xA;#else&#xA;#   define TIMER_PWM_PIN  9              // Arduino Duemilanove, Diecimila, LilyPad, etc&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I used the above code &lt;code&gt;#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)// Sanguino or Microduino&lt;/code&gt; will be true for both Microduino and Sanguino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way I can know which one is it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the board.txt section for Microduino core +&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;##Microduino Core+ (644pa)&#xA;##############################################################&#xA;644p.name= Microduino/mCookie-Core+ (644pa)&#xA;&#xA;644p.upload.tool=avrdude&#xA;644p.upload.protocol=arduino&#xA;&#xA;644p.bootloader.tool=avrdude&#xA;644p.bootloader.unlock_bits=0x3F&#xA;644p.bootloader.lock_bits=0x0F&#xA;&#xA;644p.build.board=AVR_PLUS&#xA;644p.build.core=arduino&#xA;644p.build.variant=plus&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3277" LastEditorUserId="37523" LastEditDate="2019-07-03T22:28:27.077" LastActivityDate="2019-07-03T22:28:27.077" Title="how to differentiate in code between Sangunio and Microduino core+" Tags="|hardware|" AnswerCount="0" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="23439" PostTypeId="1" CreationDate="2016-04-21T22:03:50.120" Score="8" ViewCount="4861" Body="&lt;p&gt;(Let's just skip the suggestions that it's the wrong idea and interrupts for a while...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way to replace the &lt;code&gt;digitalWrite()&lt;/code&gt; method (for example) so I can add something more to happen in there? But the following rules must be obeyed:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A call to &lt;code&gt;digitalWrite(pin, value)&lt;/code&gt; must invoke the new method.&lt;/li&gt;&#xA;&lt;li&gt;A call to &lt;code&gt;digitalWrite(pin, value)&lt;/code&gt; from &lt;strong&gt;a different library&lt;/strong&gt; included in my code (SD.h for example) must invoke the new method.&lt;/li&gt;&#xA;&lt;li&gt;None of the Arduino files can be modified (I don't want to do it on every Arduino version upgrade).&lt;/li&gt;&#xA;&lt;li&gt;Everything must be done in a header file that I can include to use the new function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have tried this and it works, but only in my code, not in external libraries that I include after this header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;class PinsHook {&#xA;  public:&#xA;    static void digitalWriteHook(uint8_t pin, uint8_t value) {&#xA;      digitalWrite(pin, value);&#xA;      if (pin == 8) {&#xA;        Serial.print(&quot;Pin &quot;);&#xA;        Serial.print(pin);&#xA;        Serial.print(&quot; changed to &quot;);&#xA;        Serial.println(value);&#xA;      }&#xA;    }&#xA;};&#xA;&#xA;#define digitalWrite(pin, value) PinsHook::digitalWriteHook(pin, value)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18748" LastEditorUserId="4628" LastEditDate="2018-01-11T03:03:02.793" LastActivityDate="2018-01-11T03:03:02.793" Title="Is there a way to replace an Arduino core function without modifying the Arduino code?" Tags="|c++|library|core-libraries|" AnswerCount="7" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23440" PostTypeId="2" ParentId="23439" CreationDate="2016-04-21T22:08:18.860" Score="2" Body="&lt;p&gt;Did you try with a C macro?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define digitalWrite(a, b) \&#xA;(pre(), digitalWrite(a, b), post())&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this evaluates to the retval of &lt;code&gt;post()&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can omit either the &lt;code&gt;pre()&lt;/code&gt; or the &lt;code&gt;post()&lt;/code&gt; functions/macros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This needs to be placed somewhere that is included whenever the header for digitalWrite is included, so that it can override it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other alternative is to become creative with the library binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, just be reasonable and modify the source code.&#xA;It's specifically available so that people can modify it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wrt not repeating the modification every time there is a new Arduino release, that should be avoidable.&#xA;If you build the environment from the git sources, you can maintain your patch by merging/rebasing onto the master branch.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="7856" LastEditDate="2016-04-21T22:26:12.537" LastActivityDate="2016-04-21T22:26:12.537" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23441" PostTypeId="2" ParentId="23439" CreationDate="2016-04-21T22:58:18.123" Score="4" Body="&lt;p&gt;Not sure about the Arduino IDE (I don't have it installed right now) but using &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; it's as simple as defining a new &lt;code&gt;digitalWrite&lt;/code&gt; function in your code.  When the whole shebang gets linked together the function in your code overrides the function in the libraries.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    digitalWrite(13, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(13, LOW);&#xA;    delay(800);&#xA;}&#xA;&#xA;void digitalWrite(int pin, int level) {&#xA;    // Not gonna do anything!&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Comment out the digitalWrite function and the LED blinks.  Uncomment it and it doesn't blink any more.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-21T22:58:18.123" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23442" PostTypeId="1" AcceptedAnswerId="23446" CreationDate="2016-04-21T23:42:29.460" Score="0" ViewCount="205" Body="&lt;p&gt;I have code that receives values from a serial connection, then uses those values to generate sine wave points. These sine wave points are used to position multiple servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently trying to decrease the resolution of the sine wave points so there is more time for the servo to reach its given position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way I can think of to accomplish this is by increasing the time between writing servo positions. As far as I can tell, I have implemented this correctly, however it results in a sine wave of a lower frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The method I am using to alter the resolution is by changing the variable &lt;code&gt;sine_time&lt;/code&gt;, which is used in the conditional statement &lt;code&gt;if(currentMillis - previousMillis &amp;gt;= sine_time)&lt;/code&gt;, near the bottom of the program.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;This is a program that recieves sine wave parameters from a serial connection in a single string.&#xA;The string is parsed and converted into numbers, which are plugged into 8 sine equations to generate&#xA;positions for each joint of the robot.&#xA;*/&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo SB, SF, HB, HF, EB, EF, KB, KF;&#xA;int iAmp, iF_offset, iB_offset, iFk_offset, iBk_offset, pos[] = {0,1,2,3,4,5,6,7};&#xA;unsigned int t = 0;&#xA;unsigned long previousMillis = 0;&#xA;float fKnee_amp, fAfreq, fPhase, fGait;&#xA;&#xA;void setup(){&#xA;  //Start serial stream at 115200 baud&#xA;  Serial.begin(115200);&#xA;&#xA;  //Connect servos to Arduino&#xA;  HB.attach(2);&#xA;  KF.attach(3);&#xA;  SB.attach(4); &#xA;  EB.attach(5);&#xA;  HF.attach(6); &#xA;  KB.attach(7);&#xA;  SF.attach(8); &#xA;  EF.attach(9);&#xA;&#xA;  delay(3000);&#xA;}&#xA;&#xA;void loop(){&#xA;  char c, buffer[10];&#xA;  String readString, amp, knee_amp, afreq, gait, phase, f_offset, b_offset, fk_offset, bk_offset;&#xA;  //change the resolution of the sine wave (lower value is higher resolution)&#xA;  //digital servos refresh at a rate of 50Hz which is 0.02s&#xA;  float sine_time = 100;&#xA;&#xA;  while (Serial.available() &amp;amp;&amp;amp; readString.length() &amp;lt; 37){&#xA;    //delay to allow buffer to fill&#xA;    delayMicroseconds(10);&#xA;    if (Serial.available() &amp;gt; 0){&#xA;      //get one byte from serial buffer&#xA;      char c = Serial.read();&#xA;      //creates the string &quot;readString&quot;&#xA;      readString += c;&#xA;    }&#xA;  }&#xA;&#xA;  if (readString.length() &amp;gt; 36){&#xA;    //see what was received&#xA;    Serial.println(&quot;The string is: &quot; + readString);&#xA;    Serial.println(readString.length()); &#xA;&#xA;    //parse serial string into separate parameters&#xA;    amp = readString.substring(0, 3);&#xA;    knee_amp = readString.substring(3, 7); &#xA;    afreq = readString.substring(7, 11); &#xA;    phase = readString.substring(11, 15); &#xA;    gait = readString.substring(15, 20); &#xA;    f_offset = readString.substring(20, 24); &#xA;    b_offset = readString.substring(24, 28); &#xA;    fk_offset = readString.substring(28, 32); &#xA;    bk_offset = readString.substring(32, 36);&#xA;    /*&#xA;    //Print to serial monitor to see parsed results&#xA;    Serial.println(&quot;Hip Amp: &quot; + amp); &#xA;    Serial.println(&quot;Knee Amp: &quot; + knee_amp); &#xA;    Serial.println(&quot;Afreq: &quot; + afreq); &#xA;    Serial.println(&quot;Gait: &quot; + gait);&#xA;    Serial.println(&quot;Phase: &quot; + phase);&#xA;    Serial.println(&quot;F Offset: &quot; + f_offset);&#xA;    Serial.println(&quot;B Offset: &quot; + b_offset);  &#xA;    Serial.println(&quot;Fk Offset: &quot; + fk_offset);&#xA;    Serial.println(&quot;Bk Offset: &quot; + bk_offset + &quot;\n&quot;);&#xA;    */&#xA;    //convert string values to numbers&#xA;    iAmp = amp.toInt();&#xA;&#xA;    knee_amp.toCharArray(buffer, 10);&#xA;    fKnee_amp = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    afreq.toCharArray(buffer, 10);&#xA;    fAfreq = atof(buffer)/100;&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    phase.toCharArray(buffer, 10);&#xA;    fPhase = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    gait.toCharArray(buffer, 10);&#xA;    fGait = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    iF_offset = f_offset.toInt();&#xA;    iB_offset = b_offset.toInt();&#xA;    iFk_offset = fk_offset.toInt();&#xA;    iBk_offset = bk_offset.toInt();&#xA;&#xA;    //clear strings&#xA;    readString=&quot;&quot;;&#xA;    amp=&quot;&quot;;&#xA;    knee_amp=&quot;&quot;;&#xA;    afreq=&quot;&quot;;&#xA;    gait=&quot;&quot;;&#xA;    phase=&quot;&quot;;&#xA;    f_offset=&quot;&quot;;&#xA;    b_offset=&quot;&quot;;&#xA;    fk_offset=&quot;&quot;;&#xA;    bk_offset=&quot;&quot;;&#xA;  }&#xA;&#xA;  //if the joints should be oscillating&#xA;  if (fAfreq &amp;gt; 0){&#xA;    //determine joint positions&#xA;    pos[0] = iAmp * sin(fAfreq*t) + 1500 + iF_offset;&#xA;    pos[1] = iAmp * sin(fAfreq*t) + 1522 - iF_offset;&#xA;    pos[2] = iAmp * sin(fAfreq*t + fGait) + 1500 + iB_offset;&#xA;    pos[3] = iAmp * sin(fAfreq*t + fGait) + 1446 - iB_offset;&#xA;&#xA;    pos[4] = iAmp*fKnee_amp*2 * sin(fAfreq*t + fPhase) + 1500 + iFk_offset;&#xA;    pos[5] = iAmp*fKnee_amp * sin(fAfreq*t + fPhase) + 1500 - iFk_offset;&#xA;    pos[6] = iAmp*fKnee_amp*2 * sin(fAfreq*t + fGait + fPhase) + 1500 + iBk_offset;&#xA;    pos[7] = iAmp*fKnee_amp*2 * sin(fAfreq*t + fGait + fPhase) + 1538 - iBk_offset;&#xA;    /*&#xA;    //print parameter variables&#xA;    Serial.println(iAmp); &#xA;    Serial.println(fKnee_amp); &#xA;    Serial.println(fAfreq); &#xA;    Serial.println(fGait);&#xA;    Serial.println(fPhase);&#xA;    Serial.println(iF_offset);&#xA;    Serial.println(iB_offset);  &#xA;    Serial.println(iFk_offset);&#xA;    Serial.println(iBk_offset);&#xA;&#xA;    //print servo positions&#xA;    Serial.println(pos[0]);&#xA;    Serial.println(pos[1]);&#xA;    Serial.println(pos[2]);&#xA;    Serial.println(pos[3]);&#xA;    Serial.println(pos[4]);&#xA;    Serial.println(pos[5]);&#xA;    Serial.println(pos[6]);&#xA;    Serial.println(pos[7]);&#xA;    */&#xA;    //get time in milliseconds&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    //if the time threshold has been passed&#xA;    if(currentMillis - previousMillis &amp;gt;= sine_time){&#xA;&#xA;      Serial.println(currentMillis - previousMillis);&#xA;&#xA;      previousMillis = currentMillis;&#xA;&#xA;      //write servo positions&#xA;      HB.writeMicroseconds(pos[2]);&#xA;      KF.writeMicroseconds(pos[6]);&#xA;      SB.writeMicroseconds(pos[0]); &#xA;      EB.writeMicroseconds(pos[4]);&#xA;      HF.writeMicroseconds(pos[3]); &#xA;      KB.writeMicroseconds(pos[7]);&#xA;      SF.writeMicroseconds(pos[1]); &#xA;      EF.writeMicroseconds(pos[5]);&#xA;&#xA;      //increment time parameter&#xA;      t+=1;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20430" LastActivityDate="2016-04-22T04:04:58.630" Title="How to Change the Output Resolution of Sine Wave Controller" Tags="|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23443" PostTypeId="1" CreationDate="2016-04-21T23:47:21.200" Score="4" ViewCount="645" Body="&lt;p&gt;We're using two RDM6300 RFID readers for this, and the code works when plugged into an UNO, but not when connected to the Yun. We have one of the rfids plugged into the rx pin (0 on the digital side) and the other plugged into pin 2 (same exact way we had it working on the UNO). Anyway, is there something majorly different between working with just sketches on Yun vs UNO? This code doesn't even involve using the Linux side yet as we couldn't get this major part figured out. Any help would be appreciated&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;    //2nd RFID using SoftwareSerial&#xA;    SoftwareSerial RFID(2, 3); // RX and TX&#xA;&#xA;&#xA;    // define constants for pins&#xA;    int UNLOCK = 8;&#xA;&#xA;    // variables to keep state&#xA;    int readVal = 0; // individual character read from serial&#xA;    unsigned int readData[10]; // data read from serial&#xA;    int counter = -1; // counter to keep position in the buffer&#xA;    char tagId[11]; // final tag ID converted to a string&#xA;&#xA;    char* authorizedTags[4]; // array to hold the list of authorized tags&#xA;&#xA;    // fills the list of authorzied tags&#xA;    void initAuthorizedTags() {&#xA;      //tags&#xA;      authorizedTags[0] = &quot;02006750B7&quot;; &#xA;      authorizedTags[1] = &quot;02006750B1&quot;;&#xA;      authorizedTags[2] = &quot;02006750B2&quot;;&#xA;      authorizedTags[3] = &quot;02006750B3&quot;;&#xA;      authorizedTags[4] = &quot;02006750B4&quot;;&#xA;    }&#xA;&#xA;    void setup() {                &#xA;      Serial.begin(9600);&#xA;&#xA;      //start serial to RFID reader2&#xA;      RFID.begin(9600); &#xA;&#xA;&#xA;      pinMode(UNLOCK, OUTPUT);&#xA;    //  pinMode(SUCCESS, OUTPUT);&#xA;    //  pinMode(ERROR, OUTPUT);&#xA;      initAuthorizedTags();&#xA;    }&#xA;&#xA;    // check if the tag ID we just read is any of the authorized tags&#xA;    int checkTag() {&#xA;      int i;&#xA;&#xA;      for (i = 0; i &amp;lt; 4; ++i) {&#xA;        if (strcmp(authorizedTags[i], tagId) == 0) {&#xA;          return 1;&#xA;        }&#xA;      }&#xA;      return 0;&#xA;    }&#xA;&#xA;    // convert the int values read from serial to ASCII chars&#xA;    void parseTag() {&#xA;      int i;&#xA;      for (i = 0; i &amp;lt; 10; ++i) {&#xA;        tagId[i] = readData[i];&#xA;      }&#xA;      tagId[10] = 0;&#xA;    }&#xA;&#xA;    // once a whole tag is read, process it&#xA;    void processTag() {&#xA;      // convert id to a string&#xA;      parseTag();&#xA;&#xA;      // print it&#xA;      printTag();&#xA;&#xA;      // check if the tag is authorized&#xA;      if (checkTag() == 1) {&#xA;        tagSuccess(); // unlock solenoid&#xA;      } else {&#xA;        tagFailed(); &#xA;      }&#xA;    }&#xA;&#xA;    void printTag() {&#xA;      Serial.print(&quot;Tag value: &quot;);&#xA;      Serial.println(tagId);&#xA;    }&#xA;&#xA;    // perform an action when an authorized tag was read&#xA;    void tagSuccess() {&#xA;      Serial.println(&quot;Tag authorized.&quot;);&#xA;&#xA;&#xA;      //activate solenoid, &#xA;      digitalWrite(8, HIGH);&#xA;      delay(3000);&#xA;      digitalWrite(8, LOW);&#xA;    }&#xA;&#xA;    // inform the user that the tag is not authorized&#xA;    void tagFailed() {&#xA;      Serial.println(&quot;Unauthorized access!&quot;);&#xA;&#xA;    }&#xA;&#xA;    // this function clears the rest of data on the serial, to prevent multiple scans&#xA;    void clearSerial() {&#xA;      while (Serial.read() &amp;gt;= 0) {&#xA;        ; // do nothing&#xA;      }&#xA;    }&#xA;&#xA;    void loop() {&#xA;&#xA;&#xA;    //RFID 1&#xA;      if (Serial.available() &amp;gt; 0) {&#xA;&#xA;&#xA;        // read the incoming byte:&#xA;        readVal = Serial.read();&#xA;&#xA;        // a &quot;2&quot; signals the beginning of a tag&#xA;        if (readVal == 2) {&#xA;          counter = 0; // start reading&#xA;        } &#xA;        // a &quot;3&quot; signals the end of a tag&#xA;        else if (readVal == 3) {&#xA;          // process the tag we just read&#xA;          processTag();&#xA;&#xA;          // clear serial to prevent multiple reads&#xA;          clearSerial();&#xA;&#xA;          // reset reading state&#xA;          counter = -1;&#xA;        }&#xA;        // if we are in the middle of reading a tag&#xA;        else if (counter &amp;gt;= 0) {&#xA;          // save valuee&#xA;          readData[counter] = readVal;&#xA;&#xA;          // increment counter&#xA;          ++counter;&#xA;        } &#xA;      }&#xA;&#xA;    if (RFID.available() &amp;gt; 0) &#xA;    {&#xA;        // read the incoming byte:&#xA;        readVal = RFID.read();&#xA;&#xA;        // a &quot;2&quot; signals the beginning of a tag&#xA;        if (readVal == 2) {&#xA;          counter = 0; // start reading&#xA;        } &#xA;        // a &quot;3&quot; signals the end of a tag&#xA;        else if (readVal == 3) {&#xA;          // process the tag we just read&#xA;          processTag();&#xA;&#xA;          // clear serial to prevent multiple reads&#xA;          clearSerial();&#xA;&#xA;          // reset reading state&#xA;          counter = -1;&#xA;        }&#xA;        // if we are in the middle of reading a tag&#xA;        else if (counter &amp;gt;= 0) {&#xA;          // save valuee&#xA;          readData[counter] = readVal;&#xA;&#xA;          // increment counter&#xA;          ++counter;&#xA;        } &#xA;    }&#xA;&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20431" LastActivityDate="2018-10-28T12:47:47.003" Title="RFID Code (and setup) works on an UNO but not on the Yun" Tags="|arduino-uno|arduino-yun|rfid|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23444" PostTypeId="1" AcceptedAnswerId="23604" CreationDate="2016-04-22T02:07:05.130" Score="1" ViewCount="351" Body="&lt;p&gt;I have an Arduino Uno with an RS-232 shield, and a servo drive that communicates via CAN or RS-232. I'm trying to communicate with this drive using an RS-232 cable, but I'm getting no response. I'm using the SoftwareSerial library on the Arduino to use digital pins 3 and 2 as rx and tx. Only pins 2 (RxD), 3 (TxD), and 5 (GND) of RS-232 are used to communicate with the drive. 19,200 is the default baud rate for the drive. The drive is powered with a dedicated power supply. The drive is supposed to echo every character received back to the sender.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've had success using a simple Java program to communicate with the drive using the same kind of cable (although with a USB-to-serial converter). The drive echos all characters back, and the motor responds to the commands sent to the drive. The cable used has a female DB9 connector on one end (to communicate with the desktop) and a custom 3 pin connector on the other (to communicate with the drive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also had success with the same Java program communicating with the Arduino (also with the converter). This cable has a female DB9 connector on one end (to communicate with the desktop) and a male DB9 connector on the other (to communicate with the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I've had no success exchanging data between the Arduino and the drive. There is no response back from the drive nor does the motor respond to any commands. The cable used for this has a male DB9 connector on one end (to communicate with the Arduino) and a custom 3 pin connector on the other (to communicate with the drive).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each cable has been tested with a voltmeter to confirm that pins on one end are connected to the correct pins on the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm at a loss here. Is there something I'm missing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your consideration, here is the Arduino code. It is the same whether it is connected to the desktop or the drive.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;const int rx = 3;               // software serial receive pin&#xA;const int tx = 2;               // software serial transmit pin&#xA;const int baudRate = 19200;     // 19,200 bits per second for read and write serial functions&#xA;&#xA;SoftwareSerial serial(rx, tx);&#xA;&#xA;&#xA;/*&#xA; * Initial, one-time setup&#xA; */&#xA;void setup()&#xA;{&#xA;    Serial.begin(baudRate);     // open hardware serial communications&#xA;    serial.begin(baudRate);     // open software serial communications&#xA;&#xA;    serial.println(&quot;MO=1;&quot;);      // start motor&#xA;    serial.println(&quot;JV=30000;&quot;);  // set velocity to 30,000 counts/second&#xA;    serial.println(&quot;BG;&quot;);        // begin movement&#xA;}&#xA;&#xA;/*&#xA; * Executes every tick&#xA; */&#xA;void loop()&#xA;{&#xA;    if (serial.available())&#xA;    {&#xA;        Serial.write(serial.read());&#xA;    }&#xA;&#xA;    if (Serial.available())&#xA;    {&#xA;        serial.write(Serial.read());&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, here is the Java code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import gnu.io.CommPort;&#xA;import gnu.io.CommPortIdentifier;&#xA;import gnu.io.SerialPort;&#xA;&#xA;import java.io.FileDescriptor;&#xA;import java.io.IOException;&#xA;import java.io.InputStream;&#xA;import java.io.OutputStream;&#xA;&#xA;&#xA;public class TwoWaySerialComm&#xA;{&#xA;    public TwoWaySerialComm()&#xA;    {&#xA;        super();&#xA;    }&#xA;&#xA;    void connect(String portName) throws Exception&#xA;    {&#xA;        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);&#xA;        if (portIdentifier.isCurrentlyOwned())&#xA;        {&#xA;            System.out.println(&quot;Error: Port is currently in use&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;            CommPort commPort = portIdentifier.open(this.getClass().getName(), 2000);&#xA;&#xA;            if (commPort instanceof SerialPort)&#xA;            {&#xA;                SerialPort serialPort = (SerialPort)commPort;&#xA;                serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);&#xA;&#xA;                InputStream in = serialPort.getInputStream();&#xA;                OutputStream out = serialPort.getOutputStream();&#xA;&#xA;                (new Thread(new SerialReader(in))).start();&#xA;                (new Thread(new SerialWriter(out))).start();&#xA;&#xA;            }&#xA;            else&#xA;            {&#xA;                System.out.println(&quot;Error: Only serial ports are handled by this example.&quot;);&#xA;            }&#xA;        }     &#xA;    }&#xA;&#xA;    /** */&#xA;    public static class SerialReader implements Runnable &#xA;    {&#xA;        InputStream in;&#xA;&#xA;        public SerialReader(InputStream in)&#xA;        {&#xA;            this.in = in;&#xA;        }&#xA;&#xA;        public void run()&#xA;        {&#xA;            byte[] buffer = new byte[1024];&#xA;            int len = -1;&#xA;            try&#xA;            {&#xA;                while ((len = this.in.read(buffer)) &amp;gt; -1)&#xA;                {&#xA;                    System.out.print(new String(buffer, 0, len));&#xA;                }&#xA;            }&#xA;            catch (IOException e)&#xA;            {&#xA;                e.printStackTrace();&#xA;            }            &#xA;        }&#xA;    }&#xA;&#xA;    /** */&#xA;    public static class SerialWriter implements Runnable&#xA;    {&#xA;        OutputStream out;&#xA;&#xA;        public SerialWriter(OutputStream out)&#xA;        {&#xA;            this.out = out;&#xA;        }&#xA;&#xA;        public void run()&#xA;        {&#xA;            try&#xA;            {&#xA;                int c = 0;&#xA;                while ((c = System.in.read()) &amp;gt; -1)&#xA;                {&#xA;                    //System.out.print(c);&#xA;                    this.out.write(c);&#xA;                }                &#xA;            }&#xA;            catch (IOException e)&#xA;            {&#xA;                e.printStackTrace();&#xA;            }            &#xA;        }&#xA;    }&#xA;&#xA;    public static void main(String[] args)&#xA;    {&#xA;        try&#xA;        {&#xA;            (new TwoWaySerialComm()).connect(&quot;COM4&quot;);  // COM4 is port of USB-to-serial converter&#xA;        }&#xA;        catch (Exception e)&#xA;        {&#xA;            // TODO Auto-generated catch block&#xA;            e.printStackTrace();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20433" LastEditorUserId="20433" LastEditDate="2016-04-22T02:18:54.877" LastActivityDate="2016-04-27T01:53:54.940" Title="No response from device when trying to communicate with it via RS-232" Tags="|arduino-uno|motor|softwareserial|rs232|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23446" PostTypeId="2" ParentId="23442" CreationDate="2016-04-22T04:04:58.630" Score="0" Body="&lt;p&gt;Your sine waves depend on “time” via appearances of &lt;code&gt;fAfreq*t&lt;/code&gt; in lots of places.  However, &lt;code&gt;t&lt;/code&gt; actually is a pass counter, rather than reflecting true elapsed time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of incrementing &lt;code&gt;t&lt;/code&gt; by 1, increment it by a value that's proportional to elapsed time.  Or, more directly, set &lt;code&gt;t&lt;/code&gt; equal to a multiple of elapsed time.  For example, whenever you start over, record current time via &lt;code&gt;basetime = millis()&lt;/code&gt;.  Then, just after your &lt;code&gt;//determine joint positions&lt;/code&gt; comment, say &lt;code&gt;t = speedratio * (millis()-basetime);&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-04-22T04:04:58.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23447" PostTypeId="2" ParentId="23393" CreationDate="2016-04-22T07:40:16.250" Score="0" Body="&lt;p&gt;A quick and dirty solution is to just the right the code that does the sampling and loop it, say 10,000 times, with a short delay.  Measure the time it takes to do the 10,000 samples by recording time before and after all the samples.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The amount of time taken will be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10,000 x (delay period -&amp;gt; known) + 10,000 x (actual amount of time to do the sampling)  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From this data you can determine the required delay to get your 1 kHz sampling goal. &lt;/p&gt;&#xA;" OwnerUserId="6496" LastEditorUserId="6936" LastEditDate="2016-04-22T08:51:33.443" LastActivityDate="2016-04-22T08:51:33.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23449" PostTypeId="2" ParentId="23412" CreationDate="2016-04-22T09:40:06.603" Score="0" Body="&lt;p&gt;Use wireless nodes which are self-powered. It is easier (no need for lot of cables) and also solves this issue completely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://en.wikipedia.org/wiki/ZigBee&quot; rel=&quot;nofollow&quot;&gt;ZigBee&lt;/a&gt;, which is mesh network. Every node re-transmit signal for nodes which are far. Because you have one on every floor, you would not have issues with reception.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;If you want to use wires, I would still keep self-powered nodes and you can communicate with them using i2c or similar. You would need only 3 wires (SDA, SCL and GND) and they could be very thin, because they transfer only signals (&amp;lt;1mA range)). These 3 wires would connect all nodes. All nodes should have distinct address. I think this could be very cheap because you can create nodes with arduino micro which can be bought for ~1.5$ each.&lt;/p&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-04-22T13:28:36.380" LastActivityDate="2016-04-22T13:28:36.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23452" PostTypeId="2" ParentId="23415" CreationDate="2016-04-22T12:16:13.207" Score="0" Body="&lt;p&gt;In my Arduino project, I wrote communication sub protocol between a Raspberry Pi (or a PC). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I simply added some commands to duo vars or arrays into memory.&lt;/p&gt;&#xA;" OwnerUserId="297" LastActivityDate="2016-04-22T12:16:13.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23453" PostTypeId="1" CreationDate="2016-04-22T12:27:54.060" Score="-1" ViewCount="1156" Body="&lt;p&gt;I am getting no response back from an ESP8266 WIFI with Arduino Mega using library ITEADLIB_Arduino_WeeESP8266.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//serial monitor response&#xA;&#xA;setup begin&#xA;&#xA;FW Version:&#xA;&#xA;to station + softap ok&#xA;&#xA;Join AP success&#xA;&#xA;IP:&#xA;&#xA;single ok&#xA;&#xA;setup end&#xA;&#xA;create tcp ok&#xA;&#xA;release tcp ok&#xA;&#xA;create tcp ok&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Mega Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ESP8266.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define SSID        &quot;atmel&quot;&#xA;#define PASSWORD    &quot;bets12345&quot;&#xA;#define HOST_NAME   &quot;www.google.com&quot;&#xA;#define HOST_PORT   (80)&#xA;&#xA;SoftwareSerial mySerial(10, 11); /* RX:D3, TX:D2 */ ESP8266 wifi(mySerial);&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  Serial.print(&quot;setup begin\r\n&quot;);&#xA;  Serial.print(&quot;FW Version:&quot;);&#xA;  Serial.println(wifi.getVersion().c_str());&#xA;  if (wifi.setOprToStationSoftAP()) {&#xA;    Serial.print(&quot;to station + softap ok\r\n&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;to station + softap err\r\n&quot;);&#xA;  }&#xA;  if (wifi.joinAP(SSID, PASSWORD)) {&#xA;    Serial.print(&quot;Join AP success\r\n&quot;);&#xA;    Serial.print(&quot;IP:&quot;);&#xA;    Serial.println( wifi.getLocalIP().c_str());&#xA;  } else {&#xA;    Serial.print(&quot;Join AP failure\r\n&quot;);&#xA;  }&#xA;  if (wifi.disableMUX()) {&#xA;    Serial.print(&quot;single ok\r\n&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;single err\r\n&quot;);&#xA;  }&#xA;  Serial.print(&quot;setup end\r\n&quot;);&#xA;}&#xA;&#xA;void loop(void) {&#xA;  uint8_t buffer[128] = {0};&#xA;  if (wifi.createTCP(HOST_NAME, HOST_PORT)) {&#xA;    Serial.print(&quot;create tcp ok\r\n&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;create tcp err\r\n&quot;);&#xA;  }&#xA;  char *hello = &quot;Hello, this is client!&quot;;&#xA;  wifi.send((const uint8_t*)hello, strlen(hello));&#xA;  uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);&#xA;  if (len &amp;gt; 0) {&#xA;    Serial.print(&quot;Received:[&quot;);&#xA;    for(uint32_t i = 0; i &amp;lt; len; i++) {&#xA;      Serial.print((char)buffer[i]);&#xA;    }&#xA;    Serial.print(&quot;]\r\n&quot;);&#xA;  }&#xA;  if (wifi.releaseTCP()) {&#xA;    Serial.print(&quot;release tcp ok\r\n&quot;);&#xA;  } else {&#xA;    Serial.print(&quot;release tcp err\r\n&quot;);&#xA;  }&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8484" LastEditorUserId="4628" LastEditDate="2016-12-20T08:10:55.913" LastActivityDate="2016-12-20T08:10:55.913" Title="No Response from ESP8266 WIFI" Tags="|arduino-mega|wifi|esp8266|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23454" PostTypeId="1" CreationDate="2016-04-22T12:42:23.317" Score="2" ViewCount="351" Body="&lt;p&gt;I have four APA102 LED matrices (those flexible ones) and I want to connect them together to make a display for showing images. Now my problem is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider the coordinate system with four quadrants. I put one matrix in each of the quadrant and my target is to have a one single display as mentioned above. I connect like this: The input of matrix 1 is connected to Arduino, the output of matrix 1 to input of matrix 2, output of matrix 2 to input of matrix 3 (or can be input of 4 also ) and then finally output of 3 (or output of 4th matrix) is connected to input of 4th matrix (or input of 3rd matrix accordingly).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with this is that although this might seem a big display from a distance with 4 matrices working in sync but actually its 4 matrices daisy chained and split into 2 rows. This would split my image if I were to display. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question: Is it possible to parallel chain these APA102 matrices and thereby form one continuous display which can be controlled by FASTLED library?? I might be somehow able to address an individual LED in this type of weird pattern, but while displaying images, I am lost. Can't figure out how to do that? Realised that I need to have parallel chaining.....which I have no idea of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help, guidance would be great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="20119" LastEditorUserId="25788" LastEditDate="2016-09-16T14:32:53.603" LastActivityDate="2016-09-16T14:32:53.603" Title="Parallel Chaining of APA102 LED matrices" Tags="|led|arduino-due|rgb-led|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23455" PostTypeId="1" AcceptedAnswerId="23481" CreationDate="2016-04-22T12:48:46.197" Score="7" ViewCount="16140" Body="&lt;p&gt;I'm getting back up and running with microcontrollers after about 5 years of hibernation time, and I am trying to understand a lot of different things. I have been experimenting with Arduinos for the past few weeks and am having a ton of fun. I'm a software engineer by day and a hardware hacker / manufacturer by night. At my day job, I write scripts and applications that are thousands of lines long and highly complex, using external libraries of thousands more lines of code, etc. These are full-fledge, professional software applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, here is my question. Is the Arduino capable of running full-fledged robotics and other large, complex hardware applications, or is it more of a tinkering, hobbyist tool?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How big of a project can be built using Arduino? Are there memory concerns? Can an Arduino run thousands and thousands of lines of code out of the box, and if not, is there a way to add more memory for larger, more complex projects? &lt;/p&gt;&#xA;" OwnerUserId="20046" LastActivityDate="2016-06-22T21:00:04.800" Title="How much code can an Arduino board run?" Tags="|memory|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23456" PostTypeId="2" ParentId="23455" CreationDate="2016-04-22T13:05:56.050" Score="2" Body="&lt;p&gt;Although Arduino is more of a hobbyist electronics board, it can handle complex projects depending on which board you use. The Mega has 54 input pins, so can handle loads of devices and has much more memory and storage. See the Uno - Mega specs below&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The ATmega328 chip found on the Uno has the following amounts of memory:&#xA;  Flash  32k bytes (of which .5k is used for the bootloader)&#xA;  SRAM   2k bytes&#xA;  EEPROM 1k byte&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The ATmega2560 in the Mega2560 has larger memory space :&#xA;  Flash  256k bytes (of which 8k is used for the bootloader)&#xA;  SRAM   8k bytes&#xA;  EEPROM 4k byte&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="19667" LastActivityDate="2016-04-22T13:05:56.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23457" PostTypeId="2" ParentId="23453" CreationDate="2016-04-22T13:18:55.173" Score="1" Body="&lt;p&gt;Have you remembered to logic shift the ESP8266 from 3.3v to 5v?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any by no response, do you mean no response from your web server or the board itself?&lt;/p&gt;&#xA;" OwnerUserId="16168" LastActivityDate="2016-04-22T13:18:55.173" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23459" PostTypeId="1" CreationDate="2016-04-22T13:53:03.890" Score="2" ViewCount="289" Body="&lt;p&gt;I'm creating a project where music gets played that is the same length or slightly shorter than the given time (minutes:seconds). For this I have a Sparkfun MP3 shield, which also has a microSD slot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue is that I can't find a way to get the playtime of a given MP3 file. The only idea that I have is using the filesize and bitrate, but that would be horribly annoying for multiple bitrates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Michidez&lt;/p&gt;&#xA;" OwnerUserId="20440" LastActivityDate="2016-04-22T13:53:03.890" Title="Get MP3 play length" Tags="|arduino-mega|sd-card|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23461" PostTypeId="1" CreationDate="2016-04-22T15:03:40.890" Score="3" ViewCount="15475" Body="&lt;p&gt;I have seen many tutorials on programming an Arduino to control a HC-05 bluetooth module. In that I did not understand the term called 'flag'. What does that mean?&lt;/p&gt;&#xA;" OwnerUserId="19413" LastEditorUserId="20631" LastEditDate="2016-04-28T21:30:24.960" LastActivityDate="2016-11-16T01:23:55.233" Title="What is a flag in programming Arduino?" Tags="|arduino-uno|hc-05|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23462" PostTypeId="1" CreationDate="2016-04-22T15:27:17.650" Score="2" ViewCount="723" Body="&lt;p&gt;I'm new to all this stuff and for the past two days, I have been trying to interface a 16x2 LCD to an Arduino Uno using an Intel 8255A component without any luck. The problem is, how can I attach or set the LCD's pins &amp;lt;&gt; to the unknown pins of the 8255A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it even possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any kind of help.&lt;a href=&quot;https://i.stack.imgur.com/KUK8o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KUK8o.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20445" LastEditorUserId="4628" LastEditDate="2016-04-23T06:33:16.930" LastActivityDate="2017-08-14T03:33:46.097" Title="Help! Interfacing LCD with Arduino using 8255A Intel peripherals" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23463" PostTypeId="1" CreationDate="2016-04-22T15:40:08.223" Score="5" ViewCount="856" Body="&lt;p&gt;So I am using an Arduino Mega with the &lt;a href=&quot;https://www.sparkfun.com/products/12660&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun MP3 shield&lt;/a&gt;. And I can't seem to read the µSD card. It's formatted in FAT32 and it has a single .txt file on it. I always get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SD initialization failed.&#xA;Do not reformat the card!&#xA;Is the card correctly inserted?&#xA;Is chipSelect set to the correct value?&#xA;Is there a wiring/soldering problem?&#xA;errorCode: 0x1, errorData: 0xff&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried chipSelect 8,9 and 10. I've seen all the other forum threads about the error but none apply here as it is a bought board and not self built, so the wiring should be correct. I've tried software that has ran on the same configuration, and I get the same error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Michidez&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that I use to try the SD card (QuickStart, from the SdFat Library):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Quick hardware test&#xA;#include &amp;lt;SdFat.h&amp;gt;&#xA;// Test with reduced SPI speed for breadboards.&#xA;// Change spiSpeed to SPI_FULL_SPEED for better performance&#xA;// Use SPI_QUARTER_SPEED for even slower SPI bus speed&#xA;const uint8_t spiSpeed = SPI_HALF_SPEED;&#xA;//------------------------------------------------------------------------------&#xA;// Normally SdFat is used in applications in place&#xA;// of Sd2Card, SdVolume, and SdFile for root.&#xA;Sd2Card card;&#xA;SdVolume volume;&#xA;SdFile root;&#xA;&#xA;// Serial streams&#xA;ArduinoOutStream cout(Serial);&#xA;&#xA;// input buffer for line&#xA;char cinBuf[40];&#xA;ArduinoInStream cin(Serial, cinBuf, sizeof(cinBuf));&#xA;&#xA;// SD card chip select&#xA;int chipSelect;&#xA;&#xA;void cardOrSpeed() {&#xA;  cout &amp;lt;&amp;lt; pstr(&#xA;    &quot;Try another SD card or reduce the SPI bus speed.\n&quot;&#xA;    &quot;The current SPI speed is: &quot;);&#xA;  uint8_t divisor = 1;&#xA;  for (uint8_t i = 0; i &amp;lt; spiSpeed; i++) divisor *= 2;&#xA;  cout &amp;lt;&amp;lt; F_CPU * 0.5e-6 / divisor &amp;lt;&amp;lt; pstr(&quot; MHz\n&quot;);&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;Edit spiSpeed in this sketch to change it.\n&quot;);&#xA;}&#xA;&#xA;void reformatMsg() {&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;Try reformatting the card.  For best results use\n&quot;);&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;the SdFormatter sketch in SdFat/examples or download\n&quot;);&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;and use SDFormatter from www.sdcard.org/consumer.\n&quot;);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {}  // wait for Leonardo&#xA;&#xA;  cout &amp;lt;&amp;lt; pstr(&#xA;    &quot;\nSD chip select is the key hardware option.\n&quot;&#xA;    &quot;Common values are:\n&quot;&#xA;    &quot;Arduino Ethernet shield, pin 4\n&quot;&#xA;    &quot;Sparkfun SD shield, pin 8\n&quot;&#xA;    &quot;Adafruit SD shields and modules, pin 10\n&quot;);&#xA;}&#xA;&#xA;bool firstTry = true;&#xA;void loop() {&#xA;  // read any existing Serial data&#xA;  while (Serial.read() &amp;gt;= 0) {}&#xA;&#xA;  if (!firstTry) cout &amp;lt;&amp;lt; pstr(&quot;\nRestarting\n&quot;);&#xA;  firstTry = false;&#xA;&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;\nEnter the chip select pin number: &quot;);&#xA;  cin.readline();&#xA;  if (cin &amp;gt;&amp;gt; chipSelect) {&#xA;    cout &amp;lt;&amp;lt; chipSelect &amp;lt;&amp;lt; endl;&#xA;  } else {&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;\nInvalid pin number\n&quot;);&#xA;    return;&#xA;  }&#xA;  if (!card.init(spiSpeed, chipSelect)) {&#xA;    cout &amp;lt;&amp;lt; pstr(&#xA;      &quot;\nSD initialization failed.\n&quot;&#xA;      &quot;Do not reformat the card!\n&quot;&#xA;      &quot;Is the card correctly inserted?\n&quot;&#xA;      &quot;Is chipSelect set to the correct value?\n&quot;&#xA;      &quot;Is there a wiring/soldering problem?\n&quot;);&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;errorCode: &quot;) &amp;lt;&amp;lt; hex &amp;lt;&amp;lt; showbase &amp;lt;&amp;lt; int(card.errorCode());&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;, errorData: &quot;) &amp;lt;&amp;lt; int(card.errorData());&#xA;    cout &amp;lt;&amp;lt; dec &amp;lt;&amp;lt; noshowbase &amp;lt;&amp;lt; endl;&#xA;    return;&#xA;  }&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;\nCard successfully initialized.\n&quot;);&#xA;  cout &amp;lt;&amp;lt; endl;&#xA;&#xA;  uint32_t size = card.cardSize();&#xA;  if (size == 0) {&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;Can't determine the card size.\n&quot;);&#xA;    cardOrSpeed();&#xA;    return;&#xA;  }&#xA;  uint32_t sizeMB = 0.000512 * size + 0.5;&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;Card size: &quot;) &amp;lt;&amp;lt; sizeMB;&#xA;  cout &amp;lt;&amp;lt; pstr(&quot; MB (MB = 1,000,000 bytes)\n&quot;);&#xA;  cout &amp;lt;&amp;lt; endl;&#xA;&#xA;  if (!volume.init(&amp;amp;card)) {&#xA;    if (card.errorCode()) {&#xA;      cout &amp;lt;&amp;lt; pstr(&quot;Can't read the card.\n&quot;);&#xA;      cardOrSpeed();&#xA;    } else {&#xA;      cout &amp;lt;&amp;lt; pstr(&quot;Can't find a valid FAT16/FAT32 partition.\n&quot;);&#xA;      reformatMsg();&#xA;    }&#xA;    return;&#xA;  }&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;Volume is FAT&quot;) &amp;lt;&amp;lt; int(volume.fatType());&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;, Cluster size (bytes): &quot;) &amp;lt;&amp;lt; 512L * volume.blocksPerCluster();&#xA;  cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&#xA;&#xA;  root.close();&#xA;  if (!root.openRoot(&amp;amp;volume)) {&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;Can't open root directory.\n&quot;);&#xA;    reformatMsg();&#xA;    return;&#xA;  }&#xA;&#xA;&#xA;&#xA;cout &amp;lt;&amp;lt; pstr(&quot;Files found (name date time size):\n&quot;);&#xA;  root.ls(LS_R | LS_DATE | LS_SIZE);&#xA;&#xA;  if ((sizeMB &amp;gt; 1100 &amp;amp;&amp;amp; volume.blocksPerCluster() &amp;lt; 64)&#xA;    || (sizeMB &amp;lt; 2200 &amp;amp;&amp;amp; volume.fatType() == 32)) {&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;\nThis card should be reformatted for best performance.\n&quot;);&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;Use a cluster size of 32 KB for cards larger than 1 GB.\n&quot;);&#xA;    cout &amp;lt;&amp;lt; pstr(&quot;Only cards larger than 2 GB should be formatted FAT32.\n&quot;);&#xA;    reformatMsg();&#xA;    return;&#xA;  }&#xA;  // read any existing Serial data&#xA;  while (Serial.read() &amp;gt;= 0) {}&#xA;  cout &amp;lt;&amp;lt; pstr(&quot;\nSuccess!  Type any character to restart.\n&quot;);&#xA;  while (Serial.read() &amp;lt; 0) {}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20440" LastEditorUserId="19409" LastEditDate="2017-04-30T07:40:54.310" LastActivityDate="2017-12-28T22:51:37.833" Title="Reading SD card with Sparkfun MP3 Shield" Tags="|sd-card|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23464" PostTypeId="1" CreationDate="2016-04-22T16:10:49.307" Score="0" ViewCount="271" Body="&lt;p&gt;This is my code. I am tring to make a connection to my wifi through esp8266.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DST_IP &quot;192.168.1.5&quot; // my IP&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(0, 1);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  mySerial.begin(115200);&#xA;  while (! Serial); // Wait until Serial is ready - Leonardo&#xA;  Serial.println(&quot;AT+RST&quot;);&#xA;  delay(4000);&#xA;  Serial.println(&quot;AT+CWJAP=\&quot;Ahmed\&quot;,\&quot;12341234Aass\&quot;&quot;);&#xA;  delay(4000);&#xA;  if (Serial.find(&quot;OK&quot;) )&#xA;  {&#xA;    Serial.println(&quot;1&quot;);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;0&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the result of my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rrJhu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rrJhu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20326" LastActivityDate="2016-04-22T16:15:54.727" Title="Connecting to WIFI using esp8266" Tags="|arduino-uno|serial|arduino-ide|wifi|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23465" PostTypeId="2" ParentId="23464" CreationDate="2016-04-22T16:15:54.727" Score="1" Body="&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(0, 1);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;try changing &lt;strong&gt;pin0&lt;/strong&gt; and &lt;strong&gt;pin1&lt;/strong&gt; with some other pins. (lets say with &lt;strong&gt;pin2&lt;/strong&gt; &amp;amp; &lt;strong&gt;pin3&lt;/strong&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;pin0&lt;/strong&gt; and &lt;strong&gt;pin1&lt;/strong&gt; are used by default &lt;strong&gt;Serial&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19513" LastActivityDate="2016-04-22T16:15:54.727" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23466" PostTypeId="1" CreationDate="2016-04-22T17:08:40.010" Score="0" ViewCount="4950" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;//This sketch is a metronome, in which each led pin shows one beat.&#xA;&#xA;const int speaker = 13;  //speaker at pin 13&#xA;int ts = 6;  //highest led pin&#xA;int count = 3;  //&quot;beat 1 pin&quot;&#xA;const int keyPin = 11;  //button to change time signature&#xA;const int keyPinR = 10;  //button to change rhythm&#xA;const int keySwitch = 2;  //sleep mode/wake up button&#xA;&#xA;//All pins below use a pull-up resistor, so the states are inverted&#xA;int buttonState = LOW;&#xA;int buttonState2 = LOW;&#xA;int switchState = LOW;&#xA;int silentState = LOW;&#xA;&#xA;int bpm = 120;  //you do not need to know this, &#xA;//it's just a variable for the potentiometer to change the tempo&#xA;&#xA;int rthm = 1;  //rhythm &#xA;volatile int pressed = 0;&#xA;long silent = p;&#xA;&#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;&#xA;   for(int thisPin = 3;thisPin &amp;lt;= ts;thisPin++)&#xA;   {&#xA;      pinMode(thisPin,OUTPUT); //initialize thisPin as an output&#xA;      pinMode(8, INPUT); //potentialmeter for changing temp    &#xA;      //Pin 9 to 11, along with pin 2, are all push buttons with pull-up     resistors&#xA;      for(int i = 9; i&amp;lt;=11; i++)&#xA;      {&#xA;         pinMode(i, INPUT);&#xA;         digitalWrite(i, HIGH);&#xA;      }&#xA;         pinMode(2, INPUT);&#xA;         digitalWrite(2,HIGH);       &#xA;   }    &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   turnOn();&#xA;}&#xA;&#xA;void turnOn()&#xA;{&#xA;    buttonState = digitalRead(keyPin);//key for &#xA;    buttonState2 = digitalRead(keyPinR);&#xA;    switchState = digitalRead(keySwitch);&#xA;    silentState = digitalRead(9);&#xA;    //Serial.println(switchState);&#xA;    if(switchState==LOW&amp;amp;&amp;amp;pressed==0)&#xA;    {&#xA;       sleep_enable();&#xA;       set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;       attachInterrupt(digitalPinToInterrupt(0), interrupt, LOW);&#xA;       sleep_cpu();&#xA;       //Serial.println(switchState);   &#xA;    }     &#xA;    else {&#xA;       //The beat starts at pin 3, runs in consecutive pins, &#xA;       //and ends at pin 8 at maximum&#xA;       if(buttonState==LOW)&#xA;       {  //changing time signature - up to 5 beats&#xA;           ts++; &#xA;           if(ts==8)&#xA;           {&#xA;              ts = 3;&#xA;              //8 - 3 = 5 beats max&#xA;           } &#xA;        }&#xA;        if(buttonState2==LOW)&#xA;        {  //changing rhythm - quarter note to eighth, then &#xA;          //triplets and sixteenths, back to quarter notes&#xA;          rthm++; &#xA;          if(rthm==5)&#xA;          rthm = 1;  &#xA; }&#xA;&#xA;    if(silentState==LOW){//if silent key pressed, go to silence (only LED's showing) &#xA;    silent++;&#xA;  }&#xA;&#xA;  //The RUN code &#xA;  for(int thisPin = 3;thisPin &amp;lt;= ts;thisPin++)&#xA;  //LED's blinking beats (thisPin - LED pin (beat number + 2))&#xA; { &#xA;&#xA; for(int r = 1; r&amp;lt;=rthm; r++)&#xA; {//nested loop for the rhythm      &#xA;   bpm = pulseIn(8, HIGH);//pin 8 - tempo potentialmeter&#xA;   digitalWrite(thisPin,HIGH);//each LED blinks&#xA;&#xA;   pinMode(13,OUTPUT); //pin 13 - speaker &#xA;&#xA;   if(silent%2==0)//Press once, tone, press again, no tone&#xA;     noTone(13);&#xA; else&#xA; if(count == 3&amp;amp;&amp;amp;r==1). //first beat is higher&#xA; tone(13,4400,80);&#xA; else if(r==1). //downbeats slightly lower&#xA; tone(13,2500,80);&#xA; else&#xA; tone(13,2200,60);  //off beats even lower&#xA; delay((bpm-52)/rthm);    &#xA; digitalWrite(thisPin,LOW);  //turn each off as we proceed to the next beat (LED)&#xA; pinMode(13,INPUT);  //speaker input        &#xA;}    &#xA;count++;  //beat++&#xA;&#xA;if(count &amp;gt;ts){//go back to count&#xA;count = 3;&#xA;}  &#xA;&#xA;   }&#xA;  }&#xA; }&#xA;&#xA;&#xA;void noSound()//silence the speaker&#xA;{&#xA;  noTone(13);&#xA;}&#xA;&#xA;void interrupt()//this is where the sleep interrupt starts -               //how can i press it to wake up???&#xA;{&#xA;    sleep_disable();        &#xA;    detachInterrupt(0);&#xA;    if(switchState==HIGH){ &#xA;       pressed = 1;&#xA;       Serial.println(switchState);&#xA;       turnOn(); //go back to the main functional method (?????)&#xA;     }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once the keySwitch button is pressed (pin 2), the arduino goes to sleep; however, the only way to turn it on is by resetting everything. How can I just wake up the Arduino, keeping every state as before the sleep interrupt?&lt;/p&gt;&#xA;" OwnerUserId="19210" LastEditorUserId="19667" LastEditDate="2016-04-23T06:33:06.380" LastActivityDate="2016-06-22T07:49:45.043" Title="Wake up from sleep from pressed button?" Tags="|arduino-uno|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23467" PostTypeId="2" ParentId="23466" CreationDate="2016-04-22T17:29:52.863" Score="1" Body="&lt;pre&gt;&lt;code&gt;attachInterrupt(digitalPinToInterrupt(0), interrupt, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;should be either &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, interrupt, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(digitalPinToInterrupt(2), interrupt, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As pin 0 is not an interrupt pin. Also the button is connected to pin 2, not pin 0. &lt;code&gt;digitalPinToInterrupt(0)&lt;/code&gt; would actually return &lt;code&gt;-1&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-04-22T18:11:25.943" LastActivityDate="2016-04-22T18:11:25.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23468" PostTypeId="1" CreationDate="2016-04-22T16:26:59.740" Score="0" ViewCount="209" Body="&lt;p&gt;I am trying to use a rotary encoder with an integrated circuit to measure the position of a rotating shaft. I am then taking this data and writing to an SD card. The IC seems to be working correctly and outputting binary data to the specified pins,  but the data does not seem to be reaching the micro-controller. My output data is fragmented, and seems to only be receiving binary data from some of the IC pins. The IC I am using is HCTL-2021-A00 (&lt;a href=&quot;http://www.mouser.com/ProductDetail/Avago-Technologies/HCTL-2021-A00/?qs=RuhU64sK2%252bsgeK17XZB%2fNA%3d%3d&quot; rel=&quot;nofollow&quot;&gt;http://www.mouser.com/ProductDetail/Avago-Technologies/HCTL-2021-A00/?qs=RuhU64sK2%252bsgeK17XZB%2fNA%3d%3d&lt;/a&gt;). I tried using a larger gauge wire to connect the two, but then the micro-controller didn't seem to pick up any of the data. Here is the code I used. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to use a rotary encoder with the HCTL-2021-A00 from avago. I am getting data output from the IC, but only one of the two bytes which it should be providing. When I move the encoder forward, it will only give me the LOW byte and all of the high bits will be zero. However, when I move the encoder backward, all of the high data bits are 1, and the low data bits still operate normally, counting the position. What could cause the high data bits to all be 1 when moving backward, and all 0 when moving forward? Code used is below. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;File datafile;&#xA;const int chipSelect = 10; // connected to the CS pin on the sd card, Make sure the card is formatted&#xA;int encoderpos=0;&#xA;int i=0;&#xA;int pulses, A_SIG=0, B_SIG=1;&#xA;int b[15];  //the individual bits of data read from the IC&#xA;int pos; //position output of IC ranging from 0 to 5000 for 1 revolution&#xA;int selpin=1, OEpin=2;&#xA;int clock=4;&#xA;int d[7]; //the pins on the IC attached to which digital teensy pins&#xA;double deg; //degree position of the servo as found from the encoder and IC&#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  //set pwm signal for timer input&#xA;  pinMode(4, OUTPUT);&#xA;  analogWriteFrequency(4, 6000000); // Teensy 3.0 pin 3 also changes to 375 kHz&#xA;analogWrite(4, 128);&#xA;   //First setup and attach the pins used to communicate with the IC and encoder&#xA;  d[0]=22;//pin numbers for attaching the IC to the teensy&#xA;  d[1]=21;&#xA;  d[2]=20;&#xA;  d[3]=19;&#xA;  d[4]=18;&#xA;  d[5]=17;&#xA;  d[6]=16;&#xA;  d[7]=15;&#xA;//first set pins as inputs and outputs&#xA;pinMode(selpin, OUTPUT);&#xA;pinMode(OEpin, OUTPUT);&#xA;pinMode(d[0], INPUT);&#xA;pinMode(d[1], INPUT);&#xA;pinMode(d[2], INPUT);&#xA;pinMode(d[3], INPUT);&#xA;pinMode(d[4], INPUT);&#xA;pinMode(d[5], INPUT);&#xA;pinMode(d[6], INPUT);&#xA;pinMode(d[7], INPUT);&#xA;&#xA;digitalWrite(selpin, HIGH);&#xA;digitalWrite(OEpin, HIGH);&#xA;&#xA;pinMode(5, OUTPUT);&#xA;&#xA;digitalWrite(5, HIGH);&#xA;delay(5);&#xA;digitalWrite(5, LOW);&#xA;delay(5);&#xA;digitalWrite(5, HIGH);&#xA;delay(5);&#xA;&#xA;pinMode(chipSelect, OUTPUT);&#xA;SD.begin();&#xA;datafile=SD.open(&quot;c.txt&quot;, FILE_WRITE);&#xA;pinMode(7, INPUT);&#xA;pinMode(8, OUTPUT);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;datafile.println(pose());&#xA;if (millis()&amp;gt;4000)&#xA;{&#xA;  datafile.close();&#xA;}&#xA;&#xA;delay(5);&#xA;}&#xA;&#xA;&#xA;int pose()     //Gives the position in degrees from the readings from encoder and IC for 0 to 5000 representing one revolution&#xA;{&#xA;    digitalWrite(selpin, LOW);     // The sel pin on the IC&#xA;  digitalWrite(OEpin, LOW);     // The OE pin on the IC&#xA;digitalWrite(4, HIGH);&#xA;digitalWrite(4, LOW);&#xA;analogWrite(4, 128);&#xA;&#xA;  b[0]=digitalRead(d[0]);&#xA;  b[1]=digitalRead(d[1]);&#xA;  b[2]=digitalRead(d[2]);&#xA;  b[4]=digitalRead(d[4]);&#xA;  b[5]=digitalRead(d[5]);&#xA;  b[6]=digitalRead(d[6]);&#xA;  b[7]=digitalRead(d[7]);&#xA;if(digitalRead(7)==1)&#xA;{&#xA;  digitalWrite(8, HIGH);&#xA;}&#xA;else if(digitalRead(7)==0)&#xA;{&#xA;  digitalWrite(8, LOW);&#xA;}&#xA;  digitalWrite(selpin, HIGH);&#xA;digitalWrite(4, HIGH);&#xA;digitalWrite(4, LOW);&#xA;analogWrite(4, 128);&#xA;&#xA;  b[8]=digitalRead(d[0]);&#xA;  b[9]=digitalRead(d[1]);&#xA;  b[10]=digitalRead(d[2]);&#xA;  b[11]=digitalRead(d[3]);&#xA;  b[12]=digitalRead(d[4]);&#xA;  b[13]=digitalRead(d[5]);&#xA;  b[14]=digitalRead(d[6]);&#xA;  b[15]=digitalRead(d[7]);&#xA;&#xA;  digitalWrite(OEpin, HIGH);&#xA;&#xA;&#xA;  pos=0;&#xA;  i=8;&#xA;  for(i; i&amp;gt;0; i--)&#xA;  {&#xA;pos=2*pos+b[i-1];&#xA;  }&#xA;&#xA;  i=16;&#xA;  for (i; i&amp;gt;8; i--)&#xA;  {&#xA;    pos=2*pos+b[i-1];&#xA;  }&#xA;&#xA;&#xA;  return pos;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20739" OwnerDisplayName="Greg Kosinski" LastEditorUserId="20739" LastEditDate="2016-05-03T03:19:24.813" LastActivityDate="2016-05-03T03:19:24.813" Title="Communication between IC and microcontroller (Teensy 3.2)" Tags="|pwm|communication|rotary-encoder|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23469" PostTypeId="2" ParentId="23468" CreationDate="2016-04-22T17:31:28.147" Score="0" Body="&lt;p&gt;Wanted to just put this in a comment but apparently still don't have the rep to do that, so taking a stab at answering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sounds to me like you are having physical layer corruption issues.  I highly doubt that your wires were too fine a gauge since these are just signal wires for SPI, however, it was instructive that you did that since larger wires seemed to make the problem worse, I would guess that you have too large capacitance on the wire for the datarate you have chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I am debugging any serial communications for the first time, the first thing I do until communication is reliable is to slow the data rate down.  Something like 10kHz should work in most cases.  See if this fixes the corrupted data.  If it does, go back to a finer gauge wire and then bump the speed back up til you see corruption issues.  If you have a logic analyzer or a scope you can get on the line, it will be very educational to see what is going on with your edge rates.  &lt;/p&gt;&#xA;" OwnerUserId="20483" OwnerDisplayName="while1" LastActivityDate="2016-04-22T17:31:28.147" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23470" PostTypeId="2" ParentId="23468" CreationDate="2016-04-22T17:44:44.270" Score="0" Body="&lt;p&gt;You seem to be overlooking (or at least mishandling) the fact that these parts are built with a bus interface where the /OE and SEL signals as well as the internal position data latch are &lt;em&gt;sampled&lt;/em&gt; synchronously with a clock input which you do not seem to be driving.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You need to generate a low-to-high transition of the CLK signal to latch the count into the readout&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You need to generate a high-to-low transition of the CLK signal to latch in chosen values of the /OE and SEL signals.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On second examination of your code, perhaps you are trying to use a free-running clock asynchronous to your reading.  That, however, is extremely unwise.  First, you don't know that a suitable clock edge will happen between when you set the /OE or SEL and when you try to read the data.  Next, you do not know that an &lt;em&gt;undesired&lt;/em&gt; clock edge will &lt;em&gt;not&lt;/em&gt; happen in the midst of reading data, causing you to end up with a corrupted value that contains some &quot;old&quot; bits from before the clock edge and some &quot;new&quot; bits from after.  This would be particularly bad if it happened across a transition such as 0b01111111 to 0b10000000 or similar...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may have other problems as well - your question is not complete without a schematic diagram of how you have wired up this chip.&lt;/p&gt;&#xA;" OwnerUserId="612" OwnerDisplayName="Chris Stratton" LastActivityDate="2016-04-22T17:44:44.270" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23472" PostTypeId="2" ParentId="23152" CreationDate="2016-04-22T19:23:45.873" Score="3" Body="&lt;p&gt;In languages such as C or C++ there is a distinction between integer types and floating-point types. You see, computers work using &lt;strong&gt;bits&lt;/strong&gt;. A bit is either &lt;strong&gt;0&lt;/strong&gt; or &lt;strong&gt;1&lt;/strong&gt;. A bit obviously lack in both range and precision, so we combine multiple bits in order to improve.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Integral Types&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;byte&lt;/strong&gt; is a group of 8 bits. In C, the type used is either&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t x; // Values from 0 to 255.&#xA;int8_t  x; // Values from -128 to 127&#xA;char    x; // Values from the ASCII character set (still -128 to 127)       &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Ardiuno Uno, an &lt;strong&gt;int&lt;/strong&gt; is a group of 16 bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t c; // Values from 0 to 2^16-1 = 65535, synonym: unsigned int (Arduino)&#xA;int16_t  c; // Values from -32768 to 32767,     synonym: int (Arduino)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A &lt;strong&gt;long&lt;/strong&gt; is a group of 32 bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t v; // Values from 0 to 2^32-1 = 4,294,967,295 = 4 GiB (unsigned long)&#xA;int32_t  v; // Values from -2,147,483,648 to 2,147,483,647 (long)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is also usually support for 64-bit numbers, but we try not to use them in Arduino code. The reason is that most Arduino MCUs use &lt;strong&gt;8-bit&lt;/strong&gt; registers, so 64-bit operations such as &quot;add&quot;, &quot;sub&quot;, etc. would be very slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Different architectures use different numbers of bits for these types. In order to be compatible with other architectures, use &lt;code&gt;int32_t&lt;/code&gt; etc. to be sure.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Literals and Casts&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Oftentimes, the compiler can not see what type a literal value is supposed to be. In C, the compiler picks a default which is usually larger than you would like. For this reason, it is useful to know how to specify a literal exactly with the type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ((uint8_t)200)   // Casting 200 to an unsigned 8-bit integer&#xA; ((char)65)       // Making the ASCII letter 'A'&#xA; ((int32_t)42)    // Force 32 as a signed 32-bit integer (long)&#xA; 42L              // The 'L' suffix does the same as above&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;Division and Remainder&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;A common cause of problems when programming in C is the division operator &lt;code&gt;/&lt;/code&gt;. If the operands are both integer types, the result will also be an integer. So &lt;code&gt;1/3&lt;/code&gt; is in fact &lt;code&gt;0&lt;/code&gt;. You can get the remainder of the division using the modulus operation &lt;code&gt;%&lt;/code&gt;. For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void show_division(int n, int d)&#xA;{&#xA;    Serial.print(&quot;The division: &quot;);&#xA;    Serial.print(n);&#xA;    Serial.print(&quot; / &quot;);&#xA;    Serial.print(d);&#xA;    Serial.print(&quot; equals &quot;);&#xA;    Serial.print(n / d);&#xA;    Serial.print(&quot; with a remainder &quot;);&#xA;    Serial.println(n % d);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Floating-point Types&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;All of the above types are integrals, so they do not support any fractional value. Therefore C defines &lt;strong&gt;two&lt;/strong&gt; different floating-point types: &lt;strong&gt;float&lt;/strong&gt; and &lt;strong&gt;double&lt;/strong&gt;. The former is a 32-bit value and the latter is a 64-bit value. The way it works is that the bits are split in 3:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A single bit is used for the &lt;strong&gt;sign&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;A certain number of bits represent the fractional part, the &lt;strong&gt;mantissa&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The rest of the bits are used for the &lt;strong&gt;exponent&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As an example, the 32-bit float value representation for 1.25 is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;seeeeeee_emmmmmmm_mmmmmmmm_mmmmmmmm = s * 2^(e-127) * (1.m...)_2&#xA;00111111_10100000_00000000_00000000 = (+1) * 2^(127-127) * (1.0100)_2&#xA;// Note: Binary 1.01 equals 1.25 in decimal&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h2&gt;For performance, use the &lt;code&gt;f&lt;/code&gt; suffix&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Although 64-bit doubles are very accurate, the resulting code will run much slower. I, therefore, recommend using 32-bit floats instead. It is useful to know that you can tack on an &lt;code&gt;f&lt;/code&gt; after the floating-point literal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(a + b + c) / 3.0f; // Make sure to divide using 32-bit operations.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; above are integer types, the additions will also be integer additions. When the compiler sees an &lt;code&gt;int&lt;/code&gt; divided by a &lt;code&gt;float&lt;/code&gt;, it will convert the &lt;code&gt;int&lt;/code&gt; to a &lt;code&gt;float&lt;/code&gt;, and then perform a float division. This is slow, but certainly faster than a double division.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler is smart, but it doesn't hurt to help it. There is only a very small precision loss in converting this to a float multiplication:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(a + b + c) * (1.0f / 3.0f);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The compiler will pre-calculate &lt;code&gt;(1.0f / 3.0f)&lt;/code&gt;, so you get a much faster floating-point multiplication (in addition to the &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;float&lt;/code&gt; cast). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Arduino Uno defaults all floating point literals to 32-bit, and &lt;code&gt;double&lt;/code&gt; is the same as &lt;code&gt;float&lt;/code&gt;. Therefore, the &lt;code&gt;f&lt;/code&gt; suffix is strictly not needed. It is still good practice to add these for compatibility with other architectures.&lt;/p&gt;&#xA;" OwnerUserId="20450" LastEditorUserId="20450" LastEditDate="2016-04-26T20:27:35.207" LastActivityDate="2016-04-26T20:27:35.207" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23473" PostTypeId="1" CreationDate="2016-04-22T21:02:56.667" Score="0" ViewCount="2247" Body="&lt;p&gt;I'm using two &lt;a href=&quot;http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01&quot; rel=&quot;nofollow noreferrer&quot;&gt;nRF24L01&lt;/a&gt; to communicate with each other. I did the right setup and they worked fine, however I wanted to change the air data rate to a lower value, for more stability, as the &lt;a href=&quot;http://www.nordicsemi.com/eng/content/download/2730/34105/file/nRF24L01_Product_Specification_v2_0.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt; says.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I setup the configuration for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a small research I knew that you can change this using &lt;code&gt;RF_DR&lt;/code&gt; &#xA;to change the value of the transmission, but I didn't really know how I could exactly write the correct code for this. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another question: does this effect the range of the module? Or does it only affect the stability? And if not, then which code can I use to extend the range of these two modules ?&lt;/p&gt;&#xA;" OwnerUserId="20243" LastEditorUserId="28084" LastEditDate="2016-11-19T20:24:52.563" LastActivityDate="2020-10-20T05:58:27.220" Title="Air data rate nRF24L01" Tags="|arduino-uno|nrf24l01+|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23474" PostTypeId="2" ParentId="23473" CreationDate="2016-04-22T21:32:58.127" Score="-1" Body="&lt;p&gt;The documentation for the function you want is &lt;a href=&quot;http://tmrh20.github.io/RF24/classRF24.html#aeb9920e7a95699748b003c4a839b0814&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reducing the speed doesn't directly increase the range, but increased stability will have the knock-on effect that the fringes of transmission distance will be more reliable, making it appear that you have slightly greater distance.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-22T21:32:58.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23475" PostTypeId="1" CreationDate="2016-04-22T21:57:54.643" Score="3" ViewCount="1558" Body="&lt;p&gt;I am currently trying to learn how to use my MQ 7 CO Standalone to read CO in the air around the sensor. Currently Im using this circuit using my Arduino Uno. I get results of 900-1000. Here's a Fritzing Schematic on my setup. &lt;a href=&quot;https://i.stack.imgur.com/gPi7c.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gPi7c.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently this is the code I am using on the arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[code]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int mqx_analogPin = A0; // connected to the output pin of MQ-X&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); // open serial at 9600 bps&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // give ample warmup time for readings to stabilize&#xA;&#xA;  int mqx_value = analogRead(mqx_analogPin);&#xA;  Serial.println(mqx_value);&#xA;&#xA;  delay(100); //Just here to slow down the output.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm following the setup from this Instructables: &#xA;&lt;a href=&quot;http://www.instructables.com/id/Smoke-Detector/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Smoke-Detector/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However his readings are around 150-200ppm outside. I'm unsure how to reach these values since im following basically everything from the guide. Does anyone any experience with a MQ7 sensor? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been reading I need to preheat the sensor but I can't find any circuit that clearly shows how to preheat an MQ7 sensor or find any code for the arduino. &lt;/p&gt;&#xA;" OwnerUserId="20454" LastActivityDate="2020-11-18T15:07:45.610" Title="MQ7 Readings are too high" Tags="|serial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23476" PostTypeId="2" ParentId="23416" CreationDate="2016-04-22T22:40:58.213" Score="1" Body="&lt;p&gt;The solution was to hook up PA0 to GPIO18 of the pi with an RC-circuit inbetween.&#xA;GPIO18 features a hardware PWM output, which has to be set to mode 0 (non balanced, mark-space), because the balanced mode could not handle odd pwmRanges for some reason(it is badly documented).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This setup enables the atmega to read the pi's pulsed 0-3,3V output as analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin initialization on Pi(using a python library):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import wiringpi2 as wiringpi&#xA;&#xA;wiringpi.wiringPiSetupGpio()&#xA;wiringpi.pinMode(18, 2)&#xA;wiringpi.pwmSetMode(0)    #&amp;lt;- important part&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently writing the Atmega side&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    uint8_t     i = 0;&#xA;    uint32_t val  = 0;&#xA;    while(i&amp;lt;8)    //average 8 measures&#xA;    {&#xA;        i++;&#xA;        ADMUX   = 0 &amp;amp; 0x1f;    //select channel 0 (PA0)&#xA;        ADMUX |= (1&amp;lt;&amp;lt;5);       //set ADLAR bit ADCH &amp;gt; ADCL&#xA;        ADCSRA  = ADCSRA | (1 &amp;lt;&amp;lt; ADSC) | (1 &amp;lt;&amp;lt; ADIF);&#xA;        while (ADCSRA &amp;amp; (1&amp;lt;&amp;lt;ADSC));&#xA;        val = val + (ADCH);&#xA;    }&#xA;    return ((val)&amp;gt;&amp;gt;3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this reads a 10bit value on the channel and discards the least significant 2bit stored in ADCL as ADLAR is set to speed everything up.&lt;/p&gt;&#xA;" OwnerUserId="11885" LastEditorUserId="11885" LastEditDate="2016-04-23T15:30:29.260" LastActivityDate="2016-04-23T15:30:29.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23477" PostTypeId="1" AcceptedAnswerId="23478" CreationDate="2016-04-23T00:06:05.360" Score="1" ViewCount="645" Body="&lt;p&gt;I'm working on a personal project  (a usefully tool based on ublox GPS and Arduino Mega that can measure distance between 2 points, compute area, speed, save data on SD card)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to add new feature and when I show the area(in m^2) on LCD, I want to show the polygon built by more coordinates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried all I know, I searched for solutions but without success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I &quot;scale down&quot; coordinates to make them fit in a x,y system with max size (320*480, LCD size) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/je0jh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/je0jh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20455" LastActivityDate="2016-04-23T07:43:02.437" Title="Draw polygon on LCD from GPS latitude and longitude" Tags="|arduino-mega|lcd|gps|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23478" PostTypeId="2" ParentId="23477" CreationDate="2016-04-23T00:40:44.037" Score="2" Body="&lt;p&gt;Over a small area lat and long are just simple Y and X coordinates respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dynamic scaling of the points is a very simple matter.  All you need to do is work out the range of each dimension - so subtract the lowest latitude from the highest, and the lowest longitude from the highest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That gives the full X and Y dimension of your area. Then just divide those by the dimensions of your screen.  That gives you a scaling factor for each direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each point, subtract the lowest longitude and latitude, and divide by the scaling factor for each direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to be more fancy and retain the aspect ratio then you just need to work out which of the two scaling factors will allow all the polygon to remain on the screen - that is, divide and offset all your points by one factor, then by the other, and pick the smallest factor where all the points are within the area of your screen.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-23T00:40:44.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23479" PostTypeId="2" ParentId="23462" CreationDate="2016-04-23T02:54:04.560" Score="1" Body="&lt;p&gt;You will not be able to use 8255 pins as parameters to the the LiquidCrystal library without making substantial changes to either the library or the Arduino core.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason is that to configure or change a pin on the 8255, you will need to go through a series of operations manipulating the ATmega pins to which the 8255's &lt;code&gt;microprocessor bus interface&lt;/code&gt; is connected.  You can learn about the necessary operations by reading the 8255 data sheet.  Also keep in mind that the 8255 does not have per-pin configuration - rather, the first two ports must each be either entirely inputs or entirely outputs, while there third port can be split in half.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you know how to set a pin, you will need to have the liquid crystal functionality trigger these operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One approach would be to create a heavily modified version of the library which knows how to work through the 8255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another would be to create a modified version of the Arduino core which has additional pin numbers corresponding to the 8255's pins, and generates code which does the necessary intermediate bus operations to access them.  However this will be quite challenging - you have to make sure the intermediate code gets in there in all paths, and figure out how it will handle cases where code tries to set pins that must have the same mode to conflicting modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As others have said, you would practically be better off using a different MCU with more I/Os - either an Arduino Mega, or one of the ARM-based boards.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-23T02:54:04.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23481" PostTypeId="2" ParentId="23455" CreationDate="2016-04-23T06:10:26.650" Score="10" Body="&lt;p&gt;There are several &quot;Arduinos&quot; with memory capacities ranging from slightly less than 32k/2k/16MHz (Flash/RAM/CPUClock) (&quot;Uno&quot;) to 512k/96k/84MHz (&quot;Due&quot;.)  In addition, there are &quot;mostly compatible&quot; boards that expand that range down to less than 8k/512/8MHz (&quot;Gemma&quot;, &quot;Digistump&quot;) and up to about 1M/256k/120MHz (TI &quot;EK-TM4C1294XL Launchpad&quot;), and &quot;somewhat compatible&quot; boards with 4G/1G/400MHz (Intel &quot;Edison&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whether these are sufficient for &quot;full fledged robotics&quot; depends on what you consider that to mean.  Edison is probably the only contender if you wanted to include computer vision, for example, and it probably doesn't do that very well. (&quot;What did you expect at ONLY 1 core at 400MHz?!&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The small Arduinos probably do not support your &quot;very large libraries&quot;, either.  For example, while the &quot;Arduino Language&quot; is technically C++, support for the C++ STL is not included due to limitations of the small CPUs used and their run-time environment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;32k of program memory (on the popular Uno) is sufficient for &quot;thousands of lines of code&quot;, but I'd think robotics would tend to run toward much more than that.  The small amount of RAM available on most of the flash-based microcontrollers also tends to be a serious limitation when you start looking at standard data-intensive algorithms.  32k/2k disappears quite quickly if you start implementing an extensive user interface, networking, or graphics.  I would say that an Uno-class Arduino is suitable for implementing COMPONENTS of robotics systems (motor drivers, sensor management, etc), but probably not a whole robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good example of large robotics-like software that runs on Arduino-class hardware can probably be found in the 3D Printer space.  &quot;Marlin&quot; firmware runs on an Arduino Mega or equivalent (256k/8k/16MHz) (with RAMPS shield), and there are alternative driver packages that run on smaller and larger arduino-like hardware.  Marlin is about 280k lines of code, according to cloc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduino hardware does NOT have expandable memory.  The AVR cpus cannot run code except from their internal Flash, and few of the other boards have any sort of memory bus that could be used for expansion.&lt;/p&gt;&#xA;" OwnerUserId="20458" LastActivityDate="2016-04-23T06:10:26.650" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23482" PostTypeId="1" AcceptedAnswerId="23500" CreationDate="2016-04-23T07:11:46.803" Score="2" ViewCount="7880" Body="&lt;p&gt;I have connected a BMP280 temperature/pressure sensor to an Arduino Uno just like here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YUjxf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YUjxf.jpg&quot; alt=&quot;pin layout BMP280+Arduino Uno&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and used the example code provided by the Adafruit BMP280 library. However, the values for temperature and pressure return 0.00 on the serial monitor. What might be the reason for this? I have set it up in I2C mode and deleted the lines responsible for the SPI connections.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /***************************************************************************&#xA;  This is a library for the BMP280 humidity, temperature &amp;amp; pressure sensor&#xA;&#xA;  Designed specifically to work with the Adafruit BMEP280 Breakout &#xA;  ----&amp;gt; http://www.adafruit.com/products/2651&#xA;&#xA;  These sensors use I2C or SPI to communicate, 2 or 4 pins are required &#xA;  to interface.&#xA;&#xA;  Adafruit invests time and resources providing this open source code,&#xA;  please support Adafruit andopen-source hardware by purchasing products&#xA;  from Adafruit!&#xA;&#xA;  Written by Limor Fried &amp;amp; Kevin Townsend for Adafruit Industries.  &#xA;  BSD license, all text above must be included in any redistribution&#xA; ***************************************************************************/&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_BMP280.h&amp;gt;&#xA;&#xA;#define BMP_SCK 13 // deleted the following 4&#xA;#define BMP_MISO 12&#xA;#define BMP_MOSI 11 &#xA;#define BMP_CS 10&#xA;&#xA;Adafruit_BMP280 bme; // I2C&#xA;// and the following 2 lines:&#xA;//Adafruit_BMP280 bme(BMP_CS); // hardware SPI&#xA;//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(F(&quot;BMP280 test&quot;));&#xA;&#xA;  if (!bme.begin()) {  &#xA;    Serial.println(&quot;Could not find a valid BMP280 sensor, check wiring!&quot;);&#xA;    while (1);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.print(&quot;Temperature = &quot;);&#xA;    Serial.print(bme.readTemperature());&#xA;    Serial.println(&quot; *C&quot;);&#xA;&#xA;    Serial.print(&quot;Pressure = &quot;);&#xA;    Serial.print(bme.readPressure());&#xA;    Serial.println(&quot; Pa&quot;);&#xA;&#xA;    Serial.print(&quot;Approx altitude = &quot;);&#xA;    Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase&#xA;    Serial.println(&quot; m&quot;);&#xA;&#xA;    Serial.println();&#xA;    delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20459" LastEditorUserId="20459" LastEditDate="2016-04-23T11:48:58.003" LastActivityDate="2020-10-02T02:36:09.650" Title="BMP280 returns 0" Tags="|arduino-uno|sensors|temperature-sensor|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23483" PostTypeId="2" ParentId="23477" CreationDate="2016-04-23T07:43:02.437" Score="0" Body="&lt;p&gt;I did the code for Arduino and it works really nice. I added an dynamic X offset to center it on the screen. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// lat = coordinatesForArea[i][0]&#xA;// lng = coordinatesForArea[i][1]&#xA;// cntr is the count of points&#xA;&#xA;float newPoints[100][2];&#xA;float maxLat = 0;&#xA;float maxLng = 0;&#xA;float minLat = 180;&#xA;float minLng = 180;  &#xA;&#xA;for (int i = 0; i &amp;lt; cntr; i++) {&#xA;  maxLat = max(maxLat, coordinatesForArea[i][0]);&#xA;  maxLng = max(maxLng, coordinatesForArea[i][1]);&#xA;  minLat = min(minLat, coordinatesForArea[i][0]);&#xA;  minLng = min(minLng, coordinatesForArea[i][1]);&#xA;}&#xA;&#xA;float ySize = maxLat - minLat;&#xA;float xSize = maxLng - minLng;&#xA;&#xA;float scaleFactor = ySize / 300;&#xA;&#xA;float maxY = 0;&#xA;float maxX = 0;&#xA;&#xA;for (int i = 0; i &amp;lt; cntr; i++) {      &#xA;  newPoints[i][1] = (coordinatesForArea[i][1] - minLng) / scaleFactor;&#xA;  newPoints[i][0] = (coordinatesForArea[i][0] - minLat) / scaleFactor;&#xA;  maxX = max(maxX, newPoints[i][0]);&#xA;  maxY = max(maxY, newPoints[i][1]);    &#xA;}&#xA;&#xA;&#xA;float newScaleFactor = maxY &amp;gt; maxX ? maxY / 300 : maxX / 300;&#xA;&#xA;float newMaxX = 0;&#xA;&#xA;for (int i = 0; i &amp;lt; cntr; i++) {      &#xA;  newPoints[i][1] = newPoints[i][1] / newScaleFactor;&#xA;  newPoints[i][0] = newPoints[i][0] / newScaleFactor;&#xA;&#xA;  newMaxX = max(newMaxX, newPoints[i][0]);      &#xA;}&#xA;&#xA;float newOffsetX = (320 - newMaxX) / 2;&#xA;float newOffsetY = 100;&#xA;&#xA;for (int i = 0; i &amp;lt; cntr; i++) {      &#xA;  newPoints[i][1] = newPoints[i][1] + newOffsetY;&#xA;  newPoints[i][0] = newPoints[i][0] + newOffsetX;    &#xA;}&#xA;&#xA;for (int i = 0; i &amp;lt; cntr-1; i++) {&#xA;  myGLCD.drawLine(newPoints[i][0], newPoints[i][1], newPoints[i+1][0], newPoints[i+1][1]);&#xA;}&#xA;&#xA;myGLCD.drawLine(newPoints[0][0], newPoints[0][1], newPoints[cntr-1][0], newPoints[cntr-1][1]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you Majenko&lt;/p&gt;&#xA;" OwnerUserId="20455" LastActivityDate="2016-04-23T07:43:02.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23485" PostTypeId="1" CreationDate="2016-04-23T09:43:26.483" Score="0" ViewCount="2878" Body="&lt;p&gt;I am trying to get a response from the arduino when I press a key, but when I try to upload the code it says that it could not find 'Keyboard' with 'Keyboard.write'. Here is my code. Ignore the bits with servo stuff, that is for the project later on. I am using the arduino mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;Servo.h&amp;gt;&#xA;  #include &amp;lt;Keyboard.h&amp;gt;&#xA;&#xA;Servo myservo;  &#xA;Servo myservo2;&#xA;&#xA;int pos = 0;    &#xA;int pos2 = 0;&#xA;String comdata = &quot;&quot;;&#xA;int lastLength = 0;&#xA;&#xA;void setup() {&#xA;myservo.attach(12); &#xA;myservo2.attach(11);&#xA;Serial.begin(9600);&#xA;pinMode(2, INPUT_PULLUP);&#xA;Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;if (Serial.available() &amp;gt; 0) {&#xA; // read incoming serial data:&#xA; char inChar = Serial.read();&#xA; Keyboard.write(inChar + 1);&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19353" LastActivityDate="2016-10-11T14:06:16.860" Title="'Keyboard' not found when trying to use Keyboard.write from the &lt;Keyboard&gt; library" Tags="|serial|arduino-mega|keyboard|input|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23488" PostTypeId="2" ParentId="23485" CreationDate="2016-04-23T10:25:04.800" Score="1" Body="&lt;p&gt;The Mega2560 can't be a keyboard. It lacks the required hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to use one of the pure USB boards, like the Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-23T10:25:04.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23489" PostTypeId="1" AcceptedAnswerId="23495" CreationDate="2016-04-23T13:00:17.883" Score="1" ViewCount="1261" Body="&lt;p&gt;I made something that uploads the measured current to Thingspeak. Everything works, but i did not place the DC to DC converter on the board because i was worried that it would interfere with the analog input. Also the ESP8266 is very close to the Arduino Pro Mini. Could it affect the reading?&#xA;Could i have put the DC to DC converter on the board without any problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C9wgI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C9wgI.jpg&quot; alt=&quot;Arduino Pro Mini that uploads the current consumption to Thingspeak every 15 seconds&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;230VAC to 12VDC adapter(not on the picture) --&gt; 12VDC to 3,3VDC(on the picture)--&gt;the prototype board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor: SCT-013-030 30A = 1V&lt;/p&gt;&#xA;" OwnerUserId="16897" LastEditorUserId="16897" LastEditDate="2016-04-23T14:26:41.560" LastActivityDate="2016-04-23T15:29:21.177" Title="When should you worry about interference affecting the analog input?" Tags="|esp8266|analogread|wireless|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23490" PostTypeId="2" ParentId="23473" CreationDate="2016-04-23T14:13:33.030" Score="1" Body="&lt;p&gt;Increasing stability will increase the (usable) range. At least a bit. You could try decreasing the packet size, to make it even more reliable. There is no way to increase the output-power (only decrease). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try different channels, and see which one gives you the best range in your application. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you have to get NRF24 modules, with external antennas and amplifiers.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-23T14:13:33.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23491" PostTypeId="2" ParentId="23489" CreationDate="2016-04-23T14:19:14.973" Score="0" Body="&lt;p&gt;Noise reduction involving Analog to Digital Conversions can be done in many ways.  Common software solutions involve averaging multiple conversions.  &lt;a href=&quot;https://en.wikipedia.org/wiki/Exponential_smoothing&quot; rel=&quot;nofollow&quot;&gt;Exponential smoothing&lt;/a&gt; is one such method.  One advantage of exponential smoothing is that it can be applied to an endless stream of conversions.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-23T14:19:14.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23493" PostTypeId="1" CreationDate="2016-04-23T14:44:17.080" Score="0" ViewCount="92" Body="&lt;p&gt;Curently I am using these connectors for my prototype:&#xA;&lt;a href=&quot;http://www.ebay.com/itm/120pcs-10cm-2-54mm-1pin-Jumper-Wire-Dupont-Cable-for-Arduino-/381350806379?hash=item58ca47836b:g:V38AAOSwN81WEeMm&quot; rel=&quot;nofollow&quot;&gt;Ebay link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I need something more reliable so I can deliver the prototype to a user without to risk that the cables fall out of their pins.&#xA;Is there something else to use? I would like to avoid soldering.. :(&lt;/p&gt;&#xA;" OwnerUserId="20463" LastActivityDate="2016-04-24T01:03:40.920" Title="Are there fixed connectors for gpio?" Tags="|arduino-uno|mechanical|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23494" PostTypeId="2" ParentId="23493" CreationDate="2016-04-23T14:49:52.653" Score="2" Body="&lt;p&gt;Unless you want to replace the headers with something else, which means soldering, then you will be soldering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The options are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Solder different connectors in the place of the existing headers&lt;/li&gt;&#xA;&lt;li&gt;Remove the existing headers and solder wires directly in their place&lt;/li&gt;&#xA;&lt;li&gt;Get a prototyping shield and solder wires in to that&lt;/li&gt;&#xA;&lt;li&gt;Get a prototyping shield and solder different connectors to it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Whatever you choose you will be soldering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't be scared of soldering - it's the most basic thing you need to be able to do when you are working with electronics.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-23T14:49:52.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23495" PostTypeId="2" ParentId="23489" CreationDate="2016-04-23T15:29:21.177" Score="0" Body="&lt;p&gt;You are more likely to have noise injected on the power pins of the Arduino that by EMI or capacitative coupling. With the switcher on board of off board it will make no difference if the voltage it supplies to the Arduino (and hence to the ADC) is noisy and full of spikes. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-23T15:29:21.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23500" PostTypeId="2" ParentId="23482" CreationDate="2016-04-23T18:27:13.350" Score="1" Body="&lt;p&gt;I2C has to have pull up resistors on the data lines, otherwise it just doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a quick search for the correct value but off the top of my head is 4.7k ish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to place a resistor from the SDA and SCK lines to the +5V and suddenly it will jump into life. (Hopefully)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-23T18:27:13.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23501" PostTypeId="2" ParentId="22301" CreationDate="2016-04-23T18:49:18.250" Score="1" Body="&lt;p&gt;You need an example that shows you how to right to a screen and an example that shows you how to detect a button press, also you need to be able to light LEDs.  These are all examples supplied with the Arduino IDE, are you using that?  Look at each example in turn, setup the circuit get to understand them, then disect them and understand how they work and can get them to do what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Button presses can be trouble some, you may need to investigate denouncing, either software or hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that gives you a starting point.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-23T18:49:18.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23504" PostTypeId="2" ParentId="22070" CreationDate="2016-04-23T20:05:14.767" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;You can actually use outputs as positive voltage, and you can sink currents. But does that mean I can connect the negative side of the coin-cell to an output, and sink it? This way it should power my arduino's VCC pin through the &quot;digital GND&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It would not be a good idea to use a input pin as they can only sink a maximum of 40mA per pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, incase any power surges are experienced and it is connected to Vcc if that 5v is exceeded then it could damage your board. It might be a better solution to use the RAW pin even if it does ultimately use more power.&lt;/p&gt;&#xA;" OwnerUserId="20473" LastActivityDate="2016-04-23T20:05:14.767" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23506" PostTypeId="1" AcceptedAnswerId="23602" CreationDate="2016-04-23T21:51:05.037" Score="4" ViewCount="837" Body="&lt;p&gt;I want to have 6 audio jacks IN waiting for connection to start some WAV/OGG playback as soon as a headphone plugs in. In fact, I'd like to have simultaneous playback in 6 lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen in the market some stuff that you can add buttons to different actions (play, pause, stop, etc). So far I believe this might be possible and affordable with Adafruit's Audio FX (which are stand-alone, Arduino-programmable WAV/OGG decoder circuits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But,&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to start audio playback when headphones gets plugged&#xA;  in? HOW?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Is that an event? like pressing a button?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does it need some &quot;hacking&quot; between GND lines maybe?&lt;/p&gt;&#xA;" OwnerUserId="20475" LastEditorUserId="6936" LastEditDate="2016-04-26T16:05:58.083" LastActivityDate="2017-11-23T23:30:09.023" Title="Is it possible to start audio playback when headphones gets plugged in?" Tags="|audio|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23507" PostTypeId="1" CreationDate="2016-04-23T21:59:22.947" Score="-1" ViewCount="3324" Body="&lt;p&gt;I'm using an ESP8266 (NodeMCU Dev Kit v1) to read analog data via an MCP3008 ADC chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I'm receiving only zeros when I know non-zero data should be present. I'm using the following code, which works perfectly when using the MCP3008 with my Arduino UNO. Using verbose mode on compilation, I can confirm that when compiling for the ESP8266, that is indeed linking the ESP8266 SPI library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I missing something here in the code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define CS_PIN 15 // Use 10 when compiling for Arduino&#xA;&#xA;int adcRead(int channel) {&#xA;  if ((channel &amp;gt; 7) || (channel &amp;lt; 0)) {&#xA;    return -1;&#xA;  }&#xA;&#xA;  digitalWrite(CS_PIN, LOW);&#xA;&#xA;  SPI.transfer(1);&#xA;  uint8_t r1 = SPI.transfer((channel + 8) &amp;lt;&amp;lt; 4);&#xA;  uint8_t r2 = SPI.transfer(0);&#xA;&#xA;  digitalWrite(CS_PIN, HIGH);&#xA;&#xA;  return ((r1 &amp;amp; 3) &amp;lt;&amp;lt; 8) + r2;&#xA;}&#xA;&#xA;void setup() {&#xA;  SPI.begin();&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  SPI.setDataMode(SPI_MODE0);&#xA;  SPI.setFrequency(1000000); // 1 MHz -- remove line when running on Arduino UNO&#xA;  Serial.begin(9600);&#xA;  digitalWrite(CS_PIN, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(adcRead(0));&#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In terms of wiring, I have the following&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MCP3008   ESP8266&#xA;V_DD      3v3&#xA;V_REF     3v3&#xA;AGND      GND&#xA;CLK       GPIO14 (D5)&#xA;D_OUT     GPIO12 (D6)&#xA;D_IN      GPIO13 (D7)&#xA;CS        GPIO15 (D8)&#xA;DGND      GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18992" LastActivityDate="2019-08-30T17:03:15.427" Title="Arduino/ESP8266 no SPI data coming from MCP3008" Tags="|esp8266|spi|adc|nodemcu|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23509" PostTypeId="2" ParentId="23493" CreationDate="2016-04-24T01:03:40.920" Score="0" Body="&lt;p&gt;The cables you link are supposed to be assembled by &lt;em&gt;crimping&lt;/em&gt; rather the &lt;em&gt;soldering&lt;/em&gt;.  The risk of them falling out is mostly because the housing are only for a single contact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you instead get multi-contact housings the width of the headers you are matching, and insert contacts into those in the desired positions, the risk of things falling out will be greatly reduced.  You can add a label to indicate correct insertion direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, a much better result would be to make either a custom shield with terminations for the signals you need to route elsewhere, or to replace the Arduino itself with a custom ATmega board that handles application-appropriate polarity-keyed wiring harnesses.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-24T01:03:40.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23510" PostTypeId="1" AcceptedAnswerId="23518" CreationDate="2016-04-24T01:25:33.440" Score="0" ViewCount="135" Body="&lt;p&gt;I am communicating with my GoPro via ESP8266 and GET requests.&lt;br&gt;&#xA;One of the replies returns a set of predefined number and what I would like to do is extract the number on position &quot;38&quot;. This is what the reply looks like in full:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SEND OK&#xA;&#xA;+IPD,4,163:HTTP/1.1 200 OK&#xA;Transfer-Encoding: chunked&#xA;Date: Sun, 24 Apr 2016 03:13:40 GMT&#xA;Server: Cherokee/1.2.101b150714_bd80061 (UNIX)&#xA;Content-type: application/json&#xA;&#xA;&#xA;OK&#xA;&#xA;+IPD,4,972:3c0&#xA;{&quot;status&quot;:{&#xA;&quot;1&quot;:1,&quot;2&quot;:1,&quot;3&quot;:0,&quot;4&quot;:0,&quot;6&quot;:0,&quot;8&quot;:0,&quot;9&quot;:0,&quot;10&quot;:0,&quot;11&quot;:0,&quot;13&quot;:0,&quot;14&quot;:0,&quot;15&quot;:0,&quot;16&quot;:0,&quot;17&quot;:1,&quot;19&quot;:0,&quot;20&quot;:0,&quot;21&quot;:0,&quot;22&quot;:0,&quot;23&quot;:0,&quot;24&quot;:0,&quot;26&quot;:0,&quot;27&quot;:0,&quot;28&quot;:18,&quot;29&quot;:&quot;&quot;,&quot;30&quot;:&quot;xxx&quot;,&quot;31&quot;:0,&quot;32&quot;:0,&quot;33&quot;:0,&quot;34&quot;:7933,&quot;35&quot;:5039,&quot;36&quot;:0,&quot;37&quot;:4,&quot;38&quot;:0,&quot;39&quot;:4,&quot;40&quot;:&quot;%10%04%18%03%0D%28&quot;,&quot;41&quot;:0,&quot;42&quot;:0,&quot;43&quot;:1,&quot;44&quot;:0,&quot;45&quot;:0,&quot;46&quot;:0,&quot;47&quot;:0,&quot;48&quot;:0,&quot;49&quot;:0,&quot;54&quot;:29698976,&quot;55&quot;:1,&quot;56&quot;:4,&quot;57&quot;:1022279,&quot;58&quot;:0,&quot;59&quot;:0,&quot;60&quot;:500,&quot;61&quot;:2,&quot;62&quot;:0,&quot;63&quot;:0,&quot;64&quot;:0},&#xA;&quot;settings&quot;:{&quot;1&quot;:0,&quot;2&quot;:9,&quot;3&quot;:6,&quot;4&quot;:1,&quot;5&quot;:2,&quot;6&quot;:1,&quot;7&quot;:1,&quot;8&quot;:0,&quot;9&quot;:0,&quot;10&quot;:0,&quot;11&quot;:1,&quot;12&quot;:1,&quot;13&quot;:1,&quot;14&quot;:0,&quot;15&quot;:4,&quot;16&quot;:0,&quot;17&quot;:2,&quot;18&quot;:2,&quot;19&quot;:2,&quot;20&quot;:0,&quot;21&quot;:1,&quot;22&quot;:2,&quot;23&quot;:0,&quot;24&quot;:2,&quot;25&quot;:0,&quot;26&quot;:4,&quot;27&quot;:0,&quot;28&quot;:2,&quot;29&quot;:1,&quot;30&quot;:10,&quot;31&quot;:0,&quot;32&quot;:0,&quot;33&quot;:0,&quot;34&quot;:1,&quot;35&quot;:2,&quot;36&quot;:1,&quot;37&quot;:2,&quot;38&quot;:0,&quot;39&quot;:4,&quot;40&quot;:0,&quot;41&quot;:13,&quot;42&quot;:8,&quot;43&quot;:0,&quot;44&quot;:8,&quot;45&quot;:8,&quot;46&quot;:0,&quot;47&quot;:0,&quot;48&quot;:0,&quot;49&quot;:0,&quot;50&quot;:1,&quot;51&quot;:1,&quot;52&quot;:0,&quot;53&quot;:0,&quot;54&quot;:0,&quot;55&quot;:1,&quot;56&quot;:1,&quot;57&quot;:1,&quot;58&quot;:1,&quot;59&quot;:0,&quot;60&quot;:8,&quot;61&quot;:1,&quot;62&quot;:700000,&quot;63&quot;:4,&quot;64&quot;:1,&quot;65&quot;:0,&quot;66&quot;:0,&quot;67&quot;:0,&quot;68&quot;:0,&quot;69&quot;:0,&quot;70&quot;:0,&quot;71&quot;:0,&quot;72&quot;:1}}&#xA;&#xA;0&#xA;&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, position 38=0 (...,&quot;38&quot;:0,...). The number 0 will increment. So I would like to find the string &lt;code&gt;&quot;38&quot;:&lt;/code&gt; and do something with following numbers until &lt;code&gt;,&lt;/code&gt;.&lt;br&gt;&lt;br&gt;&#xA;What is the correct way to grab that number from the serial reply and echo or do something with it?&lt;/p&gt;&#xA;" OwnerUserId="11249" LastEditorUserId="11249" LastEditDate="2016-04-24T01:30:43.097" LastActivityDate="2016-04-24T10:20:48.480" Title="Find number in a reply returned via serial" Tags="|serial|esp8266|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23514" PostTypeId="1" CreationDate="2016-04-24T05:13:56.740" Score="1" ViewCount="1077" Body="&lt;p&gt;Originally, I had a single sensor which I was reading at 100MHz. I used Timer3 and function attached to it to do both reading and writing of the sensor data (print to com port).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I have added another sensor which can only be read at half the frequency. I still want to be able to write data in the same format as before for both sensor data at 100Hz, with slower sensor data just being repeated twice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I handle this? Do I use multiple Timer3 attachments at different frequencies? I am planning to have three interrupts.. 1st for reading sensor A, 2nd for reading sensor B, and 3rd for writing data.&lt;/p&gt;&#xA;" OwnerUserId="20482" LastActivityDate="2016-11-20T23:33:43.950" Title="Reading two sensors at different frequencies... multiple Timer3?" Tags="|timers|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23515" PostTypeId="1" AcceptedAnswerId="23516" CreationDate="2016-04-24T06:20:22.737" Score="1" ViewCount="3537" Body="&lt;p&gt;I was thinking of using multiple analog light sensors (variable resistance by light), but basically I only need to know if there is &quot;a lot of light&quot; or &quot;not a lot of light&quot;. And would like to use interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I'm using multiple analog inputs, I can't set the ADC module to interrupt on a specific voltage, for each of the (5?) sensors?&#xA;I'd like to do this withouth using a external comparator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've checked the ATMega328p datasheet (going to use Arduino Nano probably).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Dqnbp.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Dqnbp.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fun thing, however, is that on 5V a high signal is &gt;2.6V and a low signal is &amp;lt;2.2V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does this mean for the grey area? Would my inputs be glitching randomly? Would they maintain high, until below 2.2V and maintain low until above 2.6V? Or can the switching point be any where between that (and is it different per chip or pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT: I've checked, my voltage divider circuit has 0.6V for &quot;nothing&quot; and 3V for &quot;interrupted&quot;, so it should work neverthless. Though, I'm still interested in how the grey threshold area behaves.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="7856" LastEditDate="2016-04-24T08:43:17.947" LastActivityDate="2016-04-24T08:57:08.017" Title="Digital input pin voltage treshold (voltage to register 1 or 0)" Tags="|arduino-nano|input|analog-sampling|digital-in|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23516" PostTypeId="2" ParentId="23515" CreationDate="2016-04-24T08:57:08.017" Score="1" Body="&lt;p&gt;The titles of the graphs are actually saying what happens: the hysteresis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;if the input level is high (greater than 2.6V), it will be considered high through the hysteresis area (until it goes below 2.2V)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;if the input level is low (below 2.2V), it will be considered low through the hysteresis area (until it goes above 2.6V)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;According to the description you gave, this should work for your case.&#xA;In case it doesn't, you have to condition it until the values you want to consider 0 and 1 are respectively below 2.2V and above 2.6V, with a safety margin, for good measure (say 30%).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hysteresis is meant to prevent noise from causing unwanted spurious transitions: without safety margin, it should be greater than 0.4V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can dimension the safety margin to meet your needs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, for the sake of completeness, I'll say that it might be preferable to have a timer to trigger periodic sampling with the ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know the maximum frequency at which every input can vary, you can sample it at twice that frequency and be sure that you will not miss anything. Again, this is theory, I would probably make it 4 times, to allow for unforeseen variations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This works as long as the conversion time of the ADC is shorter than the maximum combined frequency at which you need to read the values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GPIOs, of course, are faster, but might require additional circuitry for the conditioning I mentioned earlier.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-24T08:57:08.017" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23517" PostTypeId="2" ParentId="23485" CreationDate="2016-04-24T09:07:42.953" Score="0" Body="&lt;p&gt;To use USB communication (such as mouse or keyboard) you must have a arduino that uses an ATMEGA32U4. These are so far, the only boards that can work as a USB device. &lt;/p&gt;&#xA;" OwnerUserId="20473" LastActivityDate="2016-04-24T09:07:42.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23518" PostTypeId="2" ParentId="23510" CreationDate="2016-04-24T09:48:02.953" Score="0" Body="&lt;p&gt;Since you are being returned JSON, you can use the jsoncpp library found &lt;a href=&quot;https://github.com/open-source-parsers/jsoncpp&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;&#xA;To split your return to an array. Then you simply retrieve whatever item you want using array index notation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is another helpful post on creating arrays of strings in C++ from JSON.&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/14082643/parsing-json-arrays-in-c&quot;&gt;C++ and JSON&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-04-24T10:20:48.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23519" PostTypeId="1" AcceptedAnswerId="23520" CreationDate="2016-04-24T09:48:37.547" Score="2" ViewCount="2807" Body="&lt;p&gt;Why does this code not function in a similar way to the example fade sketch?&#xA;I have had to resort to using bit-banging as a way to implement PWM onto non PWM pins due to  a lack of available free pins on my Arduino Pro Mini. I am using a sketch that supposedly should fade an LED ranging from maximum brightness to minimum brightness. My code however does not work. Can anyone figure out why my code does not operate in the same way the fade sketch does?&lt;/p&gt;&#xA;&lt;p&gt;My current code is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int brightness = 0;&#xA;int fadeAmount = 50;  &#xA;void setup()&#xA;{&#xA;  pinMode(12, OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  brightness = brightness + fadeAmount;&#xA;  if (brightness == 0 || brightness == 255) {&#xA;    fadeAmount = -fadeAmount ;&#xA;  }&#xA;  digitalWrite(13, HIGH);&#xA;  delayMicroseconds(brightness); // Approximately 10% duty cycle @ 1KHz&#xA;  digitalWrite(13, LOW);&#xA;  delayMicroseconds(1000 - 100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And I want it to work in the same way as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;int led = 9;&#xA;int brightness = 0;&#xA;int fadeAmount = 5;&#xA;void setup() {&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;void loop() {&#xA;  analogWrite(led, brightness);&#xA;  brightness = brightness + fadeAmount;&#xA;  if (brightness == 0 || brightness == 255) {&#xA;    fadeAmount = -fadeAmount ;&#xA;  }&#xA;  delay(30);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If possible could anyone provide a correct version to help me with my project.&lt;/p&gt;&#xA;" OwnerUserId="20473" LastEditorUserId="31242" LastEditorDisplayName="user31481" LastEditDate="2021-04-21T13:59:51.637" LastActivityDate="2021-04-21T13:59:51.637" Title="PWM on non PWM pins" Tags="|pwm|arduino-pro-mini|digital|digital-analog-conversion|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23520" PostTypeId="2" ParentId="23519" CreationDate="2016-04-24T09:58:52.143" Score="1" Body="&lt;p&gt;You seem to have a typo on the pin number: you are configuring pin 12 and driving pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words: &lt;code&gt;pinMode(12, OUTPUT);&lt;/code&gt; and &lt;code&gt;digitalWrite(13, HIGH);&lt;/code&gt; do not match.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-24T09:58:52.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23521" PostTypeId="2" ParentId="23519" CreationDate="2016-04-24T10:16:13.303" Score="1" Body="&lt;p&gt;Your code here is not quite right:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(13, HIGH);&#xA;delayMicroseconds(brightness);&#xA;digitalWrite(13, LOW);&#xA;delayMicroseconds(1000 - 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Your two delays should add up to the total period (wavelength), or the reciprocal of the frequency (scaled to microseconds).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence the &lt;code&gt;- 100&lt;/code&gt; in the second delay - that is subtracting the &quot;on&quot; time from the total time to give the &quot;off&quot; time.   It should be replaced with &lt;code&gt;- brightness&lt;/code&gt; as such:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(13, HIGH);&#xA;delayMicroseconds(brightness);&#xA;digitalWrite(13, LOW);&#xA;delayMicroseconds(1000 - brightness);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And of course the brightness is in the range 0 - 1000 not 0 - 255 like &lt;code&gt;analogWrite()&lt;/code&gt;.  To make it 0-255 you should replace the 1000 with 255, which of course makes it all run at a much higher frequency. (1 / 0.000255 = 3922Hz).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(13, HIGH);&#xA;delayMicroseconds(brightness);&#xA;digitalWrite(13, LOW);&#xA;delayMicroseconds(255 - brightness);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Mind you, all this is not good regardless of your calculations. This is a &lt;em&gt;blocking&lt;/em&gt; system in which you are unable to do anything else at all in your program whilst generating PWM.  Instead you should be using a timer (like the &lt;code&gt;tone()&lt;/code&gt; command does) and switch between two different time periods each interrupt for &quot;on&quot; and &quot;off&quot; time periods. That way it can function asynchronously (&quot;in the background&quot;) like &lt;code&gt;analogWrite()&lt;/code&gt; does.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-24T10:16:13.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23522" PostTypeId="2" ParentId="23514" CreationDate="2016-04-24T10:24:59.990" Score="1" Body="&lt;p&gt;The rule is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One Timer, One Interrupt.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When the timer overflows it triggers its interrupt. It only has one. That interrupt then runs your ISR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using a library to provide abstraction from the timer registers then it is down to that library how it calls your ISR. It is possible for one to provide a mechanism whereby you can &quot;attach&quot; multiple routines to the same interrupt, but that is quite a lot of work and overhead for a simple timer library to provide, so it is highly unlikely anyone would ever bother.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how do you do multiple sensor measurements from one timer? Simple: just do multiple sensor measurements. You don't have to restrict yourself to just reading one sensor within your interrupt - you can read as many as you like. There is just a couple of caveats though:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The whole ISR must take less that 10ms to run or it will overrun the timer overflow period.&lt;/li&gt;&#xA;&lt;li&gt;You cannot do serial from inside an interrupt&lt;sup&gt;*&lt;/sup&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So in your interrupt you read the sensors and add their values to a buffer. Then in your main loop you read that buffer to send the data out through serial. You may want to set a flag in your interrupt routine to alert the main loop that there is data available, or implement a circular buffer which has an equivalent of a &lt;code&gt;.available()&lt;/code&gt; function to see if there is any data to read from it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;*You can place data in the serial TX buffer but it will not be transmitted out of the TX buffer until after the interrupt routine has finished. If you put too much data in that TX buffer it will block indefinitely waiting for it to empty.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-24T10:24:59.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23523" PostTypeId="1" CreationDate="2016-04-24T14:12:45.097" Score="2" ViewCount="2284" Body="&lt;p&gt;I was wondering if it's possible to send data from my Arduino Uno (e.g. from the temperature sensor) to the Amazon Web Service RDS or anything there, which will then upload the data to a website on my localhost?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If yes, could someone give me guidance please?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been messing with this for a few weeks now, but I am just getting lost with linking it all up together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="20089" LastEditorUserId="4628" LastEditDate="2017-05-27T07:04:34.067" LastActivityDate="2018-10-20T17:49:34.873" Title="Is it possible to use AWS and Arduino Uno to upload data from Arduino to a website running on my localhost?" Tags="|arduino-uno|web-server|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23524" PostTypeId="2" ParentId="23523" CreationDate="2016-04-24T14:31:07.253" Score="2" Body="&lt;p&gt;No, it is not (easily) possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AWS has no access to your localhost - you are (most likely) behind a NAT router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could &lt;em&gt;possibly&lt;/em&gt; open up port forwarding on your router and then ensure that AWS knows always what the IP address of your router is so it can connect (using some dynamic DNS service maybe).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, that is not secure, and dynamic IP address assignments makes it a real pain. It opens up your computer to hacking from the internet.  A more secure method is to use AWS as the &quot;central point&quot; and have your computer go and fetch data from there rather than having it send data to your computer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-24T14:31:07.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23525" PostTypeId="1" CreationDate="2016-04-24T15:00:12.517" Score="0" ViewCount="1037" Body="&lt;p&gt;I made this exact build on my Arduino, with the following differences:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm using Arduino Nano&lt;/li&gt;&#xA;&lt;li&gt;Transistors I use are 2N2222A&lt;/li&gt;&#xA;&lt;li&gt;I'm running everything on 12V except Arduino, I use LM317 to feed Arduino 6v&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's the build:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tbtwl.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tbtwl.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what happened. First, it started to get strange voltage, arduino would light up even when disconnected from power. After that, Arduino kind of got fried, when I connect it to USB, nothing happens. I can give it 6v to VIN and ground it with the rest, but turning potentiometers only dims the onboard LED of the Arduino and that's it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I'm going to go and pick up a new nano, however, I'd prefer not to fry that one, so figuring out why this one burned would be nice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. The image shows RGB LED instead of RGB LED Strip because 123d doesn't have strip component. &lt;/p&gt;&#xA;" OwnerUserId="18902" LastActivityDate="2016-12-22T06:27:51.203" Title="RGB Led strip pot control burned my arduino?" Tags="|arduino-nano|rgb-led|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="23526" PostTypeId="1" CreationDate="2016-04-24T15:02:32.150" Score="1" ViewCount="4175" Body="&lt;p&gt;When I power my ATmega328P chip from 5.16V and 3.3V, there doesn't seem to be a single bandgap voltage compensation figure that works for both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the following sketch, and I need the following &lt;code&gt;InternalReferenceVoltage&lt;/code&gt; values to read the correct voltage from &lt;code&gt;A0&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;1255L&lt;/code&gt; to correctly output 5.16V.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;1358L&lt;/code&gt; to correctly output 3.3V.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a couple of questions:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Should I be able to use a single &lt;code&gt;InternalReferenceVoltage&lt;/code&gt; compensation value whe powering the ATmega328P from different voltages?&lt;/li&gt;&#xA;&lt;li&gt;Aren't both of these values outside the specced 1.0 to 1.2 range?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The code is from, &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=56750.msg407897#msg407897&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=56750.msg407897#msg407897&lt;/a&gt;, retolefty post @ Mar 28, 2011, 02:27 pm.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  delay(5000);&#xA;&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  // Determines what actual Vcc is, (X 100), based on known bandgap voltage&#xA;  int battVolts = readVcc1();&#xA;&#xA;  Serial.print(&quot;Battery Vcc volts =  &quot;);&#xA;  Serial.println(battVolts);&#xA;  Serial.print(&quot;Analog pin 0 voltage = &quot;);&#xA;  Serial.println(map(analogRead(0), 0, 1023, 0, battVolts));&#xA;  Serial.println();&#xA;&#xA;  delay(1000);&#xA;}&#xA;&#xA;// Returns actual value of Vcc (x 100)&#xA;int readVcc1()&#xA;{&#xA;  uint8_t oldADMUX = ADMUX;&#xA;&#xA;  const long InternalReferenceVoltage = 1255L; // Adjust this value to your boards specific internal BG voltage x1000&#xA;&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  // For mega boards&#xA;  // REFS1 REFS0          --&amp;gt; 0 1, AVcc internal ref. -Selects AVcc reference&#xA;  // MUX4 MUX3 MUX2 MUX1 MUX0  --&amp;gt; 11110 1.1V (VBG)         -Selects channel 30, bandgap voltage, to measure&#xA;  ADMUX = (0 &amp;lt;&amp;lt; REFS1) | (1 &amp;lt;&amp;lt; REFS0) | (0 &amp;lt;&amp;lt; ADLAR) | (0 &amp;lt;&amp;lt; MUX5) | (1 &amp;lt;&amp;lt; MUX4) | (1 &amp;lt;&amp;lt; MUX3) | (1 &amp;lt;&amp;lt; MUX2) | (1 &amp;lt;&amp;lt; MUX1) | (0 &amp;lt;&amp;lt; MUX0);&#xA;&#xA;#else&#xA;  // For 168/328 boards&#xA;  // REFS1 REFS0          --&amp;gt; 0 1, AVcc internal ref. -Selects AVcc external reference&#xA;  // MUX3 MUX2 MUX1 MUX0  --&amp;gt; 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure&#xA;  ADMUX = (0 &amp;lt;&amp;lt; REFS1) | (1 &amp;lt;&amp;lt; REFS0) | (0 &amp;lt;&amp;lt; ADLAR) | (1 &amp;lt;&amp;lt; MUX3) | (1 &amp;lt;&amp;lt; MUX2) | (1 &amp;lt;&amp;lt; MUX1) | (0 &amp;lt;&amp;lt; MUX0);&#xA;&#xA;#endif&#xA;  delay(50); // Let mux settle a little to get a more stable A/D conversion&#xA;  // Start a conversion&#xA;  ADCSRA |= _BV(ADSC);&#xA;  // Wait for it to complete&#xA;  while (((ADCSRA &amp;amp; (1 &amp;lt;&amp;lt; ADSC)) != 0));&#xA;&#xA;  // Scale the value&#xA;  int results = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; // calculates for straight line value&#xA;&#xA;  ADMUX = oldADMUX;&#xA;&#xA;  return results;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have read these other references to try and find a solution:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/16352/measure-vcc-using-1-1v-bandgap&quot;&gt;Measure Vcc using 1.1V bandgap&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/making-accurate-adc-readings-on-the-arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://hackingmajenkoblog.wordpress.com/2016/02/01/making-accurate-adc-readings-on-the-arduino/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19579" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-04-25T05:30:03.693" Title="Measure different Vcc using 1.1V bandgap" Tags="|atmega328|voltage-level|adc|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23528" PostTypeId="1" CreationDate="2016-04-24T15:54:06.523" Score="3" ViewCount="528" Body="&lt;p&gt;I am using Arduino Uno for measuring sensor voltages. I am using multiplexer to switch between different sensors. The readings measured in the range of 800-900 mv are accurate, but at low millivolts (at about 20 mv) they are erratic. I read repeatedly to get average of 20 values. I get values such as 1.3, 1,4, 2,0, 3.8 etc. &#xA;Can any one help on why it is happening and how to avoid it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional information: I am using reference voltage of 1.25 volt for better resolution. &#xA;I tried having delay between two readings, though there is some improvement, still the problem persists. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate the help by experts. &#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="20495" LastEditorUserId="35247" LastEditDate="2017-12-08T13:08:42.750" LastActivityDate="2018-02-06T18:49:07.477" Title="Erratic readings on Analogread with low voltages" Tags="|arduino-uno|sensors|voltage-level|analogread|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23530" PostTypeId="1" AcceptedAnswerId="23905" CreationDate="2016-04-24T22:35:56.920" Score="3" ViewCount="8721" Body="&lt;p&gt;This (maybe stupid) question is bothering me for a long time...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the pin 0 has to be connected to the ground for uploading a sketch into ESP8266, and after the uploading the chip automatically starts the uploaded sketch (without waiting for reboot with pin 0 to be disconnected), then won't it destroy the chip if I do digitalWrite(0, HIGH) in my sketch? Correct me if I'm wrong, but it should short 3.3V directly to the ground through this pin... Is this problem secured somehow? Or maybe this pin can be safely used for reading only?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have seen it connected to ground directly on every schematic about ESP8266, but maybe I should just use a pull-down resistor? Or maybe the chip already has a resistor before this pin to solve this problem?&lt;/p&gt;&#xA;" OwnerUserId="18748" LastEditorUserId="18748" LastEditDate="2016-04-24T22:48:41.200" LastActivityDate="2018-06-29T01:47:25.453" Title="ESP8266: Is it safe to use pin 0?" Tags="|pins|esp8266|safety|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23531" PostTypeId="1" CreationDate="2016-04-25T00:15:27.507" Score="0" ViewCount="1532" Body="&lt;p&gt;I am trying the esp8266 esp-01, and did all it asked on the arduino IDE side, but i am having problems compiling and building the blink example into the board&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using: FT232RL usb-ttl in the 3.3v configuration, two 1.6v (new) batteries to power the esp, and all the conections as indicated here (not using the led though).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;when I hit (go) it compiles, but as it transfers both boards blink sincronously and I recive the following errors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;O sketch usa 219.479 bytes (50%) de espaço de armazenamento para programas. O máximo são 434.160 bytes. Variáveis globais usam 31.172 bytes (38%) de memória dinâmica, deixando 50.748 bytes para variáveis locais. O máximo são 81.920 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data error: failed reading byte warning: espcomm_send_command: cant receive slip payload data warning: espcomm_sync failed error: espcomm_open failed error: espcomm_upload_mem failed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looks to me as a newbie that its trying to establish a link and failing... what could it be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the configurations are default, programmer is &quot;AVRISP MKII&quot;&lt;/p&gt;&#xA;" OwnerUserId="20506" LastActivityDate="2016-04-25T09:06:30.217" Title="ESP8266 blink not building to esp-01" Tags="|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23533" PostTypeId="1" AcceptedAnswerId="23534" CreationDate="2016-04-25T04:48:19.603" Score="0" ViewCount="42" Body="&lt;p&gt;im working on the following project &lt;a href=&quot;https://github.com/har-in-air/Kalmanfilter_altimeter_vario&quot; rel=&quot;nofollow&quot;&gt;kalman filter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and im working to implement in arduino.. i read the entire code and i succesfully implemented it into arduino but i couldnt implement the following function &lt;a href=&quot;https://github.com/har-in-air/Kalmanfilter_altimeter_vario/blob/master/Usage.txt#L28&quot; rel=&quot;nofollow&quot;&gt;code line&lt;/a&gt; because arduino gives &quot;not defined&quot; error in &lt;strong&gt;PI_DIV_180&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;imu_MadgwickQuaternionUpdate(bUseAccel,elapsedTimeSecs,fax,fay,faz,fgx*PI_DIV_180,fgy*PI_DIV_180,fgz*PI_DIV_180,fmx,fmy,fmz);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it multiplies &lt;code&gt;fgx&lt;/code&gt; with &lt;strong&gt;PI_DIV_180&lt;/strong&gt; but as i said arduino cant identify it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i looked into math.h to find the value of that define but there isnt anything in math.h related with this&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the &lt;code&gt;imu_MadgwickQuaternionUpdate&lt;/code&gt; function is in here &lt;strong&gt;IMU.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can anyone help me please thanx..&lt;/p&gt;&#xA;" OwnerUserId="20208" LastActivityDate="2016-04-25T05:05:28.267" Title="Unidentified constant value" Tags="|arduino-uno|compile|mathematics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23534" PostTypeId="2" ParentId="23533" CreationDate="2016-04-25T05:05:28.267" Score="1" Body="&lt;p&gt;Maybe it's pi (π) divided by 180?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pi is roughly: 3.1415926535898&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3.1415926535898 / 180 = 0.017453292519943&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So add this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define PI_DIV_180 0.017453292519943&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-25T05:05:28.267" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23535" PostTypeId="2" ParentId="23526" CreationDate="2016-04-25T05:30:03.693" Score="1" Body="&lt;p&gt;The internal reference won't change much. That's why it's a reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running this code on my Atmega328P:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  ADMUX = bit (REFS0) | bit (REFS1);  // Internal 1.1V reference&#xA;}&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That outputs the reference voltage on Aref. I measured it as follows with different values for Vcc:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Vcc     Aref&#xA;------------&#xA;5.00   1.085&#xA;4.00   1.081&#xA;3.30   1.080&#xA;3.00   1.079&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can see that it retains, more or less, the same voltage regardless of Vcc. In any case, there is no way of measuring Aref, unless you have &lt;em&gt;another&lt;/em&gt; reference voltage around to compare it to.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-25T05:30:03.693" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23536" PostTypeId="2" ParentId="23531" CreationDate="2016-04-25T09:06:30.217" Score="1" Body="&lt;p&gt;You did not put ESP8266 into programing mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;the easiest way to do so is to make your own programing board, something like &lt;a href=&quot;http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/&quot; rel=&quot;nofollow&quot;&gt;shown here&lt;/a&gt;. Go down to middle of the document to title &quot;Writing a program to the ESP8266&quot; where you will see a schematic of simple programing board. You will need two switches and a 10k resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage regulator can be omitted if you are powering it by 3.3v power. Also its a good idea to put a small capacitor (100uf) between vcc and ground to stabilize any drops in voltage which is primary cause of esp8266 rebooting it self. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-04-25T09:06:30.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23537" PostTypeId="2" ParentId="23530" CreationDate="2016-04-25T09:22:44.310" Score="2" Body="&lt;p&gt;What do you consider pin 0?&#xA;As I look at the schematics it could either be GND, VCC, RX or TX pin. Or do you mean GPIO0? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;GPIO0 when connected to GND and in combination with RST to GND will put ESP into programing mode. &#xA;Good practice is to have separate programing board, something like &lt;a href=&quot;http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/&quot; rel=&quot;nofollow&quot;&gt;This here&lt;/a&gt;. Go down to &quot;Writing a program to the ESP8266&quot; section and check out the schematic. Voltage regulator can be omitted if you are already powering it with 3.3v.&lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-04-25T09:22:44.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23538" PostTypeId="1" CreationDate="2016-04-25T10:42:03.493" Score="3" ViewCount="227" Body="&lt;p&gt;I'm doing some tests and I notice a bad things with digitals pins. I have a wire that sends 1 signals. If i connect it to a reading pin, I read 1 - and it's ok. But if i disconnect it, for 5-6 seconds Arduino continues to read 1 instead of 0! How can I stabilize it more quickly?&lt;/p&gt;&#xA;" OwnerUserId="20034" LastActivityDate="2016-04-26T11:19:07.110" Title="UNO's digital pin continue to read 1 for a while" Tags="|digital|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23539" PostTypeId="2" ParentId="23538" CreationDate="2016-04-25T11:31:01.717" Score="5" Body="&lt;p&gt;Digital inputs should either be low or high. In this image acceptable input voltages on the left represent common TTL voltages based on a 0 to 5 volt range:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/KWFKX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KWFKX.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is bad practice to leave a digital input floating.  A floating or disconnected input implies the voltage is unknown.  I suspect in your case a small amount of input capacitance held a charge for several seconds.  Once leaked off the input appeared to change from 1 to 0.  Even though you know what might be happening, you should not depend on it as it is unreliable behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If connecting a SPST switch use a pull up (or pull down) resistor to pull the input pin to the opposite voltage the switch is pulling.  In this image the switch is connected to ground so the resistor is connected to positive voltage as a pull up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CPRWs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CPRWs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fist image comes from &lt;a href=&quot;https://learn.sparkfun.com/tutorials/logic-levels&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; Logic Level tutorial.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-25T11:50:24.297" LastActivityDate="2016-04-25T11:50:24.297" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23540" PostTypeId="1" AcceptedAnswerId="23543" CreationDate="2016-04-25T12:08:14.690" Score="1" ViewCount="2260" Body="&lt;p&gt;I have created a car that can detect obstacle and change its direction, but now I want to add a bluetooth module to control it and I want to switch between the two circuits using a three state switch (ON-OFF-ON), so how can I do that and how can I upload two different codes on the arduino.&#xA;Here is a fritzing diagram, (the pins for the bluetooth will be changed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sensor:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/R9uRs.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/R9uRs.jpg&quot; alt=&quot;Breadboard diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bluetooth:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5ZAHI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5ZAHI.jpg&quot; alt=&quot;Breadboard diagram w/ Bluetooth&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the code for the sensor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   #define echopin  8 // echo pin&#xA;   #define trigpin 9 // Trigger pin&#xA;&#xA;   int maximumRange = 30;&#xA;   long duration, distance;&#xA;&#xA;    void setup() {&#xA;        Serial.begin (9600);&#xA;        pinMode (trigpin, OUTPUT);&#xA;        pinMode (echopin, INPUT );&#xA;        pinMode (4, OUTPUT);&#xA;        pinMode (5, OUTPUT);&#xA;        pinMode (13, OUTPUT);&#xA;        pinMode (6, OUTPUT);&#xA;        pinMode (7, OUTPUT);&#xA;    }&#xA;&#xA;    void loop ()&#xA;    {&#xA;        digitalWrite(trigpin,LOW);&#xA;        delayMicroseconds(2);&#xA;&#xA;        digitalWrite(trigpin,HIGH);&#xA;        delayMicroseconds(10);&#xA;&#xA;        duration=pulseIn (echopin,HIGH);&#xA;&#xA;        distance= duration/58.2;&#xA;        delay (50);&#xA;        Serial.println(distance);&#xA;    }&#xA;&#xA;        if (distance &amp;gt;= 30 ){&#xA;            digitalWrite(4,HIGH);&#xA;            digitalWrite(5,HIGH);&#xA;            digitalWrite(6,LOW);&#xA;            digitalWrite(7,LOW);&#xA;            delay (200);&#xA;        }  &#xA;        else if (distance &amp;gt;=15 &amp;amp;&amp;amp; distance &amp;lt;= 25) {&#xA;            digitalWrite (4,HIGH);&#xA;            digitalWrite (5,LOW);&#xA;            digitalWrite (6,LOW);&#xA;            digitalWrite (7,LOW);&#xA;            delay (1000);&#xA;        }&#xA;        else if (distance &amp;lt; 15){&#xA;            digitalWrite (4, LOW);&#xA;            digitalWrite (5, LOW);&#xA;            digitalWrite (6,HIGH);&#xA;            digitalWrite (7,HIGH);&#xA;            delay (1000);&#xA;            digitalWrite (4,LOW);&#xA;            digitalWrite (5,HIGH);&#xA;            digitalWrite (6,LOW);&#xA;            digitalWrite (7, LOW);&#xA;            delay (1000);       &#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please write in the most details and write any code as I am still a beginner.&lt;/p&gt;&#xA;" OwnerUserId="20517" LastEditorUserId="19667" LastEditDate="2016-04-26T07:10:57.647" LastActivityDate="2016-04-26T07:10:57.647" Title="How to connect a a three state switch (ON-OFF-ON) to arduino?" Tags="|arduino-uno|programming|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23541" PostTypeId="2" ParentId="23540" CreationDate="2016-04-25T13:02:07.257" Score="0" Body="&lt;p&gt;While a simple concept, having 2 different selectable programs (sketches) in 1 Arduino is not the way the Arduino paradigm works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most Arduinos contain an Atmel processor.  This processor contains a boot loader program.  This program only knows how to deal with 1 other program (the sketch).  In order to switch between 2 different programs (sketches) you would have to re-write this boot loader.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you still have to deal with the creation of the 2nd program.  In order to do this you need to change the SDK used to create the 2nd program (sketch).  Specifically, you need to link the 2nd program (sketch) so that it can operate out of a different location in the Atmel processor's memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be far easier to combine the two programs (sketches) into a single program (sketch).  Then use your switch to change the program's (sketch's) behavior.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-04-25T13:02:07.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23542" PostTypeId="1" AcceptedAnswerId="23547" CreationDate="2016-04-25T13:03:34.707" Score="0" ViewCount="790" Body="&lt;p&gt;I'm trying to create a Tic Tac Toe game using the Arduino Uno. Since the Uno has a limited amount of pins to use, I am trying to see if there is a configuration that would make the project possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the button detection circuit I am using a simple voltage divider and an analog pin. I made the following in a circuit simulator:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/r0dGF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/r0dGF.png&quot; alt=&quot;Switch Input Detection Circuit (Voltage Divider)&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for the LEDs, since the Uno only hosts 9 pins, and we need 18, we need some sort of wizardry to get something working. I came up with the following design using the circuit simulator:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n6B7g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n6B7g.png&quot; alt=&quot;Controlling Two LEDs using One Pin&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would use 9 of these, one connected per Arduino pin. Since only one of the LEDs in each of the 9 sets should be on, this type of circuit should allow the Arduino to control all of the 18 LEDs. In the simulation I get about 5mA draw from each side (with 5v and GND).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However my problem is that the LED setup doesn't work. The lights are extremely dim. At first I simply thought that 5mA was not enough for the LED. I decided to measure the current going through the LED and found that it was about 0.8mA. What happened to my 5mA calculation? After all, isn't Arduino pin able to handle about 40mA? Am I asking for too much current?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where have I gone wrong with this? Thanks in advance for any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;tommis15&lt;/p&gt;&#xA;" OwnerUserId="20518" LastActivityDate="2016-04-25T14:22:04.323" Title="Creating an Arduino Tic Tac Toe game" Tags="|arduino-uno|led|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23543" PostTypeId="2" ParentId="23540" CreationDate="2016-04-25T13:10:56.893" Score="1" Body="&lt;p&gt;As stated by st2000, it's not common practice to have two separate programs running on one microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is simple, use the switch to &quot;switch between&quot; behavior.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(switch is on){&#xA;  //Automatic&#xA;}else{&#xA;  //Bluetooth&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;You should also use functions, to make your code more readable.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define echopin  8 // echo pin&#xA;#define trigpin 9 // Trigger pin&#xA;#define switchPin 10&#xA;&#xA;int maximumRange = 30;&#xA;long duration, distance;&#xA;&#xA;void setup() {&#xA;  Serial.begin (9600);&#xA;  pinMode (trigpin, OUTPUT);&#xA;  pinMode (echopin, INPUT );&#xA;  pinMode (4, OUTPUT);&#xA;  pinMode (5, OUTPUT);&#xA;  pinMode (13, OUTPUT);&#xA;  pinMode (6, OUTPUT);&#xA;  pinMode (7, OUTPUT);&#xA;&#xA;  pinMode(switchPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop ()&#xA;{&#xA;  if (digitalRead(switchPin)) { //If the switch is pressed.&#xA;    automaticLoop();          //Do the automatic control.&#xA;  } else {                   //If not pressed.&#xA;    bluetoothLoop();          //Do the bluetooth control.&#xA;  }&#xA;}&#xA;&#xA;void measureDistance() {&#xA;  digitalWrite(trigpin, LOW);&#xA;  delayMicroseconds(2);&#xA;&#xA;  digitalWrite(trigpin, HIGH);&#xA;  delayMicroseconds(10);&#xA;&#xA;  duration = pulseIn (echopin, HIGH);&#xA;&#xA;  distance = duration / 58.2;&#xA;  delay (50);&#xA;  Serial.print(&quot;Distance is: &quot;);&#xA;  Serial.println(distance);&#xA;}&#xA;&#xA;void automaticLoop() {&#xA;  measureDistance();&#xA;&#xA;  if (distance &amp;gt;= 30 ) {&#xA;    digitalWrite(4, HIGH);&#xA;    digitalWrite(5, HIGH);&#xA;    digitalWrite(6, LOW);&#xA;    digitalWrite(7, LOW);&#xA;    delay (200);&#xA;  }&#xA;&#xA;  else if (distance &amp;gt;= 15 &amp;amp;&amp;amp; distance &amp;lt;= 25) {&#xA;    digitalWrite (4, HIGH);&#xA;    digitalWrite (5, LOW);&#xA;    digitalWrite (6, LOW);&#xA;    digitalWrite (7, LOW);&#xA;    delay (1000);&#xA;  }&#xA;  else if (distance &amp;lt; 15) {&#xA;    digitalWrite (4, LOW);&#xA;    digitalWrite (5, LOW);&#xA;    digitalWrite (6, HIGH);&#xA;    digitalWrite (7, HIGH);&#xA;    delay (1000);&#xA;    digitalWrite (4, LOW);&#xA;    digitalWrite (5, HIGH);&#xA;    digitalWrite (6, LOW);&#xA;    digitalWrite (7, LOW);&#xA;    delay (1000);&#xA;  }&#xA;}&#xA;&#xA;void bluetoothLoop() {&#xA;  //Code for bluetooth.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-25T13:45:01.417" LastActivityDate="2016-04-25T13:45:01.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23544" PostTypeId="2" ParentId="23540" CreationDate="2016-04-25T13:24:00.410" Score="0" Body="&lt;p&gt;I'm trying to give you some more general advice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to combine two Arduino sketches into one&lt;/strong&gt;&#xA;There is no general rule, how to do this. But there are some common problems to solve.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Code has to be merged for setup and loop independently&lt;/li&gt;&#xA;&lt;li&gt;You can have only one setup() and one loop() when finished.&lt;/li&gt;&#xA;&lt;li&gt;If there are variables with same names in both sketches, you have to rename those in one of them.&lt;/li&gt;&#xA;&lt;li&gt;If you operate with delays, be aware, that delays sum up and retard processing of your loop accordingly.&lt;/li&gt;&#xA;&lt;li&gt;Having your code merged in most cases you need additional variables to transfer information from one code part to another.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;How to use two different hardware setups with one Arduino&lt;/strong&gt;&#xA;There are some general rules, too:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Except for some meticulously and intricately designed electronics, you can use each port only once. You have to move hardware to another port if they are conflicting. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you run out of ports, you may have to use port expanders or some logic circuitry to gain more inputs and outputs&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Check if your hardware does not overload your arduino power supply. some shields and modules can easily suck up the available power.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4358" LastActivityDate="2016-04-25T13:24:00.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23545" PostTypeId="2" ParentId="23542" CreationDate="2016-04-25T13:29:28.707" Score="0" Body="&lt;p&gt;You should really provide more info:&#xA;- your program&#xA;- what exactly you are trying to achieve (you seem to be driving two leds per 'board position'. What do they represent?) and schematics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would also help if you measured the voltage level at the pin in both the ON and OFF state and mentioned it here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, one thing that should be noted (hopefully before it is too late) is that your 40mA/pin assumption is wrong. First of all, 40mA is the absolute maximum rating for one pin (i.e. the value you should stay clear of). Secondly, although one isolated pin can source or sink close to 40mA, the total of all GPIO pins should stay below 200 mA. See also &lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&lt;/a&gt; .&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-04-25T13:29:28.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23546" PostTypeId="2" ParentId="23525" CreationDate="2016-04-25T13:51:25.797" Score="1" Body="&lt;p&gt;First, as Majenko said, you need resistors between the arduino output pins and the transistor bases. Start at something like 330 Ohm.&#xA;Second, what is the value of the potentiometers? If it is too low you would be drawing too much current from the 5V pin to the ground.&#xA;Third, you should power the arduino with at least 7V, assuming you power it through the Vin pin or the power jack. 6V is considered too low.&#xA;I assume the pins connected to the potentiometers are initialised as inputs. Otherwise, it would be possible to burn your arduino by having them source/sink too much current (i.e. by turning the potentiometers to one end or the other).&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-04-25T13:51:25.797" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23547" PostTypeId="2" ParentId="23542" CreationDate="2016-04-25T14:22:04.323" Score="1" Body="&lt;p&gt;I was working with it more and I found that my mistake was that I was using pin 0 and 1 to test (serial) and switching to pin 2 and above works.&lt;/p&gt;&#xA;" OwnerUserId="20518" LastActivityDate="2016-04-25T14:22:04.323" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23548" PostTypeId="2" ParentId="16514" CreationDate="2016-04-25T15:21:55.680" Score="0" Body="&lt;p&gt;If you want a simplest solution, &lt;strong&gt;you can just connect your 5V pin of Arduino to the 3.3V external power supply&lt;/strong&gt;. It will work just fine on 3.3V and all of its GPIO pins will be 3.3V too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; You must be careful because if you plug your Arduino to the USB wire, you will instantly get the 5V on all the pins, so you will burn your ESP. So you will have to disconnect ESP during programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The easiest (and safe) way for me in this scenario is to just use a standalone ATMEGA328P-PU chip on a breadboard and connect it manually. You just have to plug in 4 capacitors, a 16M oscillator and a resistor and upload sketch using a programmer (like USBasp) and &quot;Upload using a programmer&quot; button. You can then safely run everything on 3.3V because the programmer has a jumper and can work on 3.3V too and you don't have to use ANY level shifters and or voltage dividers. In my case they were not even working (I don't know why). You connect such &quot;environment&quot; once on a breadboard and you can safely work with it later. Let me know if you need more info on this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; If you work with SPI bus (MISO, MOSI, SCK), like an SD card reader for example, then you must secure the SPI lines of the device (card reader) with resistors, because you may also burn your chip if 2 opposite signals are directed to the same line by 2 separate devices. I've burned my 328P like this once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Don't use a programmer for supplying power to your circuit. It can work for programming, but when your ESP starts connecting to WiFi it will require much more power than the programmer can provide! In best scenario it will just not work and hang up or reset.&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-04-25T15:21:55.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23549" PostTypeId="2" ParentId="22267" CreationDate="2016-04-25T15:23:38.263" Score="0" Body="&lt;p&gt;I managed to finish my project and here is the code &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Useful information:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To prevent reset on serial port open and close&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://tushev.org/articles/arduino/22&quot; rel=&quot;nofollow&quot;&gt;https://tushev.org/articles/arduino/22&lt;/a&gt; /* Add a 10-100 μF capacitor between reset and GND&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; JAVA&#xA;&#xA; /* FIRST IMPORT JSSC LIBRARY */&#xA;&#xA;package arduino;&#xA;&#xA;import java.util.Scanner;&#xA;import jssc.SerialPort;&#xA;import jssc.SerialPortException;&#xA;&#xA;public class Arduino {&#xA;&#xA;public static void main(String[] args) throws InterruptedException,     SerialPortException {&#xA;&#xA;    Scanner scan = new Scanner(System.in);&#xA;    int nummer = 0;&#xA; SerialPort serialPort = new SerialPort(&quot;COM4&quot;);&#xA;&#xA;&#xA;        while (true) {&#xA;            menu();&#xA;             if (scan.hasNextInt()) {&#xA;            nummer = scan.nextInt();&#xA;        } else {&#xA;            System.out.println(&quot;verkeerde ingave&quot;);&#xA;        }&#xA;        switch (nummer) {&#xA;            case 0:&#xA;                serialPort.openPort();//Open serial port&#xA;        Thread.sleep(1000);&#xA;        serialPort.setParams(SerialPort.BAUDRATE_9600, &#xA;                             SerialPort.DATABITS_8,&#xA;                             SerialPort.STOPBITS_1,&#xA;                             SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0);&#xA;&#xA;         serialPort.writeBytes(&quot;a&quot;.getBytes());//Write data to port&#xA;           serialPort.closePort();//Close serial port&#xA;                break;&#xA;            case 1:&#xA;                 serialPort.openPort();//Open serial port&#xA;        Thread.sleep(1000);&#xA;        serialPort.setParams(SerialPort.BAUDRATE_9600, &#xA;                             SerialPort.DATABITS_8,&#xA;                             SerialPort.STOPBITS_1,&#xA;                             SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0);&#xA;         serialPort.writeBytes(&quot;b&quot;.getBytes());//Write data to port&#xA;         serialPort.writeBytes(&quot;c&quot;.getBytes());//Write data to port&#xA;           serialPort.closePort();//Close serial port&#xA;                break;&#xA;&#xA;                 case 2:&#xA;                serialPort.openPort();//Open serial port&#xA;        Thread.sleep(1000);&#xA;        serialPort.setParams(SerialPort.BAUDRATE_9600, &#xA;                             SerialPort.DATABITS_8,&#xA;                             SerialPort.STOPBITS_1,&#xA;                             SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0);&#xA;&#xA;         serialPort.writeBytes(&quot;d&quot;.getBytes());//Write data to port&#xA;           serialPort.closePort();//Close serial port&#xA;                break;&#xA;                 case 3:&#xA;                serialPort.openPort();//Open serial port&#xA;        Thread.sleep(1000);&#xA;        serialPort.setParams(SerialPort.BAUDRATE_9600, &#xA;                             SerialPort.DATABITS_8,&#xA;                             SerialPort.STOPBITS_1,&#xA;                             SerialPort.PARITY_NONE);//Set params. Also you can set params by this string: serialPort.setParams(9600, 8, 1, 0);&#xA;&#xA;         serialPort.writeBytes(&quot;e&quot;.getBytes());//Write data to port&#xA;           serialPort.closePort();//Close serial port&#xA;                break;&#xA;        }&#xA;&#xA;&#xA;}&#xA;}&#xA;&#xA;public static void menu() {&#xA;    final String ANSI_CLS = &quot;\u001b[2J&quot;;&#xA;    final String ANSI_HOME = &quot;\u001b[H&quot;;&#xA;    System.out.print(ANSI_CLS + ANSI_HOME);&#xA;    System.out.flush();&#xA;    System.out.println(&quot;&quot;);  &#xA;    System.out.println(&quot;    ************************************************************************************&quot;);&#xA;    System.out.println(&quot;    *      ***       ********   *******   **    **  *****  **      **      ******      *&quot;);&#xA;    System.out.println(&quot;    *     ** **      **    **   **    **  **    **   ***   ****    **    ***    ***    *&quot;);&#xA;    System.out.println(&quot;    *    **   **     *** ****   **     ** **    **   ***   ** **   **  **          **  *&quot;);&#xA;    System.out.println(&quot;    *   *********    **   **    **     ** **    **   ***   **  **  **  **          **  *&quot;);&#xA;    System.out.println(&quot;    *  **       **   **    **   **    **  **    **   ***   **   ** **    ***    ***    *&quot;);&#xA;    System.out.println(&quot;    * **         **  **     **  *******     ****    *****  **    ****      ******      *&quot;);&#xA;    System.out.println(&quot;    ************************************************************************************&quot;);&#xA;    System.out.println(&quot;&quot;);&#xA;    System.out.println(&quot;    By Emmanouil Perselis&quot;);&#xA;    System.out.println(&quot;&quot;);&#xA;    System.out.println(&quot;What would you like to do?&quot;);&#xA;    System.out.println(&quot;0.---&quot;);&#xA;    System.out.println(&quot;1.Toggle lights&quot;);&#xA;    System.out.println(&quot;2.Toggle air&quot;);&#xA;    System.out.println(&quot;3.---&quot;);&#xA;    System.out.println(&quot;4.---&quot;);&#xA;&#xA;}&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ARDUINO SCETCH&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; int led = 13;&#xA; int led1 = 2;&#xA; int led2 = 4;&#xA; int led3 = 7;&#xA; int led4 = 8;&#xA; void setup() {   &#xA;   Serial.begin(9600);  &#xA;   pinMode(led, OUTPUT);   &#xA;   pinMode(led1, OUTPUT); &#xA;    pinMode(led2, OUTPUT); &#xA;    pinMode(led3, OUTPUT); &#xA;    pinMode(led4, OUTPUT);&#xA; }&#xA;&#xA; void loop() {&#xA;   char i= Serial.read();&#xA;&#xA;   if(i=='a'){////////////////&#xA;     if(digitalRead(led)){////////////&#xA;   digitalWrite(led, LOW);  ////////////&#xA;  }else if(!digitalRead(led))//////////&#xA;   digitalWrite(led, HIGH);  //////////&#xA; }&#xA;&#xA;  if(i=='b'){////////////////&#xA;     if(digitalRead(led1)){////////////&#xA;   digitalWrite(led1, LOW);  ////////////&#xA;  }else if(!digitalRead(led1))//////////&#xA;   digitalWrite(led1, HIGH);  //////////&#xA; }&#xA;&#xA;&#xA; if(i=='c'){////////////////&#xA;     if(digitalRead(led2)){////////////&#xA;   digitalWrite(led2, LOW);  ////////////&#xA;  }else if(!digitalRead(led2))//////////&#xA;   digitalWrite(led2, HIGH);  //////////&#xA; }&#xA;&#xA; if(i=='d'){////////////////&#xA;if(digitalRead(led3)){////////////&#xA;   digitalWrite(led3, LOW);  ////////////&#xA;  }else if(!digitalRead(led3))//////////&#xA;   digitalWrite(led3, HIGH);  //////////&#xA; }&#xA;&#xA;&#xA; if(i=='e'){////////////////&#xA;if(digitalRead(led4)){////////////&#xA;   digitalWrite(led4, LOW);  ////////////&#xA;  }else if(!digitalRead(led4))//////////&#xA;   digitalWrite(led4, HIGH);  //////////&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19599" LastActivityDate="2016-04-25T15:23:38.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23550" PostTypeId="2" ParentId="12974" CreationDate="2016-04-25T15:25:34.857" Score="1" Body="&lt;p&gt;To expand upon what was previously mentioned in comments, there are a number of things that need to be done before you can program an ATmega via a serial  connection:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;you need to have a bootloader flashed on the chip&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you need to provide a clock source (internal or external) matching the fuse settings and the rate expected by the bootloader&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;your programming software must use the same baud rate as the bootloader is expecting&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;you need to have reset the chip recently enough before starting the upload that the bootloader has not timed out - either manually or via a small capacitor to your logic level serial connection's DTR or RTS line&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You commented that your chip came from Sparkfun and was sold as having a bootloader.  The programmed ATmega328p's they list claim to have the Uno's bootloader, so most likely these need to be programmed at 115200 baud like an Uno.  You instead said that you had selected the Duemilanove setting, which would mean you were trying to use a baud rate of 57600.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-25T15:25:34.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23551" PostTypeId="1" AcceptedAnswerId="23573" CreationDate="2016-04-25T15:33:01.823" Score="8" ViewCount="21221" Body="&lt;p&gt;I am trying to find some information on how to use the analog comparator on an Atmega328 to detect when an analog pin has reached a certain voltage (3.16 volts). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot find any example code that says how to do this, although I have read that the analog comparator can compare the voltage on an analog pin with the voltage output by a PWM pin. I do not understand how this would work as the PWM pins do not output an analog voltage, but a pulse width modulated square wave. Is it possible to use the comparator to compare with a certain voltage this way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried polling with &lt;code&gt;analogRead()&lt;/code&gt;, but it is too slow for my application.&lt;/p&gt;&#xA;" OwnerUserId="3029" LastEditorUserId="3029" LastEditDate="2016-04-26T15:09:02.620" LastActivityDate="2018-03-25T11:46:25.180" Title="How to use the analog comparator to determine when an analog pin has reached a certain voltage?" Tags="|atmega328|analogwrite|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23552" PostTypeId="1" CreationDate="2016-04-25T15:58:48.383" Score="-1" ViewCount="965" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qOvr3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qOvr3.png&quot; alt=&quot;Fritzing diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try uploading to my Arduino/Genuino UNO I get the following not in sync error with &quot;unique&quot; resp(resp=0X54) or (resp=0X81) please solve ... I have to submit my project tommorow......&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error message:&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x54&#xA;  avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x54&#xA;  Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;[![enter image description here][2]][2]&lt;/p&gt;&#xA;" OwnerUserId="20530" OwnerDisplayName="Anirudh Raghavan S" LastEditorUserId="19667" LastEditDate="2016-04-26T07:10:51.193" LastActivityDate="2016-04-26T07:10:51.193" Title="Arduino not in sync unique error" Tags="|arduino-uno|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23553" PostTypeId="2" ParentId="23552" CreationDate="2016-04-25T16:10:23.873" Score="3" Body="&lt;p&gt;You have a BT module attached to Arduino Tx Rx pins. That's the culprit. Disconnect anything from Tx and Rx pins of arduino while uploading code. Once the code has been uploaded, re-connect the BT module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this didn't solve your problem, you need to pin point the issue. If you have removed everything from Arduino and still not able to upload the code - either your drivers are not up to date or your arduino is faulty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test the arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try uploading blinky sketch. Didn't succeed? Restart arduino IDE and try again. Didn't succeed? Restart PC and try again. Didn't succeed? Re install arduino and try again? Didn't succeed? Try on a friend's PC? No luck? Arduino is faulty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: This answer is for the exact schematic you have given. If you have done something else, there might be other reasons why you are not able to upload the code. Post a real picture of what exactly you are doing and we might be able to help you further.&lt;/p&gt;&#xA;" OwnerUserId="7553" OwnerDisplayName="Whiskeyjack" LastActivityDate="2016-04-25T16:22:55.563" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23554" PostTypeId="2" ParentId="23552" CreationDate="2016-04-25T16:41:49.143" Score="3" Body="&lt;p&gt;NOTE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That schematic shows you are trying to power the motors from the Arduino's 5V power supply. That is a 'bad idea' unless they are good quality, low-current, motors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The electrical noise from the motors may cause the Arduino to reset, and run the same program from the beginning until it reaches the part where the motor's electrical noise resets it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Worse, current drawn if the motors stall may damage the Arduino's power supply. The Arduino's voltage regulator is supposed to protect itself from damage, but it doesn't always succeed. This is rare, but I have had students break it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have elevated this comment to an answer to warn other people against trying to use the schematic in the question.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="3493" LastEditDate="2016-04-25T18:43:46.957" LastActivityDate="2016-04-25T18:43:46.957" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23555" PostTypeId="1" CreationDate="2016-04-25T16:56:26.383" Score="2" ViewCount="2164" Body="&lt;p&gt;So I was starting to gain some knowledge on the PIR sensor and how to let the Arduino 'sleep' while there is no movement detected by the PIR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the following code somewhere and looked fairly simple. So  I thought I would give it a try and grabbed my Mega2560, a LED and a PIR sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While it was seeming to work at first sight, the Arduino is doing the opposite from what I was expecting. It turns off the LED and the Arduino when there is movement, instead of turning off the Arduino when there is NO movement. As I said before, it is doing pretty much the inverse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably an easy solution, but can't figure it out on my own. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;  &#xA;&#xA;int wakePin = 2;                 // pin used for waking up  &#xA;int led = 13;  &#xA;&#xA;void wakeUpNow() {  &#xA;}  &#xA;&#xA;void setup() {  &#xA;  pinMode(wakePin, INPUT_PULLUP);  &#xA;  pinMode(led, OUTPUT);   &#xA;  attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW  &#xA;}  &#xA;&#xA;void sleepNow() {  &#xA;    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here  &#xA;    sleep_enable();          // enables the sleep bit in the mcucr register  &#xA;    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function  &#xA;    digitalWrite(led,LOW);&#xA;    sleep_mode();            // here the device is actually put to sleep!!  &#xA;    // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP  &#xA;    sleep_disable();         // first thing after waking from sleep: disable sleep...  &#xA;    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.  &#xA;    digitalWrite(led,HIGH);&#xA;}  &#xA;&#xA;void loop() {  &#xA;  sleepNow();     // sleep function called here  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adapted the code to the following and seems to work now. When motion is detected by the PIR it turns on the LED on pin 13; when no motion is detected, the LED is turned off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two questions still remain:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How can I be sure that the Arduino really sleeps now? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) When the Arduino just entered sleep, it takes a couple of seconds (+/- 6s) before it can pick up another motion. Can I get a faster detection or another 'sleep' or 'powersave' method that lets the Arduino react faster to motion?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;  &#xA;&#xA;const int wakePin = 2;                 // pin used for waking up  &#xA;const int led = 13;  &#xA;&#xA;int wakeVal = 0;&#xA;int wakeState = LOW;&#xA;&#xA;void wakeUpNow() {&#xA;&#xA;}  &#xA;&#xA;void setup() {  &#xA;  Serial.begin(9600);&#xA;  pinMode(wakePin, INPUT_PULLUP);  &#xA;  pinMode(led, OUTPUT);   &#xA;  //attachInterrupt(0, sleepNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW  &#xA;}  &#xA;&#xA;void sleepNow() {  &#xA;    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here  &#xA;    sleep_enable();          // enables the sleep bit in the mcucr register  &#xA;    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function  &#xA;    sleep_mode();            // here the device is actually put to sleep!!  &#xA;} &#xA;&#xA;void disSleep(){&#xA;  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP  &#xA;    sleep_disable();         // first thing after waking from sleep: disable sleep...  &#xA;    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.  &#xA;}&#xA;&#xA;void loop() {&#xA;  wakeVal = digitalRead(wakePin);&#xA;  if (wakeVal == HIGH){&#xA;&#xA;    disSleep();&#xA;&#xA;    digitalWrite(led,HIGH);&#xA;    delay(1000);&#xA;&#xA;    if (wakeState == LOW){&#xA;      Serial.println(&quot;Motion detected&quot;);&#xA;      wakeState = HIGH;&#xA;    }&#xA;  }&#xA;  else{&#xA;    digitalWrite(led,LOW);&#xA;    delay(1000);&#xA;&#xA;    if (wakeState == HIGH){&#xA;      Serial.println(&quot;Motion stopped - Going to Sleep Mode !&quot;);&#xA;      wakeState = LOW;&#xA;      delay(1000);&#xA;&#xA;      sleepNow();     // sleep function called here&#xA;    }&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19990" LastEditorUserId="37523" LastEditDate="2019-07-01T02:11:29.193" LastActivityDate="2020-03-10T07:02:55.393" Title="PIR sensor and sleep (interrupt) on Mega2560" Tags="|arduino-mega|sensors|interrupt|sleep|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23557" PostTypeId="2" ParentId="23551" CreationDate="2016-04-25T17:29:12.077" Score="1" Body="&lt;p&gt;You need a low-pass filter between the PWM output and the comparator input. This will allow you to produce an analog voltage from the PWM output, which can the be used as a reference voltage for the comparator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typically, a simple RC LPF is sufficient. Choose a large time constant relative to your PWM frequency (the Arduino defaults to 490Hz) so that you don't have ripple in your reference voltage. &lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-04-25T17:29:12.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23558" PostTypeId="1" AcceptedAnswerId="23570" CreationDate="2016-04-25T17:34:22.913" Score="0" ViewCount="1429" Body="&lt;p&gt;I got a new servo a few days back (RC Servo, Futaba FP-S148). I first tested it out with the Sweep sketch on Arduino, powering it with the Arduino 5v and GND pins only. It was working, just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Today I was trying to use it in my robot and I tried powering it with 2 LiPo batteries (Samsung ICR16850 2200mAh, from an old laptop battery) connected in series, giving 8.32v. As soon as I connected my servo, it started rotating randomly, I had not connected it to my Arduino yet. I quickly took it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I used a L7805 to get 5.13v regulated supply out of my batteries that I used earlier. When I connected my batteries to the servo, and the servo to the Arduino, uploaded the sketch, the servo started behaving rather strangely, it first did a complete turn and then stopped. Only a humming sound came from the servo. Strange thing is, whenever I connect one of my Multimeter leads to the power cables, the servo immediately turned in the opposite direction only as long as only lead was in contact with either the positive or negative wire.&#xA;Otherwise, the servo just gives a humming sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I stripped down the servo and checked the motor. It is working fine. Moreover now the servo doesn't even makes the humming sound. It just sits there, no movement, no sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have I fried my servo? Or is it some other issue?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-04-26T01:50:50.550" Title="Did I fry my servo?" Tags="|arduino-uno|servo|battery|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23559" PostTypeId="2" ParentId="23525" CreationDate="2016-04-25T17:59:23.350" Score="0" Body="&lt;p&gt;Looking at the datasheet for the 2N2222A at &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/2N2222A-D.PDF&quot; rel=&quot;nofollow&quot;&gt;http://www.onsemi.com/pub_link/Collateral/2N2222A-D.PDF&lt;/a&gt;&#xA;The 2N2222A base will draw 50 ma at 2volt.  You are giving them more than that.&#xA;The maximum allowed output from the Arduino is 40ma.&#xA;So check the 2N2222A's they are probably burnt out as well as the Arduino.&#xA;Next time put in a limit resistor of 1k to the 2N2222A bases.&#xA;Try pulling out the 2N2222A's and see if your Arduino powers up ok.&lt;/p&gt;&#xA;" OwnerUserId="20528" LastActivityDate="2016-04-25T17:59:23.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23560" PostTypeId="2" ParentId="23558" CreationDate="2016-04-25T18:04:37.233" Score="0" Body="&lt;p&gt;Since a servo is basically the combination of this components:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Motor&lt;/li&gt;&#xA;&lt;li&gt;Gearbox&lt;/li&gt;&#xA;&lt;li&gt;Position sensor (i.e a potentiometer)&lt;/li&gt;&#xA;&lt;li&gt;Motor control electronics (e.g some useful stuff to protect the system and to relate d.d.p. over it's node to position =&gt; angle[i.e could by just an operational ampifier])&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://a.pololu-files.com/picture/0J3188.450.jpg?8db0bf79b0d26db613e6730cedbc62f7&quot; alt=&quot;servo disassembled&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The unusual behaviour could have been raised by a single component of the system, most likely the variable resistor. &#xA;There's no guarantee of sucess, but maybe we can use this event to discover soimething! &#xA;My advce is try to discover the potentiometer used by the producer of the servo by looking at related datasheet. Then solder/attach temporarly an half-value or a quarter-value, resistor if the servo change it's orientation consider a replacing, if not just get rid f it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope helps :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reference &lt;a href=&quot;https://www.pololu.com/blog/15/servo-servo-motor-servomotor-definitely-not-server&quot; rel=&quot;nofollow&quot;&gt;https://www.pololu.com/blog/15/servo-servo-motor-servomotor-definitely-not-server&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20529" LastActivityDate="2016-04-25T18:04:37.233" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23562" PostTypeId="1" AcceptedAnswerId="23565" CreationDate="2016-04-25T18:30:42.133" Score="0" ViewCount="2405" Body="&lt;p&gt;This is likely a duplicate, but I couldn't find the original question. This is really basic, but just can't figure it out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to combine a few char arrays together. This is what I've tried so far.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float a = 12.3456;&#xA;float b = 5.4321;&#xA;bool c = true;&#xA;&#xA;char a_string[4];&#xA;dtostrf(a, 4, 1, a_string);&#xA;&#xA;char b_string[4];&#xA;dtostrf(b, 4, 1, b_string);&#xA;&#xA;char c_string[2] = {'0', '\0'};&#xA;if (c) {&#xA;  c_string[0] = '1';&#xA;}&#xA;&#xA;char output[12] = &quot;-----------&quot;;&#xA;&#xA;output[0] = a_string[0];&#xA;output[1] = a_string[1];&#xA;output[2] = a_string[2];&#xA;output[3] = a_string[3];&#xA;&#xA;output[4] = ' ';&#xA;&#xA;output[5] = b_string[0];&#xA;output[6] = b_string[1];&#xA;output[7] = b_string[2];&#xA;output[8] = b_string[3];&#xA;&#xA;output[9] = ' ';&#xA;&#xA;output[10] = c_string[0];&#xA;&#xA;Serial.println(output);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results in an empty string in seems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I remove the second &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__stdlib_1ga060c998e77fb5fc0d3168b3ce8771d42.html&quot; rel=&quot;nofollow&quot;&gt;dtostrf()&lt;/a&gt;, and change b_string[0] ... to a_string[0] Then I get &lt;code&gt;12.3 12.3 1&lt;/code&gt;. Doesn't seem to like having dtostrf() called more than once, but it seems like the function I want, since it allows me to set a fixed strint size. The output I'd be looking for is &lt;code&gt;12.3  5.4 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;another approach&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String a_string = String(a, 1);&#xA;String b_string = String(b, 1);&#xA;String c_string = String(c);&#xA;&#xA;String output;&#xA;String space = &quot; &quot;;&#xA;&#xA;output.concat(a_string);&#xA;output.concat(space);&#xA;output.concat(b_string);&#xA;output.concat(space);&#xA;output.concat(c_string);&#xA;&#xA;Serial.println(output);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This outputs &lt;code&gt;12.3 5.4 1&lt;/code&gt;. Is there a way to make the String fixed width? I'm looking for &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;12.3  5.4 1&lt;/code&gt; instead of&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;12.3 5.4 1&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What's the proper way of doing this?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;After trying to use the @Majenko's answer I sometimes get garbage values printed. Any ideas why?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float a = analogRead(A1) / 1023.;&#xA;float b = analogRead(A2) / 1023.;&#xA;bool c = analogRead(A3) / 1023;&#xA;&#xA;char* output = createString(a, b, c);&#xA;Serial.println(output);&#xA;&#xA;&#xA;char* createString (float _a, float _b, bool _c) &#xA;{&#xA;    char a_string[5];&#xA;    dtostrf(_a, 4, 1, a_string);&#xA;&#xA;    char b_string[5];&#xA;    dtostrf(_b, 4, 1, b_string);&#xA;&#xA;    char out[12];&#xA;    snprintf(out, 12, &quot;%4s %4s %d&quot;, a_string, b_string, c ? 1 : 0);&#xA;    return out;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA; 0.�tS&#xA;�&#xA; 0.6  `S&#xA;�&#xA; 0.6  1.0&#xA;}&#xA; 0.6  1.0 0&#xA; 0.7  1.0 0&#xA; 0.6  1.0 0&#xA; 0.6  1.0 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.print(a_string);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(b_string);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.println(c);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't produce the errors&lt;/p&gt;&#xA;" OwnerUserId="7461" LastEditorUserId="7461" LastEditDate="2016-05-04T14:50:55.687" LastActivityDate="2016-05-04T14:56:34.870" Title="build fixed size strings from floats" Tags="|string|float|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23563" PostTypeId="2" ParentId="22955" CreationDate="2016-04-25T19:17:52.020" Score="0" Body="&lt;p&gt;After much trial and error effort, I've found the solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There was no problem in the hardware side (I ran the sketch with serial monitor after detaching the LED-matrix and all non-crutial hardwares. Thanks @jantje and @NickGammon fot the tips).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently Arduino is not capable of handling &lt;strong&gt;pointers&lt;/strong&gt; in advanced &lt;strong&gt;&lt;em&gt;Oops&lt;/em&gt;&lt;/strong&gt; fashion. The library itself used it heavily, specially &lt;strong&gt;&quot;struct pointers&quot;&lt;/strong&gt; as function parameters and as return types (Arduino messed up these pointer values with other variable declarations in memory). After removing those pointers from the code and replace them with normal variables, the code runs well.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// correct definition&#xA;typedef struct {&#xA;    uint8_t vcc;&#xA;    uint8_t gnd;&#xA;} DiodeNode;&#xA;&#xA;// wrong implementation&#xA;DiodeNode* node = new DiodeNode();&#xA;node-&amp;gt;vcc = x;&#xA;node-&amp;gt;gnd = y;&#xA;&#xA;// correct implementation&#xA;DiodeNode node = (DiodeNode){x, y};&#xA;// or&#xA;DiodeNode node;&#xA;node.vcc = x;&#xA;node.gnd = y;&#xA;return node; // from functions etc.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20065" LastActivityDate="2016-04-25T19:17:52.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23565" PostTypeId="2" ParentId="23562" CreationDate="2016-04-25T20:58:22.950" Score="3" Body="&lt;p&gt;The simple way would be to format the string with &lt;code&gt;sprintf&lt;/code&gt; - however &lt;code&gt;sprintf&lt;/code&gt; on the Arduino lacks floating point support (although it is possible to enable it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you convert your floating point numbers into strings first (remember to provide room for the NULL terminating character!) you can then use &lt;code&gt;sprintf&lt;/code&gt; to format those converted numbers into what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float a = 12.3456;&#xA;float b = 5.4321;&#xA;bool c = true;&#xA;&#xA;char a_string[5];&#xA;dtostrf(a, 4, 1, a_string);&#xA;&#xA;char b_string[5];&#xA;dtostrf(b, 4, 1, b_string);&#xA;&#xA;char out[12];&#xA;&#xA;snprintf(out, 12, &quot;%4s %4s %d&quot;, a_string, b_string, c ? 1 : 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;%4s&lt;/code&gt; is replaced by a string which is padded to at least 4 characters wide. The padding is to the left of the string. If you want the padding to the right you can use &lt;code&gt;%-4s&lt;/code&gt; instead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Addendum:&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;In your new posted code you are making a fundamental error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char out[12];&#xA;snprintf(out, 12, &quot;%4s %4s %d&quot;, a_string, b_string, c ? 1 : 0);&#xA;return out;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;out&lt;/code&gt; is a local variable to the function. Its memory is allocated on the stack. You fill that with data and then return the address of that location on the stack. As soon as you leave the function that memory allocation is lost. Yes, the data is still there, but the moment you call another function that memory gets overwritten with the call frame of the new function you have called - thus corrupting your data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two main options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make &lt;code&gt;out&lt;/code&gt; global&lt;/li&gt;&#xA;&lt;li&gt;Make &lt;code&gt;out&lt;/code&gt; static&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The effect of the two options is pretty much the same, except that in the second option the scope of &lt;code&gt;out&lt;/code&gt; is restricted to the function which means you can use the &lt;em&gt;name&lt;/em&gt; &lt;code&gt;out&lt;/code&gt; elsewhere without it conflicting. In both options though the memory allocated to &lt;code&gt;out&lt;/code&gt; is in the BSS not the stack and thus won't get overwritten.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-04T14:56:34.870" LastActivityDate="2016-05-04T14:56:34.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23566" PostTypeId="1" CreationDate="2016-04-25T23:39:26.473" Score="0" ViewCount="1157" Body="&lt;p&gt;I have a three-axis accelerometer that reads me its x, y, and z components.  This results in three graphs.  Is there a way to &quot;combine&quot; these components into one reading, hence, one graph?   Same question holds for a gyroscope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet for my device is &lt;a href=&quot;https://www.pololu.com/file/download/LSM6DS33.pdf?file_id=0J1087&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;: &lt;/p&gt;&#xA;" OwnerUserId="19872" LastActivityDate="2016-04-26T00:02:42.443" Title="Is there a way to combine a 3-axis accelerometer/gyroscope into one value?" Tags="|accelerometer|gyroscope|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23567" PostTypeId="2" ParentId="23566" CreationDate="2016-04-26T00:02:42.443" Score="1" Body="&lt;p&gt;The answer is: technically, yes, it is possible. The combined result is called &lt;a href=&quot;https://en.wikipedia.org/wiki/Quaternion&quot; rel=&quot;nofollow&quot;&gt;Quaternion&lt;/a&gt;. This is what is typically used in 3D programs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But most likely that is not what you had in mind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Usually one can do a simplification and reduction of dimensions when in presence of some constraint.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Imagine that your moving object is bound to a planar surface: no matter how you tilt and rotate and pan it, it is still a 2D surface, plus a quaternion indicating the rototranslation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, once you have established the coefficients applied to the rototranslation, it is 2D.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar 1D case: imagine that your moving object is bound to some well-known geometrical shape, say a circumference. Once you have established how the circumference is oriented in the 3D space and its radius, you can express the position of your device by indicating either the angle or the distance from a reference point on the circumference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In both cases you can simplify the representation because of constraints that do not allow for real 3d movement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if your device is a flying drone that can rototranslate freely within certain boundaries (max horizontal range, min/max altitude), there is no way that you can simplify the 3d coordinates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, instead, your question was related to the protocol used to read info from the accelerometer, you are bound to the protocol defined in the datasheet, by the manufacturer.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-26T00:02:42.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23568" PostTypeId="1" AcceptedAnswerId="23569" CreationDate="2016-04-26T01:34:00.893" Score="-1" ViewCount="172" Body="&lt;p&gt;My program has a hardware interrupt to digital pin 2,  it is an IR obstacle detection sensor which gives “open collector” signal.  My program is executing an array — “for” loop.   At some point it has to wait for the input from the IR sensor, so I am using a “while” loop to pause and wait for the input. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the program gets the signal from the sensor at which point the interrupt occurs, the program collects the data (millis) and goes on for another round.  Everything works fine, but I would like to limit the time that the program is waiting for the interrupt signal, let’s say to 5 or 10 seconds. I do not want it to just sit there forever if the signal is not coming for some reason.   So what I am trying to do is to trigger the same interrupt pin (2) by another digital pin.  I  set this pin (7) on OUTPUT wrote a little “if-then” statement  so it will go HIGH when the time is up and connected this pin (7) to pin 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The scheme works partially.  When the pins are connected and the time limit is reached the pin 2 gets signal and gets triggered.   But the IR signal seems to be disabled and not functioning while it is waiting for the time limit.  I tried to connect pull-up and pull-down resistors to no avail.  It seems that when the pins are linked the IR signal disappears.  I do not even get any voltage readings on that wire. If I disconnect the pins the IR signal works again and I get voltage readings on the wire.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me what is going on and how can I make it work.  Is even possible?  Or what I have concocted is just plain silly?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="20532" LastEditorUserId="10794" LastEditDate="2016-06-15T05:34:46.123" LastActivityDate="2016-06-15T05:34:46.123" Title="Hardware Interrupts Issues" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23569" PostTypeId="2" ParentId="23568" CreationDate="2016-04-26T01:48:55.277" Score="0" Body="&lt;p&gt;It is likely that the Arduino's digital output is of a totem poll type.  That is, it is both actively being driven high and low.  And when high, is probably over powering the IR sensor's signal.  You should not use this setup!! As it could possibly short out both your processor and IR sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you could emulate an open collector Arduino output.  By switching the second pin from a digital input to a digital output sending 0 then back to a digital input. (Never set this pin to digital output and send a 1 as this could short to ground through the IR open collector.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am assuming that the IR sensor, when activated, is momentarily pulling a pull up resistor low through the open collector to ground.  Let us know if this is incorrect as the above description would then not apply.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-26T01:57:37.823" LastActivityDate="2016-04-26T01:57:37.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23570" PostTypeId="2" ParentId="23558" CreationDate="2016-04-26T01:50:50.550" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;As soon as I connected my servo, it started rotating randomly,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The random movement could be from a floating control line, i.e. random voltages signals are being interpreted as random positions, and the servo is responding.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I stripped down the servo and checked the motor. It is working fine. Moreover now the servo doesn't even makes the humming sound. It just sits there, no movement, no sound.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Assuming it was put back together properly, then it sounds like the control circuitry has been damaged.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I had not connected it to my Arduino yet. I quickly took it out.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Have you tried it on the sweep example again, or a servo tester? It could be working.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Strange thing is, whenever I connect one of my Multimeter leads to the power cables, the servo immediately turned in the opposite direction only as long as only lead was in contact with either the positive or negative wire.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sounds like you are accidentally sending it control signals with your multimeter.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Your servo is dead if:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it is properly connected and doesn't respond to any control signals&lt;/li&gt;&#xA;&lt;li&gt;it is properly connected and responds randomly to control signals&lt;/li&gt;&#xA;&lt;li&gt;it is properly connected and responds randomly to a grounded control line&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;n.b. unconnected (floating control lines could cause random behavior in an otherwise good servo).&lt;/p&gt;&#xA;" OwnerUserId="20533" LastActivityDate="2016-04-26T01:50:50.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23572" PostTypeId="2" ParentId="23568" CreationDate="2016-04-26T03:20:03.177" Score="0" Body="&lt;p&gt;Wouldn't it be easier just to have the interrupt call a function, that you also call after 5 seconds are up? This sounds a round-about way of doing it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;must&lt;/em&gt; do this, setting your other pin to output is not correct, because then the IR sensor and your other pin (7) are fighting each other. You should set the pin to &lt;em&gt;input&lt;/em&gt;, and when you want it to do something briefly make it OUTPUT, and send HIGH. Then send LOW, and go back to INPUT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However this might still make the output pin &quot;fight&quot; the IR sensor pin.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;But the IR signal seems to be disabled and not functioning while it is waiting for the time limit.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Naturally, as your output pin is holding the line low.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If the sensor just uses a pull-down resistor (and not actively drive the line low) then my scheme should work.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;However a simpler scheme is just to set a flag in the ISR, (which you test for in the main loop) and if the flag isn't set within your timeout period, do whatever you want to do if it times out. Then you don't need to try to trigger the interrupt yourself.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-26T03:20:03.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23573" PostTypeId="2" ParentId="23551" CreationDate="2016-04-26T04:39:35.723" Score="5" Body="&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11916&quot; rel=&quot;noreferrer&quot;&gt;page about the analog comparator&lt;/a&gt; that has code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;volatile boolean triggered;&#xA;&#xA;ISR (ANALOG_COMP_vect)&#xA;  {&#xA;  triggered = true;&#xA;  }&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println (&quot;Started.&quot;);&#xA;  ADCSRB = 0;           // (Disable) ACME: Analog Comparator Multiplexer Enable&#xA;  ACSR =  bit (ACI)     // (Clear) Analog Comparator Interrupt Flag&#xA;        | bit (ACIE)    // Analog Comparator Interrupt Enable&#xA;        | bit (ACIS1);  // ACIS1, ACIS0: Analog Comparator Interrupt Mode Select (trigger on falling edge)&#xA;   }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  if (triggered)&#xA;    {&#xA;    Serial.println (&quot;Triggered!&quot;); &#xA;    triggered = false;&#xA;    }&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is for a fixed reference voltage, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FzgNt.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FzgNt.png&quot; alt=&quot;Reference voltage&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-26T04:39:35.723" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23575" PostTypeId="1" AcceptedAnswerId="23578" CreationDate="2016-04-26T07:57:55.390" Score="3" ViewCount="20036" Body="&lt;p&gt;I have a SIM900 module connected to an Arduino Uno, using an AT command for listing the SMS I get this output, how can i split this based on (&lt;code&gt;,&lt;/code&gt;) to store each data in an array? &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CMGL=&quot;ALL&quot;&#xA;&#xA;+CMGL: 2,&quot;REC READ&quot;,&quot;+639321576684&quot;,&quot;Ralph Manzano&quot;,&quot;16/04/25,21:51:33+32&quot;&#xA;Yow!!!&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20427" LastEditorUserId="6936" LastEditDate="2016-04-26T15:56:35.720" LastActivityDate="2016-04-26T15:56:35.720" Title="Split string into an array of string" Tags="|arduino-uno|serial|string|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23577" PostTypeId="1" AcceptedAnswerId="23582" CreationDate="2016-04-26T08:52:44.240" Score="0" ViewCount="274" Body="&lt;p&gt;Friends... I have an idea to attach the &lt;strong&gt;compass sensor (HIMC5883L)&lt;/strong&gt; with my  &lt;strong&gt;android smartphone&lt;/strong&gt; using arduino, but I don't clearly know how to do this. I mean I want to make an OTG compass for smartphone for map navigation etc.(Many Smartphones have compass but mine have not).  If anyone had do this or know how to do this, please guide me. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20544" LastEditorUserId="20544" LastEditDate="2016-04-26T08:59:55.493" LastActivityDate="2016-04-26T12:57:03.270" Title="How can I interface HMC5883L compass board to a smartphone with OTG?" Tags="|arduino-uno|android|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23578" PostTypeId="2" ParentId="23575" CreationDate="2016-04-26T08:53:31.350" Score="6" Body="&lt;p&gt;You could try to use &lt;code&gt;strtok&lt;/code&gt;. Code from my mind and not tested:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;&#xA;int main(int argc, char *argv[])&#xA;{&#xA;    char string[] = &quot;AT+CMGL=\&quot;ALL\&quot;\n&quot;&#xA;    &quot;\n&quot;&#xA;    &quot;+CMGL: 2,\&quot;REC READ\&quot;,\&quot;+639321576684\&quot;,\&quot;Ralph Manzano\&quot;,\&quot;16/04/25,21:51:33+32\&quot;\n&quot;&#xA;    &quot;Yow!!!\n&quot;&#xA;    &quot;\n&quot;&#xA;    &quot;OK\n&quot;;&#xA;    char delimiter[] = &quot;,\n&quot;;&#xA;&#xA;    // initialize first part (string, delimiter)&#xA;    char* ptr = strtok(string, delimiter);&#xA;&#xA;    while(ptr != NULL) {&#xA;        printf(&quot;found one part: %s\n&quot;, ptr);&#xA;        // create next part&#xA;        ptr = strtok(NULL, delimiter);&#xA;    }&#xA;&#xA;    return 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;found one part: AT+CMGL=&quot;ALL&quot;&#xA;found one part: +CMGL: 2&#xA;found one part: &quot;REC READ&quot;&#xA;found one part: &quot;+639321576684&quot;&#xA;found one part: &quot;Ralph Manzano&quot;&#xA;found one part: &quot;16/04/25&#xA;found one part: 21:51:33+32&quot;&#xA;found one part: Yow!!!&#xA;found one part: OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20541" LastEditorUserId="20541" LastEditDate="2016-04-26T10:53:53.157" LastActivityDate="2016-04-26T10:53:53.157" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23579" PostTypeId="1" AcceptedAnswerId="23596" CreationDate="2016-04-26T09:34:45.247" Score="0" ViewCount="202" Body="&lt;p&gt;I'm trying to measure kWh with an Arduino that I have connected to a ESP8266 that communicates this value to a web server I have. And I've been trying to find the best and easiest way to go about this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking that I can hook a PMAC903 up to the Arduino using the interrupt pins and measuring the pulses, but I don't really know how I'm supposed to do that? Will it even work? Is this the way it's normally done? I can't really say I've found an easy solution to measure current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find documentation for the PMAC903 &lt;a href=&quot;http://en.pmac.com.cn/downloadsfront.do?method=picker&amp;amp;flag=all&amp;amp;id=fba7e17b-464f-4df0-afc1-e1eeb4289986&amp;amp;fileId=55&amp;amp;isDownloadPermissions=true&amp;amp;memstate=/members_login.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and I'm currently in possession of an Arduino Uno that I'm using.&lt;/p&gt;&#xA;" OwnerUserId="15309" LastEditorUserId="6936" LastEditDate="2016-04-26T15:55:13.547" LastActivityDate="2016-04-26T19:28:41.467" Title="Measure current and consumption" Tags="|arduino-uno|current|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23580" PostTypeId="2" ParentId="23538" CreationDate="2016-04-26T11:08:19.443" Score="0" Body="&lt;p&gt;St2000 's reply above gives the background, which is valid for any digital input, not just the Arduino pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in the specific case of the Arduino, one more thing should be noted: You can skip the use of an external pullup resistor by configuring the pin to use the internal pullup resistor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT_PULLUP) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes, of course, that it is easy to modify the part of your circuit that is connected to your input pin to have the following two states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- ground&#xA;- high impedance (floating)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If, for example, it is a switch you are reading, just connect one pin of the switch to your arduino pin and the other to GND.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastEditorUserId="19886" LastEditDate="2016-04-26T11:19:07.110" LastActivityDate="2016-04-26T11:19:07.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23581" PostTypeId="2" ParentId="17497" CreationDate="2016-04-26T12:29:14.360" Score="1" Body="&lt;p&gt;I am not into hardware but the way we handle it was by using a external PWM designed for LEDs and control that, using an Arduino. The LED driver we used was a TLC5940, see &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/tlc5940.pdf&quot; rel=&quot;nofollow&quot;&gt;TLC5940 16-Channel LED Driver With DOT Correction and Grayscale PWM Control&lt;/a&gt;. This one is controllable using the SPI bus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several libaries implementing the protocol, i.e &lt;a href=&quot;https://github.com/PaulStoffregen/Tlc5940&quot; rel=&quot;nofollow&quot;&gt;PaulStoffregen/Tlc5940&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://playground.arduino.cc/Learning/TLC5940&quot; rel=&quot;nofollow&quot;&gt;Playground from Arduino - TLC5940&lt;/a&gt; for more information.&lt;/p&gt;&#xA;" OwnerUserId="20548" LastEditorUserId="6936" LastEditDate="2016-04-26T15:53:32.000" LastActivityDate="2016-04-26T15:53:32.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23582" PostTypeId="2" ParentId="23577" CreationDate="2016-04-26T12:57:03.270" Score="0" Body="&lt;p&gt;A cheaply available USB OTG adapter cable (ask eBay) will connect the Arduino to the phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can then connect the compass sensor to your Arduino and write a sketch to retrieve the data from it and send it through the USB serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to write some software for the phone to receive and interpret the serial data and display it as a compass.  That is unless you are happy just to have a simple text display (like the Arduino's Serial Monitor) with the compass information showing in it, in which case there is off-the-shelf software that would do that (search Play)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-26T12:57:03.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23583" PostTypeId="1" CreationDate="2016-04-26T14:52:21.130" Score="1" ViewCount="527" Body="&lt;p&gt;I've build a fairly simple doorbell using Arduino Pro Mini 3.3V: &lt;a href=&quot;https://www.youtube.com/watch?v=WFd94CYT2Lw&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=WFd94CYT2Lw&amp;amp;feature=youtu.be&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the current setup:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino running off the 9 V battery&lt;/li&gt;&#xA;&lt;li&gt;A simple speaker is connected to Arduino (powered from the battery, Arduino just drives it through a transistor)&lt;/li&gt;&#xA;&lt;li&gt;Arduino is reading light level from the light meter every 200 ms.&lt;/li&gt;&#xA;&lt;li&gt;Bulb is connected to the wire that is lit up when someone presses the doorbell button.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It works well - someone presses the doorbell button, bulb gets lit up, Arduino notices that (using light meter) and doorbell rings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short - battery life. This kind of setup lasts around 2-3 days off a single battery. I was reading all about how to run Arduino off a single battery for a few weeks, even months, but I'm not sure it's feasible in my case. First of all, I need to wake up Arduino every 100-200, maybe 500 milliseconds, to read the light level. Plus, many of those long-battery-life solutions involved basically building own Arduino-compatible scheme from scratch, which I'd like to avoid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Idea&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But... I have a 230 V power source - the one that drives the bulb. Issue is that this power source is down all the time, unless someone is pressing the doorbell button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could approach it in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When someone presses the button, I'd power the Arduino and immediately play a song. Issue with that approach is that if someone presses the button for just a split second, my Arduino would be powered up for just that short amount of time, and I wouldn't have enough time to play the complete song.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If I could possibly reverse the way doorbell button works, I could have +230V all the time, and 0 when someone presses the button. This way Arduino would be on all the time, and it would &quot;notice&quot; someone pressed the button when power would go down. Issue with that approach is that song would be played only once guest would release the doorbell button, + the time it takes for an Arduino to boot.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In both #1 and #2, I need two things then:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) have Arduino on all the time, regardless of whether button is pressed or not&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) power Arduino from the doorbell to avoid having to use a battery&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which kind of means that I need to power Arduino from a dual source - 230 V and rechargeable battery. 230 V when available, and battery when 230 V goes down. In a perfect scenario, this battery would be charged from 230 V source too :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas how to built such a thing? Is there some AC power module that I could use? How would I wire things up in such a case - Arduino, AC power module, rechargeable battery?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or maybe I'm missing some easier, simpler solution here?&lt;/p&gt;&#xA;" OwnerUserId="11153" LastEditorUserId="26916" LastEditDate="2017-09-10T01:16:55.153" LastActivityDate="2017-09-10T01:16:55.153" Title="Power Arduino from 230v with battery fallback" Tags="|power|arduino-pro-mini|battery|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23584" PostTypeId="2" ParentId="23583" CreationDate="2016-04-26T15:19:39.933" Score="2" Body="&lt;p&gt;You can run a Pro-Mini just fine of a battery. It's the UNOs that cause a lot of problems, because of the onboard USB-to-Serial chip. The only thing you might want to tweak on this board, is removing the power-led, which I've recently done with a knife. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I poll the reflectivity of my power-meter every 250ms, and I'm getting at least 3 months of battery life out of 2 AA-batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the light sensor you are using, you could even use interrupts to wake up the Arduino when the light is on, instead of having to poll every few milliseconds.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-26T15:19:39.933" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23585" PostTypeId="2" ParentId="36" CreationDate="2016-04-26T16:01:24.773" Score="1" Body="&lt;p&gt;Check &lt;a href=&quot;http://playground.arduino.cc/Code/WebClient&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; from Arduino docs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &quot;Post method request&quot; code example just define your JSON as plain text like &lt;code&gt;char jsonData[] = &quot;{name: 'yourName', data: 'yourData'}&quot;&lt;/code&gt; for example, and then call &lt;code&gt;byte postPage(char* domainBuffer,int thisPort,char* page,char* thisData)&lt;/code&gt; function passing &quot;jsonData&quot; variable defined before for &quot;thisData&quot; parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It worked for me, hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="18736" LastActivityDate="2016-04-26T16:01:24.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23586" PostTypeId="1" CreationDate="2016-04-26T16:21:49.553" Score="0" ViewCount="2088" Body="&lt;p&gt;I'm trying to use a distance sensor to trigger an LED light, as you can see below. However, I also want the LED to stay on/white when a person is within the 38 inches range. How should I do that?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Tell the Arduino IDE to include the FastLED library&#xA;#include &amp;lt;FastLED.h&amp;gt;&#xA;&#xA;//Setup the variables for the HC-SR04&#xA;const int trigPin = 9;&#xA;const int echoPin = 6;&#xA;//Setup the variables for the NeoPixel Strip&#xA;#define NUM_LEDS 60 // How many leds in your strip?&#xA;#define DATA_PIN 4 // What pin is the NeoPixel's data line connected to?&#xA;CRGB leds[NUM_LEDS]; // Define the array of leds&#xA;&#xA;void setup() {&#xA;  // initialize serial communication:&#xA;  Serial.begin(9600);&#xA;  FastLED.addLeds&amp;lt;NEOPIXEL, DATA_PIN&amp;gt;(leds, NUM_LEDS);&#xA;}&#xA;&#xA;void loop() {&#xA;  // establish variables for duration of the ping,&#xA;  // and the distance result in inches and centimeters:&#xA;  long duration, inches, cm;&#xA;&#xA;  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.&#xA;  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&#xA;  pinMode(trigPin, OUTPUT);&#xA;  digitalWrite(trigPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  // Read the signal from the sensor: a HIGH pulse whose&#xA;  // duration is the time (in microseconds) from the sending&#xA;  // of the ping to the reception of its echo off of an object.&#xA;  pinMode(echoPin, INPUT);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;&#xA;  // convert the time into a distance&#xA;  inches = microsecondsToInches(duration);&#xA;  cm = microsecondsToCentimeters(duration);&#xA;&#xA;  Serial.print(inches);&#xA;  Serial.print(&quot;in, &quot;);&#xA;  Serial.print(cm);&#xA;  Serial.print(&quot;cm&quot;);&#xA;  Serial.println();&#xA;  if (inches &amp;lt;= 38)  {&#xA;    for ( int colorStep = 0; colorStep &amp;lt; 256; colorStep++ ) {&#xA;      int r = 255 - colorStep;&#xA;      // Redness starts at zero and goes up to full&#xA;      int b = 255 - colorStep;&#xA;      // Blue starts at full and goes down to zero&#xA;      int g = 255 - colorStep;&#xA;      // No green needed to go from blue to red&#xA;      // Now loop though each of the LEDs and set each one to the current color&#xA;      for (int x = 0; x &amp;lt; NUM_LEDS; x++) {&#xA;        leds[x] = CRGB(r, g, b);&#xA;      }&#xA;      // Display the colors we just set on the actual LEDs&#xA;      FastLED.show();&#xA;      delay(10);&#xA;    }&#xA;  } else if (inches &amp;gt; 38) {&#xA;    fill_solid( &amp;amp;(leds[0]), NUM_LEDS /*number of leds*/, CRGB::Black);&#xA;    FastLED.show();&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&#xA;long microsecondsToInches(long microseconds) {&#xA;  // According to Parallax's datasheet for the PING))), there are&#xA;  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per&#xA;  // second). This gives the distance travelled by the ping, outbound&#xA;  // and return, so we divide by 2 to get the distance of the obstacle.&#xA;  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf&#xA;  return microseconds / 74 / 2;&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds) {&#xA;  // The speed of sound is 340 m/s or 29 microseconds per centimeter.&#xA;  // The ping travels out and back, so to find the distance of the&#xA;  // object we take half of the distance travelled.&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20428" LastEditorUserId="4628" LastEditDate="2017-04-23T07:22:07.720" LastActivityDate="2017-08-21T21:08:58.393" Title="Use distance sensor to trigger LED strip and stay on while the person is in range" Tags="|sensors|led|rgb-led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23587" PostTypeId="1" AcceptedAnswerId="23589" CreationDate="2016-04-26T16:55:00.060" Score="1" ViewCount="8064" Body="&lt;p&gt;When I plug in my nanoatmega328 to my computer, nothing shows up in &lt;code&gt;/dev&lt;/code&gt; as I expect it to. If I plug in my Uno, &lt;code&gt;/dev/ttyACM0&lt;/code&gt; shows up. I have tried several Nanos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Linux Mint 17.2.&lt;/p&gt;&#xA;" OwnerUserId="17310" LastActivityDate="2016-10-20T17:47:20.393" Title="Arduino Nano not showing up in /dev" Tags="|arduino-nano|port-mapping|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23588" PostTypeId="2" ParentId="23587" CreationDate="2016-04-26T17:15:18.110" Score="1" Body="&lt;p&gt;Did you try with &lt;code&gt;lsusb&lt;/code&gt; and &lt;code&gt;dmesg&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They should show if the Arduino was detected and what are its parameters (use &lt;code&gt;lsusb -v&lt;/code&gt; for more detailed info).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is detected but you do not get the corresponding tty device, it might be because of missing/different rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could check out &lt;a href=&quot;http://playground.arduino.cc/Linux/Udev&quot; rel=&quot;nofollow noreferrer&quot;&gt;this link&lt;/a&gt; and edit the parameters idProduct and idVendor to match what you get from &lt;code&gt;lsusb&lt;/code&gt;, in case your rule is not matching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then remember to &lt;a href=&quot;https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot&quot;&gt;reload the modified rules&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Protip: compare the parameters of your working Uno against the ones from the Nanos and the values set in the rules.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastEditorUserId="-1" LastEditDate="2017-04-13T12:37:14.270" LastActivityDate="2016-04-26T17:15:18.110" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23589" PostTypeId="2" ParentId="23587" CreationDate="2016-04-26T17:23:43.463" Score="3" Body="&lt;p&gt;&lt;code&gt;dmesg&lt;/code&gt; should be the tool to help you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ dmesg -w&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then hit return a few times (to get some blank lines). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next plug in your Nano.  Some text should appear on the screen, which will give you a clue as to what is going on.  I don't have a Nano to try with, but a typical working device would look something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[29125.599800] usb 9-1.4.1: new full-speed USB device number 13 using ehci-pci&#xA;[29125.694742] usb 9-1.4.1: New USB device found, idVendor=04d8, idProduct=0208&#xA;[29125.694747] usb 9-1.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3&#xA;[29125.694749] usb 9-1.4.1: Product: Lenny&#xA;[29125.694751] usb 9-1.4.1: Manufacturer: chipKIT&#xA;[29125.694753] usb 9-1.4.1: SerialNumber: CK1660A05353C5&#xA;[29125.695213] cdc_acm 9-1.4.1:1.0: This device cannot do calls on its own. It is not a modem.&#xA;[29125.695240] cdc_acm 9-1.4.1:1.0: ttyACM0: USB ACM device&#xA;[29125.695768] cdc_acm 9-1.4.1:1.2: This device cannot do calls on its own. It is not a modem.&#xA;[29125.695791] cdc_acm 9-1.4.1:1.2: ttyACM1: USB ACM device&#xA;[29125.697772] input: chipKIT Lenny as /devices/pci0000:00/0000:00:1a.7/usb9/9-1/9-1.4/9-1.4.1/9-1.4.1:1.4/0003:04D8:0208.0004/input/input19&#xA;[29125.698394] hid-generic 0003:04D8:0208.0004: input,hidraw2: USB HID v1.11 Mouse [chipKIT Lenny] on usb-0000:00:1a.7-1.4.1/input4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it doesn't know what the device is it will give you a fraction of the information, and probably tell you it can't attach a driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the device is faulty and not recognisable you will get messages similar to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[29125.698394] usb 2-2.1: device not accepting address 5, error -71&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you get absolutely nothing displayed then it can't even recognise that anything has been attached to your computer.  Try different USB sockets and different USB cables to see if that helps.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: some cheap USB cables used purely for charging small batteries don't have any data wires in them - just power. Using one of these will fail for sure.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-26T17:23:43.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23590" PostTypeId="1" CreationDate="2016-04-26T17:45:10.327" Score="2" ViewCount="342" Body="&lt;p&gt;so I'm making a project, kind of BB-8 droid replica, and I stumbled upon a problem. Since I am using two RC brushless motors, ESC's and batteries, I want to make my Uno board fed up from those batteries. Also, I want to use inductive charging set that would charge both batteries. Can anyone tell me or give some kind of scheme how should I distribute the power from batteries and what additional boards should I buy?&lt;/p&gt;&#xA;" OwnerDisplayName="user20255" LastEditorDisplayName="user20255" LastEditDate="2016-04-27T19:19:38.293" LastActivityDate="2016-11-24T01:43:43.437" Title="Can't figure out how to distribute the power" Tags="|power|battery|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23591" PostTypeId="1" CreationDate="2016-04-26T17:47:02.730" Score="1" ViewCount="86" Body="&lt;p&gt;A 32 inch flat screen was embedded in a coffee table and covered by a protective layer of glass. Sensors around the edge of the glass surface need to be able to detect the precise location of an object on the glass so that a mouse cursor can be controlled with a stylus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What sensors would you use to ensure accuracy of stylus location above the screen?&lt;/p&gt;&#xA;" OwnerUserId="18441" LastActivityDate="2016-04-27T12:54:00.293" Title="Gesture sensing TV coffee table - what sensors would you use?" Tags="|sensors|ir|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23592" PostTypeId="1" AcceptedAnswerId="23599" CreationDate="2016-04-26T17:57:44.170" Score="1" ViewCount="5726" Body="&lt;p&gt;I am new to arduino, I started learning about it today and i'm stuck. I ripped out a small stepper motor from an old DVD drive. I got a polulu a4988 driver and I have wired it up as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/VWDEG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VWDEG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*     Simple Stepper Motor Control Exaple Code&#xA; *      &#xA; *  by Dejan Nedelkovski, www.HowToMechatronics.com&#xA; *  &#xA; */&#xA;// defines pins numbers&#xA;const int stepPin = 3; &#xA;const int dirPin = 4; &#xA;&#xA;void setup() {&#xA;  // Sets the two pins as Outputs&#xA;  pinMode(stepPin,OUTPUT); &#xA;  pinMode(dirPin,OUTPUT);&#xA;}&#xA;void loop() {&#xA;  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction&#xA;  // Makes 200 pulses for making one full cycle rotation&#xA;  for(int x = 0; x &amp;lt; 200; x++) {&#xA;    digitalWrite(stepPin,HIGH); &#xA;    delayMicroseconds(500); &#xA;    digitalWrite(stepPin,LOW); &#xA;    delayMicroseconds(500); &#xA;  }&#xA;  delay(1000); // One second delay&#xA;&#xA;  digitalWrite(dirPin,LOW); //Changes the rotations direction&#xA;  // Makes 400 pulses for making two full cycle rotation&#xA;  for(int x = 0; x &amp;lt; 400; x++) {&#xA;    digitalWrite(stepPin,HIGH);&#xA;    delayMicroseconds(500);&#xA;    digitalWrite(stepPin,LOW);&#xA;    delayMicroseconds(500);&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nothing happens, the motor doesn't even vibrate. Any idea what could be wrong?&lt;/p&gt;&#xA;" OwnerDisplayName="user20551" LastActivityDate="2016-04-26T23:35:55.517" Title="DVD drive stepper motors with polulu a4988 on Arduino" Tags="|arduino-uno|stepper|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23595" PostTypeId="1" AcceptedAnswerId="23624" CreationDate="2016-04-26T19:14:00.400" Score="-2" ViewCount="5027" Body="&lt;p&gt;I am using ESP8266 with Arduino MEGA. ESP8266 is powered 3.3v via voltage divider, which is taking 5v from arduino and converting it down to 3.3v with the help of 5K and 10K resistors. AT commands seems to be working OK. I am using SD_card reader and kept my index.html file in SD_card. I am able to make a successful connection and esp also sends the whole index.html file, But the issue is my browser does not shows the page in html format, instead the whole html code appears on the browser. Can anyone help me to sort this issue ?&#xA;Herez the whole code;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;    #include &amp;lt;SD.h&amp;gt;&#xA;&#xA;     #define SSID &quot;Maxcotec&quot;   // change this to match your WiFi SSID  &#xA;     #define PASS &quot;qamar0334&quot; // change this to match your WiFi password  &#xA;     #define PORT &quot;80&quot;      // using port 80 by default&#xA;    #define DEBUG true&#xA;     #define BUFFER_SIZE 1024 &#xA;     char buffer[BUFFER_SIZE];  &#xA;    //SoftwareSerial Serial2(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;                                 // This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;                                 // and the RX line from the esp to the Arduino's pin 3&#xA;    File webFile, CSS_file;&#xA;    String webpage;&#xA;     // By default we are looking for OK\r\n  &#xA;     char OKrn[] = &quot;OK\r\n&quot;;  &#xA;     byte wait_for_esp_response(int timeout, char* term=OKrn) {  &#xA;      unsigned long t=millis();  &#xA;      bool found=false;  &#xA;      int i=0;  &#xA;      int len=strlen(term);  &#xA;      // wait for at most timeout milliseconds  &#xA;      // or if OK\r\n is found  &#xA;      while(millis()&amp;lt;t+timeout) {  &#xA;       if(Serial2.available()) {  &#xA;        buffer[i++]=Serial2.read();  &#xA;        if(i&amp;gt;=len) {  &#xA;         if(strncmp(buffer+i-len, term, len)==0) {  &#xA;          found=true;  &#xA;          break;  &#xA;         }  &#xA;        }  &#xA;       }  &#xA;      }  &#xA;      buffer[i]=0;  &#xA;      Serial.print(buffer);  &#xA;      return found;  &#xA;     }  &#xA;&#xA;    void setup()&#xA;    {&#xA;      Serial.begin(9600);&#xA;      Serial2.begin(115200); // your esp's baud rate might be different&#xA;&#xA;       setupWiFi();  &#xA;      // print device IP address  &#xA;      Serial.print(&quot;device ip addr:&quot;);  &#xA;      //esp.println(&quot;AT+CIFSR&quot;);  &#xA;&#xA;&#xA;      //sendData(&quot;AT+RST\r\n&quot;,2000,DEBUG); // reset module&#xA;      //sendData(&quot;AT+CWMODE=2\r\n&quot;,1000,DEBUG); // configure as access point&#xA;      sendData(&quot;AT+CIFSR\r&quot;,1000,DEBUG); // get ip address&#xA;      sendData(&quot;AT+CIPMUX=1\r&quot;,1000,DEBUG); // configure for multiple connections&#xA;      sendData(&quot;AT+CIPSERVER=1,80\r&quot;,1000,DEBUG); // turn on server on port 80&#xA;&#xA;        // initialize SD card&#xA;        Serial.println(&quot;Initializing SD card...&quot;);&#xA;        if (!SD.begin(53)) {&#xA;            Serial.println(&quot;ERROR - SD card initialization failed!&quot;);&#xA;            return;    // init failed&#xA;        }&#xA;        Serial.println(&quot;SUCCESS - SD card initialized.&quot;);&#xA;        // check for index.htm file&#xA;        if (!SD.exists(&quot;index.htm&quot;)) {&#xA;            Serial.println(&quot;ERROR - Can't find index.htm file!&quot;);&#xA;            return;  // can't find index file&#xA;        }&#xA;        Serial.println(&quot;SUCCESS - Found index.htm file.&quot;); &#xA;&#xA;&#xA;             // send web page&#xA;        webFile = SD.open(&quot;index.htm&quot;);        // open web page file&#xA;        if (webFile) {&#xA;            while(webFile.available()&amp;gt; 0) {&#xA;                //client.write(webFile.read()); // send web page to client&#xA;               char ch = webFile.read(); // Read a character&#xA;               webpage += ch; // Add it&#xA;            }&#xA;            webFile.close();&#xA;        }&#xA;         Serial.print(&quot;file contents&amp;gt;&amp;gt;&amp;gt;&quot;);&#xA;         //Serial.println(webpage);&#xA;         //delay(20000);&#xA;    }&#xA;&#xA;    void loop()&#xA;    {&#xA;      if(Serial2.available()) // check if the esp is sending a message &#xA;      {&#xA;        /*&#xA;        while(Serial2.available())&#xA;        {&#xA;          // The esp has data so display its output to the serial window &#xA;          char c = Serial2.read(); // read the next character.&#xA;          Serial.write(c);&#xA;        } */&#xA;&#xA;        if(Serial2.find(&quot;+IPD,&quot;))&#xA;        {&#xA;         delay(1000);&#xA;&#xA;         int connectionId = Serial2.read()-48; // subtract 48 because the read() function returns &#xA;                                               // the ASCII decimal value and 0 (the first decimal number) starts at 48&#xA;&#xA;         //String webpage = &quot;&amp;lt;h1&amp;gt;Hello&amp;lt;/h1&amp;gt;&amp;lt;h2&amp;gt;World!&amp;lt;/h2&amp;gt;&amp;lt;button id=\&quot;11\&quot;&amp;gt;Toggle Pin 11&amp;lt;/button&amp;gt;&quot;;//&amp;lt;button&amp;gt;LED1&amp;lt;/button&amp;gt;&quot;;&#xA;&#xA;&#xA;         //Serial.print(&quot;file contents&amp;gt;&amp;gt;&amp;gt;&quot;);&#xA;         //Serial.println(webpage);&#xA;         //delay(20000);&#xA;         String cipSend = &quot;AT+CIPSEND=&quot;;&#xA;         cipSend += connectionId;&#xA;         cipSend += &quot;,&quot;;&#xA;         cipSend +=webpage.length();&#xA;         cipSend +=&quot;\r\n&quot;;&#xA;&#xA;         sendData(cipSend,1000,DEBUG);&#xA;         sendData(webpage,1000,DEBUG);&#xA;&#xA;         //webpage=&quot;&amp;lt;button&amp;gt;LED2&amp;lt;/button&amp;gt;&quot;;&#xA;&#xA;    //     cipSend = &quot;AT+CIPSEND=&quot;;&#xA;    //     cipSend += connectionId;&#xA;    //     cipSend += &quot;,&quot;;&#xA;    //     cipSend +=webpage.length();&#xA;    //     cipSend +=&quot;\r\n&quot;;&#xA;    //     &#xA;    //     sendData(cipSend,1000,DEBUG);&#xA;    //     sendData(webpage,1000,DEBUG);&#xA;&#xA;         String closeCommand = &quot;AT+CIPCLOSE=&quot;; &#xA;         closeCommand+=connectionId; // append connection id&#xA;         closeCommand+=&quot;\r\n&quot;;&#xA;&#xA;         sendData(closeCommand,3000,DEBUG);&#xA;        }&#xA;      }&#xA;    }&#xA;&#xA;    void setupWiFi() {  &#xA;      // try empty AT command  &#xA;      Serial2.println(&quot;AT&quot;);  &#xA;      wait_for_esp_response(2000);  &#xA;      // set mode 1 (client)  &#xA;      Serial2.println(&quot;AT+CWMODE=1&quot;);  &#xA;      wait_for_esp_response(2000);   &#xA;      // reset WiFi module  &#xA;     /*  &#xA;      esp.print(&quot;AT+RST\r\n&quot;);  &#xA;      wait_for_esp_response(3000);  &#xA;      delay(5000);  &#xA;      */  &#xA;      // join AP  &#xA;      Serial2.print(&quot;AT+CWJAP=\&quot;&quot;);  &#xA;      Serial2.print(&quot;xxxxxxx&quot;);  &#xA;      Serial2.print(&quot;\&quot;,\&quot;&quot;);  &#xA;      Serial2.print(&quot;xxxxxxx&quot;);  &#xA;      Serial2.println(&quot;\&quot;&quot;);  &#xA;      // this may take a while, so wait for 5 seconds  &#xA;      wait_for_esp_response(5000);  &#xA;      Serial2.println(&quot;AT+CIPSTO=30&quot;);   &#xA;      wait_for_esp_response(1000);  &#xA;      // start server  &#xA;      Serial2.println(&quot;AT+CIPMUX=1&quot;);  &#xA;      wait_for_esp_response(1000);  &#xA;      Serial2.print(&quot;AT+CIPSERVER=1,&quot;); // turn on TCP service  &#xA;      Serial2.println(PORT);  &#xA;      wait_for_esp_response(1000);  &#xA;     }  &#xA;&#xA;    String sendData(String command, const int timeout, boolean debug)&#xA;    {&#xA;        String response = &quot;&quot;;&#xA;&#xA;        Serial2.print(command); // send the read character to the Serial2&#xA;&#xA;        long int time = millis();&#xA;&#xA;        while( (time+timeout) &amp;gt; millis())&#xA;        {&#xA;          while(Serial2.available())&#xA;          {&#xA;&#xA;            // The esp has data so display its output to the serial window &#xA;            char c = Serial2.read(); // read the next character.&#xA;            response+=c;&#xA;          }  &#xA;        }&#xA;&#xA;        if(debug)&#xA;        {&#xA;          Serial.print(response);&#xA;        }&#xA;&#xA;        return response;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is what I am getting in web browser;&lt;a href=&quot;https://i.stack.imgur.com/lhR2n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lhR2n.png&quot; alt=&quot;Opera browser&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Opera browser but I have tried in Chrome and firefox aswell. when I open this index.html page in my laptop with the same browser, it opens perfectly. &lt;/p&gt;&#xA;" OwnerUserId="13754" LastEditorUserId="13754" LastEditDate="2019-03-11T01:43:38.090" LastActivityDate="2019-10-17T13:32:11.160" Title="ESP8266 sends webpage to client, but html codes appears in browser instead of webpage?" Tags="|arduino-mega|esp8266|web-server|http|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="23596" PostTypeId="2" ParentId="23579" CreationDate="2016-04-26T19:28:41.467" Score="2" Body="&lt;p&gt;The state of this meter can be read in 3 ways:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Pulse, this is very easy to implement. But depending on the stability of the hardware u can miss pulses leading to inaccurate values. In this way u have to calculate the meter value yourself.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;RS485, this is a communication bus not default on arduino. But given this link &lt;a href=&quot;https://arduino-info.wikispaces.com/RS485-Modules&quot; rel=&quot;nofollow&quot;&gt;https://arduino-info.wikispaces.com/RS485-Modules&lt;/a&gt; i think it is doable but not easy. This will read the value from the meter.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;M-Bus: There is special hardware needed to interact with it. This is the industry standard of doing it. It's not cheap. But u can link many meters together. This will read the value from the meter.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Depending on your time/knowledge/other requirements u have to make a chose what way your going to use.&lt;/p&gt;&#xA;" OwnerUserId="20548" LastActivityDate="2016-04-26T19:28:41.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23597" PostTypeId="2" ParentId="23595" CreationDate="2016-04-26T20:44:13.037" Score="2" Body="&lt;p&gt;See the text from &quot;'HTTP/1.1 200 OK'&quot; until &quot;'DOCTYPE html'&quot; in the following couple of links which say the same, and you might like to read the rest of those pages:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WebServer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/WebServer&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.allaboutcircuits.com/projects/using-an-arduino-as-a-web-server&quot; rel=&quot;nofollow&quot;&gt;http://www.allaboutcircuits.com/projects/using-an-arduino-as-a-web-server&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20527" LastActivityDate="2016-04-26T20:44:13.037" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23599" PostTypeId="2" ParentId="23592" CreationDate="2016-04-26T23:35:55.517" Score="3" Body="&lt;p&gt;According to Pololu's website, the VMOT pin needs at least 8V to function. Try a 12V &lt;strong&gt;switching&lt;/strong&gt; (important!) wall wart supply that can supply at least 1A instead of your USB supply. Avoid supplies that can deliver currents &gt;3A, as they are overkill for a small stepper motor and can be dangerous if shorted. Be sure to put a large (100uF is good) capacitor across that supply to prevent voltage spikes. To prevent damaging the motor from the higher voltage, follow the information Pololu provides on setting the current limit and set it to about 350mA. If you notice the motor is too hot to touch, try 200mA.&lt;/p&gt;&#xA;" OwnerUserId="3029" LastActivityDate="2016-04-26T23:35:55.517" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23600" PostTypeId="2" ParentId="23590" CreationDate="2016-04-26T23:53:01.133" Score="1" Body="&lt;p&gt;The best option is to connect the 5V/2A output of the UBEC to the 5V pin on the Arduino. In my experience, 7.4V is not enough to feed into the input jack on an Arduino especially if it is from a battery, as the voltage will drop when current is being drawn by other loads. I have built an Arduino controlled robot using a 6V NiMH battery and brushed DC gearmotors (so no ESCs or UBEC) and used a &lt;a href=&quot;https://www.pololu.com/product/2119&quot; rel=&quot;nofollow&quot;&gt;$5 5V 1A step-up/step-down converter&lt;/a&gt; so that even if the battery voltage dropped below 5V, it could still power the board. However, since you have a UBEC that is not in use, use it. &lt;strong&gt;Note that if you put voltage into the 5V pin, disconnect it when you are connecting the arduino over USB or you might damage your board.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for inductive charging, I don't know of any off-the-shelf solution designed for charging a 2S lithium ion battery. The best option for charging would probably be an easy way to open the ball to access the batteries. &lt;/p&gt;&#xA;" OwnerUserId="3029" LastEditorUserId="3029" LastEditDate="2016-04-27T05:38:47.893" LastActivityDate="2016-04-27T05:38:47.893" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23601" PostTypeId="1" CreationDate="2016-04-27T00:04:42.363" Score="2" ViewCount="294" Body="&lt;p&gt;I am in a fix since last one week regarding this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in a previous question (asked here only), I have been working to develop a APA102 LED based display. Now for this I have an Arduino Due. The display area is non rectangular however there is a central rectangular region measuring 63 cm X 36 cm. I have managed to do everything from the software side however stuck with the hardware (first time, its mostly vice-versa!!). The confusion is this, 2 options that I have at my disposal:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Go for the APA102 144 LEDs/meter (high density required) strip and then use them to make the display. On doing a small approximate calculation, I found I would have close to 2500-2600 LEDs. My first question is that:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a. Can Arduino Due handle this? I also need to display static images (bitmaps) (forget animations) and perform fading. Would the refreshing be fast enough? I have some values from APA102 datasheet and Arduino Due but cannot make head or tail of it...I do not know how to find out time taken, data rate etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b. The other problem I have with this is that for the bitmap to be &quot;perfect&quot;, the pixel pitch needs to be same. In vertical direction, this is not possible without cutting the strip along the length to reduce its width. This a damn tedious and useless job. This act along with the soldering and everything involved makes me go for option 2 (below). &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I go for eight 8*32 APA102 flexible displays and arrange them in two columns so that to display the bitmap, I split the bitmap data into two 32*32 matrices and then pass them separately. this is because I cannot find the relation between the bitmap pixel index and the actual display index. The arrangement is like that. Here Also, my question is: Can Arduino Due deal with this a good refresh rate without flickering etc. (POV display req.) The problem with this option is that I can cover only the rectangular region of the area and I am left with some area which makes me feel guilty to see it not lighted whereas with strip I can cover the whole area and only display bitmaps for the rectangular area. Both options have serpentine arrangement. This option also has cleaner and easy construction. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Both options seem plausible to me but I really cannot decide which one is better. Confused! Please, any help, idea, guidance, advice...anything would be great. I would be ordering this stuff from aliexpress etc. and thus a wrong decision would be taxing on my pocket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be glad to provide any other info if required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20119" LastEditorUserId="20119" LastEditDate="2016-04-27T20:04:49.700" LastActivityDate="2016-04-27T20:04:49.700" Title="Help with Arduino Due and APA102 LED strip Vs Matrix" Tags="|led|arduino-due|rgb-led|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23602" PostTypeId="2" ParentId="23506" CreationDate="2016-04-27T00:59:08.970" Score="5" Body="&lt;p&gt;A lot of 3.5mm jacks come with built-in normally-closed contacts, and their state can be tested through the pins of the jack with a multimeter or sensed by your MCU like any other switch. There are usually 2 pins each for the &lt;strong&gt;ring&lt;/strong&gt; (pins 2 and 4 below) and the &lt;strong&gt;tip&lt;/strong&gt; (pins 3 and 5), each pair connected to the other and one pin for the &lt;strong&gt;sleeve&lt;/strong&gt;. The insertion of the headphones' connector breaks the connection between each pair, so that only one pin of each pair is actually connected to the connector's tip and ring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yumGc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yumGc.png&quot; alt=&quot;jack schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect the tip (pin 3) of each jack to digital input pins and connect the other pin of the pair (pin 5) to Vcc; you only need to read the tip because if the tip contacts are closed, it means nothing is fully plugged in yet. When no connector is plugged in, input pin reads HIGH from the tip since it is connected to Vcc through pin 5. When the headphones are plugged in, it breaks the 3-5 connection, and the tip now floats. Its voltage is indeterminate; it will probably sit somewhere near the middle of the 0-5V range, but we can't be sure. &#xA;To remedy this, there are 2 possible approaches I can see:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You use an &lt;strong&gt;analog&lt;/strong&gt; input pin, instead of a digital pin. This way, you can read the very voltage at the tip; if its ADC value is above 900 perhaps, you can conclude that its HIGH and therefore nothing is plugged in, whereas if its below 600, you can conclude that the tip is floating and a headphone is plugged in. However, this method will require an input pin per headphone. The Uno has 6 analog pins, so this will take up all of them. If you aren't already using any of them, this method may be good enough. You could also use an analog GPIO expander.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use a digital input pin for the tip (pin 3) &lt;em&gt;but&lt;/em&gt; instead of pulling pin 5 to Vcc, you connect it to a digital output pin. You can connect the pin 5 of each headphone set to this common output pin. To test if a particular jack has headphones plugged into it, you read the associated input pin and check if this is the same as the current value of the common output pin (saved to some variable). If it is, you toggle the output pin and again check the input pin to see if it mirrors the new value of the output pin; just additional confirmation. If everything checks out, then nothing is connected to the jack yet. If either test fails, you can reasonably conclude that headphones are plugged in.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now that you know headphones are plugged in, you can call the appropriate function to begin playback through the right jack. Of course, all this assumes you'll be working with the jacks directly and not through some module. If you use the Adafruit Soundboard, you can check out the L (Left Channel) pin, which corresponds to the tip. I don't know if it's actually connected to the jack so you'll have to experiment and find out. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="27346" LastEditDate="2017-11-23T23:30:09.023" LastActivityDate="2017-11-23T23:30:09.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23603" PostTypeId="2" ParentId="23583" CreationDate="2016-04-27T01:15:16.807" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;This kind of setup lasts around 2-3 days off a single battery. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I measured 15.8 mA consumption on my Pro Mini, running from 9V. A typical 9V battery may have a capacity of 500 mAh, so that is 500 / 15.8 = 31.6 hours. Thus your observed consumption is about right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Probably 10 mA of that is the LED, so removing it would help. I have a &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about power saving&lt;/a&gt;. You would want to investigate going into sleep mode, and waking long enough to check the light. You might be able to arrange a LDR in such a way that it generates an interrupt and wakes the processor immediately from a deep sleep.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Example of waking using an LDR&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I made up a test like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vvu0s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vvu0s.png&quot; alt=&quot;LDR schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D2 is one of the external interrupt pins so we can write a simple low-power sketch that sleeps all the time until the LDR gets enough light that the resistance drops, and D2 goes HIGH.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const byte LED = 9;&#xA;&#xA;void wake ()&#xA;{&#xA;  // cancel sleep as a precaution&#xA;  sleep_disable();&#xA;  // precautionary while we do other stuff&#xA;  detachInterrupt (0);&#xA;}  // end of wake&#xA;&#xA;void setup () &#xA;  {&#xA;  }  // end of setup&#xA;&#xA;void loop () &#xA;{&#xA;&#xA;  // flash LED 5 times&#xA;  for (byte i = 0; i &amp;lt; 5; i++)&#xA;    {&#xA;    pinMode (LED, OUTPUT);&#xA;    digitalWrite (LED, HIGH);&#xA;    delay (100);&#xA;    digitalWrite (LED, LOW);&#xA;    delay (100);&#xA;    }&#xA;&#xA;  pinMode (LED, INPUT);&#xA;&#xA;  // disable ADC&#xA;  ADCSRA = 0;  &#xA;&#xA;  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  &#xA;  sleep_enable();&#xA;&#xA;  // Do not interrupt before we go to sleep, or the&#xA;  // ISR will detach interrupts and we won't wake.&#xA;  noInterrupts ();&#xA;&#xA;  // will be called when pin D2 goes high  &#xA;  attachInterrupt (0, wake, RISING);&#xA;  EIFR = bit (INTF0);  // clear flag for interrupt 0&#xA;&#xA;  // turn off brown-out enable in software&#xA;  // BODS must be set to one and BODSE must be set to zero within four clock cycles&#xA;  MCUCR = bit (BODS) | bit (BODSE);&#xA;  // The BODS bit is automatically cleared after three clock cycles&#xA;  MCUCR = bit (BODS); &#xA;&#xA;  // We are guaranteed that the sleep_cpu call will be done&#xA;  // as the processor executes the next instruction after&#xA;  // interrupts are turned on.&#xA;  interrupts ();  // one cycle&#xA;  sleep_cpu ();   // one cycle&#xA;&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My example just flashes an LED on pin 9 five times, that is where you can play your doorbell sound. Now, with no major external circuitry (like LEDs that are always on) it should have low power consumption.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What would be a good replacement for it, with low power draw and support for interrupts?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The LDR as described above. I measured 3 µA through the LDR when it was partly covered with a black box (my glasses case) and the room lights off. However it was daylight. I think that is pretty acceptable.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Come to think of it, you could probably turn this into a nice &quot;doorway detector&quot; (like they have in shops where it plays a sound when you break a light beam at the doorway). By arranging the LDR in a tube at one side of the door, and shining a light across the doorway into it (and probably tweaking the resistor values a bit) it would play a sound once you cross the beam.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-04-27T21:35:39.160" LastActivityDate="2016-04-27T21:35:39.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23604" PostTypeId="2" ParentId="23444" CreationDate="2016-04-27T01:53:54.940" Score="1" Body="&lt;p&gt;I've found the issue. The serial cable I was using was too long, introducing resistance to the signal. That's it!&lt;/p&gt;&#xA;" OwnerUserId="20433" LastActivityDate="2016-04-27T01:53:54.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23605" PostTypeId="2" ParentId="9434" CreationDate="2016-04-27T02:31:34.460" Score="3" Body="&lt;p&gt;If the LCD has a backlight you are absolutely over heating the regulator on that board by running it at 9 or 12V: At 12V with 100mA for the backlight and using 175C/W thermal resistance for the regulator:&#xA;Tj = 25C + ((12V - 5V) x 100mA x 175C/W) = 147C&#xA;That regulator goes into thermal limit at 125C.&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2016-04-27T02:31:34.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23606" PostTypeId="2" ParentId="22377" CreationDate="2016-04-27T03:37:31.823" Score="1" Body="&lt;p&gt;There are what appear to be burn or melt marks on the 5 pin component labeled QTSO and on the diode near the USB pin. That could be a sign of damage due to soldering, reverse polarity, or excessive current draw through the voltage regulator (a short circuit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the fact that the light stays on solid when the reset button is pressed,  it sounds like it could also a different issue. First, turn on verbose output in the arduino IDE and post the full output when you try to upload. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, try disconnecting &lt;strong&gt;everything&lt;/strong&gt; except the USB cable while uploading the program. If that does not fix it, it is most likely that the bootloader is corrupted. This has happened to me on multiple occasions for no apparent reason and it is pretty easy to fix. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If repairing the bootloader does not fix this, it is most likely that one or both of the components mentioned above are damaged.&lt;/p&gt;&#xA;" OwnerUserId="3029" LastEditorUserId="3029" LastEditDate="2016-04-27T16:17:18.733" LastActivityDate="2016-04-27T16:17:18.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23608" PostTypeId="2" ParentId="23591" CreationDate="2016-04-27T05:04:26.647" Score="2" Body="&lt;p&gt;Perhaps if you drop the monitor an inch or 2 away from the glass you can use a Frustrated Total Internal Reflection (&lt;a href=&quot;http://mmu.ic.polyu.edu.hk/mu_proj/2011/IPD/IPD04/Research.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTIR&lt;/a&gt;) IR scheme.  But at that shallow angle it will be tricky and may require several cameras around the edges. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0mnrG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0mnrG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should mention the parallax problem given there is a gap of an inch or more between the monitor and the touch screen.  FTIR is better when you project the image onto the touch screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't mind lower resolution, I believe the micro dose dispenser soda machines use a capacitive touch wire mess embedded in the transparent plastic front panel.  Although micro dose dispensers appear to only need to emulate about 100 to 200 buttons.  Not enough to control a mouse with any accuracy.  But enough to control a GUI designed with such constraints.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Loose high resolution capacitive touch screens can be bought with out a monitor.  However they tend to be much smaller then 32 inches.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-27T12:54:00.293" LastActivityDate="2016-04-27T12:54:00.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23612" PostTypeId="1" AcceptedAnswerId="23613" CreationDate="2016-04-27T07:28:56.133" Score="0" ViewCount="1832" Body="&lt;p&gt;Its being a few days i am trying to achieve something that I dont really know if possible.&#xA;Using the &lt;code&gt;Samd21&lt;/code&gt; chip(&lt;code&gt;Arduino Zero&lt;/code&gt;), I am using a timer and a &lt;code&gt;DAC&lt;/code&gt; to produce a sine wave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The required frequencies are &lt;strong&gt;100Khz to 3Mhz&lt;/strong&gt;. I know its sounds too much, but according to my calculations its possible- I would like to know if I am wrong with my software approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pseudo is this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.I create a look-up table of a sine wave = array of a sine samples that holds N samples&#xA;2.I use a timer with a pre scale of 1, where the clock speed is 48Mhz&#xA;3.Each timer tick I produce from the DAC 1 sample from the sine wave&#xA;4.To change frequencies I am changing the timer top counter value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we try to speak about the max frequency, according to Nyquist , a 3MHz sine must be sampled with at least 6MHz sample rate, and my sine array has 15 samples, means 45Mhz sampling rate.(=good)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the sine frequency is :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sineF= TimerF*sineSamples = TimerF*15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Than means I need a timer frequency of :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TimerF=15*sineF = 15*3Mhz=45MHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, both are good, the timer max f can be 45Mhz, and the sampling rate is good according to Nyquist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only concern here, is &lt;strong&gt;if the DAC can do that(speed)&lt;/strong&gt;, and if changing the timer frequency fast enough (even every period) is acceptable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this whole software approach true ?&#xA;If its not, producing a square wave probably possible,since it requires much less speed, but then, can you turn it into a nice clean sin wave with filters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="4989" LastActivityDate="2016-04-27T08:10:54.390" Title="Producing a sine wave with the DAC?" Tags="|signal-processing|digital-analog-conversion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23613" PostTypeId="2" ParentId="23612" CreationDate="2016-04-27T08:10:54.390" Score="2" Body="&lt;p&gt;First, I have to say I am not familiar with the Zero hardware, so I am&#xA;answering in quite general terms. Hopefully you will also get some&#xA;answers with hardware-specific information. That being said, here are my&#xA;first thoughts:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Your approach seems reasonable to me, but you are too optimistic&#xA;regarding the achievable sampling rate.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;DACs are usually fast. It's unlikely that the DAC will limit the&#xA;frequency you can achieve.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You cannot achieve a sampling frequency of 45&amp;nbsp;MHz in software&#xA;with a CPU running at 48&amp;nbsp;MHz: your code to output a sample would&#xA;have to run in less than 1.07&amp;nbsp;CPU cycles.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You may achieve a higher sampling rate with an array of&#xA;16&amp;nbsp;samples rather than 15, as wrapping the array index modulo 16&#xA;can be optimized by the compiler into a bitwise AND, which is likely to&#xA;be faster than computing &lt;code&gt;index%15&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Fastest would probably be to use a busy loop with constant execution&#xA;time and interrupts turned off (I know how to do that on AVR, but not on&#xA;ARM). Problem is: the program cannot do anything else than outputting&#xA;samples.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-27T08:10:54.390" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23615" PostTypeId="1" CreationDate="2016-04-27T08:52:10.947" Score="-1" ViewCount="956" Body="&lt;p&gt;so I have a project which is to make a simple memory game using Arduino where the LEDs have to blink in a certain pattern and the player has to imitate the same pattern&#xA;but unfortunately I'm having so much trouble with the code&#xA;I want to make an if statement to check whether the button was pressed or not if it was it continues to check on the second button and if it wasn't the red led (which means wrong) has to  turn on&#xA;this is how i started:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enter code here&#xA;&#xA;&#xA;const int button1 = 2;          // 1st button controls Blue LED &#xA;const int button2 = 3;          // 2nd button controls Yellow LED&#xA;const int button3 = 4;          // 3rd button controls Green LED&#xA;const int button4 = 5;          // 4th button controls Red LED&#xA;const int led1 = 7;             // Blue LED&#xA;const int led2 = 8;             // Yellow LED&#xA;const int led3 = 9;             // Green LED&#xA;const int led4 = 10;            // Red LED&#xA;const int correctLED = 6;&#xA;const int wrongLED = 11;&#xA;int val = 0;&#xA;&#xA;// Variables&#xA;int buttonState[] = {0,0,0,0};         // current state of the button&#xA;int lastButtonState[] = {0,0,0,0};     // previous state of the button&#xA;int buttonPushCounter[] = {0,0,0,0}; &#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  // initialize inputs :&#xA;  randomSeed(analogRead(0));&#xA;  pinMode(button1, INPUT);&#xA;  pinMode(button2, INPUT);&#xA;  pinMode(button3, INPUT);&#xA;  pinMode(button4, INPUT);&#xA;&#xA;  // initialize outputs:&#xA;  pinMode(led1, OUTPUT);&#xA;  pinMode(led2, OUTPUT);&#xA;  pinMode(led3, OUTPUT);&#xA;  pinMode(led4, OUTPUT);&#xA;  // initialize serial communication for debugging:&#xA;  Serial.begin(9600); &#xA;        }&#xA;  }&#xA;&#xA; void loop() {&#xA;       digitalWrite(7, HIGH);&#xA;       digitalWrite(8, HIGH);&#xA;       digitalWrite(9, HIGH);&#xA;       digitalWrite(10, HIGH);&#xA;       digitalWrite(7, LOW);&#xA;       digitalWrite(8, LOW);&#xA;       digitalWrite(9, LOW);&#xA;       digitalWrite(10, LOW);&#xA;&#xA;       digitalWrite(7, HIGH);&#xA;       delay(500);&#xA;       digitalWrite(7,LOW);&#xA;       delay(500);&#xA;       digitalWrite(8, HIGH);&#xA;       delay(500);&#xA;       digitalWrite(8,LOW);&#xA;       delay(500);&#xA;       digitalWrite(9, HIGH);&#xA;       delay(500);&#xA;       digitalWrite(9,LOW);&#xA;       delay(500);&#xA;       digitalWrite(10, HIGH);&#xA;       delay(500);&#xA;       digitalWrite(10,LOW);&#xA;       delay(500);&#xA;&#xA;&#xA;       val = digitalRead(2);  // read input value&#xA;       if (val == HIGH) {         // check if the input is HIGH            (button released)&#xA;       digitalWrite(wrongLED, LOW);  // turn LED OFF&#xA;       } else {&#xA;       digitalWrite(wrongLED, HIGH);  // turn LED ON&#xA;       }&#xA;       val = digitalRead(3);  // read input value&#xA;       if (val == HIGH) {         // check if the input is HIGH           (button released)&#xA;       digitalWrite(wrongLED, LOW);  // turn LED OFF&#xA;       } else {&#xA;        digitalWrite(wrongLED, HIGH);  // turn LED ON&#xA;       }&#xA;       val = digitalRead(4);  // read input value&#xA;         if (val == HIGH) {         // check if the input is HIGH (button released)&#xA;       digitalWrite(wrongLED, LOW);  // turn LED OFF&#xA;       } else {&#xA;       digitalWrite(wrongLED, HIGH);  // turn LED ON&#xA;       }&#xA;       val = digitalRead(5);  // read input value&#xA;       if (val == HIGH) {         // check if the input is HIGH (button released)&#xA;       digitalWrite(wrongLED, LOW);  // turn LED OFF&#xA;       } else {&#xA;         digitalWrite(wrongLED, HIGH);  // turn LED ON&#xA;       }&#xA;       digitalWrite(correctLED, HIGH);&#xA;&#xA;       }&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19169" LastEditorUserId="-1" LastEditDate="2016-04-27T09:34:24.240" LastActivityDate="2018-12-13T12:22:14.267" Title="memory game arduino" Tags="|arduino-uno|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23616" PostTypeId="2" ParentId="23583" CreationDate="2016-04-27T08:54:49.900" Score="1" Body="&lt;p&gt;A small solar cell would not require excitation and would probably generate enough voltage to trigger an interrupt pin and wake up the MCU.&lt;/p&gt;&#xA;" OwnerUserId="20570" LastActivityDate="2016-04-27T08:54:49.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23617" PostTypeId="2" ParentId="23595" CreationDate="2016-04-27T09:21:04.910" Score="2" Body="&lt;p&gt;Slightly off-topic, as this is not the source of your problem, but as jBot42 says, you need a proper regulator. When you use a voltage divider, your load (the ESP8266) is connected in parallel with one of the resistors (the 10K one) and effectively changes the output voltage of the regulator. As the consumption of power in the ESP8266 changes (e.g. when the wifi circuit transfers data), the voltage will also change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the very least you should place an electrolytic capacitor in parallel with the 10K resistor, but even this is not a good solution.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-04-27T09:21:04.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23618" PostTypeId="2" ParentId="23615" CreationDate="2016-04-27T10:48:35.260" Score="2" Body="&lt;p&gt;For this kind of thing you don't really want to be worrying about &quot;is this button and then this button pressed&quot; etc. That thinking is very much &quot;of the moment&quot; in that it is all about what is happening now - not what has gone on in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to be thinking about the sequence of button presses that you have seen so far - not what is happening right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say you have three buttons.  Let's assign a number to each of them - say they are buttons 1, 2 and 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you have 3 LEDs - let's call them A, B and C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you light and extinguish the LEDs in a specific order, say BAC, and you expect the buttons to be pressed in the same order - 213. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't be checking all the time for &quot;If 2 is pressed then 1 is pressed then 3 is pressed&quot; because, basically, where are you in that sequence at any one instance in time?  Instead you need to go:  &quot;A button has been pressed. I'll store that fact.&quot; And then: &quot;Have three buttons been pressed? Yes. Do their numbers match?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically like a PIN code for your bank card, or a password for your computer. It's not what you are pressing now, it's what it remembers you pressing in the past.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the simplest way of doing that is to literally allocate numbers to the buttons. When a button is pressed you assign a number representing that button to a variable. Then append that number to the list of numbers you have seen recently. When that list is the right length you compare it. Just like entering a password.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can even compare what you have so far with a portion of what you expect to catch incorrect presses early.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So say you have an expected value of &quot;213&quot; stored in a string. You also have an empty string. When you press a button you append that number to the string - so say you press &quot;212&quot; you could then append and compare the string like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Button  Input  Expected&#xA;2       2      2         Correct&#xA;1       21     21        Correct&#xA;2       212    213       Incorrect - erase input content&#xA;2       2      2         Correct&#xA;1       21     21        Correct&#xA;3       213    213       Correct - next round please.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-27T10:48:35.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23619" PostTypeId="2" ParentId="23615" CreationDate="2016-04-27T10:52:38.957" Score="2" Body="&lt;p&gt;Format and extra braces aside there are other issues with your code, too many to fit in a comment.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You have used led1, led2 etc in the setup routine and the resorted to numbers in the loop function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At the start of loop() you turn the leds high then low, you won't see this because the processor is faster than your eye, you need a delay statement after the last high and last low.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can make you code more elegant by writing a function that takes the pin as a parameter and toggles the led high then low and call this rather than repeating 4 lines of code.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;&lt;pre&gt;&lt;code&gt;void togglePin(int pinNumber, int interval)&#xA;{ &#xA;   digitalWrite(pin, HIGH);&#xA;   delay(interval);&#xA;   digitalWrite(pin, LOW);&#xA;   delay(interval);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;When it comes to reading values you have blocks of repeated code, again these could be a separate function, which will make your code easier to read and understand.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When you have done that you might want to so a bit of research on 'switch debouncing' because I'm guessing you might have issues with that too.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-27T10:52:38.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23620" PostTypeId="1" CreationDate="2016-04-27T10:55:08.590" Score="0" ViewCount="94354" Body="&lt;p&gt;The problem occurred while testing a ping program with the ethercard examples from github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now no program will upload. It will say uploading.... and gets stuck there. The error message below appears:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;WARNING: Category '' in library UIPEthernet is not valid. Setting to 'Uncategorized'&#xA;&#xA;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xdf&#xA;avrdude: stk500_recv(): programmer is not responding&#xA;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xdf&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20573" LastEditorUserId="4628" LastEditDate="2016-12-24T19:18:24.483" LastActivityDate="2020-01-01T18:02:50.370" Title="Problem uploading to Arduino Uno" Tags="|uploading|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23622" PostTypeId="1" CreationDate="2016-04-27T12:14:22.807" Score="1" ViewCount="34098" Body="&lt;p&gt;in the datasheet, it's stated that I should apply 32 serial clocks to get the 32 bits of data. How can I program this is Arduino? &lt;/p&gt;&#xA;" OwnerUserId="20509" LastActivityDate="2021-01-18T13:09:32.213" Title="How to read data using Arduino SPI" Tags="|spi|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23623" PostTypeId="2" ParentId="16380" CreationDate="2016-04-27T12:23:06.457" Score="0" Body="&lt;p&gt;You don't need an Arduino UNO to program the ESP. You just need an USB to UART adapter (CP210x or FTDI one) and the Arduino IDE. Hook the ESP rx and tx to the tx an rx of the adapter and you are ready to go. &#xA;Here is an detailed explanation &lt;a href=&quot;http://ezbitz.com/program-esp8266-using-arduino-ide/&quot; rel=&quot;nofollow&quot;&gt;how to program ESP using arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have an USB to UART bridge you can use the Arduino board as bridge: &lt;a href=&quot;http://microcontrollerkits.blogspot.ro/2015/05/esp8266-firmware-update-with-arduino.html&quot; rel=&quot;nofollow&quot;&gt;check this&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20579" LastActivityDate="2016-04-27T12:23:06.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23624" PostTypeId="2" ParentId="23595" CreationDate="2016-04-27T12:28:13.417" Score="4" Body="&lt;p&gt;It looks like you did not send the HTTP headers. Before sending any of the HTML content send following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;HTTP/1.1 200 OK\r\n&quot;&#xA;&quot;Content-Type: text/html\r\n\r\n&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Make sure you send all the &lt;code&gt;\r\n&lt;/code&gt; !&lt;/p&gt;&#xA;" OwnerUserId="20579" LastActivityDate="2016-04-27T12:28:13.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23625" PostTypeId="1" CreationDate="2016-04-27T13:06:33.310" Score="0" ViewCount="2610" Body="&lt;p&gt;I am using ESP8266 and Arduino with &lt;code&gt;SoftwareSerial&lt;/code&gt;. My requirement is to use MQTT protocol with it. So I am using an MQTT library named &lt;code&gt;pubSubClient&lt;/code&gt; but the problem is it doesn't support &lt;code&gt;SoftwareSerial&lt;/code&gt;. Could anyone tell me how can I use MQTT protocol with it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &#xA;#include &#xA;SoftwareSerial esp(2, 3); // RX, TX &#xA;PubSubClient client(esp); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error I get is: &lt;code&gt;no matching function for call to 'PubSubClient::PubSubClient(SoftwareSerial&amp;amp;)&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="8484" LastEditorUserId="11763" LastEditDate="2016-07-27T23:00:16.520" LastActivityDate="2016-07-27T23:20:55.907" Title="mqtt library which support softwareSerial on arduino uno with ESP8266" Tags="|arduino-uno|esp8266|softwareserial|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23626" PostTypeId="2" ParentId="23622" CreationDate="2016-04-27T13:07:47.213" Score="3" Body="&lt;p&gt;You call &lt;code&gt;SPI.transfer()&lt;/code&gt; four times, each time saving the returned value to a variable after proper bit shifting.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t val;&#xA;val = SPI.transfer(0xff);  //0xff is a dummy&#xA;val |= (uint32_t)SPI.transfer(0xff) &amp;lt;&amp;lt; 8;&#xA;val |= (uint32_t)SPI.transfer(0xff) &amp;lt;&amp;lt; 16;&#xA;val |= (uint32_t)SPI.transfer(0xff) &amp;lt;&amp;lt; 24;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I assume the least significant byte is received first. Make sure the SPI mode is the right one, as indicated in your datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the slave can't handle being deasserted between bytes (which is what &lt;code&gt;SPI.transfer()&lt;/code&gt; will do at the end of the transaction), then you can either try st2000's hardware SPI approach or use bitbanged SPI with &lt;code&gt;shiftIn()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-27T15:17:50.803" LastActivityDate="2016-04-27T15:17:50.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23627" PostTypeId="2" ParentId="23615" CreationDate="2016-04-27T13:13:01.487" Score="1" Body="&lt;p&gt;Your code as written will have both the &lt;code&gt;wrongLED&lt;/code&gt; and &lt;code&gt;correctLED&lt;/code&gt; on. It will also continuously loop showing the sequence.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Showing the Sequence&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;To show the sequence once at the start, put it in the setup function.&#xA;Read more about the setup function here: &lt;a href=&quot;http://www.arduino.cc/en/Reference/Setup&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Reference/Setup&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Detecting the Button Presses&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You want to detect each press of the buttons. For this you will need &lt;strong&gt;edge detection code&lt;/strong&gt;. There is an Arduino example built into the IDE and information describing the function here: &lt;a href=&quot;http://www.arduino.cc/en/Tutorial/StateChangeDetection&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Tutorial/StateChangeDetection&lt;/a&gt;&lt;br&gt;&#xA;To add to the Arduino explanation, you can either detect the rising edge (ie. the transition from a LOW to a HIGH) or the falling edge (ie. the transition from a HIGH to a LOW). I personally prefer the following code to detect a rising edge:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ( (lastButtonState == LOW) &amp;amp;&amp;amp; (buttonState == HIGH) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;buttonState&lt;/code&gt; would be assigned by a &lt;code&gt;digitalRead&lt;/code&gt; and &lt;code&gt;lastButtonState&lt;/code&gt; would record the value of &lt;code&gt;buttonState&lt;/code&gt; at the end of the loop function (ie. just before it reads in the button states again).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using your global arrays you could write:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buttonState[0] = digitalRead(button1);&#xA;buttonState[1] = digitalRead(button2);&#xA;buttonState[2] = digitalRead(button3);&#xA;buttonState[3] = digitalRead(button4);&#xA;&#xA;if ( (lastButtonState[i] == LOW) &amp;amp;&amp;amp; (buttonState[i] == HIGH) )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;i&lt;/code&gt; is a number between 0 and 3. You could use a &lt;a href=&quot;http://www.arduino.cc/en/Reference/For&quot; rel=&quot;nofollow noreferrer&quot;&gt;for loop&lt;/a&gt; to cycle through the 4 available buttons.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Recording the Button Presses&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;The StateChangeDetection example above counts the number of button presses. Instead, you want to record 4 button presses. To do this create a global variable called &lt;code&gt;pressNumber&lt;/code&gt;. Create it with the initial value of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Create an integer array of 4 elements called `userSequence'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time the if statement detects a rising edge, store the button number in the &lt;code&gt;userSequence' at position&lt;/code&gt;pressNumber&lt;code&gt;and then increment the&lt;/code&gt;pressNumber`.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;pressNumber&lt;/code&gt; reaches 4, the user has entered his/her guess.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Evaluating the Guess&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;This only occurs once the user has entered the guess. Start off by creating a boolean variable and assign it TRUE. Cycle through the elements in the &lt;code&gt;userSequence&lt;/code&gt; array and compare the users guess to the correct answer. If the user gets one wrong set the boolean variable to false. At the end, turn on the red LED or green LED depending on the state of the boolean variable (ie. if it is true turn on the green LED, otherwise turn on the red).&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Final Notes&lt;/h1&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;As Matt suggests, try &lt;a href=&quot;https://en.wikipedia.org/wiki/Code_refactoring&quot; rel=&quot;nofollow noreferrer&quot;&gt;refactoring&lt;/a&gt; portions of code into functions. It makes the code more readable and reduces the complexity of the code.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can use the variables for the pin numbers of the buttons and LEDs in the &lt;code&gt;digitalWrite&lt;/code&gt; and &lt;code&gt;digitalRead&lt;/code&gt; functions. Eg:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;digitalRead(button1);&#xA;digitalWrite(led1);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:22:14.267" LastActivityDate="2018-12-13T12:22:14.267" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23628" PostTypeId="2" ParentId="23622" CreationDate="2016-04-27T13:21:10.627" Score="0" Body="&lt;p&gt;Objective is to read 32 bits using the (unknown) device's SPI port.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the device will tolerate the SPI Chip Select line activity (going from inactive to active to inactive for each 8 bit byte read) you should be able to get the desired 32 bits of data by performing 4 consecutive 8 bit SPI reads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the device will not tolerate the above SPI Chip Select line activity (that is, if the device requires the SPI Chip Select to be active for the entire 32 bit SPI transaction), you can not separate the 32 bit transaction into 4 individual 8 bit SPI transactions with out controlling the SPI Chip Select line.  The following code example illustrates how this is done:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;//transfer 0x0F to the device on pin 10, keep the chip selected&#xA;SPI.transfer(10, 0xF0, SPI_CONTINUE);&#xA;//transfer 0x00 to the device on pin 10, keep the chip selected&#xA;SPI.transfer(10, 0×00, SPI_CONTINUE);&#xA;//transfer 0x00 to the device on pin 10, store byte received in response1, keep the chip selected&#xA;byte response1 = SPI.transfer(10, 0×00, SPI_CONTINUE);&#xA;//transfer 0x00 to the device on pin 10, store byte received in response2, deselect the chip&#xA;byte response2 = SPI.transfer(10, 0×00);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above example comes from the &lt;a href=&quot;https://www.arduino.cc/en/Reference/DueExtendedSPI&quot; rel=&quot;nofollow&quot;&gt;Arduino SPI library web page&lt;/a&gt; and is a 16 bit (not 32 bit) transfer.  To code up a 32 bit transfer, continue to call the SPI.transfer method using the SPI_CONTINUE parameter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears people are discouraging use of the DueExtendedSPI methods. And SPISettings and SPI.beginTransaction() are to be used? If so &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SPITransaction&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; show example code where the code is explicitly controlling the SPI Chip Select line (look for slaveAPin &amp;amp; slaveBPin).  Note how the code is reading 24 bits from slave A and writing 8 bits to slave B. To read 32 instead of 24 bits, we need to alter a segment of the code (along with a few other supporting changes) in this fashion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;...&#xA;  SPI.beginTransaction(settingsA);&#xA;  digitalWrite (slaveAPin, LOW);&#xA;  // reading only, so data sent does not matter&#xA;  val0 = SPI.transfer(0);&#xA;  val1 = SPI.transfer(0);&#xA;  val2 = SPI.transfer(0);&#xA;  val3 = SPI.transfer(0);&#xA;  digitalWrite (slaveAPin, HIGH);&#xA;  SPI.endTransaction();&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-27T14:48:05.360" LastActivityDate="2016-04-27T14:48:05.360" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23629" PostTypeId="2" ParentId="23622" CreationDate="2016-04-27T13:47:49.327" Score="1" Body="&lt;p&gt;Sparkfun has a good explaination of what SPI is:&lt;br&gt;&#xA;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE has a SPI library that comes with the IDE.&lt;br&gt;&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Reference/SPI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library comes with two examples:&lt;br&gt;&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/BarometricPressureSensor&quot; rel=&quot;nofollow&quot;&gt;Using SPI to read a Barometric Pressure Sensor&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://www.arduino.cc/en/Tutorial/DigitalPotControl&quot; rel=&quot;nofollow&quot;&gt;Controlling a Digital Potentiometer Using SPI&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19409" LastActivityDate="2016-04-27T13:47:49.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23630" PostTypeId="2" ParentId="23620" CreationDate="2016-04-27T14:54:29.727" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;Remove the ethercard, return to the basic board.&lt;/li&gt;&#xA;&lt;li&gt;Disconnect the Arduino from the host.&lt;/li&gt;&#xA;&lt;li&gt;Reboot the host computer.&lt;/li&gt;&#xA;&lt;li&gt;Reconnect the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Upload the Blink example.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This should sort things out, well it did when it happened to me.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-04-27T14:54:29.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23631" PostTypeId="1" AcceptedAnswerId="23636" CreationDate="2016-04-27T16:01:55.130" Score="8" ViewCount="8128" Body="&lt;p&gt;I think that Visual Studio is a great product! I find the Arduino IDE is limited in its features. For example the Arduino IDE does not have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Code prediction&lt;/li&gt;&#xA;&lt;li&gt;Error highlighting&lt;/li&gt;&#xA;&lt;li&gt;Previews of #define values&lt;/li&gt;&#xA;&lt;li&gt;Peek at code definition&lt;/li&gt;&#xA;&lt;li&gt;Jump to code definition&lt;/li&gt;&#xA;&lt;li&gt;and many more...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Since the Arduino ino &amp;amp; pde file types are basically C++, Can I use the Visual Studio IDE instead of Arduino IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be considered as a replacement, Visual Studio must be able to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Save &amp;amp; open ino &amp;amp; pde files.&lt;/li&gt;&#xA;&lt;li&gt;Compile my code.&lt;/li&gt;&#xA;&lt;li&gt;Download my code.&lt;/li&gt;&#xA;&lt;li&gt;Use existing/custom libraries from the Arduino IDE.&lt;/li&gt;&#xA;&lt;li&gt;Detect and display an Arduino project.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I would consider these features as a bonus:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino board selection. &lt;/li&gt;&#xA;&lt;li&gt;Debugging &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Variable watch window&lt;/li&gt;&#xA;&lt;li&gt;Breakpoints&lt;/li&gt;&#xA;&lt;li&gt;Step through code&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Simulation&lt;/li&gt;&#xA;&lt;li&gt;Open the Arduino Examples&lt;/li&gt;&#xA;&lt;li&gt;Automatic board detection&lt;/li&gt;&#xA;&lt;li&gt;Serial Monitor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19409" LastActivityDate="2020-05-07T03:15:58.210" Title="Can I use Visual Studio instead of Arduino IDE?" Tags="|arduino-ide|ide|visualstudio|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23632" PostTypeId="2" ParentId="23631" CreationDate="2016-04-27T16:13:41.517" Score="-1" Body="&lt;p&gt;It's not exactly what you are asking, but maybe you would be willing to consider a solution based on &lt;a href=&quot;http://eclipse.baeyens.it/&quot; rel=&quot;nofollow&quot;&gt;Eclipse&lt;/a&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Eclipse has the advantage of being cross platform, so you can have the same experience no matter what your OS might be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although, for the sake of completeness, almost all you mentioned can be done even with vim, if adequately configured. But I wouldn't recommend it as first choice, if you have never used it before.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-04-27T16:13:41.517" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23634" PostTypeId="1" CreationDate="2016-04-27T17:23:39.870" Score="0" ViewCount="92" Body="&lt;p&gt;i use this simple code for arduino :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int buttonPin = 2;&#xA;const int ledPin =  13;      &#xA;&#xA;int buttonState = 0;        &#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  Serial.begin ( 9600 ) ;&#xA;}&#xA;&#xA;void loop() {&#xA;  buttonState = digitalRead(buttonPin);&#xA;  if (buttonState == HIGH) {&#xA;    digitalWrite(ledPin, HIGH);&#xA;    Serial.println ( buttonState ) ;&#xA;  } else {&#xA;    digitalWrite(ledPin, LOW);&#xA;    Serial.println ( buttonState ) ;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it's so basic program, I've seen some people work with Resistors when they use buttons, so i wanted to know why, i plugged in one side of the button to the pin 2 , no matter if i plugged in the other side of the button or no to the 5 volte source, the arduino started giving me some ones and zeroes therefore the blinking of the led, so basically that means there's a certain voltage comming from the button to the pin 2, I wonder why and what's the reason for this ?&lt;/p&gt;&#xA;" OwnerUserId="20243" LastEditorUserId="20243" LastEditDate="2016-04-27T19:23:06.123" LastActivityDate="2019-01-06T23:59:47.080" Title="upcoming voltage from a button" Tags="|arduino-uno|button|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23636" PostTypeId="2" ParentId="23631" CreationDate="2016-04-27T18:05:14.247" Score="8" Body="&lt;p&gt;I only use Visual Studio for Arduino programming.&#xA;&lt;a href=&quot;http://www.visualmicro.com/&quot; rel=&quot;noreferrer&quot;&gt;Arduino Plugin for Visual Studio&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18532" LastActivityDate="2016-04-27T18:05:14.247" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23637" PostTypeId="2" ParentId="23586" CreationDate="2016-04-27T19:11:04.573" Score="1" Body="&lt;p&gt;if (inches &amp;lt;= 38)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That You might want to change. Try using &quot;while(inches &amp;lt;= 38)&quot; and moving sensor calculations to that loop. When ever the distance stays less than You want the light should stay on.&lt;/p&gt;&#xA;" OwnerDisplayName="user20255" LastActivityDate="2016-04-27T19:11:04.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23638" PostTypeId="2" ParentId="23634" CreationDate="2016-04-27T21:11:36.817" Score="2" Body="&lt;p&gt;I see you are new to Arduino, so let's start:&#xA;1) if you say it works you might be using an circuit like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/DVLkW.jpg&quot; alt=&quot;button no GND&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;which is not all bad but you might find trouble. I explain: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; When you set pinMode(pin,&lt;strong&gt;INPUT&lt;/strong&gt;); you tell arduino to enable a &lt;strong&gt;high-impedance state&lt;/strong&gt; on that pin: it's equivalent to &lt;strong&gt;100Mohm&lt;/strong&gt; resistor in series in front of that pin, good for getting sensor readings, but when you use a switch the state/reading of that pin (HIGH or LOW) is &quot;floating&quot; when the switch is opened which will give unpredictable readings.&#xA;That's why you need to use a &quot;pull-down&quot; resistor, which means you pull down the value of that pin when the switch is OPENED by using GND as reference value for LOW so you are sure it goes down when switch is opened. The resistor also serves as protection (10Kohm is recommended) when the switch is CLOSED as it stops the high current flow/drain (!!5V pin connected to GND!!) that arduino can't support without (aka short-circuit).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; So you end up with something like this:&#xA;&lt;img src=&quot;https://www.arduino.cc/en/uploads/Tutorial/button.png&quot; alt=&quot;button with pull-down&quot;&gt;&#xA;I would personally put the resistor and the GND wire between the button and the digital pin wire.&#xA;I hope I was useful! If you need/want more documentation check those two links out:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Constants&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/Constants&lt;/a&gt; look into &quot;Defining Digital Pins modes&quot; section&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalReadSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/DigitalReadSerial&lt;/a&gt; here you have an practical example.&lt;/p&gt;&#xA;" OwnerUserId="20597" LastEditorUserId="20597" LastEditDate="2019-01-06T20:07:07.007" LastActivityDate="2019-01-06T20:07:07.007" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23639" PostTypeId="2" ParentId="16194" CreationDate="2016-04-27T21:21:57.710" Score="11" Body="&lt;p&gt;In my case when I try to connect to my router, I get the following output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWJAP=&amp;quot;myssid&amp;quot;,&amp;quot;mypassword&amp;quot;&#xA;WIFI CONNECTED&#xA;+CWJAP:1&#xA;&#xA;FAIL&#xA;WIFI DISCONNECT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The reason is that the ESP8266 I have is setup with DHCP disabled by default. To enable it you can try the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;AT+CWDHCP=1,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If that works, you will get this message:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;OK&#xA;WIFI GOT IP&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20600" LastEditorUserId="68853" LastEditDate="2020-09-16T18:41:46.567" LastActivityDate="2020-09-16T18:41:46.567" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23642" PostTypeId="1" CreationDate="2016-04-28T00:22:45.460" Score="1" ViewCount="329" Body="&lt;p&gt;So I am building a project that uses the analog pins for precise measurements of resistance through a voltage divider and I have been having some seemingly unsolvable problems with nonlinear response to linearly changing resistances when using the A0 pin to measure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first realized this was the problem when I had a voltage divider consisting of a 76.8K and 100K 1% resistors with Vout connected to A0, and I was consistently getting wrong values. I measured the output voltage of the voltage divider and got 1.7V, instead of the ~2.7 volts I should be getting with my supply. When I disconnected the wire to A0, the voltage rose to the expected level. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disconnected power and measured resistance between the analog pins of the Atmega328 I was using and ground and found that A0 had 220K of resistance, while all other pins measured as infinite. When using the other pins, the voltage divider returned the expected values and was able to measure a wide range of resistors with values just as accurate as my multimeter. I know I have changed a lot of low-level things with code (analog reference, the comparator, ADC clock prescalers, using analog pins as outputs, etc.) but I don't think any of this could persist while the chip is not powered on. Does doing any of these things connect a resistor in the way I was describing, and is there anything that could cause this to stay &quot;stuck&quot; this way?&lt;/p&gt;&#xA;" OwnerUserId="3029" LastEditorUserId="3029" LastEditDate="2016-04-28T17:21:54.800" LastActivityDate="2016-05-28T18:12:29.467" Title="It seems as if there is a 220K pull-down resistor on analog pin 0" Tags="|atmega328|hardware|digital-analog-conversion|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23643" PostTypeId="2" ParentId="23642" CreationDate="2016-04-28T00:29:42.287" Score="1" Body="&lt;p&gt;They don't connect a resistor as such, but analog input pins do have an &lt;em&gt;impedance&lt;/em&gt; which can affect your readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your output impedance (the resistance of your resistors) is within about a tenth of the impedance of the input pin then you will (and have) noticed skewing of the results.  This is normal.  The input impedance is somewhere in the region of 1MΩ - 10MΩ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to keep your output impedance to a value below the order of a few tens of kΩ to minimise the effect the measuring of the value has on the value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to measure higher resistances then you will need to buffer the voltage with a very high impedance op-amp buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, your volt meter probably has an input impedance in the region of 10GΩ - around 1000x higher than the Arduino's ADC.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-28T00:29:42.287" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23644" PostTypeId="1" AcceptedAnswerId="23645" CreationDate="2016-04-28T00:54:27.150" Score="1" ViewCount="342" Body="&lt;p&gt;I have multiple Arduinos that I want to control using Python. My problem is that when I plug my Arduinos into the computer, they get assigned the port &lt;code&gt;/dev/ttyUSBx&lt;/code&gt; where &lt;code&gt;x&lt;/code&gt; increments with each one I connect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to reserve a certain number for a certain Arduino so that I can hard code that into the Python script? If not, can I scan the port to figure out which Arduino it is?&lt;/p&gt;&#xA;" OwnerUserId="17310" LastEditorUserId="6936" LastEditDate="2016-04-28T02:06:11.993" LastActivityDate="2016-04-28T02:06:11.993" Title="Reserve /dev/ttyUSBx" Tags="|port-mapping|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23645" PostTypeId="2" ParentId="23644" CreationDate="2016-04-28T01:04:45.060" Score="4" Body="&lt;p&gt;Yes. You need to create new unique names for them using udev rules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By using the unique serial number, along with the VID and PID of the board you can use udev to create a symbolic link to a device name of your choice. Best to keep it to something that the Arduino IDE recognises if you want to access the link from within there for programming (otherwise you can choose what you like).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rules are stored in /etc/udev/rules.d and take the form of &lt;code&gt;.rules&lt;/code&gt; files with various instructions in.  One example, that should do what you want, is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEMS==&quot;usb&quot;, ATTRS{product}==&quot;Arduino Uno&quot;, ATTRS{serial}==&quot;6493832323135111C0A1&quot;, KERNEL==&quot;ttyACM*&quot;, SYMLINK+=&quot;ttyACM50&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, tweak it to your personal requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have crafted your rules be sure to restart udev: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo systemctl restart udev&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo /etc/init.d/udev restart&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and plug your board in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Genuine Arduino devices usually use /dev/ttyACM* not /dev/ttyUSB*. If you have /dev/ttyUSB* then you are either on a very old device (with an FT232 chip) or a cheap Chinese clone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the latter then your mileage may vary somewhat.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-04-28T01:08:19.560" LastActivityDate="2016-04-28T01:08:19.560" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23647" PostTypeId="1" AcceptedAnswerId="23691" CreationDate="2016-04-28T02:13:33.233" Score="1" ViewCount="1114" Body="&lt;p&gt;I'm trying to use the Arduino IDE (1.6.8 downloaded from arduino.cc) on a MacBook running OS X (10.11.5 beta).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IDE seems to run and I can open and upload the examples and they run. But…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't type in the editor window of the IDE – either with the examples or with the new sketch that opens when you launch the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a similar problem with the version of the IDE distributed with mBlock (1.6.5) if I use the Edit in Arduino IDE button. I also tried the 1.6.9 hourly version. All to no avail. So I'm thinking that this is a OS X problem, or maybe an issue with version of Java (1.8.0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas or troubleshooting suggestions?&lt;/p&gt;&#xA;" OwnerUserId="10907" LastEditorUserId="10907" LastEditDate="2016-04-28T02:20:15.800" LastActivityDate="2017-03-12T13:15:51.127" Title="Unable to type in Arduino IDE running on OS X" Tags="|arduino-ide|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23648" PostTypeId="1" CreationDate="2016-04-28T03:00:03.963" Score="-3" ViewCount="526" Body="&lt;p&gt;Can I make all in one arduino robot? Example - line follower, bluetooth control, sonar sensor,dtmf in one arduino robot just switch to any mode without change the parts.&lt;/p&gt;&#xA;" OwnerUserId="20607" LastActivityDate="2016-04-28T10:52:59.203" Title="all in one Arduino robot" Tags="|arduino-uno|robotics|" AnswerCount="1" CommentCount="4" ClosedDate="2016-04-28T11:09:12.033" ContentLicense="CC BY-SA 3.0" />
  <row Id="23649" PostTypeId="1" CreationDate="2016-04-28T03:44:37.923" Score="1" ViewCount="50" Body="&lt;p&gt;I'm measuring two temperatures  and powering both tmp36 sensors off of the 5v pin.  For some reason pin A0 (t0) will periodically spike or dip 100°f over actual ambient and pin A1 (t1) will spike or dip but only by about 30°f at the same time but not necessarily in the same direction at A0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using about 4' of 24ga solid wire to each sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This began with a wall adapter putting out 5v 850ma connected to the barrel connector&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previous adapter of 5.3v 2a worked fine connected via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think it's SW because the arduino is doing exactly what I want it to do: measure t0 and t1 and write them to a database table via wifi.  I'm thinking that I need a 5.3v 2a barrel connector.  Am I right?&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-04-28T03:44:37.923" Title="Tmp36 spike and dip" Tags="|arduino-uno|temperature-sensor|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23650" PostTypeId="1" AcceptedAnswerId="23659" CreationDate="2016-04-28T04:04:37.807" Score="0" ViewCount="1841" Body="&lt;p&gt;What is the &quot;proper&quot; way to handle an error during setup on an Arduino -- for example some attached component is missing or returning an error code or invalid response?  The &lt;code&gt;setup()&lt;/code&gt; function returns void so that's no help. This just doesn't seem to be an issue that is addressed in the official docs -- at least not that I have found so far. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some options I have considered:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Throw an exception (but where does that go?)&lt;/li&gt;&#xA;&lt;li&gt;Write a message to &lt;code&gt;Serial&lt;/code&gt; and then go into an infinite loop or wait for a y/n to continue.&lt;/li&gt;&#xA;&lt;li&gt;Set a setup_successful flag and then do &lt;code&gt;if (!setup_successful) return;&lt;/code&gt;  in the main &lt;code&gt;loop()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="3688" LastEditorUserId="3688" LastEditDate="2016-04-28T04:10:01.963" LastActivityDate="2016-04-28T10:10:37.710" Title="How to handle an error in setup()" Tags="|arduino-setup|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23651" PostTypeId="1" AcceptedAnswerId="23652" CreationDate="2016-04-28T04:34:28.367" Score="1" ViewCount="873" Body="&lt;p&gt;If Arduino IDE itself is built on Java can I run JVM on the Arduino? If yes how should I do it?&lt;/p&gt;&#xA;" OwnerUserId="20567" LastEditorUserId="304" LastEditDate="2016-04-28T10:32:56.873" LastActivityDate="2016-04-28T10:32:56.873" Title="I want to run jvm on arduino.What minimum configuration do I need?" Tags="|arduino-uno|programming|electronics|java|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23652" PostTypeId="2" ParentId="23651" CreationDate="2016-04-28T04:44:20.213" Score="1" Body="&lt;p&gt;Search for &quot;embedded java&quot;. Oracle supports it for ARM cores, which is what some of the arduino-like boards such as the Teensy 3.X have, but I doubt they have enough resources to support it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is haiku-vm (google it!) that's designed with AVR processors in mind, but I don't know how actively it is being worked on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Googling &quot;embedded java avr&quot; yields a tremendous amount of results; did you even try that?&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-28T04:44:20.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23653" PostTypeId="2" ParentId="23650" CreationDate="2016-04-28T04:50:45.700" Score="2" Body="&lt;p&gt;Same way you would handle any error in an embedded system; either try to recover from it if you can, or use whatever communications mechanism you have to let the user know that something failed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I normally use a combination of Serial.println in case I happen to have a serial connection at the time, and also a blinking pattern on an LED (which most boards I use have). As an example, look at my code here: &lt;a href=&quot;https://github.com/jayeye/jardino/blob/master/libard/WiFiSPIFFSConfig/src/WiFiSPIFFSConfig.cpp#L11&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jayeye/jardino/blob/master/libard/WiFiSPIFFSConfig/src/WiFiSPIFFSConfig.cpp#L11&lt;/a&gt;. &lt;code&gt;error()&lt;/code&gt; will do a sequence of slow and then fast blinks, and either return if I think the error is recoverable and I'm merely warning the user, or just stay in an infinite loop and keep blinking in despair :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this is not an original idea -- think beep codes!&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-04-28T04:50:45.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23657" PostTypeId="2" ParentId="23648" CreationDate="2016-04-28T07:23:19.520" Score="4" Body="&lt;p&gt;Yes, actually it has been done before (multiple times).&#xA;I, along with some other students did such a project at my school.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=GTJQ2VXtmk0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=GTJQ2VXtmk0&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.youtube.com/watch?v=sXXh3Q8WoEM&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=sXXh3Q8WoEM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Materials needed&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino (or other programmable microcontroller board with voltage regulation)&lt;/li&gt;&#xA;&lt;li&gt;Battery pack (and charger)&lt;/li&gt;&#xA;&lt;li&gt;2 to 5 line sensors&lt;/li&gt;&#xA;&lt;li&gt;ultrasonic sensor&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth module&lt;/li&gt;&#xA;&lt;li&gt;Robot chassis&lt;/li&gt;&#xA;&lt;li&gt;Atleast two motors (with encoders is nicer, but not neccesary)&lt;/li&gt;&#xA;&lt;li&gt;Motor driving circuitry&lt;/li&gt;&#xA;&lt;li&gt;Switch and emergency stop button&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It can be useful to buy a &quot;line follower robot kit&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Connection&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the connection we used. You're free to make your own adjustments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/raepe.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/raepe.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Programming&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We used a server that (was connected via bluetooth) and has the map and a user-interface.&#xA;When you press the end-point on the server, it would generate the shortest route, calculate the directions, and send it to the robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot would then drive until it comes to a junction and then executes the direction command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached some preview code. It's better to do it yourself, but if you really don't know where to get started, you can try this.&#xA;You will have to implement the low-level code yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot will wait for Bluetooth messages. You can set it to a &quot;direct drive&quot; modus or &quot;line following&quot; modus.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  setupBluetooth();&#xA;  setupUltrasonicSensor();&#xA;  setupMotors();&#xA;  setupLinesensors();&#xA;  state=waiting;&#xA;}&#xA;&#xA;void loop() {&#xA;  char receivedCharacter = bluetoothReceiveCharacter();&#xA;&#xA;  switch (state) {&#xA;    case waiting:&#xA;      switch(receivedCharacter){&#xA;        case 'd':&#xA;          bluetooth.println(&quot;Direct Drive enabled!&quot;);&#xA;          state = directDrive;&#xA;        break;&#xA;        case 'l':&#xA;          bluetooth.println(&quot;Line following enabled!&quot;);&#xA;          state = following;&#xA;          motor1.setSpeed(50);&#xA;          motor2.setSpeed(50);&#xA;        break;&#xA;      }&#xA;      break;&#xA;    case directDrive:&#xA;        directDrive(receivedCharacter);&#xA;      break;&#xA;    case following:&#xA;        followLine(receivedCharacter);&#xA;      break;&#xA;    default:&#xA;      bluetooth.println(&quot;STATE ERROR!&quot;);&#xA;      buzzer.buzz();&#xA;      led.blink();&#xA;    break;&#xA;  }&#xA;}&#xA;&#xA;void followLine(){&#xA;    long distance = ultrasonicSensor.measureDistance();&#xA;    unsigned char lineSensorsPattern = lineSensors.getPattern();&#xA;&#xA;    switch(receivedCharacter){&#xA;      case 'X':&#xA;        bluetooth.println(&quot;Line following disabled! (Now waiting)&quot;);&#xA;        state = waiting;&#xA;      break;&#xA;    }&#xA;&#xA;    if(distance &amp;gt; 100 || distance == -1){&#xA;      switch(lineSensorsPattern){&#xA;        case 0b00000000:&#xA;          motor1.setSpeed(0);&#xA;          motor2.setSpeed(0);&#xA;          bluetooth.println(&quot;Following interrupted, lost path!&quot;);&#xA;          findPath();&#xA;        break;&#xA;        case 0b00000100:&#xA;          motor1.setSpeed(100);&#xA;          motor2.setSpeed(100);&#xA;          bluetooth.println(&quot;Following line, middle sensor on.&quot;);&#xA;        break;&#xA;        case 0b00000100:&#xA;          motor1.setSpeed(100);&#xA;          motor2.setSpeed(100);&#xA;          bluetooth.println(&quot;Following line, middle sensor on.&quot;);&#xA;        break;&#xA;        case 0b00000110:&#xA;          motor1.setSpeed(70);&#xA;          motor2.setSpeed(100);&#xA;          bluetooth.println(&quot;Following line, middle &amp;amp; right sensor on.&quot;);&#xA;        break;&#xA;        case 0b00001100:&#xA;          motor1.setSpeed(100);&#xA;          motor2.setSpeed(70);&#xA;          bluetooth.println(&quot;Following line, middle &amp;amp; left sensor on.&quot;);&#xA;        break;&#xA;        case 0b00000010:&#xA;          motor1.setSpeed(0);&#xA;          motor2.setSpeed(100);&#xA;          bluetooth.println(&quot;Following line, right sensor on.&quot;);&#xA;        break;&#xA;        case 0b00001000:&#xA;          motor1.setSpeed(100);&#xA;          motor2.setSpeed(0);&#xA;          bluetooth.println(&quot;Following line, left sensor on.&quot;);&#xA;        break;&#xA;      }&#xA;    }else{&#xA;      bluetooth.println(&quot;Following interrupted, obstacle in path!&quot;);&#xA;    }&#xA;}&#xA;&#xA;void directDrive(char receivedCharacter) {&#xA;  switch (receivedCharacter) {&#xA;    case 'X':&#xA;      motor1.setSpeed(0);&#xA;      motor2.setSpeed(0);&#xA;      state = waiting;&#xA;      bluetooth.println(&quot;Direct Drive disabled! (Now waiting)&quot;);&#xA;      break;&#xA;    case 'w':&#xA;      motor1.setSpeed(motor1.getSpeed()++);&#xA;      motor2.setSpeed(motor2.getSpeed()++);&#xA;      break;&#xA;    case 'a':&#xA;      motor1.setSpeed(motor1.getSpeed()++);&#xA;      motor2.setSpeed(motor2.getSpeed()--);&#xA;      break;&#xA;    case 's':&#xA;      motor1.setSpeed(motor1.getSpeed()--);&#xA;      motor2.setSpeed(motor2.getSpeed()--);&#xA;      break;&#xA;    case 'd':&#xA;      motor1.setSpeed(motor1.getSpeed()--);&#xA;      motor2.setSpeed(motor2.getSpeed()++);&#xA;      break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My advice&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My best advice is to work in iterations. Slowly add more features until you've got the product that you desire. Or develop parts of it individually.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get a bluetooth link working, send some messages back and forth.&lt;/li&gt;&#xA;&lt;li&gt;Connect motors to an Arduino and chassis let it drive a pre-programmed path.&lt;/li&gt;&#xA;&lt;li&gt;Get some line sensors to work (non reflecting black tape!)&lt;/li&gt;&#xA;&lt;li&gt;Get a ultrasonic sensor to work.&lt;/li&gt;&#xA;&lt;li&gt;Start combining these! Control the robot over bluetooth. Let the robot follow the lines. Add a breaking when it sees something within range.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As addition/clarification.&#xA;You could make a button, that increases the state every time you press it.&#xA;If you then check which state the robot is in, you can make it perform his task for that state.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(buttonPressed){state++;}&#xA;if(state&amp;gt;3){state=0;}&#xA;&#xA;if(state==0){&#xA;  //code for DTMF handling&#xA;}else if(state==1){&#xA;  //code for bluetooth&#xA;}else if(state==2){&#xA;  //code for sonar&#xA;}else if(state==3){&#xA;  //code for line sensors&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-04-28T10:52:59.203" LastActivityDate="2016-04-28T10:52:59.203" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23659" PostTypeId="2" ParentId="23650" CreationDate="2016-04-28T10:10:37.710" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The setup() function returns void so that's no help.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You wouldn't be able to get the return value anyway even if it did return something - it's not you calling the &lt;code&gt;setup()&lt;/code&gt; function, but &lt;code&gt;main()&lt;/code&gt;, which is not in your code or control.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;This just doesn't seem to be an issue that is addressed in the official docs&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is because it is not within the remit of the API and its associated documentation.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Throw an exception (but where does that go?)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It goes in the bin.  Exceptions are disabled.  They make little sense in an embedded system.  Yes, it is possible to use them, but not worth it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Write a message to Serial and then go into an infinite loop or wait for a y/n to continue.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That kind of thing is what most people do - or variations on that kind of theme.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Set a setup_successful flag and then do if (!setup_successful) return; in the main loop()&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That will just run &lt;code&gt;loop()&lt;/code&gt; again - after all, it's called &lt;code&gt;loop()&lt;/code&gt; for a reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You seem to be in the mindset of a PC programmer. Embedded programming is a very very different beast. You don't (usually) have an operating system to handle exceptions and errors and things like that. You don't have a keyboard and mouse, and a screen with pretty pictures on it. Every single thing that the board does is what you program. If you want it to raise an error when an error occurs then it is up to you to program a suitable mechanism for that to happen. Reporting that error and asking for feedback in some way is entirely governed by your system's design. If you have a TFT screen you could put an error message on that. If you have a serial connection you can use that to show error messages. If you don't have any of those you can blink an LED or use a buzzer to beep in a specific pattern (like a PC's POST beeps).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-28T10:10:37.710" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23660" PostTypeId="2" ParentId="23620" CreationDate="2016-04-28T10:38:06.777" Score="1" Body="&lt;p&gt;I'm having the same issue on my Macbook Pro. It happens randomly. The only solution i found is disconnecting the USB cable from the PC wait for a few mins and reconnect it again (possibly using another USB port).&#xA;It worked for me!&lt;/p&gt;&#xA;" OwnerUserId="15256" LastActivityDate="2016-04-28T10:38:06.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23661" PostTypeId="1" CreationDate="2016-04-28T11:58:14.107" Score="-1" ViewCount="927" Body="&lt;p&gt;So I'm running a program that involves both Arduino and a Raspberry PI and they are communicating between the Serial port. As you can see below when my an emergency stop door, involving a magnetic switch, is opened then the PI sends a message to the Arduino. When the door is closed the PI sends a different value telling the Arduino to continue with the program. The Arduino is receiving and reading the messages correctly as I have ran a few tests with the serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the door is open the PI is printing '1' which shuts down the Arduino correctly. My problem is that when I close the doors nothing happens when in theory it should break the loop and continue to run the main Arduino code. The raspberry PI is correctly printing '2' and the Arduino is correctly reading this value as it prints &quot;Logoff&quot; in the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone can help or lead me to correctly breaking this loop and returning to the main code that would be great. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the emergency part of the code that continues to run. If the full code is needed I will gladly edit it into this post. Also if the PI code is needed I will post that too, I don't believe is necessary because there are no problems on that side.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Estop() {&#xA;    if (Serial.available()) {&#xA;        int d = Serial.read() - '0';&#xA;&#xA;        while (d == 1) {&#xA;            digitalWrite(green, HIGH);&#xA;            digitalWrite(red, LOW);&#xA;            digitalWrite(blue, HIGH);&#xA;            digitalWrite(estopout, HIGH);&#xA;            digitalWrite(piston, LOW);&#xA;            digitalWrite(belt, HIGH);&#xA;            Serial.read() - '0';&#xA;            Serial.print(d);&#xA;            delay(2000);&#xA;            break;&#xA;&#xA;            if (d == 0) {&#xA;                Serial.print(&quot;Logoff&quot;);&#xA;                delay(2000);&#xA;            } else {&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;`&lt;/p&gt;&#xA;" OwnerUserId="20615" LastEditorUserId="4143" LastEditDate="2016-04-28T12:04:45.290" LastActivityDate="2016-04-28T14:51:00.883" Title="My code is stuck in a loop involving Serial.read. How can I break this?" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23666" PostTypeId="2" ParentId="3014" CreationDate="2016-04-28T13:30:21.790" Score="0" Body="&lt;p&gt;I had same issue and solved by below mentioned layout.&lt;a href=&quot;https://i.stack.imgur.com/BcCMW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BcCMW.png&quot; alt=&quot;HC05 with Atmega328&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20620" LastActivityDate="2016-04-28T13:30:21.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23667" PostTypeId="2" ParentId="23625" CreationDate="2016-04-28T13:33:17.747" Score="0" Body="&lt;p&gt;Not sure what you're trying to do - but thought I would offer this since I just spend some time on getting my esp8266 to act as a wifi shield for my arduino.  Basically I wanted to subscribe to an mqtt channel and send the payload to my arduino.  So the esp8266 connected to a broker, upon reading a message, it would simply write it via serial to the arduino (I used software serial on the arduino side so I could use the standard serial for debugging).  If it helps, check out &lt;a href=&quot;http://mganis.blogspot.com&quot; rel=&quot;nofollow&quot;&gt;http://mganis.blogspot.com&lt;/a&gt; for the details&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--Matt&lt;/p&gt;&#xA;" OwnerUserId="20621" LastActivityDate="2016-04-28T13:33:17.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23668" PostTypeId="2" ParentId="23661" CreationDate="2016-04-28T14:40:29.047" Score="1" Body="&lt;p&gt;You never reassigned the variable d anywhere within the loop. The &lt;code&gt;while&lt;/code&gt; breaks after a 2 seconds delay after printing what is the value of d. That means that your &lt;code&gt;if (d == 0) [...]&lt;/code&gt; never gets hit. I presume that you expect to read 'logoff' on your code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Estop() {&#xA;    if (Serial.available()) {&#xA;        int d = Serial.read() - '0';&#xA;&#xA;        while (d == 1) {&#xA;            digitalWrite(green, HIGH);&#xA;            digitalWrite(red, LOW);&#xA;            digitalWrite(blue, HIGH);&#xA;            digitalWrite(estopout, HIGH);&#xA;            digitalWrite(piston, LOW);&#xA;            digitalWrite(belt, HIGH);&#xA;            d = Serial.read() - '0';&#xA;            Serial.print(d);&#xA;            delay(2000);&#xA;            #break;&#xA;&#xA;            if (d == 0) {&#xA;                Serial.print(&quot;Logoff&quot;);&#xA;                delay(2000);&#xA;            } else {&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="5090" LastActivityDate="2016-04-28T14:40:29.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23669" PostTypeId="2" ParentId="23661" CreationDate="2016-04-28T14:51:00.883" Score="0" Body="&lt;p&gt;Inside your while loop, &lt;strong&gt;you never change the condition&lt;/strong&gt;, running into an infinite while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further: Your program does not delay until &lt;code&gt;d&lt;/code&gt; equals &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt;. This can be problematic as &lt;code&gt;d&lt;/code&gt; can have other values. It is an &lt;code&gt;int&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Plus&lt;/strong&gt;, you do a &lt;code&gt;while&lt;/code&gt; loop while &lt;code&gt;d&lt;/code&gt; equals &lt;code&gt;1&lt;/code&gt; and ask, if &lt;code&gt;d&lt;/code&gt; equals &lt;code&gt;0&lt;/code&gt; without changing the value of &lt;code&gt;d&lt;/code&gt; in between. Your &lt;code&gt;if&lt;/code&gt; would never be true. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also don't know, what this line should do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int d = Serial.read() - '0';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;did you mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int d = Serial.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I dont't see any sense, to subtract &lt;code&gt;0&lt;/code&gt; from your the value you read.&lt;/p&gt;&#xA;" OwnerUserId="19013" LastActivityDate="2016-04-28T14:51:00.883" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23670" PostTypeId="1" AcceptedAnswerId="23678" CreationDate="2016-04-28T14:53:23.917" Score="0" ViewCount="1727" Body="&lt;p&gt;I have set up 2 DHT22 sensors and 2 BMP280 sensors with an Arduino Uno SMD R3 board. The DHTs are working fine and are outputting correct temperature and humidity values to the Serial monitor. The BMPs are connected via I2C and do not.&#xA;I assigned the standard address (0x77) to one of them, and set the other to 0x76 by placing a jumper between GND and SDO. However, in the Serial output, both devices are detected and connected (this is checked in the &lt;code&gt;loop()&lt;/code&gt; by using the Wire library), but only one of them (0x77) shows up with the correct pressure and temperature. The other address is recognized, but it seems not to be able to transmit data.&#xA;There are already pullups on the SCL and SDA lines to the +5V terminal.&#xA;Both BMP280 sensors work, by reversing their position, it is still address 0x77 that works, however, once I change the jumper, neither works. Might this be simply an issue with the breadboard or is there an address conflict somehow? Also, I have tried several values for the pullup resistors (4.7 kOhm, 10kOhm and 140kOhm), they all seem to have the same effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Found address: 118 (0x76)&#xA;Found address: 119 (0x77)&#xA;Found 2 device(s).&#xA;DHT22_1: hum1 = 28.00 %, temp1 = 24.80 C&#xA;DHT22_2: hum2 = 24.80 %, temp2 = 24.70 C&#xA;BMP280_0x77: t_77 = 25.83 Cp_77 = 100039.43 Pa&#xA;BMP280_0x76: t_76 = 0.00 Cp_76 = 0.00 Pa&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I used the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_BMP280.h&amp;gt;&#xA;&#xA;// Constants&#xA;#define DHTPIN_1 5     // pin for data&#xA;#define DHTPIN_2 4&#xA;#define DHTTYPE DHT22   // what type of sensor: DHT 22  (AM2302)&#xA;&#xA;DHT dht1(DHTPIN_1, DHTTYPE); // initializes sensor&#xA;DHT dht2(DHTPIN_2, DHTTYPE); // initializes sensor&#xA;&#xA;Adafruit_BMP280 bm77; // I2C&#xA;Adafruit_BMP280 bm76(0x76); // I2C&#xA;&#xA;// Variables&#xA;int chk;&#xA;float hum1;  // stores humidity&#xA;float temp1; // stores temperature&#xA;float hum2;  // stores humidity&#xA;float temp2; // stores temperature&#xA;&#xA;&#xA;// --- Setup --- //&#xA;void setup()&#xA;{&#xA;  delay(1000);&#xA;  Serial.begin(9600);&#xA;  dht1.begin();&#xA;  dht2.begin();&#xA;  bm77.begin();&#xA;  delay(500);&#xA;  bm76.begin();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  byte count = 0;&#xA;  Wire.begin();&#xA;  for (byte i = 1; i &amp;lt; 120; i++)&#xA;  {&#xA;    Wire.beginTransmission (i);&#xA;    if (Wire.endTransmission () == 0)&#xA;      {&#xA;      Serial.print (&quot;Found address: &quot;);&#xA;      Serial.print (i, DEC);&#xA;      Serial.print (&quot; (0x&quot;);&#xA;      Serial.print (i, HEX);&#xA;      Serial.println (&quot;)&quot;);&#xA;      count++;&#xA;      delay (1);  // maybe unneeded?&#xA;      } // end of good response&#xA;  } // end of for loop&#xA;  Serial.print (&quot;Found &quot;);&#xA;  Serial.print (count, DEC);&#xA;  Serial.println (&quot; device(s).&quot;);&#xA;&#xA;  hum1 = dht1.readHumidity(); // reads and stores hum&#xA;  temp1= dht1.readTemperature(); // reads and stores temp&#xA;  hum2 = dht2.readHumidity(); // reads and stores hum&#xA;  temp2= dht2.readTemperature(); // reads and stores temp&#xA;  // serial output commands&#xA;&#xA;  delay(2000); // reading needs to be delayed by at least 2000ms&#xA;  Serial.print(&quot;DHT22_1: &quot;);&#xA;  Serial.print(&quot;hum1 = &quot;);&#xA;  Serial.print(hum1);&#xA;  Serial.print(&quot; %, temp1 = &quot;);&#xA;  Serial.print(temp1);&#xA;  Serial.println(&quot; C&quot;);&#xA;&#xA;  Serial.print(&quot;DHT22_2: &quot;);&#xA;  Serial.print(&quot;hum2 = &quot;);&#xA;  Serial.print(hum2);&#xA;  Serial.print(&quot; %, temp2 = &quot;);&#xA;  Serial.print(temp2);&#xA;  Serial.println(&quot; C&quot;);&#xA;  delay(500);&#xA;  Serial.print(&quot;BMP280_0x77: &quot;);&#xA;  Serial.print(&quot;t_77 = &quot;);&#xA;  Serial.print(bm77.readTemperature());&#xA;  Serial.print(&quot; C&quot;);&#xA;  Serial.print(&quot;p_77 = &quot;);&#xA;  Serial.print(bm77.readPressure());&#xA;  Serial.println(&quot; Pa&quot;);&#xA;  delay(500);&#xA;  Serial.print(&quot;BMP280_0x76: &quot;);&#xA;  Serial.print(&quot;t_76 = &quot;);&#xA;  Serial.print(bm76.readTemperature());&#xA;  Serial.print(&quot; C&quot;);&#xA;  Serial.print(&quot;p_76 = &quot;);&#xA;  Serial.print(bm76.readPressure());&#xA;  Serial.println(&quot; Pa&quot;);&#xA;&#xA;  Serial.println();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The setup I used. red = +5V, black = GND, green = SCL, blue = SDA, yellow = DHT data lines, white = jumper between GND and SDO. Pictured is a different model of the BMP series, but in my case, I used the BMP280 and did not connect the other connectors. Edit: seems to be missing in the diagram, but of course, the positive and ground terminal are connected to the breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/50abs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/50abs.png&quot; alt=&quot;breadboard&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20459" LastEditorUserId="20459" LastEditDate="2016-04-28T17:16:25.267" LastActivityDate="2016-04-28T21:00:07.567" Title="Second I2C address not accepted" Tags="|arduino-uno|i2c|adafruit|temperature-sensor|pull-up|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23672" PostTypeId="1" CreationDate="2016-04-28T18:22:45.620" Score="0" ViewCount="473" Body="&lt;p&gt;I want to drive numerous chips (L9823, TLC5925, ADG1414, MCP23S08) from an Arduino Micro as well as read input from analog pins connected to momentary buttons, toggles, potentiometers and such. The chips and input controls will be on various boards connected to the Arduino using ribbon cables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current idea is to have two sets of 8 pin FFC connectors with the following pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FFC digital &quot;bus&quot; conductors:&#xA;--&#xA;SCLK&#xA;VL&#xA;SDI&#xA;RST&#xA;SDO&#xA;LE3&#xA;LE2&#xA;LE1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The clock, VL (5V), SDI and SDO will be shared by both connectors but I still need 6 latches (which can also be commandeered for an interrupt or analog input) and 2 reset pins. This will allow me to run up to 3 types of chips per connector (minus latches used for something else).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will also have a third 8-conductor FFC connector for 7 analog inputs (the eighth conductor is 5V analog ref).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, does anyone see any holes in this strategy? I don't think I'm going to try to even breadboard something like this. PCB fab is so easy now (and the first run is always wrong anyway) so I'm just going to make the boards and go from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I just need to settle on what pins to use. Here is a diagram of the Arduino Micro:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kK49s.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kK49s.png&quot; alt=&quot;Arduino Micro&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the connectors could use pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connector 1 - Digital I/O:&#xA;--&#xA;SCLK SCK&#xA;VL   5V&#xA;SDI  MOSI&#xA;RST  11&#xA;SDO  MISO&#xA;LE3  A8&#xA;LE2  A7&#xA;LE1  SS&#xA;&#xA;Connector 2 - Digital I/O:&#xA;--&#xA;SCLK SCK&#xA;VL   5V&#xA;SDI  MOSI&#xA;RST  13&#xA;SDO  MISO&#xA;LE3  A9&#xA;LE2  7 (Arduino INT)&#xA;LE1  5&#xA;&#xA;Connector 3 - Analog Inputs:&#xA;&#xA;5V&#xA;A0&#xA;A1&#xA;A2&#xA;A3&#xA;A4&#xA;A5&#xA;A6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A10 and A11 are reserved for other purposes as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this look ok?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE 1:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have updated the text of this question to consider many of the great comments. The changes include:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Share MISO and MOSI&#xA;between connectors. Not sure why I thought I needed to use separate&#xA;ports for the different connectors. SLCK, MISO and MOSI should&#xA;indeed be shared by both connectors.&lt;/li&gt;&#xA;&lt;li&gt;Moved 5V to be in between&#xA;SCK and MISO and moved RST to be in between MISO and MOSI. The idea&#xA;is that the low impedance of these lines will shield from capacitive&#xA;crosstalk described by Majenko. The connectors are 1mm pitch which&#xA;isn't terribly small so hopefully this will not be an issue. It does&#xA;make routing a little harder since the data pins tend to be next to&#xA;each other but the same bus is going to connect to multiple boards&#xA;in a daisy chain fashion so capacitive crosstalk could definitely be&#xA;an issue. Fortuntely things don't have to run really fast since&#xA;everything is ultimately for interfacing with humans who are&#xA;relatively slow.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20626" LastEditorUserId="4628" LastEditDate="2017-03-29T03:49:41.070" LastActivityDate="2017-03-29T03:49:41.070" Title="Driving numerous chips from 2 separate SPI connectors w/ Arduino Micro" Tags="|analogread|spi|arduino-micro|multiplexer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23673" PostTypeId="2" ParentId="23672" CreationDate="2016-04-28T18:32:47.817" Score="0" Body="&lt;p&gt;The MOSI (Master Out Slave In) and MISO (Master In Slave Out) will be much better for your SPI pins. Your SDI (Slave Digital In iirc) will equate to MOSI and your SDO (Slave Digital Out iirc) will equate to MISO. Those are the hardware SPI pins and will be much better than trying to emulate SPI in software. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2016-04-28T18:32:47.817" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23676" PostTypeId="2" ParentId="23461" CreationDate="2016-04-28T19:17:29.057" Score="4" Body="&lt;p&gt;I've always used flag to indicate a boolean logic value. I would also suggest this is an archaic term.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was going to come up with my own explanation but found the following at &lt;a href=&quot;https://www.quora.com/In-C-language-what-does-flag-mean-Is-it-an-arbitrary-variable-name-Can-I-use-flag-2-or-b-etc&quot; rel=&quot;nofollow&quot;&gt;In C language, what does flag mean?&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A 'flag' is a variable that is supposed to signalize something. Think&#xA;  about the word itself - flags are used in sending signals. In our&#xA;  world of programming a basic boolean flag can either be &quot;up&quot; or&#xA;  &quot;down&quot;, either true or false.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2016-04-28T19:17:29.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23677" PostTypeId="1" CreationDate="2016-04-28T19:34:27.113" Score="1" ViewCount="842" Body="&lt;p&gt;I have bought a 7&quot; LCD (&lt;code&gt;TFT01-7&lt;/code&gt;) and a shield to make it work with arduino mega (&lt;a href=&quot;http://www.elecfreaks.com/store/lcd-tft01-mega-shield-v10-p-214.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.elecfreaks.com/store/lcd-tft01-mega-shield-v10-p-214.html&lt;/a&gt;), but when I upload my code to the arduino and plug my LCD to the shield the arduino get overheated and the LCD lose power and I don't know why even when I power my arduino with external 9V 2A adapter, I even tried uploading an example from the library but it does the same, I used to work with the same code and the same shield but with 5&quot; LCD &lt;code&gt;ITDB50&lt;/code&gt; and I didn't have this problem before, how can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qVrWA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qVrWA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17349" LastEditorUserId="17349" LastEditDate="2016-04-30T12:08:08.570" LastActivityDate="2017-08-24T12:55:18.070" Title="arduino mega overheat when connected to TFT 7&quot; and TFT shield" Tags="|arduino-uno|arduino-mega|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23678" PostTypeId="2" ParentId="23670" CreationDate="2016-04-28T21:00:07.567" Score="1" Body="&lt;p&gt;According to the datasheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SDA and SCL are not pure open drain. Both pads contain ESD protection diodes to VDDIO and GND. As the devices  does  not  perform  clock  stretching,  the  SCL  structure  is  a  high-Z  input  without  drain capability.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this affects the operation with two together as you have them, but I must say that your debugging seems very thorough. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The words &quot;without  drain capability&quot; are a bit worrying. There is a &lt;a href=&quot;https://forums.adafruit.com/viewtopic.php?f=22&amp;amp;t=90509&quot; rel=&quot;nofollow noreferrer&quot;&gt;thread on the Adafruit forum&lt;/a&gt; about this, where they suggest an &lt;a href=&quot;https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/overview&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C multiplexer&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about I2C&lt;/a&gt; I have a schematic and code for a simple multiplexer using the CD4051 multiplexer chip (reply #11).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schematic is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oEhO5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oEhO5.png&quot; alt=&quot;Multiplexed I2C&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-04-28T21:00:07.567" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23679" PostTypeId="2" ParentId="23672" CreationDate="2016-04-28T21:43:56.537" Score="3" Body="&lt;p&gt;The micro only has one SPI bus. It is SCK/MISO/MOSI. You may &lt;em&gt;want&lt;/em&gt; a second one, but you don't &lt;em&gt;have&lt;/em&gt; one.  You can't magic one up out of thin air.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; emulate one in pure software (bit-banging) but it won't be anywhere near as efficient as using a real hardware one. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do you feel you need to have two independent buses anyway? What are you wanting to achieve that you can't achieve with a single shared bus? That same bus can quite happily appear on multiple connectors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note with your strategy: Ribbon connectors and SPI don't mix well together.  There is a lot of crosstalk and capacitance in a ribbon cable that high speed serial communication really doesn't like.  If I had to use ribbon cable for SPI communication for anything longer than a couple of inches I would use twice as many connections and interleave ground between each signal.  That is what the ribbon cables for later IDE drives in PCs used to get higher speed, more reliable, communication down ribbon cables.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-28T21:43:56.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23680" PostTypeId="2" ParentId="23677" CreationDate="2016-04-28T21:49:45.850" Score="1" Body="&lt;p&gt;7&quot; LCDs need a lot of current. They need it for the back light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That current comes from the 5V pin.  That 5V pin is supplied by a linear regulator that has limited current capacity.  As you draw more current it gets hotter and hotter and eventually shuts down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to power your LCD screen with another external 5V source. The best solution may be a powerful (2A) phone charger (USB) which you then plug direct into the USB port of the board thus bypassing the weak regulator.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-28T21:49:45.850" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23681" PostTypeId="1" AcceptedAnswerId="23682" CreationDate="2016-04-28T22:41:50.020" Score="2" ViewCount="553" Body="&lt;p&gt;I want to have a define from my sketch be picked up by a library.&#xA;Here is a similar question for references: &lt;a href=&quot;https://arduino.stackexchange.com/questions/21931/using-define-and-multiple-classes&quot;&gt;Using #define and multiple classes&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a CI server that compiles my arduino sketchs on commmit. It pulls all my personal libs from an other repository and compiles the sketch using arduino-builder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now i want it to also make a debug build. (Some of my library's have debugstatments in them i enable using a #define debugsomething.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way i can get the compiler to pickup the #define in the sketch or am i better off making a very complex build script that modifies the headers between builds?&lt;/p&gt;&#xA;" OwnerUserId="20548" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-04-28T23:09:28.673" Title="Visibility of #define between sketch and library" Tags="|build|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23682" PostTypeId="2" ParentId="23681" CreationDate="2016-04-28T23:09:28.673" Score="2" Body="&lt;p&gt;You need a common place that the building of all the places can get the definition from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That isn't the sketch. The sketch is one of the things that would have to look at that common place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That can either be a single shared header that everything else (that needs it) includes, or it can be a &lt;code&gt;-D&lt;/code&gt; flag added to the compilation command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, adding:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-DDEBUG=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to your compilation command is the same as adding&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define DEBUG 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to every single file you compile.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-28T23:09:28.673" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23683" PostTypeId="1" CreationDate="2016-04-29T00:35:44.260" Score="1" ViewCount="562" Body="&lt;p&gt;I'm using the code off of the sparkfun website HX711 hookup guide (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide#arduino-code&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide#arduino-code&lt;/a&gt;) to attempt to create a scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have output data of weight in the serial monitor - is there an easy way to then graph this data with regards to time? I've spent an hour fooling around with Processing and googling, but haven't had any luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20637" LastActivityDate="2019-12-25T08:02:55.480" Title="Graphing force sensor data routed through HX711?" Tags="|arduino-uno|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23684" PostTypeId="1" CreationDate="2016-04-29T03:39:53.727" Score="2" ViewCount="1681" Body="&lt;p&gt;I am working with STPM10 energy metering chip (evaluation board) and I want to read the data from 8 internal registers of the chip each containing 32 bits. &lt;a href=&quot;https://i.stack.imgur.com/guhxa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/guhxa.jpg&quot; alt=&quot;This is the 8 internal registers of the chip&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet of the STPM10 chip suggested to have a simplex synchronous SPI where the MOSI of the Arduino is not connected to any pin on the energy chip. Instead they provided a timing diagram to switch from reading and writing on the energy chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pkw7h.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pkw7h.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the t5, datasheet stated that we should apply 32 serial clocks per data record and up to 8 data records can be read this way. My problem is how to apply 32 serial clocks to the chip.  Is the Serial clock on the Arduino SPI automatically activated after &lt;code&gt;SPI.begin()&lt;/code&gt; ? If not, how can I start the serial clock? By the way, this is the code I've written:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;SPISettings settingA(32000000, LSBFIRST, SPI_MODE0);&#xA;const byte SYN = 8;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(SYN,OUTPUT);&#xA; /*Initializes the SPI bus by setting SCK, MOSI and SS to outputs&#xA;  Pulling SCK, and MOSI low, and SS high */&#xA;  SPI.begin();&#xA;  SPI.beginTransaction(settingA);&#xA;&#xA;  }&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;  //0-----&amp;gt;t1&#xA;  digitalWrite(SS,HIGH);&#xA;  digitalWrite(SYN,HIGH);&#xA;  delay(500);&#xA;  //t1-----&amp;gt;t2   &#xA;  digitalWrite(SYN,LOW);&#xA;  delayMicroseconds(1000);&#xA;  //t2-----&amp;gt;t3&#xA;  digitalWrite(SYN,HIGH);&#xA;   delayMicroseconds(0.035);&#xA;  //t3-----&amp;gt;t4&#xA;  digitalWrite(SS, LOW); &#xA;  delayMicroseconds(0.035);&#xA;  //t4-----&amp;gt;t5&#xA;  digitalWrite(SYN, LOW);&#xA;  delayMicroseconds(0.035);&#xA;  //t5----&amp;gt;t6&#xA;  digitalWrite(SYN, HIGH);&#xA;  delayMicroseconds(0.035);&#xA;&#xA;  byte d1 = SPI.transfer(0x00);&#xA;  byte d2 = SPI.transfer(0x00);&#xA;  byte d3 = SPI.transfer(0x00);&#xA;  byte d4 = SPI.transfer(0x00);&#xA;  byte d5 = SPI.transfer(0x00);&#xA;  byte d6 = SPI.transfer(0x00);&#xA;  byte d7 = SPI.transfer(0x00);&#xA;  byte d8 = SPI.transfer(0x00);&#xA;  byte d9 = SPI.transfer(0x00);&#xA;  byte d10 = SPI.transfer(0x00);&#xA;  byte d11 = SPI.transfer(0x00);&#xA;  byte d12 = SPI.transfer(0x00);&#xA;  byte d13 = SPI.transfer(0x00);&#xA;  byte d14 = SPI.transfer(0x00);&#xA;  byte d15 = SPI.transfer(0x00);&#xA;  byte d16 = SPI.transfer(0x00);&#xA;  byte d17 = SPI.transfer(0x00);&#xA;  byte d18 = SPI.transfer(0x00);&#xA;  byte d19 = SPI.transfer(0x00);&#xA;  byte d20 = SPI.transfer(0x00);&#xA;  byte d21 = SPI.transfer(0x00);&#xA;  byte d22 = SPI.transfer(0x00);&#xA;  byte d23 = SPI.transfer(0x00);&#xA;  byte d24 = SPI.transfer(0x00);&#xA;  byte d25 = SPI.transfer(0x00);&#xA;  byte d26 = SPI.transfer(0x00);&#xA;  byte d27 = SPI.transfer(0x00);&#xA;  byte d28 = SPI.transfer(0x00);&#xA;  byte d29 = SPI.transfer(0x00);&#xA;  byte d30 = SPI.transfer(0x00);&#xA;  byte d31 = SPI.transfer(0x00);&#xA;  byte d32 = SPI.transfer(0x00);&#xA;&#xA;  digitalWrite(SS,HIGH);&#xA;  digitalWrite(SYN,HIGH);&#xA;  delay(499);&#xA;&#xA;  Serial.println(String(d4,BIN) + &quot; &quot; + String(d3,BIN) + &quot; &quot; +  String(d2,BIN) + &quot; &quot; +  String(d1,DEC));&#xA;  Serial.println(String(d8,BIN) + &quot; &quot; + String(d7,BIN) + &quot; &quot; +  String(d6,BIN) + &quot; &quot; +  String(d5,BIN));&#xA;  Serial.println(String(d12,BIN) + &quot; &quot; + String(d11,BIN) + &quot; &quot; +  String(d10,BIN) + &quot; &quot; +  String(d9,BIN));&#xA;  Serial.println(String(d16,BIN) + &quot; &quot; + String(d15,BIN) + &quot; &quot; +  String(d14,BIN) + &quot; &quot; +  String(d13,BIN));&#xA;  Serial.println(String(d20,BIN) + &quot; &quot; + String(d19,BIN) + &quot; &quot; +  String(d18,BIN) + &quot; &quot; +  String(d17,BIN));&#xA;  Serial.println(String(d24,BIN) + &quot; &quot; + String(d23,BIN) + &quot; &quot; +  String(d22,BIN) + &quot; &quot; +  String(d21,BIN));&#xA;  Serial.println(String(d28,BIN) + &quot; &quot; + String(d27,BIN) + &quot; &quot; +  String(d26,BIN) + &quot; &quot; +  String(d25,BIN));&#xA;  Serial.println(String(d32,BIN) + &quot; &quot; + String(d31,BIN) + &quot; &quot; +  String(d30,BIN) + &quot; &quot; +  String(d29,BIN));&#xA;  Serial.println(&quot; &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20509" LastEditorUserId="11763" LastEditDate="2016-04-29T16:01:25.370" LastActivityDate="2016-07-30T16:24:55.107" Title="STPM10 using Arduino SPI communication" Tags="|spi|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23686" PostTypeId="1" CreationDate="2016-04-29T07:42:00.360" Score="0" ViewCount="809" Body="&lt;p&gt;I'm building a &lt;a href=&quot;https://www.google.co.nz/search?q=word%20clock&amp;amp;safe=active&amp;amp;hl=en&amp;amp;biw=1920&amp;amp;bih=1089&amp;amp;site=webhp&amp;amp;tbm=isch&amp;amp;tbo=u&amp;amp;source=univ&amp;amp;sa=X&amp;amp;sqi=2&amp;amp;ved=0ahUKEwistvr-qbPMAhWIFJQKHTd6D4sQsAQIGQ&quot; rel=&quot;nofollow&quot;&gt;word clock&lt;/a&gt; and its a grid of 20x20 letters, each with its own LED (I know, its absurd for just a clock). I've recently got the LED's on a strip. Its the WS2812B type, just like the neopixels. There are 3 rolls of 5m strips and a single 1m strip. When I tried to power the 1m strip, everything worked perfectly and all looked quite lovely. But when I tried the 5m strip (just one of them), this happened: &lt;a href=&quot;https://www.dropbox.com/s/5w1lok6wa7dfvzd/IMG_0046.MOV.mov?dl=0&quot; rel=&quot;nofollow&quot;&gt;https://www.dropbox.com/s/5w1lok6wa7dfvzd/IMG_0046.MOV.mov?dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you didn't see the video I recorded of it, for a second or two after powering the arduino (uno) on, it works as expected but not long after it all stops the colors and fades to red, sometimes it just instantly jumps to it, like the second time in the video. I don't know what happened but all I can guess is that the arduino is not able to power the strip properly. Any ideas on what I should do to be able to power a total of 16m of these strips?&lt;/p&gt;&#xA;" OwnerUserId="18429" LastActivityDate="2016-05-02T07:31:12.137" Title="Arduino struggling to power a large LED strip" Tags="|arduino-uno|power|led|rgb-led|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="23687" PostTypeId="1" CreationDate="2016-04-29T10:37:08.410" Score="0" ViewCount="240" Body="&lt;p&gt;I have two arduinos (one uno and another nano) with NRF24L0 modules attached to both and they are communicating between each other. All good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I have a load of different ones and have switched them with the working receivers to test them but they just refuse to work despite the pinouts being correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the pinout vary between manufacturers or something else perhaps? What really perplexes me is that some of the modules I've tried are brand new (just taken out of the antistatic)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have followed &lt;a href=&quot;https://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/&quot; rel=&quot;nofollow&quot;&gt;https://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be really appriciated. Thanks&lt;/p&gt;&#xA;" OwnerUserId="8726" LastActivityDate="2016-04-29T20:23:11.900" Title="NRF24L0 wireless modules" Tags="|arduino-uno|nrf24l01+|wireless|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23688" PostTypeId="2" ParentId="23687" CreationDate="2016-04-29T11:59:58.863" Score="1" Body="&lt;p&gt;I was having the same kind of problems (even with new modules) when supplying them by mistake with 5v instead of 3,3V. It even happened that the system was working fine for days after the communication problems due to wrong power supply started to appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also many people have reported similar problems(sometimes communicating, sometimes not) with this module due to poor built-in decoupling especially when using relatively long cables between arduino and module. Just to make sure, put a decoupling capacitor near the module's power and ground pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(this is more of a comment but I cannot comment due to reputation.)&lt;/p&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="20645" LastEditDate="2016-04-29T20:23:11.900" LastActivityDate="2016-04-29T20:23:11.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23689" PostTypeId="1" CreationDate="2016-04-29T13:01:50.537" Score="2" ViewCount="601" Body="&lt;p&gt;Actually, i would like to control   12 motors of AX-12 using Arduino .. I could control just 2 motors. However when i send a command to the 12 motors they don't move and one or 2 of them move randomly!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;could you please help me to find solution of that ???&lt;/p&gt;&#xA;&#xA;&lt;p&gt;note : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an external power with 12 Volts and 5 amp maximum&lt;/p&gt;&#xA;" OwnerUserId="20647" LastActivityDate="2016-12-02T09:16:39.327" Title="Controlling dynamixel AX12 by Arduino" Tags="|arduino-uno|serial|arduino-mega|softwareserial|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23690" PostTypeId="1" CreationDate="2016-04-29T13:32:52.700" Score="2" ViewCount="710" Body="&lt;p&gt;I have a shield with a SIM for &lt;code&gt;GSM/GPRS&lt;/code&gt; communications and &lt;code&gt;GPS module&lt;/code&gt;.&#xA;As visible in top-left corner its name is &quot;SIM908-C EVB v1.0 designed by UNV&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZGKlT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZGKlT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some basic information on Arduino forum but they are discordant about baud rate so I tried different configuration: &lt;a href=&quot;https://forum.arduino.cc/index.php?topic=302982.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://forum.arduino.cc/index.php?topic=302982.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to use several libraries (such as &lt;code&gt;sim900&lt;/code&gt; or &lt;code&gt;tinyGPS&lt;/code&gt;) for GPRS communication or simply for getting GPS position, but without results. Shield not respond to serial commands at any baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections that I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;shield &amp;lt;--&amp;gt; aruino mega&#xA;GPRS TXD &amp;lt;--&amp;gt; D2&#xA;GPRS RXD &amp;lt;--&amp;gt; D3&#xA;GPS TXD &amp;lt;--&amp;gt; D4&#xA;GPS RXD &amp;lt;--&amp;gt; D5&#xA;GND &amp;lt;--&amp;gt; GND&#xA;5V &amp;lt;--&amp;gt; VCC_MCU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously I set D2..D5 in library according to TX/RX pins on shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried with a simply code to send AT commands and... no results again.&#xA;Here is the code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(2,3);&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    Serial.println(&quot;Begin&quot;);&#xA;    mySerial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;    if (mySerial.available())&#xA;        Serial.write(mySerial.read());&#xA;    if (Serial.available())&#xA;       mySerial.write(Serial.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Shield seems to be well powered and connected to SGM net. Infact:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;power led: is on&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;ring led: is on&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;net status: blinks one time in three seconds&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Has someone used this shield? What is a good library to use?&#xA;Every help is very appreciated.&lt;/p&gt;&#xA;" OwnerUserId="15052" LastEditorUserId="37523" LastEditDate="2019-06-30T22:29:43.403" LastActivityDate="2019-06-30T22:29:43.403" Title="How to use SIM908-C BY UNV shield" Tags="|c++|gps|" AnswerCount="0" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="23691" PostTypeId="2" ParentId="23647" CreationDate="2016-04-29T13:44:12.400" Score="3" Body="&lt;p&gt;Make sure that in &lt;code&gt;preferences&lt;/code&gt; the option &lt;code&gt;Use external editor&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; checked.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-29T13:44:12.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23692" PostTypeId="2" ParentId="23686" CreationDate="2016-04-29T14:01:23.623" Score="1" Body="&lt;p&gt;WS2812 use around 1mA when they are off. So that's already 400mA with no LED lighted. USB can supply around 500mA. So you only have 100mA available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each led package has three colored leds inside; Red, Green and Blue. Every color will use around 20mA when fully turned on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can only turn on 5 colors at full brightness at 500mA. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a 2.5A supply you could go up to 105 colors, or 35 leds full white. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would be more than enough for a word-clock, as most leds will be off.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-04-30T14:16:35.423" LastActivityDate="2016-04-30T14:16:35.423" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23694" PostTypeId="1" AcceptedAnswerId="23700" CreationDate="2016-04-29T15:54:23.123" Score="1" ViewCount="2803" Body="&lt;p&gt;Currently, I am using a Bluetooth shield, HC-05, which is working perfectly but there are two problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Only one person can connect to Bluetooth  at a time.&lt;/li&gt;&#xA;&lt;li&gt;I have to be in a specific place to be able to control the lights.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want to be able to control everything from anywhere in the world. I've thought about using an Ethernet Shield, but I'd prefer using a Wifi Shield if it can do the task.&lt;/p&gt;&#xA;" OwnerUserId="20652" LastEditorUserId="11763" LastEditDate="2016-05-01T22:19:55.130" LastActivityDate="2016-05-01T22:19:55.130" Title="Will I be able to control stuff from anywhere in the world if I use a wifi shield like ESP8266?" Tags="|wifi|esp8266|hc-05|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23695" PostTypeId="2" ParentId="23694" CreationDate="2016-04-29T15:56:37.127" Score="1" Body="&lt;p&gt;The WiFi shield connects your Arduino to your local network. What you then do with that network is entirely up to you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it easy, though? Well, if you have to ask the question then for you it won't be easy. You have to know how networks work for a start. Routing, port forwarding, client-server models, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-29T15:56:37.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23696" PostTypeId="2" ParentId="13588" CreationDate="2016-04-29T17:08:22.970" Score="0" Body="&lt;p&gt;Feed the output to a (spare) input pin and &lt;code&gt;digitalRead()&lt;/code&gt; that pin!&lt;/p&gt;&#xA;" OwnerUserId="20654" LastEditorUserId="6936" LastEditDate="2016-05-16T09:05:43.693" LastActivityDate="2016-05-16T09:05:43.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23698" PostTypeId="1" AcceptedAnswerId="23703" CreationDate="2016-04-29T17:39:15.410" Score="1" ViewCount="1236" Body="&lt;p&gt;I am in need of a sentinel value to use to assign to a double variable initially.&#xA;0 or -1 won't work because these values are valid values in my computation and I need a value that will stand out. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible choices are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Maximum double value&lt;/li&gt;&#xA;&lt;li&gt;Minimum double value&lt;/li&gt;&#xA;&lt;li&gt;NAN (I would also need a method to check is_nan as well)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How can I accomplish this in the Arduino language?&lt;/p&gt;&#xA;" OwnerUserId="13605" LastActivityDate="2016-04-29T20:21:46.447" Title="Max double value or NAN as a sentinel value?" Tags="|c++|float|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23699" PostTypeId="2" ParentId="13588" CreationDate="2016-04-29T18:39:38.440" Score="1" Body="&lt;p&gt;Majenko's answer basically explains the cause - apparently on the SAM3X8E reading the input data register will not show the state being driven on output lines in the way it would on some other devices like the AVR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the conclusion that &quot;you will have to remember the state of the pin yourself&quot; is not correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the data sheet, the output data state can be read from the relevant port's &lt;code&gt;PIO_ODSR&lt;/code&gt; register.   That the Arduino libraries don't do this could be an oversight, but probably is an efficiency decision, as they would need to examine the direction of each pin to determine the register to read for its state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would not be hard to make your own functions or macros to read the &lt;code&gt;PIO_ODSR&lt;/code&gt; - you could model them on the &lt;code&gt;digitalInput()&lt;/code&gt; ones.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-04-29T18:39:38.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23700" PostTypeId="2" ParentId="23694" CreationDate="2016-04-29T18:56:16.757" Score="3" Body="&lt;p&gt;answer on your comment on Majenko's answer:&#xA;(cannot comment due to reputation)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;build a simple web server on your device and make sure it is accessible from a local network node (e.g. a PC).To do this open from a web browser the page &lt;code&gt;ip:port&lt;/code&gt; where &lt;code&gt;ip&lt;/code&gt; is the ip assigned to arduino (usually from your router's DHCP service) and &lt;code&gt;port&lt;/code&gt; is the port which your web server listens to. This is configured in your arduino code. For an arduino Wifi shield you can find a tutorial for this step &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/WiFiWebServer&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Now you have to set up port forwarding. This means that when somebody from the internet sends a request on your router, the router will forward this request on your arduino and not on another node on your local network. The nodes on your local network are individually recognized by their IP address. Port forwarding is configured per port, so you must set up port forwarding from a specific in-port to a specific ip,local-port combination. For example if your arduino has been assigned ip 192.168.2.10 and your web server listens on port 80, you can forward all requests from port 8080 to 192.168.2.10:80. This means that every request comes from the internet on port 8080 on your router (internet side) will be forwarded on your local node on ip 192.168.2.10 and port 80. Note that for simplicity in-port and out-port can be the same and they usually are. Port forwarding is configured in your router's menu and the exact procedure is different for every modem. Your best bet is to search google for your modem's model + &lt;code&gt;port forwarding&lt;/code&gt;. If you succesfully configure this, then you will be able to load web server's page from a node outside your local network by visiting ip:port where &lt;code&gt;ip&lt;/code&gt; is your router's internet ip and port is the aforementioned in-port. A simple page to see your internet ip is &lt;a href=&quot;http://checkip.dyndns.org/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are basically the main steps to have access from internet. Further improvements could be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;solving dynamic IP issue (in order to access your arduino, you have to know your router's internet ip which can change by your ISP anytime. Buying a static IP or setting up a dynamic DNS solves this issue)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;turning your web server to &lt;em&gt;non web&lt;/em&gt; server (more advanced topic).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="20645" LastEditDate="2016-04-29T20:20:53.890" LastActivityDate="2016-04-29T20:20:53.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23703" PostTypeId="2" ParentId="23698" CreationDate="2016-04-29T20:21:46.447" Score="1" Body="&lt;p&gt;This is a matter of personal preference. I like NAN because it is almost&#xA;always obvious it cannot be a valid value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can test for the value being NAN with&#xA;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html#ga468be9ed380771eca5a18e812b2470d4&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;isnan()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-04-29T20:21:46.447" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23704" PostTypeId="1" AcceptedAnswerId="23707" CreationDate="2016-04-29T20:59:54.393" Score="0" ViewCount="794" Body="&lt;p&gt;I'm making a basic &quot;door open&quot; detector that, when a door is opened, it turns on an LED and then sounds an alarm via a piezo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is controlled via a 5v Adafruit Trinket.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is a 9v battery the correct thing to power this with, if the goal is to change batteries as infrequently as possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XPA6y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XPA6y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code, incase that's relevant.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;elapsedMillis timeElapsed;&#xA;&#xA;const int switchPin = 2;&#xA;const int ledPin = 1;&#xA;const int piezoPin = 0;&#xA;const uint32_t openLength = 5 * 1000L; // X seconds&#xA;int notes[] = {862,294,730};&#xA;&#xA;void setup() {&#xA;  pinMode(switchPin, INPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  pinMode(piezoPin, OUTPUT);&#xA;  digitalWrite(switchPin, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  if(digitalRead(switchPin) == LOW){    &#xA;    digitalWrite(ledPin, LOW);&#xA;    timeElapsed = 0;&#xA;  } else {&#xA;    digitalWrite(ledPin, HIGH);&#xA;&#xA;    if (timeElapsed &amp;gt; openLength){&#xA;      for (int n = 0; n &amp;lt; 200 ; n++){&#xA;        beep(notes[random(0,2)]);&#xA;&#xA;        if(digitalRead(switchPin) == LOW){ break; }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void beep(int delayAmount)&#xA;{&#xA;  for (uint16_t t = 0; t &amp;lt; 30*1000/2; t += delayAmount)&#xA;  {  &#xA;    digitalWrite(piezoPin,HIGH);&#xA;    delayMicroseconds(delayAmount);&#xA;    digitalWrite(piezoPin,LOW);&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I had a 9V plugged in to this for about 3 days before it used all the power in 9V. Is that an issue w/ voltage on the battery (i.e. I should be using AA's instead of a 9V)? Or does that point largely to some other inefficiency w/ the code or hardware?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-05-02T21:48:18.713" LastActivityDate="2016-05-02T21:48:18.713" Title="Is a 9v battery appropriate for a piezo and 1 LED?" Tags="|power|led|adafruit|piezo|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23705" PostTypeId="1" CreationDate="2016-04-29T21:14:41.703" Score="4" ViewCount="172" Body="&lt;p&gt;I am trying to replace a device which used a FTDI chip (&lt;a href=&quot;http://www.ftdichip.com/Drivers/D2XX.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.ftdichip.com/Drivers/D2XX.htm&lt;/a&gt;) to get USB to serial. I need some more code on the chip, so I want to use an arduino mega 2560 instead. However, there is quite a lot of software which talks to the FTDI-based solution, some of which is not maintained by myself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I write a program for arduino mega which makes it look to the PC software like I am still a FTDI chip? I am somewhat concerned, because the FTDI requires special drivers, so any software will try to use this driver to connect to the arduino, which does not have a chip that is native to the d2xx driver. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best, &#xA;Alex&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: If I am not mistaken, arduino used those FTDI chips in the past, but switched to ATmega8u2 for arduino UNO, and to ATmega16U2 for arduino mega 2560. &lt;/p&gt;&#xA;" OwnerUserId="20662" LastActivityDate="2016-04-29T21:14:41.703" Title="Can d2xx connect to an arduino mega 250?" Tags="|arduino-mega|usb|ftdi|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23707" PostTypeId="2" ParentId="23704" CreationDate="2016-04-29T21:44:11.837" Score="1" Body="&lt;p&gt;A couple things to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Get rid of the PWR LED on the Trinket so it's not always drawing current.&lt;/li&gt;&#xA;&lt;li&gt;Sleep the MCU whenever possible, only waking on interrupts.&lt;/li&gt;&#xA;&lt;li&gt;Converting 9V to 5V with an LDO (in this case, the MIC5225) implies a 55% efficiency, &lt;em&gt;max&lt;/em&gt;, which isn't great. But at least the LDO has a low ground current.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Also, ask yourself if you really need a micro for this task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want a ballpark for runtime, find the capacity of your battery, estimate your current draw, and see what your upper bound on runtime is.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-04-29T21:44:11.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23708" PostTypeId="1" CreationDate="2016-04-29T23:25:43.387" Score="1" ViewCount="149" Body="&lt;p&gt;I am trying to use a DS1307 (from Sparkfun, &lt;a href=&quot;https://www.sparkfun.com/products/12708&quot; rel=&quot;nofollow&quot;&gt;BOB-12708&lt;/a&gt;) with an Arduino Leonardo. I have connected the SDA, SCL, GND, and 5V pins from the RTC to the Arduino. However, with a CC3000 WiFi shield on the Arduino, the I2C bus hangs. Specifically, &lt;code&gt;Wire.endtransmission()&lt;/code&gt; hangs, called by &lt;code&gt;rtc.isrunning()&lt;/code&gt;. I have confirmed that it works properly on the same Arduino without the WiFi shield. I am using the ds1307 RTClib example for testing it.&lt;/p&gt;&#xA;" OwnerUserId="20663" LastActivityDate="2016-11-26T06:36:46.730" Title="DS1307 RTC not working with CC3000 WiFi shield (I2C bus hangs)" Tags="|i2c|wifi|rtc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23709" PostTypeId="2" ParentId="23694" CreationDate="2016-04-29T23:44:37.357" Score="1" Body="&lt;p&gt;If you haven't already, take a look at &lt;a href=&quot;http://www.blynk.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blynk.cc&lt;/a&gt;'s website. Blynk provides a (drag-and-drop configurable!) smartphone/tablet app and a number of skeleton programs for many platforms and interfaces including, of course, the Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In brief, your Arduino program can report data to their server, and the smartphone app can read and display that, as well as send control signals back to your board. They make it simple to accomplish basic things and quite easy to expand it to do more. The ESP8266 is a good choice for a web interface, especially if you're using an Arduino Uno or other Atmega328p-based platform, because it takes about the least amount of the MCU's limited resources of any of the compatible network interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because your Arduino program will be configured as a network client you will avoid the hassles and potential security issues of configuring your local network to allow access to internal server from outside. The Arduino sketch opens an outboud connection to their server, just as a web-browser would, so you won't need to &quot;poke holes&quot; in your router's firewall to let in your client and anyone else that wants to mess with your stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Note: I have no connection with them, but I think they have a strong platform for Internet of Things hobbyists and I use their stuff.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;Blynk supports Arduino WiFi, WiFi 101, CC3000, and ESP8266 w/original (AT) firmware. This device (Atmega328p with ESP8266) is logging temperatures from 3 DS18b20 thermo sensors to Blynk as I type this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AO7tk.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AO7tk.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-04-30T22:07:55.127" LastActivityDate="2016-04-30T22:07:55.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23710" PostTypeId="1" AcceptedAnswerId="24232" CreationDate="2016-04-29T23:57:29.887" Score="-1" ViewCount="138" Body="&lt;p&gt;I just bought a new Intel Edison and flashed the newest Yocto 3.0 image. I uploaded an Arduino program from the Arduino ide which just constantly prints out numbers to serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After uploading the code, it works. After I unplug it and plug it back in and wait 2 minutes for it to power on, I open the serial connection and the Edison does nothing like I never uploaded anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some research I found it is a problem with the firmware version 2.5 so I tried 2.1. I tried 2.1 and it still doesn't work. Am I doing anything wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the mini-breakout.&lt;/p&gt;&#xA;" OwnerUserId="16096" LastActivityDate="2016-06-14T03:20:53.327" Title="Intel Edison Program Deleted After Power Off" Tags="|edison|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23711" PostTypeId="2" ParentId="23694" CreationDate="2016-04-30T00:04:59.660" Score="1" Body="&lt;p&gt;It is definitely possible to control anywhere from the World where internet is available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @forivaras noted, there are a few accidental complexities involved in the network setup. It is nothing specific to Arduino, these come from the fact how Internet works nowadays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For start, I suggest using an ESP8266 module (instead of any other solution), which is connecting to a readily available 3rd party server (such as dweet.io and visualize with freeboard.io, or Adafruit IO, or IFTTT).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, you don't need the Arduino at all. The ESP8266 is a way more powerful than an Arduino, and yuu can program it as if it would be an Arduino plus Wifi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the hardware comes for less than $10, and you can find ready made howtos on the web such as:&#xA;&lt;a href=&quot;https://learn.adafruit.com/home-automation-in-the-cloud-with-the-esp8266-and-adafruit-io/introduction&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/home-automation-in-the-cloud-with-the-esp8266-and-adafruit-io/introduction&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This ensures a smooth start! Have fun :)&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-04-30T00:04:59.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23712" PostTypeId="2" ParentId="23708" CreationDate="2016-04-30T01:28:46.983" Score="1" Body="&lt;p&gt;It could be that the CC3000 interrupts are affecting the Wire library's behaviour since the latter is interrupt-driven itself. &#xA;Try disabling the CC3000 IRQ before calling &lt;code&gt;rtc.isrunning()&lt;/code&gt; or any other RTC functions. First &lt;code&gt;#include &quot;ccspi.h&quot;&lt;/code&gt; in your sketch. Then place &lt;code&gt;WlanInterruptDisable()&lt;/code&gt; before any &lt;code&gt;RTClib&lt;/code&gt; function call, and then &lt;code&gt;WlanInterruptEnable()&lt;/code&gt; after the RTC function returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if this works, it may affect the functionality of the CC3000, since it increases the chances of missed interrupts. You can search for DS1307 libraries that employ SoftwareI2C instead such as &lt;a href=&quot;https://github.com/kamermans/SoftDS1307RTC&quot; rel=&quot;nofollow&quot;&gt;this one&lt;/a&gt;. They should be better able to recover from the CC3000 interrupts.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-04-30T01:38:23.507" LastActivityDate="2016-04-30T01:38:23.507" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="23715" PostTypeId="1" AcceptedAnswerId="23717" CreationDate="2016-04-30T03:36:12.210" Score="3" ViewCount="4724" Body="&lt;p&gt;I'm trying to make a basic calculator with the Serial monitor but it doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a;&#xA;int b;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if (Serial.available()) {&#xA;    Serial.println(&quot;First Number: &quot;);&#xA;    a = Serial.read();&#xA;    Serial.println(&quot;Second Number: &quot;);&#xA;    b = Serial.read();&#xA;    Serial.println(a + b);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20665" LastActivityDate="2017-06-17T09:48:28.413" Title="Simple Calculator" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23717" PostTypeId="2" ParentId="23715" CreationDate="2016-04-30T04:38:14.907" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot;&gt;Serial.read()&lt;/a&gt; reads in only the first byte of the data from the serial.This is not what we want, We everything that the user has entered to be treated as an Integer and then read it into the variables. You should use &lt;a href=&quot;https://www.arduino.cc/en/Serial/ParseInt&quot;&gt;Serial.parseInt()&lt;/a&gt; for the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See the modified program below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a;&#xA;int b;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Enter the First number&quot;);&#xA;  while(!Serial.available()); // wait till the user has entered something&#xA;  a = Serial.parseInt(); // treat what the user has entered as an Integer and read the whole number&#xA;  Serial.println(&quot;Enter the second number&quot;);&#xA;  while(!Serial.available());&#xA;  b = Serial.parseInt();&#xA;  Serial.println(a+b); // Print the sum&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11992" LastActivityDate="2016-04-30T04:38:14.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23719" PostTypeId="1" CreationDate="2016-04-30T07:08:10.080" Score="-1" ViewCount="47" Body="&lt;p&gt;This is a mini project of mine, which is to be implemented in another.&#xA;Here, I'm trying to make arduino output numbers in the serial window based on the diff. buttons pressed(there are four of them in my case).&lt;br&gt;&#xA;What I want:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the initial array is 0000.&lt;/li&gt;&#xA;&lt;li&gt;if I press button one, then button three, the array should be 1010&lt;/li&gt;&#xA;&lt;li&gt;if I press button one two times, and button 4 three  times, the&#xA;resultant array should be 2003......and so on.you might have got what&#xA;I'm trying to do here.   the problem is , all I'm getting is 0000,&#xA;ALL THE TIME.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My code is below, and I'm a newbie, so any corrections(+advice?) given would be greatly appreciated.&lt;br&gt;&#xA;(Also I don't know where to print the output :P I did it in &lt;code&gt;loop()&lt;/code&gt; so it keeps on printing it :P)  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CODE:&#xA;&#xA;//the buttons:&#xA;&#xA;const int b1=8;&#xA;const int b2=9;&#xA;const int b3=10;&#xA;const int b4=11;&#xA;//variables to store previous button press and currend button press , used to eliminate switch bouncing&#xA;boolean pb1=LOW;&#xA;boolean cb1=LOW;&#xA;&#xA;boolean pb2=LOW;&#xA;boolean cb2=LOW;&#xA;&#xA;boolean pb3=LOW;&#xA;boolean cb3=LOW;&#xA;&#xA;boolean pb4=LOW;&#xA;boolean cb4=LOW;&#xA;&#xA;&#xA;//variables to store numbers:&#xA;&#xA;int w=0;  &#xA;int x=0;  &#xA;int y=0;  &#xA;int z=0;  &#xA;&#xA;int var_array [4]={w,x,y,z};  &#xA;&#xA;void setup() {  &#xA;  // put your setup code here, to run once:  &#xA;  pinMode(b1,INPUT);  &#xA;  pinMode(b2,INPUT);  &#xA;  pinMode(b3,INPUT);  &#xA;  pinMode(b4,INPUT);  &#xA;&#xA; Serial.begin(9600);   &#xA;&#xA;&#xA;}  &#xA;&#xA;boolean debounce1(boolean last)  &#xA;{  &#xA;   boolean current=digitalRead(b1);  &#xA;  if(last != current)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current=digitalRead(b1);  &#xA;      return current;    &#xA;  }  &#xA;&#xA;boolean debounce2(boolean last)  &#xA;{  &#xA;   boolean current=digitalRead(b2);  &#xA;  if(last != current)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current=digitalRead(b2);  &#xA;      return current;    &#xA;  }  &#xA;&#xA;  boolean debounce3(boolean last)  &#xA;{  &#xA;   boolean current=digitalRead(b3);  &#xA;  if(last != current)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current=digitalRead(b3);  &#xA;      return current;     &#xA;  }  &#xA;&#xA;  boolean debounce4(boolean last)  &#xA;{  &#xA;   boolean current=digitalRead(b4);  &#xA;  if(last != current)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current=digitalRead(b4);  &#xA;      return current;    &#xA;  }  &#xA;&#xA;&#xA;void loop() {  &#xA;  // put your main code here, to run repeatedly:  &#xA;  cb1=debounce1(pb1);  &#xA;  cb2=debounce2(pb2);   &#xA;  cb3=debounce3(pb3);  &#xA;  cb4=debounce4(pb4);  &#xA;&#xA;     if (pb1==LOW&amp;amp;&amp;amp;cb1==HIGH)     &#xA;   {  &#xA;      w++;  &#xA;    }  &#xA;    pb1=cb1;  &#xA;&#xA;&#xA;    if (pb2==LOW&amp;amp;&amp;amp;cb2==HIGH)     &#xA;   {  &#xA;      x++;  &#xA;    }  &#xA;    pb2=cb2;  &#xA;&#xA;&#xA;    if (pb3==LOW&amp;amp;&amp;amp;cb3==HIGH)     &#xA;   {  &#xA;      y++;  &#xA;    }  &#xA;    pb3=cb3;  &#xA;&#xA;    if (pb4==LOW&amp;amp;&amp;amp;cb4==HIGH)      &#xA;   {  &#xA;      z++;  &#xA;    }  &#xA;    pb4=cb4;  &#xA;&#xA;for(int i=0;i&amp;lt;4;i++)  &#xA;Serial.print(var_array[i]);  &#xA;&#xA;Serial.println();  &#xA;&#xA;delay(500);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20376" LastEditorUserId="19515" LastEditDate="2016-04-30T13:55:02.853" LastActivityDate="2016-04-30T15:12:00.910" Title="Error in using buttons to input numbers!" Tags="|serial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23721" PostTypeId="1" CreationDate="2016-04-30T09:13:27.873" Score="-1" ViewCount="1024" Body="&lt;p&gt;I'm trying to use the FHT librairy from (&lt;a href=&quot;http://wiki.openmusiclabs.com/wiki/ArduinoFHT&quot; rel=&quot;nofollow&quot;&gt;http://wiki.openmusiclabs.com/wiki/ArduinoFHT&lt;/a&gt;). I used the example code provided on the link, which is the following :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;FHT.h&amp;gt; // include the library&#xA;&#xA;#define LIN_OUT8  1&#xA;#define FFT_N     64&#xA;&#xA;void setup() &#xA;{&#xA;  /*Turn off timer0 for lower jitter - &#xA;    delay() and millis() killed*/&#xA;  TIMSK0 = 0;&#xA;  /*set the adc to free running mode*/&#xA;  ADCSRA = 0xe5;&#xA;  /*use adc0*/&#xA;  ADMUX = 0x40;&#xA;  /*turn off the digital input for adc0*/&#xA;  DIDR0 = 0x01;&#xA;&#xA;&#xA;  Serial.begin(115200);&#xA;&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  while(1) &#xA;  { // reduces jitter&#xA;    cli();  // UDRE interrupt slows this way down on arduino1.0&#xA;    for (int i = 0 ; i &amp;lt; FHT_N ; i++) &#xA;    { // save 256 samples&#xA;      while(!(ADCSRA &amp;amp; 0x10)); // wait for adc to be ready&#xA;      ADCSRA = 0xf5; // restart adc&#xA;      byte m = ADCL; // fetch adc data&#xA;      byte j = ADCH;&#xA;      int k = (j &amp;lt;&amp;lt; 8) | m; // form into an int&#xA;      k -= 0x0200; // form into a signed int&#xA;      k &amp;lt;&amp;lt;= 6; // form into a 16b signed int&#xA;      fht_input[i] = k; // put real data into even bins&#xA;    }&#xA;    fht_window(); // window the data for better frequency response&#xA;    fht_reorder(); // reorder the data before doing the fft&#xA;    fht_run(); // process the data in the fft&#xA;    fht_mag_lin8(); // take the output of the fft&#xA;    sei();&#xA;    Serial.write(255);&#xA;    fht_lin_ou8[0];&#xA;    Serial.write(fht_lin_out8, FHT_N/2);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get the following error:&#xA;&lt;code&gt;fht_lin_ou8' was not declared in this scope&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I canot resolve this probleme, ans help would be appreciate&lt;/p&gt;&#xA;" OwnerUserId="19648" LastActivityDate="2016-06-08T14:19:10.973" Title="FHT doesn't work with the example code" Tags="|audio|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23724" PostTypeId="2" ParentId="21254" CreationDate="2016-04-30T13:09:25.630" Score="1" Body="&lt;p&gt;Yes you can connect multiple devices on one I2C bus. Every device on the bus needs to have its own address. Some libraries have the default address included. Some do allow to change it. Others don't. For example &lt;a href=&quot;http://pdf.datasheetcatalog.com/datasheet/philips/SE95_2.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;the SE95 temperature sensor&lt;/a&gt; (page 10) does allow for setting a few bits of the address allowing more than one sensor on a bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the Wire library from Arduino to request data from &lt;a href=&quot;http://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow noreferrer&quot;&gt;I2C&lt;/a&gt;. When you want to pull data from a sensor, you have to send a command depending on the specs than request data from the address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example: for the SE95 address 0x4F (you can repeat this for any address you have a sensor on your bus) the SE95 ranges from 0x49 to 0x4F depending on the pin settings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Please note that the example is not complete because Wire has to be loaded and initialized&#xA;byte address = 0x4F;&#xA;byte read1;&#xA;byte read2;&#xA;Wire.beginTransmission(address);&#xA;Wire.write(0x00);&#xA;Wire.requestFrom(int(address), 2);&#xA;if(Wire.available()) {&#xA;  read1 = Wire.read();&#xA;  read2 = Wire.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So depending on the libraries, this would be quite easy.&lt;/p&gt;&#xA;" OwnerUserId="20548" LastEditorUserId="4628" LastEditDate="2016-12-27T12:25:07.173" LastActivityDate="2016-12-27T12:25:07.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23727" PostTypeId="2" ParentId="23704" CreationDate="2016-04-30T14:48:33.417" Score="0" Body="&lt;p&gt;You can power the Trinket (ATTiny85) from as little as 2.7 volt. So you could power it by connecting 2 (or 3) AA-batteries directly to the 5V pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a 9V battery means you would &quot;throw away&quot; 4 of the 9 Volts to get 5Volt. So you'd waste almost half of the capacity of the battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a 9V battery only has around 500mAh, where as an AA battery has 2500mAh.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-04-30T14:48:33.417" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23728" PostTypeId="2" ParentId="23719" CreationDate="2016-04-30T15:04:52.577" Score="1" Body="&lt;p&gt;In your C program all the variables including the array occupy their own space in memory.  In the line &quot;int var_array [4]={w,x,y,z};&quot; all you did was create 4 more variables (elements of the array var_array) in memory and initialized them to the values found in variables (w, x, y &amp;amp; z) in a different part of memory.  So when you incremented the variables in memory pointed to by the names w, x, y and z... you did nothing to the variables in memory pointed to by the elements of the var_array.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, in this program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main()&#xA;{&#xA; int w=0;&#xA; int x=1;&#xA; int y=2;&#xA; int z=3;&#xA;&#xA; int var_array [4]={w,x,y,z};&#xA;&#xA; printf(&quot;w %d x %d y %d z %d\n&quot;,w,x,y,z);&#xA; printf(&quot;var_array %d %d %d %d\n&quot;, var_array[0],var_array[1],var_array[2],var_array[3]);&#xA;&#xA; w += 1;&#xA; x += 2;&#xA; y += 4;&#xA; z += 5;&#xA;&#xA; printf(&quot;w %d x %d y %d z %d\n&quot;,w,x,y,z);&#xA; printf(&quot;var_array %d %d %d %d\n&quot;, var_array[0],var_array[1],var_array[2],var_array[3]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output is this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w 0 x 1 y 2 z 3&#xA;var_array 0 1 2 3&#xA;w 1 x 3 y 6 z 8&#xA;var_array 0 1 2 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice how the array values do not change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to do this, you need to make the array var_array an array of pointers and point each element to each variable (w, x, y &amp;amp; z).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;main()&#xA;{&#xA; int w=0;&#xA; int x=1;&#xA; int y=2;&#xA; int z=3;&#xA;&#xA; int * var_array [4]={&amp;amp;w,&amp;amp;x,&amp;amp;y,&amp;amp;z};&#xA;&#xA; printf(&quot;w %d x %d y %d z %d\n&quot;,w,x,y,z);&#xA; printf(&quot;var_array %d %d %d %d\n&quot;, *var_array[0],*var_array[1],*var_array[2],*var_array[3]);&#xA;&#xA; w += 1;&#xA; x += 2;&#xA; y += 4;&#xA; z += 5;&#xA;&#xA; printf(&quot;w %d x %d y %d z %d\n&quot;,w,x,y,z);&#xA; printf(&quot;var_array %d %d %d %d\n&quot;, *var_array[0],*var_array[1],*var_array[2],*var_array[3]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now produces this output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;w 0 x 1 y 2 z 3&#xA;var_array 0 1 2 3&#xA;w 1 x 3 y 6 z 8&#xA;var_array 1 3 6 8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-04-30T15:12:00.910" LastActivityDate="2016-04-30T15:12:00.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23729" PostTypeId="1" CreationDate="2016-04-30T16:01:21.577" Score="-2" ViewCount="102" Body="&lt;p&gt;I have written the following code for a project comprising an ultrasonic&#xA;distance sensor, a buzzer and a few buttons. When the distance is less&#xA;than 60&amp;nbsp;cm, the buzzer rings and stops only when the appropriate&#xA;passcode is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to compile it, I get:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;exit status 1&lt;br&gt;&#xA;  Error compiling for board Arduino/Genuino Uno.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This does not give the &lt;strong&gt;reason&lt;/strong&gt; for the compilation failure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is below, any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include&amp;lt;NewPing.h&amp;gt;  &#xA;&#xA;&#xA;int r;  &#xA;boolean ctr;&#xA;&#xA;#define TRIGGER_PIN  10  // Arduino pin tied to trigger pin on the ultrasonic sensor.  &#xA;#define ECHO_PIN     9  // Arduino pin tied to echo pin on the ultrasonic sensor.  &#xA;#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.  &#xA;&#xA;NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.  &#xA;&#xA;&#xA;//the buttons:  &#xA;&#xA;const int SPEAKER=8;  &#xA;&#xA;const int b1=4;  &#xA;const int b2=5;  &#xA;const int b3=6;  &#xA;const int b4=7;  &#xA;//variables to store previous button press and currend button press , used to eliminate switch bouncing  &#xA;boolean pb1=LOW;  &#xA;boolean cb1=LOW;  &#xA;&#xA;boolean pb2=LOW;  &#xA;boolean cb2=LOW;  &#xA;&#xA;boolean pb3=LOW;  &#xA;boolean cb3=LOW;  &#xA;&#xA;boolean pb4=LOW;  &#xA;boolean cb4=LOW;  &#xA;&#xA;&#xA;//variables to store numbers:  &#xA;&#xA;int w=0;  &#xA;int x=0;  &#xA;int y=0;  &#xA;int z=0;  &#xA;&#xA;&#xA;&#xA;void setup() {  &#xA;  // put your setup code here, to run once:  &#xA;  pinMode(b1,INPUT);  &#xA;  pinMode(b2,INPUT);  &#xA;  pinMode(b3,INPUT);  &#xA;  pinMode(b4,INPUT);  &#xA;&#xA; Serial.begin(9600);   &#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;boolean debounce1(boolean last1)  &#xA;{  &#xA;   boolean current1=digitalRead(b1);  &#xA;  if(last1 != current1)  &#xA;  {  &#xA;       delay(5);  &#xA;    }  &#xA;      current1=digitalRead(b1);  &#xA;      return current1;    &#xA;  }  &#xA;&#xA;boolean debounce2(boolean last2)  &#xA;{  &#xA;   boolean current2=digitalRead(b2);  &#xA;  if(last2 != current2)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current2=digitalRead(b2);  &#xA;      return current2;    &#xA;  }  &#xA;&#xA;  boolean debounce3(boolean last3)  &#xA;{  &#xA;    boolean current3=digitalRead(b3);  &#xA;  if(last3 != current3)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current3=digitalRead(b3);  &#xA;      return current3;    &#xA;  }  &#xA;&#xA;  boolean debounce4(boolean last4)  &#xA;{  &#xA;   boolean current4=digitalRead(b4);  &#xA;  if(last4 != current4)  &#xA;  {  &#xA;      delay(5);  &#xA;    }  &#xA;      current4=digitalRead(b4);  &#xA;      return current4;    &#xA;  }  &#xA;&#xA;boolean distance(int o)  &#xA;{  &#xA;  boolean control;  &#xA;  if (o&amp;lt;60)  &#xA;    control=true;  &#xA;    return control;  &#xA;  }  &#xA;&#xA;&#xA;&#xA;void loop() {  &#xA;  // put your main code here, to run repeatedly:  &#xA;  cb1=debounce1(pb1);  &#xA;  cb2=debounce2(pb2);  &#xA;  cb3=debounce3(pb3);  &#xA;  cb4=debounce4(pb4);  &#xA;&#xA;     if (pb1==LOW&amp;amp;&amp;amp;cb1==HIGH)     &#xA;   {  &#xA;      w++;  &#xA;    }  &#xA;    pb1=cb1;  &#xA;&#xA;&#xA;    if (pb2==LOW&amp;amp;&amp;amp;cb2==HIGH)     &#xA;   {  &#xA;      x++;  &#xA;    }  &#xA;    pb2=cb2;  &#xA;&#xA;&#xA;    if (pb3==LOW&amp;amp;&amp;amp;cb3==HIGH)     &#xA;   {&#xA;      y++;  &#xA;    }  &#xA;    pb3=cb3;  &#xA;&#xA;    if (pb4==LOW&amp;amp;&amp;amp;cb4==HIGH)     &#xA;   {  &#xA;      z++;  &#xA;    }  &#xA;    pb4=cb4;  &#xA;&#xA;    delay(50);  &#xA;    unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds   (uS).  &#xA;&#xA;    Serial.print(uS / US_ROUNDTRIP_CM);  &#xA;    Serial.print(&quot; &quot;);  &#xA;     int r=uS / US_ROUNDTRIP_CM;  &#xA;&#xA;     ctr=distance(r);  &#xA;&#xA;  if(ctr==true)  &#xA;    tone(SPEAKER,1000);  &#xA;&#xA;Serial.print(w);  &#xA;Serial.print(x);  &#xA;Serial.print(y);  &#xA;Serial.print(z);  &#xA;&#xA;&#xA;Serial.println();  &#xA;&#xA;delay(100);  &#xA;if(w==1&amp;amp;&amp;amp;x==3&amp;amp;&amp;amp;y==3&amp;amp;&amp;amp;z==1)  &#xA;  noTone(SPEAKER);  &#xA;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20376" LastEditorUserId="7508" LastEditDate="2016-04-30T17:50:27.867" LastActivityDate="2016-04-30T17:50:27.867" Title="Compilation fails with non-explicit error message" Tags="|sensors|compile|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23730" PostTypeId="1" CreationDate="2016-04-30T16:03:46.187" Score="0" ViewCount="998" Body="&lt;p&gt;How can I include &lt;code&gt;mysql.h&lt;/code&gt; library in IDE of Arduino to connect Arduino to mysql database by using GSM shield?&lt;/p&gt;&#xA;" OwnerUserId="20681" LastEditorUserId="19515" LastEditDate="2016-04-30T23:17:13.033" LastActivityDate="2016-06-01T15:55:14.270" Title="How can I connect mysql with Arduino using GSMshield" Tags="|arduino-uno|gsm|" AnswerCount="2" CommentCount="1" ClosedDate="2016-06-04T05:32:08.107" ContentLicense="CC BY-SA 3.0" />
  <row Id="23733" PostTypeId="2" ParentId="23729" CreationDate="2016-04-30T17:05:08.633" Score="0" Body="&lt;p&gt;There is a reason. There is always a reason. You may just have to scroll back in the output panel to see it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Tone.cpp:536: multiple definition of `__vector_7'&#xA;NewPing/NewPing.cpp:284: first defined here&#xA;collect2: error: ld returned 1 exit status&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case it is that you are using &lt;code&gt;NewPing.h&lt;/code&gt; and &lt;code&gt;tone()&lt;/code&gt;.  Both of them use the same timer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't use both &lt;code&gt;tone()&lt;/code&gt; and the &lt;code&gt;NewPing.h&lt;/code&gt; library together without first making one of them use a different timer or no timer at all.  The easiest is the &lt;code&gt;NewPing.h&lt;/code&gt; library. As it says in the header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TIMER_ENABLED true      // Set to &quot;false&quot; to disable the timer ISR (if getting &quot;__vector_7&quot; compile errors set this to false). Default=true&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So edit that header file and set &lt;code&gt;true&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; for that line and it should start working.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-30T17:05:08.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23734" PostTypeId="2" ParentId="23730" CreationDate="2016-04-30T17:45:51.580" Score="2" Body="&lt;p&gt;You can't. Arduino is too small to run &lt;code&gt;libmysqlclient&lt;/code&gt; directly. There are few other solutions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can expose your database using REST API and call that.&lt;/li&gt;&#xA;&lt;li&gt;Change hardware platform to Raspberry Pi - it runs full Linux system&lt;/li&gt;&#xA;&lt;li&gt;Run your app on PC and call Arduino using some RPC library&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-04-30T17:45:51.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23736" PostTypeId="1" AcceptedAnswerId="23737" CreationDate="2016-04-30T18:50:54.680" Score="1" ViewCount="2961" Body="&lt;p&gt;I was working with my arduino clone and that was working well till last night.&#xA;I was trying to add l298p motor shield and after a few times of testing without any achievement, my PC suddenly did not recognize the arduino.&#xA;The device status in device manager is :  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Windows has stopped this device because it has reported problems. (Code 43)&#xA;A request for the USB device descriptor failed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should I do now??&#xA;My OS is windows 8.1&lt;/p&gt;&#xA;" OwnerUserId="20685" LastEditorUserId="612" LastEditDate="2018-04-27T04:09:07.837" LastActivityDate="2019-07-16T04:05:25.107" Title="Arduino Clone - A request for the USB device descriptor failed" Tags="|clones|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="23737" PostTypeId="2" ParentId="23736" CreationDate="2016-04-30T20:52:19.937" Score="1" Body="&lt;p&gt;You have a cheap Chinese clone with a CH340T USB interface chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are notoriously bad chips. It will have died.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can fix it (temporarily) by replacing the CH340T with another - though it's anyone's guess how long that'll last.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also continue using your board as it is now by either programming the chip directly through ICSP or keep using the bootloader but via an external USB to TTL Serial adapter connected to pins 0/1 + RESET (via a capacitor to DTR) as if it were a &quot;breadboard&quot; Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the price you pay for buying cheap Chinese clones. They may seem like a good idea at the time, but unless you are willing to treat them very much as a throw-away item they are not always the value they appear.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next time buy a genuine Arduino or an Arduino compatible from a reputable manufacturer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-30T20:52:19.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23738" PostTypeId="1" AcceptedAnswerId="23739" CreationDate="2016-04-30T22:52:52.823" Score="-1" ViewCount="644" Body="&lt;p&gt;I'm trying to make a line following robot for my students, the problem is that I have not done any calculations (I don't know how).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor can't move the robot unless I connect it directly to the 9 V power supply, but when i connect the other compenents(arduino) in parralel to the same 9v powersuply the motor doesn't get enough current when put on the floor so it just freeze's.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where do you think should i start ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transistor I used is: NPN C1815&#xA;the motor is a brushed dc motor&#xA;&lt;a href=&quot;https://i.stack.imgur.com/7D1eU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7D1eU.png&quot; alt=&quot;schematic line following robot&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Nezrr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Nezrr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20686" LastEditorUserId="20631" LastEditDate="2016-05-01T11:59:40.880" LastActivityDate="2016-05-02T16:27:40.097" Title="Low current in a motor used in a line following robot" Tags="|motor|current|robotics|" AnswerCount="1" CommentCount="20" ContentLicense="CC BY-SA 3.0" />
  <row Id="23739" PostTypeId="2" ParentId="23738" CreationDate="2016-04-30T23:41:32.543" Score="0" Body="&lt;p&gt;Due to only a tiny amount of gearing (what is it - 2:1? 3:1? something like that) your motor is operating near the stall point unless it is able to pick up enough speed (at which point it would smash into the nearest wall and pulverise itself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently it is drawing far more current from the battery than you'd like.  And that is, without the Arduino connected, about all the puny little PP3 battery can provide.  Add the Arduino etc into the mix and you are over-stepping your current budget by enough to mean the motor cannot start turning (the 1A stall current).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what to do? Well, two options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use a bigger battery.&lt;/li&gt;&#xA;&lt;li&gt;Increase the gearing of the motor.&lt;/li&gt;&#xA;&lt;li&gt;(my personal recommendation) Do both.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Increasing the gearing of the motor will decrease maximum output speed, increase the torque, and most importantly, decrease the start-up current. The whole load on the motor will be reduced making it much easier to start.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By increasing the power of the battery (use a 2S or 3S Li-Ion depending on what your motor's voltage limits are) you have a much bigger current budget to play with.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-04-30T23:41:32.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23741" PostTypeId="2" ParentId="23684" CreationDate="2016-05-01T02:44:47.207" Score="1" Body="&lt;p&gt;The STPM10 specification describes a SPI bus unlike any I have seen.  Apparently the STPM10 &quot;SYN&quot; line controls the direction of the &quot;SDA&quot; line.  As far as I know, there is no &quot;SYN&quot; line in a SPI bus.  As such I do not think a normal Arduino SPI library will talk to an STPM10.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A normal single port (MOSI and MISO combined) SPI slave would automatically switch between reading and writing bits.  When interfacing with a two port master (such as an Arduino) a resistor is used between the MISO and MOSI nets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the best image I could find.  Ignore the chip names.  And substitute MOSI for SDO and MISO for SDI.  Note there is no &quot;SYN&quot; line in this SPI bus.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lf60O.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lf60O.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm showing this diagram as it appears the STPM10 is using a single line for both input and output data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the missing &quot;SYN&quot; line I do not think you can even use the SPI hardware in the Arduino's Atmel processor.  I think your only option is to create a SPI driver from scratch only using software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see where STMicroelectronics offers an evaluation software package that talks to the STPM10.  Guessing, it looks like they wrote it in National Instruments Lab View.  If you could get the source code for that it may provide hints on writing your own STPM10 driver.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-01T02:44:47.207" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23742" PostTypeId="2" ParentId="23684" CreationDate="2016-05-01T04:18:54.757" Score="1" Body="&lt;p&gt;Like the datasheet says, its best if you implement writing in software and use the hardware SPI for reading. The steps for writing to the registers are as follows:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;disable the SPI peripheral;&lt;/li&gt;&#xA;  &lt;li&gt;set MISO, SCLK and SS to be output;&lt;/li&gt;&#xA;  &lt;li&gt;set the pin which is connected to SYN to be output high;&lt;/li&gt;&#xA;  &lt;li&gt;activate SCS first and then SYN;&lt;/li&gt;&#xA;  &lt;li&gt;activate SCL;&lt;/li&gt;&#xA;  &lt;li&gt;apply a bit value to SDA and deactivate SCL;&lt;/li&gt;&#xA;  &lt;li&gt;repeat the last two steps seven times to complete one byte transfer;&lt;/li&gt;&#xA;  &lt;li&gt;repeat the last three steps for any remaining byte transfer;&lt;/li&gt;&#xA;  &lt;li&gt;deactivate SYN and the SCS;&lt;/li&gt;&#xA;  &lt;li&gt;enable again the SPI module;&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In Arduino-speak:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define SCS 4  // define your own CS to have better control&#xA;&#xA;void setup(){&#xA;  pinMode(SS, OUTPUT);  //needed to use the SPI&#xA;&#xA;  pinMode(SCS, OUTPUT);  // set SCS and SYN as output&#xA;  pinMode(SYN, OUTPUT);&#xA;  digitalWrite(SCS, HIGH);  // idle state&#xA;  digitalWrite(SYN, HIGH);&#xA;  SPI.beginTransaction(SPISettings(32000000, MSBFIRST, SPI_MODE3)) // mode 3, max read clock is 32mhz&#xA;}&#xA;&#xA;void write_reg(byte addr, byte val){&#xA;  val = (val &amp;lt;&amp;lt; 7) | (addr &amp;lt;&amp;lt; 1);  // 6-bit addresses!&#xA;  SPI.end();  // disable SPI&#xA;  pinMode(MISO, OUTPUT);&#xA;  digitalWrite(SYN, HIGH);&#xA;  delayMicroseconds(10);&#xA;&#xA;  digitalWrite(SCS, LOW);  // assert SCS and SYN&#xA;  digitalWrite(SYN, LOW);&#xA;  for (int i = 0; i &amp;lt; 8; i++){  // shift out a byte&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(SCK, LOW);  // max clock is 100kHz&#xA;    digitalWrite(MISO, (val &amp;amp; 0x80) ? HIGH : LOW);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(SCK, HIGH);&#xA;    val &amp;lt;&amp;lt;= 1;&#xA;  }&#xA;&#xA;  digitalWrite(SYN, HIGH); // deassert SCS and SYN&#xA;  digitalWrite(SCS, HIGH);&#xA;&#xA;  SPI.beginTransaction(SPISettings(32000000, MSBFIRST, SPI_MODE3)); //restart SPI&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For reading, you use the hardware SPI like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void read_regs(uint32_t data[], uint8_t len){  // an array to hold register data is passed&#xA;  digitalWrite(SYN, LOW);  // latching operation&#xA;  digitalWrite(SCS, LOW);&#xA;  digitalWrite(SYN, HIGH);&#xA;&#xA;  uint32_t val = 0;&#xA;  for (int i = 0; i &amp;lt; len; i++){  // read the 8 32-bit registers into the array&#xA;    val = SPI.transfer(0);  // your 32 serial clocks&#xA;    val |= (uint32_t)SPI.transfer(0) &amp;lt;&amp;lt; 8;&#xA;    val |= (uint32_t)SPI.transfer(0) &amp;lt;&amp;lt; 16;&#xA;    val |= (uint32_t)SPI.transfer(0) &amp;lt;&amp;lt; 24;&#xA;    data[i] = val;&#xA;  }&#xA;&#xA;  digitalWrite(SCS, HIGH);  // deassert SCS&#xA;}&#xA;&#xA;// Use the functions this way:&#xA;&#xA;uint32_t reg_data[8];  // array to hold read data, max is 8&#xA;&#xA;void loop(){&#xA;  write_reg(47, 1);  // set config bit 47&#xA;  read_regs(reg_data, 8);  // read all reg data into array&#xA;&#xA;  for (int i = 0; i &amp;lt; 8; i++)&#xA;    Serial.println(reg_data[i], HEX);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The connections are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino MISO = SDA&#xA;Arduino SCK = SCL&#xA;Arduino D4 = SCS&#xA;Arduino D5 = SYN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each call of &lt;code&gt;SPI.transfer()&lt;/code&gt; yields 8 serial clocks i.e. a clock for each bit, so 32 serial clocks is merely 4 &lt;code&gt;SPI.transfer()&lt;/code&gt; calls. Your code is actually producing 32 x 8 = 256 serial clocks. I suggest you read up on SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I didn't include some of the delays in the datasheet because &lt;code&gt;digitalWrite()&lt;/code&gt; on an Uno takes about 5us which is more than enough for this case. Of course, the code is untested so...I've done most of your work already, almost feels like I should be getting paid or something...&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-05-01T12:45:56.950" LastActivityDate="2016-05-01T12:45:56.950" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23743" PostTypeId="1" AcceptedAnswerId="51488" CreationDate="2016-05-01T04:41:32.270" Score="3" ViewCount="2548" Body="&lt;p&gt;Is there any way to get the current Git tag/commit identifier into an Arduino sketch binary?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For normal desktop program development, you can pull some tricks with the Makefile (as pointed out in &lt;a href=&quot;https://stackoverflow.com/a/6526504/1480315&quot;&gt;this StackExchange answer&lt;/a&gt;). However, there is no Makefile for an Arduino sketch. Right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could make a batch file that I run before every compile, but there is the very real possibility I will forget to run it, and incorrect version information is worse than no version information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment, I am using the preprocessor macros &lt;code&gt;__DATE__&lt;/code&gt; and &lt;code&gt;__TIME__&lt;/code&gt; to try and identify what version is running on the board. This works, but tracking backwards from a compile date/time to a source control commit is more guesswork than anything.&lt;/p&gt;&#xA;" OwnerUserId="20693" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2020-03-10T09:03:15.820" Title="Include Git tag (or SVN revision) in Arduino sketch?" Tags="|programming|sketch|version-control|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23745" PostTypeId="2" ParentId="23743" CreationDate="2016-05-01T07:35:29.330" Score="1" Body="&lt;p&gt;I'm not sure what the commit ID would prove. I use git for source control for my Arduino sketches, but a particular upload might be halfway between the previous commit and the next one. That is, the code on the board might not match any particular commit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The date/time would at least identify approximately where in the commit stream the code is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A possibility would be to run a cron job that periodically (say, every minute) updates a .h file with the current commit ID from the branch, and include that in the sketch.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-01T07:35:29.330" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23746" PostTypeId="1" AcceptedAnswerId="23787" CreationDate="2016-05-01T08:16:59.880" Score="3" ViewCount="127" Body="&lt;p&gt;I want to start programming with the Arduino Uno, but I don't know where to start or what a good start is. I can program a bit in c#, but I red that you have to program in c++. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea's where to start?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20695" LastEditorUserId="19515" LastEditDate="2016-05-01T14:17:23.420" LastActivityDate="2016-05-02T11:00:33.507" Title="I want to begin with arduino programming" Tags="|arduino-uno|" AnswerCount="3" CommentCount="5" ClosedDate="2016-05-05T19:43:35.433" ContentLicense="CC BY-SA 3.0" />
  <row Id="23747" PostTypeId="1" CreationDate="2016-05-01T09:02:15.470" Score="0" ViewCount="2646" Body="&lt;p&gt;I am working on esp8266 module with arduino uno board.  This is my program.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define DEBUG true&#xA;&#xA;SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;                             // and the RX line from the esp to the Arduino's pin 3&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); // your esp's baud rate might be different&#xA;   Serial.print(&quot;START&quot;);&#xA;  pinMode(11,OUTPUT);&#xA;  digitalWrite(11,LOW);&#xA;&#xA;  pinMode(12,OUTPUT);&#xA;  digitalWrite(12,LOW);&#xA;&#xA;  pinMode(13,OUTPUT);&#xA;  digitalWrite(13,LOW);&#xA;&#xA;  sendData(&quot;AT+RST\r\n&quot;,2000,DEBUG); // reset module&#xA;  sendData(&quot;AT+CWMODE=2\r\n&quot;,1000,DEBUG); // configure as access point&#xA;  sendData(&quot;AT+CIFSR\r\n&quot;,1000,DEBUG); // get ip address&#xA;  sendData(&quot;AT+CIPMUX=1\r\n&quot;,1000,DEBUG); // configure for multiple connections&#xA;  sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;,1000,DEBUG); // turn on server on port 80&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if(esp8266.available()) // check if the esp is sending a message &#xA;  {&#xA;&#xA;&#xA;    if(esp8266.find(&quot;+IPD,&quot;))&#xA;    {&#xA;     delay(1000); // wait for the serial buffer to fill up (read all the serial data)&#xA;     // get the connection id so that we can then disconnect&#xA;     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns &#xA;                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48&#xA;&#xA;     esp8266.find(&quot;pin=&quot;); // advance cursor to &quot;pin=&quot;&#xA;&#xA;     int pinNumber = (esp8266.read()-48)*10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10&#xA;     pinNumber += (esp8266.read()-48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number&#xA;&#xA;     digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin    &#xA;&#xA;     // make close command&#xA;     String closeCommand = &quot;AT+CIPCLOSE=&quot;; &#xA;     closeCommand+=connectionId; // append connection id&#xA;     closeCommand+=&quot;\r\n&quot;;&#xA;&#xA;     sendData(closeCommand,1000,DEBUG); // close connection&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;/*&#xA;* Name: sendData&#xA;* Description: Function used to send data to ESP8266.&#xA;* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)&#xA;* Returns: The response from the esp8266 (if there is a reponse)&#xA;*/&#xA;String sendData(String command, const int timeout, boolean debug)&#xA;{&#xA;    String response = &quot;&quot;;&#xA;&#xA;    Serial.println(esp8266.print(command)); // send the read character to the esp8266&#xA;&#xA;    long int time = millis();&#xA;    while( (time+timeout) &amp;gt; millis())&#xA;    {&#xA;&#xA;      while(esp8266.available())&#xA;      {&#xA;        Serial.print(&quot;Coming&quot;);&#xA;&#xA;        // The esp has data so display its output to the serial window &#xA;        char c = esp8266.read(); // read the next character.&#xA;        response+=c;&#xA;      }  &#xA;    }&#xA;&#xA;&#xA;&#xA;    if(debug)&#xA;    {&#xA;      Serial.print(response);&#xA;    }&#xA;&#xA;    return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the problem is  i am not getting any output from esp module but arduino is transmitting the data.  power supply for esp is given by 3.3v regulator (LD3.3)feeding 12v from arduino power supply adapter  to regulator input .&#xA;TX esp to rx arduino &#xA;arduino tx to esp rx by voltage divider (R1=1k and R2=1.8k)&#xA;esp gnd  to arduino gnd&#xA;chpd and esp vin are 3.3v from regulator&#xA;Can anyone tell me where the problem is ?&lt;/p&gt;&#xA;" OwnerUserId="20726" OwnerDisplayName="Pradeep kumark" LastEditorUserId="313" LastEditDate="2016-05-01T13:07:06.720" LastActivityDate="2016-05-01T13:07:06.720" Title="Esp 8266 doesn't reply to AT commands" Tags="|esp8266|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23748" PostTypeId="2" ParentId="23747" CreationDate="2016-05-01T10:10:53.600" Score="1" Body="&lt;p&gt;Try powering the ESP from an external 3.3V power supply if possible - some people say the Arduino 3.3V regulator may not provide enough power for it (it is quite power hungry at startup).  &lt;br&gt;&#xA;Another option worth trying is to put a 100uF capacitor between ESP VCC and GND. Put some small delay at the beginning of your &lt;code&gt;setup()&lt;/code&gt; function if you do that just in case.  &lt;br&gt;&#xA;Also, there are several pins you need to pull UP: CH_PD, RESET, GPIO0. If you have GPIO15 broken out (depends on the board), pull it to ground. I have also noticed the ESP won't boot properly if GPIO2 is LOW - either leave it floating or pull it up.  &lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/esp8266/Arduino/blob/master/doc/ESP_improved_stability.png&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a picture you can use as a guide  &lt;br&gt;&#xA;Of course, you should make sure the ESP is flashed with the AT commands firmware (they usually are) and your baud rate is correct. If you don't know - try 9600, 57600, 115200.  &lt;br&gt;&#xA;If you have a USB to TTL converter, it might be better (easier) to test your setup using it, without Arduino. Any serial terminal program (including Arduino IDE Serial Monitor) will be fine. Just make sure you send both CR and LF for new lines. If you send &quot;AT&quot; and receive &quot;OK&quot; your wiring is correct, if you don't - it is not.&lt;/p&gt;&#xA;" OwnerUserId="20696" LastActivityDate="2016-05-01T10:10:53.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23749" PostTypeId="2" ParentId="23746" CreationDate="2016-05-01T10:41:50.810" Score="1" Body="&lt;p&gt;Welcome to the world of Arduino. You can start by going directly to the Arduino Site -&gt; &lt;a href=&quot;http://www.arduino.cc/en/Guide/HomePage&quot; rel=&quot;nofollow&quot;&gt;Learning &amp;amp; tutorials&lt;/a&gt;. Also the internet full of 100's, if not 1000's of information and tutorials.&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2016-05-01T10:41:50.810" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23750" PostTypeId="1" CreationDate="2016-05-01T10:45:55.817" Score="1" ViewCount="1561" Body="&lt;p&gt;My quite new Nano clone (ATmega328P + CH340G) suddenly stopped working. Plugging it in with USB did not light up the LED(s) nor did it get detected by my machine. I looked it up, and found some how-to's (such as this one: &lt;a href=&quot;http://www.instructables.com/id/Repair-Arduino-Nano-no-power-on-USB-1/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Repair Arduino Nano (no power on USB)&lt;/a&gt;), which suggested at least some diagnostics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I plugged the Nano in to a 5V breadboard power source using the Vin and GND pins, and the power LED lights up, but connecting via USB cable to my machine does not detect it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So then I used some of the methods mentioned in the link, and used just a normal jumper cable (without soldering) to check if that could magically make it detectable by my machine. No luck. I tried bypassing the voltage regulator by &quot;jumping&quot; over it, and the power LED gets brighter, and &quot;pin 13&quot; LED flashes for just an instant. The same occurs if I &quot;jump&quot; the voltage regulator all the way to either end of what I am guessing is the &quot;Schottky diode&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all cases, still nothing in terms of being detected by my computer. The cable is fine because I tested with another nano clone, and it gets detected right away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do I properly diagnose what is going on here? Specifically how do I fix my poor board? How do I find which component is in need of replacing?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some online guides on how to have another Arduino board talk to this one over &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample&quot; rel=&quot;nofollow noreferrer&quot;&gt;SoftwareSerial&lt;/a&gt; and found that I could get some data flowing through. However, the text was garbled, such that, for example if I was expecting it to say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Please enter some input&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It might read instead:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;Ulease XYZter some [][]put&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Often with the same characters being garbled in the same way. I tested the Schottky diode the way it was suggested in the video (with some guessing as to the multimeter setting I had to use was, since I have a different model than the one in the video), and it seems the diode is fine. So at this point I am guessing it is the ch340g chip that is toasty, either that, or the ATmega chip itself, which I don't know, but that sounds less likely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, could it be that it is the CH340G chip, since I get no power over USB, and the TX/RX over serial is being interfered with? Is there anything else I can do to figure out if it is the CH340G that's damaged before I go about trying to replace it?&lt;/p&gt;&#xA;" OwnerUserId="19157" LastEditorUserId="4628" LastEditDate="2017-12-27T17:43:56.597" LastActivityDate="2018-03-27T20:28:34.090" Title="Nano clone not working over USB, no data, no power, but can power via Vin (CH340 chip? schottky diode?)" Tags="|arduino-nano|atmega328|ch340|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="23751" PostTypeId="1" AcceptedAnswerId="23753" CreationDate="2016-05-01T12:16:11.250" Score="1" ViewCount="10920" Body="&lt;p&gt;Good day.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have successfully built and tested an Arduino-on-breadboard about 2 days ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device is rather straight forward, I have added a voltage divider and an LED to indicate power. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The schematics are as follows:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/xKaet.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xKaet.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is a picture of the actual board:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VCtKq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VCtKq.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an ATMega328P-PU as a Microcontroller chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded quite a few sketches on the board and all seemed to work well. I was trying to upload a sketch yesterday but I got:&#xA; &lt;strong&gt;&quot;avrdude: Yikes! invalid device signature&quot;&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I rebooted the computer, rebuilt the entire board again, and tried once again to load a sketch using Arduino as ISP. The message changed again to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;avrdude: Expected signature for ATmega328P is 1E 95 0F&#xA;         Double check chip, or use -F to override this check.&#xA;Wrong microcontroller found.  Did you select the right board from the Tools &gt; Board menu?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a search online and I have found many forums suggesting that I change the avrdude.conf file parameters to different signatures &quot;Although these are mainly targeted at people using ATMega328-PU, not ATMega328P-PU&quot; but this also did not help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried burning the bootloader again but I still get the same error message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to find a way to &quot;retrieve&quot; the chip signature, but I didn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there is a chance that I have bricked the chip somehow, but how do I know for sure? and is there anyway that one can use and Arduino as a tool to retrieve the chip signature or verify if the chip itself is dead?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You&lt;/p&gt;&#xA;" OwnerUserId="19815" LastEditorUserId="19815" LastEditDate="2016-05-01T12:21:21.040" LastActivityDate="2020-11-22T18:43:04.990" Title="Using Arduino UNO to retrieve ATMega328P-PU chip signature" Tags="|arduino-uno|atmega328|avrdude|arduinoisp|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23752" PostTypeId="1" AcceptedAnswerId="23754" CreationDate="2016-05-01T13:31:14.573" Score="0" ViewCount="84" Body="&lt;p&gt;&lt;em&gt;EDIT: My original question was a bit &quot;off&quot; since the Arduino Nano I was using appeared to be faulty. This edited question is based on my other Arduino Nano which is working.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug my Arduino into the PC, it keeps blinking it's LED until I open the Serial Monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After opening the serial monitor the Arduino will start to execute my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I get my Arduino to &quot;not wait on a connection&quot;, or simply put, start whenever it receives power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe it's the bootloader which somehow doesn't time-out (I'm not sure if that's how the bootloader works).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code below (though I don't see why this would make it hang until a connection):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(256000);&#xA;  Serial.write(&quot;Restart&quot;);&#xA;  pinMode(13, OUTPUT);&#xA;  digitalWrite(13, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    incomingByte = Serial.read();&#xA;&#xA;    // say what you got:&#xA;    startSend();&#xA;    Serial.print(&quot;I received: &quot;);&#xA;    Serial.println(incomingByte, DEC);&#xA;    stopSend();&#xA;  }else{&#xA;    startSend();&#xA;    Serial.println(&quot;I'm still standing&quot;);&#xA;    stopSend();&#xA;    delay(400);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Code is only for testing purposes)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-05-01T14:59:17.850" LastActivityDate="2016-05-01T14:59:17.850" Title="How to not wait for USB to become active?" Tags="|arduino-nano|bootloader|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23753" PostTypeId="2" ParentId="23751" CreationDate="2016-05-01T13:40:34.697" Score="1" Body="&lt;p&gt;There is a nice explanation &lt;a href=&quot;http://www.instructables.com/id/Bootload-an-ATmega328/step6/ATmega328-PU-workaround/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; about Atmel chip signatures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds like you already know this, so for others looking for help:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;It says that there are different signatures in the Atmel chips you mention.  That you can over ride the Avrdude program using an &quot;-F&quot; switch.  Or you can change the Avrdude configurations to use the &quot;other&quot; Atmel chip (however, the consequences if any were unknown by the author).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may be an obvious step, but double check to make sure the IDE's target board settings are correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also want to check the communications between the programmer and the target.  You might look into dropping the speed.  But the better way is to scope the lines to see if data is being sent to the target and if the target is talking back.  From that you can infer if the problems is a bad connection or if the chip has been damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to dig further using software tools you could look into driving Avrdude for your self.  There is a easy to read tutorial &lt;a href=&quot;http://www.ladyada.net/learn/avr/avrdude.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and what appears to be an everything you wanted to know and more document &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/using_avrprog.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the 1st tutorial (from ladyada.net) we see a test which they purposely try the wrong signature:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Just for kicks try running this command avrdude -c usbtiny -p atmega8&#xA;  -U flash:w:test_leds.hex&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/grqDr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/grqDr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You'll see that it stops at step 2, once the signature is different&#xA;  than the expected one it stops. This is because code that is compiled&#xA;  for an attiny2313 wont run on an atmega8 (this is true of most&#xA;  microcontrollers, the .hex files are not cross compatible)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But more interestingly, Avrdude prints out the signature read back from the target!  So, if you run the same test, you could tell if Avrdude is able to communicate at all with the target.  That is, you may see all zeros or all ones or even an alternate message from Avrdude. Which could be an indication that the target is not talking.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-01T14:13:37.823" LastActivityDate="2016-05-01T14:13:37.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23754" PostTypeId="2" ParentId="23752" CreationDate="2016-05-01T14:34:23.367" Score="0" Body="&lt;p&gt;After you post your code this answer may not apply.  But, guessing, you may benefit from changing your code from:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA; data = Serial.read();&#xA; // Do other sutff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop()&#xA;{&#xA; if(Serial.available() &amp;gt; 1)&#xA; {&#xA;  data = Serial.read();&#xA; }&#xA; // Do other stuff&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-01T14:34:23.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23755" PostTypeId="2" ParentId="23746" CreationDate="2016-05-01T15:14:54.123" Score="2" Body="&lt;p&gt;You can purchase some great starter kits too:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They're easy to search for, here's a few that popped up right away:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduino.cc/en/Main/ArduinoStarterKit&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Main/ArduinoStarterKit&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B016D5KUHS&quot; rel=&quot;nofollow&quot;&gt;http://www.amazon.com/Kuman-Project-Complete-Starter-breadboard/dp/B016D5KUHS/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here's one that I own, and I've recommended to other people:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.microcenter.com/product/458578/Arduino_Compatible_Maker_Kit_with_LCD_Display&quot; rel=&quot;nofollow&quot;&gt;http://www.microcenter.com/product/458578/Arduino_Compatible_Maker_Kit_with_LCD_Display&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a microcenter or radio shack or Fry's in your area, they all stock a variety of different starter kits.&lt;/p&gt;&#xA;" OwnerUserId="19745" LastActivityDate="2016-05-01T15:14:54.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23756" PostTypeId="1" CreationDate="2016-05-01T17:29:28.353" Score="1" ViewCount="647" Body="&lt;p&gt;I have the following structure:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct inst_t {&#xA;    const char *s1;&#xA;    const char *s2;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd like to initialize a constant array of this structure like this where all the strings are &lt;code&gt;PROGMEM&lt;/code&gt;'ed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char START[] PROGMEM = &quot;START&quot;;&#xA;const char ATZ[] PROGMEM = &quot;ATZ&quot;;&#xA;const char ATE0[] PROGMEM = &quot;ATE0&quot;;&#xA;const char OK[] PROGMEM = &quot;OK&quot;;&#xA;&#xA;static inst_t insts[] = {&#xA;    { START,      NULL },&#xA;    { ATZ,        OK },&#xA;    { ATE0,       OK }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see there is a lot of duplication here though. Is there anyway way I can inline the &lt;code&gt;PROGMEM&lt;/code&gt; strings directly into this array initialization without separately declaring each string as being in &lt;code&gt;PROGMEM&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastEditorUserId="18795" LastEditDate="2016-05-01T17:44:01.710" LastActivityDate="2016-05-01T21:58:41.537" Title="Possible to &quot;inline&quot; PROGMEM strings into a structure array initialization?" Tags="|progmem|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23760" PostTypeId="1" CreationDate="2016-05-01T21:24:00.993" Score="-1" ViewCount="1504" Body="&lt;p&gt;I'm building a tic tac toe board for my kids where tapping on a plexiglass surface in any one of the 9 squares would light it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are some ways I can pull off making each of those 9 squares touch sensitive? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doesn't need to be anything fancy, but the kicker is that it can't be something attached directly to the plexiglass surface (as that'd obscure the LED light underneath).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current thinking is &lt;a href=&quot;https://www.adafruit.com/products/1361&quot; rel=&quot;nofollow&quot;&gt;buy a sheet of this pressure-sensitive conductive material&lt;/a&gt; and cut it in to squares, then somehow transfer pressure form the plexiglass down to the square on the bottom of the box, but I may be overcomplicating it.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-05-01T21:37:13.197" LastActivityDate="2016-05-02T12:43:38.153" Title="Ways to implement touch sensitive surface?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23761" PostTypeId="1" CreationDate="2016-05-01T21:38:14.977" Score="0" ViewCount="293" Body="&lt;pre&gt;&lt;code&gt;int r = 12;&#xA;int g = 11;&#xA;int b = 10;&#xA;int sw = 4;&#xA;int x;&#xA;int c = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(r, OUTPUT);&#xA;    pinMode(g, OUTPUT);&#xA;    pinMode(b, OUTPUT);&#xA;    pinMode(sw, INPUT);&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    x = digitalRead(sw);&#xA;  if(x==HIGH) {&#xA;    delay(250);&#xA;    c++;&#xA;    if(c==1) {&#xA;        digitalWrite(r, HIGH);&#xA;        digitalWrite(g, LOW);&#xA;        digitalWrite(b, LOW);&#xA;       {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;      }&#xA;&#xA;    }&#xA;    else if(c==2) {&#xA;        digitalWrite(r, LOW);&#xA;        digitalWrite(g, HIGH);&#xA;        digitalWrite(b, LOW);&#xA;             {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;      }&#xA;    }&#xA;        else if(c==3) {&#xA;        digitalWrite(r, LOW);&#xA;        digitalWrite(g, LOW);&#xA;        digitalWrite(b, HIGH);&#xA;             {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;      }&#xA;    }&#xA;        else if(c==4) {&#xA;        digitalWrite(r, HIGH);&#xA;        digitalWrite(g, HIGH);&#xA;        digitalWrite(b, LOW);&#xA;             {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;      }&#xA;    }&#xA;            else if(c==5) {&#xA;        digitalWrite(r, LOW);&#xA;        digitalWrite(g, HIGH);&#xA;        digitalWrite(b, HIGH);&#xA;             {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;      }&#xA;&#xA;    }&#xA;            else if(c==6) {&#xA;        digitalWrite(r, HIGH);&#xA;        digitalWrite(g, LOW);&#xA;        digitalWrite(b, HIGH);&#xA;             {&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        digitalWrite(13,HIGH);&#xA;        delay (250);&#xA;        digitalWrite(13, LOW);&#xA;        delay (250);&#xA;        c=0;&#xA;      }&#xA;&#xA;    }&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20709" LastEditorUserId="313" LastEditDate="2016-05-01T21:44:42.673" LastActivityDate="2016-05-02T06:54:57.003" Title="Can I short this code?" Tags="|arduino-uno|code-optimization|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23762" PostTypeId="2" ParentId="23756" CreationDate="2016-05-01T21:58:41.537" Score="2" Body="&lt;p&gt;If the strings are similar size you can, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_ELEMENTS = 10;&#xA;&#xA;typedef struct {&#xA;   char description [12];&#xA;} descriptionType;&#xA;&#xA;const descriptionType descriptions [NUMBER_OF_ELEMENTS] PROGMEM = { &#xA; { &quot;Furnace on&quot; }, &#xA; { &quot;Furnace off&quot; }, &#xA; { &quot;Set clock&quot; }, &#xA; { &quot;Pump on&quot; }, &#xA; { &quot;Pump off&quot; }, &#xA; { &quot;Password:&quot; }, &#xA; { &quot;Accepted&quot; }, &#xA; { &quot;Rejected&quot; }, &#xA; { &quot;Fault&quot; }, &#xA; { &quot;Service rqd&quot; }, &#xA; };&#xA;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  for (int i = 0; i &amp;lt; NUMBER_OF_ELEMENTS; i++)&#xA;    {&#xA;    // make a copy of the current one&#xA;    descriptionType oneItem;&#xA;    memcpy_P (&amp;amp;oneItem, &amp;amp;descriptions [i], sizeof oneItem);&#xA;&#xA;    Serial.println (oneItem.description);&#xA;    }   // end of for loop&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop () { } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;This is a bit wasteful of program memory, because you need to allow for the largest string (your example had them all similar sizes) but what you &lt;em&gt;save&lt;/em&gt; is not needing a two-byte pointer for each string, so if they are all similar lengths, it will take about the same memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow&quot;&gt;my page about PROGMEM&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-01T21:58:41.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23763" PostTypeId="2" ParentId="23761" CreationDate="2016-05-01T22:33:11.127" Score="1" Body="&lt;pre&gt;&lt;code&gt;int r = 12, g = 11,b = 10, sw = 4, x, c = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(r, OUTPUT);&#xA;    pinMode(g, OUTPUT);&#xA;    pinMode(b, OUTPUT);&#xA;    pinMode(sw, INPUT);&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  x = digitalRead(sw);&#xA;  if(x==HIGH) {&#xA;    delay(250);&#xA;    c++;&#xA;    if(c==1)      setRGBandBlink13(HIGH,LOW,LOW,1);&#xA;    else if(c==2) setRGBandBlink13(LOW,HIGH,LOW,2);&#xA;    else if(c==3) setRGBandBlink13(LOW,LOW,HIGH,3);&#xA;    else if(c==4) setRGBandBlink13(HIGH,HIGH,LOW,4);&#xA;    else if(c==5) setRGBandBlink13(LOW,HIGH,HIGH,5);&#xA;    else if(c==6){&#xA;      setRGBandBlink13(HIGH,LOW,HIGH,6);&#xA;      c=0;&#xA;    }&#xA;&#xA;  }&#xA;}&#xA;&#xA;void setRGBandBlink13(bool newR,bool newG,bool newB,int times){&#xA;  setRGB( newR, newG, newB);&#xA;  blinkPin13(times);&#xA;}&#xA;&#xA;void setRGB(bool newR,bool newG,bool newB){&#xA;  digitalWrite(r, newR);&#xA;  digitalWrite(g, newG);&#xA;  digitalWrite(b, newB);&#xA;}&#xA;&#xA;void blinkPin13(int times){&#xA;  for(int i=0;i&amp;lt;times;i++){&#xA;    digitalWrite(13,HIGH);&#xA;    delay (250);&#xA;    digitalWrite(13, LOW);&#xA;    delay (250);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20645" LastActivityDate="2016-05-01T22:33:11.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23765" PostTypeId="2" ParentId="23761" CreationDate="2016-05-02T01:06:35.773" Score="0" Body="&lt;p&gt;I don't have an appropriate circuit handy for testing, but I've condensed the code a bit and renamed some things to be more readable. Hopefully the result is the same! Importantly, I've changed your &lt;code&gt;c&lt;/code&gt; to &lt;code&gt;step&lt;/code&gt; and it is now zero-based, so &quot;step 1&quot; is 0 and &quot;step 6&quot; is 5, etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int rPin = 12;&#xA;const int gPin = 11;&#xA;const int bPin = 10;&#xA;const int swPin = 4;&#xA;const int pin13 = 13; // Needs a better name!&#xA;const int msDelay = 250;&#xA;&#xA;int step = 0;&#xA;&#xA;// By pure luck, your patterns overlap, so they can be condensed like so.&#xA;const byte patterns[13] = {&#xA;    // 0         1          2          3          4           5&#xA;    HIGH, LOW, LOW, HIGH, LOW, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH&#xA;};&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(rPin, OUTPUT);&#xA;    pinMode(gPin, OUTPUT);&#xA;    pinMode(bPin, OUTPUT);&#xA;    pinMode(swPin, INPUT);&#xA;    pinMode(pin13, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (digitalRead(swPin) == HIGH)&#xA;    {&#xA;        delay(msDelay);&#xA;&#xA;        // Write red/green/blue pattern&#xA;        int index = step * 2;&#xA;        digitalWrite(rPin, patterns[index]);&#xA;        digitalWrite(gPin, patterns[index + 1]);&#xA;        digitalWrite(bPin, patterns[index + 2]);&#xA;&#xA;        // Blink once for each step (0 through 5)&#xA;        for (int i = 0; i &amp;lt;= step; ++i)&#xA;        {&#xA;            digitalWrite(pin13, HIGH);&#xA;            delay(msDelay);&#xA;            digitalWrite(pin13, LOW);&#xA;            delay(msDelay);&#xA;        }&#xA;&#xA;        // Increment or reset step&#xA;        step = (step &amp;lt; 5) ? step + 1 : 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20711" LastActivityDate="2016-05-02T01:06:35.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23766" PostTypeId="1" CreationDate="2016-05-02T03:00:04.393" Score="1" ViewCount="1147" Body="&lt;p&gt;My C is rusty, so please forgive this simple problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This line works:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Tft.drawString(&quot;Test&quot;,200,200,2,WHITE);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, this has compile errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String yStr = &quot;Test&quot;;  &#xA;Tft.drawString(yStr,200,200,2,WHITE);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function in the library:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error is &lt;strong&gt;&quot;no known conversion for argument 1 from 'String' to 'char*'&quot;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conclusion - I need a character array. Here's what I am trying to accomplish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two integers that I would like to display on my Tft screen. For example, 225 and 250 to be displayed as &quot;225,250&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't figured out a way to build the char array for the &lt;code&gt;drawString()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assistance would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Thanks for the quick reply Ignacio.&lt;br&gt;&#xA;I tried that, but the compiler still doesn't like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I built the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string stringXY ;&#xA;stringXY += xStr;&#xA;stringXY += &quot;,&quot;;&#xA;stringXY += yStr;&#xA;Tft.drawString(stringXY.c_str(),200,200,2,RED);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error: &lt;strong&gt;invalid conversion from 'const char*' to 'char*' [-fpermissive]&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am apparently using &lt;code&gt;c_str()&lt;/code&gt; wrong?&lt;/p&gt;&#xA;" OwnerUserId="20713" LastEditorUserId="84" LastEditDate="2016-10-30T16:44:33.503" LastActivityDate="2016-11-29T17:28:33.397" Title="I need to build a char array from two integers" Tags="|programming|string|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23767" PostTypeId="2" ParentId="23766" CreationDate="2016-05-02T03:10:25.857" Score="1" Body="&lt;p&gt;Put it in a &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;String&lt;/code&gt;&lt;/a&gt; and then use the &lt;code&gt;c_str()&lt;/code&gt; method to get the associated &lt;code&gt;char*&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-02T03:10:25.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23768" PostTypeId="2" ParentId="23760" CreationDate="2016-05-02T03:20:56.100" Score="1" Body="&lt;p&gt;Transparent touch sensitive surfaces are usually based on parasitic capacitance like on an iPhone.  While you can buy loose glass touch surfaces, it is difficult to use such devices if not already attached to an LCD.  The same is true for the much cheaper resistive touch surfaces like on a Newton.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are already using LEDs, I would suggest investigating using the LED to detect the light from the reflection of a finger.  I found people talking about this &lt;a href=&quot;http://www.thebox.myzen.co.uk/Workshop/LED_Sensing.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://www.bitartist.org/2008/10/led-used-as-touchinput-sensor.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://makezine.com/projects/make-36-boards/how-to-use-leds-to-detect-light/&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe this is a still from a video that someone else made using this technique:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5gtt1.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5gtt1.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your tic tac toe box I could see touching a location for X's or for O's.  Then touching 1 of 9 boxes you would want to place the symbol in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @Gerben pointed out there are other options.  I like solving hardware problems in software.  And reversing the potential on an LED then sampling the voltage over time is a snap to implement on many modern embedded processors.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are open to hardware solutions, microchip.com makes a &lt;a href=&quot;http://www.microchip.com/wwwproducts/en/MGC3030&quot; rel=&quot;nofollow noreferrer&quot;&gt;chip&lt;/a&gt; which projects an electrical field in front of a PCB for 3 dimensional gesture recognition.  However, the PCB layout is touchy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2NRFu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2NRFu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, there are gesture sensors that (probably) use IR radiation to track movement.  &lt;a href=&quot;https://www.sparkfun.com/products/12787&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here's one&lt;/a&gt; that supposedly does X Y &amp;amp; Z as well as sense colors.  And it sounds like there is already an &lt;a href=&quot;https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor/tree/V_H1.0_L1.4.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino library&lt;/a&gt; written for some simple gestures. Looks like there's a &lt;a href=&quot;https://youtu.be/A3QRyixnEl8&quot; rel=&quot;nofollow noreferrer&quot;&gt;YouTube video&lt;/a&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-02T12:43:38.153" LastActivityDate="2016-05-02T12:43:38.153" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23770" PostTypeId="2" ParentId="23761" CreationDate="2016-05-02T04:03:41.170" Score="-1" Body="&lt;p&gt;Make all those ints in a single line. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int r = 12, g = 11,b = 10, sw = 4, x, c = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20665" LastActivityDate="2016-05-02T04:03:41.170" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23771" PostTypeId="1" CreationDate="2016-05-02T04:44:11.837" Score="0" ViewCount="2555" Body="&lt;p&gt;I am trying to write a simple program that will cycle through an array using push buttons. My current version of the program uses if statements and prints lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to have contact information for 4 people stored in an array. I can either have an array of strings per person or make different arrays of strings for the different type of information (ie names, phone numbers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like one push button to cycle through the data in one direction and another push button to cycle through the data in the other direction. This is my code so far using the if statements. I modified the code from a traffic light tutorial hence you will see some of the variables named after colors. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//------------------------------- Declare variables&#xA;int ledPinOne = 2;&#xA;int ledPinTwo = 3;&#xA;int ledPinThree = 4;&#xA;int ledPinFour = 5;&#xA;int buttonPin = 6;&#xA;int state = 0;&#xA;char user_name_array[32];&#xA;char econ_one_name_array[32];&#xA;char econ_two_array[32];&#xA;char econ_three_name_array[32];&#xA;&#xA;&#xA;//------------------------------- Setup&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  //------------------------------ Sets pins for I/O&#xA;  pinMode(ledPinOne, OUTPUT);&#xA;  pinMode(ledPinTwo, OUTPUT);&#xA;  pinMode(ledPinThree, OUTPUT);&#xA;  pinMode(ledPinFour, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  Serial.println(&quot;ID&quot;);&#xA;  Serial.println(user_name_array);&#xA;}&#xA;&#xA;//------------------------------- Main Program&#xA;void loop() {&#xA;  if (digitalRead(buttonPin)) {&#xA;    if (state == 0) {&#xA;      Serial.println(&quot;Athlete&quot;);&#xA;      Serial.println(&quot;John Smith&quot;);&#xA;      Serial.println(&quot;No allergies, no medications&quot;);&#xA;      Serial.println(&quot;  &quot;);&#xA;      setLights(HIGH, LOW, LOW, LOW);&#xA;      state = 1;&#xA;    } else if (state == 1) {&#xA;      Serial.println(&quot;Emergency Contact - Sister&quot;);&#xA;      Serial.println(&quot;Eliza Smith&quot;);&#xA;      Serial.println(&quot;Cell - 333.888.777&quot;);&#xA;      Serial.println(&quot;  &quot;);&#xA;      setLights(LOW, HIGH, LOW, LOW);&#xA;      state = 2;&#xA;&#xA;    } else if (state == 2) {&#xA;      Serial.println(&quot;Emergency Contact - Hermosita&quot;);&#xA;      Serial.println(&quot;Jackie Smith&quot;);&#xA;      Serial.println(&quot;Cell - 777.888.7777&quot;);&#xA;      Serial.println(&quot;  &quot;);&#xA;      setLights(LOW, LOW, HIGH, LOW);&#xA;      state = 3;&#xA;    } else if (state == 3) {&#xA;      Serial.println(&quot;Emergency Contact - Father&quot;);&#xA;      Serial.println(&quot;Michael Smith&quot;);&#xA;      Serial.println(&quot;Cell - 888.777.777&quot;);&#xA;      Serial.println(&quot;  &quot;);&#xA;      setLights(LOW, LOW, LOW, HIGH);&#xA;      state = 0;&#xA;    }&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&#xA;void setLights(int red, int yellow, int green, int blue) {&#xA;  digitalWrite(ledPinOne, red);&#xA;  digitalWrite(ledPinTwo, yellow);&#xA;  digitalWrite(ledPinThree, green);&#xA;  digitalWrite(ledPinFour, blue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also have a 4-LED setup. When the button is pushed one of the LEDs turns on and then when the button is pushed again it turns off and turns the second one on and so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This question was asked again in a more detailed way and has more answers here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/23857/using-a-button-to-cycle-an-array&quot;&gt;Using a button to cycle an array&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastEditorUserId="10214" LastEditDate="2017-09-26T12:09:21.440" LastActivityDate="2021-08-19T21:01:20.117" Title="Using buttons with Arrays" Tags="|programming|" AnswerCount="1" CommentCount="1" ClosedDate="2021-08-24T18:30:11.107" ContentLicense="CC BY-SA 3.0" />
  <row Id="23774" PostTypeId="1" AcceptedAnswerId="23775" CreationDate="2016-05-02T05:56:24.407" Score="1" ViewCount="1571" Body="&lt;p&gt;Below is a reference to a logical level bi-directional converter (aka level shifter) I purchased on Ebay.  I've soldered the 12 pins (6 for each piece) to the level shifter so that it fits on my bread board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.com/itm/121868205078?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow&quot;&gt;http://www.ebay.com/itm/121868205078?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may sound trivial, but I'd like to troubleshoot the level shifter with communication both ways (Rx and Tx) to make sure it's working properly.  I've got a constant 4.85v (5V) going to the HV pin, and a constant regulated 3.24V (3.3V) going to the LV pin, along with ground to both GND pins.  Right now, I'm using pin0 (Rx) and pin1 (Tx) on the Arduino Mega 2560.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(1000);&#xA;  Serial.println(&quot;Test&quot;);&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I test this level shifter without any fancy components?  How could I write a program to toggle an LED both on LV1 and HV1 pins, by modifying the program above?  Please note, that even though the Arduino runs on 5V, I am not using the Arduino as my HV power source.&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;EDIT (per comment 3 by @Paul):&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Test:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Burn blank sketch into Arduino&lt;/li&gt;&#xA;&lt;li&gt;Connect 5V (Arduino 5V) to HV pin&lt;/li&gt;&#xA;&lt;li&gt;Connect GND (Arduino GND) to GND pin on same side as HV pin&lt;/li&gt;&#xA;&lt;li&gt;Connect 3.3V to LV pin&lt;/li&gt;&#xA;&lt;li&gt;Connect GND (from 3.3V power source) to GND pin on same side as LV&#xA;pin&lt;/li&gt;&#xA;&lt;li&gt;Connect Arduino Tx pin to channel 1 (HV1)&lt;/li&gt;&#xA;&lt;li&gt;Connect Arduino Rx pin to channel 2 (HV2)&lt;/li&gt;&#xA;&lt;li&gt;Short channel 1 to channel 2 with jumper wire&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;When all of this is connected, and I open the Serial Monitor on Arduino IDE, anything I type will echo back exactly what I typed.  And when I disconnect one of these jumpers, it doesn't echo back.  So it seems to work.&lt;/p&gt;&#xA;" OwnerUserId="15887" LastEditorUserId="15887" LastEditDate="2016-05-31T07:52:49.107" LastActivityDate="2020-12-03T10:38:04.787" Title="Test level shifter with Arduino and some data" Tags="|arduino-mega|led|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="23775" PostTypeId="2" ParentId="23774" CreationDate="2016-05-02T06:14:31.163" Score="2" Body="&lt;p&gt;You don't need to write any program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, note that this is (or at least purports to be) an I2C level shifter. This means that it does &lt;em&gt;not&lt;/em&gt; actively pull up anything; it only actively pulls down. You are supposed to provide pull-ups somewhere in your circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test it, pull up HV1 and LV1 with 10K resistors to HV and LV respectively; measure the voltage on both sides to verify you are pulling to ~5V and ~3.3V respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground HV1, check that LV1 is low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground LV1, check that HV1 is low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ta-dah!&lt;/p&gt;&#xA;" OwnerUserId="10024" LastEditorUserId="10024" LastEditDate="2016-05-02T18:51:20.623" LastActivityDate="2016-05-02T18:51:20.623" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="23777" PostTypeId="2" ParentId="23761" CreationDate="2016-05-02T06:54:57.003" Score="1" Body="&lt;p&gt;This Sketch is way shorter and way better to maintain.&lt;br&gt;&#xA;Note that 1/3 (26 out of 78) of the lines are comments.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note:&lt;br&gt;&#xA;Your RGB is able to display 8 states, but only 7 can be reached.&lt;br&gt;&#xA;binc - c - RGB&lt;br&gt;&#xA; 000 - 0 -&lt;br&gt;&#xA; 001 - 1 - R&lt;br&gt;&#xA; 010 - 2 -  G&lt;br&gt;&#xA; 011 - 3 - RG&lt;br&gt;&#xA; 100 - 4 -   B&lt;br&gt;&#xA; 101 - 5 - R B&lt;br&gt;&#xA; 110 - 6 -  GB&lt;br&gt;&#xA; 111 - 7 - RGB - NEVER REACHED  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int r = 12;&#xA;int g = 11;&#xA;int b = 10;&#xA;int sw = 4;&#xA;int c = 0;&#xA;int maxC = 6;&#xA;int minC = 0;&#xA;&#xA;void setup() {&#xA;    pinMode(r, OUTPUT);&#xA;    pinMode(g, OUTPUT);&#xA;    pinMode(b, OUTPUT);&#xA;    pinMode(sw, INPUT);&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// for  (pulses)-times&#xA;// set  (targetPin) HIGH&#xA;// wait (msDelay)&#xA;// set  (targetPin) LOW&#xA;// wait (msDelay)&#xA;void pulse( int targetPin, int msDelay, int pulses ){&#xA;    // count to pulses&#xA;    // for each count, set targetPin HIGH and LOW&#xA;    // wait msDelay between each state change&#xA;    for ( int i = 0; i &amp;lt;= pulses, i++ ){&#xA;        digitalWrite( targetPin, HIGH );&#xA;        delay( msDelay );&#xA;        digitalWrite( targetPin, LOW );&#xA;        delay( msDelay );&#xA;    }&#xA;}&#xA;&#xA;// int rgbBinary will set RGB according to its binary value.&#xA;// R ~= BIT_1&#xA;// G ~= BIT_2&#xA;// B ~= BIT_4&#xA;void setRGB( int rgbBinary ){&#xA;    // set each LED OFF&#xA;    // This is by far more performant than&#xA;    // checking which should keep its state.&#xA;    digitalWrite( r, LOW );&#xA;    digitalWrite( g, LOW );&#xA;    digitalWrite( b, LOW );&#xA;&#xA;    // if rgbBinary contains BIT value 1, set R to HIGH&#xA;    if ( rgbBinary &amp;amp; 1 ) {&#xA;        digitalWrite( r, HIGH) ;&#xA;    }   &#xA;    // if rgbBinary contains BIT value 2, set R to HIGH&#xA;    if ( rgbBinary &amp;amp; 2 ) {&#xA;        digitalWrite( g, HIGH );&#xA;    }   &#xA;    // if rgbBinary contains BIT value 4, set R to HIGH&#xA;    if ( rgbBinary &amp;amp; 4 ) {&#xA;        digitalWrite( b, HIGH );&#xA;    }   &#xA;}&#xA;&#xA;void loop() {&#xA;    // INPUT on SW ? &#xA;  if ( digitalRead( sw ) == HIGH) {&#xA;    // wait 250ms&#xA;    delay( 250 );&#xA;    // incement c&#xA;    c++;&#xA;    // increment RGB status&#xA;    setRGB( c );&#xA;    // pulse OUTPUT 13 (c)-times &#xA;    // starting by HIGH &#xA;    // delay 250ms between each HIGH/LOW&#xA;    pulse( 13, 250, c );&#xA;    // reset (c) on maxC&#xA;    if ( c == maxC ){&#xA;        c = minC;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4849" LastActivityDate="2016-05-02T06:54:57.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23778" PostTypeId="1" CreationDate="2016-05-02T07:21:05.680" Score="1" ViewCount="130" Body="&lt;p&gt;If UNO is supplied with 9VDC to Power Jack.&#xA;&lt;strong&gt;Will it supply power to USB&lt;/strong&gt; connector?  &lt;/p&gt;&#xA;" OwnerUserId="20717" LastActivityDate="2016-05-02T08:20:50.973" Title="UNO Power supply to USB" Tags="|arduino-uno|power|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23779" PostTypeId="2" ParentId="23686" CreationDate="2016-05-02T07:31:12.137" Score="0" Body="&lt;p&gt;You're trying to power a consumer which draws more current than the arduino could provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, you need an transistor and a ~5V battery (e.g. 4.8V NiMh, or a stronger batteries plus suitable resistors, to not burn out the leds)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at this (awesome paint) shematic to understand the principle.&#xA;The arduino will switch the transistor through S2 which then closes the circuit.&#xA;Through S1, the arduino can set the LEDs values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that for savety, you should also set a diode between S1 and the LEDs, so the battery cannot burn out your arduino, if the LED strip is cheap made.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason why the behavior at your setup differs might be because of a capacitor on the arduino which works similar to a batterie (With extreme little capacity).&#xA;The capacitor might provide enough power to run the LEDs for a very short periode. After discharging, the capacitor needs some time to recharge and thus it may vary in effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HIypH.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HIypH.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4849" LastActivityDate="2016-05-02T07:31:12.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23780" PostTypeId="1" AcceptedAnswerId="23821" CreationDate="2016-05-02T08:09:37.670" Score="0" ViewCount="5351" Body="&lt;p&gt;My Code is as follows-&gt; &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial ESP8266(8,9);&#xA;&#xA;String inData;&#xA;void setup() {&#xA;ESP8266.println(&quot;AT&quot;);&#xA;delay(1000);&#xA;ESP8266.println(&quot;AT+RST&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA; String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA; cmd += &quot;api.thingspeak.com&quot;;  // 184.106.153.149 thingspeak IP address&#xA; cmd += &quot;\&quot;,80&quot;;&#xA; ESP8266.println(cmd);&#xA;&#xA; if(ESP8266.find(&quot;Error&quot;))&#xA; {&#xA;   Serial.println(&quot;AT+CIPSTART error&quot;);&#xA;   return;&#xA;}&#xA;String hostt = &quot;GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA&quot;;&#xA;hostt += &quot;\r\n&quot;;&#xA;hostt += &quot;Host:api.thingspeak.com&quot;;&#xA;hostt += &quot;\r\n\r\n\r\n\r\n\r\n\r\n&quot;;&#xA;ESP8266.println(hostt);&#xA;&#xA;cmd = &quot;AT+CIPSEND=&quot;;&#xA;cmd += String(hostt.length());&#xA;ESP8266.println(cmd);&#xA;&#xA;if(ESP8266.find(&quot;&amp;gt;&quot;)){&#xA;ESP8266.print(hostt);&#xA;}&#xA;else{&#xA;ESP8266.println(&quot;AT+CIPCLOSE&quot;);&#xA;// alert user&#xA;Serial.println(&quot;AT+CIPCLOSE&quot;);&#xA;}&#xA;delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is this the write code? Where am I going wrong?&#xA;I am not able to see the required fetched data.&#xA;Help me with this.&lt;/p&gt;&#xA;" OwnerUserId="20151" LastActivityDate="2016-08-07T19:48:47.163" Title="How to Capture Data from a Webpage in Arduino and Display it over Serial Monitor of ESP8266?" Tags="|arduino-uno|wifi|esp8266|softwareserial|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23781" PostTypeId="1" CreationDate="2016-05-02T08:18:02.547" Score="0" ViewCount="145" Body="&lt;p&gt;&lt;br&gt;&#xA;I am trying to make an operating hours counter with arduino, i started with a basic script to make the arduino work as a stop watch, This is my script: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long start=0, finish=0, elapsed=0;&#xA;&#xA; void setup() {&#xA; Serial.begin(9600);&#xA; Serial.println(&quot;Clock START&quot;);&#xA; }&#xA; void displayResult(unsigned long elapsed){&#xA;   float h,m,s,ms;&#xA;   unsigned long over;&#xA;   h=int(elapsed/3600000);&#xA;   over=elapsed%3600000;&#xA;   m=int(over/60000);&#xA;   over=over%60000;&#xA;   s=int(over/1000);&#xA;   ms=over%1000;&#xA;   Serial.print(&quot;Elapsed time: &quot;);&#xA;   Serial.print(h,0);&#xA;   Serial.print(&quot;h &quot;);&#xA;   Serial.print(m,0);&#xA;   Serial.print(&quot;m &quot;);&#xA;   Serial.print(s,0);&#xA;   Serial.print(&quot;s &quot;);&#xA;   Serial.print(ms,0);&#xA;   Serial.println(&quot;ms&quot;);&#xA;   Serial.println();&#xA; }&#xA;&#xA; void loop() {&#xA;   start = millis();&#xA;   delay(200);&#xA;   Serial.println(&quot;Start&quot;);&#xA;   Serial.println(&quot;doing Operations and stuff&quot;);&#xA;   delay(800);&#xA;   finish=millis();&#xA;   elapsed=finish-start;&#xA;   Serial.println(&quot;Ended !!!&quot;);&#xA;   displayResult(elapsed);&#xA;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;Unfortuantly the arduino compiler blocks at the Uploading part, i tried compiling it at first without uploading, it gave me no warning errors. I tried compiling other scripts they worked, it only blocks for this stop watch code.&lt;br&gt;&#xA;Thank you for your help&lt;/p&gt;&#xA;" OwnerUserId="11897" LastActivityDate="2016-05-02T09:42:18.010" Title="Arduino Blocks at Uploading" Tags="|arduino-mega|uploading|millis|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23782" PostTypeId="2" ParentId="23778" CreationDate="2016-05-02T08:20:50.973" Score="2" Body="&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7BsUF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7BsUF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see in the schematic, the USBVCC is only connected (via a MOSFET) to the 5V line, when the voltage on VIN (barrel jack) is LOW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you connect 9V to the power jack, the mosfet will turn of, and disconnect the USB power from the 5V on the UNO.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-02T08:20:50.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23783" PostTypeId="2" ParentId="23583" CreationDate="2016-05-02T08:43:57.040" Score="1" Body="&lt;p&gt;If you make it so that the light only goes out when you press the button, and connect a battery charger with that bulb in parallel, put a battery in the charger and plug the arduino into the battery, then use the light sensor approach to detect the button press and play a tune, it would work just fine... Really the only 3 things you might wanna worry about are the user holding the button for a few hours (which is very unlikely), power outages (can be solved using a UPS), and replacing the battery/bulb once every few years, depending on how good it is... Probably the simplest approach, not sure if it is the best tho... &#xA;But why not just plug the arduino to a phone charger that is then connected to the wall, and then use the doorbell switch as input for the arduino? &lt;/p&gt;&#xA;" OwnerUserId="20720" LastEditorUserId="20720" LastEditDate="2016-05-02T09:38:17.683" LastActivityDate="2016-05-02T09:38:17.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23784" PostTypeId="2" ParentId="3655" CreationDate="2016-05-02T09:31:37.473" Score="0" Body="&lt;p&gt;To solve this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; connect your Arduino board to the PC / Laptop.&#xA;&lt;strong&gt;2.&lt;/strong&gt; open control panel. and go to &lt;strong&gt;view devices and printers&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Here You can see a &lt;strong&gt;unknown device&lt;/strong&gt;... i.e. your arduino board. double click on it.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/oNuPu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oNuPu.jpg&quot; alt=&quot;Unknown device&quot;&gt;&lt;/a&gt;&#xA;&lt;strong&gt;4&lt;/strong&gt; Click on hardware..................................................&#xA;&lt;a href=&quot;https://i.stack.imgur.com/aVFUD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aVFUD.jpg&quot; alt=&quot;Hardware&quot;&gt;&lt;/a&gt;&#xA;&lt;strong&gt;5.&lt;/strong&gt; Now Choose &lt;strong&gt;Update Driver&lt;/strong&gt;... Choose the location where the &lt;strong&gt;Arduino IDE is installed&lt;/strong&gt;... And go to &lt;strong&gt;Next&lt;/strong&gt;&#xA;&lt;strong&gt;6.&lt;/strong&gt; Now your computer will recognise your arduino board&lt;/p&gt;&#xA;" OwnerUserId="20722" LastActivityDate="2016-05-02T09:31:37.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23785" PostTypeId="2" ParentId="23781" CreationDate="2016-05-02T09:42:18.010" Score="2" Body="&lt;p&gt;There is a bug in early versions of the Mega2560 bootloader.  It crashes on &lt;code&gt;!!!&lt;/code&gt; (or enters some other special state that stops uploading happening).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your string that contains &lt;code&gt;!!!&lt;/code&gt; will be breaking it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Ended !!!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Simple solution: don't use so many exclamation marks.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-02T09:42:18.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23787" PostTypeId="2" ParentId="23746" CreationDate="2016-05-02T11:00:33.507" Score="1" Body="&lt;p&gt;The other suggestions are great.&#xA;If you want to make a more &quot;academic&quot; approach, I can recommend two courses on &lt;a href=&quot;http://www.coursera.org&quot; rel=&quot;nofollow&quot;&gt;Coursera&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/learn/arduino-platform/&quot; rel=&quot;nofollow&quot;&gt;The Arduino Platform and C Programming&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/learn/interface-with-arduino&quot; rel=&quot;nofollow&quot;&gt;Interfacing with the Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've followed and completed these 2 courses, and I think they were great fun. They give a light-weight introducton to the Arduino, with only a little time consumption needed.&lt;/p&gt;&#xA;" OwnerUserId="20725" LastActivityDate="2016-05-02T11:00:33.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23788" PostTypeId="1" AcceptedAnswerId="30664" CreationDate="2016-05-02T11:37:30.603" Score="2" ViewCount="1708" Body="&lt;p&gt;I've noticed that I can set D9, D10, and D11 to around the timer 1 can be set to ~244Hz. However I need 4 ports that are between 200-1000Hz but I have been unable to figure out how to find the last one. I can't really touch timer 0 as they control millis etc.&lt;/p&gt;&#xA;" OwnerUserId="20728" LastEditorUserId="4628" LastEditDate="2017-03-29T13:02:41.973" LastActivityDate="2017-03-29T13:02:41.973" Title="How can I set 4 Arduino Leonardo PWM-ports between 200Hz and 1kHz?" Tags="|pwm|arduino-leonardo|frequency|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23789" PostTypeId="2" ParentId="23771" CreationDate="2016-05-02T13:03:41.047" Score="0" Body="&lt;p&gt;Let's just deal with character strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The truth of the matter is that Arduino programming uses the language C.  C is very common and you can search for help in many places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to deal with strings in C.  In this example we are using an array of pointers to strings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// let's make our own array of strings&#xA;char *states[] = {&#xA;    &quot;California&quot;, &quot;Oregon&quot;,&#xA;    &quot;Washington&quot;, &quot;Texas&quot;&#xA;};&#xA;int num_states = 4;&#xA;&#xA;for(i = 0; i &amp;lt; num_states; i++) {&#xA;    printf(&quot;state %d: %s\n&quot;, i, states[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output of this code looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;state 0: California&#xA;state 1: Oregon&#xA;state 2: Washington&#xA;state 3: Texas&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I grabbed this example from &lt;a href=&quot;http://c.learncodethehardway.org/book/ex10.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The method &quot;printf&quot; is normally not used in Arduino land.  So that &quot;for&quot; loop would look more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for(i = 0; i &amp;lt; num_states; i++) &#xA;{&#xA; Serial.println(&quot;state &quot;);&#xA; Serial.println(i)&#xA; Serial.println(states[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2017-04-28T13:25:02.427" LastActivityDate="2017-04-28T13:25:02.427" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23791" PostTypeId="2" ParentId="23788" CreationDate="2016-05-02T13:48:31.253" Score="0" Body="&lt;p&gt;According to &lt;a href=&quot;https://www.arduino.cc/en/Main/arduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo&lt;/a&gt;, you have available for PWM configuration ports numbered 3, 5, 6, 9, 10, 11 and 13. The specifications presented there do not provide the range of the frequency available, but I would expect that if you are able to use 9, 10 and 11, one of the others would fall into place.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-05-02T13:48:31.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23792" PostTypeId="1" CreationDate="2016-05-02T15:53:00.860" Score="1" ViewCount="25756" Body="&lt;p&gt;Is it possible to allow an Arduino Leonardo to simulate pressing the Windows key using the &lt;code&gt;keyboard.press(......);&lt;/code&gt; command?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, what is the required value?&lt;/p&gt;&#xA;" OwnerUserId="20473" LastEditorUserId="510" LastEditDate="2020-05-04T23:28:46.477" LastActivityDate="2020-05-04T23:28:50.530" Title="Press the Windows key using &quot;keyboard.press();&quot;" Tags="|arduino-leonardo|button|keyboard|windows|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23793" PostTypeId="1" CreationDate="2016-05-02T16:22:01.063" Score="0" ViewCount="3991" Body="&lt;p&gt;I'm new at Arduino projects. I googled but I couldn't quite get an answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno R3 clone&lt;/li&gt;&#xA;&lt;li&gt;4 pin push button&lt;/li&gt;&#xA;&lt;li&gt;3 color RGB LED Module &lt;/li&gt;&#xA;&lt;li&gt;HC06 Bluetooth-Serial Module Card&lt;/li&gt;&#xA;&lt;li&gt;Arduino PIC Camera Module OV7670&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In my project, when the button is pushed, the Arduino takes a photo from the camera module and sends it with an HC06 Bluetooth Module to an Android device. And it receives the answer to turn on the Led green or red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem is how can I capture the photo and send it with bluetooth? I can handle the Android side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I reviewed that code: &lt;a href=&quot;https://github.com/ArduCAM/Arduino/blob/master/OV7670FIFO/OV7670FIFO.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;OV7670 FIFO on GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &quot;Take Picture&quot; method, I understand that the OV7670 continuously grabs frames and stores them in itself. I send it a signal to load a frame on Data Out pins. (&lt;em&gt;D0-7&lt;/em&gt;) It loads first 8 bytes on the pins and in Arduinoo, in the for loops for height, width and byte for each pixels, I read in it from &lt;em&gt;D0-7&lt;/em&gt; and send a signal for next byte array. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I can't understand how to connect the OV7670 to the Arduino. In code, there are conts called &lt;code&gt;WRST&lt;/code&gt;, &lt;code&gt;RRST&lt;/code&gt;, &lt;code&gt;WEN&lt;/code&gt;, &lt;code&gt;VSYNC&lt;/code&gt; and &lt;code&gt;RCLK&lt;/code&gt;. On the OV7670 I've got &lt;code&gt;SIOC&lt;/code&gt;, &lt;code&gt;SIOD&lt;/code&gt;, &lt;code&gt;VSYNC&lt;/code&gt;, &lt;code&gt;HREF&lt;/code&gt;, &lt;code&gt;PCLK&lt;/code&gt;, &lt;code&gt;XCLK&lt;/code&gt;, &lt;code&gt;D0-7&lt;/code&gt;, &lt;code&gt;RESET&lt;/code&gt; and &lt;code&gt;PWDN&lt;/code&gt; pins. How can I connect these pins like in the github link? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way here is my OV7670, I read there are different versions of OV7670:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/f0N9m.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/f0N9m.jpg&quot; alt=&quot;OV7670 Camera Module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20735" OwnerDisplayName="Metehan Toksoy" LastEditorUserId="4628" LastEditDate="2016-12-03T21:56:16.410" LastActivityDate="2017-03-11T12:40:16.370" Title="Send Photo with Arduino Uno" Tags="|bluetooth|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23795" PostTypeId="2" ParentId="23792" CreationDate="2016-05-02T16:28:13.437" Score="3" Body="&lt;p&gt;Looking at &lt;a href=&quot;http://www.usb.org/developers/hidpage/Hut1_12v2.pdf&quot; rel=&quot;nofollow&quot;&gt;the list of the HID keyboard codes (page 53)&lt;/a&gt;, the keys you are looking for have a code of E3 (Keyboard Left GUI) or E7 (Keyboard Right GUI).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unluckily the &lt;code&gt;Keyboard::press&lt;/code&gt; function (you can see it &lt;a href=&quot;https://github.com/arduino-libraries/Keyboard/blob/master/src/Keyboard.cpp&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) does not accept a so high value, since you can only input numbers between 0 and 255 and, in order to send a raw value, you have to send its value plus 136 (which leads to values 363 and 367).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, looking at the header file, there are two predefined keys called &lt;code&gt;KEY_LEFT_GUI&lt;/code&gt; and &lt;code&gt;KEY_RIGHT_GUI&lt;/code&gt;. Maybe these modifier keys behave in exactly the same way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my suggestion is to&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;try using one of those values (i.e. &lt;code&gt;keyboard.press(KEY_LEFT_GUI);&lt;/code&gt; or &lt;code&gt;keyboard.press(KEY_RIGHT_GUI);&lt;/code&gt;, or use the &lt;code&gt;keyboard.write(KEY_LEFT_GUI);&lt;/code&gt; to simulate a press on the key instead of you keeping it pressed).&lt;/li&gt;&#xA;&lt;li&gt;If this does not work, create your own library copying the keyboard.cpp and keyboard.h files, calling the class differently and adding the possibility to send the E3 and/or the E7 keys. In this case, you will just need to modify the press function.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Good luck&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-05-02T16:28:13.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23796" PostTypeId="1" CreationDate="2016-05-02T17:20:32.473" Score="0" ViewCount="796" Body="&lt;p&gt;I am trying to parse JSON using the ArduinoJson library. The problem is that I can’t parse www.read() because it’s declared as a char. I think www.read() needs to be a string? How can I convert www.read() into a format that jsonBufffer.parseObject() can understand? Please excuse any lack of terminology. I am new to using JSON.&lt;/p&gt;&#xA;&lt;p&gt;When I run the code I get to the point where it prints &amp;quot;-------------------------------------” then it does nothing.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;ccspi.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;quot;utility/debug.h&amp;quot;&#xA;#include &amp;lt;ArduinoJson.h&amp;gt;&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  5&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,   &#xA;ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,&#xA;SPI_CLOCK_DIVIDER); // you can change this clock speed&#xA;&#xA;#define WLAN_SSID       &amp;quot;WLAN_SSID_HERE&amp;quot; // cannot be longer than 32    characters!&#xA;#define WLAN_PASS       &amp;quot;WLAN_PASS_HERE&amp;quot;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;#define IDLE_TIMEOUT_MS  300000      // Amount of time to wait (in milliseconds) with no data &#xA;// received before closing the connection.  If you know the server&#xA;// you're accessing is quick to respond, you can reduce this value.&#xA;&#xA;// What page to grab!&#xA;#define WEBSITE      &amp;quot;wefeel.csiro.au&amp;quot;&#xA;#define WEBPAGE      &amp;quot;/api/emotions/primary/totals&amp;quot;&#xA;&#xA;&#xA;StaticJsonBuffer&amp;lt;200&amp;gt; jsonBuffer;&#xA;&#xA;&#xA;&#xA;uint32_t ip;&#xA;&#xA;void setup(void)&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&amp;quot;Hello, CC3000!\n&amp;quot;)); &#xA;&#xA;  /* Initialise the module */&#xA;  Serial.println(F(&amp;quot;\nInitializing...&amp;quot;));&#xA;  if (!cc3000.begin())&#xA;  {&#xA;    Serial.println(F(&amp;quot;Couldn't begin()! Check your wiring?&amp;quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;&#xA;  Serial.print(F(&amp;quot;\nAttempting to connect to &amp;quot;)); &#xA;  Serial.println(WLAN_SSID);&#xA;   if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&amp;quot;Failed!&amp;quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&amp;quot;Connected!&amp;quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&amp;quot;Request DHCP&amp;quot;));&#xA;  while (!cc3000.checkDHCP())&#xA;  {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }  &#xA;&#xA;  /* Display the IP address DNS, Gateway, etc. */&#xA;//  while (! displayConnectionDetails()) {&#xA; //    delay(1000);&#xA;//  }&#xA;&#xA;  ip = 0;&#xA;  // Try looking up the website's IP address&#xA;  Serial.print(WEBSITE); &#xA;  Serial.print(F(&amp;quot; -&amp;gt; &amp;quot;));&#xA;  while (ip == 0) {&#xA;    if (! cc3000.getHostByName(WEBSITE, &amp;amp;ip)) {&#xA;      Serial.println(F(&amp;quot;Couldn't resolve!&amp;quot;));&#xA;    }&#xA;    delay(500);&#xA;   }&#xA;&#xA;  cc3000.printIPdotsRev(ip);&#xA;&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  char c;&#xA;  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);&#xA;  delay(300);&#xA;  if (www.connected()) {&#xA;    www.fastrprint(F(&amp;quot;GET &amp;quot;));&#xA;    www.fastrprint(WEBPAGE);&#xA;    www.fastrprint(F(&amp;quot; HTTP/1.1\r\n&amp;quot;));&#xA;    www.fastrprint(F(&amp;quot;Host: &amp;quot;)); &#xA;    www.fastrprint(WEBSITE); &#xA;    www.fastrprint(F(&amp;quot;\r\n&amp;quot;));&#xA;    www.fastrprint(F(&amp;quot;\r\n&amp;quot;));&#xA;    www.println();&#xA;  } &#xA;  else {&#xA;    Serial.println(F(&amp;quot;Connection failed&amp;quot;));    &#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println(F(&amp;quot;-------------------------------------&amp;quot;));&#xA;&#xA;  unsigned long lastRead = millis();&#xA;  while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    //Serial.print(www.available());&#xA;    while (www.available()) {&#xA;  &#xA;  &#xA;      //Serial.print(c);&#xA;      //char json[] = www.read();&#xA;    }&#xA;  } &#xA;  c = www.read();&#xA;  Serial.print(c);&#xA; JsonObject&amp;amp; root = jsonBuffer.parseObject((char*)c);&#xA; if (!root.success()) {&#xA;    Serial.println(&amp;quot;parseObject() failed&amp;quot;);&#xA;    return;&#xA;    }&#xA;&#xA;  long love = root[&amp;quot;love&amp;quot;];&#xA;  long other = root[&amp;quot;other&amp;quot;];&#xA;  long sadness = root[&amp;quot;sadness&amp;quot;];&#xA;  long anger = root[&amp;quot;anger&amp;quot;];&#xA;  long joy = root[&amp;quot;joy&amp;quot;];&#xA;  long surprise = root[&amp;quot;surprise&amp;quot;];&#xA;  long fear = root[&amp;quot;fear&amp;quot;];&#xA;&#xA;  Serial.println(love);&#xA;  Serial.println(other);&#xA;  Serial.println(sadness);&#xA;  Serial.println(anger);&#xA;  Serial.println(joy);&#xA;  Serial.println(surprise);&#xA;  Serial.println(fear);&#xA;&#xA;&#xA;  www.stop();&#xA;  delay(100);&#xA;  www.close();&#xA;  delay(200);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20587" LastEditorUserId="8583" LastEditDate="2021-05-21T19:00:12.153" LastActivityDate="2022-02-15T20:00:20.370" Title="Parsing using the ArduinoJson library" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23797" PostTypeId="2" ParentId="23796" CreationDate="2016-05-02T19:59:29.847" Score="1" Body="&lt;p&gt;There are two &lt;code&gt;read&lt;/code&gt; methods. One that returns a single character (or error), and one that populates a buffer; you want the latter, with method signature &lt;code&gt;int read(char* buf, size_t len)&lt;/code&gt; or some such. Read the source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When allocating the json buffer in &lt;code&gt;StaticJsonBuffer&amp;lt;200&amp;gt; jsonBuffer;&#xA;&lt;/code&gt;, make sure your expected json data fit in 200 bytes. &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-02T19:59:29.847" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23800" PostTypeId="2" ParentId="23468" CreationDate="2016-05-02T21:00:54.707" Score="1" Body="&lt;p&gt;I found the problem. &#xA;I had assumed that the rst pin was supposed to be held low unless you wanted to reset the count on the encoder, and was ignoring it the whole time. Once I held the reset pin high, the count started to show up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As of now there are still problems, I cannot read the high byte from the IC. &lt;/p&gt;&#xA;" OwnerUserId="20739" LastActivityDate="2016-05-02T21:00:54.707" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23801" PostTypeId="1" CreationDate="2016-05-02T21:04:47.210" Score="3" ViewCount="1367" Body="&lt;p&gt;How to use &lt;code&gt;printf&lt;/code&gt; with Arduino's streams without an intermediary buffer? The following seems unnecessary:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buf[256];&#xA;sprintf(buf, ...);&#xA;Serial.print(buf);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to connect &lt;code&gt;HardwareSerial&lt;/code&gt; or &lt;code&gt;SoftwareSerial&lt;/code&gt; to a libc stream or is there a custom implementation of &lt;code&gt;printf&lt;/code&gt; that does this?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-05-02T21:55:31.790" Title="How to use printf with Arduino's serial ports without an intermediary buffer?" Tags="|avr|printf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23802" PostTypeId="2" ParentId="23801" CreationDate="2016-05-02T21:55:31.790" Score="6" Body="&lt;p&gt;Sure - here's a Hello, World program that uses printf(). Everything that mentions &quot;uart&quot; is what connects printf() to your output stream. &lt;code&gt;uart_putchar()&lt;/code&gt; does the actual outputting to ... someplace. That's what you'd modify to direct the C standard output to a different device - SofwareSerial, for instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Hello, World program using printf()&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;static FILE uartout = { 0 };   // FILE struct&#xA;static int uart_putchar(char c, FILE *stream);&#xA;&#xA;&#xA;void setup() {&#xA;   // For printf: fills in the UART file descriptor with pointer to putchar func.&#xA;   fdev_setup_stream(&amp;amp;uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);&#xA;   stdout = &amp;amp;uartout;&#xA;&#xA;   Serial.begin(9600);&#xA;   printf(&quot;Hello, World!\n&quot;);&#xA;}&#xA;&#xA;&#xA;void loop( void ){&#xA;   printf(&quot;Elapsed time: %ld\n&quot;, millis());&#xA;}&#xA;&#xA;&#xA;// uart_putchar - char output function for printf&#xA;static int uart_putchar (char c, FILE *stream)&#xA;{&#xA;   if( c == '\n' )&#xA;      Serial.write('\r');&#xA;   Serial.write(c) ;&#xA;   return 0 ;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-02T21:55:31.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23803" PostTypeId="1" AcceptedAnswerId="23824" CreationDate="2016-05-02T22:26:47.387" Score="0" ViewCount="39" Body="&lt;p&gt;I'm using &lt;a href=&quot;https://www.adafruit.com/products/1734&quot; rel=&quot;nofollow&quot;&gt;5 of those 8mm NeoPixels&lt;/a&gt; + a &lt;a href=&quot;https://www.adafruit.com/product/1501&quot; rel=&quot;nofollow&quot;&gt;5V Trinket&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get a rough estimate of the current requirements that would have, assuming all 5 NeoPixels were running at full brightness &quot;white&quot; (255 RGB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm voltage-regulated to about 150 mA from the Trinket and my current hunch is that those NeoPixels need more than that, but trying to confirm it.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-03T10:58:11.477" Title="What would the total current requirements be for these items?" Tags="|led|adafruit|current|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23805" PostTypeId="1" CreationDate="2016-05-02T23:01:27.143" Score="0" ViewCount="726" Body="&lt;p&gt;I am building a rather complicated model railroad crossing signal and have moved to using the Mega since I need more pins than the Uno. Upon reading the specs of the Mega on the Arduino.cc website I noticed a potential pin conflict, or not, maybe they serve a dual purpose?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2).&lt;/p&gt;&#xA;&lt;p&gt;I2C: 20 (SDA) and 21 (SCL).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;SDA and Interrupt 3 both function on pin 20? Likewise with Interrupt 2 and SCL?&lt;/p&gt;&#xA;&lt;p&gt;I assume this is true, how/why do they share the same pin?&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-10-30T05:47:19.083" Title="Arduino Mega pin conflict" Tags="|arduino-mega|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23806" PostTypeId="2" ParentId="23805" CreationDate="2016-05-02T23:07:06.370" Score="1" Body="&lt;p&gt;Lots of things share pins. It's normal. The &quot;how&quot; is that those pins are connected, internally, to multiple bits of the circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &quot;why&quot; is simply because if you had a discrete pin for each possible function you would end up with a chip the size of your desk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pretty much every single pin on the chip has multiple functions on it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-02T23:07:06.370" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23809" PostTypeId="1" CreationDate="2016-05-03T01:42:27.873" Score="0" ViewCount="7545" Body="&lt;p&gt;I used platformio IDE&lt;/p&gt;&#xA;&lt;p&gt;I did &amp;quot;platformio lib install 1101&amp;quot;&#xA;(&lt;a href=&quot;http://platformio.org/lib/show/1101/ESP8266wifi&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://platformio.org/lib/show/1101/ESP8266wifi&lt;/a&gt;),&lt;/p&gt;&#xA;&lt;p&gt;I installed this: &lt;a href=&quot;http://platformio.org/lib/show/549/WebSockets&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://platformio.org/lib/show/549/WebSockets&lt;/a&gt; (follow instructions)&lt;/p&gt;&#xA;&lt;p&gt;I did similar things to other libraries.&lt;/p&gt;&#xA;&lt;p&gt;When I click the platformio:build button, it still complains:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;fatal error: ESP8266WiFi.h: No such file or directory fatal error:&lt;/p&gt;&#xA;&lt;p&gt;ESP8266WiFiMulti.h: No such file or directory fatal error:&lt;/p&gt;&#xA;&lt;p&gt;ESP8266Webserver.h: No such file or directory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20742" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2017-10-13T06:52:35.847" Title="fatal error: ESP8266WiFi.h: No such file or directory" Tags="|arduino-uno|arduino-ide|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23810" PostTypeId="2" ParentId="23766" CreationDate="2016-05-03T03:28:44.373" Score="1" Body="&lt;p&gt;Many thanks to Ignacio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the function in the library to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void drawString(&lt;strong&gt;const&lt;/strong&gt; char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This fixed the problem and gave me more confidence in my vague understanding of C.&lt;/p&gt;&#xA;" OwnerUserId="20713" LastActivityDate="2016-05-03T03:28:44.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23811" PostTypeId="2" ParentId="23809" CreationDate="2016-05-03T03:50:59.487" Score="0" Body="&lt;p&gt;Make sure &lt;strong&gt;ESP8266WiFi.h&lt;/strong&gt;, &lt;strong&gt;ESP8266WiFiMulti.h&lt;/strong&gt;, &lt;strong&gt;ESP8266Webserver.h&lt;/strong&gt; files are located in the same directory where your *.uno file present.&lt;/p&gt;&#xA;" OwnerUserId="19781" LastActivityDate="2016-05-03T03:50:59.487" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23812" PostTypeId="1" AcceptedAnswerId="23813" CreationDate="2016-05-03T05:05:34.660" Score="0" ViewCount="413" Body="&lt;p&gt;I would like to program my ESP 8266 WiFi module. But I don't have an FDTI right now is there any way to use Arduino Uno as FDTI Programmer then use ESP without it.&lt;/p&gt;&#xA;" OwnerUserId="20744" LastActivityDate="2016-05-03T06:00:57.040" Title="Can Arduino be used as an FDTI Programmer?" Tags="|arduino-uno|esp8266|ftdi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23813" PostTypeId="2" ParentId="23812" CreationDate="2016-05-03T06:00:57.040" Score="2" Body="&lt;p&gt;Yes. Tie the reset pin on the ISP connector low to keep the ATmega328P in reset, then you can connect pins 0 and 1 to the ESP module to communicate using the Uno's USB-UART bridge. Since the pins are labelled from the perspective of the '328P, connect TX to TX and RX to RX.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-03T06:00:57.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23814" PostTypeId="1" CreationDate="2016-05-03T07:40:25.210" Score="0" ViewCount="1191" Body="&lt;p&gt;I have created an gui in python using pyserial to communicate with Arduino but my serial monitor does not show up it says (Serial port busy) whenever I run the gui.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The gui works fine but when I want to see the printed data for that, I am using an external LCD but I was wondering if there was a way to see the data in serial monitor. If not could you explain why? I have no idea whatsoever why is this happening.&lt;/p&gt;&#xA;" OwnerUserId="20749" LastEditorUserId="19515" LastEditDate="2016-05-03T08:51:06.553" LastActivityDate="2021-01-21T10:02:50.457" Title="My serial Monitor of the Arduino ide does not show up when running Gui?" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23815" PostTypeId="1" AcceptedAnswerId="23819" CreationDate="2016-05-03T07:43:54.320" Score="8" ViewCount="6204" Body="&lt;p&gt;I just bought esp8266 and ftdi usb driver, I want to power the esp8266 with Arduino's 3.3 V output, is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw some tutorial on youtube in that they are suggesting us to use 3.3v regulator ic instead of directly power 3.3 V of Arduino or ftdi driver's 3.3 V output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect my ftdi or Arduino output directly into esp8266 is there a chance to damage the esp8266?&lt;/p&gt;&#xA;" OwnerUserId="20750" LastEditorUserId="19515" LastEditDate="2016-05-03T08:43:31.753" LastActivityDate="2019-03-24T17:03:27.777" Title="Can I use arduino's 3.3 V output directly to esp8266?" Tags="|arduino-uno|arduino-ide|wifi|esp8266|voltage-protection|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23817" PostTypeId="2" ParentId="23815" CreationDate="2016-05-03T08:14:38.673" Score="1" Body="&lt;p&gt;The specs for the Uno say that it does not provide as much current on the 3.3V line as the specs for the ESP8266 requires. You will need to provide another regulator that can supply enough current.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-03T08:14:38.673" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23819" PostTypeId="2" ParentId="23815" CreationDate="2016-05-03T08:48:37.800" Score="9" Body="&lt;p&gt;You should search for this data yourself, but since you are saying you are a newbie I'll tell you how to find this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all you should search for a document called &quot;datasheet&quot;. On a datasheet the producer writes all the relevant data about his product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, you should search for the electrical characteristics of the ESP8266. For instance &lt;a href=&quot;https://cdn-shop.adafruit.com/product-files/2471/0A-ESP8266__Datasheet__EN_v4.3.pdf&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; you have one of the datasheets. On page 13, there is the &quot;Power consumption&quot; chart, which says that the worst case has a typical current of 170mA. I suggest you to raise it a bit; let's say you need 250mA for the ESP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, the arduino. You should search for the schematic of the board or read the part number of the 3.3V regulator. Since it's easier from the schematic and they released it on the web, you can see that the part number of the 3.3V regulator is LP2985. Searching for it on google will lead you to &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/lp2985-33.pdf&quot; rel=&quot;noreferrer&quot;&gt;the texas instruments webpage&lt;/a&gt;, with the datasheet. Here you can see that the maximum output current is 150mA, so below the required current. Answer: you can't with arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the FT232 cable, you should search for it because there are different models. Search on google and pick the first link pointing to the ftdi website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an example, the TTL-232RG has &lt;a href=&quot;http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232RG_CABLES.pdf&quot; rel=&quot;noreferrer&quot;&gt;this datasheet&lt;/a&gt;. On page 9 they say that the TTL-232RG-VSW3V3-WE has an output current of 50mA, so you can't use it. The TTL-232RG-VREG3V3-WE, on the other side, has a maximum output current of 250mA, so you can use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have further questions, just ask here ;)&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-05-03T08:48:37.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23821" PostTypeId="2" ParentId="23780" CreationDate="2016-05-03T09:25:16.107" Score="0" Body="&lt;p&gt;There are two basic things you are doing wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly your HTTP request is wrongly formatted.  You have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA&#xA;Host:api.thingspeak.com&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What it should look like is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA HTTP/1.0&#xA;Host: api.thingspeak.com:80&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you only need &lt;em&gt;one&lt;/em&gt; blank line after your request, not 5 as you seem to have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly you are not actually doing anything with the data the site is sending you. You make the request with &lt;code&gt;+CIPSEND=&lt;/code&gt; but then the response, which is in the form &lt;code&gt;+IPD,&amp;lt;len&amp;gt;:&amp;lt;data&amp;gt;&lt;/code&gt; is completely ignored.  You need to use the SoftwareSerial's &lt;code&gt;.read()&lt;/code&gt; and associated functions to receive that data into the Arduino so you can actually do something with it - like send it down through Serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tips:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Look for &lt;code&gt;+IPD,&lt;/code&gt; first&lt;/li&gt;&#xA;&lt;li&gt;Read up to the : and interpret it as a number&lt;/li&gt;&#xA;&lt;li&gt;You now now how many bytes to read from the data section&lt;/li&gt;&#xA;&lt;li&gt;Read that data&lt;/li&gt;&#xA;&lt;li&gt;Do something with it&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-03T10:25:32.553" LastActivityDate="2016-05-03T10:25:32.553" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23823" PostTypeId="2" ParentId="23814" CreationDate="2016-05-03T10:52:35.130" Score="0" Body="&lt;p&gt;If an application is already using the serial port then you won't be able to reopen it.  In this case you Python GUI is communicating with the Arduino over the serial port, so the IDE can't.  Think back to when you are just using the IDE, the serial monitor is closed whenever you upload a new version of the code to the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, how do you solve it.  The simplest answer is to use another serial port for the Python app to talk to the Arduino and leave the default port free for the Arduino IDE/Serial monitor.  Software serial should work, you might need to print to both serial ports from the Arduino, but you can do that by adding another function.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative might be to modify your python app to rebroadcast the debug data to another serial port and then connect to this via hyper terminal.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-03T10:52:35.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23824" PostTypeId="2" ParentId="23803" CreationDate="2016-05-03T10:58:11.477" Score="0" Body="&lt;p&gt;According to the data sheet each LED takes a maximum of 3*20mA, so you are pulling 300mA.  You  are going to need a bigger power supply :(&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-03T10:58:11.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23826" PostTypeId="1" AcceptedAnswerId="23833" CreationDate="2016-05-03T11:35:04.623" Score="1" ViewCount="359" Body="&lt;p&gt;I have a pretty simple project, where some data has to be read from a mySQL server. My idea is to do this with an ESP8266, and then provide that data to the Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible or am I going to have to use the ESP8266 itself? I highly doubt that I would have enough pins then.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read something about AT-commands. But I have no idea how to send those commands to the ESP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Michidez&lt;/p&gt;&#xA;" OwnerUserId="20440" LastActivityDate="2016-05-08T10:43:43.950" Title="ESP8266 as WiFi for Arduino" Tags="|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23827" PostTypeId="1" CreationDate="2016-05-03T11:45:41.127" Score="0" ViewCount="4119" Body="&lt;p&gt;I am using &lt;code&gt;Arduino IDE 1.6.8&lt;/code&gt; and I am trying to compile the following code &lt;a href=&quot;https://github.com/RobotShop/Wheatstone-Bridge-Amplifier-Shield/tree/master/Examples/strain_gauge_shield_and_lcd_arduino_uno_code&quot; rel=&quot;nofollow&quot;&gt;Wheatstone Bridge&lt;/a&gt;. I have currently a really weird error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unknown type name 'LiquidCrystal'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This error seems to come from the header file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Include the Wheatstone library&#xA;#include &amp;lt;WheatstoneBridge.h&amp;gt;&#xA;&#xA;// Include the LCD library&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// Declare external global lcd&#xA;extern LiquidCrystal lcd; &amp;lt;&amp;lt;&amp;lt;Error&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have already installed the &lt;code&gt;LiquidCrystal&lt;/code&gt; library but I don't know if this trouble is due to the compiler (and the IDE) or something is wrong. The compiler seems to find the right libraries...&lt;/p&gt;&#xA;" OwnerUserId="17063" LastActivityDate="2016-06-02T13:42:18.897" Title="Error on Arduino Code (unknown type name 'LiquidCrystal')" Tags="|lcd|compile|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23829" PostTypeId="2" ParentId="23827" CreationDate="2016-05-03T12:02:07.193" Score="0" Body="&lt;p&gt;Download the Liquidcrystal.zip file from this link,&#xA;&lt;a href=&quot;http://playground.arduino.cc/Main/LiquidCrystal&quot; rel=&quot;nofollow&quot;&gt;Crystal link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now add that file into documents/Arduino/libraries folder.&#xA;Now check if the library is added in the library.&#xA;It should probably work.&lt;/p&gt;&#xA;" OwnerUserId="20757" LastActivityDate="2016-05-03T12:02:07.193" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23831" PostTypeId="2" ParentId="23827" CreationDate="2016-05-03T12:49:13.697" Score="1" Body="&lt;p&gt;Using &quot;extern&quot; when instantiating a class is unusual.  We can not tell what your intentions are because this is only part of your code.  However it would be my guess that this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Declare external global lcd&#xA;extern LiquidCrystal lcd;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Should actually be written like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Declare external global lcd&#xA;LiquidCrystal lcd((12, 11, 5, 4, 3, 2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is making a BIG assumption that you are using an LCD similar to the one used in the HelloWorld example and you have connected it using the same pins!  Comments from the HelloWorld example to help you out:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; * LCD RS pin to digital pin 12&#xA; * LCD Enable pin to digital pin 11&#xA; * LCD D4 pin to digital pin 5&#xA; * LCD D5 pin to digital pin 4&#xA; * LCD D6 pin to digital pin 3&#xA; * LCD D7 pin to digital pin 2&#xA; * LCD R/W pin to ground&#xA; * LCD VSS pin to ground&#xA; * LCD VCC pin to 5V&#xA; * 10K resistor:&#xA; * ends to +5V and ground&#xA; * wiper to LCD VO pin (pin 3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Background:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino sketches are written mostly in C while the libraries take advantage of C++.  As such the libraries can use a C++ feature called &quot;overloading&quot;.  This is where you can have several different functions with different parameters all with the same name. The advantage is that you can call upon slightly different functions (or in this case different classes) simply by altering what is passed.  The LiquidCrystal class has defined all these possibilities:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  LiquidCrystal(uint8_t rs, uint8_t enable,&#xA;        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,&#xA;        uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);&#xA;  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,&#xA;        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,&#xA;        uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);&#xA;  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,&#xA;        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);&#xA;  LiquidCrystal(uint8_t rs, uint8_t enable,&#xA;        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in none are there no parameters.  That is why the compiler could not find the class in your code.  You needed to match one of the above class types.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-03T13:21:56.627" LastActivityDate="2016-05-03T13:21:56.627" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23832" PostTypeId="2" ParentId="23826" CreationDate="2016-05-03T13:07:09.840" Score="2" Body="&lt;p&gt;Check out ESP-LINK &lt;a href=&quot;https://github.com/jeelabs/esp-link&quot; rel=&quot;nofollow&quot;&gt;You can find it here&lt;/a&gt;&#xA;ESP-LINK is a esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer. It has several configuration, one of them allowes uploading new firware ower wifi, or to act as a serial link just like if usb cable is pluged in and serialport viewer is active. The website has great documentation and has one of the slickest configuration interfaces seen on ESP. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastEditorUserId="17211" LastEditDate="2016-05-08T10:43:43.950" LastActivityDate="2016-05-08T10:43:43.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23833" PostTypeId="2" ParentId="23826" CreationDate="2016-05-03T13:10:17.697" Score="1" Body="&lt;p&gt;Yes its possible, you can use the ESP8266 as a dumb Wifi to Serial convertor.  Set you Arduino IDE up so you can program the ESP8266 like an Arduino, and then write a simple program to connect to the WIFI network and read the data from the server, then just print it to the default serial console with a special sequence of characters at the beginning of each line, like 'DATA'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the serial port on the ESP8266 to the Mega, don't forget top cross the RX and TX wires and then write a program on the mega that reads from the serial port you have allocated and only process lines beginning with the special sequence of characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes you could use the AT commands, but that involves a fair amount of learning. pain and different software, when you already probably have the knowledge that you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the later version of the ESP8226 can run at 160MHz and have 1MByte or memory so you might want to hand off some of the data crunching to the ESP.  (But that's a decision for later, once its working).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-03T13:10:17.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23834" PostTypeId="2" ParentId="23793" CreationDate="2016-05-03T13:22:06.983" Score="1" Body="&lt;p&gt;I have looked into something very similar and I think the reason you are finding it difficult to find information is you are viewing the full system.  Break it down into smaller chunks and you will get more chance of finding a match.  So lets look at the camera and then the rest of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think that the reason you can't get an answer for this is that you can't do what you want with what you have.  My research seems to say that the OVO7670 camera needs a separate micro processor and 'special' RAM to work (can't remember what is special about the RAM at the moment).  There is a board that does this called a 'PIXY', but its not cheap.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the plus side, connecting an Arduino to Android via blue tooth should be quite simple there should be lots of examples on how to set up the Arduino side.  You then need to define to convey your messages between your server an client and I know you aren't asking how to turn a LED on and off from an Arduino. (If you are please see the Example Blink).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should have 18 pins on you OV7670.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;3v3 - 3.3v&lt;/li&gt;&#xA;&lt;li&gt;Gnd - Ground&lt;/li&gt;&#xA;&lt;li&gt;SIOC - Input - I2C Clock&lt;/li&gt;&#xA;&lt;li&gt;SIOD - I/O - I2C Data&lt;/li&gt;&#xA;&lt;li&gt;VSYNC - Output - Vertical Synch&lt;/li&gt;&#xA;&lt;li&gt;HREF - Output - Horizontal Synch&lt;/li&gt;&#xA;&lt;li&gt;PCLK - Output - Pixel Clock&lt;/li&gt;&#xA;&lt;li&gt;XCLK - Input - System Clock&lt;/li&gt;&#xA;&lt;li&gt;D7 - Output - Data bit 7 (MSB)&lt;/li&gt;&#xA;&lt;li&gt;D6 - Output - Data bit 6&lt;/li&gt;&#xA;&lt;li&gt;D5 - Output - Data bit 5&lt;/li&gt;&#xA;&lt;li&gt;D4 - Output - Data bit 4&lt;/li&gt;&#xA;&lt;li&gt;D3 - Output - Data bit 3&lt;/li&gt;&#xA;&lt;li&gt;D2 - Output - Data bit 2&lt;/li&gt;&#xA;&lt;li&gt;D1 - Output - Data bit 1&lt;/li&gt;&#xA;&lt;li&gt;D0 - Output - Data bit 0 (LSB)&lt;/li&gt;&#xA;&lt;li&gt;RESET - Input - RESET - Low to reset&lt;/li&gt;&#xA;&lt;li&gt;PWDN - Input - Power Down - High to activate&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2016-08-05T12:26:39.093" LastActivityDate="2016-08-05T12:26:39.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23835" PostTypeId="1" CreationDate="2016-05-03T13:37:33.547" Score="0" ViewCount="396" Body="&lt;p&gt;Well this was unexpected. &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html&quot; rel=&quot;nofollow&quot;&gt;AVR libc&lt;/a&gt; has many the variants of &lt;code&gt;printf&lt;/code&gt;, including &lt;code&gt;vprintf&lt;/code&gt;, but is missing &lt;code&gt;vprintf_P&lt;/code&gt;. Is this really just not present or implemented elsewhere?&lt;/p&gt;&#xA;" OwnerUserId="18795" LastActivityDate="2016-05-03T14:36:16.617" Title="AVR has no vprintf_P?" Tags="|avr|printf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23836" PostTypeId="2" ParentId="23835" CreationDate="2016-05-03T13:47:19.037" Score="-1" Body="&lt;p&gt;It has &lt;code&gt;vfprintf_P&lt;/code&gt; and &lt;code&gt;stdout&lt;/code&gt; is a &lt;code&gt;FILE&lt;/code&gt;. Why would you want to waste time and space with implementing &lt;code&gt;vprintf_P&lt;/code&gt; as well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;really&lt;/em&gt; want it, you can make your own:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define vprintf_P(...) vfprintf_P(stdout, __VA_ARGS__)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Incidentally, the source code to &lt;code&gt;vprintf&lt;/code&gt; looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int&#xA;vprintf(const char *fmt, va_list ap)&#xA;{&#xA;    return vfprintf(stdout, fmt, ap);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does exactly the same job as a preprocessor macro - just forwards your request on to the FILE-based function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is actually more efficient to use a preprocessor macro than needlessly nesting functions like that - less stack usage, less calls, etc (unless the compiler happens to choose to &lt;em&gt;inline&lt;/em&gt; that function, which since it is in a library it likely won't).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The non-FILE based functions can be considered simple &lt;em&gt;wrapper&lt;/em&gt; functions to the FILE-based ones. They are mostly provided for convenience, but are actually completely redundant and can all be replaced with direct calls to the FILE-based variant.  They mostly still exist purely for historical compatibility. And since &lt;code&gt;_P&lt;/code&gt; is specific to AVR libc there is nothing historical for it to be compatible with.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-03T14:36:16.617" LastActivityDate="2016-05-03T14:36:16.617" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23837" PostTypeId="2" ParentId="21673" CreationDate="2016-05-03T16:05:27.813" Score="1" Body="&lt;p&gt;I have the same issue with Huzzah and a PIR. The PIR is noisy and I get a false high every 10-20s while the code runs without any problem on an UNO.&#xA;I think it is a problem of HF coupling from wifi interfering with the PIR's amplification circuit. I will try shielding and caps/ferrites to get rid of the HF on the PIR or use another power supply and couple the signal line via optocoupler.&lt;/p&gt;&#xA;" OwnerUserId="20761" LastActivityDate="2016-05-03T16:05:27.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23838" PostTypeId="2" ParentId="21673" CreationDate="2016-05-03T16:15:55.940" Score="2" Body="&lt;p&gt;I'm sure you have probably done both these, but just in case you haven't...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see from your code you are using Pin 2 for the PIR sensor.  I'm sure your not as dumb as I am every time I program a ESP8266, but check you have connected the PIR to pin 2, that's not the connection labelled D2 its GPIO2, which may or may not be labelled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that's right then the next possible problem may be that GPIO2 is shared with TXD1, its possible that this is being used.  So try moving to GPIO4.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-03T16:15:55.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23840" PostTypeId="2" ParentId="8821" CreationDate="2016-05-03T16:35:45.760" Score="1" Body="&lt;p&gt;Your problem is that your board doesn't have the bootloader loaded into the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have success with the ATMEL-ICE ISP because it is an in-system programmer (ISP) and you are downloading the code directly into the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you use the USB, I see from your output that the programmer is &quot;butterfly&quot; and the description indicates AVR109. These both indicate that the program is trying to be loaded through a bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bootloader is a bit of code that resides in the codespace section of flash. It allows you to send the program through the UART. The bootloader then saves it to the codespace section of flash such that both the bootloader and your program co-exist.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, use the Arduino IDE along with your ATMEL-ICE ISP to load the bootloader into the microcontroller. This can be done by going into &lt;code&gt;Tools&lt;/code&gt; and then &lt;code&gt;Burn Bootloader&lt;/code&gt; (of course with the correct programmer selected).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will then allow you to download your code through the Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. You can program your sketch straight to your Arduino using your ATMEL-ICE ISP without downloading the bootloader. Do this by selecting the &lt;code&gt;Upload Using Programmer&lt;/code&gt; option in the menus.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2020-05-07T01:51:48.790" LastActivityDate="2020-05-07T01:51:48.790" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23841" PostTypeId="1" AcceptedAnswerId="35053" CreationDate="2016-05-03T17:08:21.287" Score="0" ViewCount="1369" Body="&lt;p&gt;I have been using an AVRISPmkII for many years but recently gave mine away to another hobbiest. I wnated to buy a replacement and have had to buy an ATMEL-ICE ISP as the AVRISPmkII is now unavailable.&lt;/p&gt;&#xA;&lt;p&gt;Occasionally, I like to program the Arduino Uno from the Arduino IDE using the ISP.&lt;/p&gt;&#xA;&lt;p&gt;However when I go to select the programmer (from the tools menu), I don't see the ATMEL-ICE in the list.&lt;/p&gt;&#xA;&lt;p&gt;How do I get Arduino IDE to recognize the ATMEL-ICE ISP?&lt;/p&gt;&#xA;&lt;p&gt;Note: I am using Arduino IDE v1.6.8.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2020-10-04T14:41:10.373" LastActivityDate="2020-10-04T14:41:10.373" Title="What programmer do I select in Arduino IDE for the ATMEL-ICE ISP?" Tags="|arduino-uno|arduino-ide|isp|programmer|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="23842" PostTypeId="1" CreationDate="2016-05-03T17:09:41.937" Score="-1" ViewCount="2870" Body="&lt;p&gt;I want to design three phase sine wave inverter using Arduino I found this link with circuit diagram and simulation results but he did not provide code. can anyone help me with code &lt;a href=&quot;http://microcontrollerslab.com/three-phase-sine-wave-inverter/&quot; rel=&quot;nofollow&quot;&gt;http://microcontrollerslab.com/three-phase-sine-wave-inverter/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10441" LastActivityDate="2019-02-03T06:32:46.620" Title="Three phase sine wave inverter using Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23843" PostTypeId="2" ParentId="23814" CreationDate="2016-05-03T17:10:34.723" Score="1" Body="&lt;p&gt;The problem is simple, you are dealing PySerial using the serial communication port arduino, so you can not communicate with Arduino IDE and python at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the program you should print python q values you need, with the Print command, so you'll see in the CMD same as you see in the Arduino serial monitor.&lt;/p&gt;&#xA;" OwnerUserId="20764" LastActivityDate="2016-05-03T17:10:34.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23846" PostTypeId="1" CreationDate="2016-05-03T18:07:05.560" Score="2" ViewCount="480" Body="&lt;p&gt;So we have the tone library, which produces a 50% duty cycle square wave of varying frequency, and &lt;code&gt;analogWrite()&lt;/code&gt; which produces a fixed frequency wave of varying duty cycle. Is there any way to control frequency and duty cycle at the same time on an Atmega328-based board?&lt;/p&gt;&#xA;" OwnerUserId="3029" LastActivityDate="2016-05-03T18:07:05.560" Title="How to use the timer to generate a pulse wave of the specified frequency and duty cycle" Tags="|atmega328|timers|frequency|analogwrite|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23848" PostTypeId="2" ParentId="23743" CreationDate="2016-05-03T20:02:01.963" Score="0" Body="&lt;p&gt;If you want to do Makefile-like tricks, one possibility is to use a&#xA;Makefile-based workflow instead of the Arduino IDE. There are a few&#xA;generic Arduino Makefiles floating around the Web. One quite popular is&#xA;&lt;a href=&quot;https://github.com/sudar/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;Sudar Muthu's Arduino&#xA;Makefile&lt;/a&gt;. With it, you just&#xA;write a small per-project Makefile that sets a few variables and then&#xA;includes the generic Makefile. There is one limitation with this&#xA;approach though: the Arduino IDE normally modifies your .ino file before&#xA;submitting it to the compiler, in two ways:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It #includes &amp;lt;Arduino.h&amp;gt;&lt;/li&gt;&#xA;&lt;li&gt;It writes prototypes near the beginning of the program for every&#xA;function you define.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sudar Muthu's Makefile does include Arduino.h (it does not touch your&#xA;code, using instead the &lt;code&gt;-include&lt;/code&gt; gcc option), but it does &lt;em&gt;not&lt;/em&gt; write&#xA;the function prototypes for you. It is thus not 100% compatible with the&#xA;Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility would be to completely write yourself a Makefile&#xA;that calls &lt;a href=&quot;https://github.com/arduino/arduino-builder&quot; rel=&quot;nofollow&quot;&gt;Arduino&#xA;Builder&lt;/a&gt;. This should be&#xA;100% compatible with the IDE.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-03T20:02:01.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23850" PostTypeId="1" AcceptedAnswerId="23851" CreationDate="2016-05-03T20:56:48.657" Score="0" ViewCount="482" Body="&lt;p&gt;Try verifying the code to see the errors.  This is on a arduino nano with a 328 processor.  I put the necessary library in the code.&#xA;&lt;a href=&quot;http://pastebin.com/TbTJQfBn&quot; rel=&quot;nofollow&quot;&gt;Pastebin for code&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #ifndef Pushbutton_h &#xA;#define Pushbutton_h &#xA;&#xA;&#xA;#include &amp;lt;Arduino.h&amp;gt; &#xA;&#xA;&#xA;#define PULL_UP_DISABLED    0 &#xA;#define PULL_UP_ENABLED     1 &#xA;&#xA;&#xA;#define DEFAULT_STATE_LOW   0 &#xA;#define DEFAULT_STATE_HIGH  1 &#xA;&#xA;&#xA;/*! \brief The pin used for the button on the &#xA; * [Zumo Shield for Arduino](http://www.pololu.com/product/2504). &#xA; * &#xA; * This does not really belong here in this general pushbutton library and will &#xA; * probably be removed in the future. */ &#xA;#define ZUMO_BUTTON 12 &#xA;&#xA;&#xA;class PushbuttonStateMachine &#xA;{ &#xA;public: &#xA;  PushbuttonStateMachine(); &#xA;  bool getSingleDebouncedRisingEdge(bool value); &#xA;private: &#xA;  uint8_t state; &#xA;  uint16_t prevTimeMillis; &#xA;}; &#xA;&#xA;&#xA;class PushbuttonBase &#xA;{ &#xA;public: &#xA;&#xA;&#xA;  PushbuttonBase(); &#xA;&#xA;&#xA;  // wait for button to be pressed, released, or pressed and released &#xA;  void waitForPress(); &#xA;  void waitForRelease(); &#xA;  void waitForButton(); &#xA;&#xA;&#xA;  // more complex functions that return true once for each button transition &#xA;  // from released to pressed or pressed to released &#xA;  bool getSingleDebouncedPress(); &#xA;  bool getSingleDebouncedRelease(); &#xA;&#xA;  // indicates whether button is currently pressed &#xA;  bool isPressed(); &#xA;&#xA;&#xA;  // Initializes I/O pin for use as button input. &#xA;  // This gets called automatically so normally you will not need to call this, &#xA;  // but it might be useful if the pin for the button is in the wrong state. &#xA;  virtual void init2() = 0; &#xA;&#xA;&#xA;protected: &#xA;&#xA;&#xA;  virtual bool _isPressed() = 0; &#xA;&#xA;&#xA;private: &#xA;&#xA;&#xA;  PushbuttonStateMachine pressState; &#xA;  PushbuttonStateMachine releaseState; &#xA;  bool initialized; &#xA;&#xA;&#xA;  // TODO: move all this init stuff down into Pushbutton &#xA;  inline void init() &#xA;  { &#xA;    if (!initialized) &#xA;    { &#xA;      initialized = true; &#xA;      init2(); &#xA;    } &#xA;  } &#xA;}; &#xA;&#xA;&#xA;/* \class Pushbutton Pushbutton.h &#xA; * \brief Interface with pushbuttons on dedicated pins. &#xA; * &#xA; */ &#xA;class Pushbutton : public PushbuttonBase &#xA;{ &#xA;public: &#xA;&#xA;&#xA;  // constructor; takes arguments specifying whether to enable internal pull-up &#xA;  // and the default state of the pin that the button is connected to &#xA;  Pushbutton(uint8_t pin, uint8_t pullUp = PULL_UP_ENABLED, &#xA;      uint8_t defaultState = DEFAULT_STATE_HIGH); &#xA;&#xA;  virtual void init2(); &#xA;&#xA;&#xA;protected: &#xA;&#xA;&#xA;  virtual bool _isPressed(); &#xA;&#xA;&#xA;private: &#xA;&#xA;&#xA;   uint8_t _pin; &#xA;   bool _pullUp; &#xA;   bool _defaultState; &#xA; }; &#xA;&#xA; #endif &#xA;&#xA;&#xA;&#xA;&#xA;&#xA;// PIN Configurations #define SEARCH_SPEED 255 &#xA;&#xA;#define echoPin A0 &#xA;#define triggerPin 3 &#xA;#define rightBackMotor 4 &#xA;#define rightMotorSpeed 10 &#xA;#define leftMotorSpeed 9 &#xA;#define leftForwardMotor 7  //if a motor goes backward swap the number on the FwdPin and BckPin &#xA;#define rightForwardMotor 8   //if a motor goes backward swap the number on the FwdPin and BckPin &#xA;#define leftBackMotor 11 &#xA;#define LED 13 &#xA;#define leftSensor A1 &#xA;#define rightSensor A2 &#xA;#define IRdriver 6 &#xA;&#xA;&#xA;// Robot Configuration Parameters &#xA;// Speed range is -255 -&amp;gt; 255 &#xA;#define MAX_SPEED 255 &#xA;#define QTR_Threshold 500 &#xA;#define ATTACK_DISTANCE 25 &#xA;#define BACKUP_DISTANCE 4000 &#xA;#define SEARCH_SPEED 255&#xA;&#xA;&#xA;// State variables &#xA;bool isBackup = false; &#xA;int backupTimer = 0; &#xA;long distance = 1000; &#xA;Pushbutton button(ZUMO_BUTTON); &#xA;&#xA;&#xA;void setSpeed(int speed, int motor); &#xA;&#xA;&#xA;void setup() { &#xA;   Serial.begin(9600); &#xA;   Serial.println(&quot;Setup.&quot;); &#xA;&#xA;&#xA;  pinSetup(); &#xA;&#xA;&#xA;   Serial.println(&quot;Waiting for button&quot;); &#xA;} &#xA;&#xA;&#xA;void loop() { &#xA;   digitalWrite(IRdriver, HIGH); &#xA;&#xA;  if (button.isPressed()) { &#xA;    // if button is pressed, stop and wait for another press to go again &#xA;    button.waitForRelease(); &#xA;    waitForButtonAndCountDown(); &#xA; } &#xA;&#xA;&#xA;  int leftInput = analogRead(leftSensor); &#xA;  int rightInput = analogRead(rightSensor); &#xA;&#xA;&#xA;  if ( isBackup ) { &#xA;    backupTimer = backupTimer + 1; &#xA;    setSpeed(-MAX_SPEED, 0); &#xA;    setSpeed(-MAX_SPEED + 20, 1); &#xA;    if (backupTimer &amp;gt;= BACKUP_DISTANCE ) { &#xA;      isBackup = false; &#xA;      backupTimer = 0; &#xA;    } &#xA;  } else { &#xA;    if ( leftInput &amp;lt;= 500 || rightInput &amp;lt;= 500 ) { // WHITE LINE ABORT! &#xA;      //Serial.println(&quot;Abort! - &quot;); Serial.println(leftInput); Serial.println(rightInput); &#xA;      isBackup = true; &#xA;      setSpeed(-MAX_SPEED, 0); &#xA;      setSpeed(-MAX_SPEED, 1); &#xA;    } else { &#xA;      distance = getDistance(); &#xA;      if ( distance &amp;lt;= ATTACK_DISTANCE ) { // ATTACK! &#xA;        Serial.println(&quot;Attack!&quot;); &#xA;        setSpeed(MAX_SPEED, 0); &#xA;        setSpeed(MAX_SPEED, 1); &#xA;      } else { // search &#xA;        // TODO(erh): implement other searching algorithms &#xA;        Serial.println(&quot;Search&quot;);  &#xA;        setSpeed(SEARCH_SPEED, 0);&#xA;        setSpeed(-SEARCH_SPEED, 1); &#xA;      } &#xA;    } &#xA;  } &#xA;} &#xA;&#xA;&#xA;void pinSetup() { &#xA;  // motors! &#xA;  pinMode(leftMotorSpeed, OUTPUT); &#xA;  pinMode(rightMotorSpeed, OUTPUT); &#xA;  pinMode(leftForwardMotor, OUTPUT); &#xA;  pinMode(leftBackMotor, OUTPUT); &#xA;  pinMode(rightForwardMotor, OUTPUT); &#xA;  pinMode(rightBackMotor, OUTPUT); &#xA;&#xA;   // sonar sensor &#xA;  pinMode(LED, HIGH); &#xA;  pinMode(triggerPin, OUTPUT); &#xA;  pinMode(echoPin, INPUT); &#xA;&#xA;&#xA;  // qtr light sensor &#xA;  pinMode(leftSensor, INPUT); &#xA;  pinMode(rightSensor, INPUT); &#xA;  pinMode(IRdriver, OUTPUT); &#xA;} &#xA;&#xA;&#xA;void setSpeed(int speed, int motor = 0) { &#xA;  int speedPin, forwardPin, backPin; &#xA;  if ( motor == 0 ) { &#xA;    speedPin = leftMotorSpeed; &#xA;    forwardPin = leftForwardMotor; &#xA;    backPin = leftBackMotor; &#xA;  } else if ( motor == 1 ) { &#xA;    speedPin = rightMotorSpeed; &#xA;    forwardPin = rightForwardMotor; &#xA;    backPin = rightBackMotor; &#xA;  } &#xA;&#xA;&#xA;  if ( speed == 0 ) { &#xA;    analogWrite(speedPin, 0); &#xA;    digitalWrite(forwardPin, LOW); &#xA;    digitalWrite(backPin, LOW); &#xA;  } else if ( speed &amp;gt; 0 ) { &#xA;    digitalWrite(forwardPin, HIGH); &#xA;    digitalWrite(backPin, LOW); &#xA;    analogWrite(speedPin, speed); &#xA;  } else if ( speed &amp;lt; 0 ) { &#xA;    digitalWrite(forwardPin, LOW); &#xA;    digitalWrite(backPin, HIGH); &#xA;    analogWrite(speedPin, abs(speed)); &#xA;  } &#xA;} &#xA;&#xA;&#xA;long getDistance() { &#xA;  long duration, distance; &#xA;  digitalWrite(triggerPin, LOW);  // Added this line &#xA;  delayMicroseconds(2); // Added this line &#xA;  digitalWrite(triggerPin, HIGH); &#xA;  delayMicroseconds(10); // Added this line &#xA;  digitalWrite(triggerPin, LOW); &#xA;  duration = pulseIn(echoPin, HIGH); &#xA;  distance = (duration/2) / 29.1; &#xA;  return distance; &#xA;} &#xA;&#xA;&#xA;void waitForButtonAndCountDown() { &#xA;  digitalWrite(LED, HIGH); &#xA;  button.waitForButton(); &#xA;  digitalWrite(LED, LOW); &#xA;&#xA;&#xA;  for (int i = 0; i &amp;lt; 3; i++ ) { &#xA;    Serial.println(i); &#xA;    delay(1000); &#xA;  } &#xA;&#xA;&#xA;  delay(1000); &#xA;  Serial.println(&quot;ATTACK!&quot;); &#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20771" LastEditorUserId="313" LastEditDate="2016-05-03T21:12:16.837" LastActivityDate="2016-07-03T12:56:38.477" Title="I'm having some undefined references and can't figure out why" Tags="|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23851" PostTypeId="2" ParentId="23850" CreationDate="2016-05-03T21:33:57.093" Score="1" Body="&lt;p&gt;Your code contains only the header declarations (&lt;code&gt;.h&lt;/code&gt; file) for those classes. There should also be another file (probably &lt;code&gt;.cpp&lt;/code&gt;) that actually implements the code for the classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you pasted looks very similar to the &lt;code&gt;Pushbutton&lt;/code&gt; stuff in &lt;a href=&quot;https://github.com/pololu/a-star-32u4-arduino-library&quot; rel=&quot;nofollow&quot;&gt;this project on GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look at their &lt;code&gt;Pushbutton.h&lt;/code&gt; and &lt;code&gt;Pushbutton.cpp&lt;/code&gt; files to get an idea of what I mean. In fact, you might be able to use those files instead of what you have. I can verify that it does compile, but not whether it works or not.&lt;/p&gt;&#xA;" OwnerUserId="20711" LastActivityDate="2016-05-03T21:33:57.093" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23852" PostTypeId="2" ParentId="17457" CreationDate="2016-05-03T22:10:46.393" Score="1" Body="&lt;p&gt;If it is going to be tiny, I would use continuous rotation servos and rubber belts. They are nice because you dont need motor drivers, unlike stepper motors. Also they consume a lot less power than stepper motors, so you may not need to attach them to external power (not just the arduino 5v). However, because you can not control how far they move, you will need buttons at the end of the race. I think you can get them from Adafruit.&lt;/p&gt;&#xA;" OwnerDisplayName="user20773" LastActivityDate="2016-05-03T22:10:46.393" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23855" PostTypeId="1" AcceptedAnswerId="23875" CreationDate="2016-05-04T02:53:51.210" Score="0" ViewCount="3041" Body="&lt;p&gt;I recently got one TFT LCD from aliexpress which supports SPI and uses ILI9341.&lt;/p&gt;&#xA;&lt;p&gt;This is the one.&lt;a href=&quot;http://www.aliexpress.com/item/Wholesale-1PC-2-2-Inch-240-320-Dots-SPI-TFT-LCD-Serial-Port-Module-Display-ILI9341/32508607290.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;TFT LCD&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have the ESP8266 EspressoLite 1 board, and I am using ESP8266 Arduino.&#xA;&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;(https://github.com/esp8266/Arduino)&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I made the following connection :&#xA;SCK #14, MOSI #13, MISO #12 and CS #4, DC #5,RESET #0&lt;/p&gt;&#xA;&lt;p&gt;and used the example graphicTest (which is available in the Adafruit_ILI9341-master folder) . I was able to make the display work for a few seconds.&#xA;In the graphic test, once the line test starts my ESP8266 gets restarted. This was getting repeated .&lt;/p&gt;&#xA;&lt;p&gt;In my existing project, I used the following code to just show some messages :&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_ILI9341 tft = Adafruit_ILI9341(4, 5, 13, 14, 0, 12);&#xA;  tft.begin()&#xA;  tft.fillScreen(ILI9341_BLACK);&#xA;  tft.setCursor(0, 0);&#xA;  tft.setTextColor(ILI9341_GREEN);  tft.setTextSize(4);&#xA;  tft.println(message);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The message is shown once a response is sent back from ESP. This works for a couple of times and then it again gets stuck and reboots.&lt;/p&gt;&#xA;&lt;p&gt;I am not sure whether I am using the optimised library for ESP8266 for this LCD or whether there is any as such.&lt;/p&gt;&#xA;&lt;p&gt;I read in forums and could see that there were some adafruit libraries in the ESP8266 Arduino but now that it is not available and only some TFT_Touch_Shield_V2 are present.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone faced the same issue or can tell me a better way to make this display work with ESP8266 Arduino.&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance. !!!&lt;/p&gt;&#xA;" OwnerUserId="15823" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-04T19:24:59.677" Title="ESP8266 Arduino 2.2inch ILI9341 TFT library" Tags="|lcd|esp8266|adafruit|tft|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23857" PostTypeId="1" CreationDate="2016-05-04T04:08:20.963" Score="1" ViewCount="2985" Body="&lt;p&gt;So. I would like to cycle through an array using a button. My current code goes through if statements when the button is pushed. In each if statement I have a loop to print out a list of strings. I am curious if there is anyway to directly cycle through an array using buttons instead of this indirect route I have taken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Last question - Is there a way to set the indents in the Arduino IDE to make formatting easier here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//------------------------------------------------------------------------------------------------&#xA;// Displays information when a push button is pressed. Also turns on and off a corresponding led.&#xA;// 5/3/2016&#xA;//------------------------------------------------------------------------------------------------&#xA;&#xA;// declare variables&#xA;&#xA;char* titles[] = {&#xA;  &quot;RELATION&quot;,&#xA;  &quot;FIRST NAME&quot;,&#xA;  &quot;LAST NAME&quot;,&#xA;  &quot;LOCATION&quot;,&#xA;  &quot;PHONE NUMBER&quot;&#xA;};&#xA;char* user_info[] = {&#xA;  &quot;SELF&quot;,&#xA;  &quot;JOHN&quot;,&#xA;  &quot;SMITH&quot;,&#xA;  &quot;FLORIDA&quot;,&#xA;  &quot;999-888-6666&quot;&#xA;};&#xA;char* econ_one[] = {&#xA;  &quot;BROTHER&quot;,&#xA;  &quot;MICHAEL&quot;,&#xA;  &quot;SMITH&quot;,&#xA;  &quot;FLORIDA&quot;,&#xA;  &quot;999-888-5555&quot;&#xA;};&#xA;char* econ_two[] = {&#xA;  &quot;WIFE&quot;,&#xA;  &quot;EMILY&quot;,&#xA;  &quot;SMITH&quot;,&#xA;  &quot;FLORIDA&quot;,&#xA;  &quot;999-888-4444&quot;&#xA;};&#xA;char* econ_three[] = {&#xA;  &quot;SISTER&quot;,&#xA;  &quot;SOPHIA&quot;,&#xA;  &quot;ADAMS&quot;,&#xA;  &quot;NEW YORK&quot;,&#xA;  &quot;888-777-3333&quot;&#xA;};&#xA;&#xA;int ledPinOne = 2;&#xA;int ledPinTwo = 3;&#xA;int ledPinThree = 4;&#xA;int ledPinFour = 5;&#xA;int buttonPin = 6;&#xA;int state = 0;&#xA;// setup - set pins&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPinOne, OUTPUT);&#xA;  pinMode(ledPinTwo, OUTPUT);&#xA;  pinMode(ledPinThree, OUTPUT);&#xA;  pinMode(ledPinFour, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;  Serial.println(&quot;Emergency Contact&quot;);&#xA;}&#xA;&#xA;// main&#xA;void loop() {&#xA;  if (digitalRead(buttonPin)) {&#xA;    if (state == 0) {&#xA;      int x;&#xA;      for (x = 0; x &amp;lt;= 4; x++) {&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.print(titles[x]);&#xA;        Serial.print(&quot; &quot;);&#xA;        Serial.print(user_info[x]);&#xA;      }&#xA;      Serial.println(&quot; &quot;);&#xA;      setLights(HIGH, LOW, LOW, LOW);&#xA;      state = 1;&#xA;    } else if (state == 1) {&#xA;      int y;&#xA;      for (y = 0; y &amp;lt;= 4; y++) {&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.print(titles[y]);&#xA;        Serial.print(&quot; &quot;);&#xA;        Serial.print(econ_one[y]);&#xA;      }&#xA;      Serial.println(&quot; &quot;);&#xA;      setLights(LOW, HIGH, LOW, LOW);&#xA;      state = 2;&#xA;    } else if (state == 2) {&#xA;      int z;&#xA;      for (z = 0; z &amp;lt;= 4; z++) {&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.print(titles[z]);&#xA;        Serial.print(&quot; &quot;);&#xA;        Serial.print(econ_two[z]);&#xA;      }&#xA;      Serial.println(&quot; &quot;);&#xA;      setLights(LOW, LOW, HIGH, LOW);&#xA;      state = 3;&#xA;    } else if (state == 3) {&#xA;      int q;&#xA;      for (q = 0; q &amp;lt;= 4; q++) {&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.print(titles[q]);&#xA;        Serial.print(&quot; &quot;);&#xA;        Serial.print(econ_three[q]);&#xA;      }&#xA;      Serial.println(&quot; &quot;);&#xA;      setLights(LOW, LOW, LOW, HIGH);&#xA;      state = 0;&#xA;    }&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&#xA;// function to turn LEDs on/off&#xA;&#xA;void setLights(int one, int two, int three, int four) {&#xA;  digitalWrite(ledPinOne, one);&#xA;  digitalWrite(ledPinTwo, two);&#xA;  digitalWrite(ledPinThree, three);&#xA;  digitalWrite(ledPinFour, four);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;output image&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.dropbox.com/sc/fwll0qe7cyye1mt/AAD5vI9buU_X0bl04KXFAQyja&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/sc/fwll0qe7cyye1mt/AAD5vI9buU_X0bl04KXFAQyja&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastEditorUserId="4628" LastEditDate="2017-05-01T08:16:36.377" LastActivityDate="2017-06-30T18:27:58.687" Title="Using a button to cycle an array" Tags="|array|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23859" PostTypeId="2" ParentId="14448" CreationDate="2016-05-04T07:08:49.983" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vJzZu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vJzZu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apply the pin 1, 2, 3 with 5v from Audrino passing through the resistors. Apply low voltage to pin-a to light up the led, so on so forth.&#xA;You can use the multi-meter to confirm the common pins and led pin.&#xA;For example touch the pin1 with (+) and pin-a with (-) of the multimeter.&#xA;If the pins are correct, led pin-a will light up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Picture Reference:&lt;a href=&quot;http://www.circuitstoday.com/voltmeter-using-arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.circuitstoday.com/voltmeter-using-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20783" LastActivityDate="2016-05-04T07:08:49.983" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23860" PostTypeId="2" ParentId="10020" CreationDate="2016-05-04T08:40:18.597" Score="3" Body="&lt;p&gt;Just write the amount of numbers you want to get float here Serial.println(val); after the val.&#xA;example:&#xA;Serial.println(val, 5);&#xA;It will give 5 digits after the decimal point&lt;/p&gt;&#xA;" OwnerUserId="20785" LastActivityDate="2016-05-04T08:40:18.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23861" PostTypeId="2" ParentId="23857" CreationDate="2016-05-04T09:24:59.013" Score="0" Body="&lt;p&gt;As for your question, your way is (kind of) the best way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just saw a problem: when you keep the button pressed you will go on showing. Moreover I really don't like the delay at the end, and if its purpose is just to avoid bounces, well, use the Bounce2 class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the repeated &lt;code&gt;if&lt;/code&gt;s, I prefer a &lt;code&gt;switch-case&lt;/code&gt; statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I highly suggest you to use the Bounce2 class, though. Here is an example of its usage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bounce debouncer = Bounce(); &#xA;&#xA;void setup()&#xA;{&#xA;    ...&#xA;    pinMode(buttonPin, INPUT);&#xA;    debouncer.attach(buttonPin);&#xA;    debouncer.interval(5); // interval in ms&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    debouncer.update();&#xA;    if (debouncer.rose())&#xA;    {&#xA;        switch (state)&#xA;        {&#xA;        case 0:&#xA;            {&#xA;                int x;&#xA;                for (x=0; x &amp;lt;= 4; x++)&#xA;                {&#xA;                    Serial.println(&quot; &quot;);&#xA;                    Serial.print(titles[x]);&#xA;                    Serial.print(&quot; &quot;);&#xA;                    Serial.print(user_info[x]);&#xA;                }&#xA;                Serial.println(&quot; &quot;);&#xA;                setLights(HIGH, LOW, LOW, LOW);&#xA;                state = 1;&#xA;            }&#xA;            break;&#xA;        case 1:&#xA;        ...&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the class has a &lt;code&gt;rose&lt;/code&gt; member, which tells you if the button was just pressed (only on the rising edge).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, your particular problem can be solved in another way. Since you are repeating the same code for all the cases, you can cycle through two arrays; one stating which is the second array you need to use, the other the lights.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is an example. Please note that I haven't tested it, so there might be some errors&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ** second_array[] = { user_info, econ_one, econ_two, econ_three }&#xA;uint8_t lights[][4] {   {HIGH, LOW, LOW, LOW},&#xA;                        {LOW, HIGH, LOW, LOW},&#xA;                        {LOW, LOW, HIGH, LOW},&#xA;                        {LOW, LOW, LOW, HIGH},&#xA;                    }&#xA;&#xA;void loop()&#xA;{&#xA;    debouncer.update();&#xA;    if (debouncer.rose())&#xA;    {&#xA;        int x;&#xA;        for (x=0; x &amp;lt;= 4; x++)&#xA;        {&#xA;            Serial.println(&quot; &quot;);&#xA;            Serial.print(titles[x]);&#xA;            Serial.print(&quot; &quot;);&#xA;            Serial.print(second_array[state][x]);&#xA;        }&#xA;        Serial.println(&quot; &quot;);&#xA;        setLights(lights[state][0], lights[state][1], lights[state][2], lights[state][3]);&#xA;        state++;&#xA;        if (state &amp;gt;= 4)&#xA;            state = 0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Try to use it and then report back if there is some issue ;)&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-05-04T09:24:59.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23863" PostTypeId="2" ParentId="19930" CreationDate="2016-05-04T12:39:55.570" Score="1" Body="&lt;p&gt;I would recommend you do not use speakers but instead send the output to a 3.5mm stereo plug, so you can use headphones or speakers.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is a 2.8&quot; inch display really necessary?  You could probably get away with a 1&quot; display and at a guess that would use less power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another idea may be to look at a Bluetooth interface for sending the sound to the headphones or speakers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also look at a WIFI interface to provide additional control interface and to allow downloads straight to the device.  (ESP8266 would probably be the easiest interface).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something you didn't mention was the power source.  Are you going to have internal batteries with a USB charging and power socket, so you can hook it to a PC or Batter Pack.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-04T12:39:55.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23865" PostTypeId="2" ParentId="23842" CreationDate="2016-05-04T13:04:31.033" Score="1" Body="&lt;p&gt;At the end of the page you are linking to, there is this notice:&#xA;&quot;Code for three phase inverter is not free of cost. If you want to purchase code, you can contact me at bilalmalikuet@gmail.com&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are Bilal Malik, you should already have the code since you are offering to sell it - unless you want someone here to write it for free so you can sell it afterward.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are NOT Bilal Malik, you should not impersonate someone else here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not a huge fan of the concept of intellectual property, but it seems you are trying to do something shady here.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-05-04T13:04:31.033" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23870" PostTypeId="2" ParentId="23857" CreationDate="2016-05-04T15:14:09.010" Score="1" Body="&lt;p&gt;I would recommend using multidemnsional arrays for both your contacts and your light states.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//------------------------------------------------ declare variables&#xA;&#xA;char* titles[] = {&quot;RELATION&quot;, &quot;FIRST NAME&quot;, &quot;LAST NAME&quot;, &quot;LOCATION&quot;, &quot;PHONE NUMBER&quot;};&#xA;&#xA;char* econs[][5] = {&#xA;  {&quot;SELF&quot;, &quot;JOHN&quot;, &quot;SMITH&quot;, &quot;FLORIDA&quot;, &quot;999-888-6666&quot;},&#xA;  {&quot;BROTHER&quot;, &quot;MICHAEL&quot;, &quot;SMITH&quot;, &quot;FLORIDA&quot;, &quot;999-888-5555&quot;},&#xA;  {&quot;WIFE&quot;, &quot;EMILY&quot;, &quot;SMITH&quot;, &quot;FLORIDA&quot;, &quot;999-888-4444&quot;},&#xA;  {&quot;SISTER&quot;, &quot;SOPHIA&quot;, &quot;ADAMS&quot;, &quot;NEW YORK&quot;, &quot;888-777-3333&quot;}&#xA;};&#xA;&#xA;uint8_t lights[][4] {   {HIGH, LOW, LOW, LOW},&#xA;  {LOW, HIGH, LOW, LOW},&#xA;  {LOW, LOW, HIGH, LOW},&#xA;  {LOW, LOW, LOW, HIGH},&#xA;};&#xA;&#xA;int ledPinOne = 2;&#xA;int ledPinTwo = 3;&#xA;int ledPinThree = 4;&#xA;int ledPinFour = 5;&#xA;int buttonPin = 6;&#xA;int state = 0;&#xA;&#xA;//------------------------------------------------ setup - set pins&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  pinMode(ledPinOne, OUTPUT);&#xA;  pinMode(ledPinTwo, OUTPUT);&#xA;  pinMode(ledPinThree, OUTPUT);&#xA;  pinMode(ledPinFour, OUTPUT);&#xA;  pinMode(buttonPin, INPUT);&#xA;&#xA;  Serial.println(&quot;Emergency Contact&quot;);&#xA;}&#xA;&#xA;//------------------------------------------------ main&#xA;void loop() {&#xA;&#xA;&#xA;  if (digitalRead(buttonPin))&#xA;  {&#xA;    if (state &amp;gt; 3)&#xA;      state = 0;&#xA;&#xA;    {&#xA;      for (int y = 0; y &amp;lt;= 4; y++)&#xA;      {&#xA;        Serial.println(&quot; &quot;);&#xA;        Serial.print(titles[y]);&#xA;        Serial.print(&quot; &quot;);&#xA;        Serial.print(econs[state][y]);&#xA;      }&#xA;&#xA;      Serial.println(&quot; &quot;);&#xA;      setLights(lights[state][0], lights[state][1], lights[state][2], lights[state][3]);&#xA;    }&#xA;&#xA;    delay(1000);&#xA;    state++;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;//------------------------------------------------ function to turn LEDs on/off&#xA;&#xA;void setLights(int one, int two, int three, int four)&#xA;{&#xA;  digitalWrite(ledPinOne, one);&#xA;  digitalWrite(ledPinTwo, two);&#xA;  digitalWrite(ledPinThree, three);&#xA;  digitalWrite(ledPinFour, four);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested the above, but it should provide the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the second part of your question, there is an autoformat tool in the Tools menu that will auto-indent your code. Ctrl-T will do the same.&lt;/p&gt;&#xA;" OwnerUserId="17137" LastEditorUserId="17137" LastEditDate="2016-05-05T12:54:38.913" LastActivityDate="2016-05-05T12:54:38.913" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23873" PostTypeId="1" AcceptedAnswerId="23910" CreationDate="2016-05-04T17:03:02.857" Score="1" ViewCount="450" Body="&lt;p&gt;The situation involves some Asm inline practice and a basic circuit. The program turns an LED on after a somewhat random period of time then waits until the button is pressed to report back how many milliseconds it took. This is then printed by the LCD shield. My confusion occurs because after each reset it prints a 1 before the button is pressed, which overlaps returned millisecond value on the screen giving me some false data. I tried to cut the code down so if there is anything else that might be helpful let me know. I think the issue may be in the test reaction time function but am not sure.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* --------------------------------------------------------------------------------------&#xA;  Includes&#xA;--------------------------------------------------------------------------------------*/&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;   // include LCD library&#xA;&#xA;&#xA;&#xA;/*--------------------------------------------------------------------------------------&#xA;  Init the LCD library with the LCD pins to be used&#xA;--------------------------------------------------------------------------------------*/&#xA;LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );   //Pins for the freetronics 16x2 LCD shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7 )&#xA;/*--------------------------------------------------------------------------------------&#xA;  setup()&#xA;  Called by the Arduino framework once, before the main loop begins&#xA;--------------------------------------------------------------------------------------*/&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;   //button adc input&#xA;   pinMode( BUTTON_ADC_PIN, INPUT );         //ensure A0 is an input&#xA;   digitalWrite( BUTTON_ADC_PIN, LOW );      //ensure pullup is off on A0&#xA;   //lcd backlight control&#xA;   digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is high (on)&#xA;   pinMode( LCD_BACKLIGHT_PIN, OUTPUT );     //D3 is an output&#xA;   pinMode(3,OUTPUT);                         //d4 is are LED&#xA;   //set up the LCD number of columns and rows: &#xA;   lcd.begin( 16, 2 );&#xA;   //Print some initial text to the LCD.&#xA;   lcd.setCursor( 0, 0 );   //top left&#xA;   //          1234567890123456&#xA;   lcd.print( &quot;LinkSprite  16x2&quot; );&#xA;   //&#xA;   lcd.setCursor( 0, 1 );   //bottom left&#xA;   //          1234567890123456&#xA;  // lcd.print( &quot;Btn:&quot; );&#xA;&#xA;    Serial.begin(9600);&#xA;&#xA; pinMode(2, INPUT);&#xA;&#xA; }&#xA;/*--------------------------------------------------------------------------------------&#xA;  loop()&#xA;  Arduino main loop&#xA;--------------------------------------------------------------------------------------*/&#xA;void loop()&#xA;{&#xA;&#xA;      //read the button &#xA;     byte result;//  = digitalRead(2);&#xA;      asm volatile(&#xA;          &quot;ldi %0, 0 \n\t&quot;&#xA;          &quot;sbic 0x09, 2 \n\t&quot;&#xA;          &quot;ldi %0,1 \n\t&quot;&#xA;          &quot;nop \n\t&quot;&#xA;          :&quot;=r&quot; (result)&#xA;          :&#xA;          :&#xA;      );&#xA;      int t =(random(0, 10000)+1000);&#xA;      unsigned long currentM = millis();&#xA;      //int t =(random(0, 10000)+1000 +millis());&#xA;      while( t &amp;lt; currentM){&#xA;      int x = testReactionTime();&#xA;       lcd.setCursor( 0, 1 );&#xA;     //if (result){&#xA;         lcd.print( &quot;on &quot; );&#xA;         lcd.setCursor(7,1);&#xA;         lcd.print(&quot; &quot;);&#xA;         //int x = testReactionTime();&#xA;         lcd.print(x,DEC);&#xA;         //delay(1000);&#xA;         //lcd.print(&quot;     &quot;);&#xA;      //}else{&#xA;        //testReactionTime();&#xA;        // delay(random(0, 1000)+1000);&#xA;        //lcd.print( x,DEC );&#xA;        //digitalWrite(3, LOW);&#xA;      }&#xA;//}&#xA;}&#xA;&#xA;&#xA;/*&#xA; *  after a random delay call this function to measure their reaction&#xA; *  time in milliseconds&#xA; *  It will immediately turn on a LED (pin 3)&#xA; *  And then start timing the milliseconds until they hit the button (pin 2)&#xA; * &#xA; */&#xA;int testReactionTime()&#xA;{&#xA;  int answer;&#xA;  //delay(rand());&#xA;  asm volatile(&#xA;    &quot;ldi %A0, 0 \n\t&quot;  // initializw anwer to 0&#xA;    &quot;ldi %B0, 0 \n\t&quot;  // answer should be the number of ms until they hit the button&#xA;    &quot;sbi 0x0b,3 \n\t&quot;  //turn on the led pin 3&#xA;    &quot;ldi r16, 1 \n\t&quot;&#xA;    &quot;ldi r17,0 \n\t&quot;&#xA;    &quot;movw r26, %0 \n\t&quot;&#xA;    &quot;rcall killms%= \n\t&quot;&#xA;   &quot;cbi 0x0b,3 \n\t&quot;  //turn on the led pin 3   &#xA;&#xA;      &quot;rjmp end%= \n\t&quot; //skip over the routine&#xA;      //start of kill millesecond subrouting, need to waste ~16000 clock cycles&#xA;      &quot;killms%=:ldi r24, 0x90 \n\t&quot;  //lo8(3984)&#xA;      &quot;ldi 25, 0x0f  \n\t&quot;      //hi8(3984)&#xA;      &quot;kloop%=: sbiw r24, 1 \n\t&quot;   //2 clocks&#xA;       &quot;brne kloop%=   \n\t&quot;       //2 clocks since most times true!! &#xA;       &quot;add r26, r16 \n\t&quot;&#xA;       &quot;adc r26, r17 \n\t&quot;&#xA;       &quot;movw %0, r26 \n\t&quot;&#xA;       &quot;sbis 0x09, 2 \n\t&quot;&#xA;       &quot;ret       \n\t&quot;&#xA;       &quot;rcall killms%= \n\t&quot;&#xA;      //end of the kill millesecond loop&#xA;      &quot;end%=: nop \n\t&quot;&#xA;    :&quot;=r&quot; (answer)&#xA;    :&#xA;    :&quot;r24&quot;, &quot;r25&quot;&#xA;    );&#xA;&#xA;  return answer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16727" LastEditorUserId="7508" LastEditDate="2016-05-04T19:35:30.130" LastActivityDate="2016-05-05T19:31:18.987" Title="Working on a reaction test for the Arduino Uno using an led and an lcd shield" Tags="|arduino-uno|lcd|pins|assembly|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23874" PostTypeId="1" CreationDate="2016-05-04T18:39:25.343" Score="2" ViewCount="405" Body="&lt;p&gt;As noted in earlier posts, I am building a model railroad crossing gate signal, complete with gate arms, flashers and sound. Although I haven't settled on exactly how I am going to implement detection of the train entering the zone, determining when its completely passed the entry sensor, tripped the exit sensor and completely passed the exit sensor to re-open the gate, I am researching using RFID for this now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought is to have an RFID card in every car of all my rolling stock. Therefore, I want to read all the ID's of the cars as they go buy and for this particular need, always store the latest ID in a variable so that once the whole train has passed by, the last ID in the variable SHOULD be the ID of the last car in the train. I would also have a counter incrementing for each unique ID read so I can use that as a secondary check for the exit routine (check that the exit RFID reader gets the same car count as the entry reader). The exit reader would also match its exitTag to the entryTag from the entry reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am implementing a state machine to control all this functionality but the problem lies in the RFID reading, I need a way to determine when the reader has read all the train cars tags. I thought the easiest way to do this was to use the elapsedMillis library and monitor for some interval where no card was read (two seconds? that would be way more than the time between two train cars) and once met, change state. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is proving more problematic than I thought. Here is my latest attempt.&#xA;I also think it might be better if the tag reading method only returned the last tag ID AFTER ITS DETERMINED NO MORE TAGS TO BE READ so that the code in the case statement is not the code that's running continuously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note: I am using the &lt;a href=&quot;https://www.adafruit.com/products/789?gclid=CjwKEAjw3qu5BRC-0uCw8O6Y5zcSJAA_WtdLfmp0bTa24pF0luhnG0aUBFS01u_KlBpT2bMUmcMNzBoCl0Pw_wcB&quot; rel=&quot;nofollow&quot;&gt;Adafruit RFID shield&lt;/a&gt; and &lt;a href=&quot;http://www.ebay.com/itm/400985225679?_trksid=p2057872.m2749.l2649&amp;amp;ssPageName=STRK%3AMEBIDX%3AIT&quot; rel=&quot;nofollow&quot;&gt;Mifare Classic 1k S50 IC 13.56MHz RFID&lt;/a&gt; cards.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts appreciated&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case CrossingZoneState::CROSSINGZONE_RFIDDETECTED:&#xA;    if (crossingZoneEntered == true)&#xA;    {&#xA;        // only thing we do here is monitor and identify the RFID tags of each car to determine last cars tag id&#xA;       //well, this doesnt work&#xA;        if (timeElapsedBetweenCardReads &amp;lt;= readerInactiveInterval) //only read cards that are continuous, once interval is surpassed change state&#xA;        {&#xA;            //do all the tag reading in here    &#xA;            tag = IndentifyTag(entryRFIDReader);&#xA;            readCount += 1;&#xA;&#xA;            if (tag != priorTag)&#xA;            {&#xA;                tagCount += 1;&#xA;            }&#xA;            priorTag = tag;&#xA;            timeElapsedBetweenCardReads = 0;   // reset the counter to 0 so the counting starts over...&#xA;        }&#xA;        // need to figure out how to determine no more cards are being read and change state and crossingZoneEntered back to false&#xA;    }&#xA;&#xA;    if (crossingZoneExited == true)&#xA;    {&#xA;&#xA;    }&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;IdentifyTags method:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t IndentifyTag(Adafruit_PN532 rfidReader)&#xA;{&#xA;    uint8_t tagID[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID&#xA;    uint8_t tagIDLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)&#xA;    uint32_t rfidCardID = tagID[0];&#xA;    boolean success = rfidReader.readPassiveTargetID(PN532_MIFARE_ISO14443A, &amp;amp;tagID[0], &amp;amp;tagIDLength);&#xA;    if (success) {&#xA;        // Display some basic information about the card for testing&#xA;        Serial.println(&quot;Found an ISO14443A card&quot;);&#xA;        Serial.print(&quot;  UID Length: &quot;); Serial.print(tagIDLength, DEC); Serial.println(&quot; bytes&quot;);&#xA;        Serial.print(&quot;  UID Value: &quot;); rfidReader.PrintHex(tagID, tagIDLength);&#xA;&#xA;        if (tagIDLength == 4)&#xA;        {&#xA;            // Mifare Classic card &#xA;            rfidCardID &amp;lt;&amp;lt;= 8;&#xA;            rfidCardID |= tagID[1];&#xA;            rfidCardID &amp;lt;&amp;lt;= 8;&#xA;            rfidCardID |= tagID[2];&#xA;            rfidCardID &amp;lt;&amp;lt;= 8;&#xA;            rfidCardID |= tagID[3];&#xA;            Serial.print(&quot;Mifare Classic card #&quot;);&#xA;            Serial.println(rfidCardID);&#xA;        }&#xA;        Serial.println(&quot;&quot;);&#xA;    }&#xA;    return rfidCardID;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Full switch statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch (state)&#xA;{&#xA;case CrossingZoneState::CROSSINGZONE_CLEAR:&#xA;    // only thing we do here is monitor the zone entry sensor&#xA;    if (digitalRead(entrySensorPin) == HIGH) {&#xA;        crossingZoneEntered = true;&#xA;        state = CrossingZoneState::CROSSINGZONE_ACTIVATEGATES;&#xA;    }&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_ACTIVATEGATES:&#xA;    // Do these once: turn on the flashers, put down the arms and turn on the crossing gate bells&#xA;    if (didOnce = false)&#xA;    {&#xA;        // turn on flashers&#xA;        // turn on sound&#xA;        // lower gate arms&#xA;        didOnce = true;&#xA;        state = CrossingZoneState::CROSSINGZONE_READENTRYRFID;&#xA;    }&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_READENTRYRFID:&#xA;&#xA;    // only thing we do here is monitor and identify the rfid tags of each car to determine last cars tag id&#xA;    // need to figure out how to determine no more cards are being read and change state &#xA;        if (timeElapsedBetweenCardReads &amp;lt;= readerInactiveInterval) //only read cards that are continuous, once interval is surpassed change state&#xA;        {&#xA;            //do all the tag reading in here    &#xA;            entryTag = IndentifyTag(entryRFIDReader);&#xA;            readCount += 1;&#xA;&#xA;            if (entryTag != priorTag)&#xA;            {&#xA;                entryTagCount += 1;&#xA;            }&#xA;            priorTag = entryTag;&#xA;            timeElapsedBetweenCardReads = 0;   // reset the counter to 0 so the counting starts over...&#xA;        }&#xA;        else {&#xA;            //change state now that entry rfid tag reader is finished&#xA;            state = CrossingZoneState::CROSSINGZONE_OCCUPIED;&#xA;        }&#xA;&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_OCCUPIED:&#xA;    // only thing we do here is monitor the zone exit sensor&#xA;    if (digitalRead(exitSensorPin) == HIGH) {           &#xA;        state = CrossingZoneState::CROSSINGZONE_READEXITRFID;&#xA;    }&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_READEXITRFID:&#xA;    if (timeElapsedBetweenCardReads &amp;lt;= readerInactiveInterval) //only read cards that are continuous, once interval is surpassed change state&#xA;    {&#xA;        //do all the tag reading in here    &#xA;        exitTag = IndentifyTag(entryRFIDReader);&#xA;        readCount += 1;&#xA;&#xA;        if (exitTag != priorTag)&#xA;        {&#xA;            exitTagCount += 1;&#xA;        }&#xA;        priorTag = exitTag;&#xA;        timeElapsedBetweenCardReads = 0;   // reset the counter to 0 so the counting starts over...&#xA;    }&#xA;    else {//check tags and count now that entry rfid tag reader is finished&#xA;        if (entryTagCount == exitTagCount &amp;amp;&amp;amp; entryTag == exitTag)&#xA;        {&#xA;            state = CrossingZoneState::CROSSINGZONE_DEACTIVATEGATES;&#xA;        }&#xA;    }&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_DEACTIVATEGATES:&#xA;    // Do these once: turn off the flashers, raise the arms and turn off the crossing gate bells&#xA;    if (didOnce = true)&#xA;    {&#xA;        // turn off flashers&#xA;        // turn off sound&#xA;        // raise gate arms&#xA;        didOnce = false;&#xA;    }&#xA;    break;&#xA;case CrossingZoneState::CROSSINGZONE_ERROR:&#xA;    boolean success = writeToFileOnSD(modelRRErrorLogFile, &quot;ModelRRXingErrorLog.txt&quot;, &quot;error string&quot;);&#xA;    break;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-05-05T09:50:49.287" LastActivityDate="2016-07-18T02:06:47.823" Title="How to monitor a sensor for specific period" Tags="|arduino-mega|c++|timers|rfid|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23875" PostTypeId="2" ParentId="23855" CreationDate="2016-05-04T19:24:59.677" Score="1" Body="&lt;p&gt;You did not include any output from the esp8266, but I'm pretty sure what is happening is that the watchdog timer is expiring and resetting your board. This is because the SPI transactions to transfer data to the display are taking too long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Put the following line in both &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; before any display operations happen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;wdt_disable();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Needless to say, if you actually &lt;em&gt;do&lt;/em&gt; need the WDT in your application, you can reenable it after the display operations complete (of course, if you are doing something that depends on the wdt, you already know this!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at the source for the Adafruit library, make sure there are &lt;code&gt;#ifdef ESP8266&lt;/code&gt; statements there; older versions did not support the 8266.&#xA;You may also want to increase the default speed at which the library drives the SPI bus from 8000000. I've gotten it to work at up to 40MHz, with the board flashed at 160MHz of course, and it's a lot faster (unsurprisingly), but if you have long wires or a marginal-quality display, that may fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Post pictures :)&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-04T19:24:59.677" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23876" PostTypeId="1" AcceptedAnswerId="23885" CreationDate="2016-05-04T19:38:56.283" Score="1" ViewCount="15179" Body="&lt;p&gt;Can anyone help? I'm trying to develop two sketches, where data can only be sent when a request is made for it between two arduinos. A simple hello world message can suffice. I tried out the Serial Ascii Call and Response on the arduino IDE but it didn't work for me???. Do find below the code sketches&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Arduino Sketch 1&#xA;uint16_t alpha;&#xA;uint16_t lambo;&#xA;Banana nanas;    //to hold the Banana object&#xA;uint16_t dataArray[2];&#xA;void Setup(){&#xA;    Serial.begin(9600);&#xA;    establishContact();&#xA;}&#xA;&#xA;void loop(){&#xA;    alpha=nanas.getRad;&#xA;    lambo = nanas.getBars;&#xA;    dataArray[0] = alpha;&#xA;    dataArray[1] = lambo;&#xA;    Serial.write((uint8_t*)dataArray, sizeof(dataArray));&#xA;    Serial.flush();   //clear the serial port         &#xA;}&#xA;&#xA;void establishContact()&#xA;{&#xA;    if (Serial.available())&#xA;    {&#xA;        while (Serial.available()  &amp;gt; 0)&#xA;        {&#xA;            int newByte = Serial.read();&#xA;            if (newByte == 'Q')&#xA;            {&#xA;                Serial.write(newByte);&#xA;                Serial.flush();&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The sketch for the other arduino is shown below&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Arduino sketch 2&#xA;static char buffer[2];&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;    Serial1.begin(9600);&#xA;    establishContact();&#xA;}&#xA;void loop(){&#xA;    if(Serial1.available())&#xA;    {&#xA;        while(Serial1.available() &amp;gt; 0){&#xA;            uint16_t gondola1 = Serial1.read(); &#xA;            uint16_t gondola2 = Serial1.read();&#xA;            uint16_t crixus = gondola2 &amp;gt;&amp;gt; 8;&#xA;            crixus = (crixus | gondola1);&#xA;&#xA;            gondola1 = Serial1.read(); &#xA;            gondola2 = Serial1.read();&#xA;            uint16_t mario = gondola2 &amp;gt;&amp;gt; 8;&#xA;            mario = (mario | gondola1);&#xA;            buffer[0] = crixus;&#xA;            buffer[1] = mario;&#xA;            Serial.write(buffer, sizeof(buffer);&#xA;            Serial1.flush();&#xA;        }&#xA;    }&#xA;}&#xA;void establishContact(){&#xA;    if (Serial.available()){&#xA;        uint16_t newByte = Serial.read();&#xA;        if(newByte == 'Q')&#xA;        {&#xA;            Serial.flush();&#xA;            Serial.write(newByte);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20784" LastEditorUserId="20784" LastEditDate="2016-05-04T22:59:03.833" LastActivityDate="2020-09-22T20:21:55.487" Title="Serial Communication Between Two arduinos (Asking and Receiving)" Tags="|arduino-uno|serial|arduino-mega|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23877" PostTypeId="1" AcceptedAnswerId="23882" CreationDate="2016-05-04T20:22:01.720" Score="1" ViewCount="216" Body="&lt;p&gt;Does anyone have an idea on the best way to time stamp an arduino sketch that contains a data packet which is to be read out using a java IDE (IntelliJ) for graphic visualization of the packet. I tried declaring the time variable on the arduino section but having problem unpacking the unsigned long variable in java. Below is a snippet of the arduino code. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             unsigned long codeTime = 0; //The time the sketch takes to execute&#xA;         static unsigned long char dataArray [1]; // a variable to hold both sensor data&#xA;&#xA;         void setup(){&#xA;              Serial.begin(9600);&#xA;              Serial1.begin(9600);&#xA;          }&#xA;         void state1(){&#xA;             if (Serial1.available()){&#xA;                    while (Serial1.available() &amp;gt; 0){&#xA;                 codeTime = millis(); //using the millis() instead of micros()             &#xA;                 //memcpy should copy the whole data into position 0 ????&#xA;                 memcpy(&amp;amp;dataArray[0], &amp;amp;codeTime,sizeof(codeTime));&#xA;                 uint16_t newByte1 = Serial1.read(); // read in the first byte&#xA;                 uint16_t newByte2 = Serial1.read(); //read in the second byte&#xA;                 uint16_t dataByte = newByte2 &amp;gt;&amp;gt; 8;&#xA;                 dataByte = (dataByte | newByte1);&#xA;                 dataArray[1] = dataByte;&#xA;                 Serial1.write((uint16_t*)dataArray, sizeOf(dataArray));&#xA;                 }&#xA;               }&#xA;              }&#xA;&#xA;            void loop(){&#xA;                   state1();&#xA;                   Serial1.flush();  //clear the serial port &#xA;                   delay(100);&#xA;                }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The question now is how do i unpack the data in java to ensure that the time variable (unsigned long time variable is well unpacked in the correct order)????. The second variable i could easily unpack in java as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;              int variable1 = variable2 &amp;gt;&amp;gt; 8; //as it is a 16 bit integer I shifted&#xA;                                              // the msb/lsb accordingly&#xA;              variable1 = (variable1 | variable2);  // and finally casting it.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20784" LastEditorUserId="20784" LastEditDate="2016-05-06T05:50:33.377" LastActivityDate="2016-05-06T05:50:33.377" Title="Time Stamping data on an Arduino and reading it on a Java IDE" Tags="|arduino-due|java|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23878" PostTypeId="1" CreationDate="2016-05-04T20:22:03.220" Score="2" ViewCount="9782" Body="&lt;p&gt;&lt;strong&gt;Preamble&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;code&gt;sim908&lt;/code&gt; shield and I'm trying to send some data periodically to a server using &lt;code&gt;AT commands&lt;/code&gt;.&#xA;For every command, I wait for the response to check if everything is working.&#xA;Actually the sketch works but, often, I noticed errors during http request.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;State of the art&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here it is the sequence of AT commands (not the entire code) into the loop:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Check the Network Registration and, if necessary, wait &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CREG?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;2) Set params for GPRS connection (no user or password required)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+SAPBR=3,1,&quot;Contype&quot;,&quot;GPRS&quot;&#xA;AT+SAPBR=3,1,&quot;APN&quot;,&quot;web.omnitel.it&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;3) Get current bearer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+SAPBR=2,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;4) If bearer == 0,0,0,0 (not assigned) get a new bearer&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+SAPBR=1,1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;5) Init HTTP&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+HTTPINIT&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;6) Set CID and URL&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+HTTPPARA=&quot;CID&quot;,1&#xA;AT+HTTPPARA=&quot;URL&quot;,&quot;www.someurl.com/service.php?p1=1&amp;amp;p2=2&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;7) Execute the HTTP command (POST)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+HTTPACTION=1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;8) Close HTTP connection&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+HTTPTERM&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why HTTP init (step 5) or HTTP posting (step 7) often fails? What is wrong in this procedure? I'm missing something? There is a way to make the procedure more stable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important update&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If occurs an error during sending data via HTTP, is a great idea to renew the bearer (step 4)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Answers to the comments&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;a)&lt;/strong&gt; Shield has an antenna and it works. If I try to disconnect the antenna, code still  search the network (step 1) untill I reconnect the antenna.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;b)&lt;/strong&gt; Some times I have this error initializing HTTP (step 5):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+HTTPINIT&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;+CME ERROR: 3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Some times I have only &quot;OK&quot; as response posting data (step 7) instead of:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+HTTPACTION:1,200,xxx&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Or this response:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;+HTTPACTION:1,600,0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;c)&lt;/strong&gt; I have error at step 4 (AT+SAPBR=1,1) only if I execute the command when I have yet a bearer. The error in this case is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AT+SAPBR=1,1&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;+CME ERROR: 3&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For this reason I do a check (step 3)&lt;/p&gt;&#xA;" OwnerUserId="15052" LastEditorUserId="15052" LastEditDate="2018-08-17T17:36:55.060" LastActivityDate="2018-08-17T17:36:55.060" Title="What is the proper way to send data through http using sim908?" Tags="|http|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="23879" PostTypeId="1" AcceptedAnswerId="23881" CreationDate="2016-05-04T21:34:30.073" Score="3" ViewCount="4732" Body="&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to extend the memory for a sound buffer (intensively used) if:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;SD card library supports only one file open at a time (and I have one open already)&lt;/li&gt;&#xA;&lt;li&gt;EEPROM chips are able to stand about 100,000 write cycles only (see the datasheets!)&lt;/li&gt;&#xA;&lt;li&gt;I can't find anything else to buy! (a standard and durable RAM chip that loses its content when switched off would be the best).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;About the 2nd point. Let's assume that the chip is 64KB and I want to use half of it for a circular sound buffer (it's small, I know). Let's also assume that a standard MP3 song is 160kbps and it's 3.5 min long. Given that, the EEPROM chip (with 100k write cycles limit) in this condirions will reach its limit after 3.2GB of played sound, which is about 762 songs, 44 hours. That can be reached in a single week! Replacing a chip every week is not an option. I'm not a fan of planned obsolescence...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know any chip that will be right for the job? (and can be bought on eBay and it's affordable?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have built a WWW-controlled MP3 and online radio player (using ESP8266 and VS1003) and it's working really great, we're using it whole days, but ESP is not fast enough to handle WWW requests and play MP3 at the same time (especially from SD card), so the sound is paused for about 0.5 - 1 sec every time a www page is served (a really small page! Just basic HTML with a title and a list of file links!). SD card content cannot be cached for generating the pages on the fly (not enough heap memory) and two files cannot be opened at the same time by the SD library (one is open for the currently playing file - if not playing an online stream - and I'm currently closing it during reading and sending of requested html page). So I've got two memory problems: 1. serving the www pages and 2. buffering the online stream (usually not needed, most streams can play on my 4KB buffer without a glitch whole day but some of them are jamming very often - depends on the server). I'm thinking about both caching the pages (so I don't have to read them from SD and my music won't be interrupted) and creating a circular buffer (for live streams) in external memory chip. It does not need to keep the data after cutting the power. I've got about 24KB of heap left in my sketch (max) and it can fall even to about 6KB when a single folder's content is loaded to memory. It's not far away from heap overflow... I need to load at least the current folder (with long filenames).&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-05-04T23:12:11.667" Title="What is the best way to get more RAM for a sound buffer?" Tags="|esp8266|sd-card|audio|memory-usage|eeprom|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23880" PostTypeId="2" ParentId="23879" CreationDate="2016-05-04T21:50:50.617" Score="3" Body="&lt;p&gt;An FRAM chip?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Non-volatile (though you don't need that)&lt;/li&gt;&#xA;&lt;li&gt;SPI or I^2C available on a breakout board from &lt;a href=&quot;https://www.adafruit.com/?q=FRAM&amp;amp;&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Or roll you own from a bare chip, if you're handy with Surface Mount Devices.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-04T21:50:50.617" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23881" PostTypeId="2" ParentId="23879" CreationDate="2016-05-04T23:12:11.667" Score="5" Body="&lt;p&gt;A simple SPI SRAM chip. Available up to 128KB, such as the 23LC1024: &lt;a href=&quot;http://www.microchip.com/wwwproducts/en/23LC1024&quot;&gt;http://www.microchip.com/wwwproducts/en/23LC1024&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-04T23:12:11.667" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23882" PostTypeId="2" ParentId="23877" CreationDate="2016-05-04T23:23:49.520" Score="1" Body="&lt;p&gt;There's a number of fundamentally wrong things in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char buffer[1]; // a variable to hold both sensor data&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No - that has room for 1 entry - hence the 1. 1 means 1, not 2.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buffer[1] = newByte;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No. There is no buffer[1]. You count slices from 0.  buffer[0] exists (the first one) but buffer[1] doesn't.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;buffer[0] = millis;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You aren't calling the function, you are assigning the address of the function. And worse than that, &lt;code&gt;buffer&lt;/code&gt; is an array of 8-bit values - neither the address of the function, nor the return value from the function (if you were to fix that) would fit in that space - since the return value is an &lt;code&gt;unsigned long&lt;/code&gt; which is 4 bytes in size.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to have at least 5 bytes in your array - four for the time stamp and one for the value you read from serial. Then you place them in to the array in the order you see fit, and read them back in the same order in Java.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-04T23:23:49.520" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23884" PostTypeId="1" CreationDate="2016-05-05T00:00:44.260" Score="0" ViewCount="326" Body="&lt;p&gt;Well, googling didn't do much to help me here and I'm shocked that something I can do in two lines of code in C# &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DateTime dateTime;&#xA;string text = dateTime.ToLongDateString();    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is this difficult for Arduino, but how do you get a string version of a date time stamp?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the current date and time as a string in this format&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;May 4, 2016 17:15:33&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since I can't use any of the C++ includes, like ctime, I'm not sure how to accomplish this.&lt;/p&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-05-05T00:08:56.170" LastActivityDate="2017-10-09T22:13:25.177" Title="Creating date string for error log" Tags="|arduino-uno|time|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23885" PostTypeId="2" ParentId="23876" CreationDate="2016-05-05T00:20:31.420" Score="3" Body="&lt;p&gt;it is not really easy to follow your code but here is a &quot;hello world&quot; procedure to do an on demand data send between two arduinos:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;upload this code to arduino uno before you make any connection on pins 0 and 1 of the board:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; * Code for server side (arduino uno)&#xA; */&#xA;&#xA;&#xA;uint8_t data2send = 'A'; //data to send on a received request &#xA;uint8_t incomingByte;&#xA;&#xA;void setup() {&#xA;        Serial.begin(9600);   &#xA;}&#xA;&#xA;void loop() {&#xA;        // send data only when you receive data:&#xA;        if (Serial.available() &amp;gt; 0) {&#xA;&#xA;                // read the incoming byte:&#xA;                incomingByte = Serial.read();&#xA;&#xA;                if(incomingByte=='Q'){  //if incoming data is the expected request (request code = 'Q' in this example)&#xA;                        Serial.write(data2send);        &#xA;                }&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;connect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UNO  | MEGA&#xA;------------&#xA;pin0 | pin18&#xA;pin1 | pin19&#xA;GND  | GND&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;upload to arduino mega this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /**&#xA; *  code for arduino mega.&#xA; *  &#xA; *  proxy between Serial0 and Serial1&#xA; *  &#xA; *  send data to Serial0 to forward it to Serial1.&#xA; *  when data is received from Serial1 it will be forwarded to Serial0.&#xA; */&#xA;&#xA;void setup() {&#xA;        // initialize both serial ports:&#xA;        Serial.begin(9600);&#xA;        Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;        // read from port 1, send to port 0:&#xA;        if (Serial1.available()) {&#xA;                int inByte = Serial1.read();&#xA;                Serial.write(inByte);&#xA;        }&#xA;&#xA;        // read from port 0, send to port 1:&#xA;        if (Serial.available()) {&#xA;                int inByte = Serial.read();&#xA;                Serial1.write(inByte);&#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;open the mega's serial monitor and send some characters. Check that you receive back data only when you send a 'Q' character.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="20645" LastEditDate="2016-05-05T00:25:57.260" LastActivityDate="2016-05-05T00:25:57.260" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23887" PostTypeId="1" CreationDate="2016-05-05T04:16:10.140" Score="2" ViewCount="870" Body="&lt;p&gt;I have the esp01 connected the serial port using a usb to ttl serial cable and also using the Arduino UNO as suggested in some tutorials. I can execute AT commands. But loading a sketch from Arduino IDE results in error messages show below. If anyone can help, it would be greatly appreciated. Note the error message: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;serialport_receive_C0: F0 instead of C0&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Build options changed, rebuilding all&#xA;&#xA;Sketch uses 219,211 bytes (50%) of program storage space. Maximum is 434,160 bytes.     Global variables use 31,416 bytes (38%) of dynamic memory, leaving 50,504 bytes for local variables. Maximum is 81,920 bytes.&#xA;      /Users/syedtariq/Library/Arduino15/packages/esp8266/tools/esptool/0.4.8/esptool -vv -cd ck -cb 115200 -cp /dev/cu.usbmodem14221 -ca 0x00000 -cf /var/folders/hx/m49nxmvn0799w816ct3tgsjm0000gp/T/build10f6b721887f9efd16f05460daf22810.tmp/Blink.ino.bin &#xA;esptool v0.4.8 - (c) 2014 Ch. Klippel &amp;lt;ck@atelier-klippel.de&amp;gt;&#xA;setting board to ck&#xA;setting baudrate from 115200 to 115200&#xA;setting port from /dev/tty.usbserial to /dev/cu.usbmodem14221&#xA;setting address from 0x00000000 to 0x00000000&#xA;espcomm_upload_file&#xA;espcomm_upload_mem&#xA;opening port /dev/cu.usbmodem14221 at 115200&#xA;tcgetattr&#xA;tcsetattr&#xA;serial open&#xA;opening bootloader&#xA;resetting board&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: F0 instead of C0&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: F0 instead of C0&#xA;resetting board&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: FF instead of C0&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: F0 instead of C0&#xA;resetting board&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: F0 instead of C0&#xA;trying to connect&#xA;setting character timeout 0&#xA;done&#xA;setting character timeout 1&#xA;done&#xA;espcomm_send_command: sending command header&#xA;espcomm_send_command: sending command payload&#xA;serialport_receive_C0: F0 instead of C0&#xA;warning: espcomm_sync failed&#xA;error: espcomm_open failed&#xA;error: espcomm_upload_mem failed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18546" LastActivityDate="2021-12-19T23:54:24.420" Title="Error loading Blink sketch in esp01 (esp8266)" Tags="|esp8266|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23888" PostTypeId="1" CreationDate="2016-05-05T05:16:41.747" Score="0" ViewCount="1471" Body="&lt;p&gt;I'm trying to have a user enter a series of strings. This is my code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is my error message - cannot convert 'String' to 'char*' in assignment&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* titles[] = {&quot;entry one&quot;, &quot;entry two&quot;, &quot;entry three&quot;, &quot;entry four&quot;, &quot;entry five&quot;};&#xA;&#xA;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA; Serial.println(&quot;Storing numbers in an array&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;&#xA;for (int x =0; x &amp;lt; 5; x++)&#xA;{&#xA;  if (Serial.available() &amp;gt; 0)&#xA;&#xA;  {&#xA;   Serial.println(&quot;Enter a word... &quot;);&#xA;   titles[x] = Serial.readString();&#xA;&#xA;    Serial.println(&quot; &quot;);&#xA;    Serial.println(chartitles[x]);&#xA;&#xA;   }&#xA;  } &#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-05-05T11:35:52.850" Title="error loading an array of strings" Tags="|string|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23889" PostTypeId="1" CreationDate="2016-05-05T05:20:35.747" Score="0" ViewCount="1650" Body="&lt;p&gt;I have two mega arduino and want to them communicate with modbus rtu together, i use below link circuit for this :&#xA;&lt;a href=&quot;http://www.microcontroller-project.com/rs485-communication-between-arduino-mega-and-arduino-pro-mini.html&quot; rel=&quot;nofollow&quot;&gt;http://www.microcontroller-project.com/rs485-communication-between-arduino-mega-and-arduino-pro-mini.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but dont work!! while they work in simple rs485 and without modbus with same above link code !?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my code in modbus mode is based on this forum :&#xA;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=176142.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=176142.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MASTER CODE&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    //#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;#include &amp;lt;SimpleModbusMaster.h&amp;gt;&#xA;&#xA;/*&#xA;   The example will use packet1 to read a register from address 0 (the adc ch0 value)&#xA;   from the arduino slave (id=1). It will then use this value to adjust the brightness&#xA;   of an led on pin 9 using PWM.&#xA;   It will then use packet2 to write a register (its own adc ch0 value) to address 1&#xA;   on the arduino slave (id=1) adjusting the brightness of an led on pin 9 using PWM.&#xA;*/&#xA;&#xA;//////////////////// Port information ///////////////////&#xA;#define baud 9600&#xA;#define timeout 1000&#xA;#define polling 200 // the scan rate&#xA;#define retry_count 50&#xA;&#xA;// used to toggle the receive/transmit pin on the driver&#xA;#define TxEnablePin 2&#xA;&#xA;#define LED 9&#xA;&#xA;// The total amount of available memory on the master to store data&#xA;#define TOTAL_NO_OF_REGISTERS 12&#xA;&#xA;// This is the easiest way to create new packets&#xA;// Add as many as you want. TOTAL_NO_OF_PACKETS&#xA;// is automatically updated.&#xA;enum&#xA;{&#xA;  PACKET1,&#xA;  PACKET2,&#xA;  TOTAL_NO_OF_PACKETS // leave this last entry&#xA;};&#xA;&#xA;// Create an array of Packets to be configured&#xA;Packet packets[TOTAL_NO_OF_PACKETS];&#xA;&#xA;// Masters register array&#xA;unsigned int regs[TOTAL_NO_OF_REGISTERS];&#xA;int In22=22;&#xA;&#xA;// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;//  Serial1.begin(9600);&#xA;//Serial.begin(speed,9600);&#xA;// lcd.begin(16, 2);&#xA;  // Initialize each packet&#xA;  modbus_construct(&amp;amp;packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 5, 0);&#xA;//  modbus_construct(&amp;amp;packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);&#xA;&#xA;  // Initialize the Modbus Finite State Machine&#xA;  modbus_configure(&amp;amp;Serial1, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  modbus_update();&#xA;&#xA;//  regs[0] = analogRead(0); // update data to be written to arduino slave&#xA;//regs[1] =In22;&#xA;//  analogWrite(LED, regs[0]&amp;gt;&amp;gt;2); // constrain adc value from the arduino slave to 255&#xA;//  regs[1];&#xA; if (Serial1.available()){&#xA;//regs[1]=In22;&#xA;//if(regs[1]==123){&#xA;    Serial.println(regs[0]);&#xA;    Serial.println(regs[1]);&#xA;    Serial.println(regs[2]);&#xA;    Serial.println(regs[2]);&#xA;//}&#xA;//  lcd.setCursor(6, 1);&#xA;//    lcd.print(regs[0]);&#xA;//lcd.print(&quot;hgftf&quot;);پ&#xA; }&#xA;  delay(1000);&#xA;//lcd.clear();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;SLAVE CODE&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleModbusSlave.h&amp;gt;&#xA;&#xA;/* This example code will receive the adc ch0 value from the arduino master.&#xA;   It will then use this value to adjust the brightness of the led on pin 9.&#xA;   The value received from the master will be stored in address 1 in its own&#xA;   address space namely holdingRegs[].&#xA;&#xA;   In addition to this the slaves own adc ch0 value will be stored in&#xA;   address 0 in its own address space holdingRegs[] for the master to&#xA;   be read. The master will use this value to alter the brightness of its&#xA;   own led connected to pin 9.&#xA;&#xA;   The modbus_update() method updates the holdingRegs register array and checks&#xA;   communication.&#xA;&#xA;   Note: &#xA;   The Arduino serial ring buffer is 64 bytes or 32 registers.&#xA;   Most of the time you will connect the arduino to a master via serial&#xA;   using a MAX485 or similar.&#xA;&#xA;   In a function 3 request the master will attempt to read from your&#xA;   slave and since 5 bytes is already used for ID, FUNCTION, NO OF BYTES&#xA;   and two BYTES CRC the master can only request 58 bytes or 29 registers.&#xA;&#xA;   In a function 16 request the master will attempt to write to your&#xA;   slave and since a 9 bytes is already used for ID, FUNCTION, ADDRESS,&#xA;   NO OF REGISTERS, NO OF BYTES and two BYTES CRC the master can only write&#xA;   54 bytes or 27 registers.&#xA;&#xA;   Using a USB to Serial converter the maximum bytes you can send is&#xA;   limited to its internal buffer which differs between manufactures.&#xA;*/&#xA;&#xA;#define  LED 9 &#xA;&#xA;// Using the enum instruction allows for an easy method for adding and&#xA;// removing registers. Doing it this way saves you #defining the size&#xA;// of your slaves register array each time you want to add more registers&#xA;// and at a glimpse informs you of your slaves register layout.&#xA;&#xA;//////////////// registers of your slave ///////////////////&#xA;enum&#xA;{     &#xA;  // just add or remove registers and your good to go...&#xA;  // The first register starts at address 0&#xA;  ADC_VAL,     &#xA;  PWM_VAL,       &#xA;  HOLDING_REGS_SIZE // leave this one&#xA;  // total number of registers for function 3 and 16 share the same register array&#xA;  // i.e. the same address space&#xA;};&#xA;&#xA;unsigned int holdingRegs[HOLDING_REGS_SIZE]; // function 3 and 16 register array&#xA;////////////////////////////////////////////////////////////&#xA;&#xA;void setup()&#xA;{&#xA;  /* parameters(HardwareSerial* SerialPort,&#xA;                long baudrate,&#xA;        unsigned char byteFormat,&#xA;                unsigned char ID,&#xA;                unsigned char transmit enable pin,&#xA;                unsigned int holding registers size,&#xA;                unsigned int* holding register array)&#xA;  */&#xA;&#xA;  /* Valid modbus byte formats are:&#xA;     SERIAL_8N2: 1 start bit, 8 data bits, 2 stop bits&#xA;     SERIAL_8E1: 1 start bit, 8 data bits, 1 Even parity bit, 1 stop bit&#xA;     SERIAL_8O1: 1 start bit, 8 data bits, 1 Odd parity bit, 1 stop bit&#xA;&#xA;     You can obviously use SERIAL_8N1 but this does not adhere to the&#xA;     Modbus specifications. That said, I have tested the SERIAL_8N1 option&#xA;     on various commercial masters and slaves that were suppose to adhere&#xA;     to this specification and was always able to communicate... Go figure.&#xA;&#xA;     These byte formats are already defined in the Arduino global name space.&#xA;  */&#xA;&#xA;  modbus_configure(&amp;amp;Serial1, 9600, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs);&#xA;&#xA;  // modbus_update_comms(baud, byteFormat, id) is not needed but allows for easy update of the&#xA;  // port variables and slave id dynamically in any function.&#xA;  modbus_update_comms(9600, SERIAL_8N2, 1);&#xA;&#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // modbus_update() is the only method used in loop(). It returns the total error&#xA;  // count since the slave started. You don't have to use it but it's useful&#xA;  // for fault finding by the modbus master.&#xA;&#xA;  modbus_update();&#xA;//  holdingRegs[0] = 123; // update data to be read by the master to adjust the PWM&#xA;  holdingRegs[1] = 123; // update data to be read by the master to adjust the PWM&#xA;    holdingRegs[2] = 123;&#xA;//    holdingRegs[3] = 123;&#xA;//    holdingRegs[4] = 123;&#xA;  //  analogWrite(LED, holdingRegs[PWM_VAL]&amp;gt;&amp;gt;2); // constrain adc value from the arduino master to 255&#xA;  delay(1000);&#xA;  /* Note:&#xA;     The use of the enum instruction is not needed. You could set a maximum allowable&#xA;     size for holdinRegs[] by defining HOLDING_REGS_SIZE using a constant and then access&#xA;     holdingRegs[] by &quot;Index&quot; addressing.&#xA;     I.e.&#xA;     holdingRegs[0] = analogRead(A0);&#xA;     analogWrite(LED, holdingRegs[1]/4);&#xA;  */&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20800" LastActivityDate="2016-08-10T21:51:35.760" Title="Why ModBus RTU Master-Slave Dont Work" Tags="|arduino-mega|rs485|modbus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23892" PostTypeId="1" CreationDate="2016-05-05T09:42:34.513" Score="0" ViewCount="356" Body="&lt;p&gt;Using two ultrasonic sensors together, how can I enable one before the other?&lt;/p&gt;&#xA;" OwnerUserId="20807" LastActivityDate="2016-05-05T10:33:09.223" Title="Using two ultrasonic sensors together" Tags="|arduino-uno|sketch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23893" PostTypeId="1" CreationDate="2016-05-05T10:31:28.200" Score="1" ViewCount="1786" Body="&lt;p&gt;I was wondering how to write a code that would do this, WITHOUT using IF and ELSE: when the button is pressed, one LED is on and the other one is off, but when the button is not pressed, the LED that was on turns off and the other one turns on. &lt;/p&gt;&#xA;" OwnerUserId="20809" LastActivityDate="2016-05-16T09:06:25.177" Title="How to turn two LED's on and off with one button?" Tags="|led|button|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23894" PostTypeId="2" ParentId="23892" CreationDate="2016-05-05T10:33:09.223" Score="1" Body="&lt;p&gt;You need to tell the sensor to send their pulse using the trigger line.  So triggering isn't a problem.&#xA;The problem is that you might get an echo returned on both sensors, but you know which sensor sent the pulse so you can ignore the return that was received by the 'wrong' sensor in your code.&#xA;So&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;While(1)&#xA;{&#xA;  SendPulse(SensorTx1);&#xA;  GetEcho(SensorRx1);&#xA;  SendPulse(SensorTx2);&#xA;  GetEcho(SensorRx2);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is that what you mean?  If not please can you expand you question?&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-05T10:33:09.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23895" PostTypeId="2" ParentId="23893" CreationDate="2016-05-05T10:42:16.840" Score="7" Body="&lt;p&gt;Just use the return value of &lt;code&gt;digitalRead&lt;/code&gt; (which is 1 or 0) as the input to &lt;code&gt;digitalWrite&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int btnVal = digitalRead(3);&#xA;digitalWrite(4, btnVal);      // On when button is HIGH&#xA;digitalWrite(5, 1 - btnVal);  // Off when button is HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or using boolean instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool btnVal = digitalRead(3);&#xA;digitalWrite(4, btnVal);      // On when button is HIGH&#xA;digitalWrite(5, !btnVal);     // Off when button is HIGH&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-05T10:42:16.840" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23896" PostTypeId="2" ParentId="23893" CreationDate="2016-05-05T10:42:27.497" Score="0" Body="&lt;p&gt;You could do it with only a &lt;code&gt;switch&lt;/code&gt;/&lt;code&gt;case&lt;/code&gt; statement. You do not even need to de-bounce the switch.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="6936" LastEditDate="2016-05-16T09:06:25.177" LastActivityDate="2016-05-16T09:06:25.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23899" PostTypeId="2" ParentId="23888" CreationDate="2016-05-05T11:35:52.850" Score="1" Body="&lt;p&gt;So, you are confusing the object String of Arduino with a string of C (char array), to solve your problem, I've changed your code in two parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String titles[] = {&quot;entry one&quot;, &quot;entry two&quot;, &quot;entry three&quot;, &quot;entry four&quot;, &quot;entry five&quot;};&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Storing numbers in an array&quot;);&#xA;}&#xA;&#xA;void loop(){&#xA;  for (int x = 0; x &amp;lt; 5; x++){&#xA;    if (Serial.available() &amp;gt; 0){&#xA;      Serial.println(&quot;Enter a word... &quot;);&#xA;      titles[x] = Serial.readString();&#xA;      Serial.println(&quot; &quot;);&#xA;      Serial.println(titles[x]);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, in order to use Seria.readString(), you have to use String objects to receive the data from Serial port:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String titles[]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* titles[]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The second change is related to Serial.println(chartitles[x]), I didn't understand what you mean with this code, so I changed in order to print the String that was read.&lt;/p&gt;&#xA;" OwnerUserId="14243" LastActivityDate="2016-05-05T11:35:52.850" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23900" PostTypeId="1" AcceptedAnswerId="23914" CreationDate="2016-05-05T12:07:49.977" Score="1" ViewCount="1634" Body="&lt;p&gt;I am using Atmega328p with arduino bootloader in a project. There happens to be an LED connected on SCK pin. During Start (or restarts), the LED appears to flicker a couple of times (3 times to be exact). I don't want this to happen. I can change the connections but I would prefer a software solution because hardware change means a PCB modification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I probed the SCK pin and I got some expected waveforms. There were two different cases:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) When I powered the arduino using USB to serial programmer i.e. Tx Rx connected to a PC:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bU1DZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bU1DZ.jpg&quot; alt=&quot;with UART connected&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) When I powered the arduino with an external power source (the case with my project):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/JHWZC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JHWZC.png&quot; alt=&quot;Without UART&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I think:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=204369.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;As mentioned in this thread&lt;/a&gt;, the bootloader has a piece of code which makes it act that way.&#xA;The bootloader code has a pin definition file which declares SCK pin as a LED and blinks it a couple of times to indicate that it has entered the bootloader. &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/optiboot/pin_defs.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;I found the code here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)&#xA;/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ &#xA;#define LED_DDR     DDRB&#xA;#define LED_PORT    PORTB&#xA;#define LED_PIN     PINB&#xA;#define LED         PINB5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/optiboot/optiboot.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;Other relevant piece of code is here.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, changing the LED definition to PINB4 and burning the bootloader and program again should take care of the issue. However this didn't work out for me. This is what I did exactly:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Opened the file D:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot\pin_defs.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Modified the PINB5 to PINB4 on line 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) Saved the file, burnt the bootloader and then program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;d) Powered up the chip and tested whether I am getting those 3 pulses. I got those 3 pulses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Even though it didn't work, I am still going to try it a few more times just in case I might have made an error.) :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) This brings me to second thought that since atmega328 accepts code through SPI by default, it checks for incoming data by clocking the SCK pins 3 times during startup. In this case, a software fix won't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you guys suggest? Should I go for the PCB modification or is there still some hope left?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ignacio pointed out that I can disable bootloader to get rid of the issue. I want to program the chip using arduino IDE (preferably via UART) but I can consider SPI as well in case everything else fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I am not sure whether this post is more suited for EE or Arduino. In case you guys(mods) think I'd get better suggestions there, feel free to move my post to Arduino.&lt;/p&gt;&#xA;" OwnerUserId="7553" OwnerDisplayName="Whiskeyjack" LastActivityDate="2016-05-06T05:34:07.330" Title="Atmega328P - SCK pin" Tags="|spi|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="23901" PostTypeId="2" ParentId="23900" CreationDate="2016-05-05T12:11:25.323" Score="1" Body="&lt;p&gt;There is nothing in the default megaAVR initialization that causes SCK to behave in this manner; it is all caused by the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately all you have to do to solve this is disable the bootloader. Unprogramming the &lt;code&gt;BOOTRST&lt;/code&gt; fuse (ext:0) will cause execution to start at address 0 instead of the beginning of the bootloader on reset.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-05-05T12:11:25.323" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23902" PostTypeId="1" CreationDate="2016-05-05T13:42:12.807" Score="1" ViewCount="251" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UIFqx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UIFqx.jpg&quot; alt=&quot;This is how everything is connected&quot;&gt;&lt;/a&gt;Can anyone help me please?&#xA;I’m having a tough time trying to program 2 fsr sensors.                                                                                                           The logic behind the code is that if you were to squeeze both sensors at the same time it will print out an output on the serial monitor acknowledging that both sensors have been squeezed?                     I have got only one to work by using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* FSR simple testing sketch. &#xA;&#xA;Connect one end of FSR to power, the other end to Analog 0.&#xA;Then connect one end of a 10K resistor from Analog 0 to ground &#xA;&#xA;For more information see www.ladyada.net/learn/sensors/fsr.html */&#xA;&#xA;int fsrPin = 0;     // the FSR and 10K pulldown are connected to a0&#xA;int fsrReading;     // the analog reading from the FSR resistor divider&#xA;&#xA;void setup(void) {&#xA;  // We'll send debugging information via the Serial monitor&#xA;  Serial.begin(9600);   &#xA;}&#xA;&#xA;void loop(void) {&#xA;  fsrReading = analogRead(fsrPin);  &#xA;&#xA;  Serial.print(&quot;Analog reading = &quot;);&#xA;  Serial.print(fsrReading);     // the raw analog reading&#xA;&#xA;  // We'll have a few threshholds, qualitatively determined&#xA;  if (fsrReading &amp;lt; 10) {&#xA;    Serial.println(&quot; - No pressure&quot;);&#xA;  } else if (fsrReading &amp;lt; 200) {&#xA;    Serial.println(&quot; - Light touch&quot;);&#xA;  } else if (fsrReading &amp;lt; 500) {&#xA;    Serial.println(&quot; - Light squeeze&quot;);&#xA;  } else if (fsrReading &amp;lt; 800) {&#xA;    Serial.println(&quot; - Medium squeeze&quot;);&#xA;  } else {&#xA;    Serial.println(&quot; - Big squeeze&quot;);&#xA;  }&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what would be the correct code in order to get two sensors to work at the same time?&lt;/p&gt;&#xA;" OwnerUserId="19846" LastEditorUserId="19846" LastEditDate="2016-05-06T01:26:25.153" LastActivityDate="2016-05-06T09:36:24.377" Title="I’m having a tough time trying to program 2 fsr sensors" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23903" PostTypeId="2" ParentId="23902" CreationDate="2016-05-05T14:17:50.543" Score="1" Body="&lt;p&gt;Call your second FSR &quot;fsr2&quot; connect it to analog pin A1 and add to your existing code. Sort of like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int fsrPin = 0, fsr2Pin = 1;     // the FSR and 10K pulldown are   connected to a0&#xA;int fsrReading, fsr2Reading;     // the analog reading from the FSR resistor divider&#xA;&#xA;void setup(void) {&#xA;  // We'll send debugging information via the Serial monitor&#xA;  Serial.begin(9600);   &#xA;}&#xA;&#xA;void loop(void) {&#xA;  fsrReading = analogRead(fsrPin);&#xA;  delay(5);&#xA;  fsr2Reading = analogRead(fsr2Pin);&#xA;&#xA;&#xA;  Serial.print(&quot;Analog reading = &quot;);&#xA;  Serial.print(fsrReading);     // the raw analog reading&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.print(fsr2Reading);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20570" LastEditorUserId="20570" LastEditDate="2016-05-05T14:54:06.977" LastActivityDate="2016-05-05T14:54:06.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23904" PostTypeId="2" ParentId="17536" CreationDate="2016-05-05T15:47:06.750" Score="-1" Body="&lt;p&gt;I think you need to do some &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow noreferrer&quot;&gt;debouncing&lt;/a&gt;  on the button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can modify the code to suit your project:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; Debounce&#xA;&#xA; Each time the input pin goes from LOW to HIGH (e.g. because of a push-button&#xA; press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's&#xA; a minimum delay between toggles to debounce the circuit (i.e. to ignore&#xA; noise).&#xA;&#xA; The circuit:&#xA; * LED attached from pin 13 to ground&#xA; * pushbutton attached from pin 2 to +5V&#xA; * 10K resistor attached from pin 2 to ground&#xA;&#xA; * Note: On most Arduino boards, there is already an LED on the board&#xA; connected to pin 13, so you don't need any extra components for this example.&#xA;&#xA;&#xA; created 21 November 2006&#xA; by David A. Mellis&#xA; modified 30 Aug 2011&#xA; by Limor Fried&#xA; modified 28 Dec 2012&#xA; by Mike Walters&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; http://www.arduino.cc/en/Tutorial/Debounce&#xA; */&#xA;&#xA;// constants won't change. They're used here to&#xA;// set pin numbers:&#xA;const int buttonPin = 2;    // the number of the pushbutton pin&#xA;const int ledPin = 13;      // the number of the LED pin&#xA;&#xA;// Variables will change:&#xA;int ledState = HIGH;         // the current state of the output pin&#xA;int buttonState;             // the current reading from the input pin&#xA;int lastButtonState = LOW;   // the previous reading from the input pin&#xA;&#xA;// the following variables are long's because the time, measured in miliseconds,&#xA;// will quickly become a bigger number than can be stored in an int.&#xA;long lastDebounceTime = 0;  // the last time the output pin was toggled&#xA;long debounceDelay = 50;    // the debounce time; increase if the output flickers&#xA;&#xA;void setup() {&#xA;  pinMode(buttonPin, INPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;&#xA;  // set initial LED state&#xA;  digitalWrite(ledPin, ledState);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the switch into a local variable:&#xA;  int reading = digitalRead(buttonPin);&#xA;&#xA;  // check to see if you just pressed the button&#xA;  // (i.e. the input went from LOW to HIGH),  and you've waited&#xA;  // long enough since the last press to ignore any noise:&#xA;&#xA;  // If the switch changed, due to noise or pressing:&#xA;  if (reading != lastButtonState) {&#xA;    // reset the debouncing timer&#xA;    lastDebounceTime = millis();&#xA;  }&#xA;&#xA;  if ((millis() - lastDebounceTime) &amp;gt; debounceDelay) {&#xA;    // whatever the reading is at, it's been there for longer&#xA;    // than the debounce delay, so take it as the actual current state:&#xA;&#xA;    // if the button state has changed:&#xA;    if (reading != buttonState) {&#xA;      buttonState = reading;&#xA;&#xA;      // only toggle the LED if the new button state is HIGH&#xA;      if (buttonState == HIGH) {&#xA;        ledState = !ledState;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  // set the LED:&#xA;  digitalWrite(ledPin, ledState);&#xA;&#xA;  // save the reading.  Next time through the loop,&#xA;  // it'll be the lastButtonState:&#xA;  lastButtonState = reading;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20821" LastEditorUserId="8033" LastEditDate="2016-11-02T07:10:34.920" LastActivityDate="2016-11-02T07:10:34.920" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="23905" PostTypeId="2" ParentId="23530" CreationDate="2016-05-05T16:23:03.267" Score="6" Body="&lt;p&gt;You can absolutely use GPIO0 as an output. The ESP will read the state of GPIO0 once at boot (And never again thereafter) to determine what boot mode to enter. During this time it is an input, so, whatever you hook GPIO0 up to must not hold this pin low (Unless you want to enter bootloader mode, of course), at least until the chip boots. As long as you satisfy this condition, you can use the pin for anything else. On my board for example, I use it to drive a simple status LED, and have never seen any issue from it. &lt;/p&gt;&#xA;" OwnerUserId="20172" LastActivityDate="2016-05-05T16:23:03.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23907" PostTypeId="1" AcceptedAnswerId="23908" CreationDate="2016-05-05T18:43:56.350" Score="2" ViewCount="136" Body="&lt;p&gt;I've got two arduino cards and two bluetooth bluesmirfs. I am currently trying to read value from a joystick and send it over to the other arduino card and use that value to control my servo motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       //Master Code&#xA;void loop()&#xA;{&#xA;    yVal = analogRead(yAxis);   (value between 0 and 1023)&#xA;  if(bluetooth.available())  &#xA;  {&#xA;&#xA;    bluetooth.print(yVal);  &#xA;  }&#xA;  else if(Serial.available())  &#xA;  {&#xA;&#xA;    Serial.print(yVal);&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&#xA;&#xA;&#xA;//Slave code&#xA;void loop(){&#xA;  while(Serial.available())&#xA;  {&#xA;&#xA;    int c = Serial.read();&#xA;    Serial.print(&quot;Joystick value: &quot;);&#xA;    Serial.println(c);&#xA;    int val = map(c, 0, 1023, 0, 255);&#xA;    Serial.print(&quot;Map value: &quot;);&#xA;    Serial.println(val);&#xA;&#xA;      myServo.write(val);&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong? Instead of getting something between 0 and 1023 I get something below 50.&lt;/p&gt;&#xA;" OwnerUserId="20703" LastActivityDate="2016-05-05T18:49:28.843" Title="Value of joystick reduces when I send it over serial" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23908" PostTypeId="2" ParentId="23907" CreationDate="2016-05-05T18:49:28.843" Score="0" Body="&lt;p&gt;A fundamental lack of understanding of how serial communications works is what you have.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial sends bytes. You are attempting to read an int. The two don't match. Not only that, but you are sending the value as text, not a number, so you're interpreting it as gibberish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion: do the &lt;code&gt;map&lt;/code&gt; on the master not the slave, and send a raw byte between 0 and 255 not a string of text between &quot;0&quot; and &quot;1023&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bluetooth.write(map(yVal, 0, 1023, 0, 255)); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-05T18:49:28.843" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23909" PostTypeId="1" AcceptedAnswerId="23915" CreationDate="2016-05-05T19:29:41.850" Score="1" ViewCount="618" Body="&lt;p&gt;I recently purchased a 5M strip of digital RGB LEDs, that is compatible with the &quot;Adafruit_NeoPixel.h&quot; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is maintaining the original order of the LEDs important?  Could I cut the strip in say four sections, and then reconnect those sections out of their original order?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just to be clear these are digital 3-pin(+5V,DI,GRN) strips, not analog 4-pin(+12V, R, G, B) strips.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just not finding good info regarding if the individual LEDs are pre-assigned an ID by the manufacturer, or if they somehow use a serial-timing way to assign IDs at startup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before digging through the Adafruit_NeoPixel.h, I wanted to see if I could get a quicker answer here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;THANKS!&lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-05-07T23:59:54.337" Title="Using an Arduino to drive a digital RGB LED strip" Tags="|rgb-led|" AnswerCount="1" CommentCount="0" ClosedDate="2016-05-07T01:46:47.297" ContentLicense="CC BY-SA 3.0" />
  <row Id="23910" PostTypeId="2" ParentId="23873" CreationDate="2016-05-05T19:31:18.987" Score="2" Body="&lt;p&gt;Expanding on my comment... I see a few issues in your asm code, not all&#xA;as serious as the first one:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;killms&lt;/code&gt; is calling itself recursively indefinitely, which should&#xA;overflow your stack. The last &lt;code&gt;rcall killms%=&lt;/code&gt; should probably be an&#xA;&lt;code&gt;rjmp&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;There is no need to move the answer around between register pairs.&#xA;Just use the compiler-allocated registers instead of &lt;code&gt;r17:r16&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;By &lt;code&gt;adc r26, r17&lt;/code&gt;, you probably mean &lt;code&gt;adc r27, r17&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Instead of &lt;code&gt;add&lt;/code&gt; and &lt;code&gt;adc&lt;/code&gt;, you could just &lt;code&gt;adiw&lt;/code&gt;, which saves a&#xA;register pair.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Below is my version of &lt;code&gt;testReactionTime()&lt;/code&gt;. I tested it on an Uno (with&#xA;&lt;code&gt;Serial&lt;/code&gt; instead of an LCD) and it works fine. The assumptions on the&#xA;hardware are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The LED is on pin 13 (PB5): it's the built-in LED.&lt;/li&gt;&#xA;&lt;li&gt;The button is on pin 2 (PD2), which goes HIGH when the button is pressed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * After a random delay, call this function to measure the reaction time&#xA; * in milliseconds. It will immediately turn the built-in LED and then&#xA; * start timing the milliseconds until the user hits the button (pin 2&#xA; * going HIGH).&#xA; */&#xA;int testReactionTime()&#xA;{&#xA;    int result, counter;&#xA;    asm volatile(&#xA;        &quot;    clr %A[result]                      \n&quot; // clear result&#xA;        &quot;    clr %B[result]                      \n&quot; // ditto&#xA;        &quot;    sbi %[led_port], %[led_bit]         \n&quot; // LED on&#xA;&#xA;        // delay to make the loop 0 last exactly one millisecond&#xA;        &quot;0:  ldi %A[counter], lo8(%[iterations]) \n&quot;&#xA;        &quot;    ldi %B[counter], hi8(%[iterations]) \n&quot;&#xA;        &quot;1:  sbiw %[counter], 1                  \n&quot;&#xA;        &quot;    brne 1b                             \n&quot;&#xA;        &quot;    nop                                 \n&quot;&#xA;&#xA;        &quot;    sbic %[button_pin], %[button_bit]   \n&quot; // unless button up:&#xA;        &quot;    rjmp 2f                             \n&quot; //     we are done&#xA;        &quot;    adiw %[result], 1                   \n&quot; // increment result&#xA;        &quot;    rjmp 0b                             \n&quot; // loop back&#xA;        &quot;2:  cbi %[led_port], %[led_bit]         \n&quot; // done: LED off&#xA;&#xA;        : [result]     &quot;=w&quot; (result)&#xA;        , [counter]    &quot;=w&quot; (counter)&#xA;        : [led_port]   &quot;I&quot;  (_SFR_IO_ADDR(PORTB))  // LED on PB5&#xA;        , [led_bit]    &quot;I&quot;  (5)&#xA;        , [button_pin] &quot;I&quot;  (_SFR_IO_ADDR(PIND))   // button on PD2&#xA;        , [button_bit] &quot;I&quot;  (2)&#xA;        , [iterations] &quot;i&quot;  ((16000 - 8) / 4)&#xA;    );&#xA;    return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-05T19:31:18.987" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23911" PostTypeId="1" AcceptedAnswerId="23925" CreationDate="2016-05-05T19:43:09.913" Score="5" ViewCount="8547" Body="&lt;p&gt;I am buying an ESP8266 and the plan is to control it serially from an Arduino. I am going to use a voltage divider(Using a voltage divider is temporary and I know the cons of using voltage dividers).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I calculated out the values of the voltage divider and I am going to use 220 ohm and 440 ohm value resistors to get 3.3 volts and 250 ma from the Arduino 5v pin so I can power vcc and ch_pd on the ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The question&lt;/strong&gt; is do I need to use a separate voltage divider to connect Arduino TX to ESP8266 RX and Arduino RX to ESP8266 TX. Or will it be safe to connect RX and TX directly to Arduino RX and TX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Honestly I am extremely new to this and I don't even know if I am going at this right. If I am tell me.&lt;/p&gt;&#xA;" OwnerUserId="20763" LastEditorUserId="20763" LastEditDate="2016-05-05T23:28:22.687" LastActivityDate="2016-05-06T09:06:29.210" Title="Do I need 3 voltage dividers to control ESP8266" Tags="|arduino-uno|esp8266|voltage-level|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23912" PostTypeId="1" AcceptedAnswerId="23913" CreationDate="2016-05-05T19:52:34.603" Score="1" ViewCount="1449" Body="&lt;p&gt;I have a 3A fan hooked up to an ATX power supply in parallel with a transformer which powers my board through VIN/GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATX is gated by a relay on its DC side and seems to cause enough of a current drain that it causes the Arduino to reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have place a 470μF capacitor accross the Arduinos VIN and GND pins and it seems to have stopped the problem, but I'm not too experienced using capacitors. Is this an apropriate value? I'm not sure what difference it would make. And is this a wise move as I so think?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Standard?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Here's a very basic sketch..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ybo62.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ybo62.png&quot; alt=&quot;12V Transformer powers arduino on VIN/GND pins, other pins a 5V, GND and control for relay&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;12V Transformer powers arduino on VIN/GND pins, other pins are 5V, GND and control for relay&lt;/p&gt;&#xA;" OwnerUserId="17150" LastEditorUserId="17150" LastEditDate="2016-05-05T21:38:17.357" LastActivityDate="2016-05-05T21:38:17.357" Title="Is it safe to place a capacitor across vin and gnd?" Tags="|power|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23913" PostTypeId="2" ParentId="23912" CreationDate="2016-05-05T20:26:09.903" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have a 3A fan hooked up to an ATX power supply in parallel with a transformer which powers my board through VIN/GND.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't entirely follow that wording. Please draw a picture.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I have place a 470μF capacitor accross the Arduinos VIN and GND pins and it seems to have stopped the problem, but I'm not too experienced using capacitors. Is this an apropriate value? I'm not sure what difference it would make. And is this a wise move as I so think?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;470µF is fine. In this situation the bigger the better. If 470µF fixes it then 470µF is fine. Don't be afraid of going higher though. I have 3,300µF capacitors here that are commonly used for similar purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you have implemented is called a &lt;em&gt;reservoir&lt;/em&gt; capacitor and is a common use for large value capacitors like that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-05T20:26:09.903" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23914" PostTypeId="2" ParentId="23900" CreationDate="2016-05-05T21:43:09.810" Score="1" Body="&lt;p&gt;I compiled Optiboot a while back using the shell script below. This is for Linux, you may need to adapt slightly for other operating systems.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;BIN_LOCATION='/home/nick/Development/arduino-1.6.5-r5/hardware/tools/avr/bin'&#xA;&#xA;$BIN_LOCATION/avr-gcc -mmcu=atmega328p \&#xA;    -D__AVR_ATmega328P__ \&#xA;    -DF_CPU=16000000L \&#xA;    -DBOOTLOADER_ADDRESS=7E00\&#xA;    -DBAUD_RATE=115200 \&#xA;    -DLED_START_FLASHES=0 \&#xA;    -DOPTIBOOT_FIX=1 \&#xA;    -Os \&#xA;    -gdwarf-2 \&#xA;    -fno-inline-small-functions \&#xA;    -fno-split-wide-types \&#xA;    -fno-tree-scev-cprop  \&#xA;    -fno-exceptions -ffunction-sections -fdata-sections \&#xA;    -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -fno-jump-tables  \&#xA;    -fno-keep-inline-functions -fno-common \&#xA;    -std=gnu99 \&#xA;    -Wl,--section-start=.text=7E00 \&#xA;    -Wl,--relax -nostartfiles \&#xA;    -Wl,--gc-sections \&#xA;    -ooptiboot.elf optiboot.c &#xA;&#xA;rm -f optiboot.hex&#xA;&#xA;$BIN_LOCATION/avr-objcopy -O ihex --set-section-flags=.eeprom=alloc,load \&#xA;    --no-change-warnings \&#xA;    --change-section-lma \&#xA;    .eeprom=0 \&#xA;    -R .eeprom optiboot.elf optiboot.hex&#xA;&#xA;$BIN_LOCATION/avr-objdump -j .sec1 -d -m avr5 optiboot.hex &amp;gt; optiboot.lst&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need to find where your copy of avr-gcc and insert that into the first line above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice I have changed the define for &lt;code&gt;LED_START_FLASHES&lt;/code&gt; to be zero above. That should fix the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save you the trouble of doing that, I have made a &quot;no blink&quot; version for the Atmega328 and put it here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://gammon.com.au/Arduino/optiboot_no_blink_atmega328.hex&quot; rel=&quot;nofollow&quot;&gt;http://gammon.com.au/Arduino/optiboot_no_blink_atmega328.hex&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt; - the script above compiled the &quot;no blink&quot; version OK, but using the latest version of the Optiboot.c code, and the latest compiler, makes a .hex file that is four bytes too long, for reasons I can't work out. However it compiles fine if you omit the blinks, because there is less code there. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Note re the LED on D13. Because the LED is driven by an op-amp (on the Uno), it will flash even with the above code. However that is because the op-amp has a high-impedance input. If you use a pull-down resistor on D13 it won't flash.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now that I look at the download, it is so short I may as well include it here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;:107E0000112482E08093C00088E18093C10086E065&#xA;:107E10008093C20080E18093C40084B714BE81FFC8&#xA;:107E2000C8D088E1809360008DE080936000259A3F&#xA;:107E300018E108E033E0F32EEE24EA94DD24D39435&#xA;:107E400045E0C42E51E1B52EA7D0813429F481E05C&#xA;:107E5000BED083E09AD096C0823419F484E1B7D0C2&#xA;:107E600091C0853419F485E0B2D08CC0853599F481&#xA;:107E700093D0C82FD0E0D0930102C09300028CD0E1&#xA;:107E80009E01382BC901880F991F9093010280939E&#xA;:107E9000000297D077C0863529F484E098D080E03E&#xA;:107EA00074D070C0843609F042C07ED0E0910002E8&#xA;:107EB000F0910102F0925700E895C0E0D1E002C0D5&#xA;:107EC0006BD089938C2F90910202C917C8F38C1B39&#xA;:107ED00001C0E9929C2F980F9034D8F372D007B666&#xA;:107EE00000FCFDCF40910002509101029A01A0E0F8&#xA;:107EF000B1E08C911296FD013197608190E0962B54&#xA;:107F0000F9010C01D0925700E89511242E5F3F4FE4&#xA;:107F1000A038F1E0BF0769F7FA01C0925700E89571&#xA;:107F200007B600FCFDCFB0925700E8952BC0843710&#xA;:107F3000B1F43AD046D0E0910002F0910102CF01B5&#xA;:107F40000196909301028093000284911ED080914B&#xA;:107F500002028150809302028111EDCF13C0853758&#xA;:107F600041F42FD08EE111D085E90FD08FE00DD0F4&#xA;:107F700009C0813531F4109360000093600021D076&#xA;:107F800001C01FD080E101D05FCF9091C00095FF6C&#xA;:107F9000FCCF8093C6000895A8958091C00087FF0C&#xA;:107FA000FCCF8091C6000895F7DFF6DF80930202D0&#xA;:107FB000F3CFE0E6F0E088E180831082EE27FF2730&#xA;:107FC0000994EADF803209F0F4DF84E1DECFCF9359&#xA;:0C7FD000C82FE2DFC150E9F7CF91F3CFDA&#xA;:0400000300007E007B&#xA;:00000001FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just save that as optiboot.hex.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-05-06T05:34:07.330" LastActivityDate="2016-05-06T05:34:07.330" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23915" PostTypeId="2" ParentId="23909" CreationDate="2016-05-06T03:16:11.130" Score="0" Body="&lt;p&gt;I can not find detailed information regarding the 5M LED strips you bought.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used &lt;a href=&quot;https://www.adafruit.com/products/1460&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit addressable LED strips&lt;/a&gt;.  What Adafruit publishes on their web site helped a great deal when I cut my strips into smaller sizes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an Adafruit image which may help you:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3iuFt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3iuFt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would think the order does not matter.  But you do need to connect the data such that &quot;outs&quot; go to &quot;ins&quot;.  And you need to connect them in a row.  That is you need to connect them in one loop.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming we are using the &lt;a href=&quot;https://cdn-shop.adafruit.com/datasheets/WS2812.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;WS2812&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XnVKD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XnVKD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We know from the specifications that the RGB data is encoded as 3 8 bit NZR (Non Zero Return) pulses.  8 bits for each color: red, green &amp;amp; blue.  That there is 1 such &quot;word&quot; of 24 bits for each pixel.  That the beginning of a set of &quot;words&quot; is marked by a 50us or grater interval where DI is zero.  And that each pixel strips off the first 24 bit &quot;word&quot; before passing the balance of the data on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, it doesn't matter what order WS2812 are assembled in.  Also that WS2812 have no idea where they are in the sequence.  All that matters is that each succeeding WS2812 gets its data from the previous WS2812. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last note. The necessary timing is really fast and really tight. Can't be more than 150 billionths of a second off. No way can a multitasking platform like a PC, Mac or RaspberryPi pull this off.  When sending off a set of &quot;words&quot; to a string of pixels, the embedded processor will likely not be doing anything else!&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-07T23:59:54.337" LastActivityDate="2016-05-07T23:59:54.337" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23916" PostTypeId="1" CreationDate="2016-05-06T03:25:59.370" Score="0" ViewCount="233" Body="&lt;p&gt;I have facing a problem since long and cannot solve it. I built Arduino car and place 2 IR sensors shown in image, to check down distance to avoid falling from stairs. One is at back and other at front. On hard surface they work well but on carpet always give wrong reading like no object there which translates unsafe to move and my car stops. How can we solve this problem? I also tried Ultrasonic but it has same problem on carpets or fabric. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested this that on carpet it was giving a big distance reading but when I place a white paper, suddenly it was fixed and detected surface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Zk2ve.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zk2ve.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2016-05-07T00:53:12.710" Title="IR sensor does not work well on carpets" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23917" PostTypeId="2" ParentId="23911" CreationDate="2016-05-06T04:45:59.327" Score="1" Body="&lt;p&gt;The RX pin is 5V tolerant (at least it is on all of my boards!) and almost certainly your arduino will recognize 3V as logic high for the TX pin. So you don't really need any level conversions there (no other pin is 5V tolerant).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you sure your ESP8266 board doesn't already have a 5V to 3V3 regulator? I've never seen one!&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-06T04:45:59.327" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23918" PostTypeId="1" AcceptedAnswerId="23923" CreationDate="2016-05-06T05:21:17.527" Score="0" ViewCount="7881" Body="&lt;p&gt;I know its probably an odd question...but I found a workaround for a foreach loop in C. I have a whole bunch of int arrays that I would like to be able to pass into a void, which has that foreach loop in it. This is my code right now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int example[] = {1, 2, 3, 4, 5};&#xA;&#xA;void setup () {&#xA;    Serial.begin(57600);&#xA;&#xA;    #define foreach(item, array) \&#xA;        for(int keep = 1, \&#xA;            count = 0,\&#xA;            size = sizeof (array) / sizeof *(array); \&#xA;            keep &amp;amp;&amp;amp; count != size; \&#xA;            keep = !keep, count++) \&#xA;        for(item = (array) + count; keep; keep = !keep)&#xA;    }&#xA;}&#xA;&#xA;void Words (int w[]) {&#xA;    foreach(int *v, w) {&#xA;        Serial.println(*v);&#xA;        delay(500);&#xA;    }&#xA;}&#xA;&#xA;void loop () {&#xA;    Words (example);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However when I run it, it only returns the first number of the array, I need all 5 of them. I know theres all sorts of additional things that could be it, like the * or &amp;amp; symbol but I really don't understand what they do. Any ideas as to how to get that to work?&lt;/p&gt;&#xA;" OwnerUserId="18429" LastActivityDate="2016-05-07T20:56:35.960" Title="How do I pass an Int Array into void for a foreach loop?" Tags="|arduino-uno|programming|c|array|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23920" PostTypeId="1" CreationDate="2016-05-06T07:20:53.967" Score="0" ViewCount="1669" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/94ZrE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/94ZrE.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;Can anyone help me with this issue&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to program two FSR sensors through typing this code but I've realized that one is working instead of two. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The logic behind the code is that if you were to squeeze both sensors at the same time it will print out an output on the serial monitor acknowledging that both sensors have been squeezed. I have got only one to work by using this code.              &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first sensor is connected to the A0 pin on the arduino and the second sensor is connected to the A1 pin &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that I've written &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* FSR simple testing sketch. &#xA;&#xA; Connect one end of FSR to power, the other end to Analog 0.&#xA; Then connect one end of a 10K resistor from Analog 0 to ground &#xA; For more information see www.ladyada.net/learn/sensors/fsr.html */&#xA;&#xA;int fsrPin = 0;&#xA;int fsr2Pin = 1;   // the FSR and 10K pulldown are connected to a1&#xA;int fsrReading ;&#xA;int fsr2Reading;   // the analog reading from the FSR resistor divider &#xA;&#xA;void setup(void) {&#xA;    // We'll send debugging information via the Serial monitor&#xA;    Serial.begin(9600);   &#xA;}&#xA;&#xA;void loop(void) {&#xA;    fsrReading = analogRead(fsrPin);&#xA;    fsr2Reading = analogRead(fsr2Pin); &#xA;&#xA;    Serial.print(&quot;Analog reading = &quot;);&#xA;    Serial.print(fsrReading);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.print(fsr2Reading);&#xA;&#xA;    // We'll have a few threshholds, qualitatively determined&#xA;    if (fsrReading &amp;lt; 10) {&#xA;        Serial.println(&quot; - Nothing&quot;);&#xA;    } else if (fsrReading &amp;lt; 200) {&#xA;        Serial.println(&quot; - Light&quot;);&#xA;    } else if (fsrReading &amp;lt; 500) {&#xA;        Serial.println(&quot; - Lightness&quot;);&#xA;    } else if (fsrReading &amp;lt; 800) {&#xA;        Serial.println(&quot; - Medium&quot;);&#xA;    } else if (fsr2Reading &amp;lt; 1100) {&#xA;        Serial.println(&quot; - No-Pressure&quot;);&#xA;    } else if (fsr2Reading &amp;lt; 1400) {&#xA;        Serial.println(&quot; - Light-touch&quot;);&#xA;    } else if (fsr2Reading &amp;lt; 1700) {&#xA;        Serial.println(&quot; - Light-squeeze&quot;);&#xA;    } else if (fsr2Reading &amp;lt; 2000) {&#xA;        Serial.println(&quot; - Medium-squeeze&quot;);&#xA;    } else {&#xA;        Serial.println(&quot; - Big-squeeze&quot;);&#xA;    }&#xA;    delay(1000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So could anyone tell how to edit this code correctly in order to get two sensors to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The one connected to the A0 pin is working but not the other &#xA;&lt;a href=&quot;https://i.stack.imgur.com/XnXzJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XnXzJ.jpg&quot; alt=&quot;This how its physically connected&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19846" LastEditorUserId="84" LastEditDate="2016-05-06T08:17:30.293" LastActivityDate="2016-05-06T22:25:55.793" Title="Code doesn't seem to work when trying to program 2 sensors" Tags="|arduino-uno|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23923" PostTypeId="2" ParentId="23918" CreationDate="2016-05-06T08:08:59.187" Score="1" Body="&lt;p&gt;What you want will not work the way you think: in C++ (just like in C), arrays and pointers are almost the same, and the compiler won't be able to make a distinction between&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void f(int* array)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void f(int array[])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In particular, inside &lt;code&gt;f()&lt;/code&gt; the compiler won't be able to know the actual size of &lt;code&gt;array&lt;/code&gt;: for the compiler &lt;code&gt;sizeof array&lt;/code&gt; will always be the same as &lt;code&gt;sizeof(int*)&lt;/code&gt;, i.e. just the size of a pointer, always 2 bytes on Arduino UNO, whatever type it points to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want your &lt;code&gt;foreach&lt;/code&gt; macro to work correctly, you have to pass it the actual array count of items as an additional argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define foreach(item, array, size) \&#xA;    for(int keep = 1, \&#xA;        count = 0;\&#xA;        keep &amp;amp;&amp;amp; count != size; \&#xA;        keep = !keep, count++) \&#xA;    for(item = (array) + count; keep; keep = !keep)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also pass the count of items in &lt;code&gt;Words&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Words(int w[], size_t size) {&#xA;    foreach(int *v, w, size) {&#xA;        Serial.println(*v);&#xA;        delay(500);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;loop()&lt;/code&gt; you can use &lt;code&gt;sizeof example&lt;/code&gt;, because the compiler knows what its size is, from its initialization (an array of 5 integers, i.e. 10 bytes):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    Words(example, sizeof example / sizeof example[0]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even define a macro to compute the count of items in an array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will work &lt;strong&gt;as long as you use it with an argument that is completely known by the compiler&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    Words(example, ARRAY_SIZE(example));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Important comments on your original code&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You mentioned that you want to &quot;&lt;em&gt;save space&lt;/em&gt;&quot;, but defining a macro will not help in this regard, as a macro is &lt;strong&gt;NOT&lt;/strong&gt; a function, hence &lt;strong&gt;its &lt;em&gt;binary code&lt;/em&gt; will be repeated everywhere it is used&lt;/strong&gt;. It can just help make your &lt;em&gt;source code&lt;/em&gt; shorter and possibly clearer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you defined your macro seems weird and overly complex to me: why use 2 &lt;code&gt;for&lt;/code&gt; loops when you need only one?&#xA;It would have been possible to define it in a simpler way, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define foreach(type, var, array, size) \&#xA;    for(type* var = array; var != array + size; var++)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It would be used as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Words(int w[], size_t size) {&#xA;    foreach(int, v, w, size) {&#xA;        Serial.println(*v);&#xA;        delay(500);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using C++ templates may probably help too, but this is an advanced topic. I'd recommend reading first some good book about C++ before digging into templates.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-05-06T08:08:59.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23924" PostTypeId="2" ParentId="23920" CreationDate="2016-05-06T09:02:50.933" Score="1" Body="&lt;p&gt;As JFPoilpret says you if logic is wrong.&#xA;It might make it easier if you took that whole if block out and made it into a function that accepted the value from the sensor as a parameter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void CheckReading(int reading)&#xA;{&#xA;    if (reading &amp;lt; 10) {&#xA;        Serial.println(&quot; - Nothing&quot;);&#xA;    } else if (reading &amp;lt; 200) {&#xA;        Serial.println(&quot; - Light&quot;);&#xA;    } else if (reading &amp;lt; 500) {&#xA;        Serial.println(&quot; - Lightness&quot;);&#xA;    } else if (reading &amp;lt; 800) {&#xA;        Serial.println(&quot; - Medium&quot;);&#xA;    } else {&#xA;        Serial.println(&quot; - Big-squeeze&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that the values only go up to 800, going larger than 1023 won't work anyway.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-06T09:02:50.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23925" PostTypeId="2" ParentId="23911" CreationDate="2016-05-06T09:06:29.210" Score="3" Body="&lt;p&gt;For &lt;strong&gt;ESP 3.3V power supply&lt;/strong&gt;, I'd recommend a distinct 3.3V regulated supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, the Arduino UNO already has a 3.3V output but it may not supply enough current to the ESP (current consumption can go up to almost 200mA): UNO 3.3V pin is limited to 50mA. So do not use it or you may roast your UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using resistors to output 3.3V from Arduino 5V might be possible (the UNO 5V pin can provide ~400mA) but it would be a big waste of energy because you'd have to use low resistor values to be able to supply 200mA for instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might possibly use a 7833 regulator with additional caps to provide 3.3V from Arduino 5V pin (or &lt;code&gt;Vin&lt;/code&gt; directly if your UNO is powered through the DC power jack, not USB)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;strong&gt;ESP RX&lt;/strong&gt; a voltage divider is foreseeable but it may trigger issues due its switching response time, which may be too slow when transmitting data at high baud rates. I recommend using a &lt;a href=&quot;http://www.hobbytronics.co.uk/mosfet-voltage-level-converter&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSFET based level shifter&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DDKpm.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DDKpm.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The advantages of this circuit are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;it has the fastest switching response time&lt;/li&gt;&#xA;&lt;li&gt;it can work in both directions (3.3V -&gt; 5V and 5V -&gt; 3.3V)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can also buy some cheap &lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow noreferrer&quot;&gt;ready-made breakouts&lt;/a&gt; using this circuit and offering several level shifters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For &lt;strong&gt;ESP TX&lt;/strong&gt;, I'd also recommend the same level shifter circuit as for RX (if you can make one, you can make two).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-05-06T09:06:29.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23926" PostTypeId="1" AcceptedAnswerId="23941" CreationDate="2016-05-06T09:19:12.247" Score="5" ViewCount="26640" Body="&lt;p&gt;I have a huge number of arrays, each with a series of numbers each referring to an LED on a strip. I want to be able to address each one by a number, so the logical solution to that for me was to make the whole thing into an array. Can that be done, or is there a better work around that can be implemented?&lt;/p&gt;&#xA;" OwnerUserId="18429" LastActivityDate="2018-12-13T12:57:18.810" Title="Is it possible to have an array of int arrays?" Tags="|array|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23929" PostTypeId="1" CreationDate="2016-05-06T09:42:39.437" Score="-1" ViewCount="1705" Body="&lt;p&gt;I have Arduino UNO with Adaruit wifi shield. I store some data on the sd card successfully and now I need to import that data on to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sending some token, say &quot;1&quot;, to the UART port of Arduino (COM port), there is a code written on the Arduino which responds to that token and sends data (byte by byte) in the bulk amount on the serial of the Arduino. I have to accept bytes and store in a file on the local machine (computer) and upload to the server ultimately at the same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(It will be good if the process has the browser support i.e I will send request from web browser to API and that API will connect to serial port/ COMP port of my Computer and somehow the file will be created on the local machine and the data from the Arduino will be saved in that file; the file created will be uploaded to the server ultimately.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the proper way to this, is there any API or software for it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="20838" LastActivityDate="2020-01-20T21:02:35.350" Title="How to import data from SDcard on Arduino to the computer using Arduino serial/COM port?" Tags="|arduino-uno|serial|sd-card|web-server|uart|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23930" PostTypeId="1" AcceptedAnswerId="23932" CreationDate="2016-05-06T09:44:02.660" Score="0" ViewCount="49" Body="&lt;p&gt;I have a &lt;a href=&quot;https://www.sparkfun.com/products/11231&quot; rel=&quot;nofollow&quot;&gt;SparkFun Power Cell - LiPo Charger/Booster&lt;/a&gt; and want to use the external 5V charge capability. Now my question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I directly hook up a DC jack (for a 5V power supply) &lt;strong&gt;and&lt;/strong&gt; an &lt;a href=&quot;https://www.adafruit.com/product/1407&quot; rel=&quot;nofollow&quot;&gt;inductive charging circuit&lt;/a&gt; to the external charge pins of the Sparkfun Power Cell LiPo Charger Module or should I use a slide switch so that &lt;strong&gt;either&lt;/strong&gt; the power supply via the dc jack &lt;strong&gt;or&lt;/strong&gt; the inductive charging module can power the Sparkfun Power Cell LiPo Charger? I prefer the first option, but I have concerns that the inductive charging module is damaged when for example the power supply is hooked up... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have anybody experience with an similar setup?&lt;br&gt; &#xA;Thank you in advance for your answers.&lt;/p&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2016-05-06T10:20:49.117" Title="Use of two external power sources for a power cell - charger" Tags="|power|inductive|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23931" PostTypeId="2" ParentId="23929" CreationDate="2016-05-06T10:16:53.047" Score="1" Body="&lt;p&gt;There is an example for the ESP8266 (using the Arduino IDE) called SDWebServer which might give you some ideas, I would suggest you try it but I doubt the libraries would work on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to support a web API, I would suggest you implement a REST API on the Arduino, that is a commonly used API for these type of things.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The client (PC) sends a HTTP GET request to the server (Arduino) with the token you want.&lt;/li&gt;&#xA;&lt;li&gt;The server responds with the data the token corresponds to.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You are using standard HTTP (you can do it through a browser), so it should go through firewalls without a problem.  Its a very common format, there are plenty of tools to debug it and tutorials for all sorts of platforms that you should be able learn from.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is REST API isn't the best solution for Serial comms, I'm not saying its impossible you could send the network messages via serial, but it wouldn't be pretty.  I think you would be better keeping your custom interface for the serial and moving as much of the code into common functions so you can share it between the two interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-06T10:16:53.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23932" PostTypeId="2" ParentId="23930" CreationDate="2016-05-06T10:20:49.117" Score="1" Body="&lt;p&gt;A switch would be the best way of preventing damage, but you could also use diodes to prevent power flowing back to the PSU or Inductive circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried something similar once using transistors to prevent both circuits operating at the same time, but never managed to get it to work.  You could practice any solutions on a breadboard with some LEDs.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-06T10:20:49.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23934" PostTypeId="1" AcceptedAnswerId="23940" CreationDate="2016-05-06T11:11:12.290" Score="0" ViewCount="8077" Body="&lt;p&gt;I was planning to buy serial to USB converter (FT232RL) to be able to program Arduino Pro Mini.&#xA;But the shop nearby offers Arduino Nano V3 at almost the same price.&#xA;Could I use this Arduino instead (and gain new microcontroller platform for free ;-)?&lt;/p&gt;&#xA;" OwnerUserId="20025" LastActivityDate="2019-11-29T10:14:07.550" Title="Can I use Arduino Nano V3 to program another arduino (Pro Mini)?" Tags="|programming|arduino-nano|arduino-pro-mini|programmer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23935" PostTypeId="2" ParentId="16042" CreationDate="2016-05-06T11:34:30.753" Score="0" Body="&lt;p&gt;So basically there are two wires connected to the same positive 12v source, one connected to VCC on the input side of the relay board and the other connected to the output side common terminal. &#xA;And there are three connections from the same negative 12v source, one connected to the ground of the relay board, one connected to the ground of the arduino, and the other connected to the ground of the load.&#xA;Then, of course, the connection to the relay to one of the digital pins of the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well I'm pleased to report it works!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to discover what the jumpered COM/GND connection on my relay board does or does not do. I will report back.   &lt;/p&gt;&#xA;" OwnerUserId="20843" LastActivityDate="2016-05-06T11:34:30.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23936" PostTypeId="2" ParentId="23920" CreationDate="2016-05-06T11:56:25.950" Score="1" Body="&lt;p&gt;Try changing the pins to use A0 and A1, as pins 0 and 1 relate to the digital pins.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int fsrPin = A0;&#xA;int fsr2Pin = A1;   // the FSR and 10K pulldown are connected to a1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As has been mentioned by Matt, make sure you also only test for values between 0 and 1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are also missing the pinMode, which sets the pins as input/output in the setup function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(void) {&#xA;    // We'll send debugging information via the Serial monitor&#xA;    Serial.begin(9600);   &#xA;    pinMode(fsrPin, INPUT);&#xA;    pinMode(fsr2Pin, INPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18709" LastActivityDate="2016-05-06T11:56:25.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23937" PostTypeId="1" CreationDate="2016-05-06T12:18:16.487" Score="1" ViewCount="613" Body="&lt;p&gt;I have just installed newest version of Arduino 1.7.10 from arduino.org. &lt;br&gt;&lt;br&gt;&#xA;It has this problem that its menu are not displaying properly - when I hover mouse over items in menu they either disappear completely or some of the letters are missing. Sometimes the whole menu (like 'tools' menu) won't even display. Dialog windows (like &quot;Do you want to save your changes&quot;) also suffer from this problem.&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have Windows 7 and I just installed newest version of Java to see if this helps, but it doesn't. &lt;br&gt;&#xA;Have any of you had such problem?&lt;/p&gt;&#xA;" OwnerUserId="20845" LastActivityDate="2017-06-01T06:55:55.943" Title="Arduino IDE menu doesn't display properly (missing letters)" Tags="|ide|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23938" PostTypeId="2" ParentId="23937" CreationDate="2016-05-06T12:55:12.607" Score="1" Body="&lt;p&gt;I've never had this problem, but here are some things you might want to look at.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Did you install it from an administrator account and use &quot;run as administrator&quot;?  If not, uninstall and reinstall.&lt;/li&gt;&#xA;&lt;li&gt;Its possible that you are missing a font, god knows which one.  Go and look at the Arduino source on GitHub(?) and find any TTF files and install them.&lt;/li&gt;&#xA;&lt;li&gt;Does this version support Windows 7?&lt;/li&gt;&#xA;&lt;li&gt;What version did you have previously? Did you uninstall it before installing this?&lt;/li&gt;&#xA;&lt;li&gt;If you didn't have a version before this one, uninstall this version go and get 1.5 or 1.6 and install that, then install 1.7 over the top.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Good luck, and keep monitoring the Arduino.org forums because if it is a problem with the app then they will start screaming quite quickly.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-06T12:55:12.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23940" PostTypeId="2" ParentId="23934" CreationDate="2016-05-06T13:23:59.363" Score="2" Body="&lt;p&gt;&lt;strong&gt;Yes!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, you can substitute the Arduino Nano V3 for the Arduino Uno and follow the instructions &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;, providing that the Arduino Pro Mini is a 5V version. (Otherwise, you will have to do some voltage conversion.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both boards have the same SPI pins as the Arduino Uno. The connections would be as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Nano --&gt; Arduino Pro Mini&lt;br&gt;&#xA;5V  -------------------&gt;  Vcc&lt;br&gt;&#xA;GND  ----------------&gt;  GND&lt;br&gt;&#xA;D10  -----------------&gt;  RESET (10uF between RESET &amp;amp; GND)&lt;br&gt;&#xA;D11  -----------------&gt;  D11&lt;br&gt;&#xA;D12  -----------------&gt;  D12&lt;br&gt;&#xA;D13  -----------------&gt;  D13&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The process detailed in the link can be summarized as follows:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Load the &lt;code&gt;ArduinoISP&lt;/code&gt; sketch into the Arduino that you will use as programmer. You find it under &lt;code&gt;Examples&lt;/code&gt; &gt; &lt;code&gt;11. ArduinoISP&lt;/code&gt; &gt; &lt;code&gt;ArduinoISP&lt;/code&gt;. &lt;/li&gt;&#xA;&lt;li&gt;Select the serial port of the Arduino Nano (target): &lt;code&gt;Tools&lt;/code&gt; &gt; &lt;code&gt;Port&lt;/code&gt; &gt; corresponding port number.&lt;/li&gt;&#xA;&lt;li&gt;Wire up the two Arduinos as described.&lt;/li&gt;&#xA;&lt;li&gt;In the &lt;code&gt;Tools&lt;/code&gt; menu, set the programmer to the &lt;code&gt;Arduino as ISP&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Select the target board: &lt;code&gt;Tools&lt;/code&gt; &gt; &lt;code&gt;Board&lt;/code&gt; &gt; &lt;code&gt;Arduino Pro Mini&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Open the program to be loaded to the Arduino Pro Mini and program it by selecting &lt;code&gt;Sketch&lt;/code&gt; &gt; &lt;code&gt;Upload using programmer&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:55:22.490" LastActivityDate="2018-12-13T12:55:22.490" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="23941" PostTypeId="2" ParentId="23926" CreationDate="2016-05-06T13:44:23.577" Score="7" Body="&lt;p&gt;Yes you can have arrays inside arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The array would be declared as:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int arrayName [ x ][ y ];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;x&lt;/code&gt; is the number of rows and &lt;code&gt;y&lt;/code&gt; is the number of columns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The example below declares and initializes a 2D array with 3 rows and 10 columns:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myArray[3][10] = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },&#xA;                       { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 },&#xA;                       { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 } };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To access the value of 27 (and save it into myValue):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myValue = myArray[2][6];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:57:18.810" LastActivityDate="2018-12-13T12:57:18.810" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="23943" PostTypeId="1" CreationDate="2016-05-06T14:10:12.893" Score="1" ViewCount="423" Body="&lt;p&gt;Can anyone help me with this issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We created an arduino project. We listen microswitch.&#xA;If switch click, Arduino send basic serial data.&#xA;And C# application read serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution is working but after more times (3Hours, 5Hours,..) system stoped.&#xA;Error message is &quot;a device attached to the system is not functioning&quot;&#xA;Solution: Usb remove and retry plug system is going to running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are try putty.exe maybe problem C# project but don't working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If microswitch click don't flash &quot;TX&quot; or &quot;RX&quot; led.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int button = 3;&#xA;&#xA;uint64_t bounceTime = 50;&#xA;uint64_t holdTime = 250;&#xA;uint64_t doubleTime = 500;&#xA;&#xA;uint64_t lastReading = LOW;&#xA;uint64_t hold = 0;&#xA;uint64_t single = 0;&#xA;&#xA;uint64_t onTime = 0;&#xA;uint64_t lastSwitchTime = 0;&#xA;&#xA;&#xA;void setup() {&#xA; pinMode(button, INPUT_PULLUP);&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA; int reading = digitalRead(button);&#xA;&#xA; if (reading == HIGH &amp;amp;&amp;amp; lastReading == LOW) {&#xA;   onTime = millis();&#xA; }&#xA;&#xA; if (reading == HIGH &amp;amp;&amp;amp; lastReading == HIGH) {&#xA;   if ((millis() - onTime) &amp;gt; holdTime) {  &#xA;     hold = 1;&#xA;   }&#xA; }&#xA;&#xA; if (reading == LOW &amp;amp;&amp;amp; lastReading == HIGH) {&#xA;   if (((millis() - onTime) &amp;gt; bounceTime) &amp;amp;&amp;amp; hold != 1) {&#xA;     onRelease();&#xA;   }&#xA;   if (hold == 1) {&#xA;      delay(5000);&#xA;      reading = digitalRead(button);&#xA;      if(reading==LOW){&#xA;              Serial.println(&quot;B&quot;);&#xA;      }&#xA;     hold = 0;&#xA;   }  &#xA; }&#xA; lastReading = reading;&#xA;&#xA; if (single == 1 &amp;amp;&amp;amp; (millis() - lastSwitchTime) &amp;gt; doubleTime) {&#xA;   single = 0;&#xA; }&#xA;&#xA;}&#xA;&#xA;void onRelease() {&#xA; if ((millis() - lastSwitchTime) &amp;gt;= doubleTime) {&#xA;   single = 1;&#xA;   lastSwitchTime = millis();&#xA;   return;&#xA; }  &#xA;&#xA; if ((millis() - lastSwitchTime) &amp;lt; doubleTime) {&#xA;   single = 0;&#xA;   lastSwitchTime = millis();&#xA; }  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20847" LastActivityDate="2016-05-09T11:28:50.197" Title="System Is not Functioning Error. Windows XP, Arduino Uno R3, C# Listen SerialPort" Tags="|arduino-uno|serial|c#|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23945" PostTypeId="1" AcceptedAnswerId="23946" CreationDate="2016-05-06T16:48:47.637" Score="1" ViewCount="65" Body="&lt;p&gt;Is it possible to link multiple Arduino Megas using RS485, for example, and update the program on client Megas from one master Mega, as well as for them to communicate with each other? Whilst I found multiple examples of networks, nothing comes up for programming the boards other than through a PC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any pointers! &lt;/p&gt;&#xA;" OwnerUserId="20852" LastActivityDate="2016-05-06T17:31:11.987" Title="Networking multiple Arduino Megas and updating their programs from one master" Tags="|firmware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23946" PostTypeId="2" ParentId="23945" CreationDate="2016-05-06T17:31:11.987" Score="0" Body="&lt;p&gt;In principle, yes, you can do it. It's what existing bootloaders do -- they take code over the serial port, or USB, load it to flash, and then branch to it. Not to mention OTA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, you can modify the bootloader to use different pins, talk rs485, come up with code-integrity checks, specify particular bit patterns to signal &quot;reboot&quot; or &quot;now load new code&quot;, and so on. If you have enough flash, you can even keep two copies, a working and a new, like most OTA code does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not aware of a ready-made library that does that. If I wanted to roll my own, I would start by studying the OTA code.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-06T17:31:11.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23947" PostTypeId="2" ParentId="23943" CreationDate="2016-05-06T17:45:35.400" Score="1" Body="&lt;p&gt;I assume that by &quot;USB&quot; you mean &quot;USB-to-serial adaptor&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try running the same code without any serial communications, just have an LED do the equivalent of printing, and power it from a good power supply. If it runs for more than five hours, the problem is with the USB adaptor and/or your PC (Windows XP? Really?), and hence not relevant to this forum.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the code crashes, then maybe you have a marginal board, or there is some other environmental factor that's giving you trouble. The code looks OK on first glance.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-06T17:45:35.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23950" PostTypeId="1" CreationDate="2016-05-06T06:05:17.933" Score="0" ViewCount="1938" Body="&lt;p&gt;I made simple custom arduino board using an atmega328p and the PL2303 serial to USB chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my arduino program, I am in a loop that sends out a string continuously. I can read this in the Arduino serial monitor with a baudrate of 9600. However, in my python program using the pySerial library, the readline function doesn't return anything. I checked using PuTTY but it still doesn't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I tried messing with the serial settings and found out that these lines of code work (the readline returns the string) if I call it in the exact same order.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;ser = serial.Serial(comm_port)&#xA;ser.xonxoff = True&#xA;ser.rtscts = True&#xA;ser.dsrdtr = True&#xA;ser.readline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, the code below doesn't work&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;ser = serial.Serial(comm_port, xonxoff=True, rtscts=True, dsrdtr=True)&#xA;ser.readline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could be causing this? My guess is somehow I've switched the datalines in my USB cable and that the arduino serial monitor handles this somehow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer.&lt;/p&gt;&#xA;" OwnerUserId="4958" OwnerDisplayName="Charles V." LastEditorUserId="37523" LastEditDate="2019-09-04T14:47:25.420" LastActivityDate="2023-12-18T23:40:43.100" Title="Arduino Serial Monitor works but not on PySerial and PuTTY" Tags="|serial|python|" AnswerCount="2" CommentCount="0" ClosedDate="2023-12-19T06:18:42.503" ContentLicense="CC BY-SA 4.0" />
  <row Id="23951" PostTypeId="2" ParentId="23920" CreationDate="2016-05-06T22:25:55.793" Score="0" Body="&lt;p&gt;@Rich1234&#xA;I have taken your code, JFPoilpret's, Holmez's and my answers and put them altogether.  Hopefully this explains what we mean and will give you something to work from.  It does compile, but I don't know if it works, because I don't have two sensors to try it with.  The code is by no means perfect, but its a start.  If there are any problems, give us a shout.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* FSR simple testing sketch. &#xA; Connect one end of FSR to power, the other end to Analog 0.&#xA; Then connect one end of a 10K resistor from Analog 0 to ground &#xA; For more information see www.ladyada.net/learn/sensors/fsr.html */&#xA;&#xA;const int fsrPin = A0;      // Change to A0 so it refers to the correct pin&#xA;const int fsr2Pin = A1;     // Change to A0 so it refers to the correct pin&#xA;// int fsrReading ;     // Change Not required&#xA;// int fsr2Reading;     // Change Not required&#xA;&#xA;// Function     : Read the data from the pin and write a meaningful description to the serial output.&#xA;// Parameters   : The analog pin to read from.&#xA;// Returns      : The value read from the pin&#xA;int checkReading(int pin)&#xA;{&#xA;    const int reading = analogRead (pin);       // Get the reading from the pin. (const because it won't change within the scope (life) of this function)&#xA;    Serial.print(reading);&#xA;    Serial.print(&quot; - &quot;);&#xA;    if (reading &amp;lt; 10) {&#xA;        Serial.println(&quot;Nothing&quot;);&#xA;    } else if (reading &amp;lt; 200) {&#xA;        Serial.println(&quot;Light&quot;);&#xA;    } else if (reading &amp;lt; 500) {&#xA;        Serial.println(&quot;Lightness&quot;);&#xA;    } else if (reading &amp;lt; 800) {&#xA;        Serial.println(&quot;Medium&quot;);&#xA;    } else {&#xA;        Serial.println(&quot;Big-squeeze&quot;);&#xA;    }&#xA;    return reading;&#xA;}&#xA;&#xA;void setup(void) {&#xA;    // We'll send debugging information via the Serial monitor&#xA;    Serial.begin(9600);   &#xA;    pinMode(fsrPin, INPUT);     // Change to define the pin 'direction'&#xA;    pinMode(fsr2Pin, INPUT);&#xA;}&#xA;&#xA;void loop(void) {&#xA;&#xA;    Serial.print(&quot;Analog reading A0 = &quot;);&#xA;    checkReading(fsrPin);&#xA;    Serial.print(&quot;Analog reading A1 = &quot;);&#xA;    checkReading(fsr2Pin);&#xA;&#xA;    delay(1000);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-06T22:25:55.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23952" PostTypeId="2" ParentId="23874" CreationDate="2016-05-07T00:08:19.463" Score="0" Body="&lt;p&gt;Your algorithm is the probably the problem. Use this entry &lt;code&gt;case&lt;/code&gt; instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case CrossingZoneState::CROSSINGZONE_READENTRYRFID:&#xA;&#xA;    entryTag = IndentifyTag(entryRFIDReader);&#xA;    if (!entryTag) {   // zero is usually returned if no card is detected&#xA;        readCount += 1;   // seems u want to count number of reads&#xA;&#xA;        if (entryTag != priorTag) {&#xA;            entryTagCount += 1;&#xA;            priorTag = entryTag;  // update priorTag&#xA;        }&#xA;        timeElapsedBetweenCardReads = 0;   /// reset the counter when u read ANY tag; negate the effects of reading a card more than once&#xA;&#xA;    }&#xA;    // only check timeout if you didnt read ANY tag at all&#xA;    else if (timeElapsedBetweenCardReads &amp;gt;= readerInactiveInterval){&#xA;        //change state now that entry rfid tag reader is finished&#xA;        state = CrossingZoneState::CROSSINGZONE_OCCUPIED;&#xA;    }&#xA;&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something similar for the exit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case CrossingZoneState::CROSSINGZONE_READEXITRFID:&#xA;    exitTag = IndentifyTag(entryRFIDReader);&#xA;    if (!exitTag) {   // zero is usually returned if no card is detected&#xA;        readCount += 1;   // remember this variable is shared with the other case&#xA;&#xA;        if (exitTag != priorTag) {&#xA;            exitTagCount += 1;&#xA;            priorTag = exitTag;  // update priorTag&#xA;        }&#xA;        timeElapsedBetweenCardReads = 0;&#xA;&#xA;    }&#xA;    else if ((timeElapsedBetweenCardReads &amp;gt;= readerInactiveInterval) &amp;amp;&amp;amp;&#xA;             (entryTagCount == exitTagCount) &amp;amp;&amp;amp; (entryTag == exitTag)){&#xA;        //change state now that entry rfid tag reader is finished&#xA;        state = CrossingZoneState::CROSSINGZONE_DEACTIVATEGATES;&#xA;    }&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the OCCUPIED case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case CrossingZoneState::CROSSINGZONE_OCCUPIED:&#xA;    // only thing we do here is monitor the zone exit sensor&#xA;    if (digitalRead(exitSensorPin) == HIGH) {           &#xA;        state = CrossingZoneState::CROSSINGZONE_READEXITRFID;&#xA;        timeElapsedBetweenCardReads = 0;   // reset the counter to prepare for exit case&#xA;        priorTag = 0;  // just in case&#xA;    }&#xA;    break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-05-07T00:08:19.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23954" PostTypeId="1" AcceptedAnswerId="23959" CreationDate="2016-05-07T00:32:59.567" Score="1" ViewCount="3333" Body="&lt;p&gt;I wan't to send information from my arduino digital pins to another arduino's digital pins like a string, or a char. Can I do this without something like Software Serial?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am asking is because I am wanting to send information from several serial devices to my raspberry pi from an arduino. Thing is, that Raspberry pi only has one set of UART pins, so I was thinking because I have extra arduino uno's, why not send then information to the arduino and have it write the received information to the raspberry pi's digital pins..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now that I am writing this, I think I will connect the 2 arduinos via a serial connection, and use software serial to write out to the raspberry pi, in three different stages, to get the information to the pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I am using the PI is I want to display this information on a large screen with many different options, in short the GPU capabilities are what I am using the PI for, that and Processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question still stands though, can you send information over digital pins?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="20429" LastEditorUserId="20429" LastEditDate="2016-05-07T01:06:42.027" LastActivityDate="2018-12-13T12:59:08.823" Title="Send information (such as a string) over digital pins" Tags="|arduino-uno|serial|digital|processing-lang|raspberrypi|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23955" PostTypeId="2" ParentId="23916" CreationDate="2016-05-07T00:53:12.710" Score="1" Body="&lt;p&gt;You may have noticed that this product is no longer available from well known parts distributors like adafruit.com, sparkfun.com or trossenrobotics.com. I would recommend using a Sharp distance sensor designed for the distances you are interested in:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/hZaWg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hZaWg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;It is about 10 times the price, but produces a variable voltage that you can read with the Arduino's ADC.  Then you can compensate for floor irregularities in your code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you care to experiment, I obsurved that the better distance measurement devices angle the emitter and sensor to light up &amp;amp; observe the same spot at the desired operating distance:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/AOunj.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AOunj.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try this with your current sensor.  However, it does not appear the manufacture left you enough lead length to make such an adjustment.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-07T00:53:12.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="23956" PostTypeId="2" ParentId="23954" CreationDate="2016-05-07T00:57:51.563" Score="2" Body="&lt;p&gt;The RaspberryPi is a fairly complete linux computer.  As such it can be a USB Host to many USB Devices.  If you need more serial ports simply buy &lt;a href=&quot;https://www.adafruit.com/products/954&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTDI equipped USB to serial cables&lt;/a&gt;, plug them into a USB hub and plug that into the RaspberryPi.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ykCtt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ykCtt.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-07T01:03:00.667" LastActivityDate="2016-05-07T01:03:00.667" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="23957" PostTypeId="2" ParentId="23954" CreationDate="2016-05-07T01:23:52.573" Score="2" Body="&lt;p&gt;There are many different ways of communicating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition to serial you can use a protocol like SPI or I²C. If the Arduino are in close proximity I²C enables many devices to communicate on a common bus.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-05-07T01:23:52.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23958" PostTypeId="1" CreationDate="2016-05-07T02:23:33.863" Score="0" ViewCount="47" Body="&lt;p&gt;I was powering a GPS Sensor from the 3v3 pin of a raspberry pi and my reading for my GPS sensor had some strange symbols in the mix, but when i switched to the 3v3 on the arduino, my reading came back to normal. This wasted several hours of my time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any idea why i would get weird readings when using a different power source?? (even though it is the same voltage)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Both the raspberry pi and the arduino are getting their power form the USB that is connected to my PC.&lt;/p&gt;&#xA;" OwnerUserId="20429" LastActivityDate="2016-05-07T04:55:23.093" Title="Power supply change change gps readings?" Tags="|arduino-uno|serial|power|softwareserial|raspberrypi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23959" PostTypeId="2" ParentId="23954" CreationDate="2016-05-07T02:59:57.823" Score="1" Body="&lt;p&gt;Yes, you can send information to/from your arduino digital pins using a method called Bit Banging. &lt;a href=&quot;https://en.wikipedia.org/wiki/Bit_banging&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt; (lots more on Google!)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use the Arduino to output as an ad hoc serial port or parallel port. The serial could be asynchronous (UART/RS232/I2C) or synchronous (such as SPI). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The down side is you will have to write a fair bit more software to send/interpret the data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From your description I gather that data is only going one way - from the Arduino to the Pi. I personally would bit bang SPI as I think this would be the easiest and would not require exact timing.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2018-12-13T12:59:08.823" LastActivityDate="2018-12-13T12:59:08.823" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="23960" PostTypeId="2" ParentId="23958" CreationDate="2016-05-07T04:55:23.093" Score="1" Body="&lt;p&gt;The Pi can only supply ~50mA from 3.3V. This is unlikely to be enough to run GPS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In addition USB can only supply 500mA. This is marginal at best, and below the recommended minimum for Pi.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-05-07T04:55:23.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23961" PostTypeId="1" CreationDate="2016-05-07T06:32:05.097" Score="0" ViewCount="425" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3ieoc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3ieoc.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino UNO Board keeps the LED light turned on forever whenever I connect it to my PC. And, when I try to upload even a sample sketch, it says &lt;code&gt;avrdude: stk500_recv(): programmer is not responding&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I fix this error?&lt;/p&gt;&#xA;" OwnerUserId="20151" LastEditorUserId="19515" LastEditDate="2016-05-07T18:31:27.053" LastActivityDate="2021-12-18T01:04:55.297" Title="My Arduino UNO turns LED ON forever when I connect it to my Laptop" Tags="|arduino-uno|atmega328|avrdude|atmega16u2|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="23962" PostTypeId="1" CreationDate="2016-05-07T10:51:37.210" Score="0" ViewCount="5015" Body="&lt;p&gt;I have written a simple code to read data from capacitive keypad and display it on LCD.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am getting the data from keypad in following data structure.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char phoneNumber[PHONE_DIGITS];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then displaying the data on LCD as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   LcdString(phoneNumber[i]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where my LCD string function is &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void LcdString(char *characters)&#xA;{&#xA;  while (*characters)&#xA;  {&#xA;    LcdCharacter(*characters++);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is a type cast error &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: invalid conversion from 'char' to 'char*' [-fpermissive]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How can I debug it?&lt;/p&gt;&#xA;" OwnerDisplayName="user20865" LastActivityDate="2016-05-07T12:11:19.960" Title="error: invalid conversion from 'char' to 'char*' [-fpermissive]" Tags="|data-type|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23963" PostTypeId="2" ParentId="23962" CreationDate="2016-05-07T12:05:11.787" Score="1" Body="&lt;p&gt;You're calling your function with a single char, specified by phoneNumber[i], but your function is expecting an array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you change your call to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LcdString(phonenumber)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then that will pass the entire array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you trying to say that you're storing multiple phone numbers?  i.e. a two dimensional array?  Check out the String reference for more details: &lt;a href=&quot;https://www.arduino.cc/en/Reference/String&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/String&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16487" LastEditorUserId="16487" LastEditDate="2016-05-07T12:11:19.960" LastActivityDate="2016-05-07T12:11:19.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23964" PostTypeId="1" AcceptedAnswerId="23969" CreationDate="2016-05-07T12:32:26.863" Score="0" ViewCount="2504" Body="&lt;p&gt;Is there any good way of sending values from two joysticks from arduino A to arduino B? I tried sending using if statements, so if the Y- or X-axis' value changed then it would send that, but the servo motor on Arduino B went a little bit crazy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I've done so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Master Code&#xA;void loop()&#xA;{&#xA;      yVal = analogRead(yAxis);   // read the value of the Right Joystick (value between 0 and 1023)&#xA;      yMap = map(yVal, 0, 1023, 0, 255);&#xA;      xVal = analogRead(xAxis);     // read the value of the left Joystick (value between 0 and 1023)&#xA;      xMap = map(xVal, 0, 1023, 0, 110);&#xA;&#xA;  if(Serial.available() &amp;amp;&amp;amp; !(xVal &amp;gt; 505 &amp;amp;&amp;amp; xVal &amp;lt; 510)){&#xA;      Serial.print('X');&#xA;      delay(10);&#xA;      Serial.write(xMap);&#xA;      }&#xA;  if(Serial.available() &amp;amp;&amp;amp; !(yVal &amp;gt; 500 &amp;amp;&amp;amp; yVal &amp;lt; 520)){&#xA;      Serial.print('Y');&#xA;      delay(10);&#xA;      Serial.write(yMap);&#xA;&#xA;    }&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the Slave code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Slave code&#xA;void loop(){&#xA;  while(Serial.available())&#xA;  {&#xA;    c = Serial.read();&#xA;    delay(5);&#xA;    val = Serial.read();&#xA;    if(c == 'X'){&#xA;        digitalWrite(13, LOW);&#xA;        myServo.write(val);&#xA;    }else if(c == 'Y'){&#xA;        digitalWrite(13, HIGH);&#xA;    }&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: I was thinking that maybe I should do something like a start and stop bit for X and Y?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit2: I wrote an if statement in Arduino B because it was reading the value -1, I don't know why, but after the if statement the servo motor hasn't been going crazy and the program works now. I still would like to know if I can do this in a better way. Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="20703" LastEditorUserId="20703" LastEditDate="2016-05-07T12:46:12.597" LastActivityDate="2016-05-07T13:47:26.960" Title="Bluetooth sending values from two joysticks" Tags="|arduino-uno|bluetooth|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23965" PostTypeId="2" ParentId="23961" CreationDate="2016-05-07T12:41:47.110" Score="1" Body="&lt;p&gt;When you connect the device, if you hear the Windows &quot;found device&quot; sound, then you need to check your COM port driver, as it's very likely that the COM port number may have changed. On your Desktop or in File Manager, right click &quot;This PC&quot; or &quot;My Computer&quot;, and select &quot;Manage&quot; from the submenu.  That will bring up the Computer Management console. On the left, select &quot;Device Manager&quot;.  That will bring up your list of devices. In the list look for &quot;Ports (COM &amp;amp; LPT)&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DedHz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DedHz.png&quot; alt=&quot;Device Manager - Ports&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't see, &quot;Ports&quot;, then click &quot;View&quot; and check &quot;Show hidden devices&quot;.  If this is the only Arduino that you've ever used, you should only see one listing. Make note of the COM Port Number the driver is using. &lt;em&gt;It's possible that the port number may have changed since you first used the device. Plug-n-play will do this if you plug the cable into a different USB port that may be using a different USB controller, etc.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in your Arduino IDE, click &quot;Tools&quot;, then expand &quot;Boards&quot; and select &quot;Arduino/Genuino UNO&quot; board, then re-click &quot;Tools&quot;, and hover over &quot;Port&quot;, and select the port number that is assigned to the Port that you found in Device Manager.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't work, then you may have a problem with your driver.  Some of the &quot;cheap chinese board&quot; use a different FTDI chipset, so the plug-n-play windows driver may not work. In that case, the manufacturer should point you to the correct driver. Download their provided driver, then you can update the driver in Device Manager. &lt;/p&gt;&#xA;" OwnerUserId="16487" LastActivityDate="2016-05-07T12:41:47.110" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23967" PostTypeId="1" CreationDate="2016-05-07T13:25:45.773" Score="0" ViewCount="1305" Body="&lt;p&gt;I’m trying to figure out how to extend the wires for both force sensitive resistors so that it could be place on each chair, one sensor on one chair and the other sensor on the other chair&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how this was originally connected &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cCTeD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cCTeD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what would be the best way to extend both cables to place both sensors on each chair&lt;/p&gt;&#xA;" OwnerUserId="19846" LastActivityDate="2016-05-07T14:21:47.223" Title="How do you extend the wires from the arduino board to both fsr sensors to be placed on both chairs (one for each)" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23968" PostTypeId="2" ParentId="23964" CreationDate="2016-05-07T13:28:44.920" Score="0" Body="&lt;p&gt;When using the ADC to control servos I get much better results when I process the ADC values through an &lt;a href=&quot;https://en.wikipedia.org/wiki/Exponential_smoothing&quot; rel=&quot;nofollow noreferrer&quot;&gt;exponential smoothing&lt;/a&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YsqRL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YsqRL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is less jitter.  However there is more lag.  You can tune the function by changing alpha between 1 (no history, effectively no smoothing at all) to 0 (no new data is averaged in, effectively not changing).  Pick 0.5 to start with.  If there is too much jitter pick smaller numbers until the jitter is reduced and the lag is still tolerable.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-07T13:28:44.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23969" PostTypeId="2" ParentId="23964" CreationDate="2016-05-07T13:47:26.960" Score="1" Body="&lt;h1&gt;Arduino A&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;You can read the values from two joysticks as normal and send it like this. This method ensures of no data loss. Ensure that you read the values and store them in appropriate variables and then send it over serial.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Setting Sensor pins&#xA;const int potPin = A0;&#xA;const int pot1Pin = A1;&#xA;&#xA;&#xA;&#xA;&#xA;// Creating variables&#xA;uint8_t pot;&#xA;uint8_t pot1;&#xA;&#xA;void setup() {&#xA;// Declearing the pinModes' for sensors&#xA;  pinMode(potPin, INPUT);&#xA;  pinMode(pot1Pin, INPUT);&#xA;// Begining Serial Communication&#xA;  Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;// reading from the sensors&#xA;  pot = map(analogRead(potPin),0 ,1023, 0, 255);&#xA;  pot1 = map(analogRead(pot1Pin),0 ,1023, 0, 255);  &#xA;&#xA;//Packing the Serial message&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;A&quot;);  //a token to indicate the message payload&#xA;  Serial.print(pot);&#xA;  Serial.println(&quot;&quot;);  &#xA;&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;B&quot;);  //a token to indicate the message payload&#xA;  Serial.print(pot1);&#xA;  Serial.println(&quot;&quot;);  &#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h1&gt;Arduino B&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;After the data are packed and sent over the serial. You need to unpack it with the other Arduino/device &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code will look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String data; //Store each line of Serial communication&#xA;String pot1String = &quot;0&quot;, pot2String = &quot;0&quot;;&#xA;float pot1, pot2;&#xA;void setup() &#xA;{&#xA;  //initialize Serial communication &#xA;  Serial.begin(9600);&#xA;  //read first package&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  {&#xA;    data = Serial.readStringUntil('\n');&#xA;  }&#xA;  //Disregard the first reading&#xA;  data = &quot;0&quot;;&#xA;}&#xA;&#xA;void loop() {&#xA;  //start reading from serial&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  {&#xA;    data = Serial.readStringUntil('\n');  &#xA;  }&#xA;  String payload = &quot;&quot;; &#xA;  if (data != &quot;0&quot;)&#xA;  {&#xA;    int offset = data.indexOf(&quot;U*&quot;); //This is the header (0x552A)&#xA;    if (offset &amp;gt;= 0)&#xA;    {&#xA;      payload = data.substring(offset + 3, data.indexOf('\n'));&#xA;      char value = data.charAt (offset + 2);&#xA;      switch (value)&#xA;      {&#xA;        case 'A':&#xA;          pot1String = payload;&#xA;          break;&#xA;        case 'B':&#xA;          pot2String = payload;&#xA;          break;&#xA;      //Add more case as the project grow&#xA;      }&#xA;    }&#xA;  }&#xA;  //convert strings to float&#xA;  pot1 = pot1String.toFloat();&#xA;  pot2 = pot2String.toFloat();&#xA;&#xA;// Continue with the rest of your project&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Make sure to use the same baud rate in both sketches&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hope this helped. Ask me if you have farther questions &lt;/p&gt;&#xA;" OwnerUserId="20821" LastActivityDate="2016-05-07T13:47:26.960" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="23970" PostTypeId="2" ParentId="23967" CreationDate="2016-05-07T13:50:27.477" Score="1" Body="&lt;p&gt;In ADC sampling there will always be noise.  Longer cables may increase that noise.  Sensors with lower resistance tend have less noise.  For these reasons it would be better to start from a schematic, part numbers and / or specifications rather than a picture.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of ways to reduce noise.  Hardware solutions include twisted pair and shielded cables.  Software solutions include averaging multiple samples and removing outliers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all you are asking is if you can use longer cables, the answer is yes as long as you can tolerate the or compensate for additional noise if any.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-07T13:50:27.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23971" PostTypeId="2" ParentId="23967" CreationDate="2016-05-07T14:16:06.917" Score="1" Body="&lt;p&gt;In order to extend the wires you will need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://core-electronics.com.au/0-1-2-54mm-crimp-connector-housing-1x1-pin-25-pack.html&quot; rel=&quot;nofollow&quot;&gt;Crimp Connector Housing&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://core-electronics.com.au/female-crimp-pins-for-0-1-housings-100-pack.html&quot; rel=&quot;nofollow&quot;&gt;Female Crimp Pins&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://core-electronics.com.au/male-crimp-pins-for-0-1-housings-100-pack.html&quot; rel=&quot;nofollow&quot;&gt;Male Crimp Pins &lt;/a&gt; &lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://core-electronics.com.au/stranded-wire-red-30-awg-100-feet.html&quot; rel=&quot;nofollow&quot;&gt;Stranded Wire: 30 AWG&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and if you want to do a better job than bread board then you can use a &lt;a href=&quot;http://www.ebay.com.au/itm/5Pcs-Double-Side-5x7cm-Printed-Circuit-PCB-Vero-Prototyping-Track-Strip-Board-SY-/252324587520?hash=item3abfb7a800:g:9EIAAOSwHgVW7ENM&quot; rel=&quot;nofollow&quot;&gt;Strip board&lt;/a&gt; to solder your resistors on and some &lt;a href=&quot;http://core-electronics.com.au/10-pcs-40-pin-headers-straight.html&quot; rel=&quot;nofollow&quot;&gt;headers&lt;/a&gt; to connect your wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should not get any noise in ideal situation. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know where you from so I just posted the links to the store I usually buy from. you can find these items on ebay or similar. Plus you will need a &lt;a href=&quot;http://core-electronics.com.au/crimping-tool-0-08-0-5-mm-capacity-20-28-awg.html&quot; rel=&quot;nofollow&quot;&gt;crimping tool&lt;/a&gt; as well.&lt;/p&gt;&#xA;" OwnerUserId="20821" LastEditorUserId="20821" LastEditDate="2016-05-07T14:21:47.223" LastActivityDate="2016-05-07T14:21:47.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23975" PostTypeId="1" AcceptedAnswerId="26103" CreationDate="2016-05-07T17:16:48.250" Score="2" ViewCount="1069" Body="&lt;p&gt;I have Arduino MEGA and I'm connecting to it 5 servomotors.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{ 3 TowerPro M995 &#xA;Basic Information&#xA;&#xA;Modulation:  Digital  &#xA;Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)&#xA;6.0V: 152.8 oz-in (11.00 kg-cm)&#xA;&#xA;Speed:  4.8V: 0.20 sec/60°&#xA;6.0V: 0.16 sec/60°&#xA;&#xA;Weight:  1.94 oz (55.0 g)  &#xA;Dimensions:  &#xA;Length:&#xA;1.60 in (40.7 mm)&#xA;&#xA;Width:&#xA;0.78 in (19.7 mm)&#xA;&#xA;Height:&#xA;1.69 in (42.9 mm)  &#xA;Motor Type:  3-pole  &#xA;Gear Type:  Metal  &#xA;&#xA;&#xA;2 Towerpro M996R &#xA;&#xA;Basic Information&#xA;&#xA;Modulation:  Digital  &#xA;Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)&#xA;6.0V: 152.8 oz-in (11.00 kg-cm)&#xA;&#xA;Speed:  4.8V: 0.19 sec/60°&#xA;6.0V: 0.15 sec/60°&#xA;&#xA;Weight:  1.94 oz (55.0 g)  &#xA;Dimensions:  &#xA;Length:&#xA;1.60 in (40.7 mm)&#xA;&#xA;Width:&#xA;0.78 in (19.7 mm)&#xA;&#xA;Height:&#xA;1.69 in (42.9 mm)  &#xA;Motor Type:  3-pole  &#xA;&#xA;&#xA;&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how can I calculate the voltage and current needed to supply this Arduino?&lt;/p&gt;&#xA;" OwnerUserId="19654" LastEditorUserId="10794" LastEditDate="2016-06-06T23:51:33.157" LastActivityDate="2016-07-08T02:23:35.953" Title="How to calculate the needed voltage and current to supply for Arduino" Tags="|arduino-mega|hardware|battery|electronics|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23976" PostTypeId="2" ParentId="23975" CreationDate="2016-05-07T17:21:20.303" Score="2" Body="&lt;p&gt;Voltage is simple - a device has a requirement and that is what you have to provide. In the case of the servos that is a range of voltages that it can use. So 5V is a good voltage.  The Arduino can take 5V if you feed it in to the 5V pin or the USB port, or 7-12V if you feed it in to the barrel jack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current you cannot calculate. You haven't provided enough information. The calculation, when you have the information, is quite simple: for all the devices on the same power supply add the currents requirements together. The supply has to be able to provide &lt;em&gt;at least&lt;/em&gt; that amount of current.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-07T17:21:20.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23978" PostTypeId="2" ParentId="23878" CreationDate="2016-05-07T18:20:07.127" Score="4" Body="&lt;p&gt;You mention two different error messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1. AT+HTTPINIT fail&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You get +CME ERROR 3. Which means &quot;operation not allowed&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be due to an improperly closed HTTP setup.&#xA;If you get this error (or just always do before setting up), call &lt;code&gt;AT+HTTPTERM&lt;/code&gt; to be sure that it's closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2. AT+HTTPACTION=1&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice you're trying to do a &lt;code&gt;POST&lt;/code&gt;message, while your variables are in the URL (which is &lt;code&gt;GET&lt;/code&gt; style afaik).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've found a source that states you need to call &lt;code&gt;AT+HTTPDATA&lt;/code&gt; with apropriate values.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Tell the module that you will be sending 192 bytes of data and it can timeout after 10 seconds of inactivity. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;After that, the device will say &lt;code&gt;DOWNLOAD&lt;/code&gt;, and you can send the &lt;code&gt;POST&lt;/code&gt; body.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;After this command you get the DOWNLOAD URC then you can type in 192 bytes of data within 10 seconds. The typed data is filled in a local buffer of the module and is not yet posted to the server. In the post body is the multi part form data which contains the necessary headers and data to post a file with name data.txt with 10 bytes of data.&#xA;  &lt;code&gt;AT+HTTPDATA=192,10000&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And after that you can send the &lt;code&gt;POST&lt;/code&gt; message.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Execute the HTTP POST command so that the buffer contents are POST to&#xA;  the server &lt;code&gt;AT+HTTPACTION=1 OK&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You will get a return message that states the HTTP code (200 'OK') and the amount of bytes received in the return message.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;+HTTPACTION:1,200,141&lt;/code&gt;&#xA;  This URC means that the data was successfully posted to the server and received 141 bytes of data.&#xA;  which is the server response to your HTTP POST&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;code&gt;AT+HTTPREAD&lt;/code&gt; to receive these bytes.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The below command tells the module that we want to read the received data AT+HTTPREAD The below is the data&#xA;  received from the server&#xA;  +HTTPREAD:141 Successfully dumped 0 post variables. View it at &lt;a href=&quot;http://www.posttestserver.com/data/2015/10/07/07.41.291690063480&quot; rel=&quot;nofollow&quot;&gt;http://www.posttestserver.com/data/2015/10/07/07.41.291690063480&lt;/a&gt; Post&#xA;  body was 0 chars long. OK&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Scroll a fair bit down in the source, the first part is on &lt;code&gt;HTTP GET&lt;/code&gt;: &lt;a href=&quot;http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands&quot; rel=&quot;nofollow&quot;&gt;http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also omit this by using &lt;code&gt;HTTP GET&lt;/code&gt; since it's somewhat easier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all else fails, you can set up a &lt;code&gt;TCP IP&lt;/code&gt; connection with the GSM module and manually set up the HTTP GET/POST message.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-07T18:20:07.127" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="23979" PostTypeId="2" ParentId="23918" CreationDate="2016-05-07T19:44:53.157" Score="0" Body="&lt;p&gt;Adding to the reasons why it's a bad idea to define that macro:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to keep your code readable, inventing syntactic sugar and implementing it with macros is the wrong way of going about it. If the language designers did not do provide a construct, there is probably a reason. This is particularly true if you are not a complete master of the language.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Premature optimization is &lt;em&gt;always&lt;/em&gt; a bad idea. First, modern compilers are very good about optimizing stuff. Second, unless you have measured the performance of your code in great detail and deemed the performance unacceptable, you are wasting effort and making the code harder to maintain. Third, what you &lt;em&gt;think&lt;/em&gt; may be an optimization may result in worse code in a future version of the compiler, or in a different hardware architecture. The list goes on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Never use preprocessor macros unless there is no other way of doing what you want to do (there usually is). There are countless articles detailing why you should not, but here is a short summary: macros pollute the global namespace, are hard to test and thus hard to debug, have no type checking, introduce subtle (and not-so-subtle) bugs, obscure calling semantics, and generally make the code unreadable. That we are having this discussion here is proof enough :)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In this particular example, you are relying on the fact that the array &lt;code&gt;example[]&lt;/code&gt; is &lt;em&gt;defined&lt;/em&gt; (meaning: declared and storage is allocated, and in this case initialized, for it) in the same translation unit as your macro. Had this not been the case, &lt;code&gt;sizeof&lt;/code&gt; would not have worked &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you want to inline code, use inline functions. If you want to define constants, use &lt;code&gt;const&lt;/code&gt;. And so on.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In your case, you are far better off declaring your arrays as &lt;code&gt;vector&amp;lt;int&amp;gt;&lt;/code&gt; and using either iterators or the &lt;em&gt;range for&lt;/em&gt; in combination with &lt;em&gt;auto&lt;/em&gt; type declarations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;vector&amp;gt;&#xA;std::vector&amp;lt;std::vector&amp;lt;int&amp;gt;&amp;gt; example = {&#xA;  {3, 1, 4, 1, 6},&#xA;  {2, 7, 1, 8, 2, 8, 1, 8},&#xA;  {5, 7, 7, 2}};&#xA;&#xA;...&#xA;&#xA;  for (auto v: example) {&#xA;    for (auto i: v) {&#xA;      // do something with i&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Isn't this a lot more readable than your foreach macro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Needless to say, you need to make sure that your tool chain supports C++11; the 1.6.7 version of the Arduino IDE running on Linux definitely does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously, there are occasional reasons to break the rules I mentioned above, but until you know &lt;em&gt;exactly&lt;/em&gt; what you are doing, it's better not to.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastEditorUserId="10024" LastEditDate="2016-05-07T20:56:35.960" LastActivityDate="2016-05-07T20:56:35.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23982" PostTypeId="1" AcceptedAnswerId="23997" CreationDate="2016-05-08T00:01:50.407" Score="1" ViewCount="79" Body="&lt;p&gt;I have an Uno + WiFi 101 thermometer and I'd like to be able to take it places and easily change WiFi network SSIDs and passwords.  Can I use a TFT screen to make these changes to a sktech or am I stuck using a PC and IDE for this kind of thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone provide a sample sketch of what this might look like?  I want to know it's something that's possible before I spend the money on a TFT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible (let's face it, LIKELY) that I fundamentally misunderstand the capabilities and limitations of the TFT screen.  Sorry for the noobish question.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-05-08T07:24:27.073" Title="TFT screen to change sketches" Tags="|arduino-uno|wifi|tft|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="23984" PostTypeId="2" ParentId="20181" CreationDate="2016-05-08T00:56:53.140" Score="1" Body="&lt;p&gt;If fixed this by deleting this built-in library&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/libraries/SD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but then I received the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/libraries/Robot_Control/ArduinoRobot.cpp:25:2: error: 'Serial1' was not declared in this scope&#xA;  Serial1.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I deleted these libraries as well:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/libraries/Robot_Control&#xA;/usr/share/arduino/libraries/Robot_Motor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which appear to be buggy in the 1.6 Arduino release. It's still unclear why any of these libraries were being used, since I wasn't including any of their files.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-05-08T00:56:53.140" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23987" PostTypeId="1" CreationDate="2016-05-08T02:42:44.523" Score="-1" ViewCount="1629" Body="&lt;p&gt;How do you program an Arduino Uno to request data over I2C, sending parameters defining the request?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to program Arduino A to read a sensor value from another Arduino B, and it first needs to tell B which sensor to report, but I can't find any easy way to do this with Arduino's Wire library. There doesn't seem to be anything like &lt;code&gt;Wire.requestFrom(addr, 1235, 2)&lt;/code&gt; which would then call a handler on the slave the looks like &lt;code&gt;onRequest(sensor_id)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterWriter&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; on how to push data one way to a slave, and I found &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterReader&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; on how to request data from a slave without specifying any input, but I can't find anything in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the solution to use the first method to set the parameters, and then the second to get the data? If so, that seems very circuitous. Is there a more direct method?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-06-07T04:16:27.687" Title="How to request data via I2C?" Tags="|i2c|wire-library|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23988" PostTypeId="1" AcceptedAnswerId="24001" CreationDate="2016-05-08T03:31:31.727" Score="1" ViewCount="869" Body="&lt;p&gt;I am considering purchasing these ATmega328 s from &#xA;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B018ZR3F7O&quot; rel=&quot;nofollow&quot;&gt;3 pack ATmega328P&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The company says they come with the Arduino UNO bootloader.&#xA;I do NOT have any 16 MHz crystals, and I would like to make the chips run on the 8 MHz internal crystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Duemilanove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to burn the minimal setup bootloader &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;from here&lt;/a&gt; onto the bootloaded chips without using a crystal?&lt;/p&gt;&#xA;" OwnerUserId="20883" LastActivityDate="2016-05-08T09:37:43.017" Title="Burn new bootloader without crystal" Tags="|bootloader|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="23990" PostTypeId="2" ParentId="23987" CreationDate="2016-05-08T03:53:36.410" Score="0" Body="&lt;p&gt;Its the way the protocol is designed. From the very first byte that is sent, you already indicate if you want to read or write data. You can't do both. The protocol is a lot more straightforward this way, one transaction at a time. Plus it gives the feel of a data frame, with START and STOP bits delimiting the frame (not regarding repeated STARTs).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But even for a full-duplex protocol like SPI, you've already said that the master must first send certain parameters to the slave. Nothing can be sent by the slave until it has received these parameters and processed them, full-duplex comms or not. Only after this, can it reply with the requested data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Wire methods are designed to send data in one direction at a time, as it should be. You could, of course, create a function like the one in your question, but it would inevitably involve the same process of first writing to the slave and then reading.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-05-08T04:00:38.803" LastActivityDate="2016-05-08T04:00:38.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23993" PostTypeId="1" CreationDate="2016-05-08T05:33:46.760" Score="0" ViewCount="2703" Body="&lt;p&gt;I have an issuing multiplying two one dimension arrays together. Each array is an unsigned long that is storing values of factorials. The last row is completely off. My code is below also with a screenshot of the output. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;//----------------------------- start serial monitor&#xA;Serial.begin(9600);&#xA;&#xA;Serial.println(&quot;Factorial Table&quot;);&#xA;//----------------------------- declare variables&#xA;unsigned long fact = 1;&#xA;unsigned long r[5];&#xA;unsigned long c[5];&#xA;unsigned long product[6][6];&#xA;//----------------------------- load facotirals into array(s)&#xA;for (unsigned long d = 1; d &amp;lt;= 5; d++)&#xA;{&#xA;    fact = fact * d;&#xA;    r[d] = fact;&#xA;    c[d] = fact;&#xA;}&#xA;//----------------------------- multiply factorials &#xA;//                              and load into new array&#xA;&#xA;for (int row = 1; row &amp;lt;= 5; row++)&#xA;{&#xA;    for (int col = 1; col &amp;lt;= 5; col++)&#xA;    {&#xA;        product[row][col] = r[row] * c[col];&#xA;    }&#xA;}&#xA;&#xA;//----------------------------- print factorials&#xA;&#xA;for (int prow = 1; prow &amp;lt;= 5; prow++)&#xA;{&#xA;    for (int pcol = 1; pcol &amp;lt;= 5; pcol++)&#xA;    {&#xA;        Serial.print(product[prow][pcol]);&#xA;        Serial.print(&quot; &quot;);&#xA;    }&#xA;&#xA;    Serial.println(&quot; &quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i667.photobucket.com/albums/vv38/Michael_Niebauer/output_zpsekxefuuw.jpg&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.530" LastActivityDate="2016-05-08T06:39:44.940" Title="Multiplying Arrays" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23995" PostTypeId="2" ParentId="23993" CreationDate="2016-05-08T06:39:44.940" Score="4" Body="&lt;p&gt;In C and its progeny, array indices start at 0. &lt;code&gt;unsigned long r[5]&lt;/code&gt; declares an array of five longs; the array elements are &lt;code&gt;r[0]&lt;/code&gt; through &lt;code&gt;r[4]&lt;/code&gt;. Your loop, however, varies the array index from 1 though 5. &lt;code&gt;r[5]&lt;/code&gt; is accessing whatever happens to lie in memory beyond &lt;code&gt;r[4]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a much better version of your code. Note, among other things, the coding style. Remember that you write programs for other &lt;em&gt;humans&lt;/em&gt; to read!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int kSize = 5;&#xA;void setup() {&#xA;  unsigned long r[kSize];&#xA;  unsigned long product[kSize][kSize];&#xA;  unsigned long fact = 1;&#xA;  for (int d = 0; d &amp;lt; 5; ++d) {&#xA;    fact *= d + 1;&#xA;    r[d] = fact;&#xA;  }&#xA;  for (int row = 0; row &amp;lt; 5; ++row) {&#xA;    for (int col = 0; col &amp;lt; 5; ++col) {&#xA;      product[row][col] = r[row] * r[col];&#xA;    }&#xA;  }&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Factorial Table&quot;);&#xA;  for (int row = 0; row &amp;lt; 5; ++row) {&#xA;    for (int col = 0; col &amp;lt; 5; ++col) {&#xA;      Serial.print(product[row][col]);&#xA;    }&#xA;    Serial.println();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See the difference? Style points to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;no unnecessary comments. In fact, the code is readable enough that no comments are necessary.&lt;/li&gt;&#xA;&lt;li&gt;No unnecessary space.&lt;/li&gt;&#xA;&lt;li&gt;The array size is used in several places; it's better to define it as a constant. There is also no reason to specify anything other than &lt;code&gt;int&lt;/code&gt;; a good optimizer will detect that you are never using values of more than 5, and will optimize the code accordingly.&lt;/li&gt;&#xA;&lt;li&gt;You don't really need two separate arrays, since they have the same values.&lt;/li&gt;&#xA;&lt;li&gt;You obviously don't need to first store and then print, but I assume you are doing this to learn.&lt;/li&gt;&#xA;&lt;li&gt;I didn't initialize the Serial port and didn't print the header until i was ready to print. Group logically-related statements together. (OTOH, you might have been thinking that at some point you might want to insert print statements before there, so putting Serial.begin first thing in your code might have been better.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;While there are lots of styles around, &lt;a href=&quot;https://google.github.io/styleguide/cppguide.html&quot; rel=&quot;nofollow&quot;&gt;https://google.github.io/styleguide/cppguide.html&lt;/a&gt; is good enough for Google, so it's good enough for me :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a better way to initialize the array of factorials:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  r[0] = 1;&#xA;  for (int d = 1; d &amp;lt; kSize; ++d) {&#xA;    r[d] = r[d - 1] * (d + 1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-08T06:39:44.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23996" PostTypeId="1" AcceptedAnswerId="23999" CreationDate="2016-05-08T07:24:07.567" Score="4" ViewCount="9499" Body="&lt;p&gt;Has anyone tried these? Does the ATtiny have a bootloader? What software is used to program the chip? Arduino compatible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks a lot more convenient than programming the ATtiny via an Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://m.ebay.com/itm/201536595756&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://m.ebay.com/itm/201536595756&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;/Ola&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tyPdr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tyPdr.png&quot; alt=&quot;Image of the product in hand&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8013" LastEditorUserId="4628" LastEditDate="2017-05-28T13:53:39.913" LastActivityDate="2020-12-23T12:23:59.133" Title="EBay &quot;Development Programmer Board for ATtiny&quot;" Tags="|attiny|programmer|" AnswerCount="6" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="23997" PostTypeId="2" ParentId="23982" CreationDate="2016-05-08T07:24:27.073" Score="1" Body="&lt;p&gt;A TFT screen is just a screen. You can't modify SSIDs and passwords with it, any more than you can by poking your PC monitor (unless perhaps you have a touch-screen*). To modify things you would need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An input device (eg. a keypad)&lt;/li&gt;&#xA;&lt;li&gt;A method of displaying what you are entering (this is where the screen would be handy)&lt;/li&gt;&#xA;&lt;li&gt;A method of storing the new information. You could store things like passwords in EEPROM.&lt;/li&gt;&#xA;&lt;li&gt;Code to make all that work.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;* Some distributors sell touch-screen interfaces designed to go on top of screens - this might conceivably be what you are thinking of. However you still need the touch-screen, and code to make the touch-screen, &lt;strong&gt;and&lt;/strong&gt; the TFT screen, work.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-08T07:24:27.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="23999" PostTypeId="2" ParentId="23996" CreationDate="2016-05-08T07:37:02.737" Score="4" Body="&lt;p&gt;If you don't have experience working with AVRs at a low level then stay away from that. It doesn't provide any connection for a programmer and relies on the Micronucleus bootloader already being in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want to experiment with ATtiny development then go with either an Adafruit Trinket or a Digistump Digispark (both of which already have Micronucleus loaded), or get an AVR programmer and (optionally) a ATtiny13/25/45/85 development board that includes a 6- or 10-pin programming header&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-08T07:37:02.737" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24000" PostTypeId="2" ParentId="23996" CreationDate="2016-05-08T09:22:56.180" Score="0" Body="&lt;p&gt;I don't see than much usefulness in these boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Negatives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The USB port is only for power. Not for programming.&lt;/li&gt;&#xA;&lt;li&gt;You have to buy an ATTiny chip to put into the socket. It's &lt;strong&gt;not&lt;/strong&gt; included.&lt;/li&gt;&#xA;&lt;li&gt;There is no way to put this into a breadboard.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strike&gt;There isn't even a way to get to the output pins. So you have to put the chip into this programmer, program it, remove it from the programmer, and place it back into the circuit.&lt;/strike&gt;&lt;/li&gt;&#xA;&lt;li&gt;It seems to use an 8-pin header to break out the 8 pins on the ATtiny. You'd have to use some female jumper wires to connect to them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Positives:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;There is a voltage regulator, so you can connect a higher voltage to the VIN pin&lt;/li&gt;&#xA;&lt;li&gt;&lt;strike&gt;There is an 8-pin ISP header, so you can easily connect a ISP programmer, like an &lt;a href=&quot;http://www.ebay.com/itm/51-AVR-Atmega-Programmer-ISP-Downloader-USB-ASP-Downloader-/201066541625?hash=item2ed07ff239&quot; rel=&quot;nofollow noreferrer&quot;&gt;USB-ASP&lt;/a&gt;&lt;/strike&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So in conclusion, some minor plus sides, and some major downsides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just place the 8-pin DIP ATtiny in a breadboard.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2017-05-28T13:59:11.877" LastActivityDate="2017-05-28T13:59:11.877" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24001" PostTypeId="2" ParentId="23988" CreationDate="2016-05-08T09:37:43.017" Score="1" Body="&lt;p&gt;I've done just that on a Arduino Pro Mini of mine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to change the fuses to have the chip use the Internal Oscillator, instead of a crystal. After that you just program the 8-MHz version of the bootloader. Like the one used in the &lt;code&gt;Arduino Pro Mini 3.3V&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem is that &lt;strong&gt;you need to connect a crystal, to change the fuses to not use the crystal&lt;/strong&gt;. Though it doesn't need to be 16Mhz. Anything between 1 and 16MHz will do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But since you need to change both the fuses and the bootloader, there is no advantage to buy chips with the bootloader preinstalled. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd just buy some bare chips without the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS $4.66 is on the high side for an ATMega328P-PU.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-08T09:37:43.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24003" PostTypeId="1" AcceptedAnswerId="24006" CreationDate="2016-05-08T11:37:28.343" Score="0" ViewCount="332" Body="&lt;p&gt;can anyone help me with connecting LED to Arduino LilyPad Mp3  in a way, that each switch (1 of 5) light up a different LED? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried connecting an LED between the switch and the board, then the LED light up, but the speaker does not play the audio file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried connecting an LED directly to the speaker, then LED lights up and the speaker plays the sound file, but the problem is that all of the LED´s light up at the same time....&lt;/p&gt;&#xA;" OwnerUserId="20889" LastActivityDate="2016-05-08T17:48:15.070" Title="How to connect an LED to Arduino LilyPad Mp3" Tags="|led|switch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24004" PostTypeId="1" CreationDate="2016-05-08T13:12:48.290" Score="1" ViewCount="1049" Body="&lt;p&gt;I have a GSM Sim900 connected to an Arduino Uno. I'm successfully able to use HTTP READ commands to show data from the web on the Arduino's serial monitor. It is showing complete HTML from that URL on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, how should I filter data from the web? I mean I just want to display selected numbers in the serial monitor and not the complete HTML.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And secondly, how should I store these numbers into a variable so I could use them as input data for Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="20891" LastEditorUserId="4628" LastEditDate="2017-04-20T05:44:12.597" LastActivityDate="2017-04-20T05:44:12.597" Title="How to use web data from GSM Sim900 to be used as input for Arduino?" Tags="|arduino-uno|arduino-ide|gsm|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24006" PostTypeId="2" ParentId="24003" CreationDate="2016-05-08T15:33:46.673" Score="0" Body="&lt;p&gt;You might try connecting the anode side of your LEDs through a current limiting resistor to the positive side of the supply.  Then connecting the cathode side of the LED to the switched pin on the Arduino LilyPad Mp3.  So, in this diagram:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xoTnl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xoTnl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...that would be the pads where the switches are connected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The current limiting resistor depends on the specifications of the LED.  Check the voltage and current required to light the LED.  Subtract the voltage needed from your supply voltage.  Then use the V=IR equation and solve for R.  That is, V = the voltage difference between your supply and what is needed by the LED and I is the current (probably in milliamps, so watch your math!) that the LED needs to light up properly.  You will probably need small current limiting resistors somewhere around between 100 and 800 ohms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks to @Gerben we have a diagram of what I was describing:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KCUlD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KCUlD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Gerben's diagram he has used the regulated 3 volt output of the Arduino LilyPad Mp3.  We can double check all the pin labels using a diagram from Sparkfun:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qHGAr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qHGAr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be able to repeat this circuit for each switch.  Sparkfun has an LED tutorial &lt;a href=&quot;https://learn.sparkfun.com/tutorials/light-emitting-diodes-leds?_ga=1.1888825.965782605.1436615638&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.  But I'm not very happy with their guess approach when picking out a current limiting resistor.  Ah, &lt;a href=&quot;https://www.sparkfun.com/tutorials/219&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; is much more to the point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if we assume the LEDs you are using need 3mA @ 3V (remember to use values for YOUR LEDs!) and use this equation (Vs = supply voltage and Vf = LED voltage):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5uPYa.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5uPYa.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...then we set it up like (3 - 3) / (0.03) which is zero.  That's because I was using LEDs that work at 3 volts.  But if I used LEDs that worked at 3mA at 1.8V then I need... (3 - 1.8) / (0.03) = 40 ohm resistors.  Or there about. As most resistor values are on a log scale I suspect there should be a 47 ohm available.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-08T17:48:15.070" LastActivityDate="2016-05-08T17:48:15.070" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24008" PostTypeId="2" ParentId="16170" CreationDate="2016-05-08T20:44:49.867" Score="-1" Body="&lt;p&gt;As shown in the Fritzing diagram, you have connected the ESP8266 to the Mega's Serial1 pins (18 and 19), but in the program, you try to interact with Serial2 (pins 16 an 17). For this to work, your wiring and your program must match.&lt;/p&gt;&#xA;" OwnerUserId="20899" LastEditorUserId="6936" LastEditDate="2016-10-22T18:46:31.630" LastActivityDate="2016-10-22T18:46:31.630" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24010" PostTypeId="1" CreationDate="2016-05-09T06:22:30.573" Score="0" ViewCount="1530" Body="&lt;p&gt;I want to connect an Esp8266 Wifi module to an Arduino nano. I am wondering if I need to implement level-shifting for the Arduino TX line to Esp RX line?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I find different schema's on the net. Some with, some without level-shifting:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With:&#xA;&lt;a href=&quot;http://community.blynk.cc/t/robot-with-esp8266-shield-and-arduino-nano/3316/8&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://community.blynk.cc/t/robot-with-esp8266-shield-and-arduino-nano/3316/8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17590/arduino-nano-v3-0-with-esp8266&quot;&gt;Arduino Nano v3.0 with ESP8266&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some use a capacitor between GND and Esp CH_PD pin, others use a 10K resister between the 3.3V and the CH_PD pin (&lt;a href=&quot;https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/&lt;/a&gt;)...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the most basic but required setup for a Arduino Nano and a Esp8266?&#xA;(I have Esp8266-12e modules)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="19910" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-05-10T09:19:20.223" Title="Arduino nano to esp8266 level shifting needed?" Tags="|arduino-nano|esp8266|voltage-level|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24014" PostTypeId="1" CreationDate="2016-05-09T07:51:25.520" Score="0" ViewCount="6383" Body="&lt;p&gt;Is there any way to use Arduino in the terminal? I have a USB 802.15.4 board that works with Arduino, but I don't want to use the IDE with it, I want to use the terminal.&lt;/p&gt;&#xA;" OwnerUserId="20755" LastEditorUserId="20755" LastEditDate="2016-05-09T08:34:57.793" LastActivityDate="2016-06-08T15:19:13.113" Title="Running Arduino IDE in terminal?" Tags="|terminal|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24015" PostTypeId="1" AcceptedAnswerId="24022" CreationDate="2016-05-09T08:27:36.073" Score="0" ViewCount="632" Body="&lt;p&gt;I have just completed my first project, a clone of the Simon game of the eighties. The main parts of the circuit are an ATMega328, a 1602 2x16 LCD, and a small joystick.&#xA;It is powered directly from 3x1.5V batteries with solder bridges connecting all power pins on each part directly to the batteries. Therefore, if I sleep the ATMega, it won't change a thing comsumption-wise, as the LCD will still be powered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are (my first project, I am very unknowledgeable) the possible strategies to sleep the whole circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought of using an ATMega pin as a positive lead for the joystick and LCD. Is that feasible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another strategy would be to interface some component (a relay?) between the battery and LCD, and command that component from an ATMega pin. Does someone know the right part for the job (I have a 220V relay in my parts, but it seems overkill)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lastly, even though it seems unlikely, is there a possible strategy without using any ATMega pins, as I currently use every single one (4 buttons, 4 leds, joystick x, y, and button, 1 buzzer, and 6 pins for the LCD, for a total of 18) except Rx and Tx?&lt;/p&gt;&#xA;" OwnerUserId="19700" LastActivityDate="2016-05-10T09:31:37.837" Title="How to sleep a whole circuit?" Tags="|lcd|atmega328|sleep|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24017" PostTypeId="2" ParentId="24010" CreationDate="2016-05-09T08:37:25.543" Score="1" Body="&lt;p&gt;The &lt;strong&gt;arduino nano v3&lt;/strong&gt;'s logic is 5v, and the ESP8266's logic is 3.3V, so you need to do level shifting between both.&#xA;Using a voltage divider drains more current (guess not an issue in this case) and it's ok only when going from 5V to 3.3V (when the signal must be shifted from 3.3V to 5V in the links you provide, it looks like it's based on that 3.3V is still considered &quot;HIGH&quot; on a TTL signal). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I personally prefer using a level shifter, it just complicates a bit the Bill Of Materials, but you won't have to debug the level shifting part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And better than that, using an arduino mini pro @3.3v working directly at 3.3V gets rid of this hassle.&lt;/p&gt;&#xA;" OwnerUserId="1675" LastEditorUserId="1675" LastEditDate="2016-05-10T09:19:20.223" LastActivityDate="2016-05-10T09:19:20.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24018" PostTypeId="2" ParentId="24014" CreationDate="2016-05-09T09:05:23.427" Score="1" Body="&lt;p&gt;1.) You can configure the arduino ide to use an &quot;external editor&quot;. This means the arduino ide runs als usual but reloads the opened file for compiling and uploading. This is when you want to keep the original arduino ide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.) You can use the &lt;a href=&quot;http://inotool.org/&quot; rel=&quot;nofollow&quot;&gt;ino projekt&lt;/a&gt; which gives you a cli interface to manage your arduino projects. The &lt;a href=&quot;http://inotool.org/quickstart&quot; rel=&quot;nofollow&quot;&gt;quickstart&lt;/a&gt; guide gives a good overview of the project.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ino init -t blink&#xA;ino build&#xA;ino upload&#xA;ino serial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can of course make all needed modifcations for differend boards and communication. I think the second option is what you are looking for ;)&lt;/p&gt;&#xA;" OwnerUserId="20541" LastActivityDate="2016-05-09T09:05:23.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24019" PostTypeId="2" ParentId="24010" CreationDate="2016-05-09T09:07:07.927" Score="1" Body="&lt;p&gt;You could use a simple diode, between the Arduino TX and ESP RX. That's what the &lt;a href=&quot;https://cdn-learn.adafruit.com/assets/assets/000/024/745/original/adafruit_products_schem.png?1429900999&quot; rel=&quot;nofollow&quot;&gt;Adafruit Huzzah uses&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes advantage of the internal pull-up on the RX pin of the ESP. The diode will allow a LOW, to pull the signal low, through the diode. But it will block a HIGH 5 Volt signal from going into the ESP.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-09T09:07:07.927" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24020" PostTypeId="2" ParentId="21505" CreationDate="2016-05-09T09:43:51.227" Score="1" Body="&lt;p&gt;I believe that the Arduino ground should be common with the 12v source ground. I may be wrong, though that's the way it works for me. Also be aware that some of these relay cards work when the pin is LOW, others when the pin is HIGH. Mine energises when the pin is HIGH, though all tutorials I had read until the last had the relay switching on with a LOW pin. &lt;/p&gt;&#xA;" OwnerUserId="20843" LastActivityDate="2016-05-09T09:43:51.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24022" PostTypeId="2" ParentId="24015" CreationDate="2016-05-09T10:08:23.970" Score="4" Body="&lt;p&gt;The first and most smart solution is to use a switch between the batteries and everything else. This way, you slide the switch in the off position and the whole circuit is completely detached from the batteries: power consumption: 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't (because, for instance, you want it to automatically power off after a while) you can use a transistor (PMOS, for instance) instead of the switch. you have then to put a complementary transistor (NMOS) on its gate, then a button in parallel to it. Just another passve component is required: a resistor (value e.g. can be 100k). When you press the button, the circuits becomes momentarily powered on. You will have to pull the nmos gate to a logic 1 with the atmega to keep the circuit powered. When you want to turn everything off, pull the pin to a logic 0 and your circuit will immediately shut down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If, third solution, you want to give the atmega complete control over the powering, it needs to be always on. You can then omit the complementary transistor and use a reverse logic on the pin (so 0 = on, 1 = off) and then you can do whatever you want with the power (turn on and off whenever you want).&#xA;&lt;strong&gt;edit&lt;/strong&gt;: as a comment suggests, it can be better to put a resistor to set the appropriate voltage on the gate at power up. Even if the commenter told to put a pull-down, I suggest you to put a pull-up (pull-down = normally on, pull-up = normally off). &lt;strong&gt;edit 2&lt;/strong&gt; as Paul suggested, there could be cases in which you need to be able to turn on and off automatically the circuit, and then store it for longer times without consuming battery. In this case it could be a good idea to put something (a mechanical switch, a jumper, a detachable wire) to completely detach the battery even from the arduino (even if, in this case, you can just remove the batteries from the housing).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a small paint-made sketch to show the solutions. If you have any questions just ask ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rNuc3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rNuc3.png&quot; alt=&quot;Circuits for pouzzler&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If you want to let the atmega control the power, you'll have to give him a way to do so. Which means.. You should use a pin. If you want you can use safely the RX and TX pins, as long as you don't enable the serial interface. If you need more pins, you can try to optimize your pins usage (for instance using a 4:1 multiplexer for the buttons you will have 2 control pins and 1 input, for a total of 3 pins, instead of 4), even if I think that the best solution is to use a port expander. for instance in the past I used the MCP23017, which has a I2C interface, or the MCP23S17, with a SPI interface. You will have to use the serial interface you choose (I2C: 2 pins - SCL and SDA, SPI: 4 pins - MISO, MOSI, SCK, SS, but they are the same pins used for programming), and then you will have 16 more pins for your uC&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT BY foivaras:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same result can be achieved utilizing an NMOS instead of a PMOS.This would have an advantage over PMOS solution if power line was &gt;5v and arduino was powered by a dc to dc converter. On this scenario, PMOS solution would need one more transistor to work. &#xA;Notice that the NMOS has to be placed on the low side of the power line and it will cutoff the power to joystick and lcd with 0v  and enable the power with 5v on its gate.(See 4th image)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AoK9p.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AoK9p.png&quot; alt=&quot;NMOSPOWERCONTROL&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;COMMENT BY fra87&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This solution is not a valid alternative in my opinion. Usually interrupting ground is a bad idea, because usually the rest position of the I/O pins is ground: if you interrupt the ground for the LCD, for instance, you will have +5V on the VCC pin, and a floating ground, but you will have 0V on all the I/O pins, possibly damaging the internal circuits. Moreover having a floating ground is bad in terms of noise protection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only advantage COULD be in the particular case explained by the editor, which is a DC/DC converter powering the arduino but not the LCD and the Joystick. This is a strange setup, though, and the proposed solution is better at a first glance (requires one less transistor), but is wrong. For instance, let's suppose the joystick is powered at 12V. If you detach the ground, the joystick will &quot;shut down&quot;, which means that all its pins will float up to 12V. This means that on the arduino pin you will see 12V: you can damage it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, in the end, I discourage this solution. The only case when you can need it is when you are in a hurry and do not have any feasable PMOS: even in this case, however, I suggest you to replace the NMOS with a PMOS as soon as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just one more note: edits to the posts, in my opinion, should be done to improve the quality of the answer, by better formatting the content, removing orthographic errors and so on. If someone needs to add some comments or other solutions, it's better to use the comments or add another answer to the thread&lt;/p&gt;&#xA;" OwnerUserId="10214" LastEditorUserId="10214" LastEditDate="2016-05-10T09:31:37.837" LastActivityDate="2016-05-10T09:31:37.837" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="24025" PostTypeId="1" CreationDate="2016-05-09T12:34:38.780" Score="0" ViewCount="4069" Body="&lt;p&gt;I am trying some AT commands with ESP8266 but it resets continously when it stop resetting, i can't get any response from ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&#xA;&#xA;OK&#xA;AT+CWMODE=1&#xA;&#xA;&#xA;OK&#xA;AT+CIPMODE=0&#xA;&#xA;&#xA;OK&#xA;AT+CIPMUX=1&#xA;&#xA;&#xA;OK&#xA;AT+CWJAP=&quot;..&quot;,&quot;..&quot;&#xA;&#xA;&#xA; ets Jan  8 2013,rst cause:4, boot mode:(3,1)&#xA;&#xA;wdt reset&#xA;load 0x40100000, len 612, room 16 &#xA;tail 4&#xA;chksum 0x12&#xA;load 0x3ffe8000, len 788, room 4 &#xA;tail 0&#xA;chksum 0x50&#xA;load 0x3ffe8314, len 264, room 8 &#xA;tail 0&#xA;chksum 0x4a&#xA;csum 0x4a&#xA;&#xA;2nd boot version : 1.1&#xA;  SPI Speed      : 40MHz&#xA;  SPI Mode       : QIO&#xA;  SPI Flash Size : 4Mbit&#xA;jump to run user1&#xA;&#xA;sd&#xA;ready&#xA;&#xA; ets Jan  8 2013,rst cause:4, boot mode:(3,1)&#xA;&#xA;wdt reset&#xA;load 0x40100000, len 612, room 16 &#xA;tail 4&#xA;chksum 0x12&#xA;load 0x3ffe8000, len 788, room 4 &#xA;tail 0&#xA;chksum 0x50&#xA;load 0x3ffe8314, len 264, room 8 &#xA;tail 0&#xA;chksum 0x4a&#xA;csum 0x4a&#xA;&#xA;2nd boot version : 1.1&#xA;  SPI Speed      : 40MHz&#xA;  SPI Mode       : QIO&#xA;  SPI Flash Size : 4Mbit&#xA;jump to run user1&#xA;&#xA;sd&#xA;ready&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have upgraded my firmware and I tried GPIO0 and GPIO2 are active but it still does not response fine. It worked yesterday but today it is working like crazy..&lt;/p&gt;&#xA;" OwnerUserId="20868" LastEditorUserId="4143" LastEditDate="2016-05-09T13:46:21.473" LastActivityDate="2017-12-17T22:13:35.710" Title="ESP8266 reset problem" Tags="|esp8266|" AnswerCount="2" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="24026" PostTypeId="2" ParentId="24014" CreationDate="2016-05-09T13:29:39.890" Score="0" Body="&lt;p&gt;The most popular method these days is to use &lt;a href=&quot;https://github.com/arduino/arduino-builder&quot; rel=&quot;nofollow&quot;&gt;arduino-builder&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This seems to be the official Arduino command line interface now, and can do most things the IDE can do short of actually editing your code for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a set of GO scripts, so you will need GO installed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-09T13:29:39.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24027" PostTypeId="2" ParentId="23721" CreationDate="2016-05-09T13:48:35.970" Score="1" Body="&lt;p&gt;May be you should try to replace : &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;fht_lin_ou8[0];&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;with : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;fht_lin_out8[0];&lt;/p&gt;&#xA;" OwnerUserId="20917" LastActivityDate="2016-05-09T13:48:35.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24028" PostTypeId="2" ParentId="24025" CreationDate="2016-05-09T14:09:09.290" Score="1" Body="&lt;p&gt;Arduino can not provide enough current for ESP8266 operations. Use external 3.3V power supply, I would recommend 500ma. Also don't forget to put a small cap between vcc and ground. 100uf should do it. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-05-09T14:09:09.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24031" PostTypeId="1" AcceptedAnswerId="24032" CreationDate="2016-05-09T16:37:40.247" Score="1" ViewCount="1278" Body="&lt;p&gt;my goal is to read a pwm signal from a rc receiver. For that i tried to use an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i ran this code on the arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Pin 3&#xA;&#xA;int pwm_value;&#xA;&#xA;void setup() {&#xA;  pinMode(Pin, INPUT);&#xA;  Serial.begin(9700);&#xA;}&#xA;&#xA;void loop() {&#xA;  pwm_value = pulseIn(Pin, HIGH);&#xA;  Serial.println(pwm_value);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now i connected the 3rd pin with the output of the receiver. But instead of printing the correct pwm values they get printed completely crazy. Sometimes they are under 10 and sometimes they are over 10000. The receiver outputs the correct signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also noticed that if i just touch the pin with my finger or if i only connect a single jumper cable without anything at the end, the arduino will read a pwm signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have realy no idea to solve that. Can you please help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="20921" LastEditorUserId="20645" LastEditDate="2016-05-10T01:51:46.853" LastActivityDate="2016-05-10T01:51:46.853" Title="reading pwm signal doesn't work correctly" Tags="|pwm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24032" PostTypeId="2" ParentId="24031" CreationDate="2016-05-09T17:22:27.430" Score="1" Body="&lt;p&gt;check if the problem is the fact you have set &lt;code&gt;9700&lt;/code&gt; baud rate on your sketch while the commonly used &lt;code&gt;9600&lt;/code&gt; is supported from arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I slightly modified your code and it works for me. Check if this works for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define Pin 3&#xA;#define Source 5&#xA;unsigned long  pwm_value;&#xA;&#xA;void setup() {&#xA;    pinMode(Source,OUTPUT);&#xA;    pinMode(Pin, INPUT);&#xA;    Serial.begin(9600);&#xA;    analogWrite(Source,500);&#xA;}&#xA;&#xA;void loop() {&#xA;    pwm_value = pulseIn(Pin, HIGH);&#xA;    Serial.println(pwm_value);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when you connect pin3 with pin 5 you should get a consistent value on Serial(=967).&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;About getting signal on floating pins&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Getting a signal on a floating pin is normal.&#xA;When you have a cable attached it acts like an antenna. When you touch it, you are the antenna!&lt;/p&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="20645" LastEditDate="2016-05-09T18:05:38.347" LastActivityDate="2016-05-09T18:05:38.347" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24033" PostTypeId="1" AcceptedAnswerId="24035" CreationDate="2016-05-09T17:30:01.973" Score="3" ViewCount="15008" Body="&lt;p&gt;Coming from C#, pointers are somewhat foreign although I am grasping the concept.&#xA;Is it proper to construct methods in the following manner and passing the object (as a parameter) constructed by reference? If not, then please answer how to do this properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initialize the object&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_VS1053_FilePlayer musicPlayer =&#xA;    Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Method: (use the * for pointer?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean initializeMusicPlayer(Adafruit_VS1053_FilePlayer *mp, uint16_t baudRate) {&#xA;&#xA;    musicPlayerSerialPort.begin(baudRate);&#xA;    // initialise the music player&#xA;    if (!mp-&amp;gt;begin()) { // initialise the music player&#xA;        Serial.println(F(&quot;Couldn't find VS1053, do you have the right pins defined?&quot;));&#xA;        return false;&#xA;        //while (1);&#xA;    }&#xA;    Serial.println(F(&quot;VS1053 found&quot;));&#xA;&#xA;    mp-&amp;gt;sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working&#xA;&#xA;    if (!SD.begin(CARDCS)) {&#xA;        Serial.println(F(&quot;SD failed, or not present&quot;));&#xA;        return false;&#xA;        //while (1);  // don't do anything more&#xA;    }&#xA;    Serial.println(&quot;SD OK!&quot;);&#xA;    // Set volume for left, right channels. lower numbers == louder volume!&#xA;    mp-&amp;gt;setVolume(20, 20);&#xA;&#xA;    if (!mp-&amp;gt;useInterrupt(VS1053_FILEPLAYER_PIN_INT)) {&#xA;        Serial.println(F(&quot;DREQ pin is not an interrupt pin&quot;));&#xA;        return false;&#xA;    }&#xA;    return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Call the method (Use the ampersand to pass the currently created one by reference?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(initializeMusicPlayer(&amp;amp;musicPlayer, 9600) == true) {&#xA;    tempString = tempString + &quot;MusicPlayer initialized!&quot;;&#xA;    Serial.println(tempString);&#xA;    //when adding lcd, print the above to lcd and remove the serial print&#xA;}   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19667" LastEditorUserId="19667" LastEditDate="2016-05-09T17:43:16.493" LastActivityDate="2023-10-04T04:36:40.120" Title="Proper use of * and &amp; when passing objects in methods" Tags="|arduino-mega|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24035" PostTypeId="2" ParentId="24033" CreationDate="2016-05-09T17:50:02.247" Score="7" Body="&lt;p&gt;The method you have implemented, &lt;em&gt;passing by pointer&lt;/em&gt;, is one of the two normal methods, yes. The other is &lt;em&gt;passing by reference&lt;/em&gt; and is specific to C++, not C.&lt;/p&gt;&#xA;&lt;p&gt;Under the hood the end result is the same between the two methods, by the syntactic &amp;quot;sugar&amp;quot; is very different and the latter can be preferable for that reason alone.&lt;/p&gt;&#xA;&lt;p&gt;Your method:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void function(whatever *ob) {&#xA;    ob-&amp;gt;method();&#xA;}&#xA;&#xA;function(&amp;amp;myObject);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;em&gt;pass by reference&lt;/em&gt; method:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void function(whatever &amp;amp;ob) {&#xA;    ob.method();&#xA;}&#xA;&#xA;function(myObject);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you can see the need to convert the object into a pointer with &lt;code&gt;&amp;amp;&lt;/code&gt; is now gone. That makes it much easier for people lacking in programming skills to use it since it hides the whole pointer mechanism from them.&lt;/p&gt;&#xA;&lt;p&gt;Also, internally your function now treats &lt;code&gt;ob&lt;/code&gt; as just another object using &lt;code&gt;.&lt;/code&gt;, rather than a pointer to an object and needing to use &lt;code&gt;-&amp;gt;&lt;/code&gt;.  Note that you can only use the reference operator in a function prototype, not a variable or anything like that - it's purely for passing objects and variables to functions.  If you want to then go and store the pointer in a variable you still then have to get the address:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void function(whatever &amp;amp;ob) {&#xA;    myObjectPointer = &amp;amp;ob;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As you see it gets confusing with the two different uses of &lt;code&gt;&amp;amp;&lt;/code&gt;. Basically though: if it's in a function prototype, it's the &lt;code&gt;pass by reference&lt;/code&gt; operator. If it's anywhere else, it's the &lt;code&gt;get the address of&lt;/code&gt; operator (or a logical AND of course).&lt;/p&gt;&#xA;&lt;p&gt;Storing the pointer can be useful if you want to then do other things later on with the same object, especially if you are yourself working with a class.  For instance, I often write code similar to the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class foo {&#xA;    private:&#xA;        bar *ob; // Pointer to other object of type &amp;quot;bar&amp;quot;&#xA;    public:&#xA;        foo(bar *inob) : ob(inob) {}&#xA;        foo(bar &amp;amp;inob) : ob(&amp;amp;inob) {}&#xA;&#xA;        void something() {&#xA;            ob-&amp;gt;doSomething();&#xA;        }&#xA;&#xA;        void somethingElse() {&#xA;            ob-&amp;gt;doSomethingElse();&#xA;            ob-&amp;gt;evenMoreThings();&#xA;        }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You then have a choice of constructors:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bar myBar;&#xA;foo myFoo(myBar);&#xA;&#xA;// ... later ...&#xA;myFoo.something();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;or&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bar myBar;&#xA;foo myFoo(&amp;amp;myBar);&#xA;&#xA;// ... later ...&#xA;myFoo.something();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and the user doesn't have to remember which they need to use - whichever they try will work.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="6936" LastEditDate="2023-10-04T04:36:40.120" LastActivityDate="2023-10-04T04:36:40.120" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24036" PostTypeId="2" ParentId="22923" CreationDate="2016-05-09T19:08:30.597" Score="0" Body="&lt;p&gt;The rate of change of the temperature reading depends on the thermal properties of the sensor package, not on the rate at which you read it. The less expensive, plastic packaged sensors that most of us use will be the slowest to respond to change just because that is the thermal nature of the plastic. Do note that the ground pin of that package has more influence than the package itself, so do your best to ensure the ground pin is exposed to the temperature you're trying to measure, or is at least thermally insulated from the surrounding air, unless the air temperature is what you are trying to measure. If you need faster response to temperature change, you'll need to pay attention to keeping the entire device at or close to the temperature of interest and insulated from surrounding temperatures.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-09T19:08:30.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24037" PostTypeId="1" AcceptedAnswerId="24038" CreationDate="2016-05-09T19:36:41.783" Score="0" ViewCount="138" Body="&lt;p&gt;I'm trying to run a neopixel strip and an arduino from the same power supply using a voltage divider to get 5V to the strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the values for my voltage divider:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R1 = 1500 Ω&lt;/p&gt;&#xA;&#xA;&lt;p&gt;R2 = 1000 Ω&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin = 12 V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;resulting in:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vout = Vin*(R2/(R1+R2)) = 12*(1000/(1500+1000)) = 12*(1000/2500) = 12*0.4 = 4.8&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the divider is connected at its inputs but not at its outputs, I measure the expected 4.8V across R2. But as soon as I connect the neopixels, I only get about 1.6V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could anybody explain this || Suggest a possible solution?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xdils.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xdils.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17150" LastEditorUserId="17150" LastEditDate="2016-05-09T19:41:47.710" LastActivityDate="2016-05-09T19:56:00.537" Title="Voltage divider producing unexpected voltage" Tags="|voltage-level|neopixel|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24038" PostTypeId="2" ParentId="24037" CreationDate="2016-05-09T19:56:00.537" Score="2" Body="&lt;p&gt;Since you are connecting your pixel strip in parallel with R2, the&#xA;correct formula is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = Vin × (R2∥Rp) / (R1 + (R2∥Rp))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where Rp is the resistance of the pixel strip and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R2∥Rp = R2 × Rp / (R2 + Rp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the combination of R2 and Rp in parallel. From this you can see that&#xA;an output voltage of 1.6&amp;nbsp;V is consistent with a strip resistance of&#xA;300&amp;nbsp;Ω.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is, however, somewhat oversimplified, as the I(V) characteristic of&#xA;the LED strip is probably non-linear, thus not really equivalent to a&#xA;resistor.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-09T19:56:00.537" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24039" PostTypeId="1" AcceptedAnswerId="24050" CreationDate="2016-05-09T20:48:10.797" Score="0" ViewCount="13594" Body="&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float x = 3154681.124 / 100000; //x = 31.54;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want x to be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = 31.5468112;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20326" LastActivityDate="2016-05-10T06:09:39.253" Title="How to set float to variable with 7 digits after the decimal point in arduino?" Tags="|arduino-uno|arduino-ide|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24040" PostTypeId="2" ParentId="24039" CreationDate="2016-05-09T20:52:46.317" Score="2" Body="&lt;pre&gt;&lt;code&gt;float x = 3154681.124 / 100000; //x = 31.54;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is now &lt;code&gt;31.5468112&lt;/code&gt; (or close to).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(x);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output: &lt;code&gt;31.54&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Why? Because &lt;code&gt;Serial.println&lt;/code&gt; defaults to 2 decimal places for floats.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Syntax&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Serial.println(val)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Serial.println(val, format)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Parameters&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;val&lt;/code&gt;: the value to print - any data type&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;format&lt;/code&gt;: specifies the number base (for integral data types) &lt;strong&gt;or number of decimal places (for floating point types)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So the solution: specift 7 decimal places when you print:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(x, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-09T20:52:46.317" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24042" PostTypeId="2" ParentId="16625" CreationDate="2016-05-09T21:28:50.577" Score="1" Body="&lt;p&gt;You can actually use the sim900a and 900a mini in the uk but you will have to download firmware and flashing tools that you will find with a web search, not for the beginner though, an 800l is your best bet with a SMA Female JACK Connector to U.FL/IPX Converter Pigtail Cable F1445K so you can attach an sma antenna&lt;/p&gt;&#xA;&#xA;&lt;p&gt;cheers&#xA;Stuart&lt;/p&gt;&#xA;" OwnerUserId="20928" LastActivityDate="2016-05-09T21:28:50.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24043" PostTypeId="1" AcceptedAnswerId="24061" CreationDate="2016-05-09T21:45:08.797" Score="0" ViewCount="2258" Body="&lt;p&gt;I've reviewed the WiFi101 library but have found no way to make the 101 an ad-hoc network.  Am I missing something?  I'd like to be able to emulate the RedFly example:&#xA;&lt;a href=&quot;http://notebook.kulchenko.com/embedded/storing-wifi-configuration-in-eeprom-on-arduino&quot; rel=&quot;nofollow&quot;&gt;http://notebook.kulchenko.com/embedded/storing-wifi-configuration-in-eeprom-on-arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the 101 become an ad-hoc network?  I understand the security problem with the ad-hoc capability so it would make sense that Arduino prohibits it.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-05-10T13:06:14.010" Title="Wifi101 ad-hoc network" Tags="|arduino-uno|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24044" PostTypeId="1" CreationDate="2016-05-09T21:54:02.980" Score="3" ViewCount="220" Body="&lt;p&gt;I have a situation where I need to select between two signals, lets say 1A or 2B and route it to output 3C. I need to do this six times (2A or 2B to output 2C, 3A or 3B to output 3C, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These all need to switch based on one output from my chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What sort of component do I need for this? I think it's something like a 2:1 spdt multiplexer, but something doesn't seem quite right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking at a bunch of data sheets and I cannot seem to find a chip which switches many 2:1 switches based on ONE input. Does such a thing exists? Or am I just way of the mark here? Not sure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="20930" LastActivityDate="2016-05-10T01:21:13.213" Title="Switching Many Switches with one Input" Tags="|multiplexer|switch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24045" PostTypeId="1" AcceptedAnswerId="24046" CreationDate="2016-05-09T23:11:07.047" Score="0" ViewCount="304" Body="&lt;p&gt;I wrote the following code for displaying a bitmap (small size) on a  LED matrix (formed using APA102 led strip):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//for 24-bit bitmaps&#xA;&#xA;// the header files for the RGB data&#xA;&#xA; #include &amp;lt;FastLED.h&amp;gt;&#xA; #include &quot;redarray.h&quot;   &#xA; #include &quot;greenarray.h&quot;   //g data header file (hex or dec)&#xA; #include &quot;bluearray.h&quot;   //b data header file (hex or dec)*/&#xA;&#xA;//matrix parameters&#xA;&#xA;#define MatrixWidth 36 //columns&#xA;#define MatrixHeight 7 //rows&#xA;#define numled (MatrixWidth * MatrixHeight)&#xA;&#xA;//pin details&#xA;&#xA;#define datapin 7&#xA;&#xA;#define clockpin 8&#xA;&#xA;CRGB leds[MatrixWidth * MatrixHeight];&#xA;&#xA;const bool  MatrixSerpentineLayout = true;&#xA;&#xA;&#xA; void setup() {&#xA;&#xA;     FastLED.addLeds&amp;lt;APA102, datapin, clockpin&amp;gt;(leds,numled);&#xA;     FastLED.clear();&#xA;  }&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;  for(uint8_t x=0 ; x&amp;lt;MatrixWidth ; x++)  {&#xA;&#xA;      for(uint8_t y=0; y &amp;lt; 3; y++) {&#xA;&#xA;            leds[XY (x, y)].setRGB(redarray[x][y],greenarray[x][y],bluearray[x] [y]);&#xA;&#xA;           FastLED.show();&#xA;&#xA;           delay(1);    &#xA;         }&#xA;      }&#xA;   }&#xA;&#xA;      uint16_t XY( uint8_t x, uint8_t y)   &#xA; {&#xA;   uint16_t i;&#xA;&#xA;     if( MatrixSerpentineLayout == true) {&#xA;       if( y &amp;amp; 0x01) {&#xA;        // Odd rows run backwards&#xA;          uint8_t reverseX = (MatrixWidth - 1) - x;&#xA;          i = (y * MatrixWidth) + reverseX;&#xA;     } else {&#xA;       // Even rows run forwards&#xA;          i = (y * MatrixWidth) + x;&#xA;    }&#xA;   }&#xA;&#xA;  return i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following is the data in one of the header files - its of same type for the other two colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;const unsigned char redarray[36][3] PROGMEM  = {&#xA;0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, &#xA;0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, &#xA;0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, &#xA;};&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The matrix is in a serpentine form (evident from the XY function in code). I am using an Arduino Due. The problem is that the code compiles and runs...but the bitmap is incorrect. Although I am sure, I am somewhat along the correct path because some LEDs do light up as they should as per the bitmap. But most of them are wrongly lit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you somebody plz guide where I am going wrong with the coding? I fear there is some mistake in reading the color data from array and allocating it to leds[XY(x,y)].I do not know how a 2D array is read or dealt with by Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20119" LastEditorUserId="20119" LastEditDate="2016-05-10T06:48:57.223" LastActivityDate="2016-05-10T12:38:52.760" Title="wrong leds lit in matrix display - wrong coding?" Tags="|arduino-due|rgb-led|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24046" PostTypeId="2" ParentId="24045" CreationDate="2016-05-10T01:00:01.883" Score="1" Body="&lt;p&gt;Initialize your arrays like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int a[3][4] = {  &#xA;   {0, 1, 2, 3} ,   /*  initializers for row indexed by 0 */&#xA;   {4, 5, 6, 7} ,   /*  initializers for row indexed by 1 */&#xA;   {8, 9, 10, 11}   /*  initializers for row indexed by 2 */&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...you can read more about it &lt;a href=&quot;http://www.tutorialspoint.com/cprogramming/c_multi_dimensional_arrays.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following explanation came from &lt;a href=&quot;https://stackoverflow.com/questions/18157251/multidimensional-array-initialization-in-c&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arrays that are not explicitly divided into rows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int M[4][5] = {10, 5, -3, 9, 0, 0, 32, 20, 1, 0, 0, 8};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...are filled like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int M[4][5] =&#xA;{&#xA;  {10,  5, -3, 9, 0},&#xA;  { 0, 32, 20, 1, 0},&#xA;  { 0,  8,  0, 0, 0},&#xA;  { 0,  0,  0, 0, 0}&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As only you understand your data you will have to verify if your data is populating the array as you expect.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-05-10T12:38:52.760" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24047" PostTypeId="2" ParentId="24044" CreationDate="2016-05-10T01:21:13.213" Score="4" Body="&lt;p&gt;Almost, you will need two &lt;a href=&quot;https://www.calstatela.edu/sites/default/files/groups/Department%20of%20Electrical%20and%20Computer%20Engineering/labs/74157.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;74157&lt;/a&gt; (or similar chips) to switch 8 pairs of TTL level logic signals down to 8 individual signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oVliX.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oVliX.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-10T01:21:13.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24050" PostTypeId="2" ParentId="24039" CreationDate="2016-05-10T06:09:39.253" Score="1" Body="&lt;p&gt;The &lt;code&gt;float&lt;/code&gt; type has slightly over 7 digits of precision. See &lt;a href=&quot;https://en.wikipedia.org/wiki/Floating_point&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Floating_point&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I want x to be:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   x = 31.5468112;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Bad luck. That's 9 digits of precision. You can get around 7 digits by converting it appropriately, eg. as Majenko said:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;  float x = 3154681.124 / 100000; //x = 31.54;&#xA;  Serial.println(x, 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;However that printed:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;31.5468101&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It got 7 digits right, as advertised.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;You can use the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11519&quot; rel=&quot;nofollow noreferrer&quot;&gt;BigNumber Library&lt;/a&gt; that I wrote. Available from &lt;a href=&quot;https://github.com/nickgammon/BigNumber&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Using that, you can get all the precision you want, within reason:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;BigNumber.h&amp;quot;&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  BigNumber::begin (7);  // 7 digits after the decimal place&#xA;&#xA;  BigNumber x (&amp;quot;3154681.124&amp;quot;);&#xA;  BigNumber y = x / BigNumber (&amp;quot;100000&amp;quot;);&#xA;  &#xA;  Serial.println(y);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;31.5468112&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-10T06:09:39.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24055" PostTypeId="1" CreationDate="2016-05-10T10:26:29.683" Score="1" ViewCount="15151" Body="&lt;p&gt;I'm working with a load cell and HX711. There was no weight on the sensor but I kept getting strange values, I thought it was broken or something so I used my second load cell but the same thing happened again. &#xA;I'm wondering what is wrong with it ?&#xA;If anyone have worked with it or have an idea how to work with it, please don't hesitate to give your opinions.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &quot;HX711.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt; &#xA;&#xA;#define DOUT  A0&#xA;#define CLK   A1&#xA;&#xA;#define DEC_POINT  2&#xA;#define STABLE  1&#xA;&#xA;float offset=0;&#xA;float calibration_factor = 1;&#xA;//float real_weight = 1.560;//kg&#xA;float real_weight = 0.5;//kg&#xA;&#xA;HX711 scale(DOUT, CLK);&#xA;&#xA;unsigned char state=0;&#xA;long  FindZeroFactor();&#xA;float get_units_kg();&#xA;void  ReadWeight();&#xA;void  FindCalibrationFactor();&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Serial.println();&#xA;  Serial.println(&quot;Auto Calibrate Program&quot;);&#xA;  Serial.println(&quot;Send 'a' to Find Zero Factor (Please Remove all weight from scale)&quot;);&#xA;  Serial.println(&quot;Send 'b' to Find Calibration Factor (Please insert know the weight on the scales)&quot;);&#xA;  Serial.println(&quot;Send 'c' Show weight on the scales&quot;);&#xA;}&#xA;void loop() &#xA;{&#xA;  if(Serial.available())&#xA;  {&#xA;    char temp = Serial.read();&#xA;    if(temp=='a')&#xA;      state=1;&#xA;    if(temp=='b')&#xA;      state=2;   &#xA;    if(temp=='c')&#xA;      state=3;&#xA;  }&#xA;&#xA;  switch(state)&#xA;  {&#xA;    case 0:&#xA;    break;&#xA;    case 1:&#xA;      FindZeroFactor();&#xA;   //   ReadWeight();&#xA;      state=0;&#xA;    break;&#xA;    case 2:&#xA;     FindCalibrationFactor();&#xA;     state=0;&#xA;    break;&#xA;    case 3:&#xA;      ReadWeight();&#xA;      delay(200);&#xA;    break;&#xA;    case 4:&#xA;&#xA;    break;&#xA;&#xA;  }&#xA;}&#xA;&#xA;long FindZeroFactor()&#xA;{&#xA;     Serial.println(&quot;Find Zero Factor&quot;);&#xA;     Serial.println(&quot;Please wait .....&quot;);&#xA;     scale.set_scale();&#xA;     scale.tare(); &#xA;     long zero_factor = scale.read_average(20); &#xA;     Serial.print(&quot;Zero factor: &quot;);&#xA;     Serial.println(zero_factor);&#xA;     return(zero_factor);&#xA;}&#xA;&#xA;void FindCalibrationFactor()&#xA;{&#xA;  unsigned char flag_stable=0;&#xA;  unsigned int decpoint=1;&#xA;  for(unsigned char i=0;i&amp;lt;DEC_POINT+1;i++ )&#xA;    decpoint = decpoint*10;&#xA;  while(1)&#xA;  {&#xA;      scale.set_scale(calibration_factor); //Adjust to this calibration factor&#xA;      Serial.print(&quot;Reading: &quot;);&#xA;      float read_weight = get_units_kg();&#xA;      String data = String(read_weight, DEC_POINT);&#xA;      Serial.print(data);&#xA;      Serial.print(&quot; kg&quot;); &#xA;      Serial.print(&quot; calibration_factor: &quot;);&#xA;      Serial.print(calibration_factor);&#xA;      Serial.println();&#xA;      long r_weight      = (real_weight*decpoint);&#xA;      long int_read_weight = read_weight*decpoint;&#xA;      Serial.print(r_weight);&#xA;      Serial.print(&quot; , &quot;);&#xA;      Serial.println(int_read_weight);&#xA;      long x;&#xA;      if(r_weight == int_read_weight)&#xA;      {&#xA;        flag_stable++;&#xA;        if(flag_stable&amp;gt;=STABLE)&#xA;        {&#xA;          Serial.print(&quot;Calibration Factor is = &quot;);&#xA;          Serial.println(calibration_factor);&#xA;          break;&#xA;         }&#xA;        }&#xA;       if(r_weight &amp;gt; int_read_weight)&#xA;          {&#xA;            x = r_weight - int_read_weight;&#xA;            if(x &amp;gt; 100)&#xA;              calibration_factor -= 1000; &#xA;            else if(x &amp;gt; 100)&#xA;              calibration_factor -= 10;&#xA;            else&#xA;              calibration_factor -= 1;&#xA;            flag_stable=0;&#xA;          }&#xA;          if(r_weight &amp;lt; int_read_weight)&#xA;          {&#xA;            x =  int_read_weight-r_weight;&#xA;            if(x &amp;gt; 100)&#xA;              calibration_factor += 1000; &#xA;            else if(x &amp;gt; 10)&#xA;              calibration_factor += 10;&#xA;            else&#xA;              calibration_factor += 1; &#xA;            flag_stable=0; &#xA;           }  &#xA;  }&#xA;}&#xA;&#xA;float get_units_kg()&#xA;{&#xA;  return(scale.get_units()*0.453592);&#xA;}&#xA;void ReadWeight()&#xA;{&#xA;  scale.set_scale(calibration_factor); //Adjust to this calibration factor&#xA;  Serial.print(&quot;Reading: &quot;);&#xA;  String data = String(get_units_kg()+offset, DEC_POINT);&#xA;  Serial.print(data);&#xA;  Serial.println(&quot; kg&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20940" LastEditorUserId="20940" LastEditDate="2016-05-10T13:08:02.390" LastActivityDate="2018-07-01T15:37:53.043" Title="How to calibrate a load cell?" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="24061" PostTypeId="2" ParentId="24043" CreationDate="2016-05-10T13:06:14.010" Score="1" Body="&lt;p&gt;Apparently you can have an ad-hoc network, you can see the example on the github here: &#xA;&lt;a href=&quot;https://github.com/arduino-libraries/WiFi101/blob/master/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino-libraries/WiFi101/blob/master/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It shows how to create an open ad-hoc network, for a secured one, you might need to check the datasheet + the method implement &quot;beginAP&quot;.&lt;/p&gt;&#xA;" OwnerUserId="13940" LastActivityDate="2016-05-10T13:06:14.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24064" PostTypeId="1" CreationDate="2016-05-10T13:49:22.537" Score="0" ViewCount="1470" Body="&lt;p&gt;I have been following various tutorials (especially: &lt;a href=&quot;https://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/basic-web-server/&quot; rel=&quot;nofollow&quot; title=&quot;Starting Electronics&quot;&gt;this&lt;/a&gt;) to connect an Arduino Ethernet board to my Ubuntu PC via Ethernet directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IP address of the computer was found to be 10.100.31.128, and so I tried addresses in this range (10.100.31.67, 10.100.31.121, ...) without success. DHCP also doesnt seem to work. For the MAC address I used the sticker on the back of the board. I am using a patch cable, maybe that's the problem?&lt;/p&gt;&#xA;" OwnerUserId="20459" LastActivityDate="2016-12-29T10:25:43.450" Title="Cannot directly connect Arduino Ethernet to PC" Tags="|ethernet|web-server|tcpip|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24065" PostTypeId="1" AcceptedAnswerId="24068" CreationDate="2016-05-10T13:59:00.077" Score="1" ViewCount="7842" Body="&lt;p&gt;I am undergoing a BSc (Hons) Degree in Computer Science and working on an Arduino project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the Arduino Mega and even though this microprocessor has plenty of input and output pins I am running out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the event that there are no more I/O pins available for me to make use of, and I am also referring to both analog and digital pins, is it possible to increase them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did some research, however the solutions are too vague... One of the suggestions was to use one or more of the following: 74HC595 8-Bit Shift Register DIP-16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/RRzqX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RRzqX.png&quot; alt=&quot;Arduino with shift registers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am good at coding however when it comes to hardware sometimes I'll need some push.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot.&lt;/p&gt;&#xA;" OwnerUserId="20946" LastEditorUserId="4628" LastEditDate="2017-11-21T03:40:35.433" LastActivityDate="2017-11-21T03:41:11.867" Title="Is it possible to increase the Arduino's input and output pins?" Tags="|arduino-mega|pins|" AnswerCount="3" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24066" PostTypeId="2" ParentId="22904" CreationDate="2016-05-10T14:07:29.933" Score="0" Body="&lt;p&gt;I've had this issue before. You can try reuploading the bootloader. If that doesn't work, maybe try re-installing the drivers.&lt;/p&gt;&#xA;" OwnerUserId="20665" LastActivityDate="2016-05-10T14:07:29.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24067" PostTypeId="1" AcceptedAnswerId="24072" CreationDate="2016-05-10T14:31:22.163" Score="1" ViewCount="1896" Body="&lt;p&gt;In a previous question (&lt;a href=&quot;https://arduino.stackexchange.com/questions/21782/append-text-to-variable-names-please-help-me-shorten-this-code/21799#21799&quot;&gt;Append Text to Variable Names: Please Help Me Shorten This Code&lt;/a&gt;) I learned that in order to shorten this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fanSpeed = readEEPROM(AT24C32_ADDRESS, 1, fanSpeedPos);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I could define a macro at the top of the script like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define readEE(VAR) VAR = readEEPROM(AT24C32_ADDRESS, 1, VAR ## Pos)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then just use the following shorter code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readEE(foo);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which would be expanded out to: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = readEEPROM(AT24C32_ADDRESS, 1, fooPos);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My current question is: &lt;strong&gt;How can I write a macro that accepts 2 arguments instead of just 1?&lt;/strong&gt; I couldn't find much information about this concerning Arduinos, so I studied about how to do it in C++ (like from here: &lt;a href=&quot;http://en.cppreference.com/w/cpp/preprocessor/replace&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://en.cppreference.com/w/cpp/preprocessor/replace&lt;/a&gt;) but it was too complicated for me to understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In particular, I would like to learn if it's possible to shorten the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void writeToEE(byte location, bool value, bool &amp;amp;var) {&#xA;  writeEE(loc, value); var = value;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(&lt;em&gt;Sidenote&lt;/em&gt;: the &lt;code&gt;writeEE&lt;/code&gt; function looks like this: &lt;code&gt;void writeEE(uint8_t entry, uint8_t data) { writeEEPROM(AT24C32_ADDRESS, 1, entry, data); }&lt;/code&gt;. Since the first 2 arguments are almost always constants, that's why I shortened it with another function).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since whenever I'm using &lt;code&gt;writeToEE&lt;/code&gt;, the &quot;entry&quot; variable name is always the &quot;data&quot; variable name with &quot;Pos&quot; appended, I would ideally like to do this (pseudo-code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define wrEE(VAR, VAL) VAR = writeToEE(VAR ## Pos, VAL, VAR)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so that when I write this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wrEE(fanSpeed, 3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it will be expanded out to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;writeToEE(fanspeedPos, 3, fanspeed);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just don't know how to pass the 2nd argument (&quot;VAL&quot;) into the macro, which is the value being stored in the &quot;fanSpeed&quot; variable, in the &quot;fanSpeedPos&quot; location in the EEPROM. When I try to compile my pseudo code example (was hoping to get lucky!), I get the following error message: &quot;void value not ignored as it ought to be&quot;&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-05-10T15:44:23.083" Title="How to put 2 variables in a macro?" Tags="|c++|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24068" PostTypeId="2" ParentId="24065" CreationDate="2016-05-10T14:32:20.183" Score="3" Body="&lt;p&gt;You could use an MCP23017 port expander to get 16 more pins. It communicates via I2C. The pins can be set as inputs, outputs, or inputs with pullups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit has a library for the expander: &lt;a href=&quot;https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the datasheet: &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an alternate solution, you could just add another Arduino Mega to your project, and have them both communicate via serial. You could set up state machines on each one (like in Mr. Gammon's tutorials: &lt;a href=&quot;http://www.gammon.com.au/statemachine&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/statemachine&lt;/a&gt;) for fast communication. That way you could easily add an extra 52 pins to your project.&lt;/p&gt;&#xA;" OwnerUserId="11174" LastEditorUserId="4628" LastEditDate="2017-11-21T03:41:11.867" LastActivityDate="2017-11-21T03:41:11.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24069" PostTypeId="2" ParentId="24065" CreationDate="2016-05-10T14:47:17.127" Score="1" Body="&lt;p&gt;You can either use &lt;a href=&quot;http://playground.arduino.cc/Code/I2CPortExpander8574&quot; rel=&quot;nofollow&quot;&gt;external hardware&lt;/a&gt; or &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/MasterWriter&quot; rel=&quot;nofollow&quot;&gt;communicate to a 2nd Arduino&lt;/a&gt; and control the 2nd Arduino's digital and analog ports.  Being good at coding would suggest you would prefer communicating to a 2nd Arduino.  Also, most hardware solutions only add digital pins, not analog pins.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-10T14:47:17.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24070" PostTypeId="2" ParentId="24064" CreationDate="2016-05-10T15:07:39.177" Score="1" Body="&lt;p&gt;Network problems can be complex.  If these suggestions are not right I can change the answer later if other solutions present themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are connecting two Ethernet devices directly you may need a cross over cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test your connection with out using IP addresses, try to follow what is discussed in &lt;a href=&quot;https://askubuntu.com/questions/429901/how-can-i-ping-a-computer-or-a-printer-using-its-mac-address&quot;&gt;this answer&lt;/a&gt; where the MAC address is used on a Ubuntu system instead of the IP address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also might try using wireshark to monitor the Ubuntu box's Ethernet port.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.187" LastActivityDate="2016-05-10T15:07:39.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24071" PostTypeId="1" CreationDate="2016-05-10T11:50:07.557" Score="2" ViewCount="284" Body="&lt;p&gt;I am using this &lt;a href=&quot;https://github.com/watterott/SilentStepStick&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/watterott/SilentStepStick&lt;/a&gt; stepper driver to drive a stepper motor.&#xA;I am having trouble setting pins to HI-Z/floating to configure the stepper driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set the driver to 16 micro steps and full interpolation, one has to set 2 configuration pins to HI-Z/floating &lt;a href=&quot;http://www.trinamic.com/_scripts/download.php?file=_articles%2Fproducts%2Fintegrated-circuits%2Ftmc2100%2F_datasheet%2FTMC2100_datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;(datasheet, p.9)&lt;/a&gt;.&#xA;The example code on github (TMC2100.ino) just doesn't touch the pins at all, this works fine for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I only add the lines:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;pinMode(11, INPUT);  //connected to CFG1&#xA;pinMode(10, INPUT);  //connected to CFG2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should set the pins to HI-Z/floating, the result is different.&#xA;The motor turns at the same speed, but makes more noise, I believe the driver is using the 16 step method with no interpolation. This corresponds to both pins being interpreted as high. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This makes me believe, that the Arduino uses a different code at startup than being used in &lt;code&gt;pinMode(x, INPUT)&lt;/code&gt; to configure all pins. I am using a Teensy 3.1/3.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I solve the problem? Pins 11 and 10 are hard wired to the driver, as it replaced the well known A984.&#xA;Apart from the obvious &quot;don't configure the pins then&quot;, I would like to know what's going on here.&lt;/p&gt;&#xA;" OwnerDisplayName="user765269" LastEditorUserId="37523" LastEditDate="2019-06-30T21:19:46.113" LastActivityDate="2019-06-30T21:19:46.113" Title="arduino teensy no true HI-Z available?" Tags="|pins|teensy|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="24072" PostTypeId="2" ParentId="24067" CreationDate="2016-05-10T15:44:23.083" Score="0" Body="&lt;p&gt;In the parameter list of the &lt;code&gt;#define&lt;/code&gt; for the macro, separate the second argument from the first with only a comma.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define wrEE(speed,var) writeToEE((etc))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;void value not ignored as it ought to be&quot; error message is a consequence of trying to store the &lt;code&gt;void&lt;/code&gt; result of &lt;code&gt;writeToEE&lt;/code&gt;.  The solution is to not try to store it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C, variable, parameter, and constant names are case-sensitive.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-05-10T15:44:23.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24074" PostTypeId="1" CreationDate="2016-05-10T16:57:20.703" Score="2" ViewCount="2051" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hLkgh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hLkgh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ethernet shield problem. When running the WebServer example sketch, the Serial Monitor shows that &lt;code&gt;server is at 0.0.0.0&lt;/code&gt;. Any suggestions how to debug it?&lt;/p&gt;&#xA;" OwnerUserId="20948" LastEditorUserId="26916" LastEditDate="2016-10-10T00:46:38.837" LastActivityDate="2018-06-21T12:41:49.190" Title="Ethernet shield/WebServer problem: 'server is at 0.0.0.0'. Any suggestions how to debug it?" Tags="|arduino-uno|ethernet|web-server|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24076" PostTypeId="1" CreationDate="2016-05-10T17:22:48.377" Score="0" ViewCount="3545" Body="&lt;p&gt;I'm trying to read a string like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2;12;42;43;34&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;over a serial connection and split this string afterwards by a &quot;;&quot;.&#xA;So the output would be this array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(2,12,42,34)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All the stuff runs on an arduino uno. So I made some code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String read_input;&#xA;char read_input_char[20];&#xA;char *read_values;&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.setTimeout(10);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available()){&#xA;    read_input = Serial.readString();&#xA;    read_input.toCharArray(read_input_char, 20);&#xA;&#xA;    read_values = strtok(read_input_char, &quot;;&quot;);&#xA;    Serial.println(read_values[2]);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However now instead of outputting the 3rd array element it outputs only an '1'. What's wrong?&lt;/p&gt;&#xA;" OwnerUserId="20949" LastEditorUserId="20950" LastEditDate="2016-05-10T18:31:04.897" LastActivityDate="2016-05-11T17:25:53.763" Title="split serial.readString() output" Tags="|serial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24077" PostTypeId="2" ParentId="24076" CreationDate="2016-05-10T17:50:49.790" Score="2" Body="&lt;p&gt;This is a C question, not an arduino question, but anyway:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the man page:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DESCRIPTION&#xA;   The  strtok()  function  breaks a string into a sequence of zero or more nonempty tokens.  On the first call to strtok() the&#xA;   string to be parsed should be specified in str.  In each subsequent call that should parse the  same  string,  str  must  be&#xA;   NULL.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are only calling &lt;code&gt;strtok()&lt;/code&gt; once, so it only parses the first value. You need to keep calling it until there is nothing left to parse.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-10T17:50:49.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24078" PostTypeId="2" ParentId="24074" CreationDate="2016-05-10T17:56:24.600" Score="1" Body="&lt;p&gt;That's what it's supposed to be. It's called INADDR_ANY. Read an introductory text on networks and you'll understand what that means.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try to connect to the IP address you specified, you'll see that you can indeed connect.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-10T17:56:24.600" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24079" PostTypeId="1" AcceptedAnswerId="24080" CreationDate="2016-05-10T18:04:53.137" Score="0" ViewCount="944" Body="&lt;p&gt;Hi I am new to arduino development i was using esp8266 using software serial library&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;here is the code &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial monitor(2, 3); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;  monitor.begin(9600);&#xA;  Serial.begin(9600);&#xA;&#xA;  sendDebug(&quot;AT&quot;);&#xA;  delay(5000);&#xA;  Serial.println(&quot;Hello&quot;);&#xA;  if(monitor.find(&quot;OK&quot;))&#xA;  {&#xA;   Serial.println(monitor.available());&#xA;   Serial.println((int)monitor.read());&#xA;   Serial.println((int)monitor.read());&#xA;    Serial.println(monitor.available());&#xA;   Serial.println(&quot;RECEIVED: OK&quot;);&#xA;    //connectWiFi();&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;RECEIVED: None&quot;);&#xA;  }&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;}&#xA;&#xA;&#xA;void sendDebug(String cmd){&#xA;  monitor.println(cmd);&#xA;  Serial.println(&quot;Command: &quot;+cmd);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Output&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Command: AT&#xA;Hello&#xA;2&#xA;13&#xA;10&#xA;0&#xA;RECEIVED: OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;All I know is &lt;code&gt;monitor.available()&lt;/code&gt; return the available bytes that can be read and i can also deduce that these two &lt;strong&gt;bytes&lt;/strong&gt; are &lt;strong&gt;O&lt;/strong&gt; and &lt;strong&gt;K&lt;/strong&gt; but the integer value doesn't corresponds to the &lt;strong&gt;ascii&lt;/strong&gt; value of &lt;strong&gt;O&lt;/strong&gt; and &lt;strong&gt;K&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;can anyone explain what is actually getting printed on the serial monitor what is &lt;strong&gt;13&lt;/strong&gt; and &lt;strong&gt;10&lt;/strong&gt; ? ??&lt;/p&gt;&#xA;" OwnerUserId="20942" LastActivityDate="2016-05-10T18:52:51.020" Title="What is the output of Software Serial .read() function" Tags="|serial|arduino-ide|softwareserial|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24080" PostTypeId="2" ParentId="24079" CreationDate="2016-05-10T18:52:51.020" Score="1" Body="&lt;p&gt;It is just like &lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/Read&lt;/a&gt; : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;monitor.find(&quot;OK&quot;);&lt;/code&gt; already consumed the 'O' and the 'K' bytes, (see &lt;a href=&quot;https://www.arduino.cc/en/Serial/Find&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/Find&lt;/a&gt; ) then there were two bytes .available(), a 13=CarriageReturn and a 10=LineFeed, both returned by successive &lt;code&gt;monitor.read()&lt;/code&gt;s, then zero more bytes in monitor.available().&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-05-10T18:52:51.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24081" PostTypeId="1" CreationDate="2016-05-10T19:21:13.143" Score="2" ViewCount="8639" Body="&lt;p&gt;I've been playing with my Arduino for a few months. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, I just bought a shield that says it needs to be used with ATMEGA328P.  My box says I have a 328P, however, reading the chip, it's inscribed with &quot;ATMEL MEGA16U2&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that mean the box is wrong, or is that the same as 328P somehow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!!&lt;/p&gt;&#xA;" OwnerUserId="20952" LastEditorUserId="19515" LastEditDate="2016-05-11T03:51:22.807" LastActivityDate="2019-09-25T08:35:35.400" Title="Is ATMEGA328P the same as 16U2?" Tags="|arduino-mega|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24082" PostTypeId="2" ParentId="24081" CreationDate="2016-05-10T19:26:15.463" Score="4" Body="&lt;p&gt;The 16u2 is related to the ATmega328p, and includes USB, but is more limited in resources.   While it would be &lt;em&gt;possible&lt;/em&gt; to make an Arduino-type board from alone, this is unlikely to be what you have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather, it is likely that you have a board with an ATmega328p as the main processor, and &lt;em&gt;also&lt;/em&gt; a 16u2 which serves as a USB interface for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could know for sure from what board type you select in the dropdown menu of the Arduino IDE.  If you are selecting something like &quot;Uno&quot; or &quot;Duemilanove&quot; you have a 328p as the main processor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The other presently common type of board is the &quot;Leonardo&quot; style where a 32u4 - essentially a bigger version of the 16u2 - is used as a single-chip solution that is both the primary processor and the USB interface.  But if that is what you had, it would not say 16u2 on it, unless it was an attempt to make a more limited &quot;budget&quot; version).&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-10T21:58:07.560" LastActivityDate="2016-05-10T21:58:07.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24084" PostTypeId="1" CreationDate="2016-05-10T21:33:05.437" Score="1" ViewCount="124" Body="&lt;p&gt;I have several Arduino Pro Micro clones that are giving me an issue where they work immediately after being programmed while the USB cable is still connected, but as soon as I disconnect and reconnect the USB cable the program fails. I was able to break it down to the simplest form and found that the clock cycle is off by what I estimate to be almost a factor of 10.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For testing, the only command in the loop is &lt;code&gt;Serial.println(millis());&lt;/code&gt;. Immediately after programming you can watch the milliseconds scroll by in the serial monitor at the expected rate. Unplug and plug the USB, reconnect the serial monitor and now the milliseconds scroll by at about 1 second interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE version is 1.6.8 and have tested it from both a Mac and Ubuntu with the same results. Also tested on 4 different boards with the same results. I also tested the latest Arduino beta with no change. Next I'm going to download some older Arduino IDE versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&lt;/p&gt;&#xA;" OwnerUserId="20954" LastEditorUserId="4628" LastEditDate="2016-12-03T15:35:51.510" LastActivityDate="2017-04-02T20:59:49.343" Title="Arduino Pro Micro clone clock cycle issue" Tags="|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24087" PostTypeId="1" CreationDate="2016-05-11T01:24:38.120" Score="0" ViewCount="1201" Body="&lt;p&gt;I have some &lt;a href=&quot;https://www.adafruit.com/products/1361&quot; rel=&quot;nofollow&quot;&gt;velostat&lt;/a&gt; that I'd like to hook up to an Uno. At the risk of sounding dense...how do I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately wanting to get readings of pressure from the velostat, just not sure how or what wires to connect where.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-11T05:10:34.280" Title="How do I connect velostat to an arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24088" PostTypeId="1" AcceptedAnswerId="24102" CreationDate="2016-05-11T02:13:31.787" Score="0" ViewCount="349" Body="&lt;p&gt;I have a set of buttons and a set of NeoPixel LEDs. There's lots of very similar constants (&lt;code&gt;button1pin&lt;/code&gt;, &lt;code&gt;button2pin&lt;/code&gt;, etc) so there's almost certainly a more efficient way of coding this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, 2, NEO_RGBW + NEO_KHZ800);&#xA;&#xA;// Buttons&#xA;const int button1pin = 3;&#xA;const int button2pin = 4;&#xA;const int button3pin = 5;&#xA;const int button4pin = 6;&#xA;const int button5pin = 7;&#xA;const int button6pin = 8;&#xA;const int button7pin = 9;&#xA;const int button8pin = 10;&#xA;const int button9pin = 11;&#xA;&#xA;const int led1 = 0;&#xA;const int led2 = 1;&#xA;const int led3 = 2;&#xA;const int led4 = 3;&#xA;const int led5 = 4;&#xA;const int led6 = 5;&#xA;const int led7 = 6;&#xA;const int led8 = 7;&#xA;const int led9 = 8;&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show();&#xA;&#xA;  pinMode(button1pin, INPUT_PULLUP);&#xA;  pinMode(button2pin, INPUT_PULLUP);&#xA;  pinMode(button3pin, INPUT_PULLUP);&#xA;  pinMode(button4pin, INPUT_PULLUP);&#xA;  pinMode(button5pin, INPUT_PULLUP);&#xA;  pinMode(button6pin, INPUT_PULLUP);&#xA;  pinMode(button7pin, INPUT_PULLUP);&#xA;  pinMode(button8pin, INPUT_PULLUP);&#xA;  pinMode(button9pin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (digitalRead(button1pin) == LOW){&#xA;    strip.setPixelColor(led1, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button2pin) == LOW){&#xA;    strip.setPixelColor(led2, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button3pin) == LOW){&#xA;    strip.setPixelColor(led3, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button4pin) == LOW){&#xA;    strip.setPixelColor(led4, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button5pin) == LOW){&#xA;    strip.setPixelColor(led5, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button6pin) == LOW){&#xA;    strip.setPixelColor(led6, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button7pin) == LOW){&#xA;    strip.setPixelColor(led7, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button8pin) == LOW){&#xA;    strip.setPixelColor(led8, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;  if (digitalRead(button9pin) == LOW){&#xA;    strip.setPixelColor(led9, strip.Color(20, 55, 0, 0));&#xA;  }&#xA;&#xA;  strip.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-11T14:19:32.467" Title="How would I refactor this code, given how similar most of the lines are?" Tags="|arduino-uno|adafruit|code-optimization|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24089" PostTypeId="1" CreationDate="2016-05-11T02:33:45.283" Score="0" ViewCount="686" Body="&lt;p&gt;&lt;strong&gt;Updated&lt;/strong&gt;: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected my esp to external power, the blue light stays on, I start getting garbage data. &#xA;I used voltage regulator which was giving 3.4v, power supply tested with 1A &amp;amp;  2A. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Old problem :&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been trying to make ESP8266 since my last semester exams &amp;amp; now 2nd semester exams are going on. So i've been trying to make ESP8266 work for very long time. &#xA;Earlier it was firmware problem, i updated it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a lot it worked. I tried many libraries - but none worked, either some are using specific port or some want specific firmware version which is really hard to find &amp;amp; then flash.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using telnet to check. &#xA;When i disable code to send data - i can send data madly, it works &amp;amp; never hangs up. But as i use &lt;code&gt;AT+CPISEND&lt;/code&gt; after 1-2 read/write - it stops responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am powering using arduino with/out voltage divider. Its firmware - &lt;code&gt;0020000903&lt;/code&gt;, &lt;code&gt;AT Firmware v1.5&lt;/code&gt;, 4mb flash size, I changed baudrate to &lt;code&gt;9600&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is code i worte : &#xA;( I intentionally didn't remove comments)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.&#xA;#define DEBUG true&#xA;&#xA;SoftwareSerial esp8266(9,10); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.&#xA;                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2&#xA;                             // and the RX line from the esp to the Arduino's pin 3&#xA;void setup()&#xA;{&#xA;&#xA;  pinMode(11,OUTPUT);&#xA;  digitalWrite(11,LOW);&#xA;&#xA;  pinMode(12,OUTPUT);&#xA;  digitalWrite(12,LOW);&#xA;&#xA;  pinMode(13,OUTPUT);&#xA;  digitalWrite(13,LOW);&#xA;&#xA;&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); // your esp's baud rate might be different&#xA;&#xA;Serial.print(&quot;Sending at..&quot;);&#xA;  sendData(&quot;AT&quot;,2000,DEBUG);&#xA;  //sendData(&quot;AT+RST&quot;,2000,DEBUG); // reset module&#xA;  sendData(&quot;AT+CWMODE=1&quot;,1000,DEBUG);&#xA; // sendData(&quot;AT+CWLAP&quot;,1000,DEBUG);&#xA; //sendData(&quot;AT+CIOBAUD=9600&quot;,1000,DEBUG);&#xA; //sendData(&quot;AT+UART=9600,8,1,0,0&quot;,1000,DEBUG);&#xA; //sendData(&quot;AT+IPR=9600&quot;,1000,DEBUG);&#xA; // sendData(&quot;AT+CWJAP_DEF=\&quot;mad\&quot;,\&quot;agentis47?orBond?\&quot;&quot;,15000,DEBUG);&#xA; //sendData(&quot;AT+CWMODE=2\r\n&quot;,1000,DEBUG); // configure as access point&#xA;  sendData(&quot;AT+CIFSR&quot;,1000,DEBUG); // get ip address&#xA;  sendData(&quot;AT+CIPMUX=1&quot;,1000,DEBUG); // configure for multiple connections&#xA;  sendData(&quot;AT+CIPSERVER=1,80&quot;,1000,DEBUG); // turn on server on port 80&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  if(esp8266.available()) // check if the esp is sending a message &#xA;  {&#xA;&#xA;    while(esp8266.available())&#xA;    {&#xA;      // The esp has data so display its output to the serial window &#xA;      char c = esp8266.read(); // read the next character.&#xA;      Serial.write(c);&#xA;    } &#xA;&#xA;    //Serial.println(&quot;IPD Search &quot;+(len));&#xA;    if(esp8266.find(&quot;+IPD,&quot;))&#xA;    {&#xA;&#xA;     delay(20); // wait for the serial buffer to fill up (read all the serial data)&#xA;     // get the connection id so that we can then disconnect&#xA;     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns &#xA;                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48&#xA;&#xA;     esp8266.read(); //skip the comma ','&#xA;     //(CIPMUX=0): + IPD, &amp;lt;len&amp;gt;:&#xA;     //(CIPMUX=1): + IPD, &amp;lt;id&amp;gt;, &amp;lt;len&amp;gt;: &amp;lt;data&amp;gt;&#xA;     int len = (readUntil(&quot;:&quot;)).toInt();&#xA;     if(len&amp;gt;500) len = 500; //prevent extra data we won't be sending more than 500bytes in one go. &#xA;     char data[len];&#xA;&#xA;     esp8266.readBytes(data, len);&#xA;     //data[len-2]='\0';&#xA;&#xA;&#xA;      int pinNumber = (data[0]-48)*10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10&#xA;     pinNumber += ((data[1])-48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number&#xA;&#xA;       digitalWrite(pinNumber, !digitalRead(pinNumber)); &#xA;    Serial.println(String(len));&#xA;&#xA;     /*Serial.println(&quot;===&quot;);&#xA;&#xA;     Serial.println(&quot;--&quot;);&#xA;*/&#xA;    //cleanBuffer();&#xA;    //delay(10);&#xA;     //Serial.println(&quot;Sendddiddding data&quot;);&#xA;     //sendData(connectionId,String(&quot;OK&quot;));&#xA;     //Serial.println(&quot;Sent&quot;);     &#xA;     //closeConnection(connectionId);&#xA;&#xA;&#xA;     //digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin    &#xA;&#xA;     // make close command&#xA;     //String closeCommand = &quot;AT+CIPCLOSE=&quot;; &#xA;     //closeCommand+=connectionId; // append connection id&#xA;     //closeCommand+=&quot;\r\n&quot;;&#xA;&#xA;     //sendData(closeCommand,1000,DEBUG); // close connection&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void cleanBuffer(){&#xA;  while(esp8266.available())&#xA;    {&#xA;      // The esp has data so display its output to the serial window &#xA;      char c = esp8266.read(); // read the next character.&#xA;      Serial.write(c);&#xA;    }&#xA;}&#xA;&#xA;String sendData(int connectionId, String data){&#xA;  //Serial.println(&quot;AT+CIPSEND=&quot;+String(connectionId)+ &quot;,&quot;+String(data.length()));&#xA;  //sendData(&quot;AT+CIPSEND=&quot;+String(connectionId)+ &quot;,&quot;+String(data.length()),1000,DEBUG);&#xA;  //sendData(data,100,DEBUG);&#xA;  //closeConnection(connectionId);&#xA;  String webpage = &quot;&amp;lt;h1&amp;gt;Hello&amp;lt;/h1&amp;gt;&amp;amp;lth2&amp;gt;World!&amp;lt;/h2&amp;gt;&amp;lt;button&amp;gt;LED1&amp;lt;/button&amp;gt;&quot;;&#xA;&#xA;     String cipSend = &quot;AT+CIPSEND=&quot;;&#xA;     cipSend += connectionId;&#xA;     cipSend += &quot;,&quot;;&#xA;     cipSend +=webpage.length();&#xA;     cipSend +=&quot;\r\n&quot;;&#xA;&#xA;     sendData(cipSend,1000,DEBUG);&#xA;     sendData(webpage,1000,DEBUG);&#xA;&#xA;     webpage=&quot;&amp;lt;button&amp;gt;LED2&amp;lt;/button&amp;gt;&quot;;&#xA;&#xA;     cipSend = &quot;AT+CIPSEND=&quot;;&#xA;     cipSend += connectionId;&#xA;     cipSend += &quot;,&quot;;&#xA;     cipSend +=webpage.length();&#xA;&#xA;&#xA;     sendData(cipSend,1000,DEBUG);&#xA;     sendData(webpage,1000,DEBUG);&#xA;&#xA;     String closeCommand = &quot;AT+CIPCLOSE=&quot;; &#xA;     closeCommand+=connectionId; // append connection id&#xA;&#xA;&#xA;     sendData(closeCommand,3000,DEBUG);&#xA;&#xA; /*&#xA;  Serial.println(&quot;finding prompt&quot;);&#xA;  if(esp8266.find(&quot;&amp;gt;&quot;))    //prompt offered by esp8266&#xA;  {&#xA;    Serial.println(&quot;Sending data&quot;);&#xA;   // Serial.println(&quot;found &amp;gt; prompt - issuing GET request&quot;);  //a debug message&#xA;    esp8266.println(data);  //this is our http GET request&#xA;  }&#xA;  else&#xA;  {&#xA;    closeConnection(connectionId);&#xA;    Serial.println(&quot;No '&amp;gt;' prompt received after AT+CPISEND&quot;);&#xA;  }&#xA;*/&#xA;}&#xA;&#xA;String closeConnection(int connectionId){&#xA;    sendData(&quot;AT+CIPCLOSE=&quot;+String(connectionId),100,DEBUG);&#xA;}&#xA;&#xA;String readUntil(String delimiter){&#xA;  String response = &quot;&quot;;  &#xA;  char c; &#xA;  unsigned int dLen = delimiter.length(),n=0;&#xA;&#xA;    while(esp8266.available()&amp;amp;&amp;amp;(c= esp8266.read())){&#xA;      n= (c==delimiter[n])?n+1:0;&#xA;      if(n==dLen) break; &#xA;      response+=c;&#xA;    }&#xA;   return response;&#xA;}&#xA;&#xA;void sendRaw(String data){&#xA;esp8266.print(data);&#xA;}&#xA;&#xA;String sendCommand(String command){&#xA;  esp8266.print(command); // send the read character to the esp8266&#xA;  esp8266.print(&quot;\r\n&quot;);&#xA;  esp8266.flush();&#xA;}&#xA;&#xA;String sendData(String command, const int timeout, boolean debug)&#xA;{&#xA;    String response = &quot;&quot;;&#xA;    esp8266.print(command); // send the read character to the esp8266&#xA;    esp8266.print(&quot;\r\n&quot;);&#xA;    esp8266.flush();&#xA;    long int time = millis();&#xA;&#xA;    do&#xA;    {&#xA;      while(esp8266.available())&#xA;      {&#xA;&#xA;        // The esp has data so display its output to the serial window &#xA;        char c = esp8266.read(); // read the next character.&#xA;        response+=c;&#xA;      }  &#xA;    }while( (time+timeout) &amp;gt; millis());&#xA;    if(debug)&#xA;    {&#xA;      Serial.print(response);&#xA;    }    &#xA;    return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please help, I am stuck, Is there any other cheaper &amp;amp; better solution ? I am only looking for Wifi.&lt;/p&gt;&#xA;" OwnerUserId="13500" LastEditorUserId="13500" LastEditDate="2016-05-17T04:29:12.687" LastActivityDate="2016-05-17T04:29:12.687" Title="ESP8266 - CIPSEND &amp; external power supply Hangs program" Tags="|serial|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24090" PostTypeId="1" AcceptedAnswerId="24093" CreationDate="2016-05-11T04:19:23.677" Score="0" ViewCount="754" Body="&lt;p&gt;I am looking  at this(&lt;a href=&quot;http://www.instructables.com/id/Chappie-Self-Balancing-Robot/&quot; rel=&quot;nofollow&quot;&gt;instructable with circuit picture&lt;/a&gt;) tutorial for making a self-balancing robot. However, I am confused about how the battery connects to the arduino. I know the 12 V must go to the motors to power them yet the diagram shows wires connecting to the Arduino through some kind of green device. I assume this connects to the power supply . However I do not have this green device and I don't know how to connect to the power supply. How should I get a charger cable and solder on the battery wires to the charger? If so are there any tutorials? Is the connection to the Arduino necessary? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(please look at the Firizing diagram in the instructable)&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="14820" LastActivityDate="2016-05-11T06:04:04.543" Title="connect arduino to battery with 12V motor" Tags="|motor|battery|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24091" PostTypeId="2" ParentId="24087" CreationDate="2016-05-11T05:10:34.280" Score="1" Body="&lt;p&gt;Usually a variable resistance sensor is used in a voltage divider circuit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E2LeV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E2LeV.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the above example a thermistor is connected to the positive supply and a pull down R1 is connected to ground.  The voltage where they meet is measured using one of the Arduino's analog inputs pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Choosing R1 is tricky.  If it is too large compared to the variable resistance sensor the voltage fluctuation at Vout will be too small to measure.  The same problem exists if R1 is too small compared to the variable resistance sensor.  Also, you need to mind the current through the sensor.  If the combined resistance of R1 and the sensor is too small the current may damage the sensor, over heat R1 and / or put a heavy drain on your power source.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-11T05:10:34.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24093" PostTypeId="2" ParentId="24090" CreationDate="2016-05-11T06:04:04.543" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am looking at this(instructable with circuit picture) tutorial for making a self-balancing robot. &#xA;  However, I am confused about how the battery connects to the arduino. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, it seems he has attached a 9V battery through a voltage regulator, to the Arduino.&#xA;Which is bullshit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can put the 9V directly into the barrel-jack of the Arduino. You actually should. Putting 5V on the barrel jack is not within the specs. (&lt;a href=&quot;https://www.arduino.cc/en/main/arduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/main/arduinoBoardUno&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I know the 12 V must go to the motors to power them yet the diagram shows wires connecting to the Arduino through some kind of green device. I assume this connects to the power supply . However I do not have this green device and I don't know how to connect to the power supply. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well, the motors only get 9V in this diagram (which might work neverthless). But bear in mind that 9V batteries won't last long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you mean by &quot;Green device&quot;, the HC-05 or the L293D?&#xA;Anyway, the L293D are quadruple high-current half-H drivers, which basically is a way to switch 12V on/off/invert based on the 5V inputs (from Arduino).&#xA;You could do this with some circuitry, but I suggest picking up a &quot;motor driver (arduino)&quot;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How should I get a charger cable and solder on the battery wires to&#xA;  the charger? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can't charge regular 9V batteries.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the connection to the Aruino necessary?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The specific connection he shows? No.&#xA;Power to the Arduino board? Yes.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-11T06:04:04.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24094" PostTypeId="2" ParentId="24089" CreationDate="2016-05-11T07:12:15.907" Score="1" Body="&lt;p&gt;If you are powering it using Arduino 3.3V pin it is no wonder it does not work. &#xA;ESP8266 uses more power than Arduino can provide. Power pin on arduino is about 50ma. ESP8266 in receive or send mode uses much more and either halts or restarts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://bbs.espressif.com/viewtopic.php?t=133&quot; rel=&quot;nofollow&quot;&gt;A table of ESP8266 power consumption can be found here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-05-11T07:12:15.907" CommentCount="19" ContentLicense="CC BY-SA 3.0" />
  <row Id="24097" PostTypeId="2" ParentId="1177" CreationDate="2016-05-11T07:29:39.173" Score="1" Body="&lt;p&gt;I have done this, and had (some limited) success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of your connections are wrong;&#xA;Connect both the pin 7s on the shield and MEGA, not the pin 4s. Pin 7 is the reset pin - I think that GSM.begin resets the shield before doing anything. This might help with Q1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure that you use the regulated 5V output on the MEGA, and not the Vin to power your shield. Vin is whatever voltage is connected to the MEGA power socket, and could damage your shield. I personally have not noticed any difference when powering the MEGA+Shield from USB or external 12V supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had problems with interference when I used wires to connect shield to MEGA. The stacking seems to have reduced this problem, but not eliminated it by any means...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GSM Web server is unlikely to work except maybe from within your SIM provider's own network. Some of the limitations are mentioned here;&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/GSMToolsTestWebServer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/GSMToolsTestWebServer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20967" LastActivityDate="2016-05-11T07:29:39.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24102" PostTypeId="2" ParentId="24088" CreationDate="2016-05-11T14:19:32.467" Score="0" Body="&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, 2, NEO_RGBW + NEO_KHZ800);&#xA;// The maximum pin number for the buttons&#xA;const int MaxButton = 11;&#xA;// The value if the pin is not connected to an LED&#xA;const int NotConnected = -1;&#xA;// The connections from buttons to leds.&#xA;const int Connections[MaxButton+1] = {NotConnected, NotConnected, NotConnected, 0, 1, 2, 3, 4, 5, 6, 7, 8};&#xA;&#xA;void setup()&#xA;{&#xA;  strip.begin();&#xA;  strip.show();&#xA;  for (int pinNumber = 0; pinNumber &amp;lt;= MaxButton; ++pinNumber)&#xA;  {&#xA;    if (Connections[pinNumber] != NotConnected)&#xA;    {&#xA;        pinMode(pinNumber, INPUT_PULLUP);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for (int pinNumber = 0; pinNumber &amp;lt;= MaxButton; ++pinNumber)&#xA;  {&#xA;    if (Connections[pinNumber] != NotConnected)&#xA;    {&#xA;        if (digitalRead(pinNumber) == LOW)&#xA;        {&#xA;            strip.setPixelColor(Connections[pinNumber], strip.Color(20, 55, 0, 0));&#xA;        }&#xA;    }&#xA;  }&#xA;  strip.show();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't test it, so I have no idea if it works, but it should do.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-11T14:19:32.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24103" PostTypeId="1" AcceptedAnswerId="24104" CreationDate="2016-05-11T15:00:17.490" Score="0" ViewCount="3540" Body="&lt;p&gt;I am getting this error on compilation of the code given further below;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;warning: iteration 3u invokes undefined behavior [-Waggressive-loop-optimizations]&lt;/p&gt;&#xA;&lt;p&gt;leds[XY (x, y)].r = redarray[x][y];&lt;br /&gt;&#xA;note: containing loop&#xA;for(uint8_t x=0; x &amp;lt; MatrixWidth; x++){&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; // the header files for the RGB data&#xA;&#xA;#include &amp;lt;FastLED.h&amp;gt;&#xA;#include &amp;quot;redarray.h&amp;quot;   &#xA;#include &amp;quot;greenarray.h&amp;quot;   //g data header file (hex or dec)&#xA;#include &amp;quot;bluearray.h&amp;quot;   //b data header file (hex or dec)*/&#xA;&#xA; //matrix parameters&#xA;&#xA;#define MatrixWidth 36 //columns (x)&#xA;#define MatrixHeight 1 //rows (y)&#xA;#define numled (MatrixWidth * MatrixHeight)&#xA;&#xA;//pin details&#xA;&#xA;#define datapin 7&#xA;&#xA;#define clockpin 8&#xA;&#xA;CRGB leds[MatrixWidth * MatrixHeight];&#xA;&#xA;const bool  MatrixSerpentineLayout = true;&#xA;&#xA;void setup() {&#xA;&#xA;   FastLED.addLeds&amp;lt;APA102, datapin, clockpin&amp;gt;(leds,numled);&#xA;   FastLED.clear();&#xA;         }&#xA;&#xA;void loop() {    &#xA;   for(uint8_t y=0 ; y&amp;lt;1 ; y++){&#xA;     for(uint8_t x=0; x &amp;lt; MatrixWidth; x++){ &#xA;         leds[XY (x, y)].r = redarray[x][y];&#xA;         leds[XY (x, y)].g = 0;&#xA;         leds[XY (x, y)].b = 0;&#xA;&#xA;         FastLED.show(); &#xA;         delay(50);         &#xA;     }&#xA;   }   &#xA; }&#xA;&#xA;  uint16_t XY( uint8_t x, uint8_t y)  &#xA;  {&#xA;      uint16_t i;&#xA;&#xA;      if( MatrixSerpentineLayout == true) {&#xA;          if( y &amp;amp; 0x01) {&#xA;          // Odd rows run backwards&#xA;          uint8_t reverseX = (MatrixWidth - 1) - x;&#xA;          i = (y * MatrixWidth) + reverseX;&#xA;    } else {&#xA;         // Even rows run forwards&#xA;         i = (y * MatrixWidth) + x;&#xA;    }&#xA;}  &#xA;   return i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following is redarray header -&lt;/p&gt;&#xA;&lt;p&gt;//RED&#xA;const byte redarray[3][36] PROGMEM = {&#xA;{0x00,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},&#xA;{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},&#xA;{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}&lt;/p&gt;&#xA;&lt;p&gt;};&lt;/p&gt;&#xA;&lt;p&gt;How to remove this warning. The redarray is not being read properly by arduino. THe above code should make the 36 LEDs turn off (black) as per the header file. They are randomly lit red... I am totally perplexed!&lt;/p&gt;&#xA;&lt;p&gt;Plz help if somebody can.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20119" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-11T19:32:54.210" Title="What does this error mean?? Arduino Due loop warning" Tags="|arduino-due|rgb-led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24104" PostTypeId="2" ParentId="24103" CreationDate="2016-05-11T15:10:04.213" Score="2" Body="&lt;p&gt;&lt;code&gt;MatrixWidth&lt;/code&gt; is 36. &lt;code&gt;redarray[]&lt;/code&gt; has 3 elements. The compiler has detected that your code will likely blow up on the 4th go through the loop. Make sure your code is accessing the dimensions correctly.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-11T15:10:04.213" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="24107" PostTypeId="1" AcceptedAnswerId="24115" CreationDate="2016-05-11T09:44:57.013" Score="1" ViewCount="830" Body="&lt;p&gt;I've got a CNC machine and I recently started using a spindle for it. At first it was running smoothly with no issues, but after the first brush pair wore off (I've replaced them later on) it started interfering with the Arduino/gshield and pc monitor. The monitor displays a &quot;no signal&quot; message, although after turning off the spindle or turning it to a low speed the signal comes back. The other problem is that after running a long job, sometimes the gshield disconnects and the job stops midway. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;What part could be causing all this interference?&lt;/li&gt;&#xA;&lt;li&gt;How can I shield that part so it stops interfering with other electronics?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I am using the following hardware:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;600 watt spindle&lt;/li&gt;&#xA;&lt;li&gt;600 watt power supply with variable speed&lt;/li&gt;&#xA;&lt;li&gt;the wires from the spindle to the power supply are not shielded, although Ive tried covering them with aluminium foil, not sure if that should be of any benefit, I've read it somewhere so I gave it a try.&lt;/li&gt;&#xA;&lt;li&gt;Gshield with Arduino, connected to a Raspberry pi.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;All the electronics are within 70 cm radius.&lt;/p&gt;&#xA;" OwnerUserId="20983" OwnerDisplayName="Omar K" LastEditorUserId="3742" LastEditDate="2016-05-15T02:13:00.140" LastActivityDate="2016-05-15T02:13:00.140" Title="Electric interference from cnc spindle" Tags="|motor|electronics|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24108" PostTypeId="2" ParentId="24076" CreationDate="2016-05-11T17:25:53.763" Score="1" Body="&lt;p&gt;Your code as is checks for a non-empty Serial buffer (the Serial.available() bit), and then reads it all into a String. Be careful doing this, as if this happens to execute part-way through the data arriving, you will get a partial data String. This may be cut off part way through one of your integers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the String object is very memory-intensive. Maybe not an issue for you, but try to use char arrays, or read directly from the Serial buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case, there is a great function that you could use; parseInt().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Details are at; &lt;a href=&quot;https://www.arduino.cc/en/Serial/ParseInt&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/ParseInt&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More or less, this reads successive chars from the serial buffer, and once digits are encountered, forms an int. This continues until a non-digit char, or a (configurable) timeout. Something like this might do the job for you;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int data[10]; // Or however long you need it to be!&#xA;int arrayPointer = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.setTimeout(10);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) {&#xA;    int incomingInt = Serial.parseInt();&#xA;    Serial.println(incomingInt);&#xA;    data[arrayPointer] = incomingInt;&#xA;    arrayPointer++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps!&lt;/p&gt;&#xA;" OwnerUserId="20967" LastActivityDate="2016-05-11T17:25:53.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24109" PostTypeId="1" CreationDate="2016-05-11T19:19:49.907" Score="0" ViewCount="444" Body="&lt;p&gt;I am doing a project with a receiver and transmitter and i am trying to get a message to print onto the screen. If anybody has any experience with this could you please help! I am trying to use a switch case command and it's not working.&#xA;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;`&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;LiquidCrystal lcd(12, 8, 5, 4, 3, 2);&#xA;byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages&#xA;byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Device is ready&quot;);&#xA;&#xA;  // Initialize the IO and ISR&#xA;  vw_setup(2000); // Bits per sec&#xA;  vw_rx_start(); // Start the receiver&#xA;  lcd.begin(16, 2);&#xA;&#xA;  // Print a message to the LCD.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (vw_get_message(message, &amp;amp;messageLength)) // Non-blocking&#xA;  {&#xA;    switch(message[1])&#xA;    {&#xA;    case 0:&#xA;      lcd.setCursor(0, 1);&#xA;      lcd.print(&quot;O.O&quot;);&#xA;      break;&#xA;    case 1 :&#xA;      lcd.setCursor(0, 1);&#xA;      lcd.print(&quot;Hi! :)&quot;);&#xA;      break;&#xA;    }&#xA;    {&#xA;      Serial.print(&quot;Received: &quot;);&#xA;      for (int i = 0; i &amp;lt; messageLength; i++)&#xA;      {&#xA;        Serial.write(message[i]);&#xA;      }&#xA;      Serial.println();&#xA;    }&#xA;  }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20978" LastEditorUserId="19886" LastEditDate="2016-05-12T05:01:18.773" LastActivityDate="2016-05-16T15:25:39.233" Title="Need Help with Switch Case commands/receiver and lcd screen project?" Tags="|programming|arduino-nano|lcd|" AnswerCount="1" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24110" PostTypeId="1" CreationDate="2016-05-11T18:30:24.573" Score="0" ViewCount="13561" Body="&lt;p&gt;When arduino starts up, RX TX lights doesn't blink. Only the PIN 13 and Green light turns on. Pin 13 light blinks thrice before getting stable. RX TX lights are not blinking at all. I am not able to upload any sketches. The error I get is &quot;Not in sync resp=0x00&quot; or &quot;Programmer not responding&quot; or &quot;Not in sync resp=0x95&quot; or &quot;Not in sync resp=0x69&quot; and so on. A new error everytime. Most probably the error is with serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A brief history of what I have done&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a Relay which is operated at 12V. But Arduino works at 5V logic. So I used a comparator (IC741) to improve the logic (By setting Vcc and -Vcc at 12 and 0 and the input pins connected to arduino). I also connected HC-05 bluetooth module to use the relay using my cellphone. You know what I was trying was home automation. Also Arduino was connected to 12V DC supply (I think this was my mistake). Everything was going right.                            &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suddenly IC741 started burning,maybe I shorted some pins when I was trying to measure the voltages using multimeter. I quickly removed it. Suddenly HC 05 started burning. I immediately removed all the connections. After some time I turned on Arduino again (This time using USB connected to laptop). I connected HC05. The bluetooth module heats up again. I thought the module is now gone. I turned to check Arduino and as I stated I am unable to upload any more sketches. Most probably the bluetooth module cause an error in serial communication. May be not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is&#xA;1. What's the real problem. Is my bluetooth module gone? Or is Arduino gone? If arduino is still fine, how can I get the serial to work back and enable me to upload sketches? &#xA;2. If Arduino is gone, most probably the microcontroller Atmega328 is still fine. How can I use it now without Arduino (I don't have any extra Arduino)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I have already tried :&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Loopback test : No echo back. Serial data can neither be sent nor received.&lt;/li&gt;&#xA;&lt;li&gt;When I open the Serial window, Arduino doesn't resets as it it earlier.&lt;/li&gt;&#xA;&lt;li&gt;RX TX Vin and 5V pin reads 4.99V. I hope they are fine.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20990" OwnerDisplayName="Sushant" LastActivityDate="2018-01-28T06:33:09.243" Title="Arduino Uno's RX and TX lights not blinking. Unable to upload sketches!" Tags="|relay|bluetooth|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24111" PostTypeId="2" ParentId="24110" CreationDate="2016-05-11T18:44:47.367" Score="0" Body="&lt;p&gt;Can you test the bluetooth module separately? i.e. just connect the power pins directly to the correct voltage source, and check if it overheats.  In this way you may be able to find the source of the short circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you shorted one or more of your arduino's I/O pins, you may have damaged your Atmega328 chip, since there's no protection between the chip and IO headers.  The other circuitry on the Arduino board is mostly power conditioning/regulation.  So I'm assuming that's not the problem.&#xA;Check if your 328 is getting the correct voltage at the VCC pin, to eliminate the power circuitry as the problem.&lt;/p&gt;&#xA;" OwnerUserId="15684" OwnerDisplayName="Ryan Griggs" LastActivityDate="2016-05-11T18:44:47.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24112" PostTypeId="2" ParentId="24110" CreationDate="2016-05-11T18:57:49.697" Score="0" Body="&lt;p&gt;If you are getting three blinks, most likely bootloader is fine but don't take it for granted. Also, post a schematic and picture of your original setup to get better answers in future. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how you should start the debugging process:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Disconnect everything from Arduino especially from Tx Rx pins, and try to dump the blinky sketch. If it works, then arduino is good. If it doesn't work, follow &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; to burn a fresh bootloader in your atmega. Check again. If not able to burn bootloader or code afterwards, get a new atmega IC for cheap and replace the damaged one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Check the voltage requirements for HC-05 whether it's 3.3V or 5V. Make sure you are not giving it a higher voltage. If it starts to smoke as soon as you connect the GND VCC, then probably it has been damaged. Measure the resistance between GND and VCC of HC-05 before attaching. If it's less than 10-20 ohms, you already know that it's damaged.&lt;/p&gt;&#xA;" OwnerUserId="7553" OwnerDisplayName="Whiskeyjack" LastActivityDate="2016-05-11T18:57:49.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24113" PostTypeId="2" ParentId="24109" CreationDate="2016-05-11T22:38:00.703" Score="1" Body="&lt;p&gt;Too many pieces of the puzzle are missing for us to venture a guess on what is going wrong:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The output you get (both in the LCD and the serial console)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The message sent&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;One thing that strikes me as a potential problem is the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch(message[1])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;line. If you want to check the first character received, it should be &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;switch(message[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That said, it would perhaps help you if you tried to split the program into pieces and make sure each one works before advancing to the next. Are you sure the LCD pin connections and initialisation line match? (I know from experience it is very easy to mess up and put the pin numbers in the wrong order). It would help to put the following code right after the lcd.begin line (in your setup() function):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Initialised!&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if this line doesn't display correctly, you will know it is the lcd connection/initialisation code that is at fault. Otherwise, you will concentrate on your communication code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give us more information and we 'll be able to help more.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastEditorUserId="19886" LastEditDate="2016-05-16T15:25:39.233" LastActivityDate="2016-05-16T15:25:39.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24114" PostTypeId="1" AcceptedAnswerId="32745" CreationDate="2016-05-11T22:43:02.223" Score="0" ViewCount="5180" Body="&lt;p&gt;I am currently making a design that uses the Arduino's Ethernet shield. I am using the PushingBox API for Arduino, and have tried it with my Arduino Mega (2560) with the ethernet shield attached to the router. When I did this, however, it displayed a message on my serial monitor saying &lt;code&gt;Failed to configure Ethernet using DHCP&lt;/code&gt;. The model for my Ethernet Shield is a &lt;a href=&quot;http://www.seeedstudio.com/depot/W5200-Ethernet-Shield-p-1577.html?user_country=CN&quot; rel=&quot;nofollow&quot;&gt;W5200 Seeed Studio Ethernet Shield&lt;/a&gt;, and I am using the libraries that Arduino provides. I do not have an SD card inserted and the DHCP on all other wired devices works. Any help is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code (in case):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;  /////////////////&#xA; // MODIFY HERE //&#xA;/////////////////&#xA;byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };   // Be sure this address is unique in your network&#xA;&#xA;&#xA;//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want&#xA;char DEVID1[] = &quot;{[I have replaced this with my DevID]}&quot;;        //Scenario : &quot;The mailbox is open&quot;&#xA;&#xA;//Numeric Pin where you connect your switch&#xA;uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3&#xA;&#xA;// Debug mode&#xA;boolean DEBUG = true;&#xA;  //////////////&#xA; //   End    //&#xA;//////////////&#xA;&#xA;&#xA;char serverName[] = &quot;api.pushingbox.com&quot;;&#xA;boolean pinDevid1State = false;                // Save the last state of the Pin for DEVID1&#xA;boolean lastConnected = false;                 // State of the connection last time through the main loop&#xA;&#xA;&#xA;// Initialize the Ethernet client library&#xA;// with the IP address and port of the server &#xA;// that you want to connect to (port 80 is default for HTTP):&#xA;EthernetClient client;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(pinDevid1, INPUT);&#xA;&#xA;  // start the Ethernet connection:&#xA;  if (Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;    Serial.println(&quot;Please reconfigure the settings and try again.&quot;);&#xA;    // no point in carrying on, so do nothing forevermore:&#xA;    while(true);&#xA;  }&#xA;  else{&#xA;    Serial.println(&quot;Ethernet ready&quot;);&#xA;    // print the Ethernet board/shield's IP address:&#xA;    Serial.print(&quot;My IP address: &quot;);&#xA;    Serial.println(Ethernet.localIP());&#xA;  }&#xA;  // give the Ethernet shield a second to initialize:&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;      ////&#xA;      // Listening for the pinDevid1 state&#xA;      ////&#xA;      if (digitalRead(pinDevid1) == HIGH &amp;amp;&amp;amp; pinDevid1State == false) // switch on pinDevid1 is ON &#xA;      {&#xA;        if(DEBUG){Serial.println(&quot;pinDevid1 is HIGH&quot;);}&#xA;        pinDevid1State = true;&#xA;        //Sending request to PushingBox when the pin is HIGH&#xA;        sendToPushingBox(DEVID1);&#xA;      }&#xA;       if (digitalRead(pinDevid1) == LOW &amp;amp;&amp;amp; pinDevid1State == true) // switch on pinDevid1 is OFF&#xA;      {&#xA;        if(DEBUG){Serial.println(&quot;pinDevid1 is LOW&quot;);}&#xA;        pinDevid1State = false;&#xA;        //Sending request to PushingBox when the pin is LOW&#xA;        //sendToPushingBox(DEVID1);    //Here you can run an other scenario by creating a DEVID2 variable&#xA;      }&#xA;&#xA;&#xA;      //DEBUG part&#xA;      // this write the respons from PushingBox Server.&#xA;      // You should see a &quot;200 OK&quot;&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        if(DEBUG){Serial.print(c);}&#xA;      }&#xA;&#xA;      // if there's no net connection, but there was one last time&#xA;      // through the loop, then stop the client:&#xA;      if (!client.connected() &amp;amp;&amp;amp; lastConnected) {&#xA;        if(DEBUG){Serial.println();}&#xA;        if(DEBUG){Serial.println(&quot;disconnecting.&quot;);}&#xA;        client.stop();&#xA;      }&#xA;      lastConnected = client.connected();&#xA;}&#xA;&#xA;&#xA;//Function for sending the request to PushingBox&#xA;void sendToPushingBox(char devid[]){&#xA;  client.stop();&#xA;  if(DEBUG){Serial.println(&quot;connecting...&quot;);}&#xA;&#xA;  if (client.connect(serverName, 80)) {&#xA;    if(DEBUG){Serial.println(&quot;connected&quot;);}&#xA;&#xA;    if(DEBUG){Serial.println(&quot;sendind request&quot;);}&#xA;    client.print(&quot;GET /pushingbox?devid=&quot;);&#xA;    client.print(devid);&#xA;    client.println(&quot; HTTP/1.1&quot;);&#xA;    client.print(&quot;Host: &quot;);&#xA;    client.println(serverName);&#xA;    client.println(&quot;User-Agent: Arduino&quot;);&#xA;    client.println();&#xA;  } &#xA;  else {&#xA;    if(DEBUG){Serial.println(&quot;connection failed&quot;);}&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the code for the DHCP error is removed, it does display an external IP address, but actual HTTP requests do not work. I tried port forwarding and that did not work either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Now, unusually, it gives me an IP address WITHOUT the ethernet cord connected.&lt;/p&gt;&#xA;" OwnerUserId="20068" LastEditorUserId="20068" LastEditDate="2016-05-12T17:24:45.343" LastActivityDate="2016-12-28T18:35:19.993" Title="Ethernet Shield: Failed to configure Ethernet using DHCP" Tags="|arduino-mega|ethernet|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="24115" PostTypeId="2" ParentId="24107" CreationDate="2016-05-11T22:48:42.833" Score="0" Body="&lt;p&gt;I would guess that arcing in the spindle causes spikes that travel through the power supplies and power wires. One thing you could try is to use a really long extension cord (say 15 meters or more) to power the spindle power supply. You can insert this cord to a different power outlet to gain additional distance.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-05-11T22:48:42.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24116" PostTypeId="1" AcceptedAnswerId="24117" CreationDate="2016-05-11T22:53:06.497" Score="0" ViewCount="748" Body="&lt;p&gt;I have a camera I'm planning on attaching to an arduino uno, that I want to take pictures and extract the average RGB value from each image.&lt;br&gt;&#xA;&lt;a href=&quot;https://www.adafruit.com/product/397&quot; rel=&quot;nofollow&quot;&gt;This is the camera&lt;/a&gt; I have, but I've now realized that it takes pre-compressed JPEG images, and so I cannot make use of the data it's giving me.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I realize that an arduino is not the optimal tool to use in this case, but I'm curious as to whether there would be any way to decompress the images and convert them to a format I could use. It does not need to be fast, and I do not need to take the pictures quickly. I have experience with programming but have not done many projects with the arduino, so any help or advice is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="20984" LastActivityDate="2016-05-11T23:26:01.620" Title="Getting RGB values from camera" Tags="|arduino-uno|programming|data-type|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24117" PostTypeId="2" ParentId="24116" CreationDate="2016-05-11T23:26:01.620" Score="1" Body="&lt;p&gt;No. The Arduino (or not the &quot;normal&quot; Arduinos) doesn't have enough memory to decompress JPEG.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made a JPEG decompressor for chipKIT boards the other day, and it uses the absolute bare minimum memory possible, and still comes it at close to 128kB. Far more than any &quot;normal&quot; Arduino board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can possibly do it with one of these new-fangled Linux-based Intel boards that are being sold as Arduino these days, but they are not your normal run-of-the-mill Microcontroller but closer to a Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Speaking of which, the Raspberry Pi is probably a much better choice than any Arduino board for the kind of thing you are trying to do.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-11T23:26:01.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24118" PostTypeId="1" AcceptedAnswerId="24119" CreationDate="2016-05-12T00:25:27.940" Score="3" ViewCount="213" Body="&lt;p&gt;I want to generate a PWM signal that I can turn on and off with a button press without using interrupts.  Is there a way to keep the PWM output going while running other processes?&lt;/p&gt;&#xA;" OwnerDisplayName="user20985" LastActivityDate="2016-05-12T00:30:40.890" Title="How can I maintain PWM output while still performing other tasks?" Tags="|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24119" PostTypeId="2" ParentId="24118" CreationDate="2016-05-12T00:30:40.890" Score="4" Body="&lt;p&gt;PWM just runs once started. It's all managed by a completely separate bit of silicon inside the chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have done &lt;code&gt;analogWrite(...)&lt;/code&gt; the PWM will just keep going until you tell it otherwise. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-12T00:30:40.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24120" PostTypeId="1" AcceptedAnswerId="24121" CreationDate="2016-05-12T01:17:53.857" Score="2" ViewCount="11740" Body="&lt;p&gt;The IDE tells me the included library isn't? I tried restarting the IDE and my computer but it doesn't work. The other libraries work fine it's only with Keyboard that it fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Keyboard.h&amp;gt;&#xA;&#xA;int buttonState = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(2, INPUT);&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  Keyboard.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;  buttonState = digitalRead(2);&#xA;  if (buttonState == HIGH) {&#xA;    digitalWrite(13, HIGH);&#xA;    Keyboard.press('A');&#xA;  } else {&#xA;    digitalWrite(13, LOW);&#xA;    Keyboard.releaseAll();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error log:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.8 (Windows 10), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;D:\Documents\Test\Test.ino: In function 'void setup()':&#xA;&#xA;Test:9: error: 'Keyboard' not found. Does your sketch include the line '#include &amp;lt;Keyboard.h&amp;gt;'?&#xA;   Keyboard.begin();&#xA;&#xA;   ^&#xA;&#xA;D:\Documents\Test\Test.ino: In function 'void loop()':&#xA;&#xA;Test:16: error: 'Keyboard' not found. Does your sketch include the line '#include &amp;lt;Keyboard.h&amp;gt;'?&#xA; Keyboard.press('A');&#xA;&#xA; ^&#xA;&#xA;Test:19: error: 'Keyboard' not found. Does your sketch include the line '#include &amp;lt;Keyboard.h&amp;gt;'?&#xA;     Keyboard.releaseAll();&#xA;&#xA;     ^&#xA;&#xA;exit status 1&#xA;'Keyboard' not found. Does your sketch include the line '#include &amp;lt;Keyboard.h&amp;gt;'?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11983" LastActivityDate="2018-04-05T20:08:30.413" Title="Error saying an included library is not" Tags="|arduino-uno|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24121" PostTypeId="2" ParentId="24120" CreationDate="2016-05-12T01:19:57.210" Score="4" Body="&lt;p&gt;I see you are using an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino Uno cannot act as a USB keyboard - therefore the Keyboard library doesn't exist for it (the file Keyboard.h is seen as being empty).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can only use Keyboard.h on boards where using Keyboard.h makes any kind of sense, such as the Leonardo.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-12T01:19:57.210" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24122" PostTypeId="1" CreationDate="2016-05-12T01:58:35.917" Score="1" ViewCount="1327" Body="&lt;p&gt;I've seen &lt;a href=&quot;http://hackaday.com/2012/06/29/turning-an-arduino-into-a-usb-keyboard/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; that it is possible to enable keyboard feature on Arduino Uno so it can emulate a keyboard (send keystrokes to computer) like the Leonardo. They do it by updating ATmega16U2 firmware. But I bought a cheap arduino clone that uses CH340G instead of this chip. Is there any way to do the same with this chip? Can this even work on standard arduino uno?&lt;/p&gt;&#xA;" OwnerUserId="11983" LastActivityDate="2016-05-12T02:00:03.220" Title="Enabling keyboard feature on Arduino with CH340G" Tags="|arduino-uno|usb|keyboard|atmega16u2|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24123" PostTypeId="2" ParentId="24122" CreationDate="2016-05-12T02:00:03.220" Score="2" Body="&lt;p&gt;No. That chip can only act as a USB-UART bridge. You could use V-USB to turn the ATmega328P into a low-speed USB device, but the Arduino IDE has no support for that.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-12T02:00:03.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24125" PostTypeId="1" AcceptedAnswerId="24133" CreationDate="2016-05-12T07:47:51.810" Score="3" ViewCount="21909" Body="&lt;p&gt;When I try to upload my program on the Arduino Uno Chinese clone, It says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; -&amp;gt; avrdude: ser_open(): can't open device &quot;/dev/ttyUSB0&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My Arduino Programmer: ArduinoISP&lt;/li&gt;&#xA;&lt;li&gt;My Arduino Software version: 1.6.8&lt;/li&gt;&#xA;&lt;li&gt;My OS: Linux Mint&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can you help me fix this error?&lt;/p&gt;&#xA;" OwnerUserId="20151" LastEditorUserId="6936" LastEditDate="2017-07-01T10:13:05.207" LastActivityDate="2017-07-02T04:12:07.303" Title="Error on UNOr3--&gt; avrdude: ser_open(): can't open device &quot;/dev/ttyUSB0&quot;: No such file or directory ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device" Tags="|arduino-uno|arduino-ide|avrdude|clones|" AnswerCount="2" CommentCount="10" ClosedDate="2017-07-03T07:28:52.740" ContentLicense="CC BY-SA 3.0" />
  <row Id="24127" PostTypeId="1" CreationDate="2016-05-12T10:58:38.060" Score="0" ViewCount="1574" Body="&lt;p&gt;I am using &lt;a href=&quot;http://www.blynk.cc/&quot; rel=&quot;nofollow&quot;&gt;Blynk&lt;/a&gt; to try and control a 28byj-48 stepper motor using the ULN2003 driver and an Arduino UNO from my iphone via USB withe the iOS Blynk App.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without using Blynk, my stepper is smooth and works fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;Servo.h&amp;gt;&#xA;  #include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,                                    &#xA;  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft&#xA;  const int motorpin1 = 8;                    //Assign motor  pins to Arduino pins&#xA;  const int motorpin2 = 9;                    //&#xA;  const int motorpin3 = 10;                   //&#xA;  const int motorpin4 = 11;                   //&#xA;&#xA;  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4 &#xA;  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);    &#xA;&#xA;  int pos = 0;    // variable to store the servo position&#xA;&#xA;  void setup() {&#xA;    myStepper.setSpeed(600); &#xA;  }&#xA;&#xA;  void loop(){&#xA;     myStepper.step(-500); &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I use Blynk, the stepper is so jerky and stutters terribly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;  SoftwareSerial SwSerial(10, 11);&#xA;  #define BLYNK_PRINT SwSerial&#xA;  #include &amp;lt;BlynkSimpleSerial.h&amp;gt;&#xA;  #include &amp;lt;Stepper.h&amp;gt;&#xA;&#xA;  const int stepsPerMotorRevolution = 32;  //No of steps per internal revolution of motor,4-step mode                                     &#xA;  const int stepsPerOutputRevolution = 32*64; //no of steps per revolution of the output shaft&#xA;  const int motorpin1 = 8;                    //Assign motor pins to board pins&#xA;  const int motorpin2 = 9;                    //&#xA;  const int motorpin3 = 10;                   //&#xA;  const int motorpin4 = 11;                   //&#xA;&#xA;  // initialize the stepper library on pins 8 through 11, Motor rev steps, initialise firing sequence 1-3-2-4 blah blah&#xA;  Stepper myStepper(stepsPerMotorRevolution, motorpin1,motorpin3,motorpin2,motorpin4);  &#xA;  char auth[] = &quot;my auth key here&quot;;&#xA;&#xA;  void setup(){&#xA;    SwSerial.begin(9600);&#xA;    Blynk.begin(auth);&#xA;    myStepper.setSpeed(600); &#xA;  }&#xA;&#xA;  BLYNK_WRITE(1){&#xA;    myStepper.step(param.asInt());&#xA;  }&#xA;&#xA;  void loop(){&#xA;    Blynk.run();&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using a slider on the app to control the stepper by the way. I am not sure what I am doing wrong, any suggestions?&lt;/p&gt;&#xA;" OwnerDisplayName="user20551" LastActivityDate="2016-05-12T12:25:57.743" Title="Using Blynk to control stepper motor is jerky" Tags="|arduino-uno|stepper|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24129" PostTypeId="2" ParentId="24127" CreationDate="2016-05-12T12:19:30.227" Score="1" Body="&lt;p&gt;Blynk runs over a network and therefore cannot respond in real-time nor consistently. You could have the Blynk slider control set a local variable which the motor controller would use for motor speed, but the basic motor-drive timing needs to be locally controlled and independent of network operations. The SimpleTimer library is one way; a timer interrupt would be another.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-12T12:19:30.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24130" PostTypeId="2" ParentId="24127" CreationDate="2016-05-12T12:25:57.743" Score="0" Body="&lt;p&gt;My guess would be you are suffering from a comms latency issue.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are you using a local server or the cloud?  &lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is you iOS device connected over WIFI or 2G, 3G or 4G?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is you device on the same subnet as you iOS device and local server?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I've never used blynk (I might do this weekend though), my best thought as to how to fix it would be to revise your approach.  When you are controlling devices over an unpredictable connection (Ethernet) you can't rely of messages to arrive in a certain order or at certain times.  You need to tell the device to do something and keep doing it until its done or its told to stop.&lt;br&gt;&#xA;So in this case tell the device to rotate clockwise at a certain rate until it travels n degrees or it is told to stop.  Now you can't just tell the motor to make 20 turns, because that will make your app unresponsive.  What you need to do it tell it to turn 50 steps and then return to the control loop, if no new order has come in it should then go and do another 50 steps, if there is a new order then off it goes with the new task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that makes sense and helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-12T12:25:57.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24131" PostTypeId="1" CreationDate="2016-05-12T12:26:05.657" Score="0" ViewCount="1679" Body="&lt;p&gt;I am successfully using a BMP280 sensor via SPI connection with an Arduino Uno R3 board. I'm trying to run the same code with the same setup on an Arduino Ethernet. However the sensor is not initializing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The setup function looks as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    delay(1000);        &#xA;    dht.begin(); // starts DHT sensor&#xA;    chk = dht.read(DHTPIN); // reads DHT status&#xA;    while ((!bmp.begin()) || (chk != 1) ) {&#xA;      // checks DHT and BMP status and shows red LED, in case one of them&#xA;      // wasn't found. Loops and resets timeout each time.&#xA;      wdt_reset();&#xA;      Serial.println(&quot;Could not find a valid sensor, check wiring!&quot;);&#xA;      digitalWrite(RED, HIGH);&#xA;      delay(300);&#xA;      digitalWrite(RED, LOW);&#xA;      delay(1000);&#xA;      chk = dht.read(DHTPIN);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code only returns the error message and does not initialize the BMP sensor (DHT is fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ThingSpeak.h&quot;    &#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE5, 0xBF};&#xA;IPAddress ip(10,42,0,69);&#xA;EthernetClient client;&#xA;&#xA;// --- Libraries --- //&#xA;#include &amp;lt;avr/wdt.h&amp;gt; // Watchdog, interrupts and reboots&#xA;#include &amp;lt;Adafruit_BMP280.h&amp;gt; // BMP library for BMP280&#xA;&#xA;// --- Constants --- //&#xA;// DHT22&#xA;#define DHTPIN 7&#xA;// BMP280 (SPI)&#xA;#define BMP_SCK 13 // Serial clock pin for BMP (10k pullup to +5V)&#xA;#define BMP_MISO 12 // SDO, has 10k pullup&#xA;#define BMP_MOSI 11 // SDI, no pullup&#xA;#define BMP_CS 9 // CS, has 10k pullup&#xA;// LEDs&#xA;#define RED 5 // pin for LEDs&#xA;#define YELLOW 3&#xA;#define GREEN 2&#xA;&#xA;unsigned long myChannelNumber = 115634;&#xA;const char * myWriteAPIKey = &quot;***&quot;; // removed for privacy reasons&#xA;float dht_temp;&#xA;float dht_hum;&#xA;float bmp_temp; // values from sensors&#xA;float bmp_press;&#xA;int chk; // DHT status (0 or 1)&#xA;int k; // counter variable&#xA;int number;&#xA;char COLOR;&#xA;&#xA;// --- Initialization --- //&#xA;DHT dht(DHTPIN, DHT22); // initializes sensors&#xA;Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);&#xA;&#xA;void setup() {&#xA;  wdt_disable(); // disables watchdog for initial communication&#xA;  pinMode(10, OUTPUT);&#xA;  digitalWrite(10, HIGH);&#xA;  pinMode(4, OUTPUT);&#xA;  digitalWrite(4, HIGH);&#xA;  pinMode(YELLOW, OUTPUT); // LED pins set as output&#xA;  pinMode(RED, OUTPUT);&#xA;  digitalWrite(YELLOW, HIGH); // starts yellow LED&#xA;  Serial.begin(9600); // begin serial connection with 9600 baud&#xA;  delay(500); // delay to get connection and sensors ready&#xA;  wdt_enable(WDTO_8S); // start watchdog timeout (4 sec might be too short)&#xA;  blink(RED, 3);&#xA;  Serial.println(bmp.begin());&#xA;  dht.begin(); // starts DHT sensor&#xA;  chk = dht.read(DHTPIN); // reads DHT status&#xA;  if ((!bmp.begin()) || (chk != 1) ) {&#xA;    // checks DHT and BMP status and shows red LED, in case one of them&#xA;    // wasn't found. Loops and resets timeout each time.&#xA;    wdt_reset();&#xA;    Serial.println(&quot;Could not find a valid sensor, check wiring!&quot;);&#xA;    digitalWrite(RED, HIGH);&#xA;    delay(300);&#xA;    digitalWrite(RED, LOW);&#xA;    delay(1000);&#xA;    chk = dht.read(DHTPIN);&#xA;  }&#xA;  Ethernet.begin(mac, ip);&#xA;  ThingSpeak.begin(client);&#xA;}&#xA;&#xA;// --- Loop --- //&#xA;void loop() {&#xA;  wdt_reset(); // resets watchdog&#xA;  pinMode(GREEN, OUTPUT); // gets green LED ready&#xA;  digitalWrite(GREEN, LOW);&#xA;  delay(1600); // delay for sensors to be read. In total, at least 2 sec!&#xA;  dhtread();&#xA;  delay(5000);&#xA;  wdt_reset();&#xA;  bmpread();&#xA;  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);&#xA;  delay(5000);&#xA;  wdt_reset();&#xA;  delay(5000);&#xA;}&#xA;&#xA;void blink(char COLOR, int number) {&#xA;  for (k = 1; k &amp;lt;= number; k = k + 1) {&#xA;    // blinks 3x to show that Arduino rebooted&#xA;    digitalWrite(COLOR, HIGH);&#xA;    delay(100);&#xA;    digitalWrite(COLOR, LOW);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&#xA;void bmpread() {&#xA;  bmp_temp = bmp.readTemperature(); // reads BMP sensor&#xA;  bmp_press = bmp.readPressure();&#xA;  Serial.println(bmp_temp);&#xA;  Serial.println(bmp_press);&#xA;  if (bmp_press &amp;gt; 0.0) {&#xA;    // if sensor isn't attached, it shows 0.0 or negative pressure.&#xA;    // This is used as check criterion&#xA;    digitalWrite(GREEN, HIGH); // blinks green for good BMP values&#xA;    Serial.println(&quot;bmp ok&quot;);&#xA;    ThingSpeak.setField(3,bmp_temp);&#xA;    ThingSpeak.setField(4,bmp_press);&#xA;    delay(150);&#xA;    digitalWrite(GREEN, LOW);&#xA;  } else {&#xA;    // if pressure is 0.0 or negative, blink red&#xA;    // and print 0.0 to keep formatting&#xA;    digitalWrite(RED, HIGH);&#xA;    Serial.println(&quot;Error, BMP280 missing&quot;);&#xA;    delay(150);&#xA;    digitalWrite(RED, LOW);&#xA;  }&#xA;}&#xA;&#xA;void dhtread() {&#xA;  chk = dht.read(DHTPIN); // checks if connection to DHT sensor is ok (0: no connection, 1: ok)&#xA;  if (chk == 1) {&#xA;    dht_temp = dht.readTemperature();&#xA;    dht_hum = dht.readHumidity(); // reads DHT sensor&#xA;    digitalWrite(GREEN, HIGH); // blinks once for successful DHT sensor values&#xA;    ThingSpeak.setField(1,dht_temp);&#xA;    ThingSpeak.setField(2,dht_hum);&#xA;    delay(150);&#xA;    digitalWrite(GREEN, LOW);&#xA;    delay(100);&#xA;  } else {&#xA;    // if no connection, blink red instead and print &quot;nan&quot;&#xA;    // (keeps formatting ok)&#xA;    digitalWrite(RED, HIGH);&#xA;    Serial.print(&quot;Error, DHT22 missing&quot;);&#xA;    delay(150);&#xA;    digitalWrite(RED, LOW);&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem now is that it seems to initialize (&lt;code&gt;bmp.begin()&lt;/code&gt; returns 1), but the sensor is still not reading a correct value (either 0.0 for both pressure and temperature, or a large negative pressure and very large temperature (-2602 Pa, 185°C). What might be the problem? I have tried it with another sensor of the same type, same result. Where else can I attach the CS wire to?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Lop2W.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Lop2W.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20459" LastEditorUserId="4628" LastEditDate="2017-01-10T14:26:21.080" LastActivityDate="2017-11-08T03:24:51.690" Title="BMP280 sensor not initializing" Tags="|sensors|c++|ethernet|spi|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24132" PostTypeId="2" ParentId="24131" CreationDate="2016-05-12T12:30:09.047" Score="1" Body="&lt;p&gt;The software must be OK, because it runs on the other board, so it has to be a hardware fault. The sensor is OK, because it works on the other board. Assuming the board isn't defective then it must be the way you have connected it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't included your pin designations. Some Ethernet shields use certain pins and prevent them being used by other devices. Is it possible that this could be the cause of you problems?&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="4628" LastEditDate="2017-11-08T03:24:51.690" LastActivityDate="2017-11-08T03:24:51.690" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24133" PostTypeId="2" ParentId="24125" CreationDate="2016-05-12T12:52:54.147" Score="2" Body="&lt;p&gt;This could be any number of different problems.  Here are several common causes:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You have multiple USB serial port devices connected to your computer. Try using the command &lt;code&gt;ls -l /dev/ttyUSB*&lt;/code&gt; to check if your computer thinks there are more than one terminal USB device.  Disconnect all of them, then only connect the Arduino Uno.  Then repeat the check.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You do not have permissions.  This is tricky to check as Linux offers a flexible but complicated root, group and user permission paradigm.  &lt;strong&gt;You should NOT make a habit of this&lt;/strong&gt;, but, for a quick check, you can try running the Arduino application as root and check if you can upload a sketch to the Arduino Uno.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You have a counterfeit FTDI chip on your Arduino Uno that has been &lt;a href=&quot;http://hackaday.com/2016/02/01/ftdi-drivers-break-fake-chips-again/&quot; rel=&quot;nofollow noreferrer&quot;&gt;rendered useless by certain versions of the Windows FTDI Driver&lt;/a&gt;.  The USB IDs can get reset to useless values.  I believe the current FTDI Windows Driver no longer does this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You did not install the Linux FTDI driver.  A driver is a program to abstract the hardware from the application.  In this way, different hardware can be treated the same by the application, simplifying the application.  However, the wrong driver/hardware combination may not work as expected.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="6936" LastEditDate="2017-07-02T04:12:07.303" LastActivityDate="2017-07-02T04:12:07.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24134" PostTypeId="1" CreationDate="2016-05-12T12:59:55.113" Score="0" ViewCount="323" Body="&lt;p&gt;I tried the whole process by using two arduino unos.It worked perfectly.&#xA;Though when i tried to replace the slave uno with attiny 84 uC it showed following errors in compiling.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.7 (Windows 7), Board: &quot;ATtiny24/44/84, ATtiny84 @ 1 MHz  (internal oscillator; BOD disabled)&quot;&#xA;&#xA;WARNING: Category '' in library ArduinoJson is not valid. Setting to 'Uncategorized'&#xA;C:\Users\LEGEND\AppData\Local\Temp\arduino_8a75bcb6a2713182a57eb1014198ceb3\sketch_may12c.ino: In function 'void setup()':&#xA;&#xA;sketch_may12c:12: error: 'SPCR' was not declared in this scope&#xA;&#xA;   SPCR |= bit (SPE);&#xA;&#xA;   ^&#xA;&#xA;In file included from C:\Users\LEGEND\AppData\Local\Arduino15\packages\tiny\hardware\avr\1.0.0\cores\tiny/WProgram.h:12:0,&#xA;&#xA;                 from C:\Users\LEGEND\AppData\Local\Arduino15\packages\tiny\hardware\avr\1.0.0\cores\tiny/Arduino.h:4,&#xA;&#xA;                 from sketch\sketch_may12c.ino.cpp:1:&#xA;&#xA;sketch_may12c:12: error: 'SPE' was not declared in this scope&#xA;&#xA;   SPCR |= bit (SPE);&#xA;&#xA;                ^&#xA;&#xA;C:\Users\LEGEND\AppData\Local\Arduino15\packages\tiny\hardware\avr\1.0.0\cores\tiny/wiring.h:158:25: note: in definition of macro 'bit'&#xA;&#xA; #define bit(b) (1UL &amp;lt;&amp;lt; (b))&#xA;&#xA;                         ^&#xA;&#xA;sketch_may12c:15: error: 'MISO' was not declared in this scope&#xA;&#xA;   pinMode (MISO, OUTPUT);&#xA;&#xA;            ^&#xA;&#xA;sketch_may12c:22: error: expected unqualified-id before '.' token&#xA;&#xA;   tinySPI.attachInterrupt();&#xA;&#xA;          ^&#xA;&#xA;C:\Users\LEGEND\AppData\Local\Temp\arduino_8a75bcb6a2713182a57eb1014198ceb3\sketch_may12c.ino: In function 'void SPI_STC_vect()':&#xA;&#xA;sketch_may12c:30: error: 'SPDR' was not declared in this scope&#xA;&#xA; byte c = SPDR;  // grab byte from SPI Data Register&#xA;&#xA;          ^&#xA;&#xA;exit status 1&#xA;'SPCR' was not declared in this scope&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20993" LastEditorUserId="2881" LastEditDate="2016-05-12T15:14:18.080" LastActivityDate="2016-05-13T08:27:27.133" Title="problem in integrating the slave code in attiny 84" Tags="|arduino-uno|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24135" PostTypeId="1" CreationDate="2016-05-12T13:42:47.387" Score="0" ViewCount="728" Body="&lt;p&gt;I am working on a project with the Mousecontrol library. This causes me a lot of problems with loading the library. I imported the library but it gives me errors everytime. I think it is a mistake in the library folders but I can't seem to figure it out.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MouseController.h&amp;gt;&#xA;&#xA;// Initialize USB Controller&#xA;USBHost usb;&#xA;&#xA;// Attach mouse controller to USB&#xA;MouseController mouse(usb);&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  usb.Task();&#xA;}&#xA;&#xA;void mouseMoved() {&#xA;  Serial.print(&quot;Move: &quot;);&#xA;  Serial.print(mouse.getXChange());&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.println(mouse.getYChange());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.0 (Mac OS X), Board:&quot;Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;&#xA;&#xA;In file included from /Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/MouseController.h:22:0,&#xA;                 from Muis_Bevrijding.ino:1:&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h: In member function 'virtual void HIDBoot&amp;lt;BOOT_PROTOCOL&amp;gt;::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*)':&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:62: error: 'UOTGHS_HSTPIPCFG_PTYPE_INTRPT' was not declared in this scope&#xA;   pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);&#xA;                                                              ^&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:93: error: 'UOTGHS_HSTPIPCFG_PTOKEN_IN' was not declared in this scope&#xA;   pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);&#xA;                                                                                             ^&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:151: error: 'UOTGHS_HSTPIPCFG_PBK_1_BANK' was not declared in this scope&#xA;   pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);&#xA;                                                                                                                                                       ^&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:178: error: there are no arguments to 'UHD_Pipe_Alloc' that depend on a template parameter, so a declaration of 'UHD_Pipe_Alloc' must be available [-fpermissive]&#xA;   pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);&#xA;                                                                                                                                                                                  ^&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:178: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h: In member function 'virtual uint32_t HIDBoot&amp;lt;BOOT_PROTOCOL&amp;gt;::Release()':&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:500:54: error: there are no arguments to 'UHD_Pipe_Free' that depend on a template parameter, so a declaration of 'UHD_Pipe_Free' must be available [-fpermissive]&#xA;  UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum);&#xA;                                                      ^&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h: In instantiation of 'uint32_t HIDBoot&amp;lt;BOOT_PROTOCOL&amp;gt;::Release() [with unsigned char BOOT_PROTOCOL = 2u; uint32_t = long unsigned int]':&#xA;Muis_Bevrijding.ino:22:1:   required from here&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:500:54: error: 'UHD_Pipe_Free' was not declared in this scope&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h: In instantiation of 'void HIDBoot&amp;lt;BOOT_PROTOCOL&amp;gt;::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 2u; uint32_t = long unsigned int]':&#xA;Muis_Bevrijding.ino:22:1:   required from here&#xA;/Users/jamiederooij/Downloads/Arduino.app/Contents/Resources/Java/libraries/USBHost/src/hidboot.h:474:178: error: 'UHD_Pipe_Alloc' was not declared in this scope&#xA;   pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);&#xA;                                                                                                                                                                                  ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot for your time!&lt;/p&gt;&#xA;" OwnerUserId="20994" LastEditorUserId="10794" LastEditDate="2016-05-13T20:36:08.683" LastActivityDate="2016-05-13T20:36:08.683" Title="Arduino Mousecontroller library doesn't work" Tags="|library|mouse|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24136" PostTypeId="2" ParentId="24135" CreationDate="2016-05-12T13:46:37.857" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;h1&gt;USBHost&lt;/h1&gt;&#xA;  &#xA;  &lt;h3&gt;Compatible with Arduino Due only&lt;/h3&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/USBHost&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-12T13:46:37.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24137" PostTypeId="1" CreationDate="2016-05-12T10:10:31.573" Score="2" ViewCount="35" Body="&lt;p&gt;I have an Arduino Yun that I need to connect to a machine to detect whether the machine is working or is stopped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The signal used as a flag for such behaviour is basically the presence or absence of current in one of the motors that work when the machine operates. The voltage going through the motor is 220VAC. So I figured I could use a standard AC to DC converter like the one used to charge the phones (since those converters usually take 100~240V at 50/60Hz and output 5V with 1A) and connect that to one of the digital ports in input mode. Then I would know if the machine is working or not if such pin is in HIGH state or LOW state respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, this works up to certain point. For some reason, the YUN stalls or resets itself while the machine is operating. I've checked the voltage and even used a voltage regulator to make sure it doesn't exceed the 5V. I even connected the signal to an Analog pin and measured the input and it never read more than 4.9V. So I guess my question is, what might be causing this behaviour and how could I avoid it. I suspected it was a voltage/current spike but with the voltage regulator and the resistors I added before passing the signal to the Arduino I though the issue should be solved but the issue persists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attached is an image of the power adapters I'm using to both feed the arduino with current and convert the signal that goes to the pins to DC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, I know that the arduino stalls because it closes the telnet session I am using to monitor the values read by the pins and because the USB let goes off. Normally the arduino will have the USB and the ON leds on but once the issue happens it turns the USB led off and in some boards it turns on the WAN led on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Interestingly enough, it seems that the issue happens when the machine is stopped (LOW voltage) and is preparing to start working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as a note. I've tried different Arduino Yun boards and all have the same behaviour so I don't think it's a matter of the board being broken. Resetting the board allows it to continue reading the signal but eventually it stalls again&lt;/p&gt;&#xA;" OwnerUserId="19626" OwnerDisplayName="Jose" LastEditorUserId="37523" LastEditDate="2018-07-27T02:01:31.960" LastActivityDate="2018-07-27T02:01:31.960" Title="Arduino Yun restarts or stalls during operation" Tags="|arduino-yun|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24138" PostTypeId="1" AcceptedAnswerId="24140" CreationDate="2016-05-12T16:24:21.693" Score="2" ViewCount="4040" Body="&lt;p&gt;My basic question is: &lt;strong&gt;What is a good alternative to EEPROM chips for external memory on the Arduino Unor R3?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there are EEPROM chips when one would like an external memory chip. It, in fact, seems like this is the standard choice. I am wondering if there are any other good ways to work with external memory. Are there, for example, memory chips that work a bis simpler? Like, a chip that doesn't require any specific libraries in the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I do not have extensive experience working with the Arduino.)&lt;/p&gt;&#xA;" OwnerUserId="20995" LastActivityDate="2017-02-28T13:47:33.480" Title="Simple memory chip for Arduino?" Tags="|arduino-uno|memory|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24139" PostTypeId="2" ParentId="24138" CreationDate="2016-05-12T16:50:30.497" Score="5" Body="&lt;p&gt;No. There is no external memory interface on the ATmega328P, so all external memory requires some sort of library to use.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-12T16:50:30.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24140" PostTypeId="2" ParentId="24138" CreationDate="2016-05-12T17:18:12.280" Score="7" Body="&lt;p&gt;There is no DRAM, SRAM nor flash interface in ATmega, so you can't extend your chip memory. You can only connect serial (SPI, I2C) or parallel memory (usind GPIO).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither SPI nor I2C require any specific libraries.&#xA;SPI is much simpler to program than I2C and much faster, but require more wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using rather slow EEPROM, you can try FRAM (non-volatile) or SRAM (volatile, but may be battery-sustained). They are usually available with the same interface as EEPROM, but don't suffer from limited number of erase cycles. FRAM can withstand ridiculous number of erasures, SRAM is virtually indestructible.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-05-12T17:18:12.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24142" PostTypeId="2" ParentId="23889" CreationDate="2016-05-12T17:36:40.493" Score="2" Body="&lt;p&gt;I even didn't check the Modbus part of your code but the first think what I found:&#xA;You are using the D2 pin for LCD and at the same time as TXEnablePin...&lt;/p&gt;&#xA;" OwnerUserId="18625" LastActivityDate="2016-05-12T17:36:40.493" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24143" PostTypeId="1" CreationDate="2016-05-12T20:29:54.760" Score="2" ViewCount="9954" Body="&lt;p&gt;I can successfully see the Arduino Due when I plug it in. I can compile the code, but when I attempt to upload it to the board I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;C:\Users\user\AppData\Roaming\Arduino15\packages\arduino\tools\bossac\1.6.1-arduino/bossac.exe &#xA;        -i -d --port=COM4 -U false -e &#xA;        -w true &#xA;        -b C:\Users\user\AppData\Local\Temp\build6683778295083335366.tmp/_50key_driver.cpp.bin&#xA;        -R bossac.exe: extra arguments found &#xA;    Try 'bossac.exe -h' or 'bossac.exe --help' for more information&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21004" LastEditorUserId="4628" LastEditDate="2017-10-26T10:42:59.967" LastActivityDate="2017-10-26T10:42:59.967" Title="Unable to upload to Arduino Due using version 1.6.8 of SAM tools; bossac.exe throwing an error" Tags="|arduino-due|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24144" PostTypeId="2" ParentId="24143" CreationDate="2016-05-12T20:43:33.290" Score="3" Body="&lt;p&gt;I finally figured out the problem. This occurred on both a Mac and PC (Windows 10).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This error occurred because of the &lt;strong&gt;true&lt;/strong&gt; after the &lt;strong&gt;-w&lt;/strong&gt; switch. To fix it I modified the package to tell the IDE not to use that switch.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Go to: &lt;code&gt;%USER_PROFILE%\AppData\Roaming\Arduino15\packages\arduino\hardware\sam\1.6.8&lt;/code&gt; (where &lt;code&gt;%USER_PROFILE%&lt;/code&gt; is your windows user directory, for me it was &lt;code&gt;C:\Users\user&lt;/code&gt;) in Windows Explorer.&lt;/li&gt;&#xA;&lt;li&gt;Make a copy of the platform.txt file (I called it platform_backup.txt).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open the file platform.txt with Word Pad (it had Unix line endings in my environment), search for the string:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tools.bossac.upload.pattern=&quot;{path}/{cmd}&quot; {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -e -w {upload.verify} -b &quot;{build.path}/{build.project_name}.bin&quot; -R&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;This was 3rd line from the bottom for me, and remove the text between the quotes &quot;{upload.verify}&quot;. It should now look like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;tools.bossac.upload.pattern=&quot;{path}/{cmd}&quot; {upload.verbose} --port={serial.port.file} -U {upload.native_usb} -e -w -b &quot;{build.path}/{build.project_name}.bin&quot; -R&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart the IDE so it can re-read the file you just edited. You'll now be able to upload to the Due.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="21004" LastActivityDate="2016-05-12T20:43:33.290" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24145" PostTypeId="1" AcceptedAnswerId="24147" CreationDate="2016-05-12T21:43:55.163" Score="0" ViewCount="84" Body="&lt;p&gt;I'm trying to do something to this affect:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;const string first_color = strip.Color(0, 60, 0, 0);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the intended outcome being that I could use &lt;code&gt;first_color&lt;/code&gt; wherever I'd have used &lt;code&gt;strip.Color(0, 60, 0, 0)&lt;/code&gt; before.&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-13T16:22:42.560" Title="How to store a function in a constant?" Tags="|arduino-uno|adafruit|neopixel|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24146" PostTypeId="2" ParentId="3728" CreationDate="2016-05-12T21:54:28.610" Score="2" Body="&lt;p&gt;You can, actually albeit 32u4 at 16MHz at 3.3V is outside of the safe operating area, it worked for me perfectly. Also for others :) google for it.&lt;/p&gt;&#xA;" OwnerUserId="19152" LastActivityDate="2016-05-12T21:54:28.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24147" PostTypeId="2" ParentId="24145" CreationDate="2016-05-12T21:59:12.110" Score="1" Body="&lt;p&gt;You pretty much need a helper function to do that; a small local function that calls &lt;code&gt;strip.Color()&lt;/code&gt; with the intended arguments and returns &lt;code&gt;strip.Color()&lt;/code&gt;'s return value if there is any.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int first_color(void)&#xA;{&#xA;   return(strip.Color(0, 60, 0, 0));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(assuming &lt;code&gt;strip.Color()&lt;/code&gt; returns an &lt;code&gt;int&lt;/code&gt;) which you would call with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value = first_color();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;strip.Color()&lt;/code&gt; is a &lt;code&gt;void&lt;/code&gt; function, then delete the 'return(' and one ')', fix the definition of first color to be &lt;code&gt;void&lt;/code&gt; instead of &lt;code&gt;int&lt;/code&gt;, and of course, don't try to use any return value from &lt;code&gt;first_color()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-12T21:59:12.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24148" PostTypeId="1" CreationDate="2016-05-12T21:59:19.097" Score="0" ViewCount="845" Body="&lt;p&gt;I have a project that I need to use a vector, I have tried to get several libraries to compile with out luck. The one that has gotten the closest is  &lt;a href=&quot;http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;Andy Brown's AVR-STL&lt;/a&gt;. I keep getting the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am sure that this is a simple fix, I just have no idea how. If this library is no longer viable then can someone else recommend another one?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I am trying to compile&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;iterator&quot;&#xA;#include &quot;vector&quot;&#xA;#include &quot;pnew.cpp&quot;&#xA;&#xA;std::vector&amp;lt;int&amp;gt; test;&#xA;&#xA;void setup(void) {&#xA;&#xA;    Serial.begin(57600);&#xA;}&#xA;&#xA;void loop(void) {&#xA;&#xA;    test.push_back(1);&#xA;    Serial.println(&quot;Pushed&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the full output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;14:57:27 **** Incremental Build of configuration Release for project MegaTesting ****&#xA;&quot;C:\\Eclipse\\eclipse\\arduinoPlugin\\tools\\make\\make&quot; all &#xA;'Building file: ../.ino.cpp'&#xA;'Starting C++ compile'&#xA;&quot;C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-g++&quot; -c -g -Os -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR     -I&quot;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\cores\arduino&quot; -I&quot;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\variants\mega&quot; -I&quot;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL&quot; -I&quot;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility&quot; -MMD -MP -MF&quot;.ino.cpp.d&quot; -MT&quot;.ino.cpp.o&quot; -D__IN_ECLIPSE__=1 -x c++ &quot;../.ino.cpp&quot;  -o  &quot;.ino.cpp.o&quot;   -Wall&#xA;cc1plus.exe: warning: C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL\utility: not a directory [enabled by default]&#xA;In file included from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/stl_iterator_base.h:38:0,&#xA;                 from C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/iterator:40,&#xA;                 from ../.ino.cpp:8:&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _TrivialIterator_concept_specification&amp;lt;_TrivialIterator&amp;gt;::_TrivialIterator_requirement_violation(_TrivialIterator)':&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:572:16: warning: typedef '__T' locally defined but not used [-Wunused-local-typedefs]&#xA;     value_type __T;&#xA;                ^&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h: In static member function 'static void _Allocator_concept_specification&amp;lt;_Alloc&amp;gt;::_Allocator_requirement_violation(_Alloc)':&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/concept_checks.h:799:39: warning: typedef '_Tp' locally defined but not used [-Wunused-local-typedefs]&#xA;   typedef typename _Alloc::value_type _Tp;&#xA;                                       ^&#xA;In file included from ../MegaTesting.ino:3:0,&#xA;                 from ../.ino.cpp:14:&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp: In function 'void* operator new(size_t, void*)':&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: redefinition of 'void* operator new(size_t, void*)'&#xA; void* operator new(size_t size_,void *ptr_){&#xA;       ^&#xA;In file included from ../.ino.cpp:10:0:&#xA;C:\Eclipse\eclipse\arduinoPlugin\packages\arduino\hardware\avr\1.6.10\libraries\AVR-STL/pnew.cpp:12:7: error: 'void* operator new(size_t, void*)' previously defined here&#xA; void* operator new(size_t size_,void *ptr_){&#xA;       ^&#xA;subdir.mk:24: recipe for target '.ino.cpp.o' failed&#xA;make: *** [.ino.cpp.o] Error 1&#xA;&#xA;14:57:28 Build Finished (took 600ms)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2021-10-21T19:05:10.397" Title="AVR-STL Library" Tags="|arduino-mega|vector|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24149" PostTypeId="2" ParentId="24148" CreationDate="2016-05-12T23:22:15.660" Score="1" Body="&lt;p&gt;It looks like &lt;code&gt;new&lt;/code&gt; is redefined. I see that you include &lt;code&gt;cpp&lt;/code&gt; file, that contains &lt;em&gt;implementation&lt;/em&gt; - this is rather unfortunate design, but that's how it is done. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, it seems that this file is already being compiled elsewhere. Have you tried to remove this include? What happens if you remove it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from that problem, you must be aware that dynamic memory management in such small system yelds risk of memory fragmentation that eventually leads to failed allocations.&lt;/p&gt;&#xA;" OwnerUserId="16458" LastEditorUserId="16458" LastEditDate="2016-05-12T23:27:01.283" LastActivityDate="2016-05-12T23:27:01.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24150" PostTypeId="1" AcceptedAnswerId="24152" CreationDate="2016-05-13T00:22:41.373" Score="1" ViewCount="2826" Body="&lt;p&gt;ESP8266 -&gt; FTDI -&gt; USB Mac&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the wiring on this page: &lt;a href=&quot;http://williamdurand.fr/2015/03/17/playing-with-a-esp8266-wifi-module/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://williamdurand.fr/2015/03/17/playing-with-a-esp8266-wifi-module/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XAhbE.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XAhbE.png&quot; alt=&quot;ESP8266 to FTDI Wiring&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was communicating with it via Serial at 115200.  I issued a &lt;code&gt;AT+UART_DEF=9600,8,1,0,0&lt;/code&gt; and a few seconds later I looked over and it was smoking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GIe82.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GIe82.jpg&quot; alt=&quot;Burnt ESP8266&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought 2 of these.  The previous one I had wired to an Arduino Nano running through a logic level converter.  That one only returns &lt;code&gt;Exception (28)&lt;/code&gt; over and over again after issuing that same command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On both units &lt;code&gt;AT+GMR&lt;/code&gt; returned:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+GMR&#xA;AT version:0.40.0.0(Aug  8 2015 14:45:58)&#xA;SDK version:1.3.0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are these units too hard to use? What did I do to burn it out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[UPDATE]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Answer given was that I fed it 5v instead of 3.3v. Obvious. I didn't think I did but I checked the output of the FTDI and sure enough it was 5.1v.  So why does the output on it say 3V3 ?  I thought that meant that it was 3.3v...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/otZDR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/otZDR.jpg&quot; alt=&quot;3V3 Doesn&amp;#39;t mean 3.3v?&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should have checked it first.&lt;/p&gt;&#xA;" OwnerUserId="20413" LastEditorUserId="20413" LastEditDate="2016-05-13T04:27:52.400" LastActivityDate="2016-05-13T06:34:24.163" Title="How did I burn out this ESP8266 unit?" Tags="|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24152" PostTypeId="2" ParentId="24150" CreationDate="2016-05-13T04:17:16.790" Score="2" Body="&lt;p&gt;You supplied 5V to a device that only takes up to 3.6V. Heat generated by the excessive power did the rest.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-13T04:17:16.790" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="24155" PostTypeId="1" AcceptedAnswerId="24159" CreationDate="2016-05-13T06:06:21.030" Score="0" ViewCount="936" Body="&lt;p&gt;I am building up an electricity monitor using the ACS712 hall effect sensor.  I have tested and built the circuit having the Arduino (Nano) connected via USB to my laptop, and have tested/debugged etc., getting expected results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've migrated the circuit to be powered from an external 5v power supply via the VIN pin (&lt;a href=&quot;http://www.electrodragon.com/product/ac-85-265v-dc-5v-power-module/&quot; rel=&quot;nofollow noreferrer&quot;&gt;details&lt;/a&gt;—this is not a &quot;wallmart&quot;-style supply).  It is supplying a solid 5.01v across the circuit according to multimeter readings—I've tested at multiple points in the circuit.  The 5v supply is rated at 700mA, so plenty of head room.  The ACS712 is deriving it's power directly from the supply, not the Arduino 5v pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm running a &quot;calibration&quot; routine that takes readings from the ACS712 (which is measuring AC current) to find the &quot;zero&quot; point (where the AC signal crosses over), which should be the value of half VCC with this sensor—see &lt;a href=&quot;https://arduino.stackexchange.com/questions/19301/acs712-sensor-reading-for-ac-current&quot;&gt;ACS712 sensor reading for AC current&lt;/a&gt; for more detail/background on this.  Usually this hovers around 512 (as expected—in the test unit I'm getting 547 when connected to an AC supply).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run/test this circuit with the USB connected, I get expected results.  When I remove the USB, the calibration routine returns a much higher value (about 650 in the test units) and resultant readings are therefore incorrect.  The laptop/test computer is not connected to a power supply during these tests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the USB is connected, there is no difference in reading across the VIN, 5V or sensor power pins, so the circuit seems to continue working from the external 5V source.  However, I have noted that the 5v output pin on the Arduino drops to about 3.95v when run off the power supply alone, vs 4.7v when powered by USB/both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I repeat this test by connecting an external USB power supply to the Arduino USB port (i.e. no serial connection, and removing the laptop from the equation) I get the same results (a higher calibration value and strange readings).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read that the analog pin is referenced to the 5V voltage.  This suggests that I should be connecting the ACS712 VCC pin to the Arduino 5V—is this the case? (Given the whole circuit is powered from the same power supply, this seemed unnecessary to me, but I'm still pretty new to this whole thing.)  The ACS is very sensitive to input voltage fluctuations, so I assumed that I'd be better powering it directly and not relying on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that I'm supplying a 5v input, should I be switching from the VIN to the 5v pin? (something I've read you can do, and that the VIN should be for 7v+ supply input only).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there anything else that could be causing this discrepancy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, the calibration and read routines are reproduced below.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SENSOR_PIN A0&#xA;#define ACS_MVPA (100)&#xA;&#xA;double _numSamples = 0;&#xA;double _ampsRMSSum = 0;&#xA;&#xA;int16_t acs712Calibrate() {&#xA;  uint8_t numReadings = 100;&#xA;  int16_t vals[numReadings];&#xA;&#xA;  // collect a sample of readings&#xA;  for (uint8_t i=0; i&amp;lt;numReadings; i++) {&#xA;    vals[i] = constrain(analogRead(SENSOR_PIN), 0, 1023);&#xA;  }&#xA;&#xA;  // Freq doesn't need to be 1024 wide, as the max val&#xA;  // from the ACS712 will be limited subset.&#xA;  // 20A = 100mV/A = 20*100mV/1000 = ~2v max voltage range&#xA;  // 2v / 1024 = 0.0048828125v per increment = ~410 potential increment values&#xA;  uint8_t freq[512]{0};&#xA;  uint8_t offset = 250;&#xA;  // count the frequency of specific readings&#xA;  for (uint8_t i=0; i&amp;lt;numReadings; i++) {&#xA;    freq[vals[i]-offset]++;&#xA;  }&#xA;&#xA;  // work out the most frequent value&#xA;  // note that if there is a tie, the lowest value will be used&#xA;  uint8_t maxFreq = 0;&#xA;  int16_t modeVal = -1;&#xA;  for (int i=0; i&amp;lt;512; i++) {&#xA;    if (freq[i] &amp;gt; maxFreq) {&#xA;      maxFreq = freq[i];&#xA;      modeVal = i;&#xA;    }&#xA;  }&#xA;&#xA;  modeVal = modeVal + offset;&#xA;&#xA;  return modeVal;&#xA;}&#xA;&#xA;&#xA;void avgRead() {&#xA;  //debugSerial.println(&quot;_sample()&quot;);&#xA;  // see https://arduino.stackexchange.com/questions/19301/acs712-sensor-reading-for-ac-current for description&#xA;&#xA;  int rVal = 0;&#xA;  unsigned long rSquaredSum = 0;&#xA;&#xA;  // 50hz = 20 milliseconds per wavelength&#xA;  // if we measure for 100ms we will get 5 cycles&#xA;  // 60hz = 16.66667 milliseconds per wavelength, or just over ~6 cycles&#xA;  // from what I can tell, either should be sufficient for our purposes&#xA;  int sampleDuration = 100;       // 100ms&#xA;&#xA;  // each logical &quot;sample&quot; is actually made up of a 100ms sample&#xA;  // for our internal arithmatic, we need to track the number of internal samples&#xA;  // not to be confused with _numSamples which tracks the number of times _sample() &#xA;  // is called between _log()&#xA;  int sampleCount = 0;&#xA;&#xA;  // take samples for 100ms&#xA;  uint32_t startTime = millis();&#xA;  while((millis()-startTime) &amp;lt; sampleDuration)&#xA;  {&#xA;    rVal = analogRead(SENSOR_PIN) - _config.acs712Zero;&#xA;    rSquaredSum += rVal * rVal;&#xA;    sampleCount++;&#xA;  }&#xA;&#xA;  double voltRMS = 5.0 * sqrt(rSquaredSum/sampleCount)/1024.0;&#xA;&#xA;  // x 1000 to convert volts to millivolts&#xA;  // divide by the number of millivolts per amp to determine amps measured&#xA;  // in the case of the 20A component is 100 mv/A&#xA;  double ampsRMS = voltRMS * (1000/ACS_MVPA);&#xA;&#xA;  _numSamples++; // update the overall sample count&#xA;  // add this reading to the summed total(which is averaged before logging)&#xA;  _ampsRMSSum += ampsRMS;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15852" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-05-13T07:07:20.357" Title="Different sensor readings on analog input when connected via USB to self-contained/externally powered" Tags="|sensors|power|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24156" PostTypeId="1" AcceptedAnswerId="24222" CreationDate="2016-05-13T06:22:42.863" Score="14" ViewCount="88070" Body="&lt;p&gt;&lt;H2&gt;IMPORTANT: DO NOT USE &lt;code&gt;AT+IPR=9600&lt;/code&gt;! (see update)&lt;/h2&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an ESP8266 12E module that communicates at 115,200 bauds. Since I use it with an Arduino Nano with SoftwareSerial things get messy. So I found that I should reduce the baud rate of the ESP module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/&quot; rel=&quot;noreferrer&quot;&gt;this link&lt;/a&gt; on how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I am wondering&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Is this a permanent change or do you need to do this every time after the module is powered?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I achieve the same by sending the command from the Arduino over SoftSerial? Well, I guess not since I tried and I always get an error on &lt;code&gt;AT+CIOBAUD=9600&lt;/code&gt; or &lt;code&gt;AT+IPR=9600&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I read somewhere that in newer firmware versions of the ESP8266, the baud rate defaults to 9,600. Can anyone confirm this and if so, is it better to flash this newer firmware?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The module's vendor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ai-Thinker Technology Co.,Ltd.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think the current version of the firmware is 0.3.0. If I send  &lt;code&gt;AT+GMR&lt;/code&gt; I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sending AT+GMR&#xA;&#xA;response: ?AT¥TJÕ¨H(Q�²•ÉÍ¥½¹é‚r¢‚r‚r‚BÕ��Â’‚ŠªŠ¢Ò¢ªÒªÂJm&#xA; SDK versioo:0.3.0&#xA; Ai�½½&#xA; ‚Šj&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again some garbage because of the baud rate which is too high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other info on the module:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sending AT+RST&#xA;response: ?AT+RST&#xA;OK&#xA;WRT&#xA;&quot;%M&#xA;&amp;lt;99CT&#xA; ets Jan  8 2013,rst catse:2, boot lode:(3,7)&#xA;load 0x40100000ntail 4&#xA;chksum 0x89&#xA;ld tail 4&#xA;chm3 tail 8 r 0 aM&#xA; ón't use rtc mem dat`&#xA;sl��oÌÿ&#xA;Ai-Thinker Technology Co.,Ltd.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(*) I used an FTDI232 module to send &lt;code&gt;AT+IPR=9600&lt;/code&gt; to my ESP8266-12E module &lt;strong&gt;and I bricked it&lt;/strong&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DO NOT USE &lt;code&gt;AT+IPR=9600&lt;/code&gt; ON AN ESP8266(-12E).&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did not manage to recover it so far! I tried re-flashing it but I get Invalid head exceptions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a new module I sent the &lt;code&gt;AT+CIOBAUD=9600&lt;/code&gt; command and it worked. Permanently!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My module specs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+GMR &#xA;AT version:0.40.0.0(Aug  8 2015 14:45:58)&#xA;SDK version:1.3.0&#xA;Ai-Thinker Technology Co.,Ltd.&#xA;Build:1.3.0.2 Sep 11 2015 11:48:04&#xA;OK &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19910" LastEditorUserId="972" LastEditDate="2018-08-04T12:24:57.897" LastActivityDate="2018-11-13T04:17:14.720" Title="How to change baudrate of ESP8266 (12e) permanently?" Tags="|arduino-nano|esp8266|firmware|baud-rate|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 4.0" />
  <row Id="24157" PostTypeId="1" AcceptedAnswerId="24160" CreationDate="2016-05-13T06:23:24.613" Score="0" ViewCount="154" Body="&lt;p&gt;I'm running a sketch that looks for inputs to digital pins 3, 4, 5, 6, and 7.  The gist of the sketch is that it's a digitalRead() from 3-7 with a Serial.println() to the monitor. The odd thing is that without any pins connected I'm seeing &quot;0&quot; on some and &quot;1&quot; on others.  I there a reason some will be &quot;0&quot; while other are &quot;1&quot; without anything connected?  I imagine that all pins should read &quot;0&quot; until voltage is detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on my limited experience I draw the conclusion that a &lt;a href=&quot;https://arduino.stackexchange.com/questions/186/button-state-changing-randomly&quot;&gt;pull-up resistor&lt;/a&gt; will likely resolve my problem.  Thoughts? &lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-05-13T08:05:52.093" Title="Digital Pin State - Some 1, Some 0" Tags="|arduino-uno|digital|pull-up|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24158" PostTypeId="2" ParentId="24150" CreationDate="2016-05-13T06:34:24.163" Score="0" Body="&lt;p&gt;I checkmarked Ignacio's answer because it was correct.  But I wanted to leave an answer also as to HOW I supplied 5v when I thought I was supplying 3.3v.  Maybe it will help someone else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fYvBO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fYvBO.jpg&quot; alt=&quot;FTDI backside showing 3.3 or 5v jumpers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The backside of this FTDI module has a jumper to select 3.3 or 5v and the default is set to 5v.  I needed to cut the default trace line connecting to 5v and solder my own jumper to switch it to 3.3v.  I should have double checked the voltage before powering it up.  New ESP01's on order.&lt;/p&gt;&#xA;" OwnerUserId="20413" LastActivityDate="2016-05-13T06:34:24.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24159" PostTypeId="2" ParentId="24155" CreationDate="2016-05-13T07:07:20.357" Score="0" Body="&lt;p&gt;In preparing this question, I realised that the answer may lay in the statement &quot;I've read that the analog pin is referenced to the 5V voltage. This suggests that I should be connecting the ACS712 VCC pin to the Arduino 5V—is this the case?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That made sense to me, so I modified the circuit so that the ACS712 runs off the 5v pin, and I'm now getting around 510 (which is as expected) as a calibration value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have tested with both USB connected and unconnected and getting a consistent result.&lt;/p&gt;&#xA;" OwnerUserId="15852" LastActivityDate="2016-05-13T07:07:20.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24160" PostTypeId="2" ParentId="24157" CreationDate="2016-05-13T08:03:13.427" Score="2" Body="&lt;p&gt;Yep, in fact I would configure them as INPUT_PULLUP (which uses a built-in resistor), unless you are actually wiring pull up resistors of your own to them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;nofollow&quot;&gt;Digital pins Tutorial&lt;/a&gt; has a bit more info on the modes possible.&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-05-13T08:03:13.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24161" PostTypeId="2" ParentId="24157" CreationDate="2016-05-13T08:05:52.093" Score="2" Body="&lt;p&gt;The effect you are seeing is the result of floating pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because the inputs are not at any defined voltage level and will 'follow' the voltage applied. So leaving them unconnected with no defined state will make it look as if its picking up stray signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adding a pull-up resistor, or a pull-down resistor will give you a known  state, the value can be anything from 4.7kohms to 100kohms. So your conclusion to use a resistor is correct.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-05-13T08:05:52.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24162" PostTypeId="2" ParentId="24134" CreationDate="2016-05-13T08:27:27.133" Score="1" Body="&lt;p&gt;You are trying to compile the wrong program for the wrong chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The nice thing about the Arduino core library is that it enables you to&#xA;write code that is portable across various Arduino boards. However, this&#xA;library provides very limited access to the capabilities of the&#xA;underlying hardware. Then, it is quite common for users to mix Arduino&#xA;code with C statements that directly access the hardware registers.&#xA;Doing this provides full control over the hardware, at the cost of&#xA;reduced portability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just an example from your code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;SPCR |= bit (SPE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line is accessing the control register of the SPI port (SPCR means&#xA;“SPI Control Register”) in order to set to 1 the bit named SPE (for “SPI&#xA;Enable”). This is the “bare metal” way of turning on the SPI port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, your problem is that, unlike the ATmega328P powering your Unos, the&#xA;ATtiny84 does &lt;em&gt;not&lt;/em&gt; have a hardware SPI port. Thus the line above just&#xA;makes no sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution: you have to figure out some other means for your chip to&#xA;talk SPI. You could emulate it purely in software, but it would&#xA;certainly be more efficient to use the USI port. The USI (“Universal&#xA;Serial Interface”) is a multipurpose serial port found in many ATtinies.&#xA;It can be configured to do SPI, I2C or simplex/half-duplex UART.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recommended readings:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.atmel.com/images/doc2582.pdf&quot; rel=&quot;nofollow&quot;&gt;AVR319: Using the USI module for SPI&#xA;communication&lt;/a&gt;, an&#xA;application note by ATmel&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://playground.arduino.cc/Code/USI-SPI&quot; rel=&quot;nofollow&quot;&gt;Using an ATtiny2313/4313 as SPI&#xA;master&lt;/a&gt; on the Arduino&#xA;Playground&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may be able to find ready-made libraries for doing this.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-13T08:27:27.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24165" PostTypeId="1" CreationDate="2016-05-13T06:47:43.213" Score="0" ViewCount="580" Body="&lt;p&gt;I am working on a simple Arduino project where I am controlling 5 TowerPro servos. I read that each takes up 2.2 V each so that means the Arduino can only handle about 2 , if using 5V. So far Ive connected 4 with no issues but when I added the 5th the whole thing stopped and the 5V regulator was really hot. That means I don't have enough power and the Arduino is just having a hard time giving not enought volts for all five servos. I just don't know what to do now. Ive tried adding 3  3V battery packs instead of the Arduino but it was smoking. Is there another way to provide the right amount of power for 5 servos without breaking or burning anything!&lt;/p&gt;&#xA;" OwnerDisplayName="Bri V" LastActivityDate="2016-05-13T11:52:28.193" Title="My Arduino is heating up" Tags="|motor|heat|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24166" PostTypeId="2" ParentId="24156" CreationDate="2016-05-13T10:53:01.770" Score="0" Body="&lt;p&gt;Looks like you are you are having power supply issue. What is your power supply rating ? and try adding a small capacitor between vcc and ground. &#xA;Also its good idea to update the firmware to 0.9 which has baudrate issue fixed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find new firmware at&#xA;&lt;a href=&quot;https://github.com/espressif/esp8266_at&quot; rel=&quot;nofollow&quot;&gt;https://github.com/espressif/esp8266_at&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="17211" LastEditorUserId="10394" LastEditDate="2016-05-13T17:46:16.280" LastActivityDate="2016-05-13T17:46:16.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24167" PostTypeId="2" ParentId="24165" CreationDate="2016-05-13T11:52:28.193" Score="2" Body="&lt;p&gt;The voltage regulator on the Arduino is designed to power the logic circuits, and perhaps a few LEDs and other digital devices. It is not designed to power 5 motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You haven't specified what &lt;em&gt;current&lt;/em&gt; they draw - that is the important question, not the voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the comments under your question have said, you need to power the motors separately from the Arduino, not &lt;em&gt;through&lt;/em&gt; it. However, connect the &lt;em&gt;ground wires&lt;/em&gt;, and use the Arduino to control the signal wire to the servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The graphic below shows the general idea. For 5 servos even those batteries are probably not enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice that the power for the motor does not go through the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2Msvz.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Msvz.jpg&quot; alt=&quot;Powering a servo&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-13T11:52:28.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24168" PostTypeId="1" AcceptedAnswerId="24170" CreationDate="2016-05-13T12:56:22.950" Score="1" ViewCount="2014" Body="&lt;p&gt;So I have been diving deep into AVR programming and have seen several different ways of defining constants. I know that some of these methods are from &quot;C&quot; and others are from more modern &quot;C++&quot; methods. So my question here is what is the preferred method?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Method 1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_ARRAY_LEN 3&#xA;&#xA;int my_array[MAX_ARRAY_LEN] = {1, 2, 3};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Method 2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_ARRAY_LEN = 3;&#xA;&#xA;int my_array[MAX_ARRAY_LEN] = {1, 2, 3};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In my searches online I have ran across several pages that mention using PROGMEM in the declarations to load the variable into Flash memory instead of SRAM. The thing I am unclear about using PROGMEM is what should be loaded into Flash and what should be loaded into SRAM? Should I be loading all const into Flash? Are there any performance hits using Flash?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I guess I was not clear on what I was asking. I understand that #define and PROGMEM are not related. My question is there are a couple of methods that can be used to define constants. One is #define (Method 1) and the other is const (Method 2), with the const type comes the PROGMEM, when using Method 2 there are now 2 areas where you can store variables, Flash and SRAM so when do you want to use PROGMEM and when do you want to just leave it, when using method 2? Is there any performance hits when reading from Flash vs SRAM? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that when using method 2 it is now scoped and typed, but are there any other advantages? Are the programs smaller using one vs the other? Are there times that you would want to use one over the other?&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="14761" LastEditDate="2016-05-13T20:15:59.850" LastActivityDate="2016-05-13T21:43:58.970" Title="Arduino Memory Best Practice" Tags="|variables|memory|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24169" PostTypeId="1" CreationDate="2016-05-13T13:09:29.077" Score="1" ViewCount="1392" Body="&lt;p&gt;I'm making a stopwatch that will measure time between two points. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want that stopwatch to have a millisecond accuracy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the start when someone touch the pad it will show like the time of the touch (15.359) 15 seconds and 359 millis. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an arduino uno board.&#xA;Everywhere I read it says that millis its not reliable, and in a feel tests it seems not very accurate. Also a lot of places say to use a RTC, but every RTC I found and read about it seem to use only second and not milliseconds. Others say to use a 32 KHz crystal, but I'm not sure if it will fix this. Could anyone give some ideas? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino will only record time, only that, start and get time and subtract and write on the serial and end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&#xA;&lt;strong&gt;update 1:&lt;/strong&gt; thanks Mattia for the edit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;update2 :&lt;/strong&gt; I was making some  math, and if the device is on for 8 hours, and i want millisecond precision i need something like 30ppb right?&#xA;Would this do the job?&#xA;&lt;a href=&quot;http://www.digikey.com/product-detail/en/abracon-llc/AOCJYR-12.800MHZ-M5649LF/535-12624-1-ND/4989030&quot; rel=&quot;nofollow&quot;&gt;http://www.digikey.com/product-detail/en/abracon-llc/AOCJYR-12.800MHZ-M5649LF/535-12624-1-ND/4989030&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21022" LastEditorUserId="21022" LastEditDate="2016-05-13T15:26:00.780" LastActivityDate="2016-05-13T15:26:00.780" Title="millis() in a millisecond stopwatch" Tags="|time|millis|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24170" PostTypeId="2" ParentId="24168" CreationDate="2016-05-13T13:20:14.990" Score="4" Body="&lt;p&gt;(Duplicate of &lt;a href=&quot;https://stackoverflow.com/questions/1637332/static-const-vs-define&quot;&gt;this&lt;/a&gt;.)&lt;/p&gt;&#xA;&lt;p&gt;In your example, neither definition of &lt;code&gt;MAX_ARRAY_LEN&lt;/code&gt; will use program space nor RAM.  If you were to &lt;em&gt;use&lt;/em&gt; the definition somewhere, it will certainly use program space in the instruction that uses that constant:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (int i=0 i&amp;lt;MAX_ARRAY_LEN, i++)&#xA;  Serial.print( my_array[i] );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this case, a CPU instruction will load the constant 3 into a register.  So you can say that the 3 &amp;quot;used&amp;quot; a byte in the CPU instruction, and is part of the program size.  Most people ignore that, because a loading a &lt;em&gt;variable&lt;/em&gt; into &lt;code&gt;i&lt;/code&gt; uses both RAM and program space.&lt;/p&gt;&#xA;&lt;p&gt;The primary advantage of using &lt;code&gt;const&lt;/code&gt; instead of &lt;code&gt;#define&lt;/code&gt; is that the former allows additional compiler type-checking.&lt;/p&gt;&#xA;&lt;p&gt;C++ has introduced another keyword, &lt;code&gt;constexpr&lt;/code&gt;, which tells the compiler that an entire expression can be evaluated at compile time and reduced to a single constant value.  Read all about it &lt;a href=&quot;https://stackoverflow.com/questions/14116003/difference-between-constexpr-and-const&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To answer your comment, #define's are not stored anywhere.  They are a simple string substituion that happens before the compiler processes the C++ code.&lt;/p&gt;&#xA;&lt;p&gt;When you build your sketch, the source files are processed in several phases.  First, there's a preprocessor phase that consumes all the lines that start with '#'.  The results of the preprocessing are sent to the C++ compiler.  The compiler will see &lt;em&gt;all&lt;/em&gt; the included files &lt;em&gt;inline&lt;/em&gt;, and all #define's will be substituted.&lt;/p&gt;&#xA;&lt;h2&gt;UPDATE&lt;/h2&gt;&#xA;&lt;p&gt;For example, &lt;code&gt;#define XXX 3&lt;/code&gt; will cause the preprocessor to replace all occurrences of &lt;code&gt;XXX&lt;/code&gt; in the C++ file with &lt;code&gt;3&lt;/code&gt;.  The C++ compiler will never see &lt;code&gt;XXX&lt;/code&gt;, it only sees &lt;code&gt;3&lt;/code&gt;.  You could do a search and replace with your editor, and the C++ compiler would not know the difference.  (Well, there are a few more tricks the preprocessor can do for you, but you only asked about defining a numeric constant.)  The generated code would be identical.&lt;/p&gt;&#xA;&lt;p&gt;There is no &amp;quot;global space&amp;quot; for &lt;code&gt;#define&lt;/code&gt; symbols.  There is a &amp;quot;dictionary&amp;quot; in the preprocessor that is used to perform the substitution, but that is ephemeral.&lt;/p&gt;&#xA;&lt;p&gt;PROGMEM is not related to &lt;code&gt;#define&lt;/code&gt; or &lt;code&gt;const&lt;/code&gt; at all.  It is an attribute of a variable that indicates it is to be stored in FLASH, not RAM.  I think the key is that &lt;code&gt;#define&lt;/code&gt; is just string substitution, but &lt;code&gt;const&lt;/code&gt; is a C++ attribute of a C++ variable.  All of these are equivalent:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_ARRAY_SIZE 3&#xA;const uint8_t maxArraySize = MAX_ARRAY_SIZE;&#xA;int array[ maxArraySize ] = { 1,2,3 };&#xA;&#xA;#define FOO 1,2,3&#xA;int array[] = { FOO };&#xA;const uint8_t MAX_ARRAY_SIZE = (uint8_t) sizeof(array)/sizeof(array[0]);&#xA;&#xA;#define MAX_ARRAY_SIZE goofyNameThatMeansNothing&#xA;const uint8_t MAX_ARRAY_SIZE = 3;&#xA;int array[ MAX_ARRAY_SIZE ] = { 1,2,3 };&#xA;&#xA;#define BAR = { 1,2,&#xA;int array[] BAR,3};&#xA;#define MAX_ARRAY_SIZE sizeof(array)/sizeof(array[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope that last 2 goofy examples help illustrate what a &lt;code&gt;#define&lt;/code&gt; is... string substitution.&lt;/p&gt;&#xA;&lt;p&gt;The PROGMEM attribute is a separate &lt;em&gt;thing&lt;/em&gt;.  It can only be added to C++ variables, and it now requires the variable to also be &lt;code&gt;const&lt;/code&gt;.  Extending the above, you could do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define MAX_ARRAY_SIZE 3&#xA;const uint8_t maxArraySize = MAX_ARRAY_SIZE;&#xA;const int array[ maxArraySize ] PROGMEM = { 1,2,3 }; // a flash array, not RAM&#xA;&#xA;#define FOO 1,2,3&#xA;const int array[] PROGMEM = { FOO };&#xA;const uint8_t MAX_ARRAY_SIZE = (uint8_t) sizeof(array)/sizeof(array[0]);&#xA;&#xA;#define MAX_ARRAY_SIZE goofyNameThatMeansNothing&#xA;const uint8_t MAX_ARRAY_SIZE = 3;&#xA;int array[ MAX_ARRAY_SIZE ] PROGMEM = { 1,2,3 };&#xA;&#xA;#define BAR PROGMEM = { 1,2,&#xA;const int array[] BAR,3};&#xA;#define MAX_ARRAY_SIZE 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Again, in that last goofy example I used PROGMEM in the &lt;code&gt;#define BAR&lt;/code&gt;, but it's just some characters as far as the &lt;code&gt;#define&lt;/code&gt; is concerned.  And the last define is just plain wrong, but it will compile.&lt;/p&gt;&#xA;&lt;p&gt;Because there is no validation of a string substitution, it is usually better to use a &lt;code&gt;const type var = value;&lt;/code&gt; that can be validated by the compiler, both when it is defined and again when &lt;code&gt;var&lt;/code&gt; is used in some context.&lt;/p&gt;&#xA;&lt;h2&gt;UPDATE 2&lt;/h2&gt;&#xA;&lt;p&gt;You say,&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;with the const type comes the PROGMEM&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Not really.  &lt;code&gt;const&lt;/code&gt; is the &amp;quot;read-only&amp;quot; attribute, and the compiler enforces that.&lt;/p&gt;&#xA;&lt;p&gt;PROGMEM tells the AVR compiler that, &lt;strong&gt;if storage is required for this variable&lt;/strong&gt;, put it in FLASH memory (a special address range) instead of RAM (a different address range).  Because of the AVR architecture, you must access FLASH differently, with special instructions.  The &lt;code&gt;avr.pgmspace.h&lt;/code&gt; include file has some routines (macros and inline assembler) for reading from those address spaces.&lt;/p&gt;&#xA;&lt;p&gt;I emphasized the &amp;quot;storage space required&amp;quot;, because the compiler can optimize away the storage.  The literal 3 constant &lt;code&gt;MAX_ARRAY_LEN&lt;/code&gt; does not need any storage space.  For this example program:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_ARRAY_LEN PROGMEM = 3;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin( 9600 );&#xA;&#xA;  Serial.println( MAX_ARRAY_LEN );&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is the generated code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println( MAX_ARRAY_LEN );&#xA;156:    50 e0           ldi r21, 0x00   ; 0&#xA;158:    63 e0           ldi r22, 0x03   ; 3&#xA;15a:    70 e0           ldi r23, 0x00   ; 0&#xA;15c:    82 e2           ldi r24, 0x22   ; 34&#xA;15e:    92 e0           ldi r25, 0x02   ; 2&#xA;160:    f7 c2           rjmp    .+1518  ; 0x750 &amp;lt;_ZN5Print7printlnEii&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The compiler knows that storage is not required.  The value &amp;quot;3&amp;quot; is pushed directly onto the stack at program location 0x158.  It did not go to RAM nor FLASH (PROGMEM) to load a 3 into a register, and then push that register's value onto the stack.&lt;/p&gt;&#xA;&lt;p&gt;The compiler knows the value, so it uses the &amp;quot;immediate&amp;quot; form of the instruction to push the 3.&lt;/p&gt;&#xA;&lt;p&gt;However, for this program:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const int MAX_ARRAY_LEN PROGMEM = 3;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin( 9600 );&#xA;&#xA;  Serial.println( (uint16_t) &amp;amp;MAX_ARRAY_LEN, 16 );&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following code is generated:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  e4:   03 00           .word   0x0003  ; ????&#xA;     .&#xA;     .&#xA;     .&#xA;  Serial.println( (uint16_t) &amp;amp;MAX_ARRAY_LEN, 16 );&#xA; 158:   50 e0           ldi r21, 0x00   ; 0&#xA; 15a:   64 ee           ldi r22, 0xE4   ; 228&#xA; 15c:   70 e0           ldi r23, 0x00   ; 0&#xA; 15e:   82 e2           ldi r24, 0x22   ; 34&#xA; 160:   92 e0           ldi r25, 0x02   ; 2&#xA; 162:   b5 c2           rjmp    .+1386      ; 0x6ce &amp;lt;_ZN5Print7printlnEji&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Because I took the address of MAX_ARRAY_LEN, the compiler knew that it had to have storage... in order for it to have an address.  The compiler dutifully locates it in the program space, at 0xE4.  You can see that address being pushed onto the stack at 0x15A.&lt;/p&gt;&#xA;&lt;p&gt;Without the PROGMEM attribute, the following code is generated:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println( (uint16_t) &amp;amp;MAX_ARRAY_LEN, 16 );&#xA; 156:   50 e0           ldi r21, 0x00   ; 0&#xA; 158:   60 e0           ldi r22, 0x00   ; 0&#xA; 15a:   72 e0           ldi r23, 0x02   ; 2&#xA; 15c:   84 e2           ldi r24, 0x24   ; 36&#xA; 15e:   92 e0           ldi r25, 0x02   ; 2&#xA; 160:   b5 c2           rjmp    .+1386      ; 0x6cc &amp;lt;_ZN5Print7printlnEji&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is a RAM address, 0x200.  Long before setup, a 3 is copied from the program space into RAM.  It is using both program space &lt;em&gt;and&lt;/em&gt; RAM.&lt;/p&gt;&#xA;&lt;p&gt;But this is only because I took the address of MAX_ARRAY_LEN.  In almost all cases, you will be using these as scalar values.  The compiler will not allocate any storage space for them, and the PROGMEM attribute is irrelevant.&lt;/p&gt;&#xA;&lt;p&gt;You have another question:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Is there any performance hits when reading from Flash vs SRAM?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Yes.  Reading from flash takes twice as many CPU cycles.  It's always a juggling act.  If you need to squeeze every cycle out, make sure your constants do not even need storage space (i.e., don't take their address).  And if it's a PROGMEM array or structure, consider using a cached value (i.e., loaded into a RAM array or structure).  Sometimes you don't have a choice.  If you are out of RAM, you will have to load them from PROGMEM every time you need them, with a small penalty.  RAM, SPEED, SIZE... pick two.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-13T21:43:58.970" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24171" PostTypeId="2" ParentId="24169" CreationDate="2016-05-13T13:21:29.317" Score="1" Body="&lt;p&gt;The resonator on the Arduino Uno is better than the internal oscillator of the Atmega328p, but still not very precise. Therefore, for accurate measurements, you need to use a better quality crystal. For instance @ 16 MHz. Once you set the correct prescaler in the Arduino, this should give you accurate millis() - as long as the crystal that you're using is accurate.&lt;/p&gt;&#xA;" OwnerUserId="21015" LastEditorUserId="21015" LastEditDate="2016-05-13T13:46:39.753" LastActivityDate="2016-05-13T13:46:39.753" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24172" PostTypeId="1" AcceptedAnswerId="24174" CreationDate="2016-05-13T14:02:16.583" Score="0" ViewCount="57" Body="&lt;p&gt;I'm setting a series of variables with: &lt;code&gt;uint32_t currentLedColor[9]&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to check is if certain ones of those are the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically want to say &lt;code&gt;if currentLedColor[0] and currentLedColor[1] and currentLedColor[2] are equal&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would I write that?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-13T14:12:47.240" Title="Detect if multiple variables are the same?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24173" PostTypeId="1" AcceptedAnswerId="24264" CreationDate="2016-05-13T14:06:31.293" Score="-2" ViewCount="98" Body="&lt;p&gt;Rhetorical, yet silly question: Given an Arduino to manage, what would be the easiest way, in terms of available actuators (price/availability counts) to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) Apply a positive feedback to a cat, in exchange for a good action?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Apply a &lt;em&gt;NEGATIVE&lt;/em&gt; feedback to a cat, like trying to reach forbidden places?&lt;/p&gt;&#xA;" OwnerUserId="21023" LastActivityDate="2016-05-16T16:07:20.823" Title="Best Actuator to Behavioural Positive/Negative Feedback on Cat" Tags="|sensors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24174" PostTypeId="2" ParentId="24172" CreationDate="2016-05-13T14:12:47.240" Score="1" Body="&lt;p&gt;You run multiple checks. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentLedColor[0] == currentLedColor[1] &amp;amp;&amp;amp; currentLedColor[0] == currentLedColor[2]) {&#xA;    // do something&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21015" LastActivityDate="2016-05-13T14:12:47.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24175" PostTypeId="2" ParentId="40" CreationDate="2016-05-13T14:17:16.607" Score="1" Body="&lt;h1&gt;Fritzing&lt;/h1&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This is the new “Code View”! It lets you write your code directly inside Fritzing, and even upload it from there to your microcontroller. It even has a serial monitor. :)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Normally known as a schematic builder, Fritzing has a built in IDE.&lt;br /&gt;&#xA;&lt;a href=&quot;http://blog.fritzing.org/2014/12/02/its-fritzmas-new-fritzing-code-view-release-and-a-little-present/&quot; rel=&quot;nofollow noreferrer&quot;&gt;See here for more.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19796" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-13T14:17:16.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24177" PostTypeId="1" AcceptedAnswerId="24178" CreationDate="2016-05-13T15:38:48.430" Score="11" ViewCount="29830" Body="&lt;p&gt;I'm looking to connect various USB-devices to an Arduino Uno (specifically, a gamepad and a webcam, but I'm interested in the general case). Is this possible without using the USB host shield, since the Uno has a USB port and USB-to-serial converter? I could use the shield, but I'm curious if/why it's neccessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sparkfun website states that:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The SparkFun USB Host Shield contains all of the digital logic and analog circuitry necessary to implement a full-speed USB peripheral/host controller with your Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does the Arduino not already contain this, just needing the proper software (although obviously it's easier to use the already written library for the Host Shield). Or are there hardware limitations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/16043/can-a-ethernet-usb-dongle-be-instead-of-ethernet-shield-for-arduino&quot;&gt;Can a Ethernet USB Dongle be instead of ethernet shield for arduino?&lt;/a&gt;&#xA;(Majenko's answer), it can, in theory, be done with the Due, but not with the Uno. In that case, is this because the Uno uses the ATmega16U2 instead of the FTDI FT232RL for USB communication?&lt;/p&gt;&#xA;" OwnerUserId="21026" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2019-04-13T11:56:03.280" Title="Can the Arduino interface with USB devices without the USB host shield?" Tags="|usb|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24178" PostTypeId="2" ParentId="24177" CreationDate="2016-05-13T16:02:05.010" Score="18" Body="&lt;p&gt;First things first you need to learn the basics of how USB works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In USB there are two main &quot;things&quot;: Hosts and Devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have one Host (usually your computer) and many Devices (such as Arduinos, Printers, Scanners, Webcams, WiFi dongles, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being a host involves knowing about what devices you are going to have attached to you and how to communicate with them. Being a device means just communicating with the host in your own way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see it is a far more complex job being a host than being a device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos are devices. The small USB interface chips they use are very low powered and can only be a device, never a host.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to plug a device into something it has to be a host (note: I am purposely ignoring hubs here). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Due uses a far more powerful chip, and that is capable of being a host (using what is known as On-The-Go mode).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do it with anything less powerful than a Due you require additional hardware that is specifically designed to be a USB host - and that is where the USB host shield comes in. It has a chip that is designed specially to be a USB host so you can plug a device in to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;None of the chips on the Uno are designed to be a host. They just don't have the power. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-13T16:02:05.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24179" PostTypeId="2" ParentId="24177" CreationDate="2016-05-13T16:07:05.800" Score="4" Body="&lt;p&gt;No.  USB strictly distinguishes between host and device roles.  A few chips have functional blocks capable of performing either role, but the 8u2/16u2 are not examples of this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Typical USB serial converters like the FT232, CP210x, CH340, PL2303, etc are also strictly devices and incapable of being hosts&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are inexpensive host-capable MCUs like the Kinetis KL25Z, but to use them in their cheapest form you would need a different software approach (for example mbed rather than Arduino) and a lot more personal effort.  The Teensy-LC is related, but you pay more for the Arduino code loading helper on it than for the MCU that runs your program itself.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-14T01:09:46.960" LastActivityDate="2016-05-14T01:09:46.960" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24180" PostTypeId="2" ParentId="24145" CreationDate="2016-05-13T16:22:42.560" Score="0" Body="&lt;p&gt;It sounds like you might want a preprocessor macro:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define FIRST_COLOR strip.Color(0, 60, 0, 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then later&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FIRST_COLOR;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is basically just text substitution at the initial stage of the compilation process.  It is somewhat conventional to make macros all caps, but not required.  You can also define function-like macros which take arguments.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-13T16:22:42.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24181" PostTypeId="2" ParentId="40" CreationDate="2016-05-13T16:32:59.110" Score="1" Body="&lt;p&gt;Haven't seen anyone mention it yet, but I use VisualMicro for Microsoft Visual Studio (not Atmel), and I like it just fine. It gives you everything you'd normally have in Visual Studio, like intellisense typing. The trial version is the full program, and the license is pretty cheap- like 30 bucks or something. I got my work to pay for a commercial license key. Do recommend! &lt;/p&gt;&#xA;" OwnerUserId="19892" LastActivityDate="2016-05-13T16:32:59.110" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24184" PostTypeId="2" ParentId="439" CreationDate="2016-05-13T18:17:17.600" Score="2" Body="&lt;p&gt;This fixes the problem &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import os&#xA;import sys&#xA;import termios&#xA;import fcntl&#xA;&#xA;        self.fd = sys.stdin.fileno()&#xA;&#xA;        # Stop resetting the arduino on serial connect&#xA;&#xA;        self.newattr = termios.tcgetattr(self.fd)&#xA;        self.newattr[2] = self.newattr[2] &amp;amp; ~termios.HUPCL&#xA;        termios.tcsetattr(self.fd, termios.TCSANOW, self.newattr)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21030" LastEditorUserId="2944" LastEditDate="2016-06-05T10:02:16.073" LastActivityDate="2016-06-05T10:02:16.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24185" PostTypeId="2" ParentId="10440" CreationDate="2016-05-13T18:56:47.557" Score="0" Body="&lt;p&gt;Could you post an example of your updated code?  I'm working on a similar project but a complete n00b as far as using the Arduino goes.&lt;/p&gt;&#xA;" OwnerUserId="21031" LastActivityDate="2016-05-13T18:56:47.557" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24187" PostTypeId="1" CreationDate="2016-05-13T19:19:11.923" Score="0" ViewCount="374" Body="&lt;p&gt;Provided a very simple sketch like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  digitalWrite(1, !digitalRead(1));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... should I expect 5V Arduino to run twice as fast as 3.3V, or are there some internal adjustments in place?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Specifically, I'm wondering about Pro Mini and/or Nano boards. The &quot;speed&quot; here is simply the frequency measured on pin &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To clarify, I'm wondering if there might be some behind-the-scenes frequency divider that makes sure Arduino code always run at the same physical speed, even if the actual MCUs run on different clocks. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Possibly the simplest way of forming this same question: Can the sketch above be used to identify 3.3V Pro Mini boards from 5V versions, with the help of a frequency meter?&lt;/p&gt;&#xA;" OwnerUserId="13966" LastEditorUserId="13966" LastEditDate="2016-05-14T01:23:16.927" LastActivityDate="2016-05-14T01:23:16.927" Title="Will Arduino Pro Mini 3.3V run at half the speed of 5V version?" Tags="|arduino-pro-mini|frequency|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24188" PostTypeId="2" ParentId="24187" CreationDate="2016-05-13T19:24:11.390" Score="1" Body="&lt;p&gt;If the board is running at half the speed (8MHz instead of 16MHz) then everything that isn't based on real time (i.e., millis(), delay() etc) will run at half the speed. It will all take twice as long to do everything.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-13T19:24:11.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24189" PostTypeId="1" AcceptedAnswerId="24190" CreationDate="2016-05-13T19:34:07.430" Score="0" ViewCount="60" Body="&lt;p&gt;Using an  Arduino-Nano, I'm trying to make a circuit that will change the direction of a motor based on two inputs. The input from the Arduino will be amplified by a transistor. Here's the code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int rightIn = 2;&#xA;int rightOut = 3;&#xA;int leftIn = 4;&#xA;int leftOut = 5;&#xA;int rightVal = 0;&#xA;int leftVal = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(rightIn, INPUT);&#xA;  pinMode(leftIn, INPUT);&#xA;  pinMode(rightOut, OUTPUT);&#xA;  pinMode(leftOut, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  rightVal = digitalRead(rightIn);&#xA;  Serial.println(rightVal);&#xA;  leftVal = digitalRead(leftIn);&#xA;  if ((rightVal == HIGH) || (leftVal == HIGH)) {&#xA;    if (rightVal == HIGH) {&#xA;      digitalWrite(rightOut, HIGH);&#xA;      digitalWrite(leftOut, LOW);&#xA;    }&#xA;    if (leftVal == HIGH) {&#xA;      digitalWrite(rightOut, LOW);&#xA;      digitalWrite(leftOut, HIGH);&#xA;    }&#xA;  }&#xA;  else {&#xA;    digitalWrite(rightOut, LOW);&#xA;    digitalWrite(leftOut, LOW);  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the arduino wiring:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pins 3 and 5 are attached to the motors power and ground&lt;/li&gt;&#xA;&lt;li&gt;Pins 2 ad 4 go to an seprate inputs&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21034" LastEditorUserId="19667" LastEditDate="2016-05-14T06:03:24.027" LastActivityDate="2016-05-14T06:03:24.027" Title="2 Direction Motor" Tags="|c++|motor|arduino-nano|" AnswerCount="1" CommentCount="2" ClosedDate="2016-06-01T07:26:44.023" ContentLicense="CC BY-SA 3.0" />
  <row Id="24190" PostTypeId="2" ParentId="24189" CreationDate="2016-05-13T19:36:01.483" Score="0" Body="&lt;p&gt;I think you are mixing up your &lt;code&gt;rightVal&lt;/code&gt; and &lt;code&gt;rightIn&lt;/code&gt;, and your &lt;code&gt;leftVal&lt;/code&gt; and &lt;code&gt;leftIn&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;rightVal = digitalRead(rightIn);&#xA;....&#xA;if (rightIn == HIGH) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-13T19:44:22.590" LastActivityDate="2016-05-13T19:44:22.590" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24191" PostTypeId="2" ParentId="24156" CreationDate="2016-05-13T20:11:17.173" Score="13" Body="&lt;p&gt;Depending on how recent a version of the AT Instruction Set interpreter your chip has, the two instructions you tried may not be valid ones; they are not listed in Espressif's &lt;a href=&quot;https://www.espressif.com/en/file/721/download?token=5D4jCASk&quot; rel=&quot;noreferrer&quot;&gt;ESP8266 AT Instruction Set&lt;/a&gt; document. Searches for either &quot;CIOBAUD&quot; or &quot;IPR&quot; in the current document (version 1.5.3) return no results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The baud rate commands are now &quot;AT+UART_CUR&quot; and &quot;AT+UART_DEF&quot; which configure the entire UART for the current session or the current and future sessions, respectively. The manual's prototype for the command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+UART_DEF=&amp;lt;baudrate&amp;gt;, &amp;lt;databits&amp;gt;, &amp;lt;stopbits&amp;gt;, &amp;lt;parity&amp;gt;, &amp;lt;flow control&amp;gt;&#xA;Example:&#xA;AT+UART_DEF=115200, 8, 1, 0, 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have used these and can confirm that they work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've found using software serial is that it can push 115200 baud well enough to send commands to the device (though I wouldn't build an application that depends on it) but it can only read reliably up to 9600 baud. I've been able to change my devices' baud rates from 115200 baud to 9600 over software serial; you just have to expect garbage coming back and ignore it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Set ESP8266 baud rate to 9600. You only need to do this once per device&#xA;set software serial baud to 115200;&#xA;send &quot;AT+UART_DEF=9600,8,1,0,0&quot;;&#xA;set software serial baud to 9600;&#xA;// From now on, communicate with your device at 9600 baud.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2017-04-12T12:03:38.433" LastActivityDate="2017-04-12T12:03:38.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24192" PostTypeId="1" CreationDate="2016-05-13T20:30:41.450" Score="-1" ViewCount="1751" Body="&lt;p&gt;so I will explain what I want to get.&#xA;I am reading temperature from DS18B20 and showing it on the LCD. &#xA;I have one LED o pin 3 which is blinking when there is a temp reading and screen update. I have another LED on pin 4 which should lit when temp is more than 25 and less than 30, and I want it to blink when temp is more than 30. What I am getting is a blinking but not like one blink every 10ms but it waits for whole loop to start again to blink.&#xA;Can I do it separately that this LED will blink indepentantly when condition is true? With set interval for example 10ms which wont be waiting for whole loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is my example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address&#xA;&#xA;//LiquidCrystal_I2C lcd(0x27, POSITIVE);  // Set the LCD I2C address&#xA;OneWire  ds(2);&#xA;&#xA;unsigned long previousMillis = 0;&#xA;const long interval = 1000;&#xA;int ledState = LOW;&#xA;void setup()&#xA;{&#xA;pinMode(3, OUTPUT);&#xA;pinMode(4, OUTPUT);&#xA;&#xA;  lcd.begin(16,2);               // initialize the lcd &#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius;&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println();&#xA;&#xA;  // the first ROM byte indicates which chip&#xA;  switch (addr[0]) {&#xA;    case 0x10:&#xA;      Serial.println(&quot;  Chip = DS18S20&quot;);  // or old DS1820&#xA;      type_s = 1;&#xA;      break;&#xA;    case 0x28:&#xA;      Serial.println(&quot;  Chip = DS18B20&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    case 0x22:&#xA;      Serial.println(&quot;  Chip = DS1822&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;Device is not a DS18x20 family device.&quot;);&#xA;      return;&#xA;  } &#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;  delay(850);     // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  Serial.print(&quot;  Data = &quot;);&#xA;  Serial.print(present, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;    Serial.print(data[i], HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.print(&quot; CRC=&quot;);&#xA;  Serial.print(OneWire::crc8(data, 8), HEX);&#xA;  Serial.println();&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;  celsius = (float)raw / 16.0;&#xA;&#xA;&#xA;  digitalWrite(3, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(10);              // wait for a second&#xA;  digitalWrite(3, LOW);    // turn the LED off by making the voltage LOW&#xA;&#xA;&#xA;   lcd.home ();&#xA;   lcd.print(&quot;Reading 1&quot;);&#xA;   lcd.setCursor( 0, 1);&#xA;   lcd.print(&quot;temp:&quot;);&#xA;   lcd.print(celsius);&#xA;   lcd.print(&quot;*C&quot;);&#xA;&#xA;   if (celsius &amp;gt;= 25 &amp;amp;&amp;amp; celsius &amp;lt; 30) {&#xA;    digitalWrite(4,HIGH);&#xA;   } else if (celsius &amp;gt;= 30) {&#xA;blink1();&#xA;   } else {&#xA;    digitalWrite(4,LOW);&#xA;   }&#xA;&#xA;}&#xA;&#xA;void blink1() {&#xA;digitalWrite(4,HIGH);&#xA;delay(50);&#xA;digitalWrite(4,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21038" LastActivityDate="2019-10-30T08:48:39.873" Title="Led blinking in the loop in condition" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24193" PostTypeId="2" ParentId="24192" CreationDate="2016-05-13T21:48:40.900" Score="2" Body="&lt;p&gt;Here try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt; &#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;&#xA;&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address&#xA;&#xA;//LiquidCrystal_I2C lcd(0x27, POSITIVE);  // Set the LCD I2C address&#xA;OneWire  ds(2);&#xA;&#xA;const long interval = 1000; //İnterval at which to blink(milliseconds)&#xA;unsigned long previousMillis = 0;&#xA;int ledState = LOW;&#xA;void setup()&#xA;{&#xA;pinMode(3, OUTPUT);&#xA;pinMode(4, OUTPUT);&#xA;&#xA;  lcd.begin(16,2);               // initialize the lcd &#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  byte i;&#xA;  byte present = 0;&#xA;  byte type_s;&#xA;  byte data[12];&#xA;  byte addr[8];&#xA;  float celsius;&#xA;&#xA;  if ( !ds.search(addr)) {&#xA;    ds.reset_search();&#xA;    delay(250);&#xA;    return;&#xA;  }&#xA;&#xA;  Serial.println();&#xA;&#xA;  // the first ROM byte indicates which chip&#xA;  switch (addr[0]) {&#xA;    case 0x10:&#xA;      Serial.println(&quot;  Chip = DS18S20&quot;);  // or old DS1820&#xA;      type_s = 1;&#xA;      break;&#xA;    case 0x28:&#xA;      Serial.println(&quot;  Chip = DS18B20&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    case 0x22:&#xA;      Serial.println(&quot;  Chip = DS1822&quot;);&#xA;      type_s = 0;&#xA;      break;&#xA;    default:&#xA;      Serial.println(&quot;Device is not a DS18x20 family device.&quot;);&#xA;      return;&#xA;  } &#xA;&#xA;  ds.reset();&#xA;  ds.select(addr);&#xA;  ds.write(0x44, 1);        // start conversion, with parasite power on at the end&#xA;&#xA;  delay(850);     // maybe 750ms is enough, maybe not&#xA;  // we might do a ds.depower() here, but the reset will take care of it.&#xA;&#xA;  present = ds.reset();&#xA;  ds.select(addr);    &#xA;  ds.write(0xBE);         // Read Scratchpad&#xA;&#xA;  Serial.print(&quot;  Data = &quot;);&#xA;  Serial.print(present, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for ( i = 0; i &amp;lt; 9; i++) {           // we need 9 bytes&#xA;    data[i] = ds.read();&#xA;    Serial.print(data[i], HEX);&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.print(&quot; CRC=&quot;);&#xA;  Serial.print(OneWire::crc8(data, 8), HEX);&#xA;  Serial.println();&#xA;&#xA;  // Convert the data to actual temperature&#xA;  // because the result is a 16 bit signed integer, it should&#xA;  // be stored to an &quot;int16_t&quot; type, which is always 16 bits&#xA;  // even when compiled on a 32 bit processor.&#xA;  int16_t raw = (data[1] &amp;lt;&amp;lt; 8) | data[0];&#xA;  if (type_s) {&#xA;    raw = raw &amp;lt;&amp;lt; 3; // 9 bit resolution default&#xA;    if (data[7] == 0x10) {&#xA;      // &quot;count remain&quot; gives full 12 bit resolution&#xA;      raw = (raw &amp;amp; 0xFFF0) + 12 - data[6];&#xA;    }&#xA;  } else {&#xA;    byte cfg = (data[4] &amp;amp; 0x60);&#xA;    // at lower res, the low bits are undefined, so let's zero them&#xA;    if (cfg == 0x00) raw = raw &amp;amp; ~7;  // 9 bit resolution, 93.75 ms&#xA;    else if (cfg == 0x20) raw = raw &amp;amp; ~3; // 10 bit res, 187.5 ms&#xA;    else if (cfg == 0x40) raw = raw &amp;amp; ~1; // 11 bit res, 375 ms&#xA;    //// default is 12 bit resolution, 750 ms conversion time&#xA;  }&#xA;  celsius = (float)raw / 16.0;&#xA;&#xA;   lcd.home ();&#xA;   lcd.print(&quot;Reading 1&quot;);&#xA;   lcd.setCursor( 0, 1);&#xA;   lcd.print(&quot;temp:&quot;);&#xA;   lcd.print(celsius);&#xA;   lcd.print(&quot;*C&quot;);&#xA;&#xA;   if (celsius &amp;gt;= 25 &amp;amp;&amp;amp; celsius &amp;lt; 30) {&#xA;    digitalWrite(4,HIGH);&#xA;   } else if (celsius &amp;gt;= 30) {&#xA;blink1();&#xA;   } else {&#xA;    digitalWrite(4,LOW);&#xA;   }&#xA;&#xA;   unsigned long currentMillis = millis();&#xA;&#xA;   if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;&#xA;     previousMillis = currentMillis;&#xA;&#xA;     if (ledState == LOW) {&#xA;       ledState = HIGH;&#xA;     } else {&#xA;       ledState = LOW;&#xA;     }&#xA;&#xA;     digitalWrite(3, ledState);&#xA;   }&#xA;}&#xA;&#xA;void blink1() {&#xA;digitalWrite(4,HIGH);&#xA;delay(50);&#xA;digitalWrite(4,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and also note that i choosed 1000 milliseconds for interval (equal to 1 second) so if you want 10ms as in your first post then change &lt;code&gt;const long interval&lt;/code&gt; to 10&lt;/p&gt;&#xA;" OwnerUserId="20208" LastEditorUserId="20208" LastEditDate="2016-05-13T22:33:58.233" LastActivityDate="2016-05-13T22:33:58.233" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24194" PostTypeId="1" AcceptedAnswerId="24195" CreationDate="2016-05-14T00:20:59.937" Score="0" ViewCount="549" Body="&lt;p&gt;The command is working fine if I type it directly to the serial interface&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+CIPSTART=&quot;TCP&quot;,&quot;192.168.1.5&quot;,1647&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if I want to make it automatic and send it whenever I want from inside the code is not working at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Used this but it's not working (Serial1 is from the hardware sp)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.println(&quot;AT+CIPSTART=&quot;TCP&quot;,&quot;192.168.1.5&quot;,1647&quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any way to arrange the data?&lt;/p&gt;&#xA;" OwnerUserId="3626" LastActivityDate="2018-12-13T14:24:27.743" Title="Manual TCP connection using WiFi ESP8266 module mistyped command" Tags="|serial|wifi|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24195" PostTypeId="2" ParentId="24194" CreationDate="2016-05-14T00:30:58.607" Score="2" Body="&lt;p&gt;You need to escape your quotes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;192.168.1.5\&quot;,1647&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-14T00:30:58.607" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24199" PostTypeId="1" CreationDate="2016-05-14T08:46:41.027" Score="-1" ViewCount="655" Body="&lt;p&gt;I was wondering if its possible to send binary data to an Atmega328p. I don't want to send Arduino code or C code just binary. Is it possible to programme the ATmega328p using binary and how?&lt;/p&gt;&#xA;" OwnerUserId="16124" LastActivityDate="2016-05-20T05:56:43.400" Title="Can you send binary data to arduino AtMega328p?" Tags="|arduino-uno|atmega328|" AnswerCount="2" CommentCount="2" ClosedDate="2016-05-24T20:44:57.023" ContentLicense="CC BY-SA 3.0" />
  <row Id="24200" PostTypeId="2" ParentId="24199" CreationDate="2016-05-14T10:08:16.800" Score="2" Body="&lt;p&gt;The serial port is binary data.&#xA;Because we humans can read text data easier than binary data we mostly send text. This way we only use a very small amount of the possible band with.&lt;br&gt;&#xA;The serial monitor translates your input to binary and the binary input of the arduino to text. If you write a program that uses the serialport directly you can communicate in binary without a prolem.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-05-14T10:08:16.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24201" PostTypeId="1" CreationDate="2016-05-14T11:25:32.737" Score="1" ViewCount="789" Body="&lt;p&gt;I am trying to get RSSI of a network without connecting to it directly but I get an error &quot; error: cast from 'const char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   char ssid[]=&quot;GreenNET&quot;;&#xA;    long rssi = 0;&#xA;&#xA;    void updateRSSI(){&#xA;      rssi = WiFi.RSSI(ssid);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am following this: &lt;a href=&quot;https://www.arduino.cc/en/Reference/WiFiRSSI&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/WiFiRSSI&lt;/a&gt; except I am not passing password since it is not required &lt;code&gt;WiFi.RSSI(wifiAccessPoint);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="21054" LastActivityDate="2018-07-23T19:25:36.773" Title="Wifi rssi converting char[] to uint8_t" Tags="|wifi|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24206" PostTypeId="1" CreationDate="2016-05-14T12:39:28.110" Score="1" ViewCount="188" Body="&lt;p&gt;I am trying to get relays to switch on or off based on if I touch a capacitive sensor, basically a light switch. For some reason, I get two readings that are high capacitive readings when I do a printout. I am not really sure why this is happening. I tried delays in case it was reading my touch too fast but with no luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hardware is basically a 1M resistor between send and receive.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// capactitive sensing&#xA;#include &amp;lt;CapacitiveSensor.h&amp;gt;&#xA;CapacitiveSensor   cs_7_6 = CapacitiveSensor(7,6);&#xA;// 10 megohm resistor between pins 4 &amp;amp; 2, pin 2 is sensor pin, add wire, foil&#xA;const int numReadings = 5;&#xA;int index = 0;                  // the index of the current reading&#xA;int readings[numReadings];      // the readings from the analog input&#xA;int total = 0;                  // the running total&#xA;int average = 0;&#xA;int relay = A2;&#xA;int relay2 = A3;&#xA;int relay3 = A4;&#xA;int relay4 = A5;&#xA;boolean lightState = false;&#xA;// sound sample&#xA;const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)&#xA;unsigned int sample;&#xA;//other&#xA;boolean isRelaysOn = false;&#xA;&#xA;// capacitive sensor&#xA;void setup() {&#xA;  cs_7_6.set_CS_AutocaL_Millis(0xFFFFFFFF);&#xA;  // turn off autocalibrate on channel 1 - just as an example&#xA;  Serial.begin(9600);&#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++)&#xA;    readings[thisReading] = 0;&#xA;  // other&#xA;  pinMode(relay, OUTPUT);&#xA;  pinMode(relay2, OUTPUT);&#xA;  pinMode(relay3, OUTPUT);&#xA;  pinMode(relay4, OUTPUT);&#xA;  turnRelayOff();&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;boolean state = false;&#xA;boolean lastState = true;&#xA;boolean lightTurnedItOff = false;&#xA;&#xA;void loop() {&#xA;  Serial.println(capReading());&#xA;  if(capReading() &amp;gt;= 3000) {&#xA;    Serial.println(&quot;threadhold reached&quot;);&#xA;    lightState = !lightState;&#xA;    controlRelay();&#xA;  }&#xA;}&#xA;&#xA;boolean isOn = false;&#xA;&#xA;void controlRelay() {&#xA;  if(lightState == true &amp;amp;&amp;amp; isOn == false) {&#xA;    turnRelayOn();&#xA;    //delay(1000);&#xA;  }&#xA;  if(lightState == false) {&#xA;    turnRelayOff();&#xA;    // delay(1000);&#xA;  }&#xA;}&#xA;&#xA;void turnRelayOn() {&#xA;  int delayAmount = 100;&#xA;  digitalWrite(relay, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay2, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay3, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay4, LOW);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay4, HIGH);&#xA;  delay(delayAmount);&#xA;  digitalWrite(relay4, LOW);&#xA;  isOn =true;&#xA;}&#xA;&#xA;void turnRelayOff() {&#xA;  digitalWrite(relay, HIGH);&#xA;  digitalWrite(relay2, HIGH);&#xA;  digitalWrite(relay3, HIGH);&#xA;  digitalWrite(relay4, HIGH);&#xA;  isOn = false;&#xA;}&#xA;&#xA;int capReading () {&#xA;  // get average.&#xA;  total= total - readings[index];&#xA;  readings[index] =  cs_7_6.capacitiveSensor(30);&#xA;  total= total + readings[index];&#xA;  index++;&#xA;  if (index &amp;gt;= numReadings)&#xA;    index = 0;&#xA;  average = total / numReadings;&#xA;  delay(100);&#xA;  return average;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output doesn't make much sense sometimes either, here are a few samples:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;11 16 21 22 32 61 74 threadhold reached 6191 threadhold reached 6167&#xA;  threadhold reached 30 15 11 12&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;6 10 17 44 2144 3745 threadhold reached&#xA;  -475 threadhold reached&#xA;  -3129 22 10 12 13&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;15 13 7 20 23 725 2726 2735&#xA;  -6373&#xA;  -3197 threadhold reached 4127 2714 54 40 43 34 24 27 31&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="16832" LastEditorUserId="4628" LastEditDate="2017-04-11T16:27:14.803" LastActivityDate="2017-08-10T10:45:02.943" Title="Capacitive sensor switch" Tags="|c++|switch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24207" PostTypeId="1" CreationDate="2016-05-14T12:47:38.960" Score="2" ViewCount="680" Body="&lt;p&gt;I understand that Arduino programming is procedural and not so much Object Orientated and also that the Arduino or AVR are only single core processors and any kind of &quot;Multitasking&quot; or &quot;Threading&quot; is emulated at best but I was wondering if there is a way to pause program execution in one area temporarily and give another area control? For example say we have the following class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Class A{&#xA;   void Test();&#xA;   void ProgramLoop();&#xA;}&#xA;&#xA;void A::Test(){&#xA;   for (int i = 0; i &amp;lt; 10; i++){&#xA;      //Lots of cool stuff going on here but need to give&#xA;      //Control to someone else say ProgramLoop()&#xA;      Sleep(10);&#xA;   }&#xA;}&#xA;&#xA;void A::ProgramLoop(){&#xA;   Serial.println(&quot;In Program Loop&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in the main file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A testClass;&#xA;&#xA;void Setup(){&#xA;   Serial.begin(57600);&#xA;}&#xA;&#xA;void Loop(){&#xA;   testClass.Test();&#xA;   testClass.ProgramLoop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know I could do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Loop(){&#xA;   if (!testClass.isBusy){&#xA;      testClass.ProgramLoop();&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I am trying to find out if there is a way to control how the program execution gives control? I understand that this is more of a threading topic, thats not what I am trying to get at, I just want to know if this is possible maybe using some sort of built in function or something? Or do my programs have to &quot;Fall Through&quot; being ONLY Procedural?&lt;/p&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2016-05-15T02:13:00.647" Title="Is there a way to pause Program execution?" Tags="|programming|task|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24208" PostTypeId="1" CreationDate="2016-05-14T12:54:58.467" Score="2" ViewCount="218" Body="&lt;p&gt;When I use Mouse.move() method (&lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseMove&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/MouseMove&lt;/a&gt;), what are units of xVal and yPos parameters?&lt;/p&gt;&#xA;" OwnerUserId="21059" LastActivityDate="2016-05-14T13:40:07.863" Title="what units do Mouse.move() use?" Tags="|mouse|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24209" PostTypeId="2" ParentId="24208" CreationDate="2016-05-14T13:40:07.863" Score="1" Body="&lt;p&gt;They're raw HID counts and as such don't have a unit. It is up to the OS to translate them from logical amounts to physical values.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-14T13:40:07.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24210" PostTypeId="1" CreationDate="2016-05-14T14:58:23.230" Score="2" ViewCount="5457" Body="&lt;p&gt;I bought this Arduino clone recently and it has lot of extra holes for pins, but some of them I don't know what they do. There was no instruction manual that came with it. Here's a picture of it, I added a red rectangle around the ones I don't know. (4 pins with X1, SCL/SDA, AREF and blank pin in the bottom)&#xA;&lt;a href=&quot;https://i.stack.imgur.com/KVnWI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KVnWI.jpg&quot; alt=&quot;Arduino uno clone unknown pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I could use the pins SCL SDA 5V GND with my I2C LCD Display because the names of the pins are the same on it. Could it work? Usually I use analog pins to connect the display, does that mean that by using it some analog pins will be used indirectly? I didn't try connecting it because I don't want it to break.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Jbrll.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Jbrll.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do these pins do?&lt;/p&gt;&#xA;" OwnerUserId="11983" LastActivityDate="2023-11-26T06:29:09.337" Title="Purpose of extra holes for pins or Arduino clone" Tags="|arduino-uno|pins|clones|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24211" PostTypeId="2" ParentId="24210" CreationDate="2016-05-14T15:15:33.687" Score="3" Body="&lt;p&gt;It's what they say they are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SDA/SCL are I2C - what used to be A4/A5 on the old footprint. On the '328 based boards those are directly linked to the A4/A5 pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The blank pin isn't used. The 5V next to it is actually mislabelled and should be labelled &quot;IOREF&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AREF has been there since the very first Arduino boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's the standard &quot;R3&quot; Uno footprint, plus some extra breakouts for the I2C in different forms (probably to go with specific I2C devices they also sell).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of that is on the &lt;a href=&quot;https://www.arduino.cc/en/main/arduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Uno's product page&lt;/a&gt; if you'd care to read it some time...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ones by the cheap Chinese USB interface chip will be something to do with that. Maybe RTS/CTS broken out on a header. You can ignore those - they are of no interest at all. In fact, just looking in their direction has a good chance of breaking the USB interface chip. Stay well away.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-14T15:15:33.687" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24212" PostTypeId="2" ParentId="24207" CreationDate="2016-05-14T15:48:41.720" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://create.arduino.cc/projecthub/feilipu/using-freertos-multi-tasking-in-arduino-ebc3cc&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; article gives a great example of multitasking by using &lt;a href=&quot;http://www.freertos.org/&quot; rel=&quot;nofollow&quot;&gt;FreeRTOS&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am pasting the sample code snippet which is pretty much self explanatory.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino_FreeRTOS.h&amp;gt;&#xA;&#xA;// define two tasks for Blink &amp;amp; AnalogRead&#xA;void TaskBlink( void *pvParameters );&#xA;void TaskAnalogRead( void *pvParameters );&#xA;&#xA;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;&#xA;  // Now set up two tasks to run independently.&#xA;  xTaskCreate(&#xA;    TaskBlink&#xA;    ,  (const portCHAR *)&quot;Blink&quot;   // A name just for humans&#xA;    ,  128  // Stack size&#xA;    ,  NULL&#xA;    ,  2  // priority&#xA;    ,  NULL );&#xA;&#xA;  xTaskCreate(&#xA;    TaskAnalogRead&#xA;    ,  (const portCHAR *) &quot;AnalogRead&quot;&#xA;    ,  128 // This stack size can be checked &amp;amp; adjusted by reading Highwater&#xA;    ,  NULL&#xA;    ,  1  // priority&#xA;    ,  NULL );&#xA;&#xA;  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Empty. Things are done in Tasks.&#xA;}&#xA;&#xA;/*--------------------------------------------------*/&#xA;/*---------------------- Tasks ---------------------*/&#xA;/*--------------------------------------------------*/&#xA;&#xA;void TaskBlink(void *pvParameters)  // This is a task.&#xA;{&#xA;  (void) pvParameters;&#xA;&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(13, OUTPUT);&#xA;&#xA;  for (;;) // A Task shall never return or exit.&#xA;  {&#xA;    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second&#xA;    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second&#xA;  }&#xA;}&#xA;&#xA;void TaskAnalogRead(void *pvParameters)  // This is a task.&#xA;{&#xA;  (void) pvParameters;&#xA;&#xA;  // initialize serial communication at 9600 bits per second:&#xA;  Serial.begin(9600);&#xA;&#xA;  for (;;)&#xA;  {&#xA;    // read the input on analog pin 0:&#xA;    int sensorValue = analogRead(A0);&#xA;    // print out the value you read:&#xA;    Serial.println(sensorValue);&#xA;    vTaskDelay(1);  // one tick delay (15ms) in between reads for stability&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21062" LastEditorUserId="3742" LastEditDate="2016-05-15T02:02:19.970" LastActivityDate="2016-05-15T02:02:19.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24214" PostTypeId="2" ParentId="24201" CreationDate="2016-05-14T16:03:46.060" Score="1" Body="&lt;p&gt;The argument passed to &lt;code&gt;RSSI()&lt;/code&gt; must be an integer indicating the array index of the SSID of the WiFi network whose RSSI you want to get. To get that integer, you must first scan for networks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ssid[] = &quot;greenNet&quot;;&#xA;byte num_ssids = 0;&#xA;long rssi = 0;&#xA;&#xA;num_ssids = WiFi.scanNetworks();&#xA;for (byte net = 0; net &amp;lt; num_ssids; net++){&#xA;    rssi = WiFi.RSSI(net);&#xA;    Serial.print(WiFi.SSID(net)); Serial.print(&quot;: &quot;);&#xA;    Serial.println(rssi);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-05-14T16:03:46.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24216" PostTypeId="1" CreationDate="2016-05-14T11:41:38.960" Score="2" ViewCount="778" Body="&lt;p&gt;I want to make a three phase inverter (DC to AC) bridge type using Arduino. For that I want to generate three square wave each is 120° phase shifted and other three waves of main three wave forms inverted for opposite switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone please help me out? I am new to programing in Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  pinMode( 9 , OUTPUT );    &#xA;  pinMode( 10 , OUTPUT );   &#xA;&#xA;  TCCR1A = _BV( COM1A0 ) |_BV( COM1B0 );&#xA;  TCCR1B = _BV( WGM13) | _BV( WGM12);&#xA;  OCR1A = 0;    &#xA;}&#xA;#define PRESCALER 1&#xA;#define PRESCALER_BITS 0x01&#xA;#define CLK 16000000UL    &#xA;&#xA;int setWaveforms( unsigned long freq , int shift ) {&#xA;  unsigned long clocks_per_toggle = (CLK / freq) / 2;    &#xA;  ICR1 = clocks_per_toggle;&#xA;  unsigned long offset_clocks = (clocks_per_toggle * shift) / 180UL; &#xA;  OCR1B= offset_clocks;&#xA;  TCCR1B |= _BV( CS10 ); &#xA;}&#xA;&#xA;void loop() {&#xA;  setWaveforms( 50000 , 120 );&#xA;  delay(1000); &#xA;  setWaveforms( 50000 , 120 );&#xA;  delay(1000); &#xA;  setWaveforms( 50000 , 120 );&#xA;  delay(1000); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I had get 2 waves only but I want to get 6. I am new to Stack Exchange.&lt;/p&gt;&#xA;" OwnerUserId="21056" OwnerDisplayName="user110079" LastEditorUserId="37523" LastEditDate="2019-06-30T19:07:30.760" LastActivityDate="2019-06-30T19:07:30.760" Title="3 square wave pulse by 120° phase shift and 3 inverted of each by Arduino" Tags="|signal-processing|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24217" PostTypeId="2" ParentId="7921" CreationDate="2016-05-14T18:17:06.240" Score="1" Body="&lt;p&gt;Unlike other electric components, a photoresistor(or light-dependent resistor,LDR,or photocell) is a variable resistor. This means its resistance can depend according to light intensity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/z3AcL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/z3AcL.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will go first with half of the circuit diagram to understand clearly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistance of a photoresistor decreases with increasing light intensity. &#xA;Strong Light —&gt; LDR resistance(decreases to 0ohms) So the 10k(ohm) resistor sees closer to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistance of a photoresistor increases with decreasing light intensity. &#xA;Dim Light —&gt;LDR resistance(increases to infinity).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the 10k(ohm) resistor only gets a little voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the full circuit diagram that you want to ask why second resistor is needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lYIyo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lYIyo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key point is Arduino board also has Vcc(5V) and ground. So, there is no current if the potential difference is zero. Therefore, firstly, Vcc(5V) will flow through the photoresistor and go to the 10k(ohm) resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, since there is a parallel circuit, arduino will get the same voltage as the 10k(ohm) resistor. So this LDR resistor does the function of a pull-up resistor which draws the current to VCC.&lt;/p&gt;&#xA;" OwnerUserId="21065" LastEditorUserId="2944" LastEditDate="2016-06-05T10:01:57.370" LastActivityDate="2016-06-05T10:01:57.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24218" PostTypeId="1" CreationDate="2016-05-14T19:08:27.573" Score="0" ViewCount="801" Body="&lt;pre&gt;&lt;code&gt;int j;&#xA;void setup()&#xA;{&#xA;   for(j=2 ; j&amp;lt;=9 ; j++)&#xA;      pinMode( j , OUTPUT );&#xA;   digitalWrite( 2, HIGH );&#xA;}&#xA;void one()&#xA;{&#xA;   digitalWrite( 3, HIGH );&#xA;   digitalWrite( 4, HIGH );&#xA;}&#xA;void all_off()&#xA;{&#xA;   for(j=3 ; j&amp;lt;9 ; j++)&#xA;      digitalWrite( j,LOW);&#xA;}&#xA;void loop()&#xA;{&#xA;   one();&#xA;   delay(1000);&#xA;   all_off();&#xA;   delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Trying to do a blinking &quot;1&quot; (stopped at 1 before continuing other numbers because of this problem ) with a single-digit 7 segment display. Where pin 2 is comnected to the com pins of the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected: display 1 for a second , then turn off for 3 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Reality: display1 for 3 seconds then turn off for a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried putting the delay functions in the one and all_off functions but no use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried changing the delay(1000) to delay(7000) , the off time increased.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tried changing the delay(3000) to delay(1000) , the turn on time changed to 1 second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code should work in order, should it not?  What is happening? How to fix it?&lt;/p&gt;&#xA;" OwnerUserId="21069" LastEditorUserId="313" LastEditDate="2016-05-15T14:50:20.357" LastActivityDate="2016-05-15T14:50:20.357" Title="Delay function not working as intended" Tags="|arduino-uno|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24219" PostTypeId="1" AcceptedAnswerId="24221" CreationDate="2016-05-14T19:12:45.733" Score="0" ViewCount="669" Body="&lt;p&gt;guys ! I want to implement the mass storage example from the LUFA Library to my Arduino Uno, but I do not know where to start. Has anybody done this successfully and could give me a few pieces of advice ?&lt;/p&gt;&#xA;" OwnerUserId="21068" LastActivityDate="2016-05-14T19:40:54.537" Title="Mass Storage with Arduino Uno and LUFA" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24221" PostTypeId="2" ParentId="24219" CreationDate="2016-05-14T19:40:54.537" Score="2" Body="&lt;p&gt;You start by taking the Uno and putting it aside, and picking up an AVR-based Arduino that has native USB device support such as a Leonardo or Esplora. You can then use the build scripts that come with LUFA to build the code for your device.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-14T19:40:54.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24222" PostTypeId="2" ParentId="24156" CreationDate="2016-05-14T20:00:38.473" Score="4" Body="&lt;p&gt;I Connected an FTDI232 module at 115200 baud and could read the specs of the ESP8266 module now:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+GMR &#xA;AT version:0.40.0.0(Aug  8 2015 14:45:58)&#xA;SDK version:1.3.0&#xA;Ai-Thinker Technology Co.,Ltd.&#xA;Build:1.3.0.2 Sep 11 2015 11:48:04&#xA;OK &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After that I sent the &lt;code&gt;AT+IPR=9600&lt;/code&gt; command, which first seemed to do the trick.&#xA;But after reboot of the module, all I got was garbage response, at any baudrate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;DO NOT SEND AT+IPR=9600 TO YOUR ESP8266(12e) MODULE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe the &lt;code&gt;AT+UART_DEF&lt;/code&gt; command - as mentioned by JRobert - works, but I used the  &lt;code&gt;AT+CIOBAUD=9600&lt;/code&gt; command and it worked. Permanently!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this can help others.&lt;/p&gt;&#xA;" OwnerUserId="19910" LastActivityDate="2016-05-14T20:00:38.473" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24224" PostTypeId="2" ParentId="24218" CreationDate="2016-05-14T21:09:25.500" Score="1" Body="&lt;p&gt;Without circuit information and part numbers, one can't say for sure what the problem is.  However, the symptoms suggest that your LEDs turn on when you pull some pin low, rather than when it goes high.  This can happen if, for example, the LED anodes are wired (through a resistor) to V+ and the cathodes are connected to a drive pin.  If, however, the cathodes are connected to  ground through a transistor, positive-logic should apply, rather than negative logic.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-05-14T21:09:25.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24225" PostTypeId="1" AcceptedAnswerId="24226" CreationDate="2016-05-14T19:21:36.763" Score="0" ViewCount="588" Body="&lt;p&gt;Arduino uno with official Wifi Shield take 5 Volts. &#xA;Arduino lights up as it should when powered but the WiFi shield is dead the l9 doesn't light up but works fine when arduino is connected to usb cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use 5 battery holder 5x1.5V = 7.5 V ; 2000 mAH&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;50 mA - Arduino &#xA;300 mA - WiFi shield&#xA;&#xA;350 mA * 5h = 1750 mAh&#xA;&#xA;5xAA = 7.5V ; 2000 mAh&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I missing here something? It should last in the worst case scenario 5 hours with new batteries at 2000 mAH (which I think they have more but I do not have them on me right now). &lt;/p&gt;&#xA;" OwnerDisplayName="Higeath" LastEditorUserId="614" LastEditDate="2016-05-15T02:31:13.610" LastActivityDate="2016-05-15T14:41:15.540" Title="Arduino with wifi shield and 5AA batteries current draw" Tags="|power|wifi|battery|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24226" PostTypeId="2" ParentId="24225" CreationDate="2016-05-14T20:25:13.527" Score="0" Body="&lt;p&gt;As a general answer, yes. AA alkaline should be more around 2500~3000 mAh depending on quality. 5x AA in series would result in 7.5 Volts and 2500 mAh.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's only for almost fully charged batteries. AA batteries can range from 1.6V to 0.8V &quot;dead for most purposes&quot;. As they drain, the voltage drops. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What may be happening is that you are powering the Arduino through its power jack, which goes through a diode, causing a 0.7V drop. Then it goes to the linear regulator which has a very high drop out voltage. Or even via the VIN pin, bypassing the diode. But as the battery drains, the voltage drops below the regulator ' s limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino microcontroller can easily work below 5V. The shield might not.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="Passerby" LastActivityDate="2016-05-14T20:25:13.527" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24227" PostTypeId="1" AcceptedAnswerId="24233" CreationDate="2016-05-14T22:45:46.557" Score="1" ViewCount="753" Body="&lt;p&gt;I'm trying to store four items to EEPROM.  I can do one item no problem, I just don't know how to make the jump to multiple items.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;char sgrpID[31] = &quot;acpilot's arduino&quot;;&#xA;char addrID[51] = &quot;123 any street rd&quot;;&#xA;char zpcdID[11] = &quot;12345&quot;;&#xA;char gwayID[31] = &quot;what a cool toy!&quot;;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  for (int i = 0; i &amp;lt; 6; i++) {&#xA;    EEPROM.write(i, sgrpID[i]);&#xA;    EEPROM.write(i, addrID[i]);&#xA;    EEPROM.write(i, zpcdID[i]);&#xA;    EEPROM.write(i, gwayID[i]);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(sgrpID);&#xA;  Serial.println(addrID);&#xA;  Serial.println(zpcdID);&#xA;  Serial.println(gwayID);&#xA;  delay(99999);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to be able to call on these in a sketch and post them to a db along with dynamic data of some flavor (TBD).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am  on the right path?  Any help, corrections, or general guidance is appreciated.  I've moved beyond the &quot;novice&quot; stage of basic Arduino programming but an completely new to EEPROM.  If in doubt, SLOWER AND LOUDER is by far the best way to communicate key EEPROM concepts to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have reviewed the Arduino EEPROM library but I was reading Greek.  I keep reading it and I'm sure at somepoint I'll recognize a pattrn and start to &quot;get it.&quot;&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-05-17T23:46:44.310" Title="EEPROM - Storing Static Data" Tags="|arduino-uno|memory-usage|eeprom|memory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24228" PostTypeId="1" CreationDate="2016-05-14T23:05:38.117" Score="0" ViewCount="299" Body="&lt;p&gt;I recently gave the students in my Arduino-based programming class a project to write some simple unit tests and fix the bugs that they encountered as they did.  The class in question mostly stores a bunch of Arduino-style String objects, with various getters and setters and a couple of constructors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test code that they're supposed to write involved creating two instances of the class (on the stack) and verifying that the constructors set the values correctly.  When I went through the exercise myself, everything worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the students repeated the exercise, the first object worked.  The second object returned empty strings.  If they commented out the first object, the second object began working.  I couldn't find any obvious mistakes that could explain these failures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After staring at their code for about ten minutes to make sure I wasn't losing it, I compared Arduino IDE versions to make sure my machine was running the same version.  It was.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I unplugged one of their Arduino Uno devices and plugged in my Mega 2560.  The exact same source code passed the unit tests as expected.  That means the test failures were caused by some subtle difference between the Arduino Uno and the Mega 2560—either in the hardware or in the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I file a bug against the Arduino Uno compiler (v1.6.7, though I don't see anything in the 1.6.8/1.6.9 release notes that imply any compiler changes since then), I wanted to make sure I wasn't missing something subtle.  Could somebody take a look at this and see if I missed anything?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've included a condensed version of the class in question below (with irrelevant bits removed).  You can see the complete set of exercises at:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://sites.google.com/a/cabrillo.edu/cs-11m/schedule/unit-testing-exercises&quot; rel=&quot;nofollow&quot;&gt;https://sites.google.com/a/cabrillo.edu/cs-11m/schedule/unit-testing-exercises&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tests failed unexpectedly after they added the second &lt;code&gt;AddressBookEntry&lt;/code&gt; object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Class Declaration (partial)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class AddressBookEntry {&#xA;&#xA;  public:&#xA;    AddressBookEntry(void);&#xA;    AddressBookEntry(String title, String firstName,&#xA;                     String middleName, String lastName,&#xA;                     String suffix);&#xA;&#xA;    String title(void);&#xA;    String firstName(void);&#xA;&#xA;...&#xA;&#xA;  private:&#xA;    String _title;      // Mr.&#xA;    String _firstName;  // Barack&#xA;    String _middleName; // Hussein&#xA;    String _lastName;   // Obama&#xA;    String _suffix;     // Sr.&#xA;&#xA;    String _addressLine1; // The White House&#xA;    String _addressLine2; // 1600 Pennsylvania Ave.&#xA;    String _city;         // Washington&#xA;    String _state;        // DC&#xA;    String _zip;          // 20500&#xA;    String _plusFour;     // 0001   (from 20500-0001)&#xA;&#xA;    String _homePhone;    // Unknown&#xA;    String _mobilePhone;  // Unknown&#xA;    String _workPhone;    // 202-456-1414&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Implementation (partial)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define assert(condition) { \&#xA;  if (!(condition)) { \&#xA;    Serial.print(__FILE__); \&#xA;    Serial.print(&quot;:&quot;); \&#xA;    Serial.print(__LINE__); \&#xA;    Serial.println(&quot;: Assertion failed: &quot; #condition); \&#xA;    while (1); \&#xA;  } \&#xA;}&#xA;&#xA;bool AddressBookEntry::runTests(void)&#xA;{&#xA;  Serial.println(&quot;Running tests.\n&quot;); Serial.flush();&#xA;&#xA;  AddressBookEntry testEntry(&quot;Mr.&quot;, &quot;Jim&quot;, &quot;Bob&quot;, &quot;Murphy&quot;, &quot;Sr.&quot;);&#xA;&#xA;  Serial.println(testEntry.title());&#xA;  Serial.flush();&#xA;&#xA;  assert(testEntry.title() == &quot;Mr.&quot;);&#xA;  assert(testEntry.firstName() == &quot;Jim&quot;);&#xA;  assert(testEntry.middleName() == &quot;Bob&quot;);&#xA;  assert(testEntry.lastName() == &quot;Murphy&quot;);&#xA;  assert(testEntry.suffix() == &quot;Sr.&quot;);&#xA;  testEntry.setMiddleName(&quot;Phil&quot;);&#xA;  assert(testEntry.middleName() == &quot;Phil&quot;);&#xA;&#xA;  AddressBookEntry obamaEntry(&quot;Mr.&quot;, &quot;Barack&quot;, &quot;Hussein&quot;, &quot;Obama&quot;, &quot;&quot;);&#xA;&#xA;&#xA;  assert(obamaEntry.title() == &quot;Mr.&quot;); // fails&#xA;  assert(obamaEntry.firstName() == &quot;Barack&quot;); // fails&#xA;  assert(obamaEntry.middleName() == &quot;Hussein&quot;); // stopped checking here.&#xA;  assert(obamaEntry.lastName() == &quot;Obama&quot;);&#xA;  assert(obamaEntry.suffix() == &quot;&quot;);&#xA;&#xA;  Serial.println(&quot;All tests passed.\n&quot;); Serial.flush();&#xA;}&#xA;&#xA;AddressBookEntry::AddressBookEntry()&#xA;{&#xA;  _title = &quot;&quot;;&#xA;  _firstName = &quot;&quot;;&#xA;  _middleName = &quot;&quot;;&#xA;  _lastName = &quot;&quot;;&#xA;  _suffix = &quot;&quot;;&#xA;&#xA;  _addressLine1 = &quot;&quot;;&#xA;  _addressLine2 = &quot;&quot;;&#xA;  _city = &quot;&quot;;&#xA;  _state = &quot;&quot;;&#xA;  _zip = -1; // Deliberate bug&#xA;  _plusFour = -1; // Deliberate bug&#xA;&#xA;  _homePhone = &quot;&quot;;&#xA;  _mobilePhone = &quot;&quot;;&#xA;  _workPhone = &quot;&quot;;&#xA;}&#xA;&#xA;AddressBookEntry::AddressBookEntry(String title, String firstName,&#xA;                                   String middleName, String lastName,&#xA;                                   String suffix)&#xA;{&#xA;  _title = title;&#xA;  _firstName = firstName;&#xA;  _middleName = middleName;&#xA;  _lastName = lastName;&#xA;  _suffix = suffix;&#xA;&#xA;  _addressLine1 = &quot;&quot;;&#xA;  _addressLine2 = &quot;&quot;;&#xA;  _city = &quot;&quot;;&#xA;  _state = &quot;&quot;;&#xA;  _zip = -1; // Deliberate bug&#xA;  _plusFour = -1; // Deliberate bug&#xA;&#xA;  _homePhone = &quot;&quot;;&#xA;  _mobilePhone = &quot;&quot;;&#xA;  _workPhone = &quot;&quot;;&#xA;&#xA;String str = &quot;&quot;;&#xA;  Serial.println(str + &quot;title is \&quot;&quot; + title + &quot;\&quot;&quot;);&#xA;}&#xA;&#xA;String AddressBookEntry::title()&#xA;{&#xA;  return _title;&#xA;}&#xA;&#xA;String AddressBookEntry::firstName()&#xA;{&#xA;  return _firstName;&#xA;}&#xA;&#xA;... // remaining getters are similar&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Calling Code (from setup() function)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.begin(9600);&#xA;  AddressBookEntry myEntry;&#xA;  myEntry.runTests();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21075" LastActivityDate="2016-05-14T23:55:10.417" Title="Possible Arduino Uno c++ compiler bug?" Tags="|arduino-uno|programming|arduino-mega|c++|class|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24229" PostTypeId="2" ParentId="24228" CreationDate="2016-05-14T23:55:10.417" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;That means the test failures were caused by some subtle difference between the Arduino Uno and the Mega 2560—either in the hardware or in the compiler.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not a subtle difference - a big difference.  The Mega2560 has considerably more RAM than the UNO (8kB compared to 2kB). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All those strings are using RAM. Lots of RAM.  Your Mega2560 has enough RAM to cope (just), but the UNO just dumps its stack in a heap all over the floor&lt;sup&gt;1&lt;/sup&gt; at the mere thought of trying to handle that quantity of string data.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1: That's a technical way of describing the stack and the heap meeting and, if there were no protection, colliding into each other.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-14T23:55:10.417" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24230" PostTypeId="1" CreationDate="2016-05-15T00:01:55.300" Score="1" ViewCount="761" Body="&lt;p&gt;If an external voltage of 7 volts is applied to the external voltage input on the Arduino and the power from the USB port remains connected, is there a protective circuit that will protect the Arduino?  Thank you.&lt;/p&gt;&#xA;" OwnerUserId="15103" LastEditorUserId="16198" LastEditDate="2016-05-15T11:28:30.430" LastActivityDate="2016-05-15T11:28:30.430" Title="Over voltage protection for Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24231" PostTypeId="2" ParentId="24230" CreationDate="2016-05-15T00:21:42.480" Score="2" Body="&lt;p&gt;yes there is. power will be drained from external source(altough 7 volts is around the limit and arduino may switch to usb power) and arduino will still operate at 5v, same as usb. in any case your arduino and usb will be safe.&lt;/p&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="20645" LastEditDate="2016-05-15T00:36:46.870" LastActivityDate="2016-05-15T00:36:46.870" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24232" PostTypeId="2" ParentId="23710" CreationDate="2016-05-15T01:28:13.920" Score="0" Body="&lt;p&gt;I'm having a bunch of problems like this.  I went back to 2.1, and that works, but your sketch can't have any code that uses Serial.  Serial1 is fine, but not Serial, or else the board hangs and your sketch won't autorun when you aren't connected via USB during reset.&lt;/p&gt;&#xA;" OwnerUserId="21077" LastActivityDate="2016-05-15T01:28:13.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24233" PostTypeId="2" ParentId="24227" CreationDate="2016-05-15T02:02:20.530" Score="5" Body="&lt;p&gt;Some things I noticed in your code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are writing everything to the same address (is that intentional?)&lt;/li&gt;&#xA;&lt;li&gt;You are only writing the first 6 six bytes of your arrays (I am pretty sure that is intentional)&lt;/li&gt;&#xA;&lt;li&gt;You are declaring these arrays to be bigger than what you are putting in them (this is again probably intentional, but I am just guessing)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So here is an example of how I would handle the eeprom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;char sgrpID[31] = &quot;acpilot's arduino&quot;;&#xA;char addrID[51] = &quot;123 any street rd&quot;;&#xA;char zpcdID[11] = &quot;12345&quot;;&#xA;char gwayID[31] = &quot;what a cool toy!&quot;;&#xA;&#xA;//These are the definitions of what goes where in memory&#xA;//You do not want everything to have the same number&#xA;const size_t SGRP_ID_EE_START = (0);  //Zero is good address to start&#xA;//To get the next address we merely add the size of the first item&#xA;//With the address of the first item&#xA;const size_t ADDR_ID_EE_START = (sizeof(sgrpID) + SGRP_ID_EE_START);&#xA;//And so on and so forth&#xA;const size_t ZPCD_ID_EE_START = (sizeof(addrID) + ADDR_ID_EE_START);&#xA;const size_t GWAY_ID_EE_START = (sizeof(zpcdID) + ZPCD_ID_EE_START);&#xA;&#xA;//Use this function to write a char array to the EEPROM at&#xA;//The address &quot;address&quot; (and the size of &quot;len&quot;)&#xA;void WriteEepromArray(size_t address,char* arr,size_t len){&#xA;  for (size_t x = 0; x &amp;lt; len; x++){&#xA;    EEPROM.write(address+x,arr[x]);&#xA;  }&#xA;}&#xA;//Use this function to load your char array with values from&#xA;//The EEPROM&#xA;void LoadFromEeprom(size_t address,char* arr,size_t len){  //Be aware that this function modifys the data pointed to by &quot;arr&quot;&#xA;  for (size_t x = 0; x &amp;lt; len; x++){&#xA;    arr[x] = EEPROM.read(address+x);&#xA;  }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  //Some sample writes&#xA;  //               starting address----array-----size of the array&#xA;  WriteEepromArray(SGRP_ID_EE_START   ,sgrpID   ,sizeof(sgrpID));&#xA;  WriteEepromArray(ADDR_ID_EE_START   ,addrID   ,sizeof(addrID));&#xA;  WriteEepromArray(ZPCD_ID_EE_START   ,zpcdID   ,sizeof(zpcdID));&#xA;  WriteEepromArray(GWAY_ID_EE_START   ,gwayID   ,sizeof(gwayID));&#xA;  //Use the following to load:&#xA;  LoadFromEeprom(SGRP_ID_EE_START,sgrpID,sizeof(sgrpID));&#xA;  Serial.println(sgrpID);   //Now it should be loaded&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The comments I hope help....otherwise comment below with what I left out.&lt;/p&gt;&#xA;" OwnerUserId="21078" LastEditorUserId="21078" LastEditDate="2016-05-17T23:46:44.310" LastActivityDate="2016-05-17T23:46:44.310" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24234" PostTypeId="2" ParentId="24207" CreationDate="2016-05-15T02:13:00.647" Score="1" Body="&lt;p&gt;If you have used threading before, this library-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/ivanseidel/ArduinoThread&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ivanseidel/ArduinoThread&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;makes it very easy to schedule tasks in a controlled manner. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would put this in a comment, but I don't have enough reputation yet. &lt;/p&gt;&#xA;" OwnerUserId="18718" LastActivityDate="2016-05-15T02:13:00.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24235" PostTypeId="1" AcceptedAnswerId="24236" CreationDate="2016-05-15T03:24:39.913" Score="1" ViewCount="4217" Body="&lt;p&gt;I am using Mikael Hart's TinyGPS (v.13) library and example code to talk to my module. The LED on the GPS module is lit and flashing which I assume means it is receiving data from the GPS satellites. The module seller claims that the module has a default baud of 38400.&lt;/p&gt;&#xA;&lt;p&gt;I'm pretty sure it's wired up correctly:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TOfy9.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TOfy9.jpg&quot; alt=&quot;Arduino side&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/yILgM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yILgM.jpg&quot; alt=&quot;Neo 6M-0-001 side&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;And my sketch says:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial ss(4, 3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So I read this as Orange (Rx) to pin 4 and Brown (Tx) to pin 3.&lt;/p&gt;&#xA;&lt;p&gt;Any help appreciated&lt;/p&gt;&#xA;" OwnerUserId="21079" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2020-04-18T15:52:05.763" Title="Arduino SoftwareSerial - can't get data from NEO 6M-GPS module" Tags="|gps|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24236" PostTypeId="2" ParentId="24235" CreationDate="2016-05-15T04:23:45.257" Score="2" Body="&lt;p&gt;RX of the Arduino (pin 4, according to the SoftwareSerial statement) goes to the TX of the GPS.  Arduino pin 3 (ss TX) goes to the GPS RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you should use pins 8 &amp;amp; 9 instead.  That would let you use &lt;a href=&quot;https://github.com/PaulStoffregen/AltSoftSerial&quot; rel=&quot;nofollow&quot;&gt;AltSoftSerial&lt;/a&gt;, the best choice when you can't use HardwareSerial (i.e., &lt;code&gt;Serial&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you can't use pins 8 &amp;amp; 9, then &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoSWSerial&lt;/a&gt; is a better choice than SoftwareSerial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And while I'm promoting NeoSWSerial, I'll mention a library I wrote, &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt;...  It's faster and smaller than all other GPS libraries, and very configurable.  It also has several &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Examples.md#diagnostics&quot; rel=&quot;nofollow&quot;&gt;diagnostic programs&lt;/a&gt; and a &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Troubleshooting.md&quot; rel=&quot;nofollow&quot;&gt;Troubleshooting&lt;/a&gt; section in the docs.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-05-15T04:23:45.257" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24237" PostTypeId="1" CreationDate="2016-05-15T04:25:51.017" Score="0" ViewCount="1603" Body="&lt;p&gt;Can I use HC-06 to connect the Arduino to a smartphone (which I am already doing) and thereafter take the data to the internet?&lt;/p&gt;&#xA;" OwnerUserId="21080" LastEditorUserId="21080" LastEditDate="2016-05-16T04:09:07.450" LastActivityDate="2017-05-12T11:13:08.523" Title="Connecting Arduino to internet through HC-06 and then smartphone" Tags="|arduino-uno|hc-05|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24241" PostTypeId="2" ParentId="24237" CreationDate="2016-05-15T08:25:46.073" Score="1" Body="&lt;p&gt;Yes, but not in quite the way you think.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case the smartphone is acting exactly like the PC when you have the Arduino plugged in to it. You have a serial connection. Theoretically you can:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Send a request to the smartphone over the serial bluetooth connection&lt;/li&gt;&#xA;&lt;li&gt;Write some software on the smartphone to interpret that request and perform some action depending on what the request is&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That way the smartphone is then acting like an incredibly expensive and bulky ESP8266.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-15T08:25:46.073" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24243" PostTypeId="2" ParentId="24206" CreationDate="2016-05-15T13:19:03.283" Score="1" Body="&lt;p&gt;In this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;readings[index] =  cs_7_6.capacitiveSensor(30);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...you are assigning an &quot;int&quot; the value from a method of type &quot;long&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Likely you will want to change all your types used to track the capacitance value, including the type of your &quot;capReading&quot; method, to &quot;long&quot;.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-15T13:53:35.687" LastActivityDate="2016-05-15T13:53:35.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24244" PostTypeId="2" ParentId="24225" CreationDate="2016-05-15T14:25:20.677" Score="0" Body="&lt;p&gt;4xAA = 6.0V connected to a standard diode like 1n4001 = ~5.4V (within the specs for an AVR), connect directly to Vdd (+5V on arduino's). Unless there's a reason you need to use a 7.5V pack. Bypass the protection diode &amp;amp; Vreg = less wasted energy on heat/diode drops. IIRC, the WIFI/Ethernet shields can spike to 500mA or so, so that may also be causing extra drain. If your code constantly uses the WIFI radio, it will cause more current spikes as opposed to using the WIFI less in your code. Your avg current will decrease and battery life will go up. You'll save batteries by using 4 instead of 5 and not cause the 5V regulator to drop out and cause power issues by bypassing its input at Vin and connecting the 6V pack with a series diode to drop it to ~5.4V and connecting to +5V on an Arduino. It will also help with Vdrop when the WIFI has a current spike.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that as any battery discharges, it's more of a slope than straight line and then dead, even for lithium packs. look at this link, good info for you to understand.&#xA;&lt;a href=&quot;http://www.powerstream.com/AA-tests.htm&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;http://www.powerstream.com/AA-tests.htm&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21086" LastEditorUserId="21086" LastEditDate="2016-05-15T14:41:15.540" LastActivityDate="2016-05-15T14:41:15.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24245" PostTypeId="2" ParentId="18805" CreationDate="2016-05-15T14:54:27.153" Score="1" Body="&lt;p&gt;I've done this before, but not very practical as a bare &quot;flat-pack&quot; outside its case presents other &quot;issues&quot;, the battery &quot;may&quot; catch fire if punctured or shorted too long.  (read fire hazard when punctured) Lithium fires are like thermite, you can't put them out, tossing water on it will only make it worse.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there's the voltage mismatch (unless you're using a DUE). A POL  boost converter is needed for best efficiency to get 5-5.2V from a 3.7V cell. And a specialized charging IC is needed so that you don't overcharge/over-rate the current charging the pack. (constant-voltage/constant-current regulator type is needed). I think Adafruit has a lithium breakout board for the 3.7V lithium cell charger, it's for their lilypad stuff i think.&lt;/p&gt;&#xA;" OwnerUserId="21086" LastActivityDate="2016-05-15T14:54:27.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24247" PostTypeId="1" CreationDate="2016-05-15T15:36:42.843" Score="5" ViewCount="11145" Body="&lt;p&gt;I was going to update &lt;a href=&quot;https://arduino.stackexchange.com/questions/24148/avr-stl-library&quot;&gt;this question&lt;/a&gt; but I thought that this was different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been trying to get std::vector to work with the latest Arduino. I have tried downloading several libraries found online but I can not get one of them to compile correctly. So here is my question, does anyone CURRENTLY know of a Arduino STL Library that is working? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;StandardCplusplus&lt;/a&gt;: As stated above I tried to use this library but run into problems with the new/delete functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Andy Brown's AVR-STL Library&lt;/a&gt; doesn't even seem to come close to compiling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has a working copy of these two I would love to have a copy or if you can tell me how to get them to compile. Otherwise I really need to find a way to get Vectors working, does anyone have any ideas?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I didn't want to answer this question so it is still active as I am sure there will be additions to this. Anyways I FINALLY got a library to work (for now, so far). I downloaded the &lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus/blob/master/README.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;StandardCplusplus&lt;/a&gt; library and found that in order to get any of the stl functions to work you have to add an include to the &quot;StandardCplusplus.h&quot; file before EVERY use, not just in the first file as stated in the Wiki on the Project page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was able to get vectors to work using the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;StandardCplusplus.h&quot;&#xA;#include &amp;lt;iterator&amp;gt;&#xA;#include &amp;lt;vector&amp;gt;&#xA;&#xA;vector&amp;lt;int&amp;gt; test;&#xA;&#xA;void setup(){&#xA;   Serial.begin(57600);&#xA;&#xA;   test.push_back(1);&#xA;   test.push_back(2);&#xA;   test.push_back(3);&#xA;   test.push_back(4);&#xA;}&#xA;&#xA;void loop(){&#xA;   for (int i = 0; i &amp;lt; test.size(); i++){&#xA;      Serial.println(test[i]);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would still like to know of other working STL Libraries as it seems that there are tons of outdated and old libraries out there.&lt;/p&gt;&#xA;" OwnerUserId="14761" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2017-10-20T11:47:58.943" Title="Current Arduino STL Libraries" Tags="|c++|vector|stl|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24249" PostTypeId="1" AcceptedAnswerId="24253" CreationDate="2016-05-16T00:14:41.470" Score="0" ViewCount="2111" Body="&lt;p&gt;Is it possible to get the Gerber files for the Arduino Uno r3 and the WiFi 101?  I've been teaching myself the SW side of this hobby (with much help from SE Arduino) and I'd like to better understand, or at least get some exposure to, the HW side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are the Arduino Uno and WiFi 101 Gerber files available to the general public or are they considered IP?  I am under the impression that it is open source but I'm not sure where the OS boundary ends.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="26916" LastEditDate="2017-09-08T21:49:17.660" LastActivityDate="2017-09-08T21:49:17.660" Title="Arduino + WiFi 101 Gerber Files" Tags="|arduino-uno|wifi|hardware|pcb-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24253" PostTypeId="2" ParentId="24249" CreationDate="2016-05-16T06:02:29.090" Score="2" Body="&lt;p&gt;On the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO&lt;/a&gt; and &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoWiFiShield101&quot; rel=&quot;nofollow&quot;&gt;Wifi shield&lt;/a&gt; websites in the Documentation section you can download the Schematic (PDF) and PCB layout (Eagle) files. The page already says &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Uno is open-source hardware! You can build your own board using&#xA;  the follwing files&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;With the free version of &lt;a href=&quot;http://www.cadsoftusa.com/download-eagle/freeware/&quot; rel=&quot;nofollow&quot;&gt;Eagle&lt;/a&gt;, you can open it and export to gerber file format.&lt;/p&gt;&#xA;" OwnerUserId="21101" LastActivityDate="2016-05-16T06:02:29.090" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24260" PostTypeId="1" CreationDate="2016-05-16T13:05:26.910" Score="0" ViewCount="63" Body="&lt;p&gt;I am unable to properly connect those things together with batteries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino Uno&#xA;Parallax continuous servo&#xA;Arduino wifi shield&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;5xAA batteries are connected through power jack to arduino which I assumed would power both arduino and the wifi shield and then I have 1 9 volt battery to power 2 servo motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With this setup it seems like I can only get to run 1 servo at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a picture how it looks like: &lt;a href=&quot;https://i.stack.imgur.com/7mGKe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/7mGKe.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm really desperate for any advice/guidance when it comes to powering this thing.&lt;/p&gt;&#xA;" OwnerUserId="21111" LastActivityDate="2016-10-13T19:04:52.520" Title="Arduino uno, 2x parallax continous servos (BOE), wifi shield power draw" Tags="|arduino-uno|power|wifi|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24261" PostTypeId="2" ParentId="24260" CreationDate="2016-05-16T13:14:36.397" Score="1" Body="&lt;p&gt;9V batteries can only supply  very little current. So two servo's is too much. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just use another set of multiple AA batteries for the servo's.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-16T13:14:36.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24262" PostTypeId="1" CreationDate="2016-05-16T14:04:27.197" Score="0" ViewCount="245" Body="&lt;p&gt;I am an arduino rookie and definitely not an expert in electronics, even if I do know the physics that is behind it. &#xA;Before burning my object of experience, I prefer to ask my silly question to the community. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Context : &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I do use a bare stm32 based Nucleo L053R8 board which is arduino compatible. &lt;/li&gt;&#xA;&lt;li&gt;I want a 1 minute long loop during which I send a 1.5V@20mA impulsion during 1 second and a -1.5V@20mA impulsion 30 seconds later. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Question :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;can I simply use and wire two arduino PWM-able pins only to implement that alternating polarity low current? Or will it fail because of unsinked current?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="21112" LastActivityDate="2016-05-16T21:43:38.197" Title="How to implement an alternating current using only two PWM pins on STM32 Nucleo L053R8?" Tags="|pwm|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24263" PostTypeId="2" ParentId="24262" CreationDate="2016-05-16T14:14:01.710" Score="2" Body="&lt;p&gt;It's quite hard to understand what you want from your question, it's quite &quot;woolly&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I will note:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It's not possible to output a negative voltage from a normal microcontroller.&lt;/li&gt;&#xA;&lt;li&gt;Getting a specific voltage (accurately) from PWM requires good filter design and a feedback system to keep the voltage within bounds.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I say it's not possible to output a negative voltage - that is &lt;em&gt;with respect to ground&lt;/em&gt;. Depending on what you are feeding this voltage into you may not need to reference to ground. In this case it is possible to reference the voltage to another IO pin (steady state, output, not PWM). With it set HIGH the PWM pin's filtered voltage will be below that IO pin's voltage and thus appear, &lt;em&gt;with respect to that IO pin,&lt;/em&gt; to be negative.  With the IO pin LOW it will appear, &lt;em&gt;with respect to that IO pin,&lt;/em&gt; to be positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have filtered your PWM signal you will need the output voltage from it to be monitored by an analog input. That can measure the voltage and make sure that your PWM is set to the right duty cycle. Note that the required duty cycle for any one specific voltage will depend largely on the filtering and the load on the output at the time. You will most likely need some form of PID algorithm to constantly adjust the PWM duty cycle. Also remember that your measured voltage will always be &lt;em&gt;with respect to groud,&lt;/em&gt; so you will need to subtract your output reference voltage (the output state of your reference IO pin - high or low) from your measured voltage to get the voltage as seen &lt;em&gt;with respect to the IO pin&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-16T21:43:38.197" LastActivityDate="2016-05-16T21:43:38.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24264" PostTypeId="2" ParentId="24173" CreationDate="2016-05-16T16:07:20.823" Score="0" Body="&lt;p&gt;For the negative feedback, you could use a loud, screetching noise. I would suspect, however, that the cat would eventually get used to it and ignore it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on your cat's tastes, you could use the same hardware for positive feedback - playing, for example, a Mozart tune if that's what your cat is into.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know, a silly answer, but what can you do with a silly question? ;-)&lt;/p&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-05-16T16:07:20.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24265" PostTypeId="1" AcceptedAnswerId="24481" CreationDate="2016-05-16T16:20:46.190" Score="3" ViewCount="11202" Body="&lt;p&gt;I'm using a LinkIt ONE Arduino-like to send sensor data via MQTT.&lt;/p&gt;&#xA;&lt;p&gt;It always worked very well, then out of the blue, it stopped printing anything using Serial.print();&lt;/p&gt;&#xA;&lt;p&gt;But if I ommit the &amp;quot;Serial.begin(9600);&amp;quot; line, the code runs &lt;strong&gt;normally&lt;/strong&gt;, sending sensor data via MQTT, even if I can't see debug output.&lt;/p&gt;&#xA;&lt;p&gt;This shows the problem is on the Serial handling.&lt;/p&gt;&#xA;&lt;p&gt;Since I can't show the entire code here, here's two test cases:&lt;/p&gt;&#xA;&lt;p&gt;1.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;  while(!Serial); //Wait until Serial is ready before printing&#xA;}&#xA;&#xA;void loop() {      &#xA;  Serial1.println(&amp;quot;This came from serial 1&amp;quot;); //does nothing&#xA;  Serial.println(&amp;quot;This came from serial 0&amp;quot;);  //works&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It shows me the following output:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This came from serial 0&lt;/p&gt;&#xA;&lt;p&gt;This came from serial 0&lt;/p&gt;&#xA;&lt;p&gt;Thi&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Looks like the module freezes before the third iteration.&lt;/p&gt;&#xA;&lt;p&gt;But if I omit the lines that aren't printed, from Serial1:&lt;/p&gt;&#xA;&lt;p&gt;2.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  Serial.begin(9600);&#xA;  while(!Serial);  //Wait until Serial is ready before printing&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&amp;quot;This came from serial 0&amp;quot;);  //works&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;No output is shown on Serial monitor.&lt;/p&gt;&#xA;&lt;p&gt;What is the reason behind this? Since Serial1 prints nothing, why can't I remove it?&lt;/p&gt;&#xA;&lt;p&gt;Observations:&lt;/p&gt;&#xA;&lt;p&gt;I tested the code in two LinkIt ONE modules of the same model.&lt;/p&gt;&#xA;&lt;p&gt;I tested it in Arduino SDK 1.6.8, 1.5.6r2 and 1.6.5.&lt;/p&gt;&#xA;&lt;p&gt;Edit:&lt;/p&gt;&#xA;&lt;p&gt;Just made another test using the code below. It blinked two times showing that&lt;/p&gt;&#xA;&lt;p&gt;Serial.begin(9600); runs&lt;/p&gt;&#xA;&lt;p&gt;while(!Serial); runs (it didn't freeze the module waiting for Serial to initialize)&lt;/p&gt;&#xA;&lt;p&gt;But Serial.println(); freezes&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;  pinMode(13, OUTPUT);&#xA;  blink();&#xA;  Serial.begin(9600);&#xA;  blink();&#xA;  while(!Serial); //Wait until Serial is ready before printing&#xA;}&#xA;&#xA;void loop() {      &#xA;  Serial.println(&amp;quot;This came from serial 0&amp;quot;);  //works&#xA;  blink();&#xA;  delay(1000);&#xA;}&#xA;&#xA;void blink(){&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);               // wait for a second&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21117" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-22T16:53:18.387" Title="Serial is freezing arduino" Tags="|serial|programming|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24266" PostTypeId="2" ParentId="24265" CreationDate="2016-05-16T16:58:56.390" Score="-1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;This shows the problem is on the Serial handling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The problem isn't actually in Serial, it's somewhere else.  Many things are able to make the Arduino hang in mid-write.  Show us the any code that you have written, plus links to the libraries you are using, and you'll have your answer in short order.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will guess that you have a low-RAM condition, perhaps exacerbated by heap usage.  Do you use &lt;code&gt;String&lt;/code&gt;?  I notice you're not using the F macro to save RAM.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-05-16T16:58:56.390" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24267" PostTypeId="1" CreationDate="2016-05-16T17:07:09.073" Score="1" ViewCount="804" Body="&lt;p&gt;I've seen that it is possible to use terminal command to verify software instead of using the IDE. Something like &lt;code&gt;arduino --verify lab.ino&lt;/code&gt;.&#xA;Is there a way to do so on Mac OS?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you&lt;/p&gt;&#xA;" OwnerUserId="21120" LastActivityDate="2016-05-17T09:22:14.850" Title="Use terminal command to verify software" Tags="|mac-os|terminal|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24268" PostTypeId="2" ParentId="23293" CreationDate="2016-05-16T17:16:08.953" Score="1" Body="&lt;p&gt;You will not remotely be able to achieve 1000 Hz operation of a loop which performs so many time consuming operations.  Even leaving out the possibility of substantial delay on some attempts to write to the SD card, your serial output alone could never keep up.  A 115200 baud serial implementation can only transmit on the order of 11 thousand characters per second, which means there is only time for 11 or so per your hoped interval, and you produce far more than that.  (And buffering is irrelevant if you are continually producing data faster than you can transmit it)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to achieve a high sampling rate, you are going to have to pare the code down to the bare minimum required functionality and analytically or experimentally determine how much time each portion takes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want regular samples, you are also going to have to study the rate at which the sensor produces them - you may actually want to consider letting the sensor be the timing master, and simply record the samples as they become available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you will need to study the SD card writing process and determine its possible worst-case delay.  To overcome that, you may find that you have to collect your samples in an interrupt and use most of your available RAM to buffer them across the worst-case card delays.  If the data you need to store is only a few megabytes, you might consider an SPI flash for its more &lt;em&gt;deterministic&lt;/em&gt; timing behavior.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-16T17:16:08.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24269" PostTypeId="2" ParentId="24267" CreationDate="2016-05-16T18:41:06.130" Score="0" Body="&lt;p&gt;Use AVRDude, and set the &lt;code&gt;op&lt;/code&gt; field to &lt;code&gt;v&lt;/code&gt; for verify. E.g.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbserial-A703114N -b57600 -D -Uflash:v:/var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/build7a7055aab8d0564b6a7844b201562ffe.tmp/CV-turner.ino.hex:i &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;change &lt;code&gt;/dev/cu.usbserial-A703114N&lt;/code&gt; to your serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;change &lt;code&gt;/var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/build7a7055aab8d0564b6a7844b201562ffe.tmp/CV-turner.ino.hex&lt;/code&gt; to your hex file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info on avrdude at &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sample output would be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf&quot;&#xA;         User configuration file is &quot;/Volumes/Lion-Data/home/.avrduderc&quot;&#xA;         User configuration file does not exist or is not a regular file, skipping&#xA;&#xA;         Using Port                    : /dev/cu.usbserial-A703114N&#xA;         Using Programmer              : arduino&#xA;         Overriding Baud Rate          : 57600&#xA;         AVR Part                      : ATmega328P&#xA;         Chip Erase delay              : 9000 us&#xA;         PAGEL                         : PD7&#xA;         BS2                           : PC2&#xA;         RESET disposition             : dedicated&#xA;         RETRY pulse                   : SCK&#xA;         serial program mode           : yes&#xA;         parallel program mode         : yes&#xA;         Timeout                       : 200&#xA;         StabDelay                     : 100&#xA;         CmdexeDelay                   : 25&#xA;         SyncLoops                     : 32&#xA;         ByteDelay                     : 0&#xA;         PollIndex                     : 3&#xA;         PollValue                     : 0x53&#xA;         Memory Detail                 :&#xA;&#xA;                                  Block Poll               Page                       Polled&#xA;           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff&#xA;           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff&#xA;           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00&#xA;           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00&#xA;           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;&#xA;         Programmer Type : Arduino&#xA;         Description     : Arduino&#xA;         Hardware Version: 2&#xA;         Firmware Version: 1.16&#xA;         Vtarget         : 0.0 V&#xA;         Varef           : 0.0 V&#xA;         Oscillator      : Off&#xA;         SCK period      : 0.1 us&#xA;&#xA;avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;Reading | ################################################## | 100% 0.00s&#xA;&#xA;avrdude: Device signature = 0x1e950f&#xA;avrdude: safemode: lfuse reads as 0&#xA;avrdude: safemode: hfuse reads as 0&#xA;avrdude: safemode: efuse reads as 0&#xA;avrdude: verifying flash memory against /var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/build7a7055aab8d0564b6a7844b201562ffe.tmp/CV-turner.ino.hex:&#xA;avrdude: load data flash data from input file /var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/build7a7055aab8d0564b6a7844b201562ffe.tmp/CV-turner.ino.hex:&#xA;avrdude: input file /var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/build7a7055aab8d0564b6a7844b201562ffe.tmp/CV-turner.ino.hex contains 7902 bytes&#xA;avrdude: reading on-chip flash data:&#xA;&#xA;Reading | ################################################## | 100% 3.34s&#xA;&#xA;avrdude: verifying ...&#xA;avrdude: verification error, first mismatch at byte 0x0002&#xA;         0x64 != 0x6a&#xA;avrdude: verification error; content mismatch&#xA;&#xA;avrdude: safemode: lfuse reads as 0&#xA;avrdude: safemode: hfuse reads as 0&#xA;avrdude: safemode: efuse reads as 0&#xA;avrdude: safemode: Fuses OK (H:00, E:00, L:00)&#xA;&#xA;avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the &lt;code&gt;verification error, first mismatch at byte 0x0002&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS. you need an actual &lt;code&gt;hex&lt;/code&gt; file, not an &lt;code&gt;ino&lt;/code&gt; file. Different compilers and different versions of the Arduino IDE can produce slightly different hex files, for the exact same C-program. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-16T18:41:06.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24273" PostTypeId="1" CreationDate="2016-05-17T05:57:45.717" Score="1" ViewCount="1033" Body="&lt;p&gt;I am using a custom built arduino UNO for some personal projects. I am using a custom optiboot bootloader given by Nick &lt;a href=&quot;https://arduino.stackexchange.com/a/23914/7553&quot;&gt;in this post&lt;/a&gt;. This was done to prevent the three LED flashes on digital pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have noticed a weird thing with the setup. During normal operation, I am able to reset it by pulling the reset pin low. Sometimes, my microcontroller freezes due to noise and I am unable to reset it by pulling the reset pin low. However powering it off and back on still works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am wondering what could be a possible cause for this. Is &lt;s&gt;it the custom bootloader or whether&lt;/s&gt; power on reset is different as compared to normal reset? Is there a way to ensure atmega328 always resetting through reset pin? Can noise affect the chip and make it behave in such a way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After some google searches, I found an issue where people disable the reset pin functionality by setting a fuse but this doesn't seem to be that case because I am able to reset the chip during normal operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Updates and edits:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@Nick - Bootloader seems to be working fine. I have ruled out any issues due to the bootloader that you provided because I am having similar issues with original ones as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Custom arduino has all the necessary circuit elements - including reset pin pullup 10K resistor and 1N4148 protection diode. I am able to program and run the code without any trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes, due to electromagnetic noise, the atmega locks up. GPIO doesn't work. &lt;a href=&quot;https://electronics.stackexchange.com/questions/222921/transient-protection-to-prevent-microcontroller-freeze-selecting-movs-and-tvs&quot;&gt;Here is a separate question explaining this&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;During tests, I leave the board running and wait for that hang-up to occur. During this time period, I deliberately try to induce noise in ac lines (by switching on/off appliances, turning the fan regulator knob etc). When it hangs up, I try to reset it by pulling the reset pin low using a wire. Sometimes it resets and sometimes it doesn't. When it doesn't, the only way out is to power it down and power it up back again.&lt;/p&gt;&#xA;" OwnerUserId="7553" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-05-17T08:20:35.077" Title="Unable to reset arduino with RESET pin" Tags="|atmega328|bootloader|reset|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="24279" PostTypeId="1" AcceptedAnswerId="24281" CreationDate="2016-05-17T09:22:04.597" Score="0" ViewCount="1159" Body="&lt;p&gt;I am trying to open the webpage in ESP8266 via Arduino Mega.&#xA;I have successfully opened the webpage if I use the &lt;strong&gt;AT command&lt;/strong&gt; in the Serial Monitor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The output is perfect&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+IPD,382:HTTP/1.1 200 OK&#xA;Server: nginx&#xA;Date: Sun, 08 May 2016 06:44:47 GMT&#xA;Content-Type: text/html&#xA;Connection: close&#xA;Vary: Accept-Encoding&#xA;X-Powered-By: PHP/5.5.26&#xA;Set-Cookie: PHPSESSID=rnsmo0b4kq07c5mi3mdsu280g4; path=/&#xA;Expires: Thu, 19 Nov 1981 08:52:00 GMT&#xA;Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0&#xA;Pragma: no-cache&#xA;&#xA;S|R190|W5|O31.0|T0|A24|CLOSED&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the output is fine.&#xA;Now If I issue commands using Arduino Serial1.print() and read the output using following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; while( Serial1.available() )&#xA; {&#xA;     inChar = Serial1.read();&#xA;     Serial.write(inChar);&#xA;     //delay(1);         //could play around with this value if buffer overflows are occuring    &#xA; } // while&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The output &lt;strong&gt;skips character randomly&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+IPD,386:HTTP/1.1 200 OK&#xA;Server: nginx&#xA;Date: Tue, 17 May wed-y: HP/.5.26&#xA;SetCooie:PHPESSD=7kameos5kd7aqcn4e54; pth=&#xA;Epirs: hu, 19Nov198 0852:0 GT&#xA;ach-Cotro: n-stre,no-ach, mst-evaidate,pos-chck=, pe-ceck0&#xA;raga: o-cche&#xA;F~SR19|W5O310|T90|ENDLOSD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried different values of &lt;strong&gt;delay()&lt;/strong&gt; but of no help.&#xA;My baudrate is &lt;strong&gt;9600&lt;/strong&gt; for both arduino Serial and ESP8266 Serial1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please tell me what can be the reason.&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="20885" LastEditorUserId="20885" LastEditDate="2016-05-17T09:25:36.690" LastActivityDate="2018-12-21T13:43:20.970" Title="Opening webpage using ESP8266 in Arduino" Tags="|arduino-mega|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24280" PostTypeId="2" ParentId="24267" CreationDate="2016-05-17T09:22:14.850" Score="1" Body="&lt;p&gt;I managed to verify code from terminal by invoking &lt;code&gt;/Applications/Arduino.app/Contents/MacOS/Arduino --verify lab.ino&lt;/code&gt; BUT this command automatically starts the IDE and exits it afterwards. Even with an IDE instance open it will start a new one. This is annoying since it will switch the active workspace away, but it kinda works. See &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;nofollow&quot;&gt;arduino manpage&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21120" LastActivityDate="2016-05-17T09:22:14.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24281" PostTypeId="2" ParentId="24279" CreationDate="2016-05-17T09:25:30.600" Score="0" Body="&lt;p&gt;First things first: &lt;em&gt;never&lt;/em&gt; use a delay when reading from serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are just blindly trying to read data and send it out to another port. That's not going to work unless you know &lt;em&gt;how much data&lt;/em&gt; you need to read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that information is handed to you on a plate - you just need to interpret it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are required to read the serial data as it comes in and decide what it means, then do different things depending on that data.  For instance, when you read the characters &lt;code&gt;+IPD&lt;/code&gt; you know you have an IP Data response to be interpreted.  Just after that comes a comma, and following that a number. That number is how many bytes you then have to read to get your data. So you keep looking and reading until you have received all the data you should be receiving.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-17T09:25:30.600" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24282" PostTypeId="1" CreationDate="2016-05-17T09:27:25.130" Score="2" ViewCount="164" Body="&lt;p&gt;I've built a device using an IMUduino board, which is supposed to be similar to Arduino Leonardo board with a nRF8001 bluetooth. I was able to connect my device to an Android phone using the nRF UART v2.0 app, I tested some examples and it worked with success.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to connect the device to a Windows 10 PC via bluetooth. I have installed the driver of the nRF8001, and I am able to pair both PC-UART. However, when I open the Master control Panel, I cannot find any Master emulator, the menu is empty. Master control panel version is 3.10.0.14.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to connect a device with nRF8001 to a Windows 10 PC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="20988" LastActivityDate="2016-05-17T09:27:25.130" Title="Cannot connect device with nRF8001 Bluetooth LE to Windows 10 PC" Tags="|bluetooth|arduino-leonardo|uart|windows|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24288" PostTypeId="1" AcceptedAnswerId="24312" CreationDate="2016-05-17T12:20:27.823" Score="-1" ViewCount="1413" Body="&lt;p&gt;Found this &quot;Remote IP of TCP Socket&quot; at: &#xA;&lt;a href=&quot;https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc3000/f/851/t/380635&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc3000/f/851/t/380635&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to log the remote ip address of a client.  Using Ethernet, I have accomplished remote ip address logging.  Trying to do the same with the Adafruit CC3000 library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Answer provided; does not respond every time with the correct &quot;client.IP&quot;.&lt;/strong&gt; When it is wrong; client.IP is always &quot;client.IP: 0.0.0.0.0&quot; which occurs more frequently than the correct &quot;client.IP&quot; of my computer.  Why is does this happen?  Is there a solution?   Answer is on the right track; need additional help, so client.IP is correct every time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:  File modified is Adafruit_CC3000_Server.cpp  Only change was to the clientIndex value.  Will this cause an impact on client connecting?  File is contained in &quot;Arduino Stack Exchange.zip&quot; linked in this post and is located in the Adafruit_CC3000 folder of the zip.  Changes are commented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modified files with client ip  returned.  &lt;a href=&quot;https://drive.google.com/open?id=0Byo8QWKyqAT9TUt4d0FteENQS2s&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://drive.google.com/open?id=0Byo8QWKyqAT9TUt4d0FteENQS2s&lt;/a&gt; CC3000.zip  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;William&lt;/p&gt;&#xA;" OwnerUserId="16684" LastEditorUserId="16684" LastEditDate="2016-11-02T00:06:06.353" LastActivityDate="2016-11-02T00:06:06.353" Title="Find remote ip address TCP" Tags="|programming|wifi|library|adafruit|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24289" PostTypeId="1" AcceptedAnswerId="24291" CreationDate="2016-05-17T14:28:45.383" Score="0" ViewCount="77" Body="&lt;p&gt;&lt;a href=&quot;http://www.flipkart.com/grab-em-l293d-motor-driver-arduino-shield/p/itmehvzzpzj4wyby?pid=ETYEHVZZFFHRFMFG&quot; rel=&quot;nofollow&quot;&gt;http://www.flipkart.com/grab-em-l293d-motor-driver-arduino-shield/p/itmehvzzpzj4wyby?pid=ETYEHVZZFFHRFMFG&lt;/a&gt;   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to ask whether this shield will allow me to use the free pins of arduino for other functions?&lt;/p&gt;&#xA;" OwnerUserId="21147" LastActivityDate="2023-05-19T08:03:13.143" Title="Can this Motor shield support other arduino functions?" Tags="|arduino-uno|motor|arduino-motor-shield|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24291" PostTypeId="2" ParentId="24289" CreationDate="2016-05-17T15:13:12.463" Score="0" Body="&lt;p&gt;Yes, this motor shield can allow other components to be used. You just have to make sure that the pins being used by the shield are not used by you for other tasks. Generally all shields are designed such that they do not hamper the productivity of arduino. What use would only a motor driver be? Therefore they ensure that they do not block other pins.&lt;/p&gt;&#xA;" OwnerUserId="10522" LastActivityDate="2016-05-17T15:13:12.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24292" PostTypeId="1" AcceptedAnswerId="24370" CreationDate="2016-05-17T15:22:49.050" Score="0" ViewCount="118" Body="&lt;p&gt;For some reason the Arduino IDE is unable to see my Arduino Uno even though it is connected. I have reinstalled the Arduino software, but no luck come of it. I connected the Arduino to my friends mac, who's could see it.. I am very confused and greatly appreciate any help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zKw7L.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zKw7L.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YQzfD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YQzfD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Shaun&lt;/p&gt;&#xA;" OwnerUserId="21148" LastActivityDate="2016-05-19T11:55:56.790" Title="Arduino IDE unable to see serial connection on OS X El Capitan" Tags="|arduino-uno|serial|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24293" PostTypeId="2" ParentId="24292" CreationDate="2016-05-17T15:50:31.613" Score="-1" Body="&lt;p&gt;In case someone else has this problem..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns out, &lt;strong&gt;you can't be connect to pin D0 whilst using serial.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="21148" LastEditorUserId="10794" LastEditDate="2016-05-18T02:41:37.440" LastActivityDate="2016-05-18T02:41:37.440" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24294" PostTypeId="1" AcceptedAnswerId="24299" CreationDate="2016-05-17T15:59:40.963" Score="0" ViewCount="1763" Body="&lt;pre&gt;&lt;code&gt;int i=0;&#xA;while(i == 0){&#xA;  if(digitalRead(saveSwitch) == HIGH){&#xA;    Serial.print(&quot;New coordinates saved \n&quot;);&#xA;    lat1 = gps.location.lat();&#xA;    Serial.print(&quot;Latitude&quot;);&#xA;    Serial.println(lat1);&#xA;&#xA;    lng1 = gps.location.lng();&#xA;    Serial.print(&quot;Longitude&quot;);&#xA;    Serial.println(lng1);&#xA;    i = 1;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why isn't leaving the while loop?&lt;/p&gt;&#xA;" OwnerUserId="20703" LastEditorUserId="6628" LastEditDate="2016-05-17T16:57:51.300" LastActivityDate="2016-05-19T13:49:06.863" Title="Program around this while loop not working as expected" Tags="|c++|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24298" PostTypeId="2" ParentId="24294" CreationDate="2016-05-17T18:15:12.993" Score="0" Body="&lt;p&gt;Instead of setting i=1, you could use a 'break' command to break out of the while loop.  That way you don't need 'i' at all, you can just do 'while(true)'&lt;/p&gt;&#xA;" OwnerUserId="21146" LastActivityDate="2016-05-17T18:15:12.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24299" PostTypeId="2" ParentId="24294" CreationDate="2016-05-17T19:37:55.467" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why isn't leaving the while loop?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There's a good chance that the code &lt;em&gt;is&lt;/em&gt;  leaving the &lt;code&gt;while&lt;/code&gt; loop, repeatedly.  However, if the code that's shown is in (eg) the &lt;code&gt;loop()&lt;/code&gt; function, &lt;code&gt;i&lt;/code&gt; will be reset to 0 each time the function runs, which will cause the &lt;code&gt;while&lt;/code&gt; loop to start again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As noted in Dave X's comment, you can move &lt;code&gt;int i=0;&lt;/code&gt; to a higher scope. Moving it to file scope, for example, will allow it to retain its value through repeated function calls.  For example, if the code shown is in &lt;code&gt;loop()&lt;/code&gt;, you could put &lt;code&gt;int i=0;&lt;/code&gt; just before &lt;code&gt;void loop() {&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, having generically-named variables like &lt;code&gt;i&lt;/code&gt; declared at a high level is a bad idea, a blunder, a programming faux pas.  An alternative is to leave its declaration within &lt;code&gt;loop()&lt;/code&gt; but add the &lt;code&gt;static&lt;/code&gt; keyword so that &lt;code&gt;i&lt;/code&gt; is allocated only once, rather than being reallocated and reinitialized at each execution of &lt;code&gt;loop()&lt;/code&gt;.  For example:  &lt;code&gt;static int i=0;&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-19T13:49:06.863" LastActivityDate="2016-05-19T13:49:06.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24300" PostTypeId="1" CreationDate="2016-05-17T19:43:26.093" Score="0" ViewCount="307" Body="&lt;p&gt;Im about to develop some home automation. It should be possible to connect new sensors to the main computer. Thats a Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be used as a connector for the I2C sensors? It should be customer friendly. So something like RJ11 or USB. What can be used for that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to send data wirelessly from a I2C sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards&lt;/p&gt;&#xA;" OwnerUserId="21152" LastActivityDate="2016-05-17T19:47:09.737" Title="Connector for I2C sensor" Tags="|i2c|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24301" PostTypeId="2" ParentId="24300" CreationDate="2016-05-17T19:47:09.737" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;What can be used as a connector for the I2C sensors? It should be customer friendly. So something like RJ11 or USB. What can be used for that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Almost anything you like. Whatever is easy to get hold of and use. You only need 4 wires, and they are all low voltage, so nothing too fancy is needed.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to send data wirelessly from a I2C sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. But you can connect the I2C sensor to an Arduino then use that with a wireless interface of some form to send the data wirelessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing for you to know though:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I2C is not suitable for long distance communications. A few inches to a foot or so is about the limit. Anything longer and you will start running into communication problems. For longer distance communications you need to use a more reliable protocol.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-17T19:47:09.737" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24303" PostTypeId="1" AcceptedAnswerId="24309" CreationDate="2016-05-17T21:39:54.103" Score="2" ViewCount="1841" Body="&lt;p&gt;I have worked with Arduino UNO but recently I bought a new Arduino Pro mini 5v 16M and a CH340G converter to work with. I have searched google to connect pins but I found examples that explains this way :&lt;br&gt;&#xA;GND to GND&lt;br&gt;&#xA;VCC to VCC&lt;br&gt;&#xA;Converter RDX to Arduino Pro Mini TXO&lt;br&gt;&#xA;Converter TDX to Arduino Pro Mini RXI&lt;br&gt;&#xA;My problem is that my Arduino Pro Mini (328p) has pins TXD and RXD (not RXI , not TXO) or maybe I have no knowledge about TX,RX, IN and OUT.&lt;br&gt;&#xA;Can someone please help me to connect these wires?&lt;/p&gt;&#xA;" OwnerUserId="6338" LastActivityDate="2016-05-17T22:04:56.957" Title="Arduino Pro mini to CH340G Connection problem" Tags="|arduino-pro-mini|convert|ch340|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24304" PostTypeId="2" ParentId="24303" CreationDate="2016-05-17T21:57:10.803" Score="1" Body="&lt;p&gt;try reversing the tx/rx lines, if the PRO Mini and serial adapter are chinese, you may want to try using your UNO as ISP programmer. See here for a hint/ex:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21086" LastActivityDate="2016-05-17T21:57:10.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24305" PostTypeId="2" ParentId="24265" CreationDate="2016-05-17T21:57:53.223" Score="0" Body="&lt;p&gt;I have bit similar problem. I thing, this is arduino bug.&#xA;When start serial port, must be take out data from Rx. When read buffer overflow my arduino freeze. I can't run delay because when arduino wait, serial port can receive lot of data -&gt; overflow -&gt; freeze. Instead of delay I use own function wait(milis):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void wait(unsigned long wait_time){&#xA;  unsigned long start_time;&#xA;  start_time=millis();&#xA;  while ( millis() &amp;lt; (start_time+wait_time) ){&#xA;    if (serial.available() &amp;gt; 0) serial.read();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21154" LastActivityDate="2016-05-17T21:57:53.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24306" PostTypeId="1" AcceptedAnswerId="24310" CreationDate="2016-05-17T22:00:11.367" Score="1" ViewCount="541" Body="&lt;p&gt;I'm interested in getting the &lt;a href=&quot;https://wiki.microduino.cc/index.php/MCookie_Series&quot; rel=&quot;nofollow&quot;&gt;mCookie&lt;/a&gt; working in Linux — specifically, in Fedora 23. The Arduino IDE (version 1.6.4) is already available. I'm very familiar with Linux, fine with C, and completely new to Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tutorials for &lt;a href=&quot;https://wiki.microduino.cc/index.php/Getting_started:_Windows&quot; rel=&quot;nofollow&quot;&gt;Windows&lt;/a&gt; or &lt;a href=&quot;https://wiki.microduino.cc/index.php/Getting_started:_Mac&quot; rel=&quot;nofollow&quot;&gt;Mac&lt;/a&gt; describe installing a customized version of the IDE along with drivers. Do I &lt;em&gt;need&lt;/em&gt; special drivers on Linux? On the projects' GitHub site, I found &lt;a href=&quot;https://github.com/wasdpkj/Microduino-IDE-Support/tree/master/arduino-ide-Support/[1.6.x]-hardware%28library%29/examples/00.mCookie&quot; rel=&quot;nofollow&quot;&gt;the examples&lt;/a&gt; and &lt;a href=&quot;https://github.com/wasdpkj/Microduino-IDE-Support/tree/master/arduino-ide-Support/[1.6.x]-hardware%28library%29/hardware/Microduino/avr&quot; rel=&quot;nofollow&quot;&gt;a directory called 'avr'&lt;/a&gt; which has promising subdirectories like &quot;bootloaders&quot; and &quot;libraries&quot;, along with files &lt;code&gt;boards.txt&lt;/code&gt; and &lt;code&gt;platform.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I download this stuff and add it to the existing &quot;system&quot; arduino package somehow? How, and what will I need?&lt;/p&gt;&#xA;" OwnerUserId="20298" LastActivityDate="2016-05-18T00:35:49.690" Title="How do I use Microduino (mCookie) on Linux?" Tags="|linux|fedora|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24309" PostTypeId="2" ParentId="24303" CreationDate="2016-05-17T22:04:56.957" Score="0" Body="&lt;p&gt;Generally, lines with names like TX, TXO, and TDX are for serial-data transmit, and  lines with names like RX, RXI, and RDX are for serial-data receive.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect transmit on the CH340G board to receive on the Pro Mini, and vice versa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For typical serial-converter programmers (I don't know specifically about the CH340) you need to connect CTS (Clear to Send, if the programmer has it) to the pin next to BLK on the Pro Mini, and RTS to GRN (DTR).  The RTS-to-DTR (Request to Send, Data Terminal Ready) connection lets the programmer auto-reset the Pro Mini to start programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://yourduino.com/docs/ProMiniPinout.png&quot; rel=&quot;nofollow&quot;&gt;yourduino.com's ProMiniPinout.png&lt;/a&gt; diagram.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-05-17T22:04:56.957" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24310" PostTypeId="2" ParentId="24306" CreationDate="2016-05-17T22:15:50.680" Score="1" Body="&lt;p&gt;First you will need the &lt;code&gt;arduino&lt;/code&gt; 1.6.x package from &lt;code&gt;updates&lt;/code&gt;, not the 1.0.x package from &lt;code&gt;fedora&lt;/code&gt;. Then:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You will be adding a URL to the new Additional Boards Manager URLs option: &lt;a href=&quot;https://github.com/wasdpkj/Microduino-IDE-Support/raw/master/package_Microduino_index.json&quot; rel=&quot;nofollow&quot;&gt;https://github.com/wasdpkj/Microduino-IDE-Support/raw/master/package_Microduino_index.json&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/wasdpkj/Microduino-IDE-Support&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/add-boards-arduino-v164/overview&quot; rel=&quot;nofollow&quot;&gt;This tutorial&lt;/a&gt; tells you where and how to add that URL to the preferences, as well as how to actually install the required support files.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As of this writing, the platform configuration supplied as part of the above won't work out of the box in Linux; you will also have to edit &lt;code&gt;~/.arduino15/packages/Microduino/hardware/avr/1.6.7/platform.txt&lt;/code&gt; to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;replace &lt;code&gt;compiler.path={runtime.tools.avr-gcc.path}/bin/&lt;/code&gt; with just &lt;code&gt;compiler.path=/usr/bin/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;on the line starting &lt;code&gt;recipe.ar.pattern=&lt;/code&gt;, change &lt;code&gt;{archive_file_path}&lt;/code&gt; to &lt;code&gt;{build.path}/{archive_file}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Hopefully this will be fixed in future versions.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You probably also want to prevent ModemManager from probing the serial device with this udev rule, just replace the vendor and product IDs as appropriate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SUBSYSTEM==&quot;usb-serial&quot;, ATTRS{idVendor}==&quot;xxxx&quot;, ATTRS{idProduct}==&quot;xxxx&quot;, ENV{ID_MM_DEVICE_IGNORE}=&quot;1&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastEditorUserId="20298" LastEditDate="2016-05-18T00:35:49.690" LastActivityDate="2016-05-18T00:35:49.690" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24312" PostTypeId="2" ParentId="24288" CreationDate="2016-05-18T00:28:15.580" Score="1" Body="&lt;p&gt;This function is not built-in so you'll have to modify the library slightly. This is one way to do it, I think:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Navigate to the &lt;code&gt;class Adafruit_CC3000_ClientRef&lt;/code&gt; in the file &lt;code&gt;Adafruit_CC3000_Server.h&lt;/code&gt;. In the class definition, just before the &lt;code&gt;private&lt;/code&gt; methods and attributes are defined, you will add a new public attribute as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t ip_addr[4];  // assuming a typical IPv4 address&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It will hold the IP address of each &lt;code&gt;ClientRef&lt;/code&gt; instance as the connection is accepted.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Go to &lt;code&gt;Adafruit_CC3000_Server::acceptNewConnections()&lt;/code&gt; near the end of &lt;code&gt;Adafruit_CC3000_Server.cpp&lt;/code&gt;. A few lines will be added to get the IP address from the CC3000 and store it temporarily in the appropriate &lt;code&gt;struct&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static sockaddr tSocketClientAddr;  // file scope&#xA;static socklen_t addr_len;&#xA;&#xA;// Accept new connections and update the connected clients.&#xA;bool Adafruit_CC3000_Server::acceptNewConnections() {&#xA;  bool newClientCreated = false;&#xA;  // For any unconnected client, see if new connections are pending and accept&#xA;  // them as a new client.&#xA;  for (int i = 0; i &amp;lt; MAX_SERVER_CLIENTS; ++i) {&#xA;    if (!_clients[i].connected()) {&#xA;      // Note: Because the non-blocking option was set for the listening&#xA;      // socket this call will not block and instead return SOC_IN_PROGRESS (-2) &#xA;      // if there are no pending client connections. Also, the address of the &#xA;      // connected client is not needed, so those parameters are set to NULL.&#xA;      cc3k_int_poll();&#xA;      addr_len = sizeof(tSocketClientAddr);&#xA;      int soc = accept(_listenSocket, &amp;amp;tSocketClientAddr, &amp;amp;addr_len);&#xA;      if (soc &amp;gt; -1) {&#xA;        _clients[i] = Adafruit_CC3000_Client(soc);&#xA;        newClientCreated = true;&#xA;      }&#xA;      // else either there were no sockets to accept or an error occured.&#xA;    }&#xA;  }&#xA;  return newClientCreated;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You'll also edit the &lt;code&gt;getClientRef()&lt;/code&gt; method in &lt;code&gt;Adafruit_CC3000_Server.cpp&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_CC3000_ClientRef Adafruit_CC3000_Server::getClientRef(int8_t clientIndex) {&#xA;  if (clientIndex != -1) {&#xA;    Adafruit_CC3000_ClientRef newClient =  Adafruit_CC3000_ClientRef(&amp;amp;_clients[clientIndex]);&#xA;    // at least 2 (family) + 2 (port) + 4 (ip_addr) bytes expected&#xA;    // also check if address is standard ipv4&#xA;    if ((addr_len &amp;gt;= 8) &amp;amp;&amp;amp; (tSocketClientAddr.sa_family == AF_INET)){&#xA;       // copy address into array; in network byte order  &#xA;       memcpy(newClient.ip_addr, &amp;amp;(tSocketClientAddr.sa_data[2]), 4);&#xA;    }&#xA;    return newClient;&#xA;  }&#xA;&#xA;  // Couldn't find a client ready to read, so return a client that is not &#xA;  // connected to signal no clients are available for reading (convention&#xA;  // used by the Ethernet library).&#xA;  return Adafruit_CC3000_ClientRef(NULL);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Save all the files.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Now the address is stored in an array for each client and can be accessed from your sketch. For example, you can access the address in your sketch like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;loop()&lt;/code&gt; of the the &lt;code&gt;HttpServer&lt;/code&gt; example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Adafruit_CC3000_ClientRef client = httpServer.available();&#xA; if (client) {&#xA;   Serial.println(F(&quot;Client connected.&quot;));&#xA;   for (int i = 0; i &amp;lt; 3; i++){&#xA;     Serial.print(client.ip_addr[i]);&#xA;     Serial.print('.');&#xA;   }&#xA;   Serial.println(client.ip_addr[3]); &#xA;   // other code&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Completely untested. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-05-18T21:58:54.357" LastActivityDate="2016-05-18T21:58:54.357" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24315" PostTypeId="1" CreationDate="2016-05-18T05:56:08.747" Score="0" ViewCount="4674" Body="&lt;p&gt;I want to make a server using an ESP8266 (12e) and an Arduino Nano.&#xA;I have got everything hooked and I created a minimal &quot;Hello World&quot; example, based on a number of samples found on the web, which is working fine... as long as the ESP does not receive multiple requests simultaneously.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using SoftwareSerial on pins 8 and 9 of my Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As long as I send one request at the time, things work fine.&#xA;If I use two browsers and send two requests with little interval, things go wrong, and that figures: the &lt;code&gt;sendData()&lt;/code&gt; method just reads from the serial connection. It will consume the new request while waiting for an &quot;OK&quot; from the initial request...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any sample code or library (for ESP + Arduino (nano)) that can handle correctly multiple concurrent connections?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Software serial multple serial test   &#xA; */&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define DEBUG true&#xA;&#xA;SoftwareSerial esp8266(8, 9); // RX, TX&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); // your esp's baud rate might be different : 115200&#xA;&#xA;  Serial.println(&quot;Setup...&quot;);&#xA;&#xA;  /*&#xA;  sendData(&quot;AT+RST\r\n&quot;,2000,DEBUG); // reset module&#xA;  sendData(&quot;AT+GMR\r\n&quot;,1000,DEBUG); // get version&#xA;  sendData(&quot;AT+CWMODE=2\r\n&quot;,1000,DEBUG); // configure as access point&#xA;  sendData(&quot;AT+CIFSR\r\n&quot;,1000,DEBUG); // get ip address&#xA;  sendData(&quot;AT+CIPMUX=1\r\n&quot;,1000,DEBUG); // configure for multiple connections&#xA;  sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;,1000,DEBUG); // turn on server on port 80&#xA;  */&#xA;&#xA;  sendData(&quot;AT+RST\r\n&quot;, 2000,DEBUG);&#xA;  sendData(&quot;AT+GMR\r\n&quot;, 1000, DEBUG);&#xA;&#xA;&#xA;  sendData(&quot;AT+CWMODE=1\r\n&quot;,1000,DEBUG); // configure as station&#xA;  sendData(&quot;AT+CWJAP=\&quot;******\&quot;,\&quot;*******\&quot;\r\n&quot;, 6000, DEBUG);&#xA;  sendData(&quot;AT+CIFSR\r\n&quot;,1000,DEBUG); // get ip address&#xA;  sendData(&quot;AT+CIPMUX=1\r\n&quot;,1000,DEBUG); // configure for multiple connections&#xA;  sendData(&quot;AT+CIPSERVER=1,80\r\n&quot;,1000,DEBUG); // turn on server on port 80&#xA;&#xA;&#xA;  Serial.println(&quot;Setup ready.&quot;);&#xA;}&#xA;&#xA;//WIRE RESET TO HIGH!!?&#xA;&#xA;void loop() { // run over and over&#xA;&#xA;if(esp8266.available()) // check if the esp is sending a message &#xA;  {&#xA;&#xA;    if(esp8266.find(&quot;+IPD,&quot;))&#xA;    {&#xA;     delay(1000);&#xA;&#xA;     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns &#xA;                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48&#xA;&#xA;     String webpage = &quot;&amp;lt;html&amp;gt;&amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;&amp;lt;/html&amp;gt;&quot;;&#xA;&#xA;     String cipSend = &quot;AT+CIPSEND=&quot;;&#xA;     cipSend += connectionId;&#xA;     cipSend += &quot;,&quot;;&#xA;     cipSend +=webpage.length();&#xA;     cipSend +=&quot;\r\n&quot;;&#xA;&#xA;     sendData(cipSend,1000,DEBUG);&#xA;     sendData(webpage,1000,DEBUG);   &#xA;&#xA;     String closeCommand = &quot;AT+CIPCLOSE=&quot;; &#xA;     closeCommand+= connectionId; // append connection id&#xA;     closeCommand+=&quot;\r\n&quot;;&#xA;&#xA;     sendData(closeCommand,250,DEBUG);&#xA;    }&#xA;  }&#xA;&#xA;}&#xA;&#xA;String sendData(String command, const int timeout, boolean debug)&#xA;{&#xA;    String response = &quot;?&quot;;&#xA;    int pos = -5;&#xA;&#xA;    Serial.println(&quot;--------------&quot;);&#xA;    Serial.println(&quot; sending &quot;+command);&#xA;&#xA;    esp8266.print(command); // send the read character to the esp8266&#xA;&#xA;    long int _timeout = timeout + millis();&#xA;&#xA;    while( (_timeout) &amp;gt; millis())&#xA;    {&#xA;      while(esp8266.available())&#xA;      {&#xA;        // The esp has data so display its output to the serial window &#xA;        char c = esp8266.read(); // read the next character.&#xA;        response+=c;&#xA;        pos+=1;&#xA;        if(pos&amp;gt;=0 &amp;amp;&amp;amp; response.substring(pos) == &quot;\r\nOK\r\n&quot;){&#xA;          //WE GOT OK -&amp;gt; stop waiting&#xA;          _timeout=0;&#xA;        }&#xA;      }  &#xA;    }&#xA;&#xA;    if(debug)&#xA;    {&#xA;      Serial.println(&quot; response: &quot;+response);&#xA;    }&#xA;&#xA;    return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19910" LastActivityDate="2017-10-06T07:24:48.063" Title="How to serve multiple connections with an ESP8266 and an Adruino?" Tags="|arduino-nano|esp8266|web-server|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24319" PostTypeId="2" ParentId="22633" CreationDate="2016-05-18T07:35:50.130" Score="-1" Body="&lt;p&gt;I had similar problem. I have added gsm.begin() method at the end of the loop, and it has solved my problem!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems like you can't send multiple http requests with single gsm session. &#xA;Relevant parts of setup() and loop() methods are shown below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;GSM Shield testing.&quot;);&#xA;&#xA;if (gsm.begin(2400)){&#xA;  Serial.println(&quot;\nstatus=READY&quot;);&#xA;  started=true;  &#xA;}&#xA;else Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;   if(started){&#xA;      if(inet.attachGPRS(&quot;internet.wind&quot;,&quot;&quot;,&quot;&quot;))&#xA;        Serial.println(&quot;status=ATTACHED&quot;);&#xA;      else&#xA;        Serial.println(&quot;status=ERROR&quot;);&#xA;&#xA;      if(inet.httpPOST(server,port, path,parameters,msg, 50)){&#xA;          Serial.println(&quot;Data sent to server succesfully!&quot;);&#xA;      }&#xA;      else{&#xA;        Serial.println(&quot;Failed to send data to the server&quot;);&#xA;      }&#xA; } &#xA;&#xA; if (gsm.begin(2400)){&#xA;  Serial.println(&quot;\nstatus=READY&quot;);&#xA;  started=true;  &#xA;}&#xA;else Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21165" LastEditorUserId="10794" LastEditDate="2016-06-04T22:18:40.493" LastActivityDate="2016-06-04T22:18:40.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24320" PostTypeId="1" CreationDate="2016-05-18T08:11:27.243" Score="2" ViewCount="956" Body="&lt;p&gt;I use a mega 2560, pir sensor and a SG90 9g Servo motor in my project. Basically while the pir outputs high, the Servo Motor rotates from 0 to 180 degrees. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how everything is wired up:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PIR sensor:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Data: pin 24&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vcc: 5 volt &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gnd: Ground &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Servo:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PWM pin: pin 11 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vcc: 5 volt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground: ground &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The arduino mega has two 5 volt and ground pins, one next to the analog pins and other at tho bottom bar of pin, where pins 22 and up are. I connected the Servo to the first 5v and gnd and the pir to the second. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My power source is my nexus 5 charger(5v 1.8 or 2 A). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Servo myservo; &#xA;&#xA;    void setup() {&#xA;      myservo.attach(11);  &#xA;     pinMode(24, INPUT);&#xA;    }&#xA;&#xA;    void loop() {&#xA;     if(digitalRead(24) == HIGH){&#xA;       myservo.write(0);&#xA;       delay(500);&#xA;       myservo.write(180);&#xA;       delay(500);&#xA;     }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All of this works fine for the first ~10 hours. After that the arduino just shuts down. The power led of the arduino isn't lit up. Disconnecting the adapter and reconnecting it or pressing the reset button of the arduino doesn't work.  I Have to wait for a couple of minutes with the adapter disconnected and reconnect it. After that it works fine for the next ~10 hours. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems like a hardware issue, but I'm not sure what exactly fails and why. &lt;/p&gt;&#xA;" OwnerUserId="21167" LastActivityDate="2016-07-18T09:05:53.637" Title="Arduino shuts off and doesn't turn on after couple hours" Tags="|arduino-mega|power|servo|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24322" PostTypeId="1" CreationDate="2016-05-18T08:38:21.673" Score="1" ViewCount="2137" Body="&lt;p&gt;I've been used the ACS712-20A to measure the current flow. Actually I used LIFA program (LabVIEW interface for Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used this equation:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;current = ((analog read)-2.5 )/ 0.1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I am still not sure with the result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestion?&lt;/p&gt;&#xA;" OwnerUserId="21124" LastEditorUserId="9962" LastEditDate="2016-09-19T02:52:19.530" LastActivityDate="2016-12-18T04:16:12.963" Title="How to convert voltage to current from ACS712-20A?" Tags="|arduino-mega|voltage-level|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24323" PostTypeId="2" ParentId="24320" CreationDate="2016-05-18T09:32:41.980" Score="0" Body="&lt;p&gt;&lt;code&gt;The power led of the arduino isn't lit up.&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The power LED is implemented in hardware, basically, if it's not lit, it won't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Find the problems' (power?)source&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After the 10h operation, your Arduino isn't on anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the power supply still have 5V available at that point? Or does your Arduino's chips get hot or short-circuit the supply? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Exclude as much variables as possible&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't know what the problem is, it could be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The supply&lt;/li&gt;&#xA;&lt;li&gt;The Arduino&lt;/li&gt;&#xA;&lt;li&gt;The Servo&lt;/li&gt;&#xA;&lt;li&gt;The PIR&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Try another supply (preferably through the barrel jack, since it's regulated) (The supply may have some &quot;protection&quot; to avoid it being on too long).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try another Arduino (unlikely?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try no servo &amp;amp; pir connected. (They may draw too much current, so the Arduino shuts down or create electrical noise.)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-18T09:32:41.980" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24324" PostTypeId="2" ParentId="24322" CreationDate="2016-05-18T11:01:23.717" Score="1" Body="&lt;p&gt;According to the datasheet you have 100mV per ampere, and a zero offset voltage of Vcc × 0.5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So assuming you are correctly converting the ADC reading into a floating point voltage the instantaneous current can be calculated with the formula&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i = (Vadc - 2.5) × 10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or for milliamps,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;i = (Vadc - 2.5) × 10000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are measuring a DC current that is then all well and good.  However, if you are measuring an AC current things get considerably more complex.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work out an AC current you need to have the peak-to-peak voltage, not the instantaneous voltage.  To get that you need to sample the ADC over a number of cycles and find both the maximum and minimum values.  You can then subtract the minimum from the maximum to give you the peak-to-peak voltage.  That can then give you the peak-to-peak current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that you can then calculate the RMS current.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-18T11:01:23.717" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24326" PostTypeId="2" ParentId="24320" CreationDate="2016-05-18T11:09:34.540" Score="1" Body="&lt;p&gt;I assume your charger is connecting to the USB port of the Mega2560. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That USB port has a &lt;em&gt;polyfuse&lt;/em&gt; (actually a special type of positive-coefficient thermistor) which is normally rated at around 500mA (polyfuses are a bit woolly with their ratings since they are heat based).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are drawing near that limit of current the fuse will be gradually heating up. I would think that after 10 hours it may have reached its threshold temperature and thus switches the power off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Disconnecting the power and allowing it to cool down would then make the board work again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can you test it?  Well, next time it switches itself off try bypassing the polyfuse (tweezers would be good to do that with) to see if the power LED turns on again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OfUKZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OfUKZ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-18T11:09:34.540" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24327" PostTypeId="1" CreationDate="2016-05-18T11:49:34.293" Score="0" ViewCount="2962" Body="&lt;p&gt;I have bought an arduino nano clone (called funduino) and upon trying to place it into my breadboard to work with it I realised that the pins do not line up with the holes on the breadboard so I simply can't use the funduino...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9Zm85.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9Zm85.jpg&quot; alt=&quot;Nano Clone&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any recommendations on how I can get around this?&lt;/p&gt;&#xA;" OwnerUserId="21172" LastActivityDate="2016-05-18T13:28:12.473" Title="Arduino Nano clone doesn't fit into breadboard. How can I work around this?" Tags="|arduino-nano|prototype|" AnswerCount="2" CommentCount="5" ClosedDate="2016-06-04T05:54:19.393" ContentLicense="CC BY-SA 3.0" />
  <row Id="24328" PostTypeId="2" ParentId="24327" CreationDate="2016-05-18T12:21:46.170" Score="2" Body="&lt;p&gt;You might be able to use &lt;a href=&quot;https://www.adafruit.com/product/266&quot; rel=&quot;nofollow noreferrer&quot;&gt;these female to female jumper&lt;/a&gt; wires and &lt;a href=&quot;https://www.adafruit.com/products/400&quot; rel=&quot;nofollow noreferrer&quot;&gt;these headers&lt;/a&gt; and hook up the board and breadboard like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5XVIP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5XVIP.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the square female cable ends may not fit closer than 0.1 inches on center.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more compact and (possibly) mechanically difficult solution may be implemented using wire-wrap sockets.  You may be able to leave the sockets intact and deform the pins to match the breadboard.  Or you may need to remove the pins from the plastic in order to accommodate your (different) Nano:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EgfPZ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EgfPZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-18T12:53:07.227" LastActivityDate="2016-05-18T12:53:07.227" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24330" PostTypeId="2" ParentId="24315" CreationDate="2016-05-18T12:55:34.570" Score="1" Body="&lt;p&gt;I might not have understood what you are trying to do, but if it is to use the ESP8266 to allow the Nano to connect to WIFI and act as a web server then I believe you are doing this the hard way.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 is an 80 or 160MHz microprocessor with 64KB Program Ram + 96KB data RAM.  You are using a 16/32MHz microprocessor to generate pages and pass them to it.  I would recommend that you investigate using the Arduino IDE to program the ESP8266 in &quot;Arduino C&quot; it comes with a set of examples that include webservers (which is what I think you are trying to do).  Keep the Nano if the ESP8266s 10 digital and one analogue ports aren't enough to interface to you hardware.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2017-10-06T07:24:48.063" LastActivityDate="2017-10-06T07:24:48.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24331" PostTypeId="2" ParentId="24327" CreationDate="2016-05-18T13:28:12.473" Score="2" Body="&lt;p&gt;Because of the same issue, I use mine with a miniature breadboard:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Enqih.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Enqih.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15863" LastActivityDate="2016-05-18T13:28:12.473" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24336" PostTypeId="1" CreationDate="2016-05-18T15:20:53.747" Score="1" ViewCount="746" Body="&lt;p&gt;I want to upload the real time data of ultrasonic sensor attached to my Arduino  Uno and I have been using esp8266 module for the WiFi connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to upload to &lt;a href=&quot;https://www.pubnub.com/&quot; rel=&quot;nofollow&quot;&gt;PubNub&lt;/a&gt; but I don't know how to start writing the code for PubNub and where do I have to write the code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the code working on my Arduino using the ultrasonic sensor in C++ language, printing the readings on the serial monitor. However, the code will be definitely changed in order to upload the sensor readings to PubNub.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On PubNub the most used SDK is JavaScript and I'm not very familiar to it. For C++ the most used SDK is Posix but it seems way more difficult more than JavaScript. So how I have to translate the code from C++ to JavaScript to get it published on PubNub?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry, I am completely new to this stuff therefore I don't know much about it.&lt;/p&gt;&#xA;" OwnerUserId="21174" LastEditorUserId="19409" LastEditDate="2016-10-15T20:40:33.623" LastActivityDate="2018-12-13T13:17:28.793" Title="upload real time ultrasonic sensor data to pubnub using arduino and esp8266" Tags="|sensors|esp8266|web-service|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24337" PostTypeId="1" AcceptedAnswerId="30289" CreationDate="2016-05-18T15:37:30.183" Score="0" ViewCount="389" Body="&lt;p&gt;I am planning on making a system where multiple arduinos monitor the conditions of certain type of plant. (Each arduino monitors its own plant, but the plants are of the same species). Each plant would have a different placement in the yard(varies the light). The plants are watered as normal, without an exact amount of water. The arduinos would measure light, temperature, and soil water content. Each would send it to the cloud. My question is: Is their a cloud service that can analyze and &quot;find&quot; the best conditions(amount of water,light,temperature,etc) for type a plant, based on how healthy the plants are?(The health of the plants would be entered in manually by the person using the system). (Sorry if my question doesn't make sense, please ask me any questions you have ,Thanks.)&lt;/p&gt;&#xA;" OwnerUserId="14482" LastActivityDate="2016-10-17T12:03:42.590" Title="Are there any online data analysis websites for arduino IoT projects?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24341" PostTypeId="1" CreationDate="2016-05-18T16:24:44.380" Score="1" ViewCount="169" Body="&lt;p&gt;I was wondering if there is a way to pass parameters to an arduino sketch at the upload step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: The reason this would be helpful is because I have a bunch of esp8266 units that need to have details about their specific location but changing variables around per upload feels tedious. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is not possible the other solution that I am probably going to try is to have a sketch to just flash these details to eeprom and then read it from there whenever it is needed. Also storing them in eeprom feels a bit better than as literals in these sketches.&lt;/p&gt;&#xA;" OwnerUserId="21180" LastEditorUserId="19409" LastEditDate="2016-10-17T02:13:12.550" LastActivityDate="2016-10-17T02:13:12.550" Title="Can you pass params to an arduino sketch?" Tags="|sketch|uploading|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24344" PostTypeId="2" ParentId="24341" CreationDate="2016-05-18T18:38:02.320" Score="1" Body="&lt;p&gt;Every ESP8266 has a unique MAC address. You could that information to distinguish between the different units.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like &lt;code&gt;if( mac='00:0a:95:9d:68:16' ){ ... }&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-18T18:38:02.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24345" PostTypeId="2" ParentId="12746" CreationDate="2016-05-18T18:53:54.137" Score="0" Body="&lt;p&gt;you squeezing run time, I wonder, how much time you may save,&#xA;if instead of looping to measure you do 16 times +=&#xA;and &gt;&gt;2 instead /4&#xA;an another optimization to make  an own analog read function, it would be pretty simple based on original, so in additional you save time to call read function 16 times with all CPU overhead for each call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;lastly, in your own read function run the ADC in free run mode and accumulate a significant amount of data samples for oversampling.&lt;/p&gt;&#xA;" OwnerUserId="21184" LastActivityDate="2016-05-18T18:53:54.137" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24347" PostTypeId="2" ParentId="24341" CreationDate="2016-05-18T19:43:26.220" Score="0" Body="&lt;p&gt;Another option, if you can afford the pins, is to install DIP switches or ground-jumpers on a few pins and set / wire a different n-bit code onto each board. Set those pins to INPUT_PULLUP, read them at setup, and wallah! each board is unique. You can put the lookup table (binary number -&gt; parameter string, f/ex) in Flash so it doesn't take up scarce RAM.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-18T19:43:26.220" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24349" PostTypeId="2" ParentId="14487" CreationDate="2016-05-18T20:02:35.837" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am not certain, but I get the same impression as you.&lt;br&gt;&#xA;  It seems that the Expressif SDK only supports master mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Sorry no.&#xA;Espressif SDK supports Slave Mode too.&#xA;official the Master works with 50 kHz (CPU 80MHz), and  100 kHz in technical referenz  and unofficial in my test with !1.2MHz you must switch then to the 160 MHz CPU and you must work for delays with&#xA;asm (&quot;nop&quot;) 12.5 ns at 80MHz and 6.25 ns at 160 MHz&#xA;then you can toggle the pins at 80 MHz with 700 kHz and with 160 MHz with 1400 kHz. because there are instruction to the gpio ( toggle output low, &quot;opendrain&quot; clear output with pullup high ) it will be a netto rate of &#xA;620 kHz, and 1260 kHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NZnJQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NZnJQ.png&quot; alt=&quot;a stable 120 kHz is done&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;best wishes&#xA;rudi ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BoZVs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BoZVs.png&quot; alt=&quot;I2C Slave ESP8266 &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21186" LastActivityDate="2016-05-18T20:02:35.837" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24350" PostTypeId="1" CreationDate="2016-05-18T23:06:10.813" Score="2" ViewCount="2333" Body="&lt;p&gt;This question stems from this article (&lt;a href=&quot;https://www.sistemasorp.es/2014/11/11/programando-un-arduino-remotamente-con-el-modulo-esp8266/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Originally in Spanish&lt;/a&gt;/&lt;a href=&quot;https://translate.google.com/translate?hl=en&amp;amp;sl=es&amp;amp;tl=en&amp;amp;u=http%3A%2F%2Fwww.sistemasorp.es%2F2014%2F11%2F11%2Fprogramando-un-arduino-remotamente-con-el-modulo-esp8266%2F&quot; rel=&quot;nofollow noreferrer&quot;&gt;English&lt;/a&gt;) which &lt;a href=&quot;http://hackaday.com/2014/11/13/programming-an-arduino-over-wifi-with-the-esp8266/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hack a Day&lt;/a&gt; summarizes (Includes link to partial English translation). These articles show that it is possible to update an Arduino Uno via an ESP8266 over WiFi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've modified the code so that when I hit the reset button on the Arduino connects to an &quot;Update&quot; server via the ESP8266, configured in &quot;transparent&quot; mode, to check for an update. If one is present the ESP8266 updates the Arduino which reboots itself. If there isn't an update I reset the ESP8266 and quickly tell it to drop any connection before it can reconnect to the &quot;Update&quot; server thus allowing me to connect to a &quot;Logging&quot; server instead for normal operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a slight difference in how one connects. The &quot;Update&quot; server is connected with the ESP8266 in &quot;transparent&quot; mode. While connecting to the &quot;Logging&quot; server the ESP8266 is in &quot;normal&quot; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At present I have wired an additional connection to the reset pin of the ESP8266. Whenever it doesn't do what I want it to do I drop the power on the reset pin, confuse it and Zap in a command before it's managed to re-establish any &quot;transparent&quot; connection. This works but seems a little like black magic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was curios to know if there is a better way to force the ESP8266 out of &quot;transparent&quot; mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I have not flashed the ESP8266 with NodeMCU/ESPLink or some other firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Aside: There is an ESP8266 Arduino Core library does this also flash the ESP8266 in a manner similar to NodeMCU/ESPLink or does this run on the Arduino and facilitate over the air updates using the native firmware as I am trying to do ? I've only just started reading their documentation. (As this is a first post I've run out of links to share)&lt;/p&gt;&#xA;" OwnerUserId="21191" LastEditorUserId="37523" LastEditDate="2019-06-30T19:01:34.627" LastActivityDate="2019-06-30T19:01:34.627" Title="Programming an Arduino over the air using an ESP8266" Tags="|arduino-uno|esp8266|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24351" PostTypeId="1" AcceptedAnswerId="24358" CreationDate="2016-05-19T00:07:49.223" Score="0" ViewCount="6346" Body="&lt;p&gt;I am new to low level programming.I am trying to send binary data to the http server.At the moment i just fill up the byte array with numbers and send them to the server(eventually i want to send image file). I can see the request in the server log as &lt;code&gt;&#xA;2016-05-18T23:30:26.688040+00:00 heroku[router]: at=info method=POST path=&quot;/api/users&quot; host=myapp.herokuapp.com request_id=ed2b7852-7021-4642-a663-f9709e1aea70 fwd=&quot;99.89.114.63&quot; dyno=web.1 connect=0ms service=2ms status=404 bytes=221&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1.My question is as you can see in the log, what is &lt;code&gt;bytes=221&lt;/code&gt; i thought if i sent byte array of length 32 i should see 32 bytes(or around 40s).And i made the buffer of length 1024 byte array, still in the server log is &lt;code&gt;bytes=221&lt;/code&gt;.Are my bytes are even being sent?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2.How would i handle the bytes received on the server side just to be sure &lt;code&gt;client.write&lt;/code&gt; actually succeeded?(Just in high level...doesn't matter you can guide me in any language,Java,ruby,C,NodeJS)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code.Thank you in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#define SSID &quot;ssid&quot;&#xA;#define PASS_SSID &quot;password&quot;&#xA;#define HOST &quot;myapp.herokuapp.com&quot;&#xA;WiFiClient client;&#xA;&#xA;&#xA;byte buffer[32];&#xA;int bufOffset = 0;&#xA;byte startByte = 0;&#xA;byte nextByte = 0;&#xA;&#xA;void setup() {&#xA;    Serial.begin(115200);&#xA;    checkConnection();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if (client.connect(HOST,80)) {&#xA;           Serial.begin(115200);&#xA;           Serial.println(&quot;conected to the server&quot;);&#xA;           String start_request = &quot;&quot;;&#xA;           String end_request = &quot;&quot;;&#xA;           start_request = start_request  + &quot;--AaB03x&quot; + &quot;\n&quot;&#xA;                                   + &quot;Content-Disposition: form-data; name=\&quot;picture\&quot;; filename=\&quot;cam.jpg\&quot;&quot; + &quot;\n&quot;&#xA;                                   + &quot;Content-Type: image/jpeg&quot; + &quot;\n&quot; + &quot;Content-Transfer-Encoding: binary&quot;;&#xA;          end_request = end_request + &quot;\n&quot; + &quot;--AaB03x--&quot; + &quot;\n&quot;;                       &#xA;          client.println(&quot;POST /api/users HTTP/1.1&quot;);&#xA;          client.println(&quot;Accept: */*&quot;);&#xA;          client.print(&quot;Content-Type: multipart/form-data; boundary=AaB03x&quot;);&#xA;          client.println(start_request);&#xA;&#xA;         //Fill the buffer with values&#xA;            nextByte = startByte++;&#xA;            for(int ii = 0; ii &amp;lt; sizeof(buffer); ii++) {&#xA;            buffer[ii] = nextByte++;&#xA;        }&#xA;&#xA;          //write it to the server&#xA;        int count = client.write(&amp;amp;buffer[bufOffset], sizeof(buffer));&#xA;&#xA;       //end the request&#xA;       client.println(end_request);   &#xA;        client.stop();&#xA;       }&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19181" LastActivityDate="2016-05-19T06:03:37.057" Title="Sending binary data to HTTP server" Tags="|arduino-uno|esp8266|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24356" PostTypeId="1" CreationDate="2016-05-19T05:18:40.630" Score="2" ViewCount="135" Body="&lt;p&gt;I'm using EEPROM to store long term data for use in sketches (thanks to DarthRubik for the guidance).  I store stuff like a location (&quot;Garden&quot;) and a device name (&quot;Greenhouse Monitor 02&quot;) plus whatever else I'd need to store to help filter through data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When this information is stored in the sketch itself it is recalled quickly and accurately, is passed via wifi to my PHP, that then posts the data to the relevant fields in my AWS db.  Piece o' cake!  When I store it in the EEPROM, the extra time required to find it in EEPROM, pull it through the sketch, and then push it through to the db corrupts the data sourced from EEPROM and posts a jumbled mess of characters...if it even makes it to the db at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is actually simple (I think):&lt;br&gt;&#xA;Is it possible to &quot;stage&quot; strings from EEPROM in flash or SRAM vs. pulling cold from EEPROM?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think PROGMEM plays a role here and I'm looking at examples oh how other sketched employ PROGMEM to better understand how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am withholding the code for now because I want to try to implement concepts people may describe before I am just shown the solution...although that would be easier.  If I can't figure it out I'll post the code for more direct answers.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-05-19T11:07:49.583" Title="Inherent delay running EEPROM.read()" Tags="|wifi|eeprom|datalogging|progmem|sram|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24358" PostTypeId="2" ParentId="24351" CreationDate="2016-05-19T06:03:37.057" Score="3" Body="&lt;p&gt;You should forget about MIME, that is only needed if you are sending &lt;em&gt;multiple&lt;/em&gt; files to the server. Your best bet is to just send these headers, then a blank line, then your data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POST /api/users HTTP/1.1&#xA;Accept: */*&#xA;Content-Type: application/octet-stream&#xA;Content-Length: 123&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the other end, you just look at &quot;request.body&quot; and it should have your binary data. (Replace 123 with &lt;code&gt;sizeof(buffer)&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="21198" LastActivityDate="2016-05-19T06:03:37.057" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24359" PostTypeId="2" ParentId="24320" CreationDate="2016-05-19T06:22:31.303" Score="0" Body="&lt;p&gt;I'm just going to hazard a guess: Your 5v line isn't staying at 5v because of the servo. They draw massive amounts of power quickly, and can wreck a lot of havoc. Many times electronics &quot;kinda&quot; work after voltage drops, but will lock up or glitch eventually.  (To get confirmation that this is the problem, monitor your 5v power with an oscilloscope. Set a trigger at 4.5v and try to capture the voltage drops.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that is the problem, you need better isolation on your digital power (running the arduino) and your analog power (running the servo.)  Two ideas to try (you may need both):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)  Get a big cap (say 100 uF or more), then put it across your power to the arduino. If it's big enough, it will prevent your 5v from sagging. It may be expensive to get a big enough cap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Instead of connecting your servo directly to 5v, put a small resistor (say 10 ohm) between them.  Now when he tries to suck all the power, it will get resistance, which will limit the current. The bigger the resistor the better the isolation, but too big will prevent your servo from working. (And may heat up your resistor).&lt;/p&gt;&#xA;" OwnerUserId="21198" LastActivityDate="2016-05-19T06:22:31.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24360" PostTypeId="1" CreationDate="2016-05-19T06:26:32.360" Score="4" ViewCount="88" Body="&lt;p&gt;I want to use the ATmega328 on my Arduino Uno board to clock a &lt;a href=&quot;https://www.ti.com/lit/ds/symlink/tdc1000.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TDC1000&lt;/a&gt; using the clkout bit of the ATmega328, but this requires fuse programming of the low byte. Can anyone tell me how to do this?&lt;/p&gt;&#xA;" OwnerUserId="21200" LastEditorUserId="61722" LastEditDate="2024-02-05T17:13:42.093" LastActivityDate="2024-02-05T17:15:05.933" Title="Low-byte fuse programming of ATmega328 on Arduino Uno" Tags="|arduino-uno|atmega328|oscillator-clock|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24363" PostTypeId="1" AcceptedAnswerId="32936" CreationDate="2016-05-19T07:54:02.277" Score="1" ViewCount="5037" Body="&lt;p&gt;I just purchased a RedBoard, knowing that it would work on Linux, and knowing that it could allow me to easily interface with some electronics project. I am aware of the &lt;code&gt;ino&lt;/code&gt; command line tool but I wanted to try interfacing with my board using the Arduino IDE because the latter seems to be somewhat standard. However, when I open the IDE I see a blinking cursor and for whatever reason I can't deal with this. How do I turn off the blinking cursor in the IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've managed to fix the blinking cursor problem in Firefox, GNOME, KDE, and my terminal... just not sure what to do with Java applications like Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="21201" LastActivityDate="2021-10-20T05:00:30.333" Title="How do I turn off the blinking cursor/caret in the Arduino IDE?" Tags="|arduino-ide|linux|java|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24364" PostTypeId="2" ParentId="24356" CreationDate="2016-05-19T11:07:49.583" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;When I store it in the EEPROM, the extra time required to find it in EEPROM, pull it through the sketch, and then push it through to the db corrupts the data sourced from EEPROM and posts a jumbled mess of characters...if it even makes it to the db at all.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Are you certain of that? It is incredibly unlikely that mere time will corrupt characters and data as they are read and sent - especially the minuscule amounts of time we are talking here.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to &quot;stage&quot; strings from EEPROM in flash or SRAM vs. pulling cold from EEPROM?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, and you are already doing so, since you can't send direct from EEPROM to WiFi - you have to go via SRAM. You read from EEPROM into SRAM then send from SRAM through WiFi. You just won't be doing it an entire string at once.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I think PROGMEM plays a role here and I'm looking at examples oh how other sketched employ PROGMEM to better understand how to use it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it doesn't. PROGMEM is for storing strings and other data within your sketch. It has nothing at all to do with EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I am withholding the code for now because I want to try to implement concepts people may describe before I am just shown the solution...although that would be easier. If I can't figure it out I'll post the code for more direct answers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Without seeing your code no one is really going to be able to help you. I suspect (although I am stabbing wildly in the dark) that your EEPROM reading/writing code is completely wrong and you aren't actually storing the data you expect in the EEPROM, nor reading it back properly. Unless we see your code we can't know what is going on, and so we don't have a cat's hope in hell of diagnosing your problem.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-19T11:07:49.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24367" PostTypeId="1" AcceptedAnswerId="24371" CreationDate="2016-05-19T11:54:07.923" Score="0" ViewCount="170" Body="&lt;p&gt;I am making a clock on my Arduino Uno using the time library &lt;a href=&quot;http://playground.arduino.cc/Code/Time&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/Time&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I let the user set a time. Which is then converted to seconds and used in the&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;setTime(s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;function.&#xA;When the value is over 9:10h, the seconds evaluate to 4 294 941 360 seconds (=&#xA;1 193 039.27 hours)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A code snippet:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void timeChange() {&#xA;  lcd.clear();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;Change time&quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;00:00&quot;);&#xA;  int hoursSet    = 0; //Stores the hours added.&#xA;  int minutesSet  = 0; //Stores the minutes added.&#xA;  String printTime;&#xA;  bool timeComplete = false;&#xA;  while (!timeComplete) {&#xA;    int buttonVal = analogRead(A0);&#xA;    if (buttonVal &amp;gt;= 490 &amp;amp;&amp;amp; buttonVal &amp;lt;= 520) { //Indicates button 3 is pressed. It's function is to add one hour to the time.&#xA;      hoursSet = (hoursSet + 1) % 24; //Adds one hour to the hours.&#xA;      delay(100);&#xA;    } else if (buttonVal &amp;gt;= 5 &amp;amp;&amp;amp; buttonVal &amp;lt;= 10) { //Indicates button 4 is pressed. It's function si to add 5 minutes to the time.&#xA;      minutesSet = (minutesSet + 5) % 60; //Adds minutes to the minutes.&#xA;      delay(100);&#xA;    }&#xA;&#xA;    lcd.setCursor(0,1);&#xA;    String strHr = String(hoursSet);&#xA;    String strMn = String(minutesSet);&#xA;    if(strHr.length() == 2){&#xA;      lcd.print(hoursSet);&#xA;    } else if(strHr.length() == 1) {&#xA;      lcd.print(&quot;0&quot;);&#xA;      lcd.setCursor(1, 1);&#xA;      lcd.print(hoursSet);&#xA;    }&#xA;&#xA;    lcd.setCursor(2,1);&#xA;    lcd.print(&quot;:&quot;);&#xA;    lcd.setCursor(3,1);&#xA;    if(strMn.length() == 2){&#xA;      lcd.print(minutesSet);&#xA;    } else if(strMn.length() == 1) {&#xA;      lcd.print(&quot;0&quot;);&#xA;      lcd.setCursor(4, 1);&#xA;      lcd.print(minutesSet);&#xA;    }&#xA;    delay(100);&#xA;&#xA;    if (buttonVal &amp;gt;= 990 &amp;amp;&amp;amp; buttonVal &amp;lt;= 1010) { //if button 2 is pressed again, the timecomeplete is set to true, and the script continues.&#xA;      timeIsSet = true;&#xA;      timeComplete = true;&#xA;    }&#xA;  }&#xA;  lcd.clear(); //Clear the screen&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;The time&quot;); //Print text, move cursor and print the time&#xA;  lcd.setCursor(0, 1);&#xA;  String strHr = String(hoursSet);&#xA;  String strMn = String(minutesSet);&#xA;  if(strHr.length() == 2){&#xA;    lcd.print(hoursSet);&#xA;  } else if(strHr.length() == 1) {&#xA;    lcd.print(&quot;0&quot;);&#xA;    lcd.setCursor(1, 1);&#xA;    lcd.print(hoursSet);&#xA;  }&#xA;  lcd.setCursor(2,1);&#xA;  lcd.print(&quot;:&quot;);&#xA;  lcd.setCursor(3,1);&#xA;  if(strMn.length() == 2){&#xA;    lcd.print(minutesSet);&#xA;  } else if(strMn.length() == 1) {&#xA;    lcd.print(&quot;0&quot;);&#xA;    lcd.setCursor(4, 1);&#xA;    lcd.print(minutesSet);&#xA;  }&#xA;  lcd.print(&quot; is saved!&quot;);&#xA;  setTime((hoursSet * 3600) + (minutesSet * 60));&#xA;  timeIsSet = true;&#xA;  delay(5000); //Wait five, seconds then proceed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added this to the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      Serial.print(&quot;hours &quot;);&#xA;  Serial.println(hoursSet);&#xA;  Serial.print(&quot;hours in s &quot;);&#xA;  Serial.println(hoursSet * 3600);&#xA;  Serial.print(&quot;minutes &quot;);&#xA;  Serial.println(minutesSet);&#xA;  Serial.print(&quot;minutes in s &quot;);&#xA;  Serial.println(minutesSet * 60);&#xA;  Serial.print(&quot;Combined:  &quot;);&#xA;  Serial.println( (hoursSet * 3600) + (minutesSet * 60) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I input 5:15 it results in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;hours 5&#xA;  hours in s 18000&#xA;  minutes 15&#xA;  minutes in s 900&#xA;  Combined:  18900&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I input 9:15 it results in:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;hours 9&#xA;  hours in s 32400&#xA;  minutes 15&#xA;  minutes in s 900&#xA;  Combined:  -32236&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, it looks like the library only holds an Int. But that seems odd, as the function expects seconds.&lt;/p&gt;&#xA;" OwnerUserId="21212" LastEditorUserId="21212" LastEditDate="2016-05-19T12:06:30.167" LastActivityDate="2016-05-19T12:32:10.860" Title="Can't store time over 9 hours and 10 minutes" Tags="|time|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24368" PostTypeId="1" CreationDate="2016-05-19T04:12:58.873" Score="0" ViewCount="966" Body="&lt;p&gt;I'm trying to simply program an Arduino trinket to display some text on an LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm basically trying to follow &lt;a href=&quot;https://learn.adafruit.com/usb-plus-serial-backpack/testing-with-ttl-serial&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt;, except connect it to a Trinket rather than an Arduino Uno. The background color of the LCD display is changing as expected from the &lt;code&gt;loop&lt;/code&gt; function in my Arduino code, but it's just displaying some o's and arrow's for text on the LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm new to Arduino's (and EE in general), but am a computer programmer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong that the sample code in the above link doesn't print text on my LCD display?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sSr1t.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sSr1t.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7Wc9S.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Wc9S.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TE3Hg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TE3Hg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21224" OwnerDisplayName="Catfish" LastActivityDate="2021-12-04T08:08:10.803" Title="Trying to print text on LCD display from Arduino trinket" Tags="|lcd|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24370" PostTypeId="2" ParentId="24292" CreationDate="2016-05-19T11:55:56.790" Score="0" Body="&lt;p&gt;I ran into a similar problem years ago on an ATMega128 (before Arduino) and you just have to be aware of alternative functions for the port. In this case &lt;code&gt;PD0&lt;/code&gt; is Hardware Serial &lt;code&gt;RX&lt;/code&gt; which is a receive pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some relatively older code based around the same idea:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Yes, you can use the RX/TX pins as regular IO. Just don't call the Serial.begin() in your code, and make sure you call a pinMode() for them. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;from: &lt;a href=&quot;http://www.societyofrobots.com/robotforum/index.php?PHPSESSID=b928292f91c78b57b5683484af0f635e&amp;amp;topic=12396.msg93239#msg93239&quot; rel=&quot;nofollow&quot;&gt;http://www.societyofrobots.com/robotforum/index.php?PHPSESSID=b928292f91c78b57b5683484af0f635e&amp;amp;topic=12396.msg93239#msg93239&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another interesting post, fourth post: &lt;a href=&quot;http://www.nerdkits.com/forum/thread/536/&quot; rel=&quot;nofollow&quot;&gt;http://www.nerdkits.com/forum/thread/536/&lt;/a&gt; &#xA;where they disable the serial functionality once the code begins, downside (a above) you will lose serial comms, so it depends on how much you need them. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UCSR0B = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure how successful that would be in today's arduino, I know a lot (if not all) of the prior functionality is maintained, but I haven't used them in a long while. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pin should become active again as the bootloader will automatically reenable it upon reset (although I haven't personally tested it). It will just make debugging that little bit harder if you need to. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I mentioned in my comment, if you have another pin available to you, use that instead. &lt;/p&gt;&#xA;" OwnerUserId="304" LastActivityDate="2016-05-19T11:55:56.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24371" PostTypeId="2" ParentId="24367" CreationDate="2016-05-19T12:04:25.243" Score="4" Body="&lt;p&gt;Here's a hint: 32767 seconds is 9 hours, 6 minutes and 7 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the largest value that an &lt;code&gt;int&lt;/code&gt; can hold?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;EDIT: I can't add comments on this computer (old browser), so I have to respond to your question here.&#xA;&lt;code&gt;time_t&lt;/code&gt; is an unsigned 32-bit value, but all of your input values are signed 16-bit values. When you take a product like 3600*10, you get a bit pattern of &lt;code&gt;1000110010100000&lt;/code&gt;, which is 36000 when interpreted as an unsigned value, but is -29536 when interpreted as a signed value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When assigned to a &lt;code&gt;time_t&lt;/code&gt;, the value is sign-extended to 32 bits, which makes it &lt;code&gt;11111111111111111000110010100000&lt;/code&gt;, which is 4294937760 when interpreted as an unsigned value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to write a statement like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time_t x = (hoursSet * 3600) + (minutesSet * 60);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you need to type-cast your input arguments to the correct type first:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;time_t x = ((time_t)hoursSet * 3600) + ((time_t)minutesSet * 60);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="614" LastEditorUserId="614" LastEditDate="2016-05-19T12:32:10.860" LastActivityDate="2016-05-19T12:32:10.860" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24372" PostTypeId="1" CreationDate="2016-05-19T12:07:11.700" Score="0" ViewCount="683" Body="&lt;p&gt;In finding the pH value of a liquid/Soil, what is the range of Offset voltage value that I can use in my code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/17436/using-calibrating-ph-sensor-module/24362?noredirect=1#comment46498_24362&quot;&gt;Using / calibrating pH sensor module&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I considered the above link as a reference. But I didn't come to know the range of Offset Value...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the logic below to find the value of pH right...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avgValue = 0;&#xA;for (int i=2;i&amp;lt;8;i++)       // take the average value of 6 center sample&#xA;avgValue+=buf[i]; &#xA;&#xA;float phValue = (float)avgValue*5.0/1024/6; // convert the analog into millivolt&#xA;phValue=3.5*phValue+Offset;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is the range of Offset value can I use in the above/my code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advance&lt;/p&gt;&#xA;" OwnerUserId="19311" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-05-19T13:58:41.877" Title="Range of Offset Value in pH sensor module?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24373" PostTypeId="2" ParentId="24367" CreationDate="2016-05-19T12:23:08.027" Score="0" Body="&lt;p&gt;Changing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  time_t x = (hoursSet * 3600) + (minutesSet * 60);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  time_t x = ((unsigned long)hoursSet * 3600) + (minutesSet * 60);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Has solved the problem&lt;/p&gt;&#xA;" OwnerUserId="21212" LastActivityDate="2016-05-19T12:23:08.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24375" PostTypeId="2" ParentId="24372" CreationDate="2016-05-19T13:58:41.877" Score="1" Body="&lt;p&gt;When converting real world sensor measurements into usable data there are several issues to consider:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Noise from any number of sources such as (unavoidable?) long cables and power supplies to name two.  Consider using exponential averaging to minimize the effects of noise.  If the noise if predictable consider sampling only when the noise is absent.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Slope of the data is important when converting to known scales.  For example the slop of the resistance of a thermistor verses heat may not have the same slope as the temperature in Celsius verses heat.  Simply multiply by the appropriate constant to correct for slope error.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;After you correct for slope the values may still not be correct.  When all values are equally less or more then the expected values an offset is required.  Simply add or subtract the appropriate constant to correct for offset error.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Linearity is often corrected using lookup tables.  Linearity is a measure of how closely the sensor tracks the physical value being measured.  For example, after slope and offset corrections, a thermistor measurement may appeared curved when compared to the actual temperature in Celsius.  For this final correction the sensor measured value is used to index into a lookup table which returns a correction value.  Interpolation is used to control the size of the lookup table when space is a consideration.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-19T13:58:41.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24379" PostTypeId="1" AcceptedAnswerId="24383" CreationDate="2016-05-19T18:49:56.677" Score="0" ViewCount="63" Body="&lt;p&gt;I am using Eclipse to program a ATMega2560 and would like to stay away from the Arduino library, While looking through AVR Examples I have seen the syntax &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;&#xA;PORTD.0 = 1&#xA;&#xA;or &#xA;&#xA;PORTD.DIR = 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PORTD = 0b11111111;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To define and control the Inputs/Outputs when I try to use this syntax I get compiler errors: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: request for member 'DIR' in '*34u', which is of non-class type 'volatile uint8_t {aka volatile unsigned char}'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am sure that I am simply missing a include file or something but I can't figure out what I am doing wrong.&lt;/p&gt;&#xA;" OwnerUserId="14761" LastActivityDate="2016-05-19T20:32:35.093" Title="IO Control and Configuration" Tags="|arduino-mega|avr|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24381" PostTypeId="1" AcceptedAnswerId="24407" CreationDate="2016-05-19T20:20:12.197" Score="1" ViewCount="1227" Body="&lt;p&gt;I am trying to control a strip of WS2801 LEDs through an arduino uno running firmata from Python on my laptop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written some basic code based on adafruit's library &lt;a href=&quot;https://github.com/adafruit/Adafruit-WS2801-Library/blob/master/Adafruit_WS2801.cpp&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (from line 187): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;from pymata_aio.pymata3 import PyMata3&#xA;from pymata_aio.constants import Constants&#xA;import time&#xA;&#xA;leds = [(255, 255, 0), (255, 255, 0), (0, 255, 255)]&#xA;&#xA;uno = PyMata3()&#xA;&#xA;uno.set_pin_mode(2, Constants.OUTPUT)  # signal&#xA;uno.set_pin_mode(3, Constants.OUTPUT)  # clock&#xA;&#xA;&#xA;def show(leds):&#xA;    for pixel in leds:&#xA;        for channel in pixel:&#xA;            i = 0b1&#xA;            for x in range(0,8):&#xA;                if i &amp;amp; channel:&#xA;                    uno.digital_write(2, 1)&#xA;                else:&#xA;                    uno.digital_write(2, 0)&#xA;                uno.digital_write(3, 1)&#xA;                uno.digital_write(3, 0)&#xA;&#xA;                i = i &amp;lt;&amp;lt; 1&#xA;&#xA;    uno.digital_write(3, 0)&#xA;    time.sleep(0.001)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run the code it seems to run ok, but only the first LED will light up. I think (too quick to be certain) that it flashes through all the colours - ie displaying each colour rather than passing them through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there is something wrong with the timing for the clock pin making it latch, but I'm grasping here.&lt;/p&gt;&#xA;" OwnerUserId="21230" LastActivityDate="2016-05-20T16:22:33.723" Title="Getting Firmata to control WS2801 LEDs" Tags="|led|adafruit|python|rgb-led|firmata|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24382" PostTypeId="1" CreationDate="2016-05-19T20:25:03.303" Score="0" ViewCount="8160" Body="&lt;p&gt;basically I am trying to write an IF/ELSE statement that triggers a light when a pressure sensor is between two values. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, I want the light to respond ONLY if the analog read is between 400 and 600, as opposed to, say, only being above 400.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code, any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensor=0;&#xA;int threshold=200;&#xA;&#xA;void setup (){&#xA;  pinMode(2, OUTPUT);  &#xA;  digitalWrite(2, LOW);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  sensor=analogRead(0);&#xA;  Serial.println(sensor);&#xA;  if (sensor &amp;gt; threshold) {&#xA;    digitalWrite(2, HIGH);&#xA;  }&#xA;  else {&#xA;    digitalWrite(2, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21231" LastEditorUserId="10794" LastEditDate="2016-05-19T21:41:10.850" LastActivityDate="2016-05-20T20:28:07.543" Title="How to write IF/Else using a threshold range of values" Tags="|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24383" PostTypeId="2" ParentId="24379" CreationDate="2016-05-19T20:32:35.093" Score="0" Body="&lt;p&gt;What you're doing wrong is that you're using the wrong compiler. That syntax is for CodeVision or mikroC, but the Arduino IDE uses GCC. Which follows global standards rather than making syntax up.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-19T20:32:35.093" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24384" PostTypeId="2" ParentId="24382" CreationDate="2016-05-19T20:52:50.480" Score="1" Body="&lt;p&gt;To get the light to turn on only when the sensor reading is between two numbers, you should test if the reading is between the two numbers, and if it is, turn on the light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To test if a value is between two numbers, you could use the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; AND operator to see if both conditions are met.  For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (sensor &amp;gt; loLimit &amp;amp;&amp;amp; sensor &amp;lt; hiLimit) {&#xA;    digitalWrite(2, HIGH);&#xA;} else {&#xA;    digitalWrite(2, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a shorter way to write that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(2, (sensor &amp;gt; loLimit &amp;amp;&amp;amp; sensor &amp;lt; hiLimit));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this form, the expression evaluates to 1, or HIGH, if it is true, and to 0, or LOW, if it is false.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to test if &lt;code&gt;abs(sensor-midLimit) &amp;lt; halfGap&lt;/code&gt;, where &lt;code&gt;midLimit&lt;/code&gt; is &lt;code&gt;(loLimit+hiLimit)/2&lt;/code&gt; and &lt;code&gt;halfGap&lt;/code&gt; is &lt;code&gt;(hiLimit-loLimit)/2&lt;/code&gt;.  Turn on the light if &lt;code&gt;abs(sensor-midLimit) &amp;lt; halfGap&lt;/code&gt;, else turn it off.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-20T20:28:07.543" LastActivityDate="2016-05-20T20:28:07.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24386" PostTypeId="1" AcceptedAnswerId="24387" CreationDate="2016-05-19T22:09:00.020" Score="0" ViewCount="95" Body="&lt;p&gt;What is a good max number of sensors for an Arduino Mega? Since it has like -- 2? -- ground connections, is it better to keep the number of sensors to a minimum amount?&lt;/p&gt;&#xA;" OwnerUserId="21236" LastActivityDate="2016-05-19T22:20:39.583" Title="Question about number of sensors for Arduino Mega" Tags="|arduino-mega|sensors|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24387" PostTypeId="2" ParentId="24386" CreationDate="2016-05-19T22:20:39.583" Score="0" Body="&lt;p&gt;It depends on what you want the Arduino to do with them. There is no (not much) penalty for having many sensors connected. Where it begins to matter is when you need to read at rates which, collectively, tax the speed of the processor to meet the total demand. Your project specs will really determine how many sensors make sense. The other place that sensor count might matter is if your project is to be battery powered, and the sensors draw some amount of current even when they're not being used. In a battery powered project, you'll want to be able to power-down everything that isn't being used at a given time, to maximize the system's overall run-time on battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Mega, and I'm assuming you mean Mega 2560, has 50-some odd I/O pins available, so you have a lot of potential connectivity, and I think it's safe to say, the designers intended for them to be used.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-19T22:20:39.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24389" PostTypeId="1" CreationDate="2016-05-20T05:02:53.913" Score="2" ViewCount="1455" Body="&lt;p&gt;I'm attempting to make a simple get request to my website from my arduino, but I'm unable to do so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I keep getting the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&#xA;  &amp;lt;head&amp;gt;&#xA;    &amp;lt;meta http-equiv=&quot;refresh&quot; content=&quot;0;url=http://dnserrorassist.att.net/search/?q=http://www.example.com/&amp;amp;t=0&quot;/&amp;gt;&#xA;  &amp;lt;/head&amp;gt;&#xA;  &amp;lt;body&amp;gt;&#xA;    &amp;lt;script&amp;gt;&#xA;      window.location=&quot;http://dnserrorassist.att.net/search/?q=&quot;+escape(window.location)+&quot;&amp;amp;r=&quot;+escape(document.referrer)+&quot;&amp;amp;t=0&quot;;&#xA;    &amp;lt;/script&amp;gt;&#xA;  &amp;lt;/body&amp;gt;&#xA;&amp;lt;/html&amp;gt;`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit: Here's the important code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char http_site[] = &quot;www.example.com&quot;;&#xA;const int http_port = 80;&#xA;&#xA;// Perform an HTTP GET request to a remote page&#xA;bool getPage() {&#xA;&#xA;  // Attempt to make a connection to the remote server&#xA;  if ( !client.connect('http://' + http_site, http_port) ) {&#xA;    return false;&#xA;  } else &#xA;  {&#xA;    Serial.println(&quot;Connected!&quot;);&#xA;  }&#xA;&#xA;  // Make an HTTP GET request&#xA;  client.print(&quot;GET /&quot;);&#xA;  Serial.print(&quot;GET /&quot;);&#xA;&#xA;  client.println(&quot; HTTP/1.1&quot;);&#xA;  Serial.println(&quot; HTTP/1.1&quot;);&#xA;&#xA;  client.println(&quot;Host: xxx.xxx.xxx.xxx:1995&quot;);&#xA;  Serial.println(&quot;Host: xxx.xxx.xxx.xxx:1995&quot;);&#xA;&#xA;  client.println(&quot;Connection: close\r\n&quot;);&#xA;  Serial.println(&quot;Connection: close\r\n&quot;);&#xA;&#xA;  return true;&#xA;}&#xA;&#xA;void loop(void){&#xA;&#xA;  if ( client.available() ) {&#xA;    char c = client.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21242" LastEditorUserId="21242" LastEditDate="2016-05-20T05:17:22.017" LastActivityDate="2016-08-30T11:06:33.780" Title="Arduino Wifi/Wemos Wifi D1 adding &amp;t=0 to simple GET request" Tags="|wifi|esp8266|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24390" PostTypeId="2" ParentId="24199" CreationDate="2016-05-20T05:56:43.400" Score="0" Body="&lt;p&gt;When you upload your sketch using the IDE, it has been converted from C++ into &quot;binary&quot;. So yes, it is possible. In fact that is the only way it is done.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't want to send Arduino code or C code just binary. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The job of the compiler is to convert your C code into binary, and that happens automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You an also use &lt;code&gt;avrdude&lt;/code&gt; to upload a xxx.hex file (a file containing pure machine code).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-20T05:56:43.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24391" PostTypeId="1" CreationDate="2016-05-20T07:24:48.463" Score="-1" ViewCount="3217" Body="&lt;p&gt;I'm unable to communicate with my nodemcu ESP8266 module using the AT commands. The module does not return 'ready'  on the serial monitor and entering AT commands has no effect at all. I am able to upload programs onto the module and even receive messages onto the serial monitor. But not for the AT commands.  Please help.... &lt;/p&gt;&#xA;" OwnerUserId="21244" LastActivityDate="2017-06-18T05:23:06.090" Title="No Response to AT commands" Tags="|arduino-ide|esp8266|nodemcu|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24397" PostTypeId="2" ParentId="24391" CreationDate="2016-05-20T08:42:32.993" Score="1" Body="&lt;p&gt;AT commands require the installation of firmware that responds to AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A plain ESP module normally comes with that firmware installed. A nodemcu doesn't. A nodemcu comes with Lua installed instead.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-20T08:42:32.993" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24399" PostTypeId="1" CreationDate="2016-05-20T09:29:22.993" Score="0" ViewCount="239" Body="&lt;p&gt;I wonder if anyone has written a code for GPS time stamping of voltages from seismic geophone (or any other sensors) digitized by internal or better external ADC connected to Arduino? Since the accuracy of at least 1 millisecond is required I believe using 1 PPS signal of the GPS is the only solution.&lt;/p&gt;&#xA;" OwnerUserId="21248" LastActivityDate="2017-08-15T09:50:12.657" Title="GPS timestamping of digitized voltages from geophones" Tags="|gps|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24401" PostTypeId="2" ParentId="24391" CreationDate="2016-05-20T11:47:36.913" Score="1" Body="&lt;p&gt;The bare chip knows nothing, just as an Arduino would. The AT+ command set is provided by an interpreter running on the 8266 processor. The AI Thinker modules and others, come with that interpreter already loaded. Your module does not have it installed. And any time you load a program into it, the previous one is over-written. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the AT+ interpreter available for download and upload it to the module, after which it will be able to execute AT+... commands.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-20T11:47:36.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24402" PostTypeId="2" ParentId="24399" CreationDate="2016-05-20T12:30:20.080" Score="0" Body="&lt;p&gt;I doubt anyone has written software for your exact situation but you should be able to cobble something together if we break down the problem.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You want to read a value from an Analog port (or external ADC)&lt;/li&gt;&#xA;&lt;li&gt;You want to read the time from a GPS.&lt;/li&gt;&#xA;&lt;li&gt;You want to write these two readings to 'somewhere'.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Looking at the Arduino IDE tutorials there are some Analog ones that would be relevant.  But the only line you need is &lt;code&gt;int sensorValue = analogRead(analogInPin);&lt;/code&gt; which reads a value between 0 and 1024 which relates to the output range of your sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you want to read from a GPS, looking at the Software Serial Library Examples there is an example of how to setup a second serial port to read the GPS data. The GPS data will arrive once every 2 seconds.  The PPS signal will arrive once every 1 second.  So I'm not sure how you are going to use this to get millisecond accuracy.  To get millisecond accuracy I would use the GPS data to correct a Real Time Clock connected over either the I2C or SPI bus.  There are lots of example programs on reading from an RTC over these busses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write them to somewhere, well initially I would write them to the hardware serial port, back to you PC via USB, but then you might want to start looking at writing them to a SD card or via WIFI or GSM to a cloud storage solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are a list of the examples I looked at:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/AnalogInOutSerial#&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/AnalogInOutSerial#&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample#&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample#&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Datalogger&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Datalogger&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-20T12:30:20.080" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24404" PostTypeId="2" ParentId="24399" CreationDate="2016-05-20T13:04:40.277" Score="1" Body="&lt;p&gt;To tackle the time resolution and accuracy issue you could:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Attach the 1PPS signal to an interrupt pin&lt;/li&gt;&#xA;&lt;li&gt;In the interrupt routine record the &lt;code&gt;millis()&lt;/code&gt; value at the time the 1PPS signal is activated&lt;/li&gt;&#xA;&lt;li&gt;In the main loop do a non-blocking read of the GPS data to find and build up the time string as it is sent from the GPS (shortly after the 1PPS is triggered).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You now know what the &lt;code&gt;millis()&lt;/code&gt; count was the last time a 1PPS pulse arrived, and you know the current time to within a second. The 1PPS pulse will be at &lt;code&gt;HH:MM:SS.000&lt;/code&gt; (or as near as damnit) so if you subtract the current &lt;code&gt;millis()&lt;/code&gt; from your recorded 1PPS &lt;code&gt;millis()&lt;/code&gt; value it gives you the number of milliseconds since the 1PPS pulse. Add that to the current time, and you have 1ms accuracy in the time: &lt;code&gt;HH:MM:SS.iii&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-20T13:04:40.277" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24405" PostTypeId="2" ParentId="23351" CreationDate="2016-05-20T13:56:56.457" Score="3" Body="&lt;p&gt;Yes, the Nano supports SPI when used with a modern Arduino version, and no, you do not have to do anything special to utilize it on this board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The information you found that seems to suggest something to the contrary is simply a result of the fact that that the web page for the Nano is sadly out of date date and does not reflect the current state of the Arduino libraries which support SPI on this processor and hence board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of components, the Nano it is very nearly just a form-factor shrink of the discontinued Duemilanove, and in the current version updated to an an ATmega328p it has capabilities essentially comparable to an Uno, differing primarily the in the USB interface which has nothing to do with SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of what is wrong with the web page, if we examine &lt;a href=&quot;http://archive.org/web/&quot; rel=&quot;nofollow&quot;&gt;archive.org&lt;/a&gt;'s records for the page of the comparable Duemilanvoe, on &lt;a href=&quot;http://web.archive.org/web/20100915105411/http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove&quot; rel=&quot;nofollow&quot;&gt;September 15th, 2010&lt;/a&gt; it said:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But a few days later on &lt;a href=&quot;http://web.archive.org/web/20100926114439/http://arduino.cc/en/Main/ArduinoBoardDuemilanove&quot; rel=&quot;nofollow&quot;&gt;September 26th, 2010&lt;/a&gt; it had been changed to say:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Although the page for that once-flagship product was updated to reflect SPI support nearly six years ago, they've not yet made a corresponding correction to the Nano page.  But as the difference is in the software and the same software is used in either case, the addition of SPI support to the Duemilanove was also automatically an addition of that support to the Nano.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-06-19T18:39:36.887" LastActivityDate="2016-06-19T18:39:36.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24406" PostTypeId="2" ParentId="24381" CreationDate="2016-05-20T15:20:42.173" Score="1" Body="&lt;p&gt;It's possible that time.sleep is causing a latching issue. You should instead use pymata-aio's sleep function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.sleep(0.001)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The documentation for it can be found here: &lt;a href=&quot;http://htmlpreview.github.io/?https://github.com/MrYsLab/pymata-aio/blob/master/documentation/html/pymata_aio.html#module-pymata_aio.pymata3&quot; rel=&quot;nofollow&quot;&gt;http://htmlpreview.github.io/?https://github.com/MrYsLab/pymata-aio/blob/master/documentation/html/pymata_aio.html#module-pymata_aio.pymata3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also try a different pin and see if you still have the issue?&lt;/p&gt;&#xA;" OwnerUserId="21258" LastActivityDate="2016-05-20T15:20:42.173" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24407" PostTypeId="2" ParentId="24381" CreationDate="2016-05-20T15:46:28.720" Score="0" Body="&lt;p&gt;You cannot do precise timing of I/O mediated by USB like that. Regardless of the serial baud rate in use, the USB mode utilized basically puts a 1ms minimum interval between any two distinct &lt;em&gt;communication&lt;/em&gt; operations. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Providing there are no intervening reads, if firmata is coded to deliver its data to the host's serial API in buffers matching or exceeding the USB packet size rather than individual writes for each command, it is possible that &quot;keeping the pipe full&quot; may mean that commands are able to be executed without such gaps, but any little interruption could introduce a problematic delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key problem with delay is this part of the data sheet:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CLK pin keeps low more than 500uS will make the WS2801 internal status register reset, and at this moment, the gray scale data&#xA;  in the data shift registers will be latched.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Basically, that says that you need a clock low pulse of more than a half millisecond to start the process, but by extension it also means that all of the subsequent clock pulses have to be shorter than that or you will inadvertently reset the process, and this is not something you can easily achieve reliability of with a USB bus of the type utilized here mediating your software manipulation of the clock line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Essentially, don't try to bit-bang things with Firmata.&lt;/strong&gt;  You should send the desired intensity values across the USB as byte data, and then have software running on the Uno clock this data out in accordance with the WS2801 timing requirements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I'd just write that as an ordinary sketch reading the Serial input - no need for firmata.  You can still feed the data from python on the host if you like, or anything else that can push data over a serial port.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-20T16:22:33.723" LastActivityDate="2016-05-20T16:22:33.723" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24410" PostTypeId="1" CreationDate="2016-05-20T16:53:28.280" Score="3" ViewCount="1672" Body="&lt;p&gt;Not sure if this is possible, but could I use my existing doorbell setup to power an Arduino? I'd also like to preserve the existing chime's functionality either through the existing button or triggering it through the arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My doorbell chime is made by Nicor and its input is 120VAC, but outputs 12VDC. This seems to be a very unconventional setup, but I've confirmed its output with a multimeter (it's also printed on the chime itself). The chime is very similar to this: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B006T38PTU&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.amazon.com/Nicor-18888-Door-Chimes/dp/B006T38PTU&lt;/a&gt; (only difference I can see is the output). The 12V line runs to my front door where it's connected to a light up button. Here is a picture of the button's circuitry: &lt;a href=&quot;https://i.stack.imgur.com/YsSu0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/YsSu0.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to do is use the chime's 12VDC output to power the arduino so I don't have to rely on another power source or batteries. I will be adding smart features to the doorbell via the arduino, but my main hangup is getting power to the arduino. I've tried connecting the doorbell wires to VIN and ground, which successfully powers on the Arduino, but it also triggers the chime. It appears closing the circuit triggers the chime to play. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do?&lt;/p&gt;&#xA;" OwnerUserId="21263" LastEditorUserId="21263" LastEditDate="2016-05-20T17:39:43.553" LastActivityDate="2017-09-08T23:17:19.160" Title="Use doorbell output (12VDC) to power arduino?" Tags="|arduino-uno|power|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24411" PostTypeId="1" AcceptedAnswerId="24413" CreationDate="2016-05-20T17:12:38.250" Score="2" ViewCount="1713" Body="&lt;p&gt;I'm trying to make a voltage/temp logger that will post to SQL. I'm using a WPF to make kind of a UI for people to measure the voltage of a cell, and take the temp of the battery acid in the battery. My end goal is to have the Arduino Bluetooth to a computer. the computer will handle all the SQL. The Arduino will have a physical button to post or save the data to my SQL server. Also the Arduino will have a little display to display the battery S/N, Voltage, Temp. (Side Question: Am I going to be able to do the screen and access the serial, with also sending the serial data over Bluetooth?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that when I call my function to get that data sometimes it comes out messed up. Sometimes I get, for example: &quot;3.1234 V=&quot; Or &quot;V= 3.123V=&quot; It also happens with the temperature, sometimes I get the voltage in the temp box and vice versa. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More times than not I get a bad result. When I run it in the Serial Monitor with the Arduino IDE It looks fine. Does anyone have any advice how I can clean up the communication and get more reliable results?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using to place the serial port string into a textbox. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;txt_Volt.Text = sp.ReadExisting(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tried using the &lt;code&gt;Serial.flush();&lt;/code&gt; to clear out any old stuff to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;else if (c == '3')&#xA; {&#xA;   int analog_value = analogRead(A0);&#xA;   volt = (analog_value * 5.0) / 1024.0;&#xA;   Serial.print(&quot;v= &quot;);&#xA;   Serial.print(volt, 5);&#xA;   Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Arduino &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;  if (Serial.available() &amp;gt; 0)&#xA;  { Serial.flush();&#xA;    char c = Serial.read();&#xA;    if (c == '1')&#xA;    {&#xA;      digitalWrite(13, HIGH);&#xA;      Serial.println(&quot;LED is On&quot;);&#xA;      Serial.flush();&#xA;    }&#xA;&#xA;    else if (c == '0')&#xA;    {&#xA;      digitalWrite(13, LOW);&#xA;      Serial.println(&quot;LED is off&quot;);&#xA;      Serial.flush();&#xA;    }&#xA;    else if (c == '3')&#xA;    {&#xA;      int analog_value = analogRead(A0);&#xA;      volt = (analog_value * 5.0) / 1024.0;&#xA;      Serial.print(&quot;v= &quot;);&#xA;      Serial.print(volt, 5);&#xA;      Serial.flush();&#xA;    }&#xA;    else if (c == '4')&#xA;    {&#xA;      //Temp Function go HERE&#xA;      getTemp();&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C# CODE:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c# prettyprint-override&quot;&gt;&lt;code&gt;         private void Connect_Click(object sender, RoutedEventArgs e)&#xA;         {&#xA;           while (portNum &amp;gt;= 0) //automaticly connect to correct port.&#xA;           {&#xA;            try&#xA;            {&#xA;                String portName = &quot;COM&quot; + portNum;&#xA;                comportno.Text = portName;&#xA;                //String portName = comportno.Text;&#xA;                sp.PortName = portName;&#xA;                sp.BaudRate = 9600;&#xA;                sp.Open();&#xA;                status.Text = &quot;Connected&quot;;&#xA;            }&#xA;            catch (Exception)&#xA;            {&#xA;                portNum--;&#xA;                // MessageBox.Show(&quot;Please give a valid port number or check your connection&quot;);&#xA;                if (portNum == -1)&#xA;                {&#xA;                    MessageBox.Show(&quot;Could not find Arduino\nCheck Connection&quot;);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;    }&#xA;&#xA;    private void Disconnect_Click(object sender, RoutedEventArgs e)&#xA;    {&#xA;        try&#xA;        {&#xA;            sp.Close();&#xA;            status.Text = &quot;Disconnected&quot;;&#xA;        }&#xA;        catch (Exception)&#xA;        {&#xA;&#xA;            MessageBox.Show(&quot;First Connect and then disconnect&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    private void on_Click(object sender, RoutedEventArgs e)&#xA;    {&#xA;        sp.Write(&quot;1&quot;);&#xA;        rect_LED.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));&#xA;        // DebugWindow.Text = sp.ReadExisting();&#xA;        //  readingStuff();&#xA;    }&#xA;&#xA;    private void Of_Click(object sender, RoutedEventArgs e)&#xA;    {&#xA;        sp.Write(&quot;0&quot;);&#xA;        rect_LED.Fill = new SolidColorBrush(Color.FromRgb(0, 0, 0));&#xA;        //  DebugWindow.Text = sp.ReadExisting();&#xA;        //  readingStuff();&#xA;    }&#xA;&#xA;    private void Get_Volt_On_Click(object sender, RoutedEventArgs e)&#xA;    {&#xA;&#xA;        sp.Write(&quot;3&quot;);&#xA;        string volts = sp.ReadExisting();&#xA;        int volt_length = volts.Length;&#xA;&#xA;        bool isLetter = !String.IsNullOrEmpty(volts) &amp;amp;&amp;amp; Char.IsLetter(volts[0]) &amp;amp;&amp;amp; Char.IsDigit(volts[volt_length - 1]);&#xA;&#xA;        if (isLetter)&#xA;        {&#xA;            DebugWindow.Text = volts;&#xA;        }&#xA;        else&#xA;        {&#xA;            DebugWindow.Text = &quot;Error&quot;;&#xA;            sp.Write(&quot;3&quot;);&#xA;        }&#xA;    }&#xA;&#xA;    private void Get_Temp_On_Click(object sender, RoutedEventArgs e)&#xA;    {&#xA;        sp.Write(&quot;4&quot;);&#xA;        txt_Volt.Text = sp.ReadExisting();&#xA;    }&#xA;&#xA;    void readingStuff()&#xA;    {&#xA;        String comdata = sp.ReadLine();&#xA;        Dispatcher.Invoke((Action)(() =&amp;gt; DebugWindow.Text += &quot;Data\n&quot; + comdata + &quot;\n&quot;));&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What a bad result looks like: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KGg2o.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KGg2o.png&quot; alt=&quot;Bad Results&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Good result:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wOkU3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wOkU3.png&quot; alt=&quot;Good&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21264" LastEditorUserId="26916" LastEditDate="2017-09-08T23:24:30.267" LastActivityDate="2017-09-08T23:24:30.267" Title="Serial Communication to WPF (Windows Presentation Foundation) giving me odd results. How do I clear up the Strings I am receiving?" Tags="|serial|bluetooth|arduino-leonardo|c#|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24412" PostTypeId="2" ParentId="24410" CreationDate="2016-05-20T17:23:19.453" Score="1" Body="&lt;p&gt;You need to find the transformer for your doorbell system and take the power from there. It seems like somehow you are using the signal wires for the door bell instead of the power wires. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The door bell transformer should/could be in a utility room, closet, by your heating and air unit. once you find that look at the output of the transformer. I know some are AC 12 volts, and I feel like that arduino will not like that... &lt;/p&gt;&#xA;" OwnerUserId="21264" LastActivityDate="2016-05-20T17:23:19.453" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="24413" PostTypeId="2" ParentId="24411" CreationDate="2016-05-20T17:27:11.593" Score="1" Body="&lt;p&gt;Your problem arises from a mix of newline-terminated and un-terminated messages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The newline terminated values probably would work by themselves as you can use a &lt;code&gt;ReadLine()&lt;/code&gt; type method to wait until they have been completely transferred.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the non-terminated attempts such as your use of the &lt;code&gt;ReadExisting()&lt;/code&gt; method cause a problem - these likely fetch whatever has been received &lt;em&gt;up to the time of the call&lt;/em&gt; but that will not necessarily be the full message sent (or even anything at all).   Whatever is left over (had not been received by the time of the call) will become the beginning of the data achieved during the next partial or until-newline read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a solution you should probably either:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Terminate each message with a newline&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or else&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Always read only complete lines, and then &lt;em&gt;parse&lt;/em&gt; individual messages out of them&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Always read until you find some delimiter character such as a space or comma, &lt;em&gt;or&lt;/em&gt; a newline.  You may have to write your own read method to accomplish this.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Using delays to try to fix a problem like this is bad practice as it is fragile and can easily break if there is an unexpected delay on the other side, or if the execution speed of one of the components changes&lt;/em&gt;.  A number of fragile techniques that generally worked with true serial ports subsequently broke when USB converters were introduced in the middle, as USB bunches data into packets with gaps in between, a behavior not necessarily previously seen in many pure serial implementations.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-20T17:27:11.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24414" PostTypeId="1" CreationDate="2016-05-20T17:47:38.613" Score="4" ViewCount="1003" Body="&lt;p&gt;I've run into this a couple of times when trying to use libraries written for Arduino on a particle photon. Many have the line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;pins_arduino.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which returns the error on the photon compiler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; fatal error: pins_arduino.h: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I had similar trouble with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;WProgram.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and found an easy fix was to replace that with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &quot;application.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm wondering if there's a similar easy fix for pins_arduino?&lt;/p&gt;&#xA;" OwnerUserId="21266" LastActivityDate="2019-04-26T09:01:45.357" Title="Replacement for #include &lt;pins_arduino.h&gt; on particle photon" Tags="|library|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24415" PostTypeId="2" ParentId="8292" CreationDate="2016-05-20T17:52:09.940" Score="1" Body="&lt;p&gt;Using an NPN transistor to control power to a peripheral may be problematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An NPN transitor would presumably be used as a &lt;code&gt;low-side switch&lt;/code&gt; interrupting the peripheral's ground line, however, even when turned on this will have a non-trivial voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most logic level definitions are asymmetric, ie, the maximimum legal voltage for a logic &quot;0&quot; is relatively low. If you insert the voltage drop of a bipolar transistor into a peripheral's ground line, then it may be borderline unable to drive a fully legal '0' to the ATmega, which is reference to the lower true ground and would see the peripheral's ground difference added to its output voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better approach would be to use either a high-side switch (as there is typically more room between the minimum legal '1' and the supply) or else to use an FET switch which would have a much lower voltage drop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also keep in mind that most IC's are not specified to tolerate lasting I/O voltages much outside of the range of their power suppliers, and in fact their protection diodes may mean that application of such voltages effectively powers them through the I/O pin.  So before turning off power to a peripheral, you probably want the ATmega software to assert all shared I/O lines towards the side of the peripheral supply which is not being disconnected, ie, for a low side switch drive everything high and for a high side switch drive everything low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the process of power cycling could potentially confuse peripheral interface engines and it is possible that some error flags set in this process might never be cleared.  So you may want to clear the flags of and generally re-initialize your USART, I2C, etc on resume.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-20T17:52:09.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24418" PostTypeId="1" CreationDate="2016-05-20T19:55:20.833" Score="0" ViewCount="75" Body="&lt;p&gt;In a sketch I have, I use a few libraries and have discovered that a large amount of RAM is being consumed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a tool that can identify how this RAM is being allocated, e.g. which libraries, which piece of code?&lt;/p&gt;&#xA;" OwnerUserId="20793" LastActivityDate="2018-10-31T14:47:36.353" Title="Arduino tool to enumerate where RAM is being used?" Tags="|memory|" AnswerCount="1" CommentCount="2" ClosedDate="2018-10-31T18:31:10.807" ContentLicense="CC BY-SA 3.0" />
  <row Id="24419" PostTypeId="1" AcceptedAnswerId="24421" CreationDate="2016-05-20T20:07:53.353" Score="1" ViewCount="752" Body="&lt;p&gt;I am trying to create a state machine that loops in whatever state it's in until a button is pressed.  I am using the &lt;strong&gt;Adafruit_RGBLCDShield&lt;/strong&gt; library along with the LCD shield and 16x2 display.  For some reason the buttons aren't being detected at all.  Here is the code for one of the states:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    case STANDBY_MODE:&#xA;  lcd.clear();&#xA;  lcd.setBacklight(0x0);&#xA;  delay(100);&#xA;  noInterrupts();&#xA;  digitalWrite(fire, LOW);&#xA;  digitalWrite(chg, LOW);&#xA;  digitalWrite(trig, LOW);&#xA;  analogWrite(eprgm, 0);&#xA;  // Wait for button press&#xA;  while(1)&#xA;  {&#xA;    button = lcd.readButtons();&#xA;    if(button)&#xA;    {&#xA;      showLCD();&#xA;      t0 = millis();&#xA;      state = NO_CHARGE;&#xA;      analogWrite(eprgm, (vSet*0.0204)/5);&#xA;      interrupts();&#xA;      return;&#xA;    }&#xA;  }&#xA;break; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this state, the system turns off all outputs and display and waits for a button to be pressed.  For some reason, though, it doesn't respond when I press the button.  Is there something missing here?&lt;/p&gt;&#xA;" OwnerDisplayName="user20985" LastActivityDate="2016-05-21T00:12:55.840" Title="Trouble using lcd.readButtons() in RGBLCDShield library" Tags="|arduino-uno|lcd|shields|button|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24421" PostTypeId="2" ParentId="24419" CreationDate="2016-05-21T00:12:55.840" Score="0" Body="&lt;p&gt;IMO, your post doesn't provide enough information to allow definitive problem diagnosis.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do you say &lt;code&gt;noInterrupts();&lt;/code&gt; at line 5?  Some versions of the Wire library might be interrupt driven[1].  If interrupts were off, such a library wouldn't detect any button presses on a TWI-interfaced shield like &lt;a href=&quot;https://www.adafruit.com/product/714&quot; rel=&quot;nofollow&quot;&gt;Adafruit's RGBLCDShield&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[1]: Per &lt;a href=&quot;http://playground.arduino.cc/Main/WireLibraryDetailedReference&quot; rel=&quot;nofollow&quot;&gt;arduino.cc's WireLibraryDetailedReference&lt;/a&gt; page,  “&quot;The AVR TWI is byte-oriented and interrupt based....&quot; (section 21.6 on p. 224) ... The TWI module sends an interrupt when it finishes, to notify the processor of the change in conditions ... However, notice that the Wire library has blocking I/O. ” [Ie, the usual Wire library doesn't take advantage of TWI interrupts.]&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-05-21T00:12:55.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24422" PostTypeId="1" CreationDate="2016-05-21T00:32:03.837" Score="4" ViewCount="500" Body="&lt;p&gt;I'm trying to use an Arduino for data collection, and hoping to get a consistent sampling rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I looked into the serial communication using the simplest program I could, but it produces odd results.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { Serial.begin(9600); }&#xA;void loop() { Serial.println(&quot;00000&quot;); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I use a python script to read the data and create a text file and write the time in seconds before the five zeros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the seconds as a marker, I then count the number of data lines for each second.  for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;44 00000  // recorded at time 44 seconds&#xA;44 00000&#xA;44 00000&#xA;45 00000  // recorded at time 45 seconds, etc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was expecting that there would be a somewhat stable value for this.  Using 10 bits per character, printing the 5 zeros should be able to be done about 190 times per second.  When analyzed, it turns out to be lower, which isn't surprising due to overhead, but also unexpectedly variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Collecting the zeros for 5000 seconds produced the following results:&#xA;most often, there were 137 sets of 00000 collected per second, followed by 138 sets of 00000.  This is easily explainable by not being equally spaced per second, and having one second with 137 followed by one second with 138.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is harder to explain is when it jumps to 139, 140, 141 and 142 sets of 00000 per second.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Out of the 5000 seconds of data, there were 25 seconds where 140 sets of 00000 were created.  That isn't too bad and could be due to timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, out of the 5000 seconds, there were 203 seconds where 142 sets of 00000 were created.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The percent breakdown is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;137 sets of 00000:  79.15%&#xA;138 sets of 00000:  13.8%&#xA;139 sets of 00000:  0.39%&#xA;140 sets of 00000:  0.51%&#xA;141 sets of 00000:  2.05%&#xA;142 sets of 00000:  4.11%&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the first 4 could be explainable with minor timing errors, the last ones are very hard to explain.  with 137 sets of 00000 there are 685 characters sent serially in one second.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;with 142 sets of 00000 there are 710 characters sent serially in one second.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am trying to figure out is why the variability is so wide and also so consistent - as in the pattern, which can be seen in the graph.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/nETxJ.jpg&quot; alt=&quot;frequency of characters sent per second&quot;&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/70pxx.jpg&quot; alt=&quot;pattern of characters sent&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any explanation for the variability?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the variability in the transfer, it is very hard to sync up data or filters or other uses when a constant sample rate is needed.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also added delays in the main loop from 1ms to 7ms, 7ms was the maximum because that would not cause the loop to run slower than the free running speed at 142 loops/transmissions per second (1sec/7ms = 142.8 loops per second discounting all other overhead) and found the same patterns.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a delay of 8ms produced another interesting result:&#xA;with a delay of 8ms, most of the data was transmitted at 123 or 124 sets of 00000 per second, but every 12 seconds there would be a burst of 128 sets of characters.  this makes sense because the delays add up to less than one second for 11 loops, then get an extra loop for that second, but that adds 15 characters, not just 5.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After re-reading this, it dawned on me that there might be some loop timing/buffering errors, so instead of a delay, I used Serial.flush() to pause the loop until the data was sent.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This resulted in a free-running result of 137 sets transmitted per second for the most common, followed by 138 sets.  The new issue is that every 25 seconds there is a drop down to 133 sets of characters transmitted per second, which seems to be the same issue only causing slowing instead of speeding up.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I found the answer with Serial.flush() but there is still something causing huge changes in the sent characters per second.  What could be causing this? and what can be done to make the transfer rates more constant?&lt;/p&gt;&#xA;" OwnerUserId="21271" LastActivityDate="2016-05-21T08:39:49.900" Title="why are there odd spikes in the USB serial data transfer rates?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24423" PostTypeId="2" ParentId="24422" CreationDate="2016-05-21T00:48:14.967" Score="1" Body="&lt;p&gt;While a serial port &quot;kept busy&quot; can potentially produce data with jitter comparable to its clock's jitter reduced by the number of clocks per word, a USB serial converter introduces a bunching of data into packets that is effectively entirely asynchronous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a result, once the data has gone through the USB, you really can't determine much of anything about the timing of its &lt;em&gt;origin&lt;/em&gt; just by looking at the timing of its &lt;em&gt;arrival&lt;/em&gt;.  That remains true even if you are claiming it via a serial-type API on the host, because the USB bus has already irreversibly de-synchronized it in transit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A more meaningful experiment would be to timestamp the data at the source, ie, on the Arduino.  That could potentially be more regular, but if you use a high enough resolution timestamp, you will still find that it is irregular, as by default the Arduino's foreground thread of execution is periodically interrupted by the timer, which produces a brief delay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are sending serial data into the Arduino or using other hardware peripherals, those may cause additional sporadic delay-inducing interrupts.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-21T00:48:14.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24424" PostTypeId="1" AcceptedAnswerId="24427" CreationDate="2016-05-21T01:19:12.823" Score="2" ViewCount="399" Body="&lt;p&gt;I have this if statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (now.hour() == 5 &amp;amp;&amp;amp; now.minute() == 10 &amp;amp;&amp;amp; now.second() == 0 &amp;amp;&amp;amp; now.dayOfTheWeek() != 1 &amp;amp;&amp;amp; now.dayOfTheWeek() != 7){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is there a way to condense that for the purposes of saving on some bytes?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately trying to say &quot;At 5:10 every weekday do X&quot;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-05-21T01:33:50.163" LastActivityDate="2016-05-22T16:19:45.233" Title="Possible to condense this if statement?" Tags="|code-optimization|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24425" PostTypeId="2" ParentId="24424" CreationDate="2016-05-21T01:31:08.570" Score="1" Body="&lt;p&gt;Yes. The method now() Returns the current time as seconds since Jan 1 1970. Simply keep tract of all your time this way and you only need to test this one value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://arduino.stackexchange.com/questions/242/arduino-time-clock-accuracy&quot;&gt;Arduino is not a good source of time over long periods&lt;/a&gt;.  Consider using an &lt;a href=&quot;https://en.wikipedia.org/wiki/Real-time_clock&quot; rel=&quot;nofollow noreferrer&quot;&gt;RTC&lt;/a&gt; (Real Time Clock) chip.  &lt;a href=&quot;http://playground.arduino.cc/Code/Time&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; Arduino page links to &lt;a href=&quot;http://www.pjrc.com/teensy/td_libs_DS1307RTC.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; page which talks about an RTC.  (I will leave it up to you to research any compatibility issues.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many RTCs contain a register set specifically designed to handle tasks such as you outlined above. For example, setting alarms off on weekdays only or on specific days of the month.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If absolute time is not important in your application I would try the following code outline.  Each test only has 2 operands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Turn on Arduino on Monday at the time task is to be performed.  Task&#xA;// should be performed at that time on Monday, Tuesday, ... Friday.&#xA;// Nothing should happen on Saturday &amp;amp; Sunday.  Then cycle repeats.&#xA;&#xA;// Set time to zero.&#xA;&#xA;// Count through days (0, 1, 2, ...).&#xA;&#xA;// Wait each day until number-of-seconds is greater then seconds-in-a-day&#xA;// times the day number.&#xA;&#xA;// If day number is 4 or less do activity.  Else skip activity.&#xA;&#xA;// If day number is more than 6 set the day counter to 0 and set the time&#xA;// to zero.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to start the Arduino at arbitrary times, set the initial Arduino clock value to the number of seconds from the time the activity would have been performed on Monday and initialize the day counter to the appropriate value.  For example if you started the Arduino on Tuesday 23 hours after the time the activity should have happened on Monday set the Arduino clock to 23 * 60 * 60 seconds and initialize the day counter to 2.  Of course you can calculate the initial day counter value using  = initial_number_of_seconds / 60 * 60 * 24.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-05-21T14:42:04.350" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24426" PostTypeId="1" AcceptedAnswerId="24436" CreationDate="2016-05-21T02:11:18.450" Score="0" ViewCount="91" Body="&lt;p&gt;I'm a painful 128 bytes of my max for this Trinket. Any refactoring I could do to get down the size?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;&#xA;#define LEDPIN 1&#xA;#define TONE 4&#xA;#define BTNPIN 3&#xA;&#xA;RTC_DS1307 rtc;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, LEDPIN, NEO_RGB);&#xA;&#xA;const long fadeTime = 10 * 60000L; // X minutes&#xA;const int colorStops = 255;&#xA;const int delaySpeed = fadeTime / colorStops;&#xA;const int notes[] = {262,294,330,349};&#xA;const uint32_t alarmLength = 5 * 60000L; // 5 minutes&#xA;&#xA;void setup() {&#xA;  rtc.begin();&#xA;  rtc.adjust(DateTime(__DATE__, __TIME__));&#xA;&#xA;  pinMode(TONE,OUTPUT);&#xA;  pinMode(BTNPIN, INPUT);&#xA;  digitalWrite(BTNPIN, HIGH);&#xA;&#xA;  strip.begin();&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop() {&#xA;  DateTime now = rtc.now();&#xA;&#xA;  // If it's 5:10 am on a week day, start the fade in&#xA;  if (now.hour() == 5 &amp;amp;&amp;amp; now.minute() == 10 &amp;amp;&amp;amp; now.second() == 0 &amp;amp;&amp;amp; now.dayOfTheWeek() != 1 &amp;amp;&amp;amp; now.dayOfTheWeek() != 7){&#xA;    // Fade in light&#xA;    for(int i = 1; i&amp;lt;colorStops; i++){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;        strip.setPixelColor(np, strip.Color(i,i,i));&#xA;      }&#xA;      strip.show();&#xA;      delay(delaySpeed);&#xA;    }&#xA;&#xA;    // Play tone after light fully bright&#xA;    for( uint32_t tStart = millis();  (millis()-tStart) &amp;lt; alarmLength; ){&#xA;      if (kill() == true){ break; }&#xA;&#xA;      for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;         strip.setPixelColor(np, strip.Color(random(50,255),random(50,255),random(50,255)));&#xA;      }&#xA;      strip.show();&#xA;&#xA;      beep(notes[random(0,3)]);&#xA;      delay(100);&#xA;    }&#xA;&#xA;    turnOffPixels();&#xA;  }&#xA;}&#xA;&#xA;void beep(int delayAmount)&#xA;{&#xA;  for (uint16_t t = 0; t &amp;lt; 30*1000/2; t += delayAmount)&#xA;  {  &#xA;    digitalWrite(TONE,HIGH);&#xA;    delayMicroseconds(delayAmount);&#xA;    digitalWrite(TONE,LOW);&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&#xA;void turnOffPixels() {&#xA;  for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA;    strip.setPixelColor(np, strip.Color(0,0,0));&#xA;  }&#xA;  strip.show();&#xA;}&#xA;&#xA;bool kill() {&#xA;  if (! digitalRead(BTNPIN)) {&#xA;    turnOffPixels();&#xA;    return true;&#xA;  } else {&#xA;    return false;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 5,438 bytes (102%) of program storage space. Maximum is 5,310 bytes.&#xA;Global variables use 97 bytes of dynamic memory.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-05-21T12:30:21.180" Title="Refactor to save bytes?" Tags="|code-optimization|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24427" PostTypeId="2" ParentId="24424" CreationDate="2016-05-21T02:47:27.450" Score="2" Body="&lt;p&gt;The following saves a couple of program bytes (but no RAM) when &lt;code&gt;now&lt;/code&gt; is a structure with a byte called &lt;code&gt;DayofWeek&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if ((byte)(now.DayofWeek+249)&amp;gt;250) ...&#xA;   -vs-&#xA; if ((now.DayofWeek != 1 &amp;amp;&amp;amp; now.DayofWeek != 7)) ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It might save slightly more than that in your case, where &lt;code&gt;now.dayOfTheWeek()&lt;/code&gt; appears to be a function reference.  This technique will work if function &lt;code&gt;now.dayOfTheWeek()&lt;/code&gt; returns a &lt;code&gt;byte&lt;/code&gt;, that is, an &lt;code&gt;unsigned char&lt;/code&gt;.  The technique depends on value 7+249 overflowing to zero &lt;strike&gt;in byte arithmetic&lt;/strike&gt; when truncated to a byte, because 7+249 is 0 modulo 256.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The cast to &lt;code&gt;byte&lt;/code&gt; [or &lt;code&gt;uint8_t&lt;/code&gt;] of &lt;code&gt;now.DayofWeek+249&lt;/code&gt; is needed because of &lt;code&gt;int&lt;/code&gt; promotion as Edgar Bonet pointed out.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-22T16:19:45.233" LastActivityDate="2016-05-22T16:19:45.233" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24428" PostTypeId="2" ParentId="24426" CreationDate="2016-05-21T03:42:27.213" Score="0" Body="&lt;p&gt;For refactoring, consider using a &lt;code&gt;for&lt;/code&gt; loop that executes twice, once for the  “// Fade in light” section of code, and once for the  “// Play tone after light fully bright” section.  For parts of the code that differ, test the loop index and do one action or the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are two ways to get rid of a few (eg 54) bytes of code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Instead of&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt; Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, LEDPIN, NEO_RGB);&#xA; ...&#xA; for(int np = 0;np&amp;lt;strip.numPixels(); np++){&#xA; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(with three instances of the latter), say something like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;enum {numPixels = 5 };&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, LEDPIN, NEO_RGB);&#xA;...&#xA;for (byte np=0; np&amp;lt;numPixels; ++np){&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will save about 40 bytes (10 bytes per &lt;code&gt;for&lt;/code&gt;, and another 10 probably due to &lt;code&gt;strip.numPixels()&lt;/code&gt; code not linking).  (Note, the savings is due to getting rid of function calls; the change from &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;byte&lt;/code&gt; apparently makes no difference in program size, probably because the compiler optimizes &lt;code&gt;int&lt;/code&gt; to &lt;code&gt;byte&lt;/code&gt; where its analysis shows it can do so.) &lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Instead of &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if (... &amp;amp;&amp;amp; now.dayOfTheWeek() != 1 &amp;amp;&amp;amp; now.dayOfTheWeek() != 7){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;say&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;if (... &amp;amp;&amp;amp; now.dayOfTheWeek()+250&amp;gt;250){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will save 14 bytes.  This works as explained in my answer to your previous question.  However, I've written &lt;code&gt;+250&amp;gt;250&lt;/code&gt; here instead of the &lt;code&gt;+249&amp;gt;250&lt;/code&gt; there because according to &lt;code&gt;RTClib&lt;/code&gt; documentation and &lt;code&gt;RTClib.cpp&lt;/code&gt; code, &lt;code&gt;.dayOfTheWeek()&lt;/code&gt; returns 0 for Saturday, rather than 1 as you seem to expect.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Possibly inline &lt;code&gt;beep()&lt;/code&gt;, since you call it only once.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-21T03:48:04.313" LastActivityDate="2016-05-21T03:48:04.313" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24429" PostTypeId="2" ParentId="24426" CreationDate="2016-05-21T05:48:42.763" Score="1" Body="&lt;p&gt;On a quick test build for an ATmega328p type Arduino, the implementation of random() and its unique dependencies seems to be about 180 bytes, so you might see if there's a more compact way of achieving your need there, perhaps using the low byte of some mathematical expression of the time, and just retrying until you get an in-range value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course if you get really stuck, you could remove the bootloader and program it with ISP from an ordinary Arduino or something like that.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-21T05:48:42.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24430" PostTypeId="1" CreationDate="2016-05-21T06:07:14.473" Score="0" ViewCount="1617" Body="&lt;p&gt;In trying to figure out how to solve another &lt;a href=&quot;https://arduino.stackexchange.com/questions/23750/nano-clone-not-working-over-usb-no-data-no-power-but-can-power-via-vin-schot&quot;&gt;problem with Arduino Nano clone using CH340 chip&lt;/a&gt;, I was just now wondering, would there be any issues if I were to simply remove the CH340 chip? As it stands, I have the slight suspicion that the chip itself might be causing some problems with communicating using only the Tx Rx pins, could this be the case? More importantly, can I just remove the chip with no issues (other than the already lacking ability to use it as USB-Serial bridge)? In a working board, would removing the chip cause any other problems?&lt;/p&gt;&#xA;" OwnerUserId="19157" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2021-07-19T04:17:38.943" Title="Removing CH340g chip from Arduino Nano clone.. any issues?" Tags="|arduino-nano|ch340|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24432" PostTypeId="2" ParentId="24422" CreationDate="2016-05-21T08:39:49.900" Score="-1" Body="&lt;p&gt;This could be largely to do with how USB serial works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB has a number of different methods of transferring data between the device and the host. Both CDC/ACM use FT232 use a method called &lt;em&gt;bulk transfer&lt;/em&gt;. This is a very low priority transfer method and data is moved across the bus as and when it can - that is, when the bus isn't doing anything else. If there is anything else happening on the bus (and there will be) the transfers get delayed until the bus is doing nothing else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If timing is critical for a protocol, such as USB audio or video where you have to have the data transferred to the host absolutely right now a different method is used. This is called &lt;em&gt;isochronous&lt;/em&gt;. It is the highest priority of data transfer, even higher than interrupt data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However there is no way on the Arduino to use any form of isochronous transfers so you will have to come up with some other method of managing your timing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Chris has mentioned the most common method is to include a timestamp with each packet of data. That packet may contain just one sample, or it may contain a block of samples. The important thing is to know when the block starts and from that infer the time of each sample within the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also important to ensure that your communication with the host isn't running at 100% saturation. You should be running at the highest baud rate that is reliable and only send data at regular intervals giving you time to get the data in between each transfer. Keeping your data packets as small and efficient as possible is also good for keeping you transfer rate sustained properly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T08:39:49.900" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="24433" PostTypeId="2" ParentId="24430" CreationDate="2016-05-21T08:45:31.357" Score="1" Body="&lt;p&gt;No problem whatsoever as long as you aren't powering the board over USB. You may still be able to do that though depending on what role the CH has in managing the power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I think all CH chip should be removed from all boards. They are horrible chips and cause no end of problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I assume you have an FT232 adapter board (or similar) to then use for the programming of your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T08:45:31.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24434" PostTypeId="2" ParentId="24430" CreationDate="2016-05-21T09:02:48.400" Score="0" Body="&lt;p&gt;Looking at the datasheet, I see no problem with removing it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd suggest using a sharp knife and cut all the pins, one at a time, right where they come out of the black epoxy. Make sure you don't accidentally stab into the PCB. Remove the main body of the chip. After that, remove the legs still attached to the PCB, one by one, using a soldering iron.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-21T09:02:48.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24436" PostTypeId="2" ParentId="24426" CreationDate="2016-05-21T09:21:54.807" Score="2" Body="&lt;p&gt;Remove the &lt;code&gt;rtc.adjust(DateTime(__DATE__, __TIME__));&lt;/code&gt;. You only need to set the RTC once, after e.g. you insert the backup battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(BTNPIN, INPUT);&#xA;digitalWrite(BTNPIN, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(BTNPIN, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Inline the beep function using the &lt;code&gt;inline&lt;/code&gt; hint:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inline void beep(int delayAmount)&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Shorter &lt;code&gt;beep&lt;/code&gt; function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;inline void beep(int delayAmount)&#xA;{&#xA;  for (uint16_t t = 0; t &amp;lt; 30*1000; t += delayAmount)&#xA;  {  &#xA;    digitalWrite(TONE,t &amp;amp; 0x01);// HIGH is odd, LOW if even&#xA;    delayMicroseconds(delayAmount);&#xA;  }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-21T09:21:54.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24437" PostTypeId="1" CreationDate="2016-05-21T11:33:29.223" Score="5" ViewCount="7168" Body="&lt;p&gt;I have written the following code to measure the speed of a unidirectional DC Motor.I have attempted to measure the time between successive interrupts in order to calculate speed.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;boolean check;&#xA;boolean start;&#xA;unsigned int angle = 5;   //angle moved per encoder tick&#xA;unsigned long volatile time1;&#xA;unsigned long volatile time_11;&#xA;unsigned long interrupt_time;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while (!Serial) ;&#xA;  pinMode(21, INPUT);  //Pin#21=interrupt pin, matched to interrupt#2&#xA;  attachInterrupt(digitalPinToInterrupt(2), speed, FALLING);&#xA;  time1 = 0;&#xA;  time_11 = 0;&#xA;  interrupt_time = 0;&#xA;  check = true;&#xA;  start = false;&#xA;  time_11 = millis(); //Start Clock&#xA;}&#xA;&#xA;void loop() {&#xA;  if(time1 == interrupt_time &amp;amp;&amp;amp; start) //Both times same , hence bool start.&#xA;  {&#xA;    if(check)&#xA;    {&#xA;      Serial.print(millis());  //Time taken to rise to steady speed.&#xA;      check = false;&#xA;    }&#xA;    Serial.println((angle/time1)*1000);   //Display Speed.&#xA;  }&#xA;  interrupt_time = time1;&#xA;  start = false;&#xA;  while(!start)&#xA;    {}&#xA;}&#xA;&#xA;void speed(void) {&#xA;  start = true;&#xA;  time1 = millis()-time_11;&#xA;  time_11 = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want the code to be as efficient as possible.I have around 100 ticks per 360 degrees from my encoder.Is there any chance of &quot;missing&quot; an interrupt?&lt;/p&gt;&#xA;" OwnerUserId="21281" LastEditorDisplayName="user31481" LastEditDate="2017-11-14T07:53:03.777" LastActivityDate="2021-09-23T22:04:50.447" Title="DC Motor Speed Measurement using Rotary Encoder" Tags="|arduino-mega|motor|code-review|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24438" PostTypeId="1" AcceptedAnswerId="24442" CreationDate="2016-05-21T11:35:55.423" Score="0" ViewCount="663" Body="&lt;p&gt;I'm trying to build a GSM based AC Power ON/OFF switch using Arduino. I've successfully completed the ON/OFF mechanism using SMS with the help of 240v 100amps relay to control the circuit. Apparently I don't want to disturb the regular on/off switch's operation. I want both of them to be operational. When I'm not at home arduino should be the switch control and the regular one should be preferred while at home. I'm actually a noob in this topic, and want your precious help to solve this issue.   &lt;/p&gt;&#xA;" OwnerUserId="21280" LastActivityDate="2016-05-21T20:55:59.790" Title="How to switch on an AC bulb using arduino as well as regular switch?" Tags="|relay|switch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24439" PostTypeId="1" CreationDate="2016-05-21T12:13:32.190" Score="1" ViewCount="784" Body="&lt;p&gt;I have a recurring problem that when I'm controlling leds, I make several different functions for different fx and just want to trigger them randomly but having a hard time to formulate it in an intelligent way and end up hardcoding every function call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ex: I have let's say 10 functions called anim1();, anim2();, anim3(); etc &#xA;and would like to called them randomly in that fashion :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;randNumber = random(1,11);&#xA;anim[randNumber]();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know that it's not that type of brackets I need to use but I can't find the proper syntax and I'm wondering if it's possible to do that..&#xA;I'm sure there must be a way ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for your help&lt;/p&gt;&#xA;" OwnerUserId="21282" LastActivityDate="2016-05-25T00:12:43.013" Title="calling a random function number" Tags="|programming|arduino-ide|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24440" PostTypeId="2" ParentId="24426" CreationDate="2016-05-21T12:30:21.180" Score="1" Body="&lt;p&gt;Very good suggestions so far. I have only one to add: instead of&#xA;&lt;code&gt;strip.Color(0,0,0)&lt;/code&gt; use just the constant number 0. This saves a&#xA;function call.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-21T12:30:21.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24441" PostTypeId="2" ParentId="24439" CreationDate="2016-05-21T12:38:56.880" Score="3" Body="&lt;p&gt;What you want is an &lt;em&gt;array of function pointers&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void anim1() {&#xA;    // blah blah&#xA;}&#xA;&#xA;void anim2() { &#xA;    // blah blah&#xA;}&#xA;// ... etc ...&#xA;&#xA;typedef void (*animptr)();&#xA;&#xA;animptr anims[10] = {&#xA;    anim1,&#xA;    anim2,&#xA;    anim3,&#xA;    // ... etc ...&#xA;    anim10&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;anims[animNumber]();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-21T12:43:18.683" LastActivityDate="2016-05-21T12:43:18.683" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24442" PostTypeId="2" ParentId="24438" CreationDate="2016-05-21T12:50:42.407" Score="1" Body="&lt;p&gt;This can be done (to a certain extent) using a SPDT (Single-Pole-Double-Throw) relay and an SPDT switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic principle is the same as when you have two light switches controlling the same light (such as on a staircase - one switch at the top and one at the bottom).  The two switches alternate between one of two different paths for the current. When both switches are routed to the same path the light is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2XvW3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2XvW3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both the Arduino and the switch can turn the light on and off at will. The only problem, though, is that the Arduino has no clue if the light is on or off. To know if the light is on you will need some kind of feedback mechanism.  That might be a simple LDR that looks to see if it's light or dark, or some kind of current monitoring system (current transformer, hall effect current monitor, etc) which the Arduino can use to see if current is actually flowing through the lamp circuit or not.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T12:50:42.407" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24443" PostTypeId="2" ParentId="24437" CreationDate="2016-05-21T13:03:05.257" Score="1" Body="&lt;p&gt;Just a couple of remarks:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;code&gt;start&lt;/code&gt; should be volatile, but you can remove it and simply check&#xA;that &lt;code&gt;time1 != 0&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;there is no point in calling &lt;code&gt;millis()&lt;/code&gt; twice inside the interrupt&#xA;service routine:&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void speed(void) {&#xA;  unsigned long now = millis();&#xA;  time1 = now - time_11;&#xA;  time_11 = now;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-21T13:03:05.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24447" PostTypeId="1" AcceptedAnswerId="24449" CreationDate="2016-05-21T14:43:41.997" Score="0" ViewCount="4954" Body="&lt;p&gt;i want to convert string for example &#xA;&quot;68976543210&quot; to unsigned long long(64 bit) in mega2560,&#xA; do is possible?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String x=&quot;68976543210&quot;;&#xA;unsigned long long y=?;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20800" LastActivityDate="2016-05-21T15:21:59.970" Title="convert String to unsigned long long" Tags="|arduino-mega|string|convert|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24449" PostTypeId="2" ParentId="24447" CreationDate="2016-05-21T15:21:59.970" Score="3" Body="&lt;p&gt;avr-libc lacks &lt;code&gt;strtoull()&lt;/code&gt; that I would normally use for such a conversion. You will have to do it manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Fortunately it's quite simple - just start with y=0 and, for each character in the string, multiply y by 10 then add the numeric value of the character in the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String x = &quot;68976543210&quot;;&#xA;unsigned long long y = 0;&#xA;&#xA;for (int i = 0; i &amp;lt; x.length(); i++) {&#xA;    char c = x.charAt(i);&#xA;   if (c &amp;lt; '0' || c &amp;gt; '9') break;&#xA;   y *= 10;&#xA;   y += (c - '0');&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the Arduino Print API has no method for printing a 64-bit integer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T15:21:59.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24450" PostTypeId="1" AcceptedAnswerId="24455" CreationDate="2016-05-21T16:31:32.147" Score="0" ViewCount="7840" Body="&lt;p&gt;Is there a way to monitor the battery that feeds an esp8266 in a portable project?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been meaning to implement that feature into my project so that i can be warned when the battery runs low on juice but i don't know if the esp has some kind of onboard sensor to do that.&lt;/p&gt;&#xA;" OwnerUserId="21061" LastActivityDate="2016-06-20T18:18:50.793" Title="ESP8266 Battery Monitor" Tags="|esp8266|battery|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24452" PostTypeId="1" CreationDate="2016-05-21T17:05:10.243" Score="1" ViewCount="1509" Body="&lt;p&gt;If I use direct port manipulation, what is the average number of clock cycles it takes to flip a pin on the arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ie.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  PORTB |=  0b00010000;&#xA;  PORTB &amp;amp;= ~0b00010000;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how fast is this generally?&lt;/p&gt;&#xA;" OwnerUserId="21078" LastActivityDate="2016-05-21T17:38:18.033" Title="Pin toggle speed" Tags="|arduino-uno|frequency|port-mapping|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24454" PostTypeId="2" ParentId="24452" CreationDate="2016-05-21T17:38:18.033" Score="4" Body="&lt;p&gt;If you compile the code and examine the results you can see how many instructions it will take, and thus how many clock cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's slightly more complex because of what else happens in main() to call loop, but basically you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (;;) {&#xA;loop();&#xA;  aa:0e 94 49 00 call 0x92; 0x92 &amp;lt;loop&amp;gt;&#xA;if (serialEventRun) serialEventRun();&#xA;  ae:20 97       sbi wr28, 0x00; 0&#xA;  b0:e1 f3       breq.-8      ; 0xaa &amp;lt;main+0x10&amp;gt;&#xA;&#xA;&#xA;00000092 &amp;lt;loop&amp;gt;:&#xA;  92:2c 9a       sbi0x05, 4; 5&#xA;  94:2c 98       cbi0x05, 4; 5&#xA;  96:08 95       ret&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can see there is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Operation                            Cycles&#xA;Call loop()                          4&#xA;Check if serialEventRun exists       2&#xA;Since it doesn't, got start of loop  2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then in loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Set bit                              2&#xA;Clear bit                            2&#xA;Return                               4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So in total you have 16 clock cycles. At 16MHz that gives you a frequency of 1MHz - however that won't be a square wave of 50% duty cycle since there is much less time between set and clear than between clear and set.  The full 16 cycles, mapped to the state of the IO pin, would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;             _ &#xA; _ _ _ _ _ |   | _ _ _ _ _ _ _ _&#xA;| call  |sbi|cbi|  ret  |chk|bra|&#xA; . . . . . . . . . . . . . . . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can get a much tighter operation by wrapping the pin manipulation in a &lt;code&gt;while (1)&lt;/code&gt; loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  while(1) {&#xA;    PORTB |=  0b00010000;&#xA;    PORTB &amp;amp;= ~0b00010000;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That reduces down to just:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;00000092 &amp;lt;loop&amp;gt;:&#xA;  92:2c 9a       sbi 0x05, 4; 5&#xA;  94:2c 98       cbi 0x05, 4; 5&#xA;  96:fd cf       rjmp .-6      ; 0x92 &amp;lt;loop&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's &lt;code&gt;sbi&lt;/code&gt; (2) &lt;code&gt;cbi&lt;/code&gt; (2) and &lt;code&gt;rjmp&lt;/code&gt; (2). A total of 6 clock cycles.  At 16MHz that's 2.667MHz. Again, though, not a 50% duty cycle, since the &lt;code&gt;rjmp&lt;/code&gt; takes two extra clock cycles:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     _&#xA; _ |   | _ _&#xA;|sbi|cbi|jmp|&#xA; . . . . . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By inserting a pair of 1-cycle &lt;code&gt;NOP&lt;/code&gt; instructions you can even out the duty cycle and make it 50%:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  while(1) {&#xA;    PORTB |=  0b00010000;&#xA;    asm volatile(&quot;nop&quot;);&#xA;    asm volatile(&quot;nop&quot;);&#xA;    PORTB &amp;amp;= ~0b00010000;&#xA;  }&#xA;}&#xA;&#xA;00000092 &amp;lt;loop&amp;gt;:&#xA;  92:2c 9a       sbi 0x05, 4; 5&#xA;  94:00 00       nop&#xA;  96:00 00       nop&#xA;  98:2c 98       cbi 0x05, 4; 5&#xA;  9a:fb cf       rjmp.-10     ; 0x92 &amp;lt;loop&amp;gt;&#xA;&#xA;&#xA;     _ _ _&#xA; _ |       | _ _&#xA;|sbi|n|n|cbi|jmp|&#xA; . . . . . . . .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, of course, it's 8 clock cycles, so at 16MHz that's 2MHz output, but with 50% duty cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, all these instruction timings are available in the Instruction Set Summary chapter of the ATMega328P data sheet.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T17:38:18.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24455" PostTypeId="2" ParentId="24450" CreationDate="2016-05-21T17:51:30.347" Score="4" Body="&lt;p&gt;There are two things you need to measure the battery of the system that is doing the measuring of the battery:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;An analog-to-digital converter&lt;/li&gt;&#xA;&lt;li&gt;Some form of fixed voltage reference to compare the battery voltage against.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Some ESP8266 modules have a single analog input available, and some don't. You need to check which module you have and which pins are available on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you need to use the ADC to measure the fixed known voltage. That could be from a small LDO voltage regulator that is below the voltage of the minimum voltage you will care about from your battery, or something like the forward voltage drop of a silicon diode (~0.7V) - something where you know what the voltage is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that reading you can then back-track what the supply voltage must be in order to give you the reading it has given you.  As the battery voltage drops the voltage range the ADC will be measuring will be reduced, and so the fixed voltage will rise within that range giving you higher readings from the ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a snippet of code I use with the 1.1V internal voltage reference of the ATMega328P to calculate the supply voltage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long readVcc() {&#xA;  long result;&#xA;  // Read 1.1V reference against AVcc&#xA;  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);&#xA;  delay(2); // Wait for Vref to settle&#xA;  ADCSRA |= _BV(ADSC); // Convert&#xA;  while (bit_is_set(ADCSRA,ADSC));&#xA;  result = ADCL;&#xA;  result |= ADCH&amp;lt;&amp;lt;8;&#xA;  result = 1125300L / result; // Back-calculate AVcc in mV&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you need to change that to use the analog input of the ESP8266 instead (probably just using analogRead()). And of course change the ADC-scaled voltage.  The formula is basically:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vref * ADCmax / ADCreading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if you have the 1.1V reference as above, and the ADC can read 0-1023, then it's:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.1 * 1023 / reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, pre-calculate the first half of the sum:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1125.3 / reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To keep it as integer mathematics work in millivolts instead of volts by multiplying the reference voltage by 1000:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1125300 / reading&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that, as you can see, is what is in the function above.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T17:51:30.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24456" PostTypeId="1" CreationDate="2016-05-21T18:02:40.357" Score="1" ViewCount="1504" Body="&lt;p&gt;As written in the title, could you tell me where to find the source code of the function &quot;Serial.find()&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven' t installed the Arduino IDE, so I'm glad if you could me link a web resource, or if you directly copy the source code here .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your time.&lt;/p&gt;&#xA;" OwnerUserId="21286" LastActivityDate="2016-05-21T18:05:58.950" Title="Where could I find the &quot;Serial.find()&quot; source code?" Tags="|serial|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24457" PostTypeId="2" ParentId="24456" CreationDate="2016-05-21T18:05:58.950" Score="1" Body="&lt;p&gt;It is part of the Stream class which the Serial class inherits from.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L93&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L93&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It just calls &lt;code&gt;findUntil()&lt;/code&gt; which is a little further down in the same file:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L114&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L114&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That itself calls &lt;code&gt;findMulti()&lt;/code&gt; which is where all the magic happens:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L256&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Stream.cpp#L256&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {&#xA;  // any zero length target string automatically matches and would make&#xA;  // a mess of the rest of the algorithm.&#xA;  for (struct MultiTarget *t = targets; t &amp;lt; targets+tCount; ++t) {&#xA;    if (t-&amp;gt;len &amp;lt;= 0)&#xA;      return t - targets;&#xA;  }&#xA;&#xA;  while (1) {&#xA;    int c = timedRead();&#xA;    if (c &amp;lt; 0)&#xA;      return -1;&#xA;&#xA;    for (struct MultiTarget *t = targets; t &amp;lt; targets+tCount; ++t) {&#xA;      // the simple case is if we match, deal with that first.&#xA;      if (c == t-&amp;gt;str[t-&amp;gt;index]) {&#xA;        if (++t-&amp;gt;index == t-&amp;gt;len)&#xA;          return t - targets;&#xA;        else&#xA;          continue;&#xA;      }&#xA;&#xA;      // if not we need to walk back and see if we could have matched further&#xA;      // down the stream (ie '1112' doesn't match the first position in '11112'&#xA;      // but it will match the second position so we can't just reset the current&#xA;      // index to 0 when we find a mismatch.&#xA;      if (t-&amp;gt;index == 0)&#xA;        continue;&#xA;&#xA;      int origIndex = t-&amp;gt;index;&#xA;      do {&#xA;        --t-&amp;gt;index;&#xA;        // first check if current char works against the new current index&#xA;        if (c != t-&amp;gt;str[t-&amp;gt;index])&#xA;          continue;&#xA;&#xA;        // if it's the only char then we're good, nothing more to check&#xA;        if (t-&amp;gt;index == 0) {&#xA;          t-&amp;gt;index++;&#xA;          break;&#xA;        }&#xA;&#xA;        // otherwise we need to check the rest of the found string&#xA;        int diff = origIndex - t-&amp;gt;index;&#xA;        size_t i;&#xA;        for (i = 0; i &amp;lt; t-&amp;gt;index; ++i) {&#xA;          if (t-&amp;gt;str[i] != t-&amp;gt;str[i + diff])&#xA;            break;&#xA;        }&#xA;&#xA;        // if we successfully got through the previous loop then our current&#xA;        // index is good.&#xA;        if (i == t-&amp;gt;index) {&#xA;          t-&amp;gt;index++;&#xA;          break;&#xA;        }&#xA;&#xA;        // otherwise we just try the next index&#xA;      } while (t-&amp;gt;index);&#xA;    }&#xA;  }&#xA;  // unreachable&#xA;  return -1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-21T18:05:58.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24458" PostTypeId="1" AcceptedAnswerId="24459" CreationDate="2016-05-21T19:47:24.040" Score="3" ViewCount="3147" Body="&lt;p&gt;I have an array of 41,400 elements of type char, which I am trying to put in program memory on a Mega2560. It should have 256KB of flash memory, but when I try to compile my sketch, it says the size of the array is too large. Each char is one byte, so this array should be 41,400 bytes. I'm at a loss as to how this can be too big.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tried using an array of byte variables (should be the same thing) with no success. This is the only variable going into program memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the relevant line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char Array[] PROGMEM = {0,19,21,25,27,27,27,29,24, ... };&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have included avr/pgmspace.h&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance for any help.&lt;/p&gt;&#xA;" OwnerUserId="21288" LastEditorUserId="21288" LastEditDate="2016-05-22T04:30:39.757" LastActivityDate="2016-05-22T04:30:39.757" Title="How is a 41KB char array filling up 256KB of program memory?" Tags="|progmem|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="24459" PostTypeId="2" ParentId="24458" CreationDate="2016-05-21T20:14:13.657" Score="3" Body="&lt;p&gt;The limitation here is the data type of the index of the array. That is &lt;code&gt;int&lt;/code&gt;, and on an 8-bit system an &lt;code&gt;int&lt;/code&gt; can hold a value in the range -32768 to 32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means the biggest index number an array can have is 32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That limit cannot be changed. You're stuck with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, there are some tricks you can use to expand it.  One is to use a larger data type than &lt;code&gt;char&lt;/code&gt; and pack your data into it.  For instance, using &lt;code&gt;unsigned int&lt;/code&gt; as your data type will give you a maximum of 32767 16-bit values. Each one can hold two bytes. That gives you a total capacity of 65534 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using unsigned long (32 bits) would double that again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is then up to you to work out how to get to the individual bytes. Using the &lt;code&gt;pgm_read_byte_*()&lt;/code&gt; function you may not see any difference. After all the start address is just an address regardless of type. Of course, you have to watch out for any differences in endianness when you have packed your initial data into the array...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-21T23:14:25.820" LastActivityDate="2016-05-21T23:14:25.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24460" PostTypeId="2" ParentId="24438" CreationDate="2016-05-21T20:55:59.790" Score="0" Body="&lt;p&gt;A safer approach is to optically link the Arduino to an &lt;a href=&quot;http://www.lutron.com/en-US/Products/Pages/StandAloneControls/Dimmers-Switches/MaestroIRDimmer/Overview.aspx&quot; rel=&quot;nofollow&quot;&gt;IR remote control light switch&lt;/a&gt;.  Such an approach is discussed in &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=155114.0&quot; rel=&quot;nofollow&quot;&gt;this thread&lt;/a&gt;. The technical specifications appear to be &lt;a href=&quot;http://www.lutron.com/TechnicalDocumentLibrary/048158.doc&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for the Lutron light switch remote controls.  From this document one could construct an &lt;a href=&quot;https://learn.adafruit.com/using-an-infrared-library/sending-ir-codes&quot; rel=&quot;nofollow&quot;&gt;Arduino IR transmitter&lt;/a&gt; to send out these code.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-21T20:55:59.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24461" PostTypeId="1" CreationDate="2016-05-21T21:24:58.740" Score="1" ViewCount="1115" Body="&lt;p&gt;I have a 20x20 matrix of neopixel LED's. I have a certain set of LED's on in different places at different times. Each one is set to &lt;code&gt;mainColor&lt;/code&gt;. Right now &lt;code&gt;mainColor&lt;/code&gt; is just set to &lt;code&gt;strip.Color(r, g, b)&lt;/code&gt; but I would like to have those color fade through the spectrum. I decided the easiest way would just be to do something like &lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips/example-code&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, and simply &lt;code&gt;return strip.Color(r, g, b)&lt;/code&gt; to &lt;code&gt;mainColor&lt;/code&gt;, then calling it to turn change the colors like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strip.setPixelColor(pixelNumber, mainColor(5));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code for &lt;code&gt;mainColor&lt;/code&gt;:&#xA;    int r;&#xA;    int g;&#xA;    int b = 255;&#xA;    int _r;&#xA;    int _g;&#xA;    int _b = 255;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Color (int FADESPEED)&#xA;{&#xA;    // fade from blue to violet&#xA;    for (_r = 0; _r &amp;lt; 256; _r++) {&#xA;        r = _r;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;    // fade from violet to red&#xA;    for (_b = 255; _b &amp;gt; 0; _b--) {&#xA;        b = _b;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;    // fade from red to yellow&#xA;    for (_g = 0; _g &amp;lt; 256; _g++) {&#xA;        g = _g;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;    // fade from yellow to green&#xA;    for (_r = 255; _r &amp;gt; 0; _r--) {&#xA;        r = _r;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;    // fade from green to teal&#xA;    for (_b = 0; _b &amp;lt; 256; _b++) {&#xA;        b = _b;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;    // fade from teal to blue&#xA;    for (_g = 255; _g &amp;gt; 0; _g--) {&#xA;        g = _g;&#xA;&#xA;        mainColor = strip.Color(r, g, b);&#xA;        Clock ();&#xA;&#xA;        delay(FADESPEED);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was good but it would only return &lt;code&gt;r, g, b&lt;/code&gt; as it was on the last iteration of the last for loop, which obviously isn't what I want. But when I un-comment the &lt;code&gt;Serial.print's&lt;/code&gt; the values were perfect. So then I put &lt;code&gt;return strip.Color(r, g, b)&lt;/code&gt; into each for loop, however this only returns the first iteration of the first loop, which is also not what I want. Does anyone know how in the world I can &lt;code&gt;return strip.Color(r, g, b)&lt;/code&gt; for every iteration of every for loop? Or if not, any alternatives that would work in this situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, Matthew&lt;/p&gt;&#xA;" OwnerUserId="18429" LastEditorUserId="18429" LastEditDate="2016-05-22T19:34:54.580" LastActivityDate="2016-10-19T21:41:33.693" Title="Problems With Fading Through Neopixel Colors" Tags="|led|rgb-led|neopixel|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24463" PostTypeId="2" ParentId="24461" CreationDate="2016-05-21T21:59:35.710" Score="1" Body="&lt;p&gt;There appears to be a number of problems with this code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The variables only have scope with in this function and are not static.  So they will not survive from call to call.  Every time you call this function it will be like starting over.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting returns in the middle of code is not good coding practice.  It is very difficult to follow and hard to debug.  It would be best to arrange your code so that there is only 1 return at the end of the function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code (from Adafruit) only controls 1 RGB LED.  If you are to control 40 RGB LEDs all at different stages of color changing you would need 40 copies of this function.  This is not very efficient. Instead use this function to populate one lookup table with R G B data.  Then track 40 variables, one for each RGB LED.  Use the 40 variables to lookup a specific color combination in the lookup table for each of the 40 RGB LEDs.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-21T21:59:35.710" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="24465" PostTypeId="2" ParentId="24458" CreationDate="2016-05-21T23:20:50.413" Score="1" Body="&lt;p&gt;You cannot have more than 32767 elements in one array. The reason is explained nicely by Majenko.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution for your problem is very simple, because you need only 41400 elements:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyArray&#xA;{&#xA;  static char array1[30000] = {...};&#xA;  static char array2[11400] = {...}; // rest&#xA;&#xA;  public:&#xA;    char get(long index)&#xA;    {&#xA;      return index &amp;gt; 30000 ? array2[index - 30000] : array1[index];&#xA;    }&#xA;&#xA;    char operator[] (long index)&#xA;    {&#xA;      return get(index);&#xA;    }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you can use two arrays and depending of the index choose which one to use. I think it is faster than using array of ints, because you need to have division (by two, so it can be only shift right by one) and than again shifting to get the char. Also it is easier to use because for ints you need first to pack values (two values in one int).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is just example code, fit it to your needs.&lt;/p&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-05-21T23:24:25.463" LastActivityDate="2016-05-21T23:24:25.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24467" PostTypeId="1" CreationDate="2016-05-21T23:43:36.903" Score="-1" ViewCount="196" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;There's Latest Update!&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;So i'm working on a counter just for fun. How it works is when you press BUTTON1 the LED Lights up red, the buzzer beeps and the variable &amp;quot;counter&amp;quot; adds one to itself; After counting, you can press BUTTON2 then it will first show a transition animation then blink&amp;amp;beep while taking away the value of &amp;quot;counter&amp;quot;. After the value of &amp;quot;counter&amp;quot; is less than 1, everything will start from the beginning.&lt;/p&gt;&#xA;&lt;p&gt;But what actually happens is after the transition animation played, the LED and the buzzer just won't do any thing. I'm sure my physical connection is all correct, and the buttons are also pulled to ground with a resistor&amp;amp; a 100nf cap to prevent accidental pressing and vibration.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Note that I'm using a common anode RGB LED, so the anode pin is always HIGH but to light up individual colors i'll have to pull the cathode pins LOW (remember how electrons flow?)&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;@Tom Carpenter's latest answer still didn't solve the problem. I found the &amp;quot;else&amp;quot; function inside the &amp;quot;if&amp;quot; didn't work at all. So if i put the counter code inside the &amp;quot;else&amp;quot; function, the result would be none. But if i put the counter code in the &amp;quot;if&amp;quot; inside the primary &amp;quot;if&amp;quot;, it would, again, count at clock speed, which results blinking forever!&#xA;&lt;strong&gt;So is there anyway for the code to only count once per press&amp;amp;release cycle without losing?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;em&gt;The latest code:&lt;/em&gt;&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;pre&gt;&lt;code&gt;#define RLED 10&#xA;#define GLED 11&#xA;#define BLED 12&#xA;&#xA;#define B1 4&#xA;#define B2 5&#xA;&#xA;#define BZZ 3&#xA;&#xA;boolean OB1V;&#xA;&#xA;int counter;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(RLED, OUTPUT);&#xA;  pinMode(GLED, OUTPUT);&#xA;  pinMode(BLED, OUTPUT);&#xA;&#xA;  pinMode(B1, INPUT);&#xA;  pinMode(B2, INPUT);&#xA;&#xA;  pinMode(BZZ, OUTPUT);&#xA;&#xA;  OB1V = digitalRead(B1);&#xA;  &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  digitalWrite(RLED, HIGH);&#xA;  digitalWrite(GLED, HIGH);&#xA;  digitalWrite(BLED, HIGH);&#xA;&#xA;  boolean NB1V = digitalRead(B1);&#xA;&#xA;  if (NB1V != OB1V)&#xA;    {&#xA;      digitalWrite(RLED, LOW);&#xA;      digitalWrite(BZZ, HIGH);&#xA;      counter = 0;&#xA;    }&#xA;  else&#xA;    {&#xA;      digitalWrite(RLED, HIGH);&#xA;      digitalWrite(BZZ, LOW);&#xA;      counter = counter +1;&#xA;    }&#xA;    &#xA;  if ( digitalRead(B2) == HIGH )&#xA;    {&#xA;      digitalWrite(GLED, LOW);&#xA;      delay(300);&#xA;      digitalWrite(GLED, HIGH);&#xA;      digitalWrite(RLED, LOW);&#xA;      delay(300);&#xA;      digitalWrite(RLED, HIGH);&#xA;      digitalWrite(GLED, LOW);&#xA;      delay(300);&#xA;      digitalWrite(GLED, HIGH);&#xA;      digitalWrite(BLED, LOW);&#xA;      delay(100);&#xA;      digitalWrite(BLED, HIGH);&#xA;      delay(300);&#xA;&#xA;      for ( counter; counter &amp;gt;= 1; counter -- )&#xA;        {&#xA;          digitalWrite(GLED, LOW);&#xA;          digitalWrite(BZZ, HIGH);&#xA;          delay(200);&#xA;          digitalWrite(GLED, HIGH);&#xA;          digitalWrite(BZZ, LOW);&#xA;          delay(200);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;" OwnerUserId="21294" OwnerDisplayName="user56336" LastEditorUserId="21294" LastEditDate="2021-07-18T00:45:55.277" LastActivityDate="2021-07-18T00:45:55.277" Title="My Arduino Code isn't workig... and i just couldn't see any problems... thoughts?" Tags="|programming|sketch|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="24468" PostTypeId="2" ParentId="24467" CreationDate="2016-05-22T03:31:00.853" Score="1" Body="&lt;p&gt;There are a number of problems with your code.  Your code does not deal with releasing the button.  Once you press B1 (assuming pressing B1 causes the input to go high) the counter (if correctly implemented (that is, it should be counter++)) would count up to 32K then start over at zero and count up again. Only stopping when you release B1.  The value of counter could be any number between 0 and 32K.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working with buttons is difficult.   And the 100nF capacitor will do little to help.  It would be better if you learned how to debounce buttons and treat both the press and the release with equal importance.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an Arduino library called &lt;a href=&quot;http://playground.arduino.cc/Code/Bounce&quot; rel=&quot;nofollow&quot;&gt;Bounce&lt;/a&gt; that will do some of this for you.  It will not help with your logical errors.  You still need to treat pressing and releasing the button with equal importance.  But it will help debounce button presses so your results will more closely match your expectation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your altered code will still not work.  You need to keep track of the state of the button in order to increment the counter by one for each button press.  You can call it edge detection code or state machine code.   But the code needs history to decide what to do next.  &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/StateChangeDetection&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is an example of code which does this. &lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-22T16:39:50.433" LastActivityDate="2016-05-22T16:39:50.433" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24470" PostTypeId="1" CreationDate="2016-05-22T07:27:49.607" Score="1" ViewCount="881" Body="&lt;p&gt;I receive byte data from a RS-232 device with &lt;code&gt;Serial.read();&lt;/code&gt;. Now I need to slice this down in bit-pieces:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;value1: 15bits&lt;/li&gt;&#xA;&lt;li&gt;value2: 7bits&lt;/li&gt;&#xA;&lt;li&gt;value3: 9bits&lt;/li&gt;&#xA;&lt;li&gt;value4: 12bits&lt;/li&gt;&#xA;&lt;li&gt;and so on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Data from the stream (switch them around for better understanding):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Byte 1: 00101100 =&gt; 00110100 (least significant byte first)&lt;/li&gt;&#xA;&lt;li&gt;Byte 2: 10011011 =&gt; 11011001&lt;/li&gt;&#xA;&lt;li&gt;Byte 3: 00110011 =&gt; 11001100&lt;/li&gt;&#xA;&lt;li&gt;Byte 4: 11101000 =&gt; 00010111&lt;/li&gt;&#xA;&lt;li&gt;Byte 5: 01001100 =&gt; 00110010&lt;/li&gt;&#xA;&lt;li&gt;Byte 6: 01100111 =&gt; 11100110&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now the least significant is first.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;value1: &lt;code&gt;00110100.1101100[1]&lt;/code&gt; =&gt; 6956&lt;br&gt;&#xA;Need to cut of the last bit of the second byte&lt;/li&gt;&#xA;&lt;li&gt;value2: &lt;code&gt;1.110011[00]&lt;/code&gt; =&gt; 103&lt;br&gt;&#xA;Add the last bit of the second byte and cut off the last two bits of the third byte&lt;/li&gt;&#xA;&lt;li&gt;value3: &lt;code&gt;00.0001011[1]&lt;/code&gt; =&gt; 416&lt;br&gt;&#xA;Add the last two bits of the third byte and cut off the last bit of the fourth byte&lt;/li&gt;&#xA;&lt;li&gt;value4: &lt;code&gt;1.00110010.111[00110]&lt;/code&gt; =&gt; 3737&lt;br&gt;&#xA;Add the last bit of the fourth byte and cut off the last 5 bits of the fifth byte&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now the question: How do I realize this from programming side. I'm lost.&lt;/p&gt;&#xA;" OwnerUserId="11150" LastEditorUserId="972" LastEditDate="2017-10-25T14:03:07.620" LastActivityDate="2017-10-25T14:03:07.620" Title="Slice byte-stream into bit pieces" Tags="|programming|rs232|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24473" PostTypeId="1" CreationDate="2016-05-22T10:27:21.460" Score="1" ViewCount="2981" Body="&lt;p&gt;I want to use Arduino as my RC receiver. I will generate PPM signal from Arduino. Then I will send generated signal to my OpenPilot CC3D. I fetched following image from OpenPilot GCS. The diagram shows to use input 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TF0a8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TF0a8.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Following is the image of my CC3D. The cable colors does not correspond to each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Rre43.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Rre43.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which input cable should I connect to Arduino?&#xA;How should I connect black(ground) and red(5V) cables to Arduino:&lt;/p&gt;&#xA;" OwnerUserId="12089" LastActivityDate="2016-10-22T00:48:19.710" Title="How to use Arduino as RC Receiver" Tags="|drone|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24474" PostTypeId="2" ParentId="4739" CreationDate="2016-05-22T10:32:47.533" Score="1" Body="&lt;p&gt;Have you burned a bootloader?&#xA;The standard Arduino IDE upload requires that you have a bootloader on the chip.&#xA;You can burn a bootloader with the Arduino IDE and your AVR dragon&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-05-22T10:32:47.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24475" PostTypeId="2" ParentId="24473" CreationDate="2016-05-22T10:52:44.257" Score="2" Body="&lt;p&gt;EDIT this answer explains how you can put a Arduino between a (1 ppm pin per channel) RC receiver and a RC receptor. This allows for smart features (like autonomous control with RC overrule, or sensor based corrections,..)&#xA;It seems it is not the question of op.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is easy but there are some pitfalls.&#xA;I can make a long story short by these links&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with.html&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_20.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_20.html&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;http://rcarduino.blogspot.com/2012/04/how-to-read-multiple-rc-channels-draft.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.com/2012/04/how-to-read-multiple-rc-channels-draft.html&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you are serious about RC this may be of your interest to&lt;br&gt;&#xA;&lt;a href=&quot;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_25.html&quot; rel=&quot;nofollow&quot;&gt;http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_25.html&lt;/a&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also converted this info in a library you can find here:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/jantje/ArduinoLibraries/tree/master/RCLib&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jantje/ArduinoLibraries/tree/master/RCLib&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for stackexchange policy here the hightlights.&lt;br&gt;&#xA;If I look at the picture you added you have a 6 channel ppm receiver. Each ppm channel you want to read must be connected to a interrupt enabled pin of your arduino (The drawbacks of software enabled interrupt pin is another discussion).&lt;br&gt;&#xA;The high time of the ppm tells how high or low your lever is on the remote control.&lt;br&gt;&#xA;You can then have arduino do with this info what you want. For instance use the servo library to generate a ppm signal out to servo's and ppm driven motors.  &lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-05-24T14:11:05.787" LastActivityDate="2016-05-24T14:11:05.787" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24476" PostTypeId="2" ParentId="24437" CreationDate="2016-05-22T12:55:20.003" Score="1" Body="&lt;p&gt;Thank you for the feedback! &#xA;This is my attempt at calculating speed using the averaging method.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long volatile encodercount;&#xA;unsigned long encodercount_previous;&#xA;unsigned long volatile timer;&#xA;unsigned int angle;&#xA;boolean first;&#xA;boolean firstencodertick;&#xA;void setup() {&#xA;      angle=3;&#xA;      encodercount=0;&#xA;      encodercount_previous=0;&#xA;      Serial.begin(9600);&#xA;      while (!Serial); &#xA;      pinMode(21,INPUT);  //Pin#21=interrupt pin, matched to interrupt#2&#xA;      attachInterrupt(digitalPinToInterrupt(2),speed,FALLING);&#xA;      first=true;&#xA;      firstecnodertick=true;&#xA;        }&#xA;&#xA;  void loop() {&#xA;     delay(100); &#xA;&#xA;   if(encodercount==encodercount_previous&amp;amp;&amp;amp;encodercount!=0)&#xA;    {&#xA;   if(first)&#xA;     {&#xA;   Serial.println(millis()-timer);  //Steady State Time Taken &#xA;   first=false;&#xA;     }&#xA;  Serial.println((encodercount); //Angle Moved in 0.1second.  &#xA;    }&#xA;  encodercount_previous=encodercount;&#xA;  encodercount=0;   &#xA;   }&#xA;&#xA;&#xA;  void speed(void)&#xA; {&#xA; if(firstencodertick)&#xA; {&#xA; timer=millis();&#xA; firstencodertick=false;&#xA;  }&#xA; encodercount++; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21301" LastActivityDate="2016-05-22T12:55:20.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24477" PostTypeId="1" AcceptedAnswerId="24479" CreationDate="2016-05-22T13:11:22.027" Score="0" ViewCount="149" Body="&lt;p&gt;I have a program (bash script) I wrote that is for stop motion animation. The script works perfectly, when I use any given keyboard on my laptop, and it works on other computers, as well.  So i wanted to add a controller, using a teensy, and the keyboard library. &lt;a href=&quot;https://ghostbin.com/paste/pwzwm&quot; rel=&quot;nofollow&quot;&gt;source here:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The teensy, set up as a keyboard, using one of the example codes, which I modified. The output appears correct: when I press any of the buttons, I get the expected output (asdw). But, the script throws an error, and exits anyhow, which means something else is being sent besides the key presses I desire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, WHY?&#xA;Here is the keyboard source for the teensy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; /* Buttons to USB Keyboard Example&#xA;&#xA;   You must select Keyboard from the &quot;Tools &amp;gt; USB Type&quot; menu&#xA;&#xA;   This example code is in the public domain.&#xA;*/&#xA;&#xA;#include &amp;lt;Bounce.h&amp;gt;&#xA;&#xA;// Create Bounce objects for each button.  The Bounce object&#xA;// automatically deals with contact chatter or &quot;bounce&quot;, and&#xA;// it makes detecting changes very simple.&#xA;Bounce button0 = Bounce(0, 10);&#xA;Bounce button1 = Bounce(1, 10);  // 10 = 10 ms debounce time&#xA;Bounce button2 = Bounce(2, 10);  // which is appropriate for&#xA;Bounce button3 = Bounce(3, 10);  // most mechanical pushbuttons&#xA;Bounce button4 = Bounce(4, 10);&#xA;Bounce button5 = Bounce(5, 10);  // if a button is too &quot;sensitive&quot;&#xA;Bounce button6 = Bounce(6, 10);  // to rapid touch, you can&#xA;Bounce button7 = Bounce(7, 10);  // increase this time.&#xA;Bounce button8 = Bounce(8, 10);&#xA;Bounce button9 = Bounce(9, 10);&#xA;&#xA;void setup() {&#xA;  pinMode(0, INPUT_PULLUP);&#xA;  pinMode(1, INPUT_PULLUP);&#xA;  pinMode(2, INPUT_PULLUP);&#xA;  pinMode(3, INPUT_PULLUP);&#xA;  pinMode(4, INPUT_PULLUP);&#xA;  pinMode(5, INPUT_PULLUP);&#xA;  pinMode(6, INPUT_PULLUP);  // Teensy++ LED, may need 1k resistor pullup&#xA;  pinMode(7, INPUT_PULLUP);&#xA;  pinMode(8, INPUT_PULLUP);&#xA;  pinMode(9, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;  // Update all the buttons.  There should not be any long&#xA;  // delays in loop(), so this runs repetitively at a rate&#xA;  // faster than the buttons could be pressed and released.&#xA;  button0.update();&#xA;  button1.update();&#xA;  button2.update();&#xA;  button3.update();&#xA;  button4.update();&#xA;  button5.update();&#xA;  button6.update();&#xA;  button7.update();&#xA;  button8.update();&#xA;  button9.update();&#xA;&#xA;  // Check each button for &quot;falling&quot; edge.&#xA;  // Type a message on the Keyboard when each button presses&#xA;  // Update the Joystick buttons only upon changes.&#xA;  // falling = high (not pressed - voltage from pullup resistor)&#xA;  //           to low (pressed - button connects pin to ground)&#xA;  if (button0.fallingEdge()) {&#xA;    Keyboard.println(&quot;s&quot;);&#xA;  }&#xA;  if (button1.fallingEdge()) {&#xA;    Keyboard.println(&quot;d&quot;);&#xA;  }&#xA;  if (button2.fallingEdge()) {&#xA;    Keyboard.println(&quot;w&quot;);&#xA;  }&#xA;  if (button3.fallingEdge()) {&#xA;    Keyboard.println(&quot;a&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What should I do to just get the key presses (asdw) from the teensy as if it were a plain old keyboard. &lt;/p&gt;&#xA;" OwnerUserId="4527" LastActivityDate="2016-05-22T13:31:10.267" Title="teensy as a keybooard throws error as keyboard input" Tags="|arduino-ide|teensy|keyboard|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24478" PostTypeId="2" ParentId="24477" CreationDate="2016-05-22T13:19:43.440" Score="0" Body="&lt;p&gt;Ok I figured it out. The code includes &quot;keyboard.println&quot;. I should use &quot;keyboard.print instead&quot;, to properly simulate keyboard presses. the newline is what was screwing it up. &lt;/p&gt;&#xA;" OwnerUserId="4527" LastActivityDate="2016-05-22T13:19:43.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24479" PostTypeId="2" ParentId="24477" CreationDate="2016-05-22T13:31:10.267" Score="1" Body="&lt;p&gt;You are calling Keyboard.println() which sends the character string followed by a new line.  If you want to emulate a keyboard you should only use Keyboard.print() which only sends the character string with no new line.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-22T13:31:10.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24480" PostTypeId="2" ParentId="24467" CreationDate="2016-05-22T15:22:36.453" Score="1" Body="&lt;p&gt;Your problems come down to the fact that in the first code you are trying to do things on level sensitivity rather than edge sensitivity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To try and understand the difference, some examples. Level sensitivity is effectively:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do 'x' &lt;strong&gt;while&lt;/strong&gt; 'y'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, if 'y' is true (for example an input is high), then keep doing 'x' (e.g. adding to a counter). This is what your code is doing at the moment, but not what you want it to be doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edge sensitivity on the other hand is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do 'x' &lt;strong&gt;when&lt;/strong&gt; 'y changed'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, when the state of 'y' changes (for example from true to false), then doing 'x' once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key difference between the two is the difference between 'while' and 'when'.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;So how do you do edge sensitivity in code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you have done it requires that the button be high and then low at exactly the right moment for the code to catch it. What happens if the button goes low at the end of the loop? Your code will miss the edge because at the start of the next loop it is not high, so doesn't get in to the first if statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lets think about what 'changes' means. It means when the current value is different from the previous value. That implies that we need to keep track of what the previous value is in order to compare it to the current value. In fact that is exactly what we do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean oldButtonValue; //It would be better to use a static variable in loop, but for simplicity of the example lets use a global.&#xA;&#xA;void setup() {&#xA;    oldButtonValue = digitalRead(buttonPin); //This line is executed once to initialise the variable.&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    //Each loop we read our current value&#xA;    boolean newButtonValue = digitalRead(buttonPin);&#xA;&#xA;    //Has it changed?&#xA;    if (newButtonValue != oldButtonValue) {&#xA;&#xA;        //Do something on edge.&#xA;&#xA;    }&#xA;&#xA;    //Update the old button value to match the new one (so we can check it again next loop&#xA;    oldButtonValue = newButtonValue;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What this does is each loop it compares the current state of the button with the state of it from the previous loop. If the value changes, it does something.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Now the trouble with that code is it executes on &lt;em&gt;any&lt;/em&gt; edge. That means that each time you press the button, it will run twice, once on press and again on release. So lets modify it slightly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    ...&#xA;&#xA;    //Has it changed?&#xA;    if (newButtonValue != oldButtonValue) {&#xA;&#xA;        //Was it a rising edge?&#xA;        if (newButtonValue) {&#xA;            //If the button value is now high, it must have been a rising edge&#xA;        } else {&#xA;            //Otherwise it was a falling edge&#xA;&#xA;        }&#xA;    }&#xA;&#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The extra comparison allows us to determine whether it was a rising edge or a falling edge. So you can now do something either when the button is pressed, or when it is released (or both if you want).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can have a second boolean variable to keep track of the old state for the second button. Then you use the same approach to do edge sensitivity detection approach for the second button.&lt;/p&gt;&#xA;" OwnerUserId="6860" LastActivityDate="2016-05-22T15:22:36.453" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24481" PostTypeId="2" ParentId="24265" CreationDate="2016-05-22T16:53:18.387" Score="1" Body="&lt;p&gt;The problem was solved by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;making a clean install of Arduino IDE 1.6.9&lt;/li&gt;&#xA;&lt;li&gt;uploading the LinkIt SDK on board manager from version 1.1.17 to 1.1.23.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then the Serial function returned back to normal.&lt;/p&gt;&#xA;" OwnerUserId="21117" LastActivityDate="2016-05-22T16:53:18.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24483" PostTypeId="1" CreationDate="2016-05-22T23:25:57.520" Score="0" ViewCount="1064" Body="&lt;p&gt;I'm having a bit of an odd problem here. I'm programming a self-built quadcopter using an Arduino Uno for control. One of the sensor's that I'm using is &lt;a href=&quot;https://www.adafruit.com/products/746&quot; rel=&quot;nofollow&quot;&gt;Adafruit's GPS breakout&lt;/a&gt;. The motors are controlled with electronic speed controllers (ESCs) that controlled identically to normal servo motors. Everything is connected together with &lt;a href=&quot;https://123d.circuits.io/circuits/1150668-quadcopter-electronics-shield-v2&quot; rel=&quot;nofollow&quot;&gt;a custom Arduino shield&lt;/a&gt;. The GPS is using SoftwareSerial on pins 3 and 4, and the ESCs are connected on pins 5-8. Most of the GPS code is directly copied from &lt;a href=&quot;https://github.com/adafruit/Adafruit_GPS/blob/master/examples/echo/echo.pde&quot; rel=&quot;nofollow&quot;&gt;Adafruit's documentation&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I've found is that even when the throttle is held steady (at any power level), the motors experience quick bursts of power far beyond normal whenever there is communication between the GPS module and the Arduino. For example, the GPS updates on 1Hz intervals and so the motors get a burst of speed about every second. Has anyone else experienced something like this or could someone at least point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an abbreviated version of the code that I'm currently using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GPS.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;Servo ESC1;&#xA;Servo ESC2;&#xA;Servo ESC3;&#xA;Servo ESC4;&#xA;const int maxThrottle = 2000;&#xA;const int minThrottle = 1000;&#xA;&#xA;SoftwareSerial softwareSerial(4, 3);&#xA;Adafruit_GPS GPS(&amp;amp;softwareSerial);&#xA;// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console&#xA;// Set to 'true' if you want to debug and listen to the raw GPS sentences. &#xA;#define GPSECHO false&#xA;bool usingInterrupt = false;&#xA;uint32_t timer = millis();&#xA;&#xA;void setup() {&#xA;    ESC1.attach(5);&#xA;    ESC2.attach(8);&#xA;    ESC3.attach(6);&#xA;    ESC4.attach(7);&#xA;    setThrottleAll(minThrottle);&#xA;&#xA;    GPS.begin(9600);&#xA;    GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);&#xA;    GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);&#xA;    GPS.sendCommand(PGCMD_ANTENNA);&#xA;    useInterrupt(true);&#xA;}&#xA;int throttleCommand = 20;&#xA;void loop() {&#xA;    // Map throttle command percentage to raw throttle values that are sent to the ESCs&#xA;    int throttle = map(throttleCommand, 0, 100, minThrottle, maxThrottle);&#xA;    setThrottle(1, throttle);&#xA;    setThrottle(2, throttle);&#xA;    setThrottle(3, throttle);&#xA;    setThrottle(4, throttle);&#xA;}&#xA;&#xA;// GPS interrupt&#xA;SIGNAL(TIMER0_COMPA_vect) {&#xA;    char c = GPS.read();&#xA;    // if you want to debug, this is a good time to do it!&#xA;    #ifdef UDR0&#xA;        if (GPSECHO)&#xA;            if (c) UDR0 = c;&#xA;                // writing direct to UDR0 is much much faster than Serial.print &#xA;                // but only one character can be written at a time. &#xA;    #endif&#xA;}&#xA;void useInterrupt(boolean v) {&#xA;    if (v) {&#xA;        // Timer0 is already used for millis() - we'll just interrupt somewhere&#xA;        // in the middle and call the &quot;Compare A&quot; function above&#xA;        OCR0A = 0xAF;&#xA;        TIMSK0 |= _BV(OCIE0A);&#xA;        usingInterrupt = true;&#xA;    }&#xA;    else {&#xA;        // do not call the interrupt function COMPA anymore&#xA;        TIMSK0 &amp;amp;= ~_BV(OCIE0A);&#xA;        usingInterrupt = false;&#xA;    }&#xA;}&#xA;&#xA;void setThrottleAll(int throttle) {&#xA;    setThrottle(1, throttle);&#xA;    setThrottle(2, throttle);&#xA;    setThrottle(3, throttle);&#xA;    setThrottle(4, throttle);&#xA;}&#xA;void setThrottle(int index, int throttle) {&#xA;    if (index == 1)&#xA;        ESC1.writeMicroseconds(throttle);&#xA;    if (index == 2)&#xA;        ESC2.writeMicroseconds(throttle);&#xA;    if (index == 3)&#xA;        ESC3.writeMicroseconds(throttle);&#xA;    if (index == 4)&#xA;        ESC4.writeMicroseconds(throttle);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21311" LastEditorUserId="21311" LastEditDate="2016-05-23T00:36:10.707" LastActivityDate="2016-05-23T19:44:03.097" Title="Adafruit GPS module with SoftwareSerial affecting servo signals" Tags="|servo|gps|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24486" PostTypeId="1" CreationDate="2016-05-23T03:36:16.743" Score="0" ViewCount="1310" Body="&lt;p&gt;I am new to arduino and have a basic question. I want to build a sprinkler controller system for my lawn which would detect moisture in the lawn soil and automatically starts the sprinkler controller to water the lawn when moisture in the lawn soil reaches a certain level. I am looking for soil moisture sensors that would be installed in the lawn soil and wirelessly transmit the moisture level to my arduino in the house. Any ideas where I can find these sensors?&lt;/p&gt;&#xA;" OwnerUserId="18724" LastActivityDate="2016-05-23T10:34:22.897" Title="Looking for a wireless soil moisture sensor" Tags="|sensors|bluetooth|wifi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24489" PostTypeId="1" AcceptedAnswerId="24490" CreationDate="2016-05-23T06:03:53.587" Score="0" ViewCount="643" Body="&lt;p&gt;In the &lt;a href=&quot;http://playground.arduino.cc/Main/TimerPWMCheatsheet&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt;, it shows that the higher  frequency that can be reached with an Arduino UNO for and 8bits PWM is using timer0  with the pre-scaler  set at 1. That  gives a Fs of 62500 Hz, but why is that so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the Prescaler is dividing the frequency, but why it does start at 62500 Hz and  timer1 and timer2 have as maximum 31372 Hz. &lt;/p&gt;&#xA;" OwnerUserId="18574" LastActivityDate="2016-05-23T07:47:09.843" Title="Why is timer0 the fastest timer in the arduino?" Tags="|pwm|timers|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24490" PostTypeId="2" ParentId="24489" CreationDate="2016-05-23T07:39:06.100" Score="3" Body="&lt;p&gt;Timers 1 and 2 are configured by the Arduino core library to run the so&#xA;called “&lt;em&gt;phase correct PWM&lt;/em&gt;” mode. In this mode, the timers count&#xA;forward from 0 to 255, and then they count backwards to zero. Timer 0 is&#xA;configured by the same library in “&lt;em&gt;fast PWM&lt;/em&gt;” mode, where it counts&#xA;from 0 to 255 and then overflows back to zero in a single timer cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can, if you want, configure timers 1 and 2 in fast PWM mode. For&#xA;doing this, you will have to access their I/O registers directly. C.f.&#xA;the datasheet of the relevant microcontroller for details.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A couple of links:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet of the&#xA;ATmega328P&lt;/a&gt;&#xA;microcontroller describes all the possible configurations of the&#xA;timers (sections 15, 16 and 18 for timer 0, 1 and 2, respectively)&lt;/li&gt;&#xA;&lt;li&gt;the source code of the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring.c#L284&quot; rel=&quot;nofollow&quot;&gt;Arduino init()&#xA;function&lt;/a&gt;&#xA;to see how Arduino core configures them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-05-23T07:47:09.843" LastActivityDate="2016-05-23T07:47:09.843" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24492" PostTypeId="1" CreationDate="2016-05-22T07:29:34.383" Score="0" ViewCount="9472" Body="&lt;p&gt;I would like to ask how to connect my phone's camera to an Arduino, just like it is done in this &lt;a href=&quot;https://www.youtube.com/watch?v=vkvkfcqEUkk&quot; rel=&quot;nofollow noreferrer&quot;&gt;this video&lt;/a&gt;. Is anyone familiar with &lt;a href=&quot;https://www.youtube.com/watch?v=xan3j-TiNsw&quot; rel=&quot;nofollow noreferrer&quot;&gt;this application&lt;/a&gt; they are using?&lt;/p&gt;&#xA;" OwnerDisplayName="Kevin Gast" LastEditorUserId="27346" LastEditDate="2018-11-13T10:29:16.250" LastActivityDate="2018-11-13T10:29:16.250" Title="How to connect a phone's camera to an Arduino?" Tags="|camera|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24493" PostTypeId="2" ParentId="24486" CreationDate="2016-05-23T10:34:22.897" Score="2" Body="&lt;p&gt;The project is very much possible but it will be easier if you attach the moisture sensor directly to the arduino and add a wifi shield or a bluetooth shield to the arduino itself and make it communicate with computer or phone. You could also program the arduino to directly water the plants if it finds that they dont have much moisture. You will rarely find a sensor that transmits data wirelessly and still be economically feasible. The Sparkfun SEN-13322 moisture sensor is good for the purpose but again connect it to arduino direclty.&lt;/p&gt;&#xA;" OwnerUserId="10522" LastActivityDate="2016-05-23T10:34:22.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24494" PostTypeId="1" AcceptedAnswerId="24501" CreationDate="2016-05-23T10:35:49.607" Score="0" ViewCount="79" Body="&lt;p&gt;I'm using an Arduino Mega and four of its interrupts. Each interrupt is only used to start/stop a timer, depending if it's rising or falling, so effectively runs the same function. Does anyone know if theres a way to differentiate between which interrupt has been triggered? This way I can attach them all to the same ISR and just start/stop different timers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Shaun&lt;/p&gt;&#xA;" OwnerUserId="21148" LastActivityDate="2016-05-23T13:20:24.223" Title="Interrupt numbering" Tags="|programming|arduino-mega|interrupt|code-optimization|isr|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24495" PostTypeId="1" CreationDate="2016-05-23T11:35:58.923" Score="2" ViewCount="288" Body="&lt;p&gt;I am new to arduino. It is costly for me to buy an arduino uno board. Therefore I am going to make a Arduino with breadboard at my home. I also want to make my Arduino portable. Arduino Uno boards can be powered up with battery. But can I do so with my homemade Arduino? If it is possible, what things need to be included in my homemade Arduino?&lt;/p&gt;&#xA;" OwnerUserId="21325" LastEditorUserId="612" LastEditDate="2016-05-28T19:59:42.130" LastActivityDate="2018-11-14T09:05:56.873" Title="can homemade arduino be powered up with battery?" Tags="|power|avr|battery|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24496" PostTypeId="2" ParentId="24494" CreationDate="2016-05-23T12:00:01.417" Score="0" Body="&lt;p&gt;Assuming that by &quot;Mega&quot; you mean the Mega 2560, see sections 15.2.4 and 15.2.5 of the 2/2014 &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA2560.aspx?tab=documents&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; referring to the External Interrupt Flags and Pin Change Interrupt flags:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When an edge or logic change on the INT7:0 pin triggers an interrupt&#xA;  request, INTF7:0 becomes set (one). If the I-bit in SREG and the&#xA;  corresponding interrupt enable bit, INT7:0 in EIMSK, are set (one),&#xA;  the MCU will jump to the interrupt vector. The flag is cleared when&#xA;  the interrupt routine is executed. Alternatively, the flag can be&#xA;  cleared by writing a logical one to it. These flags are always cleared&#xA;  when INT7:0 are configured as level interrupt.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It is not clear from the above when specifically &quot;The flag is cleared when the interrupt routine is executed&quot; happens. It wouldn't be much use if it happened on ISR entry so I'll take a guess that it happens on return from interrupt, in which case the flags would be available to read in the ISR. An experiment would be in order, here. These flag registers are known to the compiler as EIFR and PCIFR, respectively.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-05-23T12:06:21.590" LastActivityDate="2016-05-23T12:06:21.590" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24497" PostTypeId="2" ParentId="24495" CreationDate="2016-05-23T12:28:28.150" Score="2" Body="&lt;p&gt;Yes you can power it from a battery, as long as you add a 5V regulator to your board.  You might get strange behaviour when the battery is running low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These links all tell you what you need to build the board, good luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/Standalone&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/Standalone&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/How-to-make-your-own-Arduino-board/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/How-to-make-your-own-Arduino-board/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.instructables.com/id/DIY-Arduino-or-The-DIY-Duino/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/DIY-Arduino-or-The-DIY-Duino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-05-23T12:28:28.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24500" PostTypeId="2" ParentId="24495" CreationDate="2016-05-23T12:39:16.813" Score="3" Body="&lt;p&gt;First, of course, you'll need a battery with enough capacity, and voltage enough greater than 5v (assuming you want to run your home-built at 5v - typical, but you could run it lower, say 3.3v) to give enough run-time before the battery discharges to where it can no longer supply the system. Note that the 9v, so-called &quot;Transistor battery&quot; is not capable of supplying much current. A battery pack of off-the-shelf alkaline batteries or rechargables, or a Lithium Polymer rechargable battery will do much better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need a low dropout voltage regulator to reduce the battery voltage to your chosen Arduino supply voltage. National Semiconductor's LM1117 would be a good choice. The diagram below from NS's datasheet shows a simple-to-make voltage regulator. Its input is your battery; its output will be the supply voltage to the chip and any accessory circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Apegk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Apegk.png&quot; alt=&quot;Typical fixed voltage circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-05-23T16:26:22.677" LastActivityDate="2016-05-23T16:26:22.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24501" PostTypeId="2" ParentId="24494" CreationDate="2016-05-23T13:20:24.223" Score="0" Body="&lt;p&gt;The only sure-fire way of knowing which interrupt triggered your ISR is to examine the GPIO pin that the interrupt is associated with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to use CHANGE interrupts so that you can keep track of the state of the pins - both HIGH and LOW.  When you get an interrupt and read all the GPIO pins you have tied to the ISR you can then compare their values to the previously stored values. Any pins that have changed since the last ISR (or a pre-defined initial state) can be processed and handled accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it adds a certain amount of overhead to your code, and using &lt;code&gt;digitalRead()&lt;/code&gt; may not be the most efficient way of doing it. Instead you may want to use direct port access to read the pin's state directly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-23T13:20:24.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24502" PostTypeId="1" CreationDate="2016-05-23T13:55:03.087" Score="1" ViewCount="4003" Body="&lt;p&gt;I'm trying to program an Attiny85 chip using an Arduino Uno as an ISP following this two tutorials: &lt;a href=&quot;http://www.instructables.com/id/Program-an-ATtiny-with-Arduino/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Instructables: Program an ATtiny With Arduino&lt;/a&gt; and &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow noreferrer&quot;&gt;Programming an ATtiny w/ Arduino 1.6 (or 1.0)&lt;/a&gt; but every time I try to upload the sketch I get this error message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     avrdude: Yikes!  Invalid device signature.&#xA;     Double check connections and try again, or use -F to override&#xA;     this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried different Arduino boards/changing port and different ATtiny chips but the results are all the same. I have also checked the wiring multiple times and it seems to be correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the full error message (on verbose mode):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;     Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;     System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf&quot;&#xA;&#xA;     Using Port                    : COM7&#xA;     Using Programmer              : stk500v1&#xA;     Overriding Baud Rate          : 19200&#xA;     AVR Part                      : ATtiny85&#xA;     Chip Erase delay              : 400000 us&#xA;     PAGEL                         : P00&#xA;     BS2                           : P00&#xA;     RESET disposition             : possible i/o&#xA;     RETRY pulse                   : SCK&#xA;     serial program mode           : yes&#xA;     parallel program mode         : yes&#xA;     Timeout                       : 200&#xA;     StabDelay                     : 100&#xA;     CmdexeDelay                   : 25&#xA;     SyncLoops                     : 32&#xA;     ByteDelay                     : 0&#xA;     PollIndex                     : 3&#xA;     PollValue                     : 0x53&#xA;     Memory Detail                 :&#xA;&#xA;                              Block Poll               Page                       Polled&#xA;       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack&#xA;       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------&#xA;       eeprom        65    12     4    0 no        512    4      0  4000  4500 0xff 0xff&#xA;       flash         65     6    32    0 yes      8192   64    128 30000 30000 0xff 0xff&#xA;       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00&#xA;       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00&#xA;       calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00&#xA;&#xA;     Programmer Type : STK500&#xA;     Description     : Atmel STK500 Version 1.x firmware&#xA;     Hardware Version: 2&#xA;     Firmware Version: 1.18&#xA;     Topcard         : Unknown&#xA;     Vtarget         : 0.0 V&#xA;     Varef           : 0.0 V&#xA;     Oscillator      : Off&#xA;     SCK period      : 0.1 us&#xA;&#xA;     avrdude: AVR device initialized and ready to accept instructions&#xA;&#xA;     Reading | ################################################## | 100% 0.05s&#xA;&#xA;     avrdude: Device signature = 0x000000 (retrying)&#xA;&#xA;     Reading | ################################################## | 100% 0.05s&#xA;&#xA;     avrdude: Device signature = 0x000000 (retrying)&#xA;&#xA;     Reading | ################################################## | 100% 0.05s&#xA;&#xA;     avrdude: Device signature = 0x000000&#xA;     avrdude: Yikes!  Invalid device signature.&#xA;     Double check connections and try again, or use -F to override&#xA;     this check.&#xA;&#xA;&#xA;     avrdude done.  Thank you.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21330" LastEditorUserId="6936" LastEditDate="2019-05-09T07:13:07.277" LastActivityDate="2019-06-12T02:03:25.563" Title="Problem with programming an ATtiny85: Error - avrdude: Yikes! Invalid device signature" Tags="|arduino-uno|attiny|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24503" PostTypeId="1" AcceptedAnswerId="24506" CreationDate="2016-05-23T14:02:14.993" Score="1" ViewCount="656" Body="&lt;p&gt;I am new to electronics and arduino in general. I need to split a power supply in gnd and voltage. Basically, the power supply has one single wire (with the voltage and the gnd passing through it i think), and I need them to be separated. Sorry if this is a noob question, but I am really new to this whole thing.&lt;/p&gt;&#xA;" OwnerUserId="20679" LastActivityDate="2016-05-23T14:24:09.097" Title="Split Power supply in voltage and gnd?" Tags="|arduino-uno|power|electronics|electricity|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24504" PostTypeId="2" ParentId="24495" CreationDate="2016-05-23T14:12:46.580" Score="1" Body="&lt;p&gt;I mostly use two AA batteries to power my 'standalone' ATMega328s. One of the downsides of this, is that you can't run the ATMega at 16Mhz, but only at 8Mhz. I don't mind that, as running at a slower speed reduces the current usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use 3 AA batteries, or 4 rechargeable AA batteries, instead to get a voltage that is closer to 5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get your circuit to run for more than a couple of days, you have to implement ways of reducing the current consumption. One of the first things would be to put the processor into sleep mode.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-23T14:12:46.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24506" PostTypeId="2" ParentId="24503" CreationDate="2016-05-23T14:20:36.850" Score="1" Body="&lt;p&gt;Do you have a image of this? Logically, and as far as I know, One wire will not carry both GND and Positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you talking of a DC jack kind of thing?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, I'm starting out here too!&lt;/p&gt;&#xA;" OwnerUserId="21329" LastActivityDate="2016-05-23T14:20:36.850" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24507" PostTypeId="2" ParentId="24503" CreationDate="2016-05-23T14:24:09.097" Score="1" Body="&lt;p&gt;If the cable of the power supply contains voltage and gnd, it's two cables, with a layer between them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Kcs6b.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Kcs6b.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the inside they look much like coaxial cables, so if you softly cut the outer shell(A) you maye see a mesh of blank wires(B,C,D), they're gnd in most cases.&#xA;There also is an inner wire(C) which you have to cut softly, too.&#xA;That's the voltage carrying wire(D), in most cases. (If it's approx. less than 10 Volts, check with a LED.)&lt;/p&gt;&#xA;" OwnerUserId="7309" LastActivityDate="2016-05-23T14:24:09.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24508" PostTypeId="1" CreationDate="2016-05-23T14:36:12.070" Score="2" ViewCount="2680" Body="&lt;p&gt;I'm trying to upload a simple sketch to my Uno board but get this error message: avrdude: stk500_recv(): programmer is not responding (full error message at the end).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have other Uno boards who work fine so I guess it is something to do specifically with this board (which used to work) and not my system or cables (port,drivers,settings etc..).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a loop-back test (&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=73748.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=73748.0&lt;/a&gt;) on  the board and it worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read about possible solutions but nothing seems to solve this.&#xA;&lt;a href=&quot;https://stackoverflow.com/questions/19765037/arduino-sketch-upload-issue-avrdude-stk500-recv-programmer-is-not-respondi&quot;&gt;https://stackoverflow.com/questions/19765037/arduino-sketch-upload-issue-avrdude-stk500-recv-programmer-is-not-respondi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried using an Arduino as an AVR ISP but it failed. (&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated, thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full error message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58&#xA;     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;     Copyright (c) 2007-2009 Joerg Wunsch&#xA;&#xA;     System wide configuration file is &quot;C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf&quot;&#xA;&#xA;     Using Port                    : COM3&#xA;     Using Programmer              : arduino&#xA;     Overriding Baud Rate          : 115200&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xd3&#xA;    avrdude: stk500_recv(): programmer is not responding&#xA;    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd3&#xA;&#xA;    avrdude done.  Thank you.&#xA;&#xA;    Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21330" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2023-02-01T16:08:10.897" Title="Can't upload sketch to arduino Uno board" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24510" PostTypeId="2" ParentId="24502" CreationDate="2016-05-23T14:47:18.220" Score="1" Body="&lt;p&gt;Try connecting the RESET pin of the Attiny85 to GND the second before you hit &quot;program&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my experience, the Arduino does not always send the RESET signal when it should (or on the pin that you think it would send it). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In these cases, manually resetting the Attiny by connecting the RESET pin to ground makes it programmable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can keep RESET low during the whole programming process, but if you keep it low for many minutes before programming the chip, it might not always work. In those cases, set RESET high for a moment before setting it back low, and the Attiny should be good for another round of programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course, when you want the Attiny to start doing what you have programmed it to do, you have to pull RESET high again.&lt;/p&gt;&#xA;" OwnerUserId="21015" LastEditorUserId="21015" LastEditDate="2016-05-23T14:52:29.160" LastActivityDate="2016-05-23T14:52:29.160" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24511" PostTypeId="1" CreationDate="2016-05-23T13:40:00.443" Score="0" ViewCount="168" Body="&lt;p&gt;I want to connect a Hokuyo scanning range finder to an Arduino Mega, the outputs are labeled like this: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;COM+&lt;/li&gt;&#xA;&lt;li&gt;COM-&lt;/li&gt;&#xA;&lt;li&gt;Input&lt;/li&gt;&#xA;&lt;li&gt;Output&lt;/li&gt;&#xA;&lt;li&gt;DC12/24&lt;/li&gt;&#xA;&lt;li&gt;GND&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want to read its serial output with Arduino, please help me in details.&#xA;Thanks&lt;/p&gt;&#xA;" OwnerDisplayName="yas alip" LastEditorUserId="27346" LastEditDate="2018-11-13T10:29:23.073" LastActivityDate="2023-10-24T21:02:45.320" Title="COM+ and COM- to RX and TX" Tags="|arduino-mega|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24512" PostTypeId="2" ParentId="24511" CreationDate="2016-05-23T16:11:36.243" Score="1" Body="&lt;p&gt;You should specify what model of Hokuyo scanning range finder you have.  Some models are USB-interfaced, in which case  COM+ and COM- could possibly correspond to USB D+ and D- leads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.hokuyo-aut.jp/02sensor/07scanner/urg_04lx.html&quot; rel=&quot;nofollow&quot;&gt;Hokuyo URG-04LX&lt;/a&gt; has both USB and RS-232 interfacing.  The &lt;a href=&quot;https://www.hokuyo-aut.jp/02sensor/07scanner/urg_04lx.html&quot; rel=&quot;nofollow&quot;&gt;linked page&lt;/a&gt; shows the following pinout on CN1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pin No.   Signals                                Colors&#xA;1         N.C.                                   Red&#xA;2         N.C.                                   White&#xA;3         OUTPUT(Synchronous output)             Black&#xA;4         GND(5th pin of 9-pin, D-sub connector) Purple&#xA;5         RxD(3rd pin of 9-pin, D-sub connector) Yellow&#xA;6         TxD(2nd pin of 9-pin, D-sub connector) Green&#xA;7         0V                                     Blue&#xA;8         DC5V                                   Brown&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Given that pinout, you would connect pin 5, RxD, to a TXD output on the Mega, and pin 6, TxD, to an RXD input on the Mega.  Note, before making any such connection, measure the output voltage on pin 6.  An ordinary Mega supports 0 V and 5 V levels for serial data, but standard RS-232 levels are lower and higher than that; for example, ±12 V.  If you connect  ±12 V RS-232 levels to your Mega, you will damage it.  The several Hokuyo documents I've looked at don't say whether they use traditional RS-232 levels (±12 V) or TTL levels (0-5 V).&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-23T16:17:49.123" LastActivityDate="2016-05-23T16:17:49.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24513" PostTypeId="2" ParentId="24492" CreationDate="2016-05-23T17:21:47.670" Score="0" Body="&lt;p&gt;Normally I would say that the phone is some kind of converting image to serial data and sending it to arduino via serial port. But there is no cables on the phone in the video. It is communicating wirelessly. But I don't think that vehicle is atonoumus?  The phone should be transfering image data via ethernet (wifi) and the user controls it. The reason I don't think that's an atonoumus is because you can't simply process that image stream with an arduino it would be a enormous process for arduino's little chip. They must be processing it on a computer. Either two ways the phone is talking to another processor. Not the arduino. Maybe if you tell what you want to do spesificly I might help you instead of trying to figure out this video :))  EDIT: &lt;strong&gt;&lt;em&gt;it could also be a Bluetooth connection :))&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="21297" LastEditorUserId="21297" LastEditDate="2016-05-25T21:22:16.183" LastActivityDate="2016-05-25T21:22:16.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24515" PostTypeId="1" AcceptedAnswerId="24519" CreationDate="2016-05-23T18:22:31.407" Score="0" ViewCount="577" Body="&lt;p&gt;I've got 3 OV7670 cameras and would like to create a switch that outputs one of the cameras video as standard A/V out (I'm not sure the correct naming).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found docs explaining how to use the cameras on the Arduino platform but I'm not sure how to output video signal - composite.&lt;/p&gt;&#xA;" OwnerUserId="18874" LastEditorUserId="18874" LastEditDate="2016-05-23T18:51:29.940" LastActivityDate="2017-11-21T18:00:43.743" Title="Camera switch with ov7670 to output standard A/V signal - composite" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24516" PostTypeId="2" ParentId="9030" CreationDate="2016-05-23T18:27:21.013" Score="3" Body="&lt;p&gt;It is proprietary.  It makes it hard to build your own custom length cables. But then if you are, you probably don't need Grove modules in the first place.  I would use them more if I could build a cable.  The JST PH 2.0 definitely doesn't work well, even if you shave it down.  The PH also doesn't have the locking tab that the Grove connector does. It's interesting that some of the Grove boards have both JST PH 2.0 as well as Grove connectors for different purposes (e.g. LiPo battery connector) &lt;/p&gt;&#xA;" OwnerUserId="21336" LastActivityDate="2016-05-23T18:27:21.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24518" PostTypeId="2" ParentId="24483" CreationDate="2016-05-23T19:44:03.097" Score="1" Body="&lt;p&gt;The bad news is that you are using the absolute worst libraries (SoftwareSerial and Adafruit_GPS), and your program structure is based on the awful Adafruit_GPS example.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The good news is that there are much better alternatives: &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoSWSerial&lt;/a&gt; and &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt;.  Still, there's no doubt that you are near the limits of this processor, especially with Wire and timer-based Servos.  It can be an &quot;interesting challenge&quot; or a &quot;beginner's nightmare.&quot;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; Consider using the HardwareSerial object, &lt;code&gt;Serial&lt;/code&gt;, for the GPS interface.  Your excerpt does not show what &lt;code&gt;Serial&lt;/code&gt; is currently used for, but if it's debug print statements... don't.  Instead, use a software serial port for debug statements (use a serial-to-USB adapter on those pins to connect it to your PC).  This would have a tremendous impact.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; If you &lt;em&gt;really really&lt;/em&gt; can't use &lt;code&gt;Serial&lt;/code&gt; for the GPS (are you sure???), consider using an AltSoftSerial instance on pins 8 &amp;amp; 9, as this is much better than the dreaded &lt;code&gt;SoftwareSerial&lt;/code&gt;.  Next best is NeoSWSerial on any pins, including 4&amp;amp;3 that you are using now.  There is absolutely no reason to shoot yourself in the foot with &lt;code&gt;SoftwareSerial&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3)&lt;/strong&gt; As other's have commented, use HW PWM... let the machine do the work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;4)&lt;/strong&gt; Consider using the faster and smaller NeoGPS library.  And restructure your program to look like the NeoGPS example programs, because their sequencing is much more efficient.  The Adafruit_GPS example uses a timer interrupt... to read a character from the input buffer... that was stored by a &lt;code&gt;SoftwareSerial&lt;/code&gt; interrupt... that was on for the entire character time of ~1ms.  What a phenomenal waste!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;5)&lt;/strong&gt; Use interrupt-driven GPS parsing.  All three Neo__Serial libraries (HW, IC and SW) allow NeoGPS to handle the GPS characters &lt;em&gt;during&lt;/em&gt; the rx interrupt, avoiding character loss because the port was not read in time (input buffer overflow).  And because just a little work is performed on each character, there is no big chunk of processing when a sentence is complete.  This also uses half the interrupts and saves copying the characters multiple times, in and out of the serial input buffer... into the Adafruit double-buffered sentences, where it gets searched multiple times with &lt;code&gt;strcmp&lt;/code&gt; and &lt;code&gt;strchr&lt;/code&gt;.  Ugh.  No, I meant to say UGH!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;6)&lt;/strong&gt; NeoGPS will also free up hundreds of bytes of RAM, which you may be able to trade for some more speed, elsewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's definitely a tight squeeze.  Either reallocate your pins and use better libraries, or get a bigger hammer. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :-)&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-05-23T19:44:03.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24519" PostTypeId="2" ParentId="24515" CreationDate="2016-05-23T20:03:52.923" Score="2" Body="&lt;p&gt;An arduino uno is way too slow to output composite video. If you want to generate a PAL video signal you can see &lt;a href=&quot;http://martin.hinner.info/vga/pal.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; the signal specification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most important, one line is output in 52us. If the line is 720px long (720x576 is the common resolution), then you will have to generate one pixel in 72ns. This means that&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;you will need a very fast DAC (a flash one)&lt;/li&gt;&#xA;&lt;li&gt;you will need a VERY fast microcontroller. If you have a 160MHz uC you will have to send one output byte every 11 clock cycles, which means that you will barely be able to do any more processing.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Result: it is practically unfeasable. I suggest you, if you want to use it, to look for hardware encoders. But... Probably you will need some faster processing units: maybe a raspberry PI, which already have an hardware encoder...&lt;/p&gt;&#xA;" OwnerUserId="10214" LastActivityDate="2016-05-23T20:03:52.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24520" PostTypeId="1" AcceptedAnswerId="24522" CreationDate="2016-05-23T21:24:02.330" Score="0" ViewCount="166" Body="&lt;p&gt;I am making a Soil Analysis system with an Arduino Uno, but I have run into a problem and was wondering if /r/learnprogramming could help!  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The moisture sensor section of my code will not output the data to the Serial Monitor in Arduino 1.7.1 IDE. I am not sure why it's not working. Running the moisture sensor code by itself works, and I just copied and pasted that code into my combined code file since I'll I am running 4 sensors at once with my Arduino Uno.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the four values I need to output data on one baud rate:  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pH value&lt;/li&gt;&#xA;&lt;li&gt;EC&lt;/li&gt;&#xA;&lt;li&gt;DHT temperature reading&lt;/li&gt;&#xA;&lt;li&gt;Moisture Sensor Value&lt;br&gt;&#xA;I am currently missing Moisture Sensor Value when I run Combined1.ino  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is the Combined1.ino code of the code from four sensors together that's uploaded to the Arduino: &#xA;&lt;a href=&quot;https://github.com/trooper5010/Soil-Analysis-System/blob/master/Combined1.ino&quot; rel=&quot;nofollow&quot;&gt;Combined Code Link&lt;/a&gt;&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/trooper5010/Soil-Analysis-System/blob/master/Moisture_Sensor.ino&quot; rel=&quot;nofollow&quot;&gt;Moisture Sensor Link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated!&lt;/p&gt;&#xA;" OwnerUserId="21308" LastActivityDate="2016-05-23T22:49:39.583" Title="Moisture sensor data will not output data to Serial Monitor?" Tags="|sensors|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24521" PostTypeId="2" ParentId="13912" CreationDate="2016-05-23T21:59:23.647" Score="0" Body="&lt;p&gt;I like the way someone explained Vin to me. &quot;Whatever power source you connect to the DC Jack is supplied there, be it 12v or lesser&quot;&lt;/p&gt;&#xA;" OwnerUserId="21329" LastActivityDate="2016-05-23T21:59:23.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24522" PostTypeId="2" ParentId="24520" CreationDate="2016-05-23T22:49:39.583" Score="1" Body="&lt;p&gt;Your second print section will always fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(millis() - printTime &amp;gt; printInterval)   //Every 800 milliseconds, print a numerical, convert the state of the LED indicator&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, a bit before then you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(millis()-printTime&amp;gt;=printInterval)&#xA;{&#xA;  printTime=millis();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So &lt;code&gt;millis() - printTime&lt;/code&gt; can never be greater than &lt;code&gt;printInterval&lt;/code&gt; since you have just set &lt;code&gt;printTime&lt;/code&gt; to &lt;code&gt;millis()&lt;/code&gt;. So &lt;code&gt;millis() - printTime&lt;/code&gt; will always be somewhere between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;printInterval - 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider combining your different printing routines into one single printing routine so you are comparing (and changing) the &lt;code&gt;printTime&lt;/code&gt; only once.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-23T22:49:39.583" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24523" PostTypeId="1" AcceptedAnswerId="24524" CreationDate="2016-05-23T23:04:09.957" Score="3" ViewCount="19564" Body="&lt;p&gt;I'd like to know if there is an easy way to implement communication between multiple arduinos that avoids collisions using the RS485 module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My setup would have multiple masters that send messages to only one slave that performs a task upon been given the message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried researching some libraries for this, but they normally don't fulfil the multimaster requisite, nevertheless I found &lt;a href=&quot;https://github.com/MichaelJonker/HardwareSerialRS485&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt; which apparently does implement what I need, but I haven't been able to understand how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current options are either finding an easier library that is capable of doing what I need, learning how to make the linked library work (which I have already tried) or building my own serial communication protocol that implements collision avoidance and a multiple master configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What path should I follow? Can you give me any recommendation for any of the paths I'm suggesting? Is there a better way of implementing this type of communication?&lt;/p&gt;&#xA;" OwnerUserId="21346" LastActivityDate="2018-05-05T16:10:27.510" Title="RS485 Multimaster Communication with collision avoidance" Tags="|arduino-uno|communication|rs485|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24524" PostTypeId="2" ParentId="24523" CreationDate="2016-05-23T23:23:17.457" Score="6" Body="&lt;p&gt;Collision avoidance is a tricky subject. You can never completely avoid collisions - all you can do is work out how to a) detect them, and b) recover from them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's many different ways of doing it, and how you implement it is very much dependent on what your hardware can do, and how you are actually using the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way of detecting a collision is to arrange it so that your master is always reading the bus even when it is sending. You require separate receiver and transmitter modules, so that as you place a byte on the bus you attempt to also receive that byte. If it doesn't get received, or the wrong byte gets received, then you have a collision.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is a 100% guaranteed way of detecting a collision as it happens. If you know that what you sent didn't make it onto the wire properly then it collided. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simpler scheme is to be watching the bus before you send. If there has been no sign of any traffic for more than a certain threshold time then you can assume that the bus is currently quiet. You can then try and send your data. You don't know if it got through OK though, since something else could have decided that the bus was quiet long enough for it to send too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would have to have some kind of ACK signal coming back from the other end that says the packet got received OK. Keep retrying until you get that ACK back. Of course, the ACK could be colliding as well, so it may have been received, but you just haven't been told. So your remote device would have to be able to gracefully handle receiving the same packet multiple times and discarding (yet still ACKing) the repeated packets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should do when you do detect a collision (or fail to receive an ACK) is also kind of tricky.  You have to wait and try sending again. But if there are two devices both waiting to send again, how can you be sure that they won't both be waiting for the same time, and thus collide again? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to ensure that both devices delay for a random period - and make sure that the random period truly is random. Using the default &lt;code&gt;random()&lt;/code&gt; function, unless you can seed it from a truly random source of entropy, will generate the same sequence of numbers for all the devices - so each device would get the &lt;em&gt;same&lt;/em&gt; &quot;random&quot; number. And collisions ensue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you see, you can't just throw a random library at it and say &quot;This library will stop collisions&quot; - the best you can say is &quot;This library can help reduce collisions, detect them when they do occur, and gracefully recover from them.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the library you link to it appears to attempt to implement the latter system:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;&lt;p&gt;Collision avoidance is implemented through the assignment of a message priority. A node will not start transmission before the bus has been idle for a time determined by the priority. Note that the highest priority is given to messages with the lowest priority number.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;p&gt;Collision detection is implemented by read-verified-write, i.e. all data written is checked on the fly for proper echo-back. If the software detects a frame error or a data mismatch when the echo character is received, it will disable the RS485 transmission and flag the collision status. The included transaction management will resend the message after the bus is idle again.&lt;/p&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It waits for the bus to be free of traffic for a specific amount of time (the time is variable depending on the message priority), and expects the message to be sent back again as a form of ACK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It makes no mention of random back-off times though to avoid collisions between different masters sending messages with the same priority.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-23T23:23:17.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24525" PostTypeId="1" CreationDate="2016-05-23T23:37:04.533" Score="-1" ViewCount="6279" Body="&lt;p&gt;I know this has been asked before, but no one's solutions I've seen have worked so far. I just got started with Arduino and downloaded Arduino IDE from the Software Center. When trying to to set up my Serial Port, the option in the toolbar is gray/unaccessible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also downloaded it as a tar.xz instead of from the Software Center and had the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug in my Uno, the green light turns on so I know it's being connected at least. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One solution I saw said it was a problem with my user group. However, I entered &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;sudo groups &amp;lt;username&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and came up with &lt;code&gt;&amp;lt;username&amp;gt; tty dialout sudo audio video plugdev input&#xA;&lt;/code&gt;&#xA;so I think my groups are okay, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, I would really appreciate some help if anyone knows of a fix. I run 12.04 Ubuntu (I recently re-installed trying to fix this problem; I'm going to update to 14.04) on a Chromebook. &lt;/p&gt;&#xA;" OwnerUserId="21347" LastActivityDate="2020-01-20T08:02:15.420" Title="Arduino IDE &quot;Tools &gt; Serial Port&quot; grayed out (Ubuntu)" Tags="|serial|arduino-ide|ubuntu|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24526" PostTypeId="1" CreationDate="2016-05-24T00:10:56.377" Score="1" ViewCount="14607" Body="&lt;p&gt;I've been at this all day, and I just can't seem to wrap my mind around how to use sprintf() to set a width for my string so that my characters are right justified. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is scooch my output over to the right on my touchscreen when the value is positive.&lt;br&gt;&#xA;My output string is always a predictable length, so it seems like it should be easy.&lt;br&gt;&#xA;I tried concatenating a string with just a space in it, and every other way I could think of to add a space to the beginning of my string. No luck. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char stringval[8] = 1.08;&#xA;char juststringval[8];&#xA;            if (hashpos &amp;gt; 0 &amp;amp;&amp;amp; hashpos &amp;lt; 10) { &#xA;&#xA;                sprintf(juststringval,  &quot; %5s&quot; , stringval);&#xA;                Serial.println(juststringval);&#xA;            }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.08 (no spaces in front)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In case you're curious why I need to use a string, my touchscreen will print floats, but my library won't rotate them properly.&lt;br&gt;&#xA;Only strings can be rotated the way I need them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Isn't there some simple way of doing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems I can use the width trick as long as I include some character besides an empty space.&lt;br&gt;&#xA;For example: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;char stringval[33] = &quot;1.08&quot;;&#xA;char juststringval[33];&#xA;char space[] = &quot;rr&quot;;         ////THIS WORKS: OUTPUT IS  rr      1.08&#xA;float hashpos = 1.08;&#xA;if (hashpos &amp;gt; 0 &amp;amp;&amp;amp; hashpos &amp;lt; 10) {&#xA;&#xA;    sprintf(juststringval, &quot;%s  %7s&quot;, space, stringval);&#xA;    Serial.println(juststringval);&#xA;}&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;char stringval[33] = &quot;1.08&quot;;&#xA;char juststringval[33];&#xA;char space[] = &quot; &quot;;     ////THIS DOESNT WORK. OUTPUT IS 1.08 LEFT JUSTIFIED&#xA;float hashpos = 1.08;&#xA;if (hashpos &amp;gt; 0 &amp;amp;&amp;amp; hashpos &amp;lt; 10) {&#xA;&#xA;    sprintf(juststringval, &quot;%s  %7s&quot;, space, stringval);&#xA;    Serial.println(juststringval);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I can't live with other characters in my string.&lt;br&gt;&#xA;Isn't there something I can do?&lt;/p&gt;&#xA;" OwnerUserId="19892" LastEditorUserId="11910" LastEditDate="2018-10-30T15:57:06.660" LastActivityDate="2019-08-26T23:02:15.247" Title="Using Sprintf() to left pad a string?" Tags="|string|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="24527" PostTypeId="2" ParentId="24508" CreationDate="2016-05-24T02:11:27.340" Score="0" Body="&lt;p&gt;Try the different boards in the menu.  I had that with one of my boards and then it worked fine when I used the Due in the IDE instead.  Something to do with one of the chip revisions I think.&lt;/p&gt;&#xA;" OwnerUserId="21349" LastActivityDate="2016-05-24T02:11:27.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24528" PostTypeId="1" CreationDate="2016-05-24T03:11:16.087" Score="-1" ViewCount="5469" Body="&lt;p&gt;Was searching for some help on connecting Flir camera w/ Lepton board to arduino and found this thread&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Zdc9H.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Zdc9H.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;for power you can reroute the 3-5V to the VREF pin, then you have a nice clean solution.&#xA;You have to use a Ardunio with at least 16k or ram so you can buffer the image.&lt;/em&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was that a typo and he meant AREF?  If so would the VIN from the camera be connected to the VIN on arduino otherwise?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thread:&#xA;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=266361.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://forum.arduino.cc/index.php?topic=266361.0&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21351" LastActivityDate="2017-02-13T05:35:53.313" Title="What is VREF pin?" Tags="|arduino-uno|power|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24529" PostTypeId="2" ParentId="24528" CreationDate="2016-05-24T04:07:59.780" Score="2" Body="&lt;p&gt;VREF normally means Voltage REFerence.  Such pins are usually associated with ADCs (Analog to Digital Converters).  For example a 3.3 volt microprocessor may have a VREF pin fed by 2 volts.  The 10 bit ADC inside the microprocessor sees this as the upper limit.  That is, a 2 volt input to the ADC will produce the maximum value or 2^10 or 1024.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-24T04:07:59.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24531" PostTypeId="1" CreationDate="2016-05-24T05:18:13.787" Score="1" ViewCount="11781" Body="&lt;p&gt;I am using an Arduino uno and need to send text messages and email messages from the device based on certain events occurring.  I have the logic figured out of when to send the text message or email but don't know what shield I need to send these messages.&lt;/p&gt;&#xA;" OwnerUserId="18724" LastActivityDate="2019-05-04T07:20:22.767" Title="Sending a text message through a arduino wifi shield" Tags="|arduino-uno|shields|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24532" PostTypeId="1" AcceptedAnswerId="24535" CreationDate="2016-05-24T06:19:00.113" Score="0" ViewCount="312" Body="&lt;p&gt;I am trying to power a small peristaltic pump using an UNO R3. I have it powered using usb, and I tried running the blink program to see if I could power it using digital write, and extended the delay to troubleshoot voltages using a multimeter. The motor doesn't do anything connected to the digital pins even when the digital write is set to high. If I connect the motor to the 5 V power pin the motor turns on so I know 5 V is enough voltage. I've looked at tutorials for DC motors and they explain how to set it up with motor reversing using components I don't have, and I don't need it to reverse. How can I get the motor to turn for a specific length of time?&lt;/p&gt;&#xA;" OwnerUserId="21359" LastActivityDate="2016-05-24T07:56:56.283" Title="Power motor with Uno" Tags="|arduino-uno|power|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24533" PostTypeId="1" AcceptedAnswerId="24536" CreationDate="2016-05-24T06:35:59.773" Score="1" ViewCount="114" Body="&lt;p&gt;I have an arduino mega that will be communicating through serial to a pc. One of the things I want it to tell the pc is whether or not it is connected to a wall power to 12V converter (where there is a switch between the arduino and the wall power). I was just wondering if there was a way to do that in software without having any additional hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="21360" LastActivityDate="2016-05-24T10:54:39.907" Title="Can an arduino tell between being powered by USB or by the jack?" Tags="|power|input|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24535" PostTypeId="2" ParentId="24532" CreationDate="2016-05-24T07:56:56.283" Score="3" Body="&lt;p&gt;Most likely the motor you are trying to drive requires much higher current than what the UNO can provide through its digital outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out &lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow&quot;&gt;this summary&lt;/a&gt; to find out detailed specs for the I/O ports.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do is to draw power from the 5V line provided by the Arduino. If that can drive your motor, then use the line to power an output stage, driven by the digital I/O. See &lt;a href=&quot;http://www.opencircuits.com/Driving_Large_Loads_with_the_Arduino&quot; rel=&quot;nofollow&quot;&gt;this example&lt;/a&gt;.&#xA;In general, the idea is that the digital I/O provides the control logic, while the output stage provides the power required by the specific load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical loads that can be driven directly by GPIOs are low power LEDs.&#xA;Anything that involves moving parts is generally out of reach, power-wise.&lt;/p&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-05-24T07:56:56.283" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24536" PostTypeId="2" ParentId="24533" CreationDate="2016-05-24T08:45:02.073" Score="2" Body="&lt;p&gt;No, you can't do it without extra hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to pass VIN through a voltage divider so it sits within 0-5V when powered by 12V, then feed that into an ADC input. Protect the on-board voltage regulator with a diode between 5V (anode) and VIN (cathode). Then you can measure the voltage on VIN and make a decision on if it is around 4.5V or 11.5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 22K/10K voltage divider will reduce 12V down to 3.75V, which gives plenty of &quot;headroom&quot; for over-voltage situations (where your 12V unregulated power supply actually provides, say, 15V):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gp3tB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gp3tB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-24T10:54:39.907" LastActivityDate="2016-05-24T10:54:39.907" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24538" PostTypeId="2" ParentId="24531" CreationDate="2016-05-24T10:45:19.707" Score="1" Body="&lt;p&gt;Sending an email you need a network connection of some form.  Options include:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ethernet Shield&lt;/li&gt;&#xA;&lt;li&gt;WiFi Shield&lt;/li&gt;&#xA;&lt;li&gt;GSM Shield (can be expensive, but will work almost anywhere)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To send a text message you need access to a text message service. That can either be directly through a mobile phone operator or through an on-line SMS gateway service. For an on-line service the options are as above, since it's almost the same as sending an email (in fact, some gateways offer an email-to-SMS gateway option). For direct mobile provider access you can only use a GSM shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really it boils down to how mobile you need it to be, and how much you are willing to spend (both on the initial hardware outlay and service provider fees and charges).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-24T10:45:19.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24539" PostTypeId="2" ParentId="24528" CreationDate="2016-05-24T11:10:46.037" Score="1" Body="&lt;p&gt;Yes, he meant AREF.  What he is showing there is the board plugged direct into the Arduino's header, but the VIN of the Lepton board connects to AREF not a voltage pin. By connecting your supply voltage (5V) direct to that AREF pin you are then able to provide power to the Lepton board, and it has no noticeable effect on the Arduino since connecting 5V to AREF is a perfectly valid thing to do (though pretty pointless).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AREF and VREF are both pretty much interchangeable. Analog REFerence, and Voltage REFerence. It could be said that one is the Analog voltage REFerence, and the other is the Voltage REFerence for analog. Some chips call it AREF and some VREF. Some even provide VREF+ and VREF- or AREF+ and AREF- depending on the complexity of the ADC in the chip.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-24T11:10:46.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24540" PostTypeId="1" AcceptedAnswerId="24541" CreationDate="2016-05-24T11:21:19.213" Score="0" ViewCount="46" Body="&lt;p&gt;I am in a project where it makes set of 'modules(set of separate circuits that will work as a sensor when connected to the board' that would be connected to Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I'm planning to connect 'modules' with the Mega board using RJ-45(also known as LAN cable) cables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first, using voltage divider circuit, I tried to identify these 'modules' by attaching a resistor to it, so that if the board sends 5V to the 'module', it gets the resistance of the resistor inside the module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, as soon as I tested, this way seemed a bit unstable, because the measured resistance of the resistor kept changing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, is there any other way to 'label' the module? I'm a beginner in this thing, so I'll appreciate any help that is provided.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps. the voltage divider circuit that I used can be found in here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ps2. the resistor in the module does not mean the total resistance of the circuit in the module. It's separate.  &lt;/p&gt;&#xA;" OwnerUserId="21369" LastActivityDate="2016-05-24T14:08:17.433" Title="How to 'label' module using electric techniques" Tags="|arduino-mega|resistor|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="24541" PostTypeId="2" ParentId="24540" CreationDate="2016-05-24T14:08:17.433" Score="0" Body="&lt;p&gt;If you are unable / unwilling to change your interface into a purely digital system whereby a small microcontroller in the sensor module interfaces the sensor with a communication bus, the best method is probably to include a small 1-wire EEPROM with each module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An ideal one would be the &lt;a href=&quot;https://www.maximintegrated.com/en/products/digital/memory-products/DS2431.html&quot; rel=&quot;nofollow&quot;&gt;DS2431&lt;/a&gt; which provides 1024 bits (128 bytes) of EEPROM storage using just 1 wire to both communicate and provide power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programming in a unique identifier for the module would be a simple enough task, and that unique ID can then be used to work out what the module is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DS2431 is pretty cheap too, available at prices around  $1.50 and below (much less for bulk and surface mount).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also get bigger versions for storing more data should you want to.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-24T14:08:17.433" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24542" PostTypeId="1" CreationDate="2016-05-24T15:05:35.617" Score="2" ViewCount="88" Body="&lt;p&gt;I am working on an Project in which i have to upload hex file from java to arduino uno i wrote the code in java its working but only when i call it in main method. But when i call it when button is pressed it doesn't upload the hex.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class Main extends Application {&#xA;@Override&#xA;public void start(Stage primaryStage) throws IOException {&#xA;&#xA;    FXMLLoader loader = new FXMLLoader(getClass().getResource(&quot;/fxml/main.fxml&quot;));&#xA;    Parent root = loader.load();&#xA;    MainController controller = (MainController) loader.getController();&#xA;    Scene scene = new Scene(root,485,355);&#xA;    primaryStage.setScene(scene);&#xA;    primaryStage.setTitle(&quot;Hello World!&quot;);&#xA;    primaryStage.show();&#xA;&#xA;    controller.Init(primaryStage);&#xA;    controller.searchForPorts();&#xA;    controller.disableControls();&#xA;}&#xA;&#xA;public static void main(String[] args) {&#xA;     Avr avr = new Avr();&#xA;    avr.start();&#xA;    launch(args);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Working fine like this but when called on button pressed event doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class Avr extends Thread {&#xA;String avrdude;&#xA;String avrconf;&#xA;String hex ;&#xA;&#xA;MainController main;&#xA;void setup() throws IOException{&#xA;    Path avrpath = Paths.get(&quot;avrdude.exe&quot;);&#xA;    Path hexpath = Paths.get(&quot;sketch_may13b.ino.hex&quot;);&#xA;    Path avrconfpath = Paths.get(&quot;avrdude.conf&quot;);&#xA;    Path realavrpath = avrpath.toRealPath(LinkOption.NOFOLLOW_LINKS);&#xA;    Path realhexpath = hexpath.toAbsolutePath();&#xA;    Path realavrconfpath = avrconfpath.toAbsolutePath();&#xA;&#xA;    avrdude = realavrpath.toString();&#xA;    avrconf = realavrconfpath.toString();&#xA;    hex  = realhexpath.toString();&#xA;&#xA;    avrdude = avrdude.replace(&quot;\\&quot;,&quot;\\\\&quot;);&#xA;    avrconf = avrconf.replace(&quot;\\&quot;,&quot;\\\\&quot;);&#xA;    hex = hex.replace(&quot;\\&quot;,&quot;\\\\&quot;);&#xA;    main = new MainController();&#xA;&#xA;    String port =&quot;COM3&quot;;&#xA;        runCommand(new String[]{avrdude, &quot;-C&quot;+avrconf,&quot;-v&quot;,&quot;-v&quot;,&quot;-v&quot;,&quot;-v&quot;,&quot;-patmega328p&quot;,&quot;-carduino&quot;,&quot;-P&quot;+port,&quot;-b115200&quot;,&quot;-D&quot;,&quot;-Uflash:w:&quot;+hex+&quot;:i&quot;});&#xA;&#xA;  }&#xA;  void runCommand(String[] cmd){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;try {&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Runtime.getRuntime().exec(cmd);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;}&#xA;        catch (IOException e) {&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      System.out.println(&quot;something went wrong: \n&quot;);&#xA;      e.printStackTrace();&#xA;  }&#xA;&#xA;  }  &#xA;&#xA;@Override&#xA;public void run() {&#xA;    // TODO Auto-generated method stub&#xA;    try {&#xA;        setup();&#xA;    } catch (IOException e) {&#xA;        // TODO Auto-generated catch block&#xA;        e.printStackTrace();&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;" OwnerUserId="21135" LastActivityDate="2016-05-24T15:05:35.617" Title="AVR dude not working in javaFX" Tags="|avrdude|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24543" PostTypeId="2" ParentId="24531" CreationDate="2016-05-24T15:10:35.950" Score="1" Body="&lt;p&gt;In one of project I had seen recently, they used esp8266 for home automation and used TEMBOO.com to send SMS. I am sorry I can't help u further than this, but i am sure, Google will.. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also refer this tutorial from adafruit on sending an sms with Temboo&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/sending-an-sms-with-temboo/&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/sending-an-sms-with-temboo/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21374" LastActivityDate="2016-05-24T15:10:35.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24545" PostTypeId="1" AcceptedAnswerId="24546" CreationDate="2016-05-24T15:23:50.467" Score="3" ViewCount="2316" Body="&lt;p&gt;I revisited an older device that I made and discovered, that I had an 8 Ohm speaker connected directly to ground and an IO pin of an Atmega328P. According to my calculation that means that the pin would have to source 625 mA, which is way above the 40 mA that any single port should be able to source and even above the 200 mA that the Vcc and GND support. Yet it somehow worked and the chip seems to be working just fine. The application uses a duty cycle of 50%, so in the best case it would use maybe 312.5 mA, which is a little better but still way above the ratings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is, what happens if the output pin is asked to source more than it's rating?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen chips that just release their magic smoke while others just can't keep up with supplying that kind of voltage, so only the voltage drops without any other problems. How does the Atmega328P handle this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Atmega clearly didn't burn through, but what other kind of damage should I expect?&lt;/p&gt;&#xA;" OwnerUserId="11571" LastActivityDate="2016-05-24T21:33:09.303" Title="What happens if I draw too much current from ATMEGA IO pin?" Tags="|atmega328|current|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24546" PostTypeId="2" ParentId="24545" CreationDate="2016-05-24T15:57:56.690" Score="5" Body="&lt;p&gt;There's a few crude calculations you can do using some numbers from the datasheet.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This graph is in the datasheet:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zrsHB.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zrsHB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It shows the voltage dropped by the high-side MOSFET driver in the IO pin for different amounts of current draw. From that we can get its resistance R(DSON).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance at 10mA, at 25C, the output voltage would be 4.75V. That's a 0.25V drop from the 5V supply voltage. So we can calculate the resistance as:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;R=V/I = 0.25V / 0.01A = 25Ω&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now we have that resistance we can use it to calculate the actual current from the IO pin with an 8Ω load.  Simply add the two together:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;25Ω + 8Ω = 33Ω&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Now we can calculate the current through that circuit:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;I=V/R = 5V / 33Ω = 0.152A&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;That is, of course, way above what the IO pin can actually supply (or so the datasheet says).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what happens? Well, two things, basically:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The voltage on the IO pin will be below the 4.2V specification for the minimum of an output pin when HIGH, and&lt;/li&gt;&#xA;&lt;li&gt;It will get hot.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The actual voltage will be, of course, &lt;em&gt;V=I×R = 0.152A × 25Ω = 3.8V&lt;/em&gt; droped, so &lt;em&gt;5 - 3.8 = 1.2V&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is more critical, though, is the heat.  152mA through a 25Ω resistance generates &lt;em&gt;P=I²R = 0.152 × 0.152 × 25 = 0.5776W&lt;/em&gt;. That's quite a lot. Enough to melt the internal circuits in the chip and release the Magic Smoke™.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running at 50% duty cycle, though, makes a difference. That's 50% of the power, which makes a big difference to the heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would the actual allowable heat be? Well, at 40mA, with 25Ω, that is &lt;em&gt;0.04 × 0.04 × 25 = 0.04W&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you're generating more than 14 times the amount of heat you are allowed to. Even at 50% duty cycle, that's over 7x the limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will it kill the chip? Well, possibly, possibly not. It depends how rugged the chip is and how well it can withstand the heat. Short bursts may be OK since the heat doesn't build up enough to melt things. Extended use, though, will make it get too hot, and things will go pop.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-05-24T21:33:09.303" LastActivityDate="2016-05-24T21:33:09.303" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24547" PostTypeId="1" CreationDate="2016-05-24T16:06:55.117" Score="2" ViewCount="661" Body="&lt;p&gt;I hope somebody can shed some light on this problem. I've researched the internet and forums and noticed that others have experienced similar problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This sketch runs fine for a couple of hours...it activates a relay approximately every hour, has a 10 second loop for an LED flash and then enters sleep mode. The watchdog timer is set to 8 seconds and wakes it up from sleep. I don't know why it works for a couple of hours and then gets caught into some sort of loop with the LED flashing rapidly. The requirements for disabling and resetting the watchdog might be the problem but I just don't know where to go next. I have seen a few discussions on memory leakage but not sure what that means or how to check for it. I also wonder if need to add any short delays after resets, etc. Additionally, when I press the reset button it has no effect on restarting the sketch. The sketch is running on a breadboard atMega328p-pu. Any help would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ps. in the preview I noticed the # statements are not shown. They are the following libraries: avr/sleep.h, avr/power.h, avr/wdt.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// In this sketch, the LED's flash every 10 seconds, then at each approximately 1 hour period, the relay is activated&#xA;// for 12 seconds.  It uses the WDT at its maximum 8 second delay to wakeup the circuit from low power sleep.&#xA;&#xA;// Source: citizen-sensing.org/2013/07/arduino-watchdog/&#xA;&#xA;// Check this out for good explanation on the Watchdog timer and code.&#xA;// http://www.leonardomiliani.com/en/2013/impariamo-ad-usare-il-watchdog-2/&#xA;&#xA;// SEE NOTE at the end on known WDT reset issue&#xA;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;&#xA;&#xA;int j = 1; // Elapsed time multiplication factor&#xA;int j2 = 0; // previous j value &#xA;float tCumm = 0.0; // Cummulative time&#xA;float hSet = 1.0; // Set relay activation once per hour&#xA;float hSet2 = 0.0; // Previous hSet value&#xA;&#xA;// Create sleepNow function&#xA;&#xA;void sleepNow() {&#xA;&#xA;  wdt_reset();&#xA;  wdt_disable();&#xA;&#xA;  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Selecting the lowest power setting&#xA;&#xA;// Set watchdog parameters&#xA;  MCUSR &amp;amp;= ~(1&amp;lt;&amp;lt;WDRF); // reset status flag&#xA;  WDTCSR |= (1&amp;lt;&amp;lt;WDCE) | (1&amp;lt;&amp;lt;WDE); // required to enable configuration changes&#xA;  WDTCSR = (1&amp;lt;&amp;lt;WDP0) | (1&amp;lt;&amp;lt;WDP3); // set the pre-scalar for 10, ie 8 seconds delay &#xA;  WDTCSR |= (1&amp;lt;&amp;lt;WDIE); // enable interrupt mode&#xA;&#xA;// Disable the ADC&#xA;  ADCSRA &amp;amp;= ~(1&amp;lt;&amp;lt;ADEN); // Set bit 7 in ADC register to 1 to disable the ADC &#xA;&#xA;// Ready for sleep&#xA;  sleep_enable(); // Enable sleep function&#xA;  sleep_mode(); // Go to sleep.  Will wake up upon interrupt via Watchdog timer in this sketch.&#xA;&#xA;// disable sleep after waking up&#xA;  sleep_disable(); // Disable sleep for now after Watchdog timer interrupt activation&#xA;}&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(4, OUTPUT); // set pin 4 as output for LED&#xA;  pinMode(7, OUTPUT); // set pin 7 as output for relay   &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // 10 second LED flashing + sleep loop&#xA;&#xA;  for (int i = 0; i &amp;lt; 2; i++) {&#xA;  digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(200);               // wait for 0.2 sec&#xA;  digitalWrite(4, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(200);              // wait for 0.2 second&#xA;}&#xA;&#xA;  // Add delay for total approx 2 sec&#xA;  delay(1200);&#xA;&#xA;  // Start sleep / Low power / Watchdog interrupt&#xA;  sleepNow();&#xA;&#xA;  // Cummulative time in increments of 10 seconds&#xA;  tCumm = ((2.0 + 8.0)*j)/3600.;&#xA;&#xA;  // Time multiplication factor. Used to increment tCumm. Never resets to zero.&#xA;  j2 = j;&#xA;  j = j2 + 1;&#xA;&#xA;  // Check to see if tCumm exceeds the user defined period (hSet) before activating relay&#xA;  if (tCumm &amp;gt; hSet) {&#xA;&#xA;  // Activate relay for 12 seconds&#xA;    digitalWrite(7, HIGH);&#xA;    delay(12000);&#xA;    digitalWrite(7,LOW);&#xA;&#xA;  // Reset hSet for next relay activation time&#xA;    hSet2 = hSet;&#xA;    hSet = hSet2 + 1.0;&#xA;&#xA;    } &#xA;}&#xA;&#xA;&#xA;ISR (WDT_vect) {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;NOTE from an online discussion: The problem is that a RESET does not turn off the watchdog timer once it has been turned on, and neither does the bootloader.  So you set things up to have the watchdog cause a reset in 15ms, and the reset occurs. Now the bootloader starts up, and starts its LED-flashing, and OOPS another 15ms has gone by with no one feeding the watchdog, and it resets again.  This repeats until a power cycle turns off the watchdog.&lt;br&gt;&#xA;(This behavior is explicitly described in the ATmega datasheet...)&lt;/p&gt;&#xA;" OwnerUserId="21375" LastEditorUserId="21375" LastEditDate="2016-05-24T17:23:58.213" LastActivityDate="2016-05-24T18:19:29.213" Title="Works for 2-3 hrs, then LED blinks rapidly - Sleep Mode and Watchdog timer wakeup" Tags="|relay|sleep|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24548" PostTypeId="1" AcceptedAnswerId="24550" CreationDate="2016-05-24T13:26:48.990" Score="1" ViewCount="2517" Body="&lt;p&gt;I have an Arduino Uno and the I/O Shield wired up and I'm trying to switch (i.e. engage) a relay on the I/O Shield, but nothing seems to be working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've identified the input pins correctly and am able to send digital signals to it and it responds correctly. I also see the LED next to the relay light up when I do a digital write on the Arduino to a specific relay pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm starting to think that I might need to use an alternative power source or that I am not using the Arduino API correctly to switch the relay. At the moment I do a &lt;code&gt;digitalWrite(13, HIGH)&lt;/code&gt;, delay, and then do a &lt;code&gt;digitalWrite(13, LOW)&lt;/code&gt; - pretty simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield is just powered by the Arduino at the moment, and I haven't been able to find where I might be able to plug in power, so I'm assuming the Arduino supplies it with all of the power it needs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;int relayPin = 13;&#xA;&#xA;void setup() {&#xA;    pinMode(relayPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;            digitalWrite(relayPin, HIGH);&#xA;        delay(5000);&#xA;        digitalWrite(relayPin, LOW);&#xA;        delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/u8oFH.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/u8oFH.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="The Pax Bisonica" LastActivityDate="2017-04-09T01:28:34.573" Title="Arduino I/O Shield relay won't switch" Tags="|relay|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24549" PostTypeId="2" ParentId="24548" CreationDate="2016-05-24T13:33:35.293" Score="1" Body="&lt;p&gt;Unless you share a schematic, it will be very difficult to provide a good answer. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the things that you might be doing wrong:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Using a power supply which is not able to provide enough current to the relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Using a power supply of wrong voltage as required by relay coil. The relay might be needing 12 V and you might be trying to power it up with a 5 V power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) You might be trying to drive the relay directly with your GPIO pin (without using any external transistor switch).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Trying to raise a dead relay. There is a possibility that the relay is damaged. Check it by powering it up directly using a battery or another adequate power supply that you got.&lt;/p&gt;&#xA;" OwnerUserId="7553" OwnerDisplayName="Whiskeyjack" LastActivityDate="2016-05-24T13:33:35.293" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24550" PostTypeId="2" ParentId="24548" CreationDate="2016-05-24T14:39:13.593" Score="1" Body="&lt;p&gt;Based on your newly-added &lt;a href=&quot;http://www.velleman.co.uk/contents/media/a05-3.jpg&quot; rel=&quot;nofollow&quot;&gt;photo&lt;/a&gt;, you are using the &lt;a href=&quot;http://www.velleman.co.uk/contents/en-uk/p626_vma05.html&quot; rel=&quot;nofollow&quot;&gt;Velleman VMA05 I/O Shield&lt;/a&gt; (or the &lt;a href=&quot;http://www.velleman.co.uk/contents/en-uk/p582_ka05.html&quot; rel=&quot;nofollow&quot;&gt;KA-05 kit version&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shield &lt;strong&gt;requires&lt;/strong&gt; a 12V 500mA (minimum current capability) power supply input to the Arduino Uno, as that board uses relays with a 12V coil.  Your symptoms (LED lights but relay does not switch) suggest that you are using a lower voltage, or lower current, power supply to your Arduino. If so, then the fix is: Use the required power supply to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm assuming the arduino supplies it with all of the power it needs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes - but &lt;em&gt;only&lt;/em&gt; if you meet the minimum requirements of the power supply which you connect to the Arduino. As documented in the Vellemen VMA05 &lt;a href=&quot;http://www.velleman.co.uk/contents/en-uk/vma05d.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; and &lt;a href=&quot;http://www.velleman.co.uk/contents/en-uk/vma05.pdf&quot; rel=&quot;nofollow&quot;&gt;manual&lt;/a&gt;, this must be a 12V supply (not lower, not higher) capable of a minimum of 500mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You would likely be able to use a 12V supply capable of a slightly lower current output, if you only wanted to have one or two relays active at the same time. However if more relays were active simultaneously, the risk would increase of incorrect or erroneous behaviour, due to the additional current necessary for each relay coil, in addition to powering the Arduino, eventually exceeding the capabilities of the power supply.)&lt;/p&gt;&#xA;" OwnerUserId="21378" OwnerDisplayName="SamGibson" LastActivityDate="2016-05-24T15:10:37.047" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24551" PostTypeId="2" ParentId="23514" CreationDate="2016-05-24T16:48:41.317" Score="0" Body="&lt;p&gt;Conceptually, this is best solved by having an ISR which always reads the high rate sensor, but implements a toggle so that it only ready the low rate sensor every other execution.  On the times when you don't read it you could repeat a stored version of the last reading, though it would be more bandwidth efficient not to transmit that at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, practically speaking this may not be the best choice.  The process of reading sensors often has a latency - typically to achieve the highest possible rate you would need to start the reading, and claim the result sometime later.  If your two sensors have distinct interfaces, or even if the they share an I2C or SPI bus, you may be able to start readings for both and then claim them with subsequent transactions after allowing them an overlapped measurement time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also not clear that you are best to use an interrupt service routine at all.  If your MCU has nothing else to do, the most &lt;em&gt;deterministic&lt;/em&gt; and ultimately &lt;em&gt;fastest&lt;/em&gt; behavior on an ATmega might be to accomplish reading and direct (unbuffered) serial transmission within the main program loop, busy waiting at each phase.  This avoids not only the overhead of context switches when entering an ISR, but also a lot of the variability.  That would be doubly true if you can be transmitting the old reading while waiting for the already-triggered sensors to measure the next one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you mentioned you are using a Teensy 3.x, which probably communicates natively via USB, rather than a serial UART.  That complicates things a bit - so called &quot;serial&quot; output flows in response to interrupts from the USB engine responding to the host, which is not really deterministic for you.  Fortunately, the Teensy is enough faster that you are less likely to have issues with running out of time, particularly when sampling at 100 Hz.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-24T16:59:44.230" LastActivityDate="2016-05-24T16:59:44.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24552" PostTypeId="2" ParentId="24547" CreationDate="2016-05-24T17:14:45.477" Score="1" Body="&lt;p&gt;You have a watch dog timer for 8 seconds and when you activate the relays you do a delay of 12.&lt;br&gt;&#xA;This means that your watchdog will trigger when you activate the relays.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-05-24T17:14:45.477" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24553" PostTypeId="2" ParentId="24547" CreationDate="2016-05-24T17:55:49.350" Score="1" Body="&lt;p&gt;Looking at this declaration&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int j = 1; // Elapsed time multiplication factor&#xA;int j2 = 0; // previous j value &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Cummulative time in increments of 10 seconds&#xA;  tCumm = ((2.0 + 8.0)*j)/3600.;&#xA;&#xA; // Time multiplication factor. Used to increment tCumm. Never resets to zero.&#xA;  j2 = j;&#xA;  j = j2 + 1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;along with the associated comments seems to indicate that this variable &quot;j&quot; which is a (signed) &lt;code&gt;int&lt;/code&gt; only increments without ever resetting, and is critical to the process of calculating the next time at which your code will act.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your includes indicate that you are building for an AVR-based Arduino, and under the compiler used, an &lt;code&gt;int&lt;/code&gt; on this platform is only 16 bits, meaning it has a range of -32768 to 32767.  Most modern platforms including this one use 2's complement representation, and most non-DSP platforms including this one do not use saturating arithmetic.  &lt;strong&gt;Therefore, incrementing a positive number beyond the positive limit will actually product a negative value.&lt;/strong&gt;  Once your target time exceeds the maximum possible result of a calculation that has a positive &lt;code&gt;int&lt;/code&gt; as an input, it becomes a target you will never be able to achieve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given the the amount of time your loop takes to execute, such integer overflow may not be not the issue you are hitting &lt;em&gt;first&lt;/em&gt;, and does not seem perfectly correlated to your rapid-cycling failure mode.  But if your loop takes around 10 seconds, it seems like this would be an issue in a little less than four days.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-24T18:19:29.213" LastActivityDate="2016-05-24T18:19:29.213" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24554" PostTypeId="1" CreationDate="2016-05-24T20:58:25.707" Score="1" ViewCount="1183" Body="&lt;p&gt;Has anyone got sleep/standby + watchdog to work together on their Arduino Zero or Sparkfun SAMD mini?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to get the WDT to reset the device, and am able to put it to sleep - but can't get the WDT to bring it out of sleep.  Every time I try, it pops right back out of sleep mode again as if &lt;code&gt;SCB-&amp;gt;SCR |= SCB_SCR_SLEEPDEEP_Msk&lt;/code&gt; was never even called&lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2020-08-30T14:04:00.363" Title="ATSAMD21 sleep + watchdog?" Tags="|timers|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24555" PostTypeId="1" CreationDate="2016-05-24T22:32:15.440" Score="0" ViewCount="336" Body="&lt;p&gt;My existing Arduino Mega set up has been in use for about 4 years controlling my gas CH system &amp;amp; heat pump HW system using an Arduino mega &amp;amp; 13 'wired' DS18B20 sensors; 2 of these sensors monitor the main room (lounge) temperature &amp;amp; 1 sensor monitors the outside temp. These 3 sensors control the CH by gas boiler using an algorithm that constantly adjusts the room temp setting as the outside temp changes. The others monitor HW tank temps, heat pump inlet &amp;amp; outlet temps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to change this 'single zone' CH control to a 'multi zone' control using many more temp sensors (DS18B20 or ESP8266?) but laying in hidden wiring would be a real pain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking at using ESP8266-07 as a wireless temp sensor for each 'zone', sending its data to the Mega for processing by the above refered to algorithm, so that the Mega can control the CH system better but I can't find any reference to receiving this wireless data at the Mega for processing within the IDE sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried testing the nRF24L01 &amp;amp; nRF24L01+ but my house has many 'black' reception areas &amp;amp; transmission is unreliable.&#xA;My 2.4GHz wireless LAN has 3 extenders around the house so this would be my prefered wireless solution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could a wireless 'master' be used at the Mega to process data coming in from the 'slave' sensors or am I misunderstanding this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My programming skill is limited to 'basic IDE' &amp;amp; I find 'wireless' a bit of a black art (I'm a retired mechanical engineer!)&lt;/p&gt;&#xA;" OwnerUserId="21386" LastActivityDate="2016-05-25T21:59:48.417" Title="sending room temp data from multiple esp8266's to Mega 2560 to control CH gas boiler" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24556" PostTypeId="1" CreationDate="2016-05-24T22:44:47.303" Score="2" ViewCount="94" Body="&lt;p&gt;I just want to configure my laptops keyboard buttons &lt;kbd&gt;a&lt;/kbd&gt;,&lt;kbd&gt;s&lt;/kbd&gt;,&lt;kbd&gt;d&lt;/kbd&gt;,&lt;kbd&gt;f&lt;/kbd&gt;,&lt;kbd&gt;g&lt;/kbd&gt;,&lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;j&lt;/kbd&gt;. I wrote this code and it works for only &lt;kbd&gt;a&lt;/kbd&gt; but I couldn't configure other buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Keyboard.h&quot;&#xA;&#xA;const int buttonPin = 3;          // input pin for pushbutton&#xA;int previousButtonState = HIGH;   // for checking the state of a pushButton&#xA;int counter = 0;                  // button push counter&#xA;&#xA;void setup() {&#xA;  // make the pushButton pin an input:&#xA;  pinMode(buttonPin, INPUT);&#xA;  // initialize control over the keyboard:&#xA;  Keyboard.begin();&#xA;  Keyboard.press('a');&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the pushbutton:&#xA;  int buttonState = digitalRead(buttonPin);&#xA;  // if the button state has changed,&#xA;  if ((buttonState != previousButtonState)&#xA;      // and it's currently pressed:&#xA;      &amp;amp;&amp;amp; (buttonState == HIGH)) {&#xA;    // increment the button counter&#xA;    counter++;&#xA;    // type out a message&#xA;    Keyboard.print(&quot;a&quot;);&#xA;  }&#xA;  // save the current button state for comparison next time:&#xA;  previousButtonState = buttonState;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I configure other buttons &lt;kbd&gt;s&lt;/kbd&gt;,&lt;kbd&gt;d&lt;/kbd&gt;,&lt;kbd&gt;f&lt;/kbd&gt;,&lt;kbd&gt;g&lt;/kbd&gt;,&lt;kbd&gt;h&lt;/kbd&gt; and &lt;kbd&gt;j&lt;/kbd&gt; to pin buttons 4,5,6,7,8 and 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for help:)&lt;/p&gt;&#xA;" OwnerUserId="21387" LastEditorUserId="37523" LastEditDate="2019-06-30T18:44:15.843" LastActivityDate="2019-06-30T18:44:15.843" Title="Arduino Leonardo based h keyboard" Tags="|c++|arduino-leonardo|keyboard|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24557" PostTypeId="2" ParentId="24439" CreationDate="2016-05-25T00:12:43.013" Score="0" Body="&lt;p&gt;I end up using another way and just wanted to share it here for anybody that would want a bit less efficient but simpler way of doing that  ;) it's cleaner with Majenko's solution for sure but this gets the job done and is pretty easy to understand and troubleshoot. cheers!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int randNumber;&#xA;&#xA;void loop(){&#xA;randNumber = random(1,14);&#xA;&#xA;if (button is pressed or something){&#xA;callAnim(randNumber);&#xA;}&#xA;}&#xA;&#xA;&#xA;void callAnim(int randNumber){&#xA;if (randNumber==1){&#xA;anim1();&#xA;}&#xA;if (randNumber==2){&#xA;anim2();&#xA;}&#xA;}&#xA;// ... etc ...&#xA;&#xA;void anim1() {&#xA;// blah blah&#xA;}&#xA;&#xA;void anim2() { &#xA;// blah blah&#xA;}&#xA;// ... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21282" LastActivityDate="2016-05-25T00:12:43.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24558" PostTypeId="1" CreationDate="2016-05-24T12:17:15.617" Score="0" ViewCount="3429" Body="&lt;p&gt;I have some Atmega328-Pu micro-controllers without boot-loader program. Now I need to burn boot-loader to them all. I have two arduino uno boards having Atmega328 P-Pu micro-controllers on board. I used this circuit &lt;a href=&quot;https://i.stack.imgur.com/lyzW8.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lyzW8.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; from this page &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;Installing an arduino boot-loader&lt;/a&gt;&#xA;It does not work. The boot-loader is not uploaded. Can you please help me out? If you need any more informations please ask. I have been struggling with this kind of boot-loading techniques for more than a week. I am using arduino IDE 1.0.1 and the board is Arduino uno R3&lt;/p&gt;&#xA;" OwnerDisplayName="GDayan" LastActivityDate="2017-03-02T18:34:15.037" Title="How to bootload a atmega328-pu using arduino uno?" Tags="|bootloader|icsp|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24559" PostTypeId="1" AcceptedAnswerId="24565" CreationDate="2016-05-25T02:26:21.313" Score="1" ViewCount="1258" Body="&lt;p&gt;I'm using the &lt;strong&gt;RGBLCDShield&lt;/strong&gt; library and a few analog input signals and since it seems the interrupts are being used by the SPI interface of the LCD Shield, I decided to try it with &lt;strong&gt;FreeRTOS&lt;/strong&gt; instead.  I don't currently have my arduino with me (left if at parents') but I wanted to get some feedback on this code to see if it would run properly; I might not be getting my UNO back for a few days but I wanted to at least have a usable code ready to be tested when I do get it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Analog inputs are just 2 low level signals and the digital outputs just control some IC switches.  One PWM is fed through a lowpass filter and into an amplifier input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Here is my code in it's entirety:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino_FreeRTOS.h&amp;gt;&#xA;#include &amp;lt;Adafruit_RGBLCDShield.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;&#xA;&#xA;// define tasks&#xA;void TaskAnalogRead( void *pvParameters );  // Check voltage input&#xA;void TaskLCDShield( void *pvParameters );   // Control Display&#xA;void TaskUserInput( void *pvParameters );   // User Interface - System Process&#xA;&#xA;Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();&#xA;unsigned int vSet = 0;  // Desired Voltage (potentiometer set)&#xA;unsigned int vOut = 0;  // Voltage on capacitor&#xA;&#xA;&#xA;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;&#xA;  // Set up Tasks to run independently&#xA;  xTaskCreate(&#xA;    TaskAnalogRead&#xA;    ,  (const portCHAR *) &quot;AnalogRead&quot;   // A name just for humans&#xA;    ,  128  // This stack size can be checked &amp;amp; adjusted by reading the Stack Highwater&#xA;    ,  NULL&#xA;    ,  2  // Priority, with 1 being the highest, and 4 being the lowest.&#xA;    ,  NULL );&#xA;&#xA;  xTaskCreate(&#xA;    TaskLCDShield&#xA;    ,  (const portCHAR *) &quot;LCDShield&quot;&#xA;    ,  128  // Stack size&#xA;    ,  NULL&#xA;    ,  3  // Priority&#xA;    ,  NULL );&#xA;&#xA;  xTaskCreate(&#xA;    TaskUserInput&#xA;    , (const portCHAR *) &quot;UserInput&quot;&#xA;    , 128&#xA;    , NULL&#xA;    , 1&#xA;    , NULL );&#xA;&#xA;  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.&#xA;  lcd.begin(16, 2);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Empty. Things are done in Tasks.&#xA;}&#xA;&#xA;/*--------------------------------------------------*/&#xA;/*---------------------- Tasks ---------------------*/&#xA;/*--------------------------------------------------*/&#xA;&#xA;void TaskLCDShield(void *pvParameters)  // This is a task.&#xA;{&#xA;  (void) pvParameters;&#xA;&#xA;  // Start Display&#xA;  lcd.setBacklight(0x7);&#xA;  lcd.setCursor(0,0);&#xA;  lcd.println(&quot; PORTABLE SPARK &quot;);&#xA;  delay(5000);&#xA;  lcd.clear();&#xA;&#xA;  for (;;) // Continuously Update display&#xA;  {&#xA;&#xA;    int volts = vSet * 100.0;&#xA;    int chg   = (vOut * 0.488)/volts;&#xA;    int vpos, cpos;&#xA;    lcd.setCursor(0,0);&#xA;    lcd.print(&quot;Voltage:       &quot;);&#xA;    lcd.setCursor(15, 0);&#xA;    lcd.print(&quot;V&quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;Charge :       &quot;);&#xA;    lcd.setCursor(15,1);&#xA;    lcd.print(&quot;%&quot;);&#xA;&#xA;    lcd.setCursor(9,0);&#xA;    if(volts &amp;lt; 100)&#xA;      {&#xA;        lcd.print(&quot;    &quot;);&#xA;        vpos = 13;&#xA;      }&#xA;    else if(volts &amp;lt; 1000)&#xA;      {&#xA;        lcd.print(&quot;    &quot;);&#xA;        vpos = 11;&#xA;      }&#xA;     else if(volts &amp;lt; 10000)&#xA;     {&#xA;      lcd.print(&quot;     &quot;);&#xA;      vpos = 10;&#xA;     }&#xA;     else vpos = 9;&#xA;    lcd.setCursor(vpos,0);&#xA;    lcd.print(volts, DEC);&#xA;&#xA;    lcd.setCursor(9,1);&#xA;    if(chg &amp;lt; 10)&#xA;      {&#xA;        lcd.print(&quot;    &quot;);&#xA;        cpos = 13;&#xA;      }&#xA;    else if(chg &amp;lt; 100)&#xA;      {&#xA;        lcd.print(&quot;   &quot;);&#xA;        cpos = 12;&#xA;      }&#xA;    else cpos = 11;&#xA;    lcd.setCursor(cpos,1);&#xA;    lcd.print(chg, DEC);&#xA;    //digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second&#xA;    //digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;    //vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second&#xA;  }&#xA;}&#xA;&#xA;void TaskAnalogRead(void *pvParameters)  // Read Analog Voltages (VSet, Emonitor)&#xA;{&#xA;  (void) pvParameters;&#xA;&#xA;  for (;;)&#xA;  {&#xA;    int eMon = analogRead(A0); // read input pins&#xA;    vTaskDelay(1);&#xA;    int vA = analogRead(A1);&#xA;&#xA;    vSet = (vA/1024) * 15000;  // calculate actual values&#xA;    vOut = (5.0/1024.0) * 10000 * eMon; &#xA;&#xA;    vTaskDelay(10);  // one tick delay (300ms) in between reads&#xA;  }&#xA;}  // End Analog Read&#xA;&#xA;&#xA;void TaskUserInput(void *pvParameters) // User Interface&#xA;{&#xA;  (void) pvParameters;&#xA;&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(8, OUTPUT);  // Fire signal&#xA;  pinMode(7, OUTPUT);  // Charge/Discharge signal&#xA;  pinMode(5, OUTPUT);  // Eprgm PWM output&#xA;  pinMode(4, OUTPUT);  // Cam/DAQ trigger&#xA;&#xA;  bool charge = false;   // charge flag&#xA;&#xA;  for (;;)&#xA;  {&#xA;    uint8_t button = lcd.readButtons();&#xA;    switch(charge)&#xA;    {&#xA;      case true:&#xA;        analogWrite(5, (vSet * 0.0204)/5);&#xA;        vTaskDelay(1);&#xA;        digitalWrite(7, HIGH);&#xA;        vTaskDelay(1);&#xA;        break;&#xA;&#xA;       default:&#xA;        analogWrite(5, 0);&#xA;        vTaskDelay(1);&#xA;        digitalWrite(7, LOW);&#xA;        vTaskDelay(1);&#xA;        break;&#xA;    } // End Switch(charge)&#xA;&#xA;    if(button &amp;amp; BUTTON_UP)  // Charge/Discharge button&#xA;    {&#xA;      charge = !charge;&#xA;    } // end if&#xA;&#xA;    else if(button &amp;amp; BUTTON_DOWN) // Fire!&#xA;    {&#xA;      digitalWrite(8, HIGH);&#xA;      vTaskDelay(1);&#xA;      digitalWrite(4, HIGH);&#xA;      vTaskDelay(1);&#xA;      digitalWrite(7, LOW);&#xA;      charge = false;&#xA;      vTaskDelay(1);&#xA;      digitalWrite(4, LOW);&#xA;      vTaskDelay(1);&#xA;      digitalWrite(8, LOW);&#xA;    } // End else if&#xA;&#xA;  }  // End for&#xA;&#xA;} // End User Interface&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My specific concern is with the 2wire interface of the LCD shield and whether it would be able to communicate with the Arduino - especially when it needs to read the button inputs.&lt;br&gt;&#xA;Also, how do I determine the stack size for each task?  Is 128 for each enough to handle what I have?&lt;/p&gt;&#xA;" OwnerDisplayName="user20985" LastActivityDate="2016-05-25T07:59:04.737" Title="Is this a proper implementation of FreeRTOS for Arduino?" Tags="|arduino-uno|interrupt|threads|task|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24560" PostTypeId="1" CreationDate="2016-05-25T04:16:13.647" Score="1" ViewCount="71" Body="&lt;p&gt;I created a simple library for formatting text output on the serial monitor. It has thee functions, one that creates carriage returns, one that sets the number of spaces between characters and the last one prints dashes. I followed the tutorial on the Arduino.cc site. The problem I have is that I can’t pass the value to each of the functions when I call them in the code. If you look at the screenshot from the sketch when I create an instance of nFormat it requires me to put a value in and it passes that value to each of the functions (lines, spaces, dashes). I want to be able to specify the value directly when I call the function. See the second red line on the output screenshot. I know this post is a bit long I would appreciate it if someone could point me in the right direction. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;nFormat.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef nFormat_h &#xA;#define nFormat_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;&#xA;class nFormat&#xA;{&#xA;  public:&#xA;    nFormat(int counter);&#xA;&#xA;    void lines();&#xA;    void spaces();&#xA;    void dashes();&#xA;&#xA;   private:&#xA;    int _counter;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;nFormat.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;nFormat.h&quot;&#xA;&#xA;nFormat::nFormat(int counter)&#xA;{&#xA;    _counter=counter;&#xA;}&#xA;&#xA;void nFormat::lines()&#xA;{   &#xA;for (int x = 0; x &amp;lt; _counter; x++)&#xA;    {&#xA;        Serial.println(&quot; &quot;);&#xA;    }&#xA;&#xA;}&#xA;&#xA;void nFormat::spaces()&#xA;{&#xA;    for (int x = 0; x &amp;lt; _counter; x++)&#xA;    {&#xA;        Serial.print(&quot; &quot;);&#xA;    }&#xA;}&#xA;&#xA;void nFormat::dashes()&#xA;{&#xA;    for (int x = 0; x &amp;lt; _counter; x++)&#xA;    {&#xA;        Serial.print(&quot;-&quot;);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zWlca.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zWlca.jpg&quot; alt=&quot;output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-05-25T08:05:29.347" Title="Creating a library" Tags="|library|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24563" PostTypeId="1" CreationDate="2016-05-25T06:18:00.653" Score="0" ViewCount="111" Body="&lt;p&gt;I am currently using the Arduino Pro Micro board and I want to connect 2 ultrasonic sensors to 1 board, whilst knowing which sensor is being triggered. The sensor I am using is a HC-SR04 Ultrasonic sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help me thank you :)&lt;/p&gt;&#xA;" OwnerUserId="21393" LastEditorUserId="653" LastEditDate="2016-05-25T13:13:38.690" LastActivityDate="2016-05-25T13:24:14.437" Title="Is it possible to connect 2 ultra sonic sensors to 1 arduino?" Tags="|hardware|hc-sr04|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24564" PostTypeId="2" ParentId="24560" CreationDate="2016-05-25T07:31:12.220" Score="2" Body="&lt;p&gt;If you want to specify the number of spaces/dashes/... every time you&#xA;call any of these methods, you just have to make that number a parameter&#xA;of the method:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void lines(int count)&#xA;{&#xA;    for (int x = 0; x &amp;lt; count; x++)&#xA;        Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, your class does not need its private &lt;code&gt;_counter&lt;/code&gt;. Then, since there&#xA;is no data in the class, you do not need to instantiate it: just make&#xA;all the methods &lt;code&gt;static&lt;/code&gt; and call the methods as&#xA;&lt;code&gt;nFormat::method_name()&lt;/code&gt;. And since you are not making instances, you do&#xA;not need a constructor either. And since the methods are really trivial,&#xA;there is no point in implementing them in a .cpp file: you can just&#xA;inline them in the class declaration. Combining all this gives this small&#xA;demo program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class nFormat&#xA;{&#xA;  public:&#xA;    static void lines(int count)&#xA;    {&#xA;        for (int x = 0; x &amp;lt; count; x++)&#xA;            Serial.println();&#xA;    }&#xA;&#xA;    static void spaces(int count)&#xA;    {&#xA;        for (int x = 0; x &amp;lt; count; x++)&#xA;            Serial.print(&quot; &quot;);&#xA;    }&#xA;&#xA;    static void dashes(int count)&#xA;    {&#xA;        for (int x = 0; x &amp;lt; count; x++)&#xA;            Serial.print(&quot;-&quot;);&#xA;    }&#xA;};&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    nFormat::dashes(5);&#xA;    nFormat::lines(5);&#xA;    nFormat::spaces(5);&#xA;    nFormat::dashes(5);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It could be noted than this class serves only to avoid putting all the&#xA;functions in the global namespace. It is essentially a namespace. You&#xA;could as well replace &lt;code&gt;class&lt;/code&gt; by &lt;code&gt;namespace&lt;/code&gt; (and remove the &lt;code&gt;public&lt;/code&gt;&#xA;keyword) to make that more explicit.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-05-25T08:05:29.347" LastActivityDate="2016-05-25T08:05:29.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24565" PostTypeId="2" ParentId="24559" CreationDate="2016-05-25T07:59:04.737" Score="3" Body="&lt;p&gt;This is not a direct answer to the question. Instead, I suggest that you&#xA;do not need an RTOS to do what you want. A lightweight alternative is to&#xA;use &lt;code&gt;millis()&lt;/code&gt; to decide when it is time to perform such or such task:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    uint32_t now = millis();&#xA;&#xA;    // Update the LCD every second.&#xA;    static uint32_t last_lcd_update;&#xA;    if (now - last_lcd_update &amp;gt;= 1000) {&#xA;        last_lcd_update = now;&#xA;        update_lcd();&#xA;    }&#xA;&#xA;    // Read the analog inputs every 300 ms.&#xA;    static uint32_t last_analog_read;&#xA;    if (now - last_analog_read &amp;gt;= 300) {&#xA;        last_analog_read = now;&#xA;        do_analog_read();&#xA;    }&#xA;&#xA;    // User input is handled continuously.&#xA;    handle_user_input();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will use significantly less resources (flash, RAM and CPU time)&#xA;than an RTOS. Another advantage is that you do not need to determine a&#xA;stack size for each task, which is definitely &lt;em&gt;not&lt;/em&gt; a simple thing to&#xA;do.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-25T07:59:04.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24566" PostTypeId="2" ParentId="24563" CreationDate="2016-05-25T08:32:58.383" Score="1" Body="&lt;p&gt;Yes, you can, as long as you serialize the send/receive pulse cycles, to avoid interferences.&#xA;basically, you attach the Trig/Echo lines to a different pair of pins, then do the reading on one sensor, then do the reading on the other.&lt;/p&gt;&#xA;" OwnerUserId="1675" LastActivityDate="2016-05-25T08:32:58.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24568" PostTypeId="2" ParentId="22026" CreationDate="2016-05-25T09:03:36.283" Score="1" Body="&lt;p&gt;I have put in a lot of time with the SIM808, and I always have trouble delivering enough power to it.  Note that the SIM808 will alert you with an &quot;undervoltage warning&quot; sometimes as a response to AT commands.  I bet the SIM800 would do the same.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Max above is alluding to - try powering the SIM800L via a separate 5V 2A adapter.  When doing this don't forget to still hook up ground between the Uno and your SIM800L board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you accidentally hooked 5V to the VDD pin on your module, you may have damaged it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FTDI is a tool every embedded dev should have.  Get a few!&lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-05-25T09:03:36.283" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24573" PostTypeId="1" CreationDate="2016-05-25T12:18:21.797" Score="0" ViewCount="9903" Body="&lt;p&gt;I did a bit of playing with my new ESP-12e, but suddenly it kind of fails on me. It gives me some weird looks it didn't give me (as much) before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/L6EUc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/L6EUc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This is what the Serial Monitor prints when I try to run a very simple sketch.&lt;/strong&gt; When I restart the module, it just adds some more of these chars.&#xA;&lt;strong&gt;The following is the code for that:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int statusLED = 16;&#xA;&#xA;void setup() {&#xA;  pinMode(statusLED, OUTPUT);&#xA;  digitalWrite(statusLED, HIGH);&#xA;&#xA;  Serial.begin(115200);&#xA;  Serial.write(&quot;The ESP-12e has started.&quot;);&#xA;  delay(500);&#xA;}&#xA;&#xA;void loop() {&#xA;  delay(1000);&#xA;  digitalWrite(statusLED, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(statusLED, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This doesn't even involve the WIFI...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;These are my board settings:&lt;/strong&gt;&lt;br/&gt;&#xA;&lt;em&gt;Board: Generic ESP8266 Module&lt;br/&gt;&#xA;Flash mode: QIO&lt;br/&gt;&#xA;Flash frequency: 40MHz&lt;br/&gt;&#xA;CPU frequency: 80MHz&lt;br/&gt;&#xA;Flash size: 4M (3M SPIFFS)&lt;br/&gt;&#xA;Upload speed: 115200&lt;/em&gt;&lt;br/&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And finally, if it might help, how I connected the module:&lt;/strong&gt;&lt;br/&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/6Wn1U.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6Wn1U.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;All connections are solid, so that shouldn't be a problem. &lt;em&gt;The connection board has GPIO15 printed on it twice, but the one I connected to the LED is actually GPIO16.&lt;/em&gt; I noticed that the onboard LED of the ESP-12e doesn't light on anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use the CP2102 USB to UART module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;br/&gt;&#xA;Rogier&lt;/p&gt;&#xA;" OwnerUserId="21402" LastEditorUserId="21402" LastEditDate="2016-05-31T18:23:23.567" LastActivityDate="2018-02-13T17:26:08.087" Title="Weird characters in Serial Monitor and not functioning ESP8266 ESP-12e" Tags="|serial|esp8266|ide|" AnswerCount="1" CommentCount="18" ContentLicense="CC BY-SA 3.0" />
  <row Id="24575" PostTypeId="2" ParentId="24563" CreationDate="2016-05-25T13:24:14.437" Score="1" Body="&lt;p&gt;What you need to do, for each sensor, is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;choose a GPIO that will drive the trigger line (make sure it is not a pin you are already planning to use, ex: TX/RX )&lt;/li&gt;&#xA;&lt;li&gt;choose a pin that will receive the information from the Echo line, ideally using an interrupt driven implementation, instead of polling. The 328P supports exactly 2 independent interrupt lines: INT0 and INT1, so you could use one of them for each sensor.&lt;/li&gt;&#xA;&lt;li&gt;have a time base and use it to time-stamp the Trig and Echo lines&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Example for one sensor (for 2 just do the same and keep in mind that there might be interferences, like the OP said):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;toggle the Trig line for the required duration (strobe)and save it&lt;/li&gt;&#xA;&lt;li&gt;read the time &lt;/li&gt;&#xA;&lt;li&gt;wait for the interrupt to occur (you can do other things in the meanwhile)&lt;/li&gt;&#xA;&lt;li&gt;when the interrupt occurs, read again the time&lt;/li&gt;&#xA;&lt;li&gt;subtract the timestamp taken after toggling Trig from the timestamp taken after the Echo interrupt&lt;/li&gt;&#xA;&lt;li&gt;convert the delta time from the previous point into a linear measure, using the constant provided by the datasheet of the sensor&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7856" LastActivityDate="2016-05-25T13:24:14.437" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24576" PostTypeId="2" ParentId="24573" CreationDate="2016-05-25T13:59:44.460" Score="2" Body="&lt;p&gt;Check what baud rate is serial window displaying. It should be the same as defined in your code. &lt;/p&gt;&#xA;" OwnerUserId="17211" LastActivityDate="2016-05-25T13:59:44.460" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24577" PostTypeId="2" ParentId="24368" CreationDate="2016-05-25T14:10:49.227" Score="0" Body="&lt;p&gt;Warning: I do not have a ATtiny85 nor the lcd so this is purely based on what I found after some reading up on this mcu.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would do in your situation:&#xA;As the trinket is using a ATtiny85 it does not have hardware serial. So a software variant is needed.&lt;br&gt;&#xA;You opted for software serial (which is the most obvous in Arduino world) but which seems to be the hardest solution. &#xA;According to this source &lt;a href=&quot;http://www.ernstc.dk/arduino/tinycom.html&quot; rel=&quot;nofollow&quot;&gt;Serial communication with the Tiny's&lt;/a&gt; is is possible (And I quote)  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;you might have to tune the internal oscillator to get a stable&#xA;  connection.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Assuming your lcd does not need to send data back; I would try the TinyDebugSerial.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="10794" LastEditDate="2016-05-28T09:08:17.310" LastActivityDate="2016-05-28T09:08:17.310" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24578" PostTypeId="1" AcceptedAnswerId="24582" CreationDate="2016-05-25T14:29:10.190" Score="1" ViewCount="1720" Body="&lt;p&gt;How can I filter a garbage completely blank line over my serial data? It comes from the wifi module ESP8266&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I read data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  while (Serial1.available()){&#xA;       String inData = Serial1.readStringUntil('\n');&#xA;&#xA;       Serial.println(&quot;Got: &quot; + inData); &#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my common output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Got: AT+CIPSEND=6&#xA;Got: &#xA;Got: OK&#xA;Got: &amp;gt; &#xA;Got: Recv 6 bytes&#xA;Got: &#xA;Got: SEND OK&#xA;Got: &#xA;Got: +IPD,21:Volume From: 99 To 89AT+CIPCLOSE&#xA;Got: CLOSED&#xA;Got: &#xA;Got: OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3626" LastEditorUserId="3626" LastEditDate="2016-05-25T15:17:59.923" LastActivityDate="2016-05-25T16:23:08.097" Title="How to filter a blank line received over serial - ESP8266" Tags="|serial|esp8266|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24579" PostTypeId="2" ParentId="22189" CreationDate="2016-05-25T15:18:24.313" Score="1" Body="&lt;p&gt;I also tested 27BYJ-48 stepper motor with &lt;a href=&quot;http://www.instructables.com/id/BYJ48-Stepper-Motor/&quot; rel=&quot;nofollow&quot;&gt;instructables&lt;/a&gt; source code. It works but I had the same &quot;complete revolution&quot; problem.&#xA;They compute on their website that a revolution contains 4096 steps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As @James said, indeed, there is gearing inside the stepper motor.&#xA;The problem is the gearing could be different for the exact same reference !&#xA;Everything is described here : &lt;a href=&quot;https://grahamwideman.wikispaces.com/Motors-+28BYJ-48+Stepper+motor+notes&quot; rel=&quot;nofollow&quot;&gt;28BYJ-48&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21405" LastActivityDate="2016-05-25T15:18:24.313" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24580" PostTypeId="2" ParentId="24492" CreationDate="2016-05-25T15:28:03.107" Score="1" Body="&lt;p&gt;That &lt;a href=&quot;https://www.youtube.com/watch?v=vkvkfcqEUkk&quot; rel=&quot;nofollow&quot;&gt;video&lt;/a&gt; shows a Bluetooth connection between the smartphone and the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(A USB connection between the smartphone and the Arduino might be better in some ways).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;details&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;If you want more information after watching a video like this, click the &quot;show more&quot; button underneath the video to see the details.&#xA;Those details clearly say &quot;The Nexus S device connects to the IOIO board via Bluetooth, and uses the smartphone's camera in conjunction with OpenCV and the external IR sensors to control the vehicle.&quot;&#xA;Those details also include a link to&#xA;&quot;Android Based Robotics&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The OpenCV image processing software runs on the smartphone. In this autonomous application, the image data never leaves the smartphone. The software on the smartphone reduces the image data to two integers -- the X,Y pixel location of the center of the green ball.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino and the Bluetooth link can easily handle a few integers at over 200 Hz. Neither one is suitable for handling live video data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino could probably act as the controller.&#xA;The camera could send the X,Y pixel location of the green ball to the Arduino; while the Arduino collects all the other sensor data; then the Arduino could use that to decide what to do; then send the appropriate control signals to the motor drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, in this autonomous toy car it appears that the the smart phone acts as a controller.&#xA;The Arduino collects all the other sensor data, forwards that data to the smartphone; then software on the smart phone takes that data and the X,Y pixel location of the green ball; then the smartphone decides what motors need to turn; then the smartphone sends the appropriate commands to the Arduino, and the Arduino demultiplexes those commands to the motor drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For even more details on building robots using smartphones and Arduino, see&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Android Based Robotics&quot; ( &lt;a href=&quot;http://www.socsci.uci.edu/~jkrichma/ABR/&quot; rel=&quot;nofollow&quot;&gt;http://www.socsci.uci.edu/~jkrichma/ABR/&lt;/a&gt; ).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The Tinkernut video&#xA;&quot;DIY Smartphone Controlled RC Car&quot; ( &lt;a href=&quot;https://www.youtube.com/watch?v=xsJ7176fLNw&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=xsJ7176fLNw&lt;/a&gt; )&#xA;goes into more details of how to connect a smartphone to an Arduino via Bluetooth.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Android Based Robotics: ground robot manual&#xA;( &lt;a href=&quot;https://groups.google.com/forum/#!topic/android-based-robotics/_H8Zmvbxx-M&quot; rel=&quot;nofollow&quot;&gt;https://groups.google.com/forum/#!topic/android-based-robotics/_H8Zmvbxx-M&lt;/a&gt; )&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;Simple RC car for beginners (Android control via Bluetooth)&quot;&#xA;( &lt;a href=&quot;http://solderer.tv/cxemcar/&quot; rel=&quot;nofollow&quot;&gt;http://solderer.tv/cxemcar/&lt;/a&gt; ) ( via &lt;a href=&quot;http://english.cxem.net/&quot; rel=&quot;nofollow&quot;&gt;http://english.cxem.net/&lt;/a&gt; ).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://www.allaboutcircuits.com/projects/communicate-with-your-arduino-through-android/&quot; rel=&quot;nofollow&quot;&gt;Communicate with Your Arduino Through Android&lt;/a&gt; (using USB cable)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.arduinocommander.info/&quot; rel=&quot;nofollow&quot;&gt;ArduinoCommander&lt;/a&gt;:&#xA;&quot;Control your Arduino board from your Android device over Bluetooth, Ethernet or USB&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2016-05-25T15:28:03.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24582" PostTypeId="2" ParentId="24578" CreationDate="2016-05-25T16:23:08.097" Score="1" Body="&lt;pre&gt;&lt;code&gt;inData.trim();&#xA;if( inData.length() &amp;gt; 0 ){&#xA;   Serial.println(&quot;Got: &quot; + inData + &quot;\n&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;::trim() removes all leading and trailing whitespace characters including newlines. A line of [zero or more whitespace] + [newline] will get trimmed to the null string. If the result isn't null, then append the stripped off newline and print it. Note that this will flatten any indentation or vertical spacing that was supplied in the incoming text.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-25T16:23:08.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24584" PostTypeId="1" AcceptedAnswerId="24604" CreationDate="2016-05-25T18:30:32.283" Score="0" ViewCount="467" Body="&lt;p&gt;I have a GSM shield for my arduino and am wondering the most efficient way to receive and send data to the cloud. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific project I am looking to accomplish is starting my car from a web browser (or custom built ionic mobile app) that will send data to my GSM shielded arduino and the arduino then &quot;press the button&quot; of an already installed remote car starter (which is all probably in the car's trunk). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is more power efficient, sending and receiving a SMS (text message) or sending and receiving data via GPRS?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is best when considering strategies like sleep, or deep sleep cycles?&lt;/p&gt;&#xA;" OwnerUserId="21409" LastActivityDate="2018-12-13T04:27:41.573" Title="What is more power efficient: GPRS or SMS for a GSM sim Arduino application?" Tags="|gsm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24585" PostTypeId="1" CreationDate="2016-05-25T21:22:20.053" Score="0" ViewCount="440" Body="&lt;p&gt;i try to program use the GSM shield Arduino with Arduino UNO i did it successfully but after that i try to use GPS shield but when i add the #include  for the program i got the error  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;GSM.h&amp;gt;&#xA;#include &amp;lt;TinyGPS.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt; // when i add that one i got the output eroor &#xA;// PIN Number for the SIM&#xA;#define PINNUMBER &quot;&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;i got this error out put &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.6 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;libraries/SoftwareSerial/SoftwareSerial.cpp.o: In function `__vector_3':&#xA;/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp:227: multiple definition of `__vector_3'&#xA;libraries/GSM/GSM3SoftSerial.cpp.o:/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3SoftSerial.cpp:499: first defined here&#xA;libraries/SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':&#xA;/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp:392: multiple definition of `__vector_4'&#xA;libraries/GSM/GSM3SoftSerial.cpp.o:/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3SoftSerial.cpp:487: first defined here&#xA;libraries/SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':&#xA;/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SoftwareSerial/SoftwareSerial.cpp:392: multiple definition of `__vector_5'&#xA;libraries/GSM/GSM3SoftSerial.cpp.o:/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3SoftSerial.cpp:487: first defined here&#xA;collect2: error: ld returned 1 exit status&#xA;exit status 1&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15318" LastEditorUserId="14737" LastEditDate="2016-05-25T21:35:24.677" LastActivityDate="2016-12-23T00:47:07.867" Title="problem using GSM shield and GPS shield in one Arduino UNO R3" Tags="|gsm|tinygps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24586" PostTypeId="2" ParentId="24555" CreationDate="2016-05-25T21:59:48.417" Score="1" Body="&lt;p&gt;I am also in the middle of converting the control of my heating, multi-zone, but using Ciseco / Wirelessthings units as temperature sensors both inside and out. See &lt;a href=&quot;https://www.wirelessthings.net&quot; rel=&quot;nofollow&quot;&gt;https://www.wirelessthings.net&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple serial interface is all you need from the Arduino to run these on a network. The coin cell battery lasts for over 1 year running 1 sample / 10min - the sample rate is configured but obviously the more samples you send the more the battery drains. Range seems to be OK and gets through 3 floors in the house and from the outside. I do use external antenna on the Arduino wireless unit to ensure I get all of the sensor readings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However sounds like your house is BIG if running 3x WIFI extensions where as a single WIFI base station does me fine.&lt;/p&gt;&#xA;" OwnerUserId="21413" LastActivityDate="2016-05-25T21:59:48.417" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24588" PostTypeId="2" ParentId="24585" CreationDate="2016-05-25T23:10:27.580" Score="1" Body="&lt;p&gt;It appears the GSM library has its own conflicting copy of SoftwareSerial, and not necessarily a matching version unless you're lucky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not sure how well this would work but you can try removing the library reference to SoftwareSerial, and fiddle about to use the GSM library's SoftwareSerial.  &lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-05-25T23:10:27.580" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24591" PostTypeId="1" CreationDate="2016-05-26T01:29:16.283" Score="0" ViewCount="285" Body="&lt;p&gt;Hi I am trying to write a functiont that will build a 2x4 array based on 2 1x4 arrays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the two relevant functions are below. The first function gets information from some sensors and outputs it (I think) as a 1x4 array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second function is the problem and I have attached the error messages.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;double quatCalib_mat[2][4];&#xA;double quatCalib_ABC[4];&#xA;double quatCalib_GHI[4];   &#xA;&#xA; double  get_quat(Adafruit_BNO055 ref, double quatArray[])&#xA;{&#xA;  imu::Quaternion quat2 = ref.getQuat();&#xA;&#xA;  quatArray[0]= quat2.w();&#xA;  quatArray[1]= quat2.x();&#xA;  quatArray[2]= quat2.y();&#xA;  quatArray[3] =quat2.z();&#xA;&#xA;}&#xA;&#xA;void Calibrate()&#xA;{&#xA;quatCalib_ABC=get_quat(bnoABC, quatCalib_ABC);&#xA;&#xA;quatCalib_GHI=get_quat(bnoGHI, quatCalib_GHI);&#xA;&#xA;quatCalib_mat= {&#xA;  {quatCalib_ABC},&#xA;  {quatCalib_GHI}&#xA;  };&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the error messages&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.9 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;E:\UNI2016\thesis\gizmo programming\Thesis_V3_M\Thesis_V3_M.ino: In function 'void Calibrate()':&#xA;&#xA;Thesis_V3_M:101: error: incompatible types in assignment of 'double' to 'double [4]'&#xA;&#xA; quatCalib_ABC=get_quat(bnoABC, quatCalib_ABC);&#xA;&#xA;              ^&#xA;&#xA;Thesis_V3_M:103: error: incompatible types in assignment of 'double' to 'double [4]'&#xA;&#xA; quatCalib_GHI=get_quat(bnoGHI, quatCalib_GHI);&#xA;&#xA;              ^&#xA;&#xA;Thesis_V3_M:105: error: assigning to an array from an initializer list&#xA;&#xA; quatCalib_mat= {&#xA;&#xA;              ^&#xA;&#xA;exit status 1&#xA;incompatible types in assignment of 'double' to 'double [4]'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alex&lt;/p&gt;&#xA;" OwnerUserId="21419" LastEditorUserId="6628" LastEditDate="2016-05-26T03:35:22.880" LastActivityDate="2016-05-26T08:30:46.230" Title="Building Multidimensional Arrays from simple arrays" Tags="|array|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24593" PostTypeId="1" CreationDate="2016-05-26T02:41:31.420" Score="0" ViewCount="731" Body="&lt;p&gt;I connected a HC-SR04 Ultrasonic Sensor to Arduino Uno and built the circuit as shown in the link below. I also used the code below the link. Together, this code and the circuit detect any motion that occurs in front of the ultrasonic sensor. When the sensor detects motion, the console in the Arduino IDE prints that it detects motion and how far away the moving object is. Otherwise, nothing is printed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I created an app using MIT App Inventor. Every time the Arduino detects motion, I want a sound to be played on the phone of the person with the app. In order to do this, I plan on using a HC-05 Bluetooth Module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestions for how I should build the circuit and what code I should use?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arduinobasics.blogspot.de/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define echoPin 7 // Echo Pin&#xA;#define trigPin 8 // Trigger Pin&#xA;#define LEDPin 13 // Onboard LED&#xA;&#xA;int maximumRange = 200; // Maximum range needed&#xA;int minimumRange = 0; // Minimum range needed&#xA;long duration, distance; // Duration used to calculate distance&#xA;&#xA;void setup() {&#xA; Serial.begin (9600);&#xA; pinMode(trigPin, OUTPUT);&#xA; pinMode(echoPin, INPUT);&#xA; pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)&#xA;}&#xA;&#xA;int prevdist = 0;&#xA;&#xA;void loop() {&#xA;/* The following trigPin/echoPin cycle is used to determine the&#xA; distance of the nearest object by bouncing soundwaves off of it. */ &#xA; digitalWrite(trigPin, LOW); &#xA; delayMicroseconds(2); &#xA;&#xA; digitalWrite(trigPin, HIGH);&#xA; delayMicroseconds(10); &#xA;&#xA; digitalWrite(trigPin, LOW);&#xA; duration = pulseIn(echoPin, HIGH);&#xA;&#xA; //Calculate the distance (in cm) based on the speed of sound.&#xA; distance = duration/58.2;&#xA;&#xA; if (distance &amp;gt;= maximumRange || distance &amp;lt;= minimumRange){&#xA; //Print &quot;Out of range when there is no object within the range of the ultrasonic sensor.&#xA; Serial.println(&quot;Out of range.&quot;);&#xA; digitalWrite(LEDPin, HIGH); &#xA;&#xA; }&#xA; else {&#xA;&#xA; /* Send the distance to the computer using Serial protocol, and&#xA; turn LED OFF to indicate successful reading. */&#xA;&#xA;   if((prevdist - distance) &amp;gt; 10 || (prevdist - distance) &amp;lt; -10)&#xA;   {&#xA;     prevdist = distance;&#xA;     Serial.println(&quot;[OBJECT MOVED]&quot;);&#xA;     Serial.print(&quot;Detecting object &quot;);&#xA;     Serial.print(distance);&#xA;     Serial.println(&quot; cm away&quot;);&#xA;     Serial.println();&#xA;     digitalWrite(LEDPin, LOW);&#xA;   }  &#xA; }&#xA;&#xA; //Delay 1 millisecond before next reading.&#xA; delay(1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21315" LastEditorUserId="13432" LastEditDate="2016-05-26T07:48:59.690" LastActivityDate="2016-07-25T09:47:34.373" Title="Using HC-05 to play a sound on an app" Tags="|arduino-uno|arduino-ide|bluetooth|hc-05|hc-sr04|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24595" PostTypeId="2" ParentId="1270" CreationDate="2016-05-26T02:59:06.510" Score="1" Body="&lt;p&gt;I was found solution with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial.setTimeout(100);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like this (&lt;a href=&quot;https://www.arduino.cc/en/Serial/SetTimeout&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Serial/SetTimeout&lt;/a&gt;) setTimeout was 1000ms default.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the check serial port per 1000ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I referenced this &lt;a href=&quot;https://stackoverflow.com/a/28892086/929740&quot;&gt;https://stackoverflow.com/a/28892086/929740&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21422" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-05-26T02:59:06.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24597" PostTypeId="2" ParentId="14489" CreationDate="2016-05-26T05:46:18.140" Score="1" Body="&lt;p&gt;I ran into the same question, except I wanted to put 8 of the HC-SR04 sensors on pro-mini.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used an I2C pin expander for the triggers, and an octal OR/NOR chip to multiplex the return.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Library, examples and pictures&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/arielnh56/SonarI2C&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arielnh56/SonarI2C&lt;/a&gt;&#xA;&lt;a href=&quot;http://redhunter.com/blog/2016/04/28/sonari2c-multiple-hc-sr04-sensors-on-arduino-i2c/&quot; rel=&quot;nofollow&quot;&gt;http://redhunter.com/blog/2016/04/28/sonari2c-multiple-hc-sr04-sensors-on-arduino-i2c/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21426" LastActivityDate="2016-05-26T05:46:18.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24600" PostTypeId="2" ParentId="24593" CreationDate="2016-05-26T08:02:38.107" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;Every time the Arduino detects motion, I want a sound to be played on the phone of the person with the app. In order to do this, I plan on using a HC-05 Bluetooth Module.&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any suggestions for how I should build the circuit and what code I should use?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The Arduino sketch above is a good start.&lt;/p&gt;&#xA;&lt;p&gt;The first step is to connect the Bluetooth module so that the Serial output can be sent. The circuit is simply connecting the Bluetooth module to RX/TX on the Arduino. I am assuming that you have written an app that can read from Bluetooth on the phone and write to the screen.&lt;/p&gt;&#xA;&lt;p&gt;The second step is to parse the output and play the sound. That is also part of the app and not the code on the Arduino. To make this easier the sketch output statements can be changed to something easier to parse (detect).&lt;/p&gt;&#xA;&lt;p&gt;All and all the work is mainly app programming.&lt;/p&gt;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-26T08:02:38.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24601" PostTypeId="2" ParentId="24591" CreationDate="2016-05-26T08:30:46.230" Score="1" Body="&lt;p&gt;As Mikael Patel said, the compiler is already hinting you about what is&#xA;wrong. But there are other issues.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In &lt;code&gt;get_quat()&lt;/code&gt;, there is no point in returning anything, as the&#xA;function is already putting the relevant info in the &lt;code&gt;quatArray&lt;/code&gt;&#xA;parameter.&lt;/li&gt;&#xA;&lt;li&gt;Then, when calling &lt;code&gt;get_quat()&lt;/code&gt;, you don't want to assign the return&#xA;value to anything.&lt;/li&gt;&#xA;&lt;li&gt;You cannot assign an array like you did, unless it's an&#xA;initialization. I would explicitly copy the sub-arrays with&#xA;&lt;code&gt;memcpy()&lt;/code&gt;:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void get_quat(Adafruit_BNO055 ref, double quatArray[])&#xA;{&#xA;    imu::Quaternion quat2 = ref.getQuat();&#xA;    quatArray[0] = quat2.w();&#xA;    quatArray[1] = quat2.x();&#xA;    quatArray[2] = quat2.y();&#xA;    quatArray[3] = quat2.z();&#xA;}&#xA;&#xA;void Calibrate()&#xA;{&#xA;    get_quat(bnoABC, quatCalib_ABC);&#xA;    get_quat(bnoGHI, quatCalib_GHI);&#xA;    memcpy(quatCalib_mat[0], quatCalib_ABC, sizeof quatCalib_ABC);&#xA;    memcpy(quatCalib_mat[1], quatCalib_GHI, sizeof quatCalib_GHI);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It could be noted that storing the calibration array twice (as both one&#xA;2D array and two 1D arrays) is a waste of RAM. You could get rid of the&#xA;1D arrays and have instead &lt;code&gt;get_quat()&lt;/code&gt; fill the lines of the 2D array&#xA;directly:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void Calibrate()&#xA;{&#xA;    get_quat(bnoABC, quatCalib_mat[0]);&#xA;    get_quat(bnoGHI, quatCalib_mat[1]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-26T08:30:46.230" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24602" PostTypeId="1" AcceptedAnswerId="24603" CreationDate="2016-05-26T09:39:38.057" Score="0" ViewCount="3489" Body="&lt;p&gt;I have a problem and I can't fix it.&#xA;I'm busy with an java to arduino project.&lt;/p&gt;&#xA;&lt;p&gt;Java writes a string using writeString();&#xA;Arduino reads the serial monitor and put the incoming string into a function.&lt;/p&gt;&#xA;&lt;p&gt;then I want to put the string into a variable and the variable into a char arr[];&lt;/p&gt;&#xA;&lt;p&gt;The problem is: When I put the string directly in the arr[]; it works, but when I put first the incoming string in a variable and then the variable in the arr[]; it gives me the next error:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;string-parser:44: error: array must be initialized with a brace-enclosed initializer&lt;/p&gt;&#xA;&lt;p&gt;exit status 1&lt;/p&gt;&#xA;&lt;p&gt;initializer fails to determine size of 'arr'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;this is the code that doesnt work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;input = &amp;quot;2,5&amp;gt;2,6&amp;gt;2,7&amp;gt;4,8&amp;quot;;&#xA;&#xA;String splitStringIntoCoordinates(String input){&#xA;  char arr[] = input; // Place incoming route in char array&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is the code that does work:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;String splitStringIntoCoordinates(String input){&#xA;  char arr[] = &amp;quot;2,5&amp;gt;2,6&amp;gt;2,7&amp;gt;4,8&amp;quot;; // Place incoming route in char array&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I hope anyone can help me.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="21432" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-26T09:48:43.013" Title="Arduino: put string through variable in array" Tags="|arduino-uno|serial|c|string|array|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24603" PostTypeId="2" ParentId="24602" CreationDate="2016-05-26T09:48:43.013" Score="0" Body="&lt;p&gt;A String isn't a char array. You can't assign one to the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You shouldn't be using String, it's too heavyweight, and how you are passing your String object is wrong, it wastes huge amounts of memory making clones.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should read &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/04/the-evils-of-arduino-strings/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only time you should ever consider using a String object is if you are using a third party library that requires a String object - and even then you should consider other methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless of that, you need to copy the &lt;em&gt;content&lt;/em&gt; of your string, not the string itself.  This code &lt;em&gt;should&lt;/em&gt; work, but it doesn't address the underlying String issues:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String splitStringIntoCoordinates(String &amp;amp;input){&#xA;  char arr[input.length() + 1]; // Create a char array big enough including the terminating NULL&#xA;  strcpy(arr, input.c_str()); // Place incoming route in char array&#xA;  // ... etc ...&#xA;  // return a string&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you just want to reference the String as a C string you can just use the function &lt;code&gt;input.c_str()&lt;/code&gt; to get the internal &lt;code&gt;char *&lt;/code&gt; array pointer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-26T09:48:43.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24604" PostTypeId="2" ParentId="24584" CreationDate="2016-05-26T09:59:59.507" Score="1" Body="&lt;p&gt;Looking at it logically SMS is probably the most power efficient method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thinking is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;With SMS:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The shield sits there connected to the mobile network doing nothing much&lt;/li&gt;&#xA;&lt;li&gt;An SMS is sent by you which travels through the mobile network&lt;/li&gt;&#xA;&lt;li&gt;The SMS is sent from the mobile network to your GSM shield which then wakes up and does things with it&lt;/li&gt;&#xA;&lt;li&gt;The shield sits there connected to the mobile network doing nothing much&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;With GPRS:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service and sees a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield downloads the request&lt;/li&gt;&#xA;&lt;li&gt;The shield acts on the request&lt;/li&gt;&#xA;&lt;li&gt;The shield goes back to querying the on-line service&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;The shield queries an on-line service to see if a request is available&lt;/li&gt;&#xA;&lt;li&gt;... etc ad nausium ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As you can see with SMS the onus is on the mobile network to send the data to the shield, whereas with GPRS the onus is on the shield to keep querying an on-line service to see if there is any requests to handle. There is no way of you sending data to the shield directly (indeed, most GPRS services include at least one layer of NAT gatewaying). So your shield has to be active all the time and constantly looking at something online - not only power hungry, but potentially financially expensive too. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-26T09:59:59.507" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24606" PostTypeId="1" AcceptedAnswerId="24607" CreationDate="2016-05-26T11:47:47.097" Score="1" ViewCount="4420" Body="&lt;p&gt;I just need some confirmation, before I break something. So far I have been powering my project from USB, no I would like to power it from a battery. The official spec claims I should use a voltage anywhere from 7-12V, so I got myself a 9V block battery and would connect the positive lead to the VIN pin and the negative lead to the ground pin right next to it, based on this schematic: &lt;a href=&quot;https://40.media.tumblr.com/cdadca4e95808b376de52a88a5468367/tumblr_mi61oww6cu1s5t695o1_1280.png&quot; rel=&quot;nofollow&quot;&gt;https://40.media.tumblr.com/cdadca4e95808b376de52a88a5468367/tumblr_mi61oww6cu1s5t695o1_1280.png&lt;/a&gt;&#xA;Do I need a resistor?&lt;/p&gt;&#xA;" OwnerUserId="15349" LastActivityDate="2016-05-26T13:00:57.607" Title="How do I power my Arduino Micro directly?" Tags="|battery|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24607" PostTypeId="2" ParentId="24606" CreationDate="2016-05-26T13:00:57.607" Score="3" Body="&lt;p&gt;According to &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; schematic, VIN goes to the on arduino-micro's 5 and 3 volt regulators.  So you should not need a resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 5 volt regulator needs a bit more than 5 volts at it's input to do a good job.  That is why the specification calls for 7 to 12 volts.  &lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-26T13:00:57.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24610" PostTypeId="1" CreationDate="2016-05-26T14:24:56.980" Score="2" ViewCount="774" Body="&lt;p&gt;this was the error  message&#xA;Arduino: 1.6.7 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 1,068 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: ser_open(): can't open device &quot;\.\COM17&quot;: The semaphore timeout period has expired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&#xA;&lt;strong&gt;Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\leddelay: C:\Users\nehal\Documents\Arduino\libraries\leddelay&#xA;Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c: C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c&#xA;Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\leddelay: C:\Users\nehal\Documents\Arduino\libraries\leddelay&#xA;Invalid library found in C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c: C:\Users\nehal\Documents\Arduino\libraries\sketch_jan16c&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &gt; Preferences.&#xA; &lt;strong&gt;What should I do?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="21441" LastActivityDate="2016-05-26T14:24:56.980" Title="I am not able to compile,libraries missing" Tags="|arduino-uno|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24611" PostTypeId="1" AcceptedAnswerId="34985" CreationDate="2016-05-26T16:21:03.287" Score="0" ViewCount="598" Body="&lt;p&gt;Basically, I want an Arduino to power up whenever a &quot;creature&quot; enters viscinity (at least within up to 3 meters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would really like this to be able to keep monitoring for at least 4-8 weeks, without having to replace batteries. I don't want to use more than 1 or 2 18650 Liion cells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Couple of methods that I believe would work:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Changes in light-conditions.&lt;/li&gt;&#xA;&lt;li&gt;Sound.&lt;/li&gt;&#xA;&lt;li&gt;Small vibrations in the ground.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Approaches to conserve power:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Checking for changes in light at most every 30 seconds (boot the Arduino, and power off quickly).&lt;/li&gt;&#xA;&lt;li&gt;Checking for 1 second for sound, every 10-15 seconds.&lt;/li&gt;&#xA;&lt;li&gt;Vibrations in the ground using an accelerometer?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The ideal solution does not run the Arduino at all, unless a trigger causes it to run. When the Arduino starts, it will have to turn itself off again to resume monitoring mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What approach should I go for? I'm not very good with electronics, and would like to avoid configurations involving transistors, resistors and so on - unless stricktly required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible/easy to wire an Arduino Pro Mini to run directly off a 3.7 V battery, bypassing any power hungry voltage regulators?&lt;/p&gt;&#xA;" OwnerUserId="1379" LastActivityDate="2017-02-22T20:30:02.307" Title="Sound or motion activated long term battery powered Arduino" Tags="|power|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24612" PostTypeId="1" CreationDate="2016-05-26T17:34:20.623" Score="3" ViewCount="5694" Body="&lt;p&gt;I have a 10kOhm linear Potentiometer. I connected it to analog 0, as in &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Potentiometer&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Potentiometer&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The analogRead() gives a value between 0 and 1023, so I was expecting 0 if the potentiometer is at the lowest position, 1023 if it is at the highest position and 500 somewhere in the middle. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact I get ~40 at the lowest position, I get 1021 at the highest position (that's okay, I guess), and I also get 1021 at the middle. 500 is at a 1/4 position, I expected to have ~255 there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I measured the resistance of the potentiometer. It reads ~200 Ohm at the lowest postion, 10kOhm (as expected) at the highest position and ~5kOhm in the middle, so, exactly as I expected. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, what did I get wrong? &lt;/p&gt;&#xA;" OwnerUserId="21446" LastActivityDate="2016-05-27T05:10:50.253" Title="Why is my potentiometer giving strange reading?" Tags="|analogread|potentiometer|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="24613" PostTypeId="2" ParentId="17277" CreationDate="2016-05-26T17:39:48.643" Score="0" Body="&lt;p&gt;If you do not need to know the timing when the event occurs with a high resolution, &lt;em&gt;and do not have anything else you need to do&lt;/em&gt;, you can simply delay in short intervals and check the condition in between them.  Of course you will not know when the event occurred more precisely than knowing it happened sometime in the interval since the previous check.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach is to not use the delay mechanism, but rather continually check the input in a loop, and also check the elapsed time so that you can accomplish your periodic events when intervals of time have elapsed.  Do be aware of the &lt;code&gt;millis()&lt;/code&gt; overflow eventuality if taking this approach.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you had important work to do while waiting, you could accomplish the check with a pin change interrupt, and record a timestamp in the interrupt service routine, but if all you would be doing in the foreground is running a delay, this is inferior to the previous approach.  Using an interrupt service routine (or any more elaborate form of threading) also requires care to ensure consistency of data shared between the main and interrupt or alternate thread context.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ultimately the best solution for an actual real-world embedded application like this is typical to try to have the processor in a low powered sleep mode most of the time.  Typically you would have a low power real time clock running, but the processor's high speed clock and associated logic stopped.  Your tilt sensor would be wired as an interrupt that the MCU is configured to wake up to normal operation in response to.  On wakeup, it would read the clock to accomplish a timestamp, then go back to sleep.  You can also use various mechanisms in the real time clock or in the MCU to wake up periodically to announce the passing of time intervals.  Wakeup on a small MCU is typically a fairly efficient process - it can be beneficial in terms of net power consumption to go (at least partially) to sleep even for a fraction of a second.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-26T17:39:48.643" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24614" PostTypeId="1" AcceptedAnswerId="24618" CreationDate="2016-05-26T17:54:32.713" Score="4" ViewCount="2903" Body="&lt;p&gt;How can I generate this pulse with an Arduino Micro?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it necessary an external component?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AlJUI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AlJUI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21445" LastEditorUserId="19515" LastEditDate="2016-05-26T18:11:08.863" LastActivityDate="2016-05-26T19:18:11.733" Title="Generate particular pulse using Arduino" Tags="|arduino-micro|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24616" PostTypeId="2" ParentId="362" CreationDate="2016-05-26T18:36:56.650" Score="0" Body="&lt;p&gt;Arduino IDE and associated libraries are included as installable software in most OS repositories.  Unfortunately the versions in these repositories is usually several months or even years out-of-date.  This would seem that the real problem is in getting OS repository managers to incorporate new releases as they become available.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This problem is compounded when your OS version has not been updated to the latest release, because this forces you to use an outdated software repository.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While not a perfect answer, you should probably insure that you are using the latest release of your OS, and then encourage the repository managers for that OS to incorporate the latest version of Arduino IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative would be to go to the Arduino.org homepage and follow instructions to download and install the latest IDE and associated libraries.  This will probably be in the form of a .tar.gz file so you  will need to know how to unzip, untar, and build the necessary software.&lt;/p&gt;&#xA;" OwnerUserId="21449" LastActivityDate="2016-05-26T18:36:56.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24617" PostTypeId="2" ParentId="24614" CreationDate="2016-05-26T18:46:55.547" Score="5" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BOSdt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BOSdt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If both inputs are 0V, the output will be 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If both inputs are 5V, the output will be 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one input is 0V and one 5V the output will be 2.5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the device attached to the output doesn't have a high input impedance, the voltage will drop some. You could add an opamp to prevent this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you can generate the 2 pins outputs using one of the timers in phase correct pwm mode. Freeing up the cpu and giving a very clean output signal, as using software &quot;pwm&quot; could be slightly of due to interrupts occuring.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-05-26T18:46:55.547" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24618" PostTypeId="2" ParentId="24614" CreationDate="2016-05-26T19:18:11.733" Score="6" Body="&lt;p&gt;Take two 10K or so resistors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    +5V&#xA;     |&#xA;    10K&#xA;     | &#xA;Pin2-+---&amp;gt; output&#xA;     |&#xA;    10K&#xA;     |&#xA;    GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following program does the trick:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t kPin = 2;&#xA;const uint32_t kDelay = 10;  // 100Hz&#xA;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;  pinMode(kPin, OUTPUT);&#xA;  digitalWrite(kPin, HIGH);&#xA;  delay(kDelay);&#xA;&#xA;  pinMode(kPin, INPUT);&#xA;  delay(kDelay);&#xA;&#xA;  pinMode(kPin, OUTPUT);&#xA;  digitalWrite(kPin, LOW);&#xA;  delay(kDelay);&#xA;&#xA;  pinMode(kPin, INPUT);&#xA;  delay(kDelay);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When Pin2 (or any other pin for that matter) is set as &lt;code&gt;INPUT&lt;/code&gt;, it is in high-impedance state (theoretically), so effectively you have a voltage divider giving you 1/2 Vcc. When it is set as &lt;code&gt;OUTPUT&lt;/code&gt;, and now assuming that its output impedance is &amp;lt;&amp;lt; 10KΩ, it drives the output to either +5V or 0V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/b6HB4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/b6HB4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-26T19:18:11.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24619" PostTypeId="2" ParentId="22300" CreationDate="2016-05-26T19:48:06.600" Score="1" Body="&lt;h2&gt;Making Blynk libraries, v0.3.6 and (presumably) later, Eclipse compatible.&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;With much help from Jantje (thank you!), I found 4 easy steps that make the Blynk v0.3.6 libraries Eclipse-compatible:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create &lt;code&gt;.../libraries/Blynk/Blynk.h&lt;/code&gt; (may be empty) and #include it before including any Blynk libraries.&lt;/li&gt;&#xA;&lt;li&gt;Likewise, create and #include &lt;code&gt;.../libraries/BlynkESP8266_Lib/BlynkESP8266_Lib.h&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Delete the entire folder &lt;code&gt;.../libraries/Blynk/linux&lt;/code&gt; (unless you're running Linux! In which case, some more discovery needs doing.)&lt;/li&gt;&#xA;&lt;li&gt;In Blynk projects previously imported to Eclipse Arduino, delete the (possibly hidden) file &lt;code&gt;.ino.cpp&lt;/code&gt; and do a clean build.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This recipe works for me under MacOS 10.11.5, the Eclipse Arduino IDE nightly build, and ArduinoIDE version 1.6.9. It should be reproducible by anyone wishing to compile Blynk programs in Eclipse. Under OSes other than Mac, especially linux, step 3 may need to be modified. I deleted the &lt;code&gt;linux&lt;/code&gt; folder to prevent Eclipse from compiling &lt;code&gt;main.cpp&lt;/code&gt; and &lt;code&gt;BlynkDebug.cpp&lt;/code&gt; from there which was resulting in multiple definition errors at link time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above is an excerpt from a how-to I &lt;a href=&quot;http://community.blynk.cc/t/making-the-blynk-libraries-compatible-with-eclipse/5608&quot; rel=&quot;nofollow&quot;&gt;posted to the Blynk community&lt;/a&gt; but I think this has all of the relevant information.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-26T19:48:06.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24620" PostTypeId="1" AcceptedAnswerId="24621" CreationDate="2016-05-26T20:00:51.407" Score="6" ViewCount="1481" Body="&lt;p&gt;I have an Arduino Due with a SAM3X8E chip and am trying to read SPI data from an external source that is communicating in SPI. I was able to get data by identifying specific bytes that are identifiers but realized that the clock for my board is not synced with the source coming in. I print out the bytes in hexadecimal format (08 00 FF AB etc) and each message is 128 bytes long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, the source is an SPI master that is sending out data on its own MOSI line, but I am currently treating my board as a master as well since I do not know how to do Slave mode on Due. I connect the Slaves MOSI line to my boards MISO line, and just transfer data and read 128 bytes but it would appear that I am not getting the same data. Is there a way for my to take in the clock from the external clock and synchronize my board with that clock to make sure? My source code is below. The only methods I can think of are to either figure out how to implement the board in slave mode (i'm not familiar enough with the registers and how to change this, or read data in slave mode) or synchronize the clocks so my board is reading and sampling the source data correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone check if my thinking is correct, or do I not need to make any changes since the data is in a shift register?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;Serial.begin(9600);&#xA;SPI.begin();&#xA;SPISettings settings (50000000, LSBFIRST, SPI_MODE1); //Sampling rate    50Mhz, source's max speed&#xA;SPI.beginTransaction(settings);&#xA;}&#xA;&#xA;&#xA;void loop(){&#xA;  int i = 0;&#xA;  uint8_t value;&#xA;  value = SPI.transfer(0x00);&#xA;  while (value != 8){//searching for identifier 0x08&#xA;    value = SPI.transfer(0x00);&#xA;  }&#xA;  SPI.transfer(buffer, 127);//get the rest of the 127 bytes&#xA;  Serial.print(value, HEX);&#xA;  Serial.print(&quot; &quot;);&#xA;  for (i = 0; i &amp;lt; 127; i++){&#xA;    if (buffer[i] == 0){&#xA;      Serial.print(buffer[i],HEX);&#xA;      Serial.print(0, HEX);&#xA;    }&#xA;    else{&#xA;      Serial.print(buffer[i], HEX);&#xA;    }&#xA;    Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.println(&quot;\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21451" LastEditorUserId="4143" LastEditDate="2016-05-26T22:18:25.950" LastActivityDate="2016-05-28T17:40:14.087" Title="Syncing/taking external clock for SPI on Arduino Due" Tags="|arduino-due|spi|oscillator-clock|timing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24621" PostTypeId="2" ParentId="24620" CreationDate="2016-05-26T21:00:45.327" Score="3" Body="&lt;p&gt;For your external source to be an SPI bus master, it has to be the only one generating the clock signal. Yet, calling &lt;code&gt;SPI.transfer()&lt;/code&gt; also generates a clock signal &lt;em&gt;from the Arduino&lt;/em&gt;; both devices are attempting to drive the clock line simultaneously, hence your problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to bit-bang this or manipulate the SAM registers yourself to configure it as a slave; the SPI library doesn't support slave mode.&#xA;In order to bit-bang, you'll have to define your own MOSI, SCK, SS (and MISO, if you'll be writing to the master) pins and do all the sampling yourself with &lt;code&gt;digitalRead()&lt;/code&gt;; there are no registers to be read from since you aren't using the SAM's SPI peripheral. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since your SPI mode is MODE 1, it means the clock idle polarity is LOW, and that data is sampled on the falling edge. To bit-bang with &lt;code&gt;digitalRead()&lt;/code&gt;, it is necessary that the SCK frequency be below 50 kHz (&lt;code&gt;digitalRead()&lt;/code&gt; &lt;a href=&quot;http://jeelabs.org/2010/01/06/pin-io-performance/&quot; rel=&quot;nofollow&quot;&gt;takes&lt;/a&gt; about 4us), taking overhead into account. You should use direct port manipulation, if you need a higher frequency. If you'll be blocking till you've read data, and assuming that the external source always sends data in byte units, then a basic algorithm:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Create a &lt;code&gt;byte&lt;/code&gt; array to hold all the expected bytes&lt;/li&gt;&#xA;&lt;li&gt;Define a &lt;code&gt;byte&lt;/code&gt; variable (&lt;code&gt;curr_byte&lt;/code&gt;, maybe) for holding each byte received&lt;/li&gt;&#xA;&lt;li&gt;Wait till the SS pin goes LOW&lt;/li&gt;&#xA;&lt;li&gt;Clear &lt;code&gt;curr_byte&lt;/code&gt; to zero&lt;/li&gt;&#xA;&lt;li&gt;Wait till SCK goes HIGH&lt;/li&gt;&#xA;&lt;li&gt;Wait till SCK goes LOW&lt;/li&gt;&#xA;&lt;li&gt;Read the bit on the MOSI line and shift it into &lt;code&gt;curr_byte&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;If you've received up to 8 bits so far, save &lt;code&gt;curr_byte&lt;/code&gt; to the &lt;code&gt;byte&lt;/code&gt; array; if SS is still LOW, go to step 4, else exit this loop. But if you haven't received a complete byte yet, go to step 5.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;After you leave the loop, you can then confirm the bytes you've received with Serial. If the external device can send data with any number of bits, then you should always check the SS line after you shift in a bit, to determine if the Due has been deselected or not i.e. if there are any more incoming bits.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-05-28T17:40:14.087" LastActivityDate="2016-05-28T17:40:14.087" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24622" PostTypeId="2" ParentId="24612" CreationDate="2016-05-26T21:32:48.717" Score="0" Body="&lt;p&gt;It sounds like you have a &lt;em&gt;log taper&lt;/em&gt; potentiometer rather than a &lt;em&gt;linear taper&lt;/em&gt; potentiometer.  These are used in audio applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can tell the difference by looking at the resistance code.  It may be written as:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;103 B&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;or &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;10K B&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;both of which are 10KΩ LOG taper.  The letter A or B as a suffix is the taper type. A is linear, and B is logarithmic.  That's the &quot;normal&quot; standard, though, but Japan does it differently. They use A for Audio taper (log taper) and B for linear. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-26T21:32:48.717" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24623" PostTypeId="1" AcceptedAnswerId="24624" CreationDate="2016-05-26T22:20:51.930" Score="0" ViewCount="180" Body="&lt;p&gt;I'm using an ATTiny85 with an external 16MHz clock. I accidentally set pins 3 and 4 to output using pinMode() in a program and uploaded it, and now I'm getting an invalid device signature (the signature is 0) error when I try to upload a sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I go about fixing this (if possible)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino UNO as ISP, with an external 16MHz clock and capacitors connected to pins 3 and 4, and have rechecked my wire setup multiple times.&lt;/p&gt;&#xA;" OwnerUserId="13483" LastActivityDate="2016-05-26T23:41:07.167" Title="ATTiny85, how to fix overwritten clock pins?" Tags="|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24624" PostTypeId="2" ParentId="24623" CreationDate="2016-05-26T23:41:07.167" Score="3" Body="&lt;p&gt;Holding the chip in reset while powering it on will ensure that the pins are never reconfigured.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-26T23:41:07.167" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24627" PostTypeId="1" AcceptedAnswerId="24628" CreationDate="2016-05-27T01:53:30.940" Score="0" ViewCount="228" Body="&lt;p&gt;I've downloaded the Arduino IDE and the Genuino isn't in the list of boards. I'm running Rasbian and used the command line to install.  &lt;/p&gt;&#xA;" OwnerUserId="21456" LastActivityDate="2016-05-27T02:13:46.630" Title="Arduino/Genuino not in board list" Tags="|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24628" PostTypeId="2" ParentId="24627" CreationDate="2016-05-27T02:13:46.630" Score="0" Body="&lt;p&gt;&quot;Genuino&quot; is just a name, not an identifier. Pick the equivalent Arduino board from the list.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-05-27T02:13:46.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24632" PostTypeId="1" CreationDate="2016-05-27T04:48:14.217" Score="2" ViewCount="358" Body="&lt;p&gt;I have an HC-05 wired with an Uno, and am using a sketch to control the HC-05 AT mode and send AT commands, per a variant of this instructable:  &lt;a href=&quot;http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/&quot; rel=&quot;nofollow&quot;&gt;DIY Arduino Bluetooth Programming Shield&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The error I have is simple in appearance, when AT mode is signaled off by bringing HC-05 pin 34 low after being high, then a low pulse is sent from the HC-05 to the HC-05 pin 32 which is wired to the Uno reset pin per the instructable.  The low pulse should not be occurring and is triggering the Uno to reset, even though it is only 1-2ms.  The low pulse also occurs when the HC-05 is powered on, neither low pulse occurs if the polar command is reset to normal &quot;1,0&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After receiving the &quot;AT+POLAR=1,1&quot; command the HC-05 pin 32 should trigger low when a BT connection is made to the HC-05, that part works correctly.  The other low pulses triggering the Uno to reset when signaling to leave AT mode and when powering on the HC-05 are causing problems with running the sketch so I need to determine how to stop them.  I have checked the AT settings I am familiar with and they are as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas are appreciated.  Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-05-27T04:48:14.217" Title="Is my HC-05 broken?" Tags="|arduino-uno|hc-05|reset|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24633" PostTypeId="1" CreationDate="2016-05-27T04:48:59.087" Score="0" ViewCount="2275" Body="&lt;p&gt;I want to upload/pubish RAW IR Code to MQTT server received through my ESP8266. I have received the following RAW IR code from the Television using the IR receiver sensor: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RAW IR CODE = {&#xA;  4650,4250, 700,1550, 650,1550, 700,1550, 650,450,&#xA;  650,500, 600,500, 600,500, 600,550, 550,1700, 550,&#xA;  1650, 600,1650, 550,550, 600,500, 600,550, 550,550, &#xA;  600,500, 600,550, 550,1650, 600,550, 550,550, 600,500, &#xA;  600,550, 550,550, 600,500, 600,1650, 600,500, 600,1650, &#xA;  550,1700, 550,1650, 600,1650, 550,1650, 600,1650, 600&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to create a new variable with the following structure: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;value = RAW IR CODE+&quot;;&quot; + &quot;ESP8266-01&quot;(This is the ID of the esp8266) &#xA;&#xA;&#xA;value =  {&#xA;  4650,4250, 700,1550, 650,1550, 700,1550, 650,450, 650,500, &#xA;  600,500, 600,500, 600,550, 550,1700, 550,1650, 600,1650, 550,550,&#xA;  600,500, 600,550, 550,550, 600,500, 600,550, 550,1650, 600,550, &#xA;  550,550, 600,500, 600,550, 550,550, 600,500, 600,1650, 600,500, &#xA;  600,1650, 550,1700, 550,1650, 600,1650, 550,1650, 600,1650, &#xA;  600&#xA;}; ESP8266-01&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am unsure: which data type do I need to save the variable value so that it can later be retrieved/subscribed and sent to another IR sender using &lt;code&gt;irsend.sendRaw&lt;/code&gt;, because I want to split the variable &quot;value&quot; into 2 parts after receiving it, the ID and the RAW code. After getting the RAW code, I want to use the &lt;code&gt;irsend.sendRaw&lt;/code&gt;(RAW CODE, length of RAW , 38).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My attempts:&lt;br&gt;&#xA;At first I tried to save it as a string, so that it can be retrieved and separated for &lt;code&gt;irsend.sendRaw&lt;/code&gt;. However I am unable to compile it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code which I used to upload: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      /*&#xA;     * IRremoteESP8266: IRServer - MQTT IR server&#xA;     * An IR LED must be connected to ESP8266 RX port (GPIO-3)&#xA;     * An IR receiver to GPIO 0&#xA;     * used library:&#xA;     * https://github.com/markszabo/IRremoteESP8266&#xA;     */    &#xA;    #include &amp;lt;WiFiClient.h&amp;gt;&#xA;&#xA;   #include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;&#xA; #include &amp;lt;IRremoteESP8266.h&amp;gt;&#xA;    #include &amp;lt;PubSubClient.h&amp;gt;&#xA;    int RECV_PIN = 0; //an IR detector/demodulator is connected to GPIO pin 0&#xA;&#xA;    IRrecv irrecv(RECV_PIN);&#xA;    decode_results results;&#xA;&#xA;    const char* ssid = &quot;MY-SSID&quot;;&#xA;    const char* password = &quot;MY-WIFI-PSK&quot;;&#xA;&#xA;    const char* topicRaportPrefix = &quot;esp8266/02/info/&quot;;&#xA;    const char* topicSubscribe = &quot;esp8266/02/sender/#&quot;;&#xA;    const char* topicPrefix = &quot;esp8266/02/&quot;;&#xA;&#xA;    const char* mqtt_server = &quot;10.10.10.10&quot;;&#xA;    const char* mqtt_user = &quot;mqtt_user&quot;;&#xA;    const char* mqtt_pass = &quot;mqtt_pass&quot;;&#xA;&#xA;    String clientName; // MQTT client name&#xA;    char message_buff[100];&#xA;&#xA;&#xA;     void dump(decode_results *results) {&#xA;        const int count = results-&amp;gt;rawlen;&#xA;          Serial.println(c);&#xA;          c++;&#xA;          Serial.println(&quot;For IR Remote &quot;);&#xA;          for (int i = 1; i &amp;lt; count; i++) {&#xA;&#xA;          if ((i % 2) == 1) {&#xA;            Serial.print(&quot;+&quot;);&#xA;            Serial.print(results-&amp;gt;rawbuf[i]*USECPERTICK, DEC);&#xA;        uint16_t  raw_ir_code[count] = results-&amp;gt;rawbuf[i]*USECPERTICK;&#xA;            client.publish( &quot;esp8266/02/sender&quot;, raw_ir_code);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After doing the changes proposed, I still get an error in compiling: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;no matching function for call to 'PubSubClient::publish(const char [18], uint16_t [(int)count])'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20241" LastEditorUserId="28084" LastEditDate="2016-11-24T19:29:45.330" LastActivityDate="2016-12-24T19:45:05.563" Title="MQTT and IR code Raw" Tags="|esp8266|ir|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24634" PostTypeId="2" ParentId="24612" CreationDate="2016-05-27T05:10:50.253" Score="1" Body="&lt;p&gt;Unfortunately I cannot comment. I can't really think of a reason why your readings are the way they are. Though you did not present to us an image of what potentiometer you are using and how you are really wring it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible that your potentiometer is a center tapped type with 4 pins. You could have possibly connected the positive rail to the center tap pin, ground to the side pin and the wiper pin to the Arduino pin so that you would have the result you are getting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or potentially, you wired it correctly except for the fact the positive rail you connected to was 10V, but that is really dangerous.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried measuring the resistance of the potentiometer from one side pin to the other side pin?&lt;/p&gt;&#xA;" OwnerUserId="19520" LastActivityDate="2016-05-27T05:10:50.253" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24637" PostTypeId="1" CreationDate="2016-05-27T07:57:38.087" Score="0" ViewCount="6985" Body="&lt;p&gt;I have changed PID and VID of my FTDI board for  arduino program because i wanted to rename the com port name.&#xA;The ic is  FT232R a USB to serial UART interface IC. I have store new vid and pid to EEPROM.&#xA;Now It is showing in unknown devices. I am not able to update driver of it.&#xA;I have followed this article &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=6929.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=6929.0&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell how to make cutmoize driver for it.&#xA;Any suggestions will be very helpful.&lt;/p&gt;&#xA;" OwnerUserId="21278" LastActivityDate="2020-01-29T17:01:13.270" Title="Customize FTDI driver for custom PID and VID" Tags="|serial|ftdi|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24638" PostTypeId="2" ParentId="362" CreationDate="2016-05-27T09:52:35.017" Score="1" Body="&lt;p&gt;If you want to create such a registry yourself, you may want to take a&#xA;look at &lt;a href=&quot;https://www.npmjs.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;npm&lt;/a&gt;, the package manager of &lt;a href=&quot;https://nodejs.org/en/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Node.js&lt;/a&gt;, which is&#xA;open-source and very similar in scope to want you describe. Npm is both:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;a central registry with metadata about each library:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;name, description, keywords, homepage, author, contributors&lt;/li&gt;&#xA;&lt;li&gt;version number, in principle complying with &lt;a href=&quot;http://semver.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;semantic versioning&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;URL of source repository (svn, git, github, gitlab, bitbucket...)&lt;/li&gt;&#xA;&lt;li&gt;compatibility information (in this case it's about the versions of Node)&lt;/li&gt;&#xA;&lt;li&gt;license&lt;/li&gt;&#xA;&lt;li&gt;dependencies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;a command-line tool for:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;searching the registry&lt;/li&gt;&#xA;&lt;li&gt;downloading and installing packages, recursively following their&#xA;dependencies&lt;/li&gt;&#xA;&lt;li&gt;publishing and updating your own packages on the registry.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;See for example the page of a &lt;a href=&quot;https://www.npmjs.com/package/express&quot; rel=&quot;nofollow noreferrer&quot;&gt;popular library&lt;/a&gt;, and the &lt;a href=&quot;https://github.com/expressjs/express/blob/master/package.json&quot; rel=&quot;nofollow noreferrer&quot;&gt;JSON&#xA;file&lt;/a&gt; holding its metadata.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-27T09:52:35.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24640" PostTypeId="2" ParentId="24558" CreationDate="2016-05-27T11:33:33.910" Score="1" Body="&lt;p&gt;Hi friends thanks for your support. It worked well as it is. No external capacitor I used. &#xA;I made the connection as shown in the above picture taken from &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader&quot; rel=&quot;nofollow&quot;&gt;LINK1&lt;/a&gt;.&#xA;I modified the file &quot;boards.txt&quot; and &quot;avrdude.conf&quot; as given in step 4 of &lt;a href=&quot;http://www.instructables.com/id/Burning-the-Bootloader-on-ATMega328-using-Arduino-/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;LINK2&lt;/a&gt;&#xA;I first uploaded the ArduinoISP sketch to the board on the left.&#xA;And then I opened an &quot;EMPTY ARDUINO SKETCH&quot;.&#xA;From that empty sketch I made the following changes&#xA;     Tools-&gt;Board = &quot;Arduino328&quot;&#xA;            Port  = COM4 in my pc&#xA;            Programmer = Arduino as ISP&#xA;Last step &quot;Burn Bootloader&quot;&#xA;Ta Da....&#xA;It worked. When I posted this question I burnt the boot-loader having the arduino ISP sketch opened. Only thing I changed now is I opened an empty sketch and hit burn from that sketch. Anyway.. thank you all. I dont think I wasted your time. If so, I apologise.&lt;/p&gt;&#xA;" OwnerUserId="21469" LastActivityDate="2016-05-27T11:33:33.910" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24641" PostTypeId="2" ParentId="24633" CreationDate="2016-05-27T11:57:45.920" Score="1" Body="&lt;p&gt;First create a topic and include the ESP8266 ID. Do &lt;strong&gt;not&lt;/strong&gt; make it part of the published value. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second publish the raw data as-is, &lt;code&gt;uint16_t raw_ir_code[RAW_IR_CODE_MAX]&lt;/code&gt;. The alternative is to convert to string (characters). But if the subscriber has the same architecture (interpretation of data), there is no need to convert it to string and back. Simply publish the raw data as it is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to cast the &lt;code&gt;raw_ir_code&lt;/code&gt; vector to the appropriate type for the MQTT publish call. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="28084" LastEditDate="2016-11-24T19:28:15.063" LastActivityDate="2016-11-24T19:28:15.063" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24642" PostTypeId="2" ParentId="24611" CreationDate="2016-05-27T12:35:49.113" Score="0" Body="&lt;p&gt;What you want to do after the triggering is an important part of this design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino platform is not necessarily the best choice for power sensitive applications.  You identified one problem in your post: Linear regulators.  What you are likely wanting is an efficient switching power supply to support a wide range of voltages as your batteries drain.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many embedded processor have low power modes.  Some are specially designed to reduce current draw down into the nA range when idle or sleeping.  However, all such processors require special care when configuring for these deep sleep modes.  That is to say, the application plays an important roll in deciding how to put a processor into such modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supporting hardware is perhaps the most important aspect of a low power designs.  Contributions from the most advanced low power processors can be wiped out if supporting hardware runs at mA ranges.  A simple 10K pull up resistor will draw 0.5mA in a 5 volt circuit. The impact is meaningless in a mains powered application.  But for long term battery operation is could means days of lost time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that said, there are resources for Arduino low power operation.  &lt;a href=&quot;https://github.com/rocketscream/Low-Power&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a low power library.  You will have to decide if it is sufficient for you application. Or if you need to also investigate low power hardware solutions.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-05-27T12:35:49.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24644" PostTypeId="2" ParentId="17277" CreationDate="2016-05-27T13:58:19.707" Score="0" Body="&lt;p&gt;Yes, you can run the two &lt;code&gt;loop()&lt;/code&gt; function side-by-side with a Multi-tasking Scheduler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please see &lt;a href=&quot;https://github.com/mikaelpatel/Arduino-Scheduler&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mikaelpatel/Arduino-Scheduler&lt;/a&gt;. There are plenty of examples to get you started but basically you call &lt;code&gt;Scheduler.start()&lt;/code&gt; with &lt;code&gt;loop()&lt;/code&gt; functions. You will have to give them different names. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Scheduler will context switch between the &lt;code&gt;loop()&lt;/code&gt; functions on &lt;code&gt;yield()&lt;/code&gt; or &lt;code&gt;delay()&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-05-27T13:58:19.707" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24645" PostTypeId="1" CreationDate="2016-05-27T12:53:25.980" Score="2" ViewCount="6138" Body="&lt;p&gt;I am a new user of Aurdino and want to interface OV7670 camera with aurdino uno which uses i2c mode of communication.I want to check the configuration of the device control registers and set them as per requirement. In this case, OV7670 is my slave device.&lt;br/&gt;&lt;br/&gt;&#xA;     How can I access a particular register inside the slave device?(The parameters for commands like wire.begin() etc., include slave address but not the address of the registers inside a slave device.)&lt;/p&gt;&#xA;" OwnerUserId="21540" OwnerDisplayName="Prajna Sri" LastActivityDate="2016-05-29T12:22:23.847" Title="Accessing configuration registers of OV7670 cam on i2c" Tags="|i2c|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24646" PostTypeId="2" ParentId="24645" CreationDate="2016-05-27T13:00:06.637" Score="2" Body="&lt;p&gt;Take a look at the datasheet - that will show you the correct waveforms / transactions for this. However, something like this should work (assuming 8-bit addresses and registers)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// reading&#xA;&#xA;Wire.beginTransmission(address); &#xA;Wire.write(reg); // set address to read from our requested register&#xA;Wire.endTransmission(false); // repeated start&#xA;Wire.requestFrom(address,(unsigned char)1);  // just a single byte&#xA;if(Wire.endTransmission()!=0){&#xA;    // put error code here&#xA;}&#xA;readValue = Wire.read();&#xA;&#xA;// writing&#xA;&#xA;Wire.beginTransmission(address);&#xA;Wire.write(reg);&#xA;Wire.write(value);&#xA;if(Wire.endTransmission()!=0){ &#xA;    // put error code here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11729" OwnerDisplayName="stefandz" LastActivityDate="2016-05-27T13:00:06.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24647" PostTypeId="1" CreationDate="2016-05-27T16:07:08.427" Score="1" ViewCount="88" Body="&lt;p&gt;I was recently given an Arduino Yun board from my university. I am able to upload sketch to the board, and it seems to function properly. However, I am unable to see the Linux booting up. When I want to reset the WLAN, ressing the WLAN RST button does nothing at all, the WLAN LED doesn't even blink or light up. Pressing the YUN RST button also does nothing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I did some Googling and found out that I could upload the YunSerialTerminal to the Yun, so I did that. And when I am trying to monitor the Linux boot up from the serial monitor. Nothing is shown. I press the TUN RST button as taught by the Arduino website while monitoring the Serial Monitor, nothing shows. However, the RX button does blink whenever I press enter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody help me? &lt;/p&gt;&#xA;" OwnerUserId="21471" LastActivityDate="2016-05-27T20:12:55.507" Title="Adruino Yun's Linux environment not working" Tags="|arduino-yun|linux|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24648" PostTypeId="1" CreationDate="2016-05-27T16:16:10.737" Score="5" ViewCount="37987" Body="&lt;p&gt;I need to determine the flash size of my ESP8266 on my NodeMCU module in order to flash the AT firmware onto the board. Apparently different boards come with differently-sized flash memories. Can anyone tell me the easiest way to find the flash size?&lt;/p&gt;&#xA;" OwnerUserId="21244" LastEditorUserId="4628" LastEditDate="2019-01-16T05:17:57.480" LastActivityDate="2019-01-16T05:17:57.480" Title="How to determine Flash size?" Tags="|arduino-ide|esp8266|nodemcu|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="24649" PostTypeId="2" ParentId="23631" CreationDate="2016-05-27T19:32:55.223" Score="2" Body="&lt;p&gt;Atmel Studio 7 which is built with Visual Studio. Google &quot;Atmel Studio 7&quot; or &lt;a href=&quot;http://www.atmel.com/Microsite/atmel-studio/&quot; rel=&quot;nofollow&quot;&gt;click here&lt;/a&gt;. It has everything you want and it's released by the company that makes the atmega328 your Arduino is built on. &lt;/p&gt;&#xA;" OwnerUserId="490" LastEditorUserId="490" LastEditDate="2016-05-27T20:30:45.423" LastActivityDate="2016-05-27T20:30:45.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24650" PostTypeId="2" ParentId="24647" CreationDate="2016-05-27T20:12:55.507" Score="1" Body="&lt;p&gt;You might need to re-flash the operating system. Unfortunately it's not a trivial task.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I had to do something similar with a Dragino shield (like a Yun on a shield) that uses the same OS and core chip. Instructions were scarce and hard to follow, plus I run Linux, so there's even less instructions. I worked it out, though, and wrote a tutorial &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/24/fixing-the-dragino-yun-board/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While that is for Linux and the Dragino shield I am sure the basic principles are the same for the Yun - just make sure you get the right image file for your Yun (don't get the Dragino one I link to).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main thing is to gain access to the boot manager (dr-boot, or whatever the Yun has), which means setting up a wired (ethernet) network and messing with UDP sockets (using &lt;code&gt;nc&lt;/code&gt; in Linux - no idea what you can use in Windows).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure you can find a tutorial for fixing the Yun from Windows (or whatever OS you use) to help you get into the boot manager and upload a new OS image.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-27T20:12:55.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24651" PostTypeId="1" CreationDate="2016-05-27T20:46:40.047" Score="0" ViewCount="1007" Body="&lt;p&gt;I wish to power an Arduino Uno board AND 3 servo motors using a single 9 V battery.&lt;br&gt;&lt;br&gt;&#xA;I have connected the positive terminal of the 9 V battery to the VIN pin. The negative terminal of the battery is connected to the GND pin immediately following. This, I believe, powers the Arduino Uno board.&lt;br&gt;&lt;br&gt;&#xA;Next, I have connected the power wires of all 3 servo motors to the 5 V pin on the Arduino board ( using jumper wires and a  breadboard). Similarly, all the servo ground wires have been connected to the second GND pin in the 'POWER' set of pins on the Arduino Uno board. And finally, the 3 signal wires from the servos have been connected to the three PWM pins on the 'DIGITAL' row, exactly pins 9, 10 and 11. &lt;br&gt;&lt;br&gt;THE SERVOS ARE NOT OPERATED SIMULTANEOUSLY, THEY ARE BEING OPERATED ONE-BY-ONE (but the load is still attached to each of them, a couple of grams is all).&lt;br&gt;&lt;br&gt;&#xA;Since the servo motors operate between 4.8 V - 6 V, and I don't have any spare AA batteries to approximate a 6 V battery, I thought this could solve the problem.&lt;br&gt;&lt;br&gt;My question is, does this pose any problems for the board or devices, does this draw a higher current? Will it damage the Arduino Uno board or the servo motors or any of the individual pins? &lt;br&gt;&lt;br&gt; Please let me know soon, thank you very much.&lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="21478" LastEditorUserId="21478" LastEditDate="2016-05-28T12:24:12.697" LastActivityDate="2016-05-28T12:24:12.697" Title="Powering 3 servo motors and Arduino Uno with one 9 V battery" Tags="|arduino-uno|power|pwm|servo|battery|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24652" PostTypeId="1" CreationDate="2016-05-27T21:58:12.680" Score="0" ViewCount="1862" Body="&lt;p&gt;I am hooking up an accelerometer to an arduino uno and running it through this pid controller. However the output isnt going to my setpoint. When i move the accelerometer back and forth the data goes to 255 or 0. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Datasheet for accelerometer:&#xA;&lt;a href=&quot;https://www.sparkfun.com/datasheets/Components/SMD/adxl335.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/datasheets/Components/SMD/adxl335.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I get 336 for the x direction, which is the only direction i'm using, when its set flat on the table, which is my setpoint/desired output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: Is the output the value away from the setpoint or the actual acceleration it calculates through the controller?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;PID_v1.h&amp;gt;&#xA;&#xA;#define PIN_INPUT A0&#xA;&#xA;//Define Variables we'll be connecting to&#xA;double Setpoint, Input, Output;&#xA;&#xA;//Define the aggressive and conservative Tuning Parameters&#xA;double aggKp=4, aggKi=0.2, aggKd=1;&#xA;double consKp=1, consKi=0.05, consKd=0.25;&#xA;&#xA;//Specify the links and initial tuning parameters&#xA;PID myPID(&amp;amp;Input, &amp;amp;Output, &amp;amp;Setpoint, consKp, consKi, consKd, DIRECT);&#xA;&#xA;void setup()&#xA;{&#xA;  //initialize the variables we're linked to&#xA;Serial.begin(9600); //Start a serial session&#xA;int  xdata = analogRead(PIN_INPUT);&#xA;Input = map(xdata, 0, 1024, 0, 255); //Change read scale to analog out scale&#xA;int setPoint = 336;&#xA;Setpoint = map(setPoint, 0, 1024, 0, 255); //Change read scale to analog out    &#xA;//turn the PID on&#xA;myPID.SetMode(AUTOMATIC);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;int xdata = analogRead(PIN_INPUT);&#xA;Input = map(xdata, 0, 1024, 0, 255); //Change read scale to analog out scale&#xA;&#xA;double gap = abs(Setpoint-Input); //distance away from setpoint&#xA;if (gap &amp;lt; 10)&#xA;{  //we're close to setpoint, use conservative tuning parameters&#xA; myPID.SetTunings(consKp, consKi, consKd);&#xA;}&#xA;else&#xA;{&#xA;  //we're far from setpoint, use aggressive tuning parameters&#xA;  myPID.SetTunings(aggKp, aggKi, aggKd);&#xA;}&#xA;&#xA;myPID.Compute();&#xA;&#xA;Serial.print(&quot;Setpoint = &quot;);&#xA;Serial.print(Setpoint);&#xA;Serial.print(&quot; Input = &quot;);&#xA;Serial.print(Input);&#xA;Serial.print(&quot; Output = &quot;);&#xA;Serial.print(Output);&#xA;Serial.print(&quot;\n&quot;);&#xA;// analogWrite(PIN_OUTPUT, Output);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OUTPUT:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setpoint = 83.00 Input = 87.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 81.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 64.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 64.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 68.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 79.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 91.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 96.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 99.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 88.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 68.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 58.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 64.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 78.00 Output = 255.00&#xA;Setpoint = 83.00 Input = 95.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 97.00 Output = 0.00&#xA;Setpoint = 83.00 Input = 95.00 Output = 0.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21481" OwnerDisplayName="lightro" LastEditorUserId="21481" LastEditDate="2016-05-27T22:28:33.323" LastActivityDate="2016-06-01T19:08:10.627" Title="PID control arduino" Tags="|accelerometer|pid|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24653" PostTypeId="2" ParentId="24652" CreationDate="2016-05-27T23:18:44.997" Score="2" Body="&lt;p&gt;Ensure that your period for the PID execution routine is reasonable for your system.  I generally like to execute my PID loops at 5 to 20 times the system impulse response.  For instance, with a motor, I will apply 100% power from a standstill and measure the time it takes to get up to 90% of final value.  I will then multiply that time by 0.1 and start there.  If it takes 1s, then I will start my PID loop executing every 0.1s.  Sometimes I adjust this up or down, depending on system requirements, but this is not a bad starting point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your PID loop is executing too fast, then it will respond too quickly to actually have a real-world effect on the system.  The output will tend to oscillate.  Motors vibrate and make more noise.... different systems respond differently, but you see the point.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start at &lt;code&gt;kp = 0&lt;/code&gt;,&lt;code&gt;ki = 0&lt;/code&gt;, &lt;code&gt;kd = 0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Increase &lt;code&gt;kp&lt;/code&gt; until you get a reasonable response.  Don't expect your error to go to 0.  As long as you aren't oscillating, that should be good.&lt;/li&gt;&#xA;&lt;li&gt;Very slowly increase &lt;code&gt;ki&lt;/code&gt;until you are happy.&lt;/li&gt;&#xA;&lt;li&gt;You should probably keep &lt;code&gt;kd&lt;/code&gt; to 0.  It is for advanced usage and PI loops will meet the vast majority of application requirements.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is a very crude guide.  There are better on google, but this should get you started.  PID loops are fun, especially with motors.  Enjoy!&lt;/p&gt;&#xA;" OwnerUserId="19102" LastEditorUserId="19102" LastEditDate="2016-06-01T19:08:10.627" LastActivityDate="2016-06-01T19:08:10.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24654" PostTypeId="2" ParentId="24645" CreationDate="2016-05-27T23:43:20.863" Score="3" Body="&lt;p&gt;To communicate with the OV7670:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SIOC =&gt; SCL&#xA;(pulled up to 3.3V)&lt;/li&gt;&#xA;&lt;li&gt;SIOD =&gt; SDA&#xA;(pulled up to 3.3V)&lt;/li&gt;&#xA;&lt;li&gt;RESET =&gt; 3.3V&lt;/li&gt;&#xA;&lt;li&gt;PWDN =&gt; GND&lt;/li&gt;&#xA;&lt;li&gt;XCLK =&gt; Clock signal is necessary (at least 10 Mhz)&lt;/li&gt;&#xA;&lt;li&gt;Vcc =&gt; 3.3V&lt;/li&gt;&#xA;&lt;li&gt;GND =&gt; GND&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The XCLK needs at least 10 MHz according to the datasheet, but from other accounts, it seems that's not a hard limit. You can get a 4 MHz clock from the Uno using its &lt;code&gt;timer0&lt;/code&gt;; check out this &lt;a href=&quot;http://forum.arduino.cc/index.php?PHPSESSID=pt8le15alfme9abbohpu1grue2&amp;amp;topic=128269.msg964725#msg964725&quot; rel=&quot;nofollow&quot;&gt;post&lt;/a&gt; on how to do it. After this, you can write a small sketch along the lines of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.begin();&#xA;Wire.beginTransmission(0x21);&#xA;Wire.write(0x12);  // software reset&#xA;Wire.write(0x80);&#xA;Wire.endTransmission();&#xA;delay(500); // wait for reset to complete&#xA;&#xA;Wire.beginTransmission(0x21); &#xA;Wire.write(0x01);  // u now read from reg 0x01&#xA;Wire.endTransmission();&#xA;Wire.requestFrom(0x21, 1);&#xA;while (Wire.available() == 0);  //block till u get something&#xA;while (Wire.available())&#xA;  Serial.println(Wire.read(), HEX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can place everything in &lt;code&gt;setup()&lt;/code&gt; after including the &lt;code&gt;Wire&lt;/code&gt; library and setting up the XCLK clock signal. If all goes well, &lt;code&gt;80&lt;/code&gt; should be printed in the serial monitor and this will confirm that you're now communicating over the SCCB with the camera.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should warn you that while others have used the Uno to grab images from the OV7670, the process is moderately complex, especially for a beginner, and it's not what the Uno is intended for; all you'll be able to do is grab frames and pass them on to some TFT screen or your PC and even then you'll get at most 5 fps, I think, with QVGA or QCIF output. You'd be better off with some ARM dev board, one running Linux perhaps. Good luck.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-05-29T12:22:23.847" LastActivityDate="2016-05-29T12:22:23.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24656" PostTypeId="2" ParentId="24651" CreationDate="2016-05-28T03:36:18.483" Score="1" Body="&lt;p&gt;I don't think anything should get damaged; the regulator is rated for 1A, and even beefy servos don't draw more than 200mA when moving against heavy load. The problem is that your battery won't last long. Even the heavy-duty Li primary 9V batteries are under 1000mAh, and the actual capacity is heavily dependent on the discharge rate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't you use a rechargeable Li-ion pack with an appropriate step-up or step-down converter?&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-28T03:36:18.483" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24658" PostTypeId="1" AcceptedAnswerId="24659" CreationDate="2016-05-28T05:55:46.650" Score="0" ViewCount="31" Body="&lt;p&gt;I wrote this sketch along with an HC - SR 04 Ultrasonic transducer and a DC motor. Whenever the HC-SR 04 reads any distance less than 15 cm, the motor stops, otherwise it keeps running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is whenever I upload the sketch, the motor runs for a short while and stops. Then when I open my serial monitor, the motor runs until an object crosses the 15 cm threshold and stops right after the limit is crossed. But when I again put the object outside of the 15 cm range, the motor should start running again, but it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a &lt;a href=&quot;http://robokits.co.in/motor-drives/dual-dc-motor-driver-20a&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; motor driver and a simple DC motor(12V).&lt;br&gt;&#xA;Here's the code-  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int trigPin1 = A0;&#xA;int echoPin1 = A1;&#xA;int distance1 = 0;&#xA;int E1 = 10;&#xA;int brake1 = 7;&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(trigPin1, OUTPUT);&#xA;  pinMode(echoPin1, INPUT);&#xA;  pinMode(brake1, OUTPUT);&#xA;  pinMode (E1, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  analogWrite(E1, 153);&#xA;  distance1 = getDistance(trigPin1, echoPin1);&#xA;  printDistance(1, distance1);&#xA;  delay(250);&#xA;  if(distance1 &amp;lt;=15){&#xA;    digitalWrite(brake1, HIGH);&#xA;  }&#xA;  else{&#xA;    analogWrite(E1, 153);&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;int getDistance (int initPin, int echoPin) {&#xA;  digitalWrite(initPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(initPin, LOW);&#xA;  long pulseTime = pulseIn(echoPin, HIGH);&#xA;  int distance = pulseTime / 58.2;&#xA;  return distance;&#xA;}&#xA;&#xA;void printDistance(int id, int dist) {&#xA;&#xA;  Serial.print(id);&#xA;  if (dist &amp;gt;= 120 || dist &amp;lt;= 0 ) {&#xA;  Serial.println(&quot; Out of range&quot;);&#xA;  }&#xA;  else{&#xA;   Serial.print(&quot;\t&quot;);&#xA;   Serial.print(dist);&#xA;   Serial.println(&quot; cm&quot;);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What mistake am I doing? Moreover I am currently running it with one motor, I'll add another later on along with more sensors, so the motors are controlled by the left or right sensor. How do I make my code work with them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks...&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-05-28T06:01:42.980" Title="Sketch not running as expected" Tags="|arduino-uno|serial|motor|sketch|hc-sr04|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24659" PostTypeId="2" ParentId="24658" CreationDate="2016-05-28T06:01:42.980" Score="0" Body="&lt;p&gt;It was too damn simple...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just had to add a line inside the else block in the loop function.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(brake1, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This was happening because the first time the threshold limit was crossed the &lt;code&gt;brake1&lt;/code&gt; pin was left &lt;code&gt;HIGH&lt;/code&gt; and was never set to &lt;code&gt;LOW&lt;/code&gt; again, which caused a permanent brake in the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm too damn stupid. But I still don't have any idea how will I use this code with multiple sensors and motors.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-05-28T06:01:42.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24661" PostTypeId="2" ParentId="20063" CreationDate="2016-05-28T08:40:56.587" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My thought is that, because the audio visualizer sends color profiles dozens of times per second, the Arduino might be getting overloaded with data. Is that possible?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Close, but the source of the problem is probably this line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.flush(); //clear out the serial to prep for next time&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because your audio visualizer keeps sending data, it's quite likely that by the time you get around to claiming a record, at least some part of another one (or more) has also arrived.   When you discard that with flush(), you are probably most of the time &lt;em&gt;not&lt;/em&gt; going to be discarding exactly a record's worth of bytes, but rather some arbitrary number more or less.  This introduces a synchronization problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've already had some advice on solving synchronization problems.  There are a variety of workable methods, binary and otherwise.  One simple one that works in a lot of situations is to encode bytes textually in hex and terminate the record with a newline.  It does have just over a factor of two overhead, but it has the debug/test advantage of being human readable, and you can basically cover the overhead by switching from 9600 to 19200 baud. &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-28T08:40:56.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24662" PostTypeId="1" AcceptedAnswerId="24666" CreationDate="2016-05-28T09:23:14.483" Score="0" ViewCount="285" Body="&lt;p&gt;I'm currently trying to port a program called 'ArduinoUSBLinker' to work on my Arduino 101 (which has an Intel Curie CPU instead of the standard ATMega CPU).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program is used to flash ESCs without the need of additional hardware.&#xA;&lt;a href=&quot;https://github.com/c---/ArduinoUSBLinker&quot; rel=&quot;nofollow&quot;&gt;Arduino USB Linker&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately the code is mainly based on the ATMega's built in AVR timers,&#xA;which uses several different predefined variables such as &lt;code&gt;TCCR0,TCCR1,TCTN2…&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are not available (or are they?) in the Curie Module. Since the Arduino 101 has timer functionality, I was wondering if there is a way to translate those into the Curie Timer library.&lt;/p&gt;&#xA;" OwnerUserId="21491" LastEditorUserId="2944" LastEditDate="2016-06-05T10:02:27.573" LastActivityDate="2016-06-05T10:02:27.573" Title="Porting ATMega8 AVR based program to Intel Curie Processor" Tags="|atmega328|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24665" PostTypeId="1" CreationDate="2016-05-28T11:46:57.957" Score="1" ViewCount="1943" Body="&lt;p&gt;I want to know if it is possible to send an SMS from a SIM900 using Arduinos to another SIM900.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: When the gsm is connected to the network, it does not send an sms; my airtime balance remains the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I used:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial SIM900 (9,10);&#xA;&#xA;void setup()&#xA;{&#xA;   serial.begin(9600);&#xA;   SIM900.begin(9600);&#xA;   delay(5000);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;   sendSMS();&#xA;&#xA;   while(SIM900.available()!=0)&#xA;     {&#xA;        Serial.println(SIM900.read());&#xA;     }&#xA;}&#xA;&#xA;void sendSMS()&#xA;{&#xA;    SIM900.println(&quot;AT+CMGF=1\r&quot;);&#xA;    delay(100);&#xA;    SIM900.println(&quot;AT+CMGS=\&quot;+27769384488&quot;\r&quot;);&#xA;    delay(100);&#xA;    SIM900.println(&quot;Hello&quot;);&#xA;    delay(100);&#xA;    SIM900.println((char)26);&#xA;    delay(100);&#xA;    SIM900.println();&#xA;    delay(5000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21496" LastEditorUserId="11763" LastEditDate="2016-06-27T22:26:46.113" LastActivityDate="2018-01-29T16:39:06.477" Title="GSM GPRS for sending an sms" Tags="|arduino-uno|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24666" PostTypeId="2" ParentId="24662" CreationDate="2016-05-28T12:22:05.477" Score="0" Body="&lt;p&gt;Those variables are the addresses of physical registers on the AVR that manipulate its timer/counters. Most other processors will have equivalent, but not likely identical, hardware. You'll need to port functionality, not the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll need to reverse-engineer (worst-case) the code you're trying to port (assuming you aren't intimately familiar with it, e.g., you designed it), develop a spec for it (at least in your head), and write to that spec for the Curie.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the overall job is not (too heavily) processor-specific, you may be able to write it to be portable by writing the job-specific code in, e.g., in C, and call well-defined functions (in C or assembler) for the CPU-specific ones, that could easily be replicated on another processor.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-05-28T12:22:05.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24668" PostTypeId="1" CreationDate="2016-05-28T13:36:13.643" Score="2" ViewCount="928" Body="&lt;p&gt;I am trying to upload a single program to a number of Arduinos one by one. But it is time consuming. So I would like to know if there is any way to upload the code at once to multiple Arduinos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 Arduino with all the Rx, Reset, Vcc, Gnd line connected to each other. Only pin left is Tx line. So I just connect the Tx line of one arduino and program it and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any other way?&lt;/p&gt;&#xA;" OwnerUserId="19942" OwnerDisplayName="chandan" LastEditorUserId="16988" LastEditDate="2016-05-28T15:56:41.017" LastActivityDate="2016-05-28T15:56:41.017" Title="How to upload one program into several Arduinos at once?" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24669" PostTypeId="2" ParentId="24668" CreationDate="2016-05-28T13:56:47.693" Score="2" Body="&lt;p&gt;Are you programming them for the first time or doing a update?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If is the first programming, I cant see another way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, If is a update and your Arduino have a Wifi module you could try something like an update on the air, where you put your new firmware in a server for example and all devices updates yourself automatically or by a command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google for Arduino OTA (on the air) you will get a lot of source code and examples of doing that.&lt;/p&gt;&#xA;" OwnerUserId="27125" OwnerDisplayName="BrunoAraujo" LastActivityDate="2016-05-28T13:56:47.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24670" PostTypeId="1" AcceptedAnswerId="24672" CreationDate="2016-05-28T14:50:08.973" Score="1" ViewCount="376" Body="&lt;p&gt;My intention is to write a code that asks a user to enter the name and then the age. The code should then simply display the persons name and age. To do that, I have written a simple code. I find it difficult to get it to work.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp = 0;&#xA;char ArrayName [50]; &#xA;int positionArray = 0;&#xA;int age =0;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    positionArray = 0;&#xA;    Serial.println (&quot;What is your name?&quot;);&#xA;&#xA;    do {&#xA;&#xA;        while (Serial.available()==0);&#xA;        temp = Serial.read ();&#xA;        ArrayName [positionArray++] = temp; &#xA;    } while (temp != '\r');&#xA;&#xA;    ArrayName [--positionArray] = '\0';&#xA;&#xA;    Serial.print (&quot;Your Name is: &quot;);&#xA;    Serial.println (ArrayName);&#xA;&#xA;&#xA;    // clear the UART Buffer&#xA;    while (Serial.available()==1){    &#xA;        temp = Serial.read();&#xA;    }&#xA;&#xA;    Serial.println (&quot;What is your age?&quot;);&#xA;    while (Serial.available()==0);&#xA;    temp = Serial.read ();&#xA;    age = temp;&#xA;&#xA;    Serial.print (&quot;You are &quot;);&#xA;    Serial.print (age);&#xA;    Serial.println (&quot; Years old.&quot;);&#xA;&#xA;    while (Serial.available()==1){    &#xA;        temp = Serial.read();&#xA;        delay (10);&#xA;    }&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The error I receive is that the program already outputs age without me even typing it.  Would it be possible to know the error? &#xA;I use both NL and CR to send in characters to Arduino and the Arduino IDEs default UART terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Listening to advice gotton from answers I got the code to work but in a very weird way. My new code works! but it proves the clearing of buffer &lt;strong&gt;cannot be done&lt;/strong&gt; by just reading it. This is in contrast to Arduino documents. My new code is as follows.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char temp = 0;&#xA;char ArrayName [50]; &#xA;int positionArray = 0;&#xA;int age =0;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    positionArray = 0;&#xA;    Serial.println (&quot;What is your name?&quot;);&#xA;&#xA;    do {&#xA;&#xA;        while (Serial.available()==0);&#xA;        temp = Serial.read ();&#xA;        ArrayName [positionArray++] = temp; &#xA;    } while (temp != '\r');&#xA;&#xA;    ArrayName [--positionArray] = '\0';&#xA;&#xA;    Serial.print (&quot;Your Name is: &quot;);&#xA;    Serial.println (ArrayName);&#xA;&#xA;&#xA;    // clear the UART Buffer **WHY IS THIS CODE NOT EFFECTIVE?**&#xA;    while (Serial.available() &amp;gt;= 1){    &#xA;        temp = Serial.read(); // performing dummy reads untill buffer empty.&#xA;    }&#xA;&#xA;    temp = Serial.read();&#xA;    delay (1000);&#xA;    temp = Serial.read();&#xA;    temp = Serial.read();&#xA;    temp = Serial.read();&#xA;&#xA;    Serial.println (&quot;What is your age?&quot;);&#xA;    while (Serial.available()==0);&#xA;    temp = Serial.read ();&#xA;    temp = temp - 48;&#xA;    age = temp*10;&#xA;    delay (1000); // providing the user a day to enter next digit of age&#xA;&#xA;    if (Serial.available()){  &#xA;        temp =  Serial.read ();&#xA;        temp = temp - 48;&#xA;        age = (int) temp + age; //whatever that is added have to be of same type. Else they need to be cased to same type.&#xA;    }&#xA;&#xA;&#xA;    Serial.print (&quot;You are &quot;);&#xA;    Serial.print (age);&#xA;    Serial.println (&quot; Years old.&quot;);&#xA;&#xA;    while (Serial.available() &amp;gt;=1 ){    &#xA;        temp = Serial.read();&#xA;        delay (10);&#xA;    }&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21503" LastEditorUserId="20645" LastEditDate="2016-05-28T17:07:32.350" LastActivityDate="2016-05-28T19:11:13.583" Title="Accepting strings and integers via UART" Tags="|c++|uart|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24671" PostTypeId="2" ParentId="24668" CreationDate="2016-05-28T14:55:48.873" Score="1" Body="&lt;p&gt;Arduino uses a microcontroller from Atmel and uses a programming tool that is designed for development use and not for production programming. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are looking for are tools that are called &quot;production programming tools&quot;. Atmel has a nice documentation which describes their different programming solutions: &lt;a href=&quot;http://www.atmel.com/Images/Atmel-42215-Production-Programming-of-Atmel-Microcontroller_AP-Note_AT06015.pdf&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21504" LastActivityDate="2016-05-28T14:55:48.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24672" PostTypeId="2" ParentId="24670" CreationDate="2016-05-28T15:02:01.367" Score="3" Body="&lt;p&gt;As we don't know what you are using as a terminal program we can't comment specifically on your choice of EOL characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is likely you are receiving everything in &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;nofollow&quot;&gt;ASCII code&lt;/a&gt;.  That is, when you type the number 1 you are actually getting the ASCII equivalent (0x31) from your terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is fine when you are working with character strings.  But when you want to work with numbers that are to be used in equations you need to 1) make sure that the user is only entering a number (check to make sure the values are from 0x30 to 0x39) and 2) subtract the ASCII value for '0' from the value you received from the terminal.  That is, subtract 0x30.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should now be obvious that you can only enter 1 digit at a time when using a terminal.  That you will have to reconstruct the number as the user types each digit.  For example the number 13 is a 1 and a 3 and you will have to multiply the 1 by 10 then add it to the 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since this is such a common conversion, there are Arduino libraries that do this for you.  Consider using &lt;a href=&quot;https://www.arduino.cc/en/Reference/ParseInt&quot; rel=&quot;nofollow&quot;&gt;ParseInt&lt;/a&gt; for this purpose.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the modified code, consider the possibility the terminal program is sending both a Carriage Return (aka: CR, 0x0D, \r) and Line Feed (aka: LF, 0x0A, \n) each time the Enter key is pressed.  And that the code is only waiting for the CR.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The delays are necessary as UART communication, as most communications, takes a finite amount of time.  And additional characters, if any, and even if autonomously sent, will take a finite amount of time to arrive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider &quot;looking&quot; for the LF character after finding for the CR character and removing the added delays.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-05-28T19:11:13.583" LastActivityDate="2016-05-28T19:11:13.583" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="24675" PostTypeId="2" ParentId="24665" CreationDate="2016-05-28T17:59:54.233" Score="1" Body="&lt;p&gt;Yes, it is possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code doesn't show any sign of board powering on and initialization.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;SIM900 has some LED that show status - make sure you are connected to GSM network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please check this tutorial: &lt;a href=&quot;https://www.youtube.com/watch?v=RUGV_64lQX8&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=RUGV_64lQX8&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16458" LastActivityDate="2016-05-28T17:59:54.233" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24676" PostTypeId="2" ParentId="8095" CreationDate="2016-05-28T19:02:32.373" Score="1" Body="&lt;p&gt;I do not have an answer... but it might be power consumption problem, ou voltage stability problem. I use a LCD shield with an RFID card reader (contactless card reader like you can find in the subway). When I plug the thing to a 9v battery the contrast is higher than when I connect it to an USB cable.&lt;/p&gt;&#xA;" OwnerUserId="21512" LastActivityDate="2016-05-28T19:02:32.373" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24677" PostTypeId="1" CreationDate="2016-05-28T21:21:00.750" Score="7" ViewCount="2089" Body="&lt;p&gt;I am developing for several different target microcontrollers (on OS X 10.11), which requires some unique combinations of (Arduino) IDE version, library versions, USB drivers, support software, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the pros and cons of using separate logged-in users for each environment as opposed to using Virtual Machines? Are there other methods commonly in use to separate environments, and also keep the environments archived for any legacy needs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: I also have a desire to keep these environments as standard as possible: installing released components (e.g., IDE, drivers) and customizing IDE app settings, but trying to avoid source-level forks. This is for my own sanity, and to give best chance of replicating the environment in the future.&lt;/p&gt;&#xA;" OwnerUserId="15487" LastEditorUserId="15487" LastEditDate="2016-05-29T04:00:59.780" LastActivityDate="2017-09-09T23:51:52.803" Title="How to handle multiple simultaneous Arduino development environments?" Tags="|arduino-ide|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24678" PostTypeId="2" ParentId="24677" CreationDate="2016-05-29T01:32:05.920" Score="3" Body="&lt;p&gt;I'm yet to see evidence that there is a sound or comprehensive way to do this, so would be pleased to read better suggestions.  As for why you would want to, there are a number of board support plugins/extensions that are moderately functional on some recent Arduino versions, but partially or entirely incompatible with others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can achieve a very limited partial version segregation by creating a new sketchbook folder for each version, which would host your libraries and hardware folders.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get the IDE to pick this up, you could have a custom preferences file (rather than &lt;code&gt;preferences.txt&lt;/code&gt;) with that sketchbook location set.  You can specify the file to use on the command line, for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/opt/arduino-1.6.8/arduino --preferences-file ~/.arduino15/alternate.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there is still quite a bit related to extra board support and similar stored in the settings folder, and at present that is hard coded to the same &quot;Arduino15&quot; or &quot;.arduino15&quot; path for all recent versions.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This hard-coding of the settings folder is implemented in the version of &lt;code&gt;Platform.java&lt;/code&gt; applicable to the operating system you are running under, so it is not clear how you could change this except at the source level, by modifying the jar, or by playing file-system level tricks with the operating system (process-unique mounts, etc).&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-29T02:45:11.903" LastActivityDate="2016-05-29T02:45:11.903" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24679" PostTypeId="1" CreationDate="2016-05-29T02:44:04.847" Score="2" ViewCount="295" Body="&lt;p&gt;This might seem like a very broad question but that's what i want it to be for multiple ways of implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've an Arduino UNO communicating with 2 Serial devices interfaced using SoftwareSerial flawlessly. I've used [SS_Object].listen() function to switch between the two. Right now, the entire code works sequentially meaning that, once it's work with the 1st Serial device is done, only then it will switch to the 2nd Serial device and work with it. Can i communicate with the 2 in parallel (Multitasking) using FreeRtos? I've heard that the scheduler switches between tasks when it encounters a delay. So may be a small useless delay is required, only for the scheduler, to switch between the two. May be! or May be things will be better if i use more advanced Arduino like Mega or Due.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for taking your time to read this. Please answer the question the way you've understood it as i am sure different people with different experiences will interpret this differently. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance! &lt;/p&gt;&#xA;" OwnerUserId="4374" LastActivityDate="2016-05-29T07:59:09.573" Title="Is it possible to run 2 functions, that communicate with 2 different serial devices, in parallel using FreeRtos library?" Tags="|arduino-uno|serial|arduino-mega|arduino-due|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24680" PostTypeId="2" ParentId="8480" CreationDate="2016-05-29T04:02:27.673" Score="2" Body="&lt;p&gt;You can use the SoftwareSerial library and declare instances to communicate with your serial devices. I am not sure if you can declare 20 such different instances but if at all you do, use the function: &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerialListen&quot; rel=&quot;nofollow&quot;&gt;listen()&lt;/a&gt; to switch between those serial devices. This, probably, is as close as it gets to multiplexing as you mentioned. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried with 2 such SoftwareSerial instances for communicating with GPS module and GSM module and the listen() function worked flawlessly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="4374" LastActivityDate="2016-05-29T04:02:27.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24681" PostTypeId="2" ParentId="24679" CreationDate="2016-05-29T07:59:09.573" Score="2" Body="&lt;p&gt;It is unlikely that FreeRTOS will allow you to do that. SoftwareSerial uses busy loops with interrupts disabled, which means it cannot be interrupted or preempted by the RTOS (or by anything for that matter).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want two serial connections in parallel, at least one of them should be done in hardware.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-29T07:59:09.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24682" PostTypeId="1" CreationDate="2016-05-29T11:01:40.867" Score="0" ViewCount="457" Body="&lt;p&gt;I recently bought an arduino yun. When trying to connect to the router following the procedure in &lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoYun#toc14&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/ArduinoYun#toc14&lt;/a&gt;. After the Configure &amp;amp; Restart, the Arduino network shut down after a few moments but it wasn´t linked to my router.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After reading a bit about it in the internet, i upgraded it following &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/YunSysupgrade&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/YunSysupgrade&lt;/a&gt;. As i found that the firmware version 1.5.3 was from 2014 &lt;a href=&quot;https://github.com/arduino/openwrt-yun/blob/master/ChangeLog&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/openwrt-yun/blob/master/ChangeLog&lt;/a&gt;, and as Reflashing the OpenWrt-Yun image on the Yún would void warranty, i proceeded by &lt;a href=&quot;http://nootrix.com/software/upgrade-arduino-yun-openwrt/&quot; rel=&quot;nofollow&quot;&gt;http://nootrix.com/software/upgrade-arduino-yun-openwrt/&lt;/a&gt;. Everything occured as detailled there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However now, when i turn on the yún, none network appear and the WLAN LED doesn't blink.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="21519" LastActivityDate="2016-06-13T09:36:58.420" Title="wifi failled connection with yun and after upgrading openwrt" Tags="|wifi|arduino-yun|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24686" PostTypeId="1" AcceptedAnswerId="24780" CreationDate="2016-05-29T16:47:32.623" Score="1" ViewCount="8158" Body="&lt;p&gt;I am reading sensory data that comes from the digital inputs(two DHT11 Humidity sensors using adafruit library.) and I would like to add a hh:mm:ss real time counts next to them. I try to use the time.h library but could not understand how to worked it in that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DHT.h&quot;&#xA;&#xA;#define DHT1PIN 4&#xA;#define DHT2PIN 7&#xA;&#xA;#define DHT1TYPE DHT11&#xA;#define DHT2TYPE DHT11&#xA;&#xA;DHT dht1(DHT1PIN, DHT1TYPE); &#xA;DHT dht2(DHT2PIN, DHT2TYPE);&#xA;&#xA;void setup() { &#xA;  Serial.begin(9600); &#xA;  Serial.println(&quot;Humidity sensors DHT11 tests!&quot;); &#xA;&#xA;  dht1.begin(); &#xA;  dht2.begin(); &#xA;}&#xA;&#xA;void loop() { &#xA;&#xA;  delay(2000);&#xA;&#xA;  float h1 = dht1.readHumidity(); &#xA;  float t1 = dht1.readTemperature(); &#xA;  float h2 = dht2.readHumidity(); &#xA;  float t2 = dht2.readTemperature();&#xA;&#xA;  if (isnan(t1) || isnan(h1)) {&#xA;    Serial.println(&quot;Failed to read from DHT #1&quot;);&#xA;  } else {  &#xA;    Serial.print(h1); Serial.print(&quot; \t&quot;); &#xA;  } &#xA;&#xA;  if (isnan(t2) || isnan(h2)) {&#xA;    Serial.println(&quot;Failed to read from DHT #2&quot;);&#xA;  } else { &#xA;    Serial.print(h2); &#xA;    Serial.print(&quot; \t&quot;); &#xA;  } &#xA;  Serial.println(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my serial port out is;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vnCCn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vnCCn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I want it to be like that;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lstbu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lstbu.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will appreciated.&lt;/p&gt;&#xA;" OwnerDisplayName="user21524" LastActivityDate="2016-06-01T12:36:32.510" Title="Printing Time to Serial Port" Tags="|arduino-uno|serial|time|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="24687" PostTypeId="1" AcceptedAnswerId="24688" CreationDate="2016-05-29T17:06:43.330" Score="1" ViewCount="151" Body="&lt;p&gt;Is it possible to send and receive data from a normal router using arduino? I need to create a little device that uses a router to communicate with a remote. It's a close circuit.&lt;/p&gt;&#xA;" OwnerUserId="21522" LastActivityDate="2016-05-30T07:42:55.587" Title="Router with arduino" Tags="|communication|wireless|" AnswerCount="2" CommentCount="1" ClosedDate="2016-05-31T12:42:07.357" ContentLicense="CC BY-SA 3.0" />
  <row Id="24688" PostTypeId="2" ParentId="24687" CreationDate="2016-05-29T17:26:31.140" Score="1" Body="&lt;p&gt;If you have a network interface (wired or wireless), yes, of course it is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look into the ESP8266, and ESP-12E-based boards such as the Adafruit Huzzah; they can be programmed in an Arduino environment, and have built-in wifi.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-29T17:26:31.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24689" PostTypeId="1" CreationDate="2016-05-29T20:20:55.837" Score="2" ViewCount="776" Body="&lt;p&gt;I am using original Arduino motor shield L298P with Arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I disassembled an electric screw driver which came out with a 4.8 v battery pack and a 4.8v specified DC motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected battery pack to the Vin and Ground pins of the motor shield, and connected the DC motor to A channel of the shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing is when I run a test code with PWM 255, the torque of the motor is way too low compared to connecting the motor directly to the battery pack. I also changed the batteries to a common 1.2v rechargeable 4 batteries connected in parallel. The result is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What might be going wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also paste the code I am using below. Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int motorPin = 3;&#xA;int Speed;&#xA;int flag;&#xA;void setup()&#xA;{&#xA;pinMode(motorPin, OUTPUT); //Set pin 3 as an OUTPUT&#xA;Serial.begin(9600); //Init serial communication&#xA;//Print a message:&#xA;Serial.println(&quot;Give a number from 50 to 255.&quot;); //Why minimun value 50?     Because with values below 50 the motor doesn't spin ;)&#xA;Serial.println(&quot;&quot;); //Blank line&#xA;}&#xA;&#xA;void loop()&#xA;{   &#xA;//Check if incoming data is available:&#xA;if (Serial.available() &amp;gt; 0)&#xA;{&#xA;  // If it is, we'll use parseInt() to pull out only numbers:&#xA;  Speed = Serial.parseInt();&#xA;  flag=0;&#xA;}&#xA;&#xA;//Valid range is from 50 to 255&#xA;if (Speed&amp;gt;=50 &amp;amp;&amp;amp; Speed&amp;lt;=255){&#xA;    //Send PWM value with analogWrite to Arduino pin 3 and print a message to serial monitor&#xA;    analogWrite(motorPin, Speed);&#xA;    //Print message only once&#xA;    if (flag==0){ &#xA;        //Print PWM value&#xA;        Serial.print(&quot;Motor spinning with &quot;);&#xA;        Serial.print(Speed);&#xA;        Serial.println(&quot; PWM&quot;);&#xA;        flag=1;&#xA;    }&#xA;}&#xA;&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21527" LastActivityDate="2016-05-30T03:17:27.567" Title="Arduino original motor shield can not supply enough torque to the motor?" Tags="|arduino-motor-shield|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24690" PostTypeId="2" ParentId="24689" CreationDate="2016-05-29T20:51:59.190" Score="2" Body="&lt;p&gt;According to the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoMotorShieldR3&quot; rel=&quot;nofollow&quot;&gt;motor shield page&lt;/a&gt;: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;To avoid possible damage to the Arduino board on which the shield is mounted, we reccomend using an external power supply that provides a voltage between 7 and 12V. If your motor require more than 9V we recommend that you separate the power lines of the shield and the Arduino board on which the shield is mounted. This is possible by cutting the &quot;Vin Connect&quot; jumper placed on the back side of the shield. The absolute limit for the Vin at the screw terminals is 18V. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;According to you:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I disassembled an electric screw driver which came out with a 4.8 v battery pack and a 4.8v specified DC motor.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;I connected battery pack to the Vin and Ground pins of the motor shield, and connected the DC motor to A channel of the shield.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's a lot less than 7V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also, from the motor shield page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Max current   2A per channel or 4A max (with external power supply)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;How much current does your screwdriver use?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-05-29T20:51:59.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24691" PostTypeId="2" ParentId="19084" CreationDate="2016-05-29T20:56:57.897" Score="0" Body="&lt;p&gt;You can disolder the female pin headers from pcb and make permanent connections on the remaining holes.&lt;/p&gt;&#xA;" OwnerUserId="20645" LastActivityDate="2016-05-29T20:56:57.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24692" PostTypeId="2" ParentId="24648" CreationDate="2016-05-29T23:03:58.247" Score="7" Body="&lt;p&gt;The easiest way (windows at least) is to use Espressif's &lt;a href=&quot;https://espressif.com/en/support/download/other-tools&quot; rel=&quot;noreferrer&quot;&gt;flash download tool&lt;/a&gt; - don't select anything to flash to the device, select the appropriate com port, click start, and the details of the device will appear in the Detected Info window&lt;/p&gt;&#xA;" OwnerUserId="21371" LastActivityDate="2016-05-29T23:03:58.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24693" PostTypeId="1" CreationDate="2016-05-29T23:43:39.320" Score="1" ViewCount="222" Body="&lt;p&gt;I tried using both the SparkFun and Adafruit CC3000 libraries first with what I actually wanted as a program, but when that didn't work, the examples for those libraries, and I always seem to get the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The CC3000 will connect to my AP, which uses a private address in the range &lt;code&gt;172.24.1.1/24&lt;/code&gt;, and somehow it will end up with the address &lt;code&gt;192.168.1.64&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that it is connecting, since iw event lists the device MAC address as it connects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only changes I have made to the source code at this point are the ssid and password, and changing the interrupt and vbat pins to match the configuration of the tinyduino cc3000 board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device has firmware 1.34. &lt;a href=&quot;https://codebender.cc/example/SFE_CC3000/ConnectionTest#ConnectionTest.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The specific output I get from the arduino is as follows (Note I commented out the disconnect at the bottom): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connected at 115200&#xA;&#xA;---------------------------------&#xA;SparkFun CC3000 - Connection Test&#xA;---------------------------------&#xA;CC3000 initialization complete&#xA;Connecting to: my_wifi_ap&#xA;Connected!&#xA;&#xA;CC3000 MAC Address: 70:FF:76:04:B9:5B&#xA;IP Address: 192.168.1.62&#xA;Subnet Mask: 255.255.255.0&#xA;Default Gateway: 192.168.1.254&#xA;DHCP Server: 0.0.0.0&#xA;DNS Server: 192.168.1.254&#xA;SSID: my_wifi_ap&#xA;&#xA;Finished connection test&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;running &lt;code&gt;iw event -f&lt;/code&gt; on my AP before running a connection test gives me the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;wlan0: new station 70:ff:76:04:b9:5b&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When another device, like my phone, connects to this AP, we get &lt;code&gt;172.24.1.xx&lt;/code&gt;, where &lt;code&gt;xx&lt;/code&gt; is whatever number between &lt;code&gt;50&lt;/code&gt; and &lt;code&gt;150&lt;/code&gt; that DHCP assigns us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&#xA;Also, if I comment out the disconnect at the end of the test, I can see the device is sending keepalives every three or four seconds using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;iw dev wlan0 station get 70:ff:76:04:b9:5b  //(inactive time never exceeds 4000ms). &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't &lt;code&gt;ping 192.168.1.64&lt;/code&gt; because that network is obviously unreachable, but trying to &lt;code&gt;ping 172.24.1.64&lt;/code&gt; gives me a exception:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;icmp open socket: Operation not permitted&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output from &lt;a href=&quot;https://codebender.cc/example/Adafruit_CC3000/buildtest#buildtest.ino&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit Example&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RX Buffer : 131 bytes&#xA;TX Buffer : 131 bytes&#xA;Free RAM: 1221&#xA;&#xA;Initialising the CC3000 ...&#xA;Firmware V. : 1.32&#xA;MAC Address : 0x70 0xFF 0x76 0x04 0xB9 0x5B&#xA;Started AP/SSID scan&#xA;&#xA;Networks found: 20&#xA;================================================&#xA;&#xA;...&#xA;&#xA;SSID Name    : my_wifi_ap&#xA;RSSI         : 83&#xA;Security Mode: 3&#xA;&#xA;SSID Name    : my_other_wifi_ap&#xA;RSSI         : 67&#xA;Security Mode: 3&#xA;&#xA;...&#xA;&#xA;================================================&#xA;&#xA;Deleting old connection profiles&#xA;&#xA;Attempting to connect to my_wifi_ap&#xA;Started AP/SSID scan&#xA;&#xA;&#xA;Connecting to my_wifi_ap...Waiting to connect...Connected!&#xA;Request DHCP&#xA;&#xA;IP Addr: 192.168.1.62&#xA;Netmask: 255.255.255.0&#xA;Gateway: 192.168.1.254&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The actual device being connected to is a Raspberry Pi AP, which was set up with DNSMASQ and hostapd. The configuration works, and has been proven to work with other embedded networking devices.&lt;/p&gt;&#xA;" OwnerUserId="21533" LastEditorUserId="41407" LastEditDate="2018-08-19T19:51:56.217" LastActivityDate="2020-12-07T07:02:55.267" Title="CC3000 gets wrong address when connecting to wireless AP" Tags="|wifi|adafruit|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24694" PostTypeId="1" CreationDate="2016-05-29T23:49:50.593" Score="1" ViewCount="6085" Body="&lt;p&gt;Asking here cause I ran out of options in searching. My Arduino Nano clone isn't recognized by my computer anymore. It was, until I plugged into a Windows machine, that did not recognize it... and now even my Linux Mint distro doesn't detect the Nano at all. Here's the thing, though: the green power LED still lights up and, if I connect my DC motor to it like I used to before, the LED turns off and the motor is powered only a little bit, with less speed than if it were powered by a 1.5V battery.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My voltimeter reads a 2.18V out of the 5V pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's all I did: uploaded a sketch to power a 5v motor, it worked, unplugged the Arduino, took it home to my Windows machine on the casing I got it from my school, plugged it there, then it didn't detect anything. Go back to the lab today, plug it in, doesn't detect it there either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, I've replaced USB cables, tried different USB ports, checked with lsusb and dmesg, tried finding it using the FTDI tool (the chip underneath is FTDI), then tried powering it from a phone charger, but the voltage readings at the 5v pin still are around 2.18V with that. Nothing seems to give this little thing an output greater than 2.18V.&#xA;The only thing I haven't tested is powering it through the VIN pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came across other questions of similar problems but nothing that seems quite like mine... since they all either are able to detect the device but it is displayed as an unknown device or can't recognize the device at all but their power LED does not turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what is going on?&lt;/p&gt;&#xA;" OwnerUserId="21525" LastActivityDate="2020-04-17T22:08:24.080" Title="Arduino Nano (clone) not recognized" Tags="|arduino-nano|usb|uploading|ftdi|port-mapping|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24695" PostTypeId="2" ParentId="24694" CreationDate="2016-05-30T00:53:22.157" Score="-1" Body="&lt;p&gt;Standards compliant USB ports will only supply 100mA unless a higher current is negotiated by USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suspect that you problem is the USB serial (Chinese Nano clones often have cheap chips). This happened to one of my Nano clones. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-05-30T00:53:22.157" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24696" PostTypeId="2" ParentId="1241" CreationDate="2016-05-30T02:02:42.183" Score="-1" Body="&lt;p&gt;The program is faulty. 1) No servo can react to a command in 15 milliseconds. Delay should be more like 500 milliseconds (.5 seconds). 2) The for loops are not designed to work together. The 1st loop feeds a value of 181to the second loop which is designed to start with a value of 180. The 2nd loop feeds a value of -1 back to the first loop, which is designed to start with a value of 0. &lt;/p&gt;&#xA;" OwnerUserId="21534" LastActivityDate="2016-05-30T02:02:42.183" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24697" PostTypeId="2" ParentId="24693" CreationDate="2016-05-30T02:56:48.700" Score="0" Body="&lt;p&gt;Welcome to the wonderful world of Adafruit software. Some genius decided that the CC3000 should save the first address it is ever given to nonvolatile storage, and use that ever since no matter what DHCP may subsequently tell it. Check the library source. &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-30T02:56:48.700" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24698" PostTypeId="2" ParentId="24693" CreationDate="2016-05-30T02:58:02.003" Score="1" Body="&lt;p&gt;I realized that I was using firmware v 1.34 on the board, which is what it was configured with when I got it, and decided I would try to downgrade it to one of the fir;ware sets supplied by adafruit to see if that would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The firmware modifying program didn't actually compile on the desktop version of the arduino ide, so I decided to use codebender instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure whether or not I should be disappointed or relieved, but downgrading the firmware actually made it work. I used the file titled driverpath_1_11, which I believe the libraries refer to as firmware version 0x113 or 0x118, which identifies itself as firmware version 1.24, which somehow actually worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution is here: &lt;a href=&quot;https://codebender.cc/sketch:318229&quot; rel=&quot;nofollow&quot;&gt;https://codebender.cc/sketch:318229&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins have been changed to correspond with the fixed pings used by the tinyduino.&lt;/p&gt;&#xA;" OwnerUserId="21533" LastActivityDate="2016-05-30T02:58:02.003" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24699" PostTypeId="2" ParentId="24689" CreationDate="2016-05-30T03:03:10.827" Score="0" Body="&lt;p&gt;From the Arduino playground:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino: What Adapter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;by djmatic&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ever since the dawn of Arduino, one question has been asked over and over again: &quot;what kind of DC adapter can I use to power my Arduino?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The short answer is: 9 to 12V DC, 250mA or more, 2.1mm plug, centre pin positive.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The long answer is that an off-the shelf Arduino adapter:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;must be a DC adapter (i.e. it has to put out DC, not AC);&#xA;should be between 9V and 12V DC (see note below);&#xA;must be rated for a minimum of 250mA current output, although you will likely want something more like 500mA or 1A output, as it gives you the current necessary to power a servo or twenty LEDs if you want to.&#xA;must have a 2.1mm power plug on the Arduino end, and&#xA;the plug must be &quot;centre positive&quot;, that is, the middle pin of the plug has to be the + connection.&#xA;These important details are often contained right on the adapter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current rating: Since you'll probably be connecting other things to the Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have enough juice to make each component of the circuit function reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One final note. The Arduino's on-board regulator can actually handle up to 20V or more, so you can actually use an adapter that puts out 20V DC. The reasons you don't want to do that are twofold: you'll lose most of that voltage in heat, which is terribly inefficient. Secondly, the nice 9V pin on the Arduino board will actually be putting out 20V or so, which could lead to potential disaster when you connect something expensive to what you thought was the 9V pin. Our advice is to stick with the 9V or 12V DC adapter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Electronicalifragilistic: I use a power supply from an old HP laptop that I scrapped. The plug is center positive and puts out 12V. Fits perfectly into Arduino connector. Packs a Wallop - most laptops draw 2-2.5 amps. That ought to run your screwdriver. &lt;/p&gt;&#xA;" OwnerUserId="21534" LastEditorUserId="21534" LastEditDate="2016-05-30T03:17:27.567" LastActivityDate="2016-05-30T03:17:27.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24705" PostTypeId="2" ParentId="22628" CreationDate="2016-05-30T06:44:16.263" Score="2" Body="&lt;p&gt;The problem you run into is that you are trying to insert the binary value of 0 into an Arduino &lt;code&gt;String&lt;/code&gt;.   That may actually be possible, but the way you attempt to to do it utilizes some C-style mechanisms, specifically representing a string as a pointer to some characters terminated by a null byte - which is to say 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;string_vol = String(String((char)state)  + string_vol );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Invokes this String constructor from WString.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String::String(char c)&#xA;{&#xA;    init();&#xA;    char buf[2];&#xA;    buf[0] = c;&#xA;    buf[1] = 0;&#xA;    *this = buf;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which tries to turn the input &lt;code&gt;char&lt;/code&gt; into a C-style string containing the input and then its own terminating null.  But in the case where state=0, that ends up being a buffer of two 0's.  A C-style string is terminated by the first 0, so when interpreted that way, the buffer is considered empty.  The last line of this constructor uses the buffer to invoke yet another constructor, that treats the input as a C-style null terminated string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String::String(const char *cstr)&#xA;{&#xA;    init();&#xA;    if (cstr) copy(cstr, strlen(cstr));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since strlen() finds the input here in the state=0 case to be empty, it produces an empty String.  You then append some other data, and that is all that you see, with no state included in the packet.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As this demonstrates, it is necessary to to be careful mixing binary and textual representations.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing you might do would be to add an offset to the state before transmitting, and subtract it out on the receiver.  If you have 9 or fewer states, adding the character code of '0' (ie, 0x30) would transmit them as potentially printable digits.  If you have more, you could add 'A' and transmit them as letters of the alphabet.  In the end it doesn't really matter what you add, as long as any value you intend to transport can be represented in all the intermediate data formats it passes through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course the nRF24L01 parts will transmit binary data just fine; if you want to go ahead and move binary data through them you can, you just have to avoid using anything with C-style &lt;code&gt;char *&lt;/code&gt; mechanics that is going to see &lt;code&gt;0&lt;/code&gt; in the data as a terminator, not a character.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-05-30T19:48:46.077" LastActivityDate="2016-05-30T19:48:46.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24706" PostTypeId="2" ParentId="24687" CreationDate="2016-05-30T07:42:55.587" Score="-1" Body="&lt;p&gt;Yes ,You CAN.&#xA;Use ESP 8266-07.Its a very good Wi-Fi module.You juts need to install ESP8266 board file in Arduno IDE.&#xA;For board file installation and some basic tutorial , just&#xA;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon&quot; rel=&quot;nofollow&quot;&gt;Click here&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its helpful I think.&lt;/p&gt;&#xA;" OwnerUserId="19942" LastActivityDate="2016-05-30T07:42:55.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24711" PostTypeId="1" CreationDate="2016-05-30T09:43:14.743" Score="0" ViewCount="226" Body="&lt;p&gt;so I have a question regarding the TFT touch screen... I would like to use the serial ports 1 and 0 (on my UNO) to transmit data to my mega... however it take up those ports. on the back of it, it shows what each prong should occupy. However, nothing is noted to be required for those ports. is it possible to clip those prongs off and still have the screen be usable or are they important to keep?&lt;/p&gt;&#xA;" OwnerUserId="21549" LastActivityDate="2016-12-27T07:42:39.030" Title="I just bought a TFT screen is it still possible to use the serial port 1 and 0?" Tags="|serial|tft|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24712" PostTypeId="2" ParentId="24711" CreationDate="2016-05-30T10:10:01.560" Score="1" Body="&lt;p&gt;Yes, you can use those pins. Just because there are physical pins on the shield doesn't mean they are actually used. If nothing is written next to them then yes you can use them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be warned though that those pins are used for communication with your PC - and that includes uploading sketches - so you may experience problems doing things like that while your Mega is connected to those pins.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-30T10:10:01.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24713" PostTypeId="1" AcceptedAnswerId="24715" CreationDate="2016-05-30T10:14:17.153" Score="2" ViewCount="4409" Body="&lt;p&gt;It is not clear to me whether Pin 13, corresponding to the LED, should be driven by an external voltage or not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt;, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;LED: 13. There is a built-in LED driven by digital pin 13. When the&#xA;  pin is HIGH value, the LED is on, when the pin is LOW, it's off.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, in the &quot;Blink&quot; example code I am running, the Pin 13 appears to be driven by the ATmega328:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(100);              // wait for a second&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(2000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I now attach a voltage source to Pin 13, will there be contention issues?&lt;/p&gt;&#xA;" OwnerUserId="21550" LastEditorUserId="3917" LastEditDate="2016-05-30T15:34:46.587" LastActivityDate="2016-05-30T15:34:46.587" Title="LED Pin 13 Input or Output?" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24715" PostTypeId="2" ParentId="24713" CreationDate="2016-05-30T10:57:20.223" Score="1" Body="&lt;p&gt;Like any other I/O pin, there should be no problem driving this pin (and&#xA;thus the builtin LED) from an external source, as long as you make sure&#xA;it is in &lt;code&gt;INPUT&lt;/code&gt; mode. If the pin is set to &lt;code&gt;OUTPUT&lt;/code&gt; you will likely&#xA;damage the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: If you have the Blink example already loaded in the&#xA;Arduino, the pin is in output mode. Be sure to upload another program,&#xA;that does not set pin 13 to output, &lt;strong&gt;before&lt;/strong&gt; connecting anything that&#xA;could drive pin 13.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-05-30T10:57:20.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24717" PostTypeId="1" CreationDate="2016-05-30T12:47:58.800" Score="2" ViewCount="319" Body="&lt;p&gt;I have bought an Arduino UNO that turned out to be the Italian version (Arduino SRL) not the American one (Arduino LLC).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now when I go to arduino.org and arduino.cc, they both have different versions of the IDE!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, which one should I use (if they are even different) ?&lt;/p&gt;&#xA;" OwnerUserId="21559" LastActivityDate="2016-06-02T17:04:17.063" Title="Which (Official) Arduino IDE to use?" Tags="|arduino-ide|ide|" AnswerCount="1" CommentCount="5" ClosedDate="2016-06-04T05:42:35.177" ContentLicense="CC BY-SA 3.0" />
  <row Id="24721" PostTypeId="1" AcceptedAnswerId="24722" CreationDate="2016-05-30T16:15:30.490" Score="0" ViewCount="1087" Body="&lt;p&gt;I am using Visual Studio Community 2015 with the newest version of the Visual Micro Arduino Plugin, however I also tried compiling my code in the Arduino IDE. &#xA;When compiling my code, there is the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compiling debug version of 'Autonomous_Car' for 'Arduino/Genuino Uno'&#xA;Autonomous_Car.cpp.o:In function `setup&#xA;Autonomous_Car.ino:undefined reference to `List&amp;lt;UpdateAble&amp;gt;  List()&#xA;Autonomous_Car.ino:undefined reference to `List&amp;lt;UpdateAble&amp;gt;  ~List() &#xA;collect2.exe*:error: ld returned 1 exit status &#xA;Error creating .elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Some info&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adding &lt;code&gt;#include &quot;List.cpp&quot;&lt;/code&gt; fixes the error, however this does not seem like valid C++. &lt;/li&gt;&#xA;&lt;li&gt;The files do not lay in any sub-directory&lt;/li&gt;&#xA;&lt;li&gt;In my Project Explorer both &lt;code&gt;List.h&lt;/code&gt; and &lt;code&gt;List.cpp&lt;/code&gt; are added to the project.&lt;/li&gt;&#xA;&lt;li&gt;I also removed both files from the project, deleted them and added them again&lt;/li&gt;&#xA;&lt;li&gt;I deleted the ´%AppData%\Local\Arduino15´ directory&lt;/li&gt;&#xA;&lt;li&gt;I am fairly new to C++ and Arduino, there might be something obvious, what I just can't find&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Autonomous_Car.ino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;List.h&quot;&#xA;#include &quot;UpdateAble.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;    List&amp;lt;UpdateAble&amp;gt;* myList = new List&amp;lt;UpdateAble&amp;gt;();&#xA;    myList-&amp;gt;GetCount();&#xA;&#xA;    delete myList;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;List.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _LIST_h&#xA;#define _LIST_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;#include &quot;arduino.h&quot;&#xA;#else&#xA;#include &quot;WProgram.h&quot;&#xA;#endif&#xA;&#xA;&#xA;template &amp;lt;class T&amp;gt;&#xA;class List {&#xA;public:&#xA;    void Add(T &amp;amp;item);&#xA;    bool Contains(T &amp;amp;item);&#xA;    bool Remove(T &amp;amp;item);&#xA;    void Clear();&#xA;    int IndexOf(T &amp;amp;item);&#xA;    T* GetItem(int index);&#xA;&#xA;    inline int GetCount() { return count; };&#xA;    inline int GetCapacity() { return capacity; };&#xA;&#xA;    List();&#xA;    ~List();&#xA;private:&#xA;    void EnsureCapacity(int capacity);&#xA;&#xA;    int count;&#xA;    int capacity;&#xA;    T** items;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;List.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;List.h&quot;&#xA;&#xA;// Constructor&#xA;template &amp;lt;class T&amp;gt;&#xA;List&amp;lt;T&amp;gt;::List() {&#xA;    List::capacity = 4;&#xA;    List::count = 0;&#xA;&#xA;    List::items = new T*[List::capacity];&#xA;}&#xA;&#xA;// Cleanup&#xA;template &amp;lt;class T&amp;gt;&#xA;List&amp;lt;T&amp;gt;::~List() {&#xA;    delete[] List::items;&#xA;}&#xA;&#xA;template &amp;lt;class T&amp;gt;&#xA;void List&amp;lt;T&amp;gt;::EnsureCapacity(int capacity) {&#xA;    if (List::capacity &amp;lt; capacity) {&#xA;        // Kapazität verdoppeln&#xA;        List::capacity = List::capacity * 2;&#xA;&#xA;        // Speicher für neues array reservieren&#xA;        T** newArray = new T*[List::capacity];&#xA;&#xA;        // Array kopieren&#xA;        for (unsigned int i = 0; i &amp;lt; List::count; i++) {&#xA;            newArray[i] = List::items[i];&#xA;        }&#xA;&#xA;        // Speicher von alten array freigeben und neues array zuweisen&#xA;        delete[] List::items;&#xA;        List::items = newArray;&#xA;    }&#xA;}&#xA;&#xA;// Adds a new item to the list&#xA;template &amp;lt;class T&amp;gt;&#xA;void List&amp;lt;T&amp;gt;::Add(T &amp;amp;item) {&#xA;    List::EnsureCapacity(count + 1);&#xA;&#xA;    List::items[count] = item;&#xA;    List::count++;&#xA;}&#xA;&#xA;// Gets whether the list contains an item or not&#xA;template &amp;lt;class T&amp;gt;&#xA;bool List&amp;lt;T&amp;gt;::Contains(T &amp;amp;item) {&#xA;    return List::IndexOf(item) != -1;&#xA;}&#xA;&#xA;template &amp;lt;class T&amp;gt;&#xA;bool List&amp;lt;T&amp;gt;::Remove(T &amp;amp;item) {&#xA;    int index = List::IndexOf(item);&#xA;&#xA;    // If the item does not exist, we cannot remove it&#xA;    if (index == -1) return false;&#xA;&#xA;    // Move every item behind our item one further&#xA;    for (int i = index + 1; i &amp;lt; List::count; i++) {&#xA;        List::items[i - 1] = List::items[i];&#xA;    }&#xA;&#xA;    List::count--;&#xA;}&#xA;&#xA;// Release the heap &#xA;template &amp;lt;class T&amp;gt;&#xA;void List&amp;lt;T&amp;gt;::Clear() {&#xA;    for (int i = 0; i &amp;lt; List::count; i++) {&#xA;        delete List::items[i];&#xA;    }&#xA;&#xA;    delete[] List::items;&#xA;}&#xA;&#xA;// Gets an index of an item, -1 if not found&#xA;template &amp;lt;class T&amp;gt;&#xA;int List&amp;lt;T&amp;gt;::IndexOf(T &amp;amp;item) {&#xA;    for (int i = 0; i &amp;lt; List::count; i++) {&#xA;        if (List::items[i] == item) {&#xA;            return i;&#xA;        }&#xA;    }&#xA;&#xA;    return -1;&#xA;}&#xA;&#xA;template &amp;lt;class T&amp;gt;&#xA;T* List&amp;lt;T&amp;gt;::GetItem(int index) {&#xA;    if (index &amp;lt; List::count &amp;amp;&amp;amp; index &amp;gt;= 0) {&#xA;        return List::items[index];&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd be very glad, if we can find the solution.&lt;/p&gt;&#xA;" OwnerUserId="21553" LastActivityDate="2016-05-30T16:22:20.833" Title="Arduino IDE/Visual Micro - Undefined reference to constructor" Tags="|c++|arduino-ide|visualstudio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24722" PostTypeId="2" ParentId="24721" CreationDate="2016-05-30T16:22:20.833" Score="1" Body="&lt;p&gt;You're using a &lt;em&gt;template class&lt;/em&gt;. A &lt;em&gt;template class&lt;/em&gt; is a special corner case that breaks the &quot;code in .cpp and definitions in .h files&quot; rule.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because it's a template it can't be pre-compiled - it needs to be specially compiled each time it is used, so that it can get the right values compiled in to the template place-holders, which are provided by the CU that has the template class included with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of that it is one of the rare cases where the code has to be in the header file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a full example you can take a look at &lt;a href=&quot;https://github.com/MajenkoLibraries/Average/blob/master/Average.h&quot; rel=&quot;nofollow&quot;&gt;my Average library&lt;/a&gt; which is a fully templated class.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-30T16:22:20.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24723" PostTypeId="1" AcceptedAnswerId="24724" CreationDate="2016-05-30T05:40:08.950" Score="3" ViewCount="867" Body="&lt;p&gt;I am attempting to communicate data via I2C between two Arduino Micros, but can't seem to get the &quot;slave&quot; device to detect a Wire.onRecieve() event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Per the specification on this site [&lt;a href=&quot;http://www.takktile.com/tutorial:arduino]&quot; rel=&quot;nofollow&quot;&gt;http://www.takktile.com/tutorial:arduino]&lt;/a&gt; (and verified against Arduino's own site) I am using pins 2 and 3 as SDA and SCL for I2C. I have pin2 of Arduino 1 (ARD1) connected to pin2 of Arduino 2 (ARD2), and pin3 of ARD1 connected to pin3 of ARD2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ARD2 acts as slave, ARD1 acts as master. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am reading in a text file from SD on ARD1. On ARD1, you then press a button to initiate transfer. ARD1 lights a red LED to indicate the transfer is underway. When I initiate the transfer, it remains solid (indicating it never gets past endTransmission to where the LED is supposed to be turned off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code for ARD1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the SD library:&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;// personal debugging routines&#xA;#include &quot;debug.h&quot;&#xA;/* &#xA; *  &#xA; *  THIS IS THE SLAVE RECEIVING MODULE&#xA; *  IT WILL WRITE DATA TO AN SD CARD&#xA; */&#xA;&#xA;// GLOBAL VARIABLES&#xA;const int chipSelect = 10; // 10 because this is an Adafruit SD module.&#xA;File data;&#xA;int buttonA; // the button&#xA;char c;&#xA;&#xA;void sd_readstart() {&#xA;  unsigned char i = 0;&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.print(&quot;\nInitializing SD card...&quot;);&#xA;  if (!SD.begin(10)) {&#xA;    Serial.println(&quot;Card initialization failed.&quot;);&#xA;    errorblink();&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;Initialization successful.&quot;);&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;  pinMode(11, OUTPUT); // setup for blink&#xA;  pinMode(12, OUTPUT); // setup for blink&#xA;  pinMode(10, INPUT); // button&#xA;  Wire.begin(8); // intitalize this device as a slave on addr .&#xA;  Wire.onReceive(receiveEvent); // when data is recieved, run recieveEvent(int).&#xA;  Serial.begin(9600);&#xA;  sd_readstart();&#xA;}&#xA;&#xA;void loop(void) {&#xA;  // short blink to confirm this is going down correctly &#xA;  buttonA = digitalRead(10);&#xA;  if (buttonA == HIGH) {&#xA;    // button open&#xA;    blink(100,1000);&#xA;  } else {&#xA;    // button pressed&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  data = SD.open(&quot;testoutput.txt&quot;);&#xA;  digitalWrite(12,HIGH);&#xA;  while (Wire.available() &amp;gt; 0) { // loop through all but the last&#xA;    c = Wire.read(); // receive byte as a character&#xA;    Serial.print(c);         // print the character&#xA;    data.print(c);&#xA;  }&#xA;  data.close();&#xA;  digitalWrite(12,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code for ARD2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the SD library:&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;// Software Serial library: &#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// personal debugging routines&#xA;#include &quot;debug.h&quot;&#xA;/* &#xA; *  &#xA; *  THIS IS THE SLAVE RECEIVING MODULE&#xA; *  IT WILL WRITE DATA TO AN SD CARD&#xA; */&#xA;&#xA;// GLOBAL VARIABLES&#xA;const int chipSelect = 10; // 10 because this is an Adafruit SD module.&#xA;File data;&#xA;int buttonA; // the button&#xA;char c;&#xA;&#xA;void sd_readstart() {&#xA;  unsigned char i = 0;&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.print(&quot;\nInitializing SD card...&quot;);&#xA;  if (!SD.begin(10)) {&#xA;    Serial.println(&quot;Card initialization failed.&quot;);&#xA;    errorblink();&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;Initialization successful.&quot;);&#xA;&#xA;}&#xA;&#xA;void setup() {&#xA;  pinMode(11, OUTPUT); // setup for blink&#xA;  pinMode(12, OUTPUT); // setup for blink&#xA;  pinMode(10, INPUT); // button&#xA;  Wire.begin(8); // intitalize this device as a slave on addr 8.&#xA;  Wire.onReceive(receiveEvent); // when data is recieved, run recieveEvent(int).&#xA;  Serial.begin(9600);&#xA;  sd_readstart();&#xA;}&#xA;&#xA;void loop(void) {&#xA;  // short blink to confirm this is going down correctly &#xA;  buttonA = digitalRead(10);&#xA;  if (buttonA == HIGH) {&#xA;    // button open&#xA;    blink(100,1000);&#xA;  } else {&#xA;    // button pressed&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;void receiveEvent(int howMany) {&#xA;  data = SD.open(&quot;testoutput.txt&quot;);&#xA;  digitalWrite(12,HIGH);&#xA;  while (Wire.available() &amp;gt; 0) { // loop through all but the last&#xA;    c = Wire.read(); // receive byte as a character&#xA;    Serial.print(c);         // print the character&#xA;    data.print(c);&#xA;  }&#xA;  data.close();&#xA;  digitalWrite(12,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For completeness, here is my debug.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void blink(int h, int l) {&#xA;    digitalWrite(11, HIGH);  &#xA;    delay(h);              &#xA;    digitalWrite(11, LOW);   &#xA;    delay(l);             &#xA;}&#xA;&#xA;void errorblink() {&#xA;  unsigned char counter = 0;&#xA;  while (counter &amp;lt; 4 ) {&#xA;    digitalWrite(12, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(12, LOW);   &#xA;    delay(50);    &#xA;    digitalWrite(12, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(12, LOW);   &#xA;    delay(50);    &#xA;    digitalWrite(12, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(12, LOW);   &#xA;    delay(1000);    &#xA;    counter++;&#xA;  }&#xA;}&#xA;&#xA;void goodblink() {&#xA;  unsigned char counter = 0;&#xA;  while (counter &amp;lt; 4 ) {&#xA;    digitalWrite(11, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(11, LOW);   &#xA;    delay(50);    &#xA;    digitalWrite(11, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(11, LOW);   &#xA;    delay(50);    &#xA;    digitalWrite(11, HIGH);  &#xA;    delay(50);              &#xA;    digitalWrite(11, LOW);   &#xA;    delay(1000);    &#xA;    counter++;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I did attempt to do the minimum working example of Wire from the examples in the Arduino IDE. That didn't work either, which is to say that I didn't see any text in the serial monitor on ARD2 when I uploaded the slave reciever sketch that comes with the IDE (with send master running on ARD1) which makes me wonder if I'm doing something horribly, fundamentally wrong in hardware rather than just in software. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope it's not inappropriate to post up the more advanced example in order to get feedback on the larger picture of what I'm trying to accomplish -- moving a text file from the SD card on one arduino to the SD card attached to another.&lt;/p&gt;&#xA;" OwnerUserId="21415" OwnerDisplayName="Bradley Evans" LastActivityDate="2016-05-31T23:58:41.483" Title="Two-wire communication (I2C) between Arduino Micros" Tags="|i2c|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24724" PostTypeId="2" ParentId="24723" CreationDate="2016-05-30T05:52:36.117" Score="3" Body="&lt;p&gt;I2c is an open collector setup. The pins go low, or open/input/hi-z, and let the line/bus free. Without a pull up on each line to VCC, the line never goes high. Pull up resistors are required. 4.7k typical. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Op's crudely drawn diagram is the correct way for a 5V I2C bus:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/axou7m.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/axou7m.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind both arduinos/power supplies must have their grounds connected, as a reference ground voltage.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="cde" LastEditorUserId="21074" LastEditDate="2016-05-31T23:58:41.483" LastActivityDate="2016-05-31T23:58:41.483" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24725" PostTypeId="2" ParentId="24723" CreationDate="2016-05-30T09:15:31.900" Score="1" Body="&lt;p&gt;The I2C protocol and hardware don't care how much data is transferred. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The time you have for the transfer, or the transfer rate is much more important; you might get bored waiting, but it won't. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might get over 100k bits/second transfer (allowing time to write to the SD card) if that's enough then it's fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The significantly faster option, using Arduino's, is SPI to SPI, and you are likely using SPI for the SD card, so I2C is a reasonable alternative, and makes your hardware and software simpler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only faster interface on the Arduino, excluding SPI, is the UART. That might be a bit tricky to use while you are developing, testing and debugging your software.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastActivityDate="2016-05-30T09:15:31.900" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24726" PostTypeId="1" AcceptedAnswerId="24728" CreationDate="2016-05-30T20:12:55.803" Score="0" ViewCount="304" Body="&lt;p&gt;This has been a hard problem to diagnose, so I hope I'm giving enough info here.  I'm trying to write a program for the Arduino (a lighting controller) using a bit of OO.  There are several classes in my library, and some extend others.  I'm a long-time programmer (mostly Java) but this is my first big Arduino project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;http://playground.arduino.cc/Code/Logging&quot; rel=&quot;nofollow&quot;&gt;the Logging library&lt;/a&gt; at various points in the main program, as well as the objects, and that's where it get complicated.  Depending on where I put calls to the logging library, or even Serial.print(), it either all works, or what gets sent to the serial port is a bit garbled, and the board never enters loop() (I'm not sure if that means that it's crashing in setup() or not).  This library hasn't been touched in 4 years and there are pending merge requests, so I don't think I'll get answers from the developer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a sneaking suspicion that the root of the problem is that Logging.h ends with instantiating the logger (&quot;Logging Log = Logging();&quot;) so multiple instances of the logger may be created and the serial port is being reset several times, possibly at different port speeds.  I thought it was bad form to initialize object, or even have any running code, in a .h file.  Is this a possibility, and do I have any options to fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any good alternatives for printing outputs at different debug levels?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would hate to have to pass the logger instance in as a parameter to my classes, or have to write setLogger() methods for all my classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="21571" LastActivityDate="2016-05-30T21:14:20.477" Title="Using the Logging library, sometimes doesn't exit setup()" Tags="|serial|library|printf|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24727" PostTypeId="1" AcceptedAnswerId="24738" CreationDate="2016-05-30T20:45:07.910" Score="2" ViewCount="92" Body="&lt;p&gt;I am graduating in a month and I want to make an installation with 80 apple homebuttons which are connected to a stepper motor. The idea is that each button that is pressed, turns the stepper motor the same amount of degrees each time. Also, each button is connected to an LED which must stay on, even if the button is pressed again and the motor too must not react. Once all 80 buttons have been pressed, the installation should switch off after a minute or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not sure how to connect 80 inputs to the arduino. Does anyone have any idea?&lt;/p&gt;&#xA;" OwnerUserId="21573" LastActivityDate="2016-05-31T07:05:47.767" Title="80 Apple Homebuttons and a steppermotor" Tags="|led|button|stepper|" AnswerCount="3" CommentCount="3" ClosedDate="2016-06-04T05:50:32.377" ContentLicense="CC BY-SA 3.0" />
  <row Id="24728" PostTypeId="2" ParentId="24726" CreationDate="2016-05-30T20:45:19.470" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Logging.h ends with instantiating the logger (&quot;Logging Log = Logging();&quot;) so multiple instances of the logger may be created and the serial port is being reset several times, possibly at different port speeds. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think you are mistaken, or have done something wrong with the library files.  &lt;code&gt;Logging.cpp&lt;/code&gt; ends with the instantiation, not &lt;code&gt;Logging.h&lt;/code&gt;.  &lt;code&gt;Logging.h&lt;/code&gt; only has an &lt;code&gt;extern&lt;/code&gt; reference to the instantiated object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So some guesswork:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you try and do anything with logging or serial access (or indeed anything more than just setting a few variables) within the constructors of your objects, and you instantiate those in the global scope, you won't have full access to the serial port - if any access at all.  You can only use the serial port once &lt;code&gt;Serial.begin(...)&lt;/code&gt; has been executed in setup, and global constructors are executed &lt;em&gt;before&lt;/em&gt; &lt;code&gt;setup()&lt;/code&gt; is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is for this precise reason that 99% of Arduino libraries have a &lt;code&gt;.begin()&lt;/code&gt; method which does all the work a constructor would normally do. The constructor is only used (if at all) for storing some default settings (pin numbers, etc) that are used later on. That way you have full control over what gets executed and when.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-30T20:45:19.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24730" PostTypeId="2" ParentId="24726" CreationDate="2016-05-30T21:14:20.477" Score="1" Body="&lt;p&gt;The constructor (called in a rather weird way) doesn't do anything, so I don't think that is the issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Logging.h&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    /*! &#xA;     * default Constructor&#xA;     */&#xA;    Logging(){} ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Logging.cpp&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Logging Log = Logging();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You should be calling &lt;code&gt;Log.init(whatever)&lt;/code&gt; &lt;strong&gt;once&lt;/strong&gt; in your code (as in the example). Are you doing that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please post a &lt;a href=&quot;https://stackoverflow.com/help/mcve&quot;&gt;Minimal, Complete, and Verifiable example&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without any posted code, we can only guess at what you are doing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I thought it was bad form to initialize object, or even have any running code, in a .h file. Is this a possibility, and do I have any options to fix this?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is not done in the library you linked to.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-05-30T21:14:20.477" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24731" PostTypeId="2" ParentId="24727" CreationDate="2016-05-30T22:47:53.970" Score="1" Body="&lt;p&gt;I have no idea what an apple homebutton is, but the easiest way to add more GPIO pins is to use something like an MCP23017; it connects over I2C and gives you 16 GPIO pins. Use five of them and you have your solution. &lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-05-30T22:47:53.970" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24733" PostTypeId="1" AcceptedAnswerId="24776" CreationDate="2016-05-31T02:07:42.153" Score="-1" ViewCount="3196" Body="&lt;p&gt;not sure what is going wrong in the code below, but it's a simplified code of a larger piece I'm trying to debug. I notice that the code seems to skip to the else statement even though the if statement is valid.&#xA;Potential is set to analogRead(A0)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (potential &amp;lt; 1023) {&#xA;Serial.println(analogRead(A0));&#xA;if (potential &amp;lt; 1023) {&#xA;  if (potential &amp;gt; 200) {&#xA;    Serial.println(&quot;cool&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;low&quot;);&#xA;    lcd.print(&quot;hello&quot;);&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results in serial monitor show &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;235&#xA;low&#xA;324&#xA;low&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried if (potential &amp;lt; 1023 &amp;amp;&amp;amp; potential &gt; 200) and if ((potential &amp;lt; 1023) &amp;amp;&amp;amp; (potential &gt;200)) to no avail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help, let me know what's going wrong or suggest a fix to this?&lt;/p&gt;&#xA;" OwnerUserId="21576" LastActivityDate="2016-06-01T08:55:42.743" Title="IF, ELSE IF functions not working with analogRead" Tags="|arduino-uno|programming|arduino-ide|analogread|ide|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24734" PostTypeId="1" CreationDate="2016-05-31T03:30:52.103" Score="2" ViewCount="832" Body="&lt;p&gt;I have a an Arduino Uno doing PWM on an RGB analog LED strip ala the Adafruit guide: &lt;a href=&quot;https://learn.adafruit.com/rgb-led-strips?view=all&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/rgb-led-strips?view=all&lt;/a&gt;. I've written a sketch that accepts MIDI data over USB and uses it to control the LEDs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MIDI.h&amp;gt;&#xA;#include &amp;lt;midi_Defs.h&amp;gt;&#xA;#include &amp;lt;midi_Message.h&amp;gt;&#xA;#include &amp;lt;midi_Namespace.h&amp;gt;&#xA;#include &amp;lt;midi_Settings.h&amp;gt;&#xA;&#xA;#include &amp;lt;MIDI.h&amp;gt;&#xA;&#xA;MIDI_CREATE_DEFAULT_INSTANCE();&#xA;&#xA;#define REDPIN 5&#xA;#define GREENPIN 6&#xA;#define BLUEPIN 3&#xA;&#xA;byte commandByte;&#xA;byte noteByte;&#xA;byte velocityByte;&#xA;&#xA;byte noteOn = 144;&#xA;byte noteOff = 128;&#xA;&#xA;int colorGroup;&#xA;int pColor;&#xA;int sColor;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(REDPIN, OUTPUT);&#xA;    pinMode(GREENPIN, OUTPUT);&#xA;    pinMode(BLUEPIN, OUTPUT);&#xA;    MIDI.begin(1);&#xA;    Serial.begin(115200);&#xA;}&#xA;&#xA;void checkMIDI(){&#xA;  do{&#xA;    if (Serial.available()){&#xA;      commandByte = Serial.read();//read first byte&#xA;      noteByte = Serial.read();//read next byte&#xA;      velocityByte = Serial.read();//read final byte       &#xA;      }&#xA;    }&#xA;  while (Serial.available() &amp;gt; 2);//when at least three bytes available&#xA;}&#xA;&#xA;void updateLights(){&#xA;  colorGroup = noteByte/42;&#xA;  pColor = noteByte%41*127/41;&#xA;  sColor = 127 - pColor;&#xA;  pColor = pColor*velocityByte/127;&#xA;  sColor = sColor*velocityByte/127;&#xA;  if (commandByte == noteOn &amp;amp;&amp;amp; velocityByte &amp;gt; 0){&#xA;    if (colorGroup == 1){&#xA;      analogWrite(REDPIN, pColor);&#xA;      analogWrite(GREENPIN, sColor);&#xA;      analogWrite(BLUEPIN, 0);&#xA;    }&#xA;    else if(colorGroup == 1){&#xA;      analogWrite(GREENPIN, pColor);&#xA;      analogWrite(BLUEPIN, sColor);&#xA;      analogWrite(REDPIN, 0);&#xA;    }&#xA;    else{&#xA;      analogWrite(BLUEPIN, pColor);&#xA;      analogWrite(REDPIN, sColor);&#xA;      analogWrite(GREENPIN, 0);&#xA;    }&#xA;  }&#xA;  else if(commandByte == noteOff || velocityByte == 0){&#xA;    analogWrite(REDPIN, 0);&#xA;    analogWrite(GREENPIN, 0);&#xA;    analogWrite(BLUEPIN, 0);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    checkMIDI();&#xA;    updateLights();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently this code will turn the lights on and off in accordance with noteOn and noteOff messages. However, the color doesn't seem responsive to the note value and the brightness doesn't seem responsive to the velocity value. I suspect that the problem has to do with my arithmetic combined with the data type (maybe a problem with the order of operations), but I haven't been successful in debugging this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea behind the RGB control is that I take the possible note values (0–127) and map it onto three different combinations of colors: R+G, G+B, and B+R. That's three groups of 42 values: 0-41, 42-84, and 85-127. Then I rescale the 42 values onto 0-127 for the intensity values of the LEDs. Finally I scale the intensity of all the colors by the velocity value over its possible max value.&lt;/p&gt;&#xA;" OwnerUserId="21577" LastActivityDate="2017-02-26T02:36:18.447" Title="MIDI controlled analog RGB LED strip (code problem)" Tags="|programming|rgb-led|midi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24735" PostTypeId="2" ParentId="24727" CreationDate="2016-05-31T05:18:16.133" Score="2" Body="&lt;p&gt;If you follow JayEye's approach (ie, use five MCP23017 units to connect 80 switches, and five more to connect 80 LEDs) the wiring and the software should be fairly simple.  But dealing with all the wires will be a problem unless you use a custom printed circuit board to mount all the switches, LEDs, wiring traces, and connectors.  If you have experience with and hands-on access to printed circuit manufacturing equipment, and fast access to the parts you need, that approach should be ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A worthwhile alternative is to scale the project back slightly – say to 64 switches and LEDs instead of 80 – and use two Arduino Mega2650's, one to connect to switches, and another to connect to LEDs.  Or you could use one Mega to handle the first 32 switch-and-LED pairs, and another, identically-wired, to handle the other 32.  The two Mega's could communicate by I²C or via RxD-TxD connections (Arduino Mega's have four hardware serials ports, IIRC).  If you plan to wire stuff up with jumpers and breadboards, this probably would be among the simpler, faster, and cheaper approaches.  The modularity of building two identical units (except that only one of them will have the stepper driver attached) improves reliability and ease of debugging.  You could also use four or five identically-wired Uno or Nano boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, however, that you are likely to have serious reliability problems if you connect up 80 switches and 80 LEDs via breadboards and jumper wires.   As Chris Stratton suggested, start small.  For example, wire up a dozen or two dozen switches and LEDs on a single Mega.  This will let you see how much of a mess the wiring will be, and whether the original scale is practical.  It will also allow tracking down software bugs on a hardware system that is small enough to allow some confidence that the hardware is working.  If you build an 80-unit system before debugging the software, you are likely to run into problems where hours or days go by while you try to sort out whether the problem is due to a software error, a wiring error, or some combination of both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that use of &lt;a href=&quot;https://en.wikipedia.org/wiki/Charlieplexing&quot; rel=&quot;nofollow&quot;&gt;Charlieplexed&lt;/a&gt; connections or matrix connections would let you get by with about 10-20% as many IO lines as the direct-connect methods listed above.  However, unless you have used Charlieplexed or multiplexed LED displays and matrix-connected switches successfully in previous projects, and have experience with building and driving circuit boards, the likelihood of getting the project done on time is rather lower than for the other methods mentioned above.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-05-31T05:33:54.063" LastActivityDate="2016-05-31T05:33:54.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24736" PostTypeId="2" ParentId="24734" CreationDate="2016-05-31T06:14:39.863" Score="1" Body="&lt;p&gt;I suggest that you write separate test programs for MIDI input and LED control, before trying to combine them together.  That is, write a sketch to report back on Serial what MIDI data was read, and a sketch to cycle the LEDs through obvious patterns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you read 10,20,30 as the three MIDI bytes, output &quot;Got 10,20,30&quot; (or similar).  If that appears to be working, then add your arithmetic and output the results of &lt;code&gt;colorGroup, pColor&lt;/code&gt;, and &lt;code&gt;sColor&lt;/code&gt; calculations.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the comment after &lt;code&gt;do{ ...} while (Serial.available() &amp;gt; 2);&lt;/code&gt; says &lt;code&gt;//when at least three bytes available&lt;/code&gt;, which does not correctly represent what that &lt;code&gt;do&lt;/code&gt; loop does.  When one or more bytes are available, that loop immediately reads three bytes (getting a value of -1 for any not-available byte).  To do the read only if three bytes are available, get rid of the &lt;code&gt;do{ ...} while&lt;/code&gt; construct, and instead say &lt;code&gt;if (Serial.available() &amp;gt; 2) { &amp;lt;read 3 bytes&amp;gt; }&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, use parentheses in expressions like &lt;code&gt;pColor*velocityByte/127&lt;/code&gt;.  IIRC the C spec allows evaluation of that as either &lt;code&gt;(pColor*velocityByte)/127&lt;/code&gt; or as &lt;code&gt;pColor*(velocityByte/127)&lt;/code&gt;.  Since &lt;code&gt;velocityByte/127&lt;/code&gt; can only evaluate to 0 or 1, the result of the latter form is either &lt;code&gt;pColor&lt;/code&gt; or 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, your code shows &lt;code&gt;if (colorGroup == 1){&lt;/code&gt; twice.  Change 1 to some other number in the second instance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To cycle the LEDs through obvious patterns, you could have three different sketches, one that gradually raises and lowers the PWM level on Red, one that does the same for Green, and another for Blue. &lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-05-31T06:14:39.863" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24738" PostTypeId="2" ParentId="24727" CreationDate="2016-05-31T07:05:47.767" Score="1" Body="&lt;p&gt;&lt;strong&gt;Why Apple home buttons?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finding out how to get input/output from these things and wiring them in a reliable way may cost you some time (and quite some money).&#xA;I don't see how they would have other features than regular buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(You won't get the fingerprint-scanning thing working, I'm afraid.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Start small&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'll be quite a project to do in one month (especially when you're new to Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you start out with 80 buttons and stuff, it will probably end up in a mess, and you'll be unable to show your prof anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should however, order the 80 push-buttons (I shouldn't order the Apple ones, if you don't already know how they work) and LED's. Since they might take some shipping time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Get yourself a &lt;a href=&quot;https://www.sparkfun.com/products/112&quot; rel=&quot;nofollow&quot;&gt;solder-less breadboard&lt;/a&gt;, maybe &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B01481LNPW&quot; rel=&quot;nofollow&quot;&gt;3 buttons&lt;/a&gt;, some &lt;a href=&quot;http://www.martoparts.nl/100-leds-3mm&quot; rel=&quot;nofollow&quot;&gt;LED's&lt;/a&gt; and a stepper (if you don't have one already).&#xA;Depending on your type of stepper, you may need something to drive it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Start project&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use two buttons or so, if you press one, it would go clockwise, if you press the other, it would go counter clockwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure you pull up or down the button inputs, to be sure that they are not floating when the button is not pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find a way to drive the steppers, you'll most likely use Arduino libraries for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code will be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(button1))&#xA;  stepper.step(steps++);&#xA;if(digitalRead(button2))&#xA;  stepper.step(steps--);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scaling up - alternative&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use the 80 buttons for each angle of the stepper.&#xA;But you could also use a keypad and LCD (or 3x 7segment display) to display a value typed in, and then send it to the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scaling up&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of the 80 buttons.&#xA;You could use 10 outputs in combination with 8 inputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With each output, you can energize a row of buttons, and with each input you read the columns. This way you only need 18 pins to read all keys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if you want to control all LED's at the same time, or individually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or use shift registers or I/O expanders (JayEye).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-31T07:05:47.767" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24740" PostTypeId="2" ParentId="24733" CreationDate="2016-05-31T07:20:25.303" Score="1" Body="&lt;p&gt;I'm not sure what you're trying to achieve with that &lt;code&gt;while&lt;/code&gt;.&#xA;But this will result in none of your other code being executed until potential is above 1022, which sound rather weird. (Unless it's for some kind of safety mechanism).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that you do send the new value over serial.&#xA;But you do not assign that new value to the variable 'potential'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, you see something completely different as what is actually happening.&#xA;You should do &lt;code&gt;Serial.println(potential);&lt;/code&gt; to be sure that you print the value of 'potential'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you should assign the &lt;code&gt;analogRead(A0);&lt;/code&gt; to your variable &lt;code&gt;potential&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also taken away the &lt;code&gt;while&lt;/code&gt; since I think it would be misplaced. And I worked around it, so it doesn't block your complete sketch.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  potential = analogRead(A0));&#xA;  Serial.println(potential);&#xA;&#xA;  if (potential &amp;lt; 1023) {&#xA;    if (potential &amp;gt; 200) {&#xA;      Serial.println(&quot;cool&quot;);&#xA;    } else {&#xA;      Serial.println(&quot;low&quot;);&#xA;      lcd.print(&quot;hello&quot;);&#xA;      delay(1000);&#xA;    }&#xA;  }else{&#xA;    //Code that won't run if potential &amp;lt; 1023&#xA;  }&#xA;&#xA;  //Other code that can run &quot;simultaniously&quot;.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-31T07:20:25.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24741" PostTypeId="1" AcceptedAnswerId="24756" CreationDate="2016-05-31T07:39:16.377" Score="6" ViewCount="43106" Body="&lt;p&gt;I just bought an Arduino Due and I'm having trouble reading from a simple serial IO program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a SparkFun RedBoard which is like an Uno. With that, I just ran a &quot;&lt;code&gt;stty&lt;/code&gt;&quot; command to configure the baud rate and other terminal settings, and then I could do &quot;&lt;code&gt;cat /dev/ttyUSB0&lt;/code&gt;&quot;. Actually I have a C++ program which opens &quot;&lt;code&gt;/dev/ttyUSB01&lt;/code&gt;&quot; and reads from it like a normal file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, with the Due, the device is &quot;&lt;code&gt;/dev/ttyACM0&lt;/code&gt;&quot; and there have been a few snags. One of them is that after programming the Due, and running &lt;code&gt;stty&lt;/code&gt;, I have to open &lt;code&gt;/dev/ttyACM0&lt;/code&gt; using the &lt;code&gt;screen&lt;/code&gt; program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;screen /dev/ttyACM0 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then kill screen, before &lt;code&gt;cat /dev/ttyACM0&lt;/code&gt; will work. Otherwise, &lt;code&gt;cat&lt;/code&gt; prints out one byte and exits; rarely it prints out 10 bytes or a line, or sometimes it prints nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a bit annoying and I can't figure out what &lt;code&gt;screen&lt;/code&gt; is doing to the device which I can't seem to accomplish using &lt;code&gt;stty&lt;/code&gt;. My &lt;code&gt;stty&lt;/code&gt; command is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo stty -F /dev/ttyACM* 115200 -parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts \&#xA;-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc \&#xA;-ixany -imaxbel -iutf8 \&#xA;-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 \&#xA;-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl \&#xA;echoke -flusho -extproc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got this by running &lt;code&gt;stty -a &amp;lt; /dev/ttyACM0&lt;/code&gt; after using &lt;code&gt;screen&lt;/code&gt; to initialize as above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought it might have something to do with serial auto-reset, so I tried using a resistor between &lt;code&gt;3.3V&lt;/code&gt; and &lt;code&gt;RESET&lt;/code&gt;, but this did not fix the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should note that &lt;code&gt;cu&lt;/code&gt; from the &lt;code&gt;uucp&lt;/code&gt; package is able to read continuously from &lt;code&gt;/dev/ttyACM0&lt;/code&gt;, but unlike &lt;code&gt;screen&lt;/code&gt; it does not leave the terminal set up in such a way that a subsequent &lt;code&gt;cat&lt;/code&gt; command will work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cu -l /dev/ttyACM0 -s 115200&#xA;&amp;lt;continuous stream of data&amp;gt;&#xA;$ killall cu             # (from another shell)&#xA;$ cat /dev/ttyACM0 | hexdump -c&#xA;&amp;lt;e.g. 7 bytes&amp;gt;&#xA;$&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With &lt;code&gt;screen&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt; would have printed an infinite stream. Any ideas how to accomplish this setup without using &lt;code&gt;screen&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="21201" LastActivityDate="2016-05-31T14:46:57.843" Title="How do I read from /dev/ttyACM0 in Linux without a terminal emulator?" Tags="|serial|arduino-due|linux|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24744" PostTypeId="1" AcceptedAnswerId="24745" CreationDate="2016-05-31T09:34:55.133" Score="2" ViewCount="7313" Body="&lt;p&gt;I want send and receive a 9 bit async-serial protocol with 4800 baud on my Arduino Uno, i have read on the specification from the ATmega328P that the uart can do that.&#xA;My aim is that when my Uart receive the 9th bit as a 1 he must throw a interrupt. On this interrupt i can recognize that this byte was an adress byte.&#xA;When he receive a zero he sould do nothing spezial, only transmit it as hex-byte over usb to the pc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Problem now, i can´t initialize the Uart right because the command Serial.begin(4800, config) is not enough, i must throw the interrupt and translate the data to hex-bytes.&#xA;My Question can i modify the Serial.begin() source code respectively where can i find the source code for the Serial.begin function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When there is no possibility to change the code has someone a other option for me to send and receive the 9 bit protocol with an Arduino Uno?&lt;/p&gt;&#xA;" OwnerUserId="21214" LastActivityDate="2018-01-14T15:48:12.317" Title="Is it possible to receive a 9 bit protocol on the Arduino Uno with Arduino?" Tags="|arduino-uno|serial|uart|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24745" PostTypeId="2" ParentId="24744" CreationDate="2016-05-31T10:11:02.387" Score="5" Body="&lt;p&gt;If you want to set the UART to 9-bit mode, you will have to set the&#xA;UCSZ02 bit of the &lt;code&gt;_ucsrb&lt;/code&gt; register to 1 in&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp#L103&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;HardwareSerial::begin()&lt;/code&gt;&lt;/a&gt;.&#xA;For example:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void HardwareSerial::begin(unsigned long baud, byte config)&#xA;{&#xA;  // Mostly unchanged... but by the end:&#xA;  sbi(*_ucsrb, RXCIE0);&#xA;  cbi(*_ucsrb, UDRIE0);&#xA;  sbi(*_ucsrb, UCSZ02);  // set 9-bit data mode&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that you do not need to modify the Arduino core library for this:&#xA;you could set that bit in your &lt;code&gt;setup()&lt;/code&gt;, right after calling&#xA;&lt;code&gt;Serial.begin()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, in the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial_private.h#L101&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;HardwareSerial::_rx_complete_irq()&lt;/code&gt; interrupt&#xA;handler&lt;/a&gt;,&#xA;you will have to read the 9th bit as the RXB80 bit in UCSR0B, &lt;strong&gt;before&lt;/strong&gt;&#xA;reading the low byte from &lt;code&gt;_udr&lt;/code&gt; (emphasis in the datasheet). For&#xA;example, you could replace the line &lt;code&gt;unsigned char c = *_udr;&lt;/code&gt; by:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;bool is_address = UCSR0B &amp;amp; _BV(RXB80);  // read 9th bit first&#xA;unsigned char c = *_udr;                // then the other bits&#xA;if (is_address) {&#xA;  do_something_with_address(c);&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;do_something_with_address()&lt;/code&gt; is the stuff you wanted to do in&#xA;another interrupt (no need for that, you are already in interrupt&#xA;context).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is worth noting that, with an Arduino Uno, you will not be able to do&#xA;all this while sending data to the PC. This is because the communication&#xA;with the PC uses the only UART of the ATmega328P.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-05-31T18:33:57.673" LastActivityDate="2016-05-31T18:33:57.673" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24747" PostTypeId="1" CreationDate="2016-05-31T10:24:15.233" Score="1" ViewCount="1432" Body="&lt;p&gt;I am currently working on a project that makes a plateua move back and forth using a stepper motor. On this plateau I have attached LEDs that create patterns. &#xA;However, the plateau should be moving whilst the pattern is changing. With my current code this is not happening. I know that I have to work with millis, but when I am completely lost on how to do it. Could someone help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;AccelStepper stepper(1, 42, 38);&#xA;&#xA;int i;&#xA;int microStep = 46;&#xA;&#xA;int currentAnimation = 0;&#xA;int count = 0;&#xA;int button = 13;&#xA;&#xA;int state = LOW;&#xA;int lastState = LOW;&#xA;&#xA;//bytes for patterns&#xA;byte a = B11110000;&#xA;byte b = B00010000;&#xA;byte c = B01000000;&#xA;byte e = B10100000;&#xA;&#xA;//--------------------------------------------------------------------------------------------------------------------------------&#xA;&#xA;void setup()&#xA;{&#xA;  DDRH = B1111000; // set PORT 6-9 of arduino mega high&#xA;  DDRB = B11110000; // set PORT 10-13 high&#xA;&#xA;  stepper.setMaxSpeed(900.0);&#xA;  stepper.setAcceleration(400.0);&#xA;&#xA;  pinMode(button, INPUT);&#xA;  state = digitalRead(button);&#xA;&#xA;  pinMode(microStep, OUTPUT);&#xA;  digitalWrite(microStep, HIGH);&#xA;}&#xA;&#xA;//--------------------------------------------------------------------------------------------------------------------------------&#xA;&#xA;void loop()&#xA;{&#xA;  //This should happen constantly&#xA;  stepper.runToNewPosition(2000);&#xA;  delay(500);&#xA;  stepper.runToNewPosition(0);&#xA;&#xA;  // These are the patterns, that should be played whilst the stepper is running. The patterns chaneg when you push the button&#xA;  if ( state == HIGH &amp;amp; lastState == LOW )&#xA;  {&#xA;    currentAnimation++;&#xA;  }&#xA;&#xA;  if (currentAnimation % 3 == 0)&#xA;  {&#xA;    same();&#xA;&#xA;  }&#xA;  if (currentAnimation % 3 == 1)&#xA;  {&#xA;    left();&#xA;  }&#xA;  if (currentAnimation % 3 == 2) {&#xA;    faster();&#xA;  }&#xA;&#xA;  lastState = state;&#xA;  state = digitalRead(button);&#xA;}&#xA;&#xA;//--------------------------------------------------------------------------------------------------------------------------------&#xA;//PATTERNS&#xA;void same() {&#xA;  for (int k = 0; k &amp;lt; 10; k++) //plays 10 times&#xA;  {&#xA;    PORTH = a;&#xA;    PORTB = a;&#xA;    delay(100);&#xA;    PORTH = 0;&#xA;    PORTB = 0;&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&#xA;void left() {&#xA;  for (int z = 0; z &amp;lt; 10; z++)&#xA;  {&#xA;    PORTH = e;&#xA;    PORTB = e;&#xA;    delay(100);&#xA;    PORTH = ~e;&#xA;    PORTB = ~e;&#xA;    delay(100);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void faster() {&#xA;  for (int z = 0; z &amp;lt; 256; z++)&#xA;  {&#xA;    PORTH = z;&#xA;    PORTB = z;&#xA;    delay(100);&#xA;  }&#xA;  PORTH = 0;&#xA;  PORTB = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21584" LastActivityDate="2016-05-31T12:16:05.303" Title="How to rewrite code in millis?" Tags="|millis|stepper|" AnswerCount="3" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24748" PostTypeId="2" ParentId="24747" CreationDate="2016-05-31T11:00:59.960" Score="2" Body="&lt;h3&gt;The basic pattern goes like this:&lt;/h3&gt;&#xA;&lt;p&gt;when you start the timer, you essentially store the current millisecond.&#xA;After this, in your loop code, among other things you should check if the time has passed by comparing current millisecond with the stored one. If their difference is equal or bigger of the desired delay interval, then the time has passed.&lt;/p&gt;&#xA;&lt;p&gt;Make sure you use &lt;code&gt;unsigned long&lt;/code&gt; variables to store times and check if time has passed with the condition used below (&lt;code&gt;if(millis() - mark &amp;gt;= interval ){...}&lt;/code&gt;) so you will not have problem even after &lt;code&gt;millis()&lt;/code&gt; rolls over.&lt;/p&gt;&#xA;&lt;p&gt;If you need more help, do not hesitate to ask.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long interval=2000; //2000ms&#xA;unsigned long mark;&#xA;boolean enabled=true;&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial.println(&amp;quot;starting timer&amp;quot;);&#xA;    startTimer();&#xA;    &#xA;}&#xA;&#xA;void loop() {&#xA;    check();&#xA;}&#xA;&#xA;void startTimer(){&#xA;    mark=millis();&#xA;}&#xA;&#xA;void check(){&#xA;    if(enabled){      &#xA;        if(millis() - mark &amp;gt;= interval ){&#xA;            &#xA;            enabled=false;&#xA;            Serial.println(&amp;quot;time elapsed&amp;quot;);&#xA;        }                          &#xA;        &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20645" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-05-31T11:59:20.057" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24749" PostTypeId="2" ParentId="24747" CreationDate="2016-05-31T11:01:36.340" Score="2" Body="&lt;p&gt;You could try something along these lines, I haven't put all of the code in, but just how this could be done for the sweep timer using millis().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long sweepTime;&#xA;unsigned long animationTime;&#xA;int stepperPosition;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;    //... other setup code&#xA;    sweepTime = millis();       // initialise the variables for the sweep timer, and the animation timer&#xA;    animationTime = millis();&#xA;    stepperPosition = 2000;     // initialise the next stepper position&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if (millis() - sweepTime &amp;gt; 500) //  check if more than 500 milliseconds have elapsed since last time we ran this.&#xA;    {&#xA;        stepper.runToNewPosition(stepperPosition);  // change stepper position&#xA;        sweepTime = millis();           // reset timer variable&#xA;        switch (stepperPosition) {      // need to change the value of the next position to set the stepper to&#xA;            case 0 : &#xA;                stepperPosition = 2000;&#xA;                break;&#xA;            case 2000 :&#xA;                stepperPosition = 0;&#xA;                break;&#xA;        }&#xA;    }&#xA;    //... continuation of loop code&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally, I don't have my arduino with me, so can't verify the correctness of the code.&lt;/p&gt;&#xA;" OwnerUserId="18709" LastEditorUserId="18709" LastEditDate="2016-05-31T12:16:05.303" LastActivityDate="2016-05-31T12:16:05.303" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24751" PostTypeId="2" ParentId="24747" CreationDate="2016-05-31T11:28:42.997" Score="2" Body="&lt;p&gt;Since microcontrollers typically only have one &quot;core&quot; or &quot;thread&quot; they can only do &quot;one thing at a time&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A microcontroller will step through your code and do everything in order (if you don't call interrupts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, when you put in a &lt;code&gt;for-loop&lt;/code&gt; (or any other type of loop) or a &lt;code&gt;delay&lt;/code&gt;, it will only continue with the rest of your code when that is done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve this, and &quot;do two things at a time&quot; (or actually rapidly switch between things) you'll need either interrupts or non-blocking code (or both).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Interrupts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see you're doing some direct port manipulation, which is really nice. You're writing bytes directly to the control registers of the microcontroller. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can leverage on that, to set up a timer (check the ATMega328P datasheet). You may make this timer give an interrupt each 100ms, and execute a &quot;frame&quot; of your animation at that point. And the next frame at the next interrupt. So that the time between each frames can be used for other code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Non-blocking code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino has built-in &lt;code&gt;millis();&lt;/code&gt; which is basically an interrupt that fires every millisecond to keep track of the passed milliseconds. So you can use this instead of fiddling around with the timers (which may very well cause some of the Arduino's functions to fail (like millis() or the servo library).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To write non-blocking code, you'll not use delays, since they effectively throw away &quot;processor time&quot; by doing &quot;nothing-instructions&quot; all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if we take out the delays, the for-loops will run too fast. And a for-loop also doesn't really work without the delay. Because even if you use millis and wait for half a second, you can't do anything in between.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we'll have to break up your code (specifically the animations) in chunks of code that can be executed withouth a delay. With only the need to delay in between these chunks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Frames&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's split up your animations in &quot;frames&quot;. One of your animations &lt;code&gt;same()&lt;/code&gt; works by PORTH&amp;amp;PORTB = A for 100msec and low for 100 msec.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sameAnimation(unsigned char frame){//plays 20 times (1x on, 1x off) instead of 10x on-off.&#xA;  if(frame%2==0){//If even&#xA;    PORTH = a;&#xA;    PORTB = a;&#xA;  }else{//if not even.&#xA;    PORTH = 0;&#xA;    PORTB = 0;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So based on the frame of the animation, the port will go high or low.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we look at the complete code, we have to change the motor every 500ms and have to change the animation frame every 100ms. And check a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We could put these in an interrupt that fires every 100ms, which would get reliable timing and minimum software overhead.&#xA;Or use the millis(); (checked against the previous milis) to check if the last update was 100ms ago.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My go at the code is below, but you should be able to figure it out yourself.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  unsigned char currentFrame = 0;&#xA;&#xA;  //Could be done every round.&#xA;&#xA;  lastState = state;&#xA;  state = digitalRead(button);&#xA;  if ( state == HIGH &amp;amp; lastState == LOW )&#xA;  {&#xA;    currentAnimation++;&#xA;    PORTH = 0;&#xA;    PORTB = 0;&#xA;  }&#xA;&#xA;  // These are the patterns, that should be played whilst the stepper is running.&#xA;&#xA;  if(millis() - previousMillis &amp;gt; 500){// Should change every 100ms&#xA;    previousMillis = millis();&#xA;&#xA;    if (currentAnimation % 3 == 0)&#xA;    {&#xA;      sameAnimation(currentFrame++);&#xA;    }&#xA;    if (currentAnimation % 3 == 1)&#xA;    {&#xA;      leftAnimation(currentFrame++);&#xA;    }&#xA;    if (currentAnimation % 3 == 2) {&#xA;      fasterAnimation(currentFrame++);&#xA;    }&#xA;&#xA;    if(currentFrame % 5){//Should change every 500ms, so every 5 frames.&#xA;      if(forward){&#xA;        stepper.runToNewPosition(0);&#xA;        forward = false;&#xA;      }else{&#xA;        stepper.runToNewPosition(2000); &#xA;        forward = true;&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;//--------------------------------------------------------------------------------------------------------------------------------&#xA;//PATTERNS&#xA;void sameAnimation(unsigned char frame){//plays 20 times (1x on, 1x off) instead of 10x on-off.&#xA;  if(frame%2==0){//If even&#xA;    PORTH = a;&#xA;    PORTB = a;&#xA;  }else{//if not even.&#xA;    PORTH = 0;&#xA;    PORTB = 0;&#xA;  }&#xA;}&#xA;&#xA;void leftAnimation(unsigned char frame) {&#xA;  if(frame%2==0){//If even&#xA;    PORTH = e;&#xA;    PORTB = e;&#xA;  }else{//if not even.&#xA;    PORTH = ~e;&#xA;    PORTB = ~e;&#xA;  }&#xA;}&#xA;&#xA;void fasterAnimation(unsigned char frame){&#xA;  PORTH = frame;&#xA;  PORTB = frame;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The button&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Checking the button every round isn't really needed. You can use an interrupt on that pin, so that the code to check it's state and go to the next frame only happens when the button is actually pressed. (interrupt triggered on rising edge?).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-05-31T11:28:42.997" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24754" PostTypeId="1" AcceptedAnswerId="24755" CreationDate="2016-05-31T13:00:54.277" Score="4" ViewCount="23192" Body="&lt;p&gt;with the following sketch I should be able to read and store what is entered in the Serial monitor&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;  while(!Serial);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Serial.println(&quot;Enter Zone Number: &quot;);&#xA;  while(!Serial.available()){&#xA;  }&#xA;   int zone = Serial.parseInt();&#xA;   Serial.println(zone);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I enter &quot;1&quot; I would except this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Enter Zone Number: &#xA;1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but unfortunately I have this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Enter Zone Number: &#xA;1&#xA;Enter Zone Number: &#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I missing?&lt;/p&gt;&#xA;" OwnerUserId="15045" LastActivityDate="2023-03-30T05:11:09.077" Title="Read int from Serial" Tags="|serial|arduino-ide|input|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24755" PostTypeId="2" ParentId="24754" CreationDate="2016-05-31T13:17:23.940" Score="5" Body="&lt;p&gt;&lt;code&gt;.parseInt()&lt;/code&gt; reads incoming text up until either it times out or &lt;em&gt;until it reads something that isn't a number&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are sending a number, and most likely a line-ending. If that line-ending is a simple &lt;code&gt;\n&lt;/code&gt; then that will trigger the &quot;end of number&quot; and will be discarded and the number returned.  However, if you are sending &lt;code&gt;\r\n&lt;/code&gt; (i.e., &lt;em&gt;CRLF&lt;/em&gt;) then you effectively have two line endings there:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1\r\n&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parsed as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1\r =&amp;gt; return 1&#xA;\n =&amp;gt; return 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Relying on the (poorly written) Arduino stream parsing routines is not good. Not only are they blocking, but often they just don't work right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should be reading the serial properly, taking account of line endings, and then converting the string you have read into a number using the likes of &lt;code&gt;atoi()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tutorial on reading serial: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/&quot; rel=&quot;noreferrer&quot;&gt;https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-05-31T13:17:23.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24756" PostTypeId="2" ParentId="24741" CreationDate="2016-05-31T14:46:57.843" Score="6" Body="&lt;p&gt;I have had very similar problems with my yun(shields) and I found the stty command to be very crucial for a good working.&#xA;I use following command and it works with mega and due on the yun&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -F ${PortName}  ${SerialSpeed}  raw -clocal -echo icrnl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since I call these I can redirect from and to /dev/ttyxxx without problems.&#xA;As far as I can see you mis the raw.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-05-31T14:46:57.843" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24758" PostTypeId="2" ParentId="9155" CreationDate="2016-05-31T16:45:33.307" Score="1" Body="&lt;p&gt;Mbed is so cool.The code is written everywhere that can get internet access. You doesn't like online IDE, you can get offline IDE such as Keil, GCC. You can get other kind of interface such as Matlab and LabView. Component and library is express together at main website. We can import lib: directly to workplace. If you have an idea, it is good to implement your idea quickly and best for prototyping. &#xA;I also like Arduino but I like mbed than Arduino.  &lt;/p&gt;&#xA;" OwnerUserId="21595" LastActivityDate="2016-05-31T16:45:33.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24759" PostTypeId="2" ParentId="24368" CreationDate="2016-05-31T17:01:13.123" Score="1" Body="&lt;p&gt;Operating this display should not be out of the range of the ATTiny85 abilities. I have one using a two-way serial connection for a setup routine, that modifies EEPROM values.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;First off connect to the LCD Backpack using the &lt;a href=&quot;https://learn.adafruit.com/usb-plus-serial-backpack/testing-with-usb&quot; rel=&quot;nofollow&quot;&gt;USB connector&lt;/a&gt; and test it through there to rule out it being faulty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the bottom of that page:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For more commands, check the github repository (see the Downloads tab) for a python script that will test all commands on the display. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Testing Trinket Serial:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is take your trinket and run a basic Serial connection program to test if the Trinket is sending the right info out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trinket:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;// Create a software serial port!&#xA;SoftwareSerial comm = SoftwareSerial(0, 1); //RX,TX&#xA;#define LEDPIN  PINB2&#xA;void setup() {&#xA;  //set baud&#xA;  comm.begin(9600);&#xA;  DDRB |= (1 &amp;lt;&amp;lt; LEDPIN);  // set LED pin to output mode&#xA;}&#xA;&#xA;void loop() {&#xA;  //print a specific character once a second&#xA;&#xA;  comm.println('a');&#xA;  PORTB |= (1 &amp;lt;&amp;lt; LEDPIN); // turn on LED&#xA;  delay(500);            // 0.5 second delay&#xA;  PORTB &amp;amp;= ~(1 &amp;lt;&amp;lt; LEDPIN); // turn off LED&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you need another Arduino, like an Uno, Leonardo:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// For leonardo use Serial1 for the connection to trinket &#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;&#xA;  Serial.println(&quot;Ready...&quot;);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() { // run over and over&#xA;  if (Serial1.available()) {&#xA;    char incoming = Serial.read();&#xA;    Serial.println(incoming);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or the stock balnk sketch and connect the Trinket Serial out to Arduino &lt;code&gt;TX-&amp;gt; 1&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If using an UNO you can set up a SoftwareSerial style of the above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend this rather, a USB-Serial converter as it will be quicker and cleaner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next you need to see what is coming out. If the received data is correct then there is an issue in the LCD display, try re-flashing the LCD board with new firmware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the data comes through correctly then move onto using the Adafruit  code and still connecting it to the other Arduino boards serial connection, replacing the &lt;code&gt;Serial.println(Serial1.read());&lt;/code&gt; with &lt;code&gt;Serial.println(Serial1.read(),HEX);&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the data still comes through correctly then the data is not being received properly by the LCD backpack.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;LCD Backpack&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should test the display board with another Arduino, UNO or Leonardo (32u4).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Run the Adafruit tutorial code and see the results. If the code works then there is a problem with the Trinket and the SoftwareSerial library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there are again errors that happen with the LCD backpack when used with a 'normal' Arduino then it is the problem.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Recomendations&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download the ATTiny core from High-Low Tech and burn the 'bootloader' to reset the fuses to 8MHZ setting, also this is a good core to use if you want more space on the ATTiny.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possibly re-flash the trinket bootloader and make sure the internal clock is 8MHz; the SoftwareSerial library is touchie I believe.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-05-31T17:01:13.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24760" PostTypeId="1" CreationDate="2016-05-31T19:11:38.890" Score="0" ViewCount="295" Body="&lt;p&gt;I am working with a TOS-100 Stepper Driver Shield and am attempting to use the pre-written TMC26XMotorTester/Motor/Serial set of files to make it work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I unzipped the files, copied the TMC26XStepper folder into the library directory in my Arduino folder, and restarted the Arduino IDE (as well as the Arduino and Driver Shield boards).  I also switched the DIR and STEP pins (6 and 7 swapped to match the wiring on my board).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the TMC26XMotorTester file, I wrote&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;TMC26XStepper.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;so I'm assuming (given everything I've done), that the functions should be available given this file inclusion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I get the error &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    TMC26XMotorTester:44: error: 'TMC26XStepper' does not name a type&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;along with the complete list of functions from the TMC26XStepper.h/.cpp file that were not identified.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts?  I'm using Arduino-Uno version 1.6.9.&lt;/p&gt;&#xA;" OwnerUserId="21599" LastActivityDate="2018-03-25T18:17:06.157" Title="TMC26XMotorTester:44: error: 'TMC26XStepper' does not name a type" Tags="|arduino-uno|stepper|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24761" PostTypeId="2" ParentId="22553" CreationDate="2016-05-31T19:29:08.437" Score="1" Body="&lt;p&gt;These lines in the ISR in VirtualWire.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (vw_rx_enabled &amp;amp;&amp;amp; !vw_tx_enabled)&#xA;        vw_rx_sample = vw_digitalRead_rx() ^ vw_rx_inverted;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    if (vw_rx_enabled &amp;amp;&amp;amp; !vw_tx_enabled)&#xA;        vw_pll();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;mean that the receive path code is just not executed while the transmitter is enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It kind of seems from the comment as that might not have been true at some point in the past, though I'm not seeing a version history for an &quot;official&quot; version to check.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try to modify the code to implement both, but it is worth noting that VirtualWire has been deprecated in favor of the more versatile RadioHead, so you might want to evaluate that and perhaps make modifications there instead.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-05-31T19:29:08.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24762" PostTypeId="1" AcceptedAnswerId="24766" CreationDate="2016-05-31T21:32:12.110" Score="1" ViewCount="328" Body="&lt;p&gt;I'm running into a problem with a GikFun Arduino Nano. The symptom appears when I'm reading the receive buffer to clear it after an operation completes. The unit just appears to stop somewhere in the loop function and never continues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that this unit has a CH340 UART on it which seems to have issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions on what I can do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OP Edits&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code is more or less based on the code from this &lt;a href=&quot;http://makezine.com/projects/make-36-boards/android-arduino-led-strip-lights/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Make: article&lt;/a&gt;. I originally had this assembled through an Arduino Uno R3 with an HC-06 (Kootek BT2S) module. Everything connected via solderless bread-board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This entire circuit works properly with the UNO, which I had it running on SoftwareSerial using pins 2, 3. After putting this on a perf-board in a project box using the GikFun Nano, it was not behaving. I had a number of wiring issues, which I resolved, but still had issues communicating on the HC-06/SoftwareSerial. I re-did the wiring using pins 0, 1 for the Serial and removed the SoftwareSerial references. The circuit worked as I expected with the HC-06 working as it had before. But if I issued more than 1-2 commands via Bluetooth the unit would just get stuck. I also tried this without the HC-06 connected and just used the Serial Monitor through the IDE same behavior. It would randomly lock up after clearing the receive buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code - as requested:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const int statusLED = 13; //the pin you connect your status LED to&#xA;const int desiredBaud = 4;//index of your desired baud rate 4 is 9600&#xA;char* myPin = &quot;1234&quot;;//change to the pin of your choice&#xA;&#xA;const int memRed=0;&#xA;const int memGreen=1;&#xA;const int memBlue=2;&#xA;&#xA;const int redPin= 9;&#xA;const int greenPin= 10;&#xA;const int bluePin= 11;&#xA;const int cmdLed= 12;&#xA;&#xA;// Max Red - 255&#xA;const int max_red = 255;&#xA;// Max Green - 90&#xA;const int max_green = 255;&#xA;// Max Green - 100&#xA;const int max_blue = 255;&#xA;&#xA;int red= 255;&#xA;int green= 255;&#xA;int blue= 255;&#xA;&#xA;unsigned int baudLookup[] = &#xA;{&#xA;  1200,  //code 1&#xA;  2400,  //code 2&#xA;  4800,  //code 3&#xA;  9600,  //code 4&#xA;  19200, //code 5&#xA;  38400, //code 6&#xA;  57600  //code 7&#xA;}; &#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(redPin, OUTPUT);  &#xA;  pinMode(greenPin, OUTPUT);  &#xA;  pinMode(bluePin, OUTPUT);  &#xA;  pinMode(cmdLed, OUTPUT);&#xA;  pinMode(statusLED, OUTPUT);&#xA;  digitalWrite(statusLED, HIGH);&#xA;&#xA;  Serial.begin(9600);&#xA;  delay(1500);//wait for reset to complete&#xA;&#xA;  Serial.print(&quot;AT&quot;);&#xA;  delay(1500);//wait for reset to complete&#xA;  while(Serial.available()) {&#xA;    Serial.read();&#xA;  }&#xA;  delay(1500);//wait for reset to complete&#xA;&#xA;  digitalWrite(statusLED, HIGH); //SUCCESS!&#xA;&#xA;  digitalWrite(redPin, map( red, 0, 255, 0, max_red) );&#xA;  digitalWrite(greenPin, map( green, 0, 255, 0, max_green) );&#xA;  digitalWrite(bluePin, map( blue, 0, 255, 0, max_blue) );&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(statusLED, LOW); //fast blink means success&#xA;  delay(200);&#xA;  digitalWrite(statusLED, HIGH);&#xA;  delay(200);&#xA;&#xA;  String stat;&#xA;  char buffer[13];&#xA;  buffer[12]= 0;&#xA;  if( Serial.available() &amp;gt;= 3 ) {&#xA;    String stat = String(&quot;OK&quot;);&#xA;&#xA;    Serial.readBytes(buffer, 3);&#xA;    buffer[3]= 0;&#xA;    String command= String(buffer);&#xA;&#xA;    Serial.println(command);&#xA;    if( command == &quot;GET&quot; ) {&#xA;      char outBuffer[7];&#xA;      sprintf(outBuffer, &quot; %02x%02x%02x&quot;, red, green, blue);&#xA;      stat += outBuffer;&#xA;    }&#xA;    else if( command == &quot;SET&quot; ) {&#xA;      if( Serial.available() &amp;gt;= 6 ) {&#xA;        Serial.readBytes(buffer, 6);&#xA;&#xA;        int redVal= (getVal(buffer[0])&amp;lt;&amp;lt;4) | (getVal(buffer[1]));&#xA;        int greenVal= (getVal(buffer[2])&amp;lt;&amp;lt;4) | (getVal(buffer[3]));&#xA;        int blueVal= (getVal(buffer[4])&amp;lt;&amp;lt;4) | (getVal(buffer[5]));&#xA;&#xA;        digitalWrite(redPin, map( redVal, 0, 255, 0, max_red) );&#xA;        digitalWrite(greenPin, map( greenVal, 0, 255, 0, max_green) );&#xA;        digitalWrite(bluePin, map( blueVal, 0, 255, 0, max_blue) );&#xA;&#xA;        red= redVal;&#xA;        green= greenVal;&#xA;        blue= blueVal;&#xA;&#xA;        char outBuffer[7];&#xA;        sprintf(outBuffer, &quot; %02x%02x%02x&quot;, redVal, greenVal, blueVal);&#xA;        stat += outBuffer;&#xA;      } else {&#xA;        stat = &quot;ERR&quot;;&#xA;      }&#xA;    }&#xA;    else {&#xA;      Serial.println(&quot;No Command&quot;);&#xA;    }&#xA;    Serial.println(stat);&#xA;    Serial.println(&quot;Clearing receive buffer&quot;);&#xA;    delay(1500);&#xA;    while(Serial.available()) {&#xA;      Serial.read();&#xA;      delay(100);&#xA;    }&#xA;    delay(1500);&#xA;  }&#xA;}&#xA;&#xA;byte getVal(char c)&#xA;{&#xA;  if(c &amp;gt;= '0' &amp;amp;&amp;amp; c &amp;lt;= '9') {&#xA;    return (byte)(c - '0');&#xA;  } else {&#xA;    return (byte)(c-'A'+10);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1604" LastEditorUserId="26916" LastEditDate="2017-09-10T00:51:18.627" LastActivityDate="2017-09-10T00:51:18.627" Title="GikFun Arduino Nano locking up on serial I/O" Tags="|arduino-nano|ch340|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24763" PostTypeId="2" ParentId="19454" CreationDate="2016-05-31T23:11:55.487" Score="-1" Body="&lt;p&gt;I had something same with my  &lt;a href=&quot;http://narodmon.ru/10262&quot; rel=&quot;nofollow&quot;&gt;Arduino UNO weather station&lt;/a&gt; until I switch to the PSU with lead battery. The most common thing is the power supply. &#xA;Try to use more powerful and use the ferrites on the PSU wires. &lt;/p&gt;&#xA;" OwnerUserId="21466" LastEditorUserId="10794" LastEditDate="2016-07-01T03:07:00.013" LastActivityDate="2016-07-01T03:07:00.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24764" PostTypeId="1" CreationDate="2016-05-31T23:43:28.373" Score="0" ViewCount="433" Body="&lt;p&gt;So I was working on a far more grand project, until I discovered that I couldn't get any of my servos to move.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've gone back to basics, and am trying to just get the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Sweep&quot; rel=&quot;nofollow noreferrer&quot;&gt;boilerplate code found here, working&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;  // create servo object to control a servo&#xA;// twelve servo objects can be created on most boards&#xA;&#xA;int pos = 0;    // variable to store the servo position&#xA;&#xA;void setup() {&#xA;  myservo.attach(9);  // attaches the servo on pin 9 to the servo object&#xA;}&#xA;&#xA;void loop() {&#xA;  for (pos = 0; pos &amp;lt;= 180; pos += 1) { // goes from 0 degrees to 180 degrees&#xA;    // in steps of 1 degree&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;  for (pos = 180; pos &amp;gt;= 0; pos -= 1) { // goes from 180 degrees to 0 degrees&#xA;    myservo.write(pos);              // tell servo to go to position in variable 'pos'&#xA;    delay(15);                       // waits 15ms for the servo to reach the position&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bK6ij.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here are pictures of my setup.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19093" LastEditorUserId="10794" LastEditDate="2016-06-01T06:08:03.227" LastActivityDate="2017-03-17T20:48:53.653" Title="I feel like an idiot, why can't I make a servo move with the boilerplate code?" Tags="|arduino-nano|servo|arduino-micro|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24765" PostTypeId="1" AcceptedAnswerId="24774" CreationDate="2016-06-01T00:18:39.283" Score="0" ViewCount="51" Body="&lt;p&gt;It seems in certain applications, for example signal processing, Arduino and other micro-controllers in general run into the overflow error when they're trying to store even moderate amounts of data. It would seem the obvious answer would be to simply take this data, push it onto the computer, and deal with it there instead, where you have much more available computing power. Is this possible with Arduino, or am I missing something that makes it not feasible?&lt;/p&gt;&#xA;" OwnerUserId="17238" LastActivityDate="2016-06-01T06:04:16.973" Title="Circumventing overflow error by pushing data into computer?" Tags="|arduino-mega|arduino-ide|usb|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24766" PostTypeId="2" ParentId="24762" CreationDate="2016-06-01T00:43:01.933" Score="0" Body="&lt;p&gt;The mix of delays and flushing in your code has a high chance of leading to unreliable operation.  Consider for example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Clearing receive buffer&quot;);&#xA;delay(1500);&#xA;while(Serial.available()) {&#xA;  Serial.read();&#xA;  delay(100);&#xA;}&#xA;delay(1500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As the loop there can only consume about 10 characters per second, it would be quite easy for something on the far end to produce inputs faster than they are consumed, essentially making the loop infinite.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Time-based delineation of serial messages tends to be quite risky; better reliability is usually had by using a defined delimiting condition - for example, ending each message with a newline character and reading until that is seen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;USB-serial conversion also introduces added challenges for time-based schemes, as it introduces a sense of grouping into packets into a stream which in its native form does not have any.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-01T00:43:01.933" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24767" PostTypeId="1" CreationDate="2016-06-01T02:30:33.787" Score="0" ViewCount="193" Body="&lt;p&gt;i have just started learning Arduino, so please be patient to me :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why doesnt my circuit below doesn't work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lmIQg.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lmIQg.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define led_green 2&#xA;#define led_yellow 8&#xA;#define led_red 13&#xA;&#xA;void setup() {&#xA;  pinMode(led_green, OUTPUT);&#xA;  pinMode(led_yellow, OUTPUT);&#xA;  pinMode(led_red, OUTPUT);&#xA;&#xA;  // Strarting all turned off&#xA;  digitalWrite(led_green, LOW);   &#xA;  digitalWrite(led_yellow, LOW);  &#xA;  digitalWrite(led_red, LOW);  &#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;digitalWrite(led_red, HIGH);&#xA;&#xA;delay(1000);&#xA;&#xA;digitalWrite(led_red, LOW);&#xA;digitalWrite(led_green, HIGH);&#xA;&#xA;delay(1000);&#xA;&#xA;digitalWrite(led_green, LOW);&#xA;digitalWrite(led_yellow, HIGH);&#xA;&#xA;delay(1000);&#xA;&#xA;digitalWrite(led_yellow, LOW);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm trying to reproduce this circuit that I saw in a tutorial: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xwl6c.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xwl6c.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="21607" LastActivityDate="2016-06-01T03:39:23.700" Title="Why doesn't my LEDs turn on?" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24768" PostTypeId="2" ParentId="24767" CreationDate="2016-06-01T03:32:54.003" Score="5" Body="&lt;p&gt;If you are doing what is in the first picture then you're doing it wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to make sure the led is horizontal, not vertical. The signal is going through the led and not making it into ground. And your ground is in the same lane as your signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you should learn how breadboards work and then move on from there. Its pretty simple and I think you'll learn it quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your code part, instead of defining the variables, you could just use &lt;code&gt;int&lt;/code&gt;.&#xA;&lt;br&gt; Refer to this as a starter tutorial, &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/&lt;/a&gt;.&#xA;&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NGQFq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NGQFq.png&quot; alt=&quot;This how the breadboard is connected underneath. &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how your wiring should look like if you followed the tutorial, &lt;a href=&quot;https://i.stack.imgur.com/fVlVt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fVlVt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20665" LastEditorUserId="20665" LastEditDate="2016-06-01T03:39:23.700" LastActivityDate="2016-06-01T03:39:23.700" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24770" PostTypeId="2" ParentId="24764" CreationDate="2016-06-01T04:17:36.187" Score="1" Body="&lt;p&gt;The only thing I see that could be the problem is with your servo wiring. It seems that most servos use this kind of wiring &lt;img src=&quot;https://i.stack.imgur.com/Y1Rim.gif&quot; alt=&quot;Servo Wires&quot;&gt;&lt;br&gt;&lt;br&gt; Which is the way that you seem to wire it, but depending on how Radioshack servos are made the signal wire could correspond with a different wire. I imagine this could possibly be on the packaging so I would start by looking there to confirm your wiring.&lt;/p&gt;&#xA;" OwnerUserId="21223" LastEditorUserId="11529" LastEditDate="2017-03-17T20:48:53.653" LastActivityDate="2017-03-17T20:48:53.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24772" PostTypeId="1" AcceptedAnswerId="24773" CreationDate="2016-06-01T05:55:34.543" Score="0" ViewCount="89" Body="&lt;p&gt;the GSM code i have been working out is up and running, I use JSON format in sending the data obtained by my sensors, but the JSON message I have been receiving contains parenthesis instead of curly braces. &lt;/p&gt;&#xA;" OwnerUserId="19001" LastActivityDate="2016-06-01T06:00:26.880" Title="message received from GSM contains parenthesis instead of curly braces" Tags="|arduino-mega|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24773" PostTypeId="2" ParentId="24772" CreationDate="2016-06-01T06:00:26.880" Score="0" Body="&lt;p&gt;One or both of your GSM endpoints is incapable of handling ESC prefixes according to &lt;a href=&quot;https://en.wikipedia.org/wiki/GSM_03.38&quot; rel=&quot;nofollow&quot;&gt;GSM 03.38&lt;/a&gt;. The only difference between &quot;{&quot; and &quot;}&quot; and &quot;(&quot; and &quot;)&quot; is that the former are signified by a preceding ESC which either is not being generated by the sender or is not being interpreted by the receiver.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-01T06:00:26.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24774" PostTypeId="2" ParentId="24765" CreationDate="2016-06-01T06:04:16.973" Score="1" Body="&lt;p&gt;One of the &quot;features&quot; of most microcontrollers/microprocessors is that they don't have a whole heap of RAM - this keeps costs down, and lets the manufacturers keep everything on one chip (unlike your PC).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However to &quot;push&quot; data to somewhere that can process it, you need to have a fast communications channel. SPI is quite fast, but you don't generally talk to PCs using SPI. Serial communication is slower, but if it gets converted into a USB interface (such as on a Uno) you can get respectable speeds talking to a PC. Something like 115200 baud is usually reliable, which lets you transmit 11520 bytes per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However it depends on what you want to send (ie. how many bytes), how you are going to indicate where one piece of data ends and the next one starts, maybe allow for error detection or correction, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Say, for example, it takes 5 bytes to send one piece of data (eg. 4 digits plus a delimiter). Now you are down to 11520/5 = 2304 pieces of data per second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This may or may not be adequate for whatever-it-is you are trying to do.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-01T06:04:16.973" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24776" PostTypeId="2" ParentId="24733" CreationDate="2016-06-01T08:55:42.743" Score="0" Body="&lt;p&gt;If in while loop, analogRead needs to be reassigned so it is constantly read. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int potential = analogRead(A0);&#xA;&#xA;void setup() {&#xA;  while (potential &amp;lt; 1023) {&#xA;    potential = analogRead(A0);&#xA;    ...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks guys for the help!&lt;/p&gt;&#xA;" OwnerUserId="21576" LastActivityDate="2016-06-01T08:55:42.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24777" PostTypeId="1" AcceptedAnswerId="24781" CreationDate="2016-06-01T09:17:41.113" Score="1" ViewCount="2518" Body="&lt;p&gt;So I'm aware the Arduino Uno can take 6-20 volts, with a recommended voltage of 7-12. But I have an unregulated 12v power adapter, which puts out about 18v with no load.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the time the Arduino won't be doing much of anything but powering a 16x2 LCD, which should take only a couple mA.* I have a 10k ohm resistor on the back light, so it should only take 0.5mA.&lt;br&gt;&#xA;&lt;sup&gt;*I don't have a datasheet, but from what I've read 1-2mA is reasonable&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino won't be doing anything else that would draw any meaningful amount of current (except looping to check for input, etc). Online sources generally indicate the power draw when not doing anything is a little under 50mA, so I'm guessing that's about what the current draw will be. Using the formula in &lt;a href=&quot;https://arduino.stackexchange.com/a/100/19256&quot;&gt;this answer&lt;/a&gt;, I calculate the power dissipation by the voltage regulator to be (18v-5v)*0.05A=0.65 Watts.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is this correct?&lt;/li&gt;&#xA;&lt;li&gt;Is the voltage regulator likely to overheat?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm not really concerned about power usage, because it will be plugged into the wall all the time. Also, the Arduino will be out of sight, but will have plenty of air around it to disipate heat (though not access to a breeze).&lt;/p&gt;&#xA;" OwnerUserId="19256" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-01T13:00:25.043" Title="Is it safe to power the Uno with 18v?" Tags="|power|current|heat|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24780" PostTypeId="2" ParentId="24686" CreationDate="2016-06-01T12:27:01.427" Score="0" Body="&lt;p&gt;I solved the problem by using millis() function. And now I ca get results like these;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/qExOA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qExOA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Sensirion.h&amp;gt;&#xA;#include &quot;DHT.h&quot;&#xA;unsigned long time;&#xA;&#xA;#define DHT1PIN 4&#xA;#define DHT2PIN 7&#xA;&#xA;#define DHT1TYPE DHT11&#xA;#define DHT2TYPE DHT11&#xA;&#xA;DHT dht1(DHT1PIN, DHT1TYPE);&#xA;DHT dht2(DHT2PIN, DHT2TYPE);&#xA;&#xA;const uint8_t dataPin =  9;              // SHT serial data&#xA;const uint8_t sclkPin =  8;              // SHT serial clock&#xA;const uint8_t ledPin  = 13;              // Arduino built-in LED&#xA;const uint32_t TRHSTEP   = 1000UL;       // Sensor query period&#xA;const uint32_t BLINKSTEP =  250UL;       // LED blink period&#xA;&#xA;Sensirion sht = Sensirion(dataPin, sclkPin);&#xA;&#xA;uint16_t rawData;&#xA;float temperature;&#xA;float humidity;&#xA;float dewpoint;&#xA;&#xA;byte ledState = 0;&#xA;byte measActive = false;&#xA;byte measType = TEMP;&#xA;&#xA;unsigned long trhMillis = 0;             // Time interval tracking&#xA;unsigned long blinkMillis = 0;&#xA;&#xA;void setup() {&#xA;  dht1.begin();&#xA;  dht2.begin();&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;In.(%) In.Tem(*C) Out.(%) Time&quot;);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  delay(15);                           // Wait &amp;gt;= 11 ms before first cmd&#xA;  // Demonstrate blocking calls&#xA;  sht.measTemp(&amp;amp;rawData);              // sht.meas(TEMP, &amp;amp;rawData, BLOCK)&#xA;  temperature = sht.calcTemp(rawData);&#xA;  sht.measHumi(&amp;amp;rawData);              // sht.meas(HUMI, &amp;amp;rawData, BLOCK)&#xA;  humidity = sht.calcHumi(rawData, temperature);&#xA;  dewpoint = sht.calcDewpoint(humidity, temperature);&#xA;  logData();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;&#xA;  unsigned long curMillis = millis();          // Get current time&#xA;&#xA;  // Rapidly blink LED.  Blocking calls take too long to allow this.&#xA;  if (curMillis - blinkMillis &amp;gt;= BLINKSTEP) {  // Time to toggle the LED state?&#xA;    ledState ^= 1;&#xA;    digitalWrite(ledPin, ledState);&#xA;    blinkMillis = curMillis;&#xA;  }&#xA;&#xA;  // Demonstrate non-blocking calls&#xA;  if (curMillis - trhMillis &amp;gt;= TRHSTEP) {      // Time for new measurements?&#xA;    measActive = true;&#xA;    measType = TEMP;&#xA;    sht.meas(TEMP, &amp;amp;rawData, NONBLOCK);      // Start temp measurement&#xA;    trhMillis = curMillis;&#xA;  }&#xA;  if (measActive &amp;amp;&amp;amp; sht.measRdy()) {           // Note: no error checking&#xA;    if (measType == TEMP) {                  // Process temp or humi?&#xA;      measType = HUMI;&#xA;      temperature = sht.calcTemp(rawData); // Convert raw sensor data&#xA;      sht.meas(HUMI, &amp;amp;rawData, NONBLOCK);  // Start humidity measurement&#xA;&#xA;      float h2 = dht2.readHumidity();&#xA;      float t2 = dht2.readTemperature();&#xA;&#xA;&#xA;      Serial.print(humidity);&#xA;      Serial.print(&quot; \t&quot;);&#xA;      Serial.print(temperature);&#xA;      Serial.print(&quot; \t&quot;);&#xA;&#xA;      if (isnan(t2) || isnan(h2)) {&#xA;        Serial.println(&quot;Failed to read from DHT #1&quot;);&#xA;      } else {&#xA;        Serial.print(h2);&#xA;        Serial.print(&quot; \t&quot;);&#xA;&#xA;        //time = millis();&#xA;        //prints time since program started&#xA;        Serial.println(curMillis);&#xA;      }&#xA;      Serial.println();&#xA;    }&#xA;    else {&#xA;      measActive = false;&#xA;      humidity = sht.calcHumi(rawData, temperature); // Convert raw sensor data&#xA;      dewpoint = sht.calcDewpoint(humidity, temperature);&#xA;      logData();&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void logData() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the difference is that I am using SHT75 instead of another DHT11 so I am simultaneously acquiring data from the both of them. Thanks for everyone!&lt;/p&gt;&#xA;" OwnerDisplayName="user21524" LastEditorDisplayName="user21524" LastEditDate="2016-06-01T12:36:32.510" LastActivityDate="2016-06-01T12:36:32.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24781" PostTypeId="2" ParentId="24777" CreationDate="2016-06-01T12:53:13.910" Score="2" Body="&lt;p&gt;It won't do any harm to try it at 18V for a while. Most voltage regulators have thermal protection and just cut out if they get a little too hot. If it works reliably, stay with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Their &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow&quot;&gt;Uno page&lt;/a&gt; warns against overheating the board, so I would test it for a short while and make sure there is no overheating or strong &quot;plastic&quot; smell coming from the board. If there's enough heat to worry, then it's best not to run like that for extended periods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 18V is too high, you could get a power resistor (I'd guess say a 10 watt resistor around 24 ohms) to waste approximately half an amp from the power supply. Connect this to the supply, in parallel with the Arduino.  It's wasteful (unless your room needs heating anyway) but will lower the voltage (that reaches the Arduino) a little.&lt;/p&gt;&#xA;" OwnerUserId="10135" LastEditorUserId="10135" LastEditDate="2016-06-01T13:00:25.043" LastActivityDate="2016-06-01T13:00:25.043" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24782" PostTypeId="2" ParentId="24760" CreationDate="2016-06-01T13:04:05.487" Score="1" Body="&lt;p&gt;Arduino libraries are normally written as a C++ Class.  When you start a sketch you normally tell the compiler where to find that Class and to Instantiate that class.  If the compiler does not find the Class and you attempt to Instantiate it, the compiler will telly you it does not know what to do.  That is, it will tell you the thing you are using (TMC26XStepper) does not describe anything or is not a Type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Study the &lt;a href=&quot;https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-libraries&quot; rel=&quot;nofollow&quot;&gt;structure of Arduino libraries&lt;/a&gt; to make sure what you have installed agrees with the common Arduino library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, newer version of the &lt;a href=&quot;https://www.arduino.cc/en/Guide/Libraries#toc3&quot; rel=&quot;nofollow&quot;&gt;Arduino IDE can download and unpack libraries automatically&lt;/a&gt; given both the IDE and the library are setup to do this.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-01T13:04:05.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24783" PostTypeId="1" AcceptedAnswerId="24801" CreationDate="2016-06-01T13:44:26.833" Score="0" ViewCount="2778" Body="&lt;p&gt;I am working on a robot which uses Ackermann's steering principle. Now the steering principal itself is in the development stage and the first prototype is pretty much good except for the fact that it can get turned very easily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was hoping to find a way to lock the servo operating the steering mechanism so that it only rotates when the servo does. Any way to do that??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using a UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-06-02T05:19:59.293" LastActivityDate="2016-06-02T11:05:11.263" Title="How do I lock a servo motor?" Tags="|arduino-uno|pwm|servo|" AnswerCount="1" CommentCount="12" ClosedDate="2016-06-04T05:48:51.240" ContentLicense="CC BY-SA 3.0" />
  <row Id="24784" PostTypeId="1" AcceptedAnswerId="24792" CreationDate="2016-06-01T14:23:15.140" Score="6" ViewCount="1547" Body="&lt;p&gt;Sometime I update my sketch in the Arduino environment, and when I click on the transfer arrow but forget to plug my arduino (I'm using the UART in my project so every time I need to plug/unplug some wires) it's a drama, avrdude throw this for at least 2 minutes :&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding&#xA;  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x32&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's a real pain because I can't stop avrdude when this happens.&#xA;Is there a way to configure the Arduino environment to disable it?&lt;/p&gt;&#xA;" OwnerUserId="21287" LastEditorUserId="19409" LastEditDate="2016-10-16T17:12:54.710" LastActivityDate="2022-01-08T16:34:44.417" Title="Avoid the 10 attempts of Avrdude when programmer is not responding" Tags="|arduino-ide|uploading|avrdude|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24786" PostTypeId="2" ParentId="23730" CreationDate="2016-06-01T15:55:14.270" Score="1" Body="&lt;p&gt;You can turn on GPRS data connection on your GSM shield and perform HTTP GET or POST request to the web page script (for example PHP script), which in turn will access the MySQL database (write or read DB records). It is easier than implementing REST API.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-06-01T15:55:14.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24787" PostTypeId="1" AcceptedAnswerId="24789" CreationDate="2016-06-01T15:56:55.257" Score="0" ViewCount="334" Body="&lt;p&gt;I am designing a peristaltic pump and need some advice for parts. I am using an Arduino Leonardo and also have an UNO and am planning on adding a temperature and pH sensor as well. I have two questions: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1) I am planning to use a Stepper Motor but am unsure if I should use the &lt;em&gt;NEMA 17 or 23&lt;/em&gt; or some other motor. I need a relatively &quot;high&quot; amount of torque maybe around 1 to 3 N-m.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2) Should I go with a Motor Shield or Motor Driver. I am currently looking at the &lt;em&gt;Big Easy Driver&lt;/em&gt; or &lt;em&gt;A4988 Bipolar Driver&lt;/em&gt; or the simple &lt;em&gt;Arduino Motor Shield&lt;/em&gt;.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know which of these would be best or have any suggestions? Thank you very much!&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-06-01T16:41:35.890" Title="Peristaltic Pump Project" Tags="|power|motor|shields|arduino-leonardo|current|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24788" PostTypeId="2" ParentId="24744" CreationDate="2016-06-01T16:17:52.447" Score="1" Body="&lt;p&gt;It sounds like you want some device with a 9-bit protocol to send data to an Arduino, and then the Arduino to forward that data (perhaps in a slightly different format) to a PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People who want to connect their Arduino to two serial devices at the same time (and the PC counts as one) generally either:&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Change the hardware to accept multiple serial devices&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;While the Arduino Uno has only one hardware serial port, the following (and probably many others) have 2 or more hardware serial ports:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 2560&lt;/a&gt; (USB and 3 other hardware serial ports)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo&lt;/a&gt; (USB and 1 other hardware serial port)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.pjrc.com/teensy/teensyLC.html&quot; rel=&quot;nofollow&quot;&gt;Teensy LC&lt;/a&gt; (USB and 3 other hardware serial ports) (&lt;a href=&quot;https://forum.pjrc.com/threads/23873-serial-9-bit-on-the-t3&quot; rel=&quot;nofollow&quot;&gt;&quot;serial 9-bit on the t3&quot;&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(&lt;a href=&quot;http://blog.bouni.de/blog/2014/10/07/sending-and-receiving-9-bit-frames-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;&quot;Sending and Receiving 9-bit Frames with Arduino&quot;&lt;/a&gt; uses the hardware approach).&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Change the software to accept multiple serial devices&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;In principle, it's possible to tweak SoftwareSerial to handle 9-bit data.&#xA;Several people have talked about it&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=345147.0&quot; rel=&quot;nofollow&quot;&gt;&quot;9bit SoftwareSerial library modification&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://citizengadget.com/post/22556427458/altering-new-soft-serial-nss-for-9-bit-cans-of&quot; rel=&quot;nofollow&quot;&gt;&quot;Altering New Soft Serial NSS for 9 bit- cans of open source worms&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2016-06-01T16:17:52.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24789" PostTypeId="2" ParentId="24787" CreationDate="2016-06-01T16:41:35.890" Score="1" Body="&lt;p&gt;The specifications for each stepper motor varies, with the larger models having the greater torque. With great torque comes the requirement of great power. A quick search for nema 17 stepper motors finds the torque figures on the low side of your request, while the nema 23 motors display a greater range, including your figures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The additional power requirements may exceed the capabilities of the Arduino Motor Shield (2a per channel, 4a max), while the A4988 board specifies up to 2a per coil. Also note that to achieve the use of the higher power levels, these boards will require heat sinks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you expect to require the higher figure for torque, consider to research for a driver board that has a greater power limit, &quot;just in case&quot;.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-01T16:41:35.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24790" PostTypeId="1" AcceptedAnswerId="24791" CreationDate="2016-06-01T17:27:08.633" Score="10" ViewCount="21270" Body="&lt;p&gt;I don't yet own an Arduino board to run code on, and as the title says, I'm curious if the &lt;a href=&quot;http://www.cplusplus.com/reference/&quot; rel=&quot;noreferrer&quot;&gt;C++ STL&lt;/a&gt; is fully supported on Arduino &lt;strong&gt;and already part of&lt;/strong&gt; the Arduino IDE. The STL is probably the most efficient, fully tested, and resource-minimal (which is a slightly redundant phrase, as I already mentioned efficiency) publicly available C++ code out there, and would make life much easier to code for Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;If&lt;/em&gt; the STL is not a part of Arduino IDE, then how to include specific libraries such as &lt;code&gt;&amp;lt;algorithm&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;utility&amp;gt;&lt;/code&gt;? (I'm very tempted to ask &quot;why isn't it included?&quot; but that seems too broad.)&lt;/p&gt;&#xA;" OwnerUserId="21629" LastActivityDate="2018-05-03T20:18:17.833" Title="Is the C++ STL fully supported on Arduino?" Tags="|c++|stl|" AnswerCount="4" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24791" PostTypeId="2" ParentId="24790" CreationDate="2016-06-01T17:39:09.810" Score="10" Body="&lt;p&gt;The STL is not a part of Arduino IDE.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although efficient by desktop standards, the consensus is it doesn't fit comfortably in an Arduino's limited space.  That said, here's someone who seems to have done it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/maniacbug/StandardCplusplus&quot;&gt;https://github.com/maniacbug/StandardCplusplus&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check out the forks, they seem more up to date&lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-06-01T17:39:09.810" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="24792" PostTypeId="2" ParentId="24784" CreationDate="2016-06-01T18:00:58.880" Score="1" Body="&lt;p&gt;Unfortunately, &lt;code&gt;MAX_SYNC_ATTEMPTS&lt;/code&gt; is a constant in the source code, and one which appears several times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;avrdude is an open source project, so customizing and building it should be relatively straightforward.  Since it is a numeric rather than string value, and is checked in several places, simply modifying the binary is likely to be tricky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One can of course manually kill the process, though it is annoying to have to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another approach could be to write a wrapper which might potentially do some sanity checking first (does any other process have the port open?) and then would launch avrdude as its child, passing through all the arguments.  By monitoring the output before passing it on, it should be possible to detect this message and terminate the avrdude instance automatically.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-01T18:00:58.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24793" PostTypeId="1" AcceptedAnswerId="24794" CreationDate="2016-06-01T22:39:16.267" Score="0" ViewCount="7741" Body="&lt;p&gt;I actually have a SparkFun RedBoard, but I think this question applies to Arduino Uno and other boards as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wondering how much control the programmer has over the various LEDs on the board. First there's the &quot;ON&quot; LED which is very bright. Can this be turned off or dimmed, or do I need to resort to electrical tape?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More annoying is the &quot;TX&quot; and &quot;RX&quot; LEDs. These blink rapidly when data is being communicated over the USB-serial connection. I'm guessing these are not configurable, but I couldn't find the answer anywhere online.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that the &quot;Pin 13 LED&quot; can be controlled (via Pin 13!).&lt;/p&gt;&#xA;" OwnerUserId="21201" LastActivityDate="2016-06-01T23:03:08.833" Title="How do I stop the Arduino TX/RX LEDs from flashing? How do I turn off the &quot;ON&quot; LED?" Tags="|arduino-uno|led|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24794" PostTypeId="2" ParentId="24793" CreationDate="2016-06-01T23:03:08.833" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm wondering how much control the programmer has over the various LEDs on the board. First there's the &quot;ON&quot; LED which is very bright. Can this be turned off or dimmed, or do I need to resort to electrical tape?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Remove it, remove the resistor inline with it, or cut the track powering it. Either that or resort to electrical tape (or blu-tack). You have absolutely no control over it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;More annoying is the &quot;TX&quot; and &quot;RX&quot; LEDs. These blink rapidly when data is being communicated over the USB-serial connection. I'm guessing these are not configurable, but I couldn't find the answer anywhere online.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If your board uses an ATMega16U2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As above, or compile a custom version of the ATMega16U2 firmware and flash it on to the ATMega16U2 chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If your board uses an FT232 chip&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Download the FT232 EEPROM editing program from FTDI and use that to reconfigure the IO pins the LEDs are attached to so they do nothing. If you are on Linux you can use libftdi's &lt;code&gt;ftdi_eeprom&lt;/code&gt; program.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-01T23:03:08.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24795" PostTypeId="1" AcceptedAnswerId="24809" CreationDate="2016-06-02T03:16:56.660" Score="4" ViewCount="363" Body="&lt;p&gt;TL;DR: Multiple Arduinos listening to a single serial rail are burning out my HC-05's TX pin. Arduinos are leaking voltage onto the signal rail. How do I stop, or isolate that to keep from burning out Bluetooth TX pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to build an LED-based track light that uses an HC-05 to communicate with up to 8 Arduinos to control up to 16 LEDs total. Each Arduino can only control 2 LEDs because of the shape and form factor of the project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The track has 3 rails, 12V, Ground and Signal and all Arduinos share the same rails. Hopefully the schematic below does a good job explaining it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ka3b8.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ka3b8.png&quot; alt=&quot;Arduinos all share common ground, 12v and data line&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On to my issue. Initially, I was getting almost 5V from my pin 7 (SoftwareSerial pin) on the Arduinos, which was quietly ruining the TX pin on my HC-05. I lowered that to about 1v after using &lt;code&gt;pinMode(bluetoothTx, INPUT);&lt;/code&gt;, which is good but not good enough. That voltage starts to add up as I add more and more Arduinos to the overall setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution in theory is to add diodes to pin 7 on the Arduinos, so they can't put voltage on the signal rail. This drops the voltage by 0.7v from what I've read, which most likely is why the Arduinos aren't reading a signal now, because that drops it below the logic level required, since the HC-05 is only putting out 3v3. So I think to add a level shifter on the HC-05 to pump up the signal to 5v, then the diode's voltage drop shouldn't matter right? See schematic below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/krmGx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/krmGx.png&quot; alt=&quot;Diode&amp;#39;s keep pins from leaking voltage onto line, level shifter compensates for voltage drop over diode&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My solution seems unnecessarily convoluted and I don't even know if it would work. The more I read without bouncing the information off of others, the more confused I am becoming. Now after reformatting this post for an hour, I am thinking about a decoupling capacitor between the pin and ground... Will that have the effect I am looking for?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also looked into using a pulldown resistor, but from everything I've seen (and from the first electronics course I've taken), it seems like an inappropriate solution. The examples I've seen usually use a switch, which makes sense, but for my application I am protecting the TX pin on my HC-05, so I think it would not give the effect I am looking for (tapping the line in between resistor and pin would not isolate the voltage, tapping in after the resistor would short the signal to ground).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm including my code for completeness, but the schematic is where I think I need help. Could someone point me in the right direction, I don't mind working for my answers but I've been going solo at this for over a month now, and I'm not even at the point in my education where we've covered much logic yet. I'm reaching a little here.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;byte address = 1; //change this to change light address&#xA;byte lightno = (address + 1); // variable to print light number&#xA;int addressShifter= ((address)*500); //This number will be subtracted from input&#xA;int bluetoothTx = 7; //btTX to pin 7 //input from HC-05&#xA;int bluetoothRx = 8; //btRX to pin 8 //not used&#xA;int led1 = 3; // the PWM pin LED1 is attached to&#xA;int led2 = 5; // the PWM pin LED2 is attached to&#xA;int brightness1 = EEPROM.read(0); //Recalling previous setting&#xA;int brightness2 = EEPROM.read(1); //Recalling previous setting&#xA;int thismodMin = (0 + addressShifter); //min two-byte looked for&#xA;int thismodMax = (499 + addressShifter); //max two-byte looked for&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); //naming it bluetooth and assigning it to the variables shown&#xA;&#xA;void setup() {&#xA;    pinMode(led1, OUTPUT); // sets the pin as output&#xA;    pinMode(led2, OUTPUT); // sets the pin as output&#xA;    pinMode(bluetoothTx, INPUT); // sets the pin as input&#xA;    //Setup usb serial connection to computer&#xA;    Serial.begin(9600);&#xA;    //Setup Bluetooth serial connection to android&#xA;    bluetooth.begin(9600);&#xA;    analogWrite(led1, brightness1); //Set Led brightness from stored values&#xA;    analogWrite(led2, brightness2); //Set Led brightness from stored values&#xA;    Serial.println(&quot;SETUP COMPLETE, I am Light #&quot;); //Identify self&#xA;    Serial.println(lightno);&#xA;    Serial.println(&quot;expecting Min &quot;); //Min value listened for&#xA;    Serial.println(thismodMin);&#xA;    Serial.println(&quot;expecting Max &quot;); //Max value listened for&#xA;    Serial.println(thismodMax);&#xA;}&#xA;&#xA;void loop() {&#xA;    //---------Serial Communication---------&#xA;    if(bluetooth.available()&amp;gt;= 2) {&#xA;        unsigned int blu1 = bluetooth.read();&#xA;        unsigned int blu2 = bluetooth.read();&#xA;        unsigned int blueinput = (blu2 *256) + blu1;&#xA;        //I don't know why any of the above is neccesary but it will not read correctly without this conversion&#xA;        //Serial.println(&quot;blueinput = &quot;); Not used&#xA;        //Serial.println(blueinput);  Not used&#xA;        if (((blueinput) &amp;gt;= (thismodMin)) &amp;amp;&amp;amp; ((blueinput) &amp;lt; (thismodMax))){&#xA;            //If this blueinput is within this modules adress range, convert signal to PWM&#xA;            int thisMod = ((blueinput) - (addressShifter));&#xA;            //Convert blueinput to a value this module will work with (0-500)&#xA;            //-----------Lights---------&#xA;            if (((thisMod) &amp;gt;= 0) &amp;amp;&amp;amp; ((thisMod) &amp;lt; 100)){ //0=off 1-100=on-Bright&#xA;                brightness1 = ((thisMod)*2.55); //converts percentage brightness to PWM value&#xA;                analogWrite(led1, brightness1); //apply brightness&#xA;                //      Serial.println(&quot;brightness1: &quot;); //diagnostics&#xA;                //      Serial.println(brightness1); //diagnostics&#xA;                delay(10);&#xA;            } else if (((thisMod) &amp;gt;= 101) &amp;amp;&amp;amp; ((thisMod) &amp;lt; 201)){ //101=off 102-201=on-Bright&#xA;                brightness2 = (((thisMod)-101)*2.55); //subtract starting value and then convert percentage brightness to PWM value&#xA;                analogWrite(led2, brightness2); //apply brightness&#xA;                //      Serial.println(&quot;brightness2: &quot;); //diagnostics&#xA;                //      Serial.println(brightness2); //diagnostics&#xA;                delay(10);&#xA;            } else if ((thisMod) == (399)){ //if specific code recieved&#xA;                EEPROM.write(0, brightness1); //store brightness setting for light 1&#xA;                Serial.println(&quot;Epprom1 written&quot;);&#xA;            } else if ((thisMod) == (424)){&#xA;                EEPROM.write(1, brightness2); //store brightness setting for light 2&#xA;                Serial.println(&quot;Epprom2 written&quot;);&#xA;            } else{}&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21632" LastEditorUserId="4628" LastEditDate="2016-12-30T08:20:44.593" LastActivityDate="2018-06-25T06:21:58.260" Title="Problems running several Arduinos off of one HC-05 Tx pin" Tags="|serial|c++|arduino-nano|softwareserial|hc-05|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24799" PostTypeId="1" AcceptedAnswerId="24800" CreationDate="2016-06-02T06:06:46.490" Score="0" ViewCount="116" Body="&lt;p&gt;The max PWM frequency that can be achieved with an Arduino is by using the PWM fast mode with the pre-scaler set at 1 and the TOP counter value at 3, getting 4MHz &lt;/p&gt;&#xA;&#xA;&lt;p&gt;f_OC = 16000000/(1(1 + 3)) = 4000000&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why can't be the TOP value set at 1?&lt;/p&gt;&#xA;" OwnerUserId="18574" LastActivityDate="2016-06-02T06:08:23.070" Title="Why can't the OCR1A register be set to 1 to get a 8MHz PWM?" Tags="|pwm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24800" PostTypeId="2" ParentId="24799" CreationDate="2016-06-02T06:08:23.070" Score="2" Body="&lt;p&gt;Because then you only have 1-bit PWM. And there aren't an awful lot of applications for 1-bit PWM.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-02T06:08:23.070" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24801" PostTypeId="2" ParentId="24783" CreationDate="2016-06-02T06:12:04.077" Score="0" Body="&lt;p&gt;A normale servo will stay in position when:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It's powered up (with enough current)&lt;/li&gt;&#xA;&lt;li&gt;You are feeding the control signal into it.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;It's rated for the amount of force applied.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Based on your comments, it seems that it's not a regular servo or could be faulty.&#xA;I couldn't find the datasheet for your servo, so I can't tell if it's normal behavior, though it seems unlikely. (Servo's aren't made to bounce around)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;It doesn't really make sense that it could be easily rotated by touching it, that would also mean that it can't lift anything? I would suggest trying another servo.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="8033" LastEditDate="2016-06-02T11:05:11.263" LastActivityDate="2016-06-02T11:05:11.263" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24802" PostTypeId="2" ParentId="15893" CreationDate="2016-06-02T07:24:08.743" Score="30" Body="&lt;p&gt;I use the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc&quot; rel=&quot;noreferrer&quot;&gt;command-line interface to the &lt;code&gt;arduino&lt;/code&gt; command&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I run it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino --upload sketch/sketch.ino --port /dev/ttyUSB*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Learning/CommandLine&quot; rel=&quot;noreferrer&quot;&gt;There is a page&lt;/a&gt; which describes other command-line tools, like &lt;code&gt;inotool&lt;/code&gt;. That page also has an example &lt;code&gt;Makefile&lt;/code&gt;. These alternatives seem enticing, but apparently, as of this writing, none of them work. I'm assuming this is due to some recent changes in Arduino IDE distribution files which they depend on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Running &lt;code&gt;arduino&lt;/code&gt; as above is a bit slow, because it has to load Java I guess, but at least it works. There is also an &lt;a href=&quot;https://github.com/arduino/arduino-builder&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;arduino-builder&lt;/code&gt;&lt;/a&gt; command that comes with the Arduino IDE distribution. As of this writing, it was not sufficiently well-documented for me to be able to figure out how to use it. For instance there are no example command lines in the README or in any of the tutorials I came across, and I couldn't figure out how to use it to upload code to the board. However, presumably it is able to give us a faster compile than &lt;code&gt;arduino&lt;/code&gt;. The README also mentions being able to reuse object files from a previous compile, so there is some make-like functionality.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To view serial output &lt;a href=&quot;https://arduino.stackexchange.com/questions/24741/how-do-i-read-from-dev-ttyacm0-in-linux-without-a-terminal-emulator&quot;&gt;I use something like&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -F /dev/ttyUSB* 1000000 raw -clocal -echo&#xA;cat /dev/ttyUSB*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The number 1000000 should match the number you pass to &lt;code&gt;Serial.begin()&lt;/code&gt; in your board code. You can also use &lt;code&gt;screen&lt;/code&gt; if you have a board program which is appropriately interactive, or you can use whatever utility to write directly to the device. By the way, my Due shows up as &lt;code&gt;/dev/ttyACM0&lt;/code&gt; (rather than &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; for the Uno).&lt;/p&gt;&#xA;" OwnerUserId="21201" LastEditorUserId="21201" LastEditDate="2019-12-03T05:39:03.407" LastActivityDate="2019-12-03T05:39:03.407" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="24803" PostTypeId="1" AcceptedAnswerId="24804" CreationDate="2016-06-02T09:04:30.790" Score="0" ViewCount="87" Body="&lt;p&gt;I have a project that requires opening a door remotely. I'm using an arduino Yún and a raspberry pi.&#xA; I have a switch connected to the RPI and i'm sending it's value to a web server. How can I get the value from the website to the arduino, so that it can process it and see if an order to open the door is issued?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help :)&lt;/p&gt;&#xA;" OwnerUserId="21640" LastActivityDate="2016-06-02T09:32:42.940" Title="Get value from a website using Yún and a RPi" Tags="|arduino-yun|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24804" PostTypeId="2" ParentId="24803" CreationDate="2016-06-02T09:32:42.940" Score="0" Body="&lt;p&gt;You need to use the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Process&quot; rel=&quot;nofollow&quot;&gt;Process&lt;/a&gt; library that comes with the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That allows you to execute commands on the Linux portion of the Yun from within your Arduino code, and get data back from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You use that class to execute the &lt;code&gt;curl&lt;/code&gt; command in Linux to fetch the content of a web page and return that content to the AVR code where you can deal with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the content of the web page is complex it may be worth passing the output of &lt;code&gt;curl&lt;/code&gt; through some other Linux based commands first (such as &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;cut&lt;/code&gt; or &lt;code&gt;awk&lt;/code&gt;) to clean it up and reduce the amount of text you have to deal with at the AVR end.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-02T09:32:42.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24807" PostTypeId="1" AcceptedAnswerId="24808" CreationDate="2016-06-02T10:35:14.430" Score="3" ViewCount="3063" Body="&lt;h2&gt;This is the code I uploaded in Arduino UNO:&lt;/h2&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial ESP(2,3); // RX, TX&#xA;//ESP RX--&amp;gt;3(UNO) TX--&amp;gt;2(UNO)&#xA;&#xA;void setup() {&#xA;// Open serial communications and wait for port to open:&#xA;&#xA;    Serial.begin(9600);&#xA;    while (!Serial) {&#xA;        ; // wait for serial port to connect. Needed for native USB port only&#xA;    }&#xA;&#xA;    Serial.println(&quot;Goodnight moon!&quot;);&#xA;&#xA;    // set the data rate for the SoftwareSerial port&#xA;    ESP.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    if (ESP.available()) {&#xA;        char inData = ESP.read();&#xA;        Serial.println(&quot;Got reponse from ESP8266: &quot;);&#xA;        Serial.write(inData);&#xA;    }&#xA;&#xA;    ESP.write(&quot;AT\r\n&quot;); //Normally ESP responds to AT command with &quot;OK&quot;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;But ESP is not able to receive the AT command properly...sometimes it recieves A, sometime T. It then responds with garbage value. Though we are able to give command to ESP through Serial Monitor and it responds pretty well. But when trying to communicate through code, the communication is not OK.&lt;/p&gt;&#xA;" OwnerUserId="21650" OwnerDisplayName="abhimanyu bishnoi" LastEditorUserId="19409" LastEditDate="2016-12-20T08:10:09.933" LastActivityDate="2016-12-20T08:10:09.933" Title="ESP8266 not able to communicate over serial connection with arduino UNO" Tags="|c|uart|esp8266|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24808" PostTypeId="2" ParentId="24807" CreationDate="2016-06-02T11:25:58.630" Score="4" Body="&lt;p&gt;The problem is in your &lt;code&gt;loop()&lt;/code&gt; function. On each iteration, you will receive &lt;strong&gt;at most one&lt;/strong&gt; character from the SoftwareSerial, while writing the same AT command again and again. As a result, your slave device (ie. ESP8266) will overflow its UART buffers, resulting in garbage being sent and received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should keep receiving data from the slave for as long as it has data:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (ESP.available()) {&#xA;    char inData = ESP.read();&#xA;    Serial.println(&quot;Got response from ESP8266: &quot;);&#xA;    Serial.write(inData);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13327" OwnerDisplayName="Dmitry Grigoryev" LastEditorUserId="19409" LastEditDate="2016-12-20T08:10:03.393" LastActivityDate="2016-12-20T08:10:03.393" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24809" PostTypeId="2" ParentId="24795" CreationDate="2016-06-02T13:22:49.380" Score="2" Body="&lt;p&gt;&lt;strong&gt;first of all just to clarify some things.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;softwareSerial library sets PinMode for rx,tx declared pins internally so it should not have any impact on voltages you measure if you include &lt;code&gt;pinMode(bluetoothTx, INPUT);&lt;/code&gt; and if this happens, as you describe, it indicates a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a pin declared as INPUT is on a high impedance state which means that it will not (in general) affect signals connected to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;an RX pin, by default is &lt;em&gt;pulled up&lt;/em&gt; which means that when you do not have anything connected to it, you should measure 5V and when you connect it to GND you should read 0V. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;i tried to reproduce your problem by implementing your first schematic utilizing 3 arduinos as receivers with the difference of having another arduino as transmitter instead of HC-05 and using a simplified version of your program (see it below).&#xA;I could not reproduce it. Also, I suspect that parallel pull up resistors from ~8 arduinos may be the problem, so I would suggest:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;make sure communication between HC-05 and only one arduino works.&lt;/li&gt;&#xA;&lt;li&gt;try connecting HC-05 with two arduinos and see if both arduinos are able to read incoming data.&lt;/li&gt;&#xA;&lt;li&gt;keep adding arduinos and checking if every arduino can read incoming data.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;also try with another arduino as transmitter instead of HC-05 in case you still have a problem and post the results so we can further investigate .&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;int bluetoothTx = 7;    //btTX to pin 7 //input from HC-05&#xA;int bluetoothRx = 8;    //btRX to pin 8 //not used&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);  //naming it bluetooth and assigning it to the variables shown&#xA;&#xA;void setup()&#xA;{&#xA;        //Setup usb serial connection to computer&#xA;        Serial.begin(9600);&#xA;&#xA;        //Setup Bluetooth serial connection to android&#xA;        bluetooth.begin(9600);&#xA;&#xA;        Serial.println(&quot;SETUP COMPLETE, I am Light #&quot;);  //Identify self&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;        //---------Serial Communication------&#xA;        if(bluetooth.available() )&#xA;        {&#xA;             Serial.print(bluetooth.read(),HEX );&#xA;        }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20645" LastActivityDate="2016-06-02T13:22:49.380" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24810" PostTypeId="2" ParentId="24790" CreationDate="2016-06-02T14:00:46.293" Score="2" Body="&lt;p&gt;The STL is not part of Arduino and no support for &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_cplusplus.html&quot; rel=&quot;nofollow&quot;&gt;libstc++ from AVR&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My &quot;answer&quot; differences from Malachi at one point though, as explained in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't think you shouldn't, just because &quot;most people say&quot; that you shouldn't. There are a lot of people that even think you shouldn't use C++ at all.&#xA;The problem is that C++ (and C++ standard library) are very powerful and may be ported in a non-efficient way.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why use libstdc++?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think, however, that if you use it with care, it can be very usefull.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we've got two buffers, a send buffer and a receive buffer.&#xA;With C, you would store them in a fixed char array. In C++ you can use dynamic containers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in C, you'll use 2x 256 bytes of memory to save your messages. Any longer message won't fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In C++ you'll use only whatever bytes are needed at one point (plus some extra probably). And if you get a longer message, it will simply scale up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the C++ thing works for you, and just test it very very well, why not use it? On average, it will use less memory, since you don't assign all of it when it's not used. You will have a problem when your messages get too big, since your memory will overflow, often causing the microcontroller to reset. But if more buffers in your program are dynamic, one may leave some space for the other, etc. Effectively using the memory more efficient!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, without dynamic allocation, it might be a little safer, since you've already claimed those pieces of memory, there is no way you can't use those pieces. Any message that is bigger, simply won't fit, but you can easily check on that. Another thing is that the C++ stl's you find, might not be as well optimalised for your architecture/microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, creating your very own dynamic storage in C may cause even more problems than the C++ stl ;). And it's not like you have to use dynamic storage for everything, simply being able to do so is nice.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Current microcontrollers are also getting much more serious as the 8-bit Arduino's (328P). 20$ can get you a Teensy 3.2 which has &lt;code&gt;256K Flash Memory, 64K RAM&lt;/code&gt; so, in this case, dynamic memory can be very useful (if you are certain you always have enough memory left). &#xA;Also: &lt;code&gt;All STM32F41xxx products embed: Up to 192 Kbytes of system SRAM including 64 Kbytes of CCM (core coupled memory) data RAM&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;By that, it can also be a very nice way to learn C++ and program in the same language as you do on the PC.&#xA;But keep in mind that on an 8-bit micro, you should check if your stl-functions don't give too much overhead.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;How use C++ standard template library for AVR?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've followed the blog from &lt;a href=&quot;http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/&quot; rel=&quot;nofollow&quot;&gt;Andy Brown&lt;/a&gt; and now have iterators/string/vectors working in AtmelStudio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I did get some errors, the first batch of errors included:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Error        '_M_deallocate' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]      D:\avr-stl\include\string    173&#xA;Message        declarations in dependent base 'std::_String_alloc_base&amp;lt;char, std::allocator&amp;lt;char&amp;gt;, true&amp;gt;' are not found by unqualified lookup        D:\avr-stl\include\string    173&#xA;Message        use 'this-&amp;gt;_M_deallocate' instead     D:\avr-stl\include\string    173&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This error actually explains itself; you should use &lt;code&gt;this-&amp;gt;_M_deallocate&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I got &lt;code&gt;undefined reference to &quot;operator new(unsigned int, void*)&lt;/code&gt;. But I fixed it by including &quot;pnew.cpp&quot; right under &lt;code&gt;#include &amp;lt;new&amp;gt;&lt;/code&gt;  in &lt;code&gt;stl_construct.h&lt;/code&gt; which is weird, but it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Piece of stl_construct.h)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef __SGI_STL_INTERNAL_CONSTRUCT_H&#xA;#define __SGI_STL_INTERNAL_CONSTRUCT_H&#xA;&#xA;#include &amp;lt;new&amp;gt;&#xA;#include &amp;lt;pnew.cpp&amp;gt;&#xA;&#xA;__STL_BEGIN_NAMESPACE&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-02T14:00:46.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24811" PostTypeId="1" CreationDate="2016-06-02T14:15:45.933" Score="1" ViewCount="64" Body="&lt;p&gt;When I am including the &lt;code&gt;Adafruit_BMP280&lt;/code&gt; library, Arduino IDE 1.7.10 complains that it wants all dependent libraries included:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_Sensors.h&#xA;Wire.h&#xA;SPI.h&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Isn't it possible to circumvent that? &lt;a href=&quot;https://stackoverflow.com/questions/6504211/is-it-possible-to-include-a-library-from-another-library-using-the-arduino-ide&quot;&gt;This question&lt;/a&gt; says to include the first library like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Adafruit_BMP280&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but also with the full path, this doesn't work and just returns the same error.&lt;/p&gt;&#xA;" OwnerUserId="20459" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-10-30T16:54:51.053" Title="Any way to not explicitly include dependent libraries?" Tags="|library|adafruit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24812" PostTypeId="2" ParentId="24811" CreationDate="2016-06-02T14:26:30.640" Score="1" Body="&lt;p&gt;No, it is not possible. The IDE needs to know which libraries you are using so that it can compile the source code for them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other IDEs have got around the problem by recursively scanning the libraries themselves and building up a list of dependencies (such as &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt;) but this is not something that the Arduino IDE has been programmed to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only other possible option might be to create a single massive library that contains everything that the &quot;main&quot; library relies on, however this may cause problems with other libraries also wanting the same things and you ending up with massive conflicts.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-02T14:26:30.640" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24813" PostTypeId="2" ParentId="24790" CreationDate="2016-06-02T14:54:30.033" Score="3" Body="&lt;p&gt;STL is efficient on the platform it was designed for, which is personal computers and similar-scale devices, where allocating a single byte in the heap consumes a 4k memory page (that's several times as much as ALL Arduino RAM), and where array indexes can be efficiently replaced by pointers (8-bit microcontrollers need at least two commands to deal with a pointer). So no, it's not efficient with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Think of quicksort algorithm - it performs very well on large lists, but is easily beaten by a simple sort if you need to sort an array of 5 elements. Being asymptotically efficient doesn't mean being efficient in every case.&lt;/p&gt;&#xA;" OwnerUserId="13327" LastActivityDate="2016-06-02T14:54:30.033" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24814" PostTypeId="1" CreationDate="2016-06-02T15:09:52.353" Score="1" ViewCount="877" Body="&lt;p&gt;So I have an application that runs on the Arduino that passes info over serial.&#xA;I'm using a ESP2866 to make it wireless.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino-&amp;gt;Serial-&amp;gt;Esp2866-&amp;gt;SocketConn-&amp;gt;JavaSocket-&amp;gt;Console&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have a working java socket server, that I can connect to with other applications. (Java, c++, ext.) And even across the network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just cant seem to get my ESP2866 to connect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Iv tried several ESP2866 units, no success. Iv tried updating the firmware on each, nope.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT                      -&amp;gt;  OK&#xA;AT+RST                  -&amp;gt;  ready&#xA;AT+CWMODE=1             -&amp;gt;  OK&#xA;AT+CWJAP=&quot;name&quot;,&quot;pass&quot;  -&amp;gt;  CONNECTED,GOTIP,OK&#xA;AT+CIPMUX=0             -&amp;gt;  OK&#xA;AT+CIFSR                -&amp;gt;  192.168.0.30&#xA;AT+CIPSTART=&quot;TCP&quot;,&quot;192.168.0.9&quot;,&quot;4160&quot;  -&amp;gt;  ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The lack of debug info is... Aggravating.&#xA;Iv Seen other examples of this that worked. So whats the problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additional info:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;netstat -tulpn | grep 4160&#xA;tcp6       0      0 :::4160          :::*      LISTEN      23058/java   &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Edit 1:)Just tried restricting to IPV4 and rebinding the port. Nope. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;InetAddress localAddress = Inet4Address.getByAddress(new byte[]{(byte) 192,(byte) 168,0,9});&#xA;System.setProperty(&quot;java.net.preferIPv4Stack&quot;, &quot;true&quot;);&#xA;ServerSocket listener = new ServerSocket(port,20,localAddress);&#xA;//...Code to make socket work.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21651" LastEditorUserId="21651" LastEditDate="2016-06-02T15:58:01.003" LastActivityDate="2017-10-31T20:23:34.140" Title="ESP2866 and java ServerSocket" Tags="|arduino-uno|esp8266|linux|tcpip|java|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24815" PostTypeId="1" CreationDate="2016-06-02T15:16:14.527" Score="1" ViewCount="2797" Body="&lt;p&gt;I'm trying to program my Arduino Mega to work with a TSL1401 line scan module and while looking over someone else code I came across this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    int b = Serial.read();      //Reads incoming serial data. Returns the first byte of &#xA;                                //incoming serial data available (or -1 if no data is available)&#xA;&#xA;    if (b == 's')&#xA;    {&#xA;        getCamera();&#xA;        delay(2000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For the most part I understand what it's doing but I got confused when I saw that he was setting the return value of &lt;code&gt;Serial.read()&lt;/code&gt; equal to a variable and then checking to see if that variable was a character. To my understanding &lt;code&gt;Serial.read()&lt;/code&gt; returns an integer so why would you compare it to a character?&lt;/p&gt;&#xA;" OwnerUserId="21652" LastActivityDate="2016-06-04T18:54:15.563" Title="Does Serial.read() ever return a character?" Tags="|programming|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24816" PostTypeId="2" ParentId="24815" CreationDate="2016-06-02T15:31:10.687" Score="4" Body="&lt;p&gt;On an 8 bit arduino a character is a byte.  A byte can represent values between -128 and 127, or between 0 and 255, depending on how you &quot;look&quot; at them (signed or unsigned).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole concept of a character is a purely human thing. The Arduino only knows numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance the character 'A' is actually the number 65. We, as humans, choose to represent it as an 'A' and call it &quot;ASCII&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, the character 'a' is actually the number 97. You can also subtract characters from each other.  &lt;code&gt;'a' - 'A' = 32&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-02T15:42:20.877" LastActivityDate="2016-06-02T15:42:20.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24817" PostTypeId="2" ParentId="24814" CreationDate="2016-06-02T16:58:52.953" Score="1" Body="&lt;p&gt;The ESP trys to connect to port 4160, but the server is listing on port 20.&lt;/p&gt;&#xA;" OwnerUserId="21655" LastActivityDate="2016-06-02T16:58:52.953" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24818" PostTypeId="2" ParentId="24717" CreationDate="2016-06-02T17:04:17.063" Score="1" Body="&lt;p&gt;You can use both IDEs no matter of the origin of the UNO even fake ones runs with the IDEs.&#xA;The arduino.org IDE is just a fork of the arduino.cc.&#xA;But arduino.org has many Board which are only run with the .org IDE.&lt;/p&gt;&#xA;" OwnerUserId="21655" LastActivityDate="2016-06-02T17:04:17.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24819" PostTypeId="2" ParentId="18959" CreationDate="2016-06-02T17:54:06.570" Score="1" Body="&lt;p&gt;I was having the same problem: unable to upload a program to a brand new 101.  Now it works.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can successfully load both BLE LED example programs and also the ReadTime program read via Serial Monitor.  (BTW, using the iOS MCP app, you need to send either 00 or 01 to turn the LED on/off.)  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am running a modern 64 bit laptop with USB 3.0 ports.  All ports work fine with either of two USB cables that I have.  So I don't believe the problem is related to USB cables or USB 2.0/3.0.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How did I fix it?  Well, I tried several things and I'm not sure which one fixed it, so perhaps someone can try these methodically and confirm the best fix.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Uninstall the Arduino IDE and manually deleted the Arduino15 folder in user..\AppsData.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart laptop.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download and install IDE 1.6.8.  (Earlier failed attempt was with current 1.6.9.)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart laptop.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open IDE.  In Boards Manager, searched Intel, selected Curie boards, and install v1.0.4.  (Earlier failed attempt was with current 1.0.5.)  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Restart laptop.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open IDE.  Plug in 101 for the first time.  Device showed up normally in Device Manager.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Select proper port (COM5 for me) and proper board (101).  Select example file LED under CurieBle.  Click verify.  Looks good.  Click upload.  SUCCESS!  Can now see the 101 in nRF MCP, can turn LED on/off.  BLE functions now work with 5V USB charger. (but not 9V battery, guess that's not an option) When connected to laptop USB 3.0 port, the 101 now stays in COM5 the entire time, no longer cycling on/off when I try to upload.  No need to press either reset button during upload.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So the fix is either one of the software downgrades, or careful installation procedure.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Previously, I tried the dfu-utils updates but that didn't fix this problem.&lt;/p&gt;&#xA;" OwnerUserId="21658" LastActivityDate="2016-06-02T17:54:06.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24821" PostTypeId="1" AcceptedAnswerId="24828" CreationDate="2016-06-02T19:09:17.157" Score="0" ViewCount="668" Body="&lt;p&gt;I'm looking to use a simple IR sensor out in bright sunlight, which means hell lot of distortion. Is there any way I can modulate it using my Arduino UNO so that it isn't affected by sunlight and other ambient light sources?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The IR sensor is just like &lt;a href=&quot;http://www.amazon.in/Proximity-follower-Obstacle-sensing-Robots-Interface/dp/B01535L94C?tag=googinhydr18418-21&amp;amp;tag=googinkenshoo-21&amp;amp;ascsubtag=fb9dc0d3-db5f-411e-80bb-34bbe41b3335&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; one.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-06-03T12:41:36.373" Title="How to modulate my IR sensor?" Tags="|arduino-uno|sensors|ir|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24822" PostTypeId="1" CreationDate="2016-06-02T20:35:39.167" Score="2" ViewCount="32" Body="&lt;p&gt;If I'm using &lt;code&gt;digitalWrite();&lt;/code&gt; to send a clock impulse to a camera and then get analog signal back, how can I check to see if these pixels are in fact returning? Since there is no console how can I see if any values are actually being returned?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Arduino Mega with the TSL1401 Linear Array Scanner.&lt;/p&gt;&#xA;" OwnerUserId="21660" LastActivityDate="2016-06-02T20:35:39.167" Title="How can I test if pixels are being sent to my arduino?" Tags="|arduino-mega|" AnswerCount="0" CommentCount="4" ClosedDate="2016-06-04T05:52:39.043" ContentLicense="CC BY-SA 3.0" />
  <row Id="24823" PostTypeId="1" AcceptedAnswerId="24878" CreationDate="2016-06-02T21:33:12.223" Score="0" ViewCount="2761" Body="&lt;p&gt;Have anyone ever successfully run any of the &lt;a href=&quot;http://www.vlsi.fi/en/support/software/microcontrollersoftware.html&quot; rel=&quot;nofollow&quot;&gt;official playback and recording examples&lt;/a&gt; for &lt;strong&gt;VS1003&lt;/strong&gt; or &lt;strong&gt;VS1053&lt;/strong&gt; on Arduino / ESP8266? I mean, I was able to play sound with VS1003, but I just can't make the official example compile on Arduino IDE... It looks like it should be no problem (just provide a few methods and copy the main method code from the PDF file to the &lt;code&gt;setup()&lt;/code&gt; in sketch) but I'm just getting a bunch of stupid compiler or linker errors, like &quot;undefined reference to 'VSTestInitHardware()' &quot; while the player.h header file (containing it) is included. I'm not a C / C++ expert so it's either something stupid I do or it's just not possible on Arduino. Can anyone provide a compilable example? I'm trying it with &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;ESP8266&lt;/a&gt; currently (and it is my desired target CPU), but an Arduino Uno version could help too (it throws different errors but doesn't compile neither). Thank you.&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-06-05T06:00:21.813" Title="How to compile an official VS1003 / VS1053 example for Arduino / ESP8266?" Tags="|c++|esp8266|c|compile|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24824" PostTypeId="1" CreationDate="2016-06-03T00:09:57.077" Score="1" ViewCount="2730" Body="&lt;p&gt;My Arduino UNO I bought directly from Arduino.cc, so I'm pretty certain it's not a cheap clone. I have a MacBook Pro El Capitan 10.11.5. My Java is 1.8, but I'm pretty sure that doesn't matter. I have never used Arduino before, though I know a good bit of programming and some about computers. Whilst setting up Arduino, the only serial port my computer/Arduino recognizes is &lt;code&gt;/dev/cu.Bluetooth-Incoming-Port&lt;/code&gt;. Please comment if there is more information I should provide.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My computer recognizes that I have a USB device as seen here:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/FSnuP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FSnuP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a screenshot of the Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yuYa2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yuYa2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, the command&lt;code&gt;ls /dev/tty.*&lt;/code&gt; outputs only &lt;code&gt;/dev/tty.Bluetooth-Incoming-Port&lt;/code&gt;. Is it possible no other serial ports exist for me?&#xA;Sorry for the barrage of pictures but I thought they'd help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Installing CH34x driver&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I'm convinced it's not a driver issue though, as users and Arduino say that OS X does not need drivers installed to run Arduino&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Turning off System Integrity with &lt;code&gt;csrutil --disable&lt;/code&gt; and also tried &lt;code&gt;csrutil --enable without kext&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Installing a FTDI USB Serial Driver &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bought a new USB A/B cable, as many reported the cable was faulty. I am getting a green light on my board&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why my computer and/or Arduino does not list more serial ports that work? It's as if I don't have any besides the one Bluetooth port. I've been getting frustrated over this for several hours, so a solution would be &lt;strong&gt;much&lt;/strong&gt; appreciated :)! I've tried all the solutions I've seen on SE thus far, but maybe I'm missing something&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you ahead of time!&lt;/p&gt;&#xA;" OwnerUserId="21665" LastActivityDate="2016-06-03T01:47:58.127" Title="Why can't my Arduino IDE recognize serial ports? (Mac El Cap, Ard. UNO)" Tags="|arduino-uno|serial|usb|ide|mac-os|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24825" PostTypeId="1" AcceptedAnswerId="24826" CreationDate="2016-06-03T00:52:39.017" Score="2" ViewCount="265" Body="&lt;p&gt;Quite new to this but making pretty good ground. I have an issue I'm not sure how to solve. I want to add a Pro Micro to an RC Toy, I can easily power it from the toys GND and 5V power. But then I want to use the voltage going to an LED on the toy (uses a different ground) to trigger an event within the Pro Micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can power the Pro Micro from USB and and accomplish what I need with AnalogRead(). But if I connect the GND from the toys main power input to the GND from the LED it no longer acts as it should. I'm thinking these GNDs are not common, or are a separate circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm wanting to know is.. I'm using PIN10 on the ProMicro for the AnalogRead(), can I make it so that maybe PIN11 is the GND for that reading?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="21666" LastActivityDate="2016-06-03T04:57:51.827" Title="Pro Micro - Measuring voltage between two pins, without using GND" Tags="|arduino-pro-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24826" PostTypeId="2" ParentId="24825" CreationDate="2016-06-03T01:36:57.127" Score="3" Body="&lt;p&gt;No, you cannot - the ATmega's ADC is referenced to its ground, and there are also some strict limits on providing inputs more than a little bit outside of the range between its power and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to read two analog inputs and subtract them for a sort of &quot;software differential&quot; analog input, but the signal on an LED is unlikely to be meaningfully &quot;analog&quot; anyway - it might be pulsed with a duty cycle, but it will probably not have a steady reduced voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's actually quite likely that the anode of the LED is connected to the toy's positive supply, and it is the negative path to the cathode which is being switched - this is the most traditional way of doing things, because historically semiconductor switches suitable for &quot;low side switching&quot; have had better performance than those suited for &quot;high side switching&quot;.  There will probably be a resistor on one side or the other of the LED.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With care and verification of suitable voltage ranges, you may be able to read the voltage on the LED cathode as a digital signal and invert it in software.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-06-03T04:57:51.827" LastActivityDate="2016-06-03T04:57:51.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24827" PostTypeId="2" ParentId="24824" CreationDate="2016-06-03T01:47:58.127" Score="1" Body="&lt;p&gt;&quot;ATmega16u2 DFU&quot; indicates a USB interface micro that is in a state to have new firmware downloaded to it (DFU), &lt;em&gt;not&lt;/em&gt; one which is ready for operational use as a USB interface to program the Uno's ATmega328p target MCU.  If this persists after power-cycling/re-plugging the board, it is probably faulty and at minimum needs firmware repair - though it might be worth trying on another computer (preferably with a different OS or version) just to be absolutely sure nothing in the host software is forcing it to this mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is a new board you have not modified in any way, you should probably return it as defective.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have modified it, or you want to try to fix things yourself, you would need to follow the &lt;a href=&quot;https://www.arduino.cc/en/Hacking/DFUProgramming8U2&quot; rel=&quot;nofollow&quot;&gt;instructions&lt;/a&gt; for reflashing the 16u2 via USB-DFU.  Beware that this is a non-trivial task that looks like it is going to require installing macports and running some terminal commands, and on older boards some soldering.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-03T01:47:58.127" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24828" PostTypeId="2" ParentId="24821" CreationDate="2016-06-03T02:48:03.617" Score="0" Body="&lt;p&gt;There is little information on the Amazon page about these devices.  Only that the output is digital (only on and off) and that the sensitivity is controlled manually by an on board pot.  It would appear impractical to enhance this type of device with out detailed specifications and / or a schematic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would prefer using software to solve some of the problems you listed, I would suggest you use an IR parallax (not the company, the technique) distance sensor with an analog output.  That way the Arduino Uno's analog input can be used to read the sensor and software (sketch) can process (filter) the data before it is put to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-4-ir-distance-sensor-push-button-2-3637&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is an article describing how to use an IR parallax distance sensor.  &lt;a href=&quot;http://playground.arduino.cc/Main/SharpIR&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is an Arduino library design to work specifically with the Sharp IR parallax distance sensor.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-03T12:41:36.373" LastActivityDate="2016-06-03T12:41:36.373" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24830" PostTypeId="2" ParentId="18432" CreationDate="2016-06-03T04:34:01.567" Score="0" Body="&lt;p&gt;A pointer to a member instance function &lt;strong&gt;is&lt;/strong&gt; possible:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void (Some_class::*Some_fnc_ptr)();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in order to call different classes than just &quot;Test&quot; you'd have to play some games with templates and probably virtual functions.  It would get pretty involved, but doable.&lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-06-03T04:34:01.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24838" PostTypeId="1" CreationDate="2016-06-03T13:44:34.283" Score="3" ViewCount="87" Body="&lt;p&gt;I am getting error with this. It is displaying those segments which are not to be displayed, i.e., 3.141 is dark and other segments are red. And I have checked that the seven segment module I am having is common anode type only.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;SevSeg.h&quot;&#xA;&#xA;SevSeg sevseg; //Initiate a seven segment controller object&#xA;&#xA;void setup() {&#xA;    byte numDigits = 4;&#xA;    byte digitPins[] = {2, 3, 4, 5};&#xA;    byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};&#xA;    sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);&#xA;    sevseg.setBrightness(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;    sevseg.setNumber(3141, 3);&#xA;    sevseg.refreshDisplay(); // Must run repeatedly&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21680" LastEditorUserId="7508" LastEditDate="2016-06-03T13:53:25.397" LastActivityDate="2016-06-03T19:00:16.667" Title="7 segment with arduino" Tags="|arduino-mega|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24839" PostTypeId="2" ParentId="22511" CreationDate="2016-06-03T13:46:23.307" Score="1" Body="&lt;p&gt;You have to retrieve the VID/PID numbers your board actually has and change your boards.txt accordingly. On my Linux computer I made a USB connection with my corrupted pro micro clone, &quot;lsusb&quot; does not show it, but if I pull rst-pin down (pulse) &quot;lsusb&quot; does show it for a few seconds. Now I know the vid:pid numbers. I edited boards.txt (~/.arduino15/packages/Sparkfun/hardware/avr/1/1/5/: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;promicro.build.vid=0x1b4f      (edited 1b4f with vid outcome of &quot;lsusb&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;promicro.menu.cpu.16MHzatmega32U4.build.pid.0=0x9205  (9205 edited)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then in Arduino IDE I gave a reset pulse, the port showed up. I loaded the sample blinky script from sparkfun (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#faq-change-pid&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#faq-change-pid&lt;/a&gt;), clicked &quot;upload&quot; and once again gave a reset pulse. The upload succeeded and my pro micro clone is back to normal.&lt;/p&gt;&#xA;" OwnerUserId="21681" LastActivityDate="2016-06-03T13:46:23.307" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24840" PostTypeId="1" CreationDate="2016-06-03T14:00:09.903" Score="0" ViewCount="300" Body="&lt;p&gt;So I have a line scan camera attached to my Arduino Mega and I'm trying to send it a digital clock impulse and get an analog output back. The line scan camera is supposed to return 128 pixels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far I've been able to send the impulses and get analog values back which I am printing out. However, the values are different every time, which doesn't make sense because the camera didn't move so I assume that it should give back similar numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is there a way to determine what these numbers mean? Is there some way of turning analog signals into color pixels? My ultimate goals is to be able to determine if something has moved through the vision of the line scanner&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the datasheet for the line scanner: &lt;a href=&quot;http://www.farnell.com/datasheets/315815.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.farnell.com/datasheets/315815.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;  int delayTime = 20;&#xA;  digitalWrite(syncPin, HIGH);&#xA;  delayMicroseconds(delayTime);&#xA;  digitalWrite(clockPin, HIGH);&#xA;  delayMicroseconds(delayTime);&#xA;  digitalWrite(syncPin, LOW);&#xA;  delayMicroseconds(delayTime);&#xA;  digitalWrite(clockPin, LOW);&#xA;  delayMicroseconds(delayTime);&#xA;&#xA;  for (int i = 0; i &amp;lt; 128; i++)&#xA;  {&#xA;    digitalWrite(clockPin, HIGH);&#xA;    pixelValue[i] = analogRead(dataPin);&#xA;    delayMicroseconds(delayTime);&#xA;    digitalWrite(clockPin, LOW);&#xA;    delayMicroseconds(delayTime);&#xA;  }&#xA;&#xA;  digitalWrite(clockPin, HIGH);&#xA;  delayMicroseconds(delayTime);&#xA;  digitalWrite(clockPin, LOW);&#xA;  delayMicroseconds(delayTime);&#xA;&#xA;  for (int j = 0; j &amp;lt; 128; j++)&#xA;  {&#xA;    Serial.print(&quot;I received: &quot;);&#xA;    Serial.println(pixelValue[j]);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21660" LastActivityDate="2016-06-03T14:47:06.487" Title="How to interpret analog values sent to Arduino from line scanner?" Tags="|arduino-mega|analogread|digital|analog-sampling|analogreadresolution|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24841" PostTypeId="2" ParentId="24840" CreationDate="2016-06-03T14:47:06.487" Score="2" Body="&lt;p&gt;First, a preliminary note: according to the datasheet, the only time you&#xA;need a delay in your program is after reading the whole array and before&#xA;sending the next sync pulse. All the other timing requirements are&#xA;shorter than a single CPU cycle of your Mega, so no need to add extra&#xA;delays.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;the camera didn't move so I assume that it should give back similar&#xA;  numbers.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Similar: yes. Identical: no. You expect noise to make every reading&#xA;slightly different, and you also will have variations due to uneven&#xA;timing of your program (e.g. the timer interrupt kicking in from time to&#xA;time).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;is there a way to determine what these numbers mean?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;They are proportional to the amount of light collected by each pixel.&#xA;That's about all you know about their meaning.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there some way of turning analog signals into color pixels?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No. This is a B&amp;amp;W camera.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-03T14:47:06.487" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24843" PostTypeId="1" AcceptedAnswerId="24853" CreationDate="2016-06-03T16:15:04.753" Score="1" ViewCount="501" Body="&lt;p&gt;When I try to upload a script to my Genuino Uno from the Linux ARM distro on genuino.cc/downloads it spits out this during compiling.&#xA;&lt;code&gt;&#xA;avrdude: ser_open(): can't open device &quot;/dev/ttyACM0&quot;: Permission denied&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anyone got any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Caleb&lt;/p&gt;&#xA;" OwnerUserId="16147" LastEditorUserId="16147" LastEditDate="2017-09-30T18:32:35.033" LastActivityDate="2017-09-30T18:32:35.033" Title="Arduino Pi-3 Ubuntu MATE not compiling" Tags="|arduino-ide|raspberrypi|ubuntu|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24844" PostTypeId="2" ParentId="24838" CreationDate="2016-06-03T19:00:16.667" Score="1" Body="&lt;p&gt;If you use &lt;a href=&quot;https://github.com/DeanIsMe/SevSeg&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt;, then use&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sevseg.begin(P_TRANSISTORS, numDigits, digitPins, segmentPins);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-03T19:00:16.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24847" PostTypeId="1" CreationDate="2016-06-04T01:49:44.450" Score="4" ViewCount="1074" Body="&lt;p&gt;I have a local workshop for students to teach them 3D printing/woodworking&lt;br /&gt;&#xA;I want to know if its possible to create &lt;strong&gt;RFID/NFC tags using wordpress data from MySQL or HTTP/HTTPS&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Web Scenario&lt;/strong&gt;&lt;/em&gt; :&lt;/p&gt;&#xA;&lt;p&gt;I have a wordpress website where I setup a gamefication plugin.&lt;br /&gt;&#xA;Each time a student takes a quiz/posts on forum he gets a &amp;quot;x&amp;quot; number of points that are accumulated on his profile.&lt;/p&gt;&#xA;&lt;p&gt;I want to know if I can get a RFID/NFC tag to get that number of points.&lt;br /&gt;&#xA;Each member has a RFID/NFC tag card and with that card he can get access to different things around the workshop .&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Workshop Scenario :&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;For each tool there will be a lock , RFID/NFC reader and a LCD display screen.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;When a student want to access that tool he needs a number of points on the wordpress gamefication script that are transfered to the RFID/NFC card.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;If he has the needed points a text on the LCD screen will appear with something like &amp;quot; &lt;strong&gt;You have access to this tool&lt;/strong&gt;&amp;quot; and the tool will be unlocked .&lt;/p&gt;&#xA;&lt;p&gt;Else if the user doesn't meet the needed points the LCD screen will show &amp;quot;&lt;strong&gt;You don't have the needed points for this tool, please visit [URL] to get more info&lt;/strong&gt;&amp;quot; and the tool will stay locked.&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;I need only info if this is possible, not the way to do it.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;[ In case you are kind to hand me some guides on where to start to will be great! ]&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Thanks and waiting to see if this is possible!&lt;/p&gt;&#xA;" OwnerUserId="21689" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-02-05T10:50:37.670" Title="RFID/NFC Tag get data from wordpress MySQL" Tags="|arduino-uno|programming|lcd|rfid|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24850" PostTypeId="1" CreationDate="2016-06-04T04:15:45.687" Score="1" ViewCount="37" Body="&lt;p&gt;I have two Arduinos, each with a network shield.  What is the quickest and simplest way to connect a cat5 cable between these two Arduinos and have them exchange strings?  &lt;/p&gt;&#xA;" OwnerUserId="7572" LastActivityDate="2016-06-04T04:15:45.687" Title="What is the quickest and simplest way for two Arduinos, with network shields, to communicate?" Tags="|communication|network|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24853" PostTypeId="2" ParentId="24843" CreationDate="2016-06-04T07:18:38.020" Score="1" Body="&lt;p&gt;After following the advice left by Majenko, I went to &lt;a href=&quot;https://www.arduino.cc/en/Guide/Linux&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/Linux&lt;/a&gt; and followed the instuctions at the bottom of the page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you get an error Error opening serial port ... you need to set serial port permission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Open Terminal and type:&#xA;&lt;code&gt;&#xA;ls -l /dev/ttyACM*&#xA;&lt;/code&gt;&#xA;you will get something like:&#xA;&lt;code&gt;&#xA;crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0&#xA;&lt;/code&gt;&#xA;The &quot;0&quot; at the end of ACM might be a different number, or multiple entries might be returned. The data we need is &quot;dialout&quot; (is the group owner of the file).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we just need to add our user to the group:&#xA;&lt;code&gt;&#xA;sudo usermod -a -G dialout &amp;lt;username&amp;gt;&#xA;&lt;/code&gt;&#xA;where  is your linux user name. You will need to log out and log in again for this change to take effect. &lt;/p&gt;&#xA;" OwnerUserId="16147" LastEditorUserId="16147" LastEditDate="2016-06-19T06:02:24.350" LastActivityDate="2016-06-19T06:02:24.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24854" PostTypeId="1" CreationDate="2016-06-04T07:47:53.030" Score="1" ViewCount="1384" Body="&lt;p&gt;I'm looking at the little code snippet from &lt;a href=&quot;http://www.circuitmagic.com/arduino/control-dc-motor-cwccw-with-mpu-6050-gyroaccelerometer-arduino/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; (many other projects also use similar code):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA; mpu.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&#xA;&#xA; ax = map(ax, -17000, 17000, -1500, 1500);&#xA; ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If my reading is correct, it's assuming the value of &lt;code&gt;ax&lt;/code&gt; to be between -17000 and 17000. But isn't the value supposed to be 16-bit? If so, shouldn't the range be wider than -17000, 17000? Is the value capped?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thought appreciated.&lt;/p&gt;&#xA;" OwnerUserId="21694" LastActivityDate="2016-06-04T12:28:26.633" Title="MPU6050 acceleration values not 16-bit?" Tags="|sensors|c|accelerometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24855" PostTypeId="2" ParentId="24854" CreationDate="2016-06-04T09:13:18.610" Score="2" Body="&lt;p&gt;The ADC for the accelerometer is 16 bit, yes. Also the data being sent out is in 16 bit format.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what you are confusing is &lt;em&gt;resolution&lt;/em&gt; and &lt;em&gt;range&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The accelerometer can be programmed to have a sensitivity of 2g, 4g, 8g or 16g.  With it set to the least sensitive, that is 2g, the full range of -32768 to +32767 would equate to ±2g. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's fine when you're measuring G-forces of up to 2g, but when all you are sensing is tilt then there is only 1g - the 1g the Earth exerts on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That 1g is half the 2g range, which is -16384 to +16363.  So round that up and give a little extra headroom to your calculations, and you get -17000 to +17000. It gives enough range in your calculations to give the full ±1g range &quot;plus a little bit&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-04T09:13:18.610" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24858" PostTypeId="2" ParentId="24854" CreationDate="2016-06-04T12:28:26.633" Score="0" Body="&lt;p&gt;No, the &lt;code&gt;map()&lt;/code&gt; function does not cap it's input or output, you would&#xA;need &lt;code&gt;constrain()&lt;/code&gt; for that. With &lt;code&gt;map()&lt;/code&gt; alone, there is no assumption&#xA;about the range of the values, other than the calculation not&#xA;overflowing 32-bit integers. Thus,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ax = map(ax, -17000, 17000, -1500, 1500);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;simply multiplies x by the ratio 1500/17000. It is mathematically&#xA;equivalent to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ax = map(ax, 0, 34, 0, 3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;or to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ax = ax * 3L / 34;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;C.f. the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;documentation of &lt;code&gt;map()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-04T12:28:26.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24859" PostTypeId="1" AcceptedAnswerId="24860" CreationDate="2016-06-04T13:29:17.523" Score="3" ViewCount="2185" Body="&lt;p&gt;How can I read the fuse bits from within my sketch?&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-04T13:29:17.523" Title="How do I read the fuse bits from within my sketch?" Tags="|fuses|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24860" PostTypeId="2" ParentId="24859" CreationDate="2016-06-04T13:29:17.523" Score="9" Body="&lt;p&gt;You can use the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html#ga37ce7078335dd85f04d150a52a01d6ad&quot;&gt;boot_lock_fuse_bits_get&lt;/a&gt; function from &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html&quot;&gt;&amp;lt;avr/boot.h&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/boot.h&amp;gt;;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(57600);&#xA;&#xA;    cli();&#xA;    uint8_t lowBits      = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);&#xA;    uint8_t highBits     = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);&#xA;    uint8_t extendedBits = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);&#xA;    uint8_t lockBits     = boot_lock_fuse_bits_get(GET_LOCK_BITS);&#xA;    sei();&#xA;&#xA;    Serial.print(&quot;Low:  0x&quot;);&#xA;    Serial.println(lowBits, HEX);&#xA;    Serial.print(&quot;High: 0x&quot;);&#xA;    Serial.println(highBits, HEX);&#xA;    Serial.print(&quot;Ext:  0x&quot;);&#xA;    Serial.println(extendedBits, HEX);&#xA;    Serial.print(&quot;Lock: 0x&quot;);&#xA;    Serial.println(lockBits, HEX);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-04T13:29:17.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24861" PostTypeId="1" AcceptedAnswerId="24862" CreationDate="2016-06-04T14:38:39.740" Score="0" ViewCount="221" Body="&lt;p&gt;I have two Arduino, one is to handle the Bluetooth communication and send a signal to the other Arduino, and the other to interpret the signal and display or hide an image on the E-ink display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It work just fine when they both are connected through the USB. But when I connect a 9V battery to the Arduino running the E-ink, instead of the USB, the image is displayed and cleared (looping), as if the IF ELSE conditions are not there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tested if it actually runs the method by adding delay to the showImg()-method, and that seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have also tested with connecting the USB cable to the E-ink Arduino to a 5V charger, and the case is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/jmgiY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jmgiY.png&quot; alt=&quot;Setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bluetooth code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13; &#xA;int state = 0;&#xA;int flag = 0; &#xA;&#xA;void setup() {&#xA; pinMode(ledPin, OUTPUT);&#xA; digitalWrite(ledPin, LOW);&#xA;&#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA; if(Serial.available() &amp;gt; 0){&#xA; state = Serial.read();&#xA; flag=0;&#xA; }&#xA;&#xA; if (state == '2') {&#xA; digitalWrite(ledPin, LOW);&#xA; if(flag == 0){&#xA; Serial.println(&quot;Screen: off&quot;);&#xA; flag = 1;&#xA; }&#xA; }&#xA;&#xA; else if (state == '1') {&#xA; digitalWrite(ledPin, HIGH);&#xA; if(flag == 0){&#xA; Serial.println(&quot;Screen: on&quot;);&#xA; flag = 1;&#xA; }&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;E-ink code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;epd.h&amp;gt;&#xA;&#xA;int displayed = 0;&#xA;int val = 0;&#xA;&#xA;void showImg(void)&#xA;{&#xA;  Serial.print(&quot;showImg&quot;);&#xA;  displayed = 1;&#xA;  //epd_clear();&#xA;  epd_disp_bitmap(&quot;PIC9.bmp&quot;, 0, 100);&#xA;&#xA;  epd_udpate();&#xA;  //delay(10000);&#xA;}&#xA;&#xA;void clearImg(void){&#xA;  Serial.print(&quot;clearImg&quot;);&#xA;  displayed = 0;&#xA;  epd_clear();&#xA;  epd_udpate();&#xA;&#xA;}&#xA;&#xA;void setup(void)&#xA;{&#xA;  //Serial.begin(9600);&#xA;  epd_init();&#xA;  epd_wakeup();&#xA;  epd_set_memory(MEM_TF);&#xA;  pinMode(7, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop(void)&#xA;{&#xA;  val = digitalRead(7);&#xA;&#xA;  if(val == 1){&#xA;&#xA;    if(displayed == 0){&#xA;      showImg();&#xA;    }&#xA;&#xA;  }else {&#xA;&#xA;    if(displayed == 1){&#xA;      clearImg();&#xA;    }&#xA;  }&#xA;  //Serial.println(val);&#xA;  //delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am a beginner when it comes to Arduino, So I hope someone can give me some hints to what may be wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="4229" LastActivityDate="2016-06-04T14:59:34.040" Title="Code runs different on USB vs Battery" Tags="|arduino-uno|display|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24862" PostTypeId="2" ParentId="24861" CreationDate="2016-06-04T14:59:34.040" Score="4" Body="&lt;p&gt;The USB provides the one thing that is missing from your diagram there: the &lt;strong&gt;common ground&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The GND pins of the two boards &lt;em&gt;must&lt;/em&gt; be connected together. By using USB the USB becomes that connection. As soon as you use batteries there is no connection, so no communication happens.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-04T14:59:34.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24863" PostTypeId="2" ParentId="12505" CreationDate="2016-06-04T15:18:07.900" Score="0" Body="&lt;p&gt;You might try my &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt; library.  It has a diagostic program and some good information in the &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Troubleshooting.md&quot; rel=&quot;nofollow&quot;&gt;Troubleshooting section&lt;/a&gt;.  And NeoGPS doesn't use the &lt;code&gt;String&lt;/code&gt; class, although you can safely waste lots of RAM on the Edison.  :P&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For an Edison build, you may have to change the PACKED_DATA configuration item, described &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/doc/Configurations.md#platforms&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(This is an Arduino product, right?)&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-06-04T15:18:07.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24864" PostTypeId="1" AcceptedAnswerId="24866" CreationDate="2016-06-04T15:31:04.247" Score="0" ViewCount="897" Body="&lt;p&gt;Can I use Arduino OBD library with &quot;custom&quot; software serial or it needs to be used with hardware UART only? For example if I have D5 and D6 pin as RX and TX in my code hooked on OBD board, how do I initialize OBD library from there?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;a href=&quot;https://github.com/stanleyhuangyc/ArduinoOBD&quot; rel=&quot;nofollow&quot;&gt;OBD library&lt;/a&gt; that I'm referring to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And I'm using this &lt;a href=&quot;http://www.obddiag.net/allpro.html&quot; rel=&quot;nofollow&quot;&gt;Allpro OBD&lt;/a&gt; board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&#xA;Actually I would be satisfied with a answer how to know when entire response from the board is received, because this way is way too messy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void getResponse(void){&#xA; while(obdSerial.available()){&#xA;   Serial.write(obdSerial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here I don't know when the message is received. And if I try to use example from &lt;strong&gt;Sparkfun&lt;/strong&gt; &lt;strong&gt;obd-ii-uart-hookup-guide&lt;/strong&gt; (different board doe) I ended up in infinite-loop since the board never return &lt;code&gt;\r&lt;/code&gt;, if I send ELM command to use &lt;code&gt;\n&lt;/code&gt; as terminator, and if I disable ELM to echo the command so that I use just one &lt;code&gt;getResponse&lt;/code&gt; call I get some readings, but not all the time, I ended up in infinite-loop again.&lt;/p&gt;&#xA;" OwnerUserId="21699" LastEditorUserId="21699" LastEditDate="2016-06-04T15:49:39.397" LastActivityDate="2016-06-04T15:49:39.397" Title="Arduino OBD library and software serial library" Tags="|arduino-uno|softwareserial|uart|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24866" PostTypeId="2" ParentId="24864" CreationDate="2016-06-04T15:47:29.057" Score="1" Body="&lt;p&gt;That library is hard-coded to use the single Hardware Serial device on the Arduino Uno or the second Hardware Serial1 device on other boards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef OBDUART&#xA;#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168P__)&#xA;#define OBDUART Serial&#xA;#else&#xA;#define OBDUART Serial1&#xA;#endif&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can edit the library's header file &lt;code&gt;OBD.h&lt;/code&gt; to define your own serial port though:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;extern SoftwareSerial mySerialPort;&#xA;#define OBDUART mySerialPort&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in your sketch create the &lt;code&gt;mySerialPort&lt;/code&gt; SoftwareSerial object.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-04T15:47:29.057" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24867" PostTypeId="1" AcceptedAnswerId="24906" CreationDate="2016-06-04T15:52:27.480" Score="0" ViewCount="174" Body="&lt;p&gt;I am trying to send a few variables from my python script to my Arduino. I am using pySerial. I am able to send the variables to the Arduino, but my Arduino sketch runs only for a second and then stops. But if I put the &lt;code&gt;ser.write()&lt;/code&gt; command in a while loop (which I want to avoid) the sketch runs fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I wrote this script on my PC - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;ser = serial.Serial('COM3',9600)&#xA;counter = 'Y'&#xA;ser.write(counter)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This script should pass a &quot;Y&quot; to the Arduino and should stop executing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino code- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int flag = 0;&#xA;void setup() {&#xA;   Serial.begin(9600); // set the baud rate&#xA;   Serial.println(&quot;Ready&quot;); // print &quot;Ready&quot; once&#xA;   pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;   char inByte = ' ';&#xA;   if(Serial.available()){&#xA;      inByte = Serial.read(); // read the incoming data&#xA;      Serial.println(inByte); &#xA;      flag ++;&#xA;   }&#xA;   if(flag == 1){&#xA;      digtalWrite(13, HIGH);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now according to me the Arduino should receive the data and increment the flag variable to 1. Next the program checks whether flag is one and if it is turns the onboard LED on. However when I run the python script, the onboard LED flashes for just a second and then goes blank. I again have to run the python script to make it light up or I have to put &lt;code&gt;ser.write&lt;/code&gt; in a loop. I can't put &lt;code&gt;ser.write&lt;/code&gt; in a loop as my script won't run further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So how can a value be passed to an Arduino without having to put the &lt;code&gt;ser.write()&lt;/code&gt; in a loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a new sketch, but it still doesn't work. Here's the sketch - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;char data = ' ';&#xA;&#xA;void setup(){&#xA;   pinMode(ledPin, OUTPUT);&#xA;   Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;   if (Serial.available()&amp;gt;0) {&#xA;      data = Serial.read();&#xA;   }&#xA;   if (data == 'Y'){&#xA;      digitalWrite(ledPin, HIGH);&#xA;   }&#xA;   delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's an image of the wiring - &#xA;&lt;a href=&quot;https://i.stack.imgur.com/7eWyh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7eWyh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-06-04T18:15:23.353" LastActivityDate="2016-06-05T20:52:43.057" Title="Does serial communication between PC and Arduino has to be in a loop?" Tags="|arduino-uno|serial|sketch|python|windows|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24868" PostTypeId="1" AcceptedAnswerId="24883" CreationDate="2016-06-04T16:26:08.710" Score="4" ViewCount="10608" Body="&lt;p&gt;I am about to Fourier analyse some data I've taken, but i need to know at which sampling rate the data was written to the serial monitor. I've found a lot of threads about how to increase it and such but not a single one that lays down some information about what the sampling-rate is. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is very simple, here it is: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      // the setup routine runs once when you press reset:&#xA;  void setup() {&#xA;    // initialize serial communication at 9600 bits per second:&#xA;    Serial.begin(9600);&#xA;  }&#xA;&#xA;  // the loop routine runs over and over again forever:&#xA;  void loop() {&#xA;    // read the input on analog pin 0:&#xA;    int sensorValue = analogRead(A0);&#xA;    // print out the value you read:&#xA;    Serial.println(sensorValue);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21700" LastEditorUserId="21700" LastEditDate="2016-06-06T11:32:16.577" LastActivityDate="2016-06-06T11:32:16.577" Title="What is the sampling-rate of the `analogRead()`?" Tags="|serial|analogread|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24871" PostTypeId="2" ParentId="24815" CreationDate="2016-06-04T18:54:15.563" Score="2" Body="&lt;p&gt;Part of the answer is in the comment in your given example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int b = Serial.read();      //Reads incoming serial data. Returns the first&#xA;                            //byte of incoming serial data available&#xA;                            //(or -1 if no data is available)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you're reading raw 8-bit data from the serial port (basically, could be any value from 0-255), how do you represent errors?   Per the comment: if nothing is available, it returns -1.  But... as @Majenko pointed out, -1 is a valid CHAR too, it all depends on how you look at the data (signed, or unsigned).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But an INT can hold a value from 0-255 easily, and also a -1 to represent 'nothing'.  The Serial.read function is non-blocking (it doesn't WAIT for a data byte), so it needs to be able to return a status that indicates 'empty bucket', meaning there's actually 257 (256+1) different possible values... thus you need more than 8 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's a painful lesson with usage of &lt;strong&gt;fgetc(3)&lt;/strong&gt;, &lt;strong&gt;getc(3)&lt;/strong&gt; and similar functions.  You need to be able to represent EOF, while also returning valid 8 bit data.  Hence the use of INT's as return value size.  Often someone (ok, me... but it was a &lt;em&gt;long&lt;/em&gt; time ago!) will figure that since they're reading CHAR's, you can use a CHAR sized variable... but then EOF never seems to be found... oops!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="16859" LastActivityDate="2016-06-04T18:54:15.563" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24872" PostTypeId="1" CreationDate="2016-06-04T18:58:17.690" Score="2" ViewCount="706" Body="&lt;p&gt;I'm just starting to delve into robotics and electronics, and my first project was building a small Arduino collision-avoidance robot with a ultrasonic range finder, one servo and two DC motors.&lt;/p&gt;&#xA;&lt;p&gt;Right now I'm using a 6 V battery pack to power both DC motors, another 6 V just for the servo, and a 9 V battery for the Arduino.&lt;/p&gt;&#xA;&lt;p&gt;But I'm in doubt if the power supply for the DC motors is enough. I'm using an L293D IC to control both motors, but the robot can barely move under load (and the total weight of the robot is not that much. I already reduced all the weight I could). So, how much power, typically, I should supply for the L293D to control those motors?&lt;/p&gt;&#xA;" OwnerUserId="21705" LastEditorUserId="61722" LastEditDate="2022-08-06T08:38:29.173" LastActivityDate="2023-01-03T11:04:10.577" Title="Controlling 2 DC motors with L293D and 6 V battery pack?" Tags="|arduino-uno|motor|robotics|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="24874" PostTypeId="1" AcceptedAnswerId="24876" CreationDate="2016-06-04T20:47:37.323" Score="1" ViewCount="93" Body="&lt;p&gt;I'm using Energia to program one of TI's MCU. Since Energia is based off the Arduino IDE, I'm hoping someone can help me here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm building a simple UDP packet sender and receiver app. The MCU starts up and connects to the local Wifi network and waits for a packet from another device on the same network. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This packet is collected in a char array &lt;code&gt;char packetBuffer[16];&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to split this array into two separate arrays each of 8 elements. These are &lt;code&gt;char lampCmdRead[8];&lt;/code&gt; and &lt;code&gt;char pwdReadBuffer[8];&lt;/code&gt; Now the network bit works great. I can send the packet through my desktop and receive it on the MCU. However when I split this array I see that the &lt;code&gt;pwdReadBuffer&lt;/code&gt; shows the same contents as &lt;code&gt;packetBuffer&lt;/code&gt; even though they are of different sizes. How is this possible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char packetBuffer[16];&#xA;char lampCmdRead[8];&#xA;char pwdReadBuffer[8];&#xA;&#xA;// This is code from the 'void loop()' section&#xA;int packetSize = Udp.parsePacket();&#xA;&#xA;if(packetSize) {&#xA; int len = Udp.read(packetBuffer, 16);&#xA; if (len &amp;gt; 0) packetBuffer[len] = 0;&#xA; Serial.println();&#xA;&#xA; Serial.println(&quot;packetBuffer:&quot;);&#xA; Serial.println(packetBuffer);&#xA; Serial.println();&#xA;&#xA; for(ctr = 0; ctr &amp;lt; 8; ctr++) {&#xA;   pwdReadBuffer[ctr] = packetBuffer[ctr];&#xA; }&#xA; if (len &amp;gt; 8) pwdReadBuffer[len] = 0;&#xA;&#xA; for(ctr = 0; ctr &amp;lt; 8; ctr++) {&#xA;   lampCmdRead[ctr] = packetBuffer[ctr+8];&#xA; }    &#xA; if (len &amp;gt; 8) lampCmdRead[len] = 0;&#xA;&#xA; Serial.println(&quot;pwdReadBuffer:&quot;);&#xA; Serial.println(pwdReadBuffer);&#xA; Serial.println();&#xA;&#xA; Serial.println(&quot;lampCmdRead:&quot;);&#xA; Serial.println(lampCmdRead);&#xA; Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Received packet of size 16&#xA;From 192.168.1.101, port 55056&#xA;&#xA;packetBuffer:&#xA;2qZ@X51Rredledon&#xA;&#xA;pwdReadBuffer:&#xA;2qZ@X51Rredledon&#xA;&#xA;lampCmdRead:&#xA;redledon&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21708" LastActivityDate="2016-06-04T21:20:27.650" Title="Character array weirdness" Tags="|array|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24876" PostTypeId="2" ParentId="24874" CreationDate="2016-06-04T21:20:11.853" Score="0" Body="&lt;pre&gt;&lt;code&gt;if (len &amp;gt; 8) pwdReadBuffer[len] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This line is unsafe.  You declared pwdReadBuffer to be only 8 bytes in size, but this line of code will either do nothing, or write &lt;em&gt;outside&lt;/em&gt; of the target buffer, with unpredictable results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You make a related mistake here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (len &amp;gt; 8) lampCmdRead[len] = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First the test should be &lt;code&gt;&amp;gt;=&lt;/code&gt; but again, such a value would be beyond the end of the target buffer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider that if you receive 8 or more characters, you will have no room for a terminating null in pwdReadBuffer, and so cannot pass it to anything that expects a null terminated string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use null-terminate storage for a string of up to 8 bytes size, you need 9 bytes of storage.  And of course you need to only use in-range indices to access the elements.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-04T21:20:11.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24877" PostTypeId="2" ParentId="24874" CreationDate="2016-06-04T21:20:27.650" Score="0" Body="&lt;p&gt;This behavior (where contents of &lt;code&gt;pwdReadBuffer&lt;/code&gt; print out the same as those of &lt;code&gt;packetBuffer&lt;/code&gt;) is occurring because you haven't properly null-terminated your strings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After you copy the first 8 characters of &lt;code&gt;packetBuffer&lt;/code&gt; to &lt;code&gt;pwdReadBuffer&lt;/code&gt; the statement &lt;code&gt;if (len &amp;gt; 8) pwdReadBuffer[len] = 0;&lt;/code&gt; gets executed.  It sets &lt;code&gt;pwdReadBuffer[16]&lt;/code&gt; to 0, ie, references out of array bounds.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apparently &lt;code&gt;lampCmdRead&lt;/code&gt; is allocated directly after &lt;code&gt;pwdReadBuffer&lt;/code&gt;, so when you copy the next 8  characters of &lt;code&gt;packetBuffer&lt;/code&gt; to &lt;code&gt;lampCmdRead&lt;/code&gt;, they are being copied, in effect, to &lt;code&gt;pwdReadBuffer[8] ... pwdReadBuffer[15]&lt;/code&gt;, so that the &lt;code&gt;println&lt;/code&gt; prints a 16-character string,&#xA;&lt;code&gt;2qZ@X51Rredledon&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For each of your three arrays, allocate an extra byte for a null terminator.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-06-04T21:20:27.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24878" PostTypeId="2" ParentId="24823" CreationDate="2016-06-04T21:56:35.957" Score="0" Body="&lt;p&gt;Ok, after long battle with C++ compiler I have a &lt;strong&gt;working example&lt;/strong&gt; (at least for VS1003 and ESP8266) with a checklist how to recreate it (with minimal changes to the example files). I'm sure someone else will have this problem so I'm attaching it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The things that you need to do in player1003.c&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;rename to player1003.h (change file extension only)&lt;/li&gt;&#xA;&lt;li&gt;remove all 5 includes from the top (stdio, string, stdlib, ctype, &quot;player.h&quot;)&lt;/li&gt;&#xA;&lt;li&gt;turn off &lt;code&gt;REPORT_ON_SCREEN&lt;/code&gt; (change &lt;code&gt;#if 1&lt;/code&gt; to &lt;code&gt;#if 0&lt;/code&gt;) if you don't want to have a lot of serial output&lt;/li&gt;&#xA;&lt;li&gt;mass replace &quot;FILE *&quot; to &quot;File &quot; - mind the space (change type of file variables in all methods, mark &quot;Case sensitive&quot; to avoid errors in player1053!)&lt;/li&gt;&#xA;&lt;li&gt;mass replace &lt;code&gt;fopen(&lt;/code&gt; to &lt;code&gt;fopen2(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;mass replace &lt;code&gt;printf(&lt;/code&gt; to &lt;code&gt;Serial.printf(&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;mass replace &lt;code&gt;fflush(stdout);&lt;/code&gt; to &lt;code&gt;//fflush(stdout);&lt;/code&gt; (or &lt;code&gt;Serial.flush();&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;remove method: &lt;code&gt;VSTestInitHardware(void)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;remove &lt;code&gt;SM_SDISHARE&lt;/code&gt; flag from &lt;code&gt;WriteSci(SCI_MODE, SM_SDINEW|SM_SDISHARE|SM_TESTS|SM_RESET);&lt;/code&gt; line  (in &lt;code&gt;VSTestInitSoftware(void)&lt;/code&gt; method)&lt;/li&gt;&#xA;&lt;li&gt;in &lt;code&gt;VSTestHandleFile()&lt;/code&gt; at the bottom add &lt;code&gt;fp.close();&lt;/code&gt; after &lt;code&gt;VS1003PlayFile(fp);&lt;/code&gt; and &lt;code&gt;VS1003RecordFile(fp);&lt;/code&gt; lines (especially after the record!). We don't want unclosed files on SD card.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The main sketch (.ino):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &quot;player.h&quot;&#xA;&#xA;using namespace std;&#xA;&#xA;&#xA;// I use these values below for ESP-12 (ESP8266):&#xA;#define MP3_xCS 2&#xA;#define MP3_xDCS 4&#xA;#define MP3_DREQ 5&#xA;#define MP3_xRESET 16&#xA;#define SD_CS 15&#xA;#define SPI_MOSI 11 //SPI&#xA;#define SPI_MISO 12 //SPI&#xA;#define SPI_CLK  13 //SPI&#xA;&#xA;&#xA;#define  WAIT_DREQ()  while(!digitalRead(MP3_DREQ))&#xA;&#xA;&#xA;File song;&#xA;&#xA;&#xA;int VSTestInitHardware()&#xA;{&#xA;  pinMode(MP3_DREQ, INPUT);&#xA;  pinMode(MP3_xCS, OUTPUT);&#xA;  pinMode(MP3_xDCS, OUTPUT);&#xA;  pinMode(MP3_xRESET, OUTPUT);&#xA;  pinMode(SD_CS, OUTPUT);&#xA;&#xA;  digitalWrite(MP3_xCS, HIGH);&#xA;  digitalWrite(MP3_xDCS, HIGH);&#xA;&#xA;  digitalWrite(MP3_xRESET, LOW); // chip off!&#xA;  delay(100);&#xA;  digitalWrite(MP3_xRESET, HIGH); // chip on!&#xA;&#xA;  Serial.begin(115200);&#xA;&#xA;  if (!SD.begin(SD_CS))&#xA;  {&#xA;    Serial.println(&quot;Can't initialize SD!&quot;);&#xA;    return -1;&#xA;  }&#xA;  Serial.println(&quot;SD OK!&quot;);&#xA;&#xA;  SPI.begin();&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV32);  // Bus SPI at 1MHz (for Arduino: 16MHz / 16 = 1MHz)&#xA;  SPI.transfer(0xFF);  // Write something to the bus&#xA;  delay(10);&#xA;  return 0;&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  if (VSTestInitHardware() || VSTestInitSoftware())&#xA;  {&#xA;    Serial.printf(&quot;Failed initializing VS10xx, exiting\n&quot;);&#xA;    exit(EXIT_FAILURE);&#xA;  }&#xA;  /* ... */&#xA;  /* Playback example. You can call these functions many times in a row&#xA;  because they leave VS1003 in a stable state. */&#xA;  VSTestHandleFile(&quot;TEST.mp3&quot;, 0);  // remember to use 8.3 file names format on SD!&#xA;  /* Recording example */&#xA;  VSTestHandleFile(&quot;RECORDED.WAV&quot;, 1);  // original example for VS1003 has a bug here (OGG extension)&#xA;&#xA;  Serial.println(&quot;Playing recorded file...&quot;);&#xA;  VSTestHandleFile(&quot;RECORDED.WAV&quot;, 0);&#xA;&#xA;  Serial.println(&quot;THE END&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&#xA;&#xA;&#xA;void WriteSci(unsigned char reg, unsigned char hsb, unsigned char lsb)&#xA;{&#xA;  // for debugging:&#xA;  Serial.printf(&quot;Setting %s to: %d (%X, %X)\n&quot;, RegName(reg), (hsb&amp;lt;&amp;lt;8) + lsb, hsb, lsb);&#xA;&#xA;  WAIT_DREQ();&#xA;  digitalWrite(MP3_xCS, LOW);&#xA;&#xA;  SPI.transfer(0x02);&#xA;  SPI.transfer(reg);&#xA;  SPI.transfer(hsb);&#xA;  SPI.transfer(lsb);&#xA;  WAIT_DREQ();&#xA;  digitalWrite(MP3_xCS, HIGH); &#xA;}&#xA;&#xA;&#xA;void WriteSci(u_int8 addr, u_int16 data)&#xA;{&#xA;  WriteSci(addr, data &amp;gt;&amp;gt; 8, data &amp;amp; 255);&#xA;}&#xA;&#xA;&#xA;uint16_t ReadSci (unsigned char reg)&#xA;{&#xA;  WAIT_DREQ();&#xA;  digitalWrite(MP3_xCS, LOW);&#xA;&#xA;  SPI.transfer(0x03);&#xA;  SPI.transfer(reg);&#xA;  delayMicroseconds(10);&#xA;&#xA;  char response1 = SPI.transfer(0xFF);&#xA;  WAIT_DREQ();&#xA;  char response2 = SPI.transfer(0xFF);&#xA;  WAIT_DREQ();&#xA;&#xA;  digitalWrite(MP3_xCS, HIGH);&#xA;&#xA;  unsigned int resultvalue = response1 &amp;lt;&amp;lt; 8;&#xA;  resultvalue |= response2;&#xA;&#xA;  // for debugging:&#xA;  if (reg != SCI_HDAT0 &amp;amp;&amp;amp; reg != SCI_HDAT1)  // these registers are filtered out because they are intensively used during recording&#xA;    Serial.printf(&quot;%s is: %d (%X, %X)\n&quot;, RegName(reg), resultvalue, resultvalue &amp;gt;&amp;gt; 8, resultvalue &amp;amp; 255);&#xA;&#xA;  return resultvalue;&#xA;}&#xA;&#xA;&#xA;int WriteSdi(const u_int8 *data, u_int8 bytes)&#xA;{&#xA;  WAIT_DREQ();&#xA;  digitalWrite(MP3_xDCS, LOW);&#xA;&#xA;  for(int y = 0 ; y &amp;lt; bytes ; y++)&#xA;    SPI.transfer(data[y]);&#xA;&#xA;  digitalWrite(MP3_xDCS, HIGH);&#xA;}&#xA;&#xA;&#xA;const char* RegName(uint8_t reg)&#xA;{&#xA;  switch (reg)&#xA;  {&#xA;    case 0x00: return &quot;SCI_MODE&quot;;&#xA;    case 0x01: return &quot;SCI_STATUS&quot;;&#xA;    case 0x02: return &quot;SCI_BASS&quot;;&#xA;    case 0x03: return &quot;SCI_CLOCKF&quot;;&#xA;    case 0x04: return &quot;SCI_DECODE_TIME&quot;;&#xA;    case 0x05: return &quot;SCI_AUDATA&quot;;&#xA;    case 0x06: return &quot;SCI_WRAM&quot;;&#xA;    case 0x07: return &quot;SCI_WRAMADDR&quot;;&#xA;    case 0x08: return &quot;SCI_HDAT0&quot;;&#xA;    case 0x09: return &quot;SCI_HDAT1&quot;;&#xA;    case 0x0A: return &quot;SCI_AIADDR&quot;;&#xA;    case 0x0B: return &quot;SCI_MIXERVOL&quot;;&#xA;    case 0x0C: return &quot;SCI_AICTRL0&quot;;&#xA;    case 0x0D: return &quot;SCI_AICTRL1&quot;;&#xA;    case 0x0E: return &quot;SCI_AICTRL2&quot;;&#xA;    case 0x0F: return &quot;SCI_AICTRL3&quot;;&#xA;  }&#xA;}&#xA;&#xA;&#xA;void SaveUIState(void)&#xA;{&#xA;}&#xA;&#xA;void RestoreUIState(void)&#xA;{&#xA;}&#xA;&#xA;int GetUICommand(void)&#xA;{&#xA;  while (Serial.available() &amp;gt; 0)&#xA;  {&#xA;    char c = Serial.read();&#xA;    if (c != 10 &amp;amp;&amp;amp; c != 13)&#xA;      return c;&#xA;  }&#xA;  return -1;&#xA;}&#xA;&#xA;&#xA;void exit(int code)&#xA;{&#xA;  if (code == EXIT_SUCCESS)&#xA;    Serial.println(&quot;Exited with no error.&quot;);&#xA;  else&#xA;    Serial.printf(&quot;Terminated with error: %d\n&quot;, code);&#xA;  while (true) { yield(); }  // yield() is needed for ESP8266 only&#xA;}&#xA;&#xA;&#xA;File fopen2(const char* fileName, const char* mode)&#xA;{&#xA;  if (mode[0] == 'w')  // fast workaround!&#xA;  {&#xA;    Serial.printf(&quot;Opening for writing: %s\n&quot;, fileName);&#xA;    song = SD.open(fileName, O_WRONLY | O_TRUNC | O_CREAT);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.printf(&quot;Opening for reading: %s\n&quot;, fileName);&#xA;    song = SD.open(fileName, O_RDONLY);&#xA;  }&#xA;&#xA;  if (!(song)) &#xA;  {&#xA;     Serial.printf(&quot;File not found: %s\n&quot;, fileName);&#xA;     return song;&#xA;  }&#xA;  Serial.printf(&quot;File opened: %s\n&quot;, fileName);&#xA;  return song;&#xA;}&#xA;&#xA;size_t fread ( void * ptr, size_t size, size_t count, File stream )&#xA;{&#xA;  yield();  // this is needed for ESP8266 only (otherwise reboots)&#xA;  return stream.read(ptr, size * count);&#xA;}&#xA;&#xA;int fseek ( File stream, long int offset, int origin )&#xA;{&#xA;  stream.seek(offset);&#xA;}&#xA;&#xA;size_t fwrite ( const void * ptr, size_t size, size_t count, File stream )&#xA;{&#xA;  return stream.write((uint8_t*)ptr, size * count);&#xA;}&#xA;&#xA;int fflush ( File stream )&#xA;{&#xA;  stream.flush();&#xA;  return 0;&#xA;}&#xA;&#xA;&#xA;#include &quot;player1003.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(i had to manually clean this file out of my additional code, but I hope it will compile just fine).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I have a request:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you run this example, please write me in comment whether the recording worked. I can't make my VS1003 module record sound. I have a suspicion that mic in my module is broken. That's why I was trying the official example (with the minimum changes as possible). It records only noise in my case, but plays mp3 perfectly. If you have a working example of recording, please share too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one more to the people with more rep (moderators): Please add a &lt;code&gt;VS1003&lt;/code&gt; (and &lt;code&gt;VS1053&lt;/code&gt; and &lt;code&gt;VS1063&lt;/code&gt;) keywords and assign it to my questions about VS1003, because I'm unable to do it and it should be done. The chip deserves a keyword. (It's really good and not expensive.)&lt;/p&gt;&#xA;" OwnerUserId="18748" LastActivityDate="2016-06-04T21:56:35.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24879" PostTypeId="1" AcceptedAnswerId="24881" CreationDate="2016-06-05T04:23:54.173" Score="1" ViewCount="1307" Body="&lt;p&gt;I'm learning how to use the millis() function. Instead of having it in the main body of the program I wanted to place it in a function so I can change the time interval with which an led will flash. I modified the code blinkWithoutDelay. My code is below. The output I get is an LED that is always on. I did print the output of the ledState to the serial monitor. Its changing from on to off repeatedly. So I think the led is really flickering too fast to see. I took a screenshot from the serial monitor. The output is below. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LED2 = 2;&#xA;int ledState2 = LOW;&#xA;&#xA;void timeCheck(int interval)&#xA;{&#xA;    unsigned long cMillis = millis();&#xA;    unsigned long pMillis;&#xA;&#xA;    if (cMillis - pMillis &amp;gt; interval)&#xA;    {&#xA;        pMillis = cMillis;&#xA;&#xA;        if (ledState2 == LOW)&#xA;        {&#xA;            ledState2 = HIGH;&#xA;        }&#xA;        else&#xA;        {&#xA;            ledState2 = LOW;&#xA;        }&#xA;        digitalWrite(LED2, ledState2);&#xA;        Serial.println(ledState2);&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(LED2, OUTPUT); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    unsigned long flashtime = 1000;&#xA;    timeCheck(flashtime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GSLog.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GSLog.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2018-12-30T09:29:53.473" Title="trying to use millis()" Tags="|millis|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24881" PostTypeId="2" ParentId="24879" CreationDate="2016-06-05T05:47:28.523" Score="2" Body="&lt;p&gt;The problem here is that the variables you declare in your function are not static. The rest of the code works as expected.&lt;/p&gt;&#xA;&lt;p&gt;Where you declare the variables at the beginning of your function is correct. There is only one variable in question though as it is the cause of the error you are seeing.&lt;/p&gt;&#xA;&lt;p&gt;What you need to do is change the variable&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;unsigned long pMillis;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;static unsigned long pMillis = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;By not having the &lt;code&gt;pMillis&lt;/code&gt; as a static variable, each time the function is called the value of &lt;code&gt;pMillis&lt;/code&gt; is undefined, which means it is unpredictable whether &lt;code&gt; (cMillis - pMillis &amp;gt; interval)&lt;/code&gt; will be true or false. But with the &lt;code&gt;static&lt;/code&gt; declaration the Arduino knows to keep the previous value for the next time you call the function.&lt;/p&gt;&#xA;&lt;p&gt;An excerpt from &lt;a href=&quot;https://en.wikipedia.org/wiki/Static_variable&quot; rel=&quot;nofollow noreferrer&quot;&gt;Wikipedia&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In computer programming, a static variable is a variable that has been allocated statically—whose lifetime or &amp;quot;extent&amp;quot; extends across the entire run of the program....&lt;/p&gt;&#xA;&lt;p&gt;A static local variable is different from a local variable. It is initialized only once no matter how many times that function in which it resides is called.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-06-05T07:24:30.373" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24882" PostTypeId="2" ParentId="24823" CreationDate="2016-06-05T06:00:21.813" Score="0" Body="&lt;p&gt;This is best given with an example. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.h&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __cplusplus&#xA;extern &quot;C&quot; {&#xA;#endif&#xA;extern int foo(const char* s);&#xA;#ifdef __cplusplus&#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;foo.c&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.h&quot;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;int foo(const char* s) {&#xA;  printf(&quot;foo: %s\n&quot;, s);&#xA;  return 42;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So first, let's create a &quot;library&quot; from foo.c. Since we are compiling with a C, not a C++ compiler, the stuff in &lt;code&gt;#ifdef __cplusplus&lt;/code&gt; is ignored.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ gcc -c foo.c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This creates a file called &lt;code&gt;foo.o&lt;/code&gt;, which we can then use to link with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;as24823.cpp&lt;/code&gt; contains:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;foo.h&quot;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;&#xA;int main(int argc, char* argv[]) {&#xA;  int f = foo(&quot;called&quot;);&#xA;  std::cout &amp;lt;&amp;lt; f &amp;lt;&amp;lt; std::endl;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I can compile the C++ program (as24823.cpp) and use a C library (foo.c):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ g++ -c ase24823.cpp&#xA;$ g++ ase24823.o foo.o&#xA;$ ./a.out&#xA;foo: called&#xA;42&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Why is this necessary?&lt;/em&gt;, I hear you ask. Well, for reasons that are way beyond the scope of this posting, C++ mangles entry point names. Observe:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ nm as24823.o&#xA;$ nm ase24823.o &#xA;...&#xA;                 U foo    &#xA;0000000000000000 T main&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(I've removed most of the output). What this is telling me is that the .o file has an &lt;em&gt;entry point&lt;/em&gt; called &quot;main&quot;, and an &lt;em&gt;undefined external reference&lt;/em&gt; (something that will be provided by a library) called &quot;foo&quot;. Now, if I remove the ifdefs from the foo.h file and recompile, this is what I get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ cat foo.h&#xA;extern int foo(const char* s);&#xA;$ g++ -c ase24823.cpp &#xA;$ nm ase24823.o &#xA;0000000000000000 T main&#xA;                 U _Z3fooPKc&#xA;....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What just happened? Because C++ no longer knows that it's supposed to call a &lt;em&gt;C&lt;/em&gt; function, it has mangled the external so as to encode the types of its arguments (this is so that overloading can happen).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you find this confusing, don't worry -- just edit the .h files that come with your C libraries and you'll be fine.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-06-05T06:00:21.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24883" PostTypeId="2" ParentId="24868" CreationDate="2016-06-05T06:26:08.423" Score="3" Body="&lt;p&gt;The ADC in default configuration will take 104 µs to make a sample (which agrees with Edgar Bonet's comment of roughly 9600 per second).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can speed that up somewhat by changing the ADC prescaler from the default of 128. See &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;ADC conversion on the Arduino (analogRead)&lt;/a&gt;. A prescaler of 32 will reduce that to 26 µs and still give quite acceptable results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also run the ADC asynchronously (in the background) so you can transmit the previous result while obtaining the next one. A higher baud rate than 9600 baud would be highly recommended in this case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People have been doing FFT analysis using the Arduino Uno and similar. I suggest you Google for relevant posts about that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-05T06:26:08.423" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24884" PostTypeId="1" AcceptedAnswerId="24886" CreationDate="2016-06-05T06:43:08.790" Score="0" ViewCount="144" Body="&lt;p&gt;I have a very tight space for a project that requires a mega board , the &quot;power in&quot; plug takes it over the space available. Are there safety or other concerns soldering to the lugs for the &quot;power in&quot; socket on the reverse of a mega 2560 rev 3 board board? the board is fitted with an elctrofreaks TFT LCD MEGA SHIELD v2.2 and a TFT_320QVT LCD screen. (the elctrofreaks mega shield uses vin pin)  1 other PWM  pin is used  and an esP8266 board on a uart channel The power  is from a regulated power supply. If  I do this, am I correct that the regulator and polyfuse will still be used?&lt;/p&gt;&#xA;" OwnerUserId="8004" LastEditorUserId="8004" LastEditDate="2016-06-05T06:55:26.083" LastActivityDate="2016-06-05T08:36:50.350" Title="Is there any reason not to solder power leads to the lugs for the power in socket on the reverse side of a mega 2560 rev 3 board?" Tags="|arduino-mega|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24886" PostTypeId="2" ParentId="24884" CreationDate="2016-06-05T08:36:50.350" Score="2" Body="&lt;p&gt;Soldering to the underside of the connector is exactly the same as plugging something in to the connector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes the regulator will be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No the polyfuse will not be used - that is in the USB power circuit not the barrel jack power circuit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-05T08:36:50.350" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24887" PostTypeId="1" AcceptedAnswerId="24889" CreationDate="2016-06-05T11:03:02.103" Score="0" ViewCount="1952" Body="&lt;p&gt;I'm a programmer, more from the software side but I do have hardware working knowledge too. I've completed the Arduino Starter Kit's 15 projects, Now trying to build some things with ESP8266 and HM-10 BLE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was able to connect ESP8266 to my network and start a TCP server too via AT commands(using  Arduino's Serial Monitor and FTDI 232RL USB to TTL converter)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also have a HM-10 Bluetooth Breakout+connector board (Its based on CC2541 by TI (visible on the SMD chip)) brought from &lt;a href=&quot;http://www.amazon.in/ePro-Labs-Module-Connector-Board-Bluetooth/dp/B019WEUY6O&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the same setup I was able to issue AT commands successfully for ESP8266. However I tried many things, different baud rates and \r\n combinations; I just couldnt get the HM-10 to acknowledge my AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setup: &lt;a href=&quot;https://i.stack.imgur.com/q90QO.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connections: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino +5V --&amp;gt; +ve input of LDO regulator --&amp;gt; 3.3v OUPUT to Vcc of HM-10&#xA;Common GND for LDO regulator input and output pins, FTDI 232RL and HM10&#xA;&#xA;FTDI TX --&amp;gt; voltage divider (1k ohms --&amp;gt; connection output to HM 10 RX --&amp;gt; 1k ohms --&amp;gt; 1k ohms --&amp;gt; GND)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is no code/sketch as of now. I'm just trying to hook up the HM-10 BLE chip. I can pair my Android phone to it but that's not the concern here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The concern here is I cannot configure the HM-10 using AT commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The HM-10 does not reply an &quot;OK&quot; acknowledge for my &quot;AT&quot; command. Nothing happens in the serial monitor after hitting enter. Just a blank screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a way by which I can determine what baud rate to use and what combination of \r and \n?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I missing here?&lt;/p&gt;&#xA;" OwnerUserId="22719" LastEditorUserId="22719" LastEditDate="2016-06-05T11:32:46.340" LastActivityDate="2016-06-05T11:34:56.980" Title="Unable to issue any AT commands to BT BLE Breakout Board" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24888" PostTypeId="1" CreationDate="2016-06-05T11:23:18.493" Score="1" ViewCount="633" Body="&lt;p&gt;i am new to micro controller programming and in need of help. i have managed to interface a light sensor to a micro controller (atmega 32a) and can read the value i.e. (1023) as per the set prescale. however i intended to achieve a single decimal value as the result. in this case (1) every time the sensor is exposed to light and successively perform an incremented tally as lights go on and off around the sensor ( i am using a LDR for this). i am currently having problem getting my micro controller to do this. i have searched all over the internet but no seems to assist me on this... please any insight on how to achieve this will be much appreciated. i know its a simple thing,HELP :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;basically just a means of making my micro controller count the number of times light falls on the LDR&lt;/p&gt;&#xA;" OwnerUserId="22721" LastActivityDate="2016-06-06T07:52:56.437" Title="counting ADC samples ( using a light sensor)" Tags="|sensors|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24889" PostTypeId="2" ParentId="24887" CreationDate="2016-06-05T11:26:25.993" Score="2" Body="&lt;p&gt;I found out that there is no need for a voltage divider to reduce the voltage being given to RX pin of BLE from FTDI's TX since both FTDI232RL and HM-10 are 3.3V devices (from &lt;a href=&quot;http://arduino-er.blogspot.in/2015/12/test-hm-10-bluetooth-40-ble-module-with.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connected the TX from FTDI directly to the RX of BLE using female to female jumpers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Used &lt;code&gt;No Line Ending&lt;/code&gt; and 9600 as the baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then it worked fine, I got an &lt;code&gt;OK&lt;/code&gt; acknowledge for my &lt;code&gt;AT&lt;/code&gt; command.&lt;/p&gt;&#xA;" OwnerUserId="22719" LastEditorUserId="22719" LastEditDate="2016-06-05T11:34:56.980" LastActivityDate="2016-06-05T11:34:56.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24890" PostTypeId="2" ParentId="24868" CreationDate="2016-06-05T12:56:06.947" Score="1" Body="&lt;p&gt;I loaded this program on an arduino uno and measured with oscilloscope the time from the rising edge to the falling edge of the signal on pin13.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;    Serial.begin(9600);&#xA;    pinMode(13,OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    PORTB = B00100000; //pin13 HIGH&#xA;    int sensorValue = analogRead(A0);&#xA;    PORTB = B00000000; //pin13 LOW&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;results:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;time: 110.4 uS&#xA;  relevant freuency: 9.06 kHz&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;in case you are interested in fast analogRead with Due, I suggest you take a look at &lt;a href=&quot;http://frenki.net/2013/10/fast-analogread-with-arduino-due/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;.&#xA;The author stated that an analogRead with Due takes about 40uS and he also describes a couple of ways to make it much faster.&lt;/p&gt;&#xA;" OwnerUserId="20645" LastActivityDate="2016-06-05T12:56:06.947" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24891" PostTypeId="2" ParentId="24888" CreationDate="2016-06-05T13:13:16.923" Score="2" Body="&lt;p&gt;There are 2 common light sensor types.  The &lt;a href=&quot;https://en.wikipedia.org/wiki/Photodiode&quot; rel=&quot;nofollow noreferrer&quot;&gt;photo diode&lt;/a&gt; and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Photoresistor&quot; rel=&quot;nofollow noreferrer&quot;&gt;photo resistor&lt;/a&gt;.  The first produces small amounts of current and operates fast.  The second changes resistance and operates (very) slowly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a good stack exchange response &lt;a href=&quot;https://electronics.stackexchange.com/questions/33659/how-do-i-connect-a-photodiode&quot;&gt;here&lt;/a&gt; for how to use a photo diode.  Often the photo diode output is small and additional hardware is used to amplify the signal.  As discussed in &lt;a href=&quot;https://electronics.stackexchange.com/questions/73732/how-to-use-sfh235-ir-photodiode-correctly&quot;&gt;this&lt;/a&gt; stack exchange response.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The photo resistor or &lt;a href=&quot;https://en.wikipedia.org/wiki/Cadmium_sulfide&quot; rel=&quot;nofollow noreferrer&quot;&gt;cadmium sulphide&lt;/a&gt; cell or Light Dependent Resistor is much easier to &lt;a href=&quot;http://playground.arduino.cc/Learning/PhotoResistor&quot; rel=&quot;nofollow noreferrer&quot;&gt;interface with an Arduino&lt;/a&gt;.  However, the response time is very slow.  On the order of hundreds of milliseconds to seconds.  This is acceptable when controlling street lights.  But is not acceptable in applications requiring fast light detectors such as those used for communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before going on, verify which device you are using in your design.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduinos contain a 10 bit ADC.  This results in values from 0 to 2&lt;sup&gt;10&lt;/sup&gt;−1 or 0 to 1023&lt;/a&gt;.  Should you consistently get a reading at or near the limits of the ADC check your hardware.  Do this by measuring the voltage at the input of the ADC pin used.  Do this under varying conditions to verify the hardware is operating as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A good software design uses &lt;a href=&quot;https://en.wikipedia.org/wiki/Hysteresis&quot; rel=&quot;nofollow noreferrer&quot;&gt;hysteresis&lt;/a&gt; to convert an analog value to a logical 1 or 0.  &lt;a href=&quot;https://arduino.stackexchange.com/a/9116&quot;&gt;Here&lt;/a&gt; is a stack exchange response about using hysteresis with Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-06T07:52:56.437" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24892" PostTypeId="1" CreationDate="2016-06-05T14:16:42.110" Score="2" ViewCount="306" Body="&lt;p&gt;It's been done, but the the tutorials I find seems incomplete. What I'm trying to do is make the ATTiny84 talk to the 2.4 GHz NRF24L01+ radio. I understand that in order to do that I need the MCU to talk to the radio by serial. Attiny84 (and 85) does not have serial, hardware any ways.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But as I understand it you can do software serial by USI, but in order to do so the core for the board has to have this modification?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've searched far and wide. I bump into the cores on Google Code (&lt;a href=&quot;https://code.google.com/archive/p/arduino-tiny/downloads&quot; rel=&quot;nofollow&quot;&gt;https://code.google.com/archive/p/arduino-tiny/downloads&lt;/a&gt;). I've installed them but SPI is not listed in the list of libraries.&#xA;I've got another tinycore (from where I dont know), when I use this one SPI is a library I can reference, but compiling causes&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;error: 'SPIE' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, could anyone point me to a known good source of cores to Attiny85 and 84 so I can enable SPI?&lt;/p&gt;&#xA;" OwnerUserId="2964" LastEditorUserId="612" LastEditDate="2016-06-05T19:09:14.693" LastActivityDate="2016-06-05T19:09:14.693" Title="Attiny cores with SPI support?" Tags="|attiny|nrf24l01+|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24893" PostTypeId="1" AcceptedAnswerId="24918" CreationDate="2016-06-05T14:57:12.737" Score="1" ViewCount="9493" Body="&lt;p&gt;I'm new to arduino and electronics. I've been trying to use the MPU6050 with my arduino but I'm having difficulty understanding the code. I'm referring to the code put up on the arduino website (&lt;a href=&quot;http://playground.arduino.cc/Main/MPU-6050#short&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/MPU-6050#short&lt;/a&gt;). Is there any way I could get a line by line explanation of the code?&lt;/p&gt;&#xA;" OwnerUserId="22718" LastEditorUserId="22718" LastEditDate="2016-06-06T02:45:06.333" LastActivityDate="2019-02-26T00:57:31.670" Title="MPU6050 code explanation" Tags="|arduino-uno|mpu6050|code-review|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24894" PostTypeId="1" AcceptedAnswerId="24916" CreationDate="2016-06-05T15:15:06.900" Score="0" ViewCount="4480" Body="&lt;p&gt;I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down.&lt;br&gt;&#xA;    I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me.&lt;br&gt;&#xA;   How can I achieve such thing? I am using arduino uno.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is the code I have that sets up the ADC interrupt:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;  ADCSRA = 0;  &#xA;  ADCSRB = 0;  &#xA;  ADMUX = 0;  &#xA;  ADMUX |= (1 &amp;lt;&amp;lt; REFS0) + (1 &amp;lt;&amp;lt; REFS1);  &#xA;  ADMUX |= (1 &amp;lt;&amp;lt; ADLAR);  &#xA;&#xA;  ADCSRA |= (1 &amp;lt;&amp;lt; ADATE); //enabble auto trigger  &#xA;  ADCSRA |= (1 &amp;lt;&amp;lt; ADIE); //enable interrupts when measurement complete  &#xA;  ADCSRA |= (1 &amp;lt;&amp;lt; ADEN); //enable ADC  &#xA;  ADCSRA |= (1 &amp;lt;&amp;lt; ADSC);  &#xA;  ADCSRA |= 0b010;  &#xA;&#xA;ISR(ADC_vect) {//when new ADC value ready&#xA;  af = af + ADCH;&#xA;  aaf++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found this on the internet, but it didn't work as I expected.&lt;/p&gt;&#xA;" OwnerUserId="22722" LastEditorUserId="7508" LastEditDate="2016-06-06T19:14:23.563" LastActivityDate="2016-06-06T19:14:23.563" Title="ADC timer interrupt when ready" Tags="|interrupt|adc|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24895" PostTypeId="1" AcceptedAnswerId="24899" CreationDate="2016-06-05T12:30:02.333" Score="22" ViewCount="27997" Body="&lt;p&gt;I’m a hobbyist and have used Arduino so far for simple projects. Now I want to build a project involving addressable LEDs, I want to write several programs on the Arduino for the LEDs and on my phone I select which ones to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found ESP8266 as a good and cheap solution to talk to my Arduino. Searching on the web to learn getting it to work I found that It has its own mcu on it and I can write and upload my code in Arduino IDE! 20kB of RAM, 80MHz CPU and 4MB of flash for 3 USD (However I’m not sure of these numbers but even one fourth of it is great)!! If I just need a few GPIOs why should use an Arduino UNO? Is this module reliable?&lt;/p&gt;&#xA;" OwnerUserId="22724" OwnerDisplayName="ahmadx87" LastActivityDate="2016-06-06T07:02:50.707" Title="Can ESP8266 replace Arduino?" Tags="|esp8266|" AnswerCount="4" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24896" PostTypeId="2" ParentId="24895" CreationDate="2016-06-05T12:33:29.643" Score="1" Body="&lt;p&gt;If you can program it, then of course it is viable to directly control your lights.  It doesn't have a large number of I/O pins like the Arduino does, but as long as you have enough to do the job, it certainly drops the cost, the size, and the power requirements.&lt;/p&gt;&#xA;" OwnerDisplayName="Dov" LastActivityDate="2016-06-05T13:59:24.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24897" PostTypeId="2" ParentId="24895" CreationDate="2016-06-05T13:40:15.503" Score="1" Body="&lt;p&gt;Yes there are a few I/O pins, so in theory you could drive one or a few leds or use an I/O port expander (I2C) for example.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes you can develop software and download it into even the low cost modules.  The Arduino-like angle is just one way to do this.  It is not an ARM as one might be lead to believe.  But there is a gnu toolchain for the esp8266, etc.  Yes 80 or 160MHz, 32 bit RISC, some flash, some ram.&lt;/p&gt;&#xA;" OwnerUserId="875" OwnerDisplayName="dwelch" LastActivityDate="2016-06-05T13:40:15.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24898" PostTypeId="2" ParentId="24895" CreationDate="2016-06-05T14:50:08.357" Score="1" Body="&lt;p&gt;The Arduino Uno board and the ESP module are not the same, but as long as the GPIO of the ESP8266 provides the hardware that you need for your application it will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of my concerns is certification.  The product has received several certifications, you'ld need to check if your version is also certified.&#xA;You can lookup the manufacturer's certifications (and some documentation) from the &lt;a href=&quot;https://apps.fcc.gov/oetcf/eas/reports/GenericSearch.cfm&quot; rel=&quot;nofollow&quot;&gt;FCC Search Page&lt;/a&gt; by entering 2AC7Z as the grantee code.&#xA;The board you use may depend on those or require their own certification.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you noticed, it can be added as a board type to the Arduino tool which makes it a lot easier for hobiests to play with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just checked the grants and all three of them require that the WiFi antenna is kept at least 20 cm of all persons.&lt;/p&gt;&#xA;" OwnerUserId="22725" OwnerDisplayName="le_top" LastActivityDate="2016-06-05T14:58:02.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24899" PostTypeId="2" ParentId="24895" CreationDate="2016-06-05T15:42:13.800" Score="13" Body="&lt;p&gt;Well, the answer of the question &quot;Can it replace Arduino&quot; - yes, in many cases it can.  &lt;br&gt;&#xA;Whether it would be &quot;the Arduino killer&quot; - I doubt it.  &lt;br&gt;&#xA;There are multiple arduinos and ESPs in my home and 1 ESP in my office running 24/7 as a part of my self-made (and constantly under development) smart home solution, together with 1-2 PCs. On top of that I have several experiments / unfinished projects involving the ESP.  &lt;br&gt;&#xA;So, from my not-so-limited experience, here are the pros and cons of ESP compared to Arduino:  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;++++ Internet connectivity built in!  &lt;br&gt;&#xA;++ Faster clock and more memory.  &lt;br&gt;&#xA;+ Runs on 3V3 (most, but not all Arduinos are 5V) so it can interface 3v3 devices (like most of the display modules) directly, without level shifters.  &lt;br&gt;&#xA;+ The &quot;basic&quot; ESP-12E costs about as much as an Arduino nano or pro micro.  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;- The &quot;basic&quot; ESP-12E is 2.0mm pitch, not 2.54mm, making it a pain in the ass to work with.  &lt;br&gt;&#xA;- There are breakouts that make it easier for prototyping, but they increase the cost and take too much space on a breadboard / protoboard.  &lt;br&gt;&#xA;- The most common breakout - NodeMCU - is more expensive and has pins remapped, major annoyance, unless you program it in Lua, which is only ok for very simple projects. IMO, it should be used for prototyping only.  &lt;br&gt;&#xA;- They run on 3v3, making it hard to interface 5V modules, fully turn on most MOSFETs, etc.  &lt;br&gt;&#xA;- They are extremely picky on their power supply.  &lt;br&gt;&#xA;- They draw significantly more power than the Arduino when not transmitting and much more when transmitting.  &lt;br&gt;&#xA;- They are almost always worse for battery operated projects - you need 3v3 regulator (which has quiescent current), you need to sleep a lot (and you need GPIO16 broken out for that) and at the end of the day an arduino + a low-power radio will do the same job while lasting significantly longer on battery.  &lt;br&gt;&#xA;- They have less GPIO pins and some of them must have set voltages at startup (GPIO0 - high, GPIO2 - high or floating, GPIO15 - low), also they &quot;wiggle&quot; some of their IO pins on startup, often making them unusable for many devices.  &lt;br&gt;&#xA;- They only have one ADC, and to my knowledge it is slower than the already slow Arduino ADCs, plus you can only use it with 0-1.1V (internal reference).  &lt;br&gt;&#xA;- Many of the Arduino libraries work out of the box or are already ported, but many don't. You either have to port them yourself or wait for someone to do it. In general, the Arduino community is much bigger and more mature, so most &quot;noob-friendly&quot; tutorials, libraries, etc. are provided for the Arduino.  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;Having that said, the ESP8266 is still great and extremely useful. Even Lua is useful for quick small projects. In most cases where internet connectivity is required, they seem to be the best solution. In many other cases, whether you will use ESP or Arduino actually doesn't matter. And sometimes the Arduino (or the little ATTiny85) is the better choice.  &lt;br&gt;&#xA;As always, &quot;the right tool for the job&quot; is the way to go.  &lt;br&gt;&#xA;Or combination of tools.  &lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="20696" OwnerDisplayName="Mishony" LastEditorUserId="20696" LastEditDate="2016-06-06T07:02:50.707" LastActivityDate="2016-06-06T07:02:50.707" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="24900" PostTypeId="1" CreationDate="2016-06-05T17:20:40.910" Score="0" ViewCount="146" Body="&lt;p&gt;I need some motor drivers that can control a DC motor with 10-15 A and 25 V. I can't find any shield that can do the job. I need to control 4 motors with these.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you suggest some models that are good with this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And one more question: if a driver can control a DC motor in 2 directions, can it control 2 DC motors in one direction each?&lt;/p&gt;&#xA;" OwnerUserId="21522" LastEditorUserId="4628" LastEditDate="2017-01-02T16:14:55.250" LastActivityDate="2017-08-31T12:15:44.473" Title="Good Arduino motor drivers" Tags="|motor|arduino-motor-shield|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24901" PostTypeId="2" ParentId="24900" CreationDate="2016-06-05T18:52:53.967" Score="1" Body="&lt;p&gt;We don't really answer &quot;shopping questions&quot;.&lt;br&gt;&#xA;You could contact several suppliers like &lt;a href=&quot;https://www.adafruit.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Adafruit&lt;/a&gt;, &lt;a href=&quot;https://www.sparkfun.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;sparkfun&lt;/a&gt; or maybe even &lt;a href=&quot;http://digikey.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;Digikey&lt;/a&gt;, &lt;a href=&quot;http://www.farnell.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Farnell&lt;/a&gt; etc (&lt;a href=&quot;http://ebay.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;ebay&lt;/a&gt;?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you search for: &quot;15A dual h-bridge&quot; you will find some motor drivers which should work for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;If a driver can control a dc motor in 2 directions can it control 2 dc motors in one direction each?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where are you going to use them for?&#xA;If you're only going in one direction, you won't need a motor driver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;a href=&quot;https://www.adafruit.com/product/1794&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOSFET&lt;/a&gt; (per motor) is good enough if you only drive one direction.&#xA;If you want both motors to be able to turn each direction, a &lt;a href=&quot;http://www.ebay.com/itm/3-36V-Dual-15A-H-Bridge-DC-Motor-Driver-30A-for-Robot-Car-Arduino-Compatible-/171012036277&quot; rel=&quot;nofollow noreferrer&quot;&gt;dual h-bridge&lt;/a&gt; will do.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastEditorUserId="28084" LastEditDate="2016-12-03T14:04:49.833" LastActivityDate="2016-12-03T14:04:49.833" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24902" PostTypeId="1" AcceptedAnswerId="24903" CreationDate="2016-06-05T19:52:59.523" Score="5" ViewCount="621" Body="&lt;p&gt;I stumbled upon this piece in &lt;code&gt;digitalWrite&lt;/code&gt;.&#xA;I'm unsure why clearing interrupts and setting/resetting SREG is neccesary here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone shed a light on this?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t oldSREG = SREG;&#xA;cli();&#xA;&#xA;if (val == LOW) {&#xA;    *out &amp;amp;= ~bit;&#xA;} else {&#xA;    *out |= bit;&#xA;}&#xA;&#xA;SREG = oldSREG;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I figure they don't want an interrupt to possibly change any of the bits in the output register while it executes &lt;code&gt;*out = *out &amp;amp; ~bit&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And what would the SREG have to do with it? Could the code affect SREG and why would that matter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When speed matters, I often use the direct port manipulation, I'd like to get an idea if it's neccesary for me to include these &quot;precautions&quot;.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-05T20:10:47.730" Title="Arduino's digitalWrite, precautions for direct port manipulation?" Tags="|programming|c|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24903" PostTypeId="2" ParentId="24902" CreationDate="2016-06-05T20:05:18.523" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I figure they don't want an interrupt to possibly change any of the bits in the output register while it executes *out = *out &amp;amp; ~bit?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Correct. That is known as a &lt;em&gt;critical section&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And what would the SREG have to do with it? Could the code affect SREG and why would that matter?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;SREG is where the flag that says if interrupts are enable or not is stored.  Basically that is storing the current state, disabling interrupts, then restoring the current state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upshot is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If interrupts are enabled to begin with, they are disabled, then re-enabled.&lt;/li&gt;&#xA;&lt;li&gt;If interrupts are disabled to begin with, they are again disabled, and they remain disabled.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;It's a way of restoring the previous state without actually having to check what the state was and set or clear accordingly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-05T20:05:18.523" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24904" PostTypeId="2" ParentId="24902" CreationDate="2016-06-05T20:10:47.730" Score="2" Body="&lt;p&gt;Answering only the last question, as the rest has been addressed by&#xA;Majenko.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I often use the direct port manipulation, I'd like to get an idea if&#xA;   it's neccesary for me to include these &quot;precautions&quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you use &lt;em&gt;constant&lt;/em&gt; values, like &lt;code&gt;PORTB |= _BV(2);&lt;/code&gt; or the like, there&#xA;is no need, since this compiles into a single CPU instruction. Even if&#xA;you write things that take multiple instructions,&#xA;like &lt;code&gt;PORTB |= _BV(2) | _BV(3);&lt;/code&gt;, you probably know whether you are&#xA;modifying the same register inside an interrupt handler or not. If not,&#xA;no need for critical section either. The authors of the Arduino core&#xA;cannot make any assumptions.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-05T20:10:47.730" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24905" PostTypeId="2" ParentId="3781" CreationDate="2016-06-05T20:49:27.867" Score="4" Body="&lt;p&gt;I had &lt;em&gt;exactly&lt;/em&gt; this problem. If the ATtiny is set for external clock, then the ArduinoISP will not be able to program it without an external crystal. Connected a 16&amp;nbsp;MHz crystal and 2 capacitors and worked perfectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I was then able to set ATtiny to internal clock, remove the crystal, and then worked perfectly without the crystal.)&lt;/p&gt;&#xA;" OwnerUserId="22727" LastEditorUserId="6936" LastEditDate="2019-05-08T19:38:36.807" LastActivityDate="2019-05-08T19:38:36.807" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="24906" PostTypeId="2" ParentId="24867" CreationDate="2016-06-05T20:52:43.057" Score="0" Body="&lt;p&gt;Just put a 10 µF capacitor between the 5v and RESET pins of your Arduino and do whatever you want, just make sure that the capacitor is connected after the board has been powered up, and also, remove the capacitor before uploading any code.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-06-05T20:52:43.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24907" PostTypeId="1" AcceptedAnswerId="24908" CreationDate="2016-06-06T01:02:34.060" Score="0" ViewCount="754" Body="&lt;p&gt;So, I just fried my arduino nano on a breadboard. Can I still use the breadboard and usb cable?&lt;/p&gt;&#xA;" OwnerUserId="21318" LastEditorUserId="21318" LastEditDate="2016-07-04T05:58:25.927" LastActivityDate="2016-07-04T05:58:25.927" Title="I just fried my Arduino on a breadboard. Can I still use the breadboard?" Tags="|arduino-nano|" AnswerCount="2" CommentCount="3" ClosedDate="2016-07-04T16:32:07.250" ContentLicense="CC BY-SA 3.0" />
  <row Id="24908" PostTypeId="2" ParentId="24907" CreationDate="2016-06-06T01:08:25.513" Score="0" Body="&lt;p&gt;It really depends on the circumstances around its demise. If it went out in smoke and flames, maybe not. Assuming the chip quietly overheated and died, the breadboard and the cable are almost certainly ok. Either of them will stand more abuse than the chip will. What was the cause of failure?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-06T01:08:25.513" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24909" PostTypeId="2" ParentId="24907" CreationDate="2016-06-06T01:21:25.140" Score="1" Body="&lt;p&gt;you can test the breadboard if you have a multimeter. Even if you don't, you can place an LED, a resistor and a power source across the suspect portions of the breadboard. If you locate a trace or two that appear unreliable, you should be able to mark them appropriately and continue to use the board.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-06T01:21:25.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24915" PostTypeId="2" ParentId="24894" CreationDate="2016-06-06T06:40:02.067" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;it is somehow possible to make a ADC timer interrupt&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The ADC and the timers are two different things. If you mean a timer interrupt, I'm not sure why you would want that. If you mean an ADC interrupt, yes you can do do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is some example code from &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;my page about the ADC&lt;/a&gt; which shows using the interrupt (on a Uno):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const byte adcPin = 0;&#xA;volatile int adcReading;&#xA;volatile boolean adcDone;&#xA;boolean adcStarted;&#xA;&#xA;void setup ()&#xA;{&#xA;  Serial.begin (115200);&#xA;  ADCSRA =  bit (ADEN);                      // turn ADC on&#xA;  ADCSRA |= bit (ADPS0) |  bit (ADPS1) | bit (ADPS2);  // Prescaler of 128&#xA;  ADMUX  =  bit (REFS0) | (adcPin &amp;amp; 0x07);    // AVcc and select input port&#xA;&#xA;}  // end of setup&#xA;&#xA;// ADC complete ISR&#xA;ISR (ADC_vect)&#xA;  {&#xA;  adcReading = ADC;&#xA;  adcDone = true;  &#xA;  }  // end of ADC_vect&#xA;&#xA;void loop ()&#xA;{&#xA;  // if last reading finished, process it&#xA;  if (adcDone)&#xA;    {&#xA;    adcStarted = false;&#xA;&#xA;    // do something with the reading, for example, print it&#xA;    Serial.println (adcReading);&#xA;    delay (500);&#xA;&#xA;    adcDone = false;&#xA;    }&#xA;&#xA;  // if we aren't taking a reading, start a new one&#xA;  if (!adcStarted)&#xA;    {&#xA;    adcStarted = true;&#xA;    // start the conversion&#xA;    ADCSRA |= bit (ADSC) | bit (ADIE);&#xA;    }    &#xA;&#xA;  // do other stuff here&#xA;&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I should point out that if you do an &lt;code&gt;analogRead&lt;/code&gt; it &lt;strong&gt;blocks&lt;/strong&gt; until the read is done, so the very next line to be executed after &lt;code&gt;analogRead&lt;/code&gt; will be when the data is ready.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-06T06:40:02.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24916" PostTypeId="2" ParentId="24894" CreationDate="2016-06-06T07:45:35.303" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have been told by my teacher that it is somehow possible to make a ADC timer interrupt.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You might have asked him or he could explain it ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Generally, if you want to do anything with an Arduino, which isn't implemented by the Arduino libraries, you're going to have to roll your own code (or copy it from the internet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer from Nick will most certainly be enough to help you with the problem. However, it'd be way more cooler to find out how you can solve these problems yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Getting started&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find a duplicate of this question, though it's a rather common question. You should've checked some of the &lt;a href=&quot;http://www.avr-tutorials.com/adc/utilizing-avr-adc-interrupt-feature&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorials&lt;/a&gt; on the web, it'll get you started a lot faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But don't forget the datasheet and manuals of the ATMega328(P). In case you can't really find something that fits your needs, or if you want to check some background information.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Setting registers (ADC)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This piece of code (from Nick Gammon), sets up the ADC.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  ADCSRA =  bit (ADEN);                      // turn ADC on&#xA;  ADCSRA |= bit (ADPS0) |  bit (ADPS1) | bit (ADPS2);  // Prescaler of 128&#xA;  ADMUX  =  bit (REFS0) | (adcPin &amp;amp; 0x07);    // AVcc and select input port&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Fair enough, but if you wanted to change anything of it, you'll think: &quot;How did he ever come up with this.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the registers of the microcontroller. By setting bits in the right pattern, you can enable/disable functions or change settings of the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should download the &lt;a href=&quot;http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATMega328(P)&lt;/a&gt; datasheet. You can very easily navigate through it (if you've got a PDF reader that supports &quot;bookmarks&quot;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Check for &quot;24. Analog to Digital converter&quot; you should read through it, and go to &quot;24.9 (Analog to Digital converter) - Register description.&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you can see, which bits of (in example) the &lt;code&gt;ADCSRA&lt;/code&gt; register you have to set to enable the adc (&lt;code&gt;ADEN&lt;/code&gt;), start the conversion (&lt;code&gt;ADSC&lt;/code&gt;). And enable interrupts for it (&lt;code&gt;ADIE&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hqnzk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hqnzk.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Interrupts&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you also want behavior that has to do with interrupts. You should also check out the interrupts bookmark (#12). 12.1 will show you an table with all interrupt vectors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's quite a shame that they don't have a nice C example code, they do have an &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__interrupts.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;reference manual&lt;/a&gt; though, but you'll implement an interrupt handler like this (from Nick Gammon).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ADC complete ISR&#xA;ISR (ADC_vect)&#xA;  {&#xA;  adcReading = ADC;&#xA;  adcDone = true;  &#xA;  }  // end of ADC_vect&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you now want to interrupt on SPI you can check the datasheet or reference manual for the vector name. (&lt;code&gt;SPI_STC_vect&lt;/code&gt;)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-06T07:45:35.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24918" PostTypeId="2" ParentId="24893" CreationDate="2016-06-06T08:36:53.203" Score="2" Body="&lt;p&gt;I've added in a bunch of comments for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MPU-6050 Short Example Sketch&#xA;// By Arduino User JohnChi&#xA;// August 17, 2014&#xA;// Public Domain&#xA;#include&amp;lt;Wire.h&amp;gt;&#xA;const int MPU_addr=0x68;  // I2C address of the MPU-6050&#xA;int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; // declare accellerometer and gyro variables&#xA;void setup(){&#xA;  Wire.begin(); // initiate i2c system&#xA;  Wire.beginTransmission(MPU_addr); // be sure we talk to our MPU vs some other device&#xA;  Wire.write(0x6B);  // PWR_MGMT_1 register&#xA;  Wire.write(0);     // set to zero (wakes up the MPU-6050)&#xA;  Wire.endTransmission(true); // done talking over to MPU device, for the moment&#xA;  Serial.begin(9600); // initialize serial port to 9600 bps so you can see your debug messages in Arduino IDE via debug channel&#xA;}&#xA;void loop(){ // main program loop&#xA;  Wire.beginTransmission(MPU_addr); // get ready to talk to MPU again&#xA;  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)&#xA;  Wire.endTransmission(false); // done talking to MPU for the time being&#xA;  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers&#xA;  // all the fancy &amp;lt;&amp;lt;8| stuff is to bit shift the first 8 bits to&#xA;  // the left &amp;amp; combine it with the next 8 bits to form 16 bits&#xA;  AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C (ACCEL_XOUT_L)    &#xA;  AcY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;  AcZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;  Tmp=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x41 (TEMP_OUT_H) &amp;amp; 0x42 (TEMP_OUT_L)&#xA;  GyX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x43 (GYRO_XOUT_H) &amp;amp; 0x44 (GYRO_XOUT_L)&#xA;  GyY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x45 (GYRO_YOUT_H) &amp;amp; 0x46 (GYRO_YOUT_L)&#xA;  GyZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x47 (GYRO_ZOUT_H) &amp;amp; 0x48 (GYRO_ZOUT_L)&#xA;  // the above lines have gathered Accellerometer values for X, Y, Z&#xA;  //  as well as Gyroscope values for X, Y, Z&#xA;&#xA;  Serial.print(&quot;AcX = &quot;); Serial.print(AcX); // share accellerometer values over debug channel &#xA;  Serial.print(&quot; | AcY = &quot;); Serial.print(AcY);&#xA;  Serial.print(&quot; | AcZ = &quot;); Serial.print(AcZ);&#xA;  Serial.print(&quot; | Tmp = &quot;); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet&#xA;  Serial.print(&quot; | GyX = &quot;); Serial.print(GyX); // share gyroscope values over debug channel&#xA;  Serial.print(&quot; | GyY = &quot;); Serial.print(GyY);&#xA;  Serial.print(&quot; | GyZ = &quot;); Serial.println(GyZ);&#xA;  delay(333); // delay a bit to not overwhelm you the user/programmer as you view the results&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-06-06T08:36:53.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24919" PostTypeId="1" CreationDate="2016-06-06T09:38:40.260" Score="6" ViewCount="33618" Body="&lt;p&gt;I have bought this shield from ebay and now I don't know how to use it, &lt;a href=&quot;http://www.ebay.in/itm/ESP-12E-ESP8266-UART-WIFI-Wireless-Shield-for-Arduino-UNO-R3-Bouclier-Sans-filfr-/152048233906&quot; rel=&quot;noreferrer&quot;&gt;ESP 12E ESP8266 UART WIFI Wireless Shield for Arduino UNO R3 Bouclier Sans filfr&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1Qtcc.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1Qtcc.jpg&quot; alt=&quot;Photo of shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are no instructions in the box or anywhere on internet for this board. The only description I found everywhere is this:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt; &lt;/p&gt;&#xA;  &#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Standard pin interface to achieve full compatibility with the pitch Arduino Uno, Mega and so on. (Unless the standard size Arduino, such&#xA;  as Nano, Mini) &lt;/li&gt;&#xA;  &lt;li&gt;3.3V power supply using advanced chip (with the official expansion board power chip CC3000 same), so 3.3V Arduino board provided more&#xA;  accurate, so ESP8266 as official CC3000 chip work as normal, there is&#xA;  no gap. &lt;/li&gt;&#xA;  &lt;li&gt;It leads to a WiFi module power supply / service interface to facilitate developers to extend the power supply and maintenance. &lt;/li&gt;&#xA;  &lt;li&gt;Onboard ESP8266-12 stable industrial grade serial WiFi module, using an enhanced PCB antenna, signal better. &lt;/li&gt;&#xA;  &lt;li&gt;You can quickly switch DIP switch ESP8266-12 industrial grade WiFi stable operation mode (such as operating mode and upgrade mode)&#xA;  module, integrated serial chip, quickly flashing the firmware. &lt;/li&gt;&#xA;  &lt;li&gt;Built-in 5V to 3.3V TTL level converter to prevent high-pressure Arduino TTL level of the WiFi module damage. &lt;/li&gt;&#xA;  &lt;li&gt;Onboard ESP8266-12 stable industrial grade WiFi module with a metal shield, immunity to interference. &lt;/li&gt;&#xA;  &lt;li&gt;Onboard ESP8266-12 standard pitch leads to a stable industrial grade WiFi module all interfaces, enabling developers to easily&#xA;  develop deep. &lt;/li&gt;&#xA;  &lt;li&gt;Use stackable design, it can continue to accumulate above the other modules, easy to use. &lt;/li&gt;&#xA;  &lt;li&gt;Onboard four LED displays the status of ESP8266, namely PWR, DFU, AP, STA&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What should be the board settings for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am new to electronics please help me how can I connect this with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="22741" LastEditorUserId="6936" LastEditDate="2017-01-21T19:23:00.230" LastActivityDate="2023-01-28T15:51:04.497" Title="How to connect Wi-Fi shield ESP-12E-ESP8266-UART-WIFI-Wireless-Shield with Arduino" Tags="|arduino-uno|esp8266|wifi|library|" AnswerCount="6" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="24921" PostTypeId="1" AcceptedAnswerId="24983" CreationDate="2016-06-06T10:34:34.710" Score="0" ViewCount="184" Body="&lt;p&gt;I changed 2 Arduino Libraries because i have a 9 bit data protocol, now i want use the amended Libraries on my Arduino mega2560.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At first i have set a 9 bit data mode that can i do when i set the UCSZ12 bit on 1(original code under the following link: &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp#L103&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp#L103&lt;/a&gt; ): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void HardwareSerial::begin(unsigned long baud, byte config)&#xA;  ...&#xA;  sbi(*_ucsrb, RXCIE0);&#xA;  sbi(*_ucsrb, UCSZ12);  // chance: set 9-bit data mode on 1&#xA;  cbi(*_ucsrb, UDRIE0);&#xA;  ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At second i want throw an interrupt when the 9th bit is an 1 that can i do when i change the code like the follow (original code under the following link : &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial_private.h#L101&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial_private.h#L101&lt;/a&gt; ):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void HardwareSerial::_rx_complete_irq(void)&#xA;  if (bit_is_clear(*_ucsra, UPE0)) {&#xA;    bool is_address = UCSR0B &amp;amp; _BV(RXB80);&#xA;    unsigned char c = *_udr;   &#xA;    if (is_address) {&#xA;      do_something_with_address(c);&#xA;      return;&#xA;    }&#xA;  rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE;&#xA;...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What must i do with the two file´s?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can i use the changed Libraries?&lt;/p&gt;&#xA;" OwnerUserId="21214" LastEditorUserId="7508" LastEditDate="2016-06-06T10:45:16.270" LastActivityDate="2016-06-08T07:05:21.783" Title="Safe changes in the Arduino Libraries and use them" Tags="|library|core-libraries|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24923" PostTypeId="1" CreationDate="2016-06-06T11:47:11.117" Score="0" ViewCount="1944" Body="&lt;p&gt;I have my Arduino code as below.I am trying to send Serial request and get response for it. I can able to send request mentioned in Setup function and also able to switch cases. Problem i am facing Print character buffer after storing the  values. can someone suggest me how to store integer value into charcter buffer and print result later.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;glob.h&quot;&#xA;const int BUFFER_SZ = 32;&#xA;char sendBuffer[60]={'0'};&#xA;&#xA;void Take_Reading() {&#xA;&#xA;  for (int row = 0; row &amp;lt; 8; row++)&#xA;  {&#xA;    //   // get rid of me:&#xA;    digitalWrite(SO_enable, array[row][0]);&#xA;    digitalWrite(S1_enable, array[row][1]);&#xA;    digitalWrite(S2_enable, array[row][2]);&#xA;    delay(50);&#xA;    analog_1_pv[row] = ANALOG_SCALING * analogRead(A0);&#xA;    analog_2_pv[row] = ANALOG_SCALING * analogRead(A1);&#xA;    analog_3_pv[row] = ANALOG_SCALING * analogRead(A2);&#xA;    if ( (analog_1_pv[row] &amp;lt;= MINV_RANGE || (analog_1_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value1[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value1[row] =  (analog_1_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;    if (  (analog_2_pv[row] &amp;lt;= MINV_RANGE || (analog_2_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value2[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value2[row] =  (analog_2_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;    if (  (analog_3_pv[row] &amp;lt;= MINV_RANGE || (analog_3_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value3[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value3[row] =  (analog_3_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;&#xA;    Mod_current[row] = (uint16_t)(Mul_Factor * Current_Value1[row]);&#xA;    Mod_current[row + 8] = (uint16_t)(Mul_Factor * Current_Value2[row]);&#xA;    Mod_current[row + 16] = (uint16_t)(Mul_Factor * Current_Value3[row]);&#xA;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;int ID_Check() {&#xA;&#xA;  int ID_value;&#xA;  for (int row = 0; row &amp;lt; 8; row++)&#xA;  {&#xA;    digitalWrite(SO_enable, array[row][0]);&#xA;    digitalWrite(S1_enable, array[row][1]);&#xA;    digitalWrite(S2_enable, array[row][2]);&#xA;    Status_Out[row] = digitalRead(Output_Read);&#xA;&#xA;  }&#xA;&#xA;  ID_value = 1 * Status_Out[7] + 2 * Status_Out[6] + 4 * Status_Out[5] + 8 * Status_Out[4] + 16 * Status_Out[3] + 32 * Status_Out[2] + 64 * Status_Out[1] + 128 * Status_Out[0];&#xA;  return (ID_value);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;int  Take_Temp_Reading()&#xA;{&#xA;&#xA;  Temp_Total = Temp_Total - Temp_readings[Temp_index];&#xA;  Temp_readings[Temp_index] = analogRead(A5);&#xA;  Temp_Total = Temp_Total + Temp_readings[Temp_index];&#xA;  Temp_index = Temp_index + 1;&#xA;&#xA;  if (Temp_index &amp;gt;= numReadings)&#xA;  {&#xA;    Temp_index = 0;&#xA;    Temp_Average = Temp_Total / numReadings;&#xA;  }&#xA;  temp = (Temp_Average * 5.0) / 1023.0;&#xA;&#xA;&#xA;  //  temp = float(analogRead(A5)) * 5.0 / 1024.0;&#xA;  temp_int = (int)(temp * 100.0);&#xA;  return (temp_int);&#xA;  // Serial.print(&quot;Temp&quot;); Serial.println(temp);&#xA;}&#xA;&#xA;int SPD_Check()&#xA;{&#xA;&#xA;  SPD_STATUS = digitalRead(SPD_STATUS_PIN);&#xA;  return (SPD_STATUS);&#xA;}&#xA;&#xA;int  DC_Status()&#xA;{&#xA;&#xA;  DC_STATUS = digitalRead(DC_STATUS_PIN);&#xA;  return (DC_STATUS);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;int   Take_HV_Reading()&#xA;{&#xA;&#xA;  //int analog_int= analogRead(A4);&#xA;&#xA;  total = total - readings[index];&#xA;  // read from the sensor:&#xA;  readings[index] = analogRead(A4);&#xA;  // add the reading to the total:&#xA;  total = total + readings[index];&#xA;  // advance to the next position in the array:&#xA;  index = index + 1;&#xA;&#xA;  // if we're at the end of the array...&#xA;  if (index &amp;gt;= numReadings1)&#xA;  {&#xA;    index = 0;&#xA;    average = total / numReadings1;&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;&#xA;    HV_voltage = (average * 5.0) / 1023.0;&#xA;  }&#xA;  if (HV_voltage &amp;lt;= 0.25)&#xA;  {&#xA;&#xA;    Conv_HV_voltage = 0.0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Conv_HV_voltage = 197.837837838 * HV_voltage + 10.8108108108;&#xA;  }&#xA;&#xA;  HV_Reading = (uint16_t)(Conv_HV_voltage * 10);&#xA;&#xA;  //  HV_Reading = (uint16_t)(Conv_HV_voltage * 10);&#xA;&#xA;  return(HV_Reading);&#xA;}&#xA;&#xA;&#xA;void  Serial_Command1()&#xA;&#xA;{&#xA;   Take_Reading();&#xA;  int Temp_read=Take_Temp_Reading();&#xA;  int HV_Read=Take_HV_Reading();&#xA;  SPD=SPD_Check();&#xA;  DISCONNECTOR=DC_Status();&#xA;  Serial.println(&quot;Command1 executed &quot;);&#xA;&#xA;&#xA;  sendBuffer[1]=char(Mod_current[1]) ;&#xA;  sendBuffer[2]= ',';&#xA;  sendBuffer[2]= Mod_current[1];&#xA;  sendBuffer[3]= ',';&#xA;&#xA;  sendBuffer[4]= Mod_current[2];&#xA;  sendBuffer[5]= ',';&#xA;  sendBuffer[6]= Mod_current[3];&#xA;  sendBuffer[7]= ',';&#xA;&#xA;  sendBuffer[8]= Mod_current[4];&#xA;  sendBuffer[9]= ',';&#xA;  sendBuffer[10]= Mod_current[5];&#xA;  sendBuffer[11]= ',';&#xA;&#xA;  sendBuffer[12]= Mod_current[6];&#xA;  sendBuffer[13]= ',';&#xA;  sendBuffer[14]= Mod_current[7];&#xA;  sendBuffer[15]= ',';&#xA;&#xA;  sendBuffer[16]= Mod_current[8];&#xA;  sendBuffer[17]= ',';&#xA;  sendBuffer[18]= Mod_current[9];&#xA;  sendBuffer[19]= ',';&#xA;&#xA;  sendBuffer[20]= Mod_current[10];&#xA;  sendBuffer[21]= ',';&#xA;  sendBuffer[22]= Mod_current[11];&#xA;  sendBuffer[23]= ',';&#xA;&#xA;&#xA;  sendBuffer[24]= Mod_current[12];&#xA;  sendBuffer[25]= ',';&#xA;  sendBuffer[26]= Mod_current[13];&#xA;  sendBuffer[27]= ',';&#xA;&#xA;  sendBuffer[28]= Mod_current[23];&#xA;  sendBuffer[29]= ',';&#xA;  sendBuffer[30]= Mod_current[22];&#xA;  sendBuffer[31]= ',';&#xA;&#xA;  sendBuffer[32]= Mod_current[21];&#xA;  sendBuffer[33]= ',';&#xA;  sendBuffer[34]= Mod_current[20];&#xA;  sendBuffer[35]= ',';&#xA;&#xA;  sendBuffer[36]= Mod_current[19];&#xA;  sendBuffer[37]= ',';&#xA;  sendBuffer[38]= Mod_current[18];&#xA;  sendBuffer[39]= ',';&#xA;&#xA;  sendBuffer[40]= Mod_current[17];&#xA;  sendBuffer[41]= ',';&#xA;  sendBuffer[42]= Mod_current[16];&#xA;  sendBuffer[43]= ',';&#xA;&#xA;  sendBuffer[44]= Mod_current[15];&#xA;  sendBuffer[45]= ',';&#xA;  sendBuffer[46]= Mod_current[14];&#xA;  sendBuffer[47]= ',';&#xA;  sendBuffer[48]= Temp_read;&#xA;  sendBuffer[49]= ',';&#xA;  sendBuffer[50]= HV_Read;&#xA;  sendBuffer[51]= ',';&#xA;  sendBuffer[52]= SPD;&#xA;  sendBuffer[53]= ',';&#xA;  sendBuffer[54]= DISCONNECTOR;&#xA;&#xA;  Serial.println(sendBuffer[1]);&#xA;&#xA;}&#xA;&#xA;void Serial_Command2(int a)&#xA;{&#xA;&#xA;  Serial.print(&quot;Command2 executed: &quot;);&#xA;  Serial.println(a);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;Format 1: &amp;lt;SMCB1,1&amp;gt;&quot;);&#xA;  Serial.println(&quot;Format 2: &amp;lt;SMCB1,1,Length&amp;gt;&quot;);&#xA;&#xA;}&#xA;&#xA;// Parse the request, WITHOUT the '&amp;lt;' and '&amp;gt;' delimiters.&#xA;void parseRequest(char *request)&#xA;{&#xA;  // Check the request starts with the prefix &quot;SMCB1,1&quot;.&#xA;  if (strncmp(request, &quot;SMCB1,1&quot;, 7) != 0) {&#xA;    Serial.println(F(&quot;Error: bad request prefix&quot;));&#xA;    return;&#xA;  }&#xA;&#xA;  // Remove that known prefix.&#xA;  // Now we have either &quot;&quot;, &quot;,Length&quot; or &quot;,Timer,On_OFF&quot;&#xA;  request += 7;&#xA;&#xA;  // Format 1: &quot;&quot;&#xA;  if (request[0] == '\0') {&#xA;    //Serial.println(F(&quot;Received format 1&quot;));&#xA;    Serial_Command1();&#xA;    return;&#xA;  }&#xA;&#xA;  // Remove the leading comma.&#xA;  // Now we have either &quot;Length&quot; or &quot;Timer,On_OFF&quot;&#xA;  if (request[0] != ',') {&#xA;    Serial.println(F(&quot;Error: ',' expected&quot;));&#xA;    return;&#xA;  }&#xA;  request++;&#xA;&#xA;  // Format 2: &quot;Length&quot;, no comma.&#xA;  char * comma = strchr(request, ',');&#xA;  if (!comma) {&#xA;&#xA;    int length = atoi(request);&#xA;    Serial_Command2(length);&#xA;    //Serial.print(F(&quot;Received format 2, length = &quot;));&#xA;    // Serial.println(length);&#xA;    return;&#xA;  }&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  static char buffer[BUFFER_SZ];  // received chars&#xA;  static size_t pos;              // current position in buffer&#xA;  static bool insideRequest;      // are we between '&amp;lt;' and '&amp;gt;'?&#xA;&#xA;  if (Serial.available()) {&#xA;    char c = Serial.read();&#xA;    if (insideRequest) {&#xA;      if (c == '&amp;gt;') {  // end of request received&#xA;        buffer[pos] = '\0';  // terminate the string&#xA;        parseRequest(buffer);&#xA;        pos = 0;             // get ready for the next request&#xA;        insideRequest = false;&#xA;      }&#xA;      else if (pos &amp;lt; BUFFER_SZ-1) {  // add char to buffer&#xA;        buffer[pos++] = c;&#xA;      }&#xA;    }&#xA;    else if (c == '&amp;lt;') {  // start of request&#xA;      insideRequest = true;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Golb.h header file contains&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef GLOB_H&#xA;#define GLOB_H&#xA;int counter=0;&#xA;int Mod_current[24];&#xA;const int numReadings = 10;&#xA;const int numReadings1 = 10;&#xA;int Temp_Total = 0;&#xA;int Temp_readings[numReadings];&#xA;int Temp_index = 0;&#xA;int Temp_Average = 0;&#xA;float  reading[10];&#xA;float Total = 0.0;&#xA;static int i;&#xA;&#xA;int readings[numReadings];&#xA;int index = 0;&#xA;int total = 0;&#xA;int average = 0;&#xA;&#xA;// These PinS are use to enable and disable analog MUX&#xA;int SO_enable = 5;&#xA;int S1_enable = 4;&#xA;int S2_enable = 3;&#xA;&#xA;// temprature sensor permeter&#xA;int TempPin = 5;&#xA;float temp;&#xA;static int temp_int;&#xA;&#xA;// digital mux setting&#xA;int Output_Read = 2;&#xA;&#xA;float Vref = 2.5;&#xA;// Used for sensor conversion&#xA;float ANALOG_SCALING = 0.004887585532746823;&#xA;//tempfloat ANALOG_SCALING=0.0049560117;&#xA;&#xA;&#xA;int Sensor_Value0 = 0;&#xA;int Sensor_Value1 = 0;&#xA;int Sensor_Value2 = 0;&#xA;float analog_1_pv[8];&#xA;float analog_2_pv[8];&#xA;float analog_3_pv[8];&#xA;int Status_Out[8];&#xA;&#xA;//SPD &amp;amp; DC STATUS PIN&#xA;static int SPD_STATUS_PIN = 6;&#xA;static int DC_STATUS_PIN = 7;&#xA;&#xA;int row;&#xA;&#xA;int Mul_Factor = 10;&#xA;&#xA;float Current_Value1[8] = {&#xA;  0.0&#xA;};&#xA;float Current_Value2[8] = {&#xA;  0.0&#xA;};&#xA;float Current_Value3[8] = {&#xA;  0.0&#xA;};&#xA;&#xA;//HV perameter setting are defined here&#xA;int HV_SensorValue;&#xA;int HV_Reading;&#xA;float HV_voltage;&#xA;float Conv_HV_voltage;&#xA;unsigned  int DC_STATUS = 0;&#xA;unsigned int SPD_STATUS = 0;&#xA;float MINV_RANGE = 2.52;&#xA;//float MIDV_RANGE1=1.875;&#xA;float MAXV_RANGE = 4.5;&#xA;&#xA;int SPD;&#xA;int DISCONNECTOR;&#xA;&#xA;&#xA;int Serial_Status=0;&#xA;&#xA;&#xA;&#xA;&#xA;int array[8][3] = {&#xA;  {&#xA;    0, 0, 0&#xA;  }&#xA;  , {&#xA;    0, 0, 1&#xA;  }&#xA;  , {&#xA;    0, 1, 0&#xA;  }&#xA;  , {&#xA;    0, 1, 1&#xA;  }&#xA;  , {&#xA;    1, 0, 0&#xA;  }&#xA;  , {&#xA;    1, 0, 1&#xA;  }&#xA;  , {&#xA;    1, 1, 0&#xA;  }&#xA;  , {&#xA;    1, 1, 1&#xA;  }&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastActivityDate="2016-06-06T12:59:11.017" Title="Storing integer into character buffer" Tags="|arduino-uno|serial|c|array|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24924" PostTypeId="2" ParentId="24923" CreationDate="2016-06-06T11:54:23.927" Score="3" Body="&lt;p&gt;The simple answer is: don't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the moment you are trying to assign integers to chars, and that just won't fit. It's like a round peg in a square hole. Or more like trying to force a bowling pin through a hose pipe. It just isn't going to fit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you either need to &quot;print&quot; the values into your final string (say with &lt;code&gt;sprintf()&lt;/code&gt;) or just don't build up a string at all and print the values directly. And while you're at it, use some loops to make your code simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 14; i++) {&#xA;    Serial.print(Mod_current[i]);&#xA;    Serial.print(&quot;,&quot;);&#xA;}&#xA;&#xA;for (int i = 23; i &amp;gt; 13; i--) {&#xA;    Serial.print(Mod_current[i]);&#xA;    Serial.print(&quot;,&quot;);&#xA;}&#xA;&#xA;Serial.print(Temp_read);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.print(HV_Read);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.print(SPD);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.println(DISCONNECTOR);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you really need to create a string the easiest way is probably with &lt;code&gt;sprintf&lt;/code&gt; (or &lt;code&gt;snprintf&lt;/code&gt; to prevent buffer overflows):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char sendBuffer[200]; // Enough room for 28 integers of 1-5 characters, plus commas.&#xA;&#xA;snprintf(sendBuffer, 200, &quot;%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d&quot;,&#xA;    Mod_current[0], Mod_current[1], Mod_current[2], Mod_current[3],&#xA;    Mod_current[4], Mod_current[5], Mod_current[6], Mod_current[7],&#xA;    Mod_current[8], Mod_current[9], Mod_current[10], Mod_current[11],&#xA;    Mod_current[12], Mod_current[13], Mod_current[14], Mod_current[23],&#xA;    Mod_current[22], Mod_current[21], Mod_current[20], Mod_current[19],&#xA;    Mod_current[18], Mod_current[17], Mod_current[16], Mod_current[15],&#xA;    Mod_current[14], Temp_read, HV_Read, SPD, DISCONNECTOR);&#xA;&#xA;int len = strlen(sendBuffer);&#xA;Serial.println(sendBuffer);&#xA;Serial.print(len);&#xA;Serial.println(&quot; bytes&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(note: I think I got the right number of parameters there)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-06T12:09:44.930" LastActivityDate="2016-06-06T12:09:44.930" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24928" PostTypeId="1" AcceptedAnswerId="24929" CreationDate="2016-06-06T14:27:19.457" Score="0" ViewCount="1469" Body="&lt;p&gt;How can I fix this sketch to make it so that once the button is pressed, it performs some action for a certain amount of time and then returns back to a low state until it is pressed again. For example, I need to run a pump for 5 seconds when the button is pressed and then turn off automatically. And then, when I press the button again it will repeat, etc. I am not trying to use a relay module if it is not necessary. Here is my current sketch and a Lab View of the components: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/P3fk0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/P3fk0.png&quot; alt=&quot;My Sketch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;&#xA;int switchPin = 8;&#xA;int ledPin = 13;&#xA;int buttonPresses = 0;&#xA;boolean lastButton = LOW;&#xA;boolean currentButton = LOW;&#xA;boolean ledOn = false;&#xA;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(switchPin, INPUT);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  lcd.begin(16, 2);&#xA;}&#xA;&#xA;boolean debounce(boolean last) //just a debounce function&#xA;{&#xA;  boolean current = digitalRead(switchPin);&#xA;  if (last != current)&#xA;  {&#xA;    delay(5);&#xA;    current = digitalRead(switchPin);&#xA;  }&#xA;  return current;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  {currentButton = debounce(lastButton);&#xA;  if (lastButton == LOW &amp;amp;&amp;amp; currentButton == HIGH)&#xA;  {&#xA;    ledOn = !ledOn;&#xA;&#xA;    buttonPresses++;&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Number of Button &quot;);&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;Presses = &quot;);&#xA;    lcd.print(buttonPresses);  &#xA;  }&#xA;   lastButton = currentButton;&#xA;   digitalWrite(ledPin, ledOn);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;THANK YOU!&lt;/p&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="21627" LastEditDate="2016-06-06T14:56:56.553" LastActivityDate="2016-06-06T15:34:20.597" Title="Button Relay Control" Tags="|arduino-uno|lcd|timers|button|code-review|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24929" PostTypeId="2" ParentId="24928" CreationDate="2016-06-06T14:54:37.577" Score="0" Body="&lt;p&gt;This code should work. You will need to declare the following variables:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;lastPress   // The last time the button was pressed&lt;/li&gt;&#xA;&lt;li&gt;outputState  // The state of the timed output &lt;/li&gt;&#xA;&lt;li&gt;outputPin  // The pin number for the timed output&lt;/li&gt;&#xA;&lt;li&gt;PERIOD  // The amount of time that the outptu remains on&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    currentButton = debounce(lastButton);&#xA;    if (lastButton == LOW &amp;amp;&amp;amp; currentButton == HIGH)&#xA;    {&#xA;        ledOn = !ledOn;&#xA;&#xA;        buttonPresses++;&#xA;        lcd.clear();&#xA;        lcd.print(&quot;Number of Button &quot;);&#xA;        lcd.setCursor(0,1);&#xA;        lcd.print(&quot;Presses = &quot;);&#xA;        lcd.print(buttonPresses);&#xA;&#xA;        outputState = HIGH;&#xA;        lastPress = millis();  &#xA;    }&#xA;&#xA;    if (outputState &amp;amp;&amp;amp; ((millis() - lastPress) &amp;gt; PERIOD))&#xA;    {&#xA;        outputState = LOW;&#xA;    }&#xA;&#xA;    digitalWrite(outputPin, outputState);&#xA;&#xA;    lastButton = currentButton;&#xA;    digitalWrite(ledPin, ledOn);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A relay should be used to drive a pump etc.. The Arduino Uno can only drive 5V at maximum 20mA.&lt;/p&gt;&#xA;" OwnerUserId="19409" LastEditorUserId="19409" LastEditDate="2016-06-06T15:34:20.597" LastActivityDate="2016-06-06T15:34:20.597" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24930" PostTypeId="1" AcceptedAnswerId="24932" CreationDate="2016-06-06T14:30:33.023" Score="0" ViewCount="1733" Body="&lt;p&gt;I'm trying to port some Arduino code that I wrote for the Arduino Mega to an ATtiny and I'm having trouble figuring out how to do output. Here is what I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char foo;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;const int rx=3;&#xA;const int tx=4;&#xA;&#xA;SoftwareSerial mySerial(rx,tx);&#xA;&#xA;void setup() &#xA;{ &#xA;mySerial.begin(9600);&#xA;} &#xA;&#xA;void loop() {&#xA; if (mySerial.available()) {&#xA;   char data = mySerial.read();&#xA;   mySerial.write(data);&#xA; }&#xA;&#xA; mySerial.println(&quot;hello&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To my understanding this should print &quot;hello&quot; to the console over and over again but for some reason it uploads successfully but then it doesn't do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the programmer that I am using to connect my ATtiny to my computer: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/programming-in-arduino&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/programming-in-arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21660" OwnerDisplayName="Fortuna Iwasaki" LastActivityDate="2016-06-06T15:59:46.177" Title="Can an ATtiny print results to a console?" Tags="|attiny|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24931" PostTypeId="2" ParentId="24930" CreationDate="2016-06-06T14:38:41.677" Score="0" Body="&lt;p&gt;This is writing serial data to digital pin 4. If you have a serial to USB converter attached to pins 3,4 and you have a terminal attached to said serial to USB converter, it will print to that terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, on an ATtiny, you have to check which pins are pins 3,4. They are probably not the physical pins 3,4, and it is dependent on which pin mappings you are using (dependent on ATtiny libraries).&lt;/p&gt;&#xA;" OwnerUserId="16988" OwnerDisplayName="uint128_t" LastActivityDate="2016-06-06T14:38:41.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24932" PostTypeId="2" ParentId="24930" CreationDate="2016-06-06T14:51:44.513" Score="3" Body="&lt;p&gt;You don't have any output because you don't have a serial adapter connected to the device. The programmer you have is only for programming and does not support a UART serial connection.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-06-06T14:51:44.513" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="24933" PostTypeId="1" CreationDate="2016-06-03T17:34:18.263" Score="1" ViewCount="1882" Body="&lt;p&gt;I have a fan control circuit with Arduino (PWM). I did all things and it worked. My question is why we did not directly connect the fan to Arduino. Why should we have a driver circuit?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/Oa8rY.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;&#xA;" OwnerDisplayName="nixieh s" LastEditorUserId="26916" LastEditDate="2017-09-08T09:33:11.677" LastActivityDate="2017-11-18T00:38:57.150" Title="Fan control circuit with Arduino" Tags="|arduino-uno|pwm|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24934" PostTypeId="2" ParentId="24933" CreationDate="2016-06-04T15:32:53.817" Score="2" Body="&lt;p&gt;This is an electronics question, and it should be forwarded to the electronics stackexchange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fan needs to have a proper amount of current to spin, and because the microcontroller that controls the fan draw very little current on its output pins (check the datasheet for the exact value, but it should be a few milliamps), unless you have a miniature fan, wiring it directly on the microcontroller will not be able to move the fan.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is by design that microcontrollers cannot provide much current. Because to provide larger amount of current than what they do, they'd need to have bigger copper tracks between the transistor to avoid having they internal circuits building too much heat, and they would be much much bigger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as a work around, we use an transistor, which receives on the &quot;Base&quot; pin a voltage, drawing almost no current, which will &quot;connect&quot; the collector and emitter pins where you can have a much bigger current flowing (though be careful to respect the datasheet's nominal values for current! Or use either a MOSFET, a Triac or a Relay for bigger currents).&lt;/p&gt;&#xA;" OwnerUserId="379" OwnerDisplayName="zmo" LastActivityDate="2016-06-04T15:32:53.817" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24935" PostTypeId="2" ParentId="24933" CreationDate="2016-06-04T16:13:44.113" Score="1" Body="&lt;p&gt;Arduino is a low voltage and low current device. Arduino max current output delivery capecity is 200ma, you can read about diffrent arduino's limitations here,&#xA;&lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Fan or anything that&lt;/strong&gt; has a coil inside it, needs a huge amount of current during their start up. The current draw decreases as it gains its motion to some limit. The initial huge current is called &lt;strong&gt;surge current&lt;/strong&gt;. There is a high chance that it will blow you pins dead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let's say we are using really small fan. And it managed to start and rotating, that dosen't meant there is no problem at all. When a coil is rotated inside a magnetic field an opposite voltage is induced called &lt;strong&gt;Back Emf&lt;/strong&gt; . This is &lt;strong&gt;another&lt;/strong&gt; huge &lt;strong&gt;potential concern&lt;/strong&gt;. This is why we are always suggested to use a &lt;strong&gt;diode&lt;/strong&gt; which will &lt;strong&gt;block&lt;/strong&gt; the opposite flow of &lt;strong&gt;current&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Transistor&lt;/strong&gt;, being a low voltage device and as it can deliver tremendous large amount of output current, It is very widely used to drive high current devices&lt;/p&gt;&#xA;" OwnerUserId="16098" OwnerDisplayName="Ccr" LastActivityDate="2016-06-04T16:13:44.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24937" PostTypeId="1" CreationDate="2016-06-06T17:09:44.373" Score="0" ViewCount="1263" Body="&lt;p&gt;I have been working on this a while and I cannot seem to figure it out. Essentially, I am using the app/server Blynk and their Terminal Widget to sent String inputs to my Arduino board. My code is below:&#xA;&lt;code&gt;&#xA;  String INFO;&#xA;  String fromTerminal = param.asStr();&#xA;  int indexstart = fromTerminal.indexOf(&quot;,&quot;);&#xA;  int indexend = fromTerminal.lastIndexOf(&quot;,&quot;);&#xA;  int counter = indexstart - indexend;&#xA;  INFO[counter] = fromTerminal;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thoughts on the code was, based on the number of &quot;,&quot; I enter in the string then that will assign my input to an index within the INFO array. However as I have tried several different things, I constantly get errors such as:&#xA;cannot convert 'String' to 'char' in assignment.&#xA;Oddly enough if I set: INFO[counter] = fromTerminal.toInt();&#xA;I dont get an error but I dont think that will allow me to print out my actual input. Any help is much appreciated, thanks!&lt;/p&gt;&#xA;" OwnerUserId="22755" LastActivityDate="2022-02-27T21:08:00.727" Title="Add string inputs into an array" Tags="|array|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24938" PostTypeId="2" ParentId="8671" CreationDate="2016-06-06T18:21:59.470" Score="1" Body="&lt;p&gt;I know this thread may be dead but if it happens to somebody, the aformentioned method works perfectly fine. You just need to disable timer0 (power_timer0_disable();) and then your 40kHz signal will not fluctuate (in frequency). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, yeah try to avoid digitalWrite if you want speed.&lt;/p&gt;&#xA;" OwnerUserId="22757" LastActivityDate="2016-06-06T18:21:59.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24939" PostTypeId="1" AcceptedAnswerId="24946" CreationDate="2016-06-06T18:54:27.827" Score="2" ViewCount="3360" Body="&lt;p&gt;&lt;code&gt;Serial.parseInt()&lt;/code&gt; reads from the serial buffer until it sees a non-numeric character or it's timeout is reached. When I use it, I put a space after the last number to make it return faster. Can I change the timeout so if I forget the number it doesn't take as long?&lt;/p&gt;&#xA;" OwnerUserId="17310" LastActivityDate="2016-06-07T00:00:45.897" Title="Change timeout of `Serial.parseInt()`?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24940" PostTypeId="2" ParentId="24939" CreationDate="2016-06-06T18:59:44.897" Score="2" Body="&lt;p&gt;Don't use &lt;code&gt;Serial.parseInt()&lt;/code&gt;. It is very very wrong. The whole idea behind how it operates is completely wrong and teaches bad practices and methods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Part of your way of speeding it up is half-way to doing it properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You require a delimiter to say &quot;this is the end of the number&quot;. Relying on time in a system that is inherently asynchronous is just plain daft. You have chosen to add a space. A better choice is to use a proper line ending &quot;\n&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you should either read the serial character-by-character and parse it as it arrives until you find the EOL character, or read it character by character into a string (NOT a String, a &quot;string&quot; - a C string - a character array terminated by a NULL character), and then use &lt;code&gt;atoi()&lt;/code&gt; etc to convert it to the numerical format you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many of the methods that Arduino provide are not suitable for professional use and should be avoided at all cost lest they teach you the completely wrong way of doing things.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-06T18:59:44.897" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24944" PostTypeId="1" AcceptedAnswerId="24945" CreationDate="2016-06-06T21:30:28.050" Score="0" ViewCount="295" Body="&lt;p&gt;I am a complete newbie to Arduino and I just received an ARDX arduino starter kit (the one that comes in the transparent green case)&#xA;I have been following the instructions for Circ-01 for the blinking led light but I am curious about the wires. In the breadboard instructional picture it shows a purple wire that is supposed to connect to pin 13 on the arduino. But the kit did not come with a purple wire, it only came with black, red, white, yellow, and green wires. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried following a tutorial on YouTube and the guy in the video used a purple wire that he said was the led &quot;cathode&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can i substitute another wire for the purple and? Or did I receive an incomplete kit? I am very confused and the breadboard instruction picture is not very clear. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help!&lt;/p&gt;&#xA;" OwnerUserId="22762" LastActivityDate="2016-06-06T22:47:04.017" Title="Arduino wire question" Tags="|arduino-uno|led|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24945" PostTypeId="2" ParentId="24944" CreationDate="2016-06-06T22:47:04.017" Score="2" Body="&lt;p&gt;Personally I like to try to use red wires for +5V, black or blue for ground, and yellow for data. However as Majenko said in a comment, the colour is irrelevant to the operation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The usefulness of colour is just that if you stick to a system (like red for +5V and black for ground) then there is a visual check you make when connecting up a circuit, so you don't accidentally put things in backwards, like you might if every wire is yellow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, if you run half-a-dozen wires from one place to another, using different colours is another way of making it easier to see you have connected the correct things together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said all that, the colour does not otherwise affect things.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-06T22:47:04.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24946" PostTypeId="2" ParentId="24939" CreationDate="2016-06-07T00:00:45.897" Score="3" Body="&lt;p&gt;You can, just call &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.setTimeout(millisecondValue);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Serial/SetTimeout&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Serial/SetTimeout&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It defaults to one second, and controls the timeouts for readBytes, readBytesUntil, parseInt and parseFloat.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-06-07T00:00:45.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24947" PostTypeId="1" AcceptedAnswerId="25170" CreationDate="2016-06-07T02:15:34.253" Score="0" ViewCount="943" Body="&lt;p&gt;I'm trying to make an OO state machine based program to play music and lights at the same time. It uses the FastLED library and a 13 pixel neopixel strip.  I've confirmed that with the currently wired setup that I can separately play music and also separately run the FastLED Cylon example code. However when I upload the code below it just kinda hangs out and doesn't do anything and doesn't even print the statements in the setup statement.  The weird thing is that if I comment out the Lights lightstrip1() instantiation line and the lightstrip.Update() line, it does play the melody part ok.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;pitches.h&quot;&#xA;#include &quot;FastLED.h&quot;&#xA;&#xA;class Melody{&#xA;&#xA;// notes in the melody Minuet in G.&#xA;int melody[126] = {&#xA;  NOTE_D4, NOTE_G3, NOTE_A3, NOTE_B3, NOTE_C4, &#xA;  NOTE_D4, NOTE_G3, NOTE_G3, &#xA;  NOTE_E4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_FS4,&#xA;  NOTE_G4, NOTE_G3, NOTE_G3,&#xA;&#xA;  NOTE_C4, NOTE_D4, NOTE_C4, NOTE_B3, NOTE_A3,&#xA;  NOTE_B3, NOTE_C4, NOTE_B3, NOTE_A3, NOTE_G3,&#xA;  NOTE_FS3,NOTE_G3, NOTE_A3, NOTE_B3, NOTE_G3,&#xA;  NOTE_A3,&#xA;&#xA;  NOTE_D4, NOTE_G3, NOTE_A3, NOTE_B3, NOTE_C4, &#xA;  NOTE_D4, NOTE_G3, NOTE_G3, &#xA;  NOTE_E4, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_FS4,&#xA;  NOTE_G4, NOTE_G3, NOTE_G3,&#xA;&#xA;  NOTE_C4, NOTE_D4, NOTE_C4, NOTE_B3, NOTE_A3,&#xA;  NOTE_B3, NOTE_C4, NOTE_B3, NOTE_A3, NOTE_G3,&#xA;  NOTE_A3, NOTE_B3, NOTE_A3, NOTE_G3, NOTE_FS3,&#xA;  NOTE_G3,&#xA;&#xA; // Second part&#xA;  NOTE_B4, NOTE_G4, NOTE_A4, NOTE_B4, NOTE_G4,&#xA;  NOTE_A4, NOTE_D4, NOTE_E4, NOTE_FS4, NOTE_D4,&#xA;  NOTE_G4, NOTE_E4, NOTE_FS4, NOTE_G4, NOTE_D4,&#xA;  NOTE_CS4, NOTE_B3, NOTE_CS4, NOTE_A3,&#xA;  NOTE_A3, NOTE_B3, NOTE_CS4, NOTE_D4, NOTE_E4, NOTE_FS4,&#xA;  NOTE_G4, NOTE_FS4, NOTE_E4,&#xA;  NOTE_FS4, NOTE_A3, NOTE_CS4,&#xA;  NOTE_D4,&#xA;&#xA;  // BACK TO G MAJOR!!!!&#xA;  NOTE_D4, NOTE_G3, NOTE_FS3, NOTE_G3,&#xA;  NOTE_E4, NOTE_G3, NOTE_FS3, NOTE_G3,&#xA;  NOTE_D4, NOTE_C4, NOTE_B3,&#xA;  NOTE_A3, NOTE_G3, NOTE_FS3, NOTE_G3, NOTE_A3,&#xA;  NOTE_D3, NOTE_E3, NOTE_FS3, NOTE_G3, NOTE_A3, NOTE_B3,&#xA;  NOTE_C4, NOTE_B3, NOTE_A3,&#xA;  NOTE_B3, NOTE_D4, NOTE_G3, NOTE_FS3,&#xA;  NOTE_G3&#xA;&#xA;&#xA;&#xA;  };&#xA;&#xA;// note durations: 4 = quarter note, 8 = eighth note, etc.:&#xA;float noteDurations[126] = {&#xA;  4, 8,8,8,8,&#xA;  4, 4, 4,&#xA;  4, 8,8,8,8,&#xA;  4, 4, 4,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  1.5,&#xA;&#xA;  4, 8,8,8,8,&#xA;  4, 4, 4,&#xA;  4, 8,8,8,8,&#xA;  4, 4, 4,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  1.5,&#xA;&#xA;  // Second part&#xA;&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8,8,8,&#xA;  4, 8,8, 4,&#xA;  8,8,8,8,8,8,&#xA;  4, 4, 4,&#xA;  4, 4, 4,&#xA;  1.5,&#xA;  4, 8,8, 4,&#xA;  4, 8,8, 4,&#xA;  4, 4, 4,&#xA;  8,8,8,8, 4,&#xA;  8,8,8,8,8,8,&#xA;  4,4,4,&#xA;  8,8,4,4,&#xA;  1.5&#xA;  };&#xA;&#xA;&#xA;  unsigned long OnTime;  // This will be the time in millis to turn on a note.&#xA;  unsigned long OffTime; // This will be the time in millis to turn off a note.&#xA;&#xA;  int ToneState;&#xA;  unsigned long previousMillis;&#xA;&#xA;  int speakerPin;&#xA;  int noteNumber;&#xA;  int maxNoteNumber;&#xA;&#xA;  public:&#xA;  Melody(int pin) {&#xA;     speakerPin = pin;&#xA;     pinMode(speakerPin, OUTPUT);&#xA;     previousMillis = 0;  &#xA;     OnTime = previousMillis;&#xA;     ToneState = 0; // Off&#xA;     noteNumber = 0; // Start at the first note.&#xA;//     maxNoteNumber = sizeof(noteDurations); // This turns out to 504 for some reason.&#xA;     maxNoteNumber = 125;&#xA;&#xA;  }&#xA;&#xA;&#xA;  void Update() {&#xA;     unsigned long currentMillis = millis();&#xA;&#xA;     if (ToneState == 0 &amp;amp;&amp;amp; currentMillis &amp;gt;= OnTime) {&#xA;       tone(speakerPin, melody[noteNumber]);&#xA;       OffTime = currentMillis + (1000 / noteDurations[noteNumber]);&#xA;       ToneState = 1;&#xA;       Serial.print(noteNumber);&#xA;       Serial.print(&quot;/&quot;);&#xA;       Serial.println(maxNoteNumber);&#xA;&#xA;     } else if (ToneState == 1 &amp;amp;&amp;amp; currentMillis &amp;gt;= OffTime) {&#xA;       noTone(speakerPin);&#xA;       OnTime = currentMillis + ((1000 / noteDurations[noteNumber]) * 0.30);&#xA;       ToneState = 0;&#xA;       if (noteNumber &amp;lt; maxNoteNumber) {&#xA;         noteNumber += 1;&#xA;       } else {&#xA;         Serial.println(&quot;RESET&quot;);&#xA;         noteNumber = 0; // Reset to the begining of the song.&#xA;       }&#xA;     } &#xA;  }&#xA;};&#xA;&#xA;class Lights {&#xA;    int ledPin;&#xA;        int ledCount;&#xA;    unsigned long NextOn;&#xA;        int led_R;&#xA;        int led_G;&#xA;        int led_B;&#xA;&#xA;        CRGB leds[12];&#xA;&#xA;    int ledOn;&#xA;        int lightdelay;&#xA;&#xA;    public:&#xA;    Lights(int pin, int ledcount, int led_r, int led_g, int led_b) {&#xA;      ledPin = pin;&#xA;      pinMode(ledPin, OUTPUT);&#xA;      digitalWrite(ledPin, LOW);&#xA;      ledCount = ledcount;&#xA;      led_R = led_r;&#xA;      led_G = led_g;&#xA;      led_B = led_b;&#xA;      ledOn = 0;&#xA;      lightdelay = 100;&#xA;      NextOn = 0;&#xA;      FastLED.addLeds&amp;lt;NEOPIXEL, 7&amp;gt;(leds, ledCount); // It complains if I try to use a variable for the 7. It has to be a constant.&#xA;      for (int i = 0; i &amp;lt; ledCount; i++) {&#xA;        leds[i] = CRGB::White;&#xA;      }&#xA;      FastLED.show();&#xA;    }&#xA;&#xA;    void Update() {&#xA;      unsigned long currentMillis2 = millis();&#xA;&#xA;      if (currentMillis2 &amp;gt; NextOn) {&#xA;         if (ledOn &amp;gt;= ledCount) {&#xA;           leds[ledOn] = CRGB::Black;&#xA;           ledOn = 0;&#xA;           leds[ledOn] = CRGB::Red;&#xA;         } else if (ledOn == 0) {&#xA;           leds[ledCount - 1] = CRGB::Black;&#xA;           leds[ledOn] = CRGB::Red; // Need to put RGB to HSV converter in later.&#xA;         } else {&#xA;           leds[ledOn - 1] = CRGB::Black;&#xA;           leds[ledOn] = CRGB::Red; // Need to put RGB to HSV converter in later.&#xA;         }&#xA;         Serial.print(&quot;LED: &quot;);&#xA;         Serial.println(ledOn);&#xA;         Serial.println(NextOn);&#xA;         FastLED.show();&#xA;         NextOn = currentMillis2 + lightdelay;&#xA;         ledOn++;&#xA;      } &#xA;    }&#xA;&#xA;};&#xA;&#xA;&#xA;Melody melody1(2);&#xA;&#xA;Lights lightstrip1(7, 12, 250, 0, 0);&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Started&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;   melody1.Update();&#xA;   lightstrip1.Update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="2830" LastEditorUserId="2830" LastEditDate="2016-06-09T11:14:47.267" LastActivityDate="2016-06-13T10:25:30.990" Title="Can't play melody and FastLED lights at same time" Tags="|led|class|sound|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="24952" PostTypeId="1" CreationDate="2016-06-07T06:03:35.653" Score="2" ViewCount="74" Body="&lt;p&gt;I am working on arduino Uno board.I am trying to send request Serially from out Side using docklight.I am sending COmmand  is request send every 5S to 10S and get response.When i tested this code with arduino Uno board its working fine. When i tested same code with Customised board whos schematic as below&#xA;&lt;a href=&quot;https://i.stack.imgur.com/shBjT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/shBjT.jpg&quot; alt=&quot;Schemactic&quot;&gt;&lt;/a&gt;. For this i got response like this. I am suspecting it might be issue with crystal. I have replace KDS16 with SCTF16.00crystals . It behave same.Can someone suggest what might be wrong&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yjF0a.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yjF0a.jpg&quot; alt=&quot;Respose&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/iFb0I.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/iFb0I.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;glob.h&quot;&#xA;const int BUFFER_SZ = 32;&#xA;char sendBuffer[200]; &#xA;static int OverRide=0;&#xA;&#xA;void Take_Reading() {&#xA;&#xA;  for (int row = 0; row &amp;lt; 8; row++)&#xA;  {&#xA;    //   // get rid of me:&#xA;    digitalWrite(SO_enable, array[row][0]);&#xA;    digitalWrite(S1_enable, array[row][1]);&#xA;    digitalWrite(S2_enable, array[row][2]);&#xA;    delay(50);&#xA;    analog_1_pv[row] = ANALOG_SCALING * analogRead(A0);&#xA;    analog_2_pv[row] = ANALOG_SCALING * analogRead(A1);&#xA;    analog_3_pv[row] = ANALOG_SCALING * analogRead(A2);&#xA;    if ( (analog_1_pv[row] &amp;lt;= MINV_RANGE || (analog_1_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value1[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value1[row] =  (analog_1_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;    if (  (analog_2_pv[row] &amp;lt;= MINV_RANGE || (analog_2_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value2[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value2[row] =  (analog_2_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;    if (  (analog_3_pv[row] &amp;lt;= MINV_RANGE || (analog_3_pv[row] &amp;gt;= MAXV_RANGE) ))&#xA;    {&#xA;      Current_Value3[row] =  0.0;&#xA;    }&#xA;    else&#xA;    {&#xA;      Current_Value3[row] =  (analog_3_pv[row] * 12.5) - 31.25;&#xA;&#xA;    }&#xA;&#xA;&#xA;    Mod_current[row] = (uint16_t)(Mul_Factor * Current_Value1[row]);&#xA;    Mod_current[row + 8] = (uint16_t)(Mul_Factor * Current_Value2[row]);&#xA;    Mod_current[row + 16] = (uint16_t)(Mul_Factor * Current_Value3[row]);&#xA;&#xA;&#xA;  }&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;int ID_Check() {&#xA;&#xA;  int ID_value;&#xA;  for (int row = 0; row &amp;lt; 8; row++)&#xA;  {&#xA;    digitalWrite(SO_enable, array[row][0]);&#xA;    digitalWrite(S1_enable, array[row][1]);&#xA;    digitalWrite(S2_enable, array[row][2]);&#xA;    Status_Out[row] = digitalRead(Output_Read);&#xA;&#xA;  }&#xA;&#xA;  ID_value = 1 * Status_Out[7] + 2 * Status_Out[6] + 4 * Status_Out[5] + 8 * Status_Out[4] + 16 * Status_Out[3] + 32 * Status_Out[2] + 64 * Status_Out[1] + 128 * Status_Out[0];&#xA;  return (ID_value);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;int  Take_Temp_Reading()&#xA;{&#xA;&#xA;  Temp_Total = Temp_Total - Temp_readings[Temp_index];&#xA;  Temp_readings[Temp_index] = analogRead(A5);&#xA;  Temp_Total = Temp_Total + Temp_readings[Temp_index];&#xA;  Temp_index = Temp_index + 1;&#xA;&#xA;  if (Temp_index &amp;gt;= numReadings)&#xA;  {&#xA;    Temp_index = 0;&#xA;    Temp_Average = Temp_Total / numReadings;&#xA;  }&#xA;  temp = (Temp_Average * 5.0) / 1023.0;&#xA;&#xA;&#xA;  //  temp = float(analogRead(A5)) * 5.0 / 1024.0;&#xA;  temp_int = (int)(temp * 100.0);&#xA;  return (temp_int);&#xA;  // Serial.print(&quot;Temp&quot;); Serial.println(temp);&#xA;}&#xA;&#xA;int SPD_Check()&#xA;{&#xA;&#xA;  SPD_STATUS = digitalRead(SPD_STATUS_PIN);&#xA;  return (SPD_STATUS);&#xA;}&#xA;&#xA;int  DC_Status()&#xA;{&#xA;&#xA;  DC_STATUS = digitalRead(DC_STATUS_PIN);&#xA;  return (DC_STATUS);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;int   Take_HV_Reading()&#xA;{&#xA;&#xA;  //int analog_int= analogRead(A4);&#xA;&#xA;  total = total - readings[index];&#xA;  // read from the sensor:&#xA;  readings[index] = analogRead(A4);&#xA;  // add the reading to the total:&#xA;  total = total + readings[index];&#xA;  // advance to the next position in the array:&#xA;  index = index + 1;&#xA;&#xA;  // if we're at the end of the array...&#xA;  if (index &amp;gt;= numReadings1)&#xA;  {&#xA;    index = 0;&#xA;    average = total / numReadings1;&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;&#xA;    HV_voltage = (average * 5.0) / 1023.0;&#xA;  }&#xA;  if (HV_voltage &amp;lt;= 0.25)&#xA;  {&#xA;&#xA;    Conv_HV_voltage = 0.0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Conv_HV_voltage = 197.837837838 * HV_voltage + 10.8108108108;&#xA;  }&#xA;&#xA;  HV_Reading = (uint16_t)(Conv_HV_voltage * 10);&#xA;&#xA;  //  HV_Reading = (uint16_t)(Conv_HV_voltage * 10);&#xA;&#xA;  return(HV_Reading);&#xA;}&#xA;&#xA;&#xA;void  Serial_Command1()&#xA;&#xA;{&#xA;  Take_Reading();&#xA;  int Temp_read=Take_Temp_Reading();&#xA;  int HV_Read=Take_HV_Reading();&#xA;  SPD=SPD_Check();&#xA;  DISCONNECTOR=DC_Status();&#xA;  // Device_ID=ID_Check();&#xA;  Device_ID=1;&#xA;  Serial.print(&quot;SMCB1&quot;);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(Device_ID);&#xA;  Serial.print(&quot;,&quot;);&#xA;  for (int i = 0; i &amp;lt; 14; i++) {&#xA;    Serial.print(Mod_current[i]);&#xA;    Serial.print(&quot;,&quot;);&#xA;  }&#xA;&#xA;  for (int i = 23; i &amp;gt; 13; i--) {&#xA;    Serial.print(Mod_current[i]);&#xA;    Serial.print(&quot;,&quot;);&#xA;  }&#xA;&#xA;  Serial.print(Temp_read);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(HV_Read);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(SPD);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(DISCONNECTOR);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.print(DISCONNECTOR);&#xA;  Serial.print(&quot;,&quot;);&#xA;  Serial.println(&quot;END&quot;);&#xA;}&#xA;&#xA;void Serial_Command2(int a)&#xA;{&#xA;  Take_Reading();&#xA;  int Temp_read=Take_Temp_Reading();&#xA;  int HV_Read=Take_HV_Reading();&#xA;  SPD=SPD_Check();&#xA;  DISCONNECTOR=DC_Status();&#xA;  Device_ID=1;&#xA;  // Serial.print(&quot;Command2 executed: &quot;);&#xA;  snprintf(sendBuffer, a, &quot;SMCB1,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ,END&quot;,Device_ID,&#xA;  Mod_current[0], Mod_current[1], Mod_current[2], Mod_current[3],&#xA;  Mod_current[4], Mod_current[5], Mod_current[6], Mod_current[7],&#xA;  Mod_current[8], Mod_current[9], Mod_current[10], Mod_current[11],&#xA;  Mod_current[12], Mod_current[13], Mod_current[14], Mod_current[23],&#xA;  Mod_current[22], Mod_current[21], Mod_current[20], Mod_current[19],&#xA;  Mod_current[18], Mod_current[17], Mod_current[16], Mod_current[15],&#xA;  Mod_current[14], Temp_read, HV_Read, SPD, DISCONNECTOR);&#xA;  Serial.println(sendBuffer);&#xA;  //Serial.println(a);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(57600);&#xA;  Serial.println(&quot;Format 1: &amp;lt;SMCB1,1&amp;gt;&quot;);&#xA;  Serial.println(&quot;Format 2: &amp;lt;SMCB1,1,Length&amp;gt;&quot;);&#xA;  Serial.println(&quot;Format 2: &amp;lt;SMCB1,1,Length,ON&amp;gt; ON- turn on timer ,off to turn off timer&quot;);&#xA;}&#xA;&#xA;// Parse the request, WITHOUT the '&amp;lt;' and '&amp;gt;' delimiters.&#xA;void parseRequest(char *request)&#xA;{&#xA;  // Check the request starts with the prefix &quot;SMCB1,1&quot;.&#xA;  if (strncmp(request, &quot;SMCB1,1&quot;, 7) != 0) {&#xA;    Serial.println(F(&quot;Error: bad request prefix&quot;));&#xA;   //  Serial_Command1();&#xA;    return;&#xA;  }&#xA;&#xA;  // Remove that known prefix.&#xA;  // Now we have either &quot;&quot;, &quot;,Length&quot; or &quot;,Timer,On_OFF&quot;&#xA;  request += 7;&#xA;&#xA;  // Format 1: &quot;&quot;&#xA;  if (request[0] == '\0') {&#xA;    //Serial.println(F(&quot;Received format 1&quot;));&#xA;    Serial_Command1();&#xA;    return;&#xA;  }&#xA;&#xA;  // Remove the leading comma.&#xA;  // Now we have either &quot;Length&quot; or &quot;Timer,On_OFF&quot;&#xA;  if (request[0] != ',') {&#xA;    Serial.println(F(&quot;Error: ',' expected&quot;));&#xA;    return;&#xA;  }&#xA;  request++;&#xA;&#xA;  // Format 2: &quot;Length&quot;, no comma.&#xA;  char * comma = strchr(request, ',');&#xA;  if (!comma) {&#xA;&#xA;    int length = atoi(request);&#xA;    Serial_Command2(length);&#xA;    //Serial.print(F(&quot;Received format 2, length = &quot;));&#xA;    // Serial.println(length);&#xA;    return;&#xA;  }&#xA;&#xA;  // format 3&#xA;  int timer = atoi(request);&#xA;  char * on_off = comma + 1;&#xA;  char * Compare=&quot;ON&quot;;&#xA;  bool on = strcmp(on_off, &quot;ON&quot;) == 0;&#xA;  if (!on &amp;amp;&amp;amp; strcmp(on_off, &quot;OFF&quot;) != 0) {  // sanity check&#xA;    Serial.println(F(&quot;Error: expected either ON or OFF&quot;));&#xA;    return;&#xA;  }&#xA;  /*  Serial.print(F(&quot;Received format 3, timer = &quot;));&#xA;   Serial.print(timer);&#xA;   Serial.print(F(&quot;, on_off = &quot;));&#xA;   Serial.println(on ? &quot;ON&quot; : &quot;OFF&quot;);&#xA;   Serial.println(on_off);&#xA;   Serial.println(Compare);*/&#xA;  int v = strcmp(on_off, Compare);&#xA;  if(v==0)&#xA;  {&#xA;    Serial.println(&quot;Timer is on&quot;);&#xA;    OverRide=1;&#xA;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;Timer is OFF&quot;);&#xA;    OverRide=0;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  static char buffer[BUFFER_SZ];  // received chars&#xA;  static size_t pos;              // current position in buffer&#xA;  static bool insideRequest;      // are we between '&amp;lt;' and '&amp;gt;'?&#xA;&#xA;  if (Serial.available()) {&#xA;    char c = Serial.read();&#xA;    if (insideRequest) {&#xA;      if (c == '&amp;gt;') {  // end of request received&#xA;        buffer[pos] = '\0';  // terminate the string&#xA;        parseRequest(buffer);&#xA;        pos = 0;             // get ready for the next request&#xA;        insideRequest = false;&#xA;      }&#xA;      else if (pos &amp;lt; BUFFER_SZ-1) {  // add char to buffer&#xA;        buffer[pos++] = c;&#xA;      }&#xA;    }&#xA;    else if (c == '&amp;lt;') {  // start of request&#xA;      insideRequest = true;&#xA;    }&#xA;&#xA;&#xA;&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="904" LastEditDate="2016-06-07T12:49:11.273" LastActivityDate="2016-06-07T12:49:11.273" Title="Serial Request error" Tags="|arduino-uno|serial|c|hardware|oscillator-clock|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24954" PostTypeId="2" ParentId="18647" CreationDate="2016-06-07T08:20:46.773" Score="0" Body="&lt;p&gt;Stumbled on good tutorial here, tried and it does the job:&#xA;&lt;a href=&quot;https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/&quot; rel=&quot;nofollow&quot;&gt;https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22774" LastActivityDate="2016-06-07T08:20:46.773" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24956" PostTypeId="2" ParentId="18647" CreationDate="2016-06-07T12:22:19.470" Score="0" Body="&lt;p&gt;Yes, if you are using different power sources the grounds always have to be connected, otherwise the boards don't know what zero volts is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX of the Arduino is 5v, you need a level shifter to convert 5v to 3.3v, something like this (&lt;a href=&quot;https://shop.pimoroni.com/products/adafruit-4-channel-i2c-safe-bi-directional-logic-level-converter?utm_medium=cpc&amp;amp;utm_source=googlepla&amp;amp;variant=302017581&amp;amp;gclid=CPqujsPxlc0CFcYcGwodb8YIoA&quot; rel=&quot;nofollow&quot;&gt;https://shop.pimoroni.com/products/adafruit-4-channel-i2c-safe-bi-directional-logic-level-converter?utm_medium=cpc&amp;amp;utm_source=googlepla&amp;amp;variant=302017581&amp;amp;gclid=CPqujsPxlc0CFcYcGwodb8YIoA&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The TX of the ESP8266 is 3.3v and the RX of the Arduino is 5V and you will need a level shifter to handle this.  You can use the same one as listed above, because it can convert 4 high (5v) signals into 4 low (3.3v) signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People say you can so it with resistors, but I have also read that they don't perform well enough to handle fast switching digital signals (so 300 Baud on your serial might be OK, but not 115000 :) )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People also say you don't need level convertors.  That's true things &lt;em&gt;might&lt;/em&gt; work for a while without them, but sooner or later something will go pop.  Increasing the voltage will speed up the process so you can imagine what will happen if you connected a 230v supply directly to a USB device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One final point, do you know the ESP8266 is a 80/160MHz processor with 256KB of RAM, when you compare that to you Arduino its like programming you PC via your phone.  What you could try is connecting the ESP8266 via a FTDI module and program it via the Arduino IDE in Arduino C.  Its a lot easier than all this connection stuff.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-07T12:22:19.470" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24957" PostTypeId="1" AcceptedAnswerId="24959" CreationDate="2016-06-07T12:48:01.783" Score="0" ViewCount="24838" Body="&lt;p&gt;I'm trying to convert this array &lt;code&gt;uint8_t data[]&lt;/code&gt; in the code below to a character array to be printed in the serial monitor. However, when I run this code I see a blank screen. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(115200);&#xA;uint8_t data[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x00,0x01,0x02,0x03,0x04,0x05};&#xA;Serial.println((char*)data);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21708" LastActivityDate="2016-06-07T13:22:25.290" Title="Converting an array of uint8_t to a char array" Tags="|c|arduino-yun|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24958" PostTypeId="2" ParentId="24947" CreationDate="2016-06-07T13:08:18.177" Score="1" Body="&lt;p&gt;The WS2812 device requires precise timing down to +/- 150 x 10&lt;sup&gt;-9&lt;/sup&gt; seconds.  For details look at &lt;a href=&quot;http://cdn.sparkfun.com/datasheets/Components/LED/WS2812.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; chip specification.  As such, it is likely the FastLED library uses processor resources that can not be shared.  Look through the &lt;a href=&quot;https://github.com/FastLED/FastLED&quot; rel=&quot;nofollow&quot;&gt;FastLED library's code&lt;/a&gt; to verify this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It appears your sketch plays a note, changes the LED pattern then repeats this cycle.  Assuming the resources for FastLED are initialized in the constructor of the library, you might consider destroying and re-instantiating the FastLED class for each of these cycles.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Comments about memory space and large amounts of static data in the sketch have merit.  Consider moving your static (unchanging) data from limited RAM to FLASH memory.  &lt;a href=&quot;https://www.arduino.cc/en/Reference/PROGMEM&quot; rel=&quot;nofollow&quot;&gt;This&lt;/a&gt; resource explains how this is accomplished. &lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-08T02:25:51.890" LastActivityDate="2016-06-08T02:25:51.890" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24959" PostTypeId="2" ParentId="24957" CreationDate="2016-06-07T13:14:48.150" Score="0" Body="&lt;p&gt;When you cast as &lt;code&gt;char *&lt;/code&gt;, &lt;code&gt;println&lt;/code&gt; thinks you are passing it a string. It will try to print it as a string and stop on the first &lt;code&gt;0x00&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use &lt;a href=&quot;https://www.arduino.cc/en/Serial/Write&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Serial.write&lt;/code&gt;&lt;/a&gt; to send the array as integers (no conversion):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.write(data, sizeof(data));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to send the ASCII representation of these numbers, use a loop. &lt;a href=&quot;https://www.arduino.cc/en/Serial/Print&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;Serial.print&lt;/code&gt;&lt;/a&gt; will convert:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int count = sizeof(data) / sizeof(data[0]);&#xA;for (int i = 0; i &amp;lt; count; i++) {&#xA;    Serial.print(data[i]);&#xA;}&#xA;Serial.println();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13425" LastActivityDate="2016-06-07T13:14:48.150" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24960" PostTypeId="2" ParentId="24957" CreationDate="2016-06-07T13:16:16.897" Score="0" Body="&lt;p&gt;To print numbers, integers have to be converted to &lt;a href=&quot;https://en.wikipedia.org/wiki/ASCII&quot; rel=&quot;nofollow&quot;&gt;ASCII&lt;/a&gt; code.  To accomplish this add 0x30 to each value.  Note, this (only) works for numbers between 0 and 9 as the ASCII value for zero is 0x30.  Good code will check to make sure only the values 0 through 9 are being processed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When creating a character string you need to identify the end using the NULL character.  Before using an array of characters, set the array position after the last desired character equal to NULL or 0x00. Terminating the string is explained further in &lt;a href=&quot;https://startingelectronics.org/software/arduino/learn-to-program-course/18-strings/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; article.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-07T13:22:25.290" LastActivityDate="2016-06-07T13:22:25.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24961" PostTypeId="2" ParentId="18647" CreationDate="2016-06-07T13:22:52.723" Score="3" Body="&lt;p&gt;The easiest way to work with these devuces is to connect them to a spare pair of Arduino pins and use SoftwareSerial for communicating (unless you're using one of the Arduinos with more than one UART). SoftwareSerial work up to 9600 baud on 16MHz devices, 4800 on 8MHz devices, so you'll need to set the ESP8266 to accommodate that. They currently ship at 115200 baud. You can use the hardware UART on pins (0, 1) but then re-programming the Arduino means disconnecting &amp;amp; reconnecting the ESP temporarily each time, and gets old pretty quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I do with new ESPs (If you've re-flashed your ESP, you'll need to download the AT instruction-set emulator and re-flash it with that, first):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# To configure a new ESP module:&#xA;# Connect the ESP and the FTDI as in your top diagram, set your&#xA;# terminal-emulator to 115200 baud, and enter the following:&#xA;&#xA;AT                             # ESP should respond &quot;OK&quot;&#xA;AT+RST                         # Resets the ESP&#xA;AT+UART_DEF=9600,8,1,0,0       # Sets ESP UART: 9600,N,8,1,no flow ctl&#xA;&#xA;# Now change the terminal emulator baud rate to 9600&#xA;&#xA;AT+CWMODE=1                    # Set ESP to station mode (client)&#xA;ATE0                           # Set ESP's echo off  &#xA;AT+CWLAP                       # List access points - after a short pause&#xA;                               # the ESP returns a list of WiFi access points&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For future reference, here is a link to the &lt;a href=&quot;https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ESP8266 AT Instruction Set&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update June 2020: The above link was broken, now fixed. You can also find documentation at &lt;a href=&quot;https://github.com/espressif/esp-at/tree/master/docs&quot; rel=&quot;nofollow noreferrer&quot;&gt;Espressif's github account&lt;/a&gt; (online readable, but not pdf, as of this date).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2020-06-02T12:14:06.583" LastActivityDate="2020-06-02T12:14:06.583" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="24963" PostTypeId="1" CreationDate="2016-06-07T15:19:13.237" Score="-1" ViewCount="1437" Body="&lt;p&gt;How can I export the readings that are being sent to my Arduino Mega to a file?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know there is a write() method but I can't find the documentation on how to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want the file to be created and stored on my PC not an SD card. Also I want to know if there is a way to do this without using external programs.&lt;/p&gt;&#xA;" OwnerUserId="22788" LastEditorUserId="22788" LastEditDate="2016-06-07T15:35:22.373" LastActivityDate="2016-06-08T08:08:38.803" Title="How can you export data to a file in Arduino?" Tags="|arduino-mega|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24964" PostTypeId="2" ParentId="24963" CreationDate="2016-06-07T15:31:55.360" Score="0" Body="&lt;p&gt;if your arduino is connected to a computer, you can create a small application that will listen to serial port and write on a file whatever arduino sends over the serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively you can write directly on an sdCard. (There are many sdCard shields available on the market.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the write method, you probably are referring to &lt;a href=&quot;https://www.arduino.cc/en/Reference/FileWrite&quot; rel=&quot;nofollow&quot;&gt;write&lt;/a&gt; method of File class of &lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;SD library&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20645" LastActivityDate="2016-06-07T15:31:55.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24965" PostTypeId="2" ParentId="24963" CreationDate="2016-06-07T15:36:11.523" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I know there is a write() method but I can't find the documentation on how to use it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can use: &lt;code&gt;Serial.write(F(&quot;TEXT&quot;));&lt;/code&gt; to send text over the &quot;serial communication&quot;.&#xA;This basically means that your Arduino will send the text to your PC over the USB emulated COM port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The magnifying glass button at the top-right of your Arduino IDE's screen will open the &quot;Serial Monitor&quot; here you can see the text that's coming from the Arduino, you can even send text back.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I export the readings that are being sent to my Arduino Mega to a file?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You could make your Arduino interface with an SD-card.&#xA;Or use that serial connection I told you about.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could create a program (on the PC) that takes the serial input and stores it into a file. A lot of examples from this should be on the internet.&#xA;Another thing might be, to use a more advanced serial terminal. I believe &quot;terminal.exe&quot; allows &quot;logging&quot; to a file.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-07T15:36:11.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24967" PostTypeId="1" AcceptedAnswerId="24968" CreationDate="2016-06-07T17:54:12.900" Score="-1" ViewCount="55" Body="&lt;p&gt;I intend to design an air pollution monitoring station which will measure these data (CO, NO2, O3, Temperature, Humidity and Pressure). I want to store the data on the SD card during the whole day and deploy it online in CSV format.&#xA;I will have five stations in fixed locations and gather their daily data.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Any suggestions about specific types of sensors (references)?&lt;/li&gt;&#xA;&lt;li&gt;How to store the data as CSV format?&lt;/li&gt;&#xA;&lt;li&gt;How to send the data online at certain time on Arduino? &lt;/li&gt;&#xA;&lt;li&gt;Is it better to use GSM or WiFi? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-06-07T18:30:02.600" Title="Deploy data online from SD Card on Arduino" Tags="|sensors|wireless|datalogging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24968" PostTypeId="2" ParentId="24967" CreationDate="2016-06-07T18:30:02.600" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to store the data as CSV format?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Write the values to the card with commas between them.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile.print(noxValue);&#xA;myFile.print(&quot;,&quot;);&#xA;myFile.print(coValue);&#xA;myFile.print(&quot;,&quot;);&#xA;myFile.println(ozValue);&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to send the data online at certain time on Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to make a suitable network request to whatever unknown thing it is you are sending it to. That may be a HTTP POST request, or it could be some completely different mechanism. Until you have decided where you are sending it we can't help you with the how of sending it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As to the &lt;em&gt;when&lt;/em&gt;, you really could do with a Real Time Clock module so you know what the time is. Then at a certain time you can run your code. Some RTC modules have an alarm that can alert you when it's time to send your code. Great for if your MCU has been placed in a sleep mode and needs waking up at the right time.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it better to use GSM or WiFi?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That depends if you have access to WiFi where the sensor is. If you do, then WiFi is (more often than not) cheaper. If you don't, then WiFi is impossible and GSM is the only option. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-07T18:30:02.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24969" PostTypeId="1" CreationDate="2016-06-07T18:43:51.370" Score="2" ViewCount="813" Body="&lt;p&gt;I'm having trouble with flashing &lt;code&gt;amforth&lt;/code&gt; on my Arduino UNO.&#xA;I'm using an Arduino as ISP to write &lt;code&gt;amforth&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I do:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Upload the code on the Arduino programmer and set Baudrate to 19200&lt;/li&gt;&#xA;&lt;li&gt;Wire the Arduinos this way -&gt; &lt;a href=&quot;https://cdn.sparkfun.com/assets/3/b/d/8/1/523b53bb757b7f01268b456a.jpg&quot; rel=&quot;nofollow&quot;&gt;Wiring&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;avrdude -P /dev/ttyUSB* -c avrisp -b 19200 -p m328p -e -U flash:w:uno.hex:i -U eeprom:w:uno.eep.hex:i -U efuse:w:0x05:m -U hfuse:w:0xD9:m -U lfuse:w:0xFF:m&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sometimes it fails to set efuse,  but if I give the command just for it, even if it says &lt;code&gt;&quot;efuse changed, it was 5, not is 0xfd, do you want to change it back?&quot;&lt;/code&gt; and I say no, I get the message with the correct fuses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I log onto the &lt;code&gt;amforth&lt;/code&gt; Arduino with the python shell, but my stack is constantly &lt;code&gt;??? -13&lt;/code&gt; and different numbers. I found out &lt;code&gt;-13&lt;/code&gt; is error code for &lt;code&gt;not found&lt;/code&gt;, but... not found what?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does it mean? What am I missing?&#xA;&lt;br&gt;&#xA;I have to say that I'm new at this things, I recently studied Forth and discovered that I can use it on my Arduino, and I wanted to try.&#xA;&lt;br&gt;&#xA;By the way, the Arduino is not original.&#xA;&lt;br&gt; The chip is ATmega 328p&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;I downloaded &lt;code&gt;amforth&lt;/code&gt; from &lt;a href=&quot;https://sourceforge.net/projects/amforth/files/amforth/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&#xA;Initially I followed [first guide] (different wiring but I've read around it's the same) and then &quot;clarified my doubts&quot; with another one from sparkfun.&#xA;(no link used because maximum for me is 2 links per post at the moment, I'll write it in the comments)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br&gt;&#xA;I tried with versions &lt;code&gt;6.1&lt;/code&gt; and &lt;code&gt;6.0&lt;/code&gt;, then I decided to try with &lt;code&gt;5.9&lt;/code&gt; (the one from the first guide) and now I'm running that (at least it allows me to pop elements from the stack).&lt;/p&gt;&#xA;" OwnerUserId="21626" LastEditorUserId="653" LastEditDate="2016-06-08T19:00:59.977" LastActivityDate="2017-01-05T06:44:49.487" Title="Amforth on Arduino UNO" Tags="|arduino-uno|arduinoisp|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="24970" PostTypeId="1" AcceptedAnswerId="24971" CreationDate="2016-06-07T19:30:15.000" Score="0" ViewCount="2614" Body="&lt;p&gt;I have an Arduino Uno and an ArduCAM-mini 2MP camera:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arducam.com/tag/arducam-mini/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arducam.com/tag/arducam-mini/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to connect this camera, or similar cameras, to the arduino without a shield?  The only tutorials I've found use a shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit - here is what my cam looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/lXo3j.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lXo3j.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22791" LastEditorUserId="22791" LastEditDate="2016-06-08T15:02:35.680" LastActivityDate="2016-06-08T15:02:35.680" Title="Can I connect a camera without a shield?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="24971" PostTypeId="2" ParentId="24970" CreationDate="2016-06-07T21:40:12.640" Score="3" Body="&lt;p&gt;Judging by the photo (below) it is specifically designed to plug into the SPI ports on a Uno or similar (that is, pins 10 to 13). The other two wires are going to the ICSP header, presumably to pick up +5V and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tbj3W.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tbj3W.jpg&quot; alt=&quot;Arducam&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, most certainly you can use it like that. With the pins done like that it even points horizontally.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It wasn't clear to me that I should bend the camera pins as such (mine has 8 pins pointing downward). &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can buy pins with a 90° angle. If yours are not already soldered on, I would use the bent connector. If the pins are already soldered on, then the camera would lie flat, so just rotate the Arduino itself to point to where you want it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you would need to do something with the +5V and Gnd pins, so that they can be rerouted to the correct place.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Looking at another photo on that site.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/uhPSo.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uhPSo.jpg&quot; alt=&quot;Arducam pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pins would match most of the pins on a Uno, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qheS5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qheS5.png&quot; alt=&quot;Uno pins&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only one that is wrong is AREF - you need +5V into that pin, not AREF, which is why they bent those two pins outwards (+5V and Gnd) and ran wires to the ICSP header.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;If you mean all your pins are at right-angles already, then you really only need to fix the +5V one (you can probably bend it up). This is the pin-out for the ICSP header (view from above):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/V4CIY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/V4CIY.png&quot; alt=&quot;ICSP header&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, you can pick up +5V from pin 2 (Vcc). Alternatively, run the +5 wire over to where +5 is marked on the Uno on the other side.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another possible approach would be to not bend anything, but solder on a wire to the +5V pin and leave it plugged into AREF. AREF is just an input (analog reference voltage) and it won't hurt to have it left at +5V.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-07T21:59:13.427" LastActivityDate="2016-06-07T21:59:13.427" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="24975" PostTypeId="2" ParentId="3688" CreationDate="2016-06-08T01:58:26.083" Score="1" Body="&lt;p&gt;Another option is to look for a hardware (Arduino Clone) that has been designed for that, like this board: &lt;a href=&quot;https://bitbucket.org/talk2/whisper-node-avr/overview&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/talk2/whisper-node-avr/overview&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Combining such hardware with power-saving code techniques you should be able to run projects for quite long time on batteries!&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-08T01:58:26.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24977" PostTypeId="1" CreationDate="2016-06-08T03:08:14.503" Score="0" ViewCount="4141" Body="&lt;p&gt;I have connected a bluetooth module(HC-06) and a voice recognition shield(EasyVR) on an arduino UNO.&lt;/p&gt;&#xA;&lt;p&gt;By using an another HC-06 on the another arduino(so, 2 arduinos and 2 HC-06 totally), I am going to let two arduionos communicate with each other.&lt;/p&gt;&#xA;&lt;p&gt;Also, simultaneously, one arduino with HC-06 will recogize the voice by using the voice recognition module.&lt;/p&gt;&#xA;&lt;p&gt;I have successed each operations, but after combining two codes the bluetooth doesn't work...&#xA;(Voice recognition have successed.)&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Is it unable to operate two operations simultaneously?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can we use these two sentences in one code?&lt;/p&gt;&#xA;&lt;p&gt;SoftwareSerial BT(2,3);     --&amp;gt; for bluetooth module&#xA;SoftwareSerial Port(12,13);   --&amp;gt; for voice recognition module&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22803" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-06-08T13:10:52.623" Title="Operating two functions simultaneously" Tags="|programming|bluetooth|hc-06|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24979" PostTypeId="1" AcceptedAnswerId="24980" CreationDate="2016-06-08T00:42:23.493" Score="-1" ViewCount="794" Body="&lt;p&gt;I can't figure out why the output voltage of &lt;code&gt;analogWrite(255)&lt;/code&gt; is less than the voltage of &lt;code&gt;digitalWrite(255)&lt;/code&gt;. My code and an image of my setup are below. Some other useful information is that I am using the NodeMCU by HiLetgo, 3.3k ohm resistors with the meters, and that the meters use 1mA of current DC at full scale. Thanks for your help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pPressure       = D2;&#xA;int pPrecipProb     = D1;&#xA;int pWindSpeed      = D0;&#xA;&#xA;int mTemperature;&#xA;int mHumidity;&#xA;int mPressure;&#xA;int mPrecipProb;&#xA;int mWindSpeed;&#xA;int mAlert;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(pPrecipProb,   OUTPUT);&#xA;  pinMode(pWindSpeed,    OUTPUT);&#xA;  pinMode(pPressure,     OUTPUT);&#xA;  pinMode(LED_BUILTIN,   OUTPUT);     // Initialize the LED_BUILTIN pin as an output&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;    mPressure           = (int) constrain(mPressure + 1, 0, 255);&#xA;    mPrecipProb         = (int) constrain(mPrecipProb + 1,     0, 255 );&#xA;    mWindSpeed          = (int) constrain(mWindSpeed + 1,     0, 255 );&#xA;&#xA;    if(mPressure == 255)&#xA;    {&#xA;      mPressure = 0;&#xA;      mPrecipProb = 0;&#xA;      mWindSpeed = 0;&#xA;    }&#xA;&#xA;    digitalWrite(pPressure,      HIGH   );&#xA;    analogWrite(pPrecipProb,    255 );&#xA;    analogWrite(pWindSpeed,     mWindSpeed  );&#xA;&#xA;&#xA;    delay(10);                    &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GEaro.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GEaro.jpg&quot; alt=&quot;Left &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Left: AnalogWrite(255)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Middle: DigitalWrite(HIGH)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right: the other one that cycles&lt;/p&gt;&#xA;" OwnerUserId="23967" OwnerDisplayName="user3242816" LastEditorUserId="27346" LastEditDate="2018-11-11T15:23:35.830" LastActivityDate="2018-11-11T15:23:35.830" Title="The function AnalogWrite is outputting less voltage than digitalWrite on my board" Tags="|analogwrite|digitalwrite|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="24980" PostTypeId="2" ParentId="24979" CreationDate="2016-06-08T01:13:17.050" Score="6" Body="&lt;p&gt;First, do something simpler, and eliminate possible causes.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Are you &lt;em&gt;certain&lt;/em&gt; the NodeMCU's CPU is an 8bit PWM? If it were&#xA;9bits, it would read about 50% full scale, and 10bits would be about&#xA;25% of digitalWrite (which is what I think I can see on the photo).&lt;/li&gt;&#xA;&lt;li&gt;Swap the analogue meters around, and see if the difference is consistent&#xA;with the pin, or consistent with the meters.&lt;/li&gt;&#xA;&lt;li&gt;Use a digital multimeter (DMM) to measure voltage. It should be a&#xA;small load. So this should eliminate, or identify, the analogue&#xA;meters as a culprit.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If there is still a difference in voltage, do the NodeMCU equivalent of:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  pinMode(10, OUTPUT);  // a pin capable of analogOut and DigitalOut&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(10, HIGH);&#xA;  analogWrite(9, 255);  // a pin capable of analogOut and DigitalOut&#xA;&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then swap 9 and 10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the DMM shows the analogue output is consistently lower, then go back and check that PWM is 8 bits, and the device output range for PWM is the same output voltage as digitalWrite to a GPIO.&lt;/p&gt;&#xA;" OwnerUserId="3493" OwnerDisplayName="gbulmer" LastActivityDate="2016-06-08T01:18:02.900" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="24983" PostTypeId="2" ParentId="24921" CreationDate="2016-06-08T07:05:21.783" Score="0" Body="&lt;p&gt;I found the path to the files i want change in the github link so i can change the files(C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I enable the uart for 9 bit, i add sbi(*_ucsrb, UCSZ12);  in HardwareSerial::begin&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided that i only send a Flag to my PC when the 9th bit is set. For that i change the _rx_buffer to a 2 byte matrix (short _rx_buffer). Now i send the databyte in the low-byte and flags for 9 bit, framing error and overrun error in the high-byte. That i can do that i change the void HardwareSerial::_rx_complete_irq(void) code like the follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void HardwareSerial::_rx_complete_irq(void)&#xA;{&#xA;  if (bit_is_clear(*_ucsra, UPE0))&#xA;  {&#xA;    bool is_address = UCSR0B &amp;amp; _BV(RXB80);&#xA;    bool is_framError = UCSR0A &amp;amp; _BV(FE0);&#xA;    bool is_overError = UCSR0A &amp;amp; _BV(DOR0);&#xA;    unsigned char c = *_udr;&#xA;    rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE;&#xA;&#xA;    if (i != _rx_buffer_tail) &#xA;    {&#xA;     _rx_buffer[_rx_buffer_head] = c;&#xA;     _rx_buffer[_rx_buffer_head] |= is_address &amp;lt;&amp;lt; 8;&#xA;     _rx_buffer[_rx_buffer_head] |= is_framError &amp;lt;&amp;lt; 9;&#xA;     _rx_buffer[_rx_buffer_head] |= is_overError &amp;lt;&amp;lt; 10;&#xA;     _rx_buffer_head = i;&#xA;    } &#xA;  } &#xA;  else {    *_udr;  };&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope this will work and i can evaluate the data right at the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Frindly wishes sniffi&lt;/p&gt;&#xA;" OwnerUserId="21214" LastActivityDate="2016-06-08T07:05:21.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24984" PostTypeId="2" ParentId="24963" CreationDate="2016-06-08T08:08:38.803" Score="1" Body="&lt;p&gt;You can use a terminal program like &lt;a href=&quot;http://www.chiark.greenend.org.uk/~sgtatham/putty/&quot; rel=&quot;nofollow&quot;&gt;putty&lt;/a&gt; or &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Minicom&quot; rel=&quot;nofollow&quot;&gt;Minicom&lt;/a&gt; to write that data to a log file. Then you can use whatever program or app to process this log file.&#xA;Both programs can read from the serial interface.&lt;/p&gt;&#xA;" OwnerUserId="16061" LastActivityDate="2016-06-08T08:08:38.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24985" PostTypeId="2" ParentId="24977" CreationDate="2016-06-08T08:48:26.183" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it unable to operate two operations simultaneously?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The only way you can do two operations simultaneously is to have two Arduinos. An Arduino can only do one thing at a time. In order to make it seem like it's doing things at once you have to create your sketch accordingly. The use of &lt;code&gt;delay()&lt;/code&gt; is right out. As are long loops using things like &lt;code&gt;while()&lt;/code&gt;. In short: &lt;em&gt;anything that &lt;strong&gt;blocks&lt;/strong&gt; is bad&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can we use these two sentences in one code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not reliably, no.  They are both resource hungry and, to a large extent, blocking. A general rule is, if you need at least two more UARTs than the board provides then you need a different board. You can only reliably work with one software UART at a time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest upgrading to a more capable board with more hardware UARTs. Either that or use a bluetooth system that doesn't use UART, such as an SPI based BLE module.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-08T08:48:26.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24988" PostTypeId="1" AcceptedAnswerId="25642" CreationDate="2016-06-08T09:01:40.150" Score="0" ViewCount="2499" Body="&lt;p&gt;I have the basic version of the &lt;a href=&quot;http://www.sainsmart.com/sainsmart-l293d-motor-drive-shield-for-arduino-duemilanove-mega-uno-r3-avr-atmel.html&quot; rel=&quot;nofollow&quot;&gt;stepper motor driver&lt;/a&gt; and a Nano, I see the pins are set to plug directly in to a Uno or similar Arduino, but according to the documentation it just needs most of the digital pins connected to the arduino - &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/faq&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-motor-shield/faq&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As it seems they are the opposite position to plug into a breadboard for testing, I may need to wire and solder them (11 to D11, 3 to D3, 5 to D5, 6 to D6). Is this correct or does the Nano not have the power/amperage/timing or something to run this type of shield, hence the lack of compatibility listed for that shield?&lt;/p&gt;&#xA;" OwnerUserId="10780" LastActivityDate="2016-06-26T13:29:45.283" Title="What is the wiring of arduino motor shield to Nano?" Tags="|arduino-nano|shields|arduino-motor-shield|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24989" PostTypeId="2" ParentId="24988" CreationDate="2016-06-08T09:31:42.297" Score="0" Body="&lt;p&gt;I believe, though it's not clear, that the shield in question uses a 74HC595 shift register to control the main motor drivers - the other pins are for the servo interfaces (and they are just wired 1:1). Theoretically you can therefore use any pins you like to control the motor drivers themselves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's not the same as the Adafruit one which looks to use direct Arduino control of the motor drivers.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-08T09:31:42.297" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24993" PostTypeId="2" ParentId="24933" CreationDate="2016-06-08T10:59:26.833" Score="1" Body="&lt;p&gt;The &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vin pin = 5V or 3.3V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You cannot use the 5V from the USB to power up the FAN and the LOAD because the USB port usually delivers only 100mA, and this is not enough to switch the relay and the LOAD. &#xA;That is why you must use an external power supply (Vcc) that is between 7 to 12 volts to power up the Arduino board and the transistor + relay. The load uses its own power supply, for instance if you use a light bulb then you might connect it to the 110/220V mains or any other power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;or&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can also use a fan that has one of the pins of the fan is a PWM input. The fan has an internal transistor to switch the 12V power when given a 0-5V input. That is the pin you want to connect to the actuator pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;please get back to me if it was helpful&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="22820" LastActivityDate="2016-06-08T10:59:26.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="24994" PostTypeId="1" CreationDate="2016-06-08T11:01:13.120" Score="3" ViewCount="5745" Body="&lt;p&gt;I am new to IOT and tried out integration and a small test code with an Arduino Mega + SIM808 + GSM + GPS Module. It works fine with the SIM808 Library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My requirement is to put it in an enclosure, but when the power restarts, for some reason we have to manually start the SIM 808 + GPS + GSM Module. Can we control it from code? Can we do a software trigger from Arduino code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe if we have some pins to connect and trigger the power on. Kindly provide inputs/suggestion for &lt;a href=&quot;http://www.ebay.in/itm/222142520400?euid=007afe9cc2264537b4beecab12b7dd90&amp;amp;bu=44483664891&amp;amp;cp=1&amp;amp;sojTags=bu=bu&quot; rel=&quot;nofollow noreferrer&quot;&gt;this module&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are aware of some module that can be started through code kindly suggest.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's &lt;a href=&quot;http://www.geeetech.com/wiki/index.php/Arduino_GPRS_Shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;one reference&lt;/a&gt; I found for a different module with Software Trigger.&lt;/p&gt;&#xA;" OwnerUserId="22818" LastEditorUserId="4628" LastEditDate="2017-04-05T04:21:15.677" LastActivityDate="2019-05-17T11:59:24.070" Title="Arduino Mega + SIM808 GSM + GPS Module + Program Switch ON without pressing Push Button?" Tags="|arduino-mega|gsm|gps|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24995" PostTypeId="2" ParentId="24994" CreationDate="2016-06-08T11:56:22.717" Score="0" Body="&lt;p&gt;I can't get a great view of the board, but if you are pressing the button just below &quot;GSM&quot; and &quot;Made&quot; then I would suggest soldering some leads onto the button and connecting them to a digital output and Gnd on the Arduino.  (You might need resistors and stuff)  Then when you wanted to press the button you could pulse the line high.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-08T11:56:22.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="24998" PostTypeId="1" CreationDate="2016-06-08T12:39:28.800" Score="-1" ViewCount="553" Body="&lt;p&gt;I am in grade 6. I have a very nice pet dog in my house but it often enters Mom's kitchen to spoil all the foods. So I am thinking of a device to attach with him which can locate its position. But I am totally new to arduino programming. I have found some tutorials of arduino UNO to locate position with GPS. But I don't know how to set up the alarm when my dog reaches the position of our kitchen and what will be the code for it. If I wanna set alarm for different position, like kitchen and two toilets, what would be the code then? I know Java a very little bit. C too. Nothing else. Is there any altruist to help me out, please?&lt;/p&gt;&#xA;" OwnerUserId="22824" LastActivityDate="2016-06-09T23:18:22.627" Title="What would be the code for using Arduino UNO to alert by sound or LED when it detects a certain position through GPS?" Tags="|arduino-uno|programming|gps|java|buzzer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25000" PostTypeId="2" ParentId="24977" CreationDate="2016-06-08T13:05:26.270" Score="0" Body="&lt;p&gt;Physically It is impossible to run 2 things at the same time when you have one microcontroller. &quot;The Arduino is a very simple processor with no operating system and can only run one program at a time&quot;. But I am pretty sure that the solution you are trying to find, hides in multitasking or interuption. There are some cones in &lt;code&gt;delay()&lt;/code&gt; function: &quot;The problem is that delay() is a &quot;busy wait&quot; that monopolizes the processor. &quot; But in multitasking, you share clock of the processor between two different pieces. You can find more about running different things simultanously &lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-1/overview&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&#xA;I have used &lt;code&gt;miles()&lt;/code&gt; in one of my projects where were coin validator which was outputing impulses and screen which was showing chash inside it.&lt;/p&gt;&#xA;" OwnerUserId="22783" LastEditorUserId="22783" LastEditDate="2016-06-08T13:10:52.623" LastActivityDate="2016-06-08T13:10:52.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25003" PostTypeId="1" AcceptedAnswerId="25005" CreationDate="2016-06-08T13:45:18.987" Score="0" ViewCount="1221" Body="&lt;p&gt;Ive recently bought my self a arduino Mega 2560 and managed to get a sort of RANDOM function to work with different cases which go of by the number selected.&#xA;My question is is there a way to also make a PWM sequence in such a case? so that the LED is fully light to dark and then the the next case starts?  IS there a more random sequence wich i could then also expand if neccesary?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mark.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledcolor = 0;&#xA; int a = 500; //this sets how long the stays one color for&#xA;int b = 2000;&#xA;int brightness = 255;    // how bright the LED is&#xA;int fadeAmount = 25;    // how many points to fade the LED by&#xA;&#xA; void setup() { //this sets the output pins&#xA;&#xA; pinMode(11, OUTPUT);&#xA; pinMode(10, OUTPUT);&#xA; pinMode(9, OUTPUT);&#xA; pinMode(8, OUTPUT);&#xA; }&#xA;&#xA; void loop() {&#xA; int ledcolor = random(1,16); //this randomly selects a number between 1 and 15&#xA;&#xA; switch (ledcolor) {&#xA;&#xA; case 1: //if ledcolor equals 1 then the led on pin 11 will turn on etc.&#xA; analogWrite(11, brightness);&#xA; brightness = brightness - fadeAmount;     break;&#xA; case 2:&#xA; digitalWrite(10, HIGH);&#xA; delay(a);&#xA; digitalWrite(10, LOW);&#xA; break;&#xA; case 3:&#xA; digitalWrite(9, HIGH);&#xA; delay(a);&#xA; digitalWrite(9, LOW);&#xA; break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22819" LastEditorUserId="22819" LastEditDate="2016-06-08T15:14:50.953" LastActivityDate="2016-06-09T11:42:54.870" Title="how to implement PWM LED fading into a random case switch?" Tags="|arduino-mega|led|pwm|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25005" PostTypeId="2" ParentId="25003" CreationDate="2016-06-08T14:13:01.573" Score="1" Body="&lt;p&gt;In order to fade in and fade out LEDs you need to use &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/PWM&quot; rel=&quot;nofollow&quot;&gt;PWM&lt;/a&gt; feature. And, specifically you need to use the &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;analogWrite()&lt;/a&gt; function call. Also, you need to make sure all your LEDs are connected to PWM port pins.  Port pins which support the PWM feature for various Arduinos are listed in the above link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your code you might try replacing your 500ms delay with a count up followed by a count down loop.  Each loop should contain the appropriate delay and count up or down to the appropriate value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you might try a 1ms delay and a count from 0 to 255 followed by a count from 255 to 0.  In both loops just before or just after calling the delay() function, place the call to the analogWrite() function and pass the counter value as the PWM duty cycle (LED brightness setting).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you might try to see if this code works for the 1st case statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int brightness_level;&#xA;&#xA;&#xA;case 1: //if ledcolor equals 1 then the led on pin 11 will turn on etc.&#xA;  for(brightness_level = 0 ; brightness_level &amp;lt; 255 ; brightness_level++)&#xA;  {&#xA;    analogWrite(11, brightness_level);&#xA;    delay(1);&#xA;  }&#xA;  for(brightness_level = 255 ; brightness_level &amp;gt;= 0 ; brightness_level--)&#xA;  {&#xA;    analogWrite(11, brightness_level);&#xA;    delay(1);&#xA;  }&#xA;break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-09T06:43:41.947" LastActivityDate="2016-06-09T06:43:41.947" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25006" PostTypeId="1" CreationDate="2016-06-08T14:32:08.560" Score="2" ViewCount="36" Body="&lt;p&gt;my group is doing a project which call automatic bed maker. we want to use a servomotor to pull the sheet of the bed. can we possibly make the servomotor stop rotate when the speed of rotation decrease? or is there any way to make the servo motor automatically stop beside using timer.&#xA;sorry for broken english.&lt;/p&gt;&#xA;" OwnerUserId="22828" LastActivityDate="2016-06-08T14:32:08.560" Title="is it possible to code microservo automatically stop when the speed of rotation getting slower?" Tags="|motor|servo|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25007" PostTypeId="1" CreationDate="2016-05-30T20:17:03.713" Score="0" ViewCount="164" Body="&lt;p&gt;Hardware newbie here and I need to know how to connect my TSL 1401 line scan camera to an Arduino Mega so that I can send it the needed impulses. The Mega has a hundred different sockets and the Schema just scared me when I looked at it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to know which socket I can connect to the CLK and SI ports of my camera so that I can get and an analog output of pixels.&lt;/p&gt;&#xA;" OwnerDisplayName="Isabel" LastEditorUserId="972" LastEditDate="2016-06-08T19:01:13.773" LastActivityDate="2016-06-17T18:52:42.520" Title="How would you send clock impulses to a camera with an Arduino Mega?" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25008" PostTypeId="1" AcceptedAnswerId="25016" CreationDate="2016-06-08T15:36:00.677" Score="1" ViewCount="1098" Body="&lt;p&gt;I have an ATtiny hooked up to two line scan modules. I'm sending digital signals to the line scan modules then receiving the analog output and storing it in an array. I have an if statement that will make the LED on the ATtiny programmer blink when the number are below a certain range (meaning that lens is covered). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;const int rx=0;&#xA;const int tx=1;&#xA;&#xA;SoftwareSerial mySerial(rx,tx);&#xA;int CLK = 2;&#xA;int SI = 1;&#xA;int Aout = A3; &#xA;int Aout1 = A2;&#xA;&#xA;int LED = 0;&#xA;&#xA;int pixelsArray[128];   //Array to hold the values of the individual pixles.&#xA;int pixelsArray1[128];&#xA;&#xA; void outputPixels()&#xA;{&#xA;  for(int j = 0; j &amp;lt; 128; j++)&#xA;  {&#xA;    digitalWrite(LED, LOW);&#xA;&#xA;    if(pixelsArray[j] &amp;lt; 100)&#xA;    {&#xA;      digitalWrite(LED, HIGH);&#xA;      delay(500);&#xA;      digitalWrite(LED, LOW);&#xA;      delay(500);&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem that I am having is that when I test my code with one line scan module it works just fine. You will notice that in the &lt;code&gt;readPixels()&lt;/code&gt; I have the statement &lt;code&gt;pixelsArray1[i]=analogRead(Aout1);&lt;/code&gt; commented out. However, when I try to use it with two the LED start blinking regardless of how much light is hitting the line scanner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The strange thing is that EVEN when I comment out the &lt;code&gt;digitalWrite(LED, HIGH);&lt;/code&gt; statement in the &lt;code&gt;outputPixels()&lt;/code&gt; method...THE LED STILL BLINKS!!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the ATtiny does not support URT and can't use the console in Arduino I have no idea how to debug this. Does anyone here have any clue what is wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the datasheets&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATtiny: &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATtiny Programmer: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/?_ga=1.59946280.467360091.1464906372&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/?_ga=1.59946280.467360091.1464906372&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21660" LastEditorUserId="21660" LastEditDate="2016-06-08T18:05:09.233" LastActivityDate="2016-06-08T18:05:09.233" Title="Debugging with an ATtiny?" Tags="|library|attiny|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25009" PostTypeId="1" AcceptedAnswerId="25013" CreationDate="2016-06-08T15:41:28.437" Score="0" ViewCount="56" Body="&lt;p&gt;I want to control 2 dc motors using the arduino board directly. One motor must rotate clockwise and the other counter clockwise. The directions  doesn't change only the speed of each motors. Can this be done without any shield? Them motors may need a higher voltage than the arduino can provide. If I link the arduino board to a power source of about 15 V (the board is arduino mega limits between 6 and 20 ) and I use &quot;analog.write()&quot; function can I output more than 5 volts(the internal voltage)?&lt;/p&gt;&#xA;" OwnerUserId="21522" LastActivityDate="2016-06-08T16:37:52.140" Title="Motor control using arduino board" Tags="|motor|voltage-level|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25010" PostTypeId="1" CreationDate="2016-06-08T15:44:40.490" Score="2" ViewCount="10011" Body="&lt;p&gt;First of all, let me be clear: I'm a total noob, I have close to zero programming experience and I know i'm out of my league, but I want to learn and understand.&#xA;Here's the issue. The following code has been made to control heat pads using 4 relays that turn off/on depending on the temperature that 4 lm35 Temp sensors pick up. Because these sensors can be jumpy sometimes, I want to get the average temperature from, let's say, 50 readings, and make the code check THAT data instead of the raw temp reading.&#xA;I have the code for the arduino (I wrote some code and guys over other forums took it and modified it to make it shorter (and that kind of lost me, but the code works)&#xA;and then I searched smoothing data and got a piece of code that does exactly what I want: make an array, calculate the average temp, and keep deleting and adding new data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to join both codes together and I got all different kind of errors, lol&#xA;So here I am.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The Code that works without average data is this one:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte tempPin[] = {A1, A2, A3, A4};&#xA;const byte relayPin[] = {6, 7, 8, 9};&#xA;&#xA;// hysteresis = upperLimit - lowerLimit&#xA;const byte lowerLimit = 24;&#xA;const byte upperLimit = 31;&#xA;&#xA;float tempC[4];&#xA;word reading[4];&#xA;&#xA;&#xA;&#xA;word printInterval = 1000; // 1 second&#xA;unsigned long printCheck = 0, lastPrintTime = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  analogReference(INTERNAL);&#xA;  Serial.begin(115200);&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    pinMode(relayPin[i], INPUT_PULLUP);&#xA;    pinMode(relayPin[i], OUTPUT); // defaults HIGH, relay OFF&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // readings and control&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    reading[i] = analogRead(tempPin[i]);&#xA;    tempC[i] = reading[i] / 9.31;&#xA;&#xA;&#xA;    if (tempC[i] &amp;lt; lowerLimit) {&#xA;      digitalWrite(relayPin[i], LOW);   //relay OFF&#xA;    }&#xA;    else if (tempC[i] &amp;gt; upperLimit) {&#xA;      digitalWrite(relayPin[i], HIGH);  // relay ON&#xA;    }&#xA;  }&#xA;  printCheck = millis() - lastPrintTime;&#xA;  if (printCheck &amp;gt;= printInterval) {&#xA;    for (int i = 0; i &amp;lt; 4; i++) {&#xA;      Serial.print(&quot;tempC&quot;);&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot; &quot;);&#xA;      Serial.println(tempC[i]);&#xA;    }&#xA;    Serial.println();&#xA;    lastPrintTime = millis(); // reset print timer&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The average code I got from Arduino Learning center is this one:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;&#xA;  Smoothing&#xA;&#xA;  Reads repeatedly from an analog input, calculating a running average&#xA;  and printing it to the computer.  Keeps ten readings in an array and&#xA;  continually averages them.&#xA;&#xA;  The circuit:&#xA;    * Analog sensor (potentiometer will do) attached to analog input 0&#xA;&#xA;  Created 22 April 2007&#xA;  By David A. Mellis  &amp;lt;dam@mellis.org&amp;gt;&#xA;  modified 9 Apr 2012&#xA;  by Tom Igoe&#xA;  http://www.arduino.cc/en/Tutorial/Smoothing&#xA;&#xA;  This example code is in the public domain.&#xA;&#xA;&#xA;*/&#xA;&#xA;&#xA;// Define the number of samples to keep track of.  The higher the number,&#xA;// the more the readings will be smoothed, but the slower the output will&#xA;// respond to the input.  Using a constant rather than a normal variable lets&#xA;// use this value to determine the size of the readings array.&#xA;const int numReadings = 10;&#xA;&#xA;int readings[numReadings];      // the readings from the analog input&#xA;int readIndex = 0;              // the index of the current reading&#xA;int total = 0;                  // the running total&#xA;int average = 0;                // the average&#xA;&#xA;int inputPin = A0;&#xA;&#xA;void setup() {&#xA;  // initialize serial communication with computer:&#xA;  Serial.begin(9600);&#xA;  // initialize all the readings to 0:&#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++) {&#xA;    readings[thisReading] = 0;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // subtract the last reading:&#xA;  total = total - readings[readIndex];&#xA;  // read from the sensor:&#xA;  readings[readIndex] = analogRead(inputPin);&#xA;  // add the reading to the total:&#xA;  total = total + readings[readIndex];&#xA;  // advance to the next position in the array:&#xA;  readIndex = readIndex + 1;&#xA;&#xA;  // if we're at the end of the array...&#xA;  if (readIndex &amp;gt;= numReadings) {&#xA;    // ...wrap around to the beginning:&#xA;    readIndex = 0;&#xA;  }&#xA;&#xA;  // calculate the average:&#xA;  average = total / numReadings;&#xA;  // send it to the computer as ASCII digits&#xA;  Serial.println(average);&#xA;  delay(1);        // delay in between reads for stability&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;The monster I created joining both codes is this one:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte tempPin[] = {A1, A2, A3, A4};&#xA;const byte relayPin[] = {6, 7, 8, 9};&#xA;&#xA;// hysteresis = upperLimit - lowerLimit&#xA;const byte lowerLimit = 24;&#xA;const byte upperLimit = 31;&#xA;&#xA;float tempC[4];&#xA;word reading[4];&#xA;&#xA;const int numReadings = 50;&#xA;int readings[numReadings];&#xA;int readIndex = 0;&#xA;int total = 0;&#xA;float average[4];&#xA;&#xA;&#xA;word printInterval = 1000; // 1 second&#xA;unsigned long printCheck = 0, lastPrintTime = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  analogReference(INTERNAL);&#xA;  Serial.begin(115200);&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    pinMode(relayPin[i], INPUT_PULLUP);&#xA;    pinMode(relayPin[i], OUTPUT); // defaults HIGH, relay OFF&#xA;  }&#xA;  for (int thisReading = 0; thisReading &amp;lt; numReadings; thisReading++){&#xA;    readings[thisReading] = 0;&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // readings and control&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    reading[i] = analogRead(tempPin[i]);&#xA;    tempC[i] = reading[i] / 9.31;&#xA;    total[i] = total[i] - readings[readIndex];&#xA;    readings[readIndex] = tempC[i]&#xA;    total[i] = total[i] + readings[readIndex]&#xA;    readIndex[i] = readIndex[i] + 1 ;&#xA;    if (readIntex[i] &amp;gt;= numReadings) {&#xA;      readIndex = 0;&#xA;    }&#xA;    average[i] = total[i] / numReadings;&#xA;&#xA;    if (average[i] &amp;lt; lowerLimit) {&#xA;      digitalWrite(relayPin[i], LOW);   //relay OFF&#xA;    }&#xA;    else if (average[i] &amp;gt; upperLimit) {&#xA;      digitalWrite(relayPin[i], HIGH);  // relay ON&#xA;    }&#xA;  }&#xA;  printCheck = millis() - lastPrintTime;&#xA;  if (printCheck &amp;gt;= printInterval) {&#xA;    for (int i = 0; i &amp;lt; 4; i++) {&#xA;      Serial.print(&quot;tempC&quot;);&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot; &quot;);&#xA;      Serial.println(tempC[i]);&#xA;    }&#xA;    Serial.println();&#xA;    lastPrintTime = millis(); // reset print timer&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;These are the errors that I got:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.8 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;\temprelayfinal2.ino: In function 'void loop()':&#xA;&#xA;temprelayfinal2:40: error: invalid types 'int[int]' for array subscript&#xA;&#xA;     total[i] = total[i] - readings[readIndex];&#xA;&#xA;            ^&#xA;&#xA;temprelayfinal2:40: error: invalid types 'int[int]' for array subscript&#xA;&#xA;     total[i] = total[i] - readings[readIndex];&#xA;&#xA;                       ^&#xA;&#xA;temprelayfinal2:42: error: expected ';' before 'total'&#xA;&#xA;     total[i] = total[i] + readings[readIndex]&#xA;&#xA;     ^&#xA;&#xA;temprelayfinal2:44: error: 'readIntex' was not declared in this scope&#xA;&#xA;     if (readIntex[i] &amp;gt;= numReadings) {&#xA;&#xA;         ^&#xA;&#xA;temprelayfinal2:47: error: invalid types 'int[int]' for array subscript&#xA;&#xA;     average[i] = total[i] / numReadings;&#xA;&#xA;                         ^&#xA;&#xA;exit status 1&#xA;invalid types 'int[int]' for array subscript&#xA;&#xA;This report would have more information with&#xA;&quot;Show verbose output during compilation&quot;&#xA;option enabled in File -&amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22830" LastEditorUserId="7508" LastEditDate="2016-06-08T15:48:32.973" LastActivityDate="2016-06-08T20:13:02.920" Title="Help with getting Sensor Average using Arrays" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25011" PostTypeId="2" ParentId="25008" CreationDate="2016-06-08T15:50:23.507" Score="0" Body="&lt;p&gt;According to the Specs of the Attiny, this microcontroller only has 128 bytes of memory (RAM).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the code you declare two arrays:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pixelsArray[128];   //Array to hold the values of the individual pixles.&#xA;int pixelsArray1[128];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which will occuppy much more memory than the available on this microcontroller.&#xA;Try to reduce the size of the array. Each int entry occupies 2 bytes according to the &lt;a href=&quot;https://www.arduino.cc/en/Reference/Int&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4971" LastActivityDate="2016-06-08T15:50:23.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25013" PostTypeId="2" ParentId="25009" CreationDate="2016-06-08T16:37:52.140" Score="1" Body="&lt;p&gt;Simplest way to do this is two MOSFETs (one per motor, because you don't need to change direction), and some miscellaneous passives, and a flyback diode for each motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://bildr.org/2012/03/rfp30n06le-arduino/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt; for wiring diagrams and details.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-06-08T16:37:52.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25014" PostTypeId="2" ParentId="24998" CreationDate="2016-06-08T16:43:39.077" Score="2" Body="&lt;p&gt;First things first: do you know that a GPS can locate your dog accurately enough in your home?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, even with a good GPS receiver, the best accuracy you can expect (using off-the-shelf receivers, non-military or DGPS) is maybe 3 m. Typical performance is maybe 4 m, and indoors it will be even worse. The point is, your dog could be 5 m away from your intended location, and you will get an alarm. 5 m in a house might be the room over, two rooms over, or outside the house!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you want to go forward with this, get yourself a GPS module, connect it to your Arduino, install the &lt;a href=&quot;http://arduiniana.org/libraries/tinygpsplus/&quot; rel=&quot;nofollow&quot;&gt;TinyGPS++&lt;/a&gt; library (one of the better Arduino GPS libs IMO), and play with it. It's easy to figure out how to perform an action when the GPS coordinates are in range of a given coordinate set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might have better luck using a different form of dog location detection.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-06-08T16:43:39.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25015" PostTypeId="2" ParentId="25010" CreationDate="2016-06-08T16:47:20.050" Score="1" Body="&lt;pre&gt;&lt;code&gt;total[i] = total[i] - readings[readIndex];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;total&lt;/code&gt; is of type &lt;code&gt;int&lt;/code&gt;. That is, it is a scalar integer. You cannot index into it, &lt;code&gt;total[i]&lt;/code&gt; doesn't make sense. That is why the compiler is complaining.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-06-08T16:47:20.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25016" PostTypeId="2" ParentId="25008" CreationDate="2016-06-08T16:54:22.580" Score="0" Body="&lt;p&gt;Since you do not have enough RAM for your arrays, something has to&#xA;give. A few options:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do you really need the 10-bit precision of the ADC? If you can live&#xA;with 8 bits, then use 8-bit arrays (type &lt;code&gt;uint8_t&lt;/code&gt;) and store only&#xA;the 8 most significant bits of each reading&#xA;(&lt;code&gt;pixelsArray[i]=analogRead(Aout)&amp;gt;&amp;gt;2&lt;/code&gt;). This will make the arrays&#xA;half as big.&lt;/li&gt;&#xA;&lt;li&gt;If you really need 10-bit precision, maybe you do not need 128-pixel&#xA;resolution? Then you could store only every other pixel. This will&#xA;also halve the array sizes.&lt;/li&gt;&#xA;&lt;li&gt;If you do need both the full precision and the full resolution, then&#xA;you will have to pack the bits tight. You can pack up to 4 readings&#xA;in 5 bytes. But this will increase the complexity of your program.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Addendum&lt;/strong&gt;: To declare the arrays as being made of 8-bit integers,&#xA;just replace&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pixelsArray[128];&#xA;int pixelsArray1[128];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;by&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t pixelsArray[128];&#xA;uint8_t pixelsArray1[128];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here “uint8_t” means “unsigned 8-bit integer”, whereas “int” is a&#xA;regular integer, i.e. signed and, on the AVRs, 16-bits long.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-08T17:15:17.933" LastActivityDate="2016-06-08T17:15:17.933" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25017" PostTypeId="1" AcceptedAnswerId="25091" CreationDate="2016-06-08T17:11:10.040" Score="0" ViewCount="204" Body="&lt;p&gt;guys.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm writing here because I cannot find an obvious error, so I'm stuck. Could you please help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int arrayAAA[] = {6, 8, 10, 12};&#xA;int arrayBBB[] = {9, 15, 27, 41};&#xA;&#xA;const int arrayAAALength = sizeof(arrayAAA)/sizeof(int);&#xA;const int arrayBBBLength = sizeof(arrayBBB)/sizeof(int);&#xA;&#xA;int newArrayLength = 0;&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  String dir = &quot;AAA&quot;;&#xA;&#xA;  if (dir == &quot;AAA&quot;){&#xA;&#xA;      //Copy existing array to the new one...&#xA;      newArrayLength = arrayAAALength;              //Get the size of source array&#xA;      int newArray[newArrayLength];                 //Make the new array of the same size&#xA;      memcpy(newArray, arrayAAA, sizeof(arrayAAA)); //Copy content of the source array to the new one&#xA;&#xA;      /*&#xA;      for (int i = 0; i &amp;lt; newArrayLength; i++){&#xA;          Serial.print(newArray[i]); //Here everything works just fine...&#xA;          Serial.print(&quot;   &quot;);&#xA;      }&#xA;       */    &#xA;  }&#xA;&#xA;  for (int i = 0; i &amp;lt; newArrayLength; i++){&#xA;      Serial.print(newArray[i]); //But here I see this error: 'newArray' was not declared in this scope&#xA;      Serial.print(&quot;   &quot;);&#xA;  }&#xA;&#xA;  Serial.println();&#xA;  Serial.println();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do is to copy the array to a new one, but depending on the circumstances I need to take different source arrays (AAA or BBB).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is in checking the values of an newly crreated array: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;'newArray' was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;if I try to check its valus outside of if statment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems my stupid mistake, but I can't find it.&lt;/p&gt;&#xA;" OwnerUserId="8472" LastActivityDate="2016-06-10T19:38:01.180" Title="Variable scope error" Tags="|arduino-due|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25018" PostTypeId="2" ParentId="25017" CreationDate="2016-06-08T17:33:35.387" Score="0" Body="&lt;p&gt;The clue is in the indenting:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (dir == &quot;AAA&quot;){&#xA;&#xA;      //Copy existing array to the new one...&#xA;      newArrayLength = arrayAAALength;              //Get the size of source array&#xA;      int newArray[newArrayLength];                 //Make the new array of the same size &amp;lt;&amp;lt;&amp;lt;==== DEFINED IN THE SCOPE OF &quot;IF&quot;&#xA;      memcpy(newArray, arrayAAA, sizeof(arrayAAA)); //Copy content of the source array to the new one&#xA;&#xA;      /*&#xA;      for (int i = 0; i &amp;lt; newArrayLength; i++){&#xA;          Serial.print(newArray[i]); //Here everything works just fine...&#xA;          Serial.print(&quot;   &quot;);&#xA;      }&#xA;       */    &#xA;  }&#xA;&#xA;  for (int i = 0; i &amp;lt; newArrayLength; i++){&#xA;      Serial.print(newArray[i]); //But here I see this error: 'newArray' was not declared in this scope &amp;lt;&amp;lt;=== USED IN THE SCOPE OF &quot;FOR&quot;&#xA;      Serial.print(&quot;   &quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see by the indenting the definition of &lt;code&gt;newArray&lt;/code&gt; is in a different block of code which you come right out of before you use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You must define &lt;code&gt;newArray&lt;/code&gt; at a scope that is &lt;em&gt;outside&lt;/em&gt; where you use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From that code you don't actually need to copy the contents of one array into another - you can just &lt;em&gt;point&lt;/em&gt; to the array you want to use with a pointer.  Alternatively, if you do need to clone the array contents (for some other purpose we don't know of) then you should pre-create an array that is big enough to hold &lt;em&gt;either&lt;/em&gt; of your other arrays.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int newArray[max(arrayAAALength, arrayBBBLength)];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-08T17:33:35.387" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25022" PostTypeId="1" CreationDate="2016-06-08T19:40:38.650" Score="0" ViewCount="938" Body="&lt;p&gt;My final project goal is to make Brushless gimbal for drones using only Arduino MEGA 2560 and 9DOF IMU for control. On Instructables I found two excellent tutorials. Both are different than mine in selected components.&lt;/p&gt;&#xA;&lt;p&gt;I use the following components:&lt;/p&gt;&#xA;&lt;p&gt;Arduino MEGA2560&lt;/p&gt;&#xA;&lt;p&gt;Motors - Quanum 2208 Precision Brushless Gimbal Motor ( httpx://goo.gl/RDBvJL)&lt;/p&gt;&#xA;&lt;p&gt;Motor Driver - H bridge L298n (httpx://goo.gl/A4ZQi5)&lt;/p&gt;&#xA;&lt;p&gt;9DOF Razor IMU (httpx://goo.gl/myg9oj )&lt;/p&gt;&#xA;&lt;p&gt;I'm stuck with 9DOF Razor IMU. Surfing on the internet I found a great tutorial and  github repository (httpx://goo.gl/jh2pfU). This tutorial is excellent and AHRS works great with the FTDI Basic Breakout 3.3V. They gave me a good starting point, but my goal is use only Arduino MEGA2560 and sensors.&lt;/p&gt;&#xA;&lt;p&gt;I want to connect the Arduino and 9DOF IMU directly and use the accelerometer data (Yaw, Pitch, Roll) for directly control the engines. On the website of the manufacturer Sparkfun (httpx://goo.gl/myg9oj ) I can’t find any datasheet exclusively for 9DOF IMU that could help me to connect Arduino and IMU. There are only datasheet of sensors that are on IMU ( ITG-3200 (MEMS triple-axis gyro), ADXL345 (triple-axis accelerometer), and HMC5883L (triple-axis magnetometer)  which are useless for me.&lt;/p&gt;&#xA;&lt;p&gt;That's why I decided to use code from this site ( httpx://goo.gl/zOnYjN ) and he works great. I connected everything as is in tutorial and  Arduino SerialMonitor show me the desired values YPR. Values load very quickly directly from IMU and printed on SerialMonitor.&lt;/p&gt;&#xA;&lt;p&gt;Values on SerialMonitor looks like this:&lt;/p&gt;&#xA;&lt;h1&gt;YPR=72.13,1.74,-16.38&lt;/h1&gt;&#xA;&lt;h1&gt;YPR=72.14,1.72,-16.39&lt;/h1&gt;&#xA;&lt;h1&gt;YPR=72.12,1.71,-16.39&lt;/h1&gt;&#xA;&lt;h1&gt;YPR=72.13,1.71,-16.37&lt;/h1&gt;&#xA;&lt;h1&gt;YPR=72.13,1.70,-16.40 …&lt;/h1&gt;&#xA;&lt;p&gt;&lt;strong&gt;HELP ME&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is my first solo Arduino project and I have a lot of questions about it.&#xA;How could I parse the data that appears on SerialMonitor to get new variables eg. Yaw = 72.12, Pitch = 1.74, Roll = -16.39?&lt;/p&gt;&#xA;&lt;p&gt;Is it possible to do that?&lt;/p&gt;&#xA;&lt;p&gt;Does anyone have any experience with 9DOF razor IMU and maybe know  better way to collect information from the accelerometer 9DOF razor IMU?&lt;/p&gt;&#xA;&lt;p&gt;I want to achieve three separate variables which i will use to control the brushless motor. I think this should be an easier method as it is just comma separated numbers but then again i am new to arduino serial communication so i would appreciate any help with this. Even if it's only how to parse and extract the values.&lt;/p&gt;&#xA;" OwnerUserId="22841" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2019-09-25T12:07:18.390" Title="How to get data from 9DOF razor IMU directly to arduino mega" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25023" PostTypeId="2" ParentId="25010" CreationDate="2016-06-08T20:13:02.920" Score="1" Body="&lt;p&gt;Using the exponential moving average filter suggested by Gerben, things&#xA;become quite simpler:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte tempPin[] = {A1, A2, A3, A4};&#xA;const byte relayPin[] = {6, 7, 8, 9};&#xA;&#xA;// hysteresis = upperLimit - lowerLimit&#xA;const byte lowerLimit = 24;&#xA;const byte upperLimit = 31;&#xA;&#xA;const int numReadings = 64;&#xA;const word printInterval = 1000; // 1 second&#xA;&#xA;float tempC[4];&#xA;unsigned long lastPrintTime = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  analogReference(INTERNAL);&#xA;  Serial.begin(115200);&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    digitalWrite(relayPin[i], HIGH);&#xA;    pinMode(relayPin[i], OUTPUT);&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // readings and control&#xA;  for (int i = 0; i &amp;lt; 4; i++) {&#xA;    float raw_temp = analogRead(tempPin[i]) / 9.31;&#xA;    tempC[i] += (raw_temp - tempC[i]) / numReadings;  // filter&#xA;    if (tempC[i] &amp;lt; lowerLimit) {&#xA;      digitalWrite(relayPin[i], LOW);   //relay OFF&#xA;    }&#xA;    else if (tempC[i] &amp;gt; upperLimit) {&#xA;      digitalWrite(relayPin[i], HIGH);  // relay ON&#xA;    }&#xA;  }&#xA;  if (millis() - lastPrintTime &amp;gt;= printInterval) {&#xA;    for (int i = 0; i &amp;lt; 4; i++) {&#xA;      Serial.print(&quot;tempC&quot;);&#xA;      Serial.print(i + 1);&#xA;      Serial.print(&quot; &quot;);&#xA;      Serial.println(tempC[i]);&#xA;    }&#xA;    Serial.println();&#xA;    lastPrintTime = millis(); // reset print timer&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-08T20:13:02.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25024" PostTypeId="2" ParentId="24969" CreationDate="2016-06-08T21:16:03.530" Score="3" Body="&lt;p&gt;I programmed by Uno using your &lt;a href=&quot;http://rodbhar.com/how-to-install-amforth-on-the-arduino-uno/&quot; rel=&quot;nofollow&quot;&gt;first guide&lt;/a&gt; and it seems to work OK.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;amforth 6.1 ATmega&#xA;8P Forthduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, using the serial monitor, I entered:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6 7 * .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It printed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;42  ok&#xA;&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then  entered the ASCII table example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-forth prettyprint-override&quot;&gt;&lt;code&gt;\ print a ascii table&#xA;: .ascii&#xA;base @&#xA;$7f $20 do&#xA;    i emit&#xA;    decimal  .&quot; , dec: &quot; i .&#xA;    hex      .&quot; , hex: &quot; i .&#xA;    8 base ! .&quot; , oct: &quot; i .&#xA;    2 base ! .&quot; , bin: &quot; i .&#xA;    cr&#xA;loop&#xA;base !&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then when I invoked it with &quot;.ascii&quot; it printed the table:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;&amp;gt; .ascii&#xA; , dec: 32 , hex: 20 , oct: 40 , bin: 100000 &#xA;!, dec: 33 , hex: 21 , oct: 41 , bin: 100001 &#xA;&quot;, dec: 34 , hex: 22 , oct: 42 , bin: 100010 &#xA;#, dec: 35 , hex: 23 , oct: 43 , bin: 100011 &#xA;$, dec: 36 , hex: 24 , oct: 44 , bin: 100100 &#xA;%, dec: 37 , hex: 25 , oct: 45 , bin: 100101 &#xA;&amp;amp;, dec: 38 , hex: 26 , oct: 46 , bin: 100110 &#xA;', dec: 39 , hex: 27 , oct: 47 , bin: 100111 &#xA;(, dec: 40 , hex: 28 , oct: 50 , bin: 101000 &#xA;), dec: 41 , hex: 29 , oct: 51 , bin: 101001 &#xA;*, dec: 42 , hex: 2A , oct: 52 , bin: 101010 &#xA;+, dec: 43 , hex: 2B , oct: 53 , bin: 101011 &#xA;,, dec: 44 , hex: 2C , oct: 54 , bin: 101100 &#xA;-, dec: 45 , hex: 2D , oct: 55 , bin: 101101 &#xA;., dec: 46 , hex: 2E , oct: 56 , bin: 101110 &#xA;/, dec: 47 , hex: 2F , oct: 57 , bin: 101111 &#xA;0, dec: 48 , hex: 30 , oct: 60 , bin: 110000 &#xA;1, dec: 49 , hex: 31 , oct: 61 , bin: 110001 &#xA;2, dec: 50 , hex: 32 , oct: 62 , bin: 110010 &#xA;3, dec: 51 , hex: 33 , oct: 63 , bin: 110011 &#xA;4, dec: 52 , hex: 34 , oct: 64 , bin: 110100 &#xA;5, dec: 53 , hex: 35 , oct: 65 , bin: 110101 &#xA;6, dec: 54 , hex: 36 , oct: 66 , bin: 110110 &#xA;7, dec: 55 , hex: 37 , oct: 67 , bin: 110111 &#xA;8, dec: 56 , hex: 38 , oct: 70 , bin: 111000 &#xA;9, dec: 57 , hex: 39 , oct: 71 , bin: 111001 &#xA;:, dec: 58 , hex: 3A , oct: 72 , bin: 111010 &#xA;;, dec: 59 , hex: 3B , oct: 73 , bin: 111011 &#xA;&amp;lt;, dec: 60 , hex: 3C , oct: 74 , bin: 111100 &#xA;=, dec: 61 , hex: 3D , oct: 75 , bin: 111101 &#xA;&amp;gt;, dec: 62 , hex: 3E , oct: 76 , bin: 111110 &#xA;?, dec: 63 , hex: 3F , oct: 77 , bin: 111111 &#xA;@, dec: 64 , hex: 40 , oct: 100 , bin: 1000000 &#xA;A, dec: 65 , hex: 41 , oct: 101 , bin: 1000001 &#xA;B, dec: 66 , hex: 42 , oct: 102 , bin: 1000010 &#xA;C, dec: 67 , hex: 43 , oct: 103 , bin: 1000011 &#xA;D, dec: 68 , hex: 44 , oct: 104 , bin: 1000100 &#xA;E, dec: 69 , hex: 45 , oct: 105 , bin: 1000101 &#xA;F, dec: 70 , hex: 46 , oct: 106 , bin: 1000110 &#xA;G, dec: 71 , hex: 47 , oct: 107 , bin: 1000111 &#xA;H, dec: 72 , hex: 48 , oct: 110 , bin: 1001000 &#xA;I, dec: 73 , hex: 49 , oct: 111 , bin: 1001001 &#xA;J, dec: 74 , hex: 4A , oct: 112 , bin: 1001010 &#xA;K, dec: 75 , hex: 4B , oct: 113 , bin: 1001011 &#xA;L, dec: 76 , hex: 4C , oct: 114 , bin: 1001100 &#xA;M, dec: 77 , hex: 4D , oct: 115 , bin: 1001101 &#xA;N, dec: 78 , hex: 4E , oct: 116 , bin: 1001110 &#xA;O, dec: 79 , hex: 4F , oct: 117 , bin: 1001111 &#xA;P, dec: 80 , hex: 50 , oct: 120 , bin: 1010000 &#xA;Q, dec: 81 , hex: 51 , oct: 121 , bin: 1010001 &#xA;R, dec: 82 , hex: 52 , oct: 122 , bin: 1010010 &#xA;S, dec: 83 , hex: 53 , oct: 123 , bin: 1010011 &#xA;T, dec: 84 , hex: 54 , oct: 124 , bin: 1010100 &#xA;U, dec: 85 , hex: 55 , oct: 125 , bin: 1010101 &#xA;V, dec: 86 , hex: 56 , oct: 126 , bin: 1010110 &#xA;W, dec: 87 , hex: 57 , oct: 127 , bin: 1010111 &#xA;X, dec: 88 , hex: 58 , oct: 130 , bin: 1011000 &#xA;Y, dec: 89 , hex: 59 , oct: 131 , bin: 1011001 &#xA;Z, dec: 90 , hex: 5A , oct: 132 , bin: 1011010 &#xA;[, dec: 91 , hex: 5B , oct: 133 , bin: 1011011 &#xA;\, dec: 92 , hex: 5C , oct: 134 , bin: 1011100 &#xA;], dec: 93 , hex: 5D , oct: 135 , bin: 1011101 &#xA;^, dec: 94 , hex: 5E , oct: 136 , bin: 1011110 &#xA;_, dec: 95 , hex: 5F , oct: 137 , bin: 1011111 &#xA;`, dec: 96 , hex: 60 , oct: 140 , bin: 1100000 &#xA;a, dec: 97 , hex: 61 , oct: 141 , bin: 1100001 &#xA;b, dec: 98 , hex: 62 , oct: 142 , bin: 1100010 &#xA;c, dec: 99 , hex: 63 , oct: 143 , bin: 1100011 &#xA;d, dec: 100 , hex: 64 , oct: 144 , bin: 1100100 &#xA;e, dec: 101 , hex: 65 , oct: 145 , bin: 1100101 &#xA;f, dec: 102 , hex: 66 , oct: 146 , bin: 1100110 &#xA;g, dec: 103 , hex: 67 , oct: 147 , bin: 1100111 &#xA;h, dec: 104 , hex: 68 , oct: 150 , bin: 1101000 &#xA;i, dec: 105 , hex: 69 , oct: 151 , bin: 1101001 &#xA;j, dec: 106 , hex: 6A , oct: 152 , bin: 1101010 &#xA;k, dec: 107 , hex: 6B , oct: 153 , bin: 1101011 &#xA;l, dec: 108 , hex: 6C , oct: 154 , bin: 1101100 &#xA;m, dec: 109 , hex: 6D , oct: 155 , bin: 1101101 &#xA;n, dec: 110 , hex: 6E , oct: 156 , bin: 1101110 &#xA;o, dec: 111 , hex: 6F , oct: 157 , bin: 1101111 &#xA;p, dec: 112 , hex: 70 , oct: 160 , bin: 1110000 &#xA;q, dec: 113 , hex: 71 , oct: 161 , bin: 1110001 &#xA;r, dec: 114 , hex: 72 , oct: 162 , bin: 1110010 &#xA;s, dec: 115 , hex: 73 , oct: 163 , bin: 1110011 &#xA;t, dec: 116 , hex: 74 , oct: 164 , bin: 1110100 &#xA;u, dec: 117 , hex: 75 , oct: 165 , bin: 1110101 &#xA;v, dec: 118 , hex: 76 , oct: 166 , bin: 1110110 &#xA;w, dec: 119 , hex: 77 , oct: 167 , bin: 1110111 &#xA;x, dec: 120 , hex: 78 , oct: 170 , bin: 1111000 &#xA;y, dec: 121 , hex: 79 , oct: 171 , bin: 1111001 &#xA;z, dec: 122 , hex: 7A , oct: 172 , bin: 1111010 &#xA;{, dec: 123 , hex: 7B , oct: 173 , bin: 1111011 &#xA;|, dec: 124 , hex: 7C , oct: 174 , bin: 1111100 &#xA;}, dec: 125 , hex: 7D , oct: 175 , bin: 1111101 &#xA;~, dec: 126 , hex: 7E , oct: 176 , bin: 1111110 &#xA; ok&#xA;&amp;gt; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I suspect your issue is you are not using it the way it is supposed to be used. Can you show the exact commands you type which cause the error?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Edited to add)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After fairly extensive investigation of the source, I think that &lt;code&gt;.s&lt;/code&gt; is not necessarily implemented for the Uno .hex file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found one suggested implementation &lt;a href=&quot;https://www.mail-archive.com/search?l=amforth-devel@lists.sourceforge.net&amp;amp;q=subject:%22Re%3A+[Amforth]+.S+%E2%80%9Cdot-s%E2%80%9D%22&amp;amp;o=newest&amp;amp;f=1&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-forth prettyprint-override&quot;&gt;&lt;code&gt;: .s  ( -- )\ stack picture listing order&#xA;depth&#xA;begin dup while dup pick . 1- repeat&#xA;drop&#xA;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Running that it seems to work OK:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; 1 2 3 4 .s&#xA;1 2 3 4  ok&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;.s&lt;/code&gt; word is implemented in the file &lt;code&gt;dot-s.asm&lt;/code&gt; where you can see exactly how they did it (it's not the same as the Forth version above).&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-08T22:48:35.737" LastActivityDate="2016-06-08T22:48:35.737" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25025" PostTypeId="1" CreationDate="2016-06-08T21:35:20.613" Score="5" ViewCount="6878" Body="&lt;p&gt;Looking at &lt;a href=&quot;https://learn.sparkfun.com/tutorials/arduino-comparison-guide&quot; rel=&quot;noreferrer&quot; title=&quot;Sparkfun comparsion&quot;&gt;the Sparkfun comparison&lt;/a&gt;, it seems that the Due is by far the fastest of the Arduinos and has I/O capabilities similar to the Mega. So why was it retired with no obvious successor?&lt;/p&gt;&#xA;" OwnerUserId="22845" LastActivityDate="2016-06-09T07:57:07.147" Title="Why was the Due retired?" Tags="|arduino-due|" AnswerCount="2" CommentCount="5" ClosedDate="2016-06-13T18:56:25.420" ContentLicense="CC BY-SA 3.0" />
  <row Id="25026" PostTypeId="2" ParentId="25017" CreationDate="2016-06-08T21:52:21.543" Score="-1" Body="&lt;p&gt;&lt;em&gt;Made corrections per @Majenko's comment&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following will &lt;strong&gt;not&lt;/strong&gt; work on real Arduinos, but it did work for me on the ESP8266 and the Teensy3, which are what I use mostly, and the only ones I tested the code for: &lt;a href=&quot;https://github.com/jayeye/jardino/tree/master/esp8266/ase25017&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jayeye/jardino/tree/master/esp8266/ase25017&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;vector&amp;gt;&#xA;  ...&#xA;  size_t vector_size = 42;&#xA;  std::vector&amp;lt;int&amp;gt; foo(vector_size);  // foo is a vector of 42 integers&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Another correction:&lt;/strong&gt; Exceptions do not work even on the aforementioned platforms, so do not access the vector with &lt;code&gt;.at(n)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you &lt;em&gt;must&lt;/em&gt; have an array, use a unique_ptr with an array allocator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;memory&amp;gt;&#xA;  ...&#xA;  size_t vector_size = 42;&#xA;  std::unique_ptr&amp;lt;int[]&amp;gt; arr(new int[vector_size]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;arr&lt;/code&gt; goes out of scope, the array will be automatically freed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can always use malloc(), but you'll have to remember to free() it, and that's always a source of bugs.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastEditorUserId="10024" LastEditDate="2016-06-09T18:04:26.603" LastActivityDate="2016-06-09T18:04:26.603" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25027" PostTypeId="2" ParentId="25025" CreationDate="2016-06-08T22:45:01.667" Score="1" Body="&lt;p&gt;Because, basically (in my opinion, anyway) it was rubbish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it has grunt. Yes, it has IO, but the chips themselves are pretty rancid.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are far better options than the SAM3X from other manufacturers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, since all the in-fighting began between the two Arduino factions (.org / .cc) the majority of actual progress and innovation has been by third parties (Intel mostly).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-08T22:45:01.667" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25029" PostTypeId="2" ParentId="24998" CreationDate="2016-06-09T05:24:04.523" Score="2" Body="&lt;p&gt;A more low-tech solution might be better. For example, a couple of light beams across the doorway to the kitchen. An human would block both of them as they passed, and a dog only the lower one. You could sound an alarm if the lower one is broken, and the upper one is not broken (within a second).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Or do something with infra-red transmitters / receivers. There are lots of Arduino projects using those. You could have a transmitter in the kitchen pointing towards the doorway, sending some code (eg. 1234). Mount on the dog an Arduino with an IR decoder sketch. When the dog enters the kitchen it will get the code, and then you could sound a beeper. The beeper alone might make the dog change its mind about going in, especially if you go after it yelling &quot;bad dog!&quot; every time the beeper goes off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the IR beam is just light, it would only go in a straight line, and if properly positioned would flood the kitchen, but not hit anywhere else.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Proof of concept&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I made up a test of my idea of the IR transmitter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(Please don't report me to the moderators for being off-topic. I know the question was about a GPS, but the &lt;strong&gt;real&lt;/strong&gt; question is how to detect that the dog has come into the kitchen).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get IR (infra-red) LEDs cheaply at any electronics supplier (or eBay). They are like normal LEDs except that they transmit in the IR light range. They can also usually handle higher currents, like 80 mA.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sender&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;So, to drive that from the Arduino we need a transistor to boost the output from the Arduino pin, like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZF3ps.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZF3ps.png&quot; alt=&quot;IR driver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the positive pin of the LED will have a longer lead. The positive pin goes to the 39 ohm resistor, and the negative (shorter) lead goes to the transistor collector. In the schematic the negative pin (cathode) is at the bottom and has a horizontal line (think of the horizontal line as a minus sign).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 39 ohm resistor limits current through the LED to 74 mA. Assuming a LED forward voltage of 2.1V we have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; (5V - 2.1V) / 39Ω = 74 mA&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The 470 ohm resistor limits current through the transistor base.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Sender code&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Then some simple code to send a IR code (using PWM modulation like TV remotes do). There is a library for that, so the code is very simple:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;IRLib.h&amp;gt;&#xA;&#xA;IRsend My_Sender;&#xA;&#xA;const unsigned long DOG_ALERT_CODE = 0xBADA;&#xA;&#xA;void setup()&#xA;  {&#xA;  }&#xA;&#xA;void loop() &#xA;  {&#xA;  My_Sender.send (NEC, DOG_ALERT_CODE, 20); &#xA;  delay (1000);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That sends the code 0xBADA (which I just picked at random) every second using the NEC IR protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The objective would be to have this plugged into the power somewhere in the kitchen, and aimed at the doorway. The IR library uses digital pin 3 (on the Uno at least). That happens to be the Timer 2 &quot;B&quot; output to send 38 kHz PWM (pulse-width-modulated) signal, which it interrupts from time to time to encode the code into it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Receiver&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;Now we need something on the dog to detect the IR code. The objective is to notice the code above (eg. 0xBADA) and if found, sound a tone on a speaker, otherwise ignore it. That way we can still use remotes in the kitchen, and the speaker won't sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6WURi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6WURi.png&quot; alt=&quot;IR Receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code for the receiver is a bit more complex, but not much:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRLib.h&amp;gt;&#xA;#include &amp;lt;TonePlayer.h&amp;gt;&#xA;&#xA;const byte SPEAKER = 9;  // output pin is fixed (OC1A)&#xA;const byte IR_READER = 11;&#xA;const unsigned long BEEP_WIDTH = 50;&#xA;const int BEEP_FREQUENCY = 880;  // Hz&#xA;const unsigned long DOG_ALERT_CODE = 0xBADA;&#xA;&#xA;// pin D9 (Uno), D11 (Mega)&#xA;TonePlayer tone1 (TCCR1A, TCCR1B, OCR1AH, OCR1AL, TCNT1H, TCNT1L);  &#xA;&#xA;IRrecv My_Receiver(IR_READER); &#xA;IRdecode My_Decoder;&#xA;&#xA;void setup()&#xA;  {&#xA;  My_Receiver.enableIRIn(); // Start the receiver&#xA;  pinMode (SPEAKER, OUTPUT);  &#xA;  }&#xA;&#xA;unsigned long lastTone;&#xA;&#xA;void loop()&#xA;  {&#xA;  if (My_Receiver.GetResults(&amp;amp;My_Decoder)) &#xA;    {&#xA;    My_Decoder.decode();&#xA;    if (My_Decoder.decode_type == NEC)&#xA;      {&#xA;      if (My_Decoder.value == DOG_ALERT_CODE)&#xA;        {&#xA;        tone1.tone (BEEP_FREQUENCY);&#xA;        lastTone = millis ();&#xA;        }  // end of wanted code&#xA;      }  // end of NEC type&#xA;      My_Receiver.resume();&#xA;    }  // end of if we got a result&#xA;&#xA;    // if time up, stop the beep&#xA;    if (millis () - lastTone &amp;gt;= BEEP_WIDTH)&#xA;      tone1.noTone ();&#xA;&#xA;  } // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also uses the IR library, this time to detect an incoming code. You wire the &quot;Data&quot; pin of the IR detector to digital pin 11 on the Arduino (Uno or similar). The other two pins of the IR detector go to Ground and +5V as marked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To play a sound get a small piezo speaker and wire that to digital pin 9 (one side) and Ground (other side).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of the way that the IR library uses interrupts, I had to use my own Tone library to generate a tone. You can download that from:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/Arduino/TonePlayer.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.gammon.com.au/Arduino/TonePlayer.zip&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Testing&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;How well did it work? Certainly at short distances (like three feet or one metre) we got a positive result. There could be variance based on the light conditions in the room, and the exact parts you get.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to read the &lt;a href=&quot;https://learn.adafruit.com/tv-b-gone-kit/design-notes&quot; rel=&quot;nofollow noreferrer&quot;&gt;design notes for TV B Gone&lt;/a&gt; where they discuss the technicalities of sending IR beams. In particular for their design they used &lt;strong&gt;four&lt;/strong&gt; IR LEDs to give adequate range. You could add more LEDs by duplicating the transistor driver shown above a few times. In other words, duplicate the transistors, LEDs and resistors. They could all be driven from the same output pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As mentioned in the TV B Gone article, you can get different IR LEDs. Some have a narrow beam, but go further, others have a wider beam, but go less far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you could arrange them to point in slightly different directions to cover more of the room.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also change the length of the beep when the code is detected (BEEP_WIDTH) in milliseconds. And also the frequency (BEEP_FREQUENCY) which I had at 880 Hz. A higher frequency might annoy the dog more but be less audible to humans. I suppose it depends if you want the dog to hear it or the people in the house.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Hardware size and power&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You probably want a small Arduino (like a Nano) which is physically quite small. Also powering it could be an issue. You could get 3 x AA batteries, which would nominally output around 4.5V, and connect them directly to the +5V pin of the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To save battery power you could have the Arduino sleep for (say) a second, wake and eheck for a code, and then sleep again. See my post about power savings for more details about that sort of thing.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Hardware photos&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CSEqi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CSEqi.jpg&quot; alt=&quot;IR Transmitter and receiver&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/slBY3.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/slBY3.jpg&quot; alt=&quot;Piezo speaker&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-09T23:18:22.627" LastActivityDate="2016-06-09T23:18:22.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25031" PostTypeId="1" CreationDate="2016-06-09T05:37:40.717" Score="2" ViewCount="1296" Body="&lt;p&gt;I have simple code working on Serial Communication asn below. With Same data i would impliment Modbus protocol&gt; I have Used Modbus library for arduino earlier which works fine with 9600 baudrate and wont work with higher baudrates.And also have restriction In library ,They directly storing values into Buffers SO i cant able to fig out weather request send proper or improper.&#xA;I never Worked on EMbeded c Chip level code.Is there any way to Implement without library for arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In below code I would Like Serial value into register and when function called i could read value. Similarly the &lt;strong&gt;function CODE&lt;/strong&gt; for Modbus should be implemented.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am looking for simple c code or implement c code Where i can perform the operation this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to Send modbus Request &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found CRC error calculation like in one of forum&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; unsigned int crc_fn(unsigned char *dpacket,unsigned int len)    // CRC 16 Function(Error calculation)&#xA;    {&#xA;        unsigned int crc = 0xffff,poly = 0xa001;&#xA;        unsigned char i=0,j=0;&#xA;&#xA;        for(i=0;i&amp;lt;len;i++)&#xA;        {&#xA;            crc^= dpacket[i];&#xA;            for(j=0;j&amp;lt;8;j++)&#xA;            {&#xA;                if(crc &amp;amp; 0x01)&#xA;                {&#xA;                    crc &amp;gt;&amp;gt;= 1;&#xA;                    crc ^= poly;&#xA;                }&#xA;                else&#xA;                crc &amp;gt;&amp;gt;= 1;&#xA;            }&#xA;        }&#xA;        return (crc);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I would like to See my code in arduino Like this With CRC check&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Serial_access(void)&#xA;{&#xA;    unsigned char i=0,len=0,ser_data[60],crc_data[60],j=0;&#xA;    unsigned int crc1=0,crc2=0;&#xA;    crc1 = crc_fn(&amp;amp;rxbuf[0],6);&#xA;    _delay_ms(100);&#xA;    if((rxbuf[6] == (unsigned char)(crc1))&amp;amp;&amp;amp;(rxbuf[7] == (unsigned char)(crc1&amp;gt;&amp;gt;8)))&#xA;    {&#xA;        if(rxbuf[0]==DEVICE_ID)&#xA;        {&#xA;            if(rxbuf[1] == Function_code)&#xA;            {&#xA;                if((rxbuf[5]&amp;gt;=1)&amp;amp;&amp;amp;(rxbuf[5]&amp;lt;30))&#xA;                {&#xA;                    //Address = ((unsigned int)(rxbuf[2]&amp;lt;&amp;lt;8)+((unsigned int)(rxbuf[3])));&#xA;                    len = (rxbuf[5]*2);&#xA;                    _delay_ms(10);&#xA;                    ser_data[0] = 0;&#xA;                    ser_data[1] = 0;&#xA;                    ser_data[2] = 0;&#xA;                    ser_data[3] = 0;&#xA;                    ser_data[4] = 0;&#xA;                    ser_data[5] = 0;&#xA;                    ser_data[6] = 0;&#xA;                    ser_data[7] = 0;&#xA;                    ser_data[8] = 0;&#xA;                    ser_data[9] = 0;&#xA;                    ser_data[10] = 0;&#xA;                    ser_data[11] = 0;&#xA;                    ser_data[12] = 0;&#xA;                    ser_data[13] = 0;&#xA;                    ser_data[14] = 0;&#xA;                    ser_data[15] = 0;&#xA;                    ser_data[16] = 0;&#xA;                    ser_data[17] = 0;&#xA;                    ser_data[18] = 0;&#xA;                    ser_data[19] = 0;&#xA;                    ser_data[20] = 0;&#xA;                    ser_data[21] = 0;&#xA;                    ser_data[22] = 0;&#xA;                    ser_data[23] = 0;&#xA;                    ser_data[24] = 0;&#xA;                    ser_data[25] = 0;&#xA;                    ser_data[26] = 0;&#xA;                    ser_data[27] = 0;&#xA;                    ser_data[28] = 0;&#xA;                    ser_data[29] = 0;&#xA;                    ser_data[30] = 0;&#xA;                    ser_data[31] = 0;&#xA;                    ser_data[32] = 0;&#xA;                    ser_data[33] = 0;&#xA;                    ser_data[34] = 0;&#xA;                    ser_data[35] = 0;&#xA;                    ser_data[36] = 0;&#xA;                    ser_data[37] = 0;&#xA;                    ser_data[38] = 0;&#xA;                    ser_data[39] = 0;&#xA;                    ser_data[40] = 0;&#xA;                    ser_data[41] = 0;&#xA;                    ser_data[42] = 0;&#xA;                    ser_data[43] = 0;&#xA;                    ser_data[44] = 0;&#xA;                    ser_data[45] = 0;&#xA;                    ser_data[46] = 0;&#xA;                    ser_data[47] = 0;&#xA;                    ser_data[48] = 0;&#xA;                    ser_data[49] = 0;&#xA;                    ser_data[50] = 0;&#xA;                    ser_data[51] = 0;&#xA;                    ser_data[52] = 0;&#xA;                    ser_data[53] = 0;&#xA;                    ser_data[54] = 0;&#xA;                    ser_data[55] = 0;&#xA;                    ser_data[56] = 0;&#xA;                    ser_data[57] = 0;&#xA;                    ser_data[58] = 0;&#xA;&#xA;                    crc_data[0] = DEVICE_ID;&#xA;                    crc_data[1] = Function_code;&#xA;                    crc_data[2] = len;&#xA;&#xA;                    j=3;&#xA;                    for(i=0;i&amp;lt;len;i++)&#xA;                    {&#xA;                        crc_data[j++] = ser_data[i];&#xA;                    }&#xA;                    crc2 = crc_fn(&amp;amp;crc_data[0],(len+3));&#xA;                    _delay_ms(100);&#xA;                    serial_send(DEVICE_ID);&#xA;                    serial_send(Function_code);&#xA;                    serial_send(len);&#xA;                    for(i=0;i&amp;lt;len;i++)&#xA;                    {&#xA;                        serial_send(ser_data[i]);&#xA;                    }&#xA;                    _delay_ms(10);&#xA;                    serial_send((unsigned char)(crc2));&#xA;                    serial_send((unsigned char)(crc2&amp;gt;&amp;gt;8));&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;    index = 0;&#xA;    for(i=0;i&amp;lt;16;i++)&#xA;        rxbuf[i] = 0;&#xA;    rec_flag = 0;&#xA;    check_flag = 1; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here code written in C++, How can we convert these to C&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t Modbus::query( modbus_t telegram ) {&#xA;  uint8_t u8regsno, u8bytesno;&#xA;  if (u8id != 0) return -2;&#xA;  if (u8state != COM_IDLE) return -1;&#xA;&#xA;  if ((telegram.u8id == 0) || (telegram.u8id &amp;gt; 247)) return -3;&#xA;&#xA;  au16regs = telegram.au16reg;&#xA;&#xA;  // telegram header&#xA;  au8Buffer[ ID ]         = telegram.u8id;&#xA;  au8Buffer[ FUNC ]       = telegram.u8fct;&#xA;  au8Buffer[ ADD_HI ]     = highByte(telegram.u16RegAdd );&#xA;  au8Buffer[ ADD_LO ]     = lowByte( telegram.u16RegAdd );&#xA;&#xA;  switch ( telegram.u8fct ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;  case MB_FC_READ_REGISTERS:&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    au8Buffer[ NB_HI ]      = ((au16regs[0] &amp;gt; 0) ? 0xff : 0);&#xA;    au8Buffer[ NB_LO ]      = 0;&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER:&#xA;    au8Buffer[ NB_HI ]      = highByte(au16regs[0]);&#xA;    au8Buffer[ NB_LO ]      = lowByte(au16regs[0]);&#xA;    u8BufferSize = 6;&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    u8regsno = telegram.u16CoilsNo / 16;&#xA;    u8bytesno = u8regsno * 2;&#xA;    if ((telegram.u16CoilsNo % 16) != 0) {&#xA;      u8bytesno++;&#xA;      u8regsno++;&#xA;    }&#xA;&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO + 1 ]    = u8bytesno;&#xA;    u8BufferSize = 7;&#xA;&#xA;    u8regsno = u8bytesno = 0; // now auxiliary registers&#xA;    for (uint16_t i = 0; i &amp;lt; telegram.u16CoilsNo; i++) {&#xA;&#xA;&#xA;    }&#xA;    break;&#xA;&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS:&#xA;    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );&#xA;    au8Buffer[ NB_LO + 1 ]    = (uint8_t) ( telegram.u16CoilsNo * 2 );&#xA;    u8BufferSize = 7;&#xA;&#xA;    for (uint16_t i = 0; i &amp;lt; telegram.u16CoilsNo; i++) {&#xA;      au8Buffer[ u8BufferSize ] = highByte( au16regs[ i ] );&#xA;      u8BufferSize++;&#xA;      au8Buffer[ u8BufferSize ] = lowByte( au16regs[ i ] );&#xA;      u8BufferSize++;&#xA;    }&#xA;    break;&#xA;  }&#xA;&#xA;  sendTxBuffer();&#xA;  u8state = COM_WAITING;&#xA;  return 0;&#xA;}&#xA;&#xA;int8_t Modbus::poll() {&#xA;  // check if there is any incoming frame&#xA;  uint8_t u8current = port-&amp;gt;available();&#xA;&#xA;  if (millis() &amp;gt; u32timeOut) {&#xA;    u8state = COM_IDLE;&#xA;    u16errCnt++;&#xA;    return 0;&#xA;  }&#xA;&#xA;  if (u8current == 0) return 0;&#xA;&#xA;  // check T35 after frame end or still no frame end&#xA;  if (u8current != u8lastRec) {&#xA;    u8lastRec = u8current;&#xA;    u32time = millis() + T35;&#xA;    return 0;&#xA;  }&#xA;  if (millis() &amp;lt; u32time) return 0;&#xA;&#xA;  // transfer Serial buffer frame to auBuffer&#xA;  u8lastRec = 0;&#xA;  int8_t i8state = getRxBuffer();&#xA;  if (i8state &amp;lt; 7) {&#xA;    u8state = COM_IDLE;&#xA;    u16errCnt++;&#xA;    return i8state;&#xA;  }&#xA;&#xA;  // validate message: id, CRC, FCT, exception&#xA;  uint8_t u8exception = validateAnswer();&#xA;  if (u8exception != 0) {&#xA;    u8state = COM_IDLE;&#xA;    return u8exception;&#xA;  }&#xA;&#xA;  // process answer&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;    // call get_FC1 to transfer the incoming message to au16regs buffer&#xA;   // get_FC1( );&#xA;    break;&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;  case MB_FC_READ_REGISTERS :&#xA;    // call get_FC3 to transfer the incoming message to au16regs buffer&#xA;    get_FC3( );&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;  case MB_FC_WRITE_REGISTER :&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    // nothing to do&#xA;    break;&#xA;  default:&#xA;    break;&#xA;  }&#xA;  u8state = COM_IDLE;&#xA;  return u8BufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::poll( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  au16regs = regs;&#xA;  u8regsize = u8size;&#xA;&#xA;  // check if there is any incoming frame&#xA;  uint8_t u8current = port-&amp;gt;available();&#xA;  if (u8current == 0) return 0;&#xA;&#xA;  // check T35 after frame end or still no frame end&#xA;  if (u8current != u8lastRec) {&#xA;    u8lastRec = u8current;&#xA;    u32time = millis() + T35;&#xA;    return 0;&#xA;  }&#xA;  if (millis() &amp;lt; u32time) return 0;&#xA;&#xA;  u8lastRec = 0;&#xA;  int8_t i8state = getRxBuffer();&#xA;  if (i8state &amp;lt; 7) return i8state;&#xA;&#xA;  // check slave id&#xA;  if (au8Buffer[ ID ] != u8id) return 0;&#xA;&#xA;  // validate message: CRC, FCT, address and size&#xA;  uint8_t u8exception = validateRequest();&#xA;  if (u8exception &amp;gt; 0) {&#xA;    if (u8exception != NO_REPLY) {&#xA;      buildException( u8exception );&#xA;      sendTxBuffer();&#xA;    }&#xA;    return u8exception;&#xA;  }&#xA;&#xA;  u32timeOut = millis() + long(u16timeOut);&#xA;&#xA;  // process message&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;    return process_FC1( regs, u8size );&#xA;    break;&#xA;  case MB_FC_READ_INPUT_REGISTER:&#xA;  case MB_FC_READ_REGISTERS :&#xA;    return process_FC3( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    return process_FC5( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER :&#xA;    return process_FC6( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    return process_FC15( regs, u8size );&#xA;    break;&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    return process_FC16( regs, u8size );&#xA;    break;&#xA;  default:&#xA;    break;&#xA;  }&#xA;}&#xA;&#xA;void Modbus::init(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) {&#xA;  this-&amp;gt;u8id = u8id;&#xA;  this-&amp;gt;u8serno = (u8serno &amp;gt; 3) ? 0 : u8serno;&#xA;  this-&amp;gt;u8txenpin = u8txenpin;&#xA;  this-&amp;gt;u16timeOut = 1000;// intially set for 1000&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::getRxBuffer() {&#xA;  boolean bBuffOverflow = false;&#xA;&#xA;  if (u8txenpin &amp;gt; 1) digitalWrite( u8txenpin, LOW );&#xA;&#xA;  u8BufferSize = 0;&#xA;  while ( port-&amp;gt;available() ) {&#xA;    au8Buffer[ u8BufferSize ] = port-&amp;gt;read();&#xA;    u8BufferSize ++;&#xA;&#xA;    if (u8BufferSize &amp;gt;= MAX_BUFFER) bBuffOverflow = true;&#xA;  }&#xA;  u16InCnt++;&#xA;&#xA;  if (bBuffOverflow) {&#xA;    u16errCnt++;&#xA;    return ERR_BUFF_OVERFLOW;&#xA;  }&#xA;  u32timeOut=500;&#xA;   // u32timeOut = millis() + (unsigned long) u16timeOut;&#xA;  return u8BufferSize;&#xA;}&#xA;&#xA;&#xA;void Modbus::sendTxBuffer() {&#xA;  uint8_t i = 0;&#xA;&#xA;  // append CRC to message&#xA;  uint16_t u16crc = calcCRC( u8BufferSize );&#xA;  au8Buffer[ u8BufferSize ] = u16crc &amp;gt;&amp;gt; 8;&#xA;  u8BufferSize++;&#xA;  au8Buffer[ u8BufferSize ] = u16crc &amp;amp; 0x00ff;&#xA;  u8BufferSize++;&#xA;&#xA;  // set RS485 transceiver to transmit mode&#xA;  if (u8txenpin &amp;gt; 1) {&#xA;    switch ( u8serno ) {&#xA;#if defined(UBRR1H)&#xA;    case 1:&#xA;      UCSR1A = UCSR1A | (1 &amp;lt;&amp;lt; TXC1);&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR2H)&#xA;    case 2:&#xA;      UCSR2A = UCSR2A | (1 &amp;lt;&amp;lt; TXC2);&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR3H)&#xA;    case 3:&#xA;      UCSR3A = UCSR3A | (1 &amp;lt;&amp;lt; TXC3);&#xA;      break;&#xA;#endif&#xA;    case 0:&#xA;    default:&#xA;      UCSR0A = UCSR0A | (1 &amp;lt;&amp;lt; TXC0);&#xA;      break;&#xA;    }&#xA;    digitalWrite( u8txenpin, HIGH );&#xA;  }&#xA;&#xA;  // transfer buffer to serial line&#xA;  port-&amp;gt;write( au8Buffer, u8BufferSize );&#xA;&#xA;  // keep RS485 transceiver in transmit mode as long as sending&#xA;  if (u8txenpin &amp;gt; 1) {&#xA;    switch ( u8serno ) {&#xA;#if defined(UBRR1H)&#xA;    case 1:&#xA;      while (!(UCSR1A &amp;amp; (1 &amp;lt;&amp;lt; TXC1)));&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR2H)&#xA;    case 2:&#xA;      while (!(UCSR2A &amp;amp; (1 &amp;lt;&amp;lt; TXC2)));&#xA;      break;&#xA;#endif&#xA;&#xA;#if defined(UBRR3H)&#xA;    case 3:&#xA;      while (!(UCSR3A &amp;amp; (1 &amp;lt;&amp;lt; TXC3)));&#xA;      break;&#xA;#endif&#xA;    case 0:&#xA;    default:&#xA;      while (!(UCSR0A &amp;amp; (1 &amp;lt;&amp;lt; TXC0)));&#xA;      break;&#xA;    }&#xA;&#xA;    // return RS485 transceiver to receive mode&#xA;    digitalWrite( u8txenpin, LOW );&#xA;  }&#xA;  port-&amp;gt;flush();&#xA;  u8BufferSize = 0;&#xA;&#xA;  // set time-out for master&#xA;//  u32timeOut = millis() + (unsigned long) u16timeOut;&#xA; u32timeOut=500;&#xA;  // increase message counter&#xA;  u16OutCnt++;&#xA;}&#xA;&#xA;&#xA;&#xA;uint16_t Modbus::calcCRC(uint8_t u8length) {&#xA;  unsigned int temp, temp2, flag;&#xA;  temp = 0xFFFF;&#xA;  for (unsigned char i = 0; i &amp;lt; u8length; i++) {&#xA;    temp = temp ^ au8Buffer[i];&#xA;    for (unsigned char j = 1; j &amp;lt;= 8; j++) {&#xA;      flag = temp &amp;amp; 0x0001;&#xA;      temp &amp;gt;&amp;gt;= 1;&#xA;      if (flag)&#xA;        temp ^= 0xA001;&#xA;    }&#xA;  }&#xA;  // Reverse byte order.&#xA;  temp2 = temp &amp;gt;&amp;gt; 8;&#xA;  temp = (temp &amp;lt;&amp;lt; 8) | temp2;&#xA;  temp &amp;amp;= 0xFFFF;&#xA;  // the returned value is already swapped&#xA;  // crcLo byte is first &amp;amp; crcHi byte is last&#xA;  return temp;&#xA;}&#xA;&#xA;uint8_t Modbus::validateRequest() {&#xA;  // check message crc vs calculated crc&#xA;  uint16_t u16MsgCRC =&#xA;    ((au8Buffer[u8BufferSize - 2] &amp;lt;&amp;lt; 8)&#xA;    | au8Buffer[u8BufferSize - 1]); // combine the crc Low &amp;amp; High bytes&#xA;  if ( calcCRC( u8BufferSize - 2 ) != u16MsgCRC ) {&#xA;    u16errCnt ++;&#xA;    return NO_REPLY;&#xA;  }&#xA;&#xA;  // check fct code&#xA;  boolean isSupported = false;&#xA;  for (uint8_t i = 0; i &amp;lt; sizeof( fctsupported ); i++) {&#xA;    if (fctsupported[i] == au8Buffer[FUNC]) {&#xA;      isSupported = 1;&#xA;      break;&#xA;    }&#xA;  }&#xA;  if (!isSupported) {&#xA;    u16errCnt ++;&#xA;    return EXC_FUNC_CODE;&#xA;  }&#xA;&#xA;  // check start address &amp;amp; nb range&#xA; // uint16_t u16regs = 4000;&#xA; uint16_t u16regs = 0;&#xA;  uint8_t u8regs;&#xA;  switch ( au8Buffer[ FUNC ] ) {&#xA;  case MB_FC_READ_COILS:&#xA;  case MB_FC_READ_DISCRETE_INPUT:&#xA;  case MB_FC_WRITE_MULTIPLE_COILS:&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;&#xA;    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]) / 16;&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_WRITE_COIL:&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_WRITE_REGISTER :&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  case MB_FC_READ_REGISTERS :&#xA;  case MB_FC_READ_INPUT_REGISTER :&#xA;  case MB_FC_WRITE_MULTIPLE_REGISTERS :&#xA;    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);&#xA;    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]);&#xA;    u8regs = (uint8_t) u16regs;&#xA;    if (u8regs &amp;gt; u8regsize) return EXC_ADDR_RANGE;&#xA;    break;&#xA;  }&#xA;  return 0; // OK, no exception code thrown&#xA;}&#xA;&#xA;&#xA;uint8_t Modbus::validateAnswer() {&#xA;  // check message crc vs calculated crc&#xA;  uint16_t u16MsgCRC =&#xA;    ((au8Buffer[u8BufferSize - 2] &amp;lt;&amp;lt; 8)&#xA;    | au8Buffer[u8BufferSize - 1]); // combine the crc Low &amp;amp; High bytes&#xA;  if ( calcCRC( u8BufferSize - 2 ) != u16MsgCRC ) {&#xA;    u16errCnt ++;&#xA;    return NO_REPLY;&#xA;  }&#xA;&#xA;  // check exception&#xA;  if ((au8Buffer[ FUNC ] &amp;amp; 0x80) != 0) {&#xA;    u16errCnt ++;&#xA;    return ERR_EXCEPTION;&#xA;  }&#xA;&#xA;  // check fct code&#xA;  boolean isSupported = false;&#xA;  for (uint8_t i = 0; i &amp;lt; sizeof( fctsupported ); i++) {&#xA;    if (fctsupported[i] == au8Buffer[FUNC]) {&#xA;      isSupported = 1;&#xA;      break;&#xA;    }&#xA;  }&#xA;  if (!isSupported) {&#xA;    u16errCnt ++;&#xA;    return EXC_FUNC_CODE;&#xA;  }&#xA;&#xA;  return 0; // OK, no exception code thrown&#xA;}&#xA;&#xA;&#xA;void Modbus::buildException( uint8_t u8exception ) {&#xA;  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code&#xA;&#xA;  au8Buffer[ ID ]      = u8id;&#xA;  au8Buffer[ FUNC ]    = u8func + 0x80;&#xA;  au8Buffer[ 2 ]       = u8exception;&#xA;  u8BufferSize         = EXCEPTION_SIZE;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The functionality Check&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Modbus::get_FC3() {&#xA;  uint8_t u8byte, i;&#xA;  u8byte = 3;&#xA;&#xA;  for (i = 0; i &amp;lt; au8Buffer[ 2 ] / 2; i++) {&#xA;    au16regs[ i ] = word(&#xA;    au8Buffer[ u8byte ],&#xA;    au8Buffer[ u8byte + 1 ]);&#xA;    u8byte += 2;&#xA;  }&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC1( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit, u8bytesno, u8bitsno;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16currentCoil, u16coil;&#xA;&#xA;  // get the first and last coil from the message&#xA;  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;  // put the number of bytes in the outcoming message&#xA;  u8bytesno = (uint8_t) (u16Coilno / 8);&#xA;  if (u16Coilno % 8 != 0) u8bytesno ++;&#xA;  au8Buffer[ ADD_HI ]  = u8bytesno;&#xA;  u8BufferSize         = ADD_LO;&#xA;&#xA;  // read each coil from the register map and put its value inside the outcoming message&#xA;  u8bitsno = 0;&#xA;&#xA;  for (u16currentCoil = 0; u16currentCoil &amp;lt; u16Coilno; u16currentCoil++) {&#xA;    u16coil = u16StartCoil + u16currentCoil;&#xA;    u8currentRegister = (uint8_t) (u16coil / 16);&#xA;    u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;    bitWrite(&#xA;    au8Buffer[ u8BufferSize ],&#xA;    u8bitsno,&#xA;    bitRead( regs[ u8currentRegister ], u8currentBit ) );&#xA;    u8bitsno ++;&#xA;&#xA;    if (u8bitsno &amp;gt; 7) {&#xA;      u8bitsno = 0;&#xA;      u8BufferSize++;&#xA;    }&#xA;  }&#xA;&#xA;  // send outcoming message&#xA;  if (u16Coilno % 8 != 0) u8BufferSize ++;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;int8_t Modbus::process_FC3( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  uint8_t u8StartAdd = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint8_t u8regsno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint8_t i;&#xA;&#xA;  au8Buffer[ 2 ]       = u8regsno * 2;&#xA;  u8BufferSize         = 3;&#xA;&#xA;  for (i = u8StartAdd; i &amp;lt; u8StartAdd + u8regsno; i++) {&#xA;    au8Buffer[ u8BufferSize ] = highByte(regs[i]);&#xA;    u8BufferSize++;&#xA;    au8Buffer[ u8BufferSize ] = lowByte(regs[i]);&#xA;    u8BufferSize++;&#xA;  }&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC5( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16coil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;&#xA;  // point to the register and its bit&#xA;  u8currentRegister = (uint8_t) (u16coil / 16);&#xA;  u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;  // write to coil&#xA;  bitWrite(&#xA;  regs[ u8currentRegister ],&#xA;  u8currentBit,&#xA;  au8Buffer[ NB_HI ] == 0xff );&#xA;&#xA;&#xA;  // send answer to master&#xA;  u8BufferSize = 6;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC6( uint16_t *regs, uint8_t u8size ) {&#xA;&#xA;  uint8_t u8add = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16val = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;  regs[ u8add ] = u16val;&#xA;&#xA;  // keep the same header&#xA;  u8BufferSize         = RESPONSE_SIZE;&#xA;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC15( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8currentRegister, u8currentBit, u8frameByte, u8bitsno;&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint16_t u16currentCoil, u16coil;&#xA;  boolean bTemp;&#xA;&#xA;  // get the first and last coil from the message&#xA;  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );&#xA;  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );&#xA;&#xA;&#xA;  // read each coil from the register map and put its value inside the outcoming message&#xA;  u8bitsno = 0;&#xA;  u8frameByte = 7;&#xA;  for (u16currentCoil = 0; u16currentCoil &amp;lt; u16Coilno; u16currentCoil++) {&#xA;&#xA;    u16coil = u16StartCoil + u16currentCoil;&#xA;    u8currentRegister = (uint8_t) (u16coil / 16);&#xA;    u8currentBit = (uint8_t) (u16coil % 16);&#xA;&#xA;    bTemp = bitRead(&#xA;    au8Buffer[ u8frameByte ],&#xA;    u8bitsno );&#xA;&#xA;    bitWrite(&#xA;    regs[ u8currentRegister ],&#xA;    u8currentBit,&#xA;    bTemp );&#xA;&#xA;    u8bitsno ++;&#xA;&#xA;    if (u8bitsno &amp;gt; 7) {&#xA;      u8bitsno = 0;&#xA;      u8frameByte++;&#xA;    }&#xA;  }&#xA;&#xA;  // send outcoming message&#xA;  // it's just a copy of the incomping frame until 6th byte&#xA;  u8BufferSize         = 6;&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&#xA;&#xA;int8_t Modbus::process_FC16( uint16_t *regs, uint8_t u8size ) {&#xA;  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code&#xA;  uint8_t u8StartAdd = au8Buffer[ ADD_HI ] &amp;lt;&amp;lt; 8 | au8Buffer[ ADD_LO ];&#xA;  uint8_t u8regsno = au8Buffer[ NB_HI ] &amp;lt;&amp;lt; 8 | au8Buffer[ NB_LO ];&#xA;  uint8_t u8CopyBufferSize;&#xA;  uint8_t i;&#xA;  uint16_t temp;&#xA;&#xA;  // build header&#xA;  au8Buffer[ NB_HI ]   = 0;&#xA;  au8Buffer[ NB_LO ]   = u8regsno;&#xA;  u8BufferSize         = RESPONSE_SIZE;&#xA;&#xA;  // write registers&#xA;  for (i = 0; i &amp;lt; u8regsno; i++) {&#xA;    temp = word(&#xA;    au8Buffer[ (BYTE_CNT + 1) + i * 2 ],&#xA;    au8Buffer[ (BYTE_CNT + 2) + i * 2 ]);&#xA;&#xA;    regs[ u8StartAdd + i ] = temp;&#xA;  }&#xA;  u8CopyBufferSize = u8BufferSize +2;&#xA;  sendTxBuffer();&#xA;&#xA;  return u8CopyBufferSize;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="904" LastEditorUserId="904" LastEditDate="2016-06-10T12:27:43.330" LastActivityDate="2016-06-10T12:27:43.330" Title="Modbus Protocol RTU" Tags="|arduino-uno|serial|c|modbus|" AnswerCount="0" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="25035" PostTypeId="2" ParentId="25025" CreationDate="2016-06-09T07:57:07.147" Score="3" Body="&lt;p&gt;&quot;Why was the Due retired?&quot; - It is quite interesting that Arduino.CC never explained that. One would think, that a professional company or organisation places a notice in advance with at least a short explanation as to why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of the Arduinos, that have been available on both projects (CC and ORG) have suddenly and without further notice or explanation been retired on CC (the exceptions being Uno and Mega 2560, the cash-cows), but are still alive on ORG.&#xA;It would seem, that either the &quot;divorce&quot; is proceeding or that the copyright case at the US court is not going as smoothly as Banzi hoped. Well, he could repeatedly &quot;bend the truth&quot; by claiming Arduino being completely his idea and design in front of the press (that never bothered to check the obvious facts), but laying such a claim at court is borderline criminal. (see also: arduinohistory.github.io and make your own opinion)&#xA;CC has still the biggest chunk of the overall community and also serves as the central nexus for developers. But it seems there is a lot of movement... some people move to Wiring (from which the Arduino IDE was forked), others to 3rd Party sites and yet others try out different  and newly emerging products (eg. Adafruits MCUs and Pi or the Renesas GR series).&#xA;ORG on the other hand seems to become the bigger (Arduino branded) hardware supplier and developer. CC has apparently out-sourced this to Intel and tries to live of royalties and &quot;certification&quot; fees (which is the central point where Banzi and Martino started to heavily and openly disagree).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Why was the Due retired?&quot; - Unless CC doesn't give an explanation, there is no real answer. A lack of interest is certainly not the reason.&lt;/p&gt;&#xA;" OwnerUserId="22857" LastActivityDate="2016-06-09T07:57:07.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25036" PostTypeId="1" AcceptedAnswerId="25039" CreationDate="2016-06-09T08:39:27.543" Score="3" ViewCount="3946" Body="&lt;p&gt;I'm fairly new to arduino programming and C/C++. I would like to read a .csv file element wise, and send each element via. a nRF24L01 tranceiver to a raspberry pi. Right now I'm able to read the .csv file with &lt;code&gt;Serial.write(&amp;lt;file&amp;gt;.read())&lt;/code&gt;. I was wondering if there's a way to read each element one at a time, if so how would i do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thoughts (Pseudo code-ish):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loop through every element in .csv file {&#xA;    save the current element to X.&#xA;    send X to raspberry pi (I already have a function for sending)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I hope someone can help. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="22859" LastActivityDate="2016-06-09T09:07:06.307" Title="Reading a .csv file element wise" Tags="|arduino-uno|c++|c|nrf24l01+|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25037" PostTypeId="2" ParentId="25022" CreationDate="2016-06-09T08:43:31.237" Score="2" Body="&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/scanf/&quot; rel=&quot;nofollow&quot;&gt;sscanf&lt;/a&gt; should be enough. There is also other options, String class for example with substring method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Take a look at the example: &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&#xA;&#xA;char myString[] = &quot;#YPR=72.13,1.74,-16.38&quot;;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  float yaw = 0;&#xA;  float pitch = 0;&#xA;  float roll = 0;&#xA;&#xA;  sscanf(myString, &quot;#YPR=%f,%f,%f&quot;, &amp;amp;yaw, &amp;amp;pitch, &amp;amp;roll);&#xA;  Serial.println(yaw);&#xA;  Serial.println(pitch);&#xA;  Serial.println(roll);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-06-09T08:43:31.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25038" PostTypeId="1" CreationDate="2016-06-09T08:46:42.610" Score="1" ViewCount="883" Body="&lt;p&gt;I am building a IR-based laser tag system. The basics are working fine. One feature, that I want to have, is different weapon modes with different ranges.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I change the range of an IR transmitter with as little hardware as possible, or at best, completely in software?&lt;/p&gt;&#xA;" OwnerUserId="11571" LastActivityDate="2017-07-06T23:36:33.693" Title="Change range of IR programatically" Tags="|ir|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25039" PostTypeId="2" ParentId="25036" CreationDate="2016-06-09T09:07:06.307" Score="3" Body="&lt;p&gt;The &lt;code&gt;read()&lt;/code&gt; method works character-wise, not element-wise. Then you&#xA;have to rethink your algorithm to loop over characters:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;store each character in a buffer&lt;/li&gt;&#xA;&lt;li&gt;send the whole buffer (i.e. a single element) when you see a delimiter&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const size_t BUFFER_SZ = ...;&#xA;char buffer[BUFFER_SZ];&#xA;size_t pos = 0;    // current write position in buffer&#xA;int c;&#xA;&#xA;// While we can read a character:&#xA;while ((c = &amp;lt;file&amp;gt;.read()) != -1) {&#xA;&#xA;    // If we get a delimiter, then we have a complete element.&#xA;    if (c == ',' || c == '\n') {&#xA;        buffer[pos] = '\0';         // terminate the string&#xA;        raspberry.println(buffer);  // send to the RPi&#xA;        pos = 0;                    // ready for next element&#xA;    }&#xA;&#xA;    // Otherwise, store the character in the buffer.&#xA;    else if (pos &amp;lt; BUFFER_SZ-1) {&#xA;        buffer[pos++] = c;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here the buffer is sent as a string. If you want to parse it into a&#xA;number, you can use &lt;code&gt;sscanf&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code assumes Unix text-file conventions, i.e. each line of the file&#xA;(including the last one) being terminated by an LF character. You may&#xA;have to adapt if your file is different.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-09T09:07:06.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25043" PostTypeId="2" ParentId="25003" CreationDate="2016-06-09T11:42:54.870" Score="0" Body="&lt;p&gt;To make a completely &quot;non blocking&quot; system you need to change your thinking somewhat. Instead of thinking &quot;A need to fade from X to Y&quot; you instead need to start thinking &quot;I am at brightness X at the moment. I want to get to brightness Y. What do I need to do to get there?&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you might have a &lt;code&gt;loop()&lt;/code&gt; than contains a structure like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;My target brightness is Y&lt;/li&gt;&#xA;&lt;li&gt;My current brightness is X&lt;/li&gt;&#xA;&lt;li&gt;Is X equal to Y?&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Yes:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Select a different target brightness to get to&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;No:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If my current brightness is below my target brightness then make it brighter.&lt;/li&gt;&#xA;&lt;li&gt;Otherwise make it dimmer.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can introduce a small delay to slow the fading down, or use &lt;code&gt;millis()&lt;/code&gt; to only run that structure at pre-defined intervals (like BlinkWithoutDelay does) to get your desired fade speed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-09T11:42:54.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25044" PostTypeId="2" ParentId="25038" CreationDate="2016-06-09T13:01:00.030" Score="1" Body="&lt;p&gt;Consider using a Sharp Distance Sensor in addition to your shoot / confirm-hit inferred LED &amp;amp; receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/products/1568?gclid=CLOo8qn-ms0CFZM6gQodhnYIPg&quot; rel=&quot;nofollow noreferrer&quot;&gt;This Sharp distance sensor&lt;/a&gt; is specified to detect objects that reflect IR light from 100&amp;nbsp;cm-500&amp;nbsp;cm. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I change the range of an IR transmitter with as little&#xA;  hardware as possible, or at best, completely in software?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I believe the sensors produce an analog output that can feed into an Arduino's ADC.  So software (by itself) can be used to adjust the threshold distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar devices I have used have a narrow sensing field.  They only reported the distance to objects directly in front of them.  Also, I found they were effected by defective (burning out?) florescent light sources.  We assumed failing florescent light sources produced IR radiation similar in frequency as used by the sensor's IR emitter.  Also, the analog output is slightly stair stepped in the unit we tested.  I say this in case you were expecting to use increase relative accuracy of several readings if not precision of any given reading.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2017-07-06T23:36:33.693" LastActivityDate="2017-07-06T23:36:33.693" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25046" PostTypeId="1" AcceptedAnswerId="25051" CreationDate="2016-06-09T13:43:00.783" Score="0" ViewCount="99" Body="&lt;p&gt;I am intended to use Gas Sensors (MQ series) on protoboard so I connect it to Arduino and perform analogue read. &#xA;I would like to request if possible to get the interfacing circuit (resistors, amplification.. etc.) or if there are schematics available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, when I read the data digitized into 10bits ADC value, how can I convert it into units (ppm)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you so much in advance.&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-06-09T16:06:16.280" Title="Gas Sensors with Arduino + Interfacing Circuit" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25047" PostTypeId="2" ParentId="25046" CreationDate="2016-06-09T13:52:02.030" Score="0" Body="&lt;p&gt;You can connect the directly to the Arduino +5, Gnd and Signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know of any calibration data for the sensors that I have.  I suppose you could take the maximum concentration the sensor can measure and divide this by 1024, but I don't know if the value returned is linear or logarithmic.&lt;br&gt;&#xA;The data sheet does have some info on, but this page may be more helpful&#xA;&lt;a href=&quot;http://forum.arduino.cc/index.php?topic=230945.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=230945.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh and don't forget the warm up time on the sensors!&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-09T13:52:02.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25048" PostTypeId="1" CreationDate="2016-06-09T14:33:20.597" Score="2" ViewCount="72" Body="&lt;p&gt;I am a newbie..  I am integrating Arduino controller with Matlab&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected my arduino DUE board in COM7. And I have also connected a DC Motor in one of the digital output pins (D3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So when I just execute the matlab built in arduino function to initialise or establish a connection my motor runs for a second and then stops. I dont want my motor to run initially. Is there a solution or an alternative to do this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a = arduino('COM7', 'Due');&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="22870" LastEditorUserId="22870" LastEditDate="2016-06-10T13:08:20.500" LastActivityDate="2016-06-10T13:08:20.500" Title="initial power output in the digital io pins of an Arduino controller" Tags="|arduino-uno|arduino-due|matlab|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25050" PostTypeId="1" CreationDate="2016-06-09T15:26:34.473" Score="0" ViewCount="3162" Body="&lt;p&gt;I am trying to use a VL6180X distance sensor and an Arduino Uno board for individual sensor doing individual distance sensing. This sensor follows the I2C protocol. Since for the same type of sensor, the I2C protocol says that they would all have the same address, I am thinking about using the chip enable pin (&lt;code&gt;GPIO00&lt;/code&gt;) on the sensor chip to toggle sensor when doing the distance measuring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to update the address of the sensor group now. But I think to obtain individual results from different sensors on the Arduino serial monitor, right now I can only do one time setup sensor thing (like I couldn't update and toggle around different sensors). Once I started to do that, the results from the serial monitor were wrong. Any advice how I can continue to toggle around the sensor and make them work using the GPIO00 pin?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code I'm using is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;VL6180X.h&amp;gt;&#xA;#define Address1 0x20&#xA;#define Address2 0x22&#xA;#define Address3 0x24&#xA;&#xA;VL6180X sensor;&#xA;&#xA;int pin2 = 2;&#xA;int pin3 = 3;&#xA;int pin4 = 4;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Wire.begin();&#xA;  pinMode(pin2,OUTPUT);&#xA;  pinMode(pin3,OUTPUT);&#xA;  pinMode(pin4,OUTPUT);&#xA;  digitalWrite(pin2,HIGH);&#xA;  digitalWrite(pin3,HIGH);&#xA;  digitalWrite(pin4,HIGH);&#xA;  sensor.init();&#xA;  sensor.configureDefault();&#xA;  sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30);&#xA;  sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50);&#xA;  sensor.writeReg16Bit(VL6180X::INTERLEAVED_MODE__ENABLE,0);&#xA;  sensor.setTimeout(500);&#xA;  sensor.stopContinuous();&#xA;  delay(300);&#xA;  sensor.startInterleavedContinuous(100);&#xA;}&#xA;&#xA;void loop() {&#xA;  hello2();&#xA;  delay(1000);&#xA;}&#xA;&#xA;void hello1(){&#xA;  sensor.setAddress(0x29);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  sensor.setAddress(Address1);&#xA;  sensor.writeReg(0x212,Address1);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  Serial.println();&#xA;  digitalWrite(pin2,HIGH);&#xA;  digitalWrite(pin3,LOW);&#xA;  digitalWrite(pin4,LOW);&#xA;  Serial.print(&quot;Ambient 1: &quot;);&#xA;  Serial.print(sensor.readAmbientContinuous());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.print(&quot;\tRange 1: &quot;);&#xA;  Serial.print(sensor.readRangeContinuousMillimeters());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.println();&#xA;  sensor.writeReg(0x212,0x52);&#xA;  digitalWrite(pin2,HIGH);&#xA;  digitalWrite(pin3,HIGH);&#xA;  digitalWrite(pin4,HIGH);&#xA;}&#xA;&#xA;void hello2(){&#xA;  sensor.setAddress(0x52);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  sensor.setAddress(Address2);&#xA;  sensor.writeReg(0x212,Address2);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  Serial.println();&#xA;  digitalWrite(pin2,LOW);&#xA;  digitalWrite(pin3,HIGH);&#xA;  digitalWrite(pin4,LOW);&#xA;  Serial.print(&quot;Ambient 2: &quot;);&#xA;  Serial.print(sensor.readAmbientContinuous());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.print(&quot;\tRange 2: &quot;);&#xA;  Serial.print(sensor.readRangeContinuousMillimeters());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.println();&#xA;  sensor.writeReg(0x212,0x52);&#xA;}&#xA;&#xA;void hello3(){&#xA;  sensor.setAddress(0x52);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  sensor.setAddress(Address3);&#xA;  sensor.writeReg(0x212,Address3);&#xA;  Serial.println(sensor.readReg(0x212),HEX);&#xA;  Serial.println();&#xA;  digitalWrite(pin2,LOW);&#xA;  digitalWrite(pin3,LOW);&#xA;  digitalWrite(pin4,HIGH);&#xA;  Serial.print(&quot;Ambient 3: &quot;);&#xA;  Serial.print(sensor.readAmbientContinuous());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.print(&quot;\tRange 3: &quot;);&#xA;  Serial.print(sensor.readRangeContinuousMillimeters());&#xA;  if (sensor.timeoutOccurred()) { Serial.print(&quot; TIMEOUT&quot;); }&#xA;  Serial.println();&#xA;  sensor.writeReg(0x212,0x52);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated!&lt;/p&gt;&#xA;" OwnerUserId="22789" LastEditorUserId="4628" LastEditDate="2017-02-05T07:31:44.883" LastActivityDate="2020-12-28T21:06:05.647" Title="Multiple VL6180X distance sensors interactive problem" Tags="|i2c|pins|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25051" PostTypeId="2" ParentId="25046" CreationDate="2016-06-09T16:06:16.280" Score="0" Body="&lt;p&gt;I would suggest checking out one of the gas sensors that comes with a breakout board. I've found the pins don't quite match the spacing of a protoboard and make it a little difficult to set up. Seeed Studio sells some of the sensors with a breakout board and has some nice examples of how to convert the values to PPM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_Gas_Sensor(MQ5)&quot; rel=&quot;nofollow&quot;&gt;http://www.seeedstudio.com/wiki/Grove_-_Gas_Sensor(MQ5)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="14018" LastActivityDate="2016-06-09T16:06:16.280" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25052" PostTypeId="2" ParentId="25050" CreationDate="2016-06-09T16:31:56.433" Score="0" Body="&lt;p&gt;You are using only one VL6180 object and then changing its address repeatedly. In your setup(), since all the sensors are enabled and have the same address, you're sending init commands to all of them; I'm not sure what will happen (multiple ACK/NACKs?), but it's probably not a good thing. Your hello() functions actually changes the address of all the sensors (twice?), if the commands even work, and then enables only one to read from. A host of undefined problems is expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix this, you have to do all the config and address changes in setup():&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Before setup(), create 3 VL6180 objects: &lt;code&gt;sensor1&lt;/code&gt;, &lt;code&gt;sensor2&lt;/code&gt;, &lt;code&gt;sensor3&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;In setup(), enable ONLY ONE sensor, and call all the sensor initialization commands on one of the objects you created (sensor1, maybe), as usual. Then call &lt;code&gt;setAddress()&lt;/code&gt; on that sensor object to change its address to a unique one. This object is now tied to the physical sensor which has been enabled; all future operations related to that sensor, must be done on this object.&lt;/li&gt;&#xA;&lt;li&gt;Then, disable this first sensor, and enable another and repeat the same steps as before on another object (sensor2), making sure to make each sensor's address unique. This way, you configure only one sensor at a time.&lt;/li&gt;&#xA;&lt;li&gt;After configuring all three, you can now use their respective objects to get readings in loop().&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="4628" LastEditDate="2017-01-06T05:43:11.603" LastActivityDate="2017-01-06T05:43:11.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25055" PostTypeId="1" CreationDate="2016-06-10T02:09:02.420" Score="1" ViewCount="115" Body="&lt;p&gt;I am trying to make a RBB Arduino based project and I only need 3 pins. In the future I may use one to two more. I wanted to use an ATtiny85 however my code is 13,270 bytes and it would not fit. So I decided to use an ATtiny84 but it also would not fit, it will fit on an ATmega328p but I do not want to use one because i want to keep the project relatively small and I for sure do not need that many pins. Does anyone know of a chip that has a lot of memory but not many pins, or some other solution. Thank you, any help is appreciated.   &lt;/p&gt;&#xA;" OwnerUserId="22878" LastActivityDate="2016-06-10T08:16:55.180" Title="I need more memory!" Tags="|memory-usage|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25056" PostTypeId="2" ParentId="25055" CreationDate="2016-06-10T02:14:01.907" Score="0" Body="&lt;p&gt;There are a few ways to optimize your code and reduce the size. Have a look on this document from Atmel. I've used some tips to reduce the size of my bootloader once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.atmel.com/images/doc8453.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/doc8453.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the AVR family I'm not familiar with any option. You could use a small QFN package for the atmega328p as well... You might find some small ARM with much more memory and small size.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="16417" LastEditDate="2016-06-10T02:19:13.027" LastActivityDate="2016-06-10T02:19:13.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25057" PostTypeId="2" ParentId="25038" CreationDate="2016-06-10T03:04:01.723" Score="1" Body="&lt;p&gt;Instead of modifying the TX power, why not make the receiver read the light level. You just need to transmit some data, like the weapon ID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it works you could send more information, including how stable the weapon that hit the target was, during the shoot, using an accelerometer.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="6936" LastEditDate="2017-06-06T01:04:38.640" LastActivityDate="2017-06-06T01:04:38.640" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25059" PostTypeId="1" AcceptedAnswerId="25094" CreationDate="2016-06-10T06:32:09.853" Score="0" ViewCount="279" Body="&lt;p&gt;I have connected to EL wire, 12v EL Inverter to SparkFun EL Sequencer but it does not work (no battery is connected). The connections are the same like in Hookup Guide (&lt;a href=&quot;https://cdn.sparkfun.com/assets/learn_tutorials/3/6/9/ELSequencerHookUp_bb.png&quot; rel=&quot;nofollow&quot;&gt;https://cdn.sparkfun.com/assets/learn_tutorials/3/6/9/ELSequencerHookUp_bb.png&lt;/a&gt;). Furthermore, there is no light indicating that it works but I hear a noise/whistle from the Inverter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have to program the EL Sequencer or does it automatically turn the EL wire on?&lt;/p&gt;&#xA;" OwnerUserId="7936" LastEditorUserId="7936" LastEditDate="2016-06-10T17:36:41.420" LastActivityDate="2016-06-10T18:27:05.007" Title="SparkFun EL Sequencer does not work" Tags="|wires|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25060" PostTypeId="1" CreationDate="2016-06-10T06:42:46.487" Score="2" ViewCount="1493" Body="&lt;p&gt;I have a question about connecting a Arduino with Raspberry Pi. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the benefit of connecting the two?&lt;/p&gt;&#xA;" OwnerUserId="22886" LastEditorUserId="13614" LastEditDate="2016-06-10T22:51:48.500" LastActivityDate="2016-06-10T22:51:48.500" Title="Why connect arduino with Rasberry pi?" Tags="|arduino-uno|raspberrypi|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25061" PostTypeId="1" CreationDate="2016-06-10T07:24:28.400" Score="0" ViewCount="386" Body="&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/RowColumnScanning&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/RowColumnScanning&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;This code really confused me because I don't know if the &lt;code&gt;pixels[x][y]&lt;/code&gt; is HIGH or LOW in &lt;code&gt;void refreshScreen()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As you look at the code, &lt;code&gt;pixels[x][y]&lt;/code&gt; is HIGH and then LOW in &lt;code&gt;void setup()&lt;/code&gt;, and then &lt;code&gt;pixels[x][y]&lt;/code&gt; is HIGH again in &lt;code&gt;void loop()&lt;/code&gt;. Could anyone explain this to me, please？&lt;/p&gt;&#xA;" OwnerUserId="22887" LastEditorUserId="61722" LastEditDate="2022-08-06T08:35:34.143" LastActivityDate="2022-08-06T08:36:45.870" Title="Row-column scanning to control an 8x8 LED matrix" Tags="|arduino-uno|led-matrix|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25063" PostTypeId="2" ParentId="25060" CreationDate="2016-06-10T08:05:22.337" Score="8" Body="&lt;p&gt;Interfacing hardware is easier with the Arduino: more available I/O pins&#xA;capable of sourcing and sinking more current, 5&amp;nbsp;V I/O, analog&#xA;inputs, very predictable timings, etc. The Raspberry, on the other hand,&#xA;is a real computer with a real OS, has &lt;strong&gt;a lot&lt;/strong&gt; more computing power&#xA;and memory, has Internet connectivity, can easily run “standard” web&#xA;servers like Apache or nginx... or mostly any Linux software for that&#xA;matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some projects can benefit from using both. E.g. if you want to make a&#xA;web interface for some low-level hardware sensors.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-10T08:42:17.480" LastActivityDate="2016-06-10T08:42:17.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25064" PostTypeId="2" ParentId="25055" CreationDate="2016-06-10T08:16:55.180" Score="1" Body="&lt;p&gt;AFAIK, 8 KiB of flash is the most you can have on an AVR in a DIP&#xA;package with less than 28&amp;nbsp;pins. If you do not mind soldering&#xA;surface-mount parts, the 328P is available in TQFP and VQFN packages,&#xA;significantly smaller than the DIP version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you could try to optimize your program to fit in 8&amp;nbsp;KiB.&#xA;The Arduino libraries are often inefficient size-wise, and in many&#xA;instances you can save quite a lot by rewriting the parts that you need&#xA;on top of just &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;avr-libc&lt;/a&gt;. Note that&#xA;this libc is always linked to your program by the Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-10T08:16:55.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25068" PostTypeId="2" ParentId="20538" CreationDate="2016-06-10T09:24:02.737" Score="0" Body="&lt;p&gt;I think the best solution would be to use WS2812 LEDS. I already implemented this many times also for my home illumination.&#xA;WS2812 is a RGB LED with an integrated chip (1m strip with 60 LED will cost about 10$).&#xA;One advantage is that you need only 1 output from your Arduino and the library works very well.&#xA;Another one is that you don't need power! 5mA is enough to drive 1000 LEDS! So you don't need MOSFETS and you don't need any Relais.&lt;/p&gt;&#xA;" OwnerUserId="16591" LastActivityDate="2016-06-10T09:24:02.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25073" PostTypeId="1" AcceptedAnswerId="25074" CreationDate="2016-06-10T11:48:18.660" Score="0" ViewCount="596" Body="&lt;p&gt;I want to power my motor shield without my UNO. I have connected the &lt;code&gt;+ve&lt;/code&gt; and &lt;code&gt;-ve&lt;/code&gt; terminals resulting in lighting up of the LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to control the motors in this arrangement from the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="22899" LastEditorUserId="2944" LastEditDate="2016-06-11T03:58:33.550" LastActivityDate="2016-06-11T03:58:33.550" Title="how do I power my motor shield without an arduino uno?" Tags="|arduino-uno|motor|arduino-motor-shield|robotics|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25074" PostTypeId="2" ParentId="25073" CreationDate="2016-06-10T12:12:37.763" Score="0" Body="&lt;p&gt;Welcome!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure I understand what you are asking because what you are trying to do doesn't make much sense.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motors connected to the motor shield are controlled by the output pins of the Arduino that the motor shield is plugged in to.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could run jumper leads from an separate Arduino into your unplugged motor shield, but that's just extending what you already have.  You really do need some form of controller, not necessary a microprocessor, otherwise how can you go forwards and backwards?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the problem you have put the Arduino into a plastic case and you can't plug the motor shield in any more?  If so get a set of long male to female connectors (they look like the Arduino connectors) and use them as extensions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the problem you have a different format of board and can't plug it in? If so use the wires method to form the correct connections.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope that answers your question, if not please try and explain what I'm misunderstanding.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-10T12:12:37.763" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25076" PostTypeId="1" AcceptedAnswerId="25078" CreationDate="2016-06-10T12:44:31.187" Score="3" ViewCount="2751" Body="&lt;p&gt;I’m constructing an arduino based sytem that uses a SD card and I’m looking for a way to safely remove the card from the system during operation. One way would probably be to turn of the arduino before removal of the SD card, but that is not acceptable in this context.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The library I’m using: &#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/SD&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to safely remove the SD card during operation? If no, how can I minimize the risk of damage to the SD card while inserting and removing it? &lt;/p&gt;&#xA;" OwnerUserId="22900" LastEditorUserId="2881" LastEditDate="2016-06-10T13:26:20.747" LastActivityDate="2016-06-10T13:26:20.747" Title="How to remove SD card safely" Tags="|sd-card|adafruit|safety|memory|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25077" PostTypeId="2" ParentId="25061" CreationDate="2016-06-10T12:47:07.570" Score="2" Body="&lt;p&gt;The pixels array in initialized to all HIGH in &lt;code&gt;setup()&lt;/code&gt;. Then one element of the pixel array is set to LOW in &lt;code&gt;readSensors()&lt;/code&gt;  which turns on one LED.&lt;/p&gt;&#xA;&lt;p&gt;The tricky bit is you have to remember to turn off the previous LED. That is why in &lt;code&gt;readSensors()&lt;/code&gt; there is the line where an element of pixels is set HIGH while the pixels' array pointers are still pointing at the former (already lit) LED.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="61722" LastEditDate="2022-08-06T08:36:45.870" LastActivityDate="2022-08-06T08:36:45.870" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25078" PostTypeId="2" ParentId="25076" CreationDate="2016-06-10T13:06:19.923" Score="2" Body="&lt;p&gt;The physical construction of the card and socket are designed such that power to the card is cycled properly when the card is inserted and removed. The only thing the firmware has to do is to stop writing to the card before it is removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unexpected removal can cause a problem in &quot;larger&quot; systems (e.g. cellphones or PCs) because they may have structures open on the card that are not yet complete, but small embedded systems typically do not have the capability to do so and so once all writes are completed the card can be removed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Detection of non-presence of a card is another issue though, and the firmware will have to be designed to not fail in such a situation.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-10T13:06:19.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25079" PostTypeId="2" ParentId="25060" CreationDate="2016-06-10T13:08:57.490" Score="7" Body="&lt;p&gt;&lt;strong&gt;Why add an Raspberry Pi to an Arduino?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some things that simply are beyond the possibilities of Arduino. The first thing that would cross my mind is video processing, HDMI output, decent sound etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A Raspberry Pi can be used to add some features to your project aswell. If you make an Arduino controlled robotic arm, you could add an &quot;user interface&quot; to it, using a Raspberry Pi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why add an Arduino to an Raspberry Pi?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some may argue that the Raspberry Pi is much more capable as an Arduino, in every form.&#xA;Though, the strengths of Arduino are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ease of use. (For GPIO on Raspberry Pi you'll likely need to install something, to make it work with your favorite programming language.)&lt;/li&gt;&#xA;&lt;li&gt;Real time / deterministic timing, this is one of the best things of Arduino. Given that an Arduino has no &quot;operating system&quot; that can induce random (tiny) delays in your program (other than the millis()/micros() interrupts).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why do any of this? You could choose an Arduino OR Raspberry Pi&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing you might not think about is, that by joining an Arduino and a Raspberry Pi, you're joining two important parts of Embedded Systems. Which you can learn a lot from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Microcontrollers and Single-board computers. This really has a good educational effect. Since you'll not limit yourself to one device or &quot;way of thinking&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Moreover, the interfacing between two devices is often important and will bring some extra problems. (And solving them gives extra knowledge/experience)&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-10T13:08:57.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25080" PostTypeId="1" AcceptedAnswerId="25086" CreationDate="2016-06-10T13:18:18.563" Score="7" ViewCount="26881" Body="&lt;p&gt;I'm attempting to reduce the amount of RAM being used by my program by writing some values to the EEPROM of my micro controller. I'm currently programming on the ATtiny85 which has 512 Bytes of EEPROM. According to the documentation this is how you write to EEPROM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  EEPROM.write(0, 1);&#xA;  EEPROM.write(1, 0);&#xA;  EEPROM.write(2, 3);&#xA;  EEPROM.write(3, 2);&#xA;  EEPROM.write(4, 1);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason this isn't working for me and I can't seem to find the error. Am I programming this wrong or can the EEPROM of the ATtiny simply NOT be accessed with Arduino Code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the Datasheet: &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf&quot; rel=&quot;noreferrer&quot;&gt;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the second sketch I'm using to test the EEPROM:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  EEPROM.write(0, 1);&#xA;  EEPROM.write(1, 0);&#xA;  EEPROM.write(2, A3);&#xA;  EEPROM.write(3, A2);&#xA;  EEPROM.write(4, A1);&#xA;&#xA;byte CLK = EEPROM.read(0);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if(CLK == 1)&#xA;  {&#xA;    for(int i = 0; i &amp;lt; 3; i++)&#xA;    {&#xA;    digitalWrite(0, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(0, LOW);&#xA;    delay(1000);&#xA;    }&#xA;    exit(0); &#xA;  }&#xA;  else&#xA;  {&#xA;    for(int i = 0; i &amp;lt; 100; i++)&#xA;    {&#xA;    digitalWrite(0, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(0, LOW);&#xA;    delay(1000);&#xA;    }&#xA;    exit(0);&#xA;  }&#xA;&#xA;  exit(0);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22788" LastEditorUserId="22788" LastEditDate="2016-06-10T14:49:48.473" LastActivityDate="2022-05-10T09:37:27.393" Title="Can you access the EEPROM of an ATtiny with Arduino Code?" Tags="|attiny|memory-usage|eeprom|memory|" AnswerCount="4" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25081" PostTypeId="2" ParentId="25076" CreationDate="2016-06-10T13:19:17.810" Score="0" Body="&lt;p&gt;An SDCard is very much like a hard disk drive.  Both in how it is made and how it is treated by the host.  As such there are critical times where interrupting the communication to the SDCard can cause corruption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid problems it is advisable to finish all transaction before removing the SDCard.  In a perfect situation all data will be flushed from the host's buffers (cache) and the files being accessed closed.  So research the flush() and the close() function calls in the library you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to accomplish the above, it is obvious the host device needs to be told the SDCard is about to be removed.  In most cases this is accomplished using a switch (human interface) and some code to flush and close any open files.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this said, often people pull SDCards with out any obvious problems.  This is likely because SDCard transactions are fast and completed in fractions of a second.  Also pulling an SDCard when periodically reading a file is far safer then when writing to a file or altering any information on the SDCard (for example the name of a file).  If you can suffer the possibility of corruption, it may be that the added effort is not worth it.  However if you stand lose a great deal, I would advise you to do some research into the best ways to avoid SDCard corruption.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-10T13:19:17.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25082" PostTypeId="2" ParentId="25076" CreationDate="2016-06-10T13:25:28.423" Score="2" Body="&lt;p&gt;In my early days of computing, the computer used to turn on a led when writing to cassette tape or floppy disk. If you wanted to remove the tape or disk, you had to wait for the led to turn off. &#xA;I think that could be your easiest solution.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-06-10T13:25:28.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25084" PostTypeId="1" AcceptedAnswerId="25088" CreationDate="2016-06-10T14:17:54.907" Score="0" ViewCount="828" Body="&lt;p&gt;I have several sensors (Grove multichannel gas sensor, Air Pressure Sensor MPX4115A, Temperature and Humidity Sensor DHT11) where most of them uses I2C communication. &#xA;I wonder if it is possible to read all of them using the I2C communication on a single Arduino board? &lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-06-11T07:24:52.787" Title="I2C multi sensors reading on Arduino" Tags="|arduino-uno|sensors|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25085" PostTypeId="2" ParentId="25080" CreationDate="2016-06-10T14:43:07.250" Score="1" Body="&lt;p&gt;When you upload a new sketch with the default settings, the EEPROM will be cleared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;The -e option instructs avrdude to perform a chip-erase before programming; this is almost always necessary before programming the flash.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're using the Arduino IDE, the -e option is enabled by default. This is probably why it's not working for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See also the question &lt;a href=&quot;https://electronics.stackexchange.com/questions/98891/is-there-a-way-to-preserve-eeprom-contents-in-avr-atmega-when-burning-a-new-firm&quot;&gt;Is there a way to preserve EEPROM contents in AVR Atmega when burning a new firmware to flash with avrdude?&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21015" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-06-10T14:43:07.250" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25086" PostTypeId="2" ParentId="25080" CreationDate="2016-06-10T14:51:27.857" Score="10" Body="&lt;p&gt;The Arduino EEPROM library is compatible with the ATTiny range of AVR microcontrollers as the library itself is built on the standard Atmel AVR avr/eeprom.h 'library' so it is compatible with all the AVR microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The EEPROM also doesn't take to being written or read to often as EEPROM can wear very quickly. Reading though does not cause much damage though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that using &lt;code&gt;exit(0);&lt;/code&gt; &lt;strong&gt;will stop the ATTiny from doing anything else&lt;/strong&gt; after it is called so I hope your intention is to only run the loop once, if not this would account for either not seeing anything or it only ever running the blinking cycle once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer your follow up question. Yes you can run one sketch to set you values in EEPROM and then use another sketch to read those. That us usually the point of EEPROM it is a memory type that &quot;keeps its value while there is no power&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you need to make sure the ATTiny is set to preserve EEPROM during upload with the ISP, this is done with the fuse settings. You need to look for a tutorial on fuse calculators for the AVRs. To set the &lt;code&gt;EESAVE&lt;/code&gt; you need to set the High fuse to &lt;code&gt;0xD7&lt;/code&gt;, you can change this in the &lt;code&gt;boards.txt&lt;/code&gt; file. &lt;a href=&quot;http://eleccelerator.com/fusecalc/fusecalc.php?chip=attiny85&amp;amp;LOW=E2&amp;amp;HIGH=D7&amp;amp;EXTENDED=FF&amp;amp;LOCKBIT=FF&quot; rel=&quot;noreferrer&quot;&gt;Here is a fuse calculator.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the code that is on your question at the moment is being used you won't be seeing anything as it needs the pins to be set with &lt;code&gt;pinMode&lt;/code&gt;. That's a note for others that see this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next what you can do is run a basic test code which blinks the LED without anything else going on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup(){&#xA;&#xA; pinMode(0, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA; digitalWrite(0, HIGH);&#xA; delay(1000);&#xA; digitalWrite(0, LOW);&#xA; delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is the code you have written, it works I have it running in front of me.&#xA;I have commented it and changed a few things to make it work as intended, although the intention is not clear.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;byte CLK = 0; //This is a global variable with an initial value&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;  EEPROM.write(0, 1); //set the pin to D1&#xA;  delay(5); &#xA;&#xA;  //read from EEPROM address 0&#xA;  //this sets the value of the global variable CLK&#xA;  CLK = EEPROM.read(0); //place this inside a function&#xA;&#xA;  //just to give an example...&#xA;  byte PIN = CLK;   //PIN variable is a local variable &#xA;&#xA;  pinMode(PIN ,OUTPUT); //using that local variable&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  // Note: the below if() will always be true as the value &#xA;  // of CLK is never change and shouldn't be changed as&#xA;  // it will change the pin number of the output&#xA;&#xA;  if (CLK == 1) {&#xA;    for (int a = 0; a &amp;lt; 3; a++) {&#xA;      digitalWrite(CLK, HIGH);  //this uses the global variable &#xA;      delay(1000);&#xA;      digitalWrite(CLK, LOW);&#xA;      delay(1000);&#xA;    }&#xA;    //putting exit(0); will actually stop the program &#xA;    //remove it&#xA;//    exit(0);&#xA;  }&#xA;  else { &#xA;    for (int a = 0; a &amp;lt; 100; a++) {&#xA;      digitalWrite(0, HIGH);  //this has a predefined pin no.&#xA;      delay(500);&#xA;      digitalWrite(0, LOW);   //this has a predefined pin no.&#xA;      delay(500);&#xA;    }&#xA;    //putting exit(0); will actually stop the program &#xA;    //remove it&#xA;//    exit(0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2016-06-10T17:11:24.803" LastActivityDate="2016-06-10T17:11:24.803" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25087" PostTypeId="2" ParentId="25084" CreationDate="2016-06-10T14:56:49.820" Score="0" Body="&lt;p&gt;Should be easy enough.  Do you already know how to connect and communicate with one I2C device?  If so, connecting multiple should be simply a case of connecting them in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't know how to communicate with a single I2C device, then...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the Arduino software you can use &lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire&lt;/a&gt; to talk to devices over I2C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the hardware, connect the I2C clock and data lines from the Arduino to the I2C devices.  More on that &lt;a href=&quot;https://learn.sparkfun.com/tutorials/i2c/why-use-i2c&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16085" LastActivityDate="2016-06-10T14:56:49.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25088" PostTypeId="2" ParentId="25084" CreationDate="2016-06-10T15:31:01.207" Score="0" Body="&lt;p&gt;It is possible to use multiple I²C devices, all is needed is for each one to have a different address and the ability to set up the wiring(the &lt;a href=&quot;https://arduino.stackexchange.com/a/25087/2944&quot;&gt;other answer&lt;/a&gt; points to wriring info).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the sensors you listed only one is an I2C device(Grove sensor). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The DHT11 uses a single digital wire to communicate and the air pressure sensor is an analog device. Although you do mention having several devices, the only thing you need to be sure of is if there are no address conflicts, i.e. there being two devices with the same address on the I²C bus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If address conflicts are an issue most devices provide a way of changing that address, often there are solder jumpers on the board. This allows you to change a devices address to a unique one.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-06-11T07:24:52.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25089" PostTypeId="2" ParentId="22873" CreationDate="2016-06-10T15:35:48.237" Score="6" Body="&lt;p&gt;The speed value is correct, like TisteAndi said.  Your GPS location &quot;wanders&quot; around the same way.  You can simply ignore small speed values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One problem you may not be aware of yet: the printing isn't really coordinated with the GPS updates.  Sometimes that doesn't matter, but if you want your speed to update every second, you'll need to synchronize the two.  And as noted in the code, you can actually lose GPS data if you print too much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a GPS library, called &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoGPS&lt;/a&gt;, to fix some of these problems.  They are described in the &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/extras/doc/Troubleshooting.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;Troubleshooting&lt;/a&gt; section of the online documentation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, &lt;code&gt;SoftwareSerial&lt;/code&gt; is very inefficient.  I maintain a more-efficient alternative, &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoSWSerial&lt;/a&gt;.  As you add more features to your GPS program, the efficiency will become important.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is your program, modified to use NeoGPS and NeoSWSerial, and it uses TisteAndi's suggestion to set the speed to zero:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;NMEAGPS.h&quot;&#xA;#include &amp;lt;NeoSWSerial.h&amp;gt;&#xA;&#xA;NeoSWSerial mySerial(4, 3); // RX, TX//&#xA;&#xA;NMEAGPS     gps;&#xA;gps_fix     fix;&#xA;uint8_t     GPSupdates = 0;&#xA;&#xA;void setup()  &#xA;{&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  mySerial.begin(9600);&#xA;&#xA;  delay(1000);&#xA;&#xA;  Serial.print(&quot;Sizeof(gps) = &quot;); Serial.println(sizeof(gps));&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop() // run over and over&#xA;{&#xA;  while (gps.available( mySerial )) {&#xA;    fix = gps.read();&#xA;&#xA;    if (fix.valid.speed &amp;amp;&amp;amp; (fix.speed_mkn() &amp;lt; 1000)) {&#xA;      // Too slow, zero out the speed&#xA;      fix.spd.whole = 0;&#xA;      fix.spd.frac  = 0;&#xA;    }&#xA;&#xA;    GPSupdates++;&#xA;  }&#xA;&#xA;  // Print once every 5 seconds&#xA;  if (GPSupdates &amp;gt;= 5) {&#xA;    Serial.println(&quot;Acquired Data&quot;);&#xA;    Serial.println(&quot;-------------&quot;);&#xA;    gpsdump();&#xA;    Serial.println(&quot;-------------&quot;);&#xA;    Serial.println();&#xA;&#xA;    GPSupdates = 0;&#xA;  }&#xA;&#xA;}&#xA;&#xA;void gpsdump()&#xA;{&#xA;  Serial.print(&quot;Lat/Long(10^-7 deg): &quot;);&#xA;  if (fix.valid.location) {&#xA;    Serial.print(fix.lat); &#xA;    Serial.print(&quot;, &quot;);&#xA;    Serial.print(fix.lon);&#xA;  }&#xA;  Serial.println();&#xA;&#xA;  // GPS characters may be lost during lengthy Serial.print()&#xA;  //   See the NeoGPS Troubleshooting section.&#xA;&#xA;  Serial.print(&quot;Lat/Long(float): &quot;);&#xA;  if (fix.valid.location) {&#xA;    Serial.print(fix.latitude(), 5); &#xA;    Serial.print(&quot;, &quot;); &#xA;    Serial.print(fix.longitude(), 5);&#xA;  }&#xA;  Serial.println();&#xA;&#xA;  Serial.print(&quot;Date/Time: &quot;); &#xA;  if (fix.valid.date | fix.valid.time)&#xA;    Serial &amp;lt;&amp;lt; fix.dateTime;&#xA;  Serial.println();&#xA;&#xA;  //*&#xA;  Serial.print(&quot;Date: &quot;); &#xA;  if (fix.valid.date) {&#xA;    Serial.print(fix.dateTime.month); &#xA;    Serial.print(&quot;/&quot;); &#xA;    Serial.print(fix.dateTime.date);&#xA;    Serial.print(&quot;/&quot;);&#xA;    Serial.print(fix.dateTime.year);&#xA;  }&#xA;&#xA;  if (fix.valid.date | fix.valid.time) {&#xA;    Serial.print(&quot;  Time: &quot;); &#xA;    Serial.print(fix.dateTime.hours); &#xA;    Serial.print(&quot;:&quot;); &#xA;    Serial.print(fix.dateTime.minutes); &#xA;    Serial.print(&quot;:&quot;); &#xA;    Serial.print(fix.dateTime.seconds);&#xA;    Serial.print(&quot;.&quot;);&#xA;    Serial.print(fix.dateTime_cs);&#xA;  }&#xA;  Serial.println();&#xA;  //*/&#xA;&#xA;  Serial.print(&quot;Alt(cm): &quot;); &#xA;  if (fix.valid.altitude)&#xA;    Serial.print(fix.altitude_cm());&#xA;&#xA;  Serial.print(&quot; Course(10^-2 deg): &quot;);&#xA;  if (fix.valid.heading)&#xA;    Serial.print(fix.heading_cd()); &#xA;&#xA;  Serial.print(&quot; Speed(10^-3 knots): &quot;);&#xA;  if (fix.valid.speed)&#xA;    Serial.print(fix.speed_mkn());&#xA;  Serial.println();&#xA;&#xA;  Serial.print(&quot;Alt(float): &quot;);&#xA;  if (fix.valid.altitude)&#xA;    Serial.print(fix.altitude()); &#xA;&#xA;  Serial.print(&quot; Course(float): &quot;);&#xA;  if (fix.valid.heading)&#xA;    Serial.print(fix.heading()); &#xA;  Serial.println();&#xA;&#xA;  Serial.print(&quot;Speed(knots): &quot;);&#xA;  if (fix.valid.speed)&#xA;    Serial.print(fix.speed()); &#xA;  Serial.print(&quot; (mph): &quot;);&#xA;  if (fix.valid.speed)&#xA;    Serial.print(fix.speed_mph());&#xA;  Serial.print(&quot; (mps): &quot;); &#xA;  if (fix.valid.speed)&#xA;    Serial.print(fix.speed_kph()*3600.0/1000.0);&#xA;  Serial.print(&quot; (kmph): &quot;);&#xA;  if (fix.valid.speed)&#xA;    Serial.print(fix.speed_kph());&#xA;  Serial.println();&#xA;&#xA;  Serial.print(&quot;Stats: characters: &quot;); &#xA;  Serial.print(gps.statistics.chars);&#xA;  Serial.print(&quot; sentences: &quot;);&#xA;  Serial.print(gps.statistics.ok);&#xA;  Serial.print(&quot; failed checksum: &quot;); &#xA;  Serial.println(gps.statistics.crc_errors);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(Notice the increased accuracy of the integer lat/lon!  And you don't need &lt;code&gt;printFloat&lt;/code&gt;.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you'd like to try it, be sure to follow the NeoGPS &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS/blob/master/extras/doc/Installing.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;Installation&lt;/a&gt; instructions.  NeoSWSerial is installed like most Arduino libraries.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="45635" LastEditDate="2018-04-10T08:38:14.193" LastActivityDate="2018-04-10T08:38:14.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25091" PostTypeId="2" ParentId="25017" CreationDate="2016-06-10T17:25:27.203" Score="1" Body="&lt;p&gt;After a careful study of C/C++ documentation, I finally managed to use pointers in Arduino :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the final code became like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int arrayAAA[] = {6, 8, 10, 12};&#xA;int arrayBBB[] = {9, 15, 27, 41};&#xA;&#xA;//Create a pointer, which will point to any of your arrays of your choice&#xA;int *newArray; &#xA;&#xA;const int arrayAAALength = sizeof(arrayAAA)/sizeof(int);&#xA;const int arrayBBBLength = sizeof(arrayBBB)/sizeof(int);&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(9600);&#xA;&#xA;    //Uses the address of arrayAAA (i.e. inherits the content of arrayAAA). &#xA;    //&amp;amp;: points to address of a chosen array.&#xA;    //[0]: is a must to grab all values!&#xA;    newArray = &amp;amp;arrayAAA[0]; &#xA;&#xA;    Serial.print(&quot;arrayAAA:&quot;);&#xA;    for (int i = 0; i &amp;lt; arrayAAALength; i++){&#xA;        Serial.print(&quot;   &quot;);&#xA;        Serial.print(arrayAAA[i]);&#xA;    }&#xA;    Serial.println();&#xA;&#xA;    Serial.print(&quot;newArray:&quot;);&#xA;    for (int i = 0; i &amp;lt; arrayAAALength; i++){&#xA;        Serial.print(&quot;   &quot;);&#xA;        Serial.print(newArray[i]);&#xA;    }&#xA;    Serial.println();&#xA;}&#xA;&#xA;void loop(){&#xA;    //Left empty&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works perfectly, just what I expected!&lt;/p&gt;&#xA;" OwnerUserId="8472" LastEditorUserId="8472" LastEditDate="2016-06-10T19:38:01.180" LastActivityDate="2016-06-10T19:38:01.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25092" PostTypeId="1" AcceptedAnswerId="25098" CreationDate="2016-06-10T17:45:48.437" Score="1" ViewCount="223" Body="&lt;p&gt;I'm using a &lt;a href=&quot;https://learn.sparkfun.com/tutorials/mg2639-cellular-shield-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;MG2639 Cell Module&lt;/a&gt; with the SMS and GPS functionality.&#xA;I have a sketch that sends through SMS the location of the arduino UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt; //to communicate with mg2639 cell module.&#xA;#include &amp;lt;SFE_MG2639_CellShield.h&amp;gt; //basic librarie of the module.&#xA;#include &amp;lt;AltSoftSerial.h&amp;gt;   //to communicate with the GPS module&#xA;#include &amp;lt;TinyGPS++.h&amp;gt;    //to acquire the NMEA codes.&#xA;&#xA;TinyGPSPlus gps;&#xA;&#xA;AltSoftSerial ALTS(9, 8);&#xA;char celprim[11]=&quot;4423337388&quot;;&#xA;uint8_t GPStatus=0;&#xA;long temp=0;&#xA;&#xA; void configurado()&#xA;{&#xA;  sms.start(celprim);&#xA;  sms.print(&quot;Transmitiendo GPS Tracking....&quot;);&#xA;  sms.send();&#xA;  delay (6000);&#xA;}&#xA;&#xA;     void GPSTracking()&#xA;{&#xA;   do&#xA;      {&#xA;        if (ALTS.available()&amp;gt;0)&#xA;          if (gps.encode(ALTS.read())) &#xA;      {&#xA;        if (gps.date.isValid() &amp;amp;&amp;amp; gps.location.isValid() &amp;amp;&amp;amp; gps.time.isValid()){&#xA;          sms.start(celprim); &#xA;          sms.print(&quot;Fecha/Hora/Ubicacion: &quot;);&#xA;          sms.print(gps.date.day());&#xA;          sms.print(&quot;-&quot;);&#xA;          sms.print (gps.date.month());&#xA;          sms.print(&quot;-&quot;);&#xA;          sms.print(gps.date.year());&#xA;          sms.print(&quot; &quot;);&#xA;          if ((gps.time.hour()-5) &amp;lt; 10) sms.print(&quot;0&quot;);&#xA;          sms.print(gps.time.hour()-5);&#xA;          sms.print(&quot;:&quot;);&#xA;          if (gps.time.minute() &amp;lt; 10) sms.print(&quot;0&quot;);&#xA;          sms.print(gps.time.minute());&#xA;          sms.print(&quot;:&quot;);&#xA;          if (gps.time.second() &amp;lt; 10) sms.print(&quot;0&quot;);&#xA;          sms.print(gps.time.second());&#xA;    sms.print(&quot;https://www.google.com.mx/maps/dir/19.4161748,-99.1664011/&quot;);&#xA;          sms.print(gps.location.lat(), 6);&#xA;          sms.print(&quot;,&quot;);&#xA;          sms.print(gps.location.lng(), 6);&#xA;          sms.print(&quot;/@&quot;);&#xA;          sms.print(gps.location.lat(), 6);&#xA;          sms.print(&quot;,&quot;);&#xA;          sms.print(gps.location.lng(), 6);&#xA;          sms.print(&quot;,19z&quot;);&#xA;          sms.send();&#xA;          GPStatus=1;&#xA;        }&#xA;    }&#xA;      if ((millis()-temp) &amp;gt; 30000 &amp;amp;&amp;amp; GPStatus==0)&#xA;      {&#xA;        GPStatus=1;&#xA;        sms.start(celprim);&#xA;        sms.print(&quot;Imposible ubicar equipo, intente mas tarde...&quot;);&#xA;        sms.send();        &#xA;      }&#xA;    }while (GPStatus ==0);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  delay (5000);&#xA;  int beginStatus = cell.begin();&#xA;  if (beginStatus &amp;lt;= 0)&#xA;  {&#xA;     while(1)&#xA;      ;&#xA;  }&#xA;  delay (10000);&#xA;  sms.setMode(SMS_TEXT_MODE);   //Se pone al modulo en modo de recepción y envio de sms&#xA;  ALTS.begin(115200); // Or whatever rate the GPS uses&#xA;  configurado();&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;  if (GPStatus==0)&#xA;  {&#xA;    temp = millis();&#xA;    GPSTracking();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use only AltSoftSerial to create 2 serial ports and communicate with both cell and GPS in order to reduce program storage and global variables space? If it's possible, what changes should do in the &lt;a href=&quot;https://github.com/sparkfun/SparkFun_MG2639_Cellular_Shield_Arduino_Library/&quot; rel=&quot;nofollow&quot;&gt;MG2639 library&lt;/a&gt; to make it work?&#xA;Or what could i do to reduce space.&lt;/p&gt;&#xA;" OwnerUserId="22906" LastEditorUserId="186" LastEditDate="2016-06-12T16:52:42.533" LastActivityDate="2016-06-12T16:52:42.533" Title="MG2639 CELL AND GPS LIBRARIES" Tags="|arduino-uno|library|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25093" PostTypeId="2" ParentId="25060" CreationDate="2016-06-10T18:11:22.320" Score="3" Body="&lt;p&gt;I prefer to use arduino type boards as data acquisition units then transfer the data to an actual computer (or raspberry pi) in most of my projects. Arduinos are, in my experience, much more tolerant of fault and accidental crossed circuits than the R pi.  Thus is especially true of the ruggedized or industrial arduino versions. &lt;/p&gt;&#xA;" OwnerUserId="21687" LastActivityDate="2016-06-10T18:11:22.320" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25094" PostTypeId="2" ParentId="25059" CreationDate="2016-06-10T18:27:05.007" Score="1" Body="&lt;p&gt;It looks like Sparkfun probably only put the bootloader on the board. The &lt;a href=&quot;https://learn.sparkfun.com/tutorials/el-sequencerescudo-dos-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; is written in a way that suggests the need to flash the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also the board does not imediatly work with the 12V inverter. If you have the battery you should attach it and see the &lt;code&gt;PWR&lt;/code&gt; LED turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The inverter only provides voltage to the EL wire&lt;/em&gt; and &lt;strong&gt;not the Microcontroller&lt;/strong&gt;, power to the microcontroller is provided by way of a regulator(&lt;code&gt;U2&lt;/code&gt;), &lt;strong&gt;&lt;em&gt;not&lt;/strong&gt; the LM317&lt;/em&gt; the last quote from the one comment shows how you can connect to the 12V inverter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should do instead of having to go the route of all the wiring is to connect both the battery to &lt;code&gt;BATT IN&lt;/code&gt; and the inverter, but ensuring that the microcontroller is programmed before hand.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino Code&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Once you have all of your hardware hooked up properly, it’s time to&#xA;  program your Sequencer to run the EL Wire display as you want. You&#xA;  will need to download the Arduino code in order to follow along with&#xA;  the example.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can also download the most up-to-date code from the EL Sequencer&#xA;  &lt;a href=&quot;https://github.com/sparkfun/EL_Sequencer&quot; rel=&quot;nofollow&quot;&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;We will be working with the “SparkFun_EL_Example.ino” example. If you&#xA;  need a review on how to upload Arduino code to your board or using the&#xA;  Arduino IDE, please check our tutorial &lt;a href=&quot;https://learn.sparkfun.com/tutorials/installing-arduino-ide&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. Also, if you are unsure&#xA;  about installing the FTDI drivers, please check out &lt;a href=&quot;https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also from one of the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/el-sequencerescudo-dos-hookup-guide/discuss&quot; rel=&quot;nofollow&quot;&gt;Tech support notes&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Using 12V to Power Both the EL Inverter &amp;amp; Microcontroller&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If you are using a 12V wall adapter to power the 12V Inverter, you&#xA;  would still need to provide power to the microcontroller side. One&#xA;  solution with your 12V wall adapter to provide power to the 12V&#xA;  inverter and Atmega328P is to get a barrel jack adapter to 2 pin JST&#xA;  adapter [ &lt;a href=&quot;https://www.sparkfun.com/products/8734&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8734&lt;/a&gt; ], thus connecting&#xA;  the 12V wall adapter to the “BATT IN.” This is assuming that your wall&#xA;  adapter is using a center positive barrel jack.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;From there you can connect the 2 pin JST labeled “DC Out” to the 12V&#xA;  inverter’s input voltage. To connect, I recommend using the male DC&#xA;  barrel jack adapter [ &lt;a href=&quot;https://www.sparkfun.com/products/10287&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/10287&lt;/a&gt; ] and a&#xA;  2pin JSt jumper wire [ &lt;a href=&quot;https://www.sparkfun.com/products/8670&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8670&lt;/a&gt; or&#xA;  &lt;a href=&quot;https://www.sparkfun.com/products/8671&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/8671&lt;/a&gt; ]. You will need to wire strip&#xA;  the cable to be able to connect it to the screw terminals.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Lastly, you would need to add a solder jumper to SJ1 so that you&#xA;  bypass the voltage regulator between your external power (“BATT IN”)&#xA;  to provide power to the inverter’s “DC OUT”. This will provide power&#xA;  to your 12V inverter’s input.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Warning: if SJ1 is closed, inverter will see 5V with FTDI plugged in and switch at USB&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-06-10T18:27:05.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25095" PostTypeId="2" ParentId="24847" CreationDate="2016-06-10T18:44:46.137" Score="2" Body="&lt;p&gt;From what I can tell it's absolutely possible but will take some considerable development time and around $30-$70 of hardware per NFC terminal. Please note I would strongly not recommend this as a first project as it has a lot of individual components that all have to work together flawlessly and each is different. Properly done this will be complex software and hardware wise although more so from the hardware side of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hardware wise you need/terminal:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;LCD display&lt;/strong&gt; (I would recommend segmented for simplicity and cost)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Wifi or ethernet shield/breakout&lt;/strong&gt; and ethernet cable if the board is not wifi compatible&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Arduino&lt;/strong&gt; (MKR1000 has wifi built in), Feather (Adafruit's boards that are frequently Arduino software compatible and have many shields available and guides written on how to use them), or cheap Arduino knock off (preferably not this option as giving money to arduino.cc, Adafruit, or other designers is important if we want new boards regularly)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;NFC breakout&lt;/strong&gt; or shield (Google/DuckDuckGo/Bing RFID-RC52 for an economical option, they're ~$4 on Ebay)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Power supply&lt;/strong&gt; corresponding to the requirements of the chosen board + shields + breakouts&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;NFC tags&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Lock&lt;/strong&gt; able to be unlocked by a servo. If you expect security in absence of supervising shop manager (aka just to be safe, assume dishonesty in people using the shop) from this system, the locks need to be better than a Masterlock as those are insecure to even simple soda can shims. The rotary masterlocks can also be reduced to 100 possible combinations and then the combo can be brute forced easily from there so if you get a rotary based lock system make sure the assembly covering the dial is not easily removed.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Servo or stepper&lt;/strong&gt; powerful enough to actuate locks&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Servo or stepper driver breakout board&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Then you'd just want to have the public key (note I don't mean a &quot;public key&quot; in the general cryptography sense but on that subject, you do want the key encrypted) to the user stored on the NFC tag and then use the arduinos+electronics to read the tags and see point values. User data from wordpress could be downloaded periodically to the boards so the individual checks don't use network resources and the system works offline.&lt;/p&gt;&#xA;" OwnerUserId="20273" LastEditorUserId="20273" LastEditDate="2016-06-10T18:50:46.567" LastActivityDate="2016-06-10T18:50:46.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25097" PostTypeId="1" CreationDate="2016-06-10T18:57:40.060" Score="1" ViewCount="17776" Body="&lt;p&gt;I bought a ESP 8266 &amp;amp; I am able to send AT commands and receive response via serial monitor when I upload a empty sketch. I changed the baud rate from 115200 to 9600 by using &lt;code&gt;AT+CIOBAUD=9600&lt;/code&gt; and am able to run AT commands at 9600 baud rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Empty Sketch:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;{&#xA;&#xA;}&#xA;void loop() &#xA;{&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is how my circuit looks:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/Ec228.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ec228.png&quot; alt=&quot;Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when I create a custom sketch to run AT commands it doesn't work. Here is how my sketch looks:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial esp8266(0,1); //RX,TX&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600); &#xA;&#xA;  Serial.println(&quot;Run AT Command&quot;);&#xA;&#xA;   esp8266.print(&quot;AT\r\n&quot;);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;   String response = &quot;&quot;;&#xA;   while(esp8266.available())     {&#xA;        char c = esp8266.read(); &#xA;        response+=c;&#xA;        Serial.print(c);&#xA;      }  &#xA;&#xA;      if(response != &quot;&quot;){&#xA;        Serial.println(response);&#xA;      }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ESP8266 is receiving 3.3V but I have read TX and RX sends 5V, and they also need to be 3.3V. Don't know if thats what is causing it, but I am able to run AT commands on empty sketch, so this is a bit weird.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My sketch is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial esp8266(2, 3); //RX,TX&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(9600);&#xA;&#xA;&#xA;  esp8266.print(&quot;AT\r\n&quot;);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  String response = &quot;&quot;;&#xA;  while (esp8266.available())     {&#xA;    char c = esp8266.read();&#xA;    response += c;&#xA;  }&#xA;&#xA;    if (response != &quot;&quot;) {&#xA;      Serial.println(&quot;Response: &quot; + response);&#xA;    }&#xA;&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Serial Monitor shows this:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Response: A&#xA;Response: T&#xA;&#xA;&#xA;OK&#xA;Response: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OUTPUT when I run AT+CIFSR command:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Response: A&#xA;Response: T+CIFSR&#xA;&#xA;&#xA;Response: &#xA;+CIFSR:APIP&#xA;Response: ,&quot;192.168.4.1&#xA;Response: &quot;&#xA;+CIFSR:APMA&#xA;Response: C,&quot;5e:cf:7f:80&#xA;Response: :f7:74&quot;&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question now is:&lt;/strong&gt; How do I store the string being returned from the esp8266. I thought my response string was suppose to store the &quot;OK&quot; but that did not happen.&lt;/p&gt;&#xA;" OwnerUserId="22907" LastEditorUserId="22907" LastEditDate="2016-06-12T21:48:53.933" LastActivityDate="2020-06-28T10:58:57.727" Title="Arduino Uno - ESP 8266: sending AT commands via Code" Tags="|arduino-uno|esp8266|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25098" PostTypeId="2" ParentId="25092" CreationDate="2016-06-10T19:06:02.017" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to use only AltSoftSerial to create 2 serial ports and communicate with both cell and GPS in order to reduce program storage and global variables space?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The question is a little vague.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;AltSoftSerial&lt;/code&gt; only works on pins 8 &amp;amp; 9, so I thought you were asking if you could connect both the cell and the GPS to pins 8 &amp;amp; 9 (using jumper pads on the back of the board), and use one &lt;code&gt;AltSoftSerial&lt;/code&gt; instance to talk to both devices.  If it were possible, this would save RAM (just one instance) and program space (you wouldn't need two link in another software serial class, like &lt;code&gt;SoftwareSerial&lt;/code&gt;).  However, this is not possible.  Serial connections are always point-to-point.  Although two &quot;things&quot; can listen to one RX line, the TX line cannot be shared by two devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you were asking if you can have two instances of &lt;code&gt;AltSoftSerial&lt;/code&gt; on two separate pairs of pins (e.g., 2/3 and 8/9), the answer is again &quot;No&quot;, because... &lt;code&gt;AltSoftSerial&lt;/code&gt; only works on pins 8 &amp;amp; 9.  Also, the SparkFun library only uses SoftwareSerial to talk to the cell.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;what could i do to reduce space.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Use &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow&quot;&gt;NeoGPS&lt;/a&gt; instead, and use the F macro around double-quoted strings that you print:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    sms.print( F(&quot;Imposible ubicar equipo, intente mas tarde...&quot;) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will save several hundred bytes of RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you may be sending multiple SMS's per second.  It depends on what sentences the GPS emits.  As it is, your sketch will send one SMS per sentence (i.e., one for each &lt;code&gt;encode&lt;/code&gt;).  Even if you don't use NeoGPS, look at the example program &lt;code&gt;NMEAloc.ino&lt;/code&gt; et al for the correct program structure.  The Troubleshooting section also contains some tips.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2016-06-11T15:45:36.450" LastActivityDate="2016-06-11T15:45:36.450" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25108" PostTypeId="1" AcceptedAnswerId="25111" CreationDate="2016-06-11T06:44:53.960" Score="1" ViewCount="1058" Body="&lt;p&gt;I am planning an uno based tachometer for my truck, which doesn't have a tachometer. With nothing in place for me to get a reliable signal, I started looking at other sources to read the rpm from the engine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems to me that an engine should affect the power every time a cylinder fires --the power should spike in some way. So in theory I should be able to hook up to the 12v cigar lighter, count the spikes, and calculate the rpm. It would only need to be accurate within 500 rpm or so. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a two part question. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How would I hook up the arduino to the 12v system? As in, what should I do to protect the io of the arduino?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;How would I gather the test data to see if this is possible? Is there a way to hook the arduino up to the truck via the 12v and my computer via usb and send data back that I can record or monitor?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="16757" LastActivityDate="2016-06-11T11:37:43.193" Title="Hooking up the Arduino to a car's 12v" Tags="|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25109" PostTypeId="1" CreationDate="2016-06-11T06:50:22.920" Score="0" ViewCount="59" Body="&lt;p&gt;I was making a home automation system by making some of the appliances in the home like fans and lights voice activated. But by mistake I bought a remote controlled relay in place of a normal relay from a shop and return does not seems possible. So I want to know if I will be able to use that remote controlled relay in this project?&lt;/p&gt;&#xA;" OwnerUserId="22921" LastActivityDate="2016-09-09T21:32:17.130" Title="Can I connect a remote control relay to a arduino uno board by disabling the remote control in the relay?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25110" PostTypeId="1" AcceptedAnswerId="25194" CreationDate="2016-06-11T07:00:07.477" Score="2" ViewCount="156" Body="&lt;p&gt;For some time now I've been playing around with the latest version of Arduino IDE and my UNO and ATTiny with simple 433 RF links with the Manchester Library. It all worked fine, but for my next project I want to take the step up and use a better wireless thingy... like the nRF24l01 or the nfm12b.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And then starts the pain. Attiny does not have hardware serial, but people seems to have solved this by implementing software-serial. But then they have to use some other boards for ATTiny, because when I try to run the examples I get error messages that it could not find  and so on. I use the ATTiny boards I found over at &lt;a href=&quot;https://code.google.com/archive/p/arduino-tiny/&quot; rel=&quot;nofollow&quot;&gt;google code&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the RFM12B I got something to compile. If I went back and downloaded Arduino IDE 1.5.0 (no other!) it actually work with the JeeLib - hurray! Why is this, why can't I use the latest version of the Arduino IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regarding the NRF24 chip this case is unresolved. I have not found the correct combination of boards, IDE and library versions. Could anyone point me in the right direction?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the difference between the Arduino IDE's? Why can I get stuff to work on 1.5.0 but not the latest 1.6.x?&lt;/p&gt;&#xA;" OwnerUserId="22919" LastEditorUserId="11529" LastEditDate="2016-06-14T15:37:13.040" LastActivityDate="2016-06-14T17:06:35.093" Title="Difference between Arduino IDE giving me headaches" Tags="|arduino-ide|attiny|nrf24l01+|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25111" PostTypeId="2" ParentId="25108" CreationDate="2016-06-11T11:37:43.193" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How would I hook up the arduino to the 12v system? As in, what should I do to protect the io of the arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;First you're going to need to do some investigative work. You're going to need to beg, steel, borrow (or use your own if you have one) an oscilloscope. You can then use that to examine the 12V power coming from the cigarette lighter.  Armed with that you can then tell:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If there is any power fluctuation from the engine, and&lt;/li&gt;&#xA;&lt;li&gt;What form that fluctuation takes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If there is any fluctuation it will appear as an AC component imposed on top of the 12V DC voltage. Removing the 12V DC offset is simple enough. All you need to do is pass the power through a &lt;em&gt;high pass&lt;/em&gt; filter. That's simply a capacitor and a resistor. You need to ensure that the cut-off frequency of the filter is below the lowest frequency you want to measure (idle frequency) yet high enough to cut out the DC component effectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you have done that you can then clip the waveform using a diode to protect against negative voltage, and a resistor and zenner diode to limit the positive voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, something similar to the following (it's not exact - the source isn't creating spikes, but an offset low duty cycle PWM, which is kind of similar for demonstration purposes):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lCfpI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lCfpI.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first point measured is the 12V signal with big high voltage spikes. Next the power has been high-pass filtered by the RC network and the lower portion of the waveform clipped by the reverse biased diode. Following that the zenner diode clips the upper portion of the waveform to within safe limits for the Arduino. The 100Ω resistor with the zenner is there to limit the current through the zenner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't take any of those values as gospel, since the signal I am filtering there is not your signal. You need to know your signal first before you can work out exactly how it should be filtered, but that gives you the basic idea of how it can be done.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How would I gather the test data to see if this is possible? Is there a way to hook the arduino up to the truck via the 12v and my computer via usb and send data back that I can record or monitor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Connect the filtered and clipped signal to an interrupt input on the Arduino. Count the pulses within a given time period (1 second, 5 seconds, whatever you choose) and multiply up for number of pulses in a minute. Don't forget to then divide by 4 for a 4-cylinder engine, since I would expect you would see 4 sparks per revolution. How you then gather the data is up to you. It might be simplest to add an SD card shield to your Arduino and record the data onto an SD card. You can then place that card into your computer to process the data at your leisure. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way to power your Arduino is, of course, direct from the truck's power. The safest way, because of all those nasty spikes in the power, is to use car USB phone charger adapter. Plug that into the USB of the Arduino and all should be nice and happy.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-11T11:37:43.193" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25112" PostTypeId="1" CreationDate="2016-06-11T13:03:46.747" Score="1" ViewCount="2775" Body="&lt;p&gt;I intend to perform data logging from sensors and store it on SD card as CSV format. The data is related to weather and I would like to send it at the end of the day/&#xA;Any available codes how to deploy the SD files from Arduino to the cloud/online at specific time of the day?&#xA;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-10-26T00:58:01.147" Title="Arduino: Sending SD CSV file online at specific time of the day" Tags="|arduino-uno|arduino-ide|sd-card|timers|datalogging|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25116" PostTypeId="2" ParentId="25109" CreationDate="2016-06-11T18:21:14.327" Score="1" Body="&lt;p&gt;I don't like to work with mains, so I use those outlets and connect a &lt;a href=&quot;http://www.ebay.com/itm/NEW-433Mhz-RF-transmitter-link-kit-for-Arduino-ARM-MC-U-Remote-control-Sale-/321975775117?hash=item4af7406f8d:g:ed8AAOSwFqJWlzgA&quot; rel=&quot;nofollow&quot;&gt;433MHz transmitter&lt;/a&gt; to the arduino to activate the outlets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'd have to check the frequency of the unit, and see if anyone have decoded the transmitted data package.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't float you're boat, you could open up the unit, and remove/desolder the relay. Add a transistor, and flyback diode and you're done. Just be careful with mains power.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-11T18:21:14.327" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25118" PostTypeId="1" AcceptedAnswerId="25133" CreationDate="2016-06-11T18:49:35.097" Score="3" ViewCount="1167" Body="&lt;p&gt;&lt;strong&gt;The concept:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Play a sine wave saved as a character array in PROGMEM through an 8-bit DAC connected to the PORTC pins on the Arduino Mega.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;This works:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// File just defines an array and a size&#xA;&#xA;#include &amp;quot;sine440.h&amp;quot;&#xA;&#xA;int i = 0;&#xA;void setup() {&#xA;  DDRC = B11111111;&#xA;}&#xA;&#xA;void loop() {&#xA;  PORTC = pgm_read_byte(&amp;amp;sine[i++]);&#xA;  if(i &amp;gt;= sine_size){&#xA;    i = i - sine_size;&#xA;  }&#xA;&#xA;  delayMicroseconds(60);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above code produces a sine wave of about 440 Hz, exactly what I wanted. Now, I'd like to move this into an interrupt routine, as follows:&lt;/p&gt;&#xA;&lt;h3&gt;This doesn't work&lt;/h3&gt;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;quot;sine440.h&amp;quot;&#xA;&#xA;int i = 0;&#xA;void setup() {&#xA;  DDRC = B11111111;&#xA;  TCCR5B = (1 &amp;lt;&amp;lt; WGM52) | (1 &amp;lt;&amp;lt; CS50 );&#xA;  OCR5A =  16000000/16000;&#xA;  TIMSK5 = (1 &amp;lt;&amp;lt; OCIE5A);&#xA;}&#xA;&#xA;ISR(TIMER5_COMPA_vect){&#xA;  PORTC = pgm_read_byte(&amp;amp;sine[i++]);&#xA;  if(i &amp;gt;= sine_size){&#xA;    i = i - sine_size;&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The above code produces a sine wave of 1721 Hz. I know that this means it's iterating through the array too fast, but I don't know how to change it. In order for it to produce 440 Hz, it needs to be preforming 16,000 iterations per second, which is what I believe &lt;code&gt; OCR5A =  16000000/16000;&lt;/code&gt; does. &lt;strong&gt;But&lt;/strong&gt; it doesn't appear that changing the value of OCR5A does anything at all. Giving it the max value of 65,535 still produces a 1721 Hz sine wave...&lt;/p&gt;&#xA;&lt;p&gt;So what am I doing wrong here? How do I change the speed of this timer interrupt?&lt;/p&gt;&#xA;" OwnerUserId="22928" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-02-15T20:25:50.780" Title="Setting the frequency of a timer interrupt" Tags="|arduino-mega|interrupt|timers|sound|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25121" PostTypeId="1" CreationDate="2016-06-12T01:07:50.357" Score="3" ViewCount="1730" Body="&lt;p&gt;I am making an IoT device with the MKR1000.&lt;/p&gt;&#xA;&lt;p&gt;As a part of the process, I would like to set up an HTTPS connection to &lt;a href=&quot;https://hit.tl8.co/api/ping&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://hit.tl8.co/api/ping&lt;/a&gt; (this is a website I have made and control).&lt;/p&gt;&#xA;&lt;p&gt;The problem is that &lt;code&gt;client.connect(url, 443)&lt;/code&gt; is returning false. I have tried normal HTTP and the URL works on a browser. I can also access &lt;a href=&quot;https://www.google.com&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.google.com&lt;/a&gt;. The code is a small variation of the example HTTP client.&lt;/p&gt;&#xA;&lt;p&gt;As such, I believe that the TLS certificate I am using is not accessible by the MKR1000. Running this &lt;a href=&quot;https://www.ssllabs.com/ssltest/analyze.html?d=hit.tl8.co&amp;amp;s=2400%3a6180%3a0%3ad0%3a0%3a0%3a3e3%3a1&amp;amp;latest&quot; rel=&quot;nofollow noreferrer&quot;&gt;report&lt;/a&gt; shows that it is a RSA 2048 bits (e 65537) with SHA256withRSA certificate.&lt;/p&gt;&#xA;&lt;p&gt;Is there a way to get the MKR1000 to accept this certificate? Failing that, what changes do I need to make to this certificate for it to work?&lt;/p&gt;&#xA;&lt;p&gt;Is there a software solution to get this certificate working?&lt;/p&gt;&#xA;" OwnerUserId="22932" LastEditorUserId="61722" LastEditDate="2022-08-06T08:42:20.857" LastActivityDate="2023-05-03T19:08:46.097" Title="HTTPS Client with MKR1000" Tags="|wifi|http|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="25122" PostTypeId="1" CreationDate="2016-06-12T01:18:25.883" Score="1" ViewCount="2848" Body="&lt;p&gt;Before I tear all my hair and teeth out, can anyone please help. I have tried googling an answer and have not found anything. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Setup:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Win7 64bit&lt;/li&gt;&#xA;&lt;li&gt;Arduino 1.6.9 IDE freshly reinstalled&lt;/li&gt;&#xA;&lt;li&gt;COM14 port in Arduino IDE checked&lt;/li&gt;&#xA;&lt;li&gt;Under Device Manager COM14 shows as: &quot;USB Serial Port (COM14)&quot;. Not as &quot;Arduino...(COM14)&quot; as some pages have shown&lt;/li&gt;&#xA;&lt;li&gt;I am not sure if I have a real or copy of the Arduino. As far as I can figure out I have a real one, on the back I have the FT232RL chip&lt;/li&gt;&#xA;&lt;li&gt;I have bought 2 Arduino Nanos and both show same error&lt;/li&gt;&#xA;&lt;li&gt;Both Nanos came pre-soldered, (no noob soldering by me)&lt;/li&gt;&#xA;&lt;li&gt;I have tried uploading sketches on my Win7 platform AND over a Raspberry Pi, both same error&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Now perhaps most importantly I previously ordered an Arduino from the same retailer and that one worked. The two I have now dont work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;When I try upload I get the same message every time: &lt;strong&gt;avrdude: stk500_recv(): programmer is not responding&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a. it does this 10 times and then fails&lt;/p&gt;&#xA;&#xA;&lt;p&gt;b. Rx and Tx LED's are ON and do NOT blink at all at any point in time&lt;/p&gt;&#xA;&#xA;&lt;p&gt;c. Green power LED is always ON, no blinking&lt;/p&gt;&#xA;&#xA;&lt;p&gt;d. Pin13 LED blinks consistently&lt;/p&gt;&#xA;&#xA;&lt;p&gt;e. I have tried the extreemly annoying reset &quot;trick&quot; before uploading, after uploading, at the same time, during uploading, and nothing works&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I am seriously at a loss here. I have had an Arduino Nano work on my pc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated please. &lt;/p&gt;&#xA;" OwnerUserId="22933" LastEditorUserId="19409" LastEditDate="2016-10-16T17:12:47.000" LastActivityDate="2019-03-18T12:26:35.960" Title="Arduino Nano Update failure - avrdude: stk500_recv(): programmer is not responding" Tags="|arduino-nano|uploading|programmer|windows|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25123" PostTypeId="1" AcceptedAnswerId="25124" CreationDate="2016-06-12T01:39:00.520" Score="0" ViewCount="906" Body="&lt;p&gt;I have wired up a 74HC595N with an Uno, and the standard 8 LEDs and resistors, per the usual youtube &quot;shift register tutorial&quot; and written a sketch that works.  For example, I wrote a routine to walk from values 0 through 255 and light up the LEDs as a hex number.  So my wiring and code are correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an experiment, I tried disconnecting the pin on my breadboard's power rail that goes to the Arduino 5V, and the pin that goes to Arduino ground, and instead plugged in a breakout (if that's the right word) that plugs into the breadboard and provides 5V on the power rail when a 9V battery is plugged into it.  (It's been checked with a multimeter, it's just under 5V.)  The only pins still going to the Arduino are for DS, SHCP and STCP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things sort of work, but not really.  It seems clear to me that the shift register keeps getting reset. (All of the LEDs briefly light back up in each iteration as I'm running my hex number display routine.) All of the other wiring remains the same; specifically OE-bar is still connected to ground on the power rail.  But it still seems to reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone explain why the shift register keeps resetting?  Also, am I doing anything that might burn up the Arduino and/or shift register?&lt;/p&gt;&#xA;" OwnerUserId="22934" LastActivityDate="2016-06-12T01:47:19.563" Title="74HC595N shift register with separate power supply" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25124" PostTypeId="2" ParentId="25123" CreationDate="2016-06-12T01:47:19.563" Score="3" Body="&lt;p&gt;All ground connections except those which are explicitly isolated must be connected together in order to provide a common voltage reference for the circuit. Any breaks in the ground connection can result in gross misbehavior such as what you are experiencing.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-12T01:47:19.563" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25125" PostTypeId="1" AcceptedAnswerId="25126" CreationDate="2016-06-12T02:16:10.730" Score="5" ViewCount="48274" Body="&lt;p&gt;I am making an Arduino alarm. This is the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;exit status 1&#xA;invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code that triggers it: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(&quot;0&quot;+hours+&quot;:&quot;+minutes);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code is similar, but worked before:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String none=&quot;00&quot;;&#xA;lcd.print(none+&quot;:&quot;+none+&quot;:&quot;+minutes);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can post the full code if you need it. How can this be fixed?&lt;/p&gt;&#xA;" OwnerUserId="18804" LastActivityDate="2016-06-12T02:23:46.673" Title="Why do I get &quot;invalid operands of types 'const char*'&quot; error?" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25126" PostTypeId="2" ParentId="25125" CreationDate="2016-06-12T02:23:46.673" Score="7" Body="&lt;p&gt;Your first code took a &lt;code&gt;String&lt;/code&gt; object, then added other strings (note lowercase) to it - which are characters enclosed in quotes. It is legal to add strings to &lt;code&gt;String&lt;/code&gt; objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your new code doesn't have any &lt;code&gt;String&lt;/code&gt; objects at all - and you're not allowed to add strings to strings (both lowercase).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will work if you change your new code to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+minutes);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That turns the original string &lt;code&gt;&quot;0&quot;&lt;/code&gt; into a &lt;code&gt;String&lt;/code&gt; object, and then adds more strings to it.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-12T02:23:46.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25127" PostTypeId="1" CreationDate="2016-06-12T03:24:07.433" Score="2" ViewCount="790" Body="&lt;p&gt;It works as expected for a few seconds and then random letters appear on the second row. The wiring and the programming should be correct. I wired it according to an Arduino Starter Kit Book and coded it myself. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/DvX0B.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/DvX0B.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/XJ0OI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XJ0OI.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;int hours=23;&#xA;int minutes=0;&#xA;String none=&quot;00&quot;;&#xA;unsigned long timer;&#xA;void setup() {&#xA;lcd.begin(16, 2);&#xA;lcd.setCursor(6, 0);&#xA;lcd.print(&quot;Time:&quot;);&#xA;lcd.setCursor(6, 1);&#xA;lcd.print(&quot;23:00&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;timer=millis();&#xA;if(timer%600==0){&#xA;   minutes++;&#xA;  if(minutes==60){&#xA;      minutes=0;&#xA;      hours++;&#xA;      }&#xA;   if(hours==24){&#xA;      hours=0;&#xA;   }&#xA;  lcd.clear();&#xA;  lcd.setCursor(6, 0);&#xA;  lcd.print(&quot;Time:&quot;);&#xA;  lcd.setCursor(6, 1);&#xA;  if(minutes&amp;lt;10){&#xA;    if(hours&amp;lt;10){&#xA;      lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+&quot;0&quot;+minutes);&#xA;    }&#xA;    else{&#xA;      lcd.print(hours+String(&quot;:&quot;)+&quot;0&quot;+minutes);&#xA;    }&#xA;  }&#xA;  else{&#xA;    if(hours&amp;lt;10){&#xA;       lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+minutes);&#xA;    }&#xA;    else{&#xA;       lcd.print(hours+&quot;:&quot;+minutes);&#xA;    }&#xA;&#xA;  }&#xA;  delay(200);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was able to narrow down the problem. I was testing what happens when it hits 24 hours so I set hours to 23 in the beginning and made the time 600 ms. Once it hits 10 seconds, the characters appear. If the hour is a 2 digit number, the issue happens. I made the hours 9, and the issue disappeared. What can I do?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-06-12T03:49:43.827" LastActivityDate="2016-06-12T03:55:31.687" Title="Why does my lcd screen work fine and then display random characters?" Tags="|arduino-uno|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25128" PostTypeId="2" ParentId="25127" CreationDate="2016-06-12T03:55:31.687" Score="3" Body="&lt;p&gt;The problem was that I was adding &quot;:&quot; to the printed string on the lcd without making it a String object. That only occurred if I had double digit hours and minutes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incorrect way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(hours+&quot;:&quot;+minutes);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Correct way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;lcd.print(hours+String(&quot;:&quot;)+minutes);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-06-12T03:55:31.687" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25132" PostTypeId="2" ParentId="19985" CreationDate="2016-06-12T11:27:37.140" Score="15" Body="&lt;p&gt;Lua, like many scripting languages, tends to make you a lot more&#xA;productive as a programmer: things become far easier as you work at a&#xA;higher abstraction level and do not worry about trivial things like&#xA;memory management. You achieve the same goals with far less lines of&#xA;code. On the other hand, whereas it makes development faster, it also&#xA;makes program execution slower. Whether this is a good trade-off or not&#xA;is very dependent on the particular application you want to write.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your particular case, you also have to consider the fact that you do&#xA;not know Lua, and you already know both the C++ language and the Arduino&#xA;API. Then you may not rip the benefits of Lua on a single project,&#xA;because of the time needed to learn the language. You may consider&#xA;learning the language as an investment, probably worth it if you are&#xA;going to program a lot on this platform, probably &lt;em&gt;not&lt;/em&gt; worth it if it's&#xA;only for a single, simple enough project. If unsure, I suggest you take&#xA;a look at the API provided with Lua on this platform: how well does it&#xA;fit your project? Is it a significantly better fit than the Arduino API?&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-12T11:27:37.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25133" PostTypeId="2" ParentId="25118" CreationDate="2016-06-12T12:53:07.470" Score="3" Body="&lt;p&gt;I second BrettAM's comment. The Arduino IDE sets most of all the timers up for PWM, and I had to comment out a section once to use my own ISR with Timer&amp;nbsp;3 on a 32u4, because no matter where or how I set it, the CTC interrupt never went. The &lt;code&gt;WGM50&lt;/code&gt; and &lt;code&gt;CS51&lt;/code&gt; are set at the start of the Arduino files basically, so that messes with your settings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need go into the Arduino core files. This is &lt;code&gt;$install_path/arduino-1.x.x/hardware/arduino/avr/cores/arduino/&lt;/code&gt;, and under that directory you need to find file &lt;code&gt;wiring.c&lt;/code&gt;. This file contains all the setup of the timers for PWM and the &lt;code&gt;millis()&lt;/code&gt; or &lt;code&gt;micros()&lt;/code&gt; functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go to line 342. Located there is this:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#if defined(TCCR5B) &amp;amp;&amp;amp; defined(CS51) &amp;amp;&amp;amp; defined(WGM50)&#xA;&#xA;  sbi(TCCR5B, CS51);           //set ter 5 prescale factor to 64&#xA;  sbi(TCCR5B, CS50);&#xA;  sbi(TCCR5A, WGM50);         // put timer 5 in 8-bit phase correct pwm mode&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here you can place another &lt;code&gt;#if defined()&lt;/code&gt; macro around this, resulting in:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#if !defined(doNotSetTimer5)&#xA;&#xA;  #if defined(TCCR5B) &amp;amp;&amp;amp; defined(CS51) &amp;amp;&amp;amp; defined(WGM50)&#xA;&#xA;    sbi(TCCR5B, CS51);           //set ter 5 prescale factor to 64&#xA;    sbi(TCCR5B, CS50);&#xA;    sbi(TCCR5A, WGM50);         // put timer 5 in 8-bit phase correct pwm mode&#xA;&#xA;  #endif&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when you want to use your custom settings, you will put the following at the top of your .ino file:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define doNotSetTimer5&#xA;#include &amp;lt;wiring.c&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does not block the Arduino environment from setting up Timer&amp;nbsp;5 when compiled with other code, but only when you want to use custom settings (changed because of @Gerben's suggestion). When you change these settings you will lose PWM on 3 pins: &lt;code&gt;44 45 46&lt;/code&gt;. But you will be able to make use of setting your own PWM up or a CTC &lt;code&gt;ISR()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't mess with anything else and is the easiest way to do it.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="972" LastEditDate="2018-02-15T20:25:50.780" LastActivityDate="2018-02-15T20:25:50.780" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25134" PostTypeId="1" AcceptedAnswerId="25139" CreationDate="2016-06-12T13:50:27.473" Score="2" ViewCount="259" Body="&lt;p&gt;I am trying to hack a cheap RC car as to be able to control it using my Arduino. I took apart the cars remote controller and found the pins that make it go forwards, backwards, left, and right. So I soldered 4 jumper wires to these pins and connected them to the Arduino as follows:&#xA;Pin 8 - Left&#xA;Pin 9 - Right&#xA;Pin 10 - Forwards&#xA;Pin 11 - Backwards&#xA;I found the remote controller is controlled by a chip called TX-2E, I checked the data sheet online and found that if any of the pins that control the pins motion are ground, the car will move in that corresponding direction. So if the forwards pin is grounded the car is supposed to move forwards.&#xA;To test this, I connected each jumper wire to ground on the Arduino individually and found that it worked as described on the datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I decided to create a sketch that makes the car move forwards for 1 second and backwards for 1 second, it worked as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I wrote a sketch that makes the wheels turn left for 1 second and then turn right for 1 second. But it didn't work as expected instead the wheel turned left for 1 second, went to neutral for a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wasn't sure what was wrong, but I decided to run a sketch that should move the car forwards for 1 second, move it backwards for 1 second, turn the wheels left for 1 second, and then turn right for 1 second. But all it actually did was just turn left for 1 second every couple of seconds. I removed the jumper wire connected to pin 8 that is supposed to control the wheels turning left, while the sketch was running and everything worked as expected except the turning left part. it moved forwards for 1 second, moved back for a second, waited at neutral for a second, and then turned right for a second. &#xA;When I connected back the jumper wire that controls the car moving left everything stops working again. I am not sure whats wrong, I even connected a multimeter to each pin and found they were pulsing between 0V and 5V as expected but for some reason they weren't moving the car, it was only moving left, in this case at least. &#xA;Any help to get this working, ideas to why its not working, or any troubleshooting tips would be greatly appreciated.&#xA;Below you can find the code for the sketch, that is supposed to move the car      forwards, backwards, left and right.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int LEFT = 8;&#xA;const int RIGHT = 9;&#xA;const int FWD = 10;&#xA;const int BWD = 11;&#xA;&#xA;void reset () {&#xA;  //Sets all pins to HIGH as the car moves when the pins are grounded.&#xA;  //And we want the car to start out by not moving.&#xA;&#xA;  digitalWrite(LEFT, HIGH); //For some reason everything works when I remove this&#xA;  digitalWrite(RIGHT, HIGH);&#xA;  digitalWrite(FWD, HIGH);&#xA;  digitalWrite(BWD, HIGH);&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;  pinMode(RIGHT, OUTPUT);&#xA;  pinMode(FWD, OUTPUT);&#xA;  pinMode(BWD, OUTPUT);&#xA;  pinMode(LEFT, OUTPUT);&#xA;  reset();&#xA;}&#xA;&#xA;void Forward(){&#xA;&#xA;  digitalWrite(FWD, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(FWD,HIGH);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void Backward(){&#xA;  digitalWrite(BWD, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(BWD, HIGH);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void Left(){&#xA;  digitalWrite(LEFT, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(LEFT, HIGH);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void Right(){&#xA;  digitalWrite(RIGHT, LOW);&#xA;  delay(1000);&#xA;  digitalWrite(RIGHT, HIGH);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  Forward();&#xA;  Backward();&#xA;  Left();&#xA;  Right();&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22945" LastActivityDate="2016-06-12T15:31:48.480" Title="RC Car Hack Issue" Tags="|arduino-uno|programming|hardware|electronics|remote-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25135" PostTypeId="1" CreationDate="2016-06-12T14:05:04.790" Score="0" ViewCount="2800" Body="&lt;p&gt;I bought &lt;a href=&quot;http://www.aliexpress.com/item/MEGA-2560-R3-ATmega2560-R3-AVR-USB-board-Free-USB-Cable-for-Arduino-2560-MEGA2560/32437126167.html&quot; rel=&quot;nofollow&quot;&gt;this Chinese Arduino Mega 2560 16AU&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This was the first time to deal with Arduino boards. When I try to upload a sketch I always get this error:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;stk500v2_getsync(): timeout communicating with programmer&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I successfully burnt a bootloader to it using an Arduino uno,&lt;br&gt;&#xA;but the same error is there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I discovered the the loop test is not working, and only the LX LED flashes once  when I enter a letter in the serial monitor. &lt;/p&gt;&#xA;" OwnerUserId="22946" LastEditorUserId="46" LastEditDate="2016-06-13T12:24:51.490" LastActivityDate="2017-03-13T02:44:41.600" Title="how can i fix the error ? stk500v2_getsync(): timeout communicating with programmer" Tags="|arduino-mega|bootloader|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25136" PostTypeId="2" ParentId="25135" CreationDate="2016-06-12T14:15:41.253" Score="1" Body="&lt;p&gt;It's our old friend the CH340G again, isn't it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've been sold a dud, I'm afraid. The USB chip used there is dead. It happens a lot with those cheap Chinese boards. You should still be able to use the board with an external FTDI adapter by wiring it in to TX-&gt;RX, RX-&gt;TX and DTR-&gt;RESET (via a 100nF capacitor) with power and ground connected of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a slim chance that the CH340G may interfere with the TX/RX pins, in which case you may need to remove it. Simply cutting the pins on it with an xacto knife then removing the stumps with a soldering iron and tweezers would do the job.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-12T14:15:41.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25137" PostTypeId="1" AcceptedAnswerId="25140" CreationDate="2016-06-12T15:08:53.163" Score="-2" ViewCount="23167" Body="&lt;p&gt;I have an unofficial Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tested these:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Testing on USB 2.0 and USB 3.0&lt;/li&gt;&#xA;  &lt;li&gt;Changing Port (COM XX)&lt;/li&gt;&#xA;  &lt;li&gt;Updating drivers for the Unknown device to Arduino Uno (COM XX)&lt;/li&gt;&#xA;  &lt;li&gt;Resetting Arduino Board&lt;/li&gt;&#xA;  &lt;li&gt;Plug/Unplug&lt;/li&gt;&#xA;  &lt;li&gt;1x PC Reboot&lt;/li&gt;&#xA;  &lt;li&gt;Burning bootloader&lt;/li&gt;&#xA;  &lt;li&gt;Changing 'Programmer'&lt;/li&gt;&#xA;  &lt;li&gt;Uninstalling-Reinstalling device&lt;/li&gt;&#xA;  &lt;li&gt;Holding the &quot;Reset&quot; button while I Upload&lt;/li&gt;&#xA;  &lt;li&gt;Testing different examples (Blinking/Voltage Serial Read)&lt;/li&gt;&#xA;  &lt;li&gt;Testing different &quot;Board&quot; in Arduino software (just in case, you never know)&lt;/li&gt;&#xA;  &lt;li&gt;Removing jump wires&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any suggestion more than I just tried? &lt;/p&gt;&#xA;" OwnerUserId="22947" LastEditorUserId="37523" LastEditDate="2019-12-09T03:24:26.253" LastActivityDate="2023-10-01T11:42:00.180" Title="avrdude: ser_open(): can't set com-state for &quot;\\.\COM2&quot;" Tags="|arduino-uno|" AnswerCount="3" CommentCount="15" ContentLicense="CC BY-SA 4.0" />
  <row Id="25138" PostTypeId="2" ParentId="19473" CreationDate="2016-06-12T15:30:02.790" Score="1" Body="&lt;p&gt;I have got same problem and you can solve it in minutes! Firstly check all your I2C addresses with same code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Wire.h&quot;&#xA;&#xA;byte start_address = 0;&#xA;byte end_address = 127;&#xA;&#xA;void setup()&#xA;{&#xA;  byte rc;&#xA;  Wire.begin();&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;\nI2C Scanner&quot;);&#xA;&#xA;  Serial.print(&quot;Scanning I2C bus from &quot;);&#xA;  Serial.print(start_address,DEC);  Serial.print(&quot; to &quot;);  Serial.print(end_address,DEC);&#xA;  Serial.println(&quot;...&quot;);&#xA;&#xA;  for( byte addr  = start_address;&#xA;            addr &amp;lt;= end_address;&#xA;            addr++ ) {&#xA;      Wire.beginTransmission(addr);&#xA;      rc = Wire.endTransmission();&#xA;&#xA;      if (addr&amp;lt;16) Serial.print(&quot;0&quot;);&#xA;      Serial.print(addr,HEX);&#xA;      if (rc==0) {&#xA;        Serial.print(&quot; found!&quot;);&#xA;      } else {&#xA;        Serial.print(&quot; &quot;); Serial.print(rc); Serial.print(&quot;     &quot;);&#xA;      }&#xA;      Serial.print( (addr%8)==7 ? &quot;\n&quot;:&quot; &quot;);&#xA;  }&#xA;&#xA;  Serial.println(&quot;\n-------------------------------\nPossible devices:&quot;);&#xA;&#xA;  for( byte addr  = start_address;&#xA;            addr &amp;lt;= end_address;&#xA;            addr++ ) {&#xA;      Wire.beginTransmission(addr);&#xA;      rc = Wire.endTransmission();&#xA;      if (rc == 0) {&#xA;        Serial.print(addr,HEX); Serial.print(&quot; = &quot;);&#xA;        switch (addr) {&#xA;          case 0x50: Serial.println(&quot;AT24C32/AT24C64 - EEPROM&quot;); break;&#xA;          case 0x68: Serial.println(&quot;DS1307&quot;); break;&#xA;          default: Serial.println(&quot;Unknown&quot;); break;&#xA;        }&#xA;      }&#xA;  }&#xA;&#xA;  Serial.println(&quot;\ndone&quot;);&#xA;}&#xA;&#xA;// standard Arduino loop()&#xA;void loop()&#xA;{&#xA;    // Nothing to do here, so we'll just blink the built-in LED&#xA;    digitalWrite(13,HIGH); delay(300);&#xA;    digitalWrite(13,LOW);  delay(300);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you will get something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I2C Scanner&#xA;Scanning I2C bus from 0 to 127...&#xA;00 2      01 2      02 2      03 2      04 2      05 2      06 2      07 2     &#xA;08 2      09 2      0A 2      0B 2      0C 2      0D 2      0E 2      0F 2     &#xA;10 2      11 2      12 2      13 2      14 2      15 2      16 2      17 2     &#xA;18 2      19 2      1A 2      1B 2      1C 2      1D 2      1E 2      1F 2     &#xA;20 2      21 2      22 2      23 2      24 2      25 2      26 2      27 2     &#xA;28 2      29 2      2A 2      2B 2      2C 2      2D 2      2E 2      2F 2     &#xA;30 2      31 2      32 2      33 2      34 2      35 2      36 2      37 2     &#xA;38 2      39 2      3A 2      3B 2      3C 2      3D 2      3E 2      3F 2     &#xA;40 2      41 2      42 2      43 2      44 2      45 2      46 2      47 2     &#xA;48 2      49 2      4A 2      4B 2      4C 2      4D 2      4E 2      4F 2     &#xA;50 2      51 2      52 2      53 2      54 2      55 2      56 2      57 2     &#xA;58 2      59 2      5A 2      5B 2      5C 2      5D 2      5E 2      5F 2     &#xA;60 2      61 2      62 2      63 2      64 2      65 2      66 2      67 2     &#xA;68 2      69 found! 6A 2      6B 2      6C 2      6D 2      6E 2      6F 2     &#xA;70 2      71 2      72 2      73 2      74 2      75 2      76 2      77 2     &#xA;78 2      79 2      7A 2      7B 2      7C 2      7D 2      7E 2      7F 2     &#xA;&#xA;-------------------------------&#xA;Possible devices:&#xA;69 = Unknown&#xA;&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The address &lt;code&gt;69&lt;/code&gt; is your device, MPU-6050! Now check your code and you can see that you use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MPU6050_I2C_ADDRESS 0x68&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But you must use the correct address of MPU, change it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MPU6050_I2C_ADDRESS 0x69&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://sites.google.com/site/akvarkoota/arduino-mega-2560/tiny-rtc/i2c_scanner&quot; rel=&quot;nofollow&quot;&gt;Code source&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22948" LastEditorUserId="46" LastEditDate="2016-06-13T12:23:24.717" LastActivityDate="2016-06-13T12:23:24.717" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25139" PostTypeId="2" ParentId="25134" CreationDate="2016-06-12T15:31:48.480" Score="1" Body="&lt;p&gt;Without details of the car's circuitry one can't say with certainty what the problem is.  However, from the description given, one thing sticks out:  The TX-2E spec sheet says to ground a control pin to select a motion.  But besides grounding pins at times, you are also taking them high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, try leaving pins open when not active, and pulled down for active.  Eg, try code like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void motion(const int pin) {&#xA;  pinMode(FWD, OUTPUT);&#xA;  digitalWrite(pin, LOW);&#xA;  delay(1000);&#xA;  pinMode(pin, INPUT);&#xA;  delay(1000);&#xA;}&#xA;void Forward() {&#xA;  motion(FWD);&#xA;}&#xA;void Backward() {&#xA;  motion(BWD);&#xA;}&#xA;void Left() {&#xA;  motion(LEFT);&#xA;}&#xA;void Right() {&#xA;  motion(RIGHT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-06-12T15:31:48.480" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25140" PostTypeId="2" ParentId="25137" CreationDate="2016-06-12T16:50:51.303" Score="2" Body="&lt;p&gt;The board you have uses the CH340G chip instead of an ATMega16U2 or FTDI FT232R chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It requires special drivers, not the ones that come with the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why do they use that chip instead of the proper one? Simply because it's dirt cheap. They are the cheapest of the cheapest of the cheapest USB chips around. They frequently die. You might want to save up and invest in a genuine Arduino at some point, because that one may well die out of the blue.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-12T16:50:51.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25142" PostTypeId="2" ParentId="14256" CreationDate="2016-06-12T18:35:19.373" Score="3" Body="&lt;p&gt;After nearly a year and a number of experiments later, I've learned a little bit more about using these devices:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Issuing the sensors a Skip ROM command followed by Convert T command starts all devices converting temperature at once (pg.11 of the datasheet). Then you need only wait one delay period of {750,375,188,94}ms for a {12,11,10,9}-bit conversion, respectively, before you can start reading back the temperatures.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the devices are being powered parasitically, the bus will need a strong pullup during the conversion; the 4.7KOhm pullup is not sufficient (pg.5 of the datasheet). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An arduino pin can source 40mA and I've found that a second pin directly bypassing the 4.7K pullup without the suggested transistor, will source enough current for at least 3 sensors (as many as I've tried so far) and I assume the technique could be extended to more pins. The strong pullup must be switched on within 10uSec after the Convert T command and kept on for the duration of the conversion. The 10uSec spec pretty much means you have to do this in the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I keep an abbreviated DS18B20 library around in which I assume the sensors on the bus are related, so it sets all of their resolutions at once and starts their conversions at once, and assumes that the bus is parasite-powered, which mine are, so it switches a specified pin as a strong pullup. I give up some flexibility that the full DSTemperature library would allow but it satisfies my temperature measuring requirements (so far) and simplifies my application code by black-boxing the above techniques.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-06-12T18:41:15.807" LastActivityDate="2016-06-12T18:41:15.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25144" PostTypeId="1" AcceptedAnswerId="25147" CreationDate="2016-06-12T19:26:10.000" Score="1" ViewCount="504" Body="&lt;p&gt;A short question:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder weather I can program an AVR chip &lt;em&gt;(ATMega328, ATMega664, ATMega1284, ATTiny etc.)&lt;/em&gt; using the Arduino IDE, via ISP, &lt;strong&gt;without needing to bootload first.&lt;/strong&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does programming via ISP clear the bootload, if installed previously in the chip?&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-06-12T20:39:26.813" Title="programming via ISP" Tags="|arduinoisp|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25146" PostTypeId="1" AcceptedAnswerId="25148" CreationDate="2016-06-12T19:55:58.983" Score="1" ViewCount="4926" Body="&lt;p&gt;I'm using Energia to program TI's CC3200 MCU. Since Energia is based off the Arduino IDE, I'm hoping someone can help me here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to get the CC3200 to act as a Webserver which when successfully starts up serves up a page with two fields for the username and password that the user needs to fill. Now I'm able to see that the two fields are being successfully POST'd (through Serial.write but only when the code to get it into &lt;code&gt;buffer&lt;/code&gt; is not present) but I was hoping someone can help me get this content into a character array (called buffer declared before the setup loop begins). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code in the section &lt;code&gt;//Here is where the POST data is&lt;/code&gt; does not seem to be working as I see garbage values in &lt;code&gt;buffer&lt;/code&gt; and in the &lt;code&gt;Serial.write&lt;/code&gt;. How do I get these POST values into &lt;code&gt;buffer&lt;/code&gt; OR even better how do I split the two field values and store them into two separate character arrays?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  // listen for incoming clients&#xA;  WiFiClient client = server.available();&#xA;&#xA;  if (client) {&#xA;    //Serial.println(&quot;Client connected&quot;);&#xA;    // an http request ends with a blank line&#xA;    boolean currentLineIsBlank = true;&#xA;&#xA;    while (client.connected()) {&#xA;      while(client.available()) {&#xA;        char c = client.read();&#xA;        // if you've gotten to the end of the line (received a newline&#xA;        // character) and the line is blank, the http request has ended,&#xA;        // so you can send a reply&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;&#xA;            // Here is where the POST data is.&#xA;            Serial.println(&quot;Post data: &quot;);&#xA;            int ctr = 0;&#xA;            while(client.available())&#xA;            {&#xA;            Serial.write(client.read());&#xA;            buffer[ctr] = client.read();&#xA;            ctr++;&#xA;        }&#xA;        Serial.println(&quot;Buffer: &quot;);&#xA;        Serial.write(buffer);&#xA;        Serial.println();&#xA;&#xA;        //Serial.println(&quot;Sending response&quot;);&#xA;        // send a standard http response header&#xA;        client.println(&quot;HTTP/1.0 200 OK&quot;);&#xA;        client.println(&quot;Content-Type: text/html&quot;);&#xA;        client.println(&quot;Connection: keep-alive&quot;);&#xA;        client.println();&#xA;&#xA;        //form added to send data from browser and view received data in serial monitor&#xA;        client.println();&#xA;        client.println(&quot;&amp;lt;!DOCTYPE html&amp;gt;&quot;);&#xA;        client.println(&quot;&amp;lt;html lang=\&quot;en\&quot;&amp;gt;&quot;);&#xA;        client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;        client.println(&quot; &amp;lt;FORM action=\&quot;\&quot; method=\&quot;POST\&quot;&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;P&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;LABEL for=\&quot;username\&quot;&amp;gt;Username:&amp;lt;/LABEL&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;INPUT type=\&quot;text\&quot; name=\&quot;uname\&quot;&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;LABEL for=\&quot;password\&quot;&amp;gt;Password:&amp;lt;/LABEL&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;INPUT type=\&quot;text\&quot; name=\&quot;pwd\&quot;&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;INPUT type=\&quot;submit\&quot; value=\&quot;Submit\&quot;&amp;gt;&quot;);&#xA;        client.println(&quot;    &amp;lt;/P&amp;gt;&quot;);&#xA;        client.println(&quot; &amp;lt;/FORM&amp;gt;&quot;);&#xA;        client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;        client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;&#xA;        client.println();&#xA;&#xA;        client.stop();&#xA;        }&#xA;        else if (c == '\n') {&#xA;          // you're starting a new line&#xA;          currentLineIsBlank = true;&#xA;        }&#xA;        else if (c != '\r') {&#xA;          // you've gotten a character on the current line&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    //Serial.println(&quot;Disconnected&quot;);&#xA;    Serial.println();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21708" LastActivityDate="2016-06-12T21:20:29.917" Title="Getting POST data into a char array" Tags="|web-server|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25147" PostTypeId="2" ParentId="25144" CreationDate="2016-06-12T20:32:14.560" Score="2" Body="&lt;p&gt;As Ignacio mentioned, using ISP does not require a bootloader, however, it is also very nearly mutually exclusive with retaining one.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Does programming via ISP clear the bootload, if installed previously in the chip?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Indeed, it does.  The ISP interface on the ATmega &lt;a href=&quot;http://www.avrfreaks.net/forum/isp-programming-preserve-bootloader&quot; rel=&quot;nofollow&quot;&gt;cannot erase individual pages&lt;/a&gt; but only the entire chip.  This is distinct from the &lt;a href=&quot;http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_SPM.html&quot; rel=&quot;nofollow&quot;&gt;SPM instruction&lt;/a&gt; used by a bootloader running on the chip itself, which can perform a partial erase.  It is also distinct from the ATxmega, which does apparently offer an ISP page erase capability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in order to end up with both a bootloader and sketch on the ATmega, you would need to erase the full chip, and then load both the bootloader and the sketch, either in a unified hex file or by loading one and then the other to distinct already-blank memory regions &lt;em&gt;while using the -D option to tell avrdude not to perform an automatic erase&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not believe the the Arduino IDE supports this, rather its menu option to program a sketch via a programmer is intended to set up a chip for operation with a sketch alone and no bootloader.  There does not appear to be any way at GUI-level to configure it to do otherwise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone determined enough could probably craft a customized board configuration that built a functional bootloader into every sketch (or merged or additionally programmed a pre-built one), allowing one shot installation of both an operable sketch and an operable bootloader that could field upgrade it.  However, the Arduino IDE would be a poor choice for production programming...&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-06-12T20:39:26.813" LastActivityDate="2016-06-12T20:39:26.813" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25148" PostTypeId="2" ParentId="25146" CreationDate="2016-06-12T21:11:25.367" Score="2" Body="&lt;p&gt;In this loop&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(client.available()) { &#xA;    Serial.write(client.read());&#xA;    buffer[ctr] = client.read();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you're using &lt;code&gt;client.read()&lt;/code&gt; twice, so the &lt;code&gt;buffer&lt;/code&gt; gets only every second character.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution could be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(client.available()) { &#xA;    int c = client.read();&#xA;    Serial.write(c);&#xA;    buffer[ctr] = c;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15427" LastEditorUserId="15427" LastEditDate="2016-06-12T21:20:29.917" LastActivityDate="2016-06-12T21:20:29.917" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25150" PostTypeId="2" ParentId="25097" CreationDate="2016-06-12T21:54:45.963" Score="2" Body="&lt;p&gt;Of course you cannot use the same pins for both hardware and software serial, but that part seems to have been solved in comments.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Question now is: How do I store the string being returned from the esp8266. I thought my response string was suppose to store the &quot;OK&quot; but that did not happen.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; while (esp8266.available())     {&#xA;    char c = esp8266.read();&#xA;    response += c;&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will only read as long as characters are available, but the ATmega is able to run this loop much more quickly than characters are received, so unless the entire message was previously transferred it will likely only get a character or two before the receive buffer is found (temporarily) empty and it terminates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should instead read until a terminating condition is found, such as a newline character.  For safety you might also put in a &quot;give up and try again&quot; timeout, but make it long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some would try to solve this problem by inserting short delays before trying to read, but that is unwise - depending on delays creates unreliability as the necessary delay can easily change due to conditions that may on the surface seem to have little relevance, for example the esp866 might respond more slowly if it is seeing a lot of broadcast traffic on a network, or if the firmware version changes.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-12T21:54:45.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25151" PostTypeId="1" AcceptedAnswerId="25164" CreationDate="2016-06-13T00:23:40.013" Score="0" ViewCount="1631" Body="&lt;p&gt;I am making an Arduino alarm clock. I am checking for the state of a button. If it is clicked, I increment the button counter. If the counter is divisible by 2, it is mode 0, if not, it is mode 1. I have small delays in the code for each mode to help the lcd clear itself. Those delays are preventing the buttons to reacting to my touch, because there is likely a delay during that time. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;int hours=0;&#xA;int minutes=0;&#xA;const int modePin=6; //button&#xA;int prevModeState=0; //prev state of button&#xA;unsigned long timer;&#xA;int modeState;//current state&#xA;int mode=0;//mode of alarm&#xA;int buttonCounter=0;&#xA;void setup() {&#xA;lcd.begin(16, 2);&#xA;lcd.setCursor(6, 0);&#xA;lcd.print(&quot;Time:&quot;);&#xA;lcd.setCursor(6, 1);&#xA;lcd.print(&quot;00:00&quot;);&#xA;pinMode(modePin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;modeState=digitalRead(modePin);&#xA;if(prevModeState!=modeState){    //this is the part where I check for the state&#xA;  if(modeState==HIGH){&#xA;    buttonCounter++;&#xA;  } &#xA;}&#xA;prevModeState=modeState;&#xA;if(buttonCounter%2==0){&#xA;  mode=0;&#xA;}&#xA;else{&#xA;  mode=1;&#xA;}&#xA;&#xA;&#xA;if(mode==0){&#xA;  timer=millis();&#xA;  if(timer%600==0){&#xA;     minutes++;&#xA;    if(minutes==60){&#xA;        minutes=0;&#xA;        hours++;&#xA;        }&#xA;     if(hours==24){&#xA;        hours=0;&#xA;     }&#xA;    lcd.clear();&#xA;    lcd.setCursor(6, 0);&#xA;    lcd.print(&quot;Time:&quot;);&#xA;    lcd.setCursor(6, 1);&#xA;    writeTime();&#xA;    delay(200); //delay&#xA;    }&#xA;}&#xA;else if(mode==1){&#xA;  lcd.clear();&#xA;  lcd.setCursor(4, 0);&#xA;  lcd.print(&quot;Set Time:&quot;);&#xA;  lcd.setCursor(6, 1);&#xA;  writeTime();&#xA;  delay(500); //delays&#xA;&#xA;}&#xA;}&#xA;&#xA;void writeTime(){&#xA;if(minutes&amp;lt;10){&#xA;&#xA;      if(hours&amp;lt;10){&#xA;        lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+&quot;0&quot;+minutes);&#xA;      }&#xA;      else{&#xA;        lcd.print(hours+String(&quot;:&quot;)+&quot;0&quot;+minutes);&#xA;      }&#xA;    }&#xA;    else{&#xA;      if(hours&amp;lt;10){&#xA;         lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+minutes);&#xA;      }&#xA;      else{&#xA;         lcd.print(hours+String(&quot;:&quot;)+minutes);//possibly split if problems arise&#xA;      }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I edit my code?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-06-13T09:06:10.733" Title="How can I make push buttons react to being pressed instantly?" Tags="|arduino-uno|c++|button|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25152" PostTypeId="2" ParentId="4927" CreationDate="2016-06-13T01:04:57.017" Score="-1" Body="&lt;p&gt;You may wanna try this lib: &lt;a href=&quot;https://github.com/olikraus/u8glib&quot; rel=&quot;nofollow&quot;&gt;https://github.com/olikraus/u8glib&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supports many devices and is very well documented!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-13T01:04:57.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25153" PostTypeId="2" ParentId="25151" CreationDate="2016-06-13T01:10:33.593" Score="2" Body="&lt;p&gt;You have a few options, including using interrupts. But I believe the most important thing is: &quot;do not use delay()&quot; and you might not even need to use interrupts...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look on this nice post from Nick Gammon: &lt;a href=&quot;http://www.gammon.com.au/blink&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/blink&lt;/a&gt; with some tips about non-blocking coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also a very simple &quot;Blink LED&quot; example: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-13T01:10:33.593" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25154" PostTypeId="2" ParentId="4076" CreationDate="2016-06-13T01:26:20.270" Score="3" Body="&lt;p&gt;The word &lt;em&gt;servo&lt;/em&gt; has a vague definition and can encompass many types of subcomponents. If you want &lt;strong&gt;no-power position holding&lt;/strong&gt; using an electromagnetic motor, then there are four options:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;High viscosity grease&lt;/li&gt;&#xA;&lt;li&gt;Dash pot&lt;/li&gt;&#xA;&lt;li&gt;Very high gear ratio&lt;/li&gt;&#xA;&lt;li&gt;magnetic brake shoe / brake band&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;EDIT: There are some additional possibilities, but it's sort of an effect of some motor designs:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Permanent magnet pole holding torque, or detent torque&lt;/li&gt;&#xA;&lt;li&gt;Permanent magnet drag torque&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The high viscosity grease and dash pot have similar functions; providing a high static friction to resist motion, which then breaks away into movement. (A dash pot is essentially a toothed gear inside a toothed wall container, and which is permanently filled with a high viscosity fluid.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However both of these will add to the motor load, and when they get hot they tend to become thin and runny and lose holding ability.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A high gear ratio increases the torque required to back-spin the motor. Though note, if any gearbox could have a perfectly frictionless lubricant, no amount of gear reduction could stop back-spinning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So really this is similar to the thick grease and dash pot, but gear reduction allows just the normal thin lubrication to have enough static breakaway friction, to stop back-spinning.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A magnetic brake gives you active control over the static breakaway friction, and can allow for very high holding ability vs intermittent load spikes on the output shaft. Typically with the power off, a spring engages the brake to hold position with no power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, there are two different kinds of braking: static position holding, and deceleration of a moving mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second type both dumps heat into the brake pads and friction plate, and wears down the pads and friction plate. If the brake overheats, the pads usually disintegrate, and the brake now won't hold position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unless we're talking about large machinery, usually servo brakes are simple designs without replaceable parts. When the brake fails, you pull the whole thing off and replace it ... including possibly the entire servomotor and gearbox too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For long service life with magnetic braking, you need to actively decelerate the load using the servo, and then once it has stopped moving, then engage the brake to just do the job of holding position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using a magnetic brake for no-power static load holding only, will look like this:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Power up motor, get current position, and begin actively holding position.&lt;/li&gt;&#xA;&lt;li&gt;Energize brake to release it&lt;/li&gt;&#xA;&lt;li&gt;Accelerate and move to new position&lt;/li&gt;&#xA;&lt;li&gt;Decelerate motor and hold end position&lt;/li&gt;&#xA;&lt;li&gt;Remove power from brake to engage it&lt;/li&gt;&#xA;&lt;li&gt;Turn off power to motor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The motor is powered up and goes into position holding first, so that the load doesn't suddenly slip in either direction, in the instant between the brake being released and the servomotor then becoming active.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #1&lt;/strong&gt;: For some permanent magnet motors, even with the power off there is a resistance to rotation because in certain positions, the magnets and the pole pieces more closely attract to each other, known as &lt;em&gt;detent torque&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This pole positioning is like a low-energy valley and it takes a bit of force to overcome the magnetic attraction and move the rotor in either direction using an external torque. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can feel this in some brushless fans and stepper motors, where if you rotate the shaft unpowered, it resists continuous motion, and there seem to be high resistance points that the rotor does not want to cross. When spun, the rotor rapidly slows, and may fall into a back-forth oscillation as it settles into one of the magnetic attractive wells.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can be used to resist external torques without a brake, but making use if it requires stopping the rotor in one of the magnetic wells rather than a specific position you may want. But if combined with a gearbox, the exact specific stopping position may not matter too critically, and there may be a number of wells next to each other where the rotor can stop that provide an acceptable end-effector alignment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT #2&lt;/strong&gt;: Permanent magnet drag torque is an effect of shorting all the power wires together. When this is done it takes considerably more force to rotate the shaft than with the stepper coil wires disconnected from each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is because with the coil wires all connected together, when the rotor turns it acts as a generator and current flows through the coils. This current flow creates what is known as counter electromotive force (CEMF), which counters the magnetic field of the permanent magnet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This CEMF can provide additional resistance against rotation when the servo is unpowered. Although CEMF won't prevent motion, it can help resist continued motion and provide instant deceleration when intermittent load spikes are applied that try to move the unpowered servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the above is also generally true for linear motor servos. Those don't have gear reduction, but the motion carriage can be lubed with thick grease, be equipped with a dash pot, and have position holding magnetic brakes.&lt;/p&gt;&#xA;" OwnerUserId="22961" LastEditorUserId="22961" LastEditDate="2016-06-13T09:04:50.963" LastActivityDate="2016-06-13T09:04:50.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25156" PostTypeId="1" AcceptedAnswerId="25176" CreationDate="2016-06-13T06:21:35.030" Score="0" ViewCount="1027" Body="&lt;p&gt;How can i receive the data from my Arduino Mega 2560 with Visual C# on my PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I send a short databyte (2 bytes) and a timestamp (4 bytes) over USB to PC&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//initialization&#xA;&#xA;const int RX = 0;&#xA;const int TX = 1;  &#xA;&#xA;void setup(){&#xA;&#xA;pinMode(RX, INPUT);   //readpin for USB&#xA;pinMode(TX, OUTPUT);  //writepin for USB&#xA;...    &#xA;&#xA;Serial.begin(28800);   //open interface&#xA;}&#xA;&#xA;&#xA;&#xA; //loop()&#xA;&#xA; Serial.print(incomingByte, BIN); //sending databyte&#xA;&#xA; sendBinary(currentMillis);   //send timestamp&#xA;&#xA;//method for timestamp&#xA;&#xA;void sendBinary(long currnetMillis)&#xA; {&#xA;  int temp = currentMillis&amp;amp;0xFFFF;  //16 bit of the low-byte&#xA;  sendBinary(temp);&#xA;  temp = currentMillis &amp;gt;&amp;gt; 16;       //16 bit of the high-byte&#xA;  sendBinary(temp);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have surched in the internet for an example but i didn´t find a good. So i ask here what ist the best way with Visual Studio C# to receive the incoming data?&#xA;An example code will be nice because i´m a beginner and didn´t understand the jargon.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With frindly wishes sniffi &lt;/p&gt;&#xA;" OwnerUserId="21214" LastEditorUserId="21214" LastEditDate="2016-06-13T06:27:29.820" LastActivityDate="2016-06-13T12:27:57.280" Title="How can i receive data from Mega2560 on PC with Visual C#" Tags="|arduino-mega|visualstudio|c#|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25157" PostTypeId="1" AcceptedAnswerId="25161" CreationDate="2016-06-13T06:28:05.663" Score="3" ViewCount="4745" Body="&lt;p&gt;I built this thermometer that reads the sensor value from the temperature sensor and displays it on the LCD display. It basically works fine, but the displayed temperature shows a fluctuation between +/-2 degrees due to varying sensor value and voltage every second.&#xA;(This is my very first Arduino project and I am pretty new to electronics.)&#xA;The Arduino gets the power via my Mac through USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I check the sensor value and voltage, it slightly differs each second (or whatever delay interval I use in my code). Sensor value is between 123-125 and voltage usually 0.7, but also changes slightly, which causes the temperature calculation to vary around 2 degrees, which for a &quot;thermometer&quot; is quite a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any way to stabilize it? Should I use a capacitor or another resistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PLbKf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PLbKf.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AYl3W.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AYl3W.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;const float powerSupply = 5.0;&#xA;const int sensorPin = A0;&#xA;const float baselineTemp = 23;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);   &#xA;  lcd.begin(16, 2);&#xA;  lcd.print(&quot;Temperature:&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorVal = analogRead(sensorPin);&#xA;  Serial.print(&quot;Sensor Value: &quot;);&#xA;  Serial.print(sensorVal);&#xA;&#xA;  float voltage = (sensorVal/1024.0)*powerSupply;&#xA;  Serial.print(&quot;, Volts: &quot;);&#xA;  Serial.print(voltage);&#xA;&#xA;  Serial.print(&quot;, degrees C: &quot;);&#xA;  float temperature = (voltage - .5)*100;&#xA;  Serial.println(temperature);&#xA;&#xA;  // set the cursor to column 0, line 1&#xA;  // (note: line 1 is the second row, since counting begins with 0):&#xA;  lcd.setCursor(0, 1);&#xA;  // print the number of seconds since reset:&#xA;  lcd.print(temperature);      &#xA;  // lcd.print(String(sensorVal) + &quot;, &quot; + String(voltage) + &quot;, &quot; + String(temperature));    &#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22951" LastActivityDate="2016-06-13T08:00:07.320" Title="Thermometer project shows fluctuation due to varying sensor value and voltage" Tags="|arduino-uno|temperature-sensor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25159" PostTypeId="2" ParentId="22401" CreationDate="2016-06-13T07:09:14.187" Score="1" Body="&lt;p&gt;Allocate 4 bytes in EEPROM to save a seed value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use the EEPROM library (#include ). Use EEPROM.put() and EEPROM.get() functions to write and read the seed value to EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In setup(): Read the seed_value from EEPROM, increment it and write it back to EEPROM. Then call randomSeed(seed_value).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, after every run of setup(), random() will create a whole new random sequence. If you need a new sequence within your sketch, you can repeat the process, and don't forget to write the new seed to EEPROM for next time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that I didn't bother with initialising the EEPROM value the first time we run. It'll probably be zero when you start a new Arduino board, but the only thing that matters is that you increment it each run. Incrementing by 1 will do the trick, but any increment value will probably do.&lt;/p&gt;&#xA;" OwnerUserId="22968" LastActivityDate="2016-06-13T07:09:14.187" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25160" PostTypeId="2" ParentId="25157" CreationDate="2016-06-13T07:38:38.130" Score="1" Body="&lt;p&gt;There are a few things you might try to stabilize your readings.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Add a small ceramic capacitor, say 22pF between the analog signal from the temp sensor (green on your example) and ground;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Perform multiple reading from your analog, let's say 10, discard max. and min. values and calculate the average. Use this instead of a single reading;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;User the &quot;internal&quot; voltage as reference. It's normally more stable than using the external 5V. Just bear in mind that you might need to use a voltage divider as the &quot;interval&quot; voltage reference max value is 1.1V (&lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/AnalogReference&lt;/a&gt;);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Reduce the wire sizes and make sure all connections are OK.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Probably just by using technique number &quot;2&quot; listed above you'll get much more stable results and don't need any hardware, just a small looping. Also adding the capacitor would be quite simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope it helps. Cheers!&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-13T07:38:38.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25161" PostTypeId="2" ParentId="25157" CreationDate="2016-06-13T07:44:50.117" Score="5" Body="&lt;p&gt;What you need to do is take an averaged reading, this is because the sensor is always fluctuating, noise on the 5V line or the signal line. There are possible hardware solutions. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Adding a capacitor between &lt;code&gt;Vcc&lt;/code&gt; and &lt;code&gt;Gnd&lt;/code&gt; near the sensor, 0.1µf&lt;/li&gt;&#xA;&lt;li&gt;Adding a &lt;a href=&quot;https://en.wikipedia.org/wiki/Low-pass_filter&quot; rel=&quot;noreferrer&quot;&gt;low-pass filter&lt;/a&gt; on the signal line of the LM35 to Arduino&lt;/li&gt;&#xA;&lt;li&gt;heatsink on the LM35(they are very sensitive to movement, giving odd readings) &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The capacitor on the &lt;code&gt;Vcc&lt;/code&gt; and &lt;code&gt;Gnd&lt;/code&gt; will lessen the effects of voltage spikes from the rest of the Arduino's circuitry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The low-pass filter will help give a more filtered output from the sensor with a better response over time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;                2.2k&#xA;LM35&amp;gt;---------/\/\/\-0------&amp;lt;Arduino&#xA;                     |&#xA;                     |&#xA;                     |&#xA;                    === 1µF&#xA;                     |&#xA;                     |&#xA;                    GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The heatsink will allow the LM35 to get a better reading of the general temperature and not the temperature of the breeze from a window.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All three of the above solutions will probably give the best results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do in software too is to have an averaging algorithm/function in your code and actually take the averaged reading across the whole second that you delay the MCU. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;An example of this would be:&lt;/p&gt;&#xA;&#xA; &#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;&#xA;const float powerSupply = 5.0;&#xA;const int sensorPin = A0;&#xA;const float baselineTemp = 23;&#xA;int sensorVal = 0;&#xA;&#xA;//these are NEW&#xA;unsigned long lastTime = 0;     // last time reading taken&#xA;unsigned long currTime = 0;     //current time variable intialised&#xA;float AverageReading = 0;&#xA;&#xA;float _readingAv = 0;   // static variable for keeping the averaged reading&#xA;int _readingsCount = 0;&#xA;int _readings = 100;     //the number of readings to take&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  //  lcd.begin(16, 2);&#xA;  //  lcd.print(&quot;Temperature:&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  currTime = millis();&#xA;&#xA;&#xA;  if ((currTime - lastTime) &amp;lt; 1000) {  //checks to see if a second has passed&#xA;    sensorVal = analogRead(sensorPin);&#xA;&#xA;    if (_readingsCount &amp;lt; _readings) {&#xA;      _readingAv += sensorVal; //add the current value to the last&#xA;      _readingsCount++;&#xA;    }&#xA;    else {&#xA;      AverageReading = _readingAv / _readings; //get the average&#xA;    }&#xA;  }&#xA;  else {&#xA;    Serial.print(&quot;Sensor Value: &quot;);&#xA;    Serial.print(sensorVal);&#xA;&#xA;    float voltage = (AverageReading / 1024.0) * powerSupply;&#xA;    Serial.print(&quot;, Volts: &quot;);&#xA;    Serial.print(voltage);&#xA;&#xA;    Serial.print(&quot;, degrees C: &quot;);&#xA;    float temperature = (voltage - .5) * 100;&#xA;    Serial.println(temperature);&#xA;&#xA;    //~ reset the values used by the previous function&#xA;    _readingsCount = 0;&#xA;    lastTime = currTime;&#xA;    _readingAv = 0; //Important to set this back to 0 so not to get odd values&#xA;&#xA;    // set the cursor to column 0, line 1&#xA;    // (note: line 1 is the second row, since counting begins with 0):&#xA;    lcd.setCursor(0, 1);&#xA;   // print the number of seconds since reset:&#xA;    lcd.print(temperature);&#xA;    // lcd.print(String(sensorVal) + &quot;, &quot; + String(voltage) + &quot;, &quot; + String(temperature));&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Probably a better version of making &lt;a href=&quot;http://www.elcojacobs.com/eleminating-noise-from-sensor-readings-on-arduino-with-digital-filtering/&quot; rel=&quot;noreferrer&quot;&gt;filtering code&lt;/a&gt; of the LM35.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2016-06-13T08:00:07.320" LastActivityDate="2016-06-13T08:00:07.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25162" PostTypeId="2" ParentId="25122" CreationDate="2016-06-13T08:16:11.483" Score="1" Body="&lt;p&gt;Sorry for posting this as an answer, I don't have enough rep to write comments yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Have you tried different USB cables? A dodgy USB cable could power the Nano just fine, giving the impression that it's properly connected, without not actually supporting the data rate required for programming. The fact that something shows up on a USB port on your computer makes this explanation less plausible, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) I notice that there are different versions of the Nano, some with ATmega168 and some with ATmega328. If you have the ATmega328, maybe try selecting &quot;Arduino Uno&quot; in the IDE? If you have the ATmega168, maybe try &quot;Arduino Mini&quot;?&lt;/p&gt;&#xA;" OwnerUserId="21015" LastActivityDate="2016-06-13T08:16:11.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25163" PostTypeId="1" AcceptedAnswerId="25166" CreationDate="2016-06-13T08:28:29.763" Score="0" ViewCount="73" Body="&lt;p&gt;Is it possible to use the Wireless SD shield without the wireless function, or XBEE Module? I do not need it to be wireless it simply was cheaper than any other I could find, so I was wondering if it was possible to use it just like a normal, non-wireless SD Shield? Thanks!&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-06-13T09:13:50.740" Title="Arduino Wireless SD Shield" Tags="|arduino-leonardo|sd-card|wireless|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25164" PostTypeId="2" ParentId="25151" CreationDate="2016-06-13T09:06:10.733" Score="2" Body="&lt;p&gt;The simple answer is, of course, don't use any &lt;code&gt;delay()&lt;/code&gt; calls. There is no need for them in your code.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I cannot remove delays since lcd.clear(); would be done very often and nothing would be visible on the lcd.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So don't clear the LCD. There is no reason to clear the LCD. Just over-print the existing text with new text. Go on, have a go. Just remove the &lt;code&gt;lcd.clear()&lt;/code&gt; calls and the delays from your program and see just how smoothly the screen updates.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On an LCD a cell can only hold one character at a time. Printing one thing and then printing something else in the same place replaces the characters that are already there with the new ones. There is rarely any need to use &lt;code&gt;lcd.clear()&lt;/code&gt; for normal screen updates - only if you really need to clear the &lt;em&gt;entire&lt;/em&gt; screen should you use it. Just updating a bit of text on the screen does not require clearing of the entire screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, you don't even need to print &lt;code&gt;Time:&lt;/code&gt; or &lt;code&gt;Set Time:&lt;/code&gt; every loop - you only need to do that once when you change mode. If you are going to clear the screen that is the time to do it.  So a quick outline:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When button pressed:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set mode&lt;/li&gt;&#xA;&lt;li&gt;Clear screen&lt;/li&gt;&#xA;&lt;li&gt;Print static text (&lt;code&gt;Time:&lt;/code&gt; etc)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Every iteration:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Print the mode's dynamic text&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You see the heavyweight screen clearing is only done once when you change mode. All the rest of the time it's just updating small portions of the screen. Not only does it look nicer (no flicker) but it's also considerably more efficient and allows your program to do more.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-13T09:06:10.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25165" PostTypeId="1" CreationDate="2016-06-13T09:08:35.137" Score="-1" ViewCount="575" Body="&lt;p&gt;I was making a home automation project in which I want to control appliances like a fan and a bulb through voice commands with the help of an arduino uno and a relay but I am confused which relay to use. Please tell me the specifications of a 4 channel relay fit for this project.&lt;/p&gt;&#xA;" OwnerUserId="22930" LastEditorUserId="22930" LastEditDate="2016-06-13T09:21:14.127" LastActivityDate="2016-06-13T12:02:39.837" Title="Which relay should I use to control the power from mains?" Tags="|arduino-uno|relay|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25166" PostTypeId="2" ParentId="25163" CreationDate="2016-06-13T09:13:50.740" Score="1" Body="&lt;p&gt;In general, on a combined &quot;Something plus SD card&quot; shield like this the SD card is a completely separate section to the rest of it. The only real exception is on some audio shields (mp3) where the SD card is directly controlled by the audio CODEC chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So yes, you can pick and choose which portions of the shield you actually use in your code. Just by not using the bits you don't want to use.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-13T09:13:50.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25167" PostTypeId="2" ParentId="25165" CreationDate="2016-06-13T09:21:28.263" Score="0" Body="&lt;p&gt;There are two factors you need to consider when choosing a relay:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Can it power the devices I want it to power without the contacts melting?&lt;/li&gt;&#xA;&lt;li&gt;Can I control it?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The first one is simple enough. Find out the current requirements for each of the devices and add them together. Make sure that the relay is capable of switching &lt;em&gt;at least&lt;/em&gt; that much at the &lt;em&gt;AC&lt;/em&gt; voltage of your country's mains supply.  If in doubt go slightly higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the second point you need to consider the interfacing circuitry and what DC power supply you are using in your system. For instance, if you have a 12V power supply for the Arduino you might consider a 12V coil relay and use the 12V power as the switching power. If you are running from 9V then you might consider a 5V relay and use the Arduino's regulated 5V pin as the switching power source. Either way you need a driving circuit. That could be as simple as an NPN transistor, two resistors, and a diode (the circuit can be found throughout the web if you Google &quot;Arduino Relay&quot;), or more complex involving an opto-isolator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest solution is to find an all-in-one module - a relay with driver circuit all as a single product. There are many of these around directly targeted at the Arduino, and most are the slightly more complex (and thus better) opto-isolator driving circuit. You still have to consider the same two points - switching capacity and coil voltage - but you don't then need to worry about making your own driving circuit for them.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-13T09:21:28.263" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25168" PostTypeId="2" ParentId="24682" CreationDate="2016-06-13T09:36:58.420" Score="1" Body="&lt;p&gt;Find out if the Linux system is running. Maybe you mistyped your WiFi password.&#xA;Try the Following: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connect via Ethernet check your router to see if the Yun request an IP via DHCP&lt;/li&gt;&#xA;&lt;li&gt;If unsuccessful connect via USB and install this &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/YunSerialTerminal&quot; rel=&quot;nofollow&quot;&gt;sketch&lt;/a&gt; to see if you get a command prompt maybe your network settings are messed up &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Still no success?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Press the WiFi reset button for at least 30 seconds to do a reset to&#xA;factory defaults.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="16061" LastActivityDate="2016-06-13T09:36:58.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25170" PostTypeId="2" ParentId="24947" CreationDate="2016-06-13T10:25:30.990" Score="1" Body="&lt;p&gt;I asked on the FastLED library github page and they provided me with the correct instantiation for the object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Lights *lightstrip1;&#xA;&#xA;void setup() {&#xA;  lightstrip1 = new Lights(7,13, 250, 0, 0);&#xA;}&#xA;&#xA;void loop() {&#xA;  lightstrip1-&amp;gt;Update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It now works fine and plays the music and the lights simultaneously without issue.&lt;/p&gt;&#xA;" OwnerUserId="2830" LastActivityDate="2016-06-13T10:25:30.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25171" PostTypeId="1" AcceptedAnswerId="25210" CreationDate="2016-06-13T11:23:52.217" Score="2" ViewCount="6378" Body="&lt;p&gt;I use this simple HTTP Post request to post some values on my API from Arduino using Switch. each time I push the switch it send a different values to API.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void switch_led() {&#xA;bool SwitchReading = digitalRead(SWITCH);&#xA;if (SwitchReading == HIGH) {&#xA;Serial.println(&quot;Now pressed....&quot;);&#xA;state = state + 1;&#xA;if (state % 2 != 0) {&#xA;  digitalWrite(LED, HIGH);&#xA;  char data1[] = &quot;{&quot;&quot;LDRValue&quot;&quot;: 88888888}&quot;;&#xA;  Serial.println(&quot;\nStarting connection to led server...&quot;);&#xA;  if (client.connect(server, 8040)) {&#xA;    Serial.println(&quot;connected to post server&quot;);&#xA;    client.println(&quot;POST /api/sensor HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: 192.168.2.116:8040&quot;);&#xA;    client.println(&quot;Content-Type: application/json&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(sizeof(data1));&#xA;    client.println();&#xA;    client.print(data1);&#xA;    Serial.println(&quot;1.finish&quot;);&#xA;  }&#xA;  Serial.println(&quot;2.finish&quot;);&#xA;}&#xA;else {&#xA;  digitalWrite(LED, LOW);&#xA;  char data2[] = &quot;{&quot;&quot;LDRValue&quot;&quot;: 1111111111}&quot;;&#xA;  Serial.println(&quot;\nStarting connection to led server...&quot;);&#xA;  if (client.connect(server, 8040)) {&#xA;    Serial.println(&quot;connected to post server&quot;);&#xA;    client.println(&quot;POST /api/sensor HTTP/1.1&quot;);&#xA;    client.println(&quot;Host: 192.168.2.116:8040&quot;);&#xA;    client.println(&quot;Content-Type: application/json&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(sizeof(data2));&#xA;    client.println();&#xA;    client.print(data2);&#xA;    Serial.println(&quot;3.finish&quot;);&#xA;  }&#xA;  Serial.println(&quot;4.finish&quot;);&#xA;}&#xA;delay(500);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works perfect for the first and second posts in both Arduino and API but at the third post it works fine on Arduino but it takes long time on the API(about 2 minutes to get the post).&#xA;The fourth and the fifth posts also works fine but the sixth is same as the third.&#xA;Knowing that my API works 100% with Raspberry Pi and it has no errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing for PUT and GET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After Edition:&#xA;After I remove the port number from the host line and using strlen(data)instead of sizeof(data), the POST request works but only for first 7th posts. The output of serial monitor on Arduino is like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Attempting to connect to WPA SSID: WiFi-Repeater1&#xA;&#xA;WiFi connected&#xA;SSID: WiFi-Repeater1&#xA;IP Address: 192.168.2.149&#xA;signal strength (RSSI):-66 dBm&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;connected to post server&#xA;&#xA;Starting connection to post server...&#xA;&#xA;Starting connection to post server...&#xA;&#xA;Starting connection to post server...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before the Editing, it was always giving me &quot;connected to post server&quot; and It always posts but as I told you before It takes a lot of time at the 3rd 6th 9th 12th ..... Now after the 7th post it will not posts.&lt;/p&gt;&#xA;" OwnerUserId="22826" LastEditorUserId="22826" LastEditDate="2016-06-14T07:09:13.400" LastActivityDate="2018-07-18T16:31:53.950" Title="HTTP Requests using Arduino" Tags="|arduino-uno|arduino-yun|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25172" PostTypeId="2" ParentId="25165" CreationDate="2016-06-13T12:02:39.837" Score="0" Body="&lt;p&gt;In the US there is a set of products - plug-in modules - collectively known as X10, which uses signals sent over the house wiring to control devices elsewhere in the house. If they are available where you are, &lt;strong&gt;this is the safest way to control mains-powered devices with an Arduino&lt;/strong&gt; because the Arduino needs no connection to the house wiring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Wireless Transceiver module receive X10 commands over RF and transmit them onto the power wiring. Using this and a small RF transmitter known here as &quot;X10 Firecracker CM17A&quot;, your Arduino can be completely isolated from the house wiring, sending its control commands over the air instead. Amazon shows both products on &lt;a href=&quot;https://www.amazon.com/s?ie=UTF8&amp;amp;page=1&amp;amp;rh=i%3Aaps%2Ck%3Ax10%20firecracker&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;; the CM17A (which you use by removing its circuit board from the plastic package), and the RF control module, of which you only need one. The transceiver module can directly control one fan or light; for additional devices you'd use any other, non-RF (read &quot;less expensive&quot;) X10 module, which will &quot;hear&quot; whatever the transceiver module sends.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is an Arduino library already written for X10 communication.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-13T12:02:39.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25175" PostTypeId="2" ParentId="25171" CreationDate="2016-06-13T12:18:00.227" Score="0" Body="&lt;p&gt;I &lt;em&gt;THINK&lt;/em&gt; the problem might be the &lt;code&gt;client.println()&lt;/code&gt; statement.  I believe REST messages should be terminated with a \r\n and I think println just does \n.  So if you change it to &lt;code&gt;client.println(&quot;\r&quot;)&lt;/code&gt; it should start working on every message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you might want to consider moving creating the message into a function to reduce the amount of code you have.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-13T12:18:00.227" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25176" PostTypeId="2" ParentId="25156" CreationDate="2016-06-13T12:27:57.280" Score="0" Body="&lt;p&gt;I haven't tried the code below, but it should point you in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you have to do is write a C# program that opens the Serial port that your Arduino is connected to and read and write from there like you would from a file.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Open Visual Studio, create a C# command line project.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Paste this code inside main()&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    System.IO.Ports.SerialPort port = new SerialPort(&quot;COM1&quot;, 9600);&#xA;    try&#xA;    {&#xA;        while (true)&#xA;        {&#xA;            int readData = port.ReadByte();&#xA;            System.Console.WriteLine(&quot;Read {0} from the port&quot;, readData);&#xA;        }&#xA;    }&#xA;    catch(Exception)  // Press CTRL-C to exit.&#xA;    {&#xA;    }&#xA;    port.Close();&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Compile the code and run it.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-13T12:27:57.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25177" PostTypeId="1" AcceptedAnswerId="25180" CreationDate="2016-06-13T13:53:44.617" Score="1" ViewCount="424" Body="&lt;p&gt;Guys i'm working with a flex sensor and I'm trying to capture a specific value which is the moment before the user lets go of a flexed flex sensor and its represented as the top point of a falling edge as sub picture A in the picture I included. using an array I tried two methods, which can produce a close value at times but at other it will give me wrong values&#xA;first I tried the following logic, whenever I detect a value below a certain threshold it indicates that a fallen edge has occurred so get me the value that came right before it as shown in sub picture C but depending on the delay this can be quite unpredictable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the second method is to store the maximum value of but this returns the peak and it's not always the top of the fallen edge as shown in subpicture B&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what do you guys suggest to capture those values?&#xA;this is my code so far&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool loaded = false;&#xA;int threshold = 760;&#xA;int index = 0 ;&#xA;int _max=0;&#xA;int values[4];&#xA;int values_size = 4;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  int data = analogRead(A0);&#xA;&#xA;  if (loaded) {&#xA;    values[index] = data;&#xA;    if(data&amp;gt;_max){&#xA;      _max=data;&#xA;      }&#xA;&#xA;    if (data &amp;lt; threshold) {&#xA;      loaded = false;&#xA;      Serial.flush();&#xA;      Serial.print('a');&#xA;      Serial.print(',');&#xA;      Serial.print(_max);&#xA;      Serial.println();&#xA;      _max=0;&#xA;      delay(300);&#xA;    }&#xA;    index++;&#xA;    index %= values_size;&#xA;  }&#xA;  else if ( data &amp;gt; threshold &amp;amp;&amp;amp; !loaded) {&#xA;&#xA;    loaded = true;&#xA;  }&#xA;&#xA;&#xA;  delay(20);&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/h1gfA.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/h1gfA.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22976" LastEditorUserId="22976" LastEditDate="2016-06-13T15:40:30.880" LastActivityDate="2016-06-13T15:40:30.880" Title="how do you capture the top value in a fallen edge in analogs data (flex sensor)" Tags="|arduino-uno|analogread|signal-processing|analog-sampling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25179" PostTypeId="1" AcceptedAnswerId="25196" CreationDate="2016-06-13T14:07:52.403" Score="2" ViewCount="1800" Body="&lt;p&gt;I am working on a project that uses Arduino and Water Level Sensor MS5540C sensor that uses SPI to communicate with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use Arduino UNO, it was working like a charm using pins 11, 12 and 13, and pin 9 as clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then When I switched to Arduino MEGA, I changed SPI pins to 51, 50 and 52, and I can't get right reads input from the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any tricks that should be used when switching between Arduino UNO and MEGA ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code I use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;int clock = 9;&#xA;&#xA;void resetsensor() //this function keeps the sketch a little shorter&#xA;{&#xA; SPI.setDataMode(SPI_MODE0); &#xA; SPI.transfer(0x15);&#xA; SPI.transfer(0x55);&#xA; SPI.transfer(0x40);&#xA;}&#xA;&#xA;void setup() {&#xA; Serial.begin(9600);&#xA; SPI.begin(); //see SPI library details on arduino.cc for details&#xA; SPI.setBitOrder(MSBFIRST);&#xA; SPI.setClockDivider(SPI_CLOCK_DIV32); //divide 16 MHz to communicate on 500 kHz&#xA; pinMode(clock, OUTPUT);&#xA; delay(100);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA; TCCR1B = (TCCR1B &amp;amp; 0xF8) | 1 ; //generates the MCKL signal&#xA; analogWrite (clock, 128) ; &#xA;&#xA; resetsensor();//resets the sensor - caution: afterwards mode = SPI_MODE0!&#xA;&#xA; //Calibration word 1&#xA; unsigned int word1 = 0;&#xA; unsigned int word11 = 0;&#xA; SPI.transfer(0x1D); //send first byte of command to get calibration word 1&#xA; SPI.transfer(0x50); //send second byte of command to get calibration word 1&#xA; SPI.setDataMode(SPI_MODE1); //change mode in order to listen&#xA; word1 = SPI.transfer(0x00); //send dummy byte to read first byte of word&#xA; word1 = word1 &amp;lt;&amp;lt; 8; //shift returned byte &#xA; word11 = SPI.transfer(0x00); //send dummy byte to read second byte of word&#xA; word1 = word1 | word11; //combine first and second byte of word&#xA;&#xA; resetsensor();//resets the sensor&#xA;&#xA; //Calibration word 2; see comments on calibration word 1&#xA; unsigned int word2 = 0;&#xA; byte word22 = 0; &#xA; SPI.transfer(0x1D);&#xA; SPI.transfer(0x60);&#xA; SPI.setDataMode(SPI_MODE1); &#xA; word2 = SPI.transfer(0x00);&#xA; word2 = word2 &amp;lt;&amp;lt;8;&#xA; word22 = SPI.transfer(0x00);&#xA; word2 = word2 | word22;&#xA;&#xA; resetsensor();//resets the sensor&#xA;&#xA; //Calibration word 3; see comments on calibration word 1&#xA; unsigned int word3 = 0;&#xA; byte word33 = 0;&#xA; SPI.transfer(0x1D);&#xA; SPI.transfer(0x90); &#xA; SPI.setDataMode(SPI_MODE1); &#xA; word3 = SPI.transfer(0x00);&#xA; word3 = word3 &amp;lt;&amp;lt;8;&#xA; word33 = SPI.transfer(0x00);&#xA; word3 = word3 | word33;&#xA;&#xA; resetsensor();//resets the sensor&#xA;&#xA; //Calibration word 4; see comments on calibration word 1&#xA; unsigned int word4 = 0;&#xA; byte word44 = 0;&#xA; SPI.transfer(0x1D);&#xA; SPI.transfer(0xA0);&#xA; SPI.setDataMode(SPI_MODE1); &#xA; word4 = SPI.transfer(0x00);&#xA; word4 = word4 &amp;lt;&amp;lt;8;&#xA; word44 = SPI.transfer(0x00);&#xA; word4 = word4 | word44;&#xA;&#xA; long c1 = word1 &amp;gt;&amp;gt; 1;&#xA; long c2 = ((word3 &amp;amp; 0x3F) &amp;lt;&amp;lt; 6) | ((word4 &amp;amp; 0x3F));&#xA; long c3 = (word4 &amp;gt;&amp;gt; 6) ;&#xA; long c4 = (word3 &amp;gt;&amp;gt; 6);&#xA; long c5 = (word2 &amp;gt;&amp;gt; 6) | ((word1 &amp;amp; 0x1) &amp;lt;&amp;lt; 10);&#xA; long c6 = word2 &amp;amp; 0x3F;&#xA;&#xA; resetsensor();//resets the sensor&#xA;&#xA;//Temperature:&#xA; unsigned int tempMSB = 0; //first byte of value&#xA; unsigned int tempLSB = 0; //last byte of value&#xA; unsigned int D2 = 0;&#xA; SPI.transfer(0x0F); //send first byte of command to get temperature value&#xA; SPI.transfer(0x20); //send second byte of command to get temperature value&#xA; delay(35); //wait for conversion end&#xA; SPI.setDataMode(SPI_MODE1); //change mode in order to listen&#xA; tempMSB = SPI.transfer(0x00); //send dummy byte to read first byte of value&#xA; tempMSB = tempMSB &amp;lt;&amp;lt; 8; //shift first byte&#xA; tempLSB = SPI.transfer(0x00); //send dummy byte to read second byte of value&#xA; D2 = tempMSB | tempLSB; //combine first and second byte of value&#xA;&#xA; resetsensor();//resets the sensor&#xA;&#xA; //Pressure:&#xA; unsigned int presMSB = 0; //first byte of value&#xA; unsigned int presLSB =0; //last byte of value&#xA; unsigned int D1 = 0;&#xA; SPI.transfer(0x0F); //send first byte of command to get pressure value&#xA; SPI.transfer(0x40); //send second byte of command to get pressure value&#xA; delay(35); //wait for conversion end&#xA; SPI.setDataMode(SPI_MODE1); //change mode in order to listen&#xA; presMSB = SPI.transfer(0x00); //send dummy byte to read first byte of value&#xA; presMSB = presMSB &amp;lt;&amp;lt; 8; //shift first byte&#xA; presLSB = SPI.transfer(0x00); //send dummy byte to read second byte of value&#xA; D1 = presMSB | presLSB; &#xA;&#xA; const long UT1 = (c5 * 8) + 20224;&#xA; const long dT =(D2 - UT1);&#xA; const long TEMP = 200 + ((dT * (c6 + 50))/1024);&#xA; const long OFF  = (c2*4) + (((c4 - 512) * dT)/4096);&#xA; const long SENS = c1 + ((c3 * dT)/1024) + 24576;&#xA;&#xA; long PCOMP = ((((SENS * (D1 - 7168))/16384)- OFF)/32)+250;&#xA; float TEMPREAL = TEMP/10;&#xA; Serial.print(&quot;pressure =    &quot;);&#xA; Serial.print(PCOMP);&#xA; Serial.println(&quot; mbar&quot;); &#xA;&#xA; const long dT2 = dT - ((dT &amp;gt;&amp;gt; 7 * dT &amp;gt;&amp;gt; 7) &amp;gt;&amp;gt; 3);&#xA; const float TEMPCOMP = (200 + (dT2*(c6+100) &amp;gt;&amp;gt;11))/10;&#xA; Serial.print(&quot;temperature = &quot;);&#xA; Serial.print(TEMPCOMP);  &#xA; Serial.println(&quot; °C&quot;);&#xA; Serial.println(&quot;************************************&quot;);&#xA;&#xA; delay(300);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7807" LastEditorUserId="7807" LastEditDate="2016-06-13T14:22:09.980" LastActivityDate="2018-02-03T09:06:45.750" Title="Arduino Mega different SPI Pins" Tags="|arduino-uno|arduino-mega|spi|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25180" PostTypeId="2" ParentId="25177" CreationDate="2016-06-13T14:16:57.857" Score="0" Body="&lt;p&gt;I suggest you consider as “top value of the falling edge” the maximum of&#xA;the values you have read during a specified time window before the edge&#xA;is detected. This means you have to compute the maximum at the time you&#xA;detect the edge. If you instead continuously compute a running maximum,&#xA;then you are going to get a global maximum. Amended source:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool loaded = false;&#xA;int threshold = 760;&#xA;int index = 0 ;&#xA;const int values_size = 4;  // this controls the time window&#xA;int values[values_size];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int data = analogRead(A0);&#xA;&#xA;  if (loaded) {&#xA;    // Store the reading.&#xA;    values[index] = data;&#xA;    index = (index + 1) % values_size;&#xA;&#xA;    // Detect falling edge.&#xA;    if (data &amp;lt; threshold) {&#xA;      loaded = false;&#xA;&#xA;      // Find the max.&#xA;      int _max = 0;&#xA;      for (int i = 0; i &amp;lt; values_size; i++) {&#xA;        if (values[i] &amp;gt; _max) _max = values[i];&#xA;        values[i] = 0;  // clear, for next time&#xA;      }&#xA;&#xA;      // Report it.&#xA;      Serial.flush();&#xA;      Serial.print('a');&#xA;      Serial.print(',');&#xA;      Serial.print(_max);&#xA;      Serial.println();&#xA;      delay(300);&#xA;    }&#xA;  }&#xA;&#xA;  // Detect rising edge.&#xA;  else if (!loaded &amp;amp;&amp;amp; data &amp;gt; threshold) {&#xA;    loaded = true;&#xA;  }&#xA;  delay(20);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice the line &lt;code&gt;values[i] = 0;&lt;/code&gt;. It is intended to avoid the reading of&#xA;one falling edge being seen on the next one.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-13T14:16:57.857" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25184" PostTypeId="1" CreationDate="2016-06-13T12:44:39.823" Score="2" ViewCount="861" Body="&lt;p&gt;I was building a Bluetooth car with attiny85 (Arduino IDE) and HC05 bluetooth module. I need 4 IO pins to control the car. Since attiny have only 5vIO's, I am left with only 1 pin to connect to HC05. I would only be receiving data from HC05. So, I want to use that leftover pin as RxD to receive data.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;#include //the software serial library&#xA;#define RxD 4&#xA;&#xA;SoftwareSerial blueToothSerial(RxD);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I do this It gives the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;No matching function for call to 'SoftwareSerial::SoftwareSerial(int)'&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Though it works fine, when I also define a TxD pin. But I want to use only one pin (RxD). Please help.&lt;/p&gt;&#xA;" OwnerUserId="31723" OwnerDisplayName="Shivam Gautam" LastEditorUserId="4455" LastEditDate="2016-06-16T16:42:35.153" LastActivityDate="2016-06-16T16:42:35.153" Title="Using only Rx pin to receive data from HC 05 and attiny85 (Arduino IDE)" Tags="|bluetooth|softwareserial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25185" PostTypeId="2" ParentId="25184" CreationDate="2016-06-13T13:17:10.937" Score="0" Body="&lt;p&gt;The constructor for the SoftwareSerial object expects to be given both a TX and and RX pin (and, optionally, a boolean value representing whether or not it should use inverse logic.) From SoftwareSerial.h, see:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use the library in the way you've written, you'll need to either modify the existing constructor or write a new one into the library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a quick test, I've added the following lines to each of the listed source files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SoftwareSerial.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial(uint8_t receivePin, bool inverse_logic = false);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SoftwareSerial.cpp&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial::SoftwareSerial(uint8_t receivePin, bool inverse_logic /* = false */) :&#xA;_rx_delay_centering(0),&#xA;_rx_delay_intrabit(0),&#xA;_rx_delay_stopbit(0),&#xA;_tx_delay(0),&#xA;_buffer_overflow(false),&#xA;_inverse_logic(inverse_logic)&#xA;{&#xA;  setRX(receivePin);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now there's a constructor that allows for a single RX pin argument like you've outlined in your initial example. The problem is that this is likely to break anytime the Arduino codebase gets updated and your changes get blown away. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Best practice may dictate writing your own driver to use the serial functionality of your ATTiny without the possibility of accidentally using the TX functions, but if this is a one-off then maybe Bence Kaulics' suggestion of just feeding it a nonsense pin would be the least time-consuming.&lt;/p&gt;&#xA;" OwnerUserId="16724" OwnerDisplayName="Cheibriados" LastActivityDate="2016-06-13T13:17:10.937" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25186" PostTypeId="1" CreationDate="2016-06-13T16:02:56.190" Score="2" ViewCount="835" Body="&lt;p&gt;I'm trying to configure my ADC(LM98725) registers through Arduino UNO via SPI but I'm facing a small problem, it would be great if somebody help me out. I have to configure my 16 bit ADC registers which needs 25+ clocks but right now I'm getting 16 SCLK with my 16 bit data output on MOSI pin, there is no SCLK signal without data output. How can I increase the number of SCLK for my ADC?&#xA;To write to the serial registers, the timing diagram shown in a diagram. First, SEN is toggled low. The LM98725 assumes control of the SDO pin during the first eight clocks of the command. During this period, data is clocked out of the device at the rising edge of SCLK. At the rising edge of ninth clock,the LM98725 releases control of the SDO pin. At the falling edge of the ninth clock period, the master should assume control of the SDI pin and begin issuing the new command. SDI is clocked into the LM98725 at the rising edge of SCLK. The remaining bits are composed of the &quot;write&quot; command bit (a zero), two device addressbits (00, 01 or 10 for the LM98725), five bit register address to be written, and the eight bit register value to be written.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;int ss=10;&#xA;int DATAOUT=11;&#xA;int DATAIN=12;&#xA;int SCLK=13;&#xA;&#xA;void setup()&#xA;{&#xA;    SPI.begin();&#xA;    pinMode(DATAOUT, OUTPUT);&#xA;    pinMode(DATAIN, INPUT);&#xA;    pinMode(SCLK, OUTPUT);&#xA;    pinMode(ss, OUTPUT);&#xA;    digitalWrite(ss, HIGH);&#xA;    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(ss, LOW);&#xA;    SPI.transfer16(0x02c6);&#xA;    digitalWrite(ss, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/x3TJw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/x3TJw.png&quot; alt=&quot;clock requirement&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22982" LastEditorUserId="7508" LastEditDate="2016-06-14T08:38:15.660" LastActivityDate="2016-06-14T08:38:15.660" Title="Serial clock for SPI" Tags="|arduino-uno|spi|oscillator-clock|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25187" PostTypeId="1" AcceptedAnswerId="25212" CreationDate="2016-06-13T16:18:46.453" Score="3" ViewCount="2620" Body="&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; Maybe I'm a bad Googler, but I am finding very little on &lt;strong&gt;&lt;em&gt;wired&lt;/em&gt;&lt;/strong&gt; Internet of Things sensor networks using Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Project Goals:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino based sensor nodes that connect to the local network (not out to the internet)&lt;/li&gt;&#xA;&lt;li&gt;All the benefits of adding adding/removing nodes, moving nodes, adding new routers for more ports.&lt;/li&gt;&#xA;&lt;li&gt;Black box sensors that don't take any soldering to plug into the network (although they contain soldered components in the black box.&lt;/li&gt;&#xA;&lt;li&gt;Using a master Raspberry Pi on the network to identify the nodes and read data from them.&lt;/li&gt;&#xA;&lt;li&gt;Using Power over Ethernet (PoE) to power my sensor nodes.&lt;/li&gt;&#xA;&lt;li&gt;Don't want to actually connect to the outside internet, just want the convenience of assembling a network with node names and such.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Why not use wireless solutions (e.g. XBee):&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, it seems Xbee is the way to go, but I don't want a wireless solution.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I want the reliability of a wired connection.&lt;/li&gt;&#xA;&lt;li&gt;I don't want to have to worry about batteries&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I'm doing right now:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, I have all my sensors wired to a central Arduino MEGA using 4-conductor security cable (Vcc, GND, and two signal conductors). The MEGA communicates over serial with a Raspberry Pi. This is annoying for the following reasons:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have to solder/unsolder every time I want to change something.&lt;/li&gt;&#xA;&lt;li&gt;I have to figure out which digital I/O pins are available on the MEGA and have to write down which signal conductor goes to which pin on the MEGA and means what on the sensor.&lt;/li&gt;&#xA;&lt;li&gt;There is a finite number of pins.&lt;/li&gt;&#xA;&lt;li&gt;Each sensor is its own unique project. I want to start standardizing these sensors to clean up the code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I have found so far:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking at XPort sensors; however they are very expensive (i.e. $60 ea.) and don't support PoE. If there is a solution using Arduino and an Ethernet Shield, it brings down the base cost of a sensor by a lot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Request:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where can I find out more information about &lt;em&gt;wired&lt;/em&gt; Arduino sensors? Are there any prebuilt solutions that already do what I am looking for?&lt;/p&gt;&#xA;" OwnerUserId="8570" LastEditorUserId="27346" LastEditDate="2017-05-08T23:20:39.973" LastActivityDate="2017-05-08T23:20:39.973" Title="Wired IoT sensor network with PoE?" Tags="|sensors|ethernet|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25190" PostTypeId="1" CreationDate="2016-06-13T17:01:19.617" Score="4" ViewCount="11236" Body="&lt;p&gt;In a few months, I am planning to construct an Arduino robot with multiple sensors etc. I will use an arduino mega and a 4wd chassis like the one here: &lt;a href=&quot;http://www.ebay.com/itm/NEW-4WD-Robot-Smart-Car-Chassis-Kits-car-with-Speed-Encoder-for-Arduino-M26/201561877173?_trksid=p2047675.c100009.m1982&amp;amp;_trkparms=aid%3D777000%26algo%3DABA.MBE%26ao%3D1%26asc%3D36860%26meid%3Dc76077722d4348e88152fa6c7f32c005%26pid%3D100009%26rk%3D1%26rkt%3D1%26sd%3D181329341315&quot; rel=&quot;nofollow&quot;&gt;Chassis. &lt;/a&gt; The chassis uses 4 DC motors. I was planning to use a motor shield, but I realized that it only fits an Arduino Uno(not Mega) and it controls only 2 DC motors. What can I do to make all 4 DC motors move forward and backward? If I use a motor driver board that controls 2 motors, can I connect the 2 right and 2 left motors in parallel together and the control it through the Arduino?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-06-13T17:21:04.920" LastActivityDate="2019-04-17T21:01:20.227" Title="How can I control 4 DC motors with an Arduino?" Tags="|arduino-mega|motor|arduino-motor-shield|robotics|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="25192" PostTypeId="2" ParentId="25184" CreationDate="2016-06-13T17:17:58.697" Score="1" Body="&lt;p&gt;I suggest you get rid of SoftwareSerial and use instead this &lt;a href=&quot;http://www.technoblogy.com/show?VSX&quot; rel=&quot;nofollow&quot;&gt;Simple&#xA;ATtiny USI UART&lt;/a&gt;. This is a driver&#xA;for a receive-only UART that uses the USI port of the ATtiny85. It is&#xA;superior to a software-only UART as it makes good use of the hardware,&#xA;leaving more time for the CPU to do more useful things (or sleep and&#xA;save battery). Also, unlike SoftwareSerial, it does not need to block&#xA;interrupts for long periods, which is a good thing.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-13T17:17:58.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25193" PostTypeId="1" CreationDate="2016-06-13T18:37:42.797" Score="1" ViewCount="809" Body="&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define RST_PIN 9 // Configurable, see typical pin layout above&#xA;#define SS_PIN 10 // Configurable, see typical pin layout above&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;Servo myservo; // create servo object to control a servo&#xA;&#xA;String read_rfid;&#xA;String ok_rfid_1 = &quot;6722323b&quot;;&#xA;String ok_rfid_2 = &quot;99be859e&quot;;&#xA;int posClosed = 180; // variable to store the servo position for locked&#xA;int posOpen = 0; //same for open...&#xA;&#xA;/*&#xA;  Initialize.&#xA;*/&#xA;void setup() {&#xA;  Serial.begin(9600); // Initialize serial communications with the PC&#xA;  while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA;  SPI.begin(); // Init SPI bus&#xA;  mfrc522.PCD_Init(); // Init MFRC522 card&#xA;  lcd.begin(16, 2);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Scan your card:&quot;);&#xA;  Serial.println(&quot;Scan your card:&quot;);&#xA;  //Choose which lock below:&#xA;  myservo.attach(7); // attaches the servo on pin 7 to the servo object&#xA;}&#xA;&#xA;/*&#xA;  Helper routine to dump a byte array as hex values to Serial.&#xA;*/&#xA;void dump_byte_array(byte *buffer, byte bufferSize) {&#xA;  read_rfid = &quot;&quot;;&#xA;  for (byte i = 0; i &amp;lt; bufferSize; i++) {&#xA;    read_rfid = read_rfid + String(buffer[i], HEX);&#xA;  }&#xA;}&#xA;&#xA;void open_lock() {&#xA;  //Use this routine when working with Servos.&#xA;  lcd.print(&quot;Servo Unlocking&quot;);&#xA;  myservo.write(posOpen);&#xA;  Serial.println(&quot;Servo Unlocking&quot;);&#xA;  delay(10000);&#xA;  myservo.write(posClosed);&#xA;  lcd.clear();&#xA;  lcd.print(&quot;Servo Locking&quot;);&#xA;  Serial.println(&quot;Servo Locking&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  lcd.clear();&#xA;  lcd.print(&quot;test&quot;);&#xA;  // Look for new cards&#xA;  if (!mfrc522.PICC_IsNewCardPresent())&#xA;    return;&#xA;  // Select one of the cards&#xA;  if (!mfrc522.PICC_ReadCardSerial())&#xA;    return;&#xA;  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);&#xA;  if (read_rfid == ok_rfid_1) {&#xA;    open_lock();&#xA;    lcd.clear();&#xA;    lcd.print(read_rfid + &quot; (FRED FARMER)&quot; + &quot; -Access Granted&quot;);&#xA;    Serial.println(read_rfid + &quot; (FRED FARMER)&quot; + &quot; -Access Granted&quot;);&#xA;    delay(10000);&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Scan a card:&quot;);&#xA;    Serial.println(&quot;Scan a card:&quot;);&#xA;  }&#xA;  if (read_rfid == ok_rfid_2) {&#xA;    open_lock();&#xA;    lcd.clear();&#xA;    lcd.print(read_rfid + &quot; (JOHN DOE) &quot; + &quot; -Access Granted&quot;);&#xA;    Serial.println(read_rfid + &quot; (JOHN DOE) &quot; + &quot; -Access Granted&quot;);&#xA;    delay(10000);&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Scan a card:&quot;);&#xA;    Serial.println(&quot;Scan a card:&quot;);&#xA;  } else {&#xA;    lcd.clear();&#xA;    lcd.print(read_rfid + &quot; -Access Denied&quot;);&#xA;    Serial.println(read_rfid + &quot; -Access Denied&quot;);&#xA;    delay(10000);&#xA;    lcd.clear();&#xA;    lcd.print(&quot;Scan your card:&quot;);&#xA;    Serial.println(&quot;Scan your card:&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried running the Arduino library's &quot;Hello World&quot; example, and it successfully runs the text onto the screen. Therefore I have determined that it is not a hardware problem, rather a code problem. It occasionally does display &quot;ff&quot; on the LCD, but that's it.&lt;/p&gt;&#xA;" OwnerUserId="22987" LastEditorUserId="4628" LastEditDate="2018-01-08T07:35:38.313" LastActivityDate="2018-01-08T07:35:38.313" Title="Why doesn't my 1602A LCD display text with this code?" Tags="|arduino-uno|lcd|rfid|code-review|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25194" PostTypeId="2" ParentId="25110" CreationDate="2016-06-13T18:49:52.310" Score="0" Body="&lt;p&gt;To get RF24 working:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Download the latest IDE (not 1.0*)&lt;/li&gt;&#xA;&lt;li&gt;Use the library manager to download the&#xA;latest RF24.&lt;/li&gt;&#xA;&lt;li&gt;See &lt;a href=&quot;https://github.com/TMRh20/RF24/issues/236#issuecomment-205354077&quot; rel=&quot;nofollow&quot;&gt;https://github.com/TMRh20/RF24/issues/236#issuecomment-205354077&lt;/a&gt;&#xA;about what core to use.  &lt;/li&gt;&#xA;&lt;li&gt;Don't forget to define ATTiny in the sketch&lt;br&gt;&#xA;Ex: &lt;code&gt;#define __AVR_ATtiny84__&lt;/code&gt;&lt;br&gt;&#xA;(84, 44, 24 are the choices)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;ATTiny* do not have SPI, that's why it can't find SPI.h (SPI library).&lt;/p&gt;&#xA;" OwnerUserId="11529" LastActivityDate="2016-06-13T18:49:52.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25195" PostTypeId="1" CreationDate="2016-06-13T18:50:16.907" Score="2" ViewCount="84" Body="&lt;p&gt;I am trying to write code to test servo motors using an encoder. I create a file in the setup part, and then set 1500 microseconds to 0 for the encoder. However, if I try to print something to the SD card after I create the file, it will not print to the card. The file is always created but nothing is written to it. I have tested the mapping function separately and it works, but the code never reaches that point. It quits sometime after creating the mapping.txt file but before starting the loop. &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// voltage to servo is divided by 3 to get to something usable for teensy&#xA;&#xA;#include &amp;lt;Encoder.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#define numFrame 6750&#xA;&#xA;float twopi = 2.0 * PI;&#xA;float hz2rps = twopi;&#xA;float rps2hz = 1/hz2rps;&#xA;&#xA;//for the encoder&#xA;// Encoder Pins for Channel A and B.&#xA;int encPin1=6;&#xA;int encPin2=7;&#xA;&#xA;// Per the label on the Encoder this should be 1250 CPR, but 5000 gives actual angle (and is an option that could have been added after purchase)&#xA;int pos[numFrame]; // Array to store positions&#xA;int pw[numFrame]; // Array to store analog input of PWM&#xA;&#xA;&#xA;// for writitng to the SD card&#xA;File mappingandrange;&#xA;File step_file[10];&#xA;File bandwidth_file[10];&#xA;int filenum=0;&#xA;int chipSelect=10;&#xA;char buffer[10];&#xA;&#xA;// Encoder&#xA;Encoder myEnc(encPin1, encPin2);&#xA;&#xA;float poscmd;&#xA;int8_t poscmdInt[numFrame];&#xA;&#xA;// timing variables to stabilize the frame&#xA;unsigned long start_frame;&#xA;unsigned long stop_frame;&#xA;unsigned long stopstop_frame;&#xA;unsigned long delta_frame;&#xA;&#xA;int freqFrame_hz = 2000;&#xA;int timeFrame_us = 1000000/freqFrame_hz;&#xA;int writePwmPin = 5;&#xA;int readPwmPin = 2; // Analog pin to readback the PWM out&#xA;float freqWritePwm_hz = 333;&#xA;float freqPwmCenter_us = 1520.0;&#xA;float pulse = (freqWritePwm_hz / 1000000.0) * 65535.0;&#xA;&#xA;float mag = 500.00;&#xA;float magScale = pow(2, 15) / mag;&#xA;float tEnd_s = 3.0;&#xA;float timeCurr_s = 0.0;&#xA;float freqStart_rps = 1 * hz2rps; // Start Frequency**&#xA;float freqEnd_rps = 30 * hz2rps; // End Frequency**&#xA;float freqK = (freqEnd_rps - freqStart_rps) / (2.0 * tEnd_s); // Parameter for Sweep&#xA;&#xA;//things leftover from when i tried to write code&#xA;int freq=250;&#xA;double average;&#xA;double lengthtotalmicros;&#xA;double percent;&#xA;int analogfreq;&#xA;const int servopin=5;&#xA;int num=0;&#xA;int j=0;&#xA;int i=0;&#xA;float mapp;&#xA;double resistance=1; //resistance of resistor used to measure current though servo&#xA;int voltagepin1=1;//very high resistance bridged in parallel with servo&#xA;int voltagepin2=2;//very high resistance in parallel with servo&#xA;int voltagepin3=3;//low resistance in series with the servo&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(servopin, OUTPUT);&#xA;&#xA;  //setup for the sd card&#xA;  pinMode(chipSelect, OUTPUT);&#xA;  SD.begin();&#xA;  mappingandrange=SD.open(&quot;mapping.txt&quot;, FILE_WRITE);&#xA;&#xA;  //initalize the servo to 1500 microseconds and the position to 0&#xA;  servowrite(1500, freqWritePwm_hz, servopin);&#xA;  delay(500);&#xA;  myEnc.write(0);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  mapp=mapping();&#xA;&#xA;  //setup to run servo_step with magnitude 10 degrees&#xA;  filenum=1;&#xA;  freqFrame_hz=2000;&#xA;  freqWritePwm_hz=333;&#xA;  mag=10.0;//magnitude in degrees&#xA;  servo_step(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp, tEnd_s);&#xA;&#xA;  //setup to run servo_step with magnitude 60 degrees&#xA;  filenum=2;&#xA;  mag=60.0;//magnitude in degrees&#xA;  servo_step(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp, tEnd_s);&#xA;&#xA;  //then do setup for the servo_bandwidth function. &#xA;   freqFrame_hz = 151; // Command frame rate **** how fast teensy loop runs&#xA;   timeFrame_us = 1000000/freqFrame_hz;&#xA;   writePwmPin = 5; // PWM write pin # ****servo input pin&#xA;   freqWritePwm_hz = 333; // PWM rate **** pwm pulse frequency&#xA;   freqPwmCenter_us = 1520.0; // PWM center frequency&#xA;   pulse = (freqWritePwm_hz / 1000000.0) * 65535.0; // Scaling for pulse width duty cycle&#xA;&#xA;   mag = 40.0; // This is the PWM magnitude, need to convert from angle to PWM **** need to later convert from degrees using mapping&#xA;   magScale = pow(2, 7) / mag; // Scalling so that PWM change can be logged as int8&#xA;   tEnd_s = numFrame / freqFrame_hz; // End Time** three below possibly part of function call and change run to run&#xA;   timeCurr_s; // Current Time&#xA;   freqStart_rps = 1 * hz2rps; // Start Frequency**&#xA;   freqEnd_rps = 30 * hz2rps; // End Frequency**&#xA;   freqK = (freqEnd_rps - freqStart_rps) / (2.0 * tEnd_s); // Parameter for Sweep&#xA;&#xA;   mag=1;&#xA;   filenum=1;&#xA;   servo_bandwidth(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp,tEnd_s, freqStart_rps, freqEnd_rps);&#xA;   mag=3;&#xA;   filenum=2;&#xA;   servo_bandwidth(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp,tEnd_s, freqStart_rps, freqEnd_rps);&#xA;   mag=5;&#xA;   filenum=3;&#xA;   servo_bandwidth(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp,tEnd_s, freqStart_rps, freqEnd_rps);&#xA;   mag=10;&#xA;   filenum=4;&#xA;   servo_bandwidth(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp,tEnd_s, freqStart_rps, freqEnd_rps);&#xA;   mag=20;&#xA;   filenum=5;&#xA;   servo_bandwidth(filenum, freqFrame_hz, writePwmPin, freqWritePwm_hz, mag, mapp,tEnd_s, freqStart_rps, freqEnd_rps);&#xA;&#xA;&#xA;for( ; ; )&#xA;{&#xA;}&#xA;&#xA;}&#xA;&#xA;float mapping()&#xA;{&#xA;&#xA;  servowrite(1200, freqWritePwm_hz, servopin);&#xA;  delay(250);&#xA;  pos[0]=myEnc.read();&#xA;  j=1300;&#xA;  for(int i=1; i&amp;lt;7; i++)&#xA;  {&#xA;    servowrite(j, freqWritePwm_hz, servopin);&#xA;    delay(200);&#xA;    pos[i]=myEnc.read();&#xA;    j=j+100;&#xA;    mappingandrange.println(pos[i]);&#xA;  }&#xA;  average=0;&#xA;  for(i=0; i&amp;lt;7; i++)&#xA;  {&#xA;    average=average+pos[i];&#xA;    pos[i]=0;&#xA;  }&#xA;  average=average/i;&#xA;  mappingandrange.print(&quot;The average number of positions per microsecond lengthened is &quot;);&#xA;  mappingandrange.println(average);&#xA;  mappingandrange.print(&quot;Which corresponds to &quot;);&#xA;  mappingandrange.print((average/5000.0)*360.0);&#xA;  mappingandrange.print(&quot;degrees per microsecond lengthened, or &quot;);&#xA;  mappingandrange.print((average/5000.0)*3600.0);&#xA;  mappingandrange.println(&quot; degrees per 100 microsecond change&quot;);  &#xA;&#xA;  mapp=(average/5000.0)*360.0;&#xA;  mappingandrange.close();&#xA;  return mapp;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void servowrite(int widthmicros, int freq, int servopin)&#xA;{&#xA;  analogWriteFrequency(servopin, freq);&#xA;  lengthtotalmicros=(1.0/freq)*1000000.0;&#xA;  percent=widthmicros/lengthtotalmicros;&#xA;  analogfreq=percent*256.0; // changes how much of the duty cycle is up from 0 to 256&#xA;  analogWrite(servopin, analogfreq);&#xA;}&#xA;&#xA;//input the magnitude in degrees and then the function will convert them to pwm values necessary &#xA;void servo_step(int filenum, int freqFrame_hz, int writePwmPin, float freqWritePwm_hz, float mag, float mapping, float tEnd_s)&#xA;{&#xA;    //sd assumes that pinMode(chipSelect, OUTPUT) and SD.begin, and file has been declared&#xA;  sprintf(buffer, &quot;servo_step %d.txt&quot;, filenum);&#xA;  step_file[filenum]=SD.open(buffer, FILE_WRITE);&#xA;  step_file[filenum].println(&quot;Frequency sweep for the given parameters&quot;);&#xA;  step_file[filenum].print(&quot;Command frame rate: &quot;);&#xA;  step_file[filenum].println(freqFrame_hz);&#xA;  step_file[filenum].print(&quot;PWM pulse frequency: &quot;);&#xA;  step_file[filenum].println(freqWritePwm_hz);&#xA;  step_file[filenum].print(&quot;The magnitude of the sweep in PWM microseconds is: &quot;);&#xA;  step_file[filenum].println(mag/mapping);&#xA;  step_file[filenum].print(&quot;This corresponds to a magnitude in degrees of: &quot;);&#xA;  step_file[filenum].println(mag);&#xA;&#xA;  //converting degrees magnitude to pwm magnitude&#xA;  mag=mag/mapping;&#xA;&#xA;&#xA;  analogWriteResolution(16); // Setting the write resolution for PWM&#xA;  analogWriteFrequency(writePwmPin, freqWritePwm_hz); // Setting the frequency for the PWM update rate&#xA;  analogWrite(writePwmPin, freqPwmCenter_us * pulse); // sending the servo to neutral&#xA;&#xA;  analogReadRes(16); // set A/D converter to 16 bit&#xA;&#xA;  delay(1000); // waiting for user to pull up debug serial channel&#xA;&#xA;  //end of setup part of function now moving on to the loop part of function which only actually runs once anyway&#xA;  //should run through the frequewncy sweep and print the data to the sd card for the given parameters&#xA;&#xA;  delay(1000); // waiting for starting the test&#xA;&#xA;  poscmd = 0.0;&#xA;  int i = 0;&#xA;  while(timeCurr_s &amp;lt; tEnd_s){&#xA;    start_frame = micros(); // get the start of the frame&#xA;&#xA;    timeCurr_s = (float)(i * timeFrame_us) / 1000000.0;&#xA;    if(timeCurr_s &amp;gt; 1 &amp;amp; timeCurr_s &amp;lt;= 2)&#xA;    {&#xA;      poscmd = mag;&#xA;    }&#xA;    else if(timeCurr_s &amp;gt; 2)&#xA;    {&#xA;      poscmd = 0.0;&#xA;    }&#xA;&#xA;    poscmdInt[i] = (int)(poscmd/magScale);&#xA;&#xA;    analogWrite(writePwmPin,(freqPwmCenter_us + poscmd) * pulse); // write servo command&#xA;    pw[i] = analogRead(readPwmPin); // read the pwm signal&#xA;    pos[i] = myEnc.read();&#xA;&#xA;    i++;&#xA;&#xA;    stop_frame = micros(); // get the end of the frame&#xA;    delta_frame = stop_frame - start_frame;&#xA;    if(delta_frame &amp;lt; timeFrame_us){&#xA;      delayMicroseconds(timeFrame_us - delta_frame); // sleeping to stabilize the frame at 100 Hz&#xA;    }&#xA;  }&#xA;&#xA;  delay(1000); // wait to get the serial monitor open&#xA;  for(int j = 0; j &amp;lt; i; j++){ // printing out the stored data so we can import to MATLAB&#xA;    step_file[filenum].print(pos[j]);&#xA;    step_file[filenum].print(&quot;\t&quot;);&#xA;    step_file[filenum].print(freqPwmCenter_us + (float)(poscmdInt[j]*magScale));&#xA;    step_file[filenum].print(&quot;\t&quot;);&#xA;    step_file[filenum].println((float)(pw[j]));&#xA;&#xA;  }&#xA;  step_file[filenum].close();&#xA;}&#xA;&#xA;&#xA;&#xA;void servo_bandwidth(int filenum, int freqFrame_hz, int writePwmPin, float freqWritePwm_hz, float mag, float mapping, float tEnd_s, float freqStart_rps, float freqEnd_rps)&#xA;{&#xA;    // assumes that pinMode(chipSelect, OUTPUT) and SD.begin();&#xA;  sprintf(buffer, &quot;servo_bandwidth %d.txt&quot;, filenum);&#xA;  bandwidth_file[filenum]=SD.open(buffer, FILE_WRITE);&#xA;  bandwidth_file[filenum]=SD.open(buffer, FILE_WRITE);&#xA;  bandwidth_file[filenum].println(&quot;Frequency sweep for the given parameters&quot;);&#xA;  bandwidth_file[filenum].print(&quot;Command frame rate: &quot;);&#xA;  bandwidth_file[filenum].println(freqFrame_hz);&#xA;  bandwidth_file[filenum].print(&quot;PWM pulse frequency: &quot;);&#xA;  bandwidth_file[filenum].println(freqWritePwm_hz);&#xA;  bandwidth_file[filenum].print(&quot;The magnitude of the sweep in PWM microseconds is: &quot;);&#xA;  bandwidth_file[filenum].println(mag/mapping);&#xA;  bandwidth_file[filenum].print(&quot;This corresponds to a magnitude in degrees of: &quot;);&#xA;  bandwidth_file[filenum].println(mag);&#xA;  bandwidth_file[filenum].print(&quot;The starting frequency is: &quot;);&#xA;  bandwidth_file[filenum].println(freqStart_rps);&#xA;  bandwidth_file[filenum].print(&quot;The ending frequency is: &quot;);&#xA;  bandwidth_file[filenum].println(freqEnd_rps);&#xA;&#xA;  mag=mag/mapping;&#xA;&#xA;&#xA;&#xA;  analogWriteResolution(16); // Setting the write resolution for PWM&#xA;  analogWriteFrequency(writePwmPin, freqWritePwm_hz); // Setting the frequency for the PWM update rate&#xA;  analogWrite(writePwmPin, freqPwmCenter_us * pulse); // sending the servo to neutral&#xA;  delay(1000); // waiting for user to pull up debug serial channel&#xA;&#xA;  // loop part of function below&#xA;    delay(1000); // waiting for starting the test&#xA;&#xA;  for(int i = 0; i &amp;lt; numFrame; i++){&#xA;    start_frame = micros(); // get the start of the frame&#xA;&#xA;    timeCurr_s = (float)(i * timeFrame_us) / 1000000.0; // Current time&#xA;    poscmd = mag * sin(freqStart_rps * timeCurr_s + freqK * timeCurr_s * timeCurr_s); // Sweep signal&#xA;    poscmdInt[i] = (int)(poscmd*magScale); // integer conversion for logging&#xA;    analogWrite(writePwmPin,(freqPwmCenter_us + poscmd) * pulse); // write servo command&#xA;    pos[i] = myEnc.read(); // read encoder value&#xA;&#xA;    stop_frame = micros(); // get the end of the frame&#xA;    delta_frame = stop_frame - start_frame;&#xA;    if(delta_frame &amp;lt; timeFrame_us){&#xA;      delayMicroseconds(timeFrame_us - delta_frame); // sleeping to stabilize the frame&#xA;    }&#xA;  }&#xA;  //delay(1000); // wait to open the serial monitor&#xA;  for(int j = 0; j &amp;lt; numFrame; j++){ // printing out the stored data&#xA;    bandwidth_file[filenum].print(pos[j]);&#xA;    bandwidth_file[filenum].print(&quot;\t&quot;);&#xA;    bandwidth_file[filenum].println(freqPwmCenter_us + (float)(poscmdInt[j]/magScale));&#xA;  }&#xA;  bandwidth_file[filenum].close();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20739" LastEditorUserId="37523" LastEditDate="2019-06-28T21:23:01.107" LastActivityDate="2019-06-28T21:23:01.107" Title="Program does not seem to be passing from setup to loop, or printing to SD card" Tags="|sd-card|teensy|rotary-encoder|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="25196" PostTypeId="2" ParentId="25179" CreationDate="2016-06-13T21:53:13.527" Score="-1" Body="&lt;p&gt;The problem was basically because some limitations in Arduino MEGA,&#xA;You can't use &lt;code&gt;pin 9&lt;/code&gt;, instead use &lt;code&gt;pin 12&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It works like a charm.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7807" LastActivityDate="2016-06-13T21:53:13.527" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25197" PostTypeId="1" AcceptedAnswerId="25198" CreationDate="2016-06-13T22:25:42.163" Score="1" ViewCount="3469" Body="&lt;p&gt;I am making an Arduino clock. You can set time to it, and then it keeps on going. The problem is that it is always within a minute off. It is not a major issue, but one that I would like to fix. I use the millis function. The program checks if millis is evenly divisible by 60,000(1 minute). After I set the time, millis is NOT at 0, meaning that is ahead of what I set by a number of seconds. How can I fix this? Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&#xA;int hours=0;&#xA;int minutes=0;&#xA;const int modePin=6; //button&#xA;int prevModeState=HIGH; //prev state of button&#xA;unsigned long timer;&#xA;int modeState;//current state&#xA;int mode=0;//mode of alarm&#xA;int buttonCounter=0;&#xA;const int incrementPin=9;&#xA;const int switchPin=7;&#xA;int incrementState;&#xA;int switchState;&#xA;int prevIncrementState=HIGH;&#xA;int prevSwitchState=HIGH;&#xA;int switching=0;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;lcd.begin(16, 2);&#xA;lcd.setCursor(6, 0);&#xA;lcd.print(&quot;Time:&quot;);&#xA;lcd.setCursor(6, 1);&#xA;lcd.print(&quot;00:00&quot;);&#xA;pinMode(modePin, INPUT_PULLUP);&#xA;pinMode(incrementPin, INPUT_PULLUP);&#xA;pinMode(switchPin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop() {&#xA;modeState=digitalRead(modePin);&#xA;if(prevModeState!=modeState){&#xA;      prevModeState=modeState;&#xA;   if(modeState==LOW){&#xA;    buttonCounter++;&#xA;  if(buttonCounter%2==0){&#xA;    mode=0;&#xA;    lcd.clear();&#xA;    lcd.setCursor(6, 0);&#xA;    lcd.print(&quot;Time:&quot;);&#xA;    writeTime();&#xA;}&#xA;  else{&#xA;    mode=1;&#xA;    switching=0;&#xA;    lcd.clear();&#xA;    lcd.setCursor(4, 0);&#xA;    lcd.print(&quot;Set Time:&quot;);&#xA;}&#xA;&#xA;   }&#xA;  } &#xA;if(mode==0){&#xA;  timer=millis();&#xA;  if(timer%60000==0){&#xA;     minutes++;&#xA;    writeTime();&#xA;    }&#xA;}&#xA;else if(mode==1){&#xA; incrementState=digitalRead(incrementPin);&#xA;  switchState=digitalRead(switchPin);&#xA;  if(prevSwitchState!=switchState){&#xA;    prevSwitchState=switchState;&#xA;    if(switchState==LOW){&#xA;    switching++;&#xA;    }&#xA;    if(switching==4){&#xA;      switching=0;&#xA;    }&#xA;&#xA;    }&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;  if(prevIncrementState!=incrementState){&#xA;    prevIncrementState=incrementState;&#xA;    if(incrementState==LOW){&#xA;      if(switching==0){&#xA;        if(hours&amp;lt;14){&#xA;        hours+=10;&#xA;        }&#xA;        else if((hours&amp;gt;=14)&amp;amp;&amp;amp;(hours&amp;lt;20)){&#xA;        hours-=10;&#xA;        }&#xA;        else{&#xA;          hours-=20;&#xA;        }&#xA;        }&#xA;&#xA;        else if(switching==1){&#xA;          if((hours==9)||(hours==19)){&#xA;            hours-=9;&#xA;          }&#xA;          else if(hours==23){&#xA;            hours-=3;&#xA;          }&#xA;          else{&#xA;          hours++;&#xA;          }&#xA;        }&#xA;&#xA;        else if(switching==2){&#xA;          if(minutes&amp;lt;50){&#xA;             minutes+=10;&#xA;          }&#xA;          else{&#xA;            minutes-=50;&#xA;          }&#xA;&#xA;        }&#xA;        else if(switching==3){&#xA;          if(minutes%10==9){&#xA;            minutes-=9;&#xA;          }&#xA;          else{&#xA;          minutes++;&#xA;          }&#xA;        }&#xA;&#xA;&#xA;    }&#xA;&#xA;  }&#xA;&#xA;  writeTime();&#xA;}&#xA;}&#xA;&#xA;void writeTime(){&#xA;  lcd.setCursor(6, 1);&#xA;   if(minutes&amp;gt;=60){&#xA;        minutes=0;&#xA;        hours++;&#xA;        }&#xA;     if(hours&amp;gt;=24){&#xA;        hours=0;&#xA;     }&#xA;if(minutes&amp;lt;10){&#xA;&#xA;      if(hours&amp;lt;10){&#xA;        lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+&quot;0&quot;+minutes);&#xA;      }&#xA;      else{&#xA;        lcd.print(hours+String(&quot;:&quot;)+&quot;0&quot;+minutes);&#xA;      }&#xA;    }&#xA;    else{&#xA;      if(hours&amp;lt;10){&#xA;         lcd.print(String(&quot;0&quot;)+hours+&quot;:&quot;+minutes);&#xA;      }&#xA;      else{&#xA;         lcd.print(hours+String(&quot;:&quot;)+minutes);//possibly split if problems arise&#xA;      }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2017-09-23T14:56:01.927" Title="How can I made my Arduino follow the time exactly?" Tags="|arduino-uno|millis|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25198" PostTypeId="2" ParentId="25197" CreationDate="2016-06-13T22:39:31.883" Score="3" Body="&lt;p&gt;Three things you can do - any combination of these is good, but the more the better:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Use an RTC module to keep more accurate track of the time.&lt;/li&gt;&#xA;&lt;li&gt;Connect the Arduino to the internet and use NTP to get the exact time.&lt;/li&gt;&#xA;&lt;li&gt;Use the time provided by GPS.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The RTC chip can keep track of time when there is no external power, using just a very small button cell.&#xA;The GPS and internet time are both very accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using either or both of those sources to set and maintain the correct time in the RTC chip is the best and most accurate way of keeping the right time on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To increase the accuracy of your existing method you should count seconds, not minutes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Start by recording the current millis. When 1000 of them have passed you can increase your seconds.  Don't rely on &lt;code&gt;millis() % 1000&lt;/code&gt; since you may miss it whilst doing other things. Also don't rely on your millisecond counter check executing at exactly 1000ms intervals - work on the principle of &quot;at least 1000ms&quot; and move the next check to 1000ms from where it &lt;em&gt;should&lt;/em&gt; have happened, not where it &lt;em&gt;did&lt;/em&gt; happen.  This can help to combat some clock drift.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static unsigned long mscount = millis();&#xA;&#xA;if (millis() - mscount &amp;gt;= 1000) {&#xA;    mscount += 1000;&#xA;    seconds ++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then every 60 seconds you can increase your minutes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (seconds == 60) {&#xA;    seconds = 0;&#xA;    minutes ++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-13T22:51:12.463" LastActivityDate="2016-06-13T22:51:12.463" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="25199" PostTypeId="1" AcceptedAnswerId="25203" CreationDate="2016-06-13T23:11:35.260" Score="1" ViewCount="3638" Body="&lt;p&gt;I bought a nodeMCU 8266 and I'm hoping that it can replace my bulkier UNO+WiFi 101.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm getting an error when I compile:&#xA;Error: unknown opcode or format name 'jmp'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using it in void SoftReset() function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void softReset() {&#xA;  delay(1000);&#xA;  asm volatile (&quot;  jmp 0&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This reset works great with my Uno+101 setup but, for whatever reason, doesn't like the ESP8266.  I removed the WiFi101 library and added the ESP8266 WiFi libraries.  That has been the only change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please help me understand why I'm receiving this error?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:  I have read &lt;a href=&quot;https://stackoverflow.com/questions/18517634/tiny-c-compiler-error-unknown-opcode-jmp&quot;&gt;this SO answer&lt;/a&gt; but the &quot;syntactical sugar&quot; didn't work for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also perusing various ESP8266 sites but they are not as well managed as SE/SO and answers are tough to find.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-06-14T03:36:16.407" Title="ESP8266 - Error: unknown opcode or format name 'jmp'" Tags="|arduino-ide|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25200" PostTypeId="2" ParentId="25199" CreationDate="2016-06-13T23:43:54.817" Score="2" Body="&lt;p&gt;The ESP8266 is not an Arduino Uno. It talks a completely different language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's like you're talking Spanish to a Chinese person. It can't understand you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use assembly language then you have to use the assembly language of the chip you are programming for - not the assembly language of a completely different chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The assembly language is detailed here: &lt;a href=&quot;http://techblog.realisaatio.fi/wp-content/uploads/2015/04/xtensalx_overview_handbook.pdf&quot; rel=&quot;nofollow&quot;&gt;http://techblog.realisaatio.fi/wp-content/uploads/2015/04/xtensalx_overview_handbook.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bear in mind, though, that jumping to 0 may not reset the device - it may do something nasty. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only sure-fire way of resetting a chip where you don't really know what is going on inside is to connect a GPIO signal to the RESET pin and use that GPIO to pull RESET low and reset the board that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to call address 0 and don't know how to do it in assembly there are ways of arranging it in C using a function pointer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void (*addressZero)() = 0;&#xA;&#xA;void setup() {&#xA;    addressZero(); // Call address 0&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way it will work on multiple different architectures without having to understand the underlying assembly language.  That, of course, is assuming that calling address 0 is a valid way of resetting the board on the target chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Browsing through the document I link to above it looks most likely that you would first have to load a register with 0 and then use &lt;code&gt;JX&lt;/code&gt; to jump to the address stored in the register (i.e., zero).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-13T23:57:17.437" LastActivityDate="2016-06-13T23:57:17.437" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25202" PostTypeId="1" AcceptedAnswerId="25224" CreationDate="2016-06-14T03:20:13.683" Score="0" ViewCount="222" Body="&lt;p&gt;I am new to Arduino programming and currently working on this instructable&#xA;&lt;a href=&quot;http://www.instructables.com/id/Control-Led-RGB/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Control-Led-RGB/&lt;/a&gt; (following this diagram &lt;a href=&quot;http://cdn.instructables.com/F6Q/IMHF/I0LCDK6B/F6QIMHFI0LCDK6B.LARGE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://cdn.instructables.com/F6Q/IMHF/I0LCDK6B/F6QIMHFI0LCDK6B.LARGE.jpg&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have ordered these parts as well.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino Nano: www.ebay.in/itm/Arduino-Nano-SOLDERED-PINS-V3-0-ATmega328-CH340G-BUY-2-GET-1-USB-CABLE-FREE-/172117729247?&lt;/li&gt;&#xA;&lt;li&gt;HC-05: www.amazon.in/Bluetooth-Transceiver-Module-TTL-Outputs-HC05/dp/B00R95Y0AK?ie=UTF8&amp;amp;psc=1&amp;amp;redirect=true&amp;amp;ref_=ox_sc_act_title_2&amp;amp;smid=A1NDZY44BCNIQJ&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is there need to add voltage divider? If yes can you please provide link?&lt;/li&gt;&#xA;&lt;li&gt;Can I connect two 5050 RGB modules?&lt;/li&gt;&#xA;&lt;li&gt;Will 12 V, 1 A will be enough to power this board.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22990" LastEditorUserId="26916" LastEditDate="2017-09-08T10:02:20.930" LastActivityDate="2017-09-08T10:02:20.930" Title="Need help on HC05 and Nano" Tags="|arduino-nano|hc-05|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25203" PostTypeId="2" ParentId="25199" CreationDate="2016-06-14T03:36:16.407" Score="3" Body="&lt;p&gt;The proper way to reset the esp8266 when using the Arduino IDE is to call &lt;code&gt;ESP.reset()&lt;/code&gt;. You may need to &lt;code&gt;#include &amp;lt;Esp.h&amp;gt;&lt;/code&gt;, but almost all esp8266 headers you include to use any of its functionality will have included it already.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-06-14T03:36:16.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25204" PostTypeId="1" CreationDate="2016-06-14T05:29:05.333" Score="0" ViewCount="1074" Body="&lt;p&gt;I'm trying to get 110dB out of a 25khz Piezo Transducer.  This piezo resonates at 25khz and as per the illustration in its datasheet should emit 110dB with 10 volts and 25khz frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any assistence as to what I'm doing wrong here would be GREATLY appreciated !!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is bit-banging it.  With an oscilloscope, I confirmed that I'm getting a nice clean 25khz square wave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attached a step-up circuit to the device and am seeing 10volts across the terminals of the piezo while it is emitting it's 25khz frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, instead of 110dB, I'm only getting 50dB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried upping the voltage to 20, and still get the same volume level.  The voltage is adjustable via the screw on the top of the blue capacitor on the Voltage Step Up (pictured below).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried changing the duty cycle having HIGH go for 25microseconds and LOW go for 5microseconds.  I've tried several combinations and a 50/50 duty cycle appears to achieve maximum volume which is 50dB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how I'm connected:&#xA;1.  The inputs of the Step Up are attached to GND and 3.3V pins on the Arduino.&#xA;2.  The output+ of the Step Up is connected to 1 pin of the Piezo.&#xA;3.  The output- of the Step Up is NOT connected to anything. (tried to connect it to GND but it didn't change anything.&#xA;3.  The other pin on the Piezo is connected to D11 on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm Running the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include&amp;lt;Wire.h&amp;gt;&#xA;&#xA;const int SPK = 11;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(SPK, OUTPUT);&#xA;  digitalWrite(SPK, LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  long startTime = millis();&#xA;  for (int i = 0; i &amp;lt; 25000; i++)&#xA;  {&#xA;    digitalWrite(SPK, HIGH);&#xA;    delayMicroseconds(15);&#xA;    digitalWrite(SPK, LOW);&#xA;    delayMicroseconds(15);&#xA;  }&#xA;&#xA;  Serial.println(millis() - startTime);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bW2yi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bW2yi.jpg&quot; alt=&quot;Voltage Step-Up Module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ok, I am now set up to look like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/bEQx6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bEQx6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this the next step (ie: Adding an Inducer) ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/lGx5b.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/lGx5b.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18588" LastEditorUserId="18588" LastEditDate="2016-06-14T20:52:10.100" LastActivityDate="2016-06-14T20:52:10.100" Title="Piezo not loud enough" Tags="|arduino-nano|piezo|inductive|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25205" PostTypeId="2" ParentId="25204" CreationDate="2016-06-14T06:02:06.880" Score="1" Body="&lt;p&gt;The device you pictured seems to be a switch-mode power module which will output 10V &lt;strong&gt;DC&lt;/strong&gt;. Get rid of it before you do any damage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't post any link to data, but I assume you mean the Transducer needs 10V peak-to-peak.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can easily be accomplished by using 2 digital outputs, connected to the transducer, and driven in anti-phase.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to &lt;a href=&quot;https://arduino.stackexchange.com/questions/19250/push-pull-tone-code&quot;&gt;Push-Pull tone code&lt;/a&gt; may be an answer to your problem, but may be overkill. If you just want to output a single tone it is easily done with simple code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know why you think the transducer outputs 50dB. If it really is doubling the drive voltage will only give 56dB.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-14T06:02:06.880" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25206" PostTypeId="1" CreationDate="2016-06-14T06:07:51.177" Score="2" ViewCount="311" Body="&lt;p&gt;Today I started messing with the idea of getting an arduino uno to autoconnect with another arduino uno using the nrf24l01 breakouts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont have a particular goal in mind per se but was just wanting to get the logistics down so I started simple as pie.  One arduino at address 0x0000000B LL sends a one element array over and over.  Easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second arduino goes through a for loop in the void loop().  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The for loop is set to loop 16 times.  It starts with the address 0x00000000 LL and checks to see if radio.available is true.  if it is, the program simply states it has found an address over serial.  If not it states the address is invalid.  afterwards it increments the address by one and repeats until the address gets to 0x0000000F LL (or the for loop repeats 16 times.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;once the address gets to 0x0000000B (or the transmitter address) it states that it has found an address over serial.  So far so good!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now the problem arises when the address increments to the next address.  No matter what I seem to do or change, once radio.available() becomes true once....it seems to stay true until the function is called again from the main loop in which case it repeats the same scenario.  I have worked hours on such a small program to no avail.  Can someone help please???  I must be overlooking the most simple of things but for the life of me I have no idea what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Super Simple TX Code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;RF24 radio(8,9);&#xA;uint64_t myAddress = 0x0000000BLL;&#xA;byte txData[] = {1};&#xA;&#xA;void setup()&#xA;{&#xA;  while (!Serial);&#xA;    Serial.begin(9600);&#xA;&#xA;  radio.begin();&#xA;  radio.setRetries(15, 15);&#xA;  radio.openWritingPipe(myAddress);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if( Serial.available() )       &#xA;    {;}&#xA;&#xA;  radio.write(txData,sizeof(txData) );&#xA;  Serial.println(&quot;Sent a packet&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;RX CODE&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;&#xA;RF24 myRadio(8, 9);&#xA;&#xA;byte rxData[] = {0};&#xA;&#xA;void setup()&#xA;{&#xA;  while (!Serial);&#xA;    Serial.begin(9600);&#xA;&#xA;  myRadio.begin();&#xA;  myRadio.setRetries(15, 15);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if( Serial.available() ) &#xA;    {;}&#xA;    //function that searches through a set of 16 addresses   &#xA;    searchAddresses();&#xA;}&#xA;&#xA;&#xA;void searchAddresses()&#xA;{&#xA;  //declare a temp address variable&#xA;  //and initialize it to first possible address&#xA;  uint64_t tempAddress = 0x00000000LL;&#xA;&#xA;  myRadio.openReadingPipe(1, tempAddress);&#xA;  myRadio.startListening();&#xA;&#xA;  for (int x =0; x &amp;lt; 16; x++)&#xA;  {&#xA;      if ( myRadio.available() )&#xA;      {&#xA;        myRadio.read(rxData, sizeof(rxData) );&#xA;        Serial.println(&quot;Found an address&quot;);&#xA;      }&#xA;      else&#xA;      {&#xA;        Serial.println(&quot;Address Invalid&quot;);    &#xA;      }&#xA;      //increment temporary address to next address&#xA;      tempAddress++;&#xA;&#xA;      myRadio.openReadingPipe(1, tempAddress);&#xA;      myRadio.startListening();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22992" LastActivityDate="2016-06-14T13:44:14.443" Title="trying to discover other nrf24 modules" Tags="|arduino-uno|nrf24l01+|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25207" PostTypeId="1" AcceptedAnswerId="25259" CreationDate="2016-06-14T06:16:20.577" Score="0" ViewCount="699" Body="&lt;p&gt;&lt;strong&gt;What I Am Working With:&lt;/strong&gt;&#xA;I am working on a project involving an Arduino, some RGB led strip, and my PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Project:&lt;/strong&gt;&#xA;The PC sends UART (serial) data to the Arduino over Bluetooth (through a HC-06 Bluetooth module connected to the Arduino) to change the color of the LED strip. The user could also change &quot;lighting modes&quot; to instruct the Arduino to make the LED blink, fade, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My Problem:&lt;/strong&gt;&#xA;Having no RTOS nor interruptions on data reception, it would be impossible for me to make the LED fade and, also, to receive Bluetooth data to change the lighting mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would appreciate whatever input the community has regarding this problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance, &#xA;Stanislas.&lt;/p&gt;&#xA;" OwnerUserId="22993" LastEditorUserId="11700" LastEditDate="2016-06-15T00:26:32.283" LastActivityDate="2016-06-15T00:26:32.283" Title="Lighting LED Strip via HC-06 Bluetooth Module" Tags="|bluetooth|interrupt|rgb-led|threads|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25210" PostTypeId="2" ParentId="25171" CreationDate="2016-06-14T07:51:55.890" Score="0" Body="&lt;p&gt;I figure out the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve the session between Arduino and the server must ended after each Post using  &lt;code&gt;client.stop();&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void switch_led() {&#xA;      bool SwitchReading = digitalRead(SWITCH);&#xA;      if (SwitchReading == HIGH) {&#xA;        state = state + 1;&#xA;        if (state % 2 != 0) {&#xA;          digitalWrite(LED, HIGH);&#xA;          char data1[] = &quot;{&quot;&quot;LDRValue&quot;&quot;: 88888888}&quot;;&#xA;          Serial.println(&quot;\nStarting connection to post server...&quot;);&#xA;          if (client.connect(server, 8040)) {&#xA;            Serial.println(&quot;connected to post server&quot;);&#xA;            client.println(&quot;POST /api/sensor HTTP/1.1&quot;);&#xA;            client.println(&quot;Host: 192.168.2.116&quot;);&#xA;            client.println(&quot;Content-Type: application/json&quot;);&#xA;            client.print(&quot;Content-Length: &quot;);&#xA;            client.println(strlen(data1));&#xA;            client.println();&#xA;            client.print(data1);&#xA;          }&#xA;          client.stop();&#xA;        }&#xA;        else {&#xA;          digitalWrite(LED, LOW);&#xA;          char data2[] = &quot;{&quot;&quot;LDRValue&quot;&quot;: 11111111111}&quot;;&#xA;          Serial.println(&quot;\nStarting connection to post server...&quot;);&#xA;          if (client.connect(server, 8040)) {&#xA;            Serial.println(&quot;connected to post server&quot;);&#xA;            client.println(&quot;POST /api/sensor HTTP/1.1&quot;);&#xA;            client.println(&quot;Host: 192.168.2.116&quot;);&#xA;            client.println(&quot;Content-Type: application/json&quot;);&#xA;            client.print(&quot;Content-Length: &quot;);&#xA;            client.println(strlen(data2));&#xA;            client.println();&#xA;            client.print(data2);&#xA;          }&#xA;          client.stop();&#xA;        }&#xA;       }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22826" LastActivityDate="2016-06-14T07:51:55.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25212" PostTypeId="2" ParentId="25187" CreationDate="2016-06-14T08:42:55.297" Score="2" Body="&lt;p&gt;I think I am using a setup like you wish at my home:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;PoE Switch (for example Cisco SG300-28P) &lt;/li&gt;&#xA;&lt;li&gt;Arduino Ethernet's with PoE Module (&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardEthernet&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardEthernet&lt;/a&gt;) I bought one for every room ;-)&lt;/li&gt;&#xA;&lt;li&gt;Use DHCP-Server on raspberry PI&lt;/li&gt;&#xA;&lt;li&gt;Put your sensors on your Arduino ethernet board&lt;/li&gt;&#xA;&lt;li&gt;I am also using MQTT as protokoll for example &lt;a href=&quot;http://pubsubclient.knolleary.net/&quot; rel=&quot;nofollow&quot;&gt;http://pubsubclient.knolleary.net/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Use MQTT broker Mosquitto on raspberry pi&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For the case that you want to use your switch also for internet connectivity, define a vlan (search wikipedia) for your arduino sensor network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-14T08:42:55.297" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25216" PostTypeId="1" AcceptedAnswerId="25219" CreationDate="2016-06-14T09:24:01.830" Score="0" ViewCount="527" Body="&lt;p&gt;i have a Arduino Mega 2560 and want send data with 230400bps to my laptop without any framingerror.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want send the data over USB with serial.print ist that possible or must i use the ethernet?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When that is possible it will be really nice when someone can write what i have to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With friendly wishes sniffi&lt;/p&gt;&#xA;" OwnerUserId="21214" LastActivityDate="2016-06-14T10:56:31.583" Title="Is it possible to overclock the baudrate from the mega to 230400 bps?" Tags="|serial|arduino-mega|baud-rate|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25217" PostTypeId="2" ParentId="14361" CreationDate="2016-06-14T09:32:02.077" Score="1" Body="&lt;p&gt;You should forget about the $_SESSION[&quot;ID&quot;]; on PHP side, because you are working stateless without any session!&#xA;You should give a parameter for identifying your variable from arduino to php script - is this the temp=0? If so you need to exchange &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$sql=&quot;SELECT temp FROM perfil, client WHERE perfil.ID ='$id'&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$sql=&quot;SELECT temp FROM perfil, client WHERE perfil.ID =&quot; . $_GET[&quot;temp&quot;];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;assuming that perfil.id is only an integer - if it is a string, then add &quot;'&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-14T09:32:02.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25219" PostTypeId="2" ParentId="25216" CreationDate="2016-06-14T10:56:31.583" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to overclock the baudrate from the mega to 230400 bps?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, setting that baud-rate is not a problem but this specific baud-rate may will give a high error rate. According to the AVR baud-rate calculation (UBRRn Settings for 16 Mhz system clock) the error is 8.5% (U2Xn=0) and -3.5% (U2Xn=1). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simply choosing 250000 bps will remove this error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-06-14T10:56:31.583" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25220" PostTypeId="1" AcceptedAnswerId="25221" CreationDate="2016-06-14T11:21:53.307" Score="1" ViewCount="709" Body="&lt;p&gt;I, like many others, have encountered the avrdude error. However, I am not sure how to go about fixing mine after looking at numerous forums, etc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verification error, first mismatch at byte 0x0002&#xA;     0x74 != 0xe6&#xA;avrdude: verification error; content mismatch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am simply trying to upload a simple sketch, but right when it seems it is about to finish, I get this error and the uploading loading bar simply never finishes... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="28084" LastEditDate="2016-11-12T08:50:17.380" LastActivityDate="2017-01-11T13:15:25.727" Title="AVRDUDE Error (Arduino Leonardo)" Tags="|arduino-leonardo|uploading|avrdude|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25221" PostTypeId="2" ParentId="25220" CreationDate="2016-06-14T11:47:34.610" Score="1" Body="&lt;p&gt;I had lots of issues when I first started.  these are all things I tried and at least one of them stopped this problem occurring, but I haven't a clue which.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Close the IDE (if you are using it and open it again)&lt;/li&gt;&#xA;&lt;li&gt;Disconnect your board, wait 10 seconds and reconnect it.&lt;/li&gt;&#xA;&lt;li&gt;Check you settings, are you using the correct board, etc.&lt;/li&gt;&#xA;&lt;li&gt;Use a different cable.&lt;/li&gt;&#xA;&lt;li&gt;Update your drivers.&lt;/li&gt;&#xA;&lt;li&gt;Update your IDE/Toolset.&lt;/li&gt;&#xA;&lt;li&gt;Use a different physical port on your PC.&lt;/li&gt;&#xA;&lt;li&gt;Load the Blink example, if that doesn't work you serious have issues.&lt;/li&gt;&#xA;&lt;li&gt;Reboot your PC.&lt;/li&gt;&#xA;&lt;li&gt;If you can, try a different PC.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-14T11:47:34.610" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25224" PostTypeId="2" ParentId="25202" CreationDate="2016-06-14T12:25:34.740" Score="0" Body="&lt;p&gt;1A will be enough to power you arduino but the total powerconsumtion will depend on the amount of leds that you want to drive. If you follow the instuctable, it should be enoug but it's never a good idea to use your power source at max capacity all the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It allows you to connect 2 modules indeed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why would you need a voltage divider?&lt;/p&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-06-14T12:25:34.740" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25226" PostTypeId="2" ParentId="40" CreationDate="2016-06-14T12:38:51.340" Score="1" Body="&lt;p&gt;Notepad++ &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set Notepad++: view-&gt;folder as work space&lt;/li&gt;&#xA;&lt;li&gt;and Language-&gt;C-&gt;C++ sets syntax highlighting&lt;/li&gt;&#xA;&lt;li&gt;set arduino Ide file-&gt;preferences &quot;Use external editor&quot;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and everything runs smoothly, without the bulk of eclipse.&lt;/p&gt;&#xA;" OwnerUserId="22868" LastActivityDate="2016-06-14T12:38:51.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25230" PostTypeId="2" ParentId="25197" CreationDate="2016-06-14T13:07:53.613" Score="2" Body="&lt;p&gt;First of all, let me second Majenko in suggesting the use of an RTC. The&#xA;Arduino Uno is clocked from a ceramic resonator, and these are nowhere&#xA;accurate enough for proper timekeeping. C.f. the answers to &lt;a href=&quot;https://arduino.stackexchange.com/questions/27&quot;&gt;How do I&#xA;get an accurate time?&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, instead of counting seconds, I suggest you instead count&#xA;&lt;em&gt;milliseconds&lt;/em&gt;. I know it sounds like overkill, but it's actually&#xA;simpler because you already have &lt;code&gt;millis()&lt;/code&gt; returning a millisecond&#xA;count:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    uint32_t now = millis();&#xA;    static uint32_t last_minute;&#xA;&#xA;    // Increment the time every minute.&#xA;    if (now - last_minute &amp;gt;= 60000) {&#xA;        last_minute += 60000;&#xA;        if (++minutes &amp;gt;= 60) {&#xA;            minutes = 0;&#xA;            if (++hours &amp;gt;= 24)&#xA;                hours = 0;&#xA;        }&#xA;    }&#xA;&#xA;    // Do not advance the seconds when the user sets the time.&#xA;    if (time_is_being_set_by_the_user()) {&#xA;        last_minute = now;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Oh, wait! No! Do not count milliseconds, instead &lt;strong&gt;count microseconds&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    uint32_t now = micros();&#xA;    static uint32_t last_minute;&#xA;&#xA;    // Increment the time every minute.&#xA;    if (now - last_minute &amp;gt;= 60000000) {&#xA;        last_minute += 60000000;&#xA;&#xA;        // The rest does not change...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why? Because, as I said before, the ceramic resonator of your Arduino is&#xA;not very accurate. You will eventually find out that it drifts&#xA;significantly. However, if you compare to a good reference, you will be&#xA;able to &lt;em&gt;calibrate&lt;/em&gt; the drift. If, for example, you find that it drifts&#xA;forward by 0.0025% (about 15 seconds per week, quite optimistic), you&#xA;will be able to fix it simply by replacing 60000000 by 60001500. The&#xA;same would work if counting milliseconds, except that you would only be&#xA;able to do a coarse tuning. Oh, and do &lt;a href=&quot;https://arduino.stackexchange.com/a/12588&quot;&gt;not worry about &lt;code&gt;micros()&lt;/code&gt;&#xA;overflowing&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-06-14T13:07:53.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25231" PostTypeId="2" ParentId="25204" CreationDate="2016-06-14T13:11:44.883" Score="1" Body="&lt;p&gt;Alternatively there are &lt;a href=&quot;http://www.alliedelec.com/m/d/884b78cb9e915349d3e84cb62d58bd3e.pdf&quot; rel=&quot;nofollow&quot;&gt;COTS parts&lt;/a&gt; (Common Off The Shelf) which are simpler to use and may satisfy your requirements.  This is just the 1st one I found (search for &quot;5 volt piezo buzzer&quot;).  Of course you have no control over the frequency.  These type of devices are just to get your attention (you didn't say what your application was for).   While it works at 5 volts it is only rated at 85dB @ 10cm.  It appears to contain an internal driver so (apparently) only needs 3 to 15 volts to start making noise.  It is specified to draw 10mA at 12V.  So be careful and measure the current (using a power supply, not from an Arduino) demand at 5 volts.  I think the &lt;a href=&quot;http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations&quot; rel=&quot;nofollow&quot;&gt;GPIO pins on an Arduino can only handle less than 40mA&lt;/a&gt;.  So stay well below that to be safe.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-14T13:11:44.883" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25233" PostTypeId="1" AcceptedAnswerId="25248" CreationDate="2016-06-14T14:10:39.310" Score="2" ViewCount="612" Body="&lt;p&gt;I have a problem with the Teensy, its EEPROM and another Array.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My program contains two Arrays, the first one is a 128x4 long Array, the other one a 2560x2 double Array. The first Array is meant to be written to the EEPROM once a certain time (=number of loops) is reached. The other Array is meant to be written to an SD-Card or just the terminal, can't deiced yet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is that whenever I uncomment the save()-function the first 17 data-quadruples in the EEPROM get somehow overwritten by random data. Always the first 17 with would be the first 68 numbers or 272 byte.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried renameing the save()-function, but the onlything that works for now is to comment the function in the loop()-function out so that it won't be called at all. I even have enough RAM left, the Arduino IDE tells me I am using about 73% of the RAM for variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could it be that be creating more variables somewhere else the Teensy overwrites the Array for the EEPROM? But than again why doesn't that happen if I don't write into the everything-Array?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Greetings,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;John&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Please excuse my not perfect English for it's not my native language.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Includes&#xA;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;String.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;elapsedMillis looptime = 0; //time for each loop in ms&#xA;int loopnumber = 0; //number of loops&#xA;elapsedMillis overalltime = 0; //overalltime in ms&#xA;const int iterationtime = 25; //time for each loop in ms&#xA;&#xA;//EEPROM&#xA;//Deklarations&#xA;int nsd = 0; //counter for saving into eepromArray&#xA;const int maxArrayrows = 128; //Max number of row in eepromArray&#xA;int iArray = 0; //Number of used rows in eepromArray&#xA;long eepromArray[128][4]; //Array for EEPROM-storage&#xA;bool writtentoEEPROM = false;&#xA;double everything[2560][2]; //Big Araay with a pair of numbers of each loop&#xA;&#xA;// Some more variables&#xA;double z, zpunkt, alpha, angle;&#xA;&#xA;void setup() {&#xA; // Just inititialing stuff, nothing to do with the Arrays&#xA;}&#xA;&#xA;void loop() {&#xA;  //Calculating more stuff&#xA;&#xA;  ++nsd;&#xA;  if (nsd &amp;gt;= 20) {&#xA;    WritetoArray();&#xA;  }&#xA;&#xA;  save(loopnumber);&#xA;&#xA;  ++loopnumber;&#xA;&#xA;  looptime = 0;&#xA;}&#xA;&#xA;&#xA;//********************************************************&#xA;//&#xA;// Save Data in Array. If full write into EEPROM&#xA;//&#xA;// long: 4 byte&#xA;// Storeage needed for each quadruple: 4*4 byte = 16 byte&#xA;// EEPROM-size: 2 kibyte&#xA;// Max number of quadruples: 2048 byte / 16 byte = 128&#xA;// Quadrupels per second: 2&#xA;// Max time: 128 / 2 = 64 s&#xA;//&#xA;//********************************************************&#xA;void WritetoArray() {&#xA;  int scale = 10000;&#xA;  long zArray = (long)(scale * z);&#xA;  long zpunktArray = (long)(scale * zpunkt);&#xA;  long alphaArray = (long)(scale * alpha);&#xA;  long angleArray = (long)(scale * angle);&#xA;  if (iArray &amp;lt; maxArrayrows) {&#xA;    eepromArray[iArray][0] = zArray;&#xA;    eepromArray[iArray][1] = zpunktArray;&#xA;    eepromArray[iArray][2] = alphaArray;&#xA;    eepromArray[iArray][3] = angleArray;&#xA;    ++iArray;&#xA;  }&#xA;  else {&#xA;    if (writtentoEEPROM == false) {&#xA;      WritetoEEPROM();&#xA;      writtentoEEPROM = true;&#xA;    }&#xA;    while(true){&#xA;      for(int n = 0; n &amp;lt; 2560; ++n){&#xA;        Serial.printf(&quot;%f, %f\n&quot;, everything[n][0], everything[n][1]);&#xA;      }&#xA;      Serial.println(&quot;----------&quot;);&#xA;    }&#xA;  }&#xA;  nsd = 0;&#xA;}&#xA;&#xA;&#xA;//********************************************************&#xA;//&#xA;// Write Data to EEPROM&#xA;//&#xA;//********************************************************&#xA;void WritetoEEPROM() {&#xA;  byte data;&#xA;  int adress = 0;&#xA;  int  i = 0;&#xA;  while (adress &amp;lt; 2048) {&#xA;    for (int n = 0; n &amp;lt;= 3; ++n) {&#xA;      for (int a = 0; a &amp;lt;= 3; ++a) {&#xA;        data = (eepromArray[i][n] &amp;gt;&amp;gt; ((3 - a) * 8)) &amp;amp; 0x000000ff;&#xA;        EEPROM.write(adress + a, data);&#xA;      }&#xA;      adress = adress + 4;&#xA;    }&#xA;    ++i;&#xA;  }&#xA;}&#xA;&#xA;//********************************************************&#xA;//&#xA;// Save data-pair for later usage&#xA;//&#xA;//********************************************************&#xA;void save(int l) {&#xA;  everything[l][0] = z;&#xA;  everything[l][1] = angle;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11434" LastEditorUserId="2881" LastEditDate="2016-06-14T17:43:59.893" LastActivityDate="2016-07-14T22:57:18.420" Title="Overwritten EEPROM" Tags="|teensy|eeprom|array|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25234" PostTypeId="1" CreationDate="2016-06-14T14:19:45.017" Score="2" ViewCount="1394" Body="&lt;p&gt;I am running a program on the ATtiny and for some reason I am way over the 512 bytes of RAM that are available to me. This is confusing because when I did the math by hand I should have 432 bytes. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define FASTADC 1&#xA;&#xA;// defines for setting and clearing register bits&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;SoftwareSerial mySerial(0,1);    //This uses 47 bytes of RAM&#xA;&#xA;byte i = 0;      This uses 1 byte of RAM&#xA;&#xA;byte pixelsArray1[128];   //Arrays use 128 bytes of RAM each&#xA;byte pixelsArray2[128];&#xA;byte pixelsArray3[128];&#xA;&#xA;void setup() &#xA;{&#xA;#if FASTADC&#xA;// set prescale to 16&#xA;sbi(ADCSRA,ADPS2);&#xA;cbi(ADCSRA,ADPS1);&#xA;cbi(ADCSRA,ADPS0);&#xA;#endif&#xA;&#xA;pinMode(1,OUTPUT);        //Setting the 1 pin to be used for output &#xA;pinMode(0,OUTPUT);        //Setting the 0 pin to be used for output&#xA;pinMode(A3,INPUT);         //Input for Camera 3&#xA;pinMode(A2,INPUT);         //Input for Camera 2&#xA;pinMode(A1,INPUT);         //Input for Camera 1&#xA;&#xA;mySerial.begin(9600);     //Setting the data transfer rate&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's telling me that I am using 510 Bytes of memory but my math gave me 432 bytes of RAM. Does anyone see what I'm missing?&lt;/p&gt;&#xA;" OwnerUserId="23008" LastActivityDate="2016-06-14T14:29:59.003" Title="What is using up all the RAM in my program?" Tags="|attiny|memory-usage|memory|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25235" PostTypeId="2" ParentId="25234" CreationDate="2016-06-14T14:29:59.003" Score="9" Body="&lt;p&gt;There is a lot you are missing.  Such as:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;SoftwareSerial is using RAM.&lt;/li&gt;&#xA;&lt;li&gt;The system stack is using RAM.&lt;/li&gt;&#xA;&lt;li&gt;The Arduino core software is using RAM.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There's plenty more going on than just your sketch. For instance, where do you think it stores the current &lt;code&gt;millis()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt; counts? Where do you think incoming serial data gets buffered? Where do you think your registers, PC, etc, get stashed when a function (such as &lt;code&gt;setup()&lt;/code&gt;) is called? All that takes RAM.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-14T14:29:59.003" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25239" PostTypeId="2" ParentId="25110" CreationDate="2016-06-14T17:01:26.320" Score="0" Body="&lt;p&gt;As far as I know, there was an internal dispute in the Arduino company. So now there are two companies selling under the Arduino name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;www.arduino.cc 's latest ide is 1.5.x and that has more features than www.arduino.org 's ide 1.6.x. So make sure you use arduino.cc's version only because they do the major development of the IDE.&lt;/p&gt;&#xA;" OwnerUserId="20571" LastEditorUserId="20571" LastEditDate="2016-06-14T17:06:35.093" LastActivityDate="2016-06-14T17:06:35.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25240" PostTypeId="1" CreationDate="2016-06-14T17:33:38.953" Score="0" ViewCount="515" Body="&lt;p&gt;I have a character array called &lt;code&gt;storebuffer&lt;/code&gt; that contains data from a POST submission and its in the format &lt;code&gt;ssid=abcdef&amp;amp;pswd=ghijk&lt;/code&gt;. I wanted to extract everything after &lt;code&gt;ssid=&lt;/code&gt; into one array called &lt;code&gt;acqSSID&lt;/code&gt; and the portion after &lt;code&gt;&amp;amp;pswd=&lt;/code&gt; into another array called &lt;code&gt;acqPaswd&lt;/code&gt;. I tried using this but it does not seem to be working. MAX_STORE_BUFFER_LEN is 255. Can anyone help?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ctr = 0;&#xA;for (ctr = 5; ctr &amp;lt; MAX_STORE_BUFFER_LEN; ctr++)&#xA;{&#xA;  if ( (storebuffer[ctr] == '&amp;amp;') &amp;amp;&amp;amp; (storebuffer[ctr+1] == 'p') &amp;amp;&amp;amp; (storebuffer[ctr+2] == 's') &amp;amp;&amp;amp; (storebuffer[ctr+3] == 'w') &amp;amp;&amp;amp; (storebuffer[ctr+4] == 'd') &amp;amp;&amp;amp; (storebuffer[ctr+5] == '=') )&#xA;  {&#xA;    break;&#xA;  }&#xA;  acqSSID[ctr] = storebuffer[ctr];&#xA;}&#xA;&#xA;Serial.print(&quot;acqSSID: &quot;);&#xA;Serial.println(acqSSID);&#xA;Serial.print(&quot;ctr: &quot;);&#xA;Serial.println(ctr);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22842" LastActivityDate="2016-08-13T18:59:11.327" Title="Extracting a specific sequence of characters from an array" Tags="|arduino-yun|array|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25241" PostTypeId="2" ParentId="25240" CreationDate="2016-06-14T17:37:02.787" Score="0" Body="&lt;p&gt;Rather than &lt;code&gt;acqSSID[ctr] = storebuffer[ctr];&lt;/code&gt;, say (eg) &lt;code&gt;acqSSID[ctr-5] = storebuffer[ctr];&lt;/code&gt;.  Also, after the break but before printing &lt;code&gt;acqSSID&lt;/code&gt;, say &lt;code&gt;acqSSID[ctr-5] = 0;&lt;/code&gt; to terminate the string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, rather than coding a literal 5, you might say &lt;code&gt;enum { acqOffset=5 };&lt;/code&gt; up front, and subsequently use &lt;code&gt;acqOffset&lt;/code&gt; in place of the literal.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-06-14T17:37:02.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25244" PostTypeId="1" CreationDate="2016-06-14T17:45:17.320" Score="0" ViewCount="271" Body="&lt;p&gt;So my program fails to run because there is not enough room for my variables as well as the Arduino Core and Stack. I can't find any more ways to optimize my program so I'm thinking about just rewriting it in C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm not sure if that will actually help me. For example I know that in C my program will run faster because things like &lt;code&gt;digitalWrite()&lt;/code&gt; and &lt;code&gt;analogRead()&lt;/code&gt; have a bunch of &quot;extras&quot; that make it go slower, but I don't know if this will affect RAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So can any of the experts on here tell me if writing my code will help before I waste time doing so?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;#define FASTADC 1&#xA;&#xA;// defines for setting and clearing register bits&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;SoftwareSerial mySerial(0,1) PROGMEM;&#xA;&#xA;byte i;&#xA;&#xA;byte pixelsArray1[128];   //Array to hold the values of the individual pixles.&#xA;byte pixelsArray2[128];   //Array to hold the values of the individual pixles.&#xA;byte pixelsArray3[128];   //Array to hold the values of the individual pixles.&#xA;&#xA;void setup() &#xA;{&#xA;  #if FASTADC&#xA;   // set prescale to 16&#xA;   sbi(ADCSRA,ADPS2);&#xA;   cbi(ADCSRA,ADPS1);&#xA;   cbi(ADCSRA,ADPS0);&#xA;  #endif&#xA;&#xA;  pinMode(1,OUTPUT);        //Setting the 1 pin to be used for output &#xA;  pinMode(0,OUTPUT);        //Setting the 0 pin to be used for output&#xA;  pinMode(A3,INPUT);        //Input for Camera 3&#xA;  pinMode(A2,INPUT);        //Input for Camera 2&#xA;  pinMode(A1,INPUT);        //Input for Camera 1&#xA;&#xA;  mySerial.begin(9600);     //Setting the data transfer rate&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I'm programming on the ATtiny85&lt;/li&gt;&#xA;&lt;li&gt;I'm running Windows 10&lt;/li&gt;&#xA;&lt;li&gt;I've never programmed in Arduino before&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23008" LastEditorUserId="23008" LastEditDate="2016-06-15T20:33:47.330" LastActivityDate="2016-06-15T20:33:47.330" Title="Would rewriting my code in C help reduce RAM usage?" Tags="|programming|c|attiny|memory-usage|memory|" AnswerCount="2" CommentCount="9" ClosedDate="2016-06-15T20:33:04.450" ContentLicense="CC BY-SA 3.0" />
  <row Id="25246" PostTypeId="1" AcceptedAnswerId="25280" CreationDate="2016-06-14T17:32:16.367" Score="2" ViewCount="874" Body="&lt;p&gt;I wrote the code to produce the periodic signal by using arduino and DAC0808 where i turned on and off the respectively pins of PORTA by using a logic in iterative manner and created the periodic signal. But even without using delay logic, i couldn't get signal time period as comparable to 50 Hz voltage signal. And what i seek to get is to decrease the time period of generated signal. Pls note, blue signal is reference signal of 50Hz frequency.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float increment = 3.14159 / 500;&#xA;float initial = 0;&#xA;float value = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  DDRA  = B11111111;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  PORTA = B00000000;&#xA;  while (1)&#xA;  {&#xA;    initial = initial + increment;&#xA;    value = sin(initial)  * 255;&#xA;    PORTA = abs(value);&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/UyZ8f.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UyZ8f.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23018" OwnerDisplayName="Abhaya Singh Pandey" LastEditorUserId="23018" LastEditDate="2016-06-14T20:11:39.153" LastActivityDate="2016-06-15T11:09:04.293" Title="Unable to create a desired periodic signal with Arduino Mega 2560 and DAC0808" Tags="|arduino-mega|arduino-ide|electronics|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25247" PostTypeId="2" ParentId="25244" CreationDate="2016-06-14T18:22:14.533" Score="4" Body="&lt;p&gt;The simplest approach to reducing RAM usage of the program shown is to get rid of the three 128-byte pixel arrays.  They are not needed for the program to function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of writing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pixelsArray1[i]=analogRead(A1)/4;&#xA;pixelsArray2[i]=analogRead(A2)/4;&#xA;pixelsArray3[i]=analogRead(A3)/4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;write&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (analogRead(A1)/4 == 0 &amp;amp;&amp;amp; analogRead(A2)/4 == 0 &amp;amp;&amp;amp; analogRead(A3)/4 == 0) ++foundZero;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;foundZero&lt;/code&gt; is initialized to zero before the loop.  After the loop, you say something like&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (foundZero--) {&#xA;  digitalWrite(1, HIGH);&#xA;  delay(2000);&#xA;  digitalWrite(1, LOW);&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to toggle pin 1 as many times as there were three zero pixels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, the timing of the &lt;code&gt;if (...) ++foundZero;&lt;/code&gt; statement may differ from pixel to pixel because the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; evaluation may short circuit.  If the timing matters, save data in temporary variables, or check if the sum of the three is zero, etc.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-06-14T18:27:40.520" LastActivityDate="2016-06-14T18:27:40.520" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25248" PostTypeId="2" ParentId="25233" CreationDate="2016-06-14T19:14:31.943" Score="2" Body="&lt;p&gt;In your loop(), you increment repeatedly loopnumber without ever resetting it. You should at the very least replace &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loopnumber++ ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;loopnumber = (loopnumber+1)%2560 ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Otherwise, when loopnumber becomes &gt;= 2560, your save() function will begin writing outside the 'everything' array and overwriting whatever is written in the adjacent positions of memory.&lt;/p&gt;&#xA;" OwnerUserId="19886" LastEditorUserId="19886" LastEditDate="2016-06-14T20:56:04.377" LastActivityDate="2016-06-14T20:56:04.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25249" PostTypeId="1" AcceptedAnswerId="25251" CreationDate="2016-06-14T19:22:34.977" Score="4" ViewCount="1803" Body="&lt;p&gt;I'm running a program on a ATtiny85 and running into problems because of a lack of available RAM. When I ran &lt;code&gt;avr-nm&lt;/code&gt; on my ELF file I found that SoftwareSerial was taking up a lot of RAM even though I'm just using it to set the data transfer rate with &lt;code&gt;mySerial.begin(9600);&lt;/code&gt; and nowhere else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm wondering if there is another way of doing this without using so much memory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySerial(0,1);&#xA;&#xA;mySerial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22875" LastActivityDate="2022-03-24T21:50:12.290" Title="Is the a low memory alternative to SoftwareSerial?" Tags="|softwareserial|attiny|memory-usage|memory|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25250" PostTypeId="2" ParentId="25246" CreationDate="2016-06-14T19:23:17.077" Score="1" Body="&lt;p&gt;I'm interpreting your phrase “even without using delay logic, i couldn't get signal time period as comparable to 50 Hz” as meaning that the code shown runs Too Slow.  At 1000 samples per cycle and 50 Hz on an 8-bit 16-MHz processor, you only have 320 clocks to compute a &lt;code&gt;sin()&lt;/code&gt;, which probably is not enough to compute a 32-bit floating &lt;code&gt;sin()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To speed it up, you can either issue fewer samples per cycle or make the loop go faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the “fewer samples per cycle” approach, you would make &lt;code&gt;increment&lt;/code&gt; bigger; for example, instead of 3.14159/500, or 1000 samples per cycle, perhaps an interval of 2π/500, or 500 samples per cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the “make the loop go faster” approach, you could use a lookup table or fixed-point integer arithmetic or both.  Note, the lookup table only needs to cover 90° (or π/2 radians); index in reverse for quadrants 2 and 4, and negate values for quadrants 3 and 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, after you speed up the code, you will need to set up a time base for issuing samples.  This could use a clock-based interrupt routine that gets and issues the next array value, or that sets a flag so your main loop can get and issue a value.  Or you could spin until &lt;code&gt;micros()&lt;/code&gt; exceeds a deadline, at which time you (1) issue a value, (2) set the next deadline, and (3) compute the next value.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-06-14T19:23:17.077" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25251" PostTypeId="2" ParentId="25249" CreationDate="2016-06-14T20:00:16.627" Score="6" Body="&lt;p&gt;Simplest thing would probably be to edit your copy of SoftwareSerial.h&#xA;and replace &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/SoftwareSerial/src/SoftwareSerial.h#L42&quot; rel=&quot;noreferrer&quot;&gt;&lt;code&gt;#define _SS_MAX_RX_BUFF 64&lt;/code&gt; on line&#xA;42&lt;/a&gt;&#xA;by something smaller. If your &lt;code&gt;loop()&lt;/code&gt; runs fast enough (no delays, no&#xA;blocking code) you could probably get away with buffering only a very&#xA;few bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could rewrite the library so that, instead of buffering the&#xA;incoming bytes, it handles them to you for processing. See for example&#xA;this &lt;a href=&quot;http://www.technoblogy.com/show?VSX&quot; rel=&quot;noreferrer&quot;&gt;receive-only UART code based on the USI&#xA;port&lt;/a&gt; for an illustration of the&#xA;approach.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-14T20:00:16.627" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25252" PostTypeId="1" AcceptedAnswerId="25253" CreationDate="2016-06-14T20:12:29.700" Score="2" ViewCount="2433" Body="&lt;p&gt;I'd like to know if it's possible to create a library for Arduino that does not contain a class, just functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know how to create a library with a class, but I'd like to create a library of general purpose functions that don't need to be instantiated to be used. Just used like the standard functions included in the Arduino IDE:  sizeof(), etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible?  If so, can anyone point me in the direction of a template?  I've been searching, but haven't found anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="23023" LastActivityDate="2016-06-14T21:08:19.843" Title="Create a library without a class?" Tags="|library|class|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25253" PostTypeId="2" ParentId="25252" CreationDate="2016-06-14T20:19:08.220" Score="3" Body="&lt;p&gt;Yes, it's possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just don't make a class. Just make functions instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like a class-based one, have a &lt;code&gt;.cpp&lt;/code&gt; and a &lt;code&gt;.h&lt;/code&gt; file. In the &lt;code&gt;.cpp&lt;/code&gt; file (or &lt;code&gt;.c&lt;/code&gt; file if you don't want any of the C++ functionality or 90% of the Arduino API available to you) place your functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;code&gt;.h&lt;/code&gt; file place prototypes for them. I am in the habit of adding the &lt;code&gt;extern&lt;/code&gt; keyword, but you don't actually need to for functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo.cpp:&#xA;&#xA;void doSomething() {&#xA;    // whatever&#xA;}&#xA;&#xA;foo.h:&#xA;&#xA;extern void doSomething();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can include your &lt;code&gt;.h&lt;/code&gt; file and call your functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;foo.h&amp;gt;&#xA;&#xA;// ...&#xA;&#xA;doSomething();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-14T20:19:08.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25254" PostTypeId="1" AcceptedAnswerId="25255" CreationDate="2016-06-10T04:36:48.437" Score="1" ViewCount="1770" Body="&lt;p&gt;Stacked mega and ethernet/sd shield:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ufrib.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ufrib.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;When I do this stacking, it heats up. I tried connecting the SPI via ports 13-10 (no stacking), it doesn't work. Also tried connecting the ICSP (red circled mark) via male-female wires without stacking, it works, but still heats up. So I think the ICSP has a defect? or does it? Is it supposed to be like this and I'm just being paranoid?&lt;/p&gt;&#xA;&lt;p&gt;*PS: the heat in the &amp;quot;pain&amp;quot; level when I touch it, no burning IC odor. Maybe it's because I unplug it immediately after short use? IDK.&lt;/p&gt;&#xA;&lt;p&gt;**update, I think I got it working, the problem was not about the heating, but the program. Consulted a more experienced person, he said what's happening is normal.&lt;/p&gt;&#xA;" OwnerDisplayName="Nico Dioso" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-06-14T20:43:16.407" Title="Arduino mega 2560 Stacked with Ethernet/SD card Shield Heat up" Tags="|ethernet|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25255" PostTypeId="2" ParentId="25254" CreationDate="2016-06-10T10:36:28.720" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;em&gt;the heat in the &quot;pain&quot; level when I touch it, no burning IC odor. Maybe it's because I unplug it immediately after short use? IDK.&#xA;  So I think the ICSP has a defect? or does it? Is it supposed to be like this and I'm just being paranoid?&lt;/em&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well you're right in being a bit paranoid. And temperature building up is very likely to mean you've got a short somewhere, it might be a bad solder or a component that fails (like a cap that conducts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you've got to isolate the issue:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Isolate the faulty board: whichever board is getting hot, it might be that one that has a failure &lt;em&gt;or&lt;/em&gt; the other one ruining it&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you need to try the shield with another arduino (whatever version it is) and see if the issue is replicating&lt;/li&gt;&#xA;&lt;li&gt;then you need to try the arduino you were using with another shield running on ICSP (like another ethernet shield, or an SDCard shield), which will confirm the hypothesis that only one component of the two is failing.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Once you've isolated the board, you need to isolate the component.&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you first have to isolate which component is building up heat. &lt;/li&gt;&#xA;&lt;li&gt;If you've got access to a thermal camera, it's a good idea to use it. &lt;/li&gt;&#xA;&lt;li&gt;If not: start locating the area where heat is building with your finger, and then test each component of the area with a thermometer (like the ones you plug on a multimeter, or simply a &quot;meat&quot; thermometer for cooking).&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Once you've isolated the component, then look it up on the schematics and layout, and lookup all connected components. Either that component or one on the track is failing, or there's a short on that track.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If the solution is not obvious, you can come back on Stack Exchange (get on the &lt;a href=&quot;http://electronics.stackexchange.com&quot;&gt;electronics QA site&lt;/a&gt; with your results), and some EE expert will help you find out what's wrong!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;HTH&lt;/p&gt;&#xA;" OwnerUserId="379" OwnerDisplayName="zmo" LastActivityDate="2016-06-10T10:36:28.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25256" PostTypeId="2" ParentId="25193" CreationDate="2016-06-14T20:54:55.440" Score="1" Body="&lt;p&gt;Pins number 12, 11 are used by some other library in your code. And that's the reason there is no LCD output. Change pins/connections from 12, 11 to 7, 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then your code uses &lt;code&gt;lcd.clear()&lt;/code&gt; too often, so whatever data you display vanishes before you were able to read. Don't clear the display unnecessarily.&lt;/p&gt;&#xA;" OwnerUserId="23025" LastEditorUserId="4628" LastEditDate="2018-01-08T07:33:52.820" LastActivityDate="2018-01-08T07:33:52.820" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25257" PostTypeId="2" ParentId="22254" CreationDate="2016-06-14T20:55:04.333" Score="1" Body="&lt;p&gt;Under Windows, Arduino puts the source code for hardware specific stuff in User\AppData\Local\Arduino, and not in the installation folder. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* -------- US_WPMR : (USART Offset: 0xE4) Write Protect Mode Register -------- */&#xA;#define US_WPMR_WPEN (0x1u &amp;lt;&amp;lt; 0) /**&amp;lt; \brief (US_WPMR) Write Protect Enable */&#xA;#define US_WPMR_WPKEY_Pos 8&#xA;#define US_WPMR_WPKEY_Msk (0xffffffu &amp;lt;&amp;lt; US_WPMR_WPKEY_Pos) /**&amp;lt; \brief (US_WPMR) Write Protect KEY */&#xA;#define US_WPMR_WPKEY(value) ((US_WPMR_WPKEY_Msk &amp;amp; ((value) &amp;lt;&amp;lt; US_WPMR_WPKEY_Pos)))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would guess unlocking / locking would take the format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;????-&amp;gt;US_WPMR = (US_WPMR_WPEN | US_WPMR_WPKEY(0x555341));&#xA;????-&amp;gt;US_WPMR = (~US_WPMR_WPEN &amp;amp; US_WPMR_WPKEY(0x555341));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23028" LastActivityDate="2016-06-14T20:55:04.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25259" PostTypeId="2" ParentId="25207" CreationDate="2016-06-14T21:26:44.840" Score="0" Body="&lt;p&gt;Yes, it can be done. You don't need a realtime OS for something as simple as that. Basically in your loop function you would check the serial port and parse the input (if available) to see if the PC instructed the arduino to change its mode. Then you would call a function - say nextstep() - which would perform whatever the next step is, depending on your current mode. True, when you get serial input your loop() will take longer to execute, which will alter the 'rhythm' of your fades etc. If this is important, you should replace the call to delay() with a loop checking millis() against a value stored at the start of loop().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int currentmode ;&#xA;int previousmode ;&#xA;&#xA;void loop()&#xA;{&#xA;   previousmode = currentmode ;&#xA;   currentmode = getnewmode(currentmode) ;&#xA;   if (currentmode != previousmode)&#xA;      initmode(currentmode) ;  // turn new mode on e.g. change LED color&#xA;   nextstep(currentmode) ;     // if current mode is dynamic, make change&#xA;   delay(DELAY_INTERVAL) ;&#xA;}&#xA;&#xA;int getnewmode(oldmode)&#xA;{&#xA;   if (!serialpending()) // no serial input&#xA;      return oldmode ;&#xA;   return parseinput() ;       &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19886" LastActivityDate="2016-06-14T21:26:44.840" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25260" PostTypeId="1" AcceptedAnswerId="25261" CreationDate="2016-06-14T02:04:45.947" Score="2" ViewCount="10324" Body="&lt;p&gt;I have an embarrassingly simple question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My experience to date has been limited to Arduino Uno + Wifi101.  I bought an ESP8266 and noticed that the GPIO pins don't match the printed numbers on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When programming and defining pins, does &lt;code&gt;#define &amp;lt;pin name&amp;gt; 16&lt;/code&gt; call the pin with the printed designation D0?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find a straight answer to this anywhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Image credit: &lt;a href=&quot;http://crufti.com/content/images/2015/11/nodemcudevkit_v1-0_io.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://crufti.com/content/images/2015/11/nodemcudevkit_v1-0_io.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/93qIq.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/93qIq.jpg&quot; alt=&quot;NodeMCU ESP8266&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13355" OwnerDisplayName="acpilot" LastActivityDate="2016-11-15T12:31:37.773" Title="Basic Question - ESP8266 Board Pins" Tags="|pins|esp8266|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25261" PostTypeId="2" ParentId="25260" CreationDate="2016-06-14T08:42:38.653" Score="2" Body="&lt;p&gt;Looks like you're using &lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;, in which case - yes, 16 is GPIO16, which on the NodeMCU board you have is labeled D0.  &lt;br&gt;&#xA;I am not entirely sure why the NodeMCU guys had to do this &quot;pin remapping&quot;, but the end result is inconvenience when using the module with anything but their Lua.&lt;/p&gt;&#xA;" OwnerUserId="20696" OwnerDisplayName="Mishony" LastActivityDate="2016-06-14T08:42:38.653" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25262" PostTypeId="2" ParentId="25260" CreationDate="2016-06-14T23:15:06.123" Score="2" Body="&lt;p&gt;It looks like they are using a similar system to the Arduino pin mappings, for example:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/W6hdF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/W6hdF.png&quot; alt=&quot;Arduino Uno pin mappings&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Image credit: &lt;a href=&quot;https://www.arduino.cc/en/Hacking/PinMapping168&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Hacking/PinMapping168&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There, for example, pin 2 on the chip, is D0 (digital pin 0) on the board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Their board will use their own mappings, but the concept is the same.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;does #define  16 call the pin with the printed designation D0?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That doesn't &quot;call&quot; anything. It would depend on the code. If the code in question addresses the actual chip pins, then it is chip pin 16. If it goes through a library and the library maps the chip pins to the board pins, that it will refer to board pin 16. I notice BTW that the board doesn't have a pin 16.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-14T23:15:06.123" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25263" PostTypeId="1" CreationDate="2016-06-15T00:52:09.850" Score="1" ViewCount="1637" Body="&lt;p&gt;I have 2 programs to test serial communication, an simple arduino program that echoes whatever is on the serial port and a python program that writes to the serial port and prints the reply.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm having an issue where whenever I upload the arduino program and try to run the python code the arduino code wouldn't detect serial available on the first run.  I would have to either&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;open and close serial monitor before I run python program &lt;/li&gt;&#xA;&lt;li&gt;run the python program, quit, and run it again&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and it would continue to work until I re-upload the arduino then the same thing happens.  Does anyone know what is the issue?  This is on Ubuntu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str;&#xA;&#xA;void setup() {                &#xA;// Turn the Serial Protocol ON&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available()) {&#xA;      str = Serial.readStringUntil('\n');     // Read the serial input&#xA;      Serial.println(str);             // sends ascii code&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Python&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;&#xA;&#xA;ser = serial.Serial('/dev/ttyACM1', 115200)&#xA;&#xA;for i in range(0,4):&#xA;    str = &quot;test string\n&quot;&#xA;    ser.write(str)&#xA;    print ser.readline()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21351" LastEditorUserId="21351" LastEditDate="2016-06-15T01:04:23.343" LastActivityDate="2016-12-14T19:27:41.380" Title="Serial available doesn't work right after upload" Tags="|arduino-uno|serial|python|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25264" PostTypeId="1" AcceptedAnswerId="25276" CreationDate="2016-06-15T01:02:45.773" Score="0" ViewCount="6825" Body="&lt;p&gt;I've got an array of char* with serial data that I'm trying to remove ':' from. I have tried to iterate through the char*, find and remove any colons but it just comes out as garbage.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;  char* espData[15];&#xA;&#xA;  // pull data from serial and tokenize with strtok &amp;gt; feed to espData&#xA;&#xA;  for(int x = 0; x &amp;lt; index-1; x++){&#xA;    size_t nullTerm = strlen(espData[x]);&#xA;    espData[x][nullTerm - 1] = '\0';&#xA;    char* output&#xA;    for(size_t i = 0; i &amp;lt; strlen(espData[x]); ++i){&#xA;      if(espData[x][i] != ':') output += espData[x][i];&#xA;    }&#xA;    espData[x] = output;&#xA;    Serial.println(espData[x]);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Moving the null character works fine (I wanted to get rid of the last character in every string). Most of the answers I found for general C++ used std::string which we don't have access to.&lt;/p&gt;&#xA;" OwnerUserId="20355" LastEditorUserId="4131" LastEditDate="2016-06-15T16:28:17.847" LastActivityDate="2016-06-15T16:28:17.847" Title="Remove certain characters from char*" Tags="|string|array|pointer|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25265" PostTypeId="2" ParentId="12578" CreationDate="2016-06-15T01:10:45.040" Score="1" Body="&lt;p&gt;A: Use interrupts to detect the state change on the reed switch&lt;br&gt;&#xA;B: Use a hall sensor instead of the reed, they do not suffer switch bounce&lt;br&gt;&#xA;C: Use a debounce circuit, a 74HC14 with a small capacitor connected between ground and the input&lt;br&gt;&#xA;Put a 4K7 resistor as pullup between VCC &amp;amp; the input&lt;br&gt;&#xA;Put a 100 ohm resistor on the wire coming from the Reed, which is connected to GND on the other side&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 100 ohm prevents discharge damage to the contacts from the capacitor and suppresses RF interference&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ground all unused inputs and feed the output of the active channel to the Arduino&#xA;The 74HC series are 3v3 &amp;amp; 5V compatible, the 74HCT series is only 5V compatible but are more suited as level shifters from 3v3 signals to 5V output&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;D: use a software debounce routine&lt;/p&gt;&#xA;" OwnerUserId="23032" LastActivityDate="2016-06-15T01:10:45.040" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25267" PostTypeId="1" AcceptedAnswerId="25272" CreationDate="2016-06-15T02:45:00.433" Score="1" ViewCount="8821" Body="&lt;p&gt;I want to create a dynamic sized array of chars as a member in a class.&#xA;This is being done inside a library that I've created. &#xA;I have the &lt;code&gt;.h&lt;/code&gt; and the &lt;code&gt;.cpp&lt;/code&gt; files created. I'm not sure how to declare the array in the &lt;code&gt;.h&lt;/code&gt; file. I've tried a few things so far:&#xA;&lt;code&gt;char* content;&lt;/code&gt;&#xA;&lt;code&gt;char content[];&lt;/code&gt;&#xA;But these don't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I have in my &lt;code&gt;.h&lt;/code&gt; file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class bufr{&#xA;    public:&#xA;    //constructor and deconstructor&#xA;    bufr(char* _chars, uint8_t _len);&#xA;    ~bufr();&#xA;&#xA;    //variables&#xA;    uint8_t len;&#xA;    char content[];&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's what I have in my &lt;code&gt;.cpp&lt;/code&gt; file (this is the constructor):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bufr::bufr(char* _chars, uint8_t _len){&#xA;    char* content = new char[_len];&#xA;    content = _chars;&#xA;    len = _len;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've also tried replacing the line &lt;code&gt;content = _chars&lt;/code&gt; with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; _len; i++){&#xA;    content[i] = _chars[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this also doesn't work.  When I print the &lt;code&gt;content&lt;/code&gt; member to the serial port from within the constructor, or in the main loop it prints nonsense characters, not what I passed it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my main loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;    char chars[] = &quot;1234&quot;;&#xA;    bufr buf(chars, 4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have I explained myself well enough?  Can anyone give me a hand?&#xA;Much appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh, and yes, I know - in my deconstructor that's not shown, I have &lt;code&gt;delete [] content&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I plan on using this class nested inside another class in a few spots and hoping to take advantage of the dynamic mem allocation.  I know I can simply declare an array of fixed length, but I wanted to learn the proper way to use &lt;code&gt;new&lt;/code&gt; and &lt;code&gt;delete&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="23023" LastEditorUserId="10794" LastEditDate="2016-06-15T05:52:29.070" LastActivityDate="2021-09-02T10:34:39.273" Title="Dynamicly sized array as a class member" Tags="|c++|class|array|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25268" PostTypeId="1" AcceptedAnswerId="25409" CreationDate="2016-06-15T03:09:49.993" Score="2" ViewCount="2301" Body="&lt;p&gt;I'm trying to have a &lt;code&gt;millis()&lt;/code&gt; timer run to emulate a hardware timer inside a library, but I'm having issues compiling the code. I want the callback (pseudo ISR) to be part of the class, and not use global variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using &lt;a href=&quot;https://github.com/JChristensen/Timer/tree/v2.1&quot; rel=&quot;nofollow noreferrer&quot;&gt;Christensen's / Monk's Timer library&lt;/a&gt;, but I'm open to suggestions if there are other better/easier timer libraries out there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I have so far. It's just an example for me to understand how this might work. I'm sure there are better ways of making an LED blink, but this is just for illustrative purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Compiling gives a bunch of &quot;invalid use of member variables in static functions&quot; errors.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;error: invalid use of member 'Blink::_led_status' in static member function&#xA;           int _led_status;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;After trying to add glue routines as per your other answer I can seem to get one instance working, but adding another stops the first light from blinking, and the second one blinks on and off at the wrong times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The test library is on &lt;a href=&quot;https://github.com/waspinator/test-timer&quot; rel=&quot;nofollow noreferrer&quot;&gt;github&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Blink.h&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#ifndef Blink_h&#xA;#define Blink_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;Timer.h&amp;gt; // https://github.com/JChristensen/Timer/master&#xA;    // Timer.h uses millis() instead of built in timers &#xA;&#xA;class Blink {&#xA;public:&#xA;  Blink (int led_pin, int duration);&#xA;  void begin ();&#xA;  void updateTimer();&#xA;&#xA;private:&#xA;  static void _callbackGlue();&#xA;  void _callback();&#xA;&#xA;  static Blink *_instance;&#xA;  Timer *_blink_timer;&#xA;  int _led_pin;&#xA;  int _duration;&#xA;  int _led_status;&#xA;  int _blink_event;&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;blink.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Blink.h&quot;&#xA;&#xA;Blink *Blink::_instance;&#xA;&#xA;Blink::Blink (int led_pin, int duration) {&#xA;  _blink_timer = new Timer();&#xA;  _led_status = 0;&#xA;  _led_pin = led_pin;&#xA;  _duration = duration;&#xA;  pinMode(_led_pin, OUTPUT);&#xA;  digitalWrite(_led_pin, LOW);&#xA;}&#xA;&#xA;void Blink::begin () {&#xA;  _blink_event = _blink_timer-&amp;gt;every(_duration, _callbackGlue);&#xA;  _instance = this;&#xA;}&#xA;&#xA;void Blink::_callbackGlue() {&#xA;  _instance-&amp;gt;_callback();&#xA;}&#xA;&#xA;void Blink::_callback() {&#xA;  if (_led_status == 0) {&#xA;    digitalWrite(_led_pin, HIGH);&#xA;    _led_status = 1;&#xA;  } else if (_led_status == 1) {&#xA;    digitalWrite(_led_pin, LOW);&#xA;    _led_status = 0;&#xA;  }&#xA;}&#xA;&#xA;void Blink::updateTimer() {&#xA;  _blink_timer-&amp;gt;update();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;test/test.ino&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Blink.h&quot;&#xA;&#xA;Blink first_blink (13, 500);&#xA;//Blink second_blink (12, 1000);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting...&quot;);&#xA;  first_blink.begin();&#xA;  //second_blink.begin();&#xA;} &#xA;&#xA;void loop() {&#xA;  first_blink.updateTimer();&#xA;  //second_blink.updateTimer();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7461" LastEditorUserId="4628" LastEditDate="2018-01-07T06:52:17.813" LastActivityDate="2018-01-07T06:52:17.813" Title="How do I use interrupt service routines inside libraries and classes?" Tags="|library|timers|class|isr|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25270" PostTypeId="1" CreationDate="2016-06-15T04:38:23.850" Score="1" ViewCount="102" Body="&lt;p&gt;First time coding for Arduino. I'm working on code to operate an electronic valve switch. We have a laptop connected to an Arduino Mega, and that Arduino is hooked up to the valve (hardware) on Pin 53. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was trying to work off of the &quot;blink&quot; example originally, but that gives no basis for user prompted control. Basically I want to have the computer ask me if I should turn it on or off, type in my response (I was using &quot;HIGH&quot; for on and &quot;LOW&quot; for off, as in voltage control), and have that activate or deactivate the hardware. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main problem right now stems from how best to ask for that input. I've been trying to work with the Messenger.h library thus far. I'm definitely getting hung up on how to define the pin, or what the simplest method for user input would be. (HIGH or LOW? 0 or 1? Something else?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code is below. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Messenger.h&amp;gt;&#xA;&#xA;Messenger message = Messenger(); &#xA;&#xA;// Variable definitions. Switchinput is what the user commands, current state is whether the air is flowing or not. &#xA;boolean currentstate;&#xA;boolean switchinput;&#xA;String pin53; // Something is up on this line?? How to define this pin??&#xA;&#xA;// FUNCTION DEFINITIONS&#xA;// Startup fxn&#xA;void start() &#xA;{&#xA;  Serial.print(&quot;LOW = off, HIGH = on. Switch is &quot;);&#xA;  Serial.println(currentstate);&#xA;  Serial.print(&quot;Enter LOW to turn on or HIGH to turn off: &quot;);&#xA;  switchinput = Serial.read();&#xA;}&#xA;&#xA;// Go off to on&#xA;void offtoon()&#xA;{&#xA;    digitalWrite(pin53,HIGH);&#xA;    currentstate = switchinput;     &#xA;}&#xA;&#xA;// Go on to off&#xA;void ontooff()&#xA;{&#xA;    digitalWrite(pin53,LOW);&#xA;    currentstate = switchinput;     &#xA;}&#xA;&#xA;// Stay same -- already off&#xA;void staysameoff()&#xA;{&#xA;  if ((currentstate = switchinput) &amp;amp;&amp;amp; (switchinput = LOW))&#xA;  {&#xA;      void start();&#xA;  }&#xA;}&#xA;&#xA;// Stay same -- already on&#xA;void staysameon()&#xA;{&#xA;  if ((currentstate = switchinput) &amp;amp;&amp;amp; (switchinput = HIGH))&#xA;  {&#xA;    void start(); &#xA;  }&#xA;}&#xA;&#xA;&#xA;// Running actual code&#xA;void setup() &#xA;{&#xA;  // initialize digital pin 53 as an output.&#xA;  pinMode(pin53, OUTPUT);&#xA;&#xA;  // Sets default state to switch being off (Off = LOW, On = HIGH)&#xA;  String currentstate = LOW;&#xA;}&#xA;&#xA;&#xA;void loop() &#xA;{&#xA;   if ((currentstate != switchinput) &amp;amp;&amp;amp; (switchinput = HIGH))&#xA;  {&#xA;      void offtoon();&#xA;  }&#xA;&#xA;  if ((currentstate != switchinput) &amp;amp;&amp;amp; (switchinput = LOW))&#xA;  {&#xA;      void ontooff();&#xA;  }&#xA;&#xA;  if ((currentstate = switchinput) &amp;amp;&amp;amp; (switchinput = LOW))&#xA;  {&#xA;      void staysameoff();&#xA;  }&#xA;&#xA;  if ((currentstate = switchinput) &amp;amp;&amp;amp; (switchinput = HIGH))&#xA;  {&#xA;      void samestayon();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23040" LastEditorUserId="4131" LastEditDate="2016-06-15T16:19:47.133" LastActivityDate="2016-06-15T16:19:47.133" Title="Computer to Arduino to hardware, controlling on / off state of hardware via user input on computer" Tags="|arduino-mega|hardware|input|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25272" PostTypeId="2" ParentId="25267" CreationDate="2016-06-15T05:53:14.930" Score="1" Body="&lt;p&gt;This is wrong on a number of levels. First in the class declaration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char content[];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;s&gt;That gives you a pointer to an array of zero length.&lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This gives you an array of char, of zero length. This is not useful.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* content = new char[_len];&#xA;content = _chars;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That does a &lt;code&gt;new&lt;/code&gt; into a &lt;strong&gt;new&lt;/strong&gt; variable &lt;code&gt;content&lt;/code&gt; - not the class variable. Then you assign (overwrite) the passed pointer into &lt;code&gt;content&lt;/code&gt; (discarding the memory you just allocated). That pointer is then discarded when the constructor ends. Perhaps using &lt;code&gt;strcpy&lt;/code&gt; would be better. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made up a small example based on your code which prints the correct result:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class bufr &#xA;  {&#xA;  public:&#xA;    //constructor and deconstructor&#xA;    bufr(char* chars, uint8_t len);&#xA;    ~bufr();&#xA;&#xA;    //variables&#xA;    uint8_t len_;&#xA;    char * content_;&#xA;  };    // end of class bufr&#xA;&#xA;bufr::bufr(char* chars, uint8_t len) &#xA;  {&#xA;  content_ = new char[len];&#xA;  memcpy (content_, chars, len);  // copy into allocated memory&#xA;  len_ = len;   // remember length&#xA;  }   // end of constructor&#xA;&#xA;bufr::~bufr()&#xA;{&#xA;  delete [] content_;&#xA;} // end of destructor&#xA;&#xA;void setup() &#xA;{&#xA;  Serial.begin (115200);&#xA;&#xA;  char chars[] = &quot;1234 &quot;;&#xA;  bufr buf(chars, sizeof chars);&#xA;&#xA;  Serial.println (buf.content_);&#xA;} // end of setup&#xA;&#xA;void loop() &#xA;{&#xA;} // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can you explain to me why it was making a new variable content and not using the class variable?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Small example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char * content;&#xA;&#xA;void loop ()&#xA;  {&#xA;  char * content = &quot;foo&quot;;  // makes a NEW variable&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example there are &lt;strong&gt;two&lt;/strong&gt; variables named &lt;code&gt;content&lt;/code&gt;. The one in the function &quot;shadows&quot; the global one. However the code below only has one variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char * content;&#xA;&#xA;void loop ()&#xA;  {&#xA;  content = &quot;foo&quot;;  // uses existing variable&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In the destructor, when you delete the pointer to the array, does this free up the memory allocated to the array? It's now free to be assigned again by something else? Or does it sit there still initialized as that array, not being able to be used again?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You aren't deleting the pointer. You are deleting the &lt;em&gt;memory it points to&lt;/em&gt;. The pointer is now pointing to freed memory, so using it as a pointer at this stage would be wrong. You can do another &lt;code&gt;new&lt;/code&gt; to make it point to something else.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;they delete pointer and then delete[] pointer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You misinterpreted that. You either &lt;code&gt;delete pointer&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;delete [] pointer&lt;/code&gt; depending on whether &lt;code&gt;pointer&lt;/code&gt; is an array or not. I reworked &lt;code&gt;content&lt;/code&gt; to not be an array, &lt;s&gt;thus deleting it without the brackets is correct&lt;/s&gt; however as it is allocated using &lt;code&gt;new []&lt;/code&gt; it must be deleted with &lt;code&gt;delete []&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;on the link posted above they say to use delete this way: delete pointer if it was a single element allocated with new or delete [] pointer to release memory allocation for arrays of elements allocated with new and a size in []'s. So in my case I want to use delete [] content_? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, you don't want to be setting up an array in the first place. Take a look at this small example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct   {&#xA;  char bar [];&#xA;  } foo;&#xA;&#xA;void setup() &#xA;{&#xA;Serial.begin (115200);&#xA;Serial.println (&quot;Starting&quot;);&#xA;Serial.println (sizeof (foo));&#xA;Serial.println (sizeof (foo.bar));&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Starting&#xA;0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The variable &lt;code&gt;bar&lt;/code&gt; is a zero-length array. Thus the entire struct &lt;code&gt;foo&lt;/code&gt; is also zero length. It isn't even a pointer (that would be two bytes on this platform).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is wrong to use an array of char like that, when you want to dynamically allocate memory. Look at this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char foo [4];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That allocates 4 bytes of memory for &lt;code&gt;foo&lt;/code&gt;. You can't later on make it longer by doing a &lt;code&gt;new&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you want is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char * foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have allocated a &lt;strong&gt;pointer&lt;/strong&gt; and can do a &lt;code&gt;new&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;foo = new char [10];  // allocate 10 bytes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then delete it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delete [] foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You use the brackets on the delete, as you used them with the &lt;code&gt;new&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you allocated &lt;strong&gt;one char&lt;/strong&gt; you wouldn't use brackets. eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char * foo;&#xA;foo = new char;  // allocate a pointer to one byte&#xA;...&#xA;delete foo;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-16T06:04:40.920" LastActivityDate="2016-06-16T06:04:40.920" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="25273" PostTypeId="1" AcceptedAnswerId="25275" CreationDate="2016-06-15T06:01:43.723" Score="0" ViewCount="314" Body="&lt;p&gt;I just started with Arduino programming and currently I'm using this Sparkfun clone board:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;o &lt;a href=&quot;http://nl.aliexpress.com/item/Digispark-kickstarter-Micro-development-board-ATTINY85-module-for-Arduino-usb/32584975067.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://nl.aliexpress.com/item/Digispark-kickstarter-Micro-development-board-ATTINY85-module-for-Arduino-usb/32584975067.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's really nice and like the way to program it and 'burn' it, it's easy to do. For the first project, I came along this instructable, an USB volume knob: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;o &lt;a href=&quot;http://www.instructables.com/id/Digispark-Volume-Control/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Digispark-Volume-Control/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the Sparkfun Arduino programming IDE with added AdaFruit Trinket USB library (Trinket is also ATtiny85), download source, tweak it a bit to my needs and it's working perfectly. Had some programming question though, see also:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;o &lt;a href=&quot;https://stackoverflow.com/questions/37740026/change-override-trinket-attiny85-usb-identification-name-device-name/37743886#37743886&quot;&gt;https://stackoverflow.com/questions/37740026/change-override-trinket-attiny85-usb-identification-name-device-name/37743886#37743886&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;o  &lt;a href=&quot;https://stackoverflow.com/questions/37769451/arduino-make-a-library-more-optional-by-project?lq=1&quot;&gt;https://stackoverflow.com/questions/37769451/arduino-make-a-library-more-optional-by-project?lq=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;o &lt;a href=&quot;https://stackoverflow.com/questions/37824336/arduino-trinket-attiny85-usb-possible-to-read-the-state-of-all-keys&quot;&gt;https://stackoverflow.com/questions/37824336/arduino-trinket-attiny85-usb-possible-to-read-the-state-of-all-keys&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, optimized the source code (original not really a beauty), play with it and added also a fade-In/fade-out idle feature to the LED on PIN 1 and it blinks when turning the dial encoder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to add add some more features to this knob, such as pushbuttons to change some internal modes. For example:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Toggle button for knob sensitivity (3-modes: slow (default), normal, fast) &lt;/li&gt;&#xA;&lt;li&gt;A mute button&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I want to that device 'remember' the state of the toggle button but there is no option (flash memory) to save the state. So I came with the idea to use a backup button cell to keep the device 'alive' when disconnected from USB (or computer turned off). A Button cell is 3V and USB is 5V so maybe is possible to 'test' the input voltage. If this is possible you can put the device in sleep mode (low power mode) directly after detecting USB connection lost and this voltage drop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have read already an article how to put the device into sleep mode (and awake from it):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;o &lt;a href=&quot;https://bigdanzblog.wordpress.com/2014/08/10/attiny85-wake-from-sleep-on-pin-state-change-code-example/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://bigdanzblog.wordpress.com/2014/08/10/attiny85-wake-from-sleep-on-pin-state-change-code-example/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question is:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I measure somehow the voltage is used to power the device? Any ideas (code example please if it is possible)?&lt;/p&gt;&#xA;" OwnerUserId="23043" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-11-12T11:23:45.107" Title="ATtiny85 (Sparfun Clone/Trinket), detect/read operation voltage" Tags="|c++|voltage-level|attiny|input|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25274" PostTypeId="2" ParentId="19614" CreationDate="2016-06-15T06:40:47.957" Score="0" Body="&lt;p&gt;Often reinstall the latest arduino IDE with Windows Administrator rights helps (use right click execute as administrator).&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T06:40:47.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25275" PostTypeId="2" ParentId="25273" CreationDate="2016-06-15T08:50:44.443" Score="1" Body="&lt;p&gt;There are a few solutions. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you want to save te state of your toggle button you can save it in the eeprom of your attiny85&lt;/li&gt;&#xA;&lt;li&gt;You can use an ADC pin to check your VCC against the internal 1.1V reference&lt;/li&gt;&#xA;&lt;li&gt;alternatively you can read the 1.1ref aganist Avcc. &lt;a href=&quot;https://digistump.com/board/index.php?topic=1104.0&quot; rel=&quot;nofollow&quot;&gt;https://digistump.com/board/index.php?topic=1104.0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-06-15T08:50:44.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25276" PostTypeId="2" ParentId="25264" CreationDate="2016-06-15T09:54:18.197" Score="1" Body="&lt;p&gt;You've assumed that a &lt;code&gt;char *&lt;/code&gt; is some kind of string object, since you've got the following line of code: &lt;code&gt;output += espData[x][i];&lt;/code&gt;, and then later &lt;code&gt;espData[x] = output;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It quite simply doesn't work like that. At best you can point &lt;code&gt;output&lt;/code&gt; inside &lt;code&gt;espData[x]&lt;/code&gt; and then do some other logic: but your attempt to &quot;accumulate&quot; the correct characters is incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please consider the following code instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* espData[15];&#xA;&#xA;for(int x = 0; x &amp;lt; index-1; x++){&#xA;    size_t nullTerm = strlen(espData[x]); // Get current length&#xA;    char* output = espData[x];            // Start of string&#xA;    for (size_t i = 0; i &amp;lt; nullTerm; ++i){&#xA;        if(espData[x][i] != ':') {        // If it's NOT a colon&#xA;            *output++ = espData[x][i];    // Copy character 'up'&#xA;        } // if&#xA;                                          // If it WAS a colon, then&#xA;                                          // output does NOT get incremented&#xA;    } // for&#xA;    *output = '\0'; // End string off with NUL&#xA;    Serial.println(espData[x]);&#xA;} // for&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-06-15T11:05:25.330" LastActivityDate="2016-06-15T11:05:25.330" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25279" PostTypeId="2" ParentId="25244" CreationDate="2016-06-15T11:01:48.947" Score="0" Body="&lt;p&gt;I don't believe that rewriting it in C is going to help you much: the framework is pretty tight already, and you'd only get the C library's versions of the various drivers' buffers etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do think your only solution (apart from getting larger hardware!) is to 'optimise' the &lt;code&gt;pixelArray&lt;/code&gt;s. To do that, could you consider the following questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the worst value resolution that you'll get away with? You're currently compressing each camera feeds' pixel to the range 0-255, to store them into their individual bytes. What about 0-31? (See why below)&lt;/li&gt;&#xA;&lt;li&gt;Will you always be comparing each feed's individual pixels against the same pixel in another feed? If so, perhaps you could pack all three values into one 16-bit quantity:&lt;br&gt;&#xA;&lt;code&gt;X 11111 22222 33333&lt;/code&gt;&lt;br&gt;&#xA;where each quintet of bits is that feed's value compressed down. The &lt;code&gt;X&lt;/code&gt; is cute: before compressing, you could compare all three values with each other, or zero, or something, and if true set the X bit to &lt;code&gt;1&lt;/code&gt;. That then means that you can later test for that exact condition in the triple-pixel with a &lt;code&gt;&amp;lt;0&lt;/code&gt; check - the sign bit will be set, so the condition will be true.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Or, if compressing down to 0-31 is too extreme, what about storing a 'master' copy of the pixel, and then two (scaled) differences from there: &lt;code&gt;11111111 2222 3333&lt;/code&gt; where the master &lt;code&gt;1&lt;/code&gt; value is unscaled (other than &lt;code&gt;/4&lt;/code&gt;), while the other values are from the following table:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;0000&lt;/code&gt; - Identical pixel value&lt;br&gt;&#xA;&lt;code&gt;0001&lt;/code&gt; - Within +2&lt;br&gt;&#xA;&lt;code&gt;1111&lt;/code&gt; - Within -2&lt;br&gt;&#xA;&lt;code&gt;0010&lt;/code&gt; - Within +4&lt;br&gt;&#xA;&lt;code&gt;1110&lt;/code&gt; - Within -4&lt;br&gt;&#xA;&lt;code&gt;0011&lt;/code&gt; - Within +8&lt;br&gt;&#xA;&lt;code&gt;1101&lt;/code&gt; - Within -8&lt;br&gt;&#xA;&lt;code&gt;0100&lt;/code&gt; - Within +16&lt;br&gt;&#xA;&lt;code&gt;1100&lt;/code&gt; - Within -16&lt;br&gt;&#xA;&lt;code&gt;0101&lt;/code&gt; - Within +32&lt;br&gt;&#xA;&lt;code&gt;1011&lt;/code&gt; - Within -32&lt;br&gt;&#xA;&lt;code&gt;0110&lt;/code&gt; - Within +64&lt;br&gt;&#xA;&lt;code&gt;1010&lt;/code&gt; - Within -64&lt;br&gt;&#xA;&lt;code&gt;0111&lt;/code&gt; - Within +128&lt;br&gt;&#xA;&lt;code&gt;1001&lt;/code&gt; - Within -128&lt;br&gt;&#xA;&lt;code&gt;1000&lt;/code&gt; - More than ±128&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;Even more radical: could you do all the tests when you read the data (do you have time???), and then simply store a one-bit result for each pixel? Such a packed-bit array is VERY efficient - if you can boil down your decision to yes/no...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'd be happy to help write (reasonably) efficient C code to implement the TriplePixel functions - or even attempt it in assembly...&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-15T11:01:48.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25280" PostTypeId="2" ParentId="25246" CreationDate="2016-06-15T11:09:04.293" Score="0" Body="&lt;p&gt;As has been mentioned before, in comments and in jwpat7's answer, your&#xA;main problem here is the time taken to compute the sines. I already&#xA;provided a link to a &lt;a href=&quot;https://www.logre.eu/wiki/Trigonom%C3%A9trie_en_virgule_fixe&quot; rel=&quot;nofollow noreferrer&quot;&gt;faster fixed-point implementation of&#xA;&lt;code&gt;sin()&lt;/code&gt;&lt;/a&gt; but, since you have an Mega2560 with loads of RAM, I&#xA;would go to the simpler look-up table method. I would not even bother&#xA;optimizing the size of the table.&lt;/p&gt;&#xA;&lt;p&gt;For controlling the timing, you can use the canonical method described&#xA;in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blink Without Delay&lt;/a&gt; Arduino tutorial, with one twist: times&#xA;should be measures with &lt;code&gt;micros()&lt;/code&gt; instead of &lt;code&gt;millis()&lt;/code&gt;. Here is a&#xA;first version of the program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const float FREQUENCY = 50;            // hertz&#xA;const float PERIOD = 1e6 / FREQUENCY;  // microseconds&#xA;const size_t TABLE_SIZE = 512;&#xA;const uint16_t SAMPLE_TIME = PERIOD/TABLE_SIZE + 0.5;&#xA;uint8_t wavetable[TABLE_SIZE];&#xA;&#xA;void setup()&#xA;{&#xA;    // Prepare the wavetable.&#xA;    for (size_t i = 0; i &amp;lt; TABLE_SIZE; i++) {&#xA;        wavetable[i] = 255 * abs(sin(M_PI * i / TABLE_SIZE));&#xA;    }&#xA;&#xA;    // Set port A as output.&#xA;    DDRA = 0xff;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    uint16_t now = micros();&#xA;    static uint16_t last_sample;&#xA;    static size_t phase;&#xA;&#xA;    if (now - last_sample &amp;gt; SAMPLE_TIME) {&#xA;        last_sample += SAMPLE_TIME;&#xA;        PORTA = wavetable[phase];&#xA;        phase = (phase + 1) % TABLE_SIZE;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A few things worth noting:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The float constants &lt;code&gt;FREQUENCY&lt;/code&gt; and &lt;code&gt;PERIOD&lt;/code&gt; are used only at compile&#xA;time.&lt;/li&gt;&#xA;&lt;li&gt;The table size is a power of two because wrapping a table index&#xA;modulo a power of two is way faster than modulo, say, 500: the&#xA;compiler optimizes the modulo into a bitwise AND.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;+ 0.5&lt;/code&gt; in the expression of &lt;code&gt;SAMPLE_TIME&lt;/code&gt; is intended to ensure&#xA;that the result is rounded to the &lt;em&gt;nearest&lt;/em&gt; integer. In this instance&#xA;it happens to be useless because rounding down would give the same&#xA;result.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;code&gt;micros()&lt;/code&gt; function returns a 32-bit integer, but in this&#xA;application it is sufficient and faster to track only the 16 least&#xA;significant bits, hence the &lt;code&gt;uint16_t&lt;/code&gt; timing variables. And no,&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/12587&quot;&gt;these variables overflowing is not a problem&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This should give you, in theory, a frequency of 50.08 Hz, i.e.&#xA;0.16% too fast. The discrepancy is due to &lt;code&gt;SAMPLE_TIME&lt;/code&gt;, which should be&#xA;39.0625 µs, being rounded to 39 µs. You could fix this by&#xA;counting time with a higher resolution, but given the poor accuracy of&#xA;the ceramic resonator clocking the Arduino, this is probably not worth&#xA;the trouble.&lt;/p&gt;&#xA;&lt;p&gt;A potentially worse problem is the large jitter you have with this&#xA;approach, on the order of 10 µs. This is due both to the time taken&#xA;to run through the loop and the occasional timer interrupt taking some&#xA;extra time. You can get rid of this jitter by using a timer interrupt&#xA;instead of &lt;code&gt;micros()&lt;/code&gt;. Here is a second version of the program that uses&#xA;this approach:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const float FREQUENCY = 50;              // hertz&#xA;const float PERIOD = F_CPU / FREQUENCY;  // CPU cycles&#xA;const size_t TABLE_SIZE = 512;&#xA;const uint16_t SAMPLE_TIME = PERIOD/TABLE_SIZE + 0.5;&#xA;uint8_t wavetable[TABLE_SIZE];&#xA;&#xA;int main()&#xA;{&#xA;    // Prepare the wavetable.&#xA;    for (size_t i = 0; i &amp;lt; TABLE_SIZE; i++) {&#xA;        wavetable[i] = 255 * abs(sin(M_PI * i / TABLE_SIZE));&#xA;    }&#xA;&#xA;    // Set port A as output.&#xA;    DDRA = 0xff;&#xA;&#xA;    // Configure Timer 1.&#xA;    OCR1A = SAMPLE_TIME - 1;  // set the period&#xA;    TIMSK1 = _BV(OCIE1A);     // enable TIMER1_COMPA interrupt&#xA;    TCCR1B = _BV(WGM12)       // CTC mode with TOP = OCR1A&#xA;           | _BV(CS10);       // clock at F_CPU / 1&#xA;&#xA;    // Sleep while waiting for interrupts.&#xA;    sei();&#xA;    sleep_enable();&#xA;    for (;;) sleep_cpu();&#xA;}&#xA;&#xA;// Service routine for the Timer 1 interrupt.&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;    static size_t phase;&#xA;&#xA;    PORTA = wavetable[phase];&#xA;    phase = (phase + 1) % TABLE_SIZE;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Again, a few notes:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The &lt;code&gt;SAMPLE_TIME&lt;/code&gt; is now computed in CPU cycles and, since it is an&#xA;integer number of cycles (namely 625), there should in principle be&#xA;no frequency discrepancy.&lt;/li&gt;&#xA;&lt;li&gt;For counting 625 cycles we need a 16-bit timer clocked at the full&#xA;CPU speed (prescaler = 1). We are using Timer 1 here. See the&#xA;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet of the ATmega2560&lt;/a&gt;, chapter 17, for details on&#xA;using the timer.&lt;/li&gt;&#xA;&lt;li&gt;Sleeping between interrupts is needed in order to obtain&#xA;cycle-accurate timings. If we had simply an infinite loop, there&#xA;could be a few CPU cycles of jitter, which may not be a big deal.&lt;/li&gt;&#xA;&lt;li&gt;Writing &lt;code&gt;main()&lt;/code&gt; instead of &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; is a way to skip&#xA;the initialization normally done by the Arduino core library. In this&#xA;application that initialization is better avoided, because it creates&#xA;an extra jitter-inducing interrupt and it messes with Timer 1 in a&#xA;way that we would need to undo.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-06-15T11:09:04.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25281" PostTypeId="2" ParentId="8969" CreationDate="2016-06-15T11:38:28.590" Score="1" Body="&lt;p&gt;I don't think that arduino is the right hardware for such a project. Better use a cheap android phone, there you have a stronger processor with more memory as well as a lot of sensors like compass, accelerometer, gyroscope and maybe in newer ones barometer, which you will need - also you have wifi. An arduino uno just comes without wifi and all the sensors. Also I guess a lot of persons already have a phone, so this will lower your project costs, because hardware is already available at most users. Last but not least I think you could use mobile phone vibrations to give feedback to the sight disabled users, oder sound commands like &quot;go left&quot; etc.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T11:38:28.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25282" PostTypeId="1" CreationDate="2016-06-15T11:41:22.810" Score="0" ViewCount="368" Body="&lt;p&gt;I am a newbie in Arduino and I am trying to decode time from ltc audio. For this I got Arduino UNO. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got a sample code from &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,8237.0.html&quot; rel=&quot;nofollow&quot;&gt;here.&lt;/a&gt;. Here my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define icpPin 8        // ICP input pin on arduino&#xA;#define one_time_max          588 // these values are setup for NTSC video&#xA;#define one_time_min          422 // PAL would be around 1000 for 0 and 500 for 1&#xA;#define zero_time_max          1080 // 80bits times 29.97 frames per sec&#xA;#define zero_time_min          922 // equals 833 (divide by 8 clock pulses)&#xA;&#xA;&#xA;#define end_data_position      63&#xA;#define end_sync_position      77&#xA;#define end_smpte_position     80&#xA;&#xA;volatile unsigned int bit_time;&#xA;volatile boolean valid_tc_word;&#xA;volatile boolean ones_bit_count;&#xA;volatile boolean tc_sync;&#xA;volatile boolean write_tc_out;&#xA;volatile boolean drop_frame_flag;&#xA;&#xA;volatile byte total_bits;&#xA;volatile byte current_bit;&#xA;volatile byte sync_count;&#xA;&#xA;volatile byte tc[8];&#xA;volatile char timeCode[11];&#xA;&#xA;/* ICR interrupt vector */&#xA;ISR(TIMER1_CAPT_vect)&#xA;{&#xA; //toggleCaptureEdge&#xA; TCCR1B ^= _BV(ICES1);&#xA;  //Serial.println(&quot;Inter&quot;);&#xA; bit_time = ICR1;&#xA;&#xA; //resetTimer1&#xA; TCNT1 = 0;&#xA;&#xA;if ((bit_time &amp;lt; one_time_min) || (bit_time &amp;gt; zero_time_max)) // get rid of anything way outside the norm&#xA; {&#xA;   //Serial.println(bit_time, DEC);&#xA;   total_bits = 0;&#xA; }&#xA; else&#xA; {&#xA;   if (ones_bit_count == true) // only count the second ones pluse&#xA;     ones_bit_count = false;&#xA;   else&#xA;   {    &#xA;     if (bit_time &amp;gt; zero_time_min)&#xA;     {&#xA;       current_bit = 0;&#xA;       sync_count = 0;&#xA;     }&#xA;     else //if (bit_time &amp;lt; one_time_max)&#xA;     {&#xA;       ones_bit_count = true;&#xA;       current_bit = 1;&#xA;       sync_count++;&#xA;       if (sync_count == 12) // part of the last two bytes of a timecode word&#xA;       {&#xA;         sync_count = 0;&#xA;         tc_sync = true;&#xA;         total_bits = end_sync_position;&#xA;       }&#xA;     }&#xA;&#xA;     if (total_bits &amp;lt;= end_data_position) // timecode runs least to most so we need&#xA;     {                                    // to shift things around&#xA;       tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;&#xA;       for(int n=1;n&amp;lt;8;n++)&#xA;       {&#xA;         if(tc[n] &amp;amp; 1)&#xA;           tc[n-1] |= 0x80;&#xA;&#xA;         tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;       }&#xA;&#xA;       if(current_bit == 1)&#xA;         tc[7] |= 0x80;&#xA;     }&#xA;     total_bits++;&#xA;   }&#xA;&#xA;   if (total_bits == end_smpte_position) // we have the 80th bit&#xA;   {&#xA;     total_bits = 0;&#xA;     if (tc_sync)&#xA;     {&#xA;       tc_sync = false;&#xA;       valid_tc_word = true;&#xA;     }&#xA;   }&#xA;&#xA;   if (valid_tc_word)&#xA;   {&#xA;     valid_tc_word = false;&#xA;/*&#xA;     timeCode[10] = (tc[0]&amp;amp;0x0F)+0x30;      // frames&#xA;     timeCode[9] = (tc[1]&amp;amp;0x03)+0x30;      // 10's of frames&#xA;     timeCode[8] =  '.';&#xA;     timeCode[7] = (tc[2]&amp;amp;0x0F)+0x30;      // seconds&#xA;     timeCode[6] = (tc[3]&amp;amp;0x07)+0x30;      // 10's of seconds&#xA;     timeCode[5] =  ':';&#xA;     timeCode[4] = (tc[4]&amp;amp;0x0F)+0x30;      // minutes&#xA;     timeCode[3] = (tc[5]&amp;amp;0x07)+0x30;      // 10's of minutes&#xA;     timeCode[2] = ':';&#xA;     timeCode[1] = (tc[6]&amp;amp;0x0F)+0x30;      // hours&#xA;     timeCode[0] = (tc[7]&amp;amp;0x03)+0x30;      // 10's of hours&#xA;*/&#xA;&#xA;         timeCode[9] = ((tc[0]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 8&#xA;       timeCode[8] = ((tc[1]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 7&#xA;       timeCode[7] = ((tc[2]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 6&#xA;       timeCode[6] = ((tc[3]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 5&#xA;       timeCode[5] = '-';&#xA;       timeCode[4] = ((tc[4]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 4&#xA;       timeCode[3] = ((tc[5]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 3&#xA;       timeCode[2] = '-';&#xA;       timeCode[1] = ((tc[6]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 2  &#xA;       timeCode[0] = ((tc[7]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30; // user bits 1&#xA;&#xA;       drop_frame_flag = bit_is_set(tc[1], 2);&#xA;&#xA;     write_tc_out = true;&#xA;   }&#xA; }&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; pinMode(8, INPUT);                  // ICP pin (digital pin 8 on arduino) as input&#xA;&#xA; bit_time = 0;&#xA; valid_tc_word = false;&#xA; ones_bit_count = false;&#xA; tc_sync = false;&#xA; write_tc_out = false;&#xA; drop_frame_flag = false;&#xA; total_bits =  0;&#xA; current_bit =  0;&#xA; sync_count =  0;&#xA;&#xA; Serial.println(&quot;Finished setup &quot;);&#xA; delay (1000);&#xA;&#xA; TCCR1A = B00000000; // clear all&#xA; TCCR1B = B11000010; // ICNC1 noise reduction + ICES1 start on rising edge + CS11 divide by 8&#xA; TCCR1C = B00000000; // clear all&#xA; TIMSK1 = B00100000; // ICIE1 enable the icp&#xA;&#xA; TCNT1 = 0; // clear timer1&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (write_tc_out)&#xA;   {&#xA;     write_tc_out = false;&#xA;     //if (drop_frame_flag)&#xA;       //Serial.print(&quot;TC-[df] &quot;);&#xA;     //else&#xA;       //Serial.print(&quot;TC-[nd] &quot;);&#xA;     Serial.print((char*)timeCode);&#xA;     //Serial.print(&quot;\r&quot;);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am generating LTC audio from &lt;a href=&quot;http://elteesee.pehrhovey.net/&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt;. On running my code I am getting this output:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Finished setup&#xA;?&amp;gt;-00-0000??-??-77=??&amp;gt;-??-;?????-??-?&amp;gt;???&amp;gt;-:?-=????&amp;gt;-??-?=???&amp;gt;-;=-??5&amp;gt;?&amp;gt;-;=-??=7?&amp;gt;-?;-??=&amp;gt;?&amp;gt;-?:-??=7?&amp;gt;-;=-??&amp;gt;??&amp;gt;-;;-??=7??-?=-=7?&amp;gt;?&amp;gt;-&amp;gt;7-?????&amp;gt;-;;-??=7?&amp;gt;-;&amp;gt;-&amp;gt;??:??-?=-7????&amp;gt;-;?-??5&amp;gt;?&amp;gt;-;?-?=?&amp;gt;??-?=-?7&amp;gt;??&amp;gt;-7:-?67=?&amp;gt;-;?-???5?&amp;gt;-;=-7?==?&amp;gt;-;;-??=7?&amp;gt;-7=-??&amp;gt;&amp;gt;?&amp;gt;-:?-7????&amp;gt;-;=-?;;=??-?=-&amp;gt;?=5?&amp;gt;-;=-???=?&amp;gt;-;?-?=5&amp;gt;??-?;-&amp;gt;=???&amp;gt;-?&amp;gt;-7&amp;gt;;???-?;-&amp;gt;????&amp;gt;-;?-?7=??&amp;gt;-;&amp;gt;-??&amp;gt;;?&amp;gt;-;=-;?5&amp;gt;?&amp;gt;-??-=7;7?&amp;gt;-;=-;?=??&amp;gt;-;=-??=7?&amp;gt;-;=-??:??&amp;gt;-&amp;gt;7-=?????-?7-=?&amp;gt;&amp;gt;?&amp;gt;-?6-??;&amp;gt;?&amp;gt;-7;-???=?&amp;gt;-??-;=???&amp;gt;-;=-?7=7?&amp;gt;-?=-??&amp;gt;;?&amp;gt;-:?-&amp;gt;??&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, can anyone one tell me where is mistake.&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorUserId="19515" LastEditDate="2016-06-15T16:18:25.660" LastActivityDate="2016-06-16T11:58:10.163" Title="Random output on decoding time from LTC audio using arduino UNO" Tags="|arduino-uno|time|audio|sound|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25283" PostTypeId="2" ParentId="8382" CreationDate="2016-06-15T11:42:47.963" Score="0" Body="&lt;p&gt;In the meantime a student has made a really impressive implementation, that might answer your question: &lt;a href=&quot;http://thenextweb.com/gadgets/2016/04/28/interactive-tennis-table-help-step-ping-pong-game/&quot; rel=&quot;nofollow&quot;&gt;interactive tennis table&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T11:42:47.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25285" PostTypeId="2" ParentId="24937" CreationDate="2016-06-15T12:05:59.227" Score="1" Body="&lt;p&gt;I think you should better read about the &lt;a href=&quot;https://www.arduino.cc/en/Reference/StringObject&quot; rel=&quot;nofollow&quot;&gt;String Object&lt;/a&gt; and don't mix this up with &lt;a href=&quot;https://www.arduino.cc/en/Reference/String&quot; rel=&quot;nofollow&quot;&gt;string as char array&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T12:05:59.227" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25286" PostTypeId="2" ParentId="25282" CreationDate="2016-06-15T12:20:51.913" Score="1" Body="&lt;pre&gt;&lt;code&gt;((tc[0]&amp;amp;0xF0)&amp;gt;&amp;gt;4)+0x30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will generate values in the range x30 to x3F, which are 0 to 9 :;&amp;lt;=&gt;?&#xA;This is what you are seeing in you output (because you are adding in x2D '-')&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you are expecting to see, but as far as I can tell there are no mistakes and your code is working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are trying to turn tc[0] into a hex digit then I would use this function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char ToHex (const char input)&#xA;{&#xA;    char output = '0';&#xA;    if (input &amp;gt; 9)&#xA;    { &#xA;        output = (input - 10) + 'A';&#xA;    }&#xA;    else&#xA;    {&#xA;        output = input + '0';&#xA;    }&#xA;    return output;&#xA;}&#xA;char TCToHex (const char input)&#xA;{&#xA;    return ToHex(((input &amp;amp; 0xF0) &amp;gt;&amp;gt; 4));&#xA;}&#xA;char* CharToHex(const char input, char buffer[3])&#xA;{&#xA;    buffer[0] = ToHex((input &amp;amp; 0xF0) &amp;gt;&amp;gt; 4);&#xA;    buffer[1] = ToHex((input &amp;amp; 0x0F));&#xA;    buffer[2] = '\0'; // Always null terminate a string&#xA;    return buffer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what you will get if you call the functions is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char buffer[3];&#xA;printf(&quot;CharToHex 0x%s\n&quot;, CharToHex('A', buffer));  //0x41 65 in decimal, ASCII A&#xA;printf(&quot;TCToHex = 0x%c \n&quot;, TCToHex(0x50)); // 5, because this function only takes the high nibble.&#xA;printf(&quot;ToHex = 0x%c \n&quot;, ToHex(0x0f)); // F&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2016-06-16T11:58:10.163" LastActivityDate="2016-06-16T11:58:10.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25288" PostTypeId="2" ParentId="14361" CreationDate="2016-06-15T12:31:21.193" Score="0" Body="&lt;p&gt;Yes you are right!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile i finished this project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was with the Wi-Fi shield that I was using. The Http request wasn't in a right format. &lt;/p&gt;&#xA;" OwnerUserId="11914" LastActivityDate="2016-06-15T12:31:21.193" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25289" PostTypeId="2" ParentId="23884" CreationDate="2016-06-15T12:31:53.727" Score="1" Body="&lt;p&gt;You need additional hardware like a RTC for example an &lt;a href=&quot;https://www.adafruit.com/product/264&quot; rel=&quot;nofollow&quot;&gt;DS1307&lt;/a&gt; or on the other hand an arduino/shield with ethernet or wifi so you could get the time by &lt;a href=&quot;https://en.wikipedia.org/wiki/Network_Time_Protocol&quot; rel=&quot;nofollow&quot;&gt;NTP&lt;/a&gt; another option might be DCF77 time via the air - sorry forgot GPS could also be used to get the time .... the rest then should be simple creating a string.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T12:31:53.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25290" PostTypeId="2" ParentId="25270" CreationDate="2016-06-15T12:37:37.580" Score="1" Body="&lt;p&gt;This seems way too complex for your purpose:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;you really do not need to do anything to stay in the same state&lt;/li&gt;&#xA;&lt;li&gt;if you want to switch the valve ON, no need to check whether it's OFF:&#xA;there is no harm in switching ON a valve that is already ON.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is a simplified version of the program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    Serial.println(&quot;Type '0' to turn OFF, '1' to turn ON&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int command = Serial.read();&#xA;    if (command == '0') digitalWrite(53, LOW);&#xA;    if (command == '1') digitalWrite(53, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that &lt;code&gt;Serial.read()&lt;/code&gt; returns -1 if there is nothing in the input&#xA;buffer, and since -1 is neither '0' nor '1', this will not change the&#xA;output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use more elaborate commands (not single characters), you&#xA;may want to take a look at this &lt;a href=&quot;https://gist.github.com/edgar-bonet/607b387260388be77e96&quot; rel=&quot;nofollow&quot;&gt;simple command-line&#xA;interpreter&lt;/a&gt;. It is intended to be easy to adapt to&#xA;different purposes.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-15T13:25:10.337" LastActivityDate="2016-06-15T13:25:10.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25292" PostTypeId="2" ParentId="18143" CreationDate="2016-06-15T12:53:48.043" Score="1" Body="&lt;p&gt;Install the latest Arduino IDE with windows administrator rights.&lt;/p&gt;&#xA;" OwnerUserId="22997" LastActivityDate="2016-06-15T12:53:48.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25295" PostTypeId="1" CreationDate="2016-06-15T13:28:37.853" Score="1" ViewCount="5870" Body="&lt;p&gt;I am a newbie to arduino programming. I wish to send big strings which are in range of 100 to 1000 characters to my arduino uno. I saw that arduino cannot read more than 63 characters at a time.&#xA;&lt;p&gt;&#xA;The strings can be received in parts (~40 characters) which will be processed by my program and few minutes later they will get deleted. Then another ~40 characters will be received and the process continues till all the characters are received.&#xA;&lt;p&gt;&#xA;Can you please help me with this. If the question is not clear, you're free to ask in the comments. Thanks in advance :-)&lt;/p&gt;&#xA;" OwnerUserId="23056" LastActivityDate="2016-06-15T14:37:27.580" Title="how to send large strings (&gt; 100 characters) from arduino serial monitor" Tags="|arduino-uno|serial|sketch|string|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25296" PostTypeId="2" ParentId="25295" CreationDate="2016-06-15T14:37:27.580" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I saw that arduino cannot read more than 63 characters at a time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not strictly true. The Arduino core HardwareSerial library has a 64 byte buffer, so it can only &lt;em&gt;buffer&lt;/em&gt; up to 64 characters. If your sketch is reading the characters from the buffer whilst you are sending the characters from your PC then that limit is irrelevant. As long as you are reading the characters as fast as they are coming in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial is actually quite slow (on the scale of things) and unless you're doing silly things like using &lt;code&gt;delay()&lt;/code&gt; or long blocking loops, then reading the data fast enough is not that big a problem.  If you do need more time the simplest way is just to slow down the serial data somewhat - i.e., use a lower baud rate. The slower you send the data the longer you get between each character arrives to do things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For strings the size you are on about you are probably best off processing the data on the fly rather than storing it all then post-processing it - simply because the Arduino doesn't have much RAM, so storing large strings isn't always an option.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-15T14:37:27.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25298" PostTypeId="1" AcceptedAnswerId="25300" CreationDate="2016-06-15T14:50:52.300" Score="1" ViewCount="8673" Body="&lt;p&gt;I found the .toFloat() but that's not accurate enough.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String StrEx = &quot;57.10598&quot;;&#xA;float FloatEx = StrEx.toFloat();&#xA;&#xA;Serial.println(String(FloatEx)); //outputs 57.11&#xA;Serial.println(StrEx);           //outputs 57.10598&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16897" LastEditorUserId="16897" LastEditDate="2016-06-15T14:52:21.997" LastActivityDate="2016-06-15T15:00:24.860" Title="How to convert String to Double?" Tags="|string|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25299" PostTypeId="1" AcceptedAnswerId="25301" CreationDate="2016-06-15T14:59:04.183" Score="0" ViewCount="371" Body="&lt;p&gt;I am performing basic analogue read like temperature and LDR, reading the data serially, but I would like to deploy it online to cloud platforms like (Plotly, Xively, ThingSpeak, or DataSparkFun). Is that feasible? Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-06-15T15:02:51.000" Title="Arduino Data to Cloud without shield []" Tags="|arduino-uno|shields|datalogging|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25300" PostTypeId="2" ParentId="25298" CreationDate="2016-06-15T15:00:24.860" Score="2" Body="&lt;p&gt;It is a common misconception that, because when you print a float you only get 2 decimal places, that the float only has 2 decimal places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is not true. A float doesn't have a number of decimal places - that is how it gets its name - floating point: the decimal point floats around as needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is actually that, by default, all the Arduino print and string conversion functions are set to 2 decimal places. Unless you specify the number of decimal places you want to print (or convert to) you get 2 decimal places.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By specifying 5 decimal places when you print or convert to a string you get 5 decimal places.  It still won't always give you exactly the same number, but that is because a 32-bit float cannot store all possible numbers, so some are only an approximation. It's still a whole lot more accurate than 57.10598 -&gt; 57.11 though.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-15T15:00:24.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25301" PostTypeId="2" ParentId="25299" CreationDate="2016-06-15T15:02:51.000" Score="1" Body="&lt;p&gt;Without a shield? Yes, it's possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You send it serially to your computer as you are doing now. Then you write some software for your computer to read that data serially and send it on to your chosen web service.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can the Arduino magically send data to the internet by itself without you investing in a network connection of some form (WiFi shield, Ethernet Shield, etc)? No, of course not. If it could there would be no market for the network shields, and so they wouldn't exist.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-15T15:02:51.000" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25302" PostTypeId="1" CreationDate="2016-06-15T15:08:46.693" Score="3" ViewCount="1076" Body="&lt;p&gt;I'm trying to save power by putting my device to sleep once it has run through the code once and turn it back on every 33 milliseconds. So basically, if the code finishes executing in 20 milliseconds the device can go to sleep for the remaining 13 milliseconds and it will be turned on by the interupt which is set to go off every 33 milliseocnds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;a href=&quot;https://www.arduino.cc/en/Reference/AttachInterrupt&quot; rel=&quot;nofollow&quot;&gt;documentation&lt;/a&gt; an interrupt is based on a change to the pin state, but I'm sure there must be a way to base it on time. If there isn't then is there a way to set the total time that a device sleeps? The sleep function seemed to just turn the device off, but can it be given a parameter to just turn off for a certain amount of time?&lt;/p&gt;&#xA;" OwnerUserId="22875" LastActivityDate="2016-11-13T17:45:45.930" Title="Is there a way to set an interrupt to go off after a certain period of time?" Tags="|arduino-mega|sleep|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25303" PostTypeId="2" ParentId="25302" CreationDate="2016-06-15T15:12:09.827" Score="0" Body="&lt;p&gt;There are many many kinds of interrupt. External interrupts (of the kind you use with &lt;code&gt;attachInterrupt()&lt;/code&gt;) are but one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Almost every internal peripheral in the AVR chip can generate an interrupt (or multiple interrupts in some cases). One of the most useful is the &lt;em&gt;timer interrupt&lt;/em&gt; which is triggered by one of the timers when its timer has overflowed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not familiar with the AVR's sleep mechanisms, but I would assume a timer interrupt can wake it from sleep - assuming the timer can run while sleeping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should check the documentation for the chip on your Arduino rather than relying on the (somewhat scant and basic, and often misleading) documentation on the Arduino website when it comes to doing anything low-level like this.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-15T15:12:09.827" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25304" PostTypeId="2" ParentId="25302" CreationDate="2016-06-15T15:53:00.953" Score="1" Body="&lt;p&gt;The easiest way to achieve your purpose seems to be to configure a&#xA;timer to fire every 33&amp;nbsp;ms, and use this interrupt to wake up the&#xA;MCU. For this, you first have to choose what timer to use. On the Mega, I&#xA;would rather use the 16-bit timer, but the ATtiny85 only has 8-bit&#xA;timers. Next you have to choose a prescaler value (clock frequency&#xA;division) among those available for that timer. The prescaler should be&#xA;large enough to avoid overflowing your timer, but smaller prescaler&#xA;values give better time resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you configure the timer to run in “CTC mode” (clear timer on&#xA;compare match). In this mode, it counts from zero to the value that you&#xA;programmed in the &lt;code&gt;OCRxA&lt;/code&gt; register (where &lt;code&gt;x&lt;/code&gt; is the number identifying&#xA;the timer), and then goes back to zero. This way you can get an&#xA;interrupt every &lt;code&gt;OCRxA + 1&lt;/code&gt; timer cycles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the example code below, you have to replace &lt;code&gt;x&lt;/code&gt; with the appropriate&#xA;timer number, and check the datasheet for the bits to set in the control&#xA;registers &lt;code&gt;TCCR*&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;&#xA;// Interrupt period, in prescaled clock cycles.&#xA;const uint16_t PERIOD = ...;  // or uint8_t for an 8-bit timer.&#xA;&#xA;// The timer interrupt is used ONLY to wake the CPU, so there is no job&#xA;// to be done inside the interrupt service routine.&#xA;EMPTY_INTERRUPT(TIMERx_COMPA_vect);&#xA;&#xA;void setup()&#xA;{&#xA;    // Disable Timer 0 interrupts.&#xA;    // Warning: this will prevent the Arduino from keeping time.&#xA;    TIMSK0 = 0;&#xA;&#xA;    // Configure Timer x.&#xA;    TCCRxA = 0;            // undo the timer config done...&#xA;    TCCRxB = 0;            // ...by the Arduino core library&#xA;    TCNTx = 0;             // reset the timer&#xA;    OCRxA = PERIOD - 1;    // set the period&#xA;    TIMSKx = _BV(OCIExA);  // enable TIMERx_COMPA interrupt&#xA;    TCCRxA = ...;          // set the counting mode to CTC...&#xA;    TCCRxB = ...;          // ...and set the prescaler&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Sleep while waiting for the timer interrupt.&#xA;    sleep_mode();&#xA;&#xA;    // Now that we have been waken up...&#xA;    do_the_job();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: As noticed by Gerben, the Arduino core library configures&#xA;Timer&amp;nbsp;0 to send periodic interrupts (one every 1024&amp;nbsp;µs), which&#xA;are used for timekeeping (&lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt; and co.). This&#xA;interrupts will wake up the MCU and prevent it from sleeping as long as&#xA;you want. The simplest solution, which is implemented in the code above,&#xA;is to disable the Timer&amp;nbsp;0 interrupts. The drawback is that the&#xA;Arduino timekeeping functions will not work anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need those timekeeping functions, then the proper solution is the&#xA;one sketched by Gerben in his comment: set a boolean in the interrupt&#xA;that can be checked in the main loop. Here is the naive implementation&#xA;of this idea: &lt;code&gt;EMPTY_INTERRUPT(TIMERx_COMPA_vect);&lt;/code&gt; is replaced by&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;volatile bool time_elapsed;&#xA;&#xA;ISR(TIMERx_COMPA_vect)&#xA;{&#xA;    time_elapsed = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, in the main loop you sleep repeatedly until the ISR sets the flag:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    // Warning: race condition here!&#xA;    while (!time_elapsed)&#xA;        sleep_mode();&#xA;    time_elapsed = false;&#xA;&#xA;    // Now that we have been waken up...&#xA;    do_the_job();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As stated in the comment, this naive implementation suffers from what is&#xA;known as a &lt;em&gt;race condition&lt;/em&gt;. The problem is in the following scenario:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The main loop reads the value of &lt;code&gt;time_elapsed&lt;/code&gt; and it turns out to&#xA;be false&lt;/li&gt;&#xA;&lt;li&gt;At this point the interrupt fires and the ISR sets that boolean to&#xA;&lt;code&gt;true&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Returning from the ISR, the main loop does not test the flag again&#xA;(since it just did it) and goes straight to &lt;code&gt;sleep_mode();&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;At this point the MCU ends up sleeping although it should be performing&#xA;the job which is due now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This race condition may not a be a big deal to you: The MCU will be&#xA;eventually woken up by the Timer&amp;nbsp;0 interrupt no more than 1024&amp;nbsp;µs&#xA;later. In some cases it &lt;em&gt;is&lt;/em&gt; an issue, but fortunately there is a proper&#xA;solution. It is described in the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html&quot; rel=&quot;nofollow&quot;&gt;page about sleeping of the avr-libc&#xA;documentation&lt;/a&gt;. It relies on the fact that when interrupts are&#xA;disabled, then enabled again with &lt;code&gt;sei()&lt;/code&gt;, the machine instruction right&#xA;after the &lt;code&gt;sei()&lt;/code&gt; is guaranteed to be executed before any interrupt is&#xA;serviced. Then the proper way to test the flag and sleep is:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    while (!time_elapsed) {&#xA;        cli();&#xA;        if (!time_elapsed) {&#xA;            sleep_enable();&#xA;            sei();          // interrupts enabled&#xA;            sleep_cpu();    // this will be executed before any ISR&#xA;            sleep_disable();&#xA;        }&#xA;        sei();&#xA;    }&#xA;    time_elapsed = false;&#xA;&#xA;    // Now that we have been waken up...&#xA;    do_the_job();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this version, if the interrupt fires right after the test&#xA;&lt;code&gt;if (!time_elapsed)&lt;/code&gt;, it will be serviced &lt;em&gt;after&lt;/em&gt; &lt;code&gt;sleep_cpu()&lt;/code&gt;, which&#xA;will have the effect of waking the MCU right away.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-07-16T12:58:41.633" LastActivityDate="2016-07-16T12:58:41.633" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25305" PostTypeId="1" CreationDate="2016-06-15T16:02:41.743" Score="2" ViewCount="302" Body="&lt;p&gt;I have encountered this several times before and I would like it if someone was able to give an explanation. In almost any sketch that I've ever created with Serial communication involved, I notice that I will get text that seemingly appears before the void setup() function has run. For example, I have the simplest sketch below where this occurs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(){&#xA;// put your setup code here, to run once:&#xA;Serial.begin(9600);&#xA;Serial.println(&quot;Welcome&quot;);&#xA;}&#xA;&#xA;void loop(){&#xA;// put your main code here, to run repeatedly:&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I upload this to one of my Arduino Megas, I will often get the output in the serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WelcWelcome&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I open the serial monitor to view the output, the &quot;Welc&quot; is already written and then the rest of the &quot;Welcome&quot; come in a few moments later. If I close and re-open the serial monitor or reselect the baudrate setting within the serial monitor, the serial monitor clears, restarting the Arduino, and printing only &quot;Welcome&quot; to the screen without the &quot;Welc&quot;, as I would expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if I upload the sketch, then disconnect-reconnect the Arduino-USB cable from the computer, and open the serial monitor, there is no leftover bytes printed to the screen like before.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exact bytes leftover that appear before the void setup() function is called varies from upload to upload. Can anyone give me an explanation and is there a way to avoid the leftover bytes ? Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2017-09-16T18:25:07.640" Title="Why is there already text in the serial monitor before the Arduino initializes?" Tags="|serial|arduino-mega|usb|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25306" PostTypeId="2" ParentId="25305" CreationDate="2016-06-15T16:18:45.010" Score="5" Body="&lt;p&gt;It's because the Arduino has started running the sketch and placed data into the USB chip's buffer. You then open the serial monitor which then opens the serial port thus resetting the Arduino. So the sketch runs again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It only resets the Arduino, not the USB interface chip, so you get what was in there from the first execution plus the new text from the second (post-opening) execution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot &quot;avoid&quot; the extra bytes, that's just the way things are. The Arduino resets. There are buffers in various places. You have no control over those buffers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a side note: the serial monitor is completely disgusting. If you want to do things properly use a proper terminal emulator, then you can use ANSI control codes to do things like clear the screen, move the cursor around, apply colour, etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-15T16:18:45.010" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25307" PostTypeId="1" CreationDate="2016-06-15T17:09:04.980" Score="2" ViewCount="462" Body="&lt;p&gt;I'm working on a project that detects the pulse width of an audio signal, which uses a microphone as an input. The user gives 2 different types of sounds one last less 0.3 seconds and other lasting less than 0.7 seconds. I've attached the audio visualisation of the signal pic in the attachment.&#xA;All want to detect is their pulse widths. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried Pulsein() - but as you can see that it has a variable until 0.3 or 0.7 seconds it only detect the first and most peak and returns the value which is almost zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But all I need is the total time taken for the pulse to rise from 0 and to variate and then become 0 this total time period is what I require.&#xA;would duty cycle help ? or any other functions available to detect two different sounds in arduino ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/U0XQK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/U0XQK.jpg&quot; alt=&quot;Audio visualization&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B8TRhtqczb3_bFJiOFNadEx5T3M&quot; rel=&quot;nofollow noreferrer&quot;&gt;pulse width&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21025" LastEditorUserId="10794" LastEditDate="2016-08-14T21:02:58.763" LastActivityDate="2017-08-11T13:56:41.650" Title="How to detect the pulse width from microphone as Input?" Tags="|arduino-uno|pwm|audio|" AnswerCount="1" CommentCount="3" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25309" PostTypeId="2" ParentId="25307" CreationDate="2016-06-15T17:40:31.390" Score="1" Body="&lt;p&gt;You will need some sort of interface circuit between your mic and your&#xA;Arduino. Best would probably be to have some kind of external peak&#xA;detection. This way the Arduino reads instantaneous wave amplitude. The&#xA;other option is to only shift and scale the signal so that it fits the&#xA;Arduino ADC, acquire the signal at a high enough sampling rate, and&#xA;compute the instantaneous amplitude in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suggest you take a look at this &lt;a href=&quot;https://gist.github.com/edgar-bonet/e693799f58a545ca89a2&quot; rel=&quot;nofollow&quot;&gt;sound-meter program&lt;/a&gt;. You could use&#xA;it as a basis for your own processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you just have to define a threshold and time how long the amplitude&#xA;remains above that threshold.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-15T17:40:31.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25311" PostTypeId="1" CreationDate="2016-06-15T20:32:05.203" Score="1" ViewCount="595" Body="&lt;p&gt;I have the following program which is supposed to print the words &quot;Program is on&quot; once and then go to sleep. However it doesn't go to sleep and continues to print &quot;Program is on&quot; over and over again.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;Program is on&quot;);&#xA;  sleepNow();&#xA;}&#xA;&#xA;void sleepNow()&#xA;{&#xA;  // Choose our preferred sleep mode:&#xA;  set_sleep_mode(SLEEP_MODE_IDLE);&#xA;  // Set sleep enable (SE) bit:&#xA;  sleep_enable();&#xA;  // Put the device to sleep:&#xA;  sleep_mode();&#xA;  // Upon waking up, sketch continues from this point.&#xA;  sleep_disable();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23008" LastActivityDate="2016-06-15T23:27:21.933" Title="Why does this not put my Arduino Mega to sleep?" Tags="|arduino-mega|sleep|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25313" PostTypeId="2" ParentId="13299" CreationDate="2016-06-15T22:23:31.123" Score="1" Body="&lt;p&gt;I solved this problem.  Maybe this post will help others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've come across this problem a couple of times.  I literally searched for hours for the answer and ended up using several suggestions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both scenarios I solved are documented below as 'Scenario A' and 'Scenario B':&lt;/p&gt;&#xA;&#xA;&lt;p&gt;======================&#xA;Scenario A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plugged in a new Arduino Uno R3 board, successfully compiled the standard &quot;Blink&quot; sketch.  When I tried to upload it to the board, I got this message:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Sketch uses 1,066 bytes (3%) of program storage space. Maximum is 32,256 bytes. Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes. avrdude: ser_open(): can't open device &quot;COM1&quot;: No such file or directory ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device Problem uploading to board.  See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Port Options in the IDE (Tools--&gt; Port) only showed  /dev/cu.incoming-bluetooth-port&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what worked:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Downloaded and &lt;a href=&quot;http://www.wch.cn/download/CH341SER_MAC_ZIP.html&quot; rel=&quot;nofollow&quot;&gt;Installed the CH340 driver&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Removed the FTDI drivers from my mac.  Apple recently installed a new utility that prevents removal of what it considers to be critical components.  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The process that enforces this rule is called csrutil.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll have to disable this process to remove the FTDI driver.  Then you'll need to re-enable it when you are done.  This required a restart in recovery mode.  Here's how to do that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;a.)  power off the mac then hold 'command'+R during the restart until the image of the apple appears.&#xA;b.)  when the screen refreshes, click on 'Utilities' menu then 'Terminal.&#xA;c.)  type csrutil disable&#xA;d.)  Hit enter&#xA;e.)  Restart  [Note:  You may be able to execute the next two commands in the terminal before restarting.  I just didn't test it that way.  If the system will allow you to, then by all means run all three commands one after the other THEN restart and you should be on your way.]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;remove the FTDI drivers by opening the terminal program again and entering the following command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;   sudo rm -R /System/Library/Extensions/AppleUSBFTDI.kext&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Type in your password when prompted.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;4&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Restore the apple csrutil by following steps a and b above.  Task c will be the same EXCEPT you'll type this instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;csrutil enable&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then follow steps d and e.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When you restart the arduino IDE, you should see a more comprehensive list of ports besides just the bluetooth port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;======================&#xA;Scenario B&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This board was an import and clearly not an original Arduino/Genuino.  Attempts to load sketches resulted in this lovely error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Using Port                    : /dev/cu.usbmodem1421&#xA;    Using Programmer              : arduino&#xA;    Overriding Baud Rate          : 115200&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;avrdude: ser_open(): can't open device &quot;/dev/cu.usbmodem1421&quot;: No such file or directory&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There was only one Port listed in the IDE, dev/cu.Bluetooth-Incoming-Port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It had been a while since Scenario A had occurred and since then I'd installed a few OS updates.  Checked the drivers and low and behold, the darned FTDI drivers had RETURNED!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I repeated the steps in scenario A above but the problem remained.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I installed an updated board configuration from arduino and it worked!  Testing on the first board I'd used under scenario A were successful as well.  Here's what I did:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;In the IDE go to Tools-&gt; Boards -&gt; Boards Manager&lt;/li&gt;&#xA;&lt;li&gt;I installed 'Arduino SAM Boards (32-bits ARM Cortex-M3) by Arduino version 1.6.8&lt;/li&gt;&#xA;&lt;li&gt;Unplugged and replugged the USB cable into my arduino.&lt;/li&gt;&#xA;&lt;li&gt;In the IDE go to Tools -&gt; Port.  The /dev/cu.usbmodem1421 was listed as a port option.  Selected that.&lt;/li&gt;&#xA;&lt;li&gt;Uploaded my sketch.&lt;/li&gt;&#xA;&lt;li&gt;Bask in glory of SUCCESS!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I hope this was helpful to you.  I spent two days on Scenario A and 3 hours on Scenario B.&lt;/p&gt;&#xA;" OwnerUserId="23024" LastActivityDate="2016-06-15T22:23:31.123" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25314" PostTypeId="2" ParentId="25311" CreationDate="2016-06-15T23:27:21.933" Score="1" Body="&lt;p&gt;In idle sleep, the timer interrupts will wake the processor, as  Ignacio Vazquez-Abrams said in his comment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A &quot;higher&quot; sleep mode works, however I had to add &lt;code&gt;Serial.flush ()&lt;/code&gt; otherwise it only printed &quot;P&quot; because the processor goes to sleep before the serial output buffer has been emptied.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;Program is on&quot;);&#xA;  Serial.flush ();&#xA;  sleepNow();&#xA;}&#xA;&#xA;void sleepNow()&#xA;{&#xA;  // Choose our preferred sleep mode:&#xA;  set_sleep_mode(SLEEP_MODE_PWR_SAVE);&#xA;  // Set sleep enable (SE) bit:&#xA;  sleep_enable();&#xA;  // Put the device to sleep:&#xA;  sleep_mode();&#xA;  // Upon waking up, sketch continues from this point.&#xA;  sleep_disable();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;my page about power savings&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-15T23:27:21.933" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25315" PostTypeId="1" AcceptedAnswerId="25324" CreationDate="2016-06-16T00:30:27.910" Score="0" ViewCount="2732" Body="&lt;p&gt;I'm struggling with this issue that I can seem to get around of.&#xA; When defining a vector class, I'm seeming to get some issues when deleting the allocated pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oddly enough, this only happens after I &quot;read&quot; the memory. What I mean by this is that if I push back a series of values to the vector, they seem to stay there. But once I read the values, the data pointer seems to become invalid of some sort so I crash when trying to deallocate it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef VECTOR_H&#xA;#define VECTOR_H&#xA;&#xA;#include &amp;lt;string.h&amp;gt;     /* memcpy */&#xA;&#xA;#define min(a,b) (a &amp;lt; b) ? a : b&#xA;&#xA;template &amp;lt;typename T&amp;gt;&#xA;class vector {&#xA;public:&#xA;    vector() : __capacity(0), __count(0), __data(0) {} //empty constructor&#xA;    vector(T obj, int count = 1) {&#xA;&#xA;        if (this-&amp;gt;__data) { // free data ptr if used&#xA;            delete this-&amp;gt;__data;&#xA;        }&#xA;&#xA;        this-&amp;gt;__data = new T[count];&#xA;        this-&amp;gt;__count = count;&#xA;        this-&amp;gt;__capacity = count;&#xA;&#xA;        for (int i = 0; i &amp;lt; count; i++) //populate array with given object&#xA;            this-&amp;gt;__data[i] = obj;&#xA;&#xA;    }&#xA;&#xA;    ~vector() {&#xA;&#xA;        if (this-&amp;gt;__data) { // free data ptr if used&#xA;            delete [] this-&amp;gt;__data;&#xA;        }&#xA;&#xA;        this-&amp;gt;__count = this-&amp;gt;__capacity = 0;&#xA;    }&#xA;&#xA;    T const &amp;amp; operator[] (unsigned int idx) const {&#xA;        if (idx &amp;lt; this-&amp;gt;__count) {&#xA;            return this-&amp;gt;__data[idx];&#xA;        }&#xA;        else {&#xA;            // throw exception or handle error to be implemented&#xA;        }&#xA;    }&#xA;&#xA;    T&amp;amp; operator[] (unsigned int idx) {&#xA;        if (idx &amp;lt; this-&amp;gt;__count) {&#xA;            return this-&amp;gt;__data[idx];&#xA;        }&#xA;        else {&#xA;            // throw exception or handle error to be implemented&#xA;        }&#xA;    }&#xA;&#xA;    void resize_to_fit() {&#xA;        resize(this-&amp;gt;__count);&#xA;    }&#xA;&#xA;    T&amp;amp; pop_back(){&#xA;        return this-&amp;gt;__data[--this-&amp;gt;__count];&#xA;    }&#xA;&#xA;    void push_back(T obj) {&#xA;&#xA;        if (this-&amp;gt;__capacity == this-&amp;gt;__count) {&#xA;            resize(this-&amp;gt;__capacity + 1);&#xA;        }&#xA;&#xA;        this-&amp;gt;__data[this-&amp;gt;__count++] = obj;&#xA;    }&#xA;&#xA;    bool isempty() {&#xA;        return !this-&amp;gt;__data ||&#xA;            !this-&amp;gt;capacity ||&#xA;            !this-&amp;gt;size;&#xA;    }&#xA;&#xA;    void clear() {&#xA;        this-&amp;gt;~vector();&#xA;    }&#xA;&#xA;    T* data() {&#xA;        return this-&amp;gt;__data;&#xA;    }&#xA;&#xA;    int size() {&#xA;        return this-&amp;gt;__count;&#xA;    }&#xA;&#xA;    int capacity() {&#xA;        return this-&amp;gt;__capacity;&#xA;    }&#xA;private:&#xA;    void resize(int capacity) {&#xA;        if (this-&amp;gt;__data == nullptr) {&#xA;            this-&amp;gt;__data = new T[capacity];&#xA;&#xA;            this-&amp;gt;__count = 0;&#xA;            this-&amp;gt;__capacity = capacity;&#xA;        }&#xA;        else if (capacity != this-&amp;gt;__capacity) { //else do nothing&#xA;&#xA;            T* data = new T[capacity];&#xA;&#xA;            this-&amp;gt;__count = min(this-&amp;gt;__count, capacity);&#xA;            this-&amp;gt;__capacity = capacity;&#xA;&#xA;            memcpy(data, this-&amp;gt;__data, sizeof(T) * this-&amp;gt;__count);&#xA;&#xA;            delete this-&amp;gt;__data; //program crashes here, but the pointer is already broken...&#xA;            this-&amp;gt;__data = data;&#xA;        }&#xA;    }&#xA;protected:&#xA;&#xA;        int __capacity;&#xA;        int __count;&#xA;        T* __data;&#xA;&#xA;&#xA;&#xA;};&#xA;#endif//VECTOR_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I was using this code in my Arduino, not sure if it helps &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void print_vec(vector&amp;lt;int&amp;gt; v){&#xA;  Serial.println(&quot;Printing new vec!&quot;);&#xA;  for( int i = 0; i &amp;lt; v.size(); i++){&#xA;    Serial.println(v[i]);&#xA;  }&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;  Serial.begin(9600); // Open serial connection to report values to host&#xA;&#xA;  while(!Serial); //Waiting for serial to open&#xA;&#xA;  vector&amp;lt;int&amp;gt; i = vector&amp;lt;int&amp;gt;();&#xA;&#xA;  i.push_back(10);&#xA;  i.push_back(2);&#xA;  print_vec(i); //prints 10 and 2, perfect so far&#xA;  i.push_back(3);&#xA;&#xA;  while(true){&#xA;    print_vec(i); &#xA;    i.pop_back();&#xA;    delay(2000);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code outputs:&#xA;Printing new vec!&#xA;10&#xA;2&#xA;Printing new vec!&#xA;0&#xA;2&#xA;3&#xA;Printing new vec!&#xA;0&#xA;2&#xA;Printing new vec!&#xA;0&#xA;(...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be causing this? I'm stonewalled for a while now, any insight on how to solve this is appreciated. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="23062" LastActivityDate="2016-06-16T17:13:00.390" Title="Building a Vector class in Arduino" Tags="|programming|c++|vector|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25317" PostTypeId="2" ParentId="25267" CreationDate="2016-06-16T02:41:00.877" Score="2" Body="&lt;h1&gt;Many programmers have a disjoint between a pointer and an array. Here's an explanation.&lt;/h1&gt;&#xA;&lt;h3&gt;Here is a variable of type &lt;code&gt;char&lt;/code&gt;, initialised with the value &lt;code&gt;'A'&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;char c = 'A';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;'A'&lt;/code&gt; has the ASCII value of 65, so that means that there's a byte in memory that holds the value 65. Let's say that byte in memory is at address &lt;code&gt;0x2000&lt;/code&gt;. If you were to add &lt;code&gt;1&lt;/code&gt; to that byte, it would become 66, and if you were to print it as a character, it would print &lt;code&gt;B&lt;/code&gt; (ASCII 66).&lt;/p&gt;&#xA;&lt;h3&gt;Here is a pointer to a &lt;code&gt;char&lt;/code&gt;, initialised with the address in memory of &lt;code&gt;c&lt;/code&gt;:&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;char *p_c = &amp;amp;c; // Get the address of c into p_c&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[Note that &lt;code&gt;char *p_c = c;&lt;/code&gt; would be invalid: you can't initialise a pointer with a &lt;code&gt;char&lt;/code&gt;! That'd give &lt;code&gt;p_c&lt;/code&gt; the value &lt;code&gt;65&lt;/code&gt; - not what you want!]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In Arduino, &lt;code&gt;p_c&lt;/code&gt; represents two successive bytes of memory that together store the address of a &lt;code&gt;char&lt;/code&gt;: in this case the value 0x2000. Where those two bytes are doesn't matter for this explanation - but trust that they too have an address...&lt;/p&gt;&#xA;&lt;p&gt;If you were to change &lt;code&gt;c&lt;/code&gt; into a 'Z', that would change &lt;code&gt;c&lt;/code&gt;'s contents, but not &lt;code&gt;p_c&lt;/code&gt;'s (it would still be &lt;code&gt;0x2000&lt;/code&gt;). But if you were to use &lt;code&gt;p_c&lt;/code&gt; to look at the byte it was pointing to (&lt;code&gt;c&lt;/code&gt;), then you'd see the 'Z'.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If you were to do a &lt;code&gt;printf(&amp;quot;%c&amp;quot;, c);&lt;/code&gt; you'd get a 'Z'.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;%c&lt;/code&gt; means &amp;quot;I've got a character as the next variable in the &lt;code&gt;printf()&lt;/code&gt; list&amp;quot;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;If you were to do a &lt;code&gt;printf(&amp;quot;%c&amp;quot;, *p_c);&lt;/code&gt; you'd also get a 'Z'.&lt;/li&gt;&#xA;&lt;li&gt;If you were to do a &lt;code&gt;printf(&amp;quot;%c&amp;quot;, p_c);&lt;/code&gt; you'd get horrible results.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You lied to &lt;code&gt;printf()&lt;/code&gt; - you didn't give it a one-byte character, you gave it a two-byte pointer!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Now let's move on to arrays.&lt;/p&gt;&#xA;&lt;h3&gt;Here is a variable of type &lt;code&gt;char []&lt;/code&gt;, initialised with the value &lt;code&gt;&amp;quot;John&amp;quot;&lt;/code&gt;.&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;char s[] = &amp;quot;John&amp;quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;'J'&lt;/code&gt; has the ASCII value 74, &lt;code&gt;'o'&lt;/code&gt; 112, &lt;code&gt;'h'&lt;/code&gt; 104, and &lt;code&gt;'n'&lt;/code&gt; 111. That means that in memory there are four sequential bytes with the values 74, 112, 104, 111. Let's say that those bytes are at addresses 0x3000 through 0x3003.&lt;/p&gt;&#xA;&lt;h3&gt;And here is another pointer to &lt;code&gt;char&lt;/code&gt;, this time initialised with the address in memory of &lt;code&gt;s&lt;/code&gt;.&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;char *p_s = s; // Point to s with p_s&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I hate that the C language allows the above. It is one of the roots of the whole array/pointer confusion. It kind-of implies that &lt;code&gt;p_s&lt;/code&gt; somehow gets all of &lt;code&gt;&amp;quot;John&amp;quot;&lt;/code&gt; assigned to it. Nope!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A better statement would have been:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;char *p_s = &amp;amp;s; // Initialise p_s with the address of s // ILLEGAL!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;That gives a MUCH better idea of what's happening - alas, it's not how it's done...&lt;/p&gt;&#xA;&lt;p&gt;But also note that neither of the above could possibly store &lt;code&gt;0x3000-0x3003&lt;/code&gt; (the addresses for all of &lt;code&gt;s&lt;/code&gt;), so they have to be satisfied with only storing the start of the string: &lt;code&gt;p_s&lt;/code&gt; will get the value &lt;code&gt;0x3000&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Note that &lt;code&gt;s&lt;/code&gt; does &lt;strong&gt;NOT&lt;/strong&gt; have the value &lt;code&gt;0x3000&lt;/code&gt; in it. That is its address, like &lt;code&gt;0x2000&lt;/code&gt; was &lt;code&gt;c&lt;/code&gt;'s address (it too doesn't have &lt;code&gt;0x2000&lt;/code&gt; in it). But &lt;code&gt;p_s&lt;/code&gt; &lt;em&gt;does&lt;/em&gt; have &lt;code&gt;0x3000&lt;/code&gt; in it - and don’t forget that &lt;code&gt;p_s&lt;/code&gt; also has its own address (I won't bother with that here).&lt;/p&gt;&#xA;&lt;h3&gt;And this is where the &amp;quot;equivalency&amp;quot; (they're not) between a pointer and an array starts to get people confused:&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;s[2] = 'h';&lt;/code&gt; and &lt;code&gt;p_s[2] = 'h';&lt;/code&gt; do the same thing - but in different ways!&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The first accesses &lt;code&gt;0x3002&lt;/code&gt; directly.&lt;/li&gt;&#xA;&lt;li&gt;The second needs to find out that &lt;code&gt;p_s&lt;/code&gt; is &lt;code&gt;0x3000&lt;/code&gt; and add &lt;code&gt;2&lt;/code&gt; to it before it can access &lt;code&gt;0x3002&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;*(p_s + 2) = 'h';&lt;/code&gt; is yet a third way to do the same thing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So now let's &lt;code&gt;printf()&lt;/code&gt; these new variables:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%c&amp;quot;, *s);&lt;/code&gt; wouldn’t compile.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;s&lt;/code&gt; is not a pointer, so you can’t dereference it with &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%c&amp;quot;, *p_s);&lt;/code&gt; would print the &lt;strong&gt;character&lt;/strong&gt; at where &lt;code&gt;p_s&lt;/code&gt; was pointing.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This would print out &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%c&amp;quot;, s[0]);&lt;/code&gt; would print the &lt;strong&gt;character&lt;/strong&gt; at &lt;code&gt;s[0]&lt;/code&gt;.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This would print out &lt;code&gt;J&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%c&amp;quot;, s);&lt;/code&gt; would give horrible results.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Again, you lied to &lt;code&gt;printf()&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%s&amp;quot;, s);&lt;/code&gt; would work (but see below).&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;%s&lt;/code&gt; means &amp;quot;I've got a sequence of characters that I'd like you to print. I've provided the address of the first character.&amp;quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%s&amp;quot;, p_s);&lt;/code&gt; would be identical to the previous one.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;After all, the same address value was passed!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;printf(&amp;quot;%s&amp;quot;, *p_s);&lt;/code&gt; would give horrible results.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Again, you lied to &lt;code&gt;printf()&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;But note something: you've given &lt;code&gt;printf()&lt;/code&gt; the beginning of the string, so it can start printing. How does &lt;code&gt;printf()&lt;/code&gt; know where the end of the string is? You didn't provide the number &lt;code&gt;4&lt;/code&gt;; it's not stored anywhere; how can it know when to stop?&lt;/p&gt;&#xA;&lt;p&gt;That's where a C convention for strings steps in. By convention, when the compiler sees a string &lt;code&gt;&amp;quot;between quotes&amp;quot;&lt;/code&gt;, it stores the ASCII values of the characters, and &lt;em&gt;then follows them with a &lt;code&gt;0&lt;/code&gt;&lt;/em&gt;. Not an ASCII &lt;code&gt;'0'&lt;/code&gt; (with value 48), but an ASCII &lt;code&gt;NUL&lt;/code&gt; (with value 0). Thus if you looked at address &lt;code&gt;0x3004&lt;/code&gt; (the byte directly after &lt;code&gt;John&lt;/code&gt;), you'd see a 0 in that memory byte. That's how &lt;code&gt;printf()&lt;/code&gt; knows to stop printing - and yes, many a bug has resulted from forgetting to maintain a &lt;code&gt;NUL&lt;/code&gt; at the end of a sequence of chars!&lt;/p&gt;&#xA;&lt;h3&gt;That then leads me to the &lt;code&gt;sizeof()&lt;/code&gt; function&lt;/h3&gt;&#xA;&lt;p&gt;&lt;code&gt;sizeof()&lt;/code&gt; always returns a constant &lt;em&gt;at compile time&lt;/em&gt; using information that the compiler &lt;em&gt;then&lt;/em&gt; knows about:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(c)&lt;/code&gt; would return &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(p_c)&lt;/code&gt; would return &lt;code&gt;2&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(p_s)&lt;/code&gt; would &lt;em&gt;also&lt;/em&gt; return &lt;code&gt;2&lt;/code&gt;.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It is after all merely a pointer too.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(*p_c)&lt;/code&gt; would return &lt;code&gt;1&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(*p_s)&lt;/code&gt; would &lt;strong&gt;also&lt;/strong&gt; return &lt;code&gt;1&lt;/code&gt;.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It's only pointing to a single char...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(s)&lt;/code&gt; would return &lt;code&gt;5&lt;/code&gt;.&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The compiler knows what &lt;code&gt;s&lt;/code&gt; is: an array of &lt;strong&gt;5&lt;/strong&gt; bytes (including the final &lt;code&gt;NUL&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Given a pointer, there is &lt;em&gt;no (native) way&lt;/em&gt; to find out how large the buffer it is pointing to can be.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;OK: so if you've got a &lt;code&gt;char []&lt;/code&gt; you can find out its size. Note that that is its maximum size - the string inside it could be a lot shorter! If you did the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s[3] = 0; // Overwrite the fourth character (arrays start at 0)&#xA;printf(&amp;quot;%s&amp;quot;, s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;[Note a better version of the first line would be &lt;code&gt;s[3] = '\0';&lt;/code&gt; which means &amp;quot;store the ASCII character &lt;code&gt;0&lt;/code&gt; (&lt;strong&gt;NOT&lt;/strong&gt; &lt;code&gt;'0'&lt;/code&gt;)&amp;quot; instead of &amp;quot;store the number &lt;code&gt;0&lt;/code&gt;&amp;quot;.]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;you'd get &lt;code&gt;Joh&lt;/code&gt; printed out. Note:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;sizeof(s)&lt;/code&gt; remains &lt;code&gt;5&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;You can't get the length with &lt;code&gt;sizeof(*p_s)&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;The string inside it is only 3 characters long.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So... if you've got a string buffer, or a pointer to one, how do you know how long it is? Count the number of characters until you reach a &lt;code&gt;NUL&lt;/code&gt; - and there's already a function to do that for you: &lt;code&gt;strlen()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;Which now leads to the final point about pointers: dynamic allocation of memory.&lt;/h3&gt;&#xA;&lt;p&gt;The array &lt;code&gt;s&lt;/code&gt; above was sized by the compiler at compile time: it could count the characters, add one for the &lt;code&gt;NUL&lt;/code&gt;, and reserve the right number of bytes. You could also have written:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;char s[10] = &amp;quot;John&amp;quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which would have reserved 10 bytes and only initialised the first &lt;strong&gt;5&lt;/strong&gt; of them. The following would be an error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;char s[3] = &amp;quot;John&amp;quot;; // Buffer too small!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Scarily, &lt;code&gt;char s[4] = &amp;quot;John&amp;quot;;&lt;/code&gt; works... (The compiler says to itself &amp;quot;No room for the &lt;code&gt;NUL&lt;/code&gt;?! Ah well...”) Better never pass that string to &lt;code&gt;strlen()&lt;/code&gt; or &lt;code&gt;printf()&lt;/code&gt; then!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;What if you don't know at compile time how big a string is going to be? If you know at runtime, you can ask the system for a lump of memory from the heap - a reserved area that can have chunks taken from it and returned as required. There are two ways to do this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;char *p_b = (char *)malloc(size); // Where size is a variable&#xA;char *buffer = new char[size];    // Grab 'size' new chars&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The first calls &lt;code&gt;malloc()&lt;/code&gt;, passing in the number of desired bytes. If &lt;code&gt;malloc()&lt;/code&gt; can give those bytes it will reserve them and return a pointer to them. If it can't it will return &lt;code&gt;0&lt;/code&gt;. You should always test the return value! If not, you'll corrupt things horribly...&lt;/p&gt;&#xA;&lt;p&gt;The second uses the more sophisticated &lt;code&gt;new[]&lt;/code&gt; syntax, which is more object oriented. Notice how &lt;code&gt;malloc()&lt;/code&gt;'s return value needed to be turned into a &lt;code&gt;(char *)&lt;/code&gt;? That's because it doesn't know what type of pointer it's returning, so it just picks &lt;code&gt;void *&lt;/code&gt;. &lt;code&gt;new&lt;/code&gt; does know, so it returns the correct type - but it still may return &lt;code&gt;0&lt;/code&gt; if there's no room!&lt;/p&gt;&#xA;&lt;p&gt;Once you've got either pointer, you use them just like &lt;code&gt;p_s&lt;/code&gt; before. There is nothing stopping you from accessing outside the boundaries of the buffer - just like there isn't for &lt;code&gt;p_s&lt;/code&gt;! Be careful!&lt;/p&gt;&#xA;&lt;p&gt;Oh, and once you've finished with the lump of memory, you need to return it to the heap:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;free(p_b);&#xA;delete [] buffer;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you used &lt;code&gt;malloc()&lt;/code&gt;, return it with &lt;code&gt;free()&lt;/code&gt;. If you used &lt;code&gt;new[]&lt;/code&gt;, return it with &lt;code&gt;delete[]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3&gt;And all of the above is why they invented the &lt;code&gt;String&lt;/code&gt; object.&lt;/h3&gt;&#xA;&lt;p&gt;It manages the memory; keeps track of the string's length; lets you access and modify individual characters; lets you resize the string as needed; and gets rid of the used memory once you're finished with it. No wonder people start to use &lt;code&gt;String&lt;/code&gt; syntax when they see string pointers...&lt;/p&gt;&#xA;&lt;p&gt;But &lt;code&gt;String&lt;/code&gt;s are only useful for &lt;code&gt;char&lt;/code&gt;s. Arrays and pointers can be of and to anything - including &lt;code&gt;String&lt;/code&gt;s and (&lt;em&gt;&lt;strong&gt;GASP!&lt;/strong&gt;&lt;/em&gt;) pointers! Uh oh - here we go again...&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2021-09-02T10:34:39.273" LastActivityDate="2021-09-02T10:34:39.273" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="25320" PostTypeId="2" ParentId="25315" CreationDate="2016-06-16T04:18:18.273" Score="2" Body="&lt;h3&gt;In your second constructor you start with the following code:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (this-&amp;gt;__data) { // free data ptr if used&#xA;    delete this-&amp;gt;__data;&#xA;} // if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is deadly! You've not initialised &lt;code&gt;__data&lt;/code&gt;, so it could hold &lt;em&gt;any&lt;/em&gt; value under the Sun. And there is &lt;em&gt;no way&lt;/em&gt; that it could &lt;em&gt;possibly&lt;/em&gt; be a valid pointer to existing data - it's a brand-new uninitialized object. Returning this garbage pointer to the heap is simply asking for trouble.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Remove those lines - or even better, use an initialiser list like you did with the first constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;vector(T obj, int count = 1) :&#xA;       __data(new T[count]),&#xA;       __count(count),&#xA;       __capacity(count)&#xA;{&#xA;    for (int i = 0; i &amp;lt; count; i++) //populate array with given object&#xA;        __data[i] = obj;&#xA;} // vector(T, count)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;Another problem: In your &lt;code&gt;clear()&lt;/code&gt; member you wrote:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void clear() {&#xA;    this-&amp;gt;~vector();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should never, &lt;em&gt;never&lt;/em&gt;, &lt;strong&gt;never&lt;/strong&gt; directly call a destructor like this. The compiler can put all sorts of other code in the destructor code, since it &quot;knows&quot; that it's the only one that will ever call it. For example, some compilers pre-push a flag to say whether to &lt;code&gt;delete&lt;/code&gt; the object from the heap after doing the destruction. You haven't done that, so the above can corrupt all sorts of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, move the code that is in the destructor into &lt;code&gt;clear()&lt;/code&gt;, and then simply call &lt;code&gt;clear()&lt;/code&gt; from the destructor.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Another one, this one picked up by @Nick Gammon:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool isempty() {&#xA;    return !this-&amp;gt;__data ||&#xA;           !this-&amp;gt;capacity ||&#xA;           !this-&amp;gt;size;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is testing whether the &lt;code&gt;__data&lt;/code&gt; member is false, and whether the &lt;code&gt;capacity&lt;/code&gt; and &lt;code&gt;size&lt;/code&gt; functions have been defined. Don't worry: the latter two have been... you missed the prefix &lt;code&gt;__&lt;/code&gt;...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;[Also, stop it with the &lt;code&gt;this-&amp;gt;&lt;/code&gt; everywhere. You've used a &lt;code&gt;__&lt;/code&gt; before all your member variables (which is itself against convention); you don't need to hammer home the fact that they are member variables: the compiler already knows.]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-06-16T06:18:57.183" LastActivityDate="2016-06-16T06:18:57.183" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25321" PostTypeId="1" CreationDate="2016-06-16T04:24:51.577" Score="0" ViewCount="67" Body="&lt;p&gt;This code receives sine wave parameters from a serial connection, then formats and writes the sine wave positions to 8 servo motors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The positions are successfully written to 6 of the 8 motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the two that don't work, I tried changing the motors to see if they were faulty; they are not. I changed the output pins to see if they were damaged; they are not.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the order the equations are solved, and the positions are written to ensure there wasn't some bizarre timing issue. I saved a full cycle of the written positions and they output the correct numbers (i.e. the correct amplitude). You can see them here (format is &quot;servo #&quot; : &quot;position&quot;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1779 1:1337 2:1750 3:1480 4:1357 5:1438 6:1452 7:1490&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1846 1:1404 2:1704 3:1434 4:1403 5:1484 6:1385 7:1423&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1880 1:1438 2:1630 3:1360 4:1477 5:1558 6:1351 7:1389&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1870 1:1428 2:1549 3:1279 4:1558 5:1639 6:1361 7:1399&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1819 1:1377 2:1485 3:1215 4:1621 5:1702 6:1412 7:1450&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1742 1:1300 2:1458 3:1188 4:1649 5:1730 6:1489 7:1527&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1662 1:1220 2:1474 3:1204 4:1633 5:1714 6:1569 7:1607&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1603 1:1161 2:1530 3:1260 4:1577 5:1658 6:1628 7:1666&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1582 1:1140 2:1609 3:1339 4:1498 5:1579 6:1649 7:1687&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1604 1:1162 2:1687 3:1417 4:1420 5:1501 6:1627 7:1665&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1665 1:1223 2:1742 3:1472 4:1365 5:1446 6:1567 7:1605&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1745 1:1303 2:1757 3:1487 4:1350 5:1431 6:1486 7:1524&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1821 1:1379 2:1728 3:1458 4:1379 5:1460 6:1410 7:1448&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&#xA;0:1871 1:1429 2:1663 3:1393 4:1443 5:1524 6:1360 7:1398&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The entire code is below. The relevant section begins after &lt;code&gt;if (Afreq &amp;gt; 0)&lt;/code&gt; near the bottom. The positions that do not write correctly are pos[6] and pos[7]:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;This is a program that recieves sine wave parameters from a serial connection in a single string.&#xA;The string is parsed and converted into numbers, which are plugged into 8 sine equations to generate&#xA;positions for each joint of the robot.&#xA;*/&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo SB, SF, HB, HF, EB, EF, KB, KF;&#xA;int iAmp, iF_offset, iB_offset, iFk_offset, iBk_offset, pos[] = {0,1,2,3,4,5,6,7};&#xA;unsigned int t = 0;&#xA;unsigned long previousMillis = 0;&#xA;float fKnee_amp, fAfreq, fPhase, fGait;&#xA;&#xA;void setup(){&#xA;  //Start serial stream at 115200 baud&#xA;  Serial.begin(115200);&#xA;&#xA;  //Connect servos to Arduino&#xA;  HB.attach(2);&#xA;  KF.attach(3);&#xA;  SB.attach(4); &#xA;  EB.attach(10);&#xA;  HF.attach(6); &#xA;  KB.attach(7);&#xA;  SF.attach(8); &#xA;  EF.attach(11);&#xA;&#xA;  delay(3000);&#xA;}&#xA;&#xA;void loop(){&#xA;  char c, buffer[10];&#xA;  String readString, amp, knee_amp, afreq, gait, phase, f_offset, b_offset, fk_offset, bk_offset;&#xA;  unsigned int sine_time = 50;&#xA;&#xA;  while (Serial.available() &amp;amp;&amp;amp; readString.length() &amp;lt; 37){&#xA;    //delay to allow buffer to fill&#xA;    delayMicroseconds(100);&#xA;    if (Serial.available() &amp;gt; 0){&#xA;      //get one byte from serial buffer&#xA;      char c = Serial.read();&#xA;      //creates the string &quot;readString&quot;&#xA;      readString += c;&#xA;    }&#xA;  }&#xA;&#xA;  if (readString.length() &amp;gt; 36){&#xA;    //see what was received&#xA;    Serial.println(&quot;The string is: &quot; + readString);&#xA;    Serial.println(readString.length()); &#xA;&#xA;    //parse serial string into separate parameters&#xA;    amp = readString.substring(0, 3);&#xA;    knee_amp = readString.substring(3, 7); &#xA;    afreq = readString.substring(7, 11); &#xA;    phase = readString.substring(11, 15); &#xA;    gait = readString.substring(15, 20); &#xA;    f_offset = readString.substring(20, 24); &#xA;    b_offset = readString.substring(24, 28); &#xA;    fk_offset = readString.substring(28, 32); &#xA;    bk_offset = readString.substring(32, 36);&#xA;&#xA;    //convert string values to numbers&#xA;    iAmp = amp.toInt();&#xA;&#xA;    knee_amp.toCharArray(buffer, 10);&#xA;    fKnee_amp = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    afreq.toCharArray(buffer, 10);&#xA;    fAfreq = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    phase.toCharArray(buffer, 10);&#xA;    fPhase = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    gait.toCharArray(buffer, 10);&#xA;    fGait = atof(buffer);&#xA;    memset(buffer, 0, sizeof(buffer));&#xA;&#xA;    iF_offset = f_offset.toInt();&#xA;    iB_offset = b_offset.toInt();&#xA;    iFk_offset = fk_offset.toInt();&#xA;    iBk_offset = bk_offset.toInt();&#xA;&#xA;    //clear strings&#xA;    readString=&quot;&quot;;&#xA;    amp=&quot;&quot;;&#xA;    knee_amp=&quot;&quot;;&#xA;    afreq=&quot;&quot;;&#xA;    gait=&quot;&quot;;&#xA;    phase=&quot;&quot;;&#xA;    f_offset=&quot;&quot;;&#xA;    b_offset=&quot;&quot;;&#xA;    fk_offset=&quot;&quot;;&#xA;    bk_offset=&quot;&quot;;&#xA;  }&#xA;&#xA;  //if the joints should be oscillating&#xA;  if (fAfreq &amp;gt; 0){&#xA;    //determine joint positions&#xA;    pos[0] = iAmp * sin(fAfreq*t) + 1500 + iF_offset;&#xA;    pos[1] = iAmp * sin(fAfreq*t) + 1522 - iF_offset;&#xA;    pos[2] = iAmp * sin(fAfreq*t + fGait) + 1500 + iB_offset;&#xA;    pos[3] = iAmp * sin(fAfreq*t + fGait) + 1446 - iB_offset;&#xA;&#xA;    pos[4] = iAmp*fKnee_amp * sin(fAfreq*t + fGait + fPhase) + 1500 + iFk_offset;&#xA;    pos[5] = iAmp*fKnee_amp * sin(fAfreq*t + fGait + fPhase) + 1581 - iFk_offset;&#xA;    pos[6] = iAmp*fKnee_amp * sin(fAfreq*t + fPhase) + 1500 + iBk_offset;&#xA;    pos[7] = iAmp*fKnee_amp * sin(fAfreq*t + fPhase) + 1538 - iBk_offset;&#xA;&#xA;    //get time in milliseconds&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    //if the time threshold has been passed&#xA;    if(currentMillis - previousMillis &amp;gt;= sine_time){&#xA;      previousMillis = currentMillis;&#xA;&#xA;      //write servo positions&#xA;&#xA;      SB.writeMicroseconds(pos[0]); &#xA;      SF.writeMicroseconds(pos[1]); &#xA;      HB.writeMicroseconds(pos[2]);&#xA;      HF.writeMicroseconds(pos[3]); &#xA;      EB.writeMicroseconds(pos[4]);&#xA;      EF.writeMicroseconds(pos[5]);&#xA;      KF.writeMicroseconds(pos[6]);&#xA;      KB.writeMicroseconds(pos[7]);&#xA;&#xA;      //increment time parameter&#xA;      t+=1;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know what to try next.&lt;/p&gt;&#xA;" OwnerUserId="20430" LastActivityDate="2016-11-13T06:37:33.047" Title="Servos Do Not Move to Specified Position" Tags="|arduino-uno|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25322" PostTypeId="2" ParentId="25321" CreationDate="2016-06-16T04:36:44.913" Score="1" Body="&lt;p&gt;Given that it's the last two that aren't working, perhaps you've got a timing problem. Now I don't know how good the compiler is about detecting common code, but you might want to make it easier for it, and perhaps speed things up by making some temporary variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//determine joint positions&#xA;int pos01 = iAmp * sin(fAfreq*t);&#xA;pos[0] = pos01 + 1500 + iF_offset;&#xA;pos[1] = pos01 + 1522 - iF_offset;&#xA;&#xA;int pos23 = iAmp * sin(fAfreq*t + fGait);&#xA;pos[2] = pos23 + 1500 + iB_offset;&#xA;pos[3] = pos23 + 1446 - iB_offset;&#xA;&#xA;int pos45 = iAmp*fKnee_amp * sin(fAfreq*t + fGait + fPhase);&#xA;pos[4] =  pos45 + 1500 + iFk_offset;&#xA;pos[5] = pos45 + 1581 - iFk_offset;&#xA;&#xA;int pos67 = iAmp*fKnee_amp * sin(fAfreq*t + fPhase);&#xA;pos[6] = pos67 + 1500 + iBk_offset;&#xA;pos[7] = pos67 + 1538 - iBk_offset;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-06-16T04:44:35.260" LastActivityDate="2016-06-16T04:44:35.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25324" PostTypeId="2" ParentId="25315" CreationDate="2016-06-16T05:56:23.733" Score="1" Body="&lt;p&gt;You had a lot of problems with your code so it's hard to know where to start. :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I agree with what John Burger said.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I took your code onto my PC to save mucking around uploading it each time, and also so I could use valgrind on it. Certainly valgrind reported an error after you printed the vector. The reason for that is simple. You passed a &lt;strong&gt;copy&lt;/strong&gt; of the class to &lt;code&gt;print_vec&lt;/code&gt; which meant that the destructor got called when &lt;code&gt;print_vec&lt;/code&gt; exited, thus deallocating the memory. You should have had a &lt;em&gt;copy constructor&lt;/em&gt;. Without it the compiler makes a bitwise copy of the class, which means you now have two objects sharing the same allocated memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A quick and dirty fix is to call &lt;code&gt;print_vec&lt;/code&gt; by reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void print_vec(vector&amp;lt;int&amp;gt; &amp;amp; v){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However that leaves the bug lurking around for the future.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I implemented the copy constructor in my example below, however calling &lt;code&gt;print_vec&lt;/code&gt; by reference saves the class having to be copied, reducing the number of &lt;code&gt;new/delete&lt;/code&gt;s you are doing, thereby possibly reducing memory fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;As John Burger said: &lt;strong&gt;do not call the destructor yourself!&lt;/strong&gt; You can't do that. If you want to do the same thing in the destructor and the &lt;code&gt;clear&lt;/code&gt; function, just get the destructor to call &lt;code&gt;clear()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The use of leading double-underscores in variables is contrary to the C++ Standard. Don't do that. Use a trailing underscore if you want to indicate a member variable. Lose all the &lt;code&gt;this-&amp;gt;&lt;/code&gt; references. They just clutter things up.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Since you allocate an array you should use &lt;code&gt;delete []&lt;/code&gt; - you did that in one place but not the other.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Why do this? It's an unnecessary assignment:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  vector&amp;lt;int&amp;gt; i = vector&amp;lt;int&amp;gt;();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  vector&amp;lt;int&amp;gt; i;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you are going to assign the class for some reason you should also implement an &lt;code&gt;operator=&lt;/code&gt; or you will have the same problems as you had with the copy constructor. (See my example).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Here you are testing functions (capacity and size) without calling them:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool isempty() {&#xA;    return !this-&amp;gt;__data ||&#xA;        !this-&amp;gt;capacity ||&#xA;        !this-&amp;gt;size;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can't really do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  T const &amp;amp; operator[] (unsigned int idx) const {&#xA;        if (idx &amp;lt; this-&amp;gt;__count) {&#xA;            return this-&amp;gt;__data[idx];&#xA;        }&#xA;        else {&#xA;            // throw exception or handle error to be implemented&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you take the &quot;else&quot; path then the function is returning no value (you get a compiler warning if you turn warnings on).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My reworked example, with my suggestions in it. It compiles without warnings or errors and runs without crashing (on a PC):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//      g++ -std=c++11 -g3 test.cpp -o test&#xA;// OR:  clang -std=c++11 -g3 -Wall test.cpp -lstdc++ -o test&#xA;//&#xA;// valgrind --leak-check=yes ./test&#xA;&#xA;#include &amp;lt;stdio.h&amp;gt;      // printf&#xA;#include &amp;lt;string.h&amp;gt;     /* memcpy */&#xA;&#xA;#define min(a,b) (a &amp;lt; b) ? a : b&#xA;&#xA;template &amp;lt;typename T&amp;gt;&#xA;class vector {&#xA;public:&#xA;    //empty constructor&#xA;    vector() : capacity_(0), count_(0), data_(nullptr) {}&#xA;&#xA;    // copy constructor&#xA;    vector (const vector &amp;amp; rhs) : capacity_(0), count_(0), data_(nullptr)&#xA;      {&#xA;      data_ = new T [rhs.capacity_];&#xA;      capacity_ = rhs.capacity_;&#xA;      count_ = rhs.count_;&#xA;      memcpy (data_, rhs.data_, sizeof (T) * count_);&#xA;      }  // end of copy constructor&#xA;&#xA;    // operator=&#xA;    vector &amp;amp; operator= (const vector &amp;amp; rhs)&#xA;      {&#xA;      // gracefully handle self-assignment (eg. a = a;)&#xA;      if (this == &amp;amp;rhs )&#xA;        return *this;&#xA;&#xA;      data_ = new T [rhs.capacity_];&#xA;      capacity_ = rhs.capacity_;&#xA;      count_ = rhs.count_;&#xA;      memcpy (data_, rhs.data_, sizeof (T) * count_);&#xA;      return *this;&#xA;      }  // end of operator=&#xA;&#xA;    // destructor&#xA;    ~vector()&#xA;      {&#xA;        clear ();&#xA;      }  // end of destructor&#xA;&#xA;    T const &amp;amp; operator[] (unsigned int idx) const {&#xA;       return data_[idx];&#xA;    }&#xA;&#xA;    T&amp;amp; operator[] (unsigned int idx) {&#xA;       return data_[idx];&#xA;    }&#xA;&#xA;    void resize_to_fit() {&#xA;        resize(count_);&#xA;    }&#xA;&#xA;    T&amp;amp; pop_back(){&#xA;        return data_[--count_];&#xA;    }&#xA;&#xA;    void push_back(T obj) &#xA;        {&#xA;        if (capacity_ == count_) {&#xA;            resize(capacity_ + 1);&#xA;        }&#xA;&#xA;        data_[count_++] = obj;&#xA;    }&#xA;&#xA;    bool isempty() {&#xA;        return count_ == 0;&#xA;    }&#xA;&#xA;    void clear() {&#xA;      delete [] data_;&#xA;      data_ = nullptr;&#xA;      count_ = capacity_ = 0;&#xA;    }&#xA;&#xA;    T* data() {&#xA;        return data_;&#xA;    }&#xA;&#xA;    int size() {&#xA;        return count_;&#xA;    }&#xA;&#xA;    int capacity() {&#xA;        return capacity_;&#xA;    }&#xA;private:&#xA;    void resize(int capacity) {&#xA;        if (data_ == nullptr) {&#xA;            data_ = new T[capacity];&#xA;            count_ = 0;&#xA;            capacity_ = capacity;&#xA;        }&#xA;        else if (capacity &amp;gt; capacity_) { //else do nothing&#xA;&#xA;            // allocate new memory&#xA;            T* data = new T[capacity];&#xA;            // count can't be higher than capacity&#xA;            count_ = min(count_, capacity);&#xA;            capacity_ = capacity;&#xA;            // copy data across to new pointer&#xA;            memcpy(data, data_, sizeof(T) * count_);&#xA;            // delete old pointer&#xA;            delete [] data_;&#xA;            // now remember the new pointer&#xA;            data_ = data;&#xA;        }&#xA;    }&#xA;protected:&#xA;&#xA;        int capacity_;&#xA;        int count_;&#xA;        T* data_;&#xA;};&#xA;&#xA;&#xA;&#xA;void print_vec(vector&amp;lt;int&amp;gt; v){&#xA;  printf(&quot;%s\n&quot;, &quot;Printing new vec!&quot;);&#xA;  for( int i = 0; i &amp;lt; v.size(); i++){&#xA;    printf(&quot;%i\n&quot;, v[i]);&#xA;  }&#xA;}&#xA;&#xA;int main() {&#xA;&#xA;  vector&amp;lt;int&amp;gt; i;&#xA;&#xA;  i.push_back(10);&#xA;  i.push_back(2);&#xA;  print_vec(i);&#xA;  i.push_back(3);&#xA;&#xA;  vector&amp;lt;int&amp;gt; j;&#xA;&#xA;  // test assignment&#xA;  j = i;&#xA;  print_vec(j);&#xA;  print_vec(i);&#xA;&#xA;&#xA;  while(i.size () &amp;gt; 0){&#xA;    print_vec(i);&#xA;    i.pop_back();&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-16T06:28:21.947" LastActivityDate="2016-06-16T06:28:21.947" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25325" PostTypeId="2" ParentId="20157" CreationDate="2016-06-16T06:24:28.407" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How would the wiring look like? I was unable to find any dumb-proof&#xA;  tutorial online.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I found &lt;a href=&quot;http://arduino-info.wikispaces.com/SoftwareSerialRS485Example&quot; rel=&quot;noreferrer&quot;&gt;this&lt;/a&gt; tutorial to be pretty usefull.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There really isn't much to it, I suggest trying a short range before going full range.&#xA;It's a &quot;half duplex bus system&quot; the ends of the bus should have a &quot;end termination resistor&quot;, usually 120Ohms, between the A and B signal.&#xA;Since it's half duplex, the Pi and Arduino can't talk at the same time.&#xA;You'll have to pull the DE and RE pins high when you want to transmit (and keep them low for receiving).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basic sketch would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define TXEnablePin 13&#xA;&#xA;void setup(){&#xA;  Serial.setup(9600);&#xA;  pinMode(TXEnablePin,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  String data = &quot;&quot;;&#xA;  Unsigned int sensorValue1 = Sensor.getValue();&#xA;  Unsigned int sensorValue2 = Sensor.getValue();&#xA;  data += str(sensorValue1) + &quot;:&quot; + str(sensorValue2) + &quot;;\r\n&quot;;&#xA;  send(data);&#xA;  delay(10000);&#xA;}&#xA;&#xA;void send(String data){&#xA;  digitalWrite(TXEnablePin,HIGH);&#xA;  delay(1);&#xA;  Serial.send(data);&#xA;  Serial.flush();//Wait for everything to be transmitted, before disabling transmitter.&#xA;  digitalWrite(TXEnablePin,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't know whether or how to use the logic level shifter.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These things are pretty straight forward. You should actually be able to figure it out yourself (given you have the power of the internet).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LV to 3.3V of Pi&#xA;GND to GND of Pi&#xA;GND to GND of Arduino&#xA;HV to 5V of Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, whatever 5V signal you want to connect to HVx and whatever 3.3V signal you want to connect to LVx&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Example:&#xA;Arduino-TX -&amp;gt; HV1&#xA;Arduino-RX -&amp;gt; HV2&#xA;Pi-TX -&amp;gt; LV2&#xA;Pi-RX -&amp;gt; LV1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GUmhB.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GUmhB.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I can read the data over serial port, would it be just a plain text&#xA;  (as shown on PC in Arduino ide serial monitor), or has each value its&#xA;  address that I could then easily accessing to a variable then being&#xA;  used to process the weather data?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It would be ASCII (plain text) if you send strings.&#xA;You could make different types of requests.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like; If you send: &quot;Temperature&quot; to the Arduino, it will respond with: &quot;TEMP:10&quot; or something.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the easiest thing would be to send all values of all sensors in a combined string every 10 seconds or so. And let the Raspberry Pi unpack that string.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I'm completely wrong in something, or there's some completely&#xA;  different way how these things are being done by more experienced&#xA;  people, I'd love to hear some suggestions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think it's pretty good that you actually already know of the existence of RS485 and why you'd want to use it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I also feel that you feel a little uncomfortable with the project as it is.&#xA;It's important to handle problems one by one, to avoid getting overrun by problems.&#xA;Try to make it working over (short) USB first. Then try a short RS485 link and eventually try a long RS485 link. You can then more easily spot where the problem is. Use facts from multiple tutorials, to boost the confidence you have in the system ;). It may just work if you wire it as said. If it doesn't work, you can always post a question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, it may also be worthwhile to follow some tutorials on Arduino (get a starter kit and book with tutorial projects?). Within these tutorials they give examples of problems and show what there is to solve them. Without throwing yourself into a dark pit of a project.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-16T06:24:28.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25334" PostTypeId="1" AcceptedAnswerId="25338" CreationDate="2016-06-16T11:44:36.590" Score="4" ViewCount="32830" Body="&lt;p&gt;I am using a Arduino Uno 3 for line follower robot. However when I power the Arduino Uno, the L led is turned on and is never turned off. After a bit of searching I found out that the L LED is connected to pin 13. So I set the pin 13 to low but still the led is on. Is there a problem with the arduino? Or there's something that I am unaware about? (Amongst a lot of other things that I don't know.)&lt;/p&gt;&#xA;" OwnerUserId="23082" LastEditorUserId="25788" LastEditDate="2016-09-16T14:16:01.693" LastActivityDate="2020-10-12T05:17:29.210" Title="The L LED Keeps Itself On" Tags="|led|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25335" PostTypeId="2" ParentId="25334" CreationDate="2016-06-16T12:13:02.040" Score="0" Body="&lt;p&gt;An LED lights up when in forward bias.  That is, when the voltage on the anode is greater then that on the cathode.  If the anode is connected to an Arduino GPIO pin (and the cathode is connected to ground and an appropriate limiting resistor is used), the LED will light up when the pin has positive voltage.  This is when it is set to 1 in the code.  If the cathode is connected to an Arduino GPIO pin (and the anode is connected to positive voltage and an appropriate limiting resistor is used), the LED will light up when the pin has zero voltage. This is when it is set to 0 in the code.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-16T12:13:02.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25336" PostTypeId="2" ParentId="25334" CreationDate="2016-06-16T12:27:37.383" Score="2" Body="&lt;p&gt;Its possible its the Power LED you are looking at - that will always be on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simplest test is to load up the Blink Example that's included in the Arduino IDE - and the LED should blink once a second. That will show you if your Pin13 LED is working ok.&lt;/p&gt;&#xA;" OwnerUserId="23083" LastActivityDate="2016-06-16T12:27:37.383" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25337" PostTypeId="2" ParentId="12017" CreationDate="2016-06-16T12:54:09.313" Score="1" Body="&lt;p&gt;It's possible it's fried - but I have had recovered some boards like this that the boot software had gotten corrupted.&#xA;It's easy enough to reapply the bootloader to the device - you will need either a second arduino:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or an usbasp programmer (about $10 on eBay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also a tutorial on reflashing the USB chip (link below) - but I would try the above first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.virtuabotix.com/how-to-cure-sudden-uno-death-syndrome/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.virtuabotix.com/how-to-cure-sudden-uno-death-syndrome/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23083" LastEditorUserId="28084" LastEditDate="2016-11-13T19:20:18.437" LastActivityDate="2016-11-13T19:20:18.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25338" PostTypeId="2" ParentId="25334" CreationDate="2016-06-16T14:16:45.410" Score="7" Body="&lt;p&gt;This is a “feature” introduced in the revision 3 of the Uno board. Up to&#xA;Rev 2, the “L” LED was connected to pin 13, through a 1&amp;nbsp;kΩ&#xA;resistor. On Rev 3, the same LED+resistor combination is driven by pin&#xA;13 through an op-amp. Thus, when pin 13 is in high impedance mode (i.e.&#xA;&lt;code&gt;INPUT&lt;/code&gt; mode, the default mode when the program starts), the input of&#xA;the op-amp is floating. The voltage at this input (and thus at the&#xA;output) is not controlled and depends only on the parasitic conductances&#xA;and on leakage currents.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to turn the LED off, you not only need to write &lt;code&gt;LOW&lt;/code&gt; to it,&#xA;you also (and most importantly) should set the pin to &lt;code&gt;OUTPUT&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-16T14:16:45.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25339" PostTypeId="1" CreationDate="2016-06-16T14:51:08.910" Score="1" ViewCount="5689" Body="&lt;p&gt;I'm using sleep mode to turn off my device after the routine has finished executing and want to use interrupts to wake it up every 33 milliseconds. Basically, the idea is that if the routine completes in less than 33 milliseconds the processor can shutdown and save power for whatever remaining time, which will hopefully translate to reduced power consumption. I've currenlty managed to turn off my device with the &lt;code&gt;sleepNow()&lt;/code&gt; function you see below, but the interrupt I have programmed in doesn't seem to work. The program simply goes to sleep and never wakes up. What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;&#xA;const uint16_t PERIOD = 2150;&#xA;&#xA;void setup()&#xA;{&#xA;  noInterrupts();&#xA;  TCCR1A = 0;            // undo the timer config done...&#xA;  TCCR1B = 0;            // ...by the Arduino core library&#xA;  TCNT1 = 0;             // reset the timer&#xA;  OCR1A = PERIOD - 1;    // set the period&#xA;  TIMSK1 = _BV(OCIE1A);  // enable TIMERx_COMPA interrupt&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12); // ...and set the prescaler&#xA;  interrupts();&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;  Serial.println(millis());  &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;Program is on&quot;);&#xA;  Serial.flush();&#xA;  sleepNow();&#xA;}&#xA;&#xA;void sleepNow()&#xA;{&#xA;&#xA;    // Choose our preferred sleep mode:&#xA;    set_sleep_mode(SLEEP_MODE_PWR_SAVE);&#xA;&#xA;    // Set sleep enable (SE) bit:&#xA;    sleep_enable();&#xA;&#xA;    // Put the device to sleep:&#xA;    sleep_mode();&#xA;&#xA;    // Upon waking up, sketch continues from this point.&#xA;    sleep_disable();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22875" LastActivityDate="2016-06-16T15:58:12.173" Title="How to wake up Arduino Mega when in Power Saving Sleep Mode?" Tags="|arduino-mega|power|sleep|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25340" PostTypeId="1" AcceptedAnswerId="25341" CreationDate="2016-06-16T15:18:07.703" Score="0" ViewCount="69" Body="&lt;p&gt;I am making an arduino clock/alarm. I use an LCD screen to display the time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;    static unsigned long timing=micros();&#xA;    if (mode == 0) {//mode 0 is when the time should show&#xA;        timing=countTime(timing);&#xA;        writeTime(minutes, hours);//display time&#xA;  }&#xA;}&#xA;  unsigned long countTime(unsigned long timing){&#xA;            if (micros() - timing &amp;gt;= 59946970) {&#xA;              return timing += 59946970;//more precise because Arduino timing is not perfect&#xA;              minutes++;&#xA;&#xA;&#xA;    }&#xA;        else{&#xA;&#xA;         return timing;&#xA;        }&#xA;&#xA;      }&#xA;&#xA;&#xA;    void writeTime(int minute, int hour) {&#xA;      lcd.setCursor(6, 1);&#xA;      if (minute &amp;gt;= 60) {&#xA;        minute = 0;&#xA;        hour++;&#xA;      }&#xA;      if (hour &amp;gt;= 24) {&#xA;        hour = 0;&#xA;      }&#xA;      if (minute &amp;lt; 10) {&#xA;&#xA;        if (hour &amp;lt; 10) {&#xA;          lcd.print(String(&quot;0&quot;) + hour + &quot;:&quot; + &quot;0&quot; + minute);&#xA;        }&#xA;        else {&#xA;          lcd.print(hour + String(&quot;:&quot;) + &quot;0&quot; + minute);&#xA;        }&#xA;      }&#xA;      else {&#xA;        if (hour &amp;lt; 10) {&#xA;          lcd.print(String(&quot;0&quot;) + hour + &quot;:&quot; + minute);&#xA;        }&#xA;        else {&#xA;          lcd.print(hour + String(&quot;:&quot;) + minute); //possibly split if problems arise&#xA;        }&#xA;&#xA;      }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used to do all this within the loop, but decided to make it separate. Why isn't this code working?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-06-16T18:27:39.030" Title="Why doesn't the time update?" Tags="|arduino-uno|c++|timing|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25341" PostTypeId="2" ParentId="25340" CreationDate="2016-06-16T15:28:15.090" Score="1" Body="&lt;p&gt;This statement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static unsigned long timing=micros();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...only gives it an initial value.  It is not executed during &lt;code&gt;loop&lt;/code&gt;.  These kinds of variables should be assigned an initial value in an executable section, perhaps when the alarm time is set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This requires the definition to be pulled out, to the file scope:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static unsigned long timing;&#xA;&#xA;void loop(){&#xA;    if (mode == 0) {//mode 0 is when the time should show&#xA;        timing=countTime(timing);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here, the &lt;code&gt;static&lt;/code&gt; keyword has a different meaning, although I usually use it to reduce the chances of colliding with other global variable names.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Make sure to give it an initial value in executable code somewhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  ...&#xA;  timing = millis();  // Just once?  When the alarm is set?&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and update it as you do in &lt;code&gt;countTime&lt;/code&gt;.&#xA;&lt;hr&gt;&#xA;&lt;strong&gt;UPDATE&lt;/strong&gt;  It's not clear from your snippet as to &lt;em&gt;when&lt;/em&gt; the &lt;code&gt;timing&lt;/code&gt; variable should be initialized, so I originally avoided addressing that.  If it is really initialized just once, at program startup, you can set it in &lt;code&gt;setup&lt;/code&gt;.  Otherwise, it should be set when the initial &lt;code&gt;timing&lt;/code&gt; value is finally known.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2016-06-16T18:27:39.030" LastActivityDate="2016-06-16T18:27:39.030" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25342" PostTypeId="1" CreationDate="2016-06-16T15:36:09.193" Score="0" ViewCount="2137" Body="&lt;p&gt;So I understand that when setting a timer interrupt you don't use nanoseconds or milliseconds, but the actual number of clock cycles. However, I don't understand how you would be able to setup a specific time this way. If I wanted my interrupt to go off every 20 milliseconds would I have to divide that by the duration of each clock cycle?&lt;/p&gt;&#xA;" OwnerUserId="21660" LastActivityDate="2016-06-16T16:21:24.143" Title="How can you determine the duration of a timer interrupt?" Tags="|arduino-mega|sleep|oscillator-clock|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25343" PostTypeId="2" ParentId="25339" CreationDate="2016-06-16T15:58:12.173" Score="1" Body="&lt;p&gt;It is certainly tempting to go into a very deep sleep in order to save&#xA;power, but you still need to keep awake whatever peripheral you want to&#xA;use as a wakeup source. If you want to use a 16 bit timer, there is no&#xA;other choice than &lt;code&gt;SLEEP_MODE_IDLE&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it may not be that bad. In IDLE mode you can selectively disable the&#xA;clock (and hence put to sleep) the peripherals you do not use. Or maybe&#xA;put them &lt;em&gt;all&lt;/em&gt; to sleep, and then wake up the few ones you do need. This&#xA;is achieved with the &lt;code&gt;power_*_disable()&lt;/code&gt; and &lt;code&gt;power_*_enable()&lt;/code&gt; family&#xA;of functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the edited code below: all peripherals but the Timer 1 are disabled&#xA;while the CPU sleeps. The USART is enabled only for the time it needs to&#xA;send its message:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;&#xA;const uint16_t PERIOD = 2150;  // 34.4 ms&#xA;&#xA;void setup()&#xA;{&#xA;  // Disable all but the needed peripherals.&#xA;  power_all_disable();&#xA;  power_timer1_enable();&#xA;&#xA;  // This is for debug pulses.&#xA;  pinMode(22, OUTPUT);&#xA;&#xA;  // Configure Timer 1 to wake us up every 34.4 ms.&#xA;  TCCR1A = 0;            // undo the timer config done...&#xA;  TCCR1B = 0;            // ...by the Arduino core library&#xA;  TCNT1 = 0;             // reset the timer&#xA;  OCR1A = PERIOD - 1;    // set the period&#xA;  TIMSK1 = _BV(OCIE1A);  // enable TIMERx_COMPA interrupt&#xA;  TCCR1B = _BV(WGM12)    // CTC mode, TOP = OCR1A&#xA;         | _BV(CS12);    // ...and set the prescaler /256&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;  // Send a debug pulse.&#xA;  digitalWrite(22, HIGH);&#xA;  _delay_ms(2);&#xA;  digitalWrite(22, LOW);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // Enable the USART only while needed.&#xA;  power_usart0_enable();&#xA;  Serial.println(&quot;Program is on&quot;);&#xA;  Serial.flush();&#xA;  power_usart0_disable();&#xA;&#xA;  // And go to sleep in IDLE mode.&#xA;  sleep_mode();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice also that the ISR does not print to the serial port: it just&#xA;sends a debug pulse to watch with the scope. This should be removed from&#xA;production code. The delay is achieved with the avr-libc function&#xA;&lt;code&gt;_delay_ms()&lt;/code&gt; because the standard Arduino &lt;code&gt;delay()&lt;/code&gt; would not work: it&#xA;relies on Timer 0, which has been disabled.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-16T15:58:12.173" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25344" PostTypeId="1" AcceptedAnswerId="25399" CreationDate="2016-06-16T15:58:49.137" Score="2" ViewCount="3192" Body="&lt;p&gt;Hi I am a research student working on securing the communications in Controlled Area Networks (CANs), and I am using Arduinos to simulate one of these CANs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to use HMAC to implement message authentication of packets, and the algorithm &lt;strong&gt;must&lt;/strong&gt; be &lt;em&gt;very fast&lt;/em&gt; (I was originally thinking of using FNV1a). However, there are no Arduino libraries for this (I found one, but it uses SHA which will most likely be too slow for CAN). I don't have a &lt;em&gt;lot&lt;/em&gt; of practice with cryptography and hash algorithms, only usage of them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically, I need help writing a FNV or FNV1a function in C. The message for input will be a key (obviously) concatenated with a string (char array). Also, I need the hash to be between 128 and 256 bits for sufficient security.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just as a side note: A CAN message/packet looks like &lt;strong&gt;7df#02010d&lt;/strong&gt; and the actual data part, &lt;strong&gt;010d&lt;/strong&gt; (two bytes) is the char array I will be using. For example, as integers, the array for &lt;strong&gt;010d&lt;/strong&gt; would be {1, 13}.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also know this message applies more to cryptography than Arduino, but I figured someone from this community might have more experience with my particular task, or even have/know of a library I can use that I hadn't found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Thanks&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;EDIT:&lt;/em&gt; I found &lt;a href=&quot;http://create.stephan-brumme.com/fnv-hash/&quot; rel=&quot;nofollow&quot;&gt;this FNV1a implementation in C/C++&lt;/a&gt; that might work. But I have not tested it yet.&lt;/p&gt;&#xA;" OwnerUserId="23087" LastEditorUserId="23087" LastEditDate="2016-06-16T16:30:08.333" LastActivityDate="2016-06-22T19:24:53.607" Title="How to Implement Simple, Quick HMAC on Arduino" Tags="|arduino-uno|programming|c|can-bus|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25345" PostTypeId="2" ParentId="20838" CreationDate="2016-06-16T16:06:23.633" Score="0" Body="&lt;p&gt;I found this wiki particularly useful: &lt;a href=&quot;http://www.seeedstudio.com/wiki/CAN-BUS_Shield&quot; rel=&quot;nofollow&quot;&gt;CAN-Bus Shield Wiki&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, like CQuinson said, you have to pay attention to the pins used. I know Sparkfun is known for having an issue with which pin the CS pin is assigned to (D9 or D10). &lt;/p&gt;&#xA;" OwnerUserId="23087" LastActivityDate="2016-06-16T16:06:23.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25346" PostTypeId="1" AcceptedAnswerId="25348" CreationDate="2016-06-16T16:09:51.470" Score="10" ViewCount="9990" Body="&lt;p&gt;I'm trying to upload a compiled .hex file on an Arduino Leonardo, using the terminal. Uploading a sample code using the Arduino IDE works well, and from the Arduino IDE I got the upload command&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude -C/etc/avrdude.conf -patmega32u4 -cavr109 -v -v -v -v -P/dev/ttyACM0 -b57600 -D -Uflash:w:[file.hex]:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But executing it I got the following error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Connecting to programmer: .avrdude: Send: . [1b]&#xA;avrdude: Send: S [53] &#xA;avrdude: Recv: . [15] &#xA;&#xA;avrdude: ser_recv(): programmer is not responding&#xA;avrdude: butterfly_recv(): programmer is not responding&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong?&lt;/p&gt;&#xA;" OwnerUserId="4847" LastEditorUserId="6936" LastEditDate="2018-07-12T11:18:50.990" LastActivityDate="2023-04-04T10:19:04.917" Title="Upload code on Arduino Leonardo using command line" Tags="|arduino-leonardo|uploading|avrdude|terminal|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25347" PostTypeId="2" ParentId="25342" CreationDate="2016-06-16T16:21:24.143" Score="2" Body="&lt;p&gt;The timer takes its time from the system clock. That may be, typically, 16MHz. We call this &lt;em&gt;F_clk_io&lt;/em&gt; for the &lt;strong&gt;F&lt;/strong&gt;requency of the &lt;strong&gt;IO&lt;/strong&gt; &lt;strong&gt;CL&lt;/strong&gt;oc&lt;strong&gt;K&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Every time that clock ticks the timer counts. Or, depending on settings, every time that clock ticks the prescaler counts, and eventually the output of the prescaler ticks and then the timer counts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first you need to divide the &lt;em&gt;F_clk_io&lt;/em&gt; by the prescaler. That may be 1:1, 1:2, 1:4, 1:8, etc, depending on settings. No prescaler is the same as a prescaler of 1:1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So say you have selected a 1:4 prescaler.  The timer's frequency is then &lt;em&gt;F_clk_io / 4&lt;/em&gt;, or if it's 16MHz you're running at, then the timer's frequency is &lt;em&gt;16/4 = 4MHz&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So at 4MHz each tick lasts for &lt;em&gt;1/4000000 = 250ns&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want 20ms you need to know how many ticks that would be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;20ms in nanoseconds would be 20000000. 20000000 / 250 = 80000 ticks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, there's a problem there. 80000 won't fit into the 16-bit registers of a 16-bit timer. The maximum you can have is 65535. So we're going to need to slow things down a bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Set the prescaler to 1:8 and see what happens...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;16/8 = 2MHz. 1/2000000 = 500ns. 20000000 / 500 = 40000 ticks.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That fits.  See how doubling the prescaler has simply halved the number of ticks you get in the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So setting it to a prescaler of 1:8 and letting it tick 40000 times should give you 20ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It gives you 20.0005ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why? Because the interrupt triggers and the counter resets when it &lt;em&gt;reaches&lt;/em&gt; the target count, not when it &lt;em&gt;passes&lt;/em&gt; the target count.  And since it starts counting at 0, there's actually 40001 ticks there. So you have to subtract 1 from the number of ticks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the finished formula is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ticks = ((F_clk_io ÷ Prescale) × time) - 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Things get more tricky when you are working with a smaller chip though and only have an 8-bit timer to use. With that the maximum ticks you can have is a mere 255. So you will have to use a much bigger prescale to get it to fit in. If that's even possible.  If it's not, then there are other tricks you can use.  My favourite is a manual pre-scale:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Run the timer at a multiple of your target frequency (10x is easy)&lt;/li&gt;&#xA;&lt;li&gt;Count the number of times the interrupt triggers&lt;/li&gt;&#xA;&lt;li&gt;When the interrupt has triggered 10 times (if using a 10x faster timer) then reset the count to 0 and trigger your real ISR code.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;10x is simple to program and visualize, but it's not very programatically efficient. Better is to use a &quot;power of two&quot; multiple since you can examine a single bit in your counter to see if it's reached the target count.  Only minimal differences though, and not really worth worrying about unless you are having a very fast timer interrupt.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-16T16:21:24.143" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25348" PostTypeId="2" ParentId="25346" CreationDate="2016-06-16T16:27:46.550" Score="5" Body="&lt;p&gt;The problem with the Leonardo is it doesn't automatically reset when you open the serial port like boards such as the Uno do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE contains code to manually reset the board (by opening the serial port at 1200 baud and closing it again) which avrdude doesn't have.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you need a different way to reset the board so it enters the bootloader. That may be as simple as just pressing the reset button at the right time (the LED fades in and out when it's in bootloader mode) or using some command line utility to open the serial port at 1200 baud and close it again just before running avrdude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have my Leonardo to hand right now, but you might have some luck running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stty -F /dev/ttyACM0 ispeed 1200 ospeed 1200 &amp;amp;&amp;amp; avrdude -C/etc/avrdude.conf -patmega32u4 -cavr109 -v -v -v -v -P/dev/ttyACM0 -b57600 -D -Uflash:w:[file.hex]:i&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-16T16:27:46.550" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25349" PostTypeId="2" ParentId="23192" CreationDate="2016-06-16T16:38:54.787" Score="0" Body="&lt;p&gt;Seems like you have several options:  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;1. Find a nRF24 library that works on ESP with the &quot;arduino core&quot; or port one yourself.  &lt;br&gt;&#xA;2. Implement your own Arduino-to-ESP protocol, using Serial (SoftwareSerial if needed), I2C or whatever.  &lt;br&gt;&#xA;3. Flash the ESP with the standard AT commands firmware and command it from the Arduino.  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;IMO, option 1 is best (you would ditch the Arduino completely), but may require significant effort.  &lt;br&gt;&#xA;Option 2 is academically better than option 3, as it will skip the hassle of dealing with AT commands on the Arduino side and will eventually be more efficient in terms of data bandwith between the Arduino and the ESP. In practice, it probably won't matter.  &lt;br&gt;&#xA;Option 3 might be the easiest - as much as I dislike the AT commands, they work and you won't have to program two devices constantly while developing your code.  &lt;br&gt;&#xA;  &lt;br&gt;&#xA;So, in short, if you can go with Option 1 - please do so :)  &lt;br&gt;&#xA;If not - quickly asses which one will be easier / better for you - option 2 or option 3 and just go with it. Both will work, and are relatively easy to achieve.&lt;/p&gt;&#xA;" OwnerUserId="20696" LastActivityDate="2016-06-16T16:38:54.787" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25350" PostTypeId="2" ParentId="25315" CreationDate="2016-06-16T17:13:00.390" Score="0" Body="&lt;p&gt;There is something I would like to add.  &lt;br&gt;&#xA;Others have already pointed out numerous errors in the code. And I could point many more, but that is not the point.  &lt;br&gt;&#xA;IMO, the biggest mistake is - implementing a Vector class for the Arduino!  &lt;br&gt;&#xA;Even if it works, it is just a bad idea. Keep in mind, that the Arduino has VERY limited amount of memory. Dynamic memory allocation in such a constrained space just sounds like a bad idea - you are wasting memory, you're fragmenting the heap and you gain almost nothing, except some coding convenience.  &lt;br&gt;&#xA;I have yet to see a case where one really needs dynamic memory allocation in an Arduino project. And even if you do, there are many other tools you can use (like stack-allocated temp buffers, arena allocators, pool allocators and whatnot). But again, probably the code and memory cost of these &quot;generic&quot; solutions will be unfeasible on the Arduino.  &lt;br&gt;&#xA;Most of the time it's fine to use vectors, maps and whatever you like on platforms like PC (I work as a PC games programmer, so I often encounter situations where extras like these are big &quot;no-no&quot;, but for most applications it's fine).  &lt;br&gt;&#xA;But, on a &quot;tight&quot; platform like the Arduino, I think you should stay &quot;close to the metal&quot; and be in total control of what is going on (memory and CPU cycles wise). Ideally, you should only afford &quot;luxuries&quot; like these when you know what is going on &quot;underneath&quot; and you know you can get away with it. Which is rarely the case on &quot;tight&quot; platforms like the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="20696" LastActivityDate="2016-06-16T17:13:00.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25353" PostTypeId="1" CreationDate="2016-06-16T19:38:04.053" Score="3" ViewCount="1468" Body="&lt;p&gt;Please tell me why is it necessary to access pull-up resistors and how can we access them in arduino?&lt;/p&gt;&#xA;" OwnerUserId="22930" LastActivityDate="2016-06-17T01:43:57.217" Title="Why are pull-up resistors needed?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ClosedDate="2016-06-20T08:06:16.747" ContentLicense="CC BY-SA 3.0" />
  <row Id="25354" PostTypeId="2" ParentId="25353" CreationDate="2016-06-16T20:16:23.383" Score="1" Body="&lt;p&gt;A short answer from &lt;a href=&quot;http://playground.arduino.cc/CommonTopics/PullUpDownResistor&quot; rel=&quot;nofollow&quot;&gt;Arduino Playground&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Pull-up resistors are used in electronic logic circuits to ensure that&#xA;  inputs to the arduino settle at expected logic levels if external&#xA;  devices are disconnected or high-impedance. 'Just because you have&#xA;  nothing at all connected to an input pin doesn't mean it is a logical&#xA;  zero.'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="4131" LastActivityDate="2016-06-16T20:16:23.383" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25355" PostTypeId="2" ParentId="25353" CreationDate="2016-06-16T20:26:54.140" Score="6" Body="&lt;p&gt;Pull-up resistors are used to define the state of an otherwise &quot;floating&quot; input by pulling the voltage at the pin to a set voltage.  &lt;br&gt;&#xA;The most typical example is a switch - let's say you have some signal, which is connected to your input through a switch. If the switch is open, the state of your input is &quot;floating&quot;. If you try to digitalRead or analogRead that input, the value will be pretty much just noise.  &lt;br&gt;&#xA;But, if you have a resistor connected from your input to ground (pull-down) or VCC (pull-up) your reading will be consistent (HIGH or LOW, depending on where the resistor goes) while the switch is open.  &lt;br&gt;&#xA;When the switch is closed, the voltage at the pin will be pulled to the voltage at the other end of the switch.  Because of the lower resistance of the switch relative to your pull-up resistor, this is the input level that will be read by the microcontroller. Pull-up resistors are usually pretty big value (5k-100k) in order to be much higher resistance than the switch and to decrease the current that is used by the switch to produce a signal.  &lt;br&gt;&#xA;If, for example, you have a &lt;em&gt;pull-up&lt;/em&gt; resistor and a switch that connects your input to the ground, when the switch is open you will read HIGH and when it is closed you will read low.&#xA;Note that many components act similar to switches, for example transistors, open-drain / open-collector devices and many more, so the switch was just an example.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use external pull resistors (just add a resistor from your pin to ground or VCC) or use the internal pull resistors of your MCU.&#xA;The Arduino only has internal pull-up resistors (no internal pull-downs) - their value depends on the model, but usually is between 20K-150K.  &lt;br&gt;&#xA;To activate the internal pull-up resistor for a given pin on Arduino, use the following code:  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(N, INPUT);&#xA;digitalWrite(N, HIGH):&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &quot;N&quot; is your pin number or with recent IDEs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(N, INPUT_PULLUP);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20696" LastEditorUserId="11763" LastEditDate="2016-06-17T01:43:57.217" LastActivityDate="2016-06-17T01:43:57.217" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25359" PostTypeId="1" AcceptedAnswerId="25360" CreationDate="2016-06-11T18:51:50.567" Score="-1" ViewCount="241" Body="&lt;p&gt;i am pretty much newbie with arduino and want to start my first project so i may be asking stupid questions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to make usb controller for android tv (running on raspberry pi or s905). I want it rotary, so turning will be &quot;arrow up/down&quot; or &quot;left/right&quot; (i dont know exact android tv menu controlling) and &quot;return&quot; on push. I found &lt;a href=&quot;http://www.ebay.com/itm/1-10X-12mm-Rotary-Encoder-Push-Button-Switch-Keyswitch-Electronic-Components-New-/291289671106?var=&amp;amp;hash=item43d237a5c2:m:mFWqvrBn9_vgy9o4j9ucZeg&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; rotary switch on ebay, is it suitable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To communicate i want to use arduino. I found libraries &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow&quot;&gt;MouseKeyboard&lt;/a&gt;, which might be suitable for my needs, will arduino nano support this library or do i need arduino uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do i need something else, or just connect switch to pins on arduino and plug arduino to raspberry?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As i need this controller to operate in menu, not just in some application, will this work as some mouse or keyboard connected via otg to android and function immediately?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="23129" OwnerDisplayName="Ryder" LastActivityDate="2016-06-17T01:34:03.003" Title="arduino usb android controller" Tags="|android|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25360" PostTypeId="2" ParentId="25359" CreationDate="2016-06-17T01:34:03.003" Score="0" Body="&lt;p&gt;Yes, that rotary encoder is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neither the Nano nor the Uno support that library. You will need a device that has native USB support such as the Leonardo or Due, just like it says on the page.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rotary encoder library you use will tell you how to connect it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for specific Android functionality, you will need to ask on &lt;a href=&quot;https://android.stackexchange.com/&quot;&gt;Android.SE&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="368" LastEditorUserId="-1" LastEditDate="2017-04-13T12:18:37.940" LastActivityDate="2016-06-17T01:34:03.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25361" PostTypeId="2" ParentId="14346" CreationDate="2016-06-17T01:38:19.940" Score="2" Body="&lt;p&gt;You can power the Arduino via the 5V pin - but you need make sure you disconnect it when you are connected via USB - ie. don't power both the 5V pin and via the USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any even better way is to power it from the USB socket - I use those emergency Phone battery packs, but you could cut up a usb cable and use that - this is a much better socket fit to use than the 5v pin and more energy efficient than passing a higher voltage through the 9V supply.&lt;/p&gt;&#xA;" OwnerUserId="23096" LastActivityDate="2016-06-17T01:38:19.940" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25364" PostTypeId="1" CreationDate="2016-06-17T04:12:06.930" Score="1" ViewCount="5903" Body="&lt;p&gt;I am new to Arduino programming, and my first sketch (from a tutorial) failed to upload. I am having trouble trying to figure out what is causing it (have tried to upload the sketch using different COM ports on my Mac). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my setup:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;USB COM Port -&gt; Arduino Mega 2560 -&gt; Grove Mega Shield -&gt; Grove Temperature Sensor&#xA;  v1.2 connected to Mega Shield UART0.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here's the code from the tutorial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Demo code for Grove - Temperature Sensor V1.1/1.2&#xA;// Loovee @ 2015-8-26&#xA;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;//R0 = 100000 results in 'overflow in implicit constant conversion'&#xA;&#xA;const int B=4275;                 // B value of the thermistor&#xA;const int R0 = 100000;            // R0 = 100k&#xA;const int pinTempSensor = A5;     // Grove - Temperature Sensor connect to A5&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int a = analogRead(pinTempSensor );&#xA;&#xA;    float R = 1023.0/((float)a)-1.0;&#xA;    R = 100000.0*R;&#xA;&#xA;    float temperature=1.0/(log(R/100000.0)/B+1/298.15)-273.15;//convert to temperature via datasheet ;&#xA;&#xA;    Serial.print(&quot;temperature = &quot;);&#xA;    Serial.println(temperature);&#xA;&#xA;    delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here's the error output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;avrdude: stk500v2_cmd(): short reply, len = 0&#xA;avr_read(): error reading address 0x0000&#xA;    read operation not supported for memory &quot;signature&quot;&#xA;avrdude: error reading signature data for part &quot;ATmega2560&quot;, rc=-2&#xA;avrdude: error reading signature data, rc=-1&#xA;avrdude: stk500v2_ReceiveMessage(): timeout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I have done so far:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Disconnect and reconnect USB Cable&lt;br&gt;&#xA;2) Restart Arduino IDE (1.6.9)&lt;br&gt;&#xA;3) Changed COM Ports&lt;br&gt;&#xA;4) Press the reset button&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could someone please explain to me what the error output means?&lt;/p&gt;&#xA;" OwnerUserId="23099" LastActivityDate="2017-08-12T04:59:41.560" Title="Timeout error uploading code to Arduino Mega 2560" Tags="|arduino-mega|avrdude|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25365" PostTypeId="2" ParentId="25364" CreationDate="2016-06-17T06:54:30.377" Score="1" Body="&lt;p&gt;Have you tried to upload your sketch without the shields? I had a similar problem once where I couldn't upload while a connection was plugged into UART0. Unplugging the sensor worked for me.&lt;/p&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-06-17T06:54:30.377" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25366" PostTypeId="1" AcceptedAnswerId="25367" CreationDate="2016-06-17T07:23:25.773" Score="2" ViewCount="1558" Body="&lt;p&gt;When I first started with the Arduino environment I noticed that it had &lt;code&gt;File | Preferences | Compiler Warnings&lt;/code&gt; set to &lt;code&gt;None&lt;/code&gt;, so I set it to &lt;code&gt;All&lt;/code&gt; - and there were many, many warnings in the supplied libraries! So I quickly set it to &lt;code&gt;None&lt;/code&gt; again - until later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, &quot;later&quot; is now, and I started going through the warnings to fix the code to quiet the compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note that I don't want to &lt;em&gt;disable&lt;/em&gt; any warnings&lt;/strong&gt; - I want to placate the compiler at each spot so that it says to itself &quot;No problem here!&quot;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the compiler complains of an unused variable, I comment out the variable;&lt;/li&gt;&#xA;&lt;li&gt;If it complains of a signed/unsigned comparison, I change the type;&lt;/li&gt;&#xA;&lt;li&gt;If it complains of an unused parameter in a function, I...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;...hmmm. If this was C++, I'd simply comment out the parameter name, leaving the type naked:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Fn(int /*param*/) {&#xA;} // Fn(param)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino reports:&lt;br&gt;&#xA;    &lt;code&gt;error: parameter name omitted&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But that isn't legal in C. With some compilers you can use the &lt;code&gt;__unused&lt;/code&gt; attribute:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Fn(int __unused param) {&#xA;} // Fn(param)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino reports:&lt;br&gt;&#xA;    &lt;code&gt;error: expected ';', ',' or ')' before 'param'&lt;/code&gt;&lt;br&gt;&#xA;    It's interpreting &lt;code&gt;__unused&lt;/code&gt; as the actual parameter name&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;or if they're fussy:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Fn(int __attribute__((unused)) param) {&#xA;} // Fn(param)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Arduino reports:&lt;br&gt;&#xA;    &lt;code&gt;warning: unused parameter 'param' [-Wunused-parameter]&lt;/code&gt;&lt;br&gt;&#xA;    That's not the correct &lt;code&gt;__attribute__&lt;/code&gt;, obviously&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So none of the above work in the Arduino environment. Suggestions?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I've been programming in C and C++ for over twenty years, and I know that the #1 thing you should always do is ask the compiler to tell you about &lt;strong&gt;everything&lt;/strong&gt; it notices. You need a warning-free compile at all times! Otherwise, you spend hours or &lt;em&gt;days&lt;/em&gt; trying to find a bug - only to discover that the compiler has been warning you about it all along...&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="26916" LastEditDate="2017-11-04T07:01:03.503" LastActivityDate="2017-11-04T07:01:03.503" Title="What is the Arduino compiler's version of `__unused` for function parameters?" Tags="|c|compiler|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25367" PostTypeId="2" ParentId="25366" CreationDate="2016-06-17T07:23:25.773" Score="3" Body="&lt;p&gt;Well, I typed all that question up for posting, then tried one last thing. It worked!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void Fn(__attribute__((unused)) int param) {&#xA;} // Fn(param)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, rather than let a good question go to waste: here's the answer!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now all we need to do is get the maintainers of all the libraries to put these in... and fix the other warnings...&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-17T07:23:25.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25368" PostTypeId="2" ParentId="25364" CreationDate="2016-06-17T07:24:29.540" Score="1" Body="&lt;p&gt;Connect Mega 2560 in one of your port, select the right com port, and try to load the white sketch, look if you obtain the same error.. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//white sketch&#xA;void setup(){}&#xA;void loop(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23103" LastActivityDate="2016-06-17T07:24:29.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25370" PostTypeId="1" AcceptedAnswerId="25371" CreationDate="2016-06-17T09:25:34.983" Score="1" ViewCount="1857" Body="&lt;p&gt;I am connecting 3 accelerometers to an arduino mega. I have everything except how to connect them to the 3.3v pin. I know that I can just connect the 3 of them to the same ground pin but I have been told I can't do the same with 3.3v pin. Can anyone tell me what is the best way to power them from the arduino mega?&lt;/p&gt;&#xA;" OwnerUserId="23105" LastActivityDate="2016-06-17T09:41:35.140" Title="How to connect the 3.3v pin of arduino mega to multiple sensors" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25371" PostTypeId="2" ParentId="25370" CreationDate="2016-06-17T09:41:35.140" Score="3" Body="&lt;p&gt;You can connect all of them as long as the total current draw is not over 50mA as described &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. If you need more than 50mA, you need to create your own 3.3v supply or use something like a breadboard power supply for instance (keep in mind to make a shared ground line).&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-06-17T09:41:35.140" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25372" PostTypeId="1" AcceptedAnswerId="25375" CreationDate="2016-06-17T10:38:42.577" Score="1" ViewCount="1961" Body="&lt;p&gt;Is there a way to get approximate value of &lt;a href=&quot;https://en.wikipedia.org/wiki/Magnetic_declination&quot; rel=&quot;nofollow&quot;&gt;magnetic declination&lt;/a&gt; from GPS coordinates?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino-based device has a Magnetometer and a GPS, and uses magnetic declination in calculations. I would like to avoid having to configure it by hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have found references to &lt;a href=&quot;https://www.ngdc.noaa.gov/geomag/WMM/soft.shtml&quot; rel=&quot;nofollow&quot;&gt;https://www.ngdc.noaa.gov/geomag/WMM/soft.shtml&lt;/a&gt; online, but the site seems to be down (Google has a cache of the site but not of the code).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there another way of getting magnetic declination from GPS coordinates? Doesn't have to be precise, +/- 10% would work just fine.&lt;/p&gt;&#xA;" OwnerUserId="13966" LastActivityDate="2016-06-17T12:28:38.180" Title="Where can I find magnetic declination lookup table?" Tags="|library|gps|magnetometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25375" PostTypeId="2" ParentId="25372" CreationDate="2016-06-17T11:33:15.177" Score="2" Body="&lt;p&gt;No, the North pointed by GPS coordinates are extracted using the velocity heading which would represent the true North. If you get the ECEF (earth centered earth fixed) coordinates from the GPS you can convert it to a local ENU (east north up frame) and calculate the heading from the velocity vectors (take a look &lt;a href=&quot;https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_ECEF_to_ENU&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; if you need the formulas for that). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, this site &lt;a href=&quot;http://www.magnetic-declination.com/&quot; rel=&quot;nofollow&quot;&gt;http://www.magnetic-declination.com/&lt;/a&gt; can provide you a estimate for magnetic declination at your location.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; &#xA;From the comment I came across &lt;a href=&quot;http://diydrones.com/profiles/blogs/new-feature-automatic-compass-declination&quot; rel=&quot;nofollow&quot;&gt;this topic&lt;/a&gt; which lead to &lt;a href=&quot;http://www.societyofrobots.com/robotforum/index.php?topic=11855.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you can play with the code provided and take it as a template for your needs to create a lookup table. The software used for creation of the files is the one present in the site you &lt;a href=&quot;https://www.ngdc.noaa.gov/geomag/WMM/soft.shtml&quot; rel=&quot;nofollow&quot;&gt;pointed&lt;/a&gt;. Just downloaded the linux zip file and tested it with the sample txt coordinates provided and all seems ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the record the command used was (yes for some reason the extension exe is present but this is linux binary):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;./wmm_file.exe f sample_coords.txt out.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which created a out.txt equal to sample output file provided. Now this file can be used by the function &lt;code&gt;void build_lookup_table()&lt;/code&gt; (present on &lt;a href=&quot;http://www.societyofrobots.com/robotforum/index.php?PHPSESSID=96aa505bb519df98640d9d1243f90d3b&amp;amp;action=dlattach;topic=11855.0;attach=4966&quot; rel=&quot;nofollow&quot;&gt;grab60_char.c&lt;/a&gt;) to build the lookup table you need.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastEditorUserId="6826" LastEditDate="2016-06-17T12:28:38.180" LastActivityDate="2016-06-17T12:28:38.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25376" PostTypeId="1" CreationDate="2016-06-17T11:42:10.970" Score="-1" ViewCount="345" Body="&lt;p&gt;I want to write a tree data structure made up of Nodes, but I'm having a problem with my Node.h class as each Node need to have a reference Variable to other Nodes,it's children. which ends up giving me the following error  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;field 'child' has incomplete type&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;so I thought to myself if I was to &lt;code&gt;#include &quot;Node.h&quot;&lt;/code&gt; within my Node.h class which gave another error &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;#include nested too deeply&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;how can I have reference to my child Nodes within my node class &lt;/p&gt;&#xA;" OwnerUserId="22976" LastActivityDate="2016-06-17T15:37:47.427" Title="how to use an object of a class within that same class?" Tags="|programming|data-type|" AnswerCount="2" CommentCount="3" ClosedDate="2017-11-24T20:26:09.893" ContentLicense="CC BY-SA 3.0" />
  <row Id="25378" PostTypeId="1" AcceptedAnswerId="25379" CreationDate="2016-06-17T09:49:29.640" Score="0" ViewCount="71" Body="&lt;p&gt;I am having troubles with my arduino micro.&#xA;In my programming, I am using the serial. When I use println, nothing shows up in the serial monitor except for &lt;code&gt;0&lt;/code&gt;. So if I type &lt;code&gt;1&lt;/code&gt;, I get back &lt;code&gt;0&lt;/code&gt; instead of &lt;code&gt;1&lt;/code&gt;, same goes for &lt;code&gt;3241234&lt;/code&gt; or any random number.&#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600); //Connect to the serial monitor console&#xA;}&#xA;&#xA;void loop() {&#xA;    while (Serial.available() == 0); //Wait until Serial is available&#xA;&#xA;    //Read val&#xA;    int val = Serial.read() - '0'; //Val that represents input&#xA;    delay(500);&#xA;    Serial.println(val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I have another problem and people have asked for the code. Basically, printing a string returns 0.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; void setup() {&#xA;  Serial.begin(9600); //Connect to the serial monitor console&#xA;}&#xA;&#xA;void loop() {&#xA;    while (Serial.available() == 0); //Wait until Serial is available&#xA;&#xA;    //Read val&#xA;    int val = Serial.read(); //Val that represents input&#xA;&#xA;    delay(1000);&#xA;    if (val == 1) {&#xA;      Serial.print('Firing the motor');&#xA;    } else {&#xA;      Serial.print('Please press 1 to fire the motor.');&#xA;    }&#xA;&#xA;    delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead of printing Please press 1 to fire the motor, I get 0 in the console. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="23111" OwnerDisplayName="Tino Caer" LastEditorUserId="23111" LastEditDate="2016-06-17T12:05:26.600" LastActivityDate="2016-06-17T15:12:27.370" Title="Arduino Micro Println prints 0" Tags="|arduino-micro|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25379" PostTypeId="2" ParentId="25378" CreationDate="2016-06-17T11:09:27.543" Score="1" Body="&lt;p&gt;Try without &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- '0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You read your data and save into in int. then print that int, when you pass only the int, you get the int as an ASCII-encoded decimal.&#xA;Why r u doing&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;- '0'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;?&lt;/p&gt;&#xA;" OwnerDisplayName="bloodscript" LastActivityDate="2016-06-17T11:09:27.543" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25380" PostTypeId="2" ParentId="25376" CreationDate="2016-06-17T12:04:46.173" Score="0" Body="&lt;p&gt;You will need to forward declare the class and add a pointer to it from within  the class.  i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class CElement;  // Forward declaration&#xA;&#xA;class CElement&#xA;{&#xA;public:&#xA;    CElement();&#xA;    ... // Other functions&#xA;private:&#xA;    CElement *m_NextElement;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just to be clear you can't have your class as a member variable, it has to be a pointer or a reference.  This is because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can't use a type that hasn't been fully defined.&lt;/li&gt;&#xA;&lt;li&gt;You would end up with your class consuming an infinite amount of memory, because every node would contain a node, which contains a node, etc...&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2016-06-17T14:39:51.043" LastActivityDate="2016-06-17T14:39:51.043" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25381" PostTypeId="2" ParentId="25378" CreationDate="2016-06-17T12:15:16.773" Score="0" Body="&lt;p&gt;This time you are comparing an integer 1 with a character '1'.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val = Serial.read(); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is reading  you pressing the one key and storing it in an integer variable as the number 49 (ASCII '1')  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (val == 1) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are now seeing it 49 is the same as 1, which it isn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make your code easier stick to characters.&lt;br&gt;&#xA;Change the Serial.Read line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char val = Serial.read(); // Val that represents input &#xA;                                // (const because it will not change).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and the if line to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (val == '1')  // '1' character 1 &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By making val const you stop yourself accidentally changing it so if you do &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (val = '4') // Compilation error.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-17T12:15:16.773" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25382" PostTypeId="1" CreationDate="2016-06-17T03:10:14.617" Score="1" ViewCount="470" Body="&lt;p&gt;I've spent all day trying to monitor serial console output of a router. I'm using an &quot;ebay&quot; MAX3232 RS232 to TTL converter connecting only GND, TX and RX to the Electron. Trying to simply monitor the console output during bootup - all I get is gibberish.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even connected to computer's COM1 port and was unable to echo back and forth. All I get is 0 or weird symbols. (this was tried with more code than below)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my most basic code. I'm about ready to give up. Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Particle.h&quot;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600); // tried with 2400/even 1200 really should be 9600&#xA;  Serial.println(&quot;Starting up Serial&quot;);&#xA;  Serial1.println(&quot;Starting up Serial1&quot;);&#xA;} &#xA;&#xA;&#xA;void loop() {&#xA; while(Serial1.available()&amp;gt;0)&#xA; {&#xA;   Serial.write(Serial1.read());&#xA; }&#xA; delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23114" OwnerDisplayName="user1389579" LastActivityDate="2019-10-07T09:50:59.433" Title="Particle Electron to RS232 Serial gibberish" Tags="|serial|rs232|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25383" PostTypeId="2" ParentId="25378" CreationDate="2016-06-17T15:12:27.370" Score="0" Body="&lt;p&gt;To your second question, strings in C are surrounded by the double-quote character: &lt;code&gt;&quot;&lt;/code&gt;, not the the single-quote or apostrophe character.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-17T15:12:27.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25384" PostTypeId="2" ParentId="25376" CreationDate="2016-06-17T15:37:47.427" Score="0" Body="&lt;h3&gt;If you have a class like this:&lt;/h3&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Node {&#xA;&#xA;public: // Methods&#xA;&#xA;    inline Node() :&#xA;           left(nullptr),   // No children yet!&#xA;           right(nullptr) {&#xA;    } // Node()&#xA;&#xA;public: // Variables (normally this should be private, but for this example...)&#xA;&#xA;    Node *left;&#xA;    Node *right;&#xA;&#xA;}; // Node&#xA;&#xA;Node root; // The root of the tree&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You now have a &lt;code&gt;class&lt;/code&gt; that has two members, both pointers to &lt;code&gt;Node&lt;/code&gt;s. Obviously there's going to be more data in there - &lt;code&gt;string&lt;/code&gt;s or whatever - but let's ignore that for now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've also created the &lt;code&gt;root&lt;/code&gt; of the tree - note that I didn't use &lt;code&gt;new&lt;/code&gt;! It's a file variable that is always accessible, and there's not an &lt;code&gt;*&lt;/code&gt; in sight (except inside &lt;code&gt;root&lt;/code&gt;...).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are &lt;code&gt;left&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt;? Pointers to the children. They are &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt;&lt;/em&gt; the children: just pointers to them. As soon as any &lt;code&gt;Node&lt;/code&gt; is created (after the constructor has finished), the &lt;code&gt;Node&lt;/code&gt; has no children - both pointers are &lt;code&gt;nullptr&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So (ignoring any attempt to sort the children into place) you &lt;em&gt;could&lt;/em&gt; now do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void AddChildren() {&#xA;    Node sister;           // Create a sister&#xA;    Node brother;          // Create a brother&#xA;    root.left = &amp;amp;sister;   // Point to sister&#xA;    root.right = &amp;amp;brother; // Point to brother&#xA;} // AddChildren()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note you couldn't do &lt;code&gt;node.left = sister;&lt;/code&gt; - you're not trying to put &lt;code&gt;sister&lt;/code&gt; &lt;em&gt;inside&lt;/em&gt; &lt;code&gt;root&lt;/code&gt;, you're only trying to &lt;em&gt;point&lt;/em&gt; to &lt;code&gt;sister&lt;/code&gt; &lt;em&gt;with&lt;/em&gt; one of &lt;code&gt;root&lt;/code&gt;'s children. So you take &lt;code&gt;sister&lt;/code&gt;'s address with the &lt;code&gt;&amp;amp;&lt;/code&gt; operator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only... as soon as &lt;code&gt;AddChildren()&lt;/code&gt; exits, both &lt;code&gt;sister&lt;/code&gt; and &lt;code&gt;brother&lt;/code&gt; are destroyed (they're local to the function, so get destroyed as the function leaves) - but &lt;code&gt;root&lt;/code&gt; is still pointing to where they used to be! It doesn't know that they are dead!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is why you call &lt;code&gt;new&lt;/code&gt;. It creates the object on the heap rather than the stack, and the object stays around until explicitly destroyed with &lt;code&gt;delete&lt;/code&gt;. Only, &lt;code&gt;new&lt;/code&gt; returns a pointer to the object, not the object itself. So:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void AddChildren() {&#xA;    Node *sister = new Node();  // Point to new object on the heap&#xA;    Node *brother = new Node(); // Point to new object on the heap&#xA;    root.left = sister;         // Already a pointer! Just copy it&#xA;    root.right = brother;       // Already a pointer! Just copy it&#xA;} // AddChildren()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or, perhaps easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void AddChildren() {&#xA;    root.left = new Node();  // Point to new object on the heap&#xA;    root.right = new Node(); // Point to new object on the heap&#xA;} // AddChildren()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, how do you access the different fields inside &lt;code&gt;Node&lt;/code&gt;? It depends on whether you're accessing them through an object or through a pointer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Through an object?&lt;br&gt;&#xA;With &lt;code&gt;.&lt;/code&gt;, like &lt;code&gt;root.left&lt;/code&gt; above&lt;/li&gt;&#xA;&lt;li&gt;Through a pointer?&lt;br&gt;&#xA;Using &lt;code&gt;-&amp;gt;&lt;/code&gt;, such as &lt;code&gt;ptr-&amp;gt;left&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So finally, how can you use it for real?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// TraverseTree is going to call a function that looks like this:&#xA;typedef void TraverseFn(const Node &amp;amp;node);&#xA;&#xA;// Traverse a (sub)tree, calling the passed-in fn() on each Node.&#xA;void TraverseTree(Node *node, TraverseFn *fn) {&#xA;    if (node == nullptr) { // Nothing to traverse!&#xA;        return;&#xA;    } // if&#xA;    TraverseTree(node-&amp;gt;left, fn);  // Trees love recursion!&#xA;    fn(*node);                     // Call the passed-in fn with node&#xA;    TraverseTree(node-&amp;gt;right, fn); // More recursion!&#xA;} // TraverseTree(Node)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can call the above with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// A function to print the contents of Node&#xA;void PrintNode(const Node &amp;amp;node);&#xA;&#xA;// Traverse the whole Tree, from root, calling PrintNode at each Node&#xA;TraverseTree(&amp;amp;root, &amp;amp;PrintNode);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Beware! Do not pass! Here be dragons!&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;(or at least pointers to member functions...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally, I would have put &lt;code&gt;TraverseTree()&lt;/code&gt; inside &lt;code&gt;Node&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Node {&#xA;&#xA;public: // Methods to call with Traverse()&#xA;&#xA;    // Print this Node&#xA;    void Print();&#xA;&#xA;public: // Traverse&#xA;&#xA;    // This is the type of the function that Traverse will call&#xA;    typedef void TraverseFn();&#xA;&#xA;    // Note we're passing in a pointer-to-member-function!&#xA;    void Traverse(TraverseFn Node::*fn) {&#xA;        if (left != nullptr) {&#xA;            left-&amp;gt;Traverse(fn);&#xA;        } // if&#xA;        (this-&amp;gt;*)fn();&#xA;        if (right != nullptr) {&#xA;            right-&amp;gt;Traverse(fn);&#xA;        } // if&#xA;    } // Traverse(fn)&#xA;&#xA;}; // Node&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you do that, you'd print out the tree like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root.Traverse(&amp;amp;Node::Print);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-17T15:37:47.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25385" PostTypeId="1" AcceptedAnswerId="25386" CreationDate="2016-06-17T15:41:19.473" Score="5" ViewCount="286" Body="&lt;p&gt;I'm currently working on a project where I read a 32 bit sequence.&#xA;The digitalPin is always HIGH when no sequence is received and starts oscilating with about 1kHz when the sequence starts (&lt;a href=&quot;http://www.clearwater.com.au/code/rc5&quot; rel=&quot;nofollow noreferrer&quot;&gt;RC5&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;I am setting and clearing bits of an uint32_t depending on which signal is on the digitalPin.&#xA;It seems to work very well with every bit except of the MSB.&lt;/p&gt;&#xA;&lt;p&gt;Here a short code snippet to show what I mean:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const short irPin = 8;&#xA;const short msgDelay = 250;&#xA;&#xA;uint32_t data = 0xFFFFFFFF;&#xA;long msgArrived = 0;&#xA;&#xA;void setup(){&#xA;  Serial.begin(115200);&#xA;  pinMode(irPin, INPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  long now = millis();&#xA;&#xA;  if( (!(PINB &amp;amp; 1)) &amp;amp;&amp;amp; ((now - msgArrived)&amp;gt; msgDelay)){&#xA;    msgArrived = millis();&#xA;    bitClear(data, 31);&#xA;&#xA;    Serial.println(data, BIN);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This gives me an output of&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;11111111111111111111111111111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have already tried&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bitClear(data, 32); -&amp;gt; 11111111111111111111111111111111&#xA;bitClear(data, 30); -&amp;gt; 10111111111111111111111111111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;So every output is right, but not the when I try to clear the msb.&lt;/p&gt;&#xA;&lt;p&gt;Has anyone experienced a similar behaviour?&lt;/p&gt;&#xA;" OwnerUserId="21631" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-06-17T16:50:23.543" Title="bitClear doesn't work on most significant bit" Tags="|arduino-uno|ir|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25386" PostTypeId="2" ParentId="25385" CreationDate="2016-06-17T16:45:06.610" Score="5" Body="&lt;pre&gt;&lt;code&gt;uint32_t data = 0xFFFFFFFF;&#xA;Serial.println(data, BIN);&#xA;data = 0xFFFFFFFF;&#xA;bitClear(data, 30);&#xA;Serial.println(data, BIN);&#xA;data = 0xFFFFFFFF;&#xA;bitClear(data, 31);&#xA;Serial.println(data, BIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my mega outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11111111111111111111111111111111&#xA;10111111111111111111111111111111&#xA;1111111111111111111111111111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Are you sure you aren't mistaking the fact that println doesn't print leading 0's for the number being nothing but 1's? Try printing as hex, then all the numbers will be the same width: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FFFFFFFF&#xA;BFFFFFFF&#xA;7FFFFFFF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2016-06-17T16:50:23.543" LastActivityDate="2016-06-17T16:50:23.543" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25387" PostTypeId="2" ParentId="23809" CreationDate="2016-06-17T17:53:56.933" Score="1" Body="&lt;p&gt;Have you overridden &lt;code&gt;lib_dir&lt;/code&gt; in &lt;code&gt;platformio.ini&lt;/code&gt;? If yes, please remove it.&lt;/p&gt;&#xA;" OwnerUserId="4568" LastActivityDate="2016-06-17T17:53:56.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25389" PostTypeId="1" AcceptedAnswerId="25390" CreationDate="2016-06-17T18:14:07.563" Score="0" ViewCount="2064" Body="&lt;p&gt;On tutorials are most people using the A4&amp;amp;A5 pins with the Wire.h library. But i have an arduino with dedicated I²C pins. How can i use them? &#xA;&lt;img src=&quot;https://i.stack.imgur.com/I8HWi.jpg&quot; alt=&quot;Arduino&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="16897" LastActivityDate="2016-06-17T18:20:14.307" Title="I2C: What is the difference between A4&amp;A5 and SCL&amp;SDA pins?" Tags="|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25390" PostTypeId="2" ParentId="25389" CreationDate="2016-06-17T18:20:14.307" Score="4" Body="&lt;p&gt;They are the same pins. They are physically connected to each other on the UNO board. (So SDA is connected to A4. SCL is connected to A5)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-17T18:20:14.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25391" PostTypeId="1" AcceptedAnswerId="25392" CreationDate="2016-06-17T18:33:10.447" Score="0" ViewCount="7939" Body="&lt;p&gt;I have a void function that helps me set the time on my arduino clock. I need to use the same function twice - once for the alarm and once for the actual time. The variables I am defining need to equal either alarmHours and alarmMinutes, or hours and minutes. This was my solution:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setting(int i){&#xA; if(i==0){&#xA;  int mi=alarmMinutes;&#xA;  int ho=alarmHours;&#xA; }else if(i==1){&#xA;  int mi=minutes;&#xA;  int ho=hours;&#xA; }&#xA;//more code later&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I got an error saying that ho and mi are undefined.&#xA;I fixed this like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setting(int i){&#xA;&#xA; int mi;&#xA; int ho;&#xA;&#xA; if(i==0){&#xA;  mi=alarmMinutes;&#xA;  ho=alarmHours;&#xA; }else if(i==1){&#xA;  mi=minutes;&#xA;  ho=hours;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This solved the problem. Why couldn't I use the first option if I passed in a 0 or a 1 to the parameters of the function?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="28726" LastEditDate="2016-12-21T16:58:09.047" LastActivityDate="2016-12-21T16:58:09.047" Title="Why can't I declare variables inside an if statement?" Tags="|arduino-uno|time|variables|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25392" PostTypeId="2" ParentId="25391" CreationDate="2016-06-17T18:37:09.357" Score="4" Body="&lt;p&gt;Declaring a variable inside a block means that they only exist within that block. Once the block is exited, they become inaccessible.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-17T18:37:09.357" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25393" PostTypeId="2" ParentId="25007" CreationDate="2016-06-17T18:52:42.520" Score="1" Body="&lt;p&gt;It depends on the camera that you're using but you send in impulse just sending digital write signal, waiting a little bit and then turning it off. You do this over and over again until you have all the pixels. Here is an example where I send 128 impulses:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(int i = 0; i &amp;lt; 128; i++)&#xA;  {&#xA;    digitalWrite(CLK, HIGH);&#xA;    delay(1);  &#xA;    digitalWrite(CLK, LOW);&#xA;    delay(1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Depending on the hardware you are using you might have to send a SI (signal impulse) prior to the CLK impulses and the delay in between them will vary. The best thing to do is to read the documentation to find these figures.&lt;/p&gt;&#xA;" OwnerUserId="22750" LastActivityDate="2016-06-17T18:52:42.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25396" PostTypeId="1" CreationDate="2016-06-17T19:51:05.070" Score="4" ViewCount="98" Body="&lt;p&gt;I'm trying to set a 33 ms interrupt on my Arduino Mega and I'm not sure if I a in fact getting that kind of delay time. Is there a way to check?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've calculated that that I need 515.6 ticks to achive this kind of delay with a prescaler of 1024 and I've coded it up like so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setupInterupt()&#xA;{&#xA;  noInterrupts();&#xA;  TCCR2A = 0;             &#xA;  TCCR2B = 0;             &#xA;  TCNT2 = 0;              &#xA;  OCR2A = PERIOD - 1;     &#xA;  TIMSK2 = _BV(OCIE2A);   &#xA;  TCCR2B |= _BV(CS12) | _BV(CS10); // prescale by 1024&#xA;  interrupts();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I followed the information on the Arduino Playground &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;page&lt;/a&gt; and if my math is correct this interrupt should be going off every 33 milliseconds. I tried to test that using the &lt;code&gt;millis();&lt;/code&gt; method but it only returns the time that program was on.&lt;/p&gt;&#xA;" OwnerUserId="22750" LastActivityDate="2016-06-18T00:45:31.730" Title="How can you check how long a timer interrupt really is?" Tags="|arduino-mega|interrupt|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25397" PostTypeId="2" ParentId="25391" CreationDate="2016-06-17T19:57:42.930" Score="2" Body="&lt;p&gt;The problem with doing it how you originally did is that the variables you initialized inside the if statement do not go onto the else statement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is why your solution is correct. You need to declare your variables before going inside of a block in order to use them. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are uses for declaring a variables inside of a block.. but this is not one of them as you realized and fixed.&lt;/p&gt;&#xA;" OwnerUserId="23118" LastActivityDate="2016-06-17T19:57:42.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25398" PostTypeId="1" CreationDate="2016-06-17T20:40:20.303" Score="0" ViewCount="397" Body="&lt;p&gt;I'm trying to program a Timer Interrupt that will go off every 33 ms. I am doing this on the ATtiny85 which has a 20MHz clock. The maximum prescaler I can set is 32 so the longest possible time a single interrupt can be is 408 microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan to reach 33 milliseconds is to just run the interrupt 81 times and that will get me the desired 33 milliseconds. However, I have no clue as to how you can actually count how many time an interrupt has taken place. Anyone on here know how to do that or have any idea as to what would work?&lt;/p&gt;&#xA;" OwnerUserId="22788" LastActivityDate="2016-06-17T20:57:55.813" Title="How can you count the number of interrupts that have taken place?" Tags="|interrupt|attiny|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25399" PostTypeId="2" ParentId="25344" CreationDate="2016-06-17T20:41:20.393" Score="2" Body="&lt;p&gt;I ended finding a Arduino library called &lt;strong&gt;Spritz&lt;/strong&gt; which can be found here:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/abderraouf-adjal/ArduinoSpritzCipher&quot; rel=&quot;nofollow&quot;&gt;https://github.com/abderraouf-adjal/ArduinoSpritzCipher&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, for anyone else who comes across this task, here is a &lt;em&gt;very simple&lt;/em&gt; Hashed Message Authentication Code (HMAC) example I scrapped together:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/zach-king/ArduinoStash/blob/master/src/Spritz_HMAC/Spritz_HMAC.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/zach-king/ArduinoStash/blob/master/src/Spritz_HMAC/Spritz_HMAC.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This library supports encryption as well, which is nice, but not needed in my case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;--EDIT--&lt;br&gt;&#xA;The SpritzCipher library was actually too slow (about a 50% reduction in network speed) so I must try a different approach. I have found a MD5 library for Arduino which I will try next:&lt;br&gt;&#xA;&lt;a href=&quot;https://github.com/tzikis/ArduinoMD5&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tzikis/ArduinoMD5&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23087" LastEditorUserId="23087" LastEditDate="2016-06-22T19:24:53.607" LastActivityDate="2016-06-22T19:24:53.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25400" PostTypeId="2" ParentId="25398" CreationDate="2016-06-17T20:57:55.813" Score="2" Body="&lt;p&gt;Yes, just add a check inside your ISR statement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(TIMER0_OVF_vect)&#xA;{&#xA;  static uint8_t postscale = 0;&#xA;  if (++postscale == 81) &#xA;  {&#xA;    postscale = 0;&#xA;    do_stuff();&#xA;  }&#xA;  else&#xA;  {&#xA;    go_to_sleep();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You always have to enter the ISR method once you're done with the interrupt so just add that if statement and use a static variable (so that it keeps its value) to check if you have made the correct number of loops.&lt;/p&gt;&#xA;" OwnerUserId="22750" LastActivityDate="2016-06-17T20:57:55.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25401" PostTypeId="2" ParentId="25396" CreationDate="2016-06-17T22:20:42.627" Score="2" Body="&lt;p&gt;It doesn't fire every 33 milliseconds. First, you missed setting the CSn1 bit necessary for a 1024 prescaler; second, It looks like you want CTC mode (where the timer resets at OCRnA) but you didn't set the WGM21 bit necessary for that mode. After that your problem is that timer2 is an 8 bit timer and so OCR2A cannot store 515, but you math is correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can get the period you want on a 16-bit timer; on the arduino mega thats timers 1,3,4, and 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway here is a simple sketch for finding the average interval between interrupts. It just keeps track of the total time elapsed and the number of times the interrupt fired; the ratio of these two is the average time per interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, with a prescaler of 1024, OCRA = 0xFF, and CTC mode, it runs at an interrupt every 16.384 ms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;volatile uint16_t interruptCount;&#xA;volatile uint32_t start;&#xA;&#xA;ISR(TIMER2_COMPA_vect){&#xA;    interruptCount++;&#xA;}&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;&#xA;    noInterrupts();&#xA;    TCCR2A = _BV(WGM21);&#xA;    TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); // prescale by 1024&#xA;    OCR2A = 0xFF;&#xA;    TIMSK2 = _BV(OCIE2A);&#xA;    // start the timer&#xA;    interruptCount = 0;&#xA;    start = micros();&#xA;    interrupts();&#xA;}&#xA;&#xA;void loop(){&#xA;    // read interrupt count into a local variable atomically&#xA;    noInterrupts();&#xA;    uint16_t localCount = interruptCount;&#xA;    interrupts();&#xA;    uint32_t time = micros() - start;&#xA;&#xA;    // time elapsed&#xA;    Serial.print(time);&#xA;    Serial.print(&quot; &quot;);&#xA;&#xA;    // number of times the interrupt handler fired&#xA;    Serial.print(localCount);&#xA;    Serial.print(&quot; &quot;);&#xA;&#xA;    // average number of microseconds per interrupt&#xA;    Serial.print(time / localCount);&#xA;    Serial.println();&#xA;&#xA;    delay(30);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="1585" LastEditorUserId="1585" LastEditDate="2016-06-18T00:45:31.730" LastActivityDate="2016-06-18T00:45:31.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25402" PostTypeId="1" CreationDate="2016-06-17T23:12:30.477" Score="1" ViewCount="825" Body="&lt;p&gt;i made a weather station which is build on a ATmega2560 mini pro, Esp8266 module which communicate with atmega on serial1 which sends values to thingspeak, an TSL2561, 2.4 tft lcd, BMP180, DHT22 and a dust sensor module PMS5003 which is set on serial3 on mega2560.&#xA;I made the wiring, program etc. the weather station is working fine for some days when it freezes. The problem is that thingspeak reports that it receive some data every 6 mins like i set it but the data received is blank. Not 0, or any other value, just blank data.&#xA;I'm thinking it could be a problem with SRAM since it loses the values it reads. But why the loop is still working since it sends blank data to thingspeak ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Atmega reads all values from sensors, then communicates with esp8266 by serial and using AT commands it sends the values read to thingspeak. So in my opinion it reads the values, but it won't stores them, then it sending blank data to thingspeak.&#xA;If i reset the arduino it works fine for some days when suddenly it decides to stop working.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After compiling the program the arduino ide is reporting this: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch uses 28,890 bytes (11%) of program storage space. Maximum is 253,952 bytes.&#xA;Global variables use 1,800 bytes (21%) of dynamic memory, leaving 6,392 bytes for local variables. Maximum is 8,192 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my program it's not filling the SRAM.&#xA;I'm a beginner in C++ so i tried to do my best with programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link to thingspeak weather station: &lt;a href=&quot;https://thingspeak.com/channels/116912&quot; rel=&quot;nofollow&quot;&gt;https://thingspeak.com/channels/116912&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SFE_BMP180.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;#include &amp;lt;Adafruit_TSL2561_U.h&amp;gt;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;    // Core graphics library&#xA;#include &quot;SWTFT.h&quot; // Hardware-specific library&#xA;&#xA;#define DHTPIN 25     // what pin we're connected to&#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;#define ALTITUDE 320.0 // Altitude in Grasse&#xA;&#xA;&#xA;// Assign human-readable names to some common 16-bit color values:&#xA;#define  BLACK   0x0000&#xA;#define BLUE    0x001F&#xA;#define RED     0xF800&#xA;#define GREEN   0x07E0&#xA;#define CYAN    0x07FF&#xA;#define MAGENTA 0xF81F&#xA;#define YELLOW  0xFFE0&#xA;#define WHITE   0xFFFF&#xA;&#xA;SWTFT tft;&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino&#xA;SFE_BMP180 pressure;&#xA;&#xA;Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);&#xA;&#xA;//double bmptemp; //temp bmp rectificata cu 1.9 grade -&#xA;float hum;  //Stores humidity value&#xA;float temp; //Stores temperature value&#xA;float lux; //Stores lux luminosity&#xA;char status; //used by bmp180&#xA;double T,P,p0; //p0 - sea-level compensated pressure in mb, T - temperature, P = absolute pressure in mb&#xA;&#xA;&#xA;#define IP &quot;184.106.153.149&quot; // thingspeak.com IP address; see their website for more detail&#xA;String GET = &quot;GET /update?key=NWHWO6SLWNJP3HGQ&quot;; // you channel will have unique code&#xA;int concentration=0;&#xA;&#xA;//cod dust sensor&#xA;#define LENG 31   //0x42 + 31 bytes equal to 32 bytes&#xA;unsigned char buf[LENG];&#xA;&#xA;int PM01Value=0;          //define PM1.0 value of the air detector module&#xA;int PM2_5Value=0;         //define PM2.5 value of the air detector module&#xA;int PM10Value=0;         //define PM10 value of the air detector module&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(17, OUTPUT); //pin pt esp - on /off&#xA;  pinMode(16, OUTPUT); //pin buzzer&#xA;  pinMode(31, OUTPUT); //pin on/off dust sensor&#xA;&#xA;  Serial.begin(9600); // this is to start serial monitoring with your Arduino IDE Serial monitor.&#xA;  Serial1.begin(9600); // this is to start serial communication with the ESP via Software Serial.&#xA;  Serial3.begin(9600); //serial dust sensor&#xA;&#xA;&#xA;&#xA;  Serial.println(&quot;Begin&quot;);&#xA;  tft.reset();&#xA;  uint16_t identifier = tft.readID();&#xA;  tft.begin(identifier);&#xA;&#xA;&#xA;  dht.begin();&#xA;&#xA;  if (!pressure.begin()) {&#xA;    Serial.println(&quot;BMP180 init fail&quot;); // Oops, something went wrong, this is usually a connection problem,&#xA;    while(1); // Pause forever.&#xA;    }&#xA;&#xA;  if(!tsl.begin()) {&#xA;    /* There was a problem detecting the ADXL345 ... check your connections */&#xA;    Serial.print(&quot;Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!&quot;);&#xA;    while(1);&#xA;  }&#xA;  //tsl.setGain(TSL2561_GAIN_1X);      /* No gain ... use in bright light to avoid sensor saturation */&#xA;  //tsl.setGain(TSL2561_GAIN_16X);     /* 16x gain ... use in low light to boost sensitivity */&#xA;  tsl.enableAutoRange(true);            /* Auto-gain ... switches automatically between 1x and 16x */&#xA;  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */&#xA;&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  digitalWrite(31, LOW);&#xA;  digitalWrite(17, LOW);&#xA;  Serial.println(&quot;-----------------------&quot;);&#xA;  dht22 ();&#xA;  bmp120 ();&#xA;  tsl2561();&#xA;  dust();&#xA;  Serial.println(&quot;-----------------------&quot;);&#xA;&#xA;&#xA;  tft.fillScreen(BLACK);&#xA;  tft.setRotation(1);&#xA;  tft.setCursor(0, 0);&#xA;&#xA;  tft.setTextColor(GREEN);    &#xA;  tft.setTextSize(2);&#xA;  tft.println(&quot;DHT22&quot;);&#xA;  tft.setTextColor(WHITE);    &#xA;  tft.setTextSize(2);&#xA;  tft.print(&quot;Temperature = &quot;);&#xA;  tft.print(temp);&#xA;  tft.println(&quot; C&quot;);&#xA;  tft.print(&quot;Humidite = &quot;);&#xA;  tft.print(hum);&#xA;  tft.println(&quot; %&quot;);&#xA;  tft.println();&#xA;&#xA;  tft.setTextColor(GREEN);    &#xA;  tft.setTextSize(2);&#xA;  tft.println(&quot;BMP180&quot;);&#xA;  tft.setTextColor(WHITE);    &#xA;  tft.setTextSize(2);&#xA;  tft.print(&quot;Temperature = &quot;);&#xA;  tft.print(T);&#xA;  tft.println(&quot; C&quot;);&#xA;  tft.print(&quot;Pression = &quot;);&#xA;  tft.print(p0);&#xA;  tft.println(&quot; mb&quot;);&#xA;  tft.println();&#xA;&#xA;  tft.setTextColor(GREEN);    &#xA;  tft.setTextSize(2);&#xA;  tft.println(&quot;TSL2561&quot;);&#xA;  tft.setTextColor(WHITE);    &#xA;  tft.setTextSize(2);&#xA;  tft.print(&quot;Luminosite = &quot;);&#xA;  tft.print(lux);&#xA;  tft.println(&quot; Lux&quot;);&#xA;  tft.println();&#xA;&#xA;&#xA;  tft.setTextColor(GREEN);    &#xA;  tft.setTextSize(2);&#xA;  tft.println(&quot;Pollution aux particules&quot;);&#xA;  tft.setTextColor(WHITE);    &#xA;  tft.setTextSize(2);&#xA;  //tft.println(&quot;Concentration - ug/m3&quot;);&#xA;  tft.print(&quot;PM1.0: &quot;);&#xA;  tft.print(PM01Value);&#xA;  tft.println(&quot; ug/m3&quot;);&#xA;  tft.print(&quot;PM2.5: &quot;);&#xA;  tft.print(PM2_5Value);&#xA;  tft.println(&quot; ug/m3&quot;);&#xA;  tft.print(&quot;PM10: &quot;);&#xA;  tft.print(PM10Value);&#xA;  tft.println(&quot; ug/m3&quot;);&#xA;  //tft.println(&quot;Pcs/0.01cf&quot;);  &#xA;&#xA;&#xA;&#xA;&#xA;  String tempdht22 = String(temp);// turn integer to string&#xA;  String humdht22 = String(hum);&#xA;  String tempbmp180 = String(T);&#xA;  String pressbmp180 = String(p0);&#xA;  String lum = String(lux);&#xA;  String pol01 = String(PM01Value);&#xA;  String pol25 = String(PM2_5Value);&#xA;  String pol10 = String(PM10Value);&#xA;  esp8266(tempdht22, humdht22, tempbmp180, pressbmp180, lum, pol01, pol25, pol10);&#xA;  Serial.println(&quot;Waiting..&quot;);&#xA;  delay(300000);&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void dht22 () {&#xA;//Read data and store it to variables hum and temp&#xA;    hum = dht.readHumidity();&#xA;    temp= dht.readTemperature();&#xA;    //Print temp and humidity values to serial monitor&#xA;    Serial.print(&quot;Humidity: &quot;);&#xA;    Serial.print(hum);&#xA;    Serial.println(&quot; % &quot;);&#xA;    Serial.print(&quot;Temp: &quot;);&#xA;    Serial.print(temp);&#xA;    Serial.println(&quot; C&quot;); &#xA;}&#xA;&#xA;//cod pt dust sensor &#xA;void dust () {&#xA;  digitalWrite(31, HIGH);&#xA;  Serial.println(&quot;High Pms5003&quot;);&#xA;  delay(5000);&#xA;  for (int i=0; i &amp;lt;= 60; i++){&#xA;  if(Serial3.find(0x42)){    //start to read when detect 0x42&#xA;    Serial3.readBytes(buf,LENG);&#xA;&#xA;    if(buf[0] == 0x4d){&#xA;      if(checkValue(buf,LENG)){&#xA;        PM01Value=transmitPM01(buf); //count PM1.0 value of the air detector module&#xA;        PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module&#xA;        PM10Value=transmitPM10(buf); //count PM10 value of the air detector module &#xA;      }           &#xA;    } &#xA;  }&#xA;&#xA;  Serial.print(&quot;PM1.0: &quot;);  &#xA;  Serial.print(PM01Value);&#xA;  Serial.println(&quot;  ug/m3&quot;);            &#xA;&#xA;  Serial.print(&quot;PM2.5: &quot;);  &#xA;  Serial.print(PM2_5Value);&#xA;  Serial.println(&quot;  ug/m3&quot;);     &#xA;&#xA;  Serial.print(&quot;PM10: &quot;);  &#xA;  Serial.print(PM10Value);&#xA;  Serial.println(&quot;  ug/m3&quot;);   &#xA;  Serial.println();&#xA;  delay(1000);&#xA;  }&#xA;  delay(1000);&#xA;  Serial.println(&quot;Low Pms5003&quot;);&#xA;  digitalWrite(31, LOW);&#xA;}&#xA;&#xA;char checkValue(unsigned char *thebuf, char leng)&#xA;{  &#xA;  char receiveflag=0;&#xA;  int receiveSum=0;&#xA;&#xA;  for(int i=0; i&amp;lt;(leng-2); i++){&#xA;  receiveSum=receiveSum+thebuf[i];&#xA;  }&#xA;  receiveSum=receiveSum + 0x42;&#xA;&#xA;  if(receiveSum == ((thebuf[leng-2]&amp;lt;&amp;lt;8)+thebuf[leng-1]))  //check the serial data &#xA;  {&#xA;    receiveSum = 0;&#xA;    receiveflag = 1;&#xA;  }&#xA;  return receiveflag;&#xA;}&#xA;&#xA;int transmitPM01(unsigned char *thebuf)&#xA;{&#xA;  int PM01Val;&#xA;  PM01Val=((thebuf[3]&amp;lt;&amp;lt;8) + thebuf[4]); //count PM1.0 value of the air detector module&#xA;  return PM01Val;&#xA;}&#xA;&#xA;//transmit PM Value to PC&#xA;int transmitPM2_5(unsigned char *thebuf)&#xA;{&#xA;  int PM2_5Val;&#xA;  PM2_5Val=((thebuf[5]&amp;lt;&amp;lt;8) + thebuf[6]);//count PM2.5 value of the air detector module&#xA;  return PM2_5Val;&#xA;  }&#xA;&#xA;//transmit PM Value to PC&#xA;int transmitPM10(unsigned char *thebuf)&#xA;{&#xA;  int PM10Val;&#xA;  PM10Val=((thebuf[7]&amp;lt;&amp;lt;8) + thebuf[8]); //count PM10 value of the air detector module  &#xA;  return PM10Val;&#xA;} //cod dust sensor&#xA;&#xA;void bmp120 () {&#xA;  status = pressure.startTemperature();&#xA;  if (status != 0)&#xA;  {&#xA;    // Wait for the measurement to complete:&#xA;    delay(status);&#xA;&#xA;    // Retrieve the completed temperature measurement:&#xA;    // Note that the measurement is stored in the variable T.&#xA;    // Function returns 1 if successful, 0 if failure.&#xA;&#xA;    status = pressure.getTemperature(T);&#xA;    if (status != 0)&#xA;    {&#xA;      // Print out the measurement:&#xA;      Serial.print(&quot;Temp2: &quot;);&#xA;      Serial.print(T);&#xA;      Serial.println(&quot; C &quot;);&#xA;&#xA;&#xA;      // Start a pressure measurement:&#xA;      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).&#xA;      // If request is successful, the number of ms to wait is returned.&#xA;      // If request is unsuccessful, 0 is returned.&#xA;&#xA;      status = pressure.startPressure(3);&#xA;      if (status != 0)&#xA;      {&#xA;        // Wait for the measurement to complete:&#xA;        delay(status);&#xA;&#xA;        // Retrieve the completed pressure measurement:&#xA;        // Note that the measurement is stored in the variable P.&#xA;        // Note also that the function requires the previous temperature measurement (T).&#xA;        // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)&#xA;        // Function returns 1 if successful, 0 if failure.&#xA;&#xA;        status = pressure.getPressure(P,T);&#xA;        if (status != 0)&#xA;        {&#xA;&#xA;          // The pressure sensor returns abolute pressure, which varies with altitude.&#xA;          // To remove the effects of altitude, use the sealevel function and your current altitude.&#xA;          // This number is commonly used in weather reports.&#xA;          // Parameters: P = absolute pressure in mb, ALTITUDE = current altitude in m.&#xA;          // Result: p0 = sea-level compensated pressure in mb&#xA;&#xA;          p0 = pressure.sealevel(P,ALTITUDE); // we're at 1655 meters (Boulder, CO)&#xA;          Serial.print(&quot;Pressure: &quot;);&#xA;          Serial.print(p0);&#xA;          Serial.println(&quot; mb&quot;);&#xA;        }&#xA;        else Serial.println(&quot;error retrieving pressure measurement\n&quot;);&#xA;      }&#xA;      else Serial.println(&quot;error starting pressure measurement\n&quot;);&#xA;    }&#xA;    else Serial.println(&quot;error retrieving temperature measurement\n&quot;);&#xA;  }&#xA;  else Serial.println(&quot;error starting temperature measurement\n&quot;);&#xA;}&#xA;&#xA;void tsl2561 () {&#xA;  /* Get a new sensor event */ &#xA;  sensors_event_t event;&#xA;  tsl.getEvent(&amp;amp;event);&#xA;&#xA;  /* Display the results (light is measured in lux) */&#xA;  if (event.light)&#xA;  {&#xA;    Serial.print(event.light); Serial.println(&quot; lux&quot;); lux = event.light;&#xA;  }&#xA;  else&#xA;  {&#xA;    /* If event.light = 0 lux the sensor is probably saturated&#xA;       and no reliable data could be generated! */&#xA;    Serial.println(&quot;0 lux&quot;);&#xA;  }&#xA;}&#xA;&#xA;&#xA;&#xA;void esp8266( String temp1, String humm, String temp2, String pression, String luminosite, String pol001, String pol025, String pol010) {&#xA;  //update value on thingspeak&#xA;  digitalWrite(17, HIGH);&#xA;  Serial.println(&quot;High ESP8266&quot;);&#xA;  delay(4000);&#xA;  Serial1.println(&quot;AT+RST&quot;); // this resets the ESP8266.&#xA;  Serial.println(&quot;AT+RST&quot;); // this is just echoing the command to your serial monitor so you can follow what is going on&#xA;  delay(2000);&#xA;  Serial1.println(&quot;AT&quot;);&#xA;  Serial.println(&quot;AT&quot;);&#xA;  delay(5000);&#xA;  if(Serial1.find(&quot;OK&quot;)){&#xA;      Serial.println(&quot;OK&quot;);&#xA;      Serial.println(&quot;Connected&quot;);&#xA;  }   &#xA;&#xA;  Serial.println(&quot;in the update loop&quot;); &#xA;  //ESP8266.println(&quot;AT+RST&quot;); // it seems that mine works better if I reset it everytime before I do CIPSTART&#xA;  //Serial.println(&quot;AT+RST&quot;);&#xA;  //delay(5000);&#xA;  String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;; //standard code. see https://github.com/espressif/esp8266_at/wiki //&#xA;  cmd += IP; // += is concatenating the previous cmd string with the content of IP&#xA;  cmd += &quot;\&quot;,80&quot;; // same thing here it just keep adding stuff to the cmd string content&#xA;  Serial1.println(cmd);//type in the string in cmd into the ESP8266&#xA;  Serial.println(cmd);&#xA;  delay(1000);&#xA;&#xA;  if(Serial1.find(&quot;Error&quot;)){&#xA;    Serial.println(&quot;AT+CIPSTART Error&quot;);&#xA;    digitalWrite(16, HIGH);   &#xA;    delay(250);              &#xA;    digitalWrite(16, LOW);   &#xA;    return;&#xA;  }&#xA;  cmd = GET + &quot;&amp;amp;field1=&quot; + temp1 + &quot;&amp;amp;field2=&quot; + humm + &quot;&amp;amp;field3=&quot; + temp2 + &quot;&amp;amp;field4=&quot; + pression + &quot;&amp;amp;field5=&quot; + luminosite + &quot;&amp;amp;field6=&quot; + pol001 + &quot;&amp;amp;field7=&quot; + pol025 + &quot;&amp;amp;field8=&quot; + pol010 + &quot;\r\n\r\n&quot;;&#xA;  Serial1.print(&quot;AT+CIPSEND=&quot;); &#xA;  Serial1.println(cmd.length());&#xA;  Serial.print(&quot;AT+CIPSEND=&quot;);&#xA;  Serial.println(cmd.length());&#xA;  delay(1000);&#xA;  if(Serial1.find(&quot;&amp;gt;&quot;)){ // if ESP8266 return the &amp;gt; prompt back from the CIPSEND command, you are set, if not something is wrong&#xA;    Serial1.print(cmd); //type in the GET command string and done&#xA;    Serial.print(&quot;&amp;gt;&quot;);&#xA;    Serial.println(cmd);&#xA;    Serial.println(&quot;OK Sent&quot;);    &#xA;  }&#xA;  else&#xA;  {&#xA;   Serial.println(&quot;AT+CIPSEND error&quot;);&#xA;    digitalWrite(16, HIGH);   &#xA;    delay(250);              &#xA;    digitalWrite(16, LOW);    &#xA;  }&#xA;  delay(1000);&#xA;  digitalWrite(17, LOW);&#xA;  Serial.println(&quot;Low ESP8266&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here i uploaded the data file from thingspeak. You can see that until 2016-06-17 14:58:00 UTC it was working fine then thingspeak started receiving blank data. It received something but only blank data. &#xA;The weather station is in another location so i don't have acces all time to reset it.&#xA;&lt;a href=&quot;http://www.filedropper.com/feeds8&quot; rel=&quot;nofollow&quot;&gt;http://www.filedropper.com/feeds8&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Shown below are some lines from the front, the transition point, and the end of the &lt;a href=&quot;http://www.filedropper.com/feeds8&quot; rel=&quot;nofollow&quot;&gt;feeds (8).csv&lt;/a&gt; file at Andrei's filedropper link. – jw]&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;created_at,entry_id,field1,field2,field3,field4,field5,field6,field7,field8&#xA;2016-06-16 05:50:45 UTC,1,19.10,92.70,20.80,1003.02,1512.00,8,15,15&#xA;2016-06-16 05:55:07 UTC,2,19.00,94.00,20.91,1003.09,1659.00,41,54,61&#xA;2016-06-16 06:01:32 UTC,3,19.10,92.70,20.98,1003.11,2233.00,6,7,12&#xA;2016-06-16 06:07:57 UTC,4,19.00,92.90,21.16,1003.11,2620.00,6,7,11&#xA;2016-06-16 06:14:22 UTC,5,19.10,92.70,21.19,1002.97,2701.00,6,6,12&#xA;2016-06-16 06:20:48 UTC,6,19.10,92.20,21.44,1002.97,2973.00,220,291,327&#xA;2016-06-16 06:27:13 UTC,7,19.30,92.20,21.47,1002.99,3197.00,5,6,7&#xA;...&#xA;2016-06-17 14:19:30 UTC,305,22.70,50.50,23.43,1013.88,1956.00,1,1,1&#xA;2016-06-17 14:25:55 UTC,306,22.60,51.20,23.27,1013.88,1979.00,1,1,1&#xA;2016-06-17 14:32:20 UTC,307,22.70,50.10,23.18,1014.00,1962.00,1,1,1&#xA;2016-06-17 14:38:45 UTC,308,22.70,49.50,23.17,1014.03,1967.00,1,1,1&#xA;2016-06-17 14:45:10 UTC,309,22.50,50.90,23.55,1014.01,1856.00,2,2,2&#xA;2016-06-17 14:51:35 UTC,310,22.60,51.80,23.62,1013.99,1870.00,1,1,1&#xA;2016-06-17 14:58:00 UTC,311,22.60,50.80,23.21,1013.94,1987.00,1,2,2&#xA;2016-06-17 15:04:26 UTC,312,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:10:51 UTC,313,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:17:16 UTC,314,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:23:41 UTC,315,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:30:06 UTC,316,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:36:31 UTC,317,&quot;&quot;,,,,,,,&#xA;2016-06-17 15:42:56 UTC,318,&quot;&quot;,,,,,,,&#xA;...&#xA;2016-06-17 22:59:18 UTC,386,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:05:43 UTC,387,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:12:08 UTC,388,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:18:33 UTC,389,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:24:58 UTC,390,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:31:23 UTC,391,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:37:48 UTC,392,&quot;&quot;,,,,,,,&#xA;2016-06-17 23:44:13 UTC,393,&quot;&quot;,,,,,,,&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I went and saw the station, it's more like an electrical problem imo because if i reset arduino nothing happens. The data readed by arduino on dht22 is nan and the rest of the sensors is working fine. The only way i could make dht22 reading again is to unplug the power and plug it back. So that's why i think it's more an electrical problem but can't figure why dht22 stops responding and need to switch off all power to bring it back to life. I will try putting an capacitor on wires to dht22 to see if it's better. &lt;/p&gt;&#xA;" OwnerUserId="23121" LastEditorUserId="23121" LastEditDate="2016-06-18T11:08:30.540" LastActivityDate="2017-03-16T01:05:47.507" Title="Atmega2560 + weather station freezing" Tags="|arduino-mega|programming|sram|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25403" PostTypeId="1" CreationDate="2016-06-18T00:01:19.590" Score="0" ViewCount="480" Body="&lt;p&gt;I'm trying to rename pins so that they post as some kind of alpha-numeric combination in a database.  For example, if I define the following....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define APLHA 0&#xA;#define BRAVO 2&#xA;#define CHARLIE 5&#xA;#define DELTA 6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...I would like to rename the output of the pins, as recorded in the db, as something other than 0, 2, 5, and 6 (or whatever pin is used). Let's say A, B,C, and D for the purposes of this exercise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this just as simple as creating if() function that is called upon prior to posting to the db (ex. if 0 then A, if 2, then B, etc)?  I feel like there must be a better, dare I say more elegant(?), way of doing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Current output:&lt;br&gt;&#xA;PIN | VALUE&lt;br&gt;&#xA;0  |   1&lt;br&gt;&#xA; 2  |   1&lt;br&gt;&#xA; 5  |   0&lt;br&gt;&#xA; 6  |   0&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Desired:&lt;br&gt;&#xA;PIN | VALUE&lt;br&gt;&#xA; A  |   1&lt;br&gt;&#xA; B  |   1&lt;br&gt;&#xA; C  |   0&lt;br&gt;&#xA; D  |   0&lt;br&gt;&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="13355" LastEditDate="2016-06-21T05:35:45.713" LastActivityDate="2016-06-21T05:35:45.713" Title="Renaming pins in sketch" Tags="|pins|datalogging|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25409" PostTypeId="2" ParentId="25268" CreationDate="2016-06-18T09:15:16.177" Score="1" Body="&lt;p&gt;Nick Gammon's answer is good for one &lt;code&gt;Timer&lt;/code&gt; - but now you want two!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK, then you can take advantage of the Timer Library's &lt;code&gt;context&lt;/code&gt; parameter. What's that? If you take a look at the header for &lt;code&gt;every()&lt;/code&gt;, you'll see as well as passing in the function to call, you can &lt;em&gt;also&lt;/em&gt; pass in another value (called &lt;code&gt;context&lt;/code&gt;) to pass back to that function when it fires*. So instead of you remembering just one copy of &lt;code&gt;instance&lt;/code&gt;, get each &lt;code&gt;Timer&lt;/code&gt; to remember it for you.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;*If you can't see the &lt;code&gt;context&lt;/code&gt; parameter in &lt;code&gt;Timer.h&lt;/code&gt;, then make sure you're using the &lt;a href=&quot;https://github.com/JChristensen/Timer/tree/v2.1&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;v2.1&lt;/code&gt;&lt;/a&gt; branch, &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt;&lt;/em&gt; &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get rid of &lt;code&gt;_instance&lt;/code&gt; everywhere.&lt;/li&gt;&#xA;&lt;li&gt;Change:&lt;br&gt;&#xA;&lt;code&gt;static void _callbackGlue();&lt;/code&gt;&lt;br&gt;&#xA;to&lt;br&gt;&#xA;&lt;code&gt;static void _callbackGlue(void *context);&lt;/code&gt;  &lt;/li&gt;&#xA;&lt;li&gt;Change:&lt;br&gt;&#xA;&lt;code&gt;void Blink::_callbackGlue()&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;{&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;_instance-&amp;gt;_callback();&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;&#xA;to&lt;br&gt;&#xA;&lt;code&gt;void Blink::_callbackGlue(void *context)&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;{&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;((Blink *)context)-&amp;gt;_callback();&lt;/code&gt;&lt;br&gt;&#xA;&lt;code&gt;}&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Change:&lt;br&gt;&#xA;&lt;code&gt;_blink_event = _blink_timer-&amp;gt;every(_duration, _callbackGlue);&lt;/code&gt;&lt;br&gt;&#xA;to&lt;br&gt;&#xA;&lt;code&gt;_blink_event = _blink_timer-&amp;gt;every(_duration, _callbackGlue, this);&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Note that I've submitted these changes as a Pull Request on your GitHub repo.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Incidentally:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't need &lt;code&gt;_blink_timer&lt;/code&gt; to be a pointer. Get rid of the &lt;code&gt;*&lt;/code&gt;, get rid of the line with &lt;code&gt;new Timer()&lt;/code&gt; in it, and replace all your &lt;code&gt;_blink_timer-&amp;gt;&lt;/code&gt; with &lt;code&gt;_blink_timer.&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-06-18T11:12:01.050" LastActivityDate="2016-06-18T11:12:01.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25411" PostTypeId="1" CreationDate="2016-06-18T09:33:47.777" Score="1" ViewCount="2158" Body="&lt;p&gt;I recently bought an MFRC522 RFID module to use with my Arduino Uno, which came as a kit with a couple of MiFare 1K cards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The issue I've been having is that, I cannot scan cards consecutively (the same card or two different ones) without resetting the Sketch.  I hold a card in front of the reader and it is scanned, but when I hold another card in front of the reader it just doesn't recognize it as being there in the &lt;code&gt;mfrc522.PICC_IsNewCardPresent()&lt;/code&gt; function.  It does however work when using the example sketch &quot;DumpInfo&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I've written (please excuse any of my bad practices/untidiness).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Include Required Libraries */&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;/* Define Values for MFRC522 */&#xA;#define RST_PIN 9&#xA;#define SS_PIN 10&#xA;&#xA;/* Instantiate the MFRC522 Object */&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);&#xA;&#xA;/* Initialize Variables */&#xA;byte resultBuffer[18];&#xA;MFRC522::MIFARE_Key key;&#xA;unsigned int integerValue = 0;&#xA;char incomingByte;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  SPI.begin();&#xA;  mfrc522.PCD_Init();&#xA;  Serial.println(F(&quot;Ready to scan card...&quot;));&#xA;&#xA;  for (byte i = 0; i &amp;lt; 6; i++)&#xA;  {&#xA;    key.keyByte[i] = 0xFF;&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (!mfrc522.PICC_IsNewCardPresent())&#xA;  {&#xA;    if (Serial.available() &amp;lt;= 0)&#xA;    {&#xA;      return;&#xA;    }&#xA;&#xA;    integerValue = 0;&#xA;    while(true)&#xA;    {&#xA;      incomingByte = Serial.read();&#xA;      if (incomingByte == '\n') break;&#xA;      if (incomingByte == -1) continue;&#xA;      integerValue *= 10;&#xA;      integerValue = ((incomingByte - 48) + integerValue);&#xA;    }&#xA;&#xA;    printHeader();&#xA;    Serial.println(&quot;NEW BLOCK READ VALUE :&quot;);&#xA;    Serial.println(integerValue);&#xA;  }&#xA;&#xA;  if (!mfrc522.PICC_ReadCardSerial())&#xA;  {&#xA;    return;&#xA;  }&#xA;&#xA;  readAndPrint(integerValue);&#xA;}&#xA;&#xA;void printHeader()&#xA;{&#xA;  Serial.println(&quot; &quot;);&#xA;  Serial.println(&quot;----------------------------------------&quot;);&#xA;}&#xA;&#xA;int authenticateKeyA(int blockNumber)&#xA;{&#xA;  printHeader();&#xA;  Serial.println(&quot;Authenticating with key A...&quot;);&#xA;&#xA;  int largestModulo4Number = blockNumber / 4 * 4;&#xA;  int trailerBlock = largestModulo4Number + 3;&#xA;&#xA;  byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &amp;amp;key, &amp;amp;(mfrc522.uid));&#xA;&#xA;  if (status != MFRC522::STATUS_OK)&#xA;  {&#xA;    Serial.println(&quot;ERROR : Authentication was unsuccessful.&quot;);&#xA;    return 0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;SUCCESS : Authentication was successful.&quot;);&#xA;    return 1;&#xA;  }&#xA;}&#xA;&#xA;int authenticateKeyB(int blockNumber)&#xA;{&#xA;  printHeader();&#xA;  Serial.println(&quot;Authenticating with key B...&quot;);&#xA;&#xA;  int largestModulo4Number = blockNumber / 4 * 4;&#xA;  int trailerBlock = largestModulo4Number + 3;&#xA;&#xA;  byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &amp;amp;key, &amp;amp;(mfrc522.uid));&#xA;&#xA;  if (status != MFRC522::STATUS_OK)&#xA;  {&#xA;    Serial.println(&quot;ERROR : Authentication was unsuccessful.&quot;);&#xA;    return 0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;SUCCESS : Authentication was successful.&quot;);&#xA;    return 1;&#xA;  }&#xA;}&#xA;&#xA;int readBlock(int blockNumber, byte *resultBuffer)&#xA;{&#xA;  printHeader();&#xA;  Serial.println(&quot;Starting read block function...&quot;);&#xA;&#xA;  int authSuccess = authenticateKeyA(blockNumber);&#xA;  Serial.println(&quot; &quot;);&#xA;&#xA;  if (!authSuccess)&#xA;  {&#xA;    Serial.println(&quot;ERROR : Terminating function.&quot;);&#xA;    return 0;&#xA;  }&#xA;&#xA;  byte bufferSize = 18;&#xA;&#xA;  byte status = mfrc522.MIFARE_Read(blockNumber, resultBuffer, &amp;amp;bufferSize);&#xA;&#xA;  if (status != MFRC522::STATUS_OK)&#xA;  {&#xA;    Serial.println(&quot;ERROR : Read failed.&quot;);&#xA;    return 0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(&quot;SUCCESS : Block &quot;);&#xA;    Serial.print(blockNumber);&#xA;    Serial.print(&quot; was read successfully.&quot;);&#xA;    return 1;&#xA;  }&#xA;&#xA;  mfrc522.PICC_HaltA();&#xA;  mfrc522.PCD_StopCrypto1();&#xA;}&#xA;&#xA;void readAndPrint(int blockNumber)&#xA;{&#xA;  readBlock(blockNumber, resultBuffer);&#xA;&#xA;  printHeader();&#xA;  Serial.println(&quot;RESULT :&quot;);&#xA;  for (int j=0 ; j&amp;lt;16 ; j++)&#xA;  {&#xA;   Serial.print(resultBuffer[j], HEX);&#xA;   Serial.print(&quot; &quot;);&#xA;  }&#xA;  Serial.println(&quot; &quot;);&#xA;&#xA;  delay(2000);&#xA;  printHeader();&#xA;  Serial.println(&quot;Ready to scan card...&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before scanning the card for the first time, the serial output looks like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eIz0F.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eIz0F.png&quot; alt=&quot;First capture of serial monitor.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After scanning the card for the first time, the serial output looks like this :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZTFLI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZTFLI.png&quot; alt=&quot;Second capture of serial monitor.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After scanning the card for the second time, the serial output doesn't change from image 2.  I tried running &lt;code&gt;Serial.println(&quot;no card detected&quot;);&lt;/code&gt; when the code inside &lt;code&gt;if (!mfrc522.PICC_IsNewCardPresent())&lt;/code&gt; is ran, just to check if the program was frozen (I'd heard someone else had an issue where the program froze after scanning the first card) - it wasn't frozen, both before and after scanning the first card, it printed out 'no card detected' repeatedly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would greatly appreciate any help as I have no clue as to how I should proceed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers,&lt;/p&gt;&#xA;" OwnerUserId="23133" LastEditorUserId="23133" LastEditDate="2016-06-22T02:30:50.903" LastActivityDate="2016-10-21T12:17:07.013" Title="MFRC522 Module Won't Read Multiple PICCs Consecutively" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25412" PostTypeId="1" AcceptedAnswerId="29279" CreationDate="2016-06-18T10:00:34.033" Score="0" ViewCount="1347" Body="&lt;p&gt;Good day&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm playing with Arduino and shift register chip 74HC595N and already tried many different ways to solve my problem, but still to luck :(&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that is my current simple scheme:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/SzmlP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SzmlP.png&quot; alt=&quot;Scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino 2,3,4 ports connected to data, clock and latch pins of 74HC595N. I've connected only first two output pins of chip to make minimum power consumption and to simplify this example as much as possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is my sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int latchPin = 4; //Pin connected to ST_CP of 74HC595&#xA;const int clockPin = 3; //Pin connected to SH_CP of 74HC595&#xA;const int dataPin = 2;  //Pin connected to DS of 74HC595&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;  pinMode(13, OUTPUT);  &#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;ON&quot;);&#xA;  digitalWrite(13, HIGH);&#xA;  send(B10000001);&#xA;  Serial.println(&quot;OFF&quot;);&#xA;  digitalWrite(13, LOW);&#xA;  send(B01000010);&#xA;}&#xA;&#xA;void send(byte d) {&#xA;  Serial.println(d);&#xA;  digitalWrite(latchPin, LOW); &#xA;  shiftOut(dataPin, clockPin, MSBFIRST, d);&#xA;  delay(1000);&#xA;  digitalWrite(latchPin, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the problem is: sometimes leds are blinking but very unstable. Sometimes it's not working at all, sometimes only first led is blinking, but second one is not. Sometimes opposite - second led is blinking, first one is not. Sometimes one of led is blink very fast (just flash instead of 1 second delay).&#xA;If I touch wires and elements on breadboard - something changing. Even without touching anything - situation changing. It seems like problem is somewhere in connection or power supply and I've already tried to except it: tried few different breadboard, two different 595 chips, different wires and resistors, tried Arduino Uno, Mega and nano. Even tried atmega328p standalone, tried power it from USB, from 9v battery, old mobile charger (5.4V, 650 mA), tried to power arduino with external source (12V, 1A). In all cases the problem still exists.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already read a lot about power supply for Arduino, but I think at least few of the ways I've already tried to supply power is good enough for 595 chip and two LEDs - isn't it? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please, advice me what else can I try?&lt;/p&gt;&#xA;" OwnerUserId="23134" LastActivityDate="2016-09-14T14:34:49.893" Title="Arduino, 74HC595N, magic" Tags="|arduino-uno|shift-register|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25414" PostTypeId="1" AcceptedAnswerId="26867" CreationDate="2016-06-18T10:35:03.467" Score="0" ViewCount="1658" Body="&lt;p&gt;I have recently written a program which is supposed to change the duty-cycle to keep the feedback voltage measured on A0, A1 constant. The problem is that the Arduino will start crashing at pretty constant intervals if it approaches it's target current. Once it crashes I have confirmed that it restarts the program (but crashes again in a moment). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a sample of the serial output during the crash:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 236.00&#xA;Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 235.96&#xA;Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 235.92&#xA;Current A: 64   Current B: 67   PWM A: 175.00   PWM B: 235.88&#xA;Current A: 64   Current B: 66   PWM A: 250.00   PWM B: 285114740000000000000000000.00&#xA;Current A: 0    Current B: 0    PWM A: 1.30     PWM B: 0.00&#xA;Current A: 0    Current B: 0    PWM A: 2.60     PWM B: 1.30&#xA;Current A: 0    Current B: 0    PWM A: 3.90     PWM B: 2.60&#xA;Current A: 0    Current B: 0    PWM A: 5.20     PWM B: 3.90&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is &lt;strong&gt;all&lt;/strong&gt; of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;//Program to run on the Vegetarium&#xA;//Written by Leon Teichroeb on 12/6/2016&#xA;&#xA;//Hardware description:&#xA;//-Oscillator 2A and 2B for the two onboard driver circuits&#xA;//-Pin 13 is attached to the &quot;heartbeat&quot; LED&#xA;//-Channel A (3) and B (11) current measurements on A0 and A1&#xA;&#xA;//Functionality:&#xA;//-Drive Channels at set current&#xA;&#xA;float PWMA = 0;&#xA;float PWMB = 0;&#xA;&#xA;int TARGETA = 65;&#xA;int TARGETB = 65;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);&#xA;  TCCR2B = _BV(CS20);&#xA;  OCR2A = (int)PWMA;&#xA;  OCR2B = (int)PWMB;&#xA;  digitalWrite(3, LOW);&#xA;  digitalWrite(11, LOW);&#xA;&#xA;  delay(5000);&#xA;}&#xA;&#xA;void loop() {&#xA;  int CURRENTA = analogRead(A0) / 4;&#xA;&#xA;  if(CURRENTA &amp;lt; TARGETA) {&#xA;    PWMA += (TARGETA - CURRENTA) * 0.020f;&#xA;    if(PWMA &amp;gt; 250) {&#xA;      PWMA = 250;&#xA;    }&#xA;  }&#xA;  if(CURRENTA &amp;gt; TARGETA) {&#xA;    PWMA += (TARGETA - CURRENTA) * 0.020f;&#xA;    if(PWMA &amp;lt; 5) {&#xA;      PWMA = 5;&#xA;    }&#xA;  }&#xA;&#xA;  int CURRENTB = analogRead(A1) / 4;&#xA;&#xA;  Serial.println(&quot;Current A: &quot; + (String)CURRENTA + &quot;\t&quot; + &quot;Current B: &quot; + (String)CURRENTB + &quot;\t&quot; + &quot;PWM A: &quot; + (String)PWMA + &quot;\t&quot; + &quot;PWM B: &quot; + (String)PWMB);&#xA;  //Serial.println(&quot;PWM A: &quot; + (String)PWMA + &quot;\t&quot; + &quot;PWM B: &quot; + (String)PWMB);&#xA;  //Serial.print(&quot;freeMemory()=&quot;);&#xA;  //Serial.println(freeMemory());&#xA;&#xA;&#xA;  if(CURRENTB &amp;lt; TARGETB) {&#xA;    PWMB += (TARGETB - CURRENTB) * 0.020f;&#xA;    if(PWMB &amp;gt; 250) {&#xA;      PWMB = 250;&#xA;    }&#xA;  }&#xA;  if(CURRENTB &amp;gt; TARGETB) {&#xA;    PWMB += (TARGETB - CURRENTB) * 0.020f;&#xA;    if(PWMB &amp;lt; 5) {&#xA;      PWMB = 5;&#xA;    }&#xA;  }&#xA;&#xA;  if(PWMA &amp;lt; 10) {&#xA;    digitalWrite(3, LOW);&#xA;  } else {&#xA;    analogWrite(3, (int)PWMA);&#xA;  }&#xA;  if(PWMB &amp;lt; 10) {&#xA;    digitalWrite(11, LOW);&#xA;  } else {&#xA;    analogWrite(11, (int)PWMB);&#xA;  }&#xA;&#xA;  delay(40);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My circuit also provides power for the Arduino through a simple 7815 voltage regulator. The analog input does not exceed a few volts, and the PWM outputs are driving two logic level MOSFETs. If more information on the circuit is necessary please let me know!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have found out that it isn't a bug in the two feedback loops, because both work on their own. It crashes as soon as I use both feedback loops together. As far as I'm aware, there are no shared variables or data between them&lt;/p&gt;&#xA;" OwnerUserId="23136" LastEditorUserId="23136" LastEditDate="2016-06-18T13:43:10.987" LastActivityDate="2019-04-06T11:26:07.713" Title="Arduino crashing and rebooting" Tags="|programming|pwm|atmega328|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25416" PostTypeId="1" AcceptedAnswerId="25417" CreationDate="2016-06-18T14:59:57.237" Score="0" ViewCount="4465" Body="&lt;p&gt;I am getting the following error when attempting to compile my sketch:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In file included from sketch.ino:24:0: SerialRenderer.h:7: error:&#xA;  expected class-name before '{' token&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;SerialRenderer.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef SERIALRENDERER_H_&#xA;#define SERIALRENDERER_H_&#xA;&#xA;#include &amp;lt;MenuSystem.h&amp;gt;&#xA;&#xA;class SerialRenderer : public MenuComponentRenderer&#xA;{&#xA;public:&#xA;    SerialRenderer();&#xA;    virtual ~SerialRenderer();&#xA;&#xA;public: // methods from MenuComponentRenderer&#xA;    virtual void render(Menu const&amp;amp; menu) const;&#xA;    virtual void render_menu_item(MenuItem const&amp;amp; menu_item) const;&#xA;    virtual void render_back_menu_item(BackMenuItem const&amp;amp; menu_item) const;&#xA;    virtual void render_numeric_menu_item(NumericMenuItem const&amp;amp; menu_item) const;&#xA;    virtual void render_menu(Menu const&amp;amp; menu) const;&#xA;};&#xA;&#xA;#endif // SERIALRENDERER_H_&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The contents of MenuSystem.h can be found at &lt;a href=&quot;https://github.com/jonblack/arduino-menusystem/blob/master/MenuSystem.h&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jonblack/arduino-menusystem/blob/master/MenuSystem.h&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like the include of MenuSystem.h does not happen when SerialRenderer.h is included from my main sketch file. I get the same error if the include in SerialRenderer.h is removed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there something simple I am missing for the compiler to be able to &quot;see&quot; MenuSystem.h?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turns out I was looking at a newer version of the arduino-menusystem library than I had installed (version 2.1.1). That version did not have a class called MenuComponentRenderer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I pulled the latest version from &lt;a href=&quot;https://github.com/jonblack/arduino-menusystem/tree/master&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jonblack/arduino-menusystem/tree/master&lt;/a&gt; and it compiles fine.&lt;/p&gt;&#xA;" OwnerUserId="20884" LastEditorUserId="20884" LastEditDate="2016-06-19T13:22:54.480" LastActivityDate="2016-06-19T16:08:23.713" Title="expected class-name before '{' token" Tags="|c++|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25417" PostTypeId="2" ParentId="25416" CreationDate="2016-06-18T15:12:14.940" Score="0" Body="&lt;p&gt;It is most likely caused by the fact that a correct version of MenuSystem library is not properly installed.&#xA;Check whether you can add the library to your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: added that also the version should be correct&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-06-19T16:08:23.713" LastActivityDate="2016-06-19T16:08:23.713" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25418" PostTypeId="1" CreationDate="2016-06-18T15:15:25.323" Score="0" ViewCount="2287" Body="&lt;p&gt;I'm having trouble understanding the &lt;a href=&quot;http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheets&lt;/a&gt; for the ATtiny and I need to know what is the largest prescaler that can be set for an ATtiny Timer Interupt? I'm new to hardware so can someone tell me if this is correct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setupInterupt()&#xA;{&#xA;  noInterrupts();&#xA;  TCCR2A = 0;                       &#xA;  TCCR2B = 0;                       &#xA;  TCNT2 = 0;                        &#xA;  OCR2A = PERIOD - 1;               &#xA;  TIMSK2 = _BV(OCIE2A);             &#xA;  TCCR2B |= _BV(CS13) | _BV(CS12) | _BV(CS12) | _BV(CS10);  &#xA;  interrupts();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will this set a prescaler of 16384? Am I understanding the chart on page 89 correctly and is my syntax okay? This is my first Arduino Project.&lt;/p&gt;&#xA;" OwnerUserId="22788" LastActivityDate="2016-06-18T23:30:42.093" Title="What is the maximum prescaler you can set for an ATtiny85 Timer Interrupt?" Tags="|interrupt|attiny|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="25419" PostTypeId="1" CreationDate="2016-06-18T16:02:53.550" Score="1" ViewCount="896" Body="&lt;p&gt;I have 2 &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E594ZX0&quot; rel=&quot;nofollow&quot;&gt;nRF24L01+ modules&lt;/a&gt; that were working fine then...stopped. I'm wondering if I accidentally fried one of the modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the RF24 library GettingStarted example, this is the output of the module I believe may be fried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RF24/examples/GettingStarted/&#xA;ROLE: Pong back&#xA;*** PRESS 'T' to begin transmitting to the other node&#xA;STATUS        = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0&#xA;RX_ADDR_P0-1  = 0x0000000000 0x0000000000&#xA;RX_ADDR_P2-5  = 0x00 0x00 0x00 0x00&#xA;TX_ADDR       = 0x0000000000&#xA;RX_PW_P0-6    = 0x00 0x00 0x00 0x00 0x00 0x00&#xA;EN_AA         = 0x00&#xA;EN_RXADDR     = 0x00&#xA;RF_CH         = 0x00&#xA;RF_SETUP      = 0x00&#xA;CONFIG        = 0x00&#xA;DYNPD/FEATURE = 0x00 0x00&#xA;Data Rate     = 1MBPS&#xA;Model         = nRF24L01&#xA;CRC Length    = Disabled&#xA;PA Power      = PA_MIN&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've changed out cables and connections all the way through. I also replaced this module with the other one directly and the other worked fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question: Is this output showing definitively that I've killed the module and just need to buy a new one? Or is there some way to &quot;flash&quot; or reset the module?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2021-09-05T00:28:26.740" Title="nRF24L01+ module fried?" Tags="|arduino-uno|nrf24l01+|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25420" PostTypeId="2" ParentId="12045" CreationDate="2016-06-18T16:10:02.240" Score="2" Body="&lt;p&gt;If adding a 47uF capacitor between the 3.3V and GND is not enough to solve your problem, try to:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;power the NRF24 through a 3.3V voltage regulator (like a LM1117T-3.3) and power the voltage regulator (NOT the NRF24) through the Arduino's 5V pin. Indeed, the Arduino 3.3V pin is limited to 150mA output, while the the 5V pin can provide you about 400mA.&lt;/li&gt;&#xA;&lt;li&gt;don't use a breadboard: the NRF24 chip is very sensitive, so try to connect it directly to the board through jumpers or PCB / perf-board.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Add to your code the line: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;radio.setPALevel(RF24_PA_MIN);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;and check if it works in that way; if it does, the issue is probably about the chip's current consumption.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helped&lt;/p&gt;&#xA;" OwnerUserId="23142" LastActivityDate="2016-06-18T16:10:02.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25421" PostTypeId="2" ParentId="25402" CreationDate="2016-06-18T16:45:12.607" Score="1" Body="&lt;p&gt;You may have a power problem, but with all those libraries, I would also suspect memory issues with &lt;code&gt;String&lt;/code&gt;.  The percentages reported by the IDE do not show actual &lt;code&gt;String&lt;/code&gt; memory usage, just the declared variables and double-quoted string constants, like &lt;code&gt;&quot;BMP180 init fail&quot;&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think those humidity sensors have a heating cycle, so maybe they're causing a power sag, or maybe the sketch has run amok and is constantly requesting conversions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, instead of building a &lt;code&gt;String&lt;/code&gt; to be printed all at once, just print the pieces.  That is, instead of this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;  cmd += IP;&#xA;  cmd += &quot;\&quot;,80&quot;;&#xA;  Serial1.println(cmd);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.println( F(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;) );&#xA;Serial1.print( IP );&#xA;Serial1.print( F(&quot;\&quot;,80&quot;) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This saves copying bytes into buffers, reallocating &lt;code&gt;String&lt;/code&gt;s, copying them to the output buffer... yuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;F(&quot;x bytes&quot;)&lt;/code&gt; macro also saves x bytes of RAM each time you use it on a double-quoted string constant!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cmd = GET + &quot;&amp;amp;field1=&quot; + temp1 + &quot;&amp;amp;field2=&quot; + humm + &quot;&amp;amp;field3=&quot; + temp2 + &quot;&amp;amp;field4=&quot; + pression + &quot;&amp;amp;field5=&quot; + luminosite + &quot;&amp;amp;field6=&quot; + pol001 + &quot;&amp;amp;field7=&quot; + pol025 + &quot;&amp;amp;field8=&quot; + pol010 + &quot;\r\n\r\n&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;OMG.  Use separate &lt;code&gt;Serial1.print&lt;/code&gt; statements and &lt;code&gt;F()&lt;/code&gt; macros.  However, because you have to send the command length first to the ESP8266, don't pass them in as &lt;code&gt;String&lt;/code&gt;s, pass them as ints or floats, and add up the individual string lengths.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several ways to do this, depending on the old RAM-vs-speed tradeoff.  Here's a minimal RAM approach:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  //  Pass in values, not Strings&#xA;  esp8266( temp, hum, T, p0, lux, PM01Value, PM2_5Value, PM10Value );&#xA;}&#xA;    ...&#xA;&#xA;void esp8266( float temp1, float humm, float temp2, float pression, float luminosite, int pol001, int pol025, int pol010 )&#xA;{&#xA;    ...&#xA;&#xA;  //  Start with the fixed-length string constants:&#xA;  //     GET + 8 * &quot;&amp;amp;field#&quot; + line termination&#xA;  size_t cmdLength = strlen(GET) + 8 * 8 + 4;&#xA;&#xA;  //  Convert each value to a char array to see how big each one is...&#xA;  char buf[16]; // to hold temporary &quot;char strings&quot;&#xA;&#xA;  unsigned char decimalPlaces = 2;&#xA;  dtostrf( temp1, (decimalPlaces + 2), decimalPlaces, buf);&#xA;  cmdLength += strlen(buf);&#xA;&#xA;  dtostrf( humm, (decimalPlaces + 2), decimalPlaces, buf);&#xA;  cmdLength += strlen(buf);&#xA;&#xA;  dtostrf( temp2, (decimalPlaces + 2), decimalPlaces, buf);&#xA;  cmdLength += strlen(buf);&#xA;     ...&#xA;  itoa( pol10, buf, 10 );  // value, char *, base&#xA;  cmdLength += strlen(buf);&#xA;&#xA;  //  Now we know the total length&#xA;  Serial1.print(&quot;AT+CIPSEND=&quot;); &#xA;  Serial1.println( cmdLength ); //  &amp;lt;-- calculated!&#xA;  delay(1000);&#xA;&#xA;  if (Serial1.find(&quot;&amp;gt;&quot;)) {&#xA;&#xA;    // send all the same pieces of the GET command&#xA;    Serial1.print( GET );&#xA;&#xA;    Serial1.print( F(&quot;&amp;amp;field1=&quot;) );&#xA;    dtostrf( temp1, (decimalPlaces + 2), decimalPlaces, buf);&#xA;    Serial1.print( buf );&#xA;&#xA;    Serial1.print( F(&quot;&amp;amp;field2=&quot;) );&#xA;    dtostrf( humm, (decimalPlaces + 2), decimalPlaces, buf);&#xA;    Serial1.print( buf );&#xA;&#xA;    Serial1.print( F(&quot;&amp;amp;field3=&quot;) );&#xA;    dtostrf( temp2, (decimalPlaces + 2), decimalPlaces, buf);&#xA;    Serial1.print( buf );&#xA;        ...&#xA;    itoa( pol010, buf, 10 );  // value, char *, base&#xA;    Serial1.print( buf );&#xA;&#xA;    Serial1.print( F(&quot;\r\n\r\n&quot;) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; It is important that you use the &lt;em&gt;same&lt;/em&gt; technique to calculate the length of one piece &lt;em&gt;and&lt;/em&gt; to print that piece.  Here, the same &lt;code&gt;dtostrf&lt;/code&gt; call with the same &lt;code&gt;decimalPlaces&lt;/code&gt; is used for each piece.  Ditto for &lt;code&gt;itoa&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The speed penalty is that you convert each parameter twice, but this is probably still quicker than all the alloc/realloc/delete/copy that &lt;code&gt;String&lt;/code&gt; was doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RAM advantage is that you are using only 16 bytes for &lt;code&gt;buf&lt;/code&gt; instead of hundreds of bytes on the heap (that's where &lt;code&gt;String&lt;/code&gt; actually stores its characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The program space advantage is about 1600 bytes for &lt;em&gt;not&lt;/em&gt; using the &lt;code&gt;String&lt;/code&gt; library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you now see that the apparent &quot;convenience&quot; of using the &lt;code&gt;String&lt;/code&gt; class has real costs in speed, RAM and program size.  &lt;code&gt;String&lt;/code&gt; also affects the long-term stability of your program: you get weird crashes, hangs or string values.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-06-18T16:45:12.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25422" PostTypeId="1" CreationDate="2016-06-18T21:11:44.793" Score="2" ViewCount="215" Body="&lt;p&gt;I am trying to copy my garage door key. I opened it and found out it has dip switches which you can flip so you can send different codes. It uses 12 bits and operates at 315Mhz. I bought a 315Mhz transmitter for arduino and i am trying to send that 12 bit code. I used an RTL-SDR and found out that the key uses AM modulation. Now, the problem is i dont know how to send bits (1,0 or high and low). I connected vcc of the transmitter to arduino 5V and gnd to gnd. Data pin is connected to pin 9. I tried setting pin 9 high or low coresponding to the code with 2ms pause in beetwen but RTL-SDR showed that nothing was transmitted. I tried using rc_switch and virtual_wire libary and using diffferent transmitters in case this one was damaged but no success. So how do i actually send high and low signals with these transmitters?&#xA;PS: I know i can buy those garage key copiers but this is more fun and i learn more.&lt;/p&gt;&#xA;" OwnerUserId="23147" LastActivityDate="2016-06-18T21:11:44.793" Title="Duplicate a garage door key" Tags="|virtualwire|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25423" PostTypeId="2" ParentId="25403" CreationDate="2016-06-18T21:20:19.837" Score="1" Body="&lt;p&gt;If I understood your question correctly, you're looking for something like this:  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const byte PIN_NUMBER[4] = { 0, 2, 5, 6 };&#xA;static const char *PIN_NAME[4] = { &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot; };&#xA;&#xA;// and use them like this:&#xA;&#xA;void Log(byte index)&#xA;{&#xA;  byte val = digitalRead(PIN_NUMBER[index]);&#xA;  Serial.print(PIN_NAME[index]);&#xA;  Serial.print('|');&#xA;  Serial.println(val);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  for (byte i = 0; i &amp;lt; 4; ++i) pinMode(PIN_NUMBER[i], INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;PIN|VALUE&quot;);&#xA;  for (byte i = 0; i &amp;lt; 4; ++i) Log(i);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, in the special case of &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot; as pin names, you don't really need the &lt;code&gt;PIN_NAME&lt;/code&gt; array, instead of  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(PIN_NAME[index]);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can use:  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print('A' + index);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20696" LastEditorUserId="20696" LastEditDate="2016-06-18T21:27:53.363" LastActivityDate="2016-06-18T21:27:53.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25424" PostTypeId="1" AcceptedAnswerId="25514" CreationDate="2016-06-18T21:51:38.587" Score="1" ViewCount="20434" Body="&lt;p&gt;I have SIM800l module connected to Arduino and I'm trying to initialize it in my setup function with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;//SIM800 TX is connected to Arduino D8&#xA;#define SIM800_TX_PIN 6&#xA;//SIM800 RX is connected to Arduino D7&#xA;#define SIM800_RX_PIN 7&#xA;SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(38400);&#xA;  while(!Serial);&#xA;  serialSIM800.begin(38400);&#xA;  Serial.println(&quot;wait for .... it&quot;);&#xA;  delay(10000);&#xA;&#xA;&#xA;  // comments added just for example, both commands return junk&#xA;  //serialSIM800.write(&quot;AT\r\n&quot;); &#xA;  //serialSIM800.write(&quot;AT+SAPBR=3,1,\&quot;Contype\&quot;,\&quot;GPRS\&quot;\r\n&quot;);&#xA;&#xA;  Serial.println(&quot;command sent&quot;);&#xA;  delay(2500);&#xA;&#xA;  Serial.write(serialSIM800.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But &lt;code&gt;Serial.write&lt;/code&gt; returns junk. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I use this code in loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor&#xA;  if(serialSIM800.available()){&#xA;    Serial.write(serialSIM800.read());&#xA;  }&#xA;  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800&#xA;  if(Serial.available()){    &#xA;    serialSIM800.write(Serial.read());&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and send &lt;code&gt;AT+SAPBR=3,1,&quot;Contype&quot;,&quot;GPRS&quot;&lt;/code&gt; or just &lt;code&gt;AT&lt;/code&gt; command with serial monitor, everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone help with this?&lt;/p&gt;&#xA;" OwnerUserId="20423" LastEditorUserId="972" LastEditDate="2018-02-21T18:13:07.957" LastActivityDate="2021-03-08T00:54:15.477" Title="How to send AT command to sim800l with SoftwareSerial" Tags="|arduino-uno|serial|arduino-nano|gsm|softwareserial|" AnswerCount="7" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25427" PostTypeId="2" ParentId="25418" CreationDate="2016-06-18T23:30:42.093" Score="1" Body="&lt;p&gt;I don't know the objectives of your project, or its constraints and requirements.  Thus, portions of the following might not apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I were using an ATtiny85 in an application that needed to “maximize the amount of power saved” and also needed to wake up about every 33 ms, I'd use the factory-calibrated 8 MHz clock (rather than attaching a 20 MHz external crystal), and use system clock prescaling [see §6.3, System Clock Prescaler, on page 31 of &lt;a href=&quot;http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;the ATtiny85 specs&lt;/a&gt;, and Table 6-15. Clock Prescaler Select, p. 33] to scale that 8 MHz down to 250 KHz.  As implied by Table 21-1, DC Characteristics, page 162 of specs, this will drop CPU current draw down to under 0.1 mA if powered by 2 V, or under 0.35 mA if powered by 3 V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the system clock running at 250 KHz, you can use timer 0 prescaled by a factor of 1024 [see §11.3.1, Internal Clock Source with Prescaler, p. 166 of specs] to get an interrupt every 33 ms or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If 250 KHz is too slow to get done with whatever computation needs to be done every 33 ms, upon waking I would change the system clock prescale factor per §6.3.1, Switching Time, to 8 MHz or 4 MHz or whatever it needs to be to get the computation done at lowest power cost.  That might or might not be the same as getting the computation done most quickly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, after the periodic computation is done, I'd revert the system clock to 250 KHz, and go to sleep in Idle mode (Ref §7.1.1, Idle Mode) with almost everything except timer 0 shut down via the PRR. (Ref §7.3, Power Reduction Register.)&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-06-18T23:30:42.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25428" PostTypeId="2" ParentId="3993" CreationDate="2016-06-19T05:54:46.647" Score="2" Body="&lt;p&gt;&lt;strong&gt;For others who reach here by search results&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before this applying &lt;code&gt;AT+CSTT&lt;/code&gt; command check if the modem is attached to GPRS using the &lt;code&gt;AT+CGATT=?&lt;/code&gt; command. If the result is &lt;code&gt;+CGATT: 0&lt;/code&gt; this means the modem is not attached so attach the modem using &lt;code&gt;AT+CGATT=1&lt;/code&gt; command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will solve the issue as it was in my case. Even applying &lt;code&gt;AT+CIPCLOSE=0&lt;/code&gt; and &lt;code&gt;AT+CIPSHUT&lt;/code&gt; didn't help until I checked that that the result of &lt;code&gt;AT+CGATT=?&lt;/code&gt; was returning &lt;code&gt;+CGATT: 0&lt;/code&gt; and applied &lt;code&gt;AT+CGATT=1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3277" LastActivityDate="2016-06-19T05:54:46.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25430" PostTypeId="1" AcceptedAnswerId="25431" CreationDate="2016-06-19T06:41:53.737" Score="0" ViewCount="48" Body="&lt;p&gt;Sorry if my code isn't well written or anything because I'm new to Arduino and coding in C, but what is wrong with my code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sidepin = 2;&#xA;int LED = 5;&#xA;int val;&#xA;void setup() {&#xA;  pinMode(sidepin, INPUT);&#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  val = digitalRead(sidepin);&#xA;  if(val = 0)&#xA;  {&#xA;    pinMode(LED, HIGH);&#xA;  }&#xA;  else(val &amp;gt; 0) &#xA;  {&#xA;    pinMode(LED, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21318" LastEditorUserId="9962" LastEditDate="2016-06-19T12:55:41.380" LastActivityDate="2016-06-19T12:55:41.380" Title="What's up with my code?" Tags="|arduino-uno|code-review|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25431" PostTypeId="2" ParentId="25430" CreationDate="2016-06-19T07:04:00.130" Score="2" Body="&lt;p&gt;Your IF statement, you're using: &lt;code&gt;(val = 0)&lt;/code&gt;, and I believe you meant &lt;code&gt;(val == 0)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, you're using &lt;code&gt;else(val &amp;gt; 0)&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; doesn't need any argument. So the fixed code should look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sidepin = 2;&#xA;int LED = 5;&#xA;int val;&#xA;void setup() {&#xA;  pinMode(sidepin, INPUT);&#xA;  pinMode(LED, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  val = digitalRead(sidepin);&#xA;  if(val == LOW)&#xA;  {&#xA;    pinMode(LED, HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;    pinMode(LED, LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-19T07:04:00.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25432" PostTypeId="1" AcceptedAnswerId="25435" CreationDate="2016-06-19T09:01:47.053" Score="0" ViewCount="1073" Body="&lt;p&gt;I am trying to use the Arduino as a switch for an external circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I first thought about using a shift register, but this wont allow me to switch the external circuit. Here is a little sketch of what I want to do : &lt;a href=&quot;https://i.stack.imgur.com/0QNwG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0QNwG.jpg&quot; alt=&quot;Desired circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So basically I got this external circuit with a 3 position switch. And I want to replace this manual switch with an Arduino so it can be controlled by a PC, without influencing the other circuits Voltage or Amps...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions ? &lt;/p&gt;&#xA;" OwnerUserId="23159" LastEditorUserId="9962" LastEditDate="2016-06-19T12:55:33.257" LastActivityDate="2016-06-19T12:55:33.257" Title="Arduino as switch for external circuit" Tags="|arduino-uno|switch|arduino-setup|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25435" PostTypeId="2" ParentId="25432" CreationDate="2016-06-19T09:59:32.090" Score="0" Body="&lt;p&gt;Three-position makes it a little more tricky than normal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest option, though depending on what the circuit is, maybe not the safest option, is to use three relays.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CAHmA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CAHmA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Switch only one relay on and it is the same as having the three-position switch in that same state. Switch that relay off and switch another on and you have changed the switch position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The danger is that this arrangement can have two or even three relays on at once, something that can't happen with a switch.  Also how you do the switching could be critical. Switch one relay off, then add a delay before switching the next one on, so that the previous one has a chance to switch off properly first. That way you avoid having two on at once. Of course, depending on what it is you're switching, that may or may not be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The safest option, though the hardest to create, would be to physically move the existing switch with, say, a servo motor. Without knowing a little more about the mechanics of your switch I can't really advise more on this option.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-19T09:59:32.090" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25438" PostTypeId="1" AcceptedAnswerId="25465" CreationDate="2016-06-19T12:38:51.267" Score="1" ViewCount="6061" Body="&lt;p&gt;For my master thesis I've designed a board with an &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA328P.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATMEGA328P-AU&lt;/a&gt; as micro controller.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/87HhA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/87HhA.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&#xA;As I want to use some libraries and I like the simplicity, I want to use &amp;quot;Arduino&amp;quot; to program it.&lt;/p&gt;&#xA;&lt;p&gt;Everything works fine to a point:&#xA;I took an Arduino Uno and uploaded the &amp;quot;ArduinoISP&amp;quot; sketch.&#xA;I connected the ISP pins and burned the bootloader with board set to &amp;quot;Arduino Duemilanove / Diecimila&amp;quot; - got the message, bootloader burned.&#xA;I disconnected the ISP pins, took the ATMEGA out of its socket on the UNO board and connected the serial pins.&lt;/p&gt;&#xA;&lt;p&gt;Here comes the problem I cant figure out:&lt;/p&gt;&#xA;&lt;p&gt;Once I have done a above procedure I can upload a sketch and Serial communication is working. But I can only upload it once! The second time (no matter if during the same power-up or at another time) I push the upload sketch button, I get no response for several minutes (I once waited up to 10min to confirm there is nothing coming anymore :)). If I unplug either USB or the TX/RX cables I get the error (or for the USB cable something similar):&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;avrdude: stk500v2_ReceiveMessage(): timeout&lt;/p&gt;&#xA;&lt;p&gt;avrdude: stk500v2_getsync(): timeout communicating with programmer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;When I upload the bootloader again I can once again upload a sketch same as before. Then the same problem happens again.&lt;/p&gt;&#xA;&lt;p&gt;I checked several question on Stackexchange already (specially all points in &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;this&lt;/a&gt; one here) and googled the problem, but until now I am not able to find a solution.&lt;/p&gt;&#xA;&lt;p&gt;As you can imagine it is quite annoying to always unplug the RX/TX cable and hook up the ISP cable again and burn the bootloader.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;So my question: What could cause this problem and how can I solve it?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Btw. I am using the Arduino software version I'm using is 1.6.9&lt;/p&gt;&#xA;" OwnerUserId="4215" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2018-03-06T18:16:33.803" Title="Standalone Arduino with ATMEGA328P / Serial working, but serial programming not (only once after buning bootloader)" Tags="|serial|programming|atmega328|bootloader|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25439" PostTypeId="1" AcceptedAnswerId="25445" CreationDate="2016-06-19T13:56:00.967" Score="0" ViewCount="256" Body="&lt;p&gt;After recent flooding of my apartment (pipe burst) I got an idea of automatic water flow watch. I would like to measure or just watch if water flows on main water intake. Arduino will know at what time of day (during nights and when nobody is home) the water flow is a problem and will send me an sms or whatever alarm. Measurement will be better to enable you to go to the bathroom, so the alarm will be raised only after certain amount of water.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main problem is how to measure the water, are there any water-meter that can communicate with arduino? &lt;/p&gt;&#xA;" OwnerUserId="21253" LastActivityDate="2016-06-19T18:51:22.667" Title="Water measuring" Tags="|home-automation|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25440" PostTypeId="1" AcceptedAnswerId="25444" CreationDate="2016-06-19T14:17:05.487" Score="0" ViewCount="296" Body="&lt;p&gt;To all of this, hope to formulate the question right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In my project I have 5 sensors connected to Arduino, which I want to interpret via Seria.write() --&gt; Processing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;firstSens = 100 + (155 * digitalRead(8));&#xA;secondSens = analogRead(A1)/4;&#xA;thirdSens = analogRead(A2)/4;&#xA;fourthSens = humData;&#xA;fifthSens = tempData;&#xA;int sensData[6] = {firstSens, secondSens, thirdSens, fourthSens, fifthSens};&#xA;&#xA;int i;&#xA;for (i = 0; i &amp;lt; 5; i = i + 1) {&#xA;  Serial.write(sensData[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Processing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;serialInArray[serialCount] = inByte;&#xA;    serialCount++;&#xA;&#xA;if (serialCount &amp;gt; 4 ) {&#xA;  firstSens = serialInArray[0];&#xA;  secondSens = serialInArray[1];&#xA;  thirdSens = serialInArray[2];&#xA;  fourthSens = serialInArray[3];&#xA;  fifthSens = serialInArray[4];&#xA;&#xA;  // print the values (for debugging purposes only):&#xA;  println(firstSens + &quot;\t&quot; + secondSens + &quot;\t&quot; + thirdSens + &quot;\t&quot; + fourthSens + &quot;\t&quot; + fifthSens);&#xA;&#xA;  // Send a capital A to request new sensor readings:&#xA;  myPort.write('A');&#xA;  // Reset serialCount:&#xA;  serialCount = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that sensors find their place in Processing's array randomly, so for example arduino's &lt;em&gt;firstSens&lt;/em&gt; could be Processing's &lt;em&gt;secondSens&lt;/em&gt; or &lt;em&gt;fifthSens&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is this happening and how can I control it?&lt;/p&gt;&#xA;" OwnerUserId="23167" LastActivityDate="2016-07-09T16:22:31.853" Title="serial.write() five sensors and Processing" Tags="|serial|sensors|processing-lang|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25442" PostTypeId="1" CreationDate="2016-06-19T15:41:21.893" Score="1" ViewCount="3908" Body="&lt;p&gt;I am wondering where are the difference in between using something like:&#xA;CD4067, which selects which pins to read/write from by &quot;selecting&quot; an address with 4 pins by writing to it. Versus the MCP23017 which uses the i2c interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to learn and build a simple application with lots of digital inputs and outputs, and need something that is fast at switching the pins and reading/writing to it. &lt;/p&gt;&#xA;" OwnerUserId="10691" LastActivityDate="2016-06-19T15:47:19.850" Title="I/O expander with i2c interface vs Multiplexer" Tags="|i2c|multiplexer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25443" PostTypeId="2" ParentId="25442" CreationDate="2016-06-19T15:47:19.850" Score="2" Body="&lt;p&gt;The MCP23017 gives you 16 extra real IO pins. Each one has facilities such as pull-up resistors, change notification interrupts, etc - the kind of things that you expect from real IO pins. You can read and write to all of the pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A multiplexer though just feeds signals through to the existing pins. They're pretty dumb. Only the signal that is currently fed through can have anything done to it. So only one signal can have a value written on it or read from, and pullup resistors and interrupts are non-existent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the CD4067 can be used with signals other than digital - as such they are good at being a multiplexer to the analog inputs, something an IO expander can never do. You could, though, use an I2C ADC chip for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For high speed IO control you really want to be using the MCP23S17 instead of the MCP23017. It uses SPI instead of I2C and thus is much faster to control.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-19T15:47:19.850" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25444" PostTypeId="2" ParentId="25440" CreationDate="2016-06-19T15:53:05.427" Score="1" Body="&lt;p&gt;What is happening is you are just spewing out a list of numbers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;4132&#xA;132&#xA;1928&#xA;3240&#xA;1239&#xA;238&#xA;3048&#xA;391&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is nothing anywhere to say what anything is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to add that kind of information. Either as a &quot;start of data&quot; tag before each block, or with each line.  For instance:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;---START OF DATA---&#xA;4132&#xA;132&#xA;1928&#xA;3240&#xA;1239&#xA;---START OF DATA---&#xA;238&#xA;3048&#xA;391&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0:4132&#xA;1:132&#xA;2:1928&#xA;3:3240&#xA;4:1239&#xA;0:238&#xA;1:3048&#xA;2:391&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is then up to your processing application to interpret the data and work out what is what.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I like using the second method since it means you don't have to send all the data every time - you can send different values at different speeds of update and maintain a &quot;current value&quot; at the Processing end. For instance if you have one value that updates frequently and others that don't:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;3:4132&#xA;1:132&#xA;3:1928&#xA;3:3240&#xA;3:1239&#xA;2:238&#xA;3:3048&#xA;0:391&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You don't even have to use numbers, you could use words:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pressure:4132&#xA;temperature:132&#xA;pressure:1928&#xA;pressure:3240&#xA;pressure:1239&#xA;humidity:238&#xA;pressure:3048&#xA;rainfall:391&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-19T15:53:05.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25445" PostTypeId="2" ParentId="25439" CreationDate="2016-06-19T16:07:24.017" Score="2" Body="&lt;p&gt;I have an electronic water flow meter which uses a turbine wheel inside the pipe. Ostensibly there is a magnet on one or two or all four of the blades, which is read by a hall-effect sensor inside the meter. The specifications require 3 gallons per minute, which may be lower than you wish.&#xA;&lt;a href=&quot;http://catalog.gpi.net/item/chemical-and-water-meters/01-series-electronic-digital-meters/01n31gm-nylon-water-meter?plpver=1001&quot; rel=&quot;nofollow&quot;&gt;http://catalog.gpi.net/item/chemical-and-water-meters/01-series-electronic-digital-meters/01n31gm-nylon-water-meter?plpver=1001&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the flow rate is acceptable, you could add your own hall-effect sensor outside the pipe and connect an appropriately programmed Arduino to perform the tasks you require.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, one could create via 3d modeling software an equivalent design to be printed by an online service or a friend with a printer. For balance purposes, a magnet in each vane would be advised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Years ago, I had a speedometer for a kayak, about the size of one's thumb. It used the same technology, although the sensor was about two inches away on the upper side of the hull, while the tiny propeller was on the bottom. Apparently small magnets spinning create sufficient disturbances in the force to be read by mass produced sensors, even more than a decade ago.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-19T16:07:24.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25446" PostTypeId="1" AcceptedAnswerId="25468" CreationDate="2016-06-19T17:10:31.097" Score="1" ViewCount="1644" Body="&lt;p&gt;&lt;strong&gt;Short version&lt;/strong&gt;: This is a lighting control project.  Some of the clases are Pin and  Channel. Channel contains a Pin.  Pin is a base class for DigitalOutPin and will be the base class for AnalogOutPin, and I want Channel to be able to use any child of Pin.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin has an abstract method setPinValue(), but when I create a DigitalOutPin object and call setPinValue(), Pin.setPinValue() gets called, not DigitalOutPin.setPinValue() and my program doesn't work because Pin.setPinValue() is empty as it's supposed to be overwritten.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long version&lt;/strong&gt;: &#xA;If I leave out the definition of Pin.setPinValue(), I get that most idiotic of error gcc messages, &quot;undefined reference to `vtable for Pin'&quot;.  If I make it pure virtual I get several errors in the form of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;In file included from /devel/arduino/lightbright/LightBrightMain/LightBrightMain.ino:9:0:&#xA;/devel/arduino/libraries/LightBrightLib/Channel.h:21:20: error: cannot declare parameter 'pin' to be of abstract type 'Pin'&#xA;     void begin(Pin pin, int channelNumber);&#xA;                ^&#xA;In file included from /devel/arduino/libraries/LightBrightLib/DigitalOutPin.h:10:0,&#xA;             from /devel/arduino/lightbright/LightBrightMain/LightBrightMain.ino:8:&#xA;/devel/arduino/libraries/LightBrightLib/Pin.h:16:7: note:   because the following virtual functions are pure within 'Pin':&#xA; class Pin&#xA;   ^&#xA;/devel/arduino/libraries/LightBrightLib/Pin.h:33:18: note:  virtual void Pin::setPinValue(int)&#xA;     virtual void setPinValue(int value)=0;&#xA;              ^&#xA;In file included from /devel/arduino/lightbright/LightBrightMain/LightBrightMain.ino:9:0:&#xA;/devel/arduino/libraries/LightBrightLib/Channel.h:23:9: error: invalid abstract return type for member function 'Pin Channel::getPin()'&#xA; Pin getPin();&#xA;     ^&#xA;In file included from /devel/arduino/libraries/LightBrightLib/DigitalOutPin.h:10:0,&#xA;             from /devel/arduino/lightbright/LightBrightMain/LightBrightMain.ino:8:&#xA;/devel/arduino/libraries/LightBrightLib/Pin.h:16:7: note:   since type 'Pin' has pure virtual functions&#xA; class Pin&#xA;   ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Full code is at &lt;a href=&quot;https://github.com/djsegfault/arduino/tree/master/libraries/LightBrightLib&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt; but here are the relevant parts:&#xA;Pin is declared like this right now as pure virtual, but I've tried with and without =0&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Pin&#xA;{&#xA;  public:&#xA;   ...&#xA;  protected:&#xA;   ...&#xA;  // This method is child-specific. It's empty in this base class&#xA;  virtual void setPinValue(int value)=0;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;DigitalOutPin is declared as &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class DigitalOutPin : public Pin&#xA;{&#xA;  public:&#xA;    void on();&#xA;    void off();&#xA;  protected:&#xA;    void setPinValue(int value);&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and defined as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void DigitalOutPin::setPinValue(int value) {&#xA;....&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: I'm primarily a Java developer so C++ OO is very different for me, but as far as I can tell this should work as designed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any advice you can offer.&lt;/p&gt;&#xA;" OwnerUserId="21571" LastEditorUserId="37523" LastEditDate="2019-12-03T23:13:24.163" LastActivityDate="2019-12-03T23:13:24.163" Title="Inheritance not working as expected" Tags="|programming|class|gcc|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25447" PostTypeId="2" ParentId="25439" CreationDate="2016-06-19T18:51:22.667" Score="1" Body="&lt;p&gt;The utility company probably already placed a meter at your apartment. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mine has a spinning dial, that's half metal, half plastic. I've had a photo-reflective sensor attached to it that so I could detect the change in amount of light being reflected (metal vs plastic). Every peak meant one liter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mine also has a rotating magnet, but I wasn't able to read that using a hal-effect sensor, or the magnetometer on my phone.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-19T18:51:22.667" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25448" PostTypeId="1" AcceptedAnswerId="25451" CreationDate="2016-06-19T20:03:29.647" Score="3" ViewCount="1080" Body="&lt;p&gt;If I got the picture right(correct me if I'm wrong) the standard bootloader senses the serial comm, and if nothing is read it passes control to the core program, which roughly corresponds to &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int main(void) {&#xA;    init();&#xA;    setup();&#xA;    for (;;) {&#xA;        loop();&#xA;        if (serialEventRun) serialEventRun();&#xA;    }&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I wish to understand what happens when  (while the core program is running) I upload a new sketch (using the IDE or &lt;code&gt;avrdude&lt;/code&gt;). I guess that the bootloader regains control when something is read in the serial comm, and this happens via a board reset (triggered somewhere inside &lt;code&gt;serialEventRun&lt;/code&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how does this flow interplay with the usage of the serial port? Assume I want to use &lt;code&gt;avrdude&lt;/code&gt; to upload the sketch via USB, and also use the serial comm during the program execution.&lt;/p&gt;&#xA;" OwnerUserId="17239" LastEditorUserId="17239" LastEditDate="2016-06-19T22:19:51.717" LastActivityDate="2016-06-23T20:52:20.220" Title="Bootloader sequence" Tags="|serial|bootloader|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25451" PostTypeId="2" ParentId="25448" CreationDate="2016-06-19T21:08:16.630" Score="2" Body="&lt;p&gt;Most computers begin execution at (or jump indirect through) location zero on startup. There may be variations, but this is the general idea. Whatever is put at location zero when the bootloader is installed causes the bootloader to gain control on a power-up or a reset. After that, it is up to the bootloader what happens next.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What usually happens is that the bootloader watches the serial port for the start of a &quot;handshake&quot; sequence; when (if) it sees what it is looking for, it replies in a manner that lets the loader program, e.g., avrdude, know that this is the bootloader replying and not some random text that was being sent just at that moment. (If the bootloader doesn't see the the handshake sequence begin within a short period, or it sees something other than the handshake, it starts the existing user program).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From there, the loader program and the bootloader cooperate to transfer the user program to the Arduino and load it into Flash memory at specified locations. Also transferred along with the user program is its starting address. When the upload is finished and verified, the bootloader transfers to the user program's starting address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At this point, the user program owns the machine, including the serial port(s), and will continue to do so until another power-cycle or a reset. There is no need for the user program and the bootloader to negotiate use of the port; the bootloader owns it from reset to end-of-upload, and the user program owns it thereafter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However at that point (while the user program is running) I can start&#xA;  an upload (from the IDE or avrdude).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is possible only because avrdude can send a hardware signal (&lt;em&gt;not&lt;/em&gt; contained in the data stream) that the Arduino board uses to cause the chip to reset. It is still the reset process that transfers control from the running program to the bootloader. As an example, on a number of my hand-built boards I did not include that auto-reset circuit. On those boards, avrdude cannot begin a new upload autonomously; I have to manually reset them when I start avrdude.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-06-19T22:47:21.507" LastActivityDate="2016-06-19T22:47:21.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25456" PostTypeId="1" CreationDate="2016-06-20T04:25:25.633" Score="0" ViewCount="3986" Body="&lt;p&gt;I'm trying to get GPS coordinates using my SIM808 module by connecting it with Arduino. When I use this code, &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SIM900.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &quot;gps.h&quot;&#xA;&#xA;//To change pins for Software Serial, use the two lines in GSM.cpp.&#xA;&#xA;//GSM Shield for Arduino&#xA;//www.open-electronics.org&#xA;//this code is based on the example of Arduino Labs.&#xA;&#xA;//Simple sketch to start a connection as client.&#xA;&#xA;GPSGSM gps;&#xA;&#xA;char lon[15];&#xA;char lat[15];&#xA;char alt[15];&#xA;char time[20];&#xA;char vel[15];&#xA;char msg1[5];&#xA;char msg2[5];&#xA;&#xA;char stat;&#xA;char inSerial[20];&#xA;int i = 0;&#xA;boolean started = false;&#xA;&#xA;void setup() {&#xA;  //Serial connection.&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;GSM Shield testing.&quot;);&#xA;  //Start configuration of shield with baudrate.&#xA;  //For http uses it is recommended to use 4800 or slower.&#xA;  if (gsm.begin(2400)) {&#xA;    Serial.println(&quot;\nstatus=READY&quot;);&#xA;    gsm.forceON(); //To ensure that SIM908 is not only in charge mode&#xA;    started = true;&#xA;  } else Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;  if (started) {&#xA;    //GPS attach&#xA;    if (gps.attachGPS())&#xA;      Serial.println(&quot;status=GPSREADY&quot;);&#xA;    else Serial.println(&quot;status=ERROR&quot;);&#xA;    delay(20000); //Time for fixing&#xA;    stat = gps.getStat();&#xA;    if (stat == 1)&#xA;      Serial.println(&quot;NOT FIXED&quot;);&#xA;    else if (stat == 0)&#xA;      Serial.println(&quot;GPS OFF&quot;);&#xA;    else if (stat == 2)&#xA;      Serial.println(&quot;2D FIXED&quot;);&#xA;    else if (stat == 3)&#xA;      Serial.println(&quot;3D FIXED&quot;);&#xA;    delay(5000);&#xA;    //Get data from GPS&#xA;    gps.getPar(lon, lat, alt, time, vel);&#xA;    Serial.println(lon);&#xA;    Serial.println(lat);&#xA;    Serial.println(alt);&#xA;    Serial.println(time);&#xA;    Serial.println(vel);&#xA;  }&#xA;};&#xA;&#xA;void loop() {&#xA;  //Read for new byte on serial hardware, and write them on NewSoftSerial.&#xA;  serialhwread();&#xA;  //Read for new byte on NewSoftSerial.&#xA;  serialswread();&#xA;};&#xA;&#xA;void serialhwread() {&#xA;  i = 0;&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    while (Serial.available() &amp;gt; 0) {&#xA;      inSerial[i] = (Serial.read());&#xA;      delay(10);&#xA;      i++;&#xA;    }&#xA;    inSerial[i] = '\0';&#xA;    if (!strcmp(inSerial, &quot;/END&quot;)) {&#xA;      Serial.println(&quot;_&quot;);&#xA;      inSerial[0] = 0x1a;&#xA;      inSerial[1] = '\0';&#xA;      gsm.SimpleWriteln(inSerial);&#xA;    }&#xA;    //Send a saved AT command using serial port.&#xA;    if (!strcmp(inSerial, &quot;TEST&quot;)) {&#xA;      stat = gps.getStat();&#xA;      if (stat == 1)&#xA;        Serial.println(&quot;NOT FIXED&quot;);&#xA;      else if (stat == 0)&#xA;        Serial.println(&quot;GPS OFF&quot;);&#xA;      else if (stat == 2)&#xA;        Serial.println(&quot;2D FIXED&quot;);&#xA;      else if (stat == 3)&#xA;        Serial.println(&quot;3D FIXED&quot;);&#xA;    }&#xA;    //Read last message saved.&#xA;    if (!strcmp(inSerial, &quot;MSG&quot;)) {&#xA;      Serial.println(msg1);&#xA;    } else {&#xA;      Serial.println(inSerial);&#xA;      gsm.SimpleWriteln(inSerial);&#xA;    }&#xA;    inSerial[0] = '\0';&#xA;  }&#xA;}&#xA;&#xA;void serialswread() {&#xA;  gsm.SimpleRead();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After some time, I get this error on the Serial Monitor of Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;status=ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The connections are as follows:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;TX of Module = Pin 2 of Arduino &lt;/li&gt;&#xA;&lt;li&gt;RX of Module = Pin 3 of Arduino&lt;/li&gt;&#xA;&lt;li&gt;GND of Module = GND of Arduino&lt;/li&gt;&#xA;&lt;li&gt;5V of Module = 5V of Arduino&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The Arduino is powered by USB connected to my PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4rDkI.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4rDkI.jpg&quot; alt=&quot;Here is a pic of my connections&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vrZny.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vrZny.jpg&quot; alt=&quot;This is SIM808 module.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/k0bkp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/k0bkp.jpg&quot; alt=&quot;SIM808 module.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23184" LastEditorUserId="4628" LastEditDate="2018-01-01T07:31:39.460" LastActivityDate="2019-06-20T00:28:48.527" Title="GPS is not detected on SIM808 module!" Tags="|arduino-uno|gps|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="25458" PostTypeId="1" CreationDate="2016-06-20T05:27:28.977" Score="1" ViewCount="2798" Body="&lt;p&gt;How to clear the serial buffer of arduino uno?&#xA;This is my code to on and off the LED using sms from mobile using gsm module&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;int Led=7;&#xA;&#xA;SoftwareSerial mySerial(9, 10);&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(Led,OUTPUT);&#xA;  mySerial.begin(9600);   // Setting the baud rate of GSM Module  &#xA;  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)&#xA;  delay(100);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if (mySerial.available()&amp;gt;0)&#xA;  {&#xA;&#xA;  }&#xA;   switch(mySerial.read())&#xA;  {&#xA;    case 'a':&#xA;           digitalWrite(Led,HIGH);&#xA;           delay(10000);&#xA;           digitalWrite(Led,LOW);&#xA;           delay(100);&#xA;           break;&#xA;&#xA;    case 'b' :&#xA;           digitalWrite(Led,LOW);&#xA;           break;&#xA;&#xA;&#xA;  }}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;problem is whenever i on the module or the connection is restablished it automatically gets even without an sms.I need it to be fully in my control so i need to clear the serial buffer.&lt;/p&gt;&#xA;" OwnerUserId="23186" LastEditorUserId="4131" LastEditDate="2016-06-20T13:13:50.110" LastActivityDate="2016-06-20T13:13:50.110" Title="Clearing arduino serial buffer" Tags="|gsm|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25459" PostTypeId="2" ParentId="25458" CreationDate="2016-06-20T05:51:00.073" Score="0" Body="&lt;p&gt;You can simply clear it by reading it until its empty.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(Serial.available()){&#xA;    Serial.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There also used to be a &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.flush();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to clear the serial. However they changed it to some other functionality. For further details you can look at the arduino reference page on Serial.&lt;/p&gt;&#xA;" OwnerUserId="21491" LastActivityDate="2016-06-20T05:51:00.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25460" PostTypeId="1" CreationDate="2016-06-20T06:39:19.033" Score="1" ViewCount="2828" Body="&lt;p&gt;I am trying to build a Smart Led project using Arduino Uno, RGB Led, HM-10 BLE module, and Android device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am able to connect HM-10 with my android device and read and write characteristic values using Android BlueDroid stack.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for this project to work I need to check changes in characteristic value in Arduino and process color value and produce output to light up LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought I could possibly use AT commands (like AT+Name? AT+POWE? AT+CHAR?) parse their result , but I couldn't find any AT command to read characteristic value. &lt;strong&gt;If anyone know such working AT commands for HM-10, please answer?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I looked into CurieBLE library from Intel for Arduino. I think the library is to work on an Arduino board which has BLE hardware as a built-in feature. If that's not the case, &lt;strong&gt;please help me how can I communicate Arduino and HM-10 using CurieBLE or any other available library?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="23050" LastEditorUserId="23050" LastEditDate="2016-06-28T08:29:42.207" LastActivityDate="2018-10-12T20:00:17.337" Title="Read BLE Characteristic Value in Arduino Uno" Tags="|arduino-uno|bluetooth|rgb-led|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25465" PostTypeId="2" ParentId="25438" CreationDate="2016-06-20T10:16:10.947" Score="4" Body="&lt;p&gt;There is a problem with your circuit and the way you have it wired when programming. You have failed to use the RTS line for Serial programming. You need to have that line connected to the RESET of the ATMega328, this is as the bootloader for programming ove rserial will not start if the IC is not reset. Also you should burn the Arduino UNO bootloader rather than the one you chosen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems you clarified you were using the diode as ESD protection, thank you. It is the recommended arrangement if you have a capacitor attached to the reset line in noisy environments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit between the RTS signal and the Arduino RESET pin needs to be this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;            C&#xA; RTS &amp;gt;&amp;gt;----||-------&amp;gt;&amp;gt; RESET(PIN1)&#xA;           0.1µF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From the same &quot;&lt;a href=&quot;https://arduino.stackexchange.com/a/13293/2944&quot;&gt;Have I bricked my Arduino&lt;/a&gt;&quot; that you linked, about 3/4 down Nicks post he mentions the use of serial programming of an Arduino&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;FTDI    Arduino Uno&#xA;&#xA;GND       GND  (black wire on FTDI cable, blue jumper wire)&#xA;CTS       not connected&#xA;VCC       5V&#xA;TxD       D0 (RX)&#xA;RxD       D1 (TX)&#xA;RTS       To RESET with a 0.1 µF capacitor in series with it (green wire)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you can do if you don't have the proper serial programmer with an RTS output, you will have to manually reset the microcontroller to enter the bootloader just as the IDE says &quot;Uploading...&quot;.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-20T17:03:08.817" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25467" PostTypeId="2" ParentId="25458" CreationDate="2016-06-20T12:36:54.747" Score="1" Body="&lt;p&gt;If you are receiving unsolicited message (reading junk) then you could extend the bit pattern you are expecting so that there is almost no possibility of you accidentally receiving it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than 'a' and 'b' as triggers user LED=&quot;0&quot; and LED=&quot;1&quot;.  Doing this makes reading the data much harder, because what you are looking for may start on character 4 of the string you read.  This is what I think you will need to do.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Read each character in turn and store them in a buffer until you have 7.&lt;/li&gt;&#xA;&lt;li&gt;Is the first character an L.&lt;/li&gt;&#xA;&lt;li&gt;If it isn't then delete the first character, shuffle the buffer left&#xA;one place and load in the next character before returning to step 1.&lt;/li&gt;&#xA;&lt;li&gt;If it was, check the next character matches the expected.&lt;/li&gt;&#xA;&lt;li&gt;If it doesn't match delete all character to the left and this one and return to step one.&lt;/li&gt;&#xA;&lt;li&gt;If you have a matching token then parse it (get the 1 or 0) and do the action.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-20T12:36:54.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25468" PostTypeId="2" ParentId="25446" CreationDate="2016-06-20T13:02:12.677" Score="0" Body="&lt;p&gt;I have taken your code from above and compiled it for a PC in Visual Studio.&#xA;When I create an object of type DigitalOutPin and call setPinValue() it calls the function I expect.  So this means either you have managed to find a bug in the gcc compiler, or there is something else in your code that is coming into play.  Can you try writing a VERY simple minimal test program that defines the Pin class and DigitalOutPin class (with just the setPinValue functions that print a string) and the setup and loop functions.  Just to see if you have found a gcc bug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if this fixes the inheritance problem, you have other issues with you code because C++ is weird.  In Channel.h your Pin variables will need to be pointers, this will allow them to call the functions in the derived classes, not the base class functions.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you may get a performance improvement by using &quot;const int&amp;amp; foo&quot; for you parameters.  The const means the function can't change it, this allows the compiler to treat it differently and the &quot;&amp;amp;&quot; means use a reference to the variable rather than make a new copy of it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Functions that don't change member variables within the code should also be declared constant.  &quot;int FooBar(const int&amp;amp; value) const;&quot;  It makes it clearer to the reader and the compiler probably does some funky stuff to improve performance.  (You might want to investigate &quot;inline&quot; if you are writing one line functions.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally I'd recommend using constructors and destructors.  In release builds variables are not assigned a value.  If these variables are class members this means you don't know what they are to start with.  Also derived classes should initialise the base class, so:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Class constructor for DigitalOutPin&#xA;DigitalOutPin::DigitalOutPin(const int&amp;amp; pinNumber)&#xA;  : Pin(pinNumber)  // Initialise the base class&#xA;  , m_State(false)  // Initialise all the class members (in order declared in .h file)&#xA;{&#xA;  // Lots of lovely code&#xA;}&#xA;// Class destructor for DigitalOutPin (Declared as virtual)&#xA;DigitalOutPin::~DigitalOutPin()&#xA;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-20T13:02:12.677" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25472" PostTypeId="1" CreationDate="2016-06-19T21:04:21.760" Score="2" ViewCount="1815" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/AlmKv.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/AlmKv.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;I am a newbie to Arduino and created my first project. The project is using a Sharp short range sensor and a 7 seg LED board (&lt;a href=&quot;http://embedded-lab.com/blog/new-version-of-max7219-based-4-digit-serial-seven-segment-led-display/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://embedded-lab.com/blog/new-version-of-max7219-based-4-digit-serial-seven-segment-led-display/&lt;/a&gt;) to count objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything works fine when on USB power to my computer or if I use a 5v 1A wall adapter with a USB cable. The problem is when I use an external power adapter or use a DC power supply to the Vin. The board powers up and I measured the output voltage on the 5v pin and is measuring around 4.8v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sharp sensor is connected to the A0 Analog in and I see the voltage fluctuate when an object passes, but the LED is not displaying a value when on the external power. The display is connected to GRD, 5v where DIN, CLK, and LOAD pins of the display are connected to pins 7, 6, and 5 as the instructions stated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried two different Arduino boards and several different AC to DC power adapters ranging from 9v to 12v plus used a DC power supply to the Vin and same results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is below and pretty simple (although I am sure there is a lot better way of doing it but this is my first project in C so go easy on me and the function for digits is from a website and not written by me).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If a picture of the project would help I can upload one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas or thoughts?&#xA;Thanks,&#xA;Steve&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;LedControl.h&quot;&#xA;#include &amp;lt;stdio.h&amp;gt;&#xA;#include &amp;lt;math.h&amp;gt;&#xA;&#xA;// Arduino Pin 7 to DIN, 6 to Clk, 5 to LOAD, no.of devices is 1&#xA;LedControl lc = LedControl(7, 6, 5, 1);&#xA;int sensorpin = 0;      // analog pin used to connect the sharp sensor&#xA;int val = 0;            // variable to store the values from sensor(initially zero)&#xA;int cnt = 1;&#xA;&#xA;void setup()&#xA;{&#xA;    // Initialize the MAX7219 device&#xA;    lc.shutdown(0, false);   // Enable display&#xA;    lc.setIntensity(0, 10);  // Set brightness level (0 is min, 15 is max)&#xA;    lc.clearDisplay(0);     // Clear display register&#xA;&#xA;&#xA;}&#xA;void loop()&#xA;{&#xA;&#xA;&#xA;    val = analogRead(sensorpin);       // reads the value of the sharp sensor&#xA;    if (val &amp;gt;= 650)&#xA;    {&#xA;&#xA;    //write values to LED&#xA;    if (cnt&amp;lt;=9)&#xA;    {&#xA;        lc.setDigit(0, 0, cnt, false); // Display 4 to Digit 1-9, &quot; &quot;&#xA;    }&#xA;    if (cnt &amp;gt;= 10 &amp;amp;&amp;amp; cnt &amp;lt;= 99)&#xA;    {&#xA;        lc.setDigit(0, 0, getDigitFromNum(cnt,0), false); // Display 4 to Digit 1-9, &quot; &quot;&#xA;        lc.setDigit(0, 1, getDigitFromNum(cnt, 1), false); // Display 3 to Digit 1-9, &quot; &quot;&#xA;    }&#xA;&#xA;    if (cnt &amp;gt;=100)&#xA;    {&#xA;        lc.setDigit(0, 0, getDigitFromNum(cnt, 0), false); // Display 4 to Digit 1-9, &quot; &quot;&#xA;        lc.setDigit(0, 1, getDigitFromNum(cnt, 1), false); // Display 3 to Digit 1-9, &quot; &quot;&#xA;        lc.setDigit(0, 2, getDigitFromNum(cnt, 2), false); // Display 2 to Digit 1-9, &quot; &quot;&#xA;    }&#xA;&#xA;    delay(400);&#xA;    cnt++;&#xA;&#xA;}&#xA;}&#xA;&#xA;// Function: getDigitFromNum returns a digit at a given index of a integer.&#xA;// Goes from right to left with the starting index of 0.&#xA;int getDigitFromNum(int num, int digit) {&#xA;    num /= pow(10, digit);&#xA;    return num % 10;&#xA;}&#xA;// Function: getDigitFromDec returns a digit at a given index of a double.&#xA;// Goes from left to right with the starting index of 0.&#xA;int getDigitFromDec(double dec, int digit) {&#xA;    dec *= pow(10, digit);&#xA;    return (int)dec % 10;&#xA;}&#xA;// Function: getDigitFromNum returns the decimal values of a double.&#xA;double getDecimals(double dec) {&#xA;    return dec - (int)dec;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Steven Thorne" LastEditorUserId="37523" LastEditDate="2018-07-26T22:43:33.720" LastActivityDate="2018-07-26T22:43:33.720" Title="Arduino Uno - External Power not working properly" Tags="|arduino-uno|" AnswerCount="1" CommentCount="13" ContentLicense="CC BY-SA 4.0" />
  <row Id="25474" PostTypeId="2" ParentId="25472" CreationDate="2016-06-20T14:40:12.327" Score="2" Body="&lt;p&gt;The only difference between powering from USB and powering through the barrel jack is the voltage is reduced to 5V through a Low Dropout (LDO) voltage regulator. These are typically a clone of the popular LM1113-50 and vary in current handling capacity from around 500mA up to 1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I notice your board is not a genuine Arduino - therefore the components used may be at the cheaper end. So we'll assume a low-grade LDO that only handles 500mA before going into thermal shutdown with good heatsinking. Since there isn't on these boards we shall therefore assume a maximum of 400mA before it gets too hot. Probably somewhat conservative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if your entire circuit is drawing more than about 400mA you can expect the regulator to shut down, or at least to reduce the current and/or voltage available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact you're seeing 4.8V rather than 5V could be an indication that there is &lt;em&gt;voltage droop&lt;/em&gt; occurring - i.e., the regulator is not able to supply enough current so the voltage drops. This would be accompanied by the regulator getting very hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The regulator is the device with 3 pins on the right side and a single tab on the left directly above the barrel jack socket. See how hot that is getting.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a rule of thumb if you can hold your finger on it without crying for 10 seconds it's not too hot.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Another thing you can do is to reduce your circuit to the bare minimum. Unplug absolutely everything and upload the Blink example sketch. Power that from the external DC and see if the LED blinks for you. If it does then the power supply is working OK. You can then add your peripherals one at a time to see when it fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it doesn't blink then there must be something inherently wrong with the supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possibility is that the LDO is &lt;em&gt;oscillating&lt;/em&gt; due to insufficient or incorrect input and output capacitors. This basically means the &quot;5V&quot; voltage it gives out is actually wildly swinging between say 4.5V and 5V or 4.75V and 5.25V, which really confuses the microcontroller. Cheap LDOs are often more sensitive to the capacitors they are paired with and can suffer from this kind of problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To diagnose that kind of thing you would really need access to an oscilloscope to analyse the voltage. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is oscillating a 10µF ceramic capacitor connected between the lower two pins of the LDO (as orientated in your picture - that is Vout and GND) may cure it. A 1206 surface mount capacitor fits nicely across those pins and is reasonably easy to hand solder. You could also try a through-hole capacitor (ceramic again) between 5V and GND on the power header, but you really want it as close to the LDO as you can get it, so soldered direct to the LDO's pins is best.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-20T14:40:12.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25478" PostTypeId="1" AcceptedAnswerId="25479" CreationDate="2016-06-20T15:14:29.307" Score="0" ViewCount="5784" Body="&lt;p&gt;I am trying to make an obstacle avoiding robot with robotic arm. First, I am from software programming field with no experience in electronics, circuits and Arduino. Using online tutorials so far I am able to blink an led, bluetooth communication between PC and Arduino and sonar range measurement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After doing a lot of research on internet I have made the following diagram to connect  4 servos, 2 motors, hc-05, sr-04 and L293D to Arduino using &quot;fritzing&quot; software. I have the sketches for running servos and motors but I am not sure the circuit is correct due to the lack of knowledge in electronics. My doubts are,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Is 6V supply enough for 4 servos and 2 dc to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Is the connection between L293D and 2 DC motors correct?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final robot will look like (I hope!) a &quot;mearm&quot; like robot arm attached on top of an obstacle avoiding robot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tvi9Y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tvi9Y.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATED:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dk0MB.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dk0MB.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23202" LastEditorUserId="23202" LastEditDate="2016-06-20T16:50:46.010" LastActivityDate="2017-08-19T03:18:53.540" Title="Connecting 4 servos, 2 motors, hc-05, sr-04 and L293D to Arduino" Tags="|arduino-uno|motor|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25479" PostTypeId="2" ParentId="25478" CreationDate="2016-06-20T15:40:47.957" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;1) Is 6V supply enough for 4 servos and 2 dc to work?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If the motors are 6V motors then 6V is not only enough, it is what you &lt;em&gt;need&lt;/em&gt;. What you should be asking is &quot;Can my power source provide enough &lt;strong&gt;current&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;2) Is the connection between L293D and 2 DC motors correct?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not quite. You have only got half your grounds connected up. Also 3,4EN should be connected to Vcc1 not Vcc2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1A/2A and 3A/4A are the direction/break pins (one high and one low for a direction, both low for break). The EN pins can be (if you wish) used to control the speed with PWM (if you have any spare) - if not then they should be tied to the logic supply voltage, Vcc1, not the power supply voltage, Vcc2, since that can be up to 36V and is way too high for logic inputs like EN. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-20T15:40:47.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25480" PostTypeId="1" AcceptedAnswerId="25488" CreationDate="2016-06-20T15:45:49.023" Score="2" ViewCount="197" Body="&lt;p&gt;I am newer to arduinos, and could use some help. I have a LCD screen hooked up to an arduino uno. I can get it to display whatever I type in, which is great. But, what i want it to display is a value from an excel spreadsheet. So, it will change depending on what is in that field. Or even better yet, from access. Is this possible? is there code to have the arduino pull information from an existing table? (assuming it is connected via USB, or, eventually, wifi). thanks!&lt;/p&gt;&#xA;" OwnerUserId="23206" LastActivityDate="2016-06-21T07:57:55.553" Title="Arduino LCD Screen" Tags="|arduino-uno|lcd|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25483" PostTypeId="1" CreationDate="2016-06-20T16:53:16.370" Score="0" ViewCount="412" Body="&lt;p&gt;I saw a &lt;a href=&quot;https://www.youtube.com/watch?v=0PgFK85fIHM&quot; rel=&quot;nofollow&quot;&gt;YouTube Video&lt;/a&gt; of someone who used an aux cord input into pin A0 on their Arduino to control a strip of LEDs. I have a strip of &lt;a href=&quot;https://www.adafruit.com/products/1461&quot; rel=&quot;nofollow&quot;&gt;Adafruit's RGB NeoPixel LEDs&lt;/a&gt;, but I'm not sure how to input my audio into pin A0. If there is a way to do this without a separate shield or board, that'd be great because I'm on a tight budget, but if not possible it'll have to do. Also, would it be possible to send this audio to another Arduino via wifi or bluetooth using a different shield? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="17021" LastEditorUserId="17021" LastEditDate="2016-06-20T17:09:27.017" LastActivityDate="2016-06-20T18:19:43.300" Title="Audio Input into A0?" Tags="|led|bluetooth|audio|rgb-led|neopixel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25484" PostTypeId="2" ParentId="25483" CreationDate="2016-06-20T18:11:15.990" Score="3" Body="&lt;p&gt;Depending on how loud your audio signal is, you may be able to do it with just one capacitor and two resistors:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/n9ONN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/n9ONN.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your signal is quite quiet, though, you may need to amplify it using an op-amp. For instance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/tgsiz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tgsiz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That arrangement would double the volume of the audio. It also has the effect of inverting it, so you will need to invert your readings in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that both of these methods will give you an AC waveform centred around 2.5V, so silence will be a reading of around 512, and it will go up and down from there. You can sample that audio waveform and do some basic (though quite slow on an Arduino) analysis of it, such as FFT to get the frequency content of the audio - great for visual effects...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-20T18:19:43.300" LastActivityDate="2016-06-20T18:19:43.300" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25486" PostTypeId="1" AcceptedAnswerId="25493" CreationDate="2016-06-20T19:19:37.373" Score="0" ViewCount="212" Body="&lt;p&gt;So, I'm not sure what is causing this, but maybe I'm overlooking something simple. I have a simple program designed to read the analog input at 640 Hz, it looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Ch0 = 0;&#xA;int count = 0;&#xA;unsigned long startTime;&#xA;unsigned long currentTime;&#xA;bool startedReading = false;&#xA;&#xA;&#xA;void setup() {&#xA;  //set up pin(s)&#xA;   pinMode(Ch0, INPUT);&#xA;&#xA;  //begin serial at 115200bps&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;...&#xA;&#xA;//if the current time exceeds the start time by one second, set the start time equal to current time, print the count, set count equal to zero&#xA;if (currentTime - startTime &amp;gt;= 1000) {&#xA;  startTime = currentTime;&#xA;  Serial.println(&quot;time&quot;);&#xA;  count = 0;&#xA;}&#xA;&#xA;&#xA;&#xA;//read input, delay some microseconds as a means of controlling sampling rate, bring count up by one&#xA;//should read somewhere along the lines of 640-ish Hz&#xA;analogRead(Ch0);&#xA;delayMicroseconds(1230);&#xA;Serial.println(count);&#xA;count++;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this all works fine and dandy in the Arduino IDE, I pull up the Serial Monitor, and it prints every number 1-640 and then says time, with good consistency. Yet, when I open up a Visual Studio program and call the command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Added entire data received event method&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;private: System::Void serialPort1_DataReceived(System::Object^  sender, System::IO::Ports::SerialDataReceivedEventArgs^  e) {&#xA;    if (!this-&amp;gt;reading) return;&#xA;    else &#xA;    {&#xA;         try&#xA;         {&#xA;            //get incoming port and read&#xA;            SerialPort^ sp = (SerialPort^)sender;&#xA;            String^ sInData = sp-&amp;gt;ReadLine();&#xA;            //parse read data&#xA;            double inData = double::Parse(sInData);&#xA;&#xA;            //write data to debugger for testing&#xA;            Debug::WriteLine(inData);&#xA;&#xA;&#xA;            //start populating the &quot;in&quot; array&#xA;            AppendIn(inData);&#xA;          }&#xA;          catch (Exception^ e)&#xA;          {&#xA;            Debug::WriteLine(e-&amp;gt;Message);&#xA;          }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Aside from the obvious error that occurs when I try to parse the string &quot;time&quot; to indicate when 1 second has elapsed, everything works fine. Except for the fact that the numbers feed into the debugger &lt;em&gt;very&lt;/em&gt; slowly. As in, it'll take roughly 4-5 seconds to read through all 640 reads of the count integer and then it throws the time at me. Thus, this leads me to conclude that Arduino is indeed calculating that 1 second has elapsed and then sending that over, but the output is essentially the same, the only difference being that the message takes exactly 1 second to read on the Arduino IDE and over 4 seconds to read in real time in Visual Studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maybe it has something to do with the way I'm reading the data in VS? I have it set up to constantly monitor the stream by calling that read method every as an event when data is received over the serial. No data at all is being lost, it's just very slow...and only in VS. Thanks in advance for any help you can give, but I'm at a bit of a loss.&lt;/p&gt;&#xA;" OwnerUserId="17238" LastEditorUserId="17238" LastEditDate="2016-06-21T00:54:01.190" LastActivityDate="2016-06-21T00:54:01.190" Title="Significant drop in speed between Arduino IDE and Visual Studio?" Tags="|arduino-mega|c++|arduino-ide|visualstudio|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25488" PostTypeId="2" ParentId="25480" CreationDate="2016-06-20T22:40:16.537" Score="1" Body="&lt;p&gt;Assuming your Excel spreadsheet or Access table is stored on your PC, you can write a PC program to read the file and send the data serially over the USB connection to the connected Arduino, which can display it on the LCD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the file is stored on an SD card instead, and you want the Arduino to access the file directly by reading said SD card (through an Ethernet shield perhaps), you need to make the file format a lot simpler than XLS to ease parsing; CSV is quite simple and suitable for a lot of tasks. The built-in &lt;code&gt;SD&lt;/code&gt; library can be employed to read the data from the card, the Arduino parses the data and displays it on the LCD. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, I suggest you do more research.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-06-20T22:40:16.537" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25489" PostTypeId="1" AcceptedAnswerId="25516" CreationDate="2016-06-20T22:53:29.203" Score="1" ViewCount="799" Body="&lt;p&gt;Apparently &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00E594ZX0&quot; rel=&quot;nofollow&quot;&gt;these nRF24L01+ modules&lt;/a&gt; need 3.3v, but I've only got 5v Trinket Pros that I'm using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I reduce the voltage to the RF transmitter?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would a voltage regulator work? Specifically looking at this: &lt;a href=&quot;http://addicore.com/product-p/165.htm&quot; rel=&quot;nofollow&quot;&gt;http://addicore.com/product-p/165.htm&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-07-18T02:35:32.607" Title="Reduce 5v Trinket Pro to 3.3v?" Tags="|voltage-level|adafruit|nrf24l01+|rf|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25490" PostTypeId="2" ParentId="25489" CreationDate="2016-06-20T23:15:59.463" Score="-1" Body="&lt;p&gt;There are 3.3V Trinkets. Anything you try to do will cost more than buying one.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-06-20T23:15:59.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25491" PostTypeId="1" AcceptedAnswerId="25492" CreationDate="2016-06-20T23:18:40.860" Score="1" ViewCount="453" Body="&lt;p&gt;I'm trying to understand the &quot;programmer-id&quot; concept, as specified in &lt;code&gt;-c&lt;/code&gt; &lt;code&gt;avrdude&lt;/code&gt;'s option. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;avrdude&lt;/code&gt; asks me to choose a &quot;&lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions&quot; rel=&quot;nofollow&quot;&gt;programmer-id&lt;/a&gt;&quot; among many it knows of.&#xA;Let's say (just as an example) I have a Arduino 2560 to which I connect via USB, and I want to program it using the bootloader.  Then, in this scenario,&#xA;is one programmer-id and just one supposed to work? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;More in general, one has &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) some particular board (MCU, &lt;code&gt;-p&lt;/code&gt; in &lt;code&gt;avrdude&lt;/code&gt;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) some particular &lt;a href=&quot;http://www.ladyada.net/learn/avr/programmers.html&quot; rel=&quot;nofollow&quot;&gt;programming method/connection&lt;/a&gt; (JTAG, ISP, development board, USB/serial,  etc) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) (if using bootloader) some particular bootloader code in Flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How are these things related with the programmer selection? I guess that some (most?) programmers-ids are specific to some programmer connection/method (AND probably with some hardware family?), and they have nothing to do with the bootloader.  What is the programmer to use for a standard Arduino with bootloader, connected via USB? What more can be said?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, the Arduino IDE lets me choose &quot;Upload&quot; and &quot;Upload Using Programmer&quot; (the first works for me, the second doesn't). Why this distinction? Isn't a programmer always used? What does the IDE do, under the hood (does it call avrdude?) when choosing &quot;Upload&quot; ? &lt;/p&gt;&#xA;" OwnerUserId="17239" LastEditorUserId="17239" LastEditDate="2016-08-12T00:31:23.517" LastActivityDate="2016-08-12T00:31:23.517" Title="Relationship between avrdude's &quot;programmer&quot; and bootloaders" Tags="|uploading|avrdude|programmer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25492" PostTypeId="2" ParentId="25491" CreationDate="2016-06-20T23:28:57.103" Score="4" Body="&lt;p&gt;If you are using the bootloader, you are &lt;em&gt;not&lt;/em&gt; using a programmer. The programmer, when used, is connected to the ICSP pins on the Arduino. The bootloader however expects a well-defined sequence of data from the Arduino &lt;em&gt;through the serial port&lt;/em&gt; immediately after reset. The bootloader recognizes that (if received) and reprograms the flash.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you turn on verbose mode for uploading you will see the programmer type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-carduino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, the Arduino is using the bootloader programming method.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See my post here: &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Furthermore, the Arduino IDE lets me choose &quot;Upload&quot; and &quot;Upload Using Programmer&quot; (the first works for me, the second doesn't).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, with &quot;Upload Using Programmer&quot; you need a programmer, such as the AVRISP which you would plug into your USB port, and then select that as the type of programmer to use. In this case, your Arduino does not need to be plugged into the USB as the serial port is not used for programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that some programmers supply Vcc (ie. +5V) to the Arduino and some don't. The AVRISP doesn't.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Furthermore, it seems that that &quot;Optiboot&quot; is a different bootloader than the standard included in the Arduino.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As far as I know, recent Arduino Unos (and probably others) ship with Optiboot. Its main advantage is that it is smaller (only 512 bytes).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;More in general, do avrdude need to know the particular bootloader?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think the smaller boards use STK500 protocol (see links below) and the larger ones (eg. the Mega) use STK500 Version 2. That is because they have a larger address space. So yes, it needs to know the protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I switched my board type to Mega2560 the &quot;-c&quot; option changed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-cwiring&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am guessing from that, the &quot;arduino&quot; is code for &quot;STK500&quot; and &quot;wiring&quot; is code for &quot;STK500 V2&quot;.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;Protocols&lt;/h2&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc2525.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR061: STK500 Communication Protocol&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.atmel.com/Images/doc2591.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR068: STK500 Communication Protocol version 2&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-06-21T00:04:29.740" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25493" PostTypeId="2" ParentId="25486" CreationDate="2016-06-20T23:32:52.717" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I have it set up to constantly monitor the stream by calling that read method every as an event when data is received over the serial.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I suspect that is the issue. Waiting for an incoming &quot;serial data available&quot; event and then processing it, is likely to be slow. I would rework how you get serial data. You haven't shown that bit but maybe you can use a larger buffer.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-20T23:32:52.717" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25498" PostTypeId="1" CreationDate="2016-06-21T03:33:39.810" Score="1" ViewCount="546" Body="&lt;p&gt;With a push button on an Arduino (or Raspberry Pi), instead of wiring a high voltage (5v) through a button and to a pin to read the input, you often want your input pin set to HIGH (high impedance) and wired through a switch to ground to avoid interference like EM waves. My question is what exactly does setting the input pin to HIGH do (besides making it high impedance)? Does it make the circuit less sensitive to EM interference? I like to understand more of the physics behind circuit design.&lt;/p&gt;&#xA;" OwnerUserId="23226" LastActivityDate="2016-06-21T06:05:03.553" Title="Arduino Button interference" Tags="|arduino-uno|pins|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25499" PostTypeId="1" CreationDate="2016-06-21T04:52:31.847" Score="1" ViewCount="3048" Body="&lt;p&gt;I'm working on a project in my university and I'm having a trouble in calculate time. I have a conveyor and an IR sensor which I use to calculate the maximum and minimum distances of a box when it is moving on the conveyor. Then I want to calculate the time between the max and min distances of box. I have used millis() for timing but it is not accurate.&#xA;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int IRpin = 0;&#xA;float volts, distance,firstdata;&#xA;int k = 0;&#xA;float min;&#xA;float mang[150];&#xA;int m;&#xA;void setup() {&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;volts = analogRead(IRpin) * 0.0048828125;&#xA;distance = 13 * pow(volts, -1.10);&#xA;if (distance &amp;lt; 20)&#xA;{&#xA;Serial.println(distance);&#xA;mang[k] = distance;&#xA;k++;&#xA;}&#xA;else&#xA;{&#xA;if (k &amp;gt; 0)&#xA;{&#xA;  min = mang[0];&#xA;  for (int i = 1; i &amp;lt; k; i++)&#xA;  {&#xA;&#xA;    if (min &amp;gt; mang[i])&#xA;    {&#xA;      min = mang[i];&#xA;      m = i;&#xA;    }&#xA;  }&#xA;  firstdata=mang[1];&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I store data the sensor send to me in an array. Now I want to calculate the time between firstdata [mang(1)] and [(min)]. I use 0A41SK Sharp IR sensor.&#xA;Thank you for your time and sorry for my bad english.&lt;/p&gt;&#xA;" OwnerUserId="23229" LastActivityDate="2016-12-23T09:17:59.280" Title="Calculate time between 2 data of a sensor" Tags="|arduino-uno|sensors|time|ir|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25501" PostTypeId="2" ParentId="25498" CreationDate="2016-06-21T06:05:03.553" Score="2" Body="&lt;p&gt;In Arduino, just setting the pin as input already makes it high impedance.  &lt;br&gt;&#xA;Writing HIGH on an input pin actually enables its internal pull-up resistor.  &lt;br&gt;&#xA;This way, the voltage at the pin is always defined (instead of floating when the switch is open).  &lt;br&gt;&#xA;Just search for &quot;pull-up resistor&quot; if you need more information.  &lt;br&gt;&#xA;Note that this code:  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(n, INPUT); // set as input, high-impedance&#xA;digitalWrite(n, HIGH); // activate the internal pull-up resistor&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is equivalent to this (in recent Arduino IDEs):  &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(n, INPUT_PULLUP)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20696" LastActivityDate="2016-06-21T06:05:03.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25502" PostTypeId="1" CreationDate="2016-06-21T06:15:59.243" Score="0" ViewCount="207" Body="&lt;p&gt;Is there a sensor I could use which would let me know which direction an object is heading/facing? i.e. I have a servo that can rotate 0 to 180 degrees, and I have another sensor on a block. When I turn the block 45 degrees, I want the servo to also turn 45 degrees - I thought I could do this with a compass, but the varying magnetic fields make it impossible. Gyro/acc maybe? Except I don't know how to use that to solve this problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in other words we need to know the block was rotated 45 degrees using a sensor on the block, which tells the servo to rotate 45 degrees.&lt;/p&gt;&#xA;" OwnerUserId="23232" LastActivityDate="2016-12-24T21:45:06.237" Title="Determine Object Heading" Tags="|arduino-uno|sensors|esp8266|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25503" PostTypeId="2" ParentId="25489" CreationDate="2016-06-21T07:26:54.387" Score="-1" Body="&lt;p&gt;As said by JayEye: there are 3,3V Trinkets and that is probably the cheapest option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to pay the extra money, there are special boards for it by addicore: &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00VFNZN8K&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/gp/product/B00VFNZN8K/ref=s9_dcacsd_bhz_bw_c_x_3&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;third option is to build yourself a small voltage regulating circuit. The regulator that you linked to will do.&lt;/p&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-06-21T07:26:54.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25504" PostTypeId="2" ParentId="25480" CreationDate="2016-06-21T07:57:55.553" Score="1" Body="&lt;p&gt;It is not the easiest thing to do especially if you are newer to arduinos but Roberto Valgolio has made an Arduino Excel interface: &lt;a href=&quot;http://www.robertovalgolio.com/sistemi-programmi/arduino-excel&quot; rel=&quot;nofollow&quot;&gt;http://www.robertovalgolio.com/sistemi-programmi/arduino-excel&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not worked with it yet but it's worth looking into it.&lt;/p&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-06-21T07:57:55.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25505" PostTypeId="1" CreationDate="2016-06-21T08:20:53.770" Score="0" ViewCount="89" Body="&lt;p&gt;I'm working on a Virtual Reality game. I want to detect the position or movement of most of the bones in the human body(e.g. Knees, elbows, shoulders, hands and legs). This person may wear special equipment. How should I detect this?? I also want to get the distances between a certain position(e.g. The Arduino board) and each bone. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="23104" LastActivityDate="2016-06-21T10:26:02.513" Title="Detect movements of a person?" Tags="|sensors|" AnswerCount="1" CommentCount="2" ClosedDate="2016-06-22T09:38:33.990" ContentLicense="CC BY-SA 3.0" />
  <row Id="25507" PostTypeId="2" ParentId="25505" CreationDate="2016-06-21T10:26:02.513" Score="2" Body="&lt;p&gt;What you're looking for is called motion capture. If you google it, you'll find a Wikipedia article that can give you a starting point for deciding which of the many available techniques will suit your project. Youtube also has several videos explaining motion capture, and different technologies.&lt;/p&gt;&#xA;" OwnerUserId="21015" LastActivityDate="2016-06-21T10:26:02.513" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25509" PostTypeId="1" AcceptedAnswerId="25515" CreationDate="2016-06-21T11:43:21.933" Score="0" ViewCount="108" Body="&lt;p&gt;I have this book here about Arduino. What kind of Kit should I purchase to get started? Would &lt;a href=&quot;https://www.amazon.it/gp/product/B014L11IN6/ref=s9_wsim_gw_g147_i4_r?pf_rd_m=A11IL2PNWYJU7H&amp;amp;pf_rd_s=desktop-1&amp;amp;pf_rd_r=8Z4628HN1J4H6NG4KKHX&amp;amp;pf_rd_t=36701&amp;amp;pf_rd_p=6127e987-ce6a-47ca-bd15-51701a16b93c&amp;amp;pf_rd_i=desktop&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; work?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I'm not yet sure about what I'd like to do with Arduino, so I may prefer a pretty &lt;strong&gt;&lt;em&gt;Universal Kit&lt;/em&gt;&lt;/strong&gt; in order to cover a pretty wide range of projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except this, I won't need any advanced stuff, at the moment, as a beginner I may want to understand the fundamentals, so will surely need &lt;strong&gt;LEDs&lt;/strong&gt;, maybe &lt;strong&gt;screens&lt;/strong&gt;, and other &lt;strong&gt;basic&lt;/strong&gt; stuff like that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Later on I may try to go for Wireless modules, but not at the moment as a beginner.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? Hope to have clarified more or less what projects I'm aiming to, yeah the range is wide, but restricted to basic beginner projects.&lt;/p&gt;&#xA;" OwnerUserId="15170" LastActivityDate="2016-06-21T13:22:38.737" Title="Starter Kit for Arduino Cookbook" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25510" PostTypeId="1" CreationDate="2016-06-21T04:58:20.857" Score="-1" ViewCount="129" Body="&lt;p&gt;I am trying to connect an Arduino with SIM300 and GPS module to upload data directly into a database on my localhost using GPRS of the SIM inserted. I am not able to interface the separate GPS and GSM modules. Kindly help in this regard.&lt;/p&gt;&#xA;" OwnerDisplayName="arun soni" LastEditorUserId="27346" LastEditDate="2018-11-11T15:22:56.467" LastActivityDate="2018-11-11T15:22:56.467" Title="How to connect an Arduino with SIM300 and a seperate GPS module?" Tags="|gps|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25511" PostTypeId="2" ParentId="25510" CreationDate="2016-06-21T09:48:18.007" Score="2" Body="&lt;p&gt;I know I should write this in comment section , but as comment have word limitation and I'm going to give you a idea why this should not be a question and how should you go for your problem, I'm writing it in answer section.Please don't down voted me :p&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You miss the point of my comment. This is a forum where you ask about your problem and people try to help you to solve it. It's not a tutorial providing forum. But from you'r question as far as I understand , you want more or less  a full tutorial about your circuit. That's why you are getting down vote.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you should run your module individually . Here is two YouTube tutorial link for your GPS and GSM modules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=-okAX7ZoGDk&quot; rel=&quot;nofollow&quot;&gt;GSM module tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=bgOZLgaLa0g&quot; rel=&quot;nofollow&quot;&gt;GPS module tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can look for more tutorials in YouTube and build a besic idea. Then make GSM and GPS module working individually. When individually they work, then add there code and components and run the whole system. This way , it will be easy for you to detect where the problem is. If you'r device fail and you can't find or solve the problem, then ask here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some rules how to ask questions here, follow them. Give total idea about your problem and how far you can debug.If possible, add your code and circuit diagram. Hope we can help you then.&lt;/p&gt;&#xA;" OwnerUserId="20268" OwnerDisplayName="Anklon" LastActivityDate="2016-06-21T09:48:18.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25512" PostTypeId="2" ParentId="25509" CreationDate="2016-06-21T12:33:43.570" Score="0" Body="&lt;p&gt;The Stack Exchange format is not well suited for opinions.  That said, people are apparently giving the kit good reviews.  And I see hardware that appears to allow for several projects (LED arrays?, motors?, ultrasonic-distance-measurement?, IR-remote-control?, Alpha-numeric-LCD?, 7-segmet-LED-display?, ect).  Which is more than you need for basic Arduino projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, it would make the most sense to find a kit with a book rather than obtain a book and a kit separately. This is because slight differences between the written material and independently obtained hardware will cause confusion.  This is generally not a problem for experienced embedded developers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Keep in mind that embedded processor projects are half hardware and half software.  Since the hardware has already been collected, the majority of activity will be in software.  If this paradigm agrees with you, good luck &amp;amp; have fun.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-21T12:33:43.570" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25514" PostTypeId="2" ParentId="25424" CreationDate="2016-06-21T13:04:03.533" Score="0" Body="&lt;p&gt;You can try to use serialSIM800.println(&quot;AT&quot;) instead of write. Here some examples &lt;a href=&quot;https://github.com/stanleyhuangyc/Freematics/issues/17&quot; rel=&quot;nofollow&quot;&gt;https://github.com/stanleyhuangyc/Freematics/issues/17&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-06-21T13:04:03.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25515" PostTypeId="2" ParentId="25509" CreationDate="2016-06-21T13:22:38.737" Score="0" Body="&lt;p&gt;The advantage to a kit is it includes a lot of stuff. You'll have a big selection of sensors and parts to choose from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disadvantage to a kit is it includes a lot of stuff. You'll have bought and paid for a big selection of sensors and parts, some of which you may never use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you linked to Amazon, I assume you are someplace where shopping on line is convenient. In that case I'd start with a small handful parts and let your developing skills and interests guide your future purchases. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A bag of LEDs with resistors included is really basic - start there. I make up a dozen or so of them with a resistor permanently soldered to the cathode (ground) side of the LED (it doesn't matter which side you choose, just be consistent for your own sanity later on!) These are quicker to wire up on a breadboard than using separate LEDs and resistors, and they make a quick and dirty logic-probe (&quot;Is there 5v on this board?&quot;, &quot;Is this pin HIGH or LOW?&quot;) or output device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A handful of push-buttons, often called &quot;Tact switches&quot;, a few analog thermo sensors (LM34 or LM35 f/ex), and a light sensor, would start you off inexpensively while providing you opportunities to learn how connect these devices, some basic electronic theory, and some programming skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By then, you'll have a much better idea what kinds of projects you want to pursue and the parts necessary to build them.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-21T13:22:38.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25516" PostTypeId="2" ParentId="25489" CreationDate="2016-06-21T13:37:49.177" Score="4" Body="&lt;p&gt;The NRF24L01+ has inputs that are 5V tolerant! So you only need to provide 3.3V on the Vcc pin of the module, which you can do by putting a voltage regulator between it, and the 5V of the Trinket. So there isn't really any need to convert the Trinket to 3.3V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS Remember to add some capacitors to the output of the voltage regulator, as the NRF needs a pretty stable 3.3V. Noise in the power lines can cause instability in the operation of the device. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="11529" LastEditDate="2016-06-22T13:30:55.690" LastActivityDate="2016-06-22T13:30:55.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25519" PostTypeId="2" ParentId="25499" CreationDate="2016-06-21T14:41:52.767" Score="1" Body="&lt;p&gt;Ok, yea...Please format this a little better (properly tabbed line spacing and such), and comments would go a long way to understanding this, because chances are people don't want to invest the time to decipher what's going on here without them. I'm not entirely sure what is going on here, but I'll just suggest what I would do in my understanding of the question, which is how to detect what the minimum and maximum value of the distance is and record the time at which each of these moments occurred. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would have a float value to store the maximum and minimum distance as well as their times, and simply on every iteration of the loop check if the position was greater than the previous maximum distance or shorter than the previous minimum distance. If either of those are true, set the maximum/minimum distance to the current position and set the maximum/minimum distance time to the current time, using millis(). There's no reason I can see, if I'm understanding this correctly for an array to store all the data, it's just taking up memory space from what I see.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps a bit, and, if I'm totally off base, again I'll emphasize the utility of comments in readability. Hope this helps and good luck.&lt;/p&gt;&#xA;" OwnerUserId="17238" LastActivityDate="2016-06-21T14:41:52.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25520" PostTypeId="1" CreationDate="2016-06-21T14:49:39.647" Score="2" ViewCount="1771" Body="&lt;p&gt;I am building a boost converter using a mosfet. The mosfet is driven by PWM generated by an Arduino Uno through Matlab Simulink. In Simulink I am giving 10 KHz pulse width 50%. Practically 10 KHz available at pins 5 and 6. Up to how much frequency can pins 5 and 6 handle?&lt;/p&gt;&#xA;" OwnerUserId="23243" LastEditorUserId="4628" LastEditDate="2016-12-19T20:00:42.847" LastActivityDate="2017-08-17T02:03:43.440" Title="Generating PWM using Arduino Uno and Simulink (interfacing) pins 5 and 6. What's the maximum frequency?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25521" PostTypeId="2" ParentId="25424" CreationDate="2016-06-21T15:32:25.273" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow&quot;&gt;NeoSWSerial&lt;/a&gt; would be better for this.  It can read and write at the same time, unlike SoftwareSerial, and it doesn't disable interrupts for the entire character receive time (~1ms!).  AltSoftSerial would be even better, but you can only use it on pins 8 &amp;amp; 9 (on an UNO, different pins on other Arduinos).&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-06-21T15:32:25.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25522" PostTypeId="1" CreationDate="2016-06-21T17:08:27.670" Score="1" ViewCount="1306" Body="&lt;p&gt;So I'm trying to power down my ATtiny85 to save power, but for some reason the ATtiny doesn't power down when I'm using the default &lt;code&gt;IDLE&lt;/code&gt; mode, but when I start using the &lt;code&gt;SLEEP_MODE_PWR_DOWN&lt;/code&gt; the ATtiny appears to go to sleep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm testing it by calling a &lt;code&gt;checkPower()&lt;/code&gt; method that blinks an LED after the &lt;code&gt;sleepNow()&lt;/code&gt; method. In other words, if the ATtiny goes to sleep then the &lt;code&gt;checkPower()&lt;/code&gt; method should not be reached and the LED should not blink. Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  doStuff();&#xA;  sleepNow();&#xA;  checkPower();&#xA;}&#xA;&#xA;void sleepNow()&#xA;{&#xA;    // Choose our preferred sleep mode:&#xA;    set_sleep_mode(SLEEP_MODE_IDLE);&#xA;    // Set sleep enable (SE) bit:&#xA;    sleep_enable();&#xA;    // Put the device to sleep:&#xA;    sleep_mode();&#xA;    // Upon waking up, sketch continues from this point.&#xA;    sleep_disable();&#xA;}&#xA;&#xA;void checkArrays()&#xA;{&#xA;  for(i = 0; i &amp;lt; 15; i++)&#xA;  {&#xA;     digitalWrite(1, HIGH);&#xA;     delay(1000);&#xA;     digitalWrite(1, LOW);&#xA;     delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any idea why my LED would continue to blink when using the &lt;code&gt;IDLE&lt;/code&gt; mode but no the &lt;code&gt;PWR_DOWN&lt;/code&gt; mode?&lt;/p&gt;&#xA;" OwnerUserId="22788" LastActivityDate="2016-06-21T17:19:03.550" Title="Does IDLE Mode not power down an ATtiny85?" Tags="|attiny|sleep|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25523" PostTypeId="2" ParentId="25522" CreationDate="2016-06-21T17:19:03.550" Score="1" Body="&lt;p&gt;In IDLE mode the timers still run. Arduino uses timer0 for millis. So when timer0 overflows the ATTiny will wake up and call the ISR. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the ATTiny will go to 'sleep' but wake up a number of microseconds later.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-21T17:19:03.550" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25528" PostTypeId="2" ParentId="10257" CreationDate="2016-06-21T22:51:12.480" Score="0" Body="&lt;p&gt;Basically your yun is a linux box with a arduino connected to it on port /dev/ttyATH0.&lt;br&gt;&#xA;If you know linux that should answer all your questions about what is possible.&#xA;I have setup my own bridge and communicate via html to my robot using cgi script and lua.&lt;br&gt;&#xA;I have demoed this on a web contest and you can see it in action on this video from 15:25 onwards &lt;a href=&quot;https://www.youtube.com/watch?v=q0CnB7Yzpfg&amp;amp;index=3&amp;amp;list=PLCSjf7QmP3TCOLIw0lMPbwHtKrO-nwfKG&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=q0CnB7Yzpfg&amp;amp;index=3&amp;amp;list=PLCSjf7QmP3TCOLIw0lMPbwHtKrO-nwfKG&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-06-21T22:51:12.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25529" PostTypeId="1" AcceptedAnswerId="25547" CreationDate="2016-06-21T22:57:03.733" Score="3" ViewCount="15358" Body="&lt;p&gt;I have an accelerometer connected to an Arduino Uno board, is there a way I can detect the distance it this accelerometer moved on each of the 3 axis?&lt;/p&gt;&#xA;" OwnerUserId="23104" LastActivityDate="2017-10-19T22:42:54.827" Title="Detecting distance moved by accelerometer?" Tags="|accelerometer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25530" PostTypeId="1" CreationDate="2016-06-21T23:05:20.827" Score="0" ViewCount="256" Body="&lt;p&gt;I am using 2 accelerometers connected to an arduino. The code below does not work.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; if((acc1 &amp;gt;= 20 &amp;amp;&amp;amp; acc1 &amp;lt;= 40) &amp;amp;&amp;amp; (acc2 &amp;gt;= 20 &amp;amp;&amp;amp; acc2 &amp;lt;=40)) //If acc1 is between 20 and 40 AND if acc2 is between 20 and 40&#xA;&amp;gt;     {&#xA;&amp;gt;         digitalWrite(13, HIGH);&#xA;&amp;gt;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But, the following code does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; if((acc1 &amp;gt;= 20 &amp;amp;&amp;amp; acc1 &amp;lt;= 40)) //If acc1 is between 20 and 40&#xA;&amp;gt;     {&#xA;&amp;gt;         digitalWrite(13, HIGH);&#xA;&amp;gt;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can anyone tell me why please?&#xA;Edit with full code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int acc1_xPin = 0; //X Pin on acc1&#xA;const int acc1_yPin = 1; //Y Pin on acc1&#xA;const int acc2_xPin = 2; //X Pin on acc2&#xA;const int acc2_yPin = 3; //Y Pin on acc2&#xA;&#xA;int xAcc1_maxVal = 409; //Maximum value for X-axis Acc1&#xA;int xAcc1_minVal = 269; //Minimum value for X-axis Acc1&#xA;int yAcc1_maxVal = 410; //Maximum value for Y-axis Acc1&#xA;int yAcc1_minVal = 270; //Minimum value for Y-axis Acc1&#xA;&#xA;int xAcc2_maxVal = 411; //Maximum value for X-axis Acc2&#xA;int xAcc2_minVal = 268; //Minimum value for X-axis Acc2&#xA;int yAcc2_maxVal = 402; //Maximum value for Y-axis Acc2&#xA;int yAcc2_minVal = 263; //Minimum value for Y-axis Acc2&#xA;&#xA;//Hold Calculated Values&#xA;double acc1; //acc1 angle&#xA;double acc2; //acc2 angle&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;&#xA;  int acc1_xRead = analogRead(acc1_xPin); //acc1 X-axis&#xA;  int acc1_yRead = analogRead(acc1_yPin); //acc1 Y-axis&#xA;  int acc2_xRead = analogRead(acc2_xPin); //acc2 X-axis&#xA;  int acc2_yRead = analogRead(acc2_yPin); //acc2 Y-axis&#xA;&#xA;  //convert read values to degrees -90 to 90 - Needed for atan2&#xA;  int acc1_xAng = map(acc1_xRead, xAcc1_minVal, xAcc1_maxVal, -90, 90);&#xA;  int acc1_yAng = map(acc1_yRead, yAcc1_minVal, yAcc1_maxVal, -90, 90);&#xA;  int acc2_xAng = map(acc2_xRead, xAcc2_minVal, xAcc2_maxVal, -90, 90);&#xA;  int acc2_yAng = map(acc2_yRead, yAcc2_minVal, yAcc2_maxVal, -90, 90);&#xA;&#xA;  //Caculate 360deg values like so: atan2(-yAng, -zAng)&#xA;  //atan2 outputs the value of -π to π (radians)&#xA;  //We are then converting the radians to degrees&#xA;  acc1 = RAD_TO_DEG * (atan2(-acc1_yAng, -acc1_xAng) + PI); //acc1 in degrees&#xA;  acc2 = RAD_TO_DEG * (atan2(-acc2_yAng, acc2_xAng) + PI); //acc2 in degrees&#xA;&#xA;  if((acc1 &amp;gt;= 20 &amp;amp;&amp;amp; acc1 &amp;lt;= 40) &amp;amp;&amp;amp; (acc2 &amp;gt;= 20 &amp;amp;&amp;amp; acc2 &amp;lt;= 40))&#xA;  {&#xA;    digitalWrite(13, HIGH);&#xA;    Serial.println(&quot;HIGH&quot;);&#xA;  }&#xA;  else if ((acc1 &amp;gt;= 41 &amp;amp;&amp;amp; acc1 &amp;lt;= 60) &amp;amp;&amp;amp; (acc2 &amp;gt;= 41 &amp;amp;&amp;amp; acc2 &amp;lt;= 60))&#xA;  {&#xA;    digitalWrite(13, LOW);&#xA;    Serial.println(&quot;LOW&quot;);&#xA;  }&#xA;&#xA;  Serial.print(&quot;Acc1: &quot;);&#xA;  Serial.print(acc1);&#xA;  Serial.print(&quot; Acc2: &quot;);&#xA;  Serial.print(acc2);&#xA;  delay(1000);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'd really appreciate any input as to way the if statements are not working when I have 2 conditions in them but will work when I have 1 condition.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit:&#xA;I have corrected the typos in the code. My laptop gave up on me last night so I had to retype the code on a friends laptop, hence the typos and why I didn't post the whole code initially. &#xA;The IF statements still don't work as stated above when the 2 conditions are in the IF statements together, but when I only put 1 condition in, it works fine.&lt;/p&gt;&#xA;" OwnerUserId="23105" LastEditorUserId="23105" LastEditDate="2016-06-23T14:42:27.820" LastActivityDate="2016-06-23T17:30:47.007" Title="Issue with IF statement condition" Tags="|arduino-uno|programming|c|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="25531" PostTypeId="2" ParentId="25529" CreationDate="2016-06-21T23:13:24.280" Score="-1" Body="&lt;p&gt;Think about it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Accelerometers measure acceleration.&lt;/li&gt;&#xA;&lt;li&gt;Acceleration is a change in speed.&lt;/li&gt;&#xA;&lt;li&gt;Distance travelled is speed multiplied by time.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you know the starting speed (e.g., stationary) and you know how much you have accelerated between two points in time you can calculate the average speed for that time period - and since you know the time of that time period (one would hope) then you can get an approximation of the distance travelled in that axis.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I say approximation, because you are working with finite time points (quanta) and only looking at the acceleration at those points in time. It's far from perfect, but it can give you a rough ballpark figure. The smaller your quanta the better your accuracy - but it will never be anything more than a guestimation at best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it's just, as they say, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Small_matter_of_programming&quot; rel=&quot;nofollow&quot;&gt;SMOP&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-21T23:13:24.280" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25532" PostTypeId="2" ParentId="25424" CreationDate="2016-06-21T23:46:36.543" Score="0" Body="&lt;p&gt;My SIM808 returns a bit of junk right from the get-go, so that might be influencing things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it's conceivable you are retrieving a -1 from your initial serialSIM800.read() call - it's a nonblocking call and returns -1 when no data is available.  That would almost definitely appear as junk.&lt;/p&gt;&#xA;" OwnerUserId="17170" LastActivityDate="2016-06-21T23:46:36.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25533" PostTypeId="2" ParentId="25530" CreationDate="2016-06-22T01:11:37.273" Score="1" Body="&lt;p&gt;Your code has the following lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;acc2 = RAD_TO_DEG * (atan2(-acc1_yAng, -acc1_xAng) + PI); //acc1 in degrees&#xA;acc2 = RAD_TO_DEG * (atan2(-acc2_yAng, acc2_xAng) + PI); //acc2 in degrees&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If I'm going to believe the comments, the &lt;em&gt;first&lt;/em&gt; line should start:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;acc1 = ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-22T01:11:37.273" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25537" PostTypeId="2" ParentId="25530" CreationDate="2016-06-22T03:56:07.750" Score="2" Body="&lt;p&gt;I think this is your problem (from the full code snapshot)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(acc2 &amp;gt;= 20 &amp;amp;&amp;amp; acc2 &amp;gt;= 40))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I believe it should be (like your first snapshot)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(acc2 &amp;gt;= 20 &amp;amp;&amp;amp; acc2 &amp;lt;= 40))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the first is greater than or equal to 40 rather than less than or equal to. Also note you've done this when determining whether or not acc2 is between 41 and 60 in the else if part of that same if statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea why the code differs between your first and third snapshot. Potentially you have spotted this already and failed to update the full code being run?&lt;/p&gt;&#xA;" OwnerUserId="19911" LastEditorUserId="19911" LastEditDate="2016-06-22T04:01:57.657" LastActivityDate="2016-06-22T04:01:57.657" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25539" PostTypeId="1" AcceptedAnswerId="25550" CreationDate="2016-06-22T07:01:01.413" Score="0" ViewCount="216" Body="&lt;p&gt;i have 30Amp ESC which i can move motor by providing values ,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but i am unable to know what is the minimum and maximum throttle speed of the motor....&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how to achieve that level of info through arduino, &lt;/p&gt;&#xA;&#xA;&lt;p&gt;although when i calibrate through Open pilot software ,it is able to calibrate and the minimum value is 1500ms ..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also after calibrating it once , do i need to arm everytime before using ESC in the arduino program through serial input ?&lt;/p&gt;&#xA;" OwnerUserId="22808" LastActivityDate="2016-07-22T13:53:33.453" Title="Calibrating ESC and then using it" Tags="|serial|arduino-mega|motor|servo|" AnswerCount="1" CommentCount="1" ClosedDate="2016-07-31T11:59:41.110" ContentLicense="CC BY-SA 3.0" />
  <row Id="25540" PostTypeId="2" ParentId="23455" CreationDate="2016-06-22T07:17:27.467" Score="4" Body="&lt;p&gt;No accepted or up-voted answers, eh? I'll try my hand. :)&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How big of a project can be built using Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Depends on the model. You can go from around 4 KB of programmable memory to 256 KB, and then get into the larger models like the Due (512 KB).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are there memory concerns?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are &lt;em&gt;always&lt;/em&gt; memory concerns, however when you have gigabytes of RAM (like on your PC) you tend to ignore them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are microcontrollers, designed for embedded applications. You will find yourself probably wishing you had more of everything (RAM, PROGMEM and EEPROM). However for many applications what they have is absolutely fine.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can an Arduino run thousands and thousands of lines of code out of the box&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Probably not. Consider the Uno with 32 KB of program memory. At from two to four bytes per machine instruction (most are two bytes), you are probably going to fit at most:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;32768 / 2 = 16384&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... machine instructions. So no, not hundreds of thousands. The larger models, maybe.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and if not, is there a way to add more memory for larger, more complex projects?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Atmega2560 has expandable RAM, for example &lt;a href=&quot;http://www.rugged-circuits.com/quadram-tech/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; which adds 512 KB of RAM.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How big of a project can be built using Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I have quite a few around the place here doing their own things. One lets me know if I left the garage door open accidentally. I look upon them as being useful for &quot;helper&quot; applications. I wouldn't try to put my SQL database on one.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-06-22T21:00:04.800" LastActivityDate="2016-06-22T21:00:04.800" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25542" PostTypeId="2" ParentId="25520" CreationDate="2016-06-22T09:31:06.160" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;my page about timers&lt;/a&gt;. The maximum frequency the hardware can output is 8 MHz if you are running a 16 MHz clock.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;10 kHz should be easily achievable if you tweak the hardware registers, as Gerben said.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-22T09:31:06.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25545" PostTypeId="2" ParentId="8417" CreationDate="2016-06-22T12:49:07.103" Score="0" Body="&lt;p&gt;I believe I have finally understood this error today, and would like someone to verify or refute. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &quot;avrdude.conf&quot; there is defined for each processor and for each memory type a minimum duration and a maximum duration that the programmer will repeat trying to write each byte. These have values of &quot;min_write_delay = 4500&quot; and &quot;max_write_delay = 4500&quot; (no idea what the units are). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After increasing the max_write_delay to &quot;max_write_delay = 16000&quot; (arbitrary increase but keeping it less than a 16 bit signed integer to avoid buffer overflow risks), for all memory types (but I would presume that only &quot;flash&quot; memory needs the parameter to be altered) my Arduino takes an extra 30 seconds to program, but no more verification errors.&lt;/p&gt;&#xA;" OwnerUserId="23265" LastActivityDate="2016-06-22T12:49:07.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25547" PostTypeId="2" ParentId="25529" CreationDate="2016-06-22T13:09:58.580" Score="10" Body="&lt;p&gt;This is normally referred to as &lt;a href=&quot;https://en.wikipedia.org/wiki/Dead_reckoning&quot; rel=&quot;noreferrer&quot;&gt;Dead Reckoning&lt;/a&gt;.  The processes of determining position using known values, such as acceleration.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First we have to relate &lt;a href=&quot;https://en.wikipedia.org/wiki/Acceleration&quot; rel=&quot;noreferrer&quot;&gt;acceleration&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Velocity&quot; rel=&quot;noreferrer&quot;&gt;velocity&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Position_(vector)&quot; rel=&quot;noreferrer&quot;&gt;position&lt;/a&gt; mathematically.  Velocity is the integral of acceleration with respect to time:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4q6Td.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4q6Td.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similarly, position is the integral of velocity with respect to time:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vwd6O.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vwd6O.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dummies.com/how-to/content/how-to-analyze-position-velocity-and-acceleration-.html&quot; rel=&quot;noreferrer&quot;&gt;Here&lt;/a&gt; is an explanation that should tie this all together.  However, it appears this explanation goes in the reverse order.  That is using derivatives of position to find velocity.  And derivatives of velocity to find acceleration.  Simply put, finding a derivative is the opposite process of finding an integral.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A final note, this all works well on paper.  In reality Dead Reckoning based only on acceleration does not work very well.  For instance, I believe most &lt;a href=&quot;http://www.google.com/patents/US8374785&quot; rel=&quot;noreferrer&quot;&gt;vehicle GPS systems tend to use steering and speed&lt;/a&gt; if Dead Reckoning is to be used for guidance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Found &lt;a href=&quot;http://bluelemonlabs.blogspot.com/2013/07/blog-post.html&quot; rel=&quot;noreferrer&quot;&gt;this web site&lt;/a&gt; where someone talks specifically about Dead Reckoning using an Arduino. He is simply using the deltas of filtered acceleration readings:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;velocity(i) = velocity(i-1) + acceleration (i)&#xA;position(i) = position (i-1) + velocity (i) &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But goes on to say accumulated errors causes drift and positioning errors.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-23T12:36:33.303" LastActivityDate="2016-06-23T12:36:33.303" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25550" PostTypeId="2" ParentId="25539" CreationDate="2016-06-22T13:37:29.890" Score="0" Body="&lt;p&gt;Used this code - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;Coded by Marjan Olesch&#xA;Sketch from Insctructables.com&#xA;Open source - do what you want with this code!&#xA;*/&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;&#xA;int value = 0; // set values you need to zero&#xA;&#xA;Servo firstESC, secondESC; //Create as much as Servoobject you want. You can controll 2 or more Servos at the same time&#xA;&#xA;void setup() {&#xA;&#xA;  firstESC.attach(9);    // attached to pin 9 I just do this with 1 Servo&#xA;  Serial.begin(9600);    // start serial at 9600 baud&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;//First connect your ESC WITHOUT Arming. Then Open Serial and follo Instructions&#xA;&#xA;  firstESC.writeMicroseconds(value);&#xA;&#xA;  if(Serial.available()) &#xA;    value = Serial.parseInt();    // Parse an Integer from Serial&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;the problem was when i was connecting the battery , it was not making any sounds...it was already calibrated by open pilot GCS so it was not calibrating again... i needed to reset the ESC and then run this program from arduino&lt;/p&gt;&#xA;" OwnerUserId="22808" LastActivityDate="2016-06-22T13:37:29.890" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25551" PostTypeId="2" ParentId="23453" CreationDate="2016-06-22T14:06:37.503" Score="0" Body="&lt;p&gt;If you are using an ESP-01 board (which is an ESP8266 based board)&#xA;You should try running the ESP8266 from an independent 3.3V power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega 3.3V pin only supplies up to 50mA, wheres as the ESP8266 requires up to 200mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, make sure the CH_PD and RESET pins are held high (connected to the 3.3V).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because you're using an Arduino Mega, you might find it beneficial to use pins 16 and 17, and Serial2 instead of software serial. &#xA;Internet sources indicate that they are sometimes set up with a baud rate of either 9600, 57600 or 115200. I managed to get mine working with 115200, but software serial is limited to a baud rate of 19200.&lt;/p&gt;&#xA;" OwnerUserId="18709" LastActivityDate="2016-06-22T14:06:37.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25554" PostTypeId="1" AcceptedAnswerId="25555" CreationDate="2016-06-22T14:18:56.060" Score="1" ViewCount="309" Body="&lt;p&gt;Can anyone point me towards whats best for relatively low cost distance measuring in the 0-36&quot; range (or 0 - 1m range) with 1/16&quot;/1mm accuracy.  My initial approach was going to be to hack a laser tape measure, but wanted to know if that was the best in cost vs accuracy. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially looking to measure how close I am to a stationary metal plate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for any help.&lt;/p&gt;&#xA;" OwnerUserId="23267" LastActivityDate="2016-06-22T15:01:52.967" Title="Distance finder technology 0-24inches" Tags="|sensors|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25555" PostTypeId="2" ParentId="25554" CreationDate="2016-06-22T15:01:52.967" Score="2" Body="&lt;p&gt;You will likely find the best accuracy is derived from a laser-based measurement. My Bosch is laser only, no ultrasound component and has 1/16&quot; resolution. For your application, the six inch minimum distance limitation of the Bosch is outside your specifications. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because laser measurement devices use time versus distance, it's possible you could construct a mirror chamber with front-surface mirrors that would cause the laser to travel six inches before exiting the chamber, overcoming that limitation. The calibration should be straight-forward, as you'd place the chamber flush and adjust your mirror placement until you read the exact expected compensation distance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would need only small mirror panes, which would not &quot;break the bank,&quot; but if you find a discarded large-screen projection television, the mirror within is front surface and quite large. Front surface mirrors should not have contamination from touching and should be cleaned with care, as you can erode or otherwise degrade the reflective surface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this site:&#xA;&lt;a href=&quot;http://blog.qartis.com/arduino-laser-distance-meter/&quot; rel=&quot;nofollow&quot;&gt;http://blog.qartis.com/arduino-laser-distance-meter/&lt;/a&gt;&#xA;which looks promising for a different model of laser rangefinder, although the creator has run into a stumbling block or two.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would appear that the key is to overcome the minimum distance limitation, perhaps as I suggested above, and interfacing with serial communications of the arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the links I pursued involved the creator contacting the technical support of the manufacturer. The support ticket was closed as &quot;resolved,&quot; in the manner of advising the user that the warranty was void by opening the case. Yeah, like that matters to makers and hackers!&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-22T15:01:52.967" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25557" PostTypeId="2" ParentId="23453" CreationDate="2016-06-22T15:15:21.583" Score="2" Body="&lt;p&gt;Rx and Tx properly crossed - SwSerial Rx to ESP Tx and SwSerial Tx to ESP Rx? And the connections are sound? It wouldn't be the first time &quot;someone&quot; thought he'd killed an ESP, only to find a missing connection from its transmitter (not that I'd know anything about that ..... ;)&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-22T15:15:21.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25560" PostTypeId="1" CreationDate="2016-06-22T18:05:47.673" Score="-1" ViewCount="353" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Yi55D.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Yi55D.png&quot; alt=&quot;Arduino due Programming Port &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not able to upload sketch on Arduino Due, using Programming Port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even blink sketch from examples is not working. So tried with blank sketch, I got following messages.&lt;/p&gt;&#xA;" OwnerUserId="23276" LastEditorUserId="19515" LastEditDate="2016-06-23T03:15:30.440" LastActivityDate="2017-11-16T21:30:39.520" Title="Not able to upload program to &quot;Arduino Due&quot;" Tags="|arduino-due|" AnswerCount="1" CommentCount="3" ClosedDate="2017-11-18T18:39:28.007" ContentLicense="CC BY-SA 3.0" />
  <row Id="25561" PostTypeId="1" CreationDate="2016-06-22T19:32:51.940" Score="2" ViewCount="89" Body="&lt;p&gt;I am considering using an Arduino as a controller for a water treatment system and would love to hear your opinions. All it has to do is open/close a water gate (by starting/stopping a motor) at predefined times. It would have to...&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Be able to connect to a phone using a usb cable. The phone would act as a UI to change settings and water flush times on the Arduino (via a custom app)&lt;/li&gt;&#xA;&lt;li&gt;Log data which would be easily retrievable&lt;/li&gt;&#xA;&lt;li&gt;Ideally, be able to connect to a cell network and send/receive packets. I believe there is a shield for this&lt;/li&gt;&#xA;&lt;li&gt;Consume MINIMAL POWER. All it has to do is flush once every few days, log data, and possibly receive data from shield/usb. It would be running off of a solar panel and battery. In winter it could run out of power.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And thats pretty much it! Can this project be done with an Arduino? I would greatly appreciate any advice and recommendations!&lt;/p&gt;&#xA;" OwnerUserId="23278" LastActivityDate="2016-06-22T22:07:58.967" Title="Arduino as an automation controller" Tags="|power|remote-control|" AnswerCount="2" CommentCount="7" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25563" PostTypeId="1" AcceptedAnswerId="25571" CreationDate="2016-06-22T20:55:30.857" Score="1" ViewCount="5346" Body="&lt;p&gt;I'm planning a project where I'd like to control an RC car with Arduino and an Esp8266 module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A software running on a computer would read the input from an USB analog controller and send the data to the Esp8266 module through the wifi network, and the Arduino would read this data and send signal to the ports accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to know is: would ping/delay be an issue? Considering a dedicated wifi network for this, so the only devices connected to it would be the computer and the Esp8266 module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need to know what is the average response time of the Esp8266 module before I buy it, because if it is too high I'll think of something else since for this project I'd need a reasonably high response time.&lt;/p&gt;&#xA;" OwnerUserId="23280" LastActivityDate="2017-02-17T12:56:33.147" Title="Average response time of Esp8266 module" Tags="|esp8266|wifi|remote-control|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25564" PostTypeId="2" ParentId="25561" CreationDate="2016-06-22T21:19:59.273" Score="0" Body="&lt;p&gt;So first of all, if the voltage of your systems is too high, arduino cannot provide that on its own. Arduinos can only provide 5v out with the rail. So you could use a relay shield, an add on board to stack on top of it, or just plain old relays with some soldering. Now, for connectivity, try this thing. &lt;a href=&quot;http://www.annikken.com/andee/&quot; rel=&quot;nofollow&quot;&gt;http://www.annikken.com/andee/&lt;/a&gt; It is relatively easy to learn, and you can build a decent UI without the need for coding an app. I think you can get them for ~30$. However, I do not know how well the arduino can run with so many shields. For data logging, a few companies make data logging shields, or you can get an external read/write and wire it up. I have a small, probably 3&quot; by 8&quot; solar panel for my arduino and it is quite unreliable even in low power applications. However, if you have a good one, that is cool. Best of luck -Peter&lt;/p&gt;&#xA;" OwnerUserId="23282" LastActivityDate="2016-06-22T21:19:59.273" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25565" PostTypeId="2" ParentId="25561" CreationDate="2016-06-22T22:07:58.967" Score="1" Body="&lt;p&gt;Have a look at my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow noreferrer&quot;&gt;Temperature and humidity sensor - battery powered&lt;/a&gt;. That works from 3 x AA batteries, and has been going for a few years. I think I replaced the batteries once. It keeps track of the time, and logs data to the disk (SD card).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3rtDL.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3rtDL.png&quot; alt=&quot;Temperature logger&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have room to describe the whole project here, but the general idea is that the processor sleeps most of the time (consuming around 6 µA). Now this particular project doesn't turn on a motor, but adding a solid-state relay should be all you need to do that.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Be able to connect to a phone using a usb cable. The phone would act as a UI to change settings and water flush times on the Arduino (via a custom app)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think this will take a lot of power, keeping the phone active. One possible thing to try would be to power up the phone (eg. using another relay) during a certain &quot;window&quot; of time (eg. 6 pm to 7 pm). Then you would know to try to configure the device during that time.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-22T22:07:58.967" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25567" PostTypeId="2" ParentId="10458" CreationDate="2016-06-23T02:30:32.777" Score="0" Body="&lt;p&gt;I am looking at NimbeLink's Arduino baseboard which works with a CDMA modem. Never tried it, but thinking of ordering one. &lt;a href=&quot;http://nimbelink.com/skywire-arduino-cellular-shield/&quot; rel=&quot;nofollow&quot;&gt;http://nimbelink.com/skywire-arduino-cellular-shield/&lt;/a&gt;. Not sure if you'd put this as 'affordable' since it is $40 for baseplate + $130 for modem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also this Arduino WCDMA 3G. &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=3G_%2B_GPS_Shield_for_Arduino&quot; rel=&quot;nofollow&quot;&gt;http://linksprite.com/wiki/index.php5?title=3G_%2B_GPS_Shield_for_Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Frustrating to have all this cheap awesome GSM technology, but only CDMA network in my region. &lt;/p&gt;&#xA;" OwnerUserId="23286" LastEditorUserId="23286" LastEditDate="2016-06-23T21:08:52.033" LastActivityDate="2016-06-23T21:08:52.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25569" PostTypeId="2" ParentId="25411" CreationDate="2016-06-23T03:16:46.190" Score="1" Body="&lt;p&gt;The correct condition, for what you intend, should be &lt;code&gt;if (mfrc522.PICC_IsNewCardPresent())&lt;/code&gt;, so that the code in the IF block is run when a card is present, though this isn't the best structure. Like you discovered, your program isn't frozen. One of the 2 return statements (I'm not sure which) is causing it to abort &lt;code&gt;loop()&lt;/code&gt; before calling &lt;code&gt;readAndPrint()&lt;/code&gt;. With your current code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the first &lt;code&gt;return&lt;/code&gt; will always be executed whenever no card is detected. Since you don't seem to be sending anything with the Serial monitor,  &lt;code&gt;Serial.available()&lt;/code&gt; will return 0 and so &lt;code&gt;loop()&lt;/code&gt; returns.&lt;/li&gt;&#xA;&lt;li&gt;The second &lt;code&gt;return&lt;/code&gt; will be executed if the reader fails to obtain the UID of the card with a &lt;code&gt;SELECT&lt;/code&gt;. The &lt;code&gt;SELECT&lt;/code&gt; will fail only if you don't first call &lt;code&gt;PICC_RequestA()&lt;/code&gt; for 'new' cards (just coming within range), or &lt;code&gt;PICC_WakeupA()&lt;/code&gt; for &lt;code&gt;HALT&lt;/code&gt;ed cards (cards already within range but sleeping). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I don't know if you're trying different cards or just one. If its just one card, you may have to take it out of range and then bring it within range again for the reader to detect it a second time. But, if you want to read the card's data more than once, without taking it out of range, you have to call &lt;code&gt;PICC_WakeupA()&lt;/code&gt; instead of &lt;code&gt;PICC_IsNewCardPresent()&lt;/code&gt; since, as the names indicate, you're waking a sleeping card, not detecting a new card entirely. Also structure your &lt;code&gt;loop()&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  if (!mfrc522.PICC_IsNewCardPresent()) {  // replace the condition with PICC_WakeupA()   &#xA;    return;  // if you dont want the card to leave the reader's range&#xA;  }&#xA;&#xA;  if (!mfrc522.PICC_ReadCardSerial()) {&#xA;    return;&#xA;  }&#xA;&#xA;  // all the code that should be executed if a card has been detected and its UID read&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, there's usually little sense in &lt;code&gt;HALT&lt;/code&gt;ing a card and then waking it in the very next iteration, so you might want to do all the sector reading and writing at once, HALT the card, and then wait for a new card to enter the field; at least that's what's desired in most applications.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-10-21T12:17:07.013" LastActivityDate="2016-10-21T12:17:07.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25570" PostTypeId="2" ParentId="25563" CreationDate="2016-06-23T03:18:31.860" Score="3" Body="&lt;p&gt;I think response time would be a big problem. I used the ESP8266 with a temperature and humidity sensor, complete with a small web server on the ESP8266, and it works fine. But I wouldn't want to control an RC car with it. But if you buy it on ebay from China, it is only a few dollars, so buy one anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Bluetooth, either a couple of HC-05 modules, or the Bluetooth Low Energy HM-10 modules. Both can communicate at 115200 baud. The HM-10 modules may be a bit tricky, because some Chinese sellers put a stripped down version of firmware on the module, and forces you to search online how to flash a usable firmware version.&lt;/p&gt;&#xA;" OwnerUserId="10748" LastActivityDate="2016-06-23T03:18:31.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25571" PostTypeId="2" ParentId="25563" CreationDate="2016-06-23T07:09:55.840" Score="3" Body="&lt;p&gt;I'm pretty sure it can be made to work.  &lt;br&gt;&#xA;I have a home server with several devices attached to it, including 2 ESP8266 modules - one at home and one in my office. All devices connect using permanent TCP connection and respond to my custom &quot;ping&quot; requests over that connection. Typical round-trip response times are bellow 50ms and often bellow 10ms. There are occasional &quot;hickups&quot; of 100+ms, but they are rare and could be a result many factors. Note that these 2 ESPs are programmed in Lua, which is not optimal efficiency - I was just lazy and the tasks they do are simple enough to not matter.  &lt;br&gt;&#xA;Most probably if you start an HTTP server on the ESP and bombard it with HTTP requests every time you move the joystick it would be horribly laggy. But with a plain old TCP connection or even a consistent flow of UDP packets I'm pretty sure you will get good results.  &lt;br&gt;&#xA;Also, I would ditch the Arduino and use only the ESP - you should have no problem controlling two motors (most probably via motor driver board or chip) and perhaps a servo from the ESP directly. This would eliminate the additional lag of serial communication and parsing the serial data. It would also reduce the cost and size of the project.  &lt;br&gt;&#xA;Having that said, other solutions, like bluetooth or even RF modules should also work, but you asked whether the ESP can do it - and my answer is yes.&lt;/p&gt;&#xA;" OwnerUserId="20696" LastActivityDate="2016-06-23T07:09:55.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25572" PostTypeId="1" CreationDate="2016-06-23T07:16:08.623" Score="1" ViewCount="263" Body="&lt;p&gt;While trying to read RPM from a computer fan using the &lt;a href=&quot;http://www.formfactors.org/developer%5Cspecs%5Crev1_2_public.pdf&quot; rel=&quot;nofollow&quot;&gt;4-wire protocol&lt;/a&gt;, I am getting strange readings. +12 and GND from the fan are connected to a power supply, and the tachometer to the PIN-0 or a Teensy 3.2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote code to read the tachometer pulse using the internal pull-up and interrupts. The strange thing happening is that the number of recorded revolutions is &lt;strong&gt;increasing&lt;/strong&gt; as I manually slow the fan using my fingers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;elapsedMillis.h&amp;gt;&#xA;&#xA;const int fanPulse = 0;&#xA;volatile long half_revolutions;&#xA;elapsedMillis timeElapsed; &#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  while(!Serial);&#xA;&#xA;  pinMode(fanPulse, INPUT_PULLUP);&#xA;  attachInterrupt(fanPulse, rpm_fun, FALLING);&#xA;&#xA;  half_revolutions = 0;  &#xA;  // analogWriteFrequency(20, 25000); // Teensy 3.0 pin 3 also changes to 375 kHz&#xA;}&#xA;&#xA;void rpm_fun() {&#xA;  half_revolutions++;&#xA;}&#xA;&#xA;void loop() {&#xA;  if (timeElapsed &amp;lt; 1000)&#xA;    return;  &#xA;&#xA;  Serial.printf(&quot;%d revolutions in %d miliseconds\n&quot;, half_revolutions / 2, (unsigned long)timeElapsed);&#xA;&#xA;  timeElapsed = 0;&#xA;  half_revolutions = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the strange output :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 revolutions in 1000 miliseconds  // Start&#xA;0 revolutions in 1000 miliseconds&#xA;82 revolutions in 1000 miliseconds&#xA;394 revolutions in 1000 miliseconds  // &quot;normal&quot; reading&#xA;412 revolutions in 1000 miliseconds&#xA;576 revolutions in 1000 miliseconds&#xA;456 revolutions in 1000 miliseconds&#xA;554 revolutions in 1000 miliseconds&#xA;585 revolutions in 1000 miliseconds&#xA;799 revolutions in 1000 miliseconds  // Slowing the fan&#xA;712 revolutions in 1000 miliseconds&#xA;691 revolutions in 1000 miliseconds&#xA;683 revolutions in 1000 miliseconds&#xA;625 revolutions in 1000 miliseconds&#xA;531 revolutions in 1000 miliseconds&#xA;239 revolutions in 1000 miliseconds&#xA;0 revolutions in 1000 miliseconds&#xA;0 revolutions in 1000 miliseconds  // End&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23289" LastActivityDate="2016-06-23T16:28:35.240" Title="Strange RPM Readings on Teensy 3.2" Tags="|teensy|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25574" PostTypeId="2" ParentId="24004" CreationDate="2016-06-23T07:43:49.023" Score="0" Body="&lt;p&gt;What about RapidXml? RapidXML is a very fast and small XML DOM parser written in C++. It is aimed primarily at embedded environments so might work here. Boost software license means source is freely available. &lt;a href=&quot;http://rapidxml.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;http://rapidxml.sourceforge.net&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other way to go is just parsing out the numbers with string manipulation.&lt;/p&gt;&#xA;" OwnerUserId="23286" LastActivityDate="2016-06-23T07:43:49.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25575" PostTypeId="1" AcceptedAnswerId="25615" CreationDate="2016-06-23T08:23:46.633" Score="1" ViewCount="145" Body="&lt;p&gt;I am trying to replicate an LTC Audio Decoder code from Arduino Uno into AVR ATmega8 which I got from &lt;a href=&quot;http://forum.arduino.cc/index.php/topic,8237.0.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino Uno code is working great. Here is my Arduino Uno code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define one_time_max          588 // these values are setup for NTSC video&#xA;#define one_time_min          422 // PAL would be around 1000 for 0 and 500 for 1&#xA;#define zero_time_max          1080 // 80bits times 29.97 frames per sec&#xA;#define zero_time_min          922 // equals 833 (divide by 8 clock pulses)&#xA;&#xA;&#xA;#define icpPin 8        // ICP input pin on arduino&#xA;#define end_data_position      63&#xA;#define end_sync_position      77&#xA;#define end_smpte_position     80&#xA;&#xA;volatile unsigned int bit_time;&#xA;volatile boolean valid_tc_word;&#xA;volatile boolean ones_bit_count;&#xA;volatile boolean tc_sync;&#xA;volatile boolean write_tc_out;&#xA;volatile boolean drop_frame_flag;&#xA;&#xA;volatile byte total_bits;&#xA;volatile byte current_bit;&#xA;volatile byte sync_count;&#xA;&#xA;volatile byte tc[8];&#xA;volatile char timeCode[11];&#xA;&#xA;/* ICR interrupt vector */&#xA;ISR(TIMER1_CAPT_vect)&#xA;{&#xA; //toggleCaptureEdge&#xA; TCCR1B ^= _BV(ICES1);&#xA;  //Serial.println(&quot;Inter&quot;);&#xA; bit_time = ICR1;&#xA;&#xA; //resetTimer1&#xA; TCNT1 = 0;&#xA;&#xA;if ((bit_time &amp;lt; one_time_min) || (bit_time &amp;gt; zero_time_max)) // get rid of anything way outside the norm&#xA; {&#xA;   //Serial.println(bit_time, DEC);&#xA;   total_bits = 0;&#xA; }&#xA; else&#xA; {&#xA;   if (ones_bit_count == true) // only count the second ones pluse&#xA;     ones_bit_count = false;&#xA;   else&#xA;   {    &#xA;     if (bit_time &amp;gt; zero_time_min)&#xA;     {&#xA;       current_bit = 0;&#xA;       sync_count = 0;&#xA;     }&#xA;     else //if (bit_time &amp;lt; one_time_max)&#xA;     {&#xA;       ones_bit_count = true;&#xA;       current_bit = 1;&#xA;       sync_count++;&#xA;       if (sync_count == 12) // part of the last two bytes of a timecode word&#xA;       {&#xA;         sync_count = 0;&#xA;         tc_sync = true;&#xA;         total_bits = end_sync_position;&#xA;       }&#xA;     }&#xA;&#xA;     if (total_bits &amp;lt;= end_data_position) // timecode runs least to most so we need&#xA;     {                                    // to shift things around&#xA;       tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;&#xA;       for(int n=1;n&amp;lt;8;n++)&#xA;       {&#xA;         if(tc[n] &amp;amp; 1)&#xA;           tc[n-1] |= 0x80;&#xA;&#xA;         tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;       }&#xA;&#xA;       if(current_bit == 1)&#xA;         tc[7] |= 0x80;&#xA;     }&#xA;     total_bits++;&#xA;   }&#xA;&#xA;   if (total_bits == end_smpte_position) // we have the 80th bit&#xA;   {&#xA;     total_bits = 0;&#xA;     if (tc_sync)&#xA;     {&#xA;       tc_sync = false;&#xA;       valid_tc_word = true;&#xA;     }&#xA;   }&#xA;&#xA;   if (valid_tc_word)&#xA;   {&#xA;     valid_tc_word = false;&#xA;&#xA;     timeCode[11]= '\0';&#xA;     timeCode[10] = (tc[0]&amp;amp;0x0F)+0x30;      // frames&#xA;     timeCode[9] = (tc[1]&amp;amp;0x03)+0x30;      // 10's of frames&#xA;     timeCode[8] =  '-';&#xA;     timeCode[7] = (tc[2]&amp;amp;0x0F)+0x30;      // seconds&#xA;     timeCode[6] = (tc[3]&amp;amp;0x07)+0x30;      // 10's of seconds&#xA;     timeCode[5] =  '-';&#xA;     timeCode[4] = (tc[4]&amp;amp;0x0F)+0x30;      // minutes&#xA;     timeCode[3] = (tc[5]&amp;amp;0x07)+0x30;      // 10's of minutes&#xA;     timeCode[2] = '-';&#xA;     timeCode[1] = (tc[6]&amp;amp;0x0F)+0x30;      // hours&#xA;     timeCode[0] = (tc[7]&amp;amp;0x03)+0x30;      // 10's of hours&#xA;&#xA;       drop_frame_flag = bit_is_set(tc[1], 2);&#xA;&#xA;     write_tc_out = true;&#xA;   }&#xA; }&#xA;}&#xA;&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA; pinMode(8, INPUT);                  // ICP pin (digital pin 8 on arduino) as input&#xA;&#xA; bit_time = 0;&#xA; valid_tc_word = false;&#xA; ones_bit_count = false;&#xA; tc_sync = false;&#xA; write_tc_out = false;&#xA; drop_frame_flag = false;&#xA; total_bits =  0;&#xA; current_bit =  0;&#xA; sync_count =  0;&#xA;&#xA; Serial.println(&quot;Finished setup &quot;);&#xA; delay (1000);&#xA;&#xA; TCCR1A = B00000000; // clear all&#xA; TCCR1B = B11000010; // ICNC1 noise reduction + ICES1 start on rising edge + CS11 divide by 8&#xA; TCCR1C = B00000000; // clear all&#xA; TIMSK1 = B00100000; // ICIE1 enable the icp&#xA;&#xA; TCNT1 = 0; // clear timer1&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (write_tc_out)&#xA;   {&#xA;     write_tc_out = false;&#xA;     //if (drop_frame_flag)&#xA;       //Serial.print(&quot;TC-[df] &quot;);&#xA;     //else&#xA;       //Serial.print(&quot;TC-[nd] &quot;);&#xA;     Serial.println((char*)timeCode);&#xA;   //  Serial.print(&quot;  &quot;);&#xA;     //Serial.print(&quot;\r&quot;);&#xA;   }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now to replicate this code for AVR ATmega8, I just copy this code in AVR studio and make small changes like initializing UART, initializing Input Capture Mode etc. Here is my AVR ATmega8 code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;#include &amp;lt;avr/sfr_defs.h&amp;gt;&#xA;&#xA;&#xA;#define one_time_max          588 // these values are setup for NTSC video&#xA;#define one_time_min          422 // PAL would be around 1000 for 0 and 500 for 1&#xA;#define zero_time_max          1080 // 80bits times 29.97 frames per sec&#xA;#define zero_time_min          922 // equals 833 (divide by 8 clock pulses)&#xA;&#xA;&#xA;#define icpPin 8        // ICP input pin on arduino&#xA;#define end_data_position      63&#xA;#define end_sync_position      77&#xA;#define end_smpte_position     80&#xA;&#xA;volatile unsigned int bit_time;&#xA;volatile char valid_tc_word;&#xA;volatile char ones_bit_count;&#xA;volatile char tc_sync;&#xA;volatile char write_tc_out;&#xA;volatile char drop_frame_flag;&#xA;&#xA;volatile unsigned char total_bits;&#xA;volatile unsigned char current_bit;&#xA;volatile unsigned char sync_count;&#xA;&#xA;volatile unsigned char tc[8];&#xA;volatile char timeCode[11];&#xA;&#xA;&#xA;void USARTInit(uint16_t ubrr_value)&#xA;{&#xA;&#xA;    UBRRL = ubrr_value;&#xA;    UBRRH = (ubrr_value&amp;gt;&amp;gt;8);&#xA;    UCSRC|=(1&amp;lt;&amp;lt;URSEL)|(1&amp;lt;&amp;lt;UCSZ1)|(1&amp;lt;&amp;lt;UCSZ0);&#xA;    UCSRB=(1&amp;lt;&amp;lt;RXCIE)|(1&amp;lt;&amp;lt;RXEN)|(1&amp;lt;&amp;lt;TXEN);&#xA;&#xA;&#xA;}&#xA;&#xA;unsigned char USARTReadChar()&#xA;{&#xA;&#xA;    while(!(UCSRA &amp;amp; (1&amp;lt;&amp;lt;RXC)));&#xA;    return UDR;&#xA;}&#xA;&#xA;void USARTWriteChar(char data)&#xA;{&#xA;&#xA;    while(!(UCSRA &amp;amp; (1&amp;lt;&amp;lt;UDRE)));&#xA;    UDR=data;&#xA;}&#xA;&#xA;void send_string(char s[])&#xA;{&#xA;    int i =0;&#xA;&#xA;    while (s[i] != 0x00)&#xA;    {&#xA;        USARTWriteChar(s[i]);&#xA;        i++;&#xA;    }&#xA;}&#xA;&#xA;&#xA;&#xA;int main(void)&#xA;{&#xA;&#xA;    USARTInit(103);&#xA;    DDRB=0;&#xA;     bit_time = 0;&#xA;     valid_tc_word = 0;&#xA;     ones_bit_count = 0;&#xA;     tc_sync = 0;&#xA;     write_tc_out = 0;&#xA;     drop_frame_flag = 0;&#xA;     total_bits =  0;&#xA;     current_bit =  0;&#xA;     sync_count =  0;&#xA;&#xA;    send_string(&quot;FINISHED SETUP&quot;);&#xA;    _delay_ms(1000);     &#xA;&#xA;&#xA;    TCCR1A = 0;&#xA;    TCCR1B = (1&amp;lt;&amp;lt;ICNC1)|(1&amp;lt;&amp;lt;ICES1)|(1&amp;lt;&amp;lt;CS11);&#xA;    TIMSK = (1&amp;lt;&amp;lt;TICIE1);&#xA;    TCNT1 = 0;&#xA;    sei();&#xA;    while(1)&#xA;    {&#xA;&#xA;        if (write_tc_out==1)&#xA;        {&#xA;            write_tc_out = 0;&#xA;            send_string((char*)timeCode);       &#xA;        }&#xA;}&#xA;&#xA;}&#xA;&#xA;ISR(TIMER1_CAPT_vect)&#xA;{&#xA;&#xA; //toggleCaptureEdge&#xA; TCCR1B ^= _BV(ICES1);&#xA;  //Serial.println(&quot;Inter&quot;);&#xA; bit_time = ICR1;&#xA;&#xA; //resetTimer1&#xA; TCNT1 = 0;&#xA;&#xA;if ((bit_time &amp;lt; one_time_min) || (bit_time &amp;gt; zero_time_max)) // get rid of anything way outside the norm&#xA; {&#xA;   //Serial.println(bit_time, DEC);&#xA;   total_bits = 0;&#xA; }&#xA; else&#xA; {&#xA;   if (ones_bit_count == 1) // only count the second ones pluse&#xA;     ones_bit_count = 0;&#xA;   else&#xA;   {    &#xA;     if (bit_time &amp;gt; zero_time_min)&#xA;     {&#xA;       current_bit = 0;&#xA;       sync_count = 0;&#xA;     }&#xA;     else //if (bit_time &amp;lt; one_time_max)&#xA;     {&#xA;       ones_bit_count = 1;&#xA;       current_bit = 1;&#xA;       sync_count++;&#xA;       if (sync_count == 12) // part of the last two bytes of a timecode word&#xA;       {&#xA;         sync_count = 0;&#xA;         tc_sync = 1;&#xA;         total_bits = end_sync_position;&#xA;       }&#xA;     }&#xA;&#xA;     if (total_bits &amp;lt;= end_data_position) // timecode runs least to most so we need&#xA;     {       &#xA;               // to shift things around&#xA;       tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;&#xA;       for(int n=1;n&amp;lt;8;n++)&#xA;       {&#xA;         if(tc[n] &amp;amp; 1)&#xA;           tc[n-1] |= 0x80;&#xA;&#xA;         tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;       }&#xA;&#xA;       if(current_bit == 1)&#xA;         tc[7] |= 0x80;&#xA;     }&#xA;     total_bits++;&#xA;   }&#xA;&#xA;   if (total_bits == end_smpte_position) // we have the 80th bit&#xA;   {&#xA;     total_bits = 0;&#xA;     if (tc_sync)&#xA;     {&#xA;       tc_sync = 0;&#xA;       valid_tc_word = 1;&#xA;     }&#xA;   }&#xA;&#xA;  if (valid_tc_word==1)&#xA;   {&#xA;&#xA;     valid_tc_word = 0;&#xA;&#xA;     timeCode[11]= '\0';&#xA;     timeCode[10] = (tc[0]&amp;amp;0x0F)+0x30;      // frames&#xA;     timeCode[9] = (tc[1]&amp;amp;0x03)+0x30;      // 10's of frames&#xA;     timeCode[8] =  '-';&#xA;     timeCode[7] = (tc[2]&amp;amp;0x0F)+0x30;      // seconds&#xA;     timeCode[6] = (tc[3]&amp;amp;0x07)+0x30;      // 10's of seconds&#xA;     timeCode[5] =  '-';&#xA;     timeCode[4] = (tc[4]&amp;amp;0x0F)+0x30;      // minutes&#xA;     timeCode[3] = (tc[5]&amp;amp;0x07)+0x30;      // 10's of minutes&#xA;     timeCode[2] = '-';&#xA;     timeCode[1] = (tc[6]&amp;amp;0x0F)+0x30;      // hours&#xA;     timeCode[0] = (tc[7]&amp;amp;0x03)+0x30;      // 10's of hours&#xA;&#xA;       drop_frame_flag = bit_is_set(tc[1], 2);&#xA;&#xA;     write_tc_out = 1;&#xA;   }&#xA;&#xA; }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I run this code, I don't get any time stamps. I have gone through this code many times but I am unable to figure out the mistake in my code. Can any one help me figure out the issue?&lt;/p&gt;&#xA;" OwnerUserId="18851" LastEditorUserId="11763" LastEditDate="2016-06-23T22:20:27.997" LastActivityDate="2016-12-22T02:25:50.787" Title="Unable to replicate Arduino code into ATmega8 code" Tags="|arduino-uno|programming|c|atmega328|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25578" PostTypeId="1" CreationDate="2016-06-23T11:24:56.197" Score="1" ViewCount="2513" Body="&lt;p&gt;It is my first day of working with Arduino (it is a Due). I want to read from TMP102 through I2C. I wrote some code and it works just fine. But now I want to separate the TMP102 code from the main source code. But I get linker error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;sketch_jun15a.ino.cpp.o: In function &lt;code&gt;setup':&#xA;  C:\Users\Saeid\Desktop\sketch_jun15a/sketch_jun15a.ino:62: undefined&#xA;  reference to&lt;/code&gt;tmp102_allocate(int)' collect2.exe: error: ld returned 1&#xA;  exit status&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My code is at the moment consist of 3 files:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tmp102.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef TMP102_H&#xA;#define TMP102_H&#xA;&#xA;//TP102 sensor struct&#xA;typedef struct TMP102 { &#xA;  int   address;&#xA;  float celsius;&#xA;  float fahrenheit;    &#xA;} tmp102_t;&#xA;&#xA;tmp102_t* tmp102_allocate(int address);&#xA;&#xA;void tmp102_init_struct(tmp102_t * t, int address);&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tmp102.c&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;tmp102.h&quot;&#xA;&#xA;tmp102_t* tmp102_allocate(int address) {&#xA;  tmp102_t* t = (tmp102_t*) malloc(sizeof(tmp102_t));&#xA;  if(t) { //allocation success&#xA;    tmp102_init_struct(t, address);&#xA;    return t;&#xA;  } else {&#xA;    return 0; //null pointer&#xA;  }&#xA;}&#xA;&#xA;void tmp102_init_struct(tmp102_t* t, int address) {&#xA;  t-&amp;gt;address = address;&#xA;  t-&amp;gt;celsius = 0.0;&#xA;  t-&amp;gt;fahrenheit = 0.0;  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and here is the setup function of the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;tmp102.h&quot;&#xA;void setup(){&#xA;&#xA;  //setup TP102 sensors&#xA;  tp_1 = tmp102_allocate(72); //error is here&#xA;  tempSensors[0] = tp_1;&#xA;&#xA;  //rest of stuff...&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think there is no mistake in the code. There is also no option in the Arduino IDE so that I can meddle with the compiler/linker options.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the files are inside the sketch folder. I created these files using the drop down button in the IDE...&lt;/p&gt;&#xA;" OwnerUserId="23292" LastEditorUserId="23292" LastEditDate="2016-06-23T11:41:35.840" LastActivityDate="2016-06-23T13:02:22.060" Title="Linker error when trying to use functions in separate header and source files" Tags="|arduino-uno|arduino-ide|arduino-due|compile|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25579" PostTypeId="2" ParentId="22567" CreationDate="2016-06-23T12:27:54.110" Score="1" Body="&lt;p&gt;I have not written a full library, but I have recently been using the ADE7913 (same as ADE7912 but with an extra voltage channel) with an Arduino MEGA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic sketch located &lt;a href=&quot;https://github.com/khalida/ade7913/blob/master/ADE7913_VI_sense_board.ino.ino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; talks to the ADE7913 over SPI, and then prints the results of the measurement registers over serial (so you can see them using a serial monitor).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not yet done much measurement testing, so can't comment on the negative voltage issue you have seen, but the sketch sets up the ADE7913 to use the V2WV register for monitoring temperature, and converts the result into degrees C, so you should be able to tell if its working properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of the issues you have been having with the SPI comms, I can offer the following suggestions based on my troubleshooting experience (I also had glitchy comms initially):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I'm pretty new to SPI, but my interpretation of the data-sheet is that the ADE791X chips use &lt;code&gt;SPI_MODE3&lt;/code&gt; (i.e. SCLK is normally high, and samples are read on the trailing clock edge). I have found &lt;code&gt;SPI_MODE1&lt;/code&gt; also works, but unless others can correct me would suggest using 3.&lt;/li&gt;&#xA;&lt;li&gt;I found having physically long jumper wires (my prototyping is still on a bread-board) caused issues. I have read elsewhere that at frequencies in the ones of MHz, distances less than tens of meters shouldn't be an issue; but I shortened / tidied my wiring and it seemed to help.&lt;/li&gt;&#xA;&lt;li&gt;I would run everything at lowest possible speeds to troubleshoot, i.e. set the ADC sampling rate to 1kHz (set &lt;code&gt;CONFIG&lt;/code&gt; bits &lt;code&gt;5:4&lt;/code&gt; to &lt;code&gt;11&lt;/code&gt;), and set the SCLK at 250kHz.&lt;/li&gt;&#xA;&lt;li&gt;In the attached sketch, I am reading the register values based on an interrupt from the &lt;code&gt;CLKOUT\!DREADY&lt;/code&gt; pin. You have to be careful that this reading routine takes less than one ADC sampling time to read all the registers. There is a good explanation of this timing constraint in Figure 8 of &lt;a href=&quot;http://www.analog.com/media/en/technical-documentation/application-notes/AN-1332.pdf&quot; rel=&quot;nofollow&quot;&gt;this application note&lt;/a&gt;. The attached sketch also reports some timing information over serial to help with this.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope that helps,&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Khalid.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23003" LastActivityDate="2016-06-23T12:27:54.110" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25581" PostTypeId="2" ParentId="25578" CreationDate="2016-06-23T12:51:27.867" Score="1" Body="&lt;p&gt;This is talked about &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=57691.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  Evidently, the C++ compiler changes names of *.c files when compiling.  Try changing the names of your files from *.c to *.cpp so that the C++ compiler does not change the names. Then recompile.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-23T12:51:27.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25582" PostTypeId="2" ParentId="25578" CreationDate="2016-06-23T13:02:22.060" Score="1" Body="&lt;p&gt;The reason you are getting the undefined reference to  `tmp102_allocate(int)' is because your c source file is being converted to a cpp file and the function name is being mangled to support overloading etc etc. You need to flag that the functions are c code with  extern &quot;C&quot; blocks. If you change your header file to  the following it should compile. Alternatively, if you change the extension of your source file to .cpp you won't have any issues with name mangling but your code will probably not work (malloc). Note that by checking if __cplusplus is defined you can use this header in both cpp and c projects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;tmp102.h&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef TMP102_H&#xA;#define TMP102_H&#xA;&#xA;#ifdef __cplusplus&#xA;  extern &quot;C&quot; {&#xA;#endif&#xA;&#xA;//TP102 sensor struct&#xA;typedef struct TMP102 { &#xA;  int   address;&#xA;  float celsius;&#xA;  float fahrenheit;    &#xA;} tmp102_t;&#xA;&#xA; tmp102_t* tmp102_allocate(int address);&#xA;&#xA;void tmp102_init_struct(tmp102_t * t, int address);&#xA;&#xA;#ifdef __cplusplus&#xA;  }&#xA;#endif&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19911" LastActivityDate="2016-06-23T13:02:22.060" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25583" PostTypeId="1" CreationDate="2016-06-23T14:13:24.317" Score="0" ViewCount="283" Body="&lt;p&gt;Good day, I am currently attempting to write code that will allow a user to connect to an Arduino Mega via IP address and control a robotic arm on the X and Y axis as well as open and close the claw. I am facing 2 issues and hope someone can help me &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;when it connects for the first few seconds the servos twitch and I'm not sure why&lt;/li&gt;&#xA;&lt;li&gt;In my current code i am reading in the URL of the button pushed and moving the arm 5 degrees each time, but i would like to be able to hold the button down and have the arm move instead but I'm not sure how to go about that&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; Jamil Gaufr and Eva Santos&#xA; Bridges Project @ SUNY Purchase&#xA; Robotic Arm Control &amp;amp; Interface&#xA; */&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet2.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;//Represents servo to open/close claw&#xA;Servo microservo;&#xA;//Represents servo to move forward/away&#xA;Servo Yax;&#xA;//Represents servo to swivel left/right&#xA;Servo Xax;&#xA;&#xA;int pos = 0;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address&#xA;EthernetServer server(80);                             //server port&#xA;String readString;&#xA;String x = &quot;x =&quot;;&#xA;String y = &quot;y = &quot;;&#xA;String cl = &quot;claw  = &quot;; &#xA;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  Yax.attach(4);&#xA;  Xax.attach(5);&#xA;  microservo.attach(6);&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;  //Initializes every axis to start at the 45 degree position&#xA;  Yax.write(100);&#xA;  Xax.write(60);&#xA;  microservo.write(90);&#xA;  //1 second delay&#xA;  delay(1000);&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;  // Create a client connection&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;&#xA;        //read char by char HTTP request&#xA;        if (readString.length() &amp;lt; 100) {&#xA;          //store characters to string&#xA;          readString += c;&#xA;          //Serial.print(c);&#xA;        }&#xA;&#xA;        //if HTTP request has ended&#xA;        if (c == '\n') {&#xA;          //Serial.println(readString); //print to serial monitor for debuging&#xA;&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;); //send new page&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println();&#xA;          //begins html code&#xA;          client.println(&quot;&amp;lt;HTML&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;HEAD&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;TITLE&amp;gt;Bridges Program &amp;lt;/TITLE&amp;gt;&quot;);&#xA;          //CSS style code for buttons&#xA;          client.println(&quot;&amp;lt;STYLE&amp;gt;&quot;);&#xA;          client.println(&quot;.button { &quot;);&#xA;          client.println(&quot;background-color: #4CAF50;&quot;);&#xA;          client.println(&quot;border: none;&quot;);&#xA;          client.println(&quot;color: white;&quot;);&#xA;          client.println(&quot;padding: 15px 32px;&quot;);&#xA;          client.println(&quot;text-align: center;&quot;);&#xA;          client.println(&quot;display: inline-block;&quot;);&#xA;          client.println(&quot;font-size: 16px;&quot;);&#xA;          client.println(&quot;margin: 4px 2px;&quot;);&#xA;          client.println(&quot;cursor: pointer;&quot;);&#xA;          client.println(&quot;}&quot;);&#xA;          client.println(&quot;&amp;lt;/STYLE&amp;gt;&quot;);&#xA;          //end of CSS code&#xA;          client.println(&quot;&amp;lt;/HEAD&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;BODY&amp;gt;&quot;);&#xA;          //Page header&#xA;          client.println(&quot;&amp;lt;H1&amp;gt;Welcome to Robo-Farm!&amp;lt;/H1&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;hr /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          //Sub-heading&#xA;          client.println(&quot;&amp;lt;H2&amp;gt;Robotic Arm&amp;lt;/H2&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          //Creates buttons and corresponding URL extension&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button1on\&quot;\&quot; class = \&quot;button\&quot;&amp;gt;Close Claw&amp;lt;/a&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button1off\&quot;\&quot; class = \&quot;button\&quot;&amp;gt;Open Claw&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          //Creates buttons and corresponding URL extension&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button2on\&quot;\&quot; class = \&quot;button\&quot;&amp;gt;Move forward&amp;lt;/a&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button2off\&quot;\&quot; class = \&quot;button\&quot;&amp;gt;Move Away&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          //Creates buttons and corresponding URL extension to IP address&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button3on\&quot;\&quot; class = \&quot;button\&quot;&amp;gt;Swivle left&amp;lt;/a&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;a href=\&quot;/?button3off\&quot;\&quot; class = \&quot;button\&quot; &amp;gt;Swivle right&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          //Footer text&#xA;          client.println(&quot;&amp;lt;p&amp;gt;Created by Gafur &amp;amp; Santos.&amp;lt;/p&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/BODY&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/HTML&amp;gt;&quot;);&#xA;          //end of html file&#xA;          delay(1);&#xA;          //stopping client&#xA;          client.stop();&#xA;          //controls the Arduino if you press the buttons&#xA;          //parses the URL for the corresponding extension&#xA;          if (readString.indexOf(&quot;?button1on&quot;) &amp;gt; 0 &amp;amp;&amp;amp; microservo.read() &amp;lt;= 175) { // button1 on is close claw&#xA;            microservo.write(microservo.read() + 5);  // tell servo to go to position in variable 'pos'&#xA;            delay(15);                        // waits 15ms for the servo to reach the position&#xA;            Serial.println(cl + microservo.read());&#xA;          }&#xA;          if (readString.indexOf(&quot;?button1off&quot;) &amp;gt; 0&amp;amp;&amp;amp; microservo.read() &amp;gt;= 95) { // close claw&#xA;            microservo.write(microservo.read() - 5);  // tell servo to go to position in variable 'pos'&#xA;            delay(15);                                // waits 15ms for the servo to reach the position&#xA;            Serial.println(cl +microservo.read());&#xA;          }&#xA;          if (readString.indexOf(&quot;?button2on&quot;) &amp;gt; 0 &amp;amp;&amp;amp; Yax.read() &amp;lt; 150 ) { // button2 on is move forward on y ax (towards the servo on the claw)&#xA;            Yax.write(Yax.read() - 5);                // tell servo to go to position in variable 'pos'&#xA;            delay(15);                                // waits 15ms for the servo to reach the position&#xA;            Serial.println(y + Yax.read());&#xA;          }&#xA;          if (readString.indexOf(&quot;?button2off&quot;) &amp;gt; 0&amp;amp;&amp;amp; Yax.read() &amp;gt; 70 ) {&#xA;            Yax.write(Yax.read() + 5);                // tell servo to go to position in variable 'pos'&#xA;            delay(15);                // waits 15ms for the servo to reach the position&#xA;            Serial.println(y + Yax.read());&#xA;          }&#xA;          if (readString.indexOf(&quot;?button3on&quot;) &amp;gt; 0 ) { // button3 is swivle in direction of sticker&#xA;            Xax.write(Xax.read() - 3);                // tell servo to go to position in variable 'pos'&#xA;            delay(15);                                // waits 15ms for the servo to reach the position&#xA;            Serial.println(x + Xax.read());&#xA;          }&#xA;          if (readString.indexOf(&quot;?button3off&quot;) &amp;gt; 0) {&#xA;            Xax.write(Xax.read() + 3);                // tell servo to go to position in variable 'pos' S&#xA;            delay(15);                // waits 15ms for the servo to reach the position&#xA;            Serial.println(x + Xax.read());&#xA;          }&#xA;          //clearing string for next read&#xA;          readString = &quot;&quot;;&#xA;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7861" LastEditorUserId="19409" LastEditDate="2017-05-22T17:05:22.480" LastActivityDate="2018-05-19T12:26:37.870" Title="Ethernet Controlled Arduino Arm" Tags="|arduino-mega|ethernet|servo|web-server|robotics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25584" PostTypeId="2" ParentId="6886" CreationDate="2016-06-23T14:15:33.787" Score="1" Body="&lt;p&gt;No use in reinventing the wheel!&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Brain is an Arduino Library for parsing data from Neurosky-based EEG&#xA;  headsets. Tested units include the Star Wars Force Trainer and Mattel&#xA;  MindFlex.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;It's designed to make it simple to send out an ASCII string of&#xA;  comma-separated values over serial, or to access processed brain wave&#xA;  information directly in your Arduino sketch. See the examples for code&#xA;  demonstrating each use case.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/kitschpatrol/Brain&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kitschpatrol/Brain&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Install the library, and set it up like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Brain.h&amp;gt;&#xA;&#xA;// Set up the brain parser, pass it the hardware serial object you want to listen on.&#xA;Brain brain(Serial);&#xA;&#xA;void setup() {&#xA;// Start the hardware serial.&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;// Expect packets about once per second.&#xA;// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:&#xA;// &quot;signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma&quot;    &#xA;    if (brain.update()) {&#xA;    Serial.println(brain.readErrors());&#xA;    Serial.println(brain.readCSV());&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can't guarantee that it will work, but if you have the TX pin of the bluetooth hooked up to the RX pin of the Arduino I'm pretty sure it will work. &lt;/p&gt;&#xA;" OwnerUserId="18718" LastEditorDisplayName="user31481" LastEditDate="2017-11-17T12:10:44.837" LastActivityDate="2017-11-17T12:10:44.837" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25585" PostTypeId="2" ParentId="25560" CreationDate="2016-06-23T14:20:03.020" Score="0" Body="&lt;p&gt;Go to device manager, and make sure that you can see the change in your com ports when you unplug and plug the Arduino into your computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also have to follow the instructions here: &lt;a href=&quot;https://www.arduino.cc/en/Guide/Cores&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/Cores&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will also occasionally find that uploading won't work when I have something external connected to the RX,TX,3.3 and 5V, and GND pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also helps to go to File-Preferences- and enable both options for &quot;Show verbose output during&quot;. If you do that and post the output, we might have a better idea as to what is going wrong. &lt;/p&gt;&#xA;" OwnerUserId="18718" LastEditorUserId="18718" LastEditDate="2016-06-23T19:06:39.267" LastActivityDate="2016-06-23T19:06:39.267" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25586" PostTypeId="1" AcceptedAnswerId="25588" CreationDate="2016-06-23T14:48:51.427" Score="3" ViewCount="3074" Body="&lt;p&gt;I have been reading a bit about the internal pullup resistor. I know from past projects in school that resistor themselves are fragile (burnt one by accident due to higher current than was made for).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have two different Arduino models. One by Intel and rest are standard Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was wondering about safely using the internal pullup resistor on the Arduino Uno. Hence my question is about the internal pullup resistor pinmode; How many pin can you connect to it safely and not overload it?&lt;/p&gt;&#xA;" OwnerUserId="20049" LastActivityDate="2016-06-23T14:57:56.810" Title="Arduino Uno: Pullup Resistor" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25588" PostTypeId="2" ParentId="25586" CreationDate="2016-06-23T14:57:56.810" Score="5" Body="&lt;p&gt;Each pin has its own, separate, pullup resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't believe you can damage it by drawing current from the port, because the pullup resistor is only active when the port is in high impedance (hi-Z, input) mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The pullup resistor can be damaged by overvoltage, static discharge, and the like. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Uno has 20 kOhm pullup resistors according to &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPins&quot; rel=&quot;noreferrer&quot;&gt;this tutorial&lt;/a&gt;. If you feed it a 0V signal while the Atmega is running at 5V, the current will be a quarter of a milliamp, which is miniscule.&lt;/p&gt;&#xA;" OwnerUserId="21015" LastActivityDate="2016-06-23T14:57:56.810" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25591" PostTypeId="1" AcceptedAnswerId="25592" CreationDate="2016-06-23T15:28:32.100" Score="2" ViewCount="9091" Body="&lt;p&gt;I'm trying to debug a problem and need to reduce the speed of the clock on my Arduino Mega from 16MHz to 8MHz. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find any simple way of doing so, so I wanted to know if there were any gurus here who knew if this was possible, as well as how to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WITHOUT PRESCALER:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long int runTime;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);     //Setting the data transfer rate &#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;  delay(1000);&#xA;  runTime = millis();&#xA;  Serial.print(&quot;Runetime: &quot;);&#xA;  Serial.println(runTime);&#xA;  delay(100);&#xA;  exit(0);&#xA;}&#xA;&#xA;OUTPUT: 999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;WITH PRESCALER:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long int runTime;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(19200);   //Setting the data transfer rate for when CLK Freq. is Halfed&#xA;&#xA;  CLKPR = _BV(CLKPCE);  // enable change of the clock prescaler&#xA;  CLKPR = _BV(CLKPS0);  // divide frequency by 2&#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;  delay(1000);&#xA;  runTime = millis();&#xA;  Serial.print(&quot;Runetime: &quot;);&#xA;  Serial.println(runTime);&#xA;  delay(100);&#xA;  exit(0);&#xA;}&#xA;&#xA;OUTPUT: 999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22788" LastEditorUserId="22788" LastEditDate="2016-06-23T16:12:11.270" LastActivityDate="2016-06-23T18:01:47.597" Title="How can you reduce the clock frequency of an Arduino Mega?" Tags="|arduino-mega|oscillator-clock|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25592" PostTypeId="2" ParentId="25591" CreationDate="2016-06-23T15:43:00.443" Score="5" Body="&lt;p&gt;You can set the clock prescaler for that:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    noInterrupts();&#xA;    CLKPR = _BV(CLKPCE);  // enable change of the clock prescaler&#xA;    CLKPR = _BV(CLKPS0);  // divide frequency by 2&#xA;    interrupts();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is explained in section 10.12 and 10.13 of the&#xA;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ATmega2560&#xA;datasheet&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, changing the clock frequency will mess with the time-related&#xA;function (&lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt; and co.) and the baud rate of the serial&#xA;port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Here is a small program to demonstrate the slowing of the&#xA;clock:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;//#define SLOW_CLOCK&#xA;&#xA;void setup()&#xA;{&#xA;#ifdef SLOW_CLOCK&#xA;    noInterrupts();&#xA;    CLKPR = _BV(CLKPCE);  // enable change of the clock prescaler&#xA;    CLKPR = _BV(CLKPS0);  // divide frequency by 2&#xA;    interrupts();&#xA;#endif&#xA;    pinMode(LED_BUILTIN, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    digitalWrite(LED_BUILTIN, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(LED_BUILTIN, LOW);&#xA;    delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This makes the LED flash at 1&amp;nbsp;Hz. If you uncomment the line&#xA;&lt;code&gt;#define SLOW_CLOCK&lt;/code&gt;, it instead flashes at 0.5&amp;nbsp;Hz.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-23T18:01:47.597" LastActivityDate="2016-06-23T18:01:47.597" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25593" PostTypeId="1" AcceptedAnswerId="25626" CreationDate="2016-06-23T16:12:47.363" Score="13" ViewCount="31600" Body="&lt;p&gt;I want to create a bluetooth remote audio control to control smartphone audio, essentially identical in function to this type of equipment:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/COMqF.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/COMqF.jpg&quot; alt=&quot;Bluetooth audio control&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B01C5E95XG&quot; rel=&quot;noreferrer&quot;&gt;https://www.amazon.com/FAVOLCANO-Bluetooth-Button-Smartphone-Samsung/dp/B01C5E95XG/ref=pd_lpo_147_bs_t_1?ie=UTF8&amp;amp;refRID=1GRBCPDRMD9YPYPGK73Y&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This device is simply a bluebooth remote control which allows you to play or pause audio, skip forward or backward and change media volume on the smart phone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the Arduino tutorials I see are about either using the iPhone to control a bluebooth device, or about using bluetooth to control an arduino, neither of which are what I want to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you point me in the right direction?&lt;/p&gt;&#xA;" OwnerUserId="23303" LastActivityDate="2020-12-09T11:40:57.537" Title="Want to create bluetooth audio control (volume up/down, play, pause, etc.) for smartphone" Tags="|bluetooth|audio|remote-control|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25594" PostTypeId="2" ParentId="25572" CreationDate="2016-06-23T16:28:35.240" Score="2" Body="&lt;p&gt;Without the ground of the teensy connected to the ground of the fan all you will be measuring is noise. Ground is required to complete the circuit between the teensy and the fan.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-23T16:28:35.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25595" PostTypeId="1" AcceptedAnswerId="25622" CreationDate="2016-06-23T16:45:50.360" Score="2" ViewCount="23917" Body="&lt;p&gt;I would like to generate a sine wave with my Arduino Uno. As far as I know, there is no library for Uno to generate such a signal (correct me if I'm wrong), so the only option available is to write a function to generate the signal from scratch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as my understanding of digital electronics goes, I believe it is possible to generate a sine wave signal by using PWM and varying the duty cycle accordingly. However, this route seems to me quite long, what other options do I have?&lt;/p&gt;&#xA;" OwnerUserId="3546" LastActivityDate="2017-01-01T07:48:27.203" Title="How can I generate a sinewave with Arduino Uno?" Tags="|arduino-uno|signal-processing|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25596" PostTypeId="2" ParentId="25595" CreationDate="2016-06-23T17:04:46.770" Score="4" Body="&lt;p&gt;There are two parts to this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One is the creation/derivation/storage of the &lt;em&gt;digital representation&lt;/em&gt; of a sine wave. The other is the conversion of the digital representation of a sine wave to an analog voltage (if I understand what you want).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The easiest way to obtain the digital representation of a sine wave is a lookup table. Precompute the digital values, and store them in an array. Simple. It is up to you to decide how much resolution (both in vertical accuracy/number of bits and horizontal accuracy/number of samples) you require.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is also possible to compute the values directly. There are a number of ways of doing this, but be aware that using floating point math on the Arduino is very slow and space-intensive. You may want to look at &lt;a href=&quot;https://en.wikipedia.org/wiki/CORDIC&quot; rel=&quot;nofollow&quot;&gt;CORDIC&lt;/a&gt; for one possible solution to this.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Next is the conversion to analog. You are right, PWM is one way to do this, and one of the easiest as far as external components go: you only need an RC filter to smooth the PWM. However, PWM is limited in resolution, and performs poorly when your wave frequency becomes a significant fraction of your PWM frequency. Also, the Arduino doesn't run very fast, so your PWM frequency is limited.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other DAC solutions (there are many many many, so I'm not going to go in depth on this):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;R2R DAC: simple to construct, but requires precision resistors for decent resolution, limited in resolution, and requires many IO pins.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&quot;proper&quot; DAC: an I2C/SPI DAC can give you far better performance, but you will have to learn how to communicate with it. And it's going to be more expensive, and involve several components.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;However, this route seems to me quite long, what other options do I have?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm not sure what you mean by &quot;quite long&quot;, but this is pretty straightforward. For example, here's how I'd go about it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;store a sine wave in a lookup table&lt;/li&gt;&#xA;&lt;li&gt;set up an interrupt to trigger at regular intervals&lt;/li&gt;&#xA;&lt;li&gt;in the interrupt, pull a value from the lookup table and write it to PWM&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can now vary the frequency of your sine wave by either adjusting your interrupt interval, or adjusting the increment of your LUT position. You can vary the amplitude by simply multiplying the LUT values by a variable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is quite straightforward.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-06-23T17:04:46.770" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25600" PostTypeId="2" ParentId="16671" CreationDate="2016-06-23T19:01:04.007" Score="1" Body="&lt;p&gt;Sorry I'm late -- I realize this question was asked 8 months ago, but it doesn't look like you fixed it, and I figure others can always benefit (or you might even, if you still want to try).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code looks correct (I compared it to the Sparkfun example, and also to the datasheet for the MPC4725). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it does look like you're using the wrong address for the part.&#xA;(The actual value for the address is not given in the Sparkfun example -- at least, I couldn't find it).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define MCP4725_ADDR 0x60 // [0000 0110]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is wrong in two places: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) 0x60 is 0110 0000, not 0000 0110&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) According to the datasheet (section 7.2), the address should begin with the device code %1100, and then the address gets appended. So assuming an address of A2 = 0, A1 = 0, and A0 = 0 (default), the value for MCP4725_ADDR looks like it should be 0xC0 or %1100 000x.  If you soldered the address line to Vcc instead of ground, the address should be 0xC2 or %1100 001x.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The x in the address line represents the read/write bit.  If you're trying to command the DAC, it should not be asserted, so the addresses above are correct. If you're trying to read the current value, it should be asserted, which makes your address 0xC1 or 0xC3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have the address wrong, even though the rest is correct, the part will ignore it, so that's probably the issue you're seeing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps someone!&lt;/p&gt;&#xA;" OwnerUserId="23309" LastActivityDate="2016-06-23T19:01:04.007" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25601" PostTypeId="1" CreationDate="2016-06-23T19:28:35.800" Score="0" ViewCount="1450" Body="&lt;p&gt;I have to sleep the system in the night and have to wake the system in day time. I am using LDR to get input. LDR input is connected to interrupt pin 0 of Arduino Uno. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;int led =13;&#xA;int triggerPin = 2;&#xA;&#xA;void wakeUpNow() &#xA;{&#xA;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(triggerPin, INPUT);&#xA;pinMode(led, OUTPUT);&#xA;attachInterrupt(0, sleepNow, LOW); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;digitalWrite(led, HIGH);;&#xA;delay(1000);&#xA;digitalWrite(led, LOW);&#xA;}&#xA;&#xA;void sleepNow() &#xA;{&#xA;set_sleep_mode(SLEEP_MODE_PWR_DOWN); &#xA;sleep_enable(); &#xA;attachInterrupt(0,wakeUpNow, RISING); &#xA;sleep_mode(); &#xA;sleep_disable();&#xA;detachInterrupt(0); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cannot we attach two function in a interrupt? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edited&lt;/strong&gt;&#xA;The following code works perfectly. I want to replace the conditional check with interrupt.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;int led =13;&#xA;int wakePin = 2; &#xA;&#xA;void wakeUpNow() &#xA;{&#xA;delay(100);&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(wakePin, INPUT);&#xA;pinMode(led, OUTPUT);&#xA;//attachInterrupt(0, sleepNow, LOW); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;digitalWrite(led, HIGH);;&#xA;delay(1000);&#xA;digitalWrite(led, LOW);&#xA;&#xA;if(digitalRead(wakePin)==LOW)&#xA;  sleepNow(); &#xA;&#xA;}&#xA;&#xA;void sleepNow() &#xA;{&#xA;set_sleep_mode(SLEEP_MODE_PWR_DOWN); &#xA;sleep_enable(); &#xA;attachInterrupt(0,wakeUpNow, RISING); function&#xA;sleep_mode(); &#xA;sleep_disable(); &#xA;detachInterrupt(0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to replace `&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(digitalRead(wakePin)==LOW)&#xA;  sleepNow()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with`&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0, sleepNow, LOW);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please let me know how I can do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="23310" LastEditorUserId="23310" LastEditDate="2016-06-24T03:12:17.377" LastActivityDate="2016-06-24T04:25:32.253" Title="Sleep and Wake Arduino according to LDR interrupt" Tags="|arduino-uno|interrupt|sleep|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25604" PostTypeId="2" ParentId="25448" CreationDate="2016-06-23T20:52:20.220" Score="1" Body="&lt;p&gt;It sounds like you're missing the fact that the Arduino IDE resets the Arduino board by toggling one of the comm port flow control signals. This causes a hardware reset on the Arduino board and then things happen as you've explained. &lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2016-06-23T20:52:20.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25605" PostTypeId="2" ParentId="5231" CreationDate="2016-06-23T21:09:53.533" Score="-1" Body="&lt;p&gt;Use voltage level translator. 5v to 3.3V. Dont just connect directly 5v tx to a 3.3v tx...!!&lt;/p&gt;&#xA;" OwnerUserId="9978" LastActivityDate="2016-06-23T21:09:53.533" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25606" PostTypeId="1" CreationDate="2016-06-23T21:59:34.713" Score="0" ViewCount="95" Body="&lt;p&gt;I was wondering if it was possible to connect a camera like &lt;a href=&quot;http://www.ebay.com/itm/HD-Mini-CCTV-Camera-Security-Micro-Audio-Wired-600TVL-1-4-5Mp-0-5LUX-/171421181800?hash=item27e97fa768:g:MbMAAOSwEK9T7Fwt&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; onto an Arduino mini and have the Arduino save video and audio to a micro SD card. &lt;/p&gt;&#xA;" OwnerUserId="23314" LastEditorUserId="23118" LastEditDate="2016-06-25T18:09:20.517" LastActivityDate="2016-06-25T18:09:20.517" Title="Can I connect a camera to an arduino mini?" Tags="|sd-card|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25607" PostTypeId="2" ParentId="25583" CreationDate="2016-06-23T22:11:07.133" Score="1" Body="&lt;p&gt;Question 1 will need more information about your code and your wiring of the arm to offer any reasonable answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question 2: There really isn't much to go on but I'll take a guess that you're sending a single message to the arm server on each button press - ? I'd try instead, sending another message every 't' starting at (.75 * t) from message-1, where 't' is the time taken for the arm to move 5 degrees. That's a totally wild guess based on unfounded assumptions of what's happening now, and what fraction of 't' I guess would make sense, but that would be my first, very experimental approach. And even so, given the non-determinism of internet packet arrival times, I wouldn't bet on getting very smooth motion, nor instant stopping on button release.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My next experiment would be send start moving/keep moving commands to the arm on button-press, stop moving on button-release, with the arm controller being smart enough to 1) stop anyway after some short period of no messages or it reaches its limit, and 2) not let commands accumulate (or the arm will keep driving until it limits).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;br&gt;&#xA;Yes, if you're using a terminal emulator that has the ability to send each keystroke rather than line-by-line, and doesn't suppress key-repeat. As above, don't accumulate incoming keystrokes but when you're looking for another, drain the buffer first then watch for an incoming one. If you don't find it within &amp;lt;TIMEOUT&amp;gt;, stop moving. &amp;lt;TIMEOUT&amp;gt; should be slightly longer than the key-repeat interval.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I like my second way better - winging it at the keyboard, heh! - but if it were me, I'd probably try both anyway just for what I could learn from either one).&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-06-25T13:00:47.280" LastActivityDate="2016-06-25T13:00:47.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25608" PostTypeId="1" AcceptedAnswerId="25611" CreationDate="2016-06-23T22:34:36.197" Score="-2" ViewCount="1172" Body="&lt;p&gt;I'm using the MPU9250 and the RTIMULib to perform sensor fusion, however, when I run ArduinoMagCal, and save the calibration, and follow that with running the main ArduinoIMU it claims the calibration file is not saved, and there is no data to use. I'm trying to determine why this is - I have tried the other MPU9250 libraries without luck, as this one is working on my setup (Arduino Micro -&gt; eventually NodeMCU). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Repo : &lt;a href=&quot;https://github.com/maxouille/RTIMULib-Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/maxouille/RTIMULib-Arduino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ArduinoMagCal&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;////////////////////////////////////////////////////////////////////////////&#xA;//&#xA;//  This file is part of RTIMULib-Arduino&#xA;//&#xA;//  Copyright (c) 2014-2015, richards-tech&#xA;//&#xA;//  Permission is hereby granted, free of charge, to any person obtaining a copy of &#xA;//  this software and associated documentation files (the &quot;Software&quot;), to deal in &#xA;//  the Software without restriction, including without limitation the rights to use, &#xA;//  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the &#xA;//  Software, and to permit persons to whom the Software is furnished to do so, &#xA;//  subject to the following conditions:&#xA;//&#xA;//  The above copyright notice and this permission notice shall be included in all &#xA;//  copies or substantial portions of the Software.&#xA;//&#xA;//  THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, &#xA;//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A &#xA;//  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT &#xA;//  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION &#xA;//  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE &#xA;//  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;RTIMUSettings.h&quot;&#xA;#include &quot;RTIMU.h&quot;&#xA;#include &quot;CalLib.h&quot;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;RTIMU *imu;                                           // the IMU object&#xA;RTIMUSettings settings;                               // the settings object&#xA;CALLIB_DATA calData;                                  // the calibration data&#xA;&#xA;//  SERIAL_PORT_SPEED defines the speed to use for the debug serial port&#xA;&#xA;#define  SERIAL_PORT_SPEED  115200&#xA;&#xA;void setup()&#xA;{&#xA;  calLibRead(0, &amp;amp;calData);                           // pick up existing mag data if there   &#xA;&#xA;  calData.magValid = false;&#xA;  for (int i = 0; i &amp;lt; 3; i++) {&#xA;    calData.magMin[i] = 10000000;                    // init mag cal data&#xA;    calData.magMax[i] = -10000000;&#xA;  }&#xA;&#xA;  Serial.begin(SERIAL_PORT_SPEED);&#xA;  Serial.println(&quot;ArduinoMagCal starting&quot;);&#xA;  Serial.println(&quot;Enter s to save current data to EEPROM&quot;);&#xA;  Wire.begin();&#xA;&#xA;  imu = RTIMU::createIMU(&amp;amp;settings);                 // create the imu object&#xA;  imu-&amp;gt;IMUInit();&#xA;  imu-&amp;gt;setCalibrationMode(true);                     // make sure we get raw data&#xA;  Serial.print(&quot;ArduinoIMU calibrating device &quot;); Serial.println(imu-&amp;gt;IMUName());&#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;  boolean changed;&#xA;  RTVector3 mag;&#xA;&#xA;  if (imu-&amp;gt;IMURead()) {                                 // get the latest data&#xA;    changed = false;&#xA;    mag = imu-&amp;gt;getCompass();&#xA;    for (int i = 0; i &amp;lt; 3; i++) {&#xA;      if (mag.data(i) &amp;lt; calData.magMin[i]) {&#xA;        calData.magMin[i] = mag.data(i);&#xA;        changed = true;&#xA;      }&#xA;      if (mag.data(i) &amp;gt; calData.magMax[i]) {&#xA;        calData.magMax[i] = mag.data(i);&#xA;        changed = true;&#xA;      }&#xA;    }&#xA;&#xA;    if (changed) {&#xA;      Serial.println(&quot;-------&quot;);&#xA;      Serial.print(&quot;minX: &quot;); Serial.print(calData.magMin[0]);&#xA;      Serial.print(&quot; maxX: &quot;); Serial.print(calData.magMax[0]); Serial.println();&#xA;      Serial.print(&quot;minY: &quot;); Serial.print(calData.magMin[1]);&#xA;      Serial.print(&quot; maxY: &quot;); Serial.print(calData.magMax[1]); Serial.println();&#xA;      Serial.print(&quot;minZ: &quot;); Serial.print(calData.magMin[2]);&#xA;      Serial.print(&quot; maxZ: &quot;); Serial.print(calData.magMax[2]); Serial.println();&#xA;    }&#xA;  }&#xA;&#xA;  if (Serial.available()) {&#xA;    if (Serial.read() == 's') {                  // save the data&#xA;      calData.magValid = true;&#xA;      calLibWrite(0, &amp;amp;calData);&#xA;      Serial.print(&quot;Mag cal data saved for device &quot;); Serial.println(imu-&amp;gt;IMUName());&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ArduinoIMU&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;////////////////////////////////////////////////////////////////////////////&#xA;//&#xA;//  This file is part of RTIMULib-Arduino&#xA;//&#xA;//  Copyright (c) 2014-2015, richards-tech&#xA;//&#xA;//  Permission is hereby granted, free of charge, to any person obtaining a copy of &#xA;//  this software and associated documentation files (the &quot;Software&quot;), to deal in &#xA;//  the Software without restriction, including without limitation the rights to use, &#xA;//  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the &#xA;//  Software, and to permit persons to whom the Software is furnished to do so, &#xA;//  subject to the following conditions:&#xA;//&#xA;//  The above copyright notice and this permission notice shall be included in all &#xA;//  copies or substantial portions of the Software.&#xA;//&#xA;//  THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, &#xA;//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A &#xA;//  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT &#xA;//  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION &#xA;//  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE &#xA;//  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;I2Cdev.h&quot;&#xA;#include &quot;RTIMUSettings.h&quot;&#xA;#include &quot;RTIMU.h&quot;&#xA;#include &quot;RTFusionRTQF.h&quot; &#xA;#include &quot;CalLib.h&quot;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;RTIMU *imu;                                           // the IMU object&#xA;RTFusionRTQF fusion;                                  // the fusion object&#xA;RTIMUSettings settings;                               // the settings object&#xA;&#xA;//  DISPLAY_INTERVAL sets the rate at which results are displayed&#xA;&#xA;#define DISPLAY_INTERVAL  300                         // interval between pose displays&#xA;&#xA;//  SERIAL_PORT_SPEED defines the speed to use for the debug serial port&#xA;&#xA;#define  SERIAL_PORT_SPEED  115200&#xA;&#xA;unsigned long lastDisplay;&#xA;unsigned long lastRate;&#xA;int sampleCount;&#xA;&#xA;void setup()&#xA;{&#xA;    int errcode;&#xA;&#xA;    Serial.begin(SERIAL_PORT_SPEED);&#xA;    Wire.begin();&#xA;    imu = RTIMU::createIMU(&amp;amp;settings);                        // create the imu object&#xA;&#xA;    Serial.print(&quot;ArduinoIMU starting using device &quot;); Serial.println(imu-&amp;gt;IMUName());&#xA;    if ((errcode = imu-&amp;gt;IMUInit()) &amp;lt; 0) {&#xA;        Serial.print(&quot;Failed to init IMU: &quot;); Serial.println(errcode);&#xA;    }&#xA;&#xA;    if (imu-&amp;gt;getCalibrationValid())&#xA;        Serial.println(&quot;Using compass calibration&quot;);&#xA;    else&#xA;        Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&#xA;    lastDisplay = lastRate = millis();&#xA;    sampleCount = 0;&#xA;&#xA;    // Slerp power controls the fusion and can be between 0 and 1&#xA;    // 0 means that only gyros are used, 1 means that only accels/compass are used&#xA;    // In-between gives the fusion mix.&#xA;&#xA;    fusion.setSlerpPower(1);&#xA;&#xA;    // use of sensors in the fusion algorithm can be controlled here&#xA;    // change any of these to false to disable that sensor&#xA;&#xA;    fusion.setGyroEnable(false);&#xA;    fusion.setAccelEnable(true);&#xA;    fusion.setCompassEnable(true);&#xA;}&#xA;&#xA;void loop()&#xA;{  &#xA;    unsigned long now = millis();&#xA;    unsigned long delta;&#xA;    int loopCount = 1;&#xA;&#xA;    while (imu-&amp;gt;IMURead()) {                                // get the latest data if ready yet&#xA;        // this flushes remaining data in case we are falling behind&#xA;        if (++loopCount &amp;gt;= 10)&#xA;            continue;&#xA;        fusion.newIMUData(imu-&amp;gt;getGyro(), imu-&amp;gt;getAccel(), imu-&amp;gt;getCompass(), imu-&amp;gt;getTimestamp());&#xA;        sampleCount++;&#xA;        if ((delta = now - lastRate) &amp;gt;= 1000) {&#xA;            Serial.print(&quot;Sample rate: &quot;); Serial.print(sampleCount);&#xA;            if (imu-&amp;gt;IMUGyroBiasValid())&#xA;                Serial.println(&quot;, gyro bias valid&quot;);&#xA;            else&#xA;                Serial.println(&quot;, calculating gyro bias&quot;);&#xA;&#xA;            sampleCount = 0;&#xA;            lastRate = now;&#xA;        }&#xA;        if ((now - lastDisplay) &amp;gt;= DISPLAY_INTERVAL) {&#xA;            lastDisplay = now;&#xA;//          RTMath::display(&quot;Gyro:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getGyro());                // gyro data&#xA;//          RTMath::display(&quot;Accel:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getAccel());              // accel data&#xA;            //RTMath::display(&quot;Mag:&quot;, (RTVector3&amp;amp;)imu-&amp;gt;getCompass());              // compass data&#xA;            RTMath::displayRollPitchYaw(&quot;Pose:&quot;, (RTVector3&amp;amp;)fusion.getFusionPose()); // fused output&#xA;           Serial.println();&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Lastly in the repo, you will see a CalLib folder with the CalLib.cpp program inside, wondering if it is saving to the EEPROM incorrectly?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;////////////////////////////////////////////////////////////////////////////&#xA;//&#xA;//  This file is part of RTIMULib-Arduino&#xA;//&#xA;//  Copyright (c) 2014-2015, richards-tech&#xA;//&#xA;//  Permission is hereby granted, free of charge, to any person obtaining a copy of &#xA;//  this software and associated documentation files (the &quot;Software&quot;), to deal in &#xA;//  the Software without restriction, including without limitation the rights to use, &#xA;//  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the &#xA;//  Software, and to permit persons to whom the Software is furnished to do so, &#xA;//  subject to the following conditions:&#xA;//&#xA;//  The above copyright notice and this permission notice shall be included in all &#xA;//  copies or substantial portions of the Software.&#xA;//&#xA;//  THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, &#xA;//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A &#xA;//  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT &#xA;//  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION &#xA;//  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE &#xA;//  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&#xA;&#xA;#include &quot;CalLib.h&quot;&#xA;#ifdef __SAM3X8E__&#xA;&#xA;// Due version&#xA;&#xA;#include &quot;DueFlash.h&quot;&#xA;&#xA;DueFlash flash;&#xA;&#xA;void calLibErase(byte device)&#xA;{&#xA;    uint32_t data = 0;&#xA;&#xA;    flash.write(CALLIB_START + sizeof(CALLIB_DATA) * device, &amp;amp;data, 1); // just destroy the valid byte&#xA;}&#xA;&#xA;void calLibWrite(byte device, CALLIB_DATA *calData)&#xA;{&#xA;    calData-&amp;gt;validL = CALLIB_DATA_VALID_LOW;&#xA;    calData-&amp;gt;validH = CALLIB_DATA_VALID_HIGH;&#xA;&#xA;    flash.write(CALLIB_START + sizeof(CALLIB_DATA) * device, (uint32_t *)calData, sizeof(CALLIB_DATA) / 4);&#xA;}&#xA;&#xA;boolean calLibRead(byte device, CALLIB_DATA *calData)&#xA;{&#xA;    memcpy(calData, CALLIB_START + sizeof(CALLIB_DATA) * device, sizeof(CALLIB_DATA));&#xA;    return calData-&amp;gt;valid == CALLIB_DATA_VALID;&#xA;}&#xA;&#xA;#else&#xA;&#xA;// AVR version&#xA;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;&#xA;void calLibErase(byte device)&#xA;{&#xA;    EEPROM.write(sizeof(CALLIB_DATA) * device, 0); // just destroy the valid byte&#xA;    //EEPROM.commit();&#xA;}&#xA;&#xA;void calLibWrite(byte device, CALLIB_DATA *calData)&#xA;{&#xA;  byte *ptr = (byte *)calData;&#xA;  byte length = sizeof(CALLIB_DATA);&#xA;  int eeprom = sizeof(CALLIB_DATA) * device;&#xA;&#xA;  calData-&amp;gt;validL = CALLIB_DATA_VALID_LOW;&#xA;  calData-&amp;gt;validH = CALLIB_DATA_VALID_HIGH;&#xA;&#xA;  for (byte i = 0; i &amp;lt; length; i++) {&#xA;    EEPROM.write(eeprom + i, *ptr++);&#xA;    //EEPROM.commit();&#xA;  }&#xA;}&#xA;&#xA;boolean calLibRead(byte device, CALLIB_DATA *calData)&#xA;{&#xA;  byte *ptr = (byte *)calData;&#xA;  byte length = sizeof(CALLIB_DATA);&#xA;  int eeprom = sizeof(CALLIB_DATA) * device;&#xA;&#xA;  calData-&amp;gt;magValid = false;&#xA;&#xA;  if ((EEPROM.read(eeprom) != CALLIB_DATA_VALID_LOW) ||&#xA;      (EEPROM.read(eeprom + 1) != CALLIB_DATA_VALID_HIGH)) {&#xA;    return false;                                  // invalid data&#xA;  }&#xA;&#xA;  for (byte i = 0; i &amp;lt; length; i++)&#xA;    *ptr++ = EEPROM.read(eeprom + i);&#xA;  return true;  &#xA;}&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23232" LastActivityDate="2016-12-22T01:25:49.160" Title="MPU9250 - Calibration Not Saved with RTIMULib EEPROM Issues" Tags="|sensors|esp8266|arduino-micro|eeprom|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25609" PostTypeId="1" AcceptedAnswerId="25636" CreationDate="2016-06-24T00:52:48.440" Score="15" ViewCount="71788" Body="&lt;p&gt;I currently can set four PWM pins to around 31&amp;nbsp;kHz with the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    TCCR1B = TCCR1B &amp;amp; B11111000 | B00000001; // Set PWM frequency for D9 &amp;amp; D10:&#xA;    pinMode(pwmPin9, OUTPUT); // Sets the pin as output&#xA;    pinMode(pwmPin10, OUTPUT); // Sets the pin as output&#xA;&#xA;&#xA;    TCCR2B = TCCR2B &amp;amp; B11111000 | B00000001; // Set PWM for D3 &amp;amp; D11&#xA;    pinMode(pwmPin3, OUTPUT); // Sets the pin as output&#xA;    pinMode(pwmPin11, OUTPUT); // Sets the pin as output&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I found this setup somewhere, but I don't know how I can set these four PWM pins to around 25&amp;nbsp;kHz instead. How is that possible?&lt;/p&gt;&#xA;" OwnerUserId="4557" LastEditorUserId="972" LastEditDate="2018-02-13T03:50:43.917" LastActivityDate="2020-07-07T14:05:13.770" Title="Set PWM frequency to 25 kHz" Tags="|pwm|frequency|" AnswerCount="2" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="25611" PostTypeId="2" ParentId="25608" CreationDate="2016-06-24T02:14:15.153" Score="0" Body="&lt;p&gt;There was a compilation error which was preventing me from seeing that the data was indeed being saved to EEPROM, as far as I know there are no more issues. Just be mindful if you want to test it to add this in your calibration file after the save line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  if (imu-&amp;gt;getCalibrationValid())&#xA;      Serial.println(&quot;Using compass calibration&quot;);&#xA;  else&#xA;      Serial.println(&quot;No valid compass calibration data&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23232" LastActivityDate="2016-06-24T02:14:15.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25613" PostTypeId="2" ParentId="25606" CreationDate="2016-06-24T02:35:29.720" Score="1" Body="&lt;p&gt;Not really (at least, not with any appreciable quality). Basically, the bandwidth involved is simply too much for the Arduino's relatively slow 16MHz core speed. You might be able to periodically capture greyscale lowres frames, but capturing the full 1280x960 resolution at any decent framerate is basically impossible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to find Arduino projects that involve capturing video like this, the search term is &lt;code&gt;arduino composite video input&lt;/code&gt;. There are many projects out there that interface the Arduino with a composite input, but none that I know of that can capture full video. Consider the following: your Arduino runs at 16 MHz. If you were to handle 640x480 greyscale video (1 byte per pixel), that would be a data bandwidth (disregarding signal bandwidth) of 640*480*30 = 9216000 bytes/second. That's a pretty tall order: even if you could process each pixel in two (single cycle) instructions with no overhead, you still wouldn't have enough processor bandwidth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If all you want to do is record composite video to an SD card, there are far easier options out there, search &lt;code&gt;composite video recorder sd&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="16988" LastActivityDate="2016-06-24T02:35:29.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25614" PostTypeId="2" ParentId="25601" CreationDate="2016-06-24T04:25:32.253" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I want to replace the conditional check with interrupt.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why? If it is awake it might just as well be testing the pin as doing anything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you make it an interrupt, in the ISR interrupts will be off. Then if you go to sleep it will never wake.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, your current design is the correct one, except:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;attachInterrupt(0,wakeUpNow, RISING); function&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What is &lt;code&gt;function&lt;/code&gt; doing there?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-24T04:25:32.253" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25615" PostTypeId="2" ParentId="25575" CreationDate="2016-06-24T05:11:49.063" Score="1" Body="&lt;p&gt;I figure out the issue , I just add a small delay in ISR and my code is running fine now. I don't know reason behind it but anyway my code is running now. Here is my new code:-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define F_CPU 16000000UL&#xA;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;#include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;util/delay.h&amp;gt;&#xA;#include &amp;lt;avr/sfr_defs.h&amp;gt;&#xA;&#xA;&#xA;#define one_time_max          588 // these values are setup for NTSC video&#xA;#define one_time_min          422 // PAL would be around 1000 for 0 and 500 for 1&#xA;#define zero_time_max          1080 // 80bits times 29.97 frames per sec&#xA;#define zero_time_min          922 // equals 833 (divide by 8 clock pulses)&#xA;&#xA;&#xA;#define icpPin 8        // ICP input pin on arduino&#xA;#define end_data_position      63&#xA;#define end_sync_position      77&#xA;#define end_smpte_position     80&#xA;&#xA;volatile unsigned int bit_time;&#xA;volatile char valid_tc_word;&#xA;volatile char ones_bit_count;&#xA;volatile char tc_sync;&#xA;volatile char write_tc_out;&#xA;volatile char drop_frame_flag;&#xA;&#xA;volatile unsigned char total_bits;&#xA;volatile unsigned char current_bit;&#xA;volatile unsigned char sync_count;&#xA;&#xA;volatile unsigned char tc[8];&#xA;volatile char timeCode[11];&#xA;&#xA;&#xA;void USARTInit(uint16_t ubrr_value)&#xA;{&#xA;&#xA;    UBRRL = ubrr_value;&#xA;    UBRRH = (ubrr_value&amp;gt;&amp;gt;8);&#xA;    UCSRC|=(1&amp;lt;&amp;lt;URSEL)|(1&amp;lt;&amp;lt;UCSZ1)|(1&amp;lt;&amp;lt;UCSZ0);&#xA;    UCSRB=(1&amp;lt;&amp;lt;RXCIE)|(1&amp;lt;&amp;lt;RXEN)|(1&amp;lt;&amp;lt;TXEN);&#xA;&#xA;&#xA;}&#xA;&#xA;unsigned char USARTReadChar()&#xA;{&#xA;&#xA;    while(!(UCSRA &amp;amp; (1&amp;lt;&amp;lt;RXC)));&#xA;    return UDR;&#xA;}&#xA;&#xA;void USARTWriteChar(char data)&#xA;{&#xA;&#xA;    while(!(UCSRA &amp;amp; (1&amp;lt;&amp;lt;UDRE)));&#xA;    UDR=data;&#xA;}&#xA;&#xA;void send_string(char s[])&#xA;{&#xA;    int i =0;&#xA;&#xA;    while (s[i] != 0x00)&#xA;    {&#xA;        USARTWriteChar(s[i]);&#xA;        i++;&#xA;    }&#xA;    USARTWriteChar('\n');&#xA;}&#xA;&#xA;&#xA;&#xA;int main(void)&#xA;{&#xA;&#xA;    USARTInit(103);&#xA;    DDRB=0;&#xA;    bit_time = 0;&#xA;    valid_tc_word = 0;&#xA;    ones_bit_count = 0;&#xA;    tc_sync = 0;&#xA;    write_tc_out = 0;&#xA;    drop_frame_flag = 0;&#xA;    total_bits =  0;&#xA;    current_bit =  0;&#xA;    sync_count =  0;&#xA;&#xA;    send_string(&quot;FINISHED SETUP&quot;);&#xA;    _delay_ms(1000);&#xA;&#xA;&#xA;    TCCR1A = 0;&#xA;    TCCR1B = (1&amp;lt;&amp;lt;ICNC1)|(1&amp;lt;&amp;lt;ICES1)|(1&amp;lt;&amp;lt;CS11);&#xA;    TIMSK = (1&amp;lt;&amp;lt;TICIE1);&#xA;    TCNT1 = 0;&#xA;    sei();&#xA;    while(1)&#xA;    {&#xA;&#xA;        if (write_tc_out==1)&#xA;        {&#xA;            write_tc_out = 0;&#xA;            send_string((char*)timeCode);&#xA;        }&#xA;    }&#xA;&#xA;}&#xA;&#xA;ISR(TIMER1_CAPT_vect)&#xA;{&#xA;&#xA;    //toggleCaptureEdge&#xA;    TCCR1B ^= _BV(ICES1);&#xA;    //Serial.println(&quot;Inter&quot;);&#xA;    bit_time = ICR1;&#xA;&#xA;    //resetTimer1&#xA;    TCNT1 = 0;&#xA;_delay_us(13);&#xA;&#xA;    if ((bit_time &amp;lt; one_time_min) || (bit_time &amp;gt; zero_time_max)) // get rid of anything way outside the norm&#xA;    {&#xA;        //Serial.println(bit_time, DEC);&#xA;        total_bits = 0;&#xA;    }&#xA;    else&#xA;    {&#xA;        if (ones_bit_count == 1) // only count the second ones pluse&#xA;        ones_bit_count = 0;&#xA;        else&#xA;        {&#xA;            if (bit_time &amp;gt; zero_time_min)&#xA;            {&#xA;                current_bit = 0;&#xA;                sync_count = 0;&#xA;            }&#xA;            else //if (bit_time &amp;lt; one_time_max)&#xA;            {&#xA;                ones_bit_count = 1;&#xA;                current_bit = 1;&#xA;                sync_count++;&#xA;                if (sync_count == 12) // part of the last two bytes of a timecode word&#xA;                {&#xA;                    sync_count = 0;&#xA;                    tc_sync = 1;&#xA;                    total_bits = end_sync_position;&#xA;                }&#xA;            }&#xA;&#xA;            if (total_bits &amp;lt;= end_data_position) // timecode runs least to most so we need&#xA;            {&#xA;                // to shift things around&#xA;                tc[0] = tc[0] &amp;gt;&amp;gt; 1;&#xA;&#xA;                for(int n=1;n&amp;lt;8;n++)&#xA;                {&#xA;                    if(tc[n] &amp;amp; 1)&#xA;                    tc[n-1] |= 0x80;&#xA;&#xA;                    tc[n] = tc[n] &amp;gt;&amp;gt; 1;&#xA;                }&#xA;&#xA;                if(current_bit == 1)&#xA;                tc[7] |= 0x80;&#xA;            }&#xA;            total_bits++;&#xA;        }&#xA;&#xA;        if (total_bits == end_smpte_position) // we have the 80th bit&#xA;        {&#xA;            total_bits = 0;&#xA;            if (tc_sync)&#xA;            {&#xA;                tc_sync = 0;&#xA;                valid_tc_word = 1;&#xA;            }&#xA;        }&#xA;&#xA;        if (valid_tc_word==1)&#xA;        {&#xA;&#xA;            valid_tc_word = 0;&#xA;&#xA;            timeCode[11]= '\0';&#xA;            timeCode[10] = (tc[0]&amp;amp;0x0F)+0x30;      // frames&#xA;            timeCode[9] = (tc[1]&amp;amp;0x03)+0x30;      // 10's of frames&#xA;            timeCode[8] =  '-';&#xA;            timeCode[7] = (tc[2]&amp;amp;0x0F)+0x30;      // seconds&#xA;            timeCode[6] = (tc[3]&amp;amp;0x07)+0x30;      // 10's of seconds&#xA;            timeCode[5] =  '-';&#xA;            timeCode[4] = (tc[4]&amp;amp;0x0F)+0x30;      // minutes&#xA;            timeCode[3] = (tc[5]&amp;amp;0x07)+0x30;      // 10's of minutes&#xA;            timeCode[2] = '-';&#xA;            timeCode[1] = (tc[6]&amp;amp;0x0F)+0x30;      // hours&#xA;            timeCode[0] = (tc[7]&amp;amp;0x03)+0x30;      // 10's of hours&#xA;&#xA;            drop_frame_flag = bit_is_set(tc[1], 2); &#xA;&#xA;            write_tc_out = 1;&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18851" LastActivityDate="2016-06-24T05:11:49.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25618" PostTypeId="2" ParentId="5231" CreationDate="2016-06-24T06:47:18.463" Score="1" Body="&lt;p&gt;use this method for dealing with voltage translation. Also we have IC's which does the level shifting. Works great with higher frequencies as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9TaXn.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9TaXn.jpg&quot; alt=&quot;Voltage Translation using nMos&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="9978" LastActivityDate="2016-06-24T06:47:18.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25619" PostTypeId="1" CreationDate="2016-06-24T07:36:40.610" Score="0" ViewCount="175" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mfLOP.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mfLOP.jpg&quot; alt=&quot;Circuit diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have acquired the arduino starter kit project book, and the explanations seem at times confusing and difficult to understand. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning the above circuit diagram, the book states (I am translating from French): &lt;em&gt;&quot;The resistor and the photoresistor are in series and together they divide up the voltage. The voltage at the point where they meet is proportional to the ratio of their resistances, according to Ohm's Law.&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;What does &quot;the voltage at the point where they meet&quot; mean? The voltage/ p.d. is always supposed to be across something, e.g. a certain component. This statement makes no sense to me at all. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The above misunderstanding leads on to me not understanding what the input pins A0-A2 actually receive. I understand that they receive a voltage, but don't know across what. Also, if the voltage inputs from these pins are used later on, are they digital? (these pins have an analogue-digital converter).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23321" LastEditorUserId="23321" LastEditDate="2016-06-24T07:42:46.047" LastActivityDate="2016-06-24T12:56:30.947" Title="How can I understand the circuit diagram for Arduino Starter Kit Project 4?" Tags="|arduino-uno|programming|pins|resistor|photoresistor|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25620" PostTypeId="2" ParentId="25619" CreationDate="2016-06-24T07:58:16.267" Score="0" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I think what it means is that A0 = (5V / (Photo Resistor + 10K)).  Since the Photo Resistor will vary the voltage you get at A0 will be proportional to the light.  So by rearranging the formula above (I'm no good at doing that so you are on your own) you can convert the number received by A0 into the resistance that the photo resistor as applying and presumably turn that into Lux (?).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The analog pins report a number between 0 and 1023.  I can never remember if this equates to receiving a voltage of 0 - 5V or 0 - 2.5v.  Either way it is a linear conversion, so you can use (5V/1024)*reading to work out what the voltage at the pin is (or (2.5C/1024)*Reading).  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-06-24T07:58:16.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25621" PostTypeId="1" CreationDate="2016-06-24T08:55:38.023" Score="-1" ViewCount="724" Body="&lt;p&gt;I'm busy making a project where my accelerometer @arduino can controle a ellipse @processing&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the problem is, it doesn't work. With the code I have now, I can receive the data from the accelerometer in processing. But my map function doesn't seem to work because with my code, the ellipse doesn't move at all. When i want to map the val (string) it says it must be a float to be mapped. I've tried to convert the string into a float but it doesn't work at all..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope someone can help me out!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My arduino Code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MMA8451.h&amp;gt;&#xA;#include &amp;lt;Adafruit_Sensor.h&amp;gt;&#xA;&#xA;int waardeX;&#xA;int waardeY;&#xA;&#xA;Adafruit_MMA8451 mma = Adafruit_MMA8451();            //maak object acceleromter aan&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);                                 //begin Seriële verbinding&#xA;  Serial.println(&quot;Adafruit MMA8451 test!&quot;);           //print waardes accelerometer&#xA;&#xA;  if (! mma.begin()) {                                //mma.begin() om de sensor te herkennen.&#xA;    Serial.println(&quot;Couldnt start&quot;);                  //&quot;MMA8451 found!&quot; bij goed signaal, &quot;Couldnt start&quot; bij slecht signaal&#xA;    while (1);&#xA;  }&#xA;  Serial.println(&quot;MMA8451 found!&quot;);&#xA;&#xA;  mma.setRange(MMA8451_RANGE_2_G);                    //lees range van 2_G (voor relatief slome bewegingen)&#xA;&#xA;  Serial.print(&quot;Range = &quot;); Serial.print(2 &amp;lt;&amp;lt; mma.getRange());&#xA;  Serial.println(&quot;G&quot;);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // Read the 'raw' data in 14-bit counts&#xA;  mma.read();                                         //lees rauwe data accelerometer uit&#xA;  Serial.print(&quot;X:\t&quot;); Serial.print(mma.x);          //lees x waardes&#xA;  Serial.print(&quot;\tY:\t&quot;); Serial.print(mma.y);        // lees y waardes&#xA;  Serial.println();                                   //print de waardes met een delay van 500ms&#xA;  delay(500);&#xA;&#xA;  /* Get a new sensor event */&#xA;  sensors_event_t event;&#xA;&#xA;  Serial.write(waardeX);&#xA;  Serial.write(waardeY);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Processing code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;&#xA;Serial myPort;                                   //Maak Serial object aan&#xA;String waardeX;                                      //Ontvangen data van serial poort.&#xA;&#xA;//int waardeX;&#xA;int waardeX1;&#xA;int waardeY2;&#xA;int waardeY;&#xA;&#xA;void setup() {&#xA;  printArray(Serial.list());&#xA;  String portName = Serial.list()[0];            //0 is mijn Arduino poort. &#xA;  myPort = new Serial(this, portName, 9600);     //open de poort. Zelfde als serial.begin(9600) bij arduino zodat arduino en processing hetzelfde communiceren.&#xA;&#xA;  size(500, 500);                                //Grootte van het scherm&#xA;}&#xA;&#xA;void draw() {&#xA;  background(255);                               //Achtergrondkleur&#xA;  ellipse(waardeX1, waardeY, 20, 20);               //20,20 is grootte/breedte cirkel&#xA;  fill(200, 10, 100);                                       //maak het bolletje zwart&#xA;&#xA;  waardeX1 = (int)map(waardeX, 4000, -4000, 0, 500);        //waardeX mappen naar waa&#xA;//  waardeY = (int)map(waardeY2, -4000, 4000, 0, 500);&#xA;&#xA;  {&#xA;    if ( myPort.available() &amp;gt; 0) &#xA;    {  // Als de data beschikbaar is:&#xA;      val = myPort.readStringUntil('\n');         //Lees het en zet het in val&#xA;    } &#xA;        println(waardeX); //print it out in the console&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23322" LastEditorDisplayName="user31481" LastEditDate="2017-11-18T06:19:26.497" LastActivityDate="2017-11-18T06:19:26.497" Title="How to properly receive data from accelerometer @ arduino in processing and map it?" Tags="|arduino-uno|accelerometer|code-review|signal-processing|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25622" PostTypeId="2" ParentId="25595" CreationDate="2016-06-24T09:28:11.393" Score="5" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;As far as I know, there is no library for Uno to generate such a&#xA;  signal (correct me if I'm wrong)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You are wrong, there is &lt;a href=&quot;http://sensorium.github.io/Mozzi/&quot; rel=&quot;noreferrer&quot;&gt;Mozzi&lt;/a&gt;, the sound synthesis library for&#xA;Arduino. It works essentially along the lines sketched by uint128_t.&#xA;Take a look at the &lt;a href=&quot;https://github.com/sensorium/Mozzi/blob/master/examples/01.Basics/Sinewave/Sinewave.ino&quot; rel=&quot;noreferrer&quot;&gt;Sinewave.ino&lt;/a&gt; for an example on how to make a&#xA;(lookup table-based) sine wave. It can also do much more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In its default mode, Mozzi works with a 16,384&amp;nbsp;Hz sample rate and a&#xA;32,768&amp;nbsp;Hz (not audible) PWM frequency.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-24T09:28:11.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25623" PostTypeId="2" ParentId="25609" CreationDate="2016-06-24T12:54:55.603" Score="13" Body="&lt;p&gt;You can configure Timer 1 to cycle at 25 kHz in phase correct PWM mode, and use it's two outputs on pins 9 and 10 like so:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// PWM output @ 25 kHz, only on pins 9 and 10.&#xA;// Output value should be between 0 and 320, inclusive.&#xA;void analogWrite25k(int pin, int value)&#xA;{&#xA;    switch (pin) {&#xA;        case 9:&#xA;            OCR1A = value;&#xA;            break;&#xA;        case 10:&#xA;            OCR1B = value;&#xA;            break;&#xA;        default:&#xA;            // no other pin will work&#xA;            break;&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    // Configure Timer 1 for PWM @ 25 kHz.&#xA;    TCCR1A = 0;           // undo the configuration done by...&#xA;    TCCR1B = 0;           // ...the Arduino core library&#xA;    TCNT1  = 0;           // reset timer&#xA;    TCCR1A = _BV(COM1A1)  // non-inverted PWM on ch. A&#xA;           | _BV(COM1B1)  // same on ch; B&#xA;           | _BV(WGM11);  // mode 10: ph. correct PWM, TOP = ICR1&#xA;    TCCR1B = _BV(WGM13)   // ditto&#xA;           | _BV(CS10);   // prescaler = 1&#xA;    ICR1   = 320;         // TOP = 320&#xA;&#xA;    // Set the PWM pins as output.&#xA;    pinMode( 9, OUTPUT);&#xA;    pinMode(10, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Just an example:&#xA;    analogWrite25k( 9, 110);&#xA;    analogWrite25k(10, 210);&#xA;    for (;;) ;  // infinite loop&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Writing a value of 0 with &lt;code&gt;analogWrite25k()&lt;/code&gt; means the pin will be&#xA;always LOW, whereas 320 means always HIGH. The regular &lt;code&gt;analogWrite()&lt;/code&gt;&#xA;should &lt;em&gt;almost&lt;/em&gt; work, but it will interpret 255 the same as 320 (i.e.&#xA;always HIGH).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code assumes an Arduino Uno or similar board (ATmega168 or 328 @&#xA;16&amp;nbsp;MHz). The method used here requires a 16-bit timer, and thus it&#xA;uses Timer 1 as it's the only one available on the Uno; that's why only&#xA;two outputs are available. The method could be adapted to other&#xA;AVR-based boards with a 16-bit timer. As Gerben noted, that timer should&#xA;have a corresponding ICRx register. There are 4 such timers on the&#xA;Arduino Mega, each with 3 outputs.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-24T13:17:44.453" LastActivityDate="2016-06-24T13:17:44.453" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="25624" PostTypeId="2" ParentId="25619" CreationDate="2016-06-24T12:55:23.397" Score="0" Body="&lt;p&gt;The analog inputs of the arduino can't read resistances. They read voltages and compare them with a reference voltage. They give you a number between 0 and 1023 so the read voltage is 1/1024 of the reference voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The configuration of the LDR and the resistor is called a voltage divider. It is needed to get a voltage that the analog pin can read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The intersection of the LDR and the resistor is where you can measure that voltage (or connect it to the analog pin of the arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More info about this subject was already given in this question: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/7921/why-do-you-need-a-second-resistor-when-using-a-photoresistor-ldr&quot;&gt;Why do you need a second resistor when using a photoresistor/LDR?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiki page about voltage dividers and the relevant formulas&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://en.wikipedia.org/wiki/Voltage_divider&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23002" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-06-24T12:55:23.397" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25625" PostTypeId="2" ParentId="25619" CreationDate="2016-06-24T12:56:30.947" Score="2" Body="&lt;p&gt;The important thing to remember, which will help you understand everything else, is that &lt;em&gt;voltage is measured &lt;strong&gt;with respect to another point&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this (and almost every) case it is measured &lt;em&gt;with respect to&lt;/em&gt; ground. So when you say the voltage at point X is Y volts you are actually saying that the difference in voltage between point X and GND is Y volts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So on your schematic A0 measures the difference in voltage between it's IO pin (the junction between the 10KΩ resistor and the LDR) and ground. And looking at it, what is between its IO pin and ground? The 10KΩ resistor. So it is actually the voltage across that resistor that you are measuring.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Doing the sums:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume there is enough light falling on the LDR to make it have a resistance of 5KΩ.  Current flows through both the LDR and the 10KΩ resistor in series, so it has a total resistance of (10,000 + 5,000) 15KΩ. With 5V across the whole lot (5V -&gt; LDR -&gt; 10KΩ -&gt; GND) you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I = V/R = 5/15,000 = 0.000333... or 333µA.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;333µA flowing through 10KΩ drops how much voltage?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V=RI = 10,000 × 0.000333... = 3.333...V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So A0 would be measuring 3.333V at that point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, you turn out the lights, and the resistance of the LDR rises to, say, 50KΩ. What happens to those sums now?  Well, let's look:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Total resistance = 50,000 + 10,000 = 60,000Ω&#xA;I=V/R = 5/60,000 = 0.00008333...&#xA;V=RI = 10,000 × 0.00008333... = 0.8333...V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The formulae can be simplified into just the ratio of the two resistances:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;           R2&#xA;Vout = --------- × Vin&#xA;        R1 + R2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that is, with the lights on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        10,000&#xA;Vout = --------- × 5 = 0.666... × 5 = 3.333...&#xA;        15,000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And with the lights on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        10,000&#xA;Vout = --------- × 5 = 0.1666... × 5 = 0.8333...&#xA;        60,000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From that measured voltage, of course, you can then calculate what the resistance of the LDR must have been at the time. Rearranged the formula looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      R2 × Vin&#xA;R1 = ---------- - R2&#xA;        Vout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Plug in the numbers for the voltage with the lights on:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      10,000 × 5              50,000&#xA;R1 = ------------ - 10,000 = -------- - 10,000 = 5,000Ω&#xA;       3.333...              3.333...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The kind of circuit is known as a &lt;em&gt;Voltage Divider&lt;/em&gt; or &lt;em&gt;Potential Divider&lt;/em&gt; and you can read more about them here: &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Voltage_divider&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-24T12:56:30.947" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25626" PostTypeId="2" ParentId="25593" CreationDate="2016-06-24T13:06:53.327" Score="15" Body="&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Bluetooth_protocols&quot; rel=&quot;noreferrer&quot;&gt;Bluetooth&lt;/a&gt; supports multiple protocols for multiple purposes.  There is low latency low quality monorail bi-directional communication with a little bit of bandwidth for control for Bluetooth phone calls.  This is called &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Hands-Free_Profile_.28HFP.29&quot; rel=&quot;noreferrer&quot;&gt;HFE Bluetooth protocol&lt;/a&gt;.  If you are interfacing a keyboard or a mouse you would use the &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Human_Interface_Device_Profile_.28HID.29&quot; rel=&quot;noreferrer&quot;&gt;Human Interface Device protocol or HID&lt;/a&gt;.  If you wanted to listen to music and control it's playback you would use the high latency high quality 2 audio sending channels (stereo) no return audio channel with a little bit of bandwidth for controlling playback called &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Advanced_Audio_Distribution_Profile_.28A2DP.29&quot; rel=&quot;noreferrer&quot;&gt;Advanced Audio Distribution Profile or A2DP&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this specific case we are only interested in controlling playback.  So we could use the HID Bluetooth protocol.  However, the native music players on the platform you are using (Android or iPhone) likely will not be listening to such a device.  In order for this to work you will probably have to write your own Android or iPhone music player.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other hand, it is likely the native music players will work with A2DP Bluetooth protocol.  Unfortunately, it is also suspected that once the A2DP Bluetooth connection is established, the phone's speaker will be shutdown and all audio will be diverted to the Bluetooth connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there is the &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles#Audio.2FVideo_Remote_Control_Profile_.28AVRCP.29&quot; rel=&quot;noreferrer&quot;&gt;Audio/Video Remote Control Profile or AVRCP&lt;/a&gt;.  This protocol is used to control media playback.  There are several versions of this protocol so what features are available for a given device / music-application may vary greatly.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-24T13:18:01.520" LastActivityDate="2016-06-24T13:18:01.520" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25627" PostTypeId="2" ParentId="25621" CreationDate="2016-06-24T15:13:53.270" Score="1" Body="&lt;p&gt;The problem you are facing is that you are sending the string:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;X:⇥23.87⇥Y:⇥11.34&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and trying to interpret that as a single number. It's just not going to happen. There's two numbers and two labels there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you are going to have to parse the string to get at the individual components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might want to look at the java &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)&quot; rel=&quot;nofollow&quot;&gt;String.split()&lt;/a&gt; function to convert the string into an array of 4 items, then you can use the second and fourth slices (slices 1 and 3 since it's zero-based) and convert them to floats.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-24T15:13:53.270" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25631" PostTypeId="1" CreationDate="2016-06-24T16:29:37.993" Score="1" ViewCount="2429" Body="&lt;p&gt;I am really short of interrupt pins on my Arduino because I have a project that already uses a lot of Arduino pins and to read DMP data from MPU6050 you always have to use an interrupt pin. I searched A LOT in the internet and many people says it's impossible to retrieve DMP data without interrupt pin. Some people also said the only way to do that would be if I could reverse engineer the MPU6050 code (which I don't know how to do).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But today, playing with MPU6050 I could finally get all of its DMP data without the interrupt pin, you just have to connect 4 pins (VCC, GND, SCL and SDA). Upload the code below to your Arduino and see that it works!&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;MPU6050_6Axis_MotionApps20.h&quot;&#xA;MPU6050 mpu;&#xA;uint16_t packetSize;&#xA;uint16_t fifoCount;&#xA;uint8_t fifoBuffer[64];&#xA;Quaternion q;&#xA;VectorFloat gravity;&#xA;float ypr[3];&#xA;&#xA;void setup() {&#xA;  Wire.begin();&#xA;  TWBR = 24;&#xA;  mpu.initialize();&#xA;  mpu.dmpInitialize();&#xA;  mpu.setXAccelOffset(-1343);&#xA;  mpu.setYAccelOffset(-1155);&#xA;  mpu.setZAccelOffset(1033);&#xA;  mpu.setXGyroOffset(19);&#xA;  mpu.setYGyroOffset(-27);&#xA;  mpu.setZGyroOffset(16);&#xA;  mpu.setDMPEnabled(true);&#xA;  packetSize = mpu.dmpGetFIFOPacketSize();&#xA;  fifoCount = mpu.getFIFOCount();&#xA;&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (fifoCount &amp;lt; packetSize) {&#xA;    fifoCount = mpu.getFIFOCount();&#xA;  }&#xA;&#xA;  if (fifoCount == 1024) {&#xA;    mpu.resetFIFO();&#xA;    Serial.println(F(&quot;FIFO overflow!&quot;));&#xA;  }&#xA;  else {&#xA;    if (fifoCount % packetSize != 0) {&#xA;      mpu.resetFIFO();&#xA;    }&#xA;    else {&#xA;      while (fifoCount &amp;gt;= packetSize) {&#xA;        mpu.getFIFOBytes(fifoBuffer, packetSize);&#xA;        fifoCount -= packetSize;&#xA;      }&#xA;&#xA;      mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;      mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;      mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;&#xA;      Serial.print(&quot;ypr\t&quot;);&#xA;      Serial.print(ypr[0] * 180 / PI);&#xA;      Serial.print(&quot;\t&quot;);&#xA;      Serial.print(ypr[1] * 180 / PI);&#xA;      Serial.print(&quot;\t&quot;);&#xA;      Serial.print(ypr[2] * 180 / PI);&#xA;      Serial.println();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There is only one problem: Intermittently the Arduino hangs in the &lt;code&gt;getFIFOBytes&lt;/code&gt; function for no reason. I am pretty sure it's a bug because when you call too many times &lt;code&gt;getFIFOBytes&lt;/code&gt; for some reason the Arduino freezes.&lt;/p&gt;&#xA;" OwnerUserId="4924" LastEditorUserId="26916" LastEditDate="2017-11-04T17:22:30.517" LastActivityDate="2018-12-04T13:42:09.843" Title="MPU6050 hanging/freezing" Tags="|mpu6050|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25634" PostTypeId="1" AcceptedAnswerId="25635" CreationDate="2016-06-24T19:09:05.703" Score="0" ViewCount="44" Body="&lt;p&gt;I've built a very simple WiFi thermometer out of an &lt;a href=&quot;https://www.adafruit.com/product/2471&quot; rel=&quot;nofollow&quot;&gt;Adafruit ESP8266 HUZZAH breakout board&lt;/a&gt; and a &lt;a href=&quot;https://www.adafruit.com/products/165&quot; rel=&quot;nofollow&quot;&gt;TMP36 temperature sensor&lt;/a&gt;. I have it reporting the temperature over wifi to my computer which will be storing the data in a database for monitoring purposes. I'd like to make multiple of these devices and place them around the house. My question: I currently have the location of the board as a &lt;code&gt;const char*&lt;/code&gt; on the board itself. Doing this for multiple devices is just a bad idea and a nightmare to manage. Is there some way of setting a location variable on the board that will persist across shutdowns? Or am I coming at the problem from completely the wrong direction?&lt;/p&gt;&#xA;" OwnerUserId="23336" LastActivityDate="2016-06-24T19:27:00.947" Title="WiFi thermometers: save different location string as const across many devices" Tags="|esp8266|adafruit|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25635" PostTypeId="2" ParentId="25634" CreationDate="2016-06-24T19:27:00.947" Score="1" Body="&lt;p&gt;With a set of DIP switches or jumpers on some of the GPIO, you could encode a unique number for each one - 16 of them with 4 I/Os f/ex. The same code could run on all of them, sample the unique ID  report it along with the temperature. Let the PC-side map IDs to locations.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-24T19:27:00.947" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25636" PostTypeId="2" ParentId="25609" CreationDate="2016-06-24T20:29:19.337" Score="14" Body="&lt;p&gt;I am posting this second answer since I realized it is possible to have&#xA;4 PWM channels at 25 kHz with 161 steps on a single Arduino Uno. This&#xA;involves &lt;a href=&quot;https://arduino.stackexchange.com/questions/25591&quot;&gt;changing the main clock frequency to 8&amp;nbsp;MHz&lt;/a&gt;, which&#xA;has some side effects since the whole program will run half as fast. It&#xA;also involves reconfiguring the three timers, which means loosing the&#xA;Arduino timing functions (&lt;code&gt;millis()&lt;/code&gt;, &lt;code&gt;micros()&lt;/code&gt;, &lt;code&gt;delay()&lt;/code&gt; and&#xA;&lt;code&gt;delayMicroseconds()&lt;/code&gt;). If these trade-offs are acceptable, here is how&#xA;it goes:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup()&#xA;{&#xA;    // Set the main system clock to 8 MHz.&#xA;    noInterrupts();&#xA;    CLKPR = _BV(CLKPCE);  // enable change of the clock prescaler&#xA;    CLKPR = _BV(CLKPS0);  // divide frequency by 2&#xA;    interrupts();&#xA;&#xA;    // Configure Timer 0 for phase correct PWM @ 25 kHz.&#xA;    TCCR0A = 0;           // undo the configuration done by...&#xA;    TCCR0B = 0;           // ...the Arduino core library&#xA;    TCNT0  = 0;           // reset timer&#xA;    TCCR0A = _BV(COM0B1)  // non-inverted PWM on ch. B&#xA;        | _BV(WGM00);  // mode 5: ph. correct PWM, TOP = OCR0A&#xA;    TCCR0B = _BV(WGM02)   // ditto&#xA;        | _BV(CS00);   // prescaler = 1&#xA;    OCR0A  = 160;         // TOP = 160&#xA;&#xA;    // Same for Timer 1.&#xA;    TCCR1A = 0;&#xA;    TCCR1B = 0;&#xA;    TCNT1  = 0;&#xA;    TCCR1A = _BV(COM1A1)  // non-inverted PWM on ch. A&#xA;        | _BV(COM1B1)  // same on ch. B&#xA;        | _BV(WGM11);  // mode 10: ph. correct PWM, TOP = ICR1&#xA;    TCCR1B = _BV(WGM13)   // ditto&#xA;        | _BV(CS10);   // prescaler = 1&#xA;    ICR1   = 160;&#xA;&#xA;    // Same for Timer 2.&#xA;    TCCR2A = 0;&#xA;    TCCR2B = 0;&#xA;    TCNT2  = 0;&#xA;    TCCR2A = _BV(COM2B1)  // non-inverted PWM on ch. B&#xA;        | _BV(WGM20);  // mode 5: ph. correct PWM, TOP = OCR2A&#xA;    TCCR2B = _BV(WGM22)   // ditto&#xA;        | _BV(CS20);   // prescaler = 1&#xA;    OCR2A  = 160;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    analogWrite( 3,   1);  // duty cycle = 1/160&#xA;    analogWrite( 5,  53);  // ~ 1/3&#xA;    analogWrite( 9, 107);  // ~ 2/3&#xA;    analogWrite(10, 159);  // 159/160&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unlike the &lt;a href=&quot;https://arduino.stackexchange.com/a/25623&quot;&gt;other answer&lt;/a&gt;, this does not need a modified version of&#xA;&lt;code&gt;analogWrite()&lt;/code&gt;: the standard one will work fine. Only care should be&#xA;taken that:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The value written should be between 0 (meaning always LOW) and 160&#xA;(always HIGH), inclusive.&lt;/li&gt;&#xA;&lt;li&gt;Only pins 3, 5, 9 and 10 are available. Attempting to &lt;code&gt;analogWrite()&lt;/code&gt;&#xA;to pins 6 or 11 will not only fail to deliver a PWM output, it will&#xA;also change the frequency on pin 5 or 3 respectively.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-06-24T20:29:19.337" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25639" PostTypeId="1" CreationDate="2016-06-25T01:01:39.633" Score="0" ViewCount="46" Body="&lt;p&gt;I'm hacking together a RF-controlled garage door opener. I'm tapping the &quot;receiving&quot; end in to the push button wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the two wires touch, it toggles the garage door motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to basically &quot;close&quot; this circuit through a 5V Trinket Pro with...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pinMode(A0,OUTPUT);&lt;/code&gt; in &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;digitalWrite(A0,LOW);&lt;/code&gt; in the &lt;code&gt;loop&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the multimeter, it would seem that the wires for the push button are normally closed (I think that's correct) as I get a 15v read on the multimeter when I check the current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I touch the wires, the current drops to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My understanding was that the &lt;code&gt;digitalWrite(A0,LOW);&lt;/code&gt; would basically &quot;complete&quot; the circuit, but it doesn't seem to do anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my question is: Given I've only got 5v running through the Trinket Pro, is that not enough to toggle the garage door circuit given it's putting out  15v in it's NC state?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's the case, is there some other way around that without needing to push 15v of power?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-06-25T12:51:32.367" Title="Do I need more voltage to close this circuit?" Tags="|power|voltage-level|adafruit|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25640" PostTypeId="2" ParentId="25639" CreationDate="2016-06-25T01:19:53.840" Score="2" Body="&lt;p&gt;The Trinket really doesn't want to see 15v across one of its I/O pins. You'll do better using a solid-state (SSR) or mechanical relay to close the 15v motor-start circuit, one that can be activated by the 5v output of the Arduino pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;br&gt;&#xA;A relay has 4 specs that you need to consider up front:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The coil (or switching input of a SSR) voltage, and&lt;/li&gt;&#xA;&lt;li&gt;The coil (or switching input) current;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;These are what the Arduino or an add-on switching circuit will have to drive. And:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The contact max voltage, to limit arcing when they open&lt;/li&gt;&#xA;&lt;li&gt;the contact max current, to limit them heating,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Or, in the case of an SSR, to prevent letting out the Magic Smoke that makes them work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a relay you'll need a driver circuit between the Arduino pin and the relay, with a snubber - a diode that grounds the reverse voltage &quot;kickback&quot; from the relay coil when you open its circuit - also to protect the Magic Smoke in your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're hacking into your remote &quot;clicker&quot;, not the garage-door tractor itself, right? If that's the case, just about anything with a 5v coil 15v+ contacts will do. The remote button only has to switch a tiny transmitter on/off. If you do need to hack into the tractor, you'll want to find out what's behind its receiver terminal. It's probably not the motor but another relay, but.... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A ready source of such a relay is your/another garage door remote receiver. It has a relay in it that is already doing that job.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-06-25T12:51:32.367" LastActivityDate="2016-06-25T12:51:32.367" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25641" PostTypeId="1" AcceptedAnswerId="25675" CreationDate="2016-06-25T01:49:20.130" Score="1" ViewCount="1286" Body="&lt;p&gt;My hookup is like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;GND - GND  VCC - 5V  CS - 5V  SDO - GND  SDA - A4  SCL - A5&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;ADXL345.h&amp;gt;&#xA;&#xA;ADXL345 accelerometer;&#xA;&#xA;void setup(void) &#xA;{&#xA;  Serial.begin(9600);&#xA;&#xA;  // Initialize ADXL345&#xA;  Serial.println(&quot;Initialize ADXL345&quot;);&#xA;&#xA;  if (!accelerometer.begin())&#xA;  {&#xA;    Serial.println(&quot;Could not find a valid ADXL345 sensor, check wiring!&quot;);&#xA;    delay(500);&#xA;  }&#xA;  if (accelerometer.begin())&#xA;  {&#xA;&#xA;  // Values for Free Fall detection&#xA;  accelerometer.setFreeFallThreshold(0.35); // Recommended 0.3 - 0.6 g&#xA;  accelerometer.setFreeFallDuration(0.1);  // Recommended 0.1 s&#xA;&#xA;  // Select INT 1 for get activities&#xA;  accelerometer.useInterrupt(ADXL345_INT1);&#xA;&#xA;  // Check settings&#xA;  checkSetup();&#xA;  }&#xA;}&#xA;&#xA;void checkSetup()&#xA;{&#xA;  Serial.print(&quot;Free Fall Threshold = &quot;); Serial.println(accelerometer.getFreeFallThreshold());&#xA;  Serial.print(&quot;Free Fall Duration = &quot;); Serial.println(accelerometer.getFreeFallDuration());&#xA;}&#xA;&#xA;void loop(void) &#xA;{&#xA;  delay(50);&#xA;&#xA;  // Read values for activities&#xA;  Vector norm = accelerometer.readNormalize();&#xA;&#xA;  // Read activities&#xA;  Activites activ = accelerometer.readActivites();&#xA;&#xA;  if (activ.isFreeFall)&#xA;  {&#xA;    Serial.println(&quot;Free Fall Detected!&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It comes from this Github link: &lt;a href=&quot;https://github.com/jarzebski/Arduino-ADXL345/blob/master/ADXL345_free_fall/ADXL345_free_fall.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jarzebski/Arduino-ADXL345/blob/master/ADXL345_free_fall/ADXL345_free_fall.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initially, it would return &quot;Could not find a valid ADXL345 sensor, check wiring!&quot; in serial monitor. After messing with some wiring and changing to SPI&#xA;and back to I2C, it only returns &quot;Initialize ADXL345&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've added the second if() statement because it wouldn't say anything other than &quot;Initialize ADXL345&quot; even with the first if() statement, or with the first if() followed by an else. It should print the Free Fall Threshold and Duration but it hasn't. I have to leave and won't be back until tomorrow, so when I get back I'll try removing the checkSetup() command and maybe put something else in it's place to verify it's working. I feel like the answer is staring me in the face.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Okay so after I finally got up from my computer for once, a thought popped into my mind and I figured the reason why checkSetup() isn't returning either string is because it's declared after setup() calls checkSetup()? Am I right? I feel like this would be the case in other languages.&lt;/p&gt;&#xA;" OwnerUserId="23339" LastEditorUserId="23339" LastEditDate="2016-06-25T02:15:53.910" LastActivityDate="2016-06-25T23:09:01.680" Title="ADXL345 I2C setup not returning anything" Tags="|i2c|accelerometer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25642" PostTypeId="2" ParentId="24988" CreationDate="2016-06-25T03:25:49.723" Score="0" Body="&lt;p&gt;I found that this does work with the Nano - the only reason they don't list it is because it doesn't fit in to the shield I suppose.&lt;/p&gt;&#xA;" OwnerUserId="10780" LastActivityDate="2016-06-25T03:25:49.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25648" PostTypeId="1" CreationDate="2016-06-25T07:54:53.543" Score="2" ViewCount="520" Body="&lt;p&gt;I saw the one of your Answer that dated the 13th May 2015, i want to cross- correlate the vibration signal (with Predefined Signal) to remove the unwanted signals.But i want to do that real time so can we use the Arduino or have to use the Another platform. please advise .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kaveendra Sampath  &lt;/p&gt;&#xA;" OwnerUserId="23348" LastActivityDate="2016-06-25T07:54:53.543" Title="Real time Cross Correlation...?" Tags="|signal-processing|" AnswerCount="0" CommentCount="4" ClosedDate="2016-06-26T01:47:56.843" ContentLicense="CC BY-SA 3.0" />
  <row Id="25649" PostTypeId="2" ParentId="25499" CreationDate="2016-06-25T08:47:57.223" Score="0" Body="&lt;p&gt;I'm not exactly sure what you're trying to achieve with your code but from what i understood is that you're taking distance measurements to see if an object is front of your sensor and then you want to measure the time interval between each object passing by ....right? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming my understanding is correct, what you need to do is first measure the distance to know if an object is there or not, and then if there isnt an object you start a 'timer' until an object appears and then print thy data to Serial Monitor....&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//this is a comment...they make code easier to use and understand for you and others .....&#xA;int IRpin = 0;&#xA;float volts, distance,firstdata;&#xA;//don't Know why you need those...&#xA;/*int k = 0;&#xA;float min;&#xA;float mang[150];&#xA;int m;*/&#xA;boolean Exists;&#xA;boolean measured;&#xA;&#xA;int startTime;&#xA;int Interval;&#xA;void setup() {&#xA;Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;volts = analogRead(IRpin) * 0.0048828125;&#xA;distance = 13 * pow(volts, -1.10);&#xA;if (distance &amp;lt; 20) //an object is in front of the sensor&#xA;{&#xA;Serial.println(distance);&#xA;Exists = true;//object is present&#xA;}&#xA;else&#xA;{&#xA;Exists = false; object isn't present&#xA;}&#xA;&#xA;    if (Exists == false) {// no object present&#xA;&#xA;&#xA;if(measured == false){//to see if the timer already began&#xA;    startTime = millis();&#xA;    measured = true;// so the code only runs once&#xA;    Read = true; //so that we only measure the time when the timer begins&#xA;    }}&#xA;else &#xA;{ if(Read == true){&#xA;Interval = millis() - startTime;&#xA;measured = false;&#xA;&#xA;Read = false;&#xA;&#xA;Serial.print(Interval);&#xA;}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to do in the last snippet is to make sure that we only measure the time when nothing is present.&lt;/p&gt;&#xA;" OwnerUserId="11982" LastActivityDate="2016-06-25T08:47:57.223" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25650" PostTypeId="2" ParentId="22304" CreationDate="2016-06-25T10:03:27.967" Score="0" Body="&lt;p&gt;Check for Baudrate, the Arduino Serial Terminal, and serial port terminal should exactly match.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or either check your Rx and Tx pins for respective voltages&#xA;Either there may be problem related to power supply.&#xA;It is better you also mention the code&lt;/p&gt;&#xA;" OwnerUserId="20757" LastActivityDate="2016-06-25T10:03:27.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25654" PostTypeId="1" CreationDate="2016-06-25T15:01:11.893" Score="2" ViewCount="1972" Body="&lt;p&gt;I have built an automated window blind controller that will adjust the angle of a servo based on the value received via a light dependent resistor.  Once every 10 minutes the MCU wakes up, gets the current value of the LDR, adjusts the angle of the servo accordingly and then goes back to SLEEP_MODE_PWR_DOWN using the watchdog timer.  I am using a 5v 16MHz ATMega168 Arduino Pro Mini as the MCU.  I have removed both of the on board LEDs to reduce idle power consumption.  I am also powering directly from the VCC pin so that I bypass the on board regulator reducing power consumption even more.  I'm trying to determine what is the best battery power option for this project.  The project is still in testing but appears to be working as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/wdt.h&amp;gt;&#xA;#include &amp;lt;VarSpeedServo.h&amp;gt;&#xA;&#xA;const int ldrPin = A0;          //Analog pin that the light dependent resistor is connected to&#xA;const int ldrPower = 8;         //Supply 5v to ldr just before reading and then shutoff after&#xA;const int servoPin = 9;         //Digital pin that the Clone Futaba S3003 servo is connected to&#xA;&#xA;&#xA;//PARAMETERS FOR LOW BATTERY WARNING&#xA;const int xVPin = A1;             //Analog pin that the external +V non-boosted power supply is connected to&#xA;const int lowVLED = 10;           //Digital pin LED is connected to.  Used to identify battery levels&#xA;const int flashDelay = 250;       //LED flash length for low battery warning&#xA;const int numFlash_Low = 3;       //Number of LED flashes for LOW battery warning&#xA;const int numFlash_Mid = 1;       //Number of LED flashes for MID battery warning&#xA;int runningTotalVoltage;          //Variable that stores the sum total of the voltage readings&#xA;float voltage = 0.00;             //Calculate voltage&#xA;unsigned sampleCount = 0;         //Variable that stores the current voltage sampling number&#xA;unsigned char LEDFlashCount = 0;  //Variable that stores the current LED flash number&#xA;const int voltageSamples = 20;    //Total number of voltage readings to take&#xA;float boostVoltage = 5.27;        //Variable for the output voltage from the 5v boost coverter&#xA;float minValert = 3.20;           //Variable for the very low battery level (for 3.7v Li-on battery)&#xA;float midValert = 3.60;           //Variable for early warning low battery level (for 3.7v Li-on battery)&#xA;&#xA;//PARAMETERS FOR THE SERVO&#xA;VarSpeedServo myservo;        //Create servo object to control servo&#xA;const int angle1 = 2350;      //Variable for &quot;Fully Closed&quot; servo moving counter-clockwise rotation&#xA;const int angle2 = 1900;      //Variable for &quot;Partially Open&quot; servo moving conter-clockwise rotation&#xA;const int angle3 = 1468;      //Variable for &quot;Fully Open&quot; servo moving counter-clockwise rotation&#xA;int dest = 0;                 //Servo destination depending on sensor reading&#xA;const int spd = 15;           //Controls the speed of the servo moving between positions; 5 is slow&#xA;int prevPos = 0;              //Keep track of the angle two loops prior&#xA;int currPos = 0;              //Keep track of the angle one loop prior&#xA;int nextPos = 0;              //Keep track of the angle moving to during current loop&#xA;&#xA;//PARAMETERS FOR THE VARIOUS LIGHT LEVELS THAT TRIGGER THE SERVO TO ROTATE&#xA;int lightLevel;               //The analog reading from the LDR&#xA;const int lowLight = 400;&#xA;const int midLight = 800;&#xA;&#xA;int ATimer;&#xA;int BatTimer;&#xA;int SleepTime = 80;  //80 = 10 Min&#xA;int BatCheckTime = 8;  //8 = 1 Min&#xA;&#xA;//WATCHDOG INTERRUPT&#xA;ISR (WDT_vect)&#xA;{&#xA;  wdt_disable();&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  //Serial.begin(9600);&#xA;  myservo.attach(servoPin);&#xA;  myservo.write(angle3, spd, true);&#xA;  pinMode(lowVLED, OUTPUT);&#xA;  pinMode(ldrPower, OUTPUT);&#xA;  doFirstRun();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  BatteryCheckTimer();&#xA;  AwakeTimer();&#xA;  if (BatTimer == BatCheckTime)&#xA;  {&#xA;    doBattCheck();&#xA;  }&#xA;&#xA;  if (ATimer == SleepTime)&#xA;  {&#xA;    doWhileAwake();&#xA;  } //End of Main loop if timer was reached&#xA;&#xA;//Preparing to go to sleep&#xA;&#xA;  byte old_ADCSRA = ADCSRA;                        // disable ADC //&#xA;  ADCSRA = 0;                                      // disable ADC //&#xA;&#xA;  byte old_PRR = PRR;                              // disable Internal modules//&#xA;  PRR = 0xFF;                                      // disable Internal modules//&#xA;&#xA;  MCUSR = 0;                                       // clear various &quot;reset&quot; flags// &#xA;&#xA;  // Watchdog Timer Parameters//&#xA;  WDTCSR = bit (WDCE) | bit (WDE);                 // allow changes, disable reset&#xA;  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);   // set WDIE, and 8 seconds delay&#xA;  wdt_reset();                                     // pat the dog once program has executed.&#xA;&#xA;  // Sleep Activation //&#xA;  set_sleep_mode (SLEEP_MODE_PWR_DOWN);            //Sleep mode Selection//&#xA;  sleep_enable();                                  //Sleep Now//&#xA;&#xA;  sleep_cpu ();                                    //CPU is now sleeping&#xA;&#xA;// Once awake, code executes from this point. Once CPU wakes up do the follwoing to restore full operations&#xA;  sleep_disable();&#xA;  PRR = old_PRR;&#xA;  ADCSRA = old_ADCSRA;&#xA;}&#xA;&#xA;void BatteryCheckTimer()                  &#xA;{&#xA;  BatTimer++;&#xA;}&#xA;&#xA;void AwakeTimer()                  &#xA;{&#xA;  ATimer++;&#xA;}&#xA;&#xA;void doFirstRun()&#xA;{&#xA;  digitalWrite(ldrPower, HIGH);&#xA;  delay(flashDelay);&#xA;  lightLevel = analogRead(ldrPin);  //Query photo cell&#xA;  digitalWrite(ldrPower, LOW);&#xA;  //Define the ranges based on how bright it is, and set corresponding servo position&#xA;  if (lightLevel &amp;lt;= lowLight)&#xA;  { &#xA;    //Servo rotates to fully closed&#xA;    dest=angle1;      &#xA;    nextPos=angle1;&#xA;  }    &#xA;  else if (lightLevel &amp;gt; lowLight &amp;amp;&amp;amp; lightLevel &amp;lt;= midLight)&#xA;  {     &#xA;    //Servo rotates to partially open&#xA;    dest=angle2;      &#xA;    nextPos=angle2;&#xA;  }&#xA;  else if (lightLevel &amp;gt; midLight)&#xA;  {       &#xA;    //servo rotates to fully open&#xA;    dest=angle3;&#xA;    nextPos=angle3;&#xA;  }&#xA;  prevPos = nextPos;&#xA;  currPos = nextPos;&#xA;  myservo.attach(servoPin);         //Connect to servo&#xA;  myservo.write(dest, spd, true);   //Move the servo to the new position&#xA;  delay(flashDelay);&#xA;  myservo.detach();                 //Detach servo to keep it from humming on strain&#xA;  ATimer = 0;&#xA;  BatTimer = 0;&#xA;}&#xA;&#xA;void doBattCheck()&#xA;{&#xA;  while (sampleCount &amp;lt; voltageSamples)&#xA;  {&#xA;    runningTotalVoltage += analogRead(xVPin);&#xA;    sampleCount++;&#xA;    delay(10);&#xA;  }&#xA;  //The boostVoltage value is external power source dependent.  If using a 5v boost conveter&#xA;  //check the boost output voltage and then enter that number in the boostVoltage variable.&#xA;  voltage = ((runningTotalVoltage/voltageSamples) * (boostVoltage/1023));&#xA;  if (voltage &amp;gt;= minValert &amp;amp;&amp;amp; voltage &amp;lt;= midValert)&#xA;  {&#xA;    while (LEDFlashCount &amp;lt; numFlash_Mid)&#xA;    {&#xA;      digitalWrite(lowVLED, HIGH);&#xA;      delay(flashDelay);&#xA;      digitalWrite(lowVLED, LOW);&#xA;      LEDFlashCount++;&#xA;      delay(flashDelay);&#xA;    }&#xA;  }&#xA;  else if (voltage &amp;lt; minValert)&#xA;  {&#xA;    while (LEDFlashCount &amp;lt; numFlash_Low)&#xA;    {&#xA;      digitalWrite(lowVLED, HIGH);&#xA;      delay(flashDelay);&#xA;      digitalWrite(lowVLED, LOW);&#xA;      LEDFlashCount++;&#xA;      delay(flashDelay);&#xA;    }&#xA;  }&#xA;  sampleCount = 0;&#xA;  runningTotalVoltage = 0;&#xA;  LEDFlashCount = 0;&#xA;  BatTimer = 0;&#xA;}&#xA;&#xA;void doWhileAwake()&#xA;{&#xA;  digitalWrite(ldrPower, HIGH);&#xA;  delay(flashDelay);&#xA;  lightLevel = analogRead(ldrPin);  //Query photo cell&#xA;  digitalWrite(ldrPower, LOW);&#xA;  //Define the ranges based on how bright it is, and set corresponding servo position&#xA;  if (lightLevel &amp;lt;= lowLight)&#xA;  { &#xA;    //Servo rotates to fully closed&#xA;    dest=angle1;      &#xA;    nextPos=angle1;&#xA;  }    &#xA;  else if (lightLevel &amp;gt; lowLight &amp;amp;&amp;amp; lightLevel &amp;lt;= midLight)&#xA;  {     &#xA;    //Servo rotates to partially open&#xA;    dest=angle2;      &#xA;    nextPos=angle2;&#xA;  }&#xA;  else if (lightLevel &amp;gt; midLight)&#xA;  {       &#xA;    //servo rotates to fully open&#xA;    dest=angle3;&#xA;    nextPos=angle3;&#xA;  } &#xA;  //IF the photocell reading is different from last sample then execute servo controls&#xA;  if (nextPos == prevPos &amp;amp;&amp;amp; nextPos != currPos)&#xA;  {&#xA;    prevPos = currPos;&#xA;    ATimer = 0;&#xA;  }&#xA;  else if (nextPos != prevPos &amp;amp;&amp;amp; nextPos != currPos)&#xA;  {&#xA;    prevPos = currPos;&#xA;    currPos = nextPos;  //Remember angle so we can compare it again next round&#xA;    pos_change();&#xA;  }&#xA;  else&#xA;  {&#xA;    prevPos = currPos;&#xA;    ATimer = 0;     &#xA;  }&#xA;}&#xA;&#xA;//This code moves the servo to the desired position&#xA;void pos_change()&#xA;{    &#xA;  myservo.attach(servoPin);         //Connect to servo&#xA;  myservo.write(dest, spd, true);   //Move the servo to the new position&#xA;  delay(flashDelay);&#xA;  myservo.detach();                 //Detach servo to keep it from humming on strain&#xA;  ATimer = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, I hooked up a multi-meter and set it to monitor current draw.  I watched it for 30 minutes and below are the results.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Constant current draw is 26.8 microamps.&lt;/li&gt;&#xA;&lt;li&gt;Every minute the sketch wakes up and quickly checks the battery voltage.  This process takes less than a seconds and the current draw increases to 38.8 microamps.&lt;/li&gt;&#xA;&lt;li&gt;Every ten minutes the sketch wakes up and checks the LDR sensor.  If the sensor reading is different from the last reading the servo moves to a new preset angle.  When this happens the current draw increases to about 11 milliamps.  I forced a servo rotation a couple of times during this time period so that I could measure the current draw.  However, during the course of a normal day, I would expect the servo to rotate no more than four times (when the sun is rising, when the sun is at its highest level, when the sun is setting, and finally when the sun has completely set).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;For the last 12 days I have been running the project from a single 18650 3.7v LiPo battery.  When I started the battery was at 4.12v.  Battery reading today is about 3.68v.  Seems to me that the project is draining the battery faster than it should be.  I drained the battery and then fully charged it before starting the test so I know the battery is good. I used an inline power bank capacity tester to measure the battery capacity during charge and when it was done it registered 2405 mah.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are the components of this project:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Arduino pro mini with on board LEDs and voltage regulator removed.&lt;/li&gt;&#xA;&lt;li&gt;LDR sensor with 10k resistor&lt;/li&gt;&#xA;&lt;li&gt;LED with 220K resistor for low battery warning&lt;/li&gt;&#xA;&lt;li&gt;5v boost converter with on board LEDs removed (used to boost the 3.7v LiPo battery to 5v; actually boosts to about 5.27v)&lt;/li&gt;&#xA;&lt;li&gt;Knock-off clone Futaba S3003 servo&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Ultimately I would like to be able to power this project from a couple of 18650 batteries for 3 months or maybe 3 AA batteries for the same period of time.  Based on my research and power consumption expectations, I should be able to do it.  If I can't get any better power consumption out of this little think, I might hookup a small solar panel with a LiPo battery charge controller to help extend the battery life.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts? Thanks.&lt;/p&gt;&#xA;" OwnerUserId="23355" LastActivityDate="2016-06-25T19:54:59.377" Title="Arduino Project Power Consumption Calculations" Tags="|power|servo|arduino-pro-mini|battery|sleep|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25655" PostTypeId="2" ParentId="25654" CreationDate="2016-06-25T15:16:43.427" Score="1" Body="&lt;p&gt;You should measure with a power meter the consumption of the arduino in the two conditions, active and standby. Remember that batteries last only for the 80% of their total capacity. If you can't achieve better results, you should build it with an attiny85.&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-06-25T15:16:43.427" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="25660" PostTypeId="2" ParentId="25654" CreationDate="2016-06-25T16:12:15.017" Score="1" Body="&lt;p&gt;If you look at the discharge curves of LiPo batteries, you can see the voltage will drop a bit faster when full. Then flatten out, and have a big voltage drop when they are almost empty. So I'm not sure you can tell from the 0.44V drop that the battery is being discharged faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a problem, I think it is either the boost converters quiescent current, or the servo. Also not that because you have to convert the 3.7V up to 5V, the current coming from the battery will have to increase by 1.35 times (at 100% efficiency).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What booster are you using? How do you turn off the servo?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS1;&#xA;I always use &lt;a href=&quot;http://oregonembedded.com/batterycalc.htm&quot; rel=&quot;nofollow&quot;&gt;this calculator&lt;/a&gt; to get an approximate battery life. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS2; I'd connect the pull-up resistor on the LDR to a digital pin, so you can activate it only when you need to measure the light level, saving 2-5 µA. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-25T16:12:15.017" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25662" PostTypeId="1" CreationDate="2016-06-25T16:57:28.303" Score="-1" ViewCount="5801" Body="&lt;p&gt;As you can see in the &lt;a href=&quot;https://www.youtube.com/watch?v=JDgDMBquBw0&quot; rel=&quot;nofollow&quot;&gt;video&lt;/a&gt;, it is possible to trigger a touch with arduino. I have tried a couple of methods but with no success.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have a wire soldered on to a coin which is being used to trigger&#xA;the touch.  &lt;/li&gt;&#xA;&lt;li&gt;I tried to directly connect pin 2 from arduino to the    coin (no&#xA;touch applies)  &lt;/li&gt;&#xA;&lt;li&gt;I tried to connect a relay and transistor,    seems    necessary for&#xA;this project but I didnt get it to work either.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I will say I have very little knowledge of relay/transistor and the wiring part of it, so Im guessing thats where the problem is.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My parts:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transistor P2N2222A:&#xA;&lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF&quot; rel=&quot;nofollow&quot;&gt;http://www.onsemi.com/pub_link/Collateral/P2N2222A-D.PDF&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Relay:&#xA;JZC-11F&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch used: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void setup() {&#xA;  digitalWrite(2,LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  pinMode(2, INPUT);&#xA;  delay(500);&#xA;&#xA;  pinMode(2, OUTPUT);&#xA;  delay(500);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If possible please provide a frizting schematic showing how to connect. &lt;/p&gt;&#xA;" OwnerUserId="22907" LastActivityDate="2018-12-24T19:31:09.323" Title="Triggering capacitive touch on a touch device" Tags="|arduino-uno|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25664" PostTypeId="1" CreationDate="2016-06-25T17:34:44.633" Score="0" ViewCount="83" Body="&lt;p&gt;I ran the following really simple code on my micro and the monitor is just blank, not displaying any zeroes or anything and the Tx light isn't lighting up. I haven't used analog inputs much so I don't know what could be causing this. Can anyone help? Thanks, here's the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensePin = 0;&#xA;void setup() {&#xA;    analogReference(DEFAULT);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(analogRead(sensePin));&#xA;  delay(500);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23361" LastEditorUserId="4143" LastEditDate="2016-06-25T17:48:37.370" LastActivityDate="2016-06-25T22:07:34.417" Title="Serial.println not outputting" Tags="|analogread|arduino-micro|genuine|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25665" PostTypeId="5" CreationDate="2016-06-25T17:54:59.760" Score="0" Body="&lt;p&gt;Genuine boards generally use higher quality components. The schematics and workings are well documented and well known.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is in contrast to a clone or counterfeit board which may use substandard components, change components that would normally be used for others, and generally cause a lot of problems (for instance the infamous CH340G USB chip)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By tagging your post as &lt;code&gt;genuine&lt;/code&gt; you are letting everyone know that your question is regarding a genuine Arduino or third party board, not a cheap clone or (worse) a counterfeit board.  This helps people to better help you without them having to question if the board is genuine or not.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-25T17:54:59.760" LastActivityDate="2016-06-25T17:54:59.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25666" PostTypeId="4" CreationDate="2016-06-25T17:54:59.760" Score="0" Body="A Genuine board is either a board made by Arduino themselves or it is a board specifically designed and built by a third party. Either way it is built using the components and in the way that the designer intended.&#xD;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-25T17:54:59.760" LastActivityDate="2016-06-25T17:54:59.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25667" PostTypeId="2" ParentId="25654" CreationDate="2016-06-25T17:58:53.397" Score="1" Body="&lt;p&gt;The constant draw of 26.8 μA amounts to 0.6432 mAh per day.  38.8 μA for one second per minute is an additional 0.0048 mAh per day, and a second of 11 mA draw six times per hour would be 0.44 mAh per day.  This totals to 1.088 mAh per day, or 13.056 mAh in 12 days.  That's less than 5% of the 2405 mAh mentioned as the LiPo's capacity.  Judging from the usual discharge voltage graphs, battery voltage should still be above 4 V at that point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the above is correct, you might have a defective battery, or defective current measurements.  You could charge the battery in question, then connect a 100KΩ–150KΩ resistor across it.  As the battery discharges, measure and record its voltage a couple of times a day.  If you charge up several batteries at the same time, you could set one aside as an experimental control, attach a resistor across one of them, and attach another to your circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 26.8 μA draw while in power-down sleep is higher than I'd expect [by a factor of 3 or so].  If it includes boost converter quiescent current, perhaps use a PFET to shut down the converter when the servo isn't needed.  I'm supposing the Arduino is powered directly from the battery, and that you have a boost converter to get servo power.  Will the servo work ok straight from the battery?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could power the Arduino straight from one LiPo, and power the converter and/or servo from another, to make it more likely the system will degrade safely as the batteries run down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[Edit:] Although your Pro Mini is a 5V version, since you are powering directly from the VCC pin you can run it at a lower voltage.  See §30.3 Speed Grades, in spec sheet, for the “Safe Operating Area”, ie, the guaranteed-to-work voltage-vs-MHz region.  From Figure 30-1, Maximum Frequency vs. V&lt;sub&gt;CC&lt;/sub&gt;, 3.78 V safely supports 16 MHz operation.  Running the Pro Mini at 16 MHz below that voltage is out of spec, but I'd expect it to work fine even at appreciably lower voltages.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Prescaling the system clock [see last paragraph, below] also reduces voltage requirements.  As the system clock scales down, current draw scales down more than linearly.  [End Edit]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When trying to reduce current draw in sleep mode, work with a sketch that just tries out various setups; that is, a sketch that doesn't read the LDR or control the servo.  A simple test sketch makes it easier to figure out what is going on.  You can try tests such as all irrelevant pins initialized to low outputs, or to pulled-up inputs, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like the code doesn't do any intensive processing.  The CPU needn't run at 16 MHz while executing delays.  Instead, you could prescale the system clock (ref. §10.10, System Clock Prescaler, in spec sheet) which will drop CPU current from a few milliamps to under a milliamp during delays.  You'd divide your delay counts by the scale factor, and might also change ADC clock scaling (ref. §25.4, Prescaling and Conversion Timing, in spec sheet).&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-06-25T19:54:59.377" LastActivityDate="2016-06-25T19:54:59.377" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25669" PostTypeId="1" AcceptedAnswerId="25672" CreationDate="2016-06-25T19:49:06.250" Score="0" ViewCount="829" Body="&lt;p&gt;I have just purchased a new Sharp GP2Y0A710K0F IR sensor online. As a sanity check, I wrote this simple code to check if the sensor is working correctly. The code is expected to print output voltage from the sensor, which is based on the distance&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorpin = A5;     &#xA;int val = 0;    &#xA;&#xA;void setup()&#xA;{&#xA;Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;val = analogRead(sensorpin);&#xA;Serial.println(val);   &#xA;delay(100); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the output is quite strange. The output values start from zero and keep on increasing until they reach 1023, and then gradually decrease down to zero and this keeps on happening, even if something is kept in front of the sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my sensor a faulty one? or is it supposed to give out similar outputs. If it has to, how do I convert these values to meter or centimeters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The product description on the manufacturer's website said that it has a 3 pin interface, however it has a 5 pin one, the wires being Red, Black, Yellow, White, Green if seen from the left side. I guessed from the &lt;a href=&quot;https://1drv.ms/b/s!AnWPsNx8qqvugs0YNoXsvMuq2orDBQ&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; that Red and Black are for power and Yellow for signal output and hence I have connected only these 3 wires. The Green and White wires are unconnected. Also, pin numbers aren't marked.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-06-25T20:39:52.927" LastActivityDate="2016-06-25T21:00:11.930" Title="Sharp GP2Y0A710K0F IR sensor behaving strangely" Tags="|arduino-uno|sensors|analogread|ir|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25670" PostTypeId="1" AcceptedAnswerId="25691" CreationDate="2016-06-25T19:50:10.410" Score="0" ViewCount="219" Body="&lt;p&gt;I have set up an LED who's brightness is controlled by a sonar sensor.  The sonar works well and I can see the values coming from it through the serial monitor.  The LED fades until about 700 using analogWrite&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;NewPing.h&amp;gt;&#xA;&#xA;#define TRIGGER_PIN  12&#xA;#define ECHO_PIN     11&#xA;#define MAX_DISTANCE 5000&#xA;&#xA;int LED_PIN = 3;&#xA;&#xA;&#xA;NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);&#xA;&#xA;void setup() {&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    delay(50);&#xA;    int uS = sonar.ping();&#xA;    long int max_uS = 8000;&#xA;    float brightness = (1-(((float)uS/(float)max_uS)))*1024;&#xA;    if(brightness &amp;lt; 0){&#xA;        brightness = 0;&#xA;    }&#xA;    Serial.print(&quot;Distance: &quot;);&#xA;    Serial.print(uS / US_ROUNDTRIP_IN);&#xA;    Serial.print(&quot;\&quot; &quot;);&#xA;    Serial.print(uS);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.println(brightness, 5);&#xA;&#xA;    analogWrite(LED_PIN, brightness);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I view the serial monitor, I've made it output a line that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Distance: 10&quot; 1500 830.00000&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;830 is the number I'm using for my &lt;code&gt;analogWrite&lt;/code&gt;.  I can move my hand farther and closer to the distance sensor and when I do, the light fades, but after 13&quot; (which is brightness = 774) the LED looks like it turns back on high.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Between 1&quot;-13&quot; it fades very smoothly, except at 13&quot; the light is almost out, then at about 14&quot; it turns on again almost at full brightness and is very hit or miss from there.  Even though the numbers in the serial monitor are holding steady.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any reason for this?  &lt;/p&gt;&#xA;" OwnerUserId="1316" LastActivityDate="2016-06-26T12:29:16.307" Title="RGB LED blinks when analogWrite is low" Tags="|rgb-led|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25672" PostTypeId="2" ParentId="25669" CreationDate="2016-06-25T21:00:11.930" Score="1" Body="&lt;p&gt;I suspect you have it wired wrongly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to consult the outline diagram in the datasheet and work out which colour wire is which function. It's this bit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CJo0R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CJo0R.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By your wiring description it sounds like you may be powering it through Vo and reading the result through VCC, which won't work - and at worst may damage it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-25T21:00:11.930" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25673" PostTypeId="2" ParentId="3269" CreationDate="2016-06-25T21:54:10.853" Score="1" Body="&lt;p&gt;Just wanted to re-iterate that On the MEGA 2560 Revision 3 you can't change the L led pin 13 due to the op-amp like Nick Reported. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Spent a couple hours on this scratching my head only to find this out&lt;/p&gt;&#xA;" OwnerUserId="23363" LastActivityDate="2016-06-25T21:54:10.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25674" PostTypeId="2" ParentId="25664" CreationDate="2016-06-25T22:07:34.417" Score="1" Body="&lt;p&gt;The answer to no ouput, and suspecting your data source is to replace the data source with a constant value or a string until you get that problem sorted, and then go back to your data source and debug that if necessary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, I don't see any issue with you trying to print the output of an analog read. Obviously you should get &lt;em&gt;something&lt;/em&gt;, even if it's just a single zero on each line, twice a second.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is your monitor the Arduino built-in monitor?&lt;/li&gt;&#xA;&lt;li&gt;Is it set to 9600 baud, as you've set your output rate in the program?&lt;/li&gt;&#xA;&lt;li&gt;Is there anything else connected to the Tx pin, Pin-1 (Arduino numbering, not chip numbering)?&lt;/li&gt;&#xA;&lt;li&gt;There were no error messages from the compiler or loader, right? (The libraries, bless-'em, always get a few warnings; unfortunately we have to ignore those).&lt;/li&gt;&#xA;&lt;li&gt;You've no reason to believe the Arduino is other than 100% good?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-06-25T22:07:34.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25675" PostTypeId="2" ParentId="25641" CreationDate="2016-06-25T23:09:01.680" Score="0" Body="&lt;p&gt;You may have damaged the chip with 5 V already. Sparkfun didn't include a regulator in their breakout. Your pull-ups are also too small; significant current flows when the I2C lines are pulled low. Use two 4.7k or 10k resistors instead. Assuming your Redboard is just like the Uno, connect pin 2 to the INT1 pin of the breakout, to make use of the interrupt capabilities. You also need to call &lt;code&gt;attachInterrupt()&lt;/code&gt; and register a handler. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you bought this module from Sparkfun, as well as your Redboard. You should first follow their &lt;a href=&quot;https://www.sparkfun.com/tutorials/240&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; and library before trying any others. Theirs is SPI-based though. If you must use I2C, try out the Adafruit library.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-06-25T23:09:01.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25676" PostTypeId="1" AcceptedAnswerId="25685" CreationDate="2016-06-25T23:15:14.963" Score="0" ViewCount="6967" Body="&lt;p&gt;I am not actually using ad arduino but an atmel chip. but my question is c microprocessor related&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am reading an uart which returns data in the form uint8_t [100]&#xA;I can print the  return just fine, the return is &quot;OK&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but when I try to use strcmp(read, &quot;OK&quot;)&#xA;I do not get the expected value, I get a mismatch ( strcmp returns 13, not 0)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t  sigfox_rd_buf[100] = {0};&#xA;uint8_t sig_rd = 0;&#xA;&#xA;io_sigfox-&amp;gt;read(io_sigfox,&amp;amp;sig_rd, 1);&#xA;while(sig_rd != 10) // read until end char&#xA; {&#xA;     sigfox_rd_buf[i] = sig_rd;&#xA;     i++;&#xA;     io_sigfox-&amp;gt;read(io_sigfox,&amp;amp;sig_rd, 1);&#xA; }&#xA; if(strcmp((char *)sigfox_rd_buf,&quot;OK&quot;) == 0 )&#xA; {&#xA;  do_something()&#xA; }&#xA; else&#xA;{&#xA;complain();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I always end up in complain for some reason.. please help!! :)&lt;/p&gt;&#xA;" OwnerUserId="23365" LastActivityDate="2016-06-26T17:49:47.613" Title="compare uint8_t to char array" Tags="|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25677" PostTypeId="1" AcceptedAnswerId="25689" CreationDate="2016-06-25T23:25:58.663" Score="2" ViewCount="389" Body="&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I've plugged 6 pins from my RC receiver into my Arduino in order to read the incoming values.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I'm using Digital PWM~ pins 2-6. Oddly the Arduino only reads odd channels:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;1480, 0, 1175, 0, 991, 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've that if I physically reverse the cables (2-7, 3-6, 4-5) going into the Arduino I get ALL values:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;988, 983, 1511, 1174, 1490, 1487&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I've found that if I go back to my initial pin setup and merely flip neighbors (2-3, 4-5, 6-7) that works as well.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;What could possibly be causing this?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Here is the current code I've written&#xA;&#xA;int ch1, ch2, ch3, ch4, ch5, ch6;&#xA;int ch1Pin = 2;&#xA;int ch2Pin = 3;&#xA;int ch3Pin = 4;&#xA;int ch4Pin = 5;&#xA;int ch5Pin = 6;&#xA;int ch6Pin = 7;&#xA;&#xA;void setup() {&#xA;  pinMode(ch1Pin, INPUT);&#xA;  pinMode(ch2Pin, INPUT);&#xA;  pinMode(ch3Pin, INPUT);&#xA;  pinMode(ch4Pin, INPUT);&#xA;  pinMode(ch5Pin, INPUT);&#xA;  pinMode(ch6Pin, INPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  ch1 = pulseIn(ch1Pin, HIGH, 25000);&#xA;  ch2 = pulseIn(ch2Pin, HIGH, 25000);&#xA;  ch3 = pulseIn(ch3Pin, HIGH, 25000);&#xA;  ch4 = pulseIn(ch4Pin, HIGH, 25000);&#xA;  ch5 = pulseIn(ch5Pin, HIGH, 25000);&#xA;  ch6 = pulseIn(ch6Pin, HIGH, 25000);&#xA;&#xA;  String p = (String)ch1;&#xA;  p += &amp;quot;, &amp;quot; + (String)ch2; &#xA;  p += &amp;quot;, &amp;quot; + (String)ch3; &#xA;  p += &amp;quot;, &amp;quot; + (String)ch4;&#xA;  p += &amp;quot;, &amp;quot; + (String)ch5;&#xA;  p += &amp;quot;, &amp;quot; + (String)ch6;&#xA;  Serial.println(p);&#xA;  &#xA;//  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Photo&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mYUMe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mYUMe.jpg&quot; alt=&quot;transmitter pwm pins to arduino digital input&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;EDIT&lt;/h1&gt;&#xA;&lt;p&gt;Since posting this question I've found that reversing the &lt;code&gt;chXpin&lt;/code&gt; values accomplishes the same effect as reversing the physical pins. This makes me thing it's a software issue so I'm digging in further.&lt;/p&gt;&#xA;&lt;h1&gt;TEMPORARY SOLUTION&lt;/h1&gt;&#xA;&lt;p&gt;I'm not sure why this works but flipping the neighbor order of &lt;code&gt;pulseIn&lt;/code&gt; fixed the issue:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  /* OLD&#xA;  ch1 = pulseIn(ch1Pin, HIGH, 25000);&#xA;  ch2 = pulseIn(ch2Pin, HIGH, 25000);&#xA;  ch3 = pulseIn(ch3Pin, HIGH, 25000);&#xA;  ch4 = pulseIn(ch4Pin, HIGH, 25000);&#xA;  ch5 = pulseIn(ch5Pin, HIGH, 25000);&#xA;  ch6 = pulseIn(ch6Pin, HIGH, 25000);&#xA;  */&#xA;&#xA;  ch2 = pulseIn(ch2Pin, HIGH, 25000);&#xA;  ch1 = pulseIn(ch1Pin, HIGH, 25000);&#xA;  ch4 = pulseIn(ch4Pin, HIGH, 25000);&#xA;  ch3 = pulseIn(ch3Pin, HIGH, 25000);&#xA;  ch6 = pulseIn(ch6Pin, HIGH, 25000);&#xA;  ch5 = pulseIn(ch5Pin, HIGH, 25000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Why did that work? It makes no sense to me.&lt;/p&gt;&#xA;" OwnerUserId="19838" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2020-05-27T20:59:45.340" Title="PWM Every Other Pin Doesn't Read" Tags="|arduino-uno|pwm|input|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25678" PostTypeId="1" AcceptedAnswerId="25679" CreationDate="2016-06-24T03:42:20.643" Score="0" ViewCount="1373" Body="&lt;p&gt;That is driving me nuts so I need your help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master : PC with Ubuntu, a USB to serial converter (chipset CP2102), connected to Arduino Uno Pin 10, 11 and GND. The Arduino Uno is plugged in the same PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Port for the converter is &lt;code&gt;/dev/ttyUSB1&lt;/code&gt; &#xA;Port for the Arduino is &lt;code&gt;/dev/ACM0&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to communicate by Serial through the converter (I do not want to use ACM0 as it is buggy and sometimes suddenly change to ACM1, messing up my big testing program).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On Arduino side :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11);&#xA;int inByte = 0;         // incoming serial byte&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (mySerial.available()) {&#xA;    char inByte = mySerial.read();&#xA;    mySerial.println(inByte);&#xA;    Serial.println(inByte);&#xA;  }&#xA;  delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Python script (simple one to debug)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;arduino = serial.Serial('/dev/ttyUSB1', 9600)&#xA;arduino.timeout=0.5&#xA;arduino.bytesize=8&#xA;arduino.stopbits=1&#xA;code=49 #ASCII Code for 1&#xA;arduino.write(chr(code).encode('utf-8'))&#xA;print(chr(code))&#xA;print(chr(code).encode('utf-8'))&#xA;print(arduino.readline()) &#xA;print(&quot;done&quot;) &#xA;arduino.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run it, I have on Arduino Serial monitor a &lt;code&gt;g&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and Python script output &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;b'1'&#xA;b'Ly\x00'&#xA;done&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By the way, the very same code over &lt;code&gt;/dev/ttyACM0&lt;/code&gt; and standard serial rather than Softwareserial works perfectly (as long as the port remains ACM0 of course) &lt;/p&gt;&#xA;" OwnerUserId="15416" OwnerDisplayName="Memes" LastActivityDate="2016-06-26T00:07:01.157" Title="How to communicate from Python to Arduino Softserial" Tags="|serial|python|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25679" PostTypeId="2" ParentId="25678" CreationDate="2016-06-24T03:58:06.260" Score="1" Body="&lt;p&gt;That is all me, look for an answer for ages, finally post a question, to end up finding the answer in the following hour...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is because Arduino takes TTL as input and not RS-232...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;similar here : &#xA;&lt;a href=&quot;https://electronics.stackexchange.com/questions/42584/arduino-uno-weird-characters-sent-to-com-softwareserial&quot;&gt;https://electronics.stackexchange.com/questions/42584/arduino-uno-weird-characters-sent-to-com-softwareserial&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15416" OwnerDisplayName="Memes" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-06-24T03:58:06.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25680" PostTypeId="1" AcceptedAnswerId="25681" CreationDate="2016-06-26T00:16:56.400" Score="2" ViewCount="5492" Body="&lt;p&gt;I'm implementing a voice synthesizer chip. To build a phrase, I create a list of phonemes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t PROGMEM heybuddy[] = {&#xA;  pPA5, pHH1, pEY, pPA5,&#xA;  pBB2, pAX, pDD2, pIY, pPA5,pPA5,pPA5,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And to play them I do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; for (size_t i=0; i&amp;lt;sizeof(heybuddy); i++){&#xA;    say(pgm_read_byte(heybuddy+i));&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So what I'd like to do is create a function where I can just pass the array to a function that can take care of the loop and do some other maintenance stuff. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//what I've tried: &#xA;void sayPhrase(const uint8_t *phrase){&#xA;  int open = 0;&#xA;  for (size_t i=0; i&amp;lt;sizeof(*phrase); i++){&#xA;&#xA;      if(pgm_read_byte(*phrase) != 4 &amp;amp;&amp;amp; open == 0){&#xA;          Serial.println(&quot;mouth open&quot;);&#xA;          open = 1;&#xA;      } else if(pgm_read_byte(*phrase) == 4 &amp;amp;&amp;amp; open == 1){&#xA;         Serial.println(&quot;mouth closed&quot;);&#xA;         open = 0;&#xA;      }&#xA;      say(pgm_read_byte(*phrase+i));&#xA;    } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when it comes to passing a static const I'm lost I've tried passing it as a reference with &lt;code&gt;*&lt;/code&gt; but nothing I do seems to work - I just don't know the proper way to do this in C.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I have compiles, but it seems to only get one phoneme and repeat it over and over. The rest are lost.&lt;/p&gt;&#xA;" OwnerUserId="23366" LastEditorUserId="8384" LastEditDate="2018-05-22T13:07:27.113" LastActivityDate="2018-05-22T20:47:50.733" Title="How to pass a static const (progmem) array to a function" Tags="|array|progmem|constants|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25681" PostTypeId="2" ParentId="25680" CreationDate="2016-06-26T00:58:48.930" Score="1" Body="&lt;p&gt;The problem is, when you call &lt;code&gt;sizeof(*phrase)&lt;/code&gt;, what is returned is 1, the size of the &lt;code&gt;uint8_t&lt;/code&gt; array element, the result of your pointer de-reference. On the other hand, if you call &lt;code&gt;sizeof(phrase)&lt;/code&gt; inside the function, you get the size of the pointer itself and not the size of the array, as you might expect. When you pass the array to the function via a pointer, the function has no idea if you passed the start of an array to it or merely a pointer to some &lt;code&gt;uint8_t&lt;/code&gt; variable, so it can't know what the size is; context has been lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, you should call &lt;code&gt;sizeof(phrase)&lt;/code&gt; in the same scope where the array was declared and initialized and pass the result to the function, which can then use this value in the &lt;code&gt;for&lt;/code&gt; loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const uint8_t PROGMEM heybuddy[] = {&#xA;  pPA5, pHH1, pEY, pPA5,&#xA;  pBB2, pAX, pDD2, pIY, pPA5,pPA5,pPA5,&#xA;};&#xA;&#xA;size_t SIZE = sizeof(heybuddy);  // this is ok since each element = 1 byte&#xA;&#xA;sayPhrase(phrase, SIZE);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function definition should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void sayPhrase(const uint8_t *phrase, size_t size){&#xA;  int open = 0;&#xA;  for (size_t i=0; i &amp;lt; size; i++){&#xA;&#xA;      if(pgm_read_byte(phrase) != 4 &amp;amp;&amp;amp; open == 0){&#xA;          Serial.println(&quot;mouth open&quot;);&#xA;          open = 1;&#xA;      } else if(pgm_read_byte(phrase) == 4 &amp;amp;&amp;amp; open == 1){&#xA;         Serial.println(&quot;mouth closed&quot;);&#xA;         open = 0;&#xA;      }&#xA;      say(pgm_read_byte(phrase+i));&#xA;    } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-06-26T11:53:06.763" LastActivityDate="2016-06-26T11:53:06.763" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25682" PostTypeId="2" ParentId="25680" CreationDate="2016-06-26T01:02:45.290" Score="1" Body="&lt;p&gt;I have some extensive examples of accessing PROGMEM &lt;a href=&quot;http://www.gammon.com.au/progmem&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've adapted one of the examples to show how you might do something similar to what you want:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int NUMBER_OF_ELEMENTS = 10;&#xA;&#xA;const char Message0000 [] PROGMEM = &quot;Twas bryllyg, and ye slythy toves&quot;; &#xA;const char Message0001 [] PROGMEM = &quot;Did gyre and gymble&quot;; &#xA;const char Message0002 [] PROGMEM = &quot;in ye wabe:&quot;; &#xA;const char Message0003 [] PROGMEM = &quot;All mimsy were ye borogoves; And ye mome raths outgrabe.&quot;; &#xA;const char Message0004 [] PROGMEM = &quot;\&quot;Beware the Jabberwock, my son! \n The jaws that bite, the claws that catch!&quot;; &#xA;const char Message0005 [] PROGMEM = &quot;Beware the Jubjub bird, and shun\n The frumious Bandersnatch!\&quot;&quot;; &#xA;const char Message0006 [] PROGMEM = &quot;He took his &quot;; &#xA;const char Message0007 [] PROGMEM = &quot;vorpal sword in hand:&quot;; &#xA;const char Message0008 [] PROGMEM = &quot;Long time the manxome foe he sought - &quot;; &#xA;const char Message0009 [] PROGMEM = &quot;So rested he by the Tumtum tree, \n And stood awhile in thought.&quot;; &#xA;&#xA;const char * const messages[NUMBER_OF_ELEMENTS] PROGMEM = &#xA;   { &#xA;   Message0000, &#xA;   Message0001, &#xA;   Message0002, &#xA;   Message0003, &#xA;   Message0004, &#xA;   Message0005, &#xA;   Message0006, &#xA;   Message0007, &#xA;   Message0008, &#xA;   Message0009, &#xA;   };&#xA;&#xA;void sayPhrase (const char * const * message)&#xA;  {&#xA;  const char * ptr = reinterpret_cast&amp;lt;const char *&amp;gt;(pgm_read_ptr (message));  // pointer to message&#xA;  Serial.println(reinterpret_cast&amp;lt;const __FlashStringHelper *&amp;gt;(ptr));    // and print it&#xA;  } // end of sayPhrase&#xA;&#xA;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  for (int i = 0; i &amp;lt; NUMBER_OF_ELEMENTS; i++)&#xA;    sayPhrase (&amp;amp;messages [i]);&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop () { } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="8384" LastEditDate="2018-05-22T20:47:50.733" LastActivityDate="2018-05-22T20:47:50.733" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25683" PostTypeId="2" ParentId="25680" CreationDate="2016-06-26T01:38:07.873" Score="0" Body="&lt;p&gt;As others have pointed out, your problem is &lt;code&gt;sizeof&lt;/code&gt;, which is calculated at compile time, not when the code is run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to pass the size of the array to the function. This can be done in many ways, depending on what else you are doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;code&gt;c&lt;/code&gt; the most common method is to use a null-terminated string, but I suspect this may not work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can store the size of each phrase in a separate array, and pass as a separate parameter or Pascal style as a count byte in the first element of the phrase.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-06-26T01:38:07.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25685" PostTypeId="2" ParentId="25676" CreationDate="2016-06-26T04:48:52.560" Score="1" Body="&lt;p&gt;When using strcmp(), strings should be terminated with a NULL character.  Which, by the way, is a zero. Your code should work as is if you replace the Line Feed character (10 or 0x0a) with a NULL (0 or 0x00). That is assuming the string you are getting back is 0x4f, 0x4b &amp;amp; 0x0a.  Or you could play it safe and replace &lt;a href=&quot;http://linux.die.net/man/3/strncmp&quot; rel=&quot;nofollow&quot;&gt;strcmp with strncmp&lt;/a&gt;.  Then explicitly state the number of characters to compare:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(strncmp((char *)sigfox_rd_buf,&quot;OK&quot;,2) == 0 )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-26T17:49:47.613" LastActivityDate="2016-06-26T17:49:47.613" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25687" PostTypeId="1" CreationDate="2016-06-26T08:53:41.927" Score="0" ViewCount="5287" Body="&lt;p&gt;I'm going bonkers here. I'm using a Macbook Pro with Yosemite. Connected to the MKS Gen-2Z V1.1 reprap board (ATmega 2560).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE only shows the cu port being available and not the tty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any attempts at opening the CU port show it as being busy. This is also true when I open the port using PronterFace (3d printer software). Yet, the PronterFace shows the tty port and gladly opens it and communicates. I downloaded Arduino 1.0.6 and the tty is available in the dropdown menu and it will open the port. But my 3D printer firmware will fail building on any Arduino IDEs prior to 1.6.0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found a few suggestions on creating a file &quot;lock&quot; in /var/ and then changing the r/w permissions. Also doing the same for /var/spool/uucp. Changing both of those permissions did nothing for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I may just have to build it and use AVRdude directly so I can use the tty port, but I have no idea why the cu would be busy all the time. Any suggestions? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the Arduino output when I try to upload:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;/dev/cu.usbserial-AL00YS9R&quot;: Resource busy&lt;br&gt;&#xA;      ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&lt;br&gt;&#xA;      ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&lt;br&gt;&#xA;      avrdude: ser_send(): write error: Bad file descriptor&lt;br&gt;&#xA;      Problem uploading to board. See &lt;a href=&quot;http://www.arduino.cc/en/Guide/Troubleshooting#upload&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.arduino.cc/en/Guide/Troubleshooting#upload&lt;/a&gt; for suggestions.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="23374" LastEditorUserId="4628" LastEditDate="2017-01-23T17:16:10.160" LastActivityDate="2017-01-23T17:16:10.160" Title="cu port always busy on Mac" Tags="|serial|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25688" PostTypeId="1" CreationDate="2016-06-26T09:26:46.217" Score="0" ViewCount="4163" Body="&lt;p&gt;I am lost at this one. In Java, I would do it this way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Inside the main sketch, I would instantiate the object from the class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;do = new DoClass(this);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would also include a method inside the main sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public void doSomething(){}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, inside the DoClass, I would have the following constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    public class DoClass{&#xA;       Sketch sketch;&#xA;       public DoClass(Sketch skt){&#xA;          this.sketch = stk;&#xA;       }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, at some point, I would call, from DoClass:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stk.doSomething():&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which should be the same as calling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;doSomething();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;from the main sketch. Any ideas how to achieve that? If yes, could you please show an example of how to achive the above example in Arduino?&lt;/p&gt;&#xA;" OwnerUserId="23376" LastActivityDate="2016-06-27T08:27:08.977" Title="Access method from main sketch inside class" Tags="|class|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25689" PostTypeId="2" ParentId="25677" CreationDate="2016-06-26T10:15:58.563" Score="1" Body="&lt;p&gt;&lt;code&gt;pulseIn()&lt;/code&gt; is a &lt;em&gt;blocking function&lt;/em&gt;: it waits until it gets a complete&#xA;pulse, or until it times out. While it's waiting, the Arduino cannot do&#xA;anything else, and it will miss pulses on other channels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RC receiver sends the pulses sequentially. Then, if you try to read&#xA;them in the right sequence, it may work. If you read them out of&#xA;sequence, you will miss some pulses, and the corresponding &lt;code&gt;pulseIn()&lt;/code&gt;&#xA;calls can timeout, returning zeros.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this kind of job I would use the pin change interrupt on pins 2 – 7.&#xA;This should allow reading the six pulses continuously without blocking&#xA;the whole program. But it's low-level (AVR-level) programming, probably&#xA;not doable with the standard Arduino libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Here is what I had in mind when suggesting the use of the pin&#xA;change interrupt. Notice that the pin numbers are “hardwired” into the&#xA;code and cannot be changed easily. This is because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pins 2 – 7 share a single pin change interrupt request&#xA;(PCINT2_vect), thus a single ISR is needed to time the six channels.&lt;/li&gt;&#xA;&lt;li&gt;They also share a port (port D), meaning they can all be read by the&#xA;ISR in a single instruction.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The other possible choices having these nice properties would be pins&#xA;8&amp;nbsp;–&amp;nbsp;13 (PCINT0_vect, port&amp;nbsp;B) or A0&amp;nbsp;–&amp;nbsp;A5&#xA;(PCINT1_vect, port&amp;nbsp;C).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Read 6 PWM signals from an RC receiver.&#xA; *&#xA; * Channels 0-5 are on digital pins 2-7 (i.e. PD2-PD7 = PCINT18-23).&#xA; */&#xA;&#xA;// This always contains the last length measured on each channel.&#xA;volatile uint16_t last_pulse_lengths[6];&#xA;&#xA;// Interrupt triggered on every change in pins 2-7.&#xA;ISR(PCINT2_vect)&#xA;{&#xA;    static uint8_t last_pin_states;&#xA;    static uint16_t start_times[6];  // start time for each channel&#xA;    uint8_t pin_states = PIND &amp;gt;&amp;gt; 2;  // shifted to bits 0-5&#xA;    uint16_t now = micros();&#xA;&#xA;    // Check every changed bit of the port.&#xA;    for (int i = 0; i &amp;lt; 6; i++) {&#xA;        uint8_t mask = _BV(i);&#xA;&#xA;        // Record start time on rising edge.&#xA;        if ((pin_states &amp;amp; mask) &amp;amp;&amp;amp; !(last_pin_states &amp;amp; mask))&#xA;            start_times[i] = now;&#xA;&#xA;        // Record pulse length on falling edge.&#xA;        if (!(pin_states &amp;amp; mask) &amp;amp;&amp;amp; (last_pin_states &amp;amp; mask))&#xA;            last_pulse_lengths[i] = now - start_times[i];&#xA;    }&#xA;    last_pin_states = pin_states;&#xA;}&#xA;&#xA;// Return the pulse lengths avoiding race conditions.&#xA;static void get_pulse_lengths(uint16_t lengths[6])&#xA;{&#xA;    for (int i = 0; i &amp;lt; 6; i++) {&#xA;        noInterrupts();&#xA;        uint16_t tmp = last_pulse_lengths[i];&#xA;        interrupts();&#xA;        lengths[i] = tmp;&#xA;    }&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    // Setup the pin change interrupt.&#xA;    PCIFR  = _BV(PCIF2);  // clear pin change interrupt flag&#xA;    PCICR  = _BV(PCIE2);  // enable pin change interrupt&#xA;    PCMSK2 = 0xfc;        // sense changes on pins 2-7 (i.e. PD2-PD7)&#xA;&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // Report the pulse lengths on the serial console.&#xA;    uint16_t pulse_lengths[6];&#xA;    get_pulse_lengths(pulse_lengths);&#xA;    for (int i = 0; i &amp;lt; 6; i++) {&#xA;        Serial.print(pulse_lengths[i]);&#xA;        if (i &amp;lt; 5) Serial.print(&quot;, &quot;);&#xA;        else Serial.println();&#xA;    }&#xA;&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-26T20:03:18.540" LastActivityDate="2016-06-26T20:03:18.540" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25691" PostTypeId="2" ParentId="25670" CreationDate="2016-06-26T12:29:16.307" Score="2" Body="&lt;p&gt;The maximum value you can pass to &lt;code&gt;analogWrite()&lt;/code&gt; is 255. Anything higher than that will wrap around back to 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should scale your value to fit into 0-255 instead of 0-1024.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-26T12:29:16.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25692" PostTypeId="2" ParentId="24988" CreationDate="2016-06-26T13:29:45.283" Score="0" Body="&lt;p&gt;Or just another simple version (which is more hardcore such as brute force):&#xA;Get expansion shield for nano to uno :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think this is just a sandwich version, which just takes additional space and cost.&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-06-26T13:29:45.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25693" PostTypeId="1" CreationDate="2016-06-26T13:34:49.757" Score="4" ViewCount="6001" Body="&lt;p&gt;I was thinking about a way to reuse the RAM of my old computer on my Arduino board. I was thinking about some peojects using neural networks, and more RAM would let the Arduino use more neurons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So that's my question, how could I do that? Maybe soldering some cables to Tx/Rx pins and creating and interface between the board and the memory?&lt;/p&gt;&#xA;" OwnerUserId="23379" LastActivityDate="2023-09-01T19:21:03.337" Title="Is there any way I can connect the RAM of a computer to Arduino?" Tags="|memory-usage|sram|memory|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25695" PostTypeId="2" ParentId="25693" CreationDate="2016-06-26T13:56:21.333" Score="0" Body="&lt;p&gt;If you try hard enough it might work, but it will not be easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general there are 2 types of RAM.  &lt;a href=&quot;https://en.wikipedia.org/wiki/Static_random-access_memory&quot; rel=&quot;nofollow&quot;&gt;Static&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Dynamic_random-access_memory&quot; rel=&quot;nofollow&quot;&gt;Dynamic&lt;/a&gt;.  You can cram a lot more memory into a Dynamic RAM chip so that is what is most likely in your computer. And probably what you are asking about in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dynamic memory needs to be &lt;a href=&quot;https://en.wikipedia.org/wiki/Dynamic_random-access_memory#Refresh_rate&quot; rel=&quot;nofollow&quot;&gt;refreshed continuously&lt;/a&gt;.  Otherwise the data will be lost.  This is such a repetitive and time consuming process that special hardware is used to relieve the processor of this task.  In general, embedded processors such at the Atmel (used in most Arduinos) do not have such specialized hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it will be (very) difficult to use your computer memory in your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, there are &lt;a href=&quot;http://playground.arduino.cc/Main/SpiRAM&quot; rel=&quot;nofollow&quot;&gt;some specialized RAM chips&lt;/a&gt; that you can use with your Arduino.  But they likely do not look like the memory chips in your computer.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-26T14:08:09.343" LastActivityDate="2016-06-26T14:08:09.343" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25696" PostTypeId="2" ParentId="25662" CreationDate="2016-06-26T15:29:10.483" Score="1" Body="&lt;p&gt;Capacitive touch screens are design (both the hardware and software) to work with human fingers and human like movements.  It could be that you are not only working against the physical aspects of influencing capacitance at the screen location you are interested in controlling, but also the software which is trying to reject noise and &quot;unwanted touches&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, &lt;a href=&quot;https://electronics.stackexchange.com/questions/60385/how-to-use-a-capacitive-touch-screen-without-a-human-hand&quot;&gt;this stack exchange question / answer&lt;/a&gt; addresses some of your questions and even proposes an (untested) circuit to try.  I would suggest to skip the &quot;accepted&quot; answer and read the answer with the highest score.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the above response, I would suggest changing your strategy.  I might try connecting the Arduino directly to the metal probe.  Then changing the software to alternate between putting a negative then positive voltage potential on the metal probe.  Avoiding using the Atmel's input or high impedance configuration.  I might also try a smaller metal probe that covers a smaller area of the target device.  Perhaps something that is conductive and easily reforms to a flat screen as if it were a finger tip.  Something like a small ball of aluminum foil. Also, make sure that there is nothing else touching the screen like tape or a stray wire.  Such objects may cause the target's software to consider all touch events as noise or as &quot;unwanted touches&quot;.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="15863" LastEditDate="2017-04-24T20:30:49.857" LastActivityDate="2017-04-24T20:30:49.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25697" PostTypeId="2" ParentId="25693" CreationDate="2016-06-26T15:50:32.210" Score="5" Body="&lt;p&gt;No, you can't connect your normal desktop computer memory to your Arduino. For a number of reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Computer memory (at least for the past 20 years) is DDR SDRAM. That's Synchronous Dynamic RAM. It requires very strict timing and synchronous (clock based) data transfers with clocks measured in the hundreds of MHz - something the Arduino cannot do.&lt;/li&gt;&#xA;&lt;li&gt;You need lots and lots of I/O pins to interface with SDRAM. I mean, just look at all those pins - how would you connect all those up to a little Arduino?&lt;/li&gt;&#xA;&lt;li&gt;Being DRAM you need to use quite a complex process to keep the data refreshed and stop the capacitance of each cell from draining away. Yes, that side of things is do-able, but not child's play.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The only way you will be able to interface DDR SDRAM with an Arduino is through some intermediate interfacing system that can do all the above for you. Your best candidate is to design an SPI to DDR conversion chip using an FPGA and Verilog or VHDL. That way you can communicate with the FPGA using SPI (or you could choose I2C if you like, or a simple 8-bit parallel protocol) and the FPGA then does all the grunt work that the Arduino isn't capable of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, while you're at it, you may as well put a CPU core in the FPGA (e.g., NIOS II or something) and do away with the Arduino altogether...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-26T15:50:32.210" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25698" PostTypeId="1" AcceptedAnswerId="25699" CreationDate="2016-06-26T16:44:04.330" Score="-1" ViewCount="7162" Body="&lt;p&gt;I'm working with an esp8266 and want to have it default to an access point when it cannot connect to a wifi network.  I'm using chriscook8's example from github &lt;a href=&quot;https://github.com/chriscook8/esp-arduino-apboot/blob/master/ESP-wifiboot.ino&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;chriscook8 uses &quot;+=&quot; in several places and I can't find an explanation of what that means.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example from setup():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;  EEPROM.begin(512);&#xA;  delay(10);&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  Serial.println(&quot;Startup&quot;);&#xA;  // read eeprom for ssid and pass&#xA;  Serial.println(&quot;Reading EEPROM ssid&quot;);&#xA;  String esid;&#xA;  for (int i = 0; i &amp;lt; 32; ++i)&#xA;  {&#xA;    esid += char(EEPROM.read(i));  //&amp;lt;- here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does += do?&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-06-27T00:18:10.150" Title="What does &quot;+=&quot; mean?" Tags="|c++|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25699" PostTypeId="2" ParentId="25698" CreationDate="2016-06-26T16:56:08.030" Score="6" Body="&lt;p&gt;It adds the value or variable on the right to the variable on the left and assigns the result to the variable on the left.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A += B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is the same as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A = A + B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's short-hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of a String it concatenates the right hand item on to the end of the left hand item.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-06-26T22:07:13.257" LastActivityDate="2016-06-26T22:07:13.257" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25700" PostTypeId="1" CreationDate="2016-06-26T17:48:04.053" Score="0" ViewCount="905" Body="&lt;p&gt;Please tell me that if I keep my arduino uno on for 24 hours with a adapter, will it get harmed?&lt;/p&gt;&#xA;" OwnerUserId="22930" LastActivityDate="2016-06-28T13:19:01.593" Title="What will happen if I keep my arduino on for 24 hours?" Tags="|arduino-uno|" AnswerCount="4" CommentCount="2" ClosedDate="2016-07-01T10:43:51.500" ContentLicense="CC BY-SA 3.0" />
  <row Id="25701" PostTypeId="2" ParentId="25698" CreationDate="2016-06-26T18:38:00.830" Score="3" Body="&lt;p&gt;&lt;code&gt;+=&lt;/code&gt; is a common programming shortcut. An example: (pseudo-code)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;num1 = 7&#xA;num2 = 15&#xA;#these two lines are exactly the same&#xA;num1 += num2&#xA;num1 = num1 + num2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;+=&lt;/code&gt; is extremely useful for increasing the value of a variable by another variable. It also works similarly with &lt;code&gt;-=&lt;/code&gt;, &lt;code&gt;*=&lt;/code&gt;, and &lt;code&gt;/=&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="23385" LastActivityDate="2016-06-26T18:38:00.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25702" PostTypeId="2" ParentId="25700" CreationDate="2016-06-26T19:06:48.490" Score="2" Body="&lt;p&gt;I have several home-brUnos and a genuine Mega 2560 that are now, or have, run 24/7 for periods of weeks to months, powered by either a USB port or a USB-type wall charger. All of them supported (or still do) a string of 2 or 3 DS18b20 digital thermo sensors and a WiFi or Bluetooth radio. None of them slept during those jobs and they all still live and continue work as well as they always have.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-06-28T13:19:01.593" LastActivityDate="2016-06-28T13:19:01.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25703" PostTypeId="1" AcceptedAnswerId="26744" CreationDate="2016-06-26T19:30:55.663" Score="1" ViewCount="7738" Body="&lt;p&gt;Please tell me why I have to connect one of the wires of arduino gnd to the gnd of a relay or a bluetooth module?&lt;/p&gt;&#xA;" OwnerUserId="22930" LastActivityDate="2016-07-27T06:54:03.420" Title="Why is there a need to ground a circuit?" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25704" PostTypeId="2" ParentId="17" CreationDate="2016-06-26T19:35:09.437" Score="6" Body="&lt;p&gt;I uninstalled the IDE and drivers etc, installed it all again, then I ran the Arduino IDE as an administrator and set to run compatibility as windows 7 (I'm currently using 10).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also changed the programmer to AVR ISP (I don't think this matters, but I changed it anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All is working again... hopefully, this can help someone else out too. &lt;/p&gt;&#xA;" OwnerUserId="23386" LastEditorUserId="39212" LastEditDate="2018-06-21T16:22:40.330" LastActivityDate="2018-06-21T16:22:40.330" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25705" PostTypeId="2" ParentId="25703" CreationDate="2016-06-26T20:29:56.533" Score="5" Body="&lt;p&gt;Electric circuits need to be closed. The hydraulic analogy might help you in this sense: suppose you have a garden fountain and want to recycle its water;  if you want water to &lt;em&gt;circulate&lt;/em&gt; by means of a pump, you need a way to put the water back in the pump. That's what the ground connection is for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes you have closed circuits using other wires, and a ground connection (or a shorter, direct ground connection) might be required to keep at bay the effect of EMI (electro-magnetic interference). &#xA;For example, this is the output of an Arduino Nano sensed by connecting only the tip of the oscillocope probe to pin 13.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/B63cZ.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/B63cZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And this is the same output when I connected the ground tip to Arduino's GND (actually to the USB frame):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/vY0Ul.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vY0Ul.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="8506" LastEditorUserId="8506" LastEditDate="2016-06-26T20:50:33.190" LastActivityDate="2016-06-26T20:50:33.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25706" PostTypeId="1" CreationDate="2016-06-26T20:52:17.057" Score="0" ViewCount="118" Body="&lt;p&gt;This what I have learned :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digital inputs and outputs &#xA;&#xA;Analog inputs and outputs&#xA;&#xA;Line follower ir sensor &#xA;&#xA;Pir sensor &#xA;&#xA;Ultransonic sensor&#xA;&#xA;Ir transmitter and reciever &#xA;&#xA;Lcd &#xA;&#xA;Key pad&#xA;&#xA;Dc motor &#xA;&#xA;Stepper motor&#xA;&#xA;Servo motor&#xA;&#xA;Interrupts &#xA;&#xA;Timers &#xA;&#xA;Watchdogs &#xA;&#xA; Arduino with raspberry pi &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This topics a made with it some projects so the question is what is next to learn about arduino ? What should be my next steps ?? &lt;/p&gt;&#xA;" OwnerUserId="23371" LastActivityDate="2016-06-27T16:19:03.750" Title="What should I learn next in arduino?" Tags="|arduino-uno|" AnswerCount="5" CommentCount="1" ClosedDate="2016-07-01T10:47:30.690" ContentLicense="CC BY-SA 3.0" />
  <row Id="25707" PostTypeId="2" ParentId="22414" CreationDate="2016-06-26T22:02:21.997" Score="1" Body="&lt;p&gt;For shift (making an &lt;code&gt;a&lt;/code&gt; into an &lt;code&gt;A&lt;/code&gt;), simply program in some ands. Pseudo-code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if shift AND a:&#xA;    return A&#xA;elif shift AND b:&#xA;    return B&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and so on and so forth.&lt;/p&gt;&#xA;" OwnerUserId="23385" LastActivityDate="2016-06-26T22:02:21.997" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25708" PostTypeId="2" ParentId="61" CreationDate="2016-06-26T22:07:51.570" Score="1" Body="&lt;p&gt;Yes you can, and fairly easily. There is a wonderful online simulation (completely free) called &lt;a href=&quot;https://circuits.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;TinkerCAD&lt;/a&gt;. It has an excellent breadboard simulation, with parts like transistors, LEDs, ICs, and Arduino. You can program the Arduino and run it all in a live simulation that includes interactive inputs (pushbuttons, DIP switches, etc.).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;[Edit: The following text refers to functionality that has been moved to &lt;a href=&quot;https://circuits.io/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Circuits.io&lt;/a&gt;, namely &lt;a href=&quot;https://www.autodesk.com/products/eagle/free-download&quot; rel=&quot;nofollow noreferrer&quot;&gt;Eagle PCB&lt;/a&gt;]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's not all. It also includes in a separate tab schematics for your circuit, and another tab for PCB design of your breadboard circuit! Or, you can just make your schematics from scratch and make your PCB from there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can have your circuit designs made and you can buy them. You can do all of this in circuits.io, and you aren't risking messing up your actual Arduino. It also has warning indicators in the simulation (for example, if you didn't use enough resistance on an LED, or an IC).&lt;/p&gt;&#xA;" OwnerUserId="23385" LastEditorUserId="19409" LastEditDate="2018-06-12T12:44:29.530" LastActivityDate="2018-06-12T12:44:29.530" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25709" PostTypeId="2" ParentId="25706" CreationDate="2016-06-26T22:42:05.157" Score="2" Body="&lt;p&gt;You say you have learned these things but were you using a motor shield for the DC motor?  How's about building your own H-bridge. And how many types of stepping motors do you now know how to control?  What about micro stepping? And what about graphical LCDs. Do you know how to make custom characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As your list is hardware-centric, I would next task you to learn how to write in C++ and create a library for others to use.  Learn what it means to abstract the hardware down to a few simple function calls.  How to create a class which contains an Arduino library for, say, the graphical features of a particular LCD.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-26T22:42:05.157" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25710" PostTypeId="2" ParentId="25698" CreationDate="2016-06-27T00:18:10.150" Score="0" Body="&lt;p&gt;In the earliest days of the C language (I'm talking late 60's here), the compilers did not do much (if any) optimization, and a lot of the constructs in C were put in so that a programmer could get a more optimized program by using hints like +=.  So, in those days, &lt;code&gt;A = A + 5&lt;/code&gt; generated three PDP11 instructions, while &lt;code&gt;A += 5&lt;/code&gt; was only a single PDP11 instruction.  That meant that most programmers learned to write it that way.  But because it was more concise and to many also more readable, the C constructs with &lt;code&gt;&amp;lt;op&amp;gt;=&lt;/code&gt; have made it into most modern languages.&lt;/p&gt;&#xA;" OwnerUserId="23393" LastActivityDate="2016-06-27T00:18:10.150" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25711" PostTypeId="2" ParentId="25706" CreationDate="2016-06-27T00:49:50.830" Score="1" Body="&lt;p&gt;I would get myself familiar with low power, sleeping modes, running on batteries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also connect others devices using SPI and I2C to familiarize yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally give a go on different communication methods... over serial, ethernet, wireless, can bus, etc. No much point in having stand-alone projects that are isolated or always connected to an USB port. IMO the fun begins when your projects start to talk to each other and to the Internet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers &lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="16417" LastEditDate="2016-06-27T11:05:56.257" LastActivityDate="2016-06-27T11:05:56.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25712" PostTypeId="2" ParentId="21514" CreationDate="2016-06-27T01:00:32.683" Score="2" Body="&lt;p&gt;According to the Arduino Callback LED tutorial, you can use the dedicated library to access the BLE features of the board. All the Curie Libraries are covering the new Arduino/Genuino 101 embedded characteristics .&#xA;In your case you must incluse the CurieBLE.h and configure the bluetooth service with Read/Write access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have a look to &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Genuino101CurieBLECallbackLED&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; for a complete sample.&lt;/p&gt;&#xA;" OwnerUserId="19537" LastActivityDate="2016-06-27T01:00:32.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25713" PostTypeId="2" ParentId="24611" CreationDate="2016-06-27T01:24:59.870" Score="0" Body="&lt;p&gt;Rechargeable lithium batteries have great energy density but they also have some significant self-discharge, making a bad choice for low-power applications. Have a look on this Arduino &quot;clone&quot;: &lt;a href=&quot;https://talk2.wisen.com.au/product-talk2-whisper-node-avr/&quot; rel=&quot;nofollow&quot;&gt;https://talk2.wisen.com.au/product-talk2-whisper-node-avr/&lt;/a&gt;, which is designed to run from standard Alkaline batteries and consumes very little (under 4µA when sleeping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sensors, you should look for smart ones. You can find some very sophisticated MEMs sensors which will produce interrupt based on thresholds. You normally use I²C interface to talk to those little devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you could use something similar to this one for light sensing: &lt;a href=&quot;http://www.vishay.com/optical-sensors/list/product-83462/&quot; rel=&quot;nofollow&quot;&gt;http://www.vishay.com/optical-sensors/list/product-83462/&lt;/a&gt;. Although this is a proximity sensor, it also has thresholds for the ambient light as well as consumes very little current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most important is to design the solution to run at lower voltage (3.3V instead of 5V) and also use interrupts to wake-up everywhere. If you like to run a bare ATMega328p directly from a 18650 cell, make sure everything will be ok to run from 4.2V to 3.0V as you're not using any regulation.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="16417" LastEditDate="2016-06-27T01:30:23.390" LastActivityDate="2016-06-27T01:30:23.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25714" PostTypeId="1" CreationDate="2016-06-27T03:34:19.527" Score="2" ViewCount="588" Body="&lt;p&gt;I am trying to program my Arduino Mega 2560 to effectively create a PWM signal on any digital pin using timer interrupts and timer1. The pins will pulse a finite amount of times (not indefinitely). I am first trying this with a 256-prescaler value, which I believe means that each increment of my TCNT1 is 16.0 microseconds, and since it is a 16-bit register, it can reach a max. value of 1048567 microseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am designing the program so that the period and duty cycle are changed by Serial commands that the user can send (I already have that part figured out). I am using clear timer on compare mode and OCR1A and OCR1B to toggle the digital pin between HIGH and LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the desired period is less than 1048567 microseconds, I can divide the period by the modified clock (modified by the prescaler) to figure out the OCR1A value, and then based on the desired duty cycle, calculate OCR1B. Then I set the ISR vectors for A and B to toggle the pin and count down until the desired number of cycles is completed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would like to also allow the user to do is set periods/duty cycles that would be longer than 1048567 microseconds, but I'm not sure how to accomplish that. For example, if I wanted to have the pin be HIGH for 2 seconds with a total period of 10 seconds, I would choose values for OCR1B and OCR1A that, through the ISR(TIMER1_COMPA_vect) and ISR(TIMER1_COMPB_vect), I could keep track (through a counter variable) of how many interrupts had occurred. If enough interrupts had occurred to equal the time of that the pin had to be HIGH and/or LOW, the ISRs would actually trigger the toggling of the pin (instead of just counting the number of interrupts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I choose the OCR1B and OCR1A values that would accomplish this optimally? Is it reasonable to keep track of time this way as a workaround to the limitation of the timer counter max value? I am open to any suggestion and I appreciate any input. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2016-06-27T09:48:27.363" Title="How to user timer interrupts for times longer than can TNCTx can keep track of?" Tags="|arduino-mega|timers|isr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25716" PostTypeId="2" ParentId="25700" CreationDate="2016-06-27T05:42:25.080" Score="0" Body="&lt;p&gt;I have a number of Arduinos running 24/7. Nothing bad has happened to them. I suggest if you are running them from a wall-wart style adapter that you choose one supplying voltage at the lower-end of the recommended range. That is, for a Uno for example, with a 7V adapter rather than a 12V one. The reason is that the extra voltage basically has to be thrown away by the voltage regulator as heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An adapter supplying 9V would be OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative is to get one of those USB chargers that supply 5V (eg. for an iPhone), and use that by running a USB cable to the USB port of the Arduino. Then the voltage regulator doesn't have to do anything at all.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-27T05:42:25.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25717" PostTypeId="1" CreationDate="2016-06-27T05:42:46.807" Score="1" ViewCount="8935" Body="&lt;p&gt;How to generate 100khz square wave with 50% duty cycle using arduino uno&#xA;The following code was tried but did not give appropriate output&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delayMicroseconds(5); // wait for 5 micro seconds, 100khz frequency with  50%         &#xA;                           // duty cycle&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delayMicroseconds(5);              // wait for 5 micro seconds&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23399" LastEditorUserId="4131" LastEditDate="2016-06-27T07:11:26.093" LastActivityDate="2016-07-27T12:13:56.503" Title="100khz square wave with 50% duty cycle" Tags="|usb|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25718" PostTypeId="2" ParentId="25687" CreationDate="2016-06-27T05:47:06.347" Score="0" Body="&lt;p&gt;JRobert - I'll have to try the csrutil suggestion. The problem I see with that is the board I am trying to interface with has a genuine FTDI chip, the 232RL. The answer posted was to install a driver for a chinese USB chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Gerben - I do have a /dev/tty.usbserial-AL00YS9R. The Arduino IDE is only showing the cu ports. &lt;/p&gt;&#xA;" OwnerUserId="23375" LastActivityDate="2016-06-27T05:47:06.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25719" PostTypeId="1" CreationDate="2016-06-27T05:55:03.943" Score="0" ViewCount="300" Body="&lt;p&gt;I have installed Arduino software into my PC and copied the bin files into the memory card that has to be fixed into Arduino yun. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After switching on the yun board it is not creating any Arduino yun wifi connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you help me to overcome this problem?&#xA;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="23400" LastEditorUserId="19515" LastEditDate="2016-06-27T14:52:39.220" LastActivityDate="2016-07-12T14:45:03.503" Title="Arduino yun is not creating it's wifi?" Tags="|wifi|arduino-yun|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25720" PostTypeId="2" ParentId="25717" CreationDate="2016-06-27T06:05:15.877" Score="0" Body="&lt;p&gt;First, be sure to use the &quot;{}&quot; in the menu to show your code in a code block &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { &#xA;// initialize digital pin 13 as an output. &#xA;pinMode(13, OUTPUT); }&#xA;&#xA;// the loop function runs over and over again forever &#xA;void loop() { &#xA;digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)  &#xA;delayMicroseconds(5); // wait for a second &#xA;digitalWrite(13, LOW); // turn the LED off by making the voltage LOW &#xA;delayMicroseconds(5); // wait for a second }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I think you could benefit from reading the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM&quot; rel=&quot;nofollow&quot;&gt;Secrets of PWM&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using a microsecond delay will only give you an approximate pwm signal. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Arduino's programming language makes PWM easy to use; simply call analogWrite(pin, dutyCycle), where dutyCycle is a value from 0 to 255, and pin is one of the PWM pins (3, 5, 6, 9, 10, or 11). The analogWrite function provides a simple interface to the hardware PWM, but doesn't provide any control over frequency. (Note that despite the function name, the output is a digital signal, often referred to as a square wave.) &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="23375" LastActivityDate="2016-06-27T06:05:15.877" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25721" PostTypeId="2" ParentId="25719" CreationDate="2016-06-27T06:18:33.063" Score="1" Body="&lt;p&gt;If there is no code that enables the WiFi, it won't be enabled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the link:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Guide/ArduinoYun#toc14&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/ArduinoYun#toc14&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23402" LastActivityDate="2016-06-27T06:18:33.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25722" PostTypeId="2" ParentId="25688" CreationDate="2016-06-27T06:44:13.697" Score="1" Body="&lt;p&gt;The great thing about Java is that it was designed to have a similar syntax as C++ and Arduino will gladly compile C++. So if you're familiar with Java this should be pretty easy for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;check out &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/classes/&quot; rel=&quot;nofollow&quot;&gt;This Tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for your example... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Much like Java, it is best practice to put C++ classes in their own files, but it is not required. If you use Java you are used to &quot;importing&quot; modules and classes into the class you are creating. Similarly C++ imports header files (behind the scenes it is much different, but functionally the same).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this first you would create a header file. This is just a text file with the extension &quot;.h&quot; or &quot;.hpp&quot; intead of &quot;.txt&quot; - traditionally .h is used only for c files and .hpp would be for c++. The header file will include the class and method prototypes. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before I get to your example, as a side note: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Your example using the &quot;sketch&quot; variable is somewhat confusing because a sketch is just what the world of Arduino calls a program and it would not be used as variable.&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;DoClass.hpp&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class DoClass { &#xA;  int var; &#xA;public: &#xA;  DoClass(int var); &#xA;  int getVar();&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;DoClass.cpp&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DoClass.hpp&quot;&#xA;&#xA;DoClass::DoClass(int variable){&#xA;  var = variable&#xA;}&#xA;&#xA;int DoClass::getVar(){&#xA;  return var;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;::&quot; means &quot;member of&quot; so the &lt;em&gt;getVar()&lt;/em&gt; is a method of DoClass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These files should be saved in your sketch folder. If you are creating a class that will be reused you can place it in ../sketches/libraries/. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;DoClass.hpp&quot;&#xA;setup(){&#xA;  ...&#xA;}&#xA;&#xA;DoClass myClass(5);  // creates class&#xA;int testVal; &#xA;&#xA;loop(){&#xA;  ...&#xA;  testVal = myClass.getVar(); &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23375" LastActivityDate="2016-06-27T06:44:13.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25724" PostTypeId="2" ParentId="25688" CreationDate="2016-06-27T08:27:08.977" Score="1" Body="&lt;p&gt;Unlike Java, which insists on everything being inside a class, C++&#xA;allows “plain” functions which do not belong to any class. In fact,&#xA;&lt;code&gt;main()&lt;/code&gt; in standard C++, as well &lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; in Arduino&#xA;code, are all plain functions. Then, the main program (or “sketch” if&#xA;you wish) is not an object, you cannot give it to the constructor of&#xA;your class. Instead, you would give it a pointer to the particular&#xA;function it needs. This is called a &lt;em&gt;callback&lt;/em&gt;, because the library is&#xA;calling back something from your main program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is how I would write it in C++:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Class definition.&#xA; */&#xA;&#xA;class DoClass {&#xA;&#xA;    // Define a callback type: a pointer to a function taking no&#xA;    // arguments and returning void.&#xA;    typedef void (*callback_t)();&#xA;&#xA;public:&#xA;    // Constructor.&#xA;    DoClass(callback_t _callback)&#xA;        // Initialize internal callback with the one given as parameter.&#xA;        : callback(_callback)&#xA;        // empty function body&#xA;        {}&#xA;&#xA;    // This class method invokes the callback.&#xA;    void doIt() { callback(); }&#xA;&#xA;private:&#xA;    // The callback is kept as private internal data.&#xA;    callback_t callback;&#xA;};&#xA;&#xA;/*&#xA; * Main program.&#xA; */&#xA;&#xA;// This is the function we are going to provide as a callback.&#xA;void doSomething()&#xA;{&#xA;    Serial.println(F(&quot;Doing some work...&quot;));&#xA;}&#xA;&#xA;// Instantiate the class statically.&#xA;DoClass doObject(doSomething);&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    doObject.doIt();  // &amp;lt;- this will invoke our callback.&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The class could be instantiated dynamically&#xA;(&lt;code&gt;DoClass *doObject = new DoClass(doSomething);&lt;/code&gt;).&#xA;I prefer to do it statically when possible, because dynamic memory&#xA;allocation can easily led to memory fragmentation problems in such small&#xA;platforms.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-27T08:27:08.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25726" PostTypeId="2" ParentId="25714" CreationDate="2016-06-27T09:48:27.363" Score="2" Body="&lt;p&gt;By maintaining your own second-level prescaler you can quite easily keep track of longer periods.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most efficient method is to use a &quot;divide and multiply by two&quot; scheme.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start with a custom pre-scaler of 1.&lt;/li&gt;&#xA;&lt;li&gt;While the count period is &gt; 65535:&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Multiply the pre-scaler by 2.&lt;/li&gt;&#xA;&lt;li&gt;Divide the count period by 2&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint16_t ps = 1;&#xA;uint32_t period = 429864;&#xA;&#xA;while (period &amp;gt; 65535) {&#xA;    ps &amp;lt;&amp;lt;= 1;&#xA;    period &amp;gt;&amp;gt;= 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can load the count period register with the now divided count period and use a variable to count the number of times the interrupt has been triggered. When it equals your custom pre-scaler value you reset the count to 0 and run your actual interrupt routine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The left and right shifts multiply by two and divide by two respectively in a very efficient manner. Far more than multiplying by 10, or dividing the period by 65536 and using that as a prescaler.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-27T09:48:27.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25727" PostTypeId="2" ParentId="25717" CreationDate="2016-06-27T09:52:30.467" Score="4" Body="&lt;p&gt;The problem with your program is that it does not loop fast enough. Each&#xA;call to &lt;code&gt;delayMicroseconds()&lt;/code&gt; should take roughly the requested time to&#xA;execute, but the CPU also needs time to execute the rest of your code,&#xA;including the time needed to return from &lt;code&gt;loop()&lt;/code&gt; and call it again.&#xA;The period of the signal ends up being considerably longer than the&#xA;desired 10&amp;nbsp;µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest software-only approach would be to get rid of the delay&#xA;using the technique described in the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;Blink Without Delay&lt;/a&gt; Arduino&#xA;tutorial. With one twist: instead of&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// save the last time you blinked the LED&#xA;previousMillis = currentMillis;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you would use&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// save the last time you should have blinked the LED&#xA;previousMillis += interval;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way the small timing errors do not add up: you get, &lt;em&gt;on average&lt;/em&gt;&#xA;the correct period. Oh, and obviously, you track time in microseconds,&#xA;not milliseconds:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const uint16_t TOGGLE_TIME = 5;  // toggle pin every 5 us&#xA;&#xA;void setup() {&#xA;    pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    static uint16_t last_toggle;&#xA;    static uint8_t pin_state = LOW;&#xA;&#xA;    if ((uint16_t) micros() - last_toggle &amp;gt;= TOGGLE_TIME) {&#xA;        pin_state = !pin_state;       // invert pin state&#xA;        digitalWrite(13, pin_state);&#xA;        last_toggle += TOGGLE_TIME;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This may somehow work if you have a fast enough Arduino, maybe a Due or&#xA;a Zero. If you have an AVR-based board (like the Uno and actually most&#xA;Arduinos), you will not get anything faster than ≈&amp;nbsp;50&amp;nbsp;kHz with&#xA;this. This is because &lt;code&gt;digitalWrite()&lt;/code&gt; is sooo slooow, it cannot cope&#xA;with your 100&amp;nbsp;kHz. You can improve things by using &lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;nofollow&quot;&gt;direct port&#xA;access&lt;/a&gt;[] instead of &lt;code&gt;digitalWrite()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    static uint16_t last_toggle;&#xA;&#xA;    if ((uint16_t) micros() - last_toggle &amp;gt;= TOGGLE_TIME) {&#xA;        PINB = _BV(PB5);             // invert pin state&#xA;        last_toggle += TOGGLE_TIME;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you have roughly the requested frequency, but with some terrible&#xA;jitter: testing on my Uno I could see each level being held for&#xA;&lt;em&gt;slightly&lt;/em&gt; less than 5&amp;nbsp;µs. Then, from time to time, one level is&#xA;held for ≈&amp;nbsp;9&amp;nbsp;µs. Things could still be made faster by wrapping&#xA;the &lt;code&gt;if&lt;/code&gt; inside an infinite loop, instead of relying on the Arduino core&#xA;to repeatedly call &lt;code&gt;loop()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop() {&#xA;    uint16_t last_toggle = 0;&#xA;&#xA;    for (;;) {  // infinite loop&#xA;        if ((uint16_t) micros() - last_toggle &amp;gt;= TOGGLE_TIME) {&#xA;            PINB = _BV(PB5);             // invert pin state&#xA;            last_toggle += TOGGLE_TIME;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now the signal looks still worse: with the program running faster,&#xA;levels are held most of the time for only 3.5&amp;nbsp;µs, and then one out&#xA;of every ≈&amp;nbsp;4 levels is held for about 9&amp;nbsp;µs. The &lt;em&gt;average&lt;/em&gt;&#xA;frequency is probably right, but the jitter is absolutely awful, which&#xA;is likely due to the 4&amp;nbsp;µs resolution of &lt;code&gt;micros()&lt;/code&gt; noted by user&#xA;Talk2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The conclusion from these tests is: your only hope to get a somewhat&#xA;clean signal at this frequency is to generate it in hardware, not in&#xA;software. Choose one of the timers and have it generate the signal you&#xA;want. I would avoid timer&amp;nbsp;0, as it is needed by the Arduino timing&#xA;functions (&lt;code&gt;delay()&lt;/code&gt;, &lt;code&gt;millis()&lt;/code&gt;...). Here is how it can be done with&#xA;timer&amp;nbsp;2:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;    // The output will be on digital 3 = PD3 = OC2B.&#xA;    pinMode(3, OUTPUT);&#xA;&#xA;    // Configure timer 2 for PWM @ 10 kHz on OC2B.&#xA;    TCCR2A = _BV(COM2B1)  // non-inverting PWM on OC2B&#xA;           | _BV(WGM20)   // mode 7: fast PWM, TOP = OCR2A&#xA;           | _BV(WGM21);  // ditto&#xA;    TCCR2B = _BV(WGM22)   // ditto&#xA;           | _BV(CS21);   // clock @ F_CPU / 8&#xA;    OCR2A  = 19;          // period = (19 + 1) * 8 CPU cycles&#xA;    OCR2B  = 9;           // HIGH for (9 + 1) * 8 CPU cycles&#xA;}&#xA;&#xA;void loop() {&#xA;    // Nothing to do here, the signal is generated in hardware.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And now you have a perfectly clean 10&amp;nbsp;kHz square wave, while your&#xA;program is free to do other stuff at the same time. Notice that the&#xA;output is now on pin 3: the pin choice is limited when using the&#xA;hardware-based approach. Notice also that you loose the PWM capability&#xA;on pin 11, since it depends on timer 2.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-27T10:17:54.857" LastActivityDate="2016-06-27T10:17:54.857" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25728" PostTypeId="1" AcceptedAnswerId="25735" CreationDate="2016-06-27T10:16:18.810" Score="1" ViewCount="1042" Body="&lt;p&gt;I have read many tutorials on LDR(Light dependent resistor) with Arduino which includes a 10 kilo ohm resistor but can i use it with 220 ohm resistor or even without resistor.&lt;/p&gt;&#xA;" OwnerUserId="23408" LastActivityDate="2016-06-27T13:14:24.843" Title="Use LDR with 220 ohm resistor" Tags="|arduino-uno|resistor|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25729" PostTypeId="2" ParentId="25728" CreationDate="2016-06-27T10:35:14.847" Score="0" Body="&lt;p&gt;The simple fact is: you need a resistor with it. There's no getting away from that fact (short of building and using a constant-current source, but that's beyond the scope of this answer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What value should the resistor be? Well, that depends on how sensitive or insensitive you want the LDR to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it will work with 220Ω, but will it give suitable results? Probably not. Ideally you want the resistor to be somewhere in the vicinity of the nominal resistance of the LDR - and that usually means 10s of KΩ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As Edgar has mentioned, you can, at a pinch, use the internal pullup resistor of an IO pin instead of an external one (&lt;code&gt;pinMode(A0, INPUT_PULLUP)&lt;/code&gt;), but the variability in the possible resistances that it might be make it pretty useless for anything more than &quot;is it light or dark&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you are best off getting a 10KΩ resistor where you then know that it is 10KΩ (or within a small percentage) and can calculate the LDR's resistance properly.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-27T10:35:14.847" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25732" PostTypeId="2" ParentId="25706" CreationDate="2016-06-27T12:27:45.943" Score="0" Body="&lt;p&gt;The Nrf24L01 is an inexpensive wireless transceiver with very good Arduino library support, and there are still library opportunities, like star and mesh interconnections. It also requires less overhead than WiFi and ethernet. If you're PhD material, you could implement the OSI stack. &lt;/p&gt;&#xA;" OwnerUserId="13616" LastActivityDate="2016-06-27T12:27:45.943" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25733" PostTypeId="1" AcceptedAnswerId="25741" CreationDate="2016-06-27T12:33:39.410" Score="8" ViewCount="13566" Body="&lt;p&gt;How can one close a tab in the Arduino IDE? There is a Tab button (little triangle) with the Option &quot;Delete&quot;(kind of misleading term). There is no &quot;Close&quot; option. And the &quot;Delete&quot; option doesnt do the job for me either, because the tabs are write-protected, and I just get a prompt.&lt;/p&gt;&#xA;" OwnerUserId="23413" LastActivityDate="2016-06-27T15:18:31.083" Title="How to simply close a tab?" Tags="|arduino-ide|ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25735" PostTypeId="2" ParentId="25728" CreationDate="2016-06-27T13:14:24.843" Score="2" Body="&lt;p&gt;Unless properly filtered, an LDR has a spectral sensitivity very&#xA;different from the human eye, which makes it unsuitable for any kind of&#xA;photometric measurement. It is also typically very loosely specified,&#xA;so you won't know the illuminance it receives better than a factor two&#xA;even if you measure its resistance very accurately. Thus, if you really&#xA;need accurate illuminance measurements like, e.g., for complying with&#xA;legal requirements, then forget the LDR and get a real luxmeter with a&#xA;calibration traceable to the SI lux standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, if you only want to tell apart substantially different illuminance&#xA;levels, like sunny and cloudy, then the LDR is fine. And don't let&#xA;Majenko scare you into believing you really need to know the resistance&#xA;of your pullup: it doesn't really matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, you will get the best sensitivity if your pullup has a&#xA;resistance in the same range as the resistance of the LDR in the typical&#xA;conditions you will use it. Thus, if your LDR is nominally 10&amp;nbsp;kΩ, I&#xA;would avoid pulling up with 220&amp;nbsp;Ω, as the sensitivity would be very&#xA;poor. A 10&amp;nbsp;kΩ pullup resistor would be ideal, but the internal&#xA;pullup of the I/O pin (20 –&amp;nbsp;50&amp;nbsp;kΩ, 30&amp;nbsp;kΩ typical) should&#xA;be fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many tutorials on LDRs use the ADC reading to compute a resistance, for&#xA;which you need to know the resistance of the pullup. If you want to&#xA;follow this path, just assume a 30&amp;nbsp;kΩ pullup. All your numbers will&#xA;be somewhat off, but that makes absolutely no difference, because you&#xA;don't know how to relate the resistance to the illuminance anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest you forget about computing the resistance. Just look at&#xA;the raw ADC readings instead. Take some test readings in the typical&#xA;conditions that are of interest to you: now you have a baseline to which&#xA;you can compare further readings against. Keep in mind, though, that the&#xA;ADC readings get &lt;em&gt;lower&lt;/em&gt; as the illuminance gets &lt;em&gt;higher&lt;/em&gt;. And beware&#xA;that the resistance of the pullup, and probably that of the LDR also,&#xA;can be sensitive to temperature variations. You may do a hairdryer test&#xA;to check whether it gets really bad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example code? This one is pretty trivial:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* Connect an LDR between A0 and GND. */&#xA;&#xA;void setup() {&#xA;    pinMode(A0, INPUT_PULLUP);  // enable pullup for the LDR&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(analogRead(A0));  // print out a reading&#xA;    delay(1000);                     // delay for one second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-27T13:14:24.843" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25736" PostTypeId="2" ParentId="25706" CreationDate="2016-06-27T14:20:59.047" Score="1" Body="&lt;p&gt;&lt;strong&gt;Combine&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see a lot of loose &quot;projects&quot;, but try to fit (as much as possible) into one single project. Make a line following robot, that balances, has WiFi communication and a display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Putting all the different parts together may create whole new problems/difficulties.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Stop using Arduino?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find another IDE, so it's easier to manage a lot more code.&#xA;Learn how to set up a toolchain/compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try programming an ATMega328P without Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Why?&lt;/em&gt; Because it'll learn you how to other devices work, if you're comfortable programming an AVR without Arduino, it's just a little step to using PIC microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Design yourself a PCB specific for the project you want to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Work on &quot;Professional skills&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to make some actual designs, requirement analyses and make a report on the project. This way you can practice for school/future jobs' professional skills.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;So what project should you do?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something you would really like to do.&#xA;It's as simple as that.&#xA;Something of which you think is going to be a challenge (but not too challenging).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-06-27T14:20:59.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25738" PostTypeId="1" AcceptedAnswerId="25740" CreationDate="2016-06-27T14:25:05.777" Score="1" ViewCount="562" Body="&lt;p&gt;For one of my university projects I need to detect the presence of a person in the shower. In order to do that what I have in mind is use a proximity sensor. If the target is in a distance range (let's say 20 to 50 cm) It will assume that the person is in the shower when the distance measure is no longer in this range then it will mean that the person left the shower. I need to detect all the time of the person in the shower (meaning when he/she gets in and then out). I have read a lot of info and forums to properly choose the type of sensor. However I still don't have a clear answer. About the Ultrasonic proximity sensors I know that they are cheap and more accurate by it can be affected by Temperature, humidity and some ambient noise, all of them which happen in a shower. The other option an Infrared one gets affected by lightning conditions and the surface of the target. The last option I checked is a PIR sensor I know it senses Temperature of the target, but I don't know if it will be affected by the running hot water and also is more expensive. In general, I don't know how the running hot water will affect the detection of the person in shower. Also,so again I don't know how this will work. Sorry for the huge amount of  questions, I am a little bit confuse with all the factors to have in mind. I am hoping someone out there can help a lost newbie like me and give me a suggestion. Thanks a lot :) &lt;/p&gt;&#xA;" OwnerUserId="23416" LastActivityDate="2016-06-27T15:17:05.560" Title="Selection of presence sensor" Tags="|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25740" PostTypeId="2" ParentId="25738" CreationDate="2016-06-27T15:17:05.560" Score="1" Body="&lt;p&gt;There is no one sensor that is perfect, but some are more reliable than others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, the temperature and humidity can play an important role in your sensing, and has to be taken into account. That's not to say that things like Ultrasound don't have a place in the scheme of things.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's one word you need to think about here: Correlation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If one single sensor isn't completely reliable then add a second that works in a different way. If both of them agree that there is someone in the shower (i.e., the sensors &lt;em&gt;correlate&lt;/em&gt;) then the probability that there is actually someone in the shower is considerably higher.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The great thing about a shower is you are working in a defined enclosed space. That makes it much easier and there are plenty of sensors which, when combined with others, would be quite good at reliably sensing the presence of someone in that enclosed space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some ideas:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Ultrasound above the person's head&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros: &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Simple to arrange. &lt;/li&gt;&#xA;&lt;li&gt;Safe.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons: &#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can be fooled by the water from the shower head. &lt;/li&gt;&#xA;&lt;li&gt;Steam isn't good for them.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Infra-red distance&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Accurate&lt;/li&gt;&#xA;&lt;li&gt;Can be sealed&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Expensive&lt;/li&gt;&#xA;&lt;li&gt;Harder to work with&lt;/li&gt;&#xA;&lt;li&gt;Can be blocked by steam&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Horizontal infra-red beam&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can be positioned outside the shower glass with a reflector inside&lt;/li&gt;&#xA;&lt;li&gt;Safe&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Small sensing area&lt;/li&gt;&#xA;&lt;li&gt;Can be blocked by steam&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Pressure sensor&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pros:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;People weigh more than water so is very reliable&lt;/li&gt;&#xA;&lt;li&gt;Simple to interface&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;Cons:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Hard to install safely&lt;/li&gt;&#xA;&lt;li&gt;Needs to be completely waterproof and sealed.&lt;/li&gt;&#xA;&lt;li&gt;Could be a shock hazard if not waterproof&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You notice I haven't mentioned PIR. I'm not a fan of PIR for sensing the presence of humans. They work by detecting &lt;em&gt;moving&lt;/em&gt; heat sources. If the person is moving (entering an area, walking round a room, etc) then they get detected. If the person stands still (as is often the case in a shower) it &quot;forgets&quot; they are there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of the choices above (and I am sure someone would come up with others) I would probably opt for the infra-red beam. Maybe split it into a V shape to cover more area - that is, the beam enters the side of the shower at an angle, strikes a reflector on the shower wall, and is reflected back at another angle. The detector is then placed away from the emitter. You could also have a second set to give better coverage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Infra-red distance measuring in/on the ceiling could be used to improve correlation and thus the probability that there is actually someone there. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd stay away from pressure sensing unless you can get hold of a proper waterproof pressure sensing mat designed for in-shower use. Don't try and make one yourself, waterproofing isn't an easy task, especially when people stand on it all the time.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-27T15:17:05.560" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25741" PostTypeId="2" ParentId="25733" CreationDate="2016-06-27T15:18:31.083" Score="5" Body="&lt;p&gt;You cannot close a tab in the Arduino IDE.  If a file exists in the sketch then it is there with a tab. Deleting a tab deletes the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino IDE a tab is a file and a file is a tab. You can't remove one without removing the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might like to check out my IDE, &lt;a href=&quot;http://uecide.org&quot; rel=&quot;noreferrer&quot;&gt;UECIDE&lt;/a&gt;, which deals with tabs in a more traditional manner.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-27T15:18:31.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25743" PostTypeId="2" ParentId="25706" CreationDate="2016-06-27T16:19:03.750" Score="0" Body="&lt;p&gt;Definitely try to make practical projects that make sense and are actually useful in real life. Automation projects for &quot;smarter home&quot; lets say really do come in handy and it is extremely satisfying when you use them. They don't have to be huge, just do something small that you find interesting. Documenting what you have done and keeping something like a report will help you big time in the future. &#xA;I suggest you decide if you like C++ and if you do dig deeper into it.&lt;/p&gt;&#xA;" OwnerUserId="15042" LastActivityDate="2016-06-27T16:19:03.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25744" PostTypeId="2" ParentId="25700" CreationDate="2016-06-27T16:27:47.200" Score="0" Body="&lt;p&gt;I also have a number of Arduinos running 24/7 and no problems what so ever so far. Just keep the input voltage &amp;lt; 14-15v. because higher voltage = higher temperature (in this case). &#xA;In case you need to reset your arduino in code due the long up time you can do that by connecting the reset pin to any output pin and supply logical 0 once every 24 hours for example. &lt;/p&gt;&#xA;" OwnerUserId="15042" LastActivityDate="2016-06-27T16:27:47.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25745" PostTypeId="2" ParentId="25700" CreationDate="2016-06-27T16:35:21.427" Score="-1" Body="&lt;p&gt;It &lt;strong&gt;won't be harmed&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if the code crashes, it wont reset itself, so if the code crashes, the purpose of running you Arduino 24/7 will defeat itself.&lt;/p&gt;&#xA;" OwnerUserId="23419" LastActivityDate="2016-06-27T16:35:21.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25746" PostTypeId="1" CreationDate="2016-06-27T17:22:28.187" Score="0" ViewCount="3041" Body="&lt;p&gt;I am trying to use FreeRTOS's vTaskDelay() function in order to periodically execute tasks.  The latest version of FreeRTOS came with the &quot;tick&quot; time set to 15 ms. Therefore, the smallest resolution I can delay for is 15 ms. I would like to lower this resolution to at least 1 ms.  Is it possible to configure FreeRTOS in this way?  I found this answer online : &lt;a href=&quot;http://www.freertos.org/FreeRTOS_Support_Forum_Archive/November_2012/freertos_Problem_changing_Tick_time_from_1ms_to_10ms_6231539.html&quot; rel=&quot;nofollow&quot;&gt;http://www.freertos.org/FreeRTOS_Support_Forum_Archive/November_2012/freertos_Problem_changing_Tick_time_from_1ms_to_10ms_6231539.html&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for me, the configTICK_RATE_HZ is not defined and it seems to be using a watchdog timer to enforce the 15 ms resolution. I think the forums are referring to an earlier version.&lt;/p&gt;&#xA;" OwnerUserId="23422" LastActivityDate="2023-01-05T01:31:33.090" Title="Changing the tick time in FreeRTOS" Tags="|programming|arduino-ide|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25748" PostTypeId="2" ParentId="21444" CreationDate="2016-06-27T18:28:06.340" Score="1" Body="&lt;p&gt;The ball moves are made by a simple physics principle called Conservation of Angular Momentum. The angular momentum is a property that has any object that rotates and is proportional to its mass and velocity.&#xA;To make a ball move you should play with this momentum, using its simplest application, the mechanical gyroscope.&#xA;The mechanical gyro is made of a heavy disc rotating at high speed, modulating its velocity you can change the momentum and create a force that will move your sphere. &lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-06-27T18:28:06.340" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25749" PostTypeId="2" ParentId="25502" CreationDate="2016-06-27T18:33:27.480" Score="1" Body="&lt;p&gt;Use a gyro, it will give you the angle. Gyros are difficult to find spare, so you should buy an IMU like MPU6050 that contains also an accelerometer.&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-06-27T18:33:27.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25750" PostTypeId="2" ParentId="25112" CreationDate="2016-06-27T18:37:58.590" Score="1" Body="&lt;p&gt;You should use arduino as an ftp client, then stream the csv file to the site in binary mode. You should find examples on the web.&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-06-27T18:37:58.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25751" PostTypeId="2" ParentId="564" CreationDate="2016-06-27T20:24:47.090" Score="1" Body="&lt;p&gt;I say get a weight sensor, and program it for the roll's weight. When it drops below a certain weight, start flashing an LED or make a beep. &lt;/p&gt;&#xA;" OwnerUserId="23385" LastActivityDate="2016-06-27T20:24:47.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25752" PostTypeId="1" AcceptedAnswerId="25756" CreationDate="2016-06-27T21:06:41.993" Score="2" ViewCount="8068" Body="&lt;p&gt;I have a sensor that communicates via serial communication. &lt;a href=&quot;http://ctisensors.com/wp-content/uploads/2016/03/TILT-05-UserManual-01b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;CTi Sensors TILT-05&lt;/a&gt;. It transmits an ASCII string with data separated by commas. I want to be able to read the incoming ASCII data in the Arduino IDE's Serial Monitor in real time (the device is an accelerometer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am struggling to convey this in the code. Currently, I have the sensor's RX connected to an Arduino Uno's TX port (digital 1) and sensor TX-&gt; Arduino RX (digital 0). The sensor is powered and grounded via the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched for serial communication methods but can't find any that seem to work. How can I receive and interpret the incoming data from the sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FIZ8K.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FIZ8K.jpg&quot; alt=&quot;Basic setup. Not complicated at all, just need some clarification.&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/rKT4n.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rKT4n.jpg&quot; alt=&quot;Closer view of the connections.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23427" LastEditorUserId="2944" LastEditDate="2016-06-29T10:17:47.820" LastActivityDate="2019-01-10T08:03:21.470" Title="How do I communicate with a sensor via an Arduino's RX/TX ports?" Tags="|serial|sensors|communication|accelerometer|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25753" PostTypeId="1" AcceptedAnswerId="25754" CreationDate="2016-06-27T20:59:09.063" Score="1" ViewCount="88" Body="&lt;p&gt;I have 12 arduinos, each of them controlling some simple hardware peripherals. I want to interact with all of them over 1 USB connection to my laptop, where I have a python program communicating over serial. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following seems like it could work: &lt;a href=&quot;https://www.amazon.ca/Satechi-Power-Adapter-Control-Switches/dp/B0051PGX2I&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.ca/Satechi-Power-Adapter-Control-Switches/dp/B0051PGX2I&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there any electrical/other considerations to take into account for why this would/wouldn't work? &lt;/p&gt;&#xA;" OwnerUserId="13415" OwnerDisplayName="JDS" LastActivityDate="2016-06-27T21:06:42.333" Title="Can I connect and control 12 Arduino's over USB/serial to my laptop?" Tags="|power|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25754" PostTypeId="2" ParentId="25753" CreationDate="2016-06-27T21:03:49.077" Score="3" Body="&lt;p&gt;From a technical standpoint, USB can host up to 127 devices, so 12 Arduino boards is certainly not pushing the limit. Having 12 serial ports shouldn't be an issue in either Linux or Windows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From a practical standpoint, you will have to find a powered USB hub which can support that many devices, or plug multiple hubs together. I'll leave that up to you as shopping recommendations are off topic.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In terms of the hub you use, you need to make sure you don't exceed its maximum current rating. The Arduino boards draw typically around 60-100mA alone. 12 of those and you will need at least 1.2A rating. The hub you mentioned says that it cannot exceed 2A. Depending on what other circuitry you attach to your Arduino boards you may need an external power supply for the boards.&lt;/p&gt;&#xA;" OwnerUserId="6860" OwnerDisplayName="Tom Carpenter" LastActivityDate="2016-06-27T21:03:49.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25756" PostTypeId="2" ParentId="25752" CreationDate="2016-06-27T22:39:16.947" Score="1" Body="&lt;p&gt;You don't mention the sensor brand or a datasheet so this will be a very general answer to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Firstly, how you have the sensor connected now should just spool info into the Serial monitor of the Arduino IDE without any code on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What are the data speed and the exact way the Serial comes out from the sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to interpret the data as it is coming through you should use Software Serial as you can't relay info to the PC with an Arduino's RX TX lines connected to something else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you can do is below(&lt;strong&gt;&lt;em&gt;Untested&lt;/em&gt;&lt;/strong&gt;):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySer(3, 4); //RX TX&#xA;&#xA;//these are char areay because its from Serial&#xA;char accel[3] = {'0'};&#xA;uint8_t place = 0;&#xA;&#xA;// array to print in sync with the accelerometer values array&#xA;const char* SerialText[3] = {&#xA;   &quot;\nX Axis: &quot;,&#xA;   &quot;\nY Axis: &quot;,&#xA;   &quot;\nZ Axis: &quot;,&#xA;};&#xA;&#xA;&#xA;char inData = '0';&#xA;char separator = ','; // separator you described&#xA;&#xA;&#xA;&#xA;void setup(){&#xA;//set to the normal baud, mines for the example&#xA;     Serial.begin(9600); &#xA;&#xA;     mySer.begin(9600);&#xA;&#xA;}//~ end setup&#xA;&#xA;void loop(){&#xA;&#xA;    if(mySer.available()){&#xA;&#xA;     inData = mySer.read(); // get the value at the instance of the serial data being there&#xA;&#xA;        if(inData != separator){&#xA;          accel[place] = inData;&#xA;          Serial.print(SerialText[place]); // print the current values identifier&#xA;          Serial.print(accel[place]); // print value&#xA;          place++; // increment for the next time&#xA;     }&#xA;   }&#xA;&#xA;if(place &amp;gt;= 3) place = 0;&#xA;}//~ end loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above gives this output at the moment, with an input of &lt;code&gt;$CSACC,-0156.4,-0226.3,+0981.2*49&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;X Axis: $&#xA;Y Axis: C&#xA;Z Axis: S&#xA;X Axis: A&#xA;Y Axis: C&#xA;Z Axis: C&#xA;X Axis:  &#xA;Y Axis: -&#xA;Z Axis:  &#xA;X Axis: 0&#xA;Y Axis: 1&#xA;Z Axis: 5&#xA;X Axis: 6&#xA;Y Axis: .&#xA;Z Axis: 4&#xA;X Axis:  &#xA;Y Axis: -&#xA;Z Axis:  &#xA;X Axis: 0&#xA;Y Axis: 2&#xA;Z Axis: 2&#xA;X Axis: 6&#xA;Y Axis: .&#xA;Z Axis: 3&#xA;X Axis: +&#xA;Y Axis: 0&#xA;Z Axis: 9&#xA;X Axis: 8&#xA;Y Axis: 1&#xA;Z Axis: .&#xA;X Axis: 2&#xA;Y Axis: *&#xA;Z Axis: 4&#xA;X Axis: 9&#xA;Y Axis:  &#xA;Z Axis: &#xA;X Axis: &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code doesn't filter this the way it should but is a stepping stone. I will update it to do it properly when I have a chance.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="2944" LastEditDate="2016-06-28T11:01:35.410" LastActivityDate="2016-06-28T11:01:35.410" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25757" PostTypeId="2" ParentId="22414" CreationDate="2016-06-27T23:00:09.333" Score="0" Body="&lt;p&gt;&lt;a href=&quot;https://github.com/tmk/tmk_keyboard&quot; rel=&quot;nofollow&quot;&gt;https://github.com/tmk/tmk_keyboard&lt;/a&gt; is what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Search in Adafruit's site for how to incorporate Bluefruit.&lt;/p&gt;&#xA;" OwnerUserId="10024" LastActivityDate="2016-06-27T23:00:09.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25758" PostTypeId="1" CreationDate="2016-06-27T23:18:43.840" Score="2" ViewCount="5848" Body="&lt;p&gt;I want to use my arduino to turn a light off for 16 hours and on for 8 hours. I know the general code, just using delays and the relay shield code as well. I want to know how accurate this will be? ( I tagged uno and leonardo, as I have access to both)&lt;/p&gt;&#xA;" OwnerUserId="23282" LastEditorUserId="23282" LastEditDate="2016-06-27T23:23:46.200" LastActivityDate="2017-03-13T01:29:09.113" Title="How accurate is arduino time keeping?" Tags="|arduino-uno|sensors|arduino-leonardo|timers|" AnswerCount="7" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25759" PostTypeId="2" ParentId="25758" CreationDate="2016-06-27T23:29:43.180" Score="0" Body="&lt;p&gt;Not very.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that kind of period of timing you are far better off using a Real Time Clock (RTC) module.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-27T23:29:43.180" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25760" PostTypeId="2" ParentId="25752" CreationDate="2016-06-27T23:31:52.917" Score="0" Body="&lt;p&gt;With RSM's help I've managed to get the sensor reading into the serial monitor semi-reliably. I have yet to solder the headers onto the sensor yet and am just doing prototyping (basically just me pushing a wire against the sensor output hole) which is unreliable. I believe once I get some headers soldered on the output will be much more reliable. For those searching, this code worked for me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Digital pins 3/4 function as your RX/TX pins respectively. Connect the TX of your sensor to the RX (3) of the Arduino and likewise for the TX. I used a baud rate of 115200 but you can change it to whatever works in the code. This is simply a simplification of RSM's code in his previous answer and all credit/kudos goes to him.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial mySer(3, 4);&#xA;&#xA;char inData = '0';&#xA;&#xA;void setup(){&#xA;     Serial.begin(115200); &#xA;      mySer.begin(115200);&#xA;}&#xA;&#xA;void loop(){&#xA;    if(mySer.available()){&#xA;     inData = mySer.read(); &#xA;     Serial.print(inData);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23427" LastActivityDate="2016-06-27T23:31:52.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25761" PostTypeId="2" ParentId="25758" CreationDate="2016-06-28T00:43:01.087" Score="1" Body="&lt;p&gt;There are multiple versions and &quot;clones&quot; of the Arduino, and each one will probably use different components. The time you refer, in this case &quot;millis()&quot; I believe, is maintained from a timer interrupt, which is derived from the main clock (normally 16Mhz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main clock on your board might be generated by a ceramic resonator, which is not very accurate: around 0.5%-1% error. It also might be from good quartz crystal, with up to 0.001% accuracy. Those variations on the frequency source will produce some drift over time... Like your watch needs to be readjusted from time to time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another factor that affects accuracy, including for RTCs using a 32.768KHz crystal, is the temperature. Here an Application Note on this: &lt;a href=&quot;http://www.st.com/content/ccc/resource/technical/document/application_note/55/e2/3d/2a/87/ab/4d/e1/CD00232494.pdf/files/CD00232494.pdf/jcr:content/translations/en.CD00232494.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.st.com/content/ccc/resource/technical/document/application_note/55/e2/3d/2a/87/ab/4d/e1/CD00232494.pdf/files/CD00232494.pdf/jcr:content/translations/en.CD00232494.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your application might not require too much precision, and you could simply write a sketch to print the time every second on the serial... let it run from one hour, one day, and check how much drift you're getting. After that will be easy to estimate how much drift you'll have a after a month.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="16417" LastEditDate="2016-06-28T11:00:37.670" LastActivityDate="2016-06-28T11:00:37.670" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25762" PostTypeId="2" ParentId="18319" CreationDate="2016-06-28T01:14:47.637" Score="1" Body="&lt;p&gt;This is speculation as it may be nearly impossible for any given person to simulate your network (for example, not only the version of Windows you are running but all the drivers installed and hardware specific to your Ethernet interface ... to only mention a few variables).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Wireshark&quot; rel=&quot;nofollow&quot;&gt;network monitor&lt;/a&gt; to capture all communications set out by the Windows computer.  Consider the Windows computer occasionally failing your network.  Consider the delay you experience may be the time it takes for Windows to recover from what it thinks is a bad network.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The observation is that Windows sends out many autonomous messages over a new network in a &quot;discovery&quot; mode.  The suspicion is that the lack of response to some or all of these messages will result in Windows failing a network.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Windows does have ways of reporting the status of networks that vary with the version of Windows. But these methods (menus) can be frustrating to use as they don't appear to update often enough to reflect the true behavior of traffic coming out of the Windows computer.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless, test if the state of the network is always good.  Also, test if connecting equipment Windows might expect on a functioning network (for example, a router with a DHCP server) improves the response time.  This, as an effort / test to determine if Windows is more responsive while connected to a healthy / active network.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-28T01:14:47.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25763" PostTypeId="2" ParentId="25758" CreationDate="2016-06-28T03:06:22.903" Score="1" Body="&lt;p&gt;By definition, the Arduino is as accurate as it's crystal clock/resonator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This clock runs at approximately 16mhz for an Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's internal time is just a count of how many times this crystal has vibrated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;READ THIS!&lt;/strong&gt; - these next two paragraph are apparently &lt;strong&gt;incorrect&lt;/strong&gt;. See Nick Gammon's comment below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The crystal in question is approximately like this one: &lt;a href=&quot;https://www.sparkfun.com/products/536&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/536&lt;/a&gt; - this one from SparkFun is accurate to 50 ppm - that's parts per million. So, if your Arduino has that EXACT crystal, it may lose or gain 50 parts per million - in a million seconds, it would count somewhere between 999,950 and 1,000,050 seconds. This would mean you gain/lose less than 4.3 seconds per day, or 2 minutes per month.&#xA;  If you find the crystal on your board, google the code (probably something like 16.000N, for the Sparkfun one), which should tell you exactly what the accuracy is for that chip. Note that, if you can find the datasheet, it should tell you the accuracy, at particular temperatures - as the temperature goes up and down, the error will change too.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Remember also that an Arduino's clock is in volatile memory - that is, if you power down the Arduino, and power it back up, it has no idea what time it is - you would need to set the clock again, either by connecting it to a PC, network, or via buttons/display on your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a number of alternatives, depending on your need, to work around this: you can get the data from LAN or WIFI, if your project has that, or you can use a RTC module - you need to set this to the correct time once, then it will remember after that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you can use a light-dependent resistor (aka photoresistor), and trigger automatically when it gets dark. This may trigger when it gets dark for some other reason, e.g. a storm, which may or may not be an advantage.&lt;/p&gt;&#xA;" OwnerUserId="6740" LastEditorUserId="6740" LastEditDate="2017-03-13T01:29:09.113" LastActivityDate="2017-03-13T01:29:09.113" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="25765" PostTypeId="1" AcceptedAnswerId="25769" CreationDate="2016-06-28T03:56:20.570" Score="0" ViewCount="1162" Body="&lt;p&gt;I'm writing a library, and that library .cpp/.h code is in devel/arduino/libraries/LightBrightLib/.  I have test code that calls that library, and an example program using the library.  Right now they're in /devel/arduino/lightbright/LightBrightMain/ and /devel/arduino/lightbright/LightBrightLibTest/.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see most libraries have an examples directory inside the library, so I tried moving mine to /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/ and /devel/arduino/libraries/LightBrightLib/examples/LightBrightLibTest/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I do that, and try to save my LightBrightMain.ino file into /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/, it says &quot;You cannot save a sketch into a folder inside itself. This would go on forever.&quot;.  And of course it won't let me select the examples directory or any other directory above it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do other library makers do this?  Maybe they don't use the IDE, or they copy it in outside the IDE, or use symlinks?&#xA;What does the IDE think it's doing and why is it fighting putting the file where it already is? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE: This is not a file permission problem as I own all files&lt;/p&gt;&#xA;" OwnerUserId="21571" LastActivityDate="2016-06-28T04:35:23.070" Title="Saving library example sketch getting error &quot;you cannot save a sketch into a folder inside itself..&quot;" Tags="|programming|arduino-ide|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25767" PostTypeId="1" CreationDate="2016-06-28T04:14:51.247" Score="0" ViewCount="4340" Body="&lt;p&gt;The code is very messy. We have an L293D circuit which has two enable pins always on. We also have an LDR light sensor with two light resistors, one on the left and one on the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are trying to make a line following robot&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are ambitious high school students.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// Use this code to test your motor with the Arduino board:&#xA;&#xA;// if you need PWM, just use the PWM outputs on the Arduino&#xA;// and instead of digitalWrite, you should use the digitalWrite command&#xA;&#xA;&#xA;// --------------------------------------------------------------------------- Setup&#xA;void setup() {&#xA;{Serial.begin(9600);&#xA;&#xA;// --------------------------------------------------------------------------- Motors&#xA;int motor_left[] = {2, 7};&#xA;int motor_right[] = {10, 15};&#xA;int LDR = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0&#xA;int LDRValue = 0;      //that’s a variable to store LDR values&#xA;int light_sensitivity = 500;    //This is the approx value of light surrounding your LDR&#xA;int LDR2 = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0&#xA;int LDR2Value = 0;      //that’s a variable to store LDR values&#xA;int light_sensitivity2 = 500;    //This is the approx value of light surrounding your LDR&#xA;int i;&#xA;for(i = 0; i &amp;lt; 2; i++){&#xA;pinMode(motor_left[i], OUTPUT);&#xA;pinMode(motor_right[i], OUTPUT);&#xA;LDRValue = analogRead(LDR);     &#xA;    Serial.println(LDRValue);      &#xA;&#xA;&#xA;    if (LDRValue &amp;lt; light_sensitivity); &#xA;    Serial.println(&quot;wat&quot;);&#xA;&#xA;&#xA;}&#xA;// --------------------------------------------------------------------------- Loop&#xA;&#xA;&#xA;// --------------------------------------------------------------------------- Drive&#xA;&#xA;void motor_stop(){&#xA;digitalWrite(motor_left[0], LOW); &#xA;digitalWrite(motor_left[1], LOW); &#xA;&#xA;digitalWrite(motor_right[0], LOW); &#xA;digitalWrite(motor_right[1], LOW);&#xA;delay(25);&#xA;}&#xA;&#xA;void drive_forward(){&#xA;digitalWrite(motor_left[0], HIGH); &#xA;digitalWrite(motor_left[1], LOW); &#xA;&#xA;digitalWrite(motor_right[0], HIGH); &#xA;digitalWrite(motor_right[1], LOW); &#xA;}&#xA;&#xA;void drive_backward(){&#xA;digitalWrite(motor_left[0], LOW); &#xA;digitalWrite(motor_left[1], HIGH); &#xA;&#xA;digitalWrite(motor_right[0], LOW); &#xA;digitalWrite(motor_right[1], HIGH); &#xA;}&#xA;&#xA;void turn_left(){&#xA;digitalWrite(motor_left[0], LOW); &#xA;digitalWrite(motor_left[1], HIGH); &#xA;&#xA;digitalWrite(motor_right[0], HIGH); &#xA;digitalWrite(motor_right[1], LOW);&#xA;}&#xA;&#xA;void turn_right(){&#xA;digitalWrite(motor_left[0], HIGH); &#xA;digitalWrite(motor_left[1], LOW); &#xA;&#xA;digitalWrite(motor_right[0], LOW); &#xA;digitalWrite(motor_right[1], HIGH); &#xA;}&#xA;void loop() {&#xA;drive_forward();&#xA;delay(1000);&#xA;motor_stop();&#xA;Serial.println(&quot;1&quot;);&#xA;&#xA;drive_backward();&#xA;delay(1000);&#xA;motor_stop();&#xA;Serial.println(&quot;2&quot;);&#xA;&#xA;turn_left();&#xA;delay(1000);&#xA;motor_stop();&#xA;Serial.println(&quot;3&quot;);&#xA;&#xA;turn_right();&#xA;delay(1000);&#xA;motor_stop();&#xA;Serial.println(&quot;4&quot;); &#xA;&#xA;motor_stop();&#xA;delay(1000);&#xA;motor_stop();&#xA;Serial.println(&quot;5&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23432" LastEditorUserId="10794" LastEditDate="2016-06-28T04:25:07.053" LastActivityDate="2016-06-28T04:31:30.007" Title="Arduino Robot. a function-definition is not allowed here before '{' token" Tags="|programming|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25768" PostTypeId="2" ParentId="25767" CreationDate="2016-06-28T04:31:30.007" Score="2" Body="&lt;p&gt;You need to look more closely at your braces. Use the auto-format tool (Ctrl+T) to help you. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup() {&#xA;{Serial.begin(9600);&#xA;&#xA;// --------------------------------------------------------------------------- Motors&#xA;int motor_left[] = {2, 7};&#xA;int motor_right[] = {10, 15};&#xA;int LDR = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0&#xA;int LDRValue = 0;      //that’s a variable to store LDR values&#xA;int light_sensitivity = 500;    //This is the approx value of light surrounding your LDR&#xA;int LDR2 = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0&#xA;int LDR2Value = 0;      //that’s a variable to store LDR values&#xA;int light_sensitivity2 = 500;    //This is the approx value of light surrounding your LDR&#xA;int i;&#xA;for(i = 0; i &amp;lt; 2; i++){&#xA;pinMode(motor_left[i], OUTPUT);&#xA;pinMode(motor_right[i], OUTPUT);&#xA;LDRValue = analogRead(LDR);     &#xA;    Serial.println(LDRValue);      &#xA;&#xA;&#xA;    if (LDRValue &amp;lt; light_sensitivity); &#xA;    Serial.println(&quot;wat&quot;);&#xA;&#xA;&#xA;}   // &amp;lt;------------------------------------ HERE &#xA;&#xA;// --------------------------------------------------------------------------- Loop&#xA;&#xA;&#xA;// --------------------------------------------------------------------------- Drive&#xA;&#xA;void motor_stop(){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where I marked &quot;HERE&quot; you are closing the &lt;code&gt;for&lt;/code&gt; loop but you should also be closing &lt;code&gt;setup&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also have two opening braces here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;{Serial.begin(9600);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Proper indentation is &lt;strong&gt;very helpful&lt;/strong&gt; for sorting out these sorts of issues.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-28T04:31:30.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25769" PostTypeId="2" ParentId="25765" CreationDate="2016-06-28T04:35:23.070" Score="0" Body="&lt;p&gt;What I normally do is make the examples in their own folders (ie. inside the sketchbook folder). Then when they are tested I just use the file system to move the folders into the &quot;examples&quot; folder under the library.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When I do that, and try to save my LightBrightMain.ino file into /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/,&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The IDE makes the folder, so you would (if this works at all) save &lt;code&gt;LightBrightMain&lt;/code&gt; into the &lt;code&gt;examples&lt;/code&gt; folder. Don't make a folder of the same name as the sketch. The IDE does that.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-28T04:35:23.070" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25770" PostTypeId="1" AcceptedAnswerId="25787" CreationDate="2016-06-28T04:45:17.760" Score="1" ViewCount="9817" Body="&lt;p&gt;I'm trying to clear my EEPROM and am using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;void setup()&#xA;{&#xA;// write a 0 to all 4096 bytes of the EEPROM&#xA;for (int i = 0; i &amp;lt; 4096; i++)&#xA;EEPROM.write(i, 0);&#xA;&#xA;delay(9999999);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't see a problem with it but it is ineffective.  Am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2019-11-27T02:42:52.043" Title="Clearing EEPROM" Tags="|c++|eeprom|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25771" PostTypeId="2" ParentId="25758" CreationDate="2016-06-28T04:48:03.663" Score="1" Body="&lt;p&gt;I made a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12106&quot; rel=&quot;nofollow&quot;&gt;temperature and humidity sensor&lt;/a&gt; in August 2013. It uses a RTC chip (DS1307) which you can buy on eBay for $1 if not less. It has a battery backup (lithium cell).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't recall ever resetting the clock on it. It is now about 3 years later, and it is running about 11 minutes slow. This would be an acceptable error for something like turning garden lights on and off. Even for taking the temperature, a few minutes out when logging a reading is probably not going to matter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the internal clock probably won't be as accurate, but could be OK in this case. I suggest you follow Chris Stratton's suggestion and code so that errors are not cumulative. For example, if you delay for an hour, and then do something, make sure that the &quot;do something&quot; isn't added to the next delay time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want super accuracy (sounds like you don't) then connecting up a GPS module lets you query the exact time from the satellite, which could cut the error down to negligible amounts. Those GPS modules however aren't cheap.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Something to consider if you try to make do with the internal clock is: what happens if the power goes off? Then it loses track of when to turn the lights on and off. A clock chip however (usually) has a battery backup, and will &quot;know the time&quot; once the power comes back on.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-06-28T04:48:03.663" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25775" PostTypeId="1" CreationDate="2016-06-28T07:43:21.660" Score="7" ViewCount="21230" Body="&lt;p&gt;Here's the code that's making this error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;Wire.h&amp;quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here's the error:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fatal error: Wire.h: No such file or directory&#xA; #include &amp;quot;Wire.h&amp;quot;&#xA;                  ^&#xA;compilation terminated.&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also can't include any file from my &lt;code&gt;Arduino\libraries&lt;/code&gt; folder. I tried to reinstall the IDE several times in different places and nothing happened. Why is this happening?&lt;/p&gt;&#xA;&lt;p&gt;EDIT: after some time I discovered that this error occurs in header files only, not in sketches!&lt;/p&gt;&#xA;" OwnerUserId="23104" LastEditorUserId="4628" LastEditDate="2023-11-22T01:40:09.680" LastActivityDate="2023-11-22T01:40:09.680" Title="Wire.h not found!" Tags="|arduino-ide|library|wire-library|core-libraries|" AnswerCount="4" CommentCount="9" ContentLicense="CC BY-SA 4.0" />
  <row Id="25777" PostTypeId="2" ParentId="25460" CreationDate="2016-06-28T08:33:28.723" Score="1" Body="&lt;p&gt;I was able to communicate Arduino UNO and HM-10. Whenever one writes a characteristic on BLE using Android application, the exact bytes are transmitted to &lt;strong&gt;Tx/Rx channel&lt;/strong&gt; to Arduino and can be read using &lt;strong&gt;SoftwareSerial&lt;/strong&gt; Arduino library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CurieBLE library works on Genuino/Arduino 101 board which has Intel Curie Module.&lt;/p&gt;&#xA;" OwnerUserId="23050" LastActivityDate="2016-06-28T08:33:28.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25779" PostTypeId="1" AcceptedAnswerId="25784" CreationDate="2016-06-28T10:34:29.267" Score="2" ViewCount="6502" Body="&lt;p&gt;Is there by any chance a shield that can take an 4G LTE compatible SIM card activated by a carrier and establish a connection?&lt;/p&gt;&#xA;" OwnerUserId="23440" LastEditorUserId="11763" LastEditDate="2016-06-29T22:16:27.040" LastActivityDate="2020-01-29T23:45:16.737" Title="Arduino 4G LTE Shield" Tags="|shields|gsm|networking|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25782" PostTypeId="1" CreationDate="2016-06-28T12:44:18.267" Score="0" ViewCount="462" Body="&lt;p&gt;I'm here because I couldn't find any answer anywhere and the problem seems pretty easy and hard in a same time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a website, for exemple : My_website.host.fr&#xA;I have arduino's sensors at home, for exemple temperature sensor in my garage, servomotor in shutter, etc... with Wifi-module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to, as a User, access the website, update some information on the website, for exemple : I want the shutter down, so I put it to 0 on the website, and the arduino will, for exemple each X seconds check if the value has changed, if it does then it updates itself and so lower the shutter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, by this, i'll never have to connect directly through an @ip to my arduino, without hosting a server at home which could be hacked or anything, the arduino update itself with the infos that are on the website,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So from my arduino I must ? I have no idea, get the source code of the web page and search for some value, or, from the web page, update a file with PHP variables and retrieve that file with my arduino then read it for the values ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it's clear tho and I have no idea how to manage it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry about the bad english sentence or words, not main language;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank for the help i'm kind of lost.&lt;/p&gt;&#xA;" OwnerUserId="23442" LastActivityDate="2016-12-31T13:11:45.540" Title="Arduino and a Web Server" Tags="|web|http|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25783" PostTypeId="2" ParentId="25782" CreationDate="2016-06-28T13:42:34.257" Score="1" Body="&lt;p&gt;I believe the term you want to search on is &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Web_scraping&quot; rel=&quot;nofollow&quot;&gt;web scraping&lt;/a&gt;&quot;.  Assuming you are fine with people knowing the state of &quot;things&quot; in your home, you can simply leave the states up on your public web page.  That is, you click on a button on your web page and change the text from &quot;shutter up&quot; to &quot;shutter down&quot;.  Mean while, your Arduino is &quot;web scraping&quot; the same page looking for &quot;shutter&quot; and acting on the next word &quot;up&quot; or &quot;down&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;http://www.rogerclark.net/arduino-ethercard-web-scraping/&quot; rel=&quot;nofollow&quot;&gt;this blog&lt;/a&gt;, someone has posted his Arduino &quot;web scrapping&quot; code.  I have not tried it, so do some research before considering this particular solution.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-28T13:42:34.257" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25784" PostTypeId="2" ParentId="25779" CreationDate="2016-06-28T13:46:11.210" Score="1" Body="&lt;p&gt;Googling &quot;4g shield arduino&quot; gave &lt;a href=&quot;https://www.cooking-hacks.com/4g-gps-3g-gprs-gsm-gps-lte-wcdma-hspa-shield-for-arduino&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. It will need a 4G LTE capable SIM, but I guess &quot;it depends&quot; if &lt;em&gt;any&lt;/em&gt; 4G LTE SIM will work.. &lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-06-28T13:46:11.210" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25785" PostTypeId="2" ParentId="25770" CreationDate="2016-06-28T13:50:36.177" Score="0" Body="&lt;p&gt;Thank you all for helping me out.  This is what I ended up using (ESP8266 1.0 12E with Arduino IDE):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  EEPROM.begin(512);&#xA;  delay(5000);&#xA;  Serial.println(&quot;clearing EEPROM...&quot;);&#xA;  // write a 0 to first 1000 bytes of the EEPROM&#xA;  for (int i = 0; i &amp;lt; 1000; ++i) {&#xA;    EEPROM.write(i, -1);&#xA; }&#xA;  EEPROM.commit();&#xA;  delay(5000);&#xA;  Serial.println(&quot;Reading EEPROM ssid&quot;);&#xA;  String esid;&#xA;  for (int i = 0; i &amp;lt; 64; ++i)&#xA;  {&#xA;    esid += char(EEPROM.read(i));&#xA;  }&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(esid);&#xA;  Serial.println(&quot;Reading EEPROM pass&quot;);&#xA;  String epass = &quot;&quot;;&#xA;  for (int i = 64; i &amp;lt; 128; ++i)&#xA;  {&#xA;    epass += char(EEPROM.read(i));&#xA;  }&#xA;  Serial.print(&quot;PASS: &quot;);&#xA;  Serial.println(epass);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's probably longer than it has to be but I pulled stuff from other sketches I've worked on and prioritize function over form.  This writes a &quot;-1&quot; to the first 1000 bytes and then prints the first 128 bytes.  Since I am only concerned about the first 50 bytes or so this was sufficient for my needs.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-06-28T13:50:36.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25786" PostTypeId="2" ParentId="25746" CreationDate="2016-06-28T13:55:17.670" Score="2" Body="&lt;p&gt;See the &lt;a href=&quot;http://www.freertos.org/a00110.html#configTICK_RATE_HZ&quot; rel=&quot;nofollow&quot;&gt;configTICK_RATE_HZ&lt;/a&gt; configuration option.&#xA;Also note it is better to specify times in milliseconds, rather than ticks, so you can change the tick frequency without effecting the timing (other than the resolution of the time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;pdMS_TO_TICKS()&lt;/code&gt; macro can be used for that purpose, for example to create a delay of 100ms.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const TickType_t xBlockTime = pdMS_TO_TICKS( 100 );&#xA;vTaskDelay( xBlockTime );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23444" LastEditorUserId="19515" LastEditDate="2016-06-29T10:18:23.057" LastActivityDate="2016-06-29T10:18:23.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25787" PostTypeId="2" ParentId="25770" CreationDate="2016-06-28T14:01:59.030" Score="2" Body="&lt;p&gt;The tutorial &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/EEPROMClear&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; is very clear about how to clear the contents of the Atmel's EEPROM.  I only see 2 major difference.  The tutorial finds the size of the EEPROM through a function call.  Probably much safer.  And there is no call to a delay() function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The tutorial does include lighting up an LED when finished.  And @Edgar Bonet is correct that erasing an EEPROM (altering each &lt;a href=&quot;https://en.wikipedia.org/wiki/Floating-gate_MOSFET&quot; rel=&quot;nofollow&quot;&gt;floating gate&lt;/a&gt; with in the chip) does take time.  And you have no way to known when the EEPROM clearing is finished in your code.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is possible you are forcing your code to stop before it is finished.  In which case it would appear the EEPROM is not completely cleared.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-28T14:01:59.030" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25789" PostTypeId="1" AcceptedAnswerId="25963" CreationDate="2016-06-28T14:50:00.013" Score="0" ViewCount="72" Body="&lt;p&gt;I have written a simple sketch that takes values via serial communication through a Python script.&lt;br&gt;&#xA;Here's the code- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LEDPin 13  &#xA;&#xA;void setup() {&#xA;Serial.begin(9600); &#xA;pinMode(LEDPin, OUTPUT);&#xA;Serial.println(&quot;Ready&quot;); &#xA;}&#xA;&#xA;void loop() {&#xA;char inByte = ' ';&#xA;if(Serial.available()){ &#xA; inByte = Serial.read();&#xA;}&#xA;if (inByte == 'L')&#xA; digitalWrite(LEDPin, HIGH);&#xA;if (inByte == 'R')&#xA; digitalWrite(LEDPin, HIGH);&#xA;if (inByte == 'S')&#xA; digitalWrite(LEDPin, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now this code runs perfectly fine with my python script. No problems at all. But When I add code for my L293D motor driver module, like this - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int E1 = 6;&#xA;int Left= 5;&#xA;int Right = 4;&#xA;char data = ' ';&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(E1, OUTPUT); &#xA;  pinMode(Left, OUTPUT);  &#xA;  pinMode(Right, OUTPUT);&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.begin(9600);&#xA;&#xA;  }&#xA;&#xA;  void loop(){&#xA;    if (Serial.available()&amp;gt;0){&#xA;      data = Serial.read();&#xA;    }&#xA;    if (data =='L'){&#xA;      digitalWrite(E1, HIGH);&#xA;      digitalWrite(Left, HIGH);&#xA;      delay(2000);&#xA;      digitalWrite(Left, LOW);&#xA;      digitalWrite(E1, LOW);&#xA;      digitalWrite(13, HIGH);&#xA;    }&#xA;     if (data == 'R') {&#xA;      digitalWrite(E1, HIGH);&#xA;      digitalWrite(Right, HIGH);&#xA;      delay(2000);&#xA;      digitalWrite(Right, LOW);&#xA;      digitalWrite(E1, LOW);&#xA;      digitalWrite(13, HIGH);&#xA;    }&#xA;     if(data == 'S'){&#xA;      digitalWrite(E1,LOW);&#xA;      digitalWrite(Right, LOW);&#xA;      digitalWrite(Left, LOW);&#xA;      digitalWrite(13, LOW);&#xA;    }&#xA;&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this code added, the sketch, takes the first value it recieves, for example L, and then would go on executing the if block for that particular value &lt;strong&gt;ONLY&lt;/strong&gt;. Even if the valueschange, still the same code block gets repeated. If I reset the Arduino, using the reset button, again the first value it recieves it starts executing the conditions of the same value and not the rest of the sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S- I have attached the capacitor between the pins 5v and RESET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I put &lt;code&gt;ser.readline()&lt;/code&gt; in my python script and found that no matter what the script only sends S to the Arduino. Even if the other two conditions are being satisfied, only S is send, and then suddenly, either L or R will be sent and then thats it. No more sending from the script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my script-&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import numpy as np&#xA;import cv2&#xA;import serial&#xA;ser = serial.Serial('COM3',9600,writeTimeout = 0)&#xA;def f(x): return&#xA;cv2.namedWindow('Thresholding Control')&#xA;&#xA;# create trackbars for color change&#xA;cv2.createTrackbar('High H','Thresholding Control',179,179, f)&#xA;cv2.createTrackbar('Low H','Thresholding Control',0,179, f)&#xA;cv2.createTrackbar('High S','Thresholding Control',255,255, f)&#xA;cv2.createTrackbar('Low S','Thresholding Control',0,255, f)&#xA;cv2.createTrackbar('High V','Thresholding Control',255,255, f)&#xA;cv2.createTrackbar('Low V','Thresholding Control',0,255, f)&#xA;cv2.createTrackbar('Guassian Blur','Thresholding Control',0,99, f)&#xA;&#xA;cap = cv2.VideoCapture(0)&#xA;while(True):&#xA;  ret, image = cap.read()&#xA;  HSV = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)&#xA;  # Getting trackbar values&#xA;  highH = cv2.getTrackbarPos('High H','Thresholding Control')&#xA;  lowH = cv2.getTrackbarPos('Low H','Thresholding Control')&#xA;  highS = cv2.getTrackbarPos('High S','Thresholding Control')&#xA;  lowS = cv2.getTrackbarPos('Low S','Thresholding Control')&#xA;  highV = cv2.getTrackbarPos('High V','Thresholding Control')&#xA;  lowV = cv2.getTrackbarPos('Low V','Thresholding Control')&#xA;  # Thresholding the image.&#xA;  thresh = cv2.inRange( HSV, (lowH, lowS, lowV), (highH, highS, highV))&#xA;  blurVal = cv2.getTrackbarPos('Guassian Blur','Thresholding Control')&#xA;  if(blurVal%2==0):&#xA;      blurVal=blurVal+1&#xA;  thresh_smooth = cv2.GaussianBlur(thresh, (blurVal, blurVal), 0)&#xA;  #Defining the kernel to be used for Morphological ops.&#xA;  kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))&#xA;  # Applying Opening and Closing.&#xA;  thresh_smooth = cv2.morphologyEx(thresh_smooth,cv2.MORPH_OPEN,kernel)&#xA;  thresh_smooth = cv2.morphologyEx(thresh_smooth, cv2.MORPH_CLOSE, kernel)&#xA;&#xA;  #(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(thresh_smooth)&#xA;  eleR = np.count_nonzero(thresh_smooth[0:480, 320:550])&#xA;  eleL = np.count_nonzero(thresh_smooth[0:480, 0:320])&#xA;  eleO = np.count_nonzero(thresh_smooth[0:480, 550:640])&#xA;  if (eleL&amp;gt;eleR and eleL&amp;gt;eleO and eleL!= (eleR+eleO)):&#xA;     cv2.putText(image,&quot;Left Turn&quot;, (320,240), cv2.FONT_HERSHEY_SIMPLEX, 2, 255)&#xA;     print ('L')&#xA;  elif (eleO&amp;gt;eleR and eleO&amp;gt;eleL):&#xA;     cv2.putText(image,&quot;Right Turn&quot;, (240,320), cv2.FONT_HERSHEY_SIMPLEX, 2, 255)&#xA;     print ('R')&#xA;  else:&#xA;     cv2.putText(image,&quot;Straight&quot;, (240,320), cv2.FONT_HERSHEY_SIMPLEX, 2, 255)&#xA;     print ('S')&#xA;  cv2.imshow(&quot;BGR&quot;, image)&#xA;  cv2.imshow(&quot;Thresholded&quot;, thresh_smooth)&#xA;  print ser.readline();&#xA;  if cv2.waitKey(1) &amp;amp; 0xFF == ord('q'):&#xA;        break&#xA;#cv2.imwrite('ImG.png', thresh_smooth)&#xA;cap.release()&#xA;cv2.destroyAllWindows()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-07-01T11:46:26.973" LastActivityDate="2016-07-03T20:13:11.220" Title="Sketch behaves differently when motor driver is added" Tags="|arduino-uno|serial|programming|python|" AnswerCount="3" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="25790" PostTypeId="2" ParentId="25782" CreationDate="2016-06-28T14:54:12.340" Score="1" Body="&lt;p&gt;Another option is &lt;a href=&quot;http://www.blynk.cc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Blynk&lt;/a&gt; who offer a server, a smartphone app, and a set of libraries and example sketches for Arduino. Also an active and helpful online user community, where the developers participate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The server does not make view-able web pages; its job is to enable the Arduino and the app to communicate with each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The app lets the user quickly and easily configure a custom control panel which can communicate both ways with your Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Blynk libraries can be installed and an example program compiled and uploaded a few minutes, with support for I/O port reading and writing already built-in. Online documentation describes how to expand the example code to do more specific things. Blynk is still under active development, meaning the documentation isn't always as detailed as one might like, that bugs are being fixed and occasional new ones appear, and new features are being developed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use it myself and teach other people how to, and I find it a really quick and easy to use platform for interactive remote control of my Arduino-based gadgets.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, I am using it right now to develop a ventilation controller for room- and window-fans. It will mix the room air in winter when the heat rises to the ceiling, and ventilate or just mix the room in summer depending on the floor, ceiling, and outdoor temperatures. It will report back to the smartphone which fans are on and off; allow me to turn any of them on or off; and display a history of the temperatures and fan states.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-12-31T13:11:45.540" LastActivityDate="2016-12-31T13:11:45.540" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25791" PostTypeId="2" ParentId="25789" CreationDate="2016-06-28T15:29:22.570" Score="0" Body="&lt;p&gt;3 things: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;1: your delay statement is worrying, I'd highly recommend parallel coding in this case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;2: you don't have a &quot;data = ' ';&quot; statement in your loop function of the second code, but you do in the first. Is this intentional?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3: if your arduino receives Serial while executing Delay, you mustn't pour in more than the buffer.&lt;/p&gt;&#xA;" OwnerUserId="15994" LastActivityDate="2016-06-28T15:29:22.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25792" PostTypeId="1" CreationDate="2016-06-28T15:37:31.400" Score="0" ViewCount="85" Body="&lt;p&gt;I am using arduino as the base for an accelerometer project - the end goal is to have multiple arduinos with accelerometer chips that can wirelessly start and stop collecting data and wirelessly send this data back to the &quot;base&quot; arduino (which will be connected to a computer).  Currently we have only two arduinos communicating to test a lot of this, and currently are using a bluetooth node to wirelessly code the accelerometer arduino and Rf nodes to wirelessly send the data back to the arduino connected to a computer which then prints the data it is collecting.  How could we replace this with a wifi network?&lt;/p&gt;&#xA;" OwnerUserId="23447" LastActivityDate="2016-06-28T15:43:18.970" Title="How can I use wifi to wirelessly communicate (and wirelessly code if possible) between multiple arduinos?" Tags="|wifi|communication|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25793" PostTypeId="2" ParentId="25789" CreationDate="2016-06-28T15:38:02.727" Score="1" Body="&lt;p&gt;You have got quite a bit of difference between the two codes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your first code you declare &lt;code&gt;char inByte = ' ';&lt;/code&gt; at the beginning of &lt;code&gt;void loop&lt;/code&gt;. This means that each time you run through the loop it clears the value which you assign the Serial value to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the second code you declare &lt;code&gt;data&lt;/code&gt; as a global variable outside of loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What that means is that you first code basically allows a one-shot reaction to a Serial value because it clears the value at the beginning of loop. Thus it only goes into an &lt;code&gt;if()&lt;/code&gt; statement once. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Whereas your second code will retain the value that it received at &lt;code&gt;Serial.read()&lt;/code&gt; the first time. Thus it will continue to run the matching if statement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you could do is after each matched &lt;code&gt;if()&lt;/code&gt; statement you do &lt;code&gt;data = ' ';&lt;/code&gt; or at the beginning of loop you can clear it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you might be missing the updates from your python script because of the delays during motor control. Also Gerben is correct about there possibly being issues with the motor drivers affecting the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-06-28T15:38:02.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25794" PostTypeId="2" ParentId="25792" CreationDate="2016-06-28T15:43:18.970" Score="1" Body="&lt;p&gt;Sending data to a computer using WiFi is simple enough and there are plenty of examples. The simplest way is to set up a web server on the computer and use HTTP POST to send the data. There are &quot;lighter&quot; ways but entail more coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You won't do OTA updates on a normal Arduino. Yes, you could use a Yún, but they aren't always the best choice - the Linux side of things does make it a very &quot;heavyweight* board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be better off using an ESP8266 based system (not wired to an Arduino, but standalone) and programming it direct. Maybe a NodeMCU or something similar.  &lt;a href=&quot;http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html&quot; rel=&quot;nofollow&quot;&gt;The Arduino core for ESP8266 supports OTA programming direct from the Arduino IDE.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-28T15:43:18.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25795" PostTypeId="1" AcceptedAnswerId="25797" CreationDate="2016-06-28T16:00:32.107" Score="1" ViewCount="1992" Body="&lt;p&gt;Please help me with this library &quot;Softwareserial&quot;. The basic sketch does not work. Please look the errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:128:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors&#xA;&#xA; #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors&#xA;&#xA;  ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:184:23: error: 'SREG' was not declared in this scope&#xA;&#xA;     uint8_t oldSREG = SREG;&#xA;&#xA;                       ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:185:9: error: 'cli' was not declared in this scope&#xA;&#xA;     cli();&#xA;&#xA;         ^&#xA;&#xA;In file included from C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\cores\arduino/delay.h:27:0,&#xA;&#xA;                 from C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\cores\arduino/Arduino.h:76,&#xA;&#xA;                 from C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':&#xA;&#xA;C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]&#xA;&#xA; #define digitalPinToPort(P)        ( &amp;amp;(PORT-&amp;gt;Group[g_APinDescription[P].ulPort]) )&#xA;&#xA;                                                                                  ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:360:18: note: in expansion of macro 'digitalPinToPort'&#xA;&#xA;   uint8_t port = digitalPinToPort(tx);&#xA;&#xA;                  ^&#xA;&#xA;C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:65:44: error: base operand of '-&amp;gt;' is not a pointer&#xA;&#xA; #define portOutputRegister(port)   ( &amp;amp;(port-&amp;gt;OUT.reg) )&#xA;&#xA;                                            ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:361:27: note: in expansion of macro 'portOutputRegister'&#xA;&#xA;   _transmitPortRegister = portOutputRegister(port);&#xA;&#xA;                           ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':&#xA;&#xA;C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]&#xA;&#xA; #define digitalPinToPort(P)        ( &amp;amp;(PORT-&amp;gt;Group[g_APinDescription[P].ulPort]) )&#xA;&#xA;                                                                                  ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:371:18: note: in expansion of macro 'digitalPinToPort'&#xA;&#xA;   uint8_t port = digitalPinToPort(rx);&#xA;&#xA;                  ^&#xA;&#xA;C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:66:44: error: base operand of '-&amp;gt;' is not a pointer&#xA;&#xA; #define portInputRegister(port)    ( &amp;amp;(port-&amp;gt;IN.reg) )&#xA;&#xA;                                            ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:372:26: note: in expansion of macro 'portInputRegister'&#xA;&#xA;   _receivePortRegister = portInputRegister(port);&#xA;&#xA;                          ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:383:31: error: 'table' was not declared in this scope&#xA;&#xA;   for (unsigned i=0; i&amp;lt;sizeof(table)/sizeof(table[0]); ++i)&#xA;&#xA;                               ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:399:38: error: 'digitalPinToPCICR' was not declared in this scope&#xA;&#xA;     if (digitalPinToPCICR(_receivePin))&#xA;&#xA;                                      ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:401:78: error: 'digitalPinToPCICRbit' was not declared in this scope&#xA;&#xA;       *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));&#xA;&#xA;                                                                              ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:401:79: error: '_BV' was not declared in this scope&#xA;&#xA;       *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));&#xA;&#xA;                                                                               ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:402:37: error: 'digitalPinToPCMSK' was not declared in this scope&#xA;&#xA;       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));&#xA;&#xA;                                     ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:402:78: error: 'digitalPinToPCMSKbit' was not declared in this scope&#xA;&#xA;       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));&#xA;&#xA;                                                                              ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:417:36: error: 'digitalPinToPCMSK' was not declared in this scope&#xA;&#xA;   if (digitalPinToPCMSK(_receivePin))&#xA;&#xA;                                    ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:418:77: error: 'digitalPinToPCMSKbit' was not declared in this scope&#xA;&#xA;     *digitalPinToPCMSK(_receivePin) &amp;amp;= ~_BV(digitalPinToPCMSKbit(_receivePin));&#xA;&#xA;                                                                             ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:418:78: error: '_BV' was not declared in this scope&#xA;&#xA;     *digitalPinToPCMSK(_receivePin) &amp;amp;= ~_BV(digitalPinToPCMSKbit(_receivePin));&#xA;&#xA;                                                                              ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:453:21: error: 'SREG' was not declared in this scope&#xA;&#xA;   uint8_t oldSREG = SREG;&#xA;&#xA;                     ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:454:7: error: 'cli' was not declared in this scope&#xA;&#xA;   cli();  // turn off interrupts for a clean txmit&#xA;&#xA;       ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:458:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope&#xA;&#xA;   tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);&#xA;&#xA;                          ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:501:21: error: 'SREG' was not declared in this scope&#xA;&#xA;   uint8_t oldSREG = SREG;&#xA;&#xA;                     ^&#xA;&#xA;C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:502:7: error: 'cli' was not declared in this scope&#xA;&#xA;   cli();&#xA;&#xA;       ^&#xA;PLEASE HELP ME!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23441" LastEditorUserId="6628" LastEditDate="2016-06-28T18:20:32.800" LastActivityDate="2016-06-28T18:20:32.800" Title="SoftwareSerial error:" Tags="|softwareserial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25796" PostTypeId="1" CreationDate="2016-06-28T16:32:27.083" Score="1" ViewCount="60" Body="&lt;p&gt;I am intended to use Arduino to measure Temperature and Humidity (DTH11) and Gases Grove Sensor (Multichannel). Due to weather conditions in UK, I would to get your advice how to shield all of them in water proof box? Do you believe that using Polystyrene is useful? &#xA;Any recommended power source?&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-06-28T19:22:38.750" Title="Arduino for Weather and Air Monitoring: Casing and Power Source" Tags="|arduino-uno|sensors|wifi|shields|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25797" PostTypeId="2" ParentId="25795" CreationDate="2016-06-28T17:48:42.453" Score="1" Body="&lt;p&gt;You're trying to use the AVR SoftwareSerial library with an ARM based board. It won't work. Ever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There should be no need to use SoftwareSerial - the SAMD chips have multiple UART channels - just use one of those.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-28T17:48:42.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25799" PostTypeId="2" ParentId="25796" CreationDate="2016-06-28T19:22:38.750" Score="2" Body="&lt;p&gt;I'd say, use a IP-54 protection plastic case. The IP is a standard, that tells you, how big particles can(not) come into the case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;About powering, depends, how often can you go and switch batteries.&#xA;If you can, you can plug the cable in the case - drill the hole through and use watertight silicone plug to ensure, it is water resistant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case of batteries - use some LiPo batteries with DC-DC converter to minimum voltage.&#xA;Maybe you could even add a solar panel or two for addional life extension of batteries.&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-06-28T19:22:38.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25801" PostTypeId="1" CreationDate="2016-06-28T20:24:52.607" Score="0" ViewCount="347" Body="&lt;p&gt;I want to communicate Arduino A to Arduino B by using RF module. But my RF module (Tx- XLPCF20, Rx- XY-R01A) only consist of 4 pins of data pin where it can send 4 bits of data only. So, I want to develop a new encoding to send data by using 4 bits of data. How should i do for the coding since I don't want to use serial write for coding. Any suggestion? Help me please. If u can give me the coding, I'm beyond thankful.&lt;/p&gt;&#xA;" OwnerUserId="23451" LastActivityDate="2016-06-28T20:37:54.750" Title="Communication between two Arduinos over RF module" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25802" PostTypeId="2" ParentId="25801" CreationDate="2016-06-28T20:37:54.750" Score="1" Body="&lt;p&gt;You have 4 channels of raw HIGH/LOW communication.  How you use them is up to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest method is to use an asynchronous serial protocol:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use Serial: Connect the TX of one Arduino to channel 1 at the TX, and RX channel 1 to RX on the other Arduino&lt;/li&gt;&#xA;&lt;li&gt;Use SoftwareSerial: The same as above but you choose the pins&lt;/li&gt;&#xA;&lt;li&gt;Use VirtualWire: very similar to SoftwareSerial&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For higher speeds, since you have 4 channels, you could use a &lt;em&gt;synchronous&lt;/em&gt; serial communication protocol. It should be perfectly possible to connect three of the channels to SPI and communicate as if it were talking directly to an SPI device - one channel to SCK, one to MOSI and one to SS. The other end has SCK, MOSI and SS but running in slave mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;No need to &quot;invent&quot; a 4-bit protocol, it's too much work.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-28T20:37:54.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25804" PostTypeId="2" ParentId="25758" CreationDate="2016-06-28T22:10:44.757" Score="1" Body="&lt;p&gt;I think that RTC modules and real time clock chips have some sort of &quot;mistake&quot; said that, it CAN max. delay for fast forward for max. 6 seconds per month. Something as this, I've read year or so ago, when I was dealing with some sort of doors locking mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for app. 8 hours, there's an arduino RTC module more than enough, I'd say. I assume, that seconds doesn't matter.&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-06-28T22:10:44.757" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25805" PostTypeId="2" ParentId="19084" CreationDate="2016-06-28T22:16:53.177" Score="0" Body="&lt;p&gt;I think the best thing you can do with this, is that you use temporary wires to connect and test the application and later, when you'll come to part, where you should &quot;make-a-solid&quot;, you just solder these wires to the bottom, where pin headers are. I think this is the simplest way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do it a bit better, desolder female header pins and solder cables to those holes. It's more electronics-approved that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or the simplest (but not the brighest): Jumper wires can be glued into female header pins, but I strongly unrecommend this option, as same as making a shield for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's another(and most elegant too!) option of making a PCB version of arduino: Add the AtMega, few passive components and proper pads, to solder wires on.&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-06-28T22:16:53.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25806" PostTypeId="1" CreationDate="2016-06-28T22:43:54.233" Score="1" ViewCount="1864" Body="&lt;p&gt;I'm new to the Arduino world. The last time i was programming microprocessors, was back with the Z80 in assembly language.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am also teaching myself C++ and seems to be going quite well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have decided to write my own 'library' for driving 7 segment LED's. The reason for writing my own, rather then using an existing one is to aid with the learning process. I'm quite pleased to say it works ( it may not be the most efficient code)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The books I have on C++ are great, but i do find sometimes the explanation of concepts seem to get lost.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what I would like to know, how do you go about initialising an object class in setup() and using it in loop()? I have this sneaky suspicion that it involves creating the object on the heap, and passing a pointer to the object over somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could just initialise it once in loop(), and make my own continuous loop afterwards, but there are other things done between the and of a loop() and the beginning of the next loop() (things like timer interrupts).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I will post the code im using, but not the library unless asked to, as it is quite a few lines.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include &quot;Leddisplay.h&quot;&#xA;void setup() {&#xA;&#xA;    byte Digit[9] = { 22, 23 , 24 ,25, 26, 27, 28, 29, 2 };&#xA;&#xA;    Leddisplay *pRightDigit = new Leddisplay(Digit);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    pRightDigit-&amp;gt;setDigit(5);&#xA;    pRightDigit-&amp;gt;displayDigit();&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;^^  Obviously this does not compile  ^^&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include &quot;Leddisplay.h&quot;&#xA;void setup() {&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;    byte Digit[9] = { 22, 23 , 24 ,25, 26, 27, 28, 29, 2 };&#xA;    Leddisplay *pRightDigit = new Leddisplay(Digit);&#xA;&#xA;    pRightDigit-&amp;gt;setDigit(5);&#xA;    pRightDigit-&amp;gt;displayDigit();&#xA;&#xA;    for (;;);   // or do.. while within which has other code to repeat&#xA;                // but wont allow anything to be executed between loop() iterations&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;^^  This does, and runs fine, but may not achieve what I want  ^^&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if I have used the right wording, or even asked the right question.&#xA;Thank you for any help in advance.&#xA;Dave&lt;/p&gt;&#xA;" OwnerUserId="23455" LastActivityDate="2016-06-29T09:15:18.040" Title="Passing pointers between setup and loop" Tags="|arduino-mega|programming|c++|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25807" PostTypeId="2" ParentId="25806" CreationDate="2016-06-28T22:50:55.647" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;... how do you go about initialising an object class in setup() and using it in loop()?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You declare it in a global context so that it's accessible by both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But that's not &lt;em&gt;quite&lt;/em&gt; what you want here:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Leddisplay.h&quot;&#xA;&#xA;byte Digit[] = {...};&#xA;Leddisplay RightDigit(Digit);&#xA;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;    RightDigit.setDigit(5);&#xA;    RightDigit.displayDigit();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-06-28T22:50:55.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25808" PostTypeId="2" ParentId="25806" CreationDate="2016-06-28T22:52:57.837" Score="3" Body="&lt;p&gt;What you have to understand is the concept of &lt;em&gt;scope&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything (well, almost everything) in C and C++ is enclosed in &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;. Those define a &lt;em&gt;scope&lt;/em&gt;, and everything defined within that scope is available to any other scopes defined within that scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also assume that the whole sketch is surrounded by &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;. This scope is called the &lt;em&gt;global scope&lt;/em&gt;.  Anything defined within it is available anywhere in your sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So by defining the object in the &lt;em&gt;global scope&lt;/em&gt; it is available everywhere:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include &quot;Leddisplay.h&quot;&#xA;&#xA;Leddisplay *pRightDigit;&#xA;&#xA;void setup() {&#xA;    byte Digit[9] = { 22, 23 , 24 ,25, 26, 27, 28, 29, 2 };&#xA;    pRightDigit = new Leddisplay(Digit);&#xA;}&#xA;&#xA;void loop() {&#xA;    pRightDigit-&amp;gt;setDigit(5);&#xA;    pRightDigit-&amp;gt;displayDigit();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However the use of &lt;code&gt;new&lt;/code&gt; etc is discouraged in low-memory systems. Better is to &lt;em&gt;statically define&lt;/em&gt; the object:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include &quot;Leddisplay.h&quot;&#xA;&#xA;const byte Digit[9] = { 22, 23 , 24 ,25, 26, 27, 28, 29, 2 };&#xA;Leddisplay pRightDigit(Digit);&#xA;&#xA;void setup() {&#xA;}&#xA;&#xA;void loop() {&#xA;    pRightDigit.setDigit(5);&#xA;    pRightDigit.displayDigit();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that, when statically defined like this, things in the constructor aren't guaranteed to be run at the right time. They should be moved into a &lt;code&gt;.begin()&lt;/code&gt; function that you then call from &lt;code&gt;setup()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;# include &quot;Leddisplay.h&quot;&#xA;&#xA;const byte Digit[9] = { 22, 23 , 24 ,25, 26, 27, 28, 29, 2 };&#xA;Leddisplay rightDigit(Digit);&#xA;&#xA;void setup() {&#xA;    rightDigit.begin();&#xA;}&#xA;&#xA;void loop() {&#xA;    rightDigit.setDigit(5);&#xA;    rightDigit.displayDigit();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-28T22:52:57.837" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25809" PostTypeId="1" CreationDate="2016-06-29T00:01:18.563" Score="1" ViewCount="567" Body="&lt;p&gt;I am working on a autonomous track vehicle. I have mounted &lt;/p&gt;&#xA;&#xA;&lt;p&gt;3 HC-SR04 sensors&#xA;1 Sharp infrared distance sensor&#xA;3 infrared led distance sensors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1 Arduino Mega 2560&#xA;1 H-bridge Board HG7881&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to use 7.5 v 1700 mAh Nicd battery (also tried 11.1 Lipo 2200 mAh)&#xA;For all sensors power (5v) I developed 5v regulator using 7805 which is connected directly from battery as input. The output 5v is going to power distribution board (used from quadcopter extra board) which provides 5v to every sensor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The real problem starts here when I am not getting correct or nothing in reading from Ultrasonic sensors and my vehicle starts behaving abnormal. I checked that sensor reading is either 0 or wrong. I used both simple and with NewPing library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I checked when using 7.2v battery the output from 5v regulator is 3.72v. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now my question is if the power is below 5v, does sensors starts behaving like this? How can we supply voltage so every sensor will receive full 5v to work properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My vehicle will not work until sensors provide correct distance reading. I worked successfully with one sensor but with number of these, tired working since many days. &lt;/p&gt;&#xA;" OwnerUserId="7235" LastActivityDate="2017-08-02T07:22:32.677" Title="Multiple HC-SR04 with one 5v 7805 regulator" Tags="|arduino-mega|power|battery|hc-sr04|" AnswerCount="2" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="25810" PostTypeId="2" ParentId="25809" CreationDate="2016-06-29T04:51:20.807" Score="1" Body="&lt;p&gt;You really could benefit from a DC/DC switching power supply.  For instance you are wasting about 20% of the power of the 7.2V battery and something like 50% of the power of the 11.1V battery.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, could it be that you are triggering the 3 ultrasonic HC-SR04 too closely together?  If you don't wait for the sound to die out from the 1st sensor the 2nd sensor could give unexpected results.  Same goes for the 3rd sensor.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-29T04:51:20.807" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25812" PostTypeId="1" CreationDate="2016-06-29T05:13:21.743" Score="0" ViewCount="1571" Body="&lt;p&gt;For those of you familiar with my somewhat steep EEPROM learning curve...thank you for continuing to share your knowledge.  I see how it's supposed to work and it's falling into place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've run into a new problem and I've spent two nights (~15hrs of Googling/trial and error...mostly error) trying to understand where I'm going wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a chunk of code that take user inputs from a webpage and saves it to EEPROM.  It works as intended when only SSID and PASS fields are provided on the form.  I added an &quot;owner&quot; field to add my name to the EEPROM (because why not?) and now the PASS field is ignored and the OWNER information is saved to the PASS and OWNER EEPROM locations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think it has something to do with the string.indexof(&quot;&amp;amp;&quot;) and repeated string.lastindexof(&quot;=&quot;) but I'm still wrapping my head around what these actually do.  If I understand it correctly, the second string.lastindexof(&quot;=&quot;) is actually overwriting the PASS which was saved milliseconds earlier.  If this is correct, how do I prevent this?  If I'm wrong, why?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  s += &quot;&amp;lt;form method='get' action='a'&amp;gt;&amp;lt;label&amp;gt;SSID: &amp;lt;/label&amp;gt;&amp;lt;input name='ssid' length=32&amp;gt;&amp;lt;br&amp;gt;&amp;lt;label&amp;gt;PASS: &amp;lt;/label&amp;gt;&amp;lt;input name='pass' length=64&amp;gt;&amp;lt;br&amp;gt;&amp;lt;label&amp;gt;OWNER: &amp;lt;/label&amp;gt;&amp;lt;input name='owner' length=32&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;input type='submit'&amp;gt;&amp;lt;/form&amp;gt;&quot;;&#xA;  s += &quot;&amp;lt;/html&amp;gt;\r\n\r\n\r\n&quot;;&#xA;  Serial.println(&quot;Sending 200&quot;);&#xA;}&#xA;else if ( req.startsWith(&quot;/a?ssid=&quot;) ) {&#xA;  Serial.println(&quot;clearing eeprom&quot;);&#xA;  for (int i = 0; i &amp;lt; 128; ++i) {&#xA;    EEPROM.write(i, 0);&#xA;  }&#xA;  String qsid;&#xA;  qsid = req.substring(8, req.indexOf('&amp;amp;'));&#xA;  Serial.println(qsid);&#xA;  Serial.println(&quot;&quot;);&#xA;  String qpass;&#xA;  qpass = req.substring(req.lastIndexOf('=') + 1);&#xA;  Serial.println(qpass);&#xA;  Serial.println(&quot;&quot;);&#xA;  String owner;&#xA;  owner = req.substring(req.lastIndexOf('=') + 1);&#xA;  Serial.println(owner);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  Serial.println(&quot;writing eeprom ssid:&quot;);&#xA;  for (int i = 0; i &amp;lt; qsid.length(); ++i)&#xA;  {&#xA;    EEPROM.write(i, qsid[i]);&#xA;    Serial.print(&quot;Wrote: &quot;);&#xA;    Serial.println(qsid[i]);&#xA;  }&#xA;  Serial.println(&quot;writing eeprom pass:&quot;);&#xA;  for (int i = 0; i &amp;lt; qpass.length(); ++i)&#xA;  {&#xA;    EEPROM.write(32 + i, qpass[i]);&#xA;    Serial.print(&quot;Wrote: &quot;);&#xA;    Serial.println(qpass[i]);&#xA;  }&#xA;  Serial.println(&quot;writing eeprom owner:&quot;);&#xA;  for (int i = 0; i &amp;lt; owner.length(); ++i)&#xA;  {&#xA;    EEPROM.write(96 + i, owner[i]);&#xA;    Serial.print(&quot;Wrote: &quot;);&#xA;    Serial.println(owner[i]);&#xA;  }&#xA;  EEPROM.commit();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To summarize, my questions are:&lt;br&gt;&#xA;-what is causing the code to skip over my PASS field and save a duplicate of OWNER into both PASS and OWNER?&lt;br&gt;&#xA;-is one \r\n pair required for every field on the html form?  If I used 100 fields would I need 100 * \r\n pairs after  tag?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're interested in seeing the whole shebang, chriscook8 has graciously posted the Access Point sketch for the ESP8266 &lt;a href=&quot;https://github.com/chriscook8/esp-arduino-apboot&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (~250 lines).  There is also a very helpful discussion about this sketch &lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=29&amp;amp;t=2520&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Edit: 3 July 2016&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I've amended the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;s += &quot;&amp;lt;form method='get' action='a'&amp;gt;&amp;lt;label&amp;gt;SSID: &amp;lt;/label&amp;gt;&amp;lt;input name='ssid' length=32&amp;gt;&amp;lt;br&amp;gt;&amp;lt;label&amp;gt;PASS: &amp;lt;/label&amp;gt;&amp;lt;input name='pass' length=64&amp;gt;&amp;lt;br&amp;gt;&amp;lt;label&amp;gt;OWNER: &amp;lt;/label&amp;gt;&amp;lt;input name='owner' length=32&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;input type='submit'&amp;gt;&amp;lt;/form&amp;gt;&quot;;&#xA;s += &quot;&amp;lt;/html&amp;gt;\r\n\r\n\r\n&quot;;&#xA;Serial.println(&quot;Sending 200&quot;);&#xA;}&#xA;    else if ( req.startsWith(&quot;/a?ssid=&quot;) ) {&#xA;      Serial.println(&quot;clearing eeprom&quot;);&#xA;      for (int i = 0; i &amp;lt; 128; ++i) {&#xA;        EEPROM.write(i, 0);&#xA;      }&#xA;      String qsid = server.arg(&quot;ssid&quot;);&#xA;      String qpass = server.arg(&quot;pass&quot;);&#xA;      String owner = server.arg(&quot;owner&quot;);&#xA;    }&#xA;    Serial.println(&quot;writing eeprom ssid:&quot;);&#xA;    for (int i = 0; i &amp;lt; qsid.length(); ++i)&#xA;    {&#xA;      EEPROM.write(i, qsid[i]);&#xA;      Serial.print(&quot;Wrote: &quot;);&#xA;      Serial.println(qsid[i]);&#xA;    }&#xA;    Serial.println(&quot;writing eeprom pass:&quot;);&#xA;    for (int i = 0; i &amp;lt; qpass.length(); ++i)&#xA;    {&#xA;      EEPROM.write(32 + i, qpass[i]);&#xA;      Serial.print(&quot;Wrote: &quot;);&#xA;      Serial.println(qpass[i]);&#xA;    }&#xA;    Serial.println(&quot;writing eeprom owner:&quot;);&#xA;    for (int i = 0; i &amp;lt; owner.length(); ++i)&#xA;    {&#xA;      EEPROM.write(96 + i, owner[i]);&#xA;      Serial.print(&quot;Wrote: &quot;);&#xA;      Serial.println(owner[i]);&#xA;    }&#xA;    EEPROM.commit();&#xA;    s = &quot;HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n&amp;lt;!DOCTYPE HTML&amp;gt;\r\n&amp;lt;html&amp;gt;Hello from ESP8266 &quot;;&#xA;    s += &quot;Found &quot;;&#xA;    s += req;&#xA;    s += &quot;&amp;lt;p&amp;gt; saved to eeprom... reset to boot into new wifi&amp;lt;/html&amp;gt;\r\n\r\n&quot;;&#xA;  }&#xA;  else&#xA;  {&#xA;    s = &quot;HTTP/1.1 404 Not Found\r\n\r\n&quot;;&#xA;    Serial.println(&quot;Sending 404&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I also made the following replacement per your recommendations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//WiFiServer server(80);&#xA;ESP8266WebServer server ( 80 );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...and receive an error on this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;WiFiClient client = server.available();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;'class ESP8266WebServer' has no member named 'available'&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm sure that there is a simple replacement for this.  Any idea what it might be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, I think I see where you're going with this and it seems much cleaner than I anticipated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="13355" LastEditorUserId="13355" LastEditDate="2016-07-04T03:07:53.363" LastActivityDate="2018-02-27T04:59:41.600" Title="Posting to EEPROM via HTML - ESP8266 Arduino IDE" Tags="|c++|esp8266|eeprom|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25813" PostTypeId="1" CreationDate="2016-06-29T05:40:46.083" Score="0" ViewCount="4775" Body="&lt;p&gt;I have developed my arduino code using below library. I tested code working fine over modbus RTU slave. Now i am planning to use RS485 to wifi instead of wire connection. In order to get data over web apllication i need to add another layer of modbus TCP-IP. can some one suggest me is it possible to without changing any hardware add library function which can acts like MODBUS RtU over TCP-IP protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if any library avilable please share it&#xA;I am using WIFI device like below.&#xA;&lt;a href=&quot;http://www.usriot.com/p/rs485-to-wifi-converters/&quot; rel=&quot;nofollow&quot;&gt;rs485 to wifi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://arduino-experience.blogspot.in/2014/02/modbus-slave-example.html&quot; rel=&quot;nofollow&quot;&gt;MODBUS RTU&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="904" LastActivityDate="2017-07-25T19:35:55.720" Title="Modbus RTU over TCPip" Tags="|arduino-uno|modbus|tcpip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25816" PostTypeId="2" ParentId="25812" CreationDate="2016-06-29T06:45:30.417" Score="1" Body="&lt;p&gt;A code snippet for you - will expand later (just got tied up)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESP8266WebServer server ( 80 );&#xA;...&#xA;&#xA;else if ( req.startsWith(&quot;/a?ssid=&quot;) ) {&#xA;  Serial.println(&quot;clearing eeprom&quot;);&#xA;  for (int i = 0; i &amp;lt; 128; ++i) {&#xA;    EEPROM.write(i, 0);&#xA;  }&#xA;  String qsid = server.arg(&quot;ssid&quot;);&#xA;  String qpass = server.arg(&quot;pass&quot;);;&#xA;  String owner = server.arg(&quot;owner&quot;);&#xA;&#xA;  Serial.println(&quot;writing eeprom ssid:&quot;);&#xA;  ... rest of your code&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21371" LastActivityDate="2016-06-29T06:45:30.417" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25817" PostTypeId="1" CreationDate="2016-06-29T07:24:18.880" Score="0" ViewCount="784" Body="&lt;p&gt;I'm working on Arduino uno and trying to use more then one timer.&#xA;I'm using timer1 for my software watchdog (I needed bigger interval for that, so my program won't reset itself after 8 seconds).&#xA;In addition, I'm using timer2 for regular interrupt like turn off pin after 8 seconds.&#xA;The problem is that the timer1's interrupt override timer2's interrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to to use both of them?&lt;/p&gt;&#xA;" OwnerUserId="23464" LastActivityDate="2016-10-28T18:15:49.520" Title="use more then one timer" Tags="|arduino-uno|timers|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25818" PostTypeId="1" AcceptedAnswerId="25821" CreationDate="2016-06-29T07:52:16.733" Score="3" ViewCount="775" Body="&lt;p&gt;I'm building a small device using arduino that should be connected to my pc via a usb header to exchange data with the PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'd like to achieve is that arduino turns on when the pc is on, whereas it shuts down when the pc is turned off. If I rely on the usb port to provide power to the arduino that might not happen, since some motherboards still provide power to the usb connections even when the pc is off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore I'd like to power the arduino using the 5v rail directly from a Molex. I know that theoretically I can connect that rail straight to the 5v pin, but what about power spikes? How can I be sure that the 5v input voltage is properly filtered and stabilized? Would it be better to use a LM317 and transform the 12v rail into 7.5v to feed arduino from the vin?&lt;/p&gt;&#xA;" OwnerUserId="23466" LastActivityDate="2016-06-29T08:57:14.097" Title="Power arduino from 5v rail of pc molex" Tags="|power|voltage-level|voltage-protection|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25819" PostTypeId="2" ParentId="25813" CreationDate="2016-06-29T08:36:36.423" Score="1" Body="&lt;p&gt;Modbus TCP simply put is a Modbus packet wrapped in a TCP packet. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no 'additional layer of Modbus' added on top. If we look at the osi model pictured below you can see there is only one Modbus application layer (i.e modbus slave/server) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1xRAi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1xRAi.jpg&quot; alt=&quot;Modbus OSI Layer (stolen from http://www.protoconvert.com/&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially if the wifi-&gt;RS485 gateway strips the payload from the TCP packets and simply spits it out the serial side then no modifications are necessary (apart from the obvious RS485 transceiver you will need to interface the arduino with the gateway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you will need to make sure is that the gateway will only send packets directed to port 502 to the arduino (502 is the Modbus TCP port) as it is possible other IP traffic could cause some drama for the modbus slave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, you will have to ensure that you set the slave ID of the arduino to be what is specified by the master. Are you also building the Modbus TCP client? If not it is very possible that the required slave ID is 255 which is not supported by the modbus library you have linked. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Modbus (serial) slave IDs can only be between 1 and 247 for traditional reasons when Modbus was first standardised as it was only envisioned to be on serial, however when Modbus TCP was introduced an additional addressing layer (TCP / IP) meant that the unit ID (slave ID when using Modbus TCP) could be anything from 0 - 255. It is common for some vendors (at least in industrial automation) to use a unit ID of 255 for standard Modbus transactions scanning IO and diagnostic or configuration transactions to be send to other unit IDs (essentially making the TCP server a modbus router, forwarding packets to one of the multiple Modbus servers running on that single slave device)&lt;/p&gt;&#xA;" OwnerUserId="19911" LastEditorUserId="19911" LastEditDate="2016-06-29T08:57:52.717" LastActivityDate="2016-06-29T08:57:52.717" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25821" PostTypeId="2" ParentId="25818" CreationDate="2016-06-29T08:57:14.097" Score="3" Body="&lt;p&gt;The 5v of an ATX power supply will be perfectly adequate for powering an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will already be very heavily filtered and stabilised.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-06-29T08:57:14.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25823" PostTypeId="2" ParentId="25806" CreationDate="2016-06-29T09:15:18.040" Score="0" Body="&lt;p&gt;Sorry, I cannot comment as I do not yet have enough rep.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is in response to @Dave Dunnes comment&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Library I have written can (and does) drive multiple led displays.&#xA;  I also understand then when programming for ucontrollers, you use as&#xA;  little ram as possible. Also, you usually know at compile time, what&#xA;  hardware is available, However, say you only know how many displays&#xA;  there are at runtime. This is why I have created the LED display&#xA;  instance on the heap (I assume on the Arduino, thats RAM, not flash)&#xA;  Let us say at runtime the program would ask you how many displays are&#xA;  connected via the serial terminal, then they will be activated, and a&#xA;  recompile is not an option. Regards, Dave – Dave Dunne 9 hours ago&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you do not know the exact number of segments (or any element really) at build time then you could implement a &lt;a href=&quot;http://www.cprogramming.com/tutorial/lesson15.html&quot; rel=&quot;nofollow&quot;&gt;linked list&lt;/a&gt; and dynamically allocate new  Leddisplay objects at run time or build the list in to your class. Alternatively you can try try using &lt;a href=&quot;http://en.cppreference.com/w/cpp/container/list&quot; rel=&quot;nofollow&quot;&gt;std::list&lt;/a&gt; with the &lt;a href=&quot;http://gammon.com.au/forum/?id=11119&quot; rel=&quot;nofollow&quot; title=&quot;AVR Port of the STL&quot;&gt;AVR port of the STL&lt;/a&gt; (I have not personally tried this).&lt;/p&gt;&#xA;" OwnerUserId="19911" LastActivityDate="2016-06-29T09:15:18.040" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25825" PostTypeId="1" AcceptedAnswerId="25832" CreationDate="2016-06-29T11:43:12.653" Score="2" ViewCount="2607" Body="&lt;p&gt;I wish to access methods and fields, as well as change them, of class A from class B. Since the main Arduino sketch is not a class, but a list of fields and methods, I created a separate MainClass with a method printStuff() that I want to call from class DoClass. This is how I go about it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;MainClass.h&quot;&#xA;MainClass m;&#xA;void setup() {&#xA;  m.setup();&#xA;}&#xA;void loop() {&#xA;  m.loop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MainClass.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  MainClass.h&#xA;*/&#xA;#ifndef MainClass_h&#xA;#define MainClass_h&#xA;#include &quot;Arduino.h&quot;&#xA;class MainClass&#xA;{&#xA;  public:&#xA;    MainClass();&#xA;    void setup();&#xA;    void loop();&#xA;    void printStuff();&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MainClass.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  MainClass.cpp&#xA;*/&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &quot;MainClass.h&quot;&#xA;#include &quot;DoClass.h&quot;&#xA;MainClass::MainClass()&#xA;{&#xA;  d DoClass(this);&#xA;}&#xA;void MainClass::setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;void MainClass::loop(){&#xA;  d.callMainClassFunct();&#xA;}&#xA;void MainClass::printStuff(){&#xA;  Serial.println(&quot;printing stuff&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;DoClass.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  DoClass.h&#xA;*/&#xA;#ifndef DoClass_h&#xA;#define DoClass_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &quot;MainClass.h&quot;&#xA;class DoClass&#xA;{&#xA;  public:&#xA;    DoClass(MainClass m);&#xA;    void callMainClassFunct();&#xA;  private:&#xA;    MainClass _m;&#xA;};&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;DoClass.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  DoClass.cpp&#xA;*/&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &quot;MainClass.h&quot;&#xA;#include &quot;DoClass.h&quot;&#xA;&#xA;DoClass::DoClass(MainClass m)&#xA;{&#xA;  _m = m;&#xA;}&#xA;&#xA;void DoClass::callMainClassFunct(){&#xA;  _m.printStuff();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This produces a myriad of errors. Each time I change something, a new kind of error appears, as though I was in a vicious cycle. Clearly, I am unfamiliar with C++. It would greatly help me if you could alter my code so that it works, keeping in mind that I would like to both access methods and fields of class MainClass from class DoClass and change those fields from class DoClass.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For reference, in Java, I would achieve the same in the following way:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MainClass.java:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class MainClass{&#xA;    DoClass d;&#xA;&#xA;    public MainClass(){&#xA;        d = new DoClass(this);&#xA;}&#xA;&#xA;    public void setup(){&#xA;&#xA;}&#xA;&#xA;public void loop(){&#xA;    d.callMainClassFunct();&#xA;}&#xA;&#xA;public void printStuff(){&#xA;    Serial.println(&quot;print stuff&quot;);&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;DoClass.java:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class DoClass{&#xA;       MainClass _m;&#xA;       public DoClass(MainClass m){&#xA;          _m = m;&#xA;       }&#xA;       public callMainClassFunct(){&#xA;         _m.printStuff();&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Passing this to the constructor od DoClass passes the value of the reference pointing to MainClass instantitated in the main sketch file. Then, by prepending the name of the instantiated object (in this case, &quot;m&quot;), followed by a dot, I can simply access and change all values of that object from DoClass (provided those methods and fields are visible to DoClass, which is the case here).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have posted before about this issue, but did not receive any answers to my specific question and could not comment because I do not have enough reputation. Thank you to those who tried to answer me, but the answers did not pertain to my specific question. This time I have included more information to show my problem more clearly. Thank you in advance for your help.&lt;/p&gt;&#xA;" OwnerUserId="23377" LastActivityDate="2017-01-26T04:10:57.677" Title="How to call class A's method from class B?" Tags="|class|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25827" PostTypeId="2" ParentId="9489" CreationDate="2016-06-29T12:11:21.357" Score="0" Body="&lt;p&gt;Am new at this but I am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the LCD I would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try the code below for the keypad (The code is if you have an i2c backpack)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Keypad.h&amp;gt; //keypad library&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt; //library for the backpack&#xA;&#xA;LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); &#xA;&#xA;const byte ROWS = 4; //four rows&#xA;const byte COLS = 3; //three columns&#xA;&#xA;//define the Symbols on the buttons of the keypads&#xA;  char hexaKeys[COLS][ROWS] = {&#xA;  {'1','2','3'},&#xA;  {'4','5','6'},&#xA;  {'7','8','9'},&#xA;  {'*','0','#'}&#xA;};&#xA;&#xA;byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad&#xA;byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad&#xA;&#xA;//initialize an instance of class NewKeypad&#xA;Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); &#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  lcd.begin(16,2);&#xA;  for(int i = 0; i&amp;lt; 3; i++)&#xA;  {&#xA;    lcd.backlight();  delay(250);&#xA;    lcd.noBacklight();  delay(250);&#xA;  }&#xA;  lcd.backlight();&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  char customKey = customKeypad.getKey();&#xA;&#xA;  if (customKey){&#xA;    lcd.print(customKey);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23126" LastEditorDisplayName="user6430" LastEditDate="2016-06-29T12:58:10.003" LastActivityDate="2016-06-29T12:58:10.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25828" PostTypeId="1" AcceptedAnswerId="25836" CreationDate="2016-06-29T13:51:52.083" Score="1" ViewCount="529" Body="&lt;p&gt;So I looked through the Arduino Mega2560 documentation and searched the web for a solution, and so far I haven't had any success. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm trying to accomplish is fairly simple. I need to send a serial command over serial, ONLY if there is a serial connection between the PC and the Arduino. I've tried:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;If(Serial){&#xA;   Serial.Println(&quot;COMMAND&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That doesn't work, and I think it's because the Arduino cannot distinguish between listening to the Serial port versus establishing a Serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="16564" LastActivityDate="2016-06-29T16:53:44.047" Title="How to send Serial.Print only If Serial Connection is open?" Tags="|serial|arduino-mega|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25829" PostTypeId="1" AcceptedAnswerId="25831" CreationDate="2016-06-29T14:08:17.453" Score="1" ViewCount="10614" Body="&lt;p&gt;I use the Base64 library for Arduino (but I don't think the problem is related to the library) and have the following function definition:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char* decodeImage(char inputString[], unsigned int inputStringLength) {&#xA;  int decodedLength = Base64.decodedLength(inputString, inputStringLength);&#xA;  char decodedString[decodedLength];&#xA;  Base64.decode(decodedString, inputString, inputStringLength);&#xA;  Serial.printf(&quot;%s&quot;,decodedString); // prints &quot;Base64DecodeExample&quot;&#xA;  return decodedString;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Later on, I use the following snippet to access the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  char inputString[] = &quot;QmFzZTY0RGVjb2RlRXhhbXBsZQA=&quot;;&#xA;  char* output = decodeImage(inputString, sizeof(inputString));&#xA;  Serial.printf(&quot;%s&quot;,output); // prints garbage&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is, that the result of the decoding INSIDE the function seems to be correct, but when I return the value to the calling code, the value get garbled somehow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose this has something to do with pointer magic or &quot;decaying&quot; of references. Has someone a suggestion?&lt;/p&gt;&#xA;" OwnerUserId="23482" LastActivityDate="2016-06-29T14:41:44.623" Title="Problems returning char array from function, value gets messed up" Tags="|c++|esp8266|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25830" PostTypeId="1" AcceptedAnswerId="25833" CreationDate="2016-06-29T14:21:06.050" Score="0" ViewCount="674" Body="&lt;p&gt;I have been working on a recent project to build an Arduino Oscilloscope interfaced with a 4X4 keypad membrane with Nokia 5110 LCD display.I have successful individual code fragments/portions which&#xA;1)Generate waves interfaced with the keyboard&#xA;2)Display the same on the Nokia LCD 5110&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i am using the Arduino Due and the 1st part of my code generates waves on DAC1 with the code as follows:-&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Waveforms.h&quot;&#xA;#include &amp;lt;Keypad.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;//Set the desired duty cycle in percentage&#xA;&#xA;double dc,t,a,d;&#xA;long d_milli,d_micro,a_milli,a_micro,m,n;&#xA;int stage =0;&#xA;&#xA;int sample_delay1;&#xA;LiquidCrystal lcd(A2, A3, A4, A5, A6, A7);&#xA;float sample_delay;&#xA;String num1,num2;&#xA;int wave1;&#xA;String wave_name;&#xA;double duty_cycle,k;&#xA;const byte ROWS = 4; //four rows&#xA;const byte COLS = 4; //four columns&#xA;//define the cymbols on the buttons of the keypads&#xA;char hexaKeys[ROWS][COLS] = {&#xA;  {'1','2','3','A'},&#xA;  {'4','5','6','B'},&#xA;  {'7','8','9','C'},&#xA;  {'.','0','#','D'}&#xA;};&#xA;byte rowPins[ROWS] = {23,25,27,29}; //connect to the row pinouts of the keypad&#xA;byte colPins[COLS] = {31,33,35,37}; //connect to the column pinouts of the keypad&#xA;int i = 0;&#xA;int sample;&#xA;//initialize an instance of class NewKeypad&#xA;Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);&#xA;boolean in_setup = true;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  analogWriteResolution(12);  // set the analog output resolution to 12 bit (4096 levels)&#xA;  analogReadResolution(12);&#xA;  lcd.begin(20,4);&#xA;  char key = customKeypad.getKey();&#xA;  lcd.setCursor(0, 0);&#xA;  lcd.print(&quot;choose wave: &quot;);&#xA;  lcd.setCursor(0, 1);&#xA;  lcd.print(&quot;A=Sine&quot;);&#xA;  lcd.setCursor(8, 1);&#xA;  lcd.print(&quot;B=Triangular&quot;);&#xA;  lcd.setCursor(0, 2);&#xA;  lcd.print(&quot;C=Sawtooth&quot;);&#xA;  lcd.setCursor(11, 2);&#xA;  lcd.print(&quot;D=Square&quot;);&#xA;&#xA;  while( true)&#xA;  {&#xA;        char key = customKeypad.getKey();&#xA;        if(stage == 0)&#xA;        {&#xA;              Serial.println(&quot;in stage 0&quot;);&#xA;              if(key == 'A' )&#xA;              {&#xA;                wave1 = 0;&#xA;                lcd.clear();&#xA;                lcd.setCursor(0,0);&#xA;                lcd.print(&quot; Sine?      &quot;);&#xA;                wave_name =&quot;Sinusoidal&quot;;&#xA;                Serial.println(wave_name);&#xA;&#xA;              }&#xA;              else if(key == 'B')&#xA;              {&#xA;                wave1 = 1;&#xA;                lcd.clear();&#xA;                lcd.setCursor(0,0);&#xA;                lcd.print(&quot;Triangular?&quot;);&#xA;                wave_name =&quot;Triangular&quot;;&#xA;                Serial.println(wave_name);&#xA;              }&#xA;              else if(key == 'C')&#xA;              {&#xA;                wave1 = 2;&#xA;                lcd.clear();&#xA;                lcd.setCursor(0,0);&#xA;                lcd.print(&quot;Sawtooth?  &quot;);&#xA;                wave_name =&quot;Sawtooth&quot;;&#xA;                Serial.println(wave_name);&#xA;              }&#xA;              else if(key == 'D')&#xA;              {&#xA;                wave1 = 3;&#xA;                lcd.clear();&#xA;                lcd.setCursor(0,0);&#xA;                lcd.print(&quot;Square?    &quot;);&#xA;                wave_name =&quot;Square&quot;;&#xA;                Serial.println(wave_name);&#xA;&#xA;              }&#xA;              else if(key == '#')&#xA;              {&#xA;                stage++;&#xA;                //lcd.clear();&#xA;                lcd.setCursor(0,1);&#xA;                lcd.print(&quot;Frequency=&quot;);&#xA;                Serial.println(&quot;Frequency=&quot;);&#xA;              }&#xA;        }&#xA;       else if(stage == 1)&#xA;        {&#xA;              if(key != NO_KEY &amp;amp;&amp;amp;(key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'))&#xA;              {&#xA;                num1 = num1 + key;&#xA;                //int numLength = num1.length();&#xA;                //to adjust one whitespace for operator&#xA;                lcd.setCursor(10,1);&#xA;                lcd.print(num1);&#xA;              }&#xA;&#xA;              else if(key == '#')&#xA;              {&#xA;                    k = num1.toInt();&#xA;                    Serial.print(k);&#xA;&#xA;                          int sample_delay_int = 1000000/(k*120);&#xA;                          float sample_delay_float = 1000000/(k*120);&#xA;                          float difference= sample_delay_float-sample_delay_int;&#xA;                          sample_delay1 = sample_delay_int - 6;&#xA;                          if(difference &amp;gt; 0.5)&#xA;                          {&#xA;                            sample_delay1++;&#xA;                          }&#xA;&#xA;                          Serial.println(sample_delay1);&#xA;                          lcd.clear();&#xA;                          lcd.print(wave_name);&#xA;                          lcd.setCursor(0,1);&#xA;                          lcd.print(&quot;Frequency=&quot;);&#xA;                          lcd.print(num1);&#xA;                          lcd.print(&quot; Hz&quot;);&#xA;                          break;&#xA;                  }&#xA;              }&#xA;   }&#xA;}&#xA;&#xA;void loop()&#xA;  {&#xA;  analogWrite(DAC1, waveformsTable[wave1][i] );&#xA;  i++;&#xA;  if(i == maxSamplesNum)  // Reset the counter to repeat the wave&#xA;    i = 0;&#xA;  else&#xA;    delayMicroseconds(sample_delay1);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next, I input these waves from DAC1 into analog input A0 to display on the LCD with code as below:-&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;Adafruit_PCD8544.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#define DISPLAY_WIDTH 84&#xA;#define DISPLAY_HEIGHT 48&#xA;&#xA;#define ARDUINO_PRECISION 1023.0&#xA;Adafruit_PCD8544 display = Adafruit_PCD8544(8,9,10,12,11);&#xA;&#xA;//Analog Pins&#xA;int channelAI = A0;      // probe&#xA;&#xA;#define DELAY_POTENTIMETER //disabled it I don't have it connected&#xA;#ifdef DELAY_POTENTIMETER&#xA;int delayAI = A1;       // delay potentiometer&#xA;#endif&#xA;&#xA;float delayVariable = 0;&#xA;float scale = 0;&#xA;int xCounter = 0;&#xA;int yPosition = 0;&#xA;int readings[DISPLAY_WIDTH+1];&#xA;int counter = 0;&#xA;&#xA;unsigned long drawtime = 0;&#xA;unsigned long lastdraw = 0;&#xA;int frames = 0;&#xA;&#xA;void setup(void)&#xA;{&#xA;  display.begin();&#xA;  display.setContrast(30);// you might have a slightly different display so it might not be the optimal value for you&#xA;  display.clearDisplay();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  #ifdef DELAY_POTENTIMETER&#xA;  delayVariable = analogRead(delayAI);&#xA;  delayVariable = (delayVariable/100);&#xA;  #endif&#xA;  scale = (float)(DISPLAY_HEIGHT-1)/ARDUINO_PRECISION;&#xA;&#xA;  //record readings&#xA;  for(xCounter = 0; xCounter &amp;lt;= DISPLAY_WIDTH; xCounter++)&#xA;  {&#xA;    yPosition = analogRead(channelAI);&#xA;    readings[xCounter] = (yPosition*scale);&#xA;    #ifdef DELAY_POTENTIMETER&#xA;    delay (delayVariable);&#xA;    #endif&#xA;  }&#xA;&#xA;  display.clearDisplay();&#xA;&#xA;  //Draw Voltage Ref Lines&#xA;  display.drawLine( 10, 0, 10, DISPLAY_HEIGHT-1, BLACK);&#xA;  display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), BLACK);&#xA;  //display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), BLACK);&#xA;&#xA;  //Draw Voltage Ref Numbers&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.2));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.4));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.6));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.8));&#xA;&#xA;  for(xCounter = 0; xCounter &amp;lt;= DISPLAY_WIDTH; xCounter++)&#xA;  {&#xA;    display.drawPixel(xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);&#xA;    if(xCounter&amp;gt;1){&#xA;      display.drawLine(xCounter-1, (DISPLAY_HEIGHT-1)-readings[xCounter-1], xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);&#xA;    }&#xA;  }&#xA;  //Draw FPS&#xA;  display.setCursor((DISPLAY_WIDTH-1)-11,0);&#xA;  display.print(frames);&#xA;&#xA;  //Draw Voltage&#xA;  display.setCursor(((DISPLAY_WIDTH-1)/2),0);&#xA;  display.print(analogRead(channelAI)/ARDUINO_PRECISION*5.0);&#xA;&#xA;  display.display();&#xA;&#xA;  //Calculate FPS&#xA;  drawtime = micros();&#xA;  frames=1000000/*a second*//(drawtime-lastdraw);&#xA;  lastdraw = drawtime;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the problem arises when i try doing the 2 things on d same arduino due board.&#xA;I got perfect results when i used arduino due and arduino uno simultaneously but have not been able to generate waves on the LCD using the same board.&#xA;Is it possible to do the same. Can some1 help me incorporate the 2 programs into 1  ..Thanxx&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried playing around with my setup() and loop() and have reached a point where my program does everything ,ie takes keypad input ,displays options on the LCD ,takes in freq and generates a splashscreen but the only thing i'm missing out on is d wave display on the LCD (I'm able to see the selected wave on the DSO) ..So i guess i'm pretty close, and the edited code is as follows:-&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;waveforms.h&quot;&#xA;#include &amp;lt;Keypad.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;#include &amp;lt;Adafruit_GFX.h&amp;gt;&#xA;#include &amp;lt;gfxfont.h&amp;gt;&#xA;&#xA;#include &amp;lt;Adafruit_PCD8544.h&amp;gt;&#xA;&#xA; //Set the desired duty cycle in percentage&#xA;Adafruit_PCD8544 display = Adafruit_PCD8544(8, 9, 10, 12, 11);&#xA;double dc,t,a,d;&#xA;long d_milli,d_micro,a_milli,a_micro,m,n;&#xA;int stage =0;&#xA;&#xA;int sample_delay1;&#xA;float sample_delay;&#xA;String num1,num2;&#xA;int wave1;&#xA;String wave_name;&#xA;double duty_cycle,k,Z;&#xA;const byte ROWS = 4; //four rows&#xA;const byte COLS = 4; //four columns&#xA;//define the cymbols on the buttons of the keypads&#xA;char hexaKeys[ROWS][COLS] = {&#xA;  {'1','2','3','A'},&#xA;  {'4','5','6','B'},&#xA;  {'7','8','9','C'},&#xA;  {'.','0','#','D'}&#xA;};&#xA;byte rowPins[ROWS] = {23,25,27,29}; //connect to the row pinouts of the keypad&#xA;byte colPins[COLS] = {31,33,35,37}; //connect to the column pinouts of the keypad&#xA;int i = 0;&#xA;int t_sample;&#xA;&#xA;#define DISPLAY_WIDTH 84&#xA;#define DISPLAY_HEIGHT 48&#xA;&#xA;#define ARDUINO_PRECISION 1023.0&#xA;//Adafruit_PCD8544 display = Adafruit_PCD8544(8,9,10,12,11);&#xA;&#xA;//Analog Pins&#xA;int channelAI=A0;&#xA;&#xA;#define DELAY_POTENTIMETER //disabled it I don't have it connected&#xA;#ifdef DELAY_POTENTIMETER&#xA;int delayAI = A1;       // delay potentiometer&#xA;#endif&#xA;&#xA;float delayVariable = 0;&#xA;float scale = 0;&#xA;int xCounter = 0;&#xA;int yPosition = 0;&#xA;int readings[DISPLAY_WIDTH+1];&#xA;int counter = 0;&#xA;&#xA;unsigned long drawtime = 0;&#xA;unsigned long lastdraw = 0;&#xA;int frames = 0;&#xA;&#xA;//initialize an instance of class NewKeypad&#xA;Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);&#xA;boolean in_setup = true;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  analogWriteResolution(12);  // set the analog output resolution to 12 bit (4096 levels)&#xA;  analogReadResolution(12);&#xA;  display.begin(20,4);&#xA;&#xA;  char key = customKeypad.getKey();&#xA;&#xA;  display.begin();&#xA;  display.display();&#xA;  display.setContrast(40);// you might have a slightly different display so it might not be the optimal value for you&#xA;  display.clearDisplay();&#xA;&#xA;  display.setTextSize(1);&#xA;  display.setTextColor(BLACK);&#xA;  display.setCursor(0, 0);&#xA;  display.print(&quot;choose wave: &quot;);&#xA;  display.display();&#xA;  display.setCursor(1, 8);&#xA;  display.print(&quot;A=Sine&quot;);&#xA;  display.display();&#xA;  display.setCursor(1,16);&#xA;  display.print(&quot;B=Triangular&quot;);&#xA;  display.display();&#xA;  display.setCursor(1,24);&#xA;  display.print(&quot;C=Sawtooth&quot;);&#xA;  display.display();&#xA;  display.setCursor(1,32);&#xA;  display.print(&quot;D=Square&quot;);&#xA;  display.display();&#xA;&#xA;  while( true)&#xA;  {&#xA;    char key = customKeypad.getKey();&#xA;    if(stage == 0)&#xA;    {&#xA;      Serial.println(&quot;in stage 0&quot;);&#xA;      if(key == 'A' )&#xA;      {&#xA;        wave1 = 0;&#xA;        display.clearDisplay();&#xA;        display.setCursor(0,0);&#xA;        display.print(&quot; Sine?      &quot;);&#xA;        display.display();&#xA;        wave_name =&quot;Sinusoidal&quot;;&#xA;        Serial.println(wave_name);&#xA;&#xA;      }&#xA;      else if(key == 'B')&#xA;      {&#xA;        wave1 = 1;&#xA;        display.clearDisplay();&#xA;        display.setCursor(0,0);&#xA;        display.print(&quot;Triangular?&quot;);&#xA;        display.display();&#xA;        wave_name =&quot;Triangular&quot;;&#xA;        Serial.println(wave_name);&#xA;      }&#xA;      else if(key == 'C')&#xA;      {&#xA;        wave1 = 2;&#xA;        display.clearDisplay();&#xA;        display.setCursor(0,0);&#xA;        display.print(&quot;Sawtooth?  &quot;);&#xA;        display.display();&#xA;        wave_name =&quot;Sawtooth&quot;;&#xA;        Serial.println(wave_name);&#xA;      }&#xA;      else if(key == 'D')&#xA;      {&#xA;        wave1 = 3;&#xA;        display.clearDisplay();&#xA;        display.setCursor(0,0);&#xA;        display.print(&quot;Square?    &quot;);&#xA;        display.display();&#xA;        wave_name =&quot;Square&quot;;&#xA;        Serial.println(wave_name);&#xA;&#xA;      }&#xA;      else if(key == '#')&#xA;      {&#xA;       stage++;&#xA;       display.clearDisplay();&#xA;       display.setCursor(20, 8);&#xA;       display.println(&quot;Freq=&quot;);&#xA;       display.display();&#xA;       Serial.println(&quot;Frequency=&quot;);&#xA;      }&#xA;    }&#xA;    else if(stage == 1)&#xA;    {&#xA;      if(key != NO_KEY &amp;amp;&amp;amp;(key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'))&#xA;      {&#xA;        num1 = num1 + key;&#xA;        //int numLength = num1.length();&#xA;        //to adjust one whitespace for operator&#xA;        display.setTextSize(1);&#xA;        display.setTextColor(BLACK);&#xA;        display.setCursor(48, 9);&#xA;        display.print(num1);&#xA;        display.display();&#xA;      }&#xA;      else if(key == '#')&#xA;      {&#xA;        stage++;&#xA;        k = num1.toInt();&#xA;        Serial.print(k);&#xA;        display.setTextSize(1);&#xA;        display.setTextColor(BLACK);&#xA;        display.display();&#xA;        display.setCursor(10, 1);&#xA;&#xA;        int sample_delay_int = 1000000 / (k * 120);&#xA;        float sample_delay_float = 1000000 / (k * 120);&#xA;        float difference = sample_delay_float - sample_delay_int;&#xA;        sample_delay1 = sample_delay_int - 6;&#xA;        if (difference &amp;gt; 0.5)&#xA;        {&#xA;          sample_delay1++;&#xA;        }&#xA;&#xA;        display.display();&#xA;        Serial.println(sample_delay1);&#xA;        display.clearDisplay();&#xA;        display.print(wave_name);&#xA;        display.setCursor(1, 8);&#xA;        display.println(&quot;Freq=&quot;);&#xA;        display.print(num1);&#xA;        display.println(&quot; Hz&quot;);&#xA;        break;&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  //record readings&#xA;  for(xCounter = 0; xCounter &amp;lt;= DISPLAY_WIDTH; xCounter++)&#xA;  {&#xA;    yPosition = analogRead(A0);&#xA;    readings[xCounter] = (yPosition*scale);&#xA;    #ifdef DELAY_POTENTIMETER&#xA;    delay (delayVariable);&#xA;    #endif&#xA;  }&#xA;&#xA;  display.clearDisplay();&#xA;&#xA;  #ifdef DELAY_POTENTIMETER&#xA;  delayVariable = analogRead(delayAI);&#xA;  display.display();&#xA;  delayVariable = (delayVariable/100);&#xA;  #endif&#xA;  scale = (float)(DISPLAY_HEIGHT-1)/ARDUINO_PRECISION;&#xA;&#xA;  //Draw Voltage Ref Lines&#xA;  display.drawLine( 10, 0, 10, DISPLAY_HEIGHT-1, BLACK);&#xA;  display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), BLACK);&#xA;  display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), BLACK);&#xA;  //display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), BLACK);&#xA;&#xA;  //Draw Voltage Ref Numbers&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.2));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.4));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.6));&#xA;  display.setCursor(0,((DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale))-3);&#xA;  display.print((int)(5.0*0.8));&#xA;&#xA;  for(xCounter = 0; xCounter &amp;lt;= DISPLAY_WIDTH; xCounter++)&#xA;  {&#xA;    display.drawPixel(xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);&#xA;    if(xCounter&amp;gt;1){&#xA;      display.drawLine(xCounter-1, (DISPLAY_HEIGHT-1)-readings[xCounter-1], xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);&#xA;    }&#xA;  }&#xA;  //Draw FPS&#xA;  display.setCursor((DISPLAY_WIDTH-1)-11,0);&#xA;  display.print(frames);&#xA;&#xA;  //Draw Voltage&#xA;  display.setCursor(((DISPLAY_WIDTH-1)/2),0);&#xA;  display.print(analogRead(A0)/ARDUINO_PRECISION*5.0);&#xA;&#xA;  display.display();&#xA;&#xA;  //Calculate FPS&#xA;  drawtime = micros();&#xA;  frames=1000000/(drawtime-lastdraw);&#xA;  lastdraw = drawtime;&#xA;  display.display();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  analogWrite(DAC1, waveformsTable[wave1][i] );&#xA;  i++;&#xA;  if(i == maxSamplesNum)  // Reset the counter to repeat the wave&#xA;    i = 0;&#xA;  else&#xA;  delayMicroseconds(sample_delay1);&#xA;&#xA;  analogWrite(DAC0, waveformsTable[wave1][i] );&#xA;  i++;&#xA;  if(i == maxSamplesNum)  // Reset the counter to repeat the wave&#xA;    i = 0;&#xA;  else&#xA;    delayMicroseconds(sample_delay1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can some1 possibly tinker around with this ..It'll b a huge help!!&lt;/p&gt;&#xA;" OwnerUserId="23470" LastEditorUserId="7508" LastEditDate="2016-06-30T07:38:48.950" LastActivityDate="2016-06-30T07:38:48.950" Title="Arduino oscilloscope" Tags="|arduino-due|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25831" PostTypeId="2" ParentId="25829" CreationDate="2016-06-29T14:32:50.213" Score="6" Body="&lt;p&gt;Your variable &lt;code&gt;decodedString[]&lt;/code&gt; is created inside the function, used inside the function - and destroyed inside the function before it returns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See how your function &lt;code&gt;decodeImage()&lt;/code&gt; returns a &lt;code&gt;char *&lt;/code&gt;? That's a &lt;em&gt;pointer&lt;/em&gt; to a character array, not the whole array - and you can't return a whole array. The pointer is successfully returned all right - but what it is pointing to is overwritten by future calls and future created variables.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the perennial problem of C programmers: how to return something created inside the function. You have four choices (each with their own problems):&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You can make the variable global - put it outside the function and let anyone access it. Then you don't even need to return the string - it's already accessible.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can make &lt;code&gt;decodedString&lt;/code&gt; a permanent part of the function by making it &lt;code&gt;static&lt;/code&gt;:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static char decodedString[64];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note that the above two solutions have the same two problems:&lt;br&gt;&#xA;  a. There is only one array. That means that if the same function is called again, it will &lt;em&gt;overwrite&lt;/em&gt; the results from last time - use it before you lose it!&lt;br&gt;&#xA;  b. You can't calculate the length and then use it - it has to be created at the maximum possible size.  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can make the caller pass in the array to fill. Rather than return the array, have another parameter that is the array to fill - and for safety's sake, get them to pass in the size of the array too. You'll have to check that and return an error if it's not big enough - or do something else sensible.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;You can allocate the memory from a different area that where it's currently being allocated from. That area is called the &quot;heap&quot; - it's just a heap o' memory that you can request chunks from - and don't forget to give it back!&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To request memory from the heap, you call the function &lt;code&gt;malloc&lt;/code&gt; and pass in the number of bytes that you want. It returns a pointer to that lump of memory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *decodedString = (char *)malloc(decodedLength);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;malloc&lt;/code&gt; doesn't know what you're going to use the memory for, so you have to tell the compiler - that's what the &lt;code&gt;(char *)&lt;/code&gt; before the call to &lt;code&gt;malloc&lt;/code&gt; does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you use &lt;code&gt;malloc&lt;/code&gt;, at some stage you must give the memory back with a call to &lt;code&gt;free&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;free(returnedString);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The function that did the &lt;code&gt;malloc&lt;/code&gt; doesn't have to be the function that &lt;code&gt;free&lt;/code&gt;s it - any function can, as long as some function does! Otherwise you'll run out of heap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing that you must NOT do is call &lt;code&gt;free&lt;/code&gt; on the same block twice: that will corrupt the heap, since it will mark the same block on the heap twice, and hand it back out twice later, corrupting the data when it is used again.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;EDIT&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;There's a C++ version of &lt;code&gt;malloc&lt;/code&gt; / &lt;code&gt;free&lt;/code&gt; called &lt;code&gt;new&lt;/code&gt; / &lt;code&gt;delete&lt;/code&gt;. You use them similarly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *decodedString = new char[decodedLength];&#xA;...&#xA;// And later...&#xA;delete [] returnedString;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It looks and behaves similarly to &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt;, without the ugly &lt;code&gt;(char *)&lt;/code&gt; type-cast. Note that since an array was allocated with the &lt;code&gt;new&lt;/code&gt;, you need to call the array version of &lt;code&gt;delete&lt;/code&gt; by adding the &lt;code&gt;[]&lt;/code&gt; as shown.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-06-29T14:41:44.623" LastActivityDate="2016-06-29T14:41:44.623" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25832" PostTypeId="2" ParentId="25825" CreationDate="2016-06-29T15:06:14.413" Score="1" Body="&lt;p&gt;In your Java version, you define &lt;code&gt;MainClass&lt;/code&gt; like this (my comments added):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;public class MainClass{ // Define a new Class&#xA;    DoClass d;          // Add a member variable to the class&#xA;    public MainClass(){&#xA;        d = new DoClass(this); // Initialise the member variable&#xA;    } // MainClass()&#xA;} // MainClass&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your C++ you don't do the same thing - but you should! The class needs a &lt;code&gt;DoClass&lt;/code&gt; member so that you can use it in other &lt;code&gt;MainClass&lt;/code&gt; functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MainClass.h&#xA;...&#xA;#include &quot;DoClass.h&quot; // Need the .h here - remove it from the .cpp&#xA;class MainClass&#xA;{&#xA;  public:&#xA;    MainClass();&#xA;    void setup();&#xA;    void loop();&#xA;    void printStuff();&#xA;  private:&#xA;    DoClass _d; // Create a private member variable to use&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MainClass.cpp&#xA;MainClass::MainClass() : // MainClass constructor (note colon)&#xA;           _d(*this) // Initialise member&#xA;{&#xA;} // MainClass::MainClass()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, you want &lt;code&gt;DoClass&lt;/code&gt; to be able to use &lt;code&gt;MainClass&lt;/code&gt;, so you passed it into &lt;code&gt;DoClass&lt;/code&gt;'s constructor. But &lt;code&gt;DoClass&lt;/code&gt; cannot have a &lt;code&gt;MainClass&lt;/code&gt; inside it - &lt;code&gt;MainClass&lt;/code&gt; already has a &lt;code&gt;DoClass&lt;/code&gt; inside it! Infinite impossibility! So you need &lt;code&gt;DoClass&lt;/code&gt; to merely contain a &lt;em&gt;reference&lt;/em&gt; to the &lt;code&gt;MainClass&lt;/code&gt; that it sits inside. That's the C++ unary &lt;code&gt;&amp;amp;&lt;/code&gt; operator (different from the binary &lt;code&gt;&amp;amp;&lt;/code&gt; operator), which is used similar to the pointer &lt;code&gt;*&lt;/code&gt; operator:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// DoClass.h&#xA;...&#xA;// Need to advise compiler MainClass exists...&#xA;// but can't #include MainClass.h! Infinite loop!&#xA;class MainClass;&#xA;&#xA;class DoClass&#xA;{&#xA;public:&#xA;    DoClass(MainClass &amp;amp;m); // Reference to MainClass&#xA;    void callMainClassFunct();&#xA;private:&#xA;    MainClass &amp;amp;_m; // Reference to MainClass&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// DoClass.cpp&#xA;DoClass::DoClass(MainClass &amp;amp;m) : // DoClass constructor - note colon&#xA;         _m(m) // Initialise member variable&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-29T15:06:14.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25833" PostTypeId="2" ParentId="25830" CreationDate="2016-06-29T15:21:46.533" Score="0" Body="&lt;p&gt;You have two programs. One has a &lt;em&gt;very&lt;/em&gt; complicated &lt;code&gt;setup()&lt;/code&gt;, but a very quick &lt;code&gt;loop()&lt;/code&gt;. The other has a very small &lt;code&gt;setup()&lt;/code&gt;, but a &lt;em&gt;very&lt;/em&gt; complicated &lt;code&gt;loop()&lt;/code&gt;. And you want to merge the two programs?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That will be very, very difficult. Your first program &lt;code&gt;loop()&lt;/code&gt; looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;   analogWrite(...); // Very quick code&#xA;   i++;              // Very quick code&#xA;   if (..)           // Very quick code&#xA;      i = 0;         // Very quick code&#xA;   else              // ***BUG!!!*** This shoud not be here!&#xA;   delayMicroseconds(...); // Very specific timing delay&#xA;} // loop()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In other words, to produce the correct waveform it does very few instructions very quickly - and then waits a carefully calculated time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your other program's &lt;code&gt;loop()&lt;/code&gt; does lots of things, and doesn't care about timing. The code is not time-sensitive at all - and writing to the display takes variable time anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your only choice is to set a timer to interrupt every &lt;code&gt;sample_delay1&lt;/code&gt; microseconds, and inside the timer interrupt handler do the &lt;code&gt;analogWrite(...);&lt;/code&gt; call instead of having the &lt;code&gt;loop()&lt;/code&gt; function do it. That is Advanced Arduino programming!&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-29T15:21:46.533" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25836" PostTypeId="2" ParentId="25828" CreationDate="2016-06-29T16:53:44.047" Score="4" Body="&lt;p&gt;The Arduino Mega's &quot;serial&quot; connection comes from an external chip implementing USB-serial conversion.  While this chip knows if a session is open with a host, the standard design has no way to share that information with the main ATmega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In contrast, on a Leonardo type board the main processor implements the USB interface, so it does know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your options include changing the requirement, having the PC program send some data to the Arduino, changing the processor to an ATmega or ARM with integrated USB, or perhaps modifying the USB implementation.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-06-29T16:53:44.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25837" PostTypeId="1" CreationDate="2016-06-29T18:25:31.667" Score="1" ViewCount="438" Body="&lt;p&gt;This is my very first Arduino project. I want to learn about GPS navigation by exploring the &lt;a href=&quot;https://en.wikipedia.org/wiki/NMEA_0183&quot; rel=&quot;nofollow noreferrer&quot;&gt;NMEA protocol&lt;/a&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore, I bought a WeeBee GPS module. After reading the datasheet, I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The &lt;a href=&quot;http://playground.arduino.cc/Tutorials/GPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;official Arduino website&lt;/a&gt; states &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note: if you are using an Arduino Uno, keep in mind that you can't use the GPS module at the same time as your computer is connected on the USB port.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I you go to the end of his tutorial, you will see he can transmit the GPS data to his computer. I don't understand why it would not be possible...&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The GPS module datasheet (&lt;a href=&quot;http://pan.baidu.com/s/1hsrWhoC#path=%252FWeBee%252FGP-001&quot; rel=&quot;nofollow noreferrer&quot;&gt;download link here&lt;/a&gt;) states that the maximum voltage is 5V. But it also states &lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;serial connections are 3.3V CMOS Logic Levels&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Suitable decoupling must be provided by external decoupling circuitry.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So, does it mean I need a logic level converter to prevent damage to the GPS module?&lt;/p&gt;&#xA;" OwnerUserId="23487" LastEditorUserId="4628" LastEditDate="2017-05-27T15:36:16.447" LastActivityDate="2018-05-24T10:56:59.647" Title="Connect GPS module (WeeBee) to Arduino Uno" Tags="|arduino-uno|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25841" PostTypeId="1" CreationDate="2016-06-29T22:14:06.340" Score="0" ViewCount="3684" Body="&lt;p&gt;How do I connect a SPDT relay to an Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B008MPK0VE&quot; rel=&quot;nofollow noreferrer&quot;&gt;a DC 5V Coil 6 Pin relay&lt;/a&gt; and ultimately what I want to do is have the Arduino trigger the relay to allow voltage to pass through.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I couldn't find a data sheet, but apparently this is the layout...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----------------------------------&#xA;|....1......2..............3.....|&#xA;|................................|&#xA;|....4......5..............6.....|&#xA;----------------------------------&#xA;&#xA;2 and 5 are the 5v relay coil&#xA;3 and 6 are shorted together&#xA;3 and 1 are normally closed&#xA;3 and 4 are normally open&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mkb94.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mkb94.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2017-04-27T09:31:14.937" Title="How to wire up and trigger this SPDT relay?" Tags="|relay|wires|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25842" PostTypeId="2" ParentId="25837" CreationDate="2016-06-29T22:42:07.577" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;The article on the Arduino website means that you can't upload sketches from your PC to the Arduino or receive any sort of data, through the serial monitor or otherwise, from your PC, while the GPS module uses the RX pin. Any attempt to send data from PC to Uno in this condition would cause the Arduino to receive only corrupted data, since 2 devices (GPS module and PC) would be trying to send data &lt;em&gt;at the same time&lt;/em&gt;, &lt;em&gt;with the same line&lt;/em&gt;. This limitation is easily resolved by connecting the GPS module to a &lt;code&gt;SoftwareSerial&lt;/code&gt; port instead; this keeps the &lt;code&gt;HardwareSerial&lt;/code&gt; port (pins 0 &amp;amp; 1) free for bidirectional PC-Arduino communication.&lt;/li&gt;&#xA;&lt;li&gt;The datasheet says that the maximum power supply voltage is 5 V. However, the serial connections are 3.3 V logic, so yes, you will need logic level shifters. A simple voltage divider will serve. However, 'external decoupling' refers to circuitry used in decoupling/smoothing out any spikes or dips that may occur in the supply voltage. An untamed spike could damage the device, while a dip (perhaps from large current draw) could cause the device to stop working, if the voltage falls low enough to be considered under-voltage. A 10uF electrolytic capacitor, connected from Vcc to GND close to the GPS module, should be okay.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-06-29T22:42:07.577" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25843" PostTypeId="2" ParentId="12217" CreationDate="2016-06-29T22:57:36.993" Score="1" Body="&lt;p&gt;Yes, sort of. All the Analogs/digitals can be used as digital outputs with the following exceptions. TX0/RX0 (unless you are aware of what you're doing), SPI buss (SCK/MOSI/MISO), SDA1/SCL1, &amp;amp; CANRX/CANTX. DAC0/DAC1 may be used but be aware the min/max those two pins can output is ~0.55 to 2.75V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And these exclusions are only for an arduino DUE. Other Arduino's will have more/less exclusions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Correction:  I was able to use CANRX and CANTX as alias pin names to declare these two lines as digital outputs, and set the pin values high/low in the normal way.&lt;/p&gt;&#xA;" OwnerUserId="21086" LastEditorUserId="-1" LastEditDate="2018-06-01T22:23:37.043" LastActivityDate="2018-06-01T22:23:37.043" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="25845" PostTypeId="2" ParentId="25841" CreationDate="2016-06-29T23:03:58.423" Score="0" Body="&lt;p&gt;According to the link you've provided, the coil draws very little current, and the person posting that comment suggests that it can be directly driven by an arduino. I would hesitate to use more than one to a board without additional research in that respect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The comment also suggests that a capacitor be placed across the coil terminals, which will also protect your circuit from excessive power draw causing drop outs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The research I've done indicates that the digital pins can handle a maximum of 40 ma, but the recommendation is no more than 20 ma, which is lower than the specs for this relay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are going to use more than one on a given arduino board, a shift register or equivalent would protect your board and give you reliable results. For a single relay, consider this resource:&#xA;&lt;a href=&quot;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/transistors&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/transistors&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some additional research may lead one to believe that even 20 ma is too much current to draw, so the transistor option is certainly the safer route.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Be certain to use pull-up or pull-down resistors, depending on your configuration with the digital pin selected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You didn't indicate what you were going to be connecting to the N/O or N/C pins, but that won't matter if they are external to the arduino and do not exceed the specifications of the relay.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-29T23:03:58.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25846" PostTypeId="1" CreationDate="2016-06-29T23:49:13.163" Score="0" ViewCount="211" Body="&lt;p&gt;I've searched google honestly but can't find an answer nor changelogs for Arduino that might be the answer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I'm trying to use Serial.readString() to input commands to the Serial Monitor but it shows an error that readString is not a member of 'HardwareSerial'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino 1.0 as IDE because the device I'm using (Aceduino) seems to have a custom IDE derived from 1.0 so I'm not sure if it will work with newer IDE versions. Wondering if that was what's causing the eror&lt;/p&gt;&#xA;" OwnerUserId="23495" LastActivityDate="2016-06-30T09:59:38.647" Title="Serial.readString() not working becaue of outdated IDE?" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25848" PostTypeId="1" CreationDate="2016-06-30T01:18:34.570" Score="-1" ViewCount="86" Body="&lt;p&gt;Is there a way to make the CC3000 read the DOM of a website instead of the HTML on the file?&lt;/p&gt;&#xA;&lt;p&gt;I'm using the WebClient file which works fine and prints the HTML of the webpage, but the website I'm trying to read from has its HTML different from its DOM (ie: Javascript modifies the HTML once the page loads).&lt;/p&gt;&#xA;&lt;p&gt;Can I use something other than &lt;code&gt;www.read()&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="23498" LastEditorUserId="61722" LastEditDate="2022-07-25T23:33:56.870" LastActivityDate="2022-07-25T23:33:56.870" Title="Arduino Uno + cc3000 breakout board - read DOM instead of HTML" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="25849" PostTypeId="1" AcceptedAnswerId="25851" CreationDate="2016-06-30T01:19:56.773" Score="1" ViewCount="335" Body="&lt;p&gt;I need to power my camera peripheral with an external power supply, since apparently I can't power both the camera and the camera's relay switch with my 5V out pin (My relays cut out and continually reset themselves if I try to run my 5V to both the camera relay switch and the relay board VCC.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'm powering the camera with a 5V battery pack and my arduino with my PC, but I still need to communicate with it via UART, so I need the camera ground to be the same as my arduino ground. Can I connect the two? Is this a bad idea? Because I'm doing it now and it seems to work. I just don't want to cause a problem later on down the road, whether I'm connected to my computer or on battery power.Any advice would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="19892" LastEditorUserId="19892" LastEditDate="2016-06-30T01:26:58.967" LastActivityDate="2016-06-30T01:44:59.067" Title="Can I connect my arduino ground to an external battery ground? Are they the same when said battery is powering the arduino?" Tags="|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25851" PostTypeId="2" ParentId="25849" CreationDate="2016-06-30T01:44:59.067" Score="1" Body="&lt;p&gt;A battery's ground is floating. That means that it's &quot;happy&quot; to take on any absolute value by simply connecting it to another ground - it just stops floating. This is why it's easy to connect a battery-powered phone directly to a computer to get the photos off or whatever.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only time you shouldn't connect two grounds is if neither are floating. A good example would be the grounds of two different houses, which are physically connected to the Earth (as in the planet). It'd be difficult to budge the whole Earth's ground level!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But shouldn't they be the same? Unfortunately not. You could measure a distinct voltage difference (sometimes in the hundreds of volts) between two house earths due to the differences in their makeup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One small note: if you do connect two grounds, only connect them in one spot. If you have two other ground pins a small distance away from the connected ones, there may be a voltage difference between them: now the two are explicitly relative to each other, so neither can be considered floating &lt;em&gt;relative to each other&lt;/em&gt;. The pair as a system - if neither are earthed at least - is still floating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These so-called &quot;ground loops' can induce current where none is desired.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-06-30T01:44:59.067" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25852" PostTypeId="2" ParentId="20773" CreationDate="2016-06-30T02:13:48.443" Score="0" Body="&lt;p&gt;AVR's like all digital have their limits. In this case you're dealing with source resistances that need to charge multiple gate capacitances through series resistances (wires and metal contact connections. Specifically an Absolute MAX 40mA/pin, some milliohms in your copper wire and PCB traces, and pico to nano Farad capacitances, plus depending on how High Speed the SPI is (the spec does not list an upper limit), you will be also contending with frequency limiting parasitics. At MHz frequencies, your wire and PCB traces will have higher resistances due to &quot;skin&quot; effect, where the electrons migrate to the surface of the wire when transferring. Depending on frequency of the wire, adding just a single gate could degredate rise/fall times enough to corrupt data, as the SPI library (whichever you choose) and the SPI peripheral within the AVR probably won't be as sophisticated as a PC based one. The AVR &amp;amp; the SPI library lacks sophistication in that neither has provisions to detect and compensate for extra gate capacitance on the bus line, nor could they compensate for china jumper wires which are quite small (9x40ga) wiring. &#xA;There are many factors which could corrupt your SPI project that are coming into play to limit performance. &#xA;You should probably do some internet research on high speed bus anatomy if you intend on pushing the SPI bus on the arduino to it's limits. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the gate capacitances are combining with source resistance and skin effect and your 40mA/pin is not in fact 40mA per pin but more like 10-20mA is hitting all gate capacitances when skin effect is considered (it effectively raises the resistance of the wire sufficiently to then be a factor). &#xA;If connecting the JY-MCU converter AND running SPI at minimum speed corrects communication, then the extra gate capacitances are the factor you should change to higher performance versions. There's the 74AS series with gate times down to 1.7nS and fMAX up to 40MHz!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this helps. &lt;/p&gt;&#xA;" OwnerUserId="21086" LastActivityDate="2016-06-30T02:13:48.443" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25853" PostTypeId="1" AcceptedAnswerId="25862" CreationDate="2016-06-30T03:14:43.810" Score="1" ViewCount="170" Body="&lt;p&gt;Good evening everyone,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have bene playing around with making my own library, specifically for the controlling Timer1 on the Arduino Mega 2560. I'm sort of new to OOP but I am trying my hand at it here. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote some code to generate a PWM wave with a 100 ms period and a 25% duty cycle, and I have Siglent SDS 1052DL, 50MHz oscilloscope that I'm using that verifies the code is successful. I am using clear-timer-on-compare-match mode and timer interrupts to generate the PWM wave. My code is below:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Timer1.h&quot;&#xA;&#xA;Timer1 timer;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  pinMode(13, OUTPUT);&#xA;  timer.begin();&#xA;}&#xA;&#xA;void loop(){&#xA;  // put your main code here, to run repeatedly:&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I made a Timer1.cpp file and a Timer1.h to go along with this file. They are below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Timer1.cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Timer1.h&quot;&#xA;&#xA;float frequency = 10.0;&#xA;float period_ms;&#xA;float clock_pulse = 16.0;&#xA;&#xA;unsigned long opening_time = 25000;&#xA;&#xA;unsigned int ocr1a;&#xA;unsigned int ocr1b;&#xA;&#xA;Timer1::Timer1() { // Object used to control 16-bit timer1&#xA;&#xA;}&#xA;&#xA;void Timer1::begin() {&#xA;  CRITICAL_SECTION_START; // Clear I bit&#xA;  CLEAR_TCCR1A; // Reset TCCR1A&#xA;  CLEAR_TCCR1B; // Reset TCCR1B&#xA;  SET_CTC_MODE; // Set to CTC mode&#xA;  DISABLE_TIMER1_INTERRUPTS; // Disable OCIE1A/B&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12); // 256&#xA;  period_ms = (1000.0f / frequency);&#xA;  ocr1a = 1000UL * (period_ms / clock_pulse);&#xA;  OCR1A = ocr1a;&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;&#xA;  ocr1b = (unsigned int)float(opening_time) / clock_pulse;&#xA;  OCR1B = ocr1b;&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1B);&#xA;  TCNT1 = 0; // Reset counter&#xA;&#xA;  CRITICAL_SECTION_END; // Set I bit&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect) {&#xA;  digitalWrite(13, HIGH);&#xA;}&#xA;&#xA;ISR(TIMER1_COMPB_vect) {&#xA;  digitalWrite(13, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Timer1.h&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef TIMER1_H&#xA;#define TIMER1_H&#xA;&#xA;// ========== HANDY MACROS ========== //&#xA;#define CLEAR_TCCR1A                  TCCR1A = 0&#xA;#define CLEAR_TCCR1B                  TCCR1B = 0&#xA;#define SET_CTC_MODE                  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12)&#xA;#define DISABLE_TIMER1_INTERRUPTS     TIMSK1 &amp;amp;= ~((1 &amp;lt;&amp;lt; OCIE1B) | (1 &amp;lt;&amp;lt; OCIE1A))&#xA;#define CLEAR_CLOCK_SELECT_BITS       TCCR1B &amp;amp;= ~((1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS11) | (1 &amp;lt;&amp;lt; CS10))&#xA;&#xA;#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()&#xA;#define CRITICAL_SECTION_END   SREG = _sreg&#xA;&#xA;class Timer1{&#xA;  public:&#xA;  // Constructor:&#xA;  Timer1();&#xA;  // Begin:&#xA;  void begin();&#xA;&#xA;};&#xA;&#xA;#endif // TIMER1_H&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code works exactly as I would expect. I originally had placed the whole block of code found in the Timer1::begin() method in the Timer1::Timer1() constructor method. When I did this, I was getting a completely different signal (2.04 ms period with about an 80% duty cycle). Is there a simple explanation for what is occurring?&lt;/p&gt;&#xA;" OwnerUserId="12039" LastActivityDate="2016-06-30T09:40:29.790" Title="What is the difference between running code with the scope of the void setup() or void loop() vs. outside their scope?" Tags="|arduino-mega|c++|interrupt|timers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25854" PostTypeId="2" ParentId="25853" CreationDate="2016-06-30T04:29:47.720" Score="1" Body="&lt;p&gt;I believe you should be able to put your code back into the constructor if you move all the variable you defined with file scope in Timer1.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float frequency = 10.0;&#xA;float period_ms;&#xA;float clock_pulse = 16.0;&#xA;&#xA;unsigned long opening_time = 25000;&#xA;&#xA;unsigned int ocr1a;&#xA;unsigned int ocr1b;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...to the Timer1 class definition (either in the public or private section).  This way all the variables will have the scope of the class and the code should work the same regardless where in the class it is.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-30T04:29:47.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25858" PostTypeId="1" AcceptedAnswerId="25863" CreationDate="2016-06-30T05:56:12.800" Score="0" ViewCount="775" Body="&lt;p&gt;So I recently tried to make a hand gesture controlled robot but ran into some programming error. Here are the specs:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the transmitter module, I used the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;*Arduino Nano 3.0 as the Microcontroller development platform&lt;br&gt;&#xA;   *Grove 3 axis digital accelerometer 16g for sensing hand gesture&lt;br&gt;&#xA;   *RF transmitter 433 Mhz (Transmitter: JMR-TX1)&lt;br&gt;&#xA;   *Power source: 7.2V rechargeable battery unit to power up the Arduino Nano&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the robot, I used the following:&#xA;  *Pololu Chassis&#xA;  *Two DC geared motors, compatible wheels&#xA;  *L293D Dual DC motor controller module&#xA;  *Arduino Nano 3.0&#xA;  *RF receiver 433 Mhz (Receiver: RXB6)&#xA;  *Power source: 7.2V rechargeable battery unit to power up the Arduino Nano&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hooked up all the parts carefully. I uploaded the code entitled &quot;Transimitter_code&quot; to the transmitter. I uploaded a code called &quot;Receiver_test&quot; and used serial monitor to see if the robot's arduino received data from the transmitter, the data I wanted to receive was the angle that the accelerometer was tilted on x and y axis measured by the accelerometer. Fortunately, the Arduino was receiving data wirelessly and displaying it in the serial monitor, which means my basic concept was ok. You can see the code attached to this thread. P.s. You will need three libraries: Wire.h, VirtualWire.h and ADXL345.h to run the codes. You can google them up and get them for free. &lt;strong&gt;See the code for the transmitter below:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Code for the transmitter of the mind controlled bot */&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;ADXL345.h&amp;gt;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;ADXL345 adxl; //variable adxl is an instance of the ADXL345 library&#xA;int ledPin = 13; //a sign when the transmitter is working&#xA;&#xA;&#xA;int TX_PIN = 11;// Tell Arduino on which pin you would like to Transmit data NOTE should be a PWM Pin&#xA;int TX_ID = 3; // Transmitter ID address&#xA;&#xA;typedef struct roverRemoteData// Data Structure &#xA;{&#xA; int    TX_ID;      // Initialize a storage place for the outgoing TX ID&#xA; int    x1;// Initialize a storage place for the first integar that you wish to Send &#xA; int    y1;// Initialize a storage place for the Second integar that you wish to Send&#xA;};&#xA;&#xA;void setup() {&#xA; vw_setup(2000);//Bits per second&#xA; pinMode(ledPin,OUTPUT);&#xA; vw_set_tx_pin(TX_PIN);// Set Tx Pin&#xA; Serial.begin(9600);//Initialise the serial connection&#xA;&#xA; adxl.powerOn(); &#xA;&#xA;//set activity/ inactivity thresholds (0-255)&#xA;adxl.setActivityThreshold(75); //62.5mg per increment&#xA;adxl.setInactivityThreshold(75); //62.5mg per increment&#xA;adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?&#xA;&#xA;//look of activity movement on this axes - 1 == on; 0 == off &#xA;adxl.setActivityX(1);&#xA;adxl.setActivityY(1);&#xA;adxl.setActivityZ(1);&#xA;&#xA;//look of inactivity movement on this axes - 1 == on; 0 == off&#xA;adxl.setInactivityX(1);&#xA;adxl.setInactivityY(1);&#xA;adxl.setInactivityZ(1);&#xA;&#xA;//look of tap movement on this axes - 1 == on; 0 == off&#xA;adxl.setTapDetectionOnX(0);&#xA;adxl.setTapDetectionOnY(0);&#xA;adxl.setTapDetectionOnZ(1);&#xA;&#xA;//set values for what is a tap, and what is a double tap (0-255)&#xA;adxl.setTapThreshold(50); //62.5mg per increment&#xA;adxl.setTapDuration(15); //625us per increment&#xA;adxl.setDoubleTapLatency(80); //1.25ms per increment&#xA;adxl.setDoubleTapWindow(200); //1.25ms per increment&#xA;&#xA;//set values for what is considered freefall (0-255)&#xA;adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment&#xA;adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment&#xA;&#xA;//setting all interrupts to take place on int pin 1&#xA;//I had issues with int pin 2, was unable to reset it&#xA;adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );&#xA;adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );&#xA;adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );&#xA;adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );&#xA;adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );&#xA;&#xA;//register interrupt actions - 1 == on; 0 == off  &#xA;adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);&#xA;adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);&#xA;adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);&#xA;adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);&#xA;adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;struct roverRemoteData payload;&#xA;payload.TX_ID = TX_ID; // Set the Radio Address &#xA;int x, y, z;&#xA;adxl.readXYZ(&amp;amp;x, &amp;amp;y, &amp;amp;z); //read the accelerometer values and store them in variables  x,y,z&#xA;payload.x1 = x;&#xA;payload.y1 = y;&#xA;vw_send((uint8_t *)&amp;amp;payload, sizeof(payload)); // Send the data &#xA;vw_wait_tx();// Wait for all data to be sent &#xA;if ((x&amp;gt;80) || (x&amp;lt;-80) || (y&amp;gt;80) || (y&amp;lt;-80))&#xA;{&#xA;digitalWrite(13, HIGH); //ledpin indicator&#xA;}&#xA;else&#xA;{&#xA; digitalWrite(13, LOW);&#xA;}&#xA;delay(100);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, I tried to use the received data to control the motion of the bot, that is: run the motors in specific direction. However, this time, the code seems to have some problem. &lt;strong&gt;Here's the code for the robot&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Mind controlled car - Car's code */&#xA;&#xA;#include &amp;lt;VirtualWire.h&amp;gt;&#xA;&#xA;int RX_PIN = 11;// Tell Arduino on which pin you would like to receive data NOTE should be a PWM Pin&#xA;int RX_ID = 3;// Recever ID address&#xA;int TX_ID;&#xA;&#xA;typedef struct roverRemoteData// Data Structure&#xA;{&#xA;int    TX_ID;      // Initialize a storage place for the outgoing TX ID&#xA;int    x1;// Initialize a storage place for the first integar that you wish to Send&#xA;int    y1;// Initialize a storage place for the Second integar that you wish to Send&#xA;};&#xA;&#xA;void setup() {&#xA;pinMode(5, OUTPUT); //in 1&#xA;pinMode(6, OUTPUT); //in 2&#xA;pinMode(9, OUTPUT); //in 3&#xA;pinMode(10, OUTPUT); //in 4&#xA;Serial.begin(9600);&#xA;vw_setup(2000);// Setup and Begin communication over the radios at 2000bps( MIN Speed is 1000bps MAX 4000bps)&#xA;vw_set_rx_pin(RX_PIN);// Set RX Pin&#xA;vw_rx_start();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;struct roverRemoteData receivedData;&#xA;uint8_t rcvdSize = sizeof(receivedData);//Incoming data size&#xA;vw_wait_rx();// Start to Receive data now&#xA;if (vw_get_message((uint8_t *)&amp;amp;receivedData, &amp;amp;rcvdSize)) // Check if data is available&#xA;{&#xA;if (receivedData.TX_ID == RX_ID) //Check if the radio signal recieved matches the ID of the Reciever&#xA;{&#xA;  if (((receivedData.x1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.x1 &amp;gt; -80)) &amp;amp;&amp;amp; ((receivedData.y1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.y1 &amp;gt; -80))) //halt&#xA;  {&#xA;    halt();&#xA;&#xA;  }&#xA;  else if (((receivedData.x1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.x1 &amp;gt; -80)) &amp;amp;&amp;amp; (receivedData.y1 &amp;gt; 80)) //forward&#xA;  {&#xA;    int a = receivedData.y1;&#xA;    goForward(a);&#xA;&#xA;&#xA;&#xA;  }&#xA;  else if (((receivedData.x1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.x1 &amp;gt; -80)) &amp;amp;&amp;amp; (receivedData.y1 &amp;lt; -80)) //backward&#xA;  {&#xA;    int b = -receivedData.y1;&#xA;    goBackward(b);&#xA;&#xA;&#xA;  }&#xA;  else if ((receivedData.x1 &amp;gt; 80) &amp;amp;&amp;amp; ((receivedData.y1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.y1 &amp;gt; -80))) //left&#xA;  {&#xA;    int c = receivedData.x1;&#xA;    goLeft(c );&#xA;&#xA;&#xA;&#xA;  }&#xA;  else if ((receivedData.x1 &amp;lt; -80) &amp;amp;&amp;amp; ((receivedData.y1 &amp;lt; 80) &amp;amp;&amp;amp; (receivedData.y1 &amp;gt; -80))) //right&#xA;  {&#xA;    int d = -receivedData.x1;&#xA;    goRight(d);&#xA;&#xA;  }&#xA;  }&#xA;  }&#xA;  }&#xA;&#xA;  void goForward(int y)&#xA;  {&#xA;  analogWrite(5, y);&#xA;  analogWrite(6, 0);&#xA;  analogWrite(9, y);&#xA;  analogWrite(10, 0);&#xA;  delay(50);&#xA;&#xA;&#xA;  }&#xA;&#xA;  void goBackward(int z)&#xA;  {&#xA;  analogWrite(5, 0);&#xA;  analogWrite(6, z);&#xA;  analogWrite(9, 0);&#xA;  analogWrite(10, z);&#xA;  delay(50);&#xA;&#xA;  }&#xA;&#xA;  void goLeft(int w)&#xA;  {&#xA;  analogWrite(5, w);&#xA;  analogWrite(6, 0);&#xA;  analogWrite(9, 0);&#xA;  analogWrite(10, 0);&#xA;  delay(50);&#xA;&#xA;  }&#xA;&#xA;  void goRight(int x)&#xA;  {&#xA;  analogWrite(5, 0);&#xA;  analogWrite(6, 0);&#xA;  analogWrite(9, x);&#xA;  analogWrite(10, 0);&#xA;  delay(50);&#xA;&#xA;  }&#xA;&#xA;  void halt()&#xA;  {&#xA;  analogWrite(5, 0);&#xA;  analogWrite(6, 0);&#xA;  analogWrite(9, 0);&#xA;  analogWrite(10, 0);&#xA;  delay(50);&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I wanted to use the analogWrite() function to control the speed of the motor. However, the code does not work at all if I use the analogWrite() function within the goForward(), goBackward(), goLeft(), goRight() functions to control the speed of the motor, only one of the motors keeps rotating at a certain speed without responding to the transmitter. Surprisingly, if I use digitalWrite() to control the motors, they work fine, instantly responding to the change in direction of the transmitter. P.S. I connected my motors to PWM pins of the Arduino.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What's the problem?&lt;/strong&gt; &lt;/p&gt;&#xA;" OwnerUserId="23506" LastActivityDate="2016-06-30T08:47:52.460" Title="Programming Problem with a hand gesture controlled robot; the analogwrite() function doesn't work" Tags="|programming|arduino-ide|arduino-nano|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25859" PostTypeId="1" AcceptedAnswerId="30640" CreationDate="2016-06-30T06:42:00.100" Score="1" ViewCount="627" Body="&lt;p&gt;I am using the Arduino IDE 1.6.0, &#xA;There is a project that has compiled both for Due and Mega on another computer. But on my machine, it only compiles for Due. When compiling  for &quot;Mega or Mega 2560&quot;, I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;/Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld: skipping incompatible /Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/libc.a when searching for -lc&#xA;      /Arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld: cannot find -lc&#xA;      collect2: error: ld returned 1 exit status&#xA;      Error compiling.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;My newbie guess is something is wrong with AVR libraries. But how to solve it? Also could someone please explain what &lt;code&gt;-lc&lt;/code&gt; is, which cannot be found? At first glance it looks like an option.&lt;/p&gt;&#xA;" OwnerUserId="10740" LastEditorUserId="4628" LastEditDate="2017-03-28T10:06:46.560" LastActivityDate="2017-07-27T09:41:25.440" Title="Compile Error for Arduino Mega" Tags="|arduino-mega|compile|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25860" PostTypeId="2" ParentId="25859" CreationDate="2016-06-30T07:19:34.807" Score="0" Body="&lt;p&gt;So what I did that solved the problem was, I downloaded the latest Arduino IDE, titled &quot;&lt;strong&gt;Windows ZIP file&lt;/strong&gt; for non admin install&quot;. Then I unzipped the download, and I copied all of the files of the new IDE and pasted them into the old installation. But I did not replace anything. i.e. For each file that existed, I kept the old file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;~400 new files were copied. Now it compiles without error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW since this has been a blind workaround, I will not accept this as the final answer.&lt;/p&gt;&#xA;" OwnerUserId="10740" LastEditorUserId="4628" LastEditDate="2017-03-28T10:07:42.050" LastActivityDate="2017-03-28T10:07:42.050" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25862" PostTypeId="2" ParentId="25853" CreationDate="2016-06-30T07:55:29.970" Score="3" Body="&lt;p&gt;In your test code, you declare &lt;code&gt;Timer1&lt;/code&gt; in global scope. This means its&#xA;constructor will be called right when the program starts, even before&#xA;&lt;code&gt;main()&lt;/code&gt; is called. The first thing the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp#L33&quot; rel=&quot;nofollow&quot;&gt;Arduino &lt;code&gt;main()&lt;/code&gt;&lt;/a&gt; does is&#xA;to call &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring.c#L241&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;init()&lt;/code&gt;&lt;/a&gt;, which configures all the timers for PWM&#xA;operation, as expected by &lt;code&gt;analogWrite()&lt;/code&gt;. Then, any initialization of&#xA;Timer1 done by the constructor will be undone by &lt;code&gt;init()&lt;/code&gt;. That's why&#xA;you want to defer that initialization until &lt;code&gt;setup()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I took the liberty to do a code review on your post. Below are&#xA;a few suggestions. I hope some of them might be useful.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Put the empty constructor in the .h file, this avoids it being&#xA;compiled into a real empty function.&lt;/li&gt;&#xA;&lt;li&gt;Qualify &lt;code&gt;frequency&lt;/code&gt;, &lt;code&gt;clock_pulse&lt;/code&gt; and &lt;code&gt;opening_time&lt;/code&gt; as &lt;code&gt;const&lt;/code&gt;,&#xA;and make &lt;code&gt;period_ms&lt;/code&gt; local to &lt;code&gt;Timer1::begin()&lt;/code&gt;. This way all the&#xA;floating point operations are performed at compile time and you&#xA;don't get all the floating point support compiled into your program.&lt;/li&gt;&#xA;&lt;li&gt;Your &lt;code&gt;CRITICAL_SECTION_*&lt;/code&gt; macros are redundant with&#xA;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ATOMIC_BLOCK(ATOMIC_RESTORESTATE)&lt;/code&gt; from avr-libc&lt;/a&gt;. But&#xA;then, do you really need to block the interrupts the whole time?&lt;/li&gt;&#xA;&lt;li&gt;I don't find the other macros in Timer1.h really useful either: just&#xA;put comments next to each access to a hardware register.&lt;/li&gt;&#xA;&lt;li&gt;I would set &lt;code&gt;TCCR1B&lt;/code&gt; last: the timer starts counting the moment you&#xA;set this register.&lt;/li&gt;&#xA;&lt;li&gt;You should subtract 1 from the values you set in &lt;code&gt;OCR1A&lt;/code&gt; and&#xA;&lt;code&gt;OCR1B&lt;/code&gt;: the period and HIGH time are &lt;code&gt;OCR1A+1&lt;/code&gt; and &lt;code&gt;OCR1B+1&lt;/code&gt;&#xA;respectively.&lt;/li&gt;&#xA;&lt;li&gt;You may want to round the period and HIGH time to the nearest&#xA;integer. It may make no difference here but you users may want to&#xA;change &lt;code&gt;frequency&lt;/code&gt; and &lt;code&gt;opening_time&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Your variables &lt;code&gt;ocr1a&lt;/code&gt; and &lt;code&gt;ocr1b&lt;/code&gt; serve no useful purpose, they&#xA;just needlessly eat RAM.&lt;/li&gt;&#xA;&lt;li&gt;You casting &lt;code&gt;opening_time&lt;/code&gt; to &lt;code&gt;float&lt;/code&gt;, then back to &lt;code&gt;unsigned int&lt;/code&gt;,&#xA;serves no useful purpose either.&lt;/li&gt;&#xA;&lt;li&gt;You may want to replace &lt;code&gt;digitalWrite()&lt;/code&gt; with direct port access, as&#xA;this function is really slow and you are calling it from an ISR.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Below is my throw at Timer1.cpp. Note that &lt;code&gt;port&lt;/code&gt; and &lt;code&gt;bit&lt;/code&gt; could be&#xA;made private data of the class, and the pin number could be a parameter&#xA;to the &lt;code&gt;begin()&lt;/code&gt; method.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &quot;Timer1.h&quot;&#xA;&#xA;/* The three constants below can be tuned to taste:  */&#xA;&#xA;const float frequency    = 10;  // hertz&#xA;const float opening_time = 25;  // milliseconds&#xA;const int   pin          = 13;&#xA;&#xA;/* Nothing should need to change below this line. */&#xA;&#xA;const uint16_t prescaler = 256;&#xA;const float f_timer = float(F_CPU) / prescaler;&#xA;static volatile uint8_t *port;&#xA;static uint8_t bit;&#xA;&#xA;void Timer1::begin() {&#xA;    // Prepare the output.&#xA;    port = portOutputRegister(digitalPinToPort(pin));&#xA;    bit = digitalPinToBitMask(pin);&#xA;    pinMode(pin, OUTPUT);&#xA;&#xA;    // Configure Timer 1.&#xA;    TCCR1A = 0;  // undo the configuration done by...&#xA;    TCCR1B = 0;  // ...the Arduino core library&#xA;    TCNT1  = 0;  // reset counter&#xA;    OCR1A  = round(f_timer / frequency) - 1;&#xA;    OCR1B  = round(f_timer * opening_time * 1e-3) - 1;&#xA;    TIMSK1 = _BV(OCIE1A)   // enable TIMER1_COMPA interrupt&#xA;           | _BV(OCIE1B);  // enable TIMER1_COMPB interrupt&#xA;    TCCR1B = _BV(WGM12)    // CTC mode&#xA;           | _BV(CS12);    // prescaler = 256&#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect) {&#xA;    *port |= bit;&#xA;}&#xA;&#xA;ISR(TIMER1_COMPB_vect) {&#xA;    *port &amp;amp;= ~bit;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-06-30T09:40:29.790" LastActivityDate="2016-06-30T09:40:29.790" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25863" PostTypeId="2" ParentId="25858" CreationDate="2016-06-30T08:47:52.460" Score="0" Body="&lt;p&gt;VirtualWire uses timer1, which would disable PWM on pins 9 and 10.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-06-30T08:47:52.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25864" PostTypeId="2" ParentId="25846" CreationDate="2016-06-30T09:59:38.647" Score="1" Body="&lt;p&gt;&lt;code&gt;Stream::readString()&lt;/code&gt; is available since version 1.0.1. See:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/build/shared/revisions.txt#L1038&quot; rel=&quot;nofollow&quot;&gt;changelog&lt;/a&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;the &lt;a href=&quot;https://github.com/arduino/Arduino/commit/39eed5a&quot; rel=&quot;nofollow&quot;&gt;corresponding commit&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-06-30T09:59:38.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25866" PostTypeId="1" CreationDate="2016-06-30T10:32:38.887" Score="1" ViewCount="11388" Body="&lt;p&gt;I am running a stepper motor using arduino and IC l293d. What is the maximum possible speed of rotation that I can achieve with the IC and what should be the applied voltage for the same? Earlier, I got the optimum rotation with a step size of 30 at 7V. I want to increase the step size. What should I do?&lt;/p&gt;&#xA;" OwnerUserId="23512" LastActivityDate="2016-10-28T19:15:49.070" Title="How to run stepper motor at its maximum speed" Tags="|arduino-uno|motor|stepper|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25868" PostTypeId="2" ParentId="25866" CreationDate="2016-06-30T11:58:42.713" Score="2" Body="&lt;p&gt;As &lt;a href=&quot;http://www.daycounter.com/Calculators/Stepper-Motor-Calculator.phtml&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Stepper motors are normally used for positioning, and are not known&#xA;  for their speed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;However, the link is to an on line stepping motor speed calculator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the size of the step, this is a function of the way the stepping motor is built.  Some controllers / stepping motor combinations can do half steps or micro steps.  Disable these feature for the fewest number of steps per revolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are some of the basic concepts which deal with practical stepping motor applications.  As speed increases, other factors come into play.  For example, resonance and inductance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;http://homepage.cs.uiowa.edu/~jones/step/physics.html&quot; rel=&quot;nofollow&quot;&gt;this paper&lt;/a&gt; resonance is discussed:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If a rigidly mounted stepping motor is rigidly coupled to a&#xA;  frictionless load and then stepped at a frequency near the resonant&#xA;  frequency, energy will be pumped into the resonant system, and the&#xA;  result of this is that the motor will literally lose control.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The paper also discusses the effect of the stepper motor's coil inductance:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;An important consideration in designing high-speed stepping motor&#xA;  controllers is the effect of the inductance of the motor windings. ...&#xA;  The inductance of the motor winding determines the rise and fall time&#xA;  of the current through the windings. ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-30T12:15:06.087" LastActivityDate="2016-06-30T12:15:06.087" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25870" PostTypeId="2" ParentId="25817" CreationDate="2016-06-30T12:40:55.917" Score="1" Body="&lt;p&gt;In general, once an embedded processor's interrupt fires, the interrupt routine clears the interrupt.  Usually inside the interrupt routine.  Failure to clear the interrupt normally inhibits further interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, in the Arduino paradigm, this is &quot;taken care of&quot; by the Arduino Timer library described &lt;a href=&quot;http://playground.arduino.cc/Code/Timer1&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  In the example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; *  Timer1 library example&#xA; *  June 2008 | jesse dot tane at gmail dot com&#xA; */&#xA;&#xA;#include &quot;TimerOne.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(10, OUTPUT);&#xA;  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period&#xA;  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle&#xA;  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt&#xA;}&#xA;&#xA;void callback()&#xA;{&#xA;  digitalWrite(10, digitalRead(10) ^ 1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // your program here...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...you can see that the example does not actually contain &quot;the&quot; Timer interrupt routine but rather a callback() routine which the Timer library calls when the Timer interrupt occurs.  Code to clear the Timer interrupt is missing and assumed to be in the Timer library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider this if you are writing you own interrupt routine instead of using the Arduino's Timer library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I'm going to have to call foul on myself.  Clearing interrupts in their own interrupt routine is very common.  But looking at &lt;a href=&quot;https://oscarliang.com/arduino-timer-and-interrupt-tutorial/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;, where the Atmel timer hardware is directly controlled (that is, the normal Arduino Timer library is not being used) and the real interrupt handler exists in the sketch, I see where this is not done.  So, for the Atmel, there must be at least one timer mode where the timer interrupt does not have to be clear for the interrupt to happen again.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are using the Arduino's Timer library consider this warning from the Timer's library web page linked to above:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Be careful about trying to execute too complicated of an interrupt at&#xA;  too high of a frequency, or the CPU may never enter the main loop and&#xA;  your program will 'lock up'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Finally, hardware timed interrupts are normally reserved for operations which are time sensitive and occur much faster than executing code can handle.  For events that happen on the order of seconds, most applications setup 1 timed interrupt to count off a convenient interval.  Say 1 second.  Code is used to keep count and call the proper functions at the intended time.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-06-30T12:57:53.137" LastActivityDate="2016-06-30T12:57:53.137" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25872" PostTypeId="2" ParentId="12915" CreationDate="2016-06-30T13:04:48.420" Score="0" Body="&lt;p&gt;Happened across &lt;a href=&quot;https://oscarliang.com/arduino-timer-and-interrupt-tutorial/&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; which explains Arduino timer interrupts with out using any libraries.  The Atmel timer hardware is discussed and the sketches not only control the hardware directly but also include the actual interrupt service routine.  So addresses the OP's question very well.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-30T13:04:48.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25875" PostTypeId="1" AcceptedAnswerId="26030" CreationDate="2016-06-30T14:59:15.057" Score="0" ViewCount="9710" Body="&lt;p&gt;How do I reset an ESP8266 with an FTDI and no reset button? I assume that it has something to do with the reset pin on the ESP8266, but I cannot find a step-by-step usage of the pin online.&lt;/p&gt;&#xA;" OwnerUserId="23248" LastActivityDate="2016-07-05T15:36:31.320" Title="How do I reset an ESP8266 with an FTDI and no reset button?" Tags="|esp8266|ftdi|reset|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="25882" PostTypeId="1" AcceptedAnswerId="25884" CreationDate="2016-06-30T18:49:16.870" Score="2" ViewCount="3499" Body="&lt;p&gt;As I understand, Arduino IDE considers two paths for the libraries:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;first, &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&quot;C:\Program Files\Arduino\libraries&quot;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and second, the &quot;libraries&quot; folder next to the schetchbook.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a configuration.h file, that I include in the main file, &lt;code&gt;Test.ino&lt;/code&gt;, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;configuration.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in the &lt;code&gt;configuration.h&lt;/code&gt; file I try to include &lt;code&gt;SPI.h&lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;fatal error: SPI.h: No such file or directory&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems that I am obliged to include &lt;code&gt;SPI.h&lt;/code&gt; only from the ino file. But why?&#xA;And how can I do what I want here? do I have to change IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S: the software is large and I am improving maintainability.&lt;/p&gt;&#xA;" OwnerUserId="10740" LastActivityDate="2016-07-01T13:33:39.963" Title="How to include &lt;SPI.h&gt; outside the .ino file" Tags="|arduino-ide|spi|compile|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25883" PostTypeId="2" ParentId="18966" CreationDate="2016-06-30T20:07:15.703" Score="1" Body="&lt;p&gt;I have one, and I haven't figured out how to get it to accept input, but have received responses.  Here are some things to try:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Make sure you have your jumpers set for D2 and D3.  Just telling software serial to look at 2 and 3 doesn't mean your board is jumpered that way.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Also, remember that Tx for the board = Rx on the arduino and in your code.  Software serial is (rx, tx), so (2,3) means your board will be jumpered with tx on 2 and rx on 3.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;There are four LEDs on the board.  If all four aren't lit, the board is powered down, and won't do anything.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First, make sure your power switch is set right - &quot;VCC Switch&quot;, by&#xA;the USB connector, is set to the power level of your board.  I'm&#xA;using an Uno at 5V, so for me that's set to 5V.   &lt;/li&gt;&#xA;&lt;li&gt;It's best to provide power through your barrel connector on your Arduino &lt;em&gt;and&lt;/em&gt; connection through the USB.  GSM modules &lt;em&gt;are&lt;/em&gt; power hogs.&lt;/li&gt;&#xA;&lt;li&gt;With all of that plugged in, your board should show two lights, the first and third.   &lt;/li&gt;&#xA;&lt;li&gt;Now hit the &quot;PWR&quot; button.  The second light will come on dimly, then stronger.  Now the module has power. &lt;/li&gt;&#xA;&lt;li&gt;Finally, the fourth light will come on when the module has detected network. At that point, the 5216 will start sending you messages.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;You need to make sure your baudrate is set properly.  Anything less than a Mega can't handle communication at 115200, which is the default for the module.  At best, you'll set both Serial and SoftwareSerial for 115200 baud, and you'll get mostly correct characters from the board, but an occasional bad character.  &lt;/li&gt;&#xA;&lt;li&gt;Here are some great instructions for changing the default baudrate at &lt;a href=&quot;https://github.com/jeanbritz/ArduinoTestScripts&quot; rel=&quot;nofollow noreferrer&quot;&gt;Github from some JeanBritz&lt;/a&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;One caveat to those instructions: make sure you have your Itead board powered by the Uno &lt;em&gt;before&lt;/em&gt; plugging into the mini USB.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here's a bit of light at the end of the tunnel for you - &lt;a href=&quot;https://i.stack.imgur.com/utotF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/utotF.png&quot; alt=&quot;what you&amp;#39;ll see when it&amp;#39;s sending properly.&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23524" LastActivityDate="2016-06-30T20:07:15.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25884" PostTypeId="2" ParentId="25882" CreationDate="2016-06-30T20:42:59.380" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems that I am obliged to include SPI.h only from the ino file. But why? And how can I do what I want here? do I have to change IDE?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The background is how the Arduino IDE pre-processor works together with the GCC AVR compiler and build tools. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler needs to know the include path to the libraries. This is created by the pre-processor by scanning the ino file and searching the known libraries. A compiler command line is built with the include paths to the located libraries. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you move the library includes to a configuration file the IDE pre-processor will not be able to locate the libraries and create the include paths. The pre-processor does not recursively scan library files. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-06-30T20:42:59.380" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25885" PostTypeId="1" AcceptedAnswerId="25894" CreationDate="2016-06-30T22:05:55.340" Score="0" ViewCount="715" Body="&lt;p&gt;&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to figure out that if we use &lt;code&gt;eeprom_write_block&lt;/code&gt; function or &lt;code&gt;eeprom_update_block&lt;/code&gt; function do we need to manually null terminate it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I came across &lt;a href=&quot;http://www.avrfreaks.net/forum/tut-c-using-eeprom-memory-avr-gcc&quot; rel=&quot;nofollow&quot;&gt;this tutorial on avr-freaks&lt;/a&gt; where in one comment it is said that you have to read the strings and null terminate them but there is no word about writing. Couldnt get anything the avr-libc manual as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have reserved some parts of eeprom using &lt;code&gt;EEMEM&lt;/code&gt;  and they are strings. I am not sure how long the string would be except that it would be smaller than a max value. Now When I would read the string back from the eeprom I would just be reading the maximum number of bytes as again I would have no idea of the size of the string. If the eeprom has a null value at the end of the string when writing to it, the read string will have that null at the correct place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Situation&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am saving mobile numbers of users as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint8_t EEMEM users[numberOfUsers][maxChar4Number];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when I get a number parsed and then save it to eeprom &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define eepu(message, EEADDR, BLKSIZE) eeprom_update_block((const void *)message, (void *)EEADDR, BLKSIZE);&#xA;&#xA;eepu(user, users[0], strlen(user)); //strlen(user) will be less than the maxChar4Number&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will write the number to eeprom. When I read the i would be reading maxChar4Number bytes and a number could have been shorter than that length.&lt;/p&gt;&#xA;" OwnerUserId="3277" LastEditorUserId="3277" LastEditDate="2016-06-30T23:03:22.280" LastActivityDate="2016-07-01T03:11:14.550" Title="does eeprom_write_block function of avr.eeprom.h writes a NULL terminated string or we have to manually null terminate it" Tags="|avr|eeprom|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25886" PostTypeId="1" AcceptedAnswerId="25888" CreationDate="2016-06-30T22:20:09.563" Score="0" ViewCount="47" Body="&lt;p&gt;I'm trying to control a garage door opener. The button that lets you open the door from the inside is a NC connection (press the button and it goes to &quot;open&quot; and makes the motor run).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to keep that AND add another source (an Arduino w/ an RF module) that taps in to this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some sort of splitter I'd add to the garage door button wires to do this?&lt;/p&gt;&#xA;" OwnerUserId="18905" LastActivityDate="2016-06-30T22:41:50.357" Title="Controlling a NC connection from two sources?" Tags="|wires|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25887" PostTypeId="2" ParentId="25885" CreationDate="2016-06-30T22:25:58.843" Score="1" Body="&lt;p&gt;Since one normally does not know how long a character string is, we need a way to convey this information.  One technique used to avoid confusion is to add a NULL character (which is a zero) to the end of the string.  Another is to explicitly state how long the string is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the case of the function eeprom_write_block() talked about &lt;a href=&quot;http://playground.arduino.cc/Code/EEPROMWriteAnything&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;, we see that we are formally passing not only a pointer to the string but also the size of the string.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-06-30T22:25:58.843" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25888" PostTypeId="2" ParentId="25886" CreationDate="2016-06-30T22:41:50.357" Score="0" Body="&lt;p&gt;Are you certain that your existing circuit is NC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The typical garage door opener button is a momentary switch. Many third party remote devices, including two that I have installed, tap directly into this circuit. Because the contacts short across the existing switch, activating one, two or three is insignificant. These switches are connected in parallel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be a good idea to use an external isolation circuit to the Arduino, either a relay or SSR in order to ensure that there is no &quot;injected&quot; power from your circuit to the garage door circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your circuit is indeed an NC type, you would connect your new relay or SSR in series, using the device's NC connections. The locations for tapping into the circuit would be where your existing button resides or where those two wires engage your garage door mechanism.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I suppose my older garage door opener is NO, while newer models would use a different architecture, aka NC.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-06-30T22:41:50.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25891" PostTypeId="2" ParentId="25848" CreationDate="2016-07-01T00:48:07.113" Score="0" Body="&lt;p&gt;The DOM is something related to browsers. A web server merely serves up stored HTML and any accompanying JS to the client CC3000. It's up to a browser to parse the document, execute any JS to construct the DOM tree and finally render the webpage based on the DOM--not something an Arduino is built for. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not an expert but you will have to forward the HTML from your Arduino to a browser and then somehow scrape the results after it renders the page. Or use a website that implements server-side rendering.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-07-01T00:48:07.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25893" PostTypeId="2" ParentId="19454" CreationDate="2016-07-01T03:05:01.827" Score="0" Body="&lt;p&gt;I know a very rough brute force idea, but I'm afraid you won't like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here, how it goes: Use additional relay for powering arduino: While arduino is turned on, let the power be connected to NC contact and after each cycle, just turn this output to HIGH. How it works, you ask? Well, after a cycle, you will with logic 1 (HIGH) state cause to &quot;unplug&quot; the arduino power, which will lead to loosing power supply. However, the relay has a spring, that in case of loosing power, it goes back to NC, in which case, your arduino will be reset and working for another cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should 100% work, but as I said before: It's a horrible brute force idea :)&lt;/p&gt;&#xA;" OwnerUserId="16810" LastActivityDate="2016-07-01T03:05:01.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25894" PostTypeId="2" ParentId="25885" CreationDate="2016-07-01T03:11:14.550" Score="1" Body="&lt;p&gt;If you write a block which happens to be null-terminated, then reading it back should be fine. I do that when I want to save a filename in EEPROM. Just declare a suitable length (allowing room for the null terminator) and write the entire block to EEPROM.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-01T03:11:14.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25895" PostTypeId="2" ParentId="25882" CreationDate="2016-07-01T03:15:35.553" Score="5" Body="&lt;p&gt;See my answer &lt;a href=&quot;https://arduino.stackexchange.com/a/13182/10794&quot;&gt;How the IDE organizes things&lt;/a&gt;. There is no easy way to avoid having to put an include in the main .ino file, unless you write your own build process (or perhaps use another toolchain).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think you could put SPI.h (and other things, like Wire.h) in the main .ino file, even if they aren't used due to your configuration parameters. The linker would strip them out because the modules were not referenced.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-07-01T03:15:35.553" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25897" PostTypeId="1" CreationDate="2016-07-01T05:15:02.767" Score="1" ViewCount="3240" Body="&lt;p&gt;I am using a wiper motor as a rotor. I am trying to get it to at least point in different azimuths (compass azimuths eg. 180 degrees) In order to do this, I am thinking about attaching a potentiometer on the axle inside the motor housing to see where the motor is pointing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So lets say the pot gives me a range of 0-1023. If I divide 1023 by 360 i get 2.84. So lets say the pot gives the Arduino a 1, I can relate that to 2.84 degrees?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what if the motor is pointing at 350 degrees, and I want it to point at 2 degrees. Instead of it turning around 348 degrees, it just cross pass 360 and go to 2 degrees.  How would a pot handle going over a single step? If the motor passed a single step would it consistently give me a 1023 reading?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to get a wiper motor to have a known position 360 degrees around. &lt;/p&gt;&#xA;" OwnerUserId="23532" LastEditorUserId="26916" LastEditDate="2017-09-09T08:24:42.687" LastActivityDate="2017-09-09T08:24:42.687" Title="Potentiometer on motor for position control" Tags="|potentiometer|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25898" PostTypeId="1" CreationDate="2016-07-01T06:27:16.420" Score="1" ViewCount="2089" Body="&lt;p&gt;i am not able to detect any android device on my bluetooth HM-10 module which is connected to arduino. i am able to see my bluetooth module on my android phone. but i want to see android phones on arduino serial monitor for that i used AT+DISC? command. it shows AT+DISCS and than AT+DISCE with a 2 second interval. help me to solve the issue&#xA;thanks in advance&lt;/p&gt;&#xA;" OwnerUserId="23534" LastEditorUserId="612" LastEditDate="2016-07-31T16:36:05.237" LastActivityDate="2018-11-06T19:44:16.013" Title="HM-10 discovery issue" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25900" PostTypeId="2" ParentId="25897" CreationDate="2016-07-01T07:03:04.083" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So lets say the pot gives the Ardunio a 1, I can relate that to 2.84&#xA;  degrees?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, if the pot goes from 0 to 1023 in 360 degrees of rotation, and it can rotate continuously. That sounds unlikely - f/ex, thinking about how a pot is made, how will it get from its maximum resistance to its minimum resistance in 2.8 degrees?&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Instead of it turning around 348 degrees, it just cross pass 360&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Smart software. :) You would need to read the pot, decide which direction of rotation will get from the current position to the new position, and select that direction in the motor drive circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;A pot doesn't really &quot;output&quot; anything; it is a variable-resistor, whose resistance can be measured by placing it in a known electric circuit and using an Arduino A2D input to measure a voltage in that circuit which depends on the resistance of the pot. The reading you get is a 10-bit integer. If you divided that by 1024, you'd have a pure fraction representing the measured voltage as a fraction of the A2D's full-scale voltage, which you select as INTERNAL (1.1v internal reference voltage), or EXTERNAL and apply a reference voltage to the chip's Aref pin. Usually that is the power-supply voltage, and in any case must not exceed the power-supply voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, back to reality, if you use the EXTERNAL reference with Aref connected to +5v, then the A2D readings would mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA; A2D  Volts  Mag.Azimuth&#xA;   0   0       0&#xA; 256   1.25   90&#xA; 512   2.5   180&#xA; 768   3.57  270&#xA;1023   4.99+ 359.6&#xA;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this case you probably don't care about the measured voltage, only it's relationship to 5v, which the A2D already gives you. That relationship equals the pot's relationship to 1 full rotation. So the azimuth, Az, you're seeking:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Az/360 = A2D / 1024, and&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Az = (A2D * 360)/1024&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-02T11:42:04.680" LastActivityDate="2016-07-02T11:42:04.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25901" PostTypeId="1" AcceptedAnswerId="25904" CreationDate="2016-07-01T07:51:43.460" Score="1" ViewCount="1389" Body="&lt;p&gt;When I run FullExample program from TinyGPS++, I get following types of entries,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sats HDOP Latitude   Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum&#xA;          (deg)      (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail&#xA;---------------------------------------------------------------------------------------------------------------------------------------&#xA;&#xA;0    9999 ********** *********** **** 07/01/2016 07:32:50 689  ****** ****** ***** ***   ******** ****** ***   75128 0         0        &#xA;0    9999 ********** *********** **** 07/01/2016 07:32:51 857  ****** ****** ***** ***   ******** ****** ***   75389 0         0        &#xA;0    9999 ********** *********** **** 07/01/2016 07:32:52 864  ****** ****** ***** ***   ******** ****** ***   75642 0         0        &#xA;0    9999 ********** *********** **** 07/01/2016 07:32:53 870  ****** ****** ***** ***   ******** ****** ***   75895 0         0        &#xA;0    9999 ********** *********** **** 07/01/2016 07:32:54 878  ****** ****** ***** ***   ******** ****** ***   76148 0         0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Other details:&lt;br&gt;&#xA;GPSBaud = 9600;&lt;br&gt;&#xA;RXPin = 11;&lt;br&gt;&#xA;TXPin = 10&lt;br&gt;&#xA;Module: GY-NEO6MV2&lt;/p&gt;&#xA;" OwnerUserId="23079" LastEditorUserId="23079" LastEditDate="2016-07-01T09:43:07.213" LastActivityDate="2021-03-08T11:12:19.553" Title="Not getting data from GPS" Tags="|arduino-mega|gps|tinygps|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25902" PostTypeId="2" ParentId="3927" CreationDate="2016-07-01T07:51:52.030" Score="1" Body="&lt;p&gt;the code below should give you a 8.4MHz signal on digital pin 7 of the due. I have used it to generate a 4.2MHz clock (by setting &lt;code&gt;REG_PWM_CPRD6 = 20;&lt;/code&gt; and &lt;code&gt;REG_PWM_CDTY6 = 10;&lt;/code&gt; but I think it should work for a 8.4MHz clock also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been using this to provide a 4.2MHz clock signal instead of using a crystal oscillator for an ADE7913 and can confirm it is working well in that application. I have taken this from the arduino forum &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=184799.0&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;const unsigned long serialPeriodMillis = 2000;&#xA;unsigned long previousMillis = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  int32_t mask_PWM_pin = digitalPinToBitMask(7);&#xA;  REG_PMC_PCER1 = 1 &amp;lt;&amp;lt; 4;                         // activate clock for PWM controller&#xA;  REG_PIOC_PDR |= mask_PWM_pin;                   // activate peripheral functions for pin (disables all PIO functionality)&#xA;  REG_PIOC_ABSR |= mask_PWM_pin;                  // choose peripheral option B&#xA;  REG_PWM_CLK = 0;                                // choose clock rate, 0 -&amp;gt; full MCLK as reference 84MHz&#xA;  REG_PWM_CMR6 = 0 &amp;lt;&amp;lt; 9;                          // select clock and polarity for PWM channel (pin7) -&amp;gt; (CPOL = 0)&#xA;  REG_PWM_CPRD6 = 10;                             // initialize PWM period -&amp;gt; T = value/84MHz (value: up to 16bit), value=10 -&amp;gt; 8.4MHz&#xA;  REG_PWM_CDTY6 = 5;                              // initialize duty cycle, REG_PWM_CPRD6 / value = duty cycle, for 10/5 = 50%&#xA;  REG_PWM_ENA = 1 &amp;lt;&amp;lt; 6;                           // enable PWM on PWM channel (pin 7 = PWML6)&#xA;&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Serial on&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if (millis() - previousMillis &amp;gt; serialPeriodMillis) {&#xA;    Serial.println(&quot;TIC&quot;);&#xA;    previousMillis = millis();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23003" LastActivityDate="2016-07-01T07:51:52.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25903" PostTypeId="2" ParentId="25897" CreationDate="2016-07-01T09:50:22.770" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am trying to get a wiper motor to have a known position 360 degrees around. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There might be a few possibilities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First there &lt;strong&gt;are&lt;/strong&gt; continuous rotation potentiometers on the market. They seem expensive though and I can't comment on how accurate they are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, &lt;strong&gt;if&lt;/strong&gt; your device is only ever going to turn through say ten revolutions then go back, you could just get a multiturn pot that will handle that range of turns. (Depends what you're building of course - for example I've heard of servo winches for model sailboats that use this method.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thirdly, and I accept this may not be a good answer to your question, but have you thought about using incremental encoders instead? In theory they could be more accurate too. The hardware is quite easy but a bit more programming is required to make these work...&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-07-01T09:50:22.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25904" PostTypeId="2" ParentId="25901" CreationDate="2016-07-01T09:53:50.943" Score="3" Body="&lt;p&gt;That is a &lt;strong&gt;&lt;em&gt;perfect&lt;/em&gt;&lt;/strong&gt; printout of a GPS system that can see &lt;strong&gt;zero&lt;/strong&gt; satellites.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that the timestamps are one second apart shows that you have correctly interfaced with the GPS device. Now, the GPS device has to 'interface' with the satellites!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many people don't realise two things:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The GPS antenna really does need a clear view of the sky. A tiny view through a window may show one or two satellites, but you need a minimum of three, and preferaby four or more at a number of points around the sky to get a fix.&lt;/li&gt;&#xA;&lt;li&gt;If the GPS unit has been completely powered off (called 'cold'), when it first powers on it has NO idea where anything is. It simply listens for any signal anywhere until it &quot;hears&quot; the current time. It can then guess where satellites might be, and listens for updates on satellite positions.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;All of this listening, guessing and waiting takes time before it can start to actually lock on to satellites and start to get a fix. This time could easily be 90 seconds or more - you need to be patient. Check your GPS device specifications for &quot;cold start&quot; times.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Edit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I'm impressed! The GY-NEO6MV2 that you list has a cold-start of 27 seconds - but that assumes it has a clear view of the sky.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-01T09:53:50.943" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25905" PostTypeId="2" ParentId="25882" CreationDate="2016-07-01T10:05:46.650" Score="2" Body="&lt;p&gt;The IDE has to be explicitly told each and every library that you use. It also has to be told each and every library that every library that you use uses. And so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE only looks in the INO files. As a result: if the library is not included in the main INO file then the IDE doesn't know that you intend to use it, and so it doesn't look for it.&lt;br&gt;&#xA;Only when it's in the INO file will the IDE actually look for where that library is located and append the right flags (-I...path...) to the compilation commands to be able to get at the files for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further, it is only then that it actually knows that it should compile the source code for a library. Without that knowledge, even if you explicitly point to the header file with a relative path, the IDE won't know that it should compile and link the source code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is no way around it, it's just the way the IDE works. The only option is to change to a different IDE that has more intelligence and can recursively deep-scan the libraries to maintain a list of prerequisites (such as my popular &lt;a href=&quot;http://uecide.org&quot; rel=&quot;nofollow&quot;&gt;UECIDE&lt;/a&gt; IDE).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-07-01T13:33:39.963" LastActivityDate="2016-07-01T13:33:39.963" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25906" PostTypeId="1" CreationDate="2016-07-01T10:12:41.093" Score="0" ViewCount="191" Body="&lt;p&gt;Can the following scenario exist? &#xA;&lt;a href=&quot;https://i.stack.imgur.com/gj5pr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gj5pr.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Microcontroller 1 sends a code to microcontroller 2 to start reading sensor data. Then Microcontroller 2 reads sensor data from sensor and sends it back to microcontroller 1. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If such a scenario is possible, then how would the pseudo code for microcontroller 2 receive-event be?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Need help with this badly!!&lt;/p&gt;&#xA;" OwnerUserId="23539" LastEditorUserId="4143" LastEditDate="2016-07-01T10:24:22.360" LastActivityDate="2016-08-30T10:37:35.827" Title="Arduino i2c communication between another arduino and a sensor" Tags="|arduino-uno|i2c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25907" PostTypeId="2" ParentId="25906" CreationDate="2016-07-01T10:31:02.550" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can the following scenario exist?&#xA;  Yes. Such a scenario is called &lt;em&gt;Multi-Master&lt;/em&gt;.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;If such a scenario is possible, then how would the pseudo code for microcontroller 2 receive-event be?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;MCU 2 would just be set up as any other slave. It waits, as normal, for an instruction in whatever for you like. Once it receives that instruction in then switches into master mode and makes a normal request exactly as you would from MCU 1 if you wanted it to read the sensor.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;On receive:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Set &quot;run as master flag&quot;&lt;/li&gt;&#xA;&lt;li&gt;Disable slave mode&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In loop: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &quot;run as master flag&quot; is set:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Perform request to get data from sensor&lt;/li&gt;&#xA;&lt;li&gt;Clear &quot;run as master flag&quot;&lt;/li&gt;&#xA;&lt;li&gt;Enable slave mode&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Running a multi-master system does have its own set of caveats and things you have to watch out for. You can read more about it here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.hackster.io/chipmc/arduino-i2c-multi-master-approach-why-and-how-93f638&quot; rel=&quot;nofollow&quot;&gt;https://www.hackster.io/chipmc/arduino-i2c-multi-master-approach-why-and-how-93f638&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-01T10:31:02.550" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25910" PostTypeId="1" CreationDate="2016-07-01T11:56:01.267" Score="1" ViewCount="91" Body="&lt;p&gt;I am sending data over serial connection from a python script to my Arduino UNO. Now initially whenever I tried to send data to the arduino, it would reset. The fix was to put a 10 microFarad capacitor between the 5V and RESET pins. I did that and everything started working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now after while,  mistakenly today I ran the same script without the capacitor between the 5V and RESET pins and for some reason it was working perfectly well. No more resetting when a value was received over serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is something wrong with my Arduino?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-08-31T14:00:06.167" Title="Unusual behaviour over serial communication" Tags="|arduino-uno|serial|python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25914" PostTypeId="2" ParentId="10170" CreationDate="2016-07-01T12:58:08.363" Score="1" Body="&lt;p&gt;ComputerNerds work is good, but it is has only code and limited description. I have prepared detailed instruction using his code. You can try it: &lt;a href=&quot;http://privateblog.info/arduino-uno-i-kamera-ov7670-primer-ispolzovaniya/&quot; rel=&quot;nofollow&quot;&gt;How to use OV7670 and Arduino uno&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15624" LastActivityDate="2016-07-01T12:58:08.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25915" PostTypeId="2" ParentId="25910" CreationDate="2016-07-01T13:31:09.467" Score="-1" Body="&lt;p&gt;Knowing the entire setup would help.  For instance, knowing if the RS232 source will drive the Arduino input's dangerously past the Arduino's power rails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have connected a real RS232 signal to the Arduino, &lt;a href=&quot;https://en.wikipedia.org/wiki/RS-232#Voltage_levels&quot; rel=&quot;nofollow noreferrer&quot;&gt;the +12 to -12 volt swings&lt;/a&gt; could adversely affect the processor.  Causing unexpected behavior.  In such a case you would need a converter like &lt;a href=&quot;https://www.sparkfun.com/products/13029&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Over driving inputs is discussed in &lt;a href=&quot;https://electronics.stackexchange.com/questions/28487/tolerating-logic-inputs-in-excess-of-vcc&quot;&gt;this Stack Exchange question&lt;/a&gt; where the highest scoring answer says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you violate the spec sheet normal operating conditions requirements&#xA;  you can expect to experience abnormal operating conditions. These may&#xA;  range fro perfectly normal opration through complete maloperation...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That answer also links to &lt;a href=&quot;https://learn.sparkfun.com/tutorials/using-the-logic-level-converter&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; about logic level conversion. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, there is &lt;a href=&quot;https://www.sparkfun.com/tutorials/215&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt; which specifically addresses converting RS232 to safe TTL level signals appropriate for a micro processor.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-02T13:00:51.157" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25916" PostTypeId="2" ParentId="25898" CreationDate="2016-07-01T14:23:11.733" Score="-1" Body="&lt;p&gt;Detecting the physical Bluetooth layer is likely different from detecting the underlying protocol.  So it might be that the Arduino code is waiting until it sees a specific Bluetooth protocol.  I am guessing that it wants to use a serial Bluetooth protocol (as oppose to music or some other protocol).  You have not given enough details to determine if this is the problem.  However, I would next test your devices / hardware by loading up what is assumed to be working code on both your Android and your Arduino to test the connection.  The code in &lt;a href=&quot;https://github.com/danasf/hm10-android-arduino&quot; rel=&quot;nofollow&quot;&gt;this project&lt;/a&gt; looks promising: &lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-01T14:23:11.733" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25917" PostTypeId="2" ParentId="2987" CreationDate="2016-07-01T14:23:24.733" Score="0" Body="&lt;p&gt;I have something similar happen a couple of times with some atmega328s (on arduino unos). I believe it was the bootloader that some how became corrupted and so no longer responded to the computer. The only way to fix this is to reflash the bootloader using an ISP programmer. Luckily the arduino can act as an ISP programmer so all you need is another working arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt; for how to do this on an uno. The same can be done with the micro/nano as they all use the same atmega328p chip its just a matter of wiring it up correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you cannot reflash the bootloader with this method then one of the chips is probably damaged and would need to be replaced. At this point it might be easier to replace the whole board.&lt;/p&gt;&#xA;" OwnerUserId="20585" LastActivityDate="2016-07-01T14:23:24.733" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25918" PostTypeId="1" CreationDate="2016-07-01T16:05:09.647" Score="0" ViewCount="343" Body="&lt;p&gt;The idea is to play the tone that is given by the center value read it by the center ultrasound sensor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code that is in Arduino is this one:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include NewPing.h&#xA;&#xA;#define PING_CENTER  2  // Arduino pin tied to both trigger and echo pins on the ultrasonic sensor.&#xA;#define PING_RIGHT  3&#xA;#define PING_LEFT  4&#xA;#define PING_MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.&#xA;#define buzzerPin = 10&#xA;&#xA;&#xA;long buzzerFreq1; // The frequency to buzz the buzzer&#xA;unsigned int BUZZ_FREQ_MAX = 2500; // Maximum frequency for the buzzer&#xA;unsigned int US_MAX = 2023; // Maximum value for ultrason sensor&#xA;int c1;&#xA;&#xA;NewPing sonar2(PING_CENTER, PING_CENTER, PING_MAX_DISTANCE); // NewPing setup of pin and maximum distance.&#xA;NewPing sonar3(PING_RIGHT, PING_RIGHT, PING_MAX_DISTANCE);&#xA;NewPing sonar4(PING_LEFT, PING_LEFT, PING_MAX_DISTANCE);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(buzzerPin, OUTPUT); // set pin for buzzer output &#xA;}&#xA;&#xA;void loop() { &#xA;  buzzerFreq1 = (center * BUZZ_FREQ_MAX) / US_MAX;&#xA;  buzz(buzzerPin,buzzerFreq1,10);&#xA;  // tone(buzzerPin, center);&#xA;  delay(500);  // Wait 500ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.&#xA;  unsigned int center = sonar2.ping() / US_ROUNDTRIP_CM; // Send ping, get ping time in microseconds (uS) and convert it to centimeters (cm)&#xA;  unsigned int right = sonar3.ping() / US_ROUNDTRIP_CM;&#xA;  unsigned int left = sonar4.ping() / US_ROUNDTRIP_CM;&#xA;  // Serial.println(&quot;Distance: &quot; + String(distanceInCms) + &quot;cm&quot;);&#xA;&#xA;  Serial.println(center);&#xA;  Serial.println(right);&#xA;  Serial.println(left);&#xA;&#xA;}&#xA;&#xA; // buzz(buzzerPin, buzzerFreq1, 10);&#xA; void buzz(int targetPin, long frequency, long length) {&#xA; // int c1 = center;&#xA;  buzzerFreq1 = (center * BUZZ_FREQ_MAX) / US_MAX;&#xA;  long delayValue = 1000000/frequency/2;&#xA;&#xA;  int numCycles = frequency * length/1000;&#xA;&#xA;  for (int i=0; i &amp;lt; numCycles; i++){&#xA;    digitalWrite(targetPin,HIGH);&#xA;    delayMicroseconds(delayValue);&#xA;    digitalWrite(targetPin,LOW);&#xA;    delayMicroseconds(delayValue);&#xA;  }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I receive the following error that I have no idea how to solve it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ultrason_onewire_sound.cpp: In function ‘void setup()’:&#xA;ultrason_onewire_sound.cpp:26:11: error: expected primary-expression before ‘=’ token&#xA;ultrason_onewire_sound.cpp: In function ‘void loop()’:&#xA;ultrason_onewire_sound.cpp:38:8: error: expected primary-expression before ‘=’ token&#xA;ultrason_onewire_sound.cpp: In function ‘void buzz(int, long int, long int)’:&#xA;ultrason_onewire_sound.cpp:48:18: error: ‘center’ was not declared in this scope&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23548" LastEditorUserId="972" LastEditDate="2016-07-01T18:33:59.560" LastActivityDate="2016-07-03T09:14:36.510" Title="I want to play a sound based on my ultrason sensor reading" Tags="|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25919" PostTypeId="1" CreationDate="2016-07-01T12:54:14.783" Score="0" ViewCount="261" Body="&lt;p&gt;I'm at the stage where I can #include headerFiles.h into my arduino sketches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm just beginning to wonder whether it's possible to append strings that are concatenated from integers which are analogRead from sensors to a .h file? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It'd make the arduino a lot more portable and would negate having to buy an SD card module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would the data be extracted? EEPROM is too small for datalogging past what you'd rack up in text over a reading every minute for a few hours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any clever clogs got ideas for this?&lt;/p&gt;&#xA;" OwnerUserId="25948" OwnerDisplayName="Garion Bracken" LastActivityDate="2016-07-02T05:37:51.037" Title="Append to .h file through arduino code" Tags="|c++|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25920" PostTypeId="2" ParentId="25919" CreationDate="2016-07-01T14:39:47.270" Score="3" Body="&lt;p&gt;Header files are part of your source code. The result of a build is a set of ones and zeros which are sent to your arduino and written in its Flash memory (the program space). The way you put these zeroes and ones together is completely up to you. You could write C and/or C++ code (where you have header files), you could write assembly code or you could write the zeroes and one directly on the disk, if you are crazy enough.&#xA;Header and Source files live only in the world of the developer and its toolchain, Arduino doesn't know they exist at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, if you want to store log data you could use a SD card like you said, or send it over the network, or you could use a serial connection. But I'm sure there are plenty of other options.&lt;/p&gt;&#xA;" OwnerDisplayName="Enrico" LastActivityDate="2016-07-01T15:58:46.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25921" PostTypeId="2" ParentId="25918" CreationDate="2016-07-01T18:37:34.560" Score="4" Body="&lt;p&gt;&lt;code&gt;#define buzzerPin = 10&lt;/code&gt; shouldn't have an &lt;code&gt;=&lt;/code&gt; in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the &lt;code&gt;=&lt;/code&gt; &lt;code&gt;pinMode(buzzerPin, OUTPUT);&lt;/code&gt; will turn into &lt;code&gt;pinMode(= 10, OUTPUT);&lt;/code&gt; by the pre-processor. Which would give the error, complaining about an &lt;code&gt;=&lt;/code&gt; token, you got.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="6628" LastEditDate="2016-07-01T20:49:23.600" LastActivityDate="2016-07-01T20:49:23.600" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25922" PostTypeId="1" AcceptedAnswerId="25923" CreationDate="2016-07-01T19:11:55.357" Score="3" ViewCount="1334" Body="&lt;p&gt;I would like to drive three sixteen-segment displays (&lt;a href=&quot;https://www.sparkfun.com/products/retired/9934&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/retired/9934&lt;/a&gt;) using an Arduino Micro. These displays would output an alphabetic character that a user would scroll through using rotary encoders, and constitute a subsystem of a larger project where the user enters a &quot;combination&quot; made from the three letters to &quot;unlock&quot; functionality in the larger device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best option, if it could be called that, is this retired product from SparkFun: &lt;a href=&quot;https://www.sparkfun.com/products/retired/10103&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/retired/10103&lt;/a&gt; that would allow me to drive the displays without a huge wiring mess, and spares me a lot of pins on the Micro to use on the rotary encoder. Unfortunately, the product is retired because the A6282 IC it was based on reached end of life, so even the schematics available on the product page aren't much use to me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware that four-character 16-segment displays are available, but for &quot;aesthetic&quot; reasons I am constraining myself to using single-character 16-segment displays. I do wonder how possible it would be to run three or four individual 16-seg displays from one of those LCD backpacks, but I don't think that would be trivial to do (I'd need to, probably, fabricate some sort of printed circuit board that spaced each display as far out as I need them to be, hook the pins of each display into a key matrix, and then at that point it'd be substantially easier to just get a MAX6954 (&lt;a href=&quot;https://www.maximintegrated.com/en/app-notes/index.mvp/id/3212&quot; rel=&quot;nofollow&quot;&gt;https://www.maximintegrated.com/en/app-notes/index.mvp/id/3212&lt;/a&gt;) and try to figure that out). It would be very clumsy to prototype.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'm looking for a solid method of prototyping this &quot;combination entry&quot; subsystem and its 16 segment displays without needing to put each dial and alphanumeric display on its own AVR or something.&lt;/p&gt;&#xA;" OwnerUserId="21415" LastActivityDate="2016-07-02T04:33:17.657" Title="Driving single-character alphanumeric (16-segment) displays" Tags="|arduino-micro|display|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25923" PostTypeId="2" ParentId="25922" CreationDate="2016-07-01T20:41:56.567" Score="1" Body="&lt;p&gt;If you need additional IO lines, a typical “LCD backpack” supplies at most eight additional lines of IO; &lt;a href=&quot;http://www.ebay.co.uk/itm/16-Channel-I2C-PWM-LED-Driver-Board-TLC59116-Arduino-/182090762992?ssPageName=STRK:MESE:IT&quot; rel=&quot;nofollow&quot;&gt;16-channel TLC59116 LED Driver Board&lt;/a&gt; as mentioned by Majenko would be more elegant than using several backpacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try an approach like the following to see if it works well enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use 16 IO lines to pull down 16 segment lines.  Use three IO lines to drive three digit-select PNP or PFET transistors for digit multiplexing.  Use pin-change interrupts on two IO lines to read rotary encoder (RE) data.  Use one input to read the RE pushbutton.  Use one IO line to notify the bigger unit of success.  Total 23 IO lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In operation, your code will need to implement a state machine that frequently refreshes the multiplexed digits while keeping track of digit values, selected digit, etc.  Each time you click the RE have your sketch go on to the next digit.  To tell the user which digit is working, blink the selected digit a couple of times after the RE press.  Each time that selection wraps around to the first digit, check if the combination is correct. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you feel it's necessary to have three different digit-setting knobs, vs clicking through to each digit, you could use one less IO line by using three pots instead of one RE.  The pots would be read in analog.  A6 and A7, IIRC not usable for output lines, could be used as analog inputs for two of the pots.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-07-01T20:41:56.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25924" PostTypeId="1" CreationDate="2016-07-01T20:52:41.243" Score="0" ViewCount="1424" Body="&lt;p&gt;My project is basically a set of 5 audio signals (analog) that get altered slightly by Arduino Uno. I convert to MIDI and would then output it to USB, so that it can be used in a program of my choice on the computer. I found a vaguely similar project online with a guide. In that project they write a serial to a MIDI out, and then plug that into a computer. I'm fairly sure I can't just use the TX and run that into the USB, that wouldn't work. So I'm looking for an alternative method.&lt;/p&gt;&#xA;" OwnerUserId="23553" LastEditorUserId="4628" LastEditDate="2017-11-18T04:12:10.353" LastActivityDate="2018-04-17T08:26:23.453" Title="Can you output to D+ and D- so that Arduino Uno can be used as a USB device?" Tags="|arduino-uno|serial|usb|audio|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25925" PostTypeId="2" ParentId="25924" CreationDate="2016-07-01T20:54:49.703" Score="1" Body="&lt;p&gt;Not with an Uno, no. You can only use USB Serial (CDC/ACM) through the on-board USB chip&lt;sup&gt;[1]&lt;/sup&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your best bet is probably with a Teensy 3 (or 3.1 or whatever they are up to now) which has built-in support for USB MIDI emulation.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;1: I believe there is MIDI firmware for the USB chip on the Uno, but installing that requires a hardware programmer and then breaks the normal sketch upload.&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-01T20:54:49.703" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25926" PostTypeId="2" ParentId="25919" CreationDate="2016-07-01T21:04:36.243" Score="1" Body="&lt;p&gt;Header files are used to &quot;encapsulate&quot; functionality of your code. When you #include a header file, what you are actually doing is, as perhaps an oversimplification, &quot;pasting&quot; the code from that header file into your sketch above where the main code you've written in that file resides. You can then call on functions defined in the header file. Usually, at this level, you are using header files to include useful code that other programmers have contributed to a &quot;library&quot; that has some functionality that makes your life easier -- UART or Wire for communication, or perhaps being able to write to one of Adafruit's LCD displays with a single function call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Programmers will also write their own header files to improve readability of their code -- for example, by encapsulating all code related to a particular functionality, perhaps troubleshooting, in one file. Another header file in the same program might, a bit ironically, be dedicated to input/output functions (but in the sense that it handles the reading and writing of data on some storage medium, such as an SD card). Header files can also #include other header files (if you're careful about how you do so).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, header files are not usable &quot;input/output.&quot; The compiler will read it all as one program and flash it to the Arduino just like any other code you have written. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.learncpp.com/cpp-tutorial/19-header-files/&quot; rel=&quot;nofollow&quot;&gt;http://www.learncpp.com/cpp-tutorial/19-header-files/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21415" LastEditorUserId="21415" LastEditDate="2016-07-01T21:09:46.793" LastActivityDate="2016-07-01T21:09:46.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25927" PostTypeId="2" ParentId="2987" CreationDate="2016-07-01T21:18:25.547" Score="0" Body="&lt;p&gt;I've had the same problem. I fixed it through a series of resets (removing the serial cable and plugging it in again), and punching 'make upload' a few times. Eventually it accepted my upload. The problem was an invalid code upload, which caused the Arduino to reset QUICKLY after booting. As an alternative, had this not worked, I would have blanked the chip with a USBtinyISP - it will hook up easily to your Arduino. &lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="6936" LastEditDate="2016-10-27T23:49:12.163" LastActivityDate="2016-10-27T23:49:12.163" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25928" PostTypeId="2" ParentId="25924" CreationDate="2016-07-01T22:45:55.847" Score="0" Body="&lt;p&gt;As noted in Majenko's answer, an Uno would require some non-trivial modifications before it would be usable as you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some Arduino models – Leonardo and early Pro Micros – were based on ATmega32U4 chips instead of ATmega168 or ATmega328 chips.  The 32U4 has USB support built in.  The &lt;a href=&quot;https://www.arduino.cc/en/Reference/MouseKeyboard&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mouse and Keyboard&lt;/a&gt; libraries allow interacting with a host computer such that from the host the Arduino looks like a mouse or keyboard.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="653" LastEditDate="2017-07-20T20:05:48.910" LastActivityDate="2017-07-20T20:05:48.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25929" PostTypeId="1" AcceptedAnswerId="37067" CreationDate="2016-07-02T01:38:16.570" Score="1" ViewCount="3102" Body="&lt;p&gt;So I've researched this topic a lot online, but haven't found what I'm looking for. Before I tell you this, I'll give you guys an idea of what I'm trying to accomplish. Please understand that I'm an extreme beginner to Arduino, and that I've only been at this for a month or so, but plan on doing so much more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My friend and I are building an RC car. We have an Android phone that has a downloadable application which connects to the Bluetooth HC-06 module that is on the Arduino UNO. We have configured our circuit, and it works fine! I want to go a step above and beyond, though. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to build a physical, handheld controller or remote (literally plopping everything on a breadboard), and connect that controller or remote to our car using Bluetooth. We have an HC-05 and HC-06 module, and the HC-06 is on the car. Now comes the doubt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand how the android application sends characters through to the RC Car via Bluetooth; that's pretty straightforward as the two pieces are paired (using Android's Bluetooth Settings). What I don't understand is how to pair the two HC-05 and HC-06 Bluetooth modules. There isn't too much help online, I feel. I've looked and people have shown that they connect, but they don't explain the theory, so to speak. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to understand is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How the two HC-05 and HC-06 modules pair, and&lt;/li&gt;&#xA;&lt;li&gt;How can I read input from one (remote controller) and execute an action on the other (RC car). From the app-to-Arduino, I was using &lt;code&gt;Serial.available()&lt;/code&gt; to see if the Serial had any characters sent over from the application. I can't see how I can do that with HC-05 to HC-06 pairing, however. This concept is hard for me to grasp.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated. Thank you!&lt;/p&gt;&#xA;" OwnerUserId="23554" LastEditorUserId="972" LastEditDate="2017-04-14T04:43:30.920" LastActivityDate="2017-04-14T04:43:30.920" Title="Connect 2 Arduino UNOs via Bluetooth? (HC-05 and HC-06)?" Tags="|arduino-uno|serial|bluetooth|hc-05|hc-06|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25930" PostTypeId="2" ParentId="25924" CreationDate="2016-07-02T03:15:12.400" Score="0" Body="&lt;p&gt;The simpler thing would be to output the MIDI through the serial port, and then convert that into MIDI voltage levels like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Ln7dG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Ln7dG.png&quot; alt=&quot;MIDI tx&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then plug that into a suitable MIDI-to-USB adapter. However I would have thought that that extra step (converting to MIDI voltage and back again) would be unnecessary. Can't your computer read MIDI directly from serial? I mean, the Uno has a USB interface. If you send MIDI data at 31250 baud, how is the program on the PC going to know it isn't a real MIDI device on the USB port?&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-02T03:15:12.400" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="25931" PostTypeId="2" ParentId="25922" CreationDate="2016-07-02T04:33:17.657" Score="1" Body="&lt;p&gt;The other answers give great suggestions, but to add to them you could consider the MAX7219 driver chip. I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11516&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about using it&lt;/a&gt;. It can drive a 8x8 pixel display (like one alphanumeric character) or 8 x 7-segments displays (a 7-segment display usually has a decimal place so that is really an 8-LED display).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of 64-pixel display:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/emQHR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/emQHR.jpg&quot; alt=&quot;64 pixel display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example of 8 x 7-segment displays:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cnt78.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cnt78.jpg&quot; alt=&quot;8 x 7-segment display&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Those displays come as a unit (2 x 4 digits) but there is nothing stopping you running wires to individual 1-digit displays if you want to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a possible schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2s6UC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2s6UC.png&quot; alt=&quot;MAX7219 schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are running to individual displays you just parallel-up the anodes (A to G, plus DP) and run a &quot;digit&quot; line to the cathode of each display.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;That will only take 3 signals from your processor (MOSI, SCK, SS) plus power and ground. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I notice you are talking about 16-segment displays and not 8-segment displays, but the chip allows any bit patterns to be sent out, so you could consider a 16-segment display to be the same as 2 x 8-segment displays. You would just have to make up a suitable bit-pattern to show each digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MAX7219 also handles the requirement for constant-current driving of the LEDs.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-02T04:33:17.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25933" PostTypeId="2" ParentId="25919" CreationDate="2016-07-02T05:37:51.037" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm just beginning to wonder whether it's possible to append strings that are concatenated from integers which are analogRead from sensors to a .h file? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, you have the wrong end of the stick here. You can't &lt;strong&gt;write&lt;/strong&gt; to a .h file, certainly not on the Arduino, because it is running independently of the development environment.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It'd make the arduino a lot more portable and would negate having to buy an SD card module.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;An SD module, like the one below, only costs about $US 15, and then you can write gigabytes of data to it, and then easily move the SD card to your PC to process it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/TMdvk.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/TMdvk.png&quot; alt=&quot;SD card module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-02T05:37:51.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25935" PostTypeId="1" CreationDate="2016-07-02T08:29:33.897" Score="0" ViewCount="1404" Body="&lt;p&gt;I made a couple of arduino mini pro and esp8266 pcbs with an rs485 transceiver just to find out that I forgot to think about in-system-programming:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that I don't need to disable the transceiver i tied *RE/DE to gnd/vcc. It turned out that id &lt;em&gt;do&lt;/em&gt; need disable the transceiver (at least the receiving part) in order to be able to program the mcu because otherwise the transceiver disrupts the serial data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't want to lose one pin for this (which in case of an esp8266 are rare) and I don't want to use jumpers because I really like the workflow without.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this even possible? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: The transceiver is an SP3485.&#xA;Currently it is connected like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Mini Pro     SP3485&#xA;A-rx ------  RO&#xA;GND  --1k-- *RE   A  ---- somwhere else&#xA;Vcc  --1k--  DE   B  ----        &quot;&#xA;A-tx ------  DI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which blocks serial programming because of a) the &quot;echo&quot; and b) holding A-rx line high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect &lt;code&gt;*RE --1k-- Vcc&lt;/code&gt; and &lt;code&gt;DE --1k-- GND&lt;/code&gt; I can ISP the Arduino, but now I obviously can't use the transceiver anymore.&lt;/p&gt;&#xA;" OwnerUserId="23448" LastEditorUserId="23448" LastEditDate="2016-07-02T11:20:20.053" LastActivityDate="2016-07-02T18:26:16.960" Title="rs485 and serial ISP" Tags="|esp8266|isp|rs485|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25937" PostTypeId="2" ParentId="25935" CreationDate="2016-07-02T09:54:34.830" Score="1" Body="&lt;p&gt;I'm not sure why you used an RS-485 transceiver if you were only going to permanently enable the two halves? You've basically turned the RS-485 multi-drop into an RS-422 balanced pair-of-pairs. Ah well!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you wired the transceiver to TX and RX on the ESP8266? And you want to still use those pins to reprogram it, by going &quot;behind&quot; the transceiver and temporarily connect them to your FTDI/whatever? Yeah, sorry: that's not going to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;*RE&lt;/code&gt; pin and &lt;code&gt;DE&lt;/code&gt; pin only affect the balanced side of the transceiver. The &lt;code&gt;RX&lt;/code&gt; and &lt;code&gt;TX&lt;/code&gt; pins on the logic side are still an output and input respectively, regardless of the state of the two Enable pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That means that to reprogram, you're going to have to connect your development machine to the balanced side of the transceiver, and you won't have to worry about the Enable pins. Look for RS-422 USB cable adapters - they're out there!&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-02T09:54:34.830" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25938" PostTypeId="1" CreationDate="2016-07-02T12:36:35.300" Score="3" ViewCount="4643" Body="&lt;p&gt;I am trying to connect to my Arduino Uno board two temperature sensors: DHT11 and DS18B20. The problem is with the DHT11 sensor: apparently there's an error with reading the temperature every two measurements.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's what I get on the serial monitor (temperature 1 is from the DHT sensor):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CDFKb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CDFKb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I am new to this, I was wondering what the problem may be. I have read about the one wire interface used by the DS18B20, but I noticed that the DHT is not using the same protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I use the DHT11 alone, it works perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I am using 4k7 pull-up resistors for both sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#include &amp;lt;dht.h&amp;gt;&#xA;&#xA;dht DHT;&#xA;&#xA;#define ONE_WIRE_BUS 8&#xA;#define DHT11_PIN 7&#xA;&#xA;OneWire oneWire(ONE_WIRE_BUS);&#xA;DallasTemperature sensors(&amp;amp;oneWire);&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Dallas Temperature IC Control Library Demo&quot;);&#xA;  sensors.begin();&#xA;}&#xA;&#xA;void loop(void) {&#xA;  int chk = DHT.read11(DHT11_PIN);  &#xA;  sensors.requestTemperatures(); &#xA;  Serial.print(&quot;Temperature1: &quot;);&#xA;  Serial.print(DHT.temperature);&#xA;  Serial.print(&quot; Temperature 2 : &quot;);&#xA;  Serial.println(sensors.getTempCByIndex(0)); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23564" LastEditorUserId="4628" LastEditDate="2017-02-05T11:00:18.883" LastActivityDate="2017-02-05T11:00:18.883" Title="Problem with DHT11 and DS18B20 temperature sensors" Tags="|arduino-uno|temperature-sensor|1-wire|" AnswerCount="3" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25939" PostTypeId="1" AcceptedAnswerId="25942" CreationDate="2016-07-02T13:33:34.913" Score="0" ViewCount="1819" Body="&lt;p&gt;I decided to build a digital clock using a &lt;em&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Grove_-_4-Digit_Display&quot; rel=&quot;nofollow&quot;&gt;4-Digit Display&lt;/a&gt;&lt;/em&gt; (TM1637) from Grove.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that, I have been using the &lt;em&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/File:DigitalTube.zip&quot; rel=&quot;nofollow&quot;&gt;DigitalTube library&lt;/a&gt;&lt;/em&gt; by Grove for the TM1637 controller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My idea is to use the two first digits of the display (left to right) to display the hour and the two last digits to display the minutes. However, managing displays is difficult and all the libraries I have found for the previously mentioned controlled can only display one number per digit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here you have an example:&#xA;Using &lt;code&gt;tm1637.display(1,2);&lt;/code&gt;, lets you display a &quot;2&quot; in the second digit (L to R), using &lt;code&gt;tm1637.display(0,3);&lt;/code&gt; lets you display a 3 on the firt digit and etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I said, I want to display the hour on the first two digits and the minutes in the two last digits.&#xA;I've have readed all the examples coming with the &lt;em&gt;DigitalTube&lt;/em&gt; library but nothing was useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I'm using the &lt;em&gt;DS3231&lt;/em&gt; for managing the time with a RTC. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if you undestand my question. If not, let me know please.&#xA;&lt;em&gt;Arduino UNO R3.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15855" LastActivityDate="2016-07-02T17:56:49.980" Title="Using two digits to display a number using TM1637 and a 4-digit display" Tags="|arduino-uno|display|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25940" PostTypeId="1" AcceptedAnswerId="25961" CreationDate="2016-07-02T16:21:52.297" Score="0" ViewCount="438" Body="&lt;p&gt;&lt;strong&gt;Can I use Bluetooth Low energy devices as micro controllers directly instead of communicating to Arduino&lt;/strong&gt; e.g. HM-10/11 or even HC-05/06 ? If so &lt;strong&gt;what are limitations&lt;/strong&gt; e.g. can  I hook sensors or control other stuff like LEDs or transistors with PWM ? &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I have built a motion sensor, which consists of Arduino, Bluetooth Low energy HM-11, battery and sensor itself. It worked just fine, but one guy told me that Arduino may be completely unnecessary and that Bluetooth module could replace its functionality !&#xA;I then started digging for information, and either it's impossible or I am terrible at googling. Everything I found was info about some kind of development kits for HM-10/11, also pin outs of those boards. They do have some IO pins, which can mean it's possible, but I found no tutorials nor examples on how to program those boards and use with other components.&lt;/em&gt; &lt;/p&gt;&#xA;" OwnerUserId="13985" LastActivityDate="2018-03-25T21:29:27.743" Title="Bluetooth module as MCU?" Tags="|programming|bluetooth|remote-control|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="25942" PostTypeId="2" ParentId="25939" CreationDate="2016-07-02T17:56:49.980" Score="2" Body="&lt;p&gt;Using &lt;code&gt;tm1637.display(digit#, value);&lt;/code&gt; calls, you can display a two-digit number using division to isolate the tens digit and mod to isolate the units digit.  For example, if &lt;code&gt;hour&lt;/code&gt; and &lt;code&gt;mins&lt;/code&gt; have hour and minute values, respectively, consider code like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tm1637.display(0, hour/10);&#xA;tm1637.display(1, hour%10);&#xA;tm1637.display(2, mins/10);&#xA;tm1637.display(3, mins%10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Code like the above is suitable in cases where values don't exceed 99, and where displaying a leading zero is ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't want to display the leading zero when hour is less than 10, add an &lt;code&gt;if&lt;/code&gt; test and blank the first digit in that case.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-07-02T17:56:49.980" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25943" PostTypeId="2" ParentId="25929" CreationDate="2016-07-02T18:11:01.747" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Have a look at this for how to pair them &lt;a href=&quot;http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-pair-bind-and-link&quot; rel=&quot;nofollow&quot;&gt;http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-pair-bind-and-link&lt;/a&gt; basically you need to use the AT mode.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;As far as I know you will be using the serial connection to communicate, but if you are using UNOs debugging becomes a bit more difficult, because you can't use serial for debugging.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-02T18:11:01.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25945" PostTypeId="1" CreationDate="2016-07-02T18:18:39.513" Score="22" ViewCount="106507" Body="&lt;p&gt;I need to know how I can write integer values in EEPROM and retain the value on power on.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;char *Red = strstr(myTestUrl, &quot;/R&quot;);&#xA;if (Red) {&#xA;  int RedValue  = atoi(Red + 2);&#xA;  analogWrite(12, RedValue);&#xA;  Serial.println(&quot;Red :&quot;);&#xA;  Serial.println(RedValue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to write &lt;code&gt;RedValue&lt;/code&gt; in EEPROM. How can it be done?&lt;/p&gt;&#xA;" OwnerUserId="23271" LastEditorUserId="972" LastEditDate="2018-01-05T20:02:37.517" LastActivityDate="2020-07-06T06:33:55.260" Title="How to read and write EEPROM in ESP8266" Tags="|arduino-ide|esp8266|eeprom|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25946" PostTypeId="2" ParentId="25935" CreationDate="2016-07-02T18:26:16.960" Score="1" Body="&lt;p&gt;I can't understand the purpose of connecting *RE/DE to GND/Vcc. With&#xA;this setup, the driver inside the transceiver is always enabled, and&#xA;it's always driving the A/B pair. Meaning the device at the other end of&#xA;the link cannot drive the pair itself without making a collision.&#xA;Basically you have a simplex link, where the Pro Mini is always the&#xA;sender.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The normal way to connect an RS-485 transceiver is to have DE driven by&#xA;a GPIO pin of the MCU. You pull this pin HIGH when you want to talk, and&#xA;leave it LOW the rest of the time so you can hear other devices talking.&#xA;The *RE pin is connected either to GND (if you want to hear the echo of&#xA;what you say) or to DE (if you don't).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, you are correct in that the transceiver may cause&#xA;problems when uploading the firmware on the Pro Mini. One possible&#xA;solution is to put a resistor between RO and A-RX. The TX of the FTDI&#xA;cable should have a low output impedance and be able to overpower that&#xA;resistor. Another option is to use ICSP (in-circuit serial programming)&#xA;instead of going through the bootloader. It would be easier if you can&#xA;put an ICSP header on your board.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-02T18:26:16.960" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25947" PostTypeId="1" CreationDate="2016-07-02T21:40:04.290" Score="1" ViewCount="3223" Body="&lt;p&gt;I am new to all of this and was trying to figure out what was happening with pull-up/pull-down circuits.  I think I understand what happens when the board handles the pull-up/pull-down but I wanted to try to build the circuits.  I got help from another forum.  Once I made the circuits, I found that I don't understand the path that the voltage is traveling.  I have 2 examples with multimeters attached.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pull Up&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand the press of the button connect circuit to ground.  But why does the voltage everywhere go down to zero when it is connected to ground?  Does it have something to do with the multimeter can't read the voltage because the current is taking the path of least resistance - which I have read is a myth?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/UC7RO.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/UC7RO.gif&quot; alt=&quot;Pull Up Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pull Down&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When compared to the Pull Up, why does the voltage go to 5 before the yellow wire when the button is pushed?  Isn't it connected to the ground again which seems like it should cause the same scenario as the Pull Up where they all read zero.  Or does the resistor before ground have something to do with this.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sBxdS.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sBxdS.gif&quot; alt=&quot;Pull Down Circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know nothing about electronics.  Some information and links where I could find more information would be great.  Thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All the gifs are screen recordings from circuits I built with circuits.io.  I want to get into making somethings but wanted to practice first before I spent any money.&lt;/p&gt;&#xA;" OwnerUserId="23569" LastActivityDate="2016-07-10T07:47:34.307" Title="Understanding flow of current with pull-up and pull-down circuits" Tags="|arduino-uno|voltage-level|current|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25948" PostTypeId="2" ParentId="8129" CreationDate="2016-07-02T21:46:33.127" Score="3" Body="&lt;p&gt;In my situation the issue was with the Transmitter not continuing to transmit after a delay. I was able to resolve the issue using the powerDown (&lt;a href=&quot;http://maniacbug.github.io/RF24/classRF24.html#aa0a51923a09ba4f3478aba9be0f8a6a1&quot; rel=&quot;nofollow&quot;&gt;http://maniacbug.github.io/RF24/classRF24.html#aa0a51923a09ba4f3478aba9be0f8a6a1&lt;/a&gt;) and powerUp (&lt;a href=&quot;http://maniacbug.github.io/RF24/classRF24.html#a5cdaf47aa0edd6dca1b9a8bb7972a1a3&quot; rel=&quot;nofollow&quot;&gt;http://maniacbug.github.io/RF24/classRF24.html#a5cdaf47aa0edd6dca1b9a8bb7972a1a3&lt;/a&gt;) functions. Here is a snipet of my code. &quot;radioTx&quot; is the name assigned to my transmitter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//standard code setup for arduino uno board examples&#xA;radioTx.begin();&#xA;radioTx.setChannel(108);&#xA;radioTx.openWritingPipe(pipe);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int dist_cm = sonar.ping_cm();&#xA;&#xA;&#xA;  Serial.println(dist_cm);&#xA;  radioTx.write(&amp;amp;dist_cm,sizeof(dist_cm));&#xA;  radioTx.powerDown();&#xA;  delay(5000);&#xA;  radioTx.powerUp();&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23574" LastActivityDate="2016-07-02T21:46:33.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25949" PostTypeId="2" ParentId="25947" CreationDate="2016-07-02T22:25:54.193" Score="3" Body="&lt;p&gt;It's very hard to read your circuit, because there are wires everywhere. However this is effectively what a switch and a pull-up resistor looks like:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/j29Ek.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/j29Ek.png&quot; alt=&quot;Pull-up resistor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the pull-up, pin 8 on the Arduino (which the switch is connected to) is normally pulled-up to 5V if the switch is open.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you close the switch pin 8 becomes 0V, thus your meter reads 0V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the other hand, with a pull-down resistor, the circuit looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N8zGN.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N8zGN.png&quot; alt=&quot;Pull-down resistor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now pin 8 is normally zero volts with the switch open, and when closed pin 8 is connected to 5V to pin 8 becomes 5V.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/switches&quot; rel=&quot;nofollow noreferrer&quot;&gt;my tutorial on switches&lt;/a&gt; for more details.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What happens with the flow of current and the resistor to make one example read high and the other low.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Imagine a door with a spring on it to close it. The spring is like a pull-up (or pull-down) resistor (depending on whether you are trying to keep the door closed or open).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The spring &lt;em&gt;gently&lt;/em&gt; pulls the door shut. However if you barge out of it with a handful of pizzas in your hand your override the spring. In the absence of the spring the door would just flap in the breeze, sometimes opening and sometimes closing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The point is, a person is strong enough to force the door open, despite the spring. Similarly if you close the switch you override the pull-up (or pull-down) resistor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Where does the 5V go when the switch is closed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It flows through the resistor to ground (or 5V depending on which one you are talking about).  &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;When the switch is open in the pull up example - is voltage going through the resistor? From what I'm reading online, in the pull up case voltage isn't traveling through the resistor until the button is pressed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Voltage doesn't &quot;go through&quot; a resistor, current does.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With the switch open, effectively a tiny amount of current goes through the resistor to pin 8. It is a &quot;high impedance&quot; input which means it puts a very small load on the input. Thus there is a very small voltage drop over the 10k resistor, and almost the full 5V is presented to the input pin for reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work out the exact amount, we can look at the datasheet which says that the maximum leakage current through an I/O pin at 5V is 1 µA. Now using Ohm's Law we can find the voltage drop over the 10k resistor:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;V = I * R&#xA;V = 0.000001 * 10000&#xA;V = 0.01 V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus with 5V at the 5V pin of the processor, and a (maximum of) 1 µA consumed at pin 8, it will therefore have 4.99 V at the pin, which therefore reads &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;With the switch closed, then we use Ohm's Law to calculate the flow through the resistor:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;I = V / R&#xA;I = 5 / 10000&#xA;I = 0.0005 A&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus 0.5 mA flows through the resistor with the switch closed. This is not enough to damage the resistor, or make a significant load on the 5V line.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;I think you are getting confused (as I did when I was young) that a big resistance (like 10k) must &quot;resist&quot; a lot of voltage. It is easy to think that after going through 10k resistance there can't be much &quot;voltage&quot; left.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact is, though, that the voltage on the other end of a resistor is proportional to &lt;em&gt;not only&lt;/em&gt; the resistance (R) but &lt;em&gt;also&lt;/em&gt; the current (I). This is Ohms's Law (&lt;code&gt;V = I * R&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if the current is very small (as is the case with an input pin) then the voltage drop over a resistor - even a large one - is very small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the idea of a pull-up resistor is, that with no external influences (like a switch) then after passing through 10k resistance, there is still 5V at the other side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Let me issue you with a challenge. Find a voltage source (eg. a battery). Measure it with your multimeter. Let's say you have a 5V source which is the Arduino 5V pin. Now get a 10k resistor. Put it in series with the 5V source. Now measure it on the other side of the resistor. Depending on the quality of the meter (and thus how much current it takes to measure a voltage) you will get very close to the same voltage reading. In my case I had 5V on one side of the resistor, and 4.99V on the other side. This is exactly what my calculations above predicted.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-07-10T07:47:34.307" LastActivityDate="2016-07-10T07:47:34.307" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="25950" PostTypeId="2" ParentId="3927" CreationDate="2016-07-03T05:14:32.170" Score="1" Body="&lt;p&gt;Example from Khalid Abdulla is correct, but I used 10.5 MHz for my ov7670 camera:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int32_t mask_PWM_pin = digitalPinToBitMask(7);&#xA;REG_PMC_PCER1 = 1&amp;lt;&amp;lt;4;               // activate clock for PWM controller&#xA;REG_PIOC_PDR |= mask_PWM_pin;  // activate peripheral functions for pin (disables all PIO functionality)&#xA;REG_PIOC_ABSR |= mask_PWM_pin; // choose peripheral option B    &#xA;REG_PWM_CLK = 0;                     // choose clock rate, 0 -&amp;gt; full MCLK as reference 84MHz&#xA;REG_PWM_CMR6 = 0&amp;lt;&amp;lt;9;             // select clock and polarity for PWM channel (pin7) -&amp;gt; (CPOL = 0)&#xA;REG_PWM_CPRD6 = 8;                // initialize PWM period -&amp;gt; T = value/84MHz (value: up to 16bit), value=8 -&amp;gt; 10.5MHz&#xA;REG_PWM_CDTY6 = 4;                // initialize duty cycle, REG_PWM_CPRD6 / value = duty cycle, for 8/4 = 50%&#xA;REG_PWM_ENA = 1&amp;lt;&amp;lt;6;               // enable PWM on PWM channel (pin 7 = PWML6)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My results: &lt;a href=&quot;http://privateblog.info/arduino-due-i-kamera-ov7670-primer-ispolzovaniya/&quot; rel=&quot;nofollow&quot;&gt;Arduino Due and OV7670&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15624" LastActivityDate="2016-07-03T05:14:32.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25951" PostTypeId="1" CreationDate="2016-07-03T06:01:28.287" Score="0" ViewCount="407" Body="&lt;p&gt;I'm experimenting with PWM with the code below, but (according to my analog multimeter) the voltage on the output pins reach up to 5V whilst the largest &lt;code&gt;analogRead(IN1)&lt;/code&gt; value is only around 700:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int EN1 = 5;&#xA;const int EN2 = 6;&#xA;const int EN3 = 7;&#xA;&#xA;const int IN1 = 9;&#xA;const int IN2 = 10;&#xA;const int IN3 = 11;&#xA;&#xA;// SPWM (Sine Wave)&#xA;// const int pwmSin[] = {127, 138, 149, 160, 170, 181, 191, 200, 209, 217, 224, 231, 237, 242, 246, 250, 252, 254, 254, 254, 252, 250, 246, 242, 237, 231, 224, 217, 209, 200, 191, 181, 170, 160, 149, 138, 127, 116, 105, 94, 84, 73, 64, 54, 45, 37, 30, 23, 17, 12, 8, 4, 2, 0, 0, 0, 2, 4, 8, 12, 17, 23, 30, 37, 45, 54, 64, 73, 84, 94, 105, 116 };&#xA;&#xA;&#xA;/// SVPWM (Space Vector Wave)&#xA;//const int pwmSin[] = {128, 147, 166, 185, 203, 221, 238, 243, 248, 251, 253, 255, 255, 255, 253, 251, 248, 243, 238, 243, 248, 251, 253, 255, 255, 255, 253, 251, 248, 243, 238, 221, 203, 185, 166, 147, 128, 109, 90, 71, 53, 35, 18, 13, 8, 5, 3, 1, 1, 1, 3, 5, 8, 13, 18, 13, 8, 5, 3, 1, 1, 1, 3, 5, 8, 13, 18, 35, 53, 71, 90, 109};&#xA;const int pwmSin[] = {128, 132, 136, 140, 143, 147, 151, 155, 159, 162, 166, 170, 174, 178, 181, 185, 189, 192, 196, 200, 203, 207, 211, 214, 218, 221, 225, 228, 232, 235, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 253, 252, 252, 251, 250, 250, 249, 248, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 253, 252, 252, 251, 250, 250, 249, 248, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 235, 232, 228, 225, 221, 218, 214, 211, 207, 203, 200, 196, 192, 189, 185, 181, 178, 174, 170, 166, 162, 159, 155, 151, 147, 143, 140, 136, 132, 128, 124, 120, 116, 113, 109, 105, 101, 97, 94, 90, 86, 82, 78, 75, 71, 67, 64, 60, 56, 53, 49, 45, 42, 38, 35, 31, 28, 24, 21, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 24, 28, 31, 35, 38, 42, 45, 49, 53, 56, 60, 64, 67, 71, 75, 78, 82, 86, 90, 94, 97, 101, 105, 109, 113, 116, 120, 124};&#xA;&#xA;int currentStepA;&#xA;int currentStepB;&#xA;int currentStepC;&#xA;int sineArraySize;&#xA;int increment = 0;&#xA;boolean direct = 1; // direction true=forward, false=backward&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;&#xA;  setPwmFrequency(IN1); // Increase PWM frequency to 32 kHz  (make unaudible)&#xA;  setPwmFrequency(IN2);&#xA;  setPwmFrequency(IN3);&#xA;&#xA;  pinMode(IN1, OUTPUT); &#xA;  pinMode(IN2, OUTPUT); &#xA;  pinMode(IN3, OUTPUT); &#xA;&#xA;  pinMode(EN1, OUTPUT); &#xA;  pinMode(EN2, OUTPUT); &#xA;  pinMode(EN3, OUTPUT); &#xA;&#xA;&#xA;  digitalWrite(EN1, HIGH);&#xA;  digitalWrite(EN2, HIGH);&#xA;  digitalWrite(EN3, HIGH);&#xA;&#xA;&#xA;  sineArraySize = sizeof(pwmSin)/sizeof(int); // Find lookup table size&#xA;  int phaseShift = sineArraySize / 3;         // Find phase shift and initial A, B C phase values&#xA;  currentStepA = 0;&#xA;  currentStepB = currentStepA + phaseShift;&#xA;  currentStepC = currentStepB + phaseShift;&#xA;&#xA;  sineArraySize--; // Convert from array Size to last PWM array number&#xA;}&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////&#xA;&#xA;void loop() {&#xA;&#xA;  analogWrite(IN1, pwmSin[currentStepA]);&#xA;  analogWrite(IN2, pwmSin[currentStepB]);&#xA;  analogWrite(IN3, pwmSin[currentStepC]);  &#xA;&#xA;  if (direct==true) increment = 1;&#xA;  else increment = -1;     &#xA;&#xA;  currentStepA = currentStepA + increment;&#xA;  currentStepB = currentStepB + increment;&#xA;  currentStepC = currentStepC + increment;&#xA;&#xA;  //Check for lookup table overflow and return to opposite end if necessary&#xA;  if(currentStepA &amp;gt; sineArraySize)  currentStepA = 0;&#xA;  if(currentStepA &amp;lt; 0)  currentStepA = sineArraySize;&#xA;&#xA;  if(currentStepB &amp;gt; sineArraySize)  currentStepB = 0;&#xA;  if(currentStepB &amp;lt; 0)  currentStepB = sineArraySize;&#xA;&#xA;  if(currentStepC &amp;gt; sineArraySize)  currentStepC = 0;&#xA;  if(currentStepC &amp;lt; 0) currentStepC = sineArraySize; &#xA;&#xA;  /// Control speed by this delay&#xA;  delay(10);&#xA;  Serial.println(analogRead(IN1));&#xA;}&#xA;&#xA;&#xA;void setPwmFrequency(int pin) {&#xA;  if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {&#xA;    if(pin == 5 || pin == 6) {&#xA;      TCCR0B = TCCR0B &amp;amp; 0b11111000 | 0x01;&#xA;    } else {&#xA;      TCCR1B = TCCR1B &amp;amp; 0b11111000 | 0x01;&#xA;    }&#xA;  }&#xA;  else if(pin == 3 || pin == 11) {&#xA;    TCCR2B = TCCR2B &amp;amp; 0b11111000 | 0x01;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;analogRead(IN1)&lt;/code&gt; is just around 700 max, shouldn't the voltage be around 3.5V (700/1023 * 5V)? How come the output voltage is so high?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="21694" LastActivityDate="2016-08-02T09:20:25.527" Title="PWM output voltage too high" Tags="|arduino-nano|c|pwm|analogread|analogwrite|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25952" PostTypeId="1" AcceptedAnswerId="25958" CreationDate="2016-07-03T08:51:19.773" Score="2" ViewCount="87" Body="&lt;p&gt;quick question.  I have two 10 turn precision potentiometers and I tested both when I bought them a few weeks ago, both worked as expected.  However now that I have epoxied one of them into my project and wired it up, I don't get any resistance.  I get a max reading all the time regardless of where the dial is set.  So then I pull off the wiring and do the same setup with the other potentiometer and I am still getting expected results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the reasoning for the sudden difference in readings? Could the first one have gone bad, and if so how often does this happen and how can I avoid it in the future?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything falls within recommended specs of the pot and neither has been really used at all.&lt;/p&gt;&#xA;" OwnerUserId="19501" LastActivityDate="2017-02-28T20:19:52.427" Title="Two Identical Potentiometers, two different results" Tags="|wires|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25953" PostTypeId="2" ParentId="25952" CreationDate="2016-07-03T09:04:59.287" Score="1" Body="&lt;p&gt;Trimmers have a really low current rating, so if you hadn't protect it enough, maybe you have broken it. Always remember a pull up resistor of 10k or more.&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-07-03T09:04:59.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25954" PostTypeId="2" ParentId="25951" CreationDate="2016-07-03T09:11:26.520" Score="2" Body="&lt;p&gt;It seems that you misunderstand how pwm works.&#xA;Pwm is the modulation of duty cycle, so the pin are outputting square waves 0-5v at the same frequency, but varying the time it's low and the time it's high. Your multimeter probably is only displaying high intervals, instead your analog read probably has filters and calculates the efficient voltage of the sine wave (divide max for sqr(2)).&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-07-03T09:11:26.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25955" PostTypeId="2" ParentId="25918" CreationDate="2016-07-03T09:14:36.510" Score="0" Body="&lt;p&gt;You should use arduino built in tone command to play sounds with a buzzer, it will simplify your code and your errors.&lt;/p&gt;&#xA;" OwnerUserId="23211" LastActivityDate="2016-07-03T09:14:36.510" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25956" PostTypeId="2" ParentId="18432" CreationDate="2016-07-03T12:48:07.930" Score="0" Body="&lt;p&gt;I know that you've resolved your dilemma, but I just wanted to show you a trick: personally, I &lt;em&gt;&lt;strong&gt;hate&lt;/strong&gt;&lt;/em&gt; the pointer-to-function mechanism that everyone uses, when there's a perfectly good alternative.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's a function that takes an &lt;code&gt;int&lt;/code&gt; and returns a &lt;code&gt;char&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char SomeFn(int i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here's a &lt;code&gt;typedef&lt;/code&gt; describing that function as a type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef char Fn(int i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Looks pretty similar, huh? What's the point? Now that you've got a type, you can use that instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SetCallback(Fn *fn);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;SetCallback&lt;/code&gt; takes as a parameter a pointer to a function of type &lt;code&gt;Fn&lt;/code&gt;. The &lt;code&gt;*&lt;/code&gt; is necessary, and (to me) makes more sense than trying to barrel the pointer-ness inside the type itself - which is what leads to the parenthesis overload. You can call it like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SetCallback(&amp;amp;SomeFn);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What could be easier? If &lt;code&gt;SomeFn&lt;/code&gt; was a &lt;code&gt;static&lt;/code&gt; member of a class, you could just as easily use that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SetCallback(&amp;amp;Class::SomeFn);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-03T12:48:07.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25957" PostTypeId="2" ParentId="23850" CreationDate="2016-07-03T12:56:38.477" Score="0" Body="&lt;p&gt;The error &lt;code&gt;Undefined reference&lt;/code&gt; is a linker error, which means that the Arduino ecosystem is missing some of the pieces for the build. If you have indeed provided &lt;code&gt;PushButton.cpp&lt;/code&gt; - whether in a library or not - you need to put a &lt;code&gt;#include&lt;/code&gt; of &lt;code&gt;Pushbutton.h&lt;/code&gt; inside the &lt;code&gt;.ino&lt;/code&gt; file. This tells Arduino that you want to include &lt;code&gt;PushButton&lt;/code&gt;'s code as well as everything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;Pushbutton.cpp&lt;/code&gt; is inside the same directory as the &lt;code&gt;.ino&lt;/code&gt; file then that will &quot;just work&quot;. If it's elsewhere, you need to tell Arduino.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-03T12:56:38.477" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25958" PostTypeId="2" ParentId="25952" CreationDate="2016-07-03T13:41:46.770" Score="1" Body="&lt;p&gt;Multi turn pots range in size from about sugar cube dimensions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NcQAE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NcQAE.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;...to weighing a pound or more:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cFC8S.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cFC8S.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be easy to imagine epoxy entering a small plastic multi turn pot and &quot;freezing&quot; the parts within.  If this is what happened, try using a faster curing glue or mount the pot on a Printed Circuit Board (PCB) and glue the PCB.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-03T13:41:46.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25961" PostTypeId="2" ParentId="25940" CreationDate="2016-07-03T17:30:47.470" Score="1" Body="&lt;p&gt;All bluetooth modules will need some sort of mcu to handle the requirements of the protocol stack, and it seems common that there will be at least a couple of GPIO which can be used directly if your sensor requirements are simple. At the other end of the spectrum, you will find there are also mcus with a full set of peripherals - enough to support a couple of sensors and a small display for example. Remember, the wearables market is likely bigger than the hobby electronics market.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Limitations are most likely to be in the area of ease of use (as you hint at with your question), and possibly the toolchain which you would need to use (unlikely to be arduino compatible). Also, the bluetooth stack typically takes a reasonable proportion of these wearables focused devices, so there is not a big amount of ram/flash or CPU cycles to spare even if you opt for a part which is more than 'just' a serial-to-bluetooth bridge.&lt;/p&gt;&#xA;" OwnerUserId="21252" LastActivityDate="2016-07-03T17:30:47.470" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25962" PostTypeId="2" ParentId="25782" CreationDate="2016-07-03T18:55:14.810" Score="1" Body="&lt;p&gt;From your comment of Jul 1st, I understand that you can program your&#xA;server in PHP. Then, and to expand on my own comments, I am only&#xA;recommending that, whatever Web API you design, you keep it as simple as&#xA;possible. For example, for telling the Arduino whether it should keep&#xA;the shutter open or closed, you could write something like this in PHP:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-php prettyprint-override&quot;&gt;&lt;code&gt;header('Content-Type: text/plain');&#xA;&#xA;if (user_wants_shutter_open())&#xA;    echo &quot;open&quot;;&#xA;else&#xA;    echo &quot;close&quot;;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In particular, it makes absolutely no sense to write a PHP program that&#xA;generates an HTML document. Consider that the Arduino is a very low&#xA;powered platform: there is no point in having it process more than a&#xA;handful of bytes when you only want to communicate a single bit of&#xA;information. And you should know that there is really nothing wrong with&#xA;using HTTP to transport plain text (but you should use the header&#xA;&lt;code&gt;Content-Type: text/plain&lt;/code&gt;). If you want to send a more complex set of&#xA;data, you could use something like text/tab-separated-values, or maybe&#xA;even application/json.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning web scrapping, it is a solution to a specific problem, the&#xA;problem being that the server returns the information in a format that&#xA;is not very well suited for machine consumption. You do &lt;em&gt;not&lt;/em&gt; have this&#xA;problem. Obviously, you could &lt;em&gt;create&lt;/em&gt; the problem by having your PHP&#xA;return an HTML document, and then you could apply the solution. My point&#xA;is that it is better to avoid creating the problem in the first place:&#xA;just return the information in a format that is as easy to parse as&#xA;possible.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-03T18:55:14.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25963" PostTypeId="2" ParentId="25789" CreationDate="2016-07-03T20:13:11.220" Score="0" Body="&lt;p&gt;Okay I figured it out. Putting what I did here, for people who are curious and for those who need help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It was probably the Arduino, autoresetoverserialcomm, for some reason the Arduino auto-resets whenever you send a value over the serial comm to the Arduino from a computer, not from the Serial port (obviously). I knew of this earlier, and another one of my script which also sends data to the Arduino was working fine with this setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did? I just put a 10µ capacitor between the RESET and the GND pins. That didn't work initially, but I tried putting the +ve of the capacitor in the GND pin and -ve in the RESET pin and voila! The script started working just fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I guess this wasn't a programming issue at all, but an issue of the Arduino and the script not being able to contact each other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I still am not sure as to what was causing the problem or whether what I have done is a permanent fix, or even a fix at all, but my problem seems to have been solved. I'll keep updating the post.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Suggestions and discussions are always welcome!&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-07-03T20:13:11.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25964" PostTypeId="1" AcceptedAnswerId="25965" CreationDate="2016-07-03T20:38:36.753" Score="0" ViewCount="1108" Body="&lt;p&gt;I'm trying to pass an array to a library (written in c++) but the error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;undefined reference to `MyLib::arrayTest(int*)'&#xA;collect2: error: ld returned 1 exit status&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is being produced. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Code Is As Follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Testing.ino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyLib test = MyLib(5,4,6);&#xA;&#xA;void setup(){&#xA;    int arr[10];&#xA;&#xA;    test.arrayTest(arr);&#xA;&#xA;    Serial.println(arr[0]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MyLib.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyLib {&#xA;    public:&#xA;        MyLib(int x, int y, int z);&#xA;&#xA;        void arrayTest(int* n);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;MyLib.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void arrayTest(int* n){&#xA;    n[0] = 15;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated :)&lt;/p&gt;&#xA;" OwnerUserId="23585" LastEditorUserId="23585" LastEditDate="2016-07-03T20:39:34.830" LastActivityDate="2016-07-03T20:41:26.547" Title="Passing array to library function" Tags="|c++|library|array|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25965" PostTypeId="2" ParentId="25964" CreationDate="2016-07-03T20:41:26.547" Score="0" Body="&lt;p&gt;This function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void arrayTest(int* n){&#xA;    n[0] = 15;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is lacking the class qualifier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MyLib::arrayTest(int* n){&#xA;    n[0] = 15;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-03T20:41:26.547" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25966" PostTypeId="1" AcceptedAnswerId="46004" CreationDate="2016-07-03T20:57:37.180" Score="-1" ViewCount="1007" Body="&lt;p&gt;I wrote this simple script to control a servo over serial comm - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo steeringServo;&#xA;char data = ' ';&#xA;&#xA;void setup() {&#xA;  steeringServo.attach(9);&#xA;  Serial.begin(115200);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  if(Serial.available()){&#xA;    data = Serial.read();&#xA;  }&#xA;&#xA;  if(data =='L'){&#xA;    steeringServo.write(50);&#xA;  }&#xA;  else if(data == 'R'){&#xA;    steeringServo.write(135);&#xA;  }&#xA;  else if(data == 'S'){&#xA;    steeringServo.write(90);&#xA;  }&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It was working fine, I was sending values through a python script. I turned my Arduino off and after a while I come back and reconnect all stuff exactly the way it was, but now my Arduino isn't responding! I tried sending values through the serial monitor to the above sketch but nothing happens! I tried another code which takes values over serial comm and that didn't work as well. The Arduino just receives the values but doesn't do what its supposed to when it receives.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Not only this, I tried uploading the sweep sketch and that didn't work either. Everything is connected exactly the way it was when stuff was fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What has gone wrong with my Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;br&gt;&#xA;The Arduino works fine if the values are sent through my script.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&lt;br&gt;&#xA;The Arduino works fine if the values are sent through puTTY.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-07-03T23:21:26.550" LastActivityDate="2017-10-28T23:36:25.327" Title="Arduino UNO suddenly stops responding" Tags="|arduino-uno|serial|sketch|python|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25968" PostTypeId="1" AcceptedAnswerId="26068" CreationDate="2016-07-04T01:28:46.237" Score="4" ViewCount="24002" Body="&lt;p&gt;For my project I have to measure a  signal of the order of few microvolts.&#xA;As we know the least an Arduino can measure is ~5mV, due to its 10bit ADC and 5V reference voltage.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A solution to this problem can be to use an external ADC (16bit, I think will do).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please guide me on this problem.Is it possible to use a external ADC,if yes how should I.Any other simple solution ?&#xA;Thank You &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anupam&lt;/p&gt;&#xA;" OwnerUserId="23589" LastActivityDate="2016-07-08T14:47:07.543" Title="Using an External ADC with Arduino" Tags="|adc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="25972" PostTypeId="1" CreationDate="2016-07-04T04:19:25.820" Score="1" ViewCount="401" Body="&lt;p&gt;I have the below code working from &lt;a href=&quot;https://www.youtube.com/watch?v=Y30iEOxl1To&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=Y30iEOxl1To&lt;/a&gt; - to receive temperature &amp;amp; humidity as an sms when i give a missed call to a specific number (sim on the gsm shield)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The above code is like on demand sms. I also want to alter this code so it can automatically send me another sms if the temperature exceeds a threshold.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the code...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SIM900.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &quot;call.h&quot;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &quot;sms.h&quot;&#xA;&#xA;SMSGSM sms;&#xA;#define DHTPIN 7  &#xA;#define DHTTYPE DHT22   &#xA;&#xA;CallGSM call;&#xA;boolean started=false;&#xA;char sms_text[160];&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;void setup()&#xA;{&#xA;    dht.begin();&#xA;    Serial.begin(9600);&#xA;&#xA;    if (gsm.begin(9600)) &#xA;    {&#xA;        Serial.println(&quot;\nstatus=READY&quot;);&#xA;        started=true;&#xA;    } &#xA;    else &#xA;        Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    float humidity, temperature;&#xA;    String smsText =&quot;&quot;;&#xA;    if(temperature&amp;gt;29)&#xA;    {&#xA;        switch (call.CallStatus())&#xA;        {&#xA;            case CALL_NONE: // Nothing is happening&#xA;                break;&#xA;&#xA;            case CALL_INCOM_VOICE : // Yes! Someone is calling us&#xA;                Serial.println(&quot;RECEIVING CALL&quot;);&#xA;                call.HangUp();&#xA;                delay(1000);&#xA;                humidity = dht.readHumidity();&#xA;                temperature = dht.readTemperature();&#xA;                delay(1000);&#xA;                smsText = &quot;Temperature: &quot;+String(temperature,1)+&quot;C Humidity: &quot;+String(humidity,1)+&quot;%&quot;;&#xA;                smsText.toCharArray(sms_text,160);&#xA;                //Serial.println(smsText);&#xA;                sms.SendSMS(&quot;+91**********&quot;,sms_text);&#xA;                break;&#xA;&#xA;            case CALL_COMM_LINE_BUSY:  // In this case the call would be established&#xA;                Serial.println(&quot;TALKING. Line busy.&quot;);&#xA;                break;&#xA;        }&#xA;        delay(1000);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23594" LastEditorUserId="2881" LastEditDate="2016-07-04T12:37:38.260" LastActivityDate="2016-07-04T12:52:10.313" Title="How to make &quot;IF &quot;Temperature exceeds&quot; logic to work in same arduino code" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25976" PostTypeId="1" AcceptedAnswerId="25980" CreationDate="2016-07-04T06:41:39.990" Score="3" ViewCount="3473" Body="&lt;p&gt;So I`ve got that mouse with serial connector. It is named serial so it should be easier to connect than even a ps2 mouse, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can`t find any instruction on it. Or should I see instruction on ps2 mouse and plug in the same wires?&#xA;Btw mouse has only 4 wires connected inside, as usual PS2 mouse. I want to connect it the same way as ps2 mouse to get easy readings of rotary encoder.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/KJXmu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KJXmu.jpg&quot; alt=&quot;serial mouse&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPD1: I`ve tried to connect it like a PS2 mouse according to this schema with no success. So either a mouse is dead or it uses some kind of different connection?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/t12O8.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/t12O8.gif&quot; alt=&quot;PS2 to serial mouse&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23599" LastActivityDate="2016-07-04T12:01:28.310" Title="Interfacing pc mouse (serial port DB-9)" Tags="|serial|rotary-encoder|mouse|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25977" PostTypeId="1" AcceptedAnswerId="25978" CreationDate="2016-07-04T08:04:03.730" Score="1" ViewCount="52" Body="&lt;p&gt;I have this really simple code.&#xA;Let's say I have a variable X.&#xA;Then all I want to do is create a random value R, if R &gt; X then I want X to become R.&#xA;But for some reason, my &lt;code&gt;n_of_buttons_pressed&lt;/code&gt; climbs up and then sometimes drops back to lower values. I can not wrap my head around how it could get a lower value then a previous value. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define N_OF_BUTTONS 60&#xA;&#xA;int n_of_buttons_pressed;&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;start&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  n_of_buttons_pressed = (int) max(random(0, N_OF_BUTTONS), n_of_buttons_pressed);&#xA;&#xA;  Serial.print(&quot;n_of_buttons_pressed:&quot;);&#xA;  Serial.print(n_of_buttons_pressed);&#xA;  Serial.println();&#xA;&#xA;  delay(100);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19933" LastActivityDate="2016-07-04T08:10:37.767" Title="Strange behaviour with using max" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25978" PostTypeId="2" ParentId="25977" CreationDate="2016-07-04T08:10:37.767" Score="6" Body="&lt;p&gt;The &lt;code&gt;max()&lt;/code&gt; “function” is actually a macro defined in &lt;code&gt;Arduino.h&lt;/code&gt; as&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define max(a,b) ((a)&amp;gt;(b)?(a):(b))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This expands in your code into something like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;buttons_pressed = random(0, N_OF_BUTTONS) &amp;gt; n_of_buttons_pressed) ? \&#xA;                  random(0, N_OF_BUTTONS) : n_of_buttons_pressed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem with the macro is that it evaluates at least one of its&#xA;arguments twice. In this case, if the test is true, the variable&#xA;&lt;code&gt;buttons_pressed&lt;/code&gt; gets assigned &lt;em&gt;another&lt;/em&gt; pseudo-random number.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way around this is to store the pseudo-random number in a variable,&#xA;to avoid &lt;code&gt;random()&lt;/code&gt; being evaluated twice:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int pseudo_random = random(0, N_OF_BUTTONS);&#xA;buttons_pressed = max(pseudo_random, n_of_buttons_pressed);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-04T08:10:37.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25980" PostTypeId="2" ParentId="25976" CreationDate="2016-07-04T11:45:25.877" Score="3" Body="&lt;p&gt;A serial mouse is designed to connect to a PC's true serial port - it's an actual RS-232 device using ±5V. As such it won't connect directly to the Arduino's &lt;code&gt;RX&lt;/code&gt;/&lt;code&gt;TX&lt;/code&gt; pins, you'll have to go through an RS-232 transceiver chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also gets its power from the &lt;code&gt;RTS&lt;/code&gt; line, but I never knew what the current draw of one of those things was - be careful trying to power it from the Arduino!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Different mouse manufacturers used different protocols. The original standard used a three-byte protocol at 1,200 bps 7N1. The encoding had the following properties:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The leading bit of the first byte of the packet was set - all future bytes had the leading bit cleared.&lt;/li&gt;&#xA;&lt;li&gt;The first byte had the buttons' states, and the most significant bits of the X and Y deltas;&lt;/li&gt;&#xA;&lt;li&gt;The X delta was encoded in the second byte;&lt;/li&gt;&#xA;&lt;li&gt;The Y delta was encoded in the third byte.&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://paulbourke.net/dataformats/serialmouse/&quot; rel=&quot;nofollow&quot;&gt;http://paulbourke.net/dataformats/serialmouse/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Other manufacturers added things like extra buttons and scroll wheels that didn't fit in the packet structure. So they modified the protocol, but stuck with some features of the original:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The data rate was (usually) still 1,200 bps, although sometimes they used 7N2 or 8N1 instead.&lt;/li&gt;&#xA;&lt;li&gt;The leading bit was still used to indicate start of packet;&lt;/li&gt;&#xA;&lt;li&gt;The X, Y (and Z) wheels still indicated deltas.&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;a href=&quot;http://www.cpcwiki.eu/index.php/Serial_RS232_Mouse&quot; rel=&quot;nofollow&quot;&gt;http://www.cpcwiki.eu/index.php/Serial_RS232_Mouse&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-07-04T12:01:28.310" LastActivityDate="2016-07-04T12:01:28.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25981" PostTypeId="1" AcceptedAnswerId="25985" CreationDate="2016-07-04T11:46:35.157" Score="1" ViewCount="148" Body="&lt;p&gt;I have written a library for Arduino, &lt;code&gt;my_library&lt;/code&gt;, consisting of &lt;code&gt;my_library.h&lt;/code&gt; and &lt;code&gt;my_library.cpp&lt;/code&gt;, both included in &lt;code&gt;my_library&lt;/code&gt; folder. Actually the library is recognized from IDE Arduino and works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to add some examples, let's say &lt;code&gt;Example1&lt;/code&gt; and &lt;code&gt;Example2&lt;/code&gt;. How is that possible?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should the examples be included in &lt;code&gt;my_library&lt;/code&gt; folder?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;or should be included in another folder inside &lt;code&gt;my_library&lt;/code&gt; folder?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried several combinations but none worked. Do I miss something?&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-07-04T12:54:29.437" Title="How can I include examples in library?" Tags="|library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25984" PostTypeId="2" ParentId="25972" CreationDate="2016-07-04T12:52:10.313" Score="2" Body="&lt;p&gt;The code below will check if the temperature goes above 29 degrees. It also check whether the temperature was below 29 previously, to prevent it from sending an SMS every second, for as long as it's above 29 degrees C.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SIM900.h&quot;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &quot;call.h&quot;&#xA;#include &amp;lt;DHT.h&amp;gt;&#xA;#include &quot;sms.h&quot;&#xA;&#xA;SMSGSM sms;&#xA;#define DHTPIN 7  &#xA;#define DHTTYPE DHT22   &#xA;&#xA;CallGSM call;&#xA;boolean started=false;&#xA;char sms_text[160];&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;&#xA;void setup()&#xA;{&#xA;    dht.begin();&#xA;    Serial.begin(9600);&#xA;&#xA;    if (gsm.begin(9600)) &#xA;    {&#xA;        Serial.println(&quot;\nstatus=READY&quot;);&#xA;        started=true;&#xA;    } &#xA;    else &#xA;        Serial.println(&quot;\nstatus=IDLE&quot;);&#xA;}&#xA;&#xA;float previousTemperature = 0;&#xA;void loop()&#xA;{&#xA;    float humidity, temperature;&#xA;    humidity = dht.readHumidity();&#xA;    temperature = dht.readTemperature();&#xA;    delay(1000);&#xA;&#xA;    // check if temperature has raised to above 29 degrees&#xA;    if(temperature&amp;gt;29 &amp;amp;&amp;amp; previousTemperature&amp;lt;=29)&#xA;    {&#xA;        sendSMS(temperature, humidity);&#xA;    }&#xA;    previousTemperature = temperature;&#xA;&#xA;    // check for incomming call&#xA;    switch (call.CallStatus())&#xA;    {&#xA;        case CALL_NONE: // Nothing is happening&#xA;            break;&#xA;&#xA;        case CALL_INCOM_VOICE : // Yes! Someone is calling us&#xA;            Serial.println(&quot;RECEIVING CALL&quot;);&#xA;            call.HangUp();&#xA;            delay(1000);&#xA;            sendSMS(temperature, humidity);&#xA;            break;&#xA;&#xA;        case CALL_COMM_LINE_BUSY:  // In this case the call would be established&#xA;            Serial.println(&quot;TALKING. Line busy.&quot;);&#xA;            break;&#xA;    }&#xA;&#xA;    delay(1000);&#xA;}&#xA;&#xA;void sendSMS(float temperature, float humidity)&#xA;{&#xA;    String smsText =&quot;&quot;;&#xA;    smsText = &quot;Temperature: &quot;+String(temperature,1)+&quot;C Humidity: &quot;+String(humidity,1)+&quot;%&quot;;&#xA;    smsText.toCharArray(sms_text,160);&#xA;    //Serial.println(smsText);&#xA;    sms.SendSMS(&quot;+91**********&quot;,sms_text);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-04T12:52:10.313" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="25985" PostTypeId="2" ParentId="25981" CreationDate="2016-07-04T12:54:29.437" Score="4" Body="&lt;p&gt;You need to create a folder called &quot;examples&quot; in your library folder. Within there, each in its own folder, you place your examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyLib/&#xA;MyLib/MyLib.h&#xA;MyLib/MyLib.cpp&#xA;MyLib/examples/&#xA;MyLib/examples/Example1/&#xA;MyLib/examples/Example1/Example1.ino&#xA;MyLib/examples/Example2/&#xA;MyLib/examples/Example2/Example2.ino&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Be sure to name the example's folder the same as the name of the example.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-04T12:54:29.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25986" PostTypeId="1" CreationDate="2016-07-04T13:03:19.940" Score="2" ViewCount="283" Body="&lt;p&gt;I tried regular RFID tags and It works but when I tried NTAG203 it won't detect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I used the code &quot;dump_data&quot; example of MFRC library. &lt;/p&gt;&#xA;" OwnerUserId="23609" LastActivityDate="2016-07-04T13:03:19.940" Title="Cannot read NTAG203 with MFRC522" Tags="|arduino-uno|rfid|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="25988" PostTypeId="1" CreationDate="2016-07-04T14:08:29.570" Score="2" ViewCount="84" Body="&lt;p&gt;I have been following this tutorial by sparkfun&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.sparkfun.com/tutorials/internet-datalogging-with-arduino-and-xbee-wifi&quot; rel=&quot;nofollow&quot;&gt;https://learn.sparkfun.com/tutorials/internet-datalogging-with-arduino-and-xbee-wifi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and I have XBee Wifi but not the Shield of SparkFun. I have the Wireless ProtoShield which is provided by Arduino.cc &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if both are compatible with each other?&#xA;Thank you in advance.&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-07-04T14:08:29.570" Title="XBee WiFi: Does it work on the Wireless Proto Shield?" Tags="|wifi|shields|xbee|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25989" PostTypeId="1" AcceptedAnswerId="25990" CreationDate="2016-07-04T14:34:23.477" Score="1" ViewCount="587" Body="&lt;p&gt;I'm trying to proportion potentiometer value to analog pin value. Like 1024 to 255.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int readVolumePot() {&#xA;    int val = analogRead(potVolumePIN);&#xA;&#xA;    Serial.print(&quot;VOL&quot;);&#xA;      Serial.println((val * 255/1024));&#xA;&#xA;      return (val * 255/1024);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As potentiometer turns I got irrelevant values.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;VOL3&#xA;VOL3&#xA;VOL3&#xA;VOL17&#xA;VOL-16&#xA;VOL-16&#xA;VOL-21&#xA;VOL-1&#xA;VOL-10&#xA;VOL-3&#xA;VOL-4&#xA;VOL11&#xA;VOL8&#xA;VOL13&#xA;VOL17&#xA;VOL15&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In Arduino's &lt;a href=&quot;https://www.arduino.cc/en/Reference/Arithmetic&quot; rel=&quot;nofollow noreferrer&quot;&gt;website&lt;/a&gt; they say &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;some constant calculations may overflow (e.g. 60 * 1000 will yield a&#xA;  negative result).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Notwithstanding, I cannot find an appropriate way to convert the potentiometer value to analog pin value.&lt;/p&gt;&#xA;" OwnerUserId="23611" LastEditorUserId="26916" LastEditDate="2017-09-08T21:58:03.863" LastActivityDate="2017-09-08T21:58:03.863" Title="Getting negative results from calculations" Tags="|c++|potentiometer|" AnswerCount="1" CommentCount="2" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25990" PostTypeId="2" ParentId="25989" CreationDate="2016-07-04T14:51:11.863" Score="5" Body="&lt;p&gt;&lt;code&gt;analogRead()&lt;/code&gt; returns a number from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;1023&lt;/code&gt;, and you want to convert that to a range from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;255&lt;/code&gt;? One easy way would be to simply divide the reading by &lt;code&gt;4&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On a more general note, given that the numbers will (should!) never be negative, there's a flavour of &lt;code&gt;int&lt;/code&gt; called &lt;code&gt;unsigned int&lt;/code&gt;. By using that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int val = analogRead(...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can cover a range from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;65535&lt;/code&gt; instead of &lt;code&gt;int&lt;/code&gt;'s &lt;code&gt;-32768&lt;/code&gt; to &lt;code&gt;32767&lt;/code&gt;. That will give you a little more head room - but not enough to multiply the maximum value &lt;code&gt;1023&lt;/code&gt; by &lt;code&gt;255&lt;/code&gt; first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's also another type &lt;code&gt;long&lt;/code&gt;. That covers the range from -2 to 2 billion (and a bit), while &lt;code&gt;unsigned long&lt;/code&gt; goes from 0 to 4 billion (and a bit) - but that uses a LOT of processing for the poor Arduino to work with.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-04T14:51:11.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="25991" PostTypeId="2" ParentId="17536" CreationDate="2016-07-04T19:01:42.420" Score="1" Body="&lt;p&gt;Looks like your delay is too short. If the delay gets over before the servo can reach the set postion, it will skip that command and execute the next one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I agree with @julio about how are you powering your servo. By &quot;mini&quot; servo I assume that you are using a micro servo. I have a Tower Pro 9G micro servo (which I use as steering servo btw, small but pretty decent), and it works fine if I power it with the Arduino UNO, but torque is a bit less. Anyways, check your servo's datasheet, your servo might need more power. Just hook it up to a power supply and make sure the grounds are common. The jitter might just be the result of inappropriate power.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-07-04T19:01:42.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25992" PostTypeId="2" ParentId="17536" CreationDate="2016-07-04T20:02:00.387" Score="0" Body="&lt;p&gt;The most basic issue with servo motors is wrong cabling and then insufficient motor driver in terms of amperage. And then, PWM duty cycle must be set correctly. If you don't treat those things properly, you may hear noises such as humming, vibration instead of turning the motor.&lt;/p&gt;&#xA;" OwnerUserId="23616" LastEditorUserId="4628" LastEditDate="2018-01-15T11:35:57.170" LastActivityDate="2018-01-15T11:35:57.170" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25993" PostTypeId="1" AcceptedAnswerId="25995" CreationDate="2016-07-04T20:49:11.643" Score="1" ViewCount="105" Body="&lt;p&gt;I wrote this code for a project - &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorpin = A5;           &#xA;int val = 0;&#xA;double avgval = 0;&#xA;int E1 = 11;&#xA;int brake = 12;&#xA;char data = ' ';&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200); &#xA;  pinMode(E1, OUTPUT);   &#xA;  pinMode(brake, OUTPUT);&#xA;  pinMode(sensorpin, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;  if (Serial.available()&amp;gt;0){&#xA;      data = Serial.read();&#xA;    }&#xA;&#xA;  val = analogRead(sensorpin);   &#xA;  avgval = average(val);&#xA;  double volt = (avgval*5)/1023;&#xA;  Serial.println (avgval);&#xA;  Serial.println(volt);            &#xA;  delay(1000);   &#xA;&#xA;  if (data == 'G'){&#xA;    analogWrite(E1, 255);&#xA;    digitalWrite(brake, LOW);&#xA;  }&#xA;&#xA;  if( volt &amp;gt; 1.5 &amp;amp;&amp;amp; volt &amp;lt; 1.75 ){&#xA;    digitalWrite(brake, HIGH);&#xA;  }&#xA;}&#xA;&#xA;double average(double adc){&#xA;  int n = 1;&#xA;  double avg = 0.00, sum = 0.00;&#xA;  while(n&amp;lt;=23){&#xA;    sum = sum + adc;&#xA;    avg = sum/25;&#xA;    n++;&#xA;  }&#xA;  return avg;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The code works fine, except for the fact that the Sharp IR sensor (GP2Y0A710K0F) outputs values which are wrong (by a HUGE distance), &lt;strong&gt;ONLY&lt;/strong&gt; if in the &lt;code&gt;void setup()&lt;/code&gt; function, the commands -   &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(E1, OUTPUT);  &#xA;pinMode(brake, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;are left &lt;em&gt;uncommented&lt;/em&gt;. If I comment the above two statements, the sketch works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What on earth is wrong here? I can't make out anything.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-07-04T22:18:21.833" Title="HUGE deviation in Sharp IR sensor values if other pins are defined in void setup()" Tags="|arduino-uno|programming|c++|sketch|ir|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25994" PostTypeId="2" ParentId="5058" CreationDate="2016-07-04T21:01:58.083" Score="1" Body="&lt;p&gt;Both of the Libraries you mentioned are well written. I've used both, but decided to write my own based those libraries. For me, the network libraries were written for their project and didn't really fit my needs. So I decided to write my own. I combed the internet for a bare bones NRF24 Library and found this &lt;a href=&quot;https://github.com/kehribar/nrf24L01_plus&quot; rel=&quot;nofollow noreferrer&quot;&gt;one&lt;/a&gt;. This was my starting point. It didn't need the Arduino Core Library and handled all the SPI functions. Then I read the NRF24L01 datasheet several times, then read it again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that said, you can broadcast up to 6 radios at a time. Per the datasheet, the receiver knows which radio sent the packet. The STATUS register (0x07), should tell you who sent the packet:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/ZwL67.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZwL67.png&quot; alt=&quot;STATUS Register 0x07&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was unable to get this working (I am still working on it), so for now, I send my packet as a struct:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct  {&#xA;&#xA;uint8_t id;&#xA;uint32_t data;&#xA;&#xA;}&#xA;Packet;&#xA;&#xA;Packet pck;&#xA;pck.id = 2; // id of my second radio&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Keep in mind when you program your Arduino as the receiver, you have to tell it who it will be receiving from. The transmitter and receiver have to be on the same RF channel, speed and same pipe. To choose who receives the packet may not work the way you think, but as I mentioned you can program the receiver to know who the transmitter was and code around it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest you dig into the datasheet.   &lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2016-07-04T21:01:58.083" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="25995" PostTypeId="2" ParentId="25993" CreationDate="2016-07-04T22:18:21.833" Score="3" Body="&lt;p&gt;Not sure why commenting out those two lines makes a difference.  I think we need to see a schematic to resolve this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You do not use &quot;pinMode&quot; to setup an analog input!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at the examples on the &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogRead&quot; rel=&quot;nofollow&quot;&gt;&quot;analogRead&quot; page&lt;/a&gt;.  Notice there is no setup needed for the analog pin.  Just call &quot;analogRead&quot; like you are doing and everything should be fine.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-04T22:18:21.833" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26000" PostTypeId="1" AcceptedAnswerId="26004" CreationDate="2016-07-05T04:42:39.500" Score="2" ViewCount="2170" Body="&lt;p&gt;I am trying to use Timer2 in an Uno in fast PWM mode.  Can someone explain how to set up the TCCR2A &amp;amp; B registers?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  TCCR2A |= _BV(WGM21) | _BV(WGM20);&#xA;  TCCR2B &amp;amp;= ~_BV(WGM22);&#xA;&#xA;  TCCR2A = (TCCR2A | _BV(COM2A1)) &amp;amp; ~_BV(COM2A0);&#xA;  TCCR2A &amp;amp;= ~(_BV(COM2B1) | _BV(COM2B0));&#xA;  TCCR2B = (TCCR2B &amp;amp; ~(_BV(CS12) | _BV(CS11))) | _BV(CS10);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would like to have the inverted value on TCCR2B, but I think it can be inverted using OCR2B ^= 255, correct?  This is to have a varying signal on Pin11 and its inverse on Pin3, the signal is generated by varying the OCR2B value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-07-05T07:50:15.407" Title="Uno timer 2 set up" Tags="|arduino-uno|timers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26001" PostTypeId="1" CreationDate="2016-07-05T05:16:32.617" Score="2" ViewCount="56" Body="&lt;p&gt;I'm using an Arduino clone for serial communication. However, as soon as I even touch the board, it resets, and the serial communication stops. When I view the serial port using the 'Tools' menu of Arduino IDE, I observe that it has changed. Sometimes, opening the serial monitor crashes Arduino IDE. I was using MATLAB as well, and observed that it crashed too whenever I initiated serial communication. The setup was working well for a week, when suddenly I encountered this problem. &#xA;Do you think that there is a problem with Arduino clone? Any help would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="23625" LastEditorUserId="11763" LastEditDate="2016-07-05T23:18:05.160" LastActivityDate="2016-07-05T23:18:05.160" Title="Arduino clone changing its serial port on slight physical displacement, even during an ongoing serial communication" Tags="|arduino-uno|serial|communication|clones|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26002" PostTypeId="1" CreationDate="2016-07-05T06:24:53.700" Score="4" ViewCount="461" Body="&lt;p&gt;I was using the COZIR W-100 carbon dioxide sensor with an Arduino Mega 2560 with the example code from &lt;a href=&quot;http://www.co2meters.com/Documentation/AppNotes/AN128-%20Cozir_Arduino.pdf&quot; rel=&quot;nofollow&quot;&gt;this site&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the measured value of carbon dioxide by sensor was 90 ppm in fresh air and that is not correct. Please help me find the cause and a solution.&lt;/p&gt;&#xA;" OwnerUserId="23628" LastEditorUserId="11763" LastEditDate="2016-07-05T23:21:22.787" LastActivityDate="2016-07-29T14:56:46.967" Title="Problem in using COZIR W-100 with arduino" Tags="|arduino-mega|sensors|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26003" PostTypeId="1" CreationDate="2016-07-05T07:29:39.817" Score="0" ViewCount="999" Body="&lt;p&gt;I want to send serial data from my laptop to a Teensy LC chip through the laptop's USB port. I am not sure how to do this. From reading I have found two possibilities, which both seem to have problems:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Get a USB to serial adapter cable, connect the USB to the laptop, the serial to a MAX232 chip, the MAX232 chip to the UART serial on the Teensy. The ambiguity in this option lies in the fact that the MAX232 chip requires a minimum 4.5V input, and the specs on the Teensy LC say it has 3.3V and &lt;em&gt;one&lt;/em&gt; 5V digital output (would this one output be compatible with a MAX232?). Also, it has only 3.3V input, so it sounds like 5V coming from the MAX232 chip would be too much (I guess I could incorporate a chip like &lt;a href=&quot;https://www.adafruit.com/product/735&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/product/735&lt;/a&gt; ?). Now if I were to go this route with a Teensy 3.1, which says its input pins are 5V tolerant, its voltage output is also only 3.3V (and there is no mention of any 5V output). I guess the answer here would be to incorporate a chip like &lt;a href=&quot;https://www.adafruit.com/products/1787&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/products/1787&lt;/a&gt; ?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second possibility I looked into would be a USB-to-TTL adapter cable to go straight to the Teensy LC, but I read somewhere that the serial UART with Arduino is different in some way and I wasn't sure if the serial communication coming through the USB-to-TTL cable would be compatible with the Teensy. I was looking at one of these cables at Sparkfun, and I think I would connect the TxD from the cable to the RX on the Teensy, the RxD from the cable to the TX on the Teensy, and the GND cable to a ground on the Teensy.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Could someone point me in the right direction regarding sending serial data through a laptop's USB out to the Teensy?&lt;/p&gt;&#xA;" OwnerUserId="23630" LastEditorUserId="4628" LastEditDate="2017-04-02T10:56:57.057" LastActivityDate="2017-04-02T10:56:57.057" Title="How to transmit serial data from laptop USB out to Teensy?" Tags="|teensy|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26004" PostTypeId="2" ParentId="26000" CreationDate="2016-07-05T07:50:15.407" Score="2" Body="&lt;p&gt;If you want to get two complementary PWM signals, you have to set &lt;em&gt;the&#xA;same&lt;/em&gt; value to both output compare registers. This is necessary to have&#xA;the two signals in phase. You also have to configure one PWM in&#xA;non-inverting mode and the other in inverting mode. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;TCCR2A = _BV(COM2A1)  // non-inverting PWM on OC2A&#xA;       | _BV(COM2B0)  // PWM on OC2B:&#xA;       | _BV(COM2B1)  //    inverting mode&#xA;       | _BV(WGM20)   // fast PWM&#xA;       | _BV(WGM21);  // ditto&#xA;TCCR2B = _BV(CS10);   // clock at F_CPU / 1&#xA;OCR2A  = 84;          // duty cycle ~ 1/3&#xA;OCR2B  = 84;          // same signal, complemented&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Checked on the scope: when pin 3 goes high pin 11 goes low and&#xA;vice-versa.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-05T07:50:15.407" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26005" PostTypeId="1" CreationDate="2016-07-05T08:25:33.173" Score="1" ViewCount="2202" Body="&lt;p&gt;I am trying to use an external ADC with my UNO for very precise measurement of my signal.&#xA;The ADC which I am using is ADS1115.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://henrysbench.capnfatz.com/henrys-bench/arduino-voltage-measurements/arduino-ads1115-module-getting-started-tutorial/&quot; rel=&quot;nofollow&quot;&gt;http://henrysbench.capnfatz.com/henrys-bench/arduino-voltage-measurements/arduino-ads1115-module-getting-started-tutorial/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the site which I am referring to.It says the default reference voltage of the PGA gives a resolution of 188microvolt per bit.It also indicates towards changing the reference voltage to 2.048, to still increase the resolution per bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please guide me in how to achieve this 2.048V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;&lt;a href=&quot;https://www.google.co.in/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwiFpq3P89vNAhXJro8KHa6IC04QFggpMAI&amp;amp;url=https%3A%2F%2Fcdn-learn.adafruit.com%2Fdownloads%2Fpdf%2Fadafruit-4-channel-adc-breakouts.pdf&amp;amp;usg=AFQjCNGhdMw47MRlXolMiMoHdsTwKMwMow&quot; rel=&quot;nofollow&quot;&gt;https://www.google.co.in/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=3&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwiFpq3P89vNAhXJro8KHa6IC04QFggpMAI&amp;amp;url=https%3A%2F%2Fcdn-learn.adafruit.com%2Fdownloads%2Fpdf%2Fadafruit-4-channel-adc-breakouts.pdf&amp;amp;usg=AFQjCNGhdMw47MRlXolMiMoHdsTwKMwMow&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that by adjusting the gain (page number 16-17 of 18) we can achive it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WHat I need to know now, is where should I put that piece of code&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;blockquote&gt;&#xA;    &lt;blockquote&gt;&#xA;      &lt;p&gt;ads1115.setgain(...) &lt;/p&gt;&#xA;    &lt;/blockquote&gt;&#xA;  &lt;/blockquote&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;in void loop() or in void setup()&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anupam&lt;/p&gt;&#xA;" OwnerUserId="23589" LastEditorUserId="23589" LastEditDate="2016-07-05T08:44:42.333" LastActivityDate="2018-01-03T00:45:57.957" Title="Arduino ADS1115 PGA settings" Tags="|arduino-uno|adc|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26011" PostTypeId="1" AcceptedAnswerId="26013" CreationDate="2016-07-05T10:25:23.197" Score="2" ViewCount="3327" Body="&lt;p&gt;I have this code which produces a square wave:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int output_state = 0;&#xA;unsigned long start;&#xA;&#xA;void setup() {&#xA;  Serial.begin(1200);&#xA;  start = millis();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if((millis() - start) &amp;gt;=1000){&#xA;    output_state = ! output_state;&#xA;    //output_state *= 1023;&#xA;    start = millis();&#xA;  }&#xA;&#xA;    Serial.println(output_state);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HRuqh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HRuqh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;but should I multiply the signal by 1023:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;output_state *= 1023;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this signal is produced by the Serial Plotter:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Na4s3.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Na4s3.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind that the timing is right, just the x axis speeds up in zero values. Why is that happening, and how can be solved?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2021-02-16T23:13:46.177" Title="square wave with serial plotter" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26013" PostTypeId="2" ParentId="26011" CreationDate="2016-07-05T10:31:56.443" Score="3" Body="&lt;p&gt;It takes twice as long to print &quot;1023&quot; (6 bytes, including the CRLF line&#xA;terminator) than to print &quot;0&quot; (3 bytes). Thus, in the same time, you are&#xA;printing twice as many &quot;0&quot; than &quot;1023&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the data points to be printed at a consistent rate,&#xA;you can impose the printing timing just like you did on the&#xA;&lt;code&gt;output_state&lt;/code&gt;. Keep in mind that you cannot print more than 20 samples&#xA;per second at 1200&amp;nbsp;bps. You could also pad the strings so that they&#xA;always have the same length:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;char s[5];  // one byte for the NULL terminator&#xA;sprintf(s, &quot;%4d&quot;, output_state);&#xA;Serial.println(s);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I would prefer the first solution (explicitly control the timing).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-07-05T10:38:56.917" LastActivityDate="2016-07-05T10:38:56.917" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26014" PostTypeId="1" CreationDate="2016-07-05T10:58:24.367" Score="0" ViewCount="39" Body="&lt;p&gt;I wan't to build a diversity controller similar to &lt;a href=&quot;https://github.com/sheaivey/rx5808-pro-diversity&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; one.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A diversity controller is basically a circuit which detects the strongest RSSI Signal of multiple receivers and provides the data signal of that (the strongest) receiver.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;As a receiver I use boscam &lt;a href=&quot;https://www.foxtechfpv.com/product/5.8G%20modules/rx5808/RX5808-Spec-V1.pdf&quot; rel=&quot;nofollow&quot;&gt;RX5808&lt;/a&gt; receivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This receiver can be switchen between 8 channals through a 3 bit output interface. The CH1-3 outputs are active high 5V which got to be pulled to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Is it possible to put these receiver-outputs on an arduino digital inputs, to either put them on ground or not?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How exactly do I implement this in software?&lt;/p&gt;&#xA;" OwnerUserId="4849" LastActivityDate="2016-07-05T11:02:25.263" Title="Can I close an input?" Tags="|digital-in|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26015" PostTypeId="2" ParentId="26014" CreationDate="2016-07-05T11:02:25.263" Score="2" Body="&lt;p&gt;When you output HIGH you connect the pin to +5V. When you output LOW you connect the pin to ground.  It's called a &lt;em&gt;push-pull&lt;/em&gt; interface, and looks like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xzL94.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xzL94.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When it's set HIGH the p-FET is turned on and the n-FET is turned off. That connects the output direct to VDD. When it's set LOW the p-FET is turned off and the n-FET is turned off. That connects the output direct to GND.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are just like switches, as depicted to the right. Only one is closed at a time - when HIGH the upper switch is closed, when LOW the lower switch is closed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you just connect the output pins of the Arduino direct to the input pins of your device and write either HIGH or LOW to them to set the 5V or GND connections you need.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-05T11:02:25.263" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26016" PostTypeId="1" CreationDate="2016-07-05T11:39:49.433" Score="1" ViewCount="10380" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/w5rel.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/w5rel.jpg&quot; alt=&quot;The display.&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Hello! In my project, using a display controlled by a TM1637, I want to make the two points on the middle of the screen blink (as every clock does).&lt;/p&gt;&#xA;&lt;p&gt;The following example, provided by the library I'm using, makes the two points blink as I want (&lt;code&gt;tm1637.point(POINT_ON/POINT_OFF);&lt;/code&gt; is what enables/disbales the point):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimerOne.h&amp;gt;&#xA;#include &amp;quot;TM1637.h&amp;quot;&#xA;#define ON 1&#xA;#define OFF 0&#xA;&#xA;int8_t TimeDisp[] = {0x00,0x00,0x00,0x00};&#xA;unsigned char ClockPoint = 1;&#xA;unsigned char Update;&#xA;unsigned char halfsecond = 0;&#xA;unsigned char second;&#xA;unsigned char minute = 0;&#xA;unsigned char hour = 12;&#xA;&#xA;&#xA;#define CLK 2//pins definitions for TM1637 and can be changed to other ports    &#xA;#define DIO 3&#xA;TM1637 tm1637(CLK,DIO);&#xA;&#xA;void setup()&#xA;{&#xA;  tm1637.set();&#xA;  tm1637.init();&#xA;  Timer1.initialize(500000);//timing for 500ms&#xA;  Timer1.attachInterrupt(TimingISR);//declare the interrupt serve routine:TimingISR  &#xA;}&#xA;void loop()&#xA;{&#xA;  if(Update == ON)&#xA;  {&#xA;    TimeUpdate();&#xA;    tm1637.display(TimeDisp);&#xA;  }&#xA;  &#xA;}&#xA;void TimingISR()&#xA;{&#xA;  halfsecond ++;&#xA;  Update = ON;&#xA;  if(halfsecond == 2){&#xA;    second ++;&#xA;    if(second == 60)&#xA;    {&#xA;      minute ++;&#xA;      if(minute == 60)&#xA;      {&#xA;        hour ++;&#xA;        if(hour == 24)hour = 0;&#xA;        minute = 0;&#xA;      }&#xA;      second = 0;&#xA;    }&#xA;    halfsecond = 0;  &#xA;  }&#xA; // Serial.println(second);&#xA;  ClockPoint = (~ClockPoint) &amp;amp; 0x01;&#xA;}&#xA;void TimeUpdate(void)&#xA;{&#xA;  if(ClockPoint)tm1637.point(POINT_ON);&#xA;  else tm1637.point(POINT_OFF); &#xA;  TimeDisp[0] = hour / 10;&#xA;  TimeDisp[1] = hour % 10;&#xA;  TimeDisp[2] = minute / 10;&#xA;  TimeDisp[3] = minute % 10;&#xA;  Update = OFF;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I tried to do it as it was the famous &amp;quot;blink&amp;quot;, but nothing works.&lt;/p&gt;&#xA;&lt;p&gt;Here's what I have done:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;TM1637.h&amp;quot; // Library for the 4-Digit Display&#xA;#include &amp;quot;RTClib.h&amp;quot; // Library for the RTC&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;#define CLK 6&#xA;#define DIO 7&#xA;&#xA;TM1637 tm1637(CLK,DIO);&#xA;RTC_DS1307 RTC;&#xA;&#xA;const int fotoRes = 2;&#xA;&#xA;SoftwareSerial mySerial(10, 11);&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(fotoRes, INPUT);&#xA;  &#xA;  RTC.begin();&#xA;  RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;  &#xA;  tm1637.init();&#xA;}&#xA;void loop()&#xA;{&#xA;  DateTime now = RTC.now();&#xA;&#xA;  tm1637.display(0,now.hour()/10);&#xA;  tm1637.display(1,now.hour()%10);&#xA;  tm1637.display(2,now.minute()/10);&#xA;  tm1637.display(3,now.minute()%10);&#xA;&#xA;  tm1637.point(POINT_ON); //Like blink example.&#xA;  delay(500);&#xA;  tm1637.point(POINT_OFF);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: &lt;code&gt;tm1637.set(0-7)&lt;/code&gt; ONLY set the brightnes of the screen. What makes the two pints appear is &lt;code&gt;tm1637.point(POINT_OFF/POINT_ON)&lt;/code&gt;. I'm asking how can I do to make these two points blink. Thanks.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Arduino UNO R3, DigitalTube library by Grove&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="15855" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-07-09T13:58:13.920" Title="Making two points on a tm1637 display blink [ Solved ]" Tags="|arduino-uno|display|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26018" PostTypeId="2" ParentId="13563" CreationDate="2016-07-05T12:18:32.927" Score="2" Body="&lt;p&gt;I recently brought this book off Amazon &quot;Beginning Arduino ov7670 Camera Development&quot;.  I'm loathed to recommend it, because it has a nice 80 page introduction to the Arduino and OV7670 and the rest of the 250 pages are just double space annotated code.  That said, it does appear to be a very good introduction, with example code, for a OV7670-FIFO (the title of the book is incorrect).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might be possible to find the code on the net and then you can decide if you want to buy the book or not.  Oh and I am not Robert Chin, I do not know him and I have nothing to do with the book, other than owning a rather new and once read copy of it.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-05T12:18:32.927" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26019" PostTypeId="2" ParentId="22597" CreationDate="2016-07-05T12:34:06.900" Score="1" Body="&lt;ol&gt;&#xA;&lt;li&gt;You seem to have the ESP connected via serial, but aren't sending it anything.  &lt;/li&gt;&#xA;&lt;li&gt;The Rx of the ESP needs to be connected to the Tx of the Arduino (via a logic level shifter) and the Tx of the ESP needs to be connected to the Rx of the Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Do you know with a proper email sending library you could use any email server, not some service that you may have to pay for?&lt;/li&gt;&#xA;&lt;li&gt;The ESP8366 is a much more capable device than the Arduino (IMO).  I suspect that you could directly connect your sensor to it, and program it (in Arduino C/C++) through the Arduino IDE and it would be much less hassle.&lt;/li&gt;&#xA;&lt;li&gt;I think the problem with your code is that you haven't initialised the Wifi object, the first time you call it is to ask the status.  However I don't think you need this code because its not talking to the ESP8266 and you should be sending the data via the serial connection.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-05T12:34:06.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26021" PostTypeId="2" ParentId="26005" CreationDate="2016-07-05T12:50:45.053" Score="2" Body="&lt;p&gt;Reference voltage inputs are usually high impedance requiring little current.  So you can get by with simple circuits like a resistor and zener diode.  Here is just one I happened across:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NZmnZ.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NZmnZ.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do some research to find out more about this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your specific case, you should read the &lt;a href=&quot;http://www.ti.com/lit/ds/symlink/ads1115.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ADS1115 specification sheet&lt;/a&gt;.  As this ADC chip has it's own built in voltage reference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the Arduino paradigm, tasks that are to be executed once at the beginning of a program are placed in the setup() method.  Tasks which are to be executed repeatedly are placed in the loop() method.  As setting the gain of the ADC appears to only be done once (consult the ADS1115 PDF linked to above), it appears to fall into the former category.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I changed the circuit diagram after I realized it was a bad example for creating an Analog to Digital Converter voltage reference. &lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-07T12:17:56.400" LastActivityDate="2016-07-07T12:17:56.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26023" PostTypeId="1" AcceptedAnswerId="26027" CreationDate="2016-07-05T13:48:32.383" Score="1" ViewCount="1038" Body="&lt;p&gt;There are lots of examples around how to connect with an NTP server, but I do not see how to find such an IP-address. From the examples I conclude I need to find it on for example &lt;a href=&quot;http://www.pool.ntp.org/zone/nl&quot; rel=&quot;nofollow&quot;&gt;pool.ntp.org&lt;/a&gt;, but I do not even see how to get IP-addresses out of there myself, let alone to let my Arduino do it. Of course I looked at the &lt;code&gt;How do I use pool.ntp.org&lt;/code&gt; page, but it doesn't seem to say anything about finding IP-addresses.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Questions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ol&gt;&#xA;  &lt;li&gt;Is it possible to let my Arduino find a working NTP server (using the EtherCard library), and if so, how?&lt;/li&gt;&#xA;  &lt;li&gt;All the examples I saw have an NTP server IP address hard coded, isn't that a bad practice and also a bad idea for a longer running project?&lt;/li&gt;&#xA;  &lt;/ol&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The code I currently find the easiest to understand is from the &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=171941.0&quot; rel=&quot;nofollow&quot;&gt;Arduino forum&lt;/a&gt;, and has an IP address hard coded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Nano ATmega328 with a ENC28j60 ethernet shield, and therefore use the &lt;code&gt;EtherCard&lt;/code&gt; libray. I do know of existence of RTC devices but I would prefer NTP.&lt;/p&gt;&#xA;" OwnerUserId="23642" LastActivityDate="2016-07-05T14:54:07.697" Title="Find a time server for NTP to get the current time (EtherCard library)" Tags="|time|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26024" PostTypeId="1" AcceptedAnswerId="26025" CreationDate="2016-07-05T13:55:00.593" Score="1" ViewCount="327" Body="&lt;p&gt;I using the &lt;a href=&quot;http://datasheet.elcodis.com/pdf/58/61/586128/tsl1401r-lf.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;TSL1401R-LF Linescan Camera Module&lt;/a&gt;, which reads in a 1 X 128 line of pixels, and I'm having trouble understanding how the integration time is set for this device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand from page 9 that the minimum integration time is a constent that results from a function of the clock speed, but I don't fully understand when this integration period takes place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the timing waveform (Figure 1 on Page 5) the integration period appears to be set after the first 18 clock cycles. Does this mean that the integration period is set while the camera is outputting pixels? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jRHqc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jRHqc.png&quot; alt=&quot;TSL1401R-LF Timing Diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How is that even possible? Also does this mean that in order to achive the minimum delay time I would have to take that time and divide it across those remaining 110 clock cycles (i.e. 307 ns for a total of 33.75 us)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is how I am currently programming the camera. I'm using &lt;code&gt;delayMicrosecond()&lt;/code&gt; after the HIGH and LOW clock impulses as well as at the end. I have enough delays to achieve the minimum 33.75 microsecond delay, but I'm still having sensitivity problems.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int delayTime = 20;&#xA;&#xA;void readPixels()  &#xA;{&#xA;  digitalWriteFast(SI, HIGH);&#xA;  delayMicroseconds(delayTime/2);&#xA;  digitalWriteFast(CLK, HIGH);&#xA;  delayMicroseconds(delayTime/2);&#xA;  digitalWriteFast(SI, LOW);&#xA;  delayMicroseconds(delayTime/2);&#xA;  digitalWriteFast(CLK, LOW);&#xA;  delayMicroseconds(delayTime);&#xA;&#xA;  for(int i = 0; i &amp;lt; 128; i++)&#xA;  { &#xA;    digitalWriteFast(CLK, HIGH);&#xA;    pixelsArray1[i]=analogRead(Cam1Aout);&#xA;    pixelsArray2[i]=analogRead(Cam2Aout);&#xA;    pixelsArray3[i]=analogRead(Cam3Aout);&#xA;    delayMicroseconds(delayTime);&#xA;    digitalWriteFast(CLK, LOW);&#xA;    delayMicroseconds(delayTime);&#xA;  }&#xA;&#xA;  digitalWriteFast(CLK, HIGH);&#xA;  delayMicroseconds(delayTime);&#xA;  digitalWriteFast(CLK, LOW);&#xA;  delayMicroseconds(delayTime);&#xA;&#xA;  delayMicroseconds(20);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23008" LastActivityDate="2016-07-05T14:32:18.790" Title="How is the integration time set for a camera?" Tags="|arduino-mega|programming|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26025" PostTypeId="2" ParentId="26024" CreationDate="2016-07-05T14:32:18.790" Score="2" Body="&lt;p&gt;It is quite a difficult system to get your head around, as you have noticed.  I'll try and break it down more logically for you...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An important thing to note is that there are two capacitors in each pixel - the &lt;em&gt;integrating&lt;/em&gt; capacitor and the &lt;em&gt;sampling&lt;/em&gt; capacitor. It's these two capacitors that lead to a certain amount of confusion, and it's vital to understand the role of each one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://i.stack.imgur.com/OEL6G.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OEL6G.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Under normal sampling operation light falling on the photodiode of a pixel generates charge through the internal amplifier which is stored in the &lt;em&gt;integrating&lt;/em&gt; capacitor. Simultaneously that stored voltage level is mirrored in the &lt;em&gt;sampling&lt;/em&gt; capacitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you send the pulse on SI a signal called &lt;code&gt;HOLD&lt;/code&gt; is generated internally. This signal is sent to all of the pixels and tells them to disconnect their sampling capacitors. They do that through the switch S2.  At the same time the integrating capacitor is emptied by S1 causing a short circuit across it. That is held there for 18 clock cycles to make sure that it's completely empty. All this time the sampled voltage is still there in the sampling capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then as you continue clocking the pulse you sent in through the SI pin is walked down a 128 bit shift register. As it pops out of each output in turn it connects the sampling capacitor of that pixel to the output buffer so you can read the voltage. It's then flushed out and re-connected to the integrating circuit again to sample the pixel again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there is actually multiple things happening during your 129 clocks. Reading and integrating are both happening at the same time. But you're not reading &lt;em&gt;this&lt;/em&gt; set of clock's integration, but the &lt;em&gt;last&lt;/em&gt; set of clocks integration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SI pulse - HOLD generated, samples frozen&lt;/li&gt;&#xA;&lt;li&gt;18 clocks of clearing the integrators and reading nothing much.&lt;/li&gt;&#xA;&lt;li&gt;110 clocks of reading nothing much (nothing is sampled yet) and integrating.&lt;/li&gt;&#xA;&lt;li&gt;1 clock to terminate&lt;/li&gt;&#xA;&lt;li&gt;SI pulse - HOLD generated, samples frozen&lt;/li&gt;&#xA;&lt;li&gt;10 clocks of clearing the integrators and reading the &lt;strong&gt;previously integrated samples 1-18&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;110 clocks of reading the &lt;strong&gt;previously integrated samples 19-128&lt;/strong&gt; and integrating new ones&lt;/li&gt;&#xA;&lt;li&gt;1 clock to terminate&lt;/li&gt;&#xA;&lt;li&gt;... etc ...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So clocks 130 to 258 are reading the light that was sampled during clocks 19 to 128.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The upshot of all this is that your integrating period is the total time taken for the 110 clocks that occur between the end of the 18 clocks that clear the integrators and the next SI pulse that creates a new HOLD signal.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-05T14:32:18.790" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26026" PostTypeId="1" AcceptedAnswerId="32896" CreationDate="2016-07-05T14:41:18.710" Score="1" ViewCount="101" Body="&lt;p&gt;Hey everyone I know this is a pretty common question, and I have read/tried almost everything on all the other posts here and on the arduino.cc forums, but I have been unable to fix my problem. Basically I have been using my Arduino Leonardo for a little over a month now for all sorts of things and have never had this issue with the Arduino not showing up under the port tab on the menu. I have no idea why this just started happening to me, I am using the same cable, etc, and was hoping someone could help me out. I am on a MacBook Pro by the way. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2017-10-31T04:23:35.923" Title="Port Not Being Found" Tags="|usb|arduino-leonardo|" AnswerCount="2" CommentCount="10" ClosedDate="2017-11-09T20:42:39.570" ContentLicense="CC BY-SA 3.0" />
  <row Id="26027" PostTypeId="2" ParentId="26023" CreationDate="2016-07-05T14:54:07.697" Score="2" Body="&lt;p&gt;The &lt;code&gt;EtherCard&lt;/code&gt; library offers a method called &lt;code&gt;ether.dnsLookup(host)&lt;/code&gt; where you ask it to look up the IP address for you.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;etherCard.dnsLookup(&quot;pool.ntp.org&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...only that might fail, so it returns a &lt;code&gt;false&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!etherCard.dnsLookup(&quot;pool.ntp.org&quot;)) {&#xA;    // Error! Do something!&#xA;    return;&#xA;} // if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But if it works...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (!etherCard.dnsLookup(&quot;pool.ntp.org&quot;)) {&#xA;    // Error! Do something!&#xA;    return;&#xA;} // if&#xA;// At this stage, dnsLookup() worked...&#xA;&#xA;// Can now connect to IP adress in etherCard.hispip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now: please note that &lt;code&gt;ntp.org&lt;/code&gt; would prefer you to use a more precise locale than &lt;code&gt;pool.ntp.org&lt;/code&gt;. If you're going to distribute your application worldwide, then that's fine. But I always use &lt;code&gt;au.pool.ntp.org&lt;/code&gt; because I'm in the Australian region. There are &lt;a href=&quot;http://www.pool.ntp.org/zone/@&quot; rel=&quot;nofollow&quot;&gt;others&lt;/a&gt; that you can/should use instead.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-05T14:54:07.697" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26028" PostTypeId="2" ParentId="26026" CreationDate="2016-07-05T15:00:51.073" Score="0" Body="&lt;p&gt;Try this...&#xA;Go to your Arduino IDE.&#xA;Under the Tools tab, go to &quot;Board&quot; and select Arduino Leonardo.&#xA;Then in the Tools tab, go to Port and check to see if a port is selected.&#xA;Use this link to try and find which Serial Port you should have: &lt;a href=&quot;https://www.arduino.cc/en/Guide/MacOSX&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/MacOSX&lt;/a&gt;&#xA;Try plugging in the cable in different USB ports on your computer and see if the port number changes automatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, could you please say what peripherals or other things are connected to the arduino? Because for example, I know what using a Bluetooth slave with the Arduino while connected with the cable to your computer, doesn't let you upload your program. There could be similar problems to this.&lt;/p&gt;&#xA;" OwnerUserId="23641" LastActivityDate="2016-07-05T15:00:51.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26029" PostTypeId="2" ParentId="26016" CreationDate="2016-07-05T15:18:15.533" Score="0" Body="&lt;p&gt;I haven't used the TM1637 code, but I (think I) understand how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the original code is the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    tm1637.set();&#xA;    tm1637.init();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But in your code you only do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;    ...&#xA;    tm1637.init();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Have you tried adding the &lt;code&gt;tm1637.set();&lt;/code&gt; line in?&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-05T15:18:15.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26030" PostTypeId="2" ParentId="25875" CreationDate="2016-07-05T15:36:31.320" Score="2" Body="&lt;p&gt;Pull the reset pin up by connecting it to 3.3v with a 10k ohm resistor, then to reset the ESP you temporarily ground the pin, bringing it down to 0v/GND.&#xA;I'd recommend putting in a button for that :)&lt;/p&gt;&#xA;" OwnerUserId="23645" LastActivityDate="2016-07-05T15:36:31.320" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26031" PostTypeId="2" ParentId="22597" CreationDate="2016-07-05T15:37:48.820" Score="0" Body="&lt;p&gt;Both @CodeGorilla and @Majenko make valid points.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The shield esp will talk with the uno through Serial and your esp8266 has the AT firmware on it.&#xA;The BareMinimum reads input from serial and prints what the esp is sending .&#xA;the code you posted has code meant for the Uno and code meant for the shield esp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That wont work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your should use the arduino library for esp8266 (&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;,) make a suitable code for it , connect your sensor to the shield and forget the uno.&lt;/p&gt;&#xA;" OwnerUserId="6822" LastEditorUserId="10394" LastEditDate="2018-02-14T15:02:05.590" LastActivityDate="2018-02-14T15:02:05.590" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26033" PostTypeId="1" CreationDate="2016-07-05T16:46:36.530" Score="1" ViewCount="2181" Body="&lt;p&gt;I am having difficulty setting up an interrupt to count how many times the magnet passes so that I can count something like every 100 ms the actual speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a little code put together from the Internet:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const byte LED_pin =13;&#xA;const unsigned long wheel_circumference = 431800UL * 2UL * 31416UL; // = 94,248,000&#xA;unsigned long Speed = 0;&#xA;unsigned long PrevSpeed = 0;&#xA;volatile byte hall_rising = 0; // interrupt flag&#xA;volatile unsigned long irqMicros;&#xA;unsigned long startMicros;&#xA;unsigned long elapsedMicros;&#xA;unsigned long ledFlashStartMillis;&#xA;const unsigned long ledFlashWaitMillis = 10;&#xA;unsigned long displayStartMillis;&#xA;const unsigned long displayWaitMillis = 100;&#xA;&#xA;void wheel_IRQ()&#xA;{&#xA;  irqMicros = micros();&#xA;  hall_rising = 1;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode( 2, INPUT_PULLUP ); // pin # is tied to the interrupt&#xA;  pinMode( LED_pin, OUTPUT );&#xA;  Serial.begin( 9600 ); // can this be faster? faster would be better&#xA;  delay( 1000 );&#xA;&#xA;  attachInterrupt( 0, wheel_IRQ, RISING ); // pin 2 looks for LOW to HIGH change&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  if ( hall_rising == 1 )&#xA;  {&#xA;    elapsedMicros = irqMicros - startMicros;&#xA;    startMicros = irqMicros;&#xA;    hall_rising = 2;&#xA;  }&#xA;  else if  ( hall_rising == 2 )&#xA;  {&#xA;    if ( millis() - ledFlashStartMillis &amp;gt;= ledFlashWaitMillis )&#xA;    {&#xA;      hall_rising = 0;&#xA;    }&#xA;  }&#xA;&#xA;  // print speed 1000/Wait (10) times per second&#xA;  if ( millis() - displayStartMillis &amp;gt;= displayWaitMillis )&#xA;  {&#xA;    Speed = wheel_circumference * 0.0009 / elapsedMicros;&#xA;&#xA;    displayStartMillis += displayWaitMillis;&#xA;    if ( Speed != PrevSpeed )&#xA;    {&#xA;      Serial.print(Speed); // this shows mm/sec with no remainder&#xA;      Serial.println(&quot; kmh&quot;);&#xA;    }&#xA;    PrevSpeed = Speed;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I use this code in U8glib to display the value on a GLCD . Values are totally wrong. Can someone help me?&lt;/p&gt;&#xA;" OwnerUserId="23647" LastEditorUserId="2944" LastEditDate="2016-07-05T17:57:00.437" LastActivityDate="2016-07-06T00:55:50.240" Title="Arduino Mega Hall sensor interrupt for a speedometer" Tags="|arduino-mega|sensors|interrupt|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26035" PostTypeId="1" AcceptedAnswerId="26036" CreationDate="2016-07-05T17:58:03.240" Score="2" ViewCount="105" Body="&lt;p&gt;I'm working with a black &amp;amp; white camera and it gives me integer values to represent the amount of light hitting the sensor. Very bright is 1023 and totally dark is 0. The values are printed through serial and everything works fine but now I want to recreate the image based on the values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know if there is a simple way of doing this? I'm assuming the process would consist of looking up the value and giving a specific colored pixel in return, but I have no idea how to do this.&lt;/p&gt;&#xA;" OwnerUserId="23008" LastActivityDate="2016-07-05T18:27:01.987" Title="Is there an easy way to turn integer values to pixels?" Tags="|programming|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26036" PostTypeId="2" ParentId="26035" CreationDate="2016-07-05T18:27:01.987" Score="1" Body="&lt;p&gt;Simplest thing may be to write down your image in &lt;a href=&quot;http://netpbm.sourceforge.net/doc/pgm.html&quot; rel=&quot;nofollow&quot;&gt;plain Portable Gray&#xA;Map format&lt;/a&gt;. This is a very&#xA;simple (and inefficient) ASCII format consisting of a signature (the&#xA;string &quot;P2&quot;), followed by the width and height of the image, followed by&#xA;the maximum possible gray level (1023 in your case), followed by the&#xA;pixel values. It's a free form format, meaning you can mix spaces and&#xA;newlines at your convenience.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example image: two rows of pixels, five columns, and&#xA;brightness increasing left to right and top to bottom:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;P2&#xA;5 2&#xA;1023&#xA;  0 111 222 333 444&#xA;555 666 777 888 999&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then, any image conversion software should be able to convert that into&#xA;the format of your choice (PNG, JPEG, whatever...).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-05T18:27:01.987" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26038" PostTypeId="1" CreationDate="2016-07-05T19:56:36.993" Score="0" ViewCount="430" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Tvs16.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Tvs16.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1ocVG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1ocVG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a L3G4200D (GY-50 model) gyroscope. I have been  trying to learn how a gyro sensor works. The circuit diagram is attached. I want to ask some questions;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a) According to the datasheet of L3G4200D,&#xA;    x_lsb and x_msb  (28h and 29h),&#xA;    y_lsb ,y_msb     (2Ah and 2Bh),&#xA;    z_lsb , z_msb    (2Ch and 2Dh) as  shown in the picture 3.&#xA;But according to code that in the picture first, Arduino requests bytes from 168 address of gyro (in the picture, the mark number is 1).&#xA;But, 0x28 (hex) stands for b00101000 .&#xA;What's wrong with it ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;b) Output of gyro is outputs degrees/second, is it correct? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;c) In the picture 2, I did not move it, as it shown its results change, how can the angle change? It must be zero when it does not move. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;d) In the picture 1, what I should calculate: highbyte*256+lowbyte ? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;e) What does Fs=250,500,2000 dps mean? I know that Dps stands for Degree Per Second. But what would change by FS range, I mean if I pick either 500 or 2000 ? &lt;/p&gt;&#xA;" OwnerUserId="23656" OwnerDisplayName="Unforgiven" LastEditorUserId="27346" LastEditDate="2018-11-04T19:15:24.590" LastActivityDate="2018-11-04T19:15:24.590" Title="Main Idea of Gyro" Tags="|gyroscope|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="26039" PostTypeId="1" AcceptedAnswerId="26046" CreationDate="2016-07-05T20:18:05.817" Score="0" ViewCount="81" Body="&lt;p&gt;I'm following a tutorial which says SD.exists() only look for files inside media/realroot on Intel's Galileo board. I just confirmed this using SSH to create e remove files during a loop which was looking for some specific named file. Where's information about this? I searched for cpp files inside SD library and found nothing.&lt;/p&gt;&#xA;" OwnerUserId="15675" LastActivityDate="2016-07-06T01:14:46.627" Title="Why SD.exists() only looks for inside media/realroot on Intel's Galileo?" Tags="|sd-card|arduino-galileo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26040" PostTypeId="2" ParentId="26038" CreationDate="2016-07-05T20:29:19.923" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;According to the datasheet of L3G4200D, x_lsb and x_msb (28h and 29h), y_lsb ,y_msb (2Ah and 2Bh), z_lsb , z_msb (2Ch and 2Dh) as shown in the picture 3. But according to code that in the picture first, arduino requests biytes from 168 adress of gyro(in the pciture ,mark number is 1). But , 0x28 (hex) stands for b00101000 . what's wrong with it ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;168 is, in hex, 0xA8.  That's 0x28 with the MSB set. Why? Well, the datasheet says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;In order to read multiple bytes, it is necessary to assert the most significant bit of the subaddress&#xA;  field. In other words, SUB(7) must be equal to 1, while SUB(6-0) represents the&#xA;  address of the first register to be read.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So address 0xA8 is the same as address 0x28 plus the instruction &quot;I want to read multiple bytes&quot;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Output of gyro is outputs degrees/second ,is it correct ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Kind of. The number is actually a representation of the fraction of FS. See below.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;in the picture 1,what I should calculate hightbyte*256+lowbyte ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is turning two 8-bit values into a single 16-bit value. It's easier to represent it using bit shifts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(bighbyte &amp;lt;&amp;lt; 8) | lowbyte&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, the high byte is shifted left 8 bits and the low byte is then ORed over the lower (zero) 8 bits.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What does Fs=250,500,2000 dps mean ? I know that Dps stands for Degree Per Second .But what would change by FS range ,I mean if I pick either 500 or 2000 ?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That is the &quot;Full Scale&quot; value. It defines what the raw numbers from the gyro actually mean.  The gyro returns -32768 to +32767. -32768 is -FS, +32767 is +FS. So if the FS is set to 500 degrees per second then:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;-32768 is -500 degrees per second&lt;/li&gt;&#xA;&lt;li&gt;+32767 is +500 degrees per second&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The simple formula is (using floating point maths):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DPS = Reading / 32768.0 * FS&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The format is more commonly known as &lt;em&gt;Q15&lt;/em&gt; where a 16-bit value is split into 3 parts - a sign bit (bit 15), an integer part (there isn't one in this case), and 15 bits (14-0) of fraction. So the number actually represents, in Q15 format, between -1 and +1 in 65536 steps of 1/65536. That number is then multiplied by the full scale value, just like you would a percentage, to get the real DPS value.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-05T20:29:19.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26041" PostTypeId="2" ParentId="26038" CreationDate="2016-07-05T20:52:00.493" Score="2" Body="&lt;p&gt;According to the &lt;a href=&quot;http://www.st.com/content/ccc/resource/technical/document/datasheet/04/46/d6/00/be/d9/46/ae/CD00265057.pdf/files/CD00265057.pdf/jcr:content/translations/en.CD00265057.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;datasheet&lt;/a&gt;, FS seems to be Measurement Range. Also, I think you will find useful information in the following discussions: &lt;a href=&quot;https://electronics.stackexchange.com/questions/56234/understanding-the-sensitivity-of-an-l3g4200d-gyroscope&quot;&gt;Understanding the sensitivity of an L3G4200D gyroscope&lt;/a&gt; and in &lt;a href=&quot;https://electronics.stackexchange.com/questions/39024/how-do-i-get-gyro-sensor-data-l3g4200d-into-degrees-sec&quot;&gt;How do I get gyro sensor data (L3G4200D) into degrees/sec?&lt;/a&gt; Due to the fact that the gyro is 16 bit, the range of values would be 2^16, what makes 65536. So, the values on your screen are between -65536/2 and +65536/2, that's why max. values that you see are around 32000. &lt;br&gt; &lt;br&gt; There is always very tiny motion that the sensor can detect due to vibrations and etc. So, you should not expect the output of gyro to be a set of constants. Ideally, you should combine the data, lets say for 1 second, and find RMS value(average it) to get the result, don't look just for few instances/samples. &lt;br&gt;&lt;br&gt;Also I should note that if there is ultrasound in the gyro environment, it might also cause wrong results. When outer frequencies coincide with the natural frequency of the gyro system, it leads to resonance and distorted data. This &lt;a href=&quot;http://link.springer.com/article/10.1134/S2075108713030048#/page-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;paper&lt;/a&gt; has explanation of this phenomenon among with other impacts to the gyroscope. &lt;/p&gt;&#xA;" OwnerUserId="23654" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-05T20:52:00.493" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26042" PostTypeId="2" ParentId="24025" CreationDate="2016-07-05T22:27:37.683" Score="0" Body="&lt;p&gt;I had the same problem. My esp8266 is powered by FTDI USB to serial module. Since this module can provide a limited amount of current to 3.3V. I use to get frequent reset.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I resolved it by adding a 1000ufd electrolyte capacitor near the power connection of the esp8266 module. And issue resolved like never been there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am sure that can also be done by a smaller capacitor. Try with 470 or 220ufd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;enjoy&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rauf &lt;/p&gt;&#xA;" OwnerUserId="23658" LastActivityDate="2016-07-05T22:27:37.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26045" PostTypeId="2" ParentId="26033" CreationDate="2016-07-06T00:55:50.240" Score="1" Body="&lt;p&gt;You either need to change your code to count the number of revolutions in the interrupt.  Then divide that value in your main loop by the elapsed time to get the &lt;a href=&quot;https://en.wikipedia.org/wiki/Angular_velocity&quot; rel=&quot;nofollow noreferrer&quot;&gt;angular velocity&lt;/a&gt;.  This may or may not work, as the number of revolutions may be small or even zero when you do the calculations.  Thus contributing to errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or, change your code to record the elapsed time between rising edges in the interrupt.  Then find the inverse of this value.  This may be better as you could even miss an event in your main loop and still calculate the speed.  Careful not to take the inverse of zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To calculate speed you need to find the &lt;a href=&quot;https://en.wikipedia.org/wiki/Rotational_speed&quot; rel=&quot;nofollow noreferrer&quot;&gt;rotational speed&lt;/a&gt; of the wheel, and, consequently, how fast you are bicycling.  Use this equation:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/D46Os.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/D46Os.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;...where omega is the revolutions per time as calculated by the 1st method above or reported by the interrupt routine in the 2nd method above.  Do not forget that the interrupt routine is probably using milliseconds and not seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, do not forget to clear out the last value reported by the interrupt.  No matter which of the above 2 approaches you take.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also consider special cases.  For instance, when you stop bicycling the interrupt will never fire.  In your main loop you may have a second counter which, when exceeded, indicates that your speed is zero.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-06T00:55:50.240" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26046" PostTypeId="2" ParentId="26039" CreationDate="2016-07-06T01:14:46.627" Score="1" Body="&lt;p&gt;The Intel Galileo runs Linux.  Most Linux distributions (auto) mounts media under specific directories like &quot;/media&quot;.  So this is likely not so much a feature of the Arduino paradigm but of the Linux paradigm.  If you really want to change this you will probably have to research how Linux (specifically how the Intel Galileo version of Linux) auto mounts media.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://askubuntu.com/questions/214646/how-to-configure-the-default-automount-location&quot;&gt;This&lt;/a&gt; is a stack exchange question about auto-mounting using a Linux distribution called Ubuntu.  I am not sure how close the Intel Galileo Linux is to Ubuntu.  But it's a starting point.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="-1" LastEditDate="2017-04-13T12:23:03.187" LastActivityDate="2016-07-06T01:14:46.627" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26047" PostTypeId="2" ParentId="26003" CreationDate="2016-07-06T01:38:32.123" Score="1" Body="&lt;p&gt;Your second option is the easiest.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;a usb to ttl adapter cable to go straight to the Teensy LC, but I read somewhere that the serial UART with Arduino is different in some way&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Without seeing what you read, perhaps they were just talking about the fact that the Arduino is not &quot;true&quot; RS-232, it's only at TTL (or 3.3V) levels.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and wasn't sure if the serial communication coming through the usb to ttl cable would be compatible with the Teensy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It should be compatible, especially since you note that the Teeny is 5V-tolerant.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I was looking at one of these cables at sparkfun, and I think I would connect the TXD from the cable to the RX on the Teensy, the RXD from the cable to the TX on the Teensy, and the GND cable to a ground on the Teensy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's it in a nutshell!&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-06T01:38:32.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26048" PostTypeId="1" CreationDate="2016-07-06T02:55:03.963" Score="1" ViewCount="616" Body="&lt;p&gt;Please help me! Once I click the upload button.&#xA;I get the following error: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;'serialWrite' was not declared in this scope&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;int buttonPin&#xA;void setup ()&#xA;{&#xA;beginSerial(9600);&#xA;pinMode (buttonPin, INPUT);&#xA;}&#xA;void loop ()&#xA;{&#xA;if (digitalRead(buttonPin) == HIGH)&#xA;serialWrite('H');&#xA;else&#xA;serialwrite('L');&#xA;delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23660" LastEditorUserId="7508" LastEditDate="2016-07-06T11:59:07.700" LastActivityDate="2016-07-30T01:42:45.740" Title="'serialWrite' was not declared in this scope" Tags="|library|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26049" PostTypeId="1" CreationDate="2016-07-06T03:42:20.873" Score="0" ViewCount="195" Body="&lt;p&gt;I'm trying to create an array of strings. I'm building each individual string by parsing a json file and getting the strings between '{'s and '}'s. However, for some reason, my array is only assigning one index with the string i want. This is my code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  String day = &quot;&quot;;&#xA;  String Combo[] = {&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;};&#xA;  int x = 2;&#xA;  int number = 0;&#xA;&#xA;  /* Read data until either the connection is closed, or the idle timeout is reached. */ &#xA;  unsigned long lastRead = millis();&#xA;  while (www.connected() &amp;amp;&amp;amp; (millis() - lastRead &amp;lt; IDLE_TIMEOUT_MS)) {&#xA;    /* Reads one character at a time*/&#xA;    while (www.available()) {&#xA;      char sym = www.read();&#xA;&#xA;      if (sym == '{') {&#xA;        x = 1;&#xA;      }&#xA;      if (x==1){&#xA;        if (!day.concat(sym)) {&#xA;          //Serial.println(&quot;concat() error!&quot;);&#xA;        }&#xA;      }&#xA;      if (x==1 &amp;amp;&amp;amp; sym == '}'){&#xA;        x=0;&#xA;        Serial.println(number);&#xA;      }&#xA;&#xA;      if ((number &amp;gt; 0) &amp;amp;&amp;amp; (number &amp;lt; 9) &amp;amp;&amp;amp; (x==0)) {&#xA;        Combo[number-1] = day;&#xA;        Serial.print(day);&#xA;        Combo[number-1] = day;&#xA;&#xA;        Serial.println(F(&quot;-------------------------------------&quot;));&#xA;        Serial.println(Combo[number-1]);&#xA;&#xA;&#xA;        Serial.println(F(&quot;-------------------------------------&quot;));&#xA;        Serial.println(F(&quot;-------------------------------------&quot;));&#xA;        day = &quot;&quot;;&#xA;        number +=1;&#xA;        x = 2;&#xA;      } else if (number ==0 &amp;amp;&amp;amp; x ==0){&#xA;        day = &quot;&quot;;&#xA;        number +=1;&#xA;        x = 2;&#xA;      }&#xA;      lastRead = millis();&#xA;&#xA;    }&#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Which returns this: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;    &quot;firstString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;secondString&quot;&#xA;    }-------------------------------------&#xA;{&#xA;    &quot;secondString&quot;&#xA;    }&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;thirdString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;fourthString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;fifthString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;sixthString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;seventhString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;eighthString&quot;&#xA;    }-------------------------------------&#xA;&#xA;-------------------------------------&#xA;-------------------------------------&#xA;{&#xA;    &quot;secondString&quot;&#xA;    }-------------------------------------&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Based on this output I know that day is being constructed correctly but for some reason isn't assigned to an index in Combo (except &quot;secondString&quot;)&#xA;Does anyone know what's going on?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ideally Combo would equal: {&quot;secondString&quot;, &quot;thirdString&quot;, ... &quot;eighthString&quot;}&lt;/p&gt;&#xA;" OwnerUserId="23498" LastEditorUserId="23498" LastEditDate="2016-07-06T23:49:26.693" LastActivityDate="2017-01-03T09:20:35.357" Title="Can't assign elements to index in array" Tags="|arduino-uno|c++|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26051" PostTypeId="2" ParentId="17302" CreationDate="2016-07-06T06:48:13.660" Score="0" Body="&lt;p&gt;I've also been trying to figure out a suitable idea for the same question.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Image processing would be so accurate in this but there are some problems with this approach, since there is a lot of code work and in case we want to implement this system in restaurant people might not agree.&lt;/li&gt;&#xA;&lt;li&gt;Pressure sensors would work better for the  idea but there are some issues with this approach also. Just as mentioned in the question if there is some kind of a weight in the chair there will be an issue. also there are several chairs for a table in case of a restaurant so if we need to know whether the table is empty or not we will have to check whether all the seats are empty or not. In this case we need to pair the chair to the table using some method. we can also take this approach assuming that the chairs of the table will never change i.e. the same set of chairs remain for the same table. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The best approach for this particular scenario would be the sensors being in the table, or having a set of sensors such as a pressure sensor, thermal sensor, IR and verifying the seat is occupied. &lt;/p&gt;&#xA;" OwnerUserId="23663" LastActivityDate="2016-07-06T06:48:13.660" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26055" PostTypeId="2" ParentId="26049" CreationDate="2016-07-06T12:44:10.597" Score="1" Body="&lt;p&gt;I'm trying to understand your code.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;It looks like &lt;code&gt;x&lt;/code&gt; is a state variable, with the following values:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2 = &quot;Looking for start brace (`{`)&quot;&#xA;1 = &quot;Found! Now accumulating `day` until stop brace (`}`)&quot;&#xA;0 = &quot;Finished!&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If so, you may instead want to use the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum States { Looking, Adding, Done };&#xA;&#xA;// int x = 2;&#xA;States state = Looking;&#xA;&#xA;// x = 1&#xA;state = Adding;&#xA;&#xA;// if (x==1){&#xA;if (state==Adding) {&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you follow the flow of code, when &lt;code&gt;number&lt;/code&gt; is still &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt; finally becomes &lt;code&gt;0&lt;/code&gt;, you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Print out &lt;code&gt;number&lt;/code&gt; - the first line of your output;&lt;/li&gt;&#xA;&lt;li&gt;You then miss the main &lt;code&gt;if&lt;/code&gt; (&lt;code&gt;number&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; greater than &lt;code&gt;0&lt;/code&gt;);&lt;/li&gt;&#xA;&lt;li&gt;And enter the &lt;code&gt;else&lt;/code&gt; (which is satisfied);&lt;/li&gt;&#xA;&lt;li&gt;And then you immediately clear your hard-earned &lt;code&gt;day&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The second time through, after &lt;code&gt;x&lt;/code&gt; becomes &lt;code&gt;0&lt;/code&gt; again, this time you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Print out &lt;code&gt;number&lt;/code&gt; - the second line of your ouptut;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You &lt;em&gt;do&lt;/em&gt; enter the main &lt;code&gt;if&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You assign &lt;code&gt;day&lt;/code&gt; to &lt;code&gt;Combo[1]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You print out only the first seven entries in the the array (you want &lt;code&gt;&amp;lt;=7&lt;/code&gt;, not &lt;code&gt;&amp;lt;7&lt;/code&gt;)&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This should print out &lt;code&gt;0{?}000000&lt;/code&gt; (I don't know what &lt;code&gt;day&lt;/code&gt; should be).&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The fact that it doesn't seems to imply that your &lt;code&gt;concat()&lt;/code&gt; failed. Can you please change it to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// day.concat(sym);&#xA;if (!day.concat(sym)) {&#xA;    Serial.println(&quot;concat() error!&quot;);&#xA;} // if&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You then print out the row of dashes - and start a new line.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The third time through, it seems to work - you get your &lt;code&gt;{$ &quot;first string&quot; $}&lt;/code&gt; (where &lt;code&gt;$&lt;/code&gt; represents &lt;code&gt;\n&lt;/code&gt; and/or &lt;code&gt;\r&lt;/code&gt; - can you strip those out?)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      // if (x==1){&#xA;      //    day.concat(sym);&#xA;      if (x==1 &amp;amp;&amp;amp; sym&amp;gt;=' '){ // Don't concat new line characters!&#xA;          day.concat(sym);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;And the final few times &lt;code&gt;concat()&lt;/code&gt; seems to have failed again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The reason I say &quot;&lt;code&gt;concat()&lt;/code&gt; has failed&quot; is that it looks like &lt;code&gt;day&lt;/code&gt; is still &lt;code&gt;&quot;&quot;&lt;/code&gt; when it is assigned to &lt;code&gt;Combo&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Edit&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You've changed the code so that the main if now does the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Assigns &lt;code&gt;day&lt;/code&gt; to &lt;code&gt;Combo[number-1]&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Prints out &lt;code&gt;day&lt;/code&gt; - this seems to work;&lt;/li&gt;&#xA;&lt;li&gt;Assigns &lt;code&gt;day&lt;/code&gt; to &lt;code&gt;Combo[number-1]&lt;/code&gt; &lt;em&gt;&lt;strong&gt;again&lt;/strong&gt;&lt;/em&gt;;&lt;/li&gt;&#xA;&lt;li&gt;Prints out a line of hyphens - this works;&lt;/li&gt;&#xA;&lt;li&gt;Prints out &lt;code&gt;Combo[number-1]&lt;/code&gt; - this does &lt;strong&gt;NOT&lt;/strong&gt; seem to work;&lt;/li&gt;&#xA;&lt;li&gt;Prints out two lines of hyphens - this works.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since 5 is printing out nothing, it implies that 3 failed. This really does look like you're in a low-memory condition, and the system is failing to allocate memory from the heap.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't say what Arduino you're working on - note that most don't have much memory, and if you're already parsing a JSON file you've probably used a lot of it. You also don't say which version of the Arduino IDE you're using. There was a &lt;code&gt;String&lt;/code&gt; bug in the earlier versions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than trying to use the String class (a renowned heap hogger), you should try to use normal &lt;code&gt;char&lt;/code&gt; arrays and work the buffer management yourself.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-07-07T01:31:10.023" LastActivityDate="2016-07-07T01:31:10.023" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26056" PostTypeId="1" CreationDate="2016-07-06T13:07:20.177" Score="2" ViewCount="957" Body="&lt;p&gt;I'm new to all of this, but it's there a way to group a cluster of pins to one variable? I don't necessarily want the grouped pounds to be sequential.&lt;/p&gt;&#xA;" OwnerUserId="23667" LastActivityDate="2016-07-07T18:04:52.177" Title="Grouping multiple pins to one variable" Tags="|pins|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26057" PostTypeId="2" ParentId="26056" CreationDate="2016-07-06T13:13:26.610" Score="4" Body="&lt;p&gt;Only if you drop to low-level access, and only if the pins are &lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot;&gt;on the same port&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define pinset 0x55&#xA;&#xA; ...&#xA;&#xA;PORTC |= pinset;&#xA;delay(1000);&#xA;PORTC &amp;amp;= ~pinset;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-06T13:13:26.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26058" PostTypeId="2" ParentId="19207" CreationDate="2016-07-06T14:20:08.323" Score="6" Body="&lt;p&gt;There might be another device has already connected to that port. It could even be a terminal emulator which is left connected from last debugging session.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise, make sure that your UNO is really presented on COM4 by checking with &quot;Device Manager&quot;. if not, change the port where it is available.&lt;/p&gt;&#xA;" OwnerUserId="23616" LastActivityDate="2016-07-06T14:20:08.323" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26060" PostTypeId="1" CreationDate="2016-07-06T06:48:37.940" Score="1" ViewCount="986" Body="&lt;p&gt;I currently have a barebone arduino built from just an Atmega 328P and a 16Mhz external crystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Mrg7x.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Mrg7x.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I planning to move this system down to 3-3.6V but I have read that on low voltage I have to use 8Mhz crytstal so my only question is that because of this change do I have to take the chip out to reflash with the programmer again or it will work as it did before?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?&lt;/p&gt;&#xA;" OwnerDisplayName="Defiler" LastEditorUserId="37523" LastEditDate="2018-07-27T00:12:58.967" LastActivityDate="2018-07-27T00:12:58.967" Title="Moving ATMEGA to 3.3V" Tags="|atmega328|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26061" PostTypeId="2" ParentId="26060" CreationDate="2016-07-06T07:03:43.920" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;...I have read that on low voltage I have to use 8Mhz crytstal...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Technically you can run anywhere below 13Mhz or so, so you have lots of choice.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may also be able to use the prescaler to divide the clock by 2, either by hoping the ATmega can run the short time at 16MHz, or by programming the CKDIV8 fuse to start it at 2MHz.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...do I have to take the chip out to reflash with the programmer again...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you move to a frequency within spec with either a clock change or prescaler use, yes. The bootloader and Arduino libraries expect a 16MHz clock, so you will have to rebuild the bootloader with the new clock rate, and sketches that use &lt;code&gt;delay()&lt;/code&gt; et alia as well as the intrinsic delay functions will also need to be rebuilt.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It may work, it may not.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-07-06T07:28:54.060" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26062" PostTypeId="2" ParentId="26060" CreationDate="2016-07-06T07:05:19.413" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I planning to move this system down to 3-3.6V but I have read that on low voltage I have to use 8Mhz crytstal so my only question is that because of this change do I have to take the chip out to reflash with the programmer again or it will work as it did before?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Any time-sensitive code -- such as delays and UART I/O -- will run at half speed with the 8 MHz crystal. If any of this matters, you'll need to reprogram the chip. (This will include the bootloader, which will now run at half the baud rate it used to!) If this is OK, though, you can leave it alone.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The ATmega328P isn't specified to run reliably at 16 MHz at 3.3V. Many chips will actually work at this speed, but some will fail, possibly in subtle ways or at inconvenient times. Don't rely on it working.&lt;/p&gt;&#xA;" OwnerDisplayName="user7800" LastEditorDisplayName="user7800" LastEditDate="2016-07-07T06:08:15.183" LastActivityDate="2016-07-07T06:08:15.183" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26063" PostTypeId="1" CreationDate="2016-07-06T19:34:43.163" Score="1" ViewCount="731" Body="&lt;p&gt;So, This is your code slightly altered. I am using it to read the readings of the roll and pitch of a quadcopter. I have tried using this code for a mega 2560 but it does not work in ports A0 and A1. I think it might in A5 and A6 but I am unsure how to alter this code.&#xA;THank you,&#xA;Rohan Paleja&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*  rcTiming.ino -- JW, 30 November 2015 -- &#xA; * Uses pin-change interrupts on A0-A4 to time RC pulses&#xA; *&#xA; * Ref: http://arduino.stackexchange.com/questions/18183/read-rc-receiver-channels-using-interrupt-instead-of-pulsein&#xA; *&#xA; */&#xA;&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;static   byte rcOld;        // Prev. states of inputs&#xA;volatile unsigned long rcRises[2]; // times of prev. rising edges&#xA;volatile unsigned long rcTimes[2]; // recent pulse lengths&#xA;volatile unsigned int  rcChange=0; // Change-counter&#xA;int Roll, Pitch;&#xA;// Be sure to call setup_rcTiming() from setup()&#xA;void setup_rcTiming() {&#xA;  rcOld = 0;&#xA;  pinMode(A0, INPUT);  // pin 14, A0, PC0, for pin-change interrupt&#xA;  pinMode(A1, INPUT);  // pin 15, A1, PC1, for pin-change interrupt&#xA;&#xA;  PCMSK1 |= 0x0F;       // Four-bit mask for four channels&#xA;  PCIFR  |= 0x02;       // clear pin-change interrupts if any&#xA;  PCICR  |= 0x02;       // enable pin-change interrupts&#xA;}&#xA;// Define the service routine for PCI vector 1&#xA;ISR(PCINT1_vect) {&#xA;  byte rcNew = PINC &amp;amp; 15;   // Get low 4 bits, A0-A3&#xA;  byte changes = rcNew^rcOld;   // Notice changed bits&#xA;  byte channel = 0;&#xA;  unsigned long now = micros(); // micros() is ok in int routine&#xA;  while (changes) {&#xA;    if ((changes &amp;amp; 1)) {  // Did current channel change?&#xA;      if ((rcNew &amp;amp; (1&amp;lt;&amp;lt;channel))) { // Check rising edge&#xA;        rcRises[channel] = now;     // Is rising edge&#xA;      } else {              // Is falling edge&#xA;        rcTimes[channel] = now-rcRises[channel];&#xA;      }&#xA;    }&#xA;    changes &amp;gt;&amp;gt;= 1;      // shift out the done bit&#xA;    ++channel;&#xA;    ++rcChange;&#xA;  }&#xA;  rcOld = rcNew;        // Save new state&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Starting RC Timing Test&quot;);&#xA;  setup_rcTiming();&#xA;}&#xA;&#xA;void loop() {&#xA;  unsigned long rcT[2]; // copy of recent pulse lengths&#xA;  unsigned int rcN;&#xA;  if (rcChange) {&#xA;&#xA;    // Data is subject to races if interrupted, so off interrupts&#xA;    cli();          // Disable interrupts&#xA;    rcN = rcChange;&#xA;    rcChange = 0;       // Zero the change counter&#xA;    Roll = rcTimes[0];&#xA;    Pitch = rcTimes[1];&#xA;&#xA;&#xA;    sei();          // reenable interrupts&#xA;&#xA;    Serial &amp;lt;&amp;lt;  &quot; &quot; &amp;lt;&amp;lt; Roll &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; Pitch&#xA;       &amp;lt;&amp;lt; &quot; &quot;  &amp;lt;&amp;lt; rcN &amp;lt;&amp;lt; endl;&#xA;&#xA;  }&#xA;  sei();            // reenable interrupts&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23652" LastEditorUserId="7508" LastEditDate="2016-07-06T19:41:12.650" LastActivityDate="2016-07-07T16:27:32.200" Title="Why doesn't this work on a Mega2560 although it works on an Arduino Uno" Tags="|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26064" PostTypeId="1" AcceptedAnswerId="26065" CreationDate="2016-07-06T20:34:11.107" Score="1" ViewCount="1535" Body="&lt;p&gt;I was wondering what I would need and what I should do, to make a &lt;strong&gt;Smart Light Bulb&lt;/strong&gt;, like the &lt;a href=&quot;http://www2.meethue.com/it-it/&quot; rel=&quot;nofollow&quot;&gt;Hue one&lt;/a&gt; from Philips.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;I know these light bulbs can be &lt;strong&gt;controlled&lt;/strong&gt; by their &lt;strong&gt;Apps&lt;/strong&gt; from the smartphone, is there a way I can achieve this too?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What &lt;strong&gt;components&lt;/strong&gt; would I need to purchase?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a reference or a tutorial on how I should &lt;strong&gt;program&lt;/strong&gt; this light bulb?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15170" LastActivityDate="2016-07-07T08:58:47.243" Title="How to make a Smart Light Bulb?" Tags="|led|bluetooth|" AnswerCount="1" CommentCount="4" ClosedDate="2016-07-11T11:51:00.340" ContentLicense="CC BY-SA 3.0" />
  <row Id="26065" PostTypeId="2" ParentId="26064" CreationDate="2016-07-06T22:11:31.640" Score="4" Body="&lt;p&gt;You could use an ESP8266 NODEMCU. There is an example for making it emulate a Hue bridge ( &lt;a href=&quot;https://github.com/probonopd/ESP8266HueEmulator&quot; rel=&quot;nofollow&quot;&gt;https://github.com/probonopd/ESP8266HueEmulator&lt;/a&gt; ). &#xA;To have the official bridge control your lights would take Zigbee and finding out the protocol that Philips uses. Their API is open source, however the zigbee protocol they use is not afaik.&#xA;ESP8266 is a very cheap solution that works with arduino ide and does not need an arduino. There are powerplugs which have an ESP8266 in them (&lt;a href=&quot;https://www.itead.cc/smart-home/sonoff-sv.html&quot; rel=&quot;nofollow&quot;&gt;https://www.itead.cc/smart-home/sonoff-sv.html&lt;/a&gt;) &lt;/p&gt;&#xA;" OwnerUserId="23679" LastEditorUserId="15170" LastEditDate="2016-07-07T08:58:47.243" LastActivityDate="2016-07-07T08:58:47.243" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26066" PostTypeId="1" CreationDate="2016-07-06T22:22:53.100" Score="2" ViewCount="65" Body="&lt;p&gt;I've set up an Arduino Uno to run a pretty basic garden watering schedule, with the delay function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've now built a solar thermal water heater with a pump and tried running it separately through a 555 timer using a thermistor (33k Ohm approx). I couldn't get this running as the change in resistance with a water temperature rise to 30 deg or so wasn't enough to trip and untrip the 555 timer (thermistor at about 20 k at 20 deg, maybe 50k at 30 deg). (Any pointers to circuits that achieve this would be appreciated by the way.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've decided to try to run the solar thermal motor with my arduino set up as I have 2 relays free in a relay shield. My question is how I can run the sensor to start the solar thermal pump, then stop operating the solar thermal system and return to the garden watering code, then restart the sensor input, and so on. The issue is that my power supply is only 1 Amp, and running both systems at once might overheat it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this makes sense,&#xA;Brian&lt;/p&gt;&#xA;" OwnerUserId="23682" LastActivityDate="2016-11-04T14:58:36.010" Title="Running sensor input for given time, stopping, then running seperate scheduled relay output" Tags="|temperature-sensor|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26067" PostTypeId="1" AcceptedAnswerId="26084" CreationDate="2016-07-07T01:43:57.540" Score="1" ViewCount="76" Body="&lt;p&gt;I have an Arduino 328p (custom) and I can program it using a FTDI header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, when I power it from the FTDI using only the RAW (5V) and GND, it only executes simple programs (example blink). If in my sketch I attempt to use SPI for example, it will just get stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I power the arduino from the FTDI with the DTR pin connected, it will work just as expected for any sketch. I can even remove the DTR pin at this point and there will be no issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the cause of this behavior?&lt;br&gt;&#xA;Can it be an issue with optiboot fast start? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; FTDI is configured for 5V but VCC for the Arduino is 3.3V (I'm using the &lt;a href=&quot;http://www.microchip.com/wwwproducts/en/en530838&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP1703&lt;/a&gt; regulator). This means that the Arduino is powered by 3.3V but the RST pin will have 5V.&lt;br&gt;&#xA;&lt;strong&gt;PPS:&lt;/strong&gt; The Arduino is running at 16MHz&lt;/p&gt;&#xA;" OwnerUserId="15139" LastEditorUserId="84" LastEditDate="2016-12-04T19:23:09.387" LastActivityDate="2016-12-04T19:23:09.387" Title="Arduino fast start not working properly" Tags="|ftdi|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26068" PostTypeId="2" ParentId="25968" CreationDate="2016-07-07T03:26:44.170" Score="2" Body="&lt;p&gt;Yes, if you have a 0 to 30 mV signal that you need to measure to an accuracy of 2 microvolts, you'll need an ADC with an effective number of bits (ENOB) of at least 13.9 bits and an amplifier to make the signal to match the range accepted by the ADC.&#xA;Most ADCs pretty much require some sort of op-amp or differential amplifier between such low-level input signals and the ADC input pins.&#xA;A few ADCs have a differential amplifier already built in -- that makes things a lot easier to get working, but I don't know if any of such ADC available would meet the other requirements of your project.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know any way to make such high-resolution measurements other than using a dedicated external ADC chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You'll want to read the ADC datasheet -- some of them, and so far all the microcontrollers I've seen that claim to have a built-in &quot;16 bit ADC&quot;, have an effective number of bits (ENOB) worse than the 13.9 ENOB you need at the sampling rates I typically use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Adafruit has a very nice tutorial describing how to connect the 12-bit ADC ADS1015 or &lt;a href=&quot;https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/assembly-and-wiring&quot; rel=&quot;nofollow noreferrer&quot;&gt;the 16-bit ADC ADS1115 to an Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino playground has a brief tutorial describing connecting a 12-bit ADC MCP3208 or a &lt;a href=&quot;http://playground.arduino.cc/Code/MCP3208&quot; rel=&quot;nofollow noreferrer&quot;&gt;13-bit ADC MCP3304 to an Arduino&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I see from the Arduino blog and other sites that people have connected some even higher resolution ADCs to an to an Arduino board, including&#xA;the 24-bit Linear LTC2440 ADC;&#xA;the 18-bit LTC2400 ADC (24 bit at 5 samples per second); and&#xA;the 24-bit ADC TI ADS1220.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino blog. &lt;a href=&quot;http://blog.arduino.cc/category/ic/adc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Archive for the ‘ADC’ Category&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Peter Oakes. &lt;a href=&quot;http://www.youtube.com/watch?v=PrvhkhadL5g&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Arduino UNO, Using precision ADCs and DACs&quot;&lt;/a&gt;. (video tutorial: connecting the 24-bit ADC TI ADS1220 to an Arduino).&lt;/li&gt;&#xA;&lt;li&gt;Martin Nawrath. &lt;a href=&quot;http://interface.khm.de/index.php/lab/interfaces-advanced/connect-a-ltc2400-high-precision-24-bit-analog-to-digital-converter/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Connect a LTC2400 High Precision 24 Bit Analog to Digital Converter ... to the Arduino&quot;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;John Boxall. &lt;a href=&quot;http://tronixstuff.com/2013/07/02/tutorial-arduino-and-the-ti-ads1110-16-bit-adc/&quot; rel=&quot;nofollow noreferrer&quot;&gt;&quot;Tutorial – Arduino and the TI ADS1110 16-bit ADC&quot;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Sounds like a fun project.&#xA;Good luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Steve Luce. &lt;a href=&quot;http://www.steveluce.com/24bits/Applications%20of%20the%20LTC%2024%20bit%20ADC.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;The LTC2440 24 BIT ADC and the Arduino Uno&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Everyone that uses an ADC needs some antialiasing filter between the signal and the ADC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;People that measure very faint signals usually need some sort of amplifier between the signal and the ADC.&#xA;You may find the list of suggested op amps on p. 7 of the &lt;a href=&quot;http://www.mouser.com/ds/2/609/AMP03-879217.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;AMP03 datasheet&lt;/a&gt; useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because historically ADCs were expensive (and high-resolution ADCs were unavailable), people have developed many clever tricks for processing signals before feeding the processed signal into a relatively low-resolution ADC.&#xA;(Lock-in amplifiers, chopper amplifiers, manual precision gain adjustment, manual precision offset adjustment, heterodyning, etc.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you tried asking &quot;What sort of amplifier do I need to measure ((something)) with a 16-bit ADC&quot; at &lt;a href=&quot;https://electronics.stackexchange.com/&quot;&gt;https://electronics.stackexchange.com/&lt;/a&gt; to learn some of those tricks that specifically apply to ((something))?&lt;/p&gt;&#xA;" OwnerUserId="186" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-08T14:47:07.543" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26069" PostTypeId="2" ParentId="17355" CreationDate="2016-07-07T04:57:02.507" Score="4" Body="&lt;p&gt;As others have noted, this can be done using the same method as used in the standard 'BlinkWithoutDelay' example sketch, and combining that with a state-machine type approach. In a simple state machine you'd assume you can be in one of two states: outputting a tone, and not outputting a tone.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Applying these ideas to your code snippet above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// BEFORE SETUP&#xA;const int tonePin = 8;&#xA;unsigned long previousMillis = 0;&#xA;const long interval = pauseBetweenNotes;&#xA;const long interval = noteDuration;&#xA;boolean outputTone = false;                // Records current state&#xA;&#xA;&#xA;// IN LOOP&#xA;unsigned long currentMillis = millis();&#xA;&#xA;if (outputTone) {&#xA;// We are currently outputting a tone&#xA;// Check if it's been long enough and turn off if so&#xA;    if (currentMillis - previousMillis &amp;gt;= noteDuration) {&#xA;        previousMillis = currentMillis;&#xA;        noTone(tonePin);&#xA;        outputTone = false;&#xA;    }&#xA;} else {&#xA;// We are currently in a pause&#xA;// Check if it's been long enough and turn on if so&#xA;    if (currentMillis - previousMillis &amp;gt;= pauseBetweenNotes) {&#xA;        previousMillis = currentMillis;&#xA;        tone(tonePin, melody[thisNote]);&#xA;        outputTone = true;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23003" LastActivityDate="2016-07-07T04:57:02.507" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26070" PostTypeId="1" CreationDate="2016-07-07T03:12:31.363" Score="2" ViewCount="648" Body="&lt;p&gt;I have an Arduino Uno that I've been programming with an &lt;a href=&quot;https://en.wikipedia.org/wiki/Atmel_AVR#AVR_Dragon&quot; rel=&quot;nofollow noreferrer&quot;&gt;AVR Dragon&lt;/a&gt; through Atmel Studio 7.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did two things in close proximity, and I'm not entire sure which action is the culprit. I tried using the &lt;a href=&quot;https://en.wikipedia.org/wiki/DebugWIRE&quot; rel=&quot;nofollow noreferrer&quot;&gt;DebugWIRE&lt;/a&gt; interface (for the first time) instead of ISP in the tool select screen. I also hit the Arduino's reset button as Atmel Studio was compiling/uploading to the Arduino (stupid, I know.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I cannot program with &lt;a href=&quot;https://en.wikipedia.org/wiki/In-system_programming&quot; rel=&quot;nofollow noreferrer&quot;&gt;ISP&lt;/a&gt; the normal way, or do anything really.  If I try to upload to the Arduino I get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2Ow4e.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Ow4e.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried to use the device programming feature using the Dragon and change the fuses as I've read about in other posts and get:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kmxmA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kmxmA.png&quot; alt=&quot;Enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried burning a new bootloader with the Arduino IDE and the IDE tries ten times, but it tells me that the programmer is not responding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I plug my AVR ISP mk2 into a different Arduino Uno I get a nice constant green light. If I plug it into the board I've been discussing it blinks red.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure where to go from here...&lt;/p&gt;&#xA;" OwnerUserId="23700" OwnerDisplayName="Khaines0625" LastEditorUserId="510" LastEditDate="2016-11-02T05:28:06.403" LastActivityDate="2016-11-02T05:28:06.403" Title="Cannot enter programming mode on Arduino Uno" Tags="|avr|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26071" PostTypeId="2" ParentId="26070" CreationDate="2016-07-07T04:45:14.950" Score="1" Body="&lt;p&gt;I think either the chip or the board is fried. Try swap the chip (only the chip) to the other board and retry loading the program.&lt;/p&gt;&#xA;" OwnerUserId="4775" OwnerDisplayName="Maxthon Chan" LastActivityDate="2016-07-07T04:45:14.950" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26072" PostTypeId="1" CreationDate="2016-07-07T06:49:34.937" Score="2" ViewCount="846" Body="&lt;p&gt;Here I am using Arduino uno and GSM sim900A, I want to read sms from sim900A. But i am trying to read message, it is showing the empty values. I tried different methods, but no use. Here I have added my script. Please help me.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr wdt.h=&quot;&quot;&amp;gt;  &#xA;String phoneSMS = &quot;+91xxxxxxxxxx&quot;;  &#xA;String messageTxt;  &#xA;void setup()  &#xA;{  &#xA;Serial.begin(9600);  &#xA;delay(60000);  &#xA;srl_msg();  &#xA;}  &#xA;String srl_msg()  &#xA;{  &#xA;Serial.println(&quot;AT+CMGF=1\r&quot;);  &#xA;delay(1000);  &#xA;Serial.println(&quot;AT+CNMI=2,2,0,0,0&quot;);  &#xA;delay(1000);  &#xA;Serial.println(&quot;AT+CMGL=\&quot;ALL\&quot;\r&quot;); // to read ALL the SMS in text mode  &#xA;delay(1000);  &#xA;char txtmsg2[100]; // AT command output  &#xA;String date = readSerial(txtmsg2);  &#xA;String value = date.substring(1, 50);  &#xA;messageTxt = &quot;Internal - Heart Beat;&quot;;  &#xA;messageTxt.concat(value);  &#xA;Serial.println(value);  &#xA;SendSMS(messageTxt);  &#xA;}  &#xA;void loop()  &#xA;{  &#xA;}  &#xA;void SendSMS(String message)  &#xA;{  &#xA;Serial.print(&quot;at+cmgf=1\r&quot;);  &#xA;delay(1000);  &#xA;Serial.print(&quot;at+cmgs=\&quot;&quot;);  &#xA;Serial.print(phoneSMS);  &#xA;Serial.println(&quot;\&quot;&quot;);  &#xA;delay(1000);  &#xA;Serial.println(message);  &#xA;delay(1000);  &#xA;Serial.print((char)26);  &#xA;delay(15000); // AAN  &#xA;}  &#xA;String readSerial(char result[])  &#xA;{  &#xA;int i = 0;  &#xA;while (Serial.available() &amp;gt; 0)  &#xA;{  &#xA;char inChar = Serial.read();  &#xA;if (inChar != '\r')  &#xA;{  &#xA;result[i] = inChar;  &#xA;i++;  &#xA;}  &#xA;}  &#xA;return result;  &#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;output is look like this:&#xA;AT+CMGF=1  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;AT+CNMI=2,2,0,0,0  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK&lt;br&gt;&#xA;AT+CMGL=&quot;ALL&quot;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK&lt;/p&gt;&#xA;" OwnerUserId="23686" LastEditorUserId="23686" LastEditDate="2016-07-07T13:27:16.967" LastActivityDate="2016-11-10T03:44:37.640" Title="arduino + GSM/GPRS SIM 900A cannot able to read a message" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26073" PostTypeId="1" CreationDate="2016-07-07T07:57:41.417" Score="6" ViewCount="504" Body="&lt;p&gt;I am sending data (GPS coordinates) from Arduino once a minute with HTTP POST request to REST API (in OpenShift PaaS). Data is then stored to MySQL db.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would so called &quot;IoT&quot; publish/subscribe protocols (XMPP, MQTT) be better? Why?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When exactly do you use those two protocols rather than Restful HTTP? Would I really save a significant baterry energy using them?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AFAIK in those protocols machine would &quot;publish&quot; a data to broker and my app would subscribe to it. If I would like to gather data every minute in my app I guess that I would got to have some CRON job that would subscribe to data every minute? Or how would data gathering be achieved?&lt;/p&gt;&#xA;" OwnerUserId="23688" LastActivityDate="2017-04-30T06:07:43.850" Title="Why/when to use IoT publish/subscribe protocols rather then RESTful HTTP?" Tags="|arduino-uno|arduino-mega|power|communication|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26074" PostTypeId="2" ParentId="26066" CreationDate="2016-07-07T09:49:43.287" Score="1" Body="&lt;p&gt;If you are just running the relays off the 1 Amp supply, and there aren't more than 6 relays they shouldn't draw more than an amp.(I will edit this statement if need be)&lt;/p&gt;&#xA;&lt;p&gt;What you can do in the way of coding you can is to do a classic spinoff of using the &lt;code&gt;millis()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;//monitors temperature and schedules its operations&#xA;//RSM&#xA;#define TimeBetweenHydration 10000  //10 seconds &#xA;#define TimeBetweenThermal 1000  //1 second&#xA;#define Temperature_Thresh  25   //25°C&#xA;&#xA;float temperature = 0.00;&#xA;&#xA;unsigned long lastTempReadTime = 0;  //keep track of the time temperature was checked&#xA;//boolean MotorOn = false;  //state monitoring&#xA;&#xA;unsigned long lastWaterTime = 0; //last time the system did something with the watering thing&#xA;//boolean Watering = false; //state monitoring&#xA;&#xA;// other variables related to specifics&#xA;//…&#xA;//&#xA;&#xA;void setup(){&#xA;&#xA;//setup of analog inputs&#xA;//setup of digital pins&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA; unsigned long presentTime = millis();&#xA;&#xA;if((presentTime - lastTempReadTime) &amp;gt; TimeBetweenThermal){&#xA;lastTempReadTime = presentTime;&#xA; int inADC = analogRead(0);&#xA;&#xA;  //do whatever conversion is needed to get a value of the temperature&#xA;temperature = inADC*3.14;&#xA;&#xA;if(temperature &amp;gt; Temperature_Thresh){&#xA;&#xA;//   if(!MotorOn){&#xA;     digtalWrite(RLY, HIGH); //turn on pump&#xA;//     MotorOn = true;&#xA;//  }&#xA; }&#xA;  else{&#xA;  digitalWrite(RLY, LOW); //turn off pump&#xA;  }&#xA;}&#xA;&#xA;   if((presentTime - lastWaterTime) &amp;gt; TimeBetweenHydration){&#xA;   lastWaterTime = presentTime;&#xA;&#xA;//put your watering code stuff here&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If you want to make the pump run without a microcontroller you could use a comparator with the thermistor and use its output to switch a transistor. I do not have the 555 timer art skills.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qQ2T6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qQ2T6.jpg&quot; alt=&quot;thermistor controls with comparator&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;T1 is you thermistor. You should use the values listed for R1 - R3. The transistor, coil and flyback diode are there to show how you should connect it up, the coil could be a motor or a relay to control the motor. The comparator changes around the 30-40Kohm mark.&lt;/p&gt;&#xA;" OwnerUserId="2944" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-07-07T10:24:39.630" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26075" PostTypeId="2" ParentId="26063" CreationDate="2016-07-07T09:52:13.467" Score="1" Body="&lt;p&gt;You are trying to do an Pin Change Interrupt on Port F (A0-A7). On the arduino Uno, this port does support PCINT but not on the Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An option is to use the Port K for the PCINT. Instead of A0 and A1 you then use A8 and A9. A few little changes in the code should do the job:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup_rcTiming() {&#xA;rcOld = 0;&#xA;pinMode(A8, INPUT);  // pin 14, A0, PC0, for pin-change interrupt&#xA;pinMode(A9, INPUT);  // pin 15, A1, PC1, for pin-change interrupt&#xA;&#xA;PCMSK2 |= 0x0F;       // Four-bit mask for four channels&#xA;PCIFR  |= 0x04;       // clear pin-change interrupts if any&#xA;PCICR  |= 0x04;       // enable pin-change interrupts&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ISR(PCINT2_vect) {&#xA;byte rcNew = PINK &amp;amp; 15;&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23002" LastEditorUserId="23002" LastEditDate="2016-07-07T16:27:32.200" LastActivityDate="2016-07-07T16:27:32.200" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26076" PostTypeId="1" AcceptedAnswerId="26093" CreationDate="2016-07-07T10:17:25.157" Score="1" ViewCount="2307" Body="&lt;p&gt;I'm writing Arduino UNO (=ATMega328P-PU) programs in assembly to save memory, so I use avra.exe (same as atmel studio's avrasm32) to compile and avrdude to upload, and simple programs like blinking run fine. But now i tried to half-bright a LED with pwm. I checked up my code for errors but I didn't find any, and the LED just full brighs. I checked wiring too. I'm getting struck :c. Here's my pwm.asm code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;.nolist&#xA;.include &quot;m328pdef.inc&quot;&#xA;.list&#xA;&#xA;.cseg&#xA;.org 0x00&#xA;     rjmp start&#xA;.org 0x34&#xA; start: sbi ddrb, 5 ;pin 13&#xA;        sbi portb, 5 ;pin 13 on, just to compare with the PWMed led&#xA;        sbi ddrd, 5 ;pin 5 pwm&#xA;        ldi r16, 0b00100011 ;fast pwm mode, non inverted pwm at oc0b = pin 5 (right?)&#xA;        out tccr0a, r16 ;I'm using Timer0&#xA;        ldi r16, 0b00000001 ;no prescaler&#xA;        out tccr0b, r16&#xA;        ldi r16, 128 ; duty cycle = 50%&#xA;        out ocr0b, r16&#xA;&#xA;  loop: rjmp loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23690" LastActivityDate="2021-11-03T02:52:23.943" Title="Arduino PWM fading led in assembly" Tags="|arduino-uno|led|pwm|timers|assembly|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26080" PostTypeId="1" AcceptedAnswerId="26085" CreationDate="2016-07-07T11:50:04.917" Score="1" ViewCount="1105" Body="&lt;p&gt;I'm noob to Arduino and electronics, but here is a problem from life which I need to solve for myself:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We grow strawberries and early spring freezes can take most of the flowers from the plants. One way to protect this is to have some kind of heating in solar houses, but if you grow outside, your best option is to watering the flowers on the crops when the freezing comes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to deploy at least 3-4 temperature sensors, which are placed at every parts of the land, which will send the data for an Arduino which will turn on the pump with a relay (for this part I also want to use a pre-built relay solution with socket plugs already built, I don't want to mess around with high electricity myself).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a cable solution (like catKIT system) I need at least 100m cable for the farest part of the land, which can be managable, but later on, scaling the land lots of cables everywhere can be a problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best solution would be if every temperature sensor is a standalone station, data transmitted by wireless to the main Arduino which is triggering the pump. This way there will be lass cables on the land, less change to cable break by tractor, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, with a wireless system, I don't have to deal with signal loss over the cable, just only wireless signal loss. Is it possible to correct this by middle wireless signal transmitter stations? Or even better, all of them connected to each other!?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like if the farest sensor reading Celsius 0.8, middle sensor reading Celsius 1.2. Middle sensor have a variable to also consider any reading from the farest sensor, which is reading 0.8. If that reading under Celsius 1, than don't bother his own output, send 0.8 to the main Arduino which is triggering the pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These station's power input still need to be solved, but maybe solar panels can be an option? However I have a clue that night they will not work, most of them freezing comes at night.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I saw wireless shields for arduino which offering even a km range in ideal conditions. But how degrading when the conditions are not ideal, like a house wall, rain, fog, snow?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to feed multiple wireless inputs too one arduino? 3-4-10-20 standalone stations which transmitting temperature reads for the main arduino. If one of them sends lower temperature than +1 Celsius, than the pump will be turned on. Is it possible to solve this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You for your answers!&lt;/p&gt;&#xA;" OwnerUserId="23582" LastEditorUserId="23582" LastEditDate="2016-07-07T12:12:09.863" LastActivityDate="2016-07-07T12:54:00.620" Title="Best practices for really long distance sensor deployments" Tags="|temperature-sensor|wireless|wires|solar|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26081" PostTypeId="2" ParentId="26073" CreationDate="2016-07-07T12:12:00.420" Score="1" Body="&lt;p&gt;Basically, MQTT reduces latency where there's relatively high latency like Wi-Fi by keeping the TCP connection alive so that data can be published and received very quickly. It uses port 1883 and not 80.&#xA;As I understand it, the publishers and subscribers connect once to the broker and then ping the broker regularly to keep the connection alive; how often the broker is pinged depends on the pre-agreed keep-alive period. MQTT packets are also significantly smaller than HTTP requests. If the connection is somehow broken, the client repeatedly tries to re-establish the connection and when successful, the subscribers re-subscribe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Subscribers define callbacks that are called after a topic has has been updated by some publisher. MQTT is best for time-critical jobs where HTTP requests would just take too long and where quick notification of changed topics is desired. I'm not sure but it will probably consume more battery power, since there's that matter of a constant TCP link to the broker. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you're only expecting data updates every minute, I think it makes more sense to connect and GET the feed data from the server every 60 seconds. You can use the feed's &lt;code&gt;Last-updated&lt;/code&gt; time-stamp (if it doesn't exist, create one) to check if the feed has been updated by the Arduino yet. An MQTT technique would just spend most of the time connected to a broker for no reason since you already know that the update events occur every minute; that is a significant amount of time and power spent waiting for predictable data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you could wait for about 55 seconds, subscribe to the topic and when you get the new data, you disconnect and then wait for 55 seconds again, though I dont know if this will be much of an improvement over REST. If you use this method, you can also set the keep-alive period to be just about 10 seconds, so that the Arduino has enough time to update the feed before your app is notified and there's no need for regular pings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you decide to go with MQTT, check out &lt;a href=&quot;https://github.com/knolleary/pubsubclient&quot; rel=&quot;nofollow&quot;&gt;this Arduino library&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-07-08T00:06:32.083" LastActivityDate="2016-07-08T00:06:32.083" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26082" PostTypeId="2" ParentId="26066" CreationDate="2016-07-07T12:31:51.100" Score="1" Body="&lt;p&gt;I really appreciate your answer, thanks. I knew I'd have to let go of the delay function at some stage, and this is the moment I think ;) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the PS, I'm actually also powering two solenoid valves and the arduino through the same PS, so just being on the safe side. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wasn't too happy with a transistor circuit I made previously, but I'll give yours a go for sure. I actually came up with a workaround, which is probably pretty lame. I rigged up a second 555 timer with a large resistor to switch on and off the supply to the first 555 with thermistor every minute or so (a la flashing LED). So the thermistor now goes to temp, switches on the load, but then won't switch it off; the second 555 then resets the first 555, load switches off and either immediately switches on again if at temp, or stays off. Pretty ugly, right!&lt;/p&gt;&#xA;" OwnerUserId="23682" LastActivityDate="2016-07-07T12:31:51.100" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26084" PostTypeId="2" ParentId="26067" CreationDate="2016-07-07T12:45:03.780" Score="0" Body="&lt;p&gt;The reason for this issue is to do with SPI.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically in my custom arduino I have a 4Mbit flash and it communicates over SPI.&#xA;It seems that when the RST pin is connected it also automatically initializes the SPI protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the arduino is powered from RAW + GND directly from an external power source you need to initialize SPI manually.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your sketch you need to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;    void setup() {&#xA;        SPI.begin(); // this needs to be invoked before any SPI device gets initialized&#xA;&#xA;        // initialize and use SPI devices&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15139" LastActivityDate="2016-07-07T12:45:03.780" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26085" PostTypeId="2" ParentId="26080" CreationDate="2016-07-07T12:49:05.900" Score="2" Body="&lt;p&gt;There's as many ways of solving your problem as there are of skinning a cat (those poor poor cats - always getting skinned... ;) )&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you have already noted there are two basic solutions: wired or wireless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wired does have one major advantage that you haven't really touched on (only mentioned in passing) and that is power. With a wired solution you can provide power over those same wires so you don't need to worry about solar panels, batteries, whatever. But wires can break, yes. So they're not ideal. But then what is?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With wireless you then introduce the major problem of power. Solar panels are one possible way of getting power, though they are expensive, and you need to &quot;over spec&quot; them to charge batteries so you continue to have enough power for the times when is little or no sun.  Complementing them with wind power is also an option to boost the battery charge when its windy. It all adds up to very expensive sensors though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A compromise might be to consider both options together.  Turn the sensors into small clusters of sensors that are near by with a base station for those sensors that both gathers and stores the power needed for them, and performs the wireless communication. The sensors would then be wired to the base station.  Your wires are then shorter, and your power is more centralised.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But what to then use for the wireless itself? Well, there it's really all down to frequency.  There's two basic gropings here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;High frequency - 2.4GHz - is great at unobstructed communication. That's the frequency your WiFi works on, and as you probably know it's great if there's no walls in the way. Add walls and the signal drops off considerably. &lt;/li&gt;&#xA;&lt;li&gt;Low frequency - 433MHz - Far far better at penetrating walls and things but much less bandwidth.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have had distances of hundreds of meters using a 2.4GHz nRF24L01+ module with power amplifier and antenna. That's in open air with (pretty much) line of sight. Indoors the range is much much shorter. Put buildings in the way and your hundreds of meters drop down to tens of meters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if there are obstructions you're pretty much going to want to use the 433MHz range (there is another frequency, which is different depending on where in the world you are - 868MHz or 915MHz, so we'll ignore that for now).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's plenty of modules around that run at 433MHz, some better than others. There is, however, a new standard emerging now that is designed specifically for this kind of thing - long range, low bandwidth, just for sensors (as part of the IoT bandwagon) called LoRa (short for &lt;strong&gt;Lo&lt;/strong&gt;ng &lt;strong&gt;Ra&lt;/strong&gt;nge) which aims at distances of 15km using very small amounts of power (tens of mA) which is ideal for solar powered operation. It also can use the 868/915MHz region as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The final option that you touched on without knowing it is that of a &lt;em&gt;mesh&lt;/em&gt;. This is where all the nodes form a network and each node is capable of relaying data from other nodes to get to their destination. Kind of like how the internet works. There are some mesh libraries available for some radio modules on the Arduino, but I have no idea how good or reliable they are. The best ones would be completely self-healing with auto-discovery - add a node and the whole mesh works out how to route messages to the destination node; remove a node and the mesh works out new routes to pass the data around the hole it's created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Creating a good mesh stack is not child's play, so you would want to research it properly and find the best modules with the best library support if you wanted to take this route. That's why LoRa is taking off - it's so much simpler to get wide coverage without the need of complex mesh systems.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-07T12:49:05.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26086" PostTypeId="2" ParentId="26080" CreationDate="2016-07-07T12:54:00.620" Score="2" Body="&lt;p&gt;Personally I wouldn't use an Arduino as a wireless sensor controller, I would use an ESP8226, which comes with WIFI interface built in.  You can program this through the Arduino IDE in the same language, and its compatible with most Arduino sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ESP8266 also has the advantage that it can create a WIFI network of its own, because it can act as a WIFI client, a WIFI access point or both at the same time.  So if you do have an issue with the range of the signals then you can program your own WIFI repeater, which could also measure the temperature at the same time.   They come in many different shapes and sizes, I think you might be better having an external aerial capability, have a look around and see what you can find.  They cost around $2 so they should break the bank.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for powering it you could use solar or wind power to charge a battery.  Probably the best sort of battery for this is a Lead Acid battery because they don't object to being trickle charged.  Assuming you sensor station runs at 5V, you want at least a 6V battery.  You charge a 6V battery at 7.2V, so your solar panel(s) should generate at least 7.2V in &lt;em&gt;average&lt;/em&gt; sunshine.  You also need to work out how much power you sensor station is going to need, factor in an extra for working in cold weather, etc and then multiply it by the number of hours per day want it to work (24?).  This is the total power you need per day, so the output of you panels must be = (Required Power / Hours of Sun).  At this point you are best looking for a COTs device to charge the batteries and achieve your needs.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-07T12:54:00.620" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26087" PostTypeId="1" AcceptedAnswerId="26088" CreationDate="2016-07-07T13:16:43.830" Score="1" ViewCount="572" Body="&lt;p&gt;I have developed and produced a custom board with a ATmega 2560 on it and a FT232RL for USB communication. I want to burn an Arduino bootloader onto the board without using an external Arduino as ISP. I can't seem to figure out how. &#xA;When I just click &quot;burn bootloader&quot; from the arduino software it says: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;avrdude: stk500_recv(): programmer not responding&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong and how can I correctly burn the bootloader?&lt;/p&gt;&#xA;" OwnerUserId="23696" LastActivityDate="2016-07-07T13:19:16.130" Title="Burn bootloader on custom ATmega 2560 board" Tags="|bootloader|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26088" PostTypeId="2" ParentId="26087" CreationDate="2016-07-07T13:19:16.130" Score="1" Body="&lt;p&gt;To burn a bootloader you &lt;em&gt;have&lt;/em&gt; to use some external device. That can either be another Arduino or a hardware programmer, like an USBASP or something similar.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't just magic the bootloader on there through the USB and a dose of wishful thinking. To use the USB you first have to have the bootloader on there.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-07T13:19:16.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26089" PostTypeId="1" AcceptedAnswerId="26104" CreationDate="2016-07-07T14:34:40.200" Score="2" ViewCount="627" Body="&lt;p&gt;I am trying the RFID RC522 reader kit with an Arduino UNO to built a controlled access system for a door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the code below, I am able to read the UID of my card and light up an LED when the reader detects the card or the badge, however it will light up whatever card is presented to it even if the UID of this card is not entered as a String in my program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is how can I enter hundreds of cards (depending on memory) that will unlock the door and have all the others set as unknown if not in my program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much for your help&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;MFRC522.h&amp;gt;&#xA;&#xA;#define RST_PIN         9          // Configurable, see typical pin layout above&#xA;#define SS_PIN          10         //(or SDA) Configurable, see typical pin layout above&#xA;&#xA;MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance&#xA;// ===========================================================================&#xA;String read_rfid;&#xA;String ok_rfid_1 = &quot;C5 12 E3 52&quot;; // for the badge&#xA;String ok_rfid_2 = &quot;9A 48 3A D5&quot;; // for the card&#xA;// ==========================================================================&#xA;int led = 3;&#xA;// ===========================================================================&#xA;void setup() {&#xA; Serial.begin(9600); // Initialize serial communications with the PC&#xA; //while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)&#xA; SPI.begin(); // Init SPI bus&#xA; mfrc522.PCD_Init(); // Init MFRC522&#xA; mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details&#xA; Serial.println(F(&quot;Scan PICC to see UID, SAK, type, and data bleds...&quot;));&#xA;  pinMode(led, OUTPUT);&#xA;}&#xA;// ===========================================================================&#xA; void dump_byte_array(byte *buffer, byte bufferSize) {&#xA;  read_rfid=&quot;&quot;;&#xA;  for (byte i = 0; i &amp;lt; bufferSize; i++) {&#xA;    read_rfid = read_rfid + String(buffer[i], HEX);&#xA;  }&#xA; }&#xA;// ==========================================================================&#xA;void unlock() {&#xA;  digitalWrite(led, HIGH);&#xA;  delay(2000);&#xA;  digitalWrite(led, LOW);&#xA;}&#xA;// ======================================================================&#xA;void loop() {&#xA; // Look for new cards&#xA; if (! mfrc522.PICC_IsNewCardPresent())&#xA; return;&#xA; // Select one of the cards&#xA; if (! mfrc522.PICC_ReadCardSerial())&#xA; return;&#xA;&#xA;  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);&#xA;  Serial.println(read_rfid);&#xA;&#xA;  if (read_rfid == ok_rfid_1 || ok_rfid_2) {&#xA;    Serial.println(&quot;Open&quot;);&#xA;    unlock(); // turns LED on&#xA;  }&#xA;&#xA;  else {&#xA;    Serial.println(&quot;Stay Closed&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23697" LastEditorUserId="21252" LastEditDate="2016-07-08T00:09:02.910" LastActivityDate="2016-07-08T12:12:26.357" Title="RFID RF522 kit for access control" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26090" PostTypeId="2" ParentId="20740" CreationDate="2016-07-07T15:37:25.853" Score="2" Body="&lt;p&gt;I used &lt;a href=&quot;http://wired.chillibasket.com/2015/01/calibrating-mpu6050/&quot; rel=&quot;nofollow&quot;&gt;this script&lt;/a&gt; to calibrate the MPU6050, which is the same as the MPU9250 minus the digital compass. &lt;a href=&quot;https://github.com/kriswiner/MPU-6050/wiki/Simple-and-Effective-Magnetometer-Calibration&quot; rel=&quot;nofollow&quot;&gt;This guide&lt;/a&gt; explains how to calibrate the MPU9250's magnetometer.&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-07-07T15:37:25.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26091" PostTypeId="1" AcceptedAnswerId="26095" CreationDate="2016-07-07T16:32:01.397" Score="1" ViewCount="110" Body="&lt;p&gt;I have a wire going from &lt;code&gt;PWM4&lt;/code&gt; to &lt;code&gt;A0&lt;/code&gt; but I don't dare turn on my &lt;code&gt;Arduino Mega&lt;/code&gt; in case this is incorrect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;PWM4&lt;/code&gt; will eventually go to an &lt;em&gt;analog&lt;/em&gt; device but I want to make sure the read value is what I expect it to be. Am I okay to proceed with my current setup or do I need to throw in a &lt;code&gt;resistor&lt;/code&gt; / conversion?&lt;/p&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-07-07T18:43:48.713" Title="How can I get analog-in reading from Digital-PWM-out on the same board?" Tags="|arduino-mega|pwm|analogread|digital|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26092" PostTypeId="2" ParentId="26056" CreationDate="2016-07-07T18:04:52.177" Score="0" Body="&lt;p&gt;In the example of the constellations, consider using an array for each constellation where each element in the array corresponds to an LED output pin. You could simply put a 1 or a 0 in each array element to indicate if you want the corresponding LED output pin on or off. It would be easy then to create a function that you would pass a constellation array and would turn the LED output pins on or off based on the contents of the array.&lt;/p&gt;&#xA;" OwnerUserId="7297" LastActivityDate="2016-07-07T18:04:52.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26093" PostTypeId="2" ParentId="26076" CreationDate="2016-07-07T18:13:46.097" Score="2" Body="&lt;p&gt;I tried your program, after converting it to GNU-as syntax. It works as expected, as seen on the scope. Your problem may be simply that the difference between 50% ON and 100% ON is not very obvious to the eye because of its &lt;a href=&quot;https://en.wikipedia.org/wiki/Weber%E2%80%93Fechner_law&quot; rel=&quot;nofollow&quot;&gt;logarithmic perception&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-07T18:13:46.097" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26094" PostTypeId="1" AcceptedAnswerId="26097" CreationDate="2016-07-07T18:18:45.147" Score="1" ViewCount="8239" Body="&lt;p&gt;I'm trying to use nRF24L01 module to send a messages between 2 arduinos&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Transmiter code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  const char text[] = &quot;Hello World&quot;;&#xA;  radio.write(&amp;amp;text, sizeof(text));&#xA;&#xA;  delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reciver code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char text[32] = {0};&#xA;radio.read(&amp;amp;text, sizeof(text));&#xA;&#xA;Serial.println(text);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How I can put into char array an int value?&#xA;I tried doing it in this way&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&#xA;      int a = 60;&#xA;      const char text[] = String(a);&#xA;      radio.write(&amp;amp;text, sizeof(text));&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23701" LastActivityDate="2017-02-04T13:49:41.833" Title="Converting char array to int" Tags="|arduino-uno|wifi|arduino-leonardo|nrf24l01+|wireless|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26095" PostTypeId="2" ParentId="26091" CreationDate="2016-07-07T18:43:48.713" Score="3" Body="&lt;p&gt;You are fine by doing that, but you won't get what you expect. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A PWM signal isn't an analog value. It's a series of pulses, the duration of those pulses is set by the (not accurately called) analogWrite. So sometimes the value is 5V and sometimes it's 0V. You need to get the average value by adding e.g. an RC-filter.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to add a proper DAC (digital to analog converter) chip to your circuit.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-07T18:43:48.713" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26096" PostTypeId="1" CreationDate="2016-07-07T18:56:39.927" Score="1" ViewCount="4334" Body="&lt;p&gt;I'm reading input from a camera and trying to reach a fast frame rate. Problem is my ATtiny85 has a pretty slow conversion time (65 - 260 µs Conversion Time). Is there any way to make this faster? I heard that you can set-up a prescaler for the &lt;code&gt;analogRead()&lt;/code&gt; method by doing the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define FASTADC 1&#xA;&#xA;// defines for setting and clearing register bits&#xA;#ifndef cbi&#xA;#define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;amp;= ~_BV(bit))&#xA;#endif&#xA;#ifndef sbi&#xA;#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))&#xA;#endif&#xA;&#xA;void setup() &#xA;{&#xA;  #if FASTADC&#xA;   // set prescale to 16&#xA;   sbi(ADCSRA,ADPS2) ;&#xA;   cbi(ADCSRA,ADPS1) ;&#xA;   cbi(ADCSRA,ADPS0) ;&#xA;  #endif&#xA;&#xA;  /*Rest of the code goes here.*/&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can't really make sense of the code and I found it on a less then reliable website so I was wondering if any of the gurus on here could let me know if what I'm attempting is possible and if this is the proper way of achieving my goal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, would this also work for the Arduino Mega? I'm currently using it to test and debug my project since the ATtiny84 doesn't have serial output.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Datasheet: &lt;a href=&quot;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23008" LastActivityDate="2016-12-05T19:06:54.340" Title="How can you speed up the ADC on an ATtiny85?" Tags="|arduino-mega|programming|attiny|adc|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="26097" PostTypeId="2" ParentId="26094" CreationDate="2016-07-07T19:27:28.960" Score="0" Body="&lt;p&gt;Are you just looking for a way to get an arbitrary number expressed as a string? If so, you'll likely want to use some existing functions to help you along. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recommend using &lt;a href=&quot;http://www.cplusplus.com/reference/cstdio/sprintf/&quot; rel=&quot;nofollow&quot;&gt;sprintf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sprintf(char * str, char * format, args)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where str is the string you're storing results in, format is the string you're inserting your values into for, you guessed it, formatting, and args are all the args, separated by commas, that you'll be passing into the format string to be inserted into the str string. An example might be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char[x] result;    //x is the number of elements in your array, atleast one for every letter and one for the end character, ex: &quot;hello&quot; needs 6.&#xA;int number = 24;&#xA;sprintf(result, &quot;My number is %d&quot;, number);&#xA;sendSomewhere(result);   //sends &quot;My number is 24&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23216" LastEditorUserId="23216" LastEditDate="2016-07-08T23:55:43.163" LastActivityDate="2016-07-08T23:55:43.163" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26098" PostTypeId="1" CreationDate="2016-07-07T21:27:26.520" Score="2" ViewCount="2142" Body="&lt;p&gt;Can someone recommend a good book/reference for going vanilla (i.e. not using arduino simplified language) on e.g. ATtiny85? I will need to use the equivalents of analogRead() and digitalRead() quite a bit. And is softwareserial the best method for debug output? I have less than 8KB of flash, so any advice on that (and reduction of binary for upload) would also be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="16673" LastEditDate="2016-07-07T23:33:39.763" LastActivityDate="2017-11-21T20:59:48.160" Title="Good book/reference for AVR coding in pure C/C++?" Tags="|serial|programming|c++|avr|" AnswerCount="5" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26099" PostTypeId="1" CreationDate="2016-07-07T22:52:06.260" Score="1" ViewCount="1259" Body="&lt;p&gt;I'm using a DC motor with Hall Encoder. I bought it from &lt;a href=&quot;http://www.dx.com/p/12v-350rpm-dc-gear-motor-with-hall-encoder-silver-431965#.V334kbh96Uk&quot; rel=&quot;nofollow&quot;&gt;DX&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made all the connections to motor driver and arduino and I suppose all are correct. I've connected m1 and m2 pins of motor to that of motor driver, encoder A phase and B phase to arduino pins 3 and 11, and GND of motor to GND of Arduino and 3.3V pin of motor to 3.3V pin of Arduino. Also motor driver is also connected to arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I'm unable to run the motor but I can count the rotations made by the motor. Please help me with the working code. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="23184" LastActivityDate="2018-05-01T09:59:08.580" Title="How to control a DC Motor with Hall Encoder using Arduino and Motor Driver?" Tags="|arduino-uno|motor|l298n|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26101" PostTypeId="1" CreationDate="2016-07-07T23:51:37.703" Score="0" ViewCount="3054" Body="&lt;p&gt;I'm wondering how to drive a speaker using an arduino output pin.  I am using a pwm playback method with a sound data file.  If you wire a speaker across an output pin and ground then how do you calculate what speaker power and impedence you can use without damaging the arduino?  Is there a reference making these calculations?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-07-08T04:42:41.790" Title="What speaker can you drive with output pin?" Tags="|speaker|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26102" PostTypeId="2" ParentId="26101" CreationDate="2016-07-08T02:03:58.890" Score="1" Body="&lt;p&gt;Only very small ones with 20-30mA.  Earbud-size and slightly larger. You can buy a 2x3W amplifier which runs on 5V, and gives you two audio channels - but it works fine for mono. It can drive my 4 ohm desktop speaker, and is probably too powerful for that. Read about signal voltage and resistance for speakers. IIRC small audio outputs (like from an mp3 player) switch from -2.5V to 2.5V, giving an RMS of 5V. Or perhaps that was just my player. The only way to know this is to measure it - I played a sine wave and got a circa value. Offhand I can't say how to drive negative voltages from an arduino without extra circuitry. Hope it helps (and show us your code :)&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-07-08T02:03:58.890" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="26103" PostTypeId="2" ParentId="23975" CreationDate="2016-07-08T02:17:45.343" Score="0" Body="&lt;p&gt;Drive all your components simultaneously from an external supply at appropriate voltage. Measure current draw in series (set your multimeter's red cable on the 10A port and set it to 10A, and connect red to VOUT, black to ground). Don't hold the wires in your hands, use clip-ons. Let it run for a while, and pay attention to current fluctuations. Read the current requirements on the display. A power supply with a bit more amperage than necessary is a Good Thing(tm).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: remember to get both normal load and stall measurements. It is wise to add some way of turning stalling motors off, since stalling is motor death. And sometimes power supply death - those segway-for-kids things come to mind (and make me snicker ... WHEN I WAS A CHILD WE HAD OUR FEET FOR TRANSPORTATION, AND SHOES, IF WE WERE LUCKY!). &lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="16673" LastEditDate="2016-07-08T02:23:35.953" LastActivityDate="2016-07-08T02:23:35.953" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26104" PostTypeId="2" ParentId="26089" CreationDate="2016-07-08T02:19:11.760" Score="1" Body="&lt;p&gt;Your IF statement is the problem. &lt;code&gt;if (read_rfid == ok_rfid_1 || ok_rfid_2)&lt;/code&gt; always evaluates to &lt;code&gt;True&lt;/code&gt;. Your condition should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (read_rfid == ok_rfid_1 || read_rfid == ok_rfid_2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You also need to remove the spaces in the string literals if you want this condition to have the desired effect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This approach isn't very good though, since you have to add more comparisons to the IF condition if you want to match more cards. You should use the byte arrays as they are, without converting to Strings; it can actually be a lot simpler to compare as well as memory-safe. Store all your allowed card UIDs in a 2-D array:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define ALLOWED 2   // no of allowed cards&#xA;byte read_card[4];   // same purpose as before&#xA;bool found = false;  // to know when a valid card match occurs&#xA;byte cards[ALLOWED][4] = {{0xC5, 0x12, 0xE3, 0x52}, &#xA;                         {0x9A, 0x48, 0x3A, 0xD5}};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you should get rid of &lt;code&gt;dump_byte_array()&lt;/code&gt; and compare cards like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(read_card, mfrc522.uid.uidByte, 4); // copy UID into array with shorter name ;)&#xA;&#xA;for (int i = 0; i &amp;lt; ALLOWED; i++){&#xA;  if (memcmp(read_card, cards[i], 4) == 0){&#xA;&#xA;      found = true;&#xA;      break;&#xA;  }&#xA;}&#xA;&#xA;if (found){&#xA;  Serial.println(&quot;Open&quot;);&#xA;  unlock(); // turns LED on&#xA;  found = false;&#xA;}&#xA;else {&#xA;  Serial.println(&quot;Stay Closed&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-07-08T12:12:26.357" LastActivityDate="2016-07-08T12:12:26.357" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26105" PostTypeId="2" ParentId="26098" CreationDate="2016-07-08T03:24:28.490" Score="0" Body="&lt;p&gt;If you abandon the Arduino paradigm you will be pushed into dealing with setting up all the hardware that makes today's embedded processor so flexible.  This usually takes an experienced embedded programmer days if not weeks to get through on a new processor.  You will also need a dedicated Atmel programmer as you will no longer be using the Arduino boot loader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you get past these obstacles, you can start studying C and C++. The &quot;grand dad&quot; C reference book would be by the &quot;first guys&quot; that did C, Kernighan &amp;amp; Ritchie.  The equivalent C++ book (if you are up to it) would be by Bjarne Stroustrup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What have you gained by abandoning the Arduino paradigm?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some would say, not much.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most of why programming in the Arduino paradigm is easy has to do with Arduino libraries.  They &quot;abstract&quot; the hardware down to a couple simple function calls.  For example, with one function call you can set up the pulse train that can position a servo motor using a familiar term: degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should also be pointed out that the compiler Arduino uses is a C / C++ compiler.  And that most Arduino libraries are purposely written in C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Perhaps writing a C++ Arduino library is a good way to learn C++.  Start by finding the code to libraries that you already use.  Then reviewing how the C++ code is put together.  Finally write you own C++ Arduino library.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-08T03:24:28.490" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26106" PostTypeId="2" ParentId="26098" CreationDate="2016-07-08T04:33:44.683" Score="0" Body="&lt;p&gt;Sorry, I don't have any book recommendation apart from the AVR Datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could try to use AVR-LIBC as a abstraction layer instead of playing directly with individual registers: &lt;a href=&quot;http://www.nongnu.org/avr-libc/&quot; rel=&quot;nofollow&quot;&gt;http://www.nongnu.org/avr-libc/&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might help you saving some Ks on your code which the Arduino layer might be adding. Just make sure you have a proper IDE to assist you with code-completion and navigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also Atmel has a good link how to optimize your C code: &lt;a href=&quot;http://www.atmel.com/images/doc8453.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.atmel.com/images/doc8453.pdf&lt;/a&gt;, which I had a look when doing some bootloader coding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, you could explore the Arduino libraries, and see the overhead added to each function, like &quot;analogRead()&quot; from your example. Most of the Arduino funcions will be a layer on top of the AVR-GCC, so it'll be a good learning exercise - again, get a proper IDE that helps with auto-completion and navigation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-07-08T04:33:44.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26107" PostTypeId="2" ParentId="26101" CreationDate="2016-07-08T04:42:41.790" Score="2" Body="&lt;p&gt;The Arduino can supply 5V at max 20mA so 5/0.02 ⇒ 250Ω (if you can find such a beast).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NOTE you should use a capacitor to prevent DC flow if using a conventional speaker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general the larger the speaker the better. Tiny speakers are inefficient transducers. Hi-Fi speakers are not a good choice, as they are often inefficient, trading efficiency for linearity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative, if you are a scrounger, is to scavenge a transformer from an old transistor radio - this should give the best match.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-07-08T04:42:41.790" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26108" PostTypeId="2" ParentId="26098" CreationDate="2016-07-08T04:56:48.577" Score="0" Body="&lt;p&gt;The Arduino implements a subset of c++. I am not sure what you expect to achieve by not using it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are really after optimum code, there is no obligation to use any inbuilt function and you can code your own.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most conventional compilers use a standard runtime library. The reason Arduino does not is because of the limited memory. It is necessary to omit many standard functions to save space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By not using a library only functionality you need is actually linked in.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-07-08T04:56:48.577" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26110" PostTypeId="2" ParentId="26099" CreationDate="2016-07-08T06:39:29.487" Score="1" Body="&lt;p&gt;What are the &quot;m1&quot; and &quot;m2&quot; pins you mention?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the diagram I see on that link, the pins &quot;1-M1 motor -&quot; and &quot;6-M1 motor +&quot; should be connected to the motor driver. The other four pins should go to the Arduino only.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can probably test the motor by disconnecting it and connecting pins 1 and 6 to a 9-12V battery or similar, to see if it turns.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By the way I guess the two Encoder Phase connections would be set up on the Arduino using &lt;a href=&quot;https://www.arduino.cc/en/Reference/PinMode&quot; rel=&quot;nofollow&quot;&gt;PinMode&lt;/a&gt; setting &quot;INPUT_PULLUP&quot;. But as you can already read the positions, that part may not matter.&lt;/p&gt;&#xA;" OwnerUserId="10135" LastActivityDate="2016-07-08T06:39:29.487" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26111" PostTypeId="1" CreationDate="2016-07-08T07:45:53.450" Score="0" ViewCount="166" Body="&lt;p&gt;I am producing a  data stream and feeding to a gpio pin. THe data is sampled at 2kbps. i want to dump this data into a file after a certain length of reading . how should i proceed with this ?&lt;/p&gt;&#xA;" OwnerUserId="23708" LastEditorUserId="23708" LastEditDate="2016-07-09T09:17:38.870" LastActivityDate="2016-07-09T09:17:38.870" Title="not getting proper bitstream output in serial monitor using digitalRead" Tags="|arduino-uno|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26113" PostTypeId="1" AcceptedAnswerId="26116" CreationDate="2016-07-08T07:54:21.340" Score="2" ViewCount="81" Body="&lt;p&gt;At first, I sorry if I make some English faults but I'm French. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I'm making a connection between a client and an Arduino Uno. I receive all data that I need but when I send a response to my client some characteres are lost. &#xA;I receive this format : GET /?b=7&amp;amp;p=100$ (for exemple)&#xA;And my Arduino sends this to my client : GET /?b=7&amp;amp;p=1d&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the function where I get all data from my client : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void read_data(int *state, int *progress_program){&#xA;  // Check if there is a client&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    url = &quot;&quot;;&#xA;    index = 0;&#xA;    Serial.println(&quot;\nnew client&quot;);&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        Serial.println(c);&#xA;       if(c != '$') { // if end of char&#xA;          url[index] = c;&#xA;          index++;&#xA;        } else {&#xA;          url[index] = '\0';&#xA;          int i;&#xA;         Serial.print(&quot;\n&quot;);&#xA;          for(i=0;i&amp;lt;index;i++)&#xA;            Serial.print(url[i]);&#xA;          if(interpret(state, progress_program)){&#xA;            action();&#xA;            delay(100);  &#xA;          }&#xA;          answer(client);&#xA;          break;&#xA;        }&#xA;      }&#xA;    }&#xA;    url[0] = '\0';&#xA;    // give the web browser time to receive the data&#xA;    client.stop();&#xA;    delay(100);&#xA;    Serial.println(&quot;\nclient disconnected&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the response sent to the client : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void answer(EthernetClient client){&#xA;  Serial.print(&quot;\nResponse&quot;); // debug&#xA;  delay(100);&#xA;  client.print(url);&#xA;  Serial.print(&quot;Response Sent&quot;);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With client.write(url) there is the same problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have you got a solution? &#xA;thanks&lt;/p&gt;&#xA;" OwnerUserId="23643" LastEditorUserId="23643" LastEditDate="2016-07-08T08:03:08.180" LastActivityDate="2016-07-08T10:28:34.417" Title="Informations lost in a string" Tags="|arduino-uno|ethernet|c|string|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26114" PostTypeId="2" ParentId="8545" CreationDate="2016-07-08T08:01:23.860" Score="1" Body="&lt;p&gt;You need to connect A4 and A5 via pullup register to 3V and to I2C interface on Arduino Uno.&#xA;And you need to connect A7 to XCLK signal via 2 registers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find schema and code in my blog: &lt;a href=&quot;http://privateblog.info/arduino-uno-i-kamera-ov7670-primer-ispolzovaniya/&quot; rel=&quot;nofollow&quot;&gt;How to connect Arduino Uno and OV7670&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15624" LastActivityDate="2016-07-08T08:01:23.860" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26115" PostTypeId="2" ParentId="26111" CreationDate="2016-07-08T10:18:51.317" Score="1" Body="&lt;p&gt;Without seeing your code it's impossible to tell just what is happening, but I would guess you are reading and printing the &lt;em&gt;level&lt;/em&gt; of the wave, not the &lt;em&gt;transitions from one level to another&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WCm6a.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WCm6a.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see, just reading regularly and printing it (which itself is quite slow) results in 11001101 rather than the 10101 that you want. That's because the speed of your reading/printing and the frequency of your wave are completely separate things and out of step with each other. There's nothing to tie one to the other.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to look for the transitions from LOW to HIGH and from HIGH to LOW. Only when the input &lt;em&gt;changes&lt;/em&gt; should you look to see what the new level is and print that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/rQeYx.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rQeYx.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see the 1 and 0 are &lt;em&gt;just after&lt;/em&gt; the change in level, since it's impossible to do anything &lt;em&gt;during&lt;/em&gt; a change, only &lt;em&gt;once the change has happened&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might code that as something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(115200);&#xA;    pinMode(3, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;    static byte oldValue = LOW;     // Place to store the previous level&#xA;    byte newValue = digitalRead(3); // Read the current level&#xA;    if (newValue != oldValue) {     // The input has changed&#xA;        oldValue = newValue;        // Save the current level&#xA;        Serial.print(newValue);     // Print it.&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-08T10:18:51.317" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26116" PostTypeId="2" ParentId="26113" CreationDate="2016-07-08T10:28:34.417" Score="1" Body="&lt;p&gt;So, the solution was very simple, &#xA;My pointer &quot;url&quot; received a constant null string with url=&quot;&quot;; at the beginning. To initialize a string as null we need to make this : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; url[0] = '\0';&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="23643" LastActivityDate="2016-07-08T10:28:34.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26117" PostTypeId="1" AcceptedAnswerId="26121" CreationDate="2016-07-08T10:35:54.757" Score="1" ViewCount="1266" Body="&lt;p&gt;So i'm working on a quadcopter controlled by the arduino UNO, and focusing in pin interrupts for the reciever. This is the code for the reciever.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long timer[4];&#xA;byte last_channel[4];&#xA;volatile int input[4];&#xA;&#xA;&#xA;void rx_initialize() {&#xA;  PCICR |= (1 &amp;lt;&amp;lt; PCIE0);&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT0);&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT1);&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT2);&#xA;  PCMSK0 |= (1 &amp;lt;&amp;lt; PCINT3);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;ISR(PCINT1_vect) {&#xA;&#xA;  timer[0] = micros();//Lire la valeur PWM en microsecondes&#xA;&#xA;  //////////////////////////CHANNEL1/////////////////////////////&#xA;  if(last_channel[0] == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00000001){//vaut digitalRead(HIGH); mais en plus rapide&#xA;    last_channel[0] = 1;//le state est HIGH&#xA;    timer[1] = timer[0];//Lire combien de temps HIGH&#xA;  }&#xA;  else if(last_channel[0] == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00000001)){&#xA;    last_channel[0] = 0;//le state est HIGH&#xA;    input[0] = timer[0] - timer[1];&#xA;  }&#xA;&#xA;  //////////////////////////CHANNEL2/////////////////////////////&#xA;  if(last_channel[1] == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00000010){//Rising&#xA;    last_channel[1] = 1;//le state est HIGH&#xA;    timer[2] = timer[0];//Lire combien de temps HIGH&#xA;  }&#xA;  else if(last_channel[1] == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00000010)){//Falling&#xA;    last_channel[1] = 0;//le state est HIGH&#xA;    input[1] = timer[0] - timer[2];&#xA;  }&#xA;&#xA;  //////////////////////////CHANNEL3/////////////////////////////&#xA;  if(last_channel[2] == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00000100){//Rising&#xA;    last_channel[2] = 1;//le state est HIGH&#xA;    timer[3] = timer[0];&#xA;  }&#xA;  else if(last_channel[2] == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00000100)){//Falling&#xA;    last_channel[2] = 0;//le state est HIGH&#xA;    input[2] = timer[0] - timer[3];&#xA;  }&#xA;&#xA;  //////////////////////////CHANNEL4/////////////////////////////&#xA;  if(last_channel[3] == 0 &amp;amp;&amp;amp; PINB &amp;amp; B00001000){//Rising&#xA;    last_channel[3] = 1;//le state est HIGH&#xA;    timer[4] = timer[0];&#xA;  }&#xA;  else if(last_channel[3] == 1 &amp;amp;&amp;amp; !(PINB &amp;amp; B00001000)){//Falling&#xA;    last_channel[3] = 0;//le state est HIGH&#xA;    input[3] = timer[0] - timer[4];&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm using various files for every other part of the quadcopter such as PID controlling and IMU Reading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But avrdude tells me that I did a redefinition of 'void __vector_4()'.&#xA;Itried to look into PinChangeInt.h in the Arduino library folder but still no solution to the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you for your help!&lt;/p&gt;&#xA;" OwnerUserId="23713" LastActivityDate="2016-07-08T20:48:12.173" Title="PCINT with my arduino UNO says redefinition of 'void __vector_4()'" Tags="|arduino-uno|programming|interrupt|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26118" PostTypeId="2" ParentId="26098" CreationDate="2016-07-08T10:52:01.370" Score="5" Body="&lt;p&gt;First, let's make this clear: The Arduino environment does not provide a&#xA;“simplified language”: it provides a simple hardware abstraction layer&#xA;through its core library. The language is plain C++.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like Talk2, I don't have good book recommendations. The basics of&#xA;low-level programming are covered in the Arduino tutorial on &lt;a href=&quot;https://www.arduino.cc/en/Reference/PortManipulation&quot; rel=&quot;noreferrer&quot;&gt;port&#xA;manipulation&lt;/a&gt;[]. Past this you will have to dig into the datasheet of&#xA;your MCU. Look also at the doc of the &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/index.html&quot; rel=&quot;noreferrer&quot;&gt;avr-libc&lt;/a&gt; and the tutorials in&#xA;&lt;a href=&quot;http://www.gammon.com.au/forum/?bbtopic_id=123&quot; rel=&quot;noreferrer&quot;&gt;Nick Gammon's microprocessors pages&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest you try to develop your program like this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Do the initial prototype of your idea on an Arduino Uno (or similar)&#xA;using the Arduino libraries. It just makes things easier, and you are&#xA;more likely to get a working prototype pretty fast.&lt;/li&gt;&#xA;&lt;li&gt;Once the initial idea works, optimize it for the limited resources of&#xA;the ATtiny85. This may involve replacing some call to the Arduino&#xA;libs with avr-libc and/or direct port access.&lt;/li&gt;&#xA;&lt;li&gt;You may then want to remove all references to Arduino core, but you&#xA;don't have to: there are some ATtiny cores available that you can use&#xA;if you want.&lt;/li&gt;&#xA;&lt;li&gt;If it now fits in less than 8 K, port to the ATtiny.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The thing I love about the Arduino environment is that you can very&#xA;easily mix and match abstraction levels: you can have, in the same&#xA;program, calls to Arduino core, to avr-libc, direct port access, and&#xA;even inline assembly if want to. You don't even need to stick to the&#xA;&lt;code&gt;setup()&lt;/code&gt; and &lt;code&gt;loop()&lt;/code&gt; method: you can write your own &lt;code&gt;main()&lt;/code&gt; if you&#xA;prefer, just remember to call &lt;code&gt;init()&lt;/code&gt; to initialize the Arduino core if&#xA;you are going to use it. Oh, and you don't have to use the Arduino IDE&#xA;either if you don't like it (I don't).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the optimization tips, I would recommend :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use direct port access instead of &lt;code&gt;digitalRead()&lt;/code&gt;, because that&#xA;function is pretty big and slow.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;analogRead()&lt;/code&gt; may not be that bad, size wise, but it has a serious&#xA;shortcoming: it's a blocking function which spends 104&amp;nbsp;µs in a&#xA;spin loop, just waiting for the ADC result. If your CPU has better&#xA;things to do, you may want to implement a non-blocking read instead.&lt;/li&gt;&#xA;&lt;li&gt;For debugging output, the most efficient option is likely to be the&#xA;USI port. You will have to search for a driver or implement your own&#xA;based on the Atmel application note &lt;a href=&quot;http://www.atmel.com/Images/doc4300.pdf&quot; rel=&quot;noreferrer&quot;&gt;AVR307: Half Duplex UART Using&#xA;the USI Module&lt;/a&gt;. Alternatively, you could use something like&#xA;&lt;a href=&quot;https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html&quot; rel=&quot;noreferrer&quot;&gt;AltSoftSerial&lt;/a&gt;. Do not use SoftwareSerial: it blocks interrupts for&#xA;insanely long amounts of time.&lt;/li&gt;&#xA;&lt;li&gt;Use the command &lt;code&gt;avr-nm --size-sort -Crtd my_program.elf&lt;/code&gt; to get a&#xA;listing of the functions of your program sorted by flash usage. This&#xA;will help you choose good targets for size optimization.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-08T10:52:01.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26119" PostTypeId="2" ParentId="26117" CreationDate="2016-07-08T11:15:49.827" Score="1" Body="&lt;p&gt;You should use the ISR(PCINT0_vect) instead of the ISR(PCINT1_vect). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or if you want to use PCINT1:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PCICR |= (1 &amp;lt;&amp;lt; PCIE1);&#xA;PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT8);&#xA;PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT9);&#xA;PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT10);&#xA;PCMSK1 |= (1 &amp;lt;&amp;lt; PCINT11);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But them you have to change every PINB to PINC too as it uses a different PORT&lt;/p&gt;&#xA;" OwnerUserId="23002" LastEditorUserId="23002" LastEditDate="2016-07-08T11:22:39.063" LastActivityDate="2016-07-08T11:22:39.063" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26120" PostTypeId="2" ParentId="26096" CreationDate="2016-07-08T13:10:08.733" Score="2" Body="&lt;p&gt;The ADCs in the ATtiny85 and ATmega2560 (the chip powering the Arduino&#xA;Mega 2560) are pretty similar, except for the Mega having more inputs.&#xA;In particular, the way you set the clock prescaler is the same, namely&#xA;the bits ADPS2:0 in the register ADCSRA. You could use the same code to&#xA;set the prescaler on both chips, but you probably don't want to unless&#xA;your ATtiny is clocked at 16&amp;nbsp;MHz, like your Mega. I would normally&#xA;just &lt;em&gt;set&lt;/em&gt; the control register to the value I want, rather than&#xA;touching only a few bits, but that is a matter of personal preference.&#xA;So, to set the ADC clock of the Mega to 1&amp;nbsp;MHz, I would&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;ADCSRA = _BV(ADEN)    // enable the ADC&#xA;       | _BV(ADPS2);  // clock at F_CPU / 16 = 1 MHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The same code would do the same thing on an ATtiny clocked at&#xA;16&amp;nbsp;MHz. If the ATtiny runs at 8&amp;nbsp;MHz, I would instead&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;ADCSRA = _BV(ADEN)    // enable the ADC&#xA;       | _BV(ADPS1)   // clock at&#xA;       | _BV(ADPS0);  //     F_CPU / 8 = 1 MHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to be generic:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#if F_CPU &amp;gt;= 12000000&#xA;# define ADPS_SETTING _BV(ADPS2)                 // F_CPU / 16&#xA;#else&#xA;# define ADPS_SETTING (_BV(ADPS1) | _BV(ADPS0))  // F_CPU / 8&#xA;#endif&#xA;&#xA;ADCSRA = _BV(ADEN)      // enable the ADC&#xA;       | ADPS_SETTING;  // clock somewhere near 1 MHz&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As bigjosh explained in comments, the prescaler setting is a trade-off&#xA;between speed and accuracy. I recommend you read the &lt;a href=&quot;http://www.gammon.com.au/adc&quot; rel=&quot;nofollow&quot;&gt;article on the&#xA;Arduino ADC by Nick Gammon&lt;/a&gt;. He did some tests at various speeds&#xA;which showed that you can get decent results with clock speeds up to&#xA;1&amp;nbsp;MHz, then it becomes pretty bad at 2&amp;nbsp;MHz and mostly&#xA;useless beyond. You may want to run the same tests with your particular&#xA;setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Except for the very first conversion, which takes longer, an ADC&#xA;conversion takes 13&amp;nbsp;cycles of the ADC clock. If you run that clock&#xA;at 1&amp;nbsp;MHz, that is 13&amp;nbsp;µs per reading. If you get the readings&#xA;with &lt;code&gt;analogRead()&lt;/code&gt;, you won't get one reading every 13&amp;nbsp;µs, because&#xA;the CPU needs extra time to execute the code you have between successive&#xA;calls of &lt;code&gt;analogRead()&lt;/code&gt;. You can save time by having the CPU and the ADC&#xA;work in parallel, maybe along these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;ADCSRA |= ADSC;     // start the first conversion&#xA;for (int i = 0; i &amp;lt; NB_READINGS; i++) {&#xA;    loop_until_bit_is_clear(ADCSRA, ADSC);  // wait for the ADC&#xA;    uint16_t reading = ADC;     // get the reading&#xA;    ADCSRA |= ADSC;             // start the next conversion&#xA;    process(reading);           // process the reading we have&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you process one reading while the ADC is taking the next one.&#xA;Or you can set the ADC to “free running mode” (where it takes one&#xA;reading after another without ever stopping) and get the readings in an&#xA;interrupt service routine. Whichever method works best depends on your&#xA;particular application: the amount of works your CPU has to do while&#xA;reading the ADC and whether you can afford to do the whole series of&#xA;readings with interrupts disabled.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-08T13:10:08.733" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26121" PostTypeId="2" ParentId="26117" CreationDate="2016-07-08T13:23:15.517" Score="1" Body="&lt;p&gt;&lt;code&gt;__vector_4()&lt;/code&gt; is just another name for &lt;code&gt;PCINT1_vect()&lt;/code&gt;. The error&#xA;message simply means that you have defined that function twice. One&#xA;definition is explicit in the code you are showing to us. I cannot see&#xA;the other definition: obviously you are not showing &lt;strong&gt;all&lt;/strong&gt; of your&#xA;code. Most likely that other definition lies inside some library you are&#xA;using in your program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since you cannot define an ISR twice, you will have to use another PCINT&#xA;which is not already in use. Or you could modify the library and try to&#xA;merge it's &lt;code&gt;PCINT1_vect()&lt;/code&gt; with yours.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BTW, the error message does not come from avrdude, it comes from the&#xA;linker.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-08T13:23:15.517" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26122" PostTypeId="1" AcceptedAnswerId="26124" CreationDate="2016-07-08T14:08:05.327" Score="2" ViewCount="1067" Body="&lt;p&gt;I am trying to setup 20 input switches that can be pressed with hand. I am trying to get the output based on the pattern in which the input switches are pressed with the hand. Based on the pressure and the area of the hand pressing the input switches, there can be multiple switches that can be pressed to display the output pattern at the same time. How can I use Arduino Uno inputs to support these multiple pin reads at the same time?&lt;/p&gt;&#xA;" OwnerUserId="23716" LastActivityDate="2016-07-19T05:25:02.873" Title="Reading Multiple switch inputs" Tags="|input|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26123" PostTypeId="2" ParentId="24933" CreationDate="2016-07-08T14:14:05.870" Score="1" Body="&lt;p&gt;Actually the Arduino Uno dc current per I/O pin is 40mA. When fan is connected directly to Arduino Uno, it cannot withstand, because the fan draws more-than &lt;code&gt;20mA&lt;/code&gt; current. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The driver circuit provides sufficient current to rotate the fan. The &lt;code&gt;TIP 121&lt;/code&gt; can withstand up to &lt;code&gt;3A&lt;/code&gt; current.&lt;/p&gt;&#xA;" OwnerUserId="23717" LastActivityDate="2016-07-08T14:14:05.870" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26124" PostTypeId="2" ParentId="26122" CreationDate="2016-07-08T15:14:08.487" Score="2" Body="&lt;p&gt;You could use a MCP23017 or similar.  Its an IC that provides 16 IO ports via I2C, I think you can have 4 of them so that should be enough for both hands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you could use resistors.  All the buttons are connected to a single analogue port.  The resistors are chosen so that when you press any combination of buttons you will get a unique reading at the port. So if you press button one and get a reading of 100, press 2 and get 150, press 3 and get 200, etc.  So buttons 1+2 give you 250, 2+3 gives you 350 and 1+2+3 gives you 450.  The problem with this is the maths get out of hand very quickly and the IC is &amp;lt; $1.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-08T15:14:08.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26127" PostTypeId="1" AcceptedAnswerId="26130" CreationDate="2016-07-08T17:09:25.290" Score="3" ViewCount="430" Body="&lt;p&gt;I am tracking down the memory usage of an Arduino-like project I am working on (not a real Arduino, but has same microcontroller and it uses the Arduino build environment, version 1.6.8). I have some modules that I am using and placed them in the Libraries directory in my sketch directory:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Encoder&#xA;LiquidCrystal&#xA;OneWire&#xA;TGPages&#xA;TGPro&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now, when I compile a minimal sketch...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;&#xA;void setup()&#xA;{&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...the compiled size is 450 bytes Flash and 9 bytes RAM. So far, so good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here's the weird part: when I include a single header file from anywhere in the Libaries folder, the compiled size increases dramatically.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;#include &quot;pins.h&quot;&#xA;&#xA;void setup()&#xA;{&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;pins.h&quot; is located in the TGPro directory and only contains #defines, not even code or other includes.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;....&#xA;Using library TGPro in folder: C:\Users\User\Project\TG\libraries\TGPro (legacy)&#xA;Using library OneWire in folder: C:\Users\User\Project\TG\libraries\OneWire (legacy)&#xA;Using library Encoder in folder: C:\Users\User\Project\TG\libraries\Encoder (legacy)&#xA;Using library LiquidCrystal in folder: C:\Users\User\Project\TG\libraries\LiquidCrystal (legacy)&#xA;Using library EEPROM at version 2.0 in folder: C:\Users\User\Project\TG\hardware\arduino\avr\libraries\EEPROM &#xA;Using library Wire at version 1.0 in folder: C:\Users\User\Project\TG\hardware\arduino\avr\libraries\Wire &#xA;&#xA;Sketch uses 2,266 bytes (7%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 230 bytes (11%) of dynamic memory, leaving 1,818 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And I'm like: WTF? I'm not even referencing any of the files, still they get pulled in, wasting space. There are a few global, static variables in there which explain the used space and referenced code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, my questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is het normal for Arduino to pull in &lt;em&gt;all&lt;/em&gt; files in the Sketch\Libraries directory, regardless if they are referenced or not? It doesn't seem to do this with the 'core' libraries.&lt;/li&gt;&#xA;&lt;li&gt;How can you prevent this? Suppose I have a large collection of modules that I use in various projects, but not all modules are used all the time. It would be a waste to include code that is never actually used. &lt;/li&gt;&#xA;&lt;li&gt;How can I find out more about the code that is compiled in; I know the linker will leave out unreferenced code, but I want to make sure this is due to the statically defined variables.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23723" LastActivityDate="2016-07-09T12:19:07.543" Title="Single #include pulls in all libraries" Tags="|library|memory-usage|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26128" PostTypeId="1" AcceptedAnswerId="26129" CreationDate="2016-07-08T17:16:00.233" Score="2" ViewCount="2035" Body="&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; The sample rate of my code seems to be lower than what I expect it to be. How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Director's cut:&lt;/strong&gt;&#xA;I am trying to sample audio data and send it via serial. The setup consists of a guitar plugged into an amplifier (about 10x) + low-pass filter (second order, around 1kHz) + voltage divider (centered at 2.5V), that is then connected to and Arduino Uno Rev3. When the Arduino receives a 'cap' command via serial, it enables the interrupt-based function that takes samples and sends them via Serial. With the 10-bit resolution, it gives me a number between 1 and 4 digits. With a baud rate of 115200 and adding 1 byte for the '\n' character, the slowest rate is of 2880 values per second, but most likely around 3.6k values per second (3+1 characters).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I understood (not used to working with timer interrupts), I've set up timer1 so that it doesn't have any prescaling, and it should be running pretty close to 2048Hz. The interrupt sequence reads the data at the analog input and sends it via Serial (for now, to the computer; later, a smartphone via Bluetooth).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To check if it is working, I am copying the data received by the computer, putting it into Matlab and running the &lt;code&gt;sound(data, sampleRate)&lt;/code&gt; function. If I run it with 2048 as &lt;code&gt;sampleRate&lt;/code&gt;, I get a clearly higher pitched sound, which indicates that the sample rate is in fact lower. Testing different values, I found that it sounds close enough around 1900.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I've read, the serial and the timer interrupt work in parallel, and the serial is faster than the capture. Why am I getting this apparently lower sample rate? How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Variables&#xA;const int sampleRate = 2048; // Sampling rate&#xA;const int numSamples = 2048; // Number of Samples&#xA;//volatile int samples[numSamples]; // Data array&#xA;int currentSample = 0;&#xA;boolean capturing = false; // flags if it is in capture mode&#xA;boolean done = false; // flags if the capture is done&#xA;char chrCommand; // holds current character read&#xA;String strCommand; // joins the complete command string&#xA;&#xA;// Functions&#xA;void captureSample();&#xA;void readCommand();&#xA;void executeCommand();&#xA;&#xA;void setup() {&#xA;  /****************&#xA;   * Timer Setup&#xA;   ****************/&#xA;  cli(); // stop interrupts&#xA;  // set timer1 interrupt at 2048Hz&#xA;  TCCR1A = 0; // set the entire TCCR1A register to 0&#xA;  TCCR1B = 0; // set the entire TCCR1B register to 0&#xA;  TCNT1  = 0; // initialize counter value to 0&#xA;  // set compare match register for 2048Hz increments&#xA;  OCR1A = 7811; // = (16*10^6) / (sampleRate) - 1&#xA;  // turn on CTC mode&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // no prescaling&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS10);&#xA;  // enable timer compare interrupt&#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;  sei(); // allow interrupts&#xA;&#xA;  /****************&#xA;   * Serial Setup&#xA;   ****************/&#xA;  Serial.begin(115200);&#xA;&#xA;&#xA;  pinMode(13,OUTPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;  if(!capturing){&#xA;    // Case: waiting for command&#xA;    if(!done){&#xA;      if(Serial.available() &amp;gt; 0){&#xA;        readCommand();&#xA;        executeCommand();&#xA;      }&#xA;    }else{&#xA;      done = false;&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;/************************&#xA; * Function Definitions&#xA; ************************/&#xA;&#xA;// Timer function&#xA;ISR(TIMER1_COMPA_vect){&#xA;  if(capturing){&#xA;    captureSample();&#xA;  }&#xA;}&#xA;&#xA;void captureSample(){&#xA;  //samples[currentSample] = analogRead(0);&#xA;  Serial.println(analogRead(0));&#xA;  ++currentSample %= numSamples;&#xA;  if(currentSample == 0)&#xA;  {&#xA;    done = true;&#xA;    capturing = false;&#xA;  }&#xA;}&#xA;&#xA;void readCommand(){&#xA;  strCommand = &quot;&quot;;&#xA;  while(Serial.available() &amp;gt; 0)&#xA;  {&#xA;    chrCommand = ((byte)Serial.read());&#xA;    if(chrCommand == '\n')&#xA;    {&#xA;      break;&#xA;    } else&#xA;    {&#xA;      strCommand += chrCommand;&#xA;    }&#xA;    delay(1);&#xA;  }&#xA;}&#xA;&#xA;void executeCommand(){&#xA;  // Command cap = capture&#xA;  if(strCommand == &quot;cap&quot;){&#xA;    capturing = true;&#xA;    return;&#xA;  }&#xA;  // Command mov = move&#xA;  if(strCommand == &quot;mov&quot;){&#xA;    // get the motor movement in the following command&#xA;    readCommand();&#xA;    moveMotor();&#xA;    return;&#xA;  }&#xA;  if(strCommand == &quot;clr&quot;){&#xA;    done = false;&#xA;    capturing = false;&#xA;    for(int i = 0; i &amp;lt; 2; ++i){&#xA;      digitalWrite(13,HIGH);&#xA;      delay(50);&#xA;      digitalWrite(13,LOW);&#xA;      delay(50);&#xA;    }&#xA;    return;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23721" LastActivityDate="2016-07-08T18:51:40.317" Title="Audio sampling and serial communication" Tags="|serial|audio|analog-sampling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26129" PostTypeId="2" ParentId="26128" CreationDate="2016-07-08T18:24:04.680" Score="4" Body="&lt;p&gt;You calculation of the data rate is wrong:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;Serial.println()&lt;/code&gt; adds CRLF (i.e. &quot;\r\n&quot;) to terminate the line,&#xA;That's 2 bytes, not one.&lt;/li&gt;&#xA;&lt;li&gt;Each byte is sent by the serial port as one start bit, followed by 8&#xA;data bits, followed by one stop bit. That's 10 bits in terms of&#xA;timing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;In the worst case scenario (value ≥ 1000), you are sending 6&amp;nbsp;bytes,&#xA;or 60&amp;nbsp;bits: the fastest possible rate is 1920&amp;nbsp;samples per&#xA;second. In the arguably most common case (100 ≤ value &amp;lt; 1000), you send&#xA;50&amp;nbsp;bits per sample at up to 2304&amp;nbsp;S/s.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Here are a few optimization tips, just to make sure your&#xA;program is not CPU-bound:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Declare &lt;code&gt;captureSample()&lt;/code&gt; as &lt;code&gt;static&lt;/code&gt;, this way the compiler can&#xA;inline it and save the call overhead.&lt;/li&gt;&#xA;&lt;li&gt;Make &lt;code&gt;currentSample&lt;/code&gt; unsigned, this way the compiler can optimize the&#xA;modulo operation into a bitwise AND.&lt;/li&gt;&#xA;&lt;li&gt;Replace &lt;code&gt;analogRead(0)&lt;/code&gt; with a direct read of the &lt;code&gt;ADC&lt;/code&gt; register, and&#xA;start the next ADC conversion right away. This way you do not have to&#xA;wait for 104&amp;nbsp;µs while the ADC does its work.&lt;/li&gt;&#xA;&lt;li&gt;You may want to move the &lt;code&gt;Serial.println()&lt;/code&gt; out of the ISR, otherwise&#xA;you may be blocking interrupts for too long if the serial port cannot&#xA;cope with the sampling rate.&lt;/li&gt;&#xA;&lt;li&gt;Make some kind of binary protocol instead of using plain ASCII.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You may also trigger the ADC directly from a timer instead of going&#xA;through the timer ISR (see the datasheet for details). You would then&#xA;use &lt;code&gt;ISR(ADC_vect)&lt;/code&gt; to retrieve the ADC result. This way you get a very&#xA;steady (hardware controlled) sampling rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More about the binary protocol&lt;/strong&gt;: you could send only two bytes per&#xA;sample and remain ASCII-compatible (which is often desirable) by using&#xA;32 printable characters to represent 5 bits. This is the same idea used&#xA;in base64, but simplified to use consecutive characters:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;uint8_t high_5_bits = sample &amp;gt;&amp;gt; 5;&#xA;uint8_t low_5_bits  = sample &amp;amp; 0x1f;&#xA;Serial.write('@' + high_5_bits);&#xA;Serial.write('@' + low_5_bits);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This gives a stream of characters in the range &lt;code&gt;@A-Z[\]^_&lt;/code&gt;. Then your&#xA;maximum sampling rate is 5760&amp;nbsp;S/s.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-07-08T18:51:40.317" LastActivityDate="2016-07-08T18:51:40.317" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26130" PostTypeId="2" ParentId="26127" CreationDate="2016-07-08T19:05:55.580" Score="1" Body="&lt;p&gt;What you are experiencing is due to the fact that your use case does not match with the Arduino foreseen use cases of &quot;importing a library&quot;.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you want the use case &quot;include a file&quot; and you get &quot;import a library&quot;. The use case &quot;import file&quot; is simply not foreseen in the Arduino IDE.&#xA;Because the Arduino IDE add the library to your code it also adds the source doe files to your code. When these source codes contain global variables (which is very common and not a bad practise in embedded world) these will be part of your final code. As such your sketch will increase size even if you do not use these global variables.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To answer questions&lt;br&gt;&#xA;1) yes it is normal because the use case &quot;include file&quot; is translated into &quot;include library&quot; in .ino files in the Arduino IDE.&lt;br&gt;&#xA;Why this does not happen for the core? The core is first linked into a archive and then linked to the sketch. This leaves the linker more options to remove stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) I think the easiest is to copy the pins.h file in your sketch work folder (and you probably will need to restart the Arduino IDE).&lt;br&gt;&#xA;Another option is to go for a real IDE like the arduino eclipse plugin called &lt;a href=&quot;http://sloeber.io&quot; rel=&quot;nofollow&quot;&gt;sloeber&lt;/a&gt; (which I develop)&lt;br&gt;&#xA;In sloeber you could link to the pins.h file instead of copying. You could also reference the pins.h with a (partial/full) path avoinding the library include.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) All global variables, static and similar stuff in the source code of the &quot;imported libraries&quot;&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="18478" LastEditDate="2016-07-09T12:19:07.543" LastActivityDate="2016-07-09T12:19:07.543" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26132" PostTypeId="1" CreationDate="2016-07-08T21:03:59.003" Score="1" ViewCount="43632" Body="&lt;p&gt;I want to send my Arduino's sensor data to a MySQL database, using XAMPP and phpMyAdmin. I have been using an ESP8266 for the wifi connection. But I am unable to send the value. And actually I have to send four values, but for the time being I am sending only one value. So also please tell how to send multiple values. I have written the PHP file and saved in to Apache's htdocs.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;WiFiEsp.h&amp;gt;&#xA;#include &amp;lt;WiFiEspClient.h&amp;gt;&#xA;#include &amp;lt;WiFiEspUdp.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;PubSubClient.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;IPAddress ip(192,168,8,1);&#xA;char ssid[] = &quot;ZONG MBB-E8372-B67D&quot;; // your network SSID (name)&#xA;char pass[] = &quot;08522547&quot;; // your network password&#xA;int status = WL_IDLE_STATUS; // the Wifi radio's status&#xA;int photocellPin = 4; // Analog input pin on Arduino we connected the SIG pin from sensor&#xA;int photocellReading; // Here we will place our reading&#xA;char server[] =  &quot;192.168.8.1&quot;;&#xA;// Initialize the Ethernet client object&#xA;WiFiEspClient espclient;&#xA;SoftwareSerial soft(2,3); // RX, TX&#xA;&#xA;void setup() {&#xA;  // initialize serial for debugging&#xA;  Serial.begin(115200);&#xA;  // initialize serial for ESP module&#xA;  soft.begin(115200);&#xA;  // initialize ESP module&#xA;  WiFi.init(&amp;amp;soft);&#xA;  // check for the presence of the shield&#xA;  if (WiFi.status() == WL_NO_SHIELD) {&#xA;    Serial.println(&quot;WiFi shield not present&quot;);&#xA;    // don't continue&#xA;    while (true);&#xA;  }&#xA;  // attempt to connect to WiFi network&#xA;  while ( status != WL_CONNECTED) {&#xA;    Serial.print(&quot;Attempting to connect to WPA SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    // Connect to WPA/WPA2 network&#xA;    status = WiFi.begin(ssid, pass);&#xA;  }&#xA;  // you're connected now, so print out the data&#xA;  Serial.println(&quot;You're connected to the network&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  photocellReading = analogRead(photocellPin);&#xA;  // Fill the sensorReading with the information from sensor&#xA;  // Connect to the server (your computer or web page)&#xA;  if (espclient.connect(server, 80)) {&#xA;    espclient.println(&quot;GET /write_data7.php?&quot;); // This&#xA;    espclient.println(&quot;value=&quot;); // This&#xA;    espclient.println(photocellReading);&#xA;    // And this is what we did in the testing section above.&#xA;    // We are making a GET request just like we would from our browser&#xA;    // but now with live data from the sensor&#xA;    espclient.println(&quot; HTTP/1.1&quot;); // Part of the GET request&#xA;    espclient.println(&quot;Host: 192.168.8.1&quot;);&#xA;    // IMPORTANT: If you are using XAMPP you will have&#xA;    //to find out the IP address of your computer and put it here&#xA;    // (it is explained in previous article). If you have a web page,&#xA;    // enter its address (ie.Host: &quot;www.yourwebpage.com&quot;)&#xA;    espclient.println(&quot;Connection: close&quot;);&#xA;    // Part of the GET request telling the server&#xA;    // that we are over transmitting the message&#xA;    espclient.println(); // Empty line&#xA;    espclient.println(); // Empty line&#xA;    espclient.stop();    // Closing connection to server&#xA;  } else {&#xA;    // If Arduino can't connect to the server (your computer or web page)&#xA;    Serial.println(&quot;--&amp;gt; connection failed\n&quot;);&#xA;  }&#xA;&#xA;  // Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.&#xA;  delay(10000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Following is the PHP code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;//connecting to the database&#xA;define('DB_HOST', 'localhost');&#xA;define('DB_NAME', 'connected_car_1');&#xA;define('DB_USER','Maryam1');&#xA;define('DB_PASSWORD','telecom1213');&#xA;&#xA;$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die(&quot;Failed to connect to MySQL: &quot; . mysql_error());&#xA;$db=mysql_select_db(DB_NAME,$con) or die(&quot;Failed to connect to MySQL: &quot; . mysql_error());&#xA;&#xA;$sql = &quot;INSERT INTO connected_car_1.sensor (value) VALUES ('&quot;.$_GET[&quot;value&quot;].&quot;')&quot;;&#xA;// Execute SQL statement&#xA;mysql_query($sql,$con);&#xA;mysql_close($con);&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is my serial monitor output:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NtfTt.pnghttps://i.stack.imgur.com/NtfTt.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NtfTt.pnghttps://i.stack.imgur.com/NtfTt.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am very new to coding in Arduino as well as PHP and databases. So kindly tell me what I am doing wrong. And do I have to provide the IP address of the server, ie. 127.0.0.1? If yes, then where? &lt;/p&gt;&#xA;" OwnerUserId="21174" LastEditorDisplayName="user31481" LastEditDate="2017-10-30T14:13:09.203" LastActivityDate="2020-12-14T05:06:40.670" Title="Sending Arduino data to MySQL using phpMyAdmin and XAMPP using Windows10" Tags="|arduino-uno|esp8266|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="26133" PostTypeId="2" ParentId="26016" CreationDate="2016-07-08T21:51:51.480" Score="1" Body="&lt;p&gt;Calling the &lt;code&gt;point()&lt;/code&gt; method only updates a flag; you see the effect the next time you try to display a number. You can use something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void show_time(DateTime &amp;amp;t){&#xA;  tm1637.display(0,t.hour()/10);&#xA;  tm1637.display(1,t.hour()%10);&#xA;  tm1637.display(2,t.minute()/10);&#xA;  tm1637.display(3,t.minute()%10);&#xA;}&#xA;&#xA;void loop() {&#xA;  DateTime now = RTC.now();&#xA;&#xA;  tm1637.point(POINT_ON);&#xA;  show_time(now);  // changes take effect here&#xA;  delay(500);&#xA;  tm1637.point(POINT_OFF);&#xA;  show_time(now);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-07-08T21:51:51.480" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26134" PostTypeId="2" ParentId="20467" CreationDate="2016-07-08T22:11:32.057" Score="2" Body="&lt;p&gt;Look at page 35 of winbond datasheet.&#xA;If the LED is blinking 7 times either the chip is in isp mode or in an unstated mode. This can happen after power off during erase function.&#xA;I held erase button for about 20 seconds and after that I was able to record messages.&lt;/p&gt;&#xA;" OwnerUserId="23728" LastActivityDate="2016-07-08T22:11:32.057" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26135" PostTypeId="1" AcceptedAnswerId="26141" CreationDate="2016-07-09T02:06:06.037" Score="0" ViewCount="9228" Body="&lt;p&gt;I'm trying to get 2 devices (camera and sd card)to work on the SPI interface with an Arduino DUE.  I'm having trouble finding example code online showing how to communicate with multiple slaves on the DUE as I know it is slightly different than with the UNO.&lt;br&gt;&#xA;Questions I have include:&#xA;How do you indicate you want to talk to a slave on pin 4? Instead of digitalWrite(4,LOW) do you call SPI.begin(4)? etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone post some example code?&lt;/p&gt;&#xA;" OwnerUserId="21351" LastEditorUserId="21351" LastEditDate="2016-07-09T02:19:34.087" LastActivityDate="2018-05-25T07:53:48.787" Title="Code example SPI multiple slaves Arduino DUE" Tags="|arduino-due|spi|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26137" PostTypeId="1" AcceptedAnswerId="26138" CreationDate="2016-07-08T23:16:40.470" Score="1" ViewCount="74" Body="&lt;p&gt;I bought a ATmega328 microcontroller and burn the bootloader. Now I want to upload code directly from pc to the microcontroller on bread board. I have max232 ic for the communication but I recently knew that I need a serial port rather usb to connect max232 to pc. There are many usb to serial converter available on the market but can I make my own? One more thing is there any other way burn program from arduino ide to microcontroller via USB on bread board without having the arduino board. Or can I burn program to microcontroller on the bread board from arduino board without removing the on board ic.&lt;/p&gt;&#xA;" OwnerUserId="23749" OwnerDisplayName="Siddhartha Sadhukhan" LastEditorUserId="25788" LastEditDate="2016-09-15T23:33:04.523" LastActivityDate="2016-09-15T23:33:04.523" Title="Complete Bread board arduino" Tags="|avr|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26138" PostTypeId="2" ParentId="26137" CreationDate="2016-07-09T00:06:45.740" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;There are many usb to serial converter available on the market but can I make my own?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but if you need to ask how then you're not ready to undertake the task.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;One more thing is there any other way burn program from arduino ide to microcontroller via usb on bread board without having the arduino board.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. The IDE doesn't care how you connect to the MCU, only that it has the appropriate bootloader for the programming method.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Or can I burn program to microcontroller on the bread board from arduino board without removing the on board ic.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;ArduinoISP&lt;/a&gt; will let you use an existing Arduino as an AVR ISP programmer. ISP does not require a bootloader, nor does it require a serial (UART) connection.&lt;/p&gt;&#xA;" OwnerUserId="368" OwnerDisplayName="Ignacio Vazquez-Abrams" LastActivityDate="2016-07-09T00:06:45.740" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26139" PostTypeId="2" ParentId="26094" CreationDate="2016-07-09T04:49:17.693" Score="0" Body="&lt;p&gt;You can not have 'const' prefixed the 'text' variable as it then become 'read-only'.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    char text[32];&#xA;    int a = 60;&#xA;    sprintf(text, &quot;Number %d&quot;, a);&#xA;    radio.write(&amp;amp;text, sizeof(text));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23733" LastActivityDate="2016-07-09T04:49:17.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26141" PostTypeId="2" ParentId="26135" CreationDate="2016-07-09T10:07:20.390" Score="2" Body="&lt;p&gt;Everything you need is given here - you just need to know how to put it together:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/DueExtendedSPI&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/DueExtendedSPI&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There are variants of all the major methods that take an extra parameter - that parameter is the first parameter in the parameter list and defines the SS Pin to use for that function.  That includes the &lt;code&gt;.transfer()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use it you have to &lt;code&gt;begin()&lt;/code&gt; all the pins you want to use SPI with. Then you can use &lt;code&gt;.transfer()&lt;/code&gt; with those pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    SPI.begin(10);&#xA;    SPI.begin(4);&#xA;}&#xA;&#xA;void loop() {&#xA;    // Receive using pin 10 as SS&#xA;    byte byteFromTen = SPI.transfer(10, 0x00);&#xA;    // Transmit 123 using pin 10 as SS&#xA;    SPI.transfer(10, 123);&#xA;    // Both directions:&#xA;    byte otherByteFromTen = SPI.transfer(10, 123);&#xA;&#xA;    // Receive using pin 4 as SS&#xA;    byte byteFromFour = SPI.transfer(4, 0x00);&#xA;    // Transmit 123 using pin 4 as SS&#xA;    SPI.transfer(4, 123);&#xA;    // Both directions:&#xA;    byte otherByteFromTen = SPI.transfer(4, 123);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Doing multi-byte transfers is slightly more complex since you don't have control over the SS pin, so you have to use yet another version of the &lt;code&gt;transfer()&lt;/code&gt; function that tells it to &quot;continue&quot; the transaction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Receiving 3 bytes using pin 4:&#xA;byte firstByte = SPI.transfer(4, 0x00, SPI_CONTINUE);&#xA;byte secondByte = SPI.transfer(4, 0x00, SPI_CONTINUE);&#xA;byte thirdByte = SPI.transfer(4, 0x00);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, mixing reading and writing is pretty much the same as usual. For instance, to read the port A values from an MCP23S17 would look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SPI.transfer(4, 0x41, SPI_CONTINUE); // Address 0, read bit set&#xA;SPI.transfer(4, 0x12, SPI_CONTINUE); // Select register 0x12 (GPIOA)&#xA;byte porta = SPI.transfer(4, 0x00);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;SPI_CONTINUE&lt;/code&gt; tells the SPI system to keep the SS pin LOW. It is only then raised once it gets a &lt;code&gt;.transfer()&lt;/code&gt; without the &lt;code&gt;SPI_CONTINUE&lt;/code&gt;. This is the same as the traditional way of using &lt;code&gt;digitalWrite()&lt;/code&gt; to lower SS before the first transfer and raise it after the last transfer.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-09T10:07:20.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26143" PostTypeId="1" CreationDate="2016-07-09T11:43:10.517" Score="6" ViewCount="2895" Body="&lt;p&gt;I want to launch a communication between two Arduinos, in which case the first Arduino &lt;em&gt;(S)&lt;/em&gt; sends data to the second one &lt;em&gt;(R)&lt;/em&gt;. The type of the data is mixed, consisting of integers, longs, floats and maybe some text. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{125, 1250, 12500, 125000, 1.25, 12.5, 125.0, &quot;some text&quot;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I thought about converting each one value to string, adding up all strings to a big one, and send the final string with  &lt;code&gt;Serial.print(Big_string)&lt;/code&gt;.  In that case I reckon that it would be difficult for the Receiver to extract the string to the exact substrings and convert them to real values. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A second thought was to convert all values to bytes and create a byte &lt;em&gt;(or char)&lt;/em&gt; array, but each value would be limited to 0-255 &lt;em&gt;(let alone floats and text)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A third thought was to convert them to word type &lt;em&gt;(let alone the text)&lt;/em&gt;, but I think that &lt;code&gt;Serial.print( )&lt;/code&gt; sends only bytes, not words.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In any case, which is the best way to send mixed data over serial?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-07-09T16:16:21.867" Title="send mixed data over serial" Tags="|serial|" AnswerCount="4" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26144" PostTypeId="1" CreationDate="2016-07-09T12:24:22.767" Score="3" ViewCount="1796" Body="&lt;p&gt;I would like to connect an Arduino Uno and an ESP 01 module. I use the Arduino IDE and I tried to test communication via serial monitor. I get the &quot;ready&quot; message from the ESP 01, but I am not able to issue AT commands from the serial monitor. It only displays random characters on the console. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that no newline character is issued, because if I try to insert commands, they are inserted next to previous characters. I use &quot;Both NL &amp;amp; CR&quot; and 115200 baud settings in Arduino IDE. I tried 9600 baud too, but then the text is unreadable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used the following pins on my ESP-01:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vcc -&amp;gt; 3,3V&#xA;Gnd -&amp;gt; Gnd&#xA;Rx  -&amp;gt; Tx(pin 0) of my Arduino, used voltage divider to make it 3.3V.&#xA;Tx  -&amp;gt; Rx(pin 1) of Arduino&#xA;CH_PD -&amp;gt; 3.3V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please see serial monitor screenshot:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/boUq7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/boUq7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT: PROBLEM RESOLVED:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Arduino is connected to my PC via USB, so I changed pins for communication with the ESP by SoftwareSerial to pins 10 and 11. Now it works. Thank you.&lt;/p&gt;&#xA;" OwnerUserId="23739" LastEditorUserId="1576" LastEditDate="2017-09-05T19:00:23.123" LastActivityDate="2017-11-04T19:37:54.810" Title="Arduino Uno and ESP01: can't issue AT commands [Solved]" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26146" PostTypeId="2" ParentId="25938" CreationDate="2016-07-09T13:20:15.543" Score="2" Body="&lt;p&gt;There appears to be several DHT sensor Arduino libraries available:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/niesteszeck/idDHT11&quot; rel=&quot;nofollow&quot;&gt;niesteszeck/idDHT11&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/TinyDHT&quot; rel=&quot;nofollow&quot;&gt;adafruit/TinyDHT&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;adafruit/DHT-sensor-library&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You might try an alternate library to see if that solves your current problem.  Note, some if not all of these libraries need to know which DHT model you are using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before going through the DHT and OneWire source code line by line looking for conflicts, try to narrow down what is causing the problem:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Try only instantiating the OneWire class and skip calling the read method within the class.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If this works, then the conflict likely resides in the OneWire read method and not in the OneWire initialization code (that is, the OneWire's Constructor).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Calling the DHT read method multiple times consecutively to see if the problem resolves it self.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Actually, you have done this and exposed a curious patter of good-bad-bad-good-bad-bad... which is worth looking into.  The point here is that if only the 1st call to the DHT read method after a call the the OneWire read method was bad, then there might be a setup problem in the DHT read method.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;Call the DHT Destructor, the DHT Constuctor then make the call to the DHT read method every time you read the DHT sensor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This is a test case only and an extreme measure.  What you are doing here is re-initializing the DHT library (driver) every time you use it.  If this works it points to an initialization problem where the DHT library is initialization something which should probably be re-initialized again inside the DHT read method.  As the OneWire library is using the same &quot;something&quot; (resource).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last thing, the OneWire example I looked at here:&#xA;&lt;a href=&quot;https://github.com/PaulStoffregen/OneWire/tree/master/examples&quot; rel=&quot;nofollow&quot;&gt;PaulStoffregen/OneWire&lt;/a&gt;&#xA;...did not use the DallasTemperature library.  I doubt this will make a difference, but it is usually best to keep your code simple and avoid unnecessary complexities.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As pointed out in the comments, it turns out the DHT11 only takes new readings every few seconds.  Guessing, the DHT11 library you are using either knowingly returns an unreasonable value of -999.0 until this time passes.  Or is returning exactly what the DHT11 reports which, again, is an unreasonable value of -999.0.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In &lt;a href=&quot;https://github.com/adafruit/DHT-sensor-library&quot; rel=&quot;nofollow&quot;&gt;this DHT11 library&lt;/a&gt;, there is code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean DHT::read(bool force) {&#xA;  // Check if sensor was read less than two seconds ago and return early&#xA;  // to use last reading.&#xA;  uint32_t currenttime = millis();&#xA;  if (!force &amp;amp;&amp;amp; ((currenttime - _lastreadtime) &amp;lt; 2000)) {&#xA;    return _lastresult; // return last correct measurement&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;...which returns the last good value for 2 seconds after a DHT11 &quot;real reading&quot; should the library user call upon it faster then the DHT11 can respond.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-10T15:02:52.203" LastActivityDate="2016-07-10T15:02:52.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26147" PostTypeId="1" AcceptedAnswerId="32929" CreationDate="2016-07-09T13:31:21.787" Score="0" ViewCount="1142" Body="&lt;p&gt;Are there any oxygen sensors that measure up to 50%?.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As I understand, there are sensors that measure only in range 0-30%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to increase the threshold of sensitivity of the sensor?&lt;/p&gt;&#xA;" OwnerUserId="23741" LastEditorUserId="28033" LastEditDate="2017-01-03T03:01:00.503" LastActivityDate="2017-01-03T03:04:05.693" Title="Oxygen sensor up to 50%" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26148" PostTypeId="1" AcceptedAnswerId="26153" CreationDate="2016-07-09T13:40:06.840" Score="0" ViewCount="280" Body="&lt;p&gt;Many of the receiver modules (MX-05V) working with the Virtual Wire library (&lt;em&gt;I would like to add a link here but it requires 10 reputation, so I'll do that later)&lt;/em&gt; have two data pins. However only one of them is used in the examples I have seen so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This picture shows a transmitter (top left) and a receiver (bottom right). Apparently the receiver has four pins - two of them are data pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2Dj21.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Dj21.jpg&quot; alt=&quot;Transmitter and receiver module&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.simsso.de/?type=arduino/mx-05v-mx-fs-03v&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Image source&quot;&gt;Image source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is the purpose of the second data pin on the receiver module and how to use it?&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="23742" LastEditorUserId="23742" LastEditDate="2016-07-09T15:43:15.043" LastActivityDate="2016-07-09T15:48:56.060" Title="Receiver Module Second Data Pin" Tags="|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26150" PostTypeId="2" ParentId="26143" CreationDate="2016-07-09T13:58:47.730" Score="4" Body="&lt;p&gt;I think the easiest way to solve your problem is using a separator and transmit the array values one after the other. That means having a &lt;code&gt;for&lt;/code&gt; loop and in every iteration sending one value of the array with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;Serial.println(array[i])&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function will &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;convert numbers into Strings so you will get &quot;125&quot;, &quot;1250&quot;, ...&lt;/li&gt;&#xA;&lt;li&gt;append a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n')&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the receiver side you can simply wait for &lt;code&gt;Serial.read()&lt;/code&gt; to equal the number &lt;code&gt;13&lt;/code&gt; and (immediately afterwards) &lt;code&gt;10&lt;/code&gt; and split the messages there. That works unless your transmitted strings contain new lines.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The disadvantage is, that numbers are of course transmitted in an &lt;em&gt;unefficient&lt;/em&gt; way. If you want to transmit them as &lt;em&gt;real numbers&lt;/em&gt; instead of strings you have to write your own protocol. &lt;a href=&quot;https://youtu.be/h3OevEdl674&quot; rel=&quot;nofollow&quot; title=&quot;Wireless Module Multiple Receivers&quot;&gt;This video &quot;Wireless Module Multiple Receivers&quot; goes into that direction, it's using a fixed packet length but it gives an idea of how such a thing works.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23742" LastActivityDate="2016-07-09T13:58:47.730" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26151" PostTypeId="2" ParentId="26143" CreationDate="2016-07-09T13:59:25.857" Score="1" Body="&lt;p&gt;If your primary concern is transmission speed, you might consider turning everything into bytes and reversing the process at the other end.  If speed is not important, you can use sprintf() to create a character string and sscanf() to parse out the character string at the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turning everything into bytes is a very custom / specific approach.  A character would turn into 1 byte, an integer into 2 bytes, ect.  You would have to write custom code to encode this and remember to write code at the other end to do exactly the reverse process.  The advantage is that you would only be sending your data and no other information.  But this approach is not vary flexible.  If you were able to fit your data into 1 byte then suddenly needed 2 bytes (for example, a value once always less than 255 was now 300), you would have to re-write your code at both ends of the connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turning everything into a string with sprintf() is very similar to printing out all your data.  You will be including extra characters like commas and / or space for delineation. At the other end sscanf() is used to parse out the character string.  At both ends, if done properly, all string assembly and parsing should be done by only these 2 calls.  And some issues are taken care of automatically.  For instance, the number 100 is 3 characters long and the number 10 is 2 character long.  But the sprintf() and sscanf() calls automatically compensate for these (reasonable) variations and continue to work as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;FYI: Even though sscanf() is available for the Arduino, it is not clear to me if it is well supported.  You might try testing (create and parse a string in the same sketch) what you want to send / receive before actually committing to this method.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-09T14:12:13.653" LastActivityDate="2016-07-09T14:12:13.653" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26152" PostTypeId="2" ParentId="26144" CreationDate="2016-07-09T14:13:02.857" Score="0" Body="&lt;p&gt;It could be the case, that the &lt;strong&gt;Arduino power supply is insufficient&lt;/strong&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;[...] note that the Arduino 3.3V regulated output (50 mA max) can't drive the current requested by the ESP (Up to 200 mA). Some tutorials on the Internet use the Arduino 3.3V to power the ESP, but it didn't worked for me. I'm using an external power supply (An old 5V Android charger).&quot;&lt;a href=&quot;http://dalpix.com/blog/connecting-your-arduino-wifi-esp-8266-module&quot; rel=&quot;nofollow&quot; title=&quot;Source&quot;&gt;Source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Possible&lt;/em&gt;, that the power consumption was within range when the readable text was printed and too high when all the unreadable stuff was sent.&lt;/p&gt;&#xA;" OwnerUserId="23742" LastActivityDate="2016-07-09T14:13:02.857" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26153" PostTypeId="2" ParentId="26148" CreationDate="2016-07-09T15:48:56.060" Score="0" Body="&lt;p&gt;I would expect only one data line output from the receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks like the manufacturer might have just connected the 2 data pins together. You could try using either pin to confirm that the two data output pins are simply connected together. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dGkCe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dGkCe.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-07-09T15:48:56.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26154" PostTypeId="2" ParentId="26143" CreationDate="2016-07-09T16:06:51.740" Score="2" Body="&lt;p&gt;If you want to communicate between 2 arduino's with similar cpu (for instance uno and mega) I would go for binary data in a struct.&#xA;When using a struct you can not use the String class but you can use a char array.&#xA;Consider this struct as example&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct SerialDataPacket&#xA;{&#xA;        int someIntegerData;&#xA;        long someLongData;&#xA;        int someMoreIntegerData;&#xA;        char aString[20];&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can send this struct as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String myString;&#xA;SerialDataPacket transmissionPacket;&#xA;transmissionPacket.someIntegerData=1;&#xA;transmissionPacket.someLongData=millis();&#xA;transmissionPacket.someMoreIntegerData=2;&#xA;strncpy(transmissionPacket.aString,myString.c_str(),min(20,myString.length()));&#xA;Serial.write((uint8_t *) &amp;amp;transmissionPacket, (uint16_t) sizeof(SerialDataPacket));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;you can receive the struct at the other side as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.readBytes((uint8_t *) &amp;amp;transmissionPacket, (uint16_t) sizeof(SerialDataPacket));&#xA;myString=transmissionPacket.aString;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Again this method will only work if you have possessors with the same memory byte order. If the processors have a different bit (8 16 32 bit) you lust use processor independent types for it to work.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-07-09T16:06:51.740" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26155" PostTypeId="2" ParentId="26143" CreationDate="2016-07-09T16:16:21.867" Score="3" Body="&lt;p&gt;I have a library that does exactly what you want. It can also work with RS-485 and RS-422 multi-drop networks.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/ICSC&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/ICSC&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can even get it communicating with a Linux computer (such as a Pi or BeagleBone Black) with the Linux library:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/MajenkoLibraries/icsc-linux&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/icsc-linux&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You can use it to send data of any kind between nodes and trigger specific functions to be executed (like RPC) at the remote end.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-09T16:16:21.867" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26156" PostTypeId="2" ParentId="25440" CreationDate="2016-07-09T16:22:31.853" Score="0" Body="&lt;p&gt;I have done similar code for our car project dash display&lt;/p&gt;&#xA;&#xA;&lt;p&gt;you're looking for something like &lt;a href=&quot;https://github.com/EV-Project/DashBridge/blob/master/DashBridge.ino&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; on your Arduino side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;A&quot;);  //a token to indicate the message payload&#xA;  Serial.print(avgRPM);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;B&quot;);  //a token to indicate the message payload&#xA;  Serial.print(avgVoltage);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;C&quot;);  //a token to indicate the message payload&#xA;  Serial.print(avgCurrent);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;D&quot;);  //a token to indicate the message payload&#xA;  Serial.print(avgThrottle);&#xA;  Serial.println(&quot;&quot;);&#xA;&#xA;  Serial.print(&quot;U*&quot;); //A header&#xA;  Serial.print(&quot;E&quot;);  //a token to indicate the message payload&#xA;  Serial.print(avgBrake);&#xA;  Serial.println(&quot;&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and something like &lt;a href=&quot;https://github.com/EV-Project/DashDisplay/blob/master/DashDisplay.pde&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; on processing side:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (port.available() &amp;gt; 0) {&#xA;    data = port.readStringUntil('\n');&#xA;  }&#xA;  String payload = &quot;&quot;;&#xA;  if (data != &quot;&quot;){&#xA;    int offset = data.indexOf(&quot;U*&quot;); //this is our Header (0x552A)&#xA;    if(offset&amp;gt;=0){&#xA;      payload = data.substring(offset+3, data.indexOf('\n'));&#xA;      switch(data.substring(offset+2, offset+3)){&#xA;        case &quot;A&quot;:&#xA;          RPM = payload;&#xA;          break;&#xA;        case &quot;B&quot;:&#xA;          voltage = payload;&#xA;          break;&#xA;        case &quot;C&quot;:&#xA;          current = payload;&#xA;          break;&#xA;        case &quot;D&quot;:&#xA;          throttle = payload;&#xA;          break;&#xA;        case &quot;E&quot;:&#xA;          brake = payload;&#xA;          break;&#xA;        case &quot;F&quot;:&#xA;          telemBits = payload;&#xA;          break;&#xA;        default:&#xA;          //packet not recognised&#xA;      }&#xA;    }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20821" LastActivityDate="2016-07-09T16:22:31.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26157" PostTypeId="1" AcceptedAnswerId="26161" CreationDate="2016-07-09T16:59:02.123" Score="0" ViewCount="50" Body="&lt;p&gt;I'm trying to test my &lt;code&gt;analog&lt;/code&gt; signal before I send it to an actual &lt;code&gt;analog&lt;/code&gt; device. I've written some code and considering the &lt;code&gt;analog&lt;/code&gt; square I have expected to see a &lt;code&gt;digital&lt;/code&gt; &lt;strong&gt;ON&lt;/strong&gt; &lt;em&gt;or&lt;/em&gt; &lt;strong&gt;OFF&lt;/strong&gt; during a single &lt;code&gt;duty cycle&lt;/code&gt; but I'm either seeing all &lt;strong&gt;OFF&lt;/strong&gt; for &lt;code&gt;analog&lt;/code&gt; values 0-127 and all &lt;strong&gt;ON&lt;/strong&gt; for values 128-255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My expectation is that I would see 51 &lt;strong&gt;ON&lt;/strong&gt; and 49 &lt;strong&gt;OFF&lt;/strong&gt; thus getting a value closer to 128 of 255.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What am I missing? Is this even possible?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int OUTPUT_PIN = 2; // digital 2 (PWM)&#xA;int INPUT_PIN = A0; // analog 0&#xA;&#xA;void setup() {&#xA;  pinMode(OUTPUT_PIN, OUTPUT);&#xA;  pinMode(INPUT_PIN, INPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  analogWrite(OUTPUT_PIN, 128);&#xA;&#xA;  float j = 0;&#xA;  for(int i = 0; i &amp;lt; 100; ++i) { // get 100 reads per duty cycle&#xA;    float v;&#xA;    v = digitalRead( INPUT_PIN );&#xA;    if(v &amp;gt;= 1) Serial.println(&quot;ON&quot;);&#xA;    if(v &amp;lt;= 0) Serial.println(&quot;OFF&quot;);&#xA;    j += v;&#xA;&#xA;    delay(12); // trying to match the duty cycle&#xA;  }&#xA;  j /= 100; // average out the 100 reads&#xA;&#xA;  Serial.println(j);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-07-09T18:53:52.910" Title="Trouble reading analog (PWM)" Tags="|pwm|digital-analog-conversion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26158" PostTypeId="1" AcceptedAnswerId="26431" CreationDate="2016-07-09T17:41:18.007" Score="0" ViewCount="99" Body="&lt;p&gt;I've connected two stepper through two uln2003 chip. And wrote a small class to control them.&#xA;The class works perfectly and I'm able to control the steppers (rotate the CW and CCW).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main code looks like this : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;StepperControl.h&quot;&#xA;&#xA;StepperControl myStepperControls[2];&#xA;&#xA;void setup() {&#xA;    delay(1000);&#xA;    myStepperControls[0].init(6,5,4,3);&#xA;    myStepperControls[1].init(11,10,9,8);&#xA;&#xA;    delay(1000);&#xA;    for (int i = 0; i &amp;lt; 2; i++)&#xA;    {&#xA;        myStepperControls[i].DelayBetweenSteps = 1200;&#xA;        myStepperControls[i].StepCCWDegree(90);&#xA;        myStepperControls[i].StepCWDegree(51);&#xA;    }&#xA;}&#xA;int moveNumber = 0;&#xA;void loop(){&#xA;    int stepperNumber = moveNumber / 2;&#xA;    bool cw = ((moveNumber % 2)  == 0);&#xA;    moveNumber = (moveNumber + 1) % 4;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see I:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Init both instances of the class to different pins.&lt;/li&gt;&#xA;&lt;li&gt;Set the Delay between the steps (in microseconds).&lt;/li&gt;&#xA;&lt;li&gt;Rotate &lt;code&gt;myStepperControls[0]&lt;/code&gt; counter clock wise and then clock wise.&lt;/li&gt;&#xA;&lt;li&gt;Same for &lt;code&gt;myStepperControls[1]&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This doesn't work correctly, one of the motors doesn't move clock wise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is not always the same motor !! For the last hour the problem appeared only in &lt;code&gt;myStepperControls[0]&lt;/code&gt;, now it is only in &lt;code&gt;myStepperControls[1]&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm 100% sure it is not a wiring/electrical problem because: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If I'll delete the content of the loop (which runs after setup) it will fix the problem.&lt;/li&gt;&#xA;&lt;li&gt;If I'll make the delay between steps 2000 it will fix the problems.&lt;/li&gt;&#xA;&lt;li&gt;As I've mentioned the problem was only in &lt;code&gt;myStepperControls[0]&lt;/code&gt; for an hour, in that hour i switch the pins of the motors and still the motor that was connected to &lt;code&gt;myStepperControls[0]&lt;/code&gt; was not able to rotate CW.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Any suggestions to how to investigate the problem will be appriciated&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my library code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// StepperControl.h&#xA;&#xA;#ifndef _STEPPERCONTROL_h&#xA;#define _STEPPERCONTROL_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;    #include &quot;arduino.h&quot;&#xA;#else&#xA;    #include &quot;WProgram.h&quot;&#xA;#endif&#xA;&#xA;class StepperControl&#xA;{&#xA; public:&#xA;    StepperControl();&#xA;    void init(byte blue, byte pink, byte yellow, byte orange);&#xA;    void StepCW(int steps);&#xA;    void StepCCW(int steps);&#xA;    void StepCWDegree(float degrees);&#xA;    void StepCCWDegree(float degrees);&#xA;    const int StepsPerFullRotation = 4076;&#xA;    int DelayBetweenSteps;&#xA; private:&#xA;&#xA;    void setPinsState(byte step);&#xA;&#xA;    byte m_currentState;&#xA;    byte m_pinValuelookup[9];&#xA;&#xA;    byte m_bluePin; // = 11;    // Blue   - 28BYJ48 pin 1&#xA;    byte m_pinkPin; // = 10;    // Pink   - 28BYJ48 pin 2&#xA;    byte m_yellowPin; // = 9;    // Yellow - 28BYJ48 pin 3&#xA;    byte m_orangePin; // = 8;    // Orange - 28BYJ48 pin 4&#xA;                            // Red    - 28BYJ48 pin 5 (VCC)&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;here is the cpp file : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;StepperControl.h&quot;&#xA;&#xA;StepperControl::StepperControl() : m_pinValuelookup{B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001, B00000}, DelayBetweenSteps(1100), m_currentState(0)&#xA;{&#xA;}&#xA;&#xA;void StepperControl::init(byte blue, byte pink, byte yellow, byte orange)&#xA;{&#xA;    m_bluePin = blue;&#xA;    m_pinkPin = pink;&#xA;    m_yellowPin = yellow;&#xA;    m_orangePin = orange;&#xA;&#xA;    pinMode(m_bluePin, OUTPUT);&#xA;    pinMode(m_pinkPin, OUTPUT);&#xA;    pinMode(m_yellowPin, OUTPUT);&#xA;    pinMode(m_orangePin, OUTPUT);&#xA;    delayMicroseconds(DelayBetweenSteps);&#xA;    setPinsState(8);&#xA;    delayMicroseconds(DelayBetweenSteps);&#xA;}&#xA;&#xA;void StepperControl::StepCW(int steps)&#xA;{ &#xA;    for(int i = 0; i &amp;lt; steps; i++)&#xA;    {&#xA;        m_currentState = (m_currentState - 1) % 8;&#xA;        setPinsState(m_currentState);&#xA;        delayMicroseconds(DelayBetweenSteps);&#xA;    }&#xA;    setPinsState(8);&#xA;}&#xA;&#xA;void StepperControl::StepCCW(int steps)&#xA;{&#xA;    for(int i = 0; i &amp;lt; steps; i++)&#xA;    {&#xA;        m_currentState = (m_currentState + 1) % 8;&#xA;        setPinsState(m_currentState);&#xA;        delayMicroseconds(DelayBetweenSteps);&#xA;    }&#xA;    setPinsState(8);&#xA;}&#xA;&#xA;void StepperControl::StepCWDegree(float degrees)&#xA;{&#xA;    float steps = degrees * (float)StepsPerFullRotation / 360.0f;&#xA;    StepCW((int)steps);&#xA;}&#xA;&#xA;void StepperControl::StepCCWDegree(float degrees)&#xA;{&#xA;    float steps = degrees * (float)StepsPerFullRotation / 360.0f;&#xA;    StepCCW((int)steps);&#xA;}&#xA;&#xA;void StepperControl::setPinsState(byte step)&#xA;{&#xA;  digitalWrite(m_bluePin, bitRead(m_pinValuelookup[step], 0));&#xA;  digitalWrite(m_pinkPin, bitRead(m_pinValuelookup[step], 1));&#xA;  digitalWrite(m_yellowPin, bitRead(m_pinValuelookup[step], 2));&#xA;  digitalWrite(m_orangePin, bitRead(m_pinValuelookup[step], 3));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23746" LastActivityDate="2016-07-17T19:26:31.973" Title="Bizarre behavior, loop function affects setup function" Tags="|arduino-uno|programming|stepper|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26161" PostTypeId="2" ParentId="26157" CreationDate="2016-07-09T18:53:52.910" Score="2" Body="&lt;p&gt;Seeing all on for 128+ and all off for 127- is indicative that you are using a pin that can't do PWM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use a non-PWM pin with analogWrite it goes &quot;Is this less than 128? Yes? Then I will turn it off. Otherwise I will turn it on.&quot;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case NOT_ON_TIMER:&#xA;default:&#xA;    if (val &amp;lt; 128) {&#xA;        digitalWrite(pin, LOW);&#xA;    } else {&#xA;        digitalWrite(pin, HIGH);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you don't mention what board you are using I can only assume that you have picked a pin that can't do PWM. Change to a pin that &lt;em&gt;can&lt;/em&gt; do PWM and you should get a PWM signal.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-09T18:53:52.910" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26162" PostTypeId="2" ParentId="8511" CreationDate="2016-07-09T18:56:24.617" Score="1" Body="&lt;p&gt;On my board the regulator is marked L0UA which is the code for a 5V regulator type LP2985, L0UB is also 5V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A 3.3V regulator would be marked L0RA or L0RB.&lt;/p&gt;&#xA;" OwnerUserId="23751" LastEditorUserId="304" LastEditDate="2016-07-11T00:25:29.577" LastActivityDate="2016-07-11T00:25:29.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26164" PostTypeId="1" CreationDate="2016-07-09T19:21:23.997" Score="1" ViewCount="764" Body="&lt;p&gt;I recently bought a &lt;a href=&quot;https://www.sparkfun.com/products/13262&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun Can-Bus Shield&lt;/a&gt;, and tried the SparkFun_CAN_Demo from &lt;a href=&quot;https://learn.sparkfun.com/tutorials/can-bus-shield-hookup-guide&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;Sparkfun Can Shield Tutorial&quot;&gt;here&lt;/a&gt; but the program only prints &quot;CAN-Bus Demo&quot; and then does nothing, even when I have it connected into my vehicle's OBD-II port and the key is turned to ON (I can't run the engine because I am in my garage). Any help will be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="17159" LastEditorUserId="4628" LastEditDate="2017-09-06T05:05:55.537" LastActivityDate="2017-12-05T12:38:52.157" Title="Sparkfun Can-Bus Shield example not working" Tags="|serial|arduino-mega|spi|can-bus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26165" PostTypeId="1" CreationDate="2016-07-09T19:32:31.157" Score="2" ViewCount="2056" Body="&lt;p&gt;Forgive my lack of knowledge of some robotic related terms, but the way my two wheel drive robot steers is simply by having each wheel move at different speeds; for left, for example, the left wheel moves while the right one stays stationary for a given delay of time and vice versa.&#xA;but I want to make my obstacle detection a little more sophisticated with the following logic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the robot moves, scan the environment using an ultrasonic sensor(60 degrees to left and 60 degrees to the right) and using a simple max finding algorithm find the optimal angle i.e. angle at which the ultrasonic reading was highest. and then I want to find a way, using the same system of vehicle rotation if possible, turn to that specific angle proceed to move forward and scan simultaneously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;what I aim to achieve in the end is smoother obstacle avoidance as compared to the most common stop when close to obstacle -&gt; turn left or right -&gt; move and loop     &lt;/p&gt;&#xA;" OwnerUserId="22976" LastEditorUserId="28033" LastEditDate="2016-12-07T12:42:26.907" LastActivityDate="2017-01-06T15:21:29.187" Title="Precise rotation (steering direction to a given angle) on obstacle avoidance robot" Tags="|motor|robotics|mechanical|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26166" PostTypeId="2" ParentId="26165" CreationDate="2016-07-09T19:47:43.007" Score="2" Body="&lt;p&gt;The only way you can know how far you have turned, with any form of accuracy and, more importantly, repeatability, is by employing some form of feedback.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words, to work out how far you have turned you need, first, to know how far you have turned.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simplest method is probably to use some form of monitoring on the wheels themselves. That could be an optical encoder to give a nice high resolution &quot;number of degrees the wheel has turned&quot;, which can be coupled with the circumference of the wheel to calculate the distance travelled (which can then be used with some simple trigonometry to work out the angle you have turned through) or a more coarse &quot;magnet on the wheel + hall effect sensor&quot; to give you the number of revolutions the wheel has gone through (not very accurate and only really any use at higher speeds when there will be lots of revolutions. Maybe this method would be better on the motor before the gearbox that drives the wheel?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, do you really care that much anyway? Are you over thinking things a little too much?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Surely a simpler method would be to first turn left an arbitrary amount (somewhere around 60-degrees-ish, you're not really worried) then sweep from left to right (a distance of somewhere around 120 degrees in total) looking for the furthest distance. Once you have completed your sweep you then just reverse your turn direction &lt;em&gt;until you read the same (or within a certain tolerance) distance&lt;/em&gt; at which point you will be facing your longest space. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All that can be done just with spinning the wheels either for a pre-defined period, or until a specific reading has been obtained. No need to worry about precise angles or anything fancy like that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-09T19:47:43.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26167" PostTypeId="1" CreationDate="2016-07-09T20:38:32.153" Score="1" ViewCount="2067" Body="&lt;p&gt;I am working on HTTP GET Request. I have created ESP wifi as web server. It creates a access point with IP address : 192.168.4.1 &#xA;When my android app is connected to web server, it sends values every 50ms on 192.168.4.1/R&quot;VALUE&quot;. Value is integer type (0~1023). Example :- 192.168.4.1/R546&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is working fine when I send values every 1s, but esp crashes, when IP is hit every 5ms second. I have captured the crash detail on serial monitor. Attaching the file and code as well. Kindly help. &lt;a href=&quot;https://i.stack.imgur.com/BKzCl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BKzCl.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;EEPROM.h&amp;gt;&#xA;#include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;&#xA;#define RED_LED     12&#xA;&#xA;WiFiServer server(80); //Initialize the server on Port 80&#xA;&#xA;char myTestUrl[100];&#xA;&#xA;void setup()&#xA;{&#xA;&#xA;  EEPROM.begin(512);&#xA;  Serial.begin(9600); //Start communication between the ESP8266-12E and the monitor window&#xA;&#xA;  WiFi.mode(WIFI_AP); //Our ESP8266-12E is an AccessPoint&#xA;  WiFi.softAP(&quot;LED_Downlight1&quot;, &quot;12345678&quot;); // Provide the (SSID, password); .&#xA;  server.begin(); // Start the HTTP Server&#xA;&#xA;  IPAddress HTTPS_ServerIP = WiFi.softAPIP(); // Obtain the IP of the Server&#xA;  Serial.print(&quot;Server IP is: &quot;); // Print the IP to the monitor window&#xA;  Serial.println(HTTPS_ServerIP);&#xA;}&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  WiFiClient client = server.available();&#xA;  if (!client)&#xA;  {&#xA;    return;&#xA;  }&#xA;&#xA;  String request = client.readStringUntil('\r');&#xA;  //Serial.print(request);&#xA;&#xA;  request.toCharArray(myTestUrl, 100);&#xA;&#xA;  char *Red = strstr(myTestUrl, &quot;/R&quot;);&#xA;  if (Red)&#xA;  {&#xA;    int RedValue  = atoi(Red + 2);&#xA;    analogWrite(RED_LED, RedValue);&#xA;    Serial.print(&quot;Red: &quot;);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(RedValue);&#xA;    Serial.print(&quot;\n&quot;);&#xA;&#xA;    int SetRedValue = (RedValue / 4);&#xA;    EEPROM.write(0, SetRedValue);&#xA;&#xA;    EEPROM.commit();&#xA;&#xA;    Serial.print(&quot;Red Memory Write :&quot;);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(SetRedValue);&#xA;    Serial.print(&quot;\n \n&quot;);&#xA;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23271" LastActivityDate="2016-11-08T11:50:41.590" Title="ESP8266 Web Server Crash + Arduino IDE" Tags="|arduino-ide|esp8266|web-server|http|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26168" PostTypeId="1" CreationDate="2016-07-09T20:55:10.393" Score="0" ViewCount="1757" Body="&lt;p&gt;Im a beginner working with arduino.&#xA;Im little familliar with java syn and its not hard for me to do the work with ide ;but i know python better....is there any Lib that let you program Arduino with Python?&lt;/p&gt;&#xA;" OwnerUserId="23754" LastActivityDate="2016-07-11T14:21:41.717" Title="Programming Arduino With Python" Tags="|arduino-ide|library|python|" AnswerCount="1" CommentCount="2" ClosedDate="2016-08-19T19:22:19.467" ContentLicense="CC BY-SA 3.0" />
  <row Id="26169" PostTypeId="1" AcceptedAnswerId="26273" CreationDate="2016-07-09T21:45:00.463" Score="1" ViewCount="87" Body="&lt;p&gt;I'm using the MPU9255 Accelerometer to measure acceleration in the X,Y, and Z directions.  As per the datasheet, I've applied a scaling to the raw digital values based off of whether I specified +- 2G, +- 4G, +- 8G etc.  This scaling works fantastically, but there is consistent noise on the Z axis, far greater than that of gravity's 1G of force.  Here is a sample output&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ACCELEROMETER-X&#xA;0.7226562500&#xA;ACCELEROMETER-Y&#xA;0.1523437500    &#xA;ACCELEROMETER-Z&#xA;7.9707031250    &#xA;&#xA;ACCELEROMETER-X&#xA;0.7460937500&#xA;ACCELEROMETER-Y&#xA;0.1875000000    &#xA;ACCELEROMETER-Z&#xA;8.0468750000    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, there is about 7G of noise on the Z axis. I calculated the scaling with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Get accelerometer scaling based off of how many G's per of variation the system was tuned to handle&#xA;int16_t getAccScalar(int16_t system_scale){&#xA;  int16_t acc_scalar = 16384;&#xA;  short scalar = 1;&#xA;  if(system_scale == ACC_FULL_SCALE_4_G){&#xA;    scalar = 2;&#xA;  }&#xA;  else if(system_scale == ACC_FULL_SCALE_8_G){&#xA;    scalar = 4;&#xA;  }&#xA;  else{&#xA;    scalar = 8;&#xA;  }&#xA;  acc_scalar /= scalar;&#xA;  return acc_scalar;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then in configuration I use a register writing function with this header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and call it with these values&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;I2CwriteByte(MPU9250_ADDRESS,28,ACC_FULL_SCALE_2_G);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Anyone know why this is happening? Thanks and have a squanchy day.&lt;/p&gt;&#xA;" OwnerUserId="23755" LastActivityDate="2016-07-12T23:47:01.047" Title="Accelerometer Z Value off a significant amount, all other values reasonable" Tags="|i2c|accelerometer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26171" PostTypeId="1" AcceptedAnswerId="26172" CreationDate="2016-07-10T04:15:12.573" Score="0" ViewCount="347" Body="&lt;p&gt;I want to read data from an accelerometer sensor, which pushes its data to the Arduino via an external interrupt. I then want the Arduino to relay this data to a host computer via the serial connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will the external interrupt interfere with the serial connection? If the Arduino's in the middle of transmitting via serial, and the accelerometer triggers the interrupt, won't that potentially break the serial connection?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastActivityDate="2016-07-10T04:22:27.900" Title="Using an external interrupt alongside serial" Tags="|arduino-uno|serial|interrupt|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26172" PostTypeId="2" ParentId="26171" CreationDate="2016-07-10T04:22:27.900" Score="2" Body="&lt;p&gt;Transmitting a single character via UART on the ATmega328P (and all other AVRs with a dedicated USART) cannot be interrupted since it is independently clocked. Loading the next character into the transmit buffer can be (since the &lt;code&gt;INTx&lt;/code&gt; interrupts have priority over the &lt;code&gt;USART,xxx&lt;/code&gt; interrupts), but this will not actually break communications, just slow it down.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-10T04:22:27.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26173" PostTypeId="1" CreationDate="2016-07-10T09:53:07.327" Score="0" ViewCount="5646" Body="&lt;p&gt;I am using NodeMCU and I program it using Arduino IDE, I need to change the PWM frequency of a port, in Arduino I used to change the frequency using timers registers like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TCCR1B = (TCCR1B &amp;amp; 0xF8) | 1 ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I change the frequency of a digital pin using some function like that: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analogWriteFrequency(pin, 31250);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So that the code will looks like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifdef __AVR__&#xA;TCCR1B = (TCCR1B &amp;amp; 0xF8) | 1 ; //generates the MCKL signal&#xA;#else&#xA;analogWriteFrequency(pin, 31250);&#xA;#endif&#xA;analogWrite(pin, 128) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7807" LastActivityDate="2016-07-10T12:04:09.590" Title="NodeMCU Arduino set PWM Frequency to specific frequency" Tags="|arduino-ide|pwm|timers|nodemcu|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26174" PostTypeId="2" ParentId="26173" CreationDate="2016-07-10T12:04:09.590" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;PWM frequency is 1kHz by default. Call &lt;code&gt;analogWriteFreq(new_frequency)&lt;/code&gt; to change the frequency.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino/blob/master/doc/reference.md&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-10T12:04:09.590" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26176" PostTypeId="1" CreationDate="2016-07-10T14:37:56.267" Score="0" ViewCount="3293" Body="&lt;p&gt;I have an RGB led and I (just) would like to dim is brightness programmatically.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched Google thoroughly without any interesting code.&#xA;Some of them present only &quot;how to&quot; fade from on to another color.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I change PWM value from 0 to 255, I can easily change color, but, my need is to change the brightness value from potentiometer (through read from analog pin). &lt;/p&gt;&#xA;" OwnerUserId="23300" LastEditorUserId="2944" LastEditDate="2016-07-10T15:25:52.117" LastActivityDate="2016-07-10T15:25:52.117" Title="Arduino Dim RGB LED" Tags="|pwm|rgb-led|potentiometer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26177" PostTypeId="2" ParentId="26176" CreationDate="2016-07-10T15:11:16.360" Score="1" Body="&lt;p&gt;To control the brightness of an LED with a POT read the pot position using the ADC, convert the range of values from 0 - 1024 to 0 - 255 then write that to the PWM controlling the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This segment of code came from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=81039.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; discussion:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  knobvalue = analogRead(potpin);&#xA;  knobvalue = map(knobvalue, 0, 1023, 0, 255);&#xA;  analogWrite(11, knobvalue);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is just for 1 LED.  If you have 3 LEDs connected to 3 Arduino PWM pins, you will have to write the same value to all 3 pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is 1 RGB LED and you are controlling each of the 3 LEDs with 3 Arduino PWM pins, this will (for most RGB LEDs) cause the RGB LED to always appear White as you are varying all colors by the same amount.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are trying to vary the brightness of an RGB LED that is set to an arbitrary color...  this is more difficult:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using 3 variables ranging from 0 to 255 pick your color.  Before writing these to the 3 PWMs which control the RGB LED, multiply each by the value read from the ADC connected to the POT.  Now divide each by the maximum possible ADC value.  Take care you do not exceed the range of your variables!  Write these new values to the 3 PWMs which control the RGB LEDs.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-10T15:22:21.213" LastActivityDate="2016-07-10T15:22:21.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26179" PostTypeId="1" CreationDate="2016-07-10T16:40:24.857" Score="0" ViewCount="44" Body="&lt;p&gt;I can't seem to relibly find data sheets for MCM electronics parts.. Searched for hours.. Any help?&lt;/p&gt;&#xA;" OwnerUserId="23769" LastActivityDate="2016-07-11T07:45:22.353" Title="Does anyone have a data sheet for MC16-0072" Tags="|pwm|" AnswerCount="1" CommentCount="2" ClosedDate="2016-08-01T11:10:47.770" ContentLicense="CC BY-SA 3.0" />
  <row Id="26182" PostTypeId="1" AcceptedAnswerId="26183" CreationDate="2016-07-10T18:25:18.777" Score="0" ViewCount="2417" Body="&lt;p&gt;So I have the basic setup ready with one relay that is controlling a 200W bulb. The Phase of this bulb is passed through a current sensor acs712. While running a simple analog read example sketch, I get output 511 from ADC, which is as expected. Then I subtracted this 511 from my measurement and observed the results while turning on/off the bulb.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorValue;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);  // sets the serial port to 9600&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  sensorValue = analogRead(0);       // read analog input pin 0&#xA;  Serial.println((511-sensorValue), DEC);  // prints the value read&#xA;  delay(100);                        // wait 100ms for next reading&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the output graph;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GX1Dw.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GX1Dw.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the bulb is off, the current remains 0, but when I turn on the bulb, the voltage fluctuates over positive and negative side. Why is the sensor showing this behavior ?, I am not using any additional capacitor for noise reduction. Do I need to ? but I guess this is not noise. Is it ?&lt;/p&gt;&#xA;" OwnerUserId="13754" LastActivityDate="2016-07-10T18:39:44.433" Title="ACS712 Not working correctly with Arduino" Tags="|arduino-uno|sensors|relay|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26183" PostTypeId="2" ParentId="26182" CreationDate="2016-07-10T18:39:44.433" Score="0" Body="&lt;p&gt;You are seeing that because that is what the current is doing. It's called AC - Alternating Current. It's what the mains current is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To work with AC you have to rapidly sample over a short period to get the maximum and minimum values. Subtract one from the other and that gives you the &lt;em&gt;peak-to-peak&lt;/em&gt; current. You can then use that to calculate the &lt;em&gt;RMS&lt;/em&gt; current which is what you are (most likely) interested in.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://whatis.techtarget.com/definition/root-mean-square-RMS&quot; rel=&quot;nofollow&quot;&gt;http://whatis.techtarget.com/definition/root-mean-square-RMS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-10T18:39:44.433" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26184" PostTypeId="1" AcceptedAnswerId="26204" CreationDate="2016-07-10T22:42:35.827" Score="2" ViewCount="5868" Body="&lt;p&gt;I have some Arduino code that looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char packet = ser.read();&#xA;switch(packet){&#xA;    case 'a':&#xA;         someobj.somefunc();&#xA;         break;&#xA;    case 'b':&#xA;         otherobj.otherfunc();&#xA;         break;&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've added a few large libraries that are now causing my sketch to exceed the Arduino Uno's memory. I've done all the usual tricks to reduce memory usage, like using F(), removing unused variables and functions, but I'm still 5% over the memory limit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried commenting out various parts of my code to see what was taking up so much space, and I found removing this switch statement freed up a whopping 20% of memory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it acts like glorified array index, I was wondering if it could in fact be replaced with an array of function pointers, with the packet variable serving as the array index. e.g.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint packet = ser.read();&#xA;func_array[packet]();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Although the class instance types are arbitrary, the methods all return the same type and take no arguments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you write an array of pointers to arbitrary class instance methods in Arduino C/C++?&lt;/p&gt;&#xA;" OwnerUserId="4478" LastEditorUserId="4478" LastEditDate="2016-07-10T22:54:14.413" LastActivityDate="2016-07-11T09:11:26.133" Title="Storing an array of function pointers" Tags="|arduino-uno|memory-usage|code-optimization|pointer|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26185" PostTypeId="1" AcceptedAnswerId="26258" CreationDate="2016-07-10T15:31:06.533" Score="5" ViewCount="3889" Body="&lt;p&gt;I got 2 boards with an &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATMEGA328&lt;/a&gt; microcontroller and &lt;a href=&quot;http://www.farnell.com/datasheets/1669372.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP2515&lt;/a&gt; CAN Controller and I'm trying to get them communicate with each other. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To shortcut the programming a little bit I'm using the &lt;a href=&quot;https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library&quot; rel=&quot;nofollow noreferrer&quot;&gt;Sparkfun CAN BUS Library&lt;/a&gt;, but I am not using ther &lt;a href=&quot;https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library/blob/master/src/Canbus.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;CanbusClass()&lt;/a&gt;, I'm directly using the included &lt;a href=&quot;https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library/blob/master/src/mcp2515.c&quot; rel=&quot;nofollow noreferrer&quot;&gt;mcp2515.c/h&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The MCP2515 drives a &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21667f.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MCP2551&lt;/a&gt;. CAN_H and CAN_L of both boards are connected with each other, the line has a &lt;a href=&quot;https://electronics.stackexchange.com/questions/55389/why-does-the-can-bus-use-a-120-ohm-resistor-as-the-terminating-resistor-and-not&quot;&gt;120Ohm&lt;/a&gt; termination resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/F4U8A.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/F4U8A.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cVAIP.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cVAIP.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;Both Microcontrollers share the same code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;mcp2515.h&amp;gt;&#xA;#include &amp;lt;global.h&amp;gt;&#xA;#include &amp;lt;mcp2515_defs.h&amp;gt;&#xA;#include &amp;lt;defaults.h&amp;gt;&#xA;#define CANSPEED_125    7&#xA;const uint8_t PIN_LED_RED = 6;&#xA;const uint8_t PIN_LED_GREEN = 7;&#xA;&#xA;void setup()&#xA;{   &#xA;  Serial.begin(9600);&#xA;  pinMode(PIN_LED_GREEN, OUTPUT);   &#xA;  pinMode(PIN_LED_RED, OUTPUT);&#xA;  unsigned long now=micros();&#xA;  unsigned long init = 0;&#xA;  if(mcp2515_init(CANSPEED_125)) {&#xA;    init=micros();&#xA;    Serial.println(&quot;CAN Init ok&quot;);  &#xA;    digitalWrite(PIN_LED_GREEN, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(PIN_LED_GREEN, LOW);&#xA;  } else {&#xA;    init = micros();&#xA;    Serial.println(&quot;Can't init CAN&quot;);&#xA;    digitalWrite(PIN_LED_RED, HIGH);&#xA;    delay(1000);&#xA;    digitalWrite(PIN_LED_RED, LOW);&#xA;  }&#xA;  Serial.print(&quot;Time for init: &quot;);&#xA;  Serial.println (init-now);&#xA;  delay(1000);&#xA;  mcp2515_bit_modify(CANCTRL, (1&amp;lt;&amp;lt;REQOP2)|(1&amp;lt;&amp;lt;REQOP1)|(1&amp;lt;&amp;lt;REQOP0), 0); &#xA;  Serial.println(&quot;-------------------------&quot;);&#xA;  Serial.println(&quot;1. CAN - MSG1&quot;);&#xA;  Serial.println(&quot;-------------------------&quot;);&#xA;}&#xA;&#xA;void loop()&#xA;{   &#xA;  tCAN CANmessage;&#xA;  unsigned long tnow;&#xA;  unsigned long tsend;&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;    char incomingByte = Serial.read();&#xA;    switch (incomingByte) {&#xA;        case '1':&#xA;            Serial.println(&quot;1. CAN - MSG1&quot;);&#xA;            tsend=micros();&#xA;            CANmessage.id = 0x01;&#xA;            CANmessage.header.rtr = 0;&#xA;            CANmessage.header.length = 8;&#xA;            CANmessage.data[0] = B01010101;&#xA;            CANmessage.data[1] = B11001100;&#xA;            CANmessage.data[2] = B11100011;&#xA;            mcp2515_bit_modify(CANCTRL, (1&amp;lt;&amp;lt;REQOP2)|(1&amp;lt;&amp;lt;REQOP1)|(1&amp;lt;&amp;lt;REQOP0), 0);&#xA;            mcp2515_send_message(&amp;amp;CANmessage);&#xA;            tnow=micros();&#xA;            Serial.print(&quot;Message send in time: &quot;);&#xA;            Serial.println(tnow-tsend);&#xA;            break;&#xA;    }&#xA;  }&#xA;  checkCANBus();&#xA;}&#xA;&#xA;void checkCANBus() {&#xA;  if (mcp2515_check_message()) {&#xA;    tCAN CANmessage;&#xA;    PORTD ^= _BV(7);&#xA;    Serial.println(&quot;Has message&quot;);&#xA;    if (mcp2515_get_message(&amp;amp;CANmessage)) &#xA;    {&#xA;        Serial.print(&quot;Message receivced: &quot;);&#xA;        Serial.print(CANmessage.id);&#xA;        Serial.print(&quot;, &quot;);&#xA;        Serial.print(CANmessage.data[0], BIN);&#xA;        Serial.print(&quot;, &quot;);&#xA;        Serial.print(CANmessage.data[1], BIN);&#xA;        Serial.print(&quot;, &quot;);&#xA;        Serial.print(CANmessage.data[2], BIN);&#xA;        Serial.print(&quot;end &quot;);&#xA;        if (CANmessage.id==0x01) {&#xA;            Serial.println(&quot;MSG ID1 received&quot;);&#xA;            PORTD ^= _BV(6);&#xA;        }               &#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On Serial port of both boards I get on startup:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CAN Init ok&lt;br&gt;&#xA;  Time for init: 250&lt;br&gt;&#xA;  1. CAN - MSG1  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When I send a byte on the Serial port of one baord ('1') I get on the Serial: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Message send in time: 212&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;On the receiver side I only get &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Has message &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;and the green LED on PIN7 is turned on (means mcp2515_check_message() returns that the MCP2515 has set the receive interrupt signal). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that the program crashes in the routine mcp2515_get_message().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By toggling the LED's I figured out that the program crashes directly at the beginning of mcp2515_get_message() in the line mcp2515_read_status(SPI_RX_STATUS);&#xA;So the problem lies in mcp2515_read_status().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int8_t mcp2515_get_message(tCAN *message)&#xA;{&#xA;  // read status&#xA;  uint8_t status = mcp2515_read_status(SPI_RX_STATUS);&#xA;  ...&#xA;  ...&#xA;}&#xA;&#xA;uint8_t mcp2515_read_status(uint8_t type)&#xA;{&#xA;    uint8_t data;&#xA;    RESET(MCP2515_CS);&#xA;    spi_putc(type);&#xA;    data = spi_putc(0xff);&#xA;    SET(MCP2515_CS);&#xA;    return data;&#xA;}&#xA;&#xA;uint8_t spi_putc( uint8_t data )&#xA;{&#xA;  SPDR = data;&#xA;  while( !( SPSR &amp;amp; (1&amp;lt;&amp;lt;SPIF) ) )&#xA;    ;&#xA;  return SPDR;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By further toggling I figured that the last line correctly executed is spi_putc(type);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The line data = spi_putc(0xff); freezes the microcontoller! Which means the while loop in spi_putc() is endless running as the SPIF bit is not cleared.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what I think I figured out so far:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The SPI bus connection is clearly working as the initialization is working!&lt;/li&gt;&#xA;&lt;li&gt;As the mcp2515_check_message() returns on the receiver board that MCP2515_INT is set so I assume the CAN communication is working (otherwise, why would controller set the MCP2515_INT). &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;SPI_RX_STATUS is defined as 0xB0(original as in library). &#xA;The &lt;a href=&quot;http://www.farnell.com/datasheets/1669372.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Datasheet&lt;/a&gt; of the MCP2515 controller states on page 66&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The RX STATUS instruction (Figure 12-9) is used to&#xA;  quickly determine which filter matched the message&#xA;  and message type (standard, extended, remote). After&#xA;  the command byte is sent, the controller will return&#xA;  8 bits of data that contain the status data. If more clocks&#xA;  are sent after the eight bits are transmitted, the&#xA;  controller will continue to output the same status bits as&#xA;  long as the CS pin stays low and clocks are provided.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Which it clearly doesn't! But what I cant figure out is why :) &lt;/p&gt;&#xA;" OwnerUserId="4215" OwnerDisplayName="KarlKarlsom" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-26T12:35:13.777" Title="ATMEGA328 SPI MCP2515 - SPI communication freezes at certain point" Tags="|spi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26186" PostTypeId="1" AcceptedAnswerId="26189" CreationDate="2016-07-10T23:03:24.400" Score="2" ViewCount="127" Body="&lt;p&gt;I am using an infrared sensor and a flex sensor to read values from the serial monitor in arduino, however after maybe ten seconds or so it seems the serial monitor breaks and the printed values start to print out rapidly. Does anyone have any suggestions on why this might occurring. Any information would be highly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int previousMillis = 0;&#xA;&#xA;long interval1 = 300;&#xA;long interval2 = 350;&#xA;&#xA;void setup() {&#xA;&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    unsigned long currentMillis = millis();&#xA;&#xA;    if ( currentMillis - previousMillis &amp;gt;= interval1 ) {&#xA;        previousMillis = currentMillis;&#xA;&#xA;        Serial.println( &quot;TIMER IS DONE!&quot; );&#xA;&#xA;        int val1 = analogRead(0);&#xA;        Serial.print(&quot;Sensor Value 1 is &quot;);&#xA;        Serial.println(val1);&#xA;        delay(5);&#xA;    }&#xA;    if ( currentMillis - previousMillis &amp;gt;= interval2 ) {&#xA;        previousMillis = currentMillis;&#xA;&#xA;        int val2 = analogRead(1);&#xA;&#xA;        Serial.print(&quot;Sensor Value 2 is &quot;);&#xA;        Serial.println(val2);&#xA;    }&#xA;    delay(10);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23778" LastEditorUserId="304" LastEditDate="2016-07-10T23:32:17.470" LastActivityDate="2016-07-11T07:31:51.710" Title="Serial Monitor listing rapidly" Tags="|arduino-uno|serial|sensors|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26187" PostTypeId="2" ParentId="26186" CreationDate="2016-07-10T23:30:21.160" Score="1" Body="&lt;p&gt;You are doing math with 2 different types.   One is long and the other is an int.  So, eventually the long will always be lager than the int and the test will always be true.  (A 32 bit long can count up to over 2 billion.  A 16 bit int can only count up to about 32 thousand.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the method millis() is of type &quot;unsigned long&quot;.  So change all your variables to match this type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also note that when the millis() timer overflows and start over your program may perform unexpectedly.  Since this rarely happens it may not concern you.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-10T23:37:30.777" LastActivityDate="2016-07-10T23:37:30.777" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26188" PostTypeId="2" ParentId="18910" CreationDate="2016-07-10T23:38:14.217" Score="0" Body="&lt;p&gt;@slash-dev &quot;...Also, using SerialEvent is no better than doing the polling in loop().&quot; Are you sure about that? SerialEvent (and especially the ones on Teensy3) use hardware interrupts which can be handled in the midst of other operations; even delay() does not block interrupts (&lt;a href=&quot;http://playground.arduino.cc/Code/AvoidDelay&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/AvoidDelay&lt;/a&gt;). It's hard to imagine multiple serial streams running at 100 kbaud or better (test reported in PJRC forum) and handling each character in the main loop even if that was all your program did. And why would you want to? There are good reasons interrupts exist.&lt;br&gt;&#xA;&lt;strong&gt;Update&lt;/strong&gt;: I'm not allowed to &quot;comment&quot; without 50 reputation. Thanks for the commit link... I can't imagine why HardwareSerial would not use interrupts... that is the default on all other platforms we've used for years.&lt;/p&gt;&#xA;" OwnerUserId="23779" LastEditorUserId="23779" LastEditDate="2016-07-12T12:44:36.610" LastActivityDate="2016-07-12T12:44:36.610" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26189" PostTypeId="2" ParentId="26186" CreationDate="2016-07-11T00:12:29.963" Score="1" Body="&lt;p&gt;I hate to start with &quot;I hate delays&quot;, but I hate delays :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why have you included them? If you want your outputs to be slower, increase your intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use a state machine instead:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousMillis = 0;&#xA;unsigned long currentMillis = 0;&#xA;&#xA;unsigned long interval1 = 300;&#xA;unsigned long interval2 = 350;&#xA;&#xA;#define LEDPIN  13&#xA;&#xA;int state = 0;&#xA;// 0 = waiting for sensor one interval&#xA;// 1 = another 50ms for sensor two&#xA;&#xA;void setup() {&#xA;    currentMillis=millis();&#xA;    previousMillis=currentMillis;&#xA;    Serial.begin(9600);&#xA;    pinMode(LEDPIN, OUTPUT);&#xA;    digitalWrite(A0, HIGH); // internal pullups&#xA;    digitalWrite(A1, HIGH); // internal pullups&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;    currentMillis = millis();&#xA;    if ( state == 0 ) &#xA;    {&#xA;        if ( currentMillis - previousMillis &amp;gt;= interval1) &#xA;        {&#xA;            int val1 = analogRead(0);&#xA;            Serial.print( currentMillis );&#xA;            Serial.print(&quot; Sensor Value 1 is &quot;);&#xA;            Serial.println(val1);&#xA;            digitalWrite(LEDPIN, HIGH);&#xA;            state = 1;&#xA;        }&#xA;    }&#xA;    else&#xA;    {&#xA;        if ( currentMillis - previousMillis &amp;gt;= interval2) &#xA;        {&#xA;            int val2 = analogRead(1);&#xA;            Serial.print( currentMillis );&#xA;            Serial.print(&quot; Sensor Value 2 is &quot;);&#xA;            Serial.println(val2);&#xA;            digitalWrite(LEDPIN, LOW);   &#xA;            state = 0;         &#xA;            previousMillis = currentMillis; &#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, test 2 will only be conducted 50ms after test 1 and then previous millis is reset&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit: I fixed the interval test regarding overflow (which you had correctly in the first place)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;edit2: (I'm having too much fun with this)&#xA;assuming you want each test conducted at specifically the interval requested (ie sensor 1 every 300ms and sensor 2 every 350ms), I have come up with v2 (and removed the state machine, since it's just not needed)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previous1 = 0;&#xA;unsigned long previous2 = 0;&#xA;unsigned long currentMillis = 0;&#xA;&#xA;unsigned long interval1 = 300;&#xA;unsigned long interval2 = 350;&#xA;&#xA;const int LEDPIN = 13;&#xA;&#xA;void setup() {&#xA;    currentMillis=millis();&#xA;    previous1=currentMillis;&#xA;    previous2=currentMillis;&#xA;    Serial.begin(9600);&#xA;    pinMode(LEDPIN, OUTPUT);&#xA;    digitalWrite(A0, HIGH);&#xA;    digitalWrite(A1, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    currentMillis = millis();&#xA;    if ( currentMillis - previous1 &amp;gt;= interval1) &#xA;    {&#xA;        previous1 = currentMillis;&#xA;&#xA;        int val1 = analogRead(0);&#xA;        Serial.print(currentMillis);&#xA;        Serial.print(&quot; Sensor Value 1 is &quot;);&#xA;        Serial.println(val1);&#xA;        digitalWrite(LEDPIN, HIGH);&#xA;    }&#xA;    if ( currentMillis - previous2 &amp;gt;= interval2) &#xA;    {&#xA;        int val2 = analogRead(1);&#xA;&#xA;        Serial.print(currentMillis);&#xA;        Serial.print(&quot; Sensor Value 2 is &quot;);&#xA;        Serial.println(val2);&#xA;        previous2 = currentMillis; &#xA;        digitalWrite(LEDPIN, LOW);            &#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;edit: including some sample output to indicate a working state:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;188609 Sensor Value 1 is 15&#xA;188659 Sensor Value 2 is 14&#xA;188959 Sensor Value 1 is 14&#xA;189009 Sensor Value 2 is 15&#xA;189309 Sensor Value 1 is 15&#xA;189359 Sensor Value 2 is 14&#xA;189659 Sensor Value 1 is 14&#xA;189709 Sensor Value 2 is 1017&#xA;190009 Sensor Value 1 is 15&#xA;190059 Sensor Value 2 is 1002&#xA;190359 Sensor Value 1 is 14&#xA;190409 Sensor Value 2 is 1013&#xA;190709 Sensor Value 1 is 14&#xA;190759 Sensor Value 2 is 1019&#xA;191059 Sensor Value 1 is 15&#xA;191109 Sensor Value 2 is 1004&#xA;191409 Sensor Value 1 is 14&#xA;191459 Sensor Value 2 is 1019&#xA;191759 Sensor Value 1 is 15&#xA;191809 Sensor Value 2 is 15&#xA;192109 Sensor Value 1 is 14&#xA;192159 Sensor Value 2 is 15&#xA;192459 Sensor Value 1 is 14&#xA;192509 Sensor Value 2 is 14&#xA;192809 Sensor Value 1 is 15&#xA;192859 Sensor Value 2 is 15&#xA;193159 Sensor Value 1 is 14&#xA;193209 Sensor Value 2 is 16&#xA;193509 Sensor Value 1 is 14&#xA;193559 Sensor Value 2 is 15&#xA;193859 Sensor Value 1 is 1005&#xA;193909 Sensor Value 2 is 1021&#xA;194209 Sensor Value 1 is 1021&#xA;194259 Sensor Value 2 is 1003&#xA;194560 Sensor Value 1 is 1004&#xA;194609 Sensor Value 2 is 1020&#xA;194909 Sensor Value 1 is 1020&#xA;194959 Sensor Value 2 is 1004&#xA;195259 Sensor Value 1 is 15&#xA;195309 Sensor Value 2 is 1001&#xA;195609 Sensor Value 1 is 14&#xA;195659 Sensor Value 2 is 1022&#xA;195959 Sensor Value 1 is 15&#xA;196009 Sensor Value 2 is 998&#xA;196310 Sensor Value 1 is 15&#xA;196359 Sensor Value 2 is 1019&#xA;196659 Sensor Value 1 is 15&#xA;196709 Sensor Value 2 is 1002&#xA;197009 Sensor Value 1 is 14&#xA;197059 Sensor Value 2 is 15&#xA;197359 Sensor Value 1 is 14&#xA;197409 Sensor Value 2 is 15&#xA;197709 Sensor Value 1 is 15&#xA;197760 Sensor Value 2 is 13&#xA;198060 Sensor Value 1 is 14&#xA;198110 Sensor Value 2 is 15&#xA;198410 Sensor Value 1 is 15&#xA;198460 Sensor Value 2 is 14&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="304" LastEditorUserId="304" LastEditDate="2016-07-11T03:09:48.717" LastActivityDate="2016-07-11T03:09:48.717" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26190" PostTypeId="1" CreationDate="2016-07-11T00:26:21.730" Score="0" ViewCount="2181" Body="&lt;p&gt;I have an RFID-RC522 module based on the &lt;a href=&quot;http://www.nxp.com/documents/data_sheet/MFRC522.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;MFRC522 chip&lt;/a&gt;. This chip is described in the datasheet as supporting &quot;ISO/IEC 14443 A/MIFARE and NTAG&quot; protocols. I have wired it up to an Arduino Uno using the recommended wiring in the documentation for the &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot;&gt;MFRC522 library&lt;/a&gt; I'm using. I have a sketch that (among other things) polls for presence of a new card:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    lcd.setup ();       // initialise LCD display&#xA;    SPI.begin();        // Init SPI bus&#xA;    mfrc522.PCD_Init(); // Init MFRC522 card&#xA;}&#xA;&#xA;void loop() {&#xA;    // Look for new cards&#xA;    if ( ! mfrc522.PICC_IsNewCardPresent()) {&#xA;        return;&#xA;    }&#xA;    lcd.println (&quot;Found new card&quot;);&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This sketch correctly detects the presence of the card that was supplied with the module (I believe this is a Mifare Classic card) but does not detect my NTAG216 implant. Does anyone have any idea why it might be failing to find the implanted chip?&lt;/p&gt;&#xA;" OwnerUserId="20071" LastEditorUserId="4628" LastEditDate="2017-02-07T09:52:58.593" LastActivityDate="2019-12-23T12:52:30.103" Title="RC522 RFID reader doesn't read NTAG216 chip" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26193" PostTypeId="1" AcceptedAnswerId="26195" CreationDate="2016-07-11T04:23:48.657" Score="0" ViewCount="287" Body="&lt;p&gt;I'm starting to learn how to use Arduino and I tried to make this code, which is just a simple if else statement; what I want to make is when the input is LOW, LED 1 is HIGH and LEDs 2,3 are LOW, and when the input is HIGH, the LEDs 2,3 are HIGH and LED 1 is LOW. I wrote this code but when I put the switch in LOW, instead having just like what I intended, all the outputs are HIGH. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I try changing the output and I checked all the wiring to the LEDs so my mistake is in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you guys tell me what's wrong with the code?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int switchstate = 0;&#xA;void setup() {&#xA;  pinMode (13,OUTPUT);&#xA;  pinMode(12,OUTPUT);&#xA;  pinMode(11,OUTPUT);&#xA;  pinMode(3,INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  switchstate = digitalRead(3);&#xA;  if (switchstate == LOW) {&#xA;    digitalWrite(11,HIGH);&#xA;    digitalWrite(12,LOW);&#xA;    digitalWrite(13,LOW);&#xA;  } else {&#xA;    digitalWrite(11,LOW);&#xA;    digitalWrite(12,HIGH);&#xA;    digitalWrite(13,HIGH);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23799" OwnerDisplayName="glenn Himawan" LastEditorUserId="16988" LastEditDate="2016-07-11T08:29:38.110" LastActivityDate="2016-07-11T08:37:54.303" Title="If - else statement in Arduino" Tags="|ide|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26195" PostTypeId="2" ParentId="26193" CreationDate="2016-07-11T07:37:06.977" Score="1" Body="&lt;p&gt;Your code doesn't seem to be the problem. Contrary to what you are saying I think your problem is most definitely in your hardware setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely, your digitalRead doesn't register a HIGH input, so it doesn't get 5V. Instead of digitalRead, go for analogRead(A0). So change your circuit and attach it to pin A0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use serial.println(switchstate) to print the results to the serial monitor and then decide what your top value (HIGH) and bottom value (LOW) for detection will be. Perhaps include a pull down resistor as well on the A0 pin.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-11T07:37:06.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26197" PostTypeId="2" ParentId="26179" CreationDate="2016-07-11T07:45:22.353" Score="2" Body="&lt;p&gt;A quick search gave me the impression that MC16-0072 is actually some sort of rebranding. It seems MCM is not the manufacturer, simply a distributor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does the hardware itself have any number or serial printed on it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, when I dug a bit deeper and found &lt;a href=&quot;http://www.farnell.com/datasheets/168101.pdf?_ga=1.88928286.403328245.1468222988&quot; rel=&quot;nofollow&quot;&gt;this datasheet&lt;/a&gt;. However, without an image of your hardware or its serial number, I cannot confirm the datasheet is for your hardware.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-11T07:45:22.353" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26198" PostTypeId="2" ParentId="26167" CreationDate="2016-07-11T07:53:23.307" Score="1" Body="&lt;p&gt;I've worked with ESP8266 to create a centralized network over which different devices could communicate. In my first iteration I used an ESP8266 as an AP and let other ESP8266s connect to it. This didn't work for longer than 5 minutes. I suspected the ESP8266 couldn't handle many connections for a long period of time and bought an USB WiFi router. Now, I connected all ESP8266 to the WiFi router, including the ESP8266 that I set up as server. And it worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words: the ESP8266 isn't &lt;em&gt;strong&lt;/em&gt; enough to be an AP and communicate a lot of data at the same time. Instead, you'd rather like your ESP connect to an existing wireless network with other devices and let those devices connect to the IP of the ESP.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-11T07:53:23.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26199" PostTypeId="2" ParentId="26184" CreationDate="2016-07-11T08:35:37.977" Score="4" Body="&lt;p&gt;I'm not sure if it will not blow your memory limit as every pointer takes up 16 bits. But in C you usually do it this way:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void func1() {&#xA;    puts(&quot;Hello&quot;);&#xA;}&#xA;&#xA;void func2() {&#xA;    puts(&quot;World!&quot;);&#xA;}&#xA;&#xA;void func3() {&#xA;    puts(&quot;Array of Size 4&quot;);&#xA;}&#xA;&#xA;void func4() {&#xA;    puts(&quot;with Pointer&quot;);&#xA;}&#xA;&#xA;void func5() {&#xA;    puts(&quot;to a Function with no arguments&quot;);&#xA;}&#xA;&#xA;void func6() {&#xA;   puts(&quot;with return type void&quot;);&#xA;}&#xA;&#xA;void (* myFunc[6])() = { func1, func2, func3, func4, func5, func6 };&#xA;&#xA;int main(int argc, const char * argv[]) {&#xA;    for (int i = 0; i &amp;lt; 6; i++) {&#xA;        myFunc[i]();&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For explanation of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void (* myFunc[6])()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You read form inside to outside looking first to the right then to the left&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The variable is named myFunc.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFunc&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My func is an array of size 6.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFunc[6]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each of those entries is a Pointer.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;* myFunc[6]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we need parentheses to make clear, that we have a Pointer to a function with no arguments.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;(* myFunc[6])()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And its return type is void.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void (* myFunc[6])()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps a bit.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-07-11T08:35:37.977" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26200" PostTypeId="2" ParentId="26193" CreationDate="2016-07-11T08:37:54.303" Score="0" Body="&lt;p&gt;To debug this, as Len has suggested I would recommend putting in some Serial.println(&quot;Debug info&quot;) commands into your code. This will confirm that you are programming the Arduino as you expect, and that the Arduino is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this simply include a &lt;code&gt;Serial.begin(9600)&lt;/code&gt; command in your setup block, and then a &lt;code&gt;Serial.println(&quot;Some text&quot;)&lt;/code&gt; wherever you want to check if you are reaching a certain part of the code. You can then read these messages via the serial monitor (which you can get to from Tools-&gt;Serial Monitor in the Arduino IDE).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For hardware debugging if you have a multi-meter available I would check that you are getting 0V/5V on digital pin 3 when you expect (i.e. when you are / are not pressing the button). Also, to check your LEDs are working, and connected to the output pins you think they are, write a script which just scrolls through them with a short delay (See the &lt;code&gt;Blink&lt;/code&gt; example under File-&gt;Examples-&gt;01.Basics-&gt;Blink for an example of how to do that).&lt;/p&gt;&#xA;" OwnerUserId="23003" LastActivityDate="2016-07-11T08:37:54.303" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26201" PostTypeId="1" AcceptedAnswerId="26205" CreationDate="2016-07-11T08:39:52.120" Score="2" ViewCount="299" Body="&lt;p&gt;Hi i have an Arduino mega 2560 i send data from the Arduino over USB to PC. That works when i test a simple Serial.print(&quot;Hello&quot;); but that is not that what i need. I send a timestamp as a longe Value and the databyte as a short Value. When i send the timestamp as BIN like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      //Initialisisation&#xA;&#xA;const int RX = 0;&#xA;const int TX = 1;&#xA;const int RX1 = 19;&#xA;const int TX1 = 18;&#xA;unsigned long currentMillis;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(RX, INPUT);   //Readpin for USB&#xA;  pinMode(TX, OUTPUT);  //Writepin for USB&#xA;  pinMode(RX1, INPUT);  //Readpin for bus&#xA;  pinMode(TX1, OUTPUT); //Writepin for für bus&#xA;&#xA;  Serial.begin(38400);   //open interface for USB&#xA;  Serial1.begin(4800);   //open interface for bus&#xA;&#xA;  while (!Serial &amp;amp; !Serial1 &amp;amp;! Serial2)&#xA;  {&#xA;    ;//wait for serial port connect.&#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Ask if the timestamp over 8 hours, when yes,&#xA;  //send the time to the pc and reset currentMillis.&#xA;  currentMillis = millis();&#xA;  if (currentMillis &amp;gt;= 28800000)  //milli() 8 hours is a 4 byte  timestamp 28.800.000 millisec.&#xA;  {&#xA;    unsigned long timestamp = currentMillis;&#xA;    sendBinaryTime(timestamp);&#xA;    currentMillis = 0;&#xA;  }//end if&#xA;&#xA;  //if the businterface available, read a byte&#xA;  //and send it with the timestamp to the PC.&#xA;  //If the businterface not available send an error.&#xA;  //short incomingByte = Serial1.read();&#xA;  //sendBinaryValue(incomingByte);&#xA;  if(Serial1.available()&amp;gt;0) //if the bus (serial1) available?&#xA;    {&#xA;      short incomingByte = Serial1.read(); //read the next byte from _rx_buffer&#xA;      sendBinaryValue(incomingByte);&#xA;      sendBinaryTime(currentMillis);   //sendBinary send a long over the bus&#xA;    }//end if &#xA;}//end Loop()&#xA;&#xA;&#xA;//Methods for sending long values&#xA;&#xA;void sendBinaryValue(short incomingByte)&#xA;  {&#xA;    int temp = (incomingByte &amp;amp; 0xFF00)&amp;gt;&amp;gt;8;&#xA;    Serial.println(temp, HEX);&#xA;    temp = (incomingByte &amp;amp; 0x00FF);&#xA;    Serial.println(temp, HEX);&#xA;    return;&#xA;  }&#xA;&#xA;void sendBinaryTime(unsigned long currentMillis)//send milliseconds after every byte&#xA;{&#xA;  int temp = (currentMillis &amp;amp; 0xFF000000)&amp;gt;&amp;gt;24; //send 16 bit of the low value&#xA;  Serial.print(temp, BIN);&#xA;  temp = (currentMillis &amp;amp; 0x00FF0000)&amp;gt;&amp;gt;16;      //send 16 bit of the high value&#xA;  Serial.print(temp, BIN);&#xA;  temp = (currentMillis &amp;amp; 0x0000FF00)&amp;gt;&amp;gt;8;&#xA;  Serial.print(temp, BIN);&#xA;  temp = (currentMillis &amp;amp; 0x000000FF);&#xA;  Serial.print(temp, BIN);&#xA;  return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All is fine i haven´t any error. But i want the timestamp as DEC so i have changed the code to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;       void sendBinaryValue(short incomingByte)&#xA; {&#xA;   int temp = (incomingByte &amp;amp; 0xFF00)&amp;gt;&amp;gt;8;&#xA;   Serial.println(temp, HEX);&#xA;   temp = (incomingByte &amp;amp; 0x00FF);&#xA;   Serial.println(temp, HEX);&#xA;   return;&#xA; }&#xA;&#xA;void sendBinaryTime(unsigned long currentMillis)&#xA;{&#xA; int temp = (currentMillis &amp;amp; 0xFF000000)&amp;gt;&amp;gt;24;&#xA; Serial.print(temp, DEC);&#xA; temp = (currentMillis &amp;amp; 0x00FF0000)&amp;gt;&amp;gt;16;&#xA; Serial.print(temp, DEC);&#xA; temp = (currentMillis &amp;amp; 0x0000FF00)&amp;gt;&amp;gt;8;&#xA; Serial.print(temp, DEC);&#xA; temp = (currentMillis &amp;amp; 0x000000FF);&#xA; Serial.print(temp, DEC);&#xA; return;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now when i look on the serial monitor i get an error.&#xA;Here you can see it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/i7ruR.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/i7ruR.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I send an A as ASCII sign that must be Hex 41 and i receive a Hex 5 but why? When i send the timestamp as BIN i get the 41 and haven´t any problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope someone can help me with friendly wishes sniffi&lt;/p&gt;&#xA;" OwnerUserId="21214" LastEditorUserId="21214" LastEditDate="2016-07-11T09:05:51.170" LastActivityDate="2016-07-11T09:13:59.213" Title="Why send my Arduino sometime Hex and sometimes the wrong?" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26202" PostTypeId="2" ParentId="26184" CreationDate="2016-07-11T08:45:47.987" Score="5" Body="&lt;p&gt;This is not a direct answer to your question, as I have no such answer,&#xA;and I believe the answer you are seeking would be of no use to you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with your question is that your method of testing memory&#xA;usage is heavily flawed. By removing the &lt;code&gt;switch&lt;/code&gt; statement, you most&#xA;likely have allowed the linker to remove lots of methods referenced by&#xA;it, leading to huge memory savings. Those savings &lt;strong&gt;do not mean&lt;/strong&gt; the&#xA;culprit is the switch statement itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The correct way to test static memory usage is to use either&#xA;&lt;code&gt;avr-objdump&lt;/code&gt; or &lt;code&gt;avr-nm&lt;/code&gt;. You have to find where the IDE puts the&#xA;compiled elf file, then you can issue the command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-nm --size-sort -Crtd my_program.elf&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will give you a list of all symbols in your program sorted by size.&#xA;Symbols of type 't', 'w' and 'd' (upper or lower case) eat flash.&#xA;Symbols of type 'd', 'b' and 'v' eat RAM.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-11T08:45:47.987" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26204" PostTypeId="2" ParentId="26184" CreationDate="2016-07-11T09:11:26.133" Score="6" Body="&lt;p&gt;This all gets very much trickier than just an array of function pointers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your functions are methods in unknown objects. As such you can't have one single type that stores pointers to the functions in different objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple reason is that C++ changes the function prototype for you.  For instance, it changes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass {&#xA;    public:&#xA;        int myFunction(int size) { ... }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myFunction(MyClass *this, int size) { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For another class you end up with something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int myFunction(MyOtherClass *this, int size) { ... }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And that is a problem, because although you started with functions that, to you, look the same, they are actually very different. So you can't have one function pointer array with one type that can store either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One possible method is to use &lt;em&gt;polymorphism&lt;/em&gt;, where you have one &lt;em&gt;interface&lt;/em&gt; class that defines the interface your other classes use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyBaseClass {&#xA;    public:&#xA;        virtual int myFunction(int size) = 0;&#xA;};&#xA;&#xA;class MyClass : public MyBaseClass {&#xA;    public:&#xA;        int myFunction(int size) { ... }&#xA;};&#xA;&#xA;class MyOtherClass : public MyBaseClass {&#xA;    public:&#xA;        int myFunction(int size) { ... }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then access &lt;code&gt;myFunction()&lt;/code&gt; in either object as if it were in the class &lt;code&gt;MyBaseClass&lt;/code&gt;.  Instead of then storing pointers to the functions within the classes you can then store pointers to the classes themselves:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyBaseClass *classes[2];&#xA;&#xA;classes[0] = (MyBaseClass *)&amp;amp;myClassInstance;&#xA;classes[1] = (MyBaseClass *)&amp;amp;myOtherClassInstance;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And then access the functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x = classes[i]-&amp;gt;myFunction(z);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, this is all probably very much a moot point.  The &lt;code&gt;switch&lt;/code&gt; statement in your code is most likely not what is using all the memory, but all the classes are. By removing the switch you are most likely then not actually doing anything with the classes you have included, and so the linker is then stripping out all that now unreferenced code. A single &lt;code&gt;switch&lt;/code&gt;, unless it is an absolutely mammoth bit of code, won't take 20% of the Uno's flash. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-11T09:11:26.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26205" PostTypeId="2" ParentId="26201" CreationDate="2016-07-11T09:13:59.213" Score="1" Body="&lt;p&gt;I have found several problems with your program, although they may not&#xA;be related with your primary problem:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;while (!Serial &amp;amp; !Serial1 &amp;amp;! Serial2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You mean &lt;code&gt;while (!Serial || !Serial1 || !Serial2)&lt;/code&gt;, although this is&#xA;only useful with virtual serial ports, like on the Leonardo. On the&#xA;mega, all of these ports are real hardware ports.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void sendBinaryValue(short incomingByte)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The way you name the parameter is misleading: a &lt;code&gt;short&lt;/code&gt; is not a byte,&#xA;it's two bytes.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;int temp = (incomingByte &amp;amp; 0xFF00)&amp;gt;&amp;gt;8;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are bit-shifting a signed number, which is going to do a sign&#xA;extension. This is probably not what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.print(temp, DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are printing several numbers one after the other with no separator.&#xA;This is going to cause ambiguities: you cannot know whether &quot;345&quot; means&#xA;&quot;3 45&quot; or &quot;34 5&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I don't get the purpose of your functions. Why don't you just&#xA;print the numbers like this?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Serial.println(incomingByte, HEX);&#xA;Serial.println(currentMillis);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-11T09:13:59.213" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26209" PostTypeId="1" CreationDate="2016-07-11T12:39:03.340" Score="1" ViewCount="185" Body="&lt;p&gt;I have the same sketch one that I use at my desk and in the lab, but they are in different directories on the different computers.  This means that I have to change the paths to the includes which I have to fixup every time I transfer back and fourth.  Is there a way to put in a #ifdef that I can set at the start of the build that would include correct path.&lt;/p&gt;&#xA;" OwnerUserId="22868" LastActivityDate="2016-07-12T08:17:07.740" Title="How to use same sketch on two different computers in two different directories" Tags="|compile|build|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26211" PostTypeId="2" ParentId="26168" CreationDate="2016-07-11T14:21:41.717" Score="0" Body="&lt;p&gt;Here is a page on interfacing Arduino with Python.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Interfacing/Python&quot; rel=&quot;nofollow&quot;&gt;Interface Arduino with Python&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10219" LastActivityDate="2016-07-11T14:21:41.717" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26214" PostTypeId="1" CreationDate="2016-07-11T17:30:51.373" Score="0" ViewCount="1318" Body="&lt;p&gt;I'm trying to use micros() to measure the time it takes to execute an analogRead() cycle, but am having some issues.  Originally, I just printed out the measured time for the analogRead() right after doing the subtraction, but I wanted to change that to printing out all of the time values for the 100 loops at once.  When I print the start times, end times, and values both in the if statement (right after calculating them) and at the end, the values printed are the same.  I'm not sure if they're accurate because they fluctuate a lot within those 100 tests.  For example, some of these measured times consecutively are 216, 97, 153, 34, 89, 145, 27.  I put the ADC in freerun mode, so I figured it could be normal for that.  However, when I don't print the start times, end times, or values immediately after calculating them and instead try to print them in the else if statement, it gives a stream of values that are all either 407 or 408.  If I print &quot;Test&quot; instead of the values right after calculating them, it still gives the (I'm assuming) correct values that vary a lot, not the 407s.  If, instead of printing them in the if statement, I print them just in the general loop (currently commented out) and the else if statement, they are still the varying maybe-correct values.  I assumed that even if the values aren't being printed, they're still being stored in the array correctly.  I don't understand why printing something unrelated right after storing the values would change them.  Any ideas?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    int sensorPin = A1;    // select the input pin for the potentiometer&#xA;    int ledPin = 13;      // select the pin for the LED&#xA;    int sensorValue[1000];  // variable to store the value coming from the sensor&#xA;    int ind = 0;&#xA;    int starts[1000];&#xA;    int ends[1000];&#xA;    int vals[1000];&#xA;    int stopprint = 0;&#xA;    int i = 0;&#xA;    int countto = 100;&#xA;&#xA;    void setup() {&#xA;      // declare the ledPin as an OUTPUT:&#xA;      Serial.begin(57600);&#xA;      analogReadResolution(12);&#xA;      pinMode(ledPin, OUTPUT);&#xA;      Serial.println(&quot;ready to begin&quot;);&#xA;        analogReadSetup(A1);&#xA;      for (i = 0; i &amp;lt; 1000; i++) {&#xA;        starts[i] = 0;&#xA;        ends[i] = 0;&#xA;        vals[i] = 0;&#xA;      }&#xA;    }&#xA;&#xA;    void loop() {&#xA;      // read the value from the sensor:&#xA;      if (ind &amp;lt; countto) {&#xA;      starts[ind] = micros();&#xA;    //  delay(50);&#xA;      sensorValue[ind] = analogRead(sensorPin);&#xA;      ends[ind] = micros();&#xA;      vals[ind] = ends[ind] - starts[ind];&#xA;    //  Serial.println(&quot;Test&quot;);&#xA;        Serial.print(ind);&#xA;        Serial.print('\t');&#xA;        Serial.print(starts[ind]);&#xA;        Serial.print('\t');&#xA;        Serial.print(ends[ind]);&#xA;        Serial.print('\t');   &#xA;        Serial.print(vals[ind]);&#xA;        Serial.print('\t');&#xA;        Serial.print('|');&#xA;        Serial.print('\t');&#xA;      Serial.print('\n');&#xA;      Serial.print('\r');&#xA;      ind++;&#xA;      }&#xA;      else if (stopprint == 0) {&#xA;        Serial.println(&quot;~~~~~~~~~~~~~~~~~~~~~~~~~&quot;);&#xA;        for (int j = 0; j &amp;lt; countto; j++) {&#xA;    //        Serial.println(j);&#xA;            Serial.print(starts[j]);&#xA;            Serial.print('\t');&#xA;            Serial.print(ends[j]);&#xA;            Serial.print('\t');&#xA;            Serial.print(vals[j]);&#xA;            Serial.print('\n');&#xA;            Serial.print('\r');&#xA;            stopprint = 1;&#xA;        }&#xA;      }&#xA;      else if (stopprint == 1) {&#xA;        while(1);&#xA;      }&#xA;    //  Serial.print(ind-1);&#xA;    //  Serial.print('\t');&#xA;    //  Serial.print(starts[ind-1]);&#xA;    //  Serial.print('\t');&#xA;    //  Serial.print(ends[ind-1]);&#xA;    //  Serial.print('\t');&#xA;    //  Serial.print(vals[ind-1]);&#xA;    //  Serial.print('\n');&#xA;    //  Serial.print('\r');&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also, I'm using the Arduino Zero if it makes a difference.&lt;/p&gt;&#xA;" OwnerUserId="23804" LastActivityDate="2016-10-11T07:22:31.633" Title="Using micros() to measure analogRead() time varies based on Serial.print location?" Tags="|serial|analogread|adc|array|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26215" PostTypeId="2" ParentId="26214" CreationDate="2016-07-11T17:43:31.510" Score="1" Body="&lt;p&gt;Not sure if it is related to your problem but... if I were to try such a&#xA;measurement, I would use local variables, like&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned int start = micros();&#xA;int value = analogRead(sensorPin);&#xA;unsigned int end = micros();&#xA;sensorValue[ind] = value;&#xA;starts[ind] = start;&#xA;ends[ind] = end;&#xA;vals[ind] = end - start;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way you would be measuring the time it takes to call both&#xA;&lt;code&gt;analogRead()&lt;/code&gt; and &lt;code&gt;micros()&lt;/code&gt;, and very little more. If you do something&#xA;like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;sensorValue[ind] = analogRead(sensorPin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then you are also measuring the time taken by the pointer arithmetic and&#xA;the memory access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I generally program AVR-based Arduinos. These have a load-store&#xA;architecture, where saving to a local variable costs essentially&#xA;nothing, as the variable is typically assigned a CPU register by the&#xA;compiler. Saving to a global takes more time because of the RAM access.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no experience with ARM-based Arduinos, like the Zero, but I&#xA;believe it's also a load-store architecture, thus the same&#xA;considerations should probably apply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I tried the following experiment on my Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define PRINT_WHILE_READING&#xA;&#xA;#define READ_COUNT 100&#xA;&#xA;void setup() {&#xA;    unsigned int starts[READ_COUNT];&#xA;    unsigned int ends[READ_COUNT];&#xA;    unsigned int vals[READ_COUNT];&#xA;&#xA;    Serial.begin(57600);&#xA;    Serial.println(&quot;Ready to begin&quot;);&#xA;&#xA;    // Take the readings.&#xA;    for (int i = 0; i &amp;lt; READ_COUNT; i++) {&#xA;        starts[i] = micros();&#xA;        analogRead(A1);&#xA;        ends[i] = micros();&#xA;        vals[i] = ends[i] - starts[i];&#xA;#if defined(PRINT_WHILE_READING)&#xA;        Serial.print(i);&#xA;        Serial.print('\t');&#xA;        Serial.print(starts[i]);&#xA;        Serial.print('\t');&#xA;        Serial.print(ends[i]);&#xA;        Serial.print('\t');&#xA;        Serial.println(vals[i]);&#xA;#endif&#xA;    }&#xA;&#xA;#if !defined(PRINT_WHILE_READING)&#xA;    // Print them now.&#xA;    Serial.println(&quot;All data taken&quot;);&#xA;    for (int i = 0; i &amp;lt; READ_COUNT; i++) {&#xA;        Serial.print(i);&#xA;        Serial.print('\t');&#xA;        Serial.print(starts[i]);&#xA;        Serial.print('\t');&#xA;        Serial.print(ends[i]);&#xA;        Serial.print('\t');&#xA;        Serial.println(vals[i]);&#xA;    }&#xA;#endif&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;PRINT_WHILE_READING&lt;/code&gt; is defined as above, I get times that fluctuate&#xA;between 108 and 116&amp;nbsp;µs. If I comment out the line&#xA;&lt;code&gt;#define PRINT_WHILE_READING&lt;/code&gt;, I get mostly 116&amp;nbsp;µs and,&#xA;occasionally, 124&amp;nbsp;µs. In both cases, the first reading takes longer&#xA;(208 and 212&amp;nbsp;µs respectively).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The fact that the first reading takes longer is explained in the&#xA;datasheet: the ADC does some initializations in that first reading. All&#xA;measured times are multiples of 4&amp;nbsp;µs because that is the resolution&#xA;of &lt;code&gt;micros()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, trying to understand the differences between the two cases:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;With &lt;code&gt;PRINT_WHILE_READING&lt;/code&gt; the times are shorter on average. This is&#xA;because the numbers are not stored in RAM, as the compiler figured&#xA;out the arrays &lt;code&gt;starts[]&lt;/code&gt;, &lt;code&gt;ends[]&lt;/code&gt; and &lt;code&gt;vals[]&lt;/code&gt; are not really&#xA;needed and optimized them away. When &lt;code&gt;PRINT_WHILE_READING&lt;/code&gt; is not&#xA;defined, I can see the “store in RAM” instructions in the generated&#xA;assembly.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;With &lt;code&gt;PRINT_WHILE_READING&lt;/code&gt; the numbers fluctuate more. I guess this&#xA;is due to the printing through the serial port taking a variable&#xA;amount of time depending on the numbers being printed, and thus&#xA;creating timing inconsistencies.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The last point deserves some explanation. The ADC is clocked by a&#xA;prescaler that divides the frequency of the main clock by 128. This&#xA;gives a clock period of 8&amp;nbsp;µs. When an ADC conversion is started,&#xA;the ADC waits for the next rising edge of its clock, which can take&#xA;anywhere between 0 and 8&amp;nbsp;µs, then it does the conversion in&#xA;13&amp;nbsp;cycles of its clock. This means the whole process can take&#xA;anywhere between 104 and 112&amp;nbsp;µs depending on the exact time the&#xA;conversion is started relative to the phase of the prescaler. If the&#xA;conversions are started at irregular intervals, you expect to see&#xA;roughly 8&amp;nbsp;µs of fluctuation in the measured times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All these observations have been done on an Uno, which is based on an&#xA;AVR clocked at 16&amp;nbsp;MHz. I know the Zero is quite different. You will&#xA;have to look at the datasheet of the ATSAMD21G18 to see whether anything&#xA;of the above can be extrapolated to the Zero.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-07-12T09:39:02.277" LastActivityDate="2016-07-12T09:39:02.277" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26218" PostTypeId="1" CreationDate="2016-07-11T19:14:28.163" Score="1" ViewCount="5058" Body="&lt;p&gt;I set up communication between Arduino UNO and ESP 01 module. ESP replied to AT commands, but sometimes I got result from ESP uncompleted or with wrong characters, so I tried to set AT+IPR=9600, I didnt receive any output to this command and after reboot I only can see random characters on every baudrate, blue diode on ESP shines all the time. Is there any way how I can reset ESP 01 to default settings? Tried to set RESET pin to GND, but it didnt help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use remote power supply 3,3V/1A&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins connected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vcc = external power supply 3,3V&#xA;GND = GND (interconnected bot Arduino and power supply GND)&#xA;Tx = Arduino Rx(changed pin to 11 by SoftwareSerial)&#xA;Rx = Arduino Tx(changed pin to 10 by SoftwareSerial)&#xA;CH_PD - 3,3V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23739" LastActivityDate="2018-03-06T17:41:27.033" Title="ESP 01 - reset settings to default values" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26219" PostTypeId="1" AcceptedAnswerId="26221" CreationDate="2016-07-11T19:24:51.060" Score="1" ViewCount="52" Body="&lt;p&gt;I'm using an &lt;a href=&quot;http://www.micropik.com/PDF/HCSR04.pdf&quot; rel=&quot;nofollow&quot;&gt;HC-SR04 ultrasonic rangefinder&lt;/a&gt; to control the frequency at which an Arduino pin turns on and off, with the output going via a 1/4&quot; jack plug into my computer's audio interface. (i.e. it's a simple audio oscillator that responds to gestures). This is the code (based on that given &lt;a href=&quot;http://www.circuitbasics.com/how-to-set-up-an-ultrasonic-range-finder-on-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define trigPin 10&#xA;#define echoPin 12&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;  pinMode(9, OUTPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  float duration, distance;&#xA;  digitalWrite(trigPin, LOW); // Sends a 2 µs LOW signal to the trigPin     &#xA;  delayMicroseconds(30);&#xA;&#xA;  digitalWrite(trigPin, HIGH); // Sends a 10 µs HIGH signal to the trigPin&#xA;  delayMicroseconds(30);&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  duration = pulseIn(echoPin, HIGH); //Defines the duration variable&#xA;&#xA;&#xA;  digitalWrite(9, HIGH); //square wave oscillator &#xA;  delay(0.1+duration*0.01);&#xA;  digitalWrite(9, LOW);&#xA;  delay(0.1+duration*0.01);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pin 9 is the output, and sounds roughly as expected, but what's confusing me is that making any kind of gesture other than very slow ones (i.e. if the distance isn't changing very slowly) causes the output to stop completely for a few seconds, then start again, as if something is overloading and then resetting. What am I doing wrong?&lt;/p&gt;&#xA;" OwnerUserId="23811" OwnerDisplayName="JakaQuan" LastActivityDate="2016-07-11T20:04:29.520" Title="Arduino + ultrasonic rangefinder behaving unexpectedly" Tags="|audio|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26220" PostTypeId="2" ParentId="26219" CreationDate="2016-07-11T20:00:21.567" Score="0" Body="&lt;p&gt;Your comments don't match your timing delay values and the datasheet specifies a 10 µs pulse. You're giving it 30 µs but you might get away with it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd look at how often you're triggering the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qMUsU.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qMUsU.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Figure 1. Don't trigger the device more frequently than 40 times per second.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="13749" LastActivityDate="2016-07-11T20:00:21.567" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26221" PostTypeId="2" ParentId="26219" CreationDate="2016-07-11T20:04:29.520" Score="0" Body="&lt;p&gt;I do not really understand the behaviour of your program, but I would&#xA;like to point out a couple of points that may be problematic:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your comment says “Sends a 10 µs HIGH signal to the trigPin”, just as&#xA;the program you based yours on, yet you have a 30&amp;nbsp;µs delay. If&#xA;this extra delay makes you miss the rising edge on the echo pin, then&#xA;&lt;code&gt;pulseIn()&lt;/code&gt; will believe it is seen the &lt;em&gt;previous&lt;/em&gt; pulse, and it will&#xA;wait for the next raising edge before starting its measurement. Since&#xA;that next rising edge will never happen, &lt;code&gt;pulseIn()&lt;/code&gt; will eventually&#xA;time out after one second. This is probably the silence you are&#xA;hearing.&lt;/li&gt;&#xA;&lt;li&gt;Your sound frequency may not be what you expect, because the time&#xA;needed to run through the loop is not only the two calls to&#xA;&lt;code&gt;delay()&lt;/code&gt;, but also the time taken by &lt;code&gt;pulseIn()&lt;/code&gt; and the various&#xA;&lt;code&gt;delayMicroseconds()&lt;/code&gt;. You should have more consistent timings if you&#xA;use the &lt;code&gt;tone()&lt;/code&gt; function instead of trying to bit-bang the sound.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-11T20:04:29.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26223" PostTypeId="1" CreationDate="2016-07-11T20:53:21.213" Score="0" ViewCount="1176" Body="&lt;p&gt;I am developing a Wifi based Led light (Got Inspired from Philips hue, Lifx). I have little knowledge about web server, clients, Web protocols. I will be using ESP8266 as Controller cum WiFi module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two ways to control Led light over WiFi.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Locally&lt;/li&gt;&#xA;&lt;li&gt;Remotely&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Android/iOS app will be handling all the control part.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which protocols can I use to control Led light, locally? HTTP or Websockets? &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Note :- The speed is critical, android/iOS app can send around 50-60 values per second.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Also, which protocol should I go with if Led light is controlled Remotely.? So far, MQTT seems reliable. Any suggestion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly help!&lt;/p&gt;&#xA;" OwnerUserId="23271" LastEditorUserId="23271" LastEditDate="2016-07-11T20:59:01.707" LastActivityDate="2016-07-12T16:30:41.177" Title="Which Protocol to use to control WiFi (ESP8266) enabled Led Light" Tags="|arduino-ide|esp8266|wifi|rgb-led|http|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26224" PostTypeId="1" AcceptedAnswerId="26237" CreationDate="2016-07-11T22:39:41.910" Score="2" ViewCount="1620" Body="&lt;p&gt;I'm working on a quadrature encoder(with a 500ppr codewheel) with a Channel A, B and an Index pulse output.  Using an Arduino Mega I'm counting the number of pulses on Channel A on the rising edge. The code for counting pulses on channel A using an interrupt is straight forward enough with plenty of sources and examples out there to work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used the the code below to the count the pulses(in an increasing manner). What I'm trying to figure out is how I can reset the overall count using a second interrupt. The second interrupt is invoked when the Index channel pulses high.So in another words when the index channel pulses to indicate a full rotation on the code wheel the main count will reset to zero&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define CHA 2&#xA;#define CHB 3&#xA;#define CHI 19&#xA;&#xA;volatile int count = 0; &#xA;volatile byte INTFLAG1 = 0; &#xA;&#xA;void setup() &#xA;{ &#xA;  pinMode(CHA, INPUT);&#xA;  pinMode(CHB, INPUT);&#xA;  pinMode(CHI,INPUT);&#xA;&#xA;  Serial.begin(9600); &#xA;  Serial.println(count);&#xA;&#xA;  attachInterrupt(0, flag, RISING); &#xA;&#xA; }&#xA;&#xA;void loop() &#xA;   {&#xA;&#xA;       if (INTFLAG1)   &#xA;             {&#xA;               Serial.println(count);&#xA;               INTFLAG1 = 0; // clear flag&#xA;             } &#xA;&#xA;&#xA;    } &#xA;&#xA;&#xA;void flag()&#xA;    {&#xA;       INTFLAG1 = 1;&#xA;       if (digitalRead(CHA) &amp;amp;&amp;amp; !digitalRead(CHB)) &#xA;               {&#xA;                count++ ;&#xA;               }&#xA;     }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is it possible to implement the reset of the main pulse count with a second interrupt as described?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I've read interrupts work at the same level of priority- so I'm thinking there might be a problem here to implement this approach as the interrupts would have to be nested&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is appreciated if anyone has done anything like this using interrupts or can point me in  the right direction.&lt;/p&gt;&#xA;" OwnerUserId="23810" LastActivityDate="2016-07-12T08:06:33.413" Title="Quadrature Encoder:Interrupts: Reset Count" Tags="|arduino-mega|rotary-encoder|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26226" PostTypeId="1" CreationDate="2016-07-12T01:18:26.503" Score="1" ViewCount="672" Body="&lt;p&gt;I'm having this weird effect where my NeoPixel will blink/glitch after every cycle of a fading sketch. I'm not certain whether the issue is hardware or in my code. The blinking only occurs during the if statement portion of the code and not during the else statement which blinks red. I have tried multiple sources of power, 5V 2amp, 9V 1 amp, 12V 1amp and a Mac Usb and the problem persists on each power supply. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions or ideas would be greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;DistanceGP2Y0A21YK.h&amp;gt;&#xA;&#xA;#define PIN 6&#xA;#define PIXEL 16&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL, PIN, NEO_GRBW + NEO_KHZ800);&#xA;&#xA;&#xA;DistanceGP2Y0A21YK Dist;&#xA;int distance;&#xA;int R = 0;&#xA;int G = 0;&#xA;int B = 0;&#xA;&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show();&#xA;  strip.setBrightness(127);&#xA;&#xA;  Serial.begin(9600);&#xA;  Dist.begin(A0);&#xA;}&#xA;&#xA;void loop() {&#xA;  distance = Dist.getDistanceCentimeter();&#xA;  Serial.print(&quot;\nDistance in centimers: &quot;);&#xA;  Serial.print(distance);&#xA;  delay(2); //make it readable&#xA;&#xA;  if (distance &amp;gt; 10) {&#xA;&#xA;    for (R &amp;amp;&amp;amp; G &amp;amp;&amp;amp; B; R &amp;lt; 150 &amp;amp;&amp;amp; G &amp;lt; 150 &amp;amp;&amp;amp; B &amp;lt; 150; R++ &amp;amp;&amp;amp; G++ &amp;amp;&amp;amp; B++) {&#xA;      for (int i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, strip.Color(R, G, B));&#xA;        strip.show();&#xA;        delay(1);&#xA;      }&#xA;      delay(2);&#xA;    }&#xA;&#xA;    // fade off&#xA;    for (R &amp;amp;&amp;amp; G &amp;amp;&amp;amp; B; R &amp;gt; -1 &amp;amp;&amp;amp; G &amp;gt; -1 &amp;amp;&amp;amp; B &amp;gt; -1; R-- &amp;amp;&amp;amp; G-- &amp;amp;&amp;amp; B--) {&#xA;      for (int j = 0; j &amp;lt; strip.numPixels(); j++) {&#xA;        strip.setPixelColor(j, strip.Color(R, G, B));&#xA;        strip.show();&#xA;        delay(1);&#xA;      }&#xA;      delay(1);&#xA;    }&#xA;&#xA;  } else {&#xA;&#xA;    for (int j = 0; j &amp;lt; 256; j++) {&#xA;      for (int i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;        strip.setPixelColor(i, strip.Color(255, 0, 0));&#xA;        strip.show();&#xA;      }&#xA;      delay (1);&#xA;&#xA;      //blink off&#xA;      for (int j = 64; j &amp;gt; 0; j--) {&#xA;        for (int i = 0; i &amp;lt; strip.numPixels(); i++) {&#xA;          strip.setPixelColor(i, strip.Color(j, 0, 0));&#xA;          strip.show();&#xA;        }&#xA;        delay (2);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23778" LastEditorUserId="23120" LastEditDate="2016-07-12T16:47:35.430" LastActivityDate="2016-07-12T16:47:35.430" Title="NeoPixel Blink/Glitch" Tags="|arduino-uno|neopixel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26227" PostTypeId="2" ParentId="26218" CreationDate="2016-07-12T01:46:03.540" Score="1" Body="&lt;p&gt;Current ESP-01 firmware versions do not have an &lt;code&gt;AT+IPR&lt;/code&gt; command. If you're trying to change the ESP's baud rate to use it with SoftwareSerial, the command to do so (in recent versions of the firmware) is: &lt;code&gt;AT+UART=9600,8,1,0,0&lt;/code&gt; for 9600 baud, 1 stop bit, no parity, no flow control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The full syntax is:&lt;br&gt; &lt;code&gt;AT+UART=&amp;lt;baudrate&amp;gt;, &amp;lt;databits&amp;gt;, &amp;lt;stopbits&amp;gt;, &amp;lt;parity&amp;gt;, &amp;lt;flow control&amp;gt;&lt;/code&gt;&lt;br&gt;, where &amp;lt;databits&amp;gt; is the number of data bits per frame, 5,6,7,or 8; &amp;lt;stopbits&amp;gt; is 1, 2, or 3 for 1, 1.5, or 2 stopbits (respectively); &amp;lt;parity&amp;gt; is 0, 1, or 2 for None, Odd, Even (respectively); and &amp;lt;flow control&amp;gt; is 0, 1, 2, or 3 for None, RTS, CTS, RTS and CTS (respectively). Most serial communication and devices that most of us will ever see will be 8 data bits, no parity, and 1 stop bit, abbreviated as &quot;8N1&quot;. Flow control is sometimes used, but often it is contained in the data stream itself, such as sending &lt;kbd&gt;Ctl-S&lt;/kbd&gt; and &lt;kbd&gt;Ctl-Q&lt;/kbd&gt; from the keyboard to manually stop and resume incoming data transmission.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="26916" LastEditDate="2017-11-06T13:44:50.000" LastActivityDate="2017-11-06T13:44:50.000" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26228" PostTypeId="1" AcceptedAnswerId="26230" CreationDate="2016-07-12T02:16:19.580" Score="5" ViewCount="2256" Body="&lt;p&gt;I used my Arduino Uno's pin 3 to generate a &lt;a href=&quot;http://en.wikipedia.org/wiki/Pulse-width_modulation&quot; rel=&quot;nofollow noreferrer&quot;&gt;PWM&lt;/a&gt; output. The code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // Put your setup code here, to run once:&#xA;}&#xA;&#xA;void loop() {&#xA;  analogWrite(3, 180);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I connected the output directly with a oscilloscope.&#xA;And the output waveform is shown below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5tVdR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5tVdR.jpg&quot; alt=&quot;PWM waveform&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found it's weird that the minimum voltage is negative! And with the duty cycle increasing, both the maximum voltage and minimum voltage decrease.&#xA;Why does it behave in such a way?&lt;/p&gt;&#xA;" OwnerUserId="20002" LastEditorUserId="510" LastEditDate="2016-07-12T12:13:26.120" LastActivityDate="2022-09-01T00:03:11.250" Title="Why do I get negative voltages for a PWM waveform?" Tags="|arduino-uno|pwm|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26230" PostTypeId="2" ParentId="26228" CreationDate="2016-07-12T04:05:57.783" Score="13" Body="&lt;p&gt;At first you had the scope AC (Alternating Current) coupled.  Then you switched it to DC (Direct Current) coupled.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AC coupling is used to remove the DC component of a signal.  It places a large capacitor between the probe and the internal amplifier.  This is used, for instance, if you want to see a small signal with a large DC offset.  But it can also attenuate and / or alter signals that are low in frequency.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When a PWM signal is AC coupled to an oscilloscope, an interesting phenomenon occurs.  As the duty cycle goes from a minimum (almost always off) to a maximum (almost always on) the DC component of the PWM signal changes.  Since the DC component is blocked by the AC coupling, the PWM signal appears to move lower on the screen as the duty cycle increases.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;DC coupling is where there is no coupling capacitor between the probe and the internal amplifier.  Everything comes through.  For digital electronics where the signal travels a small distance from 0 to 5 volts or from 0 to 3.3 volts, this is the best way to use the scope.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-12T04:05:57.783" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26231" PostTypeId="1" CreationDate="2016-07-12T04:26:23.023" Score="1" ViewCount="310" Body="&lt;p&gt;I send data from arduino by method following.&#xA;Configure the value : byte message[ ];&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define RX 2&#xA;#define TX 3&#xA;int incomingByte = 0;&#xA;&#xA;SoftwareSerial mySerial(RX, TX);&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(5, OUTPUT);&#xA;&#xA;  Serial.begin(9600);&#xA;  mySerial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  incomingByte = Serial.read();&#xA;&#xA;  if (incomingByte == 's')&#xA;  {&#xA;    digitalWrite(5, HIGH);&#xA;    byte message[] = {0x01, 0x06, 0x00, 0x01, 0x02, 0x58, 0xD8, 0x90} ;&#xA;    mySerial.write(message1, sizeof(message1));&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It works. But I want to input from &quot;Serial monitor&quot; to set the temperature.&#xA;It does not work when input from &quot;Serial monitor&quot;.&lt;/p&gt;&#xA;" OwnerUserId="23817" LastEditorUserId="23817" LastEditDate="2016-07-12T07:57:02.970" LastActivityDate="2016-07-12T07:57:02.970" Title="How to send data from arduino to Temp Controller for setting temp?" Tags="|softwareserial|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26232" PostTypeId="2" ParentId="26190" CreationDate="2016-07-12T05:47:32.867" Score="2" Body="&lt;p&gt;I got my RFID kit (RF522) just this week, but I haven't had a chance to play with it yet - nor do I have an NTAG216 implant. But I remember when I was researching them seeing a couple of posts that had to do with &quot;Authentication errors&quot;. The problem for you (maybe) is that they were in Python rather than C:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mxgxw/MFRC522-python/issues/24&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mxgxw/MFRC522-python/issues/24&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and Cotix's link&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/mj3052/MFRC522-Pi&quot; rel=&quot;nofollow&quot;&gt;https://github.com/mj3052/MFRC522-Pi&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Give them a lookover and see what they can tell you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem with the &lt;code&gt;PICC_IsNewCardPresent()&lt;/code&gt; function is that it gives a Yes/No answer, not a &quot;Yes, but there's an error&quot;. In that case it would also return &lt;code&gt;false&lt;/code&gt;. But the other code may give you a clue - you'll have to delve into the library...&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-12T05:47:32.867" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26235" PostTypeId="2" ParentId="26231" CreationDate="2016-07-12T07:24:36.063" Score="1" Body="&lt;p&gt;You're not writing any data to incomingByte and you're not detecting if data is sent towards the Arduino over serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should change your &lt;code&gt;void loop()&lt;/code&gt; into this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;&#xA;  //Detects if something is sent over serial.&#xA;  if(Serial.available() &amp;gt; 0){&#xA;&#xA;    //reads the byte and puts it into the incomingByte variable&#xA;    incomingByte = Serial.read();&#xA;&#xA;    //below is your old code&#xA;    if (incomingByte == 's') {&#xA;      digitalWrite(5, HIGH);&#xA;      byte message[] = {0x01, 0x06, 0x00, 0x01, 0x02, 0x58, 0xD8, 0x90} ;&#xA;      mySerial.write(message1, sizeof(message1));&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you're using the serial monitor to send data towards the Arduino, also make sure the baudrate you use is the same as the Arduino's. In this case you set your baudrate to 9600 &lt;code&gt;Serial.begin(9600)&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastEditorUserId="23788" LastEditDate="2016-07-12T07:47:41.443" LastActivityDate="2016-07-12T07:47:41.443" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26237" PostTypeId="2" ParentId="26224" CreationDate="2016-07-12T08:06:33.413" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to implement the reset of the main pulse count with a&#xA;  second interrupt as described?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, and it's quite straightforward. Your index signal goes to pin 19,&#xA;which is interrupt 4 on the Mega, so you can simply&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;attachInterrupt(4, reset, RISING);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;in &lt;code&gt;setup()&lt;/code&gt;, where &lt;code&gt;reset()&lt;/code&gt; is a function that resets the counter:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void reset()&#xA;{&#xA;    count = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm thinking there might be a problem here to implement this approach&#xA;  as the interrupts would have to be nested&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In general you do not want to nest interrupts. If an interrupt is being&#xA;serviced when a second interrupt fires, the second one will just wait&#xA;for the first one to finish. This approach works fine as long as you do&#xA;not have interrupt handlers that take too long to execute.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-12T08:06:33.413" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26238" PostTypeId="2" ParentId="26209" CreationDate="2016-07-12T08:17:07.740" Score="1" Body="&lt;p&gt;Open &lt;code&gt;preferences.txt&lt;/code&gt; in &lt;code&gt;C:\Users\YourUserName\AppData\Roaming\Arduino&lt;/code&gt; and change the path of &lt;code&gt;sketchbook.path=C:\Users\YourUserName\Documents\Arduino&lt;/code&gt; to &lt;code&gt;sketchbook.path=YourDesiredPath&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-12T08:17:07.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26240" PostTypeId="1" AcceptedAnswerId="26277" CreationDate="2016-07-12T09:01:13.887" Score="2" ViewCount="10816" Body="&lt;p&gt;I am using Arduino UNO and SIM 900A. Pins 0 and 1 are used as TX and RX. Is it possible to use any other pins? &lt;/p&gt;&#xA;" OwnerUserId="23686" LastEditorUserId="4358" LastEditDate="2016-07-12T23:32:48.650" LastActivityDate="2019-03-30T06:55:41.127" Title="Which pins of an Arduino UNO can be used as Tx and Rx pins for connecting to GSM GPRS SIM 900A" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26241" PostTypeId="2" ParentId="26218" CreationDate="2016-07-12T09:44:21.240" Score="0" Body="&lt;p&gt;While this technically is not an answer, I can highly suggest the ESP 8266 Arduino library. This way you can program in the Arduino IDE and upload to the ESP module. It's so much faster and efficient than AT commands and because you can see the code in the IDE, you have a better overview of what is happening in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/esp8266/Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/esp8266/Arduino&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-12T09:44:21.240" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26242" PostTypeId="1" AcceptedAnswerId="26243" CreationDate="2016-07-12T10:01:35.297" Score="0" ViewCount="127" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NDGro.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NDGro.jpg&quot; alt=&quot;Image of my setup&quot;&gt;&lt;/a&gt;I am making a simple bipedal robot. I have four 9g servos connected to my uno. Whenever I try to even do the simplest command, like move right foot 45 degrees it does not work properly. I have tried on my second Uno and i have the same result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My program for testing the servos:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo;&#xA;&#xA;void setup(){&#xA;myservo.attach(6);&#xA;}&#xA;&#xA;void loop(){&#xA; myservo.write(45); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Each servo wire is attached to a breadboard where they all share power and ground from the arduino. Each servo wire then has another wire going to pins 3,5,6 and 9.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone know what the problem is and what I can do? Thanks&lt;/p&gt;&#xA;" OwnerUserId="23822" LastEditorUserId="23822" LastEditDate="2016-07-12T11:50:09.157" LastActivityDate="2017-04-02T22:47:52.463" Title="I have four servos connected to an arduiono uno and I cannot control them" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26243" PostTypeId="2" ParentId="26242" CreationDate="2016-07-12T10:16:15.683" Score="0" Body="&lt;p&gt;An Arduino is not capable of powering four servos. Power them externally, but make sure the ground of the Arduino and servos is connected.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-12T10:16:15.683" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="26245" PostTypeId="2" ParentId="26226" CreationDate="2016-07-12T11:49:49.287" Score="1" Body="&lt;pre&gt;&lt;code&gt;for (int j = 0; j &amp;lt; 256; j++) {&#xA;&#xA;  ...&#xA;&#xA;  //blink off&#xA;  for (int j = 64; j &amp;gt; 0; j--) {&#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that you are re-declaring the variable &lt;code&gt;j&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-12T11:49:49.287" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26246" PostTypeId="1" CreationDate="2016-07-12T11:58:29.120" Score="1" ViewCount="494" Body="&lt;p&gt;I'm using a Arduino Uno Rev 3 connected over usb to a Raspberry Pi Modell B+ running Rasbian. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here ist the arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int input = 0;&#xA;String command = &quot;&quot;; // beinhaltet den aktuellen befehl&#xA;int Action = 1;&#xA;&#xA;void setup() {&#xA;Serial.begin (9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (Serial.available() &amp;gt; 0) &#xA;  {&#xA;        input = Serial.read();&#xA;    char currentChar = input;&#xA;&#xA;    if(currentChar  == '!') // frage nach trennzeichen&#xA;    {&#xA;      Serial.println(command);&#xA;      //Serial.write(Action);&#xA;      Action = command.toInt();&#xA;&#xA;      command = &quot;&quot;; // befehl wieder leeren&#xA;    }else&#xA;    {&#xA;      command = command + currentChar ; // falls noch kein trennzeichen vorhanden, erweitere kommando&#xA;    }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the Raspberry Pi code (in python)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import serial&#xA;from time import sleep as sleep&#xA;ser = serial.Serial('/dev/ttyACM0',9600)&#xA;s = [0]&#xA;while True:&#xA;        ser.write(b'2!')&#xA;        a =  ser.read(1)&#xA;        print a&#xA;sleep(2)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It always works if once after the code was uploaded to the arduino, but if I stop the script on the pi and restart it it stops working. What is the problem here?&lt;/p&gt;&#xA;" OwnerUserId="23825" LastActivityDate="2016-12-28T21:02:38.530" Title="Serial communication between arduino and raspberry pi works once, then stops working" Tags="|arduino-uno|serial|raspberrypi|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26249" PostTypeId="2" ParentId="18361" CreationDate="2016-07-12T12:48:20.247" Score="-1" Body="&lt;p&gt;All TM chip Family is supported by Fastled Libs if you use a TM1811 just put TM1809.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should work, I have tried and it succeeded.&lt;/p&gt;&#xA;" OwnerUserId="23828" LastEditorUserId="19515" LastEditDate="2016-07-13T03:23:18.820" LastActivityDate="2016-07-13T03:23:18.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26251" PostTypeId="2" ParentId="25719" CreationDate="2016-07-12T14:45:03.503" Score="1" Body="&lt;p&gt;Perhaps you need to reset wiffi. Press for 3 seconds. After this you must await for a while. Some leds will open and close. This process takes about 2 or 3 minutes. After this. Your white led will be flashing. That is all.&#xA;Have in mind some points:&#xA;First time you have to connect your yun by usb. Then you have to openIDE and choose IP PORT which will be showed(192.168....). Then go to your browser and type Ip and configurate your yun for wifi.&lt;/p&gt;&#xA;" OwnerUserId="23813" LastActivityDate="2016-07-12T14:45:03.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26252" PostTypeId="1" AcceptedAnswerId="30103" CreationDate="2016-07-12T14:52:08.367" Score="2" ViewCount="320" Body="&lt;p&gt;I recently flashed bootloader of Arduino to Atmega8. Unfortunately I stumbled on a problem I can't solved.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am testing SerialEvent example on Atmega8. I modified it but started debugging it on my code (I think the same problem stops SerialEvent example from working).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the Atmega8 reads the characters sent through serial wrongly. That's why &lt;em&gt;SerialEvent&lt;/em&gt; 'if' condition doesn't work also. Because it never gets '\n' symbol (it receives it but wrongly interprets it).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean prevState = true;&#xA;boolean OnOff = false;&#xA;boolean stringComplete = false;&#xA;String inputString = &quot;&quot;;&#xA;String OnString = &quot;on\n&quot;;&#xA;String OffString = &quot;off\n&quot;;&#xA;&#xA;void setup() {&#xA;    Serial.begin(1200);&#xA;&#xA;    while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;    }&#xA;&#xA;    // reserve 200 bytes for the inputString&#xA;    inputString.reserve(200);&#xA;&#xA;    DDRD |= 0b00001100;&#xA;    PORTD |= _BV(PD2);&#xA;&#xA;    // synchronization info for RPi&#xA;    Serial.println(&quot;ARD - OK\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;    // turn on&#xA;    if (OnOff == true &amp;amp;&amp;amp; prevState == false){&#xA;        PORTD |= _BV(PD2);&#xA;        prevState = OnOff;&#xA;    }&#xA;    // turn off&#xA;    if (OnOff == false &amp;amp;&amp;amp; prevState == true){&#xA;        PORTD &amp;amp;= ~_BV(PD2);&#xA;        prevState = OnOff;&#xA;    }&#xA;&#xA;    if (stringComplete) {&#xA;        Serial.println(inputString);&#xA;        // clear the string:&#xA;        inputString = &quot;&quot;;&#xA;        stringComplete = false;&#xA;    }&#xA;}&#xA;&#xA;void serialEvent() {&#xA;    while (Serial.available()) {&#xA;         // get the new byte:&#xA;        char inChar = (char)Serial.read();&#xA;        // add it to the inputString:&#xA;        inputString += inChar;&#xA;        // if the incoming character is a newline, set a flag&#xA;        // so the main loop can do something about it:&#xA;        Serial.println(inputString);&#xA;        if (inChar == '\n') {&#xA;            stringComplete = true;&#xA;            Serial.println(&quot;test\n&quot;);&#xA;        }&#xA;&#xA;        if (stringComplete &amp;amp;&amp;amp; inputString.equals(OnString)){&#xA;            OnOff = true;&#xA;            Serial.println(&quot;Turning on.\n&quot;);&#xA;        }&#xA;        else if (stringComplete &amp;amp;&amp;amp; inputString.equals(OffString)){&#xA;            OnOff = false;&#xA;            Serial.println(&quot;Turning off.\n&quot;);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I tested a lot of behaviors. Below I attach one of the tests from Realterm:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/E0N37.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/E0N37.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First I reset the board - it responded with 'ARD - OK\n' - expected behavior.&#xA;Then I sent 'on\n' and it responded with two lines but the characters aren't the same as 'on\n'.&#xA;Then I sent 'test123\n' but once again got wrong characters.&#xA;It prints multiple lines because it sends the string in which it accumulates the data every time &lt;em&gt;SerialEvent()&lt;/em&gt; is fired.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also sending for example variabl &lt;em&gt;OnString&lt;/em&gt; works ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really don't know why is it acting like that... Help would be appreciated :).&lt;/p&gt;&#xA;" OwnerUserId="23833" LastActivityDate="2016-10-11T14:46:52.983" Title="Atmega8 with Arduino bootloader - wrong serial characters" Tags="|arduino-uno|serial|bootloader|" AnswerCount="2" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26253" PostTypeId="2" ParentId="26223" CreationDate="2016-07-12T16:30:41.177" Score="1" Body="&lt;p&gt;UDP :D&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seriously though, ESP8266 is limited in resources, AND you want to send 50-60 updates a second, just UDP will be the most lightweight, and you won't run out of connections (5 I think on ESP), because UDP has no connection state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what was used here to control a RGB strip: &lt;a href=&quot;https://github.com/cnlohr/esp8266ws2812i2s&quot; rel=&quot;nofollow&quot;&gt;https://github.com/cnlohr/esp8266ws2812i2s&lt;/a&gt; , it just listens for UDP packets on port 7777, and each packet contains rgb values, one byte for R,G,B, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;MQTT is nice, but it doesn't work well for 60hz updates, &lt;em&gt;I Tried&lt;/em&gt; :D&#xA;It resulted in un-smooth animation, and frames out of order.&lt;/p&gt;&#xA;" OwnerUserId="23645" LastActivityDate="2016-07-12T16:30:41.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26257" PostTypeId="1" CreationDate="2016-07-12T19:43:03.883" Score="0" ViewCount="713" Body="&lt;p&gt;Given:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I have some home alarm peripherals (motion detectors, glass break sensors) which operate at 12V and draw a nominal current of 20mA when in alarm state.&lt;/li&gt;&#xA;&lt;li&gt;I have a Particle Photon (3.3V logic level) which will accept up to 5.6V on its VIN pin.&lt;/li&gt;&#xA;&lt;li&gt;I have a 12V @ 2A switching power supply.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Can someone describe to me an efficient circuit which would allow me to power all of the peripherals @ 12V and the Arduino (Particle Photon) at 3.3ishV?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have on hand an LM7805 linear regulator, which I believe will work, but will be inefficient. I also have on hand a DC-DC step down converter (4.5V-28V IN, 0.8V-20V OUT @ 2A) but I am a novice and don't know how to use it for the scenario described here.&lt;/p&gt;&#xA;" OwnerUserId="23840" LastActivityDate="2017-11-28T01:28:59.430" Title="Powering 3.3V Arduino and 12V peripherals from single 12V power supply?" Tags="|power|voltage-level|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26258" PostTypeId="2" ParentId="26185" CreationDate="2016-07-12T19:52:50.367" Score="3" Body="&lt;p&gt;There is one huge pitfall in Master Mode in this ATMega - Select Slave pin (/SS - active low). If it's configured as input, SPI is switched to Slave Mode by low level on this pin. And /SS is on pin PB2 (used as CAN_INT).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the &lt;a href=&quot;https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library/blob/master/src/defaults.h&quot; rel=&quot;nofollow noreferrer&quot;&gt;library defaults&lt;/a&gt; I can see: &lt;code&gt;#define    MCP2515_INT D,2&lt;/code&gt;. PD2 is also INT0 external interrupt pin, so it does make sense to be here and it can be used with attachInterrupt. PB2 is used as an output for selecting slave device, so it's ok too.&lt;br&gt;&#xA;&lt;a href=&quot;http://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/SparkFun_CAN-Bus_Shield_v13a.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Schematics&lt;/a&gt; corresponds with that defaults:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/v6Zoo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v6Zoo.png&quot; alt=&quot;shield interface&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In OPs schematics there are slight changes. Interrupt request CAN_INT is located on /SS pin (PB2, arduino pin 10). CAN_CS was moved from PB2 to PB1 (arduino pin 10 -&gt; pin 9)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And in &lt;a href=&quot;http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Mega328&lt;/a&gt; datasheet is section: 19.2 SS Pin Functionality:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;19.3.2 Master Mode&lt;/strong&gt;&lt;br&gt;&lt;br&gt;&#xA;  When the SPI is configured as a Master (MSTR in SPCR is set), the user can determine the direction of the /SS&#xA;  pin.&lt;br&gt;&lt;br&gt;&#xA;  If /SS is configured as an output, the pin is a general output pin which does not affect the SPI system. Typically,&#xA;  the pin will be driving the SS pin of the SPI Slave.&lt;br&gt;&lt;br&gt;&#xA;  &lt;strong&gt;If /SS is configured as an input, it must be held high to ensure Master SPI operation. If the /SS pin is driven low by&#xA;  peripheral circuitry when the SPI is configured as a Master with the /SS pin defined as an input, the SPI system&#xA;  interprets this as another master selecting the SPI as a slave and starting to send data to it.&lt;/strong&gt;&lt;br&gt; To avoid bus&#xA;  contention, the SPI system takes the following actions:&lt;br&gt;&#xA;  1. The MSTR bit in SPCR is cleared and the SPI system becomes a Slave. As a result of the SPI becoming a Slave, the MOSI and SCK pins become inputs.&lt;br&gt;&#xA;  2. The SPIF Flag in SPSR is set, and if the SPI interrupt is enabled, and the I-bit in SREG is set, the interrupt&#xA;  routine will be executed.&lt;br&gt;&#xA;  Thus, when interrupt-driven SPI transmission is used in Master mode, and there exists a possibility that SS is&#xA;  driven low, the interrupt should always check that the MSTR bit is still set. If the MSTR bit has been cleared by&#xA;  a slave select, it must be set by the user to re-enable SPI Master mode.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;: If you are using HW SPI in master mode, you can't just use pin 10 (PB2) as general input.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-07-26T12:35:13.777" LastActivityDate="2016-07-26T12:35:13.777" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="26260" PostTypeId="1" AcceptedAnswerId="26271" CreationDate="2016-07-12T20:29:56.440" Score="6" ViewCount="533" Body="&lt;p&gt;I'm having some trouble conceptualizing how to go about implementing PID into my drone. There are a few ways I'm thinking about implementing the pipeline:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Having one PID Object for each of the six motors.&lt;/li&gt;&#xA;&lt;li&gt;Having one PID Object for each axis.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;How I would implement PIDs on a per-motor basis?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wn221.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wn221.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How I would implement PIDs on a per-axis basis?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/suknF.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/suknF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing that the second one will be the best course of action, as it can all be put into its own loop, where the PID data will be available on-demand, as opposed to calculating it on the spot. It is object-oriented, and runs in the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first one has its appeals, too. It eliminates some of the calculations needed in order to find the actual value. It is procedural, and very straightforward and performs on the spot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What do you guys think?&lt;/p&gt;&#xA;" OwnerUserId="15994" LastEditorUserId="4628" LastEditDate="2016-12-10T09:13:30.573" LastActivityDate="2017-10-07T01:29:52.303" Title="What is the proper way to implement PID?" Tags="|arduino-due|remote-control|code-optimization|pid|drone|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26261" PostTypeId="2" ParentId="26164" CreationDate="2016-07-12T20:33:34.433" Score="2" Body="&lt;p&gt;SPI pins are located on different pins in Arduino Mega. You have to wire it correctly with your shield. Some shields uses ICSP (6-pin header) for better compatibility but this one doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;Arduino SPI Reference&lt;/a&gt; for more details (section: Connections)&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-12T20:33:34.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26262" PostTypeId="1" AcceptedAnswerId="26267" CreationDate="2016-07-12T20:52:16.043" Score="0" ViewCount="148" Body="&lt;p&gt;I have this code, in which I try to &quot;glue&quot; four bytes in order to construct an unsigned int. I shift left the bytes and &quot;add&quot; them using the OR operator.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long number1;   &#xA;unsigned long number2;&#xA;unsigned long number3=0;&#xA;&#xA;byte byte0 = 1;&#xA;byte byte1 = 40;&#xA;byte byte2 = 107;&#xA;byte byte3 = 238;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  number1 = byte1 &amp;lt;&amp;lt;8 | byte0 ;  //(=10.241 O.K.)&#xA;&#xA;  //(should be 4.000.000.001, it produces 10.241)&#xA;  number2 = byte3 &amp;lt;&amp;lt;24 | byte2 &amp;lt;&amp;lt;16 | byte1 &amp;lt;&amp;lt;8 | byte0;  &#xA;&#xA;  //(should be 4.000.000.001, it produces 4.016.777.217)&#xA;  number3 = number3 | byte3;&#xA;  number3 = number3&amp;lt;&amp;lt;8;&#xA;  number3 = number3 | byte2;&#xA;  number3 = number3&amp;lt;&amp;lt;8;&#xA;  number3 = number3 | byte1;&#xA;  number3 = number3&amp;lt;&amp;lt;8;&#xA;  number3 = number3 | byte0;  &#xA;&#xA;  Serial.print(&quot;number1 = &quot;);Serial.println(number1);  &#xA;  Serial.print(&quot;number2 = &quot;);Serial.println(number2);   &#xA;  Serial.print(&quot;number3 = &quot;);Serial.println(number3);       &#xA;  Serial.println(&quot; &quot;);  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the OR operator applies only to &lt;code&gt;byte1 &amp;lt;&amp;lt;8 | byte0&lt;/code&gt; and ignores the rest. That is number1 and number2 appear to have the same value &lt;em&gt;(10241)&lt;/em&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried &quot;adding&quot; them up separately, as shown with number3, but it also produces a wrong result as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried the same code in python, and it works fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte3, byte2, byte1, byte0 = 238, 107, 40, 1&#xA;print byte1 &amp;lt;&amp;lt;8 | byte0&#xA;print byte3 &amp;lt;&amp;lt;24 | byte2 &amp;lt;&amp;lt;16 | byte1 &amp;lt;&amp;lt;8 | byte0&#xA;&#xA;number3 = 0;&#xA;number3 = number3 | byte3;&#xA;number3 = number3&amp;lt;&amp;lt;8;&#xA;number3 = number3 | byte2;&#xA;number3 = number3&amp;lt;&amp;lt;8;&#xA;number3 = number3 | byte1;&#xA;number3 = number3&amp;lt;&amp;lt;8;&#xA;number3 = number3 | byte0;&#xA;print number3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, the question is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why both number2 and number3 produce a false result?&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-07-12T21:56:28.020" Title="problem with bitwise OR" Tags="|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26265" PostTypeId="1" AcceptedAnswerId="26284" CreationDate="2016-07-12T21:09:51.573" Score="2" ViewCount="2742" Body="&lt;p&gt;I have very little experience with the Arduino and am hoping that you may provide me with some helpful info.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to build a device that records time spent on a project.  I envision the main Uno with a switch, microSD breakout, and an LED to indicate its tracking your time. When setup the user could simply press the switch/button (light up the LED to show you're &quot;working&quot;) and while you plug away on your day job the Uno will track the time between switch on and switch off. Then at the time the switch is turned off, have the Uno write a simple data file containing the total time spent on that activity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a basic idea of what I need hardware wise, but am hoping to find insight to the backbone of software programming to make something like this begin to take shape.&lt;/p&gt;&#xA;" OwnerUserId="23847" LastEditorUserId="26916" LastEditDate="2017-09-08T23:19:29.067" LastActivityDate="2017-09-09T01:17:37.733" Title="Record a duration of time as data" Tags="|time|software|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26266" PostTypeId="1" AcceptedAnswerId="26268" CreationDate="2016-07-12T21:44:54.403" Score="1" ViewCount="893" Body="&lt;p&gt;Since the maximum value of a float variable is 3.4028235E+38, shouldn't it represented with 128 bits instead of 32? &lt;em&gt;(2^128=3.4028235E+38)&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2016-07-13T18:11:03.133" Title="which is the number of bits in a float variable" Tags="|programming|" AnswerCount="4" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26267" PostTypeId="2" ParentId="26262" CreationDate="2016-07-12T21:56:28.020" Score="1" Body="&lt;p&gt;Correction from another answer for number2:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;number2 = (unsigned long)byte3 &amp;lt;&amp;lt;24 | (unsigned long)byte2 &amp;lt;&amp;lt;16 | byte1 &amp;lt;&amp;lt;8 | byte0; // = 4.000.000.001&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And in the first round of loop number3 is correct, all others are wrong as number3 holds a result from previous loop.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  number3 = byte3; // all magic lays here&#xA;  number3 &amp;lt;&amp;lt;= 8;&#xA;  number3 |= byte2;&#xA;  number3 &amp;lt;&amp;lt;= 8;&#xA;  number3 |= byte1;&#xA;  number3 &amp;lt;&amp;lt;= 8;&#xA;  number3 |= byte0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-12T21:56:28.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26268" PostTypeId="2" ParentId="26266" CreationDate="2016-07-12T21:56:53.333" Score="4" Body="&lt;p&gt;No, it is not integer, so you cannot calculate it that way. It have floating point (not in fixed place).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is stored as&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.significand x 2 ^ exponent.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes one bit for sign (+/-), 23 for significand (0 is not stored it is implicit) and 8 more for exponent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because of this, you have fixed precision (number of significant digits) for very large numbers and also for numbers which are close to zero.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have it all explained here:&#xA;&lt;a href=&quot;https://en.wikipedia.org/wiki/Single-precision_floating-point_format&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Single-precision_floating-point_format&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-07-13T18:11:03.133" LastActivityDate="2016-07-13T18:11:03.133" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26269" PostTypeId="2" ParentId="26266" CreationDate="2016-07-12T21:57:53.107" Score="3" Body="&lt;p&gt;No, because &lt;a href=&quot;https://en.wikipedia.org/wiki/IEEE_floating_point&quot; rel=&quot;nofollow&quot;&gt;IEEE 754 floats&lt;/a&gt; use a decimative compressed format. 64-bit floats allocate 1 bit to the sign, 11 bits to the exponent, and 52 bits to the mantissa, 32-bit floats allocate 1, 8, and 23, and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You convert from it by adding an offset to the exponent, multiplying the mantissa by the exponent to the power of 2, and then applying the sign.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-12T21:57:53.107" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26270" PostTypeId="1" CreationDate="2016-07-12T23:26:33.320" Score="3" ViewCount="2049" Body="&lt;p&gt;Is it possible to have bidirectional communication betweeen an Arduino Uno Rev 3 and a Raspberry Pi Modell B+ running Rasbian? They're connected ofer USB, and it would be good if I could use Python on the Pi.&lt;/p&gt;&#xA;" OwnerUserId="23850" LastActivityDate="2016-12-29T10:34:49.773" Title="Bidirectional communication between Arduino and Raspberry Pi over USB possible?" Tags="|arduino-uno|serial|usb|python|raspberrypi|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26271" PostTypeId="2" ParentId="26260" CreationDate="2016-07-12T23:40:32.907" Score="3" Body="&lt;p&gt;Each unique variable you want control over should have a single pid loop, and each loop should only ever stretch across one &quot;order&quot; of time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, to control the craft's roll rate, you should have one PID loop that takes the target roll rate and outputs the controlled roll torque value, which gets transformed somehow into motor accelerations. The trig weights for that part can be precalculated so it doesn't have to happen at runtime.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To control the craft's roll rotational position, you would need one PID loop that takes the target roll position and outputs the target roll velocity, that target roll velocity then becomes the setpoint for the roll-velocity pid loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't see why each motor would need its own PID loop unless you are measuring the actual thrust each motor produces. If you did measure each motor's thrust their pid loops would still come after the target torque value were calculated. The target torque PID calculations don't need to know about what motors exist or where they are located.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I may not be understanding the intention of your diagrams or what &quot;order&quot; the PID loops are in, so feel free to comment with clarifications. This is complicated stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its also worth noting that the actual implementation pid often has some features that don't appear in theoretical pid loops like integral windup prevention. You also need a way to either call them at exactly the same interval each time, or accurately keep track of the time delta since the last update. You may want to take the derivative of the process variable only, not the error, so you don't observe setpoint changes in the D term; you could also &quot;outsource&quot; the derivative term if you IMU has a better calculation of it (like the raw gyroscope values).&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-07-12T23:40:32.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26272" PostTypeId="1" CreationDate="2016-07-12T23:40:39.533" Score="0" ViewCount="109" Body="&lt;p&gt;I have already soldered the atMega chip with instructions onto the perfboard, and I may need to make changes to it. Is it possible to reprogram it without taking it out of the PCB?&lt;/p&gt;&#xA;" OwnerUserId="8744" LastActivityDate="2016-07-13T00:26:32.760" Title="Is it possible to reprogram an atMega328 chip inside of a pcb?" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26273" PostTypeId="2" ParentId="26169" CreationDate="2016-07-12T23:47:01.047" Score="0" Body="&lt;p&gt;Accelerometer static errors are usually not anywhere near that large, so I suspect your scaling code is not behaving correctly. You could verify this by turning the accelerometer on its side and see if the Z axis retains a +7G value, or if the X/Y axis instead becomes too large.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-07-12T23:47:01.047" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26274" PostTypeId="2" ParentId="26272" CreationDate="2016-07-13T00:26:32.760" Score="1" Body="&lt;p&gt;I'm assuming you're trying to program using an AVR programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, it's very likely you'll be able to do that. You need to connect the AVR programmer to the correct MCU pins (Sck, Si, So and Rst), including ground and vcc... as you would do with the chip by itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have any othe SPI device connected to the same pins, make sure it's not enabled - that might be as simple as having the device's CS pulled high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way you'll make the connection is up to you, you might need to use some clips, pogo pins or simply solder some wires to the MCU pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have other things connected to any of the MCU programming pins, you might need to disconnect, but that will vary case by case.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers &lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-07-13T00:26:32.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26275" PostTypeId="1" AcceptedAnswerId="26276" CreationDate="2016-07-13T00:43:30.557" Score="4" ViewCount="835" Body="&lt;p&gt;My Servo has already been built into my project, and I can't remove it without damaging many other things. During the process of inserting it, it was turned by hand. So I don't know at what position it is in. It turns a potentiometer that doesn't rotate fully. So I'm worried that if I just set a degree it could turn too far and damage the potentiometer or the servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do to find the current position? Is it even possible?&lt;/p&gt;&#xA;" OwnerUserId="23850" LastEditorUserId="20245" LastEditDate="2016-07-13T01:26:36.187" LastActivityDate="2016-08-11T06:33:40.113" Title="Is it possible to move a servo without knowing it's current position?" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26276" PostTypeId="2" ParentId="26275" CreationDate="2016-07-13T01:09:28.767" Score="5" Body="&lt;p&gt;A normal servo is an absolute positioning device. &lt;a href=&quot;https://en.wikipedia.org/wiki/Servo_control#Pulse_duration&quot;&gt;The position of the servo is directly proportional to the length in time of the sync pulse&lt;/a&gt;.  This means if you tell the servo to be in a given position, it will seek that position with out regard to the initial position.  It will simply figure out which way to go on it's own and stop when it gets there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I should add, that in all likely hood, when you manually moved the servo you moved the positioning potentiometer inside the servo.  So it is expected that if the servo is told to go to a particular angle, it will still go to the same angle as it did before you manually moved it.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-13T01:27:33.910" LastActivityDate="2016-07-13T01:27:33.910" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26277" PostTypeId="2" ParentId="26240" CreationDate="2016-07-13T01:10:16.530" Score="6" Body="&lt;p&gt;The best choice for serial communications is obviously the HardwareSerial object, &lt;code&gt;Serial&lt;/code&gt;, on pins 0 &amp;amp; 1.  However, it is really dedicated to the USB connection (via the onboard Serial-to-USB adapter).  There are ways to connect other devices to these pins, but it is an advanced topic, and should not be attempted by beginners.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second best choice would be pins 8 &amp;amp; 9, because &lt;a href=&quot;https://github.com/PaulStoffregen/AltSoftSerial&quot; rel=&quot;noreferrer&quot;&gt;AltSoftSerial&lt;/a&gt; requires those pins.  It is very efficient and reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that, any other pins can be used with one of these two software serial libraries:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;noreferrer&quot;&gt;NeoSWSerial&lt;/a&gt; is less efficient than AltSoftSerial, but &lt;em&gt;much&lt;/em&gt; more efficient than SoftwareSerial.  It only supports baud rates 9600, 19200 and 38400, but it does support simultaneous TX and RX.  I maintain this library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you must use a different baud rate, &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;noreferrer&quot;&gt;SoftwareSerial&lt;/a&gt; is the last choice.  It blocks interrupts for long periods of time and can interfere with other libraries.  It cannot transmit and receive at the same time.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-07-13T01:10:16.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26278" PostTypeId="2" ParentId="26270" CreationDate="2016-07-13T01:36:44.480" Score="1" Body="&lt;p&gt;Yes.  The Arduino Uno implements a serial protocol inside the USB signal using hardware.  This is how it is built.  The Linux side is a bit more complex as there are many USB protocols.  Here is a &lt;a href=&quot;http://playground.arduino.cc/Interfacing/LinuxTTY&quot; rel=&quot;nofollow&quot;&gt;howto&lt;/a&gt; which talks about the Linux side of the Arduino / Linux connection.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear, Rasbian is a derivative of Linux.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-13T01:36:44.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26280" PostTypeId="2" ParentId="26214" CreationDate="2016-07-13T04:03:32.437" Score="0" Body="&lt;p&gt;If you have access to a digital scope, try bracketing your code with changes to the state of an output pin. print() has a lot of moving parts, some (like buffer size, interrupt implementation) will vary with various Arduinos as others have noted. I am mostly using ARM Cortex M4 on Teensy 3.2. If I want to time something really precisely I will drive an I/O pin (with digitalWrite()) at the beginning and end of what I want to time. This has super fast execution. You could use more than one pin to see two things at once. Then, look at them on an oscilloscope. Trigger on the starting edge of the most important signal. Adjust the time scale to encompass the active pin level time. With a digital scope you can set persistence to infinite and then you can see the variation on the trailing edge of the pulse. You can move the digitalWrite points around in your program until you see what is causing the variation. millis() and micros() are 32-bit values so on an 8-bit AVR that is multiple machine cycles to access. A single digitWrite is usually one machine cycle so it is quick even on a slowly-clocked 8-bit AVR. Once you find the place where most of the variation occurs you at least have a quantified smoking gun to tell you what details to excavate further.&lt;/p&gt;&#xA;" OwnerUserId="23779" LastActivityDate="2016-07-13T04:03:32.437" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26281" PostTypeId="2" ParentId="13462" CreationDate="2016-07-13T05:35:33.447" Score="1" Body="&lt;p&gt;Take a look at the FONA library from Adafruit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/examples/mqtt_fona/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/examples/mqtt_fona/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The FONA Library uses SIM800 which is a newer version of SIM900. You will find MQTT and FONA within the same library. They also run an MQTT Broker service in adafruit.io&lt;/p&gt;&#xA;" OwnerUserId="23855" LastActivityDate="2016-07-13T05:35:33.447" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26284" PostTypeId="2" ParentId="26265" CreationDate="2016-07-13T08:04:08.360" Score="1" Body="&lt;p&gt;There are two ways of doing this:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using a Real Time Clock (RTC) chip, which you connect to your Arduino.&lt;/li&gt;&#xA;&lt;li&gt;Using the &lt;code&gt;millis()&lt;/code&gt; function of the Arduino.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Needless to say, they aren't completely the same in efficiency. An RTC is a dedicated chip for measuring time and is incredibly accurate. The &lt;code&gt;millis()&lt;/code&gt; is not as accurate, but still pretty accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, it really depends on how accurate you want it to be. You can make &lt;code&gt;millis()&lt;/code&gt; more accurate through code, which isn't something difficult. But an RTC always works fine and is always more accurate, if only by milliseconds. In general: need to time long durations, an RCT is probably better.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regardless of the method you will use, you can convert the data into the desired format so it can be read easily when looking at the files on the SD card. So, for example: you can write code that simply checks how many hours fit in the saved time data, and after that you can check the minutes and even after that you can check for the last seconds. For this you're going to need &lt;a href=&quot;https://www.arduino.cc/en/Reference/modulo&quot; rel=&quot;nofollow&quot;&gt;modulo&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here are some resources you might want to check out:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;An Arduino tutorial for an RTC chip: &lt;a href=&quot;http://playground.arduino.cc/Main/DS1302&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/DS1302&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Official documentation on &lt;code&gt;millis()&lt;/code&gt;: &lt;a href=&quot;https://www.arduino.cc/en/Reference/Millis&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Millis&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23788" LastEditorUserId="23788" LastEditDate="2016-07-14T07:02:16.617" LastActivityDate="2016-07-14T07:02:16.617" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26285" PostTypeId="1" CreationDate="2016-07-13T08:07:34.193" Score="0" ViewCount="1253" Body="&lt;p&gt;I'm using ATtiny44 with Arduino IDE according to this tutorial: &lt;a href=&quot;http://highlowtech.org/?p=1695&quot; rel=&quot;nofollow&quot;&gt;http://highlowtech.org/?p=1695&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a problem with &lt;code&gt;millis()&lt;/code&gt;. When I use an internal 1 MHz clock it works correctly but when I use external 16 MHz clock it takes &lt;code&gt;millis()&lt;/code&gt; much more time than one second to be divisible by 1000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it with LCD and Hello World sketch, modified to correspond ATtiny's pins. Do &lt;code&gt;millis()&lt;/code&gt; actually work with Tiny's?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why does it work properly with 1MHz and not with 16 MHz which is the same as used in Arduino platform.&lt;/p&gt;&#xA;" OwnerUserId="23695" LastEditorUserId="19515" LastEditDate="2016-07-13T12:29:56.857" LastActivityDate="2018-06-05T18:19:32.827" Title="ATtiny44 millis() not working with 16 MHz external clock" Tags="|attiny|millis|oscillator-clock|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26286" PostTypeId="2" ParentId="26266" CreationDate="2016-07-13T09:18:53.933" Score="3" Body="&lt;p&gt;Just adding a little piece of information to the previous answers: it's&#xA;worth noting that a float can represent &lt;em&gt;exactly&lt;/em&gt; all integers from&#xA;−2&lt;sup&gt;24&lt;/sup&gt; to +2&lt;sup&gt;24&lt;/sup&gt; (i.e. ±16777216).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next integer, namely 16777217, is not representable as a float. A&#xA;calculation giving this value would suffer a rounding error.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-13T09:18:53.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26287" PostTypeId="1" AcceptedAnswerId="26290" CreationDate="2016-07-13T09:49:29.150" Score="5" ViewCount="4133" Body="&lt;p&gt;Given the following minimal working example. I tested this initially with uint16_t and it worked with no warnings. After that, I adjusted everything to work with uint32_t.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt; /* needed for the uint16_t type*/&#xA;#include &amp;lt;inttypes.h&amp;gt; /* needed for sscanf uint16_t format placeholder  */&#xA;#include &quot;printf.h&quot;&#xA;&#xA;#define SET_CMD_ID(ID)    ( (ID) &amp;lt;&amp;lt; 27)&#xA;#define SET_CMD_CMD(CMD)  ( (CMD)  &amp;lt;&amp;lt; 25)&#xA;#define SET_CMD_TYPE(TYPE)  ( (TYPE) &amp;lt;&amp;lt; 19)&#xA;#define SET_CMD_PKT(PKT)  ( (PKT)    )&#xA;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  printf_begin();&#xA;  Serial.print(F(&quot;\n\rExample command\n\r: &quot;));&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  uint32_t payload = 0;&#xA;&#xA;  uint8_t id = 3;   // 00000 - 5&#xA;  uint8_t cmd = 2;  // 00    - 2&#xA;  uint8_t type = 1; // 000000 - 6 &#xA;  uint32_t pkt = 0; // 0000000000000000000 - 19&#xA;&#xA;  payload =  &#xA;        SET_CMD_ID(id)   |&#xA;        SET_CMD_CMD(cmd)  |&#xA;        SET_CMD_TYPE(type) |&#xA;        SET_CMD_PKT(pkt);&#xA;  Serial.print(F(&quot;Now sending &quot;));&#xA;  Serial.println(payload);&#xA;  delay(2000);        // Try again soon&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Verifying this sketch outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/path/to/ino/Arduino32bitTest.ino: In function 'void loop()':&#xA;/path/to/ino/Arduino32bitTest.ino:5:37: warning: left shift count &amp;gt;= width of type [enabled by default]&#xA; #define SET_CMD_ID(ID)    ( (ID) &amp;lt;&amp;lt; 27)&#xA;                                     ^&#xA;/path/to/ino/Arduino32bitTest.ino:28:9: note: in expansion of macro 'SET_CMD_ID'&#xA;         SET_CMD_ID(id)   |&#xA;         ^&#xA;/path/to/ino/Arduino32bitTest.ino:6:39: warning: left shift count &amp;gt;= width of type [enabled by default]&#xA; #define SET_CMD_CMD(CMD)  ( (CMD)  &amp;lt;&amp;lt; 25)&#xA;                                       ^&#xA;/path/to/ino/Arduino32bitTest.ino:29:9: note: in expansion of macro 'SET_CMD_CMD'&#xA;         SET_CMD_CMD(cmd)  |&#xA;         ^&#xA;/path/to/ino/Arduino32bitTest.ino:7:41: warning: left shift count &amp;gt;= width of type [enabled by default]&#xA; #define SET_CMD_TYPE(TYPE)  ( (TYPE) &amp;lt;&amp;lt; 19)&#xA;                                         ^&#xA;/path/to/ino/Arduino32bitTest.ino:30:9: note: in expansion of macro 'SET_CMD_TYPE'&#xA;         SET_CMD_TYPE(type) |&#xA;         ^&#xA;&#xA;Sketch uses 3,174 bytes (9%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 216 bytes (10%) of dynamic memory, leaving 1,832 bytes for local variables. Maximum is 2,048 bytes.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Executing the sketch on an Arduino Uno results in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Example command&#xA;&#xA;: Now sending 0&#xA;Now sending 0&#xA;Now sending 0&#xA;Now sending 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I googled the message of the warning and found out that it could mean that I'm trying to shift 32bit which is undefined, but I'm not sure on that. So my question is:&#xA;What am I doing wrong here? How can I get this to work?&lt;/p&gt;&#xA;" OwnerUserId="17080" LastActivityDate="2016-07-13T12:26:30.063" Title="Bit shifting fails with warning: left shift count &gt;= width of type" Tags="|arduino-uno|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26288" PostTypeId="1" AcceptedAnswerId="26291" CreationDate="2016-07-13T10:29:00.980" Score="7" ViewCount="4009" Body="&lt;p&gt;I am currently using a Nodemcu ESP8266-12E with the Arduino IDE in order to control my boiler. Everything is working fine, however I haven't figured out yet how to serve binary files, eg. images. (I am hosting them on a server at the moment).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ESP8266WebServer server(80);&#xA;&#xA;void setup()&#xA;{&#xA;  [...]&#xA;  server.on(&quot;/&quot;, handleResponse);&#xA;  server.onNotFound(handleResponse);&#xA;  server.begin();&#xA;}&#xA;&#xA;void handleResponse() {&#xA;  if (server.uri() == &quot;/style.css&quot;) {&#xA;    server.send(200, &quot;text/css&quot;, &quot;[css]&quot;);&#xA;    return;&#xA;  }&#xA;  if (server.uri() == &quot;/favicon.ico&quot;) {&#xA;    server.send(404, &quot;text/html&quot;, &quot;Not set&quot;);&#xA;    return;&#xA;  }&#xA;  [...]&#xA;}&#xA;&#xA;unsigned char favicon_ico[] = {&#xA;  0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,&#xA;  0x18, 0x00, 0x68, 0x03, 0x00,......... 0x00&#xA;};&#xA;unsigned int favicon_ico_len = 894;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Converting the arary to a string and serving it with &lt;code&gt;server.send&lt;/code&gt; does not work and  &lt;code&gt;server.stream&lt;/code&gt; expects a file. &lt;/p&gt;&#xA;" OwnerUserId="7965" LastActivityDate="2016-07-13T11:05:56.077" Title="Serving binary file with ESP8266WebServer" Tags="|esp8266|wifi|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26289" PostTypeId="1" CreationDate="2016-07-13T10:41:59.720" Score="5" ViewCount="654" Body="&lt;p&gt;I use this code to connect Arduino MKR1000 to API through Web Socket, but it didn't connect to the server.&#xA;Can any one help me to correct the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the Arduino code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;WiFi101.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WebSocketClient.h&amp;gt;&#xA;&#xA;char server[] = &quot;192.168.2.128&quot;;&#xA;IPAddress server1(192, 168, 2, 128);&#xA;WebSocketClient webSocketClient;&#xA;WiFiClient client;&#xA;&#xA;char path1[] = &quot;/api/WebSocketTest&quot;;&#xA;int port1 = 8060;&#xA;char ssid[] = &quot;**************&quot;;&#xA;char pass[] = &quot;**************&quot;;&#xA;&#xA;void setup() {&#xA;  pinMode(LDR, INPUT);&#xA;  pinMode(LED, OUTPUT);&#xA;  pinMode(LED2, OUTPUT);&#xA;  pinMode(SWITCH, INPUT);&#xA;  Serial.begin(115200);&#xA;  delay(10);&#xA;  while (!Serial) {&#xA;  }&#xA;&#xA;  Serial.println();&#xA;  Serial.println();&#xA;  Serial.print(&quot;Connecting to &quot;);&#xA;  Serial.println(ssid);&#xA;  WiFi.begin(ssid, pass);&#xA;&#xA;  while (WiFi.status() != WL_CONNECTED) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;&#xA;  Serial.println(&quot;&quot;);&#xA;  Serial.println(&quot;WiFi connected&quot;);&#xA;  printWifiStatus();&#xA;  delay(3000);&#xA;  Serial.println(&quot;setup done&quot;);&#xA;  delay(1000);&#xA;&#xA;&#xA;  //  webSocketClient.setDebug(&amp;amp;debug);&#xA;  webSocketClient.connect(server, port1, path1);&#xA;  if (webSocketClient.connected() == true) {&#xA;    Serial.println(&quot;Connected&quot;);&#xA;  }&#xA;  else {&#xA;    Serial.println(&quot;Not Connected&quot;);&#xA;  }&#xA;  webSocketClient.onMessage(onMessage);&#xA;  webSocketClient.onOpen(onOpen);&#xA;  webSocketClient.onError(onError);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;  webSocketClient.monitor();&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void onOpen(WebSocketClient webSocketClient) {&#xA;  Serial.println(&quot;EXAMPLE: onOpen()&quot;);&#xA;}&#xA;&#xA;&#xA;&#xA;void onMessage(WebSocketClient webSocketClient, char* message) {&#xA;  Serial.print(&quot;Received: &quot;);&#xA;  Serial.println(message);&#xA;}&#xA;&#xA;&#xA;&#xA;void onError(WebSocketClient webSocketClient, char* message) {&#xA;  Serial.print(&quot;ERROR: &quot;);&#xA;  Serial.println(message);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void printWifiStatus() {&#xA;  // print the SSID of the network you're attached to:&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;&#xA;  // print your WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Address: &quot;);&#xA;  Serial.println(ip);&#xA;&#xA;  // print the received signal strength:&#xA;  long rssi = WiFi.RSSI();&#xA;  Serial.print(&quot;signal strength (RSSI):&quot;);&#xA;  Serial.print(rssi);&#xA;  Serial.println(&quot; dBm&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is a part from the library used &quot;WebSocketClient.h&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;void WebSocketClient::connect(char hostname[], int port, char protocol[], char path[]) {&#xA;  _hostname = hostname;&#xA;  _port = port;&#xA;  _protocol = protocol;&#xA;  _path = path;&#xA;  _retryTimeout = millis();&#xA;  _canConnect = true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Edit 1: The output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Connecting to WiFi-Repeater1&#xA;&#xA;WiFi connected&#xA;SSID: WiFi-Repeater1&#xA;IP Address: 192.168.2.147&#xA;signal strength (RSSI):-68 dBm&#xA;setup done&#xA;Not Connected&#xA;ERROR: Connection Failed!&#xA;ERROR: Connection Failed!&#xA;ERROR: Connection Failed!&#xA;ERROR: Connection Failed!&#xA;ERROR: Connection Failed!&#xA;ERROR: Connection Failed!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22826" LastEditorUserId="37523" LastEditDate="2019-05-13T09:01:35.903" LastActivityDate="2019-05-13T09:01:35.903" Title="Arduino WebSocket Client &quot;Connection Failed&quot;" Tags="|mkr1000|" AnswerCount="0" CommentCount="11" ContentLicense="CC BY-SA 4.0" />
  <row Id="26290" PostTypeId="2" ParentId="26287" CreationDate="2016-07-13T10:57:50.160" Score="5" Body="&lt;p&gt;It's basically an inability of the compiler to auto-promote the source variables to a size big enough to fit the shifted version.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The default type for all operations, unless otherwise specified, is 16-bit. By shifting more than 16 bits you are overflowing that default type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To get around it you have to manually tell the compiler that you want to work with 32-bits:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SET_CMD_ID(ID)      ( ((uint32_t)ID) &amp;lt;&amp;lt; 27)&#xA;#define SET_CMD_CMD(CMD)    ( ((uint32_t)CMD)  &amp;lt;&amp;lt; 25)&#xA;#define SET_CMD_TYPE(TYPE)  ( ((uint32_t)TYPE) &amp;lt;&amp;lt; 19)&#xA;#define SET_CMD_PKT(PKT)    ( ((uint32_t)PKT)    )&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T10:57:50.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26291" PostTypeId="2" ParentId="26288" CreationDate="2016-07-13T11:05:56.077" Score="7" Body="&lt;p&gt;It looks like you can use the &lt;code&gt;send_P&lt;/code&gt; function to send raw PROGMEM data:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;void send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I.e., (from what I can gather):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PGM_P favicon = {&#xA;  0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,&#xA;  0x18, 0x00, 0x68, 0x03, 0x00,......... 0x00&#xA;};&#xA;&#xA;server.send_P(200, &quot;image/x-icon&quot;, favicon, sizeof(favicon));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Incidentally, &lt;code&gt;PGM_P&lt;/code&gt; is just a &lt;code&gt;typedef&lt;/code&gt; for &lt;code&gt;const char *&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T11:05:56.077" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26292" PostTypeId="2" ParentId="26252" CreationDate="2016-07-13T11:06:53.443" Score="1" Body="&lt;p&gt;Ok I found a solution (rather workaround).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I uploaded the same program to Arduino Uno. It worked perfectly. I transplanted the Atmega328 from Uno to breadboard. Still worked BUT the Atmega328 is using external 16Mhz crystal (which I added to the breadboard).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what if I uploaded bootloader for 16Mhz external crystal on Atmega8?&#xA;It makes it work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So in short:&#xA;Atmega8 with 8Mhz internal oscillator doesn't work properly.&#xA;Atmega8 with 16Mhz external oscillator works properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't know why does it make it work. If anyone can think of a reason I would be glad to know it. Thanks for all your help.&lt;/p&gt;&#xA;" OwnerUserId="23833" LastActivityDate="2016-07-13T11:06:53.443" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26294" PostTypeId="1" CreationDate="2016-07-13T11:43:04.600" Score="1" ViewCount="1418" Body="&lt;p&gt;I am searching for this component: a touch sensitive button with LEDs like in the &lt;a href=&quot;http://46.20.46.151/wp-content/uploads/2012/10/push_01_72dpi_rgb-632x412.jpg&quot; rel=&quot;nofollow&quot;&gt;Ableton Push&lt;/a&gt; or in other Launchpads. Does anyone have an idea about where I can buy something like this? The best would be an RGB LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is what I've &lt;a href=&quot;https://www.sparkfun.com/products/10442&quot; rel=&quot;nofollow&quot;&gt;found&lt;/a&gt; so far. It has no RGB LED though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="23866" LastEditorUserId="11763" LastEditDate="2016-07-13T23:04:53.533" LastActivityDate="2016-07-13T23:04:53.533" Title="Where can i get touch sensitive buttons with RGB-LED like in Ableton Push" Tags="|button|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26296" PostTypeId="2" ParentId="26294" CreationDate="2016-07-13T11:49:07.463" Score="3" Body="&lt;p&gt;Just a little more searching would have led you to &lt;a href=&quot;https://www.sparkfun.com/products/7835&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;, along with its associated &lt;a href=&quot;https://www.sparkfun.com/products/8033&quot; rel=&quot;nofollow&quot;&gt;breakout board&lt;/a&gt;, bezels, and LEDs.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-13T11:49:07.463" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26297" PostTypeId="2" ParentId="26287" CreationDate="2016-07-13T12:26:30.063" Score="2" Body="&lt;p&gt;Another solution would be to not shift values at all.&#xA;It seems to be very common in Arduino and other micro-controller projects to use antique ANSI C. But ALL major compiles support &quot;bit fields&quot;. The language removes your headache of packing bits into and unpacking bits from a larger type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It goes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct {&#xA;    uint32_t pkt  : 19;&#xA;    uint32_t type :  6;&#xA;    uint32_t cmd  :  2;&#xA;    uint32_t id   :  5;&#xA;} payload;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As long ans 19 + 6 + 2 + 5 does not exceed 32, the struct will still take up only 32 bits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Setting values works like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;payload.id = 3;&#xA;payload.cmd = 2;&#xA;payload.type = 1;&#xA;payload.pkt = 0;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Reading values works the same way. No need to shift mask or do any other operations by hand. The compiler does everything for you without making any mistakes or without forgetting about to mask when reading...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing you have to remember is that bitfields are packed from least significant bit to the most significant bit. So a struct like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct {&#xA;    uint8_t r :  2;&#xA;    uint8_t g :  3;&#xA;    uint8_t b :  2;&#xA;    uint8_t a :  1;&#xA;} someType;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will result it a byte where the values are layout like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;abbgggrr&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This also works for signed values. But you have to make sure they fit and be aware of the twos complement representation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hopefully more Arduino and micro controller developer will adopt this and take advantage of the compiler.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-07-13T12:26:30.063" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26298" PostTypeId="2" ParentId="26294" CreationDate="2016-07-13T12:27:14.130" Score="3" Body="&lt;p&gt;The specific buttons you link to are custom made. They're not something you can buy off the shelf. In fact they aren't even buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What they are is a translucent moulded silicone rubber sheet with conductive pads behind (typically in a ring shape) with an LED mounted on a PCB behind them.  The pad is pressed, which flexes the silicone rubber, to press the conductive portion against exposed tracks on the PCB behind.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some similar products around, such as &lt;a href=&quot;https://www.sparkfun.com/products/7835&quot; rel=&quot;nofollow&quot;&gt;the Sparkfun one Ignacio points to&lt;/a&gt; but it is highly unlikely you will find anything off-the-shelf that does exactly what you want.  Coupling a pre-moulded translucent rubber keypad membrane (if you can find one somewhere) with your own custom designed PCB to take the RGB LEDs you want (preferably surface mount to keep the size small enough) and provide the exposed tracks is probably the only way you can get exactly what you want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may be able to create your own sheet by first making a suitable mould, maybe with wood or modelling clay or something like that, then filling it with silicone (translucent bathroom sealant) and then impress on the back of that a second mould to provide the contact points and indents etc. Then, after a few days when it's all dry, add to the contact points some self-adhesive copper foil, or paint them with conductive paint. Don't quote me on that though, I haven't tried it ;)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T12:27:14.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26299" PostTypeId="2" ParentId="26266" CreationDate="2016-07-13T12:40:15.400" Score="1" Body="&lt;p&gt;Another way of looking at it is that a float variable is actually a list of 4294967296 numbers. That's far less than the possible range of numbers and fractions that a float can represent, so only a subset of the numbers are actually represented. Any number you try and use that's not in that list of numbers is rounded to the nearest one.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T12:40:15.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26301" PostTypeId="1" CreationDate="2016-07-13T13:52:16.683" Score="0" ViewCount="154" Body="&lt;p&gt;I'm trying to determine what is the best way to scale a magnometer to a servo, I am using the BNO055 from Bosch I get a heading say 50 degrees, and I want to be able to input 45 degrees and have the servo motor move accordingly. I am using a 180 degree motor. I would like to be able to input 45 degrees, and then the motor if 50 degrees was 95, would decrease in value step by step until the magnometer read 45; I'm having difficulty creating the logic to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bosch output is between 0 and 360; so I could end up with servo 0 is 120; and servo 180 is 300. Meaning the values are 300 - 360, 0 - 120 making the full 180, so I am not sure how I could use something like map in arduino to solve this issue.&lt;/p&gt;&#xA;" OwnerUserId="23232" LastActivityDate="2016-07-13T15:55:42.463" Title="Scale Magnometer to Servo" Tags="|sensors|arduino-nano|servo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26303" PostTypeId="2" ParentId="26301" CreationDate="2016-07-13T14:23:58.580" Score="1" Body="&lt;p&gt;Okay, lets say the output of your BNO055 is called &lt;code&gt;x&lt;/code&gt; and the value for your servo is &lt;code&gt;y&lt;/code&gt;. We need to translate &lt;code&gt;x&lt;/code&gt; to &lt;code&gt;y&lt;/code&gt; and you are correct to use the &lt;code&gt;map()&lt;/code&gt; function. But what you are forgetting is that you do not need to map all the values of &lt;code&gt;x&lt;/code&gt; to all the values of &lt;code&gt;y&lt;/code&gt;. You can split it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your example the values of the BNO055 relate to the servo as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x   | y   &#xA;0   | 0&#xA;120 | 0&#xA;300 | 180&#xA;360 | 180&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The servo only rotates from 0 degrees to 180 degrees between the BNO055 sensor values of 120 and 300. So you only need to map those values, while all values below should result in 0 and all values above should result in 180 degrees for the servo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This translates into the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//x is the output of BNO055 sensor&#xA;if(x &amp;lt; 120){&#xA;  servo.write(0);&#xA;}&#xA;if(x &amp;gt; 300){&#xA;  servo.write(180);&#xA;}&#xA;if(x &amp;gt; 120 &amp;amp;&amp;amp; x &amp;lt; 300){&#xA;  y = map(x, 120, 300, 0, 180);&#xA;  servo.write(y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another way of coding this is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(x &amp;lt; 120){&#xA;  servo.write(0);&#xA;}&#xA;else if(x &amp;gt; 300){&#xA;  servo.write(180);&#xA;}&#xA;else{&#xA;  y = map(x, 120, 300, 0, 180);&#xA;  servo.write(y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-13T14:23:58.580" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26304" PostTypeId="2" ParentId="26301" CreationDate="2016-07-13T15:55:42.463" Score="1" Body="&lt;p&gt;You need to remember that you are working with a circle. You have degrees 0 to 360, but only if counting clockwise. If you work anticlockwise you also have degrees 0 to -360.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So your angles of interest are, clockwise from 0, 0-120, and anti-clockwise from 0, 0 to -60&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make things easier on you you need to create a range that is wrapped around so that anything in the &quot;left&quot; half of the circle is counted as anticlockwise from 0 and anything in the &quot;right&quot; half of the circle is counted clockwise from 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So values 0-180 are 0-180, but values of 180 to 360 are -128 to 0.  Then your entire range spreads from -180 to +180 instead of 0-360 (if that makes sense).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's simple enough:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (angle &amp;gt; 180) angle = 0 - (360 - angle);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So if &lt;code&gt;angle&lt;/code&gt; is 300 you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 - (360 - 300) = 0 - 60 = -60&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;angle&lt;/code&gt; is 330 you get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 - (360 - 330) = 0 - 30 = -30&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you can map the new values using the &lt;code&gt;map&lt;/code&gt; function @Len has detailed above:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servo = map(angle, -60, 120, 0, 180);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is also possible to combine it all into one line should you wish, using the C &quot;inline if&quot; format:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;servo = map((angle &amp;gt; 180 ? (0 - (360 - angle)) : angle), -60, 120, 0, 180);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that is kind of cryptic :)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T15:55:42.463" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26305" PostTypeId="1" AcceptedAnswerId="26322" CreationDate="2016-07-13T15:57:41.197" Score="0" ViewCount="116" Body="&lt;p&gt;My question is: What is on an Arduino board besides the microcontroller? &lt;/p&gt;&#xA;" OwnerUserId="23874" LastActivityDate="2016-07-14T08:09:31.320" Title="What's on an Arduino board? Can i build one of these boards myself?" Tags="|programming|pins|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26308" PostTypeId="1" AcceptedAnswerId="26310" CreationDate="2016-07-13T17:15:29.687" Score="0" ViewCount="1556" Body="&lt;p&gt;I have a simple following analog reading code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{&#xA;  // initialize serial comms&#xA;  Serial.begin(9600); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // read A0&#xA;  int val0 = analogRead(0);&#xA;  int val1 = analogRead(1);&#xA;  int val2 = analogRead(2);&#xA;  // print to serial&#xA;  Serial.print(val0);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(val1);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(val2);&#xA;  Serial.print(&quot;\n&quot;);&#xA;  // wait &#xA;  delay(50);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I determine the sampling rate? I understand for the serial print, it's 3*4 bytes (for val0,1,2) + 2 bytes for space and 1 bytes for \n, which is 15/9600.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How much time is spent on analogRead? &lt;/p&gt;&#xA;" OwnerUserId="21128" LastEditorUserId="21128" LastEditDate="2016-07-13T18:23:55.900" LastActivityDate="2016-07-13T20:48:45.137" Title="Sampling rate of analog read" Tags="|arduino-uno|analog-sampling|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26309" PostTypeId="2" ParentId="26305" CreationDate="2016-07-13T17:17:08.130" Score="0" Body="&lt;p&gt;This list is probably not exhaustive but comes reasonably close:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A power supply (voltage regulator and filter capacitor);&lt;/li&gt;&#xA;&lt;li&gt;A USB connector for powering from a USB port and passing data to/from&#xA;your PC;&lt;/li&gt;&#xA;&lt;li&gt;A second processor (Atmega 16U2) for handling USB &amp;lt;-&gt; serial data&#xA;conversion;&lt;/li&gt;&#xA;&lt;li&gt;A barrel-jack for powering it from a 7 - 12v;&lt;/li&gt;&#xA;&lt;li&gt;A MOSFET for selecting whichever power source is being used;&lt;/li&gt;&#xA;&lt;li&gt;An LED connected to the chip's digital pin 13;&lt;/li&gt;&#xA;&lt;li&gt;A pushbutton for manual reset and a capacitor for auto-reset;&lt;/li&gt;&#xA;&lt;li&gt;A 16 MHz crystal and load capacitors;&lt;/li&gt;&#xA;&lt;li&gt;Several lengths of female headers for connecting plug-wires or shields to the Arduino.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And yes, it's relatively easy to build one - instructive, too! There are how-to project details all over the Internet. I've hand-built any number of them, just soldering up whatever parts I wanted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an Arduino home brew project, &lt;a href=&quot;http://jpralves.net/cseduino/&quot; rel=&quot;nofollow&quot;&gt;CSEDuino&lt;/a&gt;, that was easy and fun to build, with good detailed directions. It is an Arduino clone that does everything the Uno does, except that it isn't physically compatible with Arduino shields.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of my gadgets are on home-brewDuinos. I usually skip the USB connector and 16U2 processor, and keep one or two FTDI USB to serial cables on my bench to power or program whatever board I'm currently working on. I usually skip the auto-reset capacitor too, and manually reset the board to upload it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Have fun building!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In service, I just power them from a USB wall charger. Any of them that need to communicate get an radio of some kind, usually Bluetooth or Wifi. Some of them just collect data to non-volatile memory for me read out later.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="2881" LastEditDate="2016-07-13T17:51:45.903" LastActivityDate="2016-07-13T17:51:45.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26310" PostTypeId="2" ParentId="26308" CreationDate="2016-07-13T17:35:03.053" Score="1" Body="&lt;p&gt;The sample rate will be somewhat inconsistent since the first few samples' print output will go into the print buffer with little delay. Once the buffer fills, subsequent samples' time spent in Serial.print() will vary somewhat depending on how long printing the currently printing character takes to finish, when Serial.print() is called. But the average sample rate will settle to about to &lt;em&gt;about&lt;/em&gt; 64 Hz (1 sec / (15/960 lines/sec).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The printing time for one line is about 15.6 msec, much longer (140 times) than analogRead() takes, about 0.111 msec, according to &lt;a href=&quot;http://meettechniek.info/embedded/arduino-analog.html&quot; rel=&quot;nofollow&quot;&gt;this author's measurements&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: &lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;So I could just use 50ms + 15.6 for the sampling rate, ignoring&#xA;  analogRead?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That would get you pretty close to the average sampling interval. If consistency is important to you, you'd need to measure that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How many samples do you need at a time? Another way is to store the data in an array and print it later. Then the jitter in the sampling interval will be much smaller. You'd be limited to the number of samples you could fit in memory, though. Each 10-bit sample would need 2 bytes of storage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the range of your data is less than 256, you could subtract from each sample, the lowest value you expect to see; the difference will fit in 1 byte, doubling your storage capability. Don't forget to add back that lowest value to each one when you print them, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would also be a good idea to test each sample against that lowest number and the lowest + 255, and if any sample is outside those limits, store the low or high limit value instead. Then when you plot your data, &#xA;you'll see it &quot;clipping&quot; and know that it exceeded your bounds. Otherwise you'll get overflows in the arithmetic and the out-of-bounds numbers will appear to suddenly take on high values when they really are low, and vice versa.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-13T20:48:45.137" LastActivityDate="2016-07-13T20:48:45.137" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26311" PostTypeId="2" ParentId="25122" CreationDate="2016-07-13T17:54:14.767" Score="0" Body="&lt;p&gt;The baudrate for those is 57600. Try checking for an error in your boards.txt .&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-07-13T17:54:14.767" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26312" PostTypeId="1" CreationDate="2016-07-13T18:12:19.407" Score="0" ViewCount="1330" Body="&lt;p&gt;I would like to enable communication between two Arduino 101. From what I have read, the best method is to use I2C using the wire library. However, it seems as though the newest Arduino IDE has an updated version of the Wire library that no longer includes the &lt;code&gt;begin(int)&lt;/code&gt; and &lt;code&gt;onRequest&lt;/code&gt; functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the tutorials for I2C communication use these methods, so I am unable to follow and use them. It looks like when I change the board to Arduino Uno these functions are found, but as soon as I change the board to Arduino 101 the following errors appear no matching function for call to &lt;code&gt;TwoWire::begin(int)&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try replacing my wire library with the older version, I get other errors for missing libraries and if I replace everything it is unable to compile on Arduino 101.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me or direct me to a I2C tutorial that uses the most updated version of the Wire library?&lt;/p&gt;&#xA;" OwnerUserId="23875" LastEditorUserId="4628" LastEditDate="2017-03-31T05:05:34.767" LastActivityDate="2019-12-18T07:01:55.247" Title="I2C communication between 2 Arduinos with updated wire library" Tags="|i2c|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26313" PostTypeId="1" CreationDate="2016-07-13T18:28:44.910" Score="0" ViewCount="542" Body="&lt;p&gt;I'm building a laser tripwire of sorts and instead of shutting up when the laser points on it (which is essential for my project) it beeps louder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int buzzPin = 11; // buzzer connected to digital pin 11&#xA;&#xA;void setup() {&#xA;    pinMode(buzzPin, OUTPUT); // sets the digital pin as output&#xA;}&#xA;&#xA;void loop(){&#xA;    if(analogRead(0) &amp;lt; 750){ // this number depends on calibration of the photocell&#xA;        digitalWrite(buzzPin, HIGH); // turns buzzer on&#xA;        delay(5000); // waits for 1 second&#xA;        digitalWrite(buzzPin, LOW); // turns buzzer off&#xA;    } else{&#xA;        digitalWrite(buzzPin, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="Karl Stark" LastEditorDisplayName="user6430" LastEditDate="2016-07-15T06:16:04.110" LastActivityDate="2016-07-15T14:18:29.143" Title="Increase the resistance of a photoresistor with increase in light intensity" Tags="|programming|photoresistor|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26315" PostTypeId="2" ParentId="18755" CreationDate="2016-07-13T19:28:27.300" Score="5" Body="&lt;p&gt;I've had the same problem, couldn't get past 2 meters range. &#xA;Until i noticed that the TX-Frequency was off by about 150kHz.&#xA;I adjusted the RX Frequency (the module has a trimmer) and now 40-50m is possible with a wall in between.&lt;/p&gt;&#xA;" OwnerUserId="23880" LastActivityDate="2016-07-13T19:28:27.300" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26316" PostTypeId="1" AcceptedAnswerId="26319" CreationDate="2016-07-13T19:38:52.910" Score="0" ViewCount="1848" Body="&lt;p&gt;I want to converse data from long to bytes and vice versa. After searching around, I sticked together some code, which seems to work &lt;em&gt;(the same code works for int and floats as well)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The long value &lt;code&gt;LongVal&lt;/code&gt; changes to a byte array, and the four bytes construct &lt;code&gt;LongVal2&lt;/code&gt;. Obviously &lt;code&gt;LongVal = LongVal2&lt;/code&gt;.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long LongVal = -4080;&#xA;long LongVal2;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;//byte* my_function(long LongVal){&#xA;//  byte *LongVal_byte = (byte *) &amp;amp; LongVal; &#xA;//  return &amp;amp; (LongVal_byte[0]);&#xA;//}&#xA;&#xA;//long my_function2(byte &amp;amp; LongVal_byte){&#xA;//  long LongVal2;&#xA;//  memcpy(&amp;amp;LongVal2, LongVal_byte, sizeof(LongVal2));&#xA;//  return  LongVal2;&#xA;//}&#xA;&#xA;void loop(){&#xA;&#xA;  byte *LongVal_byte = (byte *) &amp;amp; LongVal; &#xA;  memcpy(&amp;amp;LongVal2, LongVal_byte, sizeof(LongVal2));&#xA;  Serial.println(LongVal2);  &#xA;  Serial.println(&quot; &quot;);  &#xA;&#xA;//byte LongVal_byte = my_function(long LongVal);&#xA;//LongVal2 = my_function2(byte &amp;amp; LongVal_byte);  &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But should I try to wrap the two first lines of &lt;code&gt;loop()&lt;/code&gt; in two individual functions, errors occur. The remarked lines are my attempts to create two functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to wrap them up properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;This is what appears if I try to use the remarked functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; In function 'long int my_function2(byte&amp;amp;)':&#xA;15:51: error: invalid conversion from 'byte {aka unsigned char}' to 'const void*' [-fpermissive]&#xA;25:0,&#xA;1:&#xA;117:14: error:   initializing argument 2 of 'void* memcpy(void*, const void*, size_t)' [-fpermissive]&#xA;&#xA; In function 'void loop()':&#xA;26:33: error: expected primary-expression before 'long'&#xA;27:30: error: expected primary-expression before '&amp;amp;' token&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="7728" LastEditDate="2016-07-13T20:15:25.593" LastActivityDate="2016-07-13T20:44:03.503" Title="changing from long to bytes and vice versa" Tags="|programming|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26317" PostTypeId="1" CreationDate="2016-07-13T19:44:45.923" Score="1" ViewCount="1072" Body="&lt;p&gt;Is there a way to force the Arduino compiler to compile individual commands sequentially?  Looking at the disassembly, lines of the assembly code for different C/Arduino commands are mixed.  I was thinking something like a dmb or dsb command in ARM assembly.  I realize it's done the way it is for timing optimization, but I would like to see if changing it fixes some other timing issues I'm having.  I'm working on an Arduino Zero.  Thanks!&lt;/p&gt;&#xA;" OwnerUserId="23804" LastActivityDate="2016-07-13T20:01:00.317" Title="Force compiler to execute instructions sequentially?" Tags="|compile|timing|assembly|compiler|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26318" PostTypeId="2" ParentId="26317" CreationDate="2016-07-13T20:01:00.317" Score="2" Body="&lt;p&gt;You can use the &lt;code&gt;optimize&lt;/code&gt; function attribute to change the compiler optimization level for an individual function. That's the closest you'll get.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;strong&gt;optimize&lt;/strong&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The optimize attribute is used to specify that a function is to be compiled with different optimization options than specified on the command line. Arguments can either be numbers or strings. Numbers are assumed to be an optimization level. Strings that begin with O are assumed to be an optimization option, while other options are assumed to be used with a -f prefix. You can also use the &lt;code&gt;#pragma GCC optimize&lt;/code&gt; pragma to set the optimization options that affect more than one function. See Function Specific Option Pragmas, for details about the &lt;code&gt;#pragma GCC optimize&lt;/code&gt; pragma.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;strong&gt;This attribute should be used for debugging purposes only. It is not suitable in production code.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;E.g.,:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void __attribute__((optimize(&quot;O0&quot;))) myFunction() {&#xA;    // ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T20:01:00.317" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26319" PostTypeId="2" ParentId="26316" CreationDate="2016-07-13T20:41:59.690" Score="1" Body="&lt;p&gt;So many problems here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) in function call there shouldn't be types, only arguments. &lt;code&gt;byte LongVal_byte = my_function(LongVal);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &amp;amp; before variable means &quot;get variable address&quot;. However in function prototype &lt;code&gt;long my_function2(byte &amp;amp; LongVal_byte)&lt;/code&gt; it means reference to passed variable (and it must be byte), not a pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) pointer to local variable is returned from my_function. It might be working until pointed memory gets rewrited by something else (another function call or so)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And whole code might look like that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long LongVal = -4080;&#xA;long LongVal2;&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;byte * my_function(long &amp;amp; LongVal) {&#xA;  return (byte*)&amp;amp;LongVal;&#xA;}&#xA;&#xA;long my_function2(byte * LongVal_byte) {&#xA;  return *((long *)LongVal_byte);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  byte * LongVal_byte = my_function(LongVal);&#xA;  LongVal2 = my_function2(LongVal_byte);  &#xA;&#xA;  Serial.println(LongVal2);  &#xA;  Serial.println(&quot; &quot;); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But it is basically exactly the same as before without functions (just no need for memcpy)&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-13T20:41:59.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26320" PostTypeId="2" ParentId="26316" CreationDate="2016-07-13T20:44:03.503" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;15:51: error: invalid conversion from 'byte {aka unsigned char}' to 'const void*' [-fpermissive]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memcpy(&amp;amp;LongVal2, LongVal_byte, sizeof(LongVal2));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;LongVal_byte is a single byte. It's not a pointer, and &lt;code&gt;memcpy&lt;/code&gt; expects a pointer.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;26:33: error: expected primary-expression before 'long'&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte LongVal_byte = my_function(long LongVal);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You do not specify the variable type when passing a variable to a function. The variable already knows what it is, and the function already knows what it wants.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;27:30: error: expected primary-expression before '&amp;amp;' token&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LongVal2 = my_function2(byte &amp;amp; LongVal_byte);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Same there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are showing a fundamental lack of understanding of some concepts of C.  Other errors you are making:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long LongVal2;&#xA;...&#xA;long my_function2(byte &amp;amp; LongVal_byte){&#xA;    long LongVal2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You should never ever re-define a global variable inside a function. It's not actually syntactically incorrect, but from a reading perspective it becomes almost impossible to keep track of &lt;em&gt;which&lt;/em&gt; &lt;code&gt;LongVal2&lt;/code&gt; variable is being used at any one time.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long my_function2(byte &amp;amp; LongVal_byte){&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are passing a reference to a &lt;em&gt;single&lt;/em&gt; byte, not an array of bytes. For that you need a pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should re-write your functions to be like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte* my_function(long LongVal) {&#xA;    return (byte *)&amp;amp;LongVal;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(although that is completely pointless, you just need to cast the value, you don't need a function to do it:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte *byteval = (byte *)&amp;amp;LongVal;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long my_function2(byte *LongVal_byte){&#xA;    long LongVal2;&#xA;    memcpy(&amp;amp;LongVal2, LongVal_byte, sizeof(LongVal2));&#xA;    return LongVal2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is a long winded, but &quot;safe&quot; way of doing it. It is needed only on CPUs where alignment matters.  On an 8-bit CPU the alignment is 8-bit, and so a 32-bit word can be at any address.  On a 32-bit system a 32-bit word will be at a 4-byte alignment, so that method is needed.  On an 8-bit though you can just cast the array into a long:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long *LongValue = (long *)&amp;amp;LongVal_byte;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A better solution to the whole thing, though, is to use a union:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef union {&#xA;    byte byteval[4];&#xA;    long longval;&#xA;} LongBytes;&#xA;&#xA;LongBytes myVal;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then access:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myVal.longval = 4893723284;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And also:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myVal.byteval[i];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;i&lt;/code&gt; is 0-3.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-13T20:44:03.503" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26321" PostTypeId="1" CreationDate="2016-07-13T21:35:46.937" Score="-2" ViewCount="3618" Body="&lt;p&gt;I still a noob, and I'm learning Arduino. I built a PHP page to send values using GET parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to send a specific value from Arduino to that PHP page. I bought an ESP8266, and I would like to see it working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found this code and I made some changes there, but the the code is not working. I don't receive any value on my database. Can you guys help me?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;SoftwareSerial esp8266(10, 11);&#xA;String cmd;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(115200);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;  Serial.println(&quot;Started&quot;);&#xA;  // set the data rate for the SoftwareSerial port&#xA;  esp8266.begin(115200);&#xA;  esp8266.write(&quot;AT\r\n&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (esp8266.available()) {&#xA;    Serial.write(esp8266.read());&#xA;    teste();&#xA;  }&#xA;  if (Serial.available()) {&#xA;    esp8266.write(Serial.read());&#xA;  }&#xA;}&#xA;&#xA;void teste(){&#xA;  // Connect to the server&#xA;  esp8266.write(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;http://bubu.esy.es\&quot;,80\r\n&quot;);&#xA;  //make this command: AT+CPISTART=&quot;TCP&quot;,&quot;192.168.88.35&quot;,80&#xA;  //wait a little while for 'Linked'&#xA;  delay(300);&#xA;&#xA;  //This is our HTTP GET Request change to the page and server you want to load.&#xA;  cmd = &quot;GET /teste.php?test=5 HTTP/1.0\r\n&quot;;&#xA;  cmd += &quot;Host: http://bubu.esy.es\r\n\r\n&quot;;&#xA;  //The ESP8266 needs to know the size of the GET request&#xA;  esp8266.write(&quot;AT+CIPSEND=&quot;);&#xA;  esp8266.write(cmd.length());&#xA;  esp8266.write(&quot;\r\n&quot;);&#xA;  esp8266.write(&quot;GET /teste.php?test=5 HTTP/1.0\r\nHost: http://bubu.esy.es\r\n\r\n&quot;);&#xA;  esp8266.write(&quot;AT+CIPCLOSE\r\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23883" LastEditorUserId="4628" LastEditDate="2017-01-10T12:05:02.510" LastActivityDate="2018-01-06T07:19:02.170" Title="Send values to a PHP page using Arduino ESP8266" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26322" PostTypeId="2" ParentId="26305" CreationDate="2016-07-13T22:13:22.673" Score="2" Body="&lt;p&gt;When I first built my first Arduino clone, I fount very useful the Fritzing examples &lt;em&gt;(boards and schematics)&lt;/em&gt;. &lt;a href=&quot;http://fritzing.org/home/&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://fritzing.org/home/&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind that in order to upload sketches, an FTDI module is very handy &lt;em&gt;(unless you use ISP via another Arduino board)&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case, I should recommend you to build an Arduino clone on a breadboard, before trying soldering. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, you may use this picture &lt;em&gt;(this is how  I create an Arduino on breadboard)&lt;/em&gt;:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/6RV5c.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/6RV5c.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;External power &lt;em&gt;(battery)&lt;/em&gt; is connected to the screw pins &lt;em&gt;(bottom left of the breadboard)&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7728" LastEditorUserId="7728" LastEditDate="2016-07-14T08:09:31.320" LastActivityDate="2016-07-14T08:09:31.320" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26324" PostTypeId="1" CreationDate="2016-07-14T00:14:13.217" Score="0" ViewCount="470" Body="&lt;p&gt;I'm using dtostrf() to transcribe a float into a string for my touchscreen. I'd leave it as a float, but my screen orientation library function only works with a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I have a char array, then a float value. then dtostrf().&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char buffer[6]&#xA;float X; //changes each loop with incoming sensor data from pixy camera&#xA;float thingposition = X * .0064  //float calculations are performed.&#xA;&#xA;void loop(){&#xA;Camera.Get_X();   //retrieves X from the camera. waits until X has been recieved via UART serial&#xA;dtostrf(buffer, 5, 2, thingposition) // writes float to string with a controled decimal place and all that - dtostrf(floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf);&#xA;Tft.drawString(buffer, 70, 215, 5, WHITE);   //print output to screen&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that this is a simplified version. In my code I also have methods for overwriting my last string value on the LCD when the new one has changed.&#xA;I also have several &quot;if&quot; conditionals that control whether I write the buffer value to the screen or instead send an error message. Those things do not seem to be causing me problems though, except to say that my buffer overflows only occur when I cause the sensors to flip the conditionals at just the right interval. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, when I place my hand in front of the camera, that triggers the error message. Take my hand away, and then the number &quot;thingposition&quot; is printed to the screen. But if I time my hand just right, the buffer overflows and numbers loop across the screen. Usually this freezes the whole sketch. The best I can figure is that since dtostrf() does not check bounds, and since the calculated float values can be longer than the buffer has room for, that sometimes dtostrf() tries to write too many digits to the buffer. Something timing-related seems to trigger the problem, but what I need is some way to prevent the overflow in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried rounding &quot;thingposition&quot; to a certain number of sigfigs, but I can't seem to truncate it at the desired decimal point. That shouldn't matter though, since dtostrf has controls for the minimum total length including the decimal point, as well the number of digits after the decimal. I also tried making sure that the last byte in my char array is null by adding this right after dtostrf():&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;stringval[5] = NULL;   //make sure buffer is null-terminated to prevent buffer overflow&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've tried doubles, different ways of rounding, and anything I could find, but the problem has persisted for several weeks and a few steady days worth of searching for a solution. I'll be glad to provide further information if anyone has any ideas on what to try. Thanks everyone.&lt;/p&gt;&#xA;" OwnerUserId="19892" LastActivityDate="2016-07-15T00:45:58.413" Title="Can anyone help me spot where my buffer overflow might be occuring?" Tags="|float|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26325" PostTypeId="2" ParentId="26324" CreationDate="2016-07-14T01:49:28.073" Score="1" Body="&lt;p&gt;The problem with using &quot;simplified code&quot; is that your 'simplification' may not have captured your problem. But I will take your code as given and assume that it's correct (which I'm afraid it isn't).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var&#xA;    char buffer[6]  // Won't compile - no semicolon (';')&#xA;    float X;        // Uninitialised value - could be 1000000000000&#xA;    float thingposition = X * .0064 // No ';', and .0064 of 10000000000 is huge!&#xA;&#xA;void loop(){&#xA;    Camera.Get_X(); // Should this be &quot;X = Camera.Get_X();&quot; ?&#xA;    dtostrf(buffer, 5, 2, thingposition)  // No ';'. You NEED to recalculate thingposition!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the above code is a good representation of what you've got, you seem to be assuming that you define the formula once (in the &lt;code&gt;thingposition&lt;/code&gt; line), and it automatically applies that formula, like Excel, when you change its input, &lt;code&gt;X&lt;/code&gt;. Sorry, programs don't work that way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once you calculate &lt;code&gt;thingposition&lt;/code&gt;, it becomes independent of where it came from. If you change other variables, &lt;code&gt;thingposition&lt;/code&gt; kees its value until you explicitly change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do you fix it? You recalculate &lt;code&gt;thingposition&lt;/code&gt; every time:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;var&#xA;    char buffer[6];      // Hopefully big enough - see below&#xA;    float X;             // Used by Camera.Get_X()&#xA;    float thingposition;&#xA;&#xA;void loop(){&#xA;    X = Camera.Get_X();        // Get X from Camera&#xA;    thingposition = X * .0064; // Calculate thingposition&#xA;    dtostrf(buffer, 5, 2, thingposition);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;dtostrf()&lt;/code&gt; will try to obey your size parameters, &lt;strong&gt;BUT&lt;/strong&gt;. If the float is larger than your maximum size, it WILL print out the full number anyway. That is, if &lt;code&gt;thingposition&lt;/code&gt; is &lt;code&gt;1000&lt;/code&gt;, it will produce 5 characters all right: &lt;code&gt;&quot;1000.&quot;&lt;/code&gt;. But if it's &lt;code&gt;1000000&lt;/code&gt;, it will produce &lt;code&gt;&quot;1000000&quot;&lt;/code&gt; which is seven characters. You need to ensure that &lt;code&gt;buffer&lt;/code&gt; is big enough to handle larger numbers than you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do the maths. If &lt;code&gt;X&lt;/code&gt; is guaranteed to be between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;255&lt;/code&gt;, then multiplying it by &lt;code&gt;0.0064&lt;/code&gt; will result in a maximum value of &lt;code&gt;1.632&lt;/code&gt;, so the above &lt;code&gt;dtostrf()&lt;/code&gt; woud produce &lt;code&gt;&quot; 1.63&quot;&lt;/code&gt;. No problem!&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-07-15T00:45:58.413" LastActivityDate="2016-07-15T00:45:58.413" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26328" PostTypeId="1" CreationDate="2016-07-14T06:23:16.187" Score="1" ViewCount="1696" Body="&lt;p&gt;I want to switch on and off a motor with arduino, used for pumping water. I need to have a idea which relay could be used with arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a photo of a similar motor:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ILtiu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ILtiu.jpg&quot; alt=&quot;Motor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23889" LastActivityDate="2022-12-03T10:03:20.367" Title="Relay for controlling a water pump motor" Tags="|arduino-uno|motor|relay|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26331" PostTypeId="2" ParentId="26321" CreationDate="2016-07-14T07:51:56.993" Score="0" Body="&lt;p&gt;&lt;code&gt;Host: http://bubu.esy.es&lt;/code&gt; needs to be &lt;code&gt;Host: bubu.esy.es&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-14T07:51:56.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26332" PostTypeId="2" ParentId="26313" CreationDate="2016-07-14T07:59:06.780" Score="0" Body="&lt;p&gt;Just invert it in software. Instead of &lt;code&gt;analogRead(0)&lt;/code&gt; use &lt;code&gt;(1023-analogRead(0))&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-14T07:59:06.780" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26336" PostTypeId="2" ParentId="26285" CreationDate="2016-07-14T10:15:26.957" Score="1" Body="&lt;p&gt;Let me guess: &quot;&lt;em&gt;much&lt;/em&gt; more time&quot; is about, ohhh, 16 times?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When &lt;code&gt;millis()&lt;/code&gt; was written, it had to assume what the input clock was. There is no way to detect the speed of the input clock: to do so would require another clock! So the writers of the function defined a starting constant, set it to &lt;code&gt;1000000&lt;/code&gt;, and required anyone that changed the clock would have to change that constant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Find the constant, and set it to &lt;code&gt;16000000&lt;/code&gt;. Voilà!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's an article on the source code of the function:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/&quot; rel=&quot;nofollow&quot;&gt;https://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-14T10:15:26.957" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26337" PostTypeId="2" ParentId="26313" CreationDate="2016-07-14T10:39:51.897" Score="1" Body="&lt;p&gt;Arduino can not measure resistance. It can measure voltage.&lt;br&gt;&#xA;To measure resistance you can convert resistance to voltage using a voltage divider.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Arduino world a voltage divider consists out of 2 resistors in series between 5V and gnd. The connection to the 2 resistors is connected to a analogue pin. &#xA;Depending whether your LDR is connected to gnd or 5V the measured value on the analogue pin will go up or down with the resistance of the LDR.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words swap the resistor and your LDR from position.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-07-14T10:39:51.897" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26338" PostTypeId="1" AcceptedAnswerId="26340" CreationDate="2016-07-14T11:05:55.410" Score="2" ViewCount="3287" Body="&lt;p&gt;I've decided to make a quadcopter but since I'm a rookie, i decided against doing it from scratch. I'm planning to order &lt;a href=&quot;http://www.amazon.in/ENGINEERSTOYS-ET-01-Engineerstoys-Mini-Quadcopter/dp/B01HTIM5WG/ref=sr_1_4?ie=UTF8&amp;amp;qid=1468170793&amp;amp;sr=8-4&amp;amp;keywords=kit%20quadcopter&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; kit, first understand the dynamics and then try and make a quadcopter on my own using the components in it.&#xA;My first question are&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Can I control the 4 motors using 2 H-bridges (L293D)?&lt;/li&gt;&#xA;&lt;li&gt;Are ESC's necessary if I use the PWM pins?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="20571" LastEditorUserId="20571" LastEditDate="2016-07-14T11:22:27.443" LastActivityDate="2018-03-02T09:12:12.483" Title="Controlling 4 motors using the Arduino Uno" Tags="|arduino-uno|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26340" PostTypeId="2" ParentId="26338" CreationDate="2016-07-14T11:42:52.783" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Can I control the 4 motors using 2 H-bridges (L293D)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. Two per chip.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are ESC's necessary if I use the PWM pins?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is one thing you must understand first: there are two kinds of DC motor - Brushed and Brushless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Brushed motor is the &quot;normal&quot; kind - you apply power to it and it spins.  These you control with the likes of an L293D and use PWM to control the speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Brushless motors are the kind you have in hard drives and the like. They consist of a number of coils that get turned on and off at the right time to pull a magnet around in a circle (to put it crudely). These require special timing and control to get the coils energised at the right time and in the right way. This is what an ESC is for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Brushless motors are smaller and lighter for the same power than brushed ones. They also have a longer life. Because of this they are generally preferred to brushed motors on quadcopters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Brushed motors have a very high starting torque, don't require complex control logic and use less energy when not running full speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you use brushless motors, which ideally you should (though I can't tell what kind of motors those are in that kit) then you must either use an ESC or build your own ESC using an Arduino and multiple motor driver circuits. Simplest to use an ESC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't use brushless motors then an ESC is not what you want to use - just the L293D chips and PWM.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="18478" LastEditDate="2016-07-15T06:15:46.060" LastActivityDate="2016-07-15T06:15:46.060" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26347" PostTypeId="1" CreationDate="2016-07-14T17:09:30.943" Score="1" ViewCount="429" Body="&lt;p&gt;So, I recently bought an Arduino Mini (5V, 16MHz), and a USB to Serial Converter.&#xA;Provided are the links to both the products:&#xA;&lt;a href=&quot;https://www.techshopbd.com/product-categories/boards/1455/arduino-mini-china-techshop-bangladesh&quot; rel=&quot;nofollow&quot;&gt;Arduino Mini,&lt;/a&gt;&#xA;&lt;a href=&quot;https://www.techshopbd.com/product-categories/modules-98775/808/usb-to-serial-converter-techshop-bangladesh&quot; rel=&quot;nofollow&quot;&gt;USB to Serial Converter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, I tried programming the mini by connecting the pins in this order:&#xA;Rx -&gt; tx, tx-&gt; rx, VCC -&gt; 5V, GND -&gt; GND, DTR -&gt; DTR&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The computer detected the USB to Serial converter after I installed the drivers manually. However, the Arduino IDE failed to program the Arduino Mini every single time, even after I swapped the TX, RX pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to program the Arduino Mini using an Arduino Uno (I removed the onboard Atmel Atmega microcontroller on the Uno before programming). I connected the pins in this order: TX-&gt;TX, RX-&gt;RX, 5V-&gt; VCC, GND-&gt; GND, RST -&gt; DTR. From the IDE, I chose Arduino Pro Mini (5V, 16Mhz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Mini was programmed successfully this time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question: What was wrong with the USB to Serial converter? Why couldn't it program the Arduino Mini with the USB to Serial Converter? &lt;/p&gt;&#xA;" OwnerUserId="23506" LastEditorUserId="23506" LastEditDate="2016-07-15T06:13:19.527" LastActivityDate="2017-08-10T17:46:48.140" Title="Programming an Arduino Mini 05" Tags="|programming|usb|arduino-mini|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26348" PostTypeId="1" AcceptedAnswerId="26349" CreationDate="2016-07-14T17:54:02.670" Score="2" ViewCount="945" Body="&lt;p&gt;I'm trying to create an array in Arduino Due and when the &#xA;array exceeds the size of 32768 integer elements &#xA;the compiler (Atmel Studio) complains.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read that Arduino Due SRAM size is 96K in 2 banks. 64Kb and 32Kb.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyone knows any details? &lt;/p&gt;&#xA;" OwnerDisplayName="user13309" LastActivityDate="2016-07-14T22:35:23.827" Title="Arduino Due SRAM" Tags="|arduino-due|sram|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26349" PostTypeId="2" ParentId="26348" CreationDate="2016-07-14T18:08:03.023" Score="2" Body="&lt;p&gt;Size of int in arduino due is 4Bytes. If you're trying to create array of 32768 integers, it means you need &lt;strong&gt;128kB&lt;/strong&gt; of free space.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-14T18:08:03.023" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26350" PostTypeId="1" AcceptedAnswerId="26353" CreationDate="2016-07-14T18:23:27.850" Score="2" ViewCount="335" Body="&lt;p&gt;having strange behavior with motor shield and steppers. when i'm trying to make &lt;code&gt;onestep&lt;/code&gt;, motor just makes some high-frequent noise, but when i add &lt;code&gt;Serial.println&lt;/code&gt; for debugging, it moves as intended.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;what is going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is an example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&#xA;#include AFMotor.h //dunno how to put angle brackets here&#xA;&#xA;AF_Stepper lrM(48, 1);&#xA;&#xA;void rightStep() {  &#xA;  lrM.onestep(BACKWARD, INTERLEAVE);&#xA;}&#xA;void leftStep() {  &#xA;  lrM.onestep(FORWARD, INTERLEAVE);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;ready&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  rightStep();&#xA;//Serial.println(&quot;right&quot;);&#xA;}&#xA;&lt;/pre&gt;&#xA;" OwnerUserId="23272" LastEditorUserId="23272" LastEditDate="2016-07-14T18:42:51.737" LastActivityDate="2016-07-14T18:59:08.067" Title="motor does not move without Serial.println" Tags="|arduino-motor-shield|stepper|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26351" PostTypeId="1" AcceptedAnswerId="28112" CreationDate="2016-07-14T18:40:06.077" Score="0" ViewCount="1100" Body="&lt;p&gt;I get the following error when I try to burn the arduino bootloader on an atmega328 mcu:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: verification error, first mismatch at byte 0x0000&#xA;         0xfd != 0x05&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using an Arduino as ISP programmer. My computer runs Ubuntu 16.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This did not happen when I was using Ubuntu 14. I also tested it on another machine with Ubuntu 14 and this error does not appear. Seems to be something with Ubuntu 16. I installed Arduino IDE using the out of the box repo.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The avrdude command launched by the IDE is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Am I safe replacing the -Uefuse:w:0x05:m with -Uefuse:w:0xfd:m ?? If answer is yes how can I get the IDE to do this correctly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uploading a sketch works pretty well.&lt;/p&gt;&#xA;" OwnerUserId="16805" LastActivityDate="2016-08-07T08:35:01.593" Title="Burn arduino bootloader using ubuntu 16" Tags="|arduino-ide|bootloader|ubuntu|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26352" PostTypeId="2" ParentId="26350" CreationDate="2016-07-14T18:58:52.307" Score="0" Body="&lt;p&gt;When you have a Serial print statement running really quickly the output buffer will fill up and the &lt;code&gt;print&lt;/code&gt; command will have to wait for there to be room; That causes the command to take a substantial amount of time to complete.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the statement is missing, you loop probably runs a few hundred times faster than without it (depending on how long &lt;code&gt;onestep&lt;/code&gt; takes), probably fast enough that the physical motor can not keep up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try adding a delay of a few milliseconds or some kind of rate limiting to the program and then see how much of a difference &lt;code&gt;serial.println&lt;/code&gt; makes.&lt;/p&gt;&#xA;" OwnerUserId="1585" LastActivityDate="2016-07-14T18:58:52.307" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26353" PostTypeId="2" ParentId="26350" CreationDate="2016-07-14T18:59:08.067" Score="1" Body="&lt;p&gt;My guess is &lt;code&gt;Serial.println&lt;/code&gt; adds additional delay so stepper motor can react. Without it changes are way too fast (= high frequency noise) to do whole step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try to add &lt;code&gt;delay(1);&lt;/code&gt; or more into the main loop.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-14T18:59:08.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26354" PostTypeId="2" ParentId="26348" CreationDate="2016-07-14T22:22:21.147" Score="1" Body="&lt;p&gt;I've read in several places that e.g. PROGMEM const int foo[] = { 1, 2, 3, ... } would work, but was unable to do it in my environment ( debian, arduino-mk package ). I had a number of arrays I needed to commit to flash to conserve sram. This worked fine for all variables, but not for arrays. Try that... What say the wizards?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note to moderators and others: I &lt;em&gt;know&lt;/em&gt; I am not answering the question definitively, but it is relevant to OP's question.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="16673" LastEditDate="2016-07-14T22:35:23.827" LastActivityDate="2016-07-14T22:35:23.827" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26356" PostTypeId="1" AcceptedAnswerId="26381" CreationDate="2016-07-14T22:54:13.907" Score="1" ViewCount="1120" Body="&lt;p&gt;I'm working on a project for school. I'm trying to rotate a servo by writing the letter that identify the servo and then the angle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the problem is that sometimes the last number of the angle is lost or the whole angle all together. for example i want to rotate servo &quot;a&quot; 50 degrees. i enter a50 this works most of the time but sometimes i only get a 5 without the zero and sometimes i just get a zero. can anyone help, thanks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;please keep in mind i only did computer science in high school and intro to c++ in college. go easy on me please.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;attached is the code and an image illustrating my problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo1;  &#xA;Servo servo2;&#xA;Servo servo3;&#xA;&#xA;String angle1=&quot;&quot;;&#xA;String angle2=&quot;&quot;;&#xA;&#xA;char serialbuffer[4];&#xA;int index=0;&#xA;int charcount=0;&#xA;&#xA;int lastangle;&#xA;int dif;&#xA;&#xA;&#xA;void setup() {&#xA;  servo3.attach(3);  // attaches the servo on pin 9 to the servo object&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  serialbuffer[0]='0';&#xA;  serialbuffer[1]='0';&#xA;  serialbuffer[2]='0';&#xA;  serialbuffer[3]='0';&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;       charcount=0;&#xA;       index=0;&#xA;       serialbuffer[0]=99;&#xA;&#xA;   while (Serial.available() &amp;gt; 0) {&#xA;&#xA;      char charbuffer = Serial.read();&#xA;       if(charbuffer=='\n'){&#xA;          index=0; &#xA;        }&#xA;        else{&#xA;&#xA;           serialbuffer[index]=charbuffer;&#xA;           index++;&#xA;           charcount++;&#xA;          }&#xA;&#xA;      }&#xA;&#xA;  angle1=&quot;&quot;;    &#xA;  if(serialbuffer[0]=='a'){&#xA;&#xA;      for(int i=1;i&amp;lt;charcount;i++){&#xA;         angle1+=serialbuffer[i];&#xA;      }&#xA;      move_servo3(angle1);&#xA;      index=0;&#xA;      serialbuffer[0]=99;&#xA;    }&#xA;  delay(15);&#xA;}&#xA;&#xA;void move_servo3(String angle2){&#xA;&#xA;&#xA;   Serial.println(angle2.toInt());   &#xA;   servo3.write(angle2.toInt()); &#xA;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Y18l6.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Y18l6.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23912" LastEditorUserId="10394" LastEditDate="2016-07-15T09:07:52.297" LastActivityDate="2016-07-15T11:58:14.743" Title="why am I losing data over serial communication between arduino and pc" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26357" PostTypeId="1" AcceptedAnswerId="26368" CreationDate="2016-07-15T02:12:05.467" Score="0" ViewCount="9517" Body="&lt;p&gt;I'd like to know if there is a function or some way to define min and max value to potentiometer, for example: I'm using a mechanical part that only tour the potentiometer a little bit, what means the potentiometer doesn't start in the beginning and doesn't finish in the end. So, how can I make this space the potentiometer tour means 0 to 255 the start to end, respectively?&lt;/p&gt;&#xA;" OwnerUserId="23915" LastActivityDate="2016-07-15T07:20:42.847" Title="Change max and min read value of potentiometer" Tags="|arduino-uno|analogread|potentiometer|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26358" PostTypeId="2" ParentId="26357" CreationDate="2016-07-15T02:42:53.310" Score="0" Body="&lt;p&gt;Either use a reference voltage closer to the maximum voltage the potentiometer is capable of, or use &lt;a href=&quot;https://www.arduino.cc/en/Reference/Map&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt; to map the existing limited range to a larger range. Note that using &lt;code&gt;map()&lt;/code&gt; will not improve precision. &lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-15T02:42:53.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26362" PostTypeId="2" ParentId="26357" CreationDate="2016-07-15T04:55:53.117" Score="0" Body="&lt;p&gt;If the values from the pot are 0 - 1023 you can divide the number by 4 which would give you a closer range to what you need. The map() function can be used instead.&lt;/p&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-07-15T04:55:53.117" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26363" PostTypeId="1" CreationDate="2016-07-15T05:42:33.787" Score="0" ViewCount="5229" Body="&lt;p&gt;Basically the user presses a button and cycles thru 3 different modes. Mode 1 the LED is on, mode 2 the LED is off and mode 3 the LED is kept on for a certain amount of time. I'm using the millis() to keep track of the time. the LED in the third mode just stays on and never switches to off. I have the Serial.Writes in there to help me debug. I have the delay after the button read since if I didnt put it in it would register a lot of button presses. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 5;&#xA;int buttonApin = 9;&#xA;int ledMode = 0;&#xA;&#xA;boolean lastButton = HIGH;&#xA;boolean currentAButton = HIGH;&#xA;&#xA;// debounce button&#xA;boolean debounceFUNC(boolean last)&#xA;{&#xA;    boolean current = digitalRead(buttonApin);&#xA;    if (last != current)&#xA;    {&#xA;        delay(5);&#xA;        current = digitalRead(buttonApin);&#xA;    }&#xA;    return current;&#xA;}&#xA;&#xA;void setMode(int ledMode)&#xA;{&#xA;    // turns on led&#xA;    if (ledMode == 1)&#xA;    {&#xA;        digitalWrite(ledPin, HIGH);&#xA;    }&#xA;    // turns off led&#xA;    if (ledMode == 2)&#xA;    {&#xA;    digitalWrite(ledPin, LOW);&#xA;    }&#xA;    // timer - turns off after 5000&#xA;    if (ledMode == 3)&#xA;    {&#xA;        long interval = 5000;&#xA;        unsigned long cMillis = millis();&#xA;        static unsigned long pMillis;&#xA;&#xA;        if (cMillis - pMillis &amp;gt; interval)&#xA;        {   &#xA;        pMillis = cMillis;&#xA;        digitalWrite(ledPin, HIGH);&#xA;        Serial.println(&quot;On&quot;);&#xA;        Serial.println(interval - cMillis);&#xA;        }&#xA;        else&#xA;        {&#xA;        digitalWrite(ledPin, LOW);&#xA;        Serial.println(&quot;Off&quot;);&#xA;        }&#xA;&#xA;        }&#xA;    }&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    pinMode(ledPin, OUTPUT);&#xA;    pinMode(buttonApin, INPUT_PULLUP);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    // sets led mode&#xA;    currentAButton = debounceFUNC(lastButton);&#xA;    delay(500);&#xA;    if (currentAButton == LOW)&#xA;    {&#xA;        ledMode++;&#xA;        Serial.println(ledMode);&#xA;    }&#xA;    else if (ledMode &amp;gt; 3)&#xA;    {&#xA;        ledMode = 0;&#xA;    }&#xA;    // ledMode function call&#xA;    setMode(ledMode);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;screenshot of the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/cqDws.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cqDws.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-07-15T11:25:51.043" Title="using millis() for a timer" Tags="|time|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26364" PostTypeId="1" AcceptedAnswerId="26383" CreationDate="2016-07-15T06:08:06.740" Score="0" ViewCount="1125" Body="&lt;p&gt;I'm trying to make a human following robot.Tried using ultrasonic sensors to follow a specific person by Having ultrasonic sensor with the person to send echo to the robot,But it didn't workout.&#xA;Any way to track a specific person and follow ?&#xA;Any sensors/algorithm to track fast moving object(a person but not specific)?&lt;/p&gt;&#xA;" OwnerUserId="23920" LastActivityDate="2016-07-15T13:13:22.583" Title="Motion Tracking Using Arduino?" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26366" PostTypeId="2" ParentId="26363" CreationDate="2016-07-15T06:22:57.940" Score="1" Body="&lt;p&gt;The problem is in the logic, basically your statement:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;    if (cMillis - pMillis &amp;gt; interval)&#xA;    {   &#xA;       pMillis = cMillis;&#xA;       digitalWrite(ledPin, HIGH);&#xA;        Serial.println(&quot;On&quot;);&#xA;        Serial.println(interval - cMillis);&#xA;    }&#xA;    else&#xA;    {&#xA;       digitalWrite(ledPin, LOW);&#xA;       Serial.println(&quot;Off&quot;);&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;will always be true, this is as the difference in time, &lt;code&gt;cMillis - pMillis&lt;/code&gt; is always greater than &lt;code&gt;interval&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This means that it never enters the else statement to turn off the LED, and thus means the &lt;code&gt;else&lt;/code&gt; statement is usually the first thing that rune at &lt;code&gt;ledMode = 3&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you need to do as the simplest fix is to change your comparison, change &lt;strong&gt;&lt;code&gt;&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/strong&gt;, in the is statement:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if (cMillis - pMillis &amp;gt; interval)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if (cMillis - pMillis &amp;lt; interval)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will ensure the LED is always on during the 5000 mS and then as soon as it is greater it will definitely go to the &lt;code&gt;else&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-07-15T06:22:57.940" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26368" PostTypeId="2" ParentId="26357" CreationDate="2016-07-15T07:20:42.847" Score="1" Body="&lt;p&gt;You cannot declare that the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; values of a potentiometer are &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;. What you can do is &lt;code&gt;map()&lt;/code&gt; the values of the potentiometer to your own desired scale.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do this, you'll have to get the following values:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Minimum value of the potentiometer, &lt;code&gt;pMin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Maximum value of the potentiometer, &lt;code&gt;pMax&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But these values aren't what you want. For example, what you want is &lt;code&gt;pmin&lt;/code&gt; to be &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;pMax&lt;/code&gt; to be &lt;code&gt;100&lt;/code&gt;. So, you'll have to scale &lt;code&gt;pMin&lt;/code&gt; and &lt;code&gt;pMax&lt;/code&gt; to those values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For this, you use the &lt;code&gt;map()&lt;/code&gt; function. What &lt;code&gt;map()&lt;/code&gt; does is changing the value in a given scale, to that of another scale. Let's get some example code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int pMin = 14;  //the lowest value that comes out of the potentiometer&#xA;int pMax = 948; //the highest value that comes out of the potentiometer.&#xA;&#xA;int x = 0;  //we will use this value to store the readings of the potentiometer&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); //Serial monitor can be used to check the values&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA;  x = analogRead(A0); //connect the potentiometer to the A0 pin of the Arduino&#xA;&#xA;  Serial.print(x);  //prints the original reading&#xA;&#xA;  x = map(x, pMin, pMax, 0, 100) //take the value of x, compared it to the scale of the potentiometer pMin to pMax, and translate that value to the scale of 0 to 100&#xA;&#xA;  Serial.print(&quot;\t&quot;); //a tab to make the reading more easy&#xA;  Serial.println(x);  //post mapped value, println is a linebreak as well&#xA;  delay(100); //so we don't post to much in the serial and you can read data better.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With this example you can clearly see how your potentiometer behaves and how you can use the 'weird' values from its readings in a useful way for your projects.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-15T07:20:42.847" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26369" PostTypeId="2" ParentId="26364" CreationDate="2016-07-15T08:03:46.870" Score="1" Body="&lt;p&gt;You need the person to emit a signal and the robot to receive it, sounds simple, but it isn't.  What you are trying to do is position fix the transmitter, in the same way as an ATC locates a plane.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The robot will need at least two directional receivers positioned a certain distance apart (depends of frequency and accuracy) to allow the robot to triangulate the transmitter.  The more receivers the more complex the triangulation.  The frequency of the signal you transmit will affect the distance that the robot can be from the person, research Frequency spectrum and transmission distances.  The longer the distance the signal can travel the stronger the signal will be at close range.  You also have to counter reflections and side lobes which will give you inaccurate readings on the transmitter direction.&#xA;Once you have dealt with all of that all you need to do is scan for the strongest signal on your frequency, triangulate it and then head towards it.&#xA;Whatever sensor you use the theory is the pretty much the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Could you tag the person with a GPS receiver and WIFI/BT and get it to transmit its location.  The robot could then consult its GPS and calculate the delta and move accordingly.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-15T08:03:46.870" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26370" PostTypeId="2" ParentId="26356" CreationDate="2016-07-15T08:19:03.783" Score="0" Body="&lt;p&gt;I don't understand why the problem is being caused, your code looks OK, but this is too big for a comment.  &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I think it would be better if you initialised you serialbuffer with NULL rather than '0'.  This way angle2.ToInt() will just read the number you have typed, rather than what was in there last time.  Try entering a111 and then a2.  You will get a211 second time.  NULL is the end of a string.&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In loop() change your while loop to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char charBuffer = Serial.read();&#xA;while (charBuffer != '\n' &amp;amp;&amp;amp; index &amp;lt; 4) // Index &amp;lt; 4 stops a buffer overflow.&#xA;{&#xA;  serialbuffer[index++] = charBuffer;&#xA;  charCount++;&#xA;  charBuffer = Serial.read();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This will keep reading until it sees a new line, which I think is what you want.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You don't need the delay statement now, the speed is controlled by&#xA;how fast you can type.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The for statement could be changed to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 4 &amp;amp;&amp;amp; serialbuffer[i] != NULL; ++i)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you make these changes I think it might help see the problem.  Also printing the number that has been typed in before the for loop might help, it will print now because you have initialised it to NULL.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-15T08:19:03.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26371" PostTypeId="1" CreationDate="2016-07-15T09:23:57.090" Score="2" ViewCount="1243" Body="&lt;p&gt;I am using an Arduino Mega to control the speed of an AC pump. This can be done by connecting to the variable frequency drive. Here is a link of the relevant datasheet, pages 66 and 67 relate to what I am doing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.parker.com/Literature/SSD%20Drives/AC%20Drives/AC650/HA464828U003.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.parker.com/Literature/SSD%20Drives/AC%20Drives/AC650/HA464828U003.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I have read and been told already, I should be able to control this using a 4 - 20 mA loop, which is fed into AIN2, as long as I connect the 0V terminal as well?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is what is the best way to make a current loop transmitter using an Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far the options I have are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Create a circuit out of discrete components, this would then be controlled using the Megas PWM&lt;/li&gt;&#xA;&lt;li&gt;Use an IC circuit, I was looking at the AD694JNZ&lt;/li&gt;&#xA;&lt;li&gt;Use an add on board, I was looking at this one: &lt;a href=&quot;http://uk.rs-online.com/web/p/products/8828929/?grossPrice=Y&amp;amp;cm_mmc=UK-PLA-_-google-_-PLA_UK_EN_Semiconductors-_-Semiconductor_Development_Kits&amp;amp;mkwid=sm9dTYvCc_dc|pcrid|88057061283|pkw||pmt||prd|8828929&amp;amp;gclid=CjwKEAjwk6K8BRDM3aCSkdCtzSQSJAA3Vf38mNs9lZrg2A1AjrVpS3SCubT0AbAr7L8OImUZbfCPzRoCIXjw_wcB&quot; rel=&quot;nofollow&quot;&gt;http://uk.rs-online.com/web/p/products/8828929/?grossPrice=Y&amp;amp;cm_mmc=UK-PLA-&lt;em&gt;-google-&lt;/em&gt;-PLA_UK_EN_Semiconductors-_-Semiconductor_Development_Kits&amp;amp;mkwid=sm9dTYvCc_dc|pcrid|88057061283|pkw||pmt||prd|8828929&amp;amp;gclid=CjwKEAjwk6K8BRDM3aCSkdCtzSQSJAA3Vf38mNs9lZrg2A1AjrVpS3SCubT0AbAr7L8OImUZbfCPzRoCIXjw_wcB&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I have a budget for my project so cost is not an issue, however I am running out of time. What would be the easiest method to implement and how?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have been thinking of using options 2 or 3, however my issues are that this is my first Arduino project. I understand what PWM is but I don't know how I would go about implementing it. I also can't find any tutorials online that demonstrate how to program the MIKROE board using an Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance for any help :)&lt;/p&gt;&#xA;" OwnerUserId="23924" LastActivityDate="2018-03-09T17:03:00.267" Title="How do you use an Arduino to control a 4 - 20 mA transmitter?" Tags="|arduino-mega|pwm|voltage-level|current|remote-control|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26373" PostTypeId="1" CreationDate="2016-07-15T10:13:59.257" Score="-2" ViewCount="200" Body="&lt;p&gt;I have 3 motors which work at 12&amp;nbsp;V 3&amp;nbsp;A, I have attached a 12&amp;nbsp;V 6&amp;nbsp;A power supply and seems to be working fine. However I was wondering if this can also power the Arduino as well.&lt;/p&gt;&#xA;" OwnerUserId="23927" LastEditorUserId="6936" LastEditDate="2018-07-12T12:07:26.563" LastActivityDate="2018-07-12T12:07:26.563" Title="12 V 6 A power supply for Arduino" Tags="|arduino-mega|power|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="26374" PostTypeId="2" ParentId="26371" CreationDate="2016-07-15T10:15:42.140" Score="1" Body="&lt;p&gt;I can recommend the Click boards from MikroElektronica (I am the chief engineer porting support for them, and the PIC32-based Clicker development board series, to the chipKIT™ system).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 4-20mA-T Click board is controlled by the Microchip MCP4921 DAC. This is a common DAC family used in many Arduino projects and there are plenty of libraries around for them (mine is &lt;a href=&quot;https://github.com/MajenkoLibraries/MCPDAC&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; though it's aimed at the 4822 not the 4921).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically you set the DAC output voltage which sets the current output from an XTR116 current loop transmitter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The XTR116 takes an input of 0 - 4.095v, and provides a convenient 4.095v reference voltage to the MCP4921.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.ti.com.cn/cn/lit/ds/symlink/xtr116.pdf&quot; rel=&quot;nofollow&quot;&gt;Datasheet for the XTR116&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/21897a.pdf&quot; rel=&quot;nofollow&quot;&gt;Datasheet for the MCP4921&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://download.mikroe.com/documents/add-on-boards/click/4-20ma/4-20ma-click-manual-v100.pdf&quot; rel=&quot;nofollow&quot;&gt;Manual for the 4-20mA T Click&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The whole thing is isolated from your main board through an ADu M1411 to keep everything safe from industrial process noise.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-15T10:15:42.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26375" PostTypeId="1" AcceptedAnswerId="26379" CreationDate="2016-07-15T10:21:39.547" Score="0" ViewCount="1056" Body="&lt;p&gt;I am trying to switch ON/OFF 10 relays connected to ATmega328P via Bluetooth HC-06 module. The problem I am facing is that when I try to Switch ON more than 3-4 relays, some of the previously ON relays switch OFF and the ATmega328 restarts. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a 12V 2A power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have set up my circuit as shown below&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/11oQ2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/11oQ2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int r1 = 4, r2 = 5, r3 = 6, r4 = 7, r5 = 8, r6 = 9, r7 = 10, r8 = 11, r9 = 12, r10 = 13;&#xA;char state;&#xA;String msg;&#xA;int r = 0;&#xA;&#xA;void setup() &#xA;{ &#xA;&#xA;    pinMode(r1, OUTPUT); &#xA;    pinMode(r2, OUTPUT);&#xA;    pinMode(r3, OUTPUT);&#xA;    pinMode(r4, OUTPUT);&#xA;    pinMode(r5, OUTPUT);&#xA;&#xA;    pinMode(r6, OUTPUT);&#xA;    pinMode(r7, OUTPUT);&#xA;    pinMode(r8, OUTPUT);&#xA;    pinMode(r9, OUTPUT);&#xA;    pinMode(r10, OUTPUT);&#xA;&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;&#xA;    while (Serial.available())&#xA;    {&#xA;      state = Serial.read();&#xA;&#xA;      if (state == '\n')&#xA;        break;&#xA;&#xA;      msg += state;&#xA;&#xA;    }&#xA;&#xA;&#xA;    if (msg.length() &amp;gt; 0) &#xA;    {&#xA;      /*Serial.print(&quot;Data: &quot;);&#xA;      Serial.println(msg);*/&#xA;&#xA;      if (msg == &quot;on1&quot;) &#xA;      {&#xA;          digitalWrite(r1, HIGH);&#xA;          Serial.print(&quot;O1&quot;);&#xA;      }&#xA;      else if (msg == &quot;on2&quot;) &#xA;      {&#xA;          digitalWrite(r2, HIGH);&#xA;          Serial.print(&quot;O2&quot;);&#xA;      }&#xA;      else if (msg == &quot;on3&quot;) &#xA;      {&#xA;          digitalWrite(r3, HIGH);&#xA;          Serial.print(&quot;O3&quot;);&#xA;      }&#xA;      else if (msg == &quot;on4&quot;) &#xA;      {&#xA;          digitalWrite(r4, HIGH);&#xA;          Serial.print(&quot;O4&quot;);&#xA;      }&#xA;      else if (msg == &quot;on5&quot;) &#xA;      {&#xA;          digitalWrite(r5, HIGH);&#xA;          Serial.print(&quot;O5&quot;);&#xA;      }&#xA;      else if (msg == &quot;on6&quot;) &#xA;      {&#xA;          digitalWrite(r6, HIGH);&#xA;          Serial.print(&quot;O6&quot;);&#xA;      }&#xA;      else if (msg == &quot;on7&quot;) &#xA;      {&#xA;          digitalWrite(r7, HIGH);&#xA;          Serial.print(&quot;O7&quot;);&#xA;      }&#xA;      else if (msg == &quot;on8&quot;) &#xA;      {&#xA;          digitalWrite(r8, HIGH);&#xA;          Serial.print(&quot;O8&quot;);&#xA;      }&#xA;      else if (msg == &quot;on9&quot;) &#xA;      {&#xA;          digitalWrite(r9, HIGH);&#xA;          Serial.print(&quot;O9&quot;);&#xA;      }&#xA;      else if (msg == &quot;on10&quot;) &#xA;      {&#xA;          digitalWrite(r10, HIGH);&#xA;          Serial.print(&quot;O10&quot;);&#xA;      }&#xA;&#xA;      //off---------------------------------------------------------&#xA;&#xA;      else if (msg == &quot;off1&quot;) &#xA;      {&#xA;          digitalWrite(r1, LOW);&#xA;          Serial.print(&quot;F1&quot;);&#xA;      }&#xA;      else if (msg == &quot;off2&quot;) &#xA;      {&#xA;          digitalWrite(r2, LOW);&#xA;          Serial.print(&quot;F2&quot;);&#xA;      }&#xA;      else if (msg == &quot;off3&quot;) &#xA;      {&#xA;          digitalWrite(r3, LOW);&#xA;          Serial.print(&quot;F3&quot;);&#xA;      }&#xA;      else if (msg == &quot;off4&quot;) &#xA;      {&#xA;          digitalWrite(r4, LOW);&#xA;          Serial.print(&quot;F4&quot;);&#xA;      }&#xA;      else if (msg == &quot;off&quot;) &#xA;      {&#xA;          digitalWrite(r5, LOW);&#xA;          Serial.print(&quot;F5&quot;);&#xA;      }&#xA;      else if (msg == &quot;off6&quot;) &#xA;      {&#xA;          digitalWrite(r6, LOW);&#xA;          Serial.print(&quot;F6&quot;);&#xA;      }&#xA;      else if (msg == &quot;off7&quot;) &#xA;      {&#xA;          digitalWrite(r7, LOW);&#xA;          Serial.print(&quot;F7&quot;);&#xA;      }&#xA;      else if (msg == &quot;off8&quot;) &#xA;      {&#xA;          digitalWrite(r8, LOW);&#xA;          Serial.print(&quot;F8&quot;);&#xA;      }&#xA;      else if (msg == &quot;off9&quot;) &#xA;      {&#xA;          digitalWrite(r9, LOW);&#xA;          Serial.print(&quot;F9&quot;);&#xA;      }&#xA;      else if (msg == &quot;off10&quot;) &#xA;      {&#xA;          digitalWrite(r10, LOW);&#xA;          Serial.print(&quot;F10&quot;);&#xA;      }&#xA;      else if (msg == &quot;offall&quot;) &#xA;      {&#xA;          digitalWrite(r1, LOW);&#xA;          digitalWrite(r2, LOW);&#xA;          digitalWrite(r3, LOW);&#xA;          digitalWrite(r4, LOW);&#xA;          digitalWrite(r5, LOW);&#xA;          digitalWrite(r6, LOW);&#xA;          digitalWrite(r7, LOW);&#xA;          digitalWrite(r8, LOW);&#xA;          digitalWrite(r9, LOW);&#xA;          digitalWrite(r10, LOW);&#xA;      }&#xA;&#xA;    }&#xA;&#xA;    msg = &quot;&quot;;&#xA;&#xA;&#xA;    delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12072" LastEditorUserId="12072" LastEditDate="2016-07-15T10:26:39.860" LastActivityDate="2016-07-15T12:20:14.943" Title="Relay switching problem with ATmega328P + 10 relays" Tags="|bluetooth|atmega328|relay|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26377" PostTypeId="2" ParentId="26373" CreationDate="2016-07-15T10:28:54.623" Score="-1" Body="&lt;p&gt;If you have 3 motors that use 3Amps combined then you have 3Amps spare and that's more than enough for an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't understand this part very well but depending on the type of motors you might get noise on the power lines and this might affect you Arduino.  In which case you will need to add in something to smooth the power, which means adding in a capacitor or two and their value depends on the frequency of the noise.  (&lt;a href=&quot;http://www.valvewizard.co.uk/smoothing.html&quot; rel=&quot;nofollow&quot;&gt;http://www.valvewizard.co.uk/smoothing.html&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I'd give it a try and see, but there again it wouldn't be the first Arduino I'd fried :)&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-15T10:28:54.623" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26378" PostTypeId="2" ParentId="26338" CreationDate="2016-07-15T11:06:02.190" Score="0" Body="&lt;p&gt;I fully agree with the answer of Majenko but I think something is missing in the explanation.&lt;br&gt;&#xA;When you say &quot;I want to control a motor&quot; then it is not yet clear what is needed.&#xA;There are the following options&lt;br&gt;&#xA;1) on/off in one direction (forward).&lt;br&gt;&#xA;2) on/off in 2 directions (forward and backwards).&lt;br&gt;&#xA;3) on/off in on direction with speed control.&lt;br&gt;&#xA;4) on/off in two directions with speed control.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a brushed dc motor this can be achieved with.&lt;br&gt;&#xA;1) a single pole single throw relay (this is similar to a on of switch)&lt;br&gt;&#xA;2) a single pole single throw relay and a double pole double throw relays (this is a on off switch and a switch to change the wires to the motor)&lt;br&gt;&#xA;3) a mosfet (this is similar to a single pole single throw switch that can go on/off very fast)&lt;br&gt;&#xA;4) a H bridge. That is 4 mosfets that are controlled in a certain way.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now here comes the trick: H bridges often come in 2 half H-bridges. And with a half H-bridge you can control a motor at level 3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In other words ... with a chip that has 4 half H bridges (an as such 2 H- bridges) you can control 4 brushed DC motors at the level 3 (forward speed controlled) or 2 brushed DC motors at the level 2 (back and forward speed controlled).  &lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-07-15T11:06:02.190" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26379" PostTypeId="2" ParentId="26375" CreationDate="2016-07-15T11:07:15.530" Score="3" Body="&lt;p&gt;I can see lot of problems.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;No decoupling capacitors on ATMega.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Capacitors on both sides voltage regulators are usualy essential for regulator stability. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Big voltage drop on regulator - if it's overheating, thermal shutdown might happen. For example 7V drop @ 350mA (about four relays) results into 2.45 Watts turned into heat.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Bare HC06 doesn't like 5 Volts on its 3.3V logic level input&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Xtal oscilator usualy requies two capacitors (22pF) for better stability.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-15T11:07:15.530" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26380" PostTypeId="2" ParentId="26363" CreationDate="2016-07-15T11:25:51.043" Score="0" Body="&lt;p&gt;There is a problem with your debounce logic. You want to compare the&#xA;current button state with the previous state, which is supposed to be&#xA;stored in &lt;code&gt;lastButton&lt;/code&gt;. But that variable is initialized to &lt;code&gt;true&lt;/code&gt; and&#xA;then &lt;em&gt;never&lt;/em&gt; updated. Your program may work better if you issue&#xA;&lt;code&gt;lastButton = currentAButton&lt;/code&gt; somewhere.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find lots of tutorials on button debouncing, and there are&#xA;several methods. The one you are using, which is based on &lt;code&gt;delay()&lt;/code&gt;, is&#xA;probably the worst: it should work in this simple case, but &lt;code&gt;delay()&lt;/code&gt; is&#xA;toxic as soon as your Arduino has more than one thing to do. A very&#xA;common (and my preferred) method is to just ignore the button for some&#xA;“debounce time” after you detect a state change. A debouncer function&#xA;can be based on something like:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (now - last_state_change &amp;lt; DEBOUNCE_TIME)&#xA;    return last_state;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you have to detect the button presses, which is not the same as the&#xA;button being down: you don't want to interpret the down state as a&#xA;continuous stream of very fast button presses. Instead, a button press&#xA;is the button being down now whereas it was up on the previous read. A&#xA;&lt;code&gt;button_press()&lt;/code&gt; function could call the &lt;code&gt;debounce()&lt;/code&gt; function and then&#xA;have something like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;bool press = last_state &amp;amp;&amp;amp; !state;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is effectively detecting falling edges of the debounced button. You&#xA;can combine the debouncer and the falling-edge detector into a single&#xA;function as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;bool button_press()&#xA;{&#xA;    static bool last_state;&#xA;    static uint32_t last_state_change;&#xA;    uint32_t now = millis();&#xA;&#xA;    // Ignore the button during the debounce time.&#xA;    if (now - last_state_change &amp;lt; DEBOUNCE_TIME)&#xA;        return false;&#xA;&#xA;    bool state = digitalRead(BUTTON_PIN);&#xA;    if (state != last_state) last_state_change = now;&#xA;    bool press = last_state &amp;amp;&amp;amp; !state;&#xA;    last_state = state;&#xA;    return press;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Next there is the management of the LED states. What you are trying to&#xA;implement is called a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;finite state&#xA;machine&lt;/a&gt;, sometimes&#xA;abbreviated “FSM”. If you search the Web for that term, you will find a&#xA;few examples on how to implement it. It canonically revolves around a&#xA;&lt;code&gt;switch&lt;/code&gt; statement that enumerates all the possible states and tells&#xA;what to do in each of those states. Something like&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;switch (state) {&#xA;    case STATE_FOO:&#xA;        if (some_condition()) {&#xA;            do_some_action();&#xA;            state = STATE_BAR;  // switch to the next state&#xA;        }&#xA;        break;&#xA;    case STATE_BAR:&#xA;        ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Below is a FSM implementation of your LED logic. Note that you did not&#xA;completely specify what should happen when the “timed” state times out:&#xA;you could go to a forth “timed out” state, or you could just go back to&#xA;the “off” state. In the code below I've taken that last option:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    static enum { OFF, TIMED, ON } state;&#xA;    static uint32_t timed_started;&#xA;    uint32_t now = millis();&#xA;&#xA;    // Switch state on button press.&#xA;    if (button_press()) switch(state) {&#xA;        case OFF:    // -&amp;gt; TIMED&#xA;            digitalWrite(LED_PIN, HIGH);&#xA;            state = TIMED;&#xA;            timed_started = now;&#xA;            break;&#xA;        case TIMED:  // -&amp;gt; ON&#xA;            // LED is lready on.&#xA;            state = ON;&#xA;            break;&#xA;        case ON:     // -&amp;gt; OFF&#xA;            digitalWrite(LED_PIN, LOW);&#xA;            state = OFF;&#xA;            break;&#xA;    }&#xA;&#xA;    // Turn off after LED_ON_TIME.&#xA;    if (state == TIMED &amp;amp;&amp;amp; now - timed_started &amp;gt;= LED_ON_TIME) {&#xA;        digitalWrite(LED_PIN, LOW);&#xA;        state = OFF;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that it would have been more “canonical” to have the tests&#xA;&lt;code&gt;if (button_press())&lt;/code&gt; inside the &lt;code&gt;switch&lt;/code&gt; rather than the other way&#xA;around. Then the test for the timeout would also be inside the same big&#xA;&lt;code&gt;switch&lt;/code&gt;. It's just that it seemed easier to me to write it this way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the sake of testability, here are the pieces that would be missing&#xA;for having a complete working program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int BUTTON_PIN = 9;&#xA;const int LED_PIN = LED_BUILTIN;&#xA;const uint32_t DEBOUNCE_TIME = 50;&#xA;const uint32_t LED_ON_TIME = 5000;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(BUTTON_PIN, INPUT_PULLUP);&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;// button_press() and loop() as above.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-15T11:25:51.043" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26381" PostTypeId="2" ParentId="26356" CreationDate="2016-07-15T11:48:51.887" Score="1" Body="&lt;p&gt;Are you hand-typing the commands? It is pretty difficult to do that consistently. I ask because your code collects data from the serial buffer until the buffer is empty - i.e. when you pause even slightly in your typing - and tries to act on whatever it has collected so far. That may be (probably will be!) an incomplete command. Even if your terminal uses line-by-line entry, there is still the risk that your code could notice an empty buffer between characters within a line. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try collecting characters until it sees a newline, instead. That is probably what you intended, and it will be immune to your typing speed. You'll still need to test for .available, but that should only allow the code to collect more characters. Keep collecting until it sees a newline.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What (I think) is happening now is called a race-condition. That means that the program's behavior is dependent on which of two (or more) events happens first, and the order of their occurrence is indeterminate. Race conditions are especially hard to find when the order of two events is almost always the one you expected. Notice the &quot;gotcha&quot; word in that sentence? :)&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-15T11:58:14.743" LastActivityDate="2016-07-15T11:58:14.743" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26382" PostTypeId="2" ParentId="26375" CreationDate="2016-07-15T12:06:45.367" Score="1" Body="&lt;p&gt;Where do the switching transistors get their +5v? The dropouts and shutdown suggest that the &quot;+5v&quot; is sagging as more relays try to draw off of it. Try supplying the relay current from a more capable supply, possibly a voltage regulator off the +12v supply - it will be wasteful but if it works, you'll know that was the problem.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-15T12:20:14.943" LastActivityDate="2016-07-15T12:20:14.943" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26383" PostTypeId="2" ParentId="26364" CreationDate="2016-07-15T13:13:22.583" Score="0" Body="&lt;p&gt;If you are clever with software you may be able to simplify your hardware requirements down to 1 IR ASK transmitter and 1 IR ASK IR receiver.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I mention IR ASK as the transmitter (simply a remote control with a button pushed down) and the &lt;a href=&quot;https://www.adafruit.com/products/157&quot; rel=&quot;nofollow&quot;&gt;receiver&lt;/a&gt; are &lt;a href=&quot;https://en.wikipedia.org/wiki/Commercial_off-the-shelf&quot; rel=&quot;nofollow&quot;&gt;COTS&lt;/a&gt; parts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider your robot looking for an IR ASK signal by rotation until one is found.  Then consider your robot traveling in a serpentine path adjusting its average vector along the angle where the IR ASK transmitter is detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might need to create an variable aperture the IR ASK receiver will look through.  This is because most IR ASK receivers have a built in &lt;a href=&quot;https://en.wikipedia.org/wiki/Automatic_gain_control&quot; rel=&quot;nofollow&quot;&gt;AGC&lt;/a&gt; circuit which will abstract you from knowing how strong the signal is.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, while searching, the aperture will be large allowing the IR ASK receiver a wide field of view.  But once locked on, the aperture should be reduced so that the robot will know in which direction the IR ASK signal is from.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-15T13:13:22.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26384" PostTypeId="2" ParentId="19614" CreationDate="2016-07-15T14:03:48.613" Score="1" Body="&lt;p&gt;The IDE package usually ships with the driver(at-least the latest one). &lt;br&gt;&#xA;Go to &lt;strong&gt;Program Files&lt;/strong&gt; in &lt;strong&gt;C:&lt;/strong&gt; and find the &lt;strong&gt;Arduino&lt;/strong&gt; folder and you should find a folder named &lt;strong&gt;Drivers&lt;/strong&gt;. Inside you will find an application named &lt;strong&gt;dpinst-x86&lt;/strong&gt;. Run it and you should be good to go!&lt;/p&gt;&#xA;" OwnerDisplayName="user8688" LastEditorDisplayName="user8688" LastEditDate="2017-04-27T16:15:06.810" LastActivityDate="2017-04-27T16:15:06.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26385" PostTypeId="2" ParentId="26313" CreationDate="2016-07-15T14:18:29.143" Score="0" Body="&lt;p&gt;You could change your circuit or just change &lt;code&gt;analogRead(0) &amp;lt; 750&lt;/code&gt; to &lt;code&gt;analogRead(0) &amp;gt; 750&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerDisplayName="user8688" LastActivityDate="2016-07-15T14:18:29.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26387" PostTypeId="2" ParentId="3997" CreationDate="2016-07-15T15:07:54.483" Score="6" Body="&lt;blockquote&gt;&#xA;When the button is not pressed, the power goes through the resistor to ground&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When the button in not pressed its not the 5v pin that is connected to ground but the input pin is connected to ground.&#xA;This is to ensure that the input does not float between 0v and 5v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&#xA;When not connected to 5v or GND the input pin tends to randomly change from `HIGH` to `LOW`.&#xA;To avoid this and quell external interference you just ground the pin.&lt;/p&gt;&#xA;" OwnerDisplayName="user8688" LastEditorUserId="50968" LastEditDate="2018-11-06T15:10:35.023" LastActivityDate="2018-11-06T15:10:35.023" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="26388" PostTypeId="2" ParentId="26347" CreationDate="2016-07-15T15:21:57.337" Score="1" Body="&lt;p&gt;Try to reset manually just after compiling end&lt;/p&gt;&#xA;" OwnerUserId="7924" LastActivityDate="2016-07-15T15:21:57.337" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26390" PostTypeId="2" ParentId="3997" CreationDate="2016-07-15T15:50:58.887" Score="1" Body="&lt;p&gt;In simple words, to avoid undefined state. This type of resistor arrangement is known as Pull Down Resistor. (Pull-Up also exists)&lt;/p&gt;&#xA;" OwnerUserId="13554" LastActivityDate="2016-07-15T15:50:58.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26392" PostTypeId="1" CreationDate="2016-07-15T16:10:48.350" Score="1" ViewCount="563" Body="&lt;p&gt;I am trying to control the brightness of an LED using PWM. I am also trying to make it so that when I click a button on my bluetooth app, I can get it to change the frequency of the PWM pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For changing the frequency, I am changing the value of the timers. When I click &quot;30 HZ&quot; on my bluetooth app, I am sending a value of &quot;A&quot;, 122 HZ = &quot;B&quot; etc..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hooked up a oscilloscope and changing the frequency does work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that when I click a button, it receives A or B etc.. but it doesn't enter the switch statement every time. It is very laggy. It will also receive inaccurate numbers at times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think I need something in differentiating between various serial inputs? (one for choosing frequency and one for the duty cycle of the LEDs)? and also being able to enter the switch statements and then staying in there until another char is received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is my code and I would appreciate any help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int pwmPin = 11;&#xA;const int TurnLightPin = 13;&#xA;&#xA;int ledState = LOW; // ledState used to set the LED&#xA;unsigned long previousMillis = 0;  // will store last time LED was updated&#xA;const long interval = 500;  // interval at which to blink (milliseconds)&#xA;int dutyCycle = 0;&#xA;&#xA;char state =' ';&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  //Change register values to adjust PWM frequency for PWM Pins 3 and 11:           &#xA;&#xA;  //TCCR2B = TCCR2B &amp;amp; B11111000 | B00000100;    // set timer 2 divisor to           64 for PWM frequency of   490.20 Hz (The DEFAULT)  &#xA;  //TCCR2B = TCCR2B &amp;amp; B11111000 | B00000101;    // set timer 2 divisor to      128 for PWM frequency of   245.10 Hz&#xA;  //TCCR2B = TCCR2B &amp;amp; B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz &#xA;  //TCCR2B = TCCR2B &amp;amp; B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz  pinMode(TurnLightPin, OUTPUT);&#xA;&#xA;  pinMode(TurnLightPin, OUTPUT);&#xA;  pinMode(pwmPin, OUTPUT); &#xA;&#xA;  Serial.begin(9600); // Default baudrate of bluetooth -- 9600 bits/second&#xA;  Serial.println(&quot;HC-06 Bluetooth connected!!!&quot;);&#xA;  Serial.flush();&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  // check to see if it's time to blink the LED; that is, if the&#xA;  // difference between the current time and last time you blinked&#xA;  // the LED is bigger than the interval at which you want to&#xA;  // blink the LED.&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;   if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;     // save the last time you blinked the LED&#xA;     previousMillis = currentMillis;&#xA;&#xA;     // if the LED is off turn it on and vice-versa:&#xA;     if (ledState == LOW) {&#xA;       ledState = HIGH;&#xA;     } else {&#xA;       ledState = LOW;&#xA;   }&#xA;&#xA;   // set the LED with the ledState of the variable:&#xA;  digitalWrite(TurnLightPin, ledState);&#xA;}&#xA;&#xA; //PWM Stuff:&#xA;&#xA;while(Serial.available()){&#xA;&#xA;   // if (Serial.available() &amp;gt; 0){&#xA;  state = Serial.read();&#xA;  Serial.print(&quot;State received - Before Switch Statement: &quot;);&#xA;  Serial.println(state);&#xA;  //}&#xA;&#xA;switch (state) {&#xA;&#xA;case 'A':&#xA;&#xA;  TCCR2B = TCCR2B &amp;amp; B11111000 | B00000111;    // set timer 2 divisor to  1024 for PWM frequency of    30.64 Hz&#xA;&#xA;  while(Serial.available() &amp;amp;&amp;amp; (Serial.read() != 'B' || Serial.read() != 'C' || Serial.read() != 'D')){&#xA;&#xA;    dutyCycle = Serial.parseInt();&#xA;    int pwmValue = (dutyCycle * 2.55 ); // Multiplied by 2.55 b/c sending a  value between 0-100 and max PWM value is 255&#xA;  //AnalogWrite takes two arguments: (pin to write to, and value b/w 0-255)&#xA;    analogWrite(pwmPin, pwmValue); //Sets the pin to the value received&#xA;    Serial.print(&quot;A-30 HZ - PWMValue:&quot;);&#xA;    Serial.println(pwmValue);&#xA;    Serial.print(&quot;A-30 HZ - State:&quot;);&#xA;    Serial.println(state);&#xA;    }&#xA;&#xA;    state = ' ';&#xA;    break;&#xA;&#xA;case 'B':    &#xA;    TCCR2B = TCCR2B &amp;amp; B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz &#xA;&#xA;    while(Serial.available() &amp;amp;&amp;amp; (Serial.read() != 'A' || Serial.read() != 'C' || Serial.read() != 'D')){&#xA;&#xA;    dutyCycle = Serial.parseInt();&#xA;    int pwmValue = (dutyCycle * 2.55 ); // Multiplied by 2.55 b/c sending a value between 0-100 and max PWM value is 255&#xA;  //AnalogWrite takes two arguments: (pin to write to, and value b/w 0-255)&#xA;    analogWrite(pwmPin, pwmValue); //Sets the pin to the value received&#xA;    Serial.print(&quot;B-122 HZ - PWMValue:&quot;);&#xA;    Serial.println(pwmValue);&#xA;    Serial.print(&quot;B-122 HZ - State:&quot;);&#xA;    Serial.println(state);&#xA;  }&#xA;&#xA;  state = ' ';&#xA;&#xA;  break;&#xA;&#xA;case 'C':&#xA;&#xA;   TCCR2B = TCCR2B &amp;amp; B11111000 | B00000101;    // set timer 2 divisor to   128 for PWM frequency of   245.10 Hz&#xA;&#xA;    while(Serial.available() &amp;amp;&amp;amp; (Serial.read() != 'A' || Serial.read() != 'B' || Serial.read() != 'D')){&#xA;&#xA;    dutyCycle = Serial.parseInt();&#xA;    int pwmValue = (dutyCycle * 2.55 ); // Multiplied by 2.55 b/c sending a value between 0-100 and max PWM value is 255&#xA;   //AnalogWrite takes two arguments: (pin to write to, and value b/w 0-255)&#xA;    analogWrite(pwmPin, pwmValue); //Sets the pin to the value received&#xA;    Serial.print(&quot;C-245 HZ - PWMValue:&quot;);&#xA;    Serial.println(pwmValue);&#xA;    Serial.print(&quot;C-245 HZ - State:&quot;);&#xA;    Serial.println(state);&#xA;  }&#xA;&#xA;  state = ' ';&#xA;&#xA;  break;&#xA;&#xA;case 'D':&#xA;&#xA;    TCCR2B = TCCR2B &amp;amp; B11111000 | B00000100;    // set timer 2 divisor to    64 for PWM frequency of   490.20 Hz (The DEFAULT) &#xA;&#xA;    while(Serial.available() &amp;amp;&amp;amp; (Serial.read() != 'A' || Serial.read() != 'B' || Serial.read() != 'C')){&#xA;&#xA;      dutyCycle = Serial.parseInt();&#xA;      int pwmValue = (dutyCycle * 2.55 ); // Multiplied by 2.55 b/c sending a value between 0-100 and max PWM value is 255&#xA;    //AnalogWrite takes two arguments: (pin to write to, and value b/w 0-255)&#xA;      analogWrite(pwmPin, pwmValue); //Sets the pin to the value received&#xA;      Serial.print(&quot;D-490 HZ - PWMValue:&quot;);&#xA;      Serial.println(pwmValue);&#xA;      Serial.print(&quot;D-490 HZ - State:&quot;);&#xA;      Serial.println(state);&#xA;    }&#xA;&#xA;    state = ' ';&#xA;&#xA;    break;&#xA;default:&#xA;&#xA;  TCCR2B = TCCR2B &amp;amp; B11111000 | B00000110;    // set timer 2 divisor to   256 for PWM frequency of   122.55 Hz &#xA;&#xA;  while(Serial.available()){&#xA;&#xA;    dutyCycle = Serial.parseInt();&#xA;    int pwmValue = (dutyCycle * 2.55 ); // Multiplied by 2.55 b/c sending a  value between 0-100 and max PWM value is 255&#xA;    //AnalogWrite takes two arguments: (pin to write to, and value b/w 0-255)&#xA;    analogWrite(pwmPin, pwmValue); //Sets the pin to the value received&#xA;    Serial.print(&quot;default - PWMValue:&quot;);&#xA;    Serial.println(pwmValue);&#xA;    Serial.print(&quot;Default - State:&quot;);&#xA;    Serial.println(state);&#xA;  }&#xA;&#xA;  state = ' ';&#xA;&#xA;  break;&#xA;    }//End of Switch Statement&#xA;  } // End of While loop for PWM&#xA;} // End of void Loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;" OwnerUserId="23932" LastEditorUserId="10394" LastEditDate="2016-07-15T23:46:17.237" LastActivityDate="2016-11-13T16:45:43.653" Title="Switch statements with Bluetooth serial input not working" Tags="|led|bluetooth|pwm|switch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26395" PostTypeId="2" ParentId="26392" CreationDate="2016-07-15T19:32:48.220" Score="1" Body="&lt;p&gt;I don't like your serial parser at all. Lots of whiles, reads, places to get stuck in...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example mine looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;  if (Serial.available()) {&#xA;    int ch = Serial.peek(); // check first character in buffer&#xA;&#xA;    switch (ch) {&#xA;      case 'a' ... 'd':&#xA;        TCCR2B &amp;amp;= 0b11111000; // mask out prescaler (turn off timer 2)&#xA;        TCCR2B |= 0b111 - (ch - 'a'); // a =&amp;gt; 7, b =&amp;gt; 6, c =&amp;gt; 5, d =&amp;gt; 4&#xA;        Serial.read(); // remove character from buffer&#xA;        Serial.println(TCCR2B, HEX);&#xA;        break;&#xA;&#xA;      case 'A' ... 'D':&#xA;        TCCR2B &amp;amp;= 0b11111000; // mask out prescaler (turn off timer 2)&#xA;        TCCR2B |= 0b111 - (ch - 'A'); // A =&amp;gt; 7, B =&amp;gt; 6, C =&amp;gt; 5, D =&amp;gt; 4&#xA;        Serial.read(); // remove character from buffer&#xA;        Serial.println(TCCR2B, HEX);&#xA;        break;&#xA;&#xA;      case '0' ... '9':&#xA;        dutyCycle = Serial.parseInt();&#xA;        analogWrite(pwmPin, (int)(dutyCycle*2.55));&#xA;        Serial.println(dutyCycle);&#xA;        break;&#xA;&#xA;      default:&#xA;        Serial.read(); // some invalid character? Drop it&#xA;        break;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However it needs some extra character after number (needed by parseInt)&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-15T19:32:48.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26396" PostTypeId="1" AcceptedAnswerId="26398" CreationDate="2016-07-15T19:51:41.437" Score="0" ViewCount="247" Body="&lt;p&gt;Im sending data between my arduino and android via bluetooth, using a simple chat app called &quot;Bluetooth Terminal&quot; . the code work perfectly at baudrate(9600) but I need to increase the speed to that of (115200) but nothing gets transmitted, or at least visible, anymore. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;here's my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int TXD = 3;&#xA;const int RXD = 4;&#xA;SoftwareSerial mrBlue(TXD, RXD);&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(9600);&#xA;  mrBlue.begin(9600);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  if (mrBlue.available() &amp;gt; 0) {&#xA;&#xA;    String data = mrBlue.readString();&#xA;    Serial.println(data);&#xA;&#xA;&#xA;&#xA;  }&#xA;&#xA;  if (Serial.available() &amp;gt; 0) {&#xA;&#xA;    String data = Serial.readString();&#xA;    mrBlue.println(data);&#xA;  }&#xA;&#xA;&#xA;  delay(20);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22976" LastActivityDate="2016-07-15T20:25:55.017" Title="Bluetooth module is neither sending nor receiving data at baudrate(115200)" Tags="|bluetooth|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26397" PostTypeId="2" ParentId="26396" CreationDate="2016-07-15T20:12:48.050" Score="0" Body="&lt;p&gt;Software serial is really limited because it needs relatively precise timing, full attention of CPU and there can't be any interruptions from other sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see source code for better understanding how it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And if you need faster communication, you should get board with more hardware serials.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-15T20:12:48.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26398" PostTypeId="2" ParentId="26396" CreationDate="2016-07-15T20:25:55.017" Score="0" Body="&lt;p&gt;Software serial is not working good with 115200 speed because of too much CPU usage. When I'm using only the bluetooth communication in Arduino, I'm connecting HC-05 (for example) to hardware serial pins and everything works fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to increase the speed you must also change it in AT mode.&lt;/p&gt;&#xA;" OwnerUserId="15334" LastActivityDate="2016-07-15T20:25:55.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26399" PostTypeId="1" CreationDate="2016-07-15T21:41:36.320" Score="2" ViewCount="1052" Body="&lt;p&gt;I purchased a pack of esp8266 (&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B00PA3UQNI&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/gp/product/B00PA3UQNI/&lt;/a&gt;) and a usb to serial converter (&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B01FUA2BBU&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/gp/product/B01FUA2BBU/&lt;/a&gt;) from amazon. I hooked them up and attempted to use the Arduino serial monitor to communicate with the esp8266. Here are the commands I used and the responses I got:&#xA;    AT&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OK&#xA;AT+GMR&#xA;&#xA;+GMR: 7.80.5.0&#xA;&#xA;OK&#xA;AT+RST&#xA;&#xA;ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My current setup is (RX on serial -&gt; TX on esp) and (TX on serial-&gt; RX on esp), although I have also tried them swapped. I have tried running the serial monitor at 115200, 57600, and 9600 baud and they all put out the same response. I have tried with both boards. I am currently running the esp8266 off of two AA batteries. All grounds are connected, CH_PD is connected to Vsupply with a 10k resistor, RST is connected to ground with a 3k resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not done anything with the firmware and I have not tried any other serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please let me know if there is anything else I can try to get these to work.&lt;/p&gt;&#xA;" OwnerUserId="23914" LastActivityDate="2016-07-15T21:41:36.320" Title="ESP8266 only responds to AT and AT+GMR" Tags="|esp8266|" AnswerCount="0" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26401" PostTypeId="2" ParentId="17" CreationDate="2016-07-16T04:48:17.007" Score="3" Body="&lt;p&gt;An unusual one but I've been swapping out the microcontrollers a lot and i got this error when one wasn't seated correctly.. i was able to burn a few times but i guess it slipped back out - a little push on the back of the ATMega328 fixed it!  &lt;/p&gt;&#xA;" OwnerUserId="23939" LastActivityDate="2016-07-16T04:48:17.007" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26402" PostTypeId="1" CreationDate="2016-07-16T06:14:37.757" Score="4" ViewCount="205" Body="&lt;p&gt;I'm using App Inventor to continuously send orientation values (as strings) to my Arduino, which are read using &lt;code&gt;Serial.parseInt()&lt;/code&gt;. Using simple IF statements (if value &gt; threshold), I'm trying to turn on an LED and otherwise turn it off. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I'm getting however, is an LED that goes on and off along with these values, which alternate between the actual and desired values and extreme unwanted values as shown in the picture:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GOrgC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GOrgC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given that my orientation values, as they are, alternate between -180 to 180, I'm using a simple IF statement that seems to work reasonably well, &lt;em&gt;except&lt;/em&gt; when the unwanted readings give inaccurate values that are within my range.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;My Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int TXD = 3;&#xA;const int RXD = 4;&#xA;SoftwareSerial mrBlue(TXD, RXD);&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  mrBlue.begin(9600);&#xA;  Serial.setTimeout(20);&#xA;  mrBlue.setTimeout(20);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;  if (mrBlue.available() &amp;gt; 0) {&#xA;&#xA;    int data = mrBlue.parseInt();&#xA;    if (data &amp;gt; 180 || data &amp;lt; -180) {&#xA;&#xA;    }&#xA;    else {&#xA;      Serial.println(data);&#xA;    }&#xA;  }    &#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22976" LastEditorUserId="11763" LastEditDate="2016-07-16T23:36:33.797" LastActivityDate="2016-07-16T23:36:33.797" Title="How to filter out &quot;jumpy&quot; readings sent using Bluetooth" Tags="|serial|bluetooth|softwareserial|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26408" PostTypeId="1" CreationDate="2016-07-16T11:25:52.603" Score="1" ViewCount="319" Body="&lt;p&gt;I am using an Arduino board with an ESP8266 module to connect to a WiFi device.&#xA;How do I check if the device is connected?&lt;/p&gt;&#xA;" OwnerUserId="23946" LastEditorUserId="11763" LastEditDate="2016-09-16T14:26:55.593" LastActivityDate="2017-03-25T06:05:37.227" Title="How to check 8266 module" Tags="|esp8266|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26409" PostTypeId="1" AcceptedAnswerId="26411" CreationDate="2016-07-16T11:43:54.597" Score="0" ViewCount="1094" Body="&lt;p&gt;I am using a function outside &lt;code&gt;loop()&lt;/code&gt;, which is called after an interrupt. Inside this function, I am setting several relays that need to change after a second or two, depending on my setting. I tried the delay, it doesn't work. &lt;code&gt;millis()&lt;/code&gt; isn't working as well; I found out it stops counting when I exit the loop function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const long on_interval = 2000;&#xA;unsigned long currentMillis = millis();&#xA;bool hv_bool = false;&#xA;&#xA;void hv_switch() {&#xA;    if (digitalRead(hv_pin)==HIGH){&#xA;        hv_startup();&#xA;    }&#xA;}&#xA;&#xA;void hv_startup() {&#xA;    unsigned long previousMillis = 0;&#xA;    digitalWrite(pre_charge, HIGH);&#xA;    digitalWrite(main_charge, LOW);&#xA;    //Wait interval&#xA;    previousMillis = currentMillis;&#xA;    while (currentMillis - previousMillis &amp;lt; on_interval) {&#xA;        Serial.println(millis());&#xA;        //Wait&#xA;    }&#xA;    digitalWrite(pre_charge, LOW);&#xA;    digitalWrite(main_charge, HIGH);&#xA;    hv_bool = true;&#xA;    loop();&#xA;}&#xA;&#xA;void setup(){&#xA;    //Set some ports&#xA;&#xA;    //Initiate interrupt &#xA;    attachInterrupt(digitalPinToInterrupt(hv_pin), hv_switch, RISING);&#xA;}&#xA;&#xA;void loop() {&#xA;    //Low voltage loop after startup, high voltage off&#xA;    while (hv_bool == false) {&#xA;        Serial.println(&quot;Waiting on high voltage&quot;);&#xA;        digitalWrite(hv_led, LOW);&#xA;        digitalWrite(pre_charge, LOW);&#xA;        digitalWrite(main_charge, LOW);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23696" LastEditorUserId="11763" LastEditDate="2016-07-16T23:40:34.127" LastActivityDate="2016-07-16T23:40:34.127" Title="How to delay outside loop" Tags="|interrupt|millis|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26411" PostTypeId="2" ParentId="26409" CreationDate="2016-07-16T13:02:35.533" Score="2" Body="&lt;p&gt;@EdgarBonet has it - hv_startup() is part of the the interrupt handler. Interrupt handlers should be as short (timewise) as possible, doing only what has to be done with the interrupts off, and leaving longer tasks for the mainline (loop() and its sub-functions) to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But a bigger problem is that loop() is called from hv_startup(), also getting used as part of the interrupt handler, and loop() has a while{} loop that depends on hv_bool, which can never get changed, 1) because there is no statement to set it false (besides the initialization); and 2) because loop is now running at interrupt level and no more interrupts (at the same level) can be taken.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I'd suggest several fixes:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't call loop from your interrupt handler. When your handler exits, loop() will resume from wherever it was when it got interrupted.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Don't delay in your interrupt handlers. If the interrupting hardware needs to be reset, do that and any other processing you have to do while the interrupts are off. But if some longer processing needs doing, set a flag in the interrupt handler (remember to declare it to be 'volatile'!), and exit.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In loop(), test the flag. If it is set, &lt;em&gt;clear it&lt;/em&gt; and call another function to handle the less urgent processing required by the interrupt.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-07-16T13:02:35.533" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26412" PostTypeId="1" CreationDate="2016-07-16T14:44:44.010" Score="-1" ViewCount="2218" Body="&lt;p&gt;I just finished a camp for the arduino and the arduino uno that they gave us is not working with my computer even though everything was working on their computers. I am trying to upload with the same schematic, same Arduino, and the same code. It is not wanting to upload even after changing in the preferences to the same com Port. I have tried updating the drivers, but Windows 7 64 bit s saying this error message : This device cannot start. (Code 10) .  Also, there is an exclamation mark in the device manager but how hard I try, it doesn't go away. &lt;/p&gt;&#xA;" OwnerUserId="23952" LastEditorUserId="612" LastEditDate="2016-10-15T17:55:53.437" LastActivityDate="2016-10-15T17:55:53.437" Title="The Right Com Port (COM 7) is NOT Showing" Tags="|clones|ch340|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26413" PostTypeId="1" AcceptedAnswerId="26416" CreationDate="2016-07-16T15:07:15.143" Score="3" ViewCount="12099" Body="&lt;p&gt;I have come across several examples about serialEvent() function, which look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent(){&#xA;  if(Serial.available()){&#xA;    \\do something &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The serialEvent() function is called when data is available, so which is the necessity of the &lt;code&gt;if&lt;/code&gt; (or &lt;code&gt;while&lt;/code&gt;) structure since that would be always &lt;code&gt;true&lt;/code&gt;? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;(In several cases I have excluded the &lt;code&gt;if&lt;/code&gt; structure, and the code works fine)&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="7728" LastActivityDate="2019-05-06T15:47:50.907" Title="how does serialEvent work?" Tags="|serial|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26414" PostTypeId="1" CreationDate="2016-07-16T15:55:46.803" Score="1" ViewCount="1059" Body="&lt;p&gt;So, I'm working on &lt;strong&gt;RedBear Blend Micro V 1.0&lt;/strong&gt;, and I must use the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ble_write(Serial.read());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To read some input from the serial monitor(&lt;em&gt;Input being stuff I type in the Serial Monitor&lt;/em&gt;) and send it via bluetooth.&#xA;It works perfectly this way!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now what I need to do is create a random &lt;strong&gt;double&lt;/strong&gt; data type number, and insert it in the place of &lt;strong&gt;Serial.read()&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Read This: &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;&lt;strong&gt;ble_write&lt;/strong&gt;&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Syntax:&#xA;    void ble_write(unsigned char data); &#xA;  ble_write sends a single byte data to the BLE Central.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, can you please help me, to:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1)Generate a random &lt;strong&gt;double&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2)Send it using the ble_write() function?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a full list of function sin the ReadBear Library click on the link:&#xA;&lt;a href=&quot;https://github.com/RedBearLab/nRF8001&quot; rel=&quot;nofollow&quot;&gt;https://github.com/RedBearLab/nRF8001&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23954" LastActivityDate="2016-10-16T20:06:52.743" Title="Convert a Double to an UnSigned Char" Tags="|serial|programming|arduino-ide|bluetooth|communication|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26416" PostTypeId="2" ParentId="26413" CreationDate="2016-07-16T16:17:41.093" Score="7" Body="&lt;p&gt;As far as I understand, using an if statement wouldn't make any difference, but using a while statement would.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The serialEvent() function is executed within each execution of your loop() function if there is data available, so it would be something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (true) &#xA;{&#xA;    loop();&#xA;    if(data_available)&#xA;        serialEvent();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you only have one byte of information in the buffer, then you wouldn't have any problem at all. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if you want to read multiple bytes at the same time, you would have to wait until the &lt;code&gt;loop()&lt;/code&gt; is executed again to read the next byte. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will solve that problem if you write your &lt;code&gt; serialEvent() &lt;/code&gt; like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void serialEvent()&#xA;{&#xA;    while (Serial.available())&#xA;    {&#xA;        // do something&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That way, you will read all the information available at once and then return to the loop.&lt;/p&gt;&#xA;" OwnerUserId="23750" LastActivityDate="2016-07-16T16:17:41.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26418" PostTypeId="1" CreationDate="2016-07-16T17:41:08.763" Score="1" ViewCount="2073" Body="&lt;p&gt;I've been trying to figure out why the analogRead() function takes about four times as long on an Arduino Zero than on an Uno, when the Zero has a faster clock than the Uno.  Arduinos website says that it should take around 100 microseconds, and it does on the Uno, but it takes a little over 400 microseconds on the Zero. To time it, I've been setting a digital pin high immediately before the function call and low immediately after and measuring the period on a digital osscilloscope.  I'm just trying to test analogRead, so I'm not doing anything else in this code.  I've tried putting the ADC in freerun mode, and it trims ~15 us off of the ~415 us it currently takes.  I've also used the on-chip debugger to look at the disassembly, and the line that takes too long is always the line waiting for the conversion to complete.  I was also wondering if other ARM-based Arduinos (like the Zero) take over 100 us.  Thanks!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int   sensorPin = A1; &#xA;int      ledPin = 11;&#xA;int sensorValue = 0;&#xA;&#xA;void setup() {&#xA;  analogReadResolution(12);&#xA;  pinMode(ledPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(ledPin,HIGH);&#xA;  sensorValue = analogRead(sensorPin);&#xA;  digitalWrite(ledPin,LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23956" LastEditorUserId="23841" LastEditDate="2016-07-17T13:03:31.987" LastActivityDate="2016-12-14T18:27:37.720" Title="analogRead() takes &gt;400 us on Arduino Zero but ~100 us on Uno, why?" Tags="|analogread|adc|timing|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26419" PostTypeId="2" ParentId="26414" CreationDate="2016-07-16T17:43:41.043" Score="1" Body="&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Chris Stratton rightfully points out that the question is&#xA;about a &lt;code&gt;double&lt;/code&gt;, not a &lt;code&gt;float&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;code&gt;float&lt;/code&gt; is four bytes in every platform I know about, as per the&#xA;IEEE-754 standard&lt;/li&gt;&#xA;&lt;li&gt;a &lt;code&gt;double&lt;/code&gt; is eight bytes in almost all platforms, with the notable&#xA;exception of AVR: &lt;a href=&quot;https://gcc.gnu.org/wiki/avr-gcc#Deviations_from_the_Standard&quot; rel=&quot;nofollow&quot;&gt;the AVR double is highly non-standard, four bytes&#xA;long, and essentially equivalent to &lt;code&gt;float&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Most, but not all Arduinos, are AVR-based.&#xA;In the following I assume you are talking about AVR doubles, i.e.&#xA;floats. If this is not the case, then just replace the array of 4 bytes&#xA;by an array of 8 bytes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Original answer&lt;/strong&gt;:&#xA;A &lt;code&gt;float&lt;/code&gt; is four bytes, so it is somewhat equivalent to an array of&#xA;four unsigned chars, i.e. to &lt;code&gt;unsigned char[4]&lt;/code&gt;. You can use this&#xA;equivalence with an &lt;code&gt;union&lt;/code&gt;. For example, the following function will&#xA;send a float byte by byte:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void ble_write_float(float x)&#xA;{&#xA;    union {&#xA;        float f;&#xA;        unsigned char c[4];&#xA;    } data;&#xA;&#xA;    data.f = x;&#xA;    ble_write(data.c[0]);&#xA;    ble_write(data.c[1]);&#xA;    ble_write(data.c[2]);&#xA;    ble_write(data.c[3]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that this will send the bytes in whatever is the natural order of&#xA;the sending processor. If it's an AVR (like most Arduinos), this will be&#xA;LSB (least significant byte) first. You have to make sure that this is&#xA;what the receiver expects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following Ignacio Vazquez-Abrams' suggestion, for sending a random float&#xA;you could just send four random bytes. However, it may be wiser to have&#xA;an idea of the random distribution you want for your float, and use&#xA;things like &lt;code&gt;random()&lt;/code&gt; and &lt;code&gt;map()&lt;/code&gt; to achieve that distribution. Using&#xA;four random bytes, you get a very wide distribution (all the possible&#xA;floats are equally likely) which includes weird things like denormals,&#xA;infinities and NaN (literally meaning “not a number”).&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-10-16T20:06:52.743" LastActivityDate="2016-10-16T20:06:52.743" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26420" PostTypeId="1" AcceptedAnswerId="26430" CreationDate="2016-07-16T17:44:49.880" Score="0" ViewCount="243" Body="&lt;p&gt;im not used to write in english but i hope you guys can understand. I have some doubts about using the arduino pro mini 3v3@8Mhz&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I know its possible to change the clock to 1 MHz with the fuses easily by setting CKDIV8 to '0'. But i dont understand if its possible to divide the internal 8 MHz clock to intermediate values like 4 MHz and 2 MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I know i can divide the clock with program running. The problem is i would like to run the arduino with a voltage less than 2,4V and arduino will start at 8MHz(out of safe operation area) for later change the clock to 4MHz(inside of safe operation area). Is there another way by software to always be in the safe zone ?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/J6EEs.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/J6EEs.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23953" LastActivityDate="2016-07-16T20:01:02.853" Title="Atmega328p clock and safe operation zone" Tags="|atmega328|arduino-pro-mini|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26422" PostTypeId="2" ParentId="26412" CreationDate="2016-07-16T18:15:06.003" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The Right Com Port (COM 7) is NOT Showing&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It would appear that Microsoft Windows does not necessarily assign the same COM port for a given device from machine to machine.  It is usually up to the user to map which COM port is being used for which device.  Some applications which work with specific devices have been known to &quot;search&quot; for that specific device and automatically connect to the correct COM port.  &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...saying this error message : This device cannot start...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is this Microsoft Web Page &lt;a href=&quot;https://support.microsoft.com/en-us/kb/943104&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; about this error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specific help may be found &lt;a href=&quot;https://www.arduino.cc/en/Guide/Troubleshooting&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.  In particular, this passage looks promising:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On Windows 7 (particularly the 64-bit version), you might need to go&#xA;  into the Device Manager and update the drivers for the Uno or Mega&#xA;  2560. Just right click on the device (the board should be connected to your computer), and point Windows at the appropriate .inf file again.&#xA;  The .inf is in the drivers/ directory of the Arduino software (not in&#xA;  the FTDI USB Drivers sub-directory of it).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-16T18:15:06.003" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26423" PostTypeId="1" AcceptedAnswerId="26424" CreationDate="2016-07-16T18:32:59.630" Score="0" ViewCount="179" Body="&lt;p&gt;Here's what I want to achieve:&#xA;I'm building a class for controlling step motors. In that class I want to have a method called &quot;init&quot;. In that method I'd like to create an object of class Tone, which I'll need to control a motor.&#xA;BUT I want to have seperate Tone class object for every object of my class that I create. How can I do it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, for exmaple, if I have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myClass newmotor1;&#xA;memotor1.init();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;After executing these two lines, I'd like to have my object newmotor1 (which I have, because I just created it) AND an object of class Tone, which I'll use.&lt;/p&gt;&#xA;" OwnerUserId="23959" LastActivityDate="2016-07-16T18:43:38.793" Title="creating object of another class when initializing an object of a class" Tags="|class|stepper|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26424" PostTypeId="2" ParentId="26423" CreationDate="2016-07-16T18:43:38.793" Score="0" Body="&lt;p&gt;You don't need to &quot;create&quot; anything. Just have an object in your class:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Tone {&#xA;    public:&#xA;        void dosomething() {&#xA;            // Whatever is in here&#xA;        }&#xA;};&#xA;&#xA;class MyMotor {&#xA;    public:&#xA;        Tone tone;&#xA;        void init() {&#xA;            // Nothing much else to do in here now.&#xA;        }&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyMotor newmotor1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And you can access:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;newmotor1.tone.dosomething();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-16T18:43:38.793" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26425" PostTypeId="2" ParentId="26412" CreationDate="2016-07-16T18:45:27.923" Score="1" Body="&lt;p&gt;I found out that I could not use the arduino drivers because I am using a DCcduino uno that has a separate driver.&lt;/p&gt;&#xA;" OwnerUserId="23952" LastActivityDate="2016-07-16T18:45:27.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26426" PostTypeId="1" AcceptedAnswerId="26429" CreationDate="2016-07-16T19:02:00.217" Score="0" ViewCount="173" Body="&lt;p&gt;Can I configure 2 XBEE modules one then another using 1 XBEE Explorer, or I MUST do this configuration operation for them at the same time and I need 2 Explorer modules? &lt;/p&gt;&#xA;" OwnerUserId="19654" LastActivityDate="2016-07-16T19:36:00.227" Title="can i configure 2 (XBee series 2) modules using one explorer" Tags="|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26427" PostTypeId="1" CreationDate="2016-07-16T19:16:18.407" Score="2" ViewCount="89" Body="&lt;p&gt;I have an Arduino Uno with the basic kit, not very good at coding it however.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How could I make a doorbell that lights up an LED instead of making a noise?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to make a doorbell for someone with hearing issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple LED lighting up would be more than enough. Would I need a wifi shield if it's not close enough to be hard wired?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="23961" LastActivityDate="2016-07-17T00:25:02.923" Title="Doorbell for someone with hearing issues" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26428" PostTypeId="1" CreationDate="2016-07-16T19:18:23.343" Score="1" ViewCount="9285" Body="&lt;p&gt;I have this sensor MQ131 by sainsmart: &lt;a href=&quot;https://www.amazon.co.uk/gp/product/B00NL8XIQG/ref=ox_sc_act_title_1?ie=UTF8&amp;amp;psc=1&amp;amp;smid=A3DRI1TTHCTDIG&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.co.uk/gp/product/B00NL8XIQG/ref=ox_sc_act_title_1?ie=UTF8&amp;amp;psc=1&amp;amp;smid=A3DRI1TTHCTDIG&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I can read is the analog value which does not reflect the gas concentration. Any Arduino code for that to read the ppm concentration? &#xA;How long does the sensor needs to be preheated? &lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2018-12-27T13:41:37.037" Title="Arduino: Reading PPM values from MQ-131 Ozone sensor" Tags="|arduino-uno|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26429" PostTypeId="2" ParentId="26426" CreationDate="2016-07-16T19:36:00.227" Score="1" Body="&lt;p&gt;You only need one. &#xA;In order to communicate in Point To Point, you must configure each xbee to belong to the same NetworkID (PAN ID). XBees can only communicate with each other if they have the same network ID. Configure one, switch the xbee then configure the other (&lt;a href=&quot;https://learn.adafruit.com/xbee-radios/point2point&quot; rel=&quot;nofollow&quot;&gt;see here&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are more advanced configurations that you can use (&lt;a href=&quot;https://learn.sparkfun.com/tutorials/exploring-xbees-and-xctu&quot; rel=&quot;nofollow&quot;&gt;check this tutorial for extended information&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-07-16T19:36:00.227" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26430" PostTypeId="2" ParentId="26420" CreationDate="2016-07-16T20:01:02.853" Score="3" Body="&lt;p&gt;Just let CKDIV8 set (it just sets system clock prescaler to /8). And you can set different system clock prescaler later.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For changing system clock prescaler you need:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/power.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;clock_prescale_set(clock_div_2); // possible values are clock_div_1 ... clock_div_256&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just don't forget that millis, delays and basically everything based on F_CPU might be slower/faster when prescaler gets changed.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-16T20:01:02.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26431" PostTypeId="2" ParentId="26158" CreationDate="2016-07-16T21:17:35.767" Score="0" Body="&lt;p&gt;Some one helped me in the Arduino forums, and I felt obligated to add the answer here : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The : &lt;code&gt;m_currentState = (m_currentState - 1) % 8;&lt;/code&gt; is the bug.&#xA;I accidentally assumed that doing &lt;code&gt;%&lt;/code&gt; on &lt;code&gt;-1&lt;/code&gt; will jump to &lt;code&gt;7&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Somehow this caused the strange behavior I had.&lt;/p&gt;&#xA;" OwnerUserId="23746" LastActivityDate="2016-07-16T21:17:35.767" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26433" PostTypeId="2" ParentId="26427" CreationDate="2016-07-16T22:57:55.283" Score="1" Body="&lt;p&gt;I know you are keen on using your Arduino.  But simpler solutions abound.  For instance, if the door bell already works at a lower then main voltage it might be easier to determine the feasibility of connecting a low voltage lamp to the door bell.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I can see a situation that an Arduino can fit very nicely into:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Events: 1) The door bell rings. 2) The Arduino senses this and starts turning on and off a room light at about 5 second intervals. 3) This can last until someone notices and resets the Arduino.  4) If no one is home to reset the Arduino, the Arduino stops turning on and off the room light after a minute passes (12 flashes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are 2 tricky bits that may need explaining.  The first is how to sense the door bell.  If mechanical you could use a micro switch:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bSooh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bSooh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That way you don't need to worry about isolating the Arduino from what is likely a strong electrically noisy solenoid.  The other tricky bit is controlling a room light.  I would suggest using a &lt;a href=&quot;https://en.wikipedia.org/wiki/Commercial_off-the-shelf&quot; rel=&quot;nofollow noreferrer&quot;&gt;COTS&lt;/a&gt; remote controllable light switch (I just did a search and there are loads of them in every price range) and hack the (battery powered) remote control into the Arduino. &lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-16T22:57:55.283" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26434" PostTypeId="2" ParentId="26427" CreationDate="2016-07-17T00:25:02.923" Score="0" Body="&lt;p&gt;If you must do wireless, you can get by with a 433MHz rx+tx module. Be sure to align both antennas either vertically or horizontally. These modules kind of need two MCUs though, but clones are cheap. Personally I would add a small switch underneath the doorbell button, but separate from its circuitry. Debounce it. On the receiving end you need a good set of LEDs - iphone has a very annoying but attention-grabbing light pulse for people hard of hearing. You can see it on youtube. I would copy that pulse timing and intensity as closely as possible, thus infringing on Apple's no doubt copyrighted+patented 'technology'. Be a pirate, arrr!&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-07-17T00:25:02.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26435" PostTypeId="2" ParentId="25366" CreationDate="2016-07-17T00:44:38.840" Score="1" Body="&lt;p&gt;Within the body of a function you can do this to suppress a warning:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void do_something(int value) {&#xA;  (void) (value);&#xA;  . . .&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use a macro to do the same thing, for better clarity:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define UNUSED(v) (void) (v)&#xA;&#xA;void do_something(int value) {&#xA;  UNUSED(value);&#xA;  . . .&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This can be helpful in situations where you have conditional compilation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void do_something(int value) {&#xA;  #ifndef USES_PARAM&#xA;    UNUSED(value);&#xA;  #else&#xA;    other_stuff(value);&#xA;  #endif&#xA;  . . .&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23965" LastActivityDate="2016-07-17T00:44:38.840" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26437" PostTypeId="2" ParentId="23874" CreationDate="2016-07-17T03:31:43.453" Score="2" Body="&lt;p&gt;Here is a solution I found on one of the forums, I modified/simplified it to suit, but it does what you are after.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I use a cheap MP3 player and small amp that runs all the time with the speaker output switched by a baby relay controlled by the UNO R3 and IR sensors from Ebay, you should be able to convert this for use on your player.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It runs the 4 steps you described.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;code attached.&#xA;(could not figure out how to get code into a box-very confusing..please enlighten me,,,,and what is a back tick??)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo gate1servo;// create servo object to control crossing gate 1&#xA;//ASSUMPTION Gate is down at position gatedownposition and up at position gateuppostion  &#xA;Servo gate2servo; // create servo object to control crossing gate 2&#xA;unsigned long previousMillisSERVOSTART=0; //FLASH Millis() setup&#xA;int intervalSERVOSTART = 1000;&#xA;unsigned long previousMillisFLASH=0;  //FLASH Millis() setup&#xA;int intervalFLASH = 250;&#xA;int gateup  =  120;  // servo position for gate up&#xA;int gatedown = 30;&#xA;int gatepos; // variable to store the servo gateposition&#xA;int gp = 120;  // servo position for gate down&#xA;int sensor1 = 5; // IR sensor pin Assumption== Pin goes LOW when train detected&#xA;int sensor2 = 6; // IR sensor pin Assumption== Pin goes LOW when train detected&#xA;int led1 = 10;  // Led 1 pin first alternating flasher&#xA;int led2 = 11;  // Led 2 pin first alternating flasher&#xA;int gates_started = 0; // this says if the crossing is active&#xA;&#xA;int entering_sensor = 5; //this will tell which sensor was triggered first&#xA;int leaving_sensor = 6; // this will tell which sensor shows train leaving&#xA;int flash_state = 0;&#xA;&#xA;void setup() {&#xA;   Serial.begin(9600);&#xA;  gate1servo.attach(3);// attaches the servo on pin 3 to the servo object&#xA;  gate2servo.attach(4);// attaches the servo on pin 4 to the servo object&#xA;  gate1servo.write(gp);//start assuming no train&#xA;  gate2servo.write(gp);//start assuming no train&#xA;  pinMode(sensor1, INPUT);  &#xA;  pinMode(sensor2, INPUT);&#xA;  pinMode(led1, OUTPUT);&#xA;  pinMode(led2, OUTPUT);  &#xA;  digitalWrite(led1, LOW);// Start with all flashers off&#xA;  digitalWrite(led2, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;    if ((digitalRead (sensor1)==LOW)&amp;amp;&amp;amp; (gates_started==0)) {//read sensor 1, if LOW ...do it&#xA;        gates_started = 1;&#xA;        leaving_sensor = sensor2;&#xA;    }&#xA;    if ((digitalRead (sensor2)==LOW)&amp;amp;&amp;amp; (gates_started==0)) {//read sensor 2, if LOW ...do it&#xA;        gates_started = 1;                      &#xA;        leaving_sensor = sensor1;&#xA;    }&#xA;    unsigned long currentMillisFLASH = millis();                                                      // get current time stamp, only need one for all if-statements&#xA;    if ((unsigned long)(currentMillisFLASH - previousMillisFLASH) &amp;gt;= intervalFLASH) {// time between button presses&#xA;       flash_state = ~flash_state;&#xA;       digitalWrite(led1, flash_state);                                           //toggle flash_state&#xA;      digitalWrite(led2, ~flash_state);&#xA;      previousMillisFLASH = currentMillisFLASH;&#xA;  }&#xA;&#xA;  unsigned long currentMillisSERVOSTART = millis();                                                     // get current time stamp, only need one for all if-statements&#xA;  if ((unsigned long)(currentMillisSERVOSTART - previousMillisSERVOSTART) &amp;gt;= intervalSERVOSTART) {      // time between button presses     &#xA;    for(gp = gatedown ; gp &amp;lt;= gateup ; gp++) {                                                          // goes from gatedown  degrees to gateup degrees      &#xA;      gate1servo.write(gp);                                                                             // tell servo to go to gateposition in variable 'gateposition'&#xA;      gate2servo.write(gp);&#xA;&#xA;  previousMillisSERVOSTART = currentMillisSERVOSTART;&#xA; }&#xA; Serial.println(gp);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23966" LastEditorUserId="19667" LastEditDate="2016-07-18T02:06:47.823" LastActivityDate="2016-07-18T02:06:47.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26438" PostTypeId="1" AcceptedAnswerId="26443" CreationDate="2016-07-17T06:56:23.343" Score="-1" ViewCount="3094" Body="&lt;p&gt;I am working on lighting some WS2812 Leds with a nodemcu form hiLetgo. The project works when it is powered from the usb that is on the board, but as soon as it is powered from the barrel jack, the leds will only light up to the last color that they were set, ignoring code. A schematic and code are included for reference.&lt;a href=&quot;https://i.stack.imgur.com/bdonO.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bdonO.png&quot; alt=&quot;The schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;&#xA;// Which pin on the ESP8266 is connected to the NeoPixels?&#xA;#define PIN            D8&#xA;&#xA;// How many NeoPixels are attached to the ESP8266?&#xA;#define NUMPIXELS      30&#xA;&#xA;Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;int delayval = 10; // delay for half a second&#xA;int x, y, z;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  pixels.begin(); // This initializes the NeoPixel library.&#xA;  x = 0;&#xA;  y = 0;&#xA;  z = 0;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;   for(int i=0;i&amp;lt;NUMPIXELS;i++){&#xA;    x = (x+1)%256;&#xA;    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255&#xA;&#xA;    pixels.setPixelColor(i, pixels.Color(x,y,z)); // Moderately bright green color.&#xA;&#xA;    pixels.show(); // This sends the updated pixel color to the hardware.&#xA;&#xA;    delay(delayval); // Delay for a period of time (in milliseconds).&#xA;&#xA;  }&#xA;  y= (y+1)%256;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23967" LastEditorUserId="4131" LastEditDate="2016-07-18T19:20:56.283" LastActivityDate="2016-07-18T19:20:56.283" Title="Problems with Powering Led Project Through Vin Pin" Tags="|led|esp8266|nodemcu|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26439" PostTypeId="2" ParentId="26418" CreationDate="2016-07-17T06:59:19.543" Score="1" Body="&lt;p&gt;Arduino is universal platform, lot of wrappers to hide real hardware and it is slow. For example digital write is about 100times slower than direct access to hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example for AVR Mega328p based Arduino analogRead looks like (without macros):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int analogRead(uint8_t pin)&#xA;{&#xA;    uint8_t low, high;&#xA;&#xA;    if (pin &amp;gt;= 14) pin -= 14; // allow for channel or pin numbers&#xA;&#xA;&#xA;    // set the analog reference (high two bits of ADMUX) and select the&#xA;    // channel (low 4 bits).  this also sets ADLAR (left-adjust result)&#xA;    // to 0 (the default).&#xA;    ADMUX = (analog_reference &amp;lt;&amp;lt; 6) | (pin &amp;amp; 0x07);&#xA;&#xA;    // start the conversion&#xA;    sbi(ADCSRA, ADSC);&#xA;&#xA;    // ADSC is cleared when the conversion finishes&#xA;    while (bit_is_set(ADCSRA, ADSC));&#xA;&#xA;    // we have to read ADCL first; doing so locks both ADCL&#xA;    // and ADCH until ADCH is read.  reading ADCL second would&#xA;    // cause the results of each conversion to be discarded,&#xA;    // as ADCL and ADCH would be locked when it completed.&#xA;    low  = ADCL;&#xA;    high = ADCH;&#xA;&#xA;    // combine the two bytes&#xA;    return (high &amp;lt;&amp;lt; 8) | low;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There are no extra function calls, no much extra actions and ADC is enabled in the startup code (as most of hw).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the other side there is ARM based arduino with SAM3X8E:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uint32_t analogRead(uint32_t ulPin)&#xA;{&#xA;    uint32_t ulValue = 0;&#xA;    uint32_t ulChannel;&#xA;&#xA;    if (ulPin &amp;lt; A0)&#xA;      ulPin += A0;&#xA;&#xA;    ulChannel = g_APinDescription[ulPin].ulADCChannelNumber ;&#xA;&#xA;    static uint32_t latestSelectedChannel = -1;&#xA;    switch ( g_APinDescription[ulPin].ulAnalogChannel )&#xA;    {&#xA;        // Handling ADC 12 bits channels&#xA;        case ADC0 :&#xA;        case ADC1 :&#xA;        case ADC2 :&#xA;        case ADC3 :&#xA;        case ADC4 :&#xA;        case ADC5 :&#xA;        case ADC6 :&#xA;        case ADC7 :&#xA;        case ADC8 :&#xA;        case ADC9 :&#xA;        case ADC10 :&#xA;        case ADC11 :&#xA;&#xA;            // Enable the corresponding channel&#xA;            if (adc_get_channel_status(ADC, ulChannel) != 1) {&#xA;                adc_enable_channel( ADC, ulChannel );&#xA;                if ( latestSelectedChannel != (uint32_t)-1 &amp;amp;&amp;amp; ulChannel != latestSelectedChannel)&#xA;                    adc_disable_channel( ADC, latestSelectedChannel );&#xA;                latestSelectedChannel = ulChannel;&#xA;                g_pinStatus[ulPin] = (g_pinStatus[ulPin] &amp;amp; 0xF0) | PIN_STATUS_ANALOG;&#xA;            }&#xA;&#xA;            // Start the ADC&#xA;            adc_start( ADC );&#xA;&#xA;            // Wait for end of conversion&#xA;            while ((adc_get_status(ADC) &amp;amp; ADC_ISR_DRDY) != ADC_ISR_DRDY)&#xA;                ;&#xA;&#xA;            // Read the value&#xA;            ulValue = adc_get_latest_value(ADC);&#xA;            ulValue = mapResolution(ulValue, ADC_RESOLUTION, _readResolution);&#xA;&#xA;            break;&#xA;&#xA;        // Compiler could yell because we don't handle DAC pins&#xA;        default :&#xA;            ulValue=0;&#xA;            break;&#xA;    }&#xA;&#xA;    return ulValue;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see there is little bit more actions to do single measure using HAL (Hardware Abstraction Level) so you have another level of abstraction here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want faster actions, you can access hw directly, or use HAL and skip unnecessary steps. It would be much faster then.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-17T06:59:19.543" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26442" PostTypeId="1" AcceptedAnswerId="28570" CreationDate="2016-07-17T09:50:53.760" Score="0" ViewCount="4971" Body="&lt;p&gt;Well, I' ve just bought and recieved a MFRC522 rfıd module and done to much research on it. After watching several videos, I sorted out a library for using this module via arduino. &#xA;You can click the first link below to be navigated to Miguel Balboa' s github page including the library that I mentioned and example codes written by him using that library. Though I' ve downloaded the zip file, ran such codes as dumpInfo, read and write, unfortunetely I couldn' t made &quot;changeUid&quot; example work. U can reach this example code via the link below as well. My connection is true, I' m sure bout' that&lt;a href=&quot;https://i.stack.imgur.com/rNGwf.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rNGwf.jpg&quot; alt=&quot;Connection is same an shown in code&quot;&gt;&lt;/a&gt;  If anybody had faced this kind of problem or knows the solution, their answers will be enough satisfying for me I guess... (By the way, error was this sentance: Are you sure this is a uid changeable card -I was sure, my card was a Mifare 1K card- failure, the card responded as NAK)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;link: &lt;a href=&quot;https://github.com/miguelbalboa/rfid&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/miguelbalboa/rfid&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="15789" LastActivityDate="2016-08-21T21:29:47.287" Title="Changing Uid Using MFRC522 Via Arduino Error" Tags="|arduino-uno|serial|rfid|" AnswerCount="1" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26443" PostTypeId="2" ParentId="26438" CreationDate="2016-07-17T11:53:20.983" Score="1" Body="&lt;p&gt;First: What is the purpose of that resistor you have in there? It serves no purpose as far as I can see, and would only cause problems anyway. Lose it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second: You have logic voltage level problems:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You are supplying 5.2V to the LEDs.&lt;/li&gt;&#xA;&lt;li&gt;The ESP8266 is a 3.3V device.&lt;/li&gt;&#xA;&lt;li&gt;The ESP8266 outputs 3.3V as a logic HIGH.&lt;/li&gt;&#xA;&lt;li&gt;The WS2812 accepts 0.7Vdd as logic HIGH (as stated in &lt;a href=&quot;https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf&quot; rel=&quot;nofollow&quot;&gt;the datasheet&lt;/a&gt;).&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;0.7 × 5.2 = 3.64v&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Ergo, the LEDs aren't seeing the logic HIGH signal as logic HIGH because it is too low a voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add to that the voltage drop across the resistor and your logic HIGH voltage will be even less.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Lose the pointless resistor&lt;/li&gt;&#xA;&lt;li&gt;Either reduce the supply voltage to the LEDs or increase the output HIGH voltage level with a logic level shifter circuit (3.3v -&gt; 5v).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-17T11:53:20.983" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26444" PostTypeId="1" AcceptedAnswerId="26453" CreationDate="2016-07-17T12:10:58.573" Score="2" ViewCount="259" Body="&lt;pre&gt;&lt;code&gt;void Multi_print (String str)&#xA;{&#xA;  Serial.print(str);&#xA;  mySerial.print(str);&#xA; }&#xA;&#xA;void Multi_println (String str)&#xA;{&#xA; Serial.println(str);&#xA; mySerial.println(str);&#xA;}&#xA;&#xA;void Multi_parse_int (int value)&#xA; {&#xA;    Serial.print(value);&#xA;    mySerial.print(value);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23973" LastEditorUserId="3917" LastEditDate="2016-07-17T18:16:54.090" LastActivityDate="2016-07-17T23:09:01.993" Title="How can I reduce the redundancy of this code, so one function can perform the task of printing on Serial and Softserial?" Tags="|serial|programming|softwareserial|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26447" PostTypeId="1" CreationDate="2016-07-17T12:52:15.130" Score="3" ViewCount="3175" Body="&lt;p&gt;Hello I have an Arduino Uno and I salvaged a USB port from an old computer. The USB port has 4 pins on it and it accepts USB sticks. I was wondering if it is possible to connect it to my Arduino so my Arduino can load data from files on the USB. I don't want to go out and buy a shield but I don't mind using libraries. Is it possible to read and write data from a USB stick with Arduino?&lt;/p&gt;&#xA;" OwnerUserId="16124" OwnerDisplayName="user2279603" LastEditorUserId="37523" LastEditDate="2018-07-27T01:41:18.693" LastActivityDate="2018-07-27T01:41:18.693" Title="How do I Read and Write data from a USB stick?" Tags="|arduino-uno|usb|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="26450" PostTypeId="2" ParentId="26447" CreationDate="2016-07-17T18:02:25.613" Score="2" Body="&lt;p&gt;The Uno does not have any USB &lt;strong&gt;&lt;em&gt;host&lt;/em&gt;&lt;/strong&gt; or OTG capabilities on its own, and bit banging it is not easy. A USB Host shield, or a better microcontroller is needed. &lt;/p&gt;&#xA;" OwnerUserId="21074" LastActivityDate="2016-07-17T18:02:25.613" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26451" PostTypeId="2" ParentId="9181" CreationDate="2016-07-17T18:27:02.260" Score="3" Body="&lt;p&gt;I've run into the same question my self just on a Mac so in case anyone with Mac run into it: It is possible to connect and use many Arduinos to Mac at the same time. To do so run &lt;code&gt;$ open -n /Applications/Arduino.app/&lt;/code&gt; which will open a second instance of the Arduino IDE and you'll be able to select the Board and Port of each one and open multiple Serial windows. Notice that each Serial window has the path to the serial device which will help you know which window connected to which Arduino.&lt;/p&gt;&#xA;" OwnerUserId="23976" LastActivityDate="2016-07-17T18:27:02.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26452" PostTypeId="2" ParentId="26158" CreationDate="2016-07-17T19:26:31.973" Score="0" Body="&lt;p&gt;You found the solution yourself. I am posting this answer anyway just to&#xA;give some background on the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I must say you were somewhat unlucky: you have just hit a couple of the&#xA;least intuitive features of the C and C++ languages: integral promotion&#xA;and signed division.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integral promotion&lt;/strong&gt;: C does not know how to perform arithmetic on&#xA;anything smaller than an int. When you write &lt;code&gt;m_currentState - 1&lt;/code&gt;,&#xA;the variable &lt;code&gt;m_currentState&lt;/code&gt; is automatically promoted to &lt;code&gt;int&lt;/code&gt;.&#xA;Note that this promotion has converted an &lt;em&gt;unsigned&lt;/em&gt; type (&lt;code&gt;byte&lt;/code&gt; is&#xA;unsigned) into a &lt;em&gt;signed&lt;/em&gt; integer. Then, &lt;code&gt;(byte) 0 - 1&lt;/code&gt; is &lt;code&gt;(int) -1&lt;/code&gt;&#xA;instead of &lt;code&gt;(byte) 255&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Signed division&lt;/strong&gt;: When dividing a negative number by a positive&#xA;one, the quotient is rounded towards zero and, conversely, the rest&#xA;is negative. Then, &lt;code&gt;-1 % 8&lt;/code&gt; is -1 instead of 7.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;There are several ways around these problems. One is to replace the&#xA;modulo operation &lt;code&gt;% 8&lt;/code&gt; by a bitwise and: &lt;code&gt;&amp;amp; 7&lt;/code&gt;. This is an optimization&#xA;the compiler would have done anyway if dealing with &lt;em&gt;unsigned&lt;/em&gt; integers.&#xA;The option I prefer is to simply undo the integral promotion by an&#xA;explicit cast:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;m_currentState = (byte) (m_currentState - 1) % 8;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This way, if &lt;code&gt;m_currentState&lt;/code&gt; is zero, &lt;code&gt;(byte) (m_currentState - 1)&lt;/code&gt; is&#xA;255 and the result is, as expected, 7. Also, the compiler optimizes the&#xA;unsigned modulo operation into a bitwise and: the whole lines compiles&#xA;very efficiently into just two single-cycle instructions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;subi r24, 0x01  ; subtract 1&#xA;andi r24, 0x07  ; bitwise and with 7&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It is worth noting that nothing of this would have happened if&#xA;&lt;code&gt;m_currentState&lt;/code&gt; was an &lt;code&gt;unsigned int&lt;/code&gt;, as there would have been no&#xA;integral promotion in the first place.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-07-17T19:26:31.973" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26453" PostTypeId="2" ParentId="26444" CreationDate="2016-07-17T19:54:17.143" Score="4" Body="&lt;p&gt;Just send your data to a tee: this is a type of pipe fitting where you&#xA;push the data through one end and it goes out through the other two&#xA;ends. As it happens, both Serial and Softserial (and almost anything&#xA;that can &lt;code&gt;print()&lt;/code&gt;) inherit from the virtual &lt;code&gt;Print&lt;/code&gt; class. You can&#xA;implement a tee as a &lt;code&gt;Print&lt;/code&gt; that outputs to two &lt;code&gt;Print&lt;/code&gt;s:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;class Tee : public Print&#xA;{&#xA;public:&#xA;    Tee(Print &amp;amp;_p1, Print &amp;amp;_p2)&#xA;    : p1(_p1), p2(_p2)&#xA;    {}&#xA;&#xA;    size_t write(uint8_t c)&#xA;    {&#xA;        size_t count1 = p1.write(c);&#xA;        size_t count2 = p2.write(c);&#xA;        return min(count1, count2);&#xA;    }&#xA;private:&#xA;    Print &amp;amp;p1, &amp;amp;p2;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;write(uint8_t)&lt;/code&gt; is the only method you really need to implement to&#xA;have a working &lt;code&gt;Print&lt;/code&gt;. Then, all the &lt;code&gt;print()&lt;/code&gt; and &lt;code&gt;println()&lt;/code&gt; methods&#xA;will work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example usage:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;Tee dualSerial(Serial, mySerial);&#xA;dualSerial.print(&quot;The answer is &quot;);&#xA;dualSerial.println(42);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that &lt;code&gt;parseInt()&lt;/code&gt; will not work, as it is not a method from&#xA;&lt;code&gt;Print&lt;/code&gt;. But if you think twice, you will realize that &lt;code&gt;parseInt()&lt;/code&gt; on a&#xA;pair of channels just does not make sense.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-07-17T20:41:21.013" LastActivityDate="2016-07-17T20:41:21.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26454" PostTypeId="1" CreationDate="2016-07-17T21:35:19.313" Score="0" ViewCount="1450" Body="&lt;p&gt;I am building an Arduino Mega robot. I am planning to use IRremote.h library for it. I am using multiple libraries in my code and I do not know which timers are taken. I always get errors when compiling because I am using the wrong timer. Here are the libraries I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get this error message when compiling:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;libraries\IRremote\IRremote.cpp.o: In function `__vector_42':&#xA;&#xA;C:\Users\Lyuba\Desktop\Nick\Arduino\libraries\IRremote/IRremote.cpp:339: multiple definition of `__vector_42'&#xA;&#xA;libraries\Servo\avr\Servo.cpp.o:C:\Users\Lyuba\Desktop\Nick\Arduino\libraries\Servo\src\avr/Servo.cpp:95: first defined here&#xA;&#xA;c:/users/lyuba/desktop/nick/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions&#xA;&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&#xA;exit status 1&#xA;Error compiling for board Arduino/Genuino Mega or Mega 2560.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is the code in the library where I can change the timers:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Arduino Mega&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  //#define IR_USE_TIMER1   // tx = pin 11&#xA;  //#define IR_USE_TIMER2     // tx = pin 9&#xA; // #define IR_USE_TIMER3   // tx = pin 5&#xA;  #define IR_USE_TIMER4   // tx = pin 6&#xA;  //#define IR_USE_TIMER5   // tx = pin 46&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What can I do to use irremote library? Looking at the error message, the servo library conflicts with irremote. How can I fix this?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-07-17T22:52:25.567" LastActivityDate="2017-01-14T22:43:35.633" Title="Why does servo library conflict with irremote?" Tags="|arduino-mega|library|timers|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26455" PostTypeId="2" ParentId="26444" CreationDate="2016-07-17T21:40:51.113" Score="1" Body="&lt;p&gt;LOL, while Edgar was busy answering your question, I posted a github implementation called &lt;a href=&quot;https://github.com/SlashDevin/NeoTee&quot; rel=&quot;nofollow&quot;&gt;NeoTee&lt;/a&gt; which will tee any number of streams.  I have occasionally wanted such a class (attached at the end).  He has explained the approach nicely.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One quirk of the Arduino &lt;code&gt;Print&lt;/code&gt; and &lt;code&gt;Stream&lt;/code&gt; classes is that the &lt;code&gt;flush&lt;/code&gt; method is in &lt;code&gt;Stream&lt;/code&gt;, not &lt;code&gt;Print&lt;/code&gt;.  So to provide that method in the &lt;code&gt;NeoTee&lt;/code&gt; class requires deriving from &lt;code&gt;Stream&lt;/code&gt;.  But &lt;code&gt;Stream&lt;/code&gt; requires that you implement &lt;code&gt;read&lt;/code&gt;, &lt;code&gt;available&lt;/code&gt; and &lt;code&gt;peek&lt;/code&gt;.  Although &lt;code&gt;available&lt;/code&gt; can return the sum of the characters available on all &lt;code&gt;Streams&lt;/code&gt;, the usefulness of &lt;code&gt;read&lt;/code&gt; and &lt;code&gt;peek&lt;/code&gt; is functional, but dubious.  ;-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One example sketch is available in the library.  For your sketch, you would declare something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Stream *streams[2] = { &amp;amp;Serial, &amp;amp;mySerial };&#xA;NeoTee tee( streams, sizeof(streams)/sizeof(streams[0]) );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And used thusly:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;tee.print( '!' ); // prints one character to both&#xA;tee.print( 123.45 ); // prints a floating-point number on both&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;hr&gt;&#xA;NeoTee implementation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef _NEOTEE_H_&#xA;#define _NEOTEE_H_&#xA;&#xA;//------------------------------------------------------&#xA;// NeoTee&#xA;// Copyright (C) 2016, SlashDevin&#xA;//&#xA;// This library is free software; you can redistribute it and/or&#xA;// modify it under the terms of the GNU Lesser General Public&#xA;// License as published by the Free Software Foundation; either&#xA;// version 2.1 of the License, or (at your option) any later version.&#xA;//&#xA;// This library is distributed in the hope that it will be useful,&#xA;// but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&#xA;// Lesser General Public License for more details.&#xA;//&#xA;&#xA;#include &amp;lt;Stream.h&amp;gt;&#xA;&#xA;// This library is like the UNIX &quot;tee&quot; command, which splits an output stream &#xA;// into two streams, but with N branches.  On the Arduino, an output stream is&#xA;// instance of the Arduino Print class, and the flush method is in Stream.&#xA;//&#xA;// Simply declare your own array of streams:&#xA;//&#xA;//     Stream *streams[2];&#xA;//&#xA;// Pass the array and its size in to the NeoTee constructor:&#xA;//&#xA;//     NeoTee tee( streams, sizeof(streams)/sizeof(streams[0]) );&#xA;//&#xA;// Any Stream operation on &quot;tee&quot; will be duplicated on all Streams in the array.&#xA;//&#xA;//     tee.println( F(&quot;This is sent to all Stream instances in the array.&quot;) );&#xA;//&#xA;// Because there is no base class with &quot;begin&quot; and &quot;end&quot; methods, you&#xA;//   must call those explicitly on the individual Streams (e.g., Serial.begin)&#xA;&#xA;class NeoTee : public Stream&#xA;{&#xA;  Stream **Streams;&#xA;  uint8_t  NumStreams;&#xA;&#xA;public:&#xA;&#xA;  NeoTee( Stream **streams, uint8_t numStreams )&#xA;    {&#xA;      Streams    = streams;&#xA;      NumStreams = numStreams;&#xA;    }&#xA;&#xA;  virtual void flush()&#xA;    {&#xA;      for (uint8_t i=0; i&amp;lt;NumStreams; i++)&#xA;        Streams[i]-&amp;gt;flush();&#xA;    }&#xA;&#xA;  virtual size_t write(uint8_t c)&#xA;    {&#xA;      size_t minWritten = 0;&#xA;      for (uint8_t i=0; i&amp;lt;NumStreams; i++) {&#xA;        size_t written = Streams[i]-&amp;gt;write( c );&#xA;        if ((i == 0) || (minWritten &amp;gt; written))&#xA;          minWritten = written;&#xA;      }&#xA;      return minWritten;&#xA;    }&#xA;&#xA;  using Stream::write; // make the other overloads visible&#xA;&#xA;  virtual int available()&#xA;    {&#xA;      int total = 0;&#xA;      for (uint8_t i=0; i&amp;lt;NumStreams; i++)&#xA;        total += Streams[i]-&amp;gt;available();&#xA;      return total;&#xA;    }&#xA;&#xA;  virtual int read()&#xA;    {&#xA;      for (uint8_t i=0; i&amp;lt;NumStreams; i++)&#xA;        if (Streams[i]-&amp;gt;available())&#xA;          return Streams[i]-&amp;gt;read();&#xA;      return -1;&#xA;    }&#xA;&#xA;  virtual int peek()&#xA;    {&#xA;      for (uint8_t i=0; i&amp;lt;NumStreams; i++)&#xA;        if (Streams[i]-&amp;gt;available())&#xA;          return Streams[i]-&amp;gt;peek();&#xA;      return -1;&#xA;    }&#xA;&#xA;};&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="14737" LastEditDate="2016-07-17T23:09:01.993" LastActivityDate="2016-07-17T23:09:01.993" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26458" PostTypeId="2" ParentId="25489" CreationDate="2016-07-18T02:23:26.677" Score="1" Body="&lt;p&gt;I also had a 5V Pro Trinket on hand and needed to connect one of its 5V output pins to the 3V pairing pin on an Adafruit's EZ-Key HID. I solved it easily for the price of a couple 1/8 watt resistors by including a simple voltage divider in the circuit as a &quot;level shifter&quot; and it works like a charm. In my case it's not serial data but give it a try.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Classic voltage divider equation: V out = V in * R1 / (R1 + R2)&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;In setup(), set the 5V Pro Trinket digital out pin to be normally LOW when it's not doing anything in the sketch, e.g. if it were pin 8: pinMode(8,OUTPUT); digitalWrite(8, LOW);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect this 5V output pin to one end of a 1.8K resistor (the &quot;R1&quot;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect the other end of that resistor to both: your 3V module's input pin AND to a 3.3K resistor (the &quot;R2&quot;) to ground.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If you have a meter, perhaps before connecting to your module input first double check your circuit at the juncture of the resistors. Actual serial data probably won't produce a reliable reading so temporarily alter your sketch to just take the 5V Pro Trinket pin HIGH. I measured 3.1 V output on mine when the output goes HIGH and it works great with the EZ-Key module.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23980" LastEditorUserId="23980" LastEditDate="2016-07-18T02:35:32.607" LastActivityDate="2016-07-18T02:35:32.607" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26462" PostTypeId="1" AcceptedAnswerId="26464" CreationDate="2016-07-18T09:02:46.823" Score="0" ViewCount="3228" Body="&lt;p&gt;I have done a simple project which measures CO gas in air.Now I want that sensor will measure the level of CO gas and sms will be received on android phone when the area is under danger zone.How to receive sms on android phone without GSM module?&lt;/p&gt;&#xA;" OwnerUserId="23990" LastEditorUserId="23990" LastEditDate="2016-07-18T09:17:07.880" LastActivityDate="2016-07-18T13:53:25.903" Title="Receive sms on android phone without GSM module" Tags="|arduino-uno|" AnswerCount="2" CommentCount="1" ClosedDate="2016-08-01T05:35:25.333" ContentLicense="CC BY-SA 3.0" />
  <row Id="26464" PostTypeId="2" ParentId="26462" CreationDate="2016-07-18T09:54:23.807" Score="0" Body="&lt;p&gt;There are exactly two ways of sending an SMS. Both of which require more than &quot;just&quot; an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Directly using GSM - for which you NEED a GSM shield&lt;/li&gt;&#xA;&lt;li&gt;Indirectly using an Internet Gateway - for which you NEED some form of internet connection.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Since you have an aversion to 1, 2 is your only option. So you require some extra hardware (unless you have an Arduino with built in WiFi or Ethernet) to connect your Arduino to the internet. Then you have to pay an SMS gateway provider to allow you to send SMS messages through them, and implement their API in the Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you need an internet connection available wherever the Arduino happens to be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All in all a lot of work and you're really no better off than using a GSM shield.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-18T09:54:23.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26465" PostTypeId="1" AcceptedAnswerId="26470" CreationDate="2016-07-18T10:12:53.883" Score="3" ViewCount="178" Body="&lt;p&gt;I have master in electronics and IT. I know various microcontrollers programming in &lt;code&gt;c&lt;/code&gt;. I want to volunteer myself to learn for arduino Projects especially for low Level Drivers etc. Can somebody suggest me Websites or way ? &lt;/p&gt;&#xA;" OwnerUserId="23848" LastActivityDate="2016-07-18T13:25:53.187" Title="How to volunteer for arduino projects?" Tags="|programming|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26467" PostTypeId="2" ParentId="26465" CreationDate="2016-07-18T11:45:51.807" Score="0" Body="&lt;p&gt;Most of the libraries to read sensors like as Dallas/Maxim 1Wire products, or to interface to RF-, WiFi-, and other radios are user-contributed and maintained, and most, if not all, of them are community maintained and on github.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any official repository for arduino libraries where someone&#xA;  can contribute and submit patches?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&quot;Official&quot;: I don't think so, at least I don't know of one if there is, but I am also just learning my way around the open sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you'll probably find most of the libraries in github, and they are usually there to share development. They aren't generally grouped as &quot;Arduino&quot;, but by each author's github username. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the best approach is probably to identify the library in your &quot;libraries&quot; folder that you want to update, and its author's name which is usually in the source-code header comments. And, if you get lucky, a URL to the github project. Otherwise go to github and search for the library, using the author's name or a quick comparison of some the source code to be sure you've really found the same library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(As I am a user &amp;amp; beneficiary of open source code, you have my sincere thanks for choosing to do this! I haven't gotten that far yet; I hope to, soon.)&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-18T13:17:21.143" LastActivityDate="2016-07-18T13:17:21.143" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26470" PostTypeId="2" ParentId="26465" CreationDate="2016-07-18T13:25:53.187" Score="2" Body="&lt;p&gt;The Arduino paradigm is based on abstracting the hardware to a few simple function calls.  So many drivers appear simple to the end user (end programmer).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most go &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; for a list of libraries (which have already been written) and how to use them.  I believe these libraries are distributed with the Arduino SDK.  To learn more about writing libraries go &lt;a href=&quot;https://www.arduino.cc/en/Hacking/LibraryTutorial&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;. I am not aware of any formal method of submitting Arduino libraries.  If I wanted to find out more I would go &lt;a href=&quot;http://forum.arduino.cc/index.php/board,53.0.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and participate in the forum.  However, using the forums search, I found &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=262051.0&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; specific (several years old) post where it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;You can add a page to the Playground section:&#xA;  &lt;a href=&quot;http://playground.arduino.cc/&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/&lt;/a&gt; You might start by adding your website&#xA;  with Arduino code to the index of the playground, perhaps a page in&#xA;  the Playground section is not needed. The index can contain links to&#xA;  websites, to the Arduino forum or to a page in the Playground section.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;You can not change or add to the reference or official libraries.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-18T13:25:53.187" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26472" PostTypeId="2" ParentId="26462" CreationDate="2016-07-18T13:53:25.903" Score="0" Body="&lt;p&gt;&lt;strong&gt;Alternative from price perspective:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assuming that you have internet at the location of sensor (WiFi or cable) you can buy a RaspberryPi (revision 3 has already integrated WiFi and bluetooth). Using python code you can than send SMS message using some free SMS service provider if there are any in your country using their API.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If SMS notificaion is not critical, you can use RaspberryPi to send an email or some other sort of notification. Heck you can even create a Twitter profile for your sensor and call it Mr.Sensor and then post tweets with sensor values. Possibilities are endless, it all depends on your use case and available infrastructure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope you will find something that will satisfy your needs :)&lt;/p&gt;&#xA;" OwnerUserId="8308" LastActivityDate="2016-07-18T13:53:25.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26473" PostTypeId="1" AcceptedAnswerId="26475" CreationDate="2016-07-18T14:25:07.300" Score="0" ViewCount="358" Body="&lt;p&gt;I just had a pretty simple question about the RTC Clock Modules, more specifically the DS3231 RTC. Once calibrated and running on my Arduino if I were to unplug it and plug it back in, will the time and everything reset and require another calibration, or will it work like a computer that, even when reset, retains the correct time and date. Thanks!&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-07-18T15:00:40.803" Title="Real Time Clock Module Reset" Tags="|arduino-leonardo|rtc|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26475" PostTypeId="2" ParentId="26473" CreationDate="2016-07-18T15:00:40.803" Score="1" Body="&lt;p&gt;It depends if your module has a battery backup or not. A bare chip, by itself, will loose everything. That's why many breakout boards will have a small lithium cell on them to retain everything when the power is removed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-18T15:00:40.803" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26477" PostTypeId="1" CreationDate="2016-07-18T15:44:46.683" Score="0" ViewCount="136" Body="&lt;p&gt;I just got an Arduino 101 board. I was told that it's practically the same as the UNO. But have no experience using the UNO and I've only done super simple things on the 101 board without using a bread board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is have 2 servos connect to the board. I've only connected one servo without using a breadboard. I've looked on Instructables.com and other places that connect at least 2 to up most 12 servos. They all use different breadboards without specify if the brand, model, or if size even matters. I don't know how breadboards work and which holes I plug the wires into. Furthermore, I haven't found any videos on people working on the 101 board.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next, I'm not sure if the servos will share the same volt port. There's only 3V and 5V on my Arduino 101 board. If they all need 5V, I'm not sure how to make both servos share. I don't know how they will share the same ground port as well. I know for sure, they will have their own analog port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A list of recommendations would be nice. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15447" LastActivityDate="2016-11-17T09:35:30.777" Title="Can anyone recommend a breadboard for the new Arduino 101?" Tags="|arduino-uno|servo|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26479" PostTypeId="2" ParentId="26454" CreationDate="2016-07-18T18:01:39.760" Score="1" Body="&lt;p&gt;Usual problem is trying to use the same counter for both. For example arduino pins 6,7,8 are on TC4 and if you try to use IR on pin 6 and servo on 7 or 8, it won't work. You can't use pwms on these pins with servo either (it is possible to do it directly in registers, but in arduino framework it might get bad behavior)&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-18T18:01:39.760" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26482" PostTypeId="2" ParentId="20294" CreationDate="2016-07-18T18:39:21.477" Score="10" Body="&lt;p&gt;I know this was asked a long time ago, but maybe it will be useful for someone. I'm a beginner, regarding all this stuff, so if anybody knows a better way to do it, please correct me. here is how I set up CLion for Arduino (on Windows 10):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;CLion 2016.1.3 + Arduino 1.6.9 + plugin&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Download and install the official Arduino IDE (1.6.9).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download and install &lt;a href=&quot;https://sourceforge.net/projects/mingw/files/latest/download?source=files&quot; rel=&quot;noreferrer&quot;&gt;MinGW&lt;/a&gt; to 'C:\MinGW'&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In MinGW, install: 'mingw32-base' and 'mingw32-gcc-g++'&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Download and install &lt;a href=&quot;https://www.jetbrains.com/clion/download/#section=windows-version&quot; rel=&quot;noreferrer&quot;&gt;CLion&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Create an 'untitled' project, just to open CLion.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In CLion &gt; Settings &gt; Plugins &gt; Browse Repositories &gt; Search for and install: 'Arduino' (tools integration), and 'Serial Monitor' (misc).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In CLion &gt; Settings &gt; Search &gt; type 'MinGW'&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;At the environment select 'Use MinGW home', and browse to MinGW folder ('C:\MinGW'). Press apply, and wait until CLion finds the environment.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In File &gt; Close project.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open any file manager and go to 'c:\Users\name\ClionProjects\' and delete the 'untitled' project you just created.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Open CLion, select 'New Arduino sketch project'&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the project directory &gt; 'open cmakelists.txt' and configure lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;6: set board version&#xA;7: set port (you can find out port# from the Arduino IDE)&#xA;8: set the path where you installed your Arduino libraries (Arduino sketch folder)&#xA;&#xA;set(${CMAKE_PROJECT_NAME}_BOARD uno)&#xA;set(${CMAKE_PROJECT_NAME}_PORT COM3)&#xA;LINK_DIRECTORIES(c:\\ARDUINO\\libraries)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the upper right corner in CLion, near the green 'Play' button, select 'Edit Configuration', on the left select 'Application' &gt; 'Upload', and set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-target: 'upload'&#xA;-configuration: 'debug'&#xA;-executable: the project name&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;then press ok.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;In the project .ino file, write some really simple code (blink).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Connect an Arduino Uno via USB, and press the green 'play' button to upload the sketch.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;To start serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;In CLion main window bottom left, click serial monitor tab (in 'the tool buttons')&lt;/li&gt;&#xA;&lt;li&gt;Click the wrench icon to set up port and baud rate.&lt;/li&gt;&#xA;&lt;li&gt;On the top of the wrench icon, click the blue 'connect' icon.&lt;/li&gt;&#xA;&lt;li&gt;If values did not appear 'correctly', click the white 'switch to hex' icon (on the right of the wrench).&lt;/li&gt;&#xA;&lt;li&gt;Before uploading sketch, disconnect the serial monitor.&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;For CLion to properly find the libraries, make sure to use the same name for the lib folder as for the '.h' file. example: for DallasTemperature.h use folder name DallasTemperature. After #inlcude-ing new libs, right click on 'External libraries folder' and select 'Reload cmake project'.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You may want to do further configuration in CLion settings like: theme, colours, text size, etc.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Also, you can configure some handy 'live templates', like: &lt;code&gt;serialprintln&lt;/code&gt;, &lt;code&gt;digitalwrite&lt;/code&gt;, &lt;code&gt;pinmode&lt;/code&gt;, &lt;code&gt;switch&lt;/code&gt;, etc. to enhance your productivity.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="19671" LastEditorUserId="-1" LastEditDate="2018-07-19T20:25:04.417" LastActivityDate="2018-07-19T20:25:04.417" CommentCount="4" ContentLicense="CC BY-SA 4.0" />
  <row Id="26483" PostTypeId="1" AcceptedAnswerId="26487" CreationDate="2016-07-18T19:33:08.330" Score="0" ViewCount="173" Body="&lt;p&gt;I am trying to iterate over an int array and writing those values to a chip. Here is my code.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;int sine[] = {0x7fc ,0x868 ,0x8d4 ,0x93c ,0x9a8 ,0xa10 ,0xa78 ,0xadc &#xA;,0xb3c ,0xba0 ,0xbfc ,0xc58 ,0xcb0 ,0xd04 ,0xd58 ,0xda4 ,0xdf0 ,0xe34 ,0xe74 &#xA;,0xeb0 ,0xee8 ,0xf1c ,0xf4c ,0xf74 ,0xf98 ,0xfb8 ,0xfd0 ,0xfe4 ,0xff0 ,0xff8 &#xA;,0xffc ,0xff8 ,0xff0 ,0xfe4 ,0xfd0 ,0xfb8 ,0xf98 ,0xf74 ,0xf4c ,0xf1c ,0xee8 &#xA;,0xeb0 ,0xe74 ,0xe34 ,0xdf0 ,0xda4 ,0xd58 ,0xd04 ,0xcb0 ,0xc58 ,0xbfc ,0xba0 &#xA;,0xb3c ,0xadc ,0xa78 ,0xa10 ,0x9a8 ,0x93c ,0x8d4 ,0x868 ,0x7fc ,0x794 ,0x728 &#xA;,0x6bc ,0x654 ,0x5ec ,0x584 ,0x520 ,0x4bc ,0x45c ,0x400 ,0x3a4 ,0x34c ,0x2f4 &#xA;,0x2a4 ,0x258 ,0x20c ,0x1c8 ,0x188 ,0x148 ,0x110 ,0xe0 ,0xb0 ,0x88 ,0x64 ,0x44 &#xA;,0x2c ,0x18 ,0xc ,0x0 ,0x0 ,0x0 ,0xc ,0x18 ,0x2c ,0x44 ,0x64 ,0x88 ,0xb0 ,0xe0 &#xA;,0x110 ,0x148 ,0x188 ,0x1c8 ,0x20c ,0x258 ,0x2a4 ,0x2f4 ,0x34c ,0x3a4 ,0x400 &#xA;,0x45c ,0x4bc ,0x520 ,0x584 ,0x5ec ,0x654 ,0x6bc ,0x728 ,0x794};&#xA;&#xA;#define samples 120&#xA;&#xA;const int cs = 9;&#xA;&#xA;int counter = 0;&#xA;&#xA;const int chipSelectPin = 10;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(cs,OUTPUT);&#xA;  pinMode(chipSelectPin, OUTPUT);&#xA;&#xA; SPI.beginTransaction(SPISettings(20000,LSBFIRST,SPI_MODE3));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;&#xA;&#xA;  digitalWrite(cs,LOW);&#xA;&#xA;&#xA;&#xA;  SPI.transfer(sine[counter]);&#xA;&#xA;  digitalWrite(cs,HIGH);&#xA;&#xA;&#xA;  counter += 1;&#xA;&#xA;  if(counter &amp;gt;= samples)&#xA;  {&#xA;    counter = 0;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Very simple, I am using an Arduino nano and according to &lt;a href=&quot;https://www.google.com/search?q=arduino%20nano%20pinout&amp;amp;espv=2&amp;amp;biw=1366&amp;amp;bih=643&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ved=0ahUKEwiS3uOm0P3NAhXCyyYKHQLmB5MQ_AUIBigB#imgrc=i5z_gVO0W559NM%3A&quot; rel=&quot;nofollow&quot;&gt;this reference&lt;/a&gt; the clock pin is 13 and MOSI is 11. I am seeing the clock signal for pin 13 but pin 11 is inactive.&lt;/p&gt;&#xA;" OwnerUserId="24003" LastEditorUserId="24003" LastEditDate="2016-07-18T19:53:20.627" LastActivityDate="2016-07-18T20:49:39.720" Title="Arduino SPI - MOSI not writing any data but clock works" Tags="|arduino-nano|spi|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26487" PostTypeId="2" ParentId="26483" CreationDate="2016-07-18T20:34:16.710" Score="2" Body="&lt;p&gt;You need to use SPI.begin() before the beginTransaction().&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation is not 100% clear but beginTransaction does not replace SPI.Begin to setup the SPI hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Documentation not very clear: &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPIbeginTransaction&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/SPIbeginTransaction&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-07-18T20:34:16.710" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26488" PostTypeId="2" ParentId="26483" CreationDate="2016-07-18T20:49:39.720" Score="3" Body="&lt;p&gt;In addition to @Talk2's answer &lt;code&gt;SPI.transfer(...)&lt;/code&gt; transfers one byte of data. Your array is made of &lt;code&gt;int&lt;/code&gt; which means each entry is 2 bytes long.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should use &lt;code&gt;SPI.transfer16(...)&lt;/code&gt; to transfer 16-bit values.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-18T20:49:39.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26489" PostTypeId="1" CreationDate="2016-07-18T21:07:11.930" Score="2" ViewCount="400" Body="&lt;p&gt;There are multiple RTC libraries available, can I load several RTC libraries into my code and then use the functions I like from each one?  Will there be some conflict if for example I include DS1307.h   and RTCLib.h and other RTCXXXX.h libraries as well? &lt;/p&gt;&#xA;" OwnerUserId="24009" LastActivityDate="2017-06-29T05:22:48.417" Title="Using multiple RTC libraries in one program" Tags="|rtc|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26491" PostTypeId="2" ParentId="19164" CreationDate="2016-07-18T21:47:31.400" Score="1" Body="&lt;p&gt;I wonder if you destroyed your Arduino's voltage regulator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Arduino was connected to the stepper motor via the A4988 when you powered the Arduino with a 12V supply, the stepper motor might have drawn current from the Arduino's regulator. This current is likely ~2As, which is far more than the tens of milliamps the Arduino is designed to output. This kind of current draw could quite possibly destroy the regulator on your Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This could also explain why your computer restarted. USB ports on computers are designed to provide an output voltage to their USB devices, so if you provide a voltage on the USB power lines your computer is also driving, you can short your ports if the two voltages are not exactly the same. This is actually why USB cables have the A vs B end design - they mark which side should supply power (A), and which should be powered (B). The Arduino might have provided a voltage on the USB cable's 5V line and thus shorted something in your computer that provides the voltage for your USB ports (I believe Unos are not designed to be powered by both USB and the 12V connectors simultaneously). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the regulator fried on your Uno, you might have had a voltage that was way off of the expected 5v on the USB port. A well designed USB port will usually try protect itself in a situation like this, often causing the computer to shutdown or the USB bus to deactivate until restarting the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could check your Uno's voltage regulator with a multimeter or better yet and oscilloscope to see if that is in fact the problem. If so, you could solder a new one on pretty cheaply and quickly. However, there is no guarantee nothing else got fried, in which case buying a new $10-20 Uno looks like a pretty appealing option.&lt;/p&gt;&#xA;" OwnerUserId="24010" LastEditorUserId="84" LastEditDate="2016-07-31T12:42:49.277" LastActivityDate="2016-07-31T12:42:49.277" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26492" PostTypeId="2" ParentId="17786" CreationDate="2016-07-18T21:49:51.363" Score="-1" Body="&lt;p&gt;I've converted first four bytes to string, and then to int :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void something(uint8_t * payload){&#xA;String str=&quot;&quot;;&#xA;char c;&#xA;for(int i=0;i&amp;lt;4;i++)&#xA;    if (isDigit(c=(char)(*(payload+i))))&#xA;        str += c;&#xA;&#xA;int Val =str.toInt();&#xA;Val=Val&amp;gt;1023?1023:Val;&#xA;&#xA;analogWrite(14,Val);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24008" LastActivityDate="2016-07-18T21:49:51.363" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26493" PostTypeId="1" AcceptedAnswerId="26497" CreationDate="2016-07-19T01:04:23.660" Score="0" ViewCount="639" Body="&lt;p&gt;To clarify I'm extremely new to this and I'm using an Arduino Uno with a wave shield. My circuit works as intended but I haven't learned enough of the code to know what to do to make it do exactly what I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right now the following code makes the sound play on button press but the led sequence doesn't at all. If I move &lt;code&gt;root.rewind(); play(root);&lt;/code&gt; to after the last &lt;code&gt;digitalWrite&lt;/code&gt; then the led sequence runs but the audio doesn't play until the led sequence ends. I'm out to make the audio play while the led sequence runs. Any suggestions?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;if (state == 1) {&#xA;    root.rewind();&#xA;    play(root);&#xA;    for (i = 0; i &amp;lt; 255; i++) { // loop from 0 to 254 (fade in)&#xA;        analogWrite(LED,i);     // set the LED brightness&#xA;        delay(15);              // wait 15ms because analogWrite&#xA;                                // is instantaneous and we would&#xA;                                // not see any change&#xA;    }&#xA;    analogWrite(LED, HIGH);     // turns the LED on&#xA;    delay(300);                 // waits for a second&#xA;    analogWrite(LED, LOW);      // turns the LED off&#xA;    delay(100);                 // waits for a second&#xA;    analogWrite(LED, HIGH);     // turns the LED on&#xA;    delay(300);                 // waits for a second&#xA;    analogWrite(LED, LOW);      // turns the LED off&#xA;    delay(100);                 // waits for a second&#xA;&#xA;    digitalWrite(RESET, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24014" LastEditorUserId="972" LastEditDate="2016-07-19T18:16:30.303" LastActivityDate="2020-05-04T06:16:03.950" Title="how to make led fade on and blink while wav file plays" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26495" PostTypeId="1" CreationDate="2016-07-19T02:02:45.980" Score="0" ViewCount="405" Body="&lt;p&gt;I am not sure an Arduino forum is the right place to ask this question, but since I'm using Arduino here I thought it would be a good starting point. I am trying to connect a lever (you can think of it as a switch, when it's pressed it's ON, and otherwise it's OFF) to an Arduino via a USB connector. My setup worked perfectly fine when I connected the lever directly to the Arduino, but via the USB it doesn't work. Since I already built and invested in USB connectors I would like to solve this issue, or at least understand what I am doing wrong in here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've attached a photo to demonstrate the wiring. Note that it works if I bypass this USB connection. I'm trying to understand why this doesn't work via a USB. &lt;a href=&quot;https://i.stack.imgur.com/Fge6i.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Fge6i.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24015" LastActivityDate="2016-07-20T11:47:30.927" Title="USB connector between Arduino and a lever (switch)" Tags="|arduino-uno|usb|switch|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26497" PostTypeId="2" ParentId="26493" CreationDate="2016-07-19T04:15:12.480" Score="3" Body="&lt;p&gt;As this can not be your entire sketch we can only guess that you are using some sort of SDCard music playing Arduino shield and library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An application can not call the delay() function if the application is trying to accomplish more than one task.  Calls to delay() block the processor from doing anything other than waiting for the delay to time out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to (appear to) do multiple tasks, run a loop with no calls to the delay() function.  Instead call the millis() function checking if enough time has elapsed to call the LED function or the sound function.  In neither function should you call the delay() function!  If you did not write the function (for example you are using a library) you may need to edit the code in the library to ensure it is following the no-calls-to-delay()-function rule!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general terms, this is referred to as a state machine.  In this case, the state machine is driven by the amount of elapsed time as reported by the call to the millis() function.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-07-19T04:15:12.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26500" PostTypeId="2" ParentId="26122" CreationDate="2016-07-19T05:25:02.873" Score="0" Body="&lt;p&gt;I'd second the use of the MCP23017, have used this chip in several projects with good results, you can connect 8 of them together which gives 128 I/O pins.&#xA;Off the SDA/SCL pins UNO R3&#xA;Link &lt;a href=&quot;https://www.adafruit.com/products/732&quot; rel=&quot;nofollow&quot;&gt;Adafruit MCP23017&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also on Ebay from other suppliers.&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-07-19T05:25:02.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26503" PostTypeId="2" ParentId="26477" CreationDate="2016-07-19T08:27:51.013" Score="2" Body="&lt;p&gt;A breadboard is nothing but a way to attach multiple wires to the same pins. There are many different kinds as can be seen &lt;a href=&quot;https://www.google.nl/search?q=breadboard&amp;amp;espv=2&amp;amp;biw=1777&amp;amp;bih=861&amp;amp;source=lnms&amp;amp;tbm=isch&amp;amp;sa=X&amp;amp;ved=0ahUKEwiUte3Jjf_NAhXG7hoKHVZwAjQQ_AUIBigB&amp;amp;dpr=0.9&quot; rel=&quot;nofollow&quot;&gt;in these images&lt;/a&gt;. There's no right or wrong when it comes to breadboards, as long as you have enough pins to prototype you should be good to go.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-19T08:27:51.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26504" PostTypeId="2" ParentId="23246" CreationDate="2016-07-19T09:18:02.507" Score="4" Body="&lt;p&gt;I've looked at the data sheet for this and I think it is the wrong choice of device for a beginner.  Can I suggest that you start by looking at a relatively simple DPI interfaced device, such as a sensor or RTC.  This will teach you the basics of sending commands via the Wire library.  You might even get the hang of it just by looking at existing libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can't find a library, so you are going to need to write your own.  The library will need a begin function which initialises you class and a write and read function, which write and read from an address.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void begin(void);&#xA;uint8_t read(const uint8_t&amp;amp; address);&#xA;void write (const uint8_t&amp;amp; address, const uint8_t&amp;amp; bytesOfData, const uint8_t* pData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You will need to flesh those functions out, but that's it.  If you want to make you library more useable read the datasheet and create wrapper functions for each of the registers that can be accessed.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This instruction requires 10 buts spread over two bytes.&#xA;void writeFrequencyOffset (const uint8_t&amp;amp; highByte, const uint8_t&amp;amp; lowByte)&#xA;{&#xA;  write (0x73, lowByte);&#xA;  write (0x74, highByte);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The process of creating friendly wrappers is a tedious operations, just reading the data sheet and translating that into code.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-19T09:18:02.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26505" PostTypeId="1" AcceptedAnswerId="26507" CreationDate="2016-07-19T09:27:48.470" Score="0" ViewCount="381" Body="&lt;p&gt;So I have just begun testing my Wireless SD Shield from Arduino with my Arduino UNO. Upon running my the basic CardInfo sketch, it uploads and displays data, but far more than expected. The SD Card is entirely empty, as in, if I plug it into my computer, there are no files on it. However, this is the Serial Monitor Output I receive: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2is3r.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2is3r.png&quot; alt=&quot;Part 1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/edenQ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/edenQ.png&quot; alt=&quot;Part 2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reason I have included screenshots rather than copy and pasting the output, is that if I try and copy and paste, it does not copy all of the Files Found on the card, it only copies the first 8 lines. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly, appreciated!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This code does not compile for me and gives me an avrdude error which I believe is due in some part to the above pictures: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Program by Jeremy Blum&#xA;//www.jeremyblum.com&#xA;//SD Card Demonstration&#xA;//Based on Example by Tom Igoe&#xA;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;//Set by default for the SD Card Library&#xA;//MOSI = Pin 11&#xA;//MISO = Pin 12&#xA;//SCLK = PIN 13&#xA;//We always need to set the CS Pin&#xA;int CS_pin = 4;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Initializing Card&quot;);&#xA;  //CS Pin is an output&#xA;  pinMode(CS_pin, OUTPUT);&#xA;&#xA;&#xA;  if (!SD.begin(CS_pin))&#xA;  {&#xA;      Serial.println(&quot;Card Failure&quot;);&#xA;      return;&#xA;  }&#xA;  Serial.println(&quot;Card Ready&quot;);&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  String dataString = &quot;Hello&quot;;&#xA;&#xA;  //Open a file to write to&#xA;  //Only one file can be open at a time&#xA;&#xA;  File dataFile = SD.open(&quot;log.txt&quot;, FILE_WRITE);&#xA;  if (dataFile)&#xA;  {&#xA;    dataFile.println(dataString);&#xA;    dataFile.close();&#xA;    Serial.println(dataString);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;Couldn't open log file&quot;);&#xA;  }&#xA;  delay(5000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whereas, this code does:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SD.h&amp;gt;         //SD Card Library&#xA;#include &amp;lt;Wire.h&amp;gt;       //I2C Library&#xA;#include &amp;lt;DallasTemperature.h&amp;gt;&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;&#xA;OneWire oneWire(2); // initiate pin connected to DS18B20&#xA;DallasTemperature sensors(&amp;amp;oneWire); // pass oneWire as parameter to Dallas Temp. library&#xA;&#xA;//SPI SD Card Pins&#xA;  //MOSI = Pin 11&#xA;  //MISO = Pin 12&#xA;  //SCLK = PIN 13&#xA;  int CS_pin = 4;&#xA;//  int pow_pin = 8;&#xA;&#xA;//Light Sensor Pins&#xA;  int light_pin = 0;&#xA;&#xA;float refresh_rate = 500;  //Dataloger Refresh Rate&#xA;float id = 0;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  sensors.begin(); // initiate the sensors on the DS18B20&#xA;  Serial.println(&quot;Initializing Card&quot;);&#xA;  //CS Pin is an output&#xA;  pinMode(CS_pin, OUTPUT);&#xA;&#xA;//  //SD Card will Draw Power from Pin 8, so set it high&#xA;//  pinMode(pow_pin, OUTPUT);  &#xA;//  digitalWrite(pow_pin, HIGH);&#xA;&#xA;  //Initialize Card&#xA;  if (!SD.begin(CS_pin))&#xA;  {&#xA;      Serial.println(&quot;Card Failure&quot;);&#xA;      return;&#xA;  }&#xA;  Serial.println(&quot;Card Ready&quot;);&#xA;&#xA;&#xA;  //Write Log File Header&#xA;  File logFile = SD.open(&quot;LOG.csv&quot;, FILE_WRITE);&#xA;  if (logFile)&#xA;  {&#xA;    logFile.println(&quot;, , , ,&quot;); //Just a leading blank line, incase there was previous data&#xA;    String header = &quot;ID, Light, Temp&quot;;&#xA;    logFile.println(header);&#xA;    logFile.close();&#xA;    Serial.println(header);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;Couldn't open log file&quot;);&#xA;  }&#xA;&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  //Check Light Level&#xA;  int light_level = analogRead(light_pin); //Write the value of the photoresistor to the serial monitor.&#xA;&#xA;  //Read Temperature&#xA;  sensors.requestTemperatures(); // request the temperatures from the DS18B20, does not actually do anything simple sets it up&#xA;  float currentTemp; // initialize variable to store and hold current temperature readings&#xA;  currentTemp = sensors.getTempCByIndex(0); // go and get temperature in Celcius for the first temp probe, temperature probe 0 (could have more than one sensor here if wanted)&#xA;&#xA;  Serial.print(&quot;Temperature = &quot;);&#xA;  Serial.print(currentTemp); // prints actual temperature and starts new line&#xA;  Serial.print(&quot; Celcius &quot;);&#xA;  /* Serial.print((char)223); print degree symbol in LCD format */&#xA;//  Serial.println(&quot;C&quot;);&#xA;&#xA;&#xA;  //Create Data string for storing to SD card&#xA;  //We will use CSV Format  &#xA;  String dataString = String(id) + &quot;, &quot; + String(light_level) + &quot;, &quot; + String(currentTemp);&#xA;&#xA;  //Open a file to write to&#xA;  //Only one file can be open at a time&#xA;  File logFile = SD.open(&quot;LOG.csv&quot;, FILE_WRITE);&#xA;  if (logFile)&#xA;  {&#xA;    logFile.println(dataString);&#xA;    logFile.close();&#xA;    Serial.println(dataString);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.println(&quot;Couldn't open log file&quot;);&#xA;  }&#xA;&#xA;  //Increment ID number&#xA;  id++;&#xA;&#xA;  delay(refresh_rate);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Both sketches are quite different, so I reccomend just looking at the intial void setup() part of each if you want to read through them.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="21627" LastEditDate="2016-07-20T12:56:55.800" LastActivityDate="2016-07-20T13:05:45.033" Title="SD Card Info Unexpected" Tags="|arduino-uno|serial|sd-card|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26506" PostTypeId="2" ParentId="18893" CreationDate="2016-07-19T10:09:24.113" Score="-1" Body="&lt;p&gt;interestingly changing to Time.h didn't work for me (arduino sdk 1.6.9) however commenting out the include line did...&lt;/p&gt;&#xA;" OwnerUserId="24027" LastActivityDate="2016-07-19T10:09:24.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26507" PostTypeId="2" ParentId="26505" CreationDate="2016-07-19T10:25:15.817" Score="1" Body="&lt;p&gt;Joy of tech... It's full file table, with old, deleted entries appearing as current files. You can nuke it with a quick or slow format, but the problem will return later. I don't know this shield, but there must be some problem with the code - it really shouldn't show deleted entries. Try another library, or google for problems with your current lib. &lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-07-19T10:25:15.817" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26508" PostTypeId="2" ParentId="26495" CreationDate="2016-07-19T11:30:52.943" Score="3" Body="&lt;p&gt;I'd suggest using a multimeter to figure out what's connected to what after hooking up the complete wiring scheme; there aren't that many options and you should be able to figure out what's connected to what soon enough. On a more philosophical note, it's only a bad idea if the alternatives weren't worse.&lt;/p&gt;&#xA;" OwnerUserId="24028" LastEditorUserId="24028" LastEditDate="2016-07-20T11:47:30.927" LastActivityDate="2016-07-20T11:47:30.927" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26510" PostTypeId="1" CreationDate="2016-07-19T07:29:08.723" Score="1" ViewCount="656" Body="&lt;p&gt;After finding out about the situation with pin7 from this tutorial:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forum.sparkfun.com/viewtopic.php?f=32&amp;amp;t=35847&quot; rel=&quot;nofollow&quot;&gt;https://forum.sparkfun.com/viewtopic.php?f=32&amp;amp;t=35847&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void setup(){&#xA;&#xA;    EICRB |= (1&amp;lt;&amp;lt;ISC60)|(0&amp;lt;&amp;lt;ISC61); // sets the interrupt type for EICRB (INT6).&#xA;                                  // EICRA sets interrupt type for INT0...3&#xA;&#xA;    /*&#xA;    ISCn0  ISCn1   Where n is the interrupt. 0 for 0, etc&#xA;      0      0   Triggers on low level&#xA;      1      0   Triggers on edge&#xA;      0      1   Triggers on falling edge&#xA;      1      1   Triggers on rising edge&#xA;    */&#xA;EIMSK |= (1&amp;lt;&amp;lt;INT6); // activates the interrupt. 6 for 6, etc&#xA;&#xA;void loop(){&#xA;//do other things here&#xA;}&#xA;&#xA;ISR(INT6_vect) {&#xA;  // interrupt code goes here&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have set:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;EICRB |= (0&amp;lt;&amp;lt;ISC60)|(0&amp;lt;&amp;lt;ISC61);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Because I need it to be triggered on LOW.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could still not get it work on the micro. IF I use the pin as regular input pin I can clearly see LOW/HIGHs on pin 7 with digitalread. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a sensor attached there which goes LOW in case it is triggered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wonder if anybody knows what else can I try to get it work. I already hardwired everything in my circuit board, there are no more free interrupts and no way to change them.&lt;/p&gt;&#xA;" OwnerUserId="16175" OwnerDisplayName="munin24" LastEditorUserId="37523" LastEditDate="2018-07-27T01:37:47.340" LastActivityDate="2018-07-27T01:37:47.340" Title="Arduino Micro Cannot get Interrupt 6 work on PIN 7" Tags="|arduino-micro|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26513" PostTypeId="2" ParentId="13393" CreationDate="2016-07-19T16:06:49.667" Score="0" Body="&lt;p&gt;You could also use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;in transmitter.ino&#xA;#define TX 1&#xA;#include &quot;share.h&quot;&#xA;&#xA;in receiver.ino&#xA;#define RX 1&#xA;#include &quot;share.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24035" LastEditorUserId="24035" LastEditDate="2016-07-19T16:15:50.663" LastActivityDate="2016-07-19T16:15:50.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26514" PostTypeId="2" ParentId="16170" CreationDate="2016-07-19T16:19:12.290" Score="0" Body="&lt;p&gt;I took your code as a starting point and got it to work with some small modifications. I am providing my version below for your review. I had to add a bunch of delays. I am also communicating with the ESP8266 at 19200 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have not optimized the timing yet but I was able to run this code for 24 hours straight with no issues. I am using Pins 6 and 7 on the Arduino for COMM to the ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#define SSID &quot;YOURSSID&quot;&#xA;#define PASS &quot;YOURPW&quot;&#xA;#define DST_IP &quot;220.181.111.85&quot;&#xA;&#xA;SoftwareSerial Serial2(6, 7); // RX, TX&#xA;&#xA;void setup() {&#xA;&#xA;// Open serial communications w ESP8266&#xA;Serial2.begin(19200);&#xA;Serial2.setTimeout(5000);&#xA;&#xA;// serial 0 is to usb&#xA;Serial.begin(115200);&#xA;while(!Serial); &#xA;while(!Serial2);&#xA;&#xA;Serial.println(&quot;ESP8266 Demo on Mega2560&quot;);&#xA;&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial2.read();&#xA;delay(1000);&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial2.read();&#xA;&#xA;//test if the module is ready&#xA;Serial.println(&quot;RESETTING ESP8266 WIFI CHIP&quot;);&#xA;Serial2.write(&quot;AT+RST\r\n&quot;);&#xA;delay(2500);&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial.write(Serial2.read());&#xA;&#xA;delay(2500);&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial.write(Serial2.read());&#xA;Serial.println(&quot;&quot;);&#xA;&#xA;//  connect to the wifi&#xA;boolean connected=false;&#xA;for(int i=0;i&amp;lt;5;i++) {&#xA;if(connectWiFi())&#xA;{&#xA;connected = true;&#xA;break;&#xA;}&#xA;}&#xA;&#xA;if (!connected){&#xA;Serial.println(&quot;Not Connected.&quot;);&#xA;}&#xA;&#xA;Serial2.println(&quot;AT+CIFSR&quot;);&#xA;delay(2000);&#xA;while (Serial2.available())&#xA;Serial.write(Serial2.read());&#xA;delay(2000);&#xA;while (Serial2.available())&#xA;Serial.write(Serial2.read());&#xA;&#xA;//  set the single connection mode&#xA;Serial2.println(&quot;AT+CIPMUX=0&quot;);&#xA;delay(2000);&#xA;while (Serial2.available())&#xA;Serial.write(Serial2.read());&#xA;delay(2000);&#xA;while (Serial2.available())&#xA;Serial.write(Serial2.read());&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;String cmd = &quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;&quot;;&#xA;cmd += DST_IP;&#xA;cmd += &quot;\&quot;,80&quot;;&#xA;Serial2.println(cmd);&#xA;Serial.println(cmd);&#xA;delay(5000);&#xA;&#xA;if(Serial2.find(&quot;Error&quot;)) return;&#xA;&#xA;cmd=&quot;GET / HTTP/1.0\r\n\r\n&quot;;&#xA;Serial2.print(&quot;AT+CIPSEND=&quot;);&#xA;Serial2.println(cmd.length());&#xA;delay(2000);&#xA;&#xA;if(Serial2.find(&quot;&amp;gt;&quot;))      {&#xA;Serial.print(&quot;&amp;gt;&quot;); &#xA;}&#xA;else {&#xA;Serial2.println(&quot;AT+CIPCLOSE&quot;);&#xA;Serial.println(&quot;connect timeout&quot;);&#xA;delay(2000);&#xA;return;&#xA;}&#xA;Serial2.print(cmd);&#xA;delay(2500);&#xA;&#xA;while (Serial2.available()) {&#xA;char c = Serial2.read();&#xA;Serial.write(c);;&#xA;if(c=='\r') Serial.print('\n');&#xA;delay(5);&#xA;}&#xA;&#xA;Serial.println(&quot;&quot;);&#xA;Serial.println(&quot;====&quot;);&#xA;delay(2000);&#xA;}&#xA;&#xA;boolean connectWiFi() {&#xA;&#xA;String cmd;&#xA;int iIP;&#xA;&#xA;iIP = 0;&#xA;Serial2.println(&quot;AT+CWMODE=1&quot;);&#xA;delay(5000);&#xA;while (Serial2.available())&#xA;Serial.write(Serial2.read());&#xA;&#xA;cmd=&quot;AT+CWJAP=\&quot;&quot;;&#xA;cmd+=SSID;&#xA;cmd+=&quot;\&quot;,\&quot;&quot;;&#xA;cmd+=PASS;&#xA;cmd+=&quot;\&quot;&quot;;&#xA;&#xA;Serial2.println(cmd);&#xA;&#xA;delay(2000);&#xA;Serial.println(&quot;Line 1&quot;);&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial.write(Serial2.read());&#xA;&#xA;delay(2000);&#xA;Serial.println(&quot;Line 2&quot;);&#xA;while (Serial2.available() &amp;gt; 0)&#xA;Serial.write(Serial2.read());&#xA;if (Serial2.find(&quot;OK&quot;)) {&#xA;Serial.println(&quot;WIFI OK was received!&quot;);&#xA;iIP = 1;&#xA;}  &#xA;&#xA;if( iIP == 1 ) {&#xA;Serial.println(&quot;OK, Connected to WiFi.&quot;);&#xA;return true;&#xA;}&#xA;else  {&#xA;Serial.println(&quot;Can not connect to the WiFi.&quot;);&#xA;return false;&#xA;}&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24036" LastActivityDate="2016-07-19T16:19:12.290" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26515" PostTypeId="1" AcceptedAnswerId="26519" CreationDate="2016-07-19T16:19:29.230" Score="3" ViewCount="54" Body="&lt;p&gt;Powering at 5 volts, atmega328 output ~4.7 volts. I need to output between 12 and 24 volts @ 2 amp. I'm currently using relay but they are costly. Is there a way to do it with transistors or any thing cheaper?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="24034" LastActivityDate="2016-07-19T19:01:26.260" Title="Cheapest way to change digital output source" Tags="|atmega328|digital|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26516" PostTypeId="1" AcceptedAnswerId="26517" CreationDate="2016-07-19T16:24:21.543" Score="1" ViewCount="9899" Body="&lt;p&gt;I working on a project that requires a small camera to be covering a (insect) nest entrance. The video needs to be transmitted to a computer to be processed. I am interfacing with Java using the RXTX library and will then be tracking objects using OpenCV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.ebay.co.uk/itm/321943226649&quot; rel=&quot;nofollow&quot;&gt;This is the camera&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, it it possible to connect this camera to an Arduino (Uno or Yun) and transmit the data back to a computer? &lt;/p&gt;&#xA;" OwnerUserId="23260" LastActivityDate="2016-07-19T17:03:59.580" Title="Is it possible to connect a camera to an arduino?" Tags="|arduino-uno|arduino-yun|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26517" PostTypeId="2" ParentId="26516" CreationDate="2016-07-19T17:03:59.580" Score="1" Body="&lt;p&gt;Yes. Check out ArduCam. Do a google search. &lt;a href=&quot;http://www.arducam.com&quot; rel=&quot;nofollow&quot;&gt;http://www.arducam.com&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="490" LastActivityDate="2016-07-19T17:03:59.580" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26518" PostTypeId="2" ParentId="16170" CreationDate="2016-07-19T18:02:28.180" Score="1" Body="&lt;p&gt;Your transmitter and receiver pins need to be crossed, rx-&gt;tx and tx-&gt;rx. As a mnemonic, the two ends of the antenna point to the board edge with the receiver pin and it is that pin that needs the voltage divider. While you're at it, it would be a good idea to tie the RST pin high, as well as the CH_PD. I use one 10K pullup for both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Recent versions of these boards are shipped with their baud rates set to 115200. Since you're using a hardware UART on the Mega board, you can send/receive to it at that rate. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Note to readers using a software UART (SoftwareSerial): First thing, change the board's baud rate to 9600 and communicate with it at that rate. You can use SoftwareSerial to make the change as it sends at 115200 reasonably reliably, but its receive function can't keep up at that rate).&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can confirm your connections and baud rate with:&lt;br&gt;&#xA;&lt;code&gt;EspSerial.println(&quot;AT&quot;);&lt;/code&gt;&lt;br&gt;&#xA;You should receive `OK' in reply.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-07-19T18:02:28.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26519" PostTypeId="2" ParentId="26515" CreationDate="2016-07-19T19:01:26.260" Score="2" Body="&lt;p&gt;As @Gerben said in the comments, I would also recommend an N-channel MOSFET.  OnSemi has a great application note on how to determine what type of MOSFET you would need based on your given load requirements and how to use it as a switch.  You can find that app note &lt;a href=&quot;http://www.onsemi.com/pub_link/Collateral/AND9093-D.PDF&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic idea is to provide an enable signal from your atmega328 to the gate of the MOSFET to drive it into saturation or to turn it off.  You would connect your 12/24V supply to the drain of the MOSFET and connect your load to the source of the MOSFET.  The basic circuit can be seen in the application note.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps!&lt;/p&gt;&#xA;" OwnerUserId="5067" LastActivityDate="2016-07-19T19:01:26.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26521" PostTypeId="1" CreationDate="2016-07-19T22:45:47.980" Score="0" ViewCount="6168" Body="&lt;p&gt;I know this problem is kinda common but I had to post it anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before anything, I would like to inform you guys that I changed the fuse of my Arduino Pro 3v3 @ 8MHz to allow 1.8 V brownout and also programmed CKDIV8 AND CLKOUT. In other words, the fuse configuration is this: E:FE, H:DA, L:3F.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The programmer is the Arduino 2009 running as ISP programmer. The target is Arduino Pro Mini 3V3 @ 8Mhz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also used a 0.1uF cap between reset and ground in the Arduino programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a good time using the Arduino Pro without problems, some random problems began to appear when I tried to upload a program with the programmer (Arduino as ISP). So I tried to burn the bootloader again and the following message appeared &quot;&quot;avrdude: Yikes! Invalid device signature.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same occurs when I try to communicate with avrdude using this command &quot;avrdude -c arduino -p m328p -P COM3 -b 19200 -v&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some tests I did:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Continuity test directly at uC pins between those signals: SCK, MISO, MOSI, (/SS - /RESET). No problem good connection.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Verified the clock in XTAL1 and XTAL2. No problem 8MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Verified the clock in CKOUT (Arduino Pro pin 2) and measured 1MHz.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I also tried to delay the avrdude using -B5, B10 and another values. With a quick search on Google some people are saying that those delays don't work with the Arduino as ISP.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I used some sketches for slow clocks, which I don't remember, and no luck.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;External power and no luck again.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;What am I missing? Do I need to change something to communicate with Arduino Pro running at 1MHz?&lt;/p&gt;&#xA;" OwnerUserId="23953" LastEditorUserId="4628" LastEditDate="2017-01-16T11:02:25.367" LastActivityDate="2017-01-16T11:02:25.367" Title="Yikes! Invalid device signature. Fail to burn bootloader and read fuses" Tags="|bootloader|arduino-pro-mini|arduinoisp|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26522" PostTypeId="2" ParentId="26521" CreationDate="2016-07-19T22:53:45.687" Score="1" Body="&lt;p&gt;If you are burning the bootloader through the IDE it won't expect the CKDIV8 fuse to be set.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&quot; rel=&quot;nofollow noreferrer&quot;&gt;bootloader programmer&lt;/a&gt; which you could use to reprogram the bootloader. You just need another Arduino (eg. Uno, Mega) and connect 6 wires between each of them like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NUmcF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NUmcF.jpg&quot; alt=&quot;Program bootloader&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch for programming the bootloader is available on Github:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/nickgammon/arduino_sketches&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/nickgammon/arduino_sketches&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want the one in the &quot;Atmega_Board_Programmer&quot; subdirectory.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-19T22:53:45.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26523" PostTypeId="1" AcceptedAnswerId="26524" CreationDate="2016-07-19T23:37:44.533" Score="0" ViewCount="942" Body="&lt;p&gt;I am using a flame sensor. I am reading the state and then printing it. Here is my code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA; flameState = digitalRead(flamePin);//variables already defined and are global&#xA;existsFire();//calls the void&#xA;delay(1000);&#xA;}&#xA;&#xA;void existsFire(){&#xA;&#xA;Serial.println(&quot;Flame: &quot; + flameState);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Before, this printed out the right thing. Today, it was printing out &quot;lame:&quot;. The &quot;F&quot; and the flameState were missing. I changed it to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void existsFire(){&#xA;&#xA;Serial.print(&quot;Flame: &quot;);&#xA;Serial.println(flameState);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything worked fine. Is there a problem with my Arduino Mega. What do I need to do to fix this?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-07-20T12:43:18.750" Title="Why does Serial.print print out the wrong thing?" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26524" PostTypeId="2" ParentId="26523" CreationDate="2016-07-19T23:53:04.097" Score="5" Body="&lt;p&gt;You've stumbled across the difference in the C++ language between a &lt;code&gt;String&lt;/code&gt; and an &quot;array of characters&quot;. What you gave &lt;code&gt;Serial.println()&lt;/code&gt; was an array of characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Flame: &quot;...);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then tried to add a number to it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;Flame: &quot; + flameState);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If it had have been a &lt;code&gt;String&lt;/code&gt;, then what you typed would have been fine:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String flame = &quot;Flame: &quot;;&#xA;Serial.println(flame + flameState);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding (literally &lt;code&gt;+&lt;/code&gt;) a number to a &lt;code&gt;String&lt;/code&gt; adds characters to the &lt;code&gt;String&lt;/code&gt; to represent the number. Unfortunately you didn't start with a &lt;code&gt;String&lt;/code&gt;, you started with an array of characters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;Flame: &quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Adding a number to THAT changes where the array starts. &lt;code&gt;flameState&lt;/code&gt; must have been &lt;code&gt;1&lt;/code&gt;, and &lt;code&gt;&quot;Flame: &quot; + 1&lt;/code&gt; would have been &lt;code&gt;&quot;lame :&quot;&lt;/code&gt; - as you found out!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The version that worked did so through a little bit of magic:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Flame: &quot;);&#xA;Serial.println(flameState);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first line called a version of &lt;code&gt;print()&lt;/code&gt; that accepted an array of characters and printed each of them out. The second line called a &lt;em&gt;different&lt;/em&gt; version of &lt;code&gt;println()&lt;/code&gt; that accepted a number and printed out its representation as a series of characters (digits) - followed by a new line (the &lt;code&gt;ln&lt;/code&gt; part of the name).&lt;/p&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-07-20T12:43:18.750" LastActivityDate="2016-07-20T12:43:18.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26525" PostTypeId="1" CreationDate="2016-07-19T23:58:41.113" Score="6" ViewCount="1016" Body="&lt;p&gt;Is there a chip that is just a parallel in / serial out shift register but with integrated internal pullups?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could use a full-blown I/O expander but I really just need more momentary button inputs. I don't need outputs and I would rather not bother adding resistors or with writing commands to initialize the chip.&lt;/p&gt;&#xA;" OwnerUserId="20626" LastActivityDate="2016-07-20T12:25:24.493" Title="Shift Register w/ Internal Pullups?" Tags="|pull-up|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26526" PostTypeId="2" ParentId="16301" CreationDate="2016-07-20T00:28:09.487" Score="3" Body="&lt;p&gt;A more sophisticated version of @MikaelPatel's techique is not to store the individual counts, but to store a derivative:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Reserve a block of storage with (say) 8 counters. Each counter has as many bits as necessary to store the largest value - but see below for what &quot;largest&quot; means.&lt;/li&gt;&#xA;&lt;li&gt;Each time the count goes up, write into the next counter along (modulo the number of counters).&lt;/li&gt;&#xA;&lt;li&gt;But don't write the value of the counter, write the value divided by the number of counters - &lt;code&gt;counter/8&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Here's the trick: while that looks like you're losing precision, you're not - because the counter location is information too! In fact you're &lt;em&gt;gaining&lt;/em&gt; size.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;It's best shown with an example. For ease, I'll assume an 8-bit counter, and only 8 counters:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0000: 03 03 03 03 03 02 02 02&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Assuming that everything started at &lt;code&gt;00&lt;/code&gt;, that means that it took 8 counts for them all to get to &lt;code&gt;01&lt;/code&gt;, a further 8 counts for them all to get to &lt;code&gt;02&lt;/code&gt;, and only 5 counts to get the first 5 to &lt;code&gt;03&lt;/code&gt;. That's a total of &lt;code&gt;8+8+5&lt;/code&gt; or &lt;code&gt;21&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At boot time, look for where the number sequence goes down. That's your current buffer position for future updates, plus the information for the current value:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CurrentCount = [Smaller number] * [Number counters] + [Number of larger];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Once you've worked it out, keep the current value for incrementing, and the buffer pointer for where to store the next count.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Advantages:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A. You write as often as you would storing a counter - but in different locations, spreading the load.&lt;br&gt;&#xA;B. Each location (8, 16 or 32 bits) can store a certain maximum - but the total maximum is a factor of &lt;code&gt;Number of Counters&lt;/code&gt; larger than that!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Odometer manufacturers use this exact technique to store the current mileage in digital dashboards - they have a legal requirement to maintain the correct number. They only use 16-bit counters (which would overflow after 65,535 miles), but then they use 16 counters, for a total mileage maximum of over a million. Each location only gets written every 16 miles, and they don't need to use 32-bit locations.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-20T00:28:09.487" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26528" PostTypeId="2" ParentId="23246" CreationDate="2016-07-20T02:23:15.507" Score="3" Body="&lt;p&gt;This seems to be the Chip used on the RFM24. Have a look on the RadioHead Library:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html&quot; rel=&quot;nofollow&quot;&gt;http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I normally use the same libs for the RFM69 (Semtech SX1231) with my &lt;a href=&quot;https://talk2.wisen.com.au/product-talk2-whisper-node-avr/&quot; rel=&quot;nofollow&quot;&gt;Whisper Node&lt;/a&gt; and works fine. I would expect the same for the RFM24.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw, getting a silicon and building the Radio can be quite complicated. You might would consider starting with a Dev Kit or an assembled module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I don't think HopeRF produces RFM24 anymore, can't find on their site (&lt;a href=&quot;http://www.hoperf.com/rf_transceiver/&quot; rel=&quot;nofollow&quot;&gt;http://www.hoperf.com/rf_transceiver/&lt;/a&gt;). If you just need it for a single project and does not intent to build a product of that, might be better chose a different/more popular option. Will be easier to find support for it on the Internet.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastEditorUserId="16417" LastEditDate="2016-07-20T02:38:34.680" LastActivityDate="2016-07-20T02:38:34.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26529" PostTypeId="2" ParentId="26525" CreationDate="2016-07-20T02:23:41.103" Score="3" Body="&lt;p&gt;Logic integrated circuits such as shift registers normally do not contain pull up resistors on their input(s).  This is because they are normally connected to a &lt;a href=&quot;https://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic#TTL_with_a_.22totem-pole.22_output_stage&quot; rel=&quot;nofollow&quot;&gt;totem pole&lt;/a&gt; driver.  Such a driver eliminates the need to avoid floating inputs.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, pull up resistors require current when the input is driven toward the opposite power rail.  Even though adding internal pull up resistors may not change the overall behavior of the chip, designers will avoid parts if they unnecessarily add to the over all power demand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on your comments and your question, consider an old ps/2 keyboard. It is essentially a switch matrix with a built in decoder chip which may fullfill your requirements. The chip scans the switch matrix, debounces the switches and converts button presses &amp;amp; button releases into a serial stream of data. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Added later...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/PS2Keyboard&quot; rel=&quot;nofollow&quot;&gt;Here&lt;/a&gt; is a description about connecting a ps/2 keyboard to an Arduino.  Included are schematics, code examples and supporting library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(USB keyboards are not well suited for this purpose as they require a USB Host.  As most Arduinos do not have this, a USB Host shield is required.)&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-20T12:25:24.493" LastActivityDate="2016-07-20T12:25:24.493" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26530" PostTypeId="1" CreationDate="2016-07-20T08:39:25.243" Score="0" ViewCount="371" Body="&lt;p&gt;I am working on an Arduino application that logs sensors values into SD files. It is essential that the SD is inserted and working when a test is started, thus I need to check the presence of the SD regularly (every 2 seconds or so) to prevent launching a test without SD inserted by the user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I run the following code, it runs very fast when the SD test succeeds (&amp;lt;10ms), but it takes more than 2000ms when the test fails. Is there another test I could run that does not takes 2 seconds to indicate that the SD is not inserted (or not working)? All my buttons are frozen and they do not trigger any action while checking if no SD is inserted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code (both loops have the same issue):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define csSD   53&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;Sd2Card card;&#xA;&#xA;void setup() {&#xA;  Serial.begin(57600);&#xA;  bool SDOK = SD.begin(csSD);&#xA;  if(SDOK) {&#xA;    Serial.println(&quot;SD.Begin Setup OK&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;SD.Begin Setup Fail&quot;);&#xA;  }&#xA;}&#xA;&#xA;unsigned long t;&#xA;//void loop() {&#xA;//  t=millis();&#xA;//  if(SD.begin(csSD)){ // SD.Begin test runs fast when there is a SD, even though it return true when you try to begin SD a second time&#xA;//    Serial.print(&quot;SD.Begin loop OK : &quot;);&#xA;//  }else {&#xA;//    Serial.print(&quot;SD.Begin loop Fail : &quot;);&#xA;//  }&#xA;//  Serial.println(String(millis()-t)+&quot;ms&quot;);&#xA;//  delay(500);&#xA;//}&#xA;&#xA;void loop() {&#xA;  t=millis();&#xA;  if(card.init(SPI_HALF_SPEED, csSD)) {&#xA;    // card.init test returns true as it should (when SD is present and working), but runs fast only when SD is working&#xA;    Serial.print(&quot;card.init loop OK : &quot;);&#xA;  } else {&#xA;    Serial.print(&quot;SD.Begin loop Fail : &quot;);&#xA;  }&#xA;  Serial.println(String(millis()-t)+&quot;ms&quot;);&#xA;  delay(500);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23827" LastEditorUserId="4628" LastEditDate="2017-12-13T15:59:07.983" LastActivityDate="2018-04-12T18:57:05.757" Title="SD test is taking long answer when it fails" Tags="|arduino-mega|sd-card|testing|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26532" PostTypeId="1" AcceptedAnswerId="26534" CreationDate="2016-07-20T08:47:23.043" Score="0" ViewCount="5545" Body="&lt;p&gt;It is necessary to recognize the motion and record video live.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;br&gt;&#xA;Save enough on your memory card.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;PS&lt;/strong&gt;&lt;br&gt;&#xA;Maybe I'll repeat the question, but I am not guided in English.&lt;br&gt;&#xA;Sorry for my English&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10291" LastEditorUserId="4628" LastEditDate="2017-04-15T05:06:01.177" LastActivityDate="2017-04-15T05:06:01.177" Title="Is it possible to use a USB camera with Arduino?" Tags="|arduino-uno|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26533" PostTypeId="2" ParentId="26530" CreationDate="2016-07-20T08:52:53.793" Score="0" Body="&lt;p&gt;You could always try this very simple sketch. I have never measured how quick it runs, but it is pretty quick. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.print(&quot;Initializing SD card...&quot;);&#xA;&#xA;  if (!SD.begin(4)) {&#xA;    Serial.println(&quot;initialization failed!&quot;);&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;initialization done.&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Just make sure to change 4 in &lt;code&gt;!SD.begin(4)&lt;/code&gt; to whatever your ChipSelect pin happens to be for your component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Furthermore, you could add a &lt;code&gt;return&lt;/code&gt; statement after your &quot;initilization fails&quot; loop because that will immediately stop the program, after all you do not want to run it if the SD card is not reading data! And last thing, it may be a little overkill to check the SD card after initial initilization, after all, it will be highly unlikely for an error to occur once everything is working fine unless you mess with the SD card alot while it is running, which I am sure you won't.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-07-20T08:52:53.793" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26534" PostTypeId="2" ParentId="26532" CreationDate="2016-07-20T09:07:33.440" Score="1" Body="&lt;p&gt;An Arduino is not a powerful processor and can not do much image processing.  I doubt that there is a USB camera that could be connected to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are a range of OVO cameras that can connect to the Arduino, but I don't think you will be able to record live video on an Arduino with these, where would you store the file for starters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a PIXY camera system, this has its own microprocessor and interfaces with an Arduino.  It can record video and do object recognition.&#xA;&lt;a href=&quot;http://charmedlabs.com/default/pixy-cmucam5/&quot; rel=&quot;nofollow&quot;&gt;http://charmedlabs.com/default/pixy-cmucam5/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-20T09:07:33.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26535" PostTypeId="2" ParentId="26489" CreationDate="2016-07-20T09:40:31.890" Score="1" Body="&lt;p&gt;If you want to load multiple RTC libraries I guess you are connecting to multiple RTCs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If they use the same interface to communicate, i.e. I2C there is a possibility you will initialise the bus multiple times.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should be OK with the functions not clashing, because they are within classes, but its possible some of the referenced structures/ classes my clash.  You &lt;em&gt;might&lt;/em&gt; be able to resolve this by namespacing the libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An alternative might be to write your own library that handles all of the RTCs that you are interested in.  This will force you to consider what each RTC requires and identify problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;At the end of the day I agree with what Gerben is saying.  Don't do it unless you really have to.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-20T09:40:31.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26538" PostTypeId="1" CreationDate="2016-07-20T10:39:28.523" Score="2" ViewCount="257" Body="&lt;p&gt;I am doing my final year project and here I am attaching the code I am using. According to the code, I will get the sensor output in serial monitor. But I want to get reading once n 10ms. Since serial monitor can't work with that resolution, I need to save the reading in an array and then output the array in serial monitor or any other way. Please help me in modifying the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* &#xA;   The circuit:&#xA;  * VCC connection of the sensor attached to +5V&#xA;  * GND connection of the sensor attached to ground&#xA;  * TRIG connection of the sensor attached to digital pin 2&#xA;  * ECHO connection of the sensor attached to digital pin 4&#xA; */&#xA;&#xA;const int trigPin = 2;&#xA;const int echoPin = 4;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  pinMode(trigPin, OUTPUT);&#xA;  pinMode(echoPin, INPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  long duration, cm;&#xA;&#xA;  pinMode(trigPin, OUTPUT);&#xA;  digitalWrite(trigPin, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trigPin, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trigPin, LOW);&#xA;&#xA;  pinMode(echoPin, INPUT);&#xA;  duration = pulseIn(echoPin, HIGH);&#xA;&#xA;  cm = microsecondsToCentimeters(duration);&#xA;&#xA;  Serial.print(cm);&#xA;  Serial.print(&quot;cm&quot;);&#xA;  Serial.println();&#xA;&#xA;  delay(100);&#xA;}&#xA;&#xA;long microsecondsToCentimeters(long microseconds)&#xA;{&#xA;  return microseconds / 29 / 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24053" LastEditorUserId="7508" LastEditDate="2016-07-20T10:50:56.787" LastActivityDate="2016-07-20T14:06:37.127" Title="How to get readings on serial monitor in every 10s?" Tags="|arduino-mega|sensors|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26539" PostTypeId="2" ParentId="26538" CreationDate="2016-07-20T11:19:27.863" Score="0" Body="&lt;p&gt;Yeah it shouldn't be an issue, remember &lt;code&gt;delay(time&lt;/code&gt;) is a millisecond command, so if you want to get a reading every 10ms, simply put &lt;code&gt;delay(10)&lt;/code&gt;, and &lt;strong&gt;not&lt;/strong&gt; &lt;code&gt;delay(100)&lt;/code&gt;. Like the comment above mentions, you should have no problem with a 9600 baud rate serial monitor link showing data every 10ms.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I would highly reccomend checking out the NewPing library (&lt;a href=&quot;https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home&quot; rel=&quot;nofollow&quot;&gt;https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home&lt;/a&gt;)&#xA;which is an update library for the ultrasonic distance sensor which I assume you are using based off your code. With that, you can send up to 30 &quot;pings&quot; per second, so if the above solution doesn't fix it for you, this definitely should.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="21627" LastEditDate="2016-07-20T11:26:11.260" LastActivityDate="2016-07-20T11:26:11.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26541" PostTypeId="2" ParentId="13462" CreationDate="2016-07-20T11:43:44.030" Score="4" Body="&lt;p&gt;MQTT Library for SIM800 GSM Modem is available at &lt;a href=&quot;https://elementztechblog.wordpress.com/2016/07/18/arduino-mqtt-library-for-sim800-gsm-modem/&quot; rel=&quot;nofollow noreferrer&quot;&gt;ElementzTechBlog&lt;/a&gt;, &lt;a href=&quot;https://github.com/elementzonline/SIM800_MQTT&quot; rel=&quot;nofollow noreferrer&quot;&gt;ElementzGithubRepository&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Functionalities:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Auto connect&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   Automatically connect to TCP and to MQTT server.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;connect function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This function can be used to connect your client to MQTT broker.&#xA;   Use only if you do not use Auto connect functionality.&#xA;   Optionally  you can use username, password, WILL topic and WILL Message.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;OnConnect CallBack function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This call back function is called when MQTT connection is established.&#xA;   You can call subscription and publish functions inside it (according to your need).&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;publish function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This function can be used to publish messages to different topics.&#xA;   You can select  QoS levels and RETAIN flag according to your need.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;subscribe function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This function can be used to subscribe messages from different topics.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;OnMessage CallBack function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This callback function is called when messages are received from  subscribed topics&#xA;   Topic, TopicLength, Message, MessageLength are the arguments of  OnMessage callback function.&#xA;   Inside this, you can write your custom code.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;unsubscribe function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This function can be used to unsubscribe from a previously subscribed topic.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;disconnect function&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   This function can be used to disconnect your client from MQTT broker.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Keep Alive&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   You can specify your KeepAlive duration while initializing.&#xA;   Ping requests are sent and received automatically.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Nowadays the easiest solution is to use SIM7600 4G/3G/2G modem. It supports MQTT using AT commands !. For more details the following link can be useful to get started.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.elementzonline.com/blog/using-mqtt-at-commands-with-sim7600-and-arduino-for-gsm-iot-projects&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.elementzonline.com/blog/using-mqtt-at-commands-with-sim7600-and-arduino-for-gsm-iot-projects&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24055" LastEditorUserId="24055" LastEditDate="2021-03-20T19:56:28.100" LastActivityDate="2021-03-20T19:56:28.100" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="26544" PostTypeId="2" ParentId="26505" CreationDate="2016-07-20T13:05:45.033" Score="1" Body="&lt;p&gt;They are Mac's OS X &quot;Spotlight&quot; hidden indexing files.  &lt;a href=&quot;https://apple.stackexchange.com/questions/6707&quot;&gt;This answer&lt;/a&gt; shows how to turn it off.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="-1" LastEditDate="2017-04-13T12:45:32.257" LastActivityDate="2016-07-20T13:05:45.033" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26546" PostTypeId="2" ParentId="26538" CreationDate="2016-07-20T14:06:37.127" Score="2" Body="&lt;p&gt;There is one fundamental error with your code that I feel I should point out - one that I see time and time again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic structure of your code is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Forever:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Send a ping&lt;/li&gt;&#xA;&lt;li&gt;Wait for the pong&lt;/li&gt;&#xA;&lt;li&gt;Print the result&lt;/li&gt;&#xA;&lt;li&gt;Delay for 100ms (or whatever time you choose)&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And you expect to get a result every (delay) milliseconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, you won't.  What you will actually get is a result &lt;em&gt;every so often&lt;/em&gt;, where that time is defined as 100ms + the time to send and receive a ping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if it takes 11.6ms (200cm, the limit of most pin sensors) to receive the pong, then you also delay for 100ms, you're going to end up with 111.6ms between each print. It's even worse if the pong never arrives back - then &lt;code&gt;pulseIn()&lt;/code&gt; will wait for up to a second before returning. You can, of course, reduce that to say 15ms by adding the timeout parameter as per &lt;a href=&quot;https://www.arduino.cc/en/Reference/PulseIn&quot; rel=&quot;nofollow&quot;&gt;the manual&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you reduce your printing delay to just 10ms you actually run the risk of delaying for more than double the time you expect to (21.6ms instead of 10ms).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you need to use &lt;code&gt;millis()&lt;/code&gt; to check to see &lt;em&gt;if it is time to print something&lt;/em&gt; so that it doesn't matter how long the pong took to arrive, as long as that never exceeds the amount of time you want between prints, otherwise it's going to get delayed regardless.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-20T14:06:37.127" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26547" PostTypeId="1" CreationDate="2016-07-20T14:18:02.377" Score="0" ViewCount="181" Body="&lt;p&gt;I am using an Arduino Mega to control the speed of an internal combustion engine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The speed is sensed via a Variable Reluctance Sensor (VRS) on the crankshaft. This signal is then converted into a 5V square wave which is feed into Interupt 2 (Pin 21) on the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The flywheel of the engine, onto which the VRS is sensing has one tooth. Therefore one square wave blip (from 5v to 0V) as it is passing it and then back up to 5v. The interupt that this is attached to increases a counter by 1. The time taken for the counter to reach 20 is recorded. I want to use this speed reading value in a PID algorithm which then in turn actuates a servo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This methodology was sucessfully used in a very similar engine with a 22 toothed flywheel but is not working on this engine with 1 tooth. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is the speed reading - the values that I am recording for the time taken for 20 revs ( in micro seconds), and displayed on the serial terminal is wrong and I do not know why. The numbers printed are all mulitples of one another e.g. 440960,551200,661440,771680 which all divide into one another with an even fraction. The correct reading here is 661440, this has been verified with observation of the square wave input through and oscilloscope. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I cannot find why!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have attached the code &lt;a href=&quot;https://gist.github.com/gawnieg/c4d290e8b0b4f5f2bbfc39ae6087e768&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10938" LastActivityDate="2016-08-19T17:13:49.967" Title="Engine Speed Control Observation" Tags="|arduino-mega|sensors|isr|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26548" PostTypeId="2" ParentId="26547" CreationDate="2016-07-20T16:19:52.113" Score="1" Body="&lt;p&gt;Your methodology there is somewhat flawed. Not only will you never see that Counter1 &gt;= 20 (since you immediately set it to 0 before returning the count), but if you never get a pulse (engine is stalled) you'll never reach 20 pulses anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A better method is to reverse everything and instead of timing how long it takes to get 20 pulses, count the number of pulses you get in a pre-defined time period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your interrupt remains the same, counting each pulse as it arrives, but you then sit and watch the clock (using &lt;code&gt;millis()&lt;/code&gt;) and when a certain (to be decided by you) time has elapsed (the &lt;em&gt;sample time&lt;/em&gt;) you record the pulse count and reset it to 0. You then have a number of rotations per time period.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you set that time period to be 1 second (the simplest) then you immediately have the number of rotations per second.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    static uint32_t ts = millis();&#xA;    uint32_t pulses;&#xA;&#xA;    if (millis() - ts &amp;gt;= 1000) {&#xA;        ts += 1000;&#xA;        uint8_t sr = SREG;&#xA;        noInterrupts();&#xA;        pulses = Counter1;&#xA;        Counter1 = 0;&#xA;        SREG = sr;&#xA;        Serial.print(pulses);&#xA;        Serial.println(&quot; revolutions per second&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Decreasing the sample time means you can respond faster, but you are working with smaller numbers and hence less accuracy. For instance, setting it to 100ms instead of 1 second you need to multiply your count by 10 to get the current pulses per second. It all depends on how fast your engine runs as to what a good sample time would be.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-20T16:19:52.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26549" PostTypeId="2" ParentId="12676" CreationDate="2016-07-20T17:56:51.977" Score="1" Body="&lt;p&gt;Arduino MQTT Library for SIM800 (and SIM900) GSM Modem is available at &lt;a href=&quot;https://elementztechblog.wordpress.com/2016/07/18/arduino-mqtt-library-for-sim800-gsm-modem/&quot; rel=&quot;nofollow&quot;&gt;ElementzTechBlog&lt;/a&gt;, &lt;a href=&quot;https://github.com/elementzonline/SIM800_MQTT&quot; rel=&quot;nofollow&quot;&gt;ElementzGithubRepository&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Functionalities:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Auto connect&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Automatically connect to TCP and to MQTT server.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;connect function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This function can be used to connect your client to MQTT broker.&lt;/li&gt;&#xA;&lt;li&gt;Use only if you do not use Auto connect functionality.&lt;/li&gt;&#xA;&lt;li&gt;Optionally  you can use username, password, WILL topic and WILL&#xA;Message.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OnConnect CallBack function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This call back function is called when MQTT connection is&#xA;established.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You can call subscription and publish functions inside it (according to your need).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;publish function&lt;/strong&gt;&#xA; - This function can be used to publish messages to different topics.   &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You can select  QoS levels and RETAIN flag according to your need.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;subscribe function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This function can be used to subscribe messages from different&#xA;topics.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OnMessage CallBack function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;This callback function is called when messages are received from &#xA;subscribed topics&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Topic, TopicLength, Message, MessageLength are the arguments of &#xA;OnMessage callback function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Inside this, you can write your custom code.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;unsubscribe function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This function can be used to unsubscribe from a previously subscribed&#xA;topic.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;disconnect function&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This function can be used to disconnect your client from MQTT broker.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Keep Alive&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;You can specify your KeepAlive duration while initializing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Ping requests are sent and received automatically.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Subscribe Publish examples are also provided.&lt;/strong&gt;&lt;/p&gt;&#xA;" OwnerUserId="24064" LastEditorUserId="24064" LastEditDate="2016-07-30T08:30:07.810" LastActivityDate="2016-07-30T08:30:07.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26550" PostTypeId="1" CreationDate="2016-07-20T17:46:52.450" Score="0" ViewCount="158" Body="&lt;p&gt;I have 2 nodes: one is a PC+arduino mega+xbee the other one is arduino micro+xbee.&#xA;The 2 xbees are communicating fine, I have tested this with 2 separate arduinos.&#xA;My problem is that when the second xbee hooked up to the micro it seems it does not try to send or receive data from the serial lines.&#xA;It is connected to the first RX/TX pins in proper order (RX-&gt;Tx, Tx-&gt;Rx) on the micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is obvious for me because if I start my program's setup section on the ardu with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() &#xA;&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The whole main program won't be running because the serial just never gets ready only if I plug my PC in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to send data from the PC-&gt;micro through xbee I see the Xbee receives it (led goes on the board) but nothing happens on the micro.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The micro right now is set to periodically send some debug data through the serial, I don't get that back either otherwise I would see the serial TX led on the micro blinking that it is sending the data. It only works when the PC is connected through USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need some additional code for the xbee or is it require a hardware modification? I use a 5V-3V ttl converter as an extra hardware.&lt;/p&gt;&#xA;" OwnerDisplayName="reaverx" LastActivityDate="2016-07-21T14:28:38.777" Title="Xbee not activate on arduino micro" Tags="|wireless|xbee|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26551" PostTypeId="2" ParentId="9030" CreationDate="2016-07-20T19:57:07.780" Score="1" Body="&lt;p&gt;Here there are GROVE connectors in SMD and a drawing is included: &lt;a href=&quot;http://www.ebay.de/itm/Grove-SMD-Universal-4-pin-connector-10-Stuck-/152174510967?hash=item236e4ec377:g:ItwAAOSwWfFXj1jf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Grove - SMD Universal 4 pin connector (10 Stück)&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/yBS9v.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/yBS9v.jpg&quot; alt=&quot;Three pin connector diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24067" LastEditorUserId="6936" LastEditDate="2016-11-16T10:52:18.393" LastActivityDate="2016-11-16T10:52:18.393" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26552" PostTypeId="1" CreationDate="2016-07-19T09:24:57.470" Score="0" ViewCount="3595" Body="&lt;p&gt;A week ago I started messing with LoRa. I got my &lt;a href=&quot;http://www.wireless-solutions.de/products/starterkits/sk-im880a.html&quot; rel=&quot;nofollow&quot;&gt;STM32L151 IM880A kit&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Company that provided SX1272 LoRa modem chip (used in kit), provided some libraries, but lots of functionalities are still not implemented and is still not suitable for use in multi P2P aplications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After googling I came across Libelium company which used SX1272 chip in their products design and they provided useful set of &lt;a href=&quot;https://github.com/Libelium/waspmoteapi/tree/master/libraries/SX1272&quot; rel=&quot;nofollow&quot;&gt;libraries&lt;/a&gt; that provides lots of functionalities and also implements some sort of LoRa frame protocol stack ideal for use in P2P applications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I'm using STM32 in my project and Libelium libraries are written for Arduino. So I was wondering if there is a smart way to port Arduino libraries so I could use them in my STM32 Keil projects, since the libraries seems huge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tips, hints, links would be appreciated (I don't have experience in using Arduino and I'm not familiar with Arduino library structure).&lt;/p&gt;&#xA;" OwnerUserId="24025" OwnerDisplayName="Ivan47" LastEditorUserId="27346" LastEditDate="2018-10-12T21:26:20.040" LastActivityDate="2018-10-12T21:26:20.040" Title="Using Arduino libraries with ARM based microcontroller" Tags="|library|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26553" PostTypeId="2" ParentId="26552" CreationDate="2016-07-19T11:14:50.080" Score="1" Body="&lt;p&gt;Every time I work on a project I use arduino libraries and port them to my micro controller.&#xA;I used &lt;a href=&quot;https://www.sublimetext.com/&quot; rel=&quot;nofollow&quot; title=&quot;sublime&quot;&gt;sublime&lt;/a&gt; text editor with multiple selection and editing(ctrl-d). Then I copy the arduino code to both sublime and my uC IDE then compile it in the IDE, scroll up to the first undefined function and add its definition to the code or modify it using sublime multiple editing and selecting (like digital read and write was in my opinion useless). After that update the file in your IDE and compile again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would do that till you have finished and it would take some time.&lt;/p&gt;&#xA;" OwnerUserId="24101" OwnerDisplayName="Catch.Me" LastActivityDate="2016-07-19T11:14:50.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26554" PostTypeId="1" CreationDate="2016-07-20T21:05:35.050" Score="0" ViewCount="206" Body="&lt;p&gt;I am a bit confused about how memory works in Arduino.  I have created an integer array like so:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int* arr = new int[3] {1, 2, 3};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I go to delete it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;delete[] arr;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The first element is deleted, and all the remaining ones are still  present and accessible.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Serial.println(arr[0]); // prints 0&#xA;Serial.println(arr[1]); // prints 2&#xA;Serial.println(arr[2]); // prints 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24069" LastActivityDate="2016-08-19T22:15:29.133" Title="Array deletion problem" Tags="|memory-usage|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26555" PostTypeId="2" ParentId="26510" CreationDate="2016-07-20T21:24:51.893" Score="1" Body="&lt;p&gt;I've used following code and loopback from pin 8 to pin 7:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// loopback:  pin 8 -&amp;gt; pin 7&#xA;&#xA;void setup() {&#xA;  pinMode(7, INPUT_PULLUP);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(LED_BUILTIN_TX, OUTPUT); // to see pin 8 logic level on TX led&#xA;  pinMode(LED_BUILTIN, OUTPUT); // toggled by ISR&#xA;&#xA;  EICRB |= _BV(ISC60);  // Triggers on edge&#xA;  EIMSK |= _BV(INT6);   // activates the interrupt&#xA;}&#xA;&#xA;ISR(INT6_vect) {&#xA;  PINC = _BV(PC7);  // toggle led 13 (@ PC7)&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(8, HIGH);&#xA;  digitalWrite(LED_BUILTIN_TX, HIGH);&#xA;&#xA;  delay(500);&#xA;  digitalWrite(8, LOW);&#xA;  digitalWrite(LED_BUILTIN_TX, LOW);&#xA;  delay(500);&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And it works perfectly. Only problem I can imagine is to figure out correctly which pin is really 7 as label is on the right side of pin (not under nor left).&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-20T21:24:51.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26556" PostTypeId="2" ParentId="26554" CreationDate="2016-07-20T21:47:07.590" Score="0" Body="&lt;p&gt;It is not a good idea to use dynamic memory in such a small devices in general.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And delete doesn't mean setting values to something at all. It's just returning allocated memory back (&quot;to system&quot; is not correct term here as there is no system).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should try to use objects with some action in constructor and destructor (like printing values).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class test {&#xA;public:&#xA;  test(int _i):i{_i} { Serial.print(&quot;test:&quot;); Serial.println(i); } &#xA;  ~test() { Serial.print(&quot;~test:&quot;); Serial.println(i); } &#xA;  int i;&#xA;};&#xA;&#xA;void setup() {&#xA;  Serial.begin(57600);&#xA;  test * arr = new test[3] {4,6,9};&#xA;  delete[] arr;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;test:4&#xA;test:6&#xA;test:9&#xA;~test:9&#xA;~test:6&#xA;~test:4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-07-20T21:56:20.013" LastActivityDate="2016-07-20T21:56:20.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26557" PostTypeId="2" ParentId="26554" CreationDate="2016-07-20T21:48:21.823" Score="1" Body="&lt;p&gt;First of all: it is not a good idea to do dynamic memory maagement in embedded systems (in casu arduino)&lt;br&gt;&#xA;Secondly freeing memory means: marking the memory as available. It does not mean &quot;setting the memory to 0&quot;&lt;br&gt;&#xA;because &lt;code&gt;ar&lt;/code&gt; still points to the same locaton in memory it is &quot;normal&quot; that it also still reads the old values. Only -according to the C CP0P0 pàrogramming rules- you should not do so. Reading will not cause problems but writing will very likely.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-07-20T21:48:21.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26558" PostTypeId="2" ParentId="26554" CreationDate="2016-07-20T21:58:22.153" Score="0" Body="&lt;p&gt;Deleting &lt;code&gt;new&lt;/code&gt;ed memory only informs the system that you are no longer using it and releasing it for re-assignment. The pointer still points to memory containing your array but that memory is no longer reserved for you. You could, in theory, go on using it, but another &lt;code&gt;new&lt;/code&gt; might well reassign it for another use and the data that was in it would likely get over-written. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be good form to zero your pointer (&lt;code&gt;arr = (int *)0;&lt;/code&gt;). It accomplishes several things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Your code clearly reminds you that the pointer is no longer usable;&lt;/li&gt;&#xA;&lt;li&gt;Your code clearly informs the next reader that the pointer is no longer usable;&lt;/li&gt;&#xA;&lt;li&gt;An attempt to use the pointer is quite likely to fail immediately (depends on the envrionment's ability to trap attempted accesses to location 0). The alternative is your code may work anyway - until someday that memory actually &lt;em&gt;does&lt;/em&gt; get re-assigned and suddenly, code that has worked &quot;forever&quot;, breaks, and in a non-obvious way. Save yourself or the guy or gal who follows you some grief, and make it a habit to zero your pointers once they are no longer valid.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-20T22:11:46.013" LastActivityDate="2016-07-20T22:11:46.013" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26559" PostTypeId="1" AcceptedAnswerId="26565" CreationDate="2016-07-20T23:28:42.030" Score="2" ViewCount="284" Body="&lt;p&gt;I started a new motor related project recently with a new Arduino Uno, beginning with several tutorial circuits included in the Vilros Arduino guide. The circuit in question is #10, a simple DC motor circuit with a transistor switch (&lt;a href=&quot;https://i.stack.imgur.com/KLC0K.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/KLC0K.jpg&lt;/a&gt;). The Arduino is being powered for the moment via USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The circuit, completed according to the diagram/common sense, does not work. The voltage across the transistor base is clearly not sufficient to activate the switch with the motor in the circuit. 5V (more like 4.6V) from Pin 13 is running across a 330 ohm resistor to the transistor base, but there is no current between the collector and the base. Bypassing the collector/base gap with a piece of metal will complete the circuit and activate the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For some reason, the transistor &lt;em&gt;will&lt;/em&gt; switch properly when the motor is replaced by a simple LED. &lt;em&gt;AND&lt;/em&gt;, switching the cable from Pin 13 to the +5V out is enough to activate the transistor switch. I was under the impression that the transistor should only require .7V above the common grounded element.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, even more bizarrely, with a cable running from +5V to the transistor base (through a resistor), a voltmeter across the DC motor is reading a potential difference of anywhere from 9V to 1702V (see &lt;a href=&quot;https://i.stack.imgur.com/mwFKp.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/mwFKp.jpg&lt;/a&gt;, yes, with 4 digits). The multimeter is otherwise working normally, so I don't see a good explanation. Is the Arduino pin just incapable of providing sufficient current/voltage to activate the transistor, or am I missing something obvious. And does anyone have some idea why the voltmeter is reading so high and fluctuating so wildly? It is curious that the Arduino disconnects from the PC whenever the circuit is completed with the motor in it, so the Arduino likely is overdrawing from the USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transistor included was not the one listed, but a common MPS2222A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerUserId="24072" LastEditorUserId="24072" LastEditDate="2016-07-20T23:37:16.230" LastActivityDate="2016-07-22T20:17:00.697" Title="Bizarre transistor behavior and voltage with DC motor in simple circuit" Tags="|arduino-uno|motor|transistor|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26560" PostTypeId="1" CreationDate="2016-07-21T01:30:08.640" Score="0" ViewCount="115" Body="&lt;p&gt;Im trying to shift LEDs using 595 register. Using SN74HC595N registers. Im using 4 of the registers as i got alots of LEDs to shift. My code for shifting doesn't seem working.. i can shift some with 2 registers but not 4 registers  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;RTClib.h&quot;&#xA;&#xA;RTC_DS1307 RTC;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;// RS-12, E-13, D4-8, D5-9, D6-10, D7-11&#xA;LiquidCrystal lcd(12, 13, 8, 9, 10, 11);&#xA;&#xA;int row[]={8,9,10,11};// Digital output connect directly to all rows&#xA;int col[] = {A0,A1,A2}; // Analog input with 10K pull-up to 5V.&#xA;int i,j; // Two counter variables to count inside for loop&#xA;int col_scan; // Variable to hold value of scanned columns&#xA;&#xA;//Pin connected to ST_CP of 74HC595&#xA;int latchPin = 3;&#xA;//Pin connected to SH_CP of 74HC595&#xA;int clockPin = 4;&#xA;////Pin connected to DS of 74HC595&#xA;int dataPin = 5;&#xA;&#xA;//holder for infromation you're going to pass to shifting function&#xA;byte data = 0; &#xA;byte data1 = 0x55;&#xA;byte data2 = 0xAA;&#xA;&#xA;&#xA;void setup()&#xA;{&#xA;  Wire.begin();&#xA;  RTC.begin();&#xA;  Serial.begin(9600);&#xA;  for(i=0;i&amp;lt;=3;i++)&#xA;  {&#xA;    pinMode(row[i],OUTPUT);&#xA;    //pinMode(col[i],INPUT);&#xA;    //digitalWrite(col[i],HIGH);&#xA;  } &#xA;&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;Medicine Box&quot;);&#xA;&#xA;  //set pins to output because they are addressed in the main loop&#xA;  pinMode(latchPin, OUTPUT);&#xA;&#xA;  if (! RTC.isrunning()) &#xA;  {&#xA;    Serial.println(&quot;RTC is NOT running!&quot;);&#xA;    // following line sets the RTC to the date &amp;amp; time this sketch was compiled&#xA;    RTC.adjust(DateTime(__DATE__, __TIME__));&#xA;  }&#xA;&#xA;&#xA;  for (i=0;i&amp;lt;=4; i++)&#xA;  {&#xA;    digitalWrite(latchPin, 0);&#xA;    shiftOut(dataPin, clockPin, data1);&#xA;    shiftOut(dataPin, clockPin, data1);&#xA;    digitalWrite(latchPin, 1);&#xA;    delay(500);&#xA;    digitalWrite(latchPin, 0);&#xA;    shiftOut(dataPin, clockPin, data2);&#xA;    shiftOut(dataPin, clockPin, data2);&#xA;    digitalWrite(latchPin, 1);&#xA;    delay(500); &#xA;  }&#xA;}&#xA;&#xA;void loop()&#xA;{ &#xA;&#xA;  DateTime now = RTC.now();&#xA;  // set the cursor to column 0, line 1&#xA;  // (note: line 1 is the second row, since counting begins with 0):&#xA;  lcd.setCursor(0, 1);&#xA;  // print the number of seconds since reset:&#xA;  //lcd.print(millis() / 1000);&#xA;  //Serial.println(now);&#xA;  //Serial.print(&quot;    &quot;);&#xA;   /*   Serial.print(now.day(), DEC);&#xA;      Serial.print('/');&#xA;      Serial.print(now.month(), DEC);&#xA;      Serial.print('/');&#xA;      Serial.print(now.year(), DEC);&#xA;      Serial.print(' ');&#xA;      Serial.print(now.hour(), DEC);&#xA;      Serial.print(':');&#xA;      Serial.print(now.minute(), DEC);&#xA;      Serial.print(':');&#xA;      Serial.print(now.second(), DEC);&#xA;      Serial.println(&quot; &quot;);*/&#xA;&#xA;      lcd.print(now.day(), DEC);&#xA;      lcd.print('/');&#xA;      lcd.print(now.month(), DEC);&#xA;      lcd.print('/');&#xA;      lcd.print(now.year()-2000, DEC);&#xA;      lcd.print(' ');&#xA;      if (now.hour()&amp;lt;10)&#xA;        lcd.print('0');&#xA;      lcd.print(now.hour(), DEC);&#xA;      lcd.print(':');&#xA;      if (now.minute()&amp;lt;10)&#xA;        lcd.print('0');&#xA;      lcd.print(now.minute(), DEC);&#xA;      lcd.print(':');&#xA;      if (now.second()&amp;lt;10)&#xA;        lcd.print('0');&#xA;      lcd.print(now.second(), DEC);&#xA;      //lcd.println(&quot; &quot;);&#xA;&#xA;  for(i=0; i&amp;lt;=3; i++)&#xA;  {&#xA;    digitalWrite(row[0],HIGH);&#xA;    digitalWrite(row[1],HIGH);&#xA;    digitalWrite(row[2],HIGH);&#xA;    digitalWrite(row[3],HIGH);&#xA;    digitalWrite(row[i],LOW);&#xA;&#xA;    for(j=0; j&amp;lt;=2; j++)&#xA;    {&#xA;      col_scan=analogRead(col[j]);&#xA;      if(col_scan &amp;lt; 1000)&#xA;      {&#xA;        while(analogRead(col[j])&amp;lt; 1000);&#xA;        keypress(i,j);&#xA;      }&#xA;    }&#xA;  }&#xA;  digitalWrite(latchPin, 0);&#xA;  shiftOut(dataPin, clockPin, data1);&#xA;  shiftOut(dataPin, clockPin, data1);&#xA;  digitalWrite(latchPin, 1);&#xA;}&#xA;&#xA;void keypress(int i, int j)&#xA;{&#xA;  if(i==0&amp;amp;&amp;amp;j==0)&#xA;    Serial.println(&quot;1&quot;);&#xA;  else if(i==0&amp;amp;&amp;amp;j==1)&#xA;    Serial.println(&quot;2&quot;);&#xA;  else if(i==0&amp;amp;&amp;amp;j==2)&#xA;    Serial.println(&quot;3&quot;);&#xA;  else if(i==0&amp;amp;&amp;amp;j==3)&#xA;    Serial.println(&quot;A&quot;);&#xA;  else if(i==1&amp;amp;&amp;amp;j==0)&#xA;    Serial.println(&quot;4&quot;);&#xA;  else if(i==1&amp;amp;&amp;amp;j==1)&#xA;    Serial.println(&quot;5&quot;);&#xA;  else if(i==1&amp;amp;&amp;amp;j==2)&#xA;    Serial.println(&quot;6&quot;);&#xA;  else if(i==1&amp;amp;&amp;amp;j==3)&#xA;    Serial.println(&quot;B&quot;);&#xA;  else if(i==2&amp;amp;&amp;amp;j==0)&#xA;    Serial.println(&quot;7&quot;);&#xA;  else if(i==2&amp;amp;&amp;amp;j==1)&#xA;    Serial.println(&quot;8&quot;);&#xA;  else if(i==2&amp;amp;&amp;amp;j==2)&#xA;    Serial.println(&quot;9&quot;);&#xA;  else if(i==2&amp;amp;&amp;amp;j==3)&#xA;    Serial.println(&quot;C&quot;);&#xA;  else if(i==3&amp;amp;&amp;amp;j==0)&#xA;    Serial.println(&quot;*&quot;);&#xA;  else if(i==3&amp;amp;&amp;amp;j==1)&#xA;    Serial.println(&quot;0&quot;);&#xA;  else if(i==3&amp;amp;&amp;amp;j==2)&#xA;    Serial.println(&quot;#&quot;);&#xA;  else if(i==3&amp;amp;&amp;amp;j==3)&#xA;    Serial.println(&quot;D&quot;);&#xA;}&#xA;&#xA;// the heart of the program&#xA;void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {&#xA;  // This shifts 8 bits out MSB first, &#xA;  //on the rising edge of the clock,&#xA;  //clock idles low&#xA;&#xA;  //internal function setup&#xA;  int i=0;&#xA;  int pinState;&#xA;  pinMode(myClockPin, OUTPUT);&#xA;  pinMode(myDataPin, OUTPUT);&#xA;&#xA;  //clear everything out just in case to&#xA;  //prepare shift register for bit shifting&#xA;  digitalWrite(myDataPin, 0);&#xA;  digitalWrite(myClockPin, 0);&#xA;&#xA;  //for each bit in the byte myDataOut�&#xA;  //NOTICE THAT WE ARE COUNTING DOWN in our for loop&#xA;  //This means that %00000001 or &quot;1&quot; will go through such&#xA;  //that it will be pin Q0 that lights. &#xA;  for (i=7; i&amp;gt;=0; i--)  {&#xA;    digitalWrite(myClockPin, 0);&#xA;&#xA;    //if the value passed to myDataOut and a bitmask result &#xA;    // true then... so if we are at i=6 and our value is&#xA;    // %11010100 it would the code compares it to %01000000 &#xA;    // and proceeds to set pinState to 1.&#xA;    if ( myDataOut &amp;amp; (1&amp;lt;&amp;lt;i) ) {&#xA;      pinState= 1;&#xA;    }&#xA;    else {  &#xA;      pinState= 0;&#xA;    }&#xA;&#xA;    //Sets the pin to HIGH or LOW depending on pinState&#xA;    digitalWrite(myDataPin, pinState);&#xA;    //register shifts bits on upstroke of clock pin  &#xA;    digitalWrite(myClockPin, 1);&#xA;    //zero the data pin after shift to prevent bleed through&#xA;    digitalWrite(myDataPin, 0);&#xA;  }&#xA;&#xA;  //stop shifting&#xA;  digitalWrite(myClockPin, 0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24074" LastActivityDate="2016-09-19T08:23:36.577" Title="Difficulty with shifting data" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26561" PostTypeId="1" AcceptedAnswerId="26590" CreationDate="2016-07-21T01:54:44.650" Score="0" ViewCount="390" Body="&lt;p&gt;I am making a remote controlled Arduino robot. I has 4 DC motors for wheels. I have 2 motor drivers available that control two dc motors each. I was wondering what the downsides are of wiring 2 dc motors together. The DC motors are 6v and the maximum current per channel of my motor driver is 1.2A which should be plenty for the motors. The motor driver that I am using can be found &lt;a href=&quot;https://www.sparkfun.com/products/9457&quot; rel=&quot;nofollow&quot;&gt;here.&lt;/a&gt; Each motor is getting controlled using a PWM signal. The DC motors are controlled separately.&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-07-21T18:00:58.933" LastActivityDate="2016-07-21T19:14:54.750" Title="Should I control each of the four robot wheel separately or wire two from each side together?" Tags="|arduino-mega|motor|arduino-motor-shield|robotics|remote-control|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26564" PostTypeId="2" ParentId="26559" CreationDate="2016-07-21T04:58:35.123" Score="1" Body="&lt;p&gt;According to second image transistor seems to be connected in oposite direction (switched Collector with Emitter). It means common collector configuration is used instead common emitter and it's usually not enough to drive motor. And C-E can handle only about 10V Max (more or less, depends on transistor) even if it could handle much more in oposite direction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.electronics-tutorials.ws/transistor/tran_1.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; for more details:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;Common Base Configuration   –   has Voltage Gain but no Current Gain.&lt;/li&gt;&#xA;  &lt;li&gt;Common Emitter Configuration   –   has both Current and Voltage Gain.&lt;/li&gt;&#xA;  &lt;li&gt;Common Collector Configuration   –   has Current Gain but no Voltage Gain.&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I've just tested this circuit an it must be powered by power jack. USB is not strong enough.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-07-22T20:17:00.697" LastActivityDate="2016-07-22T20:17:00.697" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26565" PostTypeId="2" ParentId="26559" CreationDate="2016-07-21T05:00:50.297" Score="1" Body="&lt;p&gt;There is nothing wrong with the circuit (although drawn in a bizarre method). Your understanding of how a transistor works is mistaken - forget voltage - transistors are controlled by current.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Most likely you have connected the transistor incorrectly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The voltage reading is due to back EMF. If you used an analog meter it would give the reading you expect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In all likelihood you have damaged the transistor. &lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-07-21T05:00:50.297" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26567" PostTypeId="2" ParentId="26560" CreationDate="2016-07-21T07:07:58.687" Score="1" Body="&lt;p&gt;Your code looks unnecessarily convoluted for merely sending data to a shift register. You can use the SPI hardware for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const byte LATCH = 10;&#xA;&#xA;void setup ()&#xA;{&#xA;  SPI.begin ();&#xA;}  // end of setup&#xA;&#xA;void loop ()&#xA;{&#xA;  digitalWrite (LATCH, LOW);&#xA;  SPI.transfer (0xAB);&#xA;  SPI.transfer (0xCD);&#xA;  SPI.transfer (0xEF);&#xA;  SPI.transfer (0x42);  &#xA;  digitalWrite (LATCH, HIGH);&#xA;  delay (20);&#xA;}  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You have to use the SPI hardware pins for this to work. On a Uno these are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Chip pin 14 (DS) goes to MOSI  (D11)&lt;/li&gt;&#xA;&lt;li&gt;Chip pin 11 (SH) goes to SCK   (D13)&lt;/li&gt;&#xA;&lt;li&gt;Chip pin 12 (ST) goes to SS    (D10)  (or any other pin by changing LATCH)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Example wiring:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Vmhgi.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Vmhgi.png&quot; alt=&quot;595 wiring schematic&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More details on my &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11518&quot; rel=&quot;nofollow noreferrer&quot;&gt;page about the 595 chip&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-21T07:07:58.687" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26570" PostTypeId="1" CreationDate="2016-07-21T09:43:17.723" Score="1" ViewCount="333" Body="&lt;p&gt;I'm trying to send a button press over RF (performing a closed circuit operation on the receiving end).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a controller with an UP and DOWN button. Unfortunately I am limited to the cable length, and would like to extend it with radio frequency. The controller has one cable for GND and one each for the corresponding UP and DOWN buttons.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The RF units is the typical 433mhz bought online (ebay).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I in someway send the signal over RF (directly on the data pin of the transmitter) without hooking it up to a microcontroller (Arduino)? &lt;/p&gt;&#xA;" OwnerUserId="7295" LastActivityDate="2016-07-21T10:02:10.580" Title="Send button press over RF" Tags="|electronics|rf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26571" PostTypeId="2" ParentId="26570" CreationDate="2016-07-21T10:02:10.580" Score="1" Body="&lt;p&gt;No. You need a micro-controller at both the sending, and receiving sides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;eBay does set RF remotes with a few buttons. This might be easier and cheaper than making your own.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-21T10:02:10.580" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26575" PostTypeId="1" AcceptedAnswerId="26581" CreationDate="2016-07-21T12:20:01.743" Score="0" ViewCount="1651" Body="&lt;p&gt;I am currently &lt;strong&gt;trying to add a clock functionality to my current sketch&lt;/strong&gt; for a peristaltic pump [run by NEMA 23]. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The current sketch waits for a button on my breadboard to be pressed, it then runs the motor for a specified amount of steps and then stops and waits for the next press of the button&lt;/em&gt;. It also displays the amount of steps to the Serial Monitor. I have a working sketch for a clock using an RTC DS3231 module and have unsuccessfuly attempted to fit it into my motor sketch. &lt;strong&gt;The problem is, the clock seems to be taking precedent over the rest of my sketch, so pressing the button no longer works and the time is simply consistently output onto the Serial Monitor.&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;The ideal functionality would be the time and date displayed on LCD constantly (or at least blinking so rapidly that one could not tell the difference) with the number of button presses displayed under it, changing in value only when a button is pressed.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attatched find my code, it is really quite simple, and thank you so much for the time and help. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bounce2.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;#include &amp;lt;MultiStepper.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;       //I2C Library&#xA;#include &amp;lt;OneWire.h&amp;gt;&#xA;#define DS3231_I2C_ADDRESS 0x68&#xA;&#xA;AccelStepper stepper(1, 9, 8); // initiate stepper motor&#xA;&#xA;LiquidCrystal lcd(6, 7, 5, 4, 3, 2);&#xA;&#xA;int pos = 0; // variable to store position&#xA;int buttonPresses = 0;&#xA;&#xA;const byte ButtonPin = 10;&#xA;const byte LedPin = 13; // for debugging and visualization&#xA;&#xA;unsigned long ledOnTimer = 0;&#xA;&#xA;const unsigned int ledPeriod = 3000;&#xA;&#xA;Bounce button;&#xA;&#xA;void setup() {&#xA;  Wire.begin();&#xA;  Serial.begin(9600);&#xA;  lcd.begin(16, 2);&#xA;  button.attach(ButtonPin);&#xA;  pinMode(LedPin, OUTPUT);&#xA;  stepper.setMaxSpeed(4000);&#xA;  stepper.setSpeed(2000);&#xA;  stepper.setCurrentPosition(0);&#xA;}&#xA;&#xA;byte bcdToDec(byte val)  {&#xA;  // Convert binary coded decimal to normal decimal numbers&#xA;  return ( (val / 16 * 10) + (val % 16) );&#xA;}&#xA;&#xA;void loop() {&#xA;  motor();&#xA;  printDate();&#xA;}&#xA;&#xA;void motor() { // functioning motor sketch by itself&#xA;&#xA;  //if led is on&#xA;  if (digitalRead(LedPin)) {&#xA;    stepper.runToNewPosition(21000); //about 420 steps per 10 mL&#xA;    digitalWrite(LedPin, LOW);&#xA;    // }&#xA;  }&#xA;&#xA;  //if led is off&#xA;  else {&#xA;    button.update();&#xA;    if (button.fell()) { // if the button &quot;fell&quot; from a value from HIGH to LOW (so now it is off)&#xA;      stepper.setCurrentPosition(0);&#xA;      digitalWrite(LedPin, HIGH);&#xA;      buttonPresses++; // count presses of button and print to monitor&#xA;      lcd.clear();&#xA;      Serial.print(&quot;Number of Button &quot;);&#xA;      lcd.setCursor(0, 1);&#xA;      Serial.print(&quot;Presses = &quot;);&#xA;      Serial.println(buttonPresses);&#xA;    }&#xA;  }&#xA;}&#xA;&#xA;void printDate() { //functioning time sketch by itself&#xA;&#xA;  // Reset the register pointer&#xA;  Wire.beginTransmission(DS3231_I2C_ADDRESS);&#xA;&#xA;  byte zero = 0x00;&#xA;  Wire.write(zero);&#xA;  Wire.endTransmission();&#xA;&#xA;  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);&#xA;&#xA;  int second = bcdToDec(Wire.read());&#xA;  int minute = bcdToDec(Wire.read());&#xA;  int hour = bcdToDec(Wire.read() &amp;amp; 0b111111); //24 hour time&#xA;  int weekDay = bcdToDec(Wire.read()); //0-6 -&amp;gt; sunday - Saturday&#xA;  int monthDay = bcdToDec(Wire.read());&#xA;  int month = bcdToDec(Wire.read());&#xA;  int year = bcdToDec(Wire.read());&#xA;&#xA;  //  print the date EG   3/1/11 23:59:59&#xA;  Serial.print(month);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(monthDay);&#xA;  Serial.print(&quot;/&quot;);&#xA;  Serial.print(year);&#xA;  Serial.print(&quot; &quot;);&#xA;  Serial.print(hour);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.print(minute);&#xA;  Serial.print(&quot;:&quot;);&#xA;  Serial.println(second);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Last note: Everything compiles, and I will change &quot;Serial&quot; to &quot;lcd&quot; after I finish debugging the sketch, so that is why everything is currently beign sent to the Serial Monitor.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-07-22T06:20:48.073" Title="Adding Date and Time to existing sketch" Tags="|arduino-uno|lcd|rtc|1-wire|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26576" PostTypeId="1" AcceptedAnswerId="26577" CreationDate="2016-07-21T12:21:11.153" Score="0" ViewCount="550" Body="&lt;p&gt;I'd like to use a PIR sensor (HC-SR501) to control the power to an Arduino Uno. Note that I'm not talking about using a PIR sensor as input to the Arduino and sensing the output pin from the PIR, I'm talking about using the output pin from the PIR to turn the Arduino itself on and off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hooking it up directly doesn't seem to work as I'm guessing the PIR doesn't handle that much current output. Would I use a transistor of some kind to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My reason for wanting to do this is simple, power preservation. The PIR uses so little current when it doesn't sense anything that I thought it would be nice for something like a mailbox sensor that doesn't need to run that often. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="2830" LastActivityDate="2016-09-03T07:22:14.207" Title="Can I use a PIR sensor to turn on an arduino?" Tags="|arduino-uno|sensors|power|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26577" PostTypeId="2" ParentId="26576" CreationDate="2016-07-21T12:46:45.650" Score="1" Body="&lt;p&gt;Yes you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It all depends on how you are turning the power on.  You sensor needs to flip a 'switch' rather than actually power the Arduino directly.  (I'm sure you know that but just in case).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need a normally open relay in between you power source and you Arduino.  Normally open because you don't want it powered unless you 'turn it on'.  Your relay might be able to be switched by your PIR sensor's data output, but if you need more current then you are going to have to use a transistor and draw more power from the power source.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have the PIR sensor, so now find the relay capable of carrying the maximum current you need for the Arduino.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-21T12:46:45.650" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26578" PostTypeId="2" ParentId="26575" CreationDate="2016-07-21T12:55:30.077" Score="1" Body="&lt;p&gt;I think you need to look at using interrupts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The printDate function is quite processor intensive with all the Wire and Serial.print calls, it will be taking the majority of the time in each loop().&#xA;Whilst in printDate it won't be looking at the state of the button, so you have to press at just the right time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you place an interrupt on the button's pin I think you will get a more responsive system.  Another thing that you could look at it only reading the clock once a second, this could be done with a timer interrupt.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-21T12:55:30.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26581" PostTypeId="2" ParentId="26575" CreationDate="2016-07-21T13:29:53.607" Score="1" Body="&lt;p&gt;Even if you want to display time with the seconds showing, you don't need to check the time on the RTC continiously. Once a second should be enough. You can use a timer interrupt that triggers an ISR(Interrupt Service Routine) every second to do that check for you. This will free a lot of time which your arduino can use to do other stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Same goes for your button(s): you can use an External Interrupt (INT) or a Pin Change Interrupt (PCINT) for them. This way the arduino will only look at them when they are pushed (and/or released).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you combine those two interrupts (for the clock and the button), your arduino will have a lot of spare time. This is especially handy if you later want to expand your project with more buttons and motors.&lt;/p&gt;&#xA;" OwnerUserId="23002" LastEditorUserId="23002" LastEditDate="2016-07-22T06:20:48.073" LastActivityDate="2016-07-22T06:20:48.073" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26582" PostTypeId="2" ParentId="26575" CreationDate="2016-07-21T14:03:30.097" Score="0" Body="&lt;p&gt;Attaching interrupt (PIN change or LEVEL change) to the push button would work fine. You can trigger a flag and the flag should access the controller to run motor() function.&lt;/p&gt;&#xA;" OwnerUserId="21624" LastActivityDate="2016-07-21T14:03:30.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26583" PostTypeId="2" ParentId="26550" CreationDate="2016-07-21T14:08:59.080" Score="0" Body="&lt;p&gt;From your description, it kind of hard to figure out which arduino doesn't react. Maybe a picture would help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is the arduino that is connected to the PC then the problem is that the serial connection is already used to talk to te PC and therefore can't be used to talk to the XBee. you'll need to use one of the other serial connections on the atmega (serial1, 2 or 3)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mind you that you don't need a microcontroller to connect an XBee to the PC. A simple UART to USB converter is enough.&lt;/p&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-07-21T14:08:59.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26584" PostTypeId="2" ParentId="26550" CreationDate="2016-07-21T14:28:38.777" Score="1" Body="&lt;p&gt;It is probably because you are using the only Serial to communicate to both the devices - your PC and XBee. At any instant, you can communicate to only one device. So you might need an extra serial to get you go.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, may be due to this conflict you can see TX led blinking. May be it's communicating with anyone of them, and the other one is receiving garbage. &lt;/p&gt;&#xA;" OwnerUserId="21624" LastActivityDate="2016-07-21T14:28:38.777" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26585" PostTypeId="1" CreationDate="2016-07-21T14:57:45.140" Score="0" ViewCount="911" Body="&lt;p&gt;i am trying to make an arduino pro mini sd card serial logger.The arduino should log the data that comes over the uart and write it to an sd card and if it is no data on the serial for 25 seconds to save automatically the data into the file.Each file are named diffrent every time they are saved(for example datalog0.txt, datalog1.txt and so on).I am creating also at the start of the sketch an config(config.txt) file where the number of the file present of the sd are stored and if the file already exist than a new one will be created, this option works good.Now, after the 25 seconds past and it is no more  data over the serial the arduino dont close the datalog.txt file , so the next data will be saved in the same file, this is the problem i have, even in the config file the file number will be increased.I will attach the sketch and expect patient from you, ai am still newbie.I forgot to mention that it was working good for some time but not anymore, the only thing i did was to upload the bootloader from ide and since than is not working anymore.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;            int i;&#xA;            int incomingByte = 0;&#xA;//int data[512];&#xA;            File myFile;&#xA;            unsigned char bytes,flag_again;&#xA;            unsigned int fileNo,timer_count;&#xA;            String s_fileNo,filename,filename_master;&#xA;            char comanda;&#xA;&#xA;&#xA;&#xA;            void Timer1_InIt()&#xA;        {&#xA;            TCCR1A = 0;&#xA;            TCCR1B = 0;&#xA;            TCNT1  = 0;&#xA;            OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be &amp;lt;65536)&#xA;            TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;                TCCR1B |= (1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS10);&#xA;                //TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;            }&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{&#xA;    timer_count++;&#xA;    if(timer_count &amp;gt; 25)&#xA;    {&#xA;        timer_count = 0;&#xA;        TIMSK1 &amp;amp;= ~(1 &amp;lt;&amp;lt; OCIE1A);&#xA;        myFile.close();&#xA;        fileNo++;&#xA;        myFile = SD.open(&quot;config.txt&quot;,FILE_WRITE);&#xA;        myFile.seek(0);&#xA;        myFile.print(fileNo);&#xA;        myFile.close();&#xA;        //software_Reset() ;    //reset the sketch&#xA;    }&#xA;}&#xA;SoftwareSerial mySerial(4, 5); // RX, TX&#xA;&#xA;void setup()&#xA;{&#xA;    cli();&#xA;    Timer1_InIt();&#xA;    sei();&#xA;&#xA;    mySerial.begin(9600);&#xA;    Serial.begin(10752,SERIAL_8E2);&#xA;    //mySerial.print(&quot;Initializing SD card...&quot;);&#xA;&#xA;    if (!SD.begin(10))&#xA;    {&#xA;        //mySerial.println(&quot;initialization failed!&quot;);&#xA;        return;&#xA;    }&#xA;    Serial.println(&quot;initialization done.&quot;);&#xA;&#xA;    myFile = SD.open(&quot;config.txt&quot;,FILE_READ);&#xA;// mySerial.println(&quot;Config file created&quot;);&#xA;    if(!myFile.available())&#xA;        bytes = 0;&#xA;    else&#xA;    {&#xA;        bytes = myFile.available();&#xA;        for(i = 0; i&amp;lt; bytes ; i++)&#xA;            s_fileNo += (char)myFile.read();&#xA;    }&#xA;    myFile.close();&#xA;    fileNo = s_fileNo.toInt();&#xA;// mySerial.print(&quot;file no:&quot;);&#xA;    //mySerial.println(fileNo);&#xA;&#xA;    filename = &quot;datalog&quot;;&#xA;    filename += fileNo;&#xA;    filename += &quot;.txt&quot;;&#xA;&#xA;    myFile = SD.open(filename,FILE_WRITE);&#xA;    if (myFile)&#xA;    {&#xA;        //mySerial.print(filename);&#xA;        //mySerial.println(&quot; File Open...&quot;);&#xA;    }&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;    if(!myFile)&#xA;        myFile = SD.open(filename, FILE_WRITE);&#xA;&#xA;&#xA;    while(Serial.available())&#xA;    {&#xA;        incomingByte = Serial.read();&#xA;        /*if(incomingByte == 0 || incomingByte &amp;lt; 15 )&#xA;        {&#xA;          Serial.print('0');&#xA;          myFile.print(0,HEX);&#xA;        }*/&#xA;        //mySerial.println(incomingByte,HEX);&#xA;        myFile.println(incomingByte,HEX);&#xA;        // myFile.println(incomingByte);&#xA;        timer_count = 0;&#xA;        flag_again = 1;&#xA;    }&#xA;    if(!Serial.available() &amp;amp;&amp;amp; flag_again)&#xA;    {&#xA;        TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;        flag_again = 0;&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24095" LastActivityDate="2016-11-20T16:30:28.040" Title="Arduino Pro Mini interrupts timer not working" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26586" PostTypeId="1" AcceptedAnswerId="26588" CreationDate="2016-07-21T15:45:05.773" Score="0" ViewCount="23" Body="&lt;p&gt;&lt;strong&gt;Why are (big) values being changed?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried out printing some values and noticed bigger values are changed more, they seem to be rounded to quarters and then to halves when the value gets bigger. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;MWE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.print(&quot;12457591.51 is changed into &quot;);&#xA;  Serial.println(12457591.51);&#xA;  Serial.print(&quot;2457591.80 is changed into &quot;);&#xA;  Serial.println(2457591.80);&#xA;  Serial.print(&quot;1234567.89 is changed into &quot;);&#xA;  Serial.println(1234567.89);&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;gives me&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12457591.51 is changed into 12457592.00&#xA;2457591.80 is changed into 2457591.75&#xA;1234567.89 is changed into 1234567.87&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm working with an Arduino Nano ATMega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&#xA;I need the calculation &lt;code&gt;(2457591.33 + 0.5 - 2440588)  * 60 * 60 * 24&lt;/code&gt; to be precise to within preferably a hundred, but currently it's off by about &lt;code&gt;7000&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="23642" LastActivityDate="2016-07-21T18:00:06.757" Title="Large values are changed by Arduino when viewing with `Serial.print()`" Tags="|variables|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26587" PostTypeId="1" CreationDate="2016-07-21T16:27:23.000" Score="1" ViewCount="4581" Body="&lt;p&gt;I am working on ESP8266 in Arduino IDE. I want to know how to Software RESET the ESP8266. Any sketch/example would be useful. Moreover, how to initialise WDT in ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kindly help!&lt;/p&gt;&#xA;" OwnerUserId="23271" LastActivityDate="2016-12-19T23:11:19.823" Title="WDT &amp; Software RESET in ESP8266 + Arduino IDE" Tags="|arduino-ide|esp8266|timers|reset|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26588" PostTypeId="2" ParentId="26586" CreationDate="2016-07-21T17:28:09.713" Score="1" Body="&lt;p&gt;Floating point numbers doesn't have infinite precision. But you can always change your equation to use smaller numbers (preferably integers or longs as floating point is extremely slow)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example on &lt;a href=&quot;http://www.avrfreaks.net/forum/floating-point-range&quot; rel=&quot;nofollow&quot;&gt;AVR Freaks&lt;/a&gt; they mentioned precision about 6 or 7 digits. It makes sense as 24bits signed number range is from -8388608 to 8388607 &lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-07-21T18:00:06.757" LastActivityDate="2016-07-21T18:00:06.757" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26590" PostTypeId="2" ParentId="26561" CreationDate="2016-07-21T19:14:54.750" Score="1" Body="&lt;p&gt;it looks like you have two channels on each controller, so you have some options here. but first I'm going to talk a bit about your motors. If you have a spec sheet for them you can gather most of this info through that, but it doesn't hurt to do some experimentation. A motor will draw max current when it is stalled (is trying to drive but it can't), and you can determine this &quot;stall current&quot; with a multimeter or from the spec sheet. when you're driving the robot, this can occur when you drive up to a wall and try to push through the wall (hint, no robot this size will damage a well built wall) but likely the driver will reach a wall and stop driving (unless she can't see the robot while driving, idk). the lowest current it will draw (aside from zero when it can't...) is it's &quot;free speed&quot; current, this is when it's spinning as fast as it can with no load on it. while you're driving the robot you can expect the current to be between these numbers, if you want to get super fancy (and you want to equip your robot to do this) you could log the instantaneous current every 10ms or however often (this can be useful if you want to diagnose faults, but again its a small robot)... so if you have two motors in parallel (which you want to do because in series one will drive harder than the other), then the current drawn by each will add, so you can double it for two motors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;anyways, here's a few options for the motor configuration:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if two of your motors in parallel draw less than continuous 1.2 amps, you could use a single controller for one robot, controlling left wheels on channel 0 and right on channel 1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if your motors draw more than that in parallel, you will have to use two channels per side, however you could Y the PWM lines between the motor controller and the arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if you are using something like omni wheels and want control over every single wheel, obviously you will want one channel per wheel...&lt;/p&gt;&#xA;" OwnerUserId="24071" LastActivityDate="2016-07-21T19:14:54.750" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26591" PostTypeId="1" AcceptedAnswerId="26593" CreationDate="2016-07-21T19:15:39.997" Score="0" ViewCount="952" Body="&lt;p&gt;I'm new to Arduino and dying to delve in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are lots of Arduino base board vendors, and lots of shield vendors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, should I be able to plug any shield into any Arduino board, even with existing shields?&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-07-21T19:33:57.243" Title="is the Arduino shield pinout a standard, so that any Arduino shield can work with any Arduino board" Tags="|arduino-uno|shields|pins|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26592" PostTypeId="2" ParentId="26591" CreationDate="2016-07-21T19:33:10.647" Score="1" Body="&lt;p&gt;Most shields will fit most of the &quot;regular sized&quot; boards. the obvious exception is the boards like the nano which are tiny. Shields are going to have the best compatibility with the Uno, just because that one is the most common, so if you are going to get one arduino and a bunch of shields, get an uno. Some shields (the gen 1 ethernet and wifi shields in particular had an issue where they could not be used on Megas because the mega listens to SPI on pins 50+ which simply were not connected to the shield, however most of the newer shields will connect to the 6-pin block in the center now-adays to allow Mega usage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next thing you want to look at is if you are stacking shields, if they will collide on pin usage (SPI gets around this through multiplexing) and some of the 3.3 volt devices may have conflicts with 5-volt shields. Although the 3.3v devices do provide 5v power-out pins in the same locations as the Uno, it becomes more of an issue with trying to read a 5v on a 3.3v pin, which could damage the microchip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;the best thing to do is to check the documentation of the shields and check which pins they use, what voltages they need/supply, and comparing this with the particular arduino you are using.&lt;/p&gt;&#xA;" OwnerUserId="24071" LastActivityDate="2016-07-21T19:33:10.647" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26593" PostTypeId="2" ParentId="26591" CreationDate="2016-07-21T19:33:57.243" Score="1" Body="&lt;p&gt;No, they are not standard - not entirely - although there have been some attempts to make them more standard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things to watch out for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SPI&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Uno originally had SPI on pins 10-13&lt;/li&gt;&#xA;&lt;li&gt;The Mega had it on another COMMS header instead&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;SPI has now been standardized to the 6-pin ICSP header, though not all shields honour that, and still use pins 10-13 instead, so they won't work on boards like the Mega&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I2C&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The Uno has I2C on pins A4/A5&lt;/li&gt;&#xA;&lt;li&gt;The Mega has it on the COMMS header instead&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I2C has now been standardized on a special pair of pins added to the end of the digital IO header (pins 8-13 + GND + AREF) though many shields still look for it on pins A4/A5, so they won't work on boards like the Mega&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some other boards, like the Leonardo, also have these (and other) functions on other pins, so may not work with some shields that don't use the SPI / I2C headers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The basic functions, though, i.e., digital IO and analog inputs and UART 1 are all in the same places on the majority of boards, and most have PWM in the same places too. But you can't rely on any thing more than that between any two boards.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-21T19:33:57.243" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26594" PostTypeId="1" CreationDate="2016-07-21T21:14:31.240" Score="1" ViewCount="75" Body="&lt;p&gt;Anyone recognize Mfgr/model of this display that reads: &quot;Wireless Internet Of Things&quot;.  The Arduino board is a WIOT.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been looking and looking for a source for Arduino display like this, but cannot find.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pO1Uz.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pO1Uz.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-07-21T21:41:00.933" Title="Who makes this cool Arduino display shield, and what model is it?" Tags="|lcd|shields|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26595" PostTypeId="2" ParentId="26594" CreationDate="2016-07-21T21:25:04.040" Score="3" Body="&lt;p&gt;That will be an SSD1306 based blue OLED display with SPI interface. There's lots of them around by lots of different people. Some are I2C interface, and some of those have a &quot;broken&quot; I2C interface that doesn't send ACKs (especially cheap ones on eBay) and need a special ACK-less Software I2C implementation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SPI ones, of course, won't suffer from that problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They are generally 0.96&quot; diagonal, and that one, I think, is 96x39 pixels (or it may be 128x64).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-07-21T21:41:00.933" LastActivityDate="2016-07-21T21:41:00.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26596" PostTypeId="1" CreationDate="2016-07-21T21:56:09.123" Score="0" ViewCount="407" Body="&lt;p&gt;I'm trying to make a 4 channel RC using Arduino and nrf24L01 module.&#xA;I already know how to deal with this module, but the question is &quot;What does 4 channel mean ?&quot;, and how to make it supports 4 channel ?  &lt;/p&gt;&#xA;" OwnerUserId="24103" LastActivityDate="2016-07-21T23:24:01.027" Title="4 channel Remote Control" Tags="|arduino-uno|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26599" PostTypeId="1" CreationDate="2016-07-21T23:04:14.423" Score="0" ViewCount="667" Body="&lt;p&gt;I am currently working on an Arduino project where the Arduino will send data to a processing program via bluetooth and processing will draw the data. However, my code doesn't seem to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;int bluetoothTx = 1;&#xA;int bluetoothRx = 0;&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup() {&#xA;  bluetooth.begin(9600);&#xA;}&#xA;&#xA;void loop() {    &#xA;  Serial.println(&quot;Hello&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is my Processing code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;import processing.serial.*;&#xA;Serial myPort;&#xA;&#xA;void setup() {&#xA;  myPort = new Serial(this, &quot;COM42&quot;, 9600);&#xA;  myPort.bufferUntil('\n');&#xA;}&#xA;&#xA;void serialEvent( Serial myPort) {&#xA;  String data = myPort.readStringUntil('\n');&#xA;  println(data);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I identified that the incoming port from the HC-05 module is &quot;COM42&quot; from my Bluetooth settings. I am expecting to see several &quot;Hello&quot; lines being printed on the processing console but this does not happen&lt;/p&gt;&#xA;" OwnerUserId="23816" LastActivityDate="2016-11-19T01:56:24.073" Title="Send sensor information to processing" Tags="|arduino-uno|serial|bluetooth|datalogging|processing-lang|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26600" PostTypeId="2" ParentId="26599" CreationDate="2016-07-21T23:16:57.180" Score="1" Body="&lt;p&gt;Your whole sending program is a complete mess, sorry to say:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you create a SoftwareSerial port using the HardwareSerial pins. (Why on earth would you do that?)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then you &quot;begin&quot; that SoftwareSerial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally you try and print &lt;code&gt;Hello&lt;/code&gt; through the &lt;strong&gt;HardwareSerial&lt;/strong&gt; port!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either use SoftwareSerial &lt;strong&gt;OR&lt;/strong&gt; use the hardware UART. You can't mix and match both. And since you are using the hardware UART pins, why even consider using SoftwareSerial?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;    Serial.println(&quot;Hello&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OR, to use &lt;em&gt;other pins than 0 and 1&lt;/em&gt;:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int bluetoothTx = 2;&#xA;const int bluetoothRx = 3;&#xA;&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;&#xA;void setup() {&#xA;    bluetooth.begin(9600);&#xA;}&#xA;&#xA;void loop() {    &#xA;    bluetooth.println(&quot;Hello&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-21T23:16:57.180" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26601" PostTypeId="2" ParentId="26596" CreationDate="2016-07-21T23:24:01.027" Score="2" Body="&lt;p&gt;4 channel means having the ability to send 4 individual values (maybe speeds?) at once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the nRF24L01+ is a packet based system it is as simple as sending the different &quot;channels&quot; as different bytes (or groups of bytes if more than 0-255 or -128 to +127 is needed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you want 4 channels that can represent 0-255 then you need 4 bytes, and so you can set both sender and receiver to have a packet size of 4 bytes (for efficiency) and send a packet made up of the 4 channel values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to represent numbers bigger than that then you need to split the variable into bytes (two bytes for an int, 4 for a long) or create a &lt;code&gt;struct&lt;/code&gt; to represent your packet of data. Of course you then need the sender and receiver to be set to a packet size &lt;em&gt;at least&lt;/em&gt; big enough to contain the data, and both ends must agree on the packet size.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-21T23:24:01.027" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26602" PostTypeId="1" CreationDate="2016-07-22T01:48:04.317" Score="0" ViewCount="3173" Body="&lt;p&gt;I'm using visual micro for visual studio, and I understand this kind of thing is caused by conflicting serial data when I try to read and print to the main serial at the same time, right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, I need to read serial data from the main serial on my Mega 2560, and then I need to see it on my LCD screen, which is controlled by the board via SPI. I know I can use those two at the same time because I'm doing it with my transmitting arduino and I can see that it's transmitting correctly. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I try to view my serial data in the serial port, I get nothing but a stream of these error codes, or whatever they are. They generally look like this: VMDPE_1|1_VMDPE. Usually there are some numbers in there too, like: MDPE_1|2571143_VMDPE. I sort of expected that, since you can't read and write at the same time on one serial. But that would be fine, because my project is not going to be plugged into a PC anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So of course I try to pipe my data directly to the LCD screen so I can plug my recieving arduino into external power and not have to see the error messages, which I thought were coming from the debugger of my compiler. Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//on the receiver side&#xA;&#xA;#include &amp;lt;stdint.h&amp;gt;&#xA;#include &amp;lt;TFTv2.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;char incoming[3];&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    //TFT_BL_ON;      // turn on the background light&#xA;    //Tft.TFTinit();  // init TFT library&#xA;    //Tft.setDisplayDirect(DOWN2UP);&#xA;    //TFT_BL_ON;      // turn on the background light&#xA;    //Tft.drawString(&quot;INCOMING:&quot;, 20, 301, 3, RED);&#xA;    Serial.println(incoming);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;    if (Serial.available()) {&#xA;&#xA;        Serial.readBytesUntil(',', incoming, 3 ) ;&#xA;&#xA;        //Tft.fillRectangle(64, 236, 45, 165, BLACK);&#xA;&#xA;        //Tft.drawString(incoming, 65, 235, 4, WHITE);&#xA;        Serial.println(incoming);&#xA;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But nope! I get the same error codes on my LCD screen! Even worse, now they seem to have screwed up my zigbee module! I took it off the board, plugged it into my computer, and now the XCTU utility is reading all sorts of messed up values that are total nonsense. Somehow, this seems to have overwritten the zigbee's actual SERIAL NUMBERS!!! What are they now? Take a guess!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial number high: E_1|2571092_VMDPE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Serial number low:  MDPE_1|2571143_VMDPE&lt;/p&gt;&#xA;" OwnerUserId="19892" LastActivityDate="2022-01-26T21:03:06.060" Title="What's with the debug error messages, like VMDPE_1|1_VMDPE?" Tags="|debug|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26605" PostTypeId="2" ParentId="26602" CreationDate="2016-07-22T07:47:39.797" Score="2" Body="&lt;p&gt;Your &lt;code&gt;incoming&lt;/code&gt; buffer is not big enough to handle the data that you're giving it. Cutting away the comments from your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char incoming[3];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This declares a buffer for &lt;strong&gt;two&lt;/strong&gt; characters, allowing for the (required) &lt;code&gt;0&lt;/code&gt; on the end. &lt;code&gt;println()&lt;/code&gt; needs to know when to stop printing characters: it does this when it sees a &lt;code&gt;NUL&lt;/code&gt; (&lt;code&gt;0&lt;/code&gt;) character.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.readBytesUntil(',', incoming, 3 ) ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You're passing in that you want to read &lt;code&gt;3&lt;/code&gt; characters - but that completely fills &lt;code&gt;incoming&lt;/code&gt;, leaving no room for the trailing &lt;code&gt;NUL&lt;/code&gt; (&lt;code&gt;0&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(incoming);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This then prints the first character, the second character, the third character... then the 4th, 5th, 6th, 7th etc. in memory until it &lt;em&gt;finally&lt;/em&gt; reaches a &lt;code&gt;NUL&lt;/code&gt; and then quits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you call &quot;debug messages&quot; are actually printed gibberish in memory... To fix it, you need to make &lt;code&gt;incoming&lt;/code&gt; larger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, it's a good idea when using buffers like this to use the &lt;code&gt;sizeof()&lt;/code&gt; function, as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.readBytesUntil(',', incoming, sizeof(incoming)-1 ) ; // Note the -1!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-22T07:47:39.797" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26607" PostTypeId="1" CreationDate="2016-07-22T08:15:18.583" Score="1" ViewCount="1297" Body="&lt;p&gt;First of all, I'm completely new to both arduino, and programing. Second, as for a good newbie, i'm trying to build a fairly complicated project. So, any help and suggestion is welcome. The goal is: light up a shelf, with 2x 1m led strip, with 2 different &quot;fire&quot; animation. And remote control the arduino to switch between effects and colors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The state of the project so far &lt;a href=&quot;https://circuits.io/circuits/2459366-arduino-ir-with-neopixel&quot; rel=&quot;nofollow&quot;&gt;https://circuits.io/circuits/2459366-arduino-ir-with-neopixel&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I learned one arduino is not enough to decode IR signals and drive led strips. So, I'm using two. Successfully merged 2 sketches: one, that receives, decodes and sends the IR signal to another arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And based on tutorial &lt;a href=&quot;https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I managed to control the LEDs via IR remote control. Here is code currently using (a bit bloated since its contains all the effect from the tutorial.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is code so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#define I2C_SLAVE_ADDRESS 8&#xA;&#xA;// Remote control button codes&#xA;const unsigned int BUTTON_1 = 0xFD08F7; &#xA;const unsigned int BUTTON_2 = 0xFD8877;&#xA;const unsigned int BUTTON_3 = 0xFD48B7;&#xA;const unsigned int BUTTON_4 = 0xFD28D7;&#xA;const unsigned int BUTTON_5 = 0xFDA857;&#xA;const unsigned int BUTTON_6 = 0xFD6897;&#xA;const unsigned int BUTTON_7 = 0xFD18E7;&#xA;const unsigned int BUTTON_8 = 0xFD9867;&#xA;const unsigned int BUTTON_9 = 0xFD58A7;&#xA;const unsigned int BUTTON_UP = 0xFD50AF;&#xA;const unsigned int BUTTON_DOWN = 0xFD10EF;&#xA;const unsigned int BUTTON_VOL = 0xFD906F;&#xA;&#xA;int t = 0; // variable for switching led rings with the remote&#xA;int b = 255; // brigtness starting value&#xA;// IR received code&#xA;unsigned int irCode = 0;            //ir code ends here&#xA;// Pattern types supported:&#xA;enum  pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, FIRE };&#xA;// Patern directions supported:&#xA;enum  direction { FORWARD, REVERSE };&#xA;&#xA;// NeoPattern Class - derived from the Adafruit_NeoPixel class&#xA;class NeoPatterns : public Adafruit_NeoPixel&#xA;{&#xA;    public:&#xA;&#xA;    // Member Variables: &#xA;    pattern  ActivePattern;  // which pattern is running&#xA;    direction Direction;     // direction to run the pattern&#xA;&#xA;    unsigned long Interval;   // milliseconds between updates&#xA;    unsigned long lastUpdate; // last update of position&#xA;&#xA;    uint32_t Color1, Color2;  // What colors are in use&#xA;    uint16_t TotalSteps;  // total number of steps in the pattern&#xA;    uint16_t Index;  // current step within the pattern&#xA;&#xA;    void (*OnComplete)();  // Callback on completion of pattern&#xA;&#xA;    // Constructor - calls base-class constructor to initialize strip&#xA;    NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)())&#xA;    :Adafruit_NeoPixel(pixels, pin, type)&#xA;    {&#xA;        OnComplete = callback;&#xA;    }&#xA;&#xA;    // Update the pattern&#xA;    void Update()&#xA;    {&#xA;        if((millis() - lastUpdate) &amp;gt; Interval) // time to update&#xA;        {&#xA;            lastUpdate = millis();&#xA;            switch(ActivePattern)&#xA;            {&#xA;                case RAINBOW_CYCLE:&#xA;                    RainbowCycleUpdate();&#xA;                    break;&#xA;                case THEATER_CHASE:&#xA;                    TheaterChaseUpdate();&#xA;                    break;&#xA;                case COLOR_WIPE:&#xA;                    ColorWipeUpdate();&#xA;                    break;&#xA;                case SCANNER:&#xA;                    ScannerUpdate();&#xA;                    break;&#xA;                case FADE:&#xA;                    FadeUpdate();&#xA;            case FIRE:&#xA;                    RainbowCycleUpdate();   &#xA;                    break;&#xA;                default:&#xA;                    break;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    // Increment the Index and reset at the end&#xA;    void Increment()&#xA;    {&#xA;        if (Direction == FORWARD)&#xA;        {&#xA;           Index++;&#xA;           if (Index &amp;gt;= TotalSteps)&#xA;            {&#xA;                Index = 0;&#xA;                if (OnComplete != NULL)&#xA;                {&#xA;                    OnComplete(); // call the comlpetion callback&#xA;                }&#xA;            }&#xA;        }&#xA;        else // Direction == REVERSE&#xA;        {&#xA;            --Index;&#xA;            if (Index &amp;lt;= 0)&#xA;            {&#xA;                Index = TotalSteps-1;&#xA;                if (OnComplete != NULL)&#xA;                {&#xA;                    OnComplete(); // call the comlpetion callback&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    // Reverse pattern direction&#xA;    void Reverse()&#xA;    {&#xA;        if (Direction == FORWARD)&#xA;        {&#xA;            Direction = REVERSE;&#xA;            Index = TotalSteps-1;&#xA;        }&#xA;        else&#xA;        {&#xA;            Direction = FORWARD;&#xA;            Index = 0;&#xA;        }&#xA;    }&#xA;&#xA;    // Initialize for a RainbowCycle&#xA;    void RainbowCycle(uint8_t interval, direction dir = FORWARD)&#xA;    {&#xA;        ActivePattern = RAINBOW_CYCLE;&#xA;        Interval = interval;&#xA;        TotalSteps = 255;&#xA;        Index = 0;&#xA;        Direction = dir;&#xA;    }&#xA;&#xA;&#xA;    // Update the Rainbow Cycle Pattern&#xA;    void RainbowCycleUpdate()&#xA;    {&#xA;        for(int i=0; i&amp;lt; numPixels(); i++)&#xA;        {&#xA;            setPixelColor(i, Wheel(((i * 256 / numPixels()) + Index) &amp;amp; 255));&#xA;        }&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;    // Initialize for a Theater Chase&#xA;    void TheaterChase(uint32_t color1, uint32_t color2, uint8_t interval, direction dir = FORWARD)&#xA;    {&#xA;        ActivePattern = THEATER_CHASE;&#xA;        Interval = interval;&#xA;        TotalSteps = numPixels();&#xA;        Color1 = color1;&#xA;        Color2 = color2;&#xA;        Index = 0;&#xA;        Direction = dir;&#xA;   }&#xA;&#xA;    // Update the Theater Chase Pattern&#xA;    void TheaterChaseUpdate()&#xA;    {&#xA;        for(int i=0; i&amp;lt; numPixels(); i++)&#xA;        {&#xA;            if ((i + Index) % 3 == 0)&#xA;            {&#xA;                setPixelColor(i, Color1);&#xA;            }&#xA;            else&#xA;            {&#xA;                setPixelColor(i, Color2);&#xA;            }&#xA;        }&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;    // Initialize for a ColorWipe&#xA;    void ColorWipe(uint32_t color, uint8_t interval, direction dir = FORWARD)&#xA;    {&#xA;        ActivePattern = COLOR_WIPE;&#xA;        Interval = interval;&#xA;        TotalSteps = numPixels();&#xA;        Color1 = color;&#xA;        Index = 0;&#xA;        Direction = dir;&#xA;    }&#xA;&#xA;&#xA;    // Update the Color Wipe Pattern&#xA;    void ColorWipeUpdate()&#xA;    {&#xA;        setPixelColor(Index, Color1);&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;    // Initialize for a SCANNNER&#xA;    void Scanner(uint32_t color1, uint8_t interval)&#xA;    {&#xA;        ActivePattern = SCANNER;&#xA;        Interval = interval;&#xA;        TotalSteps = (numPixels() - 1) * 2;&#xA;        Color1 = color1;&#xA;        Index = 0;&#xA;    }&#xA;&#xA;    // Update the Scanner Pattern&#xA;    void ScannerUpdate()&#xA;    {&#xA;        for (int i = 0; i &amp;lt; numPixels(); i++)&#xA;        {&#xA;            if (i == Index)  // Scan Pixel to the right&#xA;            {&#xA;                 setPixelColor(i, Color1);&#xA;            }&#xA;            else if (i == TotalSteps - Index) // Scan Pixel to the left&#xA;            {&#xA;                 setPixelColor(i, Color1);&#xA;            }&#xA;            else // Fading tail&#xA;            {&#xA;                 setPixelColor(i, DimColor(getPixelColor(i)));&#xA;            }&#xA;        }&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;    // Initialize for a Fade&#xA;    void Fade(uint32_t color1, uint32_t color2, uint16_t steps, uint8_t interval, direction dir = FORWARD)&#xA;    {&#xA;        ActivePattern = FADE;&#xA;        Interval = interval;&#xA;        TotalSteps = steps;&#xA;        Color1 = color1;&#xA;        Color2 = color2;&#xA;        Index = 0;&#xA;        Direction = dir;&#xA;    }&#xA;&#xA;    // Update the Fade Pattern&#xA;    void FadeUpdate()&#xA;    {&#xA;        // Calculate linear interpolation between Color1 and Color2&#xA;        // Optimise order of operations to minimize truncation error&#xA;        uint8_t red = ((Red(Color1) * (TotalSteps - Index)) + (Red(Color2) * Index)) / TotalSteps;&#xA;        uint8_t green = ((Green(Color1) * (TotalSteps - Index)) + (Green(Color2) * Index)) / TotalSteps;&#xA;        uint8_t blue = ((Blue(Color1) * (TotalSteps - Index)) + (Blue(Color2) * Index)) / TotalSteps;&#xA;&#xA;        ColorSet(Color(red, green, blue));&#xA;        show();&#xA;        Increment();&#xA;    }&#xA;&#xA;&#xA;    // Calculate 50% dimmed version of a color (used by ScannerUpdate)&#xA;    uint32_t DimColor(uint32_t color)&#xA;    {&#xA;        // Shift R, G and B components one bit to the right&#xA;        uint32_t dimColor = Color(Red(color) &amp;gt;&amp;gt; 1, Green(color) &amp;gt;&amp;gt; 1, Blue(color) &amp;gt;&amp;gt; 1);&#xA;        return dimColor;&#xA;    }&#xA;&#xA;    // Set all pixels to a color (synchronously)&#xA;    void ColorSet(uint32_t color)&#xA;    {&#xA;        for (int i = 0; i &amp;lt; numPixels(); i++)&#xA;        {&#xA;            setPixelColor(i, color);&#xA;        }&#xA;        show();&#xA;    }&#xA;&#xA;    // Returns the Red component of a 32-bit color&#xA;    uint8_t Red(uint32_t color)&#xA;    {&#xA;        return (color &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;    // Returns the Green component of a 32-bit color&#xA;    uint8_t Green(uint32_t color)&#xA;    {&#xA;        return (color &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;    // Returns the Blue component of a 32-bit color&#xA;    uint8_t Blue(uint32_t color)&#xA;    {&#xA;        return color &amp;amp; 0xFF;&#xA;    }&#xA;&#xA;    // Input a value 0 to 255 to get a color value.&#xA;    // The colours are a transition r - g - b - back to r.&#xA;    uint32_t Wheel(byte WheelPos)&#xA;    {&#xA;        WheelPos = 255 - WheelPos;&#xA;        if(WheelPos &amp;lt; 85)&#xA;        {&#xA;            return Color(255 - WheelPos * 3, 0, WheelPos * 3);&#xA;        }&#xA;        else if(WheelPos &amp;lt; 170)&#xA;        {&#xA;            WheelPos -= 85;&#xA;            return Color(0, WheelPos * 3, 255 - WheelPos * 3);&#xA;        }&#xA;        else&#xA;        {&#xA;            WheelPos -= 170;&#xA;            return Color(WheelPos * 3, 255 - WheelPos * 3, 0);&#xA;        }&#xA;    }&#xA;&#xA;   // brightness, need some improvements probably&#xA;   void incbrigtness() {&#xA;   if (b &amp;gt;= 255) {&#xA;      b = 255;&#xA;   setBrightness(b);}&#xA;   else {b = b + 10;   &#xA;   setBrightness(b);}&#xA;   }&#xA;&#xA;   void decbrigtness() {&#xA;   if (b &amp;lt;= 5) {&#xA;      b = 5;&#xA;   setBrightness(b);}&#xA;   else {b = b - 10;   &#xA;   setBrightness(b);}&#xA;   }&#xA;&#xA;};&#xA;&#xA;void Ring1Complete();&#xA;void Ring2Complete();&#xA;&#xA;void receiveEvent(int numBytes) {//decode the ir signal&#xA;  byte byte1 = Wire.read();&#xA;  byte byte2 = Wire.read();&#xA;  irCode = byte2;&#xA;  irCode = irCode &amp;lt;&amp;lt; 8;&#xA;  irCode = irCode | byte1;&#xA;}                                                                        &#xA;&#xA;// Define some NeoPatterns for the two rings and the stick&#xA;//  as well as some completion routines&#xA;NeoPatterns Ring1(24, 6, NEO_GRB + NEO_KHZ800, &amp;amp;Ring1Complete); // led parameters&#xA;NeoPatterns Ring2(24, 7, NEO_GRB + NEO_KHZ800, &amp;amp;Ring2Complete);    &#xA;&#xA;// Initialize everything and prepare to start                                             &#xA;void setup()&#xA;{&#xA;   Serial.begin(9600);&#xA;   Serial.println(&quot;my-main-program starting!&quot;);&#xA;   Wire.begin(I2C_SLAVE_ADDRESS);&#xA;   Wire.onReceive(receiveEvent);&#xA;   Serial.println(&quot;my-main-program successfully started!&quot;);&#xA; }&#xA;// Main loop                                                   &#xA;void loop()&#xA;{&#xA;    // Update the rings.&#xA;   if (irCode) {             //Reads the ir code&#xA;    handleButton(irCode);&#xA;    irCode = 0;&#xA;  }&#xA; Ring1.Update();&#xA; Ring2.Update();&#xA; }&#xA;&#xA;void handleButton(unsigned int irCode) {&#xA;  switch (irCode) {&#xA;   case BUTTON_UP:      // button up  will control led stip 1, button 2 will control let strip 2, button 3 both.&#xA;      t = 1;&#xA;     Serial.println(t);    &#xA;     break;&#xA;   case BUTTON_DOWN:&#xA;      t = 2;&#xA;     Serial.println(t);&#xA;      break;&#xA;   case BUTTON_VOL:&#xA;     t = 0;&#xA;      Serial.println(t);&#xA;     break;&#xA;   case BUTTON_1:&#xA;     if (t == 1) {    // this also needs some improvements&#xA;      Serial.println(t); &#xA;     Ring1.TheaterChase(Ring1.Color(0,255,0), Ring1.Color(0,0,50), 100);&#xA;      }&#xA;     else if (t == 2) {&#xA;     Serial.println(t); &#xA;     Ring2.TheaterChase(Ring1.Color(255,0,0), Ring1.Color(0,50,0), 100);&#xA;      }&#xA;     else {      // some random effects for testing&#xA;     Serial.println(t); &#xA;      Ring1.TheaterChase(Ring1.Color(0,0,255), Ring1.Color(50,0,0), 100);&#xA;     Ring2.TheaterChase(Ring1.Color(0,0,255), Ring1.Color(50,0,0), 100);&#xA;      }&#xA;   break;&#xA;    case BUTTON_2:&#xA;      Serial.println(&quot;2&quot;);&#xA;       Ring1.Scanner(Ring1.Color(255,0,0), 55);&#xA;     break;&#xA;    case BUTTON_3:&#xA;     Ring1.ColorWipe(Ring1.Color(0,255,255), 55);&#xA;     Serial.println(&quot;3&quot;);&#xA;      break;&#xA;    case BUTTON_4:&#xA;      Ring1.Scanner(Ring1.Color(0,255,255), 55);&#xA;     Serial.println(&quot;4&quot;);&#xA;      break;&#xA;    case BUTTON_5:&#xA;      Serial.println(&quot;5&quot;);&#xA;      break;&#xA;    case BUTTON_6:&#xA;      Serial.println(&quot;6&quot;);&#xA;      break;&#xA;    case BUTTON_7:&#xA;      Serial.println(&quot;7&quot;);&#xA;      break;&#xA;    case BUTTON_8:         //  test the brightness here.&#xA;   Ring1.incbrigtness();&#xA;   Serial.println(b);&#xA;     break;&#xA;    case BUTTON_9:&#xA;   Ring1.decbrigtness();&#xA;   Serial.println(b);&#xA;     break;&#xA;    default:&#xA;      Serial.print(&quot;Unrecognized code received: 0x&quot;);&#xA;      Serial.println(irCode, HEX);&#xA;      break;       &#xA;  }     &#xA;}&#xA;&#xA;&#xA;//------------------------------------------------------------&#xA;//Completion Routines - get called on completion of a pattern&#xA;//------------------------------------------------------------&#xA;&#xA;// Ring1 Completion Callback&#xA;void Ring1Complete() //dont really need to do anything specific after loop ended so should go back to update.&#xA;{Ring1.Update(); }&#xA;&#xA;void Ring2Complete()&#xA;{Ring2.Update(); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem:&#xA;What I need is help, how to restructure 2 different effects. to fit into the above code. Loops replaced wilth millis() and delay with an updater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;here is the first, fire code by danesparza:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#define PIN 6&#xA;&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(29, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.setBrightness(brightness);&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  //  Uncomment one of these RGB (Red, Green, Blue) values to&#xA;  //  set the base color of the flame.  The color will flickr&#xA;  //  based on the initial base color&#xA;&#xA;  //  Regular (orange) flame:&#xA;  //  int r = 226, g = 121, b = 35;&#xA;&#xA;  //  Purple flame:&#xA;  //  int r = 158, g = 8, b = 148;&#xA;&#xA;  //  Green flame:&#xA;  int r = 74, g = 150, b = 12;&#xA;&#xA;  //  Flicker, based on our initial RGB values&#xA;  for(int i=0; i&amp;lt;strip.numPixels(); i++) {&#xA;    int flicker = random(0,55);&#xA;    int r1 = r-flicker;&#xA;    int g1 = g-flicker;&#xA;    int b1 = b-flicker;&#xA;    if(g1&amp;lt;0) g1=0;&#xA;    if(r1&amp;lt;0) r1=0;&#xA;    if(b1&amp;lt;0) b1=0;&#xA;    strip.setPixelColor(i,r1,g1, b1);&#xA;  }&#xA;  strip.show();&#xA;&#xA;  //  Adjust the delay here, if you'd like.  Right now, it randomizes the &#xA;  //  color switch delay to give a sense of realism&#xA;  delay(random(10,113));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And a ripple effect that needs a restructure by suhajdab&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#define PIN 2&#xA;#define Pixels 24&#xA;#define BG 1&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;&#xA;int color;&#xA;int center = 0;&#xA;int step = -1;&#xA;int maxSteps = 16;&#xA;float fadeRate = 0.6;&#xA;int diff;&#xA;&#xA;//background color&#xA;uint32_t currentBg = random(256);&#xA;uint32_t nextBg = currentBg;&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show(); // Initialize all pixels to 'off'&#xA;}&#xA;&#xA;void loop () {&#xA;  ripple();&#xA;}&#xA;&#xA;void ripple() {&#xA;  if (BG){&#xA;    if (currentBg == nextBg) {&#xA;      nextBg = random(256);&#xA;    } &#xA;    else if (nextBg &amp;gt; currentBg) {&#xA;      currentBg++;&#xA;    } else {&#xA;      currentBg--;&#xA;    }&#xA;    for(uint16_t l = 0; l &amp;lt; Pixels; l++) {&#xA;      strip.setPixelColor(l, Wheel(currentBg, 0.1));&#xA;    }&#xA;  } else {&#xA;    for(uint16_t l = 0; l &amp;lt; Pixels; l++) {&#xA;      strip.setPixelColor(l, 0, 0, 0);&#xA;    }&#xA;  }&#xA;&#xA;&#xA;  if (step == -1) {&#xA;    center = random(Pixels);&#xA;    color = random(256);&#xA;    step = 0;&#xA;  }&#xA;&#xA;&#xA;&#xA;  if (step == 0) {&#xA;    strip.setPixelColor(center, Wheel(color, 1));&#xA;    step ++;&#xA;  } &#xA;  else {&#xA;    if (step &amp;lt; maxSteps) {&#xA;      strip.setPixelColor(wrap(center + step), Wheel(color, pow(fadeRate, step)));&#xA;      strip.setPixelColor(wrap(center - step), Wheel(color, pow(fadeRate, step)));&#xA;      if (step &amp;gt; 3) {&#xA;        strip.setPixelColor(wrap(center + step - 3), Wheel(color, pow(fadeRate, step - 2)));&#xA;        strip.setPixelColor(wrap(center - step + 3), Wheel(color, pow(fadeRate, step - 2)));&#xA;      }&#xA;      step ++;&#xA;    } &#xA;    else {&#xA;      step = -1;&#xA;    }&#xA;  }&#xA;&#xA;  strip.show();&#xA;  delay(50);&#xA;}&#xA;&#xA;&#xA;int wrap(int step) {&#xA;  if(step &amp;lt; 0) return Pixels + step;&#xA;  if(step &amp;gt; Pixels - 1) return step - Pixels;&#xA;  return step;&#xA;}&#xA;&#xA;&#xA;&#xA;// Input a value 0 to 255 to get a color value.&#xA;// The colours are a transition r - g - b - back to r.&#xA;uint32_t Wheel(byte WheelPos, float opacity) {&#xA;&#xA;  if(WheelPos &amp;lt; 85) {&#xA;    return strip.Color((WheelPos * 3) * opacity, (255 - WheelPos * 3) * opacity, 0);&#xA;  } &#xA;  else if(WheelPos &amp;lt; 170) {&#xA;    WheelPos -= 85;&#xA;    return strip.Color((255 - WheelPos * 3) * opacity, 0, (WheelPos * 3) * opacity);&#xA;  } &#xA;  else {&#xA;    WheelPos -= 170;&#xA;    return strip.Color(0, (WheelPos * 3) * opacity, (255 - WheelPos * 3) * opacity);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, can someone help me how to include these 2 effects based on the tutorial (unfortunately not much help on my current skill level) to the first code? Much appreciated.&lt;/p&gt;&#xA;" OwnerUserId="24116" LastActivityDate="2023-07-31T02:03:35.390" Title="Help me restructure code for multitasking Neopixel + IR remote + arduino" Tags="|arduino-uno|millis|neopixel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26616" PostTypeId="2" ParentId="26607" CreationDate="2016-07-22T12:14:47.383" Score="1" Body="&lt;p&gt;You see in the second part is a &lt;code&gt;void ripple(){&lt;/code&gt;, which is just like a &lt;code&gt;void loop(){&lt;/code&gt; but only runs when it is called.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can merge these codes by placing an if-statement after your &lt;code&gt;void loop(){&lt;/code&gt; to check if it needs to run the loop or the ripple. You can simply use a boolean for this. For example:`&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  if(state == true){  //I've called the boolean state&#xA;    ripple();  //this calls the ripple function, and runs void ripple()&#xA;  }&#xA;&#xA;  //here's the rest of the loop, this runs if state != true.&#xA;  //you can change state wherever you'd like.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could even create a new function based on what's currently in your loop. Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop(){&#xA;  if(state == 1){&#xA;    originalLoop(); //what's originally in your loop, but now as a separate function&#xA;  }&#xA;  else if(state == 2){&#xA;    ripple();&#xA;  }&#xA;&#xA;  //rest of the loop in which you can change state to 1 or 2 however you like&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope this helps a bit :)&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-22T12:14:47.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26618" PostTypeId="1" AcceptedAnswerId="26620" CreationDate="2016-07-22T12:49:33.233" Score="0" ViewCount="4512" Body="&lt;p&gt;I am having difficulties programming what should be a simple sketch that gets my &lt;strong&gt;stepper motor to run at one step per second indefinitely at the press of a button and then stops at the press of another button.&lt;/strong&gt; I am using the &lt;em&gt;Bounce2.h&lt;/em&gt; and &lt;em&gt;accelstepper.h&lt;/em&gt; libraries and have been unable to figure out how to do it. Any help would be greatly appreciated, and as for hardware I am using a &lt;strong&gt;&lt;em&gt;NEMA 23 High Torque Stepper Motor&lt;/em&gt;&lt;/strong&gt; connected through a &lt;strong&gt;&lt;em&gt;M542T Motor Driver&lt;/em&gt;&lt;/strong&gt; powered by a &lt;strong&gt;&lt;em&gt;Switching Power Supply&lt;/em&gt;&lt;/strong&gt; and running on an &lt;strong&gt;&lt;em&gt;Arduino UNO.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Attatched find my code, and thank you so much for the help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Bounce2.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;#include &amp;lt;AccelStepper.h&amp;gt;&#xA;&#xA;AccelStepper stepper(1, 9, 8); // initiate stepper motor&#xA;&#xA;//int buttonPresses = 0;&#xA;const byte ButtonPin = 10;&#xA;const byte LedPin = 13; // for debugging and visualization&#xA;&#xA;Bounce button;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  button.attach(ButtonPin);&#xA;  pinMode(LedPin, OUTPUT);&#xA;  stepper.setSpeed(1);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (button.rose()) {&#xA;    stepper.runSpeed();&#xA;    digitalWrite(LedPin, HIGH);&#xA;    //    buttonPresses++; // count presses of button and print to monitor&#xA;    //    Serial.print(&quot;Number of Button &quot;);&#xA;    //    Serial.print(&quot;Presses = &quot;);&#xA;    //    Serial.println(buttonPresses);&#xA;  }&#xA;  else {&#xA;    button.update();&#xA;    digitalWrite(LedPin, LOW);&#xA;    if (button.fell()) {&#xA;      stepper.stop();&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;As of now, a button press runs the motor at 1 step/second, but a second press or any subsequent presses thereafter do nothing to stop the motor. Thanks so much!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;!!EDIT!!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Upon adding a boolean buttonState and setting it to LOW in the setup and changing my void loop() code to look like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  button.update();&#xA;  if (button.rose() == true &amp;amp;&amp;amp; buttonState == LOW) {&#xA;    stepper.runSpeed();&#xA;    digitalWrite(LedPin, HIGH);&#xA;    buttonState = HIGH;&#xA;  }&#xA;  else {&#xA;    if (button.fell() == true &amp;amp;&amp;amp; buttonState == HIGH) {&#xA;      stepper.stop();&#xA;      buttonState = LOW;&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I know get a step every button press. Just thought it may help in answering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I I tried pulling the runSpeed() out of the loop and adding                                                            &lt;code&gt;if (buttonState = HIGH){stepper.runSpeed();}&lt;/code&gt; &#xA;but that now just runs the stepperMotor constantly and at variable speed and will not turn it off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT 3 and Working Code&lt;/strong&gt;&#xA;Thank you Janw for the help. I realized my fault in calling the runSpeed function within the if statement. Further, I also needed to change button.fell() to button.rose() since button.fell() returns true when the button is released, so basically I was stopping the motor everytime I let go of the button. Here is the final, and working void loop() in case anyone runs into a similar problem in the future:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  button.update();&#xA;  if (button.rose() == true &amp;amp;&amp;amp; buttonState == LOW) {&#xA;    digitalWrite(LedPin, HIGH);&#xA;    buttonState = HIGH;&#xA;  }&#xA;  else {&#xA;    if (button.rose() == true &amp;amp;&amp;amp; buttonState == HIGH) {&#xA;      stepper.stop();&#xA;      buttonState = LOW;&#xA;    }&#xA;  }&#xA;  if (buttonState == HIGH) {&#xA;    stepper.setSpeed(1);&#xA;    stepper.runSpeed();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="21627" LastEditDate="2016-07-25T08:09:49.377" LastActivityDate="2016-07-25T08:09:49.377" Title="Stepper Motor Button Press" Tags="|arduino-uno|timers|button|stepper|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26619" PostTypeId="1" AcceptedAnswerId="26621" CreationDate="2016-07-22T13:26:47.363" Score="0" ViewCount="479" Body="&lt;p&gt;Sorry for my code is long and my English is not good.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm working with &lt;strong&gt;8x8x8 LED cube&lt;/strong&gt; project using &lt;strong&gt;Arduino nano&lt;/strong&gt;. I tried to understand code, but I don't understand how &lt;code&gt;cube[][]&lt;/code&gt; data write on &lt;code&gt;pins&lt;/code&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I just want to know, how write the data from &lt;code&gt;cube[8][8]&lt;/code&gt; to hardware using &lt;strong&gt;SPI&lt;/strong&gt;. code download using &lt;a href=&quot;http://www.instructables.com/id/JolliCube-an-8x8x8-LED-Cube-SPI/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code is here :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define AXIS_X 1&#xA;#define AXIS_Y 2&#xA;#define AXIS_Z 3&#xA;#define REFRESH_RATE 120&#xA;&#xA;int CUBE_SIZE = 8;&#xA;int SPI_CS = 10;// This SPI Chip Select pin controls the MAX72xx&#xA;byte value[8];&#xA;&#xA;volatile unsigned char cube[8][8];&#xA;volatile int current_layer = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin (115200);&#xA;  Serial.println(&quot;jolliFactory 8x8x8 jolliCube Demo example 1.0&quot;);              &#xA;&#xA;  pinMode(SPI_CS, OUTPUT);&#xA;&#xA;  SPI.begin();&#xA;&#xA;  maxTransferAll(0x0F, 0x00);   // 00 - Turn off Test mode&#xA;  maxTransferAll(0x09, 0x00);   // Register 09 - BCD Decoding  // 0 = No decoding&#xA;  maxTransferAll(0x0B, 0x07);   // Register B - Scan limit 1-7  // 7 = All LEDS&#xA;  maxTransferAll(0x0C, 0x01);   // 01 = on 00 = Power saving mode or shutdown&#xA;  maxTransferAll(0x0A, 0x0F);   // Set Brightness Intensity&#xA;&#xA;  setUpInterrupts();&#xA;}&#xA;&#xA;// Get the current status of a voxel&#xA;unsigned char getvoxel(int x, int y, int z)&#xA;{&#xA;    if (inrange(x,y,z))&#xA;    {&#xA;        if (cube[z][y] &amp;amp; (1 &amp;lt;&amp;lt; x))&#xA;        {&#xA;            return 0x01;&#xA;        } else&#xA;        {&#xA;            return 0x00;&#xA;        }&#xA;    } else&#xA;    {&#xA;        return 0x00;&#xA;    }&#xA;}&#xA;&#xA;void maxTransferAll(uint8_t address, uint8_t value)&#xA;{&#xA;  digitalWrite(SPI_CS, LOW); &#xA;&#xA;    for ( int c=1; c&amp;lt;= CUBE_SIZE;c++) {&#xA;        SPI.transfer(address);&#xA;        SPI.transfer(value);&#xA;    }&#xA;&#xA;  digitalWrite(SPI_CS, HIGH); &#xA;}&#xA;&#xA;void maxTransferOne(uint8_t whichMax, uint8_t address, uint8_t value)&#xA;{&#xA;  byte noop_reg = 0x00;    //max72xx No op register&#xA;  byte noop_value = 0x00;  //value&#xA;&#xA;  digitalWrite(SPI_CS, LOW); &#xA;&#xA;  for (int i=CUBE_SIZE; i&amp;gt;0; i--)   // Loop through our number of Max72xx ICs &#xA;  {&#xA;    if (i==whichMax)&#xA;    {&#xA;      SPI.transfer(address);&#xA;      SPI.transfer(value);&#xA;    }&#xA;    else&#xA;    {&#xA;      SPI.transfer(noop_reg);&#xA;      SPI.transfer(noop_value);&#xA;    }&#xA;  }&#xA;&#xA;  digitalWrite(SPI_CS, HIGH);&#xA;}&#xA;&#xA;void maxTransferLEDCube(uint8_t address)&#xA;{&#xA;  digitalWrite(SPI_CS, LOW); &#xA;&#xA;  for (int i=0; i&amp;lt;CUBE_SIZE; i++)   // Loop through our number of Max72xx ICs &#xA;  {&#xA;      SPI.transfer(address);&#xA;      SPI.transfer(value[CUBE_SIZE-i-1]);&#xA;  }&#xA;&#xA;  digitalWrite(SPI_CS, HIGH);&#xA;}&#xA;&#xA;void setUpInterrupts()&#xA;{&#xA;  cli();//stop interrupts while we set them up&#xA;  //set up an interrupt with timer1&#xA;  TCCR1A = 0;&#xA;  TCCR1B = 0;&#xA;  TCNT1  = 0;&#xA;  OCR1A = (16000000/REFRESH_RATE/1024/CUBE_SIZE -1);&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; WGM12);&#xA;  // Set to CS10 and CS12 so we have the 1024&#xA;  TCCR1B |= (1 &amp;lt;&amp;lt; CS12) | (1 &amp;lt;&amp;lt; CS10);  &#xA;  TIMSK1 |= (1 &amp;lt;&amp;lt; OCIE1A);&#xA;  sei();//re-allow interrupts &#xA;}&#xA;&#xA;ISR(TIMER1_COMPA_vect)&#xA;{   &#xA;  for(byte y = 0 ; y &amp;lt; CUBE_SIZE ; y++)&#xA;  {&#xA;    byte b = 0;&#xA;&#xA;    for(byte x = 0 ; x &amp;lt; CUBE_SIZE ; x++)&#xA;    {&#xA;      //form data byte&#xA;      b = b &amp;lt;&amp;lt; 1;&#xA;&#xA;      if (getvoxel(x,y,current_layer)==1)&#xA;      {&#xA;        b |= 1;        &#xA;      }&#xA;    }&#xA;        value[y] = b;    &#xA;  }&#xA;&#xA;  maxTransferLEDCube(CUBE_SIZE - current_layer);&#xA;&#xA;  current_layer++;&#xA;&#xA;  if (current_layer == 8)&#xA;    current_layer = 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24127" LastActivityDate="2016-07-22T14:30:59.967" Title="Data transfer using SPI" Tags="|arduino-nano|c|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26620" PostTypeId="2" ParentId="26618" CreationDate="2016-07-22T14:26:39.547" Score="0" Body="&lt;p&gt;You will probably get only 1 step each button press because your &lt;em&gt;runSpeed()&lt;/em&gt; is within the &lt;em&gt;if (button.rose() == true &amp;amp;&amp;amp; buttonState == LOW)&lt;/em&gt;-statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The &lt;em&gt;runSpeed()&lt;/em&gt; needs to be called every loop to check if the motor needs to step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A simple way to change this is to set a boolean to true or false if you check your button and add something like this pseudocode:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(motorRun == true) stepper.runSpeed();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23002" LastActivityDate="2016-07-22T14:26:39.547" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26621" PostTypeId="2" ParentId="26619" CreationDate="2016-07-22T14:30:59.967" Score="1" Body="&lt;p&gt;First, you need to know how the LEDs are arranged. There are 8 layers, each with 8 rows, each with 8 LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each LED is represented as a single &lt;em&gt;bit&lt;/em&gt; inside &lt;code&gt;unsigned char cube[8][8];&lt;/code&gt; - the first &lt;code&gt;[8]&lt;/code&gt; is the array of layers, the second &lt;code&gt;[8]&lt;/code&gt; is the array of rows, and the &lt;code&gt;unsigned char&lt;/code&gt; holds 8 bits to represent the state of the 8 LEDs in that row.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each LED layer has one MAX7219 8x8 LED Matrix Controller. To tell it what to do you need to give it a Command byte and a Data byte. So to tell it to light up LEDs 1, 2, and 7 on the fourth row, you need to tell it &lt;code&gt;0x04 0x86&lt;/code&gt;. You send this command by setting &lt;code&gt;CS&lt;/code&gt; &lt;code&gt;LOW&lt;/code&gt;, sending the 16 bits of the Command+Data, then setting &lt;code&gt;CS&lt;/code&gt; &lt;code&gt;HIGH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each MAX7219 is connected one after the other in an SPI string. To command all of them at once you need to set &lt;code&gt;CS&lt;/code&gt; &lt;code&gt;LOW&lt;/code&gt;, send 16 bits for each MAX7219 (128 bits in all), then set &lt;code&gt;CS&lt;/code&gt; &lt;code&gt;HIGH&lt;/code&gt;. If you only want to command one MAX7219, you need to send a &lt;code&gt;NOP&lt;/code&gt; Command+Data (&lt;code&gt;0x00 0x00&lt;/code&gt;) to all the others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way the program works is:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;setup()&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;a. Initialise the &lt;code&gt;Serial&lt;/code&gt; port, and print a message.&lt;br&gt;&#xA;b. Set the &lt;code&gt;CS&lt;/code&gt; pin as an &lt;code&gt;OUTPUT&lt;/code&gt;, then initialise &lt;code&gt;SPI&lt;/code&gt;.&lt;br&gt;&#xA;c. Initialise all the MAX7219 chips by sending a series of commands -&lt;br&gt;&#xA;the same Command+Data to each of them (&lt;code&gt;maxTransferAll()&lt;/code&gt;).&lt;br&gt;&#xA;d. Initialise the Timer interrupt (&lt;code&gt;setUpInterrupts()&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;loop()&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;&#xA;This isn't shown in the code. Presumably it alters the &lt;code&gt;cube[8][8]&lt;/code&gt; array to make the special effects.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;TIMER1_COMPA_vect&lt;/code&gt;&lt;/strong&gt; (the interrupt handler)&lt;br&gt;&#xA;Every time the timer ticks, the handler will command all of the MAX7219s to show the next row of LEDs.  This will last until the next timer tick, when the next row will be displayed. If this is done fast enough, the human eye's &quot;persistence of vision&quot; will not see the rows flickering.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;For each row (`y`) in the `cube` array&#xA;   Set `b` to 0&#xA;   For each bit ('x') in the `cube` data&#xA;      If the bit is set (`getvoxel(...)`) set a bit in `b`.&#xA;   Store `b` in the `value[y]` array&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;value&lt;/code&gt; now holds the bytes needed as Data for the next row for each of the MAX7219 chips.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Send value over SPI using `maxTransferLEDCube(...)`&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the cube displays the same row for each layer simultaneously, the Command doesn't have to change, only the Data does. That's what the &lt;code&gt;value&lt;/code&gt; array holds: the Data to be sent to each MAX7219 chip.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-22T14:30:59.967" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26623" PostTypeId="1" AcceptedAnswerId="26624" CreationDate="2016-07-22T15:44:59.697" Score="0" ViewCount="623" Body="&lt;p&gt;Do I need third party s/w to export to a spreadsheet? I have built a heat flux sensor meter and wish to log my data.&lt;/p&gt;&#xA;" OwnerUserId="24096" LastActivityDate="2018-06-04T19:08:05.750" Title="Exporting ADC data to excel" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26624" PostTypeId="2" ParentId="26623" CreationDate="2016-07-22T16:11:36.817" Score="1" Body="&lt;p&gt;You need some way of getting the data from the Arduino to the PC. There's a number of ways of doing it depending on what resources you have available.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Through serial as CSV&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This entails printing the data to the serial port in CSV format then using some software on the PC to capture that and save it to a file. That could be as simple as a good terminal emulator that provides &quot;capture to file&quot; or similar, or you could write your own program in your favourite programming language.  This method is essentially free.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To an SD card&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Writing the data as a CSV file onto an SD card directly attached to the Arduino can be quite convenient. It means you can then just take the SD card with the data on it and slip it into your computer to import the data as you would with any other file.  It needs an SD card shield or breakout board attaching to the Arduino&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Through the network&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If your Arduino has a network connection of some form (WiFi shield, Ethernet shield, etc) you could POST the data to a web page running on your PC and store it in a CSV file for later importing. Probably the most expensive option but it does mean you can do things with the data &quot;live&quot; as it comes in.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-22T16:11:36.817" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26625" PostTypeId="1" CreationDate="2016-07-22T16:15:07.103" Score="1" ViewCount="13158" Body="&lt;p&gt;I have been using my ESP8266 module with my Arduino on my university's Wi-Fi network, which only requires a password to log on to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The university will soon terminate that Wi-Fi network and replace it with one that requires a username and password to log on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would that AT command be to connect to such a network?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I have since found out that the university has changed the network so that a user can &quot;connect&quot; to the network and then enter their university id/password in a captive portal to gain internet access (and perhaps other features of the network). Also, I have since learned how to overwrite the firmware on my esp-01 so that I no longer need to use the AT commands -- in fact, I can program it in the Arduino IDE just as I would with another esp8266-based device, such as the NodeMCU. &lt;/p&gt;&#xA;" OwnerUserId="24134" LastEditorUserId="24134" LastEditDate="2017-06-10T18:39:10.820" LastActivityDate="2017-11-26T01:48:15.753" Title="ESP8266 - AT Command for Network Requiring Username AND Password" Tags="|esp8266|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26631" PostTypeId="2" ParentId="26625" CreationDate="2016-07-22T17:39:03.830" Score="2" Body="&lt;p&gt;We can't tell without more information but it sounds rather like you will need a [WiFi_SSID, WiFi_PASSWORD] pair for the ESP to connect to the WiFi, and a [Network_USERNAME, Network_USERPASSWORD] pair for their network to let you use the network (as if you were logging onto it by hand from a terminal).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, you'd provide the first pair as you do now, with the AT+CWJAP... command, to get your device connected to the WiFi. For the second pair, your Arduino will probably need to interact with a user logon screen to provide the second pair. You'll need to get those details from the school's IT department, and possibly mimic a terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&#xA;As above, you need to find out whether the network requires 2 sets of credentials - the SSID and WPA2 key and network username and password. If it requires the latter, then your ESP can get you onto the WiFi but your Arduino will then have to mimic a user sitting at a terminal - read the network ID and Password challenges and provide the appropriate responses. Without know that, you can't know how to write the login code, nor can we. It sounds as if there are people on site who have already done what you're trying to do. They and their experience can be far more helpful than we, who have no knowledge of the school network.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2017-06-10T19:05:44.197" LastActivityDate="2017-06-10T19:05:44.197" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26632" PostTypeId="1" CreationDate="2016-07-22T17:48:47.360" Score="0" ViewCount="498" Body="&lt;p&gt;Is there a usb signal I can send on TX that will generate a response from the computer on the RX only if the computer is active/not a wall usb power supply? I'm trying to use the Remote library when a button is pressed and sometimes it won't work because the computer is off/asleep/etc and in those instances I would like the arduino to behave differently but because I have no way of knowing if the USB power is coming from the wall or passively from a computer that's off or actively from a computer that's on, I can't know what behavior to take. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be clear about the application in mind: Right now I have a device that sends keyboard signals to my computer using a modified version of Stefan Jones' modified &lt;a href=&quot;https://github.com/stefanjones/Arduino/tree/master/hardware/arduino/cores/arduino&quot; rel=&quot;nofollow&quot;&gt;USBAPI.h and HID.cpp files.&lt;/a&gt; It works fine but if you restart the computer you have to manually unplug and replug in the arduino to get it to work again. This is necessary every restart, is rather annoying, and adds unnecessary wear to the connector. This is also necessary if the arduino is connected before the OS has loaded. Additionally there are some LEDs on the device (not talking about the diagnostic lights on the arduino itself) that stay lit up at night even when the computer is off. If I could detect when the computer is off/unconnected it would be trivial to fix this.&lt;/p&gt;&#xA;" OwnerUserId="20273" LastEditorUserId="20273" LastEditDate="2016-08-01T15:10:31.887" LastActivityDate="2016-08-01T18:01:11.983" Title="Listen for USB &quot;TX signal received&quot; response on RX" Tags="|usb|arduino-micro|atmega32u4|" AnswerCount="3" CommentCount="6" ClosedDate="2016-08-01T11:02:01.410" ContentLicense="CC BY-SA 3.0" />
  <row Id="26633" PostTypeId="2" ParentId="26623" CreationDate="2016-07-22T18:24:09.043" Score="0" Body="&lt;p&gt;Use tabs to separate columns of data, and newlines between each row. &#xA;Then you can copy the serial output, and paste it into Excel.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2018-06-04T19:08:05.750" LastActivityDate="2018-06-04T19:08:05.750" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="26634" PostTypeId="1" AcceptedAnswerId="26636" CreationDate="2016-07-22T19:22:49.217" Score="1" ViewCount="88" Body="&lt;p&gt;I'm getting confused by the Arduino terminologies:  shield, breakout, module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this MicroView an Arduino compatible shield that will plug into Arduino's or Adafruit's Uno?&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2018-03-24T20:56:44.490" Title="Is Sparkfun's MicroView OLED Arduino module a shield?" Tags="|arduino-uno|shields|display|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26636" PostTypeId="2" ParentId="26634" CreationDate="2016-07-22T20:02:04.340" Score="1" Body="&lt;p&gt;No, MicroView is not an Arduino shield, so you can't plug that into any Arduino. Arduino Uno and MicroView are developed based on Atmega328 controller. So it is 100% code compatible with Arduino Uno, means the code that runs on an Arduino Uno will also be able to run on the MicroView.&lt;/p&gt;&#xA;" OwnerUserId="24064" LastEditorUserId="24064" LastEditDate="2018-03-24T20:56:44.490" LastActivityDate="2018-03-24T20:56:44.490" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26637" PostTypeId="1" CreationDate="2016-07-22T20:50:52.953" Score="1" ViewCount="1158" Body="&lt;p&gt;I've never much issue importing a library to my master sketchbook location, restarting Arduino, then using the library examples. Today is a different story:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I'm loading &lt;a href=&quot;https://github.com/jantje/ArduinoLibraries/tree/master/RCLib&quot; rel=&quot;nofollow&quot;&gt;RCLib&lt;/a&gt; which is part of this &lt;a href=&quot;https://github.com/jantje/ArduinoLibraries&quot; rel=&quot;nofollow&quot;&gt;ArduinoLibraries&lt;/a&gt; family&lt;/li&gt;&#xA;&lt;li&gt;RCLib requires &lt;a href=&quot;https://github.com/GreyGnome/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;PinChangeInt&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;So everything is in my sketchbook location right? &lt;code&gt;Arduino &amp;gt; Preferences &amp;gt; Sketchbook Location&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still I'm getting compiler errors about missing libraries:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/Users/Jackson/Documents/Arduino/ArduinoLibraries-master/RCLib/Examples/Maga6ChanelsA8_A13/Maga6ChanelsA8_A13.ino:7:86: fatal error: PinChangeInt.h: No such file or directory&#xA; #include &quot;PinChangeInt.h&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I've even tried &lt;code&gt;#include &amp;lt;PinChangeInt.h&amp;gt;&lt;/code&gt; Which makes more sense since this is a system library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What is going on here?&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The sketch I'm trying to run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**This is an example of using the RCLib with a mega and pinchangeint&#xA; * This example isprovided as is by Jantje&#xA; * Congratualtions, constructive feedback and I like it can be send to eclipse@baeyens.it&#xA; **/&#xA;&#xA;#define NUM_RC_CHANNELS 6 //You need to specify how many pins you want to use&#xA;#include &quot;PinChangeInt.h&quot;  //If you need pinchangeint you need to include this header&#xA;const uint8_t RC_Channel_Pin[NUM_RC_CHANNELS]={&#xA;  A8,A9,A10,A11,A12,A13};//Here I specify I want to listen to pins A8 to A13 of my mega&#xA;&#xA;uint16_t RC_Channel_Value[NUM_RC_CHANNELS]; //This variable will contain the values read from the RC signal&#xA;#include &quot;RCLib.h&quot; //This include needs all declarations above. Do not try to move it up or it won't compile&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Arduino v1.6.9 | OSX 10.11.4&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="19838" LastEditorUserId="19838" LastEditDate="2016-07-23T15:39:09.337" LastActivityDate="2016-11-20T18:30:29.110" Title="Missing Libraries make no sense" Tags="|library|osx|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26638" PostTypeId="1" AcceptedAnswerId="26640" CreationDate="2016-07-22T23:00:55.717" Score="0" ViewCount="617" Body="&lt;p&gt;I am just interested, but I would like to run a webpage with php on my arduino ethernet. I would like to be able to store my webpage on the sd card as well.&lt;br&gt;&lt;br&gt;&#xA;does anyone know of a library that would let me do this?&lt;/p&gt;&#xA;" OwnerUserId="24141" LastActivityDate="2016-07-23T01:10:54.673" Title="arduino ethernet run php from sd card" Tags="|library|ethernet|web-server|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26639" PostTypeId="2" ParentId="26638" CreationDate="2016-07-23T01:05:54.417" Score="0" Body="&lt;p&gt;Thats not possible, only if you write yourself a PHP interpreter, which I suspect won't fit inside an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might be able to create your own interpreter for simple Get and POST requests, but bear in mind that HTTP, and even TCP are very sophisticated protocols to run on an AVR. You might want stick with simple things, preferentially with small messages as you also have very little RAM on those MCUs.&lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-07-23T01:05:54.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26640" PostTypeId="2" ParentId="26638" CreationDate="2016-07-23T01:10:54.673" Score="1" Body="&lt;p&gt;Loading a file off an sdcard and displaying it on port 80 isn't hard. Just check out the 'Ethernet' library and the 'SD' library.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't want to discourage you too much about the PHP part, but you won't be able to load the official PHP interpreter onto the Arduino. Simply not enough memory available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you just want to have dynamic website such as display variables or output from sensors, then you could write your own code interpreter for dynamic web pages that would fit in the memory of an Arduino, just think a bit smaller in scope as far as what it can handle. Maybe you'll end up writing a new library for dynamic webpages for Arduino sensor data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really need to run a PHP interpreter then you can try something like a Rapsberry Pi and hook it up to the Arduino for sensor input using the I2C protocol.&lt;/p&gt;&#xA;" OwnerUserId="2830" LastActivityDate="2016-07-23T01:10:54.673" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26641" PostTypeId="1" AcceptedAnswerId="26643" CreationDate="2016-07-23T02:08:35.917" Score="1" ViewCount="534" Body="&lt;p&gt;How would I connect components to the Arduino with this motor shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gABEh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gABEh.jpg&quot; alt=&quot;Arduino motor shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="21318" LastActivityDate="2016-07-23T04:41:27.923" Title="How do I connect components to the Arduino with a motorshield?" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26643" PostTypeId="2" ParentId="26641" CreationDate="2016-07-23T04:41:27.923" Score="0" Body="&lt;p&gt;If you are up for a little soldering, look into &lt;a href=&quot;https://www.adafruit.com/product/85&quot; rel=&quot;nofollow&quot;&gt;stackable Arduino headers&lt;/a&gt;. (Feel free to shop around for those, adafruit was just the first result.) You could then use &lt;a href=&quot;https://www.google.com/search?q=male%20jumpers%20electronic&amp;amp;tbm=isch&quot; rel=&quot;nofollow&quot;&gt;male jumpers&lt;/a&gt; and a breadboard to connect anything that fits in a breadboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just be careful to avoid pins that the shield is already using.&lt;/p&gt;&#xA;" OwnerUserId="24144" LastActivityDate="2016-07-23T04:41:27.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26644" PostTypeId="1" CreationDate="2016-07-23T06:20:28.917" Score="0" ViewCount="2771" Body="&lt;p&gt;I have a large collection of libraries that compile correctly but won't link. I am using Visual Micro for Visual Studio 2015. Here is the complete collection of error messages:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;CommandPattern3.cpp.o:In function `DualMotorRomeo&#xA;DualMotorRomeo.h:undefined reference to `vtable for DualMotorRomeo&#xA;DualMotorRomeo.h:undefined reference to `vtable for DualMotorRomeo&#xA;CommandPattern3.cpp.o:In function `__static_initialization_and_destruction_0&#xA;CommandPattern3.ino:undefined reference to `DualMotorRomeo  ~DualMotorRomeo()&#xA;collect2.exe*:error: ld returned 1 exit status&#xA;&#xA;Error compiling for board Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have been through the code with a fine toothed comb, but cannot see what references are undefined. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there some Windows 10 utility that can examine the vTables and help me find what is missing? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code base is too large to post, but I can provide a ZIP file with all the code in it for anyone willing to help.&lt;/p&gt;&#xA;" OwnerUserId="24146" LastActivityDate="2016-12-20T13:11:15.827" Title="Getting &quot;Undefined reference to vtable for {classname}" Tags="|arduino-mega|compiler|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26646" PostTypeId="2" ParentId="26644" CreationDate="2016-07-23T09:25:55.043" Score="1" Body="&lt;p&gt;I don't have the header file for &lt;code&gt;DualMotorRomeo&lt;/code&gt;, but the linker is saying that a destructor has been declared (&lt;code&gt;~DualMotorRomeo()&lt;/code&gt;) in the class header, but no destructor has been defined. If you didn't write &lt;code&gt;DualMotorRomeo&lt;/code&gt; then the library needs to be updated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Until then, simply add the following to one of your source files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;DualMotorRomeo::~DualMotorRomeo() {&#xA;} // DualMotorRomeo::~DualMotorRomeo()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will also fix the &lt;code&gt;vtable&lt;/code&gt; linker errors - the &lt;code&gt;vtable&lt;/code&gt; will be included in the compiled file with this declared in it.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-23T09:25:55.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26648" PostTypeId="1" CreationDate="2016-07-23T13:36:14.667" Score="1" ViewCount="2360" Body="&lt;p&gt;I am currently working on a project that involves steering wheels, and I would like a way for Arduino to wait for a change in value. A potentiometer is used and I would like a program to run (say, like lights blinking ) until there is a change in value of the potentiometer ( like an increase in 300). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&#xA;I realized that I did not give enough information about what I want, so here is the actual task I am trying to achieve :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lights goes on when : &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Button is pressed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The lights goes off when :&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The button is pressed again&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;or&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another button is pressed&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;or&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Potentiometer increases &lt;strong&gt;or&lt;/strong&gt; (only one of it) decreases by 300&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus I didn't mention that the value of the potentiometer will be constantly changing so the old value for the potentiometer should be the one right after the button press. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Soooo sorry for the inconvenience caused. ( I am really bad at programming)&lt;/p&gt;&#xA;" OwnerUserId="24152" LastEditorUserId="24152" LastEditDate="2016-07-23T15:58:21.333" LastActivityDate="2016-07-28T05:16:32.810" Title="Arduino wait for change in value" Tags="|potentiometer|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26649" PostTypeId="2" ParentId="26648" CreationDate="2016-07-23T14:45:05.420" Score="1" Body="&lt;pre&gt;&lt;code&gt;int oldValue;&#xA;void setup()&#xA;{&#xA;    oldValue = analogRead(A1);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    int value = analogRead(A1);&#xA;    while( abs(value-oldValue)&amp;lt;300 )&#xA;        delay(1);&#xA;    oldValue = value;&#xA;&#xA;    // start blinking lights here, as the value has changed by at least 300&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-07-23T15:05:04.160" LastActivityDate="2016-07-23T15:05:04.160" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26650" PostTypeId="2" ParentId="26585" CreationDate="2016-07-23T15:00:42.663" Score="1" Body="&lt;p&gt;In untested (pseudo-)code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long lastSerialInput = millis();&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;&#xA;    if(!myFile)&#xA;        myFile = SD.open(filename, FILE_WRITE);&#xA;&#xA;&#xA;    while(Serial.available())&#xA;    {&#xA;        incomingByte = Serial.read();&#xA;        myFile.println(incomingByte,HEX);&#xA;&#xA;        lastSerialInput = millis();&#xA;    }&#xA;&#xA;    // check for 25 seconds of inactivity&#xA;    if( myFile &amp;amp;&amp;amp; (millis()-lastSerialInput &amp;gt; 25000 )&#xA;    {&#xA;        myFile.close();&#xA;        fileNo++;&#xA;        filename = &quot;datalog&quot;;&#xA;        filename += fileNo;&#xA;        filename += &quot;.txt&quot;;&#xA;&#xA;        //save new fileNo to config.txt (though I'd personally find the file with the largest number in setup instead of relying on a config.txt file)&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-23T15:00:42.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26651" PostTypeId="2" ParentId="26648" CreationDate="2016-07-23T15:06:01.210" Score="0" Body="&lt;p&gt;A change in value is nothing more than that.  A change between a value &lt;em&gt;then&lt;/em&gt; and the value &lt;em&gt;now&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All you need to do is remember what the value used to be, and compare it with what the value is now. If the two have changed, and the change is big enough, then you do something. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And of course you have to remember that &quot;now&quot; will be &quot;then&quot; &quot;next time&quot;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-23T15:06:01.210" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26652" PostTypeId="2" ParentId="26637" CreationDate="2016-07-23T15:53:32.467" Score="2" Body="&lt;p&gt;I had downloaded PinChangeInterrupt through Arduino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch &gt; Include Library &gt; Manage Libraries... &gt; &lt;em&gt;Filter your search...&lt;/em&gt; &gt; PinChangeInterrupt &gt; Install&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought this is all I needed but I was wrong. This differs from the popular &lt;a href=&quot;https://github.com/GreyGnome/PinChangeInt&quot; rel=&quot;nofollow&quot;&gt;PinChangeInt library&lt;/a&gt;. Ultimately the file names where slightly different which is why my file was showing as missing. I found this out by manually looking at the file names in the library I was trying to used and comparing them against my includes.&lt;/p&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-07-23T15:53:32.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26653" PostTypeId="1" AcceptedAnswerId="26699" CreationDate="2016-07-23T17:34:08.767" Score="0" ViewCount="1200" Body="&lt;p&gt;I have a custom PCB with an ATMega 2560 microcontroller on it. To test if the ATMega was working properly, I uploaded the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Test setup&quot;);&#xA;  pinMode(6, OUTPUT);&#xA;  pinMode(30, OUTPUT);&#xA;  pinMode(31, OUTPUT);&#xA;  pinMode(32, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(6, HIGH);&#xA;  digitalWrite(30, HIGH);&#xA;  digitalWrite(31, LOW);&#xA;  digitalWrite(32, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The mentioned ports are connected to LEDs, 6 to an external LED and 30, 31 and 32 to LEDs on the PCB. Each connected in series with a 220 Ohm resistor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board is setup like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/BosL4.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BosL4.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/HsWlF.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HsWlF.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kzpkK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kzpkK.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When uploading I am using a Arduino UNO as ISP and after uploading the Arduino IDE says 'Done uploading' without any errors, but the board is not showing any sign of executing the code. I have checked that VCC is 5V and RESET is HIGH after uploading. The text &quot;Test setup&quot; is also not shown on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anybody have a clue why the board is not working?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks on forehand.&lt;/p&gt;&#xA;" OwnerUserId="23696" LastEditorUserId="23696" LastEditDate="2016-07-24T09:08:12.810" LastActivityDate="2016-07-25T16:26:59.460" Title="Custom ATMega 2560 board won't execute Arduino code" Tags="|arduino-mega|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26654" PostTypeId="1" AcceptedAnswerId="26656" CreationDate="2016-07-23T17:49:23.097" Score="0" ViewCount="1925" Body="&lt;p&gt;I am currently using an atmega328 along with the mcp 2515 and the 2551 for CAN communication in my systems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I've now decided to upgrade to the arduino due for my operations. Can anybody tell me if the arduino due along with it's inbuilt CAN controller be used with the mcp2551 transciever to operate CAN successfully.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If not, can somebody also tell me if there are other alternatives I should look into. Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="24154" LastActivityDate="2016-12-21T04:15:44.157" Title="Arduino due + mcp2551" Tags="|arduino-due|can-bus|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26655" PostTypeId="1" AcceptedAnswerId="26671" CreationDate="2016-07-23T21:04:41.820" Score="2" ViewCount="108" Body="&lt;p&gt;My name is Maria and I'm learning programing in high school.&#xA;I'm working on a birthday present for my mom, want to make a mood light. Using light painter, a neopixel strip, and an arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/adafruit/NeoPixel_Painter&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/NeoPixel_Painter&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found the part, which reads the bmp line by line a very innovative way to make custom animations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But some tweaks are needed. (I've tried to make them, believe me, oh I've tried.) So, i was wondering if i can ask someone a favor and teach me how to modify the code (like, comment on parts that been changed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically, what I want to be changed is, to loop the current bmp until 'next' button is pressed, rather than hold the trigger. Also, I'm not sure if the code try to save power, but it can be disabled since it will run from a power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the part that makes you hold the trigger button (i think)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(;;) {&#xA;    while(!(TIFR1 &amp;amp; _BV(TOV1)));               // Wait for Timer1 overflow&#xA;    TIFR1 |= _BV(TOV1);                        // Clear overflow bit&#xA;&#xA;    show();                                    // Display current line&#xA;    if(stopFlag) break;                        // Break when done&#xA;&#xA;    if(++block &amp;gt;= nBlocks) {                   // Past last block?&#xA;      if(digitalRead(TRIGGER) == HIGH) {       // Trigger released?&#xA;        memset(sdBuf, 0, N_LEDS * 3);          // LEDs off on next pass&#xA;        stopFlag = true;                       // Stop playback on next pass&#xA;        continue;&#xA;      }                                        // Else trigger still held&#xA;      block = 0;                               // Loop back to start&#xA;    }&#xA;    card.readBlock(block + firstBlock, sdBuf); // Load next pixel row&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the complete code: &lt;a href=&quot;https://github.com/adafruit/NeoPixel_Painter/blob/master/NeoPixel_Painter.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/adafruit/NeoPixel_Painter/blob/master/NeoPixel_Painter.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, Since I'm talking to an experts right now, I have this idea to remote control the code! from  another arduino! &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My, probably retarded idea is, to run an IR remote code on a second arduion, than when it receives a signal, send a simulated button press to the first ardu playing the bmp! Is that even possible? Just wondering.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&#xA;Maria&lt;/p&gt;&#xA;" OwnerUserId="24157" LastActivityDate="2016-08-23T09:50:32.093" Title="Neopixel Painter - Need to change few lines. Not sure where to start" Tags="|arduino-uno|neopixel|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26656" PostTypeId="2" ParentId="26654" CreationDate="2016-07-23T21:47:47.453" Score="1" Body="&lt;p&gt;The biggest trouble you are going to find is the voltage levels. The MCP2551 works at 5V and your MCU is 3.3V. I personally don't have experience with this MCUs, but some STM32 MCUs are 5V tolerant on some pins, including the CAN_TX and Can_RX and it's fine to use a 5V Transceiver like the MCP2551.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway, you still can replace the CAN Transceiver with one that has a built in level shifter,  like one of the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;MCP2562&lt;/li&gt;&#xA;&lt;li&gt;ATA6561&lt;/li&gt;&#xA;&lt;li&gt;SN65HVD256&lt;/li&gt;&#xA;&lt;li&gt;NCV7351D13&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've used all the above, except the TI one, and they all talk nicely between each other. Some have different features, like silence or advanced sleeping modes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers &lt;/p&gt;&#xA;" OwnerUserId="16417" LastActivityDate="2016-07-23T21:47:47.453" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26657" PostTypeId="1" AcceptedAnswerId="26659" CreationDate="2016-07-23T22:22:35.397" Score="0" ViewCount="1443" Body="&lt;p&gt;I'm using my Arduino to control a relay switch, which has an extension cord attached to it (see photo).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relay is connected to the Arduino via pin 9, which is set to &lt;code&gt;pinMode(9, OUTPUT);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need any resistors or capacitors or diodes attached to this? Almost feels &lt;em&gt;too&lt;/em&gt; simple, given I'm running AC power through the relay. But maybe no?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It definitely &lt;em&gt;works&lt;/em&gt;, but I want to make sure I'm not going to burn something out (or down).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/N13sD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/N13sD.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18905" LastEditorUserId="18905" LastEditDate="2016-07-23T22:38:40.150" LastActivityDate="2016-07-23T22:53:55.640" Title="Do I need resistors or capacitors on this relay?" Tags="|relay|electronics|switch|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26659" PostTypeId="2" ParentId="26657" CreationDate="2016-07-23T22:53:55.640" Score="2" Body="&lt;p&gt;Yes, that is too simple.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino's IO pin is not designed to directly drive a relay. It needs to go through a transistor first, and you must include a diode to absorb the back-EMF generated by the collapsing magnetic field.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google for &quot;Arduino Relay&quot; and you will find hundreds of thousands of examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, the circuit you need to create is this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/42Shn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/42Shn.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-23T22:53:55.640" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26660" PostTypeId="1" AcceptedAnswerId="26661" CreationDate="2016-07-23T23:50:34.460" Score="2" ViewCount="60" Body="&lt;p&gt;I have a server with files that may be downloaded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I go about detecting when a download is cancelled by a client?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The function that handles reading files for download:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void readFile()&#xA;{&#xA;&#xA;EthernetClient client = server.available(); &#xA;&#xA;// Open file for Reading.&#xA;SdFile webFile;&#xA;webFile.open(&amp;amp;root, &amp;amp;MyBuffer[1], O_READ);   &#xA;if (!webFile.isOpen()) error(&quot;readFile&quot;);&#xA;&#xA;do   // @ adafruit_support_rick's do-while loop&#xA;{&#xA;    int count = 0;&#xA;    char buffers[BUFSIZE];&#xA;    bool done = false;&#xA;&#xA;    while ((!done) &amp;amp;&amp;amp; (count &amp;lt; BUFSIZE) &amp;amp;&amp;amp; (webFile.available()))&#xA;    {&#xA;        char c = webFile.read();&#xA;        if (0 &amp;gt; c)&#xA;        done = true;&#xA;        else&#xA;        buffers[count++] = c;&#xA;        delayMicroseconds(1000);&#xA;    }&#xA;&#xA;    if (count)&#xA;    client.write( buffers, count);&#xA;&#xA;} while (webFile.available());&#xA;&#xA;webFile.close();&#xA;&#xA;fileDownload = 0;  //File download has finished; allow logging since download has completed&#xA;&#xA;delay(500);&#xA;&#xA;MyBuffer[0] = '\0';&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16684" LastEditorUserId="11763" LastEditDate="2016-07-24T01:51:12.830" LastActivityDate="2016-07-24T02:17:35.957" Title="How to detect cancelled download?" Tags="|arduino-mega|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26661" PostTypeId="2" ParentId="26660" CreationDate="2016-07-24T02:17:35.957" Score="1" Body="&lt;p&gt;Well, assuming cancelling a download == incomplete download == client disconnected before server was done, you could create a flag like this at the top of the function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool dload_cancel = false;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Change the &lt;code&gt;IF&lt;/code&gt; block, below the innermost &lt;code&gt;WHILE&lt;/code&gt; loop, to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (count){&#xA;  if (client.connected())&#xA;    client.write( buffers, count);&#xA;  else {&#xA;    dloadCancel = true;&#xA;    break;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The flag will be set once your server checks and discovers that the client has been disconnected. You can check the state of the flag outside the &lt;code&gt;DO-WHILE&lt;/code&gt; block to know if the download was completed or not. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (dloadCancel){&#xA;  // client was disconnected; download did not complete&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;dloadCancel&lt;/code&gt; is also a better indicator of a completed download than your &lt;code&gt;fileDownload&lt;/code&gt; flag.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also know that this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (0 &amp;gt; c)&#xA;    done = true;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is redundant. Its already taken care of by &lt;code&gt;webFile.available()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-07-24T02:17:35.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26663" PostTypeId="1" CreationDate="2016-07-24T04:43:06.020" Score="0" ViewCount="267" Body="&lt;p&gt;I just recently resolved my problem on getting images to load on to my TFT display via the SD card. Thanks to UTFT_SdRaw!!! it's by far the easiest to use. For a novice like me, its been a real feat. Now translating the code, I am trying to turn on and off the image when the pin state changes:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&#xA;When pin A2 on my MEGA goes high (+5vdc) I want my SD to spool up and load an image so here is my code snipit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;****myFiles.load(20, 55, 130, 130, &quot;Power Medium.raw&quot;);****&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So now when the pin state changes back to low (0vdc), how do I remove the image without clearing the entire screen? The image seems to stay frozen instead of disappearing when the pin voltage falls away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas? I am stumped. Thanks in advance for any comments and suggestions that may help me over the hump.&lt;/p&gt;&#xA;" OwnerUserId="21098" LastActivityDate="2016-07-24T07:03:42.413" Title="How do you change the state of an image on a TFT display when the associated pin changes state?" Tags="|programming|display|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26664" PostTypeId="1" AcceptedAnswerId="45996" CreationDate="2016-07-23T23:24:34.493" Score="0" ViewCount="672" Body="&lt;p&gt;I followed regular tutorial and I was able to burn boot-loader on my standalone ATM328 chip, but because I'm using this &lt;a href=&quot;http://g01.a.alicdn.com/kf/HTB1ALCYIFXXXXa_XXXXq6xXFXXXj/Hot-sales-NEW-UNO-R3-ATmega328P-CH340-Mini-USB-Board-for-Compatible-Arduino-free-shipping.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;CH340 UNO&lt;/a&gt; and example is with regular UNO, I can't just remove the chip from there (CH340 UNO) and upload the code directly to my new standalone chip trough that board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what I tried was to use my &lt;a href=&quot;http://www.canadarobotix.com/serial-ttl/ftdi-cable-5v-vcc-3-3v-i-o&quot; rel=&quot;nofollow noreferrer&quot;&gt;FTDI&lt;/a&gt; cable, so I hooked up GND, RX, TX and VCC for my breadboard from there, but when I tried to upload a sketch I keep getting that message that programmer is not responding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I was wondering, is there a way to use this Chinese board to upload sketch to my new chip without de-soldering the chip from that board as option one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As option two what I'm doing wrong with FTDI cable and why I'm not able to upload sketch directly like that? I saw some comments related to some auto-reset that needs to be implemented but I'm not following that part, not sure what I need to hookup extra for that...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UPDATE&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's how my board look like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zSqAL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zSqAL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;OK, everything works great now! I just needed one pull-up resistor for reset pin.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks everyone!&lt;/p&gt;&#xA;" OwnerUserId="21699" OwnerDisplayName="ShP" LastEditorUserId="21699" LastEditDate="2016-07-24T15:16:42.253" LastActivityDate="2017-10-28T20:02:53.003" Title="Chinese CH340 Arduino Uno - Burning stand allone chip" Tags="|ftdi|firmware|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="26665" PostTypeId="1" AcceptedAnswerId="26668" CreationDate="2016-07-23T15:40:44.567" Score="0" ViewCount="446" Body="&lt;p&gt;I'm working with VGA DSUB-15 output, however &lt;a href=&quot;https://github.com/smaffer/vgax&quot; rel=&quot;nofollow noreferrer&quot; title=&quot;VGAX&quot;&gt;VGAX&lt;/a&gt; only allows for 4 colors. I'm using an Arduino Nano that uses an 8-bit atmel chip, and I've seen many 8-bit computers of which have a &lt;em&gt;bit&lt;/em&gt; more than 4 colors.&lt;/p&gt;&#xA;" OwnerDisplayName="James Pae" LastEditorUserId="27346" LastEditDate="2018-10-12T21:26:13.107" LastActivityDate="2018-10-12T21:26:13.107" Title="VGAX library only allows 4 colors, library or hardware limitation?" Tags="|arduino-nano|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="26666" PostTypeId="2" ParentId="26665" CreationDate="2016-07-23T16:20:09.680" Score="1" Body="&lt;p&gt;Are you using the Arduino to directly drive the VGA, or are you using a shield. If you're directly driving the display, I think the limitation is on the Arduino because with only 2kb or RAM, you can't really store all the pixel data. And the duino is also generating the high frequency vsync and hsync signals.&lt;/p&gt;&#xA;" OwnerUserId="17159" OwnerDisplayName="p7810456" LastActivityDate="2016-07-23T16:20:09.680" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26667" PostTypeId="2" ParentId="26665" CreationDate="2016-07-23T16:47:52.410" Score="0" Body="&lt;p&gt;The VGA interface uses full analog signals for Red, Green an Blue video. There is no limit to the color levels in the VGA standard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is not unusual to find that minimalist implementations of VGA in microcontroller products use Digital to Analog Converter (DAC) techniques with a limited number of bits of resolution.  For example, using two bits of resolution for Red and Blue, and three bits of resolution for Green so that the pixel information will fit into an 8-bit byte, etc.&lt;/p&gt;&#xA;" OwnerUserId="22914" OwnerDisplayName="Richard Crowley" LastActivityDate="2016-07-23T16:47:52.410" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26668" PostTypeId="2" ParentId="26665" CreationDate="2016-07-23T17:42:03.250" Score="3" Body="&lt;p&gt;It's a memory limitation. The ATmega328 has 2 KB of RAM, and a 120x60 framebuffer at two bits per pixel (four colors) uses 1.8 KB. There's no room for more.&lt;/p&gt;&#xA;" OwnerDisplayName="user7800" LastActivityDate="2016-07-23T17:42:03.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26669" PostTypeId="2" ParentId="26663" CreationDate="2016-07-24T07:03:42.413" Score="1" Body="&lt;p&gt;It's quite silmple: just draw a box over the image the same colour as the background.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Either that or draw a different image over the top of the existing image.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-24T07:03:42.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26670" PostTypeId="1" CreationDate="2016-07-24T07:48:19.517" Score="3" ViewCount="15829" Body="&lt;p&gt;I powered on my SIM808 module. It showed me following output: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;RDY  &#xA;+CFUN: 1  &#xA;+CPIN: READY  &#xA;Call Ready  &#xA;SMS Ready  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It supposed to show &lt;code&gt;GPS ready&lt;/code&gt; also.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I sent AT command and return ok.&lt;br&gt;&#xA;However &lt;code&gt;AT+CGPSPWR=?&lt;/code&gt; returns error. All GPS command showed error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think GPS is not initialized at all as i didn't see GPS message when module powered on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Why is the GPS not working?&lt;/p&gt;&#xA;" OwnerUserId="24165" LastEditorUserId="19409" LastEditDate="2017-12-16T09:52:45.400" LastActivityDate="2020-09-25T11:10:49.423" Title="SIM808 module GSM working fine, GPS not working (No GPS ready message on power on)" Tags="|gsm|atmega328|softwareserial|gps|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26671" PostTypeId="2" ParentId="26655" CreationDate="2016-07-24T09:13:34.807" Score="0" Body="&lt;p&gt;I think you need something like this.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  for(;;) {&#xA;    while(!(TIFR1 &amp;amp; _BV(TOV1)));               // Wait for Timer1 overflow&#xA;    TIFR1 |= _BV(TOV1);                        // Clear overflow bit&#xA;&#xA;    show();                                    // Display current line&#xA;&#xA;    if(++block &amp;gt;= nBlocks) {                   // Past last block?&#xA;      block = 0;                               // Loop back to start&#xA;    }&#xA;&#xA;    if(digitalRead(NEXT_PIN_OR_SOMETHING) == LOW) {       // Next button pressed&#xA;      break; // Break out of for-loop&#xA;    }&#xA;&#xA;&#xA;    card.readBlock(block + firstBlock, sdBuf); // Load next pixel row&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-24T09:13:34.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26672" PostTypeId="1" CreationDate="2016-07-24T10:03:33.900" Score="0" ViewCount="441" Body="&lt;p&gt;I have a trouble with following, few lines code.&#xA;For some reason after few seconds Arduino uno stops responding into void loop section of code.&#xA;I tried to remove serial communication, all print and println without any success. Is the problem comming from MMA_7455.h?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;MMA_7455.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int servoPin = 9;&#xA;int servoAngle = 0;&#xA;&#xA;Servo servo;&#xA;&#xA;MMA_7455 accel = MMA_7455();&#xA;char yVal;&#xA;char yVal_bkp;&#xA;&#xA;&#xA;void setup() {&#xA;    servo.attach(servoPin);&#xA;    accel.initSensitivity(2);&#xA;    accel.calibrateOffset(1.0, 26.0, -69.0);&#xA;}&#xA;&#xA;void loop() {&#xA;    yVal = accel.readAxis('y'); //Read out the 'y' Axis&#xA;&#xA;    if(yVal_bkp != yVal + 2 || yVal_bkp != yVal -2)&#xA;    {&#xA;        servo.write(90 + yVal);&#xA;        yVal_bkp = yVal;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;P.S. Servo is normal G90&lt;/p&gt;&#xA;" OwnerUserId="24167" LastEditorUserId="24167" LastEditDate="2016-07-24T10:12:34.340" LastActivityDate="2016-10-23T03:01:16.630" Title="Arduino uno unexpected void loop stop" Tags="|arduino-uno|servo|accelerometer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26674" PostTypeId="1" AcceptedAnswerId="26677" CreationDate="2016-07-24T11:29:43.967" Score="0" ViewCount="241" Body="&lt;p&gt;ok so yesterday i was in trouble with the buttons, with help from you i got over it and everything worked fine with the 1st speed of the servo, then i added the other 2 speeds and it looks like it all messed up... the buttons don`t respond as they should and the servo moves very weirdly. &#xA;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int button1Pin = 2;&#xA;const int button2Pin = 3;&#xA;const int ledPin1 = 13;&#xA;const int ledPin2 = 12;&#xA;const int ledPin3 = 11;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo servo1;&#xA;&#xA;&#xA;int x = 0;&#xA;int button1State = 0;&#xA;int lastButton1State = 0;&#xA;int button2State = 0;&#xA;int lastButton2State = 0;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  servo1.attach(9);&#xA;  pinMode(button1Pin, INPUT);&#xA;  pinMode(button2Pin, INPUT);&#xA;  pinMode(ledPin1, OUTPUT);&#xA;  pinMode(ledPin2, OUTPUT);&#xA;  pinMode(ledPin3, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;    int position;&#xA;    button1State = digitalRead(button1Pin);&#xA;    button2State = digitalRead(button2Pin);&#xA;&#xA;      if (button1State != lastButton1State)&#xA;     {&#xA;        if (button1State == HIGH) &#xA;          {&#xA;            x++;&#xA;            Serial.println(&quot;on1&quot;);&#xA;            Serial.print(&quot;number of button Pushes:  &quot;);&#xA;            Serial.println(x);&#xA;          }&#xA;        else &#xA;          {&#xA;            Serial.println(&quot;off1&quot;);  &#xA;          }&#xA;     }&#xA;&#xA;    if (button2State != lastButton2State)&#xA;      {    &#xA;        if (button2State == HIGH) &#xA;          {&#xA;            x--;&#xA;            Serial.println(&quot;on2&quot;);&#xA;            Serial.print(&quot;number of button Pushes:  &quot;);&#xA;            Serial.println(x);&#xA;          }&#xA;        else &#xA;          {&#xA;            Serial.println(&quot;off2&quot;); &#xA;          }&#xA;       }&#xA;          delay(1000);&#xA;&#xA;lastButton1State = button1State;&#xA;lastButton2State = button2State;&#xA;&#xA;  if(x == 1)&#xA;    {&#xA;      digitalWrite(ledPin1, HIGH);&#xA;      digitalWrite(ledPin2, LOW);&#xA;      digitalWrite(ledPin3, LOW);&#xA;        for(position = 0; position &amp;lt; 360; position += 2)&#xA;          {&#xA;            servo1.write(position);&#xA;            delay(20);&#xA;          }&#xA;    }&#xA;   else if (x == 2)&#xA;    {&#xA;      digitalWrite(ledPin1, LOW);&#xA;      digitalWrite(ledPin2, HIGH);&#xA;      digitalWrite(ledPin3, LOW);&#xA;        for(position = 0; position &amp;lt;360; position += 5)&#xA;          {&#xA;            servo1.write(position);&#xA;            delay(20);&#xA;          }&#xA;    }&#xA;   else &#xA;    {&#xA;      digitalWrite(ledPin1, LOW);&#xA;      digitalWrite(ledPin2, LOW);&#xA;      digitalWrite(ledPin3, HIGH);&#xA;        for(position = 0; position &amp;lt; 360; position += 10)&#xA;          {&#xA;            servo1.write(position);&#xA;            delay(20);&#xA;          }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24137" LastActivityDate="2016-07-24T23:15:01.703" Title="Servo Speed Changer with Buttons" Tags="|arduino-uno|programming|servo|button|debounce|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26675" PostTypeId="1" AcceptedAnswerId="26676" CreationDate="2016-07-24T11:37:56.157" Score="0" ViewCount="122" Body="&lt;p&gt;this is more like C question, but i failed to google this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i expect a command parameter in char[], but there may be no argument passed at all, so i need to try to parse this char[] to int and if there is garbage instead of a number, notify user.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i also need to be able to parse negative (with -sign char) numbers from char[].&lt;/p&gt;&#xA;&#xA;&lt;p&gt;how can i do this? thanks.&lt;/p&gt;&#xA;" OwnerUserId="23272" LastActivityDate="2016-07-24T14:53:34.330" Title="How to convert char[] to int with fail\success control?" Tags="|programming|c|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26676" PostTypeId="2" ParentId="26675" CreationDate="2016-07-24T11:52:00.663" Score="0" Body="&lt;p&gt;It isn't doable, reliably, with the given specs. If the array has garbage in it, it won't necessarily fail to parse as an int. That said, you can try to parse as an int with atoi() or sscanf(), as suggested in the comments, and report that it &lt;em&gt;did or did not parse&lt;/em&gt;, but not necessarily whether it is valid in some respect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you're in control of the array, zero its first element. Then if you get back a non-empty string, at least you'll know some command parameter had been placed in it.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-24T14:53:34.330" LastActivityDate="2016-07-24T14:53:34.330" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26677" PostTypeId="2" ParentId="26674" CreationDate="2016-07-24T12:29:50.167" Score="1" Body="&lt;p&gt;There may be better ways to mitigate button bounce. Check &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Debounce&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; for a discussion on button bounce and example code to work around this problem. In your code, it appears you can not press your buttons faster than once a second.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Determine if the servos you are using are capable of the range you are demanding.  Some servos only travel from 0 degrees to 180 degrees.  Your code is asking the servo to travel from 0 degrees to 360 degrees.  Also, it is unlikely that any normal servo can travel this far.  Most servos use a potentiometer as a feed back sensor.  And most potentiometers can only be turned to something less than 1 full revolution.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is likely you have not given the servos enough time to move to the zero degree position at the start of each of your 3 loops.  Understand that normal servos can not make complete revolutions.  They need to stay within their designed limit of rotation.  If you want to start over at 0 degrees you need to allow the servos time to rotate back in reverse to the 0 degree position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider your last loop.  You are asking the servo to move from 0 degrees to 360 degrees in 10 degree steps.  You are allowing 20ms per step.  That means the servo will be demanded to move almost a complete revolution in (((360 / 10) * 0.020 = 0.72 seconds) less than a second.  Some but not all servos can move that fast.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-07-24T23:15:01.703" LastActivityDate="2016-07-24T23:15:01.703" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="26678" PostTypeId="1" AcceptedAnswerId="26681" CreationDate="2016-07-24T13:15:12.440" Score="1" ViewCount="5376" Body="&lt;p&gt;The below is a snippet of a code for operating SI4455 Rf module with Arduino. I have some doubts which I'd like to seek some help in clearing.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte numOfBytes = *pSetPropCmd++;&#xA;&#xA;    if (numOfBytes &amp;gt; 16u) // What does this 16u mean?&#xA;    {&#xA;        /* Initial configuration of Si4x55 */&#xA;        if (SI4455_CMD_ID_WRITE_TX_FIFO == *pSetPropCmd) &#xA;        {&#xA;            if (numOfBytes &amp;gt; 128u) // What does this 128u mean?&#xA;            {&#xA;                /* Number of command bytes exceeds maximal allowable length */&#xA;                return SI4455_COMMAND_ERROR;&#xA;            }&#xA;&#xA;            /* Load array to the device */&#xA;            pSetPropCmd++;&#xA;            WriteEZConfigArray(numOfBytes - 1, pSetPropCmd);&#xA;&#xA;            /* Point to the next command */&#xA;            pSetPropCmd += numOfBytes - 1;&#xA;&#xA;            /* Continue command interpreter */&#xA;            continue;&#xA;        }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the above snippet, what does 16u and 128u mean?. I think its meaning u for unsigned, but still not clear as what does 16u and 128u mean. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rgds&#xA;VD&lt;/p&gt;&#xA;" OwnerUserId="3892" LastActivityDate="2016-07-24T13:29:18.097" Title="What does 16u and 128u mean?" Tags="|arduino-uno|c|data-type|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26680" PostTypeId="2" ParentId="26672" CreationDate="2016-07-24T13:24:32.097" Score="1" Body="&lt;p&gt;Have you checked that MMA_7455 can handle this many reads?&lt;br&gt;&#xA;I had sensors that stop working because I asked to often for feedback.&lt;br&gt;&#xA;As the servo needs a 20ms to adjust its location I would add a delay(20) to the loop.&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="2881" LastEditDate="2016-07-24T17:57:50.500" LastActivityDate="2016-07-24T17:57:50.500" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26681" PostTypeId="2" ParentId="26678" CreationDate="2016-07-24T13:29:18.097" Score="0" Body="&lt;p&gt;It means that it is a unsigned value. Because the compiler checks for signed and unsigned in the same operation this is used (amongst others) to avoid warnings.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is explained on stackoverflow here &lt;a href=&quot;https://stackoverflow.com/questions/14844119/define-foo-1u-2u-4u-what-does-1u-and-2u-mean&quot;&gt;https://stackoverflow.com/questions/14844119/define-foo-1u-2u-4u-what-does-1u-and-2u-mean&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-07-24T13:29:18.097" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26682" PostTypeId="1" CreationDate="2016-07-24T17:50:15.817" Score="1" ViewCount="721" Body="&lt;p&gt;My overall goal is to have an Arduino Uno with an Ethernet Shield send a short (5-character) string via a SoftwareSerial connection and a UDP packet when I press a button.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The device which is receiving the serial message is fixed at 9600 baud, no parity, one stop bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the purposes of debugging my serial problem I have removed the Ethernet Shield. I mention it above only so that potential responders understand my intended final hardware configuration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a USB/serial adaptor and Kermit to check the serial output.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C-Kermit&amp;gt;show communications&#xA;&#xA;Communications Parameters:&#xA; Line: /dev/ttyUSB0, speed: 9600, mode: local, modem: none&#xA; Parity: none, stop-bits: 1 (8N1)&#xA; Duplex: full, flow: none, handshake: none&#xA; Carrier-watch: off, close-on-disconnect: off&#xA; Lockfile: /var/lock/LCK..ttyUSB0&#xA; Terminal bytesize: 8, escape character: 28 (^\)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My first job on receiving garbled characters was to test my test rig. I connected the predecessor device and was able to receive the expected characters. (It cannot send the UDP packet, which is why it is being replaced.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One button on the original device sends &quot;X0401&quot;, exactly as expected:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b oldserial⋅&#xA;0000000 000 130 060 064 060 061&#xA;0000006&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Another button on the original device sends &quot;X0402&quot; (which I expected) and also a whole bunch of nuls, which I didn't expect:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b oldserial⋅&#xA;0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000&#xA;0000020 000 000 000 000 000 130 060 064 060 062&#xA;0000032&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In any event, it seems that the terminal is actually receiving 8N1 data at 9600, so I can trust what it shows me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was going kind of nuts trying to figure out what was the problem, because nothing I sent from the Arduino came through properly. Then I stumbled on a suggestion that 'U' made a good test character because an ASCII 'U' is 0123 or 01010101. Indeed, I am able to send sequences of arbitrary length and so long as they contain only the 'U' caracter, they come through correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I've got three buttons and three different sets of messages, so my tests tend to run in sets of three attempts.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Next step is to reintroduce a little bit of variety and see what comes through:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here I send &quot;UUUUU&quot;, &quot;UUEUU&quot;, and then &quot;UUQUU&quot;. 'E' and 'Q' were chosen because they are each just one bit different from 'U'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I saw when I sent the first message was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UUUUU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then sent the second:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UUUUUUU]UU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then the third:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UUUUUUU]UUUUWUU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Kermit was also storing the session to a log file, which looked like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b serialUsequesnce⋅&#xA;0000000 125 125 125 125 125&#xA;0000005&#xA;$ od -b serialUsequesnce⋅&#xA;0000000 125 125 125 125 125 125 125 135 125 125&#xA;0000012&#xA;$ od -b serialUsequesnce⋅&#xA;0000000 125 125 125 125 125 125 125 135 125 125 125 125 127 125 125&#xA;0000017&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Somehow, 'E' (0105) turned into 0135 and 'Q' (0121) turned into 0127. In each case, a sequence of three 0 bits were turned into 011, while no 1 bits were changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sending:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UUAUU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Got me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b serialUsequesnce2⋅&#xA;0000000 000 125 125 137 125 125&#xA;0000006&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The five consecutive 0 bits in 01000001 were turned into 01111 to give me 01011111 or 0137&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Longer strings get weirder.⋅&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test strings of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UU0123456789UU&#xA;UUABCDEFGUU&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Got me:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b serialUsequesnce3&#xA;0000000 125 125 326 266 226 166 126 066 026 366 215 125 125 000&#xA;0000016&#xA;$ od -b serialUsequesnce4&#xA;0000000 125 125 137 257 335 325 315 305 125 125 001&#xA;0000013&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I'm seeing not just bits being replaced, but I'm getting fewer characters than I'm sending.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since I wasn't getting good data from my SoftwareSerial port, I thought I would listen in on the USB traffic, which is also set to 9600 baud.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This text from the Arduino monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;UUAUU&#xA;Start button pressed&#xA;UU0123456789UU&#xA;Stop button pressed&#xA;UUABCDEFGUU&#xA;Light button pressed&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Came through as this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;$ od -b serialUSB&#xA;0000000 125 125 137 125 125 171 275 165 324 332 027 277 073 025 027 027&#xA;0000020 041 043 277 037 031 031 065 067 345 353 000&#xA;0000033&#xA;$ od -b serialUSB2&#xA;0000000 125 125 326 266 226 166 126 066 026 366 215 125 125 345 353 131&#xA;0000020 027 041 037 277 073 025 027 027 041 043 277 037 031 031 065 067&#xA;0000040 345 353 000&#xA;0000043&#xA;$ od -b serialUSB3&#xA;0000000 125 125 137 257 335 325 315 305 125 125 225 353 147 055 061 057&#xA;0000020 027 277 073 025 027 027 041 043 277 037 031 031 065 067 345 353&#xA;0000040 000&#xA;0000041&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm guessing that I'm doing something wrong with the hardware, but my serial connector simply has pin 5 connected to ground and pin 2 connected to digital 6 (or 2 when watching USB traffic).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm powering the Arduino Uno via its USB connection. When I checked the voltage at Vin and the adjacent ground, I got 4.51 volts.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;Listens on three buttons:&#xA; - Start&#xA; - Stop&#xA; - Lights&#xA;&#xA;Sends serial messages to a Color Kinetics iPlayer 2&#xA;9600 baud, 8 data bits, no parity, 1 stop bit&#xA;Commands are&#xA; - X0100 Lights Off&#xA; - X0288 Lights at half&#xA; - X02FF Lights at full&#xA; - X0401 Set Show #1&#xA;&#xA;&#xA;Created 2016-07-13&#xA;by David H. Silber&#xA;(Cribbing extensively from the Arduino examples.)&#xA;*/&#xA;&#xA;&#xA;#include &amp;lt;SPI.h&amp;gt;         // needed for Arduino versions later than 0018&#xA;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial softSerial( 5, 6 ); // RX, TX&#xA;&#xA;&#xA;const int noButton = 100;&#xA;const int startButton = 2;&#xA;const int stopButton = 3;&#xA;const int lightButton = 4;&#xA;bool startTriggered = false;&#xA;bool stopTriggered = false;&#xA;bool lightTriggered = false;&#xA;int lastTriggered = noButton;&#xA;unsigned long lastButtonTime = 0;&#xA;&#xA;const char startSerial[] = &quot;UUUUU&quot;;&#xA;const char stopSerial[]  = &quot;UUEUU&quot;;&#xA;const char lightSerial[] = &quot;UUQUU&quot;;&#xA;&#xA;&#xA;void setup() {&#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(startButton, INPUT);&#xA;  pinMode(stopButton, INPUT);&#xA;  pinMode(lightButton, INPUT);&#xA;&#xA;  Serial.begin(9600);           // set up Serial library at 9600 bps&#xA;  Serial.println(&quot;Starting&quot;);  // prints hello with ending line break⋅&#xA;&#xA;&#xA;  // set the data rate for the SoftwareSerial port&#xA;  softSerial.begin(9600);&#xA;  delay( 1000 );&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the pushbutton value:&#xA;  startTriggered = ( HIGH == digitalRead(startButton) );&#xA;  stopTriggered = ( HIGH == digitalRead(stopButton) );&#xA;  lightTriggered = ( HIGH == digitalRead(lightButton) );&#xA;&#xA;  if ( startTriggered &amp;amp;&amp;amp; (startButton != lastTriggered) ) {&#xA;    action( &quot;Start button pressed&quot;, startSerial );&#xA;&#xA;    lastTriggered = startButton;&#xA;    startTriggered = false;&#xA;  }&#xA;&#xA;  if ( stopTriggered &amp;amp;&amp;amp; (stopButton != lastTriggered) ) {&#xA;    action( &quot;Stop button pressed&quot;, stopSerial );&#xA;&#xA;    lastTriggered = stopButton;&#xA;    stopTriggered = false;&#xA;    }&#xA;&#xA;  if ( lightTriggered &amp;amp;&amp;amp; (lightButton != lastTriggered) ) {&#xA;    action( &quot;Light button pressed&quot;, lightSerial );&#xA;&#xA;    lastTriggered = lightButton;&#xA;    lightTriggered = false;&#xA;  }&#xA;&#xA;  buttonTimeout();&#xA;}&#xA;&#xA;void action( const char usbMessage[], const char serialMessage[] ) {&#xA;    Serial.println( serialMessage);⋅&#xA;    Serial.println( usbMessage);⋅&#xA;&#xA;    softSerial.write( serialMessage );&#xA;&#xA;    lastButtonTime = millis();&#xA;}&#xA;&#xA;void buttonTimeout() {&#xA;  if ( millis() - lastButtonTime &amp;gt; 2000 ) {&#xA;    lastTriggered = noButton;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24128" LastEditorDisplayName="user31481" LastEditDate="2017-11-19T07:29:44.520" LastActivityDate="2018-01-18T08:03:42.137" Title="Sending data via SoftwareSerial results in garbled reception" Tags="|serial|softwareserial|code-review|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26683" PostTypeId="1" CreationDate="2016-07-24T19:25:32.223" Score="0" ViewCount="6955" Body="&lt;p&gt;I am starting a project in Arduino and I need to read data from an CSV stored in an SD card. The data is stored as the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;id, value, date&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I want to do is read the file, filter by date and then store the values by id. Each id will correspond to different values from that same date.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to do something like this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much for your advice.&lt;/p&gt;&#xA;" OwnerUserId="24172" LastEditorUserId="2881" LastEditDate="2016-07-24T19:38:03.523" LastActivityDate="2017-03-19T18:04:09.947" Title="Best way to read CSV from SD card and store values by date" Tags="|sd-card|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26684" PostTypeId="2" ParentId="3680" CreationDate="2016-07-24T20:53:11.887" Score="6" Body="&lt;p&gt;On Ubuntu 16.04 (and maybe previous versions or other distribs too), you can do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; ls /dev/serial/by-id&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which displays (on my box where an Arduino UNO is connected):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;usb-Arduino__www.arduino.cc__0043_A4139363931351318241-if00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can easily spot the Device ID 0043 (UNO) here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This file is actually a link to &lt;code&gt;/dev/ttyACM0&lt;/code&gt; in my box.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-07-24T20:53:11.887" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26685" PostTypeId="2" ParentId="26632" CreationDate="2016-07-25T03:36:01.547" Score="2" Body="&lt;p&gt;If an MCU which has a built in USB interface (such as the ATmega32u4 on a Leondardo) is properly configured and connected to an operating USB host, it will receive a &quot;Start of Frame&quot; packet every millisecond.  I'm not very familiar with the details of the USB engine on that particular chip, but generally you can detect this as an interrupt, or as a change in a peripheral status register bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Going a step further, in the Arduino API an &lt;code&gt;if (Serial)&lt;/code&gt; test will determine if the board is connected to a host which is in an active CDC-ACM &quot;serial&quot; session with it, ie, one that has a serial terminal or other program talking to it.  Again, this only applies to those that implement USB within the chip on which the sketch is running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Chances are your problems can be fixed by enabling the AVR watchdog timer at one of its longer limits and resetting it in the USB ISR found in &lt;code&gt;USBCore.cpp&lt;/code&gt;&lt;/strong&gt; Then if the the USB goes down (ie, the usual every millisecond SoF interrupt fails to happen for several seconds) your Arduino will reset.  In the simple case, it will keep resetting as long as it has power and the USB is down, but you can put some startup logic to wait for the USB while resetting the watchdog if that bothers you.  See for comparative example the implementation details behind the &lt;code&gt;if (serial)&lt;/code&gt; and create something similar for your chosen USB mode.&lt;/p&gt;&#xA;" OwnerUserId="612" LastEditorUserId="612" LastEditDate="2016-08-01T18:01:11.983" LastActivityDate="2016-08-01T18:01:11.983" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26686" PostTypeId="1" CreationDate="2016-07-25T04:35:04.247" Score="1" ViewCount="1674" Body="&lt;p&gt;I'm trying to call a function to keep an LED on for a certain amount of time. The function is called when the button is pushed but the LED stays on. I used the same code in the void loop before moving it into a function and it worked. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin2 = 2;&#xA;const int buttonPin7 = 7;&#xA;const unsigned long onTime = 1000;&#xA;unsigned long previousMillis = 0;&#xA;&#xA;&#xA;// &#xA;void timer(){&#xA;    unsigned long currentMillis = millis();&#xA;    digitalWrite(ledPin2, HIGH);&#xA;&#xA;    if (currentMillis - previousMillis &amp;gt;= onTime){&#xA;        digitalWrite(ledPin2, LOW);&#xA;        previousMillis = millis();&#xA;    }&#xA;}&#xA;&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;    pinMode(ledPin2, OUTPUT);&#xA;    pinMode(buttonPin7, INPUT);&#xA;}&#xA;&#xA;void loop(){&#xA;    int buttonState = digitalRead(buttonPin7);&#xA;    if (buttonState == HIGH) timer();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-07-25T08:57:35.687" Title="calling a timer when a button is pushed" Tags="|timers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26687" PostTypeId="2" ParentId="26682" CreationDate="2016-07-25T04:41:07.590" Score="1" Body="&lt;p&gt;A friend came and visited me with his oscilloscope and we determined that the 'serial' output from the Arduino was not actually RS-232. It was only an accident that any data came through at all.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think my answer will be to add &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardSerial&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Main/ArduinoBoardSerial&lt;/a&gt; or something like it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of our realizations was that we needed to level shift the output, searching on &quot;arduino serial level shifter&quot; led me to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=18689.0&quot; rel=&quot;nofollow&quot;&gt;http://forum.arduino.cc/index.php?topic=18689.0&lt;/a&gt; which in turn led us to the MAX232 chip and boards that provide it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It would be a good thing if there were some mention in the Arduino documentation that the 'serial' connection one would get from it was not actually RS-232.&lt;/p&gt;&#xA;" OwnerUserId="24128" LastActivityDate="2016-07-25T04:41:07.590" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26688" PostTypeId="2" ParentId="26686" CreationDate="2016-07-25T05:26:06.537" Score="1" Body="&lt;p&gt;Your code says&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (buttonState == HIGH) timer();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So... what will it do if &lt;code&gt;buttonstate&lt;/code&gt; is &lt;code&gt;LOW&lt;/code&gt;? Sorry, but the answer is &quot;nothing&quot;. You don't have any code to tell it what to do when the button is in the opposite state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you should do is check the button, and if it's pressed (whether that's &lt;code&gt;HIGH&lt;/code&gt; or &lt;code&gt;LOW&lt;/code&gt; depends on your circuit), then light the LED and start the timer (assign to &lt;code&gt;previousMillis&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, &lt;em&gt;regardless of the state of the button&lt;/em&gt;, check to see if &lt;code&gt;currentMillis - previousMillis &amp;gt;= onTime&lt;/code&gt;. If it is, then turn off the LED.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-25T05:26:06.537" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26689" PostTypeId="2" ParentId="26670" CreationDate="2016-07-25T08:07:58.830" Score="5" Body="&lt;p&gt;You have a version2 module. Use AT+CGNSxxx instead of AT+CGPSxxx&lt;/p&gt;&#xA;" OwnerUserId="24177" LastActivityDate="2016-07-25T08:07:58.830" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26690" PostTypeId="2" ParentId="26686" CreationDate="2016-07-25T08:57:35.687" Score="2" Body="&lt;p&gt;When your code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (currentMillis - previousMillis &amp;gt;= onTime){&#xA;    digitalWrite(ledPin2, LOW);&#xA;    previousMillis = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;was in the loop, it was executed multiple times, so when &lt;code&gt;if (currentMillis - previousMillis &amp;gt;= onTime)&lt;/code&gt; eventually became true, it would set ledPin2 LOW again.&#xA;Now that you moved it to the &lt;code&gt;timer&lt;/code&gt; funtion, it only gets executed once (and &lt;code&gt;if (currentMillis - previousMillis &amp;gt;= onTime)&lt;/code&gt; never gets a chance to become true).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to introduce a loop in the &lt;code&gt;timer&lt;/code&gt; function. It also looks like you have your &lt;code&gt;currentMillis&lt;/code&gt; / &lt;code&gt;previousMillis&lt;/code&gt; messed up. I think you are looking for something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void timer(){&#xA;&#xA;    unsigned long previousMillis = millis();&#xA;    unsigned long currentMillis = millis();&#xA;    digitalWrite(ledPin2, HIGH);&#xA;&#xA;    while((currentMillis - previousMillis) &amp;lt; onTime) {&#xA;        // wait for a bit&#xA;        sleep(10);&#xA;        // update currentMillis&#xA;        currentMillis = millis();&#xA;    }&#xA;&#xA;    digitalWrite(ledPin2, LOW);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24169" LastActivityDate="2016-07-25T08:57:35.687" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26692" PostTypeId="1" AcceptedAnswerId="26693" CreationDate="2016-07-25T10:08:47.593" Score="2" ViewCount="7745" Body="&lt;p&gt;Is it possible to manually declare a global variable that is inside of a function. The only current way I know how to do so is to declare that variable within the &lt;code&gt;setup()&lt;/code&gt; function or simply outside of any function, but I was hoping there was a way to manually declare a variable as global so that I may call one variable from within one function in another function.&lt;/p&gt;&#xA;" OwnerUserId="21627" LastEditorUserId="4854" LastEditDate="2016-07-31T16:19:34.810" LastActivityDate="2016-08-11T06:25:33.363" Title="Manually Declare Global Variable" Tags="|variables|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26693" PostTypeId="2" ParentId="26692" CreationDate="2016-07-25T10:28:11.690" Score="6" Body="&lt;p&gt;You need to research 'Scope'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your variable has to be at the same level as all functions that will use it.  So at a simple level the answer has to be no.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int variableOne = 0;&#xA;void setup ()&#xA;{&#xA;  variableOne = 1;&#xA;}&#xA;void loop ()&#xA;{&#xA;  variableOne = 2;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The above code will work, but if you move &lt;code&gt;int variableOne = 0;&lt;/code&gt; inside either function then it won't work, because the variable will not be in scope in the other function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use parameters to functions.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void AFunction (const int&amp;amp; variable);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Will let you pass a single integer value to the function from the parent.  You can't change that value, because of the &lt;code&gt;const&lt;/code&gt; qualifier.  If you remove the const then the &lt;code&gt;&amp;amp;&lt;/code&gt; means pass the parameter by reference, which means you are passing in a reference (pointer) to the variable in the parent function and you can change it.  A better way to change the parent's value is to return a value from the call.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int AFunction (const int&amp;amp; variable);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you could use this like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int AFunction (const int&amp;amp; variable)&#xA;{&#xA;  return (++variable);&#xA;}&#xA;void loop (void)&#xA;{&#xA;  int value = 0;&#xA;  value = AFunction(value);&#xA;  // value now == 1.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You could use a Singleton class, but this is hardcore and I'm not sure you would see any real benefit on an Arduino.  A class is a grouping of related function and variables that you see in libraries and a Singleton class means there will only ever be one during the lifetime of the program.  In this way you can declare an instance of the class (i.e. &lt;code&gt;CSingleInstanceClass onlyOne;&lt;/code&gt;) and then retrieve/set data from the setup and loop function, i.e.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup ()&#xA;{&#xA;  CSingleInstanceClass onlyOne;  // Single instance class&#xA;  onlyOne.SetVariableOne (1);&#xA;}&#xA;void loop ()&#xA;{&#xA;  CSingleInstanceClass onlyOne;  // Single instance class&#xA;  Serial.println(onlyOne.GetVariableOne());// Prints 1&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Hope that helps.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-25T10:28:11.690" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26696" PostTypeId="2" ParentId="26692" CreationDate="2016-07-25T13:31:57.393" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;even though I understand this takes up a bit of dynamic memory&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no way around that. They have to go somewhere and that place is RAM (exception: constants could be stored in flash).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another variation (which goes beyond your question) is that a parent function could declare and build a collection of data in a local array or struct and pass a pointer to it to any sub-functions. It still takes RAM, but it will be on the parent function's stack, so only for the duration of parent function's execution(s); it will be released when the parent function exits.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-25T14:52:28.347" LastActivityDate="2016-07-25T14:52:28.347" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26698" PostTypeId="1" CreationDate="2016-07-25T16:07:51.550" Score="4" ViewCount="1078" Body="&lt;p&gt;I want to send and receive on the same node using the RF24Network library, but I'm unable to do so even when I use &lt;code&gt;radio.StopListening()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RF24Network.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;RF24 radio(9,10);&#xA;RF24Network network(radio);&#xA;struct payload_t{unsigned long int code; unsigned long int message;};&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  SPI.begin();&#xA;  radio.begin();&#xA;  radio.setPALevel(RF24_PA_MAX);&#xA;  radio.setDataRate(RF24_250KBPS);&#xA;  radio.setAutoAck(false);&#xA;  network.begin(108, 0);&#xA;}&#xA;&#xA;void loop(){&#xA;  network.update();&#xA;  RF24NetworkHeader header;&#xA;  payload_t payload;&#xA;  if(network.available()) {&#xA;    network.read(header, &amp;amp;payload, sizeof(payload));&#xA;    Serial.println(payload.message);&#xA;    // I WANT HERE TO SEND BACK TO THE TRANSMITTER but I'm unable to do that&#xA;    radio.stopListening();&#xA;    payload_t payload = { 2000, 15444452 };&#xA;    RF24NetworkHeader header(2);&#xA;    network.write(header, &amp;amp;payload, sizeof(payload));&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Second Node:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;RF24Network.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;RF24 radio(9,10);&#xA;RF24Network network(radio);&#xA;struct payload_t{unsigned long int code; unsigned long int message;};&#xA;firstExec = 1;&#xA;&#xA;void setup(void) {&#xA;  Serial.begin(9600);&#xA;  SPI.begin();&#xA;  radio.begin();&#xA;  radio.setPALevel(RF24_PA_MAX);&#xA;  radio.setDataRate(RF24_250KBPS);&#xA;  radio.setAutoAck(false);&#xA;  network.begin(108, 2);&#xA;}&#xA;&#xA;void loop() {&#xA;  network.update();&#xA;  if(firstExec) {&#xA;    radio.stopListening();&#xA;    payload_t payload = { 2000, 5555555 };&#xA;    RF24NetworkHeader header(0);&#xA;    network.write(header, &amp;amp;payload, sizeof(payload));&#xA;    radio.startListening();&#xA;    firstExec = 0;&#xA;  }&#xA;  RF24NetworkHeader header;&#xA;  payload_t payload;&#xA;  if(network.available()) {&#xA;    network.read(header, &amp;amp;payload, sizeof(payload));&#xA;    Serial.println(payload.message);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24187" LastEditorUserId="4628" LastEditDate="2017-05-26T02:10:42.490" LastActivityDate="2021-03-08T19:56:24.123" Title="Read and write on the same node (central) using an RF24 network on Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26699" PostTypeId="2" ParentId="26653" CreationDate="2016-07-25T16:26:59.460" Score="0" Body="&lt;p&gt;When using an empty ATMega2560 you need to change the fuse settings, otherwise it will just upload your code but it won't execute. &#xA;This tutorial explains it very clearly:&#xA;&lt;a href=&quot;https://soc.ninja/documentation/programming-atmega2560-with-arduino-uno-or-mega/#comment-159&quot; rel=&quot;nofollow&quot;&gt;Programming ATMega 2560 with Arduino UNO&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23696" LastActivityDate="2016-07-25T16:26:59.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26700" PostTypeId="1" AcceptedAnswerId="26702" CreationDate="2016-07-25T18:06:13.137" Score="0" ViewCount="1872" Body="&lt;p&gt;I looked up the question before, but they only gave answers for boards that are not the Uno. Is there any way to make it so when I press a button on my board, it registers as a key press on my computer? I'm trying to make a flight controller for PC sims.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="24189" LastEditorUserId="24189" LastEditDate="2016-07-26T15:23:50.607" LastActivityDate="2016-07-26T18:12:46.413" Title="Can I make so when I press a button on my Arduino Uno board, it will press a key on my computer?" Tags="|arduino-uno|button|keyboard|" AnswerCount="4" CommentCount="1" ClosedDate="2016-08-01T05:32:45.937" ContentLicense="CC BY-SA 3.0" />
  <row Id="26701" PostTypeId="1" AcceptedAnswerId="28632" CreationDate="2016-07-25T19:06:57.173" Score="0" ViewCount="690" Body="&lt;p&gt;Does anyone know of a library that works with the WiFly-RN171?&#xA;I've tried all that I could find (WiFly, WiFlyHQ and WiFlySerial) but none of them work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFly and WiFlySerial both hang on WiFly.begin(). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;WiFlyHQ fails to enter command mode and hence proceeds no further.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using the WiFly-RN171 with an Arduino Uno and Communication Shield (XBee, Bluetooth, RFID) - XBee Shield as seen below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Has anybody gotten this configuration to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0L3Tt.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0L3Tt.jpg&quot; alt=&quot;arduino setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24190" LastActivityDate="2016-09-22T17:30:32.540" Title="Wifly Library that works with RN171" Tags="|arduino-uno|wifi|shields|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26702" PostTypeId="2" ParentId="26700" CreationDate="2016-07-25T19:13:37.927" Score="3" Body="&lt;p&gt;Not without extra software on your computer side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However if you use Arduino Micro, you can emulate keyboard and/or mouse directly.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-07-25T19:13:37.927" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26705" PostTypeId="1" AcceptedAnswerId="26711" CreationDate="2016-07-25T22:40:29.030" Score="1" ViewCount="2221" Body="&lt;p&gt;I'm writing a program with three different cases. Case one an LED is off, in another it is on and in the last case the brightness is controlled by a potentiometer. Each case works as I press the button. The issue I am having is with the third case. The potentiometer is read only once and the LED is set accordingly. I would like the LED to be adjusted continuously until the button is pushed again and the case is switched to off. I used the Serial.print to see the valves read from the potentiometer. I verified its only read once on each cycle through the different cases. I also changed from a SWITCH/CASE to If statements and it only reads the potentiometer once. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;CODE HAS BEEN UPDATED&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//-------------------------------------------------------&#xA;// BUTTON AND POT - TEST&#xA;// KNOWN ISSUE - POT ONLY TAKES ON READING&#xA;// vonderasche&#xA;// 7/28/2016&#xA;//-------------------------------------------------------&#xA;&#xA;const int BUTTON_PIN = 9;&#xA;const int LED_PIN = 3;&#xA;const unsigned long DEBOUNCE_TIME = 50;&#xA;&#xA;int val = 0;&#xA;int pot = 0;&#xA;&#xA;int state = 0;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(BUTTON_PIN, INPUT_PULLUP);&#xA;    pinMode(LED_PIN, OUTPUT);&#xA;    Serial.begin(9600);&#xA;}&#xA;&#xA;bool button_press()&#xA;{&#xA;    static bool last_state;&#xA;    static unsigned long last_state_change;&#xA;    unsigned long now = millis();&#xA;&#xA;    if (now - last_state_change &amp;lt; DEBOUNCE_TIME)&#xA;        return false;&#xA;&#xA;    bool state = digitalRead(BUTTON_PIN);&#xA;    if (state != last_state) last_state_change = now;&#xA;    bool press = last_state &amp;amp;&amp;amp; !state;&#xA;    last_state = state;&#xA;    return press;&#xA;}&#xA;&#xA;void loop()&#xA;{    &#xA;&#xA;    unsigned long now = millis();&#xA;    static enum { OFF, ON, POT } state;&#xA;&#xA;    if (button_press()) switch (state) {&#xA;    case OFF:&#xA;        analogWrite(LED_PIN, 255);&#xA;        state = ON;&#xA;        Serial.println(state);&#xA;        break;&#xA;    case ON:&#xA;        analogWrite(LED_PIN, 0);&#xA;        state = POT;&#xA;        Serial.println(state);&#xA;        break;&#xA;    case POT:&#xA;        Serial.println(state);&#xA;        int Mode = button_press();&#xA;        while (val &amp;lt; 1023) {&#xA;            val = (analogRead(pot) / 4);&#xA;            analogWrite(LED_PIN, val);&#xA;            Serial.println(val);&#xA;            state = OFF;&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20714" LastEditorUserId="20714" LastEditDate="2016-07-28T04:56:47.497" LastActivityDate="2016-07-28T12:49:34.013" Title="Constantly read analog in in SWITCH/CASE setup" Tags="|potentiometer|switch|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26706" PostTypeId="1" AcceptedAnswerId="26860" CreationDate="2016-07-25T23:13:07.033" Score="0" ViewCount="985" Body="&lt;p&gt;I have an Arducam-Mini-5MP with Arduino UNO R3. I am running the unaltered example &lt;a href=&quot;https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_Mini_OV5642_Video_Streaming/ArduCAM_Mini_OV5642_Video_Streaming.ino&quot; rel=&quot;nofollow&quot;&gt;ArduCAM_Mini_OV5642_Video_Streaming&lt;/a&gt; to the arduino and am running ArduCAM_host_v1.0.exe on my PC with huge successes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this state, I can reliably take photos at low resolution (up to 1280x720) in all tested settings. However, when I go to higher resolutions (2592x1944, 2048x1563, and 1920x1080), certain situations result in consistently corrupt images all with the exact size of 524288 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The images are corrupted whenever I point the camera outside my window, and images are fine when taking photos inside my house. At 1280x720, a typical photo inside my house is 80kb and a typical photo out the window is 190kb (more than double in size). I suppose some content of the photo is impacting the jpg compression?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, images are corrupt 100% of the time for the actual subject I want to take; but the camera works perfectly when I'm testing it indoors. In my scenario I can only capture 0.8MP before images become corrupt.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The frame buffer limit for Arducam is 512kb, so am I just running up against the constraints of the hardware? I feel a bit fooled because I bought a 5MP camera and can only take 0.8MP photos with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is my understanding of this failure correct -- is this the frame buffer size being hit by conditions impacting jpg compression? Are there Arducam shields available with higher frame buffers? Can I avoid this situation somehow?&lt;/p&gt;&#xA;" OwnerUserId="23286" LastEditorUserId="23286" LastEditDate="2016-07-25T23:51:23.613" LastActivityDate="2016-07-30T06:26:29.677" Title="Limited to 1MP still captures with OV5642 ArduCam Mini + Arduino Uno" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26707" PostTypeId="2" ParentId="26700" CreationDate="2016-07-25T23:48:26.160" Score="0" Body="&lt;p&gt;You'll need something on the Arduino that sends an event to your PC whenever the button is pressed. The easiest version of this would be the Serial channel over USB. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second, you'll need a program running on your PC that receives that Serial message and generates your desired keyboard and mouse events. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Windows, you can generate system wide keyboard and mouse events fairly easily using the Windows API. This would allow you to click a mouse, or keyboard button when inside of most programs written in Windows. &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ms171548(v=vs.110).aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://msdn.microsoft.com/en-us/library/ms171548(v=vs.110).aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, you can have problems sending spoofed events to video games that don't use standard Windows forms. You might find this answer helpful from StackOverflow - &lt;a href=&quot;https://stackoverflow.com/questions/7320424/c-win32-simulate-keypress-with-directinput&quot;&gt;https://stackoverflow.com/questions/7320424/c-win32-simulate-keypress-with-directinput&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23286" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-07-25T23:48:26.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26709" PostTypeId="1" AcceptedAnswerId="26710" CreationDate="2016-07-26T00:40:33.163" Score="0" ViewCount="25733" Body="&lt;p&gt;I have an ESP8266 12E module and I'm trying to connect it to arduino, without any shields or whatsoever. I've looked everywhere but all I can find is about ESP-01 or with a NodeMCU. I'd like to do the bridge manually, but I don't know which pins I should ground and which pins I should power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my current setup:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/9H6Wc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9H6Wc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And the following sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;//RX pin 2, TX pin 3&#xA;SoftwareSerial esp8266(2, 3);&#xA;&#xA;#define DEBUG true&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  esp8266.begin(115200);&#xA;  sendData(&quot;AT\r\n&quot;, 2000, DEBUG);&#xA;  delay(1000);&#xA;  Serial.println(&quot;Firmware version:&quot;);&#xA;  delay(3000);&#xA;  sendData(&quot;AT+GMR\r\n&quot;, 2000, DEBUG);&#xA;  Serial.println(&quot;** End **&quot;);&#xA;}&#xA;&#xA;void loop() {}&#xA;&#xA;String sendData(String command, const int timeout, boolean debug) {&#xA;  String response = &quot;&quot;;&#xA;  esp8266.print(command);&#xA;  long int time = millis();&#xA;  while ( (time + timeout) &amp;gt; millis())&#xA;  {&#xA;    while (esp8266.available())&#xA;    {&#xA;      // The esp has data so display its output to the serial window&#xA;      char c = esp8266.read(); // read the next character.&#xA;      response += c;&#xA;    }&#xA;  }&#xA;  if (debug)&#xA;  {&#xA;    Serial.print(response);&#xA;  }&#xA;  return response;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When run, I get the following output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Firmware version:&#xA;** End **&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the module, the led flashes when I power it up, but after that it remains off. I've already tested the voltage regulator with &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage&quot; rel=&quot;nofollow noreferrer&quot;&gt;ReadAnalogVoltage&lt;/a&gt;, and the output was 3.33v, so it is working. &lt;/p&gt;&#xA;" OwnerUserId="23280" LastEditorUserId="23280" LastEditDate="2016-07-27T11:23:09.387" LastActivityDate="2017-03-05T09:20:00.333" Title="How to connect ESP8266 12e directly to Arduino Uno (without shields)" Tags="|esp8266|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26710" PostTypeId="2" ParentId="26709" CreationDate="2016-07-26T00:51:53.717" Score="2" Body="&lt;p&gt;Make sure to specify as SoftwareSerial's Rx pin, the pin# connected to the ESP's Tx pin. They have to be crossed. (I just fumbled that myself, a couple of hours ago ):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is the ESP's Rx pin that needs the voltage divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also pullup the ESP's reset pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP-01 and ESP-12 modules use the same ESP8266 chip. The differences are in the number of pins brought out from the chip and made available on the board. Other differences include the firmware interpreters installed on them before shipment: &quot;NodeMCU&quot; is one. ESP-01 is usually shipped with the AT+ command interpreter unless it specified otherwise; I would expect the same for the others. Bottom line is they are connected pretty much alike. Interacting with them serially from an Arduino (or other device) then depends on the installed firmware, including whether you've installed your own. So far, I've used all of mine as WiFi modules using the AT+ interpreter they came with.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I pullup the reset pin? Also do I need to pullup it just for&#xA;  initial setup (changing baud rate and such) or should it be pulled up&#xA;  at all times?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I use a 10K-Ohm resistor to +3.3v as a pullup. You need it pulled up anytime you are not trying to force a hardware reset; grounding it resets the chip. I have never used a reset button on my ESPs. I just leave them pulled up. If you want one, it should short the reset pin to ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update 2 (wiring):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You've powered the ESP with 3v but your pullups are taken to the Arduino's 3.3v supply. Most chips have a slim tolerance for signal levels above their supply voltage. I'd suggest driving the entire ESP from your 3v battery - power &amp;amp; both pullups.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know the ESP-12E's pinouts to check them; I'm sure you have, and you might want to label the diagram so someone else can look over it too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then there's whatever &quot;chicken dance&quot; is needed on the reset and the GPIO line that needs to get toggled to start an upload. I don't know that sequence, but I think you need a grounding buttons on on each one to be able to sequence them. &lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-07-27T14:57:27.147" LastActivityDate="2016-07-27T14:57:27.147" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26711" PostTypeId="2" ParentId="26705" CreationDate="2016-07-26T03:03:26.517" Score="0" Body="&lt;p&gt;The problem is that it will only go through the POT case once, if you want it to repeatedly read the potentiometer, and then change the LED brightness, you would have to put the case in a loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, you might do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;case POT:&#xA;int Mode = digitalRead(BUTTONPIN);&#xA;while(Mode == LOW) {   &#xA;    val = (analogRead(pot) / 4);&#xA;        analogWrite(LED_PIN, val);&#xA;        Serial.println(val);&#xA;        state = OFF;&#xA;        break;&#xA;        Mode = digitalRead(BUTTONPIN);&#xA;    }&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want to use the debounce, do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static enum { OFF, ON, POT } state;&#xA;unsigned long now = millis();&#xA;int x = 0;&#xA;&#xA;while (x == 0) {&#xA;    switch (state) {&#xA;    case OFF:&#xA;        analogWrite(LED_PIN, 255);&#xA;        if (button_press()) {&#xA;        state = ON;&#xA;        }&#xA;        break;&#xA;    case ON:&#xA;        analogWrite(LED_PIN, 0);&#xA;        if (button_press()) {&#xA;        state = POT;&#xA;        }&#xA;        break;&#xA;    case POT:&#xA;        val = (analogRead(pot) / 4);&#xA;        analogWrite(LED_PIN, val);&#xA;        Serial.println(val);&#xA;        if (button_press()) {&#xA;        state = OFF;&#xA;        }&#xA;        break;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should work. What it's doing is basically just going through this while loop over and over and over again, and whenever the button is pressed, THEN it will switch state, but otherwise, it'l just do the same state again and again. This way the potentiometer will work AND the debounce. &lt;/p&gt;&#xA;" OwnerUserId="24199" LastEditorUserId="24199" LastEditDate="2016-07-28T12:49:34.013" LastActivityDate="2016-07-28T12:49:34.013" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26712" PostTypeId="2" ParentId="22848" CreationDate="2016-07-26T03:14:19.027" Score="0" Body="&lt;p&gt;adafruit has a resistive touch screen which is 2.8&quot; and works on most boards. Its 30 dollars and works well. It has instructions and all and libraries which you can use. Plug it into a breadboard, connect the jumpers and you're all set. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/product/1770&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/product/1770&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;on the other hand, Elegoo has made a very similar product, which can also be used on most boards if you plug it into a breadboard, but it is specially designed for the UNO. You can plug it straight into the UNO board, without the need of breadboards. This comes with a instructional DVD and is only 12 dollars on Amazon. It is also a resistive screen and basically the same product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B01EUVJYME&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/gp/product/B01EUVJYME/ref=oh_aui_detailpage_o04_s01?ie=UTF8&amp;amp;psc=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck!&lt;/p&gt;&#xA;" OwnerUserId="24199" LastActivityDate="2016-07-26T03:14:19.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26713" PostTypeId="2" ParentId="16530" CreationDate="2016-07-26T03:23:45.000" Score="4" Body="&lt;p&gt;&lt;strong&gt;Photon advantages:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The photon has cloud compatibility and wifi access. The Arduino doesn't without a separate shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A photon  about 1/4 the size of an Arduino UNO&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Photon is much cheaper than arduinos&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino UNO advantages:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino UNO has 5 volt AND 3.3 volt while Photon has only 3.3 volt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino has many resources while Photons don't since Photons are fairly new&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduinos don't need any wifi to work while Photons need to be connected to wifi and the cloud to flash code (Although there is a way to flash over USB cable, it is HIGHLY complicated with need of the terminal and DFU-UTIL installed.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UNO has 5 analog, 13 digital ports while Photon has only 5 analog, 7 digital&lt;/p&gt;&#xA;&#xA;&lt;p&gt;UNOs have female pins, so no breadboards are necessary for small, simple projects.&#xA;Photons have male pins, and they need to be plugged into a breadboard or soldered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Personally, I have both an UNO and a photon. Photons are useful for small and more compact projects, while Arduinos are for projects on a bigger scale. Unless you specifically need access to the cloud or access to WIFI, I would suggest buying the Arduino. Good luck!&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="24199" LastEditorUserId="24199" LastEditDate="2016-07-26T08:54:46.300" LastActivityDate="2016-07-26T08:54:46.300" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26714" PostTypeId="1" AcceptedAnswerId="26862" CreationDate="2016-07-26T04:16:43.543" Score="0" ViewCount="593" Body="&lt;p&gt;Howdie!  I trying to run a GPRS modem on an Arduino. My full stack is &lt;a href=&quot;http://nimbelink.com/skywire-gsmgprs/&quot; rel=&quot;nofollow&quot;&gt;Nimbelink's NL-SW-GPRS Modem&lt;/a&gt; (containing Telit GE910-QUAD GPRS module) with the &lt;a href=&quot;http://nimbelink.com/skywire-arduino-cellular-shield/&quot; rel=&quot;nofollow&quot;&gt;Nimbelink Arduino Development Shield&lt;/a&gt; on an Arduino UNO R3. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to connect to an FTP server and upload a file. I am following this &lt;a href=&quot;http://nimbelink.com/wp-content/uploads/2015/11/Skywire-FTP-Application-note.pdf&quot; rel=&quot;nofollow&quot;&gt;guide from Nimbelink&lt;/a&gt; and &lt;a href=&quot;http://www.telit.com/fileadmin/user_upload/products/Downloads/3G/Telit_IP_Easy_User_Guide_r19.pdf&quot; rel=&quot;nofollow&quot;&gt;section 3.3 from Telit's user guide&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am stuck because the AT#FTPOPEN command doesn't seem to ever timeout nor does it return any result (ERROR or OKAY).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the AT commands I am running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&amp;gt; OK&#xA;&#xA;AT+CGREG?&#xA;&amp;gt; +CGREG: 0,1&#xA;&amp;gt; OK&#xA;&#xA;AT#SIMDET=1&#xA;&amp;gt; OK&#xA;&#xA;AT+CGDCONT=1,&quot;IP&quot;,&quot;internet.com&quot;,&quot;0.0.0.0&quot;,0,0&#xA;&amp;gt; OK&#xA;&#xA;AT#SCFG=1,1,300,90,600,200&#xA;&amp;gt; OK&#xA;&#xA;AT#SGACTAUTH=0&#xA;&amp;gt; OK&#xA;&#xA;AT#SGACT=1,1&#xA;&amp;gt; &amp;lt;My IP Address&amp;gt;&#xA;&amp;gt; OK&#xA;&#xA;AT#FTPTO=100&#xA;&amp;gt; OK&#xA;&#xA;AT#FTPOPEN=&quot;209.86.62.76&quot;,&quot;anonymous&quot;,&quot;anonymous&quot;,0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where 209.86.62.76 is the IP address of ftp.earthlink.net which I am just using for testing purposes, but I have tried several others. I have tried with FTP mode 0 (active) and 1 (passive) with no change in behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The AT#FTPOPEN just never returns anything (no ERROR and no OK). I've waited up to 5 minutes. The command does returns &quot;ERROR&quot; if I deliberately mess up the syntax of the command (eg. AT#FTPOPEN=&quot;&quot;) but for any valid format it just seems to hang.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this a known problem or something I can easy work around? Am I doing something crazy with my timeout values? Is there an easy way to test the context that I activated with the SGACT?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is more of a question for an M2M forum, but I'm on an Arduino and it seems like there are many people using GSM modules on Arduino - so I thought I'd post here because I am a bit desperate. Thanks :)&lt;/p&gt;&#xA;" OwnerUserId="23286" LastActivityDate="2016-07-30T08:28:48.690" Title="Telit GPRS Module never returning and never timing out for command AT#FTPOPEN" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26715" PostTypeId="1" AcceptedAnswerId="26723" CreationDate="2016-07-26T05:53:33.663" Score="1" ViewCount="110" Body="&lt;p&gt;I have 4 usb Hard Drives and I just want to connect them to computer network directly without a traditional computer. Is there an any module with 4 usb ports and one RJ45 port. The module should able to connect drives to network as NAS (Network Area Storage) or other mounting possibility.&lt;/p&gt;&#xA;" OwnerUserId="7021" LastActivityDate="2016-07-26T08:01:45.903" Title="How to use Aiduino module to connect to computer network?" Tags="|arduino-mega|arduino-ide|arduino-nano|hardware|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26716" PostTypeId="1" AcceptedAnswerId="26724" CreationDate="2016-07-26T06:41:38.000" Score="0" ViewCount="62" Body="&lt;p&gt;I have changed the code with some help here. There are two buttons each one is set to turn on a LED. When the LED turns on it is timed and when the time is up it turns off. The problem I am having is that only one LED can be on at a time even though I am not using the delay() and I am using millis() to keep track of time. So if I press button one the first LED will turn on. Even if I press button two at this time the second LED wont turn on until the first one turns off. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin2 = 2;&#xA;const int ledPin3 = 3;    &#xA;const int buttonPin6 = 6;&#xA;const int buttonPin7 = 7;&#xA;&#xA;const unsigned long onTime = 10000;&#xA;unsigned long previousMillis = 0;&#xA;&#xA;void timer() {&#xA;&#xA;unsigned long previousMillis = millis();&#xA;unsigned long currentMillis = millis();&#xA;digitalWrite(ledPin2, HIGH);&#xA;&#xA;while ((currentMillis - previousMillis) &amp;lt; onTime) {&#xA;&#xA;    currentMillis = millis();&#xA;}&#xA;&#xA;digitalWrite(ledPin2, LOW);&#xA;}&#xA;&#xA;void timer2() {&#xA;&#xA;unsigned long previousMillis = millis();&#xA;unsigned long currentMillis = millis();&#xA;digitalWrite(ledPin3, HIGH);&#xA;&#xA;while ((currentMillis - previousMillis) &amp;lt; onTime) {&#xA;&#xA;    currentMillis = millis();&#xA;}&#xA;&#xA;digitalWrite(ledPin3, LOW);&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;Serial.begin(9600);&#xA;pinMode(ledPin2, OUTPUT);&#xA;pinMode(ledPin3, OUTPUT);&#xA;pinMode(buttonPin6, INPUT);&#xA;pinMode(buttonPin7, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;int buttonState2 = digitalRead(buttonPin6);&#xA;if (buttonState2 == HIGH) timer2();&#xA;&#xA;int buttonState = digitalRead(buttonPin7);&#xA;if (buttonState == HIGH) timer();&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-07-26T09:45:59.230" Title="Follow up question to Calling a timer when a button is pushed" Tags="|timers|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26719" PostTypeId="2" ParentId="26716" CreationDate="2016-07-26T07:47:28.293" Score="3" Body="&lt;p&gt;Yes, it is because in timer() and timer2() you busy-loop with while until the condition is not met. Hence, when buttonState2 is HIGH, your code will execute timer2() until the condition of the while loop is not met. You are effectively doing a delay.&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-07-26T07:47:28.293" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26720" PostTypeId="1" CreationDate="2016-07-26T07:49:39.513" Score="0" ViewCount="188" Body="&lt;p&gt;I don't think USB chip is more expensive than Ethernet chip. So, I expect there should exist a board like Arduino, but where USB is removed in favour of Ethernet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are there such boards?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2016-07-27T13:36:49.900" Title="Arduino-like ethernet only board?" Tags="|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26721" PostTypeId="2" ParentId="26720" CreationDate="2016-07-26T07:54:34.887" Score="2" Body="&lt;p&gt;Yes, there's the Arduino Ethernet. Available from &lt;a href=&quot;https://www.sparkfun.com/products/11229&quot; rel=&quot;nofollow&quot;&gt;Sparkfun&lt;/a&gt; for example&lt;/p&gt;&#xA;" OwnerUserId="4909" LastActivityDate="2016-07-26T07:54:34.887" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26722" PostTypeId="2" ParentId="26709" CreationDate="2016-07-26T07:58:23.810" Score="1" Body="&lt;p&gt;Oh boy, lot of things can be the problem here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First of all: a voltage divider using 10k-10k has an output of 2.5V when the source is 5V. The ESPs run on 3.3V, so this effectively could mean the commands are completely scrambled when they arrive at the ESP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other way around and you're putting 3.3V comms into a 5V device. This isn't a problem per say, but it could definitely lead to problems. I suggest you use a bi-directional logic level converter which will transform a 5V command to the 3.3V ESP level, and back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your wiring between the Arduino and the ESP seems al right, but make sure TX~RX and RX~TX are connected, not TX~TX and RX~RX, but as I said above: use a bi-directional logic level converter.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-26T07:58:23.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26723" PostTypeId="2" ParentId="26715" CreationDate="2016-07-26T08:01:45.903" Score="3" Body="&lt;p&gt;An Arduino is completely incapable of doing such a difficult task. It's literally impossible because the processor isn't strong enough, it has no built in network capabilities that support NAS, it has no USB software built in, and so on and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you &lt;em&gt;can&lt;/em&gt; use a Raspberry Pi. They are cheap for their capabilities, they do require quite some programming to get it to work but there's a huge community that has guides for everything. Best of luck :)&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-07-26T08:01:45.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26724" PostTypeId="2" ParentId="26716" CreationDate="2016-07-26T08:41:33.750" Score="3" Body="&lt;p&gt;As jogco says, you are (effectively) using a delay in your timer function, by doing this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while ((currentMillis - previousMillis) &amp;lt; onTime) {&#xA;&#xA;    currentMillis = millis();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What you want is to remember the time each LED was switched on, and each every time through the loop check if the required time has passed. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int ledPin2 = 2;&#xA;const int ledPin3 = 3;    &#xA;const int buttonPin6 = 6;&#xA;const int buttonPin7 = 7;&#xA;&#xA;const unsigned long onTime = 10000;&#xA;unsigned long led1_start = 0;&#xA;unsigned long led2_start = 0;&#xA;boolean led1_on = false;&#xA;boolean led2_on = false;&#xA;&#xA;void timerOn(int led) {&#xA;&#xA;    switch(led) {&#xA;        case 1:&#xA;            led1_start = millis();&#xA;            digitalWrite(ledPin2, HIGH);&#xA;            led1_on = true;&#xA;            break;&#xA;        case 2:&#xA;            led2_start = millis();&#xA;            digitalWrite(ledPin3, HIGH);&#xA;            led2_on = true;&#xA;            break;&#xA;    }&#xA;}&#xA;&#xA;void timerOff(int led) {&#xA;&#xA;    switch(led) {&#xA;        case 1:&#xA;            digitalWrite(ledPin2, LOW);&#xA;            led1_on = false;&#xA;            break;&#xA;        case 2:&#xA;            digitalWrite(ledPin3, LOW);&#xA;            led2_on = false;&#xA;            break;&#xA;    }&#xA;}&#xA;&#xA;boolean checkTime(unsigned long startTime) {&#xA;      return ((startTime + onTime) &amp;gt;= millis());&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    pinMode(ledPin2, OUTPUT);&#xA;    pinMode(ledPin3, OUTPUT);&#xA;    pinMode(buttonPin6, INPUT);&#xA;    pinMode(buttonPin7, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    int buttonState2 = digitalRead(buttonPin6);&#xA;    if (buttonState2 == HIGH) timerOn(2);&#xA;&#xA;    int buttonState = digitalRead(buttonPin7);&#xA;    if (buttonState == HIGH) timerOn(1);&#xA;&#xA;    if (led1_on) {&#xA;        if (checkTime(led1_start)) timerOff(1);&#xA;    }&#xA;&#xA;    if (led2_on) {&#xA;        if (checkTime(led2_start)) timerOff(2);&#xA;    }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In fact I would look at arrays for the pin numbers and status/time variables, to make it more reusable...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPins[2] = {2, 3};&#xA;int ledStart[2] = {0, 0};&#xA;int buttonPins[2] = {6, 7};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;... and the like&lt;/p&gt;&#xA;" OwnerUserId="24169" LastEditorUserId="24169" LastEditDate="2016-07-26T09:45:59.230" LastActivityDate="2016-07-26T09:45:59.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26728" PostTypeId="1" CreationDate="2016-07-26T10:45:35.777" Score="1" ViewCount="1527" Body="&lt;p&gt;I was wondering if its possible to program the esp8266 to receive firmware updates without the use of an IDE to program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Use Case: &#xA;This device should be setup to the WiFi network scan an IP for a firmware update and update itself if needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help is greatly appreciated. Thank you&lt;/p&gt;&#xA;" OwnerUserId="13542" LastActivityDate="2016-12-26T13:19:32.080" Title="OTA Update Esp8266 without IDE" Tags="|arduino-ide|esp8266|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26729" PostTypeId="2" ParentId="26700" CreationDate="2016-07-26T10:51:08.573" Score="0" Body="&lt;p&gt;EDIT: check @JohnBurger 's comment. THIS is NOT good for the UNO.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect your Arduino as a keyboard to the computer. There is a Keyboard Arduino library you can use. Here is a reference: &#xA;&lt;a href=&quot;https://www.arduino.cc/en/Reference/KeyboardWrite&quot; rel=&quot;nofollow&quot;&gt;KeyboardWrite&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example this line of code will react just like you pressed A on your keyboard:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Keyboard.write(65);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23120" LastEditorUserId="23120" LastEditDate="2016-07-26T11:18:46.507" LastActivityDate="2016-07-26T11:18:46.507" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26733" PostTypeId="1" CreationDate="2016-07-26T17:27:17.663" Score="1" ViewCount="9663" Body="&lt;p&gt;I wrote the code that if an interrupt is generated, get GSM location and send a  message.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first time the interrupt is generated, I got the correct GSM location using &lt;code&gt;AT+CIPGSMLOC=1,1&lt;/code&gt; and successfully sent a message using the &lt;code&gt;AT+CMGS=+91xxxxxxxx&lt;/code&gt;command.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But the next time an interrupt was generated, &lt;code&gt;AT+CIPGSMLOC=1,1&lt;/code&gt; gave a wrong location. When I commented out the code to send a message, on every interrupt generated I am getting the correct GSM location. So it seems like the problem is occurring after sending a message. But I have no clue what exactly is going wrong. Following is my code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: on restarting the module, I'm again getting the correct location the first time, before sending a message.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  mySerial.begin(9600);&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;  }&#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(sensorPin, INPUT);&#xA;  // Attach an interrupt to the ISR vector&#xA;  attachInterrupt(0, pin_ISR, FALLING);&#xA;}&#xA;&#xA;/////////***GSM RESPONSE***///////////&#xA;String DisplayGSMResponse() {&#xA;  if(mySerial.available()) {&#xA;    String gsm_input=&quot;&quot;;&#xA;    while(mySerial.available()) {&#xA;      gsm_input+= (char)mySerial.read();&#xA;    }&#xA;    gsm_input.trim();&#xA;    delay(1000);&#xA;    Serial.println(gsm_input);&#xA;    return gsm_input;&#xA;  }&#xA;}&#xA;&#xA;void SendMessage(String mobNum,String Location) {&#xA;  Serial.println(&quot;Sending message..&quot;);&#xA;  mySerial.println(&quot;AT+CMGF=1&quot;);&#xA;  //Sets the GSM Module in Text Mode&#xA;  delay(2000);&#xA;  // Delay of 1000 milli seconds or 1 second&#xA;  DisplayGSMResponse();&#xA;  mySerial.println(&quot;AT+CMGS=\&quot;&quot;+mobNum+&quot;\&quot;\r&quot;);&#xA;  // mobile Number&#xA;  delay(4000);&#xA;  DisplayGSMResponse();&#xA;  cleanBuffer();&#xA;  mySerial.print(&quot;test&quot;);&#xA;  // The SMS text you want to send&#xA;  delay(100);&#xA;  mySerial.println((char)26);&#xA;  // ASCII code of CTRL+Z&#xA;  delay(8000);&#xA;  DisplayGSMResponse();&#xA;}&#xA;&#xA;void gprsInit() {&#xA;  if (isGPRSInit) {&#xA;    return;&#xA;  }&#xA;  Serial.println(&quot;GPRS INITIALIZING&quot;);&#xA;  mySerial.println(&quot;AT+SAPBR=3,1,\&quot;CONTYPE\&quot;,\&quot;GPRS\&quot;&quot;);&#xA;  delay(2000);&#xA;  DisplayGSMResponse();&#xA;  mySerial.println(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;INTERNET\&quot;&quot;);&#xA;  delay(2000);&#xA;  DisplayGSMResponse();&#xA;  mySerial.println(&quot;AT+SAPBR=1,1&quot;);&#xA;  delay(8000);&#xA;  DisplayGSMResponse();&#xA;  mySerial.println(&quot;AT+SAPBR=2,1&quot;);&#xA;  delay(2000);&#xA;  DisplayGSMResponse();&#xA;  isGPRSInit = true;&#xA;}&#xA;&#xA;void gprsterm() {&#xA;  mySerial.println(&quot;AT+SAPBR=0,1&quot;);&#xA;  delay(1000);&#xA;  DisplayGSMResponse();&#xA;  isGPRSInit = false;&#xA;}&#xA;&#xA;String getGPS() {&#xA;  Serial.println(&quot;GETTING GPS LOCATION&quot;);&#xA;  String loc = &quot;&quot;;&#xA;  String location = &quot;&quot;;&#xA;  mySerial.println(&quot;AT+CIPGSMLOC=1,1&quot;);&#xA;  delay(3000);&#xA;  loc = DisplayGSMResponse();&#xA;  return location;&#xA;}&#xA;&#xA;void loop() {&#xA;  if (buttonState == 1) {&#xA;    detachInterrupt(0);&#xA;    gprsInit();&#xA;    location = getGPS();&#xA;    SendMessage(mobileNumber, location);&#xA;    gprsterm();&#xA;    Serial.println(&quot;location = &quot; + location);&#xA;    buttonState = 0;&#xA;    location = &quot;&quot;;&#xA;    attachInterrupt(0, pin_ISR, FALLING );&#xA;  }&#xA;}&#xA;&#xA;void pin_ISR() {&#xA;  buttonState = 1;&#xA;  Serial.println(&quot;interrupt&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT: added gprsterm function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note: I removed the interrupt and called the code inside the loop function twice. The first time I got a correct result. The second time a wrong result. So it seems like the interrupt is not be causing the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT2:&#xA;One interesting thing I found is that at my home it is showing correct results every time, but in the office it is showing a wrong location on second location call i.e after the SMS was sent and we get the GSM location using &lt;code&gt;AT+CIPGSMLOC=1,1&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="24165" LastEditorUserId="4628" LastEditDate="2017-06-21T04:28:11.113" LastActivityDate="2020-01-22T10:02:15.303" Title="SIM808 module: GSM location command (AT+CIPGSMLOC=1,1) giving wrong value after execution of sending message command (AT+CMGS=+91xxxxxxxx)" Tags="|serial|arduino-mega|gsm|gps|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26734" PostTypeId="2" ParentId="26700" CreationDate="2016-07-26T17:49:00.287" Score="0" Body="&lt;p&gt;You can do USB HID device on any AVR or Arduino chip without USB hardware interface by bitbanging on any 2 DIO:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow&quot;&gt;https://www.obdev.at/products/vusb/index.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Supports 4 endpoints &lt;strike&gt;(like 2 mouse and 2 keyboard, if makes sense :)&lt;/strike&gt;. Sure no additional software or driver is needed on OS side (default drivers shall be ok if correct VID/PID specified).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;b&gt;EDIT:&lt;/b&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Seems 2 endpoints are required for USB HID keyboard. If remaining 2 is enough for USB HID joystick, it could be useful for flight sim.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="13594" LastEditDate="2016-07-26T18:12:46.413" LastActivityDate="2016-07-26T18:12:46.413" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26735" PostTypeId="1" CreationDate="2016-07-26T21:39:14.683" Score="0" ViewCount="1746" Body="&lt;p&gt;I've got a weird issue, probably something I'm missing but have no clue what. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Got some simple float sensors connected to D2 - D5 on a Nano. Need internal pull-up to eliminate a floating value. Wrote this little sketch to test things: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(2, INPUT_PULLUP);&#xA;int sensorVal = digitalRead(2);&#xA;Serial.println(sensorVal);&#xA;&#xA;pinMode(3, INPUT_PULLUP);&#xA;int sensorVal = digitalRead(3);&#xA;Serial.println(sensorVal);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There's one sensor connected reading HIGH and one reading LOW. This works as expected (displays 1010101010...). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I've got this connected to my Raspberry Pi via Bluetooth (BT shield connected to RX/TX) and using Firmata to communicate with the Nano. Code (C#):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_arduino.pinMode(2, PinMode.PULLUP);&#xA;PinState result2 = _arduino.digitalRead(2);&#xA;&#xA;_arduino.pinMode(3, PinMode.PULLUP);&#xA;PinState result3 = _arduino.digitalRead(3);&#xA;&#xA;Debug.WriteLine($&quot;Result pin 2: {result2} and pin 3: {result3}&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This always gives me two pinstates of LOW, even though I'm absolutely sure it should be reading HIGH as my test sketch is outputting the correct value. This driving me nuts. The Firmata sketch I've got loaded on the Arduino is this one: &lt;a href=&quot;https://github.com/jsiegmund/submerged/blob/master/src/Arduino%20Sketches/SubmergedCabinetModule/SubmergedCabinetModule.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jsiegmund/submerged/blob/master/src/Arduino%20Sketches/SubmergedCabinetModule/SubmergedCabinetModule.ino&lt;/a&gt;. Also tried the latest available version from the firmata repo, doesn't solve the issue. As I've got the BlueTooth shield connected to RX/TX (and wasn't able to change that) I cannot use the serial monitor to provide more debug info. Should anyone know how to change that, would also be appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Btw for other things, Firmata is working just fine. So the communication itself shouldn't be the issue I think. &lt;/p&gt;&#xA;" OwnerUserId="14525" LastEditorUserId="14525" LastEditDate="2016-07-27T05:50:58.890" LastActivityDate="2016-07-27T07:15:38.790" Title="Reading digital port with pullup via Firmata" Tags="|arduino-nano|pull-up|firmata|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26737" PostTypeId="2" ParentId="26728" CreationDate="2016-07-27T01:16:20.880" Score="0" Body="&lt;p&gt;The firmware host will need a loader application that can talk to the bootloader in the ESP. You'll probably need to build a bit of hardware on the client to sequence grounding of the appropriate GPIO &amp;amp; Reset pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The application on the ESP would probably need to do something like:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Discover the availability of an update;&lt;/li&gt;&#xA;&lt;li&gt;Tell the host to start its loader application;&lt;/li&gt;&#xA;&lt;li&gt;Begin the local I/O-pin sequencer to start the local bootloader.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The final step should cause the chip to reset and the bootloader to take control. Both the loader on the host and the bootloader will nned to be somewhat tolerant of the potential network delays.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-07-27T01:16:20.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26738" PostTypeId="1" CreationDate="2016-07-27T03:13:08.710" Score="0" ViewCount="157" Body="&lt;p&gt;I am in a pickle and want to know if you can help me. I have an IR sensor and receiver and want a program that makes a light bulb flash or detect whenever the IR receiver is in range.&#xA;So whenever the IR sender detects the receiver, it should print &quot;detect&quot;. This will be done using the Arduino program. And it is an Arduino Nano I am using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These are the things I use:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dx.com/p/keyestudio-digital-ir-receiver-module-for-arduino-black-429206#.V5gcpzYko-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.dx.com/p/keyestudio-digital-ir-receiver-module-for-arduino-black-429206#.V5gcpzYko-U&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.dx.com/p/38khz-ir-infrared-transmitter-module-for-arduino-135040#.V5gcpjYko-U&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.dx.com/p/38khz-ir-infrared-transmitter-module-for-arduino-135040#.V5gcpjYko-U&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How should this program look like? Anyone have the code for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Never mind the LED blinking, I just want the program to know whenever the receiver is detected and probably display it somehow. My plan is to send the number of times the transmitter detects the receiver to an Android app in the end.&lt;/p&gt;&#xA;" OwnerUserId="24276" OwnerDisplayName="Face " LastEditorUserId="27346" LastEditDate="2018-11-04T19:15:12.027" LastActivityDate="2018-11-04T19:15:12.027" Title="ir sender detecting receiver and display" Tags="|ir|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="26739" PostTypeId="2" ParentId="26738" CreationDate="2016-07-27T03:43:14.423" Score="2" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IR is a one-way protocol. The transmitter has no way of knowing whether a receiver is in range; it's literally just an LED that emits infrared instead of visible light.&lt;/p&gt;&#xA;" OwnerDisplayName="user7800" LastActivityDate="2016-07-27T03:43:14.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26740" PostTypeId="2" ParentId="26738" CreationDate="2016-07-27T04:18:10.443" Score="1" Body="&lt;p&gt;Assuming you got receiver and transmitter mixed up, then its simple. Otherwise, its not as simple. As @duskwuff points out, simple IR is one-way. The Transmitter here is just an IR Led. That's it. The Receiver is a Remote Control type IR Receiver, looks for a 38khz modulated IR signal, and removes the 38khz carrier wave, passing on the data to be read by the other end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For a IR beacon type setup, in either simple or two way mode, you'd need two micro controllers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Microcontroller A is the Transmitter. All it does is repeatedly send out an IR modulated code. The Arduino IRLib library can do this. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Microcontroller B is the Receiver. It looks for that specific code, and if found, does X, which could be print to serial, or send over bluetooth to a phone.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Complex, both receive and send:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microcontroller A is the main part&lt;/strong&gt;. It sends a code then switches to receive mode for X seconds. If it receives a confirmation or its own code back, it tells the phone/pc it has been found or flashes a different LED.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Microcontroller B is &lt;strong&gt;a beacon/repeater&lt;/strong&gt;. It waits to receive the code above, then switches to transmit mode, and sends the same code or a different code back. That's all it does. A Basic IR Remote Control Repeater.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/using-an-infrared-library?view=all&quot; rel=&quot;nofollow&quot;&gt;This tutorial at Adafruit&lt;/a&gt; explains it all, with code examples.&lt;/p&gt;&#xA;" OwnerUserId="21074" OwnerDisplayName="cde" LastActivityDate="2016-07-27T04:26:09.567" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26741" PostTypeId="1" AcceptedAnswerId="26748" CreationDate="2016-07-27T05:35:20.747" Score="0" ViewCount="56" Body="&lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/assets/3813&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/assets/3813&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I understand that &lt;code&gt;analog 4&lt;/code&gt; and &lt;code&gt;5&lt;/code&gt; are &lt;code&gt;SDA/SLC&lt;/code&gt;, isn't the picture also showing &lt;code&gt;5v&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt; being plugged into two analog pins? Does that work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have it wired up to the actual &lt;code&gt;5v&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt;, but it would be convieniet to be able to stack the RTC like they show in the picture&lt;/p&gt;&#xA;" OwnerUserId="24230" LastActivityDate="2016-07-27T09:20:17.180" Title="Please explain this adafruit image for connecting a DS1307 RTC" Tags="|arduino-uno|rtc|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26743" PostTypeId="1" CreationDate="2016-07-27T06:32:20.280" Score="0" ViewCount="900" Body="&lt;p&gt;I am new in the Arduino area.&lt;br&gt;&#xA;What is necessary to control motors through Arduinos. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What is the difference between &lt;a href=&quot;http://www.allegromicro.com/en/Products/Motor-Driver-And-Interface-ICs/Bipolar-Stepper-Motor-Drivers/A4988.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;A4988&lt;/a&gt; and the Arduino motor shield? &lt;/li&gt;&#xA;&lt;li&gt;Is one A4988 needed for each stepper motor? &lt;/li&gt;&#xA;&lt;li&gt;Or is one A4988 enough for all motors? &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="24234" LastEditorUserId="28084" LastEditDate="2016-11-24T20:47:03.397" LastActivityDate="2016-12-24T23:50:53.567" Title="Arduino and A4988" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26744" PostTypeId="2" ParentId="25703" CreationDate="2016-07-27T06:54:03.420" Score="1" Body="&lt;p&gt;If you are constructing a complex circuits or connecting many boards and sensors together, you really need to provide a common ground for all the devices. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main reason is here we are dealing voltage and different circuits operate at different voltages. It is important to understand that voltage is the potential difference between two points in the circuit. This value is relative to the circuit itself since every circuit has its own ground (GND) pin. What this means is there is no absolute potential difference for a complex circuits. Hence, it is important to establish a common ground such that all potential difference can be measured from a common GND pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, consider you have an arduino (operates at 5V) connected to motor controllers or relays (operates at 12V) and there are no common ground established between them. This will mess up the signals from arduino to motor controllers or relays. The output signals coming from the arduino may not be 5V but lower. Therefore, it is not detected by the motor controllers/relays. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope this helps.&lt;/p&gt;&#xA;" OwnerUserId="13456" LastActivityDate="2016-07-27T06:54:03.420" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26745" PostTypeId="2" ParentId="26735" CreationDate="2016-07-27T07:15:38.790" Score="1" Body="&lt;p&gt;Never mind, I found out what the problem is. The Firmata SDK (Remote Wiring) for Windows just completely ignores the PULLUP pin mode. There are PR (&lt;a href=&quot;https://github.com/ms-iot/remote-wiring/pull/102&quot; rel=&quot;nofollow&quot;&gt;https://github.com/ms-iot/remote-wiring/pull/102&lt;/a&gt;) which fixes this, now it's working just fine.&lt;/p&gt;&#xA;" OwnerUserId="14525" LastActivityDate="2016-07-27T07:15:38.790" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26746" PostTypeId="2" ParentId="26743" CreationDate="2016-07-27T07:54:07.113" Score="1" Body="&lt;p&gt;An A4988 can control a single motor and supply up to 35V at 1.5A.&#xA;An Arduino motor shield can drive 2 DC Motors or 1 stepper motor at up to 12V and 4A/2A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An A4988 needs mounting.&#xA;A motor shield drops straight in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are other options, including getting the ICs and doing it your self.  I have a motor shield which drives 4 DC motors or 2 Stepper motors that I got off eBay.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-27T07:54:07.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26748" PostTypeId="2" ParentId="26741" CreationDate="2016-07-27T09:20:17.180" Score="3" Body="&lt;p&gt;It's written in &lt;a href=&quot;https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up&quot; rel=&quot;nofollow&quot;&gt;the tutorial&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you set analog pin 3 (digital 17) to an OUTPUT and HIGH and analog pin 2 (digital 16) to an OUTPUT and LOW you can power the RTC directly from the pins!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-27T09:20:17.180" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26749" PostTypeId="2" ParentId="26683" CreationDate="2016-07-27T10:06:33.713" Score="1" Body="&lt;p&gt;I highly suggest checking out this YouTube video (&lt;a href=&quot;https://www.youtube.com/watch?v=5v5A3j7Rrco&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=5v5A3j7Rrco&lt;/a&gt;), especially around 21:30. It goes over in detail to do exactly what you are asking for, mainly the headings with IDs for each data point. At the end of the day you are going to need something that looks similar to this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;float id = 0; //used to provide a numbered ID to each data point&#xA;&#xA;void setup(){&#xA;//initialize all your once-run variables and such&#xA;}&#xA;&#xA;void loop(){&#xA;  //Write Log File Header&#xA;  File logFile = SD.open(&quot;NAME.csv&quot;, FILE_WRITE); &#xA;&#xA;  if (logFile){&#xA;    logFile.println(&quot;, , , ,&quot;); //Just a leading blank line, incase there was previous data&#xA;&#xA;    String header = &quot;ID, Time, Light, Temp&quot;; //These will be the headers for your excel file, CHANGE &quot;&quot; to whatevr headers you would like to use&#xA;    logFile.println(header);&#xA;    logFile.close();&#xA;    Serial.println(header);&#xA;  }&#xA;&#xA;  else {&#xA;    Serial.println(&quot;Couldn't open log file&quot;);&#xA;  }&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is all code that I currently use to do the exact same thing as you, and its a small edit from what Jeremy Blum does in the YouTube video I just linked you too. This is how the header files will look on an excel sheet, I took a screenshot of an actual file I have created using this method:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xF2uC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xF2uC.png&quot; alt=&quot;Sample File with Headers&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21627" LastActivityDate="2016-07-27T10:06:33.713" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26750" PostTypeId="1" CreationDate="2016-07-27T10:57:48.663" Score="0" ViewCount="76" Body="&lt;p&gt;I am currently in a arduino project to read some parameters from another microcontroller serially and the arduino is supposed to transmit these serially to dweet.io cloud. I use SIM900 modem for this. But my problem is that if i put some data to the variables, then the post to the cloud becomes unsuccessfull. Without any data in all parameters, the code runs fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please find the code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char code[4] = {'\0'}, voltage[4] = {'\0'}, current[4] = {'\0'}, mcurrent[4] = {'\0'}, acurrent[4] = {'\0'}, power[4] = {'\0'}, pf[4] = {'\0'}, freq[4] = {'\0'}, temp[4] = {'\0'};&#xA;const char APN[18] = &quot;bsnlnet&quot;;&#xA;byte dtype = 0;&#xA;&#xA;#include &amp;lt;avr/pgmspace.h&amp;gt;&#xA;&#xA;void read_comp() {&#xA;    byte flag = 0, index = 0, l = 0;&#xA;    char c;&#xA;    char readings[8] = {'\0'};&#xA;    dtype = 0;&#xA;&#xA;    do {&#xA;        while (Serial.available() &amp;amp;&amp;amp; l == 0) {&#xA;            c = Serial.read();&#xA;            delay(20);&#xA;&#xA;            if (c == '\n') {&#xA;                l = 1;&#xA;                break;&#xA;            } else {&#xA;                readings[index] = c;&#xA;                index++;&#xA;            }&#xA;        }&#xA;&#xA;        readings[index] = '\0';&#xA;        index = 0;&#xA;        l = 0;&#xA;&#xA;        if (readings[0] == 'v' || readings[0] == 'V') {             //check if received reading is voltage&#xA;            dtype = 1;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'o') {&#xA;                flag = 100;&#xA;            }&#xA;        } else if (readings[0] == 'c' || readings[0] == 'C') {  //check if received reading is current&#xA;            dtype = 2;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'u') {&#xA;                flag = 100;&#xA;            }&#xA;        } else if (flag == 1 &amp;amp;&amp;amp; readings[1] == 'o') {&#xA;            dtype = 9;&#xA;            flag = 100;&#xA;        } else if (readings[0] == 'm' || readings[0] == 'M') {&#xA;            dtype = 3;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'c' &amp;amp;&amp;amp; flag == 1) {&#xA;                flag = 100;&#xA;            }&#xA;        } else if (readings[0] == 'a' || readings[0] == 'A') {&#xA;            dtype = 4;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'c') {&#xA;                flag = 100;&#xA;            }&#xA;        } else if (readings[0] == 'p' || readings[0] == 'P') {&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'o') {&#xA;                flag = 100;&#xA;                dtype = 5;&#xA;            } else if (readings[1] == 'f' || readings[1] == 'F') {&#xA;                flag = 100;&#xA;                dtype = 6;&#xA;            }&#xA;        } else if (readings[0] == 'f' || readings[0] == 'F') {&#xA;            dtype = 7;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'r') {&#xA;                flag = 100;&#xA;            }&#xA;        } else if (readings[0] == 't' || readings[0] == 'T') {&#xA;            dtype = 8;&#xA;            flag = 1;&#xA;&#xA;            if (readings[1] == 'e') {&#xA;                flag = 100;&#xA;            }&#xA;        }&#xA;&#xA;        if (flag == 100) {&#xA;            switch (dtype) {&#xA;                case 1:&#xA;                    voltage[0] = readings[3];&#xA;                    voltage[1] = readings[4];&#xA;                    voltage[2] = readings[5];&#xA;                    voltage[3] = readings[6];&#xA;                    voltage[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 2:&#xA;                    current[0] = readings[3];&#xA;                    current[1] = readings[4];&#xA;                    current[2] = readings[5];&#xA;                    current[3] = readings[6];&#xA;                    current[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 3:&#xA;                    mcurrent[0] = readings[3];&#xA;                    mcurrent[1] = readings[4];&#xA;                    mcurrent[2] = readings[5];&#xA;                    mcurrent[3] = readings[3];&#xA;                    mcurrent[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 4:&#xA;                    acurrent[0] = readings[3];&#xA;                    acurrent[1] = readings[4];&#xA;                    acurrent[2] = readings[5];&#xA;                    acurrent[3] = readings[6];&#xA;                    acurrent[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 5:&#xA;                    power[0] = readings[3];&#xA;                    power[1] = readings[4];&#xA;                    power[2] = readings[5];&#xA;                    power[3] = readings[6];&#xA;                    power[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 6:&#xA;                    pf[0] = readings[3];&#xA;                    pf[1] = readings[4];&#xA;                    pf[2] = readings[5];&#xA;                    pf[3] = readings[6];&#xA;                    pf[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 7:&#xA;                    freq[0] = readings[3];&#xA;                    freq[1] = readings[4];&#xA;                    freq[2] = readings[5];&#xA;                    freq[3] = readings[6];&#xA;                    freq[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 8:&#xA;                    temp[0] = readings[3];&#xA;                    temp[1] = readings[4];&#xA;                    temp[2] = readings[5];&#xA;                    temp[3] = readings[6];&#xA;                    temp[4] = '\0';&#xA;                    flag = 0;&#xA;                    break;&#xA;&#xA;                case 9:&#xA;                    code[0] = readings[3];&#xA;                    code[1] = readings[4];&#xA;                    code[2] = readings[5];&#xA;                    code[3] = readings[6];&#xA;                    code[4] = '\0';&#xA;                    dtype = 10;&#xA;                    flag = 0;&#xA;                    break;&#xA;            }&#xA;        }&#xA;    } while (dtype != 10);&#xA;}&#xA;&#xA;void modem_initialization(void) {&#xA;    char rec_data, r;&#xA;    byte network_status = 0 ;//network_status initialized as zero&#xA;    byte status_check = 0 ;//status_check initialized as zero&#xA;    byte Serial3_cnt = 0;//Serial3_cnt initialized as zero&#xA;    byte ok_flag = 0; //ok_flag initialized as zero&#xA;    byte count = 0; //count initialized as zero&#xA;    clear_rx_buffer();&#xA;&#xA;    while (Serial3_cnt &amp;lt; 4) { // repeat entire loop until Serial3_cnt less than 5&#xA;        switch (Serial3_cnt) {&#xA;            case 0:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;AT&quot;));// Attention command to wake up Serial3 modem&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 1:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;ATE0&quot;));//Command for disable echo&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            /*case 2: clear_rx_buffer();//clearing receiving buffer&#xA;                   // Serial3.println(&quot;ATV0&quot;);// Command for numeric response after this '0'(zero) will be recieved instead of &quot;OK&quot;&#xA;                    delay(1000);&#xA;                    break;*/&#xA;            case 2:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;AT&amp;amp;W&quot;));// Command TO SAVE SETTINGS&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 3:&#xA;                Serial3_cnt = 4;// exit from the loop&#xA;                break;&#xA;&#xA;            default :&#xA;                break;&#xA;        }&#xA;&#xA;        while (Serial3.available() &amp;gt; 0) {&#xA;            rec_data = Serial3.read();&#xA;&#xA;            if (rec_data == 'O') { // 'o' is recieved&#xA;                ok_flag = 1;&#xA;            } else if (ok_flag == 1 &amp;amp;&amp;amp; rec_data == 'K') { // 'K' is recieved&#xA;                Serial3_cnt ++;&#xA;                ok_flag = 0;&#xA;            } else if (rec_data == '0') { // '0'(zero) is recieved (numeric response)&#xA;                Serial3_cnt ++;&#xA;                ok_flag = 0;&#xA;            } else if (rec_data == '+') { // '+' is recieved message&#xA;                clear_rx_buffer();&#xA;&#xA;                if (Serial3_cnt &amp;gt; 0) {&#xA;                    Serial3_cnt --;&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    Serial3_cnt = 0;&#xA;    ok_flag = 0;&#xA;&#xA;    while (network_status == 0) { //wait for PIN READY&#xA;        if (status_check == 0) {&#xA;            delay(1000);&#xA;            status_check = 1 ;&#xA;            clear_rx_buffer();&#xA;            Serial3.println(F(&quot;AT+CPIN?&quot;)); //checkin PIN return ready(+CPIN: READY) with a valid simcard otherwise error&#xA;        }&#xA;&#xA;        while (Serial3.available() &amp;gt; 0) {&#xA;            rec_data = Serial3.read();&#xA;&#xA;            if (rec_data == '+' &amp;amp;&amp;amp; status_check == 1) { // '+' is recieved&#xA;                status_check = 2 ;&#xA;            } else if (rec_data == 'C' &amp;amp;&amp;amp; status_check == 2) { // 'C' is recieved&#xA;                status_check = 3 ;&#xA;            } else if (rec_data == 'P' &amp;amp;&amp;amp; status_check == 3) { // 'P' is recieved&#xA;                status_check = 4 ;&#xA;            } else if (rec_data == 'I' &amp;amp;&amp;amp; status_check == 4) { // 'I' is recieved&#xA;                status_check = 5 ;&#xA;            } else if (rec_data == 'N' &amp;amp;&amp;amp; status_check == 5) { // 'N' is recieved&#xA;                status_check = 6 ;&#xA;            } else if (rec_data == ':' &amp;amp;&amp;amp; status_check == 6) { // ':' is recieved&#xA;                status_check = 7 ;&#xA;            } else if (rec_data == ' ' &amp;amp;&amp;amp; status_check == 7) { // ' ' is recieved&#xA;                status_check = 8 ;&#xA;            } else if (rec_data == 'R' &amp;amp;&amp;amp; status_check == 8) { // 'R' is recieved&#xA;                status_check = 9 ;&#xA;            } else if (rec_data == 'E' &amp;amp;&amp;amp; status_check == 9) { // 'E' is recieved&#xA;                status_check = 10 ;&#xA;            } else if (rec_data == 'A' &amp;amp;&amp;amp; status_check == 10) { // 'A' is recieved&#xA;                status_check = 11 ;&#xA;            } else if (rec_data == 'D' &amp;amp;&amp;amp; status_check == 11) { // 'D' is recieved&#xA;                status_check = 12 ;&#xA;            } else if (rec_data == 'Y' &amp;amp;&amp;amp; status_check == 12) { // 'Y' is recieved&#xA;                status_check = 13 ;&#xA;            } else if (rec_data == 0X0D &amp;amp;&amp;amp; status_check == 13) { //Carriage return&#xA;                status_check = 14 ;&#xA;            } else if (rec_data == 0X0A &amp;amp;&amp;amp; status_check == 14) { //Line Feed&#xA;                status_check = 15 ;&#xA;            } else if (rec_data == 'O' &amp;amp;&amp;amp; status_check == 15) { // '0' is recieved&#xA;                status_check = 16;&#xA;            } else if (rec_data == 'K' &amp;amp;&amp;amp; status_check == 16) {&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 1; //goto next step&#xA;            } else if (rec_data != 'R' &amp;amp;&amp;amp; status_check == 8) { //+CPIN: NOT READY&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 0; //repeat current step&#xA;            } else if (rec_data == 'M' &amp;amp;&amp;amp; status_check == 3) { // in case of any message&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 0; //repeat current step&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    while (network_status == 1) { //wait for SIM network registration&#xA;        if (status_check == 0) {&#xA;            delay(1000);&#xA;            status_check = 1 ;&#xA;            clear_rx_buffer();&#xA;            Serial3.println(F(&quot;AT+CREG?&quot;)); //checking for SIM card registration ,if registerd &quot;+CREG: 0,1&quot; will receive&#xA;        }&#xA;&#xA;        while (Serial3.available() &amp;gt; 0) {&#xA;            rec_data = Serial3.read();&#xA;&#xA;            if (rec_data == '+' &amp;amp;&amp;amp; status_check == 1) { // '+' is recieved&#xA;                status_check = 2 ;&#xA;            } else if (rec_data == 'C' &amp;amp;&amp;amp; status_check == 2) { // 'C' is recieved&#xA;                status_check = 3 ;&#xA;            } else if (rec_data == 'R' &amp;amp;&amp;amp; status_check == 3) { // 'R' is recieved&#xA;                status_check = 4 ;&#xA;            } else if (rec_data == 'E' &amp;amp;&amp;amp; status_check == 4) { // 'E' is recieved&#xA;                status_check = 5 ;&#xA;            } else if (rec_data == 'G' &amp;amp;&amp;amp; status_check == 5) { // 'G' is recieved&#xA;                status_check = 6 ;&#xA;            } else if (rec_data == ':' &amp;amp;&amp;amp; status_check == 6) { // ':' is recieved&#xA;                status_check = 7 ;&#xA;            } else if (rec_data == ' ' &amp;amp;&amp;amp; status_check == 7) { // ' ' is recieved&#xA;                status_check = 8 ;&#xA;            } else if (rec_data == '0' &amp;amp;&amp;amp; status_check == 8) { // '0' is recieved&#xA;                status_check = 9 ;&#xA;            } else if (rec_data == ',' &amp;amp;&amp;amp; status_check == 9) { // ',' is recieved&#xA;                status_check = 10 ;&#xA;            } else if (rec_data == '1' &amp;amp;&amp;amp; status_check == 10) { // '1' is recieved&#xA;                status_check = 11 ;&#xA;            } else if (rec_data == 0X0D &amp;amp;&amp;amp; status_check == 11) { //Carriage return&#xA;                status_check = 12 ;&#xA;            } else if (rec_data == 0X0A &amp;amp;&amp;amp; status_check == 12) { //Line Feed&#xA;                status_check = 12 ;&#xA;            } else if (rec_data == 'O' &amp;amp;&amp;amp; status_check == 12) { // '0' is recieved&#xA;                status_check = 13;&#xA;            } else if (rec_data == 'K' &amp;amp;&amp;amp; status_check == 13) {&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 2; //goto next step&#xA;            } else if (rec_data != '1' &amp;amp;&amp;amp; status_check == 10) { // +CREG: 0,2 not registered&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 1; //repeat current step&#xA;            } else if (rec_data == 'M' &amp;amp;&amp;amp; status_check == 3) { // in case of any message&#xA;                clear_rx_buffer();&#xA;                status_check = 0 ;&#xA;                network_status = 1; //repeat current step&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    Serial3_cnt = 0;&#xA;&#xA;    while (Serial3_cnt &amp;lt; 4) { // repeat entire loop until Serial3_cnt less than 4&#xA;        switch (Serial3_cnt) {&#xA;            case 0:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;AT+CMGF=1&quot;));// Attention command to wake up Serial3 modem&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 1:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;AT+CNMI=2,1,0,0,0&quot;));//Command to configure new message indication&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 2:&#xA;                clear_rx_buffer();//clearing receiving buffer&#xA;                Serial3.println(F(&quot;AT+CMGD=1,4&quot;));// Command to delete all received messages&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 3:&#xA;                Serial3_cnt = 4;// exit from the loop&#xA;                break;&#xA;&#xA;            default :&#xA;                break;&#xA;        }&#xA;&#xA;        while (Serial3.available() &amp;gt; 0) {&#xA;            rec_data = Serial3.read();&#xA;&#xA;            if (rec_data == 'O') { // '0'(zero) is recieved (numeric response)&#xA;                rec_data = Serial3.read();&#xA;&#xA;                if (rec_data == 'K') {&#xA;                    Serial3_cnt ++;&#xA;                }&#xA;            } else if (rec_data == '+') { // '+' recieved ,before &quot;AT+CIICR&quot; command,may be any message&#xA;                clear_rx_buffer();&#xA;&#xA;                if (Serial3_cnt &amp;gt; 0) {&#xA;                    Serial3_cnt --;&#xA;                }&#xA;            } else if (rec_data == 'E' &amp;amp;&amp;amp; Serial3_cnt &amp;gt; 2) { // '4' recieved (error),in gprs initialisation commands&#xA;                clear_rx_buffer();&#xA;                Serial3_cnt = 4;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    Serial3_cnt = 0;&#xA;}&#xA;&#xA;void clear_rx_buffer(void) {&#xA;    Serial3.flush();&#xA;}&#xA;&#xA;&#xA;void gprs_init() {&#xA;    byte st = 1, i = 0, response = 0;&#xA;    char r[10];&#xA;&#xA;    while (st &amp;lt;= 9) {&#xA;        delay(1000);&#xA;        clear_rx_buffer();&#xA;&#xA;        switch (st) {&#xA;            case 1:&#xA;                Serial3.println(F(&quot;AT+CGATT?&quot;));&#xA;                break;&#xA;&#xA;            case 2:&#xA;                Serial3.println(F(&quot;AT+CIPSHUT&quot;));&#xA;                break;&#xA;&#xA;            case 3:&#xA;                Serial3.println(F(&quot;AT+CIPMUX=0&quot;));&#xA;                break;&#xA;&#xA;            case 4:&#xA;                response = cmd1_check(1);&#xA;                break;&#xA;&#xA;            case 5:&#xA;                Serial3.println(F(&quot;AT+CIICR&quot;));&#xA;                delay(1000);&#xA;                break;&#xA;&#xA;            case 6:&#xA;                Serial3.println(F(&quot;AT+CIFSR&quot;));&#xA;                break;&#xA;&#xA;            case 7:&#xA;                response = cmd1_check(2);&#xA;                delay(2200);&#xA;                clear_rx_buffer();&#xA;                break;&#xA;&#xA;            case 8:&#xA;                Serial3.println(F(&quot;AT+CIPSEND&quot;));&#xA;                break;&#xA;&#xA;            case 9:&#xA;                Serial3_send();&#xA;                ++st;&#xA;                break;&#xA;        }&#xA;&#xA;        if (st == 10) {&#xA;            clear_rx_buffer();&#xA;        }&#xA;&#xA;        delay(1000);&#xA;&#xA;        while (Serial3.available() &amp;amp;&amp;amp; st &amp;lt; 9 &amp;amp;&amp;amp; st != 7 &amp;amp;&amp;amp; st != 4) {&#xA;            r[i] = Serial3.read();&#xA;            i++;&#xA;        }&#xA;&#xA;        i = 0;&#xA;&#xA;        if (strstr(r, &quot;ALREADY&quot;) != NULL) {&#xA;            Serial3.println(&quot;AT+CIPSHUT&quot;);&#xA;            delay(50);&#xA;            clear_rx_buffer();&#xA;            st = 2;&#xA;            r[0] = '\0';&#xA;        }&#xA;&#xA;        if (strstr(r, &quot;OK&quot;) != NULL || strstr(r, &quot;+CGATT&quot;) != NULL || (strstr(r, &quot;.&quot;) != NULL &amp;amp;&amp;amp; st == 6) || strstr(r, &quot;&amp;gt;&quot;) != NULL) {&#xA;            st++;&#xA;        } else if (strstr(r, &quot;ERR&quot;) != NULL) {&#xA;            break;&#xA;        } else if (response == 1 &amp;amp;&amp;amp; (st == 7 || st == 4)) {&#xA;            st++;&#xA;            response = 0;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;char cmd1_check(short int o) {&#xA;    byte timout1 = 10500, m1, p1 = 0, resp1 = 0;&#xA;    char response1[25] = {'\0'};&#xA;    m1 = millis();&#xA;    clear_rx_buffer();&#xA;&#xA;    if (o == 1) {&#xA;        Serial3.print(F(&quot;AT+CSTT=&quot;));&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(APN);&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(',');&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(',');&#xA;        Serial3.print('&quot;');&#xA;        Serial3.println('&quot;');&#xA;        delay(3000);&#xA;    } else if (o == 2) {&#xA;        Serial3.print(F(&quot;AT+CIPSTART=&quot;));&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(F(&quot;TCP&quot;));&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(',');&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(F(&quot;dweet.io&quot;));&#xA;        Serial3.print('&quot;');&#xA;        Serial3.print(',');&#xA;        Serial3.println(80);&#xA;        delay(2000);&#xA;    }&#xA;&#xA;    do {&#xA;        p1 = 0;&#xA;&#xA;        while (Serial3.available()) {&#xA;            response1[p1] = Serial3.read();&#xA;            p1++;&#xA;            delay(20);&#xA;        }&#xA;&#xA;        if (strstr(response1, &quot;OK&quot;) != NULL &amp;amp;&amp;amp; o == 1) {&#xA;            resp1 = 1;&#xA;        } else if (strstr(response1, &quot;ERR&quot;) != NULL) {&#xA;            resp1 = 2;&#xA;        } else if (strstr(response1, &quot;CONNECT OK&quot;) != NULL &amp;amp;&amp;amp; o == 2) {&#xA;            resp1 = 1;&#xA;        }&#xA;    } while ((millis() - m1) &amp;lt;= timout1 &amp;amp;&amp;amp; resp1 == 0);&#xA;&#xA;    return (resp1);&#xA;}&#xA;&#xA;void Serial3_send() {&#xA;    Serial3.print(&quot;POST /dweet/for/&quot;);&#xA;    Serial3.print(&quot;mythingname&quot;);&#xA;    Serial3.print(&quot;?vo=&quot;);&#xA;    Serial3.print(voltage);&#xA;    Serial3.print(&quot;&amp;amp;cu=&quot;);&#xA;    Serial3.print(current);&#xA;    Serial3.print(&quot;&amp;amp;Mc=&quot;);&#xA;    Serial3.print(mcurrent);&#xA;    Serial3.print(&quot;&amp;amp;Ac=&quot;);&#xA;    Serial3.print(acurrent);&#xA;    Serial3.print(&quot;&amp;amp;Po=&quot;);&#xA;    Serial3.print(power);&#xA;    Serial3.print(&quot;&amp;amp;PF=&quot;);&#xA;    Serial3.print(pf);&#xA;    Serial3.print(&quot;&amp;amp;fr=&quot;);&#xA;    Serial3.print(freq);&#xA;    Serial3.print(&quot;&amp;amp;Te=&quot;);&#xA;    Serial3.print(temp);&#xA;    Serial3.println(&quot; HTTP/1.1&quot;);&#xA;    Serial3.println(&quot;connection: keep-alive&quot;);&#xA;    Serial3.println();&#xA;    Serial3.println();&#xA;    Serial3.write(26);&#xA;    Serial3.println();&#xA;    delay(10000);&#xA;    Serial3.println(&quot;AT+CIPSHUT&quot;);&#xA;    delay(50);&#xA;}&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    Serial3.begin(9600);&#xA;    modem_initialization();&#xA;}&#xA;&#xA;void loop() {&#xA;    dtype = 0;&#xA;    read_comp();&#xA;    gprs_init();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24240" LastEditorUserId="4143" LastEditDate="2016-07-27T11:03:37.620" LastActivityDate="2016-07-27T12:13:12.657" Title="Arduino sketch unexpected behaviour" Tags="|gsm|memory|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26751" PostTypeId="1" CreationDate="2016-07-27T11:30:51.753" Score="1" ViewCount="762" Body="&lt;p&gt;I plan on making an Arduino project for reminding a parent to take a child from a car. In order to power the project I though on using a solar panel. Since I can't rely on having solar power all the time I'll need to use rechargeable batteries and charge them with the solar panel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that from reading about the subject it is clear that it can be dangerous as far as battery go up in flame in some cases, especially due to high heat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My car can get into very high temperature when parked outside so this scenario is very likely to happen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please direct me to reading materials about using solar power in a very safe way?&lt;/p&gt;&#xA;" OwnerUserId="23976" LastEditorUserId="2881" LastEditDate="2016-07-27T18:52:38.657" LastActivityDate="2016-07-27T18:52:38.657" Title="Solar Power Inside a Car" Tags="|power|solar|heat|" AnswerCount="1" CommentCount="14" ContentLicense="CC BY-SA 3.0" />
  <row Id="26752" PostTypeId="2" ParentId="26750" CreationDate="2016-07-27T12:13:12.657" Score="2" Body="&lt;p&gt;This &lt;strong&gt;looks like&lt;/strong&gt; you are constructing the data to be sent as &lt;strong&gt;GET&lt;/strong&gt; parameters (i.e as part of the querystring), whereas I believe dweet.io expects them as part of the &lt;strong&gt;POST&lt;/strong&gt; body - &lt;a href=&quot;https://dweet.io/play/#!/dweets/postDweet_post_0&quot; rel=&quot;nofollow noreferrer&quot;&gt;as seen here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There seem to be many people &lt;a href=&quot;http://google.com/?q=sim900%20post%20data&quot; rel=&quot;nofollow noreferrer&quot;&gt;struggling to successfully send HTTP POSTs with a SIM900&lt;/a&gt;, but I think &lt;a href=&quot;https://arduino.stackexchange.com/questions/21688/send-json-via-post-on-sim900-shield-with-at-commands&quot;&gt;this answer outlines the correct sequence to make it work&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="24169" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-07-27T12:13:12.657" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26754" PostTypeId="2" ParentId="26751" CreationDate="2016-07-27T13:26:14.893" Score="1" Body="&lt;p&gt;Firstly, solar panels inside a car is pretty pointless. Solar panels need to be in direct sunlight to be effective. Having them inside a car means they're not going to be in direct sunlight, so they're not going to be able to generate anywhere near enough power - unless they are massive, in which case where is the child going to sit? Yes, you could put them on the roof, but that would be silly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole concept of solar panels for this project is completely wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The car has a big battery and an in-built generator. Use them. There is absolutely no reason for you to have your own batteries as well. Yes, you could charge your own batteries from the car's battery, but that just introduces extra losses and wastefulness.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only possible benefit of having your own batteries is it will safeguard the car's battery when the engine isn't running. It would then be impossible for your project to flatten the car's battery. But if you design your project properly that wouldn't be a problem anyway.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some things you seem to be missing with your project:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The car has power you can use. It's throughout the car. No need to provide your own external power source.&lt;/li&gt;&#xA;&lt;li&gt;The car has an &quot;accessory&quot; signal that is only turned on when the ignition is on. It's used by things like the radio etc so that when you turn the car's ignition off the radio turns off. No need for vibration sensors or anything to know if the car is running, it can tell you directly.&lt;/li&gt;&#xA;&lt;li&gt;Cars generally have &quot;seat occupied&quot; sensors in them that couple with the seatbelts to know if a passenger hasn't got their seatbelt on and warn the driver (in most jurisdictions it's the responsibility of the driver to ensure all passengers have their seatbelts on).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If you really must charge batteries there are certain safety aspects you really must take into account. Your charge circuit must be able to manage the battery charging 100% safely. You have mentioned heat, and that is a very very important thing to manage. A decent battery manager chip will include an input for a thermistor. That is used as one of the multiple methods of charge termination (there's dv/dt (change in voltage over time), dT/dt (change in temperature over time), etc). It also serves as an over-heat safety cutout. Ensure that the charge circuit you use not only provides a thermistor input but also has the ability to cut off charging in the case of an overheat situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You also need to consider over-voltage. A car's 12V supply isn't 12V. It can get as high as 16V sometimes, and noise from the ignition can cause regular spikes as high as 70V or more. Automotive electronics have to be able to withstand those spikes, and that means your charge circuit has to be able to withstand those spikes.  Buffering the 12V through a proper 5V (cigarette lighter USB charger) regulator will remove that noise and make your circuit easier to work with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you need to think more carefully about just what it is you want to achieve and how that is going to fit into an automotive situation.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-27T13:26:14.893" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26755" PostTypeId="2" ParentId="26720" CreationDate="2016-07-27T13:36:49.900" Score="0" Body="&lt;p&gt;It is highly unlikely you will ever find an &quot;Ethernet only&quot; board. There are plenty of boards that have both Ethernet and USB, but one without USB? I doubt it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make an Ethernet only board you would first need to create a bootloader with built-in support for the Ethernet port as well as a way of configuring that port to suit your network. Than kind of program would be rather large and take up a fair proportion of the flash memory, leaving you with much less room for your own program.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And as you have rightly noticed, USB chips (especially the dreaded CH340G, the bane of my life) are so cheap now, so why &lt;em&gt;wouldn't&lt;/em&gt; you include one on your board?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you get boards with both USB &lt;em&gt;and&lt;/em&gt; Ethernet, and you install the software (generally) through USB which doesn't need any special configuration or complex software to get it to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some boards provide &quot;OTA&quot; (Over The Air) updates, such as the ESP8266, but these generally require the OTA software first installing via the USB (or UART) connection to allow it to communicate on your network and accept OTA firmware. Others, such as the Arduino Yun, use multiple MCUs to provide remote programming. In the case of the Yun you get a &quot;host&quot; microcontroller which is considerably more powerful than the AVR microcontroller that it is programming, which always strikes me as a little pointless.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So no, I doubt that anyone would ever want to make an Ethernet only board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-27T13:36:49.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26756" PostTypeId="1" CreationDate="2016-07-27T14:26:00.817" Score="1" ViewCount="222" Body="&lt;p&gt;The problem: Message prints only to the Arduino IDE's &lt;strong&gt;Tools &gt; Serial Monitor&lt;/strong&gt;, not coming out of TX pin 11. &#xA;Question, please how to get Arduino Uno or Mega to send data out of pin 11?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(12, 13); // RX, TX pins on Arduino&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;void loop() {&#xA;  Serial.print(&quot;This is a test\n\n&quot;);&#xA;  delay(1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24245" LastEditorUserId="26916" LastEditDate="2017-11-04T18:45:51.183" LastActivityDate="2017-11-04T18:45:51.183" Title="On UNO, when serial.print to UART pin 11, nothing comes out of pin 11" Tags="|arduino-uno|softwareserial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26757" PostTypeId="2" ParentId="26756" CreationDate="2016-07-27T14:34:37.067" Score="3" Body="&lt;p&gt;Of course it's only coming out on the serial monitor - you are printing it to the hardware UART which comes out on the serial monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have created a SoftwareSerial object which you are then completely ignoring and then using the HardwareSerial UART object instead, which is on pins 0/1.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a SoftwareSerial object you should actually &lt;em&gt;use&lt;/em&gt; the SoftwareSerial object.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace all the references to &lt;code&gt;Serial&lt;/code&gt; with &lt;code&gt;mySerial&lt;/code&gt; instead.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-27T14:34:37.067" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26760" PostTypeId="2" ParentId="26743" CreationDate="2016-07-27T17:57:32.113" Score="1" Body="&lt;p&gt;The A4988 is a bipolar stepper driver. It is designed specifically to drive a single bipolar (4-wire) stepper motor. It consists of a pair of H-bridges and some extra drive logic to provide a simple GPIO interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor shield, in contrast, uses the L298D motor driver chip. This provides, as well, two H-bridges like the A4988. However it just gives you direct control of those H-bridges without a simple stepper-oriented interface.  So it is up to you to provide the correct control signals to effectively emulate the A4988's outputs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Both chips can interface with exactly one bipolar stepper motor. The A4988 can &lt;em&gt;only&lt;/em&gt; interface with a stepper motor. The L298D can &lt;em&gt;also&lt;/em&gt; be used with other types of motor (though of course not at the same time as a bipolar stepper).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-27T17:57:32.113" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26762" PostTypeId="2" ParentId="25775" CreationDate="2016-07-27T18:23:53.570" Score="0" Body="&lt;p&gt;First go to your library folder and check whether u included that Wire.h header file or not.If not then first include that file then problem will get solved automatically.&lt;/p&gt;&#xA;" OwnerUserId="24255" LastActivityDate="2016-07-27T18:23:53.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26764" PostTypeId="2" ParentId="23625" CreationDate="2016-07-27T23:20:55.907" Score="1" Body="&lt;p&gt;In order to use the ESP8266 WiFi module with &lt;code&gt;pubSubCient&lt;/code&gt;, you need a library that interfaces with the module with the usual AT commands, while presenting an Arduino &lt;code&gt;Client&lt;/code&gt; interface on the surface. A while back, I found &lt;a href=&quot;https://github.com/bportaluri/WiFiEsp&quot; rel=&quot;nofollow&quot;&gt;this library&lt;/a&gt; after a great deal of searching. It supports &lt;code&gt;SoftwareSerial&lt;/code&gt; as well as &lt;code&gt;HardwareSerial&lt;/code&gt; objects. Its ESP8266 interface provides the standard &lt;code&gt;Client&lt;/code&gt; methods of &lt;code&gt;write()&lt;/code&gt;, &lt;code&gt;read()&lt;/code&gt;, &lt;code&gt;connected()&lt;/code&gt;, etc. There are some issues, of course, but its the best I've found so far. You can pass the created &lt;code&gt;Client&lt;/code&gt; object to the &lt;code&gt;pubSubClient&lt;/code&gt; constructor and you're good to go. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-07-27T23:20:55.907" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26767" PostTypeId="1" AcceptedAnswerId="26857" CreationDate="2016-07-28T03:37:50.270" Score="0" ViewCount="172" Body="&lt;p&gt;I am driving two stepper motor using serial data from Raspberry Pi to Arduino. Motors work fine when i am passing serial data but once i stop sending serial data, it doesn't accept serial data again unless I burn the program again in arduino. Here is code for that:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Driver.h&amp;gt;&#xA;&#xA;//////////////////////////////////////////////////////////////////////////////////////////&#xA;/*&#xA;   Hardware pins defined in this section as connected from arduino to Pan DRV8834&#xA;   controller and tilt DRV8834 controller.M0 and M1 pins are common for both controllers&#xA;   ,hence declared only once(This is done to save number of pins, connecting it to&#xA;   additional pins , provide no special advantage since both both motors should be set&#xA;   to same level of microstepping).SLP pin is not currently used.&#xA;&#xA;*/&#xA;//////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;#define PAN_DIRECTION_PIN 8&#xA;#define TILT_DIRECTION_PIN 7&#xA;&#xA;#define PAN_STEP_PIN 10&#xA;#define TILT_STEP_PIN 9&#xA;&#xA;#define M0 6&#xA;#define M1 5&#xA;&#xA;#define MOTOR_SPEED 200&#xA;&#xA;#define SLP 0&#xA;///////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;#define BAUD_RATE 230400      //Baud Rate for serial communication&#xA;&#xA;///////////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;/*&#xA;   field data for receiving buffer on arduino side , important for serial communication&#xA;*/&#xA;#define NUMBER_OF_FIELDS 2 // how many comma separated fields we expect&#xA;int fieldIndex = 0;           // the current field being received&#xA;int values[NUMBER_OF_FIELDS];  // array holding angles for both motors&#xA;&#xA;const char startChar = '&amp;lt;'; //beginning character of a valid command&#xA;const char endchar   = '&amp;gt;'; //this will be ending character to ensure a valid command has ended&#xA;boolean storeString = false; //This will be our flag to put the data in our buffer&#xA;&#xA;#define zeroCharacter 'z'&#xA;&#xA;bool zeroCommand = false;&#xA;&#xA;#define DATABUFFERSIZE 50&#xA;char dataBuffer[DATABUFFERSIZE + 1]; //Add 1 for NULL terminator&#xA;int dataBufferIndex = 0;&#xA;&#xA;&#xA;int procBufCounter;         //iterate through whole string to obtain the commands&#xA;&#xA;&#xA;float panAngle, tiltAngle;&#xA;&#xA;int sign = 1;&#xA;&#xA;&#xA;&#xA;    Driver stepper_pan(M0, M1, PAN_STEP_PIN, SLP, PAN_DIRECTION_PIN);&#xA;    Driver stepper_tilt(M0, M1, TILT_STEP_PIN, SLP, TILT_DIRECTION_PIN);&#xA;&#xA;&#xA;    void processCommand(char *buffer) {&#xA;&#xA;        procBufCounter = 0;&#xA;        bool startprocessing = false;&#xA;        bool endprocessing = false;&#xA;&#xA;        values[0] = 0;&#xA;        values[1] = 0;&#xA;&#xA;        while ((procBufCounter &amp;lt; DATABUFFERSIZE) &amp;amp;&amp;amp; (!endprocessing)) {&#xA;&#xA;            char ch = buffer[procBufCounter];           //read the character while simulatneously increasing the buffer cursor&#xA;&#xA;&#xA;&#xA;            if (ch == '&amp;lt;') {&#xA;                startprocessing = true;&#xA;            }&#xA;            else if (ch == '&amp;gt;') {&#xA;                values[fieldIndex] = values[fieldIndex] * sign ;&#xA;                fieldIndex = 0;&#xA;                endprocessing = true;&#xA;            }&#xA;&#xA;            if (startprocessing)&#xA;            {&#xA;                if (ch == ',') {&#xA;                    values[fieldIndex] = values[fieldIndex] * sign ; // set value to the accumulated value&#xA;                    sign = 1;&#xA;                    fieldIndex++;&#xA;                }&#xA;                else if ('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9' ) {&#xA;                    values[fieldIndex] = (values[fieldIndex] * 10) + (ch - '0');&#xA;                }&#xA;                else if (ch == '-') {&#xA;                    sign = -1;&#xA;                }&#xA;                else if(ch == 'z'){&#xA;                  zeroCommand = true;&#xA;                }&#xA;            }&#xA;            procBufCounter++;&#xA;        }&#xA;        panAngle = ((float)(values[0]))/100;&#xA;        tiltAngle = ((float)(values[1]))/100;&#xA;&#xA;&#xA;       bool panMoved = true, tiltMoved = true;&#xA;        stepper_pan.moveTo(panAngle);&#xA;        stepper_tilt.moveTo(tiltAngle);&#xA;      while (panMoved || tiltMoved) {&#xA;        panMoved = stepper_pan.run();&#xA;        tiltMoved = stepper_tilt.run();&#xA;      }&#xA;&#xA;      if(zeroCommand){&#xA;        stepper_pan.reset_positions();&#xA;        stepper_tilt.reset_positions();&#xA;        zeroCommand = false;&#xA;      }&#xA;&#xA;&#xA;    }&#xA;&#xA;    //////////////////////////////////////////////////////////////////////////////////////&#xA;&#xA;    void setup() {&#xA;      stepper_pan.setStepMode(STEP_THIRTYTWO);&#xA;      stepper_pan.setSpeed(MOTOR_SPEED);&#xA;      stepper_tilt.setStepMode(STEP_THIRTYTWO);&#xA;      stepper_tilt.setSpeed(MOTOR_SPEED);&#xA;      Serial.begin (BAUD_RATE);&#xA;      Serial.flush();&#xA;    }&#xA;&#xA;    void loop() {&#xA;      if (processString) {&#xA;        processCommand(dataBuffer);&#xA;        processString = false;&#xA;    //     dataBuffer = &quot;&quot;;&#xA;&#xA;      }&#xA;    }&#xA;&#xA;    void serialEvent() {&#xA;      static int dataBufferIndex = 0;&#xA;      while (Serial.available() &amp;gt; 0) {&#xA;        char incomingbyte = Serial.read();&#xA;        if (incomingbyte == startChar) {&#xA;          dataBufferIndex = 0;  //Initialize our dataBufferIndex variable&#xA;          storeString = true;&#xA;        }&#xA;        if (storeString) {&#xA;          //Let's check our index here, and abort if we're outside our buffer size&#xA;          //We use our define here so our buffer size can be easily modified&#xA;          if (dataBufferIndex == DATABUFFERSIZE) {&#xA;            //Oops, our index is pointing to an array element outside our buffer.&#xA;            dataBufferIndex = 0;&#xA;            break;&#xA;          }&#xA;          if (incomingbyte == endchar) {&#xA;            dataBuffer[dataBufferIndex] = endchar; //null terminate the C string&#xA;            dataBuffer[dataBufferIndex + 1] = '\0';&#xA;            //Our data string is complete.  return true&#xA;            storeString = false;&#xA;            processString = true;&#xA;            dataBufferIndex = 0;&#xA;          }&#xA;          else {&#xA;            dataBuffer[dataBufferIndex++] = incomingbyte;&#xA;            dataBuffer[dataBufferIndex] = 0; //null terminate the C string&#xA;          }&#xA;        }&#xA;&#xA;      }&#xA;&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24018" LastEditorUserId="24018" LastEditDate="2016-07-28T06:43:33.840" LastActivityDate="2016-07-30T05:06:07.037" Title="Blocking Serial Data" Tags="|serial|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26768" PostTypeId="1" CreationDate="2016-07-28T04:14:56.040" Score="4" ViewCount="4074" Body="&lt;p&gt;I'm creating a PIR motion sensor doggy door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm having with it is, it runs 3 times, I've figured out how to pause when reaches 180° but not how to stop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking I could use detach my servo and attach after a delay of 30,000 and then re-attach return to 0 degrees, then wait for next PIR high.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't know how to code it into what I have or even if it would work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* This code sweeps a servo from 0 degrees to 180 when the PIR sensor detects motion.&#xA;   Special thanks goes to the author of the PIR sensor code, whose code helped tremendously&#xA;   in the making of this code and Instructable.&#xA;   author of PIR sensor code: Kristian Gohlke / krigoo (_) gmail (_) com / http://krx.at&#xA;**/&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo myservo; //creates a servo object&#xA;//a maximum of eight servo objects can be created&#xA;int pos = 0; //variable to store servo position&#xA;//amount of time we give the sensor to calibrate(10-60 secs according to the datasheet)&#xA;int calibrationTime = 30;&#xA;//the time when the sensor outputs a low impulse&#xA;long unsigned int lowIn;&#xA;//the amount of milliseconds the sensor has to be low&#xA;//before we assume all motion has stopped&#xA;long unsigned int pause = 5000;&#xA;boolean lockLow = true;&#xA;boolean takeLowTime;&#xA;int pirPin = 12; //digital pin connected to the PIR's output&#xA;int pirPos = 13; //connects to the PIR's 5V pin&#xA;&#xA;void setup() {&#xA;  myservo.attach(4); //attaches servo to pin 4&#xA;  Serial.begin(9600); //begins serial communication&#xA;  pinMode(pirPin, INPUT);&#xA;  pinMode(pirPos, OUTPUT);&#xA;  digitalWrite(pirPos, HIGH);&#xA;  //give the sensor time to calibrate&#xA;  Serial.println(&quot;calibrating sensor &quot;);&#xA;  for (int i = 0; i &amp;lt; calibrationTime; i++) {&#xA;    Serial.print(calibrationTime - i);&#xA;    Serial.print(&quot;-&quot;);&#xA;    delay(1000);&#xA;  }&#xA;  Serial.println();&#xA;  Serial.println(&quot;done&quot;);&#xA;  //while making this Instructable, I had some issues with the PIR's output&#xA;  //going HIGH immediately after calibrating&#xA;  //this waits until the PIR's output is low before ending setup&#xA;  while (digitalRead(pirPin) == HIGH) {&#xA;    delay(500);&#xA;    Serial.print(&quot;.&quot;);&#xA;  }&#xA;  Serial.print(&quot;SENSOR ACTIVE&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (digitalRead(pirPin) == HIGH) {&#xA;    //if the PIR output is HIGH, turn servo&#xA;    /*turns servo from 0 to 180 degrees and back&#xA;      it does this by increasing the variable &quot;pos&quot; by 1 every 5 milliseconds until it hits 180&#xA;      and setting the servo's position in degrees to &quot;pos&quot; every 5 milliseconds&#xA;      it then does it in reverse to have it go back&#xA;      to learn more about this, google &quot;for loops&quot;&#xA;      to change the amount of degrees the servo turns, change the number 180 to the number of degrees you want it to turn&#xA;    **/&#xA;    for (pos = 0; pos &amp;lt; 180; pos += 1) {&#xA;      //goes from 0 to 180 degrees&#xA;      myservo.write(180);&#xA;      delay(8000); ////stops motor for 8 seconds&#xA;      for (pos = 180; pos &amp;gt;= 90; pos -= 1) {&#xA;        // goes from 180 degrees to 0 degrees&#xA;        myservo.write(pos); // tell servo to go to position in variable 'pos'&#xA;        delay(15); // waits 15ms for the servo to reach the position&#xA;      }&#xA;      myservo.write(90);&#xA;      delay(4000); //stops motor for 4 seconds&#xA;      for (pos = 90; pos &amp;lt;= 180; pos += 1) {&#xA;        // goes from 0 degrees to 180 degrees&#xA;        // in steps of 1 degree&#xA;        myservo.write(pos); // tell servo to go to position in variable 'pos'&#xA;        delay(15); // waits 15ms for the servo to reach the position&#xA;      }&#xA;      //to make it go slower, increase the number.&#xA;      if (lockLow) {&#xA;        //makes sure we wait for a transition to LOW before further output is made&#xA;        lockLow = false;&#xA;        Serial.println(&quot;---&quot;);&#xA;        Serial.print(&quot;motion detected at &quot;);&#xA;        Serial.print(millis() / 1000);&#xA;        Serial.println(&quot; sec&quot;);&#xA;        delay(50);&#xA;      }&#xA;      takeLowTime = true;&#xA;    }&#xA;&#xA;    if (digitalRead(pirPin) == LOW) {&#xA;      if (takeLowTime) {&#xA;        lowIn = millis(); //save the time of the transition from HIGH to LOW&#xA;        takeLowTime = false; //make sure this is only done at the start of a LOW phase&#xA;      }&#xA;      //if the sensor is low for more than the given pause,&#xA;      //we can assume the motion has stopped&#xA;      if (!lockLow &amp;amp;&amp;amp; millis() - lowIn &amp;gt; pause) {&#xA;        //makes sure this block of code is only executed again after&#xA;        //a new motion sequence has been detected&#xA;        lockLow = true;&#xA;        Serial.print(&quot;motion ended at &quot;); //output&#xA;        Serial.print((millis() - pause) / 1000);&#xA;        Serial.println(&quot; sec&quot;);&#xA;        delay(50);&#xA;      }&#xA;    }&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Could I also just change the jumper pin on the PIR hardware for a retriggering set high to keep the door open when the dog is there so it won't just close on them? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using this PIR: &#xA;&lt;a href=&quot;https://i.stack.imgur.com/INVdh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/INVdh.jpg&quot; alt=&quot;pir&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24270" LastEditorUserId="4628" LastEditDate="2017-05-26T02:25:01.480" LastActivityDate="2017-09-23T06:11:08.737" Title="How to run servo 180 degrees and stop?" Tags="|arduino-uno|programming|c++|servo|" AnswerCount="1" CommentCount="6" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26769" PostTypeId="2" ParentId="26648" CreationDate="2016-07-28T05:16:32.810" Score="0" Body="&lt;p&gt;Figured it out in the end. Although my solution doesn't exactly fit what I wanted but it works in this case. I used the FMS Majenko mentioned like this : &#xA;Wait for potentiometer value to go beyond a certain value, then wait for it to come back to the value. If that happens then the lights stop blinking. Thanks guys( this is quite different from what I initially wanted but it is enough for what it is meant to do)&lt;/p&gt;&#xA;" OwnerUserId="24152" LastActivityDate="2016-07-28T05:16:32.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26770" PostTypeId="1" CreationDate="2016-07-28T05:38:24.500" Score="0" ViewCount="2197" Body="&lt;p&gt;So I want to send some data from Matlab to Arduino. To verify that I am getting the correct data I am sending the data back to Matlab (since I get errors if I open the serial monitor, if there's an easier way to print debug messages let me know).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that I always get 48 back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My matlab code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;arduino = serial('COM3','BaudRate',115200);&#xA;fopen(arduino);&#xA;fprintf(arduino,'%f',1);&#xA;fclose(arduino);&#xA;&#xA;fopen(arduino);&#xA;disp(fscanf(arduino, '%f'))&#xA;fclose(arduino);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and my arduino code:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the setup:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(115200);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the loop:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;delay(100);&#xA;myFunction();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In myFunction:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while(!Serial.available()&amp;gt;0)){}&#xA;int data = Serial.read();&#xA;Serial.println(data,DEC);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It seems like the 48 is an ascii code for something but it doesn't ever change when I change the 1 is the 3rd line of the matlab code to anything else.&lt;/p&gt;&#xA;" OwnerUserId="20778" LastActivityDate="2016-08-27T11:56:41.337" Title="Why am I always getting 48 with serial communication?" Tags="|serial|communication|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26771" PostTypeId="2" ParentId="26770" CreationDate="2016-07-28T06:25:11.090" Score="0" Body="&lt;p&gt;I don't know much about maylab, but you are sending a float to the Arduino where you read bytes and send characters back to matlab and read it as a float.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try sending a single character from matlab and reading a single character back, %c.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-28T06:25:11.090" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26773" PostTypeId="1" AcceptedAnswerId="26775" CreationDate="2016-07-28T07:02:02.113" Score="1" ViewCount="1252" Body="&lt;p&gt;I am trying to make an arduino alarm clock to which you can send alarm clock times over the web.&#xA;This is the HTML code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; &amp;lt;input type=&quot;checkbox&quot; name=&quot;alarm1&quot; id=&quot;alarm1&quot;&amp;gt;1&amp;lt;/button&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It's sending the HTTP correctly but the rest of the code insists that the alarms are always on.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;      if (_server.arg(&quot;alarm1&quot;) = &quot;on&quot;) {&#xA;      alarm1 = true;&#xA;      Serial.println(&quot;Alarm 1 is set&quot;);&#xA;  }&#xA;  else {&#xA;      alarm1 = false;&#xA;      Serial.println(&quot;Alarm 1 is inactive&quot;);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24275" LastActivityDate="2016-07-28T08:02:15.800" Title="Server checkbox not working properly" Tags="|esp8266|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26774" PostTypeId="1" AcceptedAnswerId="26992" CreationDate="2016-07-28T07:42:32.063" Score="0" ViewCount="225" Body="&lt;p&gt;I have added my Arduino code for reading messages from GSM SIM900A using Arduino. But the output is showing something different. Please help me. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define SERIAL_BUFFER_SIZE 256&#xA;&#xA;char msg;&#xA;void setup() {&#xA;  Serial.begin(9600);   // Setting the baud rate of GSM Module&#xA;  delay(60000);&#xA;  Serial.println(&quot;AT&quot;);&#xA;  delay(1000);&#xA;  Serial.println(&quot;AT+CREG=1&quot;);&#xA;  delay(1000);&#xA;  Serial.println(&quot;AT+CMGF=1&quot;); // set SMS mode to text&#xA;  delay(1000);&#xA;  Serial.println(&quot;AT+CMGR=\&quot;ALL\&quot;&quot;);&#xA;  delay(1000);&#xA;  Serial.println(&quot;AT+CMGR=\&quot;ALL\&quot;&quot;);&#xA;  delay(1000);&#xA;  while ( Serial.available() &amp;gt; 0) Serial.read();  // removing serial buffer values&#xA;  Serial.println(&quot;AT+CMGR=1&quot;);&#xA;  delay(2000);&#xA;}&#xA;&#xA;void loop() {&#xA;  while (Serial.available() &amp;gt; 0) {&#xA;    msg = serial.read()&#xA;    Serial.print(msg);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+CMGR: &quot;REC READ&quot;,&quot;+91xxxxxxxxxx&quot;,&quot;&quot;,&quot;16/07&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23686" LastEditorUserId="4628" LastEditDate="2017-01-30T16:35:04.453" LastActivityDate="2017-10-30T19:09:07.560" Title="Printing the messages having problem in SIM 900A to Arduino" Tags="|arduino-uno|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26775" PostTypeId="2" ParentId="26773" CreationDate="2016-07-28T08:02:15.800" Score="2" Body="&lt;p&gt;The alarm is always on because you are setting it to be always on.  You code should say:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; if (_server.arg(&quot;alarm1&quot;) == &quot;on&quot;) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-28T08:02:15.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26781" PostTypeId="1" AcceptedAnswerId="26783" CreationDate="2016-07-28T11:47:33.617" Score="0" ViewCount="4669" Body="&lt;p&gt;I am trying to find out the size of an array like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    String days[3] = { &quot;Mon&quot;, &quot;Tue&quot;, &quot;Wed&quot; };&#xA;Serial.printf(&quot;Size of array: %2d\n&quot;, sizeof(days));&#xA;for (int i = 0; i &amp;lt; sizeof(days); i++) {&#xA;    Serial.print(days[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The result of the code above is 36 which is incorrect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have any other options considering that I don't know the size of the array to begin with?&lt;/p&gt;&#xA;" OwnerUserId="24275" LastActivityDate="2016-11-14T06:53:46.893" Title="Size of String array" Tags="|esp8266|string|array|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26783" PostTypeId="2" ParentId="26781" CreationDate="2016-07-28T11:56:50.763" Score="1" Body="&lt;p&gt;No, the result is correct, you're just interpreting it incorrectly. If you want the number of elements in a statically-allocated array use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sizeof(somearray) / sizeof(somearray[0])&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-28T11:56:50.763" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26784" PostTypeId="1" CreationDate="2016-07-28T12:35:22.193" Score="2" ViewCount="11417" Body="&lt;p&gt;It's a basic one: I have two values from two different analogRead pins:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int val1;&#xA;int val2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, val1 = 10 and val2 = 10. How could I put these two values into a variable val3 = val1 + val2 that will give the answer 1010, instead 20 ?&lt;/p&gt;&#xA;" OwnerUserId="24283" LastActivityDate="2016-08-27T23:58:29.537" Title="Is possible to concatenate integers?" Tags="|string|" AnswerCount="5" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26785" PostTypeId="1" AcceptedAnswerId="26791" CreationDate="2016-07-28T12:49:41.283" Score="0" ViewCount="199" Body="&lt;p&gt;Is it possible to call a HTTPS web service on arduino UNO? I am trying to connect it through client.connect(ip,port). It said connected but never respond, ended up in TIMEOUT.&lt;/p&gt;&#xA;" OwnerUserId="24284" LastActivityDate="2016-07-28T15:28:21.453" Title="Arduino UNO HTTPS" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26786" PostTypeId="2" ParentId="26670" CreationDate="2016-07-28T13:08:49.180" Score="2" Body="&lt;p&gt;Use &lt;code&gt;AT+CGNSxxx&lt;/code&gt; instead of &lt;code&gt;AT+CGPSxxx&lt;/code&gt; commands&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ATGNSPWR=1&lt;/code&gt; and &lt;code&gt;ATCGNSINF&lt;/code&gt; to get location.&lt;/p&gt;&#xA;&lt;p&gt;if you get following output&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;1,0,19800106001337.000,,,,0.00,0.0,0,,,,,,0,0,,,,, &lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;It means your GPS is not set.&lt;/p&gt;&#xA;&lt;p&gt;Try to put GPS antenna outside your room, on open space for 10-15 minutes.&#xA;GPS bulb will start blinking to confirm it is now ready for use.&lt;/p&gt;&#xA;&lt;p&gt;Then use &lt;code&gt;AT+CGNSINF&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="24165" LastEditorUserId="33608" LastEditDate="2020-09-25T11:10:49.423" LastActivityDate="2020-09-25T11:10:49.423" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="26788" PostTypeId="2" ParentId="26768" CreationDate="2016-07-28T14:03:39.627" Score="1" Body="&lt;p&gt;I haven't been able to compile or test this but I think it should do what you are asking for, or at the very least steer you in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This code waits for a signal from the PIR sensor.&#xA;// When the signal is recieved it rotates the servo 180 degrees and waits 30 seconds&#xA;// it then rotates the servo back to 0 (to close the door)&#xA;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;const int ServoIntraStepDelay   =  15;      // Delay between servo steps (ms)&#xA;const int ServoAngleStep        =   1;      // The angle by which the servo position is changed every step (degree) &#xA;const int ServoAngleMinimum     =   0;      // The min angle of the servo (degrees)&#xA;const int ServoAngleMaximum     = 180;      // The max angle of the servo (degree)&#xA;const int DoorOpenPeriod        = 30 * 1000;// The time the door will remain open for (ms)&#xA;const int DoorClearPoll         = 100;      // The interval betwen polls to the sensor when checking to see if the door is clear(ms)&#xA;const int DoorClearPeriod       = 5000;     // The interval that the PIR sensor must report low before closing the door (ms)&#xA;&#xA;const int PIRCalibrationTime    = 30;       //amount of time we give the sensor to calibrate(10-60 secs according to the datasheet) (s)&#xA;&#xA;const int PinPIRData            = 12;       //digital pin connected to the PIR's output&#xA;const int PinPIRPower           = 13;       //connects to the PIR's 5V pin&#xA;const int PinServoPower         = 4;        // The pin that controls the servo. &#xA;&#xA;Servo myservo;                              //creates a servo object&#xA;&#xA;void setupCalibratePIR()&#xA;{&#xA;        //give the sensor time to calibrate&#xA;    Serial.println(&quot;Calibrating sensor &quot;);&#xA;    for(int i = 0; i &amp;lt; PIRCalibrationTime; i++)&#xA;    {&#xA;        Serial.print(PIRCalibrationTime - i);&#xA;        Serial.print(&quot;-&quot;);&#xA;        delay(1000);&#xA;    }&#xA;    Serial.println();&#xA;    Serial.println(&quot;done&quot;);&#xA;    //while making this Instructable, I had some issues with the PIR's output&#xA;    //going HIGH immediately after calibrating&#xA;    //this waits until the PIR's output is low before ending setup&#xA;    Serial.print(&quot;Waiting for PIR sensor to report low&quot;);&#xA;    while (digitalRead(PinPIRData) == HIGH) &#xA;    {&#xA;        delay(500);&#xA;        Serial.print(&quot;.&quot;); &#xA;    }&#xA;    Serial.print(&quot;SENSOR ACTIVE&quot;);  &#xA;}&#xA;&#xA;void turnServo (const int&amp;amp; from, const int&amp;amp; to, const int&amp;amp; step)&#xA;{&#xA;    for(int pos = from; pos &amp;lt;= to; pos += step)&#xA;    { &#xA;        myservo.write(pos); &#xA;        delay(ServoIntraStepDelay); &#xA;    } //to make it go slower, increase the number.&#xA;}&#xA;&#xA;// Test the PIR sensor and ensure that it reports low for a specific time&#xA;void waitForDoorClear ()&#xA;{&#xA;    bool doorIsNotClear = true;&#xA;    while (doorIsNotClear)&#xA;    {&#xA;        doorIsNotClear = false;&#xA;        for (int doorClear = 0; !doorIsNotClear &amp;amp;&amp;amp; (doorClear * DoorClearPoll) &amp;lt; DoorClearPeriod; ++doorClear)&#xA;        {   // Poll every few ms and check that the sensor in LOW&#xA;            // As soon as it is high this loop will exit which restarts the time that the low signal must been seen for.&#xA;            delay (DoorClearPoll);&#xA;            doorIsNotClear = (digitalRead(PinPIRData) == HIGH);&#xA;        }&#xA;    }   // This is potentially an infinite loop.&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);                     // Begins serial communication&#xA;    myservo.attach(PinServoPower);          // Connect to the servo object&#xA;    pinMode(PinPIRData, INPUT);             // Connect the PIR data &#xA;    pinMode(PinPIRPower, OUTPUT);           // Connect the PIR power    &#xA;    digitalWrite(PinPIRPower, HIGH);        // Turn on the PIR power&#xA;&#xA;    setupCalibratePIR();                    // Calibrate the PIR sensor&#xA;}&#xA;// attach&#xA;void loop()&#xA;{&#xA;&#xA;    if(digitalRead(PinPIRData) == HIGH)&#xA;    { //if the PIR output is HIGH, turn servo&#xA;&#xA;        turnServo (ServoAngleMinimum, ServoAngleMaximum, ServoAngleStep);&#xA;        delay (DoorOpenPeriod - DoorClearPeriod);&#xA;        waitForDoorClear ();&#xA;        turnServo (ServoAngleMaximum, ServoAngleMinimum, -ServoAngleStep);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You weren't that far off.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2016-07-29T12:01:46.733" LastActivityDate="2016-07-29T12:01:46.733" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26789" PostTypeId="2" ParentId="26784" CreationDate="2016-07-28T14:05:22.957" Score="0" Body="&lt;p&gt;This is not even remotely related to Arduino but mathematics.&#xA;As Mikael Patel pointed out this can be done fairly easy.&#xA;You might tell us your intent.&#xA;If you are seeking for a way to pack values tightly you may consider &lt;a href=&quot;https://prtsh.wordpress.com/2014/01/18/integer-sequence-encoding/&quot; rel=&quot;nofollow&quot;&gt;Integer Sequence Enconding&lt;/a&gt;.&#xA;But without more detailed information this will be just a guess.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-07-28T14:05:22.957" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26790" PostTypeId="2" ParentId="26784" CreationDate="2016-07-28T14:12:25.580" Score="1" Body="&lt;p&gt;If you are reading from the analog pins then the values are 10 bits (not 8 as suggested above).  Are you looking at concatenating 2 10 bit numbers or 2 16 bit numbers or are you using a zero or duo in which case they could be 12 bit numbers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In any case:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int BITMASK = 0x3FF;  // 10 bits = 0x3FF, 12 = 0xFFF, 16 = 0xFFFF&#xA;const int BITWIDTH = 10;&#xA;long result = ((value1 &amp;amp; BITMASK) &amp;lt;&amp;lt; BITWIDTH) | (value2 &amp;amp; BITMASK);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect it won't give you the answer you want, but...&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-28T14:12:25.580" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26791" PostTypeId="2" ParentId="26785" CreationDate="2016-07-28T15:28:21.453" Score="1" Body="&lt;p&gt;No, it is not possible. The Arduino UNO is not powerful enough to encrypt the data for an SSL connection. On top of that the W5100 chip used on the Ethernet shield has its own IP stack built into it, and that stack doesn't support SSL either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you require SSL then it is recommended that you use one of the &quot;dual&quot; boards, like the Yun, and have the Linux portion of the board make the SSL connection for you using cURL.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-28T15:28:21.453" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26793" PostTypeId="2" ParentId="26698" CreationDate="2016-07-28T15:36:22.827" Score="1" Body="&lt;p&gt;The library says you must include &lt;code&gt;network.update()&lt;/code&gt; in &lt;code&gt;loop()&lt;/code&gt; for the nodes to be in sync. Place that call at the top of &lt;code&gt;loop()&lt;/code&gt; in both nodes.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-07-28T15:36:22.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26794" PostTypeId="1" AcceptedAnswerId="26796" CreationDate="2016-07-28T16:05:06.037" Score="-1" ViewCount="571" Body="&lt;p&gt;I am trying to make the following board work with Raspberry Pi.&#xA;Board Name: &lt;code&gt;L293D Motor Drive Shield Expansion Board for Arduino Mega Raspberry Pi&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0paaJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0paaJ.jpg&quot; alt=&quot;L293D Motor Drive Shield Expansion Board for Arduino Mega Raspberry Pi&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I need to know is which pins do the following:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Enable the motor&lt;/li&gt;&#xA;&lt;li&gt;Disable the motor&lt;/li&gt;&#xA;&lt;li&gt;Rotate forward&lt;/li&gt;&#xA;&lt;li&gt;Rotate backward&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;More information about the board: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/using-dc-motors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.adafruit.com/adafruit-motor-shield/using-dc-motors&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.raspberrypi.org/forums/viewtopic.php?f=45&amp;amp;t=16118&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.raspberrypi.org/forums/viewtopic.php?f=45&amp;amp;t=16118&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me find this information?&lt;/p&gt;&#xA;" OwnerUserId="15949" LastActivityDate="2017-02-23T22:00:32.327" Title="Trying to figure out how to use an extension board with Pi" Tags="|arduino-motor-shield|raspberrypi|" AnswerCount="1" CommentCount="2" ClosedDate="2017-03-17T10:35:54.953" ContentLicense="CC BY-SA 3.0" />
  <row Id="26795" PostTypeId="1" CreationDate="2016-07-28T16:30:07.297" Score="-1" ViewCount="1306" Body="&lt;p&gt;Is it possible to send a text message using an Arduino and the Sparkfun ESP8266 Wifi Shield using Temboo? I noticed that the ESP8266 might not be supported by Temboo and I was wondering if there is a workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="24038" LastActivityDate="2016-07-31T12:34:09.870" Title="Sending a text/notification with Arduino + ESP8266 Wifi shield" Tags="|arduino-uno|esp8266|" AnswerCount="2" CommentCount="0" ClosedDate="2016-08-09T04:02:25.703" ContentLicense="CC BY-SA 3.0" />
  <row Id="26796" PostTypeId="2" ParentId="26794" CreationDate="2016-07-28T17:21:04.903" Score="1" Body="&lt;blockquote&gt;&#xA;&lt;p&gt;The following pins are in use only if the DC/Stepper noted is in use:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Digital pin 11: DC Motor #1 / Stepper #1 (activation/speed control)&lt;/li&gt;&#xA;&lt;li&gt;Digital pin 3: DC Motor #2 / Stepper #1 (activation/speed control)&lt;/li&gt;&#xA;&lt;li&gt;Digital pin 5: DC Motor #3 / Stepper #2 (activation/speed control)&lt;/li&gt;&#xA;&lt;li&gt;Digital pin 6: DC Motor #4 / Stepper #2 (activation/speed control)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following pins are in use if any DC/steppers are used&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Digital pin 4, 7, 8 and 12 are used to drive the DC/Stepper motors via the 74HC595 serial-to-parallel latch&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The following pins are used only if that particular servo is in use:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Digitals pin 9: Servo #1 control&lt;/li&gt;&#xA;&lt;li&gt;Digital pin 10: Servo #2 control&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;(&lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/faq&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;)&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-07-28T17:21:04.903" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26797" PostTypeId="1" AcceptedAnswerId="26808" CreationDate="2016-07-28T17:31:50.820" Score="1" ViewCount="1093" Body="&lt;p&gt;I just recently found the ThingSpeak platform for the IoT. I have been playing around with its features a bit, but I have not found a way for it to show a simple table of all the data collected. For example, the table might have humidity, temperature, and timestamp columns, and then every time data is written to ThingSpeak, a new row would be added with the latest readings. I would be surprised if this is not possible with all of its complex graphing tools. Has anybody found a feature like this?&lt;/p&gt;&#xA;" OwnerUserId="24269" LastActivityDate="2016-07-28T21:40:52.560" Title="Is it possible for ThingSpeak to show a simple table of all data collected?" Tags="|datalogging|" AnswerCount="1" CommentCount="1" ClosedDate="2016-08-01T11:11:56.707" ContentLicense="CC BY-SA 3.0" />
  <row Id="26799" PostTypeId="2" ParentId="26784" CreationDate="2016-07-28T17:50:54.800" Score="0" Body="&lt;p&gt;You want to send a string of data that represents the data from a number of sensors. For example let's say you have 2 10 bit analog readings and 4 Boolean readings, high or low from the digital pins.  You can compress this into 24 bits of data, or 3 bytes.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your transmission library supports binary writing and reading then you can send it as 3 unsigned chars.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your transmission library doesn't support binary then you can either base64 encode it as 4 bytes. (The numbers are converted into printable characters that represent their value).  Or a more light weight solution would be to write each byte as two hexadecimal digits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You pack the data into three bytes by using bit masking and shifting (as per my other answer).  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensor1data = 512;      &#xA;int sensor2data = 64;&#xA;bool digital1 = true;&#xA;bool digital2 = false;&#xA;bool digital3 = false;&#xA;bool digital4 = true;&#xA;&#xA;unsigned char data[3]{ 0, 0, 0 };&#xA;&#xA;// Take the top 8 bits of the 10 bit data on sensor1data &#xA;// 0x300 takes the 2 lowest bits of the upper byte&#xA;// 0x0FC takes the 6 highest bits of the lower byte.&#xA;// Shift the result 2 places right so the what was bit 2&#xA;// of the upper byte becomes the most significant bit (MSb) &#xA;// in the result byte.&#xA;data[0] = (sensor1data &amp;amp; 0x3FC) &amp;gt;&amp;gt; 2;&#xA;&#xA;// Take the 2 lowest bits of the lower byte (0x03) &#xA;// Shift the 6  places left to make them the MSb of the &#xA;// result byte.&#xA;data[1] = ((sensor1data &amp;amp; 0x3) &amp;lt;&amp;lt; 6);&#xA;// Take the 6 MSbs of the sensor2data and left shift them &#xA;// so that they become the LSbs of the result byte.&#xA;// The result is ORed onto what is already in the result &#xA;// to retain the previous instruction.&#xA;data[1] |= ((sensor2data &amp;amp; 0x3F0) &amp;gt;&amp;gt; 4);&#xA;&#xA;// Take the 4 LSbs of sensor2data and shift them right &#xA;// for places to ocupy the 4 MSbs of the result.&#xA;data[2] = ((sensor2data &amp;amp; 0xF) &amp;lt;&amp;lt; 4);&#xA;// OR each of the flags into the result, shifting by &#xA;// a different amount each time.&#xA;data[2] |= (digital1 ? 1 : 0) &amp;lt;&amp;lt; 3; // I explicitly convert the bool to an int &#xA;data[2] |= (digital2 ? 1 : 0) &amp;lt;&amp;lt; 2; // because some older compilers don't always&#xA;data[2] |= (digital3 ? 1 : 0) &amp;lt;&amp;lt; 1; // use 1 for true.&#xA;data[2] |= (digital4 ? 1 : 0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-28T17:50:54.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26800" PostTypeId="1" AcceptedAnswerId="26845" CreationDate="2016-07-28T18:26:39.590" Score="0" ViewCount="1508" Body="&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt; interface and Arduino MEGA to a Mettler Toledo SB32001 using the RS-232 communication protocol described in &lt;a href=&quot;https://us.mt.com/mt_ext_files/Editorial/Generic/7/MT-SICS_for_Excellence_Balances_BA_Editorial-Generic_1116311007471_files/Excellence-SICS-BA-e-11780711B.pdf%22the%20manual%22&quot; rel=&quot;nofollow&quot;&gt;the manual&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Equipment Used:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SB32001 Mettler Toledo 32 kg scale&lt;/li&gt;&#xA;&lt;li&gt;Arduino MEGA&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/449&quot; rel=&quot;nofollow&quot;&gt;Sparkfun RS232 Shifter - SMD&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the &lt;code&gt;SoftwareSerial&lt;/code&gt; library to try to communicate with the scale through MEGA pins 52 and 53. I have the level shifter connected to the scale using a through cable. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far, I have tried to send the most basic command to the scale, and the command is both not executing, and not causing a status code to be send back (i.e. failure OR success). My Tx light on the level shifter flashes, but the Rx light never does.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Write string to screen:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;D &quot;String&quot;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Because I have a through cable, I have tried switching the Tx and Rx pins in code. Neither has worked.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The from the scale has the following options I can set:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Baud Rate:&lt;/strong&gt; 150, 300, 600, 1200, 2400, 4800, &lt;strong&gt;9600&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Parity:&lt;/strong&gt; 7b-E, 7b-no, &lt;strong&gt;8b-no&lt;/strong&gt;, 7b-odd&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is a minimal (non)working example of my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const int pinTX = 53;&#xA;const int pinRX = 52;&#xA;&#xA;scale = SoftwareSerial(53, 52);&#xA;&#xA;void setup(){&#xA;    Serial.begin(9600);&#xA;    scale.begin(9600);&#xA;    delay(100);&#xA;}&#xA;&#xA;void loop(){&#xA;    scale.println(&quot;D \&quot;Hello!?\&quot;&quot;);&#xA;    delay(100);&#xA;&#xA;    while (scale.available()){&#xA;        Serial.print(scale.read());&#xA;    }&#xA;    Serial.println()&#xA;    delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;What I need:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I need help figuring out where I should look next to solve this issue. I have tried switching the transmit and receive pins in software. I have tried using jumpers to switch the Tx and Rx pins in hardware. I have tried 7 and 8-bit settings with no parity. Nothing give me a signal back. Totally perplexed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it my converter chip? Does anyone know of problems with this shifter? I know that it does not contain the industry standard MAX232&lt;/p&gt;&#xA;" OwnerUserId="8570" LastEditorUserId="8570" LastEditDate="2016-07-28T22:42:49.883" LastActivityDate="2016-07-29T18:13:53.650" Title="Interfacing to scale over RS-232" Tags="|arduino-mega|communication|softwareserial|datalogging|rs232|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="26801" PostTypeId="1" AcceptedAnswerId="26804" CreationDate="2016-07-28T18:27:07.647" Score="2" ViewCount="523" Body="&lt;p&gt;I am new to xbees. I want to have multiple xbees (up to 400 xbees) send data constantly to one xbee (receiver).This is just simple data like lets say 0 or 1 . Is this possible? Are there any limitations? &lt;/p&gt;&#xA;" OwnerUserId="19181" LastActivityDate="2018-03-24T20:54:12.680" Title="Can multiple xbees send data to one xbee" Tags="|arduino-uno|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26803" PostTypeId="1" AcceptedAnswerId="26809" CreationDate="2016-07-28T19:15:07.287" Score="1" ViewCount="3868" Body="&lt;p&gt;Is it possible to connect more than one TFT screen (like this one or similar: &lt;a href=&quot;https://www.adafruit.com/products/1651&quot; rel=&quot;nofollow&quot;&gt;https://www.adafruit.com/products/1651&lt;/a&gt;) to an Arduino Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm wanting to connect and control two color screens at once; note the touch functionality of the one linked above isn't really necessary, I just like the size and overall build. They have a version that works like a shield and sits on top of the Arduino, which would work I suppose if I bought another unit for the other screen. The breakout board version is more flexible but I don't know of a way to control two screens that require that many pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions?&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="24223" LastActivityDate="2022-08-18T14:50:13.287" Title="Connecting multiple TFT panels to Arduino Uno via SPI?" Tags="|arduino-uno|lcd|multiplexer|tft|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26804" PostTypeId="2" ParentId="26801" CreationDate="2016-07-28T19:22:30.367" Score="0" Body="&lt;p&gt;Yes, you can send data from 400 XBees to a single xbee. I would like to clarify one thing. XBees are connecting to a network, not to a particular xbee. And the devices connected in a network can communicate each other.&lt;/p&gt;&#xA;" OwnerUserId="24064" LastEditorUserId="24064" LastEditDate="2018-03-24T20:54:12.680" LastActivityDate="2018-03-24T20:54:12.680" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26805" PostTypeId="2" ParentId="26632" CreationDate="2016-07-28T20:13:24.180" Score="0" Body="&lt;p&gt;As I understand, you are trying to implement some peripheral device based on AtMega 8-bit micro-controller that uses USB1.1 interface (FS or LS) to connect to USB host. Your problem seems to be that your host computer (unspecified) puts the port into SUSPEND (sleep), and does not wake up when you try to activate your device (button or something).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First, the USB2.0/1.1 interface does not have any &quot;Tx&quot; or &quot;Rx&quot;, it is a half-duplex bi-directional bus. It has D+ and D-, and VBUS. But it is true that a USB peripheral device can generate a bus event called RESUME. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two choices. (1) either you make your host computer to never sleep or put USB ports into SUSPEND, or (2) make your device to support RESUME (aka &quot;remote wake-up&quot;) function in full compliance with USB specifications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In case (2) the driver for your device (on host computer) must support remote wake-up function, and this function must be enabled. Then when the host computer is planning to go into one of various sleep modes and decides to SUSPEND your device, it must send special control command to your device which should arm it for wake-up, and the host will be expecting it. In this case the host will never remove VBUS (&quot;passively from computer&quot;), so the device will be able to wake the bus up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this your question about?&lt;/p&gt;&#xA;" OwnerUserId="24294" LastEditorUserId="24294" LastEditDate="2016-07-28T20:46:39.663" LastActivityDate="2016-07-28T20:46:39.663" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="26806" PostTypeId="2" ParentId="26784" CreationDate="2016-07-28T20:28:31.150" Score="0" Body="&lt;p&gt;If you know in advance how many variables' values you want to transmit:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char output[100+1];&#xA;....    &#xA;snprintf(output, sizeof(buffer), &quot;%d,%d,$d\n&quot;, val, val2, val3);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If not and you need to build the string &quot;as you go&quot;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char output[100+1] = &quot;&quot;;&#xA;char oneVal[12+1];&#xA;...&#xA;snprintf(oneVal, sizeof(buf), &quot;%d,&quot;, value);&#xA;strcat(output, oneVal);&#xA;&#xA;// more of the above, possibly in a loop.&#xA;...&#xA;strcat(output, &quot;\n&quot;);      // if you need a newline at the end&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-07-28T20:28:31.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26807" PostTypeId="1" AcceptedAnswerId="26820" CreationDate="2016-07-28T21:06:34.790" Score="0" ViewCount="660" Body="&lt;p&gt;I have a control module that accepts 8V PWM signals.  My goal is to send a 500Hz PWM signal from an Arduino to an 8V PWM input on the control module.  Looks like everything generated from the Arduino is 5V.  Is there a way to generate an 8V PWM output or method of manipulating that signal to reach 8V?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CQh4M.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CQh4M.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24297" LastEditorUserId="24297" LastEditDate="2016-08-09T16:13:37.447" LastActivityDate="2016-08-09T16:53:45.917" Title="Generating an 8V PWM signal" Tags="|pwm|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26808" PostTypeId="2" ParentId="26797" CreationDate="2016-07-28T21:32:58.910" Score="0" Body="&lt;p&gt;Since ThingSpeak has an extensive API, you can build a tool to read in data and display it as a table. I have created a GitHub repo called, &quot;&lt;a href=&quot;https://github.com/nothans/iot-debugger&quot; rel=&quot;nofollow&quot;&gt;IoT Debugger&lt;/a&gt;&quot; that allows you to see data as a table as the it comes into a ThingSpeak Channel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use the demo, enter your channel number and the read API key.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to modify the project, fork the project on &lt;a href=&quot;https://github.com/nothans/iot-debugger&quot; rel=&quot;nofollow&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="21598" LastEditorUserId="21598" LastEditDate="2016-07-28T21:40:52.560" LastActivityDate="2016-07-28T21:40:52.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26809" PostTypeId="2" ParentId="26803" CreationDate="2016-07-28T22:38:46.313" Score="1" Body="&lt;p&gt;Yes, you can. All the SPI pins (MISO, MOSI and SCK) are all shared between the panels. You can even share the D/C and RST signals. The only signal that &lt;em&gt;needs&lt;/em&gt; to be separate is the CS pin since this is the pin that identifies which panel is actively receiving commands and data at any one time. Also you don't need to connect up the MISO pin at all, since that is only connected to the SD card slot, not the TFT screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So each screen that you add just requires one more pin to be used. One screen uses 5 pins. Two screens use 6 pins. Three screens use 7 pins, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And yes, for this the breakout version would be easier to work with than the shield version.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-28T22:38:46.313" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26810" PostTypeId="2" ParentId="26784" CreationDate="2016-07-28T22:50:48.250" Score="1" Body="&lt;p&gt;It sounds to me, from your comments, that what you want to do is turn this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myRadio.transmit(val1);&#xA;myRadio.transmit(val2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;into something more like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myVal = join(val1, val2);&#xA;myRadio.transmit(myVal);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That's all pseudocode of course, and those functions are in themselves nonsense, but it serves to illustrate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you want to turn two values into one single block of data for sending thus reducing the overall transmission overhead of the packet (one large packet instead of two smaller packets). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What you are actually looking for is called a &lt;em&gt;struct&lt;/em&gt; and looks something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyData {&#xA;    int val1;&#xA;    int val2;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That creates a new variable type which contains two sub-variables in it. You then use it like any other variable:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyData data;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can then get at the values inside it with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;data.val1 = analogRead(A1);&#xA;data.val2 = analogRead(A2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And the whole thing can be transmitted in one block with whatever functions your RF library provides:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myRadio.transmit(&amp;amp;data, sizeof(struct MyData));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Receiving at the other end is just the same - as long as the receiving end has the same structure. Receive into a MyData structure variable and you can get at the individual sub-variables:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;struct MyData data;&#xA;myRadio.receive(&amp;amp;data, sizeof(struct MyData));&#xA;Serial.print(data.val1);&#xA;Serial.print(&quot;,&quot;);&#xA;Serial.println(data.val2);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, you need to read up on whatever library it is you're using to do your transmitting and receiving to find the actual correct functions to call to transmit and receive a block of data like that...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-28T22:50:48.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26814" PostTypeId="1" CreationDate="2016-07-29T00:15:54.800" Score="1" ViewCount="166" Body="&lt;p&gt;This should be fairly straightforward, but there must be something I'm not understanding about buffers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have serial data coming in to my Mega via Zigbee. I'm sending a string just like this: &lt;code&gt;~-0.6016800&lt;/code&gt;, where &lt;code&gt;~&lt;/code&gt; is my unique starting delimiter and my end delimiter is a carriage return &lt;code&gt;\n&lt;/code&gt;. I'm sure it's coming through the zigbee correctly, because I can see my string show up looking good in XCTU when I plug the zigbee into the PC. Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;const int numChars = 15;&#xA;char incoming[numChars];&#xA;&#xA;static boolean Receiving = false;&#xA;static byte ndx = 0;&#xA;char startMarker = '~';&#xA;char endMarker = '\n';&#xA;byte K;&#xA;bool allreceived = false;&#xA;&#xA;void Get() {&#xA;    memset(incoming, NULL, strlen(incoming));&#xA;    while (allreceived == false) {&#xA;        if (Serial.available() &amp;gt; 0) {&#xA;            K = Serial.read();&#xA;            if (Receiving == true) {&#xA;                if (K != endMarker) {&#xA;                    incoming[ndx] = K;&#xA;                    ndx++;&#xA;                    if (ndx &amp;gt;= numChars) {&#xA;                        ndx = numChars-1;&#xA;                    }&#xA;                }&#xA;                else {&#xA;                    incoming[ndx] = '\0'; // terminate the string&#xA;                    Receiving = false;&#xA;                    ndx = 0;&#xA;                    allreceived = true;&#xA;                }&#xA;            }&#xA;            else if (K == startMarker) {&#xA;                Receiving = true;&#xA;                ndx = 0;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So somehow my buffer is overflowing or something, no matter how big I make it. I see the array start off as I expect it for the first few characters, then it turns into unintelligible characters. I think part of the problem might be that the serial data is coming through at a different rate or something, because I can see my starting delimiter &lt;code&gt;~&lt;/code&gt; on my LCD screen in the middle of my array. The way it's set up, I should never be able to see my start delimiter unless I miss my end delimiter without ending the array. (Note- I've tried different unique end delimiters too, but this seems to work just the same) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what might be causing this??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: NOW TRYING THIS CODE- I'm still having the buffer overflow, and I'd be really grateful if someone could take a look.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Sending code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void PayloadSendit(void) {   &#xA;&#xA;Payload[0] = '~';  //1 char unique start&#xA;&#xA;if (outFormat == 0) {&#xA;    Payload[1] = '0';&#xA;    Payload[2] = '$';  //spacer&#xA;    strcat(Payload, stringval); //5 char for hashmarks&#xA;}&#xA;else {&#xA;    Payload[1] = '1';&#xA;    strcat(Payload, stringvalin);  //6 char for inch&#xA;}&#xA;if (dotpos &amp;lt;= 99) {&#xA;    Payload[8] = '@';  //spacer&#xA;    char dotpos2[2];&#xA;    sprintf(dotpos2, &quot;%i&quot;, dotpos);&#xA;    strcat(Payload, dotpos2);    //2 char &#xA;}&#xA;else {&#xA;    char dotpos3[3];&#xA;    sprintf(dotpos3, &quot;%i&quot;, dotpos);&#xA;    strcat(Payload, dotpos3);   //3 char ///////////////////////////&#xA;}&#xA;&#xA;Payload[11] = '0';  //1 char for &quot;no errors&quot; code&#xA;Payload[12] = '*';  //1 char end delimiter&#xA;Serial.println(Payload);&#xA;Serial.flush();&#xA;memset(Payload, '\0', 13);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;}&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Receiving code:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  void Get2() {&#xA;    memset(Payload, '\0', bufsize);&#xA;    while (allreceived == false) {&#xA;        int K = Serial.read();&#xA;        switch (K) {&#xA;        case -1: // Nothing to read&#xA;            break;&#xA;&#xA;        case '~': // Starting a new string&#xA;            Receiving = true;&#xA;            break;&#xA;&#xA;        default: // Any other characters.&#xA;            break;&#xA;&#xA;        }&#xA;        if (Receiving) {&#xA;            for (int i = 0; i &amp;lt;= 10; i++) {&#xA;                Payload[i] = Serial.read();&#xA;            }&#xA;            if (Serial.read() == '*') {&#xA;                Receiving = false;&#xA;                allreceived = true;&#xA;            }&#xA;            else { memset(Payload, '\0', bufsize); }  //destroy array if end delimiter not where it should be&#xA;        }&#xA;&#xA;    }&#xA;}  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19892" LastEditorUserId="9962" LastEditDate="2016-08-02T01:14:43.423" LastActivityDate="2016-08-02T01:14:43.423" Title="Can anyone help me figure out why this buffer is overflowing? (Updated)" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26815" PostTypeId="2" ParentId="26814" CreationDate="2016-07-29T00:32:45.987" Score="1" Body="&lt;p&gt;My guess is this line:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memset(incoming, NULL, strlen(incoming));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When &quot;incoming&quot; hasn't yet been cleared, what is the length of it? It's whatever it counts up until the first '\0' character - and where is that character on the first run through? Who knows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead you should memset the size of the buffer, not the number of non-NULL characters in the buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;memset(incoming, NULL, numChars);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt;, that is a pointless operation, since you are storing a C string and (should be) properly terminating it, so it really doesn't matter what is in the array to begin with since you are just overwriting it anyway. So you can completely lose that whole function call.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might like to re-write your receiving routine to use a &lt;code&gt;switch/case&lt;/code&gt; construct instead of ifs and elses - it'll be much easier to follow:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define EVER ;;&#xA;&#xA;const int numChars = 15;&#xA;char buffer[numChars];&#xA;&#xA;void Get() {&#xA;    int pos = 0;&#xA;    bool receiving = false;&#xA;&#xA;    for (EVER) {&#xA;        int K = Serial.read();&#xA;        switch(K) {&#xA;            case -1: // Nothing to read&#xA;                break;&#xA;&#xA;            case '\n': // Got the end of the string.&#xA;                if (receiving) return; // We have a valid string.&#xA;                pos = 0; // Reset pointer to start of buffer&#xA;                break;&#xA;&#xA;            case '~': // Starting a new string&#xA;                pos = 0;&#xA;                receiving = true;&#xA;                break;&#xA;&#xA;            default: // Any other characters.&#xA;                if (receiving) {&#xA;                    if (pos &amp;lt; numChars-2) {&#xA;                        buffer[pos++] = K;&#xA;                        buffer[pos] = 0;&#xA;                    }&#xA;                }&#xA;                break;&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-07-29T13:57:31.250" LastActivityDate="2016-07-29T13:57:31.250" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26816" PostTypeId="2" ParentId="17477" CreationDate="2016-07-29T00:33:10.677" Score="3" Body="&lt;p&gt;Gerben, thanks for your code. I took it and added seconds to the check, and tidied up a few typos. This isn't as sophisticated as other methods, but might be good for beginners to follow logic. hope it helps&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TimeLib.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;DS1307RTC.h&amp;gt;  // a basic DS1307 library that returns time as a time_t&#xA;&#xA;int openHH = 9;&#xA;int openMM = 10;&#xA;int openSS = 0;&#xA;int closeHH = 9;&#xA;int closeMM = 40;&#xA;int closeSS = 0;&#xA;&#xA;bool isOpenTime()&#xA;{  &#xA;  time_t t = now(); // Read in what our current datestamp is from RTC&#xA;//  DateTime now = RTC.now();  // if using timeRTC lib, i think&#xA;&#xA;  int nowHH = hour(t); int nowMM = minute(t); int nowSS = second(t);  // put into local variables for easier read&#xA;&#xA;  if (( &#xA;        (nowHH&amp;gt;openHH)                        // check hours first&#xA;        || ((nowHH==openHH) &amp;amp;&amp;amp; (nowMM&amp;gt;openMM))             // check minutes if in same hour&#xA;        || ((nowHH==openHH) &amp;amp;&amp;amp; (nowMM==openMM) &amp;amp;&amp;amp; (nowSS&amp;gt;=openSS))    // check seconds if in same hour &amp;amp; minute&#xA;      ) &#xA;      &amp;amp;&amp;amp;                                  // both conditions must be valid&#xA;      (&#xA;        (nowHH&amp;lt;closeHH)                       // check hours first&#xA;        || ((nowHH==closeHH) &amp;amp;&amp;amp; (nowMM&amp;lt;closeMM)))             // check minutes if in same hour&#xA;        || ((nowHH==closeHH) &amp;amp;&amp;amp; (nowMM==closeMM) &amp;amp;&amp;amp; (nowSS&amp;lt;=closeSS)) // check seconds if in same hour &amp;amp; minute&#xA;      ) &#xA;  { return true; } else { return false; }&#xA;}&#xA;&#xA;  // usage &#xA;  if (isOpenTime) {&#xA;    // ... do something, eg open door&#xA;  } else {&#xA;    // ... do something, eg close door&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24302" LastEditorUserId="24302" LastEditDate="2016-07-29T04:16:48.893" LastActivityDate="2016-07-29T04:16:48.893" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26817" PostTypeId="1" CreationDate="2016-07-29T02:21:46.113" Score="0" ViewCount="560" Body="&lt;p&gt;I want to log GPS coordinates using my Arduino and other sensors.  The difficulty is that I will be in forested conditions.  Would it be better to hardwire a gps device to the Arduino or to bluetooth an external device (a much more accurate, Trimble device that I know will give me the accuracy I need)?  Can such devices pair to a bluetooth receiver that would hardwire to my Arduino, or do I need an intermediate device like my iPhone?&lt;/p&gt;&#xA;" OwnerUserId="24303" LastActivityDate="2017-03-29T03:47:12.150" Title="I want to log GPS coordinates using my Arduino and other sensors" Tags="|arduino-uno|bluetooth|gps|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26818" PostTypeId="2" ParentId="25775" CreationDate="2016-07-29T06:56:50.403" Score="4" Body="&lt;p&gt;Use &lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Including files in double quotes (&quot;) will point to headers in current working directory first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: ... and there is nothing wrong with copying headers to CWD if you are modifying them, but that's probably not what you want.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="10394" LastEditDate="2016-07-29T07:50:39.173" LastActivityDate="2016-07-29T07:50:39.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26819" PostTypeId="1" CreationDate="2016-07-29T07:07:02.787" Score="0" ViewCount="1172" Body="&lt;p&gt;I have a problem with the interworking between Atmel Studio 7 and Arduino IDE 1.6.10. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently upgraded from IDE 1.0 to 1.6.10 and I can no longer upload my code to the Arduino. Everything works including compiling and it does recognise my COM3 port. Atmel Studio is configured for no external programmer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I compile with the Arduino IDE it &lt;em&gt;does&lt;/em&gt; upload the code. My question is what goes wrong here, what do I need to do solve it. Thanks for your help&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This the message I have in the end:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Compiling 'GridMonintor_V1R1' for 'Arduino Nano w/ ATmega328' Binary sketch size: 12,268 bytes (used 40% of a 30,720 byte maximum) (22.20 secs)&#xA;&#xA;Minimum Memory Usage: 774 bytes (38% of a 2048 byte maximum) Uploading to I/O board using 'COM3'&#xA;&#xA;avrdude: no programmer has been specified on the command line or the config file&#xA;         Specify a programmer using the -c option and try again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24309" LastEditorUserId="6936" LastEditDate="2017-01-25T14:59:46.247" LastActivityDate="2017-08-31T16:18:44.047" Title="Problem Atmel Studio 7 with uploading" Tags="|arduino-ide|uploading|atmel-studio|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26820" PostTypeId="2" ParentId="26807" CreationDate="2016-07-29T07:23:49.900" Score="1" Body="&lt;p&gt;I'd suggest you use a power-source that delivers you 8V. Your Arduino takes anything from 7-12V to power it and it regulates it down to 5V. But you still can access the 8V from the RAW pins. Use a MOSFET like &lt;a href=&quot;http://www.datasheetlib.com/datasheet/835216/d1703l_stmicroelectronics.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;D1703L&lt;/a&gt; to control the 8V with an 5V Arduino digital pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You just connect Drain (D) to GND and Source (S) to your RAW 8V (don't forget to put your device between the Source and RAW 8V). Your Arduino digital pin goes to Gate (G), but to not draw to much current from the pin you might want to use a resistor of roughly 1kΩ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the safest way that also allows for much higher voltage and also current for up to a few amps.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;EDIT&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You should not connect the PWM pin to Ground on your Arduino. But you have to connect both grounds together. I'm not sure where your 8V comes from so I made a sketch where the 8V is an external source and powers your device along with the MOSFET.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/OJsQo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OJsQo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23644" LastEditorUserId="23644" LastEditDate="2016-08-09T16:53:45.917" LastActivityDate="2016-08-09T16:53:45.917" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26822" PostTypeId="2" ParentId="26817" CreationDate="2016-07-29T07:54:22.203" Score="0" Body="&lt;p&gt;If the Trimble has a serial output then you could connect via that.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Trimble supports the same Bluetooth spec as your receiver, then there is no reason why you shouldn't be able to connect them directly. You will need to find out if the Trimble is a Master, Slave or both and buy the appropriate receiver for you Arduino.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="4628" LastEditDate="2017-03-29T03:47:12.150" LastActivityDate="2017-03-29T03:47:12.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26823" PostTypeId="2" ParentId="26819" CreationDate="2016-07-29T08:02:54.473" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;...Specify a programmer using the -c option and try again&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;For Arduino, the programmer switch must be &lt;code&gt;-c arduino&lt;/code&gt;. The full arguments for &lt;code&gt;avrdude&lt;/code&gt;, in the Atmel Studio 7 External Tools window, are:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-c arduino -p m328p -P COM3 -b 57600 -D -V -U flash:w:&quot;$(TargetDir)$(TargetName).hex&quot;:a&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions&quot; rel=&quot;nofollow noreferrer&quot;&gt;avrdude options&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastEditorUserId="6936" LastEditDate="2017-01-25T15:28:00.763" LastActivityDate="2017-01-25T15:28:00.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26825" PostTypeId="1" CreationDate="2016-07-29T08:31:33.577" Score="2" ViewCount="1172" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1bQ6b.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1bQ6b.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;I have mini project which is Emergency Traffic Light for Ambulance, police etc.&#xA;What I am try to do is when emergency traffic light go through first sensor 1 (in this code I just using button, “SA”), traffic light will be pause and the traffic light for ambulance will be green.&#xA;After ambulance go through second sensor (SB), traffic light will be reset and the flow become normal (red → orange → green).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My problem is I don’t know how to make interrupt for this code.&#xA;I hope anyone can help me.&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define SA 2 //sensor 1&#xA;#define SB 3 //sensor 2&#xA;#define IND 6 //indicator&#xA;/////////////////////////////////////&#xA;#define AH 13   // A&#xA;#define AK 12&#xA;#define AM 11&#xA;/////////////////////////////////////////&#xA;#define CH 10    //C B&#xA;#define CK 9&#xA;#define CM 8&#xA;#define yellowBlinkTime 500 // 0.5 seconds for yellow light blink&#xA;&#xA;///////////////////////////////////c&#xA;#define BH A0   // B&#xA;#define BK A1&#xA;#define BM A2&#xA;///////////////////////////////////////////////&#xA;&#xA;boolean TA = true; // west = true, east = false&#xA;int flowTime = 10000; // amount of time to let traffic flow&#xA;int changeDelay = 2000; // amount of time between color changes&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(SA, INPUT); //sensor 1&#xA;pinMode(SB, INPUT); //sensor 2&#xA;pinMode(IND, OUTPUT);   //indicator&#xA;&#xA;pinMode(AH, OUTPUT);   // A&#xA;pinMode(AK, OUTPUT);&#xA;pinMode(AM, OUTPUT);&#xA;///&#xA;pinMode(CH, OUTPUT);   //C&#xA;pinMode(CK, OUTPUT);&#xA;pinMode(CM, OUTPUT);&#xA;///////&#xA;pinMode(BH, OUTPUT);   // B&#xA;pinMode(BK, OUTPUT);&#xA;pinMode(BM, OUTPUT);&#xA;&#xA;// set initial state for lights -&#xA;//jalan A&#xA;digitalWrite(AM, LOW);&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(AH, HIGH);  &#xA;&#xA;//jalan C&#xA;digitalWrite(CM, HIGH);    &#xA;digitalWrite(CK, LOW);&#xA;digitalWrite(CH, LOW);&#xA;&#xA;///// JAlAN B&#xA;digitalWrite(BM, HIGH);    &#xA;digitalWrite(BK, LOW);&#xA;digitalWrite(BH, LOW);&#xA;&#xA;}//-------setup end&#xA;&#xA;&#xA;void loop()&#xA;{&#xA;  if(digitalRead(SA) == HIGH )&#xA;  { &#xA;  blink();&#xA;  //flow();&#xA;  //break;&#xA;  }&#xA;&#xA;  else{&#xA;&#xA;  flow(); // p void flow normal&#xA;} // end else &#xA;} // end void loop&#xA;&#xA;void flow() // flow normal tf&#xA;{&#xA;//flow1&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(AM, LOW);&#xA;digitalWrite(CK, LOW);&#xA;digitalWrite(AH, HIGH);  &#xA;digitalWrite(CM, HIGH);   &#xA;&#xA;digitalWrite(BH, LOW);&#xA;digitalWrite(BK, LOW);&#xA;digitalWrite(BM, HIGH); &#xA;&#xA;delay(changeDelay);&#xA;&#xA;//flow2&#xA;digitalWrite(AH, LOW);&#xA;digitalWrite(AM, LOW);&#xA;digitalWrite(AK, HIGH); &#xA;&#xA;digitalWrite(CM, HIGH);    &#xA;&#xA;digitalWrite(BM, HIGH);&#xA;delay(changeDelay);&#xA;&#xA;//flow3&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(CM, LOW);&#xA;digitalWrite(AM, HIGH);   &#xA;digitalWrite(CH, HIGH);  &#xA;digitalWrite(BM, HIGH);&#xA;delay(changeDelay);&#xA;&#xA;&#xA;//flow4&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(AH, LOW);&#xA;digitalWrite(CM, LOW);&#xA;digitalWrite(CH, LOW);&#xA;digitalWrite(AM, HIGH);    &#xA;digitalWrite(CK, HIGH);  &#xA;digitalWrite(BM, HIGH);&#xA;delay(changeDelay);&#xA;&#xA;//flow 5&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(AH, LOW);&#xA;digitalWrite(AM, HIGH);    &#xA;digitalWrite(BH, HIGH);    &#xA;digitalWrite(BM, LOW);&#xA;digitalWrite(CK, LOW);&#xA;digitalWrite(CH, LOW);&#xA;digitalWrite(CM, HIGH);  &#xA;delay(changeDelay);&#xA;&#xA;//flow 6&#xA;digitalWrite(AK, LOW);&#xA;digitalWrite(AH, LOW);&#xA;digitalWrite(AM, HIGH);    &#xA;&#xA;digitalWrite(BK, HIGH);    &#xA;digitalWrite(BH, LOW);&#xA;&#xA;digitalWrite(CM, HIGH);  &#xA;digitalWrite(CK, LOW);&#xA;digitalWrite(CH, LOW);&#xA;&#xA;delay(changeDelay);&#xA;&#xA;}//-------flow end&#xA;&#xA;void blink()&#xA;{&#xA;[enter link description here][2]&#xA;    digitalWrite(AH, LOW);&#xA;    digitalWrite(AM, LOW);&#xA;&#xA;    digitalWrite(BH, LOW);&#xA;    digitalWrite(BM, LOW);&#xA;&#xA;    digitalWrite(CH, LOW);&#xA;    digitalWrite(CM, LOW);&#xA;&#xA;&#xA;    digitalWrite(AK, LOW);&#xA;    digitalWrite(CK, LOW);&#xA;    digitalWrite(BK, LOW);&#xA;    delay(yellowBlinkTime);&#xA;&#xA;&#xA;&#xA;    ////////////////////////////////////////////////// BLINK BLINK&#xA;    digitalWrite(AK, HIGH); &#xA;    digitalWrite(CK, HIGH); &#xA;    digitalWrite(BK, HIGH); &#xA;    delay(yellowBlinkTime);&#xA;&#xA;}  ///////////////// end void blink&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24310" LastEditorUserId="37523" LastEditDate="2019-06-27T00:52:47.470" LastActivityDate="2019-06-27T00:52:47.470" Title="Interrupt for traffic light" Tags="|interrupt|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="26826" PostTypeId="1" CreationDate="2016-07-29T08:40:51.830" Score="1" ViewCount="48" Body="&lt;p&gt;Is it possible for Arduino boards to accurately process analog inputs that vary at MHz frequencies? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If possible, which Arduino board would be most appropriate for such application? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;What adjustments would be required for it to handle such rapid analog input variations?&lt;/p&gt;&#xA;" OwnerUserId="24218" LastEditorUserId="84" LastEditDate="2016-07-31T12:44:27.087" LastActivityDate="2016-09-29T15:41:16.133" Title="Is possible to process analogue inputs with variation frequencies in MHz?" Tags="|analog-sampling|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26828" PostTypeId="2" ParentId="26728" CreationDate="2016-07-29T09:42:49.833" Score="1" Body="&lt;p&gt;This: &lt;a href=&quot;https://github.com/arendst/Sonoff-MQTT-OTA-Arduino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/arendst/Sonoff-MQTT-OTA-Arduino&lt;/a&gt; is a Arduino based firmware with support for OTA. It's written for Sonoff, but that is just a ESP8266 with a relay attached, you can easily adapt it to any ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It uses a 'hard coded' address of a web server where it downloads the firmware, and updates are triggered by MQTT messages, but all of that should not be too hard to change to something else.&lt;/p&gt;&#xA;" OwnerUserId="23645" LastActivityDate="2016-07-29T09:42:49.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26829" PostTypeId="2" ParentId="26826" CreationDate="2016-07-29T10:06:26.097" Score="1" Body="&lt;p&gt;Your typical ATMega-base Arduino cannot sample anywhere near that kind of speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It takes 13 clock cycles to sample an analog value on an ATMega chip, and the maximum clock frequency for the ADC is 1MHz. That gives you an absolute maximum sampling speed of 76923 samples per second. That means the highest frequency you can sample is 38461Hz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are better chips on the market with higher sampling speeds, but they aren't Arduino. Some can sample at the tens of millions of samples per second allowing you to sample frequencies in the low MHz. Other specialised ADC chips are available that can sample in the Gsps range which are what are used in oscilloscopes and high speed communication (fibre optic) systems etc. Working with these kind of chips needs quite a lot of skill though as the analog signal paths requires special design and consideration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also when sampling at those kind of frequencies you need a &lt;em&gt;lot&lt;/em&gt; of high-speed memory, which no Arduino can ever even consider the possibility of having.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-29T10:06:26.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26831" PostTypeId="2" ParentId="26795" CreationDate="2016-07-29T12:34:30.670" Score="0" Body="&lt;p&gt;Yes, apparently you can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I did a quick search on Google and found a GitHub library for the ESP8266 &lt;a href=&quot;https://github.com/sabas1080/TembooForESP8266&quot; rel=&quot;nofollow&quot;&gt;https://github.com/sabas1080/TembooForESP8266&lt;/a&gt; and a post on the Arduino Forum &lt;a href=&quot;https://forum.arduino.cc/index.php?topic=337186.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=337186.0&lt;/a&gt; that says you can download a skeleton program and hack that.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-07-29T12:34:30.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26832" PostTypeId="1" AcceptedAnswerId="26835" CreationDate="2016-07-29T13:50:03.453" Score="17" ViewCount="99298" Body="&lt;p&gt;Asked this question on Electrical Engineering Stack Exchange and was directed here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pretty self explanatory; how would I go about converting a float into a char*? I have code in which the float 'resistance' is constantly being updated. I would like to be able to update the variable 'result' to take the value of 'resistance'. Here is some of the code, in case it helps:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char * result = &quot;&quot;;&#xA;float resistance = 2.5;&#xA;&#xA;result = resistance; //This bit (obviously) doesn't work&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;" OwnerUserId="24318" LastActivityDate="2016-07-29T14:15:07.280" Title="How do I convert a float into char*?" Tags="|arduino-uno|c++|c|float|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26835" PostTypeId="2" ParentId="26832" CreationDate="2016-07-29T14:15:07.280" Score="25" Body="&lt;p&gt;There is a function in the standard Arduino library called &lt;code&gt;dtostrf()&lt;/code&gt;. I think of it as &quot;Decimal to String Float&quot;. You pass in the float, how wide you want the whole number to be (if it will fit), the number of decimals of precision - and the buffer you want it to fill.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that! You need to provide the buffer, and you need to be careful to provide more than enough! Don't forget to add 1, too (to store the NUL character at the end):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char result[8]; // Buffer big enough for 7-character float&#xA;dtostrf(resistance, 6, 2, result); // Leave room for too large numbers!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will give &lt;code&gt;result&lt;/code&gt; values like &lt;code&gt;&quot;  1.23&quot;&lt;/code&gt; and &lt;code&gt;&quot; -1.23&quot;&lt;/code&gt; and &lt;code&gt;&quot;123456789&quot;&lt;/code&gt; (without the quotes). Note the last example - it won't truncate the number if it's too large, and that &lt;strong&gt;&lt;em&gt;10-&lt;/em&gt;&lt;/strong&gt; character &lt;code&gt;result&lt;/code&gt; (don't forget the final &lt;code&gt;NUL&lt;/code&gt;) just overflowed your buffer...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incidentally, if you specify a negative width, it won't right-justify the answer, it'll left-justify it (put any spaces on the end instead of the beginning).&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-29T14:15:07.280" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26839" PostTypeId="2" ParentId="26795" CreationDate="2016-07-29T15:09:28.527" Score="3" Body="&lt;p&gt;I work at Temboo. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While we don't officially support the ESP8266, we've found a couple of forum posts in which people have been able to get Temboo to work with the ESP8266. Here you go: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.esp8266.com/viewtopic.php?p=24019&quot; rel=&quot;nofollow&quot;&gt;http://www.esp8266.com/viewtopic.php?p=24019&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://forum.arduino.cc/index.php?topic=337186.0&quot; rel=&quot;nofollow&quot;&gt;https://forum.arduino.cc/index.php?topic=337186.0&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that doesn't help, feel free to contact Temboo Support and we'll do our best to help figure out what's going wrong for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The key piece of info you need to be aware of is that you need to modify following Temboo library files:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;\Arduino\libraries\Temboo\src\Temboo.cpp&#xA;&#xA;\Arduino\libraries\Temboo\src\utility\&#xA;--ChoreoInputFormatter&#xA;--ChoreoOutputFormatter&#xA;--ChoreoPresetFormatter&#xA;--TembooSession&#xA;--tmbhmac&#xA;--tmbmd5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You need to modify all occurrences of &lt;code&gt;&quot;avr/pgmspace.h&quot;&lt;/code&gt; in these files, changing it to &lt;code&gt;&quot;pgmspace.h&quot;&lt;/code&gt;. &lt;/p&gt;&#xA;" OwnerUserId="21256" LastEditorUserId="84" LastEditDate="2016-07-31T12:34:09.870" LastActivityDate="2016-07-31T12:34:09.870" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26841" PostTypeId="1" AcceptedAnswerId="26842" CreationDate="2016-07-29T15:47:49.763" Score="0" ViewCount="30" Body="&lt;p&gt;&lt;strong&gt;Items:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;Laptop&lt;/li&gt;&#xA;&lt;li&gt;7.4V 2s LiPo Battery&lt;/li&gt;&#xA;&lt;li&gt;Neewer 30A ESC&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LiPo powers the ESC while the Laptop USB powers the Arduino. If I unplug the USB from Arduino is loses power (obviously) and when I plug in the ESC to the arduino I get power again to the Arduino. I need the USB plugged in to receive &lt;code&gt;Serial&lt;/code&gt; information from the laptop and I need pow+gnd plugged into the Arduino or else I get a lot of PWM noise rendering my ESC useless.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;ESC is 5V&lt;/li&gt;&#xA;&lt;li&gt;USB is 5V&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my due diligence to not blowing anything up. What is the safest way to plug in power from both USB and the ESC? Same voltage, difference sources. Or can I just connect the grounds and call it good?&lt;/p&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-07-29T15:57:01.873" Title="Answer power IN from two sources" Tags="|power|usb|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26842" PostTypeId="2" ParentId="26841" CreationDate="2016-07-29T15:57:01.873" Score="2" Body="&lt;p&gt;Connecting the grounds would work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also connect the 7.2V lipo to the Vin pin on the UNO. The UNO will automatically switch from USB to Vin, if it's present.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-07-29T15:57:01.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26844" PostTypeId="2" ParentId="9082" CreationDate="2016-07-29T17:57:30.970" Score="2" Body="&lt;p&gt;The IR sensor module incorporates an internal 38KHz bandpass filter. The pot near the GND pin fine tunes the frequency of that signal, which is used to illuminate the IR LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other pot adjusts the duty cycle of the signal. This controls the brightness of the IR LED.  Both adjustments effect the sensitivity and range of the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To achieve maximum sensitivity, it is absolutely necessary to use the 'EN' or 'Enable' pin.  When used correctly, however, additional optical shielding of the IR LED is required.  This can be done with a small cardboard tube commonly used as packing material or any of a variety of other materials.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the Enable function is not used, the jumper must be installed on the board. The Enable pin cannot be used if the jumper is in place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more information, see: &lt;a href=&quot;http://irsensor.wizecode.com/&quot; rel=&quot;nofollow&quot;&gt;http://irsensor.wizecode.com/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="21227" LastEditorUserId="21227" LastEditDate="2016-08-09T23:13:41.670" LastActivityDate="2016-08-09T23:13:41.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26845" PostTypeId="2" ParentId="26800" CreationDate="2016-07-29T18:13:53.650" Score="2" Body="&lt;p&gt;The solution turned out to be a couple of things, some of which mentioned by others in the comments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Problems that needed to be fixed:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;My level-shifter was a huge part of the problem. I switched to a MAX232-based chip and then I was a least able to get responses shorted lines 2 and 3 (Tx and Rx).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I needed a cross-over cable. I had tried this while troubleshooting, but because that alone didn't fix the problem, I had not idea whether or not that was the problem, or just one of the problems.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;I needed to use the onboard UART (Serial1) rather than SoftwareSerial. The problem was that I needed to be able to set the protocol to 8 bits with no parity. This configuration parameter cannot be changed on SoftwareSerial, but is as simple as &lt;code&gt;Serial1.begin(9600, SERIAL_8N2)&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you for the help, and hopefully my mistakes make the process easier for others.&lt;/p&gt;&#xA;" OwnerUserId="8570" LastActivityDate="2016-07-29T18:13:53.650" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26847" PostTypeId="1" AcceptedAnswerId="36459" CreationDate="2016-07-29T21:03:04.167" Score="0" ViewCount="246" Body="&lt;p&gt;I need to do some simple line control of audio out from a phone, 3.5mm TRS. I would have preferred to use transistors, but the voltage drop on an already fairly weak signal makes it unusable. Also not sure about negative voltage from collector to emitter. Essentially I need to switch the line on/off. How can I do this while not introducing noise or signal loss (K.I.S.S.) - I haven't checked if optocouplers are without voltage drop, but in any case they're probably overkill. &#xA;Ask for clarification if needed.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2017-03-29T20:42:15.127" Title="Control/switching of headphone audio" Tags="|arduino-pro-mini|audio|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26848" PostTypeId="2" ParentId="26847" CreationDate="2016-07-29T21:26:33.160" Score="0" Body="&lt;p&gt;My first thought was what about relays.  I've done a quick search and found this &lt;a href=&quot;http://www.geofex.com/article_folders/relays/relays_for_switching_audio_signa.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.geofex.com/article_folders/relays/relays_for_switching_audio_signa.htm&lt;/a&gt; and this &lt;a href=&quot;https://electronics.stackexchange.com/questions/110750/is-it-possible-to-turn-an-audio-signal-on-off-using-a-solid-state-relay&quot;&gt;https://electronics.stackexchange.com/questions/110750/is-it-possible-to-turn-an-audio-signal-on-off-using-a-solid-state-relay&lt;/a&gt; so maybe it's not such a stupid idea, but like optocouplers it probably is a bit OTT.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-29T21:26:33.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26850" PostTypeId="1" CreationDate="2016-07-29T22:14:46.180" Score="2" ViewCount="164" Body="&lt;p&gt;Currently trying to implement a lightweight webserver using the WiFly shield and an Arduino UNO, this is the code I have so far:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt; &#xA;#include &amp;lt;WiFly.h&amp;gt;&#xA;WiFlyServer server(80);&#xA;&#xA;/* Function defs */&#xA;void cmd(void)  { SpiSerial.print(&quot;$$$&quot;); }&#xA;void dhcp(void) { SpiSerial.println(&quot;SET IP DHCP 0&quot;); }&#xA;void pass(void) { SpiSerial.println(&quot;SET WLAN PHRASE 22222222&quot;); }&#xA;void ssid(void) { SpiSerial.println(&quot;JOIN BTHOMEHUB&quot;); }&#xA;void port(void) { SpiSerial.println(&quot;SET IP LOCAL 80&quot;); }&#xA;void ip(void)   { SpiSerial.println(&quot;SET IP ADDRESS 192.168.1.123&quot;); }&#xA;void tcp(void)  { SpiSerial.println(&quot;SET IP PROTOCOL 2&quot;); }&#xA;void boot(void) { SpiSerial.println(&quot;REBOOT&quot;); }&#xA;&#xA;/* Pointer to a handler function */&#xA;typedef void (*Handler)(void);&#xA;Handler table[8] = { cmd, dhcp, pass, ssid, port, ip, tcp, boot };&#xA;&#xA;void setup() {&#xA;  server.begin();&#xA;  Serial.begin(9600);&#xA;  SpiSerial.begin();&#xA;&#xA;  for(short x = 0; x &amp;lt; 7; x++) {&#xA;    table[x]();&#xA;    delay(100);&#xA;  }&#xA;}&#xA;&#xA;void loop() {&#xA;  WiFlyClient client = server.available();&#xA;&#xA;  if(client){&#xA;    while(client.connected()) {&#xA;      if(client.available()) {&#xA;        client.println(&quot;&amp;lt;HTML&amp;gt;&amp;lt;BODY&amp;gt;&amp;lt;H1&amp;gt;Hi&amp;lt;/H1&amp;gt;&amp;lt;P&amp;gt;This is text.&amp;lt;/P&amp;gt;&amp;lt;/BODY&amp;gt;&amp;lt;/HTML&amp;gt;&quot;);&#xA;      }&#xA;    }&#xA;    delay(100);&#xA;    client.flush();&#xA;    client.stop();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This compiles well, but when hitting &lt;code&gt;192.168.1.123&lt;/code&gt; in my web browser I get an ever-increasing output like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*HELLO*&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;&amp;lt; (cont.)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Definitely not the expected html. I have been playing with this code for hours now and this is the most positive output I can get. If I do a &lt;code&gt;Serial.write(client.read())&lt;/code&gt; within &lt;code&gt;if(client.available()) {&lt;/code&gt; I am able to print all the request information to the serial monitor, it just seems I am perhaps sending the data in an incorrect format? Any suggestions? Cheers&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have updated the codebase to include the http headers,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;client.println(&quot;Content-Type: text/html&quot;);&#xA;client.println(&quot;Connnection: close&quot;);&#xA;client.println(&quot;&quot;);&#xA;client.println(&quot;&amp;lt;!DOCTYPE html&amp;gt;&quot;);&#xA;client.println(&quot;&amp;lt;HTML&amp;gt;&amp;lt;BODY&amp;gt;&amp;lt;H1&amp;gt;Hi.....&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;now I get I different (similar) output, seems like it is printing the first character of each new line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;*HELLO*H&#xA;C&#xA;C&#xA;&#xA;&amp;lt;&#xA;&amp;lt;&#xA;H&#xA;C&#xA;C&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24330" LastEditorUserId="24330" LastEditDate="2016-07-29T23:33:26.493" LastActivityDate="2016-07-30T00:58:10.997" Title="Basic WiFly server returning unexpected output within web client" Tags="|arduino-uno|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26851" PostTypeId="2" ParentId="18755" CreationDate="2016-07-29T22:32:17.353" Score="4" Body="&lt;p&gt;On the transmitting side (with cheap AC switches as receiver), I've actually had good results with the cheap green squares, and the equally cheap 5 for a dollar 'Helical antenna 433MHz' you find everywhere on ebay :)&#xA;I can reach all three levels of our house with that, and that's with only 5v supply on the green square, and it just sitting on a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On request, picture of the antenna, soldered onto one of the cheap green  transmitters, this one works well for me on 5V:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/jux2j.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/jux2j.jpg&quot; alt=&quot;Picture of antenna&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This antenna was bought as a set of 5 from:&#xA;&lt;a href=&quot;http://www.ebay.com/itm/171271811976&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.ebay.com/itm/171271811976&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's about 21 windings, with 5mm diameter, so that makes roughly 5mm * 3.14(=Pi) * 21 = 33 cm of wire in the coil.&lt;/p&gt;&#xA;" OwnerUserId="23645" LastEditorUserId="23645" LastEditDate="2016-07-30T15:12:38.613" LastActivityDate="2016-07-30T15:12:38.613" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26852" PostTypeId="2" ParentId="26850" CreationDate="2016-07-29T23:44:00.540" Score="1" Body="&lt;p&gt;Your browser sent a HTTP GET request. You need to send a HTTP response in kind, in accordance with the protocol, for your browser to correctly interpret the data. Something like this should do:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #define TIMEOUT 100&#xA;  char response[] = &quot;&amp;lt;HTML&amp;gt;&amp;lt;BODY&amp;gt;&amp;lt;H1&amp;gt;Hi&amp;lt;/H1&amp;gt;&amp;lt;P&amp;gt;This is text.&amp;lt;/P&amp;gt;&amp;lt;/BODY&amp;gt;&amp;lt;/HTML&amp;gt;&quot;;&#xA;  unsigned long lastRead;&#xA;  ...&#xA;&#xA;  while (client.connected()){&#xA;    if (client.available()){&#xA;      lastRead = millis();&#xA;      while (millis() - lastRead &amp;lt; TIMEOUT){&#xA;        while (client.available()){&#xA;          Serial.write(client.read());&#xA;          lastRead = millis();&#xA;        }&#xA;      }&#xA;      client.println(&quot;HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: closed\r\n\r\n&quot;);&#xA;      client.print(response);&#xA;      break;&#xA;    }&#xA;  }&#xA;  delay(1000);&#xA;  client.stop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It turns out that the Wifly shield sends a response status as well as &quot;HELLO&quot; by default. You have to disable that with a few commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;set comm remote 0&#xA;set comm open 0&#xA;set comm close 0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will ensure that &quot;&lt;em&gt;HELLO&lt;/em&gt;&quot; isnt sent each time a client connection is made, though I'm not sure if this affects the default &lt;code&gt;HTTP/0.9 200 OK&lt;/code&gt; response status that is always sent. You can try the sketch above with and without the response header to see what you get.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-07-30T00:58:10.997" LastActivityDate="2016-07-30T00:58:10.997" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26853" PostTypeId="1" AcceptedAnswerId="26854" CreationDate="2016-07-29T23:49:48.480" Score="0" ViewCount="307" Body="&lt;p&gt;So I'm trying to create a new file that has underscores in its name. However, when I try this, no file is created.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This works&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String fileName = &quot;NMEA.txt&quot;;&#xA;mySensorData = SD.open(fileName.c_str(), FILE_WRITE); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;This does not work&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String fileName = &quot;NMEA__23_33_3__16_7_29.txt&quot;;&#xA;mySensorData = SD.open(fileName.c_str(), FILE_WRITE); &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Does anyone know why?&lt;/p&gt;&#xA;" OwnerUserId="24065" LastActivityDate="2016-07-29T23:55:02.197" Title="Cannot open file with underscores using the SD library" Tags="|arduino-mega|sd-card|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26854" PostTypeId="2" ParentId="26853" CreationDate="2016-07-29T23:55:02.197" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;[The SD library] uses short 8.3 names for files.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/SD&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-07-29T23:55:02.197" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26857" PostTypeId="2" ParentId="26767" CreationDate="2016-07-30T05:06:07.037" Score="1" Body="&lt;p&gt;I finally figured it out. It is due to reset whenever I open a port for serial communication. Attaching a 10uF capacitor between ground and reset fixed everything.&lt;/p&gt;&#xA;" OwnerUserId="24018" LastActivityDate="2016-07-30T05:06:07.037" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26858" PostTypeId="2" ParentId="26632" CreationDate="2016-07-30T05:35:39.507" Score="0" Body="&lt;p&gt;Upon having a clarification on what the problem essentially is, the answer is as follows:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) There is no way of knowing if the port is a wall charger or inactive computer port, initially. Therefore the initial device behavior must be identical in both cases – asserting pull-up on D+ (assuming it is USB 1.1 FS interface);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(2) However, if the port belongs to a computer, the connect event will awake the host, and the host will issue USB_reset, and perform device enumeration. There is no need to “send any Tx signal” or else, the host will perform this activity by itself. The Arduino software must remember this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(3)  If the host decides to suspend the port (fell asleep), the device must transition into SUSPEND state, and Arduino software must remember this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(4) If the port was initially in a state with USB totally disabled and does not wake up upon cable attach, see scenario (1);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(5) When/if the host computer is awaken, it will see USB attach status (D+ is up), and will start scenario (2).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In summary, the device (upstream facing port) must implement port functionality in full accord with port state machine described in USB2.0 specifications, Section 9 (Figure 9-1) and Appendix C.2 , Figures C-2 and C-3. As one can see, contrary to the assumption of OP, the port can be in more than two states, and Adruino software must have several different behaviors. Any half-baked implementation of the port state diagram is unacceptable and will cause some functional problem sooner or later.&lt;/p&gt;&#xA;" OwnerUserId="24294" LastActivityDate="2016-07-30T05:35:39.507" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26860" PostTypeId="2" ParentId="26706" CreationDate="2016-07-30T06:26:29.677" Score="0" Body="&lt;p&gt;The Arducam Mini Shield is limited to 512kb frame buffer, so photos of larger resolution easily overflow the buffer. You can fit higher resolution photos onto the frame buffer by increasing the compression or adjusting other settings on the camera that reduce the file size of the resulting image (reduce saturation, windowing, etc).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To change the compression, adjust register 0x4407. The higher the number the more compression there is. The camera's default is 0x0C and the Arducam sample code sets it to 0x04.  &lt;code&gt;myCAM.wrSensorReg16_8(0x4407,0x09);&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To adjust other settings on the camera (including the ones listed above) check out the detailed list of camera registers at &lt;a href=&quot;http://www.dragonwake.com/download/camera/ov5642/OV5642-DS.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.dragonwake.com/download/camera/ov5642/OV5642-DS.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, Arducam is releasing the Arducam Mini Plus which has an 8 MByte frame buffer and is available on advanced order for $35 USD by contacting Arducam directly.&lt;/p&gt;&#xA;" OwnerUserId="23286" LastActivityDate="2016-07-30T06:26:29.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26861" PostTypeId="1" CreationDate="2016-07-30T07:27:33.920" Score="1" ViewCount="1920" Body="&lt;p&gt;&lt;strong&gt;Electronics Newbie!!&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to connect a USB cable to my Uno's GPIO pins (and then connect it to a USB port on my computer). I have chopped off a USB cable from a keyboard, I read &lt;a href=&quot;https://electronics.stackexchange.com/a/37066&quot;&gt;this&lt;/a&gt; and I'm hoping that the wires will be in the correct order (the keyboard was made by Dell). I'm a little confused about which wires go where.&lt;/p&gt;&#xA;" OwnerUserId="24324" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-07-30T09:33:44.810" Title="Connect USB cable to GPIO pins on an Arduino Uno" Tags="|arduino-uno|usb|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26862" PostTypeId="2" ParentId="26714" CreationDate="2016-07-30T08:28:48.690" Score="0" Body="&lt;p&gt;The issues were:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Pin 9 MSM_nRESET should be explicitly set to HIGH.&lt;/li&gt;&#xA;&lt;li&gt;Pin 10 (DTR) and pin 11 (RTS) should be explicitly set to LOW.&lt;/li&gt;&#xA;&lt;li&gt;The Nimbelink device requires 5V external power. With USB power, the modem can intermittently reset during period of high activity. If the modem resets, then the command can appear to run forever when nothing is actually running.&lt;/li&gt;&#xA;&lt;li&gt;Must use FTPOPEN with connection type 1 (passive).&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="23286" LastActivityDate="2016-07-30T08:28:48.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26864" PostTypeId="1" CreationDate="2016-07-30T09:07:36.270" Score="0" ViewCount="185" Body="&lt;p&gt;I have an fps gt-511c1r fingerprint sensor module. I want to know whether i can run it using teensy 3.0 or above?&#xA;I have tried it successfully using arduino uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: I have uploaded the fps blink sketch on the teensy 3.2 successfully, but the fingerprint scanner is not responding. Here is the code:-&lt;br&gt;&#xA;         #include &quot;FPS_GT511C3.h&quot;&lt;br&gt;&#xA;         #include &quot;SoftwareSerial.h&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     // Hardware setup - FPS connected to:  &#xA;     //   digital pin 0(arduino rx, fps tx)  &#xA;     //   digital pin 1(arduino tx, fps rx)  &#xA;&#xA;&#xA;     FPS_GT511C3 fps(0, 1);&#xA;&#xA;     void setup()&#xA;     {&#xA;         Serial.begin(9600);&#xA;         fps.UseSerialDebug = true; &#xA;         fps.Open();&#xA;     }&#xA;&#xA;&#xA;     void loop()&#xA;     {&#xA;        // FPS Blink LED Test&#xA;        fps.SetLED(true);&#xA;         delay(1000);&#xA;         fps.SetLED(false);&#xA;         delay(1000);&#xA;     } &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;connected fps tx to teensy rx(pin 0),&lt;br&gt;&#xA;          fps rx to teensy tx(pin 1),&lt;br&gt;&#xA;          fps vcc to 3.3v teensy,&lt;br&gt;&#xA;          fps gnd to teensy gnd.  &lt;/p&gt;&#xA;" OwnerUserId="24287" LastEditorUserId="24287" LastEditDate="2016-08-03T13:48:27.827" LastActivityDate="2016-08-03T13:48:27.827" Title="can teensy 3.0 or above run fingerprint scanner fps gt-511c1r?" Tags="|teensy|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="26865" PostTypeId="2" ParentId="17463" CreationDate="2016-07-30T09:10:13.140" Score="0" Body="&lt;p&gt;Finally I got it working yesterday, and by accident!!!! Sorry it was not sooner, hope you had better luck with it. In any case if anyone wants to know what I did, you can read about it here. &#xA;&lt;a href=&quot;https://forum.sparkfun.com/viewtopic.php?f=14&amp;amp;t=44292&quot; rel=&quot;nofollow&quot;&gt;https://forum.sparkfun.com/viewtopic.php?f=14&amp;amp;t=44292&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24280" LastActivityDate="2016-07-30T09:10:13.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26866" PostTypeId="2" ParentId="26861" CreationDate="2016-07-30T09:33:44.810" Score="1" Body="&lt;p&gt;The reason you are confused about which wires go where is simply because the Uno has no connection on it for a USB cable's wires.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You cannot directly interface an Uno to a USB port without extra hardware.  What hardware you require depends on exactly what it is you think you are trying to achieve.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(There have been some attempts to create a USB device interface purely in software, but personally I wouldn't touch it with a barge pole - the GPIO of the Arduino is not electrically compatible with USB.)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-30T09:33:44.810" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26867" PostTypeId="2" ParentId="25414" CreationDate="2016-07-30T10:20:52.607" Score="1" Body="&lt;p&gt;I finally figured it out, the Arduino was entering a current protection mode causing it to reset. The pins driving the MOSFETs were pulling too much current once the regulation started because of the BUZ11's input capacitance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix the problem I just had to add 120 ohm resistors in series with the gate. This made the activation and deactation slower resulting in less current flow.&lt;/p&gt;&#xA;" OwnerUserId="23136" LastActivityDate="2016-07-30T10:20:52.607" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26868" PostTypeId="2" ParentId="26864" CreationDate="2016-07-30T10:48:42.657" Score="1" Body="&lt;p&gt;The GT-511C1R is a 5V device. The Teensy 3.0 is a 3.3V device. You will require some level shifting as you would with any 3.3V Arduino connecting to a 5V device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Besides that, yes, the Teensy 3.0 is more than capable of working with the fingerprint scanner. Will the software work? Most likely, but only trying it will confirm that.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-30T10:48:42.657" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26869" PostTypeId="1" CreationDate="2016-07-30T13:38:38.953" Score="2" ViewCount="1032" Body="&lt;p&gt;I just got my Arduino UNO delivered and I wanted to see if it's working properly or not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried following &lt;a href=&quot;https://www.arduino.cc/en/Main/Howto&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; to create a simple program and the program compiled successfully. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I tried to select the serial port on IDE, the port option was grayed out. I searched for the problem and I landed on &lt;a href=&quot;https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/linux&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt;. It says&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Linux includes the drivers necessary to use Arduino, and no additional&#xA;  install is needed. However, permissions might need to be configured.&#xA;  For current instructions on how to set up these permissions, visit&#xA;  this page.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;An alternative method is to run Arduino as root in the terminal.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But I still see the port option grayed out even as a root user. Any idea? &lt;/p&gt;&#xA;" OwnerUserId="20271" LastEditorUserId="84" LastEditDate="2016-07-31T12:32:28.840" LastActivityDate="2016-07-31T12:32:28.840" Title="Cannot access &quot;tools&gt;Serial port&quot; on Kali Linux" Tags="|serial|arduino-ide|linux|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26873" PostTypeId="1" AcceptedAnswerId="27010" CreationDate="2016-07-30T16:19:43.860" Score="0" ViewCount="3749" Body="&lt;h2&gt;tl;dr&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I can't send data using the raw &lt;a href=&quot;http://www.aliexpress.com/item/10pcs-SPP-C-Bluetooth-serial-module-wireless-serial-communication-Module-Wireless-SPPC-Bluetooth-Module-free-shiping/32375150414.html&quot; rel=&quot;nofollow&quot;&gt;SPP-C&lt;/a&gt; Bluetooth module without a breakout board.&#xA;The communication via UART works fine as I am able to issue AT commands and get proper responses.&#xA;But when connected over Bluetooth the data passed over UART does not show up on my computer while the other direction works fine.&#xA;Has anyone tried that module yet without using a breakout board?&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;The long story:&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;I started my project by using a regular &lt;a href=&quot;http://www.aliexpress.com/item/Free-Shipping-910K-1-0603-100pcs-LOT-SMD-Resistor-sample-in-stock-most-value-don/615810800.html?spm=2114.01010208.3.8.Bz3tbN&amp;amp;ws_ab_test=searchweb201556_0,searchweb201602_5_10057_10056_10055_10037_10049_10033_10059_10058_10032_10017_405_404_10060_10061_10062_412,searchweb201603_1&amp;amp;btsid=8f32b1e9-afa4-451e-87c0-13841a62c223&quot; rel=&quot;nofollow&quot;&gt;HC-05&lt;/a&gt; module on a breakout board. The prototype worked just fine as there are also plenty tutorials available. The drawback using that breakout module is that it works with two voltages, 5V for power and 3V3 for communication. I have also more components in my project that run best at 3V3. That is why it came to my mind to use 3V3 as the only voltage. The raw &lt;a href=&quot;http://www.aliexpress.com/item/Free-Shipping-lot-wholesale-HC-05-HC-05-RF-Wireless-Bluetooth-Transceiver-Module-RS232-TTL-to/32532940254.html?spm=2114.01010208.3.17.az8Edc&amp;amp;ws_ab_test=searchweb201556_0,searchweb201602_5_10057_10056_10055_10037_10049_10033_10059_10058_10032_10017_405_404_10060_10061_10062_412,searchweb201603_1&amp;amp;btsid=5b7f99a0-2a87-42b0-9cf6-30852c96567f&quot; rel=&quot;nofollow&quot;&gt;HC-05&lt;/a&gt; module without breakout board is also powered with 3V3. So everything looked just perfect.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at the specs to the HC-05 I noticed that there is also more on that module like SPI and USB (&lt;a href=&quot;http://www.tec.reutlingen-university.de/uploads/media/DatenblattHC-05_BT-Modul.pdf&quot; rel=&quot;nofollow&quot;&gt;page 12 bottom&lt;/a&gt;). So I got curious and off track.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Anyway. Instead of ordering raw HC-05 modules without breakout board I ordered cheaper SPP-C modules that don't have all this fancy stuff but just UART communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following the description from &lt;a href=&quot;http://www.martyncurrey.com/bluetooth-modules/&quot; rel=&quot;nofollow&quot;&gt;Martyn Currey&lt;/a&gt; I was quicky able to issue AT commands and receive data over bluetooth. But I am not able to send data over Bluetooth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the same setup as it is shown on page 4 in the &lt;a href=&quot;http://www.elektroda.pl/rtvforum/download.php?id=745759&quot; rel=&quot;nofollow&quot;&gt;Chinese datasheet&lt;/a&gt;. (no I can't read that crazy symbols but I can read and understand the images)&lt;/p&gt;&#xA;" OwnerUserId="23644" LastEditorUserId="23644" LastEditDate="2016-07-31T20:27:17.363" LastActivityDate="2016-08-03T21:31:08.587" Title="Sending data using Bluetooth SPP-C Module without a Breakout-Board" Tags="|bluetooth|uart|hc-05|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26881" PostTypeId="1" CreationDate="2016-07-30T19:18:45.853" Score="0" ViewCount="1001" Body="&lt;p&gt;I'm having issues implementing a web socket on the Arduino/Genuino to procress a string received and do something respectively.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using SimpleWebSocket example, edited for my purpose, from the ArduinoHttpClient... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;don't seam to get the hangs of it. don't know what i'm doing wrong, cannot store the received string object on a string variable or use the readString() method on and if statement to compare with a string to decide what flow path to get in to&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code im trying:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Simple WebSocket client for ArduinoHttpClient library&#xA;  Connects to the WebSocket server, and sends a hello&#xA;  message every 5 seconds&#xA;&#xA;  note: WiFi SSID and password are stored in config.h file.&#xA;  If it is not present, add a new tab, call it &quot;config.h&quot;&#xA;  and add the following variables:&#xA;  char ssid[] = &quot;ssid&quot;;     //  your network SSID (name)&#xA;  char pass[] = &quot;password&quot;; // your network password&#xA;&#xA;  created 28 Jun 2016&#xA;  by Sandeep Mistry&#xA;&#xA;  this example is in the public domain&#xA;*/&#xA;#include &amp;lt;ArduinoHttpClient.h&amp;gt;&#xA;#include &amp;lt;WiFi101.h&amp;gt;&#xA;#include &quot;config.h&quot;&#xA;&#xA;char serverAddress[] = &quot;192.168.1.140&quot;;  // server address&#xA;int port = 8000;&#xA;&#xA;WiFiClient wifi;&#xA;WebSocketClient client = WebSocketClient(wifi, serverAddress, port);&#xA;int status = WL_IDLE_STATUS;&#xA;int count = 0;&#xA;&#xA;void setup() {&#xA;  pinMode(6, OUTPUT);&#xA;&#xA;&#xA;  Serial.begin(9600);&#xA;  while ( status != WL_CONNECTED) {&#xA;    Serial.print(&quot;Attempting to connect to Network named: &quot;);&#xA;    Serial.println(ssid);                   // print the network name (SSID);&#xA;&#xA;    // Connect to WPA/WPA2 network:&#xA;    status = WiFi.begin(ssid, pass);&#xA;  }&#xA;&#xA;  // print the SSID of the network you're attached to:&#xA;  Serial.print(&quot;SSID: &quot;);&#xA;  Serial.println(WiFi.SSID());&#xA;&#xA;  // print your WiFi shield's IP address:&#xA;  IPAddress ip = WiFi.localIP();&#xA;  Serial.print(&quot;IP Address: &quot;);&#xA;  Serial.println(ip);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;starting WebSocket client&quot;);&#xA;  client.begin();&#xA;&#xA;  while (client.connected()) {&#xA;    int messageSize = client.parseMessage();&#xA;&#xA;    if (messageSize &amp;gt; 0) {&#xA;      String test = client.readString();&#xA;      Serial.println(client.readString());&#xA;      Serial.println(test);&#xA;      if (client.readString() == &quot;off&quot;) {&#xA;        Serial.println(&quot;low&quot;);&#xA;        digitalWrite(6, LOW);&#xA;      }&#xA;      else {&#xA;        Serial.println(&quot;high&quot;);&#xA;        digitalWrite(6, HIGH);&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  Serial.println(&quot;disconnected&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On the example above, you can see in the void loop, after I check there's incoming data with messsageSize I store the incoming data using readString on a variable test, which I then println, this shows and empty line, although when I directly via println readString it shows some data, so the data is coming in... subsequently when I try to use the data from the incoming buffer on and if statement to compare with a string is wont work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried everything I can think off, puting the string to compare in to a variable and compare them, using Compare method from the object and I cannot even remember what else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does anyone have any advice on how to do this, maybe the library is buggie, maybe I'm doing it wrong, any other libraries that anyone can recommend, I've looked around and this is the only one that looked simple enough to get started with and had the most examples.&lt;/p&gt;&#xA;" OwnerUserId="11798" LastActivityDate="2016-11-05T22:43:38.460" Title="WebSocket client for ArduinoHttpClient conditional if with readString() incoming data buffer" Tags="|string|mkr1000|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26882" PostTypeId="1" CreationDate="2016-07-30T20:56:36.193" Score="0" ViewCount="66" Body="&lt;p&gt;I would like to know if I need an I/O shield for the 4 ESC's on a Quadcopter I am building using Arduino Mega2560.  The current to the ESC's should come from the battery itself and the data from the board so my first thought is that it is not needed however I wanted to be sure.&lt;/p&gt;&#xA;" OwnerUserId="24353" LastActivityDate="2016-10-29T00:27:45.847" Title="do i need an I/O shield for quadcopter motors" Tags="|arduino-mega|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26884" PostTypeId="2" ParentId="26882" CreationDate="2016-07-30T21:31:08.260" Score="1" Body="&lt;p&gt;If the ESC accepts a signal that the Arduino can generate (i.e., 5V PWM) then no interfacing is required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the ESC is running from 3.7V (or similar) then some level shifting may be required to reduce the 5V signal to 3.7V, depending on the ESC. That may be built on a shield of some form or just with discrete resistors wired in manually to the leads.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-30T21:31:08.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26888" PostTypeId="1" CreationDate="2016-07-31T00:59:20.587" Score="1" ViewCount="8129" Body="&lt;p&gt;is it possible to use a normal PNP transistor to drive a motor?&#xA;I'm kinda new to this stuff so I want to be on the safe side, so I don't damage my Arduino Uno because of the motor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have made a motor driver? &lt;a href=&quot;https://circuits.io/circuits/2493784-test-1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://circuits.io/circuits/2493784-test-1&lt;/a&gt;&#xA;But I'm not sure if i have done right and I wont break any components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So does this work without any problems and have I done it right?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not trying to make a H-bridge because I need both PNP and NPN?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:Picture&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BWJP0.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BWJP0.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24360" LastEditorUserId="24360" LastEditDate="2016-08-01T16:56:50.357" LastActivityDate="2016-08-01T16:56:50.357" Title="Arduino Driver can I use only PNP?" Tags="|motor|transistor|h-bridge|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26890" PostTypeId="2" ParentId="26817" CreationDate="2016-07-31T01:02:37.897" Score="1" Body="&lt;p&gt;The GPS receiver I've always used is the Adafruit Ultimate GPS:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.adafruit.com/products/746?gclid=CjwKEAjwoPG8BRCSi5uu6d6N5WcSJABHzD8FmldH1vIvTt8h-S-948CJmDR6fR_BcF20UZMS4I-AEBoCt9Tw_wcB&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/products/746?gclid=CjwKEAjwoPG8BRCSi5uu6d6N5WcSJABHzD8FmldH1vIvTt8h-S-948CJmDR6fR_BcF20UZMS4I-AEBoCt9Tw_wcB&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It comes with a spot for you to plug in an external antenna (with an adapter), so you can get more precision and presumably be able to receive data much more accurately in places like forests. However, I'm not sure of this, so an external device may be the way to go. Bluetooth would be possible, but it can be a little difficult to set up with Arduino if you lack the experience, so if you can I'd go with a wired connection (with an RS232 or other).&lt;/p&gt;&#xA;" OwnerUserId="16025" LastEditorUserId="4628" LastEditDate="2017-03-29T03:46:26.097" LastActivityDate="2017-03-29T03:46:26.097" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26891" PostTypeId="2" ParentId="26888" CreationDate="2016-07-31T01:21:10.323" Score="1" Body="&lt;p&gt;You need an NPN transistor to run a motor like that off of an arduino. Take a look at this article: &lt;a href=&quot;https://learn.sparkfun.com/tutorials/transistors&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://learn.sparkfun.com/tutorials/transistors&lt;/a&gt;&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Similar to the NPN circuit, the base is our input, and the emitter is tied to a constant voltage. This time however, the emitter is tied high, and the load is connected to the transistor on the ground side.&lt;/p&gt;&#xA;&lt;p&gt;This circuit works just as well as the NPN-based switch, but there’s one huge difference: to turn the load “on” the base must be low. This can cause complications, especially if the load’s high voltage (VCC in this picture) is higher than our control input’s high voltage. For example, this circuit wouldn’t work if you were trying to use a 5V-operating Arduino to switch on a 12V motor. In that case it’d be impossible to turn the switch off because Vb would always be less than Ve.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Using an NPN transistor is the way to go here. Keep in mind that you can't control the direction of a motor with just one transistor, however.&lt;/p&gt;&#xA;" OwnerUserId="16025" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-07-31T01:21:10.323" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26893" PostTypeId="1" AcceptedAnswerId="26894" CreationDate="2016-07-31T02:22:49.693" Score="0" ViewCount="51" Body="&lt;p&gt;I made a servo motor turn if the result of random(0, 10000) is less than or equal to 1. If that is the case, the motor turns to 130 degrees, to 50 degrees, and then to default position(90 degrees). It works well except whenever I turn on the Arduino, it automatically executes the turning maneuver. It usually takes dozens of seconds for the randomNum to be 1 or 0. However, the servo always turns right away at the beginning. Here is my code. I will make comments to help you understand what I was thinking. I used no delays. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;Servo servo;&#xA;unsigned long timer=millis();//counter&#xA;unsigned long servoTimer;&#xA;boolean turned130 = false;&#xA;int randomNum;//will hold value 0-9999&#xA;bool backCheck = false;//variables to keep track which code block to call&#xA;bool checkingAllowed = false;&#xA;bool turned50 = false;&#xA;bool startChecking = false;&#xA;&#xA;void setup() {&#xA;servo.attach(12);&#xA;servo.write(90);//set default position&#xA;servoTimer=millis();&#xA;}&#xA;&#xA;void loop() {&#xA;timer=millis();//update counter each time&#xA;if(checkingAllowed==false){&#xA;randomNum = random(0, 10000);//random number generator&#xA;if(randomNum&amp;lt;=1){//small odds&#xA;  checkingAllowed = true;//makes this codeblock unable to run&#xA;  servoTimer=millis();&#xA;  servo.write(130);&#xA;  turned130=true;/sets variables to allow other if statements to run&#xA;  turned50=false;&#xA;}&#xA;}&#xA;if(timer-servoTimer&amp;gt;=1000 &amp;amp;&amp;amp; turned130==true &amp;amp;&amp;amp; checkingAllowed==true &amp;amp;&amp;amp; turned50==false){//next codeblock that runs if random &amp;lt;= 1 after 1 second&#xA;turn50();&#xA;}&#xA;if(timer-servoTimer&amp;gt;=1000 &amp;amp;&amp;amp; turned130==false &amp;amp;&amp;amp; checkingAllowed==true &amp;amp;&amp;amp; turned50==true){&#xA;turnBack(); one second later this runs&#xA;}&#xA;if(timer-servoTimer&amp;gt;=1000 &amp;amp;&amp;amp; checkingAllowed==true &amp;amp;&amp;amp; backCheck==true){&#xA;  backCheck=false;//servo turns back to 90&#xA;  checkingAllowed = false;//allows the main code block to be called&#xA;}&#xA;&#xA;&#xA;delay(2);//small delay&#xA;}&#xA;&#xA;&#xA;void turnBack(){&#xA;random50 = random(0, 160);&#xA;servoTimer=millis();&#xA;servo.write(90);&#xA;backCheck = true;&#xA;turned50=false;&#xA;}&#xA;void turn50(){&#xA;turned130 = false;&#xA;random130  = random(0, 160);&#xA;servoTimer = millis();&#xA;servo.write(50);&#xA;turned50=true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It takes a while for the random number to be 1 or 0. I do not understand how 100% of the time, the servo executes the maneuver in the beginning. I will give any more information if you need it to aid me. The random() will soon be replaced by ping() of ultrasonic sensor. Then, the problem will probably disappear. I just want to be clear on what is happening here. &lt;/p&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2016-07-31T03:05:13.137" Title="Why does my servo execute an action in the beginning when the odds are almost 0?" Tags="|arduino-mega|programming|c++|servo|millis|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26894" PostTypeId="2" ParentId="26893" CreationDate="2016-07-31T03:05:13.137" Score="3" Body="&lt;p&gt;Recognise that, despite the name, &lt;code&gt;random()&lt;/code&gt; does not produce a &lt;em&gt;truly&lt;/em&gt; random number. Because a computer is basically determinate, every time &lt;code&gt;random()&lt;/code&gt; is called it produces results in a fixed sequence - it is possible that this sequence includes &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;1&lt;/code&gt; straight away.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want it to start at a different point, you need to &quot;seed&quot; the random number generator by calling &lt;code&gt;randomSeed()&lt;/code&gt; and passing in an integer. Note that it can't be the &lt;em&gt;same&lt;/em&gt; integer every time - that would just move the sequence to the same point every time. The &lt;a href=&quot;https://www.arduino.cc/en/Reference/Random&quot; rel=&quot;nofollow&quot;&gt;Arduino reference for &lt;code&gt;random()&lt;/code&gt;&lt;/a&gt; suggests reading an unconnected analog input with &lt;code&gt;analogRead()&lt;/code&gt; (which would produce different numbers at different instances in time) to &quot;seed&quot; the random number generator with a new starting position.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;randomSeed(analogRead(A0)); // Seed random() with random starting point&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-07-31T03:05:13.137" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26895" PostTypeId="2" ParentId="26888" CreationDate="2016-07-31T07:08:01.107" Score="0" Body="&lt;p&gt;I don't know what you are trying to do, because the link fails to display in my browser.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general there is no reason why you can not use a PNP transistor, providing you use appropriate polarities, and assuming common-emitter mode, reference to the +5V rail rather than Gnd.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Having said that, you would need some specific reason. In general NPN devices are cheaper and/or outperform PNP, all other things being equal.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-07-31T07:08:01.107" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26897" PostTypeId="2" ParentId="20935" CreationDate="2016-07-31T08:33:16.720" Score="1" Body="&lt;p&gt;Go to ICT's website to download the Installation manual (one used for many different models), there is info on the pinout for every pin on your model, along with recommended I/O interface circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using a different model, but from what I know, if your model is a &quot;Pulse&quot; model, which means that when a bill is accepted, there are pulses that you can captured (the pulse width is pre-set by toggle switches, and the number of pulses depends on the value of the bill).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I would do is to use interrupt to listen to these pulses. When the interrupt triggers, light up your LED.&lt;/p&gt;&#xA;" OwnerUserId="24362" LastEditorUserId="24362" LastEditDate="2016-07-31T09:11:34.923" LastActivityDate="2016-07-31T09:11:34.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26898" PostTypeId="1" AcceptedAnswerId="26899" CreationDate="2016-07-31T09:00:45.460" Score="2" ViewCount="2851" Body="&lt;p&gt;I am creating a simple shield with two i2c &lt;code&gt;MCP23017&lt;/code&gt; chips. Each &lt;code&gt;MCP23017&lt;/code&gt; has two interrupt pins, but the Arduino Uno only has two interrupt pins (&lt;code&gt;pin 2&lt;/code&gt; and &lt;code&gt;pin 3&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The way I understand it, interrupts are there to tell the Arduino something has changed, so it can then poll the &lt;code&gt;MCP23017&lt;/code&gt; for the latest pin reads.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I connect the 4 interrupt pins to my Arduinos 2 pins?&lt;/p&gt;&#xA;" OwnerUserId="10675" LastActivityDate="2016-07-31T10:34:04.807" Title="Using interrupts for two MCP23017" Tags="|arduino-uno|" AnswerCount="1" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="26899" PostTypeId="2" ParentId="26898" CreationDate="2016-07-31T10:34:04.807" Score="4" Body="&lt;p&gt;The MCP23017 (and it's sister the SPI-based MCP23S17) can have their interrupt pins set to &quot;mirror&quot; mode. In this mode both pins are internally joined so when an interrupt occurs on any port both pins activate.  This is done using the &lt;code&gt;MIRROR&lt;/code&gt; bit of the &lt;code&gt;IOCON&lt;/code&gt; register.  Using this will turn your 4 interrupt pins into just 2, one for each Arduino INT pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Should you want to add more in the future, or if you find you want to use one of the interrupt pins on the Arduino for something else, there is also the &lt;code&gt;ODR&lt;/code&gt; bit in the &lt;code&gt;IOCON&lt;/code&gt; register. This sets the interrupt pins to be &lt;em&gt;open drain&lt;/em&gt;, which means that all of them can be wired together into just one INT pin on the Arduino. Add a pullup (or enable the internal pullup) and you have have many IO expanders on one INT pin. Of course, that then means that you have to poll all the expanders to find which of them triggered the interrupt, so could slow things down somewhat depending on how you are using it.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-31T10:34:04.807" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26901" PostTypeId="2" ParentId="26888" CreationDate="2016-07-31T11:42:24.330" Score="1" Body="&lt;p&gt;Despite the fact that the circuit you have is completely wrong, there is one fundamental thing that is stopping you using a PNP transistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With an NPN transistor you have to raise the voltage on the base &lt;em&gt;above&lt;/em&gt; the ground voltage (this voltage is called &lt;em&gt;V_BE&lt;/em&gt;, the &lt;em&gt;V&lt;/em&gt;oltage between &lt;em&gt;B&lt;/em&gt;ase and &lt;em&gt;E&lt;/em&gt;mitter). Typically that voltage is around 0.7V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;With an PNP, because the emitter is wired to your 9V rail, &lt;em&gt;V_BE&lt;/em&gt; must therefore be relative to 9V, not ground, so the voltage on the base must be less than 0.7V &lt;em&gt;below&lt;/em&gt; 9V to turn on. Which in itself is fine - a LOW will be around 0V, which is about 9V less than 9V. So it will turn on. The problem comes when you want to turn it off. You need to get the base voltage &lt;em&gt;above&lt;/em&gt; 8.3V (9V - 0.7V), and that is impossible for an Arduino to do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So normally a PNP transistor is switched by using an NPN transistor to switch the base of the PNP between 9V (pulled up through a resistor) and 0V (switched through the NPN).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And that then becomes pretty much pointless, since you are then adding a second, NPN, transistor, and you could just as well use the NPN alone to switch the motor, making the PNP completely redundant.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-31T11:42:24.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26903" PostTypeId="2" ParentId="26881" CreationDate="2016-07-31T14:35:02.293" Score="1" Body="&lt;p&gt;this workes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (messageSize &amp;gt; 0) {&#xA;      //Serial.println(client.readString());&#xA;      String input = client.readString();&#xA;      Serial.println(input);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;looks like reading from the method readString() empties the buffer hence cant use it again, what I did is store it on a String object variable &quot;input&quot; and use that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It worked.&lt;/p&gt;&#xA;" OwnerUserId="11798" LastEditorUserId="11798" LastEditDate="2016-11-05T22:43:38.460" LastActivityDate="2016-11-05T22:43:38.460" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26906" PostTypeId="1" CreationDate="2016-07-31T16:16:26.263" Score="1" ViewCount="412" Body="&lt;p&gt;I have a problem I can't see to solve. I'm trying to program my Arduino, which I just got. I have read a lot of programming scenarios, but can't seem to find one that fits my problem. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can get the LED to turn off and on like I want. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Assume a switch is pressed or even two wires to the LED are put together. Once the switch is pressed I'd like the LED to flash briefly, even though the LED has power to it. Is there a way to do this with Arduino code? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(1) Press switch &#xA;(2) Flash LED briefly&#xA;(3) Switch is still being pressed&#xA;(4) LED remains off until switch is pressed again&#xA;(5) loop through routine again. &lt;/p&gt;&#xA;" OwnerUserId="24372" LastActivityDate="2016-08-01T23:11:25.620" Title="LED Strobe based on switch press through Arduino" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26907" PostTypeId="2" ParentId="25898" CreationDate="2016-07-31T16:38:15.000" Score="1" Body="&lt;p&gt;The HM-10 is a BLE-only device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Android phones do not normally transmit BLE advertisements, so there is normally nothing about an Android phone for it to discover.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The exception would be if you have software on a late Android version with the capability, which you have set up to intentionally transmit BLE advertisements, or else if software you put on your Android phone is actively responding to advertisements you had the HM-10 transmit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Essentially, you are expecting something that his not normal behavior, but will only be achieved by adding your software on &lt;em&gt;both&lt;/em&gt; devices.&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-07-31T16:38:15.000" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26908" PostTypeId="1" CreationDate="2016-07-31T16:58:32.160" Score="0" ViewCount="314" Body="&lt;p&gt;I want to create a simple electronic temperature sensor using the Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The environments I want it to handle is inside a fridge and near a heater.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although I am sure the Arduino can easily handle a heater; my issue is that the Arduino may not be able to handle a fridge. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A fridge also has the added problem of causing water vapor (and we all know water + electronics is never a good idea).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my question is:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;How would I create a temperature sensor using my Arduino Uno, that I can put in my fridge?&lt;/li&gt;&#xA;&lt;li&gt;Are there any other problems I have not considered and how do I solve them?&lt;/li&gt;&#xA;&lt;li&gt;Will I need a special type of casing? If so, which type?&lt;/li&gt;&#xA;&lt;li&gt;Is an Arduino Uno even the best tool for this task?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="24374" LastActivityDate="2016-07-31T20:32:50.250" Title="How to handle low temperatures using Arduino Uno?" Tags="|arduino-uno|temperature-sensor|safety|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26909" PostTypeId="1" CreationDate="2016-07-31T17:05:29.810" Score="0" ViewCount="701" Body="&lt;p&gt;I'm still new to Arduino Yún and I can't find any tutorials or examples on making the Yún send data through Ethernet, which will then be showed on a web server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've seen other tutorials but they use Uno with an Ethernet shield.  Is it the same with the Yún too?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I send data through Ethernet using Yún?&lt;/p&gt;&#xA;" OwnerUserId="20427" LastEditorUserId="4628" LastEditDate="2017-01-28T14:26:00.793" LastActivityDate="2017-01-28T14:26:00.793" Title="Using Arduino Yún to send data through Ethernet" Tags="|ethernet|arduino-yun|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26910" PostTypeId="2" ParentId="26888" CreationDate="2016-07-31T17:39:32.747" Score="1" Body="&lt;p&gt;When connecting together several circuits that have different supply&#xA;voltages, common practice is to make them all have a common negative&#xA;supply rail. This is called “&lt;em&gt;common ground&lt;/em&gt;”. As explained in Majenko’s&#xA;answer, you would need an NPN transistor for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to use a PNP instead, then you could forget the common&#xA;practice and do everything “backwads”: if you connect together the positive&#xA;ends of the power supplies, you will have a “common V&lt;sub&gt;CC&lt;/sub&gt;”&#xA;instead of a common ground. Relative to the Arduino ground, your&#xA;9&amp;nbsp;V battery will have one pole at +5&amp;nbsp;V and the other at&#xA;−4&amp;nbsp;V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The wiring is the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;connect the emitter to +5&amp;nbsp;V (Arduino +5 and battery +)&lt;/li&gt;&#xA;&lt;li&gt;connect the base to an Arduino output through a resistor&lt;/li&gt;&#xA;&lt;li&gt;connect the collector to the motor&lt;/li&gt;&#xA;&lt;li&gt;connect the other end of the motor to the battery −&lt;/li&gt;&#xA;&lt;li&gt;put a free wheeling diode in parallel with the motor.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: Below is an ASCII art rendering of the circuit. Beware that&#xA;the motor is ON when the Arduino output is LOW.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;+-----------+&#xA;|         5V|-----------------+-------------------+&#xA;|           |                 |                   |&#xA;|  Arduino  |                 |                   |&#xA;|           |    ,-----.  B |&amp;lt; E                 ___ +&#xA;|        D13|----|     |----|    PNP              _&#xA;+-----------+    `-----'    |\                   ___&#xA;                              |C                  _&#xA;                              |                  ___&#xA;                              +---------+         _&#xA;                              |         |        ___ 9 V batt.&#xA;                              |         |         _&#xA;                             ---        |        ___&#xA;                              ^       motor       _&#xA;                             / \        |        ___&#xA;                             ---        |         _  −&#xA;                              |         |         |&#xA;                              |         |         |&#xA;                              +---------+---------+&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-08-01T08:12:00.360" LastActivityDate="2016-08-01T08:12:00.360" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26911" PostTypeId="1" CreationDate="2016-07-31T17:49:25.107" Score="0" ViewCount="434" Body="&lt;p&gt;Please I'm working on a quadcopter, and I have to made my own flight controller based on arduino uno.&lt;br&gt;&#xA;First of all please how can I get a filtred angular velocity and linear acceleration from the MPU6050, is the following code give us the angular velocity in deg/sec and the linear velocity in m/s² ?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;accelgyro.getMotion6(&amp;amp;ax, &amp;amp;ay, &amp;amp;az, &amp;amp;gx, &amp;amp;gy, &amp;amp;gz);&lt;/code&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;and is this pid value in this following code is right ?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  accel_reading = ax;&#xA;  accel_corrected = accel_reading - accel_offset;&#xA;  accel_corrected = map(accel_corrected, -16800, 16800, -90, 90);&#xA;  accel_corrected = constrain(accel_corrected, -90, 90);&#xA;  accel_angle = (float)(accel_corrected * accel_scale);&#xA;&#xA;  err = angle_setpoint - accel_angle  ;&#xA;&#xA;  P = Kp * err ;&#xA;  I += (Ki * err) ;&#xA;  D = Kd * (err - errp);&#xA;&#xA;  pid = P + I + D;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="24375" LastEditorUserId="10794" LastEditDate="2016-08-01T05:17:54.107" LastActivityDate="2017-02-27T22:09:38.617" Title="How can I convert PID correction values to an PWM brushless command?" Tags="|arduino-uno|pwm|mpu6050|pid|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26912" PostTypeId="2" ParentId="26908" CreationDate="2016-07-31T18:10:31.147" Score="1" Body="&lt;p&gt;Your Arduino does not have to be in the fridge, just the sensor. You can always choose waterproof sensor &lt;a href=&quot;https://www.sparkfun.com/products/11050&quot; rel=&quot;nofollow noreferrer&quot;&gt;like this one&lt;/a&gt; to use with the arduino. Then you can always store your arduino outside the fridge. Same goes for the heater. Try to keep the arduino at room temperatures to avoid decreasing its life unnecessarily. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for an actual answer to the temperature ranges, &lt;a href=&quot;https://arduino.stackexchange.com/questions/633/how-cold-or-hot-can-my-arduino-uno-get&quot;&gt;here is a good answer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19375" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-07-31T18:10:31.147" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26915" PostTypeId="2" ParentId="26908" CreationDate="2016-07-31T20:32:50.250" Score="1" Body="&lt;p&gt;Humidity would be your biggest enemy. The fridge is a very moist environment for two reasons: &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The colder the air temperature, the less moisture it can hold overall, thus saturating more quickly and reaching a higher relative humidity.&lt;/li&gt;&#xA;&lt;li&gt;Lots of moist foodstuffs in an enclosed space.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You should be OK as long as the enclosure you choose has plenty of ventilation to avoid a temperature differential or trapping moisture.  Either of those two conditions could cause and even larger increase in humidity or, worse, condensate to form.&lt;/p&gt;&#xA;" OwnerUserId="24379" LastActivityDate="2016-07-31T20:32:50.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26917" PostTypeId="1" CreationDate="2016-07-31T21:23:17.877" Score="0" ViewCount="162" Body="&lt;p&gt;I am trying to run this code:&#xA;&lt;a href=&quot;https://github.com/miguelbalboa/rfid/blob/master/examples/ReadNUID/ReadNUID.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/miguelbalboa/rfid/blob/master/examples/ReadNUID/ReadNUID.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using an ESP8266 based D1 board and an RFID-RC522.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am not able to get it to detect the rfid tags ...&lt;br&gt;&#xA;the serial monitor just shows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; ets Jan  8 2013,rst cause:4, boot mode:(3,4)&#xA;&#xA;wdt reset&#xA;load 0x4010f000, len 1384, room 16 &#xA;tail 8&#xA;chksum 0x2d&#xA;csum 0x2d&#xA;v00000000&#xA;~ld&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &quot;Typical pin layout used&quot; section of the above document does not mention any connections on the 3.3V &amp;amp; GND pins of the RFID-RC522 card.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does this mean that I do not need to connect them?&lt;br&gt;&#xA;Or is is just so obvious that I should connect them that they did not bother to write it in that section?&lt;/p&gt;&#xA;" OwnerUserId="24342" LastEditorUserId="24342" LastEditDate="2016-08-01T07:19:54.920" LastActivityDate="2016-08-02T11:11:38.127" Title="do i need to also connect GND and 3.3v" Tags="|library|rfid|wires|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26922" PostTypeId="1" CreationDate="2016-07-31T23:19:17.637" Score="0" ViewCount="2013" Body="&lt;p&gt;I was reading through SparkFun's article on transistors when I came across something that confused me. The article showed this circuit:&lt;a href=&quot;https://i.stack.imgur.com/69TQu.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/69TQu.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;With this description:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Similar to the NPN circuit, the base is our input, and the emitter is tied to a constant voltage. This time however, the emitter is tied high, and the load is connected to the transistor on the ground side.&lt;/p&gt;&#xA;&lt;p&gt;This circuit works just as well as the NPN-based switch, but there’s one huge difference: to turn the load “on” the base must be low. This can cause complications, especially if the load’s high voltage (VCC in this picture) is higher than our control input’s high voltage. &lt;strong&gt;For example, this circuit wouldn’t work if you were trying to use a 5V-operating Arduino to switch on a 12V motor.&lt;/strong&gt; In that case it’d be impossible to turn the switch off because VB would always be less than VE.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I am confused because the part about the Arduino not being able to turn off a PNP transistor makes sense, but doesn't the circuit shown feature exactly the situation described that the transistor wouldn't work in? Is this an oversight by me and is there something else going on here that I don't understand, or is this a mistake in the article?&lt;/p&gt;&#xA;" OwnerUserId="16025" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-07-31T23:45:52.593" Title="Confusion about PNP transistors" Tags="|arduino-uno|electronics|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="26923" PostTypeId="2" ParentId="26922" CreationDate="2016-07-31T23:43:26.127" Score="2" Body="&lt;p&gt;The article is saying that the &lt;strong&gt;circuit wouldn't work&lt;/strong&gt;, thus it illustrates (correctly) something that won't work. What is the confusion?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To turn the PNP transistor off, the base voltage needs to be low &lt;em&gt;with reference to the emitter voltage&lt;/em&gt;. Thus with an emitter voltage of 12V, and the most the Arduino can output is 5V, the transistor will never be off.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-07-31T23:43:26.127" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26924" PostTypeId="2" ParentId="26917" CreationDate="2016-07-31T23:51:01.900" Score="4" Body="&lt;p&gt;It is just so obvious that you should connect them that they did not bother to write it down.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The reader needs power. That is taken as read. Without power it can do nothing. Why would they bother to waste time telling you to connect the things that you have to connect regardless? The only things that they tell you to connect are things that are specific to the sketch - i.e., which IO pins to connect to which function on the reader. Power doesn't change - it's the same from sketch to sketch and from person to person. The IO pins do, though, and need to be detailed. Power and ground don't.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-31T23:51:01.900" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26925" PostTypeId="2" ParentId="26909" CreationDate="2016-07-31T23:54:39.873" Score="1" Body="&lt;p&gt;There are three bits of information you need to know:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The Ethernet port is connected to a tiny Linux computer&lt;/li&gt;&#xA;&lt;li&gt;On Linux you can do HTTP POST and HTTP GET using a program called cURL&lt;/li&gt;&#xA;&lt;li&gt;The AVR chip can tell the Linux computer what to do using the &lt;code&gt;Process&lt;/code&gt; library.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Putting all those together: You need to use the &lt;code&gt;Process&lt;/code&gt; library to tell Linux to run &lt;code&gt;curl&lt;/code&gt; with the right parameters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just like the tutorials show you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Process&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/Process&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-07-31T23:54:39.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26927" PostTypeId="2" ParentId="26906" CreationDate="2016-08-01T01:57:43.430" Score="1" Body="&lt;p&gt;This is a modified Example program that i have tested and seems to do what you expect. I have used a 2 position switch instead of a button. using a pointer &quot;ledState&quot; to indicate that the LED has flashed and have then combined 2 conditions with the &quot;&amp;amp;&amp;amp;&quot; in the IF statement.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  Button&#xA;&#xA; Turns on and off a light emitting diode(LED) connected to digital&#xA; pin 13, when pressing a pushbutton attached to pin 2.&#xA;&#xA;&#xA; The circuit:&#xA; * LED attached from pin 13 to ground&#xA; * pushbutton attached to pin 2 from +5V&#xA; * 10K resistor attached to pin 2 from ground&#xA;&#xA; * Note: on most Arduinos there is already an LED on the board&#xA; attached to pin 13.&#xA;&#xA;&#xA; created 2005&#xA; by DojoDave &amp;lt;http://www.0j0.org&amp;gt;&#xA; modified 30 Aug 2011&#xA; by Tom Igoe&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; http://www.arduino.cc/en/Tutorial/Button&#xA; */&#xA;&#xA;// constants won't change. They're used here to&#xA;// set pin numbers:&#xA;const int buttonPin = 2;     // the number of the pushbutton pin&#xA;const int ledPin =  13;      // the number of the LED pin&#xA;&#xA;// variables will change:&#xA;int buttonState = 0;         // variable for reading the pushbutton status&#xA;int ledState = 0;&#xA;void setup() {&#xA;  // initialize the LED pin as an output:&#xA;  pinMode(ledPin, OUTPUT);&#xA;  // initialize the pushbutton pin as an input:&#xA;  pinMode(buttonPin, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read the state of the pushbutton value:&#xA;  buttonState = digitalRead(buttonPin);        &#xA;  // check if the pushbutton is pressed.&#xA;  // if it is, the buttonState is HIGH:&#xA;  if ((buttonState == HIGH)&amp;amp;&amp;amp;(ledState == 0)) {&#xA;    // Flash LED:&#xA;    ledState = 1;&#xA;    digitalWrite(ledPin, HIGH);&#xA;    delay(500);&#xA;    digitalWrite(ledPin, LOW);&#xA;    delay(500);&#xA;  } else if ((buttonState == LOW) &amp;amp;&amp;amp; (ledState == 1)){&#xA;    ledState = 0;&#xA;    delay(50);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23966" LastEditorUserId="23966" LastEditDate="2016-08-01T23:11:25.620" LastActivityDate="2016-08-01T23:11:25.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26930" PostTypeId="2" ParentId="26911" CreationDate="2016-08-01T04:56:23.380" Score="0" Body="&lt;p&gt;You convert PID outputs to process outputs by selecting appropriate Kp, Ki, and Kd constants -- they translate the error components into a process output.   For example, if you want 10 degrees of error to give you a full-scale analogWrite() adjustment, set Kp=255.0/10.   Ki and Kd will depend on the (unspecified) sampling interval.  If the measurements are noisy, you can use the Ki term to do some filtering work, but if you filter it prior to the PID, it will reduce the performance of the PID.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Code-wise, you are missing some sort of&lt;code&gt;errp=err;&lt;/code&gt; code, you need more than acceleration in the x direction to calculate an angle, (atan2(az,ax) or some such, depending on orientation), and your PID scheme doesn't protect against common problems like out-of-range, integral windup, or inconsistent sampling interval.   You should investigate the &lt;a href=&quot;http://playground.arduino.cc/Code/PIDLibrary&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Code/PIDLibrary&lt;/a&gt; for a more robust implementation than you've half-coded above.&lt;/p&gt;&#xA;" OwnerUserId="6628" LastActivityDate="2016-08-01T04:56:23.380" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26931" PostTypeId="2" ParentId="20860" CreationDate="2016-08-01T08:20:38.700" Score="1" Body="&lt;p&gt;Should be possible, but only if you setup the Bluetooth module of Arduino 2 as the master. You see, Bluetooth requires to connect to a master. A master can connect to 8 slaves in total. Because Arduino 2 connects to multiple devices (Arduino 1 and your Android device) it should be the master. This also means your Android device cannot connect to any other devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this gives you a place to start exploring.&lt;/p&gt;&#xA;" OwnerUserId="23788" LastActivityDate="2016-08-01T08:20:38.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26935" PostTypeId="1" CreationDate="2016-08-01T10:32:12.447" Score="0" ViewCount="1491" Body="&lt;p&gt;When I am using RF 433 MHz module with ARDUINO MEGA then it is transmitting any text or anything in ASCII values. Now how to decode those ASCII values to alphabets? If I use ASCII conversion programme then what if I send a number and that conversion program converts that number also to text or related ASCII character? please suggest any way.&lt;/p&gt;&#xA;" OwnerUserId="24255" LastActivityDate="2016-08-01T12:29:36.410" Title="Arduino - RF 433 Mhz transmitting string and but receiving ASCII values of those characters" Tags="|arduino-mega|rf|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26937" PostTypeId="1" CreationDate="2016-08-01T11:02:48.060" Score="-1" ViewCount="104" Body="&lt;p&gt;I have 2 Stepper Motors (QMot stepper motor1 Amp, 5.3Ohms, 5.3 volts and 200 steps/rev.)&#xA;, which are connected to the Adafruit shield2.4, they are mounted to Arduino Mega, the motors pull generally 2 A from external current from Adafruit. My problem is, they don´t rotate smoothly, clearly and fast at the same time.&#xA;When I use DOUBLE to define my Stepps, speed is ok but rotation is lout and shaking. When I use MICROSTEP is more smoothly but too much slow. The program is running two stepper motors to roll up optical cables. The cables have to be really precisely come together and accurately be installed on pulley. &#xA;Also I need a solution to run my Steppers Motors smoothly, clearly and fast.&#xA;Incidentally, I want to know, do I need BigEasyDriver for that? &#xA; If you need more info oder fotos feel free to ask&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Paria&lt;/p&gt;&#xA;" OwnerUserId="24395" LastActivityDate="2016-08-01T16:32:10.643" Title="Steppermotor+Arduino Mega+ Adafruit" Tags="|arduino-mega|adafruit|stepper|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="26939" PostTypeId="2" ParentId="26935" CreationDate="2016-08-01T12:29:36.410" Score="2" Body="&lt;p&gt;Lokesh, to expand on what Majenko said when you transmit something over this sort of link you are transmitting either a 1 or a 0.  When 8 ones or zeros arrive you have a byte.  A byte has a value of between 0 and 255 and what this means is entirely up to the 'protocol' you are using.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In your case your sending program is sending a letter, lets say A.  Now the A that you are sending is held in memory as a byte with the value of 65, 65 is the ASCII [code] for A. So 65 is sent as 8 different transmissions to the other end of the link and is received, built back into a byte and your program receives a byte with the value of 65.  Your receiver program is using the same protocol as your transmitter program, so it 'knows' you don't meant the number 65, the colour green or an elephant riding a bicycle, you mean the character A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To show that A you might need to cast the data you receive to a character i.e. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned char rxData = 0;&#xA;Radio.ReceiveData (&amp;amp;rxData, 1);&#xA;Serial.println((char)rxData);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-01T12:29:36.410" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26940" PostTypeId="2" ParentId="26073" CreationDate="2016-08-01T14:28:00.200" Score="0" Body="&lt;p&gt;In my applications, the biggest power drain is turning on the radio to transmit data. I often keep the radio off, collect data points, and then turn on the radio to send multiple pieces of data together as one request using a RESTful HTTP call. For my case, RESTful HTTP is way more efficient since I do not need an always on connection.&lt;/p&gt;&#xA;" OwnerUserId="21598" LastActivityDate="2016-08-01T14:28:00.200" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26945" PostTypeId="2" ParentId="26937" CreationDate="2016-08-01T16:32:10.643" Score="3" Body="&lt;p&gt;I'd look for a proper stepper driver, e.g. something based on A4988 or similar. I wasted a fair amount of time on the Adafruit motor-shield 2.3 until I finally abandoned it after failing to achieve higher speeds (I also had lots of issues with the motor getting hot). The A4988 takes care of step sequencing including micro-stepping and interfacing and programming is very simple. It only comes in surface-mount packaging but there are bread-board friendly carriers costing a few dollars available from multiple manufacturers.&lt;/p&gt;&#xA;" OwnerUserId="24400" LastActivityDate="2016-08-01T16:32:10.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26946" PostTypeId="1" AcceptedAnswerId="26947" CreationDate="2016-08-01T16:34:28.117" Score="3" ViewCount="1614" Body="&lt;p&gt;When I want to write a literal string in Python, I use &lt;code&gt;r&lt;/code&gt; before the string (or &lt;code&gt;@&lt;/code&gt; in C#):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;in [1]: print r'\no esca\pe ch\ara\cters'&#xA;out [1]: \no esca\pe ch\ara\cters&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In straight c++ I can use &lt;code&gt;R&lt;/code&gt;, but in the Arduino IDE, this throws the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;Serial.println(R&quot;\no esca\pe ch\ara\cters&quot;);&#xA;&#xA;&amp;lt;output&amp;gt; invalid character '\'in raw string delimiter&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So how do I do the same in Arduino c++?&lt;/p&gt;&#xA;" OwnerUserId="8570" LastEditorUserId="8570" LastEditDate="2016-08-01T16:44:57.873" LastActivityDate="2016-08-01T16:59:38.987" Title="Declaring literal strings" Tags="|c++|string|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26947" PostTypeId="2" ParentId="26946" CreationDate="2016-08-01T16:59:38.987" Score="3" Body="&lt;p&gt;Raw strings in C++11 must have parens within the quotes in order to allow for a custom delimiter. Since your string lacks those parens, it is not valid.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(R&quot;(\no esca\pe ch\ara\cters)&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-01T16:59:38.987" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26952" PostTypeId="2" ParentId="23159" CreationDate="2016-08-02T03:33:48.233" Score="0" Body="&lt;p&gt;I believe that CTS would be fairly easy to implement:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  uint8_t clear_to_send = digitalRead(CTS);&#xA;  volatile char data;&#xA;  if (clear_to_send) {&#xA;    Serial.write(data);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I'm not sure about RTS.&lt;/p&gt;&#xA;" OwnerUserId="24144" LastActivityDate="2016-08-02T03:33:48.233" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26953" PostTypeId="1" AcceptedAnswerId="28040" CreationDate="2016-08-02T07:04:26.973" Score="3" ViewCount="209" Body="&lt;p&gt;I am trying to use the inbuilt ADC of the Arduino Due to measure voltage signals. The frequency range I'm interested in measuring is  up to about 30 kHz.But I'm observing a strong capacitor behaviour as I increase the frequency ( from 10kHz onwards this is quite visible). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is most visible when measuring a square wave. When I get close to 30 kHz the signal looks exactly like the text book capacitor charge/discharge wave and nothing like a square wave. Even at around 15 kHz, the square wave looks more like a sine wave/ ramp signal than a square wave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Based on the behaviour my guess is that a capacitor in the Arduino Due ADC is causing this (as  the frequency increases, the capacitor cannot charge/discharge fast enough). But I'm not sure whether I'm correct about this.&#xA;Even if I'm correct, how can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have screenshots for the behaviour for a range of frequencies, but I will attach a hand drawing of what it looks like.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kRmY2.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kRmY2.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also NOTE that As the frequency increases, the amplitude of the observed wave decreases ( I couldn't show this in my drawing). Think this again links back to the capacitor charge/discharge speed behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Vin circuit : I tested by adding a voltage follower at the right most end(not shown on the schematic), but that made no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/v4474.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/v4474.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24416" LastEditorUserId="24416" LastEditDate="2016-08-03T03:05:20.297" LastActivityDate="2016-08-04T16:06:23.573" Title="Arduino Due - using built in ADC as a DSO causes issues at high frequencies (kHz)" Tags="|arduino-due|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26955" PostTypeId="2" ParentId="26953" CreationDate="2016-08-02T08:02:27.010" Score="1" Body="&lt;p&gt;Well, if you have source output impedance about 1k and Sample-And-Hold capacitance is 14pF, then RC time constant is about 14us.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need something with low output impedance. Non-inverting Voltage Follower would be perfect for this (see &lt;a href=&quot;http://www.electronics-tutorials.ws/opamp/opamp_3.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;source&lt;/a&gt;):&lt;br/&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/uOr8k.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/uOr8k.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-02T08:02:27.010" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="26961" PostTypeId="1" AcceptedAnswerId="26963" CreationDate="2016-08-02T12:03:34.460" Score="1" ViewCount="237" Body="&lt;p&gt;I have read through a number of posts including &lt;a href=&quot;https://arduino.stackexchange.com/questions/1013/how-do-i-split-an-incoming-string/1237&quot;&gt;How do I split an incoming string?&lt;/a&gt; However I cannot work out how to extract numbers from a serial string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My challenge is this;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I send a serial command 'freq\r' to a radio which will return a string like this 'FREQ: 10138.7 RX, INHIBIT TX'. The only thing I want out of this is the 1013 so I can then manipulate it and send out a second serial port. It sounds easy enough but I just don't seem to be able to extract those numbers easily because I don't have a separator to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other thing is if the number is below 10 e.g. 9138 I only want to extract the first 3 numbers then add a leading 0 so I end up with 0913.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Once I have the four numbers I can then divide them so I end up with e.g. 09 and 13 or 10 and 13. I can then send these as HEX to my second serial device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are wondering what the numbers are they are frequencies in kHz which I am extracting from a radio then converting to HEX to tune a pre-selector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be greatly appreciated as this is my last stumbling block on this serial translator project. I hope this makes sense.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Callum&lt;/p&gt;&#xA;" OwnerUserId="24427" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-08-02T12:50:52.667" Title="How do I read numbers from a serial sequence" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26963" PostTypeId="2" ParentId="26961" CreationDate="2016-08-02T12:50:52.667" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I don't have a separator to use&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You do. There is a space before the integer part of the frequency, and a&#xA;decimal point just after it. You can use &lt;code&gt;strchr()&lt;/code&gt; to find them. Then,&#xA;you will have to prepend a zero if needed, and terminate the string one&#xA;character before the decimal point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following code does this by overwriting the original string. If you&#xA;need to keep that string, you will instead have to copy the relevant&#xA;characters to another buffer:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;char * get_freq(char *message)&#xA;{&#xA;    char *space = strchr(message, ' ');&#xA;    char *dot   = strchr(message, '.');&#xA;&#xA;    if (!space || !dot || dot - space &amp;lt; 5)&#xA;        return NULL;    // invalid message&#xA;&#xA;    if (dot - space == 5)&#xA;        *space = '0';   // prepend a zero&#xA;&#xA;    *(dot - 1) = '\0';  // terminate the string&#xA;&#xA;    return dot - 5;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-02T12:50:52.667" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26964" PostTypeId="1" AcceptedAnswerId="26971" CreationDate="2016-08-02T13:23:50.620" Score="1" ViewCount="197" Body="&lt;p&gt;I need to purchase the correct bluetooth module for interfacing some simple functionality between an arduino and a motor. The tricky bit is getting the bluetooth radio to play nice with android and apple ios. There are things like MIT App Inventor, but I'd love to hear from someone with experience how to reliably control arduino from tablets/phones. Preferrably in a way that lets me define the control on the arduino. I can build android apps (slowly), not ios apps, but I would then have to either ask users to install untrusted apks or get it out through the google app store, which would take too long. Any help on this would be great.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-09-01T16:30:45.273" Title="Bluetooth radio control of a motor" Tags="|c++|motor|bluetooth|arduino-nano|shields|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26966" PostTypeId="1" AcceptedAnswerId="26970" CreationDate="2016-08-02T14:42:07.957" Score="3" ViewCount="7526" Body="&lt;p&gt;everybody!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a genuine Arduino Micro (&quot;designed with adafruit&quot;, made in Italy) which is working perfectly well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing I'd like to do but cannot figure out how (or at all), is to turn off the blue power LED. I hate blue LEDs, they hurt my eyes, and this one is particularly bright too. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I could just paint it over with black paint but maybe there are programmatic ways to switch it off?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards﻿&lt;/p&gt;&#xA;" OwnerUserId="24434" LastActivityDate="2016-08-02T15:19:45.180" Title="Arduino Micro: how to switch off its blue power LED?" Tags="|power|led|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26967" PostTypeId="1" CreationDate="2016-08-02T14:59:13.620" Score="6" ViewCount="503" Body="&lt;p&gt;I'm trying to interface with a master I2C device that doesn't exactly follow the normal I2C protocol.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only difference really is in the read request. A &quot;normal&quot; I2C read operation looks like this ([M]aster, [S]lave):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S | SLA+R | ACK | Data | Ack | Data ...some number of bytes... Nack | P&#xA;^M  ^M      ^S    ^S     ^M    ^S                              ^M     ^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this device expects to do a read like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;S | SLA+R | ACK | Data | Ack | Data | Ack | Data | Ack | P&#xA;^M  ^M      ^S    ^M     ^S    ^S     ^M    ^S     ^M    ^M&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Essentially a read request goes to the slave device, and then the master sends an 8-bit register address, and then the master expects 2 data bytes back from the slave with the Master responding with an ACK on both.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've been able to set up a master device to do this style of protocol pretty easily by just manipulating the I2C registers directly. But I can't seem to find a way to get the slave device to accept that it is going to receive a data byte after it has been selected by a SLA+R, which leads to a bus contention problem and the slave not giving the master an ACK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this possible to do with the built in I2C hardware on the Atmel chips? Is there any alternative if it can't (bit-banging)?&lt;/p&gt;&#xA;" OwnerUserId="24436" LastActivityDate="2017-07-01T12:53:03.237" Title="Arduino as a custom I2C slave device" Tags="|i2c|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26968" PostTypeId="2" ParentId="26966" CreationDate="2016-08-02T15:14:05.837" Score="2" Body="&lt;p&gt;Unfortunately the blue LED is a direct connection between 5V and GND. You can see below in the schematic exactly how it is connected&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/wDAiW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wDAiW.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to 'turn off' the LED would be to remove either the 1K resistor or LED with a soldering iron.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility is to take a sharp knife and make a cut in the track directly before or after the LED. I've marked the locations where to cut on the eagle screenshot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/68fO6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/68fO6.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19785" LastEditorUserId="19785" LastEditDate="2016-08-02T15:19:45.180" LastActivityDate="2016-08-02T15:19:45.180" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26969" PostTypeId="2" ParentId="26966" CreationDate="2016-08-02T15:15:12.177" Score="2" Body="&lt;p&gt;There is not way to turn it off in software.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only thing you can do is desolder the led, or it's resistor. Just add some solder to the joints on both sides. Then angle the iron, so it touches both side. The led/resistor will tend to get loose and stick to the iron. Cleanup the board, by removing the excess solder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tend to just destroy the led using a utility knife. Just try to lift the &quot;glass&quot; on top of the led with a bit of force. Scrape over the white remains to make sure there isn't any connection left.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-02T15:15:12.177" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26970" PostTypeId="2" ParentId="26966" CreationDate="2016-08-02T15:16:14.280" Score="2" Body="&lt;p&gt;The Blue LED is permanently connected to +5 volts through R5. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to either remove R5 or the LED from the circuit board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CeyeJ.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CeyeJ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6945" LastActivityDate="2016-08-02T15:16:14.280" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26971" PostTypeId="2" ParentId="26964" CreationDate="2016-08-02T15:35:51.953" Score="2" Body="&lt;p&gt;You may want to have a look at the Adafruit BLE modules:&#xA;&lt;a href=&quot;https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/bleuart?view=all&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend/bleuart?view=all&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They have provided great examples of how to connect from Android and iOS devices, as well as providing apps or code to integrate into your own apps and you get to implement the motor controller code yourself on the Arduino so should have full control over that side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They even have an example where they are controlling a motor using an Arduino and Bluetooth, it may not be exactly what you need but hopefully gets you closer to an answer:&#xA;&lt;a href=&quot;https://learn.adafruit.com/bluetooth-motorized-camera-slider/overview?view=all&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/bluetooth-motorized-camera-slider/overview?view=all&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24440" LastActivityDate="2016-08-02T15:35:51.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26972" PostTypeId="1" CreationDate="2016-08-02T15:58:22.863" Score="0" ViewCount="1254" Body="&lt;p&gt;I have a Nano (clone) that I am powering from a regulated supply via the 5V pin; I have checked this at the board and my multimeter reads 4.92V, which seems close enough (?). The main reason I don't use the microUSB jack is a space constraint. In any case, thus far it does work fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Except&lt;/em&gt; the leftmost (considered with the microUSB jack as &quot;top&quot;) of the four onboard LEDs, on the opposite side from the rx/tx lights, blinks at a steady one second interval.  Searching around, the only association I've found for that LED is that it is connected to D13, which I'm not using for anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What does this indicate?  I have not tried disabling it (by setting 13 low) but I am hoping to do so if it is a benign issue.&lt;/p&gt;&#xA;" OwnerUserId="16150" LastActivityDate="2016-08-02T18:04:48.260" Title="Nano onboard &quot;test&quot; LED blinks when powered via 5V pin" Tags="|power|arduino-nano|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26974" PostTypeId="1" CreationDate="2016-08-02T16:36:07.770" Score="0" ViewCount="1757" Body="&lt;p&gt;I have the setup described here: &lt;a href=&quot;https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/wiring&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/wiring&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I currently have the reset pin set to float and the GPIO0 pin grounded, which should make it execute the uploaded program, but instead I get the flash mode output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    writing flash&#xA;...................................................................................................................................................................................................................................................&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How do I put it into execution mode?&lt;/p&gt;&#xA;" OwnerUserId="23248" LastActivityDate="2019-12-10T04:05:50.727" Title="ESP8266 stuck in flash mode?" Tags="|arduino-ide|esp8266|flash|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="26975" PostTypeId="2" ParentId="26312" CreationDate="2016-08-02T17:07:13.407" Score="1" Body="&lt;p&gt;The problem I see is the Arduino 101 uses an Intel microprocessor (Curie) instead of an Atmel microprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only information I could find is on the &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoard101&quot; rel=&quot;nofollow&quot;&gt;Arduino page for the 101&lt;/a&gt;, which mentions it has dedicated pins for I2C, but it also says that you can use the Wire library. Maybe you just need to update your IDE?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd help more, but I can't seem to find any useful information on the Curie...&lt;/p&gt;&#xA;" OwnerUserId="24436" LastActivityDate="2016-08-02T17:07:13.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26976" PostTypeId="2" ParentId="26312" CreationDate="2016-08-02T17:46:50.883" Score="0" Body="&lt;p&gt;Although I did not manage to get wire communication to work, I was able to get the Arduinos to communicate through serial port. You just need to ensure to use Serial1 rather than Serial.&lt;/p&gt;&#xA;" OwnerUserId="23875" LastEditorUserId="4628" LastEditDate="2017-03-31T05:06:15.080" LastActivityDate="2017-03-31T05:06:15.080" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26977" PostTypeId="2" ParentId="26972" CreationDate="2016-08-02T18:04:48.260" Score="1" Body="&lt;p&gt;So, as per the comments on the question here's what I think happened:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That &quot;test&quot; LED lights briefly when the board is first powered on, indicating I suppose that it's booted and &lt;code&gt;setup()&lt;/code&gt; is either complete or about to run.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It also lights briefly when the reset button is released.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the sketch I'm using one of the digital pins is connected to RST -- the arduino is being controlled via UART.  I have swapped some of the pin numbers and wiring around, so I tried leaving the one driving RST low instead of high and indeed, this seems to be the issue: It's resetting at ~1s intervals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(I honestly believe I checked this before by removing all connections, but since I did not note that in the question, perhaps I never did...)&lt;/p&gt;&#xA;" OwnerUserId="16150" LastActivityDate="2016-08-02T18:04:48.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26978" PostTypeId="2" ParentId="501" CreationDate="2016-08-02T18:33:53.783" Score="1" Body="&lt;p&gt;You could take a piece of 2 conductor wire in a U shape that is weighted at the bottom of the &quot;U&quot; to rest at the bottom of the tank.  (The reason to use a U shaped wire instead of a straight wire is to prevent having to insulate one end from the water).  You would then measure the capacitance of the wire, where some baseline capacitance is the wire when dry and any wire that is wet would increase the capacitance proportional to the length that is wet.  Any wire that is rated for outdoor operation, i.e. does not absorb water would do and actually the thicker the jacket the better as the baseline capacitance would be lower.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The capacitance could be measured in the same way as a capacitive touch sensor or a capacitance to frequency converter (Sometimes called an &quot;Oscillator&quot;).&lt;/p&gt;&#xA;" OwnerUserId="10147" LastActivityDate="2016-08-02T18:33:53.783" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26979" PostTypeId="1" AcceptedAnswerId="28044" CreationDate="2016-08-02T18:55:30.800" Score="0" ViewCount="192" Body="&lt;p&gt;I'm trying to detect light using an led that's already attached to the circuit. I have a flashlight shining on the led.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Minimal sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while( true )&#xA;{&#xA;    int photoValue = 0;&#xA;    analogReference(INTERNAL);&#xA;    photoValue = analogRead(A5);&#xA;&#xA;    Serial.println(photoValue);&#xA;&#xA;    delay(300);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I have my multimeter attached, it reads a pretty constant value around 5mV. The serial output however swings around, as seen in this sample output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;0&#xA;4&#xA;4&#xA;0&#xA;16&#xA;15&#xA;22&#xA;21&#xA;25&#xA;20&#xA;36&#xA;40&#xA;34&#xA;36&#xA;24&#xA;5&#xA;0&#xA;3&#xA;6&#xA;0&#xA;0&#xA;0&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That would translate to values between 0 and 43mV.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I disconnect the multimeter only get &lt;code&gt;1023&lt;/code&gt; printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't get how the values from the ADC and the multimeter, totally don't match.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-04T19:12:09.447" Title="analogRead values all over the place, while measuring light" Tags="|adc|analogreference|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="26982" PostTypeId="1" AcceptedAnswerId="26985" CreationDate="2016-08-02T23:44:07.000" Score="2" ViewCount="586" Body="&lt;p&gt;I'm building a GPS tracker using an arduino nano, Adafruit Ultimate GPS breakout, a SD card slot and a SIM800L module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So far everything works, the tracker uploads the data to a server as well as saving an extra copy to the SD card. The problem is now, that I don't really think that sending a HTTP request every cycle (gps data point) is very efficient and I would also like to have a way of storing information if there is no GPRS reception.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The idea is to save the GPS data to SD card and bulk send it out every 5 minutes or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the best way to set up the data structure? I'm saving the deta in a csv style file:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;2016-8-2 22:23:44, 52.53251922, 13.31121666, 18.30, 7, 1.33;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Parsing that is not the problem, but rather how to keep track of what has been sent already and what not. I was thinking about Marking the lines that I sent with a # or something similar as first character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only problem I could see with that would be performance, since it could take a while to go though it every time once it's getting a bit larger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lukas&lt;/p&gt;&#xA;" OwnerUserId="24444" LastActivityDate="2016-08-03T11:33:37.237" Title="How to structure data for HTTP upload" Tags="|sd-card|gps|datalogging|http|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26985" PostTypeId="2" ParentId="26982" CreationDate="2016-08-03T00:49:02.347" Score="1" Body="&lt;p&gt;The only alternative structure I can think of is, since you have a number of data fields to send, you could create a struct to contain all the fields. Write the gathered GPS data to the file in its raw format, with &lt;code&gt;file.write(&amp;amp;your_struct, sizeof(your_struct))&lt;/code&gt; and read in a similar manner into a struct. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;This will reduce the number of bytes written or read for any data point, and &lt;/li&gt;&#xA;&lt;li&gt;Reduce the overall size of the file, compared to your original method, for the same number of GPS points. &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The former improvement means there will be about 3 times as many GPS data points in a single block of data read from or written to the SD card, when compared to your current structure. Another more subtle advantage is that each data point occupies a known number of bytes in the file, making file navigation potentially easier. But you can only use this structure if you don't intend to view the CSV file with some spreadsheet program like MS Excel. You could, of course, very easily write your own PC program to parse the file and write to proper CSV. The Python &lt;code&gt;struct&lt;/code&gt; module is very capable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, if you wish to continue with your current format, you can keep track of your current position in the file with &lt;code&gt;file.position()&lt;/code&gt;; no need to use # as an indicator. You create 2 position variables, one to hold the position of the next line to be uploaded, &lt;code&gt;curr_pos&lt;/code&gt;, and the other to hold the position of the end of the file for writing new data, &lt;code&gt;end_pos&lt;/code&gt;. Initialize the former to 0.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;You gather data as usual, and after 5 mins, you save the current file position to &lt;code&gt;end_pos&lt;/code&gt; and seek to &lt;code&gt;curr_pos&lt;/code&gt; with &lt;code&gt;file.seek()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You read a line from the file and send it to the server. &lt;/li&gt;&#xA;&lt;li&gt;If it's sent successfully (use the return code), you update &lt;code&gt;curr_pos&lt;/code&gt; with &lt;code&gt;file.position()&lt;/code&gt; so that it's now pointing to the next line in the file to be uploaded and go to step 2. &lt;/li&gt;&#xA;&lt;li&gt;Else if the upload fails perhaps due to service, you stop uploading and &lt;em&gt;don't&lt;/em&gt; update &lt;code&gt;curr_pos&lt;/code&gt;. You seek to &lt;code&gt;end_pos&lt;/code&gt; with &lt;code&gt;file.seek()&lt;/code&gt; and go to step 1.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;You will, of course, use &lt;code&gt;available()&lt;/code&gt; to know when you've hit the end of the file to stop uploading, or you can compare &lt;code&gt;curr_pos&lt;/code&gt; with &lt;code&gt;end_pos&lt;/code&gt; for equality, whichever's more direct for you.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This involves a lot of operations on the file and I/O operations don't come cheap with SD cards, both in terms of current drawn and latency. Depending on how often you collect data and if you don't need to view it on a PC, you might consider some other means of storage (SPI flash, perhaps) or use a more capable Arduino like the Mega with more RAM and store the data temporarily in an array before upload, granting you faster access by orders of magnitude and much reduced power drain in the long term, since each block of file data will be accessed only once.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastEditorUserId="11763" LastEditDate="2016-08-03T11:33:37.237" LastActivityDate="2016-08-03T11:33:37.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26991" PostTypeId="1" CreationDate="2016-08-03T03:20:39.050" Score="0" ViewCount="642" Body="&lt;p&gt;Can arduino generate the frequency with the resolution of 2 decimal places? &#xA;i.e. 100.12 Hz, 98.23Hz, 1.92Hz...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;recently I need to generate a frequency to allow a stepper motor to move accordingly. But to ensure the stepper motor to functions normally, frequency must be generated , and it must be of 2 decimal places. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can Arduino do that? Or is there any specific product that may generate frequency resolution as such?&lt;/p&gt;&#xA;" OwnerUserId="24447" LastActivityDate="2016-08-04T07:56:15.593" Title="Frequency generator" Tags="|pwm|frequency|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="26992" PostTypeId="2" ParentId="26774" CreationDate="2016-08-03T05:56:58.750" Score="0" Body="&lt;p&gt;Hello Guys i found the issue. Serial.read() function reads only 62bytes. After i have update the serial buffer size in library file C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.H ... It shows the messages which is stored in serial buffer.&lt;/p&gt;&#xA;" OwnerUserId="23686" LastActivityDate="2016-08-03T05:56:58.750" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26993" PostTypeId="2" ParentId="26991" CreationDate="2016-08-03T06:46:49.153" Score="1" Body="&lt;p&gt;The standard Arduino Uno is clocked at a nominal 16MHz, and has three timers: Timer0, 1 and 2. Timer1 uses a 16 bit counter (the others are 8 bit), and can be prescaled by 1, 8, 64, 256 and 1024. That lets you do &lt;em&gt;very&lt;/em&gt; precise timings (assuming an accurate clock!), simply by choosing different prescaler values and the relevant values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using your example rates, and assuming that you want a square wave (hence the &quot;Halved&quot; column), here are the calculations:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Hertz Prescaler  Calculated      Halved  Actual Hz&#xA;100.12         8  19976.02876548   9,988  100.120144173...&#xA; 98.23         8  20360.3787      10,180   98.231827112...&#xA;  1.92       256  32552.08333333  16,276    1.9200049...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that to do this, you need to program the Timer yourself - the standard Arduino library sets Timer1 to a default setting, which won't do what you want.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-08-03T06:46:49.153" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="26994" PostTypeId="1" CreationDate="2016-08-03T08:08:44.923" Score="0" ViewCount="1007" Body="&lt;p&gt;I will be running my CNC Via Arduino UNO R3, so i have found out that it runs on GRBL and that i need to load Python and Pyserial and a graphic interface.&#xA;Loaded Python 3.5.2, no problems, opened dos window typed Python, got the python &gt;&gt;&gt; prompt, so far so good, downloaded/unzipped/copy/paste Pyserial  into c:/python35/lib/site-packages/pyserial.&#xA;at this point, at the dos prompt i type &gt;&gt;&gt;python setup.py install. All i get is a syntax error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have included the dos script for comment&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Microsoft Windows [Version 6.1.7601]&#xA;Copyright (c) 2009 Microsoft Corporation.  All rights reserved.&#xA;&#xA;C:\Users\Goblin&amp;gt;python&#xA;Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (In&#xA;tel)] on win32&#xA;Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.&#xA;&#xA;&amp;gt;&amp;gt;&amp;gt; import os&#xA;&amp;gt;&amp;gt;&amp;gt; os.getcwd()&#xA;'C:\\Users\\Goblin'&#xA;&amp;gt;&amp;gt;&amp;gt; os.chdir(&quot;/users/&quot;)&#xA;&amp;gt;&amp;gt;&amp;gt; os.getcwd()&#xA;'C:\\users'&#xA;&amp;gt;&amp;gt;&amp;gt; os.chdir(&quot;/../&quot;)&#xA;&amp;gt;&amp;gt;&amp;gt; os.getcwd()&#xA;'C:\\'&#xA;&amp;gt;&amp;gt;&amp;gt; os.chdir(&quot;/python35/lib/site-packages/pyserial/&quot;)&#xA;&amp;gt;&amp;gt;&amp;gt; os.getcwd()&#xA;'C:\\python35\\lib\\site-packages\\pyserial'&#xA;&amp;gt;&amp;gt;&amp;gt; python setup.py install&#xA;  File &quot;&amp;lt;stdin&amp;gt;&quot;, line 1&#xA;    python setup.py install&#xA;               ^&#xA;SyntaxError: invalid syntax&#xA;&amp;gt;&amp;gt;&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is about the 7th attempt.&#xA;I seem to be following the instruction correctly but it wont install ....HELP Please, this is so frustrating, what have I done wrong.&#xA;Thanks in advance&#xA;Doug&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-04T07:40:28.737" Title="Installing Pyserial" Tags="|arduino-uno|programming|python|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="26997" PostTypeId="2" ParentId="26994" CreationDate="2016-08-03T09:12:17.017" Score="2" Body="&lt;p&gt;not exactly related to Arduino but here it goes...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First check if you have pip installed:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip --version&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;if not installed&lt;/strong&gt; go &lt;a href=&quot;https://pip.pypa.io/en/stable/installing/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and download the get-pip script.&#xA;then on directory where you saved get-pip run on console:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python get-pip.py&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this will install pip into your system which makes installation of packages in python way more easy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if installed but not latest version ( at momment 8.1.2) do an upgrade before:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On Linux or OS X:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install -U pip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On Windows:&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python -m pip install -U pip&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after install pyserial using pip:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pip install pyserial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Did it work?&lt;/strong&gt; &#xA;If not, try:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python -m pip install pyserial&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;if it still doesn't work&lt;/strong&gt; install from source. Get the latest version &lt;a href=&quot;https://pypi.python.org/pypi/pyserial&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; extract it and in the dir where you extrated run:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python setup.py install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;PS: change to dir first, no need to do it inside python.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-08-03T09:12:17.017" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26998" PostTypeId="1" AcceptedAnswerId="27002" CreationDate="2016-08-03T09:16:20.340" Score="0" ViewCount="654" Body="&lt;p&gt;I have a SIM900 GPRS/GSM Shield (&lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;details here&lt;/a&gt;) and I am looking to stack a GPS shield (&lt;a href=&quot;https://www.adafruit.com/product/1272&quot; rel=&quot;nofollow&quot;&gt;such as this one here&lt;/a&gt;). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: I believe that they both require software serial, also it says to use software serial on D7 and D8 for both. Is this possible on an Uno?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a bit confused at if software serial has to have these two specific pins, or if these are just what is chosen on schematics?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be the most effective way to stack these two shields so they don't interfere with each other?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Using a gps shield such as &lt;a href=&quot;https://www.sparkfun.com/products/13750&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; gives the option  of &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you need to move the software serial port pins, they can be custom-routed to any other pin by cutting the solder jumpers between pins GPS-RX and D8 and/or GPS-TX and D9.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This isn't entirely clear to me, but am I right in thinking it means I can have multiple software serials on my Uno, just using different pins?&lt;/p&gt;&#xA;" OwnerUserId="12166" LastEditorUserId="12166" LastEditDate="2016-08-03T09:36:00.417" LastActivityDate="2016-08-03T10:30:08.217" Title="Software Serial and multiple shields for Arduino Uno" Tags="|shields|gsm|pins|gps|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="26999" PostTypeId="1" AcceptedAnswerId="27001" CreationDate="2016-08-03T09:26:12.490" Score="0" ViewCount="3935" Body="&lt;p&gt;Can I know a code for simple IR receiver. I using external trasmitter, and when the receiver (on arduino board) get the input (detect signal from transmitter), LED will be HIGH.&lt;/p&gt;&#xA;" OwnerUserId="24310" LastEditorUserId="24310" LastEditDate="2016-08-03T12:39:33.787" LastActivityDate="2016-08-03T19:07:54.170" Title="Simple IR Receiver code" Tags="|ir|" AnswerCount="2" CommentCount="1" ClosedDate="2016-08-09T04:03:03.593" ContentLicense="CC BY-SA 3.0" />
  <row Id="27000" PostTypeId="2" ParentId="26994" CreationDate="2016-08-03T09:40:21.703" Score="2" Body="&lt;p&gt;I'm pretty sure that what you are trying to do is actually call 'python setup.py' within the python script itself. Which you cannot do. The easiest way to install pyserial is via pip like so. (Windows)&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python -m -U pyserial --upgrade &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now if you still want to use setup.py or you don't have pip installed. Make sure that you meet all of the package dependencies. Which in pyserial there are no others. Try exiting out of the python interpreter and just running&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;python setup.py install&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the same folder location as the extracted zip (use cd to change directories) &lt;/p&gt;&#xA;" OwnerUserId="24452" LastActivityDate="2016-08-03T09:40:21.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27001" PostTypeId="2" ParentId="26999" CreationDate="2016-08-03T09:58:30.010" Score="1" Body="&lt;p&gt;Here is a library that might be able to help you out: &lt;a href=&quot;https://github.com/cyborg5/IRLib/&quot; rel=&quot;nofollow&quot;&gt;https://github.com/cyborg5/IRLib/&lt;/a&gt;. Also a specific example of controlling a server from a sony remote control. &lt;a href=&quot;https://github.com/cyborg5/IRLib/blob/master/examples/IRservo/IRservo.ino&quot; rel=&quot;nofollow&quot;&gt;https://github.com/cyborg5/IRLib/blob/master/examples/IRservo/IRservo.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am slightly confused on what you mean 'get input'. So I am assuming an input from a button. Here is some pseudo code compiled from the IRservo example that might point you in the right direction.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRLib.h&amp;gt;&#xA;&#xA;#define MY_PROTOCOL SONY&#xA;#define BUTTON_0 0x90bca  //LED ON&#xA;#define BUTTON_1 0x00bca  //LED OFF&#xA;&#xA;#define LED_PIN 13 //Pin to LED&#xA;&#xA;IRrecv My_Receiver(11);//Receive on pin 11&#xA;IRdecode My_Decoder;&#xA;&#xA;void setup() { //Code to run once&#xA;  My_Receiver.No_Output();//Turn off any unused IR LED output circuit&#xA;  My_Receiver.enableIRIn(); // Start the receiver&#xA;&#xA;  pinMode(LED_PIN, OUTPUT); //Set LED 13 to out&#xA;  digitalWrite(LED_PIN, LOW); //Start off in the off position&#xA;}&#xA;&#xA;void loop() { //Code that runs forever&#xA;    if (My_Receiver.GetResults(&amp;amp;My_Decoder)) {&#xA;       My_Decoder.decode(); //Convert the values into types&#xA;       if(My_Decoder.decode_type==MY_PROTOCOL) { // Match the controller&#xA;          switch(My_Decoder.value) {&#xA;            case BUTTON_0:      digitalWrite(LED_PIN, HIGH); break; //Turn the LED on&#xA;            case BUTTON_1:      digitalWrite(LED_PIN, LOW); break; //Turn the LED off&#xA;          }&#xA;       }&#xA;     My_Receiver.resume(); //Wait for next input&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This should theoretically work, but has never been tested. Now if you are just wanting any result to turn on the LED you might be able to do this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() { //Code that runs forever&#xA;    if (My_Receiver.GetResults(&amp;amp;My_Decoder)) {&#xA;        My_Decoder.decode();&#xA;        digitalWrite(LED_PIN, HIGH); //Turn the LED on&#xA;    }&#xA;    My_Receiver.resume(); //Wait for next input&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sample from getting text (Different library) from the receiver and printing it to the Serial Monitor. Link to library: &lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;https://github.com/z3t0/Arduino-IRremote&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;IRremote.h&amp;gt; //Link: https://github.com/z3t0/Arduino-IRremote&#xA;&#xA;#define IR_PIN = 11; //The data pin to the IR recv&#xA;#define LED_DATA = 13; //Either the builtin LED or plug one in&#xA;&#xA;IRrecv irrecv(IR_PIN); //Start recv obj&#xA;decode_results results;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600); //Start Serial at 9600 baud&#xA;  pinMode(LED_DATA, OUTPUT); //Set LED pin to out&#xA;  digitalWrite(LED_DATA, LOW); //Start recv data view pin in low&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results)) {&#xA;    //We have recieved something... lets print it and turn on the LED&#xA;    digitalWrite(LED_DATA, HIGH);&#xA;    Serial.println(results.value, HEX); //Send line in ascii hex format&#xA;    delay(200); //Make the LED visible&#xA;    digitalWrite(LED_DATA, LOW); //Turn off data led&#xA;    irrecv.resume(); // Receive the next value&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit #2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since an image has been provided I believe this is what you want. To turn the ir data into a visible light... To do that is a little more tricky in just doing code. Here's an example that doesn't require any external libraries and will do what you want.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;avr/interrupt.h&amp;gt;&#xA;#include &amp;lt;avr/io.h&amp;gt;&#xA;&#xA;#define TIMER_RESET  TCNT1 = 0&#xA;#define SAMPLE_SIZE  64&#xA;#defome LED_PIN 13&#xA;&#xA;int IRpin = 2;&#xA;unsigned int TimerValue[SAMPLE_SIZE];&#xA;char direction[SAMPLE_SIZE];&#xA;byte change_count;&#xA;long time;&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial.println(&quot;Analyze IR Remote&quot;);&#xA;  TCCR1A = 0x00;          // COM1A1=0, COM1A0=0 =&amp;gt; Disconnect Pin OC1 from Timer/Counter 1 -- PWM11=0,PWM10=0 =&amp;gt; PWM Operation disabled&#xA;  // ICNC1=0 =&amp;gt; Capture Noise Canceler disabled -- ICES1=0 =&amp;gt; Input Capture Edge Select (not used) -- CTC1=0 =&amp;gt; Clear Timer/Counter 1 on Compare/Match&#xA;  // CS12=0 CS11=1 CS10=1 =&amp;gt; Set prescaler to clock/64&#xA;  TCCR1B = 0x03;          // 16MHz clock with prescaler means TCNT1 increments every 4uS&#xA;  // ICIE1=0 =&amp;gt; Timer/Counter 1, Input Capture Interrupt Enable -- OCIE1A=0 =&amp;gt; Output Compare A Match Interrupt Enable -- OCIE1B=0 =&amp;gt; Output Compare B Match Interrupt Enable&#xA;  // TOIE1=0 =&amp;gt; Timer 1 Overflow Interrupt Enable&#xA;  TIMSK1 = 0x00;&#xA;  pinMode(IRpin, INPUT);&#xA;  pinMode(LED_PIN, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  Serial.println(&quot;Waiting...&quot;);&#xA;  change_count = 0;&#xA;  while(digitalRead(IRpin) == HIGH) {}&#xA;  TIMER_RESET;&#xA;  TimerValue[change_count] = TCNT1;&#xA;  direction[change_count++] = '0';&#xA;  while (change_count &amp;lt; SAMPLE_SIZE) {&#xA;    if (direction[change_count-1] == '0') {&#xA;      while(digitalRead(IRpin) == LOW) {}&#xA;      TimerValue[change_count] = TCNT1;&#xA;      direction[change_count++] = '1';&#xA;      digitalWrite(LED_PIN, LOW);&#xA;    } else {&#xA;      while(digitalRead(IRpin) == HIGH) {}&#xA;      TimerValue[change_count] = TCNT1;&#xA;      direction[change_count++] = '0';&#xA;      digitalWrite(LED_PIN, HIGH);&#xA;    }&#xA;  }&#xA;  Serial.println(&quot;Bit stream detected!&quot;);&#xA;  change_count = 0;&#xA;  time = (long) TimerValue[change_count] * 4;&#xA;  digitalWrite(LED_PIN, LOW)&#xA;  Serial.print(time);&#xA;  Serial.print(&quot;\t&quot;);&#xA;  Serial.println(direction[change_count++]);&#xA;  while (change_count &amp;lt; SAMPLE_SIZE) {&#xA;    time = (long) TimerValue[change_count] * 4;&#xA;    Serial.print(time);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.println(direction[change_count-1]);&#xA;    Serial.print(time);&#xA;    Serial.print(&quot;\t&quot;);&#xA;    Serial.println(direction[change_count++]);&#xA;  }&#xA;  Serial.println(&quot;Bit stream end!&quot;);&#xA;  delay(2000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you want a non code example check out the answer below. It is a great solution. Without needing any arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;best regards, David&lt;/p&gt;&#xA;" OwnerUserId="24452" LastEditorUserId="24452" LastEditDate="2016-08-03T19:07:54.170" LastActivityDate="2016-08-03T19:07:54.170" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="27002" PostTypeId="2" ParentId="26998" CreationDate="2016-08-03T10:30:08.217" Score="0" Body="&lt;p&gt;SoftwareSerial can use any pins. That's the whole point of it. However, some shields are wired to use specific pins. If two shields try and use the same pins then you can't use them together. Not stacked, anyway. You will have to use flying leads, or physically alter the shield (cutting tracks, soldering in &quot;bodge&quot; wires) to use them together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That said, though, you can only use ONE SoftwareSerial port reliably at a time. That means, regardless of what pins they use, you can't use two shields together that require pins other than 0 and 1 (hardware serial). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To use them both you will need a board with multiple hardware UART ports and modify the shields (as mentioned above) to use the correct pins for those UART ports.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-03T10:30:08.217" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="27004" PostTypeId="2" ParentId="26999" CreationDate="2016-08-03T13:17:16.623" Score="0" Body="&lt;p&gt;I know you want code.  However your question is how to light up an LED when an external remote control is transmitting.  This can be done with the following hardware:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Many ASK sensors integrate an IR photo sensor, AGC &amp;amp; PLL into a 3 pin package that has an appearance of a transistor.  Supply power and get back a signal when an ASK IR transmitter is detected.  Check the current capabilities of the ASK receiver, you might have to add a transistor to drive an LED.  No Arduino needed for detection. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an example found on the web:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/fR8Ku.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/fR8Ku.gif&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-08-03T13:17:16.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27005" PostTypeId="1" AcceptedAnswerId="27006" CreationDate="2016-08-03T13:58:54.720" Score="-1" ViewCount="695" Body="&lt;p&gt;I am doing code for IR sensor. My problem is when I put this code (below) for buzzer, there will be error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:536: multiple definition of `__vector_7'&#xA;IRremote\IRremote.cpp.o:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C:\Program Files\Arduino\libraries\IRremote/IRremote.cpp:312: first defined here&#xA;collect2: error: ld returned 1 exit status&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  tone(buzzer, 4000); // Send 1KHz sound signal...&#xA;  delay(500);        // ...for 1 sec&#xA;  noTone(buzzer);     // Stop sound...&#xA;  delay(500);        // ...for 1sec&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24310" LastEditorUserId="24310" LastEditDate="2016-08-03T14:05:18.773" LastActivityDate="2016-08-03T14:39:12.403" Title="Error when using buzzer and IR sensor" Tags="|ir|buzzer|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27006" PostTypeId="2" ParentId="27005" CreationDate="2016-08-03T14:39:12.403" Score="2" Body="&lt;p&gt;Both the IRRemote library and the tone command use the same timer. You can't use them both together without modifying one of them to use a different timer. And that means looking at the source code for them both.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-03T14:39:12.403" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="27007" PostTypeId="2" ParentId="26991" CreationDate="2016-08-03T15:05:40.060" Score="1" Body="&lt;p&gt;I happened to do a similar analysis for Timer 1 on 328 / 32U4 clocked at 16MHz the other day and produced this plot:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CqQQY.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CqQQY.png&quot; alt=&quot;Timer 1 Frequency Error Bound&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shows the frequency resolution as a proportion of frequency in red assuming optimal prescaling (the jumps are where prescale changes). The blue markers are realized frequency errors at frequencies drawn at the E12 series in magnitudes from 0 to 5. Unsurprisinly these are half or better than the resolution.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a conclusion, you get a relative error of around 5e-5 for frequencies up to about 1kHz. After that you loose an order of magnitude per order of magnitude (which of course makes perfect sense).&lt;/p&gt;&#xA;" OwnerUserId="24400" LastActivityDate="2016-08-03T15:05:40.060" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27009" PostTypeId="1" AcceptedAnswerId="27011" CreationDate="2016-08-03T19:56:20.607" Score="1" ViewCount="2451" Body="&lt;p&gt;I am sending a HTTP Request to my WiFi module &lt;code&gt;http://192.168.4.1/STA/ID=HelloWorld/Pass=Testin123&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I parse above string in Arduino. First I need to check for &lt;code&gt;STA&lt;/code&gt;, if it exists, continue to scan the string. Put Value of &lt;code&gt;ID&lt;/code&gt;, in this case &lt;code&gt;HelloWorld&lt;/code&gt; should be store in String data type &lt;code&gt;SSID&lt;/code&gt; and Value of &lt;code&gt;Pass&lt;/code&gt;, in this case &lt;code&gt;Testin123&lt;/code&gt; should be store in String data type &lt;code&gt;Pass&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can achieve above using ARDUINO code! Please help.&lt;/p&gt;&#xA;" OwnerUserId="23271" LastActivityDate="2016-08-07T21:37:46.770" Title="Parse HTTP Request Arduino" Tags="|arduino-ide|esp8266|string|http|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="27010" PostTypeId="2" ParentId="26873" CreationDate="2016-08-03T21:31:08.587" Score="0" Body="&lt;p&gt;I found a solution myself.&#xA;The modules are working as they are supposed to and are not faulty.&#xA;Also I did nothing wrong.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Problem are my development machines. Mac mini (Late 2009) and MacBookPro (Mid 2009), both having a Broadcom 2046 Bluetooth host chip. I used those to connect via Bluetooth and open a tty session using &lt;code&gt;minicom&lt;/code&gt;. Running macOS and using &quot;Hardware IO Tools&quot; to log Bluetooth packets I saw that there was clearly nothing coming in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that I turned over to my Windows and used &lt;a href=&quot;https://sourceforge.net/projects/hypeterminal/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Hype! Terminal&lt;/a&gt;. Everything worked!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I went to my Raspberry Pi and Linux. After pairing using &lt;code&gt;bluetoothctl&lt;/code&gt; and issuing a few commands from &lt;a href=&quot;https://raspberrypi.stackexchange.com/questions/9119/bluetooth-as-ttyusb/9127#9127&quot;&gt;Bluetooth as ttyUSB&lt;/a&gt;. Everything worked as well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I tried &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.shenyaocn.android.BlueSPP&quot; rel=&quot;nofollow noreferrer&quot;&gt;BlueSPP&lt;/a&gt; on an Andriod phone. And again, it worked as it was supposed to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So my conclusion is that there is some sort of incompatibility between the SPP-C module and the Broadcom 2046 host controller.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastEditorUserId="-1" LastEditDate="2017-04-13T12:56:28.377" LastActivityDate="2016-08-03T21:31:08.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27011" PostTypeId="2" ParentId="27009" CreationDate="2016-08-03T21:44:27.313" Score="4" Body="&lt;p&gt;Your incoming string, as Gerben has mentioned, will actually be more like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;GET /STA/ID=HelloWorld/Pass=Testin123 HTTP/1.1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My personal preferred method is to use &lt;code&gt;strtok()&lt;/code&gt; to split the string up.  I'd use a two-pass method for this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First split the string up into three parts - one GET, one the request, and the third the request type (though you don't need to use that for anything).  Assume the string is in C string &lt;code&gt;incoming&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *get = strtok(incoming, &quot; &quot;);&#xA;char *request = strtok(NULL, &quot; &quot;);&#xA;char *rtype = strtok(NULL, &quot; &quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The request is now pointed to by the &lt;code&gt;*request&lt;/code&gt; pointer and the string has been sliced up in-place.  So now you can do something similar with the request, this time splitting on &lt;code&gt;/&lt;/code&gt; instead of space:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String SSID;&#xA;String Pass;&#xA;&#xA;if (request != NULL) {&#xA;    char *part = strtok(request, &quot;/&quot;);&#xA;&#xA;    bool seenSTA = false;&#xA;    while (part) { // While there is a section to process...&#xA;&#xA;        if (seenSTA) {&#xA;            if (!strncmp(part, &quot;ID=&quot;, 3)) { // We have the ID&#xA;                SSID = String(part + 3);&#xA;            } else if (!strncmp(part, &quot;Pass=&quot;, 5)) { // We have the password&#xA;                Pass = String(part + 5);&#xA;            }&#xA;        } else if (!strcmp(part, &quot;STA&quot;)) { &#xA;            seenSTA = true;&#xA;        }&#xA;&#xA;        part = strtok(NULL, &quot;/&quot;);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-07T21:37:46.770" LastActivityDate="2016-08-07T21:37:46.770" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="27012" PostTypeId="1" AcceptedAnswerId="28117" CreationDate="2016-08-03T22:29:06.880" Score="0" ViewCount="919" Body="&lt;p&gt;I have a Teensy 3.2 and the &lt;a href=&quot;https://www.pjrc.com/store/teensy3_audio.html&quot; rel=&quot;nofollow&quot;&gt;Teensy audio board&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was going to connect lavalier microphone to its audio jack but learned that it's only for output.&#xA;There are line-in pins though (see &quot;Back Side&quot; scheme). And MIC+GND pins, but these are for, ehm, radio parts microphones, I guess?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Being a complete novice I have no idea how to connect microphone jack (or audio connector) to line-in pins and whether I would need an amplifier between microphone and pins. If so then probably I just can't do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would be grateful for detailed instructions.&lt;/p&gt;&#xA;" OwnerUserId="23977" LastActivityDate="2016-08-06T20:19:03.250" Title="Connecting external mic to the Teensy" Tags="|teensy|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27013" PostTypeId="2" ParentId="362" CreationDate="2016-08-03T22:44:44.217" Score="6" Body="&lt;p&gt;Since this question was first asked, there is now the Arduino Library Manager, built into the Arduino IDE. There you can search for and install libraries.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is information about how the library manager works here:&#xA;&lt;a href=&quot;https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ&quot; rel=&quot;noreferrer&quot;&gt;https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There isn't however an official website listing the libraries, so I recently created this unofficial site, based on the same data in the Arduino Library Manager:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.arduinolibraries.info/&quot; rel=&quot;noreferrer&quot;&gt;http://www.arduinolibraries.info/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24470" LastActivityDate="2016-08-03T22:44:44.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27014" PostTypeId="2" ParentId="981" CreationDate="2016-08-03T22:51:13.560" Score="2" Body="&lt;p&gt;I have been working on an IPv6 library for Arduino, called EtherSia, that works with the ENC28J60 chip, but with a lower overhead compared with libraries that use Contiki / uIP. It is comparable to the EtherCard library for IPv4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/njh/ethersia&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/njh/ethersia&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While the Wiznet chips do not support IPv6 natively, they do have a MACRAW mode that allows you to send Layer 2 Ethernet frames directly. I have managed to get IPv6 working with the Wiznet W5100 and W5500 chips, which is what the official Arduino Ethernet Shield and Ethernet Shield 2 use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it is possible...&lt;/p&gt;&#xA;" OwnerUserId="24470" LastEditorUserId="24470" LastEditDate="2017-01-11T10:16:21.683" LastActivityDate="2017-01-11T10:16:21.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27015" PostTypeId="1" AcceptedAnswerId="27017" CreationDate="2016-08-03T22:31:29.873" Score="4" ViewCount="9442" Body="&lt;p&gt;On an Arduino 101, I have this code running:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{    &#xA; pinMode(2, INPUT); &#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;int counter = 0;&#xA;&#xA;void loop()&#xA;{ &#xA; Serial.print(millis()/1000);&#xA; Serial.print(&quot;\t&quot;);&#xA; Serial.print(counter);&#xA; Serial.print(&quot;\t&quot;);&#xA; Serial.println(digitalRead(2));&#xA; counter++; &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A wire can be used to jump Pin2 between 3.3V and GND. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When running with the Serial Monitor on, I see the values increment at a rate where counter increases by the hundreds very quickly and steadily ticks through the thousands over time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I close Serial Monitor momentarily and re-open it, I notice that this counter value has increased dramatically (by the tens-of-thousands).  Another sign of this is when starting the program and waiting a moment to start the Serial Monitor.  As the Arduino 101 does not restart when the Serial Monitor is opened, I see a large initial value in the tens of thousands despite having just started the program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is this: is the Serial library operating synchronously or asynchronously? I was led to believe that it was asynchronous; however, if that was the case, why should the Arduino execute any slower when the serial monitor is on? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;While I understand that increasing baud rate will increase the speed at which counter increases, I still see the same dramatic increase in this code when the monitor is closed and then re-opened.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another possibility I thought of was that maybe counter was being stored in a buffer and what I was seeing was not an up-to-date time or count.  To check this, the program prints the digitalRead value of pin2 as I swap the jumper between 3.3v and GND. This change in value was reflected instantaneously on the Serial Monitor, and I believe this means I am not seeing past data slowly being printed out to the monitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One last attempt at understanding what was going on was executing this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;{    &#xA; pinMode(2, INPUT); &#xA; Serial.begin(9600);&#xA;}&#xA;&#xA;int counter = 0;&#xA;&#xA;void loop()&#xA;{ &#xA;counter++;&#xA;if (counter%1000==0)&#xA; {&#xA;  Serial.println(counter);&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In this example, counter can be seen ticking through quite fast, by the hundreds of thousands, which indicates that the program is capable of running very quickly until a print statement is made. The effect is notably less when baud rate is increased to something like 115200 but is that saying that baud rate is literally slowing the processing speed of the controller? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any kind of explanation as to what exactly is going on would be very appreciated. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank You for your Time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Source of Arduino being supposedly Asynchronous:&#xA;&lt;a href=&quot;https://itp.nyu.edu/physcomp/lessons/serial-communication/serial-communication-the-basics/&quot; rel=&quot;nofollow&quot;&gt;https://itp.nyu.edu/physcomp/lessons/serial-communication/serial-communication-the-basics/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25497" OwnerDisplayName="Cablenot" LastActivityDate="2016-08-03T23:31:03.880" Title="Arduino Serial library (Synchronous or Asynchronous?)" Tags="|serial|communication|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="27016" PostTypeId="2" ParentId="27015" CreationDate="2016-08-03T23:03:03.333" Score="0" Body="&lt;p&gt;The Universal asynchronous receiver/transmitter (UART) is a chip that control the actual wires for serial communication. The UART operates independently and asynchronously. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I know the UART (or USART) has a buffer, and the serial.print* functions will write to this buffer, and if it is full will block until the buffer has room. The UART will consume the buffer and transmit it over the wire. So your code will run full speed until the buffer is full then it will have to wait for the UART to make space.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... but is that saying that baud rate is literally slowing the processing speed of the controller?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;When the UART's buffer becomes full, the Serial API has no choice but to wait for the buffer to empty so it can fill it again. This makes it appear as if the code is running synchronously; waiting on the buffer is essentially acting as a synchronization device. So yes a slow baud rate can slow the micro-controller down since the code is forced to wait for the UART even though it is asynchronous!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You may not notice any of the above effects, since even 9600, a relatively slow rate, is much faster than humans can read. 300 baud is approximately the rate at which humans can read comfortlably. If you repeat your experiments with a higher baud rate you should see the text fly past on the serial monitor much faster than at 9600; if you lower the speed to 300 (the lowest supported by the library) you should be able to read along, and see that things do go slower. The buffer on the UART is rather small, and even when slowing down to 300 baud, it might be difficult to see the buffering behavior.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When the serial monitor is closed the serial communications are still happening, the UART on the receiving side is receiving the data, but it gets dropped on the floor since no one is reading it. If you were to disconnect the serial wires at some point this should stall the sending UART which should cause the serial.print* functions to block (alternatively the UART could be configured to drop the data if it can't physically transmit it over the wire.)&lt;/p&gt;&#xA;" OwnerUserId="20533" OwnerDisplayName="esoterik" LastActivityDate="2016-08-03T23:09:24.553" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="27017" PostTypeId="2" ParentId="27015" CreationDate="2016-08-03T23:19:28.843" Score="6" Body="&lt;p&gt;The Arduno 101 doesn't communicate to the PC using a UART. It uses CDC/ACM over USB, which &lt;em&gt;looks&lt;/em&gt; like a UART to the PC.  But it isn't.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB sends packets of data, not individual characters&lt;/li&gt;&#xA;&lt;li&gt;It only sends if there is something to receive it at the other end&lt;/li&gt;&#xA;&lt;li&gt;There is no such thing as &lt;em&gt;baud rate&lt;/em&gt; with USB.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Basically, when the CDC/ACM port has been opened by an application (e.g., the serial monitor) the Arduino 101 starts to send the data down the line. When the port is closed all data to be sent gets silently dropped by the Arduino since there is nowhere to send it to.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence when the port is closed it runs much faster since the data that would normally have to be packed into packets and sent down USB isn't. It's just thrown away.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To address your confusion:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are misunderstanding the concept of synchronous and asynchronous with regards to serial. There are basically two types of serial communication: Asynchronous, where both ends have to (pretty precisely) agree on the speed of communication (baud rate), and synchronous, where one end tells the other end what the speed is by providing a discrete clock signal. UART (RS-232, RS-485, etc) is asynchronous. It sends at a specific rate and has to rigidly stick to that rate for the other end to be able to receive it properly.  SPI and I2C are synchronous - they both (as master) provide a clock signal to the receiving end (slave) and the receiver &lt;em&gt;synchronises&lt;/em&gt; its reading and writing of data with that clock signal (hence &lt;em&gt;synchronous&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are confusing those concepts with another meaning of synchronous and asynchronous - terms that could better be used would be &lt;em&gt;parallel&lt;/em&gt; and &lt;em&gt;sequential processing&lt;/em&gt;. If something happens &lt;em&gt;in parallel&lt;/em&gt; then two (or more) things happen at once. This is the case of the hardware UART where you submit characters to be sent to the buffer and they get transmitted out by the hardware separately to the sketch - in parallel. Sequential would mean that one thing has to happen after the other. If the UART behaved like that your program would stall every time you wanted to send a single character. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So UART processing happens in the background, in &lt;em&gt;parallel&lt;/em&gt; to your sketch. So does USB data processing for CDC/ACM. These things are generally coupled with interrupts to allow the CPU to handle tasks such as placing more data in the buffer or storing data that has arrived somewhere that you can get to it.  Interrupts aren't strictly parallel, in that they do stall your program while they run, but they are kind of in a different thread, or &lt;em&gt;context&lt;/em&gt;. So they appear to be parallel. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-03T23:31:03.880" LastActivityDate="2016-08-03T23:31:03.880" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28018" PostTypeId="1" CreationDate="2016-08-04T01:48:36.143" Score="1" ViewCount="2724" Body="&lt;p&gt;I have 2 Arduinos communicating with each other. My problem is that one sends packets every 1.5-2 seconds but the other Arduino does sensor reading and data uploading with a Wifi module, which may take up to 5 seconds until the next time the nRF24L01+ is available to receive data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This results in about 4 packet losses and if I am lucky sometimes 2. Is there any way that when the nRF24L01+ sends data, the other Arduino stops everything to get the data? Like a communication between these two Arduinos that will be open 24/7, so that the other Arduino can multitask (reading sensors and upload the data through wifi).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the code from this &lt;a href=&quot;https://www.youtube.com/watch?v=D40cgHyBLL4&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt;. Here is a my problem in an image (I hope this helps you understand it). Thanks in advance. &lt;a href=&quot;https://i.stack.imgur.com/oz1os.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oz1os.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15847" LastEditorUserId="4628" LastEditDate="2017-07-31T09:19:21.517" LastActivityDate="2023-03-12T01:54:30.827" Title="nRF24L01+ packet loss caused by Arduino reading and communicating with sensors" Tags="|arduino-uno|communication|nrf24l01+|rf|datalogging|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28021" PostTypeId="1" AcceptedAnswerId="28026" CreationDate="2016-08-04T05:09:51.623" Score="1" ViewCount="5112" Body="&lt;p&gt;Can I know how to change or connect from this circuit (three pin IR receiver) to two pin IR receiver because when I change the connection (3 pin to double pin), my arduino cannot receive the signal from transmitter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I dont know because of my connection or because of there are different between tree and double pin IR receiver. Can anyone help me.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code too long, so I just paste IR sensor for detect signal from transmitter.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;{&#xA;  indicator();&#xA;  irrecv.resume();&#xA;  while(1)  //-------loop M1&#xA;  {&#xA;      HM_1();  &#xA;      if(irrecv.decode(&amp;amp;results) &amp;gt;0 || digitalRead(SBB) == HIGH )&#xA;      // if IR receiver detect signal or button pressed&#xA;      {&#xA;         indicator();&#xA;         break;&#xA;        //irrecv.resume();&#xA;      }//&#xA;      else&#xA;      {    //-------else &quot;if(sensor 2)&quot;&#xA;          //go back to else &quot;if(sensor 1)&quot; &#xA;      }//-------else &quot;if(sensor 2)&quot; end&#xA;      //nothing&#xA;    }//-------while end&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/aMd94.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/aMd94.jpg&quot; alt=&quot;double pin&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/PCHh4.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/PCHh4.gif&quot; alt=&quot;IR connection&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24310" LastEditorUserId="10394" LastEditDate="2016-08-04T12:07:17.757" LastActivityDate="2016-08-04T12:07:17.757" Title="IR basic connection" Tags="|ir|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28024" PostTypeId="2" ParentId="26994" CreationDate="2016-08-04T07:40:28.737" Score="0" Body="&lt;p&gt;Thanks All...by running the command at a std DOS prompt I was able to install the Pyserial.py file.&#xA;i have since seen comments that some of the 3.x.x series Python has glitches,(I am running Windows7). I have gone to 2.7 Python as a program i would like to use doesn't appear to run under 3.x.x   bCNC likes the earlier versions, not sure why, but it does run under 2.7  . for those interested JCNC, EFL CNC, Grbl Controller seem to run OK under 3.x.x&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-04T07:40:28.737" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28025" PostTypeId="2" ParentId="26991" CreationDate="2016-08-04T07:56:15.593" Score="1" Body="&lt;p&gt;The other answers about the way you can configure the timers are very good, but Edgar Bonet's comment goes to the heart of the matter. Do you need accuracy?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your example of 98.23Hz suggests that you want 98.23Hz and not 98.22Hz or 98.24Hz. That means therefore that you require an accuracy of around 1 in 10000 (0.01%).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Can arduino generate the frequency ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You haven't said &lt;em&gt;which&lt;/em&gt; Arduino, but assuming one of the basic models, like the Uno, they come with a &lt;em&gt;resonator&lt;/em&gt; which will have an accuracy of around 1%.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the system clock is only good for 1% accuracy there isn't much point worrying about trying to get a frequency within 0.01%.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-04T07:56:15.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28026" PostTypeId="2" ParentId="28021" CreationDate="2016-08-04T08:08:51.047" Score="3" Body="&lt;p&gt;From what you have described, i think you are getting confused between the function of the two types. The 3 leg style is designed to receive coded pulses from remote controls (TV,Video, etc) where as the 2 leg is typically used, but not limited to, IR switching, where a signal is generated when the light path between the sender and receiver is broken with an opaque blade or similar or a beam is reflected back from an object as it passes. So trying to use the same code for the two types is provably where you are having problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Two example of this are &lt;a href=&quot;http://www.ebay.com.au/itm/Car-Sensor-Obstacle-for-Arduino-IR-Infrared-Avoidance-Robot-NEW-Smart-Module-/331917171309?hash=item4d47ce1a6d:g:~5AAAOSwIgNXlAVO&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; this uses a reflected IR beam where as &lt;a href=&quot;http://www.instructables.com/id/low-cost-air-flow-sensor/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; slot sensor is the break a beam type, often used in a limit or timing situation. One half of this is similar to the 2 leg diode you show.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It just depends on what situation you are using it in as to which is appropriate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Without seeing your code, this is about as far as i can go, post your code so the forum can view it and make suggestions.&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-04T08:08:51.047" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28029" PostTypeId="2" ParentId="28018" CreationDate="2016-08-04T09:34:48.703" Score="1" Body="&lt;p&gt;You need to re-factor your program somewhat (I would imagine).  The nRF needs to be read &lt;em&gt;at the same time&lt;/em&gt; as doing other things. That means interleaving it with your other operations.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a concept called a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow&quot;&gt;finite state machine&lt;/a&gt; which is the best way of writing a complex program like this. The idea is that nothing ever &lt;em&gt;blocks&lt;/em&gt;, it just changes states. And all the time other things can be happening, such as reading the nRF24L01+ module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a little tutorial on the Finite State Machine here:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/&quot; rel=&quot;nofollow&quot;&gt;https://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If you use the Finite State Machine concept to run the reading of your sensors and the writing of data to the WiFi the nRF can then be polled constantly outside of the FSM constantly - maybe with an FSM of its own to deal with reception etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Things to remember:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Avoid &lt;code&gt;delay()&lt;/code&gt;, certainly for anything longer than a couple of ms.&lt;/li&gt;&#xA;&lt;li&gt;Avoid &lt;code&gt;while()&lt;/code&gt;, &lt;code&gt;for()&lt;/code&gt;, etc except for very short loops that finish quickly.&lt;/li&gt;&#xA;&lt;li&gt;Any operation that takes more than a few ms to complete should be broken down into a number of sub-operations and coded as separate states of the FSM.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T09:34:48.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28030" PostTypeId="2" ParentId="28021" CreationDate="2016-08-04T10:02:16.133" Score="3" Body="&lt;p&gt;To expand on Doug's answer:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are two types of IR receiver. The two-pin one you have is basically a photodiode with infra-red filter. When infra-red light hits it the transistor gets biased and turns on. This is the most basic type you can get and is very hard to work with for anything other than simple on-off signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The second type is the IR receiver &lt;em&gt;module&lt;/em&gt;. This contains a photodiode as above, but also contains extra circuitry. It receives IR light on the photodiode and filters it through a band-pass filter. A remote control sends a sequence of pulses of light which itself is further made up of high frequency pulses (36KHz square wave, for example). It's this high frequency pulsing that is allowed through the band-pass filter. The internal circuitry then turns these pulses of high frequency square waves into pulses of ON or OFF signals by low-pass filtering them to remove the high frequency component.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This latter type of receiver is far easier to work with for sending of data or commands from (eg) a remote control. But it can't detect a steady-state IR signal. The modulation and filtering means that a much weaker signal can be extracted from the background IR light meaning much greater distances can be achieved using much weaker transmission LEDs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So while it is possible to use the former type with an Arduino you have to realise that the software required to do all the filtering and detection, as well as the extra hardware required to interface it, makes them considerably harder to use. That is why almost everyone uses the three-pin versions that do all that for you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note with the three-pin versions: they have to match the carrier frequency of the transmitter. So a 36KHz transmitter has to be paired with a 36KHz receiver. Otherwise it won't be able to detect the signal. Just like a radio - it has to be tuned to the right band.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T10:02:16.133" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28034" PostTypeId="2" ParentId="5058" CreationDate="2016-08-04T13:29:32.833" Score="0" Body="&lt;p&gt;You need to dig into the &lt;a href=&quot;https://www.sparkfun.com/datasheets/Wireless/Nordic/nRF24L01P_Product_Specification_1_0.pdf&quot; rel=&quot;nofollow&quot;&gt;datasheet&lt;/a&gt; and read about ESB (Enhanced ShockBurst).  This is technology that is integrated into the radios and allows for broadcasting and direct pipes.  One of the limitations is that the mesh only works for up to 6 pipes, so be aware that this limits the number of devices that will be able to hear your transmission.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to have all the nodes listening on the same pipe, and then when node x wants to talk, he stops listening on pipe 1234 and starts writing to it.  You would put some sort of addressing header in the payload section of the packet, then when all of the nodes receive that packet, they can check that address and see whether or not to process it.  This might work well in your situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, if you have a packet that is sent on the communal pipe with a payload of [broadcast address,data] then your receiving nodes (those within &quot;earshot&quot;) can receive the packet, see that it is a broadcast, then process the data.  If you want to send to a single node, create a packet that has a payload of [destination node id,data].  When each node receives that packet on the communal pipe, they will check the destination, and when it doesn't match either their own address or the broadcast address, then they dump it.  Only the intended receiver will actually process the data.&lt;/p&gt;&#xA;" OwnerUserId="25493" LastActivityDate="2016-08-04T13:29:32.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28036" PostTypeId="1" CreationDate="2016-08-04T12:12:46.773" Score="0" ViewCount="4238" Body="&lt;p&gt;I've been working on a 3D printer and I've come to the last step, which is wiring it all up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 3D printer I'm making works ONLY with the Arduino Mega. No Ramps. If I need to get Ramps later, I will, but for now, can someone please help me understand which of the Ramps pin goes with which Arduino pin. For example, in the Repetier firmware, the code is like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define X_STEP_PIN         54&#xA;#define X_DIR_PIN          55&#xA;#define X_ENABLE_PIN       38&#xA;#define X_MIN_PIN           3&#xA;#define X_MAX_PIN           2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But Arduino doesn't have a 54 and a 55 pin. I've been googling this and I found that Ramps pins 54 - 69  are the same as pins A0 - A15 on the Arduino Mega.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know this but not for the other pins...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone please tell me the connection of all the Ramps pins to the Arduino pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Like: pin 54 on Ramps = A0 on Arduino. I need this for all of the pins.&lt;/p&gt;&#xA;" OwnerDisplayName="mitch" LastEditorUserId="4628" LastEditDate="2016-12-03T15:37:02.873" LastActivityDate="2018-09-01T09:42:00.860" Title="What are the Ramps pins on my Arduino mega?" Tags="|arduino-mega|hardware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28037" PostTypeId="2" ParentId="28036" CreationDate="2016-08-04T12:33:22.853" Score="1" Body="&lt;p&gt;You are right, your have all the information in your question.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pin 54 Refers to the Arduino PIN Number, nothing to do with RAMPS.&#xA;0-53 are the digital pins and the 54 is A0, etc.&#xA;So the pin numbers should go higher than 69, which is A15.&lt;/p&gt;&#xA;" OwnerUserId="10394" OwnerDisplayName="Matt" LastActivityDate="2016-08-04T12:33:22.853" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28038" PostTypeId="1" CreationDate="2016-08-04T15:02:52.220" Score="1" ViewCount="4034" Body="&lt;p&gt;I have ESP8266 WiFi module and Arduino Mega Board connected. I use external 5 to 3.3 V regulator to power up the module. Common (-ve) line on the external power source and Arduino Mega GND is connected. Then I used 1K and 2K voltage divider for WiFi module RX and TX use as same. I am sure my circuit is well works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I connect RX0-RX and TX0-TX. Then i put CH-PD to 3.3v&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I opened the Arduino IDE and upload the Blink sketch. Done.. Then I opened Serial Monitor and set baud rate to 115200. Then power up the module. It gave me a lots of garbage values and ready. Fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I downloaded the FLASH_DOWNLOAD_TOOLS_v0.9.5. configure the 0x0000, 0x1000 and 0x7c000 &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;SPI speed = 40MHZ&lt;/li&gt;&#xA;&lt;li&gt;SPI mode = QIO&lt;/li&gt;&#xA;&lt;li&gt;FLASH size = 4Mbit&lt;/li&gt;&#xA;&lt;li&gt;0x1000 = ai-thinker-0.9.5.2-9600.bin&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then O power off the module and connect GPIO0 to ground and again power on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then push start button. Then it downloaded to the chip. It worked. Done. Success fully uploaded. Then I again disconnected the GPIO0 and power on. Then I put AT and it results OK.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;AT+GMR gives version 0.9.5 updated.done.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem was the module was responded for 115200 baud rate, not 9600. Then I:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+IPR=9600&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it gives me nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I can't communicate with it at either 115200 or 9600 baud. No respond whatever baud rate I put. Sometimes I am having same garbage values.&lt;/p&gt;&#xA;" OwnerUserId="25495" LastEditorUserId="26916" LastEditDate="2017-11-04T08:44:41.423" LastActivityDate="2017-11-04T08:44:41.423" Title="ESP8266 does not respond after changing baud rate to 9600" Tags="|arduino-mega|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28040" PostTypeId="2" ParentId="26953" CreationDate="2016-08-04T16:06:23.573" Score="1" Body="&lt;p&gt;Fixed : The issue was with the LM324 op-amp. It has a small slew rate (0.5 v/uS) which was causing the signal to flatten out at high frequencies. So had to change to an op-amp with a better slew rate.&lt;/p&gt;&#xA;" OwnerUserId="24416" LastActivityDate="2016-08-04T16:06:23.573" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28041" PostTypeId="2" ParentId="1180" CreationDate="2016-08-04T16:43:17.370" Score="1" Body="&lt;p&gt;I know this is a very old question, but I recently created a mac application that solves this problem very well. You can find more information about it on www.bloonapp.com. There are some demo videos on the website that you can check out.&lt;a href=&quot;https://i.stack.imgur.com/GiB7R.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GiB7R.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25498" LastActivityDate="2016-08-04T16:43:17.370" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28042" PostTypeId="2" ParentId="28038" CreationDate="2016-08-04T16:47:18.470" Score="1" Body="&lt;p&gt;This is a common issue. Using the &lt;code&gt;AT+IPR&lt;/code&gt; command seems to brick the module. Try to re-flash your module, like you did the first time. If it works, use this command: &lt;code&gt;AT+UART_DEF=9600,8,1,0,0&lt;/code&gt; instead to change the baud rate.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-08-04T16:47:18.470" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28043" PostTypeId="2" ParentId="28036" CreationDate="2016-08-04T18:02:30.613" Score="0" Body="&lt;p&gt;You're very close to your answer.  Here are the specifics:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Name      software pin  Mega2560 board label&#xA;X_STEP_PIN    54         Analog A0&#xA;X_DIR_PIN     55         Analog A1&#xA;X_ENABLE_PIN  38         Digital 38&#xA;X_MIN_PIN     3          PWM 3&#xA;X_MAX_PIN     2          PWM 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://reprap.org/mediawiki/images/3/3f/Arduinomegapololushieldschematic.png&quot; rel=&quot;nofollow&quot;&gt;http://reprap.org/mediawiki/images/3/3f/Arduinomegapololushieldschematic.png&lt;/a&gt; shows the mapping.&lt;/p&gt;&#xA;" OwnerUserId="17070" LastActivityDate="2016-08-04T18:02:30.613" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28044" PostTypeId="2" ParentId="26979" CreationDate="2016-08-04T19:12:09.447" Score="1" Body="&lt;p&gt;The problem you are facing is that the output of the LED is too high impedance for the ADC to work reliably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the LEDs can't produce enough current to charge the S&amp;amp;H capacitor properly, and on top of that the LED doesn't act as a resistive load when not forward biased, so the input is basically floating and picking up noise.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best cure is to add a voltage-follower buffer with incredibly high input impedance in front of the ADC input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;By high impedance I mean something measured in the 10s to 100s of TΩ. Something like the OPA355.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T19:12:09.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28045" PostTypeId="1" AcceptedAnswerId="28046" CreationDate="2016-08-04T19:41:33.433" Score="0" ViewCount="310" Body="&lt;p&gt;In this example I have an one object which uses a pointer and one object which does not.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class MyClass {&#xA;  public:&#xA;    void myMethod() {&#xA;      // do nothing&#xA;    }&#xA;};&#xA;&#xA;MyClass* mc1;&#xA;MyClass mc2;&#xA;&#xA;void setup() {&#xA;  mc1 = new MyClass();&#xA;}&#xA;&#xA;void loop() {&#xA;  mc1-&amp;gt;myMethod();&#xA;  mc2.myMethod();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is one implementation better than the other? Why?&lt;/p&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-08-05T14:33:29.480" Title="Pros and Cons of using a non-pointer class object" Tags="|pointer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28046" PostTypeId="2" ParentId="28045" CreationDate="2016-08-04T20:40:36.253" Score="1" Body="&lt;p&gt;In this situation, where you are just working with globals, the static declaration is preferred, although it makes little difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The static declaration (&lt;code&gt;MyClass mc2&lt;/code&gt;) will reserve space in the BSS. The dynamic allocation (&lt;code&gt;mc1 = new MyClass()&lt;/code&gt;) will allocate space on the heap at run time at the start of your sketch. Both are in pretty much the same area of RAM (the heap is directly above the static data area).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only trouble starts to come when you want to free (&lt;code&gt;delete&lt;/code&gt;) the object created with &lt;code&gt;new&lt;/code&gt;. That can, over time, make a complete swiss-cheese mess of your heap which can cause memory allocation problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For that reason the dynamic method is shunned, but if all you ever do is allocate at the start and never deallocate then there is little practical difference between the two methods.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T20:40:36.253" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28047" PostTypeId="1" AcceptedAnswerId="67688" CreationDate="2016-08-04T20:41:33.253" Score="1" ViewCount="10881" Body="&lt;p&gt;I'm trying to get Neo-6M module to work with Arduino Uno, but it just isn't transmitting any data. It is getting 3.3V.&lt;br&gt;&#xA;I've tried measuring the Amps and I got zero, so I'm afraid that the module could be broken.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Neo-6M wiring:&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/dY9P8.jpg&quot; alt=&quot;gps module wiring&quot;&gt;&lt;br&gt;&#xA;Arduino wiring (power):&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/ABrFk.jpg&quot; alt=&quot;arduino power wiring&quot;&gt;&lt;br&gt;&#xA;Arduino wiring (data):&lt;br&gt;&#xA;&lt;img src=&quot;https://i.stack.imgur.com/nHuyf.jpg&quot; alt=&quot;arduino data wiring&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;TinyGPS++.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;/*&#xA;   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.&#xA;   It requires the use of SoftwareSerial, and assumes that you have a&#xA;   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).&#xA;*/&#xA;static const int RXPin = 4, TXPin = 3;&#xA;static const uint32_t GPSBaud = 9600;&#xA;&#xA;// The TinyGPS++ object&#xA;TinyGPSPlus gps;&#xA;&#xA;// The serial connection to the GPS device&#xA;SoftwareSerial ss(RXPin, TXPin);&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  ss.begin(GPSBaud);&#xA;&#xA;  Serial.println(F(&quot;DeviceExample.ino&quot;));&#xA;  Serial.println(F(&quot;A simple demonstration of TinyGPS++ with an attached GPS module&quot;));&#xA;  Serial.print(F(&quot;Testing TinyGPS++ library v. &quot;));     Serial.println(TinyGPSPlus::libraryVersion());&#xA;  Serial.println(F(&quot;by Mikal Hart&quot;));&#xA;  Serial.println();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  // This sketch displays information every time a new sentence is correctly encoded.&#xA;  while (ss.available() &amp;gt; 0)&#xA;    if (gps.encode(ss.read()))&#xA;      displayInfo();&#xA;&#xA;  if (millis() &amp;gt; 5000 &amp;amp;&amp;amp; gps.charsProcessed() &amp;lt; 10)&#xA;  {&#xA;    Serial.println(F(&quot;No GPS detected: check wiring.&quot;));&#xA;    while(true);&#xA;  }&#xA;}&#xA;&#xA;void displayInfo()&#xA;{&#xA;  Serial.print(F(&quot;Location: &quot;)); &#xA;  if (gps.location.isValid())&#xA;  {&#xA;    Serial.print(gps.location.lat(), 6);&#xA;    Serial.print(F(&quot;,&quot;));&#xA;    Serial.print(gps.location.lng(), 6);&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot;  Date/Time: &quot;));&#xA;  if (gps.date.isValid())&#xA;  {&#xA;    Serial.print(gps.date.month());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.day());&#xA;    Serial.print(F(&quot;/&quot;));&#xA;    Serial.print(gps.date.year());&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.print(F(&quot; &quot;));&#xA;  if (gps.time.isValid())&#xA;  {&#xA;    if (gps.time.hour() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.hour());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.minute() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.minute());&#xA;    Serial.print(F(&quot;:&quot;));&#xA;    if (gps.time.second() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.second());&#xA;    Serial.print(F(&quot;.&quot;));&#xA;    if (gps.time.centisecond() &amp;lt; 10) Serial.print(F(&quot;0&quot;));&#xA;    Serial.print(gps.time.centisecond());&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;INVALID&quot;));&#xA;  }&#xA;&#xA;  Serial.println();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25501" LastActivityDate="2019-08-05T16:32:20.200" Title="No data from U-Blox Neo-6M" Tags="|gps|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28048" PostTypeId="1" CreationDate="2016-08-04T20:50:55.463" Score="0" ViewCount="1339" Body="&lt;p&gt;I am trying to implement the modbus library written by smarmengol to read process values and to set new setpoints (e.g. temperature) on a Eurotherm controller. The Arduino sketch looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/**&#xA; *  Modbus master example 2:&#xA; *  The purpose of this example is to query several sets of data&#xA; *  from an external Modbus slave device. &#xA; *  The link media can be USB or RS232.&#xA; *&#xA; *  Recommended Modbus slave: &#xA; *  diagslave http://www.modbusdriver.com/diagslave.html&#xA; *&#xA; *  In a Linux box, run &#xA; *  &quot;./diagslave /dev/ttyUSB0 -b 9600 -d 8 -s 1 -p none -m rtu -a 1&quot;&#xA; *  This is:&#xA; *      serial port /dev/ttyUSB0 at 9600 baud 8N1&#xA; *      RTU mode and address @1&#xA; */&#xA;&#xA;#include &amp;lt;ModbusRtu.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial&amp;gt;&#xA;&#xA;SoftwareSerial mySerial (3,5);&#xA;&#xA;uint16_t au16data[16]; //!&amp;lt; data array for modbus network sharing&#xA;uint8_t u8state; //!&amp;lt; machine state&#xA;uint8_t u8query; //!&amp;lt; pointer to message query&#xA;&#xA;/**&#xA; *  Modbus object declaration&#xA; *  u8id : node id = 0 for master, = 1..247 for slave&#xA; *  u8serno : serial port (use 0 for Serial)&#xA; *  u8txenpin : 0 for RS-232 and USB-FTDI &#xA; *               or any pin number &amp;gt; 1 for RS-485&#xA; */&#xA;Modbus master(0); // this is master and RS-232 or USB-FTDI&#xA;&#xA;/**&#xA; * This is an structe which contains a query to an slave device&#xA; */&#xA;modbus_t telegram[2];&#xA;&#xA;unsigned long u32wait;&#xA;&#xA;void setup() {&#xA;  // telegram 0: read registers&#xA;  telegram[0].u8id = 1; // slave address&#xA;  telegram[0].u8fct = 3; // function code (this one is registers read)&#xA;  telegram[0].u16RegAdd = 1; // start address in slave&#xA;  telegram[0].u16CoilsNo = 1; // number of elements (coils or registers) to read&#xA;  telegram[0].au16reg = au16data; // pointer to a memory array in the Arduino&#xA;&#xA;  // telegram 1: write a single register&#xA;  telegram[1].u8id = 1; // slave address&#xA;  telegram[1].u8fct = 6; // function code (this one is write a single register)&#xA;  telegram[1].u16RegAdd = 2; // start address in slave&#xA;  telegram[1].u16CoilsNo = 250; // (Setpoint) number of elements (coils or registers) to read&#xA;  telegram[1].au16reg = au16data+4; // pointer to a memory array in the Arduino&#xA;&#xA;  Serial.begin(9600);&#xA;  master.begin( &amp;amp;mySerial, 9600); // baud-rate at 9600&#xA;&#xA;  master.setTimeOut( 5000 ); // if there is no answer in 5000 ms,roll over&#xA;  u32wait = millis() + 1000;&#xA;  u8state = u8query = 0; &#xA;}&#xA;&#xA;void loop() {&#xA;  switch( u8state ) {&#xA;  case 0: &#xA;    if (millis() &amp;gt; u32wait) u8state++; // wait state&#xA;    break;&#xA;  case 1: &#xA;    master.query( telegram[u8query] ); // send query (only once)&#xA;    u8state++;&#xA;    u8query++;&#xA;    if (u8query &amp;gt; 2) u8query = 0;&#xA;    break;&#xA;  case 2:&#xA;    master.poll(); // check incoming messages&#xA;    if (master.getState() == COM_IDLE) {&#xA;      u8state = 0;&#xA;      u32wait = millis() + 1000; &#xA;    }&#xA;    break;&#xA;  }&#xA;   Serial.print(au16data[O]);&#xA;&#xA;  au16data[4] = analogRead( 0 );&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can read process values with telegram[0] very well (temperature and/or setpoint), but I cannot change the setpoint with telegram[1]. If I run the code, it puts the current temperature to serial monitor but resets manually changed setpoints to zero. Where is the error? Should I write the value for the setpoint as HEX or DEC? What does the last command do actually?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="13392" LastEditorUserId="4628" LastEditDate="2017-02-27T06:03:19.823" LastActivityDate="2019-04-23T14:14:14.587" Title="Talking to Eurotherm 2416 temperature controller over modbus rs232" Tags="|arduino-uno|modbus|rs232|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28049" PostTypeId="1" AcceptedAnswerId="28050" CreationDate="2016-08-04T21:11:47.640" Score="2" ViewCount="5701" Body="&lt;p&gt;I'm a little new to circuitry, and the Arduino in itself!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From what I know, I think that it might be possible to actually build one (the processor itself, of course) from transistors. This isn't a practical question, of course, but it would be an excellent learning opportunity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be actually possible to go through with such a project (Even without EEPROM)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, how would it be completed?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="25504" LastActivityDate="2019-03-25T07:01:59.040" Title="Building an AtMega328p from Transistors" Tags="|assembly|" AnswerCount="7" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28050" PostTypeId="2" ParentId="28049" CreationDate="2016-08-04T21:20:47.210" Score="5" Body="&lt;p&gt;Yes, it is possible - after all, the Arduino is essentially just a bunch of incredibly tiny transistors. Early computers, before ICs were invented, were built from transistors. Before that it was valves. Before that it was relays. All just, at the end of the day, switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Would it be a practical project? Not really, although someone has done it (not for the AVR CPU, but the concept is the same): &lt;a href=&quot;http://www.megaprocessor.com/&quot; rel=&quot;noreferrer&quot;&gt;http://www.megaprocessor.com/&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How would you start? Well, first off you'd create the basic building blocks of a CPU, which is logic gates. There are two basic ones that can be combined together to make any other gate: the NAND gate and the NOR gate. You'd pick one of those and put lots of them together to make the basic sections of the CPU. Then those blocks connect together to form the CPU. More logic gates go together to make the IO functionality, memory, interfaces, etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Transistors combine to make NAND gates (or NOR gates if you prefer that form)&lt;/li&gt;&#xA;&lt;li&gt;NAND (or NOR) gates combine to make complex gates.&lt;/li&gt;&#xA;&lt;li&gt;Complex gates combine to make logic functions&lt;/li&gt;&#xA;&lt;li&gt;Logic functions combine to make logic blocks (like the ALU)&lt;/li&gt;&#xA;&lt;li&gt;Logic blocks combine to make the CPU&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T21:20:47.210" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28051" PostTypeId="1" CreationDate="2016-08-04T21:23:42.503" Score="1" ViewCount="2333" Body="&lt;p&gt;I have ATMega328p chip, and I have HC-06 on pin A5, A4 (RX, TX) and I have another device on pin 10, 9 (RX,TX). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to be able to send some command on BT via Bluetooth Terminal and pass raw (exact) command to that device unchanged just to log on my computer (on my serial monitor) incoming command from BT and to log the response from device the same way on serial monitor and pass unmodified to HC-06.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried by using &quot;listen()&quot; method but sometimes I get some weird character while I'm transferring\reading data, so not sure how to do this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All baud rates are 9600.&lt;/p&gt;&#xA;" OwnerUserId="21699" LastActivityDate="2017-03-03T10:00:10.797" Title="Using two software serial - two UART" Tags="|arduino-uno|bluetooth|atmega328|softwareserial|uart|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28052" PostTypeId="2" ParentId="28049" CreationDate="2016-08-04T21:29:44.377" Score="1" Body="&lt;p&gt;Why not? Atmel did it.  But if you mean by soldering up discretes... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the mid 70s the Zilog Z80 had 8,500 transistors; a couple of years later, the Intel 8088 had 29000(source: &lt;a href=&quot;https://en.wikipedia.org/wiki/Transistor_count&quot; rel=&quot;nofollow&quot;&gt;Wikipedia)&lt;/a&gt;. Neither of those had on-chip memory. The AtMega 328p has 2K of RAM and 1K of EEPROM on chip, so factor in for those and their drivers. At 20 MHz it will probably be fun 1) keeping signals where they belong; and 2) keeping the wire runs short enough and suitably arranged that capacitance doesn't slow and distort the signals to unusability.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-08-05T16:02:57.090" LastActivityDate="2016-08-05T16:02:57.090" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28053" PostTypeId="2" ParentId="28051" CreationDate="2016-08-04T22:15:41.303" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How can I do that?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is impossible to use two SoftwareSerial ports together. Simply because while you are writing to one port everything else stops. Interrupts are disabled, and receiving requires interrupts. So anything that arrives while you are sending will either be lost or corrupted.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only solution is to use a board with multiple hardware UARTs like the Mega or any of the more powerful alternatives to Arduino such as chipKIT or Teensy.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-04T22:15:41.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28055" PostTypeId="2" ParentId="28047" CreationDate="2016-08-04T23:34:43.250" Score="1" Body="&lt;p&gt;It isn't enough to power the module with 3.3V. You also have to level-shift the Arduino's 5V TX signal to 3.3V that is acceptable by the GPS module's RX pin, using a 1:2 voltage divider. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CBwwb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CBwwb.png&quot; alt=&quot;Converter&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should also know that the Arduino's 3.3 V pin can't source more than 50 mA; your module's current draw may sometimes exceed this limit (max is 67 mA). Instead, connect the Arduino's 5 V pin (which can source up to 500 mA) to the VCC of the GPS module through an LM1117T 3.3 V regulator:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QcsNT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QcsNT.png&quot; alt=&quot;Regulator&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The input goes the Arduino 5V pin and the output goes to the NEO-6M VCC. Connect all GNDs together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then run a basic sketch like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;SoftwareSerial.h&quot;&#xA;&#xA;SoftwareSerial gps(4,3);&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600);&#xA;  gps.begin(9600);&#xA;}&#xA;&#xA;void loop(){&#xA;  while (gps.available())&#xA;    Serial.write(gps.read());&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This will basically make the Arduino grab any NMEA data sent by the NEO-6M and forward it to your PC's serial monitor. If you receive legible data, it means you've established comms with the module. You can then upload your original sketch.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-08-04T23:34:43.250" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28060" PostTypeId="2" ParentId="28049" CreationDate="2016-08-05T07:32:01.510" Score="1" Body="&lt;p&gt;While it is possible, you will have to spend a lot of money and a lot of time. I think about thousends of dollars and months of work. Even when accomplished you will have learned more about electronics than about the ATmega328P. In order to accomplish, you will also have to ask Atmel to hand you over the schematics to get the inner working right. I highly doubt they will aggree since it is not Open Hardware.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I highly discourage you to do that. Instead I suggest you start with an Arduino UNO and discover the capabilities and then go a step further and use a bare ATmege328P.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-08-05T07:32:01.510" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28063" PostTypeId="1" CreationDate="2016-08-05T10:12:42.993" Score="0" ViewCount="1753" Body="&lt;p&gt;Today I tried to display some text with my Arduino UNO and a LCD 1602A screen. I did find some schemas online, but I cannot get any character or &quot;black boxes&quot; on the display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connect wires like that : &#xA;Pin 1 : GND&#xA;Pin 2 : +5V&#xA;Pin 3 : 50K Pot.&#xA;Pin 4 : Pin 7 from Arduino&#xA;Pin 5 : GND&#xA;Pin 6 : Pin 6 from Arduino&#xA;Pin 11 : Pin 5 from Arduino&#xA;Pin 12 : Pin 4 from Arduino&#xA;Pin 13 : Pin 3 from Arduino&#xA;Pin 14 : Pin 2 from Arduino&#xA;Pin 15 : +5V&#xA;Pin 16 : GND&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can see my setup here : &lt;a href=&quot;https://i.stack.imgur.com/u32sj.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://i.stack.imgur.com/u32sj.jpg&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD screen is lighten up, but nothing else appears. Pot. is working (increase or decrease light). I tried to change the LCD with another, but both are not working. I tested some many code, here an example : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;  LiquidCrystal Library - Hello World&#xA;&#xA; Demonstrates the use a 16x2 LCD display.  The LiquidCrystal&#xA; library works with all LCD displays that are compatible with the&#xA; Hitachi HD44780 driver. There are many of them out there, and you&#xA; can usually tell them by the 16-pin interface.&#xA;&#xA; This sketch prints &quot;Hello World!&quot; to the LCD&#xA; and shows the time.&#xA;&#xA;  The circuit:&#xA; * LCD RS pin to digital pin 12&#xA; * LCD Enable pin to digital pin 11&#xA; * LCD D4 pin to digital pin 5&#xA; * LCD D5 pin to digital pin 4&#xA; * LCD D6 pin to digital pin 3&#xA; * LCD D7 pin to digital pin 2&#xA; * LCD R/W pin to ground&#xA; * LCD VSS pin to ground&#xA; * LCD VCC pin to 5V&#xA; * 10K resistor:&#xA; * ends to +5V and ground&#xA; * wiper to LCD VO pin (pin 3)&#xA;&#xA; Library originally added 18 Apr 2008&#xA; by David A. Mellis&#xA; library modified 5 Jul 2009&#xA; by Limor Fried (http://www.ladyada.net)&#xA; example added 9 Jul 2009&#xA; by Tom Igoe&#xA; modified 22 Nov 2010&#xA; by Tom Igoe&#xA;&#xA; This example code is in the public domain.&#xA;&#xA; http://www.arduino.cc/en/Tutorial/LiquidCrystal&#xA; */&#xA;&#xA;// include the library code:&#xA;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;// initialize the library with the numbers of the interface pins&#xA;LiquidCrystal lcd(7, 6, 5, 4, 3, 2);&#xA;&#xA;void setup() {&#xA;  // set up the LCD's number of columns and rows:&#xA;  lcd.begin(16, 2);&#xA;  // Print a message to the LCD.&#xA;  lcd.print(&quot;hello, world!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // set the cursor to column 0, line 1&#xA;  // (note: line 1 is the second row, since counting begins with 0):&#xA;  lcd.setCursor(0, 1);&#xA;  // print the number of seconds since reset:&#xA;  lcd.print(millis() / 1000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Do you have an idea ? Thanks !&lt;/p&gt;&#xA;" OwnerUserId="25518" LastActivityDate="2016-09-06T08:48:02.943" Title="Can't display text on LCD 1602" Tags="|arduino-uno|lcd|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28064" PostTypeId="1" AcceptedAnswerId="28067" CreationDate="2016-08-05T11:01:40.753" Score="0" ViewCount="1192" Body="&lt;p&gt;I need to know if there is a sensor that mesure pH and ORP, I have already googled about this type of sensor but i found only AtlasScientific that commercialise this kind of sensor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks&lt;/p&gt;&#xA;" OwnerUserId="24012" LastActivityDate="2016-08-05T12:04:56.920" Title="pH ORP sensor esp12 esp82666" Tags="|esp8266|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28067" PostTypeId="2" ParentId="28064" CreationDate="2016-08-05T12:04:56.920" Score="0" Body="&lt;p&gt;Yes there are lots.  You might try search for &quot;Arduino PH Sensor&quot; and &quot;Arduino ORP sensor&quot; you'll get a lot more hits for Arduino than ESP8226.&#xA;This might be useful:&#xA;&lt;a href=&quot;http://www.instructables.com/id/ORP-pH-Temperature-Data-Logger/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/ORP-pH-Temperature-Data-Logger/?ALLSTEPS&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-05T12:04:56.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28068" PostTypeId="1" AcceptedAnswerId="28171" CreationDate="2016-08-05T12:23:26.390" Score="0" ViewCount="146" Body="&lt;p&gt;My operating system : OS X EL CAPITAN&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help I was trying to do project 05 Mood cue of the arduino starter kit. I completed setting up my board and writing the code and when I tried to upload I got this error message: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.7.10 (Mac OS X), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Sketch uses 1,030 bytes (3%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;avrdude: ser_open(): can't open device &quot;/dev/tty.usbmodem1411&quot;: Device not         configured&#xA;ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device&#xA;Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can someone please help me?&lt;/p&gt;&#xA;" OwnerUserId="25522" LastEditorUserId="4594" LastEditDate="2016-08-05T14:59:09.790" LastActivityDate="2016-08-08T18:08:03.123" Title="code wont upload to arduino starter kit" Tags="|arduino-uno|uploading|mac-os|" AnswerCount="1" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28069" PostTypeId="2" ParentId="28045" CreationDate="2016-08-05T14:33:29.480" Score="0" Body="&lt;p&gt;It depends on what you are trying to do and partly a matter of taste but I tend to take this one step further when the class corresponds to a specific hardware resource. In this case you can use static methods exclusively to guarantee a 1 to 1 correspondence. Templates come to rescue when you want to bind a specific physical instance of some finite resource (e.g. one of the timers) and this can be further refined using specialization and traits (each timer has different characteristics).&lt;/p&gt;&#xA;" OwnerUserId="24400" LastActivityDate="2016-08-05T14:33:29.480" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28076" PostTypeId="1" CreationDate="2016-08-05T17:16:29.763" Score="0" ViewCount="182" Body="&lt;p&gt;I'm working on a data logging project and would like to use all six analog inputs on my Arduino Uno R3.  I've been able to get everything working, including writing to the SD card.  However, with the shield installed I'm getting junk readings from a4 and a5.  They work fine without the shield.&lt;/p&gt;&#xA;" OwnerUserId="25530" LastActivityDate="2016-08-05T19:22:25.593" Title="Uno R3's a4 and a5 not working after installing itead SD Shield 3.0" Tags="|arduino-uno|shields|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28077" PostTypeId="1" AcceptedAnswerId="28096" CreationDate="2016-08-05T17:22:06.127" Score="0" ViewCount="36" Body="&lt;p&gt;I am very new to Arduino, I bought a starter's kit and I am working with the user manual that is available. I am in chapter 6 Tri Color Module&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using the following code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Defining the LED driver pins and some other&#xA;// variables.&#xA;const int numLEDs = 3;&#xA;&#xA;int blueLEDPin  = 3;&#xA;int greenLEDPin = 4;&#xA;int redLEDPin   = 5;&#xA;int ledPin[3];&#xA;int ledPinIndex = 0;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {    &#xA;&#xA;  Serial.begin(9600);&#xA;&#xA;  // initialize the digital pin as an output.&#xA;  ledPin[0] = blueLEDPin;&#xA;  ledPin[1] = greenLEDPin;&#xA;  ledPin[2] = redLEDPin;&#xA;&#xA;  for (int i=0; i &amp;lt; numLEDs; i++)&#xA;     pinMode(i, OUTPUT);&#xA;&#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;&#xA;  digitalWrite(ledPin[ledPinIndex%numLEDs], HIGH);&#xA;  delay(1000);&#xA;  Serial.println(ledPinIndex%numLEDs);&#xA;  delay(2000);  &#xA;  digitalWrite(ledPin[ledPinIndex%numLEDs], LOW);&#xA;&#xA;  ledPinIndex++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;My problem is that in the setup() method where the following code is&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i=0; i &amp;lt; numLEDs; i++)&#xA;         pinMode(i, OUTPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;From my understanding pinMode OUTPUT is use to send power out of the specific pin. As the code displays pin 3, 4, and 5 are used but the above code is setting pinMode for 0, 1, 2. Is this write? And even if I comment out the two lines up my project no differently as to the previous code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone verify if the above code is correct, or should it be setting pinMode for 3, 4, and 5. &lt;/p&gt;&#xA;" OwnerUserId="25528" LastActivityDate="2016-08-06T08:20:32.467" Title="Arduino Saint Smart Chapter 7 Tri Color Module" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28078" PostTypeId="1" CreationDate="2016-08-05T18:02:41.080" Score="0" ViewCount="367" Body="&lt;p&gt;In the SoftwareSerial library, I see the beginning of recv() as follows&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SoftwareSerial::recv()&#xA;{&#xA;&#xA;#if GCC_VERSION &amp;lt; 40302&#xA;// Work-around for avr-gcc 4.3.0 OSX version bug&#xA;// Preserve the registers that the compiler misses&#xA;// (courtesy of Arduino forum user *etracer*)&#xA;  asm volatile(&#xA;    &quot;push r18 \n\t&quot;&#xA;    &quot;push r19 \n\t&quot;&#xA;    &quot;push r20 \n\t&quot;&#xA;    &quot;push r21 \n\t&quot;&#xA;    &quot;push r22 \n\t&quot;&#xA;    &quot;push r23 \n\t&quot;&#xA;    &quot;push r26 \n\t&quot;&#xA;    &quot;push r27 \n\t&quot;&#xA;    ::);&#xA;#endif    &#xA;&#xA;  uint8_t d = 0;&#xA;&#xA;  // If RX line is high, then we don't see any start bit&#xA;  // so interrupt is probably not for us&#xA;  if (_inverse_logic ? rx_pin_read() : !rx_pin_read())&#xA;  { &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This comment seems to be testing for if the pin change was from low to high, or high to low.  If you are using inverse logic - where the line is held high, and start bits are low - then a call to rx_pin_read() should return 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This doesn't seem correct.  In inverse logic the line is held high and a drop indicates a start bit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the SoftwareSerial library ignoring the start bit and relying on some kind of return to zero break between the start bit and any subsequent bits?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems like it can't handle start bits followed by high bits since there would be no change in the pin state.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/4DOst.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4DOst.gif&quot; alt=&quot;typical ttl &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25531" LastActivityDate="2016-10-06T21:54:11.863" Title="Help understanding SoftwareSerial recv() and PCINT" Tags="|softwareserial|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28079" PostTypeId="1" AcceptedAnswerId="28081" CreationDate="2016-08-05T19:11:15.080" Score="13" ViewCount="4545" Body="&lt;p&gt;Are there any best practices regarding password safety?  The following is taken from a wifi tutorial sketch.  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;WiFi.h&amp;gt;&#xA;&#xA;char ssid[] = &quot;yourNetwork&quot;;      // your network SSID (name) &#xA;char pass[] = &quot;secretPassword&quot;;   // your network password&#xA;int keyIndex = 0;                 // your network key Index number (needed only for WEP)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;While I accept that the tutorial is there for learning how to use the shield, I would assume hard coding the password into the sketch leaves this open to attackers.  Is this actually the case?  If so, are there any strategies to harden the sketch, for example with encrypted storage?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am a relative newbie with physical computing and Arduino, so sorry if I am overlooking something obvious.&lt;/p&gt;&#xA;" OwnerUserId="24460" LastActivityDate="2021-05-12T14:11:01.297" Title="WiFi Password Safety" Tags="|wifi|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28080" PostTypeId="2" ParentId="28076" CreationDate="2016-08-05T19:22:25.593" Score="1" Body="&lt;p&gt;The shield has pull-up resistors for I2C/TWI on pins A4 and A5. Special care (resistor bridge) needs to be taken if using these as analog pins. Please see the schematics for more details. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.itead.cc/wiki/images/4/46/Sch_sd_shield_3.0.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.itead.cc/wiki/images/4/46/Sch_sd_shield_3.0.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-05T19:22:25.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28081" PostTypeId="2" ParentId="28079" CreationDate="2016-08-05T19:26:13.160" Score="12" Body="&lt;p&gt;You're actually entering into a very tricky and difficult area.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, having a plain text password in your sketch is a risk. It is stored in flash as plain text. If an attacker can gain access to the contents of the flash through some means (whatever they may be) then they could obtain that WiFi password.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would think that encrypting the password would be the answer, but that's not the case. The problem with an encrypted password like this is it has to be decrypted to use it. That means that both the encrypted password and the encryption key are both stored together in flash. If you can get one you can get the other, and thus the encryption is null and void.  Encryption security relies on keeping the encrypted data and the key used to encrypt/decrypt it completely separate. After all, you don't leave the key to your house in the front door lock when you go out, do you? It's exactly the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what do you do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Well, there's lots of different ways of looking at security. In this case there is one specific viewpoint that works best:&lt;/p&gt;&#xA;&#xA;&lt;h1&gt;Security Through Obscurity&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;Your system is (pretty much) unique. Nobody but you knows just what it does and how it does it, or how you interact with it. It's not obvious to the casual observer just what it is or what could be done with it. That means that they won't know how to break in to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The majority of use of vulnerabilities in systems rely on those systems being ubiquitous - that is, all over the place; easy to obtain. In short, easy to find out what they are, how they work, and even reverse engineer them to a certain extent. Attackers aren't going to be able to do that with your system, since you are the only person in the world with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it's far from perfect, and you shouldn't rely &lt;em&gt;only&lt;/em&gt; on Security Through Obscurity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Simple obfuscation of the password (not actual encryption, but just storing it in a way that isn't obvious) can help, since it isn't then easy to see where in a memory dump the password would be. Splitting it up and scattering it around the place, too, can be useful.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically there is no simple answer, other than &lt;em&gt;make it as hard for an attacker to find sensitive things as possible&lt;/em&gt; and &lt;em&gt;don't tell anyone what you have done to hide it&lt;/em&gt; ;)&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-05T19:26:13.160" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28084" PostTypeId="2" ParentId="28049" CreationDate="2016-08-05T20:53:32.730" Score="3" Body="&lt;p&gt;I do not think you could build an ATmega328P out of discrete parts: you&#xA;would need floating-gate transistors for implementing the flash, and&#xA;these do not seem to be available as discretes.&lt;/p&gt;&#xA;&lt;p&gt;If you forgo the flash (or replace it with RAM or ROM), then it should&#xA;in principle be possible. This processor, however, is probably not a&#xA;good choice for such a project. From &lt;a href=&quot;https://www.embeddedrelated.com/showthread/comp.arch.embedded/14362-1.php&quot; rel=&quot;nofollow noreferrer&quot;&gt;the discussion&lt;/a&gt; linked to by&#xA;Mikael Patel, it seems you would need something like 80 K&#xA;transistors for the core alone, and much more if you include the RAM and&#xA;the peripherals. It would be a daunting task to assemble all this by&#xA;hand. For comparison, the &lt;a href=&quot;http://www.megaprocessor.com/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Megaprocessor&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; as about&#xA;42 K transistors total (core + RAM + LED drivers).&lt;/p&gt;&#xA;&lt;p&gt;If you want to pursue such a project, I recommend you target a simpler&#xA;CPU. The &lt;a href=&quot;https://en.wikipedia.org/wiki/MOS_Technology_6502&quot; rel=&quot;nofollow noreferrer&quot;&gt;MOS 6502&lt;/a&gt; may be a good choice. This CPU, which was very&#xA;popular in the late 70s and early 80s, has “only” 3,510 transistors and&#xA;is well documented. See for example the resources at &lt;a href=&quot;http://www.visual6502.org/&quot; rel=&quot;nofollow noreferrer&quot;&gt;visual6502.org&lt;/a&gt;.&#xA;They have an amazing &lt;a href=&quot;http://www.visual6502.org/JSSim/&quot; rel=&quot;nofollow noreferrer&quot;&gt;online transistor-level simulator&lt;/a&gt; built from&#xA;the actual layout of the chip.&lt;/p&gt;&#xA;&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;Thanks Majenko for the link&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-05T20:53:32.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28086" PostTypeId="1" CreationDate="2016-08-05T23:45:14.733" Score="1" ViewCount="629" Body="&lt;p&gt;I want to design my PCB with Atmega328p chip on it and I want to be able to burn Bootloader and sketch after that while everything is soldered on the PCB. So my question is, what would be the best way to do that? My current idea is to leave extra pins for burning a Bootloader, and to leave also extra pins for uploading the sketch, and to &quot;unplug&quot; other stuff connected on these pins (for example on hardware UART) by adding\removing jumpers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm pretty new to all this stuff, so I'm not quite sure what's the best approach. &lt;/p&gt;&#xA;" OwnerUserId="21699" LastActivityDate="2016-08-06T03:03:50.650" Title="Atmega328p - PCB ISP pins for bootloader and sketch upload" Tags="|atmega328|pcb-design|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="28087" PostTypeId="1" CreationDate="2016-08-06T01:12:33.547" Score="0" ViewCount="1263" Body="&lt;p&gt;I have an Arduino Mega 2560 board running a ramps 1.4 shield for a 3D printer.  For some reason, I can only power the Mega with USB.  It does not get power from the ramps shield and it also will not power on when plugged in to a 12v wall adapter.  I know all power sources are working because I have a second Mega that works fine on all.  What could I check on the Mega board to help figure this out.  Other than being powered only by USB, everything else works as expected with no problems.&lt;/p&gt;&#xA;" OwnerUserId="25537" LastActivityDate="2017-04-04T00:41:06.337" Title="Arduino Mega 2560 Only Powers on with USB" Tags="|arduino-mega|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28088" PostTypeId="2" ParentId="28087" CreationDate="2016-08-06T02:54:47.027" Score="2" Body="&lt;p&gt;Looking at &lt;a href=&quot;https://arduino-info.wikispaces.com/file/view/arduino-mega2560-schematic-F.jpg/346627792/arduino-mega2560-schematic-F.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; Arduino Mega 2560 schematic, if IC1 or IC2 failed (assuming only one or the other is installed for a given board), then you would only be able to power the board using the USB port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looking at &lt;a href=&quot;http://reprap.org/mediawiki/images/f/f6/RAMPS1.4schematic.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; ramps 1.4 shield schematic it is assumed that the RAMPS 1.4 shield is providing 12 volts through D1 to the Arduino Mega 2560.  And that testing included using a known good Arduino Mega 2560 board with the RAMPS 1.4 shield board with good results.  Thereby eliminating the possibility that D1 on the RAMPS 1.4 shield is damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If these assumptions are correct, this reinforces the likelihood that either IC1 or IC2 has failed on the Arduino Mega 2560 board.  &lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2017-01-03T16:37:51.160" LastActivityDate="2017-01-03T16:37:51.160" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28089" PostTypeId="2" ParentId="28086" CreationDate="2016-08-06T03:03:50.650" Score="2" Body="&lt;p&gt;Realistically, you should design ATmega boards to support both ISP and bootloader pins.  The logic is simple:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Unless you buy pre-programmed chips, or have a programming fixture, you will need ISP either to load the firmware itself, or to load a bootloader.  &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even if you plan to use only ISP for programming, it is still worth providing external connections to the UART pins for interacting with firmware during development; generally with ATmega-based Arduinos you do not have a breakpoint debugger, so debug messages on serial are your primary visibility into what is happening.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;You should wire the reset line to somewhere that you can manipulate it, so you don't have to power cycle your firmware every time you want to restart it in testing.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Once you have done all that, you end up with support for both ISP and UART bootloader - regardless if you plan to use them both or not. &lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-08-06T03:03:50.650" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28090" PostTypeId="1" CreationDate="2016-08-06T04:50:52.160" Score="1" ViewCount="381" Body="&lt;p&gt;I compiled my code several times today,&#xA;I would quit and restart randomly through the day.&#xA;each time I started I get a error box board and libraries need updates.&#xA;I did an AVR board up date, then compiled and now I get this every time.....&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;avrdude: no programmer has been specified on the command line or the config file&#xA;         Specify a programmer using the -c option and try again&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Yes I have tried rebooting my Windows 7 64 bit AMD machine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;this is on IDE &quot;Arduino 1.6.8&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course I made the mistake of not backing up my IDE folders in the belief that an update would not screw my IDE up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Nothing will upload, not even any of the examples.&#xA;I turned on Show Verbose output during Compilation, and upload&#xA;I pasted the full output and it was 4500 char to many for this so I turned of the compilation check and left just the upload check on show verbose errors&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I loaded in the example blink, &lt;/p&gt;&#xA;&#xA;&lt;h2&gt;the file followed by the IDE lower window text.&lt;/h2&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;  Blink&#xA;  Turns on an LED on for one second, then off for one second, repeatedly.&#xA;&#xA;  Most Arduinos have an on-board LED you can control. On the Uno and&#xA;  Leonardo, it is attached to digital pin 13. If you're unsure what&#xA;  pin the on-board LED is connected to on your Arduino model, check&#xA;  the documentation at http://www.arduino.cc&#xA;&#xA;  This example code is in the public domain.&#xA;&#xA;  modified 8 May 2014&#xA;  by Scott Fitzgerald&#xA; */&#xA;&#xA;&#xA;// the setup function runs once when you press reset or power the board&#xA;void setup() {&#xA;  // initialize digital pin 13 as an output.&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;// the loop function runs over and over again forever&#xA;void loop() {&#xA;  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(1000);              // wait for a second&#xA;  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(1000);              // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;END OF FILE &#xA;Copy and paste of the lower IDE window  last lines the same as above&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c prettyprint-override&quot;&gt;&lt;code&gt;Sketch uses 928 bytes (2%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.&#xA;C:\Users\Lee\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/bin/avrdude -CC:\Users\Lee\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/etc/avrdude.conf -v true -patmega328p -carduino -PCOM10 -b115200 -D -Uflash:w:C:\Users\Lee\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.hex:i &#xA;&#xA;avrdude: Version 6.3, compiled on Jun 22 2016 at 16:05:21&#xA;         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/&#xA;         Copyright (c) 2007-2014 Joerg Wunsch&#xA;&#xA;         System wide configuration file is &quot;C:\Users\Lee\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/etc/avrdude.conf&quot;&#xA;&#xA;&#xA;avrdude: no programmer has been specified on the command line or the config file&#xA;         Specify a programmer using the -c option and try again&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;There is that line again   What do I do to fix this?&#xA;besides deleting everything and starting all over again?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I do not want to delete and start over&lt;/p&gt;&#xA;" OwnerUserId="25541" LastEditorUserId="6826" LastEditDate="2016-08-06T23:25:30.973" LastActivityDate="2021-08-05T19:02:40.257" Title="Board and library updates required caused an error" Tags="|avrdude|programmer|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28091" PostTypeId="1" AcceptedAnswerId="28161" CreationDate="2016-08-06T05:46:31.117" Score="1" ViewCount="3448" Body="&lt;p&gt;Out of curiosity, I am trying to upload a simple hex file to Arduino UNO using avrdude from windows command prompt.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;As per &lt;a href=&quot;https://asensar.com/blog/2013/programming-arduino-using-avrdude/&quot; rel=&quot;nofollow noreferrer&quot;&gt;this forum&lt;/a&gt;, I tried to implement it. But got stuck at &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;COM41&quot;: The system cannot find the file&#xA;  specified.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This command was directly imported from Arduino IDE verbose, and also it works fine when uploaded with Arduino IDE. I checked both the device and syntax are correct unless I would not be able to generate the hex file by Arduino compiler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S. I have installed Winavr separately although it was pre-installed by Arduino&#xA;itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a snapshot of the error &lt;a href=&quot;https://i.stack.imgur.com/nWwWW.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/nWwWW.png&quot; alt=&quot;command prompt&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What could be the possible reason for it to fail? Please notify, if anything is missing.&lt;/p&gt;&#xA;" OwnerUserId="21624" LastEditorUserId="21624" LastEditDate="2016-08-06T05:52:53.787" LastActivityDate="2016-08-08T11:32:15.093" Title="Programming arduino using avrdude from command prompt" Tags="|arduino-uno|serial|uploading|avrdude|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28092" PostTypeId="1" AcceptedAnswerId="28103" CreationDate="2016-08-06T06:01:59.920" Score="6" ViewCount="48149" Body="&lt;p&gt;How would I split &lt;code&gt;part1&lt;/code&gt; into 2-3 digits and put them into &lt;code&gt;num1&lt;/code&gt;, &lt;code&gt;num2&lt;/code&gt;, and &lt;code&gt;num3&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int FMSTATION = 10250;&#xA;&#xA;int update_display() {&#xA;  int fm_station = FMSTATION ;&#xA;&#xA;  int part1;&#xA;  int part2;&#xA;&#xA;  part1 = (FMSTATION / 100);&#xA;  part2 = (FMSTATION % 100);&#xA;  part2 = (part2/10);&#xA;&#xA;  int num1 = ;&#xA;  int num2 = ;&#xA;  int num3 = ;&#xA;  int num4 = part2;&#xA;&#xA;  matrix.writeDigitNum(0, num1, false);  //1st number on lcd&#xA;  matrix.writeDigitNum(1, num2, false);  //2nd number on lcd&#xA;  matrix.writeDigitNum(3, num3, true);   //3rd number on lcd and adds &quot;.&quot;&#xA;  matrix.writeDigitNum(4, num4, false);  //4th number on lcd&#xA;&#xA;  matrix.writeDisplay();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have searched the web from top to bottom, but could not find the answer. In the end what I should get displayed on my LCD is &lt;code&gt;102.5&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="25543" LastEditorUserId="84" LastEditDate="2016-08-06T07:31:46.950" LastActivityDate="2019-10-10T10:41:39.400" Title="How do I split a number into individual digits?" Tags="|programming|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28093" PostTypeId="2" ParentId="3479" CreationDate="2016-08-06T06:20:48.080" Score="1" Body="&lt;pre&gt;&lt;code&gt;// When first time program launches it confused to press push button twice. Well replace it with this&#xA;&#xA;if (x == 1) {&#xA;    // Toggle on&#xA;    digitalWrite(ledPin, HIGH);&#xA;    x = 0;&#xA;} else {&#xA;    // Toggle off&#xA;    digitalWrite(ledPin, LOW);&#xA;    x = 1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25544" LastEditorUserId="84" LastEditDate="2016-08-06T07:36:28.390" LastActivityDate="2016-08-06T07:36:28.390" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28094" PostTypeId="2" ParentId="28092" CreationDate="2016-08-06T06:37:14.240" Score="1" Body="&lt;p&gt;I think this will help you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int FMSTATION = 10250;&#xA;int update_display() {&#xA;  int fm_station = FMSTATION ;&#xA;&#xA;  int part1;&#xA;  int part2; &#xA;  part1 = (FMSTATION / 100); //102&#xA;  part2 = (FMSTATION % 100); //50&#xA;  part2 = (part2/10); //5&#xA;&#xA;  int num1 = part1/100; //1&#xA;  int num2 = (part1 % 100)/10; //0&#xA;  int num3 = part1%10; //2&#xA;  int num4 = part2; //5&#xA;&#xA;  matrix.writeDigitNum(0, num1, false); //1st number on lcd&#xA;  matrix.writeDigitNum(1, num2, false); //2nd number on lcd&#xA;  matrix.writeDigitNum(3, num3, true); //3rd number on lcd and adds &quot;.&quot;&#xA;  matrix.writeDigitNum(4, num4, false); //4th number on lcd&#xA;&#xA;  matrix.writeDisplay();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24064" LastEditorUserId="84" LastEditDate="2016-08-06T07:33:17.403" LastActivityDate="2016-08-06T07:33:17.403" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28095" PostTypeId="2" ParentId="28091" CreationDate="2016-08-06T06:50:40.600" Score="1" Body="&lt;pre&gt;&lt;code&gt;can't open device &quot;COM41&quot;: The system cannot find the file specified.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This means there is no device at &lt;code&gt;COM41&lt;/code&gt;. This may be due to 2 reasons: &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;You may not have connected your arduino. If this is the case then you please connect the arduino and retry&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Your arduino might be on a different COM port. If this is the case, then, go to device manager and check your arduino's COM port and replace &lt;code&gt;COM41&lt;/code&gt; with that and retry.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="24064" LastEditorUserId="4854" LastEditDate="2016-08-07T08:51:03.693" LastActivityDate="2016-08-07T08:51:03.693" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28096" PostTypeId="2" ParentId="28077" CreationDate="2016-08-06T08:20:32.467" Score="2" Body="&lt;p&gt;This line &lt;code&gt;pinMode(i, OUTPUT);&lt;/code&gt; should probably be replaced by &lt;code&gt;pinMode(ledPin[i], OUTPUT);&lt;/code&gt;&#xA;Otherwise it won't make sense.&lt;/p&gt;&#xA;" OwnerUserId="6826" LastActivityDate="2016-08-06T08:20:32.467" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28098" PostTypeId="1" CreationDate="2016-08-06T09:55:55.330" Score="0" ViewCount="862" Body="&lt;p&gt;So I want to do something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt;int PIN, int CHANNEL&amp;gt;&#xA;void initPin() {&#xA;    attachInterrupt(PIN, rising&amp;lt;PIN, CHANNEL&amp;gt;, RISING);&#xA;}&#xA;&#xA;&#xA;template&amp;lt;int PIN, int CHANNEL&amp;gt;&#xA;void rising() {&#xA;    startTimes[CHANNEL] = micros();&#xA;    attachInterrupt(PIN, falling&amp;lt;PIN, CHANNEL&amp;gt;, FALLING);&#xA;}&#xA;&#xA;template&amp;lt;int PIN, int CHANNEL&amp;gt;&#xA;void falling() {&#xA;    values[CHANNEL] = micros() - startTimes[CHANNEL];&#xA;    attachInterrupt(PIN, rising&amp;lt;PIN, CHANNEL&amp;gt;, RISING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but the compiler gives me this error&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;no matches converting function ‘rising’ to type ‘void (*)()’&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can I even do this, or do I have to write all the functions by myself?&lt;/p&gt;&#xA;" OwnerUserId="23994" LastEditorUserId="23994" LastEditDate="2016-08-06T10:02:22.757" LastActivityDate="2020-02-27T11:47:33.950" Title="Pass templated function as attachInterrupt parameter" Tags="|c++|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28100" PostTypeId="1" CreationDate="2016-08-06T10:59:31.763" Score="2" ViewCount="3645" Body="&lt;p&gt;hello guys is there someone who can help me with my first project.&#xA;its basically about logic circuits.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;by using tact switch and pull-up resistor to set the values to logical 1 or 0.&#xA;the output can be verified by using a LED as an indicator.&#xA;so the code goes like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//AND GATE          &#xA;int pin2=1;         //set pin2=1&#xA;int pin3=1;         //set pin3=1&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(2,INPUT);&#xA;pinMode(3,INPUT);&#xA;pinMode(4,OUTPUT);&#xA;pinMode(11,OUTPUT);    &#xA;pinMode(12,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  pin2=digitalRead(2);&#xA;  pin3=digitalRead(3);&#xA;&#xA; if(pin2==1)            //turn led on pin11 when pin2 =1&#xA; {&#xA; digitalWrite(11,HIGH);&#xA; }&#xA; else&#xA; {&#xA; digitalWrite(11,LOW);&#xA; }&#xA;&#xA; if(pin3==1)          ////turn led on pin12 when pin3 =1&#xA; {&#xA;   digitalWrite(12,HIGH);&#xA; }&#xA; else&#xA; {&#xA;   digitalWrite(12,LOW);&#xA; }&#xA;&#xA;//TRUTH TABLE OF AND &#xA;&#xA;  if(pin2 &amp;amp;&amp;amp; pin3)       &#xA;  {&#xA;    digitalWrite(4,HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;  digitalWrite(4,LOW);&#xA;  }&#xA;}&#xA;&#xA;//OR GATE          &#xA;int pin2=1;&#xA;int pin3=1;&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(2,INPUT);&#xA;pinMode(3,INPUT);&#xA;pinMode(4,OUTPUT);&#xA;pinMode(11,OUTPUT);&#xA;pinMode(12,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  pin2=digitalRead(2);&#xA;  pin3=digitalRead(3);&#xA;&#xA; if(pin2==1)            &#xA; {&#xA; digitalWrite(11,HIGH);&#xA; }&#xA; else&#xA; {&#xA; digitalWrite(11,LOW);&#xA; }&#xA;&#xA; if(pin3==1)          &#xA; {&#xA;   digitalWrite(12,HIGH);&#xA; }&#xA; else&#xA; {&#xA;   digitalWrite(12,LOW);&#xA; }&#xA;&#xA;//TRUTH TABLE OF OR &#xA;&#xA;  if(pin2 || pin3)       &#xA;  {&#xA;    digitalWrite(4,HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;  digitalWrite(4,LOW);&#xA;  }&#xA;}&#xA;&#xA;//NAND GATE          &#xA;int pin2=1;&#xA;int pin3=1;&#xA;&#xA;void setup()&#xA;{&#xA;pinMode(2,INPUT);&#xA;pinMode(3,INPUT);&#xA;pinMode(4,OUTPUT);&#xA;pinMode(11,OUTPUT);&#xA;pinMode(12,OUTPUT);&#xA;}&#xA;void loop()&#xA;{&#xA;  pin2=digitalRead(2);&#xA;  pin3=digitalRead(3);&#xA;&#xA; if(pin2==1)            &#xA; {&#xA; digitalWrite(11,HIGH);&#xA; }&#xA; else&#xA; {&#xA; digitalWrite(11,LOW);&#xA; }&#xA;&#xA; if(pin3==1)          &#xA; {&#xA;   digitalWrite(12,HIGH);&#xA; }&#xA; else&#xA; {&#xA;   digitalWrite(12,LOW);&#xA; }&#xA;&#xA;//TRUTH TABLE OF NAND &#xA;&#xA;  if(!(pin2 &amp;amp;&amp;amp; pin3))       &#xA;  {&#xA;    digitalWrite(4,HIGH);&#xA;  }&#xA;  else&#xA;  {&#xA;  digitalWrite(4,LOW);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;can you guys help me to run this in one sketch by using tact switch  to select the logic gate to be tested or run? thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="25550" LastEditorUserId="23841" LastEditDate="2016-08-06T12:11:10.687" LastActivityDate="2016-08-06T14:31:23.020" Title="Testing Logic Gates using Arduino" Tags="|arduino-uno|led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28101" PostTypeId="2" ParentId="28100" CreationDate="2016-08-06T12:11:38.730" Score="1" Body="&lt;p&gt;What about something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const uint8_t    inA =  2;&#xA;const uint8_t    inB =  3;&#xA;const uint8_t   outA =  4;&#xA;const uint8_t   outB = 11;&#xA;const uint8_t   outY = 12;&#xA;const uint8_t button =  5;&#xA;&#xA;void setup() {&#xA;    pinMode(inA, INPUT_PULLUP);&#xA;    pinMode(inB, INPUT_PULLUP);&#xA;    pinMode(outA, OUTPUT);&#xA;    pinMode(outB, OUTPUT);&#xA;    pinMode(outY, OUTPUT);&#xA;&#xA;    pinMode(button, INPUT_PULLUP);&#xA;}&#xA;&#xA;uint32_t check_time = 0;&#xA;&#xA;uint8_t     counter = 0;&#xA;uint8_t       funct = 0b0110; // start with XOR  &#xA;&#xA;void loop() {&#xA;    // active low: (for usage with buttons connected to ground with internal pullup)&#xA;    // uint8_t state = (digitalRead(inA)==LOW) | (digitalRead(inB)==LOW)&amp;lt;&amp;lt;1;&#xA;&#xA;    // active high:&#xA;    uint8_t state = (digitalRead(inA)==HIGH) | (digitalRead(inB)==HIGH)&amp;lt;&amp;lt;1;&#xA;&#xA;    digitalWrite(outA, (state &amp;amp; 1) &amp;gt; 0);&#xA;    digitalWrite(outB, (state &amp;amp; 2) &amp;gt; 0);&#xA;&#xA;    digitalWrite(outY, ((funct &amp;gt;&amp;gt; state) &amp;amp; 1) &amp;gt; 0);&#xA;&#xA;&#xA;    // button handling&#xA;    uint32_t actual = millis();&#xA;    if (actual &amp;gt; check_time) {&#xA;        check_time = actual + 4; // check every 4ms&#xA;&#xA;        if (digitalRead(button) == LOW) { // expects pull-up and active low&#xA;            if (++counter == 4) { // debounce - confirmed after 16ms (4*4) and every 256*4 ms again&#xA;                funct = (funct + 1) &amp;amp; 0xF;&#xA;            }&#xA;        } else {&#xA;            counter = 0; // reset counter&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It uses push button to cycle through all 16 possible functions of two inputs.&#xA;Default is XOR. Assumption is Active HIGH inputs (you can use INPUT instead of INPUT_PULLUP).&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-06T12:11:38.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28102" PostTypeId="2" ParentId="28100" CreationDate="2016-08-06T12:59:13.633" Score="1" Body="&lt;p&gt;For simulating different gates with the same program, an option is to&#xA;use the serial port to tell it what gate you want it to simulate. Here I&#xA;am also using a function pointer (called &lt;code&gt;gate&lt;/code&gt;) to represent the&#xA;selected gate:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Wiring. */&#xA;const int inputA    = 2;&#xA;const int inputB    = 3;&#xA;const int outputA   = 11;&#xA;const int outputB   = 12;&#xA;const int outputRes = 4;&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode(inputA,    INPUT_PULLUP);&#xA;    pinMode(inputB,    INPUT_PULLUP);&#xA;    pinMode(outputA,   OUTPUT);&#xA;    pinMode(outputB,   OUTPUT);    &#xA;    pinMode(outputRes, OUTPUT);&#xA;    Serial.begin(9600);&#xA;    Serial.println(F(&quot;Type 'a'(for AND), 'o' (OR) or 'n' (NAND).&quot;));&#xA;}&#xA;&#xA;/* Available gates. */&#xA;bool AND(bool a, bool b)  { return a &amp;amp;&amp;amp; b; }&#xA;bool OR(bool a, bool b)   { return a || b; }&#xA;bool NAND(bool a, bool b) { return !(a &amp;amp;&amp;amp; b); }&#xA;&#xA;/* The gate we want to test. */&#xA;bool (*gate)(bool a, bool b) = AND;&#xA;&#xA;void loop()&#xA;{&#xA;    // Select the gate through the serial port.&#xA;    switch (Serial.read()) {&#xA;        case 'a': gate = AND;  Serial.println(&quot;AND&quot;);  break;&#xA;        case 'o': gate = OR;   Serial.println(&quot;OR&quot;);   break;&#xA;        case 'n': gate = NAND; Serial.println(&quot;NAND&quot;); break;&#xA;    }&#xA;&#xA;    // Simulate the gate.&#xA;    bool a = !digitalRead(inputA);  // input is in negative logic&#xA;    bool b = !digitalRead(inputB);&#xA;    digitalWrite(outputA, a);&#xA;    digitalWrite(outputB, b);&#xA;    digitalWrite(outputRes, gate(a, b));&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is another version, that uses an &lt;code&gt;enum&lt;/code&gt; instead of a function&#xA;pointer to identify the gate. The constants and the &lt;code&gt;setup()&lt;/code&gt; are the&#xA;same as before, then:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;    // The gate we want to test.&#xA;    static enum { AND, OR, NAND } gate;&#xA;&#xA;    // Select the gate through the serial port.&#xA;    switch (Serial.read()) {&#xA;        case 'a': gate = AND;  Serial.println(&quot;AND&quot;);  break;&#xA;        case 'o': gate = OR;   Serial.println(&quot;OR&quot;);   break;&#xA;        case 'n': gate = NAND; Serial.println(&quot;NAND&quot;); break;&#xA;    }&#xA;&#xA;    // Simulate the gate.&#xA;    bool a = !digitalRead(inputA);  // input is in negative logic&#xA;    bool b = !digitalRead(inputB);&#xA;    digitalWrite(outputA, a);&#xA;    digitalWrite(outputB, b);&#xA;    bool res = false;&#xA;    switch (gate) {&#xA;        case AND:  res = a &amp;amp;&amp;amp; b;    break;&#xA;        case OR:   res = a || b;    break;&#xA;        case NAND: res = !(a &amp;amp;&amp;amp; b); break;&#xA;    }&#xA;    digitalWrite(outputRes, res);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-08-06T14:31:23.020" LastActivityDate="2016-08-06T14:31:23.020" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28103" PostTypeId="2" ParentId="28092" CreationDate="2016-08-06T13:51:08.633" Score="9" Body="&lt;p&gt;&lt;code&gt;% 10&lt;/code&gt; returns the final digit of a number. Dividing by 10 shifts the number one digit to the right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if you have the number 10250 as an integer you can get at each number with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10250 % 10 = 0&#xA;(10250 / 10) % 10 = 5&#xA;(10250 / 100) % 10 = 2&#xA;(10250 / 1000) % 10 = 0&#xA;(10250 / 10000) % 10 = 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So your code could be written as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;num4 = (fm_station / 10) % 10;&#xA;num3 = (fm_station / 100) % 10;&#xA;num2 = (fm_station / 1000) % 10;&#xA;num1 = (fm_station / 10000) % 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No need to mess with &quot;part&quot; variables.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-06T13:51:08.633" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28105" PostTypeId="2" ParentId="28098" CreationDate="2016-08-06T14:42:15.267" Score="1" Body="&lt;p&gt;Try this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template&amp;lt;int PIN, int CHANNEL&amp;gt; void initPin() {&#xA;    attachInterrupt(PIN, rising&amp;lt;PIN, CHANNEL&amp;gt;, RISING);&#xA;}&#xA;&#xA;&#xA;template&amp;lt;int PIN, int CHANNEL&amp;gt; void rising() {&#xA;    startTimes[CHANNEL] = micros();&#xA;    attachInterrupt(PIN, falling&amp;lt;PIN, CHANNEL&amp;gt;, FALLING);&#xA;}&#xA;&#xA;template&amp;lt;int PIN, int CHANNEL&amp;gt; void falling() {&#xA;    values[CHANNEL] = micros() - startTimes[CHANNEL];&#xA;    attachInterrupt(PIN, rising&amp;lt;PIN, CHANNEL&amp;gt;, RISING);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is actually the Arduino preprocessor. It adds illegal forward declarations if template functions are formated as your original code. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-06T14:42:15.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28106" PostTypeId="1" CreationDate="2016-08-06T14:52:47.997" Score="0" ViewCount="108" Body="&lt;p&gt;I am running a simple servo program that swings the servo back and forth, it is essentially pressing a button continuously. However, after some time the servo stops moving and it seems like the code stops. I have no code in the program to tell it to stop and I am uploading from a sketch. Can anyone tell me why the servo will stop after some amount of time? is this some kind of safety or programmatic end that is used when you use the sketch compiler to run code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;int servoPin = 9;&#xA;Servo servo;&#xA;&#xA;int servoAngle = 0;&#xA;&#xA;void setup() {&#xA;    // put your setup code here, to run once:&#xA;    Serial.begin(9600);&#xA;    servo.attach(servoPin);&#xA;}&#xA;&#xA;void loop() {&#xA;    // put your main code here, to run repeatedly:&#xA;&#xA;    int randnum = rand()%(40000-1000 + 1) + 1000;&#xA;    int randnumreturn = rand()%(600-350 + 1) + 350;&#xA;    servo.write(45);&#xA;    delay(randnum);&#xA;    servo.write(22);&#xA;    delay(randnumreturn); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25553" LastEditorUserId="84" LastEditDate="2016-08-07T08:21:51.173" LastActivityDate="2016-08-07T09:06:08.000" Title="Arduino servo seems to time out after code runs for some amount of time" Tags="|arduino-uno|servo|time|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28107" PostTypeId="1" AcceptedAnswerId="28108" CreationDate="2016-08-06T16:07:07.867" Score="0" ViewCount="4457" Body="&lt;p&gt;I have arduino uno and I've bought &lt;a href=&quot;https://www.amazon.co.uk/12-Volt-350-GPH-Seaflo-Electric-Bilge/dp/B00OCHCRBC&quot; rel=&quot;nofollow&quot;&gt;12 Volt/350 GPH Seaflo Electric Bilge Pump&lt;/a&gt;, how to control it directly from arduino?&lt;/p&gt;&#xA;" OwnerUserId="25556" LastActivityDate="2016-08-06T16:27:05.533" Title="How to control 12v water pump by arduino?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28108" PostTypeId="2" ParentId="28107" CreationDate="2016-08-06T16:22:47.433" Score="0" Body="&lt;p&gt;It's not possible to control it directly. You need relay module (better one is with opto coupler).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use some N-Mosfet like IRF540 with antiparallel fast diode to supress induced high voltage from coil. However arduino output might be weak for fast charge/discharge mosfets gate and it gets hot.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-06T16:22:47.433" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28110" PostTypeId="2" ParentId="28063" CreationDate="2016-08-06T17:06:59.803" Score="1" Body="&lt;p&gt;Wiring on the photo and description you provided are not consistent. On the photo, LCD-RS (PIN 4) is connected to &lt;code&gt;D12&lt;/code&gt; and LCD-E (PIN 6) is connected to &lt;code&gt;D11&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If so, initialization must be &lt;code&gt;LiquidCrystal lcd(12, 11, 5, 4, 3, 2);&lt;/code&gt;&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-08-06T17:06:59.803" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28111" PostTypeId="1" AcceptedAnswerId="28122" CreationDate="2016-08-06T17:48:17.663" Score="0" ViewCount="1656" Body="&lt;p&gt;I am far from being an Arduino specialist, so please bear with me if some of my code below is far from correct.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am writing a sketch in which I need to use 3 instances of the &lt;a href=&quot;https://github.com/bogde/HX711&quot; rel=&quot;nofollow&quot;&gt;HX711 library&lt;/a&gt;, as I am using 3 different weight sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to try to clean up the code, I want to put basically all the code using HX711 in my own class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is what my ScaleMeasure.h looks like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// ScaleMeasure.h&#xA;#ifndef _SCALEMEASURE_h&#xA;#define _SCALEMEASURE_h&#xA;&#xA;#if defined(ARDUINO) &amp;amp;&amp;amp; ARDUINO &amp;gt;= 100&#xA;    #include &quot;arduino.h&quot;&#xA;#else&#xA;    #include &quot;WProgram.h&quot;&#xA;#endif&#xA;&#xA;#include &amp;lt;CmdMessenger.h&amp;gt;&#xA;#include &quot;HX711.h&quot;&#xA;&#xA;class ScaleMeasure&#xA;{&#xA; public:&#xA;    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); &#xA;    void Setup();   &#xA;    float Measure();    &#xA;&#xA;private:&#xA;    int _dout_pin;&#xA;    int _clk_pin;&#xA;    float _calibration_factor;&#xA;    byte _scaleID;&#xA;    HX711 _scale = HX711(_dout_pin, _clk_pin);  &#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and .cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;ScaleMeasure.h&quot;&#xA;&#xA;ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)&#xA;{&#xA;    _clk_pin = Clk;&#xA;    _dout_pin = Dout;   &#xA;    _calibration_factor = CalibF;&#xA;    _scaleID = ScaleID;     &#xA;}&#xA;&#xA;void ScaleMeasure::Setup()&#xA;{       &#xA;    _scale.power_up();&#xA;    _scale.set_scale();&#xA;    _scale.set_scale(_calibration_factor);&#xA;    _scale.tare();&#xA;    _scale.read();&#xA;}&#xA;&#xA;float ScaleMeasure::Measure()&#xA;{   &#xA;    return _scale.get_units(5);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but there is obviously something wrong, as a call to the constructor lock the rest of the program. I believe that my instantiation, of HX711 in ScaleMeasure.h  &lt;code&gt;HX711 _scale = HX711(_dout_pin, _clk_pin);&lt;/code&gt; is not correct, or not in the right place. The code compile fine, though.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help.&lt;/p&gt;&#xA;" OwnerUserId="21020" LastActivityDate="2016-08-07T12:02:32.603" Title="Initialize a class (HX711) within a class with constructor and parameters" Tags="|arduino-uno|class|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28112" PostTypeId="2" ParentId="26351" CreationDate="2016-08-06T18:07:49.913" Score="1" Body="&lt;p&gt;I had same problem and I think I have solved it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In boards.txt file, I had:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;##############################################################&#xA;&#xA;diecimila.name=Arduino Duemilanove or Diecimila&#xA;&#xA;diecimila.upload.tool=avrdude diecimila.upload.protocol=arduino&#xA;&#xA;diecimila.bootloader.tool=avrdude diecimila.bootloader.low_fuses=0xFF&#xA;diecimila.bootloader.unlock_bits=0x3F&#xA;diecimila.bootloader.lock_bits=0x0F&#xA;&#xA;diecimila.build.f_cpu=16000000L diecimila.build.board=AVR_DUEMILANOVE&#xA;diecimila.build.core=arduino diecimila.build.variant=standard&#xA;&#xA;## Arduino Duemilanove or Diecimila w/ ATmega328&#xA;## --------------------------------------------- diecimila.menu.cpu.atmega328=ATmega328&#xA;&#xA;diecimila.menu.cpu.atmega328.upload.maximum_size=30720&#xA;diecimila.menu.cpu.atmega328.upload.maximum_data_size=2048&#xA;diecimila.menu.cpu.atmega328.upload.speed=57600&#xA;&#xA;diecimila.menu.cpu.atmega328.bootloader.high_fuses=0xDA&#xA;diecimila.menu.cpu.atmega328.bootloader.extended_fuses=0x05&#xA; diecimila.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex&#xA;&#xA;diecimila.menu.cpu.atmega328.build.mcu=atmega328p&#xA;&#xA;## Arduino Duemilanove or Diecimila w/ ATmega168&#xA;## --------------------------------------------- diecimila.menu.cpu.atmega168=ATmega168&#xA;&#xA;diecimila.menu.cpu.atmega168.upload.maximum_size=14336&#xA;diecimila.menu.cpu.atmega168.upload.maximum_data_size=1024&#xA;diecimila.menu.cpu.atmega168.upload.speed=19200&#xA;&#xA;diecimila.menu.cpu.atmega168.bootloader.high_fuses=0xdd&#xA;diecimila.menu.cpu.atmega168.bootloader.extended_fuses=0x00&#xA; diecimila.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex&#xA;&#xA;diecimila.menu.cpu.atmega168.build.mcu=atmega168&#xA;&#xA;##############################################################&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have replaced the line containing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diecimila.menu.cpu.atmega328.bootloader.extended_fuses=0x05&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;diecimila.menu.cpu.atmega328.bootloader.extended_fuses=0xFD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Everything is ok now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can install boot loader on an ATMEGA328P (with an usbasp programmer), and I can install sketchs after that (via usb serial).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know if it's the best way to solve the problem, but it works.&#xA;Hope this will help you, if not already solved.&lt;/p&gt;&#xA;" OwnerUserId="25552" LastEditorUserId="84" LastEditDate="2016-08-07T08:35:01.593" LastActivityDate="2016-08-07T08:35:01.593" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28113" PostTypeId="2" ParentId="28111" CreationDate="2016-08-06T18:29:40.090" Score="0" Body="&lt;p&gt;The line&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HX711 _scale = HX711(_dout_pin, _clk_pin);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;would be executed at construction time, which is the wrong time for it to run since &lt;code&gt;_dout_pin&lt;/code&gt; and &lt;code&gt;_clk_pin&lt;/code&gt; won't be set. Instead (much as it pains me to recommend it) you will have to use dynamic allocation:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HX711 *_scale;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can, in your constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_scale = new HX711(_dout_pin, _clk_pin);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since you now have a pointer all your accesses to it need to change to &lt;code&gt;-&amp;gt;&lt;/code&gt; instead of &lt;code&gt;.&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;_scale-&amp;gt;power_up();&#xA;... etc ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also you should add a destructor to your class that deletes the object pointed to by &lt;code&gt;_scale&lt;/code&gt; if it has been created.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-06T18:29:40.090" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28114" PostTypeId="2" ParentId="28111" CreationDate="2016-08-06T18:30:12.420" Score="1" Body="&lt;p&gt;Unfortunatly HX711 has no default constructor. So the easiest way would be to add one in the header:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HX711() {} // default constructor, empty&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Add member function to do the init job (done by original constructor), also in the header file&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    void Init(byte dout, byte pd_sck, byte gain = 128) {&#xA;    PD_SCK  = pd_sck;&#xA;    DOUT    = dout;&#xA;&#xA;    pinMode(PD_SCK, OUTPUT);&#xA;    pinMode(DOUT, INPUT);&#xA;&#xA;    set_gain(gain);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now your ScaleMeasure class will be like (header):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class ScaleMeasure&#xA;{&#xA; public:&#xA;    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); &#xA;    void Setup();   &#xA;    float Measure();    &#xA;&#xA;private:&#xA;    int _dout_pin;&#xA;    int _clk_pin;&#xA;    float _calibration_factor;&#xA;    byte _scaleID;&#xA;    HX711 _scale;  &#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and cpp&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)&#xA;{&#xA;    _clk_pin = Clk;&#xA;    _dout_pin = Dout;&#xA;&#xA;    _scale.Init(_dout_pin, _clk_pin);  &#xA;&#xA;    _calibration_factor = CalibF;&#xA;    _scaleID = ScaleID;     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-08-06T18:30:12.420" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28117" PostTypeId="2" ParentId="27012" CreationDate="2016-08-06T20:19:03.250" Score="0" Body="&lt;p&gt;It is easier than I thought! I soldered audio jack to MIC+GND, inserted microphone in and it works!&#xA;And pretty well :-)&#xA;Cheap random lavalier model: Panasonic RP-VC201. I guess any consumer model will do.&lt;/p&gt;&#xA;" OwnerUserId="23977" LastActivityDate="2016-08-06T20:19:03.250" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28118" PostTypeId="2" ParentId="28106" CreationDate="2016-08-06T21:09:43.407" Score="2" Body="&lt;p&gt;&lt;code&gt;int&lt;/code&gt; in AVR architecture is signed 16 bits. This means 40000 is actually an overflow if it gets assigned to an integer. It would work in most cases, but when the resultant number is &lt;code&gt;&amp;gt; 32767&lt;/code&gt;, you would get a minus value, which may cause delay not to work properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to solve the issue, you may either use long int for randnum or use a random interval smaller than 32768.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; I did some calculation, if you hit exactly 40000 you would delay for 4294974529 milliseconds (+/-1). Any value over 32767 will cause delays that are extremely long.&lt;/p&gt;&#xA;" OwnerUserId="25559" LastEditorUserId="25559" LastEditDate="2016-08-07T09:06:08.000" LastActivityDate="2016-08-07T09:06:08.000" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28119" PostTypeId="1" AcceptedAnswerId="28276" CreationDate="2016-08-07T03:34:33.433" Score="0" ViewCount="115" Body="&lt;p&gt;I am trying to control an app on OSX with an Arduino Uno.  Specifically, I would like to start and stop play of an MP3 on iTunes, or a track on Spotify, using an Arduino connected to the Apple computer with USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any suggestions would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="25562" LastActivityDate="2016-09-11T12:08:46.887" Title="Controlling an OSX app by Arduino" Tags="|arduino-uno|serial|osx|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28120" PostTypeId="2" ParentId="28090" CreationDate="2016-08-07T03:45:10.260" Score="1" Body="&lt;p&gt;This sounds very much like the problem I had when I updated my ARV version,I was also getting &quot;no programmer has been specified error&quot;, I run Windows 7 32bit, the way i got out of it was to go back to the update screen when it pops up and in Arduino ARV Boards area....select versions....I went back to version 1.6.10...now it all works again.....at this point I am no longer updating my ARV, but I will after a few more version updates come out, there is obviously something that conflicts at this stage, if you google the problem you will find other of ways to fix this.&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-07T03:45:10.260" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28121" PostTypeId="2" ParentId="28063" CreationDate="2016-08-07T03:57:15.670" Score="2" Body="&lt;p&gt;I realize that your question is based around using multiple connections to the arduino, however if you wish to simplify the setup/operation have a good look into I2C interface, this only uses 2 pins SDA and SCL to operate, you can get an interface board on Ebay for $1.00....just a thought.&lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-07T03:57:15.670" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28122" PostTypeId="2" ParentId="28111" CreationDate="2016-08-07T08:41:41.037" Score="1" Body="&lt;p&gt;The right way, in C++, to properly construct a field member &lt;code&gt;b&lt;/code&gt; (of type class &lt;code&gt;B&lt;/code&gt;) inside a class &lt;code&gt;A&lt;/code&gt; is to do it as follows in &lt;code&gt;A&lt;/code&gt;'s constructor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A::A() : b(...) {&#xA;    // Other init code here&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In your situation that would mean:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class ScaleMeasure&#xA;{&#xA; public:&#xA;    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); &#xA;    void Setup();   &#xA;    float Measure();    &#xA;&#xA;private:&#xA;    int _dout_pin;&#xA;    int _clk_pin;&#xA;    float _calibration_factor;&#xA;    byte _scaleID;&#xA;    HX711 _scale;  &#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that I have removed the init part for &lt;code&gt;_scale&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)&#xA;: _scale(Dout, CLk)&#xA;{&#xA;    _clk_pin = Clk;&#xA;    _dout_pin = Dout;   &#xA;    _calibration_factor = CalibF;&#xA;    _scaleID = ScaleID;     &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="84" LastEditorUserId="84" LastEditDate="2016-08-07T12:02:32.603" LastActivityDate="2016-08-07T12:02:32.603" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28123" PostTypeId="2" ParentId="5430" CreationDate="2016-08-07T09:39:17.350" Score="4" Body="&lt;p&gt;I'm adding another answer, because I don't think the core thing to grasp is mentioned, and others might benefit :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The noise you are seeing, is actually the result of a feature of the RXB6, KSA6, and similar modules. When they see no signal, they increase gain/sensitivity until they do see a signal. The upside of this is they are very sensitive, and can operate well over quite long ranges. The downside is that if there really is no signal, they will start picking up anything that remotely looks like a signal, the noise you see :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Dealing with this noise is the job of the software/protocol and other electronics built around the receiver.&#xA;A common way to solve it, which the VirtualWire library also uses, is to send some unimportant 'data' first, which makes the receiver decrease it's sensitivity, and then send the  important data.&#xA;Another common way is to just repeat the data several times, this is also what your wall sockets most likely do.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In software you can usually find the 'important' parts by looking at pulse lengths, the noise is usually short high pulses, most protocols use far longer pulses, which also have a predictable/defined length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I did in exactly your case was to dump the sound recording as a raw signed pcm 16 bit file, which I could then easily read into a bit of software I wrote, which find's the high/low transitions, filters out any short pulses, and then writes out the output (like a csv) you want :)&lt;/p&gt;&#xA;" OwnerUserId="23645" LastActivityDate="2016-08-07T09:39:17.350" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28124" PostTypeId="1" CreationDate="2016-08-07T09:52:59.300" Score="1" ViewCount="3003" Body="&lt;p&gt;I am using &lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B015SCPCIE&quot; rel=&quot;nofollow&quot;&gt;W5100 Ethernet Shield Network Module with arduino Uno &lt;/a&gt;as a webserver to trigger four relays connected to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The relays may be toggled through the four buttons attached to it physically, or through the four buttons on the hosted webpage. There is a counter how many times the relays are toggled which can be reset through a button on the webpage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is, whenever I toggle the relay through physical button, it does not update the counter on the webpage. And if I refresh the page, the last command from the page, such as togglerelay1 keeps echoing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What solution do you propose to this problem:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;int Relay1 = 2;&#xA;int Relay2 = 3;&#xA;int Relay3 = 4;&#xA;int Relay4 = 5;&#xA;int Button1 = 8;&#xA;int Button2 = 9;&#xA;int Button3 = 10;&#xA;int Button4 = 11;&#xA;&#xA;String on = &quot;On&quot;;&#xA;String off = &quot;Off&quot;;&#xA;&#xA;String Relay1Status = on;&#xA;String Relay2Status = on;&#xA;String Relay3Status = on;&#xA;String Relay4Status = on;&#xA;&#xA;int count1 = 0;&#xA;int count2 = 0;&#xA;int count3 = 0;&#xA;int count4 = 0;&#xA;&#xA;byte toggle1 = LOW;&#xA;byte toggle2 = LOW;&#xA;byte toggle3 = LOW;&#xA;byte toggle4 = LOW;&#xA;&#xA;void toggleRelay1();&#xA;void toggleRelay2();&#xA;void toggleRelay3();&#xA;void toggleRelay4();&#xA;&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address&#xA;byte ip[] = { 172, 168, 1, 178 };                      // ip in lan (that's what you need to use in your browser. (&quot;192.168.1.178&quot;)&#xA;byte gateway[] = { 172, 168, 1, 1 };                   // internet access via router&#xA;byte subnet[] = { 255, 255, 255, 0 };                  //subnet mask&#xA;EthernetServer server(80);                             //server port&#xA;String readString;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for Leonardo only&#xA;  }&#xA;  pinMode(Relay1, OUTPUT);&#xA;  pinMode(Relay2, OUTPUT);&#xA;  pinMode(Relay3, OUTPUT);&#xA;  pinMode(Relay4, OUTPUT);&#xA;  pinMode(Button1, INPUT_PULLUP);&#xA;  pinMode(Button2, INPUT_PULLUP);&#xA;  pinMode(Button3, INPUT_PULLUP);&#xA;  pinMode(Button4, INPUT_PULLUP);&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac, ip, gateway, subnet);&#xA;  server.begin();&#xA;  Serial.print(&quot;server is at &quot;);&#xA;  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  if (digitalRead(Button1) == LOW) {&#xA;    toggleRelay1();&#xA;    while (digitalRead(Button1) == LOW);&#xA;  }&#xA;  if (digitalRead(Button2) == LOW) {&#xA;    toggleRelay2();&#xA;    while (digitalRead(Button2) == LOW);&#xA;  }&#xA;  if (digitalRead(Button3) == LOW) {&#xA;    toggleRelay3();&#xA;    while (digitalRead(Button3) == LOW);&#xA;  }&#xA;  if (digitalRead(Button4) == LOW) {&#xA;    toggleRelay4();&#xA;    while (digitalRead(Button4) == LOW);&#xA;  }&#xA;&#xA;  // Create a client connection&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;&#xA;        //read char by char HTTP request&#xA;        if (readString.length() &amp;lt; 100) {&#xA;          //store characters to string&#xA;          readString += c;&#xA;          //Serial.print(c);&#xA;        }&#xA;&#xA;        //if HTTP request has ended&#xA;        if (c == '\n') {&#xA;          Serial.println(readString); //print to serial monitor for debuging&#xA;          homepage();&#xA;          //controls the Arduino if you press the buttons&#xA;          if (readString.indexOf(&quot;?resetcount1&quot;) &amp;gt; 0) {&#xA;            count1 = 0;&#xA;          }&#xA;          if (readString.indexOf(&quot;?resetcount2&quot;) &amp;gt; 0) {&#xA;            count2 = 0;&#xA;          }&#xA;          if (readString.indexOf(&quot;?resetcount3&quot;) &amp;gt; 0) {&#xA;            count3 = 0;&#xA;          }&#xA;          if (readString.indexOf(&quot;?resetcount4&quot;) &amp;gt; 0) {&#xA;            count4 = 0;&#xA;          }&#xA;          if (readString.indexOf(&quot;?togglerelay1&quot;) &amp;gt; 0) {&#xA;            toggleRelay1();&#xA;          }&#xA;          if (readString.indexOf(&quot;?togglerelay2&quot;) &amp;gt; 0) {&#xA;            toggleRelay2();&#xA;          }&#xA;          if (readString.indexOf(&quot;?togglerelay3&quot;) &amp;gt; 0) {&#xA;            toggleRelay3();&#xA;          }&#xA;          if (readString.indexOf(&quot;?togglerelay4&quot;) &amp;gt; 0) {&#xA;            toggleRelay4();&#xA;          }&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;  //clearing string for next read&#xA;  readString = &quot;&quot;;&#xA;&#xA;}&#xA;&#xA;void toggleRelay1() {&#xA;  toggle1 = !toggle1;&#xA;  digitalWrite(Relay1, toggle1);&#xA;  if (toggle1 == HIGH) {&#xA;    count1++;&#xA;    Relay1Status = on;&#xA;  }&#xA;  else&#xA;    Relay1Status = off;&#xA;}&#xA;&#xA;void toggleRelay2() {&#xA;  toggle2 = !toggle2;&#xA;  digitalWrite(Relay2, toggle2);&#xA;  if (toggle2 == HIGH) {&#xA;    count2++;&#xA;    Relay2Status = on;&#xA;  }&#xA;  else&#xA;    Relay2Status = off;&#xA;}&#xA;&#xA;void toggleRelay3() {&#xA;  toggle3 = !toggle3;&#xA;  digitalWrite(Relay3, toggle3);&#xA;  if (toggle3 == HIGH) {&#xA;    count3++;&#xA;    Relay3Status = on;&#xA;  }&#xA;  else&#xA;    Relay3Status = off;&#xA;}&#xA;&#xA;void toggleRelay4() {&#xA;  toggle4 = !toggle4;&#xA;  digitalWrite(Relay4, toggle4);&#xA;  if (toggle4 == HIGH) {&#xA;    count4++;&#xA;    Relay4Status = on;&#xA;  }&#xA;  else&#xA;    Relay4Status = off;&#xA;}&#xA;&#xA;void homepage() {&#xA;  client.println(&quot;HTTP/1.1 200 OK&quot;); //send new page&#xA;  client.println(&quot;Content-Type: text/html&quot;);&#xA;  client.println(&quot;Connection: Close&quot;);&#xA;  client.println();&#xA;  client.println(&quot;&amp;lt;HTML&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;HEAD&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;meta name='apple-mobile-web-app-capable' content='yes' /&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' /&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' /&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;TITLE&amp;gt;Relay Control System&amp;lt;/TITLE&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;/HEAD&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;BODY&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;H1&amp;gt;Relay Control System&amp;lt;/H1&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;hr /&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;H2&amp;gt;Relays Status&amp;lt;/H2&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Relay 1 Status: &quot;);&#xA;  client.println(Relay1Status);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Relay 2 Status: &quot;);&#xA;  client.println(Relay2Status);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Relay 3 Status: &quot;);&#xA;  client.println(Relay3Status);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Relay 4 Status: &quot;);&#xA;  client.println(Relay4Status);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Number of times Relay1 has been activated: &quot;);&#xA;  client.println(count1);&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?resetcount1\&quot;\&quot;&amp;gt;Reset Counter&amp;lt;/a&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Number of times Relay2 has been activated: &quot;);&#xA;  client.println(count2);&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?resetcount2\&quot;\&quot;&amp;gt;Reset Counter&amp;lt;/a&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Number of times Relay3 has been activated: &quot;);&#xA;  client.println(count3);&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?resetcount3\&quot;\&quot;&amp;gt;Reset Counter&amp;lt;/a&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;Number of times Relay4 has been activated: &quot;);&#xA;  client.println(count4);&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?resetcount4\&quot;\&quot;&amp;gt;Reset Counter&amp;lt;/a&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?togglerelay1\&quot;\&quot;&amp;gt;Toggle Relay1&amp;lt;/a&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?togglerelay2\&quot;\&quot;&amp;gt;Toggle Relay2&amp;lt;/a&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?togglerelay3\&quot;\&quot;&amp;gt;Toggle Relay3&amp;lt;/a&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;a href=\&quot;/?togglerelay4\&quot;\&quot;&amp;gt;Toggle Relay4&amp;lt;/a&amp;gt;&quot;);&#xA;&#xA;  client.println(&quot;&amp;lt;/BODY&amp;gt;&quot;);&#xA;  client.println(&quot;&amp;lt;/HTML&amp;gt;&quot;);&#xA;&#xA;  delay(1);&#xA;  //stopping client&#xA;  client.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25563" LastActivityDate="2017-02-04T02:34:26.390" Title="Webserver on Arduino: Refresh issues" Tags="|arduino-uno|ethernet|web-server|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28125" PostTypeId="2" ParentId="28124" CreationDate="2016-08-07T10:22:35.310" Score="1" Body="&lt;p&gt;Instead of always responding with the &lt;code&gt;homepage()&lt;/code&gt; for every request you should respond specially to the command requests with a &lt;code&gt;307&lt;/code&gt; temporary redirect code to make the browser request the index page afresh&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;client.println(&quot;HTTP/1.1 307 Temporary Redirect&quot;);&#xA;client.println(&quot;Location: /&quot;);&#xA;client.println(&quot;Connection: Close&quot;);&#xA;client.println();&#xA;client.stop();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So the client gets &lt;code&gt;/?togglerelay3&lt;/code&gt;, which happens, and then gets sent a reply telling it to &lt;code&gt;make a new request to get /&lt;/code&gt; which it then does to get the new status. The URL in the browser will not have the &lt;code&gt;?togglerelay3&lt;/code&gt; in it, so refreshing won't cause the command to be run again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want live updating of the page with new count values as they happen you will have to be more cunning. Either use AJAX and JavaScript in the page to fetch new values to display, or periodically refresh the page (with a &lt;a href=&quot;https://en.wikipedia.org/wiki/Meta_refresh&quot; rel=&quot;nofollow&quot;&gt;META Refresh&lt;/a&gt;).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T10:22:35.310" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28127" PostTypeId="1" AcceptedAnswerId="28128" CreationDate="2016-08-07T11:14:48.577" Score="1" ViewCount="1446" Body="&lt;p&gt;I originally asked this &lt;a href=&quot;https://arduino.stackexchange.com/questions/28124/webserver-on-arduino-refresh-issues?newreg=fec67955f67e4baea0fc7402e8cb57da&quot;&gt;question.&lt;/a&gt; Regarding a webserver Refresh issue on arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am totally new to web development and ethernet. The answer from @Majenko is correct, but I do not understand how to implement it. Should I change the &lt;code&gt;homepage()&lt;/code&gt; function's first line to &lt;code&gt;HTTP/1.1 307 temporary redirect&lt;/code&gt; and use &lt;code&gt;META REFRESH&lt;/code&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do the &lt;code&gt;homepage()&lt;/code&gt; first using &lt;code&gt;HTTP/1.1 200 OK&lt;/code&gt; and then for all the following requests, use &lt;code&gt;HTTP/1.1 307 temporary redirect&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="25566" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-08-07T11:21:42.993" Title="Webserver on Arduino: How to 307 temporary redirect" Tags="|arduino-uno|ethernet|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28128" PostTypeId="2" ParentId="28127" CreationDate="2016-08-07T11:21:42.993" Score="0" Body="&lt;p&gt;You need to make a decision on what to respond with depending on what the request is you have received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you receive a &quot;command&quot; URL (which you already check for by looking for certain sub-strings) then you need to respond with the &lt;code&gt;307&lt;/code&gt; response. If you don't receive a &quot;command&quot; URL (so anything &lt;em&gt;except&lt;/em&gt; the things you are specifically looking for) then you respond with the homepage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A slight re-formatting of your decision code to use &lt;code&gt;else if&lt;/code&gt; instead of just &lt;code&gt;if&lt;/code&gt; would make it easier:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (c == '\n') {&#xA;  Serial.println(readString); //print to serial monitor for debuging&#xA;  // homepage(); &amp;lt;&amp;lt; This is now moved elsewhere.&#xA;  //controls the Arduino if you press the buttons&#xA;  if (readString.indexOf(&quot;?resetcount1&quot;) &amp;gt; 0) {&#xA;    count1 = 0;&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?resetcount2&quot;) &amp;gt; 0) {&#xA;    count2 = 0;&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?resetcount3&quot;) &amp;gt; 0) {&#xA;    count3 = 0;&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?resetcount4&quot;) &amp;gt; 0) {&#xA;    count4 = 0;&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?togglerelay1&quot;) &amp;gt; 0) {&#xA;    toggleRelay1();&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?togglerelay2&quot;) &amp;gt; 0) {&#xA;    toggleRelay2();&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?togglerelay3&quot;) &amp;gt; 0) {&#xA;    toggleRelay3();&#xA;    redirect();&#xA;  } else if (readString.indexOf(&quot;?togglerelay4&quot;) &amp;gt; 0) {&#xA;    toggleRelay4();&#xA;    redirect();&#xA;  } else { // If none of them match then send the homepage.&#xA;    homepage();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;redirect()&lt;/code&gt; is as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void redirect() {&#xA;  client.println(&quot;HTTP/1.1 307 Temporary Redirect&quot;);&#xA;  client.println(&quot;Location: /&quot;);&#xA;  client.println(&quot;Connection: Close&quot;);&#xA;  client.println();&#xA;  client.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T11:21:42.993" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28129" PostTypeId="1" AcceptedAnswerId="28130" CreationDate="2016-08-07T13:31:14.737" Score="0" ViewCount="14861" Body="&lt;p&gt;I've been using Arduino UNO for quite sometime and brought a new Arduino Nano. When I connected it to my computer, the power usb lit up and the blink sketch started running ( as expected of course).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I opened up the IDE and switched boards. But when I try to upload code to my Nano I get an error- &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;\.\COM3&quot;: The system cannot find the file specified.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Clearly the IDE can't see my board. Uploading to my UNO goes fine. The serial port option is greyed out so I can't change it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched extensively online for a solution and have found none. This must be either a very unique issue or a very simple one.&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2020-10-16T03:56:07.413" Title="Cannot upload sketch to Arduino Nano" Tags="|arduino-ide|arduino-nano|ide|windows|" AnswerCount="4" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="28130" PostTypeId="2" ParentId="28129" CreationDate="2016-08-07T14:57:35.727" Score="1" Body="&lt;p&gt;Firstly, you have a clone not a genuine Arduino Nano. They use a different USB chip and require different drivers. Install the CH340 drivers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Secondly your cable is bad. It sounds like one with no data wires in it used for powering or charging small low-powered devices like bluetooth headsets etc. Replace the cable with a proper one.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T14:57:35.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28131" PostTypeId="2" ParentId="28078" CreationDate="2016-08-07T16:36:57.933" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;This doesn't seem correct. In inverse logic the line is held high and a drop indicates a start bit.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, in inverse logic (for a UART) the line is held LOW and a rise indicates a start bit. The diagrams you show in your question show that UART communication normally is HIGH with LOW for a start bit.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It seems like it can't handle start bits followed by high bits since there would be no change in the pin state.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The PCINT is only used to identify the falling (or rising in the case of inverse logic) edge of the start bit. From then on it samples at pre-defined periods to read each bit. Accurate timing is needed for that, so assembly code is used to give precise delays (see &lt;code&gt;tunedDelay()&lt;/code&gt;). Once the whole 10-bit packet has been received the interrupt handler finishes and control is returned to the main thread again. The PCINT is then free to look for the next start bit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T16:36:57.933" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28132" PostTypeId="1" AcceptedAnswerId="28165" CreationDate="2016-08-07T16:38:10.940" Score="2" ViewCount="14022" Body="&lt;p&gt;I am trying to both send and receive data using bluetooth module.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Receiving data works fine with this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() { &#xA;    Serial1.begin(9600);&#xA;    Serial.begin(9600);&#xA;} &#xA;&#xA;void loop() { &#xA;    if (Serial1.available()) {&#xA;        Serial.println(Serial1.read());&#xA;    }&#xA;&#xA;    delay(20);                          &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But I cannot send any data. This is what I am doing:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() { &#xA;    if (Serial1.available()) {&#xA;       Serial.println(Serial1.read());&#xA;    }&#xA;&#xA;    delay(20);&#xA;&#xA;    if (digitalRead(bluetoothInput) == HIGH) {&#xA;        Serial1.write(&quot;2&quot;);&#xA;        // only &quot;send&quot; prints. Nothing in android terminal&#xA;        Serial.println(&quot;send!&quot;);&#xA;        delay(1000);&#xA;    }&#xA;&#xA;    delay(20);                            &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What am I doing wrong?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino Leonardo and Bluetooth terminal app on Android device.&lt;/p&gt;&#xA;" OwnerUserId="25568" LastEditorUserId="84" LastEditDate="2016-08-07T18:26:34.447" LastActivityDate="2016-08-08T14:55:55.700" Title="Sending data via bluetooth" Tags="|serial|bluetooth|arduino-leonardo|android|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28133" PostTypeId="1" AcceptedAnswerId="28137" CreationDate="2016-08-07T16:55:09.043" Score="8" ViewCount="9202" Body="&lt;p&gt;I declared my enum and called it Dir. I wanted to use value of that type in my function Move(). Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;enum Dir&#xA;{&#xA;  forward = 1,&#xA;  backward = 2,&#xA;  left = 3,&#xA;  right = 4&#xA;};&#xA;&#xA;void Move ( Dir direction , int distance )&#xA;{&#xA;     direction = forward;&#xA;}&#xA;&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately i get the following errors:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V2.ino:23:13: error: variable or field 'Move' declared void&#xA;V2.ino:23:13: error: 'Dir' was not declared in this scope&#xA;V2.ino:23:29: error: expected primary-expression before 'int'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What's wrong?&lt;/p&gt;&#xA;" OwnerUserId="23959" LastEditorUserId="23959" LastEditDate="2016-08-07T17:48:02.417" LastActivityDate="2016-08-07T18:46:05.030" Title="Can't use enum as function argument" Tags="|programming|" AnswerCount="4" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28134" PostTypeId="1" AcceptedAnswerId="28135" CreationDate="2016-08-07T17:53:04.103" Score="1" ViewCount="3166" Body="&lt;p&gt;I hope I can get some help on how to get this to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have multiple Sensors (32 of these) which values I want to read. I am using a master multiplexer &lt;strong&gt;HC4051&lt;/strong&gt; connected to 4 slave multiplexers, this is my wiring:&#xA;[here][1]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested it using one single multiplexer and it works as intended, but when adding the slave I cannot getting it to work, I am not sure how to code for it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When using this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// 74XX4051 ADDRESS PINS :&#xA;#define  M_S0 2&#xA;#define  M_S1 3&#xA;#define  M_S2 4&#xA;&#xA;#define  S_S0 7&#xA;#define  S_S1 6&#xA;#define  S_S2 5&#xA;&#xA;// 74XX4051 ANALOG PIN :&#xA;#define  Z 0&#xA;&#xA;void setup() {&#xA;    // CONFIGURE ADDRESS PINS&#xA;    pinMode(M_S0, OUTPUT);&#xA;    pinMode(M_S1, OUTPUT);&#xA;    pinMode(M_S2, OUTPUT);&#xA;&#xA;    pinMode(S_S0, OUTPUT);&#xA;    pinMode(S_S1, OUTPUT);&#xA;    pinMode(S_S2, OUTPUT);&#xA;&#xA;    // CONFIGURE SERIAL&#xA;    Serial.begin(57600);&#xA;}&#xA;&#xA;void loop() {&#xA;    int value;&#xA;&#xA;    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER &#xA;    for ( byte count = 0; count &amp;lt; 4 ; count++ ) {&#xA;         // SET THE ADDRESS&#xA;         digitalWrite(M_S0, bitRead(count, 0) );   &#xA;         digitalWrite(M_S1, bitRead(count, 1) );&#xA;         digitalWrite(M_S2, bitRead(count, 2) );&#xA;&#xA;         // LOOP THROUGH ALL THE ADDRESSES OF THE SLAVES&#xA;         for ( byte count_1 = 0; count_1 &amp;lt; 32 ; count_1++ ) {&#xA;             digitalWrite(S_S0, bitRead(count_1, 0) );&#xA;             digitalWrite(S_S1, bitRead(count_1, 1) );&#xA;             digitalWrite(S_S2, bitRead(count_1, 2) );&#xA;&#xA;             // READ THE ANALOG VALUE&#xA;             value = (bitRead(count_1, 2), bitRead(count_1, 1), bitRead(count_1, 0));&#xA;         }&#xA;&#xA;         // READ THE ANALOG FOR THE MASTER ADRESSE&#xA;         value = analogRead(Z);&#xA;&#xA;         // SERIAL OUTPUT&#xA;         // print : ### value&#xA;         Serial.print(bitRead(count, 2));&#xA;         Serial.print(bitRead(count, 1));&#xA;         Serial.print(bitRead(count, 0));&#xA;         Serial.print(' ');&#xA;         Serial.println(value);&#xA;&#xA;         delay(100);&#xA;     }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am only getting random readings really (the reading LED for the moisture sensor does not switch on when the reading is done).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What I am doing wrong? Any help is appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i updated my code as follows :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Master moisture sensor pins&#xA;#define  M_S0 7&#xA;#define  M_S1 8&#xA;#define  M_S2 9&#xA;// Slave moisture sensor pins&#xA;#define  S_S0 4&#xA;#define  S_S1 5&#xA;#define  S_S2 6&#xA;&#xA;// PIN from the transistor to power the sensors only when doing a reading&#xA;int sensorVCC = 13;&#xA;&#xA;//  ANALOG PIN :&#xA;#define  Z 0&#xA;&#xA;void setup() {&#xA;    Serial.begin(9600);&#xA;    // CONFIGURE ADDRESS PINS&#xA;    pinMode(M_S0, OUTPUT);&#xA;    pinMode(M_S1, OUTPUT);&#xA;    pinMode(M_S2, OUTPUT);&#xA;&#xA;    pinMode(S_S0, OUTPUT);&#xA;    pinMode(S_S1, OUTPUT);&#xA;    pinMode(S_S2, OUTPUT);&#xA;    pinMode(sensorVCC, OUTPUT); &#xA;&#xA;    digitalWrite(sensorVCC, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER &#xA;    for (int i = 0; i &amp;lt; 32; i++) {&#xA;    digitalWrite(sensorVCC, HIGH);&#xA;    delay(100); //make sure the sensor is powere&#xA;&#xA;    digitalWrite(M_S2, i &amp;amp; 0b100000);&#xA;    digitalWrite(M_S1, i &amp;amp; 0b010000);&#xA;    digitalWrite(M_S0, i &amp;amp; 0b001000);        &#xA;    digitalWrite(S_S2, i &amp;amp; 0b000100);&#xA;    digitalWrite(S_S1, i &amp;amp; 0b000010);&#xA;    digitalWrite(S_S0, i &amp;amp; 0b000001);&#xA;&#xA;&#xA;&#xA;    delay(1);&#xA;&#xA;&#xA;    int humidityRaw = analogRead(Z); // 1023 to 0 ===&amp;gt; 0 to 100%&#xA;    int humidityReal = map(humidityRaw, 975, 523, 0, 100);&#xA;    digitalWrite(sensorVCC, LOW);  &#xA;&#xA;    Serial.print(&quot;Input &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;: &quot;);&#xA;    Serial.print(humidityReal);&#xA;    Serial.println(&quot; % &quot;);&#xA;    delay(1000); &#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and this is my output :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    Input 0: 100 % &#xA;    Input 1: 0 % &#xA;    Input 2: 100 % &#xA;    Input 3: 0 % &#xA;    .&#xA;    .&#xA;    .&#xA;    Input 0: 0 % &#xA;    Input 1: 100 % &#xA;    Input 2: 0 % &#xA;    Input 3: 0 % &#xA;    .&#xA;    .&#xA;    .&#xA;    Input 0: 100 % &#xA;    Input 1: 0 % &#xA;    Input 2: 0 % &#xA;    Input 3: 0 % &#xA;    .&#xA;    .&#xA;    .&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;ONLY channel 0 is hooked !! .... it seems that it reads with different delays. changing the delay gives me different sequence. what is wrong ?&lt;/p&gt;&#xA;" OwnerUserId="25570" LastEditorUserId="25570" LastEditDate="2016-09-05T21:39:48.200" LastActivityDate="2016-12-05T03:44:45.467" Title="How to code for cascading multiplexers?" Tags="|arduino-uno|multiplexer|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28135" PostTypeId="2" ParentId="28134" CreationDate="2016-08-07T18:17:22.350" Score="0" Body="&lt;p&gt;It becomes much easier if you start thinking in binary.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have an 8 bit multiplexer connected to four 8 bit multiplexers that gives you 32 inputs. Four of the inputs on the &quot;master&quot; multiplexer are unused and can be ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have 32 inputs. That's inputs numbered 0 to 31. In binary that equates to, in full,&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;0 = 000000   8 = 001000  16 = 010000  24 = 011000&#xA;1 = 000001   9 = 001001  17 = 010001  25 = 011001&#xA;2 = 000010  10 = 001010  18 = 010010  26 = 011010&#xA;3 = 000011  11 = 001011  19 = 010011  27 = 011011&#xA;4 = 000100  12 = 001100  20 = 010100  28 = 011100&#xA;5 = 000101  13 = 001101  21 = 010101  29 = 011101&#xA;6 = 000110  14 = 001110  22 = 010110  30 = 011110&#xA;7 = 000111  15 = 001111  23 = 010111  31 = 011111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have laid it out like that especially so that you see a pattern occurring. Four columns with 8 rows. Four slave multiplexers with 8 inputs. A perfect match. Each column has bits that are distinct to that column. Each row has bits that are unique to that row.  So you could split those bits up and know that the left-hand three bits indicate the column, and the right-hand three bits indicate the row. Between the two it's a unique location in the table.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same applies to the multiplexers.  The left-hand three bits indicate which slave multiplexer to use, the right-hand three bits which input to use on the selected multiplexer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you can loop through each of the 32 inputs with a single loop and examine the individual bits of the input number and apply those bits directly to the select outputs to control the multiplexers - the left-hand bits to the master to select which slave to use, and the right-hand bits to the slaves to select which input to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 32; i++) {&#xA;    digitalWrite(M_S2, i &amp;amp; 0b100000);&#xA;    digitalWrite(M_S1, i &amp;amp; 0b010000);&#xA;    digitalWrite(M_S0, i &amp;amp; 0b001000);&#xA;    digitalWrite(S_S2, i &amp;amp; 0b000100);&#xA;    digitalWrite(S_S1, i &amp;amp; 0b000010);&#xA;    digitalWrite(S_S0, i &amp;amp; 0b000001);&#xA;&#xA;    delay(1);&#xA;&#xA;    int reading = analogRead(Z);&#xA;    Serial.print(&quot;Input &quot;);&#xA;    Serial.print(i);&#xA;    Serial.print(&quot;: &quot;);&#xA;    Serial.println(reading);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The &lt;code&gt;i &amp;amp; 0b000001&lt;/code&gt; etc performs the same function as &lt;code&gt;bitRead()&lt;/code&gt; but is more explicit using a mask that is far more visual as to what it achieves.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also include a tiny delay after setting the multiplexers up so as to ensure they have settled into their new settings properly before reading. It shouldn't be needed, but it doesn't hurt.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T18:17:22.350" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28136" PostTypeId="2" ParentId="28133" CreationDate="2016-08-07T18:31:41.593" Score="4" Body="&lt;p&gt;I did not experience the problem because I usually use a Makefile instead of&#xA;the Arduino IDE. I now tried with the IDE version 1.0.5 and I had the same&#xA;problem as you. The fix is to explicitly declare the function before&#xA;defining it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void Move(Dir direction, int distance);&#xA;void Move(Dir direction, int distance)&#xA;{&#xA;     direction = forward;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-07T18:31:41.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28137" PostTypeId="2" ParentId="28133" CreationDate="2016-08-07T18:31:51.613" Score="3" Body="&lt;p&gt;The Arduino 1.7.x series from Arduino.org uses the old build system that is severely broken when you try and do anything more complex than simple types.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It adds prototypes to your functions to the top of the program so you don't have to get the order right, but it puts them in completely the wrong place.  The result is a C++ file that looks like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Arduino.h&amp;gt;&#xA;void Move ( Dir direction , int distance );&#xA;void setup();&#xA;void loop();&#xA;&#xA;enum Dir&#xA;{&#xA;  forward = 1,&#xA;  backward = 2,&#xA;  left = 3,&#xA;  right = 4&#xA;};&#xA;&#xA;void Move ( Dir direction , int distance )&#xA;{&#xA;     direction = forward;&#xA;}&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see the prototype involving &lt;code&gt;Dir&lt;/code&gt; has been placed before the definition of &lt;code&gt;Dir&lt;/code&gt;, and so it fails miserably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are some hacks you can do to force it to place the prototypes after your definition, but I can't recall what they are off hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The simple answer is to ditch Arduino 1.7.10 and switch to Arduino 1.6.10 from Arduino.cc instead. This uses the Arduino Builder system which does things much better, including placing the prototypes in the right place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Despite the numbering 1.7.10 is not a newer version than 1.6.10 - it is an older version renumbered. It's all part of the schism between the two halves of Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even better is to ditch the awful Arduino IDE entirely and use one of the many far better IDEs that exist.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T18:31:51.613" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28138" PostTypeId="2" ParentId="28133" CreationDate="2016-08-07T18:32:00.203" Score="0" Body="&lt;p&gt;You have to define a new enum type:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef enum &#xA;{&#xA;  forward = 1,&#xA;  backward = 2,&#xA;  left = 3,&#xA;  right = 4&#xA;} Dir;&#xA;&#xA;void Move ( Dir direction , int distance )&#xA;{&#xA;     direction = forward;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;without &lt;code&gt;typedef&lt;/code&gt; your Dir is just static enum variable, it can't be used to define other vars.&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-08-07T18:32:00.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28140" PostTypeId="2" ParentId="28133" CreationDate="2016-08-07T18:46:05.030" Score="2" Body="&lt;p&gt;As Majenko points out, this seems to be a problem with the parsing of the preprocessor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have two options:&#xA;&#xA;&lt;li&gt;&#xA;Use Edgar Bonets solution and declare the function before defining it&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;Create a separate header file for your enum in a new tab and import it with #include &quot;[myEnumsHeaderFilename].h&quot;&#xA;&lt;/li&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;myEnums.h&quot;&#xA;&#xA;&#xA;void Move(Dir direction, int distance)&#xA;{&#xA;   direction = forward; &#xA;}&#xA;&#xA;void setup() {}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25571" LastActivityDate="2016-08-07T18:46:05.030" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28141" PostTypeId="2" ParentId="16493" CreationDate="2016-08-07T18:55:01.697" Score="1" Body="&lt;p&gt;IRremote (already recommended) - but to save you some time, use the IRRecvDump example to grab the raw codes you need for &lt;code&gt;sendRaw()&lt;/code&gt;. They need to be averaged out across 10-20 reads. I log the output to a file, and use a perl script to do it for me, since it is painful to type this into a calculator a million times. The resistor you connect to the sensor affects its sensitivity - I used 330ohm, and have ~10 metres range from a 3V3 remote inside, 4-5 metres outside in sunlight. I would give you the script, but it's on my desktop. Let me know if you need it - or just use python, which is so popular nowadays (indent-or-fail... feh. what about people who don't like setting up the tab-space continuum, and don't have fancy editors...mumblemumble)&#xA;Edit: my raw codes absolutely needed to be averaged out, or they were useless. Any negative values in the array can just be made positive, don't fret.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-07T18:55:01.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28145" PostTypeId="1" CreationDate="2016-08-07T22:14:55.297" Score="1" ViewCount="361" Body="&lt;p&gt;I am writing a software that runs on the PC that has a Arduino 2560 connected to it via USB. This PC needs to communicate with multiple devices through RS232.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to use the Arduino's 4 UARTs to communicate with 4 different hardware that uses RS232 serial communication, using just 1 USB connection between the PC and the Arduino 2560?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino 2560 will basically act as an interface for 1 USB to talk to 4 RS232 devices.&lt;/p&gt;&#xA;" OwnerUserId="639" LastActivityDate="2018-03-07T14:37:55.510" Title="Arduino 2560 as an Interface to 4 Serial Hardwares" Tags="|serial|arduino-mega|uart|rs232|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28146" PostTypeId="1" CreationDate="2016-08-07T22:28:18.743" Score="1" ViewCount="296" Body="&lt;p&gt;Is it possible to connect to an Arduino 2560 using a RS232 (DB9) connection rather than the regular connection using USB cable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am thinking of this connection scheme:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;PC -&amp;gt; USB cable -&amp;gt; USB to RS232 Multiplexer -&amp;gt; DB9 Cable -&amp;gt; Adapter board -&amp;gt; Arduino 2560&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="639" LastActivityDate="2016-08-07T22:46:03.563" Title="Connect to Arduino 2560 using a RS232 Connection" Tags="|arduino-mega|usb|rs232|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28147" PostTypeId="1" CreationDate="2016-08-07T22:44:29.403" Score="1" ViewCount="635" Body="&lt;p&gt;I'm looking for a mechanical component that enables me to do two things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;contain a gas in a bottle and if opened, the gas should smoothly flow out (with the same pressure as a child blowing out candles on his birthday cake)&lt;/li&gt;&#xA;&lt;li&gt;a valve for the bottle that can be opened by an Arduino when powered via USB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I already figured out that there are outlets for CO&lt;sub&gt;2&lt;/sub&gt; capsules. This could work, but then I'd need to figure out a way to decrease the pressure in order to receive a gentle gas flow. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know any better approaches? Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="25575" LastEditorDisplayName="user24204" LastEditDate="2016-08-08T09:49:46.140" LastActivityDate="2018-01-02T14:42:26.270" Title="Releasing gas from a bottle via Arduino - opening a valve?" Tags="|power|components|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28148" PostTypeId="2" ParentId="28146" CreationDate="2016-08-07T22:46:03.563" Score="2" Body="&lt;p&gt;Yes, perfectly possible.  You need an RS-232 interface chip - the most common and well-known of these is the MAX232. You can get them as breakouts on eBay.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That interfaces between the DB9 and pins 0/1 (or other UART comms pins) on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are wanting to program the board through it you will also need to connect (after converting the voltage through the MAX232) the DTR line to RESET through a 100nF capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... Exactly like you would with a breadboard Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T22:46:03.563" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28149" PostTypeId="2" ParentId="28145" CreationDate="2016-08-07T23:00:46.823" Score="1" Body="&lt;p&gt;No, but it is possible to use 3 of them. The reason being that one of them is the connection to the computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hard part is in the programming. You will need not only a suitable sketch on the Arduino (the easy part), but also some software on your computer that presents three COM ports to the operating system and forwards the data through to the Arduino in a suitably packeted format, and receive data back and sent it on to the right COM port.  Depending on your operating system that may be a very easy task (on Linux and OS X) or a complete and utter nightmare (Windows).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T23:00:46.823" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28152" PostTypeId="1" AcceptedAnswerId="28153" CreationDate="2016-08-07T23:42:08.390" Score="0" ViewCount="81" Body="&lt;p&gt;I am working on a project, where i need to control the flow of a liquid made from food. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example: making chicken curry, I will separate all the liquid from the meat, and run that tough a pipe, where this control pipe is on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I have been unable to find a subtle valve for this, as the liquid on all of them will flow tough the mechanics of the valve, and this would not be optimal as it would make it impossible to clean, and it would diffidently get stuck.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can one of you suggest a valve that would work for this case?&lt;/p&gt;&#xA;" OwnerUserId="25576" LastEditorDisplayName="user24204" LastEditDate="2016-08-08T09:49:34.733" LastActivityDate="2016-08-08T09:49:34.733" Title="Water valve for food" Tags="|hardware|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28153" PostTypeId="2" ParentId="28152" CreationDate="2016-08-07T23:53:48.873" Score="2" Body="&lt;p&gt;I would suggest, instead of a valve, a &lt;a href=&quot;https://en.wikipedia.org/wiki/Peristaltic_pump&quot; rel=&quot;nofollow&quot;&gt;Peristaltic Pump&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In short, it comprises a set of rollers that squeeze a flexible tube and push the fluid along. It has good advantages for food use:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Very easy to clean - only the inside of the tube needs cleaning&lt;/li&gt;&#xA;&lt;li&gt;Pumped fluid is not in physical contact with the pump mechanism so can't be contaminated.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;They are used in many sterile environments - medical, industrial, etc., because they are so easy to keep clean and have no way of contaminating the pumped fluid. They are also good with viscous (sticky, gloopy) fluids like soups and sauces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;They can also deliver precisely measured amounts very easily.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-07T23:53:48.873" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28154" PostTypeId="1" CreationDate="2016-08-08T03:52:17.930" Score="1" ViewCount="5441" Body="&lt;p&gt;I am running Ubuntu Mate 16.04 LTS, with an Arduino Uno R3 clone. I am having the dreaded serial port graying out problem, and have not found a solution for fixing it. Currently, The serial port will grey out sometimes, and sometimes it will be not grayed out, and I can see that I have selected ttyUSB0. Usually when it is not grayed out, uploading a sketch will not work, and I get the error like it is grayed out:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: ser_open(): can't open device &quot;/dev/ttyUSB0&quot;: No such file or directory&#xA;  An error occurred while uploading the sketch&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;chmod a+rw /dev/ttyUSB0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't solve the issue, with log out included&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;gpasswd -a aaron dialout&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;doesn't solve the issue, with log out included&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched preferences.txt and serial.debug rate is set to 9600&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried entering preferences.txt and deleting all of the serial entries. They are recreated the same after deletion, and this doesn't solve anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried running as sudo, doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried solving this originally on Arduino IDE 1.0, didn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have upgraded to Arduino IDE 1.6.10, still not working.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;running lsusb in terminal yields this while Arduino is plugged in:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 001 Device 003: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]&#xA;Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub&#xA;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&#xA;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Checking var/log/syslog after plugging in Arduino:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;kernel: [42043.787178] usb 3-2: new full-speed USB device number 109 using xhci_hcd&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;kernel: [42043.916241] usb 3-2: New USB device found, idVendor=1a86, idProduct=7523&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;kernel: [42043.916249] usb 3-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;kernel: [42043.916253] usb 3-2: Product: USB2.0-Serial&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;kernel: [42043.916964] ch341 3-2:1.0: ch341-uart converter detected&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;kernel: [42043.918199] usb 3-2: ch341-uart converter now attached to ttyUSB0&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;mtp-probe: checking bus 3, device 109: &quot;/sys/devices/pci0000:00/0000:00:14.0&#xA;  /usb3/3-2&quot;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;mtp-probe: bus: 3, device: 109 was not an MTP device&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Ran to add to dialout group, then logged out&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;sudo usermod -a -G dialout aaron&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;No solution.&#xA;So it looks like Arduino board is not being recognized. Not sure what to try next. It is important that I have uploaded sketches before, but am not sure if there is a pattern to when it does not work. It does not work 95% of the time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for the help!&lt;/p&gt;&#xA;" OwnerUserId="25578" LastEditorUserId="25578" LastEditDate="2016-08-08T14:31:27.693" LastActivityDate="2019-12-25T15:00:45.400" Title="Serial Port greyed out Ubuntu 16.04" Tags="|arduino-uno|serial|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28155" PostTypeId="1" AcceptedAnswerId="28158" CreationDate="2016-08-08T04:40:24.380" Score="1" ViewCount="237" Body="&lt;p&gt;As part of the research I am involved with, the detection (not imaging) of UV (ultraviolet) sources, either emitters or reflectors is an important factor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am aware of the &lt;a href=&quot;https://www.sparkfun.com/products/12705&quot; rel=&quot;nofollow&quot;&gt;SparkFun UV Sensor Breakout - ML8511&lt;/a&gt; component, which, according to the &lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/ML8511_3-8-13.pdf&quot; rel=&quot;nofollow&quot;&gt;product specifications&lt;/a&gt;, has a decent broadband response across the UVA and UVB, with little amount of visible light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there an Arduino component that only detects the UVB waveband (280nm to 320nm)? &lt;/p&gt;&#xA;" OwnerDisplayName="user24204" LastActivityDate="2016-08-08T09:25:34.143" Title="UVB sensing with Arduino" Tags="|sensors|components|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28158" PostTypeId="2" ParentId="28155" CreationDate="2016-08-08T09:25:34.143" Score="1" Body="&lt;p&gt;The SparkFun board you mentioned should detect UVB and UVA, but I guess, from your question, that you want one that cannot detect UVA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically any device that has an I2C interface &lt;em&gt;should&lt;/em&gt; work with an Arduino as long as you know how to interface with the device in the code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your intention is professional research, than a demo device such as the SparkFun may not fit your needs anyway as it will not be particularly accurate and is mainly intended as a little board to play about with on your Arduino and say &quot;Hey, look, there's UV light there!&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The answer to your question is that the best place to look is above the consumer range, at some higher-end UV sensors that are not generally suitable for the little Arduino demos due to price, but may give you much more accurate readings and only sense the UVB waveband.&lt;/p&gt;&#xA;" OwnerUserId="4594" LastActivityDate="2016-08-08T09:25:34.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28159" PostTypeId="1" AcceptedAnswerId="28160" CreationDate="2016-08-08T10:00:13.933" Score="0" ViewCount="118" Body="&lt;p&gt;my project involves:&#xA;1 ultrasonic sensor. &#xA;1 servo motor.&#xA;3 leds.&#xA;when a person comes in range of ultrasonic sensor (7 to 20),servo turns by 150 degree.&#xA;then ultrasonic sensor check again if the person is in range, if yes then led1 turns on for 10sec n turns off, still if the person in in range then led2 turns on for 10sec and turns off, still if the person is in range then led3 turns on for 10sec and this keep on repeating for the leds(led1, led2, led3 but servo is still in 150) &#xA;once detected and the person is not detected the leds should not glow and servo should return to 0 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((distance1&amp;gt;7)&amp;amp;&amp;amp;(distance1 &amp;lt;= 20))&#xA; {&#xA;  myservo1.write(150);&#xA;  delay(1000);&#xA; }&#xA; {&#xA;  if ((distance2&amp;gt;7)&amp;amp;&amp;amp;(distance2 &amp;lt;= 20))&#xA;   {&#xA;   digitalWrite(led1,HIGH); &#xA;   delay(1000); &#xA;   digitalWrite(led1,LOW);&#xA;   }&#xA;  if ((distance1&amp;gt;7)&amp;amp;&amp;amp;(distance1 &amp;lt;= 20))&#xA;   {&#xA;   digitalWrite(led2,HIGH); &#xA;   delay(1000); &#xA;   digitalWrite(led2,LOW);&#xA;   }&#xA;   if ((distance1&amp;gt;7)&amp;amp;&amp;amp;(distance1 &amp;lt;= 20))&#xA;   {&#xA;   digitalWrite(led3,HIGH); &#xA;   delay(1000); &#xA;   digitalWrite(led3,LOW);&#xA;   }&#xA;else&#xA;{&#xA; myservo1.write(0);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but this code does not work the way i want.&#xA;it blink the leds even when there is no person in range.&#xA;need help in programing so that the leds blink only when ultrasonic detects the person in range and stops when person is not detected.&#xA;thank u in advance&lt;/p&gt;&#xA;" OwnerUserId="25583" LastEditorUserId="4143" LastEditDate="2016-08-08T10:01:39.357" LastActivityDate="2016-08-09T11:06:08.863" Title="help with arduino programming" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28160" PostTypeId="2" ParentId="28159" CreationDate="2016-08-08T10:23:23.500" Score="1" Body="&lt;p&gt;Your indenting doesn't match your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Right after the very first &lt;code&gt;if&lt;/code&gt; (without an &lt;code&gt;else&lt;/code&gt;), you have a new open brace (&lt;code&gt;{&lt;/code&gt;). This looks wrong:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if ((distance1&amp;gt;7)&amp;amp;&amp;amp;(distance1 &amp;lt;= 20))&#xA; {&#xA;  myservo1.write(150);&#xA;  delay(1000);&#xA; }&#xA; { // &amp;lt;&amp;lt;&amp;lt;&amp;lt; What is this?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The very very final &lt;code&gt;else&lt;/code&gt; matches the very very final &lt;code&gt;if&lt;/code&gt; - certainly not the first &lt;code&gt;if&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, what is the difference between &lt;code&gt;distance1&lt;/code&gt; and &lt;code&gt;distance2&lt;/code&gt;? You only have one ultrasonic sensor - there is only one &lt;code&gt;distance&lt;/code&gt;!&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;EDIT:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I think what you need to do is use &lt;code&gt;loop()&lt;/code&gt; more effectively. At the moment, you're pausing in the middle of your code, rather than letting the rest of the code work and using &lt;code&gt;millis()&lt;/code&gt;. That function returns the number of milliseconds since the program started - which you can use for your problem (with a little mathematics):&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;EDIT 2:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I've added a little extra code to play different tunes depending on the current state. It uses the library at &lt;a href=&quot;http://www.rhydolabz.com/other-widgets-c-205_124/mini-mp3-player-module-p-2159.html&quot; rel=&quot;nofollow&quot;&gt;http://www.rhydolabz.com/other-widgets-c-205_124/mini-mp3-player-module-p-2159.html&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static unsigned lastMilli = 0;&#xA;static byte lastLED = 0;&#xA;static const byte LEDs[] = { led1, led2, led3 };&#xA;&#xA;distance1 = // Whatever you call to get the distance...&#xA;if (distance1&amp;gt;7) &amp;amp;&amp;amp; (distance1&amp;lt;=20)) { // Too close?&#xA;   if (lastMilli==0) {       // Is this new???&#xA;       lastMilli = millis(); // Yes! Record that...&#xA;       mysero.write(150);    // ...and set servo.&#xA;   } // if&#xA;   unsigned delay = millis() - lastMilli; // Get how long it's been&#xA;   byte which = delay / 10000 % 3;        // Which LED / tune?&#xA;   byte LED = LEDs[which];                // Which LED?&#xA;   if (LED != lastLED) {                  // Has LED changed?&#xA;       if (lastLED!=0) {&#xA;           digitalWrite(lastLED, LOW);    // Yes! Stop that one&#xA;       } // if&#xA;       mp3_single_loop(true);             // Play forever!&#xA;       mp3_single_play(which+1);          // Play &quot;mp3/000#.mp3&quot;&#xA;       lastLED = LED;&#xA;       digitalWrite(LED, HIGH);           // And start the new one&#xA;   } // if&#xA;} // if&#xA;else if (lastMillis!=0) { // They're gone!&#xA;    digitalWrite(lastLED, LOW); // No LED&#xA;    myservo.write(0);           // No servo&#xA;    lastMilli = 0;              // So start again&#xA;    lastLED = 0;&#xA;    mp3_stop();&#xA;} // else&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastEditorUserId="22924" LastEditDate="2016-08-09T11:06:08.863" LastActivityDate="2016-08-09T11:06:08.863" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28161" PostTypeId="2" ParentId="28091" CreationDate="2016-08-08T11:32:15.093" Score="2" Body="&lt;p&gt;After a lot of experiment, I finally made it. I got to know from some forum that when COM PORT is greater than 10, you have to put a '.' after COM PORT setting e.g. -P.COM41. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, unfortunately that did not work. Then I changed the COM PORT to under 10 in device manager -&gt; Properties -&gt; COM Port Setting -&gt; Advanced Setting; e.g. COM6.&#xA;Then it worked. At the time of flash just I have to press the RST button for once.&#xA;And now bingo!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Still, I will try to find out why it didn't work with higher COM Port.&lt;/p&gt;&#xA;" OwnerUserId="21624" LastActivityDate="2016-08-08T11:32:15.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28162" PostTypeId="1" AcceptedAnswerId="28163" CreationDate="2016-08-08T11:57:37.110" Score="0" ViewCount="1015" Body="&lt;p&gt;I am having a strange issue where if I try and create a TCP connection to my service, it doesn't work. But any other website, such as google, works fine. The serial monitor output is also slightly different, but I cannot see any difference in the code. I am using &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; module for communications.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the method that I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SendPost()&#xA;{&#xA;  Serial1.println(&quot;AT+CGATT?&quot;);&#xA;  delay(1000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CSTT=\&quot;everywhere\&quot;&quot;);//start task and setting the APN,&#xA;  delay(1000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIICR&quot;);//bring up wireless connection&#xA;  delay(3000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIFSR&quot;);//get local IP adress&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSPRT=0&quot;);&#xA;  delay(3000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSTART=\&quot;tcp\&quot;,\&quot;www.google.com/\&quot;,\&quot;80\&quot;&quot;);//start up the connection //https://rocky-garden-56471.herokuapp.com/breadcrum/lifecycle/register&#xA;  delay(5000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPSEND&quot;);//begin send data to remote server&#xA;  delay(4000);&#xA;  ShowSerialData();&#xA;  &#xA;  Serial1.println(&quot;{\&quot;device_info\&quot;:\&quot;breadcrum-prototype-a\&quot;}&quot;);  &#xA;  delay(500);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println((char)26);//sending&#xA;  delay(5000);//waitting for reply, important! the time is base on the condition of internet &#xA;  &#xA;  Serial1.println(); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CIPCLOSE&quot;);//close the connection&#xA;  delay(100);&#xA;  ShowSerialData();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using 'www.google.com' I get an OK upon tcp connection (with an expected error on the data as I try to POST):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setup CompleteAT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;AT+CSTT=&quot;everywhere&quot;&#xA;&#xA;OK&#xA;AT+CIICR&#xA;&#xA;OK&#xA;AT+CIFSR&#xA;&#xA;100.66.4.95&#xA;AT+CIPSPRT=0&#xA;&#xA;OK&#xA;AT+CIPSTART=&quot;tcp&quot;,&quot;www.google.com/&quot;,&quot;80&quot;&#xA;&#xA;OK&#xA;&#xA;STATE: IP STAAT+CIPSEND&#xA;&#xA;ERROR&#xA;{&quot;device_info&quot;:&quot;breadcrum-prototype-a&quot;}&#xA;&#xA;&#xA;AT+CIPCLOSE&#xA;&#xA;ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But using the address I actually want to post data to (&lt;a href=&quot;https://rocky-garden-56471.herokuapp.com/breadcrum/lifecycle/register&quot; rel=&quot;nofollow&quot;&gt;https://rocky-garden-56471.herokuapp.com/breadcrum/lifecycle/register&lt;/a&gt;), it cannot connect and I get this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setup CompleteAT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;AT+CSTT=&quot;everywhere&quot;&#xA;&#xA;OK&#xA;AT+CIICR&#xA;&#xA;OK&#xA;AT+CIFSR&#xA;&#xA;100.66.4.95&#xA;AT+CIPSPRT=0&#xA;&#xA;OK&#xA;AT+CIPSTART=&quot;tcp&quot;,&quot;https://rocky-garden-56471.herokuapp.com/breAT+CIPSEND&#xA;&#xA;ERROR&#xA;{&quot;device_info&quot;:&quot;breadcrum-prototype-a&quot;}&#xA;&#xA;&#xA;AT+CIPCLOSE&#xA;&#xA;ERROR&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This errors on connection, and you can also see that the full address isn't printed out for some reason. Does anyone have any idea what could be causing this issue?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;@Majenko, my previous version did what I believe you are describing. The issue being I got an error that I struggled to resolve so attempted this version. The previous version is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void SubmitHttpRequest()&#xA;{&#xA;  Serial1.println(&quot;AT+CSQ&quot;);&#xA;  delay(100); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+CGATT?&quot;);&#xA;  delay(100); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+SAPBR=3,1,\&quot;CONTYPE\&quot;,\&quot;GPRS\&quot;&quot;);//setting the SAPBR, the connection type is using gprs&#xA;  delay(1000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+SAPBR=3,1,\&quot;APN\&quot;,\&quot;everywhere\&quot;&quot;);//setting the APN, the second need you fill in your local apn server&#xA;  delay(4000); &#xA;  ShowSerialData();&#xA;&#xA; //Enable GPRS&#xA;  Serial1.println(&quot;AT+SAPBR=1,1&quot;);&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;  //Query if connection is setup correctly, return IP address if it is &#xA;  Serial1.println(&quot;AT+SAPBR=2,1&quot;);&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPINIT&quot;); //init the HTTP request &#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;//Set up bearer profile identifier (NEW PART)&#xA;  Serial1.println(&quot;AT+HTTPPARA=\&quot;CID\&quot;,1&quot;);&#xA;  delay(2000); &#xA;  ShowSerialData();&#xA;&#xA;&#xA;  Serial1.println(&quot;AT+HTTPPARA=\&quot;URL\&quot;,\&quot;https://rocky-garden-56471.herokuapp.com/breadcrum/lifecycle/register\&quot;&quot;);// setting the httppara, the second parameter is the website you want to access&#xA;  delay(3000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPPARA=\&quot;CONTENT\&quot;,\&quot;application/json\&quot;&quot;);&#xA;  delay(3000); &#xA;  ShowSerialData();  &#xA;&#xA;  Serial1.println(&quot;AT+HTTPDATA=1000,10000&quot;);&#xA;  delay(3000);&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;{\&quot;device_info\&quot;:\&quot;breadcrum-prototype-a\&quot;}&quot;);&#xA;  delay(3000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPACTION=1&quot;);//submit the request //0:READ 1:POST 2:HEAD&#xA;  delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.&#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;AT+HTTPREAD&quot;);// read the data from the website you access&#xA;  delay(1000); &#xA;  ShowSerialData();&#xA;&#xA;  Serial1.println(&quot;&quot;);&#xA;  delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But the results I got from this was another error when attempting to post:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Setup CompleteAT+CSQ&#xA;&#xA;+CSQ: 18,0&#xA;&#xA;OK&#xA;AT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;AT+SAPBR=3,1,&quot;CONTYPE&quot;,&quot;GPRS&quot;&#xA;&#xA;OK&#xA;AT+SAPBR=3,1,&quot;APN&quot;,&quot;everywhere&quot;&#xA;&#xA;OK&#xA;AT+SAPBR=1,1&#xA;&#xA;OK&#xA;AT+SAPBR=2,1&#xA;&#xA;+SAPBR: 1,1,&quot;19.177.18.205&quot;&#xA;&#xA;OK&#xA;AT+HTTPINIT&#xA;&#xA;OK&#xA;AT+HTTPPARA=&quot;CID&quot;,1&#xA;&#xA;OK&#xA;AT+HTTPPARA=&quot;URL&quot;,&quot;https://rocky-garden-56471.herokuapp.com/breAT+HTTPPARA=&quot;CONTENT&quot;,&quot;application/json&quot;&#xA;&#xA;OK&#xA;AT+HTTPDATA=1000,10000&#xA;&#xA;DOWNLOAD&#xA;&#xA;ERROR&#xA;AT+HTTPREAD&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT 2:&#xA;Following HTTPS commands:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; AT+CSQ&#xA;&#xA;+CSQ: 18,0&#xA;&#xA;OK&#xA;AT+CGATT?&#xA;&#xA;+CGATT: 1&#xA;&#xA;OK&#xA;AT+SAPBR=3,1,&quot;CONTYPE&quot;,&quot;GPRS&quot;&#xA;&#xA;OK&#xA;AT+SAPBR=3,1,&quot;APN&quot;,&quot;everywhere&quot;&#xA;&#xA;OK&#xA;AT+SAPBR=1,1&#xA;&#xA;ERROR&#xA;AT+SAPBR=2,1&#xA;&#xA;+SAPBR: 1,1,&quot;31.94.203.234&quot;&#xA;&#xA;OK&#xA;AT+HTTPSSL=1&#xA;&#xA;OK&#xA;AT+HTTPINIT&#xA;&#xA;OK&#xA;AT+HTTPPARA=&quot;CID&quot;,1&#xA;&#xA;OK&#xA;AT+HTTPPARA=&quot;URL&quot;,&quot;https://rocky-garden-56471.herokuapp.com/breAT+HTTPPARA=&quot;CONTENT&quot;,&quot;application/json&quot;&#xA;&#xA;OK&#xA;AT+HTTPDATA=100,10000&#xA;&#xA;DOWNLOAD&#xA;&#xA;ERROR&#xA;AT+HTTPREAD&#xA;&#xA;OK&#xA;AT+HTTPTERM&#xA;&#xA;OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="12166" LastEditorUserId="12166" LastEditDate="2016-08-08T13:45:39.413" LastActivityDate="2016-08-08T13:45:39.413" Title="SIM900 TCP Connection issue" Tags="|arduino-mega|communication|tcpip|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28163" PostTypeId="2" ParentId="28162" CreationDate="2016-08-08T13:07:24.063" Score="0" Body="&lt;p&gt;There is so many things wrong that I don't know where to start.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You are trying to use a URL in place of a hostname.&lt;/li&gt;&#xA;&lt;li&gt;You are trying to connect to an HTTPS service which runs on port 443 not on port 80&lt;/li&gt;&#xA;&lt;li&gt;HTTPS is encrypted. You are opening a plain TCP socket to an encrypted service.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Your whole methodology is wrong. You need to use the &lt;a href=&quot;http://simcom.ee/documents/SIM900/SIM900_HTTPS%20AT%20Command%20Set_V1%2000.pdf&quot; rel=&quot;nofollow&quot;&gt;SIM900 HTTPS AT Command Set&lt;/a&gt; to get the SIM900 to perform an HTTPS request on your behalf rather than opening a socket and sending / receiving data.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-08T13:07:24.063" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28165" PostTypeId="2" ParentId="28132" CreationDate="2016-08-08T14:55:55.700" Score="2" Body="&lt;p&gt;I've found the problem&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.println(&quot;2&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial1.write(&quot;2&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25568" LastActivityDate="2016-08-08T14:55:55.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28167" PostTypeId="2" ParentId="28147" CreationDate="2016-08-08T17:30:40.933" Score="1" Body="&lt;p&gt;If you can tolerate a decreasing flow as the pressure in the bottle drops, a simple restrictor (fluidic equivalent of a resistor) will limit the flow but of course, I = E/R; the flow will be proportional to the bottle pressure. If that is acceptable, it is probably the cheapest, simplest, and most reliable way.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-08T17:30:40.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28168" PostTypeId="1" AcceptedAnswerId="28170" CreationDate="2016-08-08T17:41:09.947" Score="0" ViewCount="749" Body="&lt;p&gt;I'm trying to create a program for my robot, but something is not right.&#xA;Here's the code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Tone.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;   // standardowa biblioteka Arduino&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt; // dolaczenie pobranej biblioteki I2C dla LCD&#xA;&#xA;//Enums:&#xA;enum Dir&#xA;{&#xA;  forward = 1,&#xA;  backward = 2,&#xA;  left = 3,&#xA;  right = 4&#xA;};&#xA;&#xA;enum State&#xA;{&#xA;    movingForward = 1,&#xA;    movingBack = 2,&#xA;    turningLeft = 3,&#xA;    turningRight = 4,&#xA;    doingNothing = 5,&#xA;    readyToMove = 6 //Potrzebne?&#xA;};&#xA;&#xA;enum SpeedState&#xA;{&#xA;  slowingDown = 1,&#xA;  maxSpeed = 2,&#xA;  accelerating = 3,&#xA;  notMoving = 4&#xA;};&#xA;&#xA;&#xA;//Classes:&#xA;LiquidCrystal_I2C lcd1(0x27, 20, 4);&#xA;&#xA;//Base class for devices&#xA;class Device&#xA;{&#xA;    public:&#xA;        virtual void Init() = 0;&#xA;};&#xA;&#xA;//STEPPER::&#xA;class StepMotor: public Device&#xA;{&#xA;    public:    &#xA;        int motorPin;&#xA;        int dirPin;&#xA;        int sleepPin;&#xA;&#xA;        void Init ( void )&#xA;        {     &#xA;            pinMode(motorPin, OUTPUT);&#xA;            pinMode(dirPin, OUTPUT);&#xA;            pinMode(sleepPin, OUTPUT);&#xA;&#xA;            toneObject.begin(motorPin);&#xA;        }&#xA;&#xA;        void SetSpeed ( int speed )&#xA;        {&#xA;          toneObject.play(speed);&#xA;        }&#xA;&#xA;    private:&#xA;      Tone toneObject;            &#xA;};&#xA;&#xA;//VARIABLES:&#xA;int a = 1; //przyspieszenie (przyrost prędkości i jej ubytek przy hamowaniu&#xA;int s_accelerating = 1; //droga przyspieszania [mm]&#xA;int s_braking = 1;  //droga hamowania [mm]&#xA;&#xA;&#xA;class Robot&#xA;{&#xA;    public:&#xA;        static float x;&#xA;        static float y;&#xA;        static float t;&#xA;        static State state;&#xA;        static SpeedState speedState;&#xA;        static int currentSpeed;&#xA;};&#xA;&#xA;class MoveOrder&#xA;{&#xA;  public:&#xA;    static Dir direction;&#xA;    static int distance;&#xA;    static int speed;&#xA;    static int distanceRemaining;&#xA;    static int distanceMade;    &#xA;};&#xA;&#xA;&#xA;//FUNCTIONS:&#xA;void SetInterrupt ( void )&#xA;{&#xA;    noInterrupts();           // disable all interrupts&#xA;    TCCR5A = 0;&#xA;    TCCR5B = 0;&#xA;    TCNT5  = 0;&#xA;    OCR5A = 310;            // compare match register 16MHz/256/2Hz   400 okolo 6.4ms  380-6.1ms 300-4.9ms&#xA;    TCCR5B |= (1 &amp;lt;&amp;lt; WGM12);   // CTC mode&#xA;    TCCR5B |= (1 &amp;lt;&amp;lt; CS12);    // 256 prescaler&#xA;    TIMSK5 |= (1 &amp;lt;&amp;lt; OCIE1A);  // enable timer compare interrupt&#xA;    interrupts();             // enable all interrupts&#xA;}&#xA;&#xA;void SetSpeed ( int speedValue )&#xA;{&#xA;   //currently empty&#xA;}&#xA;&#xA;&#xA;void setup() &#xA;{   &#xA;    SetInterrupt();&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&#xA;ISR(TIMER5_COMPA_vect)&#xA;{&#xA;    if (Robot::state != doingNothing)&#xA;    {&#xA;        if (Robot::state == movingForward || Robot::state == movingBack )&#xA;        {&#xA;          if (MoveOrder::distanceMade &amp;lt; s_accelerating)&#xA;            {&#xA;&#xA;                Robot::currentSpeed += a;&#xA;&#xA;                SetSpeed(4);&#xA;&#xA;            }&#xA;        }     &#xA;    }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compilation returns this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino:1.6.10 (Windows 10), Płytka:&quot;Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;&#xA;&#xA;C:\Users\Marcin\AppData\Local\Temp\ccU9OfJk.ltrans0.ltrans.o: In function `__vector_21':&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x812): undefined reference to `Robot::state'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x816): undefined reference to `Robot::state'&#xA;&#xA;C:\Users\Marcin\AppData\Local\Temp\ccU9OfJk.ltrans0.ltrans.o: In function `__vector_47':&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x820): undefined reference to `MoveOrder::distanceMade'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x824): undefined reference to `MoveOrder::distanceMade'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x82e): undefined reference to `Robot::currentSpeed'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x832): undefined reference to `Robot::currentSpeed'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x838): undefined reference to `Robot::currentSpeed'&#xA;&#xA;ccU9OfJk.ltrans0.o:(.text+0x83c): undefined reference to `Robot::currentSpeed'&#xA;&#xA;collect2.exe: error: ld returned 1 exit status&#xA;&#xA;exit status 1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I noticed that when I comment these lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;        Robot::currentSpeed += a;&#xA;&#xA;        SetSpeed(4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;errors are gone. Why?&lt;/p&gt;&#xA;" OwnerUserId="23959" LastActivityDate="2016-08-08T17:50:48.053" Title="A lot of &quot;undefined reference&quot; errors" Tags="|interrupt|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28169" PostTypeId="1" CreationDate="2016-08-08T17:50:10.783" Score="2" ViewCount="1805" Body="&lt;p&gt;Hey I'm very new to Arduino. I don't have very much knowledge in electrical engineering either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My project: an EL wire working on Arduino. Since the Arduino can only support 5V and the wire needs 120V, how can I make sure that it works? (I assume the voltage provided by the Arduino is not high enough for the EL wire to operate.)&lt;/p&gt;&#xA;" OwnerUserId="25589" LastActivityDate="2016-08-09T10:32:23.633" Title="How to increase voltage of Arduino?" Tags="|arduino-uno|voltage-level|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28170" PostTypeId="2" ParentId="28168" CreationDate="2016-08-08T17:50:48.053" Score="0" Body="&lt;p&gt;Because you have only &lt;em&gt;declared&lt;/em&gt; the class static variables; you never &lt;em&gt;defined&lt;/em&gt; them.  For the &lt;code&gt;Robot&lt;/code&gt; class, you must have:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class Robot&#xA;{&#xA;    public:&#xA;         ...&#xA;};&#xA;&#xA;float      Robot::x;&#xA;float      Robot::y;&#xA;float      Robot::t;&#xA;State      Robot::state = doingNothing;&#xA;SpeedState Robot::speedState = notMoving;&#xA;int        Robot::currentSpeed;&#xA;&#xA;void setup()&#xA;{&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ditto for other classes.  (Dangit, Mikael!  :) )&lt;/p&gt;&#xA;" OwnerUserId="14737" LastActivityDate="2016-08-08T17:50:48.053" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28171" PostTypeId="2" ParentId="28068" CreationDate="2016-08-08T18:08:03.123" Score="-1" Body="&lt;p&gt;Thank you Harry i managed to fix it by downloading CH341SER_MAC.zip just in case someone has the same problem wch.cn/downfile/178 &lt;/p&gt;&#xA;" OwnerUserId="25522" LastActivityDate="2016-08-08T18:08:03.123" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28172" PostTypeId="2" ParentId="28169" CreationDate="2016-08-08T18:16:16.747" Score="0" Body="&lt;p&gt;In this case, you can use relays. You can give your supply voltage (120v as you said) to EL via relays. And you can switch ON and switch OFF your EL by controlling relays with Arduino.&lt;/p&gt;&#xA;" OwnerUserId="24064" LastActivityDate="2016-08-08T18:16:16.747" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28173" PostTypeId="1" CreationDate="2016-08-08T18:26:57.310" Score="0" ViewCount="725" Body="&lt;p&gt;In my project Arduino provides value range between 0-1024. I need to convert this serial value to a standard µSiemens value to measure emotional stress.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody point me to an answer that would give an appropriate equation for the conversion?&lt;/p&gt;&#xA;" OwnerUserId="25591" LastEditorUserId="4628" LastEditDate="2017-01-06T05:48:17.927" LastActivityDate="2017-01-06T05:48:17.927" Title="How to convert Arduino GSR values to microsiemens?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28174" PostTypeId="2" ParentId="28173" CreationDate="2016-08-08T18:46:16.247" Score="1" Body="&lt;p&gt;A Siemens (aka a Mho) is a unit of conductance, the inverse of resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have a measure of the voltage (A/D value) between the pads so you can find voltage. You'll also need to know the current between the pads.&#xA;Convert your A/D reading into voltage and use that and the current to find resistance (using Ohm's law), and the reciprocal of the resistance is in Siemens. 1 Siemens == 1,000,000 uSiemens.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Siemens_(unit)&quot; rel=&quot;nofollow&quot;&gt;https://en.wikipedia.org/wiki/Siemens_(unit)&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-08T18:46:16.247" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28176" PostTypeId="1" CreationDate="2016-08-09T01:28:23.550" Score="1" ViewCount="450" Body="&lt;p&gt;I am brand new to the arduino board and I am trying to build a simple IR proximity sensor. I bought a handful of emitters and detectors from amazon here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://rads.stackoverflow.com/amzn/click/B01HGIQ8NG&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.com/gp/product/B01HGIQ8NG/ref=oh_aui_detailpage_o02_s00?ie=UTF8&amp;amp;psc=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am about to pull my hair out and shoot my board with a 12 gauge shot gun if I don't figure this out soon. Can someone point me to a good SIMPLE tutorial that uses ONE emitter and ONE detector and ONE LED. All i can find are a bunch of complex circuits with multiple sets of sensors or a buzzer or whatever else and anything that is as simple as that has no information on schematic or code. Can someone please post a tutorial link?&lt;/p&gt;&#xA;" OwnerUserId="25553" LastEditorUserId="25788" LastEditDate="2016-09-16T14:15:50.973" LastActivityDate="2016-10-16T15:31:05.420" Title="build simple IR sensor with 220 ohm and 1000 ohm resistors" Tags="|arduino-uno|sensors|led|ir|proximity|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28179" PostTypeId="1" CreationDate="2016-08-09T03:35:47.013" Score="2" ViewCount="272" Body="&lt;p&gt;Have an AES-128 implementation I'd like to install on an ATTiny85 for embedded use but need to come up with a way to &lt;strong&gt;communicate with it from a PC&lt;/strong&gt; as you would do via Serial on Arduino Uno. For example, I'd like to stream 16 bytes of plaintext and get back 16 bytes of ciphertext (or signature hash, etc.).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The faster the transfer rate, the better obviously, but it would of course need to fit on the remaining space on an ATTiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any thoughts or working examples out there (i.e. I2C for PC, etc.) without incurring a lot of extra hardware cost?&lt;/p&gt;&#xA;" OwnerUserId="19939" LastActivityDate="2018-04-04T15:04:07.813" Title="Serializing data created by ATTiny85 for use on PC" Tags="|arduino-uno|attiny|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28180" PostTypeId="2" ParentId="28179" CreationDate="2016-08-09T04:24:41.973" Score="1" Body="&lt;p&gt;So thanks to Ignacio Vazquez-Abrams' tip, it looks like I'll be able to accomplish this with &lt;a href=&quot;https://www.obdev.at/products/vusb/index.html&quot; rel=&quot;nofollow&quot;&gt;V-USB&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;V-USB is a software-only implementation of a low-speed USB device for&#xA;  Atmel’s AVR® microcontrollers, making it possible to build USB&#xA;  hardware with almost any AVR® microcontroller, not requiring any&#xA;  additional chip.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt; AVR microcontroller with at least 2 kB of Flash memory, 128 bytes RAM and a clock rate of at least 12 MHz.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taken from &lt;a href=&quot;http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;ATTiny85's Datasheet&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;ul&gt;&#xA;  &lt;li&gt;8K Bytes of In-System Programmable Program Memory Flash&lt;/li&gt;&#xA;  &lt;li&gt;512 Bytes In-System Programmable EEPROM (enough for third-two 16-byte keys)&lt;/li&gt;&#xA;  &lt;li&gt;512 Bytes Internal SRAM&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Looking forward to trying it out :)&lt;/p&gt;&#xA;" OwnerUserId="19939" LastActivityDate="2016-08-09T04:24:41.973" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28182" PostTypeId="1" CreationDate="2016-08-09T05:22:30.683" Score="1" ViewCount="16589" Body="&lt;p&gt;I have an ESP8266-01. I followed the instructions on this &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://yaab-arduino.blogspot.com/2015/12/flashing-esp8266-firmware-arduino.html?m=1&quot; rel=&quot;nofollow&quot;&gt;http://yaab-arduino.blogspot.com/2015/12/flashing-esp8266-firmware-arduino.html?m=1&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;exactly. When I start the firmware update the TX and RX pins blink rapidly along with the blue light on the ESP.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then the terminal spits out &quot;chip sync error&quot; and disconnects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like this to work because buying a ftdi cable isn't an option right now.&lt;/p&gt;&#xA;" OwnerUserId="20763" LastEditorUserId="10394" LastEditDate="2016-08-10T12:09:46.870" LastActivityDate="2021-07-22T11:55:24.330" Title="Esp8266 firmware update with uno &quot;chip sync error&quot;" Tags="|esp8266|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28185" PostTypeId="1" CreationDate="2016-08-09T07:36:15.973" Score="0" ViewCount="426" Body="&lt;p&gt;I am making a project with several modules and libraries involved. I just tested the SD lib example, and got a binary at ~14KB  - way too much. I'd like the SD bits to go below 8KB, since it's just for logging from an NFC and RTC module. I notice some 'stabs' debug bits in my Makefile, and wonder if I could do something with that. Besides that, perhaps the experts here can recommend a smaller library for my SD bits, so I won't exceed my ~27KB flash capacity. I am using the SD example for creating/deleting files. Ask me to clarify if needed.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-09T19:34:07.267" Title="most effective ( progsize/speed ) SD card usage" Tags="|arduino-nano|library|sd-card|core-libraries|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28186" PostTypeId="2" ParentId="28176" CreationDate="2016-08-09T08:33:55.073" Score="1" Body="&lt;p&gt;You could always start out attempting a simple IR detector circuit. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Google Arduino IR detector brings up several tutorials, such as &lt;a href=&quot;http://www.instructables.com/id/ARDUINO-Burglar-Alarm-Using-Infrared-Emitter-Detec/?ALLSTEPS&quot; rel=&quot;nofollow&quot;&gt;this one from the Instructables website&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You would have to change the buzzer in tutorial for an LED and resistor in series.&lt;/p&gt;&#xA;" OwnerUserId="18709" LastActivityDate="2016-08-09T08:33:55.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28187" PostTypeId="2" ParentId="28169" CreationDate="2016-08-09T10:32:23.633" Score="2" Body="&lt;p&gt;There are two ways of tackling this.  You can either switch the low-voltage DC power to the EL wire inverter (which is safe and easy) or you can switch the high voltage AC power out of the inverter (which is harder, more dangerous, but does allow you to route the power to different EL wires for animation).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The former can be arranged in just the same way as switching any heavy load from an Arduino - with an N-channel MOSFET as a low-sided switch, or a combination of N- and P-channel MOSFETs as a high-side switch. You could add further isolation with a relay should you wish. BJTs could be used instead of MOSFETs but MOSFETs are better at switching higher currents from low current sources.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For switching the high-voltage side you will need a TRIAC circuit. While it is possible to switch a TRIAC direct from the Arduino it is preferred to opt-isolate the system from the Arduino both for safety and ease of switching at higher voltages. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most common opto-isolator to use is the MOC3041 Opto-Isolated Triac. This is used to switch the gate of a higher voltage / power TRIAC to switch the load. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/LWQQ1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LWQQ1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that circuit the &quot;220V&quot; comes from the EL inverter, and the LOAD is the EL wire itself. Each EL wire you want to switch would use a copy of that circuit, but can (power permitting) use the same inverter as the source.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-09T10:32:23.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28190" PostTypeId="1" CreationDate="2016-08-09T12:28:18.820" Score="1" ViewCount="648" Body="&lt;p&gt;I'm working on a code based on &lt;a href=&quot;https://gist.github.com/kriegsman/1f7ccbbfa492a73c015e&quot; rel=&quot;nofollow noreferrer&quot;&gt;PaletteCrossfade.ino&lt;/a&gt; example. But I found the motion speed too fast. It's stated in this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  static uint8_t startIndex = 0;&#xA;  startIndex = startIndex + 1; /* motion speed */&#xA;  FillLEDsFromPaletteColors(startIndex);&#xA;  FastLED.show();&#xA;  FastLED.delay(1000 / UPDATES_PER_SECOND);&#xA;}&#xA;&#xA;void FillLEDsFromPaletteColors( uint8_t colorIndex) {&#xA;  uint8_t brightness = 255;&#xA;  for( int i = 0; i &amp;lt; NUM_LEDS; i++) {&#xA;    leds[i] = ColorFromPalette( currentPalette, colorIndex + sin8(i*16), brightness);&#xA;colorIndex += 3;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since the startIndex defined in &lt;code&gt;uint8_t&lt;/code&gt;, it cant be lower than 1. So I used float and set it to 0.2 in my code. Which seems to work, and animation slowed down. However I'm not sure how is that float value added into the &lt;code&gt;ColorFromPalette&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://fastled.io/docs/3.1/group___colorutils.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;Its documentations states&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;CRGB  ColorFromPalette (const CRGBPalette16 &amp;amp;pal, uint8_t index,&#xA;  uint8_t brightness=255, TBlendType blendType=LINEARBLEND)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To my understanding it accepts only integer, and also int based sin8 being added to float value. So, what exactly happens there? Is this method viable, or is there any better way to slow down the animation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking about adding a millis() based delay and only increasing the colorindex every 2-3 seconds or so.&lt;/p&gt;&#xA;" OwnerUserId="24157" LastEditorUserId="4628" LastEditDate="2017-06-07T09:09:39.357" LastActivityDate="2018-05-04T09:33:31.427" Title="FastLED int + float problem" Tags="|arduino-uno|float|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28194" PostTypeId="1" CreationDate="2016-08-09T14:15:33.050" Score="0" ViewCount="146" Body="&lt;p&gt;i'm trying to find out the capacitance value using the time constant of the RC ciruit. so i followed the technique on the below link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/forum/?id=12075&quot; rel=&quot;nofollow&quot;&gt;http://www.gammon.com.au/forum/?id=12075&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, it's working fine.. but still i need wider range so i want to know the full core logic of that program like how the capacitance formula has been derived out in those program?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks in advance...&lt;/p&gt;&#xA;" OwnerUserId="25615" LastActivityDate="2016-08-09T14:38:15.063" Title="how to find find out capacitance using time constant?" Tags="|arduino-uno|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28195" PostTypeId="2" ParentId="28194" CreationDate="2016-08-09T14:38:15.063" Score="3" Body="&lt;p&gt;The key concept is this line:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;... we find the point where the voltage reaches 63.2% ...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The time constant τ is how long it takes for a capacitor to charge up to 63.2% of the supply voltage. That is governed by both the capacitance (C) and the resistance (R). τ=RC. That is one of the basic formulae you should know as an Electronic Engineer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you know R (which you do because you chose it at 10KΩ) and you know τ (which you do because you measured it) then you can calculate C (τ/R). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since τ, C and R are tied together like that it is possible to change the balance of C and R and keep τ the same. For instance, a 10KΩ resistor and a 47nF capacitor would give the same τ as a 1KΩ resistor and a 470nF capacitor. Also the same τ as a 100kΩ resistor and a 4.7nF capacitor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily change the range without having to change your time measurement system by changing the resistor to give a different scale.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-09T14:38:15.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28201" PostTypeId="2" ParentId="24919" CreationDate="2016-08-09T18:23:53.180" Score="0" Body="&lt;p&gt;A search on the designer's name turned up a few posts by people working with this board. &lt;a href=&quot;http://www.esp8266.com/viewtopic.php?f=8&amp;amp;t=7352&amp;amp;start=8&quot; rel=&quot;nofollow&quot;&gt;This post&lt;/a&gt; was the most useful one I found. I don't have this shield and haven't tested this poster's instructions, but it seems worth trying:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Hi! Finally back here, more enlightened! :D I have finally done some&#xA;  stuff with the 8266 shield. I just wanted to share it with you all.&#xA;  Since I know I wanted all this before I started. I write all this a&#xA;  little bit as a &quot;for dummies&quot; just to make sure every step is&#xA;  included. So to be more precise, I use a Arduino uno with a (se&#xA;  below).&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;1: (identifying) The shield is a &quot;ESP8266 ESP-12E UART WIFI Wireless&#xA;  Shield for Arduino UNO R3&quot; (from Ebay). Since there seems to be none&#xA;  documentation about this board, hopfully this will help you. I think&#xA;  there was some pictures before on this thread. On my board it states:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&quot;Arduino ESP8266 Wifi shield. Version 0.9 by WangTongze.&quot; (and 1.0..&#xA;  I've got two)&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Here is a good link to identify which ESP8266 module you got if you&#xA;  want to know exacly what you got (if it is a different wifi board) :&#xA;  wiki/doku.php?id=esp8266-module-family&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;There a 4 DIP switches on this board are numbered from 1-4. To be&#xA;  honest I really don't know what 1 and 2 is. But my guess is that you&#xA;  can use TTL levels on TX &amp;amp; RX opposed to 3.3 which the 8266 module&#xA;  uses directly. These two are always set to DOWN for me. Second though,&#xA;  if so, I might set them to UP when using Arduino. I usually play&#xA;  around with the board with a USB to 232 converter when testing. The&#xA;  other two, 3-4, are connected to GPIO 0 and something else xD. I&#xA;  really doesn't matter really. All I know, that I set these to UP to&#xA;  start a firmware update. Here is a good link that might be somewhat&#xA;  equal to what the shield has implemented.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;http://blog.falafel.com/how-to-wire-the&quot; rel=&quot;nofollow&quot;&gt;http://blog.falafel.com/how-to-wire-the&lt;/a&gt; ... ogramming/&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;2: (using Arduino with the shield) So everywhere, including this&#xA;  thread states that Arduino UNO doesn't handle the software emulated&#xA;  serial very good at high speeds. That is true :D So I got it to work&#xA;  perfectly with a baud rate 9600. What I did was to find a firmware&#xA;  that has default baud rate 9600 from AI thinker. I never really got&#xA;  the baud change to work. AT+CIOBAUD=9600 never got stuck after a reset&#xA;  (rst button och a AT+RST). And the other AT+IPR=9600 broke the&#xA;  firmware. If someone got this to work, please write here in this&#xA;  thread!!&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Here is a link: &lt;a href=&quot;http://wiki.aprbrother.com/wiki/Firmware_For_ESP8266&quot; rel=&quot;nofollow&quot;&gt;http://wiki.aprbrother.com/wiki/Firmware_For_ESP8266&lt;/a&gt;&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The only wiring I did to make it work, is to connect the tx and rx to&#xA;  Arduino's pins. (rx-&gt;tx and tx-&gt;rx). According to this example:&#xA;  &lt;a href=&quot;http://allaboutee.com/2014/12/27/esp826&quot; rel=&quot;nofollow&quot;&gt;http://allaboutee.com/2014/12/27/esp826&lt;/a&gt; ... d-circuit/ connect to pins&#xA;  2 and 3. The tx and rx from the 8266 shield are located on the left&#xA;  down side. There are other pins you can use also.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;3: (flashing a firwmware) To set the board on flash mode, put the DIP&#xA;  switches to 3-4 to UP, press the 'ESP-RST' button. When flashing is&#xA;  done, set these to DOWN and press the 'ESP-RST'. Maybe there is a way&#xA;  to flash a firmware with the Arduino, but I finally bought a &quot;FT232RL&#xA;  3.3V 5.5V FTDI USB to TTL Serial Adapter Module for Arduino Mini Port T&quot;. There is a picture here: &lt;a href=&quot;http://blog.falafel.com/how-to-wire-the&quot; rel=&quot;nofollow&quot;&gt;http://blog.falafel.com/how-to-wire-the&lt;/a&gt;&#xA;  ... ogramming/. I use this flash software:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://github.com/Stadslab/ESP8266_exa&quot; rel=&quot;nofollow&quot;&gt;https://github.com/Stadslab/ESP8266_exa&lt;/a&gt; ... te%20Ready&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;Because you can't really do any setting with it and it has worked 100%&#xA;  of all time for me and my use.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;So to connect the FT232RL to the 8266 board:&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;(pins down) from left to right you have: dtr, rx, tx, vcc,cts and gnd&#xA;  and on the wifi shield from left to right: txd, rxd, 5v, gnd, 3v3.&#xA;  rx-&gt;txd, tx-&gt;rxd, gnd-&gt;gnd, vcc-&gt; 3v3. Remeber that the FT232RL board&#xA;  has a jumper to change the voltage. You should use 3.3v. But for me I&#xA;  had some problems flashing, so I actually the the voltage to 5v and&#xA;  then connect the vcc to 5v connector on the wifi board. Never had any&#xA;  problems after that.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-09T18:23:53.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28202" PostTypeId="1" CreationDate="2016-08-09T19:10:11.543" Score="1" ViewCount="263" Body="&lt;p&gt;I'm using a modified version of Arduino Zero Bootloader. I am trying to write software to automatically detect which USB device the bootloader is currently running on in order to execute bossac.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have noticed a few unique characteristics when using &quot;lsusb -v&quot;. Things like &quot;bDeviceClass&quot; is always 2. and &quot;bDeviceSubClass&quot; is always 0; However, I do not feel confident in using these traits to identify the bootloader. Is there any clear indication of bootloader so I can find the correct ttyACM#?&lt;/p&gt;&#xA;" OwnerUserId="25620" LastActivityDate="2017-04-07T00:21:30.597" Title="Identifying Bootloader ttyACM# device" Tags="|bootloader|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28203" PostTypeId="2" ParentId="28202" CreationDate="2016-08-09T19:32:36.153" Score="1" Body="&lt;p&gt;The only things you have at your disposal are what is in &lt;code&gt;lsusb -v&lt;/code&gt;. Using those you can craft a &lt;code&gt;udev&lt;/code&gt; rule to create a symlink to a unique device name. I do that with all my boards so that they all get a unique name.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is one of my rules:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ATTRS{idVendor}==&quot;2341&quot;, ATTRS{idProduct}==&quot;0042&quot;,  &#xA;  ATTRS{serial}==&quot;95336333635351F091B1&quot;, KERNEL==&quot;ttyACM*&quot;, &#xA;  MODE=&quot;0660&quot;, GROUP=&quot;plugdev&quot;, SYMLINK+=&quot;board/arduino/mega2560&quot;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That links &lt;code&gt;/dev/board/arduino/mega2560&lt;/code&gt; to whatever &lt;code&gt;/dev/ttyACM*&lt;/code&gt; node got created when it was plugged in.  That is in &lt;code&gt;/etc/udev/rules.d/50-boards.rules&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More on udev here: &lt;a href=&quot;http://playground.arduino.cc/Linux/Udev&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Linux/Udev&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A useful command is &lt;code&gt;udevadm info -a -n /dev/ttyACM0&lt;/code&gt; which lists all the attributes for that device which you can then use in the &lt;code&gt;udev&lt;/code&gt; rule.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-09T19:32:36.153" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28204" PostTypeId="2" ParentId="28185" CreationDate="2016-08-09T19:34:07.267" Score="2" Body="&lt;p&gt;For AVR + SDCard you should check &lt;a href=&quot;http://elm-chan.org/fsw/ff/00index_e.html&quot; rel=&quot;nofollow&quot;&gt;FatFs&lt;/a&gt; from Chang. It is widely used and proven C library. You can &lt;a href=&quot;http://elm-chan.org/fsw/ff/en/config.html&quot; rel=&quot;nofollow&quot;&gt;tweak the configuration&lt;/a&gt; file to get minimal size (8K shall be easy). Check wrapper library for Arduino &lt;a href=&quot;https://github.com/greiman/PetitFS&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (6K with default options).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also even smaller version called &lt;a href=&quot;http://elm-chan.org/fsw/ff/00index_p.html&quot; rel=&quot;nofollow&quot;&gt;Petit FAT&lt;/a&gt; (2-4K) but it doesn't support file delete feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you would like to get smallest possible code, there is option to use Atmel Studio for programming Arduino boards, but you will loose the convenience of Arduino libraries (re-implement the libraries or find AVR versions of them, work with registers directly etc).&lt;/p&gt;&#xA;" OwnerUserId="13594" LastActivityDate="2016-08-09T19:34:07.267" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28206" PostTypeId="2" ParentId="28134" CreationDate="2016-08-07T17:42:55.290" Score="0" Body="&lt;p&gt;I think that you have confused your address &lt;em&gt;encoding&lt;/em&gt; in your code. Your complete address space is only a total of 5 bits, decimal 0 to 31. Your two loops (&lt;code&gt;for ( byte count = 0; count &amp;lt; 4 ; count++ )&lt;/code&gt; and &lt;code&gt;for ( byte count_1 = 0; count_1 &amp;lt; 32 ; count_1++ )&lt;/code&gt;) are actually counting through a 7 bit address space, just with the 3 MSBs of the inner loop being ignored.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For your 32-input example, I'm going to assume that the master 4051 only has inputs A-D (&lt;code&gt;y0&lt;/code&gt; to &lt;code&gt;y3&lt;/code&gt;) connected to downstream muxes and that the analog mux decodes based on the binary value of the input select. Then your digital outputs should correspond to, for &lt;code&gt;byte address&lt;/code&gt; as your counter:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;S_S0&lt;/code&gt; -&gt; &lt;code&gt;bitRead(address, 0)&lt;/code&gt; (LSB)&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;S_S1&lt;/code&gt; -&gt; &lt;code&gt;bitRead(address, 1)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;S_S2&lt;/code&gt; -&gt; &lt;code&gt;bitRead(address, 2)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;M_S0&lt;/code&gt; -&gt; &lt;code&gt;bitRead(address, 3)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;M_S1&lt;/code&gt; -&gt; &lt;code&gt;bitRead(address, 4)&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;M_S2&lt;/code&gt; -&gt; constant &lt;code&gt;0&lt;/code&gt; (MSB)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thus, your test should only use a &lt;code&gt;for ( byte address = 0; address &amp;lt; 32 ; address++ )&lt;/code&gt; to acquire data from all 32 possible inputs. Remember to have a long enough delay from selecting a different multiplexer input to starting your ADC conversion to avoid errors due to signal settling.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally, you should be calling only one analog read location corresponding to the pin connected to the &lt;code&gt;AnalogInPin&lt;/code&gt; in the schematic. You will have to record what the current multiplexer selection to determine which of the 32 inputs is actually being recorded by that conversion. Basically, there's only one 'master&quot; analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your use of &lt;code&gt;value = (bitRead(count_1, 2),bitRead(count_1, 1),bitRead(count_1, 0));&lt;/code&gt; is confusing and seems incorrect. After you &lt;code&gt;digitalWrite()&lt;/code&gt; the new address for your multiplexers, you shouldn't need to read-back the digital pins to know what address you have selected.&lt;/p&gt;&#xA;" OwnerUserId="25734" OwnerDisplayName="user2943160" LastActivityDate="2016-08-07T17:42:55.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28213" PostTypeId="1" CreationDate="2016-08-10T04:37:41.043" Score="0" ViewCount="1570" Body="&lt;p&gt;I would like to control a pump.&#xA;The pump rating is 12 volt 60watts.&#xA;The pump mfg says to use a 12 volt power supply of 5 - 12 amps but AT LEAST 5 amps. This pump has a pressure turn off at 116 psi and the mfg states that the pump will not make maximum pressure with less than 5 amps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the question becomes, to be able to switch this pump on and off based on some sensor reading what would be considered best practice:&#xA;transistor, MOSFET, or relay?&lt;/p&gt;&#xA;" OwnerUserId="25629" LastActivityDate="2016-08-10T10:27:21.130" Title="switch pump on with transistor, mosfet, or relay" Tags="|switch|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28214" PostTypeId="1" AcceptedAnswerId="28216" CreationDate="2016-08-10T05:47:52.383" Score="2" ViewCount="3721" Body="&lt;p&gt;I am working on an autonomous robot in my summer vacations. I am currently working on running the motors of my robot in a closed loop. In order to do so, I have to interface &lt;strong&gt;two Quadrature encoders&lt;/strong&gt; of the motors with the Arduino Due that I have. My motor encoder have &lt;strong&gt;3200 Edges per Revolution&lt;/strong&gt;. I have read the Atmel SAM3x8E datasheet and have successfully tested one encoder in Arduino IDE. It appears that TIOA0 and TIOBO are used to read PHA and PHB of of one Encoder which correspond to Pin 2 and 13 of Arduino Due. I am not using Index pin (TIOB1).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/mrCuA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mrCuA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It seems that I can only interface 1 quadrature .Is their any way I can use Quadrature decoder to read 2 encoders instead of one. As I have stated earlier I am not using the index pin. So, maybe there might be a way to decode to encoders using the three available pins as shown in the above diagram. I don't want to use Interrupts to do this job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's is the link of SAM3x Manual:&#xA;&lt;a href=&quot;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Link of Motor that i am using:&#xA;www.pololu.com/product/2824&lt;/p&gt;&#xA;" OwnerUserId="25632" LastEditorUserId="25632" LastEditDate="2016-08-11T19:10:16.013" LastActivityDate="2021-03-18T18:41:55.030" Title="Reading Two Quadrature Encoder using a single Arduino Due" Tags="|arduino-due|atmel-studio|rotary-encoder|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28215" PostTypeId="2" ParentId="28213" CreationDate="2016-08-10T05:57:18.157" Score="1" Body="&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Transistor - Big voltage drop between C-E @ 5A (depends on type but it will be about 2V). Power dissipitation is voltage drop times current so about 24Watts. You must be careful with inductive load - induced high voltage must be supressed. Usual way is using anti-parallel fast diode over load.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Mosfet - Voltage drop can be really small, so it might be possible to use it without heatsink. Big Gate capacity needs strong driver to charge and discharge. If not, slow switching causes huge losses (again voltage drop times current). For inductive load it's same as for transistor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Relay - It must be selected carefully as switch-off causes electric arc (= burning contacts) and because of DC current it's burning for much longer time than AC.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-10T05:57:18.157" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28216" PostTypeId="2" ParentId="28214" CreationDate="2016-08-10T06:54:16.140" Score="1" Body="&lt;p&gt;According to &lt;a href=&quot;http://www.atmel.com/Images/Atmel-42706-Quadrature-Decoder-QDEC-for-SAM3-4-Devices_ApplicationNote_AT11483.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Quadrature Decoder QDEC for SAM3/4 Devices_ApplicationNote_AT11483&lt;/a&gt; and referenced excel sheet with &lt;a href=&quot;http://atmel.force.com/support/servlet/fileField?id=0BEG0000000HRvP&quot; rel=&quot;nofollow noreferrer&quot;&gt;Device to No of QDEC channels&lt;/a&gt; it seems to have two of them. However in DUE almost none of interesting devices are wired to headers completely (Extmem, SD interface,...)&lt;/p&gt;&#xA;&lt;p&gt;However TIOA6 and TIOB6 should be on pins 5 and 4&lt;/p&gt;&#xA;&lt;p&gt;Pin configuration should be something like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC25B_TIOA6, PIO_DEFAULT);&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC26B_TIOB6, PIO_DEFAULT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And TC0 is pretty much same as TC2, so just copy&amp;amp;paste and change TC0 to TC2&lt;/p&gt;&#xA;&lt;p&gt;Full config:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;  REG_PMC_PCER0 = PMC_PCER0_PID27 | PMC_PCER0_PID28 | PMC_PCER0_PID29; &#xA;  REG_PMC_PCER1 = PMC_PCER1_PID33 | PMC_PCER1_PID34 | PMC_PCER1_PID35;&#xA;&#xA;  PIO_Configure(PIOB, PIO_PERIPH_B, PIO_PB25B_TIOA0, PIO_DEFAULT); // arduino pin 2&#xA;  PIO_Configure(PIOB, PIO_PERIPH_B, PIO_PB27B_TIOB0, PIO_DEFAULT); // arduino pin 13&#xA;&#xA;  REG_TC0_CMR2  = TC_CMR_TCCLKS_TIMER_CLOCK4 | TC_CMR_WAVE | TC_CMR_ACPC_TOGGLE | TC_CMR_WAVSEL_UP_RC;&#xA;  REG_TC0_RC2   = F_CPU / 128 / 1;&#xA;  REG_TC0_CMR0  = TC_CMR_ABETRG | TC_CMR_LDRA_EDGE | TC_CMR_LDRB_EDGE | TC_CMR_ETRGEDG_EDGE | TC_CMR_CPCTRG;&#xA;  REG_TC0_BMR   = TC_BMR_QDEN | TC_BMR_SPEEDEN /*| TC_BMR_EDGPHA*/;&#xA;  REG_TC0_CCR0  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC0_CCR1  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC0_CCR2  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC25B_TIOA6, PIO_DEFAULT); // arduino pin 5&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC26B_TIOB6, PIO_DEFAULT); // arduino pin 4&#xA;&#xA;  REG_TC2_CMR2  = TC_CMR_TCCLKS_TIMER_CLOCK4 | TC_CMR_WAVE | TC_CMR_ACPC_TOGGLE | TC_CMR_WAVSEL_UP_RC;&#xA;  REG_TC2_RC2   = F_CPU / 128 / 10;&#xA;  REG_TC2_CMR0  = TC_CMR_ABETRG | TC_CMR_LDRA_EDGE | TC_CMR_LDRB_EDGE | TC_CMR_ETRGEDG_EDGE | TC_CMR_CPCTRG;&#xA;  REG_TC2_BMR   = TC_BMR_QDEN | TC_BMR_POSEN /*| TC_BMR_EDGPHA*/;&#xA;  REG_TC2_CCR0  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC2_CCR1  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC2_CCR2  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2021-03-18T18:41:55.030" LastActivityDate="2021-03-18T18:41:55.030" CommentCount="5" ContentLicense="CC BY-SA 4.0" />
  <row Id="28217" PostTypeId="1" AcceptedAnswerId="28218" CreationDate="2016-08-10T07:46:44.643" Score="0" ViewCount="5043" Body="&lt;p&gt;I have installed Domoticz on Raspberry Pi and bought an RfxCom 433MHz emitter/receiver. &#xA;It works well for example with Chacon DiO 54781 door sensor.&#xA;I want to create my own sensor with Arduino that would be recognized by Domoticz as a native RF 433MHz device.&#xA;In first place, I want to make a flooding sensor, I also need an On/Off information.&#xA;I would like to implement X10 protocol because it seems to be the simplest one.&lt;/p&gt;&#xA;" OwnerUserId="21405" LastActivityDate="2016-08-10T08:34:57.777" Title="Send RF 433MHz data to Domoticz RfxCom with protocol X10 from Arduino Nano" Tags="|arduino-nano|wireless|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28218" PostTypeId="2" ParentId="28217" CreationDate="2016-08-10T07:46:44.643" Score="2" Body="&lt;p&gt;I finally found a documentation about RF X10 protocol:&#xA;&lt;a href=&quot;http://www.printcapture.com/files/X10_RF_Receiver.pdf&quot; rel=&quot;nofollow&quot;&gt;X10 RF Receiver.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With following Hardware :&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Pro Mini 5V         (4€)        &lt;a href=&quot;https://www.amazon.fr/gp/product/B00QPUEFNW/ref=oh_aui_search_detailpage?ie=UTF8&amp;amp;psc=1&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.fr/gp/product/B00QPUEFNW/ref=oh_aui_search_detailpage?ie=UTF8&amp;amp;psc=1&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;RF 433MHz emitter/receiver  (3€) (Note: only the emitter is used)       &lt;a href=&quot;https://www.amazon.fr/HDigiWorld-metteur-cepteur-commande-Arduino/dp/B00JTQI39G/ref=sr_1_3?s=computers&amp;amp;ie=UTF8&amp;amp;qid=1470813610&amp;amp;sr=1-3&amp;amp;keywords=433&quot; rel=&quot;nofollow&quot;&gt;https://www.amazon.fr/HDigiWorld-metteur-cepteur-commande-Arduino/dp/B00JTQI39G/ref=sr_1_3?s=computers&amp;amp;ie=UTF8&amp;amp;qid=1470813610&amp;amp;sr=1-3&amp;amp;keywords=433&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;3 wires : VCC, GND, Signal (on Arduino pin 2)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've created the following working code for Arduino Nano :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;* Custom sensor (base code)&#xA;*&#xA;* Emission in RF 433MHz with the X10 protocol for Domoticz&#xA;*&#xA;* Hardware :&#xA;*   Arduino Pro Mini 5V         (4€)        https://www.amazon.fr/gp/product/B00QPUEFNW/ref=oh_aui_search_detailpage?ie=UTF8&amp;amp;psc=1&#xA;*   RF 433MHz emitter/receiver  (3€)        https://www.amazon.fr/HDigiWorld-metteur-cepteur-commande-Arduino/dp/B00JTQI39G/ref=sr_1_3?s=computers&amp;amp;ie=UTF8&amp;amp;qid=1470813610&amp;amp;sr=1-3&amp;amp;keywords=433&#xA;*       Note: only the emitter is used&#xA;*   3 wires : VCC, GND, Signal (on Arduino pin 2)&#xA;*&#xA;* Documentation found for RF X10: http://www.printcapture.com/files/X10_RF_Receiver.pdf&#xA;*&#xA;* Example of malformed data received in RfxMngr in mode &quot;nodec&quot; (before this code was correctly debugged) :&#xA;*&#xA;*       Packettype        = UNDECODED RF Message&#xA;*       UNDECODED NEC:1C515C86F0      &#xA;*&#xA;*&#xA;* Correct data that is now receveived by RfxMngr with this program :&#xA;*&#xA;*------------------------------------------------&#xA;*       Packettype    = Lighting1&#xA;*       subtype       = X10&#xA;*       Sequence nbr  = 13&#xA;*       housecode     = D&#xA;*       unitcode      = 1&#xA;*       Command       = On&#xA;*       Signal level  = 7  -64dBm&#xA;*------------------------------------------------&#xA;*       Packettype    = Lighting1&#xA;*       subtype       = X10&#xA;*       Sequence nbr  = 14&#xA;*       housecode     = D&#xA;*       unitcode      = 1&#xA;*       Command       = Off&#xA;*       Signal level  = 7  -64dBm&#xA;*------------------------------------------------&#xA;*/&#xA;&#xA;const int pin_emit = 2;         // Signal pin for RF433 emitter&#xA;const int pin_led = 13;         // Internal LED : it will be ON when the &quot;On&quot; command is sent in RF, and OFF the the &quot;Off&quot; command is sent (changed each 60s)&#xA;&#xA;const unsigned int X10_A1_ON = 0x00;        &#xA;const unsigned int X10_A1_OFF = 0x20;&#xA;&#xA;const unsigned int X10_address = 5;     // this is Housecode. In my case 5 results in &quot;D&quot; house code&#xA;unsigned int X10_data = X10_A1_ON;      // command. I have implemented only On/Off for unit code 1&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(pin_led, OUTPUT);&#xA;  pinMode(pin_emit, OUTPUT);&#xA;  digitalWrite(pin_emit, LOW);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;/**&#xA;* Bit to 0 : 1.125ms between rising edges, so before next bit&#xA;*/&#xA;void X10_sendBit_zero()&#xA;{&#xA;  digitalWrite(pin_emit, HIGH);&#xA;  delayMicroseconds(555);       // Arbitrary value: I took around 1.125ms divided by two for the &quot;VCC&quot; state.&#xA;  digitalWrite(pin_emit, LOW);&#xA;  delayMicroseconds(570);       // Total 555+570 : 1125µs = 1.125ms&#xA;}&#xA;&#xA;&#xA;/**&#xA;* Bit à 1 : 2.25ms entre les &quot;rising edges&quot;&#xA;*/&#xA;void X10_sendBit_one()&#xA;{&#xA;  digitalWrite(pin_emit, HIGH);&#xA;  delayMicroseconds(555);       // Arbitrary value: I took around 1.125ms divided by two for the &quot;VCC&quot; state.&#xA;  digitalWrite(pin_emit, LOW);&#xA;  delayMicroseconds(1695);      // Total 555+1695 : 2250µs = 2.250ms&#xA;}&#xA;&#xA;&#xA;&#xA;void X10_send8bits(unsigned int data)&#xA;{&#xA;  // - Send the 8 bits, and then the complementary of the 8 bits.&#xA;  // from documentation: &quot;Within each byte, bit7 is received first and bit0 last&quot;&#xA;  int mask = 0x80;&#xA;  for(int i = 0; i &amp;lt; 8; i++)&#xA;  {&#xA;    int bit = mask &amp;amp; data;&#xA;    if (bit == 0)&#xA;      X10_sendBit_zero();     &#xA;    else&#xA;      X10_sendBit_one();&#xA;&#xA;    mask = mask &amp;gt;&amp;gt; 1;&#xA;  }&#xA;}&#xA;&#xA;&#xA;/**&#xA;* Sending a byte consists of sending this byte, and then sending the opposite of the same byte.&#xA;* As we send the opposite as well as the data, the total duration is always the same : 8 * (1.125ms+2.250ms) = 8 * 3.375 = total of 27ms&#xA;*/&#xA;void X10_sendByte(unsigned int data)&#xA;{&#xA;  X10_send8bits(data);&#xA;  X10_send8bits(~data);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;/**&#xA;* Send a complete X10 packet&#xA;*&#xA;* Total duration :&#xA;* (9ms + 4.5ms) + (27ms + 27ms) + 0.555ms + 40ms = 108.055 ms&#xA;*  from doc: &quot;It appears, from articles on the 'net, that other people have seen a range from 95 msec to 116 msec for various transmitters and that standard X-10 transceivers can tolerate timing variations of 30-35% from nominal.&quot;&#xA;*/&#xA;void X10_sendState_once(unsigned int data)&#xA;{&#xA;&#xA;&#xA;  // - Header&#xA;  digitalWrite(pin_emit, HIGH); // &quot;Burst&quot; de 9ms&#xA;  delayMicroseconds(9000);&#xA;  digitalWrite(pin_emit, LOW); // Silence de 4.5ms&#xA;  delayMicroseconds(4500);&#xA;&#xA;  // - Data&#xA;  X10_sendByte(0x50); // - Address&#xA;  X10_sendByte(data); // - Data&#xA;&#xA;  // - Send a last rising edge to validate last bit&#xA;  digitalWrite(pin_emit, HIGH);&#xA;  delayMicroseconds(555);       // Arbitraty value (but always the same), for &quot;VCC&quot; state.&#xA;&#xA;  // - Footer&#xA;  digitalWrite(pin_emit, LOW); // Silence de 40ms pour signifier la fin de l'émission&#xA;  delayMicroseconds(40000);&#xA;&#xA;}&#xA;&#xA;&#xA;/**&#xA;* Send a complete packet multiple times (this X10 protocol has not ACK))&#xA;* From doc: &quot;Most X-10 RF transmitters send a minimum of five copies of the code separated by 40 msec silences although some can send single bursts.&quot; &#xA;*&#xA;*  5 times 108.055ms = 540.275 ms, half a second&#xA;*/&#xA;void X10_sendState(unsigned int data)&#xA;{&#xA;  // - &quot;clean&quot; to be sure to have a zero for the first rising edge on init&#xA;  digitalWrite(pin_emit, LOW);&#xA;  delay(1);&#xA;&#xA;  // - Send 5 time complete packet&#xA;  for(int repeat=0 ; repeat&amp;lt;5 ; repeat++)&#xA;    X10_sendState_once(data);&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  if(X10_data == X10_A1_ON)&#xA;    digitalWrite(pin_led, HIGH);&#xA;  else&#xA;    digitalWrite(pin_led, LOW);&#xA;  X10_sendState(X10_data);&#xA;  delay(60000);              // 1 minute&#xA;&#xA;  // - I change state each 60 seconds to see changes in Domoticz&#xA;  if(X10_data == X10_A1_ON)&#xA;    X10_data = X10_A1_OFF;&#xA;  else&#xA;    X10_data = X10_A1_ON;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;By changing House code and data, it is now possible to create our own RF sensors.&lt;/p&gt;&#xA;" OwnerUserId="21405" LastEditorUserId="21405" LastEditDate="2016-08-10T08:34:57.777" LastActivityDate="2016-08-10T08:34:57.777" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28219" PostTypeId="1" AcceptedAnswerId="28228" CreationDate="2016-08-10T08:15:49.777" Score="0" ViewCount="315" Body="&lt;p&gt;I called HTTP web service on Arduino Uno, now i am trying to store the data in SD card. But as soon as i compile the program, it shows LOW MEMORY error and no data stored in SD card.&#xA;Any one can help?&lt;/p&gt;&#xA;" OwnerUserId="24284" LastActivityDate="2016-08-11T05:11:59.647" Title="Low memory error using SD card" Tags="|arduino-uno|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28220" PostTypeId="1" AcceptedAnswerId="28221" CreationDate="2016-08-10T09:07:23.120" Score="3" ViewCount="177" Body="&lt;p&gt;The Arduino documentation says &lt;strong&gt;if(Serial)&lt;/strong&gt; always returns 1, except for the case where Leonardo USB serial connection delays becoming ready.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Leonardo has two USB IDs, and switches between them for boot loader and Serial USB.  After boot loader finishes and kicks off the program, it takes a while for the USB master (e.g. your PC) to process the disconnect of the boot loader USB device and the connection of the Serial USB device.  Thus the need for a wait.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now &quot;&lt;em&gt;Serial&lt;/em&gt;&quot; is a static external instantiation of the &lt;em&gt;Serial_&lt;/em&gt; class (defined as &lt;strong&gt;&lt;em&gt;extern Serial_ Serial;&lt;/em&gt;&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The c++ rules, as I understand them, do not allow a constructor to return a value, nor may the class name (which is also the constructor name) be used as a member (function) name in the class.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;em&gt;Serial&lt;/em&gt;&quot; cannot be defined in class &lt;em&gt;Serial_&lt;/em&gt;, or the &lt;strong&gt;if(Serial)&lt;/strong&gt; syntax would have to be &lt;strong&gt;if(Serial.Serial)&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;&lt;em&gt;Serial&lt;/em&gt;&quot; cannot be defined outside the &lt;strong&gt;class Serial_,&lt;/strong&gt; or it will conflict with (i.e. hide) the definition of &lt;em&gt;Serial&lt;/em&gt; as an instantiation of &lt;em&gt;Serial_&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;&lt;em&gt;So how does the Arduino IDE do it?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All I can think of is that the magic pre-scanner does something...  But what exactly, pray tell?  &lt;/p&gt;&#xA;" OwnerUserId="14697" LastEditorUserId="14697" LastEditDate="2016-08-10T10:12:20.493" LastActivityDate="2016-08-10T10:12:20.493" Title="How does if(serial) work, a c++ question" Tags="|c++|arduino-ide|attiny|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28221" PostTypeId="2" ParentId="28220" CreationDate="2016-08-10T09:20:19.507" Score="3" Body="&lt;p&gt;It's not the constructor that's returning the value, it's the &lt;code&gt;bool&lt;/code&gt; operator:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;HardwareSerial::operator bool() {&#xA;    return true;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Leonardo:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial_::operator bool() {&#xA;    bool result = false;&#xA;    if (_usbLineInfo.lineState &amp;gt; 0)&#xA;        result = true;&#xA;    delay(10);&#xA;    return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When you use the object in a setting where a boolean value is expected of it (e.g., &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt; etc.) the &lt;code&gt;bool()&lt;/code&gt; operator is called (if it exists) and that value is used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More specifically, the &lt;code&gt;bool()&lt;/code&gt; operator is called when the object is being &lt;em&gt;cast&lt;/em&gt; to a &lt;code&gt;bool&lt;/code&gt; type, either implicitly (as in &lt;code&gt;if...&lt;/code&gt;) or explicitly (as in &lt;code&gt;... = (bool)Serial;&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More on C++ class operators here: &lt;a href=&quot;http://en.cppreference.com/w/cpp/language/operators&quot; rel=&quot;nofollow&quot;&gt;http://en.cppreference.com/w/cpp/language/operators&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-10T09:20:19.507" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28222" PostTypeId="1" CreationDate="2016-08-10T09:35:48.180" Score="6" ViewCount="10641" Body="&lt;p&gt;Lately I was asking myself about the possibility of measuring a potentiometer resistance with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is it possible?&lt;/li&gt;&#xA;&lt;li&gt;If it's possible, what kind of restriction does the Arduino have with the resistance value measured?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="25635" LastEditorUserId="972" LastEditDate="2018-05-11T16:10:03.193" LastActivityDate="2018-05-11T16:10:03.193" Title="A question about resistance measurement with arduino" Tags="|arduino-uno|arduino-leonardo|analogread|potentiometer|analogwrite|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="28224" PostTypeId="2" ParentId="28213" CreationDate="2016-08-10T10:27:21.130" Score="1" Body="&lt;p&gt;The problem with a MOSFET is that at 5A you might find that the arduino output pin can't deliver enough voltage to the gate of the MOSFET to get it to fully turn on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the transistor, it is possible to use a transistor however it is probably best to construct it as a high side switch as opposed to a low side switch. This is to deal with potential problems that may arise with disconnecting the ground from the pump whilst running.&lt;br&gt;&#xA;&lt;a href=&quot;http://jeelabs.org/2012/11/11/low-side-switching/&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is a good article which explains why low side switching can be bad&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best possible solution in this circumstance would be to use a relay connected to a NPN transistor which switches the low side of the relay. This isolates the delicate arduino electronics from the pump.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/xMxjg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/xMxjg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19785" LastActivityDate="2016-08-10T10:27:21.130" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28225" PostTypeId="2" ParentId="28222" CreationDate="2016-08-10T11:02:15.640" Score="2" Body="&lt;p&gt;&lt;em&gt;The question isn't explicitly clear, this answer is based on having a single known value pot and wishing to know its resistance at any one point rather than trying to find an unknown resistance entirely&lt;/em&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can't measure resistance directly. What you can do however is measure the voltage across a potentiometer.&lt;br&gt;&#xA;There is a really good example provided by arduino &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage&quot; rel=&quot;nofollow&quot;&gt;which can be found here&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, it is possible to turn this into a resistance value with a little bit of editing to the code &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int potPin = A0;    // Select the input pin for the potentiometer&#xA;int potR = 1000;    // This is your max potentiometer resistance in Ohms&#xA;int val = 0;        // Variable to store the value coming from the sensor&#xA;float voltage;      // This is the voltage from the wiper of the pot&#xA;float resistance;   // This is the resistance of the pot at the wiper&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  val = analogRead(potPin);                      // Read the value from the pot wiper&#xA;  voltage = val * (5.0 / 1023.0);                // Convert the value into a voltage&#xA;  resistance = (voltage / 5.0) * potR;           // Convert the voltage into a resistance&#xA;  Serial.print(&quot;Voltage = &quot;);&#xA;  Serial.print(voltage);                         // Print the voltage&#xA;  Serial.println(&quot;V&quot;);                           &#xA;  Serial.print(&quot;Resistance = &quot;);&#xA;  Serial.print(resistance);                      // Print the resistance&#xA;  Serial.println(&quot;R&quot;);&#xA;  delay(1000);                                   // Add a little delay                           &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As for your second question, it can do as high a resistance as you want. As long as you update the potR value in the code with the resistance of your pot (e.g. 1000000 for a 1MOhm pot)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I'm an electronics engineer by trade so my code could probably be cleaned up and made more efficient, this is just a starting point&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="19785" LastEditorUserId="19785" LastEditDate="2016-08-11T08:36:46.697" LastActivityDate="2016-08-11T08:36:46.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28227" PostTypeId="2" ParentId="28190" CreationDate="2016-08-10T12:46:20.603" Score="1" Body="&lt;p&gt;The code you have seems to fill the lights with a colour and change every nth of a second.  You could control that to change every 1ms to 2^16ms (which is 65 seconds) just by changing the FastLED.delay() value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;sin8() might return a float or I suspect an int, but colourIndex is an uint8_t so that is a whole number.  All it is doing is picking a colour, based on some scheme.  If the value passed to the function is a float i.e. 1.611 then it will be converted to an int by taking just the whole number part, in this case 1.  It does not round up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its not clear what you are trying to do.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are trying to slow the rate that the LEDs change colour, you need to change the delay statement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to smooth the transition between colours you need to change in the area of the sin8 statement, but what you change it to will depend on what your palette is loaded with.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope that helps, if not please can you try and describe what it is you are tying to achieve.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-10T12:46:20.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28228" PostTypeId="2" ParentId="28219" CreationDate="2016-08-10T12:49:27.603" Score="0" Body="&lt;p&gt;Try Arduino mega. It has more memory 8 KB RAM, 256 KB flash memory.&lt;/p&gt;&#xA;" OwnerUserId="21624" LastActivityDate="2016-08-10T12:49:27.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28229" PostTypeId="2" ParentId="28222" CreationDate="2016-08-10T12:59:57.000" Score="8" Body="&lt;p&gt;If you know Ohm's Law (which you should) and you realise that the ADC measures voltage, you should be able to work it out from there. But I will go into minute detail for you to ensure you understand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ohm's Law defines the relationship between Voltage (V), Current (I) and Resistance (R).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R = V/I&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To find one unknown value (in your case R) you need to know the other two values.  That is, the current flowing through the resistor, and the voltage dropped across the resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We have no way of directly measuring current, but we can measure voltage using the ADC. So if we can somehow measure a voltage and use that to calculate the current then we have two of the three values and we can calculate the third. However, calculating the current requires that we know the resistance - and that is what we are wanting to find out.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So we need to then provide a &lt;em&gt;known&lt;/em&gt; resistance that we can measure the voltage across, and thus find the current flowing through it. First a couple of reminders of basics:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Current flows the same through all resistances connected in series&lt;/li&gt;&#xA;&lt;li&gt;The sum of all voltages dropped across resistors in series equals the total voltage across all the resistors.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So if we put two resistors in series and apply an fixed voltage across it (5V in our case) a single current will flow through them both. With that two voltages will be dropped across the resistors - and those two voltages will add up to 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If we have one known resistor and one unknown resistor and we know the voltage dropped across both resistors then we can calculate the current that is flowing through the known resistor. And that current is the same current that is flowing through the unknown resistor. And since we know the voltage drop across that resistor we can then calculate its resistance using that voltage and the current we have just calculated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the circuit I just described:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/27kWo.png&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/27kWo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Vin us 5V. Let's have R1 as, say, 10KΩ (a common enough value). R2 we don't know.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the ADC of the Arduino we measure a value of 681. First we convert that into a voltage:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = 681 / 1024.0 * 5.0&#xA;     = 3.325V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So we know that R2 has 3.325V dropped across it, and since all the voltages must add up to 5V we know that R1 has (5 - 3.325) 1.675V dropped across it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the current (I=V/R) through R1 must be (1.675 / 10,000) 167.5µA (0.0001675A).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we can calculate the resistance of R2 since R=V/I and V is 3.325 and I is 0.0001675, so R must be 19850Ω - or pretty much 20KΩ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's the long-hand version from a current-based perspective. However there is a short-cut. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the output voltage is a simple ratio of the input voltage defined by the ratio between the resistors we can use that to create a much simpler formula.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;From the example above the output voltage is two thirds the input voltage - and R2 is two thirds the total resistance (R1+R2). The two match perfectly.  So we can use a simple ratio calculation to give us the resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, the ratio formula:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Vout = R2 / (R1 + R2) * Vin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;(that's R2 as a proportion of the total resistance multiplied by the input voltage)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When rearranged to get R2 gives us:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R2 = R1 * (1 / ((Vin / Vout) - 1))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So taking the voltage we measured above (3.325) and the known resistor (10,000Ω) and the input voltage (5V) and substituting those values into the formula, we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;R2 = 10,000 * (1 / ((5 / 3.325) - 1))&#xA;   = 10,000 * (1 / (1.504) - 1)&#xA;   = 10,000 * (1 / 0.504)&#xA;   = 10,000 * 1.984&#xA;   = 19840&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or pretty much 20KΩ. (Note: the discrepancy in the results is purely due to rounding errors. Use higher precision values and you get better results).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have to have a rough idea of the kind of order of magnitude of resistor you are trying to find, though, in order to select an R1 of a comparable value so that the voltage Vout is large enough to measure accurately. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you need to be aware that the input to the ADC has quite a (relatively) low impedance (can be very crudely thought of as a resistor between the input and ground) which is measured in the low mega-ohm range. This can have an impact on the values you read with the ADC if your resistors are too high, since this impedance will be in parallel to the resistor R2, so you'd actually be measuring the resistance of both R2 and the ADC's input in parallel. To measure very high resistances you should first buffer the ADC through a &lt;em&gt;voltage follower&lt;/em&gt; with a very high (tens or hundreds of tera-ohms) impedance input.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-11T10:22:34.810" LastActivityDate="2016-08-11T10:22:34.810" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28230" PostTypeId="1" CreationDate="2016-08-10T08:26:49.170" Score="1" ViewCount="611" Body="&lt;p&gt;To start, I am a software guy, so I am not too clued up on the electronics side of things. My question is: I have a number of Arduino shields and would like to power them with a portable power source, and therefore would like some advice on what to use without frying any electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a list of the current equipment that will require power:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 2560&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;SIM900 GPRS/GSM Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/13750&quot; rel=&quot;nofollow&quot;&gt;Sparkfun GPS Logger Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/13287&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Wifi Shield - ESP8266&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The shields will be stacked on top of each other. &lt;/p&gt;&#xA;" OwnerUserId="12166" OwnerDisplayName="Calco" LastActivityDate="2016-08-10T15:31:39.573" Title="Powering multiple Arduino shields" Tags="|power|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28231" PostTypeId="2" ParentId="28230" CreationDate="2016-08-10T09:11:53.350" Score="1" Body="&lt;p&gt;All the shields are 5v compatible. So no need to worry about 3.3v.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But there may be a chance of insufficient current if you use a battery to the power-jack of arduino mega (due to the internal voltage regulator). I'd suggest you cut a USB cable and solder the +5(red color) wire to VIN on the mega and ground(black wire) to GND pin. And use a 'power bank', which is used for mobile phones.&lt;/p&gt;&#xA;" OwnerUserId="25643" OwnerDisplayName="Sanu - Open Maker" LastEditorUserId="2881" LastEditDate="2016-08-10T15:31:39.573" LastActivityDate="2016-08-10T15:31:39.573" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28232" PostTypeId="2" ParentId="28230" CreationDate="2016-08-10T13:25:15.953" Score="1" Body="&lt;p&gt;Your stack will need quite a lot of current - most probably more than the Arduino can supply itself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will need to provide your own regulated 5V supply - either from a USB port (convenient if you are by a computer) - as long as it can supply more than 500mA of current (you need a Charging Downstream Port &lt;em&gt;CDP&lt;/em&gt; for that) or from some external regulated 5V power supply, such as a mobile phone charger.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That 5V supply should be connected direct to the 5V pin of the Arduino's power header.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One thing to note: the headers themselves are only rated for up to 1A. If you need more than 1A throughout the entire stack it could be worth connecting the 5V power supply direct to the 5V pins of ALL the shields in the stack. Also do the same with the GND pins to the negative of the power supply. That way the high current doesn't need to flow through the pins themselves.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-10T13:25:15.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28233" PostTypeId="1" CreationDate="2016-08-10T13:32:12.240" Score="1" ViewCount="4426" Body="&lt;p&gt;I've recently gotten my hands on an Arduino (or rather a Genuino, but the overall architecture should be the same) UNO. I'm now using that Arduino to test how data is transmitted from a USB to Serial Connector to the Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've already verified that data transmission from Arduino to the PC is possible, by using hTerm and PySerial. However, whenever I send data from Pyserial or hTerm, it doesn't show up in the Arduino serial terminal. Also, I'm using SoftwareSerial to set up a secondary serial terminal to see what the Arduino receives. (I'm using the standard serial port to send data to the terminal, and the SoftwareSerial Port to connect to the USB to Serial Connector.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's my code so far: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Python side:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-python prettyprint-override&quot;&gt;&lt;code&gt;import serial&#xA;import time&#xA;import sys&#xA;import struct&#xA;ser = serial.Serial('COM3', 9600, timeout=0)&#xA;time.sleep(10)&#xA;while 1:&#xA;    print(ser.write(struct.pack('&amp;gt;B', 0)))&#xA;    time.sleep(2)&#xA;    print(1)&#xA;    sys.stdout.flush()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Arduino side looks like this, and is essentially the default example:&#xA;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Tutorial/SoftwareSerialExample&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;SoftwareSerial mySerial(10, 11); // RX, TX&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  if (Serial) {&#xA;    Serial.end();&#xA;  }&#xA;  Serial.begin(9600);&#xA;  while (!Serial) {&#xA;    ;&#xA;  }&#xA;&#xA;  Serial.println(&quot;Godnight moon!&quot;);&#xA;&#xA;  mySerial.begin(9600);&#xA;  mySerial.println(&quot;Hello, world?&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  mySerial.listen();&#xA;  if (mySerial.available() &amp;gt; 0) {&#xA;    Serial.println(&quot;Hello User&quot;);&#xA;    Serial.println(mySerial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The Terminal never prints &quot;Hello User&quot;. Also, no other signals are being printed. By removing the if-condition, I get a whole lot of &quot;Hello User&quot; and &quot;-1&quot; in the Arduino IDE serial monitor. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Concerning my setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've got an USB to Serial converter, which is connected as &quot;COM3&quot;. On the other side, I have an Arduino UNO which is connected via USB to the same computer. The TX pin of the converter is connected to the RX pin of the Arduino and vice versa. Also, Ground is connected to Ground. Furthermore, I use Jupyter/IPython notebook to run my Python script, and the default Arduino IDE to compile programs for my Arduino. In the case there I received data from the Arduino, I used the script specified in the URL provided, which is very similar to the one I'm already showing here. Also, &lt;code&gt;ser.write()&lt;/code&gt; is replaced by &lt;code&gt;ser.read(1)&lt;/code&gt;, so that it reads one byte at a time. My system is Windows 7 (64 Bit). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: Here is an established connection between hTerm (a serial terminal) and the Python script while using com0com as a port emulator.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/cEkD9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/cEkD9.png&quot; alt=&quot;A successful communication between the Python script and hTerm&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25642" LastEditorUserId="26916" LastEditDate="2017-11-06T13:57:18.207" LastActivityDate="2018-05-05T22:37:48.953" Title="Arduino-Pyserial communication on Python 3, Windows machine: Pyserial.write() doesn't seem to do anything" Tags="|serial|softwareserial|python|" AnswerCount="2" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="28236" PostTypeId="1" CreationDate="2016-08-10T15:21:27.327" Score="1" ViewCount="202" Body="&lt;p&gt;When compiling I get the error &#xA;'as: unknown option »-mmcu=avr5« exit status 1' &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I succeeded now using your piece of advise. Thank you so much.&lt;/p&gt;&#xA;" OwnerUserId="25645" LastEditorUserId="25645" LastEditDate="2016-08-10T20:33:32.713" LastActivityDate="2016-08-10T20:33:32.713" Title="IDE 1.6.10 on LinuxMint 17.3 Cinnamon" Tags="|arduino-uno|arduino-ide|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28239" PostTypeId="2" ParentId="28236" CreationDate="2016-08-10T18:01:58.623" Score="1" Body="&lt;p&gt;Delete or rename the old &quot;Arduino15&quot; directory located at /home/(username)/.arduino15    (a.k.a. ~/.arduino15) and re-install 1.6.10.&lt;/p&gt;&#xA;" OwnerUserId="24064" LastActivityDate="2016-08-10T18:01:58.623" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28242" PostTypeId="1" AcceptedAnswerId="28243" CreationDate="2016-08-10T20:06:05.583" Score="1" ViewCount="142" Body="&lt;p&gt;I have LED bar graph on pins 2-11. Eventually I want to use a voltage divider to figure out the amount of voltage left in a power supply. Currently, this script should set the number of LEDs on the bar graph based on &lt;code&gt;round((v_actual/v_reference)*10)&lt;/code&gt;, I am just using some placeholder numbers in the mean time to test this portion of the script e.g. &lt;code&gt;v_actual&lt;/code&gt; of 5 and &lt;code&gt;v_reference&lt;/code&gt; of 10. However, the &lt;code&gt;convert&lt;/code&gt; variable &lt;em&gt;keeps printing 0&lt;/em&gt;. I've checked that the other variables were passing and they are. What is the issue here?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int ledBarNum = 10;    // # of leds&#xA;int vref = 10;     // max voltage of power supply&#xA;&#xA;void setup(){&#xA;  pinMode(2, OUTPUT);&#xA;  pinMode(3, OUTPUT);&#xA;  pinMode(4, OUTPUT);&#xA;  pinMode(5, OUTPUT);&#xA;  pinMode(6, OUTPUT);&#xA;  pinMode(7, OUTPUT);&#xA;  pinMode(8, OUTPUT);&#xA;  pinMode(9, OUTPUT);&#xA;  pinMode(10, OUTPUT);&#xA;  pinMode(11, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  ledBarSetup(5);&#xA;}&#xA;&#xA;void ledBarSetup(int v) {&#xA;&#xA;  // logic vref=8; vactual or v = 4; (4/8)*10 = 2 &#xA;  // e.g. number of leds we need to light up to represent the total amt left&#xA;&#xA;  Serial.println(v);&#xA;  Serial.println(vref);&#xA;&#xA;  int convert = round((v/vref)*10);&#xA;&#xA;  Serial.println(convert);&#xA;&#xA;  ledBar(convert);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void ledBar(int n) {&#xA;&#xA;  int startingPin = 2;&#xA;&#xA;  for (int thisPin = 2; thisPin &amp;lt; ledBarNum; thisPin++) {&#xA;&#xA;    if (thisPin &amp;lt;= n) {&#xA;&#xA;      digitalWrite(thisPin, HIGH);&#xA;&#xA;    } else {&#xA;&#xA;      digitalWrite(thisPin, LOW);&#xA;&#xA;    }&#xA;&#xA;  }&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25651" LastActivityDate="2016-08-10T20:10:45.963" Title="LED bar graph script not working" Tags="|led|arduino-nano|arduino-micro|mathematics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28243" PostTypeId="2" ParentId="28242" CreationDate="2016-08-10T20:10:45.963" Score="4" Body="&lt;p&gt;Both &lt;code&gt;v&lt;/code&gt; and &lt;code&gt;vref&lt;/code&gt; are integers, which means that integer division will be performed. if &lt;code&gt;v&lt;/code&gt; is ever less than &lt;code&gt;vref&lt;/code&gt; then the result will be 0. Multiply first, then divide.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-10T20:10:45.963" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28244" PostTypeId="1" AcceptedAnswerId="28257" CreationDate="2016-08-10T20:44:16.560" Score="5" ViewCount="3697" Body="&lt;p&gt;I have been working on an arduino program, which has gotten rather large. I am close to hitting the 32k limit on Flash for my ATmega328p. I would like lower my program size by saving some of my many string literals into EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All of the example programs on the EEPROM page suggest loading them in at runtime, in which case they would take up flash memory anyways! What I am wondering, is if there is a way to write to EEPROM from my PC, THEN load the arduino program which will access those values. Do I need some external hardware to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-sam&lt;/p&gt;&#xA;" OwnerUserId="23278" LastActivityDate="2016-08-12T02:11:42.377" Title="Set EEPROM from PC before program" Tags="|eeprom|code-optimization|flash|" AnswerCount="3" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28246" PostTypeId="1" AcceptedAnswerId="28248" CreationDate="2016-08-10T23:44:01.357" Score="0" ViewCount="371" Body="&lt;p&gt;I've written a program which allows me to use my &lt;code&gt;Arduino Uno&lt;/code&gt; to send a &lt;code&gt;PWM&lt;/code&gt; to an &lt;strong&gt;Electronic Speed Controller&lt;/strong&gt;. 5 seconds after startup the ESC is sent a config via &lt;code&gt;PWM&lt;/code&gt; to signal the low to high &lt;code&gt;PWM&lt;/code&gt; range to be used by the ESC. Then I can type into the &lt;code&gt;Serial Monitor&lt;/code&gt; a single digit 0-9 to pick the &lt;code&gt;PWM&lt;/code&gt; I want to send to my ESC. &lt;em&gt;(n*2 = pwm)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;This works great when running code for &lt;em&gt;one&lt;/em&gt; ESC, but adding code for a &lt;em&gt;second&lt;/em&gt; ESC causes significant issues (I only have one ESC plugged in). When I send a &lt;code&gt;serial&lt;/code&gt; command to specify &lt;code&gt;PWM&lt;/code&gt; rate, my ESC only receives the &lt;code&gt;PWM&lt;/code&gt; change &lt;em&gt;sometimes&lt;/em&gt;. About 2/3 times it ignores the PWM change and keeps spinning at the same rate it was already at.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;strong&gt;What's going on here?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Code&lt;/h1&gt;&#xA;&lt;p&gt;&lt;strong&gt;WorkingESCSoftware&lt;/strong&gt; &lt;em&gt;(main file of .eno)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareServo.h&amp;gt;&#xA;#include &amp;quot;TestClass.h&amp;quot;&#xA;&#xA;int val;    // variable to read the value from the analog pin&#xA;int stage = 0;&#xA;&#xA;TestClass t, t2;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;&#xA;  t = TestClass();&#xA;  t.setPin(3);&#xA;  t2 = TestClass();&#xA;  t2.setPin(5);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  t.loop();&#xA;  t2.loop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;TestClass.h&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;class TestClass {&#xA;  private:&#xA;    SoftwareServo servo;&#xA;    bool _initialized = false;&#xA;    &#xA;    int PWM_MAX = 180;&#xA;    int PWM_HIGH = 170;&#xA;    int PWM_MEDIUM = 80;&#xA;    int PWM_LOW = 40;&#xA;    int PWM_OFF = 25; // has to be between esc config off (stop) and low (slow spin)&#xA;  public:&#xA;    TestClass();&#xA;    void setPin(int);&#xA;    void loop();&#xA;};&#xA;&#xA;TestClass::TestClass() {&#xA;  Serial.println(&amp;quot;cycle lipo power to esc&amp;quot;);&#xA;}&#xA;&#xA;void TestClass::setPin(int pin) {&#xA;  this-&amp;gt;servo.attach(pin);&#xA;}&#xA;&#xA;void TestClass::loop() {&#xA;  //  Serial.println(&amp;quot;loop&amp;quot;);&#xA;  &#xA;  // 5 seconds after power, send PWM range to ESC&#xA;  if(millis() &amp;gt; 5000 &amp;amp;&amp;amp; this-&amp;gt;_initialized == false) {&#xA;    this-&amp;gt;_initialized = true;&#xA;&#xA;    Serial.println(&amp;quot;esc setup&amp;quot;);&#xA;    this-&amp;gt;servo.write(PWM_MAX);&#xA;    delay(5);&#xA;    this-&amp;gt;servo.write(PWM_OFF);&#xA;    delay(5);&#xA;    Serial.println(&amp;quot;esc ready&amp;quot;);&#xA;  }&#xA;  &#xA;  char r = Serial.read();&#xA;  String inStr = String(r);&#xA;  if(r &amp;gt; -1) {&#xA;    Serial.print(&amp;quot;serial in: &amp;quot;);&#xA;    Serial.println(inStr);&#xA;  }&#xA;&#xA;  use h, m, l, o, or 0-9 to control PWM of ESC&#xA;  if(r &amp;lt;= -1) {&#xA;    // void&#xA;  } else if(inStr == &amp;quot;h&amp;quot;) { // high&#xA;    Serial.print(&amp;quot;HIGH: &amp;quot;);&#xA;    Serial.println(PWM_HIGH);&#xA;    this-&amp;gt;servo.write(PWM_HIGH); // highest spinning (same as 160?)&#xA;  } else if(inStr == &amp;quot;m&amp;quot;) { // medium&#xA;    Serial.print(&amp;quot;MED: &amp;quot;);&#xA;    Serial.println(PWM_MEDIUM);&#xA;    this-&amp;gt;servo.write(PWM_MEDIUM);&#xA;  } else if (inStr == &amp;quot;l&amp;quot;) { // low&#xA;    Serial.print(&amp;quot;LOW: &amp;quot;);&#xA;    Serial.println(PWM_LOW);&#xA;    this-&amp;gt;servo.write(PWM_LOW);&#xA;  } else if (inStr == &amp;quot;o&amp;quot;) {&#xA;    Serial.println(&amp;quot;OFF&amp;quot;);&#xA;    this-&amp;gt;servo.write(PWM_OFF);&#xA;  } else if (inStr.toInt() &amp;gt;= 0 &amp;amp;&amp;amp; inStr.toInt() &amp;lt;= 9) {&#xA;    int val = inStr.toInt() * 20;&#xA;    Serial.println(val);&#xA;    this-&amp;gt;servo.write(val);&#xA;  }&#xA;&#xA;//  SoftwareServo::refresh();&#xA;  this-&amp;gt;servo.refresh();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19838" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-11T03:25:34.120" Title="Problems with running multiple ESC" Tags="|arduino-uno|pwm|servo|electronics|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28248" PostTypeId="2" ParentId="28246" CreationDate="2016-08-11T03:25:34.120" Score="1" Body="&lt;p&gt;You have two copies of your program sharing one physical resource, the serial port input to the Arduino.  It is by chance which of the two copies will receive and process the input data.  So this approach will not work dependably.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Semaphore_%28programming%29&quot; rel=&quot;nofollow&quot;&gt;Semiphoras&lt;/a&gt; are often used when sharing hardware among several programs.  However you are not only sharing hardware, but also the data being sent to the Arduino.  And the data will only be sent once.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this case, you need to handle the data once in code that is separate from the 2 instantiations of the ESP class.  That is, you need to process the received data once and pass that processed data to the appropriate instantiation of the ESP class.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-08-11T03:25:34.120" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28249" PostTypeId="2" ParentId="28219" CreationDate="2016-08-11T05:11:59.647" Score="0" Body="&lt;p&gt;Try to use properly  kind of variables for example if u r using Int in a value can would  use byte of try to put some serial.println(F(&quot;wherever  you can print &quot;))  for running  on sram instead of  stack memory. &lt;/p&gt;&#xA;" OwnerUserId="13373" LastActivityDate="2016-08-11T05:11:59.647" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28250" PostTypeId="2" ParentId="26692" CreationDate="2016-08-11T06:25:33.363" Score="0" Body="&lt;p&gt;Please note that 'Scope' of a variable is limited inside the block ( &lt;em&gt;a block starts at &lt;strong&gt;{&lt;/strong&gt; and ends at &lt;strong&gt;}&lt;/strong&gt;&lt;/em&gt; ), and that variable cant be accessed outside the block.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;consider &lt;strong&gt;life time&lt;/strong&gt; of a variable as well. using the keyword &lt;strong&gt;static&lt;/strong&gt; may can help you some times. refer this &lt;a href=&quot;https://stackoverflow.com/questions/5033627/static-variable-inside-of-a-function-in-c&quot;&gt;link.&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25643" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-08-11T06:25:33.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28251" PostTypeId="2" ParentId="26275" CreationDate="2016-08-11T06:33:40.113" Score="0" Body="&lt;p&gt;Yes. Servo can rotate to a particular angle irrespective of previous position.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But you may face an issue here if you rotated the shaft manually by hand (when servo is not powered), and if you reassembled the shaft to the servo in a different orientation. Actually it is really hard to re assemble a removed shaft to the same angle position. &lt;/p&gt;&#xA;" OwnerUserId="25643" LastActivityDate="2016-08-11T06:33:40.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28252" PostTypeId="2" ParentId="28244" CreationDate="2016-08-11T07:42:02.773" Score="3" Body="&lt;p&gt;I think here is a confusion about the three types of memory. EEPROM, FLASH and SRAM are completely separate. EEPROM is like your file storage. FLASH contains you program and static values. SRAM is the memory the program is working with. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Static values are loaded from FLASH into SRAM upon start unless you declare your static content not to load automatically by using the according Macro &lt;code&gt;PROGMEM&lt;/code&gt;. In that case it does not eat up your SRAM until you manually read it from FLASH into SRAM. &lt;code&gt;#include &amp;lt;avr/pgmspace.h&amp;gt;&lt;/code&gt; is used for this (&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html&quot; rel=&quot;nofollow&quot;&gt;pgmspace.h&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EEPROM is not loaded automatically and therefore must be read explicitly. &lt;code&gt;#include &amp;lt;avr/eeprom.h&amp;gt;&lt;/code&gt; contains all the functionality (&lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html&quot; rel=&quot;nofollow&quot;&gt;eeprom.h&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure about the Arduino IDE but with avrdude you can program the EEPROM separately without having the values been predefined in your program. The &lt;a href=&quot;http://www.nongnu.org/avrdude/user-manual/avrdude_6.html&quot; rel=&quot;nofollow&quot;&gt;third example&lt;/a&gt; in the AVRdude manual shows how to flash the program, eeprom and fuses at once.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-08-11T07:42:02.773" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28253" PostTypeId="2" ParentId="28233" CreationDate="2016-08-11T08:00:02.417" Score="1" Body="&lt;p&gt;What do you think should come out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm no expert with Python but you seem to be using struct pack, which I think prepends a number of bytes to the data to generate a 4 byte word.  You are using NULL, 0 to pack the structure.  When Serial.println() encounter a NULL it will assume that is the end of the string.  So you seem to be printing a zero byte string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Oh and Serial.read() only reads one byte of data, so there is an issue with that too. I suspect that the write call has a similar issue, you normally need to supply a size parameter because its binary data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does that make sense?&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-11T08:00:02.417" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28255" PostTypeId="1" AcceptedAnswerId="28260" CreationDate="2016-08-11T10:13:42.333" Score="1" ViewCount="1717" Body="&lt;p&gt;I have the following system:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/qqxsc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/qqxsc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As a master, I have an Arduino UNO Chip, more specifically an Atmel MEGA328P. The important thing is that this microcontroller has only one hardware Serial port, and that port is used to communicate with a WiFi adapter. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem I'm facing with is that I want to receive data from a Compass and a GPS modules. Booth send data via Serial protocol. The 328p Chip have only one serial which is busy!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;I can't use SoftwareSerial as I don't want any delay on master board!&lt;/strong&gt;&#xA;I can't also use Arduino Mega2560 which have 3 Serial ports as its sizes are too big.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So there are are my approaches:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Using MCP4725 I2C DAC for Compass, but what we do with GPS?&lt;/li&gt;&#xA;&lt;li&gt;Using and intermediate Arduino UNO Chip?&#xA;On that chip I could use Software serial but how to transfer data to MASTER using only digital and analogic pins? Maybe using 10 pins to implement a parallel transfer?&lt;/li&gt;&#xA;&lt;li&gt;Perhaps there is possible to convert Compass and GPS data to analogic then transfer to MASTER?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Anyway, what possibilities would I have to play around?&lt;/p&gt;&#xA;" OwnerUserId="4682" LastActivityDate="2016-11-09T18:22:22.143" Title="[Arduino UNO]Receive Serial Data from multiple sources" Tags="|arduino-uno|serial|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28256" PostTypeId="2" ParentId="28255" CreationDate="2016-08-11T11:13:19.020" Score="0" Body="&lt;p&gt;I think softserials are working based pinchange interrupt. This wont make you any significant delay i hop.Or you should go gps or wifi modules with SPI or IIC interface.&lt;/p&gt;&#xA;" OwnerUserId="25643" LastActivityDate="2016-08-11T11:13:19.020" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28257" PostTypeId="2" ParentId="28244" CreationDate="2016-08-11T11:29:24.497" Score="4" Body="&lt;p&gt;The simplest way would be to have &lt;strong&gt;two&lt;/strong&gt; sketches. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;One that will store all the strings into EEPROM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After that you can upload the second actual sketch that uses the values stored in EEPROM. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You only need to upload the first sketch if any of the strings change.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a way to upload a hex directly to the EEPROM using avrdude, but you'd have to use the commandline, and also have some way of generating this hex file containing all these strings.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-11T11:29:24.497" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28258" PostTypeId="1" CreationDate="2016-08-11T11:29:37.057" Score="0" ViewCount="147" Body="&lt;p&gt;I want to do WiFi GeoChaching box. I'll use cheap ESP01, but problem is it will work in forest 24/7 in cycle of 1 min of work 5 in deep sleep and waiting for those who will find that.&#xA;How I can get power?&lt;/p&gt;&#xA;" OwnerUserId="4734" LastEditorUserId="10394" LastEditDate="2016-08-11T12:25:21.183" LastActivityDate="2017-03-09T17:45:01.717" Title="Power ESP01 in forest" Tags="|power|wifi|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28259" PostTypeId="2" ParentId="28258" CreationDate="2016-08-11T12:36:19.697" Score="1" Body="&lt;p&gt;I think that in this case you will need multiple solutions for generating the power.  &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You need to know how much power you need.  This depends on you solution, I can't help there.&lt;/li&gt;&#xA;&lt;li&gt;You need a backup battery, ideally one that doesn't mind constant trickle charge and deep discharge.  Sealed lead acid are probably the best.  &lt;/li&gt;&#xA;&lt;li&gt;Your battery must have enough power over a long enough time.&lt;/li&gt;&#xA;&lt;li&gt;You need a power generator, wind, solar, water, chemical. And they should all have a common interface so you GeoCache is modular, so the GeoCaches can be plugged into any of the power sources, maybe even more than one source.  &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The problem with the power source is it is going to be a visual clue to where the cache is, probably also an audio clue.&#xA;The battery, if SLA, is going to be a great big lump that could be dangerous if damaged.&#xA;The caches are not going to be cheap, just because of the power source and battery, so I hope you have deep pockets.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than looking for a ESP01+BT4 module look for any microprocessor with BT built in, it maybe a better way to go.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-11T12:36:19.697" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28260" PostTypeId="2" ParentId="28255" CreationDate="2016-08-11T15:38:08.220" Score="1" Body="&lt;p&gt;&lt;a href=&quot;https://arduino.stackexchange.com/questions/26240/which-pins-of-an-arduino-uno-can-be-used-as-tx-and-rx-pins-for-connecting-to-gsm/26277#26277&quot;&gt;This answer&lt;/a&gt; summarizes the possibilities:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) &lt;code&gt;HardwareSerial&lt;/code&gt; is always best.  You are using that for WiFi.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) &lt;a href=&quot;https://github.com/PaulStoffregen/AltSoftSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;AltSoftSerial&lt;/code&gt;&lt;/a&gt; is the best software serial library, but it requires pins 8 &amp;amp; 9.  Very efficient and non-blocking!  Strongly recommended for the GPS connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) &lt;a href=&quot;https://github.com/SlashDevin/NeoSWSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;NeoSWSerial&lt;/code&gt;&lt;/a&gt; is next best, but it supports only 9600, 19200 and 38400.  It is non-blocking on receive, so it could be used for the GPS connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) &lt;code&gt;SoftwareSerial&lt;/code&gt; is the worst.  :P  Not suitable for the GPS connection, as you have discovered.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll also mention my GPS library, &lt;a href=&quot;https://github.com/SlashDevin/NeoGPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;NeoGPS&lt;/a&gt;.  It is smaller and faster than other libraries, and there are examples that show how to make it run &lt;em&gt;during&lt;/em&gt; the RX character interrupt, saving even more time.  It can also be configured for just the messages and fields that you actually use, saving RAM, program space and execution time.&lt;/p&gt;&#xA;" OwnerUserId="14737" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-08-11T15:38:08.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28261" PostTypeId="2" ParentId="28244" CreationDate="2016-08-11T17:49:11.563" Score="2" Body="&lt;p&gt;You don't need two sketches:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/eeprom.h&amp;gt;&#xA;&#xA;char e2str[] EEMEM = &quot;Hello, world!\n&quot;;&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    uint8_t *ptr = reinterpret_cast&amp;lt;uint8_t *&amp;gt;(e2str);&#xA;    while (true)&#xA;    {&#xA;        char c = eeprom_read_byte(ptr++);&#xA;        if (c == '\0') break;&#xA;        Serial.write(c);&#xA;    }&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Compile (Sketch&gt;Verify/Compile) the source above and you should find file named &lt;code&gt;&amp;lt;sketch-name&amp;gt;.ino.eep&lt;/code&gt; in project's build directory.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Arduino Nano, you can just run &lt;code&gt;avrdude&lt;/code&gt; with &lt;code&gt;-U eeprom:w:&amp;lt;path-to-eep-file&amp;gt;:i&lt;/code&gt; option before Sketch&gt;Upload.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For Arduino Uno, however, you must first program it's EEPROM using programmer, since Optiboot doesn't support writing to EEPROM. &lt;s&gt;Or you can burn it with Arduino Nano bootloader once (Tools&gt;Board&gt;Arduino Nano, Tools&gt;Processor&gt;ATmega328, Tools&gt;Burn Bootloader) and then use the procedure for Arduino Nano.&lt;/s&gt; (Arduino Uno and Nano bootloaders use different baud rates).&lt;/p&gt;&#xA;" OwnerUserId="13725" LastEditorUserId="13725" LastEditDate="2016-08-12T02:11:42.377" LastActivityDate="2016-08-12T02:11:42.377" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28263" PostTypeId="1" AcceptedAnswerId="28264" CreationDate="2016-08-11T23:57:03.563" Score="0" ViewCount="1007" Body="&lt;p&gt;I've been asked to do a small project using an Ada BlueFruit board. It has a &lt;a href=&quot;http://www.atmel.com/devices/ATMEGA32U4.aspx&quot; rel=&quot;nofollow&quot;&gt;ATMega32U4&lt;/a&gt;. The 32U4 &lt;a href=&quot;http://www.atmel.com/Images/doc7618.pdf&quot; rel=&quot;nofollow&quot;&gt;comes from the factory with a bootloader pre-installed&lt;/a&gt;. I've never used an Arduino before, but I have used AVR a bit in the past. Is the Arduino bootloader actually the one that came pre flashed from the factory? Does it even matter if it's the same bootloader as far as Flip is concerned?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I use the Flip batchisp utility to load my application code? We don't have a programmer handy and I don't want to muck up the bootloader on the board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's my understanding that the Arduino IDE tool chain does a bit of preprocessing &quot;behind your back&quot;. I'd much rather continue writing straight AVR code in Atmel Studio. Is there anything I need to take into account when writing my application code? For example, do I need to do anything when compiling my app code, or when uploading it, to ensure it doesn't try to write to the memory addresses in the bootloader's range?&lt;/p&gt;&#xA;" OwnerUserId="25690" LastEditorUserId="25690" LastEditDate="2016-08-12T00:43:56.323" LastActivityDate="2016-08-12T11:17:02.537" Title="Is the Arduino bootloader really the Atmel bootloader? Can I use Flip to upload?" Tags="|programming|avr|adafruit|" AnswerCount="3" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28264" PostTypeId="2" ParentId="28263" CreationDate="2016-08-12T00:22:52.993" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is the Arduino bootloader actually the one that came pre flashed from the factory?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You would have to ask Adafruit that.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It's my understanding that the Arduino IDE tool chain does a bit of preprocessing &quot;behind your back&quot;. Is there anything I need to take into account when writing my application code?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The things you are talking about is generation of function prototypes, that sort of thing. It's nothing you really need to worry about.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;For example, do I need to do anything when compiling my app code, or when uploading it, to ensure it doesn't try to write to the memory addresses in the bootloader's range?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, it would be crazy for the IDE to overwrite the bootloader. Then you wouldn't be able to use it again. In fact, to change the bootloader needs special hardware. You need to connect a programmer to the ICSP pins.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;I just want to know if I need to do anything special during linking to ensure there's no memory address conflicts&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I doubt you need to worry about that, as long as you ensure that whatever tool you are using knows to allow room for the bootloader.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;and if I can use the Flip tool to upload&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I don't see why not. Or you could use the dfu-programmer as I describe in my post &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11635&amp;amp;reply=2#reply2&quot; rel=&quot;nofollow&quot;&gt;How to flash the USB chip on the Arduino Uno&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-12T00:42:28.307" LastActivityDate="2016-08-12T00:42:28.307" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28266" PostTypeId="2" ParentId="25097" CreationDate="2016-08-12T05:51:38.333" Score="2" Body="&lt;p&gt;There is another technique that you can use, instead of hanging around waiting for more characters from the ESP8266. Your code starts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;    String response = &quot;&quot;;&#xA;    while (esp8266.available())     {&#xA;        char c = esp8266.read();&#xA;        response += c;&#xA;    } // while&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has the effect of creating a new &lt;code&gt;String&lt;/code&gt; every time &lt;code&gt;loop()&lt;/code&gt; is entered, and you accumulate the data from the ESP8266 in that - but it's lost if you leave &lt;code&gt;loop()&lt;/code&gt;. So it may be better to do it differently:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const char EOL = '\n'; // End of line&#xA;String response = &quot;&quot;; // Create String once, outside loop()&#xA;&#xA;void loop() {&#xA;    char c = '\0'; // Initialise to NUL&#xA;    while (esp8266.available() &amp;amp;&amp;amp; c!=EOL) { // Wait for End of Line&#xA;        c = esp8266.read();&#xA;        response += c;&#xA;    } // while&#xA;    if (c==EOL) {&#xA;        Serial.print(&quot;Response: &quot;); // Don't use '+' if you can help it!!!&#xA;        Serial.println(response);&#xA;        // Do other processing&#xA;        response = &quot;&quot;; // Clear response for next string&#xA;    } // if&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This has three effects:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;It keeps an incomplete &lt;code&gt;response&lt;/code&gt; between calls to &lt;code&gt;loop()&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It only processes &lt;code&gt;response&lt;/code&gt; once the end-of-line is read.&lt;/li&gt;&#xA;&lt;li&gt;It keeps &lt;code&gt;loop()&lt;/code&gt; running nicely (important on other Arduino), rather than hanging around&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-08-12T05:51:38.333" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28268" PostTypeId="1" AcceptedAnswerId="28393" CreationDate="2016-08-12T06:39:55.123" Score="1" ViewCount="2507" Body="&lt;p&gt;I am working to read two quadrature encoders using a single Arduino DUE, as part of my summer vacations project. According to the following link&#xA;&lt;a href=&quot;http://atmel.force.com/support/servlet/fileField?id=0BEG0000000HRvP&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://atmel.force.com/support/servlet/fileField?id=0BEG0000000HRvP&lt;/a&gt;, the SAM3X8E has 2 quadrature decoders in it. Now I am not being able to understand how can I initialize this second quadrature decoder. According to &lt;strong&gt;Quadrature Decoder QDEC for SAM3/4 Devices_ApplicationNote_AT11483&lt;/strong&gt;  &lt;em&gt;Pg16&lt;/em&gt; we have to first configure the IOPINS for QDEC1. I have to do that same task in Arduino IDE instead of Atmel Studio.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the code that I have found and works well to read encoder using QDEC0. However, I now need to read the encoder using the second quadrature decoder, whose input pins are TIOA6 , TIOB6 which correspond to Pin 5 and 4 of Arduino DUE. After reading the Atmel SAM3X datasheet, I think I should change &quot;TC0&quot; with &quot;TC2&quot; to make the second decoder work. However, this doesn't work. I think it does not work because channel 2 is busy in time base calculations.&#xA;In Application Note &lt;em&gt;5.52&lt;/em&gt; &lt;strong&gt;QDEC Speed Measurement Mode&lt;/strong&gt; point 2 says to Initialize TC0, TC1, TC2. If I wanted to used other encoder which timer instance will be used.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA;** Quadrature Encoder on Arduino Due in &quot;Speed Mode&quot;&#xA;** Will not work on other Arduino types because of a specific hardware requirement.&#xA;**&#xA;** @bungle99 / 2014-02-28&#xA;**&#xA;** Many thanks to @Designservicecorp (notably post #32 and post #42) that gave me the base to work from.&#xA;**&#xA;** Uses *hardware* to do the heavy lifting of interpreting the Encoder output, which gives it significant&#xA;** advantage over other Arduino's for this use case. Eg many people have reported their Unos maxing out&#xA;** or skipping counts when interpretting high RPMs, whereas people using the Due in hardware mode have &#xA;** reported better success with high RPMs.&#xA;**&#xA;** This particular example puts the hardware into &quot;Speed&quot; mode, whereas other examples in this thread use &#xA;** &quot;Position&quot; mode (see posts 32, 42). The one example in the thread that attempts Speed calcs uses Position &#xA;** Mode and uses an interrupt on the Z Index axis to manually apply a time period (needed to caculate speed) &#xA;** on each rotation.&#xA;**&#xA;** This code below has been used in tests (using Lego NXT and a gear train for driving / comparison) to &#xA;** ~3,500 RPM with a 1,024 PPR Encoder (4 x 1,024 Edges). The Arduino didn't seem to struggle and the &#xA;** numbers (eg RPM) matched fairly closely with the Lego (eg as a sanity check, the calcs in the code look&#xA;** correct).&#xA;**&#xA;** I bought one of these encoders, which seems ok;&#xA;**&#xA;**   * http://proto-pic.co.uk/rotary-encoder-1024-p-r-quadrature/&#xA;**&#xA;** Great service from proto-pic. The encoder specs are officially&#xA;**&#xA;**   * http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Robotics/E6B2Encoders.pdf&#xA;**&#xA;** But look an awful lot like this one too (which is easier to read)&#xA;**&#xA;**   * http://www.ia.omron.com/product/item/e6b27032r/index.html&#xA;**&#xA;** Note that this Encoder is rated at 5V min. I've successully powered it off the 5V Arduino pin header, &#xA;** and it doesn't work off the 3.3V one. At 5V, the outputs need to be run through some resistors to bring&#xA;** them into tolerance of the Arduino inputs.&#xA;**&#xA;** The inputs are 2 and 13 (and optionally A6 for the index).&#xA;**&#xA;** The test hardware (some Lego NXT servos and gear train) was unable to turn any faster (more gears &#xA;** stalled the servos) - eg the Arduino Due was not the limiting factor. At this speed, the Due Hardware &#xA;** is dealing with approx 238,000 edges per second.&#xA;**&#xA;** This example offloads the speed calculation onto the hardware, meaning no interrupt is required. &#xA;** In addition, the index is not required either, so it allows speeds to be seen even for rotations that &#xA;** don't pass the index marker (for example, slow rotations needing a speed before a complete rotation). &#xA;** That said, index is available if you want it and the docs suggest you can still use it (and others) as &#xA;** interrupt if you wish. &#xA;**&#xA;** NB There appears to be a myriad of features on the Chip that have not been touched. Eg you can still add&#xA;** interrupts to this code to do other things; eg passing the Z index, direction changes. There are also &#xA;** filters available if your encoder suffers from noise (eg vibrations). All this is available to play with&#xA;** another day :)&#xA;**&#xA;** Code appears to work, but no guarantees. Understand it. Test it. Feedback to the group. YMMV. Don't blame &#xA;** me if it doesn't work or expolodes!&#xA;*/&#xA;&#xA;const int ENCODER_EDGES_PER_ROTATION = 3200;  // this depends on your encoder&#xA;const int ENCODER_SAMPLES_PER_SECOND = 10;        // this will need to be tuned depending on your use case...&#xA;const int LOOP_DELAY_MS = 1 * 1000;               // ... as will this (see comments in main code)&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(115200);  &#xA;  delay(10);&#xA;&#xA;&#xA;  // Setup Quadrature Encoder&#xA;  // http://www.atmel.com/Images/doc11057.pdf&#xA;  // Section 37 p869 &#xA;  // Section 37.6.14 p885&#xA;  // Section 37.6.14.2 p890 Position and Rotation Measurement&#xA;  // Section 37.6.14.5 p891 Speed Measurement (what this is about)&#xA;&#xA;  REG_PMC_PCER0 = PMC_PCER0_PID27&#xA;                | PMC_PCER0_PID28&#xA;                | PMC_PCER0_PID29;&#xA;&#xA;  // Setup a channel in waveform mode (eg an input into the encoder to trigger the time based sampling)&#xA;  // Note some of the choices here impact calculations below and if you change them, you need to change&#xA;  // the next section to suit.&#xA;  // Section 37.7.11 p906 (also refer to Section 37.6.14.5 p891 for detail of what to set)&#xA;  REG_TC0_CMR2 = TC_CMR_TCCLKS_TIMER_CLOCK4 &#xA;               | TC_CMR_WAVE&#xA;               | TC_CMR_ACPC_TOGGLE &#xA;               | TC_CMR_WAVSEL_UP_RC;&#xA;&#xA;  // Now define the sample period, using the clock chosen above as the basis&#xA;  // Note that REG_TC0_CMR2 above is using CLOCK4; this is an 128 divisor. You need to change the&#xA;  // divisor below if you change the clock above. You could change the input clock and the RC mode to &#xA;  // suit your app (eg how many pulses are you  expecting - depends on encoder type &#xA;  // and slowest/normal/fastest rotation speed and what you want to do with the result).&#xA;  // Section 37.6.14.5 p891 notes you need to set this up, otherwise 0 comes out all the time :-)&#xA;  REG_TC0_RC2 = F_CPU / 128 / ENCODER_SAMPLES_PER_SECOND;&#xA;&#xA;  // Setup a channel in capture mode&#xA;  // Section 37.7.10 p904 (also refer to Section 37.6.14.5 p891 for detail of what to set)&#xA;  REG_TC0_CMR0 = TC_CMR_ABETRG&#xA;               | TC_CMR_LDRA_EDGE&#xA;               | TC_CMR_LDRB_EDGE &#xA;               | TC_CMR_ETRGEDG_EDGE &#xA;               | TC_CMR_CPCTRG;&#xA;&#xA;  // Enable features, noting Speed not Position is chosen&#xA;  // Section 37.7.2 p895 (also refer to Section 37.6.14.5 p891 for detail of what to set)&#xA;&#xA;// 37.7.2 TC Block Mode Register&#xA;  REG_TC0_BMR = TC_BMR_QDEN&#xA;              | TC_BMR_SPEEDEN&#xA;              | TC_BMR_EDGPHA; //Pg 896&#xA;&#xA;/*EDGPHA: EDGe on PHA count mode&#xA;0: edges are detected on both PHA and PHB.&#xA;1: edges are detected on PHA only.*/&#xA;&#xA;&#xA;  // Set everything going&#xA;  REG_TC0_CCR0 = TC_CCR_CLKEN | TC_CCR_SWTRG;  &#xA;  REG_TC0_CCR1 = TC_CCR_CLKEN | TC_CCR_SWTRG;  &#xA;  REG_TC0_CCR2 = TC_CCR_CLKEN | TC_CCR_SWTRG;  &#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  int iIndexCount = REG_TC0_CV1;  // Don't need this, but manual notes its available  &#xA;  int iSpeedPPP = REG_TC0_RA0;    // This is what we're really after (speed in Pulses Per sample Period)&#xA;&#xA;  // which we can convert to rps or rpm easily&#xA;  double dSpeedRPS = ((iSpeedPPP / (ENCODER_EDGES_PER_ROTATION * 1.0)) * ENCODER_SAMPLES_PER_SECOND);&#xA;  double dSpeedRPM =  dSpeedRPS * 60;&#xA;&#xA;  Serial.print(&quot;Speed ppp: &quot;);&#xA;  Serial.print(iSpeedPPP);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(&quot;Speed rps: &quot;);&#xA;  Serial.print(dSpeedRPS);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(&quot;Speed rpm: &quot;);&#xA;  Serial.print(dSpeedRPM);&#xA;  Serial.print(&quot;, &quot;);&#xA;  Serial.print(&quot;Indexes: &quot;);&#xA;  Serial.print(iIndexCount);&#xA;  Serial.print(&quot;. &quot;);&#xA;  Serial.println();&#xA;&#xA;  // Slow down the main loop noting the Encoder can update independently in the background (we're&#xA;  // effectively polling it to find out the latest and greatest info on each loop around).&#xA;  delay(LOOP_DELAY_MS);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Additionally I wanted to ask what is the difference between REG_TC0_CMR2 REG_TC0_CMR0 and REG_TC0_CMR1 ? Two of them are used in the above code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Motor with Encoder I am using is:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/pBsCJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pBsCJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25632" LastActivityDate="2020-06-01T06:02:35.353" Title="How to configure 2nd Quadrature Decoder IO pins in Arduino IDE" Tags="|arduino-ide|arduino-due|atmel-studio|rotary-encoder|assembly|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28269" PostTypeId="1" AcceptedAnswerId="28279" CreationDate="2016-08-12T06:50:51.337" Score="1" ViewCount="4233" Body="&lt;p&gt;I am trying to port a simple project I have working in an Arduino UNO to a NodeMCU but I am stuck as I am using the analog gpio to receive the input from some buttons, I am always getting always low values (between 0 and 5) while in the working arduino sketch I get values from 0 to 1023.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried deactivating the wifi while trying to retrieve the values, but I got no luck trying that, as I have read that sometimes the NodeMCU A0 gpio malfunctions when the wifi is not sleeping.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am setting up the gpio in the setup method like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup(void){&#xA;    pinMode(sensorPin, INPUT_PULLUP);  &#xA;    ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And my sensorPin variable is declared in the beginning of the sketch&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int sensorPin = A0; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas why when I read the value in the NodeMCU I don't get the same behaviour as in an Arduino board?&lt;/p&gt;&#xA;" OwnerUserId="25614" LastActivityDate="2016-08-12T14:01:35.853" Title="NodeMCU : Input pullup in A0" Tags="|arduino-uno|esp8266|nodemcu|" AnswerCount="1" CommentCount="8" ClosedDate="2016-08-17T09:19:53.337" ContentLicense="CC BY-SA 3.0" />
  <row Id="28271" PostTypeId="1" AcceptedAnswerId="28272" CreationDate="2016-08-12T07:19:03.463" Score="0" ViewCount="4301" Body="&lt;p&gt;I have following code (and it works great!) for SHT75 Sensirion sensor. &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Example code for SHT1x or SHT7x sensors demonstrating blocking calls&#xA; * for temperature and humidity measurement in the setup routine and&#xA; * non-blocking calls in the main loop.  The pin 13 LED is flashed as a&#xA; * background task while temperature and humidity measurements are made.&#xA; * In addition, the sensor may be placed in low resolution mode by&#xA; * uncommenting the status register write call in setup().&#xA; */&#xA;&#xA;#include &amp;lt;Sensirion.h&amp;gt;&#xA;&#xA;const uint8_t dataPin =  2;            // SHT serial data&#xA;const uint8_t sclkPin =  3;            // SHT serial clock&#xA;const uint8_t ledPin  = 13;            // Arduino built-in LED&#xA;const uint32_t TRHSTEP   = 3000UL;     // Sensor query period&#xA;const uint32_t BLINKSTEP =  250UL;     // LED blink period&#xA;&#xA;Sensirion sht = Sensirion(dataPin, sclkPin);&#xA;&#xA;uint16_t rawData;&#xA;float temperature;&#xA;float humidity;&#xA;float dewpoint;&#xA;&#xA;byte shtState = 0;&#xA;byte ledState = 0;&#xA;&#xA;unsigned long curMillis;               // Time interval tracking&#xA;unsigned long trhMillis = 0;&#xA;unsigned long blinkMillis = 0;&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  pinMode(ledPin, OUTPUT);&#xA;  delay(15);                           // Wait at least 11 ms before first cmd&#xA;//  sht.writeSR(LOW_RES);                // Set sensor to low resolution&#xA;  sht.measTemp(&amp;amp;rawData);              // Maps to: sht.meas(TEMP, &amp;amp;rawData, BLOCK)&#xA;  temperature = sht.calcTemp(rawData);&#xA;  sht.measHumi(&amp;amp;rawData);              // Maps to: sht.meas(HUMI, &amp;amp;rawData, BLOCK)&#xA;  humidity = sht.calcHumi(rawData, temperature);&#xA;  dewpoint = sht.calcDewpoint(humidity, temperature);&#xA;  logData();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  curMillis = millis();&#xA;&#xA;  if (curMillis - blinkMillis &amp;gt;= BLINKSTEP) {    // Time to toggle the LED state?&#xA;    ledState ^= 1;&#xA;    digitalWrite(ledPin, ledState);&#xA;    blinkMillis = curMillis;&#xA;  }&#xA;&#xA;  switch (shtState) {&#xA;  case 0:&#xA;    if (curMillis - trhMillis &amp;gt;= TRHSTEP) {      // Start new temp/humi measurement?&#xA;      sht.meas(TEMP, &amp;amp;rawData, NONBLOCK);&#xA;      shtState++;&#xA;      trhMillis = curMillis;&#xA;    }&#xA;    break;&#xA;  case 1:&#xA;    if (sht.measRdy()) {                         // Process temperature measurement?&#xA;      temperature = sht.calcTemp(rawData);&#xA;      sht.meas(HUMI, &amp;amp;rawData, NONBLOCK);&#xA;      shtState++;&#xA;    }&#xA;    break;&#xA;  case 2:&#xA;    if (sht.measRdy()) {                         // Process humidity measurement?&#xA;      humidity = sht.calcHumi(rawData, temperature);&#xA;      dewpoint = sht.calcDewpoint(humidity, temperature);&#xA;      shtState = 0;&#xA;      logData();&#xA;    }&#xA;    break;&#xA;  default:&#xA;    Serial.println(&quot;How did I get here?&quot;);&#xA;    break;&#xA;  }&#xA;}&#xA;&#xA;void logData() {&#xA;  Serial.print(&quot;Temperature = &quot;);   Serial.print(temperature);&#xA;  Serial.print(&quot; C, Humidity = &quot;);  Serial.print(humidity);&#xA;  Serial.print(&quot; %, Dewpoint = &quot;);  Serial.print(dewpoint);&#xA;  Serial.println(&quot; C&quot;);&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How can I extend it for &lt;strong&gt;&lt;em&gt;two&lt;/em&gt;&lt;/strong&gt; sensors (by using of another pins, of course)?&lt;/p&gt;&#xA;" OwnerUserId="13392" LastEditorUserId="37523" LastEditDate="2019-09-12T14:40:38.437" LastActivityDate="2019-09-12T14:40:38.437" Title="Sensirion library for SHT7x humidity sensor" Tags="|temperature-sensor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 4.0" />
  <row Id="28272" PostTypeId="2" ParentId="28271" CreationDate="2016-08-12T09:23:11.390" Score="1" Body="&lt;p&gt;You simply create a second instance of the object with different pins and store the result in a different set of variables. Any extra logic of when to do what is purely down to you.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-12T09:23:11.390" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28273" PostTypeId="2" ParentId="28263" CreationDate="2016-08-12T09:31:47.730" Score="2" Body="&lt;p&gt;Arduino uses a different (second) bootloader, next to the DFU one that build into the 32u4.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-12T09:31:47.730" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28274" PostTypeId="2" ParentId="4214" CreationDate="2016-08-12T10:26:04.663" Score="4" Body="&lt;p&gt;If you're into standards, then you may take a look at ASN.1 / BER TLV encoding. ASN.1 is a language used to describe data structures, made specifically for communication. BER is a TLV method of encoding the data structured using ASN.1. Problem is that ASN.1 encoding may be tricky at best. Creating a full fledged ASN.1 compiler is a project in itself (and a particularly tricky one at that, think &lt;em&gt;months&lt;/em&gt;).&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;It's probably better to keep just the TLV structure. TLV basically consists of three elements: a tag, a length and a value field. The tag defines the type of the data (text string, octet string, integer etc.) and the length the length &lt;em&gt;of the value&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In BER the T also denotes if the value is a set of TLV structures itself (a constructed node) or directly a value (a primitive node). That way you can create a tree in binary, much like XML (but without the XML overhead).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TT LL VV&#xA;02 01 FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is an integer (tag &lt;code&gt;02&lt;/code&gt;) with a length of the value of 1 (length &lt;code&gt;01&lt;/code&gt;) and value -1 (value &lt;code&gt;FF&lt;/code&gt;). In ASN.1 / BER the integers are sign big endian numbers, but you can of course use your own format.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TT LL (TT LL VV, TT LL VV VV)&#xA;30 07  02 01 FF  02 02 00 FF&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;is a sequence (a list) with length 7 containing &lt;em&gt;two&lt;/em&gt; integers, one with value -1 and one with value 255. The two integer encodings together make up the value of the sequence.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can simply toss this into an online decoder too, aint that nice?&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You can also use indefinite length in BER which will allow you to stream data. In that case you do need to parse your tree correctly though. I'd consider it an advanced topic, you need to know about breadth first and depth first parsing, for one.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Using a TLV scheme basically allows you to think of any kind of data structure and encode it. ASN.1 goes a lot further than that, giving you unique identifiers (OID's), choices (a lot like C-unions), includes of other ASN.1 structures etc. etc. but that may be overkill for your project. Probably the best well known ASN.1-defined structures today are the certificates used by your browser.&lt;/p&gt;&#xA;" OwnerUserId="25701" LastActivityDate="2016-08-12T10:26:04.663" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28275" PostTypeId="2" ParentId="28263" CreationDate="2016-08-12T11:17:02.537" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'd much rather continue writing straight AVR code in Atmel Studio.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE allows you be lazy about #includes and forward references to functions, but it won't get in your way if you choose to write correct code. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I write standard C/C++ and switch back and forth between Eclipse (no over-helpful pre-processing) and the Arduino IDE. The Arduino IDE knows better; it just CYA (covers your assumptions :) in case you don't.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-12T11:17:02.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28276" PostTypeId="2" ParentId="28119" CreationDate="2016-08-12T11:59:24.243" Score="0" Body="&lt;p&gt;I am now having Screen output to log.txt, and the following applescript works just great!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;set trigger to 1&lt;/p&gt;&#xA;&#xA;&lt;p&gt;set stopString to &quot;&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;repeat until (stopString = &quot;stop&quot;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;set testTxt to paragraphs of (read POSIX file &quot;/Users/fed/log.txt&quot;)&#xA;set countTxt to (count of testTxt) - 1&#xA;set lastLine to item countTxt of testTxt&lt;br&gt;&#xA;if lastLine contains &quot;Start MP3&quot; and trigger is 1 then&#xA;    tell application &quot;Spotify&quot; to playpause&#xA;    set trigger to 0&#xA;end if&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if lastLine does not contain &quot;Start MP3&quot; then&#xA;    set trigger to 1&#xA;end if&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if lastLine contains &quot;Stop Loop&quot; then&#xA;    set stopString to &quot;stop&quot;&#xA;end if&#xA;end repeat&lt;/p&gt;&#xA;" OwnerUserId="25562" LastActivityDate="2016-08-12T11:59:24.243" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28278" PostTypeId="2" ParentId="4214" CreationDate="2016-08-12T13:26:00.740" Score="0" Body="&lt;p&gt;If not, you've got the basics covered. Your commands can be created and read by both humans and machines which is a big plus. You might add a checksum to detect a mal-formed command or one damaged in transit, especially if your channel includes long cable or a radio link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need industrial strength (your device mustn't cause or allow someone to get hurt or die; you need high data rates, fault recovery, missing packet detection etc.) then look to some of the standard protocols and design practices.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-12T13:26:00.740" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28279" PostTypeId="2" ParentId="28269" CreationDate="2016-08-12T14:01:35.853" Score="3" Body="&lt;p&gt;As stated by Majenko in the comments, I thought that all MCUs analog gpios had a pullup resistor built in, so I have been able to solve the problem using an external pullup, in this case connecting a 10K resistor like in the diagram: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/djw9d.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/djw9d.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; . &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Special thanks to Majenko for his time and patience. Cheers! &lt;/p&gt;&#xA;" OwnerUserId="25614" LastActivityDate="2016-08-12T14:01:35.853" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28280" PostTypeId="2" ParentId="24143" CreationDate="2016-08-12T15:26:40.407" Score="0" Body="&lt;p&gt;Tim's solution is also applicable to Version 1.6.9 of the SAM tools. I just installed it in my Arduino IDE V1.6.8 and had the same parameter problem as originally reported. Following Tim's solution fixed the problem right away. As this is clearly a configuration issue on the Arduino IDE side, it should happen on any supported Windows platform, mine was Windows 7. &#xA;The only difference I encountered was the path to the SAM tools directory. On my Enterprise version of Win7, the path was not in &lt;code&gt;AppData\Roaming&lt;/code&gt; but in &lt;code&gt;AppData\Local&lt;/code&gt; , so &#xA;&lt;code&gt;%USER_PROFILE%\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.9\&lt;/code&gt; for the full pathname.&lt;/p&gt;&#xA;" OwnerUserId="25705" LastEditorUserId="25705" LastEditDate="2016-08-12T15:35:06.690" LastActivityDate="2016-08-12T15:35:06.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28281" PostTypeId="1" AcceptedAnswerId="28295" CreationDate="2016-08-12T17:08:30.383" Score="0" ViewCount="54" Body="&lt;p&gt;I have a MQ135 gas sensor from keyestudio, and a light sensor from a chinese manufacturer. They are both on their own PCB with resistors, small eeprom and a variable pot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Turning the variable pot fine tune the calibration of the sensor, but is there anyone who could explain me exactly what is it doing? Does it have an effect on signal amplification? or only adding more or less resistance to the signal output by the light sensor in order to fine tune the reading ?&lt;/p&gt;&#xA;" OwnerUserId="24376" LastActivityDate="2016-08-12T22:00:17.833" Title="What is the variable pot exactly for in arduino sensors boards?" Tags="|sensors|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28282" PostTypeId="1" AcceptedAnswerId="28283" CreationDate="2016-08-12T17:17:22.437" Score="0" ViewCount="941" Body="&lt;p&gt;I have a project where I'm looking to power 120 RGB LEDs in a strip (WS2812B).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously an Arduino Micro cannot supply this amount of current so I'm looking to use an external 5V/4A switching power supply (wall-wart) to power the LED's as well as the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is, can I just split the power from the wall-wart providing 5v_reg directly to the 5V pin on the Arduino Micro and 5v_reg to the LEDs Vss?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It it necessary to use extra bypass capacitors in this case?&lt;/p&gt;&#xA;" OwnerUserId="505" LastActivityDate="2016-08-12T17:41:44.097" Title="External power supply?" Tags="|power|arduino-micro|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28283" PostTypeId="2" ParentId="28282" CreationDate="2016-08-12T17:41:44.097" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;My question is, can I just split the power from the wall-wart providing 5v_reg directly to the 5V pin on the Arduino Micro and 5v_reg to the LEDs Vss?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes. As long as it is a clean regulated 5V supply.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;It it necessary to use extra bypass capacitors in this case?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-12T17:41:44.097" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28284" PostTypeId="2" ParentId="28281" CreationDate="2016-08-12T17:47:05.467" Score="0" Body="&lt;p&gt;It's for sensitivity adjustment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/GyWuh.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/GyWuh.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-12T17:47:05.467" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28285" PostTypeId="2" ParentId="26428" CreationDate="2016-08-12T18:36:29.383" Score="1" Body="&lt;p&gt;First you need t make it burn for 24hrs mini (48 advised). Just plug it and wait. Then for calibration you need a reference atmosphere free of NOx, CL2 and O3. In this reference atmosphere you should get an output value of 0.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't know this model you bought exactly, but most of these gas sensors mounted on a PCB have a mini eeprom so the output is the actual PPM concentration. Note that these sensors are not able to tell you how much of which gas is detected, but only a ppm concentration (you then have to guess which one is in the air). If you have several of these gas in the air, you will not be able to tell their concentration with such a sensor.&lt;/p&gt;&#xA;" OwnerUserId="24376" LastActivityDate="2016-08-12T18:36:29.383" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28287" PostTypeId="1" AcceptedAnswerId="28291" CreationDate="2016-08-12T18:42:21.420" Score="0" ViewCount="642" Body="&lt;p&gt;Can I power my Arduino using a 5V/2A adapter by connecting it through the USB port?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;More precisely, I have to run a module requiring 200mA but the aim is to make the laptop independent.&lt;/p&gt;&#xA;" OwnerUserId="25709" LastEditorUserId="19515" LastEditDate="2016-08-13T14:08:42.703" LastActivityDate="2016-08-13T14:08:42.703" Title="Supplying power to arduino by 5V and 2A adapter" Tags="|arduino-uno|power|electronics|" AnswerCount="2" CommentCount="0" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28288" PostTypeId="2" ParentId="4165" CreationDate="2016-08-12T18:43:05.743" Score="1" Body="&lt;p&gt;For humidity and temperature you can plug the DHT11 or DHT22 to your arduino. DHT11 is cheaper but you'll get a more precise value with DHT22.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For noise you have ready made PCB like these : &lt;a href=&quot;http://www.ebay.com/sch/items/?_nkw=arduino%20sound%20sensor&amp;amp;_sacat=&amp;amp;_ex_kw=&amp;amp;_mPrRngCbx=1&amp;amp;_udlo=&amp;amp;_udhi=&amp;amp;_sop=12&amp;amp;_fpos=&amp;amp;_fspt=1&amp;amp;_sadis=&amp;amp;LH_CAds=&amp;amp;rmvSB=true&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&#xA;You'll only have to plug it to GND, 5V and analog input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For CO2 this is more complicate. There is a cheap but very unprecise option, using a MQ135 sensor, here is a tutorial: &lt;a href=&quot;https://hackaday.io/project/3475-sniffing-trinket/log/12363-mq135-arduino-library&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;&#xA;Otherwise there are better sensors like the &lt;a href=&quot;http://www.co2meter.com/products/k-30-co2-sensor-module&quot; rel=&quot;nofollow&quot;&gt;K30&lt;/a&gt; but they are much more expensive.&lt;/p&gt;&#xA;" OwnerUserId="24376" LastActivityDate="2016-08-12T18:43:05.743" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28289" PostTypeId="2" ParentId="28287" CreationDate="2016-08-12T18:46:39.693" Score="0" Body="&lt;p&gt;I'm not quite sure what the second half of your question is saying, but:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;can i power my Arduino by 5 volt 2 amp adapter by connecting it through the usb port&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, you can.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-12T18:46:39.693" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28291" PostTypeId="2" ParentId="28287" CreationDate="2016-08-12T19:36:16.570" Score="1" Body="&lt;p&gt;Amps are not &quot;forced&quot; through a circuit like volts are. A closed circuit draws as much power (in amps) as it needs, so the only problem you could ever have is having too &lt;em&gt;little&lt;/em&gt; current and not too much. Seeing as your module draws 200ma 2 amps to power it is plenty.&lt;/p&gt;&#xA;" OwnerUserId="13942" LastActivityDate="2016-08-12T19:36:16.570" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28295" PostTypeId="2" ParentId="28281" CreationDate="2016-08-12T22:00:17.833" Score="1" Body="&lt;p&gt;If the resistance is higher, your LDR (light sensor) will respond in smaller increments or decrements to the same light changes. Analog inputs have 10 bit (0-1023) resolution, which is fine, but LDRs can be tricky (their sensitivity varies), so a pot is useful for prototyping the resistance you need to wire it up with in your project. &lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-12T22:00:17.833" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28297" PostTypeId="1" AcceptedAnswerId="28303" CreationDate="2016-08-13T02:23:38.737" Score="0" ViewCount="1202" Body="&lt;p&gt;I am having a very weird and frustrating issue with this ESP01. I am creating a shield on protoboard, and everything checks out as far as I can tell. I am using a 3.3v voltage divider (1k and 2.2k) from arduino TX to ESP RX.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I connect the ESP straight to the arduino Mega 2560, it works fine. When I connect the ESP to my protoboard, the blue led stays lit. Now here's he weird part. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I broke out the protoboard header with jumpers to the ESP, 3.3v to vcc and ch_pd, gnd to gnd in my header. Bypassing the logic voltage divider on my protoboard results in a working ESP8266.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While still powered up, I moved the Tx/Rx to the header, through the voltage divider, and it still works! But when I disconnect USB from the Arduino, then reconnect, the blue led stays lit, until I bypass the voltage divider, connect to the ESP, then connect back to the divider.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am currently testing my code with a simple serial relay sketch, ESP on Serial3.&#xA;I have nothing else connected to ESP besides vcc, ch_pd, gnd, tx and Rx.&#xA;I am connecting to the arduino and ESP on 115200 baud. The ESP replies without garbage on 115200 when connected straight to Serial3 rx/tx&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought insufficient power may have been an issue, using the mega's 3.3v for vcc, so I built a voltage regulator circuit converting a 9v battery to 3.3v (well 3.75, using an LM317T with R1=330ohm/R2=660ohm because it's what I had on hand) and there was no change in performance, besides the LEDs being slightly brighter. The ESP still functioned with RX/TX straight to the mega while connected to the 3.75v supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know pics would help a lot, and I can post some later tonight after work. My wife, sensing my frustration, told me to set everything down and go to work so I wouldn't break anything, so I am asking around for possible fixes for when I get home. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I appreciate any and all replies, and will provide any necessary clarification. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks,&#xA;Vl4d&lt;/p&gt;&#xA;" OwnerUserId="25718" LastActivityDate="2018-05-07T18:46:50.450" Title="EPS8266 ESP-01 Blue led stays lit unless 3.3v logic divider is bypassed, works when reconnected" Tags="|serial|arduino-mega|esp8266|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28299" PostTypeId="1" AcceptedAnswerId="28302" CreationDate="2016-08-13T10:13:14.867" Score="4" ViewCount="17028" Body="&lt;p&gt;I would like to connect a headphone jack to my Arduino and make it as an output. I mean I would simply send some simple beeps.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know that there is a breadboard friendly headphone jack, but I don't know how to wire it. I really don't know if I can simply connect the Arduino to the headphone jack, or I will need some resistors, etc. Will I need some voltage measurements? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, can I do this simply by connecting the parts of the jack ( right, left, GND) to the Arduino?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So could you please help me with this?&lt;/p&gt;&#xA;" OwnerUserId="23120" LastActivityDate="2020-09-03T10:58:12.540" Title="How to connect Arduino to headphone jack?" Tags="|arduino-uno|audio|sound|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28302" PostTypeId="2" ParentId="28299" CreationDate="2016-08-13T14:04:36.880" Score="4" Body="&lt;p&gt;&lt;a href=&quot;http://www.echanter.com/home/howto-build&quot; rel=&quot;nofollow noreferrer&quot;&gt;This&lt;/a&gt; project connects the headphones directly to a digital pin.  Here is the schematic:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/oWNwS.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/oWNwS.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would, however, be more cautious and add a limiting resistor.  The output of an Arduino pin should be limited to 20mA as stated &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardUno&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. So, using &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;V=I*R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;5 = 0.02 * R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = 5 / 0.02 &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = 250ohms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;So I would add a ~250ohm resistor in series with the head phone.  Especially if I were debugging my code.  That is, in case I accidentally left the output pin high for an extended period of time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The head phones should have some DC resistance.  If the sound is not loud enough you might measure that DC resistance of the head phones and subtract it from the 250 ohm resistance calculated above and use a limiting resistor of that value instead.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-08-13T14:04:36.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28303" PostTypeId="2" ParentId="28297" CreationDate="2016-08-13T14:36:37.367" Score="1" Body="&lt;p&gt;A wiring diagram would help. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, measure the 3.3v regulator's output, especially under load; 9v batteries are best in low-drain long-life applications like smoke detectors. Another supply, perhaps Arduino's 5v supply, might be a better source for the 3.3v regulator.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-13T14:36:37.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28305" PostTypeId="1" CreationDate="2016-08-13T14:46:56.103" Score="1" ViewCount="130" Body="&lt;p&gt;I need to connect a lot (~100) of modules with a computer (Raspberry pi). The modules are based on Arduino micro and are very simple. They will be spread around, but for the two adjacent the distance would not be larger than 2 meters.&#xA;From time to time they receive information from the computer and also can send some data back. So bandwidth requirement is small.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My first idea was connecting them in one i2c network. It would be fine, except I have figured out that i2c is not good for a distances. Signal degrades and communication is unreliable if works in the first place.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Second idea is the nrf24 network (mash). But I am not sure how reliable communication is with them? Wired seams more reliable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would you recommend? It needs to be as cheap as possible, because of number of modules. Reliability of communication is important. The bandwidth requirement is very small (1Kbps is enough). Also modules are not battery powered so no need to be low power option.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What is the best way of doing this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Network topology (it can be changed):&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/gY4Uu.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fgY4Uu.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;" OwnerUserId="18600" LastEditorUserId="18600" LastEditDate="2016-08-13T16:19:35.063" LastActivityDate="2016-08-13T16:19:35.063" Title="Inexpensive way of connecting a lot of modules on a distance" Tags="|i2c|nrf24l01+|wireless|wires|" AnswerCount="0" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28308" PostTypeId="1" CreationDate="2016-08-13T17:59:38.160" Score="0" ViewCount="2164" Body="&lt;p&gt;I've seen a few different User-Agents used in demo sketches and am curious as to what the various User-Agent options are and how to determine which one to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example...&lt;br&gt;&#xA;    &lt;code&gt;User-Agent: Mozilla/4.0&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;User-Agent: Arduino/1.0&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;User-Agent: ESP8266&lt;/code&gt;&lt;br&gt;&#xA;    &lt;code&gt;User-Agent: ArduinoWiFi/1.1&lt;/code&gt;&lt;br&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've used Arduino/1.0 successfully with an Uno/WiFi101 but want to use an ESP8266 now.  Do I continue using Arduino/1.0 or switch to ESP8266 (Arduino IDE 1.6.5)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When would someone use Mozilla?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any guidance is appreciated.&lt;/p&gt;&#xA;" OwnerUserId="13355" LastActivityDate="2016-11-11T22:18:19.133" Title="User-Agent question" Tags="|arduino-uno|c++|esp8266|networking|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28310" PostTypeId="2" ParentId="28308" CreationDate="2016-08-13T18:29:32.077" Score="3" Body="&lt;p&gt;You can use anything you like. It's used by the remote server to (try and) determine what browser you're using in order to give you the best visual experience. On an Arduino you really don't care about the visual experience. You don't even &lt;em&gt;need&lt;/em&gt; to provide a &lt;code&gt;User-Agent&lt;/code&gt; field, but it is courteous to do so.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-13T18:29:32.077" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28311" PostTypeId="2" ParentId="25240" CreationDate="2016-08-13T18:59:11.327" Score="1" Body="&lt;p&gt;You can simply chop it up in place without requiring more than a few extra bytes of RAM using &lt;code&gt;strtok()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char storebuffer[] = &quot;ssid=abcdef&amp;amp;pswd=ghijk&quot;;&#xA;&#xA;// Slice it into two parts around the &amp;amp;:&#xA;char *lefthalf = strtok(storebuffer, &quot;&amp;amp;&quot;);&#xA;if (lefthalf != NULL) { // We found a &amp;amp; and split the string OK&#xA;    char *righthalf = strtok(NULL, &quot;&amp;amp;&quot;);&#xA;&#xA;    // Now you can slice each half around the =&#xA;    char *ssidtag = strtok(lefthalf, &quot;=&quot;);&#xA;    char *ssid = strtok(NULL, &quot;=&quot;);&#xA;    char *pswdtag = strtok(righthalf, &quot;=&quot;);&#xA;    char *pswdtag = strtok(NULL, &quot;=&quot;);&#xA;&#xA;    Serial.print(&quot;SSID: &quot;);&#xA;    Serial.println(ssid);&#xA;    Serial.print(&quot;Password: &quot;);&#xA;    Serial.println(pswd);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The existing string gets chopped up and the pointers point to different places:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ssid\0abcdef\0pswd\0ghijk&#xA;^     ^       ^     ^&#xA;1     2       3     4&#xA;&#xA;1: ssidtag&#xA;2: ssid&#xA;3: pswdtag&#xA;4: pswd&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-13T18:59:11.327" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28315" PostTypeId="1" CreationDate="2016-08-13T18:10:04.737" Score="0" ViewCount="198" Body="&lt;p&gt;I have an arduino where I looking for an input event then do something. Unfortunately this input event can occur like 200 times and I only care about the first notification. Since I have a DS1302 timer handy in the circuit already for other purposes I was thinking using the minutes reading out of this to squelch this event.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the code I come up with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(sensor_event)==HIGH)&#xA;  {&#xA;&#xA;      if (RTC.read(tm)) {&#xA;&#xA;              if(time_set)&#xA;                {&#xA;                       if (tm.Minute &amp;gt; time_pushed+5)&#xA;                           time_set=0; // Unlock&#xA;                 }&#xA;               else&#xA;                 {&#xA;                        if (tm.Minute &amp;gt;= 55)&#xA;                          time_pushed=0;&#xA;                        else&#xA;                          time_pushed=tm.Minute; // Set global volatile min value&#xA;&#xA;                        print(&quot;Sensor event&quot;);  &#xA;                        time_set=1;&#xA;                 }  &#xA;      }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;About the seconds and hours I don't care all I need is if this event is detected then go ahead with a function and put it on a 5 minutes hold before checking it again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The small issue here is the minute overflow. For example if the minute is just at 56 when this happens the time_pushed would be set to 56 then the time_pushed+5 would give 61 (which of course is never reached).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a better way to code this? What is the name of this time issue I having to ignore an event until x minutes? What I found for this was mostly debounce but I'm sure this has to be handled by others sometimes too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;" OwnerDisplayName="catkillr" LastActivityDate="2016-12-19T07:09:41.853" Title="Ignore event until x minutes" Tags="|time|" AnswerCount="5" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28316" PostTypeId="2" ParentId="28315" CreationDate="2016-08-13T18:46:43.100" Score="1" Body="&lt;p&gt;Use the &lt;code&gt;millis()&lt;/code&gt; function instead if you can accomodate a rollover after 50 days.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Take a reading of millis() at the start time.&lt;/li&gt;&#xA;&lt;li&gt;time_pushed = millis() + 5 * 60 * 1000;   // 5 minutes into future.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The rest of your code shouldn't require too much editing.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="Transistor" LastActivityDate="2016-08-13T19:01:05.063" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28317" PostTypeId="2" ParentId="28315" CreationDate="2016-08-13T19:02:54.107" Score="-1" Body="&lt;p&gt;Don't bother with the RTC, just use millis().  Or just convert the time in hours/minutes/seconds to a single number in seconds (i.e. UNIX timestamp) and use that.  Then use these time comparison macros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define time_after(unknown, known) ((long)(known) - (long)(unknown) &amp;lt; 0) &#xA;#define time_before(unknown, known) ((long)(unknown) - (long)(known) &amp;lt; 0)&#xA;#define time_after_eq(unknown, known) ((long)(unknown) - (long)(known) &amp;gt;= 0) &#xA;#define time_before_eq(unknown, known) ((long)(known) - (long)(unknown) &amp;gt;= 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then do something like this in your main loop, with a variable unsigned long sample_timer that's initialized to 0 at the start of your program:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (time_after_eq(millis(), sample_timer))&#xA;{&#xA;    if (event)&#xA;    {&#xA;        sample_timer = millis() + 5*60*1000;&#xA;        // handle event...&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;These time comparison macros will properly handle overflow if you use unsigned long for your timestamps.  &lt;/p&gt;&#xA;" OwnerUserId="3832" OwnerDisplayName="alex.forencich" LastActivityDate="2016-08-13T19:02:54.107" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28318" PostTypeId="1" CreationDate="2016-08-13T16:10:21.877" Score="1" ViewCount="323" Body="&lt;p&gt;I am trying to create my own home automation using Arduino. I am using shift register for reading input(via push buttons) and writing output to led's. I am using SPI interface to communicate with shift registers. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Apart from SPI Arduino also deals with I2C devices. When push button is clicked Arduino ISR is invoked via pin 2, which then checks exact button that was pushed and takes action accordingly. The functionality currently works well with one small problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sometimes when push button is clicked Arduino ignores the button press. After debugging for some time I observed that it happens when Arduino is busy with I2C communication with other devices.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to know if it is possible to temporarily delay the push button input while Arduino busy with I2C communication? or is it possible to prioratize interrupt handling over I2C communication?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is the simplified code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;byte Input=1;&#xA;volatile byte Check=1;&#xA;volatile byte Output=1;&#xA;&#xA;int j;&#xA;//Pin connected to ST_CP of 74HC595&#xA;int latchPin = 8;&#xA;//Pin connected to SH_CP of 74HC595&#xA;int clockPin = 13;&#xA;////Pin connected to DS of 74HC595&#xA;int dataPin = 11;&#xA;&#xA;int interruptPin=2;&#xA;&#xA;int espPin=7;&#xA;&#xA;&#xA;char arduinoStatus[100]=&quot;\0&quot;;&#xA;&#xA;&#xA;&#xA; void pin_read(){&#xA;&#xA;    for(j=0; j&amp;lt;50; j++)&#xA;    delayMicroseconds(1000);&#xA;&#xA;    Check=1;&#xA;    for(j=0; j&amp;lt;8; j++){&#xA;      digitalWrite(latchPin, LOW);&#xA;      delayMicroseconds(500);&#xA;&#xA;     SPI.transfer(Check);&#xA;     SPI.transfer(Output);&#xA;&#xA;     digitalWrite(latchPin, HIGH);&#xA;&#xA;     delayMicroseconds(500);&#xA;    if(digitalRead(interruptPin)==HIGH){&#xA;      //Serial.println(Check);&#xA;&#xA;      if(bitRead(Output, j)==1)&#xA;      bitWrite(Output, j, 0);&#xA;      else&#xA;      bitWrite(Output, j, 1);&#xA;    }//dig check&#xA;&#xA;    Check = Check&amp;lt;&amp;lt;1;&#xA;&#xA;    }&#xA;&#xA;&#xA;    digitalWrite(latchPin, LOW);&#xA;    delayMicroseconds(500);&#xA;    SPI.transfer(255); //to push buttons&#xA;    SPI.transfer(Output); //to LEDs&#xA;&#xA;&#xA;    digitalWrite(latchPin, HIGH);&#xA;    delayMicroseconds(500);&#xA;&#xA;&#xA;}//pin_read&#xA;&#xA;void setup() {&#xA;  //set pins to output so you can control the shift register&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;  pinMode(espPin, OUTPUT);&#xA;  pinMode(interruptPin, INPUT);//Input from buttons&#xA;&#xA;  delay(1000);  &#xA;  // the LEDs don't change while you're sending in bits:&#xA;    digitalWrite(latchPin, LOW);&#xA;  SPI.setBitOrder(MSBFIRST);&#xA;  SPI.setDataMode(SPI_MODE0);&#xA;  SPI.setClockDivider(SPI_CLOCK_DIV2);&#xA;  SPI.begin();&#xA;  SPI.transfer(255);&#xA;  SPI.transfer(255);&#xA;   //take the latch pin high so the LEDs will light up:&#xA;    digitalWrite(latchPin, HIGH);&#xA;&#xA;    Serial.begin(115200);&#xA;    attachInterrupt(0, pin_read, RISING); &#xA;&#xA;    Wire.begin(8);                // join i2c bus with address #8&#xA;  Wire.onRequest(requestEvent); // register event&#xA;  Wire.onReceive(receiveEvent);&#xA;&#xA;  Serial.println(&quot;Initialized...&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Interrupting...&quot;);&#xA; digitalWrite(espPin, HIGH);&#xA;&#xA; while(digitalRead(interruptPin)==HIGH){}&#xA;  delayMicroseconds(500);&#xA; digitalWrite(espPin, LOW);&#xA; delayMicroseconds(500);&#xA; Serial.println(&quot;Done...&quot;);&#xA;Serial.print(&quot;Output:&quot;);&#xA;Serial.println(Output);&#xA;delay(3000);&#xA;}&#xA;&#xA;// function that executes whenever data is received from master&#xA;// this function is registered as an event, see setup()&#xA;void receiveEvent(int howMany) {&#xA;  int i=0;&#xA;  Serial.println(&quot;received::&quot;);&#xA;  while (Wire.available()) { // loop through all&#xA;    char c = Wire.read(); // receive byte as a character&#xA;    arduinoStatus[i++]=c;&#xA;&#xA;    Serial.print(c);         // print the character&#xA;&#xA;  }&#xA;  arduinoStatus[i]='\0';&#xA;  Serial.println(&quot;###&quot;);&#xA;}&#xA;&#xA;&#xA;// function that executes whenever data is requested by master&#xA;// this function is registered as an event, see setup()&#xA;void requestEvent() {&#xA;  Serial.println(&quot;Sending...&quot;);&#xA;  Wire.write(&quot;hello&quot;); // respond with message of 6 bytes&#xA;  Wire.write(Output);&#xA;  Serial.println(&quot;Sent&quot;);&#xA;  // as expected by master&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10768" OwnerDisplayName="Xinus" LastActivityDate="2016-08-13T19:35:18.693" Title="Delaying pushbutton input to microcontroller while it's busy processing I/O" Tags="|i2c|spi|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28319" PostTypeId="2" ParentId="28318" CreationDate="2016-08-13T18:00:38.037" Score="1" Body="&lt;p&gt;Without looking any further than the first &lt;code&gt;delaymicroseconds()&lt;/code&gt; command I would say that that's where the trouble lies. The &lt;code&gt;delay()&lt;/code&gt; functions are very handy for getting the beginner's first LED to blink and are a big problem after that. The problem is that the CPU is completely tied up during the delay and can't do anything else other than interrupts and you only have a limited supply of those. Your button press is missed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to develop your own timers in the code and keep the main loop running constantly checking on each pass to see if the delay is complete.&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="Transistor" LastActivityDate="2016-08-13T18:00:38.037" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28320" PostTypeId="2" ParentId="28318" CreationDate="2016-08-13T19:19:09.140" Score="0" Body="&lt;p&gt;What about polling the buttons periodically instead of using an interrupt?  If you check them every 10 ms or so, you should still be able to detect a button press reliably.  Connecting buttons to interrupt inputs is not necessarily the best idea due to contact bounce - this can cause a number of back-to-back interrupts.  My guess is that interrupts are being disabled during some part of your code and when the interrupt pin level changes during that period, it gets ignored.  &lt;/p&gt;&#xA;" OwnerUserId="3832" OwnerDisplayName="alex.forencich" LastActivityDate="2016-08-13T19:19:09.140" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28323" PostTypeId="2" ParentId="28315" CreationDate="2016-08-13T22:30:35.483" Score="0" Body="&lt;p&gt;Calculate target time, rollover if necessary and check if time is already passed that point. As long as you are checking the time multiple times per minute you shouldn't run into any issues.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(sensor_event)==HIGH)&#xA;{&#xA;&#xA;  if (RTC.read(tm)) {&#xA;&#xA;          if(time_set)&#xA;            {&#xA;                   if (tm.Minute &amp;gt;= targettime)&#xA;                       time_set=0; // Unlock&#xA;             }&#xA;           else&#xA;             {&#xA;                    targettime=tm.Minute+5; // Set global volatile min value&#xA;                    targettime=targettime % 60;&#xA;&#xA;                    print(&quot;Sensor event&quot;);  &#xA;                    time_set=1;&#xA;             }  &#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25559" LastActivityDate="2016-08-13T22:30:35.483" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28324" PostTypeId="1" CreationDate="2016-08-14T01:02:03.490" Score="-1" ViewCount="1697" Body="&lt;p&gt;Can I connect a Bluetooth module to usual digital pins, other than D0/D1 (RX/TX) pins as the shield is already using the D0 and D1 pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My Bluetooth module is an HC-05 MODULE.&lt;/p&gt;&#xA;" OwnerUserId="25738" LastEditorUserId="84" LastEditDate="2016-08-14T12:16:27.377" LastActivityDate="2019-11-22T05:54:10.800" Title="Connecting Bluetooth module to Arduino Uno without RX/TX pins" Tags="|bluetooth|pins|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28326" PostTypeId="1" CreationDate="2016-08-14T04:26:41.123" Score="-2" ViewCount="367" Body="&lt;p&gt;can i unplug my Arduino project when i'm done installing the libraries and it still work the way it did when it is plugged in &lt;/p&gt;&#xA;" OwnerUserId="25740" LastActivityDate="2016-08-14T04:58:06.180" Title="can i unplug my Arduino project when i'm done installing the libraries and it still work the way it did when it is plugged in" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="3" ClosedDate="2016-10-06T08:08:49.333" ContentLicense="CC BY-SA 3.0" />
  <row Id="28327" PostTypeId="2" ParentId="28326" CreationDate="2016-08-14T04:58:06.180" Score="2" Body="&lt;p&gt;Once you compile and upload your arduino sketch and any libraries it uses, your code is stored in nonvolatile memory inside the processor. You can unplug your arduino and power it up later and it will run your code again with out any help from your computer.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-08-14T04:58:06.180" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28328" PostTypeId="1" AcceptedAnswerId="28330" CreationDate="2016-08-14T08:58:28.333" Score="2" ViewCount="186" Body="&lt;p&gt;I'm working on an Arduino robot and I ran into a problem when reorganizing my code. I have an Adafruit Motor Shield v2.3 connected to an Arduino Uno. My robot can be controlled using a bluetooth connection (BlueSMIRF module) or it can be told to avoid obstacles using an ultra sonic range finder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything worked fine and the robot moved nicely until I decided I wanted to organize the code better, so that my code for moving the robot would be in a separate class, my code for servo movement also in a class as well as my code for the logic for movement (received bluetooth command - do this, or avoid obstacles like so, etc.). Suddenly, none of the motors respond or just one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if I have a problem with my C++ and passing pointers to my functions or what is going on...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is my main .ino file, its relevant parts, I left out stuff that concerns the bluetooth connection etc. And yes, I know the hardcoded include paths look ugly, I'll figure out what to do with includes at some point... :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// bluetoothRobot.ino&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;SonarSRF08.h&amp;gt;&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;  &#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;#include &quot;utility/Adafruit_PWMServoDriver.h&quot;&#xA;&#xA;#include &quot;\Users\Jarno\Arduino\bluetoothOhjausBot\MotorController.h&quot;&#xA;#include &quot;\Users\Jarno\Arduino\bluetoothOhjausBot\AvoidObstacleController.h&quot;&#xA;#include &quot;\Users\Jarno\Arduino\bluetoothOhjausBot\MemoryFree-master\MemoryFree.h&quot;&#xA;&#xA;MotorController* motorController;&#xA;&#xA;Adafruit_MotorShield AFMS = Adafruit_MotorShield();&#xA;&#xA;Adafruit_DCMotor *rightRearMotor = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *leftRearMotor = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *rightFrontMotor = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *leftFrontMotor = AFMS.getMotor(4);&#xA;&#xA;void setup() &#xA;{ &#xA;    motorController-&amp;gt;start(&amp;amp;AFMS, leftRearMotor, leftFrontMotor, rightFrontMotor, rightRearMotor); &#xA;    AFMS.begin();     &#xA;}  &#xA;&#xA;void loop() &#xA;{ &#xA;    if(bluetooth.available())  {&#xA;        char command = (char) bluetooth.read();&#xA;&#xA;        if (controlMode == 2) {&#xA;            motorController-&amp;gt;executeBluetoothCommand(command);&#xA;        }&#xA;    } &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Here is my MotorController.h:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MotorController.h&#xA;&#xA;#ifndef MotorController_h&#xA;#define MotorController_h&#xA;&#xA;#include &quot;Arduino.h&quot;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_MotorShield.h&amp;gt;&#xA;&#xA;class MotorController {&#xA;    public:&#xA;      int executeBluetoothCommand(char command);&#xA;      void start(Adafruit_MotorShield *AFMS, Adafruit_DCMotor *rightRearMotor, Adafruit_DCMotor *leftRearMotor, Adafruit_DCMotor *rightFrontMotor, Adafruit_DCMotor *leftFrontMotor);&#xA;      void turnRight();&#xA;      void turnLeft();&#xA;      void moveForward();&#xA;      void moveBackward();&#xA;      void stopRobot();&#xA;      void setRobotSpeed(int leftWheelsSpeed, int rightWheelsSpeed);   &#xA;    private:&#xA;      Adafruit_MotorShield* AFMS;&#xA;      Adafruit_DCMotor* leftRearMotor;&#xA;      Adafruit_DCMotor* rightRearMotor;&#xA;      Adafruit_DCMotor* rightFrontMotor;&#xA;      Adafruit_DCMotor* leftFrontMotor;&#xA;  };&#xA;&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And here is MotorController.cpp:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// MotorController.cpp&#xA;&#xA;#include &quot;\Users\Jarno\Arduino\bluetoothOhjausBot\MotorController.h&quot;&#xA;&#xA;void MotorController::start(Adafruit_MotorShield *shield, Adafruit_DCMotor *rrm, Adafruit_DCMotor *lrm, Adafruit_DCMotor *rfm, Adafruit_DCMotor *lfm) {&#xA;      AFMS = shield;&#xA;      rightRearMotor = rrm;&#xA;      leftRearMotor = lrm;&#xA;      rightFrontMotor = rfm;&#xA;      leftFrontMotor = lfm;&#xA;      setRobotSpeed(80,80);&#xA;  }&#xA;int MotorController::executeBluetoothCommand(char command) {&#xA;        switch(command) {&#xA;            case 'F':&#xA;              moveForward(); &#xA;              break;    &#xA;&#xA;            case 'B':&#xA;              moveBackward();&#xA;              break;       &#xA;&#xA;            case 'L':&#xA;              turnLeft();&#xA;              break;       &#xA;&#xA;            case 'R':&#xA;              turnRight();&#xA;              break;     &#xA;&#xA;            case 'S':&#xA;              stopRobot();&#xA;              break;  &#xA;&#xA;            /*case 'W':&#xA;              stopRobot();&#xA;              controlMode = 1;&#xA;              tiltServoAngle = 120;&#xA;              panServoAngle = 90;&#xA;              motorController.setPanAndTilt(panServoAngle, tiltServoAngle);&#xA;            */&#xA;            default:&#xA;              return -1;&#xA;              }&#xA;    return 0;              &#xA;&#xA;}&#xA;void MotorController::setRobotSpeed(int leftWheelsSpeed, int rightWheelsSpeed) {&#xA;        leftFrontMotor-&amp;gt;setSpeed(leftWheelsSpeed);       &#xA;        leftRearMotor-&amp;gt;setSpeed(leftWheelsSpeed);&#xA;        rightRearMotor-&amp;gt;setSpeed(rightWheelsSpeed);&#xA;        rightFrontMotor-&amp;gt;setSpeed(rightWheelsSpeed);&#xA;  }&#xA;void MotorController::moveForward() {&#xA;&#xA;        setRobotSpeed(80,80);&#xA;        leftRearMotor-&amp;gt;run(FORWARD);&#xA;        rightRearMotor-&amp;gt;run(FORWARD);&#xA;        leftFrontMotor-&amp;gt;run(FORWARD);&#xA;        rightFrontMotor-&amp;gt;run(FORWARD);&#xA;&#xA;&#xA;  }&#xA;&#xA;void MotorController::moveBackward() {&#xA;        leftRearMotor-&amp;gt;run(BACKWARD);&#xA;        rightRearMotor-&amp;gt;run(BACKWARD);&#xA;        rightFrontMotor-&amp;gt;run(BACKWARD);&#xA;        leftFrontMotor-&amp;gt;run(BACKWARD);&#xA;        setRobotSpeed(80,80);&#xA;  }&#xA;&#xA;void MotorController::turnLeft() {&#xA;        leftRearMotor-&amp;gt;run(BACKWARD);&#xA;        rightRearMotor-&amp;gt;run(FORWARD);&#xA;        rightFrontMotor-&amp;gt;run(FORWARD);&#xA;        leftFrontMotor-&amp;gt;run(BACKWARD);&#xA;        setRobotSpeed(80, 80);&#xA;  }&#xA;&#xA;void MotorController::turnRight() {&#xA;        leftRearMotor-&amp;gt;run(FORWARD);&#xA;        rightRearMotor-&amp;gt;run(BACKWARD);&#xA;        rightFrontMotor-&amp;gt;run(BACKWARD);&#xA;        leftFrontMotor-&amp;gt;run(FORWARD);&#xA;        setRobotSpeed(80, 80);&#xA;&#xA;  }&#xA;&#xA;void MotorController::stopRobot() {&#xA;        leftRearMotor-&amp;gt;run(RELEASE);&#xA;        rightRearMotor-&amp;gt;run(RELEASE);&#xA;        rightFrontMotor-&amp;gt;run(RELEASE);&#xA;        leftFrontMotor-&amp;gt;run(RELEASE);&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I used to have a constructor for MotorController with the Motor Shield library &lt;code&gt;AFMS.begin()&lt;/code&gt; call in it and all. But this caused the Arduino to constantly reset for some reason. I coudn't understand why but I moved the motor configurations and call to &lt;code&gt;begin()&lt;/code&gt; to my .ino file where the problem doesn't occur. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; What happens with the code as it is, is which ever pointer to motor is passed last seems to work and that particular motor turns but the others won't. If I comment out the call to &lt;code&gt;setRobotSpeed&lt;/code&gt; in &lt;code&gt;MotorController::start&lt;/code&gt;, nothing happens with any motor even though speed is also set in the relevant functions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As said, the robot worked fine when the code was in my .ino file. Although, for some reason I had to call the Motor Shield library's &lt;code&gt;begin()&lt;/code&gt; function always before any other commands to motors. So it was called every time the user told the robot to move forward, move backward etc. Otherwise nothing happened with the motors. Now, if I add a call &lt;code&gt;AFMS-&amp;gt;run()&lt;/code&gt; to my MotorController.cpp, the Arduino starts to constantly reset...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, none of the other stuff (blueSMIRF, the range finder code etc.) should interfere since they were also there when it worked and I even commented out that stuff.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm baffled. Maybe its some silly mistake with my C++? Or is there really something weird going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help would be much appreciated, I've spent hours trying to figure this thing out! Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="25742" LastEditorUserId="84" LastEditDate="2016-08-14T09:25:51.147" LastActivityDate="2016-08-14T09:36:07.663" Title="Problem with wrapping Adafruit Motor Controller function calls in a class" Tags="|motor|adafruit|arduino-motor-shield|pointer|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28329" PostTypeId="2" ParentId="28328" CreationDate="2016-08-14T09:23:53.977" Score="0" Body="&lt;p&gt;One thing about instantiating classes before &lt;code&gt;setup()&lt;/code&gt; is called is that &lt;code&gt;init()&lt;/code&gt; (which you don't see) may undo all of your careful setup.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Your code starts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Adafruit_DCMotor *rightRearMotor = AFMS.getMotor(1);&#xA;Adafruit_DCMotor *leftRearMotor = AFMS.getMotor(2);&#xA;Adafruit_DCMotor *rightFrontMotor = AFMS.getMotor(3);&#xA;Adafruit_DCMotor *leftFrontMotor = AFMS.getMotor(4);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;but these are constructed before &lt;code&gt;setup()&lt;/code&gt;. And then you call &lt;code&gt;MotorController::start()&lt;/code&gt; with those values. You haven't provided the code for &lt;code&gt;AFMS::getMotor()&lt;/code&gt; - so it may be doing things internally that is undone by &lt;code&gt;init()&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of creating the whole pointer, why not do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const byte rightRearMotor = 1;&#xA;const byte leftRearMotor = 2;&#xA;const byte rightFrontMotor = 3;&#xA;const byte leftFrontMotor = 4;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then callig &lt;code&gt;AFMS.getMotor()&lt;/code&gt; inside &lt;code&gt;MotorController::start()&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void MotorController::start(Adafruit_MotorShield *shield,&#xA;                            byte rrm, byte lrm, byte rfm, byte lfm) {&#xA;    AFMS = shield;&#xA;    rightRearMotor = AFMS.getMotor(rrm);&#xA;    leftRearMotor = AFMS.getMotor(lrm);&#xA;    rightFrontMotor = AFMS.getMotor(rfm);&#xA;    leftFrontMotor = AFMS.getMotor(lfm);&#xA;    setRobotSpeed(80,80);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-08-14T09:23:53.977" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28330" PostTypeId="2" ParentId="28328" CreationDate="2016-08-14T09:36:07.663" Score="0" Body="&lt;p&gt;The obvious issue in your current code is that &lt;code&gt;motorController&lt;/code&gt; is a pointer to your class but I don't see any place it was instantiated properly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hence, it points &lt;strong&gt;anywhere&lt;/strong&gt; the first time you use it, which can explain resets of the MCU.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, either you keep it as a pointer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MotorController* motorController;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;And then you instantiate it in place&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MotorController* motorController = new MotorController();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Or you can also instantiate it in &lt;code&gt;setup()&lt;/code&gt; as first line (ie before it is used anywhere else)&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    motorController = new MotorController();&#xA;    ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;However&lt;/strong&gt;, for reasons discussed elsewhere on this site, I would not use dynamic allocation but &lt;strong&gt;I'd rather define &lt;code&gt;motorController&lt;/code&gt; as an instance of &lt;code&gt;MotorController&lt;/code&gt; instead of a pointer&lt;/strong&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MotorController motorController;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now everywhere you were using &lt;code&gt;motorController-&amp;gt;xxx&lt;/code&gt; you'll have to replace it it with &lt;code&gt;motorController.xxx&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That should remove the most important bug of your current code (I can-'t tell if there are other issues but this one must be fixed in priority).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-08-14T09:36:07.663" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28331" PostTypeId="1" CreationDate="2016-08-14T09:48:04.447" Score="0" ViewCount="2880" Body="&lt;p&gt;I have this SIM900 board and working just fine.&#xA;But i can't find a way to soft power on this board from arduino.&#xA;I read for JP pads. They need soldering first, but from my board this JP pads missing.&#xA;Know someone other way to soft power on this from arduino?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/OCSYG.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/OCSYG.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25743" LastEditorUserId="25743" LastEditDate="2016-08-15T16:46:43.757" LastActivityDate="2017-10-26T15:52:07.567" Title="SOLVED: Soft Power On SIM900 module - JP pads missing!" Tags="|hardware|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28332" PostTypeId="1" AcceptedAnswerId="28342" CreationDate="2016-08-14T10:40:08.787" Score="1" ViewCount="142" Body="&lt;p&gt;I'd like to receive on my arduino live coordinates of planets of solar system. Because there are already websites listing every planet coordinates, I thought it would be easier to just use a wifi module (in my case an ESP8266) and connect the arduino to one of these website.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the option of getting it from &lt;a href=&quot;http://theskylive.com/planets&quot; rel=&quot;nofollow&quot; title=&quot;Live coordinates of planets&quot;&gt;this&lt;/a&gt; website, but I have no idea how to do that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The other way of doing it may be to connect to &lt;a href=&quot;http://ssd.jpl.nasa.gov/?phys_data&quot; rel=&quot;nofollow&quot;&gt;Horizon&lt;/a&gt; via their telnet server at this adress :telnet://horizons.jpl.nasa.gov:6775&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Though I know how establish a connection with this server on my computer using Putty, I have no idea how to connect my arduino to it, execute commands, and, more importantly, get data (RA and DEC) of every solar system main objects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my first time using Arduino wifi module, so I have no experience with it, and I don't know what it is capable of.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks a lot for your attention,&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thomas&lt;/p&gt;&#xA;" OwnerUserId="25746" LastEditorUserId="25746" LastEditDate="2016-08-14T10:46:05.547" LastActivityDate="2016-08-14T15:27:37.067" Title="Receiving live astronomical coordinates on Arduino Mega using telnet and ESP8266 wifi module" Tags="|arduino-mega|wifi|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28338" PostTypeId="1" AcceptedAnswerId="28341" CreationDate="2016-08-14T14:40:04.977" Score="0" ViewCount="936" Body="&lt;p&gt;Hi SE (and Majenko in particular, if I'm lucky) -&#xA;I have a setup with an SD module (on SPI) and an Elechouse PN532 NFC reader (on I2C). I would like to use a master tag to enter MASTER MODE [sic] to add tags if they are not present in a file on my SD card, or remove tags which are present in the same file. I am currently checking tag UID against a hardcoded master UID, and it works well enough for now. What trips me up is making the tag database in the most arduino-friendly way. How would you advise me to do this in the most spartan way? And when removing existing tags from the database, how would you suggest I update it, to remove unwanted UIDs? I am using a flat text database now, but it could be a binary file - I am just puzzled by what is the best method to remove an entry(line) from a file using SD library.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-14T15:25:11.347" Title="NFC 'dynamic' UID database" Tags="|arduino-uno|sd-card|rfid|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28339" PostTypeId="2" ParentId="28324" CreationDate="2016-08-14T14:45:50.547" Score="1" Body="&lt;p&gt;Classic Arduinos use pins 0 and 1 for serial communication to the host computer, so it is problematic to connect a bluetooth module there anyway - it can be done, but basically means that programming the board and communicating with it by serial will not work (at least not reliably) until the interfering bluetooth module is removed or disabled.  For these boards you need to use a software serial instance to talk to the module, and you can put it on most any digital pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ATmega32u4 boards like the Leonardo do not have debug/programming on pins 0 and 1 but do have a hardware UART there, so those would be the best choice for a bluetooth module, but you can still use software serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino Mega has additional hardware serial pins that would be good choices, but you can use software serial.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Various ARM based boards with Arduino ports typically have additional hardware serial pins which you should use.  Software serial may or may not be an option on these (it's not that an implementation cannot exist, but that software serial is generally disadvantageous, so when a chip has more hardware UARTs that particular function may not be ported).&lt;/p&gt;&#xA;" OwnerUserId="612" LastActivityDate="2016-08-14T14:45:50.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28340" PostTypeId="2" ParentId="28315" CreationDate="2016-08-14T14:48:28.933" Score="0" Body="&lt;p&gt;The proper way to do that depends on whether the event is guaranteed to&#xA;happen at least once every 49.7&amp;nbsp;days. If this is the case then, as&#xA;Tom Carpenter suggested in a comment, you can just test for&#xA;&lt;code&gt;now - last_event &amp;gt;= hold_time&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    uint32_t now = millis();&#xA;    static uint32_t last_event = -hold_time;&#xA;&#xA;    // Detect the event if it did not happen in the last five minutes.&#xA;    if (now - last_event &amp;gt;= hold_time&#xA;            &amp;amp;&amp;amp; digitalRead(sensor_event) == HIGH) {&#xA;        Serial.println(&quot;Sensor event&quot;);&#xA;        last_event = now;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If you can have 49.7 days without a single event, then this approach&#xA;fails because &lt;code&gt;last_event&lt;/code&gt; is ambiguous. The simplest solution is&#xA;probably to implement a state machine with only two states, as the event&#xA;detection is either “on hold” or it is not:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void loop()&#xA;{&#xA;    uint32_t now = millis();&#xA;    static bool on_hold;&#xA;    static uint32_t last_event;&#xA;&#xA;    // Remove the hold after five minutes.&#xA;    if (on_hold &amp;amp;&amp;amp; now - last_event &amp;gt;= hold_time) {&#xA;        on_hold = false;&#xA;    }&#xA;&#xA;    // Detect the event.&#xA;    if (!on_hold &amp;amp;&amp;amp; digitalRead(sensor_event) == HIGH) {&#xA;        Serial.println(&quot;Sensor event&quot;);&#xA;        on_hold = true;&#xA;        last_event = now;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now I would want to insist on a specific point: in either approach&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/a/12588&quot;&gt;the millis() rollover is not an issue&lt;/a&gt;. The choice&#xA;between the first and the second approach depends solely on the maximum&#xA;time between the events, not on how long the program is meant to run.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.563" LastActivityDate="2016-08-14T14:48:28.933" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28341" PostTypeId="2" ParentId="28338" CreationDate="2016-08-14T15:11:32.793" Score="3" Body="&lt;p&gt;You got me ;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since a UID is a fixed size you don't need to think in &quot;lines&quot;, only in bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most efficient way of storing the UIDs is as pure bytes. I am not familiar with that specific card and reader combination, but I will assume as an example an 8 byte UID (though this all holds true for any other length you care to choose).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You treat your file on SD card like a kind of database with a number of records in it. Each record is the exact same size (8 bytes in this case) . To read or write a specific record you just &quot;seek&quot; to the record number multiplied by the record size - so multiples of 8 in this example.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile.seek(recordNumber * 8);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If &lt;code&gt;.seek()&lt;/code&gt; returns &lt;code&gt;false&lt;/code&gt; then you have reached the end of the file.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to find a tag you can:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile.seek(0); // Start at the beginning of the file&#xA;int recno = 0;&#xA;char foundUID[8];&#xA;bool found = false;&#xA;while (myFile.read(foundUID, 8)) {&#xA;    if (strncmp(foundUID, myUID, 8) == 0) { // 8 bytes match&#xA;        found = true;&#xA;        break;&#xA;    }&#xA;    recno++;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;At the end of that &lt;code&gt;found&lt;/code&gt; will be &lt;code&gt;true&lt;/code&gt; if there is a match, and &lt;code&gt;recno&lt;/code&gt; will be set to the record number. Now the magic begins...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it has been found and you want to delete it, think again. That's a very wasteful idea. Instead you just want to &quot;invalidate&quot; it - that is, replace the UID in the database with something the UID can never be - all 0xFF is a good choice. Simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myFile.seek(recno * 8);&#xA;for (int i = 0; i &amp;lt; 8; i++) {&#xA;    myFile.write(0xFF);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now the tag has gone from the database. You may want to add a filter at the card reading phase to stop anyone using a card that has a UID of all 0xFF, of course.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now for adding a new card...  This is where the fun starts.  You could just add 8 bytes to the end of the file, but then the file will grow and grow and grow. Instead, you can first search through the file for a tag entry that is all 0xFF and replace that data with your new UID. Just the same as when you deleted it - seek to 8x the record number and write 8 bytes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It might help to write a function to wrap the tag seeking routine so you can easily call it multiple times from multiple places. Returning the record number would be most useful - and you could return -1 if it's not found.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you really want it to be plain text you can do the exact same thing but work with the ASCII representation of the UID bytes instead of the raw values - maybe as HEX. So your 8 byte records would become 18 bytes (16 bytes for 2 ASCII characters per UID byte, plus two for the &lt;code&gt;\r\n&lt;/code&gt; line ending). Doing the conversion between bytes and text and back to bytes again though is wasteful if you don't really need it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;sub&gt;In case you're wondering why I recommended 0xFF as the deleted tag fill value and not 0x00 or anything else, it is simply because when you erase flash memory it is set to 0xFF. When you change the contents of a block on an SD card the block is read, it is modified in memory, the block is then erased (the whole lot set to 0xFF), then the modified block re-written back to the card. The act of erasing the block slightly damages it as it forces electrons through bits they don't really want to go through to make it all 0xFF. By setting your empty records to 0xFF, when it comes time to filling them again, the flash doesn't have to work as hard to erase that block since those bits are already in the erased state. Therefore the lifetime of the flash card should be extended slightly.&lt;/sub&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-14T15:25:11.347" LastActivityDate="2016-08-14T15:25:11.347" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28342" PostTypeId="2" ParentId="28332" CreationDate="2016-08-14T15:27:37.067" Score="0" Body="&lt;p&gt;That telnet interface is an interactive service. Getting an Arduino to interact with it is not an easy task - certainly not a task for a beginner with no experience of network programming.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A much easier task is to &lt;em&gt;scrape&lt;/em&gt; the website since that just returns text which you then need to search through a bit at a time looking for the information you need.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-14T15:27:37.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28344" PostTypeId="1" CreationDate="2016-08-14T15:58:26.493" Score="3" ViewCount="97" Body="&lt;p&gt;I'm trying to make the transition from coding in the Arduino language to AVR-C, but I'm having some issues with my microcontrollers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't have an ISP, so I'm using one of my Arduino UNOs with the ArduinoISP sketch. The problem is that when I try to run avrdude it gives me this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avrdude: Device signature = 0x000000&#xA;avrdude: Yikes!  Invalid device signature.&#xA;  Double check connections and try again, or use -F to override&#xA;  this check.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However, when I try to run the command with the sugested -F it uploads the code to the Arduino UNO I'm using as an ISP instead of the ATmega328p on my breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Does anyone have any idea about whats going on here, or how to fix it?&lt;/p&gt;&#xA;" OwnerUserId="25755" LastEditorUserId="26916" LastEditDate="2017-09-09T23:58:08.290" LastActivityDate="2017-12-09T06:28:03.147" Title="Issues graduating to AVR-C" Tags="|c|atmega328|avr|avrdude|arduinoisp|" AnswerCount="1" CommentCount="13" ClosedDate="2017-12-09T09:07:07.827" ContentLicense="CC BY-SA 3.0" />
  <row Id="28345" PostTypeId="1" AcceptedAnswerId="28347" CreationDate="2016-08-14T16:02:23.847" Score="1" ViewCount="137" Body="&lt;p&gt;I have an Arduino Nano and was adding up some values &lt;code&gt;2^i from 0..7&lt;/code&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);&#xA;  int i,k;&#xA;  k = 0;&#xA;  for (i=0;i&amp;lt;8;i++){&#xA;     k += pow(2, i);&#xA;     Serial.println(k);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Those numbers should sum up to &lt;code&gt;255&lt;/code&gt;, but that's the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1&#xA;3&#xA;6&#xA;13&#xA;28&#xA;59&#xA;122&#xA;249&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Is my Arduino not working or what can be the reason for this behaviour?&lt;/p&gt;&#xA;" OwnerUserId="25751" LastActivityDate="2016-08-14T22:26:21.177" Title="Strange adding behaviour" Tags="|c++|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28346" PostTypeId="1" CreationDate="2016-08-14T16:08:34.013" Score="5" ViewCount="2480" Body="&lt;p&gt;What should be expected if the code in the timer interrupt ISR does not finish before the interrupt is called again?  For example Timer0 ISR(TIMER0_COMPA_vect){} on the Uno.  This is for debugging purposes in a complex program.  Thanks.&lt;/p&gt;&#xA;" OwnerUserId="15341" LastActivityDate="2016-08-15T09:29:59.740" Title="interrupting an interrupt" Tags="|arduino-uno|interrupt|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28347" PostTypeId="2" ParentId="28345" CreationDate="2016-08-14T16:14:30.310" Score="3" Body="&lt;p&gt;No, there is nothing &quot;wrong&quot; there. In fact it's the expected results.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem here is that &lt;code&gt;pow()&lt;/code&gt; returns a float, and some numbers just can't be represented with floating point. When that floating point value is converted to an integer it truncates the decimal portion leaving you with the wrong integer value.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(115200);&#xA;&#xA;    int t = 0;&#xA;    for (int i = 0; i &amp;lt; 8; i++) {&#xA;        float f = pow(2, i);&#xA;        int d = f;&#xA;        t += f;&#xA;        Serial.print(&quot;2^&quot;);&#xA;        Serial.print(i);&#xA;        Serial.print(&quot;: float = &quot;);&#xA;        Serial.print(f, 10);&#xA;        Serial.print(&quot; int = &quot;);&#xA;        Serial.print(d);&#xA;        Serial.print(&quot; total = &quot;);&#xA;        Serial.println(t);&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;2^0: float = 1.0000000000 int = 1 total = 1&#xA;2^1: float = 2.0000000000 int = 2 total = 3&#xA;2^2: float = 3.9999995231 int = 3 total = 6&#xA;2^3: float = 7.9999980926 int = 7 total = 13&#xA;2^4: float = 15.9999961853 int = 15 total = 28&#xA;2^5: float = 31.9999885559 int = 31 total = 59&#xA;2^6: float = 63.9999771118 int = 63 total = 122&#xA;2^7: float = 127.9999542236 int = 127 total = 249&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Instead you should use bit-shifting to perform the same operation on an integer:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(115200);&#xA;&#xA;    int t = 0;&#xA;    for (int i = 0; i &amp;lt; 8; i++) {&#xA;        int d = 1 &amp;lt;&amp;lt; i;&#xA;        t += d;&#xA;        Serial.print(&quot;1&amp;lt;&amp;lt;&quot;);&#xA;        Serial.print(i);&#xA;        Serial.print(&quot;: int = &quot;);&#xA;        Serial.print(d);&#xA;        Serial.print(&quot; total = &quot;);&#xA;        Serial.println(t);&#xA;    }&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&#xA;1&amp;lt;&amp;lt;0: int = 1 total = 1&#xA;1&amp;lt;&amp;lt;1: int = 2 total = 3&#xA;1&amp;lt;&amp;lt;2: int = 4 total = 7&#xA;1&amp;lt;&amp;lt;3: int = 8 total = 15&#xA;1&amp;lt;&amp;lt;4: int = 16 total = 31&#xA;1&amp;lt;&amp;lt;5: int = 32 total = 63&#xA;1&amp;lt;&amp;lt;6: int = 64 total = 127&#xA;1&amp;lt;&amp;lt;7: int = 128 total = 255&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-14T16:14:30.310" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28348" PostTypeId="2" ParentId="28346" CreationDate="2016-08-14T16:45:10.683" Score="2" Body="&lt;p&gt;It won't be called until the current interrupt is finished. As soon as the current interrupt function returns the pending interrupt would trigger and call the ISR again.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-14T16:45:10.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28350" PostTypeId="2" ParentId="28346" CreationDate="2016-08-14T18:34:46.500" Score="7" Body="&lt;ol&gt;&#xA;&lt;li&gt;the timer will set the Timer Interrupt Flag (TIFR0 register)&lt;/li&gt;&#xA;&lt;li&gt;The ISR will be called, and the flag will be cleared&lt;/li&gt;&#xA;&lt;li&gt;you do some long calculations or something&lt;/li&gt;&#xA;&lt;li&gt;the timer will match OCR0A, and set the interrupt flag again.&lt;/li&gt;&#xA;&lt;li&gt;you calculations are done, and the ISR function will end.&lt;/li&gt;&#xA;&lt;li&gt;the uC will jump back to the main loop code, and execute &lt;strike&gt;2&lt;/strike&gt; 1 instruction&lt;strike&gt;s&lt;/strike&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The uC will see the flag, and call the ISR again. As per step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;PS please note that by default the ISR macro will turn off global interrupt (cli) at the beginning of the function, and set it back at the end. You can re-enable interrupts inside the ISR, but you have to be very careful here, as interrupts can be nested, and cause stack-overflows.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strike&gt;You can re-enable interrupts inside the ISR, but that only means other interrupt may interrupt this ISR, but never the same vector. (i.e. only one ISR per vector can run at the same time). So in your case the timer ISR can't be interrupted by the same timer interrupt.&lt;/strike&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastEditorUserId="2881" LastEditDate="2016-08-15T09:29:59.740" LastActivityDate="2016-08-15T09:29:59.740" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28351" PostTypeId="2" ParentId="28345" CreationDate="2016-08-14T18:53:36.883" Score="0" Body="&lt;p&gt;Granted that integer arithmetic is a computationally better approach to this problem; if your intent was to learn to use floating point and float to int conversions, then you need to round up the floating result before the conversion truncates it. As you saw in @Majenko's example, the floating results are close but not quite exact. In your own example, you'd change&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;k += pow(2, i);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;p = pow(2, i); k += (p &amp;lt; 0. ? -0.5 : 0.5);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to so the float would truncate to the nearest int instead to the next lower int.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-08-14T22:26:21.177" LastActivityDate="2016-08-14T22:26:21.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28353" PostTypeId="1" AcceptedAnswerId="28354" CreationDate="2016-08-14T20:04:36.117" Score="0" ViewCount="5208" Body="&lt;p&gt;Given that there is a circuit with two pins (12 and 10) from an Uno providing power to LEDs on two separate branches, why is the yellow LED dimmer than the green LED? (Please see below image.) To my understanding, the branches attach to GND in parallel, so the LEDs should be equally bright. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it helps, the two branches are programmed so one LED is off when the other is on and vice versa, with a 1s interval between changing pin state. This isn't a PWM thing as using pin 8 instead of 10 makes no difference.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/0DGJX.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/0DGJX.png&quot; alt=&quot;Arduino UNO and Breadboard setup&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25757" LastEditorUserId="25757" LastEditDate="2016-08-14T20:25:34.473" LastActivityDate="2016-08-14T20:25:34.473" Title="Why is one LED more luminous (brighter) than the other?" Tags="|arduino-uno|led|pins|pwm|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28354" PostTypeId="2" ParentId="28353" CreationDate="2016-08-14T20:19:11.653" Score="1" Body="&lt;p&gt;Just like men, all LEDs have been made different.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Practically, that means two different LEDs (one green and one yellow for instance) will have different brightnesses (more precisely, &lt;strong&gt;luminous intensities&lt;/strong&gt;) when they are traversed by the same current (&lt;strong&gt;forward current&lt;/strong&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LED luminous intensity is a function of the current that traverses it (among other factors).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want the same brightness for those 2 LEDs, then you'll have to:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Get both LEDs datasheets (should be a couple of A4 pages for each)&lt;/li&gt;&#xA;&lt;li&gt;Find the luminous intensity/forward current function curve in each&lt;/li&gt;&#xA;&lt;li&gt;Determine which brightness you want for both&lt;/li&gt;&#xA;&lt;li&gt;Deduce the current for each&lt;/li&gt;&#xA;&lt;li&gt;Calculate the resistor value to get that current for each&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Then you will have to use two different resistors values in your wiring, based on calculations of step 5.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Simpler,&lt;/strong&gt; you could just replace one of your 2 resistors with one small pot that you can use to tune brightness of the second LED until it fits brightness of the first one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Be careful with pot manipulation though,&lt;/strong&gt; as a 0 resistance would probably grill your LED (and potentially the Arduino pin it is wired to).&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-08-14T20:19:11.653" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28357" PostTypeId="1" CreationDate="2016-08-14T22:34:28.940" Score="2" ViewCount="26290" Body="&lt;p&gt;Today I tried to update the sketch on my Arduino Uno, but was unable to due to this error:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Sketch uses 1,870 bytes (5%) of program storage space. Maximum is 32,256 bytes.&#xA;Global variables use 188 bytes (9%) of dynamic memory, leaving 1,860 bytes for local variables. Maximum is 2,048 bytes.&#xA;D:\Users\User\Desktop\arduino-1.6.10\hardware\tools\avr/bin/avrdude -CD:\Users\User\Desktop\arduino-1.6.10\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:\Users\User\AppData\Local\Temp\build2f7b4a32c3810b2d8e42648954faba05.tmp/nes_controller.ino.hex:i &#xA;An error occurred while uploading the sketch&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nothing will upload to the board now. I tried uploading a simple sketch with empty setup() and loop() functions, I've tried different PCs and gotten the same error, I've swapped USB cables, I've double-checked that I'm using the right COM port, I've disconnected every wire from the Arduino pins - nothing has helped.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The old sketch is still running fine on the Uno. It was uploaded a few days ago using the exact same setup I'm trying right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino IDE doesn't even indicate any errors, everything compiles and looks good until &quot;An error occurred while uploading the sketch&quot;&lt;/p&gt;&#xA;" OwnerUserId="25764" LastActivityDate="2020-09-18T22:16:50.027" Title="Sketches won't upload to Uno" Tags="|arduino-uno|uploading|" AnswerCount="5" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28360" PostTypeId="2" ParentId="28357" CreationDate="2016-08-15T07:30:52.923" Score="-1" Body="&lt;p&gt;right click on computer, manage, device manager and disable the usb driver and enable it again.&lt;/p&gt;&#xA;" OwnerUserId="25769" LastActivityDate="2016-08-15T07:30:52.923" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28361" PostTypeId="1" CreationDate="2016-08-14T16:28:26.973" Score="4" ViewCount="719" Body="&lt;p&gt;I just bought a new stepper motor (400 steps for revolution, 0.9°/step) and I would like make a turn of 180° by 200 steps, but it doesn't work as expected.&#xA;It looks like the motor needs only 110 steps to make a turn of 180° and I don't know the cause. The driver motors is the Keyes L298. It is wired to my Arduino UNO rev3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In order to clarify, please see the image below:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/51Ocg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/51Ocg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define negativeSteps -55&#xA;#define positiveSteps 55&#xA;#define Speed 7500&#xA;&#xA;int motorPin1 = 11;&#xA;int motorPin2 = 10;&#xA;int motorPin3 = 9;&#xA;int motorPin4 = 8;         &#xA;&#xA;int steps;&#xA;unsigned int tmp2;&#xA;&#xA;byte modeR[] = {B00001001, B00001010, B00000110, B00000101};&#xA;byte modeF[] = {B00000101, B00000110, B00001010, B00001001};&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(115200); //Opens serial connection at 115200 baud.     &#xA;&#xA;  pinMode(11,OUTPUT);&#xA;  pinMode(10,OUTPUT);&#xA;  pinMode(9,OUTPUT);&#xA;  pinMode(8,OUTPUT); &#xA;&#xA;  pinMode(3,OUTPUT);    // Enable pin motorA&#xA;  pinMode(2,OUTPUT);    // Enable pin motorB&#xA;&#xA;  digitalWrite(2,HIGH);&#xA;  digitalWrite(3,HIGH); &#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    while (Serial.available())&#xA;    {&#xA;      char cmd = (char)Serial.read();&#xA;      if (cmd == 's')   while(1) Seek();&#xA;    }&#xA;}&#xA;void motorR(){&#xA;  int bitMask=B00001111; // bitmask to modify only last 4 bit&#xA;&#xA;          for (int id = 0; id &amp;lt;4; id++) {&#xA;            PORTB = (PORTB &amp;amp;~bitMask) |  modeR[id]; &#xA;            while (tmp2++&amp;lt;Speed);&#xA;            tmp2=0;&#xA;          }&#xA;}&#xA;void motorF(){&#xA;  int bitMask=B00001111; // bitmask to modify only last 4 bit&#xA;&#xA;          for (int id = 0; id &amp;lt;4; id++) {&#xA;            PORTB = (PORTB &amp;amp;~bitMask) |  modeF[id]; &#xA;            while (tmp2++&amp;lt;Speed);&#xA;            tmp2=0;&#xA;          }&#xA;}&#xA;void Seek() {&#xA;  steps = negativeSteps;      //Init Steps&#xA;  while (1)&#xA;  {&#xA;&#xA;    while (steps&amp;lt;positiveSteps) //  starts from &quot;negative&quot; steps to &quot;positive&quot; steps ( -55 to +55)&#xA;    {&#xA;       if (steps&amp;lt;0) motorF(); // if steps = 0 it will change the direction&#xA;       else motorR();&#xA;&#xA;      Serial.println(steps);&#xA;      steps++;  &#xA;   }&#xA; }  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25816" OwnerDisplayName="Victor Dika" LastEditorUserId="27346" LastEditDate="2017-11-22T22:24:30.920" LastActivityDate="2017-11-22T22:24:30.920" Title="Arduino - stepper motor wrong steps number" Tags="|motor|stepper|l298n|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28364" PostTypeId="1" CreationDate="2016-08-15T09:54:54.867" Score="3" ViewCount="227" Body="&lt;p&gt;Trying to get started with the Arduino, so I'm trying to do something kinda simple. I'm following this tutorial: &lt;a href=&quot;http://www.makeuseof.com/tag/build-your-own-dynamic-ambient-lighting-for-a-media-center/&quot; rel=&quot;nofollow&quot;&gt;Build Your Own Dynamic Ambient Lighting For A Media Center&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I'm still confused about one, most likely simple and self-explainatory, thing:&#xA;Take a look at &lt;a href=&quot;http://i.1n9i9c7om.com/r3tnBj.png&quot; rel=&quot;nofollow&quot;&gt;this image&lt;/a&gt; - is that DC connector on the bottom left the one that's one my Arduino? Do I simply have to connect the 12V wire from the RGB LED stripe to Vin?  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;After using google for a bit, I read this: &lt;code&gt;the diode and trace width are other limiting factors. The diode is rated at 1 amp and the board traces can't handle much above 2 amp.&lt;/code&gt;&lt;br&gt;&#xA;Does that mean I can only use 1A because of the diode? If so, why does it matter how much the board traces can handle?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm trying to power a 12V 2A RGB LED stripe.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd appreciate your help and I hope this is the correct subreddit to ask that. :S&lt;/p&gt;&#xA;" OwnerUserId="25772" LastActivityDate="2016-08-19T01:58:53.400" Title="Arduino Uno VIN 2A" Tags="|power|current|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28365" PostTypeId="2" ParentId="28364" CreationDate="2016-08-15T10:10:35.287" Score="2" Body="&lt;p&gt;No, that connector is a completely separate one.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect a power supply to the on-board power socket of the Arduino and take power out from the VIN pin to power other things.  However the &lt;em&gt;total current&lt;/em&gt; that is used by both the Arduino &lt;em&gt;and&lt;/em&gt; whatever you power from it &lt;em&gt;cannot&lt;/em&gt; exceed 1A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So to have more than 1A available you have to have the power connected externally to the Arduino. That doesn't mean that the Arduino can't share that power, just that the Arduino can't &lt;em&gt;provide&lt;/em&gt; that power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can connect the +12V of the LED strip to VIN on the Arduino as long as the 12V power supply is connected to the LED strip not to the Arduino - that way the power for the Arduino comes &lt;em&gt;from&lt;/em&gt; your external circuit.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-15T10:10:35.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28367" PostTypeId="2" ParentId="28357" CreationDate="2016-08-15T11:12:54.920" Score="1" Body="&lt;p&gt;assumption is windows, so with the old ide's a reboot to free up the usb ports, or sometimes simply swapping the usb port, and changing the port in the tools &gt; port menu.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;does it identify the board you are using when you choose the port? (Genuino / Arduino) &lt;/p&gt;&#xA;" OwnerUserId="25773" LastActivityDate="2016-08-15T11:12:54.920" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28368" PostTypeId="2" ParentId="26392" CreationDate="2016-08-15T11:21:29.357" Score="0" Body="&lt;p&gt;i had major issues with ws2812 and the hm-10, and i couldn't get a great solution for it, and although your setup is different, it may help…&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my solution was to stop things that were interrupting the interrupt, in this case, the leds, so to create;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void dataLow () {&#xA;  // drop the power on the data pins for the leds&#xA;  digitalWrite(DATA_PINA, LOW); &#xA;  digitalWrite(DATA_PINB, LOW);&#xA;  Serial.println(&quot;DATA_PINS - LOW&quot;);&#xA;}&#xA;&#xA;void dataHigh () {&#xA;  // turn the power back on for the leds&#xA;  digitalWrite(DATA_PINA, HIGH);&#xA;  digitalWrite(DATA_PINB, HIGH);&#xA;  Serial.println(&quot;DATA_PINS - HIGH&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and then to clean the data. i was looking for 2 numerical characters, and if i got anything else, then dump the data. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bluetooth.listen(); &#xA;while (bluetooth.available() &amp;gt; 0) {&#xA;    dataLow();&#xA;    char inChar = bluetooth.read();&#xA;      // if its a character, add it to the string&#xA;      if (isDigit(inChar)) {&#xA;        inString += (char)inChar;&#xA;      }&#xA;      // if the string is longer than 2, truncate and return nothing&#xA;      if(inString.length() &amp;gt; 2) {&#xA;        inString[2] = '\0';&#xA;      }&#xA;      // if the serial recieves bluetooth end of line /n print string data out&#xA;      if (inChar == '\n') {&#xA;        Serial.print(&quot;String: &quot;); Serial.println(inString.toInt());&#xA;        program=inString.toInt();&#xA;        inString = &quot;&quot;;&#xA;        dataHigh();&#xA;      }&#xA;      // read user input from serial monitor&#xA;      if (Serial.available()){&#xA;        delay(10); // The DELAY!&#xA;        bluetooth.write(Serial.read());&#xA;      }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;it was still twitchy, but it mostly works.&lt;/p&gt;&#xA;" OwnerUserId="25773" LastActivityDate="2016-08-15T11:21:29.357" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28369" PostTypeId="2" ParentId="10041" CreationDate="2016-08-15T12:28:52.527" Score="4" Body="&lt;p&gt;For greater precision, less code, faster execution and no need for capacitors read the PWM &quot;analog&quot; signal on the other Arduino from a &lt;strong&gt;digital input&lt;/strong&gt; pin with &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;pulseIn(pin, HIGH, timeout)&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The timeout is optional (1 second by default). As soon as the line goes high, a timer engages and automatically stops the instant the line goes low. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The primary reason to use PWM communcation (as opposed to i2c, SPI, etc.) is to broadcast to an unlimited number of devices simultaneously without the need for a clock signal or acknowledgement. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;We are currently using this method of communication for neural networks composed of separate tiny processors for each neuron substructure (one processor for each synapse and activation function).&lt;/p&gt;&#xA;" OwnerUserId="25774" LastEditorUserId="25812" LastEditDate="2016-08-17T07:04:52.800" LastActivityDate="2016-08-17T07:04:52.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28372" PostTypeId="2" ParentId="28364" CreationDate="2016-08-15T12:55:43.607" Score="0" Body="&lt;p&gt;It will be dangerous to take 12V from VIN pin. Please have a look at following picture. That is the diode you mentioned. the diode can burn out if the current get exceeded.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/3zgKh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/3zgKh.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;there are three ways to solve this.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;Use two different supplies. Use a 6V battery(or 5V USB power) to power arduino and 12v supply for LED strip. You should connect both grounds( grounds of supplies)&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;Solder a wire from bottom(from the point shown in picture) of arduino board for 12v &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;connect 12v power directly to VIN (not by using power jack)&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/YMyb9.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/YMyb9.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25643" LastEditorUserId="7297" LastEditDate="2016-08-19T01:58:53.400" LastActivityDate="2016-08-19T01:58:53.400" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28373" PostTypeId="1" CreationDate="2016-08-15T13:13:38.397" Score="1" ViewCount="213" Body="&lt;p&gt;I am pretty new to arduino.I am working on a project which requires comparison of two keypad inputs to operate a relay using arduino. I have found lot of info on connecting single keypad but none about connecting two keypad inputs.So how can i connect two keypad and a relay to arduino?Thanx in advance.&lt;/p&gt;&#xA;" OwnerUserId="24233" LastActivityDate="2016-08-15T14:46:45.103" Title="connecting two keypad with arduino" Tags="|arduino-uno|relay|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28375" PostTypeId="2" ParentId="28373" CreationDate="2016-08-15T14:46:45.103" Score="2" Body="&lt;p&gt;It should be no problems as long as you can get enough digital inputs into the Arduino.  Search for the library KeyPad, it lets you define the pins that control each row and column and so you could use 2 2*2 keypads quite easily.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think Keypad is very easy to use, but if you get stuck, just show what code you have so far and describe the problem and people will help you.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-15T14:46:45.103" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28376" PostTypeId="1" CreationDate="2016-08-15T14:57:15.317" Score="0" ViewCount="633" Body="&lt;p&gt;I am having an Arduino Uno and I want to add a LCD to it. My LCD is a C2042A with I2C shield on it. I tried the LiquidCrystal_I2C library but it doesnt work. I am not getting any errors the LCD is just not showing the text. I just used the example code 'Hello World' from the library. I only changed the adress from 0x27 to 0x63 because I found that with the I2C scanner. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So all in all the LCD is connected right. It shows I2C mode which is also fine and it is find by the I2C Scanner code. Which library do I have to use that it will work? &lt;a href=&quot;http://www.wentztech.com/filevault/Electronics/Arduino/&quot; rel=&quot;nofollow&quot;&gt;http://www.wentztech.com/filevault/Electronics/Arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25779" LastActivityDate="2016-08-15T15:55:29.807" Title="Arduino which library for led 4x20" Tags="|arduino-uno|i2c|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28377" PostTypeId="2" ParentId="28376" CreationDate="2016-08-15T15:55:29.807" Score="1" Body="&lt;p&gt;0x63 is the correct address - the module is at 0xC6 which is the 8-bit equivalent of 0x63 (0x63 shifted left once for the read/write bit to be added).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LCD03 uses its own custom I2C protocol, not compatible with the &quot;normal&quot; I2C LCD library. Instead you have to use their own special commands.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The commands are detailed here: &lt;a href=&quot;http://www.robot-electronics.co.uk/htm/Lcd03tech.htm&quot; rel=&quot;nofollow&quot;&gt;http://www.robot-electronics.co.uk/htm/Lcd03tech.htm&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There may be a library available that wraps those commands, I don't know, but you can just use the Wire library to send the commands you need to send.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-15T15:55:29.807" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28378" PostTypeId="1" AcceptedAnswerId="28383" CreationDate="2016-08-15T16:10:53.507" Score="0" ViewCount="1656" Body="&lt;p&gt;To start, I am a software guy, and I really want to ensure I not going to destroy any components. I previously looked at power through a USB power bank, but the issue with these is that they turn themselves off with low current pull.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: I have a number of Arduino shields and would like to power them with 4 rechargeable AA batteries, and therefore would like some advice on what to use without frying any electronics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The rechargeable batteries I have are &lt;a href=&quot;https://www.duracell.co.uk/en-gb/products/duracell-rechargeable/duracell-rechargeable-batteries&quot; rel=&quot;nofollow&quot;&gt;these&lt;/a&gt; 1.2V AA (NiMH). Going on their rated value they should supply 4.8V. Testing the 4 batteries in serial gives me 5.3V overall, or around 1.325V per battery at full charge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So if the batteries provide more than 5V, I cannot safely plug them into the 5V pin on the Arduino. But if the batteries could potentially provide around 4.8V to 5.5V plugging them into VIN means that the voltage regulator will take too much power, reducing the overall voltage to be too low for all of the shields (Which require 5V). What should I do in this situation?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is a list of the current equipment that will require power:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMega2560&quot; rel=&quot;nofollow&quot;&gt;Arduino Mega 2560&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow&quot;&gt;SIM900 GPRS/GSM Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/13750&quot; rel=&quot;nofollow&quot;&gt;Sparkfun GPS Logger Shield&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/13287&quot; rel=&quot;nofollow&quot;&gt;Sparkfun Wifi Shield - ESP8266&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The shields will be stacked on top of each other. &lt;/p&gt;&#xA;" OwnerUserId="12166" LastActivityDate="2016-08-15T17:09:29.133" Title="How to power Arduino and shields with 4 rechargeable AA batteries?" Tags="|power|shields|battery|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28380" PostTypeId="2" ParentId="28331" CreationDate="2016-08-15T16:42:28.813" Score="1" Body="&lt;p&gt;OK for anyone who has the same problem. I solved this by soldering a cable on the underside of the board on this pin (see image) on power button. Then I connect the cable to pin 9 on Arduino and run this on sketch:    &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  pinMode(9, OUTPUT); &#xA;  digitalWrite(9,LOW);&#xA;  delay(1000);&#xA;  digitalWrite(9,HIGH);&#xA;  delay(2000);&#xA;  pinMode(9, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I don't know how it works, but it solves my problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/KOcNr.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/KOcNr.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25743" LastEditorUserId="2944" LastEditDate="2016-11-11T08:01:48.990" LastActivityDate="2016-11-11T08:01:48.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28383" PostTypeId="2" ParentId="28378" CreationDate="2016-08-15T17:09:29.133" Score="1" Body="&lt;p&gt;Most 5V devices will function fine at up to 5.5V - however, check the datasheets for the major components and modules on the boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The main thing to watch though is that a 3.3V device, which can normally communicate fine with a 5V one, may not be able to. The problem is that the logic HIGH signal from the 3.3V device may be below the threshold for a logic HIGH on the Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;V_IH = 0.6Vcc = 0.6 x 5 = 3V&#xA;&#xA;V_IH = 0.6Vcc = 0.6 x 5.5 = 3.3V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Thus a 3.3V device would have to output at the very minimum 3.3V as a logic HIGH in order for it to register as one on the Arduino, which may be a problem...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can easily drop the battery voltage by 0.7V though by inserting a single silicon diode (such as the trusty 1N4001) in series with the batteries. That will take your voltage down from your measured 5.3V down to 4.6V which will improve matters somewhat.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, it is important to note that you have so far measured the &lt;em&gt;open circuit&lt;/em&gt; voltage of the batteries. That is, the voltage with no load on them. The voltage will most likely be lower once they are actively driving the Arduino etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Arduino itself will be fine running off 5.3V, so I suggest you power just the Arduino direct into the 5V pin from the batteries and measure the actual voltage while powering the Arduino. That will give you a more accurate voltage reading. Then, if needed, you can add the diode to drop it by 0.7V.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-15T17:09:29.133" CommentCount="17" ContentLicense="CC BY-SA 3.0" />
  <row Id="28384" PostTypeId="2" ParentId="1222" CreationDate="2016-08-15T17:39:40.367" Score="0" Body="&lt;p&gt;Since the Encoder resolution is high, the Arduino Uno misses some pulses hence you could not get the accurate reading from it. You could use the hardware quadrature decoder in Arduine Due board which can easily read the encoder values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a code which can only be executed in arduino Due to Read one quadrature encoder.&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/28268/how-to-configure-2nd-quadrature-decoder-io-pins-in-arduino-ide&quot;&gt;How to configure 2nd Quadrature Decoder IO pins in Arduino IDE&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25632" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.413" LastActivityDate="2016-08-15T17:39:40.367" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28385" PostTypeId="1" AcceptedAnswerId="28388" CreationDate="2016-08-15T18:08:54.593" Score="2" ViewCount="258" Body="&lt;p&gt;I recently started with Arduino and I have my starter kit. However, there are some strange looking components I can't recognize. Is there some way to find out the names of these components? &lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastEditorDisplayName="user24204" LastEditDate="2016-11-20T15:33:48.103" LastActivityDate="2016-11-20T15:33:48.103" Title="How do I find names of components I don't know?" Tags="|components|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28386" PostTypeId="1" AcceptedAnswerId="28389" CreationDate="2016-08-15T18:16:10.723" Score="0" ViewCount="187" Body="&lt;p&gt;I have a load sensor for measuring weights , it has for wires labelled E+,E-,S+,S-. I assume S means sensor and E means excitation and the power is sent into E+ and E-. &#xA;The output of any load sensor would be the order of typically millivolts if it takes a load (depending on the weight of the load of course) so I guess amplifying it with a darlington would make its output useful for an interface to an arduino.&#xA;What would be a generic circuit using a darlington transistor (e.g. a TIP 120) that can make the load sensor output useful for building an interface to an arduino with the minimal number of components? Ans this circuit is to be as simple as possible. &#xA;Im trying to build a circuit with the components I have which does include a tip 120 and I have a lot of other common components.&lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorUserId="25788" LastEditDate="2016-08-15T18:25:51.057" LastActivityDate="2016-08-15T19:34:32.763" Title="How to interface an arduino to load sensor with darlington transistor?" Tags="|arduino-nano|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28388" PostTypeId="2" ParentId="28385" CreationDate="2016-08-15T18:34:47.027" Score="3" Body="&lt;p&gt;The Arduino webpage has a section about their &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoStarterKit&quot; rel=&quot;nofollow&quot;&gt;Starter Kits&lt;/a&gt;, including pictures (and technical specs if you scroll down the page). Particularly, if you go to the Arduino store, there is a sub-menu for components - for example, for &lt;a href=&quot;https://store.arduino.cc/category/31&quot; rel=&quot;nofollow&quot;&gt;actuators&lt;/a&gt; (there are more categories to the left of the image).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a blog by Aaron Eiche, &lt;a href=&quot;https://aaroneiche.com/2009/07/16/arduino-starter-rundown-part-2/&quot; rel=&quot;nofollow&quot;&gt;Arduino Starter Rundown&lt;/a&gt;, that if you scroll down, there is a chart that labels the main components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There are several websites that have pages that identify components by image - an example is the uCHobby webpage &lt;a href=&quot;http://www.uchobby.com/index.php/2007/07/15/identifying-electronic-components/&quot; rel=&quot;nofollow&quot;&gt;Identifying Electronic Components&lt;/a&gt;, with pictorial menus of the main types of components.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In Google images, searching &quot;arduino starter kit components&quot; yields a considerable amount of labelled component charts.&lt;/p&gt;&#xA;" OwnerDisplayName="user24204" LastActivityDate="2016-08-15T18:34:47.027" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28389" PostTypeId="2" ParentId="28386" CreationDate="2016-08-15T19:34:32.763" Score="0" Body="&lt;p&gt;What you have there is (or sounds like) a full wheatstone bridge.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You require either a special amplifier (such as the &lt;a href=&quot;https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;HX711&lt;/a&gt;) or a highly sensitive and accurate differential ADC (such as the &lt;a href=&quot;http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf&quot; rel=&quot;nofollow&quot;&gt;MCP3428&lt;/a&gt; - (&lt;a href=&quot;http://majenko.co.uk/hpdaq.php&quot; rel=&quot;nofollow&quot;&gt;on  a shield&lt;/a&gt;)).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-15T19:34:32.763" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28390" PostTypeId="1" CreationDate="2016-08-15T20:27:30.640" Score="2" ViewCount="1864" Body="&lt;p&gt;I'm a complete newbie in anything related to electronics, software or hardware; yet with a couple of friends we're going ahead with an interesting project related to automation through wireless devices: more or less IoT but involving electric locks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The case scenario: there's a room without any power outlets. It has a regular door. &lt;strong&gt;We want to be able to open this door through the internet, with a lock that lies inside the room, on the other side of the door&lt;/strong&gt;; all this, given we:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Can't make any modifications to the door's structure.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Can't drill or make holes or whatever so as to get a power cable to&#xA;the inside of the room.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;But &lt;strong&gt;we can&lt;/strong&gt; glue certain pieces behind the door, this is, inside&#xA;the room that hasn't any power outlets.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;We've planned, so far, to use an Arduino Uno; enhance it with WiFi features (i.e. a module or shield) so as to bypass the limitation of not being able to connect an ethernet cable; and glue a solenoid or lock to the inside of the doors, so that it acts as a second lock that can only be unlocked through the internet, accessed via Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Our ideal scenario would be opening this door remotely, from our home, even if this door is a hundred blocks away. If someone wants to get in, they should ask for our permission, as we don't control the built-in handle, but we do control a latch fixed on the inside.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;All this setup should be powered with a long-lasting battery: we can't plug anything, and we can't risk getting our batteries depleted fast, because we'll never be able to open the door once again. We need these batteries to last long enough so as to be able to change them in a prudent time window; a back-up battery system should also work well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Standard solenoid locks are 12v. Arduino powers 5v devices, not 12v ones, as far as my understanding goes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We should open this door only 5 times a day. That's it; the remaining time in between, the whole device setup can well stay 'dormant', in low-energy consumption mode, only to 'wake up' when we give the order: &quot;Arduino, please tell the solenoid to open&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We haven't specified which battery we would use; ideally, the most cost-efficient option. If it lasts 3 months and costs, say, 20 dollars -- well, we would love that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done this really inaccurate, schematic drawing to illustrate our idea and research. I know there's many details missing but I wanted to prove our point:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7nTnC.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7nTnC.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(The Arduino should be positioned on the wall and not on the door! My bad.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope I'm clear enough up to now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The questions, then, are:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done some research, and I've seen that Arduino can be enhanced so that it consumes the minimum possible energy so as to remain 'aware', but not in full-power mode, which in our case would be unnecessary.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;So, can we make Arduino &lt;em&gt;super efficient&lt;/em&gt; in terms of power consumption, even if we attach WiFi functions, which, as far as I'm concerned, really takes on battery life? So that we can make Arduino run for months before replacing the battery?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino can send only 5v; but the solenoid powers on 12v; then, getting a second battery to power our solenoid sounds straightforward, except that as far as my knowledge goes, this battery should last next to nothing (maybe I'm wrong here). And we want it to last for months -- if not, our door will remain sealed forever! Can I make the solenoid dependant on the Arduino, so that it's part of the &quot;almost-no-battery-consumption&quot; scheme, and battery lasts, as I would really like, some months? We would be talking of only one battery to power the whole set-up, instead of two that I guess that we'll need.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm a newbie, but can't Arduino power 12v through a relay or a transistor? Can't post links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To clarify: Getting two batteries for our complete setup (one for the Arduino, one for the solenoid), if these two batteries both last, is not a problem; but it would be catastrophic to make a battery last long enough while the other depletes in 48 hours. The solenoid needs to get electricity a modest 5 times a day; that's why I believe we can make it super efficient.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With our friends, we've so far programmed Arduino to open a solenoid from the Internet. The solenoid we've used was 220v because we had it in stock; it won't be what we need for our project. It was just a trial. On top of this, the Arduino has no WiFi module, just an Ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gkd59.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gkd59.jpg&quot; alt=&quot;prototype&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a remaining problem to solve, which is: what would happen if the Arduino fails? The door would be sealed 'forever'. We'll tackle that issue afterwards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; we'd love to open a lock via WiFi: the lock and Arduino should run solely on batteries that last more than 48 hours: a couple of months would be ideal! Can we work this out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you very much for your help, opinions, and time. I hope my question is up to the standards.&lt;/p&gt;&#xA;" OwnerUserId="25787" LastEditorUserId="4628" LastEditDate="2018-01-10T05:36:20.173" LastActivityDate="2018-01-10T05:40:39.167" Title="Powering a 12v lock with batteries, via WiFi, and with low energy consumption" Tags="|wifi|battery|home-automation|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28393" PostTypeId="2" ParentId="28268" CreationDate="2016-08-16T07:31:57.513" Score="1" Body="&lt;p&gt;TC blocks are pretty much identical (except TC1 doesn't have wired some signals to pins)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you have to copy registers containing &lt;code&gt;*_TC0_* =&lt;/code&gt; and replace TC0 to TC2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Plus PC25 and PC24 should be set to its alternate function PIO_PERIPH_B. Something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC25B_TIOA6, PIO_DEFAULT);&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC26B_TIOB6, PIO_DEFAULT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Also TC6, TC7 and TC8 clocks must be enabled by:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;REG_PMC_PCER1 = PMC_PCER1_PID33 | PMC_PCER1_PID34 | PMC_PCER1_PID35;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And TC_CMR0..2 are Channel Mode Registers for one of three timers/counters in one TC block. Again, these are the same, but WAVE mode dependent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kRDgl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kRDgl.png&quot; alt=&quot;TC_CMR WAVE=0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/amN6y.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/amN6y.png&quot; alt=&quot;TC_CMR WAVE=1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full configuration:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  REG_PMC_PCER0 = PMC_PCER0_PID27 | PMC_PCER0_PID28 | PMC_PCER0_PID29;&#xA;  REG_PMC_PCER1 = PMC_PCER1_PID33 | PMC_PCER1_PID34 | PMC_PCER1_PID35;&#xA;&#xA;  PIO_Configure(PIOB, PIO_PERIPH_B, PIO_PB25B_TIOA0, PIO_DEFAULT); // arduino pin 2&#xA;  PIO_Configure(PIOB, PIO_PERIPH_B, PIO_PB27B_TIOB0, PIO_DEFAULT); // arduino pin 13&#xA;&#xA;  REG_TC0_CMR2  = TC_CMR_TCCLKS_TIMER_CLOCK4 | TC_CMR_WAVE | TC_CMR_ACPC_TOGGLE | TC_CMR_WAVSEL_UP_RC;&#xA;  REG_TC0_RC2   = F_CPU / 128 / 1;&#xA;  REG_TC0_CMR0  = TC_CMR_ABETRG | TC_CMR_LDRA_EDGE | TC_CMR_LDRB_EDGE | TC_CMR_ETRGEDG_EDGE | TC_CMR_CPCTRG;&#xA;  REG_TC0_BMR   = TC_BMR_QDEN | TC_BMR_SPEEDEN /*| TC_BMR_EDGPHA*/;&#xA;  REG_TC0_CCR0  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC0_CCR1  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC0_CCR2  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC25B_TIOA6, PIO_DEFAULT); // arduino pin 5&#xA;  PIO_Configure(PIOC, PIO_PERIPH_B, PIO_PC26B_TIOB6, PIO_DEFAULT); // arduino pin 4&#xA;&#xA;  REG_TC2_CMR2  = TC_CMR_TCCLKS_TIMER_CLOCK4 | TC_CMR_WAVE | TC_CMR_ACPC_TOGGLE | TC_CMR_WAVSEL_UP_RC;&#xA;  REG_TC2_RC2   = F_CPU / 128 / 10;&#xA;  REG_TC2_CMR0  = TC_CMR_ABETRG | TC_CMR_LDRA_EDGE | TC_CMR_LDRB_EDGE | TC_CMR_ETRGEDG_EDGE | TC_CMR_CPCTRG;&#xA;  REG_TC2_BMR   = TC_BMR_QDEN | TC_BMR_POSEN /*| TC_BMR_EDGPHA*/;&#xA;  REG_TC2_CCR0  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC2_CCR1  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;  REG_TC2_CCR2  = TC_CCR_CLKEN | TC_CCR_SWTRG;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2020-06-01T06:02:35.353" LastActivityDate="2020-06-01T06:02:35.353" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="28394" PostTypeId="2" ParentId="28385" CreationDate="2016-08-16T07:38:07.133" Score="1" Body="&lt;p&gt;A slightly more general answer to this question would be to browse the catalogue of a component supplier. Printed catalogues seem to be becoming rarer (Maplin used to sell a catalogue, but it seems to be discontinued this year), but RS and Farnell still seem to have printed ones. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm not suggesting you find specific components by searching the catalogue, but skimming through a catalogue will give you an idea about some of the components that do exist, and will help you to narrow things down a little.&lt;/p&gt;&#xA;" OwnerUserId="21252" LastActivityDate="2016-08-16T07:38:07.133" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28395" PostTypeId="1" AcceptedAnswerId="28397" CreationDate="2016-08-16T08:41:23.637" Score="1" ViewCount="13676" Body="&lt;p&gt;I have following problem:&#xA;I'm reading 8 bit signal from one Arduino pin and store all informatin in bool array. Now I want to convert this array to single byte in decimal. How to do this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool ID[8] = {0, 0, 0, 0, 0, 0, 1, 1};&#xA;int recivedID = int(ID);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool ID[8] = {0, 0, 0, 0, 0, 0, 1, 1};&#xA;int recivedID = ID.toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;non works.&lt;/p&gt;&#xA;" OwnerUserId="25802" LastActivityDate="2016-08-16T08:51:28.227" Title="How to convert bool array to byte?" Tags="|arduino-uno|c++|" AnswerCount="2" CommentCount="1" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28396" PostTypeId="2" ParentId="28395" CreationDate="2016-08-16T08:50:24.753" Score="1" Body="&lt;pre&gt;&lt;code&gt;byte BoolArrayToByte(bool boolArray[8])&#xA;{&#xA;  byte result = 0; &#xA;&#xA;  for(int i = 0; i &amp;lt; 8; i++)&#xA;  {&#xA;    if(boolArray[i])&#xA;    {&#xA;      result = result | (1 &amp;lt;&amp;lt; i);&#xA;    }&#xA;  }&#xA;&#xA;  return result;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25806" LastActivityDate="2016-08-16T08:50:24.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28397" PostTypeId="2" ParentId="28395" CreationDate="2016-08-16T08:51:28.227" Score="0" Body="&lt;p&gt;try with this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int recivedID = ID[0] | (ID[1] &amp;lt;&amp;lt; 1) | (ID[2] &amp;lt;&amp;lt; 2) | (ID[3] &amp;lt;&amp;lt; 3) | (ID[4] &amp;lt;&amp;lt; 4) | (ID[5] &amp;lt;&amp;lt; 5) | (ID[6] &amp;lt;&amp;lt; 6) | (ID[7] &amp;lt;&amp;lt; 7);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is the same as&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int recivedID = 0;&#xA;for(int i=0; i&amp;lt;8; i++){&#xA;   recivedID |= ID[i] &amp;lt;&amp;lt; i;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I haven't tested it though.&lt;/p&gt;&#xA;" OwnerUserId="25805" LastActivityDate="2016-08-16T08:51:28.227" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28400" PostTypeId="2" ParentId="8511" CreationDate="2016-08-16T10:59:22.253" Score="33" Body="&lt;p&gt;&lt;strong&gt;Consideration&lt;/strong&gt; (go down for the actual solution)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you have a lot of different China-Arduino-clones, the easiest way will be to just test it. The cloned Arduinos use a lot of different voltage regulators and often you won't even be able to find datasheets for them on Google.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Someone here provided an Arduino sketch which helps you identify the frequency with which the Atmel is running and the comments say &quot;it is the safest method&quot;. But why? It is complicated (you need to connect the USB-TTL-converter to each of the different Arduinos and sometimes they have different pinouts, so it's error-prone - you could easily fry your Arduino if you connect the wires to the wrong pins)...&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think the safest way is just connecting a voltage in the range of &lt;code&gt;6V-12V&lt;/code&gt; to the &lt;code&gt;RAW&lt;/code&gt;-pin and measuring the (regulated) output of the &lt;code&gt;VCC&lt;/code&gt;-pin. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is &lt;em&gt;no reason&lt;/em&gt; why this would kill your Arduino (in case your Arduino isn't broken - which would be good to know anyway; and of course you shouldn't short anything).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done a short sketch of how you should connect your Arduino Pro Mini:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/vRb0Y.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/vRb0Y.jpg&quot; alt=&quot;Connecting the Arduino Pro Mini&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;RAW&lt;/code&gt; &amp;lt;---&gt; &lt;code&gt;6V-12V&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;VCC&lt;/code&gt; &amp;lt;---&gt; multimeter (&lt;code&gt;5V = 5V Arduino&lt;/code&gt;, &lt;code&gt;3.3V = 3.3V Arduino&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;One &lt;code&gt;GND&lt;/code&gt; pins to the &lt;code&gt;GND&lt;/code&gt; of the power source and one &lt;code&gt;GND&lt;/code&gt; pins to the &lt;code&gt;GND&lt;/code&gt; of the multimeter (you can take any of the Arduino pins labeled with &lt;code&gt;GND&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Don't worry if your Arduino looks a little bit different, just look for the pin labels. For instance, one of my 5V Arduino Pro Minis looks like this, but also has &lt;code&gt;RAW&lt;/code&gt;-, &lt;code&gt;VCC&lt;/code&gt;- and &lt;code&gt;GND&lt;/code&gt;-labels (just one of the &lt;code&gt;GND&lt;/code&gt; pins is at a different position, make sure you check your Arduino pin-labels):&#xA;&lt;a href=&quot;https://i.stack.imgur.com/gge9q.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gge9q.jpg&quot; alt=&quot;Different Arduino Pro Mini layout&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Alternative&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't want to use the method above for some reasons? Then you need sharp eyes and some luck that the following list includes you components (some of these are collected from the other posts, some of them from my Arduinos):&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3.3V:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Voltage regulators: &lt;code&gt;KB33&lt;/code&gt;, &lt;code&gt;S20K&lt;/code&gt;, &lt;code&gt;F34V&lt;/code&gt;, &lt;code&gt;L0RA&lt;/code&gt;, &lt;code&gt;L0RB&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Oscillators: &lt;code&gt;80e.&lt;/code&gt;, &lt;code&gt;80'0&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;li&gt;5V:&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Voltage regulators: &lt;code&gt;KB50&lt;/code&gt;, &lt;code&gt;L05&lt;/code&gt;, &lt;code&gt;L0UA&lt;/code&gt;, &lt;code&gt;L0UB&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Oscillators: &lt;code&gt;R160JAC6s&lt;/code&gt;, &lt;code&gt;16.000-30&lt;/code&gt;, &lt;code&gt;A1&lt;/code&gt;, &lt;code&gt;A'N&lt;/code&gt;, &lt;code&gt;A'a&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;(no limit or warranty for these details...)&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;More Suggestions&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Some of the Arduino Pro Minis come with &lt;code&gt;MHz&lt;/code&gt; and &lt;code&gt;V&lt;/code&gt; markings on the back. In my case, none of these were checked. Make sure you check them as your new Arduinos arrive, so you won't have any problems identifying them later!&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ZFngy.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ZFngy.jpg&quot; alt=&quot;Arduino Pro Mini markings&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25808" LastEditorUserId="25808" LastEditDate="2016-08-16T13:04:48.920" LastActivityDate="2016-08-16T13:04:48.920" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28402" PostTypeId="1" AcceptedAnswerId="28622" CreationDate="2016-08-16T11:12:23.477" Score="0" ViewCount="254" Body="&lt;p&gt;I'm trying to control a DMX dimmer (&lt;a href=&quot;http://eshop.steinigke.de/de/mpn70064250-eurolite-es-12-iec-dmx-switchpack.html&quot; rel=&quot;nofollow&quot;&gt;eurolite ES-12 IEC DMX Switchback&lt;/a&gt;) through an Arduino Mega. In an earlier test, we were able to make one RGB DMX light run through the color spectrum. Now, a technician has installed this ES-12 dimmer pack with 12 1-channel DMX lights attached to it. The dimmer has some kind of built-in testing program and all the lights work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation on the dimmer is very sparse regarding the programming side of things. The dimmer is set to mode &lt;code&gt;d---&lt;/code&gt; and when the Arduino is running its program, a little green light flickers next to the &lt;code&gt;d---&lt;/code&gt;, apparently responding to the signals it's receiving, like so: &lt;code&gt;d---.&lt;/code&gt; Unfortunately, that the only light that responds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've tried using the DMXSimple library (the DMX is connected to pin 3), but even the example code (after correcting the brightness-- to ++) does not get any response -- none at all, not even the little green light. The only thing the little green light responds to is an analogWrite() on pin 3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm guessing it's an addressing issue, but I don't know enough to fix it. As I understand it, the dimmer is seen as the controller and is sent a LOW on channel 0 as the Start Code (SC): &lt;a href=&quot;http://www.dmx512-online.com/packt.html&quot; rel=&quot;nofollow&quot;&gt;http://www.dmx512-online.com/packt.html&lt;/a&gt;. The first light on the dimmer will then be channel 1, the second light channel 2, etc. (since, the technician tells me, they are 1-channel lights). Is this correct? Or is the dimmer its own universe that should be addressed in some other way?&lt;/p&gt;&#xA;" OwnerUserId="25810" LastActivityDate="2016-08-23T09:32:45.093" Title="DMX dimmer appears to receive data from Arduino but connected lights do not respond" Tags="|arduino-mega|programming|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28403" PostTypeId="1" CreationDate="2016-08-16T11:37:42.207" Score="1" ViewCount="8254" Body="&lt;p&gt;Here is my circuit:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/kMqM1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kMqM1.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;and here is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int LED = 13;&#xA;int BTN = 7;&#xA;&#xA;void setup() {&#xA;pinMode(LED,OUTPUT);&#xA;pinMode(BTN,INPUT);&#xA;}&#xA;void loop() {&#xA;if(digitalRead(BTN) == HIGH) {&#xA;digitalWrite(LED,LOW);&#xA;}&#xA;else{&#xA;digitalWrite(LED,HIGH);&#xA;}&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I press the button, the LED is supposed to go low, but it doesn't. What is wrong with this circuit/code?&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastActivityDate="2017-03-15T10:18:37.423" Title="Why isn't this pushbutton program working?" Tags="|arduino-uno|button|input|" AnswerCount="4" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28404" PostTypeId="2" ParentId="28403" CreationDate="2016-08-16T12:02:46.637" Score="1" Body="&lt;p&gt;Paul is correct. Your button is wired wrong. The GPIO pin should be connected to the same side as the resistor. Also the button needs rotating through 90 degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also check how your LED is wired up. At the moment it looks like it's set up so that the GPIO sinks the current (LOW turns the LED on) yet the LED looks like it's connected the wrong way around for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In fact, I can't actually find anything &lt;em&gt;right&lt;/em&gt; about that circuit...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-16T12:13:05.157" LastActivityDate="2016-08-16T12:13:05.157" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28405" PostTypeId="2" ParentId="28403" CreationDate="2016-08-16T12:05:14.543" Score="0" Body="&lt;p&gt;The Input port is going to always be at Gnd, because you have connected it to ground.  Sorry to put it in such basic terms but this is the way I understand it.  It needs to be more difficult for the output of the button to get to ground than to get to the BTN pin of your UNO.  So put a bigger resistor (1K-10K) in place of your yellow wire between the button and ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And your LED is the wrong way round in the diagram.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(And Majenko is a quicker typist than me! :) )&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-16T12:05:14.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28407" PostTypeId="2" ParentId="28390" CreationDate="2016-08-16T12:40:24.723" Score="-1" Body="&lt;p&gt;This is not the place to answer all the questions and design options that you have, but, to give you a starting point, you need to look at very low power arduino-compatible boards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My suggestion is to use an ESP8266 module which can be programmed as an Arduino (have a look at &lt;a href=&quot;http://www.esp8266.com/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). The module is quite low power, and &lt;a href=&quot;https://www.youtube.com/watch?v=IYuYTfO6iOs&quot; rel=&quot;nofollow&quot;&gt;it may run for some days with AA batteries&lt;/a&gt;. You can use a 12V power source for both the module and the solenoid (you need a voltage regulator). The solenoid will only be activated when needed, so the rest of the time it won't consume any power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The whole project is not a simple one. I would definitely suggest you to go step by step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Good luck.&lt;/p&gt;&#xA;" OwnerUserId="25805" LastActivityDate="2016-08-16T12:40:24.723" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28408" PostTypeId="2" ParentId="28403" CreationDate="2016-08-16T12:50:50.867" Score="0" Body="&lt;p&gt;In addition to the answers from Matt and Majenko, you code uses the wrong pin for the LED.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You have &lt;code&gt;int LED = 13;&lt;/code&gt; whereas your LED is connected to pin 6.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;NB: Pin 13 is connected to an LED soldered on to the Arduino board - as seen in the image below.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CY5Xx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CY5Xx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="18709" LastActivityDate="2016-08-16T12:50:50.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28409" PostTypeId="1" CreationDate="2016-08-16T13:08:21.703" Score="2" ViewCount="1890" Body="&lt;p&gt;I am having trouble with my Arduino Mega with getting the program to start when the Arduino is plugged into a computer via USB.  All that happens is the LED turns on and stays on.  The device does not initialize, and only when I press the reset button does it begin the setup.  How can I make the Arduino start the program when it is first plugged into the computer?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; my code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(115200);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;test&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;very simple, which is why i don't understand why this is happening&lt;/p&gt;&#xA;" OwnerUserId="24069" LastEditorUserId="24069" LastEditDate="2016-08-16T13:30:36.670" LastActivityDate="2022-08-14T19:06:43.103" Title="Arduino program does not start when plugged in" Tags="|arduino-mega|usb|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28411" PostTypeId="1" AcceptedAnswerId="28412" CreationDate="2016-08-16T13:58:23.427" Score="0" ViewCount="121" Body="&lt;p&gt;I would like to start with a very simple robot, which should be based on an arduino uno.&#xA;I already have an uno and made the decision fpr my robot chassie:&#xA;&lt;a href=&quot;https://www.roboter-bausatz.de/en/diy-electronics/kits/robotic-kits/97/2wd-motor-smart-car-chassis-fuer-roboter-mit-getriebemotor-und-batteriebox&quot; rel=&quot;nofollow&quot;&gt;https://www.roboter-bausatz.de/en/diy-electronics/kits/robotic-kits/97/2wd-motor-smart-car-chassis-fuer-roboter-mit-getriebemotor-und-batteriebox&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Additionally I want to by an ultrasonic distance sensor and a infrared sensor.&#xA;What else do I need to start ? Only a DC motor driver or anything else?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance&#xA;LStrike&lt;/p&gt;&#xA;" OwnerUserId="16424" LastActivityDate="2016-08-16T14:26:08.290" Title="Start to build a robot" Tags="|arduino-uno|motor|robotics|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28412" PostTypeId="2" ParentId="28411" CreationDate="2016-08-16T14:26:08.290" Score="0" Body="&lt;p&gt;You'll need:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Emergency switch (it should be easy to cut the power off, even for small robots)&lt;/li&gt;&#xA;&lt;li&gt;A chassis (you've found one already)&lt;/li&gt;&#xA;&lt;li&gt;Motors (Obviously)&lt;/li&gt;&#xA;&lt;li&gt;Motor control (Probably a dual H-bridge, think if you need reverse or not.)&lt;/li&gt;&#xA;&lt;li&gt;Power (powering on (single use) batteries may not be your best option)&lt;/li&gt;&#xA;&lt;li&gt;Controller (Arduino Uno, or something smaller or faster)&lt;/li&gt;&#xA;&lt;li&gt;Sensors (Can be anything, depending on the requirements)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;A way to communicate with the robot is also nice, often wireless (bluetooth/wifi/443mhz).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also, it will be nice if the robot fits some kind of purpose, but this could be added later.&#xA;You could think of the robot having to pick up and carry something, extinguish a flame etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I advise to check out one of the many tutorials on building a robot, they often have a detailed parts list (sometimes even shopping links).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-08-16T14:26:08.290" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28420" PostTypeId="1" CreationDate="2016-08-16T18:53:19.857" Score="0" ViewCount="6308" Body="&lt;p&gt;Hi everyone I seem to have run into a problem while uploading a library to the board. I managed to import the library to Arduino Uno, however, i could not upload it&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please Help :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advance&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error i received:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.6.11 Hourly Build 2016/08/05 02:12 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;&#xA;&#xA;In file included from /Users/pendukenipandeni/Documents/Arduino/SimpleTimer/SimpleTimer.ino:1:0:&#xA;/Users/pendukenipandeni/Documents/Arduino/libraries/SimpleTimer-master/SimpleTimer.h:37:22: fatal error: functional: No such file or directory&#xA; #include &amp;lt;functional&amp;gt;&#xA;                      ^&#xA;compilation terminated.&#xA;exit status 1&#xA;Error compiling for board Arduino/Genuino Uno.&#xA;&#xA;This report would have more information with&#xA;&quot;Show verbose output during compilation&quot;&#xA;option enabled in File -&amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25522" LastEditorUserId="4143" LastEditDate="2016-08-16T18:54:28.090" LastActivityDate="2018-05-29T15:48:56.717" Title="Compilation Error" Tags="|arduino-uno|compile|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28421" PostTypeId="2" ParentId="28420" CreationDate="2016-08-16T19:45:32.920" Score="2" Body="&lt;p&gt;I managed to fix this by simply downloading and uploading a different SimpleTimer Library from &lt;a href=&quot;https://github.com/jfturcot/SimpleTimer&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jfturcot/SimpleTimer&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25522" LastActivityDate="2016-08-16T19:45:32.920" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28422" PostTypeId="1" CreationDate="2016-08-16T19:54:28.350" Score="0" ViewCount="815" Body="&lt;p&gt;I try to send an &quot;a&quot; string via serial with&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(&quot;a&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and I receive &quot;Oy=&quot; in Ascii or {4F}{79}{3D} in Hexa.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where should I start investigating? What could be wrong?  Baudrate is 9600 on all sides.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: I suspect the cable. Any hints how to check it?&lt;/p&gt;&#xA;" OwnerUserId="3183" LastEditorUserId="3183" LastEditDate="2016-08-16T20:05:23.887" LastActivityDate="2016-08-16T20:13:35.190" Title="Serial characters are corrupted" Tags="|serial|arduino-mega|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28423" PostTypeId="2" ParentId="28422" CreationDate="2016-08-16T20:13:35.190" Score="1" Body="&lt;p&gt;On your setup function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(115200);//&amp;lt;- 115200 is the baud rate, serial monitor must match this speed&#xA;while(!Serial);//&amp;lt;-- wait for Serial to be ready&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;see: &lt;a href=&quot;https://electronics.stackexchange.com/questions/9264/what-standard-uart-rates-are-there&quot;&gt;https://electronics.stackexchange.com/questions/9264/what-standard-uart-rates-are-there&lt;/a&gt; for more baud rates&lt;/p&gt;&#xA;" OwnerUserId="527" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-08-16T20:13:35.190" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28424" PostTypeId="1" CreationDate="2016-08-16T20:36:06.323" Score="-2" ViewCount="245" Body="&lt;p&gt;for 2.8&quot; diagonal color touchscreen TFT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Readme states:&#xA;&quot;Works with any classic Arduino '328. Solder closed three jumpers to use the ICSP header for use with Leonardo or Mega&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I solder? See image.&lt;a href=&quot;https://i.stack.imgur.com/mIfbu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/mIfbu.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6976" LastActivityDate="2016-08-19T21:56:34.257" Title="Use a 2.8&quot; TFT with my Leonardo" Tags="|arduino-leonardo|tft|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28426" PostTypeId="1" AcceptedAnswerId="28427" CreationDate="2016-08-16T22:29:53.307" Score="0" ViewCount="37" Body="&lt;p&gt;The &quot;DumpFile.ino&quot; example sketch from the SD library tries to open a file off an SD card, read its contents, and write them to the Serial Monitor. I am confused in how the following &lt;code&gt;if()&lt;/code&gt; statement is evaluated:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File dataFile = SD.open(&quot;datalog.txt&quot;);&#xA;&#xA;if (dataFile) {&#xA;// read and print, then close&#xA;}&#xA;else {&#xA;// print error message&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There must be some implicit conversion on &lt;code&gt;dataFile&lt;/code&gt; which depends on whether or not &lt;code&gt;SD.open(&quot;myFile.txt&quot;)&lt;/code&gt; was successful. I would like to understand how this implicit conversion occurs. Which property of the &lt;code&gt;File&lt;/code&gt; object determines if the &lt;code&gt;if()&lt;/code&gt; statement evaulates &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;?&lt;/p&gt;&#xA;" OwnerUserId="19573" LastActivityDate="2016-08-16T22:43:19.720" Title="How is IF( object ) evaluated? Follows from SD card example sketch" Tags="|c++|sd-card|" AnswerCount="1" CommentCount="1" ClosedDate="2016-08-17T01:11:56.450" ContentLicense="CC BY-SA 3.0" />
  <row Id="28427" PostTypeId="2" ParentId="28426" CreationDate="2016-08-16T22:43:19.720" Score="1" Body="&lt;p&gt;There is an operator bool which does the test:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;File::operator bool() {&#xA;  if (_file) &#xA;    return  _file-&amp;gt;isOpen();&#xA;  return false;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When used inside an &lt;code&gt;if&lt;/code&gt; the compiler invokes the &lt;code&gt;operator bool()&lt;/code&gt; which does the test you see above.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-16T22:43:19.720" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28428" PostTypeId="1" AcceptedAnswerId="28434" CreationDate="2016-08-17T03:20:39.787" Score="0" ViewCount="3407" Body="&lt;p&gt;I have some really simple code and tested on an 8&amp;nbsp;MHz &lt;a href=&quot;http://www.atmel.com/devices/ATTINY85.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATtiny85&lt;/a&gt; and &lt;a href=&quot;http://www.atmel.com/devices/ATTINY2313.aspx&quot; rel=&quot;nofollow noreferrer&quot;&gt;ATtiny2313&lt;/a&gt;. It's basically a blocking blink:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int relayPin = 7;&#xA;&#xA;long offPeriod = 1 * 60 * 1000;&#xA;long onPeriod = 1 * 60 * 1000;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(relayPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(relayPin, LOW);&#xA;  delay(onPeriod);&#xA;  digitalWrite(relayPin, HIGH);&#xA;  delay(offPeriod);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I assign &lt;code&gt;onPeriod&lt;/code&gt; and &lt;code&gt;offPeriod&lt;/code&gt; to be &lt;code&gt;1 * 1000&lt;/code&gt; (1 second), the LED will blink as expected. When I add the 60 second multiplier in, it seems to fail.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the ATtiny85 I use Arduino Pin 4 (physical pin 3) and for the ATtiny2313, I use Arduino pin 7 (physical pin 9).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I program through the Arduino IDE using boards manager to install the ATTinyCore library for the ATtiny2313 and &lt;a href=&quot;https://github.com/damellis/attiny&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; for the ATtiny85.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Am I doing something wrong here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like if I throw the delay in a function, and then invoke it with however many seconds I want, it will work. This is not good as it remains blocking. So perhaps the correct way to do this is to grab timestamps.&#xA;Here's the somewhat working code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int relayPin = 4;&#xA;unsigned long offPeriod = 60;&#xA;unsigned long onPeriod = 60;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(relayPin, OUTPUT);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  digitalWrite(relayPin, LOW);&#xA;  delaySeconds(onPeriod);&#xA;  digitalWrite(relayPin, HIGH);&#xA;  delaySeconds(offPeriod);&#xA;}&#xA;&#xA;void delaySeconds(int s) {&#xA;  for (int i = 0; i &amp;lt; s; i++) {&#xA;    delay(1000);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="6709" LastEditorUserId="510" LastEditDate="2016-11-04T21:07:38.580" LastActivityDate="2016-11-04T21:07:38.580" Title="Why can't the Atmel ATtiny family delay over a minute?" Tags="|arduino-ide|attiny|avr|atmel-studio|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28429" PostTypeId="2" ParentId="28428" CreationDate="2016-08-17T05:17:25.203" Score="4" Body="&lt;p&gt;These are the problem lines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long offPeriod = 1 * 60 * 1000;&#xA;long onPeriod = 1 * 60 * 1000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Even though &lt;code&gt;long&lt;/code&gt; should hold the result, integer operations in C++ are still done in &lt;code&gt;int&lt;/code&gt; by default. And on AVR &lt;code&gt;int&lt;/code&gt; is 16 bits. The fix is to tell the compiler what size the intermediate result should be:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;long offPeriod = 1 * 60L * 1000;&#xA;long onPeriod = 1 * 60L * 1000;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-17T05:17:25.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28433" PostTypeId="2" ParentId="28428" CreationDate="2016-08-17T07:26:30.940" Score="-1" Body="&lt;p&gt;According to &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html&quot; rel=&quot;nofollow&quot;&gt;AVR libC&lt;/a&gt; the implementation of the delay function has a limited value range that varies with the F_CPU macro definition. So your &lt;code&gt;delaySeconds(int)&lt;/code&gt; function is the only solution.&lt;/p&gt;&#xA;" OwnerUserId="23644" LastActivityDate="2016-08-17T07:26:30.940" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28434" PostTypeId="2" ParentId="28428" CreationDate="2016-08-17T09:09:40.363" Score="8" Body="&lt;p&gt;This is absolutely nothing to do with &quot;why can't the atmel attiny family delay over a minute?&quot;. It is all to do with the way that C++ works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12146&quot;&gt;my page about Integer arithmetic and overflow&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To excerpt from that:&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;On the Arduino (Uno) platform, what do you think will be printed here?&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  Serial.println (30000 + 30000); // twice 30000&#xA;  Serial.println (60 * 60 * 24);  // seconds in a day&#xA;  Serial.println (50 / 100 * 1000); // half of 1000&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Did you guess:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;60000&#xA;86400&#xA;500&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Nope!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It prints:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;-5536&#xA;20864&#xA;0&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is because of &lt;strong&gt;integer arithmetic&lt;/strong&gt;. If the compiler can, it treats an numeric literal (like 60) as an int type, which means it has the range -32768 to +32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And, arithmetic is done using the type of the largest argument, which means the arithmetic in each case is done as 16-bit arithmetic, and thus it overflows once it reaches 32767.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, 30000 + 30000 = 60000 which is 0xEA60 in hex. Unfortunately, 0xEA60 is exactly how -5536 is stored in an int type, which is why it prints -5536.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Meanwhile, 60 * 60 * 24 = 86400 which is 0x15180 in hex. As that doesn't fit in 16 bits, it is truncated to 0x5180 which is 20864 in decimal (as printed).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, in integer arithmetic 50/100 is zero, multiply zero by 1000 and you still get zero, which is why the final result is zero.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;Solution&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;First, you can add a suffix to numeric literals (eg. L for long, or UL for unsigned long), and add a decimal place to floats, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  Serial.println (30000L + 30000); // twice 30000&#xA;  Serial.println (60L * 60 * 24);  // seconds in a day&#xA;  Serial.println (50.0 / 100 * 1000); // half of 1000&#xA;  }  // end of setup&#xA;&#xA;void loop () { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now we get:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;60000&#xA;86400&#xA;500.00&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You only need to help out with the first literal, once the compiler knows we are using longs (or floats) it sticks with them for the expression.*&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;* It's actually somewhat more complex than that as this link explains: &lt;a href=&quot;https://www.securecoding.cert.org/confluence/display/cplusplus/INT02-CPP.+Understand+integer+conversion+rules&quot;&gt;Understand integer conversion rules&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The compiler &quot;promotes&quot; a value in an expression to match another &quot;higher-ranked&quot; type, under certain circumstances. For example, adding an &lt;strong&gt;int&lt;/strong&gt; and a &lt;strong&gt;long&lt;/strong&gt; will result in the &lt;strong&gt;int&lt;/strong&gt; being promoted to a &lt;strong&gt;long&lt;/strong&gt; (regardless of whether it appears first in the expression or not). However if an &lt;strong&gt;int&lt;/strong&gt; is being added to another &lt;strong&gt;int&lt;/strong&gt;, it will not promote them to a &lt;strong&gt;long&lt;/strong&gt;, even though the result may not fit into an &lt;strong&gt;int&lt;/strong&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-17T09:09:40.363" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28435" PostTypeId="2" ParentId="28390" CreationDate="2016-08-17T09:19:11.380" Score="-1" Body="&lt;p&gt;As far as the 12V motor is concerned, you can construct a decent H-bridge to shift polarity. I am assuming you are using a linear actuator or servo. Use a mechanical relay with 2 channels. Wire GND to NO1 and NO2, VCC (12V) to NC1 and NC2, and pull VOUT  to motor from COM1 and COM2 - IIRC - and in your code track state of when each channel is on or off... It will short out if both relay channels are ON simultaneously, so that must not be possible.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Mechanical relays are slower to switch than transistors (can haul 230VAC/30VDC/10A with no voltage drop), but if you want a transistor H-bridge use the rather old TIP120 NPN Darlington (0.6-0.7V voltage drop per transistor), or MOSFETs. At least the TIP120s require heatsinking for &gt;=0.5A, but can drive 5-6A upto 60V, which is plenty.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the wifi bit goes, I don't have enough experience. I would use a GET request to a web server/page and read what state the lock should be in at short intervals... no more than 5 seconds. A simple '1' or '0' in a text file will do. To output state, heartbeat (is the Arduino OK right now, or is something wrong?) and other stuff from the Arduino, use POST requests. You should use a simple database for this... PostgreSQL is my favourite, but you may want something simpler.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need precise timekeeping for events like open at 9.00 am, use a DS3231. Be careful to conserve SRAM, the Uno has only 2KB. There are guides on arduino.cc to help you with that (PROGMEM for immutable variables and the F macro for static strings). This is a good method, hope it helps.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastEditorUserId="4628" LastEditDate="2018-01-10T05:40:39.167" LastActivityDate="2018-01-10T05:40:39.167" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28439" PostTypeId="1" CreationDate="2016-08-17T11:31:27.730" Score="0" ViewCount="1091" Body="&lt;p&gt;I tried l298n before but its output voltage wasn't high&lt;/p&gt;&#xA;&#xA;&lt;p&gt;so I use relay shield but  it seems that the car can only go forward or stop&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can I control the speed and direction of dc motors?&lt;/p&gt;&#xA;" OwnerUserId="25784" LastActivityDate="2016-08-17T12:41:10.387" Title="How to use relay shield to control dc motor speed and direction?" Tags="|motor|relay|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28440" PostTypeId="1" CreationDate="2016-08-17T11:42:24.900" Score="1" ViewCount="833" Body="&lt;p&gt;I have a &lt;a href=&quot;http://linksprite.com/wiki/index.php5?title=SIM900_GPRS/GSM_Shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;SIM900 GPRS/GSM Shield&lt;/a&gt; and an Arduino Mega. Now for the past week I have been using USB as power to send and receive GPRS data with no issue. Today the SIM900 module is continually randomly turning off, not even turning of at specific stages of communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought this could be power related, so have external power (5V 5A UBEC) into the 5V pin of the Mega, which I believe should cover the voltage and current requirements of the SIM900 shield. However this has not solved the problem.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on what could be causing the random shutdowns?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&#xA;Is it safe for me to wire power up like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/sImrM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sImrM.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="12166" LastEditorUserId="12166" LastEditDate="2016-08-17T14:05:30.610" LastActivityDate="2017-09-12T13:04:41.613" Title="SIM900 random shutdowns" Tags="|arduino-mega|power|communication|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28441" PostTypeId="2" ParentId="28439" CreationDate="2016-08-17T12:25:17.663" Score="0" Body="&lt;p&gt;Yes you can, but the easiest way is by using a &quot;motor shield&quot;.  There are more options than just L298N.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Are you sure it was the voltage that wasn't high enough, its normally the current (Amps)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To do it with a relay you need to change the polarity of the feeds to the motor.  You could do this with 2 relays both connected all the time, but if you close the wrong one, you will short everything.  It would be better using a motor controller.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-17T12:25:17.663" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28442" PostTypeId="1" AcceptedAnswerId="28445" CreationDate="2016-08-17T12:25:56.467" Score="0" ViewCount="201" Body="&lt;p&gt;I'm working on my first arduino project and i have my first problem dealing with servo motor , i'm trying to control the servo from my pc with this code but it just spining :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  #include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;Servo servo1;  &#xA;long num;     &#xA;&#xA;void setup()&#xA;{&#xA;   servo1.attach(7);&#xA;   Serial.begin(9600); &#xA;   Serial.print(&quot;Enter Position = &quot;);&#xA;}&#xA;&#xA;void loop() &#xA;{ &#xA;  while(Serial.available()&amp;gt;0)&#xA;  { &#xA;    num= Serial.parseInt();   &#xA;    Serial.print(num);  &#xA;    Serial.println(&quot; degree&quot;);&#xA;    Serial.print(&quot;Enter Position = &quot;);&#xA;  }&#xA;  servo1.write(num);&#xA;  delay(15);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this is my setup&#xA;   &lt;a href=&quot;https://i.stack.imgur.com/wRggT.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/wRggT.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="34429" LastEditorUserId="10394" LastEditDate="2016-08-17T12:30:52.727" LastActivityDate="2016-08-17T12:37:47.337" Title="Arduino servo motor on pushbutton" Tags="|arduino-uno|motor|servo|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28443" PostTypeId="2" ParentId="28439" CreationDate="2016-08-17T12:27:12.823" Score="0" Body="&lt;p&gt;Most refer to &lt;a href=&quot;https://en.wikipedia.org/wiki/Relay&quot; rel=&quot;nofollow&quot;&gt;relays&lt;/a&gt; when talking about mechanical devices which are either closed or open.  If you arrange several in an H-bridge configuration, you can make you car go forward, stop and reverse.  But controlling speed is not possible.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-08-17T12:27:12.823" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28444" PostTypeId="2" ParentId="28440" CreationDate="2016-08-17T12:28:58.600" Score="0" Body="&lt;p&gt;Pumping 5Amps into the Mega isn't going to make a difference to the current the SIM900 is receiving (needs &gt;2A)  it will still get 500mA (?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to feed the power directly into the SIM900 from the PSU, because when it transmits it needs a nuclear reactor to power it.  Don't forget the common ground.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-17T12:28:58.600" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28445" PostTypeId="2" ParentId="28442" CreationDate="2016-08-17T12:37:47.337" Score="0" Body="&lt;p&gt;I have reformatted your code and the problem becomes very clear (to me).&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{ &#xA;  while(Serial.available()&amp;gt;0)&#xA;  { &#xA;    num= Serial.parseInt();   &#xA;    Serial.print(num);  &#xA;    Serial.println(&quot; degree&quot;);&#xA;    Serial.print(&quot;Enter Position = &quot;);&#xA;  }&#xA;  servo1.write(num);&#xA;  delay(15);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You are getting some input from the user and then setting the servo to that point.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When there is no data in the Serial buffer you set the servo to the value of write and delay 15ms before checking the buffer again.&lt;br&gt;&#xA;I think what you want to do is if there is no data then you don't want to change the Servo position.  In short move the &lt;code&gt;servo1.write(num);&lt;/code&gt; line inside the } of the while loop.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now much more importantly the first time you enter loop() you won't have any data there so the servo will be moved to the number held in &lt;code&gt;num&lt;/code&gt; which is? Undefined, it could be anything at all from 0 to 4294967295 and if its the upper end of that it will take a while for the servo to get there, it might seem like all it does is spin.  &lt;strong&gt;ALWAYS INITIALIES VARIABLES BEFORE USE&lt;/strong&gt; :)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A minor point, your while loop could be, probably should be an if statement.  That will prevent a cat sitting on the keyboard and blocking the servo movement.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-08-17T12:37:47.337" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28446" PostTypeId="2" ParentId="28439" CreationDate="2016-08-17T12:41:10.387" Score="1" Body="&lt;p&gt;Using a mechanical relay to control the speed is not a good idea. But you can control the directions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I prefer you to use Solid state relays (SSR) to do this. Arrange 4 SSR as Hbridge and Use PWM to control the speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;refer &lt;a href=&quot;http://www.power-io.com/library/appnotes/h-bridge.htm&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;or you can use the devices like &lt;a href=&quot;http://www.crydom.com/en/tech/newsletters/jan%202013%20-%20solid%20statements%20-%20dc%20motor%20reversing.pdf&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; which has direction control as well. &lt;/p&gt;&#xA;" OwnerUserId="25643" LastActivityDate="2016-08-17T12:41:10.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28451" PostTypeId="2" ParentId="1180" CreationDate="2016-08-17T18:43:11.827" Score="1" Body="&lt;p&gt;I know you were probably after more advanced GUI output, but I managed to replicate a task that one would normally do with an oscilloscope:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/VhOIW.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/VhOIW.jpg&quot; alt=&quot;Arduino Serial Plotter output&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;using the serial plotter in the Arduino IDE and an ADC module you can get for $3 on eBay. I admit it's a bit crude, but it might be worth playing with the tool for a while, before you invest in Python/Matlab/ect level solutions. It was exceedingly easy to use. It would not take much to add SD card recording to the process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See: &lt;a href=&quot;https://edwardmallon.wordpress.com/2016/08/15/using-the-arduino-uno-as-a-basic-data-acquisition-system/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://edwardmallon.wordpress.com/2016/08/15/using-the-arduino-uno-as-a-basic-data-acquisition-system/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="16238" LastActivityDate="2016-08-17T18:43:11.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28456" PostTypeId="1" CreationDate="2016-08-18T01:19:34.247" Score="3" ViewCount="349" Body="&lt;p&gt;I am looking to build my own arduino-based board that, when triggered, will play a file (line out, not amped to a speaker). Most of the audio shields I see are more complicated than I need, so what I'm wondering is what is the barebones circuit I would need for audio output? I've got the atmega and SDcard side fine, I'm just not sure what IC's are involved in audio output. WAV's are fine so I don't have to deal with mp3 decoding. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS feel free to move this to electronics instead of arduino, I'm not sure where it belonged since it's built into an arduino board but is more the electronic circuitry. &lt;/p&gt;&#xA;" OwnerUserId="18878" LastActivityDate="2017-08-14T12:33:50.003" Title="Arduino audio output circuit" Tags="|audio|pcb-design|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28457" PostTypeId="2" ParentId="18925" CreationDate="2016-08-18T01:48:14.880" Score="1" Body="&lt;p&gt;Although the nRF51822 supports Central (master) mode, the Adafruit Feather's firmware only support's Peripheral (slave) mode.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Bluefruit LE firmware from Adafruit is currently peripheral only,&#xA;  and doesn't run in Central mode, which would cause the module to&#xA;  behave similar to your mobile phone or BLE enabled laptop.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;At some point we might consider a new firmware image offering this,&#xA;  but since 98% of the uses cases for BLE involved running as a&#xA;  peripheral we've concentrated all of our development effort there for&#xA;  now.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;&lt;a href=&quot;https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/faq#faq-2&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/faq#faq-2&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The HM-11 on your Seeed shield &lt;strong&gt;is&lt;/strong&gt; capable of Central (master) mode though. This means your Uno will play the part that your Android phone was playing when you connected the Feather to the terminal app. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To set your HM-11 to Central mode, run the following AT command. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT+ROLE1&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://wiki.seeedstudio.com/wiki/Bluetooth_V4.0_HM-11_BLE_Module&quot; rel=&quot;nofollow&quot;&gt;Example code for the HM-11&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Alternatively, you could burn the S120 Soft Device and your own custom firmware onto the Feather's nRF51822. You can find all the docs, tools, and Soft Device images &lt;a href=&quot;https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF51822&quot; rel=&quot;nofollow&quot;&gt;on Nordic's website&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="25690" LastActivityDate="2016-08-18T01:48:14.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28458" PostTypeId="1" AcceptedAnswerId="28470" CreationDate="2016-08-18T05:52:36.247" Score="0" ViewCount="143" Body="&lt;p&gt;This is a snip it of code from a program I am writing. I have the program turn an LED on and if a button is pressed when the LED is on I want it to add to a counter and print the counter value. The problem seems that my if statement is skipped. Right now the while loop is setup for 5 seconds using millis() and stays off using a short delay. This part (button_press_9())) is a function call to a Boolean I have setup for debouncing. If I put the function call in an if statement by its self for example to test it. It works and will turn an LED on and off. It seems the combination of the two is incompatible. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you in advance. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long previousMillis = millis();&#xA;unsigned long currentMillis = millis();&#xA;&#xA;while ((currentMillis - previousMillis) &amp;lt; onTime)&#xA;{&#xA;    digitalWrite(ledPin4, HIGH);&#xA;    if (ledPin4 == HIGH &amp;amp;&amp;amp; (button_press_9()))&#xA;    {&#xA;        counter++;&#xA;        Serial.println(counter);&#xA;        currentMillis = onTime * 100;&#xA;    }&#xA;    currentMillis = millis();&#xA;}&#xA;digitalWrite(ledPin4, LOW);&#xA;delay(1000);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="20714" LastActivityDate="2016-08-18T11:36:58.923" Title="Using logical operators" Tags="|programming|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28461" PostTypeId="1" CreationDate="2016-08-18T08:47:58.543" Score="1" ViewCount="5462" Body="&lt;p&gt;I'm working on my own project with Arduino Uno. There are controlled 4 pneumatic cylinders via 4 coils. Every pneumatic cylinder has got their own coil which switch air to the pneumatic cylinder. Every pneumatic cylinder has got 2 magnetic sensors (when the pneumatic cylinder is retracted and extended).&#xA;I created a program for arduino but it doesn't work correctly. When I write there that I want to control only 2 pneumatic cylinders, it works correctly. If I write there the others, it skip the second if statement, do the third if statement and then do the previous if. I don't know why. The behaviour is random. What's wrong with my code? Thank you for help!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// Constants for pneumatic valves&#xA;   const int dvere = 2;&#xA;   const int davkovani = 3;&#xA;   const int lisovani = 4;&#xA;   const int vyhazovani = 5;&#xA;// ----------------------------------------&#xA;// Constants for sensors&#xA;   const int vyhazovaniZasunute = 6;&#xA;   const int vyhazovaniVysunute = 7;&#xA;   const int lisovaniVysunute = 8;&#xA;   const int lisovaniZasunute = 9;&#xA;   const int dvereZasunute = 10;&#xA;   const int dvereVysunute = 11;&#xA;   const int davkovaniVysunute = 12;&#xA;   const int davkovaniZasunute = 13;&#xA;&#xA;&#xA;void setup() {&#xA;  // Pneumatic cylinders set as output&#xA;  pinMode(dvere, OUTPUT);    &#xA;  pinMode(davkovani, OUTPUT);    &#xA;  pinMode(lisovani, OUTPUT);    &#xA;  pinMode(vyhazovani, OUTPUT);    &#xA;&#xA;  // Sensors set as input&#xA;  pinMode(vyhazovaniZasunute, INPUT);   &#xA;  pinMode(vyhazovaniVysunute, INPUT);   &#xA;  pinMode(lisovaniVysunute, INPUT);   &#xA;  pinMode(lisovaniZasunute, INPUT);   &#xA;  pinMode(dvereZasunute, INPUT);   &#xA;  pinMode(dvereVysunute, INPUT);  &#xA;  pinMode(davkovaniVysunute, INPUT);  &#xA;  pinMode(davkovaniZasunute, INPUT);  &#xA;&#xA;  // Set pneumatic cylinders as they are retracted&#xA;  digitalWrite(dvere, HIGH);&#xA;  digitalWrite(davkovani, HIGH);&#xA;  digitalWrite(lisovani, HIGH);&#xA;  digitalWrite(vyhazovani, HIGH);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;  if(digitalRead(dvereZasunute) == HIGH)&#xA;  {&#xA;      digitalWrite(dvere, LOW);      // extend the first pneumatic cylinder when the sensor is lighted on because the pneumatic cylinder is retracted&#xA;  }&#xA;&#xA;  if(digitalRead(dvereVysunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH&#xA;  )&#xA;  {&#xA;      digitalWrite(davkovani, LOW);      // extend the second pneumatic cylinder&#xA;      delay(4000);&#xA;      digitalWrite(davkovani, HIGH);    // retract the second pneumatic cylinder after 4 seconds, &#xA;      // this code works when it is alone there, the next if statements not&#xA;  }&#xA;&#xA;  if(digitalRead(dvereVysunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(lisovaniZasunute) == HIGH)&#xA;  {&#xA;      digitalWrite(lisovani, LOW);    // extend the third pneumatic cylinder&#xA;      delay(3000);&#xA;      digitalWrite(lisovani, HIGH);   // retract the secondthird pneumatic cylinder after 3 seconds&#xA;  }&#xA;&#xA;  if(digitalRead(dvereVysunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(lisovaniZasunute) == HIGH)&#xA;  {&#xA;      digitalWrite(dvere, HIGH);      // retract the first pneumatic cylinder&#xA;  }&#xA;&#xA;  if(digitalRead(dvereZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(lisovaniZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(vyhazovaniZasunute) == HIGH)&#xA;  {&#xA;      digitalWrite(vyhazovani, LOW);    // extend the fourth pneumatic cylinder&#xA;  }&#xA;&#xA;  if(digitalRead(dvereZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH &amp;amp;&amp;amp; digitalRead(lisovaniZasunute) == HIGH&amp;amp;&amp;amp; digitalRead(vyhazovaniVysunute) == HIGH)&#xA;  {&#xA;      digitalWrite(vyhazovani, HIGH);    // retract the fourth pneumatic cylinder&#xA;  }&#xA;&#xA;  // sensors - HIGH - light on, LOW - light off,&#xA;  // pneumatic cylinders - HIGH - retracted, LOW - extended.&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25865" LastEditorUserId="25865" LastEditDate="2016-08-19T13:38:43.803" LastActivityDate="2018-01-22T07:45:51.193" Title="Pneumatic cylinders with sensors with Arduino Uno" Tags="|arduino-uno|sensors|" AnswerCount="3" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28462" PostTypeId="2" ParentId="28461" CreationDate="2016-08-18T09:21:32.703" Score="0" Body="&lt;p&gt;Your code's variable names must be meaningful. You mention &quot;2 magnetic sensors (when the pneumatic cylinder is retracted and extended)&quot;-I guess it is solenoid valve. I hope I don't guess wrongly. This help us to understand your code. Otherwise, do you have any procedure diagram-it is like square and prismatic shape to illustrate your programing and its sequence.   &lt;/p&gt;&#xA;" OwnerUserId="25868" LastActivityDate="2016-08-18T09:21:32.703" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="28464" PostTypeId="1" CreationDate="2016-08-18T09:33:42.967" Score="2" ViewCount="19660" Body="&lt;p&gt;so I have a circuit with a buzzer and a resistor:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/EsL8s.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EsL8s.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This circuit should be working, but for some reason the buzzer doesn't sound. I pushed the buzzer into the breadboard as hard as I could, I put the + side to positive and the - side to negative but it still doesnt work :(. How can I fix this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Quick curiosity question: When I was doing electricity in school, the teacher just called the buzzers 'buzzers' but when I started doing arduino I noticed that the arduino community seems to call them 'Piezo buzzers/piezo speakers'. Is there any significance in the word 'Piezo' and should I start referring to them as 'Piezo buzzers' myself?&lt;/p&gt;&#xA;" OwnerDisplayName="user15851" LastActivityDate="2019-12-07T14:42:41.723" Title="Circuit with buzzer not working :(" Tags="|arduino-uno|buzzer|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28465" PostTypeId="1" AcceptedAnswerId="28469" CreationDate="2016-08-18T09:55:55.800" Score="1" ViewCount="21521" Body="&lt;p&gt;I am having a double value for example: 34.26 or 11.92 or 2.51. It should be rounded to the nearest 0.5 so 1.34 -&gt; 1.50 and 32.78 -&gt; 33 and 21.09 -&gt; 21.00 &lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do to do this?&lt;/p&gt;&#xA;" OwnerUserId="25779" LastActivityDate="2019-10-01T11:12:10.340" Title="Arduino round to nearest 0.5" Tags="|arduino-uno|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28466" PostTypeId="2" ParentId="28464" CreationDate="2016-08-18T10:10:23.120" Score="6" Body="&lt;p&gt;There is two kinds of buzzers - active and passive&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Passive buzzer means they can be operated by applying  just logic high to + and low to ground.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Digitalwrite function will do this job&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;Active buzzers needs pulses to make sound. Sound produced depends on the frequency.  Your buzzer might be a passive one. You can make a symphony by applying different frequencies..&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;'tone' function will help you for this&lt;/p&gt;&#xA;" OwnerUserId="25643" LastEditorUserId="61440" LastEditDate="2019-12-07T14:42:41.723" LastActivityDate="2019-12-07T14:42:41.723" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="28468" PostTypeId="2" ParentId="28465" CreationDate="2016-08-18T10:24:10.603" Score="0" Body="&lt;p&gt;I made a little algorithm from the first thing that popped into my mind.&#xA;I'm using integers, since I believe it works better as floats.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, you can represent euro's (with floating points) by expressing them in cents.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned int roundToFifty(unsigned int nonRound){&#xA;    unsigned int rest = nonRound % 50;&#xA;    unsigned int fits = floor(nonRound / 50);&#xA;    unsigned int add = 0;&#xA;    if(rest &amp;gt;= 25){&#xA;        if(rest &amp;gt;= 75){&#xA;            add = 100&#xA;        }else{&#xA;            add = 50&#xA;        }&#xA;    }&#xA;    return fits*50+add&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I actually think the algorithm is a tad weird and something simpler/more effective could also exist. It was just the first thing that popped into my mind.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-08-18T10:24:10.603" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28469" PostTypeId="2" ParentId="28465" CreationDate="2016-08-18T10:24:43.483" Score="7" Body="&lt;p&gt;It is a very bad idea to use float.&lt;br&gt;&#xA;That being said. multiply by 2 and do a standard round.&lt;br&gt;&#xA;Then divide back by 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.34     *2 = 2.68&#xA;round(2.68) = 3&#xA;3        /2 = 1.5&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;32.78    *2 = 65.56&#xA;round(65.56)= 66&#xA;66       /2 = 33&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18478" LastEditorUserId="8033" LastEditDate="2016-08-18T10:31:24.440" LastActivityDate="2016-08-18T10:31:24.440" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28470" PostTypeId="2" ParentId="28458" CreationDate="2016-08-18T11:36:58.923" Score="1" Body="&lt;p&gt;You should use &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (digitalRead(ledPin4) == HIGH &amp;amp;&amp;amp; (button_press_9()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (ledPin4 == HIGH &amp;amp;&amp;amp; (button_press_9()))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-18T11:36:58.923" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28471" PostTypeId="1" AcceptedAnswerId="28478" CreationDate="2016-08-18T11:50:14.500" Score="0" ViewCount="1208" Body="&lt;p&gt;I recently wrote the code for this project but it's weird because when I press button on the remote nothing shows up on the Serial Monitor and consequently the robot doesn't respond. I know it's not a hardware issue because when I used the IRrecv Demo sketch values were displayed on the serial monitor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please tell me what's wrong! I'm sure there are a lot of talented programmers out there!!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;IRremote.h&amp;gt;&#xA;#include &amp;lt;AFMotor.h&amp;gt;&#xA;AF_DCMotor rightMotor(1); // Right motor connected to port 1&#xA;AF_DCMotor leftMotor(2); // Left motor connected to port 2&#xA;IRrecv irrecv(A2);// IR receiver connected to pin A2(ANALOG PINS ON MOTOR             SHIELD USED AS DIGITAL INS!)&#xA;decode_results results;&#xA;#define Straight 0xC1CC42BD&#xA;#define Right 0xC1CCA25D&#xA;#define Left 0xC1CC22DD&#xA;#define Back 0xC1CCC23D&#xA;&#xA;void setup(){&#xA;  Serial.begin(9600); // Establishing Serial Communication, THIS IS     IMPORTANT!!&#xA;  irrecv.enableIRIn(); // Start the receiver&#xA;}&#xA;void loop() {&#xA;  if (irrecv.decode(&amp;amp;results))&#xA;  { &#xA;      Serial.println(results.value, HEX);&#xA;&#xA;      if((results.value)== Straight)&#xA;      {&#xA;      moveForward();       &#xA;      } &#xA;      if((results.value)== Right)&#xA;      {&#xA;        turnRight();      &#xA;       }&#xA;      if((results.value)== Left)&#xA;      {&#xA;        turnLeft();      &#xA;      }&#xA;      if((results.value)== Back)&#xA;      {&#xA;        moveBackward();&#xA;      }&#xA;      else &#xA;      {&#xA;        Stop();&#xA;      }&#xA;      irrecv.resume();&#xA;  }&#xA;  delay(100);&#xA;}&#xA;&#xA;void moveForward() {&#xA;&#xA;    leftMotor.setSpeed(255);&#xA;    rightMotor.setSpeed(255);&#xA;    leftMotor.run(FORWARD);&#xA;    rightMotor.run(FORWARD);&#xA;}&#xA;&#xA;void turnRight(){&#xA;&#xA;  leftMotor.setSpeed(200);&#xA;  rightMotor.setSpeed(200);&#xA;  leftMotor.run(FORWARD);&#xA;  rightMotor.run(BACKWARD);&#xA;  delay(400);&#xA;&#xA;  leftMotor.run(FORWARD);&#xA;  rightMotor.run(FORWARD);      &#xA;} &#xA;&#xA;void turnLeft() {&#xA;&#xA;  leftMotor.setSpeed(200);&#xA;  rightMotor.setSpeed(200);&#xA;  leftMotor.run(BACKWARD);&#xA;  rightMotor.run(FORWARD);&#xA;  delay(400);&#xA;&#xA;  leftMotor.run(FORWARD);&#xA;  rightMotor.run(FORWARD);&#xA;}  &#xA;void moveBackward() {&#xA;&#xA;    leftMotor.setSpeed(200);&#xA;    rightMotor.setSpeed(200);&#xA;    leftMotor.run(BACKWARD);&#xA;    rightMotor.run(BACKWARD);&#xA;}&#xA;&#xA;void Stop(){&#xA;    leftMotor.setSpeed(0);&#xA;    rightMotor.setSpeed(0);&#xA;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25870" LastEditorUserId="10394" LastEditDate="2016-08-18T12:25:56.423" LastActivityDate="2016-08-18T15:36:53.677" Title="Problem with code for IR remote controlled robot" Tags="|arduino-uno|programming|ir|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28472" PostTypeId="2" ParentId="28471" CreationDate="2016-08-18T12:36:47.967" Score="0" Body="&lt;p&gt;Try replacing you loop function with this one.  It won't fix it.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() &#xA;{&#xA;    if (irrecv.decode(&amp;amp;results))&#xA;    { &#xA;        Serial.println(results.value, HEX);&#xA;&#xA;        switch (results.value)&#xA;        {&#xA;        case Straight:&#xA;            moveForward();&#xA;            break;&#xA;        case Right:&#xA;            turnRight();&#xA;            break;&#xA;        case Left:&#xA;            turnLeft();&#xA;            break;&#xA;        case Back:&#xA;            moveBackward();&#xA;            break;&#xA;        default:&#xA;            Stop();&#xA;        }&#xA;        irrecv.resume();&#xA;    }&#xA;    else&#xA;    {&#xA;        Serial.println (&quot;Nothing received&quot;);    // This message will annoy you so comment it out as soon as you are happy with what is happening.&#xA;    delay(100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The switch statement is just a neater way of doing your ifs.  The Nothing received message will show you if decode is ever returning.  If it is returning you need to work out why it is returning false, by looking in the library code.  If it isn't returning then you need to look in the library code and see why.  If it is returning, but not giving you an expected value, you need to look in the library code and see why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sorry but from what you describe it seems to be an issue with the library or your use of it, could be anything, but when you can get some more info post it back here.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="972" LastEditDate="2016-08-18T15:09:07.820" LastActivityDate="2016-08-18T15:09:07.820" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28474" PostTypeId="2" ParentId="28424" CreationDate="2016-08-18T14:32:02.237" Score="0" Body="&lt;p&gt;It looks like that display doesn't have a touch screen, only a tft and sd card. The modifications you would need to make pertain only to the SD card and the nonexistent touch screen interface. The tft portion should work with any arduino since it is a bit banged 8 bit parallel interface.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-18T14:32:02.237" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28475" PostTypeId="2" ParentId="23326" CreationDate="2016-08-18T14:43:14.500" Score="-1" Body="&lt;p&gt;It is not a problem in serial connection. I have experienced this problem when I was trying to make a biped robot using 12 servos. It is the programming bug where Arduino does not use its timers properly. You can say that it is arduino limitation.&#xA;There are two main solutions :&#xA;1). Use Raspberry Pi instead of arduino.&#xA;2). Secondly you can make a small servo controlling shield of TLC5940 IC + servo controlling library...  Here is he Link: &lt;a href=&quot;http://bildr.org/2012/03/servos-tlc5940-arduino/&quot; rel=&quot;nofollow&quot;&gt;http://bildr.org/2012/03/servos-tlc5940-arduino/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="20544" LastActivityDate="2016-08-18T14:43:14.500" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28476" PostTypeId="2" ParentId="28456" CreationDate="2016-08-18T15:06:42.497" Score="1" Body="&lt;p&gt;If you don't care much about quality then all you need is two capacitors and a resistor. Use PWM to create the audio (there is a timerpcm pr something library that will do it). The resistor and pne capacitor form a low pass filter for the PWM, and the other capacitor removes the dc offset.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;----/\/\/\----+----||------&#xA;              |&#xA;             ---&#xA;             ---&#xA;              |&#xA;              _&#xA;              -&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-18T15:06:42.497" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28478" PostTypeId="2" ParentId="28471" CreationDate="2016-08-18T15:36:53.677" Score="0" Body="&lt;p&gt;You are using two libraries (&lt;a href=&quot;https://github.com/z3t0/Arduino-IRremote&quot; rel=&quot;nofollow&quot;&gt;Arduino-IRremote&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://github.com/adafruit/Adafruit-Motor-Shield-library&quot; rel=&quot;nofollow&quot;&gt;Adafruit-Motor-Shield-library&lt;/a&gt;) which both use Timer2 on the microcontroller.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The motor library actually changes the setup of timer 2 (see line 92 of AFMotor.cpp) which will disrupt the timing that the IR sensor uses to determine the IR code received.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as I can see, the IR library is using Timer2 only. This means you should be able to change your motors over to port 3 &amp;amp; 4 which use Timer0 instead.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AF_DCMotor rightMotor(3); // Right motor connected to port 3&#xA;AF_DCMotor leftMotor(4); // Left motor connected to port 4&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19409" LastActivityDate="2016-08-18T15:36:53.677" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28479" PostTypeId="1" CreationDate="2016-08-18T16:16:39.137" Score="0" ViewCount="1315" Body="&lt;p&gt;I work on my first arduino car project and i want to turn my servo to a position with a letter input &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code so far&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Servo.h&amp;gt;&#xA;Servo servo;&#xA;&#xA; void setup() {&#xA; Serial.begin(9600);&#xA;pinMode(7,OUTPUT);&#xA;pinMode(8,OUTPUT);&#xA; }&#xA;&#xA; void loop() {&#xA;&#xA; if(Serial.available()&amp;gt;0){&#xA; int  caz=Serial.read();&#xA; switch(caz)&#xA;{&#xA;  case 'w':&#xA;      digitalWrite(8,LOW);&#xA;      digitalWrite(7,HIGH);&#xA;      break;&#xA;  case 's':&#xA;      digitalWrite(7,LOW);&#xA;      digitalWrite(8,HIGH);&#xA;      break;&#xA;  case'd':&#xA;       servo.attach(12);&#xA;       servo.write(0);&#xA;       break;&#xA;  case'a':&#xA;       servo.attach(11);&#xA;       servo.write(180);&#xA;       break;&#xA;   default:&#xA;       digitalWrite(7,LOW);&#xA;       digitalWrite(8,LOW);&#xA;       servo.attach(0);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;when i input 'a' or 'd' it starts turning until i input something else and i want it to stop after 10-30 degree .&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And also i would like to do that to my motor , moving a bit when i input the key.&lt;/p&gt;&#xA;" OwnerUserId="34429" LastActivityDate="2017-01-16T18:39:41.263" Title="How to turn servo to a specific location and then turn over" Tags="|arduino-uno|motor|servo|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28480" PostTypeId="2" ParentId="28479" CreationDate="2016-08-18T16:33:13.903" Score="1" Body="&lt;p&gt;Rather than writing to 180 and 0 write to a variable.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;static const int MovementAmount = 30; //degrees&#xA;int position = 90;  // 90 is the start position.&#xA;...&#xA;case 'd':&#xA;   servo.attach(12);&#xA;   position += MovementAmount;&#xA;   if (position &amp;gt; 180)&#xA;   {&#xA;     position = 180;&#xA;   }&#xA;   servo.write(position);&#xA;   break;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10394" LastEditorUserId="10394" LastEditDate="2016-08-19T12:20:17.153" LastActivityDate="2016-08-19T12:20:17.153" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28481" PostTypeId="1" AcceptedAnswerId="28547" CreationDate="2016-08-18T16:39:58.250" Score="1" ViewCount="13194" Body="&lt;p&gt;I am working on a project where I am trying to send data using HTTP and POST method from my Arduino Mega2560 to a website which I host on localhost. I am living to a students' accommodation and thus, I do not have access to the router. However, I have bought a router and have connected it to the wall via the WAN. Also, the Arduino is connected to one of the ethernet plugs of the router via an Ethernet shield and my laptop to another ethernet plug. I am trying to retrieve the data from the website, but I cannot seem to load them.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Arduino Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;dht.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;dht DHT1;&#xA;int temperatureSensorPin1 = 25;&#xA;&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;EthernetClient client;&#xA;EthernetServer server(80);&#xA;&#xA;long previousMillis = 0;&#xA;unsigned long currentMillis = 0;&#xA;long interval = 250000;&#xA;String data;&#xA;&#xA;long lastUpdate = 0;&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  if(Ethernet.begin(mac) == 0) {&#xA;    Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);&#xA;  }&#xA;&#xA;  data = &quot;&quot;;&#xA;&#xA;  pinMode(temperatureSensorPin1, INPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;&#xA;int temp1 = DHT1.read11(temperatureSensorPin1);&#xA;&#xA;switch (temp1)&#xA;  {&#xA;    case DHTLIB_OK:  &#xA;        Serial.print(&quot;OK,\t&quot;); &#xA;        break;&#xA;    case DHTLIB_ERROR_CHECKSUM: &#xA;        Serial.print(&quot;Checksum error,\t&quot;); &#xA;        break;&#xA;    case DHTLIB_ERROR_TIMEOUT: &#xA;        Serial.print(&quot;Time out error,\t&quot;); &#xA;        break;&#xA;    case DHTLIB_ERROR_CONNECT:&#xA;        Serial.print(&quot;Connect error,\t&quot;);&#xA;        break;&#xA;    case DHTLIB_ERROR_ACK_L:&#xA;        Serial.print(&quot;Ack Low error,\t&quot;);&#xA;        break;&#xA;    case DHTLIB_ERROR_ACK_H:&#xA;        Serial.print(&quot;Ack High error,\t&quot;);&#xA;        break;&#xA;    default: &#xA;        Serial.print(&quot;Unknown error,\t&quot;); &#xA;        break;&#xA;  }&#xA;&#xA;  currentMillis = millis();&#xA;  if(currentMillis - previousMillis &amp;gt; interval) {&#xA;    previousMillis = currentMillis;&#xA;  }&#xA;  String data=&quot;temp1=&quot;+String(DHT1.temperature, 0)+&quot;&amp;amp;temp2=&quot;+String(DHT2.temperature, 0)+&quot;&amp;amp;temp3=&quot;+String(DHT3.temperature, 0)+&quot;&amp;amp;temp4=&quot;+String(DHT4.temperature, 0)+&quot;&amp;amp;temp5=&quot;+String(DHT5.temperature, 0)&#xA;                  +&quot;&amp;amp;hum1=&quot;+String(DHT1.humidity, 0)+&quot;&amp;amp;hum2=&quot;+String(DHT2.humidity, 0)+&quot;&amp;amp;hum3=&quot;+String(DHT3.humidity, 0)+&quot;&amp;amp;hum4=&quot;+String(DHT4.humidity, 0)+&quot;&amp;amp;hum5=&quot;+String(DHT5.humidity, 0)+&quot;&amp;amp;gas=&quot;+gasValue;&#xA;&#xA;  Serial.println(Ethernet.localIP());&#xA;  if(client.connect(&quot;192.168.0.1&quot;, 80)) {&#xA;    client.println(&quot;POST /home/visualisation.php HTTP/1.1&quot;);&#xA;    client.println(&quot;Host:  192.168.0.1&quot;);&#xA;    //client.println(&quot;User-Agent: Arduino/1.0&quot;);&#xA;    //client.println(&quot;Connection: close&quot;);&#xA;    client.println(&quot;Content-Type: application/x-www-form-urlencoded;&quot;);&#xA;    client.print(&quot;Content-Length: &quot;);&#xA;    client.println(data.length());&#xA;    client.println();&#xA;    client.print(data);&#xA;    //Serial.println(data);&#xA;    Serial.println(&quot;We have connection&quot;);&#xA;  }&#xA;&#xA;  if(client.connected()) {    &#xA;    Serial.println(&quot;We have abc&quot;);&#xA;    client.stop();&#xA;  }&#xA;&#xA;  delay(4000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;PHP Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;?php&#xA;$temp1 = &quot;&quot;;&#xA;if(isset($_POST['temp1'])) {&#xA;    $temp1 = $_POST['temp1'];&#xA;}&#xA;echo $temp1;&#xA;?&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FMhoZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Windows ip configuration&lt;/a&gt;&#xA;[Router ip configuration][2]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is the connection that I have made the appropriate one? How should I do it in order to work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;P.S.: I would like to clarify that I do not have an extended knowledge regarding networking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Router ip configuration&lt;/strong&gt;&#xA;&lt;em&gt;LAN&lt;/em&gt;&#xA;MAC Address: 60-E3-27-E7-70-7A&#xA;IP Address: 192.168.0.1&#xA;Subnet Mask: 255.255.255.0&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Wireless&lt;/em&gt;&#xA;Wireless Radio: Enable&#xA;Name (SSID): TP-LINK_707A&#xA;Mode: 11bgn mixed&#xA;Channel Width: Automatic&#xA;Channel: Auto (Current channel 3)&#xA;MAC Address: 60-E3-27-E7-70-7A&#xA;WDS Status: Disable&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;WAN&lt;/em&gt;&#xA;MAC Address: 60-E3-27-E7-70-7B&#xA;IP Address: 100.66.166.2    Dynamic IP&#xA;Subnet Mask: 255.255.255.192&lt;br&gt;&#xA;Default Gateway: 100.66.166.1   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;DNS Server: 77.244.128.44 , 77.244.128.45&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FMhoZ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FMhoZ.png&quot; alt=&quot;Windows ip configuration&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25877" LastActivityDate="2016-08-21T01:25:04.073" Title="POST data from Arduino to website" Tags="|web-server|networking|http|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28482" PostTypeId="1" AcceptedAnswerId="28483" CreationDate="2016-08-18T17:13:54.700" Score="0" ViewCount="146" Body="&lt;p&gt;Well, I hope this question won' t be buried to the dark depths of this forum as my previous q' s:) But I suppose it won' t this time cause it's pretty short without this introduction part...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino pro mini works with 3.3V and in the other hand, I have a DS1307 DIP ic, works with +3V. I was wondering if I could connect the ic to my Arduino directly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thats all. Thanks already:)&lt;/p&gt;&#xA;" OwnerUserId="15789" LastActivityDate="2016-08-18T17:18:38.553" Title="connecting 3.3V to +3V" Tags="|electronics|components|voltage-protection|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28483" PostTypeId="2" ParentId="28482" CreationDate="2016-08-18T17:18:38.553" Score="2" Body="&lt;p&gt;The 3V input on the DS1307 is for a 3V battery, usually a CR2032 or similar. The &lt;em&gt;supply&lt;/em&gt; voltage of the DS1307 is 5V, which means that it won't work with a 3.3V Arduino without a separate supply and level shifter.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-18T17:18:38.553" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28484" PostTypeId="1" CreationDate="2016-08-18T18:09:29.660" Score="0" ViewCount="330" Body="&lt;p&gt;I am using a GeeeTech voice recognition module, I have recorded my voices using CoolTerm, and imported these voice commands in my sketch. However, when I plug in that voice recognition module, an error gets thrown: &lt;code&gt;avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00&lt;/code&gt;; otherwise, it uploads normally. How can the computer and the Arduino lose connection when the voice recognition module gets plugged in? &lt;a href=&quot;https://i.stack.imgur.com/LNtvb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LNtvb.png&quot; alt=&quot;This is the USB that I used to record my commands&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://i.stack.imgur.com/rl7BJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/rl7BJ.png&quot; alt=&quot;This is the Geetech voice recognition module I am using&quot;&gt;&lt;/a&gt;. I have checked my com ports, and checked the everything that it is connected to is correct. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;avr/sleep.h&amp;gt;&#xA;#include &amp;lt;avr/power.h&amp;gt;&#xA;//#include &quot;math.h&quot;&#xA;//This sketch is a metronome, in which each led pin shows one beat.&#xA;/**************************************/&#xA;const int speaker = 13;//speaker at pin 13&#xA;int ts = 6;//highest led pin&#xA;int count = 3;//&quot;beat 1 pin&quot;&#xA;const int keyPin = 11;//button to change time signature&#xA;const int keyPinR = 10;//button to change rhythm&#xA;const int keySwitch = 2;//sleep mode/wake up button&#xA;&#xA;//All pins below use a pull-up resistor, so the states are inverted&#xA;int buttonState = LOW;&#xA;int buttonState2 = LOW;&#xA;int switchState = LOW;&#xA;int silentState = LOW;&#xA;&#xA;int bpm = 120;//you do not need to know this, &#xA;//it's just a variable for the potentialmeter to change the tempo&#xA;int comdata;&#xA;&#xA;int rthm = 1;//rhythm &#xA;int pressed = 0;//&#xA;long silent = 0;&#xA;&#xA;byte com = 0; //reply from voice module&#xA;/**************************************/&#xA;&#xA;void setup()&#xA;{&#xA; Serial.begin(9600);&#xA;&#xA; for(int thisPin = 3;thisPin &amp;lt;= ts;thisPin++)&#xA;  {&#xA;     pinMode(thisPin,OUTPUT); //initialize thisPin as an output&#xA;     pinMode(12, INPUT); //potentialmeter for changing tempo&#xA;&#xA;   //Pin 9 to 11, along with pin 2, are all push buttons with pull-up resistors&#xA;    for(int i = 9; i&amp;lt;=11; i++)&#xA;    {&#xA;      pinMode(i, INPUT);&#xA;      digitalWrite(i, HIGH);&#xA;    }&#xA;    pinMode(2, INPUT);&#xA;    digitalWrite(2,HIGH);&#xA;  }&#xA;delay(2000);&#xA;&#xA;//imported voice commands&#xA;Serial.write(0xAA);&#xA;Serial.write(0x37);&#xA;delay(1000);&#xA;Serial.write(0xAA);&#xA;Serial.write(0x21); &#xA;&#xA; Serial.print(&quot;Type in beats per minute&quot;);&#xA;&#xA;}&#xA;&#xA;/****************************************/&#xA;void loop()&#xA;{&#xA;  turnOn();&#xA;  getTS();&#xA;  getVoiceCommand();&#xA;}&#xA;&#xA;void turnOn()&#xA;{&#xA;    buttonState = digitalRead(keyPin);//key for &#xA;    buttonState2 = digitalRead(keyPinR);&#xA;    switchState = digitalRead(keySwitch);&#xA;    silentState = digitalRead(9);&#xA;&#xA;    if(switchState==LOW) pressed++;&#xA;&#xA;    if(pressed!=0)&#xA;    {&#xA;      sleep_enable();&#xA;      set_sleep_mode(SLEEP_MODE_PWR_DOWN);&#xA;      attachInterrupt(0, interrupt, LOW);&#xA;      sleep_cpu();&#xA;    }&#xA;&#xA;  else{&#xA;    //The beat starts at pin 3, runs in consecutive pins, and ends at pin 8 at maximum&#xA;&#xA;     if(buttonState==LOW){//changing time signature - up to 5 beats&#xA;            ts++; &#xA;          if(ts==8) ts = 3;  //8 - 3 = 5 beats max&#xA;     }&#xA;     if(buttonState2==LOW){//changing rhythm - quarter note to eighth, then &#xA;             //triplets and sixteenths, back to quarter notes&#xA;           rthm++;&#xA;          if(rthm==5) rthm = 1;&#xA;     }&#xA;     if(silentState==LOW) silent++; //if silent key pressed, go to silence (only LED's showing) &#xA;&#xA;      runMetronome();//Run the metronome&#xA;     }&#xA;  }&#xA;&#xA;  void runMetronome(){&#xA;    for(int thisPin = 3;thisPin &amp;lt;= ts;thisPin++)&#xA;      //LED's blinking beats (thisPin - LED pin (beat number + 2))&#xA;      { &#xA;           for(int r = 1; r&amp;lt;=rthm; r++){//nested loop for the rhythm&#xA;               bpm = pulseIn(12, HIGH);//pin 12 - tempo potentialmeter&#xA;               digitalWrite(thisPin,HIGH);//each LED blinks&#xA;               pinMode(13,OUTPUT); //pin 13 - speaker &#xA;&#xA;              silent%2==0 ? noTone(13) : (count==3 &amp;amp;&amp;amp; r==1 ? tone(13,4400,80) : &#xA;                   r==1 ? tone(13,2500,80) : tone(13,2200,60));&#xA;              delay((bpm-52)/rthm);&#xA;              digitalWrite(thisPin,LOW);//turn each off as we proceed to the next beat (LED)&#xA;              pinMode(13,INPUT);//speaker input&#xA;            }&#xA;          count++;//beat++&#xA;&#xA;          if(count&amp;gt;ts) count = 3; //go back to beat 1 &#xA;        }&#xA;    }&#xA;&#xA;&#xA;  void interrupt()  {&#xA;      sleep_disable();        &#xA;      detachInterrupt(0);&#xA;  }&#xA;&#xA;   void getTS(){&#xA;      if(Serial.available()&amp;gt;0){&#xA;          comdata = Serial.read();&#xA;          switch (comdata){&#xA;              case '1': ts = 3; break;&#xA;              case '2': ts = 4; break;&#xA;              case '3': ts = 5; break;&#xA;              case '4': ts = 6; break;&#xA;              case '5': ts = 7; break;&#xA;            }&#xA;     }&#xA;   }&#xA;     void getVoiceCommand(){&#xA;        while(Serial.available()){&#xA;            com = Serial.read();&#xA;            switch(com){&#xA;                case 0x11: ts = 3; break;&#xA;                case 0x12: ts = 4; break;&#xA;                case 0x13: ts = 5; break;&#xA;                case 0x14: ts = 6; break;&#xA;                case 0x15: ts = 7; break;&#xA;              }&#xA;          }&#xA;      }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19210" LastActivityDate="2017-08-15T06:46:35.610" Title="Voice recognition module: avrdude: stk500_getsync(): not in sync: resp=0x00" Tags="|arduino-uno|avrdude|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28485" PostTypeId="2" ParentId="28484" CreationDate="2016-08-18T18:21:47.810" Score="1" Body="&lt;p&gt;It's not loosing connection, there just can't be two devices on the same serial port (I suppose this setup)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use software serial for VR module, arduino with more hardware serials (=mega) or you can use another arduino as ISP programmer.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-18T18:21:47.810" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28486" PostTypeId="1" AcceptedAnswerId="28487" CreationDate="2016-08-18T19:54:51.447" Score="0" ViewCount="1425" Body="&lt;p&gt;I'm trying to program an Arduino MKR1000 and I am using the &lt;code&gt;millis()&lt;/code&gt; function to emulate a traditional timer.  The problem is that any call to &lt;code&gt;millis()&lt;/code&gt; inside the &lt;code&gt;debounceTimer()&lt;/code&gt; function returns the same value.  I only added the &lt;code&gt;Serial.print&lt;/code&gt; to debug.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I left out a decent bit of the code to simplify your reading of it.  It works by waiting for an interrupt on pin 4 which then calls the &lt;code&gt;runTimers()&lt;/code&gt; function and that calls the &lt;code&gt;debounceTimer()&lt;/code&gt; function and within that the &lt;code&gt;millis()&lt;/code&gt; function is called. The &lt;code&gt;debouncetimer()&lt;/code&gt; function keeps getting called until the 10 ms has elapsed and then should end the timer.  The problem is that the &lt;code&gt;millis()&lt;/code&gt; function stops returning a value that goes up.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define doorIntPin 4&#xA;unsigned char sysEnabled = 0;&#xA;unsigned long debounceTimerPlace =0;&#xA;unsigned char debounceTimerOn =0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  attachInterrupt(doorIntPin, doorOpens, LOW);&#xA;  interrupts();&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;}&#xA;void runTimers(){&#xA;  Serial.print('r');&#xA;  while(alarmTimerOn || debounceTimerOn || enablingTimerOn){&#xA;     if(alarmTimerOn)&#xA;      alarmTimer();&#xA;    if(enablingTimerOn)&#xA;      enablingTimer();&#xA;    if(debounceTimerOn)&#xA;      debounceTimer();&#xA;  }&#xA;}&#xA;&#xA;void debounceTimer(){&#xA;  unsigned long time = millis()- debounceTimerPlace;&#xA;  Serial.println(millis() &amp;amp; 0xFFFF, DEC);&#xA;  if(sysEnabled &amp;amp;&amp;amp; time&amp;gt; 10){&#xA;    debounceTimerOn=0;&#xA;  }&#xA;}&#xA;void doorOpens() {&#xA;  Serial.print('o');&#xA;  if(!debounceTimerOn){&#xA;      debounceTimerPlace = millis();&#xA;      debounceTimerOn=1;&#xA;  }&#xA;  runTimers();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I suspect that in the background an interrupt is being called than increments the value &lt;code&gt;millis()&lt;/code&gt; returns and somehow my external interrupt is disabling that.  I don't know why this is happening or how to fix it.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="23700" LastEditorUserId="6936" LastEditDate="2016-12-06T21:57:16.917" LastActivityDate="2016-12-06T21:57:16.917" Title="millis() function always returns same value" Tags="|millis|mkr1000|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28487" PostTypeId="2" ParentId="28486" CreationDate="2016-08-18T20:01:20.283" Score="3" Body="&lt;p&gt;You never exit the ISR, hence all interrupts are disabled. Do the &lt;em&gt;minimum&lt;/em&gt; work possible within an ISR, and have the main loop outside.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-18T20:01:20.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28488" PostTypeId="1" CreationDate="2016-08-18T20:17:13.763" Score="4" ViewCount="8406" Body="&lt;p&gt;I found this &lt;a href=&quot;https://arduino.stackexchange.com/questions/14191/mcp23s17-programming-iodirx-register-works-in-loop-but-not-in-setup&quot;&gt;post&lt;/a&gt; and I am having almost the exact same issue. Nick Gammon (the god of arduino) has an excellent answer but I can't for the life of me implement it myself. I am not an advanced user like the initial question asker.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So What I want to do is use 2 MCP23S17's (&lt;a href=&quot;https://i.stack.imgur.com/XZman.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;picture here&lt;/a&gt;).&#xA;I have been messing with one of them all week and have it reading like a charm. I am using the &lt;a href=&quot;https://github.com/n0mjs710/MCP23S17&quot; rel=&quot;nofollow noreferrer&quot;&gt;githib library&lt;/a&gt; by n0mjs710 to do this. But writing to one will not work. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Along with the zipped library is a few examples. I am trying to read some BCD switches off of one &quot;input MCP&quot; and then display the digits on the &quot;output MCP&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have used external pullups so I did make one change to the code by commenting out the call for pullups. Here is what Doesn't work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;              // We use this library, so it must be called here.&#xA;#include &amp;lt;MCP23S17.h&amp;gt;         // Here is the new class to make using the MCP23S17 easy.&#xA;&#xA;MCP inputchip(1, 10);             // Instantiate an object called &quot;inputchip&quot; on an MCP23S17 device at address 1&#xA;                                  // and slave-select on Arduino pin 10&#xA;MCP outputchip(2, 10);            // Instantiate an object called &quot;outputchip&quot; on an MCP23S17 device at address 2&#xA;                                  // and slave-select on Arduino pin 10&#xA;&#xA;void setup() {&#xA;  inputchip.begin();&#xA;  outputchip.begin();&#xA;  inputchip.pinMode(0xFFFF);     // Use word-write mode to set all of the pins on inputchip to be inputs&#xA;  //inputchip.pullupMode(0xFFFF);  // Use word-write mode to Turn on the internal pull-up resistors.&#xA;  inputchip.inputInvert(0xFFFF); // Use word-write mode to invert the inputs so that logic 0 is read as HIGH&#xA;  outputchip.pinMode(0x0000);    // Use word-write mode to Set all of the pins on outputchip to be outputs&#xA;}&#xA;&#xA;void loop() {&#xA;  int value;                        // declare an integer to hold the value temporarily.&#xA;  value = inputchip.digitalRead();  // read the input chip in word-mode, storing the result in &quot;value&quot;&#xA;  outputchip.digitalWrite(value);   // write the output chip in word-mode, using our variable &quot;value&quot; as the argument&#xA;  // outputchip.digitalWrite(inputchip.digitalRead()); // this one line replaces the three above, and is more efficient&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have tried:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;slowing the SPI bus by changing the library to SPI_Divide the clock by 2&lt;/li&gt;&#xA;&lt;li&gt;changing the ss line and even splitting the lines so one chip uses pin 10 and the other uses pin 9&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;So after reading Mr. Gammon's post I have made some changes to the code attempting to rid myself &lt;strong&gt;&lt;em&gt;of the old slave select pin low trick&lt;/em&gt;&lt;/strong&gt; he mentioned. Here is my attempt:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MCP inputchip(1, 10);             // Instantiate an object called &quot;inputchip&quot; on an MCP23S17 device at address 1&#xA;                                  // and slave-select on Arduino pin 10&#xA;MCP outputchip(2, 9);            // Instantiate an object called &quot;outputchip&quot; on an MCP23S17 device at address 2&#xA;                                  // and slave-select on Arduino pin 10&#xA;int ssPin = 9;&#xA;&#xA;void setup() {&#xA;  pinMode(ssPin,OUTPUT);&#xA;&#xA;  inputchip.begin();&#xA;  digitalWrite(ssPin, HIGH);&#xA;  digitalWrite(ssPin, LOW);&#xA;  outputchip.begin();&#xA;  inputchip.pinMode(0xFFFF);     // Use word-write mode to set all of the pins on inputchip to be inputs&#xA;  //inputchip.pullupMode(0xFFFF);  // Use word-write mode to Turn on the internal pull-up resistors.&#xA;  inputchip.inputInvert(0xFFFF); // Use word-write mode to invert the inputs so that logic 0 is read as HIGH&#xA;  digitalWrite(ssPin, HIGH);&#xA;  digitalWrite(ssPin, LOW);&#xA;  outputchip.pinMode(0x0000);    // Use word-write mode to Set all of the pins on outputchip to be outputs&#xA;}&#xA;&#xA;void loop() {&#xA;  int value;&#xA;  // declare an integer to hold the value temporarily.&#xA;  value = inputchip.digitalRead();  // read the input chip in word-mode, storing the result in &quot;value&quot;&#xA;  digitalWrite(ssPin, HIGH);&#xA;  digitalWrite(ssPin, LOW);&#xA;  outputchip.digitalWrite(value);   // write the output chip in word-mode, using our variable &quot;value&quot; as the argument&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So any advice would be great to get this working. Help me Obi wan Gammon your me only hope. &lt;/p&gt;&#xA;" OwnerUserId="25885" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2018-02-02T10:17:53.333" Title="Arduino MCP23S17 I/O Expander (SPI)" Tags="|arduino-uno|pins|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28490" PostTypeId="1" AcceptedAnswerId="28493" CreationDate="2016-08-18T20:53:26.903" Score="0" ViewCount="981" Body="&lt;p&gt;The MKR1000 is still pretty new and I'm having a hard time getting good information on it. I'm using the Arduino IDE but don't find any functions to sleep the MKR1000. Most libraries I encounter are for AVR chips while the MKR1000 has an ARM chip. I want to put it to sleep until an external interrupt is called. I also use the millis() function, will this function be rendered useless if it goes to sleep?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the data sheet for the ATSAMD21 it talks about the Wait for Interrupt instruction which puts the machine to sleep but it doesn't say how to call the instruction. How can I do this in the Arduino IDE?&lt;/p&gt;&#xA;" OwnerUserId="23700" LastEditorUserId="26916" LastEditDate="2017-09-08T09:41:46.090" LastActivityDate="2017-09-08T09:41:46.090" Title="Powering Down Arduino MKR1000" Tags="|arduino-ide|sleep|mkr1000|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28493" PostTypeId="2" ParentId="28490" CreationDate="2016-08-18T21:35:04.013" Score="0" Body="&lt;p&gt;The &lt;a href=&quot;https://github.com/rocketscream/Low-Power/commit/9692ae155b0395c1a0676c063995cf06fe761203&quot; rel=&quot;nofollow&quot;&gt;rocketscream low power library&lt;/a&gt; looks like it supports the ATSAMD21.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-18T21:35:04.013" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28494" PostTypeId="2" ParentId="21358" CreationDate="2016-08-18T21:41:15.283" Score="2" Body="&lt;p&gt;My Ruggeduino stopped showing up as a serial device under El Capitan (10.11.6). I was able to fix this by installing/updating the VCP drivers for Silicon Labs USB devices available here:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx&quot; rel=&quot;nofollow&quot;&gt;https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After installing the Mac driver the Ruggeduino shows up as SLAB_USBtoUART and works fine with the Arduino GUI.&lt;/p&gt;&#xA;" OwnerUserId="25888" LastActivityDate="2016-08-18T21:41:15.283" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28496" PostTypeId="1" AcceptedAnswerId="28544" CreationDate="2016-08-18T23:42:13.677" Score="1" ViewCount="170" Body="&lt;p&gt;I have an HC-SR04 attached to a servo. When the 90 degree reading is less than 30 cm, I want the motor to take 2 seconds to turn to 130 degrees, get a measurement on the right, and turn back to 90 degrees. My code does not seem to work. Even though I tell it to wait for 2000 ms, it skips directly to the if statement where the turning to 90 degrees is done. Here is the main code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; #include &amp;lt;Servo.h&amp;gt;&#xA;#define trig 22&#xA;#define echo 24&#xA;long duration;&#xA;boolean turned130 = false;&#xA;int cm50, cm, cm130;&#xA;Servo servo;&#xA;boolean checkRight = false;&#xA;boolean mainPing = true;&#xA;unsigned long counter;&#xA;unsigned long servoTimer = millis();&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;Serial.begin(9600);&#xA;pinMode(echo, INPUT);&#xA;pinMode(trig, OUTPUT);&#xA;servo.attach(12);&#xA;servo.write(90);&#xA;delay(2000);&#xA;&#xA;}&#xA;&#xA;void loop(){&#xA;counter=millis();//my timer&#xA;  if(((counter-servoTimer) &amp;gt;= 250) &amp;amp;&amp;amp; mainPing){//distance measured 4 times a second&#xA;    ping();&#xA;    cm=duration/29.1/2;&#xA;    Serial.println(cm);&#xA;    servoTimer=counter;//this if statement works fine&#xA;  }&#xA;  if((cm&amp;lt;30) &amp;amp;&amp;amp; mainPing){&#xA;&#xA;    mainPing=false;//makes the 90 degree ping and this if statement unable to run&#xA;    checkRight = true;//enables next if statement to run&#xA;    servoTimer=millis();&#xA;    servo.write(130);&#xA;    cm=30;//so that this if statement does not get called again until distance is obtained&#xA;    Serial.println(&quot;Inside less than 30 loop&quot;);//I added this for debugging, to let me know when the loop is called&#xA;&#xA;&#xA;  }&#xA;  if(checkRight &amp;amp;&amp;amp; ((counter-servoTimer) &amp;gt;= 2000)){//after 2 seconds passes&#xA;&#xA;    checkRight=false;&#xA;    ping();&#xA;    cm130 = duration/29.1/2;&#xA;    mainPing = true;//enable to other 2 if statements to run&#xA;    servoTimer=millis();&#xA;    Serial.println(cm130);&#xA;    servo.write(90);//turn motor back&#xA;    Serial.println(&quot;Inside other loop&quot;);//for debugging&#xA;&#xA;&#xA;  }&#xA;&#xA;&#xA;&#xA;  delay(2);&#xA;  }&#xA;&#xA;void ping(){&#xA;&#xA;    digitalWrite(trig, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(trig, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(trig, LOW);&#xA;    duration = pulseIn(echo, HIGH);&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is what I got in the Serial monitor:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;25//distance triggers 2nd if statement&#xA;Inside less than 30 loop&#xA;261&#xA;Inside other loop&#xA;13&#xA;Inside less than 30 loop&#xA;14&#xA;Inside other loop&#xA;14&#xA;Inside less than 30 loop&#xA;14&#xA;Inside other loop&#xA;3242&#xA;13&#xA;Inside less than 30 loop&#xA;14&#xA;Inside other loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This all happened within milliseconds. There was no 2 second pause and the servo never turned. What is wrong with my code that prevents the motor from turning and waiting 2 seconds? The order of the Serial messages is correct, but it is happening fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I remove the Serial messages and disconnect from the computer, it kind of works. By that, I mean it turns and waits for 2 seconds 50% of the time. Other times, the servo just shakes a little bit and stops.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another thing I noticed is that if I leave only Serial.println(cm) message and Serial.println(&quot;Inside less than 30 loop&quot;), this is the result that I observe.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    12&#xA;    13&#xA;    Inside less than 30 loop&#xA;&#xA;    15&#xA;    3&#xA;    Inside less than 30 loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For some reason the loop does not get triggered the first time. Is there a possibility that I have a defective Arduino Mega?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested the same setup on an official Arduino Uno and it did not work either. This means that I do not have a broken Arduino. Could the servo motor be broken? That won't explain the Serial messages though.&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-08-20T15:49:37.767" LastActivityDate="2016-08-20T23:58:04.500" Title="How come my code does not wait for a specific time before going into an if statement?" Tags="|arduino-mega|servo|timers|millis|hc-sr04|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28497" PostTypeId="1" AcceptedAnswerId="28617" CreationDate="2016-08-19T00:04:52.847" Score="1" ViewCount="3872" Body="&lt;p&gt;Does any one know how to use Gas Sensor module in Proteus. I wanna use Gas Sensor but I am unable to find it in Proteus. So, does anyone know any way of adding Gas Sensor Library for Proteus software. Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2019-04-07T15:28:17.643" Title="Gas Sensor Library for Proteus" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28499" PostTypeId="1" CreationDate="2016-08-18T21:27:41.947" Score="0" ViewCount="336" Body="&lt;p&gt;My son and I are attempting to connect a TCS230 Color Sensor to an Arduino Nano using the tutorial at TopTechBoy.com (&lt;a href=&quot;http://www.toptechboy.com/arduino/lesson-15-super-cool-arduino-color-sensor-project/&quot; rel=&quot;nofollow&quot;&gt;http://www.toptechboy.com/arduino/lesson-15-super-cool-arduino-color-sensor-project/&lt;/a&gt;) as guidance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seems to be working except that the conversion from pulseIn to RGB used on TopTechBoy is expecting a maximum pulse count of 102,400. Instead I am receiving pulseIn readings with a maximum of 2000.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our Wiring&lt;/p&gt;&#xA;&#xA;&lt;p&gt;S0  - GND&lt;br&gt;&#xA; S1  - 5V &#xA; OE  - No Connection (Tried GND)&lt;br&gt;&#xA; GND - GND&lt;br&gt;&#xA; S2  - D8&lt;br&gt;&#xA; S3  - D7&lt;br&gt;&#xA; OUT - D4&lt;br&gt;&#xA; VCC - 5V&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Our Code: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int S2 = 8;&#xA;int S3 = 7;&#xA;int OUT = 4;&#xA;&#xA;void setup() {&#xA;&#xA;Serial.begin(9600);&#xA;pinMode (S2, OUTPUT);&#xA;pinMode (S3, OUTPUT);&#xA;pinMode (OUT, INPUT);&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;  int red , green, blue; &#xA;&#xA;  red = getRed(); &#xA;  Serial.print(&quot;Red : &quot;); Serial.println(red); &#xA;  Serial.println(&quot;**********************&quot;);&#xA;  Serial.println();&#xA;&#xA;  blue = getBlue(); &#xA;  Serial.print(&quot;Blue : &quot;); Serial.println(blue); &#xA;  Serial.println(&quot;**********************&quot;);&#xA;  Serial.println();&#xA;&#xA;  green = getGreen(); &#xA;  Serial.print(&quot;Green : &quot;); Serial.println(green); &#xA;  Serial.println(&quot;**********************&quot;);&#xA;  Serial.println();&#xA;&#xA;  delay(3000);&#xA;&#xA;}&#xA;&#xA;&#xA;int getRed(void){ return getColor(0, 0, 19000, 24000); }&#xA;&#xA;&#xA;int getGreen(void){return getColor(1, 1, 13600, 19200);}&#xA;&#xA;&#xA;int getBlue(void){return getColor (0, 1, 16400, 21600);}&#xA;&#xA;&#xA;int getColor(int s2Value, int s3Value , int typicalPulseWidth, int maxPulseWidth){&#xA;&#xA;  long divideForScale = typicalPulseWidth / 255 ;&#xA;&#xA;  digitalWrite(S2, s2Value); &#xA;  digitalWrite(S3, s3Value);&#xA;&#xA;  unsigned int pulseWidth = pulseIn(OUT,LOW);&#xA;&#xA;  Serial.print(&quot;Pulse Width : &quot;); Serial.println(pulseWidth);&#xA;&#xA;  unsigned int rColor = pulseWidth / divideForScale ; //401.5686274509804&#xA;  Serial.print(&quot;Response Color - Inverted : &quot;); Serial.println(rColor);&#xA;&#xA;  rColor = 255 - rColor ; &#xA;  Serial.print(&quot;Response Color - Final : &quot;); Serial.println(rColor);&#xA;&#xA;  delay(500);&#xA;&#xA;  return rColor ; &#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The pulses appear correct, just out of scale. Red items produce short Red pulses and so on. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to correct for the shorter pulses by using the Typical Output Frequency (f0) found on page 4 of the data sheet. I'm not sure if this is the right use of this frequency output spec. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.unihedron.com/projects/darksky/tcs230-e33.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.unihedron.com/projects/darksky/tcs230-e33.pdf&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Lowering the max possible pulses per second from 100,400 to around 20,000 gave us a little more variation between RGB values, but still the output is nothing like the expected color.   &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anybody offer some insight as to why the TCS230 pulse count is far fewer than the TTB code expects and what can I do to fix either the pulse count or the scale? Kind regards.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Output from Measuring a Blue RFID Keyfob:&#xA;    divideForScale : 74&#xA;    Pulse Width : 673&#xA;    Response Color - Inverted : 9&#xA;    Respponse Color - Final : 246&#xA;    Red : 246&#xA;    **********************&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;divideForScale : 64&#xA;Pulse Width : 376&#xA;Response Color - Inverted : 5&#xA;Respponse Color - Final : 250&#xA;Blue : 250&#xA;**********************&#xA;&#xA;divideForScale : 53&#xA;Pulse Width : 737&#xA;Response Color - Inverted : 13&#xA;Respponse Color - Final : 242&#xA;Green : 242&#xA;**********************&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25905" OwnerDisplayName="Jordan Reddick" LastEditorUserId="27346" LastEditDate="2018-10-12T21:26:24.820" LastActivityDate="2018-10-12T21:26:24.820" Title="TCS230 Low Pulse Length with Arduino" Tags="|sensors|arduino-nano|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28502" PostTypeId="2" ParentId="28499" CreationDate="2016-08-19T03:47:44.590" Score="0" Body="&lt;p&gt;From the project page (a comment by Marius David) it seems some integer datatypes may not be the same on different platforms. If he is correct, you may be working with a 16 bit pulseWidth while 32 bits are needed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try using an &lt;code&gt;unsigned long&lt;/code&gt; for the &lt;code&gt;pulseWidth&lt;/code&gt; variable.&lt;/p&gt;&#xA;" OwnerUserId="25893" LastActivityDate="2016-08-19T03:47:44.590" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28504" PostTypeId="2" ParentId="28499" CreationDate="2016-08-19T09:42:18.577" Score="1" Body="&lt;p&gt;Connect S0 to 5V to get 100% OUTPUT FREQUENCY SCALING.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently, with S0 LOW and S1 HIGH, you get 2% OUTPUT FREQUENCY SCALING. Which would explain the 50 times to low values you get (100% / 2% = 50).&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-19T09:42:18.577" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28507" PostTypeId="1" AcceptedAnswerId="28509" CreationDate="2016-08-19T11:39:29.600" Score="0" ViewCount="654" Body="&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/NL4YV.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NL4YV.jpg&quot; alt=&quot;Bidirectional logic level converter&quot;&gt;&lt;/a&gt;&#xA;THe product: (&lt;a href=&quot;https://www.sparkfun.com/products/12009&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.sparkfun.com/products/12009&lt;/a&gt;)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So guys, here' s a pretty simple but important question for me:&#xA;Can I convert 3.7V (li-po battery's voltage level) to 5V's (I do have arduino pro mini running on 5 volts) using 3.3v to 5v converter (picture shown above...) ??&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks already...&lt;/p&gt;&#xA;" OwnerUserId="15789" LastEditorUserId="15789" LastEditDate="2016-08-19T11:50:04.757" LastActivityDate="2016-08-19T12:18:34.643" Title="Can I convert 3.7V to 5V's using 3.3v to 5v converter" Tags="|voltage-level|arduino-pro-mini|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28509" PostTypeId="2" ParentId="28507" CreationDate="2016-08-19T12:18:34.643" Score="2" Body="&lt;p&gt;No. That is a level shifter. It uses a low voltage (3.3V) to switch a separate high voltage (5V) supply to create different logic levels.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It does not convert voltage, it merely switches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To create 5V from 3.7V you need either a &lt;em&gt;boost converter&lt;/em&gt; (inductor based circuit) or a &lt;em&gt;charge pump&lt;/em&gt; converter (capacitor based circuit). &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-19T12:18:34.643" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28512" PostTypeId="1" AcceptedAnswerId="28513" CreationDate="2016-08-19T15:16:35.170" Score="0" ViewCount="55" Body="&lt;p&gt;Using &lt;code&gt;RCLib&lt;/code&gt; (&lt;a href=&quot;https://github.com/jantje/ArduinoLibraries/tree/master/RCLib&quot; rel=&quot;nofollow&quot;&gt;github&lt;/a&gt;) I'm getting this error. The trick is that the RCLib &lt;a href=&quot;https://github.com/jantje/ArduinoLibraries/blob/master/RCLib/Examples/Maga6ChanelsA8_A13/Maga6ChanelsA8_A13.ino&quot; rel=&quot;nofollow&quot;&gt;example&lt;/a&gt; works on it's own but does not work in my program (&lt;a href=&quot;https://github.com/jacksonkr/SwatBotSpine&quot; rel=&quot;nofollow&quot;&gt;github&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Serial Output &quot;Error&quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Pin 0 (62) you are trying to use is not supporting interrupts&#xA;Pin 1 (63) you are trying to use is not supporting interrupts&#xA;Pin 2 (64) you are trying to use is not supporting interrupts&#xA;Pin 3 (65) you are trying to use is not supporting interrupts&#xA;Pin 4 (66) you are trying to use is not supporting interrupts&#xA;Pin 5 (67) you are trying to use is not supporting interrupts&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-08-19T15:25:44.467" Title="Pin 0 (62) you are trying to use is not supporting interrupts" Tags="|arduino-mega|interrupt|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28513" PostTypeId="2" ParentId="28512" CreationDate="2016-08-19T15:25:44.467" Score="2" Body="&lt;p&gt;It is quite right. Those pins aren't interrupt pins. What you want to do is make it use &lt;em&gt;PinChange interrupt&lt;/em&gt; pins instead.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This can (by the look of things) be done by including the PinChangeInt.h library before including the RCLib library.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-19T15:25:44.467" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28514" PostTypeId="1" CreationDate="2016-08-19T16:04:45.393" Score="0" ViewCount="162" Body="&lt;p&gt;I am interfacing an LCD with an Arduino. Sometimes it shows nothing after uploading the program. What should I do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/5jVAx.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5jVAx.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25910" LastEditorUserId="14737" LastEditDate="2016-12-18T15:37:29.897" LastActivityDate="2017-01-17T20:04:42.977" Title="Arduino Mega LCD" Tags="|arduino-mega|lcd|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28515" PostTypeId="2" ParentId="28488" CreationDate="2016-08-19T16:08:09.423" Score="2" Body="&lt;p&gt;Majenko's library works. All praise to Majenko &lt;a href=&quot;https://github.com/MajenkoLibraries/MCP23S17&quot; rel=&quot;nofollow&quot;&gt;https://github.com/MajenkoLibraries/MCP23S17&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25885" LastActivityDate="2016-08-19T16:08:09.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28516" PostTypeId="1" CreationDate="2016-08-19T16:49:25.023" Score="5" ViewCount="3396" Body="&lt;p&gt;I'm kind of curious as to why there is a 0.1uF capacitor on this Arduino Pro Mini (&lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino-Pro-Mini-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/uploads/Main/Arduino-Pro-Mini-schematic.pdf&lt;/a&gt;). It seems like it would work just fine without it. &lt;/p&gt;&#xA;" OwnerUserId="26003" OwnerDisplayName="Teague" LastEditorUserId="37523" LastEditDate="2018-07-26T21:48:04.167" LastActivityDate="2018-07-26T21:48:04.167" Title="Why does this Arduino Pro Mini use a capacitor on the DTR reset line?" Tags="|arduino-pro-mini|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="28517" PostTypeId="2" ParentId="28464" CreationDate="2016-08-19T17:34:09.423" Score="0" Body="&lt;p&gt;Try the toneAC library if it is a two pin piezo speaker... It generates weak alternating current, using two arduino pins. Your piezo will last longer. Works like old tone library. Remember to put a 100 ohm resistor in series :)&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-19T17:34:09.423" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28518" PostTypeId="2" ParentId="28514" CreationDate="2016-08-19T17:36:40.613" Score="2" Body="&lt;p&gt;An LCD will show blocks like that if it isn't initialized correctly.  You may have an intermittently-bad connection on one or more of the control lines.  [But see edit 1, below, regarding contrast adjustment.]&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To diagnose intermittent connections, you could run a sketch that repeatedly initializes the LCD and then displays different sets of characters for a few seconds.  This will allow you to wiggle different pins and find out which is responsible for the bad connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To avoid intermittent connections, you could use a shield with soldered pins, or could get multipin shells to replace the single-pin shells of the Dupont-type connectors shown in the photograph.  Having adjacent connectors fixed in a single multipin shell results in more-stable connections.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;Edit 1:&lt;/em&gt; As noted in a comment, blocks appearing on both lines is typical of contrast adjustment problems or missing contrast voltage.  On the other hand,  blocks appearing on just the first line is typical of incorrect  initialization, which could be caused by poor connections or by software errors.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Below is a sketch that repeatedly initializes the LCD and then displays different sets of characters for a few seconds each.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if you don't have  the &lt;code&gt;Streaming.h&lt;/code&gt; &lt;a href=&quot;https://www.arduino.cc/en/Reference/Libraries&quot; rel=&quot;nofollow noreferrer&quot;&gt;contributed library&lt;/a&gt; installed, you can get &lt;a href=&quot;http://arduiniana.org/Streaming/Streaming5.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;code&gt;Streaming5.zip&lt;/code&gt;&lt;/a&gt; from &lt;a href=&quot;http://arduiniana.org/libraries/streaming/&quot; rel=&quot;nofollow noreferrer&quot;&gt;arduiniana.org&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note, if not using an I2C-interfaced LCD, change the included LCD library .h from &lt;code&gt;LiquidCrystal_I2C.h&lt;/code&gt; to whatever is appropriate, and remove I2C-address-related stuff from the sketch.  If you are using an I2C-interfaced LCD on a known fixed address, remove the &lt;code&gt;lcd.setAddress(address);&lt;/code&gt; and &lt;code&gt;lcd.getAddress(address);&lt;/code&gt; stuff.  Those routines are not part of the usual LCD libraries; they probably can be added by subclassing &lt;code&gt;LiquidCrystal_I2C&lt;/code&gt;, but on my system I added code as shown after the sketch.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Screen-test sketch for PCF8574/PCF8574A/PCF8574T I2C LCD Backpack &#xA;Uses library from https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads GNU General Public License, version 3 (GPL-3.0) */&#xA;#include &amp;lt;Streaming.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;LCD.h&amp;gt;&#xA;#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&#xA;&#xA;enum { LCDcols=16, LCDrows=2 };        // # of rows and cols on LCD&#xA;enum { LCDaddr2=0x27, LCDaddr3=0x3F}; // For TI PCF8754 or PCF8754A &#xA;LiquidCrystal_I2C lcd(LCDaddr2,2,1,0,4,5,6,7);&#xA;&#xA;void initLCD(byte address) {&#xA;  byte cdata[8];&#xA;  Serial &amp;lt;&amp;lt; &quot;initLCD(&quot; &amp;lt;&amp;lt; _HEX(address) &amp;lt;&amp;lt; ')' &amp;lt;&amp;lt; endl;&#xA;  lcd.setAddress(address);       // Set LCD I2C address&#xA;  Serial &amp;lt;&amp;lt; &quot;LCD address ... &quot; &amp;lt;&amp;lt; _HEX(lcd.getAddress()) &amp;lt;&amp;lt; endl;&#xA;  // activate LCD module&#xA;  lcd.begin(LCDcols, LCDrows);&#xA;  lcd.setBacklightPin(3,POSITIVE);&#xA;  lcd.setBacklight(HIGH);&#xA;  lcd.noCursor();&#xA;&#xA;  // Load custom characters&#xA;  for (int c=0; c&amp;lt;8; ++c) {&#xA;    unsigned int d = ((c+4)&amp;lt;&amp;lt;12 | (c|3)&amp;lt;&amp;lt;9 | (c|2)&amp;lt;&amp;lt;6 | (c|1)&amp;lt;&amp;lt;3 | c) ^ 0x5555;&#xA;    //Serial &amp;lt;&amp;lt; &quot;c=&quot; &amp;lt;&amp;lt; c &amp;lt;&amp;lt; &quot;  d=&quot; &amp;lt;&amp;lt; _HEX(d) &amp;lt;&amp;lt; endl;&#xA;    for (byte k=0; k&amp;lt;8; ++k)&#xA;      cdata[k] = d &amp;gt;&amp;gt; k;&#xA;    lcd.createChar(c, cdata);&#xA;  }&#xA;  lcd.home ();&#xA;  lcd.print(&quot;Initialized&quot;);&#xA;  delay(1000);&#xA;}&#xA;&#xA;void setup() {&#xA;  Serial.begin(115200);&#xA;  Serial &amp;lt;&amp;lt; &quot;Starting up&quot; &amp;lt;&amp;lt; endl;&#xA;  Wire.begin();                 // Setup to wirescan to check for 8754 addr&#xA;  Serial &amp;lt;&amp;lt; &quot;after Wire.begin()&quot; &amp;lt;&amp;lt; endl;&#xA;  TWBR = 152;  // 50 kHz, use if it works, or use slower rate&#xA;  TWBR = 158;  // 12.5 kHz, = slower rate &#xA;  TWSR |= bit (TWPS0);  // change prescaler&#xA;  Serial &amp;lt;&amp;lt; &quot;after TWBR / TWSR&quot; &amp;lt;&amp;lt; endl;&#xA;  Wire.beginTransmission (LCDaddr2);&#xA;  Serial &amp;lt;&amp;lt; &quot;after Wire.beginTransmission()&quot; &amp;lt;&amp;lt; endl;&#xA;  if (Wire.endTransmission() == 0) // Does 0x27 succeed?&#xA;    initLCD(LCDaddr2);          // Set up with 0x27 address&#xA;  else&#xA;    initLCD(LCDaddr3);          // Set up with 0x3F address&#xA;  Serial &amp;lt;&amp;lt; &quot;after initLCD()&quot; &amp;lt;&amp;lt; endl;&#xA;}&#xA;&#xA;void show(char base, byte delt) {&#xA;  enum {MD=2000};&#xA;  byte k, ro;&#xA;  for (ro=0; ro&amp;lt;LCDrows; ++ro) {&#xA;    lcd.setCursor(0, ro);&#xA;    for (k=0; k&amp;lt;LCDcols; ++k) {&#xA;      lcd.print(base);&#xA;      base += delt;&#xA;    }&#xA;  }&#xA;  if (base==' ') {&#xA;    lcd.setCursor(1, 1);&#xA;    lcd &amp;lt;&amp;lt; &quot;LCD @&quot; &amp;lt;&amp;lt; _HEX(lcd.getAddress()) &amp;lt;&amp;lt; &quot; =&quot; &amp;lt;&amp;lt; lcd.getAddress();&#xA;  }&#xA;  delay(MD);&#xA;}&#xA;&#xA;long p=0;&#xA;void loop() {&#xA;  byte c;&#xA;  Serial &amp;lt;&amp;lt; &quot;Pass &quot; &amp;lt;&amp;lt; p++ &amp;lt;&amp;lt; &quot; on &quot; &amp;lt;&amp;lt; _HEX(lcd.getAddress()) &amp;lt;&amp;lt; &quot; at t=&quot; &amp;lt;&amp;lt; millis() &amp;lt;&amp;lt; endl;&#xA;  lcd.home ();          // Set cursor to 0,0&#xA;  show('#', 0);         // Screen of # characters&#xA;  show(' ', 0);         // Screen of ' ' characters&#xA;  show('@', 0);         // Screen of @ characters&#xA;  show( 0,  1);         // lo specials + ' '...'/'&#xA;  for (c=' '; c &amp;lt; '~'; c+=16)&#xA;    show(c, 1);&#xA;&#xA;  lcd.setBacklight(HIGH);&#xA;  while (Serial.available()) {&#xA;    c = Serial.read();&#xA;    if (c == '2') initLCD(LCDaddr2);&#xA;    if (c == '3') initLCD(LCDaddr3);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;To add &lt;code&gt;lcd.setAddress(address);&lt;/code&gt; and &lt;code&gt;lcd.getAddress(address);&lt;/code&gt; routines:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// add after void setBacklight(...); in LiquidCrystal_I2C.h&#xA;void setAddress(uint8_t addr);&#xA;uint8_t getAddress();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// add after void setBacklight(...); in LiquidCrystal_I2C.cpp&#xA;void LiquidCrystal_I2C::setAddress(uint8_t addr) {&#xA;  LiquidCrystal_I2C::_Addr = addr;&#xA;}&#xA;uint8_t LiquidCrystal_I2C::getAddress() {&#xA;  return LiquidCrystal_I2C::_Addr;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2017-01-17T20:04:42.977" LastActivityDate="2017-01-17T20:04:42.977" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28519" PostTypeId="2" ParentId="28516" CreationDate="2016-08-19T18:00:30.770" Score="7" Body="&lt;p&gt;Most USB to serial chips set the DTR to LOW on connecting, but it keeps it LOW. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This would reset the arduino, but since the DTR never goes HIGH the Arduino will never get out of this reset state, and not run your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The capacitor will AC couple the signal. The the DTR goes low, the other side of the capacitor will go LOW too, but the pull-up resistor will slowly charge the capacitor, till the reset pin is HIGH again. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So it will convert a LOW transition to a LOW pulse.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-19T18:00:30.770" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28520" PostTypeId="1" CreationDate="2016-08-19T18:30:15.917" Score="0" ViewCount="601" Body="&lt;p&gt;I have an ESP8266 module attached to an Arduino Uno that is connected to my local network. On the network, at address 192.168.1.13, I have a nodejs/express server running on port 3000. How would I go about posting an eight digit number from the Arduino to the webserver? In my current attempts the server console isn't receiving any data when using AT+CIPSEND while connected to it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: My Code is as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;     #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 9; // Wire this to Tx Pin of ESP8266&#xA;const byte txPin = 10; // Wire this to Rx Pin of ESP8266&#xA;&#xA;// We'll use a software serial interface to connect to ESP8266&#xA;SoftwareSerial ESP8266 (rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  ESP8266.begin(9600); // Change this to the baudrate used by ESP8266&#xA;  delay(1000); // Let the module self-initialize&#xA;  Serial.println(&quot;Sending an AT command...&quot;);&#xA;  ESP8266.println(&quot;AT+CWMODE=1&quot;);&#xA;  delay(1000);&#xA;  ESP8266.println(&quot;AT+CWJAP=\&quot;username\&quot;,\&quot;pass\&quot;&quot;);&#xA;  delay(10000);&#xA;  ESP8266.println(&quot;AT+CIPMODE=1&quot;);&#xA;  delay(1000);&#xA;  ESP8266.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;192.168.1.13\test\&quot;,3000&quot;);&#xA;  delay(1000);&#xA;  GetData();&#xA;&#xA;}&#xA;void loop() {&#xA; while (ESP8266.available()){&#xA;     String inData = ESP8266.readStringUntil('\n');&#xA;     Serial.println(&quot;Got reponse from ESP8266: &quot; + inData);&#xA;  }&#xA;}&#xA;void GetData(){&#xA;  ESP8266.println(&quot;AT+CIPSEND=4&quot;);&#xA;  ESP8266.print(&quot;test&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and My output is this&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Sending an AT command...&#xA;Got reponse from ESP8266: AT+CWMODE=1&#xA;&#xA;&#xA;Got reponse from ESP8266: &#xA;&#xA;Got reponse from ESP8266: OK&#xA;&#xA;Got reponse from ESP8266: AT+CWJAP=&quot;surveillancevan4&quot;,&quot;7073199495&quot;&#xA;&#xA;&#xA;Got reponse from ESP8266: AT+CIPSEND=4&#xA;&#xA;&#xA;Got reponse from ESP8266: testI&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT 2: I modified my code to this &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA;const byte rxPin = 9; // Wire this to Tx Pin of ESP8266&#xA;const byte txPin = 10; // Wire this to Rx Pin of ESP8266&#xA;// We'll use a software serial interface to connect to ESP8266&#xA;SoftwareSerial ESP8266 (rxPin, txPin);&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  ESP8266.begin(9600); // Change this to the baudrate used by ESP8266&#xA;  ESP8266.println(&quot;AT&quot;);&#xA;  delay(1000);&#xA;  ESP8266.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;192.168.1.13\&quot;,3000&quot;);&#xA;  delay(20000);&#xA;  String request = &quot;POST /test HTTP/1.0 \r\n&quot;;&#xA;  ESP8266.println(&quot;AT+CIPSEND=19&quot;);&#xA;  delay(5000);&#xA;  ESP8266.println(request);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA; while (ESP8266.available()){&#xA;     String inData = ESP8266.readStringUntil('\n');&#xA;     Serial.println(&quot;Got reponse from ESP8266: &quot; + inData);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and now my output claims it posted successfully, but I'm still not seeing any data in my nodejs server. Here is the output:&#xA;Got reponse from ESP8266: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;AT&#xA;&#xA;&#xA;Got reponse from ESP8266: &#xA;&#xA;Got reponse from ESP8266: OK&#xA;&#xA;Got reponse from ESP8266: AT+CIPSTART=&quot;TCP&quot;,&quot;192.168.1.13&quot;,3000&#xA;&#xA;&#xA;Got reponse from ESP8266: CONNECT&#xA;&#xA;Got reponse from ESP8266: &#xA;&#xA;Got reponse from ESP8266: O &#xA;&#xA;&#xA;&#xA;Got reponse from ESP8266: busy sytes&#xA;&#xA;Got reponse from ESP8266: &#xA;&#xA;Got reponse from ESP8266: SEND OK&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I can confirm that it is connecting to my web app because when I run the code on the module without the server running it returns an error.&lt;/p&gt;&#xA;" OwnerUserId="25908" LastEditorUserId="25908" LastEditDate="2019-07-22T23:00:49.590" LastActivityDate="2019-07-22T23:00:49.590" Title="Posting data with ESP8266 module?" Tags="|arduino-uno|esp8266|node.js|" AnswerCount="1" CommentCount="2" ClosedDate="2016-08-20T05:13:38.200" ContentLicense="CC BY-SA 4.0" />
  <row Id="28522" PostTypeId="2" ParentId="28520" CreationDate="2016-08-19T23:34:39.887" Score="0" Body="&lt;pre&gt;&lt;code&gt; ESP8266.println(&quot;AT+CIPSTART=\&quot;TCP\&quot;,\&quot;192.168.1.13\test\&quot;,3000&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That line is going to fail miserably for a number of reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;You need to provide an IP address or domain name - NOT a URL&lt;/li&gt;&#xA;&lt;li&gt;Even if you could provide a URL this bit &lt;code&gt;192.168.1.13\test&lt;/code&gt; would end up, after C escaping, as &lt;code&gt;92.168.1.13        est&lt;/code&gt; since &lt;code&gt;\t&lt;/code&gt; is a TAB character.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;And then on top of all that I assume you are connecting to a HTTP server, yet you aren't sending a HTTP request, you are just sending the word &quot;test&quot;, which the HTTP server has no hope of ever understanding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to formulate and send a proper HTTP request and send it to the server. I suggest you go and look at a few tutorials and maybe look up how HTTP Servers actually operate and what the protocol looks like.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-19T23:34:39.887" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28527" PostTypeId="1" CreationDate="2016-08-20T10:23:23.237" Score="0" ViewCount="22" Body="&lt;p&gt;I took just Arduino Uno board, connected Ethernet Shield to it and compiled Web Server example. And it works. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But it outputs:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;analog input 0 is 1023&#xA;analog input 1 is 1023&#xA;analog input 2 is 789&#xA;analog input 3 is 663&#xA;analog input 4 is 525&#xA;analog input 5 is 449&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why so different values? Shouldn't it be zeros? Is this static electricity or what?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2016-08-20T10:37:34.063" Title="Why so different not connected analog inputs?" Tags="|arduino-uno|analogread|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28528" PostTypeId="2" ParentId="28527" CreationDate="2016-08-20T10:37:34.063" Score="1" Body="&lt;p&gt;Floating inputs, EMI, high input impedance and sample-and-hold capacitor. It can measure anything at this point (usually electro static charge is split between pin capacity and S&amp;amp;H capacitor. It can be used even for touch sense pins...&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-20T10:37:34.063" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28529" PostTypeId="1" AcceptedAnswerId="28531" CreationDate="2016-08-20T11:35:02.470" Score="0" ViewCount="224" Body="&lt;p&gt;I have a simple sketch here that should just blink a led once a second or so (approximately):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean onOff=true;&#xA;int count=0;&#xA;&#xA;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA; }&#xA;&#xA;void loop() {&#xA;    count++;&#xA;    delay(1);&#xA;&#xA;    if (count == 316) { &#xA;    onOff=!onOff;&#xA;    digitalWrite(13, onOff);&#xA;    count=0;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So, if &lt;code&gt;count&lt;/code&gt; is 316 it changes the state of led. It works right now, but it does not without &lt;code&gt;delay()&lt;/code&gt; function or some other complex ones like &lt;code&gt;digitalWrite()&lt;/code&gt; being in the &lt;code&gt;loop()&lt;/code&gt; too. If i am deleting &lt;code&gt;delay()&lt;/code&gt;, than led is just always on. I can feel it is smth about interrupts, but i am not sure. &lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;What am i trying to do here is to make an alternative to &lt;code&gt;delay()&lt;/code&gt; and &lt;code&gt;millis()&lt;/code&gt; for my other project. One of the most needed thing for me is to make ASAP (as soon as possible) &quot;timer&quot;, so that some code could run every 2(3-4...) iterations of loop(). delay() is bad always, and millis() uses &lt;code&gt;long&lt;/code&gt; variable (which is bad for cpu time and ram), and while having problems with ram and cpu time in my project, i want smth lighter for ASAP and other not very precise timing.  So, the questions are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why does my sketch works only with delay(), but does not work&#xA;without it? &lt;/li&gt;&#xA;&lt;li&gt;Why does blinking sketches work with millis(), while they do not use any delay() just like my sketch. &lt;/li&gt;&#xA;&lt;li&gt;Am i a bad person for trying to make smth like an ASAP timer?:)  Is saved ram and cpu time worth of it?  Any other possible problems? &lt;/li&gt;&#xA;&lt;li&gt;Can this sketch be workable without &lt;code&gt;delay()&lt;/code&gt; or other complex or ram and cpu costly functions?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Thank you. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, the sketch up there works indeed, but here is the version that you can can observe with your eyes:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean onOff=1;&#xA;unsigned int counter=0;&#xA;unsigned long time=0;&#xA;&#xA;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;  Serial.begin(57600);&#xA;}&#xA;&#xA;void loop() {&#xA;   if (counter==0)  time=micros();&#xA;    counter++;&#xA;    if (counter == 0) {&#xA;        onOff= !onOff;&#xA;    digitalWrite(13, onOff);&#xA;    Serial.println(micros()-time);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With Serial i was checking delay between blinks, and it is 140164 mcs = 140 ms = 0.14s. But to be honest it feels slower, so please correct me if i can benchmark it in a better way.&lt;/p&gt;&#xA;" OwnerUserId="15007" LastEditorUserId="15007" LastEditDate="2016-08-20T20:38:29.780" LastActivityDate="2016-08-21T01:01:32.130" Title="Sketch does not work without delay() or other complex functions like digitalWrite()" Tags="|interrupt|timers|millis|timing|" AnswerCount="2" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28531" PostTypeId="2" ParentId="28529" CreationDate="2016-08-20T12:19:13.353" Score="1" Body="&lt;p&gt;As majenko answered in the comments, the blinking rate will be so fast you can not see it.&lt;br&gt;&#xA;Also it is possible that without the delay the optimizer removes the whole counting. So increasing the number as proposed by majenko may not even work due to compiler optimisations.&lt;br&gt;&#xA;Using a method based on counters is a very unreliable way to use timings.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Look at the blinkwithout delay example as proposed by Dirk.&lt;br&gt;&#xA;It boils down to using millis() for timing. millis tells you how many millis the arduino is running.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;  // here is where you'd put code that needs to be running all the time.&#xA;&#xA;  // check to see if it's time to blink the LED; that is, if the&#xA;  // difference between the current time and last time you blinked&#xA;  // the LED is bigger than the interval at which you want to&#xA;  // blink the LED.&#xA;  unsigned long currentMillis = millis();&#xA;&#xA;  if (currentMillis - previousMillis &amp;gt;= interval) {&#xA;    // save the last time you blinked the LED&#xA;    previousMillis = currentMillis;&#xA;&#xA;    // if the LED is off turn it on and vice-versa:&#xA;    if (ledState == LOW) {&#xA;      ledState = HIGH;&#xA;    } else {&#xA;      ledState = LOW;&#xA;    }&#xA;&#xA;    // set the LED with the ledState of the variable:&#xA;    digitalWrite(ledPin, ledState);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="18478" LastActivityDate="2016-08-20T12:19:13.353" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28532" PostTypeId="1" CreationDate="2016-08-20T15:15:55.893" Score="0" ViewCount="71" Body="&lt;p&gt;I have a water counter which switches reed on each 10 liters of water. I would like to count these values with Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wrote a program which counts changes from analog input and connected counter between &lt;code&gt;+5V&lt;/code&gt; and analog input. It counts well but I am doubt I connected correctly. Because when reed is opened, then analog input is connected to nothing, while it should be connected to &lt;code&gt;GND&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to implement correct conversion from reed to analog or digital input?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastActivityDate="2016-08-20T15:17:11.970" Title="How to encode resistance change (reed) for Arduino?" Tags="|input|resistor|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28533" PostTypeId="2" ParentId="28532" CreationDate="2016-08-20T15:17:11.970" Score="1" Body="&lt;p&gt;A reed switch is just a button. Treat it as such. Either connect it between a digital input and ground, with a pull-up resistor (internal one would do) or between a digital input and +5V and use a pull-down resistor.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-20T15:17:11.970" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28534" PostTypeId="1" AcceptedAnswerId="28539" CreationDate="2016-08-20T17:47:18.153" Score="0" ViewCount="919" Body="&lt;p&gt;I am working on a project that I am supplying with voltage an LED through a digital pin (26) and I want the LED to be switched off after 4 seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino Mega2560 and I am programming it using Arduino's IDE version 1.6.10. I have installed the SimpleTimer library .zip method but it does not seem to function. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SimpleTimer.h&amp;gt;&#xA;&#xA;SimpleTimer timer;&#xA;&#xA;void setup() {&#xA;pinMode(26, OUTPUT);&#xA;digitalWrite(26, HIGH);&#xA;&#xA;&#xA;timerId = timer.setTimeout(4000, switchOff);&#xA;}&#xA;&#xA;void switchOff() {&#xA;  digitalWrite(26, LOW);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the LED stays just on (&lt;em&gt;digitalWrite(26, HIGH);&lt;/em&gt;) instead of going to the &lt;em&gt;switchOff&lt;/em&gt; function and turning off (&lt;em&gt;digitalWrite(26, LOW);&lt;/em&gt;). I have also tried using Timer1 and Timer libraries but they also do not work. Can someone who has made any of the libraries work, provide me with some guidance?&lt;/p&gt;&#xA;" OwnerUserId="25877" LastActivityDate="2016-08-20T19:11:35.043" Title="Perform function after a period of time" Tags="|arduino-mega|library|digital|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28535" PostTypeId="1" AcceptedAnswerId="28545" CreationDate="2016-08-20T18:14:16.163" Score="0" ViewCount="1193" Body="&lt;p&gt;This is the multi serial example from Arduino IDE&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  // initialize both serial ports:&#xA;  Serial.begin(9600);&#xA;  Serial1.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  // read from port 1, send to port 0:&#xA;  if (Serial1.available()) {&#xA;  // plus do some operations&#xA;    int inByte = Serial1.read();&#xA;    Serial.write(inByte);&#xA;  }&#xA;&#xA;  // read from port 0, send to port 1:&#xA;  if (Serial.available()) {&#xA;    // plus do some operations&#xA;    int inByte = Serial.read();&#xA;    Serial1.write(inByte);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see, the loop is running multiple times doing almost nothing at most of cycles, this will eat up battery life (if it has one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to read when data is available without looping, just like with an interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, is it a good practice to run a loop all the time? Is there any way to sleep? I have seen examples like this one &lt;a href=&quot;http://playground.arduino.cc/Learning/ArduinoSleepCode&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Learning/ArduinoSleepCode&lt;/a&gt; which uses some other pin to wake up. I don't want that. &lt;/p&gt;&#xA;" OwnerUserId="25927" LastEditorUserId="84" LastEditDate="2016-08-20T21:47:28.620" LastActivityDate="2016-08-20T23:12:09.223" Title="Interrupt driven serial in Arduino Mega" Tags="|serial|arduino-mega|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28536" PostTypeId="2" ParentId="28535" CreationDate="2016-08-20T18:34:25.800" Score="1" Body="&lt;p&gt;Why do you not want to sleep the processor? If it's running at all, it doesn't matter whether it is polling the UARTs or executing something else; it will still be using power.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The first several paragraphs of the article you linked to describe putting the processor into low-power mode and reducing the power consumption further by disabling some internal hardware modules. When the UART receives a byte, the processor will wake up and continue execution from where it slept. Isn't that what you are asking for?&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-20T18:34:25.800" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28539" PostTypeId="2" ParentId="28534" CreationDate="2016-08-20T19:11:35.043" Score="1" Body="&lt;p&gt;You have to call &lt;code&gt;timer.run()&lt;/code&gt; inside loop function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SimpleTimer library is more like a scheduler. You call at every so often, and it checks if there is any event that has expired.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-20T19:11:35.043" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28540" PostTypeId="1" AcceptedAnswerId="28978" CreationDate="2016-08-20T19:18:50.920" Score="12" ViewCount="40006" Body="&lt;p&gt;I'm creating a data-logger system which logs data in SD card at a high speed of about 20000-30000 bytes per second. But the SD library in arduino currently writes data at about 4500-5000 bytes per second which is too slow.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've read this &lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/03/25/fast-efficient-data-storage-on-an-arduino/&quot; rel=&quot;noreferrer&quot;&gt;hack to improve the write speed&lt;/a&gt;, but I'm wondering if a more direct approach is possible, maybe by adjusting the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPISettings&quot; rel=&quot;noreferrer&quot;&gt;SPISettings&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="25931" LastActivityDate="2022-03-11T06:49:00.350" Title="How to increase SD card write speed in arduino" Tags="|sd-card|spi|datalogging|baud-rate|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28541" PostTypeId="1" CreationDate="2016-08-20T19:24:47.877" Score="2" ViewCount="51" Body="&lt;p&gt;I am using Arduino Uno. I want to control my room lamp both manually and over the network, so when I switch off my lamp manually, how do I get acknowledgement over the network that lamp is off ?&lt;/p&gt;&#xA;" OwnerUserId="25930" LastEditorDisplayName="user24204" LastEditDate="2016-08-21T01:07:41.210" LastActivityDate="2016-08-21T01:07:41.210" Title="Arduino connection confirmation" Tags="|arduino-uno|relay|" AnswerCount="0" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28544" PostTypeId="2" ParentId="28496" CreationDate="2016-08-20T23:06:16.173" Score="2" Body="&lt;p&gt;I added some more debugging, and I think I have your issues detected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Amended code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;#define trig 22&#xA;#define echo 24&#xA;long duration;&#xA;boolean turned130 = false;&#xA;int cm50, cm, cm130;&#xA;Servo servo;&#xA;boolean checkRight = false;&#xA;boolean mainPing = true;&#xA;unsigned long counter;&#xA;unsigned long servoTimer = millis();&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;  Serial.begin(115200);&#xA;  pinMode(echo, INPUT);&#xA;  pinMode(trig, OUTPUT);&#xA;  servo.attach(12);&#xA;  servo.write(90);&#xA;  delay(2000);&#xA;}&#xA;&#xA;void loop() {&#xA;  counter = millis(); //my timer&#xA;  if (((counter - servoTimer) &amp;gt;= 250) &amp;amp;&amp;amp; mainPing) { //distance measured 4 times a second&#xA;    Serial.print (&quot;Doing ping at time &quot;);&#xA;    Serial.println (counter);&#xA;    ping();&#xA;    cm = duration / 29.1 / 2;&#xA;    Serial.println(cm);&#xA;    servoTimer = counter; //this if statement works fine&#xA;  }&#xA;  if ((cm &amp;lt; 30) &amp;amp;&amp;amp; mainPing) {&#xA;&#xA;    mainPing = false; //makes the 90 degree ping and this if statement unable to run&#xA;    checkRight = true;//enables next if statement to run&#xA;    servoTimer = millis();&#xA;    servo.write(130);&#xA;    cm = 30; //so that this if statement does not get called again until distance is obtained&#xA;    Serial.println(&quot;Inside less than 30 loop&quot;);//I added this for debugging, to let me know when the loop is called&#xA;  }&#xA;  if (checkRight &amp;amp;&amp;amp; ((counter - servoTimer) &amp;gt;= 2000)) { //after 2 seconds passes&#xA;    Serial.print (&quot;counter = &quot;);&#xA;    Serial.println (counter);&#xA;    Serial.print (&quot;servoTimer = &quot;);&#xA;    Serial.println (servoTimer);&#xA;    checkRight = false;&#xA;    ping();&#xA;    cm130 = duration / 29.1 / 2;&#xA;    mainPing = true;//enable to other 2 if statements to run&#xA;    servoTimer = millis();&#xA;    Serial.print (&quot;cm130 = &quot;);&#xA;    Serial.println(cm130);&#xA;    servo.write(90);//turn motor back&#xA;    Serial.println(&quot;Inside other loop&quot;);//for debugging&#xA;  }&#xA;  delay(2);&#xA;}&#xA;&#xA;void ping() {&#xA;  digitalWrite(trig, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trig, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trig, LOW);&#xA;  duration = pulseIn(echo, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With no server (or anything) attached I get this output:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Doing ping at time 1999&#xA;0&#xA;Inside less than 30 loop&#xA;counter = 1999&#xA;servoTimer = 2693&#xA;cm130 = 0&#xA;Inside other loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;First note that &lt;code&gt;servoTimer&lt;/code&gt; is somewhat higher than &lt;code&gt;counter&lt;/code&gt; because the &lt;code&gt;pulseIn&lt;/code&gt; function takes a while to execute (times out after 1 second allegedly, although that was less than a second).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now we come to the problem &quot;if&quot; statement.&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;  if (checkRight &amp;amp;&amp;amp; ((counter - servoTimer) &amp;gt;= 2000)) { //after 2 seconds passes&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That can't be right, eh? &lt;code&gt;counter&lt;/code&gt; is 1999 and &lt;code&gt;servoTimer&lt;/code&gt; is 2693, and there is not 2000 difference. However you are doing the maths the other way:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;counter - servoTimer =  1999 - 2693 = -694&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since we are using &lt;strong&gt;unsigned long&lt;/strong&gt;, it cannot hold negative numbers so the result of the subtraction is 4294966602.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/K1kXn.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/K1kXn.png&quot; alt=&quot;Unsigned long calculation&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That is much larger than 2000, so the &quot;if&quot; branch is taken.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-20T23:58:04.500" LastActivityDate="2016-08-20T23:58:04.500" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28545" PostTypeId="2" ParentId="28535" CreationDate="2016-08-20T23:12:09.223" Score="1" Body="&lt;p&gt;Serial input can wake the processor from sleep, assuming it is useful for it to sleep (for example, if it is battery-powered).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;http://www.gammon.com.au/power&quot; rel=&quot;nofollow&quot;&gt;My page about power&lt;/a&gt; shows various technicques including using serial input to wake it from sleep (see reply #8 on that page). However a disadvantage of that is, it take a few microseconds to wake from sleep - sometimes quite a few - so you are likely to lose the first byte received from serial if you are asleep.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Also, is it a good practice to run a loop all the time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There is no harm, except for battery consumption.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-20T23:12:09.223" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28546" PostTypeId="2" ParentId="28529" CreationDate="2016-08-21T00:19:34.447" Score="0" Body="&lt;p&gt;This sketch blinks an LED on D10 (on a Uno) at one second intervals. It does not use &lt;code&gt;delay&lt;/code&gt;, &lt;code&gt;micros&lt;/code&gt;, &lt;code&gt;millis&lt;/code&gt; or any unsigned long variables (apart from a constant).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;const int STROBE_FREQ = 1000;     // sets the period in milliseconds &#xA;const unsigned long countTo = ((float) F_CPU / 1024.0) / (1000.0 / STROBE_FREQ); &#xA;&#xA;void setup ()&#xA;  {&#xA;  // D10 to output&#xA;  bitSet (DDRB, 2);&#xA;&#xA;  // Fast PWM top at OCR1A&#xA;  TCCR1A = bit (WGM10) | bit (WGM11); // fast PWM&#xA;  TCCR1B = bit (WGM12) | bit (WGM13) | bit (CS12) | bit (CS10);   // fast PWM, prescaler of 1024&#xA;  OCR1A = countTo - 1;                 // zero relative &#xA;  OCR1B = (countTo / 2) - 1;           // 50% duty cycle&#xA;  bitSet (TCCR1A, COM1B1);   // clear OC1B on compare&#xA;  }  // end of setup&#xA;&#xA; void loop ()&#xA;   {&#xA;    // do something useful&#xA;   }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It frees up the main loop to do something useful without worrying about time taken to do the blinking.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For more details see &lt;a href=&quot;http://www.gammon.com.au/timers&quot; rel=&quot;nofollow&quot;&gt;my page about timers&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-21T01:01:32.130" LastActivityDate="2016-08-21T01:01:32.130" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28547" PostTypeId="2" ParentId="28481" CreationDate="2016-08-21T01:25:04.073" Score="0" Body="&lt;p&gt;The ip that I have Arduino send data to is the router's and thus, I should have used the 192.168.0.100 ip which is the one of my computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also needed to save the value to a database to notice the changes because &lt;em&gt;echo $temp1;&lt;/em&gt; did not seem to work, probably I should have it included into HTML &lt;em&gt;label&lt;/em&gt; tags. Anyway, I just loaded the value from the database into a PHP variable and I was able to accomplish the task.&lt;/p&gt;&#xA;" OwnerUserId="25877" LastActivityDate="2016-08-21T01:25:04.073" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28549" PostTypeId="1" AcceptedAnswerId="28556" CreationDate="2016-08-21T01:38:45.950" Score="1" ViewCount="4218" Body="&lt;p&gt;In my current project, I want the sensor to be continuously scanning for a value of less than 30cm. I was wondering how long of a delay I need (if any) between each call of the ping function. It currently works at 150ms between each ping call with no problem. The less the delay, the better for my project. This is the ping function:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void ping() {&#xA;  digitalWrite(trig, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trig, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trig, LOW);&#xA;  duration = pulseIn(echo, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example, would having a delay of only 5ms be sufficient?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastActivityDate="2017-12-08T23:32:17.983" Title="How often can I ping an HC-SR04 ultrasonic sensor?" Tags="|millis|hc-sr04|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28550" PostTypeId="1" AcceptedAnswerId="29121" CreationDate="2016-08-21T02:54:05.430" Score="1" ViewCount="2717" Body="&lt;p&gt;I am building a robot with multiple sensors, abilities etc. Since I had a bug with a HC-SR04 rotated by a servo, I experimented in a different sketch. If the distance is less than 30cm, the servo turns left and right. Since I need continuous readings of other sensors, I cannot use delays so I used millis in order to keep time. The sensor worked correctly in a different sketch, but something in the full one conflicts with it. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;RTClib.h&amp;gt;&#xA;#include &amp;lt;Servo.h&amp;gt;&#xA;#include &amp;lt;IRremote.h&amp;gt;&#xA;&#xA;RTC_DS1307 rtc;&#xA;&#xA;/*const int blue2 = 12;&#xA;const int blue1 = 11;&#xA;const int red1 = 10;&#xA;const int red2 = 9;&#xA;*/&#xA;Servo servo;&#xA;&#xA;&#xA;byte leds[4] = {8, 7, 6, 9};&#xA;&#xA;const int STBY1=45;&#xA;const int ain11=47;&#xA;const int ain12=43;&#xA;const int aPWM1=2;&#xA;const int bin11=41;&#xA;const int bin12=40;&#xA;const int bPWM1=4;&#xA;const int STBY2 = 39;&#xA;const int ain21=33;&#xA;const int ain22=31;&#xA;const int aPWM2=5;&#xA;const int bin21=35;&#xA;const int bin22=37;&#xA;const int bPWM2=3;&#xA;&#xA;&#xA;const int piezo = 32;&#xA;&#xA;const int flamePin = A7;&#xA;&#xA;int flameState;&#xA;&#xA;const int photoResistor = A1;&#xA;&#xA;int photoState;&#xA;&#xA;const int temp = A2;&#xA;&#xA;float temperature;&#xA;&#xA;int ledAnalog;&#xA;&#xA;const int irGnd = 52;&#xA;&#xA;const int irVcc = 50;&#xA;&#xA;const int irSignal = 48;&#xA;&#xA;decode_results results;&#xA;&#xA;IRrecv irrecv(irSignal);&#xA;&#xA;boolean manualLeds = false;&#xA;&#xA;boolean ledsOn = false;&#xA;&#xA;&#xA;unsigned long counter;&#xA;&#xA;unsigned long prevMillis = 0;&#xA;&#xA;int piezoInterval = 200;&#xA;&#xA;int drivingMode = 0;&#xA;&#xA;boolean playPiezo=false;&#xA;&#xA;#define trig 22&#xA;#define echo 24&#xA;long duration;&#xA;boolean turned150 = false;&#xA;int cm30, cm, cm150;&#xA;bool checkLeft = false;&#xA;boolean checkRight = false;&#xA;boolean mainPing = true;&#xA;unsigned long servoTimer = millis();&#xA;&#xA;void setup(){&#xA;  Wire.begin();&#xA;  rtc.begin();&#xA;  pinMode(piezo, OUTPUT);&#xA;pinMode(STBY1, OUTPUT);&#xA;  pinMode(aPWM1, OUTPUT);&#xA;  pinMode(ain11, OUTPUT);&#xA;  pinMode(ain12, OUTPUT);&#xA;  pinMode(bPWM1, OUTPUT);&#xA;  pinMode(bin11, OUTPUT);&#xA;  pinMode(bin12, OUTPUT);&#xA;&#xA;  pinMode(STBY2, OUTPUT);&#xA;  pinMode(aPWM2, OUTPUT);&#xA;  pinMode(ain21, OUTPUT);&#xA;  pinMode(ain22, OUTPUT);&#xA;  pinMode(bPWM2, OUTPUT);&#xA;  pinMode(bin21, OUTPUT);&#xA;  pinMode(bin22, OUTPUT);&#xA;&#xA; servo.attach(12);&#xA; for(int i=0;i&amp;lt;sizeof(leds)/sizeof(leds[0]);i++){&#xA;    pinMode(leds[i], OUTPUT);&#xA; }&#xA;&#xA;  pinMode(flamePin, INPUT);&#xA;  pinMode(photoResistor, INPUT);&#xA;  pinMode(temp, INPUT);&#xA;  pinMode(irGnd, OUTPUT);&#xA;  digitalWrite(irGnd, LOW);&#xA;  pinMode(irVcc, OUTPUT);&#xA;  digitalWrite(irVcc, HIGH);&#xA;  pinMode(irSignal, INPUT);&#xA; Serial.begin(9600);&#xA;  irrecv.enableIRIn();&#xA;  digitalWrite(STBY1, LOW);&#xA;    digitalWrite(STBY2, LOW);&#xA;servo.write(90);&#xA;delay(200);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA; counter=millis();&#xA; //Serial.print(&quot;Millis1: &quot;);&#xA; //Serial.println(millis());&#xA; if(irrecv.decode(&amp;amp;results)){&#xA;    translateIR();&#xA;    irrecv.resume();&#xA;  }&#xA; // Serial.print(&quot;Millis2: &quot;);&#xA; //Serial.println(millis());&#xA;if(drivingMode == 1){&#xA;   if(((counter-servoTimer) &amp;gt;= 150) &amp;amp;&amp;amp; mainPing){&#xA;    ping();&#xA;    cm=duration/29.1/2;&#xA;    Serial.println(cm);&#xA;    counter=millis();&#xA;    servoTimer=counter;&#xA;  }&#xA;  if((cm&amp;lt;30) &amp;amp;&amp;amp; mainPing){&#xA;&#xA;    mainPing=false;&#xA;    checkRight = true;&#xA;    counter=millis();&#xA;    servoTimer=millis();&#xA;    servo.write(150);&#xA;    cm=30;&#xA;&#xA;&#xA;  }&#xA;  if(checkRight &amp;amp;&amp;amp; !checkLeft &amp;amp;&amp;amp; ((counter-servoTimer) &amp;gt;= 170)){&#xA;&#xA;    ping();&#xA;    checkLeft=true;&#xA;    cm150 = duration/29.1/2;&#xA;    counter=millis();&#xA;    servoTimer=millis();&#xA;    servo.write(50);&#xA;  }&#xA;  if(checkRight &amp;amp;&amp;amp; checkLeft &amp;amp;&amp;amp; ((counter-servoTimer) &amp;gt;= 340)){&#xA;  checkRight=false;&#xA;  checkLeft=false;&#xA;  mainPing=true;&#xA;  ping();&#xA;  cm30 = duration/29.1/2;&#xA;  counter=millis();&#xA;  servoTimer=millis();&#xA;  servo.write(90);&#xA;&#xA;  }&#xA;&#xA; }&#xA;&#xA;//getTime();&#xA;//existsFire();&#xA;/*if(!manualLeds){&#xA;readPhoto();&#xA;}*/&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void readPhoto(){&#xA;&#xA;  photoState = analogRead(photoResistor);&#xA;  if(photoState&amp;gt;600){&#xA;    ledAnalog=0;&#xA;  }&#xA;  else if(photoState&amp;lt;300){&#xA;    ledAnalog=255;&#xA;  }&#xA;  else{&#xA;    ledAnalog = 150 - photoState/4;&#xA;  }&#xA;  for(int x = 0;x&amp;lt;sizeof(leds)/sizeof(leds[0]);x++){&#xA;  analogWrite(leds[x], ledAnalog);&#xA;  }&#xA;&#xA;&#xA;}&#xA;&#xA;&#xA;void existsFire(){&#xA;flameState = analogRead(flamePin);&#xA;Serial.println(flameState);&#xA;if(flameState &amp;lt;= 50){&#xA;  static boolean playingBuzzer = true; &#xA;  if(counter - prevMillis &amp;gt; piezoInterval){&#xA;&#xA;     prevMillis = counter;&#xA;     playingBuzzer=!playingBuzzer;&#xA;&#xA;  }&#xA;  if(playingBuzzer){&#xA;&#xA;    digitalWrite(piezo, HIGH);&#xA;&#xA;  }&#xA;  else{&#xA;    digitalWrite(piezo, LOW);&#xA;  }&#xA;&#xA;}&#xA;else if(!playPiezo){&#xA;  digitalWrite(piezo, LOW);&#xA;}&#xA;else if(playPiezo){&#xA;  digitalWrite(piezo, HIGH);&#xA;}&#xA;&#xA;}&#xA;&#xA;void checkTemp(){&#xA;&#xA;  temperature = ((analogRead(temp) / 1024.0 * 5.0) - .5) * 100;&#xA;  Serial.println(temperature);&#xA;&#xA;}&#xA;void ping(){&#xA;&#xA;    digitalWrite(trig, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(trig, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(trig, LOW);&#xA;    duration = pulseIn(echo, HIGH);&#xA;&#xA;}&#xA;void getTime(){&#xA;&#xA;  DateTime now = rtc.now();&#xA;&#xA;  Serial.print(now.year(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.month(), DEC);&#xA;    Serial.print('/');&#xA;    Serial.print(now.day(), DEC);&#xA;    Serial.print(&quot; &quot;);&#xA;    Serial.print(now.hour(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.minute(), DEC);&#xA;    Serial.print(':');&#xA;    Serial.print(now.second(), DEC);&#xA;    Serial.println();&#xA;}&#xA;void forward(){&#xA;digitalWrite(STBY1, HIGH);&#xA;digitalWrite(ain11, HIGH);&#xA;digitalWrite(ain12, LOW);&#xA;analogWrite(aPWM1, 255);&#xA;&#xA;digitalWrite(bin11, LOW);&#xA;digitalWrite(bin12, HIGH);&#xA;analogWrite(bPWM1, 234);&#xA;&#xA;&#xA;digitalWrite(STBY2, HIGH);&#xA;digitalWrite(ain21, LOW);&#xA;digitalWrite(ain22, HIGH);&#xA;analogWrite(aPWM2, 255);&#xA;&#xA;digitalWrite(bin21, LOW);&#xA;digitalWrite(bin22, HIGH);&#xA;analogWrite(bPWM2, 234);&#xA;}&#xA;void backward(){&#xA;&#xA;digitalWrite(STBY1, HIGH);&#xA;digitalWrite(ain11, LOW);&#xA;digitalWrite(ain12, HIGH);&#xA;analogWrite(aPWM1, 255);&#xA;&#xA;digitalWrite(bin11, HIGH);&#xA;digitalWrite(bin12, LOW);&#xA;analogWrite(bPWM1, 235);&#xA;&#xA;&#xA;digitalWrite(STBY2, HIGH);&#xA;digitalWrite(ain21, HIGH);&#xA;digitalWrite(ain22, LOW);&#xA;analogWrite(aPWM2, 255);&#xA;&#xA;digitalWrite(bin21, HIGH);&#xA;digitalWrite(bin22, LOW);&#xA;analogWrite(bPWM2, 235);&#xA;&#xA;&#xA;}&#xA;void left(){&#xA;&#xA;digitalWrite(STBY1, HIGH);&#xA;digitalWrite(ain11, HIGH);&#xA;digitalWrite(ain12, LOW);&#xA;analogWrite(aPWM1, 255);&#xA;&#xA;digitalWrite(bin11, HIGH);&#xA;digitalWrite(bin12, LOW);&#xA;analogWrite(bPWM1, 255);&#xA;&#xA;&#xA;digitalWrite(STBY2, HIGH);&#xA;digitalWrite(ain21, LOW);&#xA;digitalWrite(ain22, HIGH);&#xA;analogWrite(aPWM2, 255);&#xA;&#xA;digitalWrite(bin21, HIGH);&#xA;digitalWrite(bin22, LOW);&#xA;analogWrite(bPWM2, 255);&#xA;&#xA;}&#xA;void right(){&#xA;digitalWrite(STBY1, HIGH);&#xA;digitalWrite(ain11, LOW);&#xA;digitalWrite(ain12, HIGH);&#xA;analogWrite(aPWM1, 255);&#xA;&#xA;digitalWrite(bin11, LOW);&#xA;digitalWrite(bin12, HIGH);&#xA;analogWrite(bPWM1, 255);&#xA;&#xA;&#xA;digitalWrite(STBY2, HIGH);&#xA;digitalWrite(ain21, HIGH);&#xA;digitalWrite(ain22, LOW);&#xA;analogWrite(aPWM2, 255);&#xA;&#xA;digitalWrite(bin21, LOW);&#xA;digitalWrite(bin22, HIGH);&#xA;analogWrite(bPWM2, 255);&#xA;&#xA;&#xA;}&#xA;void brake(){&#xA;&#xA;digitalWrite(STBY1, LOW);&#xA;digitalWrite(ain11, LOW);&#xA;digitalWrite(ain12, LOW);&#xA;analogWrite(aPWM1, 0);&#xA;&#xA;digitalWrite(bin11, LOW);&#xA;digitalWrite(bin12, LOW);&#xA;analogWrite(bPWM1, 0);&#xA;&#xA;&#xA;digitalWrite(STBY2, LOW);&#xA;digitalWrite(ain21, LOW);&#xA;digitalWrite(ain22, LOW);&#xA;analogWrite(aPWM2, 0);&#xA;&#xA;digitalWrite(bin21, LOW);&#xA;digitalWrite(bin22, LOW);&#xA;analogWrite(bPWM2, 0);&#xA;&#xA;}&#xA;void translateIR(){&#xA;//Serial.println(results.value, HEX);&#xA;switch(results.value){&#xA;case 0xFF02FD:&#xA;case 0x20DF22DD:&#xA;//stop(ok)&#xA;if(drivingMode==0){&#xA;brake();&#xA;//Serial.println(&quot;brake&quot;);&#xA;&#xA;}&#xA;break;&#xA;case 0xFF629D:&#xA;case 0x20DF02FD:&#xA;//forward&#xA;if(drivingMode==0){&#xA;forward();&#xA;//Serial.println(&quot;forward&quot;);&#xA;}&#xA;break;&#xA;case 0x20DF827D:&#xA;case 0xFFA857:&#xA;//back&#xA;if(drivingMode==0){&#xA;backward();&#xA;//Serial.println(&quot;back&quot;);&#xA;&#xA;}&#xA;break;&#xA;case 0xFF22DD:&#xA;case 0x20DFE01F:&#xA;//left &#xA;if(drivingMode==0){&#xA;left();&#xA;//Serial.println(&quot;left&quot;);&#xA;}&#xA;break;&#xA;case 0x20DF609F:&#xA;case 0xFFC23D:&#xA;//right&#xA;if(drivingMode==0){&#xA;right();&#xA;//Serial.println(&quot;right&quot;);&#xA;&#xA;}&#xA;break;&#xA;case 0xFF6897:&#xA;case 0x20DF8877:&#xA;if(drivingMode==0){&#xA;  brake();&#xA;  drivingMode=1;&#xA;}&#xA;else{&#xA;  brake();&#xA;  servo.write(90);&#xA;  drivingMode=0;&#xA;}&#xA;//1(switch driving mode)&#xA;break;&#xA;case 0xFF9867:&#xA;case 0x20DF48B7:&#xA;//2(switch led mode)&#xA;if(!manualLeds){&#xA;manualLeds=true;&#xA;    for(int x = 0;x&amp;lt;sizeof(leds)/sizeof(leds[0]);x++){&#xA;  digitalWrite(leds[x], LOW);&#xA;  }&#xA;}&#xA;else{&#xA;manualLeds=false;&#xA;}&#xA;&#xA;break;&#xA;case 0xFFB04F:&#xA;case 0x20DFC837:&#xA;if(manualLeds){&#xA;  if(!ledsOn){&#xA;    for(int x = 0;x&amp;lt;sizeof(leds)/sizeof(leds[0]);x++){&#xA;  digitalWrite(leds[x], HIGH);&#xA;  }&#xA;&#xA;  ledsOn=true;&#xA;  }&#xA;  else{&#xA;       for(int x = 0;x&amp;lt;sizeof(leds)/sizeof(leds[0]);x++){&#xA;  digitalWrite(leds[x], LOW);&#xA;  }&#xA;  ledsOn=false;   &#xA;  }&#xA;}&#xA;//3(toggle leds if mode is on)&#xA;break;&#xA;case 0xFF30CF:&#xA;case 0x20DF28D7:&#xA;//4(play sound)&#xA;playPiezo = !playPiezo;&#xA;&#xA;}&#xA;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;EDIT 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I decided to see what will happen if I start removing code. I removed most of the code that I did not need for this experiment. After the removal, the issue persisted. The sensor is still giving me 0s. This is all the code that was left after I removed stuff:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;//RTC_DS1307 rtc;&#xA;&#xA;/*const int blue2 = 12;&#xA;const int blue1 = 11;&#xA;const int red1 = 10;&#xA;const int red2 = 9;&#xA;*/&#xA;Servo servo;&#xA;&#xA;&#xA;&#xA;unsigned long counter;&#xA;&#xA;unsigned long prevMillis = 0;&#xA;&#xA;int piezoInterval = 200;&#xA;&#xA;int drivingMode = 0;&#xA;&#xA;boolean playPiezo=false;&#xA;&#xA;#define trig 22&#xA;#define echo 24&#xA;long duration;&#xA;boolean turned150 = false;&#xA;int cm30, cm, cm150;&#xA;bool checkLeft = false;&#xA;boolean checkRight = false;&#xA;boolean mainPing = true;&#xA;unsigned long servoTimer = millis();&#xA;&#xA;void setup(){&#xA;&#xA;&#xA; servo.attach(12);&#xA;/* for(int i=0;i&amp;lt;sizeof(leds)/sizeof(leds[0]);i++){&#xA;    pinMode(leds[i], OUTPUT);&#xA; }&#xA;*/&#xA; Serial.begin(9600);&#xA;&#xA;servo.write(90);&#xA;delay(200);&#xA;}&#xA;&#xA;void loop(){&#xA;&#xA; counter=millis();&#xA; //Serial.print(&quot;Millis1: &quot;);&#xA; //Serial.println(millis());&#xA;/* if(irrecv.decode(&amp;amp;results)){&#xA;    translateIR();&#xA;    irrecv.resume();&#xA;  }*/&#xA;//  Serial.print(&quot;Millis2: &quot;);&#xA;&#xA;if(drivingMode == 0){&#xA;   if(((counter-servoTimer) &amp;gt;= 150) &amp;amp;&amp;amp; mainPing){&#xA;    ping();&#xA;    cm=duration/29.1/2;&#xA;    Serial.println(cm);&#xA;    counter=millis();&#xA;    servoTimer=counter;&#xA;  }&#xA;  if((cm&amp;lt;30) &amp;amp;&amp;amp; mainPing){&#xA;&#xA;    mainPing=false;&#xA;    checkRight = true;&#xA;    counter=millis();&#xA;    servoTimer=millis();&#xA;    servo.write(150);&#xA;    cm=30;&#xA;&#xA;&#xA;  }&#xA;  if(checkRight &amp;amp;&amp;amp; !checkLeft &amp;amp;&amp;amp; ((counter-servoTimer) &amp;gt;= 170)){&#xA;&#xA;    ping();&#xA;    checkLeft=true;&#xA;    cm150 = duration/29.1/2;&#xA;    counter=millis();&#xA;    servoTimer=millis();&#xA;    servo.write(50);&#xA;  }&#xA;  if(checkRight &amp;amp;&amp;amp; checkLeft &amp;amp;&amp;amp; ((counter-servoTimer) &amp;gt;= 340)){&#xA;  checkRight=false;&#xA;  checkLeft=false;&#xA;  mainPing=true;&#xA;  ping();&#xA;  cm30 = duration/29.1/2;&#xA;  counter=millis();&#xA;  servoTimer=millis();&#xA;  servo.write(90);&#xA;&#xA;  }&#xA;&#xA; }&#xA;&#xA;//getTime();&#xA;//existsFire();&#xA;/*if(!manualLeds){&#xA;readPhoto();&#xA;}*/&#xA;&#xA;delay(2);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;//}&#xA;void ping(){&#xA;&#xA;    digitalWrite(trig, LOW);&#xA;    delayMicroseconds(2);&#xA;    digitalWrite(trig, HIGH);&#xA;    delayMicroseconds(10);&#xA;    digitalWrite(trig, LOW);&#xA;    duration = pulseIn(echo, HIGH, 24000L);&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe this means that the issue is within this remaining code. Of course I will need all of the code that I removed for the final project, but I was just trying to debug. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made my code a lot more concise since the posted code draft, but the ultrasonic sensor still gives me 0s. I do not understand what can affect its performance as it works fine in my other sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried connecting the sensor to an external 5 volt power source and the same thing happened. The reason for the issue is not because if my power source. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used to have a small delay at the end of my code and I removed that in order to make it run faster. Since pulseIn is blocking for 24ms, the delays do not affect it and it should work normally. But it does not. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, the sensor is giving 0s not because the target is too far away. Even if I put my hand close, it still gives 0s. If I make the cm equal 400 if the duration equals 0, the cm are always 400 regardless of the distance from the sensor. &lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-09-07T21:57:57.400" LastActivityDate="2016-09-10T12:11:06.933" Title="Why does HC-SR04 return 0s in this sketch" Tags="|arduino-mega|servo|sketch|sketch-size|hc-sr04|" AnswerCount="3" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28553" PostTypeId="1" AcceptedAnswerId="28560" CreationDate="2016-08-21T10:06:29.440" Score="0" ViewCount="108" Body="&lt;p&gt;I prefer writing code in Vim, so I'd like to get a workflow going with the Arduino CLI. I used to use &lt;a href=&quot;http://inotool.org&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;ino&lt;/code&gt;&lt;/a&gt;, but I didn't like the restructuring of the project, which meant anyone who downloaded the code having to use &lt;code&gt;ino&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I can build and verify using &lt;code&gt;/Applications/Arduino.app/Contents/MacOS/Arduino --verify MyProject.ino&lt;/code&gt;, which pops up a new instance of the Java IDE, then exits after verifying.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;While this works, and works well, it's incredibly slow. Is there any way to keep the IDE open to save the few seconds lost from the IDE starting again?&lt;/p&gt;&#xA;" OwnerUserId="10675" LastActivityDate="2016-08-21T15:23:38.103" Title="Is there any way to prevent Arduino CLI from closing each time?" Tags="|arduino-ide|command-line|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28554" PostTypeId="1" CreationDate="2016-08-21T10:57:16.787" Score="0" ViewCount="491" Body="&lt;p&gt;I have two DS18B20 temperature sensors connected via a OneWire bus to an arduino. I noticed that these sensors get hot, when permanently powered and decided to just turn them on for measurment.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;First attempt: Define a pin as output and feed the sensors. Because I received only one value (first sensor on bus), I assumed that the current delivered may not be high enough and utilized a transistor (+resistor) as switch for the main 5V line to feed the sensors from the mains (as before). The result is the same. I only get the value of the first sensor. When I connect the sensors directly, I get both values.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried up to 4 seconds delay after switching the bus on and again after reading the values (before switching the bus off again), with no luck. Only the first sensor answers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I have a timing or a current problem here? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring (working): Two DS18B20 in parrallel with a 4,7k resisor between &lt;code&gt;DATA&lt;/code&gt; and &lt;code&gt;VIN&lt;/code&gt;. One Arduino pin used, Sensors directly powered by power-supply (same as arduino)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wiring (not working): Broke the &lt;code&gt;VIN&lt;/code&gt; line and added a transistor as switch between power-supply and sensors &lt;code&gt;VIN&lt;/code&gt;. Used a second pin and a resistor to power up the line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The transistor is a &lt;code&gt;TC124E&lt;/code&gt; (npn) logic level transistor. I have the feeling, that this boy is not providing enough current to the sensors, which in addidtion have five meter cables attached...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE II&lt;/strong&gt;&#xA;It is not the current. I replaced the transistor with a mosfet (70T03H) and the result is exactly the same: When switched, only one sensor answers . When I connect the gate directly to a +5V line, I get both values as expected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Kinda think, that the switching of the pin irritates the bus or the specific device. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE III (Solution)&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tracked this down to a mixture of &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Different resolution settings on the sensors &lt;/li&gt;&#xA;&lt;li&gt;my code not waiting long enough to get the sensor with the higher resolution to setup (on-to-read time). Giving the bus slightly more time to setup before any reading is accepted, solved my problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19013" LastEditorUserId="19013" LastEditDate="2017-05-15T10:32:01.643" LastActivityDate="2017-05-15T10:32:01.643" Title="Weird OneWire bus problem" Tags="|1-wire|ds18b20|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28555" PostTypeId="1" CreationDate="2016-08-21T11:23:13.500" Score="0" ViewCount="447" Body="&lt;p&gt;My task is to use a port extender (MCP23s17) to drive a touch keypad for which I have to define names of pins so that I can call those names in arguments of a function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have searched for different methods to define &quot;PORT EXTENDER&quot; pin but could not find any satisfactory results. Kindly help me handle the situation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i have used the following libraries downloaded from Arduino playground&#xA;1. CapacitiveSensor.h&#xA;2. MCP23S17.h&#xA;Now I have to use MCP23S17 Pin in the following function&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define key1 2&#xA;#define key2 4&#xA;CapacitiveSensor cs_4_2=Capacitivesensor(key2,key1);  //capacitive sensor is connected to pin 4 and 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;key1 and key2 are Arduino's pins. I want some method by which I can refer key1 and key2 to the port extender's (MSP23S17) pin. The above answers are surely helpful but they doesn't fulfill my requirement.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in Advance&#xA;Sorry for English.&lt;/p&gt;&#xA;" OwnerUserId="25944" LastEditorUserId="25944" LastEditDate="2016-08-22T05:14:19.183" LastActivityDate="2017-01-19T08:10:49.053" Title="How can I define a port extender MCP23s17 pin in Arduino" Tags="|arduino-uno|" AnswerCount="3" CommentCount="4" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28556" PostTypeId="2" ParentId="28549" CreationDate="2016-08-21T12:20:28.863" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How often can I ping an HC-SR04 ultrasonic sensor?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This ping() function is vulnerable to interrupts during the pulseIn(). This implies that a delay needs to wait for queued interrupts as from, for instance, Serial output. Input interrupts may still affect the results. This function only works in very simple sketches.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Possible solutions are to 1) disable during the pulse measurement (not the wait for pulse start), 2) use a more advanced method to allow concurrent events (such as timer capture). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers! &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-21T12:20:28.863" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28557" PostTypeId="2" ParentId="28550" CreationDate="2016-08-21T12:54:54.427" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why does the same block of code act differently in different sketches?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are different interrupt sources in the sketches that may affect pulseIn(). Try using a more advanced method to measure the pulse width such as Timer Capture. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-21T12:54:54.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28558" PostTypeId="2" ParentId="28554" CreationDate="2016-08-21T13:07:48.733" Score="1" Body="&lt;p&gt;If you were trying to wire your bus in parasitic mode, here is what I am using:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;OneWire Bus in parasitic mode:&#xA;&#xA;+------------+     +5v            +---------+     +---------+&#xA;|    MCU     |      |             | DS18b20 |     | DS18b20 |&#xA;|            |  R_pu = 4.7K       | g  d +5 |     | g  d +5 |&#xA;| Strong-    |      |             +-o--o--o-+     +-o--o--o-+&#xA;| Pullup   &amp;gt; o------o               |  |  |         |  |  |&#xA;|            |      |               +--|--+         +--|--+&#xA;|            |      |               |  |            |  |&#xA;|    Data &amp;lt;&amp;gt; o------o---------------|--o------------|--o------ - - -&#xA;|            |                      |               |&#xA;+------------+                      V               V&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I run at least three sensors this way on an approximately 6 meter bus, completely reliably.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-21T13:07:48.733" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28559" PostTypeId="2" ParentId="28461" CreationDate="2016-08-21T15:03:46.190" Score="0" Body="&lt;p&gt;Hi~ The synchronized method is below. The function millis() you can refer Arduino.org. It is a function to show you current time. Here I use it to create a time interval to run synchronization.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Declaration the variables are below: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/* Declaration time interval variables for synchronizing pneumaticValve1 and pneumaticValve2. The interval is 1000ms.  */ &#xA;long perviousTimepneumaticValve1 = 0; &#xA;long perviousTimepneumaticValve2 = 0; &#xA;long previousTimeLocal = 0; &#xA;long interval = 1000; &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The loop() function is below: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() { &#xA;checkPneumaticValve1(); &#xA;checkPneumaticValve2(); &#xA;} &#xA;&#xA;void checkPneumaticValve1() { &#xA;  if (millis()-previousTimeLocal&amp;gt;interval) {&#xA;    printPneumaticValve1(); &#xA;    previousTimeLocal=millis();&#xA;   }&#xA; }&#xA;&#xA;void printPneumaticValve1() { &#xA;     //Here write your code for PneumaticValve1&#xA;   }&#xA;&#xA;void checkPneumaticValve2() { &#xA;   if (millis() - previousTimeLocal &amp;gt; interval) {&#xA;     printPneumaticValve2(); &#xA;     previousTimeLocal=millis();&#xA;   }&#xA;  }&#xA;&#xA;void printPneumaticValve2() { &#xA;  //Here write your code for PneumaticValve2 &#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25868" LastEditorDisplayName="user31481" LastEditDate="2017-09-23T10:11:19.423" LastActivityDate="2017-09-23T10:11:19.423" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28560" PostTypeId="2" ParentId="28553" CreationDate="2016-08-21T15:23:38.103" Score="2" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is there any way to prevent Arduino CLI from closing each time?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would suggest working the other way around. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Start the Arduino IDE and set external editor in the Preferences (once).&lt;/li&gt;&#xA;&lt;li&gt;Open the sketch file(s) in the Arduino IDE and VIM. &lt;/li&gt;&#xA;&lt;li&gt;Edit the sketch file(s) in VIM.&lt;/li&gt;&#xA;&lt;li&gt;Move to the Arduino IDE and Verify, Upload, Monitor, etc.&lt;/li&gt;&#xA;&lt;li&gt;Repeat steps 3-4. &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The alternative is to use a make based build system. An example may be found in the &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/tree/master/build/Arduino-Makefile&quot; rel=&quot;nofollow&quot;&gt;Cosa build system for Linux&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: VIM = any external editor such as GNU Emacs, TextEdit, etc. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-21T15:23:38.103" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28561" PostTypeId="2" ParentId="28555" CreationDate="2016-08-21T15:50:51.330" Score="1" Body="&lt;p&gt;If you use this &lt;a href=&quot;http://playground.arduino.cc/Main/MCP23S17#pinMode&quot; rel=&quot;nofollow&quot;&gt;arduino library&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define LED_PIN 15&#xA;&#xA;mcp.pinMode(LED_PIN, LOW); //set led pin on the MCP23S17 to an OUTPUT&#xA;&#xA;mcp.digitalWrite(LED_PIN, LOW)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-21T15:50:51.330" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28562" PostTypeId="1" AcceptedAnswerId="28563" CreationDate="2016-08-21T15:58:20.453" Score="3" ViewCount="1611" Body="&lt;p&gt;It seems like the majority of Arduino applications are written without using classes / objects. Is there a reason for this? Does is slow down the Arduino or somehow present undesirable behavior?&lt;/p&gt;&#xA;" OwnerUserId="19838" LastEditorUserId="4854" LastEditDate="2016-08-22T14:47:07.090" LastActivityDate="2016-08-22T14:47:07.090" Title="OOP vs procedural programming on arduino" Tags="|programming|c++|code-optimization|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28563" PostTypeId="2" ParentId="28562" CreationDate="2016-08-21T16:03:15.073" Score="10" Body="&lt;p&gt;Your assumption is quite wrong:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The majority of libraries use OOP. &lt;/li&gt;&#xA;&lt;li&gt;The majority of in-built device drivers use OOP.&lt;/li&gt;&#xA;&lt;li&gt;The core is filled with many OOP helper objects and classes.&lt;/li&gt;&#xA;&lt;li&gt;99.99% of all sketches use those OOP objects.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;The sketches themselves may not be written as a class or set of classes for a number of reasons:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is no point&lt;/li&gt;&#xA;&lt;li&gt;The programmer doesn't know how&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When a sketch is just stitching together calls to objects defined through libraries and making a few decisions there is little point in making the sketch itself an object. It's just a waste of time.  In general if the sketch gets too complex to manage it gets broken down into smaller units - i.e., libraries - which are very often written as classes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The moment you do &lt;code&gt;Serial.begin(9600);&lt;/code&gt; you are using OOP.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-21T16:03:15.073" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28564" PostTypeId="2" ParentId="28555" CreationDate="2016-08-21T16:06:53.113" Score="1" Body="&lt;p&gt;If you are using &lt;a href=&quot;https://github.com/MajenkoLibraries/MCP23S17&quot; rel=&quot;nofollow&quot;&gt;my library&lt;/a&gt; you can do something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MCP23S17 expander1(&amp;amp;SPI, 10);&#xA;&#xA;#define LED_PIN expander1, 15&#xA;&#xA;void setPin(MCP23S17 &amp;amp;expander, int pin, bool level) {&#xA;    expander.digitalWrite(pin, level);&#xA;}&#xA;&#xA;// ... later ...&#xA;&#xA;setPin(LED_PIN, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-21T16:06:53.113" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28565" PostTypeId="2" ParentId="28550" CreationDate="2016-08-21T16:12:29.053" Score="3" Body="&lt;p&gt;&lt;code&gt;pulseIn()&lt;/code&gt; may block up to &lt;strong&gt;1 second&lt;/strong&gt; (by default), which would happen everytime the &lt;strong&gt;HC-SR04&lt;/strong&gt; receives no echo, which might be the case if ultrasounds do not get properly reflected on a flat surface or if the nearest echoing surface is over ~4 meters away from it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In this situation, not only would &lt;code&gt;pulseIn&lt;/code&gt; block for one second, but it would also return &lt;code&gt;0&lt;/code&gt; to indicate the pin never changed level during that time (which can explain the &lt;strong&gt;0cm distance&lt;/strong&gt; you calculated).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the &lt;strong&gt;HC-SR04&lt;/strong&gt; range is maximum 4 meters, the max ultrasound distance echoed should be then less than 8 meters. Under normal atmospheric conditions, sound propagates at &lt;strong&gt;~340m/s&lt;/strong&gt;, that means in the worst case, i.e. an obstacle found 4 meters away, the sound roundtrip should take less than &lt;strong&gt;8/340s&lt;/strong&gt;, i.e. &lt;strong&gt;~24ms&lt;/strong&gt; rounded up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This shows it is pointless to have &lt;code&gt;pulseIn&lt;/code&gt; wait for 1 second, where 24ms would be enough. To tell &lt;code&gt;pulseIn&lt;/code&gt; to use a shorter timeout, just pass it an extra argument:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;duration = pulseIn(echo, HIGH, 24000L);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that timeout must be expressed in &lt;strong&gt;us&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then, in other parts of your code, before using &lt;code&gt;duration&lt;/code&gt;, you should check that it is not &lt;code&gt;0&lt;/code&gt; (which means no obstacle found less than 4 meters away), for example you might consider in this case the distance is 4 meters (or anything larger).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;E.g. you could replace:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cm150 = duration/29.1/2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;cm150 = duration == 0 ? 400 : duration/29.1/2;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Since this calculation is found several times you should probably create a function for it, that would improve code maintainability and maybe code size as well.&lt;/p&gt;&#xA;" OwnerUserId="84" LastActivityDate="2016-08-21T16:12:29.053" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28566" PostTypeId="1" AcceptedAnswerId="31108" CreationDate="2016-08-21T16:37:23.180" Score="4" ViewCount="10597" Body="&lt;p&gt;I am uploading a test sketch(Blink) to my new Zero(with Wifi101 shield) and when I press Upload in the IDE, the Console says the following:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino: 1.6.10 (Linux), Board: &quot;Arduino/Genuino Zero (Programming Port)&quot;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Open On-Chip Debugger 0.9.0-gd4b7679 (2014-10-03-00:26)&#xA;Licensed under GNU GPL v2&#xA;For bug reports, read&#xA;    http://openocd.org/doc/doxygen/bugs.html&#xA;debug_level: 0&#xA;adapter speed: 500 kHz&#xA;adapter_nsrst_delay: 100&#xA;cortex_m reset_config sysresetreq&#xA;Error: unable to find CMSIS-DAP device&#xA;Error: No Valid JTAG Interface Configured.&#xA;Error: No Valid JTAG Interface Configured.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the Zero programming port.&lt;/p&gt;&#xA;" OwnerUserId="25951" LastEditorUserId="612" LastEditDate="2016-08-21T17:21:41.410" LastActivityDate="2021-01-20T12:58:53.510" Title="Arduino zero Error: unable to find CMSIS-DAP device" Tags="|arduino-ide|arduino-zero|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28567" PostTypeId="1" AcceptedAnswerId="28568" CreationDate="2016-08-21T17:17:30.580" Score="0" ViewCount="63" Body="&lt;p&gt;Just this general question.As the titles says.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How does Arduino decide when to go into flashing mode and normal mode?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it by connecting certain pins to ground,so it's a hardware check or does it have to do with the code?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other similar arduino like products such as the esp8266 work the same way as long as they use the same chip?&lt;/p&gt;&#xA;" OwnerUserId="21061" LastActivityDate="2016-08-21T17:50:14.217" Title="How does Arduino decide when to go into flashing mode and normal mode?" Tags="|esp8266|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28568" PostTypeId="2" ParentId="28567" CreationDate="2016-08-21T17:50:14.217" Score="1" Body="&lt;p&gt;It first runs the bootloader. If there is no data coming into the serial connection within a certain amount, i.e. it's not being programmed, it will exit the bootloader and start the actual sketch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the UNO you will notice a 3 second delay between providing power, and your sketch starting.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-21T17:50:14.217" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28569" PostTypeId="1" CreationDate="2016-08-21T19:15:53.183" Score="0" ViewCount="2611" Body="&lt;p&gt;I'm about identify myself stupid, howcome I couldn' t figure out how to split a string into substring using arduino, even after 10 days of searching. The number is fact... So, As Mr.Arduino.cc says: &lt;em&gt;string&lt;/em&gt;.substring() is just can be used as conditional phrase with loops like if. and there is no method such strtok() like in C can help me with this. So guys, I' m bagging you for help, please!&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (ks &amp;gt; 255 * 60)&#xA;            {&#xA;                    vek.print(&quot;Bu yazı, &quot;, 25, 0);&#xA;                    vek.printNumI(255*60, 25, 8);&#xA;                    vek.print(&quot;karakterd-&quot;, 25, 16);&#xA;                    vek.print(&quot;en uzun ol&quot;, 25, 24);&#xA;                    vek.print(&quot;dugundan&quot;, 25, 32);&#xA;                    vek.print(&quot;gosterlemz&quot;, 25, 40);&#xA;            }&#xA;&#xA;for (byte i = 0; i &amp;lt;= ss ; i ++)&#xA;            {&#xA;                    for (byte j = 0; j &amp;lt;= 6; j++)&#xA;                    {&#xA;                            int ilk_kar = j * 10 + i * 60;&#xA;                            int son_kar = ilk_kar + 10;&#xA;&#xA;                            String yaz=readString.strtok(ilk_kar,son_kar);&#xA;&#xA;                            vek.print(yaz, 25, j);&#xA;&#xA;                            if (analogRead(A5) == 1023)&#xA;                            {&#xA;                                    continue;&#xA;                            }&#xA;                            else&#xA;                            {&#xA;                                    break;&#xA;                            }&#xA;                    }&#xA;            }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Error: sketch_aug22a.ino: In function ‘void loop()’:&#xA;sketch_aug22a.ino:83:56: error: ‘class String’ has no member named ‘strtok’&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What am I supposed to do?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks, already...&lt;/p&gt;&#xA;" OwnerUserId="15789" LastEditorUserId="3917" LastEditDate="2016-08-22T02:55:42.217" LastActivityDate="2016-12-23T18:21:11.930" Title="How to split a string into substring Arduino" Tags="|programming|arduino-ide|sketch|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28570" PostTypeId="2" ParentId="26442" CreationDate="2016-08-21T21:29:47.287" Score="1" Body="&lt;p&gt;Search for UID changeable card. The kit included this RFID reader just had a normal RFID card and keychain. You will probably have to buy it yourself. I bought it from aliexpress but I don' t remember which seller. Good Luck! (I mean who read this...)&lt;/p&gt;&#xA;" OwnerUserId="15789" LastActivityDate="2016-08-21T21:29:47.287" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28571" PostTypeId="2" ParentId="28555" CreationDate="2016-08-21T21:59:37.593" Score="1" Body="&lt;p&gt;There is also the &lt;a href=&quot;https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library&quot; rel=&quot;nofollow&quot;&gt;Adafruit&lt;/a&gt; Library, all do similar things, just in a slightly different way. I use this one, it just depends on which method you are most comfortable with and what your requirements are. Try them all and find out. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;  Serial.begin(9600);  // debugging  &#xA;  mcp.begin();      // use default address 0&#xA;&#xA;      for(int i = 0; i &amp;lt; 6; i++) {&#xA;        mcp.pinMode(trafficLights1[i], OUTPUT);&#xA;      }&#xA;       for(int i = 0; i &amp;lt; 6; i++) { &#xA;        mcp.pinMode(trafficLights2[i], OUTPUT);&#xA;       }&#xA;        for(int i = 0; i &amp;lt; 5; i++) {&#xA;        mcp.pinMode(trafficLights3[i], OUTPUT);&#xA;        }&#xA;  for (int P=0;P&amp;lt;16;P++) {&#xA;    mcp.pullUp(P, HIGH);  // turn on a 100K pullup internally&#xA;    mcp.digitalWrite(P,LOW);&#xA; }&#xA;      mcp.digitalWrite(11, HIGH);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-21T21:59:37.593" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28572" PostTypeId="1" AcceptedAnswerId="28573" CreationDate="2016-08-21T08:13:27.257" Score="1" ViewCount="1558" Body="&lt;p&gt;We are using an Arduino Nano for simple serial comms to fire a relay from a Windows 10 PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Initial issue we had was windows not recognizing the device (COM Port) when the pc is powered off (as per this link: &lt;a href=&quot;https://electronics.stackexchange.com/questions/74123/arduino-nano-usb-not-present-after-rebootn&quot;&gt;Arduino Nano - USB not present after reboot&lt;/a&gt; ) so we powered the arduino nano over a 5V pin and now when Windows starts up the device is recognized.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as I'm learning with these chips, nothing is ever that simple. Now the relay that we are firing does not work with external power, but if you unplug the external power then the relay does fire (powered over USB)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The units are at a mine and at the moment and I believe that the problem is that the serial chip is now not responding as per this - from the official Arduino Nano page:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;The FTDI FT232RL chip on the Nano is only powered if the board is being powered over USB. As a result, when running on external (non-USB) power, the 3.3V output (which is supplied by the FTDI chip) is not available and the RX and TX LEDs will flicker if digital pins 0 or 1 are high.&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note - I included the above from another question but this no longer appears on the official arduino nano page (can't past link as it's my first post)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is how can we get the digital pins on the arduino nano to fire using an external power source and input from a Windows PC?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Diagram:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/zhH2X.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zhH2X.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25960" OwnerDisplayName="onemorecupofcoffee" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-08-22T06:37:06.847" Title="Arduino nano digital pins not working with external power source" Tags="|serial|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28573" PostTypeId="2" ParentId="28572" CreationDate="2016-08-21T11:42:56.883" Score="2" Body="&lt;p&gt;I think you may need to back up and start over again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Rather than changing the power supply, you need to fix the problem that made you think you needed to change power supplies.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Following a link in a comment on the &lt;a href=&quot;https://electronics.stackexchange.com/questions/74123/arduino-nano-usb-not-present-after-rebootn&quot;&gt;question you linked&lt;/a&gt;  to leads to &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=23025.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;this thread on the Arduino forums.&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The suggestion there is that a particular pin on the FTDI chip on the Nano isn't connected as it should be.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To be exact, the Test pin (&lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;pin 26 on the FT232RL chip&lt;/a&gt;) needs to be grounded to fix the original problem you were having with communications with the Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The description there fits your description.  The Nano can't talk to the PC if the Nano is connected to the PC at power on.  The same thing happens with the circuit referenced in that Arduino forum thread, but they are using another embedded system instead of a PC.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you fix that, then you won't need to use an external 5V supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To back up the conclusion from the Arduino forum, here's an excerpt from page 8 (pin descriptions) of the &lt;a href=&quot;http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;FT232RL datasheet:&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;26 TEST   Input  Puts the device into IC test mode. Must be tied to GND&#xA;  for normal operation, otherwise the device will appear to fail&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to connect pins 25 (ground) and pin 26 (Test.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Excerpt from the Nano schematic:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/XaPqA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/XaPqA.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 25 (ground) and 26 (Test) are right next to one another, so easy to fix.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You need to put a blob of solder on the red marked spot in this picture:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ovzQJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ovzQJ.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="10567" OwnerDisplayName="JRE" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-08-21T11:53:18.447" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28574" PostTypeId="1" CreationDate="2016-08-21T22:55:33.407" Score="5" ViewCount="3989" Body="&lt;p&gt;I have this strange problem. My TMP 36 sensor works fine when it is the only thing connected to my Arduino Uno board. The voltage measurements, and thus the temperature, are accurate and consistent. However, when I attach an LCD screen to the Uno and have a program print the TMP's measurements to the screen, the values become inconsistent, and can change up to 10 degrees F from one reading to another. (I have the sensor take a measurement every second.) This does not happen when the LCD screen is not plugged in. I decided to remove separate connectors from the screen and see when the measurements became consistent again. I tried this once and found that a ground wire that goes to connection 5 on the screen caused to value to change when I repeatedly inserted and removed it from a ground pin. The TPM values were changing even when there was nothing else connected to the LCD (it wasn't on) except for the ground wire. I don't understand how this is possible, and I don't know if this is a hardware or software issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I rewired the LCD screen starting with sensor wires, then ground wires, and then the two 5V connections, with one of them having a 220 ohm resistor. I did this while the circuit was powered, and watched the values for any large changes. The first change was a few seconds after I wired the last 5V wire. The sensor measured 80 degrees F and then 85 degrees F one second later. It then went to 81 for a few seconds, then 87. The values continued to change, but not by as much as previous times. By the way, the temperature in the area that the Arduino is in is about 82 degrees F.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;TMP values do not change by more than 3 degrees F when the LCD is not connected to the screen. I don't understand what could be causing this. Has anyone else had this problem before, or know the cause? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is &lt;a href=&quot;http://fritzing.org/projects/tmp-and-lcd&quot; rel=&quot;nofollow noreferrer&quot;&gt;the layout&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&#xA;&#xA;LiquidCrystal lcd(12,11,5,4,3,2);&#xA;const int sensorPin = A5;&#xA;const float baselineTemp = 20.0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sensorVal = analogRead(sensorPin);&#xA;  Serial.print(&quot;Sensor value: &quot;);&#xA;  Serial.print(sensorVal);&#xA;  float voltage = (sensorVal / 1024.0) * 5.0;&#xA;  Serial.print(&quot;, volts: &quot;);&#xA;  Serial.print(voltage);&#xA;  Serial.print(&quot;, degrees C: &quot;);&#xA;  float temperature = (voltage - .5) * 100;&#xA;  Serial.print(temperature);&#xA;  Serial.print(&quot;, degrees F: &quot;);&#xA;  float fahrenheit = (temperature * 1.8 + 32);&#xA;  Serial.println(fahrenheit);&#xA;  delay(1000);&#xA;  lcd.begin(16,2);&#xA;  lcd.print(fahrenheit);&#xA;  lcd.print(&quot; degrees F&quot;);&#xA;  float averageTemp;&#xA;  if(temperature &amp;lt; baselineTemp) {&#xA;    lcd.setCursor(0,1);&#xA;    lcd.print(&quot;Below room temp&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="13748" LastEditorUserId="4628" LastEditDate="2017-09-12T10:37:38.293" LastActivityDate="2018-08-10T19:50:25.683" Title="Why do my temperature sensor values become inconsistent when additional hardware is added to the board?" Tags="|arduino-uno|lcd|temperature-sensor|" AnswerCount="5" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28575" PostTypeId="1" AcceptedAnswerId="28594" CreationDate="2016-08-22T05:14:55.477" Score="2" ViewCount="996" Body="&lt;p&gt;I am wanting to POST some data from Arduino to WebService (written in .NET), intending to save some temperature data to MS SQL Server.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code in arduino is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void PostarDados(String dados, String chamador) {&#xA;  if (client.connect(&quot;mysite.com.br&quot;,80)) {&#xA;    client.println(chamador);&#xA;    client.println(F(&quot;Host: mysite.com.br&quot;));&#xA;    client.println(F(&quot;Content-Type: application/x-www-form-urlencoded&quot;));&#xA;    client.print(F(&quot;Content-Length: &quot;));&#xA;    client.println(dados.length());&#xA;    client.println();&#xA;    client.println(dados);&#xA;  }&#xA;  if (client.connected()) client.stop();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When sending to Serial instead of client, I am obtaining the following text:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;POST /webservice.asmx/SetValoresTempUmidade HTTP/1.1&#xA;Host: mysite.com.br&#xA;Content-Type: application/x-www-form-urlencoded&#xA;Content-Length: 39&#xA;&#xA;Chave=1&amp;amp;Temperatura=23.30&amp;amp;Umidade=42.20&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have enabled HTTP POST in web.config to make HTTP POST possible (I can successfully invoke webservice from browser):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  &amp;lt;location path=&quot;Webservice.asmx&quot;&amp;gt;&#xA;    &amp;lt;system.web&amp;gt;&#xA;      &amp;lt;webServices&amp;gt;&#xA;        &amp;lt;protocols&amp;gt;&#xA;          &amp;lt;add name=&quot;HttpGet&quot;/&amp;gt;&#xA;          &amp;lt;add name=&quot;HttpPost&quot;/&amp;gt;&#xA;        &amp;lt;/protocols&amp;gt;&#xA;      &amp;lt;/webServices&amp;gt;&#xA;    &amp;lt;/system.web&amp;gt;&#xA;  &amp;lt;/location&amp;gt;&#xA;  &amp;lt;system.webServer&amp;gt;&#xA;    &amp;lt;httpProtocol&amp;gt;&#xA;      &amp;lt;customHeaders&amp;gt;&#xA;        &amp;lt;add name=&quot;Access-Control-Allow-Origin&quot; value=&quot;*&quot; /&amp;gt;&#xA;        &amp;lt;add name=&quot;Access-Control-Allow-Headers&quot; value=&quot;Content-Type&quot; /&amp;gt;&#xA;      &amp;lt;/customHeaders&amp;gt;&#xA;    &amp;lt;/httpProtocol&amp;gt;&#xA;  &amp;lt;/system.webServer&amp;gt;&#xA;&amp;lt;/configuration&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I have also set &lt;code&gt;ScriptMethod&lt;/code&gt; to my webservice functions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;WebMethod()&amp;gt; &amp;lt;ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)&amp;gt;&#xA;Public Sub SetValoresTempUmidade(Chave As Integer, ByVal Temperatura As Double, ByVal Umidade As Double)&#xA;    Dim ctx As New DataClassesDataContext&#xA;    Try&#xA;        Dim A As New TBL_DADO&#xA;        A.CHAVE_INICIO = Chave&#xA;        A.DATA = Now&#xA;        A.TEMPERATURA = Temperatura&#xA;        A.UMIDADE = Umidade&#xA;        ctx.TBL_DADOs.InsertOnSubmit(A)&#xA;        ctx.SubmitChanges()&#xA;    Catch ex As Exception&#xA;    End Try&#xA;End Sub&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Finally, I am trying to get some response from server using the following code (not receiving anything):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;while (client.connected()) {&#xA;  while (client.available()) {&#xA;   buffer[counter++] = client.read();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Explained that, I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;What am I doing wrong?&lt;/li&gt;&#xA;&lt;li&gt;How could I debug this?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="280" LastEditorUserId="10394" LastEditDate="2016-08-22T08:00:10.167" LastActivityDate="2016-12-21T00:14:38.657" Title="HTTP Post not working" Tags="|arduino-uno|ethernet|web-service|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28577" PostTypeId="2" ParentId="28572" CreationDate="2016-08-22T06:37:06.847" Score="0" Body="&lt;p&gt;I accepted the answer from JRE as I believe this is the best answer. For certain reasons we weren't able to do this so I've posted this as a workaround.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;We ended up splitting the USB input to the arduino nano by using a Y cable. We used the one end for the power to the device and the other end for comms from the PC (with power disabled). This solved our issue as the chip now received power and responded to comms and the USB driver also initialised correctly on Windows when starting up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you are unable to solder the chip then this is a workaround that we have used.&lt;/p&gt;&#xA;" OwnerUserId="25960" LastActivityDate="2016-08-22T06:37:06.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28578" PostTypeId="2" ParentId="24508" CreationDate="2016-08-22T07:42:54.963" Score="1" Body="&lt;p&gt;In Arduino IDE check that&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;correct port number is selected in Tools -&gt; Port &lt;/li&gt;&#xA;&lt;li&gt;correct programmer is selected in Tools -&gt; Programmer (should be AVRISP mkII if you upload the code via USB cable)&lt;/li&gt;&#xA;&lt;li&gt;correct board is selected in Tools -&gt; Board (Arduino/Genuino Uno)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If above doesn't help, install the latest version of Arduino IDE.&lt;/p&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-22T07:42:54.963" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28579" PostTypeId="2" ParentId="28569" CreationDate="2016-08-22T07:54:42.527" Score="1" Body="&lt;p&gt;Import the &lt;em&gt;string.h&lt;/em&gt; library by adding &lt;code&gt;#include &amp;lt;string.h&amp;gt;&lt;/code&gt; on top of your sketch, in order to use the &lt;code&gt;strtok()&lt;/code&gt; function.&#xA;Checkout the usage example of &lt;code&gt;strtok()&lt;/code&gt; here: &lt;a href=&quot;http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok&quot; rel=&quot;nofollow&quot;&gt;http://www.cplusplus.com/reference/cstring/strtok/?kw=strtok&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="25946" LastEditorUserId="20158" LastEditDate="2016-10-24T15:38:00.227" LastActivityDate="2016-10-24T15:38:00.227" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28580" PostTypeId="1" CreationDate="2016-08-22T09:19:31.880" Score="1" ViewCount="726" Body="&lt;p&gt;i want to use multiple capacitive touch keypads with arduino uno but number of IO ports are not enough. So I decided to use MSP23S17 port extender. Now i have to find some methods to sense the touch keypad without using its library. Can anyone tell me if there is any way to do the task.&lt;/p&gt;&#xA;" OwnerUserId="25944" LastActivityDate="2016-12-21T05:15:45.133" Title="how to use capacitive touch keypad without using CapacitiveSensor.h Library" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28581" PostTypeId="1" CreationDate="2016-08-22T10:04:56.940" Score="1" ViewCount="863" Body="&lt;p&gt;I'm using a max7219 like this one &lt;a href=&quot;http://www.aliexpress.com/item/MAX7219-Dot-Matrix-Module-For-Arduino-Microcontroller-4-In-One-Display-with-5P-Line/32637207300.html?spm=2114.30010308.3.1.1iTpoC&amp;amp;ws_ab_test=searchweb201556_10%2Csearchweb201602_5_10057_10056_10055_10049_10017_10059_10058_10060_10061_10062_412_10063%2Csearchweb201603_7&amp;amp;btsid=7c7446b0-8328-4abd-b0d9-6d20abc0b98a&quot; rel=&quot;nofollow&quot;&gt;max7219&lt;/a&gt;. When I first tested my circuit, I used an 8x8 display and the code worked just fine. Now, after I modified the code and changed the display with the chained one, the text is showing only on the first matrix. I've seen someone that had another problem with the same matrix module, only that in his case the same text was printed on all the matrixes &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=402935.0&quot; rel=&quot;nofollow&quot;&gt;unsolved problem&lt;/a&gt;, in the end he didn't find a solution. Below, I'll attach my code. Please help me find the problem.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;//Pin connected to ST_CP of 74HC595&#xA;int latchPin = 6;&#xA;//Pin connected to SH_CP of 74HC595&#xA;int clockPin = 7;&#xA;////Pin connected to DS of 74HC595&#xA;int dataPin = 5;&#xA;&#xA;int period = 30;&#xA;&#xA;byte rotl(byte n, byte b)&#xA;{&#xA;  return (n &amp;lt;&amp;lt; b) | (n &amp;gt;&amp;gt; (8 - b));&#xA;}&#xA;&#xA;byte X[] {&#xA;&#xA;0x80,&#xA;0x80,&#xA;0x80,   //L&#xA;0x80,&#xA;0x80,&#xA;0x80,&#xA;0x80,&#xA;0xFF,&#xA;&#xA;/*0x10,&#xA;0x00,&#xA;0x10, //I&#xA;0x10,&#xA;0x10,&#xA;0x10,&#xA;0x10,&#xA;0x10,&#xA;&#xA;0XF0,&#xA;0x90,&#xA;0x80, //C&#xA;0x80,&#xA;0x80,&#xA;0x80,&#xA;0x90,&#xA;0xF0,&#xA;&#xA;0xF0,&#xA;0x09,&#xA;0x09,&#xA;0x09,&#xA;0x09,&#xA;0x09, //A&#xA;0x09,&#xA;0xF0*/&#xA;&#xA;};&#xA;&#xA;void setup() {&#xA;  //set pins to output so you can control the shift register&#xA;  pinMode(latchPin, OUTPUT);&#xA;  pinMode(clockPin, OUTPUT);&#xA;  pinMode(dataPin, OUTPUT);&#xA;}&#xA;&#xA;void loop() &#xA;{&#xA;  for (int i = 0; i &amp;lt; 8; i++)&#xA;  {&#xA;    X[i] = rotl(X[i], 1);&#xA;  }&#xA;  for(int i = period;i&amp;gt;0;i--)&#xA;  {&#xA;    displayX();&#xA;  }&#xA;&#xA;}&#xA;&#xA;void DisplayMatrix(byte numCol, byte numLine)&#xA;{&#xA;  byte numberToDisplay1 = numCol;  &#xA;  byte numberToDisplay2 = numLine;  &#xA;&#xA;&#xA;  digitalWrite(latchPin, LOW);&#xA;  shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay1);  &#xA;  shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay2);  &#xA;  digitalWrite(latchPin, HIGH);&#xA;  delay(1);&#xA;&#xA;}&#xA;&#xA;void displayX()&#xA;{&#xA;   DisplayMatrix(X[0],1);&#xA;   DisplayMatrix(X[1],2);&#xA;   DisplayMatrix(X[2],4);&#xA;   DisplayMatrix(X[3],8);&#xA;   DisplayMatrix(X[4],16);&#xA;   DisplayMatrix(X[5],32);&#xA;   DisplayMatrix(X[6],64);&#xA;   DisplayMatrix(X[7],128);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25961" LastActivityDate="2016-08-22T13:14:38.847" Title="max7219 chained display showing text only on the first display" Tags="|arduino-uno|c|max7219|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28582" PostTypeId="1" CreationDate="2016-08-22T12:50:30.967" Score="1" ViewCount="1846" Body="&lt;p&gt;I am having an Arduino Uno and a C2042A LCD with I2C shield on it. Because the VirtualWire library does not work for me. I tried only the wire library but it's still not working:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Wire.begin(0x63);&#xA;}&#xA;&#xA;void loop() {&#xA;  Wire.write(4);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I just read on &lt;a href=&quot;http://www.robot-electronics.co.uk/htm/Lcd03tech.htm&quot; rel=&quot;nofollow noreferrer&quot;&gt;this website&lt;/a&gt; which commands you have to use but it doesn't do anything. What is my fault, how to solve it?&lt;/p&gt;&#xA;" OwnerUserId="25779" LastEditorUserId="4628" LastEditDate="2017-05-29T09:59:02.837" LastActivityDate="2017-05-29T09:59:02.837" Title="Arduino Wire.h library: how to communicate with an LCD?" Tags="|i2c|lcd|wire-library|" AnswerCount="3" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28584" PostTypeId="2" ParentId="28574" CreationDate="2016-08-22T13:14:09.873" Score="3" Body="&lt;p&gt;Don't take power for LCD from Uno pins. Connect LCD power to separate power source.&lt;/p&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-22T13:14:09.873" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28585" PostTypeId="2" ParentId="28581" CreationDate="2016-08-22T13:14:38.847" Score="3" Body="&lt;p&gt;Communicating with more than one MAX7219 chip when cascaded involves sending data to all the chips at once. You have to treat the cascaded sequence of chips as a single entity - an entire display in its own right.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With one chip you send an 8-bit register value followed by an 8-bit data value. To use two chips you have to send twice that - an 8-bit register and 8-bit data for the second chip, followed by an 8-bit register and 8-bit data for the first chip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The chips have a &quot;NO-OP&quot; register (0x00) which can be used to ensure that nothing is done on that chip if you don't want to change anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So setting line 3 to 0x55 on the first display, and line 5 to 0xAA on the second display you would send the sequence &lt;code&gt;\ 0x05,0xAA,0x03,0x55 /&lt;/code&gt; as a single transaction (lower CS &lt;code&gt;\&lt;/code&gt; before, raise it &lt;code&gt;/&lt;/code&gt; afterwards).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you only wanted to set line 2 on the second display to 0x69 you would send the sequence: &lt;code&gt;\ 0x02,0x69,0x00,0x00 /&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For three chips you need to send three blocks of 8+8 values. For four chips, 4 blocks of 8+8. Etc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that it is important to send enough data for &lt;em&gt;all&lt;/em&gt; the chips - you can't shortcut and only send data for the first display if that is all you want to talk to, since whatever is currently in the first display's shift register will get sent out to successive chips, and you will get the display duplication as seen in the other question.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-22T13:14:38.847" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28586" PostTypeId="2" ParentId="28582" CreationDate="2016-08-22T13:54:34.983" Score="0" Body="&lt;p&gt;The documentation under the link you posted says: &quot;The I2C display is located on the I2C bus at an address of 0XC6.&quot;, not the address you have used in your code.&lt;/p&gt;&#xA;" OwnerUserId="24400" LastActivityDate="2016-08-22T13:54:34.983" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28587" PostTypeId="1" AcceptedAnswerId="28588" CreationDate="2016-08-22T14:01:35.697" Score="0" ViewCount="133" Body="&lt;p&gt;Can uncompressed MP3 audio data be sent from Arduino board, by SPI, to Adafruit Music Maker shield instead of from the SD card on the Music Maker?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead of using SD card on Music Maker board, I want to send the compressed MP3 data from a Particle Photon board on the Particle shield shield, by SPI, to the VS1053B codec chip on Music Maker board, and then to amplifier for speakers.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Particle Shield Shield is attached to Particle Photon board, which has STM32F205RGY6 120Mhz ARM Cortex M3.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Particle Photon board uses its WiFi to receive uncompressed MP3.&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-08-22T14:15:00.700" Title="Can MP3 be sent to SPI of Adafruit Music Maker Arduino shield instead of from its SD card?" Tags="|shields|communication|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28588" PostTypeId="2" ParentId="28587" CreationDate="2016-08-22T14:15:00.700" Score="1" Body="&lt;p&gt;As far as I can see the SD card on the shield isn't read by the VS1053 directly, but by the arduino, which sends it to the VS1053. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So as far as I can see, you should be able to do what you want.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-22T14:15:00.700" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28589" PostTypeId="2" ParentId="28582" CreationDate="2016-08-22T15:41:19.477" Score="1" Body="&lt;p&gt;SOLVED!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I forgot to write &lt;code&gt;beginTransmission()&lt;/code&gt;. Here's my code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;  Wire.begin(0x63);&#xA;}&#xA;&#xA;void loop() {    &#xA;  Wire.beginTransmission(0x63);&#xA;  Wire.write(byte(0x00));&#xA;  Wire.write(&quot;Temperatur:&quot;);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25779" LastEditorUserId="26916" LastEditDate="2016-12-21T09:18:17.720" LastActivityDate="2016-12-21T09:18:17.720" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28591" PostTypeId="1" AcceptedAnswerId="28839" CreationDate="2016-08-22T16:49:28.637" Score="-1" ViewCount="160" Body="&lt;p&gt;I want Arduino to receive MP3 by WiFi (from iPhone), and then send to Music Maker codec and amplifier.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to use Arduino IDE and library software from Adafruit for the Music Maker, so I need an Arduino board 100% compatible with the library for Music Maker.&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-08-29T19:15:01.900" Title="Is Adafruit Arduino Feather M0 WiFi compatible with Adafruit Music Maker shield?" Tags="|wifi|shields|hardware|adafruit|audio|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28593" PostTypeId="2" ParentId="21490" CreationDate="2016-08-22T17:11:07.057" Score="0" Body="&lt;p&gt;I've searched in google and found a project in &lt;code&gt;Atmel Community&lt;/code&gt; that supports &lt;code&gt;serial&lt;/code&gt; with &lt;code&gt;USBasp&lt;/code&gt; &lt;a href=&quot;http://community.atmel.com/projects/usbasp-tty-usbasp-programmer-modified-serial-support-and-terminal-program&quot; rel=&quot;nofollow noreferrer&quot;&gt;here&lt;/a&gt;. They called it &lt;code&gt;USBASP-tty&lt;/code&gt;. I've not tested it yet but i think it will work. There are basically three requirements for it : &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;On the PC side, it uses a different software to capture the serial data from the &lt;code&gt;usbasp&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;It needs the conventionally bought &lt;code&gt;usbasp&lt;/code&gt; programmers to have the two serial connections (image: &lt;code&gt;PDO&lt;/code&gt; and &lt;code&gt;PD1&lt;/code&gt; connected with the &lt;code&gt;ISCP&lt;/code&gt; header) to work. If those aren't already made, you have to rewire the pins. Normally these connections aren't made and the &lt;code&gt;ICSP&lt;/code&gt; pins are connected to ground.&lt;/li&gt;&#xA;&lt;li&gt;The firmware of your &lt;code&gt;usbasp&lt;/code&gt; programmer must be updated to the provided firmware using another programmer.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/elBcb.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/elBcb.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="6723" LastEditorUserId="6723" LastEditDate="2016-08-22T17:51:08.727" LastActivityDate="2016-08-22T17:51:08.727" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28594" PostTypeId="2" ParentId="28575" CreationDate="2016-08-22T17:26:44.813" Score="1" Body="&lt;p&gt;Using &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;byte server[] = {XX, XX, XX, XX}; //IP&#xA;if (client.connect(server,80)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;instead of&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (client.connect(&quot;mysite.com.br&quot;,80)) {&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;worked&lt;/p&gt;&#xA;" OwnerUserId="280" LastActivityDate="2016-08-22T17:26:44.813" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28595" PostTypeId="2" ParentId="28580" CreationDate="2016-08-22T17:57:39.577" Score="1" Body="&lt;p&gt;Here's one: Microchip mtch6102, though it might be a little more complex than you're looking for.  All the others I found with a quick search were surface mount or single button controllers.  You might be able to multiplex a single button controller like the Atmel AT42QT1011, but I don't know what the settling or reset times are.  It may take to long to change pads, reset the chip, then wait for settling/calibration time (if any).&lt;/p&gt;&#xA;" OwnerUserId="19457" LastActivityDate="2016-08-22T17:57:39.577" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28596" PostTypeId="1" CreationDate="2016-08-22T18:06:37.827" Score="1" ViewCount="247" Body="&lt;p&gt;I have code but I don't know how to send SMS from my Mobile&#xA;I mean what the message I can send to switch the Led?&#xA;To switch On or Off.&#xA;I use SIm900&#xA;and use this code&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;&#xA; char inchar; // Will hold the incoming character from the GSM shield&#xA; SoftwareSerial SIM900(7, 8);&#xA;&#xA; int led = 10;&#xA;&#xA; void setup()&#xA; {&#xA;   Serial.begin(19200);&#xA;   // set up the digital pins to control&#xA;   pinMode(led, OUTPUT);&#xA;   digitalWrite(led, LOW);&#xA;&#xA;   // wake up the GSM shield&#xA;   SIM900.begin(19200);&#xA;   delay(20000); // give time to log on to network.&#xA;   SIM900.print(&quot;AT+CMGF=1\r&quot;); // set SMS mode to text&#xA;   delay(100);&#xA;   SIM900.print(&quot;AT+CNMI=2,2,0,0,0\r&quot;);&#xA;   // blurt out contents of new SMS upon receipt to the GSM shield's serial out&#xA;   delay(100);&#xA;   Serial.println(&quot;Ready...&quot;);&#xA; }&#xA;&#xA; void loop()&#xA; {&#xA;   //If a character comes in from the cellular module...&#xA;   if(SIM900.available() &amp;gt;0)&#xA;   {&#xA;     inchar=SIM900.read();&#xA;     if (inchar=='#')&#xA;     {&#xA;       delay(10);&#xA;&#xA;       inchar=SIM900.read();&#xA;       if (inchar=='a')&#xA;       {&#xA;         delay(10);&#xA;         inchar=SIM900.read();&#xA;         if (inchar=='0')&#xA;         {&#xA;           digitalWrite(led, LOW);&#xA;         }&#xA;         else if (inchar=='1')&#xA;         {&#xA;           digitalWrite(led, HIGH);&#xA;         }&#xA;         delay(10);&#xA;         // SIM900.println(&quot;AT+CMGD=1,4&quot;); // delete all SMS&#xA;       }&#xA;     }&#xA;   }&#xA; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25487" LastEditorUserId="313" LastEditDate="2016-08-22T18:18:16.763" LastActivityDate="2016-08-22T18:24:11.703" Title="What SMS can send to switch LED?" Tags="|gsm|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28597" PostTypeId="2" ParentId="28596" CreationDate="2016-08-22T18:24:11.703" Score="3" Body="&lt;p&gt;The code appears to be looking for an SMS that says &lt;code&gt;#a0&lt;/code&gt; or &lt;code&gt;#a1&lt;/code&gt;. The logic doesn't look very robust, though. It reads a character, then waits 10ms and tries to read another. What does &lt;code&gt;SIM900.read()&lt;/code&gt; do if there is no next character? Will it return something? Or wait until there is another? If it waits, the code can get out of sync with incoming, badly-formed commands.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-22T18:24:11.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28598" PostTypeId="1" CreationDate="2016-08-22T20:10:48.900" Score="4" ViewCount="3437" Body="&lt;p&gt;I am trying to get 2-Arduinos passing data. The Master will request the data and the Slave send it. But, the length of the string the Slave will send is unknown each cycle.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some things here on writing strings with I2C but it seems it is limited to 32 bytes no matter what the Master requests. How can I get the full string sent each time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Master makes request for string that could be about 180 bytes max - ever.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Wire.requestFrom(8,200);  // I2C-ID = 8, Length = 200 &#xA;while (Wire.available()) &#xA;{char c = Wire.read(); &#xA;cmdInStr.concat(c);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Slave sends&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int len = cmdOutStr.length()+1;&#xA;char ascii_num[len];&#xA;for (int i=0; i&amp;lt;len; ++i)&#xA;{ Wire.write(ascii_num[i]);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25973" LastActivityDate="2016-08-22T20:35:13.710" Title="Arduino I2C long string" Tags="|arduino-uno|i2c|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28600" PostTypeId="1" CreationDate="2016-08-22T20:29:30.307" Score="0" ViewCount="1249" Body="&lt;p&gt;When I try to upload any sketch to my arduino uno r3, the code compiles, the board resets and the RX light blinks 3 or 4 times.I have nothing from the TX light.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The uploading progress bar in the IDE stucks at it's end for a period and then gives me &quot;avrdude: stk500_recv(): programmer is not responding&quot; 10 times.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've done the loopback test and it works well so, what should i do ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for help.&lt;/p&gt;&#xA;" OwnerUserId="25975" LastActivityDate="2021-08-11T02:00:40.057" Title="&quot;avrdude: stk500_recv(): programmer is not responding&quot; when uploading sketch" Tags="|arduino-uno|" AnswerCount="1" CommentCount="2" ClosedDate="2021-08-11T05:41:12.063" ContentLicense="CC BY-SA 3.0" />
  <row Id="28601" PostTypeId="2" ParentId="28598" CreationDate="2016-08-22T20:29:40.080" Score="0" Body="&lt;p&gt;There is no maximum length for sending/receiving in I2C. It is the Wire library &lt;code&gt;BUFFER_LENGTH 32&lt;/code&gt; macro, causing this limitation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can either copy some code from Wire library and implement your own &lt;code&gt;requestFrom&lt;/code&gt; function which will store data directly to your &lt;code&gt;cmdInStr&lt;/code&gt; string buffer or you can change Wire.h to have bigger &lt;code&gt;BUFFER_LENGTH&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or another way is to extend Wire.h like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#ifndef BUFFER_LENGTH&#xA;#define BUFFER_LENGTH 32&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and in your sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#define BUFFER_LENGTH 180&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;All depends on your preferences, but implementing own requestFrom and storing it directly into your &lt;code&gt;cmdInStr&lt;/code&gt; buffer will be little bit more efficient than copying it into Wire buffer and then into your own buffer again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And do you really need all these data in one string, isn't it possible to proceed it on the fly?&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-22T20:35:13.710" LastActivityDate="2016-08-22T20:35:13.710" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28602" PostTypeId="2" ParentId="28598" CreationDate="2016-08-22T20:32:02.493" Score="1" Body="&lt;p&gt;You can only send and receive fixed length amounts of data with I2C. The master has to know how much to request from the slave - or the slave to accept from the master.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There's a number of ways around it though:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Splitting / joining.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;The trick here is to split the data into packets and re-assemble it at the remote end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, you split your string into 16-byte chunks. Then you send each chunk separately. Prefixed to each chunk (so the chunk becomes 17 bytes) is a byte telling the remote end how many characters are in this chunk.  Any spare space in a chunk is padded with something (0x00 for instance) so it remains 17 bytes long in total.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;two-stage transaction&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;In this method you first make a transaction which tells the remote end how many characters to receive in the next transaction, or retrieves the number of characters that need to be received from the remote end. The second transaction then receives (or sends) that specific number of characters.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If your strings are longer than the internal I2C buffer (32 bytes) then method 1 is probably the best way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can also combine the two methods so both ends know how much to expect to be transferred in total as well as how much of each packet is valid data. The sum of the second should match the first.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-22T20:32:02.493" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28603" PostTypeId="1" AcceptedAnswerId="28620" CreationDate="2016-08-22T20:33:36.887" Score="2" ViewCount="5596" Body="&lt;p&gt;I made a big search about how to Format Numbers with the Arduino. I want to &lt;strong&gt;format unsigned Longs into a String&lt;/strong&gt; in this format: &quot;&lt;em&gt;23,854,972&lt;/em&gt;&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The most of the snippets I found work &lt;strong&gt;only with the standard C / C++ Libraries&lt;/strong&gt;. They &lt;strong&gt;dont work on the Arduino&lt;/strong&gt; until I should put some STL libraries on the Arduino, which I want to prevent. It would be too bit of a overhead to import these only for this task. Also these Libraries will of course use some additional Flash and SRAM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For my Application it is very important that the solution uses the minimum Flash, SRAM and is &lt;strong&gt;fast&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Even if a solution does not use STL or works only with the native Arduino Libraries, I would need help to decide which one is &lt;strong&gt;more effective&lt;/strong&gt; in the sense of speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Incoming Number: 23854972&#xA;Arduino Program Output: 23,854,972&lt;/p&gt;&#xA;" OwnerUserId="25974" LastEditorUserId="11529" LastEditDate="2016-08-22T21:19:21.450" LastActivityDate="2016-08-23T09:24:26.660" Title="The most effective way to format numbers on Arduino" Tags="|programming|c++|c|string|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28604" PostTypeId="1" CreationDate="2016-08-22T20:48:30.843" Score="1" ViewCount="250" Body="&lt;p&gt;I need to split up code which I've already developed for one micro into two different Arduinos connected by serial. The &quot;remote&quot; micro is directly connected to a 20x4 character LCD and the main micro will be sending it a command set to print, move cursor, etc. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My plan was to make functions that used existing code such as &#xA;lcd.print(&quot;This or that&quot;);&#xA;to replace the lcd library on the main micro and send command bytes and data bytes up to the remote micro. Seems pretty straightforward. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then I discovered that apparently lcd.print cannot be a function name. Fine, so I changed it to lcd_print(). So far, so good. But in the existing library, lcd.print accepts strings, bytes, just about anything any length. For example:&#xA;lcd_print(&quot;any string of any length&quot;);&#xA;lcd_print(a_2d_array [x] [y]);&#xA;lcd_print(this_byte);&#xA;lcd_print(this_integer);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now it's getting over my head. I know I can painstakingly turn a single function into many different functions, but wouldn't it be nice to replicate the functionality of the Arduino LCD library with a single command:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;lcd.print();&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then all I have to do is create the function and keep the existing code and send the bytes up to the slave micro. Wouldn't that be nice! I appreciate any thoughts. Thanks.&lt;/p&gt;&#xA;" OwnerUserId="25586" LastEditorUserId="25788" LastEditDate="2016-09-16T02:06:33.047" LastActivityDate="2017-08-13T03:13:31.277" Title="Sending LCD commands to a slave micro" Tags="|serial|lcd|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28605" PostTypeId="2" ParentId="28540" CreationDate="2016-08-22T20:53:29.047" Score="4" Body="&lt;p&gt;Many factors would decide if you can reach this wanted speed. Only some of these.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h2&gt;1. Your Software&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://github.com/greiman/SdFat&quot; rel=&quot;nofollow&quot;&gt;SdFat&lt;/a&gt; Library is faster than the standard SD Library of the Arduino IDE. It also has an easy to use compatibility function with the standard SD Library. Try it out.&lt;/p&gt;&#xA;&#xA;&lt;h2&gt;2. Your Hardware&lt;/h2&gt;&#xA;&#xA;&lt;p&gt;You should use a high class SD Card. As you maybe know SD Cards are sorted into performance classes. Most people in the internet recommend a SanDisk SD Card.&lt;/p&gt;&#xA;" OwnerUserId="25974" LastEditorUserId="25974" LastEditDate="2016-08-22T20:59:26.690" LastActivityDate="2016-08-22T20:59:26.690" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28606" PostTypeId="2" ParentId="28604" CreationDate="2016-08-22T21:09:19.557" Score="1" Body="&lt;p&gt;Just inherit &lt;code&gt;Print&lt;/code&gt; class and implement &lt;code&gt;virtual size_t write(uint8_t);&lt;/code&gt; and you can use all kinds of print/println that Print implements. See &lt;a href=&quot;http://playground.arduino.cc/Code/Printclass&quot; rel=&quot;nofollow&quot;&gt;Print Class @arduino.cc&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It implements these methods for you:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t print(const __FlashStringHelper *);&#xA;size_t print(const String &amp;amp;);&#xA;size_t print(const char[]);&#xA;size_t print(char);&#xA;size_t print(unsigned char, int = DEC);&#xA;size_t print(int, int = DEC);&#xA;size_t print(unsigned int, int = DEC);&#xA;size_t print(long, int = DEC);&#xA;size_t print(unsigned long, int = DEC);&#xA;size_t print(double, int = 2);&#xA;size_t print(const Printable&amp;amp;);&#xA;&#xA;size_t println(const __FlashStringHelper *);&#xA;size_t println(const String &amp;amp;s);&#xA;size_t println(const char[]);&#xA;size_t println(char);&#xA;size_t println(unsigned char, int = DEC);&#xA;size_t println(int, int = DEC);&#xA;size_t println(unsigned int, int = DEC);&#xA;size_t println(long, int = DEC);&#xA;size_t println(unsigned long, int = DEC);&#xA;size_t println(double, int = 2);&#xA;size_t println(const Printable&amp;amp;);&#xA;size_t println(void);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;However you have to implement 2D array print if you really need this, I don't see why do you need it but whatever (you can print each line separately). It just saves you time with implementing everything else.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for std::ostream like approach I like this (works with anything inherited from Print class):&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;template &amp;lt;class T&amp;gt; inline Print &amp;amp; operator&amp;lt;&amp;lt;(Print &amp;amp; p, const T &amp;amp; val) {&#xA;  p.print(val);&#xA;  return p;&#xA;}&#xA;&#xA;// ...&#xA;&#xA;void loop() {&#xA;  float variableA = 221.23;&#xA;  String variableB = &quot;Some string&quot;;&#xA;  Serial &amp;lt;&amp;lt; F(&quot;flash string to save some ram: &quot;) &amp;lt;&amp;lt; variableA &amp;lt;&amp;lt; F(&quot; / &quot;) &amp;lt;&amp;lt; variableB &amp;lt;&amp;lt; &quot;\n&quot;;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Then you can implement some commands interface.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-23T05:09:39.417" LastActivityDate="2016-08-23T05:09:39.417" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28608" PostTypeId="2" ParentId="28603" CreationDate="2016-08-22T22:15:11.927" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;The most effective way to format numbers on Arduino&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If &quot;effective way&quot; is minimum effort you could hack the avr-libc source code for &lt;a href=&quot;https://github.com/vancegroup-mirrors/avr-libc/blob/master/avr-libc/tests/simulate/stdlib/ltoa-2.c&quot; rel=&quot;nofollow&quot;&gt;ltoa&lt;/a&gt; and do something like below: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;char *ultos_recursive(unsigned long val, char *s, unsigned radix, int pos)&#xA;{&#xA;  int c;&#xA;&#xA;  if (val &amp;gt;= radix)&#xA;    s = ultos_recursive(val / radix, s, radix, pos+1);&#xA;  c = val % radix;&#xA;  c += (c &amp;lt; 10 ? '0' : 'a' - 10);&#xA;  *s++ = c;&#xA;  if (pos % 3 == 0) *s++ = ',';&#xA;  return s;&#xA;}&#xA;&#xA;char *ltos(long val, char *s, int radix)&#xA;{&#xA;  if (radix &amp;lt; 2 || radix &amp;gt; 36) {&#xA;    s[0] = 0;&#xA;  } else {&#xA;    char *p = s;&#xA;    if (radix == 10 &amp;amp;&amp;amp; val &amp;lt; 0) {&#xA;      val = -val;&#xA;      *p++ = '-';&#xA;    }&#xA;    p = ultos_recursive(val, p, radix, 0) - 1;&#xA;    *p = 0;&#xA;  }&#xA;  return s;&#xA;}&#xA;&#xA;void setup()&#xA;{&#xA;  Serial.begin(9600);&#xA;  while (!Serial);&#xA;&#xA;  char buf[32];&#xA;  Serial.println(ltos(12345678, buf, 10));&#xA;  Serial.println(ltos(-12345678, buf, 10));&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Gives the output:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;12,345,678&#xA;-12,345,678&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PS: Please see the table driven, non-recursive, number conversion in &lt;a href=&quot;https://github.com/mikaelpatel/Cosa&quot; rel=&quot;nofollow&quot;&gt;Cosa&lt;/a&gt; (&lt;a href=&quot;https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/IOStream_dtoa.cpp&quot; rel=&quot;nofollow&quot;&gt;source&lt;/a&gt; and &lt;a href=&quot;https://github.com/mikaelpatel/Cosa/tree/master/examples/Benchmarks/CosaBenchmarkUART&quot; rel=&quot;nofollow&quot;&gt;benchmark&lt;/a&gt;) for a lean and faster implementation. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-22T22:52:59.487" LastActivityDate="2016-08-22T22:52:59.487" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28609" PostTypeId="1" AcceptedAnswerId="28621" CreationDate="2016-08-23T00:20:20.477" Score="0" ViewCount="1295" Body="&lt;p&gt;Schematic: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/C8GMc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/C8GMc.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am making some light fixtures controlled by an Arduino UNO. Each fixture will host two approx. 1 meter long analog RGB LED strips with a current draw at full power of ~1.2 A per meter. I have a 12 V power supply that I will wire directly to the strips, with the RGB channels wired to the Ardiino PWM pins via NPN MOSFET (note in the schematic I've only shown one color channel for simplicity, but there would of course be three transistors hooked up to three PWM pins). The Arduino itself will be powered by USB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My main difficulty in wiring the system is that for so much current I need fairly thick wire. The pads on the LED strips are delicate and I have several times damaged them by mechanical stress from the wire while soldering. The thick wire also crowds the narrow space between the pads creating a risk of a short. Therefore my first question is (bear with me, I'm pretty new to this):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) How should I wire the LED strips?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My thought is to wire up the strips in parallel with thinner, more flexible wires. This brings up two sub-questions:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1a) How should I join the thinner wires to the thick wire coming from the power supply?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1b) At the junction between the wires leaving the lights and running to the transistor, does the wire need to become thick again? (I think the answer is yes – the current should be the same as coming out of the power supply.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also am unsure about the ground.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Does the wire coming from transistor to ground need to be joined to the ground pin on the Arduino or can it run directly to the ground terminal of the power supply?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sub-question:&#xA;2a) Does the wire coming from transistor to ground need to be thick?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't really understand how transistors work (basically my understanding is that the Arduino uses a small amount of current over the PWM pins to somehow control how much current is allowed to flow through the rest of the circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've drawn a schematic showing how I think maybe this system needs to be wired up. Do I need to make changes?&lt;/p&gt;&#xA;" OwnerUserId="21577" LastEditorUserId="26916" LastEditDate="2017-09-10T00:44:31.170" LastActivityDate="2017-09-10T00:44:31.170" Title="Wiring LED strips in parallel &amp; ground" Tags="|power|wires|rgb-led|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28610" PostTypeId="1" CreationDate="2016-08-23T01:44:36.183" Score="1" ViewCount="130" Body="&lt;p&gt;I am working with two servomotors and both are having the same problem: right after i connect them to the arduino and upload the code, they do as the code says for a really small amount of time (0.1s maybe), and then they simply stop. If i keep connecting and reconnecting it again the servo answer to the code for a really small amount of time and then stop, as I said before.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Servo.h&amp;gt;&#xA;&#xA;#define SERVO 6 // Porta Digital 6 PWM&#xA;&#xA;Servo s; // Variável Servo&#xA;int pos; // Posição Servo&#xA;&#xA;void setup ()&#xA;{&#xA;  s.attach(SERVO);&#xA;  Serial.begin(9600);&#xA;  s.write(0); // Inicia motor posição zero&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  for(pos = 0; pos &amp;lt; 90; pos++)&#xA;  {&#xA;    s.write(pos);&#xA;  delay(15);&#xA;  }&#xA;delay(1000);&#xA;  for(pos = 90; pos &amp;gt;= 0; pos--)&#xA;  {&#xA;    s.write(pos);&#xA;    delay(15);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I am using the code above, and it looks totally fine. Does anyone know what might be causing this problem?&lt;/p&gt;&#xA;" OwnerUserId="25978" LastActivityDate="2016-12-21T10:16:30.003" Title="Servomotor losing its connection right after being connected to Arduino" Tags="|arduino-uno|motor|servo|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28611" PostTypeId="2" ParentId="28609" CreationDate="2016-08-23T02:16:06.490" Score="0" Body="&lt;p&gt;I think you are overestimating the size of wire required to attach to the LED strips, I have connected a lot of single color LED strip (in excess of 1mtr) with the wire that was already attach and it was reasonably light gauge.&#xA;Look at this &lt;a href=&quot;http://www.ebay.com.au/itm/NEW-2835SMD-300-LED-Flexible-Strip-Light-Ribbon-Lamp-Lighting-COOL-White-DC12V-/302050174238?hash=item465397e51e:g:P7sAAOSwRQlXeyVB&quot; rel=&quot;nofollow&quot;&gt;Example&lt;/a&gt; on Ebay and you can see what i mean.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am note an Electrical Engineer so i don't know the method to calculate the minimum wire gauge, but if in doubt contact the manufacturers and ask them or search on the web.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for the Transistor mounting/wiring you would mount that on a small circuit board with terminal block fitted for ease. Any power/connecting wire should not be less that used to the LED strip.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also you will need a current limiting resistor attached to the Base pin on your transistors. You will have to work out the value of that based on the spec sheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is a bit of learning required first, once you have researched the above you will have you exact answers. &lt;/p&gt;&#xA;" OwnerUserId="23966" LastActivityDate="2016-08-23T02:16:06.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28612" PostTypeId="1" AcceptedAnswerId="28613" CreationDate="2016-08-23T03:27:51.007" Score="0" ViewCount="777" Body="&lt;p&gt;I want to use loop() iterations counter to execute some tasks periodically or tasks like debouncing. My other sketch is running every loop() at least 20 ms, and if i am using 5 ms time to wait to&#xA;debounce a button, it will still be at least 20 ms waiting, also cpu will have to compare two not zero values, which is a bit slower.&#xA;I think it is more difficult for cpu than just incrementing and decrementing one variable and comparing it to 0. So i came up with pattern like that: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;boolean onOff=1; // arduino led state. My task here is LED blinking.&#xA;byte loopCounter=2; // number of iterations made by loop(). Set as little variable as possible to save ram and cpu time. &#xA;//Code will be executed every &quot;loopCounter&quot; iteration of loop(). &#xA;void setup() {&#xA;  pinMode(13, OUTPUT);&#xA;}&#xA;&#xA;void loop() {&#xA;      if (--loopCounter == 0) { //comparing with 0 should be a bit faster and easier for Arduino to process. Correct me if i am wrong. &#xA;        loopCounter=2; // That digit sets how often your code will be executed. Every 2(3,4... set your own value) iterations of loop().&#xA;        digitalWrite(13, onOff= !onOff); // the task itself. &#xA;        }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;It may be more convenient in some ways than millis() and micros() patterns. Also i do want want to use hardware timers for timing. &#xA;It may be convenient in cases, when you don't care when exactly task will be done, you just want it to be done ASAP (as soon as possible), but&#xA;not during that particular iteration of loop(). Basicly you can use it as a timer if you know how it takes one iteration to be done.&#xA;So, if your sketch runs 1 iteration of loop() for 1 ms, and you need some action to be done every 1 sec, 1ms*1000 == 1 sec. So you&#xA;need it to be done every 1000 iterations. &lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;So, is that really can save some ram and cpu time?&lt;/li&gt;&#xA;&lt;li&gt;Is comparing with zero is faster for arduino than comparing with not&#xA;zero?&lt;/li&gt;&#xA;&lt;li&gt;Are millis() and micros() timing patterns using more operations&#xA;(setting value to variable, computing the difference between 2&#xA;values and than comparing it to a period you have set) instead of&#xA;decrementing and comparing to zero with my pattern?&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Any side-effects of using my pattern? I can only think of very&#xA;unaccurate timing and delays more than you think if your sketch done&#xA;smth more than usual, because of button push for example or some&#xA;sensor changed value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="15007" LastActivityDate="2016-08-23T03:43:57.973" Title="Faster and lighter approximate timing code without using timer" Tags="|code-optimization|millis|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28613" PostTypeId="2" ParentId="28612" CreationDate="2016-08-23T03:43:57.973" Score="3" Body="&lt;p&gt;Personally I wouldn't be putting too much effort into optimizing away your timers. &lt;code&gt;millis()&lt;/code&gt; is pretty fast - the work needed to calculate the result is done in the background &lt;em&gt;anyway&lt;/em&gt; (by interrupts). I tried some test code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  unsigned long start, finish;&#xA;&#xA;  start = micros ();&#xA;  for (byte i = 0; i &amp;lt; 100; i++)&#xA;    digitalWrite (13, HIGH);&#xA;  finish = micros ();&#xA;&#xA;  Serial.print (&quot;Time taken to do digitalWrites: &quot;);&#xA;  Serial.println (finish - start);&#xA;  Serial.flush ();&#xA;&#xA;  start = micros ();&#xA;  volatile unsigned long now;&#xA;  for (byte i = 0; i &amp;lt; 100; i++)&#xA;    now = millis ();&#xA;  finish = micros ();&#xA;&#xA;  Serial.print (&quot;Time taken to do millis: &quot;);&#xA;  Serial.println (finish - start);&#xA;  Serial.flush ();&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Results:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Time taken to do digitalWrites: 520&#xA;Time taken to do millis: 188&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can see that the &lt;code&gt;digitalWrite()&lt;/code&gt; (which you weren't worried about) takes 5.2 µs, whereas calling &lt;code&gt;millis()&lt;/code&gt; (which you &lt;em&gt;were&lt;/em&gt; worried about) takes 1.88 µs.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Are millis() and micros() timing patterns using more operations (setting value to variable, computing the difference between 2 values and than comparing it to a period you have set) instead of decrementing and comparing to zero with my pattern?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, just adding one to a variable and then comparing will be faster. Whether it is worth the effort is debatable.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-23T03:43:57.973" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28616" PostTypeId="2" ParentId="21055" CreationDate="2016-08-23T07:41:01.633" Score="1" Body="&lt;p&gt;Yes, that is easy. You need multiplexer (MUX) to forward communication pins (2 &amp;amp; 3) to the right GSM shield. Google for it to find the one that suits your budget.&lt;/p&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-23T07:41:01.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28617" PostTypeId="2" ParentId="28497" CreationDate="2016-08-23T08:15:37.753" Score="0" Body="&lt;p&gt;I have found the &lt;a href=&quot;http://www.theengineeringprojects.com/2016/05/gas-sensor-library-proteus.html&quot; rel=&quot;nofollow&quot;&gt;Gas Sensor Library for Proteus&lt;/a&gt;, so I thought to share it here so that others can also get benefit out of it. They have also posted the complete method of How to use this Gas Sensor Library and have also given an example to download.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-08-23T08:15:37.753" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28618" PostTypeId="2" ParentId="28610" CreationDate="2016-08-23T08:16:07.460" Score="1" Body="&lt;p&gt;Your code is correct. Check the following:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino works from 5V, but most servos need 6V. &lt;/li&gt;&#xA;&lt;li&gt;Even if your servo works from 5V, don't ever connect your servo power directly to Arduino pins. These pins are not able to provide adequate power for servo.&lt;/li&gt;&#xA;&lt;li&gt;Check that grounds of both power supply for Arduino and power supply for servo are connected together.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-23T08:16:07.460" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28619" PostTypeId="2" ParentId="15943" CreationDate="2016-08-23T08:18:52.197" Score="0" Body="&lt;p&gt;If you are using HC-SR04 then I would suggest you to first check it out on simulation. I use Proteus software for simulation purposes and you should download the &lt;a href=&quot;http://www.theengineeringprojects.com/2015/02/ultrasonic-sensor-library-proteus.html&quot; rel=&quot;nofollow&quot;&gt;Ultrasonic Sensor Library for Proteus&lt;/a&gt;, using this library you can easily simulate your Ultrasonic sensor in Proteus and can design your code. It will save you from hardware testing.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-08-23T08:18:52.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28620" PostTypeId="2" ParentId="28603" CreationDate="2016-08-23T09:24:26.660" Score="4" Body="&lt;p&gt;Here is my try at it: The usual way to write a number in decimal is to&#xA;get the digits from right to left with a loop that looks something like&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;digit = '0' + val % 10;&#xA;val /= 10;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The following function does exactly this, with the addition of adding&#xA;commas at the correct positions:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Format an unsigned long (32 bits) into a string in the format&#xA; * &quot;23,854,972&quot;.&#xA; *&#xA; * The provided buffer must be at least 14 bytes long. The number will&#xA; * be right-adjusted in the buffer. Returns a pointer to the first&#xA; * digit.&#xA; */&#xA;char *ultoa(unsigned long val, char *s)&#xA;{&#xA;    char *p = s + 13;&#xA;    *p = '\0';&#xA;    do {&#xA;        if ((p - s) % 4 == 2)&#xA;            *--p = ',';&#xA;        *--p = '0' + val % 10;&#xA;        val /= 10;&#xA;    } while (val);&#xA;    return p;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the string is right adjusted in the buffer, and the unused&#xA;characters are not touched. This means you can get a right adjusted&#xA;string by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;pre-filling the string with spaces (for padding)&lt;/li&gt;&#xA;&lt;li&gt;calling the function above&lt;/li&gt;&#xA;&lt;li&gt;using the original buffer as the right adjusted string&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Otherwise you would use the returned pointer to have a string with no&#xA;padding.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is a simple test program:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;unsigned long vals[] = {0, 1, 2, 9, 10, 999, 1000, 0xffffffff};&#xA;const int COUNT = sizeof vals / sizeof vals[0];&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    char buffer[14];&#xA;    for (int i = 0; i &amp;lt; COUNT; i++) {&#xA;        unsigned long val = vals[i];&#xA;        Serial.print(val);&#xA;        Serial.write('\t');&#xA;        Serial.println(ultoa(val, buffer));&#xA;    }&#xA;}&#xA;&#xA;void loop() {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-23T09:24:26.660" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28621" PostTypeId="2" ParentId="28609" CreationDate="2016-08-23T09:31:35.273" Score="0" Body="&lt;p&gt;It's all a question of &lt;em&gt;losses&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Wire is basically a resistor. The thinner and longer the wire the higher the resistance. Current flowing through a resistor causes a voltage drop across the resistor.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Long thin wires with large amounts of current through them will basically mean you get less than your 12V at the LED strips. The question has to be: how much less a voltage is tolerable?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each strip takes 1.2A. Take for example 24AWG wire. That has a resistance of 0.0842Ω per meter. With 1.2A flowing through a meter of that you get 0.10104V dropped across the wire. That turns your 12V into 11.9V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Conversely, a meter of 14AWG wire has a resistance of 0.00829Ω - so you would lose 0.009948V over that length.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now you want two strips - which is double the current, and thus double the voltage drop. On 14AWG you would lose about 0.02V over a meter. Not really enough to worry about. But you can't connect 14AWG to the LED strips. You can connect thinner wire (say 24AWG as above) to them. But that looses too much voltage. Well - &lt;em&gt;over a meter it loses too much voltage&lt;/em&gt;. But what about over, say, 10cm? That's a 10th the length of before, and so a 10th the voltage loss: 0.01V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So what is to stop you having a short length of thin wire connected to the LED strips, which then connects to a longer length of thick wire? Answer: absolutely nothing.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And how do you join them together? Well, I find the best way is with solder. Insert the thin wire (stripped) into the end of the fat wire (stripped) and twist them together (axially) then flood the joint with solder. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/8UoH0.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/8UoH0.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-23T09:31:35.273" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28622" PostTypeId="2" ParentId="28402" CreationDate="2016-08-23T09:32:45.093" Score="0" Body="&lt;p&gt;The light technician, Toby Peperkamp, came with the solution. I'm not sure exactly where he found the information, but apparently the protocol for non-RGB DMX lights requires that the lights be switched on to maximum (255) at the beginning of the connection. So I added that to the setUp() and all the lights started to respond.&lt;/p&gt;&#xA;" OwnerUserId="25810" LastActivityDate="2016-08-23T09:32:45.093" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28624" PostTypeId="1" CreationDate="2016-08-23T09:44:34.467" Score="-2" ViewCount="111" Body="&lt;p&gt;we have an error after compiling the code in arduinouno that is displayed as&lt;br&gt;&#xA;error: 'power_usi_disable' was not declared in this scope   in Board: &quot;Arduino/Genuino Uno&quot;.how to rectify this error. please reply us fast&lt;/p&gt;&#xA;" OwnerUserId="25987" LastEditorUserId="7508" LastEditDate="2016-08-23T09:57:54.590" LastActivityDate="2016-08-23T10:54:50.053" Title="No power_usi_disable() on Arduino Uno" Tags="|arduino-uno|compile|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28625" PostTypeId="2" ParentId="28624" CreationDate="2016-08-23T09:55:50.910" Score="3" Body="&lt;p&gt;The Arduino Uno does not have a USI peripheral. Thus, you cannot disable&#xA;the power of the (non-existent) USI, and there is no&#xA;&lt;code&gt;power_usi_disable()&lt;/code&gt; function.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Solution: remove the call to &lt;code&gt;power_usi_disable()&lt;/code&gt; from your code.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: To answer your &lt;em&gt;new&lt;/em&gt; question in the comment, &lt;code&gt;WDTCR&lt;/code&gt; is the&#xA;Watchdog Timer Control Register on some AVR chips. On the Uno it is&#xA;called &lt;code&gt;WDTCSR&lt;/code&gt;, because it is a control and status register.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Looks to me like you have downloaded from somewhere a program you do not&#xA;understand. That program was written for an ATtiny chip and you are&#xA;trying to compile it as-is for an Arduino Uno, which is based on an&#xA;(incompatible) ATmega328P. That's not the way to do it: you have to&#xA;understand the program and rewrite all the ATtiny specific stuff to fit&#xA;the Uno.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-08-23T10:54:50.053" LastActivityDate="2016-08-23T10:54:50.053" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28630" PostTypeId="1" AcceptedAnswerId="28631" CreationDate="2016-08-23T11:22:47.963" Score="2" ViewCount="3046" Body="&lt;p&gt;How much &lt;strong&gt;time&lt;/strong&gt; does an Arduino Uno or Mega need &lt;strong&gt;to only call a function&lt;/strong&gt;. And how does the time change if this function is inside a Class, for example inside a Library?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The same thing for a variable. How much time does a micro-controller need &lt;strong&gt;to read a declared variable&lt;/strong&gt;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How to determine this values? Is there a mathematic formula? Can we predetermine this type of delays and other similar micro-controller related delays?&lt;/p&gt;&#xA;" OwnerUserId="25974" LastActivityDate="2016-09-03T01:18:42.757" Title="How much time does the Arduino need to call a Function or to read a Variable?" Tags="|time|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28631" PostTypeId="2" ParentId="28630" CreationDate="2016-08-23T12:19:46.073" Score="8" Body="&lt;p&gt;It is hard to give a general answer, as it depends on the specifics of&#xA;your code and on how the compiler compiles it:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How much time does an Arduino Uno or Mega need to only call a function.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This can involve a number of things:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the caller puts the arguments on some predefined CPU registers, unless&#xA;they are already there from a previous operation (the compiler tries&#xA;to optimize the code so that this happens whenever possible)&lt;/li&gt;&#xA;&lt;li&gt;the caller issues the &lt;code&gt;call&lt;/code&gt; instruction to do the actual function&#xA;call&lt;/li&gt;&#xA;&lt;li&gt;the callee pushes some CPU registers into the stack in order to use&#xA;them without clobbering the caller's data&lt;/li&gt;&#xA;&lt;li&gt;the callee does its job&lt;/li&gt;&#xA;&lt;li&gt;the callee pops the previously pushed registers&lt;/li&gt;&#xA;&lt;li&gt;the callee issues the &lt;code&gt;ret&lt;/code&gt; (meaning return) instruction&lt;/li&gt;&#xA;&lt;li&gt;the caller finds the return value in some CPU registers&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;On the Uno, the &lt;code&gt;call&lt;/code&gt; and &lt;code&gt;ret&lt;/code&gt; instructions cost 4&amp;nbsp;CPU cycles&#xA;each (0.25&amp;nbsp;µs). On the Mega, it's 5&amp;nbsp;cycles (0.3125&amp;nbsp;µs)&#xA;each. &lt;code&gt;push&lt;/code&gt; and &lt;code&gt;pop&lt;/code&gt; are 2&amp;nbsp;cycles each, and you need one such&#xA;pair for every 8-bit register you need to save.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And how does the time change if this function is inside a Class, for&#xA;  example inside a Library?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The only difference is that a class method receives an extra hidden&#xA;parameter called &lt;code&gt;this&lt;/code&gt;. Except if it's a virtual method, which is more&#xA;expensive because it involves some pointer dereferencing.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How much time does a micro-controller need to read a declared&#xA;  variable?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;“Reading” generally means transferring the contents of the variable to&#xA;some CPU registers. Local variable are usually allocated to CPU&#xA;registers in the first place, so there is no need to read them. Global&#xA;(and local static) variables are stored in RAM, and reading them takes&#xA;2&amp;nbsp;cycles per byte (e.g. 4 cycles for a 16-bit &lt;code&gt;int&lt;/code&gt;).&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to determine this values?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Disassemble the code generated by the compiler. Then look up the&#xA;instructions in the &lt;a href=&quot;http://www.atmel.com/images/Atmel-0856-AVR-Instruction-Set-Manual.pdf&quot;&gt;instruction set manual&lt;/a&gt;: it documents the number&#xA;of clock cycles needed by each instruction.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-23T12:19:46.073" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28632" PostTypeId="2" ParentId="26701" CreationDate="2016-08-23T15:56:25.113" Score="0" Body="&lt;p&gt;I have the same configuration and it works (Arduino UNO rev3)&#xA;I used WiFlyHQ library. Just be carefull with the serial.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.begin(9600);&#xA;...&#xA;if (!wifly.begin(&amp;amp;Serial, NULL)) { &#xA;   ...&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Upload with serial select then put it on USB and then open the monitor.&lt;/p&gt;&#xA;" OwnerUserId="25995" LastEditorUserId="84" LastEditDate="2016-08-23T16:49:11.900" LastActivityDate="2016-08-23T16:49:11.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28635" PostTypeId="1" AcceptedAnswerId="28638" CreationDate="2016-08-23T17:32:17.210" Score="1" ViewCount="1277" Body="&lt;p&gt;I'm working on a project using a set of different Arduino Nano connected to a Raspberry Pi through USB.&#xA;Now my question is: &lt;em&gt;&quot;how can I, from the Pi's point of view, differentiate all of those Arduino and associate them with their respective tty?&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found some part of my answer in &lt;a href=&quot;https://arduino.stackexchange.com/questions/14600/how-to-differentiate-between-2-micros-on-linux?newreg=c19dc2b8ae03419c8bb5e132fc41bbb3&quot;&gt;this question&lt;/a&gt;. The answering guy proposes to manually change the Arduino &lt;code&gt;MODEL_ID&lt;/code&gt; when compiling and to use it afterwork to identify the device. The problem is that I don't know how to achieve that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried to edit the &lt;code&gt;boards.txt&lt;/code&gt; file to add a new board configuration with custom &lt;code&gt;vid.x&lt;/code&gt; and &lt;code&gt;pid.x&lt;/code&gt; (why all those 4 different values?) but after selecting my board and uploading, the &lt;code&gt;MODEL_ID&lt;/code&gt; still stays the same:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;ID_MODEL_FROM_DATABASE=HL-340 USB-Serial adapter&#xA;ID_MODEL_ID=7523&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Can't I just specify somehow the &lt;code&gt;USB_PID&lt;/code&gt; macro to the compiler command line?&lt;/p&gt;&#xA;" OwnerUserId="25998" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2021-06-06T10:41:16.830" Title="How to change Arduino Nano MODEL_ID" Tags="|arduino-nano|compile|command-line|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28636" PostTypeId="2" ParentId="28600" CreationDate="2016-08-23T17:35:40.697" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;yes, it has worked before. ... uncorrect bootloader or something,,...&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Does the last program you successfully uploaded write anything to the serial port? If you just run the Arduino (no upload attempt) with the Arduino IDE's serial terminal open, can you see that output? It's pretty hard to damage the boot-loader without actually writing a new, bad one to the chip. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If the current program seems to running but not writing to serial when it should, a likely cause of upload failure is the code in 16U2 processor (or the chip itself) that handles the USB to serial conversion; it's the square 32-pin chip between the 16 MHz crystal and USB connector. Its firmware can be re-loaded - search here for how to do that. If the chip itself is damaged it is probably not worth attempting a repair.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update: Is the +5v pin on the power header (left edge of the board, if the USB connector is pointing up) reading 5v? You'd expect the output pins to read 0v, 5v, or be noisy if they are floating. A steady 1v sounds strange. At this point it would be worth trying this board on another computer, and another board on your computer, and see which one fails.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-08-23T22:21:43.800" LastActivityDate="2016-08-23T22:21:43.800" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28637" PostTypeId="1" CreationDate="2016-08-23T18:30:13.630" Score="0" ViewCount="2820" Body="&lt;p&gt;I want to use Arduino(atmega8) on breadboard using USBASP programmer and want to use Serial Monitor without using any Arduino board as ISP programmer.&#xA;My questions: 1. Is such thing possible?&#xA;2. How do I do that?&lt;/p&gt;&#xA;" OwnerUserId="26000" LastActivityDate="2016-08-23T18:50:38.303" Title="How to use Serial Monitor without Arduino board?" Tags="|serial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28638" PostTypeId="2" ParentId="28635" CreationDate="2016-08-23T18:36:22.463" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to change Arduino Nano MODEL_ID?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardNano&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano&lt;/a&gt; used a special USB-Serial adapter (FTDI FT232RL). You can &lt;a href=&quot;http://www.alauda.ro/2013/11/changing-ftdi-descriptors/&quot; rel=&quot;nofollow&quot;&gt;change the ID&lt;/a&gt; but this requires some special hacking. Please see the provided links.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-23T18:42:20.620" LastActivityDate="2016-08-23T18:42:20.620" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28639" PostTypeId="2" ParentId="28637" CreationDate="2016-08-23T18:40:45.877" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How to use Serial Monitor without Arduino board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes that is possible. Connect to the RX/TX pins on the breadboard chip. Remember these are 5V. You will need an Serial-USB or RS232 adapter to connect your development machine. Please see this &lt;a href=&quot;http://cosa-arduino.blogspot.se/2013/04/programming-attinyx5.html&quot; rel=&quot;nofollow&quot;&gt;blog post&lt;/a&gt; for some inspiration. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-23T18:50:38.303" LastActivityDate="2016-08-23T18:50:38.303" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28643" PostTypeId="1" CreationDate="2016-08-23T20:36:39.417" Score="1" ViewCount="1343" Body="&lt;p&gt;I just bought a raw Atmega328p microcontroller. I am attempting to flash it with the Arduino bootloader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The process seemed relatively straightforward as I had just followed the posted tutorial (&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/ArduinoISP&lt;/a&gt;).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Everything seemed to go fine and I even got a message after the second attempt with a message of 'Burning Bootloader Done'. I am targeting the device as if it were an Arduino Pro Mini.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I then moved onto program the chip with an Arduino sketch via the FTDI programmer. However, the sketch upload fails. It says that it is out of sync. I verify that everything is wired up correctly, yet it still fails. I then remove power to the Atmega328p chip (just to see if I get a different error) yet I still get the out of sync error. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has me questioning whether or not the bootloader was even flashed in the first place. So how do I know if the bootloader actually was successful? A couple things to note:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;When I power on the Atmega328p, the PB6 output starts blinking immediately. I would assume that if there were a bootloader, there would be a moment of pause until the regular program starts. Should I expect to see a pause if the bootloader is on the chip?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;If the bootloader is on the chip, should I even expect to see the Atemga328ps default heartbeat?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;When I flash the chip with the bootloader, it says that it could take up to a minute to finish. However, it only takes 6 seconds until it states 'Bootloader Finished Burning'. This seems like it's happening too fast.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If we determine that the problem is due to something else (i.e. not the bootloader), I will begin a new discussion. However, right now I'm just curious how I know if the bootloader is actually on the device.&lt;/p&gt;&#xA;" OwnerUserId="26003" LastActivityDate="2016-08-23T21:42:40.513" Title="How do I know if bootloader flash was successful?" Tags="|arduino-uno|bootloader|arduino-pro-mini|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28647" PostTypeId="2" ParentId="28643" CreationDate="2016-08-23T21:42:40.513" Score="1" Body="&lt;p&gt;See &lt;a href=&quot;http://www.gammon.com.au/bootloader&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about burning bootloaders&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The sketch there has a &amp;quot;verify&amp;quot; option so you can check if the bootloader was burned.&lt;/p&gt;&#xA;&lt;p&gt;See my post &lt;a href=&quot;https://arduino.stackexchange.com/questions/15936/what-happens-when-code-is-uploaded-using-the-bootloader&quot;&gt;What happens when code is uploaded using the bootloader?&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;With Optiboot installed you expect to see three flashes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/I3ii5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/I3ii5.png&quot; alt=&quot;Optiboot start&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;As for your other problems, see &lt;a href=&quot;https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board&quot;&gt;Have I bricked my Arduino Uno? Problems with uploading to board&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You may well not have set the fuses correctly.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-23T21:42:40.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28649" PostTypeId="1" AcceptedAnswerId="28650" CreationDate="2016-08-23T22:10:22.083" Score="-1" ViewCount="278" Body="&lt;p&gt;I am trying to control 64 leds through a number of 8:1 analog multiplexers. The input is from pin 11 on the Arduino which is giving 40mA (maximum) and it is pulsed at 38kHz. Then I use other pins to select one of 64 leds to control. For testing, I am just trying one of those leds. The problem is that the current across the led is just 2mA, which means it is very dim. Using a multimeter, the current after the first multiplexer seems to be 4mA and after the second just 2mA. How can I get the current to increase? Thanks in advance!&lt;/p&gt;&#xA;" OwnerUserId="26005" LastActivityDate="2016-08-24T00:03:23.067" Title="Why does the current drop through a multiplexer?" Tags="|led|multiplexer|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28650" PostTypeId="2" ParentId="28649" CreationDate="2016-08-24T00:03:23.067" Score="1" Body="&lt;p&gt;Analog multiplexers are not a good design choice for switching digital signals.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You should instead choose a digital solution. Maybe the 74HC138 would be a better choice? That's a 3-to-8 decoder with 3 enable inputs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use 9 of them to reduce pin usage on the Arduino, or 8 of them if you have pins to spare.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;One of the enables on the first-stage can be a &quot;mater enable&quot; - or tie one of the enables of all 8 of the second-stage together for a &quot;master enable&quot;. Another enable to all the 8 second-stage muxes can be the PWM signal. The third is driven by the Arduino or the first stage as a MUX selector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like this arrangement:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/eG8t7.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/eG8t7.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Note that the outputs are &lt;em&gt;active low&lt;/em&gt;, so you would connect the anode of your LEDs to +5V and the cathode, through a suitable resistor, to the output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option would be to use a set of shift registers that have an &lt;em&gt;output enable&lt;/em&gt; pin. Drive that pin with the PWM signal and you can have any combination of LEDs enabled at once.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-24T00:03:23.067" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28651" PostTypeId="1" CreationDate="2016-08-24T03:27:55.647" Score="4" ViewCount="168" Body="&lt;p&gt;My 10-year-old son went to a &quot;Robotics Camp&quot; and came home with a non-functional Arduino robot. I figured it shouldn't be too much trouble to get it working. He swears he had it operating at the camp, but our best efforts notwithstanding, we were unable to reproduce his successes at home to any degree at all. Currently we seem to have an ungainly, $400 paperweight.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm a .Net web-developer by day, but I'm completely uninitiated when it comes to Arduino. I did enough research to learn how to upload a basic sketch- the &quot;Blink&quot; sketch- to our board an verify that the board is functional. Upon uploading the Blink sketch we got a flashing red LED. I was able to go into the sketch and modify the the variable values and see the results in the duration of the LED flash after uploading the sketch again. So I'm confident that we have a good connection to the PC and a functioning Arduino board. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But beyond that I'm stumped. When I attempt to upload the program that my son brought home, the robot does nothing. I can see a red LED blink a few times on the Arduino, but other that that, nothing happens. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's some photos of our setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/gFLrZ.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/gFLrZ.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/4KcaR.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/4KcaR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here's the sketch that my son brought home:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;/***************************************************&#xA;  This is an example for our Adafruit 16-channel PWM &amp;amp; Servo driver&#xA;  Servo test - this will drive 16 servos, one after the other&#xA;&#xA;  Pick one up today in the adafruit shop!&#xA;  ------&amp;gt; http://www.adafruit.com/products/815&#xA;&#xA;  These displays use I2C to communicate, 2 pins are required to  &#xA;  interface. For Arduino UNOs, thats SCL -&amp;gt; Analog 5, SDA -&amp;gt; Analog 4&#xA;&#xA;  Adafruit invests time and resources providing this open source code,&#xA;  please support Adafruit and open-source hardware by purchasing&#xA;  products from Adafruit!&#xA;&#xA;  Written by Limor Fried/Ladyada for Adafruit Industries.  &#xA;  BSD license, all text above must be included in any redistribution&#xA; ****************************************************/&#xA;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;Adafruit_PWMServoDriver.h&amp;gt;&#xA;#include &amp;lt;QueueList.h&amp;gt;&#xA;&#xA;// called this way, it uses the default address 0x40&#xA;Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();&#xA;// you can also call it with a different address you want&#xA;//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);&#xA;&#xA;// Depending on your servo make, the pulse width min and max may vary, you&#xA;// want these to be as small/large as possible without hitting the hard stop&#xA;// for max range. You'll have to tweak them as necessary to match the servos you&#xA;// have!&#xA;#define SERVOMIN  300//150 // this is the 'minimum' pulse length count (out of 4096)&#xA;#define SERVOMAX  400//600 // this is the 'maximum' pulse length count (out of 4096)&#xA;&#xA;uint16_t servoMins[] = {160, 200, 500, 150, 150, 150, 0};&#xA;uint16_t servoMaxs[] = {600, 600, 700, 600, 600, 600, 0};&#xA;uint16_t servoHomes[] = {380, 400, 300, 340, 375, 375, 0};&#xA;&#xA;enum GroupType {WithPrevious, NewGroup};&#xA;&#xA;#define PAUSE_COMMAND 6&#xA;#define NUM_TRANSITIONS (PAUSE_COMMAND+1)&#xA;&#xA;&#xA;unsigned long currentTime;&#xA;&#xA;class transition&#xA;{&#xA;  private:&#xA;    unsigned long startTime;&#xA;    unsigned long totalTime;&#xA;    uint16_t pulseLenStart;&#xA;    uint16_t pulseLenEnd;&#xA;    uint16_t currentPulseLen;&#xA;    int id;&#xA;    bool transitioning;&#xA;&#xA;  public:&#xA;    void init(int id, uint16_t current)&#xA;    {&#xA;      this-&amp;gt;id = id;&#xA;      currentPulseLen = current;&#xA;      totalTime = 0;&#xA;      startTime = 0;&#xA;      pulseLenStart = current;&#xA;      pulseLenEnd = current;&#xA;      transitioning = false;&#xA;&#xA;    }&#xA;&#xA;    uint16_t calculate(unsigned long currentTime)&#xA;    {&#xA;      float t = 1.0f;&#xA;      if (totalTime &amp;gt; 1e-3f)&#xA;        t = (currentTime - startTime) / (float)totalTime;&#xA;      t = (t &amp;gt; 1.0f) ? 1.0f : t;&#xA;      currentPulseLen = (uint16_t)(((float)pulseLenEnd - (float)pulseLenStart) * t + pulseLenStart);&#xA;/*      if (transitioning)&#xA;      {&#xA;        Serial.println(&quot;transitioning&quot;);&#xA;        Serial.println(id);&#xA;        Serial.println(t);&#xA;        Serial.println(currentTime);&#xA;        Serial.println(startTime);&#xA;        Serial.println(totalTime);&#xA;        Serial.println(pulseLenStart);&#xA;        Serial.println(pulseLenEnd);&#xA;        Serial.println(currentPulseLen);&#xA;      }&#xA;*/&#xA;      if (t &amp;gt;= 1.0f)&#xA;        transitioning = false;&#xA;      return currentPulseLen;&#xA;    }&#xA;&#xA;    void createTransition (uint16_t pulseLen, unsigned long time)&#xA;    {&#xA;/*      Serial.println(&quot;create Transition:&quot;);&#xA;      Serial.println(id);&#xA;      Serial.println(pulseLen);&#xA;      Serial.println(time);&#xA;*/&#xA;      pulseLenStart = currentPulseLen;&#xA;      pulseLenEnd = pulseLen;&#xA;      totalTime = time;&#xA;      startTime = currentTime;&#xA;      transitioning = true;&#xA;    }&#xA;&#xA;    bool isTransitioning()&#xA;    {&#xA;      return transitioning;&#xA;    }&#xA;};&#xA;&#xA;transition transitions[NUM_TRANSITIONS];&#xA;&#xA;&#xA;struct Command&#xA;{&#xA;  uint16_t pulseLen;&#xA;  unsigned long totalTime;&#xA;  int commandType;&#xA;  GroupType groupType;&#xA;&#xA;  void execute()&#xA;  {&#xA;    transitions[commandType].createTransition(pulseLen, totalTime);&#xA;  }&#xA;};&#xA;QueueList&amp;lt;Command&amp;gt; commandQueue;&#xA;&#xA;void program ();&#xA;void restoreHomePositions (double seconds);&#xA;&#xA;void setup()&#xA;{&#xA;  pwm.begin();&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Hello world&quot;);&#xA;&#xA;  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates&#xA;&#xA;  for (int servoNum =0; servoNum &amp;lt; NUM_TRANSITIONS; servoNum++)&#xA;  {&#xA;    //pwm.setPWM(servoNum, 0, servoHomes[servoNum]);&#xA;    transitions[servoNum].init(servoNum, servoHomes[servoNum]);&#xA;  }&#xA;&#xA;  restoreHomePositions (0);&#xA;  program();&#xA;  restoreHomePositions (.75);&#xA;&#xA;&#xA;  yield();&#xA;}&#xA;&#xA;void processCommandQueue();&#xA;&#xA;void loop()&#xA;{&#xA;  currentTime = millis();&#xA;&#xA;  processCommandQueue();&#xA;&#xA;  for (int servoNum = 0; servoNum &amp;lt; NUM_TRANSITIONS; servoNum++)&#xA;  {&#xA;    if (transitions[servoNum].isTransitioning())&#xA;    {&#xA;      uint16_t pulselen = transitions[servoNum].calculate(currentTime);&#xA;      if (servoNum != PAUSE_COMMAND)&#xA;      {&#xA;        pwm.setPWM(servoNum, 0, pulselen);&#xA;        Serial.println(&quot;setPWM&quot;);&#xA;        Serial.println(servoNum);&#xA;        Serial.println(pulselen);&#xA;      }&#xA;    }    &#xA;  }&#xA;}&#xA;&#xA;bool isTransitioning()&#xA;{&#xA;  for (int servoNum = 0; servoNum &amp;lt; NUM_TRANSITIONS; servoNum++)&#xA;  {&#xA;    if (transitions[servoNum].isTransitioning())&#xA;      return true;&#xA;  }&#xA;  return false;&#xA;}&#xA;&#xA;int frame = 0;&#xA;void processCommandQueue()&#xA;{&#xA;  if (!commandQueue.isEmpty())&#xA;  {&#xA;    Serial.println(&quot;Frame&quot;);&#xA;    Serial.println(frame);&#xA;    frame++;&#xA;  }&#xA;  if (!commandQueue.isEmpty() &amp;amp;&amp;amp; !isTransitioning())&#xA;  {&#xA;    do&#xA;    {&#xA;      Command top = commandQueue.pop();&#xA;      top.execute();&#xA;    }&#xA;    while (!commandQueue.isEmpty() &amp;amp;&amp;amp; commandQueue.peek().groupType == WithPrevious);&#xA;  }&#xA;}&#xA;&#xA;void move (int commandType, uint16_t pulseLen, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  Command command;&#xA;  command.groupType = groupType;&#xA;  command.commandType = commandType;&#xA;  command.pulseLen = pulseLen;&#xA;  command.totalTime = (unsigned long)(seconds * 1000);&#xA;  Serial.println(&quot;Command:&quot;);&#xA;  Serial.println(groupType == NewGroup ? &quot;NewGroup&quot; : &quot;WithPrevious&quot;);&#xA;  Serial.println(commandType);&#xA;  Serial.println(pulseLen);&#xA;  Serial.println(command.totalTime);&#xA;  commandQueue.push (command);&#xA;}&#xA;&#xA;void rotateWrist (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[5], servoMaxs[5]);&#xA;  move (5, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void bendWrist (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[4], servoMaxs[4]);&#xA;  move (4, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void rotateForeArm (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[3], servoMaxs[3]);&#xA;  move (3, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void bendForeArm (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[2], servoMaxs[2]);&#xA;  move (2, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void bendUpperArm (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[1], servoMaxs[1]);&#xA;  move (1, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void rotateRobot (int percent, double seconds, GroupType groupType = NewGroup)&#xA;{&#xA;  percent = percent &amp;lt; -100 ? -100 : percent;&#xA;  percent = percent &amp;gt; 100 ? 100 : percent;&#xA;  uint16_t pulseLen = map (percent, -100, 100, servoMins[0], servoMaxs[0]);&#xA;  move (0, pulseLen, seconds, groupType);&#xA;}&#xA;&#xA;void pause (double seconds)&#xA;{&#xA;  move (PAUSE_COMMAND, 0, seconds, NewGroup);&#xA;}&#xA;&#xA;void restoreHomePositions (double seconds)&#xA;{&#xA;  rotateRobot (0, seconds, NewGroup);&#xA;  bendUpperArm (0, seconds, WithPrevious);&#xA;  bendForeArm (0, seconds, WithPrevious);&#xA;  rotateForeArm (0, seconds, WithPrevious);&#xA;  bendWrist (0, seconds, WithPrevious);&#xA;  rotateWrist (0, seconds, WithPrevious);&#xA;&#xA;}&#xA;&#xA;&#xA;//This is where the program goes!&#xA;&#xA;void program ()&#xA;{&#xA;    //Available commands&#xA;  /*rotateWrist (where, seconds, groupType)  &#xA;  bendWrist (where, seconds, groupType)&#xA;  rotateForeArm (where, seconds, groupType)&#xA;  bendForeArm (where, seconds, groupType)&#xA;  bendUpperArm (where, seconds, groupType)&#xA;  rotateRobot (where, seconds, groupType)  &#xA;  pause (seconds)*/&#xA;&#xA;  //example 1 -- rotates the wrist servo 100% over 2 seconds,&#xA;  //starting a new transition group.&#xA;  rotateWrist (100, 2);&#xA;  //example 2 -- bends the upper arm and the forearm at the same time&#xA;  //moving both 45% over 1.5 seconds.&#xA;  bendUpperArm (45, 1.5);&#xA;  bendForeArm (45, 1.5, WithPrevious);&#xA;  bendForeArm(45, 1.7, WithPrevious);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;  //To start a new group, the groupType should be either NewGroup or left blank&#xA;  //Any call after that set to WithPrevious will start the transition at the&#xA;  //same time as the first transition in the group.&#xA;  //As soon as a new call is made with a NewGroup groupType, a new transition group is m&#xA;// End of your program&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26007" LastActivityDate="2017-07-23T09:50:59.260" Title="Absolute noob looking for troubleshooting help" Tags="|arduino-nano|adafruit|robotics|wires|" AnswerCount="2" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="28653" PostTypeId="2" ParentId="28630" CreationDate="2016-08-24T05:02:24.243" Score="4" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;How much time does an Arduino Uno or Mega need to only call a function.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Why do you want to know? This sounds like an &lt;a href=&quot;http://xyproblem.info/&quot; rel=&quot;nofollow&quot;&gt;X-Y problem&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It will vary, depending on a lot of things. &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The number of arguments, because the more arguments the more work involved. Plus if an argument involves copying it might invoke a copy constructor.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Whether or not the compiler in-lines the function. If it is in-lined (copied into the other function) then there is less work, for example the compiler doesn't need to generate &lt;code&gt;call&lt;/code&gt; and &lt;code&gt;ret&lt;/code&gt; instructions.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;What the function does. The more things a function does, the more registers the compiler may have to &lt;code&gt;push&lt;/code&gt; and then &lt;code&gt;pop&lt;/code&gt; afterwards to save the state of registers which had useful information in them, outside the called function.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The size of the arguments. Longer arguments take longer to copy onto the stack, or put into registers. For example, &lt;code&gt;long&lt;/code&gt; arguments will take longer than &lt;code&gt;char&lt;/code&gt; arguments.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How much time does a micro-controller need to read a declared variable?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Again, it varies. It depends on the variable size, and whether or not it is already in a register. If the variable happens to be in a register at the time, you could argue it takes zero time to read it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How to determine this values?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The sensible thing to do is to time some test code. Here's an example from another thread:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  Serial.println ();&#xA;&#xA;  unsigned long start, finish;&#xA;&#xA;  start = micros ();&#xA;  for (byte i = 0; i &amp;lt; 100; i++)&#xA;    digitalWrite (13, HIGH);&#xA;  finish = micros ();&#xA;&#xA;  Serial.print (&quot;Time taken to do digitalWrites: &quot;);&#xA;  Serial.println (finish - start);&#xA;  Serial.flush ();&#xA;&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;In the middle of the code there I time doing digitalWrite 100 times. By dividing the resulting output by 100, I can work out how long each digitalWrite takes.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You don't normally need to know how long, exactly, it takes to read variables, and call functions. Either your code works at an acceptable speed, or it doesn't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to answer this question on test code may give meaningless results. For example, in my test code the compiler may have in-lined the digitalWrite call. But if I use digitalWrite in many places it will no longer in-line it, which means the timing figures are now incorrect.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The Questions is how much time the millis() and micros() functions need to finish their work, so the measurement is accurate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If that was what you wanted to know, it would have been better to ask that exact question. That saves us waffling on about copy constructors and so on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tested with the code below, which calls &lt;code&gt;micros()&lt;/code&gt; and saves the results to a variable &lt;code&gt;foo&lt;/code&gt;. I made it volatile so that the compiler wouldn't be tempted to optimize away the saving altogether (because it isn't used anywhere else).&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  pinMode (13, OUTPUT);&#xA;  PORTB = 0;&#xA;  }  // end of setup&#xA;&#xA;volatile unsigned long foo;&#xA;&#xA;void loop ()&#xA;  {&#xA;  PINB = bit (PB5);   // toggle D13&#xA;  foo = micros ();&#xA;  PINB = bit (PB5);   // toggle D13&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I measured 3.380 µs on my oscilloscope for the time when D13 is high. That would be 54 clock cycles. A couple (only) would be the time taken to toggle D13. Thus you can probably reckon &lt;code&gt;micros()&lt;/code&gt; in general as taking 3.38 µs.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Changing it to call &lt;code&gt;millis()&lt;/code&gt; instead, it only takes 1.760 µs (28 clock cycles). This is probably because all &lt;code&gt;millis()&lt;/code&gt; does is return a variable which has already been calculated (in the timer ISR).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Test done on an Arduino Uno running at 16 MHz.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-09-03T01:18:42.757" LastActivityDate="2016-09-03T01:18:42.757" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28654" PostTypeId="1" AcceptedAnswerId="30548" CreationDate="2016-08-24T06:45:02.113" Score="5" ViewCount="4366" Body="&lt;p&gt;I have an Arduino data collector with a W5100 module (see bottom of picture). Simple fixed IP connection:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; &#xA; byte ip[] = { 192, 168, 1, 242 };&#xA; Ethernet.begin(mac,ip);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This works with my old routers (Asus WL500, TP-Link MR3420), but fails to connect when plugged in a gigabit switch or my new router (D-Link DWR-116). The connection LED on the new devices does not lit up or blinks slowly, showing repeated connection attempts. So the W5100 fails to make the physical connection.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I made it work by adding my 10-year old Surecom switch to the mix, but wonder what the problem could be. Is there some cable configuration that is used by the W5100 but have been removed from these new network devices? (Not sure if the cable is cross or straight, trying another cable is messy, the whole thing is built in the wall.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/svMaW.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/svMaW.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26011" LastActivityDate="2020-02-17T11:41:30.113" Title="WizNet W5100 not connecting to modern switches and routers" Tags="|ethernet|" AnswerCount="3" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28657" PostTypeId="1" CreationDate="2016-08-24T10:10:17.683" Score="1" ViewCount="360" Body="&lt;p&gt;Help please&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to connect an Arduino Due via a SPI bus to a MAXIM31855 thermocouple sensing chip. I am using Arduino IDE version 1.6.11.&#xA;The problem I am having is that the code will only read the SPI bus once, it will not loop, regardless of how many times I call the function to read the SPI bus. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected the clock and the MISO to the pin header just below the SAM processor chip its labeled SPI and I have connected the CS to pin 4.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each time I press the reset button on the Due, the SPI will read once. I have confirmed this by using a Salae logic analyser. The Due doesn't lock up as other functions continue normally, it simply will not repeat the SPI read.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 4 bytes that are returned from the Max are consistent with the specification for the chip as are the timing of the clk (4kHz) and the MISO logic levels (there is no MOSI in this MAX chip).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If anyone has a clue as to why this will not loop I would appreciate their input.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;//Give convenient names to the control pins&#xA;&#xA;#define slaveAPin 10&#xA;// set up the speed, data order and data mode&#xA;SPISettings settingsA(4000000, MSBFIRST, SPI_MODE1);&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  pinMode(slaveAPin,OUTPUT);&#xA;  SPI.begin(slaveAPin);&#xA;&#xA;}&#xA;&#xA;uint8_t  val1, val2, val3, val4;&#xA;&#xA;void loop() {&#xA;// read four bytes from device A&#xA; Serial.println(ReadTemp());&#xA; delay(1000);&#xA;&#xA;&#xA; }&#xA;&#xA;uint8_t ReadTemp(void)&#xA;{&#xA;  SPI.beginTransaction(settingsA);&#xA;  digitalWrite (slaveAPin, LOW);&#xA;  // reading only, so data sent does not matter&#xA;  val1 = SPI.transfer(slaveAPin,0x00,SPI_CONTINUE);&#xA;  val2 = SPI.transfer(slaveAPin,0x00,SPI_CONTINUE);&#xA;  val3 = SPI.transfer(slaveAPin,0x00,SPI_CONTINUE);&#xA;  val4 = SPI.transfer(slaveAPin,0x00,SPI_LAST);&#xA;  digitalWrite (slaveAPin, HIGH);&#xA;  SPI.endTransaction();&#xA;&#xA;  return val2;&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerDisplayName="RDEPTYLTD" LastActivityDate="2016-08-24T10:59:15.133" Title="Arduino Due SPI will not loop" Tags="|spi|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28663" PostTypeId="1" AcceptedAnswerId="28673" CreationDate="2016-08-24T13:30:46.767" Score="2" ViewCount="536" Body="&lt;p&gt;I guess its a dumb question but couldnt find anything about it online. I know its possible to supply the AREF pin with 3.3 V to increase the ADC resolution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the project i am working on the analog voltage i will be reading will be between 0 and 2.2 and the increased resolution is a must. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I know i can use another board that has a 12 bit resolution but i really would like to make do with Uno. So i wonder if i can set an analog pin to output 2.3 V and feed it to the Aref pin.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If thats not possible please let me know why, so i can increase my knowledge&lt;/p&gt;&#xA;" OwnerUserId="26024" LastActivityDate="2016-08-24T17:03:29.250" Title="Can i supply the AREF pin with an Analog pin from the same board?" Tags="|arduino-uno|analogwrite|analogreadresolution|analogreference|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28664" PostTypeId="2" ParentId="28663" CreationDate="2016-08-24T13:58:28.017" Score="0" Body="&lt;p&gt;The output voltage of the &quot;analog outputs&quot; (which are actually PWM) are dependent on supply voltage and so are not a good choice where precision is required. Consider using either an integrated voltage reference (e.g. TL431) or a constant-current source feeding a zener diode instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-08-24T13:58:28.017" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28665" PostTypeId="2" ParentId="18575" CreationDate="2016-08-24T14:04:16.647" Score="0" Body="&lt;p&gt;We found that many of the problems with the ESP - Arduino Uno serial software integration had to do with incompatible baudrate. We created this short tutorial (including a Github library) which you are welcome to test and see if it solves these issues. &lt;a href=&quot;http://www.instructables.com/id/Simple-ESP8266-Arduino-Uno-Software-Serial-Integra/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Simple-ESP8266-Arduino-Uno-Software-Serial-Integra/&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26027" LastActivityDate="2016-08-24T14:04:16.647" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28671" PostTypeId="1" AcceptedAnswerId="28677" CreationDate="2016-08-24T16:24:27.017" Score="0" ViewCount="1698" Body="&lt;p&gt;I'm new to gyroscope and accelerometer and am working on my project to control servo with Arduino Uno R3 based on the reading from InvenSense MPU6050 6DOF gyroscope and accelerometer. I've found the a same sheet of code from different websites. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Website 1_http://www.projehocam.com/wp-content/uploads/mpu6050-2-servo.txt&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Website 2_http://www.instructables.com/files/orig/FLY/GZAL/IDIN48PC/FLYGZALIDIN48PC.ino&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And from this part of the code, I couldn't understand the servo.write part...&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;    #ifdef OUTPUT_READABLE_YAWPITCHROLL&#xA;        // display Euler angles in degrees&#xA;        mpu.dmpGetQuaternion(&amp;amp;q, fifoBuffer);&#xA;        mpu.dmpGetGravity(&amp;amp;gravity, &amp;amp;q);&#xA;        mpu.dmpGetYawPitchRoll(ypr, &amp;amp;q, &amp;amp;gravity);&#xA;        Serial.print(&quot;ypr\t&quot;);&#xA;        Serial.print(ypr[0] * 180/M_PI);&#xA;        Serial.print(&quot;\t&quot;);&#xA;        Serial.print(ypr[1] * 180/M_PI);&#xA;        myservoY.write(int(ypr[1] * -180/M_PI)+90);   // Rotation around Y&#xA;        Serial.print(&quot;\t&quot;);&#xA;        Serial.println(ypr[2] * 180/M_PI);&#xA;        myservoX.write(int(ypr[2] * 180/M_PI)+90);   // Rotation around X&#xA;    #endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is the operation (int(ypr[1] * -180/M_PI)+90) ??&lt;/p&gt;&#xA;" OwnerUserId="25968" LastActivityDate="2016-08-24T20:37:34.347" Title="Arduino MPU6050 Control 2 Servo" Tags="|arduino-uno|servo|mpu6050|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28673" PostTypeId="2" ParentId="28663" CreationDate="2016-08-24T17:03:29.250" Score="3" Body="&lt;p&gt;With an input voltage between 0 and 2.2 V, you can use a 2:1 voltage divider to cut the voltage in half.  In your code, use &lt;a href=&quot;https://www.arduino.cc/en/Reference/AnalogReference&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;analogReference(INTERNAL)&lt;/code&gt;&lt;/a&gt; to set the analog reference voltage to 1.1 V.  The 1.1 V internal reference voltage is created by a bandgap circuit so is reasonably accurate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To make the &lt;a href=&quot;https://en.wikipedia.org/wiki/Voltage_divider&quot; rel=&quot;nofollow&quot;&gt;voltage divider&lt;/a&gt;, put two equal resistors (eg 10KΩ each) in series; connect one end of the series to your input voltage, the other end to ground, and the mid-point to an analog input pin.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-08-24T17:03:29.250" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28675" PostTypeId="2" ParentId="19875" CreationDate="2016-08-24T19:26:59.533" Score="1" Body="&lt;p&gt;Your safest option is to use an opto-isolator. Connect the LED side in parallel with the load with a suitable resistor, then the transistor side becomes, effectively, a button connected to the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as the car is concerned you have just connected an LED. As far as the Arduino is concerned you have a button connecting to ground. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It provides complete isolation of the car's electrics from your Arduino.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-24T19:26:59.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28677" PostTypeId="2" ParentId="28671" CreationDate="2016-08-24T20:37:34.347" Score="0" Body="&lt;p&gt;&lt;code&gt;ypr&lt;/code&gt; contains the Yaw, Pitch and Roll. It is provided in radians.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Servo.write takes degrees.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Multiplying radians by 180/PI converts it to degrees.  Adding 90 centralises it around the 90 degree point (half way) of the servo.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-24T20:37:34.347" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28678" PostTypeId="1" CreationDate="2016-08-24T21:03:00.117" Score="0" ViewCount="685" Body="&lt;p&gt;I have several questions on externally powering the Arduino Uno&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;I have a 7.2V power source that is 6 rechargeable AA batteries together, 1.2V and 1300mA each. If i use a 4.70 and 1.5 ohm resistors together to give 1.16 amps, can I power the arduino with this?&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Can I power a servo off the Arduino 5V rail If i place a 470uF or more capacitor alongside it?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Will anything heat or blow up or am I just being paranoid like always?&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26040" OwnerDisplayName="Kr4t0s" LastEditorUserId="10394" LastEditDate="2016-08-31T11:18:16.103" LastActivityDate="2016-08-31T11:18:16.103" Title="externally powering the Arduino questions" Tags="|arduino-uno|power|" AnswerCount="4" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28679" PostTypeId="2" ParentId="28678" CreationDate="2016-08-24T21:30:37.363" Score="3" Body="&lt;p&gt;I am guessing that you are thinking of dividing down the battery voltage from 7.2V down to 7.2*(4.7)/(4.7+1.5) = 5.5V. This is generally a bad idea for a few reasons.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;The battery voltage will not be a constant 7.2V. When they are fully charged it could be even higher. As they discharge they could drop significantly and your Arduino POR (power-on-reset) circuit would potentially shut the board down before the batteries are fully discharged&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;The batterys' internal resistance would probably drop the output voltage considerably once the resistors try to draw 1A of current. It might even collapse the voltage to some unusable value. &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Even if the battery internal resistance is very low and even if the Arduino is not drawing much power (or even off) you will always be drawing ~1A of current from the batteries. This will rapidly drain your batteries and will also heat them up from their internal resistance. Not to mention your external resistors better be able to handle &gt; 5W or so. Conclusion: lots of unnecessary heat and power loss.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;To answer your other question, assuming the servo is low power and the Arduino power supply is up, you could power it from the Arduino 5V supply (not your batteries).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need to use batteries to power an Arduino, I would highly recommend a power regulator to produce a stable output voltage to power your Arduino.&lt;/p&gt;&#xA;" OwnerDisplayName="Daniel V" LastActivityDate="2016-08-24T21:30:37.363" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28680" PostTypeId="2" ParentId="28678" CreationDate="2016-08-24T21:51:58.450" Score="1" Body="&lt;p&gt;Your typical Arduino has a built-in 5V regulator. Just plug the batteries into the barrel jack - that is what it is for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't have a barrel jack on your Arduino (it's one of the little ones?) then you will need a &lt;em&gt;voltage regulator&lt;/em&gt;. For battery usage you want a switching &quot;buck&quot; regulator.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find them cheaply enough under the name &quot;UBEC&quot; (Universal Battery Elimination Circuit) and are used for model aircraft etc.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-24T21:51:58.450" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28681" PostTypeId="2" ParentId="28678" CreationDate="2016-08-24T22:16:47.813" Score="0" Body="&lt;p&gt;You can connect the batteries fine into Vin or the barrel jack, however you will run into the issue that your battery voltage will sag. This will vary on what chemistry batteries you are using, NiMh voltage discharge sits on a bit of a plateau around 1.2V typically, alkaline has more of a gentle curve downwards and then drops off quite sharply around or below 1V.&lt;/p&gt;&#xA;&lt;p&gt;The reason this is an issue is highlighted on the Arduino Uno page itself:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Input Voltage (recommended)   7-12V&lt;/p&gt;&#xA;&lt;p&gt;Input Voltage (limit)  6-20V&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;and&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The issue here is the dropout of the onboard regulator.&lt;/p&gt;&#xA;&lt;p&gt;The solution is to use your own external regulator and connect it to the 5VDC pin.&lt;/p&gt;&#xA;&lt;p&gt;You can use:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;An external swithcmode DC-DC converter, you would be ideally after a buck boost. DC-DC converters are available from ICs for a full ground up DIY design to available on board modules and daughterboards and fully assembled circuits. Regarding the other answer a BEC or UBEC may not be suitable as typically they are buck converters and have higher minimum output voltages than that required by the OP, some however with careful selection may be alright to use.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Adafruit off the shelf buck-boost module:&#xA;&lt;a href=&quot;https://www.adafruit.com/products/2190&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.adafruit.com/products/2190&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;&lt;p&gt;An external linear LDO regulator, ideally with as low dropout as possible. You will need to pick this part to suit your input voltage range, this may be difficult as extremely low dropout parts are typically low current and not suitable if wanting to drive a servo. Something like a REG103 for example may work, depending on the dropout an LDO linear regulator may work down to around 5.2~5.3VDC minimum, which should be okay for most of the capacity of the batteries.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;A premade shield, some may work for you, some to give you an idea of what is required.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;DC-DC converter for battery shield:&#xA;&lt;a href=&quot;https://www.wayneandlayne.com/projects/battery-booster-shield/&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.wayneandlayne.com/projects/battery-booster-shield/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Adafruit has a lithium battery shield such as does Sparkfun (not enough rep for more links)&lt;/p&gt;&#xA;&lt;p&gt;Itead has a AAA battery shield also.&lt;/p&gt;&#xA;&lt;p&gt;Options here will depend on your design ability and assembly skills as to if you can DIY or need off the shelf.&lt;/p&gt;&#xA;&lt;p&gt;Your servo will be fine connected to the external regulator as long as the option you use is rated to supply enough current.&lt;/p&gt;&#xA;" OwnerUserId="26039" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-24T22:38:51.407" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28682" PostTypeId="2" ParentId="28678" CreationDate="2016-08-24T22:25:11.440" Score="2" Body="&lt;p&gt;This question has been answered on electronics.stackexchange, e.g. &lt;a href=&quot;https://electronics.stackexchange.com/questions/252742/how-to-provide-separate-voltages-from-a-common-power-source/252793&quot;&gt;How to provide separate voltages from a common power source&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Daniel V has explained the main issues. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 'killer' for most people is the resistors are always across the battery, and so they alone will take over 1A from the battery pack continuously, and hence run it flat in just over an hour. Further, they need to dissipate over 5W of heat, so they aren't that cheap either.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A NiMh rechargeable battery will have a voltage of about 1.4V when it's fully charged, dropping to under 1V before it is exhausted. So that would mean the resistor network needs to output 5V or less with an input voltage from 6x1.4V=8.2V down to under 6x1V=6V. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the resistor ratio would need to handle 8.2V in and produce 5V out, and then 6V in would produce 3.66V. My reading of the ATmega sec is it might struggle to run at 16MHz at that 3.66V input voltage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You might try to make a resistor-based voltage divider more efficient by increasing the total resistance. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, as explained on the electronics.stackexchange, the load presented by the ATmega on an Arduino varies dynamically, from microsecond to microsecond, so it is very hard to choose resistors which would maintain the voltage within a reasonable operating range, while the current passing through the Arduino varies so much.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An Arduino has an on-board voltage regulator. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, the typical 5V regulator on generic Arduino's have a drop-out voltage of 2V, i.e. the input voltage needs to be 7V or more. That means most of that battery pack capacity will provide less than 7V, so the voltage will start to drop. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;might&lt;/em&gt; be lucky and the on-board regulator will 'track' the input voltage down. That means it will fail below 5V as its input drops below 7V. You would need to test your Arduino; there is no guarantee that the regulator on the board does this. Further, it might struggle to run at 16MHz as the voltage approaches 4V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, if this is just a one-off hobby project, it might be reasonable to try that. However, if other people are going to use it, it might be too risky.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The ATmega can be run with anything between 5V and 1.8V if the clock is slow enough. Also you'd need to either modify the electronics, or change the bootloader of the Arduino to ensure it runs at a much lower clock frequency. So it is possible to run at a lower voltage than 5V, by changing the bootloader, but it seems like a strange exercise. Then a resistor divider (which wastes a lot of energy), or the on-board regulator could be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Instead, look at a Low-Drop-Out (LDO) voltage regulator. There are parts which will regulate anything from 8.4V down to 6V, or less, down to 5V. An Arduino alone uses well under 100mA, it is the electronics it is driving which uses the majority of an Arduino's specified 500mA.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you look for a voltage regulator, which will take 9V in (as a safety margin) with a drop-out voltage of 0.7V (lots at this spec), 5V out, and 250mA or better. Most electronics distributors have a product selector which will help you find this, and you may find small ready-made modules which do exactly this (but not an LM111xx).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You don't post a link to the servo you're using. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Low-cost servo's typically take a lot of current as they move. I've measured some using a proper bench power-supply unit (bench PSU). They typically take well over 1A for periods long enough for me to see it happen. So the power supply would likely need to supply more than 1A for short periods, i.e. 10's of milliseconds. You will need quite a substantial capacitor to handle that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the servo, you might be better to use 4xNiMh to power the servo directly, without any intermediate regulation, and a more modest capacitor. The ground (-) of that power supply needs to be connected to the GND of the Arduino so that the servo signal from the Arduino will drive the servo correctly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that case, you might use a low-cost (ebay) DC-DC step up (boost) switching regulator to provide the 5V to the Arduino. Their are lots available which are intended to power USB devices at 5V.&lt;/p&gt;&#xA;" OwnerUserId="3493" LastEditorUserId="-1" LastEditDate="2017-04-13T12:33:09.983" LastActivityDate="2016-08-24T22:41:01.727" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28685" PostTypeId="1" CreationDate="2016-08-24T23:22:07.550" Score="2" ViewCount="1769" Body="&lt;p&gt;It all started when I tried connecting an hm10-nano to a relay board which is Bluetooth enabled.  Here is my nano with the hm10 module:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/pzIwe.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/pzIwe.jpg&quot; alt=&quot;nano-hm10&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And here is the relay board's BT module, which looks like an hm12:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/2Jgox.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/2Jgox.jpg&quot; alt=&quot;relay&amp;#39;sBT&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I started by connecting the nano-hm10 to my mac and using the Arduino IDE to send the module commands.  The hm12 has a mac for ble and another for edr:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ble:00-0e-0b-00-75-12&#xA;edr:00-0e-0e-00-75-12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hm10 does connect because:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I get a steady blue led on the hm10 after AT+COmacble&lt;/li&gt;&#xA;&lt;li&gt;I get the macble from the hm10 module after AT+RADD?&lt;/li&gt;&#xA;&lt;li&gt;I hear the relay (channel1) open on the relay board after AT+COmacble&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;When I try the following steps -&gt; I get these results&#xA;1. Unplug relay board -&gt; hm10 blue blinking&#xA;2. Plug relay board -&gt; hm10 blue steady, relay BT module blue led steady&#xA;3. AT commands to hm10 thru serial monitor stop working (expected)&#xA;4. AT+CO000e0e007512 to hm10 -&gt; turns on relay 1 for some reason&#xA;5. Unplug relay -&gt; RADD on hm10 = 00-0e-0b-00-75-12 instead of 00-0e-0e-00-75-12&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My questions are:&#xA;A. Is it possible to send data from an hm10 to hm12?&#xA;B. Why does the relay get activated when I connect to the hm12-relay board?&#xA;C. I just realized my sketch's bluetooth.print() sends a command from the nano to the hm10, not to from the hm10 to the hm12.  How can I send the data from the nano to the hm12?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Sketch:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;lt;SoftwareSerial.h&amp;gt;&#xA;int bluetoothTx = 10;  // TX-O pin of bluetooth&#xA;int bluetoothRx = 11;  // RX-I pin of bluetooth&#xA;SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);&#xA;void setup(){&#xA;  Serial.begin(9600);  // Begin the serial monitor at 9600bps&#xA;  delay(200);&#xA;  bluetooth.begin(9600);  // Start bluetooth serial at 9600&#xA;  Serial.print(&quot;send...&quot;);&#xA;  bluetooth.print(&quot;AT&quot;);&#xA;    bluetooth.print(&quot;110&quot;); //open relay 1&#xA;    delay(2000);&#xA;  bluetooth.print(&quot;100&quot;); //close relay 1&#xA;}&#xA;void loop(){&#xA;  if(bluetooth.available()){&#xA;    Serial.print((char)bluetooth.read());&#xA;  }&#xA;  if(Serial.available()){&#xA;    bluetooth.print((char)Serial.read());&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="14195" OwnerDisplayName="marciokoko" LastEditorUserId="37523" LastEditDate="2019-06-26T19:04:07.953" LastActivityDate="2019-06-26T19:04:07.953" Title="Sending data from Arduino w/HM10 to relay board with hm12" Tags="|bluetooth|arduino-nano|" AnswerCount="0" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="28689" PostTypeId="1" CreationDate="2016-08-25T05:26:27.223" Score="0" ViewCount="3685" Body="&lt;p&gt;I am new in PIC programming&lt;/p&gt;&#xA;&#xA;&lt;p&gt;my question is, how can i communicate arduino UNO with  PIC18f4550. i am using &lt;a href=&quot;http://g01.a.alicdn.com/kf/HTB11cl0KXXXXXb.XVXXq6xXFXXXZ/-font-b-PIC-b-font-font-b-Development-b-font-font-b-Board-b-font.jpg&quot; rel=&quot;nofollow&quot;&gt;THIS&lt;/a&gt; programmer board for PIC controller and it has a builtin RS232 serial interface.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can any body tell me how to communicate between them. I want to communicate in such a way that only Rx &amp;amp; Tx pins and the power pins of arduino will be used.&lt;/p&gt;&#xA;" OwnerUserId="25944" LastActivityDate="2016-08-25T07:32:16.520" Title="How to serially communicate arduino uno to PIC18f4550?" Tags="|arduino-uno|serial|communication|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28691" PostTypeId="2" ParentId="28689" CreationDate="2016-08-25T07:32:16.520" Score="1" Body="&lt;p&gt;yeah you can quite easily do the Serial communication between Arduino and PIC Microcontroller. You need to connect the below pins:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino TX will be connected to PIC RX.&lt;/li&gt;&#xA;&lt;li&gt;Arduino RX will be connected to PIC TX.&lt;/li&gt;&#xA;&lt;li&gt;GND of Arduino must be connected to GND of PIC.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Next thing you need to remember is to have same baud rate for both Arduino and PIC. Now you should check these two posts:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;Arduino Serial Communication&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://learn.mikroe.com/ebooks/picmicrocontrollersprogramminginassembly/chapter/serial-communication-modules/&quot; rel=&quot;nofollow&quot;&gt;PIC Serial Communication&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;First one is explaining the Serial Communication of Arduino while the second one is Serial Communication of PIC Microcontroller. You should also read &lt;a href=&quot;http://www.theengineeringprojects.com/2015/06/serial-port.html&quot; rel=&quot;nofollow&quot;&gt;What is Serial Port?&lt;/a&gt; to get more idea about Serial communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I hope they will help you out. If you still got into some issues then let me know.&lt;/p&gt;&#xA;" OwnerUserId="7523" LastActivityDate="2016-08-25T07:32:16.520" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28692" PostTypeId="1" AcceptedAnswerId="28746" CreationDate="2016-08-25T10:35:19.033" Score="0" ViewCount="1736" Body="&lt;p&gt;I recently bought an Arduino Nano ( a clone actually), I installed the CH340G drivers for it and got it working perfectly fine... Played around with it for a while and then kept it aside...&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now after sometime I get time to play with it again, I was actually trying to power it with my 11.1V 2200mAh 8C LiPo battery. So I plug the JST connector to the Vin and GND pin and the LED doesn't light up. I noticed that I had plugged it in the wrong way and I immediately unplugged it. Next I make another attempt and this time I plugged the pins entirely somewhere else, again I disconnect quickly. The third time I connect it properly and the power LED lights up (phew...)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I move on to my computer to program it but the Arduino IDE is stuck at uploading. It was working fine before, when I hit upload, the RX LED glows &lt;em&gt;VERY&lt;/em&gt; dimly and the board just stays like that. Only the power LED glows up, not even the LED on pin 13 glows up.&lt;br&gt;&#xA;Uploading to a UNO works perfectly fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the error I get after a while-&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;avrdude: stk500_recv(): programmer is not responding&lt;br&gt;&#xA;  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x7d&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Did I burn my board? Or is it just a bootloader issue?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastActivityDate="2016-08-26T14:07:16.813" Title="Arduino Nano stuck on uploading" Tags="|arduino-ide|arduino-nano|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28694" PostTypeId="1" CreationDate="2016-08-25T10:14:50.080" Score="0" ViewCount="1399" Body="&lt;p&gt;I'm using arduino Ethernet shield 2 form arduino.org and the arduino IDE 1.7.10 also from arduino.org &#xA;the code is : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Dhcp.h&amp;gt;&#xA;#include &amp;lt;Dns.h&amp;gt;&#xA;#include &amp;lt;Ethernet2.h&amp;gt;&#xA;#include &amp;lt;EthernetClient.h&amp;gt;&#xA;#include &amp;lt;EthernetServer.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp2.h&amp;gt;&#xA;#include &amp;lt;Twitter.h&amp;gt;&#xA;#include &amp;lt;util.h&amp;gt;&#xA;&#xA;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;EthernetUdp2 udp;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;and it is giving the following Error : &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.7.10 (Windows 8.1), Board: &quot;Arduino Uno&quot;&#xA;&#xA;UDPMessages002.ino:14:1: error: 'EthernetUdp2' does not name a type&#xA;&#xA;Error compiling.&#xA;&#xA;  This report would have more information with&#xA;  &quot;Show verbose output during compilation&quot;&#xA;  enabled in File &amp;gt; Preferences.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;after Enabling Show verbose output I got :&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Arduino: 1.7.10 (Windows 8.1), Board: &quot;Arduino Uno&quot;&#xA;&#xA;Build options changed, rebuilding all&#xA;&#xA;Using library Ethernet2 in folder: C:\Program Files\ArduinoOrg\libraries\Ethernet2 &#xA;&#xA;Using library SPI in folder: C:\Program Files\ArduinoOrg\hardware\arduino\avr\libraries\SPI &#xA;&#xA;&#xA;&#xA;C:\Program Files\ArduinoOrg/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\ArduinoOrg\hardware\arduino\avr\cores\arduino -IC:\Program Files\ArduinoOrg\hardware\arduino\avr\variants\standard -IC:\Program Files\ArduinoOrg\libraries\Ethernet2\src -IC:\Program Files\ArduinoOrg\hardware\arduino\avr\libraries\SPI C:\Users\friend\AppData\Local\Temp\build8617491196975133384.tmp\UDPMessages002.cpp -o C:\Users\friend\AppData\Local\Temp\build8617491196975133384.tmp\UDPMessages002.cpp.o &#xA;&#xA;UDPMessages002.ino:14:1: error: 'EthernetUdp2' does not name a type&#xA;&#xA;Error compiling.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;any Help please &lt;/p&gt;&#xA;&#xA;&lt;p&gt;These libraries came with the IDE and were not added by me and all the includes &#xA;were added automatically after using Sketch --&gt; Import Library --&gt; Ethernet2 &lt;/p&gt;&#xA;" OwnerUserId="26073" OwnerDisplayName="jad_obeid" LastActivityDate="2017-02-22T16:04:28.083" Title="EthernetUdp2 does not name a type" Tags="|ethernet|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28695" PostTypeId="2" ParentId="28694" CreationDate="2016-08-25T12:14:59.183" Score="1" Body="&lt;p&gt;The error you see, &lt;code&gt;'EthernetUdp2' does not name a type&lt;/code&gt;, means exactly that - there is no type &lt;code&gt;EthernetUdp2&lt;/code&gt; defined.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look at the source of &lt;a href=&quot;https://github.com/adafruit/Ethernet2/blob/master/src/EthernetUdp2.h&quot; rel=&quot;nofollow&quot;&gt;EthernetUdp2.h&lt;/a&gt;, you'll see that the class declaration is &lt;code&gt;EthernetUDP&lt;/code&gt;. See:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;class EthernetUDP : public UDP {&#xA;    private:&#xA;        // Private members...&#xA;    public:&#xA;        EthernetUDP();  // Constructor&#xA;&#xA;      // Public members...&#xA;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;class EthernetUDP : public UDP&lt;/code&gt; defines a class called &lt;code&gt;EthernetUDP&lt;/code&gt; that inherets from the base class &lt;code&gt;UDP&lt;/code&gt;. The constructor is what gets called when you instantiate a new object of type &lt;code&gt;EthernetUDP&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Replace the line &lt;code&gt;EthernetUdp2 udp;&lt;/code&gt; in your code with &lt;code&gt;EthernetUDP udp;&lt;/code&gt; and it should work because the types will match. For reference:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Dhcp.h&amp;gt;&#xA;#include &amp;lt;Dns.h&amp;gt;&#xA;#include &amp;lt;Ethernet2.h&amp;gt;&#xA;#include &amp;lt;EthernetClient.h&amp;gt;&#xA;#include &amp;lt;EthernetServer.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp2.h&amp;gt;&#xA;#include &amp;lt;Twitter.h&amp;gt;&#xA;#include &amp;lt;util.h&amp;gt;&#xA;&#xA;&#xA;#include&amp;lt;SPI.h&amp;gt;&#xA;&#xA;&#xA;EthernetUDP udp; // &amp;lt;---- This works&#xA;&#xA;void setup() {&#xA;  // put your setup code here, to run once:&#xA;&#xA;}&#xA;&#xA;void loop() {&#xA;  // put your main code here, to run repeatedly:&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="16724" LastEditorUserId="16724" LastEditDate="2016-08-26T11:10:43.240" LastActivityDate="2016-08-26T11:10:43.240" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28696" PostTypeId="2" ParentId="23115" CreationDate="2016-08-25T13:04:27.417" Score="0" Body="&lt;p&gt;I have been always frustrated from the missing double (64bit) type in Arduino world and hence the problem with properly calculating GPS distance, bearing and destination point.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The following library uses Float64 &amp;amp; Math64 libs and also adds some fast and very fast implementations of trigonometric functions and fast and regular versions of GPS GPS distance, bearing and destination point.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Feel free to use it - and any help in improving it is welcome !&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/vtomanov/Gps64&quot; rel=&quot;nofollow&quot;&gt;https://github.com/vtomanov/Gps64&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="19225" LastActivityDate="2016-08-25T13:04:27.417" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28698" PostTypeId="1" AcceptedAnswerId="28699" CreationDate="2016-08-25T13:25:18.333" Score="1" ViewCount="94" Body="&lt;p&gt;I know this question is not so releavant as it does not include any research, but I am in search of a barcode scanner that i can easily interface with arduino and get output from it but unfortunately the Scanner models which are listed from the people doing the same stuff are not easily available in India. So if anyone knows which barcode scanner would best suit the requirement please suggest.&#xA;Availabilty in &lt;strong&gt;Indian&lt;/strong&gt; market would be much appreciated :)&lt;/p&gt;&#xA;" OwnerUserId="26057" LastActivityDate="2016-08-25T13:59:29.197" Title="Which Barcode Scanner to be used with arduino in India" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28699" PostTypeId="2" ParentId="28698" CreationDate="2016-08-25T13:59:29.197" Score="2" Body="&lt;p&gt;Most barcode scanners behave just like a regular keyboard. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Try getting one with a PS2 port. You can pretty easily interface a PS2 keyboard to an Arduino. There are already libraries for it. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-25T13:59:29.197" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28700" PostTypeId="1" CreationDate="2016-08-25T15:08:12.533" Score="0" ViewCount="278" Body="&lt;p&gt;avrdude: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;no programmer has been specified on the command line or the config&#xA;  file&#xA;           Specify a programmer using the -c option and try again&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="26061" LastEditorDisplayName="user24204" LastEditDate="2016-08-27T22:37:32.387" LastActivityDate="2017-04-27T00:40:48.687" Title="Uploading a sketch causing an error message in Arduino Uno" Tags="|arduino-uno|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28701" PostTypeId="2" ParentId="28700" CreationDate="2016-08-25T16:06:53.443" Score="1" Body="&lt;p&gt;On the &quot;Tools&quot; menu choose &quot;Programmer:&quot; and specify AVRISP mkII; be sure that you've also chosen the appropriate &quot;Board:&quot; entry for the Uno.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/tBPH5.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/tBPH5.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26063" LastActivityDate="2016-08-25T16:06:53.443" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28702" PostTypeId="1" AcceptedAnswerId="28711" CreationDate="2016-08-25T16:35:08.090" Score="2" ViewCount="2469" Body="&lt;p&gt;I am using an Arduino Mega 2560 board. I have tried connecting a 115 &amp;Omega; resistor from 5V to Reset, and 10 &amp;micro;f capacitor form reset to GND (to disable autoreset), and the variables still seem to reset themselves when I unplug and replug-in the Arduino. Any way to stop this from happening?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically I am making a device that is sensitive to time, and must run for about 2 months, but if it is unplugged, it can't lose its place in time and reset the whole program. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think one alternative would be for me to have it actually write how long it has been running into a &lt;code&gt;.txt&lt;/code&gt; file on the microSD card and then verify that in the start-up... &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="26064" LastEditorUserId="6936" LastEditDate="2016-10-27T18:17:14.677" LastActivityDate="2016-10-27T18:17:14.677" Title="Is there any way I can stop the Arduino Mega 2560 from resetting all variables after losing and reconnecting power?" Tags="|arduino-mega|power|time|reset|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28703" PostTypeId="1" CreationDate="2016-08-25T16:42:32.433" Score="0" ViewCount="334" Body="&lt;p&gt;Here is the image of Ethernet shield near RJ45 socket:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/hxDeR.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/hxDeR.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;These small boxes are probably SMD capacitors which may mean, that internal board is glavanically disconnected from the UTP line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this true?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If this is true, then what will happen, if I pass &lt;code&gt;5V&lt;/code&gt; &lt;code&gt;DC&lt;/code&gt; current just into my UTP? Won't I be able to wire appropriate conductors just into Arduino power input? Won't I be able to power Arduino this way?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is about not using premade PoE splitter. I have an injector, which injects &lt;code&gt;5V&lt;/code&gt; into line.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found my injector put power to lines 4,5 and GND to 7,8. Can I take this power on Arduino side?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="6841" LastEditDate="2016-08-25T17:28:01.017" LastActivityDate="2016-08-25T17:28:01.017" Title="What if I just connect 5V DC to my UTP?" Tags="|arduino-uno|power|ethernet|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28704" PostTypeId="2" ParentId="28703" CreationDate="2016-08-25T17:05:22.747" Score="1" Body="&lt;p&gt;Not exactly. That RJ45 connector labeled HR911105A is internally connected like this:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/NQHXn.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/NQHXn.gif&quot; alt=&quot;scheme&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's possible with PoE version (but I suppose not with 5V but more like 12V or so)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or there are variants without PoE module connected but with support, that should be possible to use 5V if you wire it correctly)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use external PoE injector and extractor: &lt;a href=&quot;https://i.stack.imgur.com/JggQK.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/JggQK.jpg&quot; alt=&quot;injector/extractor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For 100Mb networks are two unused communication pairs used as power lines:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/dbGJg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dbGJg.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-25T17:12:33.013" LastActivityDate="2016-08-25T17:12:33.013" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28705" PostTypeId="1" AcceptedAnswerId="28710" CreationDate="2016-08-25T17:23:21.470" Score="1" ViewCount="897" Body="&lt;p&gt;I have 2 LED strips with 6 LEDs on each. They use a 12V power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question, how can I use them like regular LEDs using Arduino UNO? Without any MOSFETS or transistors if possible.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And can I use PWM?&lt;/p&gt;&#xA;" OwnerUserId="20381" LastEditorUserId="20381" LastEditDate="2016-08-25T18:19:28.520" LastActivityDate="2016-08-25T18:23:51.570" Title="Controlling 12v DC LED strips using Arduino UNO" Tags="|arduino-uno|led|pins|pwm|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28706" PostTypeId="2" ParentId="28702" CreationDate="2016-08-25T17:24:39.680" Score="1" Body="&lt;p&gt;Arduino Mega board has RESET-EN &quot;jumper&quot;. If you cut the trace, it won't reset MCU by DTR from USB-to-Serial chip. If you have to upload new sketch, you'll have to short it by piece of metal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is also possibility to use &lt;code&gt;.noinit&lt;/code&gt; section for storing variables, so if you don't loose power, it won't get overwritten by automatic init. However, bootloader could be messing with that memory too. So it might not help without erasing this bootloader and using ISP(SPI) interface to program it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use for example RTC (if you already have one) and it's battery backed RAM.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-08-25T17:24:39.680" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28707" PostTypeId="1" AcceptedAnswerId="29433" CreationDate="2016-08-25T17:26:36.053" Score="0" ViewCount="746" Body="&lt;p&gt;I'm doing a device to recongnize NFC cards with an Arduino UNO, a CC3000 wifi shield, and a PN532 NFC shield. That's ok.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I created a sketch with this library: &lt;a href=&quot;https://github.com/nathanchantrell/pubsubclient&quot; rel=&quot;nofollow&quot;&gt;https://github.com/nathanchantrell/pubsubclient&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I subscribed a topic /ocean/nfc/porta. When I publish a message to it, the callback function isn't called. Moreover, when it takes a card ID it publishs to a topic sometimes then don`t work more. How to solve it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Adafruit_PN532.h&amp;gt;&#xA;#include &amp;lt;Adafruit_CC3000.h&amp;gt;&#xA;#include &amp;lt;cc3000_PubSubClient.h&amp;gt;&#xA;&#xA;#define PN532_IRQ   (4)&#xA;#define PN532_RESET (3)  // Not connected by default on the NFC Shield&#xA;&#xA;char cardID[ 16 ];&#xA;&#xA;Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);&#xA;&#xA;#if defined(ARDUINO_ARCH_SAMD)&#xA;// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!&#xA;// also change #define in Adafruit_PN532.cpp library file&#xA;   #define Serial SerialUSB&#xA;#endif&#xA;&#xA;// These are the interrupt and control pins&#xA;#define ADAFRUIT_CC3000_IRQ   2  // MUST be an interrupt pin!&#xA;// These can be any two pins&#xA;#define ADAFRUIT_CC3000_VBAT  7&#xA;#define ADAFRUIT_CC3000_CS    10&#xA;&#xA;// Use hardware SPI for the remaining pins&#xA;// On an UNO, SCK = 13, MISO = 12, and MOSI = 11&#xA;Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER);&#xA;&#xA;#define WLAN_SSID       &quot;Ocean Convidado&quot;&#xA;#define WLAN_PASS       &quot;ocean2901&quot;&#xA;//#define WLAN_SSID       &quot;Ocean Lab&quot;&#xA;//#define WLAN_PASS       &quot;ocean3101&quot;&#xA;&#xA;// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2&#xA;#define WLAN_SECURITY   WLAN_SEC_WPA2&#xA;&#xA;Adafruit_CC3000_Client client;&#xA;&#xA;// We're going to set our broker IP and union it to something we can use&#xA;union ArrayToIp {&#xA;  byte array[4];&#xA;  uint32_t ip;&#xA;};&#xA;&#xA;ArrayToIp server = { 25, 0, 25, 172 };&#xA;&#xA;void callback (char* topic, byte* payload, unsigned int len) {&#xA;&#xA;&#xA;    Serial.println(F(&quot;CALLBACK&quot;));&#xA;/*&#xA;    char payload_buffer[20];&#xA;&#xA;&#xA;    if (strcmp (topic,&quot;/ocean/nfc/porta&quot;) == 0) {&#xA;&#xA;        byteToChar(payload, payload_buffer, len);&#xA;&#xA;        if (strcmp(payload_buffer, &quot;permitir&quot;) == 0) {&#xA;          Serial.println(F(&quot;Abreeee!!!!!!&quot;));&#xA;        } else {&#xA;          Serial.println(F(&quot;Não abre!!!!!!&quot;));&#xA;        }&#xA;&#xA;    }*/&#xA;}&#xA;&#xA;cc3000_PubSubClient mqttclient(server.ip, 1883, callback, client, cc3000);&#xA;&#xA;void setup(void) {&#xA;&#xA;  #ifndef ESP8266&#xA;    while (!Serial); // for Leonardo/Micro/Zero&#xA;  #endif&#xA;  Serial.begin(115200);&#xA;  Serial.println(F(&quot;Hello OCEAN NFC Reader!&quot;));&#xA;&#xA;  Serial.println(F(&quot;Inicializando NFC Reader....&quot;));&#xA;&#xA;  nfc.begin();&#xA;&#xA;  uint32_t versiondata = nfc.getFirmwareVersion();&#xA;  if (! versiondata) {&#xA;    Serial.print(F(&quot;Didn't find PN53x board&quot;));&#xA;    while (1); // halt&#xA;  }&#xA;  // Got ok data, print it out!&#xA;  Serial.print(F(&quot;Found chip PN5&quot;)); Serial.println((versiondata&amp;gt;&amp;gt;24) &amp;amp; 0xFF, HEX); &#xA;  Serial.print(F(&quot;Firmware ver. &quot;)); Serial.print((versiondata&amp;gt;&amp;gt;16) &amp;amp; 0xFF, DEC); &#xA;  Serial.print(F(&quot;.&quot;)); Serial.println((versiondata&amp;gt;&amp;gt;8) &amp;amp; 0xFF, DEC);&#xA;&#xA;  // configure board to read RFID tags&#xA;  nfc.SAMConfig();&#xA;&#xA;  Serial.println(F(&quot;Waiting for an ISO14443A Card ...\n\n&quot;));&#xA;&#xA;  Serial.println(F(&quot;Inicializando Wifi CC3000&quot;));&#xA;&#xA;  displayDriverMode();&#xA;&#xA;  Serial.println(F(&quot;\nInicializando o CC3000 ...&quot;));&#xA;  if (!cc3000.begin()) {&#xA;    Serial.println(F(&quot;Nao foi possivel inicializar o CC3000! Os cabos estao conectados corretamente?&quot;));&#xA;    for(;;);&#xA;  }&#xA;  else {&#xA;    Serial.println(F(&quot;Carregou&quot;));&#xA;  }&#xA;&#xA;  uint16_t firmware = checkFirmwareVersion();&#xA;  if ((firmware != 0x113) &amp;amp;&amp;amp; (firmware != 0x118)) {&#xA;    Serial.println(F(&quot;Versao do firmware errada!&quot;));&#xA;    for(;;);&#xA;  }&#xA;&#xA;  displayMACAddress();&#xA;&#xA;  Serial.println(F(&quot;\nDeletando perfis de conexoes antigas&quot;));&#xA;  if (!cc3000.deleteProfiles()) {&#xA;    Serial.println(F(&quot;Falhou!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  /* Attempt to connect to an access point */&#xA;  char *ssid = WLAN_SSID;             /* Max 32 chars */&#xA;  Serial.print(F(&quot;\nTentando conectar-se a(o) &quot;)); Serial.println(ssid);&#xA;&#xA;  /* NOTE: Secure connections are not available in 'Tiny' mode! */&#xA;  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {&#xA;    Serial.println(F(&quot;Falhou!&quot;));&#xA;    while(1);&#xA;  }&#xA;&#xA;  Serial.println(F(&quot;Conectado!&quot;));&#xA;&#xA;  /* Wait for DHCP to complete */&#xA;  Serial.println(F(&quot;Requisitando DHCP&quot;));&#xA;  while (!cc3000.checkDHCP()) {&#xA;    delay(100); // ToDo: Insert a DHCP timeout!&#xA;  }&#xA;&#xA;  /* Display the IP address DNS, Gateway, etc. */  &#xA;  while (!displayConnectionDetails()) {&#xA;    delay(1000);&#xA;  }&#xA;&#xA;   // connect to the broker&#xA;   if (!client.connected()) {&#xA;     client = cc3000.connectTCP(server.ip, 1883);&#xA;     Serial.println(F(&quot;Conectando em TCP&quot;));&#xA;   }&#xA;&#xA;   // did that last thing work? sweet, let's do something&#xA;   if(client.connected()) {&#xA;    if (mqttclient.connect(&quot;ArduinoUnoClient-CC3000-A2&quot;, &quot;iotocean&quot;, &quot;NZZOLd0O66oLS0vpajiA123&quot;)) {&#xA;      Serial.println(F(&quot;Publicando&quot;));&#xA;      mqttclient.publish(&quot;/ocean/nfc/debug&quot;,&quot;A2 está online&quot;);&#xA;      mqttclient.subscribe(&quot;/ocean/nfc/porta&quot;);&#xA;    }&#xA;    else {&#xA;      Serial.println(F(&quot;Ouve um erro ao conectar-se ao broker&quot;));&#xA;    }&#xA;   } &#xA;&#xA;}&#xA;&#xA;&#xA;void loop(void) {&#xA;&#xA;  delay(1000);&#xA;&#xA;  Serial.println(F(&quot;Entrei no loop\n&quot;));&#xA;  uint8_t success;&#xA;  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID&#xA;  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)&#xA;&#xA;  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found&#xA;  // 'uid' will be populated with the UID, and uidLength will indicate&#xA;  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)&#xA;  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &amp;amp;uidLength);&#xA;&#xA;  if (success) {&#xA;    // Display some basic information about the card&#xA;    Serial.println(F(&quot;Found an ISO14443A card&quot;));&#xA;    Serial.print(F(&quot;  UID Length: &quot;));Serial.print(uidLength, DEC);Serial.println(&quot; bytes&quot;);&#xA;    Serial.print(F(&quot;  UID Value: &quot;));&#xA;    nfc.PrintHex(uid, uidLength);&#xA;&#xA;    if (uidLength == 4)&#xA;    {&#xA;      // We probably have a Mifare Classic card ... &#xA;      uint32_t cardid = uid[0];&#xA;      cardid &amp;lt;&amp;lt;= 8;&#xA;      cardid |= uid[1];&#xA;      cardid &amp;lt;&amp;lt;= 8;&#xA;      cardid |= uid[2];  &#xA;      cardid &amp;lt;&amp;lt;= 8;&#xA;      cardid |= uid[3]; &#xA;      Serial.print(F(&quot;Seems to be a Mifare Classic card #&quot;));&#xA;      Serial.println(cardid);&#xA;&#xA;&#xA;          // Testa se ainda esta conectado&#xA;          if (!client.connected()) {&#xA;            Serial.println(F(&quot;!client.connected()&quot;));&#xA;             client = cc3000.connectTCP(server.ip, 1883);&#xA;&#xA;             if(client.connected()) {&#xA;               if (mqttclient.connect(&quot;ArduinoUnoClient-Office-A2&quot;)) {&#xA;                  mqttclient.publish(&quot;/ocean/nfc/debug&quot;,&quot;A2 está novamente online&quot;);&#xA;               }&#xA;             } &#xA;          } else {&#xA;            Serial.println(F(&quot;else !client.connected()&quot;));&#xA;            // as per comment from LS_dev, platform is int 16bits&#xA;            sprintf(cardID,&quot;%lu&quot;, cardid);&#xA;&#xA;&#xA;            mqttclient.publish(&quot;/ocean/nfc/id&quot;, cardID); delay(1000);&#xA;          }&#xA;          //delay(1000);&#xA;&#xA;    }&#xA;    Serial.println(F(&quot;&quot;));&#xA;  }&#xA;&#xA;&#xA;  Serial.println(F(&quot;Sai do loop\n&quot;));&#xA;}&#xA;&#xA;void displayDriverMode(void)&#xA;{&#xA;  #ifdef CC3000_TINY_DRIVER&#xA;    Serial.println(F(&quot;CC3000 is configure in 'Tiny' mode&quot;));&#xA;  #else&#xA;    Serial.print(F(&quot;RX Buffer : &quot;));&#xA;    Serial.print(CC3000_RX_BUFFER_SIZE);&#xA;    Serial.println(F(&quot; bytes&quot;));&#xA;    Serial.print(F(&quot;TX Buffer : &quot;));&#xA;    Serial.print(CC3000_TX_BUFFER_SIZE);&#xA;    Serial.println(F(&quot; bytes&quot;));&#xA;  #endif&#xA;}&#xA;&#xA;void charToByte(char* chars, byte* bytes, unsigned int count){&#xA;    for(unsigned int i = 0; i &amp;lt; count; i++)&#xA;      bytes[i] = (byte)chars[i];&#xA;}&#xA;&#xA;void byteToChar(byte* bytes, char* chars, unsigned int count){&#xA;    for(unsigned int i = 0; i &amp;lt; count; i++)&#xA;       chars[i] = (char)bytes[i];&#xA;}&#xA;&#xA;uint16_t checkFirmwareVersion(void)&#xA;{&#xA;  uint8_t major, minor;&#xA;  uint16_t version;&#xA;&#xA;#ifndef CC3000_TINY_DRIVER  &#xA;  if(!cc3000.getFirmwareVersion(&amp;amp;major, &amp;amp;minor))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the firmware version!\r\n&quot;));&#xA;    version = 0;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;Firmware V. : &quot;));&#xA;    Serial.print(major); Serial.print(F(&quot;.&quot;)); Serial.println(minor);&#xA;    version = major; version &amp;lt;&amp;lt;= 8; version |= minor;&#xA;  }&#xA;#endif&#xA;  return version;&#xA;}&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Tries to read the 6-byte MAC address of the CC3000 module&#xA;*/&#xA;/**************************************************************************/&#xA;void displayMACAddress(void)&#xA;{&#xA;  uint8_t macAddress[6];&#xA;&#xA;  if(!cc3000.getMacAddress(macAddress))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve MAC Address!\r\n&quot;));&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;MAC Address : &quot;));&#xA;    cc3000.printHex((byte*)&amp;amp;macAddress, 6);&#xA;  }&#xA;}&#xA;&#xA;&#xA;/**************************************************************************/&#xA;/*!&#xA;    @brief  Tries to read the IP address and other connection details&#xA;*/&#xA;/**************************************************************************/&#xA;bool displayConnectionDetails(void)&#xA;{&#xA;  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;&#xA;&#xA;  if(!cc3000.getIPAddress(&amp;amp;ipAddress, &amp;amp;netmask, &amp;amp;gateway, &amp;amp;dhcpserv, &amp;amp;dnsserv))&#xA;  {&#xA;    Serial.println(F(&quot;Unable to retrieve the IP Address!\r\n&quot;));&#xA;    return false;&#xA;  }&#xA;  else&#xA;  {&#xA;    Serial.print(F(&quot;\nIP Addr: &quot;)); cc3000.printIPdotsRev(ipAddress);&#xA;    Serial.print(F(&quot;\nNetmask: &quot;)); cc3000.printIPdotsRev(netmask);&#xA;    Serial.print(F(&quot;\nGateway: &quot;)); cc3000.printIPdotsRev(gateway);&#xA;    Serial.print(F(&quot;\nDHCPsrv: &quot;)); cc3000.printIPdotsRev(dhcpserv);&#xA;    Serial.print(F(&quot;\nDNSserv: &quot;)); cc3000.printIPdotsRev(dnsserv);&#xA;    Serial.println();&#xA;    return true;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Output of Arduino IDE:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;O sketch usa 28.438 bytes (88%) de espaço de armazenamento para&#xA;  programas. O máximo são 32.256 bytes. Variáveis globais usam 1.546&#xA;  bytes (75%) de memória dinâmica, deixando 502 bytes para variáveis&#xA;  locais. O máximo são 2.048 bytes. Pouca memória disponível, problemas&#xA;  de estabilidade podem ocorrer.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="25628" LastActivityDate="2016-09-20T14:49:48.070" Title="MQTT Callback function don't called" Tags="|arduino-uno|rfid|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28708" PostTypeId="1" AcceptedAnswerId="28712" CreationDate="2016-08-25T17:34:51.410" Score="1" ViewCount="1127" Body="&lt;p&gt;I've an Arduino Nano to which a &lt;a href=&quot;http://www.robotelettronica.altervista.org/immagini/tower-pro-sg90.jpg&quot; rel=&quot;nofollow&quot;&gt;Micro Servo 9g&lt;/a&gt; is connected. The Arduino board and consequently the servo are powered by a USB powerbank connected to the board with a USB mini cable.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is: Is there a way to insert a power switch so I can turn on/off the board without plug/unplug the USB (that now is the way I use) ?&#xA;I was thinking to cut the USB cable and work with the positive of it but if someone has an alternative or any tips I'd really appreciate it. Thanks!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: If is needed I could make a wiring diagram.&lt;/p&gt;&#xA;" OwnerUserId="15350" LastEditorUserId="15350" LastEditDate="2016-08-25T17:41:56.550" LastActivityDate="2016-08-25T21:31:31.890" Title="How to insert a power button on Arduino Nano" Tags="|power|arduino-nano|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28709" PostTypeId="2" ParentId="28651" CreationDate="2016-08-25T17:45:03.540" Score="1" Body="&lt;p&gt;I'm not familiar with the breadboard in your images. You didn't mention if you're familiar with how to use a breadboard and from what I can see I'm not even sure why its being used. It looks to me like you could just connect the jumper wires directly to the pins on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Was the Arduino ever unplugged from the breadboard after it was known to work properly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due to the angle of the photo it is hard to see which pins the wires are connected to. Can you identify which Arduino pins the six wires are connected to?&lt;/p&gt;&#xA;" OwnerUserId="7297" LastEditorUserId="7297" LastEditDate="2016-08-25T17:51:59.917" LastActivityDate="2016-08-25T17:51:59.917" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28710" PostTypeId="2" ParentId="28705" CreationDate="2016-08-25T17:47:16.387" Score="3" Body="&lt;p&gt;It's not safe for the MCU without transistors or so.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use some kind of LED driver (for example TLC5940 with on chip PWM) or ULN2003 as 8 channel low side switch (instead of 8 transistors, PWM is possible if you do it programmatically) or many others.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With single transistor it looks like:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/ycp0m.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/ycp0m.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Where R_1 can be about 1K and transistor can be any NPN that could handle led current.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-25T18:23:51.570" LastActivityDate="2016-08-25T18:23:51.570" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28711" PostTypeId="2" ParentId="28702" CreationDate="2016-08-25T17:55:49.690" Score="5" Body="&lt;p&gt;Save the variables you need to EEPROM. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-25T17:55:49.690" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28712" PostTypeId="2" ParentId="28708" CreationDate="2016-08-25T18:00:59.203" Score="1" Body="&lt;p&gt;Cutting a usb wire would be the easiest. Otherwise you'd have to cut traces in the pcb and attach wires. Not recommend for beginners. You can actually buy usb cable with a switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another alternative would be to put the microcontroler in sleep mode and have it use very little power. &lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-25T18:00:59.203" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28713" PostTypeId="1" CreationDate="2016-08-25T18:34:30.460" Score="6" ViewCount="733" Body="&lt;p&gt;I am trying to transmit from an ATtiny85 running at 16MHz internal clock to an Arduino Uno with the &lt;a href=&quot;https://mchr3k.github.io/arduino-libs-manchester/&quot; rel=&quot;nofollow noreferrer&quot;&gt;Manchester Library&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that the Arduino is not receiving any data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have hooked an oscilloscope to the ATAD/DATA pin of the transmitter, and I can see data being transmitted. I have also done the same thing on the DATA pin of the receiver, and it shows data being received. But the Arduino Uno is not detecting anything.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have tried having an Arduino Uno sending data to itself, which does work, but the data gets dropped very often.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the source code of the transmitter:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Manchester.h&amp;gt;&#xA;&#xA;#define TX_PIN 3  //pin where your transmitter is connected&#xA;&#xA;uint16_t transmit_data = 2761;&#xA;&#xA;void setup() {&#xA;  pinMode(1,OUTPUT);&#xA; man.setupTransmit(TX_PIN, MAN_1200);&#xA;}&#xA;&#xA;void loop() {&#xA;  digitalWrite(1,HIGH);&#xA;  man.transmit(transmit_data);&#xA;  delay(200);&#xA;  digitalWrite(1,LOW);&#xA;  delay(200);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And this is the code on the receiver:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;Manchester.h&quot;&#xA;&#xA;#define RX_PIN 4&#xA;#define BUFFER_SIZE 22&#xA;&#xA;uint8_t buffer[BUFFER_SIZE];&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  man.setupReceive(RX_PIN, MAN_1200);&#xA;  man.beginReceiveArray(BUFFER_SIZE, buffer);&#xA;}&#xA;&#xA;void loop() {&#xA;  if (man.receiveComplete()) {&#xA;    uint8_t receivedSize = 0;&#xA;    // do something with the data in 'buffer' here before you start receiving to the same buffer again&#xA;    receivedSize = buffer[0];&#xA;    for(uint8_t i=1; i&amp;lt;receivedSize; i++)&#xA;      Serial.write(buffer[i]);&#xA;    Serial.println();&#xA;    man.beginReceiveArray(BUFFER_SIZE, buffer);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the code I used to test with only the Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Manchester.h&amp;gt;&#xA;&#xA;#define RX_PIN 7&#xA;#define TX_PIN 8  //pin where your transmitter is connected&#xA;&#xA;uint16_t transmit_data = 2761;&#xA;int lastTransmit = 0;&#xA;&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  man.setupReceive(RX_PIN, MAN_1200);&#xA;  man.setupTransmit(TX_PIN, MAN_1200);&#xA;  man.beginReceive();&#xA;}&#xA;&#xA;void loop() {&#xA;  if (millis() - lastTransmit &amp;gt; 200) {&#xA;    man.transmit(transmit_data);&#xA;    lastTransmit = millis();&#xA;  }&#xA;&#xA;  if (man.receiveComplete()) {&#xA;    uint16_t m = man.getMessage();&#xA;    Serial.println(m);&#xA;    man.beginReceive();&#xA;    //start listening for next message right after you retrieve the message&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26065" LastEditorUserId="4628" LastEditDate="2017-01-21T05:03:22.213" LastActivityDate="2017-02-20T08:05:59.187" Title="Problems with transmission between ATtiny85 and Arduino Uno with 433MHz RF modules and Manchester" Tags="|arduino-uno|attiny|rf|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28714" PostTypeId="2" ParentId="28702" CreationDate="2016-08-25T19:14:41.147" Score="1" Body="&lt;p&gt;If you can't give the MCU enough warning of a power-down to save its critical variables, you'll have to keep it alive with batteries, sleeping if necessary, until the power comes back.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Tying Reset high won't help. The chip resets at power-up - that's built in. In fact, a power-up reset and a grounded-Reset-pin reset behave a bit differently - see the datasheet. Even if it didn't reset on power-up, the RAM needs power to maintain its contents, so it loses them when it drops. &lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-25T19:14:41.147" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28715" PostTypeId="1" CreationDate="2016-08-25T19:15:10.037" Score="2" ViewCount="3076" Body="&lt;p&gt;I have successfully wrote a sketch for Ethernet Shield and Arduino. If I plug it into computer's USB, it works.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But if I plug into any other power source, like USB power adapter from iPhone or laboratory power source to power socket -- it doesn't work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;LEDs are doing various strange bursts, very different than if powered from computer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What can be the reason?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have updated sketch so that it doesn't refer serial:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;// The IP address will be dependent on your local network:&#xA;// B6-62-C5-CC-48-81&#xA;byte mac[] = {&#xA;  0xB6, 0x62, 0xC5, 0xCC, 0x48, 0x81&#xA;};&#xA;IPAddress ip(192, 168, 10, 90);&#xA;&#xA;// Initialize the Ethernet server library&#xA;// with the IP address and port you want to use&#xA;// (port 80 is default for HTTP):&#xA;EthernetServer server(80);&#xA;&#xA;long requestCount = 0;&#xA;long upCounts[] = {0, 0, 0, 0, 0, 0};&#xA;long downCounts[] = {0, 0, 0, 0, 0, 0};&#xA;int currVals[] = {0, 0, 0, 0, 0, 0};&#xA;int prevStats[]= {0, 0, 0, 0, 0, 0};&#xA;int upThreshold = 1024-32;&#xA;int downThreshold = 32;&#xA;&#xA;&#xA;&#xA;void setup() {&#xA;  // Open serial communications and wait for port to open:&#xA;//  Serial.begin(9600);&#xA;//  while (!Serial) {&#xA;//    ; // wait for serial port to connect. Needed for native USB port only&#xA;//  }&#xA;&#xA;&#xA;  // start the Ethernet connection and the server:&#xA;  Ethernet.begin(mac, ip);&#xA;  server.begin();&#xA;//  Serial.print(&quot;server is at &quot;);&#xA;//  Serial.println(Ethernet.localIP());&#xA;}&#xA;&#xA;&#xA;void loop() {&#xA;&#xA;  for (int analogChannel = 0; analogChannel &amp;lt; 6; analogChannel++) {&#xA;    int sensorReading = analogRead(analogChannel);&#xA;    currVals[analogChannel] = sensorReading;&#xA;&#xA;    if( prevStats[analogChannel] == 0 ) {&#xA;      if( currVals[analogChannel] &amp;gt;= upThreshold ) {&#xA;        prevStats[analogChannel] = 1;&#xA;        if( requestCount&amp;gt;0 ) {&#xA;          upCounts[analogChannel] ++;&#xA;        }&#xA;      }&#xA;    }&#xA;    else {&#xA;      if( currVals[analogChannel] &amp;lt; downThreshold ) {&#xA;        prevStats[analogChannel] = 0;&#xA;        if( requestCount&amp;gt;0 ) {&#xA;          downCounts[analogChannel] ++;&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;&#xA;  // listen for incoming clients&#xA;  EthernetClient client = server.available();&#xA;  if (client) {&#xA;    //Serial.println(&quot;new client&quot;);&#xA;    // an http request ends with a blank line&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) {&#xA;        char c = client.read();&#xA;        //Serial.write(c);&#xA;        // if you've gotten to the end of the line (received a newline&#xA;        // character) and the line is blank, the http request has ended,&#xA;        // so you can send a reply&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          // send a standard http response header&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println(&quot;Connection: close&quot;);  // the connection will be closed after completion of the response&#xA;          client.println(&quot;Refresh: 2&quot;);  // refresh the page automatically every 2 sec&#xA;&#xA;          client.print(&quot;X-Inthemoon-Request-Count: &quot;);  &#xA;          client.println(requestCount);&#xA;          for (int analogChannel = 0; analogChannel &amp;lt; 6; analogChannel++) {&#xA;            client.print(&quot;X-Inthemoon-Analog-To-Digital: &quot;);  &#xA;            client.print(&quot;Channel=&quot;);&#xA;            client.print(analogChannel);&#xA;            client.print(&quot;; &quot;);&#xA;            client.print(&quot;Min-Value=0; &quot;);&#xA;            client.print(&quot;Max-Value=1023; &quot;);&#xA;            client.print(&quot;Value=&quot;);&#xA;            client.print(currVals[analogChannel]);&#xA;            client.print(&quot;; &quot;);&#xA;            client.print(&quot;Up-Change-Count=&quot;);&#xA;            client.print(upCounts[analogChannel]);&#xA;            client.print(&quot;; &quot;);&#xA;            client.print(&quot;Down-Change-Count=&quot;);&#xA;            client.print(downCounts[analogChannel]);&#xA;            client.println(&quot;;&quot;);&#xA;          }&#xA;&#xA;&#xA;          client.println();&#xA;          client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;          // output the value of each analog input pin&#xA;          client.print(&quot;Was counting: &quot;);&#xA;          if( requestCount&amp;gt;0 ) {&#xA;            client.print(&quot;YES (request count is &quot;);&#xA;            client.print(requestCount);&#xA;            client.print(&quot;)&quot;);&#xA;          }&#xA;          else {&#xA;            client.print(&quot;NO&quot;);&#xA;          }&#xA;          client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          for (int analogChannel = 0; analogChannel &amp;lt; 6; analogChannel++) {&#xA;            client.print(&quot;analog input &quot;);&#xA;            client.print(analogChannel);&#xA;            client.print(&quot; is &quot;);&#xA;            client.print(currVals[analogChannel]);&#xA;            client.print(&quot;, up changes count is &quot;);&#xA;            client.print(upCounts[analogChannel]);&#xA;            client.print(&quot;, and down changes count is &quot;);&#xA;            client.print(downCounts[analogChannel]);&#xA;            client.println(&quot;&amp;lt;br /&amp;gt;&quot;);&#xA;          }&#xA;          client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;&#xA;          requestCount++;&#xA;          break;&#xA;        }&#xA;        if (c == '\n') {&#xA;          // you're starting a new line&#xA;          currentLineIsBlank = true;&#xA;        } else if (c != '\r') {&#xA;          // you've gotten a character on the current line&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      }&#xA;    }&#xA;    // give the web browser time to receive the data&#xA;    delay(1);&#xA;    // close the connection:&#xA;    client.stop();&#xA;    //Serial.println(&quot;client disconnected&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The situation is the same:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://youtu.be/vypaNOxZ5KI&quot; rel=&quot;nofollow&quot;&gt;https://youtu.be/vypaNOxZ5KI&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is plugged into Samsung tablet USB power of 2A, so insufficient current is unprobable reason.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 2&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I also tried to remove inclusion of &lt;code&gt;SPI.h&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 3&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I connect another Arduino board  (but of the same vendor, it is from AliExpress), the behavior is the same.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 4&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have compiled &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Blink&quot; rel=&quot;nofollow&quot;&gt;blink example&lt;/a&gt; and it works in any combination. If I connect Ethernet shield, then it blinks with both LEDs on Arduino board and on Ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE 5&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I bought different Ethernet Board and it doesn't work too.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help. Have anybody ever powering Arduino + Ethernet not from USB?&lt;/p&gt;&#xA;" OwnerUserId="6841" LastEditorUserId="6841" LastEditDate="2016-09-23T17:11:52.460" LastActivityDate="2020-03-31T00:57:18.273" Title="Cannot power up Arduino Uno + Ethernet Shield with other than computer USB" Tags="|arduino-uno|power|" AnswerCount="4" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="28716" PostTypeId="2" ParentId="28702" CreationDate="2016-08-25T19:29:18.280" Score="0" Body="&lt;p&gt;Take power from UPS (uninterruptable power supply).&lt;/p&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-25T19:29:18.280" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28717" PostTypeId="1" AcceptedAnswerId="28721" CreationDate="2016-08-25T19:38:54.773" Score="2" ViewCount="2490" Body="&lt;p&gt;I would like to upload a .hex to ATTiny13V (or '13A) using Arduino Uno R3.&#xA;I think I know everything to do, but ATTiny13 ISP support and Arduino IDE is a bit search-and-find, and I have some grey-areas in my understanding of how this all works together.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I got here by:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Finding an Instructable that did something I liked, and there's a ATTiny13V used, a .hex to upload, and C source if I want to modify the source.  Right now I do not need to modify the source, the available .hex is fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-I then looked for a way to have AVR programing from OS X.  This seems a little problem, many AVR programmer hardware work great under Windows but seem to have mixed results under OS X.  I saw Arduino could be used for this under OS X.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-I looked on local craigslist for Arduino, someone was selling a Uno R3 with some extras for a great price, and here we are.   And now I have a lot more projects I wish to complete!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using Arduino 1.6.10 (from the .cc not the .org).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I read on stackexchange and other places that smeezekitty's core13 works for the ATTiny13.&#xA;elabz.com/arduino-shrunk-how-to-use-attiny13-with-arduino-ide/&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's great, but: If I am not using any of the Arduino-specific commands, I don't think I need the bootloader, correct?  I think it is not really a bootloader but builds support for some of the Arduino-specific higher-level commands used by sketch files.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I even need the ATTiny13 core files if I hook the pins up properly between the '13 on a breadboard and the Arduino (as per here:  &lt;a href=&quot;https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829&quot; rel=&quot;nofollow&quot;&gt;https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829&lt;/a&gt; ).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I really do not understand what the Arduino IDE/bootloader is doing for me as an abstraction layer.  Do I need the bootloader if I'm not using any of the higher-level Arduino-specific commands on the chip?  HOw about the core files for ATTinyanything vs specifically ATTiny13?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The hex file and C source I will be using are here:&#xA;&lt;a href=&quot;http://www.instructables.com/id/Programmable-LED/&quot; rel=&quot;nofollow&quot;&gt;http://www.instructables.com/id/Programmable-LED/&lt;/a&gt;&#xA;My nextstep will be to modify the source. The C source looks like it references some AVR-specific header files.  I see that the ArduinoIDE uses avrdude so maybe things will compile anyway?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I feel like I'm close but not 100% in my understanding of what I need to do, with the tools I have on hand.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks for your help- I am not above a step-by-step.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main question 1:  I have a .hex file, an Arduino and IDE 1.6.10, OS X, and breadboard and useful components.  What do I need to do to put the hex on this ATTiny13?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Main question 2: Jumping-off points for taking the C source I linked, tweaking it a bit, building a hex, and uploading that.  I am not against moving it to a sketch if I have to, but it would be good for me to learn how this works before I mode to the IDE.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have a small software background, am comfortable taking that C source and making changes and compiling (assuming I can find the needed .h files), but this is my first time working with any multiprocessors.&lt;/p&gt;&#xA;" OwnerUserId="26067" LastEditorUserId="26067" LastEditDate="2016-08-26T12:16:33.220" LastActivityDate="2020-06-08T02:41:23.813" Title="Uploading .hex to ATTiny13 using Arduino" Tags="|avr|attiny13|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28718" PostTypeId="1" CreationDate="2016-08-25T19:53:00.527" Score="3" ViewCount="5017" Body="&lt;p&gt;I recently bought the HC 08 Bluetooth module (link &lt;a href=&quot;https://www.aliexpress.com/item/SH-HC-08-CC2541-Bluetooth-4-0-BLE-to-UART-Transceiver-Module-with-Transparent-Serial-Port/32392960671.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). As the specs state, this module supports Bluetooth 4.0 which indicates that it supports BLE (Bluetooth low energy).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My goal is to be able to use something similar to the CurieBLE library: I want to code services and characteristics on my Arduino so I can discover those on LightBlue (iOS).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I searched the internet for some guidelines, but I only found code using AT commands and honestly I don't know anything about those.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can you please recommend any source to achieve the goal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After following the connections in this &lt;a href=&quot;http://www.prometec.net/bluetooth-le/&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; (In Spanish I guess but helpful), I was able to discover the Arduino on LightBlue. The characteristic name was Tx/Rx and I was able to write, read and subscribe to notifications (data coming in). Of course if would be better to find something that allows the definition of services and characteristics.&lt;/p&gt;&#xA;" OwnerUserId="26069" LastEditorUserId="26069" LastEditDate="2016-08-25T20:29:33.600" LastActivityDate="2016-08-25T20:29:33.600" Title="HC 08 Module with Arduino Uno" Tags="|arduino-uno|bluetooth|communication|" AnswerCount="0" CommentCount="0" ClosedDate="2017-11-17T03:11:44.260" ContentLicense="CC BY-SA 3.0" />
  <row Id="28719" PostTypeId="1" CreationDate="2016-08-25T20:06:24.013" Score="1" ViewCount="607" Body="&lt;p&gt;I have a need to receive a specific confirmation packet after commanding my transmitting Xbee to stop sending normal packets. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My buffer still has normal packets in it when this happens, so next time I call readPacket(), I don't want to see them. So right before I call my stop command, I try to purge the incoming buffer like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void burnSerial(void) {&#xA;  while (xbee.readPacket(20)) {&#xA;    xbee.getResponse().getRx16Response(rx16);&#xA;  } //read all available responses&#xA;    // only do this when not in a constant stream of responses or it may hang.&#xA;&#xA;  while (Serial.available()) { Serial.read(); }&#xA;  //burn whatever may be in serial buffer&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But this doesn't work. The next time I call &lt;code&gt;xbee.readPacket()&lt;/code&gt;, I see tons of normal packets before I finally see my confirmation packet. Why don't these functions do anything for me at all?&lt;/p&gt;&#xA;" OwnerUserId="19892" LastEditorUserId="4628" LastEditDate="2017-10-21T05:40:09.820" LastActivityDate="2022-01-17T21:00:15.033" Title="How to purge incoming Xbee packets from the buffer?" Tags="|xbee|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28720" PostTypeId="2" ParentId="28651" CreationDate="2016-08-25T20:07:22.223" Score="1" Body="&lt;p&gt;Please consider the following to assist in your understanding of the Arduino and of the servo operation. I recently &quot;instructed&quot; a summer camp of teens to construct the MeArm robot arm, using inexpensive servos and an Arduino. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The servos you have will operate without the servo driver, enabling you to isolate the problem. Consider to connect the signal wire for each servo to an assigned pin on the Arduino and test each servo with the built-in Sweep sketch. Your off-board power for the servos should share the ground with the Arduino, while the +V would connect to the power lead for the breadboard and hence to the servos.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Pins 6, 9, 10, 11 are PWM capable and you can modify in the Sweep sketch to operate each one independently as a way of testing the base &quot;kit.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The code for Sweep is simplistic, while the servo driver has a good bit of &quot;middle-man&quot; calculations to accomplish more refined control.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example from the summer camp:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[in setup]&#xA;claw.attach(9);&#xA;inout.attach(10);&#xA;updown.attach(11);&#xA;rightleft.attach(6);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;[in loop]&#xA; - the following was placed in a for-loop:&#xA;claw.write(pos);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;... and more code including delays and limits to pos to prevent servo chatter/slam.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This will likely show you that your servos are working (or not) and enable a better understanding of the basics, while perhaps increasing your chances of understanding the more complex and flexible servo board library of code.&lt;/p&gt;&#xA;" OwnerUserId="19300" LastActivityDate="2016-08-25T20:07:22.223" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28721" PostTypeId="2" ParentId="28717" CreationDate="2016-08-25T20:14:01.310" Score="1" Body="&lt;p&gt;Your computer cannot talk directly to the ATtiny. You need some piece of&#xA;interfacing hardware between them. This is called an ICSP (or ISP)&#xA;programmer. You also need software to drive the programmer, typically&#xA;avrdude.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you do not have a programmer, you can buy one (I had success with&#xA;some very cheap USBASPs), or you can program an Arduino Uno to behave&#xA;like an ISP programmer. You do this by uploading into the Arduino a&#xA;program called ArduinoISP, like explained in the tutorial &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/ArduinoISP&quot; rel=&quot;nofollow&quot;&gt;Using an&#xA;Arduino as an AVR ISP (In-System&#xA;Programmer)&lt;/a&gt;. You will&#xA;typically use the Arduino IDE and the Arduino core for the Uno to&#xA;compile and load ArduinoISP into your Uno. Once this is done, you can&#xA;use the Arduino as a programmer and burn your .hex into your ATtiny.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to compile your own programs for the ATtiny, you will need&#xA;the avr-gcc compiler and the avr-libc. These are bundled with the&#xA;Arduino IDE, so you already have them. You will need an Arduino core for&#xA;the ATtiny &lt;em&gt;only&lt;/em&gt; if you want to use the Arduino APIs and libraries.&#xA;Otherwise you can write plain C programs with noting else than the&#xA;avr-libc and avr-gcc.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: To compile a plain C program, you can type something like&#xA;this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;avr-gcc -mmcu=attiny13a -DF_CPU=1200000 -Os -Wall -Wextra flickled.c -o flickled.elf&#xA;avr-objcopy -O ihex flickled.elf flickled.hex&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This assumes your source file is called &lt;code&gt;flickled.c&lt;/code&gt; and your ATtiny&#xA;runs at 1.2&amp;nbsp;MHz.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="7508" LastEditDate="2016-08-25T20:29:53.737" LastActivityDate="2016-08-25T20:29:53.737" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28722" PostTypeId="1" CreationDate="2016-08-25T20:27:05.897" Score="3" ViewCount="978" Body="&lt;p&gt;I'm doing a project for university and I am struggling to code and set up a rotary encoder that can control hot-cold variations. Much like the idea of communicating temperature selected by turning a dial. I would either like to control a single strip of RGB LEDs or a single bulb (changing and fading between colours at the same time).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would like to have the dial turn from 0 - 180 degrees and relate to intense blue changing to intense red and all the colours in between as increments.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Uno.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you!&lt;/p&gt;&#xA;" OwnerUserId="26071" LastEditorUserId="4628" LastEditDate="2017-05-28T07:20:53.507" LastActivityDate="2017-10-25T18:45:55.637" Title="How to control cold to hot (blue to red gradient) RBG LED strip/bulb with a rotary encoder?" Tags="|led|rgb-led|rotary-encoder|" AnswerCount="2" CommentCount="6" ClosedDate="2017-10-30T11:56:06.713" ContentLicense="CC BY-SA 3.0" />
  <row Id="28723" PostTypeId="2" ParentId="28461" CreationDate="2016-08-25T20:59:48.077" Score="1" Body="&lt;pre&gt;&lt;code&gt;void loop() {&#xA;&#xA;...&#xA;&#xA;  if(digitalRead(dvereVysunute) == HIGH &amp;amp;&amp;amp; digitalRead(davkovaniZasunute) == HIGH&#xA;  )&#xA;  {&#xA;      digitalWrite(davkovani, LOW);      // extend the second pneumatic cylinder&#xA;      delay(4000);&#xA;      digitalWrite(davkovani, HIGH);    // retract the second pneumatic cylinder after 4 seconds, &#xA;      // this code works when it is alone there, the next if statements not&#xA;  }&#xA;&#xA;...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;If the condition is met, then &lt;code&gt;davkovani&lt;/code&gt; is going to be LOW 99.999% of the time. It will only briefly go HIGH, as there is no delay there. The loop will iterate and set it LOW again. So it may seem to be &quot;not working&quot; whereas the problem is that it &quot;works&quot; very briefly.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-25T20:59:48.077" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28724" PostTypeId="2" ParentId="28708" CreationDate="2016-08-25T21:31:31.890" Score="0" Body="&lt;p&gt;As Gerben said, you can buy a cable with a switch built in.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/FszT4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/FszT4.jpg&quot; alt=&quot;Usb cable with switch&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26039" LastActivityDate="2016-08-25T21:31:31.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28726" PostTypeId="1" AcceptedAnswerId="28731" CreationDate="2016-08-25T23:02:29.727" Score="3" ViewCount="5355" Body="&lt;p&gt;I am a newbie and I would like to build my own minimalistic ATmega32U4 based arduino compatible board. Can anyone please tell me which parts resistors/capacitors (and maybe one status led) I need to connect it over usb to my computer? Thanks in advance.&lt;/p&gt;&#xA;" OwnerUserId="26076" OwnerDisplayName="Chris" LastEditorUserId="37523" LastEditDate="2018-07-27T01:03:03.283" LastActivityDate="2018-07-27T01:03:03.283" Title="Minimal Arduino using ATmega32U4" Tags="|atmega32u4|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28727" PostTypeId="2" ParentId="28726" CreationDate="2016-08-26T00:18:26.527" Score="2" Body="&lt;p&gt;Building your own may be worthwhile from a learning point of view, but makes minimal sense otherwise. You can buy Arduino clones (legal) from China for under $US5 each - good enough quality, assembled, working.&lt;br&gt;&#xA;You cannot build one for that. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A DIY minimalist Arduino requires a running processor - see datasheet for the processor of choice as Ignacio says.Probably decoupling capacitors and maybe one or two resistors and maybe 1 or 2 small capacitors. If you cannot derive the needed information from a datasheet you do not know enough to sensibly do it by yourself. There are many on-web ~= minimalist implementations to copy.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want onboard USB you'd usually use a USB-serial converter but this can be done by &quot;bit bashing&quot; if you truly want a minimalist implementation&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;BUT - just buy one and use the large amount of time gained to learn related things of more immediate use. &lt;/p&gt;&#xA;" OwnerUserId="6959" LastActivityDate="2016-08-26T00:18:26.527" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28729" PostTypeId="2" ParentId="28694" CreationDate="2016-08-26T01:18:14.177" Score="-1" Body="&lt;p&gt;As it was answered above by Cheirbriados, the library is &lt;code&gt;EthernetUdp.h&lt;/code&gt; not &lt;code&gt;EthernetUdp2.h&lt;/code&gt;. I'll post you an example code, but you can also analyze it by yourself, by going on tab Examples of the Arduino IDE and choosing Ethernet -&gt; UDPSendReceiveString: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;         // needed for Arduino versions later than 0018&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;#include &amp;lt;EthernetUdp.h&amp;gt;         // UDP library from: bjoern@cs.stanford.edu 12/30/2008&#xA;&#xA;&#xA;// Enter a MAC address and IP address for your controller below.&#xA;// The IP address will be dependent on your local network:&#xA;byte mac[] = {&#xA;  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED&#xA;};&#xA;IPAddress ip(192, 168, 1, 177);&#xA;&#xA;unsigned int localPort = 8888;      // local port to listen on&#xA;&#xA;// buffers for receiving and sending data&#xA;char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  //buffer to hold incoming packet,&#xA;char  ReplyBuffer[] = &quot;acknowledged&quot;;       // a string to send back&#xA;&#xA;// An EthernetUDP instance to let us send and receive packets over UDP&#xA;EthernetUDP Udp;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26036" LastActivityDate="2016-08-26T01:18:14.177" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28730" PostTypeId="1" CreationDate="2016-08-26T02:12:05.653" Score="0" ViewCount="2837" Body="&lt;p&gt;I am having trouble figuring out the pinout of my 6 - pin USBasp Chinese clone that I got off eBay.&#xA;&lt;strong&gt;BEFORE YOU TELL ME TO LOOK AT THE PINOUT DIAGRAMS,&lt;/strong&gt; I can tell you that my version of the usbasp has no way of telling which way is up and which ways is down. Images:&#xA;&lt;a href=&quot;https://i.stack.imgur.com/RUq6W.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/RUq6W.jpg&quot; alt=&quot; &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/HM2Ok.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/HM2Ok.jpg&quot; alt=&quot; &quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26077" LastActivityDate="2016-08-26T02:55:37.203" Title="Help with usbasp pinout" Tags="|usbasp|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28731" PostTypeId="2" ParentId="28726" CreationDate="2016-08-26T02:28:26.160" Score="4" Body="&lt;p&gt;Several Arduinos and Arduino-compatible boards use the ATmega32U4.&#xA;Many of them have published open-source plans that show exactly what components are used and how they are connected. They may not be the absolute minimal number of components, but it seems clear that you don't need &lt;em&gt;more&lt;/em&gt; components than a known-working board:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1 ATmega32u4&lt;/li&gt;&#xA;&lt;li&gt;1 16 MHz crystal&lt;/li&gt;&#xA;&lt;li&gt;2 22pF ceramic caps (for crystal)&lt;/li&gt;&#xA;&lt;li&gt;1 uF decoupling cap&lt;/li&gt;&#xA;&lt;li&gt;1 pushbutton&lt;/li&gt;&#xA;&lt;li&gt;1 10 KOhm pull-up resistor (for pushbutton)&lt;/li&gt;&#xA;&lt;li&gt;1 LED&lt;/li&gt;&#xA;&lt;li&gt;1 220 Ohm resistor (for LED)&lt;/li&gt;&#xA;&lt;li&gt;1 USB socket&lt;/li&gt;&#xA;&lt;li&gt;2 22 Ohm resistors (between USB socket and ATmega32u4)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Alas, there are two unnecessarily difficult hurdles between newbies and getting a new ATmega32u4 device connected over USB to a computer:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;The ATmega32u4 and nearly every other device that communicates over USB is only available in SMT packages with pins at 0.8 mm pitch or even closer together.&#xA;Most people find packages with pins at 2.54 mm pitch easier to handle and plug into a breadboard.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Installing a bootloader into any new processor chip is often tricky.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;As Russel already pointed out, you can save a lot of time by starting out with an Arduino or Arduino-compatible board that already has the chip soldered on and the bootloader programmed in, bypassing the above unnecessarily difficult hurdles.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A few Arduinos and Arduino-compatibles (with links to schematics, etc.) that use the ATmega32u4:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://murchlabs.com/monday-experiment-bootloading-an-atmega32u4-with-arduino/&quot; rel=&quot;nofollow&quot;&gt;Bootloading an ATmega32u4 with Arduino&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/199&quot; rel=&quot;nofollow&quot;&gt;Teensy 2.0 (ATmega32u4 USB dev board)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardLeonardo&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo&lt;/a&gt;; &lt;a href=&quot;https://www.adafruit.com/product/849&quot; rel=&quot;nofollow&quot;&gt;Arduino Leonardo&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Main/ArduinoBoardMicro&quot; rel=&quot;nofollow&quot;&gt;Arduino MICRO&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/12640&quot; rel=&quot;nofollow&quot;&gt;SparkFun Pro Micro (Arduino-compatible)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/product/659&quot; rel=&quot;nofollow&quot;&gt;FLORA - Wearable electronic platform: Arduino-compatible&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/2771&quot; rel=&quot;nofollow&quot;&gt;Adafruit Feather 32u4 Basic Proto&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://electronut.in/bootloader-atmega32u4/&quot; rel=&quot;nofollow&quot;&gt;Installing Arduino Bootloader on an ATmega32u4&lt;/a&gt;; &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=121371.0&quot; rel=&quot;nofollow&quot;&gt;Installing Arduino Bootloader on an ATmega32u4&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="186" LastActivityDate="2016-08-26T02:28:26.160" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28732" PostTypeId="2" ParentId="28730" CreationDate="2016-08-26T02:55:37.203" Score="2" Body="&lt;p&gt;Look at the following pinout diagram (from &lt;a href=&quot;http://telecnatron.com/reference/pinouts/avr-isp/index.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;telecnatron.com&lt;/a&gt;):&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/EWRoo.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/EWRoo.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The right-hand diagram above shows the USBASP-board pin-header pin assignments, when you are looking into the pin-header.  The header shell will have a triangle marking pin 1.  Note that pin 1 is on the same side of the connector as the key (the ridge on the cable connectors, the slot on the pin-header shell).  Each socket on the cable also will have a triangle marking pin 1.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-08-26T02:55:37.203" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28733" PostTypeId="1" AcceptedAnswerId="28739" CreationDate="2016-08-26T02:58:57.620" Score="1" ViewCount="251" Body="&lt;p&gt;I am using an ATTINY88 for a project that requires to turn on an LED. Right now I am using pin PA1(ADC7/PCINT25). I noted, however, that when the pin is ON, I get about half the voltage that is connected to Vcc. I checked the voltage in other pins and they are close to Vcc. Will anyone know, what could be the reason for this?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I figure this pin has an internal resistor enable, but I am not certain. &lt;/p&gt;&#xA;" OwnerUserId="11802" LastActivityDate="2016-08-26T07:59:35.230" Title="digitalPin giving lower voltage than Vcc" Tags="|voltage-level|attiny|resistor|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28734" PostTypeId="1" CreationDate="2016-08-26T04:16:44.070" Score="1" ViewCount="2389" Body="&lt;p&gt;I have a device in which a user connects their mobile device to an arduino uno via a HM-10 bluetooth transponder.  I want to be able to calculate the approximate distance between the user and the transponder by hopefully using the RSSI methodology:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; d = 10 ^ ((TxPower - RSSI) / 20)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;My goal&lt;/strong&gt; is for the user to send a connection request to the HM-10, the uno to then calculate the distance, and if greater than x meters away, reject the request.  I realize RSSI based distance is an estimate at best but that is fine for my purposes.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With that in mind, I have two questions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;1.) Is an HM-10 able to capture the RSSI strength of a mobile device to &#xA;    calculate distance? &#xA;2.) Can it do so WITHOUT connecting first based on the &#xA;    initial request of the mobile device?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26078" LastEditorUserId="26078" LastEditDate="2016-08-29T04:35:45.210" LastActivityDate="2016-08-31T08:57:09.913" Title="Find RSSI of Mobile Device Without Connecting" Tags="|arduino-uno|bluetooth|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28737" PostTypeId="2" ParentId="28719" CreationDate="2016-08-26T07:06:42.513" Score="1" Body="&lt;p&gt;It means there's a lot of latency between your issuing a command and getting a confirmation of the command's effect. When you send the command, it's best that you wait and read packets &lt;em&gt;until&lt;/em&gt; you find the confirmation and &lt;em&gt;then&lt;/em&gt; you return from the function or do whatever else you want to do. There is no need for a separate &lt;code&gt;burnSerial()&lt;/code&gt; function, nor should you blindly discard data. So basically, the sequence of operations should be:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Send the command&lt;/li&gt;&#xA;&lt;li&gt;Read packets until you find the 'confirmation' identification marker&lt;/li&gt;&#xA;&lt;li&gt;Return or exit&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;This assumes that your transmitter only sends confirmation &lt;em&gt;after&lt;/em&gt; it has halted the stream. &lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-08-26T07:06:42.513" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28739" PostTypeId="2" ParentId="28733" CreationDate="2016-08-26T07:59:35.230" Score="2" Body="&lt;p&gt;You should connect the AVCC pin to VCC. From the datasheet (emphasis&#xA;mine):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;AV&lt;sub&gt;CC&lt;/sub&gt; is the supply voltage pin for the A/D converter &lt;strong&gt;and&#xA;  a selection of I/O pins&lt;/strong&gt;. This pin should be externally connected to&#xA;  V&lt;sub&gt;CC&lt;/sub&gt; &lt;strong&gt;even if the ADC is not used&lt;/strong&gt;. [...]&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The following pins receive their supply voltage from AV&lt;sub&gt;CC&lt;/sub&gt;:&#xA;  PC7, PC[5:0] and (in 32-lead pack- ages) &lt;strong&gt;PA[1:0]&lt;/strong&gt;. All other I/O&#xA;  pins take their supply voltage from V&lt;sub&gt;CC&lt;/sub&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-26T07:59:35.230" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28740" PostTypeId="1" CreationDate="2016-08-26T10:05:24.120" Score="2" ViewCount="972" Body="&lt;p&gt;I'm using the Arduino sketch for LED stroboscope found here: &lt;a href=&quot;http://mehax.blogspot.co.uk/2011/02/arduino-stroboscope.html&quot; rel=&quot;nofollow&quot;&gt;http://mehax.blogspot.co.uk/2011/02/arduino-stroboscope.html&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also below, I've inserted the loop part where this calculations are made:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop() {&#xA;// this while is a workaround for timer limitations using micros vs millis&#xA;sensorValue = analogRead(analogInPin);   //take potentiometer reading&#xA;hold = sensorValue*55 + 400;             //add some time to scale and for code execution&#xA;microsCurrent = micros();                // collect current time&#xA;if (microsCurrent &amp;gt; microsPrev + hold){  //set up timing loop&#xA;frequency = 1000000/(microsCurrent - microsPrev);    &#xA;microsPrev = microsPrev + hold;            //set up millis for delay stuff&#xA;&#xA;//set all 6 LEDs high (they were already plugged in)&#xA;digitalWrite(3,HIGH);&#xA;digitalWrite(5,HIGH);&#xA;digitalWrite(6,HIGH);&#xA;digitalWrite(9,HIGH);&#xA;digitalWrite(10,HIGH);&#xA;digitalWrite(11,HIGH);&#xA;delayMicroseconds(.02*hold);  //leave LEDs on long enough to see&#xA;&#xA;//set all LEDs low&#xA;digitalWrite(3,LOW);&#xA;digitalWrite(5,LOW);&#xA;digitalWrite(6,LOW);&#xA;digitalWrite(9,LOW);&#xA;digitalWrite(10,LOW);&#xA;digitalWrite(11,LOW);&#xA;&#xA;if(millis() &amp;gt; millisSerial + 200){ &#xA;  millisSerial=millis();    //reset timer&#xA;  holdFrequency = 1000000/hold;    &#xA;  //do some math to find values&#xA;  rpm = frequency * 60;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I want to use this code in my project, but I don't really understand how this code calculates the stobing frequency. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, I have following questions:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Why &quot;hold&quot; variable is calculated in the given way?&lt;/li&gt;&#xA;&lt;li&gt;Why &quot;microsCurrent&quot;, &quot;microsPrev&quot; and all other timings are executed?&lt;/li&gt;&#xA;&lt;li&gt;How &quot;frequency is calculated&quot;?&lt;/li&gt;&#xA;&lt;li&gt;What is &quot;hold frequency&quot; variable?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Sorry, I'm very new to Arduino and don't know much coding. &#xA;Will appreciate very much your help!&lt;/p&gt;&#xA;" OwnerUserId="26083" LastActivityDate="2016-08-26T10:24:47.557" Title="Strobe Frequency Calculation, how its done?" Tags="|programming|c++|led|sketch|frequency|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28741" PostTypeId="2" ParentId="28740" CreationDate="2016-08-26T10:24:47.557" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why &quot;hold&quot; variable is calculated in the given way?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;hold&lt;/code&gt; stores the intended delay between the strobe pulses, i.e. the&#xA;stroboscope period. It is computed as an affine function of the&#xA;potentiometer cursor position because... well, that's the simplest way&#xA;to make it user-adjustable. 400&amp;nbsp;µs is the shortest period that&#xA;(according to the program author) one may reasonably want to set.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Why &quot;microsCurrent&quot;, &quot;microsPrev&quot; and all other timings are executed?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&quot; rel=&quot;nofollow&quot;&gt;Blink Without&#xA;Delay&lt;/a&gt; Arduino&#xA;tutorial.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How &quot;frequency is calculated&quot;?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;From the code:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;frequency = 1000000/(microsCurrent - microsPrev);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The frequency is the inverse of the period. The period is the time&#xA;elapsed between this strobe and the previous one. The numerator is a&#xA;conversion factor to get the frequency in hertz from a period in&#xA;microseconds.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;What is &quot;hold frequency&quot; variable?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;It's the intended frequency (inverse of the intended period),&#xA;disregarding the timing jitter that makes the actual instantaneous&#xA;frequency slightly different.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-26T10:24:47.557" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28743" PostTypeId="2" ParentId="25687" CreationDate="2016-08-26T10:41:12.437" Score="1" Body="&lt;p&gt;Can't you see what's hooking the serial port with &lt;code&gt;sudo lsof -n | grep cuaU0&lt;/code&gt; ? If so, &lt;code&gt;sudo kill -9 12345&lt;/code&gt;, where 12345 is the offending PID. Your FTDI chip may need a driver, try &lt;code&gt;sudo dmesg&lt;/code&gt; after pluggibg it in, or use systemprofiler.&lt;/p&gt;&#xA;" OwnerUserId="16673" LastActivityDate="2016-08-26T10:41:12.437" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28744" PostTypeId="1" CreationDate="2016-08-26T11:11:11.240" Score="6" ViewCount="1304" Body="&lt;p&gt;I just got my ESP8266, but I am unable to program it. Since it can't be connected to via USB, I was wondering if I can program it using an Arduino or perhaps use it as a shield for an Arduino Nano. I haven't been able to find a good guide online. Any help is greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26086" LastEditorUserId="11763" LastEditDate="2016-08-26T19:12:25.917" LastActivityDate="2017-09-23T22:27:44.600" Title="Is it possible to program an ESP8266 12F using an Arduino Nano?" Tags="|esp8266|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28746" PostTypeId="2" ParentId="28692" CreationDate="2016-08-26T13:52:36.307" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;So I plug the JST connector to the Vin and GND pin and the LED doesn't light up. I noticed that I had plugged it in the wrong way and I immediately unplugged it. Next I make another attempt and this time I plugged the pins entirely somewhere else, again I disconnect quickly. The third time I connect it properly and the power LED lights up (phew...)&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Unfortunately Vin on an &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Arduino Nano&lt;/a&gt; does not have a reverse polarity protection diode such as the &lt;a href=&quot;https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf&quot; rel=&quot;nofollow&quot;&gt;Arduino Uno PWRin&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Did I burn my board? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Very probable. For more details please see &quot;&lt;a href=&quot;http://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/&quot; rel=&quot;nofollow&quot;&gt;10 Ways to Destroy an Arduino&lt;/a&gt;&quot;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-26T14:07:16.813" LastActivityDate="2016-08-26T14:07:16.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28747" PostTypeId="1" AcceptedAnswerId="28754" CreationDate="2016-08-26T15:31:38.357" Score="2" ViewCount="1325" Body="&lt;p&gt;I'd like the double number 200.00 shown as &lt;code&gt;200.00&lt;/code&gt; on my LCD screen.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, when I pass just a number (&lt;code&gt;int&lt;/code&gt;) like 40 to the LCD, it uses it as an ASCII code to show a character on the display. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now I want to send a &lt;code&gt;double&lt;/code&gt; to it and it should be displayed as a double.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;void setup() {&#xA;   Wire.begin(0x63);&#xA;}&#xA;&#xA;&#xA;double f;&#xA;void loop() {&#xA;&#xA;  f = 200.00;&#xA;&#xA;  Wire.beginTransmission(0x63);&#xA;  Wire.write(byte(0x00));&#xA;  Wire.write(4); //HIDE CURSOR&#xA;  Wire.write(12); //CLEAR SCREEN&#xA;  Wire.write(13); //CURSOR 2nd LINE&#xA;  Wire.write(&quot;Frequenz: &quot;);&#xA;  Wire.write(f); //&amp;lt;- How to do this?&#xA;  Wire.write(&quot;Hz&quot;);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="25779" LastEditorUserId="84" LastEditDate="2016-08-28T09:32:09.620" LastActivityDate="2016-08-28T09:32:09.620" Title="Arduino Wire.h send double to lcd" Tags="|programming|lcd|wire-library|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28748" PostTypeId="1" CreationDate="2016-08-26T15:35:00.980" Score="3" ViewCount="701" Body="&lt;p&gt;This is similar to:&#xA;&lt;a href=&quot;https://arduino.stackexchange.com/questions/22319/is-this-function-subject-to-memory-fragmentation&quot;&gt;Is this function subject to memory fragmentation?&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to get my head around Memory fragmentation in Arduino's and embedded systems in general. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Currently I have a function in a &lt;code&gt;__lcdAux__&lt;/code&gt; Class which is responsible for doing basic operation on the lcd. &#xA;One of the members of the class is a char array &lt;code&gt;double2StrBuff1&lt;/code&gt; which is used with &lt;code&gt;__dtostrf()__&lt;/code&gt; to create a double which is then passed to &lt;code&gt;sprintf&lt;/code&gt;. So the following function (&lt;code&gt;__lcdAux::UpdatePosition__&lt;/code&gt;) is responsible for updating the position on the lcd.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void lcdAux::UpdatePosition(double MtXPosLengthUnits) {&#xA;    lcd-&amp;gt;setCursor(0, 2);&#xA;    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);&#xA;    sprintf(lcdBuff, &quot;X: %s&quot;, double2StrBuff1);&#xA;    lcd-&amp;gt;print(lcdBuff);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Currently, I am under the impression that by defining once the class as a global variable and then using it throughout the program, then the char array is allocated only once memory space. Therefore by using it afterwards no memory fragmentation occurs. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, I read that functions allocate space on the stack which is immediately recoved when the function is exited. Therefore I am curious if the following declaration is any different in terms of memory fragmentation.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void lcdAux::UpdatePosition(double MtXPosLengthUnits) {&#xA;    lcd-&amp;gt;setCursor(0, 2);&#xA;    char double2StrBuff1[10];&#xA;    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);&#xA;    sprintf(lcdBuff, &quot;X: %s&quot;, double2StrBuff1);&#xA;    lcd-&amp;gt;print(lcdBuff);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;To sum up:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;by putting  the declaration for variable &lt;code&gt;__char double2StrBuff1[10];__&lt;/code&gt;  inside the function, is the memory allocated from the stack and therefore recovered upon exiting the function (therefore there is no need to declarate a member variable on the class level), &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;OR &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;is the fact that &lt;code&gt;__double2StrBuff1__&lt;/code&gt; is a pointer means that the pointer is allocated in the stack but the values are located in the heap (therefore what I am doing makes sense)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;PS: Because some might point out that  &lt;code&gt;__&quot;X: %s&quot;__&lt;/code&gt; is worse in terms of memory usage and fragmentation, I'll state the following. Instead of the format string &lt;code&gt;__&quot;X:%s&quot;__&lt;/code&gt; I use a &lt;code&gt;_PROGMEM&lt;/code&gt; const &lt;code&gt;char_ array&lt;/code&gt; and &lt;code&gt;__strcpy_P()_&lt;/code&gt;, but to simplify the question I replaced it with the literal string , since I feel that is another problem. &lt;/p&gt;&#xA;" OwnerUserId="26093" LastEditorUserId="-1" LastEditorDisplayName="user24204" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-08-31T10:49:24.353" Title="Understanding memory fragmentation due to char arrays in functions" Tags="|string|memory|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28749" PostTypeId="2" ParentId="28744" CreationDate="2016-08-26T15:35:42.603" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Is it possible to program an ESP8266 12F using an Arduino Nano?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Yes, but it is much easier to use a FTDI for USB-to-Serial adaptation. Two buttons are also needed to activate the ESP8266 programming mode. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-27T08:54:37.490" LastActivityDate="2016-08-27T08:54:37.490" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28750" PostTypeId="2" ParentId="28747" CreationDate="2016-08-26T15:41:02.140" Score="1" Body="&lt;p&gt;Use &lt;code&gt;Wire.print()&lt;/code&gt;, instead of &lt;code&gt;Wire.write()&lt;/code&gt; which is intended only to output single bytes or byte arrays.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-26T15:41:02.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28751" PostTypeId="2" ParentId="28748" CreationDate="2016-08-26T15:49:26.897" Score="3" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;by putting the declaration for variable char double2StrBuff1[10];&#xA;  inside the function, is the memory allocated from the stack and&#xA;  therefore recovered upon exiting the function&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is correct.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;is the fact that double2StrBuff1 is a pointer means that the pointer&#xA;  is allocated in the stack but the values are located in the heap&#xA;  (therefore what I am doing makes sense)?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, &lt;code&gt;double2StrBuff1&lt;/code&gt; is not a pointer, it's an array. In C and C++,&#xA;when you use an array identifier, it decays to a pointer in many&#xA;situations. However, for the purpose of memory allocation, an array is&#xA;&lt;em&gt;very different&lt;/em&gt; from a pointer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Heap allocation only happens when using &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;new&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-26T15:49:26.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28753" PostTypeId="2" ParentId="28748" CreationDate="2016-08-26T16:05:27.440" Score="2" Body="&lt;p&gt;The examples in the question above use 1) global and 2) local aka stack allocation and do not give heap fragmentation. The heap is not involved. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is a version that may give heap fragmentation (though a very low risk): &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void lcdAux::UpdatePosition(double MtXPosLengthUnits) {&#xA;    lcd-&amp;gt;setCursor(0, 2);&#xA;    char* double2StrBuff1 = (char*) malloc(10);&#xA;    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);&#xA;    sprintf(lcdBuff, &quot;X: %s&quot;, double2StrBuff1);&#xA;    lcd-&amp;gt;print(lcdBuff);&#xA;    free(double2StrBuff1);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please not that heap allocation is very slow compared to stack allocation.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;C/C++ does not have any implicit heap allocations (in the language). A local array in a function is allocated on the stack and removed when the function returns. The only library functions that can generate stack fragmentation are &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__setjmp.html&quot; rel=&quot;nofollow&quot;&gt;setjmp and longjmp&lt;/a&gt; if used to create a &lt;a href=&quot;http://c2.com/cgi/wiki?SpaghettiStack&quot; rel=&quot;nofollow&quot;&gt;spaghetti stack&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-26T16:05:27.440" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28754" PostTypeId="2" ParentId="28747" CreationDate="2016-08-26T17:18:19.790" Score="2" Body="&lt;p&gt;The Arduino &lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;Wire&lt;/a&gt; class does only support &lt;a href=&quot;https://www.arduino.cc/en/Reference/WireWrite&quot; rel=&quot;nofollow&quot;&gt;write()&lt;/a&gt; of byte, string and vector of bytes. To write a double it must first be converted to a string. This can be done with the standard C library function &lt;a href=&quot;http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__avr__stdlib_1ga060c998e77fb5fc0d3168b3ce8771d42.html&quot; rel=&quot;nofollow&quot;&gt;dtostrf()&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double f;&#xA;&#xA;void loop() {&#xA;  char buf[10];&#xA;&#xA;  f = 200.00;&#xA;&#xA;  Wire.beginTransmission(0x63);&#xA;  Wire.write(byte(0x00));&#xA;  Wire.write(4); //HIDE CURSOR&#xA;  Wire.write(12); //CLEAR SCREEN&#xA;  Wire.write(13); //CURSOR 2nd LINE&#xA;  Wire.write(&quot;Frequenz: &quot;);&#xA;  Wire.write(dtostrf(f, 0, 2, buf));&#xA;  Wire.write(&quot;Hz&quot;);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The class inherits from &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Print.h&quot; rel=&quot;nofollow&quot;&gt;Print&lt;/a&gt; (via &lt;a href=&quot;https://www.arduino.cc/en/Reference/Stream&quot; rel=&quot;nofollow&quot;&gt;Stream&lt;/a&gt;) so that the overloaded member function &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Print.h#L67&quot; rel=&quot;nofollow&quot;&gt;print()&lt;/a&gt; for double can be used. In that case: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;double f;&#xA;&#xA;void loop() {&#xA;  f = 200.00;&#xA;&#xA;  Wire.beginTransmission(0x63);&#xA;  Wire.write(byte(0x00));&#xA;  Wire.write(4); //HIDE CURSOR&#xA;  Wire.write(12); //CLEAR SCREEN&#xA;  Wire.write(13); //CURSOR 2nd LINE&#xA;  Wire.write(&quot;Frequenz: &quot;);&#xA;  Wire.print(f);&#xA;  Wire.write(&quot;Hz&quot;);&#xA;  Wire.endTransmission();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that the maximum number of bytes to write (between beginTransmission and endTransmission) is &lt;a href=&quot;https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/src/Wire.h#L28&quot; rel=&quot;nofollow&quot;&gt;limited to 32&lt;/a&gt; in the standard configuration of the Arduino core. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastEditorUserId="13432" LastEditDate="2016-08-26T17:42:58.587" LastActivityDate="2016-08-26T17:42:58.587" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28756" PostTypeId="1" AcceptedAnswerId="28757" CreationDate="2016-08-26T18:04:49.030" Score="1" ViewCount="2259" Body="&lt;p&gt;So my problem is this, I have an Arduino Uno with an Adafruit Motor Shield (1.0) and an HC-06 Bluetooth Module and I want to use them at the same time, the problem is that the Motor Shield uses all the ports that I need for the HC-06 (TX, RX, GND and VCC). In addition to all that, my project needs to be light weight (It's a quadcopter). Is there any way that I could use both of them at the same time?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance!    &lt;/p&gt;&#xA;" OwnerUserId="26097" LastActivityDate="2020-08-08T17:13:02.877" Title="Motor Shield and HC-06 Bluetooth Module competing for pins" Tags="|arduino-uno|arduino-motor-shield|hc-06|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28757" PostTypeId="2" ParentId="28756" CreationDate="2016-08-26T18:37:10.330" Score="0" Body="&lt;p&gt;The motor shield doesn't actually use the TX and RX pins. Though as a shield it will go into all the arduino pins. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could either solder some wires to the TX and RX pins, or use something like the &lt;a href=&quot;https://www.adafruit.com/product/2077&quot; rel=&quot;nofollow&quot;&gt;proto shield&lt;/a&gt; to sandwich in the middle of it, and connect the BT module onto this shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could also remove all the male headers from the motor shield, and replace them with &lt;a href=&quot;https://www.adafruit.com/products/85&quot; rel=&quot;nofollow&quot;&gt;stacking headers&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-26T18:37:10.330" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28758" PostTypeId="1" AcceptedAnswerId="28759" CreationDate="2016-08-26T20:46:33.747" Score="1" ViewCount="409" Body="&lt;p&gt;I was connecting L293d Motor Driver IC with an Arduino Due Board. May be due to wrong connections, but when I made the grounds common, the Arduino LED goes off and Atmel IC heats up. When I reconnect my Due board with my PC anytime, the LED turns on and slowly dims to off and Atmel IC fries up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to repair it. What should I do? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have checked the input voltage of the &lt;strong&gt;AMS1117 3.3V regular IC&lt;/strong&gt; as 3.8 V, while the output is 2.2 V. If I externally give 5 volt at input again, the input voltages drops. The regulator is loading.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;I thought of replacing the regular IC?&#xA;Will that work?&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also I externally powered the Board with 3.3V by its pin labeled &quot;3.3V&quot; . The LEDs glow on and did not go off. But the Atmel Microcontroller IC becomes very hot.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What should I do?&lt;/p&gt;&#xA;" OwnerUserId="25632" LastEditorUserId="84" LastEditDate="2016-08-28T09:27:52.017" LastActivityDate="2019-03-18T04:47:33.903" Title="Arduino Due ( Atmel Microcontroller) IC Heat up and led goes off" Tags="|arduino-due|hardware|debug|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28759" PostTypeId="2" ParentId="28758" CreationDate="2016-08-26T21:18:29.740" Score="1" Body="&lt;p&gt;Motor driver boards exist to allow an MCU to &lt;em&gt;control&lt;/em&gt; a motor without having to supply its power. If you try to power motors from the Arduino as well, they draw too much current and things get hot or damaged.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 3.3v pin is only for supplying modest amounts of current at 3.3v &lt;em&gt;from&lt;/em&gt; a 5v Arduino. You can not back-power the board with it. I don't know what happens if you try, but I bet it isn't good...&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-26T21:18:29.740" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28760" PostTypeId="1" AcceptedAnswerId="28763" CreationDate="2016-08-26T21:31:32.617" Score="0" ViewCount="5024" Body="&lt;p&gt;I'm building web based remote control system for esp8266. In arduino IDE, using the ESP libraries. To, send data to the server, I'm using http post.&#xA;For some settings, I need to transfer 30 or so, different values over a single post request.  And assign it to different type of variables.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;so, from this:&#xA;192.168.1.101/testpost?lenght=10&amp;amp;1=100&amp;amp;2=true&amp;amp;3=1800&amp;amp;4=125&#xA;&#xA;i need this:&#xA;&#xA;uint8_t brightness = 100;&#xA;bool randomOrder = true;&#xA;uint16_t Delay = 1800;&#xA;uint8_t Position = 125;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This is the relevant code. Basically, my idea is, to send the lenght of the array (will be different each time.) in the first argument.&#xA;Than create a for loop that put every value in a array into variable pointers. But, since lots of different type variables going on, i'm not sure how to do that.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;ESP8266WiFi.h&amp;gt;&#xA;#include &amp;lt;WiFiClient.h&amp;gt;&#xA;#include &amp;lt;ESP8266WebServer.h&amp;gt;&#xA;#include &amp;lt;ESP8266mDNS.h&amp;gt;&#xA;&#xA;//values i need to set in a single post.&#xA;uint8_t settings0;&#xA;bool brightness; &#xA;uint16_t randomOrder; &#xA;uint8_t Delay;&#xA;&#xA;void setup {&#xA;//relevant code that handels post request.&#xA;server.on(&quot;/testpost&quot;, HTTP_POST, []() {&#xA;&#xA;String ZeroValue = server.arg(&quot;lenght&quot;);&#xA;&#xA;int lenght = ZeroValue.toInt();&#xA;&#xA;//this doesnt really work, but its a starting idea.&#xA;int* SettingsArray[4] = {&amp;amp;settings0, &amp;amp;brightness, &amp;amp;randomOrder, &amp;amp;Delay};&#xA;&#xA;for( int i = 0; i &amp;lt; lenght; i++) {&#xA;&#xA;     String PresetSettings = server.arg(i);&#xA;     SettingsArray[i] = PresetSettings.toInt();&#xA;    }&#xA;});&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ultimately, I can just do that, but I'm wondering if there is a more elegant solution.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brightness = SettingsArray[1];&#xA;randomOrder = SettingsArray[2];&#xA;Delay = SettingsArray[3];&#xA;Position = SettingsArray[4];&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="24157" LastActivityDate="2018-03-23T11:56:50.307" Title="Best way to assign value to lot of variables" Tags="|esp8266|variables|array|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28761" PostTypeId="1" AcceptedAnswerId="28762" CreationDate="2016-08-26T22:30:32.160" Score="3" ViewCount="12517" Body="&lt;p&gt;I have a 12V addressable RGB strip that I want to control with an Arduino, the chips are ws2811s, is there a way to do this as the Arduino is 5V and 3.3V?&lt;/p&gt;&#xA;" OwnerUserId="26100" LastEditorDisplayName="user24204" LastEditDate="2016-08-26T22:34:02.007" LastActivityDate="2019-04-15T23:32:21.147" Title="Controlling a digital 12V addressable RGB led strip with Arduino?" Tags="|arduino-uno|led|rgb-led|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28762" PostTypeId="2" ParentId="28761" CreationDate="2016-08-26T22:44:50.720" Score="4" Body="&lt;p&gt;&lt;s&gt;The only signal you need to worry about is DIN (data in) which is normally 5V from an Arduino. Use that to switch a MOSFET or transistor to convert the digital pulses to 12V. In other words, the Arduino switches the transistor, the transistor outputs 0 or 12 V.&lt;/s&gt;&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Judging by &lt;a href=&quot;http://doityourselfchristmas.com/forums/showthread.php?23588-WS2811-5050-Pixels-at-12v-Signaling-at-5v&quot; rel=&quot;nofollow&quot;&gt;this link&lt;/a&gt; you still just send 5V digital switching to the strip.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The data signal never needs to be 12 volts. The 12 volt pixels all drop the voltage down to about 5 volts to operate the chip. Usually just a resistor and a zener diode, sometimes just a resistor. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;In other words, connect the &quot;power&quot; pin to +12V, and the ground pin to Gnd from your power supply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Connect the Din (data in) to your Arduino pin directly. Of course, &lt;em&gt;also connect the Arduino ground to the ground pin&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also see &lt;a href=&quot;https://www.youtube.com/watch?v=pu1kzJGMZyA&quot; rel=&quot;nofollow&quot;&gt;this Youtube video&lt;/a&gt;. On the comments he says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;These 12v WS2811 &quot;pixels&quot; still use 5v signalling. You simply connect the 12v source power directly to the strip, tie the ground to the arduino and then treat them as if they were a 5v strip.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-26T23:39:04.953" LastActivityDate="2016-08-26T23:39:04.953" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28763" PostTypeId="2" ParentId="28760" CreationDate="2016-08-26T23:05:47.333" Score="1" Body="&lt;p&gt;The WebServer class supports &lt;a href=&quot;https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/src/ESP8266WebServer.h#L93&quot; rel=&quot;nofollow&quot;&gt;argument lookup by name&lt;/a&gt;. This should allow HTTP argument parsing that does not require length and/or specific order:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;192.168.1.101/testpost?brightness=100&amp;amp;randomOrder=true&amp;amp;delay=1800&amp;amp;position=125&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And parse with:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;brightness = server.arg(&quot;brightness&quot;).toInt();&#xA;randomOrder = server.arg(&quot;randomOrder&quot;).toInt();&#xA;Delay = server.arg(&quot;delay&quot;).toInt();&#xA;Position = server.arg(&quot;position&quot;).toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Please note that some value will require cast (and there might be a need for special handling of &quot;true&quot; and &quot;false&quot;). For further robustness each argument name needs to be checked that it is available. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String arg = server.arg(&quot;argName&quot;);&#xA;val = (arg.length() == 0 ? defaultVal : arg.toInt());&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Or simply:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String arg = server.arg(&quot;argName&quot;);&#xA;if (arg.length() != 0) val = arg.toInt();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Cheers!&lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-26T23:05:47.333" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28764" PostTypeId="1" CreationDate="2016-08-26T23:19:29.117" Score="2" ViewCount="40278" Body="&lt;p&gt;I am a beginner in the Arduino world. I made some basic projects of the book that comes with the starter kit (it's was borrowed by a friend of mine) and also I used a humidity, a temperature sensors and a LCD display.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to buy an Arduino Uno for measure &lt;strong&gt;room temperature, humidity, carbon monoxide, carbon dioxin and maybe a couple more variables. I will to use 4 sensors, 1 buzzer, 1 LCD display and 1 ESP8266 serial WIFI wireless module&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After this work I will add for functionalities but as I have a lot of components I am not sure if the Arduino Uno can supports them because it has a limited quantity of pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do I need an Arduino with more pins? what if I use all these pins and I need more? Can the Arduino Uno be expanded with more pins?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As the Arduino Uno is a very small computer, can its processor support all these components and their operations? &lt;/p&gt;&#xA;" OwnerUserId="26074" LastEditorDisplayName="user24204" LastEditDate="2016-08-29T20:43:58.583" LastActivityDate="2018-12-20T13:03:11.200" Title="How many sensors can be supported by a single Arduino unit?" Tags="|arduino-uno|sensors|pins|components|" AnswerCount="4" CommentCount="8" ContentLicense="CC BY-SA 3.0" />
  <row Id="28765" PostTypeId="1" AcceptedAnswerId="28861" CreationDate="2016-08-27T02:32:26.037" Score="2" ViewCount="1171" Body="&lt;p&gt;I am a beginner who would like to buy an Arduino Yún (58 dollars). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is retired so will I have any problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Else I can buy an Arduino Uno and an Arduino Yún Shield. But in this case I don't understand the difference between an &lt;strong&gt;Arduino Uno + Arduino Yún Shield&lt;/strong&gt; and an &lt;strong&gt;Arduino Uno + ESP8266 serial WIFI wireless module&lt;/strong&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Arduino Yún Shield: I can't find the price. I only found an Iduino.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/QnX0E.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QnX0E.jpg&quot; alt=&quot;Arduino Yún Shield&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;ESP8266 serial WIFI wireless module: 7 dollars.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/LTufu.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/LTufu.jpg&quot; alt=&quot;WiFi Module - ESP8266&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26074" LastActivityDate="2016-11-17T22:58:42.983" Title="Should I buy a retired Arduino?" Tags="|arduino-uno|esp8266|wifi|shields|arduino-yun|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28766" PostTypeId="2" ParentId="28700" CreationDate="2016-08-27T04:41:20.247" Score="-1" Body="&lt;p&gt;I fixed it. I just reinstalled the drivers. &lt;/p&gt;&#xA;" OwnerUserId="26061" LastEditorUserId="10794" LastEditDate="2016-08-29T07:18:56.213" LastActivityDate="2016-08-29T07:18:56.213" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28767" PostTypeId="2" ParentId="20724" CreationDate="2016-08-27T06:47:41.897" Score="2" Body="&lt;p&gt;Double click the reset button on the board. Then it will show in the Port list :-)&lt;/p&gt;&#xA;" OwnerUserId="26103" LastActivityDate="2016-08-27T06:47:41.897" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28768" PostTypeId="1" AcceptedAnswerId="28823" CreationDate="2016-08-27T07:57:46.657" Score="2" ViewCount="117" Body="&lt;p&gt;&lt;em&gt;&lt;sup&gt;&lt;strong&gt;Question completely rewritten&lt;/strong&gt;&lt;/sup&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Trying to assess an Arduino project feasibility. New to Arduino... but did a lot of controller programming (assembly), Roboteq (C) and Phidgets (C++) , using various kinds of motors and sensors ; and reading the Arduino documentation makes me feel confident interfacing and programming shouldn't be an issue.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, before investing time (and some money) in the project, I thought it'd be better to ask here if Arduino is the right choice, considering&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a non-latching &lt;a href=&quot;https://en.wikipedia.org/wiki/Hall_effect_sensor&quot; rel=&quot;nofollow&quot;&gt;Hall sensor&lt;/a&gt; is to be connected to Analog 0, &lt;code&gt;analogRead()&lt;/code&gt; to return a [0,1023] value, used as a proximity sensor. This should be straight forward.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Question →&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;while the Arduino runs my program, and is still connected to the PC (USB), is it possible to synchronously or asynchronously send commands from the PC to the Arduino. I.e. can the Arduino poll if there is something coming from USB (synchronous), or is there a way for the PC via USB to have Arduino do something (asynchronously)?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Thank you.&lt;/p&gt;&#xA;" OwnerUserId="26104" LastEditorUserId="26104" LastEditDate="2016-08-29T01:35:21.190" LastActivityDate="2016-08-29T07:56:50.173" Title="Arduino project feasibility" Tags="|sensors|usb|arduino-motor-shield|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28769" PostTypeId="2" ParentId="24665" CreationDate="2016-08-27T08:51:14.230" Score="1" Body="&lt;p&gt;I had worked on GSM long back ago and sometimes it becomes very difficult to debug the problem. However u need to just check whether the AT commands are being sent properly to the GSM module. I had tried using Software Serial but it did not work for me but when I switched to the usual Serial port it worked like a charm. Few things that you need to check are:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Check the baud rate of GSM module. Does it match with the baud rate of Software Serial.&lt;/li&gt;&#xA;&lt;li&gt;Do a if-else check to see whether the commands are actually being sent to the GSM module. The println() returns the number of bytes written so you can do like this in your sendSMS() function.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&#xA;  int a; //To store the number of bytes written&#xA;  a=SIM900.println(&quot;AT command to be sent&quot;);&lt;br&gt;&#xA;  if(a)&lt;br&gt;&#xA;  {&lt;br&gt;&#xA;  Serial.println(&quot;Command sent&quot;);&lt;br&gt;&#xA;  }&lt;br&gt;&#xA;  else&lt;br&gt;&#xA;  {&lt;br&gt;&#xA;  Serial.println(&quot;Command not sent&quot;);&lt;br&gt;&#xA;  }&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Now upload the code and open the serial monitor to see whether the command is actually being sent to the GSM module or not.&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;You also need to check whether the format of your AT command is correct. Because you need to send &lt;strong&gt;\n(newline) and\r(carriage return)&lt;/strong&gt; at the end of every AT command to ensure proper operation. For this you need to read the response sent back by the GSM module after every command. This can be done by reading the Software serial port and the printing the response onto the Serial monitor.&lt;/li&gt;&#xA;&lt;li&gt;You also need to check whether your GSM module has detected the SIM card. Usually this is indicated by an onboard LED that blinks after every &lt;strong&gt;3 seconds&lt;/strong&gt;.   &lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I think your code is pretty much correct but try to ensure that everything is setup properly as I said.&#xA;Here is my code but I used Serial port instead:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;&lt;code&gt;&#xA;  void setup()&#xA;  {&lt;br&gt;&#xA;    Serial.begin(9600);&lt;br&gt;&#xA;    delay(10000);  \\For initialization purpose&lt;br&gt;&#xA;  }&lt;br&gt;&#xA;  void sendSMS()&lt;br&gt;&#xA;  {&#xA;    Serial.println(&quot;AT+CMGF=1&quot;);&lt;br&gt;&#xA;    delay(5000);&#xA;    Serial.println(&quot;AT+CMGS=\&quot;Phone number with international code\&quot;&quot;);&lt;br&gt;&#xA;    delay(5000); &#xA;    Serial.print(&quot;Hello&quot;);&lt;br&gt;&#xA;    delay(5000);&#xA;    Serial.println((char)26);&lt;br&gt;&#xA;    delay(5000);&lt;br&gt;&#xA;  }&lt;br&gt;&#xA;  void loop()&lt;br&gt;&#xA;  {&lt;br&gt;&#xA;    sendSMS();&lt;br&gt;&#xA;    do&#xA;    {&lt;br&gt;&#xA;    }while(1);&lt;br&gt;&#xA;  }&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This code will send the SMS once so you need to reset the board for sending another SMS or you can remove the do while loop for continuous operation.You can adjust the delay accordingly.&lt;/p&gt;&#xA;" OwnerUserId="25660" LastEditorUserId="25660" LastEditDate="2016-08-27T16:45:26.050" LastActivityDate="2016-08-27T16:45:26.050" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28771" PostTypeId="1" AcceptedAnswerId="28773" CreationDate="2016-08-27T09:14:17.300" Score="1" ViewCount="308" Body="&lt;p&gt;I am looking for a more elegant way to write a function that performs timer-based tasks as in the case of the code below, which essentially collects 5 sample values from a microphone module over a given period of time and then computes their average. It is important that it does not use the &lt;code&gt;delay()&lt;/code&gt; function because other tasks are supposed to run in the background which should not be affected by the delay. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  int sensorPin = A0; &#xA;  int ledPin = 13; //  pin for the LED&#xA;  int sensorValue = 0; // variable to store the value coming from the sensor&#xA;  unsigned long timer;&#xA;  int interv = 50;&#xA;  unsigned long sampleArray[] = {0, 0, 0, 0 , 0};&#xA;  unsigned long millisaver;&#xA;&#xA;&#xA;  void setup ()&#xA;  {&#xA;    pinMode (ledPin, OUTPUT);&#xA;    Serial.begin (9600);&#xA;&#xA;  }&#xA;&#xA;  void loop ()&#xA;  {&#xA;&#xA;    if (millis() &amp;gt; 2000) {&#xA;      if (millis() &amp;lt; 2050) {&#xA;        millisaver = millis();&#xA;        timer = (int) millisaver;&#xA;        Serial.println(timer);&#xA;      }&#xA;      if ( millis() &amp;gt; timer &amp;amp;&amp;amp; millis() &amp;lt; timer + interv ) {&#xA;        sampleArray[0] = sensorValue = analogRead (sensorPin);&#xA;      }&#xA;      else if ( millis() &amp;gt; timer+interv &amp;amp;&amp;amp; millis() &amp;lt; timer + interv*2 ) {&#xA;        sampleArray[1] = sensorValue = analogRead (sensorPin);&#xA;      }&#xA;      else if ( millis() &amp;gt; timer+interv*2 &amp;amp;&amp;amp; millis() &amp;lt; timer + interv*3 ) {&#xA;        sampleArray[2] = sensorValue = analogRead (sensorPin);&#xA;&#xA;      }&#xA;      else if ( millis() &amp;gt; timer+interv*3 &amp;amp;&amp;amp; millis() &amp;lt; timer + interv*4 ) {&#xA;        sampleArray[3] = sensorValue = analogRead (sensorPin);&#xA;&#xA;      }&#xA;      else if ( millis() &amp;gt; timer+interv*4 &amp;amp;&amp;amp; millis() &amp;lt; timer + interv*5 ) {&#xA;        sampleArray[4] = sensorValue = analogRead (sensorPin);&#xA;      }&#xA;      else if ( millis() &amp;gt; timer+interv*5) {&#xA;        unsigned long averageVal = (sampleArray[0] + sampleArray[1] + sampleArray[2] +sampleArray[3] + sampleArray[4])/5 ;&#xA;        Serial.println(averageVal);&#xA;        millisaver = millis();&#xA;        timer = (int) millisaver;&#xA;      }&#xA;    }&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="15863" LastEditorDisplayName="user24204" LastEditDate="2016-08-28T09:28:44.373" LastActivityDate="2016-09-04T23:03:35.283" Title="A more elegant way to deal with timers without using delay()?" Tags="|sensors|arduino-nano|code-optimization|" AnswerCount="3" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28772" PostTypeId="2" ParentId="28771" CreationDate="2016-08-27T10:48:52.930" Score="1" Body="&lt;p&gt;You need to make a function which is pretty much completely self contained. Within the function should be a counter so it knows which sample it is on, and a timestamp to know when it should next run. The function should also inform the caller when it has a full sample set to process.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I haven't tested this (don't know if it even compiles) but something like this might work:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;bool getSample(uint8_t pin, unsigned long *samples) {&#xA;    static uint32_t ts = millis();&#xA;    static uint8_t sampleNumber = 0;&#xA;&#xA;    if (millis() - ts &amp;gt;= 50) {&#xA;        ts += 50;&#xA;        samples[sampleNumber++] = analogRead(pin);&#xA;        if (sampleNumber == 5) {&#xA;            sampleNumber = 0;&#xA;            return true; // We have 5 samples&#xA;        }&#xA;    }&#xA;    return false; // We don't have 5 samples yet.&#xA;}&#xA;&#xA;// ... later ...&#xA;&#xA;if (getSample(sensorPin, sampleArray)) {&#xA;    // Process Samples&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-27T10:48:52.930" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28773" PostTypeId="2" ParentId="28771" CreationDate="2016-08-27T10:53:42.897" Score="2" Body="&lt;p&gt;For excact timing there is feature called ADC Auto Trigger mode. For example millis() are usually counted by timer 0 overflow (on AVR based Arduinos) every 1024us (I suppose it's because of PWM - otherwise it could be set exactly to 1ms). So if you don't mind that little offset, you can configure &#xA;ADC with Timer 0 Overflow and use every 20 measure only.&#xA;But don't forget that analogRead on another pin changes ADC channel and you will get something else if you don't check it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As an auto trigger source can be used one of these:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Free Running Mode&lt;/li&gt;&#xA;&lt;li&gt;Analog Comparator&lt;/li&gt;&#xA;&lt;li&gt;External Interrupt 0&lt;/li&gt;&#xA;&lt;li&gt;Timer/Counter 0 Compare Match A&lt;/li&gt;&#xA;&lt;li&gt;Timer/Counter 0 Overflow&lt;/li&gt;&#xA;&lt;li&gt;Timer/Counter 1 Compare Match B&lt;/li&gt;&#xA;&lt;li&gt;Timer/Counter 1 Overflow&lt;/li&gt;&#xA;&lt;li&gt;Timer/Counter 1 Capture Event&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For ATMega328 it can be something like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;    Serial.begin(57600);&#xA;&#xA;    // ADC setup is done by arduino framework, but it's possible to change it slightly (for ATMega328) :&#xA;    ADCSRB  = _BV(ADTS2); // ADTS2..0 = 100, Timer 0 overflow as trigger source&#xA;    ADCSRA |= _BV(ADATE); // enable auto trigger mode    &#xA;    ADCSRA |= _BV(ADIF); // reset conversion interrupt flag (by writing log 1)&#xA;&#xA;    analogRead(A0); // dummy read to set correct channel and to start auto trigger mode&#xA;}&#xA;&#xA;int8_t sample_count = 0;&#xA;int8_t sample_index = 0;&#xA;uint16_t  samples[] = {0, 0, 0, 0, 0};&#xA;uint16_t sample_sum = 0;&#xA;&#xA;void loop() {&#xA;    if (ADCSRA &amp;amp; _BV(ADIF)) {&#xA;        ADCSRA |= _BV(ADIF); // reset ADIF flag by writing logic 1 into it (mentioned in datasheet)&#xA;        if (++sample_count == 20) {&#xA;            sample_count = 0; // reset sample_count, as we wan't every 20th&#xA;&#xA;            sample_sum -= samples[sample_index];&#xA;            samples[sample_index] = ADC; // read value&#xA;            sample_sum += samples[sample_index];&#xA;&#xA;            if (++sample_index == 5) { // reset index and count and send average&#xA;                sample_index = 0;&#xA;                Serial.println(sample_sum);&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-09-04T23:03:35.283" LastActivityDate="2016-09-04T23:03:35.283" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28775" PostTypeId="2" ParentId="28771" CreationDate="2016-08-27T11:36:25.813" Score="1" Body="&lt;p&gt;You didn't say what you want to do with those samples. If you want to&#xA;estimate the level of sound intensity, your whole approach is completely&#xA;wrong. First, your sampling rate (20&amp;nbsp;Hz) is way too low: you should&#xA;sample at least at twice the frequency of interest, typically at&#xA;8&amp;nbsp;kHz or more. Then you have to subtract the DC offset added by the&#xA;microphone module, then square the result in order to get an&#xA;instantaneous intensity, then low-pass filter to get a usable intensity&#xA;reading. As Majenko said, if you average (or low-pass filter) the&#xA;samples &lt;em&gt;before&lt;/em&gt; squaring, you would detect zero sound.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've written a sound meter program for an Arduino Uno that does exactly&#xA;that, and it's available as a GitHub Gist:&#xA;&lt;a href=&quot;https://gist.github.com/edgar-bonet/e693799f58a545ca89a2&quot; rel=&quot;nofollow&quot;&gt;sound-meter.ino&lt;/a&gt;.&#xA;It uses the auto-trigger mode as explained by KIIV, but with free&#xA;running mode instead of a timer. This gives 9.6&amp;nbsp;kHz sampling rate.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-27T11:36:25.813" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28777" PostTypeId="2" ParentId="26770" CreationDate="2016-08-27T11:56:09.793" Score="0" Body="&lt;p&gt;May I recommend that you take a look at the data stream that MatLab produces? That will &lt;em&gt;show&lt;/em&gt; you what it is producing, and therefore what code you should write in the Arduino to process it.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If you had a second COM port on the PC, and a cable to connect your PC's MatLab port (COM3) to that port, you could use Arduino's Serial Monitor to show the data - make the Arduino Serial Monitor &quot;pretend&quot; to be the Arduino listening to MatLab.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;But on the assumption that you don't have a second port or a NULL Modem serial cable, another alternative is to use a PC program such as &quot;&lt;a href=&quot;http://www.eltima.com/products/serial-port-monitor/&quot; rel=&quot;nofollow&quot;&gt;Serial Port Monitor&lt;/a&gt;&quot; (I've heard good things about this program, although I've never used it). Apparently you can use it for 14 days to trial it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically it presents a window (you'll want the Window called &quot;Terminal&quot;, not any of the others) that shows what is being sent and received on the COM port - even data generated by another program. Shut down MatLab, start this program, tell it to listen to COM3, set the baudrate etc, press Go - then start MatLab again.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When MatLab sends data, you'll see whether it's sending &quot;0.125&quot; or &quot;0y@/&quot; - and assuming that you don't want to decode the latter, how to change your MatLab code so that it looks like the former! Then you can change the Arduino code to understand values like &quot;0.125&quot;.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-08-27T11:56:09.793" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28778" PostTypeId="2" ParentId="26770" CreationDate="2016-08-27T11:56:41.337" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Why am I always getting 48 with serial communication?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your Arduino sketch (snippet) is &lt;a href=&quot;https://www.arduino.cc/en/Serial/Read&quot; rel=&quot;nofollow&quot;&gt;reading a byte&lt;/a&gt; and writing the value, not the character. The value 48 in &lt;a href=&quot;http://www.asciitabell.se/&quot; rel=&quot;nofollow&quot;&gt;ASCII&lt;/a&gt; is the character '0'. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The below loop() function will echo all the characters received. &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void loop()&#xA;{&#xA;  while (Serial.available()) {&#xA;     char c = Serial.read();&#xA;     Serial.println(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This could be a good starting point when debugging what is actually written from MATLAB. &lt;/p&gt;&#xA;" OwnerUserId="13432" LastActivityDate="2016-08-27T11:56:41.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28779" PostTypeId="1" CreationDate="2016-08-27T13:19:44.813" Score="2" ViewCount="1984" Body="&lt;p&gt;I'm working on Linux Mint 18 Sarah (earlier Ubuntu 16.04 LTS) system. I've installed Arduino IDE using command &lt;code&gt;sudo apt-get install arduino&lt;/code&gt; and I've added me dialout group using &lt;code&gt;sudo usermod -aG dialout $(whoami)&lt;/code&gt;. This is results of executing &lt;code&gt;groups&lt;/code&gt; command:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;hubert@hubert-SATELLITE-C660D ~ $ groups&#xA;dialout adm cdrom sudo dip plugdev lpadmin sambashare hubert&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try upload following code to Arduino Leonardo:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA;  Blink&#xA;  Turns on an LED on for one second, then off for one second, repeatedly.&#xA;&#xA;  This example code is in the public domain.&#xA; */&#xA;&#xA;// Pin 13 has an LED connected on most Arduino boards.&#xA;// give it a name:&#xA;int led = 13;&#xA;&#xA;// the setup routine runs once when you press reset:&#xA;void setup() {                &#xA;  // initialize the digital pin as an output.&#xA;  pinMode(led, OUTPUT);     &#xA;}&#xA;&#xA;// the loop routine runs over and over again forever:&#xA;void loop() {&#xA;  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)&#xA;  delay(500);               // wait for a second&#xA;  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW&#xA;  delay(500);               // wait for a second&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;orange LED marked with L letter on my board blinks and next I get following error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;Wielkość binarna szkicu: 4 736 bajtów (maksymalnie: 28 672 bajtów)&#xA;processing.app.debug.RunnerException: Couldn’t find a Leonardo on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.&#xA;    at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:153)&#xA;    at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)&#xA;    at processing.app.Sketch.upload(Sketch.java:1671)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1627)&#xA;    at processing.app.Sketch.exportApplet(Sketch.java:1599)&#xA;    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)&#xA;    at java.lang.Thread.run(Thread.java:745)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;On my IDE Arduino shows on &lt;code&gt;/dev/ttyACM0&lt;/code&gt; serial port. When I try running this IDE on root privileges, I get the same error. On root privileges serial port is changing from &lt;code&gt;/dev/ttyACM0&lt;/code&gt; to &lt;code&gt;/dev/ttyACM1&lt;/code&gt;, from &lt;code&gt;/dev/ttyACM1&lt;/code&gt; to &lt;code&gt;/dev/ttyACM2&lt;/code&gt; etc. I tried different USB cabels and reset Arduino but these ways nothing help. On Windows 7 my Arduino works and Arduino IDE uploads code without problems. Can anybody help me?&lt;/p&gt;&#xA;" OwnerUserId="7605" LastEditorUserId="37523" LastEditDate="2019-06-25T18:21:09.333" LastActivityDate="2019-06-25T18:21:09.333" Title="Arduino Leonardo isn't detected by Linux Mint on serial port /dev/ttyACM0" Tags="|arduino-leonardo|uploading|" AnswerCount="0" CommentCount="12" ContentLicense="CC BY-SA 4.0" />
  <row Id="28780" PostTypeId="1" AcceptedAnswerId="28784" CreationDate="2016-08-27T13:22:16.517" Score="1" ViewCount="520" Body="&lt;p&gt;I'm trying to provide analog control to a Bluetooth controlled car, via Arduino. I have joystick app (as the pot).&#xA;It send values between 0 to 255&#xA;So I'm thinking... Whether this flow down here  will work?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Joystick app --&gt; Bluetooth Rx --&gt; DAC --&gt; Vs pin of L293D. Or motor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is Arduino required at all? Or is the serial word enough to translate into voltage via DAC?&lt;/p&gt;&#xA;" OwnerUserId="26117" LastActivityDate="2016-08-27T15:19:50.637" Title="Can I use a DAC with an L293D driver?" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="16" ContentLicense="CC BY-SA 3.0" />
  <row Id="28781" PostTypeId="1" CreationDate="2016-08-27T13:32:49.410" Score="3" ViewCount="111" Body="&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt;&#xA;Is there a way to collect any data (e.g. MAC addresses, installed devices, driver versions, etc.) from a PC by simply connecting an Arduino via USB to it, so that this PC can be clearly identified? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&#xA;Basically, I`m using an Arduino to send some text to a computer by emulating a keyboard, but I don´t want the text to be sent to any computer I connect the Arduino with. That is why I want the PC to be identified first.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;To be clear: this should be done without having to install programs on the PC in the first place.&lt;/em&gt;&lt;/p&gt;&#xA;" OwnerUserId="11039" LastActivityDate="2016-11-20T15:30:24.187" Title="Identify connected PC per Arduino" Tags="|serial|usb|communication|windows|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28782" PostTypeId="1" CreationDate="2016-08-27T14:06:07.820" Score="3" ViewCount="707" Body="&lt;p&gt;I tried connect my Arduino Uno R3 with module camera VC0706 following this instruction of Adafruit: &lt;a href=&quot;https://learn.adafruit.com/ttl-serial-camera/using-the-camera&quot; rel=&quot;nofollow&quot;&gt;https://learn.adafruit.com/ttl-serial-camera/using-the-camera&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;[VC0706] --- [Arduino]&#xA;  Vcc    ---   +5V&#xA;  GND    ---   GND&#xA;  Tx     ---   PIN 2&#xA;  Rx     ---   PIN 3&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And upload this example source code: &lt;strong&gt;Snapshot.ino&lt;/strong&gt; of &lt;strong&gt;Adafruit_VC0706&lt;/strong&gt; library to my Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// This is a basic snapshot sketch using the VC0706 library.&#xA;// On start, the Arduino will find the camera and SD card and&#xA;// then snap a photo, saving it to the SD card.&#xA;// Public domain.&#xA;&#xA;// If using an Arduino Mega (1280, 2560 or ADK) in conjunction&#xA;// with an SD card shield designed for conventional Arduinos&#xA;// (Uno, etc.), it's necessary to edit the library file:&#xA;//   libraries/SD/utility/Sd2Card.h&#xA;// Look for this line:&#xA;//   #define MEGA_SOFT_SPI 0&#xA;// change to:&#xA;//   #define MEGA_SOFT_SPI 1&#xA;// This is NOT required if using an SD card breakout interfaced&#xA;// directly to the SPI bus of the Mega (pins 50-53), or if using&#xA;// a non-Mega, Uno-style board.&#xA;&#xA;#include &amp;lt;Adafruit_VC0706.h&amp;gt;&#xA;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;SD.h&amp;gt;&#xA;&#xA;// comment out this line if using Arduino V23 or earlier&#xA;#include &amp;lt;SoftwareSerial.h&amp;gt;         &#xA;&#xA;// uncomment this line if using Arduino V23 or earlier&#xA;// #include &amp;lt;NewSoftSerial.h&amp;gt;       &#xA;&#xA;// SD card chip select line varies among boards/shields:&#xA;// Adafruit SD shields and modules: pin 10&#xA;// Arduino Ethernet shield: pin 4&#xA;// Sparkfun SD shield: pin 8&#xA;// Arduino Mega w/hardware SPI: pin 53&#xA;// Teensy 2.0: pin 0&#xA;// Teensy++ 2.0: pin 20&#xA;#define chipSelect 10&#xA;&#xA;// Pins for camera connection are configurable.&#xA;// With the Arduino Uno, etc., most pins can be used, except for&#xA;// those already in use for the SD card (10 through 13 plus&#xA;// chipSelect, if other than pin 10).&#xA;// With the Arduino Mega, the choices are a bit more involved:&#xA;// 1) You can still use SoftwareSerial and connect the camera to&#xA;//    a variety of pins...BUT the selection is limited.  The TX&#xA;//    pin from the camera (RX on the Arduino, and the first&#xA;//    argument to SoftwareSerial()) MUST be one of: 62, 63, 64,&#xA;//    65, 66, 67, 68, or 69.  If MEGA_SOFT_SPI is set (and using&#xA;//    a conventional Arduino SD shield), pins 50, 51, 52 and 53&#xA;//    are also available.  The RX pin from the camera (TX on&#xA;//    Arduino, second argument to SoftwareSerial()) can be any&#xA;//    pin, again excepting those used by the SD card.&#xA;// 2) You can use any of the additional three hardware UARTs on&#xA;//    the Mega board (labeled as RX1/TX1, RX2/TX2, RX3,TX3),&#xA;//    but must specifically use the two pins defined by that&#xA;//    UART; they are not configurable.  In this case, pass the&#xA;//    desired Serial object (rather than a SoftwareSerial&#xA;//    object) to the VC0706 constructor.&#xA;&#xA;// Using SoftwareSerial (Arduino 1.0+) or NewSoftSerial (Arduino 0023 &amp;amp; prior):&#xA;#if ARDUINO &amp;gt;= 100&#xA;// On Uno: camera TX connected to pin 2, camera RX to pin 3:&#xA;SoftwareSerial cameraconnection = SoftwareSerial(2, 3);&#xA;// On Mega: camera TX connected to pin 69 (A15), camera RX to pin 3:&#xA;//SoftwareSerial cameraconnection = SoftwareSerial(69, 3);&#xA;#else&#xA;NewSoftSerial cameraconnection = NewSoftSerial(2, 3);&#xA;#endif&#xA;&#xA;Adafruit_VC0706 cam = Adafruit_VC0706(&amp;amp;cameraconnection);&#xA;&#xA;// Using hardware serial on Mega: camera TX conn. to RX1,&#xA;// camera RX to TX1, no SoftwareSerial object is required:&#xA;//Adafruit_VC0706 cam = Adafruit_VC0706(&amp;amp;Serial1);&#xA;&#xA;void setup() {&#xA;&#xA;  // When using hardware SPI, the SS pin MUST be set to an&#xA;  // output (even if not connected or used).  If left as a&#xA;  // floating input w/SPI on, this can cause lockuppage.&#xA;#if !defined(SOFTWARE_SPI)&#xA;#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&#xA;  if(chipSelect != 53) pinMode(53, OUTPUT); // SS on Mega&#xA;#else&#xA;  if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.&#xA;#endif&#xA;#endif&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;VC0706 Camera snapshot test&quot;);&#xA;&#xA;  // see if the card is present and can be initialized:&#xA;  if (!SD.begin(chipSelect)) {&#xA;    Serial.println(&quot;Card failed, or not present&quot;);&#xA;    // don't do anything more:&#xA;    return;&#xA;  }  &#xA;&#xA;  // Try to locate the camera&#xA;  if (cam.begin()) {&#xA;    Serial.println(&quot;Camera Found:&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;No camera found?&quot;);&#xA;    return;&#xA;  }&#xA;  // Print out the camera version information (optional)&#xA;  char *reply = cam.getVersion();&#xA;  if (reply == 0) {&#xA;    Serial.print(&quot;Failed to get version&quot;);&#xA;  } else {&#xA;    Serial.println(&quot;-----------------&quot;);&#xA;    Serial.print(reply);&#xA;    Serial.println(&quot;-----------------&quot;);&#xA;  }&#xA;&#xA;  // Set the picture size - you can choose one of 640x480, 320x240 or 160x120 &#xA;  // Remember that bigger pictures take longer to transmit!&#xA;&#xA;  cam.setImageSize(VC0706_640x480);        // biggest&#xA;  //cam.setImageSize(VC0706_320x240);        // medium&#xA;  //cam.setImageSize(VC0706_160x120);          // small&#xA;&#xA;  // You can read the size back from the camera (optional, but maybe useful?)&#xA;  uint8_t imgsize = cam.getImageSize();&#xA;  Serial.print(&quot;Image size: &quot;);&#xA;  if (imgsize == VC0706_640x480) Serial.println(&quot;640x480&quot;);&#xA;  if (imgsize == VC0706_320x240) Serial.println(&quot;320x240&quot;);&#xA;  if (imgsize == VC0706_160x120) Serial.println(&quot;160x120&quot;);&#xA;&#xA;  Serial.println(&quot;Snap in 3 secs...&quot;);&#xA;  delay(3000);&#xA;&#xA;  if (! cam.takePicture()) &#xA;    Serial.println(&quot;Failed to snap!&quot;);&#xA;  else &#xA;    Serial.println(&quot;Picture taken!&quot;);&#xA;&#xA;  // Create an image with the name IMAGExx.JPG&#xA;  char filename[13];&#xA;  strcpy(filename, &quot;IMAGE00.JPG&quot;);&#xA;  for (int i = 0; i &amp;lt; 100; i++) {&#xA;    filename[5] = '0' + i/10;&#xA;    filename[6] = '0' + i%10;&#xA;    // create if does not exist, do not open existing, write, sync after write&#xA;    if (! SD.exists(filename)) {&#xA;      break;&#xA;    }&#xA;  }&#xA;&#xA;  // Open the file for writing&#xA;  File imgFile = SD.open(filename, FILE_WRITE);&#xA;&#xA;  // Get the size of the image (frame) taken  &#xA;  uint16_t jpglen = cam.frameLength();&#xA;  Serial.print(&quot;Storing &quot;);&#xA;  Serial.print(jpglen, DEC);&#xA;  Serial.print(&quot; byte image.&quot;);&#xA;&#xA;  int32_t time = millis();&#xA;  pinMode(8, OUTPUT);&#xA;  // Read all the data up to # bytes!&#xA;  byte wCount = 0; // For counting # of writes&#xA;  while (jpglen &amp;gt; 0) {&#xA;    // read 32 bytes at a time;&#xA;    uint8_t *buffer;&#xA;    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!&#xA;    buffer = cam.readPicture(bytesToRead);&#xA;    imgFile.write(buffer, bytesToRead);&#xA;    if(++wCount &amp;gt;= 64) { // Every 2K, give a little feedback so it doesn't appear locked up&#xA;      Serial.print('.');&#xA;      wCount = 0;&#xA;    }&#xA;    //Serial.print(&quot;Read &quot;);  Serial.print(bytesToRead, DEC); Serial.println(&quot; bytes&quot;);&#xA;    jpglen -= bytesToRead;&#xA;  }&#xA;  imgFile.close();&#xA;&#xA;  time = millis() - time;&#xA;  Serial.println(&quot;done!&quot;);&#xA;  Serial.print(time); Serial.println(&quot; ms elapsed&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But when I open my Serial Monitor, it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;No camera found?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Where did I go wrong ?&lt;/p&gt;&#xA;" OwnerUserId="18412" LastActivityDate="2016-08-27T14:06:07.820" Title="Camera VC0706 not found" Tags="|arduino-uno|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28783" PostTypeId="2" ParentId="28764" CreationDate="2016-08-27T15:07:57.523" Score="1" Body="&lt;p&gt;I think you want to know how many sensors 1 Arduino can support.  But just in case, I am answering both interpretations of the title of your question:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;How many different types of sensors can an Arduino support?:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;With the correct software and hardware, the Aruidno can interface with almost any kind of sensor.  The exceptions include but are not limited to sensors which produce more data than an Arduino can process (such as a video camera) or sensors that require fast responses (such a time of flight laser distance sensors (LIDAR)).&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;2&quot;&gt;&#xA;&lt;li&gt;How many sensors can an Arduino support at the same time?:&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;This depends on what processor resources are needed.  If the sensor needs the ADC there 6 channels on most Arduinos.  If you need more, there are hardware solutions.  But many here have suggested to simply add a 2nd Arduino.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To specifically address your laundry list:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;room temperature&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thermistor connected to ADC.  But most are not linear, so you will have to create a look up table.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;humidity&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I think there is a SPI module on the market to do this.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;carbon monoxide&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;These sensors usually require an amplifier.  And change with age &amp;amp; temperature.  So a lot of software here as well as hardware. &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;carbon dioxin&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Not sure about this one.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;buzzer&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Self osculating? Then you only need a logic output.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;1 LCD display&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Alpha &amp;amp; numeric? Most have 4 or 8 pin Hitachi interfaces.  But you can look for a SPI or serial port LCD so as to conserve on Arduino pins.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;ESP8266&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;This is just a serial device.  You will need the Ardino's serial port.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'll leave it up to you to make a detailed assessment of the necessary processor resources.  Because you need to first pick out the specific hardware you will be using.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's half the battle.  The other half is verifying the libraries for all these sensors and communication devices will not interfere with one another.  That I will leave up to you as it is not an easy task to wade through all the code for all the different libraries you will be using.  And, again, until you pick out exactly what sensors and devices you will be using it is impossible to even start analyzing as we wouldn't know which libraries to look at.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastEditorUserId="20245" LastEditDate="2016-08-27T23:22:04.487" LastActivityDate="2016-08-27T23:22:04.487" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28784" PostTypeId="2" ParentId="28780" CreationDate="2016-08-27T15:19:50.637" Score="0" Body="&lt;p&gt;No, you cannot. A DAC cannot provide enough current to either directly drive a motor or to power a motor driver (which is basically driving the motor directly through a switch anyway).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A motor driver requires a PWM signal to rapidly switch a high current source on and off to set the motor speed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You &lt;em&gt;could&lt;/em&gt; feed the DAC output into the input of a voltage-to-PWM converter chip which would then feed the motor driver's EN pin, but that is pretty pointless when you could just use a small microcontroller to receive the digital speed value and directly generate a PWM signal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After all, that is the kind of job that small microcontrollers are designed for...&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-27T15:19:50.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28785" PostTypeId="1" AcceptedAnswerId="28814" CreationDate="2016-08-27T11:08:46.763" Score="2" ViewCount="392" Body="&lt;p&gt;Folks,&#xA;I want to use my arduino with ethernet shield to access the following webpage &quot;&lt;a href=&quot;http://www.met.ie/forecasts/sea-area.asp&quot; rel=&quot;nofollow&quot;&gt;http://www.met.ie/forecasts/sea-area.asp&lt;/a&gt;&quot; and take some information. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the website it has a line &quot;Small Craft Warning&quot;- This is always either &quot;In Operation&quot; or &quot;Nil&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically i want to hook up a RGB LED to the duino and if &quot;Small Craft Warning&quot; is &quot;in Operation&quot; i want LED to be Red, and if &quot;Nil&quot; LED can be green.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My issue is i cant figure out hot to go about getting the information from the webpage.- Can the arduino read this directly?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am confident with arduino but this is my first web based project!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any Tips or advice would be savage helpful&#xA;Thanks&lt;/p&gt;&#xA;" OwnerUserId="26141" OwnerDisplayName="Omasín" LastActivityDate="2016-08-28T20:47:55.140" Title="Arduino Accessing a web page" Tags="|ethernet|" AnswerCount="4" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28786" PostTypeId="2" ParentId="28785" CreationDate="2016-08-27T11:30:47.387" Score="0" Body="&lt;p&gt;Unfortunately that text is delivered as part of the complete web page and not, for example, an AJAX request.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Do you supply an RSS feed of your forecasts?&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;This is not something we provide at present, although we hope to do so in the future.&lt;/em&gt; &lt;a href=&quot;http://www.met.ie/faqs/#rss&quot; rel=&quot;nofollow noreferrer&quot;&gt;Source&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Your only option is to scan through the whole page looking for the text strings.&lt;/p&gt;&#xA;&lt;p&gt;This is a little dangerous as the page could, for example, contain the phrase as part of a help file and give you an incorrect status reading. I wouldn't set to sea on the basis of your LED.&lt;/p&gt;&#xA;&lt;p&gt;Bí cúramach!&lt;/p&gt;&#xA;" OwnerUserId="13749" OwnerDisplayName="Transistor" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-27T11:30:47.387" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28788" PostTypeId="1" CreationDate="2016-08-27T17:26:25.030" Score="3" ViewCount="157" Body="&lt;p&gt;I have tried several different ways to do this, but in the line: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;code&gt;myTFT.println(&quot;DS32(32,g,'Hello!',4);&quot;);&lt;/code&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;where &lt;code&gt;g&lt;/code&gt; is an int, it simply doesn't print. If I just replace the &lt;code&gt;g&lt;/code&gt; with a value of any kind, all is well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using an Uno (well, an Orion board from Makeblock) and the Makeblock TFT. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;All my other print lines work fine but of course, none contain variables.&lt;/p&gt;&#xA;" OwnerUserId="26122" LastEditorDisplayName="user24204" LastEditDate="2016-08-30T00:43:33.400" LastActivityDate="2017-09-24T18:44:57.140" Title="Using softwareserial with a TFT, how can I use a variable to position cursor?" Tags="|arduino-uno|softwareserial|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28789" PostTypeId="2" ParentId="28788" CreationDate="2016-08-27T18:31:46.203" Score="1" Body="&lt;p&gt;Just split the print into three parts:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;myTFT.print(&quot;DS32(32,&quot;);&#xA;myTFT.print(g);&#xA;myTFT.println(&quot;,'Hello!',4);&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-27T18:31:46.203" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28792" PostTypeId="1" AcceptedAnswerId="28821" CreationDate="2016-08-28T02:57:55.533" Score="0" ViewCount="3183" Body="&lt;p&gt;I am trying to read an MCP23S17 I/O expander port B with the Arduino SPI library.&#xA;The following example is simple as possible, and I still can not get it to work.&#xA;&lt;a href=&quot;https://i.stack.imgur.com/BipC4.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/BipC4.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&#xA;The setup is an MCP23S17 I/O expander on a Teensy LC controller.&#xA;MCP23S17 port B pins are alternately grounded and energized.&#xA;I confirmed the pin voltages with a multi-meter.&#xA;Variable portBState is a bitwise reading of port B, and printed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Expected output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;10101010&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Actual output is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;11111111&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Sketch:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;&#xA;const uint8_t ADDR = 0x20;      //MCP23S17 address, all 3 ADDR pins are grounded&#xA;const uint8_t OPCODE_READ  = (ADDR &amp;lt;&amp;lt; 1 | 0x01); //MCP23S17 read command&#xA;&#xA;const uint8_t IODIRB = 0x01;&#xA;const uint8_t GPIOB  = 0x13;&#xA;&#xA;uint8_t portBState = 0;                 //bit wise&#xA;&#xA;void setup()&#xA;{&#xA;    Serial.begin(9600);&#xA;    delay(1000);&#xA;&#xA;    pinMode(SS, OUTPUT);                //configure controller's Slave Select pin to output&#xA;    digitalWrite(SS, HIGH);             //disable Slave Select&#xA;    SPI.begin();&#xA;&#xA;    //IODIRB register is already configured to input by default&#xA;&#xA;    SPI.beginTransaction(SPISettings (SPI_CLOCK_DIV8, MSBFIRST, SPI_MODE0));&#xA;    digitalWrite(SS, LOW);              //enable Slave Select&#xA;      SPI.transfer(OPCODE_READ);        //read command&#xA;      SPI.transfer(GPIOB);              //register address to read data from&#xA;      portBState = SPI.transfer(0);     //save the data (0 is dummy data to send)&#xA;    digitalWrite(SS, HIGH);             //disable Slave Select&#xA;    SPI.endTransaction();               //release the SPI bus&#xA;&#xA;    Serial.println(portBState, BIN);    //should print 10101010&#xA;}&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Why is the output not &quot;10101010&quot;?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The controller is Teensy LC (3.3 volts) on Arduino 1.6.7.&lt;br&gt;&#xA;SPI library: &lt;a href=&quot;https://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.arduino.cc/en/Reference/SPI&lt;/a&gt;&lt;br&gt;&#xA;More links in the comments below (I don't have enough reputation points to post more links in the question).&lt;/p&gt;&#xA;" OwnerUserId="26127" LastEditorUserId="26127" LastEditDate="2016-08-28T03:28:12.183" LastActivityDate="2018-05-10T18:20:28.150" Title="Reading an MCP23S17 I/O expander port with the Arduino SPI library" Tags="|sketch|spi|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28794" PostTypeId="1" AcceptedAnswerId="28795" CreationDate="2016-08-28T05:00:46.010" Score="10" ViewCount="72419" Body="&lt;p&gt;Sometimes I run out of space of the program size for the embedded C program that I want to put on an arduino. So what chip do I need to expand the program memory of the arduino so that I can use bigger C programs with my arduino?&lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorUserId="25660" LastEditDate="2016-08-28T07:02:02.033" LastActivityDate="2021-08-18T02:11:04.073" Title="How to expand program memory on an arduino?" Tags="|arduino-uno|" AnswerCount="5" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28795" PostTypeId="2" ParentId="28794" CreationDate="2016-08-28T05:13:29.660" Score="12" Body="&lt;p&gt;An ATmega2560 is the chip to add for more memory when you run out of program memory on an Uno.  Referring to the &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Memory&quot; rel=&quot;noreferrer&quot;&gt;Memory&lt;/a&gt; webpage at arduino.cc, you'll see that it has Flash=256KB, SRAM=8KB, EEPROM=4KB, where the ATmega328 chip on the Uno has Flash=32KB, SRAM=2KB, EEPROM=1KB.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you run out of program memory on an Uno, you have about three choices that are practical:  make the program smaller; remove the bootloader (to free up one or two KB); use a different board with a more-capable processor.  The CPU on an Uno board doesn't have a way to access program bytes from places other than the on-chip 32KB flash.  The CPU on a Mega2560 board starts out with 8 times as much flash, so it can hold bigger programs than an Uno can.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you remove the bootloader, you could instead program using a USBASP board, as described in a &#xA;&lt;a href=&quot;http://www.learningaboutelectronics.com/Articles/Program-AVR-chip-using-a-USBASP-with-10-pin-cable.php&quot; rel=&quot;noreferrer&quot;&gt;“Program AVR chip using a USBASP with 10 pin cable”&lt;/a&gt; article at learningaboutelectronics.com.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastEditorUserId="3917" LastEditDate="2016-08-28T05:18:03.367" LastActivityDate="2016-08-28T05:18:03.367" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="28796" PostTypeId="2" ParentId="28794" CreationDate="2016-08-28T07:53:29.543" Score="7" Body="&lt;p&gt;Another way (other than MCU with more memory) is not using Arduino framework and its libraries. Such level of abstraction is expensive in both ways - memory usage and speed. But that's much harder way. If you need some library, you have to port it (if you haven't found native one) or at least provide required functions from Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example in Arduino IDE 1.6.11 empty sketch is using up 444 Bytes of flash. Using one &lt;code&gt;pinMode&lt;/code&gt; and &lt;code&gt;digitalWrite(13, ! digitalRead(13));&lt;/code&gt; + &lt;code&gt;delay(500);&lt;/code&gt; means 964 Bytes. Of course, these are most likely one-timers. If you use six more pins and toggle it, it uses much less program memory than using first one (1192B). But it still grows really fast.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In pure C empty program is about 134 Bytes long. Same functionality (toggling one pin every 500ms) takes 158 Bytes (and it's way faster).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But for hobby project i would go for ATMega2560 or ATMega644/1284 instead. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;And you can use direct access to hardware too. Toggle pin sketch with using registers directly and _delay_ms from avr libraries uses 468 Bytes instead of 964B. With delay from Arduino core libraries it's 602B.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-28T09:14:59.817" LastActivityDate="2016-08-28T09:14:59.817" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28798" PostTypeId="1" AcceptedAnswerId="31888" CreationDate="2016-08-28T10:39:54.233" Score="1" ViewCount="2140" Body="&lt;p&gt;I am doing some experiments with nodemcu 12 (which has built in esp8266). There most of the tutorials I found by internet describe how to connect to home wifi connection using it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;But when I power on nodemcu, I can see wifi network called &quot;ESPXXX&quot; in my laptop's wifi connection list. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So is there a way to directly connect to the wifi nw of esp8266 by my laptop or via another esp8266 (so I don't have to switch on my home wifi router)? &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If it is possible, is there is way to change ssid of esp8266's wifi connection and add password (again this is not about connecting to home wifi and this is about the wifi connection on esp8266 it self)? &#xA;So we can make one esp8266 as a wifi host and connect other esp8266s as slave to it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am using arduino IDE to upload program into esp8266 and not Lua.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks.&lt;/p&gt;&#xA;" OwnerUserId="26135" LastEditorUserId="26135" LastEditDate="2016-08-29T06:00:10.137" LastActivityDate="2016-12-04T18:04:51.057" Title="Wifi networking with ESP8266 (NODEMCU version)" Tags="|arduino-ide|esp8266|nodemcu|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28799" PostTypeId="2" ParentId="28574" CreationDate="2016-08-28T12:08:36.273" Score="0" Body="&lt;p&gt;I don't see +5v -&gt; Aref (and Aref -&gt; bypass capacitor -&gt; Gnd). Necessary, if you are using the power supply voltage as a reference, as you appear to be.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-28T12:08:36.273" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28801" PostTypeId="2" ParentId="28794" CreationDate="2016-08-28T12:30:56.177" Score="2" Body="&lt;p&gt;What about a &lt;a href=&quot;https://www.raspberrypi.org/blog/zero-grows-camera-connector/&quot; rel=&quot;nofollow&quot;&gt;raspberry pi zero&lt;/a&gt;?  I have a couple and use them quite often as arduinos.  &lt;/p&gt;&#xA;" OwnerUserId="26137" LastActivityDate="2016-08-28T12:30:56.177" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28802" PostTypeId="2" ParentId="28794" CreationDate="2016-08-28T12:37:26.537" Score="2" Body="&lt;p&gt;You could also look into other platforms. For instance, a Teensy 3.2 is Arduino compatible and has a 2KB eeprom and 64KB of RAM.&lt;/p&gt;&#xA;" OwnerUserId="2830" LastActivityDate="2016-08-28T12:37:26.537" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28803" PostTypeId="2" ParentId="28785" CreationDate="2016-08-28T12:39:06.723" Score="0" Body="&lt;p&gt;To add to Transitor's answer, while not guaranteed to work perfectly, you can always try to narrow down the page's source by only searching the component the text is in which should hopefully work. (unless they redo their website)&lt;/p&gt;&#xA;" OwnerUserId="26137" LastActivityDate="2016-08-28T12:39:06.723" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28807" PostTypeId="2" ParentId="28785" CreationDate="2016-08-28T15:11:33.947" Score="0" Body="&lt;p&gt;I think this can be accomplished with the use of a few libraries.  Also, I'd recommend the use of a third color to let you know when your program has encountered an unexpected condition, such as couldn't retrieve the webpage or couldn't find &quot;Small Craft Warning&quot; in the page or if the value for that attribute is something unexpected.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So first you'd want to use the Ethernet library that comes with the Arduino IDE. There is even an example sketch that shows you how to use it to download a webpage. Make sure you parse the status returned from the webserver to ensure its giving you a 200 HTTP status code and produce an error if it does not or if the connection fails.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As for parsing the webpage itself, you might try &lt;a href=&quot;https://github.com/nickgammon/Regexp&quot; rel=&quot;nofollow&quot;&gt;this regular expression library&lt;/a&gt; that Nick Gammon wrote.&#xA;Just have it search for the line with Small Craft Warning and then parse that line as a string as test for matches against the strings you are expecting to find or erroring out. Or you can use additional regular expressions to match your expected values once you find the right line. Remember to make the LED show an error color if it doesn't find the line or an expected value.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just talking about this makes me want to try it. ;-)&lt;/p&gt;&#xA;" OwnerUserId="2830" LastActivityDate="2016-08-28T15:11:33.947" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28809" PostTypeId="1" AcceptedAnswerId="28810" CreationDate="2016-08-28T16:07:23.337" Score="2" ViewCount="349" Body="&lt;p&gt;This is my first program on Arduino Uno (the starter kit), although I do have prior experience with programming (JavaScript, coding class last year 7th grade). It blinks the internal led (pin 13) in a Morse Code message:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;.... . .-.. .-.. ---   .-- --- .-. .-.. -..&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;. = dit(); &#xA;&#xA;- = dah(); &#xA;&#xA;(interval between parts of letter) = wip(); &#xA;&#xA;(interval between letters/words) = wah();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Here's my code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/*&#xA; * Roman's first program&#xA; * Decipher the message!&#xA;*/&#xA;&#xA;int ledPin = 13;&#xA;int index = 0;&#xA;&#xA;void setup() {&#xA;  //initialize pins as outputs&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop() {&#xA;  int sequence[] = {1,0,1,0,1,0,1,3,1,3,1,0,2,0,1,0,1,3,1,0,2,0,1,0,1,3,2,0,2,0,2,3,3,3,1,0,2,0,2,3,2,0,2,0,2,3,1,0,2,0,1,3,1,0,2,0,1,0,1,3,2,0,1,0,1};&#xA;  int arrLength = sizeof(sequence)/sizeof(int); //however THIS works?!&#xA;  if (index &amp;lt; arrLength-1) { //0-based array&#xA;    index++;&#xA;  } else {&#xA;     index = 0; //restart the sequence once finished&#xA;  }&#xA;  if (sequence[index] == 0) {&#xA;    wip();&#xA;  } else if (sequence[index] == 1) {&#xA;    dit();&#xA;  } else if (sequence[index] == 2) { &#xA;    dah();&#xA;  } else if (sequence[index] == 3) { //because sometimes I the values are screwed past arrLength...&#xA;    wah();&#xA;  }&#xA;  //Serial.println(String(sequence[index])+&amp;quot; , &amp;quot;+String(index));&#xA;}&#xA;&#xA;void dit () {&#xA;  digitalWrite(pinMode, HIGH); &#xA;  delay(300); &#xA;  digitalWrite(pinMode, LOW);&#xA;}&#xA;&#xA;void dah () {&#xA;  digitalWrite(pinMode, HIGH); &#xA;  delay(900); &#xA;  digitalWrite(pinMode, LOW);&#xA;}&#xA;&#xA;void wip () {&#xA;  delay(900);&#xA;}&#xA;&#xA;void wah () {&#xA;  delay(2100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Yet nothing is happening, except for the four/five startup flashes on the led when I restart it (red button). And yes, I saved and compiled.&lt;/p&gt;&#xA;" OwnerUserId="26130" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-28T16:26:17.813" Title="LED pin 13 not flashing properly" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28810" PostTypeId="2" ParentId="28809" CreationDate="2016-08-28T16:18:34.570" Score="6" Body="&lt;p&gt;Well, mainly &lt;code&gt;digitalWrite(pinMode, HIGH);&lt;/code&gt; looks suspicious. I though you called LED pin as &lt;code&gt;ledPin&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you fix this, it should be working. As this one is working too, it's just simplified a little:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int ledPin = 13;&#xA;int index = 0;&#xA;const int8_t sequence[] = {1,0,1,0,1,0,1,3,1,3,1,0,2,0,1,0,1,3,1,0,2,0,1,0,1,3,2,0,2,0,2,3,3,3,1,0,2,0,2,3,2,0,2,0,2,3,1,0,2,0,1,3,1,0,2,0,1,0,1,3,2,0,1,0,1};&#xA;int arrLength     = sizeof(sequence);&#xA;&#xA;&#xA;void setup() {&#xA;  pinMode(ledPin, OUTPUT);&#xA;  Serial.begin(57600);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(String(sequence[index])+&quot; , &quot;+String(index));&#xA;  switch (sequence[index++]) {&#xA;    case 0: wip(); break;&#xA;    case 1: dit(); break;&#xA;    case 2: dah(); break;&#xA;    case 3: wah(); break;&#xA;  }&#xA;  if (index == arrLength) {&#xA;    index = 0;&#xA;  }&#xA;}&#xA;&#xA;void dit () {&#xA;  digitalWrite(ledPin, HIGH); &#xA;  delay(300); &#xA;  digitalWrite(ledPin, LOW);&#xA;}&#xA;&#xA;void dah () {&#xA;  digitalWrite(ledPin, HIGH); &#xA;  delay(900); &#xA;  digitalWrite(ledPin, LOW);&#xA;}&#xA;&#xA;void wip () {&#xA;  delay(900);&#xA;}&#xA;&#xA;void wah () {&#xA;  delay(2100);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-28T16:26:17.813" LastActivityDate="2016-08-28T16:26:17.813" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28811" PostTypeId="1" CreationDate="2016-08-28T19:27:43.573" Score="-2" ViewCount="47" Body="&lt;p&gt;motor driver is for current amplification.for that we could connect more batteries to servos to get more current.but why are we using motor shields?&lt;/p&gt;&#xA;" OwnerUserId="26126" LastActivityDate="2016-08-28T22:54:58.867" Title="use more no of batteries for more current for servos,why using motor shield?" Tags="|arduino-uno|arduino-motor-shield|" AnswerCount="1" CommentCount="3" ClosedDate="2016-10-26T05:45:57.367" ContentLicense="CC BY-SA 3.0" />
  <row Id="28814" PostTypeId="2" ParentId="28785" CreationDate="2016-08-28T20:47:55.140" Score="1" Body="&lt;p&gt;As I commented on deltaray's answer, a regular expression library is&#xA;overkill for finding a fixed string. There is a standard avr-libc&#xA;function for that called &lt;a href=&quot;http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html#ga6a441da9211eb85881d99c60b1003552&quot; rel=&quot;nofollow noreferrer&quot;&gt;strstr()&lt;/a&gt;:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;char * strstr(const char *haystack, const char *needle);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;haystack&lt;/code&gt; is the Web page and &lt;code&gt;needle&lt;/code&gt; is the fixed string you&#xA;are searching for.&lt;/p&gt;&#xA;&lt;p&gt;There is an issue with this function though: in order to use it, you&#xA;need to have the whole haystack in RAM. For a non-trivial Web page, this&#xA;may not be doable on a small Arduino.&lt;/p&gt;&#xA;&lt;p&gt;Below is a custom solution based on a &lt;a href=&quot;https://en.wikipedia.org/wiki/Finite-state_machine&quot; rel=&quot;nofollow noreferrer&quot;&gt;finite state machine&lt;/a&gt;: the&#xA;parser can be in a number of different states:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;state 0 = waiting for the 'S' of &amp;quot;Small Craft&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;state 1 = waiting for the 'm' of &amp;quot;Small Craft&amp;quot;&lt;/li&gt;&#xA;&lt;li&gt;etc...&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The state is actually an index in a character array representing the&#xA;string we are looking for. Each time the parser finds the expected&#xA;character, it moves to the next state. Otherwise it moves back to state&#xA;0. There is a small kludge though: when in the state &lt;em&gt;waiting for the&#xA;'N' of &amp;quot;Nil&amp;quot;&lt;/em&gt;, if it doesn't get an 'N', it moves to the state &lt;em&gt;waiting&#xA;for the 'I' of &amp;quot;In Operation&amp;quot;&lt;/em&gt; and tries the match again. This way it&#xA;can look for both the possible strings at once. Also, once it got the&#xA;full preamble &amp;quot;Small Craft Warning: &amp;lt;/b&amp;gt;&amp;quot;, if it gets something&#xA;invalid, it moves to an extra state called &lt;em&gt;INVALID&lt;/em&gt; instead of state 0.&lt;/p&gt;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;// Possible return values of parse_forecast().&#xA;// The last three are sticky.&#xA;enum parse_state {&#xA;    NO_PREAMBLE,        // no complete preamble seen yet&#xA;    PREAMBLE_COMPLETE,  // preamble just completed&#xA;    PARTIAL_NIL,        // received preamble and start of &amp;quot;Nil&amp;quot;&#xA;    PARTIAL_IN_OP,      // received preamble and start of &amp;quot;In Operation&amp;quot;&#xA;    COMPLETE_NIL,       // result = Nil&#xA;    COMPLETE_IN_OP,     // result = In Operation&#xA;    INVALID             // valid preamble followed by invalid data&#xA;};&#xA;&#xA;parse_state parse_forecast(char c)&#xA;{&#xA;    // position:      0                        25   29            42&#xA;    const char T[] = &amp;quot;Small Craft Warning: &amp;lt;/b&amp;gt;Nil\0In Operation\0&amp;quot;;&#xA;    static size_t i;  // T[i] is the character we expect next&#xA;&#xA;    if (T[i]) {  // non-sticky state&#xA;        if (i == 25 &amp;amp;&amp;amp; c != T[i])&#xA;            i = 29;      // switch to &amp;quot;In Op&amp;quot; branch&#xA;        if (c == T[i])   // found expected char&#xA;            i++;         // wait for the next one&#xA;        else {&#xA;            if (i &amp;lt; 25)&#xA;                i = 0;   // reset to start of the string&#xA;            else&#xA;                i = 42;  // invalid state&#xA;        }&#xA;    }&#xA;    return i &amp;lt;  25 ? NO_PREAMBLE :&#xA;           i == 25 ? PREAMBLE_COMPLETE :&#xA;           i &amp;lt;  28 ? PARTIAL_NIL :&#xA;           i == 28 ? COMPLETE_NIL :&#xA;           i &amp;lt;  41 ? PARTIAL_IN_OP :&#xA;           i == 41 ? COMPLETE_IN_OP :&#xA;           INVALID;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With this you do not need to store the Web page in RAM. Instead, you&#xA;feed the parser one character at a time and, at the end, check the&#xA;return value. You expect it to be either &lt;code&gt;COMPLETE_NIL&lt;/code&gt; or&#xA;&lt;code&gt;COMPLETE_IN_OP&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Implementation detail: there are three NUL characters in the template&#xA;string, at positions 28, 41 and 42 (the last one is implicit). They&#xA;correspond to the three possible &amp;quot;sticky&amp;quot; states.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-28T20:47:55.140" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28815" PostTypeId="1" AcceptedAnswerId="28822" CreationDate="2016-08-28T21:46:55.067" Score="6" ViewCount="22239" Body="&lt;p&gt;I'm working on trying to control a hard drive with an Arduino Uno, but I'm having trouble with the power supply. From what I know, both the Molex Mate-n-Lok and the new SATA connectors both have 2 grounds, a 5V and a 12V power in. I'm wondering what the purpose of the 12V power supply is. I suspect it's used to drive the motor but I'm not sure.&lt;/p&gt;&#xA;" OwnerUserId="16100" LastEditorDisplayName="user24204" LastEditDate="2016-08-30T00:44:04.757" LastActivityDate="2018-06-13T08:38:27.307" Title="Do I need to supply the 12V connection to an HDD" Tags="|power|pins|hardware|" AnswerCount="2" CommentCount="13" ContentLicense="CC BY-SA 3.0" />
  <row Id="28816" PostTypeId="1" AcceptedAnswerId="28824" CreationDate="2016-08-28T22:49:22.713" Score="3" ViewCount="8817" Body="&lt;p&gt;I have an HC-SR04 sensor and I need to get the distance from it. I use this code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;digitalWrite(trig, LOW);&#xA;delayMicroseconds(2);&#xA;digitalWrite(trig, HIGH);&#xA;delayMicroseconds(10);&#xA;digitalWrite(trig, LOW);&#xA;duration=pulseIn(echo, HIGH, 24000L);&#xA;cm=duration/2/29.1;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Pulsein takes too much time and I would like to use interrupts to prevent code from being blocked. From the beginning, I had no idea how to do it. I did not want to ask this question without trying on my own so here is my miserable attempt: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; while(digitalRead(echo)==LOW){&#xA; }&#xA;if(digitalRead(echo)==HIGH){&#xA;      lowTimer=millis();&#xA;}&#xA;while(digitalRead(echo)==HIGH){&#xA;&#xA;}&#xA;&#xA;if(digitalRead(echo)==LOW){&#xA;   duration=millis()-lowTimer;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Obviously, this does not work. I don't know if I am on the right track, but I do know that even if this worked, it would still block my code for a long time. Can someone help me, point me in the right direction? Please don't just write it for me - I want to learn. I would like someone to point me to the right direction till I get it. Thank you!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried on of the suggestions:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;unsigned long duration;&#xA;int cm;&#xA;const int echo = 24;&#xA;const int trig = 22;&#xA;bool doPing=true;&#xA;&#xA;void setup()&#xA;{&#xA;  pinMode(echo, INPUT);&#xA;  pinMode(trig, OUTPUT);&#xA;  Serial.begin(9600);&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;    if(doPing){&#xA;        ping();&#xA;        doPing=false;&#xA;    }&#xA;    read_pulse();&#xA;    if(duration!=0){&#xA;        cm=duration/29.1/2;&#xA;        Serial.println(&quot;cm: &quot;+cm);&#xA;        doPing=true;&#xA;    }&#xA;    delay(2);&#xA;}&#xA;void ping(){&#xA;  digitalWrite(trig, LOW);&#xA;  delayMicroseconds(2);&#xA;  digitalWrite(trig, HIGH);&#xA;  delayMicroseconds(10);&#xA;  digitalWrite(trig, LOW);&#xA;}&#xA;&#xA;void read_pulse()&#xA;{&#xA;    static unsigned long rising_time;  // time of the rising edge&#xA;    static int last_state;             // previous pin state&#xA;    int state = digitalRead(echo);      // current pin state&#xA;    duration = 0; // default return value&#xA;&#xA;    // On rising edge: record current time.&#xA;    if (last_state == LOW &amp;amp;&amp;amp; state == HIGH) {&#xA;        rising_time = micros();&#xA;    }&#xA;&#xA;    // On falling edge: report pulse length.&#xA;    if (last_state == HIGH &amp;amp;&amp;amp; state == LOW) {&#xA;        unsigned long falling_time = micros();&#xA;        duration = falling_time - rising_time;&#xA;    }&#xA;&#xA;    last_state = state;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This does not print anything to my serial monitor. Is there something I am missing?&lt;/p&gt;&#xA;" OwnerUserId="19606" LastEditorUserId="19606" LastEditDate="2016-09-07T00:04:52.020" LastActivityDate="2016-09-07T00:04:52.020" Title="How can I replace pulseIn with interrupts?" Tags="|arduino-mega|interrupt|millis|pulsein|hc-sr04|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28817" PostTypeId="2" ParentId="28811" CreationDate="2016-08-28T22:54:58.867" Score="2" Body="&lt;p&gt;The motor shield is useful because you cannot pass the required amount of current through Arduino's microcontroller without blowing it up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course you don't need to use the motor shield if you create a similar circuit of your own that performs the same task.&lt;/p&gt;&#xA;" OwnerUserId="4007" LastActivityDate="2016-08-28T22:54:58.867" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28821" PostTypeId="2" ParentId="28792" CreationDate="2016-08-29T02:56:04.547" Score="0" Body="&lt;p&gt;It's working now.  Here is what was missing:&#xA;A yellow jumper from the micro-controller MOSI pin to the MCP23S17 SO pin.&#xA;So the read command can travel from micro-controller to MCP23S17.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WFkx5.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WFkx5.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26127" LastEditorUserId="26127" LastEditDate="2016-08-29T03:57:16.253" LastActivityDate="2016-08-29T03:57:16.253" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28822" PostTypeId="2" ParentId="28815" CreationDate="2016-08-29T04:50:43.703" Score="5" Body="&lt;p&gt;Judging by my old copy of &quot;Upgrading and repairing PCs&quot; - which I found a quote for on &lt;a href=&quot;https://books.google.com.au/books?id=jw7yCQAAQBAJ&amp;amp;pg=PT901&amp;amp;lpg=PT901&amp;amp;dq=ATA++HDD+spindle+motor&amp;amp;source=bl&amp;amp;ots=Jvb80oa6A1&amp;amp;sig=9H1agBSU7sXF_vYtrLlz1f16M14&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ved=0ahUKEwisv5aG6eXOAhVGoJQKHQU-CoEQ6AEIQDAI#v=onepage&amp;amp;q=ATA%20%20HDD%20spindle%20motor&amp;amp;f=false&quot; rel=&quot;noreferrer&quot;&gt;Google Books&lt;/a&gt; - the 12V supply is for the spindle motor, and it says:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Spindle motors, particularly on the larger form-factor drivers, can consume a great deal of 12V power.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-29T04:50:43.703" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28823" PostTypeId="2" ParentId="28768" CreationDate="2016-08-29T07:56:50.173" Score="3" Body="&lt;p&gt;It's perfectly doable. As Chris Stratton puts it, it's all about&#xA;implementing &lt;em&gt;non-blocking&lt;/em&gt; serial communication:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;whenever you receive a character, you store it in a buffer&lt;/li&gt;&#xA;&lt;li&gt;whenever you have a complete command in the buffer, you process it and&#xA;reset the buffer&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;For a line-oriented protocol, it may look something like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/* Process incoming characters if any. */&#xA;while (Serial.available()) {&#xA;    static char buffer[BUF_LENGTH];  // incoming command&#xA;    static int length = 0;           // command length&#xA;&#xA;    int data = Serial.read();&#xA;    if (data == '\r') {              // complete command&#xA;        buffer[length] = '\0';       // terminate the string&#xA;        if (length)&#xA;            exec_command(buffer);    // process&#xA;        length = 0;                  // reset buffer&#xA;    }&#xA;    else if (length &amp;lt; BUF_LENGTH - 1)&#xA;        buffer[length++] = data;     // buffer incoming character&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For a more complete example, you may want to take a look at this &lt;a href=&quot;https://gist.github.com/edgar-bonet/607b387260388be77e96&quot; rel=&quot;nofollow&quot;&gt;simple&#xA;Arduino command line interpreter&lt;/a&gt;. You connect a terminal&#xA;emulator to the Arduino at 9600/8N1, type the &quot;help&quot; command and it&#xA;displays:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;mode &amp;lt;pin&amp;gt; &amp;lt;mode&amp;gt;: pinMode()&#xA;read &amp;lt;pin&amp;gt;: digitalRead()&#xA;aread &amp;lt;pin&amp;gt;: analogRead()&#xA;write &amp;lt;pin&amp;gt; &amp;lt;value&amp;gt;: digitalWrite()&#xA;awrite &amp;lt;pin&amp;gt; &amp;lt;value&amp;gt;: analogWrite()&#xA;echo &amp;lt;value&amp;gt;: set echo off (0) or on (1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can use it as a template, replace existing commands or add new ones&#xA;(the interpreter is just a long &lt;code&gt;if ... else if ...&lt;/code&gt;) and –&amp;nbsp;since&#xA;it's all non-blocking&amp;nbsp;– add whatever you want to &lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-29T07:56:50.173" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28824" PostTypeId="2" ParentId="28816" CreationDate="2016-08-29T09:32:46.290" Score="3" Body="&lt;p&gt;You do not want the reading of the incoming pulse to &lt;strong&gt;block&lt;/strong&gt; your&#xA;program execution. This is the very key requirement: you want a&#xA;&lt;em&gt;non-blocking&lt;/em&gt; pulse reading. You can write a non-blocking replacement&#xA;for &lt;code&gt;pulseIn()&lt;/code&gt;, but you will have to use it differently. You cannot&#xA;expect a non-blocking &lt;code&gt;pulseIn()&lt;/code&gt; to return the pulse length whenever&#xA;you call it: instead, it would return that value &lt;em&gt;only&lt;/em&gt; when you call it&#xA;right after the pulse falling edge. On all other circumstances it will&#xA;return a dummy value meaning “the pulse is not finished yet, thus I&#xA;cannot give you its length right now, please call me later”.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below is an example of a function implementing this approach. You have&#xA;to call it on every loop iteration: the more often you call it, the&#xA;better resolution you will have. This function uses 0 as the dummy value&#xA;meaning “no answer available right now”:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;/*&#xA; * Non-blocking pulseIn(): returns the pulse length in microseconds&#xA; * when the falling edge is detected. Otherwise returns 0.&#xA; */&#xA;unsigned long read_pulse(int pin)&#xA;{&#xA;    static unsigned long rising_time;  // time of the rising edge&#xA;    static int last_state;             // previous pin state&#xA;    int state = digitalRead(pin);      // current pin state&#xA;    unsigned long pulse_length = 0;    // default return value&#xA;&#xA;    // On rising edge: record current time.&#xA;    if (last_state == LOW &amp;amp;&amp;amp; state == HIGH) {&#xA;        rising_time = micros();&#xA;    }&#xA;&#xA;    // On falling edge: report pulse length.&#xA;    if (last_state == HIGH &amp;amp;&amp;amp; state == LOW) {&#xA;        unsigned long falling_time = micros();&#xA;        pulse_length = falling_time - rising_time;&#xA;    }&#xA;&#xA;    last_state = state;&#xA;    return pulse_length;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;A better approach, but harder to implement for a novice, is to use&#xA;interrupts. Chris gave you a pointer to Nick Gammon’s tutorial on&#xA;interrupts. This is definitely a good reading. But you will also have to&#xA;dig into the &lt;a href=&quot;http://www.atmel.com/Images/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_datasheet.pdf&quot; rel=&quot;nofollow&quot;&gt;data sheet of the ATmega328P microcontroller&lt;/a&gt;.&#xA;It's a little bit daunting, but a must read if you go into low-level&#xA;programming. If you follow this path, I suggest you look at the “input&#xA;capture” capability of Timer 1 (chapter 20, section 20.9). This is a&#xA;feature of the timer that can have it automatically save a timestamp&#xA;whenever some external pin changes state. You then use the input capture&#xA;interrupt to alert the program when an edge has been detected, and your&#xA;interrupt service routine can read the automatically saved timestamp.&#xA;Using this approach, you can have extremely accurate pulse length&#xA;measurements, independent on how fast your program goes through its&#xA;&lt;code&gt;loop()&lt;/code&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastActivityDate="2016-08-29T09:32:46.290" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28825" PostTypeId="2" ParentId="28815" CreationDate="2016-08-29T11:27:23.727" Score="4" Body="&lt;p&gt;3.5&quot; hard drives require 12V and 5V for the motor and logic respectively. SATA ones may also require 3.3V for the logic.  Most smaller laptop drives (2.5&quot;) only require 5V and 3.3V.  &lt;a href=&quot;https://www.seagate.com/files/www-content/product-content/enterprise-hdd-fam/enterprise-capacity-2-5-hdd/en-us/docs/100827452b.pdf&quot; rel=&quot;nofollow noreferrer&quot;&gt;Some&lt;/a&gt; 2.5&quot; drives also require 12V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You will not be able to interface a SATA hard drive to an Arduino without some kind of SATA hard drive controller, which you could possibly build using a fast FPGA (in which case why would you bother with an Arduino?). For SATA-I (way out of date now) you need to generate a 1.5Gbps LVDS (Low-Voltage Differential Signal) data stream. For SATA-3.2 that is now 16Gbps. Impossible on an Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;PATA (Parallel ATA) is more realistic, although you need a lot of pins since it is a 16-bit parallel interface. Timing is less critical since it is synchronous with the read / write strobes. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="47322" LastEditDate="2018-06-13T08:38:27.307" LastActivityDate="2018-06-13T08:38:27.307" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="28828" PostTypeId="1" AcceptedAnswerId="28853" CreationDate="2016-08-29T11:48:01.433" Score="1" ViewCount="250" Body="&lt;p&gt;as a project I have to build a sensor hub based on Arduino. I need a couple of sensors like gyroscope, barometer, etc. This is no problem so far. The problem arises when it comes to power measurement. We have to measure the power consumption of the Arduino AND all the sensors. Sure, I could use a sensor like the &lt;a href=&quot;https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout&quot; rel=&quot;nofollow&quot;&gt;Adafruit INA219 sensor&lt;/a&gt;. But this only gives the total consumed power of the Arduino and the sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to measure the energy, say, for every pin on the Arduino?&lt;/p&gt;&#xA;" OwnerDisplayName="user19698" LastActivityDate="2016-08-30T01:34:29.197" Title="Power measurement on Pins" Tags="|arduino-uno|adafruit|" AnswerCount="1" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28830" PostTypeId="1" CreationDate="2016-08-29T14:27:05.757" Score="1" ViewCount="301" Body="&lt;p&gt;It looks like I cannot combine the Grove sunlight sensor and the Grove DHT22 temperature and humidity sensor. I can't figure out why.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have the following setup:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Seeeduino Cloud (Arduino Yún clone) &lt;/li&gt;&#xA;&lt;li&gt;Grove Shield Grove sunlight sensor connected to an I2C port&lt;/li&gt;&#xA;&lt;li&gt;Grove DHT22 temperature and humidity sensor connected to port A0&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I'm sending the data to Initialstate.com. This is my code:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;// Process.h gives us access to the Process class, which lets&#xA;// us communicate with the shell&#xA;#include &quot;DHT.h&quot; //Temp Hum sensor&#xA;#include &amp;lt;Bridge.h&amp;gt;&#xA;#include &amp;lt;Process.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;#include &quot;SI114X.h&quot; //Sunlight sensor&#xA;&#xA;SI114X SI1145 = SI114X();&#xA;&#xA;////////////////////////////////////////////&#xA;&#xA;//Temperature and Humidity sensor data start&#xA;#define DHTPIN A0&#xA;// what sensor is connected to, in this case A0    &#xA;#define DHTTYPE DHT22   // DHT 22  (AM2302)&#xA;&#xA;DHT dht(DHTPIN, DHTTYPE);&#xA;//Temperature and Humidity sensor data end&#xA;&#xA;////////////////////////////&#xA;// Initial State Streamer //&#xA;////////////////////////////&#xA;// URL to IS Bucket API&#xA;String ISBucketURL = &quot;https://groker.initialstate.com/api/buckets&quot;;&#xA;// URL to IS Event API&#xA;String ISEventURL = &quot;https://groker.initialstate.com/api/events&quot;;&#xA;// Access key (the one you find in your account settings):&#xA;String accessKey = &quot;KRYLC3tvJUiyTVqTJr5nRqgkKQI2FiDh&quot;;&#xA;String bucketKey = &quot;Test_Klimaat2&quot;;&#xA;// Bucket name (name your data will be associated with in Initial State):&#xA;String bucketName = &quot;Test klimaat 2&quot;;&#xA;// Bucket key (hidden reference to your bucket that allows appending):&#xA;//String bucketKey = &quot;arduino_stream&quot;;&#xA;// Bucket name (name your data will be associated with in Initial State):&#xA;//String bucketName = &quot;Arduino Stream&quot;;&#xA;// How many signals are in your stream? You can have as few or as many as you want&#xA;const int NUM_SIGNALS = 5;&#xA;// What are the names of your signals (i.e. &quot;Temperature&quot;, &quot;Humidity&quot;, etc.)&#xA;String signalName[NUM_SIGNALS] = {&quot;Humidity&quot;, &quot;Temperatur&quot;, &quot;Visable&quot;, &quot;Infrared&quot;, &quot;UV&quot;};&#xA;// This array is to store our signal data later&#xA;String signalData[NUM_SIGNALS];&#xA;&#xA;// This only runs once at the very beginning&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  Bridge.begin();&#xA;  Wire.begin(); &#xA;  SI1145.Begin();&#xA;  dht.begin(); //Initialize temparature and humidity sensor&#xA;&#xA;  while (!Serial);&#xA;    // Post Bucket&#xA;    Serial.println(&quot;Posting Bucket!&quot;);&#xA;    // The postBucket() function creates a bucket &#xA;    // (unnecessary if the bucket already exists)&#xA;    postBucket();&#xA;}&#xA;&#xA;// This repeats&#xA;void loop() {&#xA;  // Gather Data&#xA;  // Read from a port for input or output or generate your own values/messages&#xA;  // These signals are random numbers for the sake of example&#xA;&#xA;  String VIS;&#xA;  String IR;&#xA;  String UV;&#xA;  String TEMP;&#xA;  String HUM;&#xA;&#xA;  //Code reading DHT22&#xA;  HUM = String((float)dht.readHumidity());&#xA;  TEMP = String((float)dht.readTemperature());&#xA;&#xA;  //code reading Sunlight data&#xA;  VIS = String(SI1145.ReadVisible());&#xA;  IR = String(SI1145.ReadIR());&#xA;  UV = String((float)SI1145.ReadUV()/100);&#xA;&#xA;  signalData[0] = HUM;&#xA;  signalData[1] = TEMP;&#xA;  signalData[2] = VIS;&#xA;  signalData[3] = IR;&#xA;  signalData[4] = UV;&#xA;&#xA;  // Post Data&#xA;  Serial.println(&quot;Posting Data!&quot;);&#xA;  // The postData() function streams our events&#xA;  postData(); &#xA;  // Wait for 5 seconds before collecting and sending the next batch&#xA;  delay(5000);&#xA;}&#xA;&#xA;// Here are the data bucket creation and posting functions&#xA;// They do not need to be edited - everything you would need to change for &#xA;// your situation can be found above&#xA;&#xA;void postBucket() {&#xA;  // Initialize the process&#xA;  Process isbucket;&#xA;&#xA;  isbucket.begin(&quot;curl&quot;);&#xA;  isbucket.addParameter(&quot;-k&quot;);&#xA;  isbucket.addParameter(&quot;-v&quot;);&#xA;  isbucket.addParameter(&quot;-X&quot;);&#xA;  isbucket.addParameter(&quot;POST&quot;);&#xA;  isbucket.addParameter(&quot;-H&quot;);&#xA;  isbucket.addParameter(&quot;Content-Type:application/json&quot;);&#xA;  isbucket.addParameter(&quot;-H&quot;);&#xA;  isbucket.addParameter(&quot;Accept-Version:0.0.1&quot;);&#xA;&#xA;  // IS Access Key Header&#xA;  isbucket.addParameter(&quot;-H&quot;);&#xA;  isbucket.addParameter(&quot;X-IS-AccessKey:&quot; + accessKey);&#xA;&#xA;  // IS Bucket Key Header&#xA;  isbucket.addParameter(&quot;-d&quot;);&#xA;  isbucket.addParameter(&quot;{\&quot;bucketKey\&quot;: \&quot;&quot; + bucketKey + &quot;\&quot;, \&quot;bucketName\&quot;: \&quot;&quot; + bucketName + &quot;\&quot;}&quot;);&#xA;  isbucket.addParameter(&quot;https://groker.initialstate.com/api/buckets&quot;);&#xA;  // Run the process&#xA;  isbucket.run();&#xA;  Serial.flush();&#xA;}&#xA;&#xA;void postData() {&#xA;  // Initialize the process&#xA;  Process isstreamer;&#xA;  isstreamer.begin(&quot;curl&quot;);&#xA;  isstreamer.addParameter(&quot;-k&quot;);&#xA;  isstreamer.addParameter(&quot;-v&quot;);&#xA;  isstreamer.addParameter(&quot;-X&quot;);&#xA;  isstreamer.addParameter(&quot;POST&quot;);&#xA;  isstreamer.addParameter(&quot;-H&quot;);&#xA;  isstreamer.addParameter(&quot;Content-Type:application/json&quot;);&#xA;  isstreamer.addParameter(&quot;-H&quot;);&#xA;  isstreamer.addParameter(&quot;Accept-Version:0.0.1&quot;);&#xA;&#xA;  // IS Access Key Header&#xA;  isstreamer.addParameter(&quot;-H&quot;);&#xA;  isstreamer.addParameter(&quot;X-IS-AccessKey:&quot; + accessKey);&#xA;&#xA;  // IS Bucket Key Header&#xA;  // Note that bucketName is not needed here&#xA;  isstreamer.addParameter(&quot;-H&quot;);&#xA;  isstreamer.addParameter(&quot;X-IS-BucketKey:&quot; + bucketKey);&#xA;&#xA;  isstreamer.addParameter(&quot;-d&quot;);&#xA;&#xA;  // Initialize a string to hold our signal data&#xA;  String jsonData;&#xA;  jsonData = &quot;[&quot;;&#xA;  for (int i=0; i&amp;lt;NUM_SIGNALS; i++) {&#xA;    jsonData += &quot;{\&quot;key\&quot;: \&quot;&quot; + signalName[i] + &quot;\&quot;, \&quot;value\&quot;: \&quot;&quot; + signalData[i] + &quot;\&quot;}&quot;;&#xA;    if (i != NUM_SIGNALS - 1) {&#xA;      jsonData += &quot;,&quot;;&#xA;    }&#xA;  }&#xA;  jsonData += &quot;]&quot;;&#xA;  isstreamer.addParameter(jsonData);&#xA;  isstreamer.addParameter(&quot;https://groker.initialstate.com/api/events&quot;);&#xA;  // Print posted data for debug&#xA;  Serial.print(&quot;Sending data: &quot;);&#xA;  Serial.println(jsonData);&#xA;  // Run the process&#xA;  isstreamer.run();&#xA;  Serial.flush();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I run this code, the Serial monitor will correctly display the data string I want to send with all values. However the data is NOT sent. Only when I comment out one of these lines in the &lt;code&gt;loop()&lt;/code&gt; declaration the data is sent to Initialstate successfully. Obviously without the data commented out:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;  //Code reading DHT22&#xA;  HUM = String((float)dht.readHumidity());&#xA;  TEMP = String((float)dht.readTemperature());&#xA;&#xA;  //code reading Sunlight data&#xA;  VIS = String(SI1145.ReadVisible());&#xA;  IR = String(SI1145.ReadIR());&#xA;  UV = String((float)SI1145.ReadUV()/100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Any ideas are appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26165" LastEditorUserId="37523" LastEditDate="2019-08-17T14:07:46.853" LastActivityDate="2021-09-05T18:01:35.200" Title="Combine DHT22 and SI114X.h" Tags="|arduino-yun|temperature-sensor|" AnswerCount="1" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="28831" PostTypeId="2" ParentId="25866" CreationDate="2016-08-29T15:03:19.427" Score="1" Body="&lt;p&gt;The speed of the stepper motor (assuming you measure it in RPM) will depend on many factors. I am not sure how the &quot;30 step size at 7V&quot; you mention is relevant.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;IMHO, the most important parameters are&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) physical parameters of motor (steps per revolution, rated voltage, motor intetia)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Load on the motor&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) software implementation&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Normally you shouldn't be able to affect 1( if you are looking like most arduino's developers you should be looking at things like &lt;a href=&quot;http://www.oddwires.com/nema17-stepper-motor-for-arduino/&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt;. i.e. 200 steps per revolution, 5-12VDC and a few tens to hundreds of g*cm^2 or motor inertia.) or 2 (although with higher loads lower velocities can be achieved, normally you select the motor based on the load and not vice versa).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Therefore you are left with Software implementation. Things here can get messy very quickly depending on how experienced you are and what you want to do. &#xA;e.g. The arduino Stepper library is simple and you can set parameters but it is blocking (i.e. you can't do anything else until movement is completed, or interrupts are used). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to get your hands dirty (and your head messed up ;-/ ) you can looks at &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Arduino timers&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;micros(), and millis() for updating the steps yourself. (Have a look at &lt;a href=&quot;http://www.mauroalfieri.it/elettronica/motor-shield-r3-arduino.html&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://bitbucket.org/npapnet/ard.lib.bipolarsteppermotorasync&quot; rel=&quot;nofollow&quot;&gt;here - shameless plug&lt;/a&gt;) &lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;pin registers (for increasing speed) &lt;a href=&quot;http://tronixstuff.com/2011/10/22/tutorial-arduino-port-manipulation/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;My experience is that normally you can get up to 150 [rpm] easily. Theoretically you should be able to go higher but the uC should be doing pretty much nothing else.&lt;/p&gt;&#xA;" OwnerUserId="26093" LastActivityDate="2016-08-29T15:03:19.427" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28832" PostTypeId="1" CreationDate="2016-08-29T15:11:59.193" Score="2" ViewCount="350" Body="&lt;p&gt;I am using DHT22 temperature/humidity sensor and I noticed that there exist so many libraries. I wonder which one is the most accurate?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is giving me readings that does not seem to be logic. High temperature and very low RH%. Is it because of the library or because I am not connecting 10k or 4.7k resistor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thank you so much in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;Badr Eddine&lt;/p&gt;&#xA;" OwnerUserId="22780" LastActivityDate="2016-09-19T16:13:04.700" Title="DHT22: Library and Data accuracy" Tags="|arduino-uno|arduino-mega|sensors|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28834" PostTypeId="1" CreationDate="2016-08-29T16:18:33.043" Score="4" ViewCount="1078" Body="&lt;p&gt;I've got an Adafruit Trinket microcontroller set up using &lt;a href=&quot;https://learn.adafruit.com/trinket-usb-keyboard/code&quot; rel=&quot;nofollow&quot;&gt;this USB keyboard tutorial&lt;/a&gt;, and it works great.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'd like to set up my project to type a shruggie ( &lt;code&gt;¯\_(ツ)_/¯&lt;/code&gt; ) when I press a hardware button. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;My naive solution was:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;TrinketKeyboard.print(&quot;¯\_(ツ)_/¯&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But that only printed the underscores, parentheses and slashes, not the &quot;hands&quot; or the &quot;face.&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there a standard keyboard input method I could use so this device, when plugged into any Mac, will type out a string that includes Unicode (specifically Katakana) characters?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;An &lt;em&gt;ideal&lt;/em&gt; solution does not require configuring the machine before plugging this widget in, and doesn't require changing state on the machine -- although I'll take what I can get! :) (e.g., configuring Japanese keyboard support and toggling input source -- all of which is done blind since the computer can't give feedback to a lowly keyboard -- is un-ideal.)&lt;/p&gt;&#xA;" OwnerUserId="3476" LastActivityDate="2016-08-29T18:29:51.957" Title="How can a USB keyboard emulator (TrinketKeyboard) type Unicode characters?" Tags="|usb|adafruit|keyboard|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28835" PostTypeId="1" AcceptedAnswerId="28850" CreationDate="2016-08-29T16:49:16.530" Score="5" ViewCount="7580" Body="&lt;p&gt;I want to replace my door lock with an one made with an Arduino and a servo, but I'm not sure if the platform is stable enough to use it for something like this.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I do everything right (code, connections, constant power), could I trust in this? &lt;/p&gt;&#xA;" OwnerUserId="16637" LastActivityDate="2016-08-31T07:30:12.547" Title="Is Arduino stable enough to use it for a door lock?" Tags="|servo|" AnswerCount="5" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28836" PostTypeId="2" ParentId="28834" CreationDate="2016-08-29T18:22:48.133" Score="2" Body="&lt;p&gt;It depends entirely on the operating system you are working with. The Arduino is merely a keyboard. It sends keystrokes. Whatever keystrokes your operating system will accept to generate unicode character are the keystrokes you have to program the Arduino to send. Most likely there is some combination of ALT-GR + keypad numbers that will do the trick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For OS X it looks like the only possible way is to change the input settings on the computer to allow &quot;Unicode HEX&quot; entry.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://discussions.apple.com/thread/1899290?tstart=0&quot; rel=&quot;nofollow&quot;&gt;https://discussions.apple.com/thread/1899290?tstart=0&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;There is no other way of doing it. As I say, the Arduino is just a keyboard. It is subject to the same rules as any other keyboard. You can only type things that can be typed. If you need to type other things the OS has to be made aware that you want to type those things through settings.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-29T18:29:51.957" LastActivityDate="2016-08-29T18:29:51.957" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28837" PostTypeId="2" ParentId="28834" CreationDate="2016-08-29T18:29:48.050" Score="2" Body="&lt;p&gt;You could hack it.&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Make it press CMD+SPACE &lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;terminal.app&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press ENTER &lt;/li&gt;&#xA;&lt;li&gt;type  &lt;code&gt;echo -e&#xA;&quot;\xC2\xAF\\_(\xE3\x83\x84)_/\xC2\xAF&quot; | pbcopy&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;press ENTER&lt;/li&gt;&#xA;&lt;li&gt;press CMD+Q&lt;/li&gt;&#xA;&lt;li&gt;press CMD+V&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;though the user would see a terminal window for a second.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-29T18:29:48.050" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28838" PostTypeId="2" ParentId="28835" CreationDate="2016-08-29T18:33:32.203" Score="7" Body="&lt;p&gt;If you can &lt;em&gt;guarantee&lt;/em&gt; that your hardware and software skills are &lt;em&gt;impeccable&lt;/em&gt; then you can certainly trust the MCU on the board. After all, the ATMega chips aren't toys, even though many people around here seem to treat them as such. They are a professional industrial product.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Of course, this is assuming that the Arduino you have is genuine and not some cheap Chinese knock-off with gawd knows what on the board.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-29T18:33:32.203" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28839" PostTypeId="2" ParentId="28591" CreationDate="2016-08-29T19:15:01.900" Score="0" Body="&lt;p&gt;No, it is not.  Adafruit Feather boards are only compatible with Feather 'wings' and not Arduino shields.&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-08-29T19:15:01.900" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28842" PostTypeId="1" CreationDate="2016-08-29T20:16:35.707" Score="1" ViewCount="1554" Body="&lt;p&gt;I am recently seeing strange behavior in my Arduino Yun.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Just using the microcontroller, I enter the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&#xA;#include &amp;lt;string.h&amp;gt; // For string operations.&#xA;#include &quot;Keyboard.h&quot;&#xA;#include &quot;Mouse.h&quot;&#xA;&#xA;void setup() {&#xA;  Keyboard.begin();&#xA;  Keyboard.println(&quot;Hello world.&quot;);&#xA;  Keyboard.print(&quot;Hello world.&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Rather than getting two lines as expected, I get &lt;code&gt;Hello world.Hello world.&lt;/code&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is a very strange error because &lt;a href=&quot;http://www.arduino.org/learning/reference/keyboard-println&quot; rel=&quot;nofollow&quot;&gt;println (docs)&lt;/a&gt; is so 'core' to Keyboard function. I've never had this issue before and I've been playing with it for months. I am running IDE 1.6.11.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;A possibly relevant detail&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;I had this working on my Yun months ago &lt;strong&gt;without&lt;/strong&gt; the &lt;code&gt;#include &quot;Keyboard.h&quot;&lt;/code&gt; and &lt;code&gt;#include &quot;Mouse.h&quot;&lt;/code&gt;. I opened the IDE again just recently and, upon compiling, it failed saying I needed to add those lines. So I did, and it now &lt;code&gt;println&lt;/code&gt; doesn't work.&lt;/p&gt;&#xA;" OwnerUserId="10236" LastEditorUserId="10236" LastEditDate="2016-08-30T02:42:37.390" LastActivityDate="2017-03-29T04:18:34.867" Title="Arduino Keyboard - print() works but println() does not" Tags="|arduino-yun|keyboard|" AnswerCount="1" CommentCount="11" ContentLicense="CC BY-SA 3.0" />
  <row Id="28844" PostTypeId="1" AcceptedAnswerId="28845" CreationDate="2016-08-29T21:06:56.190" Score="0" ViewCount="497" Body="&lt;p&gt;I have an Atmega328 programmed using the Arduino software and libraries (but is standalone on on a board in the TSOP package) without bootloader and with ISP programming). I am using the Wire library to act as an I2C peripheral, where I implement (and register) the &lt;code&gt;requestEvent&lt;/code&gt; and &lt;code&gt;receiveEvent&lt;/code&gt; callbacks.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is it possible to determine, either during the &lt;code&gt;requestEvent&lt;/code&gt; callback or after it at some point, how many bytes were read by the master before it sent a NACK?&lt;/p&gt;&#xA;" OwnerUserId="4526" LastActivityDate="2016-08-29T21:21:07.250" Title="How can I determine how many bytes an I2C master read from my Arduino acting as I2C slave?" Tags="|i2c|atmega328|wire-library|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28845" PostTypeId="2" ParentId="28844" CreationDate="2016-08-29T21:21:07.250" Score="1" Body="&lt;p&gt;You can't.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The master will have to inform the slave how many bytes to transfer, or the master will have to query the slave how many bytes there are to receive.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-29T21:21:07.250" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28846" PostTypeId="2" ParentId="28722" CreationDate="2016-08-29T21:44:18.950" Score="0" Body="&lt;p&gt;Well as I understand you want to use a rotary encoder ? Rotary encoder can turn freely. Which you can read via arduino easily with a library. You can count a number(let's say x) from 0 up to 255, and write that number to one of the color. For the other color write 255-x so when blue is fading down the red is increasing. But I suggest you to use a potentiometer which has a limited turn (about 270 degrees). Connect it to arduino's one of the analog read pins. It will give you a 10 bit value which is between 0-1023 . You can scale this down to 0-255 range with map function. [Example:  &quot;x = map(x,0,1023,0,255);&quot; ] after that just follow the same process as before. &lt;/p&gt;&#xA;" OwnerUserId="21297" LastActivityDate="2016-08-29T21:44:18.950" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28847" PostTypeId="1" CreationDate="2016-08-29T21:54:29.057" Score="2" ViewCount="54" Body="&lt;p&gt;I will be teaching Arduino during a fair in my university, and the school gave me 3 afternoons to teach Arduino to Engineering students. Now I am looking for ideas on how to organize this course, and any help would be very nice.&lt;/p&gt;&#xA;" OwnerUserId="10859" LastActivityDate="2016-08-29T21:54:29.057" Title="How should I organize a 3-day Arduino beginners course?" Tags="|arduino-uno|" AnswerCount="0" CommentCount="5" ClosedDate="2016-08-30T21:51:12.373" ContentLicense="CC BY-SA 3.0" />
  <row Id="28849" PostTypeId="2" ParentId="28835" CreationDate="2016-08-29T23:30:40.420" Score="4" Body="&lt;p&gt;Replying to Majenko's answer with more depth. The limits of the Arduino hardware depend on the ATmega CPU it's built around (I suspect you'll be directly migrating from Arduino to the final PCB). &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;but I'm not sure if the platform is stable enough to use it for something &gt;like this. &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Thus it may be worth considering for you to read through the data sheet. I'd read through it and look at the parameters which could affect your project. For example, the ATmega is only designed to work properly within certain temperature ranges (so this may affect your lock if it's outdoors in the cold). If you're relying on the built-in timer for something in your project, then that can get affected by temperatures, for example &amp;mdash; as opposed to using a quartz crystal for reliable timing. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you'd need to think how your project can fail with the parameter limits of the hardware components. For example, if you're activating the door lock with a secret code stored on external memory, then the memory used may get corrupted when it gets near a magnetic field. &lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorUserId="26190" LastEditDate="2016-08-31T07:30:12.547" LastActivityDate="2016-08-31T07:30:12.547" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28850" PostTypeId="2" ParentId="28835" CreationDate="2016-08-29T23:40:13.353" Score="15" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I'm not sure if the platform is stable enough to use it for something like this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Absolutely it is. As I describe in &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11283&quot; rel=&quot;noreferrer&quot;&gt;my post about an RFID door lock&lt;/a&gt; I use a Uno (and some additional parts) to unlock my door.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since writing that I improved the software &lt;a href=&quot;http://www.gammon.com.au/forum/?id=12869&quot; rel=&quot;noreferrer&quot;&gt;as described here&lt;/a&gt; so you can reprogram the valid list of cards &quot;on the fly&quot; (without uploading new code) as the valid cards are stored in EEPROM.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/It9iY.jpg&quot; rel=&quot;noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/It9iY.jpg&quot; alt=&quot;RFID door lock&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My system has been operating for over 5 years without any problems, except once when there was a brownout in the area and I had to power cycle the system (possibly the RFID reader failed and not the Arduino).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My system &quot;fails shut&quot; so it keeps the door locked in the event of a power failure. However I have alternate ways of leaving the building in the event of a power failure combined with a fire.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You are talking about a servo rather than an electric strike. That is likely to be the weak point, and not the Arduino as such. You would need to ensure it was powerful enough to do whatever-it-is you are planning to do, and that it had suitable drivers (eg. MOSFET or driver board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My system gets used dozens of times each day. We never have a problem with it.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-29T23:40:13.353" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28851" PostTypeId="1" AcceptedAnswerId="28956" CreationDate="2016-08-29T23:46:07.963" Score="2" ViewCount="93" Body="&lt;p&gt;Below is some code that I'm writing to concurrently run &quot;animations&quot; on the same strip of NeoPixels. When I try to make use of the Serial monitor to control the program functions, I just get a bunch of garbled garbage and often, a reboot. I have similar code to this that is actually smaller that runs from a Bluetooth module attached to the same Arduino and has worked for years. Is there some obvious memory issue I'm missing, could my Arduino's SRAM finally be starting to eat it?&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &quot;TripCycling.h&quot;&#xA;#include &quot;CycleLight.h&quot;&#xA;#include &quot;Alternate.h&quot;&#xA;#include &quot;Collision.h&quot;&#xA;#include &quot;FluidColor.h&quot;&#xA;#include &quot;ColorRandomizer.h&quot;&#xA;#include &quot;StreamAnimation.h&quot;&#xA;#include &quot;StreamControl.h&quot;&#xA;#include &amp;lt;MemoryFree.h&amp;gt;&#xA;&#xA;#define MAX_STRIPS 1&#xA;#define MAX_ANIMATIONS 6&#xA;&#xA;&#xA;#define control Serial&#xA;&#xA;static Adafruit_NeoPixel** strips = new Adafruit_NeoPixel*[MAX_STRIPS];&#xA;&#xA;static uint32_t colors[] = {LEDUtils::red, LEDUtils::orange, LEDUtils::yellow, LEDUtils::green, LEDUtils::blue, LEDUtils::purple};&#xA;&#xA;static Animation** animations = new Animation*[MAX_ANIMATIONS];&#xA;&#xA;static int8_t stripIDs[MAX_STRIPS];&#xA;&#xA;&#xA;static String temp = &quot;&quot;;&#xA;static char val;&#xA;static String strings[12];&#xA;&#xA;&#xA;void setup() {&#xA;&#xA;  Serial.begin(9600);&#xA;  Serial.println(&quot;Free Memory: &quot; + String(freeMemory()));&#xA;&#xA;  strips[0] = new Adafruit_NeoPixel(42, 9);&#xA;  stripIDs[0] = 1;&#xA;&#xA;  strips[0]-&amp;gt;begin();&#xA;  strips[0]-&amp;gt;clear();&#xA;  strips[0]-&amp;gt;show();&#xA;&#xA;&#xA;  control.println(&quot;Setup finished!&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  Serial.println(&quot;Free Memory: &quot; + String(freeMemory()));&#xA;&#xA;  if(control.available())&#xA;  {&#xA;    if(control.find('~'))&#xA;    {&#xA;      temp = control.readStringUntil('~');&#xA;&#xA;      val = LEDUtils::split(strings, temp, ':');&#xA;&#xA;      if(strings[0].equals(&quot;CLR&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          LEDUtils::clearSection(*strips[arrayPos], strings[2].toInt(), strings[3].toInt());&#xA;&#xA;          if(strings[4].equals(&quot;True&quot;))&#xA;          {&#xA;            strips[arrayPos]-&amp;gt;show();&#xA;          }&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;ALL&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          LEDUtils::setAll(*strips[arrayPos], strings[2].toInt(), strings[3].toInt(), strings[4].toInt());&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;MAT&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          int8_t findValue = getNextAniPos();&#xA;&#xA;          if(findValue == -1)&#xA;          {&#xA;            control.print(&quot;ERR:Max animations reached~&quot;);&#xA;          }&#xA;          else&#xA;          {&#xA;            uint16_t startPixel = strings[2].toInt();&#xA;            uint16_t stopPixel = strings[3].toInt();&#xA;            long updateTime = strings[4].toInt();&#xA;            uint16_t refNum = strings[5].toInt();&#xA;&#xA;            uint32_t colors[val - 6];&#xA;&#xA;            for(uint8_t i = 6; i &amp;lt; val; i++)&#xA;            {&#xA;              colors[i - 6] = strings[i].toInt();&#xA;            }&#xA;&#xA;            animations[findValue] = new Alternate(*strips[arrayPos], refNum, startPixel, stopPixel, colors, val - 6, updateTime);&#xA;            animations[findValue]-&amp;gt;start();&#xA;          }&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;CRZ&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          int8_t findValue = getNextAniPos();&#xA;&#xA;          if(findValue == -1)&#xA;          {&#xA;            control.print(&quot;ERR:Max animations reached~&quot;);&#xA;          }&#xA;          else&#xA;          {&#xA;            uint16_t startPixel = strings[2].toInt();&#xA;            uint16_t stopPixel = strings[3].toInt();&#xA;            long updateTime = strings[4].toInt();&#xA;            boolean fade = strings[5].toInt() ? true : false; &#xA;            uint16_t refNum = strings[6].toInt();&#xA;&#xA;            uint32_t colors[val - 7];&#xA;&#xA;            for(uint8_t i = 7; i &amp;lt; val; i++)&#xA;            {&#xA;              colors[i - 7] = strings[i].toInt();&#xA;            }&#xA;&#xA;            animations[findValue] = new ColorRandomizer(*strips[arrayPos], refNum, startPixel, stopPixel, colors, val - 7, fade, updateTime);&#xA;            animations[findValue]-&amp;gt;start();&#xA;          }&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;TCL&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          int8_t findValue = getNextAniPos();&#xA;&#xA;          if(findValue == -1)&#xA;          {&#xA;            control.print(&quot;ERR:Max animations reached~&quot;);&#xA;          }&#xA;          else&#xA;          {&#xA;            uint16_t startPixel = strings[2].toInt();&#xA;            uint16_t stopPixel = strings[3].toInt();&#xA;            long updateTime = strings[4].toInt();&#xA;            uint32_t color1 = strings[5].toInt();&#xA;            uint32_t color2 = strings[6].toInt();&#xA;            uint16_t tripSize = strings[7].toInt();&#xA;            uint16_t refNum = strings[8].toInt();&#xA;&#xA;            animations[findValue] = new TripCycling(*strips[arrayPos], refNum, startPixel, stopPixel, tripSize, color1, color2, updateTime);&#xA;            animations[findValue]-&amp;gt;start();&#xA;          }&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;CLI&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          int8_t findValue = getNextAniPos();&#xA;&#xA;          if(findValue == -1)&#xA;          {&#xA;            control.print(&quot;ERR:Max animations reached~&quot;);&#xA;          }&#xA;          else&#xA;          {&#xA;            uint16_t startPixel = strings[2].toInt();&#xA;            uint16_t stopPixel = strings[3].toInt();&#xA;            long updateTime = strings[4].toInt();&#xA;            uint32_t color1 = strings[5].toInt();&#xA;            uint32_t color2 = strings[6].toInt();&#xA;            uint16_t refNum = strings[7].toInt();&#xA;&#xA;            animations[findValue] = new CycleLight(*strips[arrayPos], refNum, startPixel, stopPixel, color1, color2, updateTime);&#xA;            animations[findValue]-&amp;gt;start();&#xA;          }&#xA;        }&#xA;      }&#xA;      else if(strings[0].equals(&quot;COL&quot;))&#xA;      {&#xA;        int8_t arrayPos = getArrayPosByID(strings[1].toInt());&#xA;&#xA;        if(arrayPos == -1)&#xA;        {&#xA;          control.print(&quot;ERR:Strip ID not found~&quot;);&#xA;        }&#xA;        else&#xA;        {&#xA;          int8_t findValue = getNextAniPos();&#xA;&#xA;          if(findValue == -1)&#xA;          {&#xA;            control.print(&quot;ERR:Max animations reached~&quot;);&#xA;          }&#xA;          else&#xA;          {&#xA;            uint16_t startPixel = strings[2].toInt();&#xA;            uint16_t stopPixel = strings[3].toInt();&#xA;            long updateTime = strings[4].toInt();&#xA;            uint32_t color1 = strings[5].toInt();&#xA;            uint32_t color2 = strings[6].toInt();&#xA;            uint16_t refNum = strings[7].toInt();&#xA;&#xA;            animations[findValue] = new Collision(*strips[arrayPos], refNum, startPixel, stopPixel, color1, color2, updateTime);&#xA;            animations[findValue]-&amp;gt;start();&#xA;          }&#xA;        }&#xA;      }&#xA;    }&#xA;  }&#xA;&#xA;  for(uint16_t i = 0; i &amp;lt; MAX_ANIMATIONS; i++)&#xA;  {&#xA;    if(animations[i]-&amp;gt;getRefNum() != 65535 &amp;amp;&amp;amp; animations[i]-&amp;gt;isStarted())&#xA;    {&#xA;      animations[i]-&amp;gt;update();&#xA;    }&#xA;  }&#xA;&#xA;  delay(1);&#xA;}&#xA;&#xA;int8_t getArrayPosByID(int8_t id)&#xA;{&#xA;  for(int8_t i = 0; i &amp;lt; MAX_STRIPS; i++)&#xA;  {&#xA;    if(stripIDs[i] == id)&#xA;    {&#xA;      return i;&#xA;    }&#xA;  }&#xA;&#xA;  return -1;&#xA;}&#xA;&#xA;int8_t getNextAniPos()&#xA;{&#xA;  for(int8_t i = 0; i &amp;lt; MAX_ANIMATIONS; i++)&#xA;  {&#xA;    if(animations[i]-&amp;gt;getRefNum() == 65535)&#xA;    {&#xA;      return i;&#xA;    }&#xA;  }&#xA;&#xA;  return -1;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Note that the includes above are all based on classes I designed to represent the animations, each one has some information in them like the strip to use (passed by reference), the starting pixel, stopping pixel, colors, how long there timers should wait before executing the next animation step, etc. And they are all subclasses of the parent class Animation. I cannot seem to find what is causing the garbling to happen, if I remove references to Serial and just hard-code animations in, everything works fine, and I have around 1KB of SRAM (out of 2K) for other stuff running 6 different animations on one strip of 42 LEDs. At this point I don't make it through the Free Memory println before stuff starts coming up weird and normally the Arduino will just hang and do nothing or keep transmitting the last garbled character over and over as fast as it can. Am I missing something?&lt;/p&gt;&#xA;" OwnerUserId="19937" LastActivityDate="2016-09-02T01:52:12.597" Title="Help with a Memory Issue" Tags="|arduino-uno|serial|led|string|memory-usage|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28852" PostTypeId="2" ParentId="19432" CreationDate="2016-08-30T00:00:57.560" Score="1" Body="&lt;p&gt;I suppose that you already found a solution. If you haven't, one inexpensive way for the Arduino to sense when the water reaches the desired level is to drill two thin parallel holes into the container (using a wire gauge drill bit, provided you're not using glass or something difficult to drill) slightly below the &quot;trigger point.&quot; Then, you can insert two thin strands of conductor so that they protrude a millimeter or less inside the container(consider something like graphite 0.5 mm pencil leads to prevent corrosion). You'll need to seal the holes using epoxy. If you make a voltage divider and put these two pencil leads in the place of the second resistor, you can measure the resistance change (using an Arduino analog input pin) when the pencil leads are &quot;connected&quot; by the water. Once you find the ADC value for the &quot;water full&quot; state of your connection, you can make the Arduino turn off the flow when this value is detected. You should place the pencil leads below the &quot;trigger point&quot; so that you can experiment with different delay periods between sensing the water and turning the flow off (to compensate for the water that remains in the pipe &quot;downstream&quot; the flow controller. I've used this approach successfully to measure flow rate, but I can't guarantee it would work in your application.  &lt;/p&gt;&#xA;" OwnerUserId="26180" LastActivityDate="2016-08-30T00:00:57.560" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28853" PostTypeId="2" ParentId="28828" CreationDate="2016-08-30T00:31:54.727" Score="0" Body="&lt;p&gt;&quot;Sorry, my description was not clear enough. We want to measure everything in total AND every sensor separately. So, we do not really have to measure every sensor, it would be enough to have some reliable numbers to work with.&quot; &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;it possible to measure the energy, say, for every pin on the Arduino?&quot;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You ask if it possible to measure the energy- yes it is-or at least an approximation. The basic solution is as follows. Suppose you want to find the energy consumed by some component at one pin.  Energy is measure in joules. For an electrical circuit we the amount of energy (consumed in 1 second) is given by the formula&lt;/p&gt;&#xA;&#xA;&lt;p&gt;joules=current X voltage. &#xA;Lets consider the case with one sensor first , lets refer to this as sensor A.&#xA;The amount of energy that electrical component consumes in some time duration is by sensor A is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;joules (use by sensor A)=current X voltage X time duration sensor A is on&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now to make this formula applicable to your answer- we can replace voltage by the average voltage, and current by average current, since this is mathemtically equivalent, that the component is on for, and the time duration would be the time the component is on for. So the equivalent formula that can be used is&lt;/p&gt;&#xA;&#xA;&lt;p&gt;joules= average current X average voltage of sensor A during time duration X time duration sensor A is on&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for example if the sensor is only ever used for 50 minutes for all time throughout your project- and the sensor is turned on at the arduino pin for 1 second for every minute of that 50 minutes then the energy used by that sensor on that specific pin is equivalent to leaving the pin on for 50 seconds at the average voltage and average current of that sensor. Say the average voltage is 3v then the energy and average current is 20ma. Then the energy used by that sensor is thus&#xA;3v*0.02amps*55 seconds=3.3 joules.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thus to get the total energy (if there were two sensors A and B) you would just need to sum&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(joules (use by sensor A)= current of A X voltage of A Xtime duration sensor A is on)+(joules (use by sensor B)=current of B Xvoltage of B Xtime duration sensor B is on.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Similar formula for more sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up- basically you would need your arduino program to keep track of how long each sensor pin is on (assuming high voltage turn on the sensor and makes it use power, low voltage turns off the sensor or make it use no power)  for each of the time duration in the formula for the duration of the project, you would need an estimate of the average voltage and current (e.g. from data sheet) or another way. Then you would need to use the formula in your code to compute the energy used by each sensor and the total energy.&#xA;If you have a way to measure the voltage and current fast enough then you could use them measurement instead of using average value as explained above-but I guess using averages is the easiest way to do it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;. &lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorUserId="25788" LastEditDate="2016-08-30T01:34:29.197" LastActivityDate="2016-08-30T01:34:29.197" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28854" PostTypeId="2" ParentId="28835" CreationDate="2016-08-30T00:46:21.430" Score="11" Body="&lt;p&gt;If you want to use an Arduino in this sort of environment, there are a few things to watch out for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;p&gt;Heat (usually from sunlight striking the enclosure). This could be&#xA;relevant for your project, depending on the installation and location&#xA;of the door. Choice of enclosure material, colour and finish can all affect this.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Rollover of millis() (see &lt;a href=&quot;http://playground.arduino.cc/Code/TimingRollover&quot;&gt;http://playground.arduino.cc/Code/TimingRollover&lt;/a&gt;). After 55 days, the millis() function on the Arduino rolls over and resets back to 0. Depending on if/how you use this, it may affect you.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Power supply stability. If you choose to power your Arduino directly from 5v, ensure that it is a smooth stable supply. I've had noisy power supplies cause some weird resets and glitches.&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Water ingress. Again, this depends on location. Don't forget to account for condensation and frost (if applicable).&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Flyback from relay switching and locking solenoids. Add flyback diodes to relay coils and solenoids to stop any flyback voltages killing your control circuitry. See &lt;a href=&quot;https://en.wikipedia.org/wiki/Flyback_diode&quot;&gt;https://en.wikipedia.org/wiki/Flyback_diode&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;I've run in to all of these issues across various Arduino projects. They may not cause the system to fail completely, instead causing strange behaviour.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you design your system to account for all of these factors, then it is absolutely reliable enough to run something 24x7x365.&lt;/p&gt;&#xA;" OwnerUserId="26183" LastEditorUserId="26183" LastEditDate="2016-08-30T01:35:05.737" LastActivityDate="2016-08-30T01:35:05.737" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28855" PostTypeId="2" ParentId="28764" CreationDate="2016-08-30T01:58:13.763" Score="1" Body="&lt;p&gt;The question itself is a bit broad, but I'll try and provide some insight here.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The number of sensors that can be supported, and the number of pins they require, will depend on what sort of interface they use.&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If your sensor has an &lt;strong&gt;analog&lt;/strong&gt; interface, you will need an analog input pin for each sensor.&lt;/li&gt;&#xA;&lt;li&gt;If your sensor has an &lt;strong&gt;I2C&lt;/strong&gt; interface, you can have multiple devices sharing the same pins (a bus) provided that they have different I2C addresses (often configurable with jumpers on the device).&lt;/li&gt;&#xA;&lt;li&gt;If your sensor has an &lt;strong&gt;SPI&lt;/strong&gt; interface, you can have multiple devices using the same pins (a bus), except that each will need a &lt;em&gt;chip select&lt;/em&gt; PIN connected to a digital I/O pin on your Arduino so that it can 'select' each device.&lt;/li&gt;&#xA;&lt;li&gt;If your sensor has a &lt;strong&gt;serial&lt;/strong&gt; interface, you can generally only have one device.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;To add complexity to the problem, you can get expansion modules for the Arduino that will give you extra analog pins or other communication interfaces.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With the long list of sensors you have above, you may also be hard-pressed for program space, as most sensors will need code and/or libraries to interface with them. The Arduinos with more pins (such as the MEGA) also have more program space.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would encourage you to do some further research on the sensors you want to use, and finding out what interface they use, and what Arduino libraries are available for them. This way, you can fully understand the requirements and limitations of any parts you want to use.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Further reading:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Wire&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Wire&lt;/a&gt; (I2C interface)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/SPI&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/SPI&lt;/a&gt; (SPI interface)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/Serial&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Reference/Serial&lt;/a&gt; (Serial interface)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Guide/Libraries&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Guide/Libraries&lt;/a&gt; (Using libraries)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/HomePage&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/HomePage&lt;/a&gt; (Arduino tutorial)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26183" LastActivityDate="2016-08-30T01:58:13.763" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28856" PostTypeId="2" ParentId="28765" CreationDate="2016-08-30T02:58:57.370" Score="2" Body="&lt;p&gt;It is retired so will I have any problem?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It depends on what you want to do with your arduino. If you need a project that requires future support then dont buy a retired board. If you just want to do basic beginners stuff (like blinking LEDs, controlling motors, sending serial information wired or with an add on shield to send wireless information)-then any arduino can do these basic projects and probably at a cheaper price than 58 dollars.&lt;/p&gt;&#xA;" OwnerUserId="25788" LastActivityDate="2016-08-30T02:58:57.370" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28857" PostTypeId="2" ParentId="28835" CreationDate="2016-08-30T03:31:45.890" Score="2" Body="&lt;p&gt;To add to the already good advice so far.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Safety and security wise you need to plan and anticpate for failure. An electromechanical lock or your power supply are hardware wise probably more likely to cause issue than the Arduino board, just watch for back emf and use a flyback diode or snubber as mentioned if required. There may be issues though in your code being stuck in a loop or say card reader or contact faults and so on, this may require a simple on-off at best.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consider using a battery backed power supply for short blackouts or brownouts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then consider your lock type and what will happen in an emergency or with a fault.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Locks such as a strike or mortice lock allow you to use standard door hardware so you have the capability to use a free handle egress out so you won't be trapped in an emergency. You can then also fit a key barrel so if the lock has failed you have a backup way of entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With either type you can then have a fairly good balance of safety and security, if you set it up as fail secure your house will not be vulnerable in a power outage or PSU fault whilst also not trapping you inside.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In a commercial setting fail safe is commonly used on non secure common areas and rooms but preference for a residential front door is fail secure.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Other lock types such as maglock, drop bolt, V-Lock, hook and loop and automatic doors among others do not have purely mechanical methods of using the door in a fault so are harder to use in a residential setting and may need emergency breakglass or stop buttons to cut power on the inside and keyswitch or pincode unit on the outside in case of fault if no other entry point available. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Maglocks for example are fail safe only and will open once power is off,potentially leaving your home vulnerable, so need fairly significant battery backup. However I have also experienced issues where a door controller has failed and will not release, as it is a maglock the power has to be broken and there was no method of release externally and no other point of entry.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I would suggest a strike or electronic mortice lock for your purpose and suggest an off the shelf unit, it will be far more reliable long term.&lt;/p&gt;&#xA;" OwnerUserId="26039" LastActivityDate="2016-08-30T03:31:45.890" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28858" PostTypeId="2" ParentId="23371" CreationDate="2016-08-30T04:09:16.583" Score="5" Body="&lt;p&gt;Both responses are correct but be mindful that this is a SparkFun feature.  An Arduino Pro Mini from China won't necessarily have the &lt;code&gt;SJ1&lt;/code&gt; pad.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) Like Gerben said, the pads on the underside of the board are for I2C pull-up resistors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) Like David said, &lt;code&gt;SJ1&lt;/code&gt; is on the top of the board next to the &lt;code&gt;GND&lt;/code&gt; and &lt;code&gt;RST&lt;/code&gt; pins.  (It looks like a small solder blob.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) To isolate the regulator from &lt;code&gt;VCC&lt;/code&gt;, remove the solder blob on the top of the board with a sucker or solder wick.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Sparkfun schematic shows all of these elements:&#xA;&lt;a href=&quot;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&quot; rel=&quot;noreferrer&quot;&gt;https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26189" LastActivityDate="2016-08-30T04:09:16.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28860" PostTypeId="2" ParentId="4672" CreationDate="2016-08-30T05:34:48.827" Score="1" Body="&lt;p&gt;There is a bit of info on the DC6688F2SCN here: &lt;a href=&quot;http://www.dragonchip.com/TechDoc/Selection%20Guide/DC6688F%20Selection%20Guide%20130301.pdf&quot; rel=&quot;nofollow&quot;&gt;Chip Selection Guide&lt;/a&gt;, but Chris is 100%. Without the firmware, all you can do is look at the source code for the Arduino side.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you look closely at the top of the board, you can see that one side of J16 goes to pins 2 &amp;amp; 3 and the other to 0 &amp;amp; 1. On the schematic, there are some other components hooked in there as well. The serial is definitely going using 0 &amp;amp; 1. I'm not sure why they have them wired to 2 &amp;amp; 3. It's probably a good idea not to put anything on any of these four pins.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's pretty good though. Compare it to the SainSmart L293D shield, which is significantly cheaper but eats up eight digital pins when driving four motors. Also, the L293Ds can only put out 600 mA per channel while the &lt;a href=&quot;http://www.cs.uml.edu/~fredm/cher/people/rsargent/rec/datasheets/l293/&quot; rel=&quot;nofollow&quot;&gt;Bs&lt;/a&gt; can do a full Amp.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The documentation isn't very good and the supporting code also has some issues; but, overall, this is a pretty decent package. It comes with the erector set pieces as well. You also get three IR sensor channels. &lt;/p&gt;&#xA;" OwnerUserId="26191" LastActivityDate="2016-08-30T05:34:48.827" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28861" PostTypeId="2" ParentId="28765" CreationDate="2016-08-30T05:44:23.220" Score="1" Body="&lt;p&gt;When a board is retired, it may:&#xA;- get no support (never had support from Arduino zelf though)&#xA;- not be readily available.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Which may or may nog be a problem.&#xA;The biggest problemen with retired boards is that they often didn't sell very well.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So they may:&#xA;- target niche applications.&#xA;- not have a lot of people post tutorials on it.&#xA;- not have/get elaborate answers on Arduino.se&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I believe you should only get something that fits your needs. &#xA;Usually you van get away with an Uno, and since there are millions if (beginner) tutorials, i'd pick that as my first Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do anything more &quot;pc-like&quot; like USB, camera or a &quot;server&quot;, my first pick would be a raspberry pi.&#xA;Also, since there are hundreds of tutorials.&#xA;You can choose to do it with a yún, and it may work, but you should check if there are tutorials/documentation for whatever you'd like to do with it.&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-08-30T05:44:23.220" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28862" PostTypeId="2" ParentId="28851" CreationDate="2016-08-30T06:03:20.787" Score="4" Body="&lt;p&gt;In short:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Lots of &lt;code&gt;new&lt;/code&gt;, no &lt;code&gt;delete&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Constant strings like &lt;code&gt;Serial.print(&quot;something&quot;)&lt;/code&gt; can be stored in flash memory by Flash Helper &lt;code&gt;Serial.print(F(&quot;something&quot;))&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Maybe too wide color spectre. You can save 1Byte per pixel if you use struct with 8b R/G/B. (or you can use even 16b depth colors - but it is little bit harder).&lt;/li&gt;&#xA;&lt;li&gt;And maybe, if you were storing some instructions only and prepare pixels into ledstrip directly, you can save a lot. However it takes some time to prepare it, so you have to count with it. Something like fill(color, from, to), gradient(...), move left/right... &lt;/li&gt;&#xA;&lt;li&gt;Using Arduino framework is memory and cpu extensive too.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Anyway crashing as you described sounds like stack overflow or memory corruption.&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-08-30T07:22:47.787" LastActivityDate="2016-08-30T07:22:47.787" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28864" PostTypeId="2" ParentId="28722" CreationDate="2016-08-30T06:52:34.630" Score="0" Body="&lt;p&gt;&lt;a href=&quot;http://playground.arduino.cc/Main/RotaryEncoders&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/RotaryEncoders&lt;/a&gt; is where the rotarty encoder libraries are. From there you can use PWM on the outputs as said. There are also some addressable RGB strips/modules that incorporate a driver IC such as adafruit neopixels where you can just write values for colour and brightness to the IC fairly simply, depending on your level of electronics knowledge.&lt;/p&gt;&#xA;" OwnerUserId="26039" LastActivityDate="2016-08-30T06:52:34.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28866" PostTypeId="1" AcceptedAnswerId="28867" CreationDate="2016-08-30T08:13:07.317" Score="1" ViewCount="333" Body="&lt;p&gt;As a project I have to build a SensorHub with multiple sensors. I am relatively new to the Arduino and circuit world, so I need a little help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Goal is to build hub with multiple sensors and to be able to measure power consumption of the entire thing and log the data from all sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I came up with the following part list:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arduino Uno (Rev3)&lt;/li&gt;&#xA;&lt;li&gt;Adafruit 10-DOF IMU L3GD20H + LSM303 + BMP180&lt;/li&gt;&#xA;&lt;li&gt;Adafruit Ultimate GPS v3&lt;/li&gt;&#xA;&lt;li&gt;Adafruit VCNL4010 Proximity and Light sensor&lt;/li&gt;&#xA;&lt;li&gt;Adafruit INA219 High Side DC Current Sensor Breakout&lt;/li&gt;&#xA;&lt;li&gt;Adafruit MicroSD card breakout board&lt;/li&gt;&#xA;&lt;li&gt;of course breadboard, powersupply, calbes, etc.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Everything is connected like this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/CIG46.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/CIG46.png&quot; alt=&quot;SensorHub diagram&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My question is now if this thing will work as I expect. With the 10-DOF, GPS and VCNL4010 I'm pretty sure. They work all with I2C on different addresses and all of them need 5V.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The question is now if I can measure the needed power with this setup. Or does the INA219 need power to be able to get the power to the Arduino? Do you see any problems?&lt;/p&gt;&#xA;" OwnerDisplayName="user19698" LastActivityDate="2016-08-30T09:13:33.130" Title="Will this SensorHub work?" Tags="|arduino-uno|sensors|power|adafruit|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28867" PostTypeId="2" ParentId="28866" CreationDate="2016-08-30T09:13:33.130" Score="0" Body="&lt;p&gt;The INA219 breakout will pass current, even if it doesn't receive any power itself.&lt;/p&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-30T09:13:33.130" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28868" PostTypeId="1" AcceptedAnswerId="28869" CreationDate="2016-08-30T10:47:18.137" Score="1" ViewCount="485" Body="&lt;p&gt;I have a &lt;a href=&quot;https://learn.sparkfun.com/tutorials/gps-logger-shield-hookup-guide&quot; rel=&quot;nofollow&quot;&gt;Sparkfun GPS Logger Shield&lt;/a&gt; and I want to save power by shutting it off when I do not need GPS readings. Now reading the hookup guide it says that the &quot;EN&quot; pin can do this: &quot;Active-high chip-enable – pull low to reset or turn off&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I wanted to ask some advice as to what this actually means and how I safely go about it. Is it as simple as:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, OUTPUT);&#xA;&#xA;//turn off    &#xA;digitalWrite(pin, LOW);&#xA;&#xA;//turn on&#xA;digitalWrite(pin, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Where the pin is a digital pin on the Arduino and it is connected to the &quot;EN&quot; pin of the GPS shield.&lt;/p&gt;&#xA;" OwnerUserId="12166" LastActivityDate="2016-08-30T11:23:12.463" Title="Turning my GPS logger shield off and on" Tags="|power|gps|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28869" PostTypeId="2" ParentId="28868" CreationDate="2016-08-30T10:55:56.967" Score="2" Body="&lt;p&gt;Yes, it is as simple as that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However, since the pin is pulled up already you could also do this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;pinMode(pin, INPUT);&#xA;digitalWrite(pin, LOW);&#xA;&#xA;// Turn off&#xA;pinMode(pin, OUTPUT);&#xA;&#xA;// Turn on&#xA;pinMode(PIN, INPUT);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That then emulates an Open Drain pin which means you're not actively driving the pin when turned on, only when turned off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Personally I prefer system that are active low not active high, and are pulled down by default (normally off) so that you don't waste power driving the pin in order to save power (it's kind of silly really) - you drive the pin to turn on and let the pin float to turn off (especially good with deep deep comatose sleep on some MCUs where the IO pins all switch off).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However the designers of this module decided otherwise, so you're stuck with driving the pin LOW to make it sleep.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-30T11:23:12.463" LastActivityDate="2016-08-30T11:23:12.463" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28871" PostTypeId="1" CreationDate="2016-08-30T12:18:11.037" Score="0" ViewCount="508" Body="&lt;p&gt;I am building a robotic arm using 8 servo motors. I am wondering about what voltage my external power will need to be to control all of them at 6v. I am wanting to use a rechargeable battery.&lt;/p&gt;&#xA;" OwnerUserId="26207" LastActivityDate="2016-08-31T23:52:48.163" Title="What power supply should I use?" Tags="|arduino-uno|power|servo|robotics|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28872" PostTypeId="2" ParentId="28871" CreationDate="2016-08-30T13:20:14.177" Score="6" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;I am wondering about what voltage my external power will need to be to control all of them at 6v&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Well that would be 6V then wouldn't it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You're asking the wrong question. The question you should be asking is:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;How much current will I need from my 6V power supply?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;And the answer is:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Add up the total current required by all of the devices and that is the &lt;em&gt;minimum&lt;/em&gt; current the PSU has to provide&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;On top of that you need to consider &lt;em&gt;how long the supply should last&lt;/em&gt;. The average current need to draw from the batteries, multiplied by the number of hours you need it to run for, is the minimum capacity of battery you need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For instance, if you need to draw an average of 500mA for 6 hours then you need (0.5*6 =) 3Ah (or 3000mAh) batteries (or better).&lt;/p&gt;&#xA;" OwnerUserId="4143" LastEditorUserId="4143" LastEditDate="2016-08-31T23:52:48.163" LastActivityDate="2016-08-31T23:52:48.163" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28873" PostTypeId="1" CreationDate="2016-08-30T14:13:51.333" Score="2" ViewCount="451" Body="&lt;p&gt;I've successfully implemented Door Unlock system described in &lt;a href=&quot;http://www.instructables.com/id/Arduino-RC522-RFID-Door-Unlock/&quot; rel=&quot;nofollow&quot;&gt;this tutorial&lt;/a&gt;.&#xA;At first I used Arduino Uno and RFID RC522 Reader and &lt;a href=&quot;https://www.aliexpress.com/item/1pcs-MG90S-Metal-Geared-Micro-Servo-F4-for-RC-Helicopter-Airplane-Car-Boat-HB88-Free-Shipping/32652367219.html?spm=2114.13010608.0.56.NhxLQJ&quot; rel=&quot;nofollow&quot;&gt;MG90S Micro servo&lt;/a&gt;. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I used Arduino Uno with Arduino Pro Micro for arduino ATmega32U4 5V/16MHz, the RFID reader stops working after plugging the servo. &#xA;Since Arduino Pro Micro have only 5V output, I used resistors to downgrade 5V to 3V in order to poser the RFID reader. I used same output 'vcc' to select 5V for the servo and 3V converted to the reader.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is that each component works perfectly independent of each other, however, when I place them together they stop working.&lt;/p&gt;&#xA;" OwnerUserId="21488" LastEditorDisplayName="user24204" LastEditDate="2016-08-30T20:34:56.177" LastActivityDate="2021-09-07T07:06:05.577" Title="RFID stops working when I place the servo" Tags="|servo|rfid|arduino-pro-micro|" AnswerCount="3" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28874" PostTypeId="1" CreationDate="2016-08-30T15:04:30.913" Score="2" ViewCount="2203" Body="&lt;p&gt;Can I generate a PWM signal for a Mosfet driver using a saw tooth wave and sine wave through Arduino ?&lt;/p&gt;&#xA;" OwnerUserId="26217" LastEditorDisplayName="user24204" LastEditDate="2016-09-02T02:50:02.510" LastActivityDate="2016-09-02T02:50:02.510" Title="PWM generation for inverter by Arduino" Tags="|arduino-uno|mosfet|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28876" PostTypeId="1" AcceptedAnswerId="28904" CreationDate="2016-08-30T15:58:44.937" Score="2" ViewCount="187" Body="&lt;p&gt;I am building a shield that contains an AC power supply and relay for an Arduino-like board. The problem I am having is that the relay is quite noisy with respect to EMI, and I can see a few jitters or jumps in my system during normal operation even with a zero cross detector. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have added in another shield between the 'relay' shield and the main board, which has helped the problem by creating a larger gap, but I would like a more permanent and robust solution. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I was thinking of building a simple shield that has nothing much on it and is simply a large ground plane that sits in between the relay shield and the main board. This would be a simple solution that does not involve making any shielding cages.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;This ground plane would be connect to the chassis of my device, which is then earthed. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since the device has both a DC ground voltage (0V DC) and a AC earth (0V AC) I was thinking maybe I should use both as part of my shielding. Since the board has layers on both sides perhaps I could design it to have the side facing the relays to be earthed, while on the other side, facing the CPU, would be DC ground. I could even couple the two planes with a capacitor, if it helps. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On the one hand I think the earthed option should be fine, but on the other hand I would like to know more about using the DC ground as an EMI shield. Would the simple earth only option work? Would even a DC ground only option work? Does it help to use the DC ground as an EMI shield for the DC components or am I over complicating it?&lt;/p&gt;&#xA;" OwnerUserId="26231" OwnerDisplayName="Brad R" LastEditorUserId="3917" LastEditDate="2016-08-30T17:36:31.887" LastActivityDate="2016-08-31T10:31:53.683" Title="Design considerations for creating an Arduino 'shield' shield to limit EMI" Tags="|power|shields|electronics|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28877" PostTypeId="2" ParentId="28874" CreationDate="2016-08-30T16:17:27.160" Score="0" Body="&lt;p&gt;Currently, none of the boards have a DAC on them, with the exception of the arduino Due. Thus, Unless you have the Due board, it is not possible.&#xA;If you have a due board, and are interested in generating wave functions, then check out here: &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DueSimpleWaveformGenerator&quot; rel=&quot;nofollow&quot;&gt;https://www.arduino.cc/en/Tutorial/DueSimpleWaveformGenerator&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="15994" LastActivityDate="2016-08-30T16:17:27.160" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28878" PostTypeId="1" CreationDate="2016-08-30T16:59:28.083" Score="3" ViewCount="1216" Body="&lt;p&gt;How to produce a sine wave with variable frequency and variable amplitude?&#xA;I found a library to produce variable frequency called &lt;code&gt;sinwave&lt;/code&gt; but not produce variable amplitude (I want -2V to 2V amplitude)&lt;/p&gt;&#xA;" OwnerUserId="26223" LastEditorDisplayName="user24204" LastEditDate="2016-08-31T07:30:25.920" LastActivityDate="2017-07-17T15:00:38.990" Title="producing sine wave variable in amplitude and frequency" Tags="|library|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28879" PostTypeId="2" ParentId="7950" CreationDate="2016-08-30T17:12:24.457" Score="0" Body="&lt;p&gt;Mac OS X will default to using the GPT partition table to format the card, even in FAT32. This does not work with the standard Arduino library for SD cards I've found. You must use MBR. &lt;/p&gt;&#xA;" OwnerUserId="19937" LastActivityDate="2016-08-30T17:12:24.457" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28880" PostTypeId="2" ParentId="28878" CreationDate="2016-08-30T17:27:16.543" Score="2" Body="&lt;p&gt;You can use a digital potentiometer as a programmable attenuator or as a feedback element in a programmable gain amplifier circuit.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;See references  at arduino.cc regarding interfacing an &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPotentiometer&quot; rel=&quot;nofollow&quot;&gt;AD5171&lt;/a&gt; or &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/DigitalPotControl&quot; rel=&quot;nofollow&quot;&gt;AD5206&lt;/a&gt; to Arduinos.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-08-30T17:27:16.543" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28881" PostTypeId="1" CreationDate="2016-08-30T15:28:37.250" Score="2" ViewCount="233" Body="&lt;p&gt;The XBee part of the entire thing works flawlessly no matter how things are being run. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Equipment:&lt;/h3&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Laptop&lt;/li&gt;&#xA;&lt;li&gt;Arduino Uno&lt;/li&gt;&#xA;&lt;li&gt;Sainsmart XBee Shield&lt;/li&gt;&#xA;&lt;li&gt;USB XBee Explorer&lt;/li&gt;&#xA;&lt;li&gt;2 x XBee Series1 modules&lt;/li&gt;&#xA;&lt;li&gt;Terminal software&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;h3&gt;What we are doing:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Send data through terminal software using &quot;XBee 1&quot; on a USB explorer, to remote &quot;XBee 2&quot; which is connected to Arduino Uno using the Sainsmart Shield. Arduino sends a reply which we see in the terminal software. (This is basically just using the two XBee modules to eliminate physical RX-TX connections in a simple point to point communication.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This configuration works perfectly fine when the remote Arduino + XBee are powered by a USB port of a PC (doesn't have to be the same PC - tried with separate PCs, one powering the transmitter and other the receiver.)&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;The problem:&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;This configuration does not work if the remote Arduino + XBee are being powered by:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;9V Battery (brand new)&lt;/li&gt;&#xA;&lt;li&gt;12V, 2A adaptor&lt;/li&gt;&#xA;&lt;li&gt;5V, 2A mobile charger directly supplying through USB&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;BUT it starts working after pressing RESET (sometimes, very rarely, we have to press RESET 2 or 3 times but it does start working) and keeps working while the supply is not disconnected/turned off.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important Note 1:&lt;/strong&gt; As mentioned earlier, the remote XBee always works perfectly fine in all of the above cases as shorting RX/TX shows that the data perfectly and flawlessly echoes back.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Important Note 2:&lt;/strong&gt; I don't think that the Arduino isn't starting up, as to check that I am blinking pin13 LED which always starts working fine in any of the scenarios listed above.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please help. Having to RESET every time after power up makes the whole thing pretty useless for any real world application.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I say that does not work, I mean I don't get a reply from arduino when I send a query over terminal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After pressing Reset, it begins working, i.e. I start getting a reply.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But I don't think that Arduino isn't startup because Pin 13 LED blinks as expected which is something I put just to check whether Arduino code starts running.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As far as circuit, it is nothing but XBee Explorer USB plugged into my laptop and arduino with ready made XBee shield plugged into another USB port (which is when it works). Powering Arduino from a USB port of a different PC also gives no issues.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Only when Arduino is powered by external power source like an adapter or phone charger or 9V battery (literally tried all 3) does it not work automatically and I have to Reset the Arduino after which it starts replying.&lt;/p&gt;&#xA;" OwnerDisplayName="Chinuhark" LastActivityDate="2016-08-30T17:58:15.803" Title="XBee Shield Arduino External Power Issue" Tags="|usb|xbee|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28882" PostTypeId="2" ParentId="28878" CreationDate="2016-08-30T18:38:59.753" Score="2" Body="&lt;p&gt;Here's one solution to do it using your own code implementing the following.The basic solution is as follows.&#xA;Start with the basic sine wave output (this has amplitude between -1 and 1, and repeats ever 360 degrees) implemented as a function in your Arduino sketch with a variable parameter for the frequency and amplitude. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now input the frequency you want (which you don't specify) and the amplitude (that is multiply your sine function by 2). The frequency can be implemented by using the delay function to output a value corresponding to the y-axis of the sine wave  at the specified time on the x-axis. You would need the y output to depend on the delay and the frequency. This is all in code so far. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The next step is to output the corresponding voltages for each point on the sine wave. To make a varying voltage you can use a digital potentiometer with a voltage divider type circuit (it's not quite an voltage divider because it needs to produce negative voltages too). Thus you just need to make your code activate the digital potentiometer at the required resistance to create the required voltage that represents the y value of that sine value at that point in time (x axis has time). This voltage divider requires some more circuity to make the voltage between 0 and -2 volts (the negative voltage depends on the time the circuit has been on or the x-axis of the sine wave). There are lots of ways to make a corresponding negative voltage (the bottom half of the sine wave).  The triggering on or off of the potentiometer is done from the Arduino thus this also controls the frequency of the sine wave.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To sum up code the sine wave in a sketch with your desired frequency and amplitude use these values and implement the discrete point on the sine wave using a (digital) potentiometer which is part of a circuit which is a variation of  the simple voltage divider (the voltage divider type circuit will implement the amplitude of the sine wave which you want between 2v and -2v). The frequency is, basically, implemented with the delay function. &lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorDisplayName="user6430" LastEditDate="2017-07-17T15:00:38.990" LastActivityDate="2017-07-17T15:00:38.990" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28884" PostTypeId="1" CreationDate="2016-08-30T19:51:14.137" Score="-2" ViewCount="99" Body="&lt;p&gt;I am trying to write a program to control a stepper, and incorporate a selector switch and a rheostat. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The object is to make the stepper oscillate, and to be able to control the speed with the rheostat, and the amount of oscillation with the selector switch.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would the best way to go about this?&lt;/p&gt;&#xA;" OwnerUserId="26233" LastActivityDate="2016-08-31T14:04:21.150" Title="Arduino IDE programming help" Tags="|arduino-ide|" AnswerCount="2" CommentCount="4" ClosedDate="2016-09-03T06:49:09.490" ContentLicense="CC BY-SA 3.0" />
  <row Id="28885" PostTypeId="2" ParentId="28830" CreationDate="2016-08-30T20:01:03.510" Score="1" Body="&lt;p&gt;I found the solution. Based on this post: &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=198433.0&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://forum.arduino.cc/index.php?topic=198433.0&lt;/a&gt; I concluded that my strings are too long or my board runs out of memory. I removed the posting of the bucket and created abbreviations in my signal names. This solved the problem.&lt;/p&gt;&#xA;" OwnerUserId="26165" LastEditorUserId="4628" LastEditDate="2017-03-29T03:40:10.957" LastActivityDate="2017-03-29T03:40:10.957" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28886" PostTypeId="1" AcceptedAnswerId="28893" CreationDate="2016-08-30T20:40:01.557" Score="3" ViewCount="2535" Body="&lt;p&gt;I'm doing a little project that requires a lot of sensors. Right now I'm using 4, but i want to reach up to 60 sensors, and a minimum of 16 (for me that's a lot).&#xA;So, I have an Arduino MEGA 2560, and I'm new to Arduino (Had a little experience with PIC before).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've started my project with buttons and leds to simulate the sensor, but my sensors work normally HIGH, and when something pass in front of it, it goes quickly to LOW and back. English is not my first language so I don't recall the name of this sensor, kind of like movement sensor(?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;A lot of stuff pass normally, up to 50/s, in front of it, so it should keep &quot;bouncing&quot; between HIGH and LOW. But when I changed the buttons for the sensors, sometimes my processor won't react, and I think it's because the signal goes back to HIGH before the code reads it. Maybe it's not a problem when it's sensing lot of things, but I can't test it right now with a lot of sensors, and it's not something that can keep getting errors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So I got to interrupts, reading the awesome gammon review. I understood a lot of new things that i didn't know and I searched for a interrupt Library, but the one I found can't use too many sensors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I forgot to tell, but I'm using a touch 2,4&quot; shield too, so a lot of interrupts pins can't be used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Will I be able to use all the sensors I want? If not, could I do it with 2 Arduinos and 1 screen? Am i missing something about the interrupts? Where can I find something to help me?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit 1: All the sensor are the same&lt;/p&gt;&#xA;" OwnerUserId="26234" LastEditorDisplayName="user24204" LastEditDate="2016-08-30T23:46:50.783" LastActivityDate="2017-06-03T17:05:24.130" Title="Using a lot of interrupts on a single Arduino" Tags="|arduino-mega|sensors|interrupt|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28887" PostTypeId="2" ParentId="28871" CreationDate="2016-08-30T20:52:37.207" Score="-1" Body="&lt;p&gt;You should use a &lt;strong&gt;Voltage Regulator&lt;/strong&gt; for a stable Voltage Output. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;First you should know your &lt;strong&gt;maximum Current consumption&lt;/strong&gt;. Lets say for example maximum 2A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You want the Voltage of the Servos stable, so they dont jerk around when there is a voltage drop or change. Because of this reason you should use a Voltage Regulator. For this example, choose one which has a Output of 6V 2A.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For the most of the Voltage Regulators you will be safe if you calculate &lt;strong&gt;an extra of 2V for the Voltage Drop&lt;/strong&gt;. The Voltage Drop Value is specific for every Voltage Regulator Model. You can find this Value in its Datasheet.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So you would need a Power Source, for example a rechargeable NiMh battery with 8V(6V+2V), which can supply 2A. Not all batteries in the world will be able to give you 2A, but like all of the NiMh batteries should.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can find the exact circuit for your Voltage Regulator in its Datasheet, which most likely also will have some (optional) capacitors in it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;In Summary:&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Your needed Voltage (6V)&lt;/li&gt;&#xA;&lt;li&gt;Your maximum needed Current (for example 2A)&lt;/li&gt;&#xA;&lt;li&gt;Find one Voltage Regulator with 6V and 2A Output&lt;/li&gt;&#xA;&lt;li&gt;Find out its Voltage Drop Value&lt;/li&gt;&#xA;&lt;li&gt;6V + Voltage Drop Value = minimum battery voltage&lt;/li&gt;&#xA;&lt;li&gt;Be sure the battery can support the maximum current (2A)&lt;/li&gt;&#xA;&lt;li&gt;Design your circuit with the help of the Voltage Regulators Datasheet&lt;/li&gt;&#xA;&lt;li&gt;Calculate if you need a heat sink for your Voltage Regulator&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;" OwnerUserId="25974" LastActivityDate="2016-08-30T20:52:37.207" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28888" PostTypeId="2" ParentId="28886" CreationDate="2016-08-30T21:03:11.143" Score="3" Body="&lt;p&gt;For that many sensors (way more than the number of interrupts available on the chip), your interrupt service routine (ISR) will need to be able to poll the sensors to discover which one(s) caused the interrupt. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;That might mean connecting each motion-sensor's output to both a latch and a many-input OR-gate to one of the interrupt pins. Your ISR would have to read the latches; set a flag for each LOW latch; clear the latches (to HIGH) and exit. The main routine would then take whatever action was needed for each sensor that had been LOW.&lt;/p&gt;&#xA;" OwnerUserId="313" LastActivityDate="2016-08-30T21:03:11.143" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28889" PostTypeId="2" ParentId="28874" CreationDate="2016-08-30T21:14:45.230" Score="1" Body="&lt;p&gt;Yes you can very easy generate an PWM Output with an Arduino:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup()&#xA;&#xA;{&#xA;&#xA;  pinMode(pwmPin, OUTPUT);   // sets the pin as output&#xA;&#xA;}&#xA;&#xA;&#xA;&#xA;void loop()&#xA;&#xA;{&#xA;&#xA;  analogWrite(pwmPin, yourWantedValue);  // analogWrite values from 0 to 255&#xA;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;On most Arduino boards (those with the ATmega168 or ATmega328), this&#xA;  function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it&#xA;  works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8&#xA;  only support analogWrite() on pins 9, 10, and 11.&lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;The Arduino Due supports analogWrite() on pins 2 through 13, plus pins&#xA;  DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to&#xA;  Analog converters, and act as true analog outputs.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Visit &lt;a href=&quot;http://www.arduino.cc/en/Reference/AnalogWrite&quot; rel=&quot;nofollow&quot;&gt;quote origin&lt;/a&gt; for more Information.&lt;/p&gt;&#xA;" OwnerUserId="25974" LastActivityDate="2016-08-30T21:14:45.230" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28891" PostTypeId="2" ParentId="28842" CreationDate="2016-08-30T21:58:25.390" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Please test: Keyboard.print(&quot;Hello world.\n&quot;);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;That works. println still doesn't.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I'm going to guess here that println is doing something odd in the Yun libraries. I note that the Keyboard.cpp file in my release has this in it:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define SHIFT 0x80&#xA;const uint8_t _asciimap[128] =&#xA;{&#xA;    0x00,             // NUL&#xA;    0x00,             // SOH&#xA;    0x00,             // STX&#xA;    0x00,             // ETX&#xA;    0x00,             // EOT&#xA;    0x00,             // ENQ&#xA;    0x00,             // ACK  &#xA;    0x00,             // BEL&#xA;    0x2a,           // BS   Backspace&#xA;    0x2b,           // TAB  Tab&#xA;    0x28,           // LF   Enter&#xA;    0x00,             // VT &#xA;    0x00,             // FF &#xA;    0x00,             // CR    &amp;lt;---------- note!&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Notice that linefeed has a code mapped (0x28) but carriage return (CR) does not (unless you call 0x00 a mapping).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I &lt;em&gt;think&lt;/em&gt; you'll find that when you hit Enter on a keyboard it is sending a CR (after all, it used to be labelled the &quot;return&quot; key) and not a LF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However I thought that the Print class outputted both:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;size_t Print::println(void)&#xA;{&#xA;  return write(&quot;\r\n&quot;);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Maybe yours doesn't. I'm not certain which exact &lt;code&gt;println&lt;/code&gt; will be pulled in for a Yun. The fact that it used to work, and now doesn't, suggests a change there somewhere.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-08-30T21:58:25.390" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28892" PostTypeId="2" ParentId="28873" CreationDate="2016-08-30T22:29:34.257" Score="1" Body="&lt;p&gt;Use a 3.3VDC regulator for your RFID board a small boxed DC-DC buck converter will be easiest, if linear use an LDO type. Ideally also use a level shifter on your data lines. This could be a resistor voltage divider or zener diode clamp at the most basic, FETs or a dedicated IC is a bit more involved but gets better results.&lt;/p&gt;&#xA;" OwnerUserId="26039" LastActivityDate="2016-08-30T22:29:34.257" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28893" PostTypeId="2" ParentId="28886" CreationDate="2016-08-30T23:58:19.463" Score="6" Body="&lt;p&gt;On a &lt;em&gt;Uno&lt;/em&gt;, all of the digital and analog pins can trigger a pin-change interrupt. That gives you 20 inputs straight away. The Mega also has pin change interrupts but not on all its pins. The pins that the Mega supports for pin-change interrupts are documented on the &lt;a href=&quot;https://www.arduino.cc/en/Reference/SoftwareSerial&quot; rel=&quot;nofollow noreferrer&quot;&gt;Software Serial page&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Not all pins on the Arduino Mega and Arduino Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;(Note that the Atmega2560 chip itself supports more pin change interrupts, however those extra ones are not brought out to header pins on the Arduino board).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That's still quite a few (18 if I counted correctly). Plus the &lt;em&gt;hardware&lt;/em&gt; interrupt pins: 2, 3, 18, 19, 20, 21.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Right now I'm using 4, but i want to reach up to 60 sensors, and a minimum of 16&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;To reach 60 you probably want an input shift register such as the &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11979&quot; rel=&quot;nofollow noreferrer&quot;&gt;74HC165&lt;/a&gt; - you can daisy-chain them together to get lots of inputs. However you would have to &lt;em&gt;poll&lt;/em&gt; to see if pins changed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Otherwise you could use something like the MCP23017 chip, which has 16 input/output pins, and supports interrupts. You can use 4 of them (interfacing with I2C) and thus get 64 inputs. There is &lt;a href=&quot;http://docs.macetech.com/doku.php/centipede_shield&quot; rel=&quot;nofollow noreferrer&quot;&gt;a shield&lt;/a&gt; that has 4 of those chips on it:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/s5bvI.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/s5bvI.png&quot; alt=&quot;Centipede board&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;With suitable software (see &lt;a href=&quot;http://www.gammon.com.au/i2c&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about I2C&lt;/a&gt;) you could configure for interrupts and read any of those 64 inputs when they change.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I have to keep checking all the time for every sensor one by one? &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No, because you can configure the interrupts as open-drain, which means you can connect them all together (if you want to). Or, you could bring out the interrupts for the 4 x MCP23017 chips to four interrupt inputs on the Mega (that narrows down for you which chip caused the interrupt). Then you can read the chip's register(s) to find the state of the pins - either at the time of the interrupt, or right now.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;However you might find that it is actually faster to just poll the chips (say) 100 times a second. There is &lt;em&gt;some&lt;/em&gt; overhead to using I2C, you can also get SPI versions of that chip (MCP23S17) which would operate a bit faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Alternatively, the 74HC165, whilst simpler, could also turn out to be overall faster if you just poll rapidly.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;And the sensor sense a lot of movement per second, won't that cause trouble for the Arduino?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;You need to define &quot;a lot&quot; and &quot;trouble&quot;. You won't do billions of read a second. You can probably do thousands. What would you do with thousands of readings anyway? The time taken to process them would probably be the limiting factor.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;At the same time I'm using a GPS, no problem for the usage of Serial and I2C together right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;No problem, because serial input is interrupt-driven. Within reason, you can do both at once.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-31T21:44:24.657" LastActivityDate="2016-08-31T21:44:24.657" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28894" PostTypeId="1" CreationDate="2016-08-31T00:15:17.103" Score="0" ViewCount="17524" Body="&lt;p&gt;I'm using the ATtiny x5 series board, compiling my project (.cpp.ino file).  Whenever I use the &lt;strong&gt;max(&lt;em&gt;a&lt;/em&gt;,&lt;em&gt;b&lt;/em&gt;)&lt;/strong&gt; macro, I receive this message:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;&quot;C:\Documents and Settings\&amp;lt;user&amp;gt;\Local Settings\Application Data\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++&quot; -c -g -Os  -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10609 -DARDUINO_AVR_ATTINYX5 -DARDUINO_ARCH_AVR   &quot;-IC:\Documents and Settings\&amp;lt;user&amp;gt;\Local Settings\Application Data\Arduino15\packages\ATTinyCore\hardware\avr\1.1.1\cores\tiny&quot; &quot;-IC:\Documents and Settings\&amp;lt;user&amp;gt;\Local Settings\Application Data\Arduino15\packages\ATTinyCore\hardware\avr\1.1.1\variants\tinyX5&quot; &quot;-IC:\Documents and Settings\&amp;lt;user&amp;gt;\My Documents\Arduino\libraries\Pins_xxxxx&quot; &quot;-IC:\Documents and Settings\&amp;lt;user&amp;gt;\My Documents\Arduino\libraries\TinyWireS&quot; &quot;C:\WINDOWS\TEMP\build18f8c74edd63168be814edc24cb0a11a.tmp\sketch\AT85PWM.ino.cpp&quot; -o &quot;C:\WINDOWS\TEMP\build18f8c74edd63168be814edc24cb0a11a.tmp\sketch\AT85PWM.ino.cpp.o&quot;&#xA;C:\Documents and Settings\&amp;lt;user&amp;gt;\Local Settings\Application Data\Arduino15\packages\ATTinyCore\hardware\avr\1.1.1\cores\tiny/Arduino.h:54:24: note: in definition of macro 'max'&#xA; #define max(a,b) ((a)&amp;gt;(b)?(a):(b))&#xA;                        ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;What does &lt;em&gt;note: in definition of macro 'max'&lt;/em&gt; mean, do I need to do anything about it, and if so what?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Searching google for the message gives lots of compiler output listings with the message, but the posting is always for &lt;em&gt;another &lt;strong&gt;different&lt;/strong&gt; message&lt;/em&gt; that is causing trouble.  None of the fixes from those posts address the max note: message.&lt;/p&gt;&#xA;" OwnerUserId="14697" LastEditorUserId="37523" LastEditDate="2019-11-13T17:22:12.337" LastActivityDate="2019-11-13T17:22:12.337" Title="GCC msg &quot;note: in definition of macro 'max'&quot; error message" Tags="|c++|compiler|gcc|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28895" PostTypeId="1" AcceptedAnswerId="28896" CreationDate="2016-08-31T00:55:23.123" Score="1" ViewCount="2902" Body="&lt;p&gt;I am looking to purchase the correct hardware to be able to control 5 DC Motors from an Arduino (UNO preferred, MEGA if necessary).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The Specs of the Motors are as follows: 12 V nominal, 3 → 12 V dc, 794 gcm, 100 rpm, 0.394 W&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What would be your recommendations for how to set this up? As I am fairly new to circuitry a circuit diagram would be helpful along with the recommendation of what shield or drivers to use. Thank You&lt;/p&gt;&#xA;" OwnerUserId="24174" LastActivityDate="2016-08-31T06:26:08.337" Title="Controlling 5 DC motors with Arduino" Tags="|arduino-uno|arduino-mega|motor|shields|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28896" PostTypeId="2" ParentId="28895" CreationDate="2016-08-31T02:13:32.620" Score="1" Body="&lt;p&gt;There are currently no expansion boards (shields) for the Arduino platform that are designed to do what you're asking of it. At most you'll find shields that can support up to 2 maybe 3 motors. My recommendation for a beginner would be to experiment with a breakout board like this one: &lt;a href=&quot;https://www.sparkfun.com/products/9457&quot; rel=&quot;nofollow&quot;&gt;https://www.sparkfun.com/products/9457&lt;/a&gt; It's compact and can easily control 2 of the motors you need, three together and you could control up to 6. &lt;/p&gt;&#xA;" OwnerUserId="19937" LastActivityDate="2016-08-31T02:13:32.620" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28897" PostTypeId="2" ParentId="28894" CreationDate="2016-08-31T05:17:28.880" Score="1" Body="&lt;p&gt;Note to the future:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(My particular case was a function call with several parameters.  One had the &lt;strong&gt;max(a,b)&lt;/strong&gt;, and another parameter had an error.  It used a different macro, which may have pushed the compiler to flag &lt;em&gt;every&lt;/em&gt; macro in the whole call).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The message seems like a red herring, given that there is no problem with the &lt;strong&gt;max(a,b)&lt;/strong&gt; macro definition.  I suspect it is being flagged only because it was tangentially involved with a statement in error.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since it wasn't part of the problem, the compiler couldn't say anything specific about it or the code it generated.  Therefore the flagging message then ends up saying &quot;in definition of macro&quot; (kind of a default of last resort) since it couldn't say anything more specific.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you ever get one of these, particularly from a system provided macro, ignore it until you've diagnosed your other problems.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Ignore the fact that the error message is first in the listing, and the statement using the macro doesn't get flagged until after several other statements are flagged.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Again, I suspect that compiler feels obligated to say something about the macro because it was used.  But since it's not part of the problem in the statement where it appears, it doesn't get flagged there.  Instead the compiler puts the message at the top because it has to go somewhere, but the compiler can't/doesn't want to associate it with the statement where it was used.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The solution worked for me, but a language lawyer or compiler developer may say my explanation has no basis.&lt;/p&gt;&#xA;" OwnerUserId="14697" LastActivityDate="2016-08-31T05:17:28.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28898" PostTypeId="2" ParentId="28894" CreationDate="2016-08-31T06:25:09.237" Score="2" Body="&lt;p&gt;I can reproduce your message easily enough:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define max(a,b) ((a)&amp;gt;(b)?(a):(b))&#xA;&#xA;void setup() {&#xA; int b = 66;&#xA; unsigned int c = 42;&#xA; analogWrite (3, max (b, c));&#xA;}&#xA;&#xA;void loop() { }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get these warnings:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino: In function 'void setup()':&#xA;/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino:1:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]&#xA; #define max(a,b) ((a)&amp;gt;(b)?(a):(b))&#xA;                         ^&#xA;/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino:6:18: note: in expansion of macro 'max'&#xA;  analogWrite (3, max (b, c));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The point is that the warning &lt;code&gt;note: in expansion of macro 'max'&lt;/code&gt; is just telling you where the macro is &lt;em&gt;defined&lt;/em&gt;, so you can make sense of the &lt;em&gt;real&lt;/em&gt; warning. The &lt;em&gt;real&lt;/em&gt; warning is: &lt;code&gt;warning: comparison between signed and unsigned integer expressions&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, reading them together, you are comparing (in the macro) a signed and unsigned number, and the compiler is warning you about that.&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The message seems like a red herring, given that there is no problem with the max(a,b) macro definition. I suspect it is being flagged only because it was tangentially involved with a statement in error.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;That's right. There is no problem in that macro per se. Macros can generate weird error message because they are just text replacements. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;max (the quick brown fox, jumps over the lazy dog);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will generate a slew of errors, including a &quot;note&quot; to where &lt;code&gt;max&lt;/code&gt; is defined. There is nothing wrong with &lt;code&gt;max&lt;/code&gt; until you try feeding garbage into it.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;h1&gt;Templates&lt;/h1&gt;&#xA;&#xA;&lt;p&gt;That's one of the reasons I prefer to avoid macros if possible. You can do &quot;max&quot; with a template. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#undef max   // throw away the original macro in the Arduino header file&#xA;&#xA;template&amp;lt;typename T&amp;gt; T max (T a, T b)&#xA;  {&#xA;  if (a &amp;gt; b)&#xA;    return a;&#xA;&#xA;  return b;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you get slightly more reasonable error messages:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino: In function 'void setup()':&#xA;sketch_aug31a:14: error: no matching function for call to 'max(int&amp;amp;, unsigned int&amp;amp;)'&#xA;   analogWrite (3, max (b, c));&#xA;                            ^&#xA;/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:14:28: note: candidate is:&#xA;/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:3:24: note: template&amp;lt;class T&amp;gt; T max(T, T)&#xA; template&amp;lt;typename T&amp;gt; T max (T a, T b)&#xA;                        ^&#xA;/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:3:24: note:   template argument deduction/substitution failed:&#xA;/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:14:28: note:   deduced conflicting types for parameter 'T' ('int' and 'unsigned int')&#xA;   analogWrite (3, max (b, c));&#xA;                            ^&#xA;exit status 1&#xA;no matching function for call to 'max(int&amp;amp;, unsigned int&amp;amp;)'&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Of course, now you've gone from a warning to an error, because the template wants a single type.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Notice the notes? That's just the compiler trying to be helpful.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;You could make the template take two types if you are prepared to guess the return type (will it be the first type, or the second type?):&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#undef max&#xA;&#xA;template&amp;lt;typename T1, typename T2&amp;gt; T1 max (T1 a, T2 b)&#xA;  {&#xA;  if (a &amp;gt; b)&#xA;    return a;&#xA;&#xA;  return b;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now you don't get an error or a warning, however the result will be the first type (T1) which may or may not suit you.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="10794" LastEditDate="2016-08-31T21:45:42.410" LastActivityDate="2016-08-31T21:45:42.410" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28899" PostTypeId="2" ParentId="28895" CreationDate="2016-08-31T06:26:08.337" Score="1" Body="&lt;p&gt;I would suggest to use the shield that is directly attachable to the Uno, for example: &lt;a href=&quot;http://playground.arduino.cc/Main/AdafruitMotorShield&quot; rel=&quot;nofollow&quot;&gt;http://playground.arduino.cc/Main/AdafruitMotorShield&lt;/a&gt;. So everything you need is Uno, this shield and motors. No soldering.&lt;/p&gt;&#xA;" OwnerUserId="25946" LastActivityDate="2016-08-31T06:26:08.337" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28901" PostTypeId="2" ParentId="28884" CreationDate="2016-08-31T08:20:46.630" Score="3" Body="&lt;p&gt;Majenko provided the correct answer in his comment: you just have to&#xA;write a program to do it! This site is not meant to provide you with a&#xA;ready made solution, but to give help if you run into an issue while&#xA;trying to &lt;em&gt;solve the problem yourself&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That being said, before you attempt to write the program, you should&#xA;learn how to interface with the hardware you are using. Here are the&#xA;relevant Arduino tutorials:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&quot;https://www.arduino.cc/en/Tutorial/Button&quot; rel=&quot;nofollow noreferrer&quot;&gt;Button&lt;/a&gt; tutorial is about reading a push button, but you would&#xA;do exactly the same to read a switch&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/tutorial/potentiometer&quot; rel=&quot;nofollow noreferrer&quot;&gt;Reading a Potentiometer (analog input)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://www.arduino.cc/en/Tutorial/StepperSpeedControl&quot; rel=&quot;nofollow noreferrer&quot;&gt;Stepper Speed Control&lt;/a&gt; will teach you how to control your&#xA;stepper motor&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;And then there is plenty of material available on the Web for each of&#xA;these topics.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go through the tutorials, understand the programs given as examples,&#xA;make them work with your hardware, then put the pieces together to solve&#xA;your problem. If you run into an issue you cannot solve buy yourself,&#xA;then come back here with a &lt;em&gt;specific&lt;/em&gt; question and show us what you have&#xA;attempted so far, including code and schematic. See also &lt;a href=&quot;https://arduino.stackexchange.com/help/how-to-ask&quot;&gt;How do I ask&#xA;a good question?&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="-1" LastEditDate="2017-04-13T12:50:09.617" LastActivityDate="2016-08-31T08:20:46.630" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28902" PostTypeId="2" ParentId="28884" CreationDate="2016-08-31T08:37:05.593" Score="1" Body="&lt;p&gt;Here are the code fragments that would help you.&lt;/p&gt;&#xA;&lt;p&gt;Connect the three wires from the potentiometer to your board. The first goes from one of the outer pins of the potentiometerto ground. The second goes from the other outer pin of the potentiometer to 5 volts. The third goes from the middle pin of the potentiometer to the analog pin &lt;code&gt;A0&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Here is the connection schematic:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/dlY5g.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/dlY5g.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here is the code to read the analog value from port A0:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int sensorValue = analogRead(A0);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;this would assign a value ranging fro 0-1023 to &lt;code&gt;sensorValue&lt;/code&gt; according to the position of the Pot.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;int stepsPerRevolution = 200; &#xA;//this variable holds the no of steps the motor rotates to complete a full circle rotation.&#xA;&#xA;int stepCount = 0;  // number of steps the motor has taken&#xA;&#xA;stepsPerRevolution = map(sensorReading, 0, 1023, 0, 200); &#xA;&#xA;// step 1/100 of a revolution:&#xA;myStepper.step(stepsPerRevolution / 100);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Here is an example program for controlling the direction of stepper using microswitches:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#define stepPin 2&#xA;#define dirPin 3&#xA;#define pinLimitswitchLeft 4  // these can be either left or right depending on motor wiring and dir pin.&#xA;#define pinLimitswitchRight 5 // these switches must be N.O. types&#xA;int stepDelay = 100; // this is the step delay in microseconds. Reduce this to speed up motor rotation and vice versa.&#xA;&#xA;void setup()&#xA;{&#xA;    pinMode (stepPin, OUTPUT);&#xA;    pinMode (dirPin, OUTPUT);&#xA;    pinMode (pinLimitswitchLeft, INPUT_PULLUP);&#xA;    pinMode (pinLimitswitchRight, INPUT_PULLUP); &#xA;}&#xA;    &#xA;void loop()&#xA;{&#xA;    digitalWrite(dirPin, HIGH);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring&#xA;    while (digitalRead(pinLimitswitchLeft) == HIGH) // move motor until left limit switch is pressed.&#xA;    {&#xA;        stepMotor(); &#xA;    }&#xA;    &#xA;    digitalWrite(dirPin, LOW);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring&#xA;    while (digitalRead(pinLimitswitchRight) == HIGH) // move motor until right limit switch is pressed.&#xA;    {&#xA;        stepMotor(); &#xA;    }&#xA;    &#xA;}&#xA;    &#xA;void stepMotor()&#xA;{&#xA;    digitalWrite(stepPin, HIGH);&#xA;    delayMicroseconds(stepDelay);&#xA;    digitalWrite(stepPin, LOW);&#xA;    delayMicroseconds(stepDelay); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Change the control from the control switch to the number of steps taken by your motor when the switch is pressed and it will work as you require.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;I have not included the header files.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please edit the program as you require&lt;/p&gt;&#xA;" OwnerUserId="25638" LastEditorUserId="-1" LastEditDate="2020-06-17T08:21:05.623" LastActivityDate="2016-08-31T14:04:21.150" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28903" PostTypeId="2" ParentId="28734" CreationDate="2016-08-31T08:57:09.913" Score="1" Body="&lt;p&gt;You have two questions, but what makes you think you can't find these out?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you want to know what a device can do (and thus can't do) you should check the devices' datasheet. I believe it is &lt;a href=&quot;ftp://imall.iteadstudio.com/Modules/IM130614001_Serial_Port_BLE_Module_Master_Slave_HM-10/DS_IM130614001_Serial_Port_BLE_Module_Master_Slave_HM-10.pdf&quot; rel=&quot;nofollow&quot;&gt;this file&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Bluetooth (and gsm) devices often work by sending AT commands. For example: &quot;AT+PIO&quot; to set/query GPIO pins of the module.&#xA;You can send &quot;AT+RSSI?&quot; to get a response on the RSSI value.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Not everything can be mentioned in the datasheet though. If you can't find any sources on it, it's most likely not a feature.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The only way to add a &quot;validation function&quot; within the bluetooth connection code, would be to re-write the firmware of the device.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But, you could:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Connect (with everyone using the right pin)&lt;/li&gt;&#xA;&lt;li&gt;Check their RSSI&lt;/li&gt;&#xA;&lt;li&gt;Disconnect if it doesn't match your criteria&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;I'm not sure if this module can have multiple connections, I didn't really see a way to disconnect a single connection. If not, you could even toggle the power to the module to &quot;disconnect&quot; the client(s).&lt;/p&gt;&#xA;" OwnerUserId="8033" LastActivityDate="2016-08-31T08:57:09.913" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28904" PostTypeId="2" ParentId="28876" CreationDate="2016-08-31T10:31:53.683" Score="1" Body="&lt;p&gt;What would be helpful would be explanation of the type of AC you are using and then possibly a schematic or board layout.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;That aside, there does seem to be noise between the two boards. The Idea of placing a PCB with just a large copper pour would work. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;DC Ground&lt;/h3&gt; &#xA;&#xA;&lt;p&gt;If you connect the DC ground from the main board you should use a &lt;code&gt;ferrite bead&lt;/code&gt;(FB) between the two grounds, this will ensure that you don't get noise getting back into the ground of the main board after you have tried to shield it. You should try to match the ferrite bead to the noise frequency you experiencing (use a scope if you have one).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the DC ground as a shield is often done, if you look at the EMI cages on cellular phones, WiFi modules, and other noise generating devices/susceptible-to-noise devices, they are connected to ground. It gives the noise somewhere to go, instead of your signal lines. Thus using the DC ground is defiantly an option&lt;/p&gt;&#xA;&#xA;&lt;p&gt;i.e.:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Main ground&amp;gt;--------[__FB__]-------&amp;lt;SHIELD&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;h3&gt;AC Ground&lt;/h3&gt; &#xA;&#xA;&lt;p&gt;You could use the AC earth line on the top part of the shielding board. The coupling part might be a bit over kill, leave space for it to test to see if it helps when you make the board. Also AC earth can be used for shielding but is used for the safety aspect of earth leakage.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Don't do a direct &lt;em&gt;DC ground&lt;/em&gt; to &lt;em&gt;AC ground&lt;/em&gt; unless you know what you are doing as this will create a ground loop, this will change the way stuff behaves and will make your circuit no longer a floating device.&lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Other stuff&lt;/h3&gt; &#xA;&#xA;&lt;p&gt;I would also make sure how you drive the relay is isolated from the control circuitry, although from what you describe:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;if I move the shield further away I also don't see the issues.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;If you share power rails between the relay board and the main board, try filtering the power going to the CPU section. Also the control lines can be isolated between the controller and the relay with opto-couplers, this might stop noise coming back into the circuit from the relay part. &lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-08-31T10:31:53.683" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28905" PostTypeId="1" CreationDate="2016-08-31T10:50:36.243" Score="1" ViewCount="351" Body="&lt;p&gt;I am trying to solder arduino nano onto a perfboard/solderable breadboard using rosin core solder. The connection is only working some of the time, when I check with a multimeter (+) at pin 29 (in image below) I and (-) at pin 17 there is power at the top of the pin sticking out of the via/hole but there is 0 volts if I check at the actual joint (lower portion of the pin). I see a little flux residue around pin 29 that could indicate a little burning around the area could that be causing this, it is only very minor .. anyway I can fix it?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/QVrbD.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/QVrbD.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/zdt0J.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zdt0J.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also is it normal  to have a little yellow residue left over on the joints? I am new to soldering so not sure if a little flux reside is a bad thing on the joint...&lt;/p&gt;&#xA;" OwnerUserId="26203" LastActivityDate="2016-08-31T16:04:34.953" Title="Soldering issue with arduino" Tags="|arduino-nano|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28906" PostTypeId="2" ParentId="28905" CreationDate="2016-08-31T10:56:23.340" Score="2" Body="&lt;p&gt;Fair play, that is a lot of flux residue. I am assuming you are using some quite chunky solder with lots of flux in it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Flux is non-conductive, so the residue will be forming an insulating layer on the outside of the solder. That doesn't mean the joint is bad, only that you can't get to the joint because the flux residue is in the way.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is a conductive path between the tip of the pin and the pad next to it then all is fine. The fact that you can't see the signal through the outside layer of flux is neither here nor there.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to clean it off you can use isopropyl alcohol (AKA PCB cleaner, AKA &quot;rubbing alcohol&quot;) and use, for instance, a tooth brush to scrub it off. &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-31T10:56:23.340" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28907" PostTypeId="1" AcceptedAnswerId="28922" CreationDate="2016-08-31T14:04:10.187" Score="0" ViewCount="1152" Body="&lt;p&gt;I want to use my Atmega328P in 8MHz, but I noticed that the internal clock is not as accurate and cause problems in my application. To add an external crystal 8MHz I do like the image below or 22pF capacitors are only necessary when I use a 16MHz crystal?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/q2BuC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/q2BuC.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="3837" LastActivityDate="2016-09-01T00:00:53.953" Title="Arduino running at 8MHz with external crystal" Tags="|arduino-uno|" AnswerCount="1" CommentCount="12" ContentLicense="CC BY-SA 3.0" />
  <row Id="28908" PostTypeId="1" AcceptedAnswerId="28909" CreationDate="2016-08-31T14:51:30.013" Score="0" ViewCount="2824" Body="&lt;p&gt;When I use DHCP with &lt;code&gt;ether.dhcpSetup()&lt;/code&gt; the DNS lookup for NTP &lt;code&gt;ether.dnsLookup(&quot;0.pool.ntp.org&quot;)&lt;/code&gt; works fine, but when I use a static setup (because my Android app needs to know the IP address) with &lt;code&gt;ether.staticSetup(myip);&lt;/code&gt; then this returns false and I don't get an IP address from the NTP pool. How come?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have an Arduino Nano ATmega328 with a ENC28j60 ethernet shield, and therefore use the EtherCard libray.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Full MWE:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;EtherCard.h&amp;gt;      // https://github.com/jcw/ethercard&#xA;#include &amp;lt;Time.h&amp;gt;           // http://www.arduino.cc/playground/Code/Time&#xA;&#xA;static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };&#xA;static byte myip[] = {192, 168, 2, 106};&#xA;const char poolNTP[] PROGMEM = &quot;0.pool.ntp.org&quot;; //pool to get time server from&#xA;uint8_t ntpMyPort = 123; //port for the time server, no idea why needed&#xA;&#xA;byte Ethernet::buffer[700];&#xA;&#xA;void setup () {&#xA;  Serial.begin(9600);&#xA;&#xA; //do not forget to add the extra '10' argument because of this ethernet shield&#xA;  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0) {&#xA;    Serial.println(F(&quot;Failed to access Ethernet controller&quot;));&#xA;  }&#xA;&#xA;  //static setup&#xA;  ether.staticSetup(myip);&#xA;  ether.printIp(&quot;Address: http://&quot;, ether.myip);&#xA;&#xA; //this works&#xA;//  if (!ether.dhcpSetup())&#xA;//    Serial.println(F(&quot;DHCP failed&quot;));&#xA;&#xA;  //Find ip address of a time server from the pool&#xA;  if (!ether.dnsLookup(poolNTP)) {&#xA;    Serial.println(&quot;DNS failed&quot;); //with static setup this line is executed, not so with DHCP&#xA;  }&#xA;  ether.printIp(&quot;Lookup IP   : &quot;, ether.hisip);&#xA;}&#xA;&#xA;void loop () {}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23642" LastActivityDate="2017-01-22T15:44:11.797" Title="dns lookup only works with DHCP and not with static setup (EtherCard library)" Tags="|ethernet|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28909" PostTypeId="2" ParentId="28908" CreationDate="2016-08-31T15:42:04.997" Score="1" Body="&lt;p&gt;DHCP does more than just give you your IP address: it also gives you the Net Mask, the Gateway IP address, and the DNS Server IP address. If you don't call &lt;code&gt;dhcpSetup()&lt;/code&gt;, you'll have to do it yourself.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to the &lt;code&gt;EtherCard&lt;/code&gt; documentation, you can do that as follows:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const static uint8_t ip[] = {192,168,0,100}; // Example&#xA;const static uint8_t gw[] = {192,168,0,254}; // Example&#xA;const static uint8_t dns[] = {192,168,0,1};  // Example&#xA;&#xA;...&#xA;&#xA;if (!ether.staticSetup(ip, gw, dns)&#xA;{&#xA;    // handle failure to configure static IP address&#xA;    // (current implementation always returns true!)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-08-31T15:42:04.997" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28911" PostTypeId="2" ParentId="28905" CreationDate="2016-08-31T16:04:34.953" Score="0" Body="&lt;p&gt;“The connection is only working some of the time” does seem to indicate bad solder connections.  (Another possibility is wires in wrong holes.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To locate problems, clip (rather than hold) one lead of an ohmmeter (or a DVM set to Ohms), to a wire soldered to the beginning of the problematic chain of connections.  Then advance step by step along the chain, looking for an open junction.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To fix problems, obtain a &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1558&amp;amp;bih=809&amp;amp;q=solder+sucker&amp;amp;oq=solder+sucker&amp;amp;gs_l=img.3..0j0i24k1.2220.2220.0.2622.1.1.0.0.0.0.86.86.1.1.0....0...1ac..64.img..0.1.85.7MJKU7cTv-I&quot; rel=&quot;nofollow&quot;&gt;solder sucker&lt;/a&gt; and/or &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;source=hp&amp;amp;biw=1558&amp;amp;bih=809&amp;amp;q=solder+wick&amp;amp;oq=solder+wick&amp;amp;gs_l=img.3..0j0i30k1j0i5i30k1j0i24k1l7.7138.7138.0.7590.1.1.0.0.0.0.98.98.1.1.0....0...1ac..64.img..0.1.96.W8GDYoimbVs&quot; rel=&quot;nofollow&quot;&gt;solder wick&lt;/a&gt;, a hot fine-point &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;biw=1558&amp;amp;bih=809&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;sa=1&amp;amp;q=fine-point+soldering+iron++temperature+controlled&amp;amp;oq=fine-point+soldering+iron++temperature+controlled&amp;amp;gs_l=img.3...5190.5190.0.6163.1.1.0.0.0.0.77.77.1.1.0....0...1c.1.64.img..0.0.0.7Ojx_1olWYA&quot; rel=&quot;nofollow&quot;&gt;soldering iron&lt;/a&gt; (preferably temperature controlled), and thin (eg 1-2mm) 60-40 tin-lead rosin-core solder.  Use the solder wick or solder sucker to remove the old solder from the joint.  Apply new solder to make a nice shiny &lt;a href=&quot;https://www.google.com/search?hl=en&amp;amp;biw=1558&amp;amp;bih=809&amp;amp;site=imghp&amp;amp;tbm=isch&amp;amp;sa=1&amp;amp;q=proper+solder+joint&amp;amp;oq=proper+solder&amp;amp;gs_l=img.1.0.0l2j0i8i7i30k1j0i30k1j0i24k1l6.134559.135287.0.137694.6.6.0.0.0.0.119.477.4j1.5.0....0...1c.1.64.img..1.5.473...0i7i30k1j0i7i10i30k1j0i7i5i30k1.kemV59fMwUI&quot; rel=&quot;nofollow&quot;&gt;proper solder joint&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="3917" LastActivityDate="2016-08-31T16:04:34.953" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28912" PostTypeId="1" AcceptedAnswerId="28913" CreationDate="2016-08-31T17:40:32.677" Score="1" ViewCount="115" Body="&lt;p&gt;I'm using an Atmega328p SMD with 32 pins.  I'm trying to get several pins on Port D to function as inputs.  As outputs, they work fine, but for some reason, not as inputs.  Here's a simple example of what I'm dealing with.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void setup() {&#xA;&#xA;DDRB |= (1&amp;lt;&amp;lt;PB3);  //Set up an output on PB3 for an LED&#xA;DDRD = B00000000;  //All of Port D set as inputs&#xA;DDRC = B00000000;  //All of Port C set as inputs&#xA;}&#xA;&#xA;void loop() {&#xA;&#xA;int Power = (PIND &amp;amp; (1 &amp;lt;&amp;lt; PORTD5));  //Read input&#xA;&#xA;  if(Power == 1){&#xA;PORTB |= (1 &amp;lt;&amp;lt; PORTB3);      //set high&#xA;  }&#xA;  else{&#xA;  PORTB &amp;amp;= ~(1 &amp;lt;&amp;lt; PORTB3);  // set  low  &#xA;}    &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;I get no response from my LED like this, no matter which pin on Port D I use as an input.  But when I simply change over to Port C, it works fine.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int Power = (PINC &amp;amp; (1 &amp;lt;&amp;lt; PORTC5));  //Read input&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Ideas?&lt;/p&gt;&#xA;" OwnerUserId="21114" LastActivityDate="2016-08-31T17:45:59.763" Title="Port D isn't Working as Input" Tags="|arduino-uno|port-mapping|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28913" PostTypeId="2" ParentId="28912" CreationDate="2016-08-31T17:45:59.763" Score="1" Body="&lt;p&gt;You check if &lt;code&gt;power&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt;, but it will never be &lt;code&gt;1&lt;/code&gt;. Instead it will be &lt;code&gt;1&amp;lt;&amp;lt;5&lt;/code&gt; or &lt;code&gt;32&lt;/code&gt;. Better use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if(Power != 0){&#xA;  PORTB |= (1 &amp;lt;&amp;lt; PORTB3);      //set high&#xA;}&#xA;else{&#xA;  PORTB &amp;amp;= ~(1 &amp;lt;&amp;lt; PORTB3);  // set  low  &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="2881" LastActivityDate="2016-08-31T17:45:59.763" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28914" PostTypeId="2" ParentId="13684" CreationDate="2016-08-31T18:05:22.583" Score="2" Body="&lt;p&gt;A little late but in case someone like me ran into this:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HC-05&lt;/strong&gt; seems to be the DIY choice. Can work in slave or master mode and works with Android but not iOS.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HC-06&lt;/strong&gt; is the same as HC-05 except that you can only use it in slave mode.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;HM-10&lt;/strong&gt; seems to be the option for iOS users.&lt;/p&gt;&#xA;" OwnerUserId="26150" LastActivityDate="2016-08-31T18:05:22.583" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28915" PostTypeId="1" AcceptedAnswerId="28965" CreationDate="2016-08-31T18:47:14.530" Score="2" ViewCount="1960" Body="&lt;p&gt;I have bought MPU-6050 a month ago for a project, I have got a hang I2C protocol and register maps of MPU. I have learnt how to get raw values of accelerometer and gyroscope. What I needed for my project is roll and pitch angles and acceleration in x,y,z axes. I have tried some algorithms as shown below: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt; First I saw a code which uses only raw accelerometer values to get roll and pitch. Here is a small snippet of that code:  &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;x=(AcX)/16384;&#xA;y=(AcY)/16384;&#xA;z=(AcZ)/16384;&#xA;roll = (atan2(y, z)+PI)*57.295779513082320876798154814105;&#xA;pitch = (atan2(x , z)+PI)*57.295779513082320876798154814105;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;As you can see this uses principle of angle between two vectors, the angles were pretty accurate. But the problem with this code is that as the sensor moves in a particular direction without changing the roll or pitch they still seemed to change (The roll and pitch values are dependent on accel values). &lt;br/&gt;&#xA;Next, I saw about using Complementary Filter my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;Wire.h&amp;gt;&#xA;const int  MPU_addr=0x68, dt=20;&#xA;float AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;&#xA;float xa,ya,za,xg,yg,zg;&#xA;float gan_x = 0 ,gan_y = 0,aan_x = 0,aan_y = 0, anx = 0, any = 0, gain  =0.95;&#xA;int xao = -521 ,yao = 1073 ,zao = 1724 ,xgo = 94 ,ygo =31 ,zgo = 60;                       //offset values&#xA;void setup()&#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  Wire.beginTransmission(MPU_addr);&#xA;  Wire.write(0x1A);&#xA;  Wire.write(0b00000110);&#xA;  Wire.endTransmission(true);&#xA;  Wire.beginTransmission(MPU_addr);&#xA;  Wire.write(0x1B);&#xA;  Wire.write(0b00000000);&#xA;  Wire.endTransmission(true);&#xA;  Wire.beginTransmission(MPU_addr);&#xA;  Wire.write(0x1C);&#xA;  Wire.write(0b00000000);&#xA;  Wire.endTransmission(true);&#xA;  Wire.beginTransmission(MPU_addr);&#xA;  Wire.write(0x6B);&#xA;  Wire.write(0b00000000);&#xA;  Wire.endTransmission(true);&#xA;}&#xA;void loop()&#xA;{ &#xA;  Wire.beginTransmission(MPU_addr);&#xA;  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)&#xA;  Wire.endTransmission(false);&#xA;  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers&#xA;  AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C (ACCEL_XOUT_L)    &#xA;  AcY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;  AcZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;  Tmp=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x41 (TEMP_OUT_H) &amp;amp; 0x42 (TEMP_OUT_L)&#xA;  GyX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x43 (GYRO_XOUT_H) &amp;amp; 0x44 (GYRO_XOUT_L)&#xA;  GyY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x45 (GYRO_YOUT_H) &amp;amp; 0x46 (GYRO_YOUT_L)&#xA;  GyZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x47 (GYRO_ZOUT_H) &amp;amp; 0x48 (GYRO_ZOUT_L)&#xA;  xa = (AcX-xao)/16384;                                                    //sensitivity adjusting&#xA;  ya = (AcY-yao)/16384;&#xA;  za = (AcZ-zao)/16384;&#xA;  xg = (GyX-xgo)/131;&#xA;  yg = (GyY-ygo)/131;&#xA;  zg = (GyZ-zgo)/131;&#xA;  gan_x = dt * xg + anx;                                                       // integrating&#xA;  gan_y = dt * yg + any;&#xA;  aan_x = (atan2(ya,za)+PI)*57.295779513082320876798154814105;&#xA;  aan_y = (atan2(xa,za)+PI)*57.295779513082320876798154814105;&#xA;  anx = (gain) * gan_x + (1-gain) * aan_x;                                     // filtering&#xA;  any = (gain) * gan_y + (1-gain) * aan_y;&#xA;  //Serial.print(&quot; | GyX = &quot;); &#xA;  Serial.print(gan_x);&#xA;  Serial.print(&quot; &quot;);&#xA;  //Serial.print(&quot; | GyY = &quot;); &#xA;  Serial.println(gan_y);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;This code gives good gyroscope values in terms of angular velocity but I want it in degrees is there any way to change those gyro values to degrees(like in first case)?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;I saw Jeff Rowberg's library and I can't seem understand all of the code. Can anyone please provide any reference material explaining the functions present in i2cdevlib.h (Ex: mpu.dmpInitialize(), mpu.setDMPEnabled() etc) it would be a lot of help.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;br/&gt;&#xA;I also would like to know if there are any other alternative IMUs (Gyro+accel) other than MPU6050 which are more of an open source than 6050 (in terms of accessing DMP which seems to be main drawback for MPU) and easier to work with.&#xA;&lt;br/&gt;&#xA;I am using Arduino Nano.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;-Thank you in advance&lt;/p&gt;&#xA;" OwnerUserId="26301" OwnerDisplayName="Teja Allani" LastEditorUserId="26301" LastEditDate="2016-09-02T12:01:54.723" LastActivityDate="2022-05-01T08:31:36.913" Title="Help with MPU-6050" Tags="|accelerometer|mpu6050|gyroscope|" AnswerCount="1" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28916" PostTypeId="1" CreationDate="2016-08-31T19:59:35.620" Score="2" ViewCount="819" Body="&lt;p&gt;How to increase current in O/P port in Arduino uno ?&#xA;to make it 200mA How I can do this?&#xA;It can in proggraming add more current&#xA;Which sample way to increase current ?&#xA;To control 2 Dc motor which normally work with 3 AA battery &#xA;Thanks &lt;/p&gt;&#xA;" OwnerUserId="25487" LastEditorUserId="25487" LastEditDate="2016-09-01T05:18:49.310" LastActivityDate="2016-09-01T05:18:49.310" Title="How to increase current in Arduino uno?" Tags="|arduino-uno|programming|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28917" PostTypeId="2" ParentId="28916" CreationDate="2016-08-31T21:10:34.070" Score="3" Body="&lt;p&gt;You add a transistor. Just like when you're controlling a relay, which &lt;em&gt;needs more current that the Arduino can provide&lt;/em&gt;.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-31T21:10:34.070" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28919" PostTypeId="1" CreationDate="2016-08-31T21:35:21.943" Score="2" ViewCount="368" Body="&lt;p&gt;I've got my sim900 module working with arduino by using their software serial library, however, I want to eliminate arduino from the equation and have serial communication directly to sim900 module. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using putty as my terminal emulator. It's serial is configured to &lt;code&gt;COM1 19200 8 N 1&lt;/code&gt; the same as device manager configuration for this port. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I connect straight from hardware serial on my PCs motherboard into serial-to-ttl interface board which connects to sim900 module. The board has 4 pins - VCC GND TX RX. They're all connected to my sim900 hardware serial as follows: &lt;code&gt;VCC=5V GND=GND TX=TX RX=RX&lt;/code&gt; (Yes I know that it's always actually TX=RX and RX=TX, but when I connect it that way my interface board doesn't blink any led to indicate a transfer whereas it does when I connect TX=TX and RX=RX). The switch on the module is set to hardware serial pins as well. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;So the only thing that happens when I send AT commands such as &lt;code&gt;AT&lt;/code&gt; or &lt;code&gt;ATI&lt;/code&gt; and press enter is that puttys cursor comes back to the beginning of command that I typed. No response. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm thinking that I'm not doing something that the arduinos software serial port is doing when it sends commands to sim900. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone help please ? It's literally been days of trying different configurations with no results. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;In that time besides getting sim900 working with arduino software serial I verified that the hardware serial port on my motherboard is working correctly and the interface board is working correctly as well. &lt;/p&gt;&#xA;" OwnerUserId="25737" LastActivityDate="2016-08-31T21:35:21.943" Title="SIM900 module not responding on hardware COM port" Tags="|arduino-uno|serial|" AnswerCount="0" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28920" PostTypeId="1" AcceptedAnswerId="28924" CreationDate="2016-08-31T22:42:35.530" Score="1" ViewCount="11144" Body="&lt;p&gt;The Arduino Uno manual (from the kit) instructs to connect a resistor to GND when lighting an LED on the breadboard with the 5V (socket?). The red, green, and yellow LEDs don't light up so brightly... actually they are barely bright enough to detect. Is it safe to apply all 5 volts by connecting the cathode to the ground with a &lt;em&gt;wire&lt;/em&gt;? I tried it for a second and it worked... Just don't try it on the blue, I assume that beyond 5V it will explode, it burnt so bright..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Optional: Why does only the blue LED light visibly? &lt;/p&gt;&#xA;" OwnerUserId="26130" LastEditorUserId="26130" LastEditDate="2016-09-01T01:14:52.360" LastActivityDate="2017-05-12T19:50:46.130" Title="Is applying 5 volts to LED dangerous?" Tags="|arduino-uno|led|voltage-protection|" AnswerCount="4" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28921" PostTypeId="2" ParentId="28920" CreationDate="2016-08-31T23:23:08.330" Score="3" Body="&lt;p&gt;No, you cannot safely power an LED with 5V without a resistor. The resistor is absolutely 100% required.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The resistor isn't put there purely on a whim, it's required to set the current based on the supply voltage minus the LED forward voltage and the resistance of the resistor.  &lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-08-31T23:23:08.330" CommentCount="7" ContentLicense="CC BY-SA 3.0" />
  <row Id="28922" PostTypeId="2" ParentId="28907" CreationDate="2016-09-01T00:00:53.953" Score="0" Body="&lt;p&gt;Yes, you require the capacitors, and the capacitors have to be the right value for your crystal.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The datasheet will specify a &lt;em&gt;load capacitance&lt;/em&gt; which you use in the following formula:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;C1 = C2 = 2(CL - C_STRAY)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That is, the &lt;em&gt;load capacitance&lt;/em&gt; of the crystal, minus the stray capacitance from your circuit (as long as your traces are short that is negligible and can be largely ignored unless you have very very tight timing requirements) multiplied by 2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So for 22pF capacitors it is safe to assume that the crystal that is with them has a load capacitance of 11pF.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So check the datasheet for the load capacitance (it should be very prominent) and select the correct capacitors accordingly.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you want to do away with the capacitors and your timing requirements aren't that precise you may get away with a ceramic resonator which doesn't require capacitors.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another option is to use a MEMS® clock chip which generates a stable clock signal at a pre-set frequency. While this doesn't require capacitors for the clock signal it does still require a decoupling capacitor on the power supply for it, but of course that doesn't affect the timing of the clock signal, so precise selection of a specific value isn't needed.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-09-01T00:00:53.953" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28923" PostTypeId="2" ParentId="28920" CreationDate="2016-09-01T03:03:04.533" Score="0" Body="&lt;p&gt;Ah. I found it. From the manual: &lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Without the resistor, the LED would be brighter for a few moments, but quickly burn out.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Since 5V is HIGH on this thing, it looks like 5V would be too much for an LED. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Question 2: You were using the wrong resistor (too much resistance). But even with the incorrect resistor, the blue one shined! Strange. &lt;/p&gt;&#xA;" OwnerUserId="26130" LastActivityDate="2016-09-01T03:03:04.533" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28924" PostTypeId="2" ParentId="28920" CreationDate="2016-09-01T04:38:21.923" Score="5" Body="&lt;p&gt;Different color LEDs are not the same.  The are made with different impurities.  And some colors (blue) were really hard to figure out.  &lt;a href=&quot;https://www.nobelprize.org/nobel_prizes/physics/laureates/2014/press.html&quot; rel=&quot;noreferrer&quot;&gt;So much so that the blue LED inventor was awarded the Nobel Prize&lt;/a&gt;!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Consequently, it should not be assume all LEDs operate at the same voltage and current.  As such, when driving an LED with a constant voltage source, derive the proper series resistance for each case. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Example 1: &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a red LED which may have 1.8 volt drop and may need 20mAmps to operate driven by a 5 volt source, we find the proper series resistor to be...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;V = I * R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;5 - 1.8 = 20mA * R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = (5 - 1.8) / 0.020 &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = 160 ohms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Example 2:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Given a blue LED which may have a 3.3 volt drop and may need 20mAmps to operate driven by a 5 volt source, we find the proper series resistor to be...&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;V = I * R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;5 - 3.3 = 20mA * R &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = (5 - 3.3) / 0.020 &lt;/p&gt;&#xA;  &#xA;  &lt;p&gt;R = 85 ohms&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;Your specific LEDs may have different specifications.  The above are only examples.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Go &lt;a href=&quot;https://en.wikipedia.org/wiki/LED_circuit#Series_resistor_calculation&quot; rel=&quot;noreferrer&quot;&gt;here&lt;/a&gt; for more about calculating the proper LED series resistance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In general, LEDs that are over driven will grow dimmer and not recover.&lt;/p&gt;&#xA;" OwnerUserId="20245" LastActivityDate="2016-09-01T04:38:21.923" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28925" PostTypeId="1" AcceptedAnswerId="28959" CreationDate="2016-09-01T05:18:27.997" Score="0" ViewCount="251" Body="&lt;p&gt;The first challenge on the Arduino Uno manual is to make a closed circuit with a button and LED. The voltage is provided by the 5V pin (non IO), connected by wire to (+) on the bus (breadboard). The wire connects to a resistor, which &lt;strong&gt;makes sense since it resists current running from source&lt;/strong&gt;. The button connects to the resistor, if pushed, the button closes the circuit and current passes through LED (making it shine) and through a wire to GND. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;OK. The second challenge makes no sense. The resistors are connected not to the 5V, but the GND. WHY? Doesn't current dissipate past at ground?? As if the GND is supplying power!? It's like flipping the anode/diode! Here's the challenge: &lt;img src=&quot;https://s10.postimg.org/tn7huuna1/IMG_0499_1.jpg&quot; alt=&quot;&quot;&gt;.What is the logic behind connecting the resistors to GND and WHY DOES IT SUPPLY POWER? I'm not talking about the button, which step two somewhat explains but not why, but the LEDs. Thank you thank you thank you!!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT: Ok, then. I am now being told current flows negative to positive. Fine, then why resistor connected to positive? Also, I was told that GND is there to dissipate the energy flowing from positive because some of that energy was lost. Then, could you explain the circuit and whether flow is perpetual or lost at the end (wherever that is) and if it isn't perpetual in a loop, why have a resistor past the LED when the LED recieved all the volts and the electrical energy it then outputs back on the cycle is reduced by the resistor. Thanks. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I'm changing my question to &quot;Why does resistor on GND ever work on LED&quot; to &quot;Why have resistor at end of circuit cycle if GND dissipates final energy?&quot;.&lt;/p&gt;&#xA;" OwnerUserId="26130" LastEditorDisplayName="user24204" LastEditDate="2016-09-02T22:43:51.527" LastActivityDate="2016-09-03T15:30:33.703" Title="Why have resistor at end of circuit cycle if GND dissipates final energy?" Tags="|led|resistor|" AnswerCount="3" CommentCount="9" FavoriteCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28928" PostTypeId="1" CreationDate="2016-09-01T09:26:18.787" Score="1" ViewCount="2133" Body="&lt;p&gt;There are three Arduinos on a model. Each of them has a DS18B20 Dallas temperature sensor and an nRF24L01 antenna wireless communication. There is also an independent device consisting of an Arduino and an nRF24L01 antenna. Device acts as a receiver. Arduino and antenna play the role of transmitter. The code is:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;nRF24L01.h&amp;gt;&#xA;#include &amp;lt;RF24.h&amp;gt;&#xA;#include &amp;lt;Wire.h&amp;gt;&#xA;&#xA;int temp1;&#xA;int WindSpeed;&#xA;int temp2;&#xA;int temp3;&#xA;RF24 radio(7, 8);&#xA;const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL};&#xA;void setup() {&#xA;  Serial.begin(9600);&#xA;  radio.begin();&#xA;  radio.setRetries(15, 15);&#xA;  radio.setDataRate(RF24_250KBPS); &#xA;  radio.openReadingPipe(0, pipes[1]);&#xA;  radio.openReadingPipe(1, pipes[2]);&#xA;  radio.openReadingPipe(2, pipes[3]);&#xA;  radio.startListening();&#xA;}&#xA;&#xA;void loop() {&#xA;  if (radio.available()) {&#xA;    radio.read(&amp;amp;temp1, sizeof(temp1));  &#xA;     Serial.println(&quot;Temp1:&quot;);&#xA;     Serial.println(temp1);&#xA;     delay(50);&#xA;     radio.read(&amp;amp;WindSpeed, sizeof(WindSpeed));&#xA;     Serial.println(&quot; WindSpeed Bf : &quot;);&#xA;     Serial.println(WindSpeed);  &#xA;     delay(50);&#xA;     radio.read(&amp;amp;temp2, sizeof(temp2));&#xA;     Serial.println(&quot;temp2:&quot;);&#xA;     Serial.println(temp2);&#xA;     delay(50);&#xA;     radio.read(&amp;amp;temp3, sizeof(temp3));      &#xA;     Serial.println(&quot;temp3:&quot;);&#xA;     Serial.println(temp3);&#xA;     delay(50);&#xA;  } else {&#xA;    Serial.println(&quot;No radio Data avaliable&quot;);&#xA;  }&#xA;  delay(3000);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the code sends some values but the correspondence isn't right in &lt;code&gt;AnalogRead&lt;/code&gt;. How can I watch each pipe with the antenna of corresponding Arduino in order to have the right results, and each Arduino sends to the receiver through its own antenna the value of its sensor?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks all for your time!&lt;/p&gt;&#xA;" OwnerUserId="26275" LastEditorUserId="612" LastEditDate="2016-12-31T18:52:01.627" LastActivityDate="2023-01-11T06:02:15.290" Title="Multiple transmitters and problem with ref" Tags="|arduino-uno|nrf24l01+|" AnswerCount="2" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28930" PostTypeId="1" AcceptedAnswerId="28942" CreationDate="2016-09-01T10:03:16.050" Score="2" ViewCount="2084" Body="&lt;p&gt;Is it safe to use a unique 12V 5A DC power source to feed both Arduino and its connected Motor shield, provided that&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the motor (connected to the shield) will eat 3A maximum&lt;/li&gt;&#xA;&lt;li&gt;the Arduino &lt;code&gt;Vin&lt;/code&gt; will get the power&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Arduino and the shield exchange information, and use both the same power supply, is there some risk of &quot;interference&quot; of some kind?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;em&gt;edit&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is the &lt;a href=&quot;http://www.robotshop.com/en/10a-dc-motor-driver-arduino-shield.html&quot; rel=&quot;nofollow&quot;&gt;motor controller shield&lt;/a&gt; I intend to use. In the manual, the connections show that &lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the Arduino and the shield have different power supplies&lt;/li&gt;&#xA;&lt;li&gt;the Arduino power pins are not used by the shield&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="26104" LastEditorUserId="26104" LastEditDate="2016-09-01T14:37:25.027" LastActivityDate="2016-09-01T15:22:39.503" Title="Is it safe to use the same power source for Arduino and its Motor shield?" Tags="|power|arduino-motor-shield|" AnswerCount="2" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28931" PostTypeId="1" CreationDate="2016-09-01T10:11:17.867" Score="1" ViewCount="179" Body="&lt;p&gt;I am encountering a very strange error using &lt;code&gt;freeRTOS&lt;/code&gt; on an Arduino Mega2560:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In the setup block I can create an instance of my class: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;MyClass* myClass = new MyClass(/*char*/ a, /*char*/ b, new Vector(42));&#xA;// new Vector(42) creates a new vector and pushes 42 in as first item&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Using a &lt;code&gt;print()&lt;/code&gt; method in this class, I get a legitimate output on the console, showing me all the chars and values in the vector.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Using the exact same line inside a task, causes the object not to be created properly. It seems like the fields are empty or there is something entirely wrong (like strange memory errors) with the instance. Printing it again results in an empty line (program doesn't crash) while printing a globally created instance gives the correct result.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is there any trap in &lt;code&gt;freeRTOS&lt;/code&gt; concerning the creation of new instances of an object inside a task? Below is the code for the task creation, increasing the task stack size doesn't help. For debug reasons this the only task running at the moment.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;xTaskCreate(displayTask,&#xA;    &quot;DisplayTask&quot;,&#xA;    configMINIMAL_STACK_SIZE + 300,&#xA;    NULL,&#xA;    tskIDLE_PRIORITY + 1,&#xA;    NULL);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="17033" LastEditorDisplayName="user24204" LastEditDate="2016-09-02T06:55:05.310" LastActivityDate="2016-09-02T06:55:05.310" Title="FreeRTOS: Object not created properly from within task" Tags="|arduino-mega|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28932" PostTypeId="1" CreationDate="2016-09-01T10:47:57.053" Score="1" ViewCount="2310" Body="&lt;p&gt;I recently bought a W5100 Ethernet shield and I'm trying to run this simple example, which is a little improvement of the basic WebServer sketch provided by Arduino.cc&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;SPI.h&amp;gt;&#xA;#include &amp;lt;Ethernet.h&amp;gt;&#xA;&#xA;// MAC address from Ethernet shield sticker under board&#xA;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };&#xA;IPAddress DnsServer (192, 168, 1, 6);&#xA;IPAddress GateWay (192, 168, 1, 1);&#xA;IPAddress SubNetMask(255, 255, 255, 0);&#xA;IPAddress ip(192, 168, 1, 20); // IP address, may need to change depending on network&#xA;EthernetServer server(80); // create a server at port 80&#xA;&#xA;String HTTP_req; // stores the HTTP request&#xA;boolean LED_status = 0; // state of LED, off by default&#xA;&#xA;void setup() {&#xA;  Ethernet.begin(mac, ip, DnsServer, GateWay, SubNetMask); // initialize Ethernet device&#xA;  server.begin(); // start to listen for clients&#xA;  Serial.begin(9600); // for diagnostics&#xA;  pinMode(2, OUTPUT); // LED on pin 2&#xA;}&#xA;&#xA;void loop() {&#xA;  EthernetClient client = server.available(); // try to get client&#xA;  if (client) { // got client?&#xA;    boolean currentLineIsBlank = true;&#xA;    while (client.connected()) {&#xA;      if (client.available()) { // client data available to read&#xA;        char c = client.read(); // read 1 byte (character) from client&#xA;        HTTP_req += c; // save the HTTP request 1 char at a time&#xA; // last line of client request is blank and ends with \n&#xA; // respond to client only after last line received&#xA;        if (c == '\n' &amp;amp;&amp;amp; currentLineIsBlank) {&#xA;          // send a standard http response header&#xA;          client.println(&quot;HTTP/1.1 200 OK&quot;);&#xA;          client.println(&quot;Content-Type: text/html&quot;);&#xA;          client.println(&quot;Connection: close&quot;);&#xA;          client.println();&#xA;          // send web page&#xA;          client.println(&quot;&amp;lt;!DOCTYPE html&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;html&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;head&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;title&amp;gt;Arduino LED Control&amp;lt;/title&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/head&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;body&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;h1&amp;gt;LED&amp;lt;/h1&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;p&amp;gt;Click to switch LED on and off.&amp;lt;/p&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;form method=\&quot;get\&quot;&amp;gt;&quot;);&#xA;          ProcessCheckbox(client);&#xA;          client.println(&quot;&amp;lt;/form&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/body&amp;gt;&quot;);&#xA;          client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&#xA;          Serial.print(HTTP_req);&#xA;          HTTP_req = &quot;&quot;; // finished with request, empty string&#xA;          break;&#xA;        }&#xA; // every line of text received from the client ends with \r\n&#xA;        if (c == '\n') {&#xA; // last character on line of received text&#xA; // starting new line with next character read&#xA;          currentLineIsBlank = true;&#xA;        } else if (c != '\r') {&#xA;          // a text character was received from client&#xA;          currentLineIsBlank = false;&#xA;        }&#xA;      } // end if (client.available())&#xA;    } // end while (client.connected())&#xA;    delay(1); // give the web browser time to receive the data&#xA;    client.stop(); // close the connection&#xA;  } // end if (client)&#xA;}&#xA;&#xA;// switch LED and send back HTML for LED checkbox&#xA;void ProcessCheckbox(EthernetClient cl) {&#xA;  if (HTTP_req.indexOf(&quot;LED2=2&quot;) &amp;gt; -1) {&#xA;    // see if checkbox was clicked&#xA; // the checkbox was clicked, toggle the LED&#xA;    if (LED_status) {&#xA;      LED_status = 0;&#xA;    } else {&#xA;      LED_status = 1;&#xA;    }&#xA;  }&#xA;&#xA;  if (LED_status) { // switch LED on&#xA;    digitalWrite(2, HIGH);&#xA;    // checkbox is checked&#xA;    cl.println(&quot;&amp;lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;2\&quot; \&#xA;        onclick=\&quot;submit();\&quot; checked&amp;gt;LED2&quot;);&#xA;  } else { // switch LED off&#xA;    digitalWrite(2, LOW);&#xA;    // checkbox is unchecked&#xA;    cl.println(&quot;&amp;lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;2\&quot; \&#xA;        onclick=\&quot;submit();\&quot;&amp;gt;LED2&quot;);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So I proceed with connecting my shield via a LAN cable to my router (Gateway &lt;code&gt;192.168.1.1&lt;/code&gt;), but if I ping &lt;code&gt;192.168.1.20&lt;/code&gt; (my Arduino) it says &quot;Host Unreachable&quot;, my router use DHCP which always worked and still works fine, I'm sure that there aren't any MAC address or IP conflict. I googled around a lot but nothing seems to work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My DNS server is &lt;code&gt;192.168.1.6&lt;/code&gt; because I'm running PI-Hole (it's an ad blocker) on a Raspberry, and I don't think this is the problem because all devices connected to it are working fine.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please any help? Do I have to assume that my shield is faulty?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I tried also using DHCP connection in order to get an IP from the router by doing a:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Ethernet.begin(mac);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;But no good as well.&lt;/p&gt;&#xA;" OwnerUserId="26276" LastEditorUserId="4628" LastEditDate="2017-05-01T06:31:15.423" LastActivityDate="2018-02-07T07:40:08.443" Title="Can't connect to my Arduino via W5100 Ethernet shield" Tags="|shields|ethernet|web-server|tcpip|" AnswerCount="1" CommentCount="10" ContentLicense="CC BY-SA 3.0" />
  <row Id="28933" PostTypeId="1" CreationDate="2016-09-01T11:34:25.200" Score="1" ViewCount="1235" Body="&lt;p&gt;I have been searching for cheap slim 3&quot; 16:9 capacitive touch screens for a while now. But I couldn't find any that had an I2C or SPI interface. The cheap displays always have these ribbon cables with a ton or pins and it's really hard to find a way to control them from an Arduino (or ESP-32 or ESP-8266).  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I recently found &lt;a href=&quot;https://www.alibaba.com/product-detail/3-inch-tft-screen-with-capacitive_60495467722.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this one&lt;/a&gt;, but how do you access such a touch screen that doesn't have an I2C or SPI interface? &#xA;Do I need some sort of driver board? What exactly would I be look for?&#xA;&lt;a href=&quot;https://i.stack.imgur.com/sLuBK.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/sLuBK.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="13491" LastEditorUserId="10394" LastEditDate="2016-09-01T12:42:38.600" LastActivityDate="2016-09-02T01:31:50.610" Title="Controlling a capacitive touch screen that doesn't have I2C/SPI" Tags="|i2c|spi|display|" AnswerCount="2" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="28934" PostTypeId="2" ParentId="28930" CreationDate="2016-09-01T11:53:46.347" Score="2" Body="&lt;p&gt;I'm assuming your shield has its own power input and you feed the circuit from there. If you are sure that your motor shield can hold that much current there shouldn't be any problem. You should see your motor shield's specs for that.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And actually if your shield has the standard arduino layout, it probably has an header goes into &lt;code&gt;Vin&lt;/code&gt; pin. So even if you try to supply arduino from USB or power jack along with your power supply, the auto selector circuit of arduino board will use the power from 12 volt power source.&lt;/p&gt;&#xA;" OwnerUserId="26263" LastActivityDate="2016-09-01T11:53:46.347" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28935" PostTypeId="2" ParentId="28931" CreationDate="2016-09-01T12:41:23.437" Score="1" Body="&lt;p&gt;'Strange memory errors' you seem to be describing values that have gone out of scope.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is all based on your code, so I may have misunderstood.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The third parameter is causing a memory leak, unless you happen to be deleting it within MyClass (which is normally, not always, bad practice).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It sounds to me that you are trying to access values that have gone out of scope.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Its also possible that this OS requires you to do something to allow the memory to be shared between the tasks.&lt;/p&gt;&#xA;" OwnerUserId="10394" LastActivityDate="2016-09-01T12:41:23.437" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28937" PostTypeId="1" CreationDate="2016-09-01T13:07:59.730" Score="4" ViewCount="699" Body="&lt;p&gt;I am interface Arduino with nRf905 in receive mode use 433 MHZ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I Have follow this link &lt;a href=&quot;http://www.electrodragon.com/w/NRF905_Transceiver_433MHz-Wireless_Module&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.electrodragon.com/w/NRF905_Transceiver_433MHz-Wireless_Module&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;And for transmitter, I am use RF-Transmitter-Door-Window-Sensor which works on 433MHZ. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now, Arduino receive garbage data I have attached snapshot of received data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am quarry about to set address and 433MHZ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My config_buffer is:&#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;unsigned char config_info_buf[10]={&#xA;      0x4C,&#xA;      0x01,                   //output power 10db, resend disable, Current &#xA;      0x44,                   //4-byte address&#xA;      0x20,0x20,              //receive or send data length 32 bytes&#xA;      0x21,0x11,0x11,0x00,&#xA;      0x18,&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Question is there are 0x4C set exactly 433MHZ.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/kSiGL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/kSiGL.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any help will be appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;rajneesh&lt;/p&gt;&#xA;" OwnerUserId="26277" LastEditorUserId="37523" LastEditDate="2019-05-13T06:40:10.400" LastActivityDate="2019-05-13T06:40:10.400" Title="Nordic nRf905 (433MHZ) with arduino receive garbage data" Tags="|arduino-uno|" AnswerCount="0" CommentCount="3" ContentLicense="CC BY-SA 4.0" />
  <row Id="28938" PostTypeId="2" ParentId="28925" CreationDate="2016-09-01T13:08:15.583" Score="4" Body="&lt;p&gt;Roman, As I understand your question you have a resistor, an LED and a switch in &quot;series&quot;. It makes no difference in which order these are connected. It may help to think like water flowing through a hose, with a tap being a switch - it can be at either end.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&quot;Current&quot; flows through each in turn. As others have mentioned current conventionally is considered to flow from + to - (even though in most, but not all, cases electrons flow from - to +).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;In practical circuits it is usually more convenient to select one configuration over another. An Arduino digital pin can be considered as a switch which is either connected to + or -. You could connect a LED (with a current limiting resistor) to either + or -, either is valid it just changes the logic controlling the switch.&lt;/p&gt;&#xA;" OwnerUserId="3879" LastActivityDate="2016-09-01T13:08:15.583" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28939" PostTypeId="1" CreationDate="2016-09-01T04:35:28.397" Score="-1" ViewCount="62" Body="&lt;p&gt;I know that Arduino nano/Uno has one Serial port to read serial data. But if I use software serial can i read more than one serial data.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have 150 Arduino's working on a project(Can be reduced to 50 if required) these arduino will generate serial data (150 serial data as of now). I wanna connect all these 150 serial data to a computer through a single COM port. How can i make it possible. &lt;/p&gt;&#xA;" OwnerDisplayName="Aswinth Raj" LastActivityDate="2016-09-01T14:40:31.183" Title="How can I read Data from 150 Arduino Serially to a Single Arduino to display it via serial port." Tags="|serial|communication|wireless|" AnswerCount="2" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28940" PostTypeId="2" ParentId="28939" CreationDate="2016-09-01T06:51:46.550" Score="1" Body="&lt;p&gt;If each source generates messages at a low enough rate, you can put them all in series. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Each Uno has a serial input, and a serial output, and they are all chained. Each Uno labels its message with who it's from, and passes on received messages unchanged. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Obviously this means that if you used (say) 9600 baud, or approaching 1000 bytes per second, each device would only be able to source 6 bytes per second of message. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If that's not fast enough for your application, then you would need a higher baud rate at the COM port.&lt;/p&gt;&#xA;" OwnerUserId="14348" OwnerDisplayName="Neil_UK" LastActivityDate="2016-09-01T06:51:46.550" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28941" PostTypeId="2" ParentId="28939" CreationDate="2016-09-01T07:08:26.633" Score="1" Body="&lt;p&gt;You can attempt to connect your devices in a loop, if you are insisting on using a single serial port for each. How well all that works will depend on a lot of things.&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/rBDFw.png&quot; alt=&quot;schematic&quot;&gt;&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&lt;p&gt;&lt;sup&gt;&lt;a href=&quot;/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2frBDFw.png&quot;&gt;simulate this circuit&lt;/a&gt; &amp;ndash; Schematic created using &lt;a href=&quot;https://www.circuitlab.com/&quot; rel=&quot;nofollow&quot;&gt;CircuitLab&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have no idea what your computer is, but this is a common mention to string multiple units together where they only have a single serial port each. The software in each unit will need to pass along messages that belong to other units and you will have to device a method for achieving that process. But it can work. Message delays will exist, of course. And with from 50 to 150 units, you may find some serious frustration. But if the needs are modest, you may be able to get by with this mechanism.&lt;/p&gt;&#xA;" OwnerDisplayName="jonk" LastActivityDate="2016-09-01T07:08:26.633" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28942" PostTypeId="2" ParentId="28930" CreationDate="2016-09-01T15:22:39.503" Score="3" Body="&lt;p&gt;In my case, when I was running my DC motors at full load, I noticed a large voltage drop in the circuit. This could affect the signals or transmission of data on the Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It is definitely recommended to power the arduino and motor shield with separate power source. Make sure the the share a common GND.&lt;/p&gt;&#xA;" OwnerUserId="13456" LastActivityDate="2016-09-01T15:22:39.503" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28943" PostTypeId="1" AcceptedAnswerId="28946" CreationDate="2016-09-01T15:22:56.123" Score="2" ViewCount="1662" Body="&lt;p&gt;I'm new to Arduino, and I'm trying to connect my Leonardo via WiFi using a ESP8266 module. What I want to know is if I can power it directly from the onboard 3.3V pin like in the image:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://microcontrollerelectronics.com/wp-content/uploads/2014/12/esp8266_bb.png&quot; alt=&quot;Leonardo&quot;&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or do I need an external voltage regulator? I don't want to damage it.&#xA;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="26278" LastEditorUserId="-1" LastEditDate="2017-03-10T09:42:36.543" LastActivityDate="2017-11-26T18:34:02.717" Title="Powering ESP8266 from Leonardo's 3.3v pin" Tags="|power|esp8266|arduino-leonardo|" AnswerCount="2" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28945" PostTypeId="1" CreationDate="2016-09-01T15:39:24.827" Score="4" ViewCount="341" Body="&lt;p&gt;Will all the classes in this library work with the MKR1000 with wifi hardware?&#xA;The guide mentions &quot;wifi shield&quot;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;So, does the library work exactly the same with the Arduino MKR100 (with the onboard wifi HW) as it does with the wifi shield?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://www.arduino.cc/en/Reference/WiFi101&quot; rel=&quot;nofollow&quot;&gt;WiFi101 library reference&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="24102" LastActivityDate="2016-09-01T15:39:24.827" Title="Is Arduino WiFi101 library fully compatible with Arduino MKR1000 with WiFi HW?" Tags="|arduino-uno|wifi|shields|mkr1000|" AnswerCount="0" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28946" PostTypeId="2" ParentId="28943" CreationDate="2016-09-01T16:12:52.073" Score="4" Body="&lt;p&gt;The Leonardo is specified to provide only 50mA on the 3V3 pin. A ESP8266 can use up to almost 300mA when transmitting. Consider using a LDO regulator connected to the 5V pin instead.&lt;/p&gt;&#xA;" OwnerUserId="368" LastActivityDate="2016-09-01T16:12:52.073" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28949" PostTypeId="1" CreationDate="2016-09-01T19:58:34.940" Score="1" ViewCount="636" Body="&lt;p&gt;I'm using an Arduino Uno. &quot;Regular&quot; serial is plugged into my computer, and I can receive just fine. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I'm using AltSoftSerial (tried SoftwareSerial, same results) with RX and TX on pins 8 and 9 to interface with a BR-355S4 GPS module. According to the &lt;a href=&quot;http://usglobalsat.com/store/gpsfacts/br355s4_gps_facts.html&quot; rel=&quot;nofollow&quot;&gt;data sheet&lt;/a&gt; on that module, the RX and TX are at 5v, which I believe is what the Arduino expects.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I combined the Serial and SoftwareSerial examples to test the connectivity from the Arduino to my PC and from the GPS to the arduino.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;AltSoftSerial.h&amp;gt;&#xA;AltSoftSerial altSerial;&#xA;&#xA;void setup() {&#xA;  //Initialize serial and wait for port to open:&#xA;  Serial.begin(19200);&#xA;  while (!Serial) {&#xA;    ; // wait for serial port to connect. Needed for native USB port only&#xA;  }&#xA;&#xA;  printAsciiTable();&#xA;&#xA;  altSerial.begin(4800);&#xA;}&#xA;&#xA;void printAsciiTable(){&#xA;  Serial.println(&quot;ASCII Table ~ Character Map&quot;);&#xA;  int thisByte;&#xA;  for(thisByte = 33; thisByte &amp;lt; 127; thisByte++){&#xA;    Serial.write(thisByte);&#xA;    Serial.print(&quot;, dec: &quot;);&#xA;    Serial.print(thisByte);&#xA;    Serial.print(&quot;, hex: &quot;);&#xA;    Serial.print(thisByte, HEX);&#xA;    Serial.print(&quot;, oct: &quot;);&#xA;    Serial.print(thisByte, OCT);&#xA;    Serial.print(&quot;, bin: &quot;);&#xA;    Serial.println(thisByte, BIN);&#xA;  }&#xA;  Serial.println(&quot;~~Done with ASCII Table~~&quot;);&#xA;}&#xA;&#xA;void loop() {&#xA;  char c;&#xA;  if(altSerial.available()){&#xA;    c = altSerial.read();&#xA;    Serial.print(c);&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The data coming into the Serial Monitor tool looks fine until it starts pulling from the GPS serial stream (ellipses added by me):&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;...&lt;br&gt;&#xA;  |, dec: 124, hex: 7C, oct: 174, bin: 1111100&lt;br&gt;&#xA;  }, dec: 125, hex: 7D, oct: 175, bin: 1111101&lt;br&gt;&#xA;  ~, dec: 126, hex: 7E, oct: 176, bin: 1111110&lt;br&gt;&#xA;  ~~Done with ASCII Table~~&lt;br&gt;&#xA;  4™5f3y=›ùÙ)É9Ó¦Ì™¦ ...  &lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I would like to receive the &lt;a href=&quot;http://www.gpsinformation.org/dale/nmea.htm#stream&quot; rel=&quot;nofollow&quot;&gt;correct NMEA strings&lt;/a&gt; from the GPS module on altSerial and push them out to Serial. The garbled nature of the serial data looks like a baud rate issue, but I've tried a handful of combinations for Serial and altSerial speed with no success. Any ideas?&lt;/p&gt;&#xA;" OwnerUserId="26284" LastActivityDate="2019-04-23T06:02:45.500" Title="Garbled serial from GPS device" Tags="|arduino-uno|serial|softwareserial|rs232|" AnswerCount="3" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28950" PostTypeId="1" AcceptedAnswerId="28951" CreationDate="2016-09-01T20:27:04.517" Score="3" ViewCount="2491" Body="&lt;p&gt;I'd like to know how much current can supply the 5V pin and the 3.3V pin on an Arduino Leonardo board. I've been lead not to trust the specs on Arduino's website. And, as an added question, can the 5V pin supply enough power for an LM741 opamp?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks!&lt;/p&gt;&#xA;" OwnerUserId="26278" LastActivityDate="2016-09-06T18:37:28.977" Title="What's Leonardo 5V pin current limit?" Tags="|arduino-leonardo|current|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28951" PostTypeId="2" ParentId="28950" CreationDate="2016-09-01T20:36:01.417" Score="3" Body="&lt;p&gt;The 5V pin is either supplied by the USB port, which has a limit of 500mA (imposed by a resettable fuse) if directly connected to the computer or a powered hub (or 100mA in an unpowered hub), or the on-board regulator (NCP1117ST50T3G), which is 1A, when powered externally.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The 3.3V pin is regulated using an LP2985-33DBVR which has a current limit of 150mA (the specifications on the website say 50mA. This is wrong. I think it is a left-over from the old Uno boards with FTDI chips where the 3.3V was fed directly by the internal 3.3V regulator of the FTDI chip and thus limited to 50mA).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Yes, the 5V pin has more than enough current to run an LM741 op-amp.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-09-01T20:36:01.417" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28952" PostTypeId="2" ParentId="28933" CreationDate="2016-09-01T21:13:05.610" Score="0" Body="&lt;p&gt;There are two major parts to a capacitive touchscreen:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The touch panel&lt;/li&gt;&#xA;&lt;li&gt;The controller chip&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;You have to have both in order to use the panel.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically the panel is like a matrix of capacitive sensors, and the controller chip has to rapidly cycle through each row of them (or column if you hold it the other way) sensing all the inputs on that row. It's quite a complex task, and so a special chip is really required for the job.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It's that chip, not the touch screen panel, that presents the SPI or I2C interface.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-09-01T21:13:05.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28953" PostTypeId="2" ParentId="28925" CreationDate="2016-09-01T22:22:58.540" Score="2" Body="&lt;p&gt;To go further with the water analogy as proposed by @Milliways, consider the water system being closed and made of hard pipe (which cannot expand or contract). All of the water (electrical charge) there is, is contained within the closed system. (We'll use a battery instead of a power supply for clarity but it won't make any difference). Think of a simple loop containing a pump &amp;amp; small reservoir (battery), a small turbine or water motor (the LED or most any other electrical load), and a resistor (a constriction somewhere in pipes).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It won't matter where you put the restriction; it will still reduce the flow in the entire loop and therefore, through the turbine, reducing its mechanical output. Even if the restriction is on the return side. Why? Because the same amount of water has to flow past any point in the system, as flows past any other point. If that were not true - the water flowing toward any point != the water flowing away from that point, then there must be either a leak or a water source (loss or gain of water) at that point. Since we believe there is no leak (short circuit to ground) or source of water (battery), then water flowing in must == water flowing out at any point. So wherever you put the restriction (resistor), it limits the flow (current) through the entire loop, and the turbine will do less work.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Update:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If say, 3V are lost/used in the circuit one way, then 2V isn't enough&#xA;  to power, right?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The difference in voltage at various points in the circuit is like the change in pressure at various points in the hydraulic loop. Energy (which is neither pressure nor voltage) is transferred by the flow of water or electrons from the pump (battery) to the turbine (LED) and the restriction (resistor). But in a closed system, no water (electrons) is/are lost.&lt;/p&gt;&#xA;" OwnerUserId="313" LastEditorUserId="313" LastEditDate="2016-09-03T15:30:33.703" LastActivityDate="2016-09-03T15:30:33.703" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28955" PostTypeId="2" ParentId="28933" CreationDate="2016-09-02T01:31:50.610" Score="1" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;Do I need some sort of driver board?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;There are quite a few solutions around to interface with parallel devices like that. Some can be purchased off-the-shelf. I described a home-made solution on my page &lt;a href=&quot;http://www.gammon.com.au/lcd&quot; rel=&quot;nofollow noreferrer&quot;&gt;Connecting a graphical LCD via a I2C/SPI using a 16-bit port expander&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This isn't a touch screen, but from what I can make out of your (rather hard to read) image, it looks similar in concept.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9ZE8A.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9ZE8A.jpg&quot; alt=&quot;Graphical LCD&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I used a MCP23017 16-bit port expander (that is an I2C part, but you can get the MCP23S17 chips which has an SPI interface).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;As you can see from the photo, there are only four wires from the Arduino to the LCD board: +5V, Gnd, SDA, SCL.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When I wrote that article it looks like the MCP23017 was $AUD 2.30. A quick Google search indicates it is still selling for around $US 2.50. On eBay they seem to be selling for around one dollar (eg. $5 for 5 chips).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Depending on the complexity of the driver (on the touch-screen board) writing suitable code may be moderately easy to slightly harder. It depends on how much you are used to coding for these port expanders, and how fiddly the interface requirements are.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Since Adafruit offer a driver shield, it can presumably be done.&lt;/p&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-09-02T01:31:50.610" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28956" PostTypeId="2" ParentId="28851" CreationDate="2016-09-02T01:52:12.597" Score="0" Body="&lt;p&gt;There was a very major issue with the amount of Strings I was storing in RAM. Moving Strings out of RAM and into PROGMEM using the F() macro has helped significantly. Going at things step by step helped me see where the issue was.&lt;/p&gt;&#xA;" OwnerUserId="19937" LastActivityDate="2016-09-02T01:52:12.597" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28957" PostTypeId="2" ParentId="28928" CreationDate="2016-09-02T02:44:34.760" Score="0" Body="&lt;p&gt;You want to send data from 3 (or 4?) different Arduino transmitters to one Arduino receiver and you want to be able to distinguish the packets sent by each transmitter as they are received. The most straightforward way is to create a struct for your data and attach a unique header and trailer that can be used to identify the sender.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;typedef struct {&#xA;  uint8_t header = 0x01;&#xA;  int temp1;&#xA;  uint8_t trailer = 0x10;&#xA;} PACKET;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Something like this should be present in each transmitter but with unique header and trailer for each one. Then the receiver should have the header and trailer bytes for all the transmitters and, whenever it receives data, it checks the first received byte against the list of header bytes to know who sent the data before it continues. Finally, it checks the last byte to know if it's the correct trailer byte for the assumed sender and also as an additional (but perhaps unnecessary) layer of error detection to know if the received packet is a complete valid one.&lt;/p&gt;&#xA;" OwnerUserId="11763" LastActivityDate="2016-09-02T02:44:34.760" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28958" PostTypeId="2" ParentId="28949" CreationDate="2016-09-02T03:47:04.670" Score="1" Body="&lt;p&gt;I looked up the datasheet and product specs for the GPS device. It says that the output is RS-232.&#xA;Note that RS-232 is NOT compatible with the Arduino levels. Arduino &quot;talks and listens&quot; at 5V or 3.3V depending on which board you're using.&#xA;So what you need is a RS-232-to-TTL converter. Now, TTL speaks Arduino. So Arduino will be able to understand that. So try using a MAX232 IC or a shield, whichever you're comfortable with.&lt;/p&gt;&#xA;" OwnerUserId="26293" LastActivityDate="2016-09-02T03:47:04.670" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28959" PostTypeId="2" ParentId="28925" CreationDate="2016-09-02T04:11:59.590" Score="1" Body="&lt;p&gt;Some images may help, other answers so far are quite good. You need to realise the concept that electrons are flowing in a circuit, with series it doesn't matter which order, so in the following schematic, the first 2 are the same and both work in exactly the same way, the 3rd functions the same but obviously uses 2 resistors instead of 1, It is there to help you understand the concept. The resistance of R3+R4 = 1K so the same amount of current flows through D3 the 3rd LED as D1 and D2.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Do you know Ohms law and about voltage drop ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also how to calculate resistance in series and parallel ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;There is some fairly simple maths that shows the 3 different legs are all doing the same thing, however it may over complicate things at this stage if it is above your knowledge as you state you are in middle school.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/SKHGE.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/SKHGE.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="26039" LastActivityDate="2016-09-02T04:11:59.590" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28961" PostTypeId="1" CreationDate="2016-09-02T10:57:27.757" Score="2" ViewCount="3569" Body="&lt;p&gt;This question is posted here as a reference question (its actually a follows  on from comments in my earlier question &quot;How to expand program memory on an arduino?&quot;) -( Edgar Bonet suggested this question and who answered 1 below  in the comments there). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I think its a useful question to others new to arduino. I have posted an answer too. But you can of course add your answer too. I dont know everything about arduino- still learning. It does not refer to the version of the Uno that uses a surface mount atmega328-but the version with removable atmega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;1) If I take out the atmega 328 chip from its socket on the Uno and replace it with using atmega8-16PU instead and I burn a bootloader-does that mean I can use the arduino Uno with the atmega8 like the atmaga328 (but with a subset of the features of the 328)?  The atmega8 is of course an older chip than the 328 (and is significantly cheaper) but it still has same pinouts.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2). I am using the 16mhz crystal in my project. So using an Arduino Uno with atmeg8 chip does this mean that the bootloader will set the fuses on the arduino's atmega8 to use the crystal on the arduino Uno pcb? Or does the bootloader set the fuses on the arduino's atmega8 to use its internal oscillator?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) So hw much memory is left after writing bootlader to atmega8 ?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Can I burn the bootloader more than once?&lt;/p&gt;&#xA;" OwnerUserId="25788" LastEditorUserId="25788" LastEditDate="2016-09-04T02:14:00.230" LastActivityDate="2016-09-04T02:14:00.230" Title="Using an Atmega8 Chip with an Arduino Uno instead of an atmega328" Tags="|arduino-uno|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28962" PostTypeId="2" ParentId="28961" CreationDate="2016-09-02T10:57:57.367" Score="2" Body="&lt;p&gt;1) yes the arduino uno can be used with a blanked at mega8 chip with the NG bootloader burned onto it.&#xA;You would set the board as NG in the IDE to use the arduino IDE (to upload sketches and so on) with it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;2) A crystal and capacitors is still required -the same values as used for the removed atmega328.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;3) The smallest bootloader will leave 7.5kb of program memory left to use on the atmega8.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;4) Yes&lt;/p&gt;&#xA;" OwnerUserId="25788" LastActivityDate="2016-09-02T10:57:57.367" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28965" PostTypeId="2" ParentId="28915" CreationDate="2016-09-02T14:44:35.807" Score="3" Body="&lt;p&gt;I finally got this working after one sleepless night&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include&amp;lt;Wire.h&amp;gt;&#xA;const int MPU = 0x68;&#xA;int t = 0,dt = 1;&#xA;int AcX,AcY,AcZ,GyX,GyY,GyZ,tmp;&#xA;int AcXo,AcYo,AcZo,GyXo,GyYo,GyZo;&#xA;float roll = 0,pitch = 0,rollgy = 0,pitchgy = 0,rollac = 0,pitchac = 0,Ax,Ay,Az,Gx,Gy,Gz,gain = 0.95;&#xA;void MPUconfig(int Addr,int data)&#xA;{&#xA;  Wire.beginTransmission(MPU);&#xA;  Wire.write(Addr);&#xA;  Wire.write(data);&#xA;  Wire.endTransmission();&#xA;}&#xA;void MPUread()&#xA;  {&#xA;    Wire.beginTransmission(MPU);&#xA;    Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)&#xA;    Wire.endTransmission();&#xA;    Wire.requestFrom(MPU,14);  // request a total of 14 registers&#xA;    AcX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C (ACCEL_XOUT_L)    &#xA;    AcY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;    AcZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;    tmp=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3B (ACCEL_XOUT_H) &amp;amp; 0x3C (ACCEL_XOUT_L)    &#xA;    GyX=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3D (ACCEL_YOUT_H) &amp;amp; 0x3E (ACCEL_YOUT_L)&#xA;    GyY=Wire.read()&amp;lt;&amp;lt;8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) &amp;amp; 0x40 (ACCEL_ZOUT_L)&#xA;    GyZ=Wire.read()&amp;lt;&amp;lt;8|Wire.read();&#xA;  }&#xA;void offset()&#xA;{&#xA;  MPUconfig(0x1A,0b00000000);&#xA;  int ax = 0, ay = 0,az = 0,gx = 0,gy = 0,gz = 0,i;&#xA;MPUread();&#xA;MPUread();&#xA;ax = AcX;&#xA;ay = AcY;&#xA;az = AcZ;&#xA;gx = GyX;&#xA;gy = GyY;&#xA;gz = GyZ;&#xA;for(i=0;i&amp;lt;1100;i++)&#xA;{&#xA;    MPUread();&#xA;    if(i&amp;gt;100)&#xA;    {&#xA;      ax = (ax+AcX)/2;&#xA;      ay = (ay+AcY)/2;&#xA;      az = (az+AcZ)/2;&#xA;      gx = (gx+GyX)/2;&#xA;      gy = (gy+GyY)/2;&#xA;      gz = (gz+GyZ)/2;&#xA;    } &#xA;    delay(2);&#xA; }&#xA;AcXo = ax;&#xA;AcYo = ay;&#xA;AcZo = 16384-az;&#xA;GyXo = gx;&#xA;GyYo = gy;&#xA;GyZo = gz;&#xA;MPUconfig(0x1A,0b00000110);&#xA;}&#xA;void setup() &#xA;{&#xA;  Serial.begin(115200);&#xA;  Wire.begin();&#xA;  MPUconfig(0x1A,0b00000110);&#xA;  MPUconfig(0x1B,0b00000000);&#xA;  MPUconfig(0x1C,0b00000000);&#xA;  MPUconfig(0x6B,0b00000000);&#xA;  offset();&#xA;}&#xA;&#xA;void loop()&#xA;{&#xA;  t = millis();&#xA;  MPUread();&#xA;  Ax = (float)(AcX-AcXo)/16384;&#xA;  Ay = (float)(AcY-AcYo)/16384;&#xA;  Az = (float)(AcZ-AcZo)/16384;&#xA;  Gx = (float)(GyX-GyXo)/131;&#xA;  Gy = (float)(GyY-GyYo)/131;&#xA;  Gz = (float)(GyZ-GyZo)/131;&#xA;  pitchgy = (Gy * ((float) dt/1000)) + pitch;&#xA;  rollgy = (Gx * ((float) dt/1000)) + roll;&#xA;  pitchac = atan2(Ax,Az) * (float)(180/PI);&#xA;  rollac =  atan2(Ay,Az) * (float) (180/PI);&#xA;  roll = gain * rollgy + (1-gain)* rollac;&#xA;  pitch = gain * pitchgy + (1-gain) * pitchac; &#xA;  Serial.print(roll);&#xA;  Serial.print(&quot; &quot;); Serial.print(pitch);&#xA;  Serial.println(&quot; &quot;);&#xA;  dt = millis()-t;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="26301" LastEditorUserId="26301" LastEditDate="2016-09-04T16:36:57.207" LastActivityDate="2016-09-04T16:36:57.207" CommentCount="9" ContentLicense="CC BY-SA 3.0" />
  <row Id="28966" PostTypeId="1" CreationDate="2016-09-02T15:16:19.813" Score="2" ViewCount="744" Body="&lt;p&gt;Maybe it's a simple question but I'm unable to get what I need.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My task is this:&#xA;Get the acceleration and speed of each axis of the accelerometer.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I thought of something like: &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;const int VCCPin = A0;&#xA;const int xPin   = A1;&#xA;const int yPin   = A2;&#xA;const int zPin   = A3;&#xA;const int GNDPin = A4;&#xA;&#xA;// variables&#xA;int old_x = 0;&#xA;int old_y = 0;&#xA;int old_z = 0;&#xA;&#xA;int new_x = 0;&#xA;int new_y = 0;&#xA;int new_z = 0;&#xA;&#xA;void setup() {&#xA;  // pin A0 (pin14) is VCC and pin A4 (pin18) in GND to activate the GY-61-module&#xA;  pinMode(A0, OUTPUT);&#xA;  pinMode(A4, OUTPUT);&#xA;  digitalWrite(14, HIGH);&#xA;  digitalWrite(18, LOW);&#xA;&#xA;  // activating debugging for arduino UNO&#xA;  Serial.begin(9600);&#xA;} &#xA;&#xA;void loop() {&#xA;  new_x = analogRead(xPin);&#xA;  new_y = analogRead(yPin);&#xA;  new_z = analogRead(zPin);&#xA;&#xA;  Serial.print(&quot;Difference in X=&quot;);&#xA;  Serial.println(abs(old_x - new_x));&#xA;&#xA;  Serial.print(&quot;Difference in Y=&quot;);&#xA;  Serial.println(abs(old_y - new_y));&#xA;&#xA;  Serial.print(&quot;Difference in Z=&quot;);&#xA;  Serial.println(abs(old_z - new_z));&#xA;&#xA;  old_x = new_x;&#xA;  old_y = new_y;&#xA;  old_z = new_z;&#xA;} &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Unfortunately, the analogRead will give me a value between 0 and 1023 and I don't know how to convert this to speed and acceleration.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any ideas on how to get this convertion?&lt;/p&gt;&#xA;" OwnerUserId="26306" LastActivityDate="2016-10-28T08:40:59.607" Title="Transforming from analog output to speed and acceleration with gy-61" Tags="|arduino-uno|serial|accelerometer|mathematics|" AnswerCount="0" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="28967" PostTypeId="2" ParentId="242" CreationDate="2016-09-02T16:08:13.393" Score="5" Body="&lt;p&gt;Re-visiting an old question... as I found a very informative blog post&#xA;that sheds new light into it. But let me first provide some context&#xA;before giving the link.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When assessing the quality of a time base, be it a crystal, a ceramic&#xA;resonator or a lab-grade frequency standard, there are two notions that&#xA;should be distinguished:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;accuracy&lt;/strong&gt;: how close is the frequency of the time base to its&#xA;&lt;em&gt;nominal&lt;/em&gt; value&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;stability&lt;/strong&gt;: how much does that frequency drift over time&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Accuracy is important if you want your clock to give correct time “out&#xA;of the box”. However, if you are willing to spend some time calibrating&#xA;your clock, then you do not really care because you are going to&#xA;calibrate out any inaccuracy you measure. jfpoilpret's answer provides&#xA;an example of a “manual” calibration protocol, which is by necessity&#xA;quite lengthy. If you can borrow a GPS module with a 1PPS output, the&#xA;calibration could be done in a few seconds.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Stability is a more serious issue. If the frequency of the time base&#xA;drifts randomly, this will defeat your calibration efforts. Essentially,&#xA;the calibration will tell you how fast or slow your clock is running&#xA;&lt;em&gt;right now&lt;/em&gt;, but it will not allow you to predict how fast or slow it&#xA;will run &lt;em&gt;in the future&lt;/em&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is the promised link: &lt;a href=&quot;http://jorisvr.nl/article/arduino-frequency&quot; rel=&quot;nofollow noreferrer&quot;&gt;Arduino clock frequency&#xA;accuracy&lt;/a&gt;, by Joris van Rantwijk.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;What Joris did is measure the accuracy and stability of an Arduino Pro&#xA;Mini (clocked off a ceramic resonator) and an old Duemilianove (quartz&#xA;crystal). From my perspective, the main takeaways are:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;both clocks are &lt;em&gt;grossly&lt;/em&gt; inaccurate, thus both would need user&#xA;calibration in order to be used as timepieces&lt;/li&gt;&#xA;&lt;li&gt;the quartz crystal of the Duemilianove has decent stability, better&#xA;than 1.5e-8 at 6 h averaging time&lt;/li&gt;&#xA;&lt;li&gt;the stability of the Pro Mini’s ceramic resonator is pathetic, more&#xA;than &lt;em&gt;two orders of magnitude&lt;/em&gt; worse than the crystal, which makes it&#xA;essentially useless as a time piece&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;Here is his &lt;a href=&quot;https://en.wikipedia.org/wiki/Allan_variance&quot; rel=&quot;nofollow noreferrer&quot;&gt;Allan deviation&lt;/a&gt; plot, which measures clock instability&#xA;as a function of observation time:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/Cy5Le.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/Cy5Le.png&quot; alt=&quot;Allan deviation of Arduino Clock Frequency&quot;&gt;&lt;/a&gt;&lt;br&gt;&#xA;&lt;sub&gt;(source: &lt;a href=&quot;http://jorisvr.nl/images/arduinofreq/allandev_small.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;jorisvr.nl&lt;/a&gt;)&lt;/sub&gt;  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this study has some limitations (only two boards were tested,&#xA;and the observation time is too short), it is well thought and very&#xA;informative. I encourage you to read it in whole.&lt;/p&gt;&#xA;" OwnerUserId="7508" LastEditorUserId="27346" LastEditDate="2019-03-12T18:04:29.223" LastActivityDate="2019-03-12T18:04:29.223" CommentCount="1" ContentLicense="CC BY-SA 4.0" />
  <row Id="28968" PostTypeId="1" CreationDate="2016-09-02T17:32:35.597" Score="0" ViewCount="4642" Body="&lt;p&gt;I'm trying to install a bootloader on my ATmega328P-PU. I'm trying to install it from Arduino Uno (not original). I can install all sketches. After I click &quot;Burn bootloader&quot; I get the following error:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;Arduino:1.6.11 (Windows 10), Board:&quot;Arduino/Genuino Uno&quot;&#xA;&#xA;avrdude: Yikes!  Invalid device signature.&#xA;avrdude: Expected signature for ATmega328P is 1E 95 0F&#xA; ***failed;  &#xA;avrdude: verification error, first mismatch at byte 0x0000&#xA;         0x00 != 0x3f&#xA;avrdude: verification error; content mismatch&#xA;Error while burning bootloader.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;How to fix it?&lt;/p&gt;&#xA;" OwnerUserId="26310" LastEditorUserId="972" LastEditDate="2016-09-03T06:45:46.337" LastActivityDate="2016-09-04T20:50:11.787" Title="Error while installing bootloader ATmega328" Tags="|arduino-uno|atmega328|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28969" PostTypeId="1" CreationDate="2016-09-02T18:06:59.423" Score="0" ViewCount="175" Body="&lt;p&gt;Is there a way to route an analog signal from a simple temperature sensor through an ADC, MCP3008, into a digital pin. I have used all the analog pins on my Arduino  Mega 2560 and am trying to utilize all the digital I/Os. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any insights on the matter would be greatly appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26311" LastActivityDate="2016-09-02T18:09:57.593" Title="Trying to read analog signal with digital pin using outside ADC" Tags="|arduino-mega|signal-processing|digital-analog-conversion|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28970" PostTypeId="2" ParentId="28969" CreationDate="2016-09-02T18:09:57.593" Score="1" Body="&lt;p&gt;The MCP3008 is an SPI device. You connect it to the SPI pins of your Arduino. Then you can read 8 analog channels through it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It requires 4 pins: MISO, MOSI, SCK and a chip select pin.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-09-02T18:09:57.593" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28971" PostTypeId="1" AcceptedAnswerId="28984" CreationDate="2016-09-02T19:49:52.027" Score="1" ViewCount="764" Body="&lt;p&gt;I have a few Arduino boards connected to my computer running firmata and I want the computer to be able to differentiate between them even when I unplug them and plug them back into a different USB port in a different sequence. My solution was to save and read a Unique I.D. into each Arduino's EEPROM, but I am not sure how to accomplish this using firmata?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I want to save a few bits of data to the Arduino UNO with EEPROM, but the Arduino has to be running code compatible with firmata. Is this possible?&lt;/p&gt;&#xA;" OwnerUserId="26312" LastActivityDate="2016-09-03T22:12:51.293" Title="Can you save data to EEPROM using firmata?" Tags="|eeprom|firmata|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="28972" PostTypeId="1" CreationDate="2016-09-02T20:21:34.400" Score="2" ViewCount="803" Body="&lt;p&gt;I have a quick question to ask.&#xA;I have an Arduino Uno reading 4 temperature sensors (LM35) in 4 different rooms. What happens is that the two nearest rooms give stable values, while the two further ones give very unstable measurements (the temperature keeps floating +-30C around the real values.)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I have connected all the sensors with Ethernet cables with the longest one being about 8-10m.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Is this problem due to noise picked up along the line? There are no strong electromagnetic sources along the way.&#xA;I have also measured the voltage values on Arduino end with a multimeter: the values are all stable (and correct) and do not reflect the behaviour detected by Arduino.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also, I have tried to substitute the LM35 in the farthest room with a photoresistor (the one in the starter kit) and this time the values read by Arduino are perfectly stable. I know that the LM35 works because I have tested it on a breadboard.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can someone give my some help? Any idea is greatly appreciated.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit: I am adding a sketch, although it is a very basic setup:&#xA;The only difference with the real layout is that there is also a Ethernet shield.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;img src=&quot;https://i.stack.imgur.com/ITwcg.jpg&quot; alt=&quot;circuit schematics&quot;&gt;&lt;/p&gt;&#xA;" OwnerUserId="26313" LastEditorUserId="27346" LastEditDate="2019-01-07T08:24:34.140" LastActivityDate="2019-01-07T08:24:34.140" Title="Trouble reading LM35 with long (?) Ethernet connection" Tags="|arduino-uno|ethernet|temperature-sensor|" AnswerCount="2" CommentCount="6" ContentLicense="CC BY-SA 4.0" />
  <row Id="28973" PostTypeId="2" ParentId="28968" CreationDate="2016-09-02T21:34:13.690" Score="1" Body="&lt;p&gt;EDIT: First ensure that you have made the hardware correctly (see comment below this post). &lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need different settings for custom avr hardware the following will help:-&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The best way to create a custom board definition is to create your own &lt;code&gt;boards.txt&lt;/code&gt; entry in the Arduino custom hardware folder.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;But less effort to learn is to try to temporarily change or add to the Arduino IDE &lt;code&gt;avr&lt;/code&gt; board definitions.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The board definition (properties) are passed to the tool that burns the bootloader. All board specific properties are provided by the &lt;code&gt;boards.txt&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Edit the &lt;code&gt;[ArduinoIDE\Hardware\hardware\arduino\avr\boards.txt&lt;/code&gt; with a text editor and find the Uno section. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;It looks like this. Notice the &lt;code&gt;mcu&lt;/code&gt;, &lt;code&gt;vid&lt;/code&gt;, &lt;code&gt;pid&lt;/code&gt; and &lt;code&gt;uno.bootloader.file=&lt;/code&gt; settings in particular. The bootloader points to a file in &lt;code&gt;[ArduinoIDE\Hardware\hardware\arduino\avr&lt;/code&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno.name=Arduino/Genuino Uno&#xA;&#xA;uno.vid.0=0x2341&#xA;uno.pid.0=0x0043&#xA;uno.vid.1=0x2341&#xA;uno.pid.1=0x0001&#xA;uno.vid.2=0x2A03&#xA;uno.pid.2=0x0043&#xA;uno.vid.3=0x2341&#xA;uno.pid.3=0x0243&#xA;&#xA;uno.upload.tool=avrdude&#xA;uno.upload.protocol=arduino&#xA;uno.upload.maximum_size=32256&#xA;uno.upload.maximum_data_size=2048&#xA;uno.upload.speed=115200&#xA;&#xA;uno.bootloader.tool=avrdude&#xA;uno.bootloader.low_fuses=0xFF&#xA;uno.bootloader.high_fuses=0xDE&#xA;uno.bootloader.extended_fuses=0x05&#xA;uno.bootloader.unlock_bits=0x3F&#xA;uno.bootloader.lock_bits=0x0F&#xA;uno.bootloader.file=optiboot/optiboot_atmega328.hex&#xA;&#xA;uno.build.mcu=atmega328p&#xA;uno.build.f_cpu=16000000L&#xA;uno.build.board=AVR_UNO&#xA;uno.build.core=arduino&#xA;uno.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;You can add a new entry like this. The example uses a board prefix of &lt;code&gt;uno2.&lt;/code&gt; but it can be any simple unique name. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Save the changes to &lt;code&gt;boards.txt&lt;/code&gt; then restart the Ide:- &lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;uno2.name=Arduino ATmega328P-PU&#xA;&#xA;uno2.vid.0=0x2341&#xA;uno2.pid.0=0x0043&#xA;uno2.vid.1=0x2341&#xA;uno2.pid.1=0x0001&#xA;uno2.vid.2=0x2A03&#xA;uno2.pid.2=0x0043&#xA;uno2.vid.3=0x2341&#xA;uno2.pid.3=0x0243&#xA;&#xA;uno2.upload.tool=avrdude&#xA;uno2.upload.protocol=arduino&#xA;uno2.upload.maximum_size=32256&#xA;uno2.upload.maximum_data_size=2048&#xA;uno2.upload.speed=115200&#xA;&#xA;uno2.bootloader.tool=avrdude&#xA;uno2.bootloader.low_fuses=0xFF&#xA;uno2.bootloader.high_fuses=0xDE&#xA;uno2.bootloader.extended_fuses=0x05&#xA;uno2.bootloader.unlock_bits=0x3F&#xA;uno2.bootloader.lock_bits=0x0F&#xA;uno2.bootloader.file=optiboot/optiboot_atmega328.hex&#xA;&#xA;uno2.build.mcu=atmega328p&#xA;uno2.build.f_cpu=16000000L&#xA;uno2.build.board=AVR_UNO&#xA;uno2.build.core=arduino&#xA;uno2.build.variant=standard&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;note: make a copy of the .txt or grab a new one from the zip on arduino.cc if you mess it up.&lt;/p&gt;&#xA;" OwnerUserId="4169" LastEditorUserId="4169" LastEditDate="2016-09-04T20:50:11.787" LastActivityDate="2016-09-04T20:50:11.787" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28974" PostTypeId="1" CreationDate="2016-09-02T21:44:26.237" Score="1" ViewCount="119" Body="&lt;p&gt;Is there a simple way to rig two balls in a way that lets you know if they are touching?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example, here's a bad idea. Put a free-to-move magnet inside of each ball. When the balls get close, the magnets snap together. Use a magnetic sensor within each ball to tell the direction of the magnet. Use an accelerometer to tell the direction of gravity. When the gravity direction differs from the magnet direction, the balls are touching.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I don't need to know the direction of the contact (that would be ideal, but I don't &lt;em&gt;need&lt;/em&gt; it). It should work over the whole surface. I would like to have more than two balls and be able to tell &lt;em&gt;which&lt;/em&gt; two are touching. I can make the balls however I want.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;(Even very basic advice would be quite helpful. I'm not familiar at all with hardware projects or what kinds of sensors are available or how to combine the available pieces into some desired thing. That includes advice like &quot;this is probably too hard&quot;.)&lt;/p&gt;&#xA;" OwnerUserId="26315" LastActivityDate="2016-09-03T18:50:46.697" Title="Detecting mutual contact between balls" Tags="|sensors|" AnswerCount="1" CommentCount="6" ContentLicense="CC BY-SA 3.0" />
  <row Id="28975" PostTypeId="2" ParentId="28932" CreationDate="2016-09-02T22:07:49.723" Score="2" Body="&lt;p&gt;&lt;em&gt;&quot;...Please any help? Do I have to assume that my shield is faulty?...&quot;&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Before trashing the shield, I'd run through a sligtly more comprehensive troubleshooting approach, from the lowest level of the network stack (the physical layer) up to the ICMP/IP layer. Let me expand over this process:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Physical layer&lt;/strong&gt;: I bet your router has some LEDs whose purpose is to show &lt;em&gt;IF&lt;/em&gt; some ethernet device is connected to related physical router port... or not. So, as a very first step, supposing you connect your ethernet shield to PORT-1 of your router, you should check that once you connect the cable and turn on the Arduino.... the &quot;port 1&quot; LED on the router should turn on.&#xA;If it turns on... let's proceed to next step. Otherwise... let's launch a different question (or expand accordingly your OP);&lt;/p&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ethernet layer&lt;/strong&gt;: once the LED is on, we can be sure that the physical layer is OK. So let's go up at Ethernet layer. In order to communicate on an Ethernet network, every device need to have a MAC address. Also, even if not strictly necessarily, we can bet that every ethernet device (including your shield) implement the &lt;a href=&quot;https://en.wikipedia.org/wiki/Address_Resolution_Protocol&quot; rel=&quot;nofollow&quot;&gt;ARP resolution protocol&lt;/a&gt;. This is needed in order, for other ethernet devices, to obtain the MAC address of your shield, in order to include such a MAC address in all the ethernet datagrams to be sent over the network (to communicate with your shield).&#xA;So, if you configured your shield with MAC &lt;code&gt;DE:AD:BE:EF:FE:ED&lt;/code&gt; and IP &lt;code&gt;192.168.1.6&lt;/code&gt; I would:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;connect my Linux box to your router (&lt;em&gt;BTW: sorry! I can't help with other operating systems, as I switched to a linux-only notebook lots of years ago!&lt;/em&gt;);&lt;/li&gt;&#xA;&lt;li&gt;configure my Linux ethernet interface (&lt;code&gt;eth0&lt;/code&gt;) with an IP like &lt;code&gt;192.168.1.99&lt;/code&gt;;&lt;/li&gt;&#xA;&lt;li&gt;run an &lt;code&gt;arping -I eth0 192.168.1.6&lt;/code&gt; (where &lt;code&gt;arping&lt;/code&gt; is &lt;a href=&quot;https://en.wikipedia.org/wiki/Arping&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; tool)&lt;/li&gt;&#xA;&lt;/ol&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;If everything is working correctly, you should receive something like:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;root@iMac-Chiara:~# arping -I eth0 10.20.20.2&#xA;ARPING 10.20.20.2 from 10.20.20.1 eth0&#xA;Unicast reply from 10.20.20.2 [A4:BA:DB:98:FC:A4]  0.736ms&#xA;Unicast reply from 10.20.20.2 [A4:BA:DB:98:FC:A4]  0.729ms&#xA;Unicast reply from 10.20.20.2 [A4:BA:DB:98:FC:A4]  0.720ms&#xA;[...]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;where you see that my notebook (10.20.20.1) is getting ARP-replyies from 10.20.20.2, who has the &lt;code&gt;A4:BA:DB:98:FC:A4&lt;/code&gt; MAC address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you don't see replyies... we have an Ethernet problem (but not a physical one) and... chances are high that you have a faulty shield (BTW: the message &quot;Host unreachable&quot; you mentioned in your OP, let me think that this is your problem);&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Viceversa, if you obtain replyies, than the Ethernet level is OK and problems are located on upper layers. Let's focus on this last particular case&lt;/p&gt;&#xA;&#xA;&lt;ol start=&quot;3&quot;&gt;&#xA;&lt;li&gt;&lt;strong&gt;IP layer&lt;/strong&gt;: once the physical layer and the ethernet layer are OK, you should be able to properly PING your target (I'm excluding the case where you have some firewall that, somewhere along the path from the two hosts, could &quot;cut&quot; some traffic. I'm also supposing that IP addresses and netmask are properly configured [from an IP point of view]). I'm not getting deeper with such a case, as you should be already familiar with PING (BTW: from your POST, it's not clear from &lt;em&gt;where&lt;/em&gt; you were PINGing your Arduino. Directly from the &quot;router&quot;? or from you PC?)&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Having said all the above, let me conclude by saying that several further checks could be putted in place but... it's much better to previously run above checks :-)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Hope this help!&lt;/p&gt;&#xA;" OwnerUserId="13193" LastActivityDate="2016-09-02T22:07:49.723" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28978" PostTypeId="2" ParentId="28540" CreationDate="2016-09-03T07:01:53.637" Score="12" Body="&lt;p&gt;OK. So, I tried the SDFat lib. This library is definitely better than the default SD library that comes with adruino.&#xA;But that is not how I solved my problem of low data-rate.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I followed the instruction of the author of SDFat library from &lt;a href=&quot;http://forum.arduino.cc/index.php?topic=49649.msg354701#msg354701&quot; rel=&quot;noreferrer&quot;&gt;&lt;strong&gt;&lt;em&gt;this post&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;According to &lt;em&gt;fat16lib&lt;/em&gt;, to increase the data rate we need to use flush() wisely. We would want to write() the data in each cycle, but we only need to flush() once every 100 cycles or so depending on how much data is being written in each cycle. Also, be sure to keep the flag in SD.open() as 'O_WRITE | O_CREAT' instead of 'FILE_WRITE'.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This sure increased the speed by a great factor. But I needed more!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Storing the data in binary (&lt;a href=&quot;https://hackingmajenkoblog.wordpress.com/2016/03/25/fast-efficient-data-storage-on-an-arduino/&quot; rel=&quot;noreferrer&quot;&gt;check out this blog&lt;/a&gt;) improved the performance even more.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My current speed is approximately 100-120 KBps (that's kilo bytes) with a class 4 SD card!&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Finally, I want to thank you guys for your help.&lt;/p&gt;&#xA;" OwnerUserId="25931" LastActivityDate="2016-09-03T07:01:53.637" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28983" PostTypeId="1" CreationDate="2016-09-03T14:27:49.717" Score="0" ViewCount="1802" Body="&lt;p&gt;I am using CS5211AGP wireless RF transmitter to transmit some data and another side receive this data through nRf905 as receiver. But now problem is how can I decode RF transmitter address (because transmitter and receiver address must be same).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;if any one working on this module then please suggest me how can I decode address.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Please show below image where you can see the connection of address and zone.&lt;a href=&quot;https://i.stack.imgur.com/zEROM.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/zEROM.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/7Lp7f.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/7Lp7f.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Now please say about what address should I set at receiver side for communication.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Thanks in advance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Regards,&#xA;rajneesh&lt;/p&gt;&#xA;" OwnerUserId="26277" LastActivityDate="2017-01-09T21:04:29.190" Title="CS5211AGP wireless RF transmitter (433MHZ) address decoding problem" Tags="|wireless|" AnswerCount="1" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28984" PostTypeId="2" ParentId="28971" CreationDate="2016-09-03T15:46:09.167" Score="2" Body="&lt;p&gt;You have to edit the Firmata source code and add a few lines of code:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;add the EEPROM library&lt;/li&gt;&#xA;&lt;li&gt;include the library into the Firmata code&lt;/li&gt;&#xA;&lt;li&gt;in the setup() function use the EEPROM library to read the id from the EEPROM&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;How do you plan to write that data into your Arduino EEPROM?&#xA;If you want to do that via serial connection than you also need to add that code.&#xA;I have done something similar in an example for my &lt;a href=&quot;https://github.com/rlogiacco/VoltageReference&quot; rel=&quot;nofollow&quot;&gt;VoltageReference&lt;/a&gt; library, specifically in &lt;a href=&quot;https://github.com/rlogiacco/VoltageReference/blob/master/examples/EEPROMCalibration/EEPROMCalibration.ino&quot; rel=&quot;nofollow&quot;&gt;EEPROMCalibration.ino&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;After a little investigation I understand there is the possibility to exchange generic messages and handle generic commands via Firmata: commands 0x00-0x0F are reserved for customization. On the Arduino side you can use:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;void storeToEEPROM(int id) {&#xA;  ...&#xA;}&#xA;&#xA;void readFromEEPROM() {&#xA;  char buf[12];&#xA;  Firmata.sendString(itoa(the_id, buf, 10));&#xA;}&#xA;&#xA;void setup() {&#xA;  ...&#xA;  Firmata.attach(0x00, storeToEEPROM);&#xA;  Firmata.attach(0x01, readFromEEPROM);&#xA;  ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That will allow you to write and read the id using those two custom commands.&lt;/p&gt;&#xA;" OwnerUserId="19867" LastEditorUserId="19867" LastEditDate="2016-09-03T22:12:51.293" LastActivityDate="2016-09-03T22:12:51.293" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28985" PostTypeId="2" ParentId="11846" CreationDate="2016-09-03T15:55:06.703" Score="0" Body="&lt;blockquote&gt;&#xA;  &lt;p&gt;how long will that value &quot;stick&quot; to that address before being lost?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The Atmega328 data retention is guaranteed by Atmel (the manufacturer) for 20 years at 85 degrees Celsius, 100 years at 25 degrees Celsius. Beware cheap Chinese clones usually use counterfeits chips, meaning those values are not going to be guaranteed any more&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;If I were to power down the Arduino, flash a whole new program to it, and power it on, could I still retrieve that old/cached value written from the previous program?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;While @ignacio answer is more detailed I believe you are interested in plain Arduino IDE programming along with standard Arduino boards, in which case the answer is &lt;strong&gt;yes&lt;/strong&gt;, the data is not going to be erased.&lt;/p&gt;&#xA;" OwnerUserId="19867" LastActivityDate="2016-09-03T15:55:06.703" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28986" PostTypeId="2" ParentId="24084" CreationDate="2016-09-03T17:11:19.580" Score="1" Body="&lt;p&gt;The fix for this issue was to reload the bootloader.  I used the &lt;a href=&quot;https://github.com/sparkfun/Arduino_Boards/tree/master/sparkfun/avr/bootloaders/caterina&quot; rel=&quot;nofollow&quot;&gt;SparkFun Caterina bootloader&lt;/a&gt;.  &lt;/p&gt;&#xA;" OwnerUserId="20954" LastActivityDate="2016-09-03T17:11:19.580" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28987" PostTypeId="2" ParentId="28974" CreationDate="2016-09-03T18:50:46.697" Score="2" Body="&#xA;&#xA;&lt;h3&gt;Option 1&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;Seems you say you can make the balls out of whatever you want, I would suggest the spheres be made of a metal and then you can either suspend them by wire spot welded or soldered onto the balls. Then what you do is you connect all the balls to inputs of an Arduino ( this is if you are doing this with one). Then connect all inputs to pull-up resistors. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then to read if a ball is touching a neighbour you start with ball &lt;code&gt;n&lt;/code&gt; and set it as an &lt;code&gt;output&lt;/code&gt; and use &lt;code&gt;digitalWrite(n,LOW);&lt;/code&gt;  and then poll all the other balls as inputs to see which one reads &lt;code&gt;LOW/0V&lt;/code&gt; and then record that in an array, you the move onto ball &lt;code&gt;n+1&lt;/code&gt; and scan the rest of the balls. There is also no need to read the previous ball to &lt;code&gt;n+1&lt;/code&gt; as if it did not register a touch, then it won't register with the next ball. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Then at the end you reset everything and start at the beginning again. Using the data how you wish at the end. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;Below code is just to show, not tested. &lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;for(int n =0; n &amp;lt; total_N; n++){&#xA;      pinMode(n, OUTPUT);&#xA;&#xA;  for(int i = 0; i &amp;lt; total_inputs; i++){&#xA;          if(!(digitalRead(n)))// ball is touching&#xA;   {&#xA;&#xA;         myArray[i] = 1;// store a point in the list, replace with a way you want&#xA;    }&#xA;    else myArray[i] = 0;&#xA;}&#xA;     pinMode(n, INPUT);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;h3&gt;Option 2&lt;/h3&gt; &lt;em&gt;(probably to much to go wrong)&lt;/em&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You could use material that will allow IR rays to pass through and make you balls with that. Then in each ball is have a IR transmitter and a IR receiver, making a transceiver basically and then have each ball echo a specific ID and let the other balls pick it up. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;To solve the issue that IR travels a good distance you will need to limit the power/voltage/current to the IR transmitter(LED) so that they only work within a certain range. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Option 3&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;You could place reed switches or hall effect sensors in each ball, with a magnet. Place a niece of metal behind the sensor so that the magnet is drawn to it. The only issue with this is that either the magnet in each ball will not only affect its neighbour but also itself. So they will need to be spaced and also the right strength of magnet. &lt;/p&gt;&#xA;&#xA;&lt;h3&gt;Option 4&lt;/h3&gt;&#xA;&#xA;&lt;p&gt;A combination of option 2 and 3 would be to surround a IR receiver setup with a piece of metal disk(like a washer) and also a reed switch or hall effect sensor, and then have a ball with a magnet and a IR transmitter by a magnet, so that when the two are pulled together the transmitter and receiver match up in the same view and are able to tell them that they are connected, you would thus have each ball with a set, one to receive placed on one side and another on the opposite side to transmit. &lt;/p&gt;&#xA;" OwnerUserId="2944" LastActivityDate="2016-09-03T18:50:46.697" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28988" PostTypeId="1" AcceptedAnswerId="29003" CreationDate="2016-09-03T20:23:34.403" Score="1" ViewCount="829" Body="&lt;p&gt;I have this MQ-2 gas sensor for an Arduino Uno:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/WrBcL.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/WrBcL.jpg&quot; alt=&quot;MQ-2 sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/IzJCU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/IzJCU.jpg&quot; alt=&quot;MQ-2 sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/9gwPi.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/9gwPi.jpg&quot; alt=&quot;MQ-2 sensor&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I found these two articles about how to use it:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;http://www.instructables.com/id/Ardunio-Smoke-And-Gas-SensorMQ-2/?ALLSTEPS&quot; rel=&quot;nofollow noreferrer&quot;&gt;http://www.instructables.com/id/Ardunio-Smoke-And-Gas-SensorMQ-2/?ALLSTEPS&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;But I need to know if the sensor is analog or digital.&#xA;Also I would like to know what is the blue switch for.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This questions help me a bit:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;It says that he use an analog sensor. But as this sensor is not mine I don't want to brake it or burn it.&lt;/p&gt;&#xA;" OwnerUserId="26074" LastActivityDate="2016-09-04T09:28:24.830" Title="Is my MQ-2 gas sensor analog or digital?" Tags="|arduino-uno|sensors|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28990" PostTypeId="2" ParentId="28972" CreationDate="2016-09-03T22:43:04.220" Score="0" Body="&lt;p&gt;&lt;strong&gt;Short answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Add &lt;code&gt;delay&lt;/code&gt; between each reading, 100ms should be enough.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;Long answer&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The LM35 is an analog device and you are using the internal ATmega328 ADC to read the voltage on the signal pin.&#xA;The way the Arduino ADC works is a sample-and-hold process:&lt;/p&gt;&#xA;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;open a circuit to an internal capacitor&lt;/li&gt;&#xA;&lt;li&gt;charge the capacitor&lt;/li&gt;&#xA;&lt;li&gt;disconnect the circuit&lt;/li&gt;&#xA;&lt;li&gt;compare capacitor to the reference voltage&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&#xA;&lt;p&gt;Because there is only one of such circuits shared among all the 6 analog pins you need to let the capacitor charge up, which is much slower on long lines having a non negligible resistance and also a non negligible capacitance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Also other wires and power lines near to your ethernet cable are going to influence your readings, but in that case the ethernet cable shielding is going to help you, &lt;a href=&quot;https://en.wikipedia.org/wiki/Shielded_cable&quot; rel=&quot;nofollow&quot;&gt;if properly used&lt;/a&gt;.&lt;/p&gt;&#xA;" OwnerUserId="19867" LastActivityDate="2016-09-03T22:43:04.220" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28991" PostTypeId="1" AcceptedAnswerId="28992" CreationDate="2016-09-03T23:17:40.923" Score="0" ViewCount="51" Body="&lt;p&gt;I have a &lt;code&gt;Channel&lt;/code&gt; class which on instantiation receives a &lt;code&gt;_type&lt;/code&gt; via &lt;code&gt;new Channel(&quot;type&quot;, ...)&lt;/code&gt;. I can read the type back out via &lt;code&gt;channelObject-&amp;gt;getType()&lt;/code&gt; which returns a string.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This has always worked fine until today. I have no idea what changed but if I &lt;code&gt;Serial.print(channelObject-&amp;gt;getType())&lt;/code&gt; I get a nasty amount of garbage in the terminal:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;���QQ���� 00@��������'����������������������(�����������b���������������������������������������H���E���������������������������������������������������������������uD��DESC  initializedOoops, no LSM303 detected ... Check your wiring!Ooops, no BMP180 detected ... Check your wiring!Setting IMU ground: Setting front: !! set ground kalman initConnect Powerbooting up...SWATBOT SETUP COMPLETEtype_xelevatoraileronthrottlerudderaux1aux2serial in: DISARMED!E;1  &#xA;B��LSM303(&amp;gt;.a+a+8L.�S2E/��BMP085.qL3GD20���T �4&amp;amp;�'�%�%�%&amp;amp;&#xA;naninfovf�!,�!H�!��!��!Њ!�D�s6/&amp;amp;������?)m((a&amp;amp;l1=#k2���_&#xA;X� +�����+����=� ��J�5�.d�6s'���z :����������-/�type_xtype_x    elevatoraileron    throttlerudderaux1aux2�F�OX4Vjx 7���2�?�xr����:~aileronaux1&#xA;�:~  elevator&#xA; ~ throttle:):~rudder������=�@��&amp;gt;�̀?��=�=�@��&amp;gt;�����=�=�@��&amp;gt;�f�B��=�i�?�k��BMP085QF��D�C&#xA;�#&amp;lt;}D������D]v� ,B����^v�QF����P}D .?P���f�B.s�D2m .?�oIB��P��(=:@���A�A�@9�@ A@�@�?�A0SB0N�&amp;gt;dC9�@ A@�@�?�A ��A��dC��L?��L&amp;gt;s����C�B(��&quot;�  (�  �&quot;��&#xA;(�&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&quot;elevator&quot;, &quot;aileron&quot;, &quot;throttle&quot;, and &quot;rudder&quot; are types for objects that I know exist but why is it coming out like this? I'm also seeing other unrelated parts of my program being spit out too like &quot;Ooops, no LSM303 detected ...&quot;. This is all so strange.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If I had to guess, there must be an awry pointer somewhere in my application but I'm having no luck finding it. Worst case I'll rollback my application and retrace my last implementations (a couple days worth of work).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone give me a clue as to what is going on here?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;My broken application is online at: &lt;a href=&quot;https://github.com/jacksonkr/SwatBotSpine/tree/master&quot; rel=&quot;nofollow&quot;&gt;https://github.com/jacksonkr/SwatBotSpine/tree/master&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Emphasis on &lt;a href=&quot;https://github.com/jacksonkr/SwatBotSpine/blob/master/Channel.h&quot; rel=&quot;nofollow&quot;&gt;Channel.h&lt;/a&gt;:68 which is where all the garbage is coming from.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Related code:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/jacksonkr/SwatBotSpine/blob/master/RemoteControl.h&quot; rel=&quot;nofollow&quot;&gt;RemoteControl.h&lt;/a&gt;:37&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&quot;https://github.com/jacksonkr/SwatBotSpine/blob/master/RemoteControl.h&quot; rel=&quot;nofollow&quot;&gt;RemoteControl&lt;/a&gt;::getChannel&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-09-03T23:59:40.480" Title="Why are my objects losing their member's values?" Tags="|arduino-uno|serial|c++|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28992" PostTypeId="2" ParentId="28991" CreationDate="2016-09-03T23:59:40.480" Score="1" Body="&lt;p&gt;You might be running out of RAM. I suggest you change all lines like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Serial.println(&quot;SWATBOT SETUP COMPLETE&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;to use the &lt;code&gt;F&lt;/code&gt; macro like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt; Serial.println(F(&quot;SWATBOT SETUP COMPLETE&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;There seem to be a &lt;em&gt;lot&lt;/em&gt; of places you could change.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Also I would not put code (implementation) into the .h files. That belongs in .cpp files. The .h files are for declarations.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;Inside a class function, using &lt;code&gt;this-&amp;gt;&lt;/code&gt; all the time just makes things look cluttered, eg.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;StabilityController::StabilityController(RemoteControl* rc, ROSController* ros, IMUController *imu) {&#xA;  this-&amp;gt;_rc = rc;&#xA;  this-&amp;gt;_ros = ros;&#xA;  this-&amp;gt;_imu = imu;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="10794" LastActivityDate="2016-09-03T23:59:40.480" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="28994" PostTypeId="1" CreationDate="2016-09-04T01:49:54.983" Score="5" ViewCount="3533" Body="&lt;p&gt;I have lots of &lt;code&gt;Serial.print()&lt;/code&gt; and &lt;code&gt;Serial.println()&lt;/code&gt; statements throughout my (rather large) program for debugging when things fail. I've commented out the &lt;code&gt;Serial.begin()&lt;/code&gt; statement so I don't slow down execution by running a serial port. However, I'd like to leave the &lt;code&gt;Serial.print()&lt;/code&gt; calls so I only have to uncomment &lt;code&gt;Serial.begin()&lt;/code&gt; later on.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If there is no Serial port active on the device, are the &lt;code&gt;Serial.print()&lt;/code&gt; lines still executed at runtime, or does the compiler ignore them? Is there any performance advantage to explicitly commenting out those lines?&lt;/p&gt;&#xA;" OwnerUserId="11254" LastEditorDisplayName="user24204" LastEditDate="2016-09-04T07:40:36.070" LastActivityDate="2016-09-05T07:38:06.827" Title="Will unnecessary Serial.print() statements slow down my program?" Tags="|serial|performance|" AnswerCount="3" CommentCount="2" ContentLicense="CC BY-SA 3.0" />
  <row Id="28998" PostTypeId="2" ParentId="28994" CreationDate="2016-09-04T06:01:22.473" Score="5" Body="&lt;p&gt;No, there is no &lt;code&gt;USART&lt;/code&gt; wasn't enabled so skip all &lt;code&gt;print&lt;/code&gt;s. Everything must be done anyways (calls, conversions to strings, writes to &lt;code&gt;UDR&lt;/code&gt; - &lt;code&gt;USART Data Register&lt;/code&gt;). It is just not sent outside by &lt;code&gt;USART&lt;/code&gt; and it doesn't have to wait for &lt;code&gt;UDRE&lt;/code&gt; (&lt;code&gt;USART Data Register Empty&lt;/code&gt; flag) so it might be slightly faster.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;You can use similar technique as Loggers - log level variable and &lt;code&gt;if&lt;/code&gt;s (this can be changed runtime).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Or you can use macros:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;// comment out this line, if you want to show logs:&#xA;#define NDEBUG&#xA;&#xA;#ifdef NDEBUG&#xA;  #define LOG(...)&#xA;  #define LOGLN(...)&#xA;#else&#xA;  #define LOG(...) Serial.print(__VA_ARGS__)&#xA;  #define LOGLN(...) Serial.println(__VA_ARGS__)&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And later:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;LOG(F(&quot;Something: 0x&quot;));&#xA;LOGLN(variable, HEX);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And how it looks after macro substitution? For code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (...) LOG(F(&quot;something&quot;)); else LOG(F(&quot;something else&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;With NDEBUG defined it's expanded to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (...) ; else ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And without NDEBUG defined it's expanded to:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;if (...) Serial.print(F(&quot;something&quot;)); else Serial.print(F(&quot;something else&quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-09-04T13:32:29.773" LastActivityDate="2016-09-04T13:32:29.773" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="28999" PostTypeId="2" ParentId="28994" CreationDate="2016-09-04T07:22:59.880" Score="1" Body="&lt;p&gt;The compiler cannot know what the situation with the device is at runtime. The function itself must determine that, so the call &lt;em&gt;will&lt;/em&gt; take place, with arguments and everything. A well-written function would test early on whether there was anything to do, and if not then return early - but that still wastes time.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;The norm in programming is to have two versions of the code: one labelled &quot;DEBUG&quot;, which has lots of &lt;code&gt;print()&lt;/code&gt;s, and one labelled &quot;RELEASE&quot;, which uses language contructs to ignore them. This is achieved a number of different ways - but Arduino doesn't really support this out of the box.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;@KIIV's answer, using &lt;code&gt;#define&lt;/code&gt;, is one way to do this. The problem with it comes when you have multiple modules, or are using libraries that themselves do their own &lt;code&gt;print()&lt;/code&gt;s. If you only have your main sketch, then it would work fairly well.&lt;/p&gt;&#xA;" OwnerUserId="22924" LastActivityDate="2016-09-04T07:22:59.880" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29000" PostTypeId="2" ParentId="28994" CreationDate="2016-09-04T07:54:53.157" Score="1" Body="&lt;p&gt;A quick test shows that not doing a Serial.begin makes things run 10 times as fast. For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;void setup ()&#xA;  {&#xA;  Serial.begin (115200);&#xA;  pinMode (13, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  digitalWrite (13, HIGH);&#xA;  for (byte i = 0; i &amp;lt; 100; i++)&#xA;    Serial.println (&quot;But does it get goat's blood out?&quot;);&#xA;  digitalWrite (13, LOW);&#xA;  delay (500);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That took 292 ms to do 100 x of those prints on my Uno. If I comment out the Serial.begin call it takes 29 ms. So, faster but not incredibly fast. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;On &lt;a href=&quot;http://www.gammon.com.au/forum/?id=11329&quot; rel=&quot;nofollow noreferrer&quot;&gt;my page about debugging&lt;/a&gt; I have suggested code to turn on or off debugging prints. The basic idea is to have a Trace define that lets you output stuff if debugging is on, like this:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#define DEBUG false&#xA;&#xA;// conditional debugging&#xA;#if DEBUG &#xA;&#xA;  #define beginDebug()  do { Serial.begin (115200); } while (0)&#xA;  #define Trace(x)      Serial.print   (x)&#xA;  #define Trace2(x,y)   Serial.print   (x,y)&#xA;  #define Traceln(x)    Serial.println (x)&#xA;  #define Traceln2(x,y) Serial.println (x,y)&#xA;  #define TraceFunc()   do { Serial.print (F(&quot;In function: &quot;)); Serial.println (__PRETTY_FUNCTION__); } while (0)&#xA;&#xA;&#xA;#else&#xA;  #define beginDebug()  ((void) 0)&#xA;  #define Trace(x)      ((void) 0)&#xA;  #define Trace2(x,y)   ((void) 0)&#xA;  #define Traceln(x)    ((void) 0)&#xA;  #define Traceln2(x,y) ((void) 0)&#xA;  #define TraceFunc()   ((void) 0)&#xA;#endif // DEBUG&#xA;&#xA;&#xA;void setup ()&#xA;  {&#xA;  beginDebug ();&#xA;  pinMode (13, OUTPUT);&#xA;  }  // end of setup&#xA;&#xA;void loop ()&#xA;  {&#xA;  digitalWrite (13, HIGH);&#xA;  for (byte i = 0; i &amp;lt; 100; i++)&#xA;    Traceln (&quot;But does it get goat's blood out?&quot;);&#xA;  digitalWrite (13, LOW);&#xA;  delay (500);&#xA;  }  // end of loop&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Now in this case, with DEBUG defined as &lt;code&gt;false&lt;/code&gt;, the time taken with pin 13 high is now only 5 µs - a substantial speed-up.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you define DEBUG to be true, then it is much slower - 290 ms as in the first test.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;p&gt;The suggestion made by KIIV will fail if you have &lt;code&gt;if&lt;/code&gt; statements:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;#ifdef NDEBUG&#xA;  #define LOG(...)&#xA;  #define LOGLN(...)&#xA;#else&#xA;  #define LOG(...) Serial.print(__VA_ARGS__);&#xA;  #define LOGLN(...) Serial.println(__VA_ARGS__);&#xA;#endif&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (something)&#xA;   LOG (&quot;something is true&quot;);&#xA;&#xA;digitalWrite (8, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Imagine that debugging is off. Now the empty define makes the code look like:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-c++ prettyprint-override&quot;&gt;&lt;code&gt;if (something)&#xA;  digitalWrite (8, HIGH);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;So you have a side-effect that the code behaves differently if debugging is off.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Semicolon is not part of the macro, so it will be expanded into: &lt;code&gt;if (something) ;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/questions/25021081/what-does-the-c-precompiler-do-with-macros-defined-as-void0&quot;&gt;What does the c precompiler do with macros defined as (void)0&lt;/a&gt; - there are subtle issues with using an empty define compared to void(0).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;  Serial.println (&quot;hi there&quot;), LOGLN (&quot;debugging&quot;);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;That fails to compile (with the empty define) if debugging is off. The &lt;code&gt;void(0)&lt;/code&gt; version does compile. Admittedly it's an edge case, but nevertheless ...&lt;/p&gt;&#xA;" OwnerUserId="10794" LastEditorUserId="-1" LastEditDate="2017-05-23T12:37:43.020" LastActivityDate="2016-09-05T07:38:06.827" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="29001" PostTypeId="1" CreationDate="2016-09-04T08:37:04.690" Score="2" ViewCount="978" Body="&lt;p&gt;I was trying to play with Arduino this weekend and connected a DC motor to &lt;code&gt;A0&lt;/code&gt; and &lt;code&gt;GND&lt;/code&gt; to measure the voltage it provides when I rotate it. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;However,&#xA;when I rotate the DC motor with my fingers to test out the readings I see that when rotated clockwise it generates voltage that can be read in Arduino. But when I rotate it counter-clockwise the values I get are 0 - this is probably because DC motor generates negative voltage (?).&lt;/p&gt;&#xA;&#xA;&lt;p&gt;How do I fix this so that no matter the direction of the turn I get always positive value?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;I am trying to build a simple anemometer, just for fun for kids and plot the values, however can't do much when I get 0 on &lt;code&gt;analogRead&lt;/code&gt; when wind blows from the other direction..&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/1wshU.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/1wshU.jpg&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;thanks for any input into this. &lt;/p&gt;&#xA;" OwnerUserId="17003" LastEditorDisplayName="user24204" LastEditDate="2016-09-04T09:02:00.997" LastActivityDate="2017-01-03T08:09:44.273" Title="analogRead DC Motor - Negative value" Tags="|motor|esp8266|" AnswerCount="2" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="29002" PostTypeId="2" ParentId="29001" CreationDate="2016-09-04T09:06:04.943" Score="1" Body="&lt;p&gt;You can use full wave rectifier, but there is a significant voltage drop on it.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Another way is using Voltage divider to provide &lt;code&gt;1/2 Vcc&lt;/code&gt; to one of the motor terminals. But then you can measure just &lt;code&gt;1/2 Vcc&lt;/code&gt; in both directions (without another Voltage divider)&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Something like:&lt;br&gt;&#xA;&lt;a href=&quot;https://i.stack.imgur.com/5LXBG.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/5LXBG.png&quot; alt=&quot;enter image description here&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;" OwnerUserId="23841" LastEditorUserId="23841" LastEditDate="2016-09-04T09:28:50.683" LastActivityDate="2016-09-04T09:28:50.683" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="29003" PostTypeId="2" ParentId="28988" CreationDate="2016-09-04T09:28:24.830" Score="1" Body="&lt;p&gt;Your sensor is analog. I have the same one. By the way, there is no chip on board, so it cannot form a digital signal ;)&lt;/p&gt;&#xA;" OwnerUserId="26334" LastActivityDate="2016-09-04T09:28:24.830" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29007" PostTypeId="1" AcceptedAnswerId="29017" CreationDate="2016-09-04T13:38:43.193" Score="1" ViewCount="548" Body="&lt;p&gt;I'm building a MIDI guitar, using an Arduino, sound synthesising and wood.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;To properly know which note I'm pressing, I built a voltage divider with 12 equal resistors (10K). One side is connected at +5V and the other end at GND, so each of the 6 strings connects the right tap to the ADC. &#xA;I had just calculated the expected value w/ a bit of math considering I also needed a pullDown resistor(1M) and capacitor for every analog channel to keep the readings stable when no key is pressed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.stack.imgur.com/bZM2i.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.stack.imgur.com/bZM2i.jpg&quot; alt=&quot;circuit&quot;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&#xA;&lt;p&gt;When measuring with my multimeter the readings are stable, and there are variations of less than 0.02V, and since the difference from tap to tap is about 0.4V that's quite good. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The problem is when reading the 6 channels together: channels supposed to be pulled down to gnd read voltages caused by nearby channels, readings are shaky and similar errors.&lt;br&gt;&#xA;This mess disappears on one channel when I connect the multimeter to that one.&#xA;Instead of buying 6 multimeters, I figured I could ask you if someone has an idea on why this happens, my guess is on the pulldown resistor, but I'm not sure about Arduino's ADC; I'm also worried about having 6 wires half of a meter each so close, so any other idea on finding the keys is welcome.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;EDIT&lt;br&gt;&#xA;@EdgarBonet was right, I used 12x220ohm resistors, and at first the results were absolute garbage, then I made it so the code would read each channel about 10 times, discard the readings, wait a millisecond and finally read and store the value. Now it is perfect.&#xA;Thanks again.&lt;/p&gt;&#xA;" OwnerUserId="26341" LastEditorUserId="972" LastEditDate="2016-09-05T21:10:31.477" LastActivityDate="2016-09-06T09:09:31.250" Title="AnalogRead from voltage divider ladder" Tags="|arduino-uno|analogread|adc|" AnswerCount="1" CommentCount="4" ContentLicense="CC BY-SA 3.0" />
  <row Id="29008" PostTypeId="1" CreationDate="2016-09-04T15:10:50.567" Score="4" ViewCount="710" Body="&lt;p&gt;I'm trying to get some binary data from an Arduino Due to Matlab.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Basically this is the setup:&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Due: &#xA;&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;byte usbMsg[33]= {0};&#xA;// filled with dummy as example&#xA;usbMsg[1] = '00000001';// in[3];&#xA;usbMsg[2] = '00000001';//in[4];&#xA;usbMsg[3] = '00000001';//in[5];&#xA;.&#xA;.&#xA;.&#xA;SerialUSB.write(usbMsg, 33);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And on the Matlab side, I open the corresponding COM port and use a command like this one:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; a = fread(serialPort,3)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;this gives me:&lt;/p&gt;&#xA;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt; a =&#xA;&#xA;    49&#xA;    49&#xA;    49&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;which is the ASCII representation of the data I sent.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Can anyone explain to me why this happens and what I could do? As I understood &lt;code&gt;serial.write&lt;/code&gt; sends binary data and &lt;code&gt;fread&lt;/code&gt; reads binary data. &lt;/p&gt;&#xA;" OwnerUserId="21173" LastEditorUserId="37523" LastEditDate="2019-06-24T22:02:51.647" LastActivityDate="2019-06-24T22:02:51.647" Title="ArduinoDue - Matlab: SerialUSB.write() sends ASCII?" Tags="|serial|arduino-due|matlab|" AnswerCount="0" CommentCount="2" ContentLicense="CC BY-SA 4.0" />
  <row Id="29010" PostTypeId="1" AcceptedAnswerId="29011" CreationDate="2016-09-04T17:07:09.070" Score="3" ViewCount="504" Body="&lt;p&gt;Here are three use cases. Are all preferred or is the use of the &lt;code&gt;F()&lt;/code&gt; macro pointless on some?&lt;/p&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;Serial.println(F(&quot;some string&quot;); // definitely useful here&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;String str = F(&quot;some string&quot;);&#xA;Serial.println(str);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt;&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;int num = 5;&#xA;String str = F(&quot;some string with int &quot;);&#xA;str += (String)num;&#xA;Serial.println(str);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;" OwnerUserId="19838" LastActivityDate="2016-09-04T17:09:05.757" Title="Question of proper usage for F Macro" Tags="|memory-usage|" AnswerCount="1" CommentCount="3" ContentLicense="CC BY-SA 3.0" />
  <row Id="29011" PostTypeId="2" ParentId="29010" CreationDate="2016-09-04T17:09:05.757" Score="2" Body="&lt;p&gt;Any time String is involved F() becomes pointless. Avoid String like the plague if you value your memory integrity.&lt;/p&gt;&#xA;" OwnerUserId="4143" LastActivityDate="2016-09-04T17:09:05.757" CommentCount="5" ContentLicense="CC BY-SA 3.0" />
  <row Id="29012" PostTypeId="1" CreationDate="2016-09-04T17:22:35.003" Score="1" ViewCount="571" Body="&lt;p&gt;I am running the following sketch on an Arduino Uno using Arduino 1.6.8.&#xA;Strip is a WS2811 12V.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;lt;Adafruit_NeoPixel.h&amp;gt;&#xA;#define PIN 6&#xA;Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, PIN, NEO_GRB + NEO_KHZ800);&#xA;&#xA;void setup() {&#xA;  strip.begin();&#xA;  strip.show();&#xA;}&#xA;&#xA;void loop (){&#xA;   strip.setPixelColor(0, 255, 0, 255);&#xA;   strip.show(); &#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The problem is that the LED’s light in (Green) groups of three and what I want is individual control.&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;strip.setPixelColor(0, 255, 0, 255); Illuminates Pixels 0,1,2&#xA;strip.setPixelColor(1, 255, 0, 255); Illuminates Pixels 3,4,5&#xA;strip.setPixelColor(2, 255, 0, 255); Illuminates Pixels 6,7,8&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;And so forth.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Although this code uses NeoPixel I get exactly the same issue if I use the equivalent in FastLed.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Any pointers to what I am doing wrong would be appreciated.&lt;/p&gt;&#xA;" OwnerUserId="26350" LastEditorUserId="3917" LastEditDate="2016-09-04T18:19:28.163" LastActivityDate="2018-02-11T21:31:23.577" Title="Arduino only addresses 3 LED at a time" Tags="|neopixel|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29013" PostTypeId="2" ParentId="29012" CreationDate="2016-09-04T17:34:08.523" Score="3" Body="&lt;p&gt;LED strips with WS2811 and 12V are the ones with one driver and 3 RGB LEDs on it. These are interconnected so you just can't control less than whole group of three.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;If you need individual control, you have to get 5V variant with &lt;a href=&quot;http://www.tme.eu/gb/details/hc-f5v-30l-30_20/light-sources-led-ribbon/worldsemi/hc-f5v-30l-30led-wip20/&quot; rel=&quot;nofollow&quot;&gt;WS2812&lt;/a&gt;. &lt;/p&gt;&#xA;" OwnerUserId="23841" LastActivityDate="2016-09-04T17:34:08.523" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29014" PostTypeId="1" CreationDate="2016-09-04T17:49:10.430" Score="0" ViewCount="474" Body="&lt;p&gt;I have the Arduino Starter Kit and I'm on project 10 Zoetrope. I've removed the switch that changes the direction as I don't want the reverse to happen when I press a switch. I want the reverse to happen based on time. &lt;/p&gt;&#xA;&#xA;&lt;p&gt;For example using code, I want the reverse to happen every second (the motor moves clockwise for the first second, counterclockwise for the next second, clockwise for the third second etc.) &lt;/p&gt;&#xA;&#xA;&lt;p&gt;I've search for solutions but I haven't found anything yet. I had no luck with the &lt;code&gt;millis&lt;/code&gt; function as well.&lt;/p&gt;&#xA;" OwnerUserId="26344" LastEditorDisplayName="user24204" LastEditDate="2016-09-05T01:33:14.550" LastActivityDate="2016-12-04T05:21:01.637" Title="Reverse DC motor direction every second automatically" Tags="|arduino-uno|motor|" AnswerCount="1" CommentCount="0" ContentLicense="CC BY-SA 3.0" />
  <row Id="29015" PostTypeId="2" ParentId="14011" CreationDate="2016-09-04T18:04:06.163" Score="1" Body="&lt;p&gt;I had a problem similar to yours recently.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The thing that got me was that the RS232 from the Arduino is reverse. This is because it would usually go through a RS232 IC that produces +12 and -12 signals.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;A sensor or RS232 backpack on a LCD cannot deal with the reverse signals.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;The SoftwareSerial library has an undocumented feature that will reverse the RS232 output for you.  &lt;/p&gt;&#xA;&#xA;&lt;p&gt;When you configure your interface do the following:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;SoftwareSerial mySerial(3, 2, true);  &#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;The true option instructs the library to reverse the RS232 signals.&#xA;Hope this helps you out since this post was a long time ago.&lt;/p&gt;&#xA;" OwnerUserId="26354" LastEditorUserId="84" LastEditDate="2016-09-04T21:40:05.010" LastActivityDate="2016-09-04T21:40:05.010" CommentCount="1" ContentLicense="CC BY-SA 3.0" />
  <row Id="29017" PostTypeId="2" ParentId="29007" CreationDate="2016-09-04T18:21:49.887" Score="2" Body="&lt;p&gt;The datasheet of the ATmega328P (the main chip of the Uno) states:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;The ADC is optimized for analog signals with an output impedance of&#xA;  approximately 10&amp;nbsp;kΩ or less.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Th%C3%A9venin%27s_theorem&quot; rel=&quot;nofollow&quot;&gt;Thevenin equivalent&lt;/a&gt; output impedance of most taps of&#xA;your voltage ladder is higher than 10&amp;nbsp;kΩ. You 1&amp;nbsp;MΩ pulldown is&#xA;way beyond that limit. Cross talk from previously read channels is&#xA;exactly the symptom you expect from excess output impedance.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Taking each reading multiple times, until the value stabilizes, should&#xA;help. A buffer (e.g. an OP-amp set as a unit gain amplifier) is the&#xA;usual solution to this kind of impedance problems.&lt;/p&gt;&#xA;&#xA;&lt;hr&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Actually, the whole works perfectly with R as 220 and pull downs as&#xA;  10K. The problem comes when connecting more than 3 strings at the same&#xA;  time, on any tap, as the pull down resistors become part of the&#xA;  ladder (i belive).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;The pull down resistors will indeed have an effect on the potentials of&#xA;the voltage ladder, especially if you connect several strings. This&#xA;could be minimized by having the pull-downs be &lt;em&gt;a lot&lt;/em&gt; more resistive&#xA;than the resistors along the ladder, but then you would need very low&#xA;resistances along the ladder, which is not desirable because of current&#xA;consumption and heating.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;Here is an idea for an alternative solution: If you can spare 6 digital&#xA;pins, you could build for each analog input a pull-down circuit that is&#xA;switchable between a “strong pull” mode and a “weak pull” mode. Assuming&#xA;D0 is the “pull strength control” pin for A0, it would look like this:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;A0 ---+--- 1 kΩ --- D0&#xA;      |&#xA;     1 MΩ&#xA;      |&#xA;     GND&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;Whenever you want to read A0, you:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;set D0 to &lt;code&gt;OUTPUT&lt;/code&gt; &lt;code&gt;LOW&lt;/code&gt;, which creates a strong pull-down to ground&lt;/li&gt;&#xA;&lt;li&gt;take a couple of analogRead()s&lt;/li&gt;&#xA;&lt;li&gt;set D0 as &lt;code&gt;INPUT&lt;/code&gt;, which leaves only the weak 1&amp;nbsp;MΩ pull down&lt;/li&gt;&#xA;&lt;li&gt;take a couple of analogRead()s, keep the last one.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&#xA;&lt;p&gt;If A0 is not connected to the ladder, then the first 